diff --git a/dist/ngl.esm.js b/dist/ngl.esm.js index 74684035..c167084d 100644 --- a/dist/ngl.esm.js +++ b/dist/ngl.esm.js @@ -24,5 +24,5 @@ import{Vector2 as t,Vector3 as e,Matrix4 as i,Quaternion as r,Color as s,ShaderC * * @param {Float32Array} points - points * @param {Function} metric - metric - */class ka{constructor(t,e){this.points=t,this.metric=e,this.maxDepth=0,this.currentNode=0;const i=t.length/3,r=new Uint32Array(i);for(let t=0;tthis.maxDepth&&(this.maxDepth=t);const s=r-i;if(0===s)return-1;const n=4*this.currentNode,o=this.nodes;if(this.currentNode+=1,1===s)return o[n]=i,o[n+1]=-1,o[n+2]=-1,o[n+3]=e,n;const a=this.indices,c=this.points,l=i+Math.floor(s/2),h=t%3;let d,u,m,p,f,g=i,y=r-1;for(;y>g;){for(m=g+y>>1,p=c[3*a[m]+h],u=a[m],a[m]=a[y],a[y]=u,f=g,d=g;d-t[1])),s=this.nodes,n=this.points,o=this.indices,a=c=>{let l,h;const d=this.getNodeDepth(c)%3,u=3*o[s[c]],m=[n[u+0],n[u+1],n[u+2]],p=this.metric(t,m);function f(t,i){r.push([t,i]),r.size()>e&&r.pop()}const g=s[c+1],y=s[c+2];if(-1===y&&-1===g)return void((r.size()n[3*o[s[t]]+r])throw new Error("left child is > parent!");i+=this.verify(a,e+1)}if(-1!==c){if(n[3*o[s[c]]+r]0}isBackbone(){const t=this.residueType.backboneIndexList;return t.length>0&&t.includes(this.index-this.residueAtomOffset)}isPolymer(){if(this.structure.entityList.length>0)return this.entity.isPolymer();{const t=this.residueType.moleculeType;return 3===t||4===t||5===t}}isSidechain(){return this.isPolymer()&&!this.isBackbone()}isCg(){const t=this.residueType.backboneType;return 4===t||5===t||6===t}isTrace(){return this.index===this.residueType.traceAtomIndex+this.residueAtomOffset}isHetero(){return 1===this.residueType.hetero}isProtein(){return 3===this.residueType.moleculeType}isNucleic(){const t=this.residueType.moleculeType;return 4===t||5===t}isRna(){return 4===this.residueType.moleculeType}isDna(){return 5===this.residueType.moleculeType}isWater(){return 1===this.residueType.moleculeType}isIon(){return 2===this.residueType.moleculeType}isSaccharide(){return 6===this.residueType.moleculeType}isHelix(){return Hs.includes(this.sstruc)}isSheet(){return Ws.includes(this.sstruc)}isTurn(){return qs.includes(this.sstruc)&&this.isProtein()}isBonded(){return 0!==this.bondHash.countArray[this.index]}isRing(){return void 0!==this.residueType.getRings().atomRings[this.index-this.residueAtomOffset]}isAromatic(){return 1===this.aromatic}isPolarHydrogen(){let t=!1;return 1!==this.number||(t=!this.hasBondToElement(6)),t}isMetal(){return this.atomType.isMetal()}isNonmetal(){return this.atomType.isNonmetal()}isMetalloid(){return this.atomType.isMetalloid()}isHalogen(){return this.atomType.isHalogen()}isDiatomicNonmetal(){return this.atomType.isDiatomicNonmetal()}isPolyatomicNonmetal(){return this.atomType.isPolyatomicNonmetal()}isAlkaliMetal(){return this.atomType.isAlkaliMetal()}isAlkalineEarthMetal(){return this.atomType.isAlkalineEarthMetal()}isNobleGas(){return this.atomType.isNobleGas()}isTransitionMetal(){return this.atomType.isTransitionMetal()}isPostTransitionMetal(){return this.atomType.isPostTransitionMetal()}isLanthanide(){return this.atomType.isLanthanide()}isActinide(){return this.atomType.isActinide()}getDefaultValence(){return this.atomType.getDefaultValence()}getValenceList(){return this.atomType.getValenceList()}getOuterShellElectronCount(){return this.atomType.getOuterShellElectronCount()}distanceTo(t){const e=this.atomStore,i=t.atomStore,r=this.index,s=t.index,n=e.x[r]-i.x[s],o=e.y[r]-i.y[s],a=e.z[r]-i.z[s],c=n*n+o*o+a*a;return Math.sqrt(c)}connectedTo(t){const e=this.atomStore,i=t.atomStore,r=this.index,s=t.index;if(e.altloc&&i.altloc){const t=e.altloc[r],n=i.altloc[s];if(0!==t&&0!==n&&32!==t&&32!==n&&t!==n)return!1}const n=e.x[r]-i.x[s],o=e.y[r]-i.y[s],a=e.z[r]-i.z[s],c=n*n+o*o+a*a;if(c<48&&this.isCg())return!0;if(isNaN(c))return!1;const l=this.covalent+t.covalent,h=l+.3,d=l-.5;return cd*d}positionFromArray(t,e=0){return this.x=t[e+0],this.y=t[e+1],this.z=t[e+2],this}positionToArray(t=[],e=0){const i=this.index,r=this.atomStore;return t[e+0]=r.x[i],t[e+1]=r.y[i],t[e+2]=r.z[i],t}positionToVector3(t){return void 0===t&&(t=new e),t.x=this.x,t.y=this.y,t.z=this.z,t}positionFromVector3(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}positionAdd(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}positionSub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}getResidueBonds(t=!1){const e=this.residueAtomOffset,i=this.index-this.residueAtomOffset,r=this.residueType.getBonds(),s=r.atomIndices1,n=r.atomIndices2;let o,a,c,l;for(t||(l=[]),o=s.indexOf(i);-1!==o;){if(c=n[o]+e,!l)return c;l.push(c),o=s.indexOf(i,o+1)}for(a=n.indexOf(i);-1!==a;){if(c=s[a]+e,!l)return c;l.push(c),a=n.indexOf(i,a+1)}return l}qualifiedName(t=!1){var e="";return this.resname&&!t&&(e+="["+this.resname+"]"),void 0!==this.resno&&(e+=this.resno),this.inscode&&(e+="^"+this.inscode),this.chainname&&(e+=":"+this.chainname),this.atomname&&(e+="."+this.atomname),this.altloc&&(e+="%"+this.altloc),this.structure.modelStore.count>1&&(e+="/"+this.modelIndex),e}clone(){return new Ma(this.structure,this.index)}toObject(){return{index:this.index,residueIndex:this.residueIndex,resname:this.resname,x:this.x,y:this.y,z:this.z,element:this.element,chainname:this.chainname,resno:this.resno,serial:this.serial,vdw:this.vdw,covalent:this.covalent,hetero:this.hetero,bfactor:this.bfactor,altloc:this.altloc,atomname:this.atomname,modelIndex:this.modelIndex}}}function Ta(t,e){const i=t[0]-e[0],r=t[1]-e[1],s=t[2]-e[2];return i*i+r*r+s*s}function Ba(t,e){return Math.sqrt(Ta(t,e))}const Da=new Float32Array(3);class $a{constructor(t,e=!1){De&&Me.time("Kdtree build");const i=e?Ta:Ba,r=new Float32Array(3*t.atomCount),s=new Uint32Array(t.atomCount);let n=0;t.eachAtom((function(t){r[n+0]=t.x,r[n+1]=t.y,r[n+2]=t.z,s[n/3]=t.index,n+=3})),this.atomIndices=s,this.points=r,this.kdtree=new ka(r,i),De&&Me.timeEnd("Kdtree build")}nearest(t,i,r){t instanceof e?t.toArray(Da):t instanceof Ma&&t.positionToArray(Da);const s=this.kdtree.nearest(Da,i,r),n=this.kdtree.indices,o=this.kdtree.nodes,a=this.atomIndices,c=[];for(let t=0,e=s.length;t":"3/4-Z","?":"X-Y","@":"Y-X",A:"Z+1/3",B:"Z+2/3",C:"X+2/3",D:"Y+1/3",E:"-Y+2/3",F:"X-Y+1/3",G:"Y-X+2/3",H:"-X+1/3",I:"X+1/3",J:"Y+2/3",K:"-Y+1/3",L:"X-Y+2/3",M:"Y-X+1/3",N:"-X+2/3",O:"2/3+X",P:"1/3+Y",Q:"1/3+Z",R:"2/3-Y",S:"1/3+X-Y",T:"2/3+Y-X",U:"1/3-X",V:"2/3-X",W:"1/3-Y",X:"1/3-Z",Y:"2/3+Y",Z:"1/3+Y-X","[":"2/3+X-Y","]":"1/3+X","^":"2/3+Z",_:"2/3-Z","`":"5/6+Z",a:"1/6+Z",b:"5/6-Z",c:"1/6-Z",d:"Z+5/6",e:"Z+1/6",f:"Z+1/4",g:"+Y"},Ra={"P 1":" !#","P -1":" !#$%&","P 1 2 1":" !#$!&","P 1 21 1":" !#$'&","C 1 2 1":" !#$!&()#*)&","P 1 m 1":" !# %#","P 1 c 1":" !# %+","C 1 m 1":" !# %#()#(,#","C 1 c 1":" !# %+()#(,+","P 1 2/m 1":" !# %#$!&$%&","P 1 21/m 1":" !#$)&$%& ,#","C 1 2/m 1":" !# %#$!&$%&()#(,#*)&*,&","P 1 2/c 1":" !#$!-$%& %+","P 1 21/c 1":" !#$%&$)- ,+","C 1 2/c 1":" !#$!-$%& %+()#*)-*,&(,+","P 2 2 2":" !#$%#$!& %&","P 2 2 21":" !#$%+$!- %&","P 21 21 2":" !#$%#*)&(,&","P 21 21 21":" !#*%+$)-(,&","C 2 2 21":" !#$%+$!- %&()#*,+*)-(,&","C 2 2 2":" !#$%#$!& %&()#*,#*)&(,&","F 2 2 2":" !#$%#$!& %& )+$,+$)- ,-(!+*%+*!-(%-()#*,#*)&(,&","I 2 2 2":" !#$%# %&$!&.'/01/.120'2","I 21 21 21":" !#*%+$)-(,&()+$,#*!& %-","P m m 2":" !#$%# %#$!#","P m c 21":" !#$%+ %+$!#","P c c 2":" !#$%# %+$!+","P m a 2":" !#$%#(%#*!#","P c a 21":" !#$%+(%#*!+","P n c 2":" !#$%# ,+$)+","P m n 21":" !#*%+(%+$!#","P b a 2":" !#$%#(,#*)#","P n a 21":" !#$%+(,#*)+","P n n 2":" !#$%#(,+*)+","C m m 2":" !#$%# %#$!#()#*,#(,#*)#","C m c 21":" !#$%+ %+$!#()#*,+(,+*)#","C c c 2":" !#$%# %+$!+()#*,#(,+*)+","A m m 2":" !#$%# %#$!# )+$,+ ,+$)+","A b m 2":" !#$%# ,#$)# )+$,+ %+$!+","A m a 2":" !#$%#(%#*!# )+$,+(,+*)+","A b a 2":" !#$%#(,#*)# )+$,+(%+*!+","F m m 2":" !#$%# %#$!# )+$,+ ,+$)+(!+*%+(%+*!+()#*,#(,#*)#","F d d 2":" !#$%#345675 )+$,+3896:9(!+*%+;49<79()#*,#;85<:5","I m m 2":" !#$%# %#$!#()+*,+(,+*)+","I b a 2":" !#$%#(,#*)#()+*,+ %+$!+","I m a 2":" !#$%#(%#*!#()+*,+ ,+$)+","P 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!#","P 2/n 2/n 2/n":" !#$%#$!& %&*,-()-(,+*)+","P 2/c 2/c 2/m":" !#$%#$!- %-$%& !& %+$!+","P 2/b 2/a 2/n":" !#$%#$!& %&*,&()&(,#*)#","P 21/m 2/m 2/a":" !#*%#$!&(%&$%&(!& %#*!#","P 2/n 21/n 2/a":" !#*%#*)- ,-$%&(!&(,+$)+","P 2/m 2/n 21/a":" !#*%+*!- %&$%&(!-(%+$!#","P 21/c 2/c 2/a":" !#*%#$!-(%-$%&(!& %+*!+","P 21/b 21/a 2/m":" !#$%#*)&(,&$%& !&(,#*)#","P 21/c 21/c 2/n":" !#*,#$)-(%-$%&()& ,+*!+","P 2/b 21/c 21/m":" !#$%+$)- ,&$%& !- ,+$)#","P 21/n 21/n 2/m":" !#$%#*)-(,-$%& !&(,+*)+","P 21/m 21/m 2/n":" !#$%#*'&.,&*,&.'& %#$!#","P 21/b 2/c 21/n":" !#*,+$!-(,&$%&()- %+*)#","P 21/b 21/c 21/a":" !#*%+$)-(,&$%&(!- ,+*)#","P 21/n 21/m 21/a":" !#0%/$'&.12$%&.!2 1#0'/","C 2/m 2/c 21/m":" !#$%+$!- %&$%& !- %+$!#()#*,+*)-(,&*,&()-(,+*)#","C 2/m 2/c 21/a":" !#$,+$)- %&$%& )- ,+$!#()#*%+*!-(,&*,&(!-(%+*)#","C 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!#()#*,#*)&(,&*,&()&(,#*)#","C 2/c 2/c 2/m":" !#$%#$!- %-$%& !& %+$!+()#*,#*)-(,-*,&()&(,+*)+","C 2/m 2/m 2/a":" !#$,#$)& %&$%& )& ,#$!#()#*%#*!&(,&*,&(!&(%#*)#","C 2/c 2/c 2/a":" !#*,#$!&(,&$,-(!- ,+*!+()#$%#*)& %&*%- )-(%+$)+","F 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!# )+$,+$)- ,-$,- )- ,+$)+(!+*%+*!-(%-*%-(!-(%+*!+()#*,#*)&(,&*,&()&(,#*)#","F 2/d 2/d 2/d":" !#$%#$!& %&64=37=345675 )+$,+$)- ,-68>3:>3896:9(!+*%+*!-(%-<4>;7>;49<79()#*,#*)&(,&<8=;:=;85<:5","I 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!#()+*,+*)-(,-*,-()-(,+*)+","I 2/b 2/a 2/m":" !#$%#*)&(,&$%& !&(,#*)#()+*,+$!- %-*,-()- %+$!+","I 21/b 21/c 21/a":" !#*%+$)-(,&$%&(!- ,+*)#()+$,#*!& %-*,- )&(%#$!+","I 21/m 21/m 21/a":" !#$,#$)& %&$%& )& ,#$!#()+*%+*!-(,-*,-(!-(%+*)+","P 4":" !#$%#% #!$#","P 41":" !#$%+% 5!$9","P 42":" !#$%#% +!$+","P 43":" !#$%+% 9!$5","I 4":" !#$%#% #!$#()+*,+,(+)*+","I 41":" !#*,+%(5)$9()+$%#, 9!*5","P -4":" !#$%#!$&% &","I -4":" !#$%#!$&% &()+*,+)*-,(-","P 4/m":" !#$%#% #!$#$%& !&!$&% &","P 42/m":" !#$%#% +!$+$%& !&!$-% -","P 4/n":" !#$%#,(#)*#*,&()&!$&% &","P 42/n":" !#$%#,(+)*+*,-()-!$&% &","I 4/m":" !#$%#% #!$#$%& !&!$&% &()+*,+,(+)*+*,-()-)*-,(-","I 41/a":" !#*,+%(5)$9$,=(!>!$&,(-()+$%#, 9!*5*%> )=)*-% &","P 4 2 2":" !#$%#% #!$#$!& %&! &%$&","P 4 21 2":" !#$%#,(#)*#*)&(,&! &%$&","P 41 2 2":" !#$%+% 5!$9$!& %-! >%$=","P 41 21 2":" !#$%+,(5)*9*)=(,>! &%$-","P 42 2 2":" !#$%#% +!$+$!& %&! -%$-","P 42 21 2":" !#$%#,(+)*+*)-(,-! &%$&","P 43 2 2":" !#$%+% 9!$5$!& %-! =%$>","P 43 21 2":" !#$%+,(9)*5*)>(,=! &%$-","I 4 2 2":" !#$%#% #!$#$!& %&! &%$&()+*,+,(+)*+*)-(,-)(-,*-","I 41 2 2":" !#*,+%(5)$9*!> ,=)(-%$&()+$%#, 9!*5$)=(%>! &,*-","P 4 m m":" !#$%#% #!$# %#$!#%$#! #","P 4 b m":" !#$%#% #!$#(,#*)#,*#)(#","P 42 c m":" !#$%#% +!$+ %+$!+%$#! #","P 42 n m":" !#$%#,(+)*+(,+*)+%$#! #","P 4 c c":" !#$%#% #!$# %+$!+%$+! +","P 4 n c":" !#$%#% #!$#(,+*)+,*+)(+","P 42 m c":" !#$%#% +!$+ %#$!#%$+! +","P 42 b c":" !#$%#% +!$+(,#*)#,*+)(+","I 4 m m":" !#$%#% #!$# %#$!#%$#! #()+*,+,(+)*+(,+*)+,*+)(+","I 4 c m":" !#$%#% #!$# %+$!+%$+! +()+*,+,(+)*+(,#*)#,*#)(#","I 41 m d":" !#*,+%(5)$9 %#*)+%*5) 9()+$%#, 9!*5(,+$!#,$9!(5","I 41 c d":" !#*,+%(5)$9 %+*)#%*9) 5()+$%#, 9!*5(,#$!+,$5!(9","P -4 2 m":" !#$%#% &!$&$!& %&%$#! #","P -4 2 c":" !#$%#% &!$&$!- %-%$+! +","P -4 21 m":" !#$%#% &!$&*)&(,&,*#)(#","P -4 21 c":" !#$%#% &!$&*)-(,-,*+)(+","P -4 m 2":" !#$%#!$&% & %#$!#! &%$&","P -4 c 2":" !#$%#% &!$& %+$!+! -%$-","P -4 b 2":" !#$%#% &!$&(,#*)#)(&,*&","P -4 n 2":" !#$%#% &!$&(,+*)+)(-,*-","I -4 m 2":" !#$%#% &!$& %#$!#! &%$&()+*,+,(-)*-(,+*)+)(-,*-","I -4 c 2":" !#$%#% &!$& %+$!+! -%$-()+*,+,(-)*-(,#*)#)(&,*&","I -4 2 m":" !#$%#% &!$&$!& %&%$#! #()+*,+,(-)*-*)-(,-,*+)(+","I -4 2 d":" !#$%#% &!$&*!>(%>,$9) 9()+*,+,(-)*-$)= ,=%*5!(5","P 4/m 2/m 2/m":" !#$%#% #!$#$!& %&! &%$&$%& !&!$&% & %#$!#%$#! #","P 4/m 2/c 2/c":" !#$%#% #!$#$!- %-! -%$-$%& !&!$&% & %+$!+%$+! +","P 4/n 2/b 2/m":" !#$%#% #!$#$!& %&! &%$&*,&()&)*&,(&(,#*)#,*#)(#","P 4/n 2/n 2/c":" !#$%#% #!$#$!& %&! &%$&*,-()-)*-,(-(,+*)+,*+)(+","P 4/m 21/b 2/m":" !#$%#% #!$#*)&(,&)(&,*&$%& !&!$&% &(,#*)#,*#)(#","P 4/m 21/n 2/c":" !#$%#% #!$#*)-(,-)(-,*-$%& !&!$&% &(,+*)+,*+)(+","P 4/n 21/m 2/m":" !#$%#,(#)*#*)&(,&! &%$&*,&()&!$&% & %#$!#,*#)(#","P 4/n 2/c 2/c":" !#$%#,(#)*#*)-(,-! -%$-*,&()&!$&% & %+$!+,*+)(+","P 42/m 2/m 2/c":" !#$%#% +!$+$!& %&! -%$-$%& !&!$-% - %#$!#%$+! +","P 42/m 2/c 2/m":" !#$%#% +!$+$!- %-! &%$&$%& !&!$-% - %+$!+%$#! #","P 42/n 2/b 2/c":" !#$%#,(+)*+$!- %-)(&,*&*,-()-!$&% &(,#*)#%$+! +","P 42/n 2/n 2/m":" !#$%#,(+)*+$!& %&)(-,*-*,-()-!$&% &(,+*)+%$#! #","P 42/m 21/b 2/c":" !#$%#% +!$+*)&(,&)(-,*-$%& !&!$-% -(,#*)#,*+)(+","P 42/m 21/n 2/m":" !#$%#,./'*/*'-.,-! &%$&$%& !&'*-,.-.,/*'/%$#! #","P 42/n 21/m 2/c":" !#$%#,(+)*+*)-(,-! &%$&*,-()-!$&% & %#$!#,*+)(+","P 42/n 21/c 2/m":" !#$%#,(+)*+*)&(,&! -%$-*,-()-!$&% & %+$!+,*#)(#","I 4/m 2/m 2/m":" !#$%#% #!$#$!& %&! &%$&$%& !&!$&% & %#$!#%$#! #()+*,+,(+)*+*)-(,-)(-,*-*,-()-)*-,(-(,+*)+,*+)(+","I 4/m 2/c 2/m":" !#$%#% #!$#$!- %-! -%$-$%& !&!$&% & %+$!+%$+! +()+*,+,(+)*+*)&(,&)(&,*&*,-()-)*-,(-(,#*)#,*#)(#","I 41/a 2/m 2/d":" !#*,+%(5)$9*!> ,=)(-%$&$,=(!>!$&,(-(,+$!#,$9!(5()+$%#, 9!*5$)=(%>! &,*-*%> )=)*-% & %#*)+%*5) 9","I 41/a 2/c 2/d":" !#*,+%(5)$9*!= ,>)(&%$-$,=(!>!$&,(-(,#$!+,$5!(9()+$%#, 9!*5$)>(%=! -,*&*%> )=)*-% & %+*)#%*9) 5","P 3":" !#%?#@$#","P 31":" !#%?A@$B","P 32":" !#%?B@$A","H 3":" !#%?#@$#CDAEFAGHAIJBKLBMNB","R 3":" !## !!# ","P -3":" !#%?#@$#$%&!@&? &","H -3":" !#%?#@$#$%&!@&? &OPQRSQTUQVWXYZX[]X]Y^W[^ZV^UR_PT_SO_","R -3":" !## !!# $%&&$%%&$","P 3 1 2":" !#%?#@$#%$&@!& ?&","P 3 2 1":" !#%?#@$#! &?%&$@&","P 31 1 2":" !#%?Q@$^%$_@!X ?&","P 31 2 1":" !#%?A@$B! &?%_$@X","P 32 1 2":" !#%?^@$Q%$X@!_ ?&","P 32 2 1":" !#%?B@$A! &?%X$@_","H 3 2":" !#%?#@$#! &?%&$@&OPQRSQTUQY]X[WXVZX]Y^W[^ZV^PO_SR_UT_","R 3 2":" !## !!# %$&$&%&%$","P 3 m 1":" !#%?#@$#%$#@!# ?#","P 3 1 m":" !#%?#@$#! #?%#$@#","P 3 c 1":" !#%?#@$#%$+@!+ ?+","P 3 1 c":" !#%?#@$#! +?%+$@+","H 3 m":" !#%?#@$#%$#@!# ?#OPQRSQTUQRUQTPQOSQ]Y^W[^ZV^WV^ZY^][^","R 3 m":" !## !!# ! # #!#! ","H 3 c":" !#%?#@$#%$+@!+ ?+OPQRSQTUQRU`TP`OS`]Y^W[^ZV^WVaZYa][a","R 3 c":" !## !!# '././'/'.","P -3 1 2/m":" !#%?#@$#%$&@!& ?&$%&!@&? &! #?%#$@#","P -3 1 2/c":" !#%?#@$#%$-@!- ?-$%&!@&? &! +?%+$@+","P -3 2/m 1":" !#%?#@$#! &?%&$@&$%&!@&? &%$#@!# ?#","P -3 2/c 1":" !#%?#@$#! -?%-$@-$%&!@&? &%$+@!+ ?+","H -3 2/m":" !#%?#@$#! &?%&$@&$%&!@&? &%$#@!# ?#OPQRSQTUQY]X[WXVZXVWXYZX[]XRUQTPQOSQ]Y^W[^ZV^PO_SR_UT_UR_PT_SO_WV^ZY^][^","R -3 2/m":" !## !!# %$&$&%&%$$%&&$%%&$! # #!#! ","H -3 2/c":" !#%?#@$#! -?%-$@-$%&!@&? &%$+@!+ ?+OPQRSQTUQY]b[WbVZbVWXYZX[]XRU`TP`OS`]Y^W[^ZV^POcSRcUTcUR_PT_SO_WVaZYa][a","R -3 2/c":" !## !!# 102021210$%&&$%%&$'././'/'.","P 6":" !#%?#@$#$%#!@#? #","P 61":" !#%?A@$B$%/!@d? e","P 65":" !#%?B@$A$%/!@e? d","P 62":" !#%?^@$Q$%#!@^? Q","P 64":" !#%?Q@$^$%#!@Q? ^","P 63":" !#%?#@$#$%+!@+? +","P -6":" !#%?#@$# !&%?&@$&","P 6/m":" !#%?#@$#$%#!@#? #$%&!@&? & !&%?&@$&","P 63/m":" !#%?#@$#$%+!@+? +$%&!@&? & !-%?-@$-","P 6 2 2":" !#%?#@$#$%#!@#? #! &?%&$@&%$&@!& ?&","P 61 2 2":" !#%?Q@$^$%+!@`? a! X?%&$@_%$b@!- ?c","P 65 2 2":" !#%?^@$Q$%+!@a? `! _?%&$@X%$c@!- ?b","P 62 2 2":" !#%?^@$Q$%#!@^? Q! _?%&$@X%$_@!& ?X","P 64 2 2":" !#%?Q@$^$%#!@Q? ^! X?%&$@_%$X@!& ?_","P 63 2 2":" !#%?#@$#$%+!@+? +! &?%&$@&%$-@!- ?-","P 6 m m":" !#%?#@$#$%#!@#? #%$#@!# ?#! #?%#$@#","P 6 c c":" !#%?#@$#$%#!@#? #%$+@!+ ?+! +?%+$@+","P 63 c m":" !#%?#@$#$%+!@+? +%$+@!+ ?+! #?%#$@#","P 63 m c":" !#%?#@$#$%+!@+? +%$#@!# ?#! +?%+$@+","P -6 m 2":" !#%?#@$# !&%?&@$&%$#@!# ?#%$&@!& ?&","P -6 c 2":" !#%?#@$# !-%?-@$-%$+@!+ ?+%$&@!& ?&","P -6 2 m":" !#%?#@$# !&%?&@$&! &?%&$@&! #?%#$@#","P -6 2 c":" !#%?#@$# !-%?-@$-! &?%&$@&! +?%+$@+","P 6/m 2/m 2/m":" !#%?#@$#$%#!@#? #! &?%&$@&%$&@!& ?&$%&!@&? & !&@$&%?&%$#@!# ?#! #?%#$@#","P 6/m 2/c 2/c":" !#%?#@$#$%#!@#? #! -?%-$@-%$-@!- ?-$%&!@&? & !&@$&%?&%$+@!+ ?+! +?%+$@+","P 63/m 2/c 2/m":" !#%?#@$#$%+!@+? +! -?%-$@-%$&@!& ?&$%&!@&? & !-@$-%?-%$+@!+ ?+! #?%#$@#","P 63/m 2/m 2/c":" !#%?#@$#$%+!@+? +! &?%&$@&%$-@!- ?-$%&!@&? & !-@$-%?-%$#@!# ?#! +?%+$@+","P 2 3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ","F 2 3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ","I 2 3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-(","P 21 3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(","I 21 3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- ","P 2/m -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$","P 2/n -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& *,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*","F 2/m -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$ )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-($,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(*%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- *,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$","F 2/d -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& 64=37=345675=64=375345674=67=3453756 )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(68>3:>3896:9=<8=;:5;85<:4><7>;49;79<(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(<4>;7>;49<79>68>3:93896:8=<:=;85;:5<()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- <8=;:=;8f<:f><4>;79;49<78>6:>3893:96","I 2/m -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-(*,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*","P 21/a -3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&($%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*","I 21/a -3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&($%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*()+$,#*g& %-+()#$,&*!- %)+(,#$!&*%- *,- )&(%#$!+-*,& )#(%+$!,-*)& %#(!+$","P 4 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$","P 42 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*","F 4 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$ )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(-%*-!*+%(+ +,$+)$-, -)#)*#,(&)(&,*(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() -,$-)$+, +(#,*#)*&,(&)+!*+%(-!(-%*()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(&,*&)*#,(#(+%*+!*-%(-!+)$+, -) -,$","F 41 3 2":" !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=46 )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<(!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>86","I 4 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*","P 43 3 2":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(7;>46=:<5839398<5:6=4;>75:<983>7;=46","P 41 3 2":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<","I 41 3 2":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- 7;>46=:<5839398<5:6=4;>75:<983>7;=46","P -4 3 m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% ","F -4 3 m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(+%*+!*-%(- +)$+,$-) -,#)(#,*&)*&,((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() +,$+)$-, -(#)*#,*&)(&,+!(+%*-!*-%(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(#,*#)*&,(&(+!*+%*-!(-%+) +,$-)$-, ","I -4 3 m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,(","P -4 3 n":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,(","F -4 3 c":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,( )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-() #,$#)$&, &(#!*#%*&!(&%+! +%$-!$-% (!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(!(#%*#!*&%(& +!$+%$-! -%#) #,$&)$&, ()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ! +%$+!$-% - #)$#,$&) &,#!(#%*&!*&%(","I -4 3 d":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(7354<9:6>8;=357<946>:;=857394<>:6=8;()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- :;98657<=43>;9:658<=73>49:;586=7<>43","P 4/m -3 2/m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ","P 4/n -3 2/n":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$*,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(","P 42/m -3 2/n":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(","P 42/n -3 2/m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,**,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ","F 4/m -3 2/m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(-%*-!*+%(+ +,$+)$-, -)#)*#,(&)(&,*$,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*%*+!(+%(-!*-$-) -, +)$+,&,(&)*#,*#)((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() -,$-)$+, +(#,*#)*&,(&)+!*+%(-!(-%**%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*,$+) +, -)$-*&)(&,(#)*#,-%(-!*+%*+!(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(&,*&)*#,(#(+%*+!*-%(-!+)$+, -) -,$*,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$,*#)(#,(&)*&*-!(-%(+!*+%-, -)$+,$+) ","F 4/m -3 2/c":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)( )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-() &,$&)$#, #(#%*#!*&%(&!+!$+% -! -%$$,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*,$#) #, &)$&*&!(&%(#!*#%-% -!$+%$+! (!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(!(&%*&!*#%(# +%$+!$-% -!#)$#, &) &,$*%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*%*#!(#%(&!*&$-! -% +!$+%&, &)$#,$#) ()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ! -%$-!$+% + #,$#)$&, &)#!*#%(&!(&%**,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$%$+! +% -!$-$&) &, #)$#,&%(&!*#%*#!(","F 41/d -3 2/m":" !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=4664=3:>;85<79=64>3:5;89<74=6:>385;79<,$+! #%(-)*&*&)(-% #!$+,-%(&)*+,$#! )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<68>37=;49<:5=<8>;753496:4><:=;893756,*#!(+% &)$-*-!(&, +)$#%-, &!$+%*#)((!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<<4>;:=389675>68=379;45<:8=<7>;453:96%$#) +,(&!*-$&! -,(#)*+%&% -)$#,*+!(()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>86<8=;7>3456:9><4=;:9385678>67=349;:5<%*+)(#, -!$&$-) &%(+!*#,&,(-!*#%$+) ","F 41/d -3 2/c":" !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=46<8>;7=3496:5><8=;793456:8><7=;493:56%*#)(+, &!$-$-! &,(+)*#%&, -!$#%*+)( )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<<4=;:>385679>64=3:9;85<78=67>345;:9<%$+) #,(-!*&$&) -%(#!*+,&%(-)*#,$+! (!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<68=37>;45<:9=<4>;:5389674>6:=389;75<,*+!(#% -)$&*-)(&% +!$#,-,(&!*+%$#) ()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>8664>3:=;89<75=68>375;49<:4=<:>;853796,$#! +%(&)*-*&!(-, #)$+%-% &)$+,*#!(","I 4/m -3 2/m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,**,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(","I 41/a -3 2/d":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<$%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*4<97358;=:6>6>:;=8357<94=8;>:694<573()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- 7;>46=:<5839398<5:6=4;>75:<983>7;=46*,- )&(%#$!+-*,& )#(%+$!,-*)& %#(!+$865:;943>7<=<=73>4;9:658>43=7<5869:;","P 1 1 2":" !#$%#","P 1 1 21":" !#$%+","B 1 1 2":" !#$%#(g+*%+","A 1 2 1":" !#$!& )+$)-","C 1 21 1":" !#$)&()#*!&","I 1 2 1":" !#$!&.'/0'2","I 1 21 1":" !#$)&.'/0!-","P 1 1 m":" !# !&","P 1 1 b":" !# )&","B 1 1 m":" !# !&(!+(!-","B 1 1 b":" !# )&(!+()-","P 1 1 2/m":" !# !&$%#$%&","P 1 1 21/m":" !#$%+$%& !-","B 1 1 2/m":" !# !&$%#$%&(!+(!-*%+*%-","P 1 1 2/b":" !#$,#$%& )&","P 1 1 21/b":" !#$%&$,+ )-","B 1 1 2/b":" !#$,#$%& )&(!+*,+*%-()-","P 21 2 2":" !#$!&(%&*%#","P 2 21 2":" !# ,&$)&$%#","P 21 21 2 (a)":" !#*,#.%&$'&","P 21 2 21":" !#$!&(%-*%+","P 2 21 21":" !# %&$)-$,+","C 2 2 21a)":" !#*%+(,&$)-()#$,+ %&*!-","C 2 2 2a":" !#*,#.%&$'&()#$%# ,&*!&","F 2 2 2a":" !#*,#.%&$'& '/*%/.12$!2.!/$,/ %20'2.'#$%# 1&0!&","I 2 2 2a":" !#*,#.%&$'&()+$%+*!- ,-","P 21/m 21/m 2/n a":" !#*,#$)&(%&$%&.'& ,#*!#","P 42 21 2a":" !#*,#%.+'$+$'&.%&! -,*-","I 2 3a":" !#*,#.%&$'&!# ,- '&$%/$# !-*!/$%&.%()+$%+ ,-*!-)+(%&(!-*,#*+()&$)#*,- ,"},Ea=/^[1-9]$/;function Fa(t){let e="";return t.length>0&&(e=":"+gt(t).join(" OR :")),new pe(e)}class La{constructor(t=""){this.name=t,this.partList=[]}get type(){return"Assembly"}addPart(t,e){const i=new Na(t,e);return this.partList.push(i),i}getAtomCount(t){return this.partList.reduce(((e,i)=>e+i.getAtomCount(t)),0)}getResidueCount(t){return this.partList.reduce(((e,i)=>e+i.getResidueCount(t)),0)}getInstanceCount(){let t=0;return this.partList.forEach((function(e){t+=e.matrixList.length})),t}isIdentity(t){if(1!==this.partList.length)return!1;const e=this.partList[0];if(1!==e.matrixList.length)return!1;if(!(new i).equals(e.matrixList[0]))return!1;let r=[];return t.eachChain((function(t){r.push(t.chainname)})),r=gt(r),e.chainList.length===r.length}getBoundingBox(t){const e=new a;return this.partList.forEach((function(i){const r=i.getBoundingBox(t);e.expandByPoint(r.min),e.expandByPoint(r.max)})),e}getCenter(t){return this.getBoundingBox(t).getCenter(new e)}getSelection(){let t=[];return this.partList.forEach((function(e){t=t.concat(e.chainList)})),Fa(t)}}class Na{constructor(t=[],e=[]){this.matrixList=t,this.chainList=e}get type(){return"AssemblyPart"}_getCount(t,e){let i=0;return t.eachChain((t=>{(0===this.chainList.length||this.chainList.includes(t.chainname))&&(i+=t[e])})),this.matrixList.length*i}getAtomCount(t){return this._getCount(t,"atomCount")}getResidueCount(t){return this._getCount(t,"residueCount")}getBoundingBox(t){const e=new a,i=new a,r=this.getSelection(),s=t.getBoundingBox(r);return this.matrixList.forEach((function(t){i.copy(s).applyMatrix4(t),e.expandByPoint(i.min),e.expandByPoint(i.max)})),e}getSelection(){return Fa(this.chainList)}getView(t){const e=this.getSelection();return e?t.getView(e):t}getInstanceList(){const t=[];for(let e=0,i=this.matrixList.length;e0&&this.addResidueType(this.ri-1),l.growIfFull(),l.resno[this.ri]=s,void 0!==o&&(l.sstruc[this.ri]=o.charCodeAt(0)),void 0!==a&&(l.inscode[this.ri]=a.charCodeAt(0)),l.atomOffset[this.ri]=this.ai,l.atomCount[this.ri]=0,l.count+=1,l.chainIndex[this.ri]=this.ci,h.residueCount[this.ci]+=1),c.count+=1,c.residueIndex[this.ai]=this.ri,l.atomCount[this.ri]+=1,this.currentModelindex=t,this.currentChainid=i,this.currentResname=r,this.currentResno=s,this.currentInscode=a,this.currentHetero=n}finalize(){this.previousResname=this.currentResname,this.previousHetero=this.currentHetero,this.ri>-1&&this.addResidueType(this.ri)}}function Va(t,e){if(!e)return;De&&Me.time("assignSecondaryStructure");const i=[];t.eachModel((function(t){t.eachChain((function(t){i.push(t.chainname)}))}));const r=i.slice().sort(),s=[];r.forEach((function(t){s.push(i.indexOf(t))}));const n=e.helices.filter((function(t){return pt(r,t[0])>=0}));n.sort((function(t,e){const i=t[0],n=e[0],o=t[1],a=e[1];if(i===n)return o===a?0:o=0}));a.sort((function(t,e){const i=t[0],n=e[0];if(i===n)return 0;const o=pt(r,i),a=pt(r,n);return s[o]=t.residueCount)continue;o.index=n+s,a.index=n+s+e,c.index=o.traceAtomIndex,l.index=a.traceAtomIndex;const h=c.distanceTo(l);if(Math.abs(h-i[e-2])>r)return!1}return!0},i=function(e,i){return t(e,i,[5.45,5.18,6.37],2.1)},r=function(e,i){return t(e,i,[6.1,10.4,13],1.42)};return function(t){De&&Me.time("calculateSecondaryStructure"),t.eachPolymer((function(t){if(t.residueCount<4)return;if(t.isCg())!function(t){const i=t.residueStore,r=t.residueIndexStart,s=new Pa(t).position,n=new e,o=new e;for(let e=0,a=t.residueCount;e1&&s.bending[e]<20&&(i.sstruc[r+e]="h".charCodeAt(0),i.sstruc[r+e+1]="h".charCodeAt(0))}}(t);else{if(!t.isProtein())return;!function(t){const e=t.residueStore,s=t.residueIndexStart;for(let n=0,o=t.residueCount;n=e;)i=Math.floor(i/e),s+=Ua[i%e],r+=1;return r>=5&&Me.warn("chainname overflow"),s}function Ha(t,e=!1){De&&Me.time("calculateChainnames");let i=!0;if(t.eachChain((function(t){t.chainname&&(i=!1)})),i){const i=t.modelStore,r=t.chainStore,s=t.residueStore,n=function(t,e,n,o){const a=r.count;for(let t=0;t{h.add(e),t.forEach((t=>{h.add(t)}))}))),t.eachResidue((function(t){if(!e&&l){const e=t.atomCount,s=t.atomOffset;if(e>500)return void Me.warn("more than 500 atoms, skip residue for auto-bonding",t.qualifiedName());if("auto"===i&&t.hetero)for(let e=t.atomOffset;e{u.forEach((i=>{e.push(t.clone().multiply(i))}))})),h.addPart(e)}else h.addPart(d);const m=new e,p=new La("SUPERCELL"),f=Array.prototype.concat.call(l(m.set(1,0,0)),l(m.set(0,1,0)),l(m.set(0,0,1)),l(m.set(-1,0,0)),l(m.set(0,-1,0)),l(m.set(0,0,-1)),l(m.set(1,1,0)),l(m.set(1,0,1)),l(m.set(0,1,1)),l(m.set(-1,-1,0)),l(m.set(-1,0,-1)),l(m.set(0,-1,-1)),l(m.set(1,-1,-1)),l(m.set(1,1,-1)),l(m.set(1,-1,1)),l(m.set(-1,1,1)),l(m.set(-1,-1,1)),l(m.set(-1,1,-1)),l(m.set(0,1,-1)),l(m.set(0,-1,1)),l(m.set(1,0,-1)),l(m.set(-1,0,1)),l(m.set(1,-1,0)),l(m.set(-1,1,0)),l(),l(m.set(1,1,1)),l(m.set(-1,-1,-1)));if(t.biomolDict.NCS){const t=[];f.forEach((function(e){u.forEach((function(i){t.push(e.clone().multiply(i))}))})),p.addPart(t)}else p.addPart(f);t.biomolDict.UNITCELL=h,t.biomolDict.SUPERCELL=p,De&&Me.timeEnd("buildUnitcellAssembly")}const Qa=["H","C","O","N","S","P"],Ja=["NA","CL","FE"];function tc(t){let e=t.toUpperCase(),i=0,r=0;for(let t=0;t0)break;++i}else r=t+1;(i>0||r=3&&-1!==Qa.indexOf(e[0])?e[0]:""}function ec(t){const e=t.bondHash,i=e.countArray,r=e.offsetArray,s=e.indexArray,n=t.getBondProxy();t.eachResidue((function(t){const e=t.residueType;if(void 0!==e.bonds)return;var o=t.atomOffset,a=[],c=[],l=[],h={};const d=o+t.atomCount;t.eachAtom((function(t){const e=t.index,u=r[e];for(let t=0,r=i[e];t=d)continue;let i=n.atomIndex2;if(i=d)continue;if(e>i){const t=i;i=e,e=t}const r=e+"|"+i;void 0===h[r]&&(h[r]=!0,a.push(e-o),c.push(i-o),l.push(n.bondOrder))}})),e.bonds={atomIndices1:a,atomIndices2:c,bondOrders:l}}))}function ic(t,...e){De&&Me.time("concatStructures");const i=new Cc(t,""),r=new za(i),s=i.atomStore,n=i.atomMap;s.addField("formalCharge",1,"int8"),s.addField("partialCharge",1,"float32");const o={};let a=0,c=0,l=0;e.forEach((t=>{t.eachAtom((t=>{s.growIfFull(),s.atomTypeId[a]=n.add(t.atomname,t.element),s.x[a]=t.x,s.y[a]=t.y,s.z[a]=t.z,s.serial[a]=t.serial,s.formalCharge[a]=t.formalCharge,s.partialCharge[a]=t.partialCharge,s.altloc[a]=t.altloc,s.occupancy[a]=t.occupancy,s.bfactor[a]=t.bfactor,r.addAtom(t.modelIndex+l,t.chainname,t.chainid,t.resname,t.resno,1===t.hetero,t.sstruc,t.inscode),o[t.index+c]=a,a+=1})),c+=t.atomStore.count,l+=t.modelStore.count}));const h=i.bondStore,d=i.getAtomProxy(),u=i.getAtomProxy();return c=0,e.forEach((t=>{t.eachBond((t=>{d.index=o[t.atomIndex1+c],u.index=o[t.atomIndex2+c],h.addBond(d,u,t.bondOrder)})),c+=t.atomStore.count})),r.finalize(),Ka(i,!0),Ya(i,!0),i.finalizeAtoms(),i.finalizeBonds(),ec(i),De&&Me.timeEnd("concatStructures"),i}const rc=[3,11,19,37,55,87],sc=[4,12,20,38,56,88],nc=[6,15,16,34],oc=[1,7,8,9,17,35,53],ac=[2,10,18,36,54,86],cc=[13,30,31,48,49,50,80,81,82,83,84,85,112],lc=[5,14,32,33,51,52,85],hc=[9,17,35,53,85];class dc{constructor(t,e,i){this.structure=t,this.atomname=e,i=i||tc(e),this.element=i,this.number=Xs[i]||0,this.vdw=Ys[this.number]||2,this.covalent=Ks[this.number]||1.6}getDefaultValence(){const t=Zs[this.number];return t?t[0]:-1}getValenceList(){return Zs[this.number]||[]}getOuterShellElectronCount(){return Qs[this.number]||2}isMetal(){return this.isAlkaliMetal()||this.isAlkalineEarthMetal()||this.isLanthanide()||this.isActinide()||this.isTransitionMetal()||this.isPostTransitionMetal()}isNonmetal(){return this.isDiatomicNonmetal()||this.isPolyatomicNonmetal()||this.isNobleGas()}isMetalloid(){return lc.includes(this.number)}isHalogen(){return hc.includes(this.number)}isDiatomicNonmetal(){return oc.includes(this.number)}isPolyatomicNonmetal(){return nc.includes(this.number)}isAlkaliMetal(){return rc.includes(this.number)}isAlkalineEarthMetal(){return sc.includes(this.number)}isNobleGas(){return ac.includes(this.number)}isTransitionMetal(){const t=this.number;return t>=21&&t<=29||t>=39&&t<=47||t>=72&&t<=79||t>=104&&t<=108}isPostTransitionMetal(){return cc.includes(this.number)}isLanthanide(){return this.number>=57&&this.number<=71}isActinide(){return this.number>=89&&this.number<=103}}class uc{constructor(t){this.structure=t,this.dict={},this.list=[],this.structure=t}add(t,e){const i=function(t,e){return t+"|"+e}(t=t.toUpperCase(),e=e?e.toUpperCase():tc(t));let r=this.dict[i];if(void 0===r){const s=new dc(this.structure,t,e);r=this.list.length,this.dict[i]=r,this.list.push(s)}return r}get(t){return this.list[t]}}class mc{constructor(t,e,i,r,s,n){this.structure=t,this.bondReferenceAtomIndices=[],this.resname=e,this.atomTypeIdList=i,this.hetero=r?1:0,this.chemCompType=s,this.bonds=n,this.atomCount=i.length,this.moleculeType=this.getMoleculeType(),this.backboneType=this.getBackboneType(0),this.backboneEndType=this.getBackboneType(-1),this.backboneStartType=this.getBackboneType(1),this.backboneIndexList=this.getBackboneIndexList();const o=mn[this.backboneType],a=mn[this.backboneStartType],c=mn[this.backboneEndType],l=this.getAtomIndexByName(o.trace);this.traceAtomIndex=st(l,-1);const h=this.getAtomIndexByName(o.direction1);this.direction1AtomIndex=st(h,-1);const d=this.getAtomIndexByName(o.direction2);this.direction2AtomIndex=st(d,-1);const u=this.getAtomIndexByName(a.backboneStart);this.backboneStartAtomIndex=st(u,-1);const m=this.getAtomIndexByName(c.backboneEnd);let p;this.backboneEndAtomIndex=st(m,-1),p=on.includes(e)?this.getAtomIndexByName("N1"):this.getAtomIndexByName("N3"),this.rungEndAtomIndex=st(p,-1)}getBackboneIndexList(){const t=[];let e;switch(this.moleculeType){case 3:e=dn;break;case 4:case 5:e=un;break;default:return t}const i=this.structure.atomMap,r=this.atomTypeIdList;for(let s=0,n=this.atomCount;s500)De&&Me.warn("more than 500 atoms, skip residue for auto-bonding",t.qualifiedName());else if(s>50){const e=new $a(t,!0),s=t.isCg()?1.2:2.3;for(let t=n;t=0||yc(t,e);this.rings={atomRings:t.atomRings,rings:t.rings}}isAromatic(t){return this.aromaticAtoms=this.getAromatic(t),1===this.aromaticAtoms[t.index-t.residueAtomOffset]}calculateAromatic(t){const e=this.aromaticAtoms=new Uint8Array(this.atomCount),i=this.getRings().rings,r=i.map((e=>function(t){if(t.some((t=>!pc.includes(t.number))))return!1;let e=0;const i=new ho(3,t.length),r=i.data;t.forEach((t=>{r[e+0]=t.x,r[e+1]=t.y,r[e+2]=t.z,e+=3}));return new ya(i).vecC.length()this.structure.getAtomProxy(e+t.atomOffset)))))),s=this.aromaticRings=[];i.forEach(((t,i)=>{r[i]&&(s.push(t),t.forEach((t=>e[t]=1)))}))}assignBondReferenceAtomIndices(){const t=this.getBondGraph(),e=this.getRings(),i=e.atomRings,r=e.rings,s=this.bonds,n=s.atomIndices1,o=s.atomIndices2,a=s.bondOrders,c=this.bondReferenceAtomIndices,l=s.atomIndices1.length;c.length=0;for(let e=0;e1)for(let i=0;i1)for(let i=0;i=0;t--)p[f++]=o[t];const g=t.rings.length;for(let e=0;e0?n[c]!==e&&n[e]!==c&&gc(t,e,c):(r[c]=1,s[a++]=c,n[c]=e)}}}const bc=4;class xc{constructor(t){this.structure=t,this.dict={},this.list=[]}add(t,e,i,r="",s){const n=function(t,e,i,r=""){return t+"|"+e.join(",")+"|"+(i?1:0)+"|"+r}(t=t.toUpperCase(),e,i,r);let o=this.dict[n];if(void 0===o){const a=new mc(this.structure,t,e,i,r,s);o=this.list.length,this.dict[n]=o,this.list.push(a)}return o}get(t){return this.list[t]}}class vc{constructor(t,i=0){this.structure=t,this.index=i,this.bondStore=t.bondStore,this._v12=new e,this._v13=new e,this._ap1=this.structure.getAtomProxy(),this._ap2=this.structure.getAtomProxy(),this._ap3=this.structure.getAtomProxy()}get atom1(){return this.structure.getAtomProxy(this.atomIndex1)}get atom2(){return this.structure.getAtomProxy(this.atomIndex2)}get atomIndex1(){return this.bondStore.atomIndex1[this.index]}set atomIndex1(t){this.bondStore.atomIndex1[this.index]=t}get atomIndex2(){return this.bondStore.atomIndex2[this.index]}set atomIndex2(t){this.bondStore.atomIndex2[this.index]=t}get bondOrder(){return this.bondStore.bondOrder[this.index]}set bondOrder(t){this.bondStore.bondOrder[this.index]=t}getOtherAtomIndex(t){return t===this.atomIndex1?this.atomIndex2:this.atomIndex1}getOtherAtom(t){return this.structure.getAtomProxy(this.getOtherAtomIndex(t.index))}getReferenceAtomIndex(){const t=this._ap1,e=this._ap2;if(t.index=this.atomIndex1,e.index=this.atomIndex2,t.residueIndex!==e.residueIndex)return;const i=t.index-t.residueAtomOffset,r=e.index-e.residueAtomOffset,s=t.residueType.getBondReferenceAtomIndex(i,r);if(void 0!==s)return s+t.residueAtomOffset;console.warn("No reference atom found",t.index,e.index)}calculateShiftDir(t=new e){const i=this._ap1,r=this._ap2,s=this._ap3,n=this._v12,o=this._v13;i.index=this.atomIndex1,r.index=this.atomIndex2;const a=this.getReferenceAtomIndex();n.subVectors(i,r).normalize(),void 0!==a?(s.index=a,o.subVectors(i,s)):o.copy(i),o.normalize();let c=n.dot(o);return 1-Math.abs(c)<1e-5&&(o.set(1,0,0),c=n.dot(o),1-Math.abs(c)<1e-5&&(o.set(0,1,0),c=n.dot(o))),t.copy(o.sub(n.multiplyScalar(c))).normalize()}qualifiedName(){return this.atomIndex1+"="+this.atomIndex2}clone(){return new vc(this.structure,this.index)}toObject(){return{atomIndex1:this.atomIndex1,atomIndex2:this.atomIndex2,bondOrder:this.bondOrder}}}class wc{constructor(t,e=0){this.structure=t,this.index=e,this.chainStore=t.chainStore,this.residueStore=t.residueStore,this.atomStore=t.atomStore,this.residueMap=t.residueMap,this.atomMap=t.atomMap}get entity(){return this.structure.entityList[this.entityIndex]}get entityIndex(){return this.chainStore.entityIndex[this.chainIndex]}get chain(){return this.structure.getChainProxy(this.chainIndex)}get chainIndex(){return this.residueStore.chainIndex[this.index]}set chainIndex(t){this.residueStore.chainIndex[this.index]=t}get atomOffset(){return this.residueStore.atomOffset[this.index]}set atomOffset(t){this.residueStore.atomOffset[this.index]=t}get atomCount(){return this.residueStore.atomCount[this.index]}set atomCount(t){this.residueStore.atomCount[this.index]=t}get atomEnd(){return this.atomOffset+this.atomCount-1}get modelIndex(){return this.chainStore.modelIndex[this.chainIndex]}get chainname(){return this.chainStore.getChainname(this.chainIndex)}get chainid(){return this.chainStore.getChainid(this.chainIndex)}get resno(){return this.residueStore.resno[this.index]}set resno(t){this.residueStore.resno[this.index]=t}get sstruc(){return this.residueStore.getSstruc(this.index)}set sstruc(t){this.residueStore.setSstruc(this.index,t)}get inscode(){return this.residueStore.getInscode(this.index)}set inscode(t){this.residueStore.setInscode(this.index,t)}get residueType(){return this.residueMap.get(this.residueStore.residueTypeId[this.index])}get resname(){return this.residueType.resname}get hetero(){return this.residueType.hetero}get moleculeType(){return this.residueType.moleculeType}get backboneType(){return this.residueType.backboneType}get backboneStartType(){return this.residueType.backboneStartType}get backboneEndType(){return this.residueType.backboneEndType}get traceAtomIndex(){return this.residueType.traceAtomIndex+this.atomOffset}get direction1AtomIndex(){return this.residueType.direction1AtomIndex+this.atomOffset}get direction2AtomIndex(){return this.residueType.direction2AtomIndex+this.atomOffset}get backboneStartAtomIndex(){return this.residueType.backboneStartAtomIndex+this.atomOffset}get backboneEndAtomIndex(){return this.residueType.backboneEndAtomIndex+this.atomOffset}get rungEndAtomIndex(){return this.residueType.rungEndAtomIndex+this.atomOffset}get x(){let t=0;for(let e=this.atomOffset;e<=this.atomEnd;++e)t+=this.atomStore.x[e];return t/this.atomCount}get y(){let t=0;for(let e=this.atomOffset;e<=this.atomEnd;++e)t+=this.atomStore.y[e];return t/this.atomCount}get z(){let t=0;for(let e=this.atomOffset;e<=this.atomEnd;++e)t+=this.atomStore.z[e];return t/this.atomCount}eachAtom(t,e){const i=this.atomCount,r=this.atomOffset,s=this.structure._ap,n=r+i;if(e&&e.atomOnlyTest){const i=e.atomOnlyTest;for(let e=r;e0)return this.entity.isPolymer();{const t=this.residueType.moleculeType;return 3===t||4===t||5===t}}isHetero(){return 1===this.residueType.hetero}isWater(){return 1===this.residueType.moleculeType}isIon(){return 2===this.residueType.moleculeType}isSaccharide(){return 6===this.residueType.moleculeType}isStandardAminoacid(){return this.residueType.isStandardAminoacid()}isStandardBase(){return this.residueType.isStandardBase()}isHelix(){return Hs.includes(this.sstruc)}isSheet(){return Ws.includes(this.sstruc)}isTurn(){return qs.includes(this.sstruc)&&this.isProtein()}getAtomType(t){return this.atomMap.get(this.atomStore.atomTypeId[t])}getResname1(){return en[this.resname.toUpperCase()]||"X"}getBackboneType(t){switch(t){case-1:return this.residueType.backboneStartType;case 1:return this.residueType.backboneEndType;default:return this.residueType.backboneType}}getAtomIndexByName(t){let e=this.residueType.getAtomIndexByName(t);return void 0!==e&&(e+=this.atomOffset),e}hasAtomWithName(t){return this.residueType.hasAtomWithName(t)}getAtomnameList(){console.warn("getAtomnameList - might be expensive");const t=this.atomCount,e=this.atomOffset,i=new Array(t);for(let r=0;r=e){const e=st(t,this.structure.getResidueProxy());if(e.index=i,e.connectedTo(this))return e}else if(i===e-1){const i=this.chainStore.residueCount[this.chainIndex],r=st(t,this.structure.getResidueProxy());if(r.index=e+i-1,r.connectedTo(this))return r}}getBonds(){return this.residueType.getBonds(this)}getRings(){return this.residueType.getRings()}getAromaticRings(){return this.residueType.getAromaticRings(this)}qualifiedName(t=!1){let e="";return this.resname&&!t&&(e+="["+this.resname+"]"),void 0!==this.resno&&(e+=this.resno),this.inscode&&(e+="^"+this.inscode),this.chain&&(e+=":"+this.chainname),e+="/"+this.modelIndex,e}clone(){return new wc(this.structure,this.index)}toObject(){return{index:this.index,chainIndex:this.chainIndex,atomOffset:this.atomOffset,atomCount:this.atomCount,resno:this.resno,resname:this.resname,sstruc:this.sstruc}}}class Ac{constructor(t,e,i){this.structure=t,this.residueIndexStart=e,this.residueIndexEnd=i,this.chainStore=t.chainStore,this.residueStore=t.residueStore,this.atomStore=t.atomStore,this.residueCount=i-e+1;const r=this.structure.getResidueProxy(this.residueIndexStart),s=this.structure.getResidueProxy(this.residueIndexEnd);this.isPrevConnected=void 0!==r.getPreviousConnectedResidue();const n=s.getNextConnectedResidue();this.isNextConnected=void 0!==n,this.isNextNextConnected=void 0!==n&&void 0!==n.getNextConnectedResidue(),this.isCyclic=s.connectedTo(r),this.__residueProxy=this.structure.getResidueProxy()}get chainIndex(){return this.residueStore.chainIndex[this.residueIndexStart]}get modelIndex(){return this.chainStore.modelIndex[this.chainIndex]}get chainname(){return this.chainStore.getChainname(this.chainIndex)}isProtein(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isProtein()}isCg(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isCg()}isNucleic(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isNucleic()}getMoleculeType(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.moleculeType}getBackboneType(t){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.getBackboneType(t)}getAtomIndexByType(t,e){this.isCyclic?-1===t?t=this.residueCount-1:t===this.residueCount&&(t=0):(-1!==t||this.isPrevConnected||(t+=1),t!==this.residueCount||this.isNextNextConnected||(t-=1));const i=this.__residueProxy;let r;switch(i.index=this.residueIndexStart+t,e){case"trace":r=i.traceAtomIndex;break;case"direction1":r=i.direction1AtomIndex;break;case"direction2":r=i.direction2AtomIndex;break;default:r=i.getAtomIndexByName(e)}return r}eachAtom(t,e){this.eachResidue((function(i){i.eachAtom(t,e)}))}eachAtomN(t,e,i){const r=this.residueCount,s=new Array(t);for(let e=0;e1&&t(new Ac(n,i,l.index)),i=r)):(o!==Ns&&l.index-i>1&&t(new Ac(n,i,l.index)),i=r)}r-i>1&&this.structure.getResidueProxy(i).backboneEndType&&t(new Ac(n,i,r))}qualifiedName(){return":"+this.chainname+"/"+this.modelIndex}clone(){return new _c(this.structure,this.index)}toObject(){return{index:this.index,residueOffset:this.residueOffset,residueCount:this.residueCount,chainname:this.chainname}}}class Sc{constructor(t,e=0){this.structure=t,this.index=e,this.modelStore=t.modelStore,this.chainStore=t.chainStore,this.residueStore=t.residueStore}get chainOffset(){return this.modelStore.chainOffset[this.index]}set chainOffset(t){this.modelStore.chainOffset[this.index]=t}get chainCount(){return this.modelStore.chainCount[this.index]}set chainCount(t){this.modelStore.chainCount[this.index]=t}get residueOffset(){return this.chainStore.residueOffset[this.chainOffset]}get atomOffset(){return this.residueStore.atomOffset[this.residueOffset]}get chainEnd(){return this.chainOffset+this.chainCount-1}get residueEnd(){return this.chainStore.residueOffset[this.chainEnd]+this.chainStore.residueCount[this.chainEnd]-1}get atomEnd(){return this.residueStore.atomOffset[this.residueEnd]+this.residueStore.atomCount[this.residueEnd]-1}get residueCount(){return 0===this.chainCount?0:this.residueEnd-this.residueOffset+1}get atomCount(){return 0===this.residueCount?0:this.atomEnd-this.atomOffset+1}eachAtom(t,e){this.eachChain((function(i){i.eachAtom(t,e)}),e)}eachResidue(t,e){this.eachChain((function(i){i.eachResidue(t,e)}),e)}eachPolymer(t,e){if(e&&e.chainOnlyTest){const i=e.chainOnlyTest;this.eachChain((function(r){i(r)&&r.eachPolymer(t,e)}))}else this.eachChain((function(i){i.eachPolymer(t,e)}))}eachChain(t,e){const i=this.chainCount,r=this.chainOffset,s=this.structure._cp,n=r+i;if(e&&e.test){const i=e.chainOnlyTest;if(i)for(let e=r;e{const i=3*e;a.index=t,l&&a.positionToArray(l,i),h&&n.atomColorToArray(a,h,i),d&&(d.array[e]=t),u&&(u[e]=s.atomRadius(a)),m&&(m[e]=t)})),o}getBondData(t){const i=Object.assign({},t);i.colorParams&&(i.colorParams.structure=this.getStructure());const r=i.what,s=st(i.bondSet,this.bondSet),n=st(i.multipleBond,"off"),o="off"!==n,a="offset"===n,c=st(i.bondScale,.4),l=st(i.bondSpacing,1);let h,d;const u={},m=this.getBondProxy();i.bondStore&&(m.bondStore=i.bondStore);const p=this.getAtomProxy(),f=this.getAtomProxy();let g;if(o){const t=m.bondStore.bondOrder;g=0,s.forEach((function(e){g+=t[e]}))}else g=s.getSize();r&&!r.position||(u.position1=new Float32Array(3*g),u.position2=new Float32Array(3*g)),r&&!r.color||!i.colorParams||(u.color=new Float32Array(3*g),u.color2=new Float32Array(3*g),d=Fe.getScheme(i.colorParams)),r&&!r.picking||(u.picking=new Zn(new Float32Array(g),this.getStructure(),i.bondStore)),(!r||r.radius||o&&r.position)&&(h=new pa(i.radiusParams)),r&&!r.radius||(u.radius=new Float32Array(g),i.radius2&&(u.radius2=new Float32Array(g)));const{position1:y,position2:b,color:x,color2:v,picking:w,radius:A,radius2:_}=u;let S,C,P,I,k,M,T=0;const B=new e,D=new e,$=new e;return s.forEach((t=>{if(C=3*T,m.index=t,p.index=m.atomIndex1,f.index=m.atomIndex2,I=m.bondOrder,y)if(o&&I>1){const t=h.atomRadius(p);M=t*c/(.5*I),m.calculateShiftDir($),a?(k=2*l*t,$.multiplyScalar(k),$.negate(),D.subVectors(f,p).multiplyScalar(Math.max(.1,k/1.88)),p.positionToArray(y,C),f.positionToArray(b,C),I>=2&&(B.addVectors(p,$).add(D).toArray(y,C+3),B.addVectors(f,$).sub(D).toArray(b,C+3),I>=3&&(B.subVectors(p,$).add(D).toArray(y,C+6),B.subVectors(f,$).sub(D).toArray(b,C+6)))):(k=(l-c)*t,$.multiplyScalar(k),2===I?(B.addVectors(p,$).toArray(y,C),B.subVectors(p,$).toArray(y,C+3),B.addVectors(f,$).toArray(b,C),B.subVectors(f,$).toArray(b,C+3)):3===I?(p.positionToArray(y,C),B.addVectors(p,$).toArray(y,C+3),B.subVectors(p,$).toArray(y,C+6),f.positionToArray(b,C),B.addVectors(f,$).toArray(b,C+3),B.subVectors(f,$).toArray(b,C+6)):(p.positionToArray(y,C),f.positionToArray(b,C)))}else p.positionToArray(y,C),f.positionToArray(b,C);if(x&&v&&(d.bondColorToArray(m,1,x,C),d.bondColorToArray(m,0,v,C),o&&I>1))for(S=1;S1))for(S=1;S1))for(M=A[T]*c/(a?1:.5*I),S=a?1:0;S1))for(M=_[T]*c/(a?1:.5*I),S=a?1:0;S{const e=t.x,a=t.y,l=t.z;en&&(n=e),a>o&&(o=a),l>c&&(c=l)}),t),e.min.set(i,r,s),e.max.set(n,o,c),De&&Me.timeEnd("getBoundingBox"),e}getPrincipalAxes(t){De&&Me.time("getPrincipalAxes");let e=0;const i=new ho(3,this.atomCount),r=i.data;return this.eachAtom((t=>{r[e+0]=t.x,r[e+1]=t.y,r[e+2]=t.z,e+=3}),t),De&&Me.timeEnd("getPrincipalAxes"),new ya(i)}atomCenter(t){return t?this.getBoundingBox(t).getCenter(new e):this.center.clone()}hasCoords(){if(void 0===this._hasCoords){const t=this.atomStore;this._hasCoords=0!==Di(t.x)||0!==Bi(t.x)||0!==Di(t.y)||0!==Bi(t.y)||0!==Di(t.z)||0!==Bi(t.z)||t.count/this.modelStore.count==1}return this._hasCoords}getSequence(t){const e=[],i=this.getResidueProxy();return this.eachAtom((function(t){i.index=t.residueIndex,t.index===i.traceAtomIndex&&e.push(i.getResname1())}),t),e}getAtomIndices(t){if(t&&t.string){const e=[];return this.eachAtom((function(t){e.push(t.index)}),t),new Uint32Array(e)}{const t={what:{index:!0}};return this.getAtomData(t).index}}getChainnameCount(t){const e=new Set;return this.eachChain((function(t){t.residueCount&&e.add(t.chainname)}),t),e.size}updatePosition(t,e=!0){let i=0;this.eachAtom((function(e){e.positionFromArray(t,i),i+=3}),void 0),this._hasCoords=void 0,e&&this.refreshPosition()}refreshPosition(){this.getBoundingBox(void 0,this.boundingBox),this.boundingBox.getCenter(this.center),this.spatialHash=new Ts(this.atomStore,this.boundingBox),this.signals.refreshed.dispatch(this)}dispose(){this.frames&&(this.frames.length=0),this.boxes&&(this.boxes.length=0),this.bondStore.dispose(),this.backboneBondStore.dispose(),this.rungBondStore.dispose(),this.atomStore.dispose(),this.residueStore.dispose(),this.chainStore.dispose(),this.modelStore.dispose(),delete this.bondSet,delete this.atomSet}}const Pc=new a,Ic=[_s,xs,Ss,As,Cs,vs,bs,ws,Is,Ps,ks,Ms],kc={aspectRatio:1.5,sphereDetail:2,radialSegments:50,disableImpostor:!1,openEnded:!1,dashedCylinder:!1,labelParams:{},pointSize:2,sizeAttenuation:!1,useTexture:!0,linewidth:2};class Mc{constructor(t="shape",e={}){this.boundingBox=new a,this.bufferList=[],this.meshCount=0,this._primitiveData={},this.name=t,this.parameters=nt(e,kc),Ic.forEach((t=>{Object.keys(t.fields).forEach((e=>{this._primitiveData[t.getShapeKey(e)]=[]})),this._primitiveData[t.getShapeKey("name")]=[]}))}addBuffer(t){this.bufferList.push(t);const e=t.geometry;return e.boundingBox||e.computeBoundingBox(),this.boundingBox.union(e.boundingBox),this}addMesh(t,e,i,r,s){let n;t=Ct(t),e=Ct(e),Array.isArray(i)&&(i=xt(i,t.length)),r&&(r=Ct(r)),n=void 0===r||0==r.length?{position:t,color:e,index:i}:{position:t,color:e,index:i,normal:r};const o=new io(this,Object.assign({serial:this.meshCount,name:s},n)),a=new Uo(Object.assign({picking:o},n));return this.bufferList.push(a),Pc.setFromArray(t),this.boundingBox.union(Pc),this.meshCount+=1,this}addSphere(t,e,i,r){return bs.objectToShape(this,{position:t,color:e,radius:i,name:r}),this}addEllipsoid(t,e,i,r,s,n){return Cs.objectToShape(this,{position:t,color:e,radius:i,majorAxis:r,minorAxis:s,name:n}),this}addTorus(t,e,i,r,s,n){return Ps.objectToShape(this,{position:t,color:e,radius:i,majorAxis:r,minorAxis:s,name:n}),this}addCylinder(t,e,i,r,s){return As.objectToShape(this,{position1:t,position2:e,color:i,radius:r,name:s}),this}addCone(t,e,i,r,s){return Ss.objectToShape(this,{position1:t,position2:e,color:i,radius:r,name:s}),this}addArrow(t,e,i,r,s){return _s.objectToShape(this,{position1:t,position2:e,color:i,radius:r,name:s}),this}addBox(t,e,i,r,s,n){return xs.objectToShape(this,{position:t,color:e,size:i,heightAxis:r,depthAxis:s,name:n}),this}addOctahedron(t,e,i,r,s,n){return vs.objectToShape(this,{position:t,color:e,size:i,heightAxis:r,depthAxis:s,name:n}),this}addTetrahedron(t,e,i,r,s,n){return ws.objectToShape(this,{position:t,color:e,size:i,heightAxis:r,depthAxis:s,name:n}),this}addText(t,e,i,r){return Is.objectToShape(this,{position:t,color:e,size:i,text:r}),this}addPoint(t,e,i){return ks.objectToShape(this,{position:t,color:e,name:i}),this}addWideline(t,e,i,r,s){return this.parameters.linewidth=r,Ms.objectToShape(this,{position1:t,position2:e,color:i,name:s}),this}addLabel(t,e,i,r){return console.warn("Shape.addLabel is deprecated, use .addText instead"),this.addText(t,e,i,r)}getBufferList(){const t=[];return Ic.forEach((e=>{this._primitiveData[e.getShapeKey("color")].length&&t.push(e.bufferFromShape(this,this.parameters))})),this.bufferList.concat(t)}dispose(){this.bufferList.forEach((function(t){t.dispose()})),this.bufferList.length=0,Ic.forEach((t=>{Object.keys(t.fields).forEach((e=>{this._primitiveData[t.getShapeKey(e)].length=0})),this._primitiveData[t.getShapeKey("name")].length=0}))}get center(){return this._center||(this._center=this.boundingBox.getCenter(new e)),this._center}get type(){return"Shape"}}class Tc extends zr{constructor(t,e,i){Array.isArray(t)||(t=[t]),super(t,e,i),this.type="buffer",this.parameters=Object.assign({},this.parameters,{colorScheme:null,colorScale:null,colorValue:null,colorDomain:null,colorMode:null}),this.buffer=t,this.init(i)}init(t){super.init(t),this.build()}create(){this.bufferList.push.apply(this.bufferList,this.buffer)}attach(t){this.bufferList.forEach((t=>{this.viewer.add(t),t.setParameters(this.getBufferParams())})),this.setVisibility(this.visible),t()}}const Bc=new i,Dc=new O;class $c extends Uo{constructor(t,e={},i){super(function(t,e){const i=e.attributes.position.array,r=e.index?e.index.array:void 0,s=t.position.length/3,n=i.length/3,o=s*n,a=new Float32Array(3*o),c=new Float32Array(3*o),l=new Float32Array(3*o);let h;return r&&(h=xt(s*r.length,o)),{position:a,color:l,index:h,normal:c,primitiveId:t.primitiveId||Ii(s,n),picking:t.picking}}(t,i),e),this.updateNormals=!1;const r=i.attributes.position.array,s=i.attributes.normal.array,n=i.index?i.index.array:void 0;this.geoPosition=r,this.geoNormal=s,this.geoIndex=n,this.positionCount=t.position.length/3,this.geoPositionCount=r.length/3,this.transformedGeoPosition=new Float32Array(3*this.geoPositionCount),this.transformedGeoNormal=new Float32Array(3*this.geoPositionCount);const o=this.geometry.attributes;if(this.meshPosition=o.position.array,this.meshColor=o.color.array,this.meshNormal=o.normal.array,this.setAttributes(t),n){const t=this.geometry.getIndex();if(!t)return void Me.error("Index is null");this.meshIndex=t.array,this.makeIndex()}}setAttributes(t={},e=!1){const i=this.geometry.attributes;let r,s,n,o,a,c,l,h,d;const u=this.updateNormals;t.position&&(r=t.position,n=this.geoPosition,l=this.meshPosition,a=this.transformedGeoPosition,i.position.needsUpdate=!0,(u||e)&&(o=this.geoNormal,d=this.meshNormal,c=this.transformedGeoNormal,i.normal.needsUpdate=!0)),t.color&&(s=t.color,h=this.meshColor,i.color.needsUpdate=!0);const m=this.positionCount,p=this.geoPositionCount;for(let t=0;t 0.0 ){\ncameraPos = rayDirection * posT + rayOrigin;\ninterior = true;\nflag2 = true;\n}\n#else\nif( calcDepth( cameraPos ) <= 0.0 ){\ncameraPos = rayDirection * posT + rayOrigin;\ninterior = true;\n}\n#endif\ncameraNormal = normalize( cameraPos - cameraSpherePos );\ncameraNormal *= float(!interior) * 2.0 - 1.0;\nreturn !interior;\n}\nvoid main(void){\nbool flag = Impostor( cameraPos, cameraNormal );\n#ifdef NEAR_CLIP\nif( calcClip( cameraPos ) > 0.0 )\ndiscard;\n#endif\ngl_FragDepthEXT = calcDepth( cameraPos );\nif( !flag ){\n#ifdef NEAR_CLIP\nif( flag2 ){\ngl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( clipNear - 0.5 ) ) ) + ( 0.0000001 / vRadius ) );\n}else if( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n#else\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n#endif\n}\nif (gl_FragDepthEXT < 0.0)\ndiscard;\nif (gl_FragDepthEXT > 1.0)\ndiscard;\n#ifdef PICKING\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 vNormal = cameraNormal;\nvec3 vViewPosition = -cameraPos;\nvec4 diffuseColor = vec4( diffuse, opacity );\nReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\nvec3 totalEmissiveLight = emissive;\n#include color_fragment\n#include roughnessmap_fragment\n#include metalnessmap_fragment\n#include normal_fragment_begin\n#include lights_physical_fragment\n#include lights_fragment_begin\n#include lights_fragment_end\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\nif( interior ){\n#ifdef USE_INTERIOR_COLOR\noutgoingLight.xyz = interiorColor;\n#else\n#ifdef DIFFUSE_INTERIOR\noutgoingLight.xyz = vColor;\n#endif\n#endif\noutgoingLight.xyz *= 1.0 - interiorDarkening;\n}\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");class Fc extends Go{constructor(t,e,i={}){super(e,i),this.index=xt(this.indexSize,this.attributeSize),this.makeIndex(),this.initIndex(this.index),this.addAttributes({mapping:{type:t,value:null}}),this.setAttributes({primitiveId:Pi(this.size)})}get attributeSize(){return this.size*this.mappingSize}get indexSize(){return this.size*this.mappingIndicesSize}addAttributes(t){const e={};for(const i in t){const r=t[i];e[i]={type:r.type,value:null}}super.addAttributes(e)}getAttributeIndex(t){return 3*t*this.mappingSize}setAttributes(t){t&&!t.position&&t.position1&&t.position2&&(t.position=Ai(t.position1,t.position2));const e=this.size,i=this.mappingSize,r=this.geometry.attributes;let s,n,o,a,c,l,h;for(const d in t)if("index"!==d&&"picking"!==d){n=t[d],s=r[d],o=s.itemSize,a=s.array;for(let t=0;t0&&this.parameters.alphaTest<=1&&(e.ALPHATEST=this.parameters.alphaTest.toPrecision(2)),e}setUniforms(t){t&&void 0!==t.edgeBleach&&(this.makeTexture(),t.map=this.tex),super.setUniforms(t)}dispose(){super.dispose(),this.tex&&this.tex.dispose()}}je.add("point",Wc);class qc extends zr{constructor(t,e,i){super(t,e,i),this.type="dot",this.parameters=Object.assign({thresholdType:{type:"select",rebuild:!0,options:{value:"value",sigma:"sigma"}},thresholdMin:{type:"number",precision:3,max:1/0,min:-1/0,rebuild:!0},thresholdMax:{type:"number",precision:3,max:1/0,min:-1/0,rebuild:!0},thresholdOut:{type:"boolean",rebuild:!0},dotType:{type:"select",rebuild:!0,options:{"":"",sphere:"sphere",point:"point"}},radiusType:{type:"select",options:{"":"",value:"value","abs-value":"abs-value","value-min":"value-min",deviation:"deviation",size:"size"}},radius:{type:"number",precision:3,max:10,min:.001,property:"size"},scale:{type:"number",precision:3,max:10,min:.001},sphereDetail:!0,disableImpostor:!0,pointSize:{type:"number",precision:1,max:100,min:0,buffer:!0},sizeAttenuation:{type:"boolean",buffer:!0},sortParticles:{type:"boolean",rebuild:!0},useTexture:{type:"boolean",buffer:!0},alphaTest:{type:"range",step:.001,max:1,min:0,buffer:!0},forceTransparent:{type:"boolean",buffer:!0},edgeBleach:{type:"range",step:.001,max:1,min:0,buffer:!0}},this.parameters,{colorScheme:{type:"select",update:"color",options:{"":"",value:"value",uniform:"uniform",random:"random"}}}),t instanceof Eo?(this.surface=void 0,this.volume=new ba(t)):(this.surface=t,this.volume=void 0),this.init(i)}init(t){var e=t||{};e.colorScheme=st(e.colorScheme,"uniform"),e.colorValue=st(e.colorValue,14540253),this.thresholdType=st(e.thresholdType,"sigma"),this.thresholdMin=st(e.thresholdMin,2),this.thresholdMax=st(e.thresholdMax,1/0),this.thresholdOut=st(e.thresholdOut,!1),this.dotType=st(e.dotType,"point"),this.radius=st(e.radius,.1),this.scale=st(e.scale,1),this.pointSize=st(e.pointSize,1),this.sizeAttenuation=st(e.sizeAttenuation,!0),this.sortParticles=st(e.sortParticles,!1),this.useTexture=st(e.useTexture,!1),this.alphaTest=st(e.alphaTest,.5),this.forceTransparent=st(e.forceTransparent,!1),this.edgeBleach=st(e.edgeBleach,0),super.init(e),this.build()}attach(t){this.bufferList.forEach((t=>{this.viewer.add(t)})),this.setVisibility(this.visible),t()}create(){var t={};if(this.volume){var e,i,r=this.volume;"sigma"===this.thresholdType?(e=r.getValueForSigma(this.thresholdMin),i=r.getValueForSigma(this.thresholdMax)):(e=this.thresholdMin,i=this.thresholdMax),r.setFilter(e,i,this.thresholdOut),Object.assign(t,{position:r.getDataPosition(),color:r.getDataColor(this.getColorParams())}),"sphere"===this.dotType&&Object.assign(t,{radius:r.getDataSize(this.radius,this.scale),picking:r.getDataPicking()})}else{var s=this.surface;Object.assign(t,{position:s.getPosition(),color:s.getColor(this.getColorParams())}),"sphere"===this.dotType&&Object.assign(t,{radius:s.getSize(this.radius,this.scale),picking:s.getPicking()})}"sphere"===this.dotType?this.dotBuffer=new Gc(t,this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!1})):this.dotBuffer=new Wc(t,this.getBufferParams({pointSize:this.pointSize,sizeAttenuation:this.sizeAttenuation,sortParticles:this.sortParticles,useTexture:this.useTexture,alphaTest:this.alphaTest,forceTransparent:this.forceTransparent,edgeBleach:this.edgeBleach})),this.bufferList.push(this.dotBuffer)}update(t={}){if(0===this.bufferList.length)return;const e={};t.color&&(this.volume?Object.assign(e,{color:this.volume.getDataColor(this.getColorParams())}):Object.assign(e,{color:this.surface.getColor(this.getColorParams())})),"sphere"===this.dotType&&(t.radius||t.scale)&&(this.volume?Object.assign(e,{radius:this.volume.getDataSize(this.radius,this.scale)}):Object.assign(e,{radius:this.surface.getSize(this.radius,this.scale)})),this.dotBuffer.setAttributes(e)}setParameters(t,e={},i){return t&&void 0!==t.thresholdType&&this.volume instanceof Eo&&("value"===this.thresholdType&&"sigma"===t.thresholdType?(this.thresholdMin=this.volume.getSigmaForValue(this.thresholdMin),this.thresholdMax=this.volume.getSigmaForValue(this.thresholdMax)):"sigma"===this.thresholdType&&"value"===t.thresholdType&&(this.thresholdMin=this.volume.getValueForSigma(this.thresholdMin),this.thresholdMax=this.volume.getValueForSigma(this.thresholdMax)),this.thresholdType=t.thresholdType),t&&void 0!==t.radiusType&&("radius"===t.radiusType?this.radius=.1:this.radius=parseFloat(t.radiusType),e.radius=!0,"sphere"!==this.dotType||Ie&&!this.disableImpostor||(i=!0)),t&&void 0!==t.radius&&(e.radius=!0,"sphere"!==this.dotType||Ie&&!this.disableImpostor||(i=!0)),t&&void 0!==t.scale&&(e.scale=!0,"sphere"!==this.dotType||Ie&&!this.disableImpostor||(i=!0)),super.setParameters(t,e,i),this}}Ve.add("shader/Image.vert","uniform float clipRadius;\nuniform vec3 clipCenter;\nvarying vec2 vUv;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvarying vec3 vViewPosition;\n#endif\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\nvoid main() {\n#include begin_vertex\n#include project_vertex\nvUv = uv;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvViewPosition = -mvPosition.xyz;\n#endif\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n}"),Ve.add("shader/Image.frag","uniform sampler2D map;\nuniform float opacity;\nuniform vec2 mapSize;\nuniform float clipNear;\nuniform float clipRadius;\nvarying vec2 vUv;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvarying vec3 vViewPosition;\n#endif\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#if defined( PICKING )\nuniform sampler2D pickingMap;\nuniform float objectId;\n#else\n#include fog_pars_fragment\n#endif\n#if defined( CUBIC_INTERPOLATION )\n#if defined( CATMULROM_FILTER ) || defined( MITCHELL_FILTER )\n#if defined( CATMULROM_FILTER )\nconst float B = 0.0;\nconst float C = 0.5;\n#elif defined( MITCHELL_FILTER )\nconst float B = 0.333;\nconst float C = 0.333;\n#endif\nfloat filter( float x ){\nfloat f = x;\nif( f < 0.0 ){\nf = -f;\n}\nif( f < 1.0 ){\nreturn ( ( 12.0 - 9.0 * B - 6.0 * C ) * ( f * f * f ) +\n( -18.0 + 12.0 * B + 6.0 *C ) * ( f * f ) +\n( 6.0 - 2.0 * B ) ) / 6.0;\n}else if( f >= 1.0 && f < 2.0 ){\nreturn ( ( -B - 6.0 * C ) * ( f * f * f )\n+ ( 6.0 * B + 30.0 * C ) * ( f *f ) +\n( - ( 12.0 * B ) - 48.0 * C ) * f +\n8.0 * B + 24.0 * C ) / 6.0;\n}else{\nreturn 0.0;\n}\n}\n#elif defined( BSPLINE_FILTER )\nfloat filter( float x ){\nfloat f = x;\nif( f < 0.0 ){\nf = -f;\n}\nif( f >= 0.0 && f <= 1.0 ){\nreturn ( 2.0 / 3.0 ) + ( 0.5 ) * ( f * f * f ) - ( f * f );\n}else if( f > 1.0 && f <= 2.0 ){\nreturn 1.0 / 6.0 * pow( ( 2.0 - f ), 3.0 );\n}\nreturn 1.0;\n}\n#else\nfloat filter( float x ){\nreturn 1.0;\n}\n#endif\nvec4 biCubic( sampler2D tex, vec2 texCoord ){\nvec2 texelSize = 1.0 / mapSize;\ntexCoord -= texelSize / 2.0;\nvec4 nSum = vec4( 0.0 );\nfloat nDenom = 0.0;\nvec2 cell = fract( texCoord * mapSize );\nfor( float m = -1.0; m <= 2.0; ++m ){\nfor( float n = -1.0; n <= 2.0; ++n ){\nvec4 vecData = texture2D(\ntex, texCoord + texelSize * vec2( m, n )\n);\nfloat c = filter( m - cell.x ) * filter( -n + cell.y );\nnSum += vecData * c;\nnDenom += c;\n}\n}\nreturn nSum / nDenom;\n}\n#endif\nvoid main(){\n#include nearclip_fragment\n#include radiusclip_fragment\n#if defined( CUBIC_INTERPOLATION )\ngl_FragColor = biCubic( map, vUv );\n#else\ngl_FragColor = texture2D( map, vUv );\n#endif\n#if defined( PICKING )\nif( gl_FragColor.a < 0.3 )\ndiscard;\ngl_FragColor = vec4( texture2D( pickingMap, vUv ).xyz, objectId );\n#else\nif( gl_FragColor.a < 0.01 )\ndiscard;\ngl_FragColor.a *= opacity;\n#include fog_fragment\n#endif\n}");const Xc=new Uint16Array([0,1,2,1,3,2]),Yc=new Float32Array([0,1,0,0,1,1,1,0]),Kc=Object.assign({filter:"nearest",forceTransparent:!0},zo),Zc=Object.assign({filter:{updateShader:!0,uniform:!0}},Vo);class Qc extends Go{constructor(e,i){super({position:e.position,index:Xc,picking:e.picking},i),this.parameterTypes=Zc,this.alwaysTransparent=!0,this.hasWireframe=!1,this.vertexShader="Image.vert",this.fragmentShader="Image.frag";const{imageData:r,width:s,height:n}=e,o=new G(r,s,n);o.flipY=!0,this.tex=o;const a=r.length,c=new Uint8Array(a);for(let t=0;t>16&255,c[t+1]=e>>8&255,c[t+2]=255&e}const l=new G(c,s,n);l.flipY=!0,l.minFilter=x,l.magFilter=x,this.pickingTex=l,this.addUniforms({map:{value:o},pickingMap:{value:l},mapSize:{value:new t(s,n)}}),this.geometry.setAttribute("uv",new M(Yc,2))}get defaultParameters(){return Kc}getDefines(t){const e=super.getDefines(t),i=this.parameters.filter;return i.startsWith("cubic")&&(e.CUBIC_INTERPOLATION=1,i.endsWith("bspline")?e.BSPLINE_FILTER=1:i.endsWith("catmulrom")?e.CATMULROM_FILTER=1:i.endsWith("mitchell")&&(e.MITCHELL_FILTER=1)),e}updateTexture(){const t=this.tex,e=this.parameters.filter;e.startsWith("cubic")?(t.minFilter=x,t.magFilter=x):"linear"===e?(t.minFilter=A,t.magFilter=A):(t.minFilter=x,t.magFilter=x),t.needsUpdate=!0,this.pickingTex.needsUpdate=!0}makeMaterial(){super.makeMaterial(),this.updateTexture();const t=this.material;t.uniforms.map.value=this.tex,t.blending=U,t.needsUpdate=!0;const e=this.wireframeMaterial;e.uniforms.map.value=this.tex,e.blending=U,e.needsUpdate=!0;const i=this.pickingMaterial;i.uniforms.map.value=this.tex,i.uniforms.pickingMap.value=this.pickingTex,i.blending=U,i.needsUpdate=!0}setUniforms(t){t&&void 0!==t.filter&&(this.updateTexture(),t.map=this.tex),super.setUniforms(t)}}class Jc{constructor(t,e){const i=e||{};this.dimension=st(i.dimension,"x"),this.positionType=st(i.positionType,"percent"),this.position=st(i.position,30),this.thresholdType=st(i.thresholdType,"sigma"),this.thresholdMin=st(i.thresholdMin,-1/0),this.thresholdMax=st(i.thresholdMax,1/0),this.normalize=st(i.normalize,!1),this.volume=t}getPositionFromCoordinate(t){const i=this.dimension,r=this.volume,s=r.matrix,n=(new e).setFromMatrixPosition(s)[i],o=(new e).setFromMatrixScale(s)[i];let a;return a="x"===i?r.nx:"y"===i?r.ny:r.nz,Math.round(((t-n)/(a/100)+1)/o)}getData(t){t=t||{};const i=this.volume,r=i.data,s=i.matrix;let n;function o(t){return Math.round(t/100*(n-1))}function a(t,e,r,s){return 3*(r*i.ny*i.nx+e*i.nx+t)+s}n="coordinate"===this.positionType?this.getPositionFromCoordinate(this.position):this.position;const c=new Float32Array(12),l=new e;let h,d,u,m,p,f=0,g=0,y=0,b=i.nx,x=i.ny,v=i.nz;function w(t,e,i,r){l.set(t,e,i).applyMatrix4(s).toArray(c,r)}"x"===this.dimension?(u=o(i.nx),m=i.ny-1,p=i.nz-1,h=i.nz,d=i.ny,f=u,b=f+1,w(u,0,0,0),w(u,m,0,3),w(u,0,p,6),w(u,m,p,9)):"y"===this.dimension?(u=i.nx-1,m=o(i.ny),p=i.nz-1,h=i.nz,d=i.nx,g=m,x=g+1,w(0,m,0,0),w(u,m,0,3),w(0,m,p,6),w(u,m,p,9)):"z"===this.dimension&&(u=i.nx-1,m=i.ny-1,p=o(i.nz),h=i.nx,d=i.ny,y=p,v=y+1,w(0,0,p,0),w(0,m,p,3),w(u,0,p,6),w(u,m,p,9));let A=0,_=0;const S=new Uint8Array(h*d*4),C=new Float32Array(h*d);let P,I;"sigma"===this.thresholdType?(P=i.getValueForSigma(this.thresholdMin),I=i.getValueForSigma(this.thresholdMax)):(P=this.thresholdMin,I=this.thresholdMax);const k=Object.assign({},t.colorParams,{volume:i});this.normalize&&(k.domain=[0,1]);const M=Fe.getScheme(k),T=new Float32Array(3),B=M.getScale();let D,$=0,O=0;if(this.normalize){$=1/0,D=-1/0;for(let t=g;tD&&(D=s)}O=D-$}for(let t=g;tP&&n{this.viewer.add(t)})),this.setVisibility(this.visible),t()}create(){const t=new Jc(this.volume,{positionType:this.positionType,position:this.position,dimension:this.dimension,thresholdType:this.thresholdType,thresholdMin:this.thresholdMin,thresholdMax:this.thresholdMax,normalize:this.normalize}),e=new Qc(t.getData({colorParams:this.getColorParams()}),this.getBufferParams({filter:this.filter}));this.bufferList.push(e)}}function el(t){Me.error(`makeRepresentation: representation type ${t} unknown`)}const il={name:"some element",status:""};class rl{constructor(t,e={}){this.stage=t,this.signals={statusChanged:new et,nameChanged:new et,disposed:new et},this.parameters=nt(e,this.defaultParameters),this.uuid=Bt()}get defaultParameters(){return il}get name(){return this.parameters.name}setStatus(t){return this.parameters.status=t,this.signals.statusChanged.dispatch(t),this}setName(t){return this.parameters.name=t,this.signals.nameChanged.dispatch(t),this}dispose(){this.signals.disposed.dispatch()}}const sl=Object.assign({visible:!0},il);class nl extends rl{constructor(t,e,i={},r){super(t,Object.assign({name:e.type},i)),this.parent=r,this.signals=Object.assign({visibilityChanged:new et,parametersChanged:new et},this.signals),this.setRepresentation(e)}get defaultParameters(){return sl}get visible(){return this.parameters.visible}get type(){return"representation"}getType(){return this.repr.type}setRepresentation(t){this._disposeRepresentation(),this.repr=t,this.stage.tasks.listen(this.repr.tasks),this.updateVisibility()}_disposeRepresentation(){this.repr&&(this.stage.tasks.unlisten(this.repr.tasks),this.repr.dispose())}dispose(){this.parent&&this.parent.hasRepresentation(this)?this.parent.removeRepresentation(this):(this._disposeRepresentation(),this.signals.disposed.dispatch())}setVisibility(t){return this.parameters.visible=t,this.updateVisibility(),this.signals.visibilityChanged.dispatch(this.parameters.visible),this}getVisibility(){return this.parent?this.parent.parameters.visible&&this.parameters.visible:this.parameters.visible}toggleVisibility(){return this.setVisibility(!this.parameters.visible)}updateVisibility(){this.repr.setVisibility(this.getVisibility())}update(t){return this.repr.update(t),this}build(t){return this.repr.build(t),this}setSelection(t){const e=this.repr;return e.setSelection&&e.setSelection(t),this}setParameters(t){return this.repr.setParameters(t),this.signals.parametersChanged.dispatch(this.repr.getParameters()),this}getParameters(){return this.repr.getParameters()}setColor(t){return this.repr.setColor(t),this}}const ol=new i,al=new e,cl={name:"",status:"",visible:!0};class ll{constructor(t,s,n={}){this.stage=t,this.object=s,this.signals={representationAdded:new et,representationRemoved:new et,visibilityChanged:new et,matrixChanged:new et,statusChanged:new et,nameChanged:new et,disposed:new et},this.reprList=[],this.annotationList=[],this.matrix=new i,this.position=new e,this.quaternion=new r,this.scale=new e(1,1,1),this.transform=new i,this.parameters=nt(n,this.defaultParameters),this.uuid=Bt(),this.viewer=t.viewer,this.controls=new ua(this)}get defaultParameters(){return cl}get name(){return this.parameters.name}get status(){return this.parameters.status}get visible(){return this.parameters.visible}setPosition(t){return Array.isArray(t)?this.position.fromArray(t):this.position.copy(t),this.updateMatrix(),this}setRotation(t){if(Array.isArray(t))if(3===t.length){const e=(new j).fromArray(t);this.quaternion.setFromEuler(e)}else this.quaternion.fromArray(t);else t instanceof j?this.quaternion.setFromEuler(t):this.quaternion.copy(t);return this.updateMatrix(),this}setScale(t){return this.scale.set(t,t,t),this.updateMatrix(),this}setTransform(t){return this.transform.copy(t),this.updateMatrix(),this}updateMatrix(){const t=this.getCenterUntransformed(al);this.matrix.makeTranslation(-t.x,-t.y,-t.z),ol.makeRotationFromQuaternion(this.quaternion),this.matrix.premultiply(ol),ol.makeScale(this.scale.x,this.scale.y,this.scale.z),this.matrix.premultiply(ol);const e=this.position;ol.makeTranslation(e.x+t.x,e.y+t.y,e.z+t.z),this.matrix.premultiply(ol),this.matrix.premultiply(this.transform),this.updateRepresentationMatrices(),this.stage.viewer.updateBoundingBox(),this.signals.matrixChanged.dispatch(this.matrix)}updateRepresentationMatrices(){this.reprList.forEach((t=>{t.setParameters({matrix:this.matrix})}))}addAnnotation(t,e,i){const r=new ca(this,t,e,i);return this.annotationList.push(r),r}eachAnnotation(t){this.annotationList.slice().forEach(t)}removeAnnotation(t){const e=this.annotationList.indexOf(t);-1!==e&&(this.annotationList.splice(e,1),t.dispose())}removeAllAnnotations(){this.eachAnnotation((t=>t.dispose())),this.annotationList.length=0}_addRepresentation(t,e,i,r=!1){const s=i||{},n=this.stage.getParameters();s.matrix=this.matrix.clone(),s.quality=s.quality||n.quality,s.disableImpostor=st(s.disableImpostor,!n.impostor),s.useWorker=st(s.useWorker,n.workerDefault),s.visible=st(s.visible,!0);const o=Object.assign({},s,{visible:this.parameters.visible&&s.visible}),a=function(t,e,i,r){var s;if(De&&Me.time("makeRepresentation "+t),e instanceof Cc){if(!(s=Ne.get(t)))return void el(t)}else if(e instanceof Oo)if("surface"===t)s=Yo;else{if("dot"!==t)return void el(t);s=qc}else if(e instanceof Eo)if("surface"===t)s=Yo;else if("dot"===t)s=qc;else{if("slice"!==t)return void el(t);s=tl}else if(e instanceof Mc)s=Tc,e=e.getBufferList();else{if("buffer"!==t)return void Me.error("makeRepresentation: object "+e+" unknown");s=Tc}const n=new s(e,i,r);return De&&Me.timeEnd("makeRepresentation "+t),n}(t,e,this.viewer,o),c=new nl(this.stage,a,s,this);return r||(this.reprList.push(c),this.signals.representationAdded.dispatch(c)),c}addBufferRepresentation(t,e){return this._addRepresentation.call(this,"buffer",t,e)}hasRepresentation(t){return-1!==this.reprList.indexOf(t)}eachRepresentation(t){this.reprList.slice().forEach(t)}removeRepresentation(t){const e=this.reprList.indexOf(t);-1!==e&&(this.reprList.splice(e,1),t.dispose(),this.signals.representationRemoved.dispatch(t))}updateRepresentations(t){this.reprList.forEach((e=>e.update(t))),this.stage.viewer.requestRender()}removeAllRepresentations(){this.eachRepresentation((t=>t.dispose()))}dispose(){this.removeAllAnnotations(),this.removeAllRepresentations(),this.reprList.length=0,this.signals.disposed.dispatch()}setVisibility(t){return this.parameters.visible=t,this.eachRepresentation((t=>t.updateVisibility())),this.eachAnnotation((t=>t.updateVisibility())),this.signals.visibilityChanged.dispatch(t),this}setStatus(t){return this.parameters.status=t,this.signals.statusChanged.dispatch(t),this}setName(t){return this.parameters.name=t,this.signals.nameChanged.dispatch(t),this}getBox(...t){return this.getBoxUntransformed(...t).clone().applyMatrix4(this.matrix)}getCenter(...t){return this.getCenterUntransformed(...t).clone().applyMatrix4(this.matrix)}getZoom(...t){return this.stage.getZoomForBox(this.getBox(...t))}getBoxUntransformed(...t){return new a}getCenterUntransformed(...t){return this.getBoxUntransformed().getCenter(new e)}autoView(t){this.stage.animationControls.zoomMove(this.getCenter(),this.getZoom(),st(t,0))}}class hl{constructor(t=[]){this.list=t;const e=t.length;for(let i=0;i0?this.list[0]:void 0}forEach(t){return this.list.forEach(t),this}dispose(){return this.forEach((t=>t.dispose()))}}class dl extends hl{setParameters(t){return this.forEach((e=>e.setParameters(t)))}setVisibility(t){return this.forEach((e=>e.setVisibility(t)))}setSelection(t){return this.forEach((e=>e.setSelection(t)))}setColor(t){return this.forEach((e=>e.setColor(t)))}update(t){return this.forEach((e=>e.update(t)))}build(t){return this.forEach((e=>e.build(t)))}dispose(t){return this.forEach((t=>t.dispose()))}}const ul=Object.assign({defaultStep:1,defaultTimeout:50,defaultInterpolateType:"",defaultInterpolateStep:5,defaultMode:"loop",defaultDirection:"forward",initialFrame:0},il);class ml extends rl{constructor(t,e,i={}){super(t,Object.assign({name:e.name},i)),this.trajectory=e,this.signals=Object.assign(this.signals,{frameChanged:new et,playerChanged:new et,countChanged:new et,parametersChanged:new et}),e.signals.frameChanged.add((t=>{this.signals.frameChanged.dispatch(t)})),e.signals.playerChanged.add((t=>{this.signals.playerChanged.dispatch(t)})),e.signals.countChanged.add((t=>{this.signals.countChanged.dispatch(t)})),void 0!==i.initialFrame&&this.setFrame(i.initialFrame)}get defaultParameters(){return ul}get type(){return"trajectory"}setFrame(t){this.trajectory.setFrame(t)}setParameters(t={}){this.trajectory.setParameters(t),this.signals.parametersChanged.dispatch(t)}dispose(){this.trajectory.dispose(),super.dispose()}}class pl{constructor(t,e){this.name=t,this.path=e,this.coordinates=[],this.boxes=[],this.times=[],this.timeOffset=0,this.deltaTime=1}get type(){return"Frames"}}class fl{constructor(t,e){let r,s;if(this.A=new ho(3,3),this.W=new ho(1,3),this.U=new ho(3,3),this.V=new ho(3,3),this.VH=new ho(3,3),this.R=new ho(3,3),this.tmp=new ho(3,3),this.c=new ho(3,3),t instanceof Cc)r=t.atomCount;else{if(!(t instanceof Float32Array))return;r=t.length/3}if(e instanceof Cc)s=e.atomCount;else{if(!(e instanceof Float32Array))return;s=e.length/3}const n=Math.min(r,s),o=new ho(3,n),a=new ho(3,n);this.coords1t=new ho(n,3),this.coords2t=new ho(n,3),this.transformationMatrix=new i,this.c.data.set([1,0,0,0,1,0,0,0,-1]),this.prepCoords(t,o,n,!1),this.prepCoords(e,a,n,!1),this._superpose(o,a)}_superpose(t,e){this.mean1=fo(t),this.mean2=fo(e),go(t,this.mean1),go(e,this.mean2),uo(this.coords1t,t),uo(this.coords2t,e),mo(this.A,this.coords2t,this.coords1t),wo(this.A,this.W,this.U,this.V),function(t,e){const i=t.data,r=e.data,s=i[4],n=i[8],o=i[5],a=i[7],c=i[0],l=c*s,h=c*o,d=i[3],u=i[1],m=d*u,p=i[2],f=d*p,g=i[6],y=g*u,b=g*p,x=1/(l*n-h*a-m*n+f*a+y*o-b*s);r[0]=(s*n-o*a)*x,r[1]=-(u*n-p*a)*x,r[2]=-(-u*o+p*s)*x,r[3]=-(d*n-o*g)*x,r[4]=(c*n-b)*x,r[5]=-(h-f)*x,r[6]=-(-d*a+s*g)*x,r[7]=-(c*a-y)*x,r[8]=(l-m)*x}(this.V,this.VH),po(this.R,this.U,this.VH),function(t){const e=t.data;return e[0]*e[4]*e[8]-e[0]*e[5]*e[7]-e[3]*e[1]*e[8]+e[3]*e[2]*e[7]+e[6]*e[1]*e[5]-e[6]*e[2]*e[4]}(this.R)<0&&(De&&Me.log("R not a right handed system"),po(this.tmp,this.c,this.VH),po(this.R,this.U,this.tmp));const i=new ho(4,4),r=new ho(4,4),s=new ho(4,4),n=new ho(4,4),o=new ho(4,4),a=new ho(4,4),c=this.R.data,l=this.mean1,h=this.mean2;n.data.set([1,0,0,-l[0],0,1,0,-l[1],0,0,1,-l[2],0,0,0,1]),o.data.set([c[0],c[1],c[2],0,c[3],c[4],c[5],0,c[6],c[7],c[8],0,0,0,0,1]),a.data.set([1,0,0,h[0],0,1,0,h[1],0,0,1,h[2],0,0,0,1]),uo(r,n),mo(i,o,r),uo(s,i),mo(r,a,s),uo(i,r),this.transformationMatrix.elements=i.data}prepCoords(t,e,i,r){let s=0;const n=e.data;let o=3,a=3*i;if(r&&(a=4*i,o=4),t instanceof Cc)t.eachAtom((function(t){s{t!==this&&this.pause()}),this);const i=st(t.frameCount,1);this.traj=t,this.parameters=nt(e,gl),this.parameters.end=Math.min(st(e.end,i-1),i-1),this.parameters.step=st(e.step,Math.ceil((i+1)/100)),this._currentFrame=this.parameters.start,this._direction="bounce"===this.parameters.direction?"forward":this.parameters.direction,t.signals.countChanged.add((t=>{this.parameters.end=Math.min(st(this.parameters.end,t-1),t-1)}),this),this._animate=this._animate.bind(this)}get isRunning(){return this._run}setParameters(t={}){ot(this.parameters,t),void 0!==t.direction&&"bounce"!==this.parameters.direction&&(this._direction=this.parameters.direction)}_animate(){if(!this._run)return;this._currentTime=window.performance.now();const t=this._currentTime-this._previousTime,e=this.parameters.interpolateType?this.parameters.interpolateStep:1,i=this.parameters.timeout/e,r=this.traj;if(r&&r.frameCount&&!r.inProgress&&t>=i)if(this.parameters.interpolateType)if(this._currentStep>this.parameters.interpolateStep&&(this._currentStep=1),1===this._currentStep&&(this._currentFrame=this._nextInterpolated()),r.hasFrame(this._currentFrame)){this._currentStep+=1;const t=this._currentStep/(this.parameters.interpolateStep+1),[e,i,s,n]=this._currentFrame;r.setFrameInterpolated(e,i,s,n,t,this.parameters.interpolateType),this._previousTime=this._currentTime}else r.loadFrame(this._currentFrame);else{const t=this._next();r.hasFrame(t)?(r.setFrame(t),this._previousTime=this._currentTime):r.loadFrame(t)}window.requestAnimationFrame(this._animate)}_next(){const t=this.parameters;let e;return e="forward"===this._direction?this.traj.currentFrame+t.step:this.traj.currentFrame-t.step,(e>t.end||e=t.end?i=t.start:"backward"===t.direction&&e<=t.start&&(i=t.end),this.traj.setFrame(i),this._run=!0,this._animate(),this.signals.startedRunning.dispatch()}}pause(){this._run=!1,this.signals.haltedRunning.dispatch()}stop(){this.pause(),this.traj.setFrame(this.parameters.start)}}class bl{constructor(t,e,i={}){this.signals={countChanged:new et,frameChanged:new et,playerChanged:new et},this.frameCache={},this.loadQueue={},this.boxCache={},this.pathCache={},this.frameCacheSize=0,this._frameCount=0,this._currentFrame=-1,this._disposed=!1,this.deltaTime=st(i.deltaTime,0),this.timeOffset=st(i.timeOffset,0),this.centerPbc=st(i.centerPbc,!1),this.removePbc=st(i.removePbc,!1),this.removePeriodicity=st(i.removePeriodicity,!1),this.superpose=st(i.superpose,!1),this.name=t.replace(/^.*[\\/]/,""),this.trajPath=t,this.selection=new pe(st(i.sele,"backbone and not hydrogen")),this.selection.signals.stringChanged.add((()=>{this.selectionIndices=this.structure.getAtomIndices(this.selection),this._resetCache(),this._saveInitialCoords(),this.setFrame(this._currentFrame)}))}get frameCount(){return this._frameCount}get currentFrame(){return this._currentFrame}_init(t){this.setStructure(t),this._loadFrameCount(),this.setPlayer(new yl(this))}_loadFrameCount(){}setStructure(t){this.structure=t,this.atomCount=t.atomCount,this.backboneIndices=this._getIndices(new pe("backbone and not hydrogen")),this._makeAtomIndices(),this._saveStructureCoords(),this.selectionIndices=this._getIndices(this.selection),this._resetCache(),this._saveInitialCoords(),this.setFrame(this._currentFrame)}_saveInitialCoords(){this.structure.hasCoords()?(this.initialCoords=new Float32Array(this.structureCoords),this._makeSuperposeCoords()):this.frameCache[0]?(this.initialCoords=new Float32Array(this.frameCache[0]),this._makeSuperposeCoords()):this.loadFrame(0,(()=>this._saveInitialCoords()))}_saveStructureCoords(){this.structureCoords=this.structure.getAtomData({what:{position:!0}}).position}setSelection(t){return this.selection.setString(t),this}_getIndices(t){let e=0;const i=t.test,r=[];return i&&this.structure.eachAtom((t=>{i(t)&&r.push(e),e+=1})),r}_makeSuperposeCoords(){const t=3*this.selectionIndices.length;this.coords1=new Float32Array(t),this.coords2=new Float32Array(t);const e=this.initialCoords,i=this.coords2;for(let r=0;r!!this.frameCache[t])):!!this.frameCache[t]}setFrame(t,e){return void 0===t||(this.inProgress=!0,-1===t||this.frameCache[t]?(this._updateStructure(t),e&&e()):this.loadFrame(t,(()=>{this._updateStructure(t),e&&e()}))),this}_interpolate(t,e,i,r,s,n){const o=this.frameCache;let a;a="spline"===n?function(t,e,i,r,s){const n=t.length,o=new Float32Array(n);for(let a=0;a{this._interpolate(t,e,i,r,s,n),o&&o()})):(this._interpolate(t,e,i,r,s,n),o&&o()),this}loadFrame(t,e){Array.isArray(t)?t.forEach((t=>{this.loadQueue[t]||this.frameCache[t]||(this.loadQueue[t]=!0,this._loadFrame(t,(()=>{delete this.loadQueue[t]})))})):this.loadQueue[t]||this.frameCache[t]||(this.loadQueue[t]=!0,this._loadFrame(t,(()=>{delete this.loadQueue[t],e&&e()})))}_loadFrame(t,e){Me.error("Trajectory._loadFrame not implemented",t,e)}_updateStructure(t){this._disposed?console.error("updateStructure: traj disposed"):(-1===t?this.structureCoords&&this.structure.updatePosition(this.structureCoords):this.structure.updatePosition(this.frameCache[t]),this.structure.trajectory={name:this.trajPath,frame:t},this._currentFrame=t,this.inProgress=!1,this.signals.frameChanged.dispatch(t))}_doSuperpose(t){const e=3*this.selectionIndices.length,i=this.coords1,r=this.coords2;for(let r=0;r0&&this.centerPbc){const t=[e[0],e[4],e[8]],r=function(t,e,i){return[wi(e,i[0],3,0,t),wi(e,i[1],3,1,t),wi(e,i[2],3,2,t)]}(this.backboneIndices,i,t);!function(t,e,i){if(0===i[0]||0===i[8]||0===i[4])return;const r=t.length,s=i[0],n=i[1],o=i[2],a=-e[0]+s+s/2,c=-e[1]+n+n/2,l=-e[2]+o+o/2;for(let e=0;e.5&&(t[s+r]-=e[3*r+r]*Math.round(n))}}(i,e,t)}this.removePbc&&function(t,e){if(0===e[0]||0===e[8]||0===e[4])return;const i=t.length;for(let r=3;r.9*e[3*i+i])if(s>0)for(let s=0;s<3;++s)t[r+s]-=e[3*i+s];else for(let s=0;s<3;++s)t[r+s]+=e[3*i+s]}}(i,e)}this.selectionIndices.length>0&&this.coords1&&this.superpose&&this._doSuperpose(i),this.frameCache[t]=i,this.boxCache[t]=e,this.frameCacheSize+=1}_setFrameCount(t){t!==this._frameCount&&(this._frameCount=t,this.signals.countChanged.dispatch(t))}dispose(){this._resetCache(),this._disposed=!0,this.player&&this.player.stop()}setPlayer(t){this.player=t,this.signals.playerChanged.dispatch(t)}getFrameTime(t){return this.timeOffset+t*this.deltaTime}}class xl extends bl{constructor(t,e,i){const r=i||{};r.timeOffset=st(r.timeOffset,t.timeOffset),r.deltaTime=st(r.deltaTime,t.deltaTime),super("",e,r),this.name=t.name,this.path=t.path,this.frames=t.coordinates,this.boxes=t.boxes,this._init(e)}get type(){return"frames"}_makeAtomIndices(){"StructureView"===this.structure.type?this.atomIndices=this.structure.getAtomIndices():this.atomIndices=void 0}_loadFrame(t,e){let i;const r=this.frames[t];if(this.atomIndices){const t=this.atomIndices,e=t.length;i=new Float32Array(3*e);for(let s=0;s{const s=i.response;if(!s)return void Me.error(`empty arrayBuffer for '${r}'`);const n=new Int32Array(s,0,1)[0],o=new Float32Array(s,8,9),a=new Float32Array(s,44);this._process(t,o,a,n),"function"==typeof e&&e()}),!1),i.send(s)}_loadFrameCount(){const t=new XMLHttpRequest,e=qe.getCountUrl(this.trajPath);t.open("GET",e,!0),t.addEventListener("load",(()=>{this._setFrameCount(parseInt(t.response))}),!1),t.send()}}class Al extends bl{constructor(t,e,i){super("",e,i),this.requestCallback=t,this._init(e)}get type(){return"callback"}_makeAtomIndices(){const t=[];if("StructureView"===this.structure.type){const e=this.structure.getAtomIndices(),i=e.length;let r=e[0],s=e[0];for(let n=1;n{this._process(t,i,r,s),"function"==typeof e&&e()}),t,this.atomIndices)}_loadFrameCount(){this.requestCallback((t=>this._setFrameCount(t)))}}Cc.prototype.getView=function(t){return new _l(this,t)};class _l extends Cc{constructor(t,i){super(),this.structure=t,this.selection=i,this.center=new e,this.boundingBox=new a,this._bp=this.getBondProxy(),this._ap=this.getAtomProxy(),this._rp=this.getResidueProxy(),this._cp=this.getChainProxy(),this.selection&&this.selection.signals.stringChanged.add(this.refresh,this),this.structure.signals.refreshed.add(this.refresh,this),this.refresh()}init(){}get type(){return"StructureView"}get name(){return this.structure.name}get path(){return this.structure.path}get title(){return this.structure.title}get id(){return this.structure.id}get data(){return this.structure.data}get atomSetDict(){return this.structure.atomSetDict}get biomolDict(){return this.structure.biomolDict}get entityList(){return this.structure.entityList}get unitcell(){return this.structure.unitcell}get frames(){return this.structure.frames}get boxes(){return this.structure.boxes}get validation(){return this.structure.validation}get bondStore(){return this.structure.bondStore}get backboneBondStore(){return this.structure.backboneBondStore}get rungBondStore(){return this.structure.rungBondStore}get atomStore(){return this.structure.atomStore}get residueStore(){return this.structure.residueStore}get chainStore(){return this.structure.chainStore}get modelStore(){return this.structure.modelStore}get atomMap(){return this.structure.atomMap}get residueMap(){return this.structure.residueMap}get bondHash(){return this.structure.bondHash}get spatialHash(){return this.structure.spatialHash}get _hasCoords(){return this.structure._hasCoords}set _hasCoords(t){this.structure._hasCoords=t}refresh(){De&&Me.time("StructureView.refresh"),this.atomSetCache={};const t=this.structure;if(this.selection.isAllSelection()&&t!==this&&t.atomSet&&t.bondSet){this.atomSet=t.atomSet.clone(),this.bondSet=t.bondSet.clone();for(let t in this.atomSetDict){const e=this.atomSetDict[t];this.atomSetCache["__"+t]=e.clone()}this.atomCount=t.atomCount,this.bondCount=t.bondCount,this.boundingBox.copy(t.boundingBox),this.center.copy(t.center)}else if(this.selection.isNoneSelection()&&t!==this&&t.atomSet&&t.bondSet){this.atomSet=new Os(t.atomCount),this.bondSet=new Os(t.bondCount);for(let e in this.atomSetDict)this.atomSetCache["__"+e]=new Os(t.atomCount);this.atomCount=0,this.bondCount=0,this.boundingBox.makeEmpty(),this.center.set(0,0,0)}else{this.atomSet=this.getAtomSet(this.selection,!0),t.atomSet&&(this.atomSet=this.atomSet.intersection(t.atomSet)),this.bondSet=this.getBondSet();for(let t in this.atomSetDict){const e=this.atomSetDict[t];this.atomSetCache["__"+t]=e.makeIntersection(this.atomSet)}this.atomCount=this.atomSet.getSize(),this.bondCount=this.bondSet.getSize(),this.boundingBox=this.getBoundingBox(),this.center=this.boundingBox.getCenter(new e)}De&&Me.timeEnd("StructureView.refresh"),this.signals.refreshed.dispatch()}setSelection(t){this.selection=t,this.refresh()}getSelection(t){const e=[];t&&t.string&&e.push(t.string);const i=this.structure.getSelection();i&&i.string&&e.push(i.string),this.selection&&this.selection.string&&e.push(this.selection.string);let r="";return e.length>0&&(r=`( ${e.join(" ) AND ( ")} )`),new pe(r)}getStructure(){return this.structure.getStructure()}eachBond(t,e){this.structure.eachBond(t,this.getSelection(e))}eachAtom(t,e){const i=this.getAtomProxy(),r=this.getAtomSet(e),s=this.atomStore.count;if(r.getSize()=this.V[i][r]?(e="S",this.score=this.S[i][r]):this.V[i][r]>=this.H[i][r]?(e="V",this.score=this.V[i][r]):(e="H",this.score=this.H[i][r]),De&&Me.log("Alignment: SCORE",this.score),De&&Me.log("Alignment: S, V, H",this.S[i][r],this.V[i][r],this.H[i][r]);i>0&&r>0;)"S"===e?this.S[i][r]===this.S[i-1][r-1]+t(i-1,r-1)?(this.ali1=this.seq1[i-1]+this.ali1,this.ali2=this.seq2[r-1]+this.ali2,--i,--r,e="S"):this.S[i][r]===this.V[i][r]?e="V":this.S[i][r]===this.H[i][r]?e="H":(--i,--r):"V"===e?this.V[i][r]===this.V[i-1][r]+this.gapExtensionPenalty?(this.ali1=this.seq1[i-1]+this.ali1,this.ali2="-"+this.ali2,--i,e="V"):this.V[i][r]===this.S[i-1][r]+this.gap(0)?(this.ali1=this.seq1[i-1]+this.ali1,this.ali2="-"+this.ali2,--i,e="S"):--i:"H"===e?this.H[i][r]===this.H[i][r-1]+this.gapExtensionPenalty?(this.ali1="-"+this.ali1,this.ali2=this.seq2[r-1]+this.ali2,--r,e="H"):this.H[i][r]===this.S[i][r-1]+this.gap(0)?(this.ali1="-"+this.ali1,this.ali2=this.seq2[r-1]+this.ali2,--r,e="S"):--r:Me.error("Alignment: no matrix");for(;i>0;)this.ali1=this.seq1[i-1]+this.ali1,this.ali2="-"+this.ali2,--i;for(;r>0;)this.ali1="-"+this.ali1,this.ali2=this.seq2[r-1]+this.ali2,--r;De&&Me.timeEnd("Alignment.trace"),De&&Me.log([this.ali1,this.ali2])}}function kl(t,e,i=!1,r="",s=""){let n,o,a,c,l;if(i){let i=t,h=e;r&&s&&(i=t.getView(new pe(r)),h=e.getView(new pe(s)));const d=i.getSequence(),u=h.getSequence(),m=new Il(d.join(""),u.join(""));let p,f;m.calc(),m.trace(),n=0,o=0,a=m.ali1.length;const g=[],y=[];for(let t=0;tt[e]))}}}(),this.spacefillRepresentation=this.addRepresentation("spacefill",{sele:"none",opacity:Te.opacity,color:Te.color,disablePicking:!0,radiusType:"data"},!0),this.distanceRepresentation=this.addRepresentation("distance",Te,!0),this.angleRepresentation=this.addRepresentation("angle",Te,!0),this.dihedralRepresentation=this.addRepresentation("dihedral",Te,!0),this.measureRepresentations=new dl([this.spacefillRepresentation,this.distanceRepresentation,this.angleRepresentation,this.dihedralRepresentation]),this.setDefaultAssembly(this.parameters.defaultAssembly),this.structure.signals.refreshed.add((()=>{this.updateRepresentations({position:!0})}))}get defaultParameters(){return Ml}get type(){return"structure"}initSelection(t){this.selection=new pe(t),this.structureView=new _l(this.structure,this.selection),this.selection.signals.stringChanged.add((()=>{this.structureView.setSelection(this.selection),this.rebuildRepresentations(),this.rebuildTrajectories()}))}setSelection(t){return this.parameters.sele=t,this.selection.setString(t),this}setDefaultAssembly(t){if(void 0===this.structure.biomolDict[t]&&(t=""),this.parameters.defaultAssembly!==t){const e={defaultAssembly:t};this.reprList.forEach((t=>t.setParameters(e))),this.measureRepresentations.setParameters(e),this.parameters.defaultAssembly=t,this.signals.defaultAssemblyChanged.dispatch(t)}return this}rebuildRepresentations(){this.reprList.forEach((t=>{t.build()})),this.measureRepresentations.build()}rebuildTrajectories(){this.trajList.forEach((t=>{t.trajectory.setStructure(this.structureView)}))}updateRepresentations(t){super.updateRepresentations(t),this.measureRepresentations.update(t)}updateRepresentationMatrices(){super.updateRepresentationMatrices(),this.measureRepresentations.setParameters({matrix:this.matrix})}addRepresentation(t,e={},i=!1){e.defaultAssembly=this.parameters.defaultAssembly;const r=this._addRepresentation(t,this.structureView,e,i);return i||r.signals.parametersChanged.add((()=>this.measureUpdate())),r}addTrajectory(t="",e={}){const i=function(t,e,i){let r;return r=t&&t instanceof pl?new xl(t,e,i):!t&&e.frames?new vl(t,e,i):t&&"function"==typeof t?new Al(t,e,i):new wl(t,e,i),r}(t,this.structureView,e),r=new ml(this.stage,i,e);return this.trajList.push(r),this.signals.trajectoryAdded.dispatch(r),r}removeTrajectory(t){const e=this.trajList.indexOf(t);-1!==e&&this.trajList.splice(e,1),t.dispose(),this.signals.trajectoryRemoved.dispatch(t)}dispose(){this.trajList.slice().forEach((t=>t.dispose())),this.trajList.length=0,this.structure.dispose(),this.measureRepresentations.dispose(),super.dispose()}autoView(t,e){"number"==typeof t&&(e=t,t=""),this.stage.animationControls.zoomMove(this.getCenter(t),this.getZoom(t),st(e,0))}getBoxUntransformed(t){let e;return e=t?this.structureView.getBoundingBox(new pe(t)):this.structureView.boundingBox,e}getCenterUntransformed(t){return t&&"string"==typeof t?this.structure.atomCenter(new pe(t)):this.structure.center}superpose(t,e,i,r){return kl(this.structureView,t.structureView,e,i,r),this.updateRepresentations({position:!0}),this}getMaxRepresentationRadius(t){let e=0;const i=this.structure.getAtomProxy(t);return this.eachRepresentation((t=>{if(t.getVisibility()){const r=t.repr;e=Math.max(r.getAtomRadius(i),e)}})),e}measurePick(t){const e=this.pickBuffer.count;if(this.lastPick===t.index&&e>=1){if(e>1){const t=this.pickBuffer.data,i=this.pickBuffer.data.sort();this.pickDict.has(i)?this.pickDict.del(i):this.pickDict.add(i,t),2===e?this.distanceRepresentation.setParameters({atomPair:this.pickDict.values.filter((t=>2===t.length))}):3===e?this.angleRepresentation.setParameters({atomTriple:this.pickDict.values.filter((t=>3===t.length))}):4===e&&this.dihedralRepresentation.setParameters({atomQuad:this.pickDict.values.filter((t=>4===t.length))})}this.pickBuffer.clear(),this.lastPick=void 0}else this.pickBuffer.has(t.index)||this.pickBuffer.push(t.index),this.lastPick=t.index;this.measureUpdate()}measureClear(){this.pickBuffer.clear(),this.lastPick=void 0,this.spacefillRepresentation.setSelection("none")}measureBuild(){const t=this.measureData();this.distanceRepresentation.setParameters({atomPair:t.distance}),this.angleRepresentation.setParameters({atomTriple:t.angle}),this.dihedralRepresentation.setParameters({atomQuad:t.dihedral})}measureUpdate(){const t=this.pickBuffer.data,e={};t.forEach((t=>{const i=Math.max(.1,this.getMaxRepresentationRadius(t));e[t]=i*(2.3-Rt(.1,2,i))})),this.spacefillRepresentation.setSelection(t.length?"@"+t.join(","):"none"),t.length&&this.spacefillRepresentation.setParameters({radiusData:e})}measureData(){const t=this.pickDict.values;return{distance:t.filter((t=>2===t.length)),angle:t.filter((t=>3===t.length)),dihedral:t.filter((t=>4===t.length))}}removeAllMeasurements(t){const e=this.pickDict,i=e.values,r=function(t){i.filter((e=>e.length===t)).forEach((t=>e.del(t.slice().sort())))};(!t||1&t)&&r(2),(!t||2&t)&&r(3),(!t||4&t)&&r(4),this.measureBuild()}removeMeasurement(t){this.pickDict.del(t.slice().sort()),this.measureBuild()}addMeasurement(t){if(t.length<2||t.length>4)return;const e=t.slice().sort();this.pickDict.has(e)||this.pickDict.add(e,t),this.measureBuild()}}Ue.add("structure",Tl),Ue.add("structureview",Tl);class Bl extends ll{constructor(t,e,i={}){super(t,e,Object.assign({name:e.name},i)),this.surface=e}get type(){return"surface"}addRepresentation(t,e={}){return this._addRepresentation(t,this.surface,e)}getBoxUntransformed(){return this.surface.boundingBox}getCenterUntransformed(){return this.surface.center}dispose(){this.surface.dispose(),super.dispose()}}Ue.add("surface",Bl);class Dl extends ll{constructor(t,e,i={}){super(t,e,Object.assign({name:e.name},i)),this.volume=e}get type(){return"volume"}addRepresentation(t,e={}){return this._addRepresentation(t,this.volume,e)}getBoxUntransformed(){return this.volume.boundingBox}getCenterUntransformed(){return this.volume.center}dispose(){this.volume.dispose(),super.dispose()}}Ue.add("volume",Dl);class $l extends hl{addRepresentation(t,e){return this.forEach((i=>i.addRepresentation(t,e)))}autoView(t){return this.forEach((e=>e.autoView(t)))}}function Ol(t,e){return t instanceof RegExp?null!==e.name.match(t):e.name===t}const Rl=new e,El={impostor:!0,quality:"medium",workerDefault:!0,sampleLevel:0,backgroundColor:"black",rotateSpeed:2,zoomSpeed:1.2,panSpeed:1,clipNear:0,clipFar:100,clipDist:10,clipMode:"scene",clipScale:"relative",fogNear:50,fogFar:100,cameraFov:40,cameraEyeSep:.3,cameraType:"perspective",lightColor:14540253,lightIntensity:1,ambientColor:14540253,ambientIntensity:.2,hoverTimeout:0,tooltip:!0,mousePreset:"default"};class Fl{constructor(t,e={}){this.signals={parametersChanged:new et,fullscreenChanged:new et,componentAdded:new et,componentRemoved:new et,clicked:new et,hovered:new et},this.tasks=new ui,this.compList=[],this.defaultFileParams={},this.logList=[],this.viewer=new Ji(t),this.viewer.renderer&&(this.tooltip=document.createElement("div"),Object.assign(this.tooltip.style,{display:"none",position:"fixed",zIndex:"1000000",pointerEvents:"none",backgroundColor:"rgba( 0, 0, 0, 0.6 )",color:"lightgrey",padding:"8px",fontFamily:"sans-serif"}),this.viewer.container.appendChild(this.tooltip),this.mouseObserver=new sr(this.viewer.renderer.domElement),this.viewerControls=new kr(this),this.trackballControls=new gr(this),this.pickingControls=new xr(this),this.animationControls=new Lr(this),this.mouseControls=new Jo(this),this.keyControls=new ia(this),this.pickingBehavior=new ra(this),this.mouseBehavior=new sa(this),this.animationBehavior=new na(this),this.keyBehavior=new aa(this),this.spinAnimation=this.animationControls.spin([0,1,0],.005),this.spinAnimation.pause(!0),this.rockAnimation=this.animationControls.rock([0,1,0],.005),this.rockAnimation.pause(!0),this.parameters=nt(e,El),this.setParameters(this.parameters),this.viewer.animate())}setParameters(t={}){ot(this.parameters,t);const e=t,i=this.parameters,r=this.viewer,s=this.trackballControls;return void 0!==e.quality&&this.setQuality(i.quality),void 0!==e.impostor&&this.setImpostor(i.impostor),void 0!==e.rotateSpeed&&(s.rotateSpeed=i.rotateSpeed),void 0!==e.zoomSpeed&&(s.zoomSpeed=i.zoomSpeed),void 0!==e.panSpeed&&(s.panSpeed=i.panSpeed),void 0!==e.mousePreset&&this.mouseControls.preset(i.mousePreset),this.mouseObserver.setParameters({hoverTimeout:i.hoverTimeout}),r.setClip(i.clipNear,i.clipFar,i.clipDist,i.clipMode,i.clipScale),r.setFog(void 0,i.fogNear,i.fogFar),r.setCamera(i.cameraType,i.cameraFov,i.cameraEyeSep),r.setSampling(i.sampleLevel),r.setBackground(i.backgroundColor),r.setLight(i.lightColor,i.lightIntensity,i.ambientColor,i.ambientIntensity),this.signals.parametersChanged.dispatch(this.getParameters()),this}log(t){console.log("STAGE LOG",t),this.logList.push(t)}getParameters(){return Object.assign({},this.parameters)}defaultFileRepresentation(t){if(t instanceof Tl){let e,i,r;t.setSelection("/0");const s=t.structure;if(s.biomolDict.BU1){const n=s.biomolDict.BU1;e=n.getAtomCount(s),i=n.getResidueCount(s),r=n.getInstanceCount(),t.setDefaultAssembly("BU1")}else e=s.getModelProxy(0).atomCount,i=s.getModelProxy(0).residueCount,r=1;let n=e;Se&&(n*=4);const o=s.atomStore.count/s.residueStore.count<2;o&&(n*=10);let a="chainname",c="RdYlBu",l=!1;if(1===s.getChainnameCount(new pe("polymer and /0"))&&(a="residueindex",c="Spectral",l=!0),De&&console.log(n,e,r,o),i/r<4)t.addRepresentation("ball+stick",{colorScheme:"element",radiusScale:2,aspectRatio:1.5,bondScale:.3,bondSpacing:.75,quality:"auto"});else if(r>5&&n>15e3||n>7e5){let e=Math.min(2,Math.max(.1,6e3/(n/r)));o&&(e=Math.min(e,.5)),t.addRepresentation("surface",{colorScheme:a,colorScale:c,colorReverse:l,sele:"polymer",surfaceType:"av",probeRadius:1.4,scaleFactor:e,useWorker:!1})}else n>25e4?t.addRepresentation("backbone",{colorScheme:a,colorScale:c,colorReverse:l,lineOnly:!0}):n>1e5?t.addRepresentation("backbone",{colorScheme:a,colorScale:c,colorReverse:l,quality:"low",disableImpostor:!0,radiusScale:2}):n>8e4?t.addRepresentation("backbone",{colorScheme:a,colorScale:c,colorReverse:l,radiusScale:2}):(t.addRepresentation("cartoon",{colorScheme:a,colorScale:c,colorReverse:l,radiusScale:.7,aspectRatio:5,quality:"auto"}),n<5e4&&t.addRepresentation("base",{colorScheme:a,colorScale:c,colorReverse:l,quality:"auto"}),t.addRepresentation("ball+stick",{sele:"ligand",colorScheme:"element",radiusScale:2,aspectRatio:1.5,bondScale:.3,bondSpacing:.75,quality:"auto"}));t.structure.frames.length&&t.addTrajectory()}else(t instanceof Bl||t instanceof Dl)&&t.addRepresentation("surface");this.tasks.onZeroOnce(this.autoView,this)}loadFile(t,e={}){const i=Object.assign({},this.defaultFileParams,e),r=ri(t).name;this.tasks.increment(),this.log(`loading file '${r}'`);const s=st(i.ext,ri(t).ext);let n;return n=ze.isTrajectory(s)?Promise.reject(new Error(`loadFile: ext '${s}' is a trajectory and must be loaded into a structure component`)):ni(t,i),n.then((t=>{this.log(`loaded '${r}'`);const e=this.addComponentFromObject(t,i);return i.defaultRepresentation&&this.defaultFileRepresentation(e),this.tasks.decrement(),e}),(t=>{this.tasks.decrement();const e=`error loading file: '${t}'`;throw this.log(e),e}))}loadScript(t){const e=ri(t).name;return this.log(`loading script '${e}'`),ni(t).then((t=>{this.tasks.increment(),this.log(`running script '${e}'`),t.run(this).then((()=>{this.tasks.decrement(),this.log(`finished script '${e}'`)})),this.log(`called script '${e}'`)}),(t=>{this.tasks.decrement();const i=`errored script '${e}' "${t}"`;throw this.log(i),i}))}addComponent(t){t?(this.compList.push(t),this.signals.componentAdded.dispatch(t)):Me.warn("Stage.addComponent: no component given")}addComponentFromObject(t,e={}){const i=Ue.get(t.type);if(i){const r=new i(this,t,e);return this.addComponent(r),r}Me.warn("no component for object type",t.type)}removeComponent(t){const e=this.compList.indexOf(t);-1!==e&&(this.compList.splice(e,1),t.dispose(),this.signals.componentRemoved.dispatch(t))}removeAllComponents(){this.compList.slice().forEach((t=>this.removeComponent(t)))}handleResize(){this.viewer.handleResize()}setSize(t,e){const i=this.viewer.container;i!==document.body&&(void 0!==t&&(i.style.width=t),void 0!==e&&(i.style.height=e),this.handleResize())}toggleFullscreen(t){if(!(document.fullscreenEnabled||document.mozFullScreenEnabled||document.webkitFullscreenEnabled||document.msFullscreenEnabled))return void Me.log("fullscreen mode (currently) not possible");const e=this;function i(){return document.fullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement||document.msFullscreenElement}function r(){if(!i()&&e.lastFullscreenElement){const t=e.lastFullscreenElement;t.style.width=t.dataset.normalWidth||"",t.style.height=t.dataset.normalHeight||"",document.removeEventListener("fullscreenchange",r),document.removeEventListener("mozfullscreenchange",r),document.removeEventListener("webkitfullscreenchange",r),document.removeEventListener("MSFullscreenChange",r),e.handleResize(),e.signals.fullscreenChanged.dispatch(!1)}}t=t||this.viewer.container,this.lastFullscreenElement=t,i()?document.exitFullscreen?document.exitFullscreen():document.msExitFullscreen?document.msExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen&&document.webkitExitFullscreen():(t.dataset.normalWidth=t.style.width||"",t.dataset.normalHeight=t.style.height||"",t.style.width=window.screen.width+"px",t.style.height=window.screen.height+"px",t.requestFullscreen?t.requestFullscreen():t.msRequestFullscreen?t.msRequestFullscreen():t.mozRequestFullScreen?t.mozRequestFullScreen():t.webkitRequestFullscreen&&t.webkitRequestFullscreen(),document.addEventListener("fullscreenchange",r),document.addEventListener("mozfullscreenchange",r),document.addEventListener("webkitfullscreenchange",r),document.addEventListener("MSFullscreenChange",r),this.handleResize(),this.signals.fullscreenChanged.dispatch(!0),setTimeout((function(){e.handleResize()}),100))}setSpin(t){t?(this.spinAnimation.resume(!0),this.rockAnimation.pause(!0)):this.spinAnimation.pause(!0)}setRock(t){t?(this.rockAnimation.resume(!0),this.spinAnimation.pause(!0)):this.rockAnimation.pause(!0)}toggleSpin(){this.setSpin(this.spinAnimation.paused)}toggleRock(){this.setRock(this.rockAnimation.paused)}getFocus(){const t=this.parameters;if("scene"!==t.clipMode)return 0;let e=t.clipNear;return"absolute"===t.clipScale&&(e=this.viewer.absoluteToRelative(e)),2*e}setFocus(t){if("scene"!==this.parameters.clipMode)return;let e,i,r,s;"relative"===this.parameters.clipScale?(e=Dt(t/2,0,49.9),i=100-e,r=50,s=function(t){return Dt(t,0,100)}(2*i-50)):(e=this.viewer.relativeToAbsolute(t/2),i=e,r=0,s=2*i),this.setParameters({clipNear:e,clipFar:i,fogNear:r,fogFar:s})}getZoomForBox(t){const e=t.getSize(Rl),i=Math.max(e.x,e.y,e.z),r=Math.min(e.x,e.y,e.z);let s=i+Math.sqrt(r);const n=kt(this.viewer.perspectiveCamera.fov),o=this.viewer.width,a=this.viewer.height,c=a{this.tasks.onZeroOnce((()=>{this.tasks.increment(),this.viewer.makeImage(t).then((t=>{this.tasks.decrement(),e(t)})).catch((t=>{this.tasks.decrement(),i(t)}))}))}))}setImpostor(t){this.parameters.impostor=t;const e=["spacefill","ball+stick","licorice","hyperball","backbone","rocket","helixorient","contact","distance","dot"];this.eachRepresentation((function(i){if(!e.includes(i.getType()))return;const r=i.getParameters();r.disableImpostor=!t,i.build(r)}))}setQuality(t){this.parameters.quality=t;const e=["tube","cartoon","ribbon","trace","rope"],i=["spacefill","ball+stick","licorice","hyperball","backbone","rocket","helixorient","contact","distance","dot"];this.eachRepresentation((function(r){const s=r.getParameters();if(!e.includes(r.getType())){if(!i.includes(r.getType()))return;if(!s.disableImpostor)return void(r.repr.quality=t)}s.quality=t,r.build(s)}))}eachComponent(t,e){this.compList.slice().forEach((i=>{void 0!==e&&e!==i.type||t(i)}))}eachRepresentation(t,e){this.eachComponent((i=>{i.reprList.slice().forEach((r=>{void 0!==e&&e!==r.getType()||t(r,i)}))}))}getComponentsByName(t){const e=[];return this.eachComponent((i=>{(void 0===t||Ol(t,i))&&e.push(i)})),new $l(e)}getComponentsByObject(t){const e=[];return this.eachComponent((i=>{i.object===t&&e.push(i)})),new $l(e)}getRepresentationsByName(t){const e=[];return this.eachRepresentation(((i,r)=>{(void 0===t||Ol(t,i))&&e.push(i)})),new dl(e)}measureClear(){this.eachComponent((t=>t.measureClear()),"structure")}measureUpdate(){this.eachComponent((t=>t.measureUpdate()),"structure")}dispose(){this.tasks.dispose(),this.viewer.dispose(),this.mouseObserver.dispose()}}class Ll extends ll{constructor(t,e,i={}){super(t,e,Object.assign({name:e.name},i)),this.shape=e}get type(){return"shape"}addRepresentation(t,e={}){return this._addRepresentation(t,this.shape,e)}getBoxUntransformed(){return this.shape.boundingBox}getCenterUntransformed(){return this.shape.center}dispose(){this.shape.dispose(),super.dispose()}}function Nl(t,e,i,r){var s,n=arguments.length,o=n<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,r);else for(var a=t.length-1;a>=0;a--)(s=t[a])&&(o=(n<3?s(o):n>3?s(e,i,o):s(e,i))||o);return n>3&&o&&Object.defineProperty(e,i,o),o}Ue.add("shape",Ll);class zl extends zt{constructor(t){super(t),t.scale||(this.parameters.scale="rainbow",this.parameters.reverse=st(t.reverse,!0)),this.scalePerModel={},t.structure.eachModel((t=>{this.parameters.domain=[t.atomOffset,t.atomEnd],this.scalePerModel[t.index]=this.getScale()}))}atomColor(t){return this.scalePerModel[t.modelIndex](t.index)}}Nl([Nt],zl.prototype,"atomColor",null),Fe.add("atomindex",zl);class Vl extends zt{constructor(t){if(super(t),t.scale||(this.parameters.scale="OrRd"),!t.domain){let e,i=1/0,r=-1/0;t.sele&&(e=new pe(t.sele)),t.structure.eachAtom((function(t){const e=t.bfactor;i=Math.min(i,e),r=Math.max(r,e)}),e),this.parameters.domain=[i,r]}this.bfactorScale=this.getScale()}atomColor(t){return this.bfactorScale(t.bfactor)}}Nl([Nt],Vl.prototype,"atomColor",null),Fe.add("bfactor",Vl);class Gl extends zt{constructor(t){super(t),this.chainidDictPerModel={},this.scalePerModel={},t.scale||(this.parameters.scale="Spectral"),t.structure.eachModel((t=>{let e=0;const i={};t.eachChain((function(t){void 0===i[t.chainid]&&(i[t.chainid]=e,e+=1)})),this.parameters.domain=[0,e-1],this.chainidDictPerModel[t.index]=i,this.scalePerModel[t.index]=this.getScale()}))}atomColor(t){const e=this.chainidDictPerModel[t.modelIndex];return this.scalePerModel[t.modelIndex](e[t.chainid])}}Nl([Nt],Gl.prototype,"atomColor",null),Fe.add("chainid",Gl);class Ul extends zt{constructor(t){super(t),this.scalePerModel={},t.scale||(this.parameters.scale="Spectral"),t.structure.eachModel((t=>{this.parameters.domain=[t.chainOffset,t.chainEnd],this.scalePerModel[t.index]=this.getScale()}))}atomColor(t){return this.scalePerModel[t.modelIndex](t.chainIndex)}}Nl([Nt],Ul.prototype,"atomColor",null),Fe.add("chainindex",Ul);class jl extends zt{constructor(t){super(t),this.chainnameDictPerModel={},this.scalePerModel={},t.scale||(this.parameters.scale="Spectral"),t.structure.eachModel((t=>{let e=0;const i={};t.eachChain((function(t){void 0===i[t.chainname]&&(i[t.chainname]=e,e+=1)})),this.parameters.domain=[0,e-1],this.chainnameDictPerModel[t.index]=i,this.scalePerModel[t.index]=this.getScale()}))}atomColor(t){const e=this.chainnameDictPerModel[t.modelIndex];return this.scalePerModel[t.modelIndex](e[t.chainname])}}Nl([Nt],jl.prototype,"atomColor",null),Fe.add("chainname",jl);class Hl extends zt{constructor(t){super(t),this.rsrzDict={},this.rsccDict={},t.scale||(this.parameters.scale="RdYlBu"),this.rsrzScale=this.getScale({domain:[2,0]}),this.rsccScale=this.getScale({domain:[.678,1]});const e=t.structure.validation;e&&(this.rsrzDict=e.rsrzDict,this.rsccDict=e.rsccDict)}atomColor(t){let e=t.resno+"";t.inscode&&(e+="^"+t.inscode),t.chainname&&(e+=":"+t.chainname),e+="/"+t.modelIndex;const i=this.rsrzDict[e];if(void 0!==i)return this.rsrzScale(i);const r=this.rsccDict[e];return void 0!==r?this.rsccScale(r):9474192}}Nl([Nt],Hl.prototype,"atomColor",null),Fe.add("densityfit",Hl);const Wl={ARG:{CD:.1,CZ:.5,NE:-.1},ASN:{CG:.55,OD1:-.55},ASP:{CB:-.16,CG:.36,OD1:-.6,OD2:-.6},CYS:{CB:.19,SG:-.19},GLN:{CD:.55,OE1:-.55},GLU:{CD:.36,CG:-.16,OE1:-.6,OE2:-.6},HIS:{CB:.1,CD2:.2,CE1:.45,CG:.15,ND1:.05,NE2:.05},LYS:{CE:.25,NZ:.75},MET:{CE:.06,CG:.06,SD:-.12},PTR:{C:.55,CA:.1,CZ:.25,N:-.35,O:-.55,O1P:-.85,O2P:-.85,O3P:-.85,OG1:-1.1,P:1.4},SEP:{C:.55,CA:.1,CB:.25,N:-.35,O:-.55,O1P:-.85,O2P:-.85,O3P:-.85,OG1:-1.1,P:1.4},SER:{CB:.25,OG:-.25},THR:{CB:.25,OG1:-.25},TPO:{C:.55,CA:.1,CB:.25,N:-.35,O:-.55,OG1:-1.1,O1P:-.85,O2P:-.85,O3P:-.85,P:1.4},TRP:{CD1:.06,CD2:.1,CE2:-.04,CE3:-.03,CG:-.03,NE1:-.06},TYR:{CZ:.25,OH:-.25},backbone:{C:.55,O:-.55,N:-.35,CA:.1}};class ql extends zt{constructor(t){super(t),this.delta=new e,this.hCharges=[],t.scale||(this.parameters.scale="rwb"),t.domain||(this.parameters.domain=[-50,50]),this.scale=this.getScale(),this.charges=new Float32Array(t.structure.atomCount);const i=[];t.structure.eachAtom((t=>{var r;if(this.charges[t.index]=(null!==(r=t).partialCharge?r.partialCharge:r.isProtein()&&(Wl[r.resname]&&Wl[r.resname][r.atomname]||Wl.backbone[r.atomname])||0)*t.occupancy,"N"===t.atomname){if(t.bondCount>=3)return;if(t.bondToElementCount(1))return;const r=function(t,i=new e){let r=!1,s=!1,n=!1;return i.set(2*t.x,2*t.y,2*t.z),t.eachBondedAtom((function(t){if(!r)return"H"===t.atomname?(i.set(t.x,t.y,t.z),void(r=!0)):void(s||"CA"!==t.atomname?n||"C"!==t.atomname||(n=!0,i.sub(t)):(i.sub(t),s=!0))})),r?i:s&&n?(i.normalize(),i.multiplyScalar(1.04),i.add(t),i):void 0}(t);void 0!==r&&(i.push(r),this.hCharges.push(.25*t.occupancy))}}));const r=t.structure.getBoundingBox();r.expandByScalar(1.04),this.hStore=function(t){const e=t.length,i=new Float32Array(e),r=new Float32Array(e),s=new Float32Array(e);for(let e=0;e{const s=e[t];0!==s&&(r+=s/i)})),this.hHash.eachWithin(t.x,t.y,t.z,12,((t,e)=>{const s=i[t];0!==s&&(r+=s/e)})),this.scale(332*r)}}Nl([Nt],ql.prototype,"positionColor",null),Fe.add("electrostatic",ql);const Xl={H:16777215,HE:14286847,LI:13402367,BE:12779264,B:16758197,C:9474192,N:3166456,O:16715021,F:9494608,NE:11789301,NA:11230450,MG:9109248,AL:12560038,SI:1578e4,P:16744448,S:16777008,CL:2093087,AR:8442339,K:9388244,CA:4062976,SC:15132390,TI:12567239,V:10921643,CR:9083335,MN:10255047,FE:14706227,CO:15765664,NI:5296208,CU:13140019,ZN:8224944,GA:12750735,GE:6721423,AS:12419299,SE:16752896,BR:10889513,KR:6076625,RB:7351984,SR:65280,Y:9764863,ZR:9756896,NB:7586505,MO:5551541,TC:3907230,RU:2396047,RH:687500,PD:27013,AG:12632256,CD:16767375,IN:10909043,SN:6717568,SB:10380213,TE:13924864,I:9699476,XE:9699476,CS:5707663,BA:51456,LA:7394559,CE:16777159,PR:14286791,ND:13107143,PM:10747847,SM:9437127,EU:6422471,GD:4587463,TB:3211207,DY:2097095,HO:65436,ER:58997,TM:54354,YB:48952,LU:43812,HF:5096191,TA:5089023,W:2200790,RE:2522539,OS:2516630,IR:1528967,PT:13684960,AU:16765219,HG:12105936,TL:10900557,PB:5724513,BI:10375093,PO:11230208,AT:7688005,RN:4358806,FR:4325478,RA:32e3,AC:7384058,TH:47871,PA:41471,U:36863,NP:33023,PU:27647,AM:5528818,CM:7888099,BK:9064419,CF:10565332,ES:11739092,FM:11739066,MD:11734438,NO:12389767,LR:13041766,RF:13369433,DB:13697103,SG:14221381,BH:14680120,HS:15073326,MT:15400998,DS:16777215,RG:16777215,CN:16777215,UUT:16777215,FL:16777215,UUP:16777215,LV:16777215,UUH:16777215,D:16777152,T:16777120};class Yl extends zt{constructor(t){t.value=st(t.value,Xl.C),super(t)}atomColor(t){const e=t.element;return"C"===e?this.parameters.value:Xl[e]||16777215}}Nl([Nt],Yl.prototype,"atomColor",null),Fe.add("element",Yl);class Kl extends zt{constructor(t){super(t),t.scale||(this.parameters.scale="Spectral"),t.domain||(this.parameters.domain=[0,t.structure.entityList.length-1]),this.entityindexScale=this.getScale()}atomColor(t){return this.entityindexScale(t.entityIndex)}}Nl([Nt],Kl.prototype,"atomColor",null),Fe.add("entityindex",Kl);class Zl extends zt{atomColor(t){const e=t.entity;switch(e?e.entityType:void 0){case 1:return 8374655;case 2:return 16629894;case 3:return 12496596;case 4:return 3697840;default:return 16777113}}}Nl([Nt],Zl.prototype,"atomColor",null),Fe.add("entitytype",Zl);class Ql extends zt{constructor(t){super(t),this.geoAtomDict={},this.geoDict={};const e=t.structure.validation;e&&(this.geoAtomDict=e.geoAtomDict,this.geoDict=e.geoDict)}atomColor(t){let e,i=t.resno+"";t.inscode&&(i+="^"+t.inscode),t.chainname&&(i+=":"+t.chainname),i+="/"+t.modelIndex;const r=this.geoAtomDict[i];if(void 0!==r){const i=r[t.atomname]||0;s=i,e=16843009*((s=(858993459&(s-=s>>1&1431655765))+(s>>2&858993459))+(s>>4)&252645135)>>24}else e=this.geoDict[i]||0;var s;return 0===e?2188972:1===e?16703627:2===e?16018755:e>=3?10813478:9474192}}Nl([Nt],Ql.prototype,"atomColor",null),Fe.add("geoquality",Ql);class Jl extends zt{constructor(t){super(t),this.resHF={},t.scale||(this.parameters.scale="RdYlGn");for(const t in Js)this.resHF[t]=Js[t][0];if(this.defaultResidueHydrophobicity=tn[0],!t.domain){let t=1/0,e=-1/0;for(const i in this.resHF){const r=this.resHF[i];t=Math.min(t,r),e=Math.max(e,r)}this.parameters.domain=[t,0,e]}this.hfScale=this.getScale()}atomColor(t){return this.hfScale(this.resHF[t.resname]||this.defaultResidueHydrophobicity)}}Nl([Nt],Jl.prototype,"atomColor",null),Fe.add("hydrophobicity",Jl);class th extends zt{constructor(t){super(t),t.scale||(this.parameters.scale="rainbow"),t.domain||(this.parameters.domain=[0,t.structure.modelStore.count]),this.modelindexScale=this.getScale()}atomColor(t){return this.modelindexScale(t.modelIndex)}}Nl([Nt],th.prototype,"atomColor",null),Fe.add("modelindex",th);class eh extends zt{atomColor(t){switch(t.residueType.moleculeType){case 1:return 3697840;case 2:return 15729279;case 3:return 12496596;case 4:return 16629894;case 5:return 12540695;case 6:return 8374655;default:return 16777113}}}Nl([Nt],eh.prototype,"atomColor",null),Fe.add("moleculetype",eh);class ih extends zt{constructor(t){super(t),t.scale||(this.parameters.scale="PuBu"),t.domain||(this.parameters.domain=[0,1]),this.occupancyScale=this.getScale()}atomColor(t){return this.occupancyScale(t.occupancy)}}Nl([Nt],ih.prototype,"atomColor",null),Fe.add("occupancy",ih);class rh extends zt{constructor(t){super(t),t.scale||(this.parameters.scale="rwb"),t.domain||(this.parameters.domain=[-1,1]),this.partialchargeScale=this.getScale()}atomColor(t){return this.partialchargeScale(t.partialCharge||0)}}function sh(){return 16777215*Math.random()}Nl([Nt],rh.prototype,"atomColor",null),Fe.add("partialcharge",rh);class nh extends zt{atomColor(){return sh()}volumeColor(){return sh()}positionColor(){return sh()}}Nl([Nt],nh.prototype,"atomColor",null),Nl([Nt],nh.prototype,"volumeColor",null),Nl([Nt],nh.prototype,"positionColor",null),Fe.add("random",nh);class oh extends zt{constructor(t){super(t),this.rciDict={},t.scale||(this.parameters.scale="RdYlBu"),this.rciScale=this.getScale({domain:[.6,0]});const e=t.structure.validation;e&&(this.rciDict=e.rciDict)}atomColor(t){let e=`[${t.resname}]${t.resno}`;t.chainname&&(e+=":"+t.chainname);const i=this.rciDict[e];return void 0!==i?this.rciScale(i):9474192}}Nl([Nt],oh.prototype,"atomColor",null),Fe.add("randomcoilindex",oh);class ah extends zt{constructor(t){super(t),this.scalePerChain={},t.scale||(this.parameters.scale="rainbow",this.parameters.reverse=st(t.reverse,!0)),t.structure.eachChain((t=>{this.parameters.domain=[t.residueOffset,t.residueEnd],this.scalePerChain[t.index]=this.getScale()}))}atomColor(t){return this.scalePerChain[t.chainIndex](t.residueIndex)}}Nl([Nt],ah.prototype,"atomColor",null),Fe.add("residueindex",ah);const ch={ALA:9240460,ARG:124,ASN:16743536,ASP:10485826,CYS:16777072,GLN:16731212,GLU:6684672,GLY:16777215,HIS:7368959,ILE:19456,LEU:4546117,LYS:4671416,MET:12099650,PHE:5459026,PRO:5395026,SER:16740418,THR:12078080,TRP:5195264,TYR:9203788,VAL:16747775,ASX:16711935,GLX:16711935,ASH:16711935,GLH:16711935,A:14423100,G:3329330,I:10145074,X:8190976,C:16766720,T:4286945,U:4251856,D:35723,DA:14423100,DG:3329330,DI:10145074,DX:8190976,DC:16766720,DT:4286945,DU:4251856,DD:35723};class lh extends zt{atomColor(t){return ch[t.resname]||16711935}}Nl([Nt],lh.prototype,"atomColor",null),Fe.add("resname",lh);const hh=16711808,dh=10485888,uh=6291584,mh=16762880,ph=6324479,fh=16777215,gh=11403518,yh=16580962,bh=10921722;class xh extends zt{constructor(t){super(t),this.residueProxy=t.structure.getResidueProxy()}atomColor(t){const e=t.sstruc,i=this.residueProxy;return"h"===e?hh:"g"===e?dh:"i"===e?uh:"e"===e||"b"===e?mh:"t"===e?ph:(i.index=t.residueIndex,i.isDna()?gh:i.isRna()?yh:i.isSaccharide()?bh:i.isProtein()||"s"===e||"l"===e?fh:8421504)}}Nl([Nt],xh.prototype,"atomColor",null),Fe.add("sstruc",xh);class vh extends zt{constructor(t){var e,i;super(t),t.scale||(this.parameters.scale="rwb"),this.atomData=null===(e=this.parameters.data)||void 0===e?void 0:e.atomData,this.bondData=null===(i=this.parameters.data)||void 0===i?void 0:i.bondData,this.scale=this.getScale(this.parameters)}atomColor(t){var e;const i=null===(e=this.atomData)||void 0===e?void 0:e[t.index];return void 0!==i?this.scale(i):this.parameters.value}bondColor(t,e){var i;const r=null===(i=this.bondData)||void 0===i?void 0:i[t.index];return void 0!==r?this.scale(r):this.atomProxy?(this.atomProxy.index=e?t.atomIndex1:t.atomIndex2,this.atomColor(this.atomProxy)):this.parameters.value}}Nl([Nt],vh.prototype,"atomColor",null),Nl([Nt],vh.prototype,"bondColor",null),Fe.add("structuredata",vh);class wh extends zt{atomColor(){return this.parameters.value}bondColor(){return this.parameters.value}valueColor(){return this.parameters.value}volumeColor(){return this.parameters.value}}Nl([Nt],wh.prototype,"atomColor",null),Nl([Nt],wh.prototype,"bondColor",null),Nl([Nt],wh.prototype,"valueColor",null),Nl([Nt],wh.prototype,"volumeColor",null),Fe.add("uniform",wh);class Ah extends zt{constructor(t){super(t),this.valueScale=this.getScale()}volumeColor(t){return this.valueScale(this.parameters.volume.data[t])}}Nl([Nt],Ah.prototype,"volumeColor",null),Fe.add("value",Ah);class _h extends zt{constructor(t){super(t),this.vec=new e,this.valueScale=this.getScale()}positionColor(t){const e=this.parameters.volume;if(!e||!e.inverseMatrix)return this.parameters.value;const i=this.vec,r=e.data,s=e.nx,n=e.ny,o=s*n;i.copy(t),i.applyMatrix4(e.inverseMatrix);const a=Math.floor(i.x),c=Math.floor(i.y),l=Math.floor(i.z),h=(l*n+c)*s+a,d=h+1,u=h+s,m=h+o,p=u+1,f=m+1,g=u+o,y=g+1,b=r[h],x=r[d],v=r[u],w=r[m],A=r[p],_=r[f],S=r[g],C=r[y],P=i.x-a,I=i.y-c,k=i.z-l,M=$t(b,x,P),T=$t(w,_,P),B=$t(v,A,P),D=$t(S,C,P),$=$t(M,B,I),O=$t(T,D,I),R=$t($,O,k);return this.valueScale(R)}}Nl([Nt],_h.prototype,"positionColor",null),Fe.add("volume",_h);class Sh extends zr{constructor(t,e,i){const r=i||{};if(super(t,e,r),this.type="structure",this.parameters=Object.assign({radiusType:{type:"select",options:pa.types},radiusData:{type:"hidden"},radiusSize:{type:"number",precision:3,max:10,min:.001},radiusScale:{type:"number",precision:3,max:10,min:.001},assembly:null,defaultAssembly:{type:"hidden"}},this.parameters),this.selection=new pe(r.sele),this.dataList=[],this.structure=t,this.structureView=this.structure.getView(this.selection),t.biomolDict){const e={default:"default","":t.unitcell?"AU":"FULL"};Object.keys(t.biomolDict).forEach((function(t){e[t]=t})),this.parameters.assembly={type:"select",options:e,rebuild:!0}}else this.parameters.assembly=null}get defaultScale(){return{vdw:1,covalent:1,bfactor:.01,sstruc:1}}init(t){const e=t||{};e.colorScheme=st(e.colorScheme,"element"),this.setRadius(e.radius,e),this.radiusType=st(e.radiusType,"vdw"),this.radiusData=st(e.radiusData,{}),this.radiusSize=st(e.radiusSize,1),this.radiusScale=st(e.radiusScale,1),this.assembly=st(e.assembly,"default"),this.defaultAssembly=st(e.defaultAssembly,""),"auto"===e.quality&&(e.quality=this.getQuality()),super.init(e),this.selection.signals.stringChanged.add((()=>{this.build()})),this.build()}setRadius(t,e){const i=Object.keys(ma);return"string"==typeof t&&i.includes(t.toLowerCase())?e.radiusType=t:void 0!==t&&(e.radiusType="size",e.radiusSize=t),this}getAssembly(){const t="default"===this.assembly?this.defaultAssembly:this.assembly;return this.structure.biomolDict[t]}getQuality(){let t;const e=this.structureView,i=this.getAssembly();t=i?i.getAtomCount(e):e.atomCount,Se&&(t*=4);return e.atomStore.count/e.residueStore.count<2&&(t*=10),t<15e3?"high":t<8e4?"medium":"low"}create(){if(0===this.structureView.atomCount)return;if(!this.structureView.hasCoords())return void(this.needsBuild=!0);this.needsBuild=!1;const t=this.getAssembly();if(t)t.partList.forEach(((t,e)=>{const i=t.getView(this.structureView);if(0===i.atomCount)return;const r=this.createData(i,e);r&&(r.sview=i,r.instanceList=t.getInstanceList(),this.dataList.push(r))}));else{const t=this.createData(this.structureView,0);t&&(t.sview=this.structureView,this.dataList.push(t))}}update(t){!this.lazy||this.visible?this.needsBuild?this.build():this.dataList.forEach((e=>{e.bufferList.length>0&&this.updateData(t,e)}),this):Object.assign(this.lazyProps.what,t)}updateData(t,e){this.build()}getColorParams(){return Object.assign(Object.assign({},super.getColorParams()),{structure:this.structure})}getRadiusParams(t){return{type:this.radiusType,scale:this.radiusScale,size:this.radiusSize,data:this.radiusData}}getAtomParams(t,e){return Object.assign({what:t,colorParams:this.getColorParams(),radiusParams:this.getRadiusParams()},e)}getBondParams(t,e){return Object.assign({what:t,colorParams:this.getColorParams(),radiusParams:this.getRadiusParams()},e)}getAtomRadius(t){if(this.structureView.atomSet.isSet(t.index)){return new pa(this.getRadiusParams()).atomRadius(t)}return 0}setSelection(t,e){return this.selection.setString(t,e),this}setParameters(t,e={},i=!1){const r=t||{};return this.setRadius(r.radius,r),void 0===r.radiusType&&void 0===r.radiusData&&void 0===r.radiusSize&&void 0===r.radiusScale||(e.radius=!0,Ie&&!this.disableImpostor||(i=!0)),void 0!==r.defaultAssembly&&r.defaultAssembly!==this.defaultAssembly&&("default"===this.assembly&&void 0===r.assembly||"default"===r.assembly)&&(i=!0),super.setParameters(r,e,i),this}getParameters(){return Object.assign(super.getParameters(),{sele:this.selection?this.selection.string:void 0,defaultAssembly:this.defaultAssembly})}attach(t){const e=this.viewer,i=this.bufferList;this.dataList.forEach((function(t){t.bufferList.forEach((function(r){i.push(r),e.add(r,t.instanceList)}))})),this.setVisibility(this.visible),t()}clear(){this.dataList.length=0,super.clear()}dispose(){this.structureView.dispose(),super.dispose()}}class Ch extends Sh{constructor(t,e,i){super(t,e,i),this.n=0,this.parameters=Object.assign({labelVisible:{type:"boolean"},labelSize:{type:"number",precision:3,max:10,min:.001},labelColor:{type:"color"},labelFontFamily:{type:"select",options:{"sans-serif":"sans-serif",monospace:"monospace",serif:"serif"},buffer:"fontFamily"},labelFontStyle:{type:"select",options:{normal:"normal",italic:"italic"},buffer:"fontStyle"},labelFontWeight:{type:"select",options:{normal:"normal",bold:"bold"},buffer:"fontWeight"},labelsdf:{type:"boolean",buffer:"sdf"},labelXOffset:{type:"number",precision:1,max:20,min:-20,buffer:"xOffset"},labelYOffset:{type:"number",precision:1,max:20,min:-20,buffer:"yOffset"},labelZOffset:{type:"number",precision:1,max:20,min:-20,buffer:"zOffset"},labelAttachment:{type:"select",options:{"bottom-left":"bottom-left","bottom-center":"bottom-center","bottom-right":"bottom-right","middle-left":"middle-left","middle-center":"middle-center","middle-right":"middle-right","top-left":"top-left","top-center":"top-center","top-right":"top-right"},rebuild:!0},labelBorder:{type:"boolean",buffer:"showBorder"},labelBorderColor:{type:"color",buffer:"borderColor"},labelBorderWidth:{type:"number",precision:2,max:.3,min:0,buffer:"borderWidth"},labelBackground:{type:"boolean",rebuild:!0},labelBackgroundColor:{type:"color",buffer:"backgroundColor"},labelBackgroundMargin:{type:"number",precision:2,max:2,min:0,rebuild:!0},labelBackgroundOpacity:{type:"range",step:.01,max:1,min:0,buffer:"backgroundOpacity"},labelFixedSize:{type:"boolean",buffer:"fixedSize"},lineOpacity:{type:"range",min:0,max:1,step:.01},linewidth:{type:"integer",max:50,min:1,buffer:!0}},this.parameters,{flatShaded:null})}init(t){const e=t||{};this.labelVisible=st(e.labelVisible,!0),this.labelSize=st(e.labelSize,2),this.labelColor=st(e.labelColor,16777215),this.labelFontFamily=st(e.labelFontFamily,"sans-serif"),this.labelFontStyle=st(e.labelFontstyle,"normal"),this.labelFontWeight=st(e.labelFontWeight,"bold"),this.labelsdf=st(e.labelsdf,"Chrome"===Ae),this.labelXOffset=st(e.labelXOffset,0),this.labelYOffset=st(e.labelYOffset,0),this.labelZOffset=st(e.labelZOffset,.5),this.labelAttachment=st(e.labelAttachment,"bottom-left"),this.labelBorder=st(e.labelBorder,!1),this.labelBorderColor=st(e.labelBorderColor,"lightgrey"),this.labelBorderWidth=st(e.labelBorderWidth,.15),this.labelBackground=st(e.labelBackground,!1),this.labelBackgroundColor=st(e.labelBackgroundColor,"lightgrey"),this.labelBackgroundMargin=st(e.labelBackgroundMargin,.5),this.labelBackgroundOpacity=st(e.labelBackgroundOpacity,1),this.labelFixedSize=st(e.labelFixedSize,!1),this.lineOpacity=st(e.lineOpacity,1),this.linewidth=st(e.linewidth,2),super.init(e)}update(t){t.position?this.build():super.update(t)}updateData(t,e){const i={};if(t&&!t.labelSize||Object.assign(i,{size:Si(this.n,this.labelSize)}),!t||t.labelColor){const t=new s(this.labelColor);Object.assign(i,{color:Ci(this.n,t.r,t.g,t.b)})}this.textBuffer.setAttributes(i)}setParameters(t,e={},i=!1){return t&&t.labelSize&&(e.labelSize=!0),t&&(t.labelColor||0===t.labelColor)&&(e.labelColor=!0,i=!0),super.setParameters(t,e,i),t&&void 0!==t.opacity&&this.textBuffer.setParameters({opacity:1}),t&&void 0!==t.labelVisible&&this.setVisibility(this.visible),this}setVisibility(t,e){return super.setVisibility(t,!0),this.textBuffer&&this.textBuffer.setVisibility(this.labelVisible&&this.visible),e||this.viewer.requestRender(),this}getLabelBufferParams(t={}){return super.getBufferParams(Object.assign({fontFamily:this.labelFontFamily,fontStyle:this.labelFontStyle,fontWeight:this.labelFontWeight,sdf:this.labelsdf,xOffset:this.labelXOffset,yOffset:this.labelYOffset,zOffset:this.labelZOffset,attachment:this.labelAttachment,showBorder:this.labelBorder,borderColor:this.labelBorderColor,borderWidth:this.labelBorderWidth,showBackground:this.labelBackground,backgroundColor:this.labelBackgroundColor,backgroundMargin:this.labelBackgroundMargin,backgroundOpacity:this.labelBackgroundOpacity,fixedSize:this.labelFixedSize,disablePicking:!0,visible:this.labelVisible},t,{opacity:1}))}getAtomRadius(){return 0}}function Ph(t,e){const i=t.getAtomProxy(),r=new pe,s=e.length;if(0===s)return new Float32Array(0);const n=e[0].length,o=t.getAtomSet(),a=new Float32Array(s*n*3);let c=0;return e.forEach((function(e){let s=!1;for(let l=0;l 1.0 ){\ngl_FragColor = vec4( backgroundColor, backgroundOpacity );\n}else{\nfloat sdf = texture2D( fontTexture, texCoord ).a;\nif( showBorder ) sdf += borderWidth;\nfloat a = smoothstep(padding - gamma, padding + gamma, sdf);\nif( a < 0.2 ) discard;\na *= opacity;\nvec3 outgoingLight = vColor;\nif( showBorder && sdf < ( padding + borderWidth ) ){\noutgoingLight = borderColor;\n}\ngl_FragColor = vec4( outgoingLight, a );\n}\n#if defined( PICKING )\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");const Th={};const Bh={font:"sans-serif",size:36,style:"normal",variant:"normal",weight:"normal",outline:3,width:1024,height:1024};class Dh{constructor(t={}){this.gamma=1,this.mapped={},this.scratchW=0,this.scratchH=0,this.currentX=0,this.currentY=0,this.cutoff=.25,this.parameters=nt(t,Bh);const e=this.parameters;this.radius=e.size/8,this.padding=e.size/3;const i=this.lineHeight=e.size+2*e.outline+Math.round(e.size/4),r=this.maxWidth=e.width/4,s=this.canvas=document.createElement("canvas");s.width=r,s.height=i;const n=this.context=this.canvas.getContext("2d");n.font=`${e.style} ${e.variant} ${e.weight} ${e.size}px ${e.font}`,n.fillStyle="black",n.textAlign="left",n.textBaseline="bottom",n.lineJoin="round",this.gridOuter=new Float64Array(i*r),this.gridInner=new Float64Array(i*r),this.f=new Float64Array(Math.max(i,r)),this.d=new Float64Array(Math.max(i,r)),this.z=new Float64Array(Math.max(i,r)+1),this.v=new Int16Array(Math.max(i,r)),this.data=new Uint8Array(e.width*e.height*4),this.canvas2=document.createElement("canvas"),this.canvas2.width=e.width,this.canvas2.height=e.height,this.context2=this.canvas2.getContext("2d"),this.placeholder=this.map(String.fromCharCode(65533));for(let t=32;t<=126;++t)this.map(String.fromCharCode(t));this.map(String.fromCharCode(176)),this.map(String.fromCharCode(8491)),this.texture=new H(this.canvas2),this.texture.flipY=!1,this.texture.needsUpdate=!0}map(t){const e=this.parameters;return void 0===this.mapped[t]&&(this.draw(t),this.currentX+this.scratchW>e.width&&(this.currentX=0,this.currentY+=this.scratchH),this.currentY+this.scratchH>e.height&&console.warn("canvas to small"),this.mapped[t]={x:this.currentX,y:this.currentY,w:this.scratchW,h:this.scratchH},this.context2.drawImage(this.canvas,0,0,this.scratchW,this.scratchH,this.currentX,this.currentY,this.scratchW,this.scratchH),this.currentX+=this.scratchW),this.mapped[t]}get(t){return this.mapped[t]||this.placeholder}draw(t){const e=this.parameters,i=this.lineHeight,r=e.outline,s=this.context,n=this.maxWidth,o=r,a=i-e.outline,c=s.measureText(t),l=Math.min(n,Math.ceil(c.width+2*o+1)),h=l*i;s.clearRect(0,0,l,i),s.fillText(t,o,a);const d=s.getImageData(0,0,l,i),u=d.data;for(let t=0;t= 0.0 ) {\ntrimSegment( start, end );\n} else if ( end.z < 0.0 && start.z >= 0.0 ) {\ntrimSegment( end, start );\n}\n}\nvec4 clipStart = projectionMatrix * start;\nvec4 clipEnd = projectionMatrix * end;\nvec2 ndcStart = clipStart.xy / clipStart.w;\nvec2 ndcEnd = clipEnd.xy / clipEnd.w;\nvec2 dir = ndcEnd - ndcStart;\ndir.x *= aspect;\ndir = normalize( dir );\nvec2 offset = vec2( dir.y, - dir.x );\ndir.x /= aspect;\noffset.x /= aspect;\nif ( mapping.x < 0.0 ) offset *= - 1.0;\noffset *= linewidth;\noffset /= resolution.y;\nvec4 clip = ( mapping.y < 0.5 ) ? clipStart : clipEnd;\noffset *= clip.w;\nclip.xy += offset;\ngl_Position = clip;\n#ifndef PICKING\nvViewPosition = ( projectionMatrixInverse * clip ).xyz;\n#endif\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n#include nearclip_vertex\n}"),Ve.add("shader/WideLine.frag","uniform vec3 diffuse;\nuniform float opacity;\nuniform float clipNear;\nuniform float clipRadius;\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#ifdef PICKING\nuniform float objectId;\nvarying vec3 vPickingColor;\n#else\n#include common\n#include fog_pars_fragment\nvarying vec3 vViewPosition;\nvarying vec3 vColor;\nvarying vec3 vColor2;\nvarying float flag;\n#endif\nvoid main() {\n#include nearclip_fragment\n#include radiusclip_fragment\n#if defined( PICKING )\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 outgoingLight = vec3( 0.0 );\nvec4 diffuseColor = vec4( diffuse, 1.0 );\nif ( flag < 0.0 ) {\ndiffuseColor.rgb *= vColor;\n} else {\ndiffuseColor.rgb *= vColor2;\n}\n#include alphatest_fragment\noutgoingLight = diffuseColor.rgb;\ngl_FragColor = vec4( outgoingLight, diffuseColor.a * opacity );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");const Fh=Object.assign({linewidth:2},zo),Lh=Object.assign({linewidth:{uniform:!0}},Vo);class Nh extends zc{constructor(e,r={}){super(e,r),this.parameterTypes=Lh,this.vertexShader="WideLine.vert",this.fragmentShader="WideLine.frag",!e.color2&&e.color&&(e.color2=e.color),this.addUniforms({linewidth:{value:this.parameters.linewidth},resolution:{value:new t},projectionMatrixInverse:{value:new i}}),this.addAttributes({position1:{type:"v3",value:null},position2:{type:"v3",value:null},color2:{type:"c",value:null}}),this.setAttributes(e),this.makeMapping()}get defaultParameters(){return Fh}setParameters(t){super.setParameters(t)}}je.add("wideline",Nh);class zh extends Ch{constructor(t,e,i){super(t,e,i),this.type="angle",this.parameters=Object.assign({atomTriple:{type:"hidden",rebuild:!0},vectorVisible:{type:"boolean",default:!0},arcVisible:{type:"boolean",default:!0},sectorVisible:{type:"boolean",default:!0}},this.parameters),this.init(i)}init(t){const e=t||{};e.side=st(e.side,"double"),e.opacity=st(e.opacity,.5),this.atomTriple=st(e.atomTriple,[]),this.arcVisible=st(e.arcVisible,!0),this.sectorVisible=st(e.sectorVisible,!0),this.vectorVisible=st(e.vectorVisible,!0),super.init(e)}createData(t){if(!t.atomCount||!this.atomTriple.length)return;const e=function(t,e){return function(t){const e=[],i=t.length/9;for(let r=0;r radius2) {\ndiscard;\n}\n#ifdef CAP\nsurface_point = front_point;\n_normal = axis;\n#else\nsurface_point = ray_target + ( (-a1 - sqrt(d)) / a2 ) * ray_direction;\ndNV = dot(-axis, ray_direction);\nnear = dot(axis, end) / dNV;\nnew_point2 = ray_direction * near + ray_origin;\nif (dot(new_point2 - end, new_point2-base) < radius2) {\ndiscard;\n}\ninterior = true;\n#endif\n}\nif( end_cap_test > 0.0 )\n{\nfloat dNV;\nfloat near;\nvec3 end_point;\nif ( ortho == 1.0 ) {\nend_point = ray_target;\n} else {\ndNV = dot(axis, ray_direction);\nif (dNV < 0.0) {\ndiscard;\n}\nnear = dot(axis, end) / dNV;\nend_point = ray_direction * near + ray_origin;\n}\n\nif( dot(end_point - end, end_point-base) > radius2 ) {\ndiscard;\n}\n#ifdef CAP\nsurface_point = end_point;\n_normal = axis;\n#else\nsurface_point = ray_target + ( (-a1 - sqrt(d)) / a2 ) * ray_direction;\ndNV = dot(-axis, ray_direction);\nnear = dot(-axis, (base)) / dNV;\nnew_point2 = ray_direction * near + ray_origin;\nif (dot(new_point2 - base, new_point2-base) < radius2) {\ndiscard;\n}\ninterior = true;\n#endif\n}\ngl_FragDepthEXT = calcDepth( surface_point );\n\n#ifdef NEAR_CLIP\nif( calcClip( surface_point ) > 0.0 ){\ndist = (-a1 - sqrt(d)) / a2;\nsurface_point = ray_target + dist * ray_direction;\nif( calcClip( surface_point ) > 0.0 ) {\ndiscard;\n}\ninterior = true;\ngl_FragDepthEXT = calcDepth( surface_point );\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( clipNear - 0.5 ) ) ) + ( 0.0000001 / vRadius ) );\n}\n}else if( gl_FragDepthEXT <= 0.0 ){\ndist = (-a1 - sqrt(d)) / a2;\nsurface_point = ray_target + dist * ray_direction;\ninterior = true;\ngl_FragDepthEXT = calcDepth( surface_point );\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n}\n#else\nif( gl_FragDepthEXT <= 0.0 ){\ndist = (-a1 - sqrt(d)) / a2;\nsurface_point = ray_target + dist * ray_direction;\ninterior = true;\ngl_FragDepthEXT = calcDepth( surface_point );\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n}\n#endif\nif (gl_FragDepthEXT < 0.0) {\ndiscard;\n}\nif (gl_FragDepthEXT > 1.0) {\ndiscard;\n}\n#ifdef PICKING\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 vViewPosition = -surface_point;\nvec3 vNormal = _normal;\nvec3 vColor;\nif( distSq3( surface_point, end ) < distSq3( surface_point, base ) ){\nif( b < 0.0 ){\nvColor = vColor1;\n}else{\nvColor = vColor2;\n}\n}else{\nif( b > 0.0 ){\nvColor = vColor1;\n}else{\nvColor = vColor2;\n}\n}\nvec4 diffuseColor = vec4( diffuse, opacity );\nReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\nvec3 totalEmissiveLight = emissive;\n#include color_fragment\n#include roughnessmap_fragment\n#include metalnessmap_fragment\nvec3 normal = normalize( vNormal );\nvec3 geometryNormal = normal;\n#include lights_physical_fragment\n#include lights_fragment_begin\n#include lights_fragment_end\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\nif( interior ){\n#ifdef USE_INTERIOR_COLOR\noutgoingLight.xyz = interiorColor;\n#else\n#ifdef DIFFUSE_INTERIOR\noutgoingLight.xyz = vColor;\n#endif\n#endif\noutgoingLight.xyz *= 1.0 - interiorDarkening;\n}\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");const Xh=new Float32Array([-1,1,-1,-1,-1,-1,1,1,-1,1,1,1,1,-1,-1,1,-1,1]),Yh=new Uint16Array([0,1,2,1,4,2,2,4,3,4,5,3]);class Kh extends Fc{constructor(t,e={}){super("v3",t,e)}get mapping(){return Xh}get mappingIndices(){return Yh}get mappingIndicesSize(){return 12}get mappingSize(){return 6}get mappingItemSize(){return 3}}const Zh=Object.assign({openEnded:!1},zo),Qh=Object.assign({openEnded:{updateShader:!0}},Vo);class Jh extends Kh{constructor(t,e={}){super(t,e),this.parameterTypes=Qh,this.isImpostor=!0,this.vertexShader="CylinderImpostor.vert",this.fragmentShader="CylinderImpostor.frag",this.addUniforms({modelViewMatrixInverse:{value:new i},ortho:{value:0}}),this.addAttributes({position1:{type:"v3",value:null},position2:{type:"v3",value:null},color2:{type:"c",value:null},radius:{type:"f",value:null}}),this.setAttributes(t),this.makeMapping()}get defaultParameters(){return Zh}getDefines(t){const e=Kh.prototype.getDefines.call(this,t);return this.parameters.openEnded||(e.CAP=1),e}}Object.assign({disableImpostor:!1},Hh,Zh);const td=class{constructor(t,e={}){return!t.color2&&t.color&&(t.color2=t.color),!Ie||e&&e.disableImpostor?new qh(t,e):new Jh(t,e)}};je.add("cylinder",td);class ed extends Sh{constructor(t,e,i){super(t,e,i),this.type="axes",this.parameters=Object.assign({radiusSize:{type:"number",precision:3,max:10,min:.001},sphereDetail:!0,radialSegments:!0,disableImpostor:!0,showAxes:{type:"boolean",rebuild:!0},showBox:{type:"boolean",rebuild:!0}},this.parameters,{assembly:null}),this.init(i)}init(t){const e=t||{};e.radiusSize=st(e.radiusSize,.5),e.colorValue=st(e.colorValue,"lightgreen"),e.useInteriorColor=st(e.useInteriorColor,!0),this.showAxes=st(e.showAxes,!0),this.showBox=st(e.showBox,!1),super.init(e)}getPrincipalAxes(){let t;const e=this.getAssembly();return e&&(t=e.partList[0].getSelection()),this.structureView.getPrincipalAxes(t)}getAxesData(t){const i=this.getPrincipalAxes(),r=new s(this.colorValue);let n=0,o=0;this.showAxes&&(n+=6,o+=3),this.showBox&&(n+=8,o+=12);const a=new Float32Array(3*n),c=Ci(n,r.r,r.g,r.b),l=Si(n,this.radiusSize),h=new Float32Array(3*o),d=new Float32Array(3*o),u=Ci(o,r.r,r.g,r.b),m=Si(o,this.radiusSize);let p=0;if(this.showAxes){const t=function(t,e){t.toArray(a,2*p),e.toArray(a,2*p+3),t.toArray(h,p),e.toArray(d,p),p+=3};t(i.begA,i.endA),t(i.begB,i.endB),t(i.begC,i.endC)}if(this.showBox){const r=new e,{d1a:s,d2a:n,d3a:o,d1b:c,d2b:l,d3b:u}=i.getProjectedScaleForAtoms(t);let m=2*p;const f=function(t,e,s){r.copy(i.center).addScaledVector(i.normVecA,t).addScaledVector(i.normVecB,e).addScaledVector(i.normVecC,s),r.toArray(a,m),m+=3};f(s,n,o),f(s,n,u),f(s,l,u),f(s,l,o),f(c,l,u),f(c,l,o),f(c,n,o),f(c,n,u);let g=p;const y=function(t,e){r.fromArray(a,2*p+3*t).toArray(h,g),r.fromArray(a,2*p+3*e).toArray(d,g),g+=3};y(0,1),y(0,3),y(0,6),y(1,2),y(1,7),y(2,3),y(2,4),y(3,5),y(4,5),y(4,7),y(5,6),y(6,7)}const f=new Kn(i);return{vertex:{position:a,color:c,radius:l,picking:f},edge:{position1:h,position2:d,color:u,color2:u,radius:m,picking:f}}}create(){const t=this.getAxesData(this.structureView);this.sphereBuffer=new Gc(t.vertex,this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0})),this.cylinderBuffer=new td(t.edge,this.getBufferParams({openEnded:!0,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0})),this.dataList.push({sview:this.structureView,bufferList:[this.sphereBuffer,this.cylinderBuffer]})}createData(t){}updateData(t,e){const i=this.getAxesData(e.sview),r={},s={};t&&!t.position||(Object.assign(r,{position:i.vertex.position}),Object.assign(s,{position1:i.edge.position1,position2:i.edge.position2})),t&&!t.color||(Object.assign(r,{color:i.vertex.color}),Object.assign(s,{color:i.edge.color,color2:i.edge.color})),t&&!t.radius||(Object.assign(r,{radius:i.vertex.radius}),Object.assign(s,{radius:i.edge.radius})),this.sphereBuffer.setAttributes(r),this.cylinderBuffer.setAttributes(s)}}Ne.add("axes",ed);class id extends Sh{constructor(t,e,i){super(t,e,i),this.type="ball+stick",this.parameters=Object.assign({sphereDetail:!0,radialSegments:!0,openEnded:!0,disableImpostor:!0,aspectRatio:{type:"number",precision:1,max:10,min:1},lineOnly:{type:"boolean",rebuild:!0},cylinderOnly:{type:"boolean",rebuild:!0},multipleBond:{type:"select",rebuild:!0,options:{off:"off",symmetric:"symmetric",offset:"offset"}},bondScale:{type:"number",precision:2,max:1,min:.01},bondSpacing:{type:"number",precision:2,max:2,min:.5},linewidth:{type:"integer",max:50,min:1,buffer:!0}},this.parameters),this.init(i)}init(t){var e=t||{};e.radiusType=st(e.radiusType,"size"),e.radiusSize=st(e.radiusSize,.15),e.useInteriorColor=st(e.useInteriorColor,!0),this.aspectRatio=st(e.aspectRatio,2),this.lineOnly=st(e.lineOnly,!1),this.cylinderOnly=st(e.cylinderOnly,!1),this.multipleBond=st(e.multipleBond,"off"),this.bondSpacing=st(e.bondSpacing,1),this.bondScale=st(e.bondScale,.4),this.linewidth=st(e.linewidth,2),super.init(e)}getAtomRadius(t){return this.aspectRatio*super.getAtomRadius(t)}getAtomParams(t,e){var i=super.getAtomParams(t,e);return i.radiusParams.scale*=this.aspectRatio,i}getAtomData(t,e,i){return t.getAtomData(this.getAtomParams(e,i))}getBondParams(t,e){return e=Object.assign({multipleBond:this.multipleBond,bondSpacing:this.bondSpacing,bondScale:this.bondScale},e),super.getBondParams(t,e)}getBondData(t,e,i){return t.getBondData(this.getBondParams(e,i))}createData(t){const e=[];if(this.lineOnly)this.lineBuffer=new Nh(this.getBondData(t,{position:!0,color:!0,picking:!0}),this.getBufferParams({linewidth:this.linewidth})),e.push(this.lineBuffer);else{const i=new td(this.getBondData(t),this.getBufferParams({openEnded:this.openEnded,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0}));if(e.push(i),!this.cylinderOnly){const i=new Gc(this.getAtomData(t),this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0}));e.push(i)}}return{bufferList:e}}updateData(t,e){"off"!==this.multipleBond&&t&&t.radius&&(t.position=!0);const i=this.getBondData(e.sview,t);if(this.lineOnly){const r={};t&&!t.position||Object.assign(r,{position1:i.position1,position2:i.position2}),t&&!t.color||Object.assign(r,{color:i.color,color2:i.color2}),e.bufferList[0].setAttributes(r)}else{var r={};if(t&&!t.position||Object.assign(r,{position1:i.position1,position2:i.position2}),t&&!t.color||Object.assign(r,{color:i.color,color2:i.color2}),t&&!t.radius||Object.assign(r,{radius:i.radius}),e.bufferList[0].setAttributes(r),!this.cylinderOnly){var s=this.getAtomData(e.sview,t),n={};t&&!t.position||Object.assign(n,{position:s.position}),t&&!t.color||Object.assign(n,{color:s.color}),t&&!t.radius||Object.assign(n,{radius:s.radius}),e.bufferList[1].setAttributes(n)}}}setParameters(t={}){let e=!1;const i={};return(t.aspectRatio||t.bondSpacing||t.bondScale)&&(Object.assign(i,{radius:!0}),Ie&&!this.disableImpostor||(e=!0)),super.setParameters(t,i,e),this}}Ne.add("ball+stick",id);class rd extends id{constructor(t,e,i){super(t,e,i),this.type="backbone",this.parameters=Object.assign({},this.parameters,{multipleBond:null,bondSpacing:null}),this.init(i)}init(t){var e=t||{};e.aspectRatio=st(e.aspectRatio,1),e.radiusSize=st(e.radiusSize,.25),super.init(e)}getAtomRadius(t){return t.isTrace()?super.getAtomRadius(t):0}getAtomData(t,e,i){return t.getBackboneAtomData(this.getAtomParams(e,i))}getBondData(t,e,i){return t.getBackboneBondData(this.getBondParams(e,i))}}Ne.add("backbone",rd);class sd extends id{constructor(t,e,i){super(t,e,i),this.type="base",this.parameters=Object.assign({},this.parameters,{multipleBond:null,bondSpacing:null})}init(t){let e=t||{};e.aspectRatio=st(e.aspectRatio,1),e.radiusSize=st(e.radiusSize,.3),super.init(e)}getAtomData(t,e,i){return t.getRungAtomData(this.getAtomParams(e,i))}getBondData(t,e,i){let r=this.getBondParams(e,i);return Object.assign(r.colorParams,{rung:!0}),t.getRungBondData(r)}}Ne.add("base",sd);class nd{constructor(t,i){this.m=t,this.tension=i,this.dt=1/this.m,this.delta=1e-4,this.vec1=new e,this.vec2=new e,this.vDir=new e,this.vTan=new e,this.vNorm=new e,this.vBin=new e,this.m2=Math.ceil(this.m/2)}interpolateToArr(t,e,i,r,s,n,o){n[o+0]=Ot(t.x,e.x,i.x,r.x,s,this.tension),n[o+1]=Ot(t.y,e.y,i.y,r.y,s,this.tension),n[o+2]=Ot(t.z,e.z,i.z,r.z,s,this.tension)}interpolateToVec(t,e,i,r,s,n){n.x=Ot(t.x,e.x,i.x,r.x,s,this.tension),n.y=Ot(t.y,e.y,i.y,r.y,s,this.tension),n.z=Ot(t.z,e.z,i.z,r.z,s,this.tension)}interpolatePosition(t,e,i,r,s,n){for(var o=0;o1&&(l=1),this.interpolateToVec(t,e,i,r,c,this.vec1),this.interpolateToVec(t,e,i,r,l,this.vec2),this.vec2.sub(this.vec1).normalize(),this.vec2.toArray(s,h)}}vectorSubdivide(t,e,i,r,s){let n,o=e.next(),a=e.next(),c=e.next();const l=e.size,h=l-1;let d=r||0;for(let r=0;r0&&e{if(t.residueCount<4)return;i.push(t);const r=this.getSpline(t),s=this.getAspectRatio(t),n=r.getSubdividedPosition(),o=r.getSubdividedOrientation(),a=r.getSubdividedColor(this.getColorParams()),c=r.getSubdividedPicking(),l=r.getSubdividedSize(this.getRadiusParams());e.push(new hd(Object.assign({},n,o,a,c,l),this.getBufferParams({radialSegments:this.radialSegments,aspectRatio:s,capped:this.capped})))}),t.getSelection()),{bufferList:e,polymerList:i}}updateData(t,e){De&&Me.time(this.type+" repr update"),t=t||{};for(var i=0,r=e.polymerList.length;i0;Qr(A,b,_);const s=Zr(A,v)<0;if(ns(A,v,Zr(v,x)),Qr(S,x,A),ns(A,v,Zr(v,w)),Qr(C,w,A),0===rs(S)||0===rs(C))continue;os(S,S),os(C,C);const D=n[T]=us(S,C);a[T]=(vi*D).toFixed(1)+String.fromCharCode(176),Kr(k,S,v),os(k,k),Zr(k,C)<0&&ds(k,k),Ih(A,_,S,k,D/2),es(A,o,3*T);const $=Math.ceil(D/i),O=$+(e.extendLine?4:2),R=e.extendLine?36:0,E=new Float32Array(3*O),F=new Float32Array(3*O),L=new Float32Array(9*$),N=new Float32Array(R);c[T]=E,l[T]=F,h[T]=L,d[T]=N,e.extendLine&&(r?(Qr(A,f,y),os(A,A),ns(P,A,1/Zr(S,A)),Jr(P,P,y)):(ns(P,x,1/Zr(S,x)),Jr(P,P,g)),s?(Qr(A,b,g),os(A,A),ns(I,A,1/Zr(C,A)),Jr(I,I,g)):(ns(I,w,1/Zr(C,w)),Jr(I,I,y))),Jr(M,_,S);let z=0;e.extendLine?(es(f,E,z),es(P,F,z),z+=3,es(P,E,z),es(M,F,z),z+=3,es(P,N,0),es(M,N,3),es(r?y:g,N,6),es(r?y:g,N,9),es(M,N,12),es(_,N,15)):(es(_,E,z),es(M,F,z),z+=3);const V=function(t,e){const i=9*e;es(_,L,i),es(M,L,i+3),es(M,E,z),Ih(M,_,S,k,t),es(M,L,i+6),es(M,F,z),z+=3};let G=0;for(let t=i;t{const e=pd(i,t);Object.assign(t,e)})),e.side=st(e.side,"double"),e.opacity=st(e.opacity,.5),e.radiusType=st(e.radiusType,"size"),e.radiusSize=st(e.radiusSize,.15),super.init(e)}getHistogramBinBorderBufferParameters(){return this.getBufferParams({linewidth:this.histogramBinBorderWidth,visible:this.histogramBinBorderVisible,opacity:this.histogramBinBorderOpacity})}getBondArrowsBufferParameters(){return this.getBufferParams({linewidth:this.bondArrowWidth,visible:this.bondArrowVisible,opacity:this.bondArrowOpacity})}getOpaqueMiddleDiscBufferParameters(){return this.getBufferParams({visible:this.opaqueMiddleDiscVisible,opacity:this.opaqueMiddleDiscOpacity})}getHistogramBufferParameters(){return this.getBufferParams({visible:!0,opacity:this.histogramOpacity,side:"double"})}createData(t){if(!t.atomCount||!this.histogramsData.length)return;this.histogramsData.forEach((e=>e.atomPositions=Ph(t,[e.atomQuad])));const e=this.scaleBinToSectorArea?function(t){return Math.sqrt(t)}:function(t){return t};function i(t){const e=t.map((t=>t.length)),i=new Float32Array($i(e));let r=0;for(let e=0;et.startPoints))),position2:i(t.map((t=>t.endPoints))),color:i(t.map((t=>t.startColors))),color2:i(t.map((t=>t.endColors)))},e)}function s(t,e){return new Uo({position:i(t.map((t=>t.triangles))),color:i(t.map((t=>t.triangleColors)))},e)}this.histogramsData.forEach((t=>t.histogram360Scaled=t.histogram360.map(e)));const n=[];for(let t=0;t=3&&(e=yd(i)),void 0!==e&&n.push(e)}return this.frontHistogramBinBordersBuffer=r(n.map((t=>t.frontHistogramBinBorders)),this.getHistogramBinBorderBufferParameters()),this.backHistogramBinBordersBuffer=r(n.map((t=>t.backHistogramBinBorders)),this.getHistogramBinBorderBufferParameters()),this.adjacentBondArrowsBuffer=r(n.map((t=>t.adjacentBondArrows)),this.getBondArrowsBufferParameters()),this.distantBondArrowsBuffer=r(n.map((t=>t.distantBondArrows)),this.getBondArrowsBufferParameters()),this.opaqueMiddleDiscBuffer=s(n.map((t=>t.opaqueMiddleDisc)),this.getOpaqueMiddleDiscBufferParameters()),this.frontHistogramBuffer=s(n.map((t=>t.frontHistogram)),this.getHistogramBufferParameters()),this.backHistogramBuffer=s(n.map((t=>t.backHistogram)),this.getHistogramBufferParameters()),{bufferList:[].concat(this.frontHistogramBinBordersBuffer,this.backHistogramBinBordersBuffer,this.adjacentBondArrowsBuffer,this.distantBondArrowsBuffer,this.opaqueMiddleDiscBuffer,this.frontHistogramBuffer,this.backHistogramBuffer)}}setParameters(t){return super.setParameters(t,{},!1),t&&void 0!==t.histogramBinBorderVisible&&this.setVisibility(this.visible),this}setVisibility(t,e){return super.setVisibility(t,!0),this.frontHistogramBinBordersBuffer&&this.frontHistogramBinBordersBuffer.setVisibility(this.histogramBinBorderVisible),this.backHistogramBinBordersBuffer&&this.backHistogramBinBordersBuffer.setVisibility(this.histogramBinBorderVisible),e||this.viewer.requestRender(),this}}function yd(t){const e=t.atomPositions,i=t.histogram360Scaled,r=i.length<=180?360:2*i.length,s={triangles:new Float32Array(3*r*3),triangleColors:fd(t.opaqueMiddleDiscColor,3*r)},n={triangles:new Float32Array(3*i.length*3),triangleColors:fd(t.frontHistogramColor,3*i.length)},o={triangles:new Float32Array(3*i.length*3),triangleColors:fd(t.backHistogramColor,3*i.length)},a={startPoints:new Float32Array(3*i.length),endPoints:new Float32Array(3*i.length),startColors:fd(t.histogramBinBorderColor,i.length),endColors:fd(t.histogramBinBorderColor,i.length)},c={startPoints:new Float32Array(3*i.length),endPoints:new Float32Array(3*i.length),startColors:fd(t.histogramBinBorderColor,i.length),endColors:fd(t.histogramBinBorderColor,i.length)},l={startPoints:new Float32Array(6),endPoints:new Float32Array(6),startColors:fd(t.adjacentBondArrowColor,i.length),endColors:fd(t.adjacentBondArrowColor,i.length)},h={startPoints:new Float32Array(6),endPoints:new Float32Array(6),startColors:fd(t.distantBondArrowColor,i.length),endColors:fd(t.distantBondArrowColor,i.length)},d=Yr(),u=Yr(),m=Yr(),p=Yr(),f=Yr(),g=Yr(),y=Yr(),b=Yr(),x=Yr(),v=Yr(),w=Yr(),A=Yr(),_=Yr(),S=Yr(),C=Yr(),P=Yr(),I=[d,u,m,p];for(let t=0;t{let u=e[0],m=e[1];if("number"==typeof u&&Number.isInteger(u)&&"number"==typeof m&&Number.isInteger(m)){if(!d.get(u)||!d.get(m))return void(h+=1);c.index=u,l.index=m}else{n.setString(u),o.setString(m);var p=t.getAtomIndices(n),f=t.getAtomIndices(o);if(!p.length||!f.length)return void(h+=1);c.index=p[0],l.index=f[0]}a.addBond(c,l,1),i-=h;var g=c.distanceTo(l);switch(this.labelUnit){case"angstrom":r[i]=g.toFixed(2)+" "+String.fromCharCode(8491);break;case"nm":r[i]=(g/10).toFixed(2)+" nm";break;default:r[i]=g.toFixed(2)}var y=3*i;s[y+0]=(c.x+l.x)/2,s[y+1]=(c.y+l.y)/2,s[y+2]=(c.z+l.z)/2})),h>0&&(i-=h,s=s.subarray(0,3*i));var u=new Os(a.count,!0);return{text:r,position:s,bondSet:u,bondStore:a}}getBondData(t,e,i){const r=t.getBondData(this.getBondParams(e,i));return r.picking&&(r.picking=new to(r.picking.array,r.picking.structure,i.bondStore)),r}createData(t){if(!t.atomCount||!this.atomPair.length)return;const e=this.atomPair.length,i=new s(this.labelColor),r=this.getDistanceData(t,this.atomPair);this.textBuffer=new Eh({position:r.position,size:Si(e,this.labelSize),color:Ci(e,i.r,i.g,i.b),text:r.text},this.getLabelBufferParams());const n={bondSet:r.bondSet,bondStore:r.bondStore},o=this.getBondData(t,{position:!0,color:!0,picking:!0,radius:this.useCylinder},n);return this.useCylinder?this.distanceBuffer=new td(o,this.getBufferParams({openEnded:this.openEnded,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0})):this.distanceBuffer=new Nh(ps(o),this.getBufferParams({linewidth:this.linewidth,visible:this.lineVisible,opacity:this.lineOpacity})),{bondSet:r.bondSet,bondStore:r.bondStore,position:r.position,bufferList:[this.textBuffer,this.distanceBuffer]}}updateData(t,e){super.updateData(t,e);const i={bondSet:e.bondSet,bondStore:e.bondStore},r=this.getBondData(e.sview,t,i),s={};t&&!t.color||Object.assign(s,{color:r.color,color2:r.color2}),t&&!t.radius||Object.assign(s,{radius:r.radius}),this.distanceBuffer.setAttributes(s)}setParameters(t){return super.setParameters(t,{},!1),this.useCylinder||(t&&t.lineOpacity&&this.distanceBuffer.setParameters({opacity:t.lineOpacity}),t&&void 0!==t.opacity&&this.distanceBuffer.setParameters({opacity:this.lineOpacity}),t&&t.linewidth&&this.distanceBuffer.setParameters({linewidth:t.linewidth})),this}}function xd(t){return 2*(t.position.length/3)*3}Ne.add("distance",bd);const vd=Object.assign({scale:1,color:"grey"},zo);class wd extends Go{constructor(t,e={}){super({position:new Float32Array(xd(t)),color:new Float32Array(xd(t))},e),this.isLine=!0,this.vertexShader="Line.vert",this.fragmentShader="Line.frag";const i=new s(this.parameters.color),r=this.geometry.attributes;Ci(xd(t)/3,i.r,i.g,i.b,r.color.array),this.setAttributes(t)}get defaultParameters(){return vd}setAttributes(t={}){const e=this.geometry.attributes;let i,r,s;t.position&&t.vector&&(i=t.position,r=t.vector,s=e.position.array,e.position.needsUpdate=!0);const n=this.size/2,o=this.parameters.scale;if(i&&r)for(let t=0;t{if(t.residueCount<4)return;i.push(t);const r=new Ca(t),s=r.getPosition(),n=r.getColor(this.getColorParams()),o=r.getSize(this.getRadiusParams()),a=r.getPicking();e.push(new Gc({position:s.center,color:n.color,radius:o.size,picking:a.picking},this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0})),new wd({position:s.center,vector:s.axis},this.getBufferParams({color:"skyblue",scale:1})),new wd({position:s.center,vector:s.resdir},this.getBufferParams({color:"lightgreen",scale:1})))}),t.getSelection()),{bufferList:e,polymerList:i}}updateData(t,e){De&&Me.time(this.type+" repr update"),t=t||{};for(let i=0,r=e.polymerList.length;i radius2) {\nspaceposition.y = mapping.y * 1.5 * radius1;\nspaceposition.x = mapping.x * 1.5 * radius1;\n} else {\nspaceposition.y = mapping.y * 1.5 * radius2;\nspaceposition.x = mapping.x * 1.5 * radius2;\n}\nspaceposition.w = 1.0;\nvec4 e3 = vec4( 1.0 );\nvec3 e1, e1_temp, e2, e2_temp;\ne3.xyz = normalize(position_atom1-position_atom2);\nif (e3.z == 0.0) { e3.z = 0.0000000000001;}\nif ( (position_atom1.x - position_atom2.x) == 0.0) { position_atom1.x += 0.001;}\nif ( (position_atom1.y - position_atom2.y) == 0.0) { position_atom1.y += 0.001;}\nif ( (position_atom1.z - position_atom2.z) == 0.0) { position_atom1.z += 0.001;}\nvec4 focus = vec4( 1.0 );\nfocus.x = ( position_atom1.x*position_atom1.x - position_atom2.x*position_atom2.x +\n( radius2*radius2 - radius1*radius1 )*e3.x*e3.x/shrink )/(2.0*(position_atom1.x - position_atom2.x));\nfocus.y = ( position_atom1.y*position_atom1.y - position_atom2.y*position_atom2.y +\n( radius2*radius2 - radius1*radius1 )*e3.y*e3.y/shrink )/(2.0*(position_atom1.y - position_atom2.y));\nfocus.z = ( position_atom1.z*position_atom1.z - position_atom2.z*position_atom2.z +\n( radius2*radius2 - radius1*radius1 )*e3.z*e3.z/shrink )/(2.0*(position_atom1.z - position_atom2.z));\ne1.x = 1.0;\ne1.y = 1.0;\ne1.z = ( (e3.x*focus.x + e3.y*focus.y + e3.z*focus.z) - e1.x*e3.x - e1.y*e3.y)/e3.z;\ne1_temp = e1 - focus.xyz;\ne1 = normalize(e1_temp);\ne2_temp = e1.yzx * e3.zxy - e1.zxy * e3.yzx;\ne2 = normalize(e2_temp);\nmat3 R= mat3( e1.xyz, e2.xyz, e3.xyz );\nvertex_position.xyz = R * spaceposition.xyz;\nvertex_position.w = 1.0;\nvertex_position.x += (position_atom1.x+position_atom2.x) / 2.0;\nvertex_position.y += (position_atom1.y+position_atom2.y) / 2.0;\nvertex_position.z += (position_atom1.z+position_atom2.z) / 2.0;\ngl_Position = modelViewProjectionMatrix * vertex_position;\nvec4 i_near, i_far;\nvec4 near = gl_Position;\nnear.z = 0.0 ;\nnear = modelViewProjectionMatrixInverse * near;\ni_near = near;\nvec4 far = gl_Position;\nfar.z = far.w ;\ni_far = modelViewProjectionMatrixInverse * far;\nprime1 = vec4( position_atom1 - (position_atom1 - focus.xyz)*shrink, 1.0 );\nprime2 = vec4( position_atom2 - (position_atom2 - focus.xyz)*shrink, 1.0 );\nfloat Rsquare = (radius1*radius1/shrink) - (\n(position_atom1.x - focus.x)*(position_atom1.x - focus.x) +\n(position_atom1.y - focus.y)*(position_atom1.y - focus.y) +\n(position_atom1.z - focus.z)*(position_atom1.z - focus.z)\n);\nfocus.w = Rsquare;\nmatrix_near = mat4( i_near, i_far, focus, e3 );\ngl_Position.z = 1.0;\n}"),Ve.add("shader/HyperballStickImpostor.frag","#define STANDARD\n#define IMPOSTOR\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 interiorColor;\nuniform float interiorDarkening;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\nuniform float clipNear;\nuniform float shrink;\nuniform mat4 modelViewMatrix;\nuniform mat4 modelViewProjectionMatrix;\nuniform mat4 modelViewMatrixInverseTranspose;\nuniform mat4 projectionMatrix;\nvarying mat4 matrix_near;\nvarying vec4 prime1;\nvarying vec4 prime2;\nvarying float vRadius;\nvarying float vRadius2;\n#ifdef PICKING\nuniform float objectId;\nvarying vec3 vPickingColor;\n#else\nvarying vec3 vColor1;\nvarying vec3 vColor2;\n#include common\n#include fog_pars_fragment\n#include bsdfs\n#include lights_pars_begin\n#include lights_physical_pars_fragment\n#endif\nbool interior = false;\nfloat calcClip( vec4 cameraPos ){\nreturn dot( cameraPos, vec4( 0.0, 0.0, 1.0, clipNear - 0.5 ) );\n}\nfloat calcClip( vec3 cameraPos ){\nreturn calcClip( vec4( cameraPos, 1.0 ) );\n}\nfloat calcDepth( in vec3 cameraPos ){\nvec2 clipZW = cameraPos.z * projectionMatrix[2].zw + projectionMatrix[3].zw;\nreturn 0.5 + 0.5 * clipZW.x / clipZW.y;\n}\nstruct Ray {\nvec3 origin ;\nvec3 direction ;\n};\nbool cutoff_plane (vec3 M, vec3 cutoff, vec3 x3){\nfloat a = x3.x;\nfloat b = x3.y;\nfloat c = x3.z;\nfloat d = -x3.x*cutoff.x-x3.y*cutoff.y-x3.z*cutoff.z;\nfloat l = a*M.x+b*M.y+c*M.z+d;\nif (l<0.0) {return true;}\nelse{return false;}\n}\nvec3 isect_surf(Ray r, mat4 matrix_coef){\nvec4 direction = vec4(r.direction, 0.0);\nvec4 origin = vec4(r.origin, 1.0);\nfloat a = dot(direction,(matrix_coef*direction));\nfloat b = dot(origin,(matrix_coef*direction));\nfloat c = dot(origin,(matrix_coef*origin));\nfloat delta =b*b-a*c;\ngl_FragColor.a = 1.0;\nif (delta<0.0){\ndiscard;\n}\nfloat t1 =(-b-sqrt(delta))/a;\nreturn r.origin+t1*r.direction;\n}\nvec3 isect_surf2(Ray r, mat4 matrix_coef){\nvec4 direction = vec4(r.direction, 0.0);\nvec4 origin = vec4(r.origin, 1.0);\nfloat a = dot(direction,(matrix_coef*direction));\nfloat b = dot(origin,(matrix_coef*direction));\nfloat c = dot(origin,(matrix_coef*origin));\nfloat delta =b*b-a*c;\ngl_FragColor.a = 1.0;\nif (delta<0.0){\ndiscard;\n}\nfloat t2 =(-b+sqrt(delta))/a;\nreturn r.origin+t2*r.direction;\n}\nRay primary_ray(vec4 near1, vec4 far1){\nvec3 near=near1.xyz/near1.w;\nvec3 far=far1.xyz/far1.w;\nreturn Ray(near,far-near);\n}\nfloat update_z_buffer(vec3 M, mat4 ModelViewP){\nfloat depth1;\nvec4 Ms=(ModelViewP*vec4(M,1.0));\nreturn depth1=(1.0+Ms.z/Ms.w)/2.0;\n}\nvoid main(){\nfloat radius = max( vRadius, vRadius2 );\nvec4 i_near, i_far, focus;\nvec3 e3, e1, e1_temp, e2;\ni_near = vec4(matrix_near[0][0],matrix_near[0][1],matrix_near[0][2],matrix_near[0][3]);\ni_far = vec4(matrix_near[1][0],matrix_near[1][1],matrix_near[1][2],matrix_near[1][3]);\nfocus = vec4(matrix_near[2][0],matrix_near[2][1],matrix_near[2][2],matrix_near[2][3]);\ne3 = vec3(matrix_near[3][0],matrix_near[3][1],matrix_near[3][2]);\ne1.x = 1.0;\ne1.y = 1.0;\ne1.z = ( (e3.x*focus.x + e3.y*focus.y + e3.z*focus.z) - e1.x*e3.x - e1.y*e3.y)/e3.z;\ne1_temp = e1 - focus.xyz;\ne1 = normalize(e1_temp);\ne2 = normalize(cross(e1,e3));\nvec4 equation = focus;\nfloat shrinkfactor = shrink;\nfloat t1 = -1.0/(1.0-shrinkfactor);\nfloat t2 = 1.0/(shrinkfactor);\nvec4 colonne1, colonne2, colonne3, colonne4;\nmat4 mat;\nvec3 equation1 = vec3(t2,t2,t1);\nfloat A1 = - e1.x*equation.x - e1.y*equation.y - e1.z*equation.z;\nfloat A2 = - e2.x*equation.x - e2.y*equation.y - e2.z*equation.z;\nfloat A3 = - e3.x*equation.x - e3.y*equation.y - e3.z*equation.z;\nfloat A11 = equation1.x*e1.x*e1.x + equation1.y*e2.x*e2.x + equation1.z*e3.x*e3.x;\nfloat A21 = equation1.x*e1.x*e1.y + equation1.y*e2.x*e2.y + equation1.z*e3.x*e3.y;\nfloat A31 = equation1.x*e1.x*e1.z + equation1.y*e2.x*e2.z + equation1.z*e3.x*e3.z;\nfloat A41 = equation1.x*e1.x*A1 + equation1.y*e2.x*A2 + equation1.z*e3.x*A3;\nfloat A22 = equation1.x*e1.y*e1.y + equation1.y*e2.y*e2.y + equation1.z*e3.y*e3.y;\nfloat A32 = equation1.x*e1.y*e1.z + equation1.y*e2.y*e2.z + equation1.z*e3.y*e3.z;\nfloat A42 = equation1.x*e1.y*A1 + equation1.y*e2.y*A2 + equation1.z*e3.y*A3;\nfloat A33 = equation1.x*e1.z*e1.z + equation1.y*e2.z*e2.z + equation1.z*e3.z*e3.z;\nfloat A43 = equation1.x*e1.z*A1 + equation1.y*e2.z*A2 + equation1.z*e3.z*A3;\nfloat A44 = equation1.x*A1*A1 + equation1.y*A2*A2 + equation1.z*A3*A3 - equation.w;\ncolonne1 = vec4(A11,A21,A31,A41);\ncolonne2 = vec4(A21,A22,A32,A42);\ncolonne3 = vec4(A31,A32,A33,A43);\ncolonne4 = vec4(A41,A42,A43,A44);\nmat = mat4(colonne1,colonne2,colonne3,colonne4);\nRay ray = primary_ray(i_near,i_far) ;\nvec3 M;\nM = isect_surf(ray, mat);\nif (cutoff_plane(M, prime1.xyz, -e3) || cutoff_plane(M, prime2.xyz, e3)){ discard; }\nvec4 M1 = vec4(M,1.0);\nvec4 M2 = mat*M1;\nvec3 _normal = ( modelViewMatrixInverseTranspose * M2 ).xyz;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix) ;\n#ifdef NEAR_CLIP\nif( calcClip( modelViewMatrix * vec4( M, 1.0 ) ) > 0.0 ){\nM = isect_surf2(ray, mat);\nif( calcClip( modelViewMatrix * vec4( M, 1.0 ) ) > 0.0 )\ndiscard;\ninterior = true;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix) ;\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( clipNear - 0.5 ) ) ) + ( 0.0000001 / radius ) );\n}\n}else if( gl_FragDepthEXT <= 0.0 ){\nM = isect_surf2(ray, mat);\ninterior = true;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix);\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / radius );\n}\n}\n#else\nif( gl_FragDepthEXT <= 0.0 ){\nM = isect_surf2(ray, mat);\ninterior = true;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix) ;\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / radius );\n}\n}\n#endif\nif (cutoff_plane(M, prime1.xyz, -e3) || cutoff_plane(M, prime2.xyz, e3)){ discard; }\nif (gl_FragDepthEXT < 0.0)\ndiscard;\nif (gl_FragDepthEXT > 1.0)\ndiscard;\nfloat distance_ratio = ((M.x-prime2.x)*e3.x + (M.y-prime2.y)*e3.y +(M.z-prime2.z)*e3.z) /\ndistance(prime2.xyz,prime1.xyz);\n#ifdef PICKING\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 vViewPosition = -( modelViewMatrix * vec4( M, 1.0 ) ).xyz;\nvec3 vNormal = _normal;\nvec3 vColor;\nif( distance_ratio>0.5 ){\nvColor = vColor1;\n}else{\nvColor = vColor2;\n}\nvec4 diffuseColor = vec4( diffuse, opacity );\nReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\nvec3 totalEmissiveLight = emissive;\n#include color_fragment\n#include roughnessmap_fragment\n#include metalnessmap_fragment\nvec3 normal = normalize( vNormal );\nvec3 geometryNormal = normal;\n#include lights_physical_fragment\n#include lights_fragment_begin\n#include lights_fragment_end\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\nif( interior ){\n#ifdef USE_INTERIOR_COLOR\noutgoingLight.xyz = interiorColor;\n#else\n#ifdef DIFFUSE_INTERIOR\noutgoingLight.xyz = vColor;\n#endif\n#endif\noutgoingLight.xyz *= 1.0 - interiorDarkening;\n}\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");const Sd=new Float32Array([-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,-1,1,-1,1,1,-1,1,1,1,-1,1,1]),Cd=new Uint16Array([0,1,2,0,2,3,1,5,6,1,6,2,4,6,5,4,7,6,0,7,4,0,3,7,0,5,1,0,4,5,3,2,6,3,6,7]);class Pd extends Fc{constructor(t,e={}){super("v3",t,e)}get mapping(){return Sd}get mappingIndices(){return Cd}get mappingIndicesSize(){return 36}get mappingSize(){return 8}get mappingItemSize(){return 3}}const Id=Object.assign({shrink:.14},zo),kd=Object.assign({shrink:{uniform:!0}},Vo);class Md extends Pd{constructor(t,e={}){super(t,e),this.parameterTypes=kd,this.isImpostor=!0,this.vertexShader="HyperballStickImpostor.vert",this.fragmentShader="HyperballStickImpostor.frag",this.addUniforms({modelViewProjectionMatrix:{value:new i},modelViewProjectionMatrixInverse:{value:new i},modelViewMatrixInverseTranspose:{value:new i},shrink:{value:this.parameters.shrink}}),this.addAttributes({position1:{type:"v3",value:null},position2:{type:"v3",value:null},color2:{type:"c",value:null},radius:{type:"f",value:null},radius2:{type:"f",value:null}}),this.setAttributes(t),this.makeMapping()}get defaultParameters(){return Id}}Object.assign({disableImpostor:!1},Hh,Id);const Td=class{constructor(t,e={}){return!Ie||e&&e.disableImpostor?(t.radius=function(t,e){const i=t.length,r=new Float32Array(i);for(let s=0;sa.push(r.atomLabel(t)))))}else if("residue"===this.labelGrouping){e&&!e.position||(c=[]),e&&!e.color||(h=[]),e&&!e.radius||(l=[]),e&&!e.text||(a=[]),i.colorParams&&(i.colorParams.structure=t.getStructure());const d=Fe.getScheme(i.colorParams),u=new pa(i.radiusParams),m=t.getAtomProxy();let p=0;t.eachResidue((t=>{const i=3*p;t.isProtein()||t.isNucleic()?(m.index=t.traceAtomIndex,e&&!e.position||m.positionToArray(c,i)):(m.index=t.atomOffset,e&&!e.position||t.positionToArray(c,i)),e&&!e.color||d.atomColorToArray(m,h,i),e&&!e.radius||(l[p]=u.atomRadius(m)),e&&!e.text||a.push(r.atomLabel(m)),++p})),e&&!e.position||(s=new Float32Array(c)),e&&!e.color||(o=new Float32Array(h)),e&&!e.radius||(n=new Float32Array(l))}return{position:s,size:n,color:o,text:a}}createData(t){return{bufferList:[new Eh(this.getTextData(t,{position:!0,color:!0,radius:!0,text:!0}),this.getBufferParams({fontFamily:this.fontFamily,fontStyle:this.fontStyle,fontWeight:this.fontWeight,xOffset:this.xOffset,yOffset:this.yOffset,zOffset:this.zOffset,attachment:this.attachment,showBorder:this.showBorder,borderColor:this.borderColor,borderWidth:this.borderWidth,showBackground:this.showBackground,backgroundColor:this.backgroundColor,backgroundMargin:this.backgroundMargin,backgroundOpacity:this.backgroundOpacity,fixedSize:this.fixedSize}))]}}updateData(t,e){e.bufferList[0].setAttributes(this.getTextData(e.sview,t))}getAtomRadius(){return 0}}function Od(t){const e=t.getAtomSet(),i=t.getBondSet(),r=t.getBondProxy();return i.forEach((function(t){r.index=t,e.clear(r.atomIndex1),e.clear(r.atomIndex2)})),e}Ne.add("label",$d);class Rd extends Sh{constructor(t,e,i){super(t,e,i),this.type="line",this.parameters=Object.assign({multipleBond:{type:"select",rebuild:!0,options:{off:"off",symmetric:"symmetric",offset:"offset"}},bondSpacing:{type:"number",precision:2,max:2,min:.5},linewidth:{type:"integer",max:50,min:1,buffer:!0},lines:{type:"boolean",rebuild:!0},crosses:{type:"select",rebuild:!0,options:{off:"off",lone:"lone",all:"all"}},crossSize:{type:"number",precision:2,max:2,min:.1}},this.parameters,{flatShaded:null,side:null,wireframe:null,roughness:null,metalness:null}),this.init(i)}init(t){var e=t||{};this.multipleBond=st(e.multipleBond,"off"),this.bondSpacing=st(e.bondSpacing,1),this.linewidth=st(e.linewidth,2),this.lines=st(e.lines,!0),this.crosses=st(e.crosses,"lone"),this.crossSize=st(e.crossSize,.4),super.init(e)}getAtomRadius(t){return.1}getBondParams(t,e){return e=Object.assign({multipleBond:this.multipleBond,bondSpacing:this.bondSpacing,radiusParams:{type:"size",size:.1,scale:1}},e),super.getBondParams(t,e)}_crossData(t,e){if(t&&!t.position&&!t.color)return;const i={};"lone"===this.crosses&&Object.assign(i,{atomSet:Od(e)});const r=e.getAtomData(this.getAtomParams(t,i)),s={},n=r.position,o=r.color,a=r.picking,c=(n||o).length,l=3*c;let h=new Float32Array(0),d=new Float32Array(0),u=new Float32Array(0),m=new Float32Array(0),p=0,f=new Float32Array(0);t&&!t.position||(h=s.position1=new Float32Array(l),d=s.position2=new Float32Array(l),p=this.crossSize/2),t&&!t.color||(u=s.color=new Float32Array(l),m=s.color2=new Float32Array(l)),t&&!t.picking||(f=new Float32Array(3*r.picking.array.length));for(let e=0;el?u[f]=-1:(c=Math.sqrt(l-a),u[f]=Math.floor(c)),++f;p[g]=d,m[g]=u}}function k(i){var r,s,n,a,d,f,b,v,w,A,S,C,P,I,k,M,T,B,D=3*i,$=i;r=Math.floor(.5+o*(t[D]+u[0])),s=Math.floor(.5+o*(t[D+1]+u[1])),n=Math.floor(.5+o*(t[D+2]+u[2]));var O,R=e[$],E=m[R],F=0,L=l*h,N=p[R];for(A=0;A=c||I>=l||k>=h)){var z=P*L+I*h+k;if(g)if(y[z]&_){if(y[z]&_){var V=x[z];V!==D&&b*b+v*v+w*w<(a=r+b-Math.floor(.5+o*(t[V]+u[0])))*a+(d=s+v-Math.floor(.5+o*(t[V+1]+u[1])))*d+(f=n+w-Math.floor(.5+o*(t[V+2]+u[2])))*f&&(x[z]=i)}}else y[z]|=_,x[z]=i;else y[z]|=_}F++}}function M(e){var i,r;for(console.time("EDTSurface fillvoxels"),i=0,r=y.length;i=c||_>=l||C>=h)){var L=A*F+_*h+C;if(y[L]&S){if(g){var N=x[L];b*b+v*v+w*w<(a=Math.floor(.5+o*(t[N]+u[0])))*a+(d=Math.floor(.5+o*(t[N+1]+u[1])))*d+(f=Math.floor(.5+o*(t[N+2]+u[2])))*f&&(x[L]=i)}}else y[L]|=S,g&&(x[L]=i)}R++}}function B(){var t,e,i,r;console.time("EDTSurface fastdistancemap");var s,n=Ed(c,l,h,Uint16Array,3),o=l*h,d=f*f,u=0;for(t=0;t0);var A,P=a*a,I=new Uint16Array(3);for(t=0;t=P)||(y[s]|=C,g&&y[s]&S&&(n.toArray(t,e,i,I),A=I[0]*o+I[1]*h+I[2],x[s]=x[A])));console.timeEnd("EDTSurface fastdistancemap")}function D(t,e,i,r){var s,n,o,a,d,u,m,p,f,g,x,v,w=new Uint16Array(3),A=0;if(0===i)return A;var I=-1,k=-1,M=-1,T=l*h;for(m=0,f=i;m-1&&k-1&&M-1&&(y[x=I*T+h*k+M]&_&&!(y[x]&S)?(e.fromArray(I,k,M,w),g=(a=I-w[0])*a+(d=k-w[1])*d+(u=M-w[2])*u,b[x]=g,y[x]|=S,y[x]|=C,r[A]=I,r[A+1]=k,r[A+2]=M,A+=3):y[x]&_&&y[x]&S&&(g=(a=I-w[0])*a+(d=k-w[1])*d+(u=M-w[2])*u)-1&&k-1&&M-1&&(y[x=I*T+h*k+M]&_&&!(y[x]&S)?(e.fromArray(I,k,M,w),g=(a=I-w[0])*a+(d=k-w[1])*d+(u=M-w[2])*u,b[x]=g,y[x]|=S,y[x]|=C,r[A]=I,r[A+1]=k,r[A+2]=M,A+=3):y[x]&_&&y[x]&S&&(g=(a=I-w[0])*a+(d=k-w[1])*d+(u=M-w[2])*u)-1&&k-1&&M-1&&(y[x=I*T+h*k+M]&_&&!(y[x]&S)?(e.fromArray(I,k,M,w),g=(a=I-w[0])*a+(d=k-w[1])*d+(u=M-w[2])*u,b[x]=g,y[x]|=S,y[x]|=C,r[A]=I,r[A+1]=k,r[A+2]=M,A+=3):y[x]&_&&y[x]&S&&(g=(a=I-w[0])*a+(d=k-w[1])*d+(u=M-w[2])*u)-1&&o-1&&d-1&&aT&&(T=O)}return{neighbourListLength:27*T+1,withinRadii:function(s,n,o,a,d){for(var u=0,m=p(s,c),f=p(n,l),g=p(o,h),y=Math.max(0,m-1),w=Math.max(0,f-1),_=Math.max(0,g-1),S=Math.min(b,m+2),C=Math.min(x,f+2),M=Math.min(v,g+2),T=y;Tu&&(u=h[t]);!function(){const t=$o(c,l,u,p,0);p=t.scaleFactor,y=t.dim,b=t.matrix,$=Math.max(5,2+Math.floor(m*p)),x=Si(y[0]*y[1]*y[2],-1001),v=new Int32Array(x.length),w=new Float32Array(y[0]),A=new Float32Array(y[1]),_=new Float32Array(y[2]),R(w,c[0],1/p),R(A,c[1],1/p),R(_,c[2],1/p)}(),function(){var t=0,e=2*Math.PI/g;C=new Float32Array(g),S=new Float32Array(g);for(var i=0;i=0;){if(n!==r&&n!==s&&F(n,t,e,i))return k=n,n;n=I[++o]}return k=-1,-1}function F(e,i,r,s){var n=3*e,o=d[e],a=t[n]-i,c=t[n+1]-r,l=t[n+2]-s;return a*a+c*c+l*l0&&u=0;)t{e(this._makeSurface(t.data.sd,i))}),(t=>{console.warn("MolecularSurface.getSurfaceWorker error - trying without worker",t),this.worker.terminate(),this.worker=void 0;const r=this.getSurface(i);e(r)}))}else{const t=this.getSurface(i);e(t)}}dispose(){this.worker&&this.worker.terminate()}}class Vd extends Sh{constructor(t,e,i){super(t,e,i),this.type="surface",this.parameters=Object.assign({surfaceType:{type:"select",rebuild:!0,options:{vws:"vws",sas:"sas",ms:"ms",ses:"ses",av:"av"}},probeRadius:{type:"number",precision:1,max:20,min:0,rebuild:!0},smooth:{type:"integer",precision:1,max:10,min:0,rebuild:!0},scaleFactor:{type:"number",precision:1,max:5,min:0,rebuild:!0},cutoff:{type:"number",precision:2,max:50,min:0,rebuild:!0},contour:{type:"boolean",rebuild:!0},background:{type:"boolean",rebuild:!0},opaqueBack:{type:"boolean",buffer:!0},filterSele:{type:"text",rebuild:!0},colorVolume:{type:"hidden"},useWorker:{type:"boolean",rebuild:!0}},this.parameters,{radius:null,scale:null}),this.__infoList=[],this.structure.signals.refreshed.add((()=>{this.__forceNewMolsurf=!0})),this.toBePrepared=!0,this.init(i)}init(t){const e=t||{};e.colorScheme=st(e.colorScheme,"uniform"),e.colorValue=st(e.colorValue,14540253),e.disablePicking=st(e.disablePicking,!0),this.surfaceType=st(e.surfaceType,"ms"),this.probeRadius=st(e.probeRadius,1.4),this.smooth=st(e.smooth,2),this.scaleFactor=st(e.scaleFactor,2),this.cutoff=st(e.cutoff,0),this.contour=st(e.contour,!1),this.background=st(e.background,!1),this.opaqueBack=st(e.opaqueBack,!0),this.filterSele=st(e.filterSele,""),this.colorVolume=st(e.colorVolume,void 0),this.useWorker=st(e.useWorker,!0),super.init(t)}prepareData(t,i,r){let s=this.__infoList[i];if(s||(s={},this.__infoList[i]=s),s.molsurf&&s.sele===t.selection.string)r(i);else{if(this.filterSele){const s=t.structure.getView(new pe(this.filterSele)),n=s.boundingBox.getSize(new e),o=Math.max(n.x,n.y,n.z),a=t.getAtomSetWithinPoint(s.center,o/2+6);if(0===(t=t.getView(new pe(t.getAtomSetWithinSelection(a,3).toSeleString()))).atomCount)return void r(i)}s.sele=t.selection.string,s.molsurf=new zd(t);const n=this.getSurfaceParams(),o=t=>{s.surface=t,r(i)};this.useWorker?s.molsurf.getSurfaceWorker(n,o):o(s.molsurf.getSurface(n))}}prepare(t){if((this.__forceNewMolsurf||this.__sele!==this.selection.string||this.__surfaceParams!==JSON.stringify(this.getSurfaceParams()))&&(this.__infoList.forEach((t=>{t&&t.molsurf&&t.molsurf.dispose()})),this.__infoList.length=0),0===this.structureView.atomCount)return void t();const e=()=>{this.__sele=this.selection.string,this.__surfaceParams=JSON.stringify(this.getSurfaceParams()),this.__forceNewMolsurf=!1,t()},i="default"===this.assembly?this.defaultAssembly:this.assembly,r=this.structure.biomolDict[i];r?r.partList.forEach(((t,i)=>{const s=t.getView(this.structureView);this.prepareData(s,i,(t=>{t===r.partList.length-1&&e()}))})):this.prepareData(this.structureView,0,e)}createData(t,e){const i=this.__infoList[e],r=i.surface;if(!r)return;const s={position:r.getPosition(),color:r.getColor(this.getColorParams()),index:r.getFilteredIndex(this.filterSele,t)},n=[];if(r.contour){const t=new Xo(s,this.getBufferParams({wireframe:!1}));n.push(t)}else{Object.assign(s,{normal:r.getNormal(),picking:r.getPicking(t.getStructure())});const e=new jo(s,this.getBufferParams({background:this.background,opaqueBack:this.opaqueBack,dullInterior:!1}));if("double"==this.getBufferParams().side){const t=new qo(e);n.push(t)}else n.push(e)}return{bufferList:n,info:i}}updateData(t,e){const i={};if(t.position||t.radius)return this.__forceNewMolsurf=!0,void this.build();t.color&&(i.color=e.info.surface.getColor(this.getColorParams())),t.index&&(i.index=e.info.surface.getFilteredIndex(this.filterSele,e.sview)),e.bufferList[0].setAttributes(i)}setParameters(t,e={},i){return t&&t.filterSele&&(e.index=!0),t&&void 0!==t.colorVolume&&(e.color=!0),t&&t.wireframe&&(t.contour||void 0===t.contour&&this.contour)&&(t.wireframe=!1),super.setParameters(t,e,i),this}getSurfaceParams(t={}){return Object.assign({type:this.surfaceType,probeRadius:this.probeRadius,scaleFactor:this.scaleFactor,smooth:this.smooth&&!this.contour,cutoff:this.cutoff,contour:this.contour,useWorker:this.useWorker,radiusParams:this.getRadiusParams()},t)}getColorParams(){const t=super.getColorParams();return t.volume=this.colorVolume,t}getAtomRadius(){return 0}clear(){super.clear()}dispose(){this.__infoList.forEach((t=>{t&&t.molsurf&&t.molsurf.dispose()})),this.__infoList.length=0,super.dispose()}}Ne.add("surface",Vd);class Gd extends Sh{constructor(t,e,i){super(t,e,i),this.type="point",this.parameters=Object.assign({pointSize:{type:"number",precision:1,max:100,min:0,buffer:!0},sizeAttenuation:{type:"boolean",buffer:!0},sortParticles:{type:"boolean",rebuild:!0},useTexture:{type:"boolean",buffer:!0},alphaTest:{type:"range",step:.001,max:1,min:0,buffer:!0},forceTransparent:{type:"boolean",buffer:!0},edgeBleach:{type:"range",step:.001,max:1,min:0,buffer:!0}},this.parameters,{flatShaded:null,wireframe:null,linewidth:null,side:null,roughness:null,metalness:null}),this.init(i)}init(t){var e=t||{};this.pointSize=st(e.pointSize,1),this.sizeAttenuation=st(e.sizeAttenuation,!0),this.sortParticles=st(e.sortParticles,!1),this.useTexture=st(e.useTexture,!1),this.alphaTest=st(e.alphaTest,.5),this.forceTransparent=st(e.forceTransparent,!1),this.edgeBleach=st(e.edgeBleach,0),super.init(e)}createData(t){var e=t.getAtomData(this.getAtomParams({position:!0,color:!0,picking:!0}));return{bufferList:[new Wc(e,this.getBufferParams({pointSize:this.pointSize,sizeAttenuation:this.sizeAttenuation,sortParticles:this.sortParticles,useTexture:this.useTexture,alphaTest:this.alphaTest,forceTransparent:this.forceTransparent,edgeBleach:this.edgeBleach}))]}}updateData(t,e){var i=e.sview.getAtomData(this.getAtomParams(t)),r={};t&&!t.position||Object.assign(r,{position:i.position}),t&&!t.color||Object.assign(r,{color:i.color}),e.bufferList[0].setAttributes(r)}getAtomRadius(){return.1}}Ne.add("point",Gd),Ve.add("shader/Ribbon.vert","#define STANDARD\nuniform float clipNear;\nuniform vec3 clipCenter;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvarying vec3 vViewPosition;\n#endif\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\nattribute vec3 dir;\nattribute float size;\n#ifdef PICKING\n#include unpack_color\nattribute float primitiveId;\nvarying vec3 vPickingColor;\n#else\n#include color_pars_vertex\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\n#endif\n#include common\nvoid main(void){\n#ifdef PICKING\nvPickingColor = unpackColor( primitiveId );\n#else\n#include color_vertex\n#include beginnormal_vertex\n#include defaultnormal_vertex\n#ifndef FLAT_SHADED\nvNormal = normalize( transformedNormal );\n#endif\n#endif\n#include begin_vertex\ntransformed += normalize( dir ) * size;\n#include project_vertex\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvViewPosition = -mvPosition.xyz;\n#endif\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n#include nearclip_vertex\n}");const Ud=new Uint16Array([0,1,2,1,3,2]);function jd(t){return 3*(4*(t.position.length/3-1))}class Hd extends Uo{constructor(t,e={}){super({position:new Float32Array(jd(t)),color:new Float32Array(jd(t)),index:xt(jd(t),jd(t)/3),normal:new Float32Array(jd(t)),picking:t.picking},e),this.vertexShader="Ribbon.vert";const i=t.position.length/3-1,r=4*i,s=3*r;this.addAttributes({dir:{type:"v3",value:new Float32Array(s)}}),this.addAttributes({size:{type:"f",value:new Float32Array(r)}}),t.primitiveId=Pi(i),this.setAttributes(t),this.makeIndex()}setAttributes(t={}){const e=this.size/4,i=this.geometry.attributes;let r,s,n,o,a,c,l,h,d,u,m,p,f,g,y,b,x,v,w;t.position&&(r=t.position,l=i.position.array,i.position.needsUpdate=!0),t.normal&&(s=t.normal,h=i.normal.array,i.normal.needsUpdate=!0),t.size&&(n=t.size,d=i.size.array,i.size.needsUpdate=!0),t.dir&&(o=t.dir,u=i.dir.array,i.dir.needsUpdate=!0),t.color&&(a=t.color,m=i.color.array,i.color.needsUpdate=!0),t.primitiveId&&(c=t.primitiveId,p=i.primitiveId.array,i.primitiveId.needsUpdate=!0);let A=n?n[0]:null;for(f=0;f{if(!(t.residueCount<4)){i.push(t);var r=new od(t,this.getSplineParams()),s=r.getSubdividedPosition(),n=r.getSubdividedOrientation(),o=r.getSubdividedColor(this.getColorParams()),a=r.getSubdividedPicking(),c=r.getSubdividedSize(this.getRadiusParams());e.push(new Hd({position:s.position,normal:n.binormal,dir:n.normal,color:o.color,size:c.size,picking:a.picking},this.getBufferParams()))}}),t.getSelection()),{bufferList:e,polymerList:i}}updateData(t,e){t=t||{};var i=0,r=e.polymerList.length;for(i=0;i{if(t.residueCount<4||t.isNucleic())return;const s=new Pa(t),n=s.getAxis(this.localAngle,this.centerDist,this.ssBorder,this.getColorParams(),this.getRadiusParams());e+=n.size.length,i.push(n),r.push(s)}),t.getSelection());const s={begin:new Float32Array(3*e),end:new Float32Array(3*e),size:new Float32Array(e),color:new Float32Array(3*e),picking:{}};let n=new Float32Array(e),o=0;i.forEach((function(t){s.begin.set(t.begin,3*o),s.end.set(t.end,3*o),s.size.set(t.size,o),s.color.set(t.color,3*o),n.set(t.picking.array,o),o+=t.size.length})),e&&(s.picking=new Yn(n,t.getStructure()));return{bufferList:[new td({position1:s.begin,position2:s.end,color:s.color,color2:s.color,radius:s.size,picking:s.picking},this.getBufferParams({openEnded:this.openEnded,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0}))],axisList:i,helixbundleList:r,axisData:s}}updateData(t,e){if((t=t||{}).position)this.build();else{var i={};if(t.color||t.radius){var r=0;e.helixbundleList.forEach((i=>{var s=i.getAxis(this.localAngle,this.centerDist,this.ssBorder,this.getColorParams(),this.getRadiusParams());t.color&&e.axisData.color.set(s.color,3*r),(t.radius||t.scale)&&e.axisData.size.set(s.size,r),r+=s.size.length})),t.color&&Object.assign(i,{color:e.axisData.color,color2:e.axisData.color}),(t.radius||t.scale)&&Object.assign(i,{radius:e.axisData.size})}e.bufferList[0].setAttributes(i)}}}Ne.add("rocket",qd);class Xd extends dd{constructor(t,e,i){super(t,e,i),this.type="rope",this.parameters=Object.assign({smooth:{type:"integer",max:15,min:0,rebuild:!0}},this.parameters,{aspectRatio:null,smoothSheet:null})}init(t){var e=t||{};e.aspectRatio=1,e.tension=st(e.tension,.5),e.radiusScale=st(e.radiusScale,5),e.smoothSheet=!1,this.smooth=st(e.smooth,2),super.init(e)}getSpline(t){var e=new Ca(t);return new od(t,this.getSplineParams({directional:!1,positionIterator:e.getCenterIterator(this.smooth)}))}}Ne.add("rope",Xd);class Yd extends Sh{constructor(t,e,i){super(t,e,i),this.type="spacefill",this.parameters=Object.assign({sphereDetail:!0,disableImpostor:!0},this.parameters),this.init(i)}init(t){var e=t||{};e.useInteriorColor=st(e.useInteriorColor,!0),super.init(e)}createData(t){return{bufferList:[new Gc(t.getAtomData(this.getAtomParams()),this.getBufferParams({sphereDetail:this.sphereDetail,dullInterior:!0,disableImpostor:this.disableImpostor}))]}}updateData(t,e){var i=e.sview.getAtomData(this.getAtomParams(t)),r={};t&&!t.position||Object.assign(r,{position:i.position}),t&&!t.color||Object.assign(r,{color:i.color}),t&&!t.radius||Object.assign(r,{radius:i.radius}),e.bufferList[0].setAttributes(r)}}function Kd(t){return 3*(t.position.length/3-1)*2}Ne.add("spacefill",Yd);class Zd extends Go{constructor(t,e={}){super({position:new Float32Array(Kd(t)),color:new Float32Array(Kd(t))},e),this.isLine=!0,this.vertexShader="Line.vert",this.fragmentShader="Line.frag",this.setAttributes(t)}setAttributes(t){let e,i,r,s;const n=this.geometry.attributes;if(t.position&&(e=t.position,r=n.position.array,n.position.needsUpdate=!0),t.color&&(i=t.color,s=n.color.array,n.color.needsUpdate=!0),!e&&!i)return void Me.warn("TraceBuffer.prototype.setAttributes no data");let o,a;const c=this.size-1;for(let t=0;t{if(!(t.residueCount<4)){i.push(t);var r=new od(t,this.getSplineParams()),s=r.getSubdividedPosition(),n=r.getSubdividedColor(this.getColorParams());e.push(new Zd(Object.assign({},s,n),this.getBufferParams()))}}),t.getSelection()),{bufferList:e,polymerList:i}}updateData(t,e){t=t||{};var i=0,r=e.polymerList.length;for(i=0;i{t.boundingBox||t.computeBoundingBox(),this.boundingBox.union(t.boundingBox)}))}}const lu=Object.assign({aspectRatio:1.5,radialSegments:50,openEnded:!1,disableImpostor:!1},zo);class hu{constructor(t,e={}){this.group=new m,this.wireframeGroup=new m,this.pickingGroup=new m,this.visible=!0,this.parameters=nt(e,this.defaultParameters),this.splitPosition=new Float32Array(t.position1.length),this.cylinderRadius=new Float32Array(t.radius.length);const r=this.makeAttributes(t),s={radialSegments:this.parameters.radialSegments,openEnded:this.parameters.openEnded,disableImpostor:this.parameters.disableImpostor};this.cylinderBuffer=new td(r.cylinder,s),this.coneBuffer=new au(r.cone,s),this.geometry=new cu([this.cylinderBuffer.geometry,this.coneBuffer.geometry]),this.matrix=st(e.matrix,new i),this.picking=t.picking}get defaultParameters(){return lu}set matrix(t){Go.prototype.setMatrix.call(this,t)}get matrix(){return this.group.matrix.clone()}get pickable(){return!!this.picking}makeAttributes(t={}){const i=this.splitPosition,r=this.cylinderRadius,s=this.parameters.aspectRatio;let n,o;const a={},c={};if(t.radius){for(n=0,o=r.length;n(this._beforeParse(),this._parse(),this._afterParse(),this[this.__objName])))}_parse(){}_beforeParse(){}_afterParse(){De&&Me.log(this[this.__objName])}}class Nu extends Lu{constructor(t,e){var i=e||{};super(t,i),this.firstModelOnly=st(i.firstModelOnly,!1),this.asTrajectory=st(i.asTrajectory,!1),this.cAlphaOnly=st(i.cAlphaOnly,!1),this.structure=new Cc(this.name,this.path),this.structureBuilder=new za(this.structure)}get type(){return"structure"}get __objName(){return"structure"}}class zu{constructor(t,e,i="",r,s=[]){this.structure=t,this.index=e,this.description=i,this.entityType=function(t){switch(t=t.toLowerCase()){case"polymer":return 1;case"non-polymer":return 2;case"macrolide":return 3;case"water":return 4;default:return 0}}(r||""),this.chainIndexList=s,s.forEach((function(i){t.chainStore.entityIndex[i]=e}))}get type(){return function(t){switch(t){case 1:return"polymer";case 2:return"non-polymer";case 3:return"macrolide";case 4:return"water";default:return}}(this.entityType)}getEntityType(){return this.entityType}isPolymer(){return 1===this.entityType}isNonPolymer(){return 2===this.entityType}isMacrolide(){return 3===this.entityType}isWater(){return 4===this.entityType}eachChain(t){const e=this.structure.getChainProxy();this.chainIndexList.forEach((function(i){e.index=i,t(e)}))}}const Vu={a:1,b:1,c:1,alpha:90,beta:90,gamma:90,spacegroup:"P 1"};class Gu{constructor(t=Vu){this.cartToFrac=new i,this.fracToCart=new i,this.a=t.a,this.b=t.b,this.c=t.c,this.alpha=t.alpha,this.beta=t.beta,this.gamma=t.gamma,this.spacegroup=t.spacegroup;const e=kt(this.alpha),r=kt(this.beta),s=kt(this.gamma),n=Math.cos(e),o=Math.cos(r),a=Math.cos(s),c=Math.sin(r),l=Math.sin(s);if(this.volume=this.a*this.b*this.c*Math.sqrt(1-n*n-o*o-a*a+2*n*o*a),void 0===t.cartToFrac){const t=this.a*this.b*l/this.volume,e=(o*a-n)/(c*l);this.fracToCart.set(this.a,0,0,0,this.b*a,this.b*l,0,0,this.c*o,-this.c*c*e,1/t,0,0,0,0,1).transpose(),this.cartToFrac.getInverse(this.fracToCart)}else this.cartToFrac.copy(t.cartToFrac),this.fracToCart.getInverse(this.cartToFrac)}getPosition(t){const i=new Float32Array(24);if(t.unitcell){const r=t.unitcell,s=t.center.clone().applyMatrix4(r.cartToFrac).floor(),n=new e;let o=0;const a=function(t,e,a){n.set(t,e,a).add(s).applyMatrix4(r.fracToCart).toArray(i,o),o+=3};a(0,0,0),a(1,0,0),a(0,1,0),a(0,0,1),a(1,1,0),a(1,0,1),a(0,1,1),a(1,1,1)}return i}getCenter(t){return function(t,i=new e){const r=t.length;for(let e=0;e0)continue;let e,i,r,s,a,g=0;if(n){if(s=S.split(Wu),g=10===s.length?1:0,D=s[2],p&&"CA"!==D)continue;e=parseFloat(s[6-g]),i=parseFloat(s[7-g]),r=parseFloat(s[8-g])}else{if(D=S.substr(12,4).trim(),p&&"CA"!==D)continue;e=parseFloat(S.substr(30,8)),i=parseFloat(S.substr(38,8)),r=parseFloat(S.substr(46,8))}if(m){const t=3*b;if(y[t+0]=e,y[t+1]=i,y[t+2]=r,b+=1,x)continue}n?(P=parseInt(s[1]),a="",$="H"===S[0],I=g?"":s[4],k=parseInt(s[5-g]),B="",M=s[3],R="",T=1):(P=parseInt(S.substr(6,5),h),l&&99999===P&&(h=16),$="H"===S[0],I=S[21].trim(),k=parseInt(S.substr(22,4),d),l&&9999===k&&(d=16),B=S[26].trim(),M=S.substr(17,4).trim()||"MOL",O=parseFloat(S.substr(60,6)),R=S[16].trim(),T=parseFloat(S.substr(54,6)),t||(o?(a=S.substr(76,3).trim(),a in pn&&(a=pn[a])):(a=S.substr(76,2).trim(),I||(I=S.substr(72,4).trim())),E=parseInt((S.substr(79,1)+S.substr(78,1)).trim()))),dt.growIfFull(),dt.atomTypeId[pt]=ht.add(D,a),dt.x[pt]=e,dt.y[pt]=i,dt.z[pt]=r,dt.serial[pt]=P,dt.altloc[pt]=R.charCodeAt(0),dt.occupancy[pt]=isNaN(T)?0:T,n?(dt.partialCharge[pt]=parseFloat(s[9-g]),dt.radius[pt]=parseFloat(s[10-g])):(dt.bfactor[pt]=isNaN(O)?0:O,o&&(dt.partialCharge[pt]=parseFloat(S.substr(70,6))),isFinite(E)&&(dt.formalCharge||dt.addField("formalCharge",1,"int8"),dt.formalCharge[pt]=E));const v=qu(k,I,B);!$||K[v]||ju.includes(M)?tt||et===I||(Q+=1,J=Q.toString()):et===I&&rt===M&&(cn.includes(M)||it===k&&st===B)||(Q+=1,J=Q.toString(),it=k,rt=M,st=B),c.addAtom(ft,I,J,M,k,$,void 0,B),U[P]=pt,pt+=1,tt=!1,et=I}else if("CONECT"===C){const t=U[parseInt(S.substr(6,5))],e=[11,16,21,26],i={};if(void 0===t)continue;for(let r=0;r<4;++r){let s=parseInt(S.substr(e[r],5));if(!Number.isNaN(s)&&(s=U[s],void 0!==s))if(t0)continue;const s=e[l].replace(Zu,"");if(k&&"CA"!==s)continue;const T=parseFloat(e[x]),$=parseFloat(e[v]),O=parseFloat(e[w]);if(I){const e=3*r;if(t[e+0]=T,t[e+1]=$,t[e+2]=O,r+=1,X>0)continue}const R=e[h],E=parseInt(e[-1!==a?a:c]);let F=e[b];F="?"===F?"":F;const L=e[o],N=e[d],z="H"===e[p][0],V=e[g],Y=parseFloat(e[A]),K=parseFloat(e[_]);let Z=e[m];if(Z="."===Z?"":Z,H.growIfFull(),H.atomTypeId[q]=j.add(s,V),H.x[q]=T,H.y[q]=$,H.z[q]=O,H.serial[q]=parseInt(e[f]),H.bfactor[q]=isNaN(Y)?0:Y,H.occupancy[q]=isNaN(K)?0:K,H.altloc[q]=Z.charCodeAt(0),C.addAtom(X,L,N,R,E,z,void 0,F),De){const t=B[N];void 0!==t&&t!==L&&De&&Me.warn(t,L)}B[N]=L;const Q=e[u];D[Q]||(D[Q]=new Set),D[Q].add(S.chainStore.count-1),q+=1}else{const t=n.match(Ku),e=t.length;N===L.length&&(N=0);for(let i=0;ic*c)return n.growIfFull(),n.atomTypeId[m]=n.atomTypeId[t],n.x[m]=h.x,n.y[m]=h.y,n.z[m]=h.z,n.occupancy[m]=n.occupancy[t],n.serial[m]=m,n.altloc[m]="A".charCodeAt(0),s.addAtom(0,"","","HET",1,!0),void(m+=1)}}}))}}(T,S,C),C.finalize(),S.finalizeAtoms(),Wa(S),S.finalizeBonds();else{var Y=function(t,e,i){var r,s,n,o,a=[],c=[],l=t.struct_conf;if(null==l?void 0:l.pdbx_PDB_helix_class)for(tm(l,"id"),r=0,s=l.beg_auth_seq_id.length;r0){o=o.split("(");var l=c(o[0]),h=c(o[1]);Object.keys(l).forEach((function(t){Object.keys(h).forEach((function(e){var r=new i;r.multiplyMatrices(l[t],h[e]),s[t+"x"+e]=r}))}))}else s=c(o);var d=[];for(var u in s)d.push(s[u]);var m=t;/^(0|[1-9][0-9]*)$/.test(m)&&(m="BU"+m);for(var p=a.asym_id_list[e].split(","),f=0,g=p.length;fA){var _=w;w=A,A=_;var S=p;p=x,x=S}if(0!==w&&0!==A)for(var C=0;Cb)continue}d=I.substr(5,5).trim(),u=parseInt(I.substr(0,5)),m=parseInt(I.substr(15,5)),v.growIfFull(),v.atomTypeId[w]=x.add(h),v.x[w]=T,v.y[w]=B,v.z[w]=D,v.serial[w]=m,r.addAtom(A,"","",d,u,!1,"l"),w+=1}}}(0,i.length,i)})),r.finalize(),i.finalizeAtoms(),Ha(i),Wa(i),i.finalizeBonds(),Ga(i),De&&Me.timeEnd("GroParser._parse "+this.name)}});var nm=["mmtfVersion","mmtfProducer","unitCell","spaceGroup","structureId","title","depositionDate","releaseDate","experimentalMethods","resolution","rFree","rWork","bioAssemblyList","ncsOperatorList","entityList","groupList","numBonds","numAtoms","numGroups","numChains","numModels","groupsPerChain","chainsPerModel"].concat(["xCoordList","yCoordList","zCoordList","groupIdList","groupTypeList","chainIdList","bFactorList","atomIdList","altLocList","occupancyList","secStructList","insCodeList","sequenceIndexList","chainNameList","bondAtomList","bondOrderList"]);function om(t,e,i){return e?new t(e.buffer,e.byteOffset,e.byteLength/(i||1)):void 0}function am(t){return om(DataView,t)}function cm(t){return om(Int8Array,t)}function lm(t){return om(Int32Array,t,4)}function hm(t,e){var i=t.length/2;e||(e=new Int16Array(i));for(var r=0,s=0;rn&&++a;e=new Int32Array(a)}for(i=0,r=0;is){for(var n=[],o=0;o0&&(o.biomolDict[t]=e)}const O=a.unitCell;O&&Array.isArray(O)&&O[0]?o.unitcell=new Gu({a:O[0],b:O[1],c:O[2],alpha:O[3],beta:O[4],gamma:O[5],spacegroup:a.spaceGroup}):o.unitcell=void 0,Ka(o,!0),Ya(o,!0),o.finalizeAtoms(),o.finalizeBonds(),Za(o),De&&Me.timeEnd("MmtfParser._parse "+this.name)}});const Am=/\s+/,_m={1:1,2:2,3:3,am:1,ar:1,du:1,un:1,nc:0};ze.add("mol2",class extends Nu{get type(){return"mol2"}_parse(){De&&Me.time("Mol2Parser._parse "+this.name);const t=this.structure,e=this.structureBuilder,i=this.firstModelOnly,r=this.asTrajectory,s=t.frames;let n,o,a=!1;const c=t.atomMap,l=t.atomStore;l.resize(Math.round(this.streamer.data.length/60)),l.addField("partialCharge",1,"float32");let h=0,d=0,u=0,m=-1,p=0,f=0;const g=t.getAtomProxy(),y=t.getAtomProxy();this.streamer.eachChunkOfLines((function(b){!function(b,x,v){for(let w=b;wMOLECULE"===b?(f=1,d=0,++m):"@ATOM"===b?(f=2,u=l.count,r&&(o=0,n=new Float32Array(3*p),s.push(n),m>0&&(a=!0))):f="@BOND"===b?3:0;else if(1===f){if(0===d)t.title=b,t.id=b;else if(1===d){const t=b.split(Am);p=parseInt(t[0])}++d}else if(2===f){const t=b.split(Am);if(i&&m>0)continue;const s=parseFloat(t[2]),d=parseFloat(t[3]),u=parseFloat(t[4]);if(r){const t=3*o;if(n[t+0]=s,n[t+1]=d,n[t+2]=u,o+=1,a)continue}const p=t[0],f=t[1],g=t[5].split(".")[0],y=t[6]?parseInt(t[6]):1,x=t[7]?t[7]:"",v=t[8]?parseFloat(t[8]):0;l.growIfFull(),l.atomTypeId[h]=c.add(f,g),l.x[h]=s,l.y[h]=d,l.z[h]=u,l.serial[h]=p,l.partialCharge[h]=v,e.addAtom(m,"","",x,y,!0),h+=1}else if(3===f){if(i&&m>0)continue;if(r&&m>0)continue;const e=b.split(Am);g.index=parseInt(e[1])-1+u,y.index=parseInt(e[2])-1+u;const s=_m[e[3]];t.bondStore.addBond(g,y,s)}}}(0,b.length,b)})),e.finalize(),t.finalizeAtoms(),Ha(t),Ya(t,!0),Ka(t,!0),t.finalizeBonds(),ec(t),Ga(t),De&&Me.timeEnd("Mol2Parser._parse "+this.name)}});ze.add("pdbqt",class extends Xu{get type(){return"pdbqt"}});ze.add("pqr",class extends Xu{get type(){return"pqr"}});const Sm=/> +<(.+)>/;class Cm extends Nu{get type(){return"sdf"}_parse(){De&&Me.time("SdfParser._parse "+this.name);const t=this.structure,e=this.structureBuilder,i=this.firstModelOnly,r=this.asTrajectory,s=this.streamer.peekLines(2);t.id=s[0].trim(),t.title=s[1].trim();const n=t.frames;let o,a,c=!1;const l=t.atomMap,h=t.atomStore;h.resize(Math.round(this.streamer.data.length/50)),h.addField("formalCharge",1,"int8");const d=t.getAtomProxy(),u=t.getAtomProxy();let m=0,p=0,f=0,g=0;const y=[];let b,x,v,w,A,_,S,C,P,I,k,M,T,B,D=!1,$={};t.extraData.sdf=y;let O=!1,R=!1,E=!1,F=[],L=[];const N=new Map;this.streamer.eachChunkOfLines((function(s){!function(s,z,V){for(let G=s;G-1,O?N.clear():(x=parseInt(s.substr(0,3)),v=parseInt(s.substr(3,3)),w=4,A=w+x,_=A,S=_+v,r&&(a=0,o=new Float32Array(3*x),n.push(o),f>0&&(c=!0)));else if(O&&"COUNTS"===F[0])x=parseInt(F[1]),r&&(a=0,o=new Float32Array(3*x),n.push(o),f>0&&(c=!0));else if(O&&2==F.length)"ATOM"===F[1]?"BEGIN"===F[0]?R=!0:"END"===F[0]&&(R=!1):"BOND"===F[1]&&("BEGIN"===F[0]?E=!0:"END"===F[0]&&(E=!1));else if(R||!O&&p>=w&&p0)continue;let t=0;if(O){if(C=parseFloat(F[2]),P=parseFloat(F[3]),I=parseFloat(F[4]),M=F[1],T=parseInt(F[0]),N.set(T,m),k=M+T,F.length>6){let e=F.slice(6).find((t=>0===t.indexOf("CHG=")));e&&(t=parseInt(e.substring(4)))}}else C=parseFloat(s.substr(0,10)),P=parseFloat(s.substr(10,10)),I=parseFloat(s.substr(20,10)),M=s.substr(31,3).trim(),k=M+(m-g+1);if(r){const t=3*a;if(o[t+0]=C,o[t+1]=P,o[t+2]=I,a+=1,c)continue}h.growIfFull(),h.atomTypeId[m]=l.add(k,M),h.x[m]=C,h.y[m]=P,h.z[m]=I,h.serial[m]=O?T:m,h.formalCharge[m]=t,e.addAtom(f,"","","HET",1,!0),m+=1}else if(E||!O&&p>=_&&p0)continue;if(r&&f>0)continue;O?(d.index=N.get(parseInt(F[2])),u.index=N.get(parseInt(F[3])),B=parseInt(F[1])):(d.index=parseInt(s.substr(0,3))-1+g,u.index=parseInt(s.substr(3,3))-1+g,B=parseInt(s.substr(6,3))),t.bondStore.addBond(d,u,B)}else if("M CHG"===s.substr(0,6)){const t=parseInt(s.substr(6,3));for(let e=0,i=10;e"===s.charAt(0)&&(b=s.match(Sm))?(D=b[1],$[D]=[]):!1!==D&&s&&$[D].push(s);++p}}}(0,s.length,s)})),e.finalize(),t.finalizeAtoms(),t.finalizeBonds(),ec(t),De&&Me.timeEnd("SdfParser._parse "+this.name)}_postProcess(){ec(this.structure)}}ze.add("sdf",Cm),ze.add("sd",Cm),ze.add("mol",Cm);function Pm(t,e,i){return parseInt(t.substr(e,i).trim())}class Im extends Nu{get type(){return"prmtop"}_parse(){De&&Me.time("PrmtopParser._parse "+this.name);const t=this.structure,e=this.structureBuilder,i=t.atomMap,r=t.atomStore;r.addField("partialCharge",1,"float32"),r.addField("radius",1,"float32");const s=[],n={},o=["NATOM","NTYPES","NBONH","MBONA","NTHETH","MTHETA","NPHIH","MPHIA","NHPARM","NPARM","NNB","NRES","NBONA","NTHETA","NPHIA","NUMBND","NUMANG","NPTRA","NATYP","NPHB","IFPERT","NBPER","NGPER","NDPER","MBPER","MGPER","MDPER","IFBOX","NMXRS","IFCAP","NUMEXTRA","NCOPY"];let a,c,l,h,d;o.forEach((t=>{n[t]=0}));let u,m,p,f,g,y=new Uint8Array(0);this.streamer.eachChunkOfLines((function(t){!function(t,e,i){for(let b=t;b0)return void Me.error("dcd format with fixed atoms unsupported, aborting");const p=n.NATOM,f=4*p;for(let i=0,a=n.NSET;i=1&&(i.timeOffset=(n.ISTART-1)*i.deltaTime),De&&Me.timeEnd("DcdParser._parse "+this.name)}});const Em={BYTE:1,CHAR:2,SHORT:3,INT:4,FLOAT:5,DOUBLE:6};function Fm(t){switch(Number(t)){case Em.BYTE:return"byte";case Em.CHAR:return"char";case Em.SHORT:return"short";case Em.INT:return"int";case Em.FLOAT:return"float";case Em.DOUBLE:return"double";default:return"undefined"}}function Lm(t){switch(Number(t)){case Em.BYTE:case Em.CHAR:return 1;case Em.SHORT:return 2;case Em.INT:case Em.FLOAT:return 4;case Em.DOUBLE:return 8;default:return-1}}function Nm(t){switch(String(t)){case"byte":return Em.BYTE;case"char":return Em.CHAR;case"short":return Em.SHORT;case"int":return Em.INT;case"float":return Em.FLOAT;case"double":return Em.DOUBLE;default:return-1}}function zm(t,e){if(1!==t){const i=new Array(t);for(let r=0;r6,"non valid type "+h);const d=t.readUint32();let u=t.readUint32();2===i&&($m(u>0,"offsets larger than 4GB not supported"),u=t.readUint32()),c[0]===e&&(n+=d),s[r]={name:o,dimensions:c,attributes:l,type:Fm(h),size:d,offset:u,record:c[0]===e}}}return{variables:s,recordStep:n}}(t,r.recordId,e);return i.variables=s.variables,i.recordDimension.recordStep=s.recordStep,i}function qm(t){let e;const i=t.readUint32();if(i===Gm)return $m(t.readUint32()!==Gm,"wrong empty tag for list of attributes"),[];{$m(i!==Hm,"wrong tag for list of attributes");const r=t.readUint32();e=new Array(r);for(let i=0;i6,"non valid type "+s);const n=t.readUint32(),o=Vm(t,s,n);Om(t),e[i]={name:r,type:Fm(s),value:o}}}return e}class Xm{constructor(t){const e=new hi(t);e.setBigEndian(),$m("CDF"!==e.readChars(3),"should start with CDF");const i=e.readByte();$m(i>2,"unknown version"),this.header=Wm(e,i),this.buffer=e}get version(){return 1===this.header.version?"classic format":"64-bit offset format"}get recordDimension(){return this.header.recordDimension}get dimensions(){return this.header.dimensions}get globalAttributes(){return this.header.globalAttributes}get variables(){return this.header.variables}hasDataVariable(t){return-1!==this.header.variables.findIndex((function(e){return e.name===t}))}getDataVariable(t){let e;return e="string"==typeof t?this.header.variables.find((function(e){return e.name===t})):t,$m(void 0===e,"variable not found"),this.buffer.seek(e.offset),e.record?function(t,e,i){const r=Nm(e.type),s=e.size?e.size/Lm(r):1,n=i.length,o=new Array(n),a=i.recordStep;for(let e=0;e=1&&(e.timeOffset=s[0]),s.length>=2&&(e.deltaTime=s[1]-s[0]),De&&Me.timeEnd("NctrajParser._parse "+this.name)}}ze.add("nctraj",Ym),ze.add("ncdf",Ym),ze.add("nc",Ym);ze.add("trr",class extends Dm{get type(){return"trr"}get isBinary(){return!0}_parse(){De&&Me.time("TrrParser._parse "+this.name);const t=vt(this.streamer.data),e=new DataView(t),i=this.frames,r=i.coordinates,s=i.boxes,n=i.times;let o=0;for(;;){o+=8;const i=e.getInt32(o);o+=4,o+=i;const a=e.getInt32(o+8),c=e.getInt32(o+12),l=e.getInt32(o+16),h=e.getInt32(o+28),d=e.getInt32(o+32),u=e.getInt32(o+36),m=e.getInt32(o+40);o+=52;const p=a/9,f=3*m;if(8===p?n.push(e.getFloat64(o)):n.push(e.getFloat32(o)),o+=2*p,a){const t=new Float32Array(9);if(8===p)for(let i=0;i<9;++i)t[i]=10*e.getFloat64(o),o+=8;else for(let i=0;i<9;++i)t[i]=10*e.getFloat32(o),o+=4;s.push(t)}if(o+=c,o+=l,h){let i;if(8===p){i=new Float32Array(f);for(let t=0;t>8&65280|i>>24&255}i=new Float32Array(t,o,f);for(let t=0;t=t.byteLength)break}n.length>=1&&(i.timeOffset=n[0]),n.length>=2&&(i.deltaTime=n[1]-n[0]),De&&Me.timeEnd("TrrParser._parse "+this.name)}});const Km=new Uint32Array([0,0,0,0,0,0,0,0,0,8,10,12,16,20,25,32,40,50,64,80,101,128,161,203,256,322,406,512,645,812,1024,1290,1625,2048,2580,3250,4096,5060,6501,8192,10321,13003,16384,20642,26007,32768,41285,52015,65536,82570,104031,131072,165140,208063,262144,330280,416127,524287,660561,832255,1048576,1321122,1664510,2097152,2642245,3329021,4194304,5284491,6658042,8388607,10568983,13316085,16777216]);function Zm(t){let e=1,i=0;for(;t>=e&&i<32;)i++,e<<=1;return i}const Qm=new Uint8Array(32);function Jm(t,e){let i=1,r=0;Qm[0]=1;for(let r=0;r>=8;for(;0!==s;)Qm[t++]=255&s,s>>=8;i=t}let s=1;for(i--;Qm[i]>=s;)r++,s*=2;return r+8*i}function tp(t,e,i,r){const s=(1<=8;)o=o<<8|e[a++],c|=o>>n<0&&(n>n&(1<8;)ep[a++]=tp(t,e,8,o),r-=8;r>0&&(ep[a++]=tp(t,e,r,o));for(let t=i-1;t>0;t--){let e=0;for(let i=a-1;i>=0;i--){e=e<<8|ep[i];const r=e/s[t]|0;ep[i]=r,e-=r*s[t]}n[t]=e}n[0]=ep[0]|ep[1]<<8|ep[2]<<16|ep[3]<<24}ze.add("xtc",class extends Dm{get type(){return"xtc"}get isBinary(){return!0}_parse(){De&&Me.time("XtcParser._parse "+this.name);const t=vt(this.streamer.data),e=new DataView(t),i=this.frames,r=i.coordinates,s=i.boxes,n=i.times,o=new Int32Array(6),a=new Int32Array(3),c=new Int32Array(3),l=new Uint32Array(3),h=new Float32Array(3),d=new Float32Array(3);let u=0;const m=new Int32Array(3),p=new Uint32Array(m.buffer);for(;;){let i;const f=e.getInt32(u+4);u+=12;const g=3*f;n.push(e.getFloat32(u)),u+=4;const y=new Float32Array(9);for(let t=0;t<9;++t)y[t]=10*e.getFloat32(u),u+=4;if(s.push(y),f<=9){i=new Float32Array(f);for(let t=0;t16777215?(c[0]=Zm(a[0]),c[1]=Zm(a[1]),c[2]=Zm(a[2]),f=0):f=Jm(3,a);let y=e.getInt32(u);u+=4;let b=y-1;b=9>b?9:b;let x=Km[b]/2|0,v=Km[y]/2|0;l[0]=l[1]=l[2]=Km[y];let w=4*Math.ceil(e.getInt32(u)/4);u+=4;const A=1/n;let _=0,S=0;const C=new Uint8Array(t,u);for(h[0]=h[1]=h[2]=0;S0){h[0]=h[1]=h[2]=0;for(let t=0;t<_;t+=3){if(ip(m,C,3,y,l,h,p),S++,h[0]+=d[0]-v,h[1]+=d[1]-v,h[2]+=d[2]-v,0===t){let t=h[0];h[0]=d[0],d[0]=t,t=h[1],h[1]=d[1],d[1]=t,t=h[2],h[2]=d[2],d[2]=t,i[r++]=d[0]*A,i[r++]=d[1]*A,i[r++]=d[2]*A}else d[0]=h[0],d[1]=h[1],d[2]=h[2];i[r++]=h[0]*A,i[r++]=h[1]*A,i[r++]=h[2]*A}}else i[r++]=h[0]*A,i[r++]=h[1]*A,i[r++]=h[2]*A;if(y+=t,t<0?(v=x,x=y>9?Km[y-1]/2|0:0):t>0&&(x=v,v=Km[y]/2|0),l[0]=l[1]=l[2]=Km[y],0===l[0]||0===l[1]||0===l[2])return void console.error("(xdrfile error) Undefined error.")}u+=w}for(let t=0;t=t.byteLength)break}n.length>=1&&(i.timeOffset=n[0]),n.length>=2&&(i.deltaTime=n[1]-n[0]),De&&Me.timeEnd("XtcParser._parse "+this.name)}});class rp extends Lu{constructor(t,e){const i=e||{};super(t,i),this.volume=new Eo(this.name,this.path),this.voxelSize=st(i.voxelSize,1)}get type(){return"volume"}get __objName(){return"volume"}_afterParse(){this.volume.setMatrix(this.getMatrix()),super._afterParse()}getMatrix(){return new i}}const sp=/\s+/,np=/-?\d+(?:\.\d*)?(?:[eE][+-]?\d+)?/g,op=.529177210859;class ap extends rp{get type(){return"cube"}_parse(){De&&Me.time("CubeParser._parse "+this.name);const t=this.volume,i=this.streamer.peekLines(6),r={},s=op*this.voxelSize;function n(t,e){var r=i[t].trim().split(sp)[e];return parseFloat(r)}r.atomCount=Math.abs(n(2,0)),r.originX=n(2,1)*op,r.originY=n(2,2)*op,r.originZ=n(2,3)*op,r.NVX=n(3,0),r.NVY=n(4,0),r.NVZ=n(5,0),r.basisX=new e(n(3,1),n(3,2),n(3,3)).multiplyScalar(s),r.basisY=new e(n(4,1),n(4,2),n(4,3)).multiplyScalar(s),r.basisZ=new e(n(5,1),n(5,2),n(5,3)).multiplyScalar(s);const o=new Float32Array(r.NVX*r.NVY*r.NVZ);let a=0,c=0;const l=n(2,0)>0?0:1;this.streamer.eachChunkOfLines((function(t){!function(t,e,i){for(let s=t;s=r.atomCount+6+l){const e=t.match(np);for(let t=0,i=e.length;t>8&255}e.xStart=n[0],e.yStart=n[1],e.zStart=n[2],e.xExtent=n[3],e.yExtent=n[4],e.zExtent=n[5],e.xRate=n[6],e.yRate=n[7],e.zRate=n[8];const t=1/n[17],s=t*this.voxelSize;e.xlen=n[9]*s,e.ylen=n[10]*s,e.zlen=n[11]*s,e.alpha=n[12]*t,e.beta=n[13]*t,e.gamma=n[14]*t,i=n[15]/100,r=n[16],e.gamma=n[14]*t}t.header=e,De&&Me.log(e,i,r);const c=new Float32Array(e.xExtent*e.yExtent*e.zExtent);let l=512;const h=Math.ceil(e.xExtent/8),d=Math.ceil(e.yExtent/8),u=Math.ceil(e.zExtent/8);for(var m=0;ms){const t=i[r].trim();if(""!==t){const e=t.split(lp);for(let t=0,i=e.length;t=s&&(p-s)%u!=0&&m=0?i-1:i+e/3)},parseNormalIndex:function(t,e){var i=parseInt(t,10);return 3*(i>=0?i-1:i+e/3)},addVertex:function(t,e,i){var r=this.vertices,s=this.object.geometry.vertices;s.push(r[t+0]),s.push(r[t+1]),s.push(r[t+2]),s.push(r[e+0]),s.push(r[e+1]),s.push(r[e+2]),s.push(r[i+0]),s.push(r[i+1]),s.push(r[i+2])},addVertexLine:function(t){var e=this.vertices,i=this.object.geometry.vertices;i.push(e[t+0]),i.push(e[t+1]),i.push(e[t+2])},addNormal:function(t,e,i){var r=this.normals,s=this.object.geometry.normals;s.push(r[t+0]),s.push(r[t+1]),s.push(r[t+2]),s.push(r[e+0]),s.push(r[e+1]),s.push(r[e+2]),s.push(r[i+0]),s.push(r[i+1]),s.push(r[i+2])},addFace:function(t,e,i,r,s,n,o,a){var c,l=this.vertices.length,h=this.parseVertexIndex(t,l),d=this.parseVertexIndex(e,l),u=this.parseVertexIndex(i,l);if(void 0===r?this.addVertex(h,d,u):(c=this.parseVertexIndex(r,l),this.addVertex(h,d,c),this.addVertex(d,u,c)),void 0!==s){var m=this.normals.length;h=this.parseNormalIndex(s,m),d=s===n?h:this.parseNormalIndex(n,m),u=s===o?h:this.parseNormalIndex(o,m),void 0===r?this.addNormal(h,d,u):(c=this.parseNormalIndex(a,m),this.addNormal(h,d,c),this.addNormal(d,u,c))}},addLineGeometry:function(t){this.object.geometry.type="Line";for(var e=this.vertices.length,i=0,r=t.length;i0?x.setAttribute("normal",new M(new Float32Array(b.normals),3)):x.computeVertexNormals(),y.push(x)}}return y}};ze.add("obj",class extends Ip{get type(){return"obj"}getLoader(){return new kp}});const Mp=function(){this.propertyNameMapping={}};Mp.prototype={constructor:Mp,setPropertyNameMapping:function(t){this.propertyNameMapping=t},bin2str:function(t){for(var e=new Uint8Array(t),i="",r=0;r=r.elements[o].count&&(o++,a=0);var h=this.parseASCIIElement(r.elements[o].properties,l);this.handleElement(i,r.elements[o].name,h),a++}}return this.postProcess(i)},postProcess:function(t){if(t.useColor){for(var e=0;e{const s=r.length;for(let n=0;n/g,""),{declaration:e(),root:i()};function e(){if(!s(/^<\?xml\s*/))return;const t={attributes:{}};for(;!n()&&!o("?>");){const e=r();if(!e)return t;t.attributes[e.name]=e.value}return s(/\?>\s*/),t}function i(){const t=s(Dp);if(!t)return;const e={name:t[1],attributes:{},children:[]};for(;!(n()||o(">")||o("?>")||o("/>"));){const t=r();if(!t)return e;e.attributes[t.name]=t.value}if(s(/^\s*\/>\s*/))return e;let a;for(s(/\??>\s*/),e.content=function(){const t=s($p);return t?t[1]:""}();a=i();)e.children.push(a);return s(/^<\/[\w-:.]+>\s*/),e}function r(){const t=s(Op);var e;if(t)return{name:t[1],value:(e=t[2],e.replace(Bp,""))}}function s(e){const i=t.match(e);if(i)return t=t.slice(i[0].length),i}function n(){return 0===t.length}function o(e){return 0===t.indexOf(e)}}class Ep extends Lu{constructor(t,e){const i=e||{};super(t,i),this.useDomParser=st(i.useDomParser,!1),this.xml={name:this.name,path:this.path,data:{}}}get type(){return"xml"}get __objName(){return"xml"}get isXml(){return!0}__xmlParser(t){return Rp(t)}__domParser(t){return(new window.DOMParser).parseFromString(t,"text/xml")}_parse(){De&&Me.time("XmlParser._parse "+this.name),this.useDomParser?this.streamer.data instanceof Document?this.xml.data=this.streamer.data:this.xml.data=this.__domParser(this.streamer.asText()):this.xml.data=this.__xmlParser(this.streamer.asText()),De&&Me.timeEnd("XmlParser._parse "+this.name)}}function Fp(t,e){const i=t.getNamedItem(e);return null!==i?i.value:""}function Lp(t,e,i=!1){const r=Fp(t,"icode").trim(),s=Fp(t,"chain").trim(),n=Fp(t,"altcode");let o=Fp(t,"resnum");return r&&(o+="^"+r),s&&(o+=":"+s),e&&(o+="."+e),i&&n.trim()&&(o+="%"+n),o+="/"+(parseInt(Fp(t,"model"))-1),o}function Np(t){const e=Fp(t,"chain").trim();let i=`[${Fp(t,"rescode")}]${Fp(t,"resnum")}`;return e&&(i+=`:${e}`),i}function zp(t,e,i){void 0===t[e]?t[e]=i:t[e]|=i}function Vp(t,e){return null!==t&&t.value===e}function Gp(t,e,i){let r=0;const s=e.getElementsByTagName("clash");for(let e=0,i=s.length;e0&&(r+=1);e.getElementsByTagName("bond-outlier").length>0&&(r+=1);return e.getElementsByTagName("plane-outlier").length>0&&(r+=1),Vp(i.getNamedItem("rota"),"OUTLIER")&&(r+=1),Vp(i.getNamedItem("rama"),"OUTLIER")&&(r+=1),Vp(i.getNamedItem("RNApucker"),"outlier")&&(r+=1),r}ze.add("xml",Ep);class Up{constructor(t,e){this.name=t,this.path=e,this.rsrzDict={},this.rsccDict={},this.rciDict={},this.clashDict={},this.clashArray=[],this.geoDict={},this.geoAtomDict={},this.atomDict={},this.clashSele="NONE"}get type(){return"validation"}fromXml(t){De&&Me.time("Validation.fromXml");const e=this.rsrzDict,i=this.rsccDict,r=this.rciDict,s=this.clashDict,n=this.clashArray,o=this.geoDict,a=this.geoAtomDict,c=this.atomDict,l=t.getElementsByTagName("Entry");if(1===l.length){const t=l[0].getElementsByTagName("chemical_shift_list");if(1===t.length){const e=t[0].getElementsByTagName("random_coil_index");for(let t=0,i=e.length;t0&&(o[r]=t)}else{const t=e.getElementsByTagName("clash"),i=e.getElementsByTagName("mog-bond-outlier"),n=e.getElementsByTagName("mog-angle-outlier");if(i.length>0||n.length>0||t.length>0){const e={};a[r]=e;for(let i=0,r=t.length;i>>16&65535|0,o=0;0!==i;){i-=o=i>2e3?2e3:i;do{n=n+(s=s+e[r++]|0)|0}while(--o);s%=65521,n%=65521}return s|n<<16|0}ze.add("validation",class extends Ep{constructor(t,e){super(t,e||{}),this.useDomParser=!0,this.validation=new Up(this.name,this.path)}get __objName(){return"validation"}get isXml(){return!0}_parse(){super._parse(),De&&Me.time("ValidationParser._parse "+this.name),this.validation.fromXml(this.xml.data),De&&Me.timeEnd("ValidationParser._parse "+this.name)}});var qp=function(){for(var t,e=[],i=0;i<256;i++){t=i;for(var r=0;r<8;r++)t=1&t?3988292384^t>>>1:t>>>1;e[i]=t}return e}();function Xp(t,e,i,r){var s=qp,n=r+i;t^=-1;for(var o=r;o>>8^s[255&(t^e[o])];return-1^t}var Yp=30,Kp=12;function Zp(t,e){var i,r,s,n,o,a,c,l,h,d,u,m,p,f,g,y,b,x,v,w,A,_,S,C,P;i=t.state,r=t.next_in,C=t.input,s=r+(t.avail_in-5),n=t.next_out,P=t.output,o=n-(e-t.avail_out),a=n+(t.avail_out-257),c=i.dmax,l=i.wsize,h=i.whave,d=i.wnext,u=i.window,m=i.hold,p=i.bits,f=i.lencode,g=i.distcode,y=(1<>>=v=x>>>24,p-=v,0===(v=x>>>16&255))P[n++]=65535&x;else{if(!(16&v)){if(0==(64&v)){x=f[(65535&x)+(m&(1<>>=v,p-=v),p<15&&(m+=C[r++]<>>=v=x>>>24,p-=v,!(16&(v=x>>>16&255))){if(0==(64&v)){x=g[(65535&x)+(m&(1<c){t.msg="invalid distance too far back",i.mode=Yp;break t}if(m>>>=v,p-=v,A>(v=n-o)){if((v=A-v)>h&&i.sane){t.msg="invalid distance too far back",i.mode=Yp;break t}if(_=0,S=u,0===d){if(_+=l-v,v2;)P[n++]=S[_++],P[n++]=S[_++],P[n++]=S[_++],w-=3;w&&(P[n++]=S[_++],w>1&&(P[n++]=S[_++]))}else{_=n-A;do{P[n++]=P[_++],P[n++]=P[_++],P[n++]=P[_++],w-=3}while(w>2);w&&(P[n++]=P[_++],w>1&&(P[n++]=P[_++]))}break}}break}}while(r>3,m&=(1<<(p-=w<<3))-1,t.next_in=r,t.next_out=n,t.avail_in=r=1&&0===T[w];w--);if(A>w&&(A=w),0===w)return s[n++]=20971520,s[n++]=20971520,a.bits=1,0;for(v=1;v0&&(t===ef||1!==w))return-1;for(B[1]=0,b=1;bJp||t===sf&&P>tf)return 1;for(;;){p=b-S,o[x]m?(f=D[$+o[x]],g=k[M+o[x]]):(f=96,g=0),c=1<>S)+(l-=c)]=p<<24|f<<16|g|0}while(0!==l);for(c=1<>=1;if(0!==c?(I&=c-1,I+=c):I=0,x++,0==--T[b]){if(b===w)break;b=e[i+o[x]]}if(b>A&&(I&d)!==h){for(0===S&&(S=A),u+=v,C=1<<(_=b-S);_+SJp||t===sf&&P>tf)return 1;s[h=I&d]=A<<24|_<<16|u-n|0}}return 0!==I&&(s[u+I]=b-S<<24|64<<16|0),a.bits=A,0}var hf=1,df=2,uf=0,mf=-2,pf=1,ff=12,gf=30,yf=852,bf=592;function xf(t){return(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24)}function vf(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function wf(t){var e;return t&&t.state?((e=t.state).wsize=0,e.whave=0,e.wnext=0,function(t){var e;return t&&t.state?(e=t.state,t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=pf,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(yf),e.distcode=e.distdyn=new Int32Array(bf),e.sane=1,e.back=-1,uf):mf}(t)):mf}function Af(t,e){var i,r;return t?(r=new vf,t.state=r,r.window=null,i=function(t,e){var i,r;return t&&t.state?(r=t.state,e<0?(i=0,e=-e):(i=1+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?mf:(null!==r.window&&r.wbits!==e&&(r.window=null),r.wrap=i,r.wbits=e,wf(t))):mf}(t,e),i!==uf&&(t.state=null),i):mf}var _f,Sf,Cf=!0;function Pf(t){if(Cf){var e;for(_f=new Int32Array(512),Sf=new Int32Array(32),e=0;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(lf(hf,t.lens,0,288,_f,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;lf(df,t.lens,0,32,Sf,0,t.work,{bits:5}),Cf=!1}t.lencode=_f,t.lenbits=9,t.distcode=Sf,t.distbits=5}function If(t,e,i,r){var s,n=t.state;return null===n.window&&(n.wsize=1<=n.wsize?(Hp(n.window,e,i-n.wsize,n.wsize,0),n.wnext=0,n.whave=n.wsize):((s=n.wsize-n.wnext)>r&&(s=r),Hp(n.window,e,i-r,s,n.wnext),(r-=s)?(Hp(n.window,e,i-r,r,0),n.wnext=r,n.whave=n.wsize):(n.wnext+=s,n.wnext===n.wsize&&(n.wnext=0),n.whave>>8&255,i.check=Xp(i.check,I,2,0),l=0,h=0,i.mode=2;break}if(i.flags=0,i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&l)<<8)+(l>>8))%31){t.msg="incorrect header check",i.mode=gf;break}if(8!=(15&l)){t.msg="unknown compression method",i.mode=gf;break}if(h-=4,A=8+(15&(l>>>=4)),0===i.wbits)i.wbits=A;else if(A>i.wbits){t.msg="invalid window size",i.mode=gf;break}i.dmax=1<>8&1),512&i.flags&&(I[0]=255&l,I[1]=l>>>8&255,i.check=Xp(i.check,I,2,0)),l=0,h=0,i.mode=3;case 3:for(;h<32;){if(0===a)break t;a--,l+=r[n++]<>>8&255,I[2]=l>>>16&255,I[3]=l>>>24&255,i.check=Xp(i.check,I,4,0)),l=0,h=0,i.mode=4;case 4:for(;h<16;){if(0===a)break t;a--,l+=r[n++]<>8),512&i.flags&&(I[0]=255&l,I[1]=l>>>8&255,i.check=Xp(i.check,I,2,0)),l=0,h=0,i.mode=5;case 5:if(1024&i.flags){for(;h<16;){if(0===a)break t;a--,l+=r[n++]<>>8&255,i.check=Xp(i.check,I,2,0)),l=0,h=0}else i.head&&(i.head.extra=null);i.mode=6;case 6:if(1024&i.flags&&((m=i.length)>a&&(m=a),m&&(i.head&&(A=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Array(i.head.extra_len)),Hp(i.head.extra,r,n,m,A)),512&i.flags&&(i.check=Xp(i.check,r,m,n)),a-=m,n+=m,i.length-=m),i.length))break t;i.length=0,i.mode=7;case 7:if(2048&i.flags){if(0===a)break t;m=0;do{A=r[n+m++],i.head&&A&&i.length<65536&&(i.head.name+=String.fromCharCode(A))}while(A&&m>9&1,i.head.done=!0),t.adler=i.check=0,i.mode=ff;break;case 10:for(;h<32;){if(0===a)break t;a--,l+=r[n++]<>>=7&h,h-=7&h,i.mode=27;break}for(;h<3;){if(0===a)break t;a--,l+=r[n++]<>>=1)){case 0:i.mode=14;break;case 1:if(Pf(i),i.mode=20,6===e){l>>>=2,h-=2;break t}break;case 2:i.mode=17;break;case 3:t.msg="invalid block type",i.mode=gf}l>>>=2,h-=2;break;case 14:for(l>>>=7&h,h-=7&h;h<32;){if(0===a)break t;a--,l+=r[n++]<>>16^65535)){t.msg="invalid stored block lengths",i.mode=gf;break}if(i.length=65535&l,l=0,h=0,i.mode=15,6===e)break t;case 15:i.mode=16;case 16:if(m=i.length){if(m>a&&(m=a),m>c&&(m=c),0===m)break t;Hp(s,r,n,m,o),a-=m,n+=m,c-=m,o+=m,i.length-=m;break}i.mode=ff;break;case 17:for(;h<14;){if(0===a)break t;a--,l+=r[n++]<>>=5,h-=5,i.ndist=1+(31&l),l>>>=5,h-=5,i.ncode=4+(15&l),l>>>=4,h-=4,i.nlen>286||i.ndist>30){t.msg="too many length or distance symbols",i.mode=gf;break}i.have=0,i.mode=18;case 18:for(;i.have>>=3,h-=3}for(;i.have<19;)i.lens[k[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,S={bits:i.lenbits},_=lf(0,i.lens,0,19,i.lencode,0,i.work,S),i.lenbits=S.bits,_){t.msg="invalid code lengths set",i.mode=gf;break}i.have=0,i.mode=19;case 19:for(;i.have>>16&255,b=65535&P,!((g=P>>>24)<=h);){if(0===a)break t;a--,l+=r[n++]<>>=g,h-=g,i.lens[i.have++]=b;else{if(16===b){for(C=g+2;h>>=g,h-=g,0===i.have){t.msg="invalid bit length repeat",i.mode=gf;break}A=i.lens[i.have-1],m=3+(3&l),l>>>=2,h-=2}else if(17===b){for(C=g+3;h>>=g)),l>>>=3,h-=3}else{for(C=g+7;h>>=g)),l>>>=7,h-=7}if(i.have+m>i.nlen+i.ndist){t.msg="invalid bit length repeat",i.mode=gf;break}for(;m--;)i.lens[i.have++]=A}}if(i.mode===gf)break;if(0===i.lens[256]){t.msg="invalid code -- missing end-of-block",i.mode=gf;break}if(i.lenbits=9,S={bits:i.lenbits},_=lf(hf,i.lens,0,i.nlen,i.lencode,0,i.work,S),i.lenbits=S.bits,_){t.msg="invalid literal/lengths set",i.mode=gf;break}if(i.distbits=6,i.distcode=i.distdyn,S={bits:i.distbits},_=lf(df,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,S),i.distbits=S.bits,_){t.msg="invalid distances set",i.mode=gf;break}if(i.mode=20,6===e)break t;case 20:i.mode=21;case 21:if(a>=6&&c>=258){t.next_out=o,t.avail_out=c,t.next_in=n,t.avail_in=a,i.hold=l,i.bits=h,Zp(t,u),o=t.next_out,s=t.output,c=t.avail_out,n=t.next_in,r=t.input,a=t.avail_in,l=i.hold,h=i.bits,i.mode===ff&&(i.back=-1);break}for(i.back=0;y=(P=i.lencode[l&(1<>>16&255,b=65535&P,!((g=P>>>24)<=h);){if(0===a)break t;a--,l+=r[n++]<>x)])>>>16&255,b=65535&P,!(x+(g=P>>>24)<=h);){if(0===a)break t;a--,l+=r[n++]<>>=x,h-=x,i.back+=x}if(l>>>=g,h-=g,i.back+=g,i.length=b,0===y){i.mode=26;break}if(32&y){i.back=-1,i.mode=ff;break}if(64&y){t.msg="invalid literal/length code",i.mode=gf;break}i.extra=15&y,i.mode=22;case 22:if(i.extra){for(C=i.extra;h>>=i.extra,h-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=23;case 23:for(;y=(P=i.distcode[l&(1<>>16&255,b=65535&P,!((g=P>>>24)<=h);){if(0===a)break t;a--,l+=r[n++]<>x)])>>>16&255,b=65535&P,!(x+(g=P>>>24)<=h);){if(0===a)break t;a--,l+=r[n++]<>>=x,h-=x,i.back+=x}if(l>>>=g,h-=g,i.back+=g,64&y){t.msg="invalid distance code",i.mode=gf;break}i.offset=b,i.extra=15&y,i.mode=24;case 24:if(i.extra){for(C=i.extra;h>>=i.extra,h-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){t.msg="invalid distance too far back",i.mode=gf;break}i.mode=25;case 25:if(0===c)break t;if(m=u-c,i.offset>m){if((m=i.offset-m)>i.whave&&i.sane){t.msg="invalid distance too far back",i.mode=gf;break}m>i.wnext?(m-=i.wnext,p=i.wsize-m):p=i.wnext-m,m>i.length&&(m=i.length),f=i.window}else f=s,p=o-i.offset,m=i.length;m>c&&(m=c),c-=m,i.length-=m;do{s[o++]=f[p++]}while(--m);0===i.length&&(i.mode=21);break;case 26:if(0===c)break t;s[o++]=i.length,c--,i.mode=21;break;case 27:if(i.wrap){for(;h<32;){if(0===a)break t;a--,l|=r[n++]<=252?6:$f>=248?5:$f>=240?4:$f>=224?3:$f>=192?2:1;function Of(t){var e,i,r,s,n,o=t.length,a=0;for(s=0;s>>6,e[n++]=128|63&i):i<65536?(e[n++]=224|i>>>12,e[n++]=128|i>>>6&63,e[n++]=128|63&i):(e[n++]=240|i>>>18,e[n++]=128|i>>>12&63,e[n++]=128|i>>>6&63,e[n++]=128|63&i);return e}function Rf(t,e){var i,r,s,n,o=e||t.length,a=new Array(2*o);for(r=0,i=0;i4)a[r++]=65533,i+=n-1;else{for(s&=2===n?31:3===n?15:7;n>1&&i1?a[r++]=65533:s<65536?a[r++]=s:(s-=65536,a[r++]=55296|s>>10&1023,a[r++]=56320|1023&s)}return function(t,e){if(e<65537&&(t.subarray&&Bf||!t.subarray&&Tf))return String.fromCharCode.apply(null,jp(t,e));for(var i="",r=0;rt.length&&(e=t.length),i=e-1;i>=0&&128==(192&t[i]);)i--;return i<0||0===i?e:i+Df[t[i]]>e?i:e}Df[254]=Df[254]=1;var Ff=0,Lf={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"};function Nf(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}function zf(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var Vf=Object.prototype.toString;function Gf(t){if(!(this instanceof Gf))return new Gf(t);this.options=function(t){for(var e=Array.prototype.slice.call(arguments,1);e.length;){var i=e.shift();if(i){if("object"!=typeof i)throw new TypeError(i+"must be non-object");for(var r in i)i.hasOwnProperty(r)&&(t[r]=i[r])}}return t}({chunkSize:16384,windowBits:0,to:""},t||{});var e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&0==(15&e.windowBits)&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Nf,this.strm.avail_out=0;var i,r,s,n=Af(this.strm,e.windowBits);if(n!==Ff)throw new Error(Lf[n]);this.header=new zf,i=this.strm,r=this.header,i&&i.state&&(0==(2&(s=i.state).wrap)||(s.head=r,r.done=!1))}Gf.prototype.push=function(t,e){var i,r,s,n,o,a,c=this.strm,l=this.options.chunkSize,h=this.options.dictionary,d=!1;if(this.ended)return!1;r=e===~~e?e:!0===e?4:0,"string"==typeof t?c.input=function(t){for(var e=new Uint8Array(t.length),i=0,r=e.length;i0||0===c.avail_out)&&1!==i);return 1===i&&(r=4),4===r?(i=function(t){if(!t||!t.state)return mf;var e=t.state;return e.window&&(e.window=null),t.state=null,uf}(this.strm),this.onEnd(i),this.ended=!0,i===Ff):2!==r||(this.onEnd(Ff),c.avail_out=0,!0)},Gf.prototype.onData=function(t){this.chunks.push(t)},Gf.prototype.onEnd=function(t){t===Ff&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=function(t){var e,i,r,s,n,o;for(r=0,e=0,i=t.length;e({path:t,data:e.data})))}getUrl(t){const e=ri(t);return`${this.baseUrl}file/${e.path}${e.query}`}getCountUrl(t){const e=ri(t);return`${this.baseUrl}traj/numframes/${e.path}${e.query}`}getFrameUrl(t,e){const i=ri(t);return`${this.baseUrl}traj/frame/${e}/${i.path}${i.query}`}getFrameParams(t,e){return`atomIndices=${e.join(";")}`}getPathUrl(t,e){const i=ri(t);return`${this.baseUrl}traj/path/${e}/${i.path}${i.query}`}getExt(t){return ri(t).ext}}function eg(t,e){return{type:"integer",max:t,min:e}}function ig(t,e,i){return{type:"number",precision:t,max:e,min:i}}function rg(t,e,i){return{type:"range",step:t,max:e,min:i}}function sg(...t){return{type:"select",options:t.reduce(((t,e)=>Object.assign(Object.assign({},t),{[e]:e})),{})}}const ng={backgroundColor:{type:"color"},quality:sg("auto","low","medium","high"),sampleLevel:rg(1,5,-1),impostor:{type:"boolean"},workerDefault:{type:"boolean"},rotateSpeed:ig(1,10,0),zoomSpeed:ig(1,10,0),panSpeed:ig(1,10,0),clipNear:rg(1,100,0),clipFar:rg(1,100,0),clipDist:eg(200,0),clipMode:sg("scene","camera"),clipScale:sg("relative","absolute"),fogNear:rg(1,100,0),fogFar:rg(1,100,0),cameraType:sg("perspective","orthographic","stereo"),cameraEyeSep:ig(3,1,.01),cameraFov:rg(1,120,15),lightColor:{type:"color"},lightIntensity:ig(2,10,0),ambientColor:{type:"color"},ambientIntensity:ig(2,10,0),hoverTimeout:eg(1e4,-1),tooltip:{type:"boolean"},mousePreset:sg(...Object.keys(Zo))};const og="2.2.0";export{zh as AngleRepresentation,hu as ArrowBuffer,La as Assembly,ed as AxesRepresentation,rd as BackboneRepresentation,id as BallAndStickRepresentation,sd as BaseRepresentation,fu as BoxBuffer,Tc as BufferRepresentation,dd as CartoonRepresentation,hl as Collection,zt as Colormaker,Fe as ColormakerRegistry,ll as Component,$l as ComponentCollection,au as ConeBuffer,ud as ContactRepresentation,ui as Counter,td as CylinderBuffer,Le as DatasourceRegistry,De as Debug,Ge as DecompressorRegistry,gd as DihedralHistogramRepresentation,md as DihedralRepresentation,bd as DistanceRepresentation,wu as EllipsoidBuffer,pl as Frames,Ad as HelixorientRepresentation,Bd as HyperballRepresentation,$a as Kdtree,ta as KeyActions,$d as LabelRepresentation,tr as LeftMouseButton,_d as LicoriceRepresentation,Rd as LineRepresentation,We as ListingDatasource,tg as MdsrvDatasource,Te as MeasurementDefaultParams,Uo as MeshBuffer,er as MiddleMouseButton,zd as MolecularSurface,Vd as MolecularSurfaceRepresentation,Ko as MouseActions,Pu as OctahedronBuffer,ze as ParserRegistry,ai as PdbWriter,br as PickingProxy,Wc as PointBuffer,Gd as PointRepresentation,Nr as Queue,dl as RepresentationCollection,nl as RepresentationElement,Ne as RepresentationRegistry,Wd as RibbonRepresentation,ir as RightMouseButton,qd as RocketRepresentation,Xd as RopeRepresentation,Re as ScriptExtensions,ci as SdfWriter,pe as Selection,Mc as Shape,Ll as ShapeComponent,Yd as SpacefillRepresentation,Ts as SpatialHash,Gc as SphereBuffer,Fl as Stage,Jf as StaticDatasource,di as StlWriter,Cc as Structure,Tl as StructureComponent,Ml as StructureComponentDefaultParameters,Sh as StructureRepresentation,fl as Superposition,Bl as SurfaceComponent,Bu as TetrahedronBuffer,Eh as TextBuffer,Fu as TorusBuffer,Qd as TraceRepresentation,qe as TrajectoryDatasource,yl as TrajectoryPlayer,Jd as TubeRepresentation,ng as UIStageParameters,tu as UnitcellRepresentation,eu as ValidationRepresentation,og as Version,Ji as Viewer,Eo as Volume,Dl as VolumeComponent,Nh as WidelineBuffer,ni as autoLoad,ic as concatStructures,dt as download,at as flatten,si as getDataInfo,ri as getFileInfo,rt as getQuery,tc as guessElement,Oe as setDebug,Xe as setListingDatasource,Be as setMeasurementDefaultParams,Ye as setTrajectoryDatasource,kl as superpose,ut as throttle,gt as uniqueArray}; + */class ka{constructor(t,e){this.points=t,this.metric=e,this.maxDepth=0,this.currentNode=0;const i=t.length/3,r=new Uint32Array(i);for(let t=0;tthis.maxDepth&&(this.maxDepth=t);const s=r-i;if(0===s)return-1;const n=4*this.currentNode,o=this.nodes;if(this.currentNode+=1,1===s)return o[n]=i,o[n+1]=-1,o[n+2]=-1,o[n+3]=e,n;const a=this.indices,c=this.points,l=i+Math.floor(s/2),h=t%3;let d,u,m,p,f,g=i,y=r-1;for(;y>g;){for(m=g+y>>1,p=c[3*a[m]+h],u=a[m],a[m]=a[y],a[y]=u,f=g,d=g;d-t[1])),s=this.nodes,n=this.points,o=this.indices,a=c=>{let l,h;const d=this.getNodeDepth(c)%3,u=3*o[s[c]],m=[n[u+0],n[u+1],n[u+2]],p=this.metric(t,m);function f(t,i){r.push([t,i]),r.size()>e&&r.pop()}const g=s[c+1],y=s[c+2];if(-1===y&&-1===g)return void((r.size()n[3*o[s[t]]+r])throw new Error("left child is > parent!");i+=this.verify(a,e+1)}if(-1!==c){if(n[3*o[s[c]]+r]0}isBackbone(){const t=this.residueType.backboneIndexList;return t.length>0&&t.includes(this.index-this.residueAtomOffset)}isPolymer(){if(this.structure.entityList.length>0)return this.entity.isPolymer();{const t=this.residueType.moleculeType;return 3===t||4===t||5===t}}isSidechain(){return this.isPolymer()&&!this.isBackbone()}isCg(){const t=this.residueType.backboneType;return 4===t||5===t||6===t}isTrace(){return this.index===this.residueType.traceAtomIndex+this.residueAtomOffset}isHetero(){return 1===this.residueType.hetero}isProtein(){return 3===this.residueType.moleculeType}isNucleic(){const t=this.residueType.moleculeType;return 4===t||5===t}isRna(){return 4===this.residueType.moleculeType}isDna(){return 5===this.residueType.moleculeType}isWater(){return 1===this.residueType.moleculeType}isIon(){return 2===this.residueType.moleculeType}isSaccharide(){return 6===this.residueType.moleculeType}isHelix(){return Hs.includes(this.sstruc)}isSheet(){return Ws.includes(this.sstruc)}isTurn(){return qs.includes(this.sstruc)&&this.isProtein()}isBonded(){return 0!==this.bondHash.countArray[this.index]}isRing(){return void 0!==this.residueType.getRings().atomRings[this.index-this.residueAtomOffset]}isAromatic(){return 1===this.aromatic}isPolarHydrogen(){let t=!1;return 1!==this.number||(t=!this.hasBondToElement(6)),t}isMetal(){return this.atomType.isMetal()}isNonmetal(){return this.atomType.isNonmetal()}isMetalloid(){return this.atomType.isMetalloid()}isHalogen(){return this.atomType.isHalogen()}isDiatomicNonmetal(){return this.atomType.isDiatomicNonmetal()}isPolyatomicNonmetal(){return this.atomType.isPolyatomicNonmetal()}isAlkaliMetal(){return this.atomType.isAlkaliMetal()}isAlkalineEarthMetal(){return this.atomType.isAlkalineEarthMetal()}isNobleGas(){return this.atomType.isNobleGas()}isTransitionMetal(){return this.atomType.isTransitionMetal()}isPostTransitionMetal(){return this.atomType.isPostTransitionMetal()}isLanthanide(){return this.atomType.isLanthanide()}isActinide(){return this.atomType.isActinide()}getDefaultValence(){return this.atomType.getDefaultValence()}getValenceList(){return this.atomType.getValenceList()}getOuterShellElectronCount(){return this.atomType.getOuterShellElectronCount()}distanceTo(t){const e=this.atomStore,i=t.atomStore,r=this.index,s=t.index,n=e.x[r]-i.x[s],o=e.y[r]-i.y[s],a=e.z[r]-i.z[s],c=n*n+o*o+a*a;return Math.sqrt(c)}connectedTo(t){const e=this.atomStore,i=t.atomStore,r=this.index,s=t.index;if(e.altloc&&i.altloc){const t=e.altloc[r],n=i.altloc[s];if(0!==t&&0!==n&&32!==t&&32!==n&&t!==n)return!1}const n=e.x[r]-i.x[s],o=e.y[r]-i.y[s],a=e.z[r]-i.z[s],c=n*n+o*o+a*a;if(c<48&&this.isCg())return!0;if(isNaN(c))return!1;const l=this.covalent+t.covalent,h=l+.3,d=l-.5;return cd*d}positionFromArray(t,e=0){return this.x=t[e+0],this.y=t[e+1],this.z=t[e+2],this}positionToArray(t=[],e=0){const i=this.index,r=this.atomStore;return t[e+0]=r.x[i],t[e+1]=r.y[i],t[e+2]=r.z[i],t}positionToVector3(t){return void 0===t&&(t=new e),t.x=this.x,t.y=this.y,t.z=this.z,t}positionFromVector3(t){return this.x=t.x,this.y=t.y,this.z=t.z,this}positionAdd(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this}positionSub(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this}getResidueBonds(t=!1){const e=this.residueAtomOffset,i=this.index-this.residueAtomOffset,r=this.residueType.getBonds(),s=r.atomIndices1,n=r.atomIndices2;let o,a,c,l;for(t||(l=[]),o=s.indexOf(i);-1!==o;){if(c=n[o]+e,!l)return c;l.push(c),o=s.indexOf(i,o+1)}for(a=n.indexOf(i);-1!==a;){if(c=s[a]+e,!l)return c;l.push(c),a=n.indexOf(i,a+1)}return l}qualifiedName(t=!1){var e="";return this.resname&&!t&&(e+="["+this.resname+"]"),void 0!==this.resno&&(e+=this.resno),this.inscode&&(e+="^"+this.inscode),this.chainname&&(e+=":"+this.chainname),this.atomname&&(e+="."+this.atomname),this.altloc&&(e+="%"+this.altloc),this.structure.modelStore.count>1&&(e+="/"+this.modelIndex),e}clone(){return new Ma(this.structure,this.index)}toObject(){return{index:this.index,residueIndex:this.residueIndex,resname:this.resname,x:this.x,y:this.y,z:this.z,element:this.element,chainname:this.chainname,resno:this.resno,serial:this.serial,vdw:this.vdw,covalent:this.covalent,hetero:this.hetero,bfactor:this.bfactor,altloc:this.altloc,atomname:this.atomname,modelIndex:this.modelIndex}}}function Ta(t,e){const i=t[0]-e[0],r=t[1]-e[1],s=t[2]-e[2];return i*i+r*r+s*s}function Ba(t,e){return Math.sqrt(Ta(t,e))}const Da=new Float32Array(3);class $a{constructor(t,e=!1){De&&Me.time("Kdtree build");const i=e?Ta:Ba,r=new Float32Array(3*t.atomCount),s=new Uint32Array(t.atomCount);let n=0;t.eachAtom((function(t){r[n+0]=t.x,r[n+1]=t.y,r[n+2]=t.z,s[n/3]=t.index,n+=3})),this.atomIndices=s,this.points=r,this.kdtree=new ka(r,i),De&&Me.timeEnd("Kdtree build")}nearest(t,i,r){t instanceof e?t.toArray(Da):t instanceof Ma&&t.positionToArray(Da);const s=this.kdtree.nearest(Da,i,r),n=this.kdtree.indices,o=this.kdtree.nodes,a=this.atomIndices,c=[];for(let t=0,e=s.length;t":"3/4-Z","?":"X-Y","@":"Y-X",A:"Z+1/3",B:"Z+2/3",C:"X+2/3",D:"Y+1/3",E:"-Y+2/3",F:"X-Y+1/3",G:"Y-X+2/3",H:"-X+1/3",I:"X+1/3",J:"Y+2/3",K:"-Y+1/3",L:"X-Y+2/3",M:"Y-X+1/3",N:"-X+2/3",O:"2/3+X",P:"1/3+Y",Q:"1/3+Z",R:"2/3-Y",S:"1/3+X-Y",T:"2/3+Y-X",U:"1/3-X",V:"2/3-X",W:"1/3-Y",X:"1/3-Z",Y:"2/3+Y",Z:"1/3+Y-X","[":"2/3+X-Y","]":"1/3+X","^":"2/3+Z",_:"2/3-Z","`":"5/6+Z",a:"1/6+Z",b:"5/6-Z",c:"1/6-Z",d:"Z+5/6",e:"Z+1/6",f:"Z+1/4",g:"+Y"},Ra={"P 1":" !#","P -1":" !#$%&","P 1 2 1":" !#$!&","P 1 21 1":" !#$'&","C 1 2 1":" !#$!&()#*)&","P 1 m 1":" !# %#","P 1 c 1":" !# %+","C 1 m 1":" !# %#()#(,#","C 1 c 1":" !# %+()#(,+","P 1 2/m 1":" !# %#$!&$%&","P 1 21/m 1":" !#$)&$%& ,#","C 1 2/m 1":" !# %#$!&$%&()#(,#*)&*,&","P 1 2/c 1":" !#$!-$%& %+","P 1 21/c 1":" !#$%&$)- ,+","C 1 2/c 1":" !#$!-$%& %+()#*)-*,&(,+","P 2 2 2":" !#$%#$!& %&","P 2 2 21":" !#$%+$!- %&","P 21 21 2":" !#$%#*)&(,&","P 21 21 21":" !#*%+$)-(,&","C 2 2 21":" !#$%+$!- %&()#*,+*)-(,&","C 2 2 2":" !#$%#$!& %&()#*,#*)&(,&","F 2 2 2":" !#$%#$!& %& )+$,+$)- ,-(!+*%+*!-(%-()#*,#*)&(,&","I 2 2 2":" !#$%# %&$!&.'/01/.120'2","I 21 21 21":" !#*%+$)-(,&()+$,#*!& %-","P m m 2":" !#$%# %#$!#","P m c 21":" !#$%+ %+$!#","P c c 2":" !#$%# %+$!+","P m a 2":" !#$%#(%#*!#","P c a 21":" !#$%+(%#*!+","P n c 2":" !#$%# ,+$)+","P m n 21":" !#*%+(%+$!#","P b a 2":" !#$%#(,#*)#","P n a 21":" !#$%+(,#*)+","P n n 2":" !#$%#(,+*)+","C m m 2":" !#$%# %#$!#()#*,#(,#*)#","C m c 21":" !#$%+ %+$!#()#*,+(,+*)#","C c c 2":" !#$%# %+$!+()#*,#(,+*)+","A m m 2":" !#$%# %#$!# )+$,+ ,+$)+","A b m 2":" !#$%# ,#$)# )+$,+ %+$!+","A m a 2":" !#$%#(%#*!# )+$,+(,+*)+","A b a 2":" !#$%#(,#*)# )+$,+(%+*!+","F m m 2":" !#$%# %#$!# )+$,+ ,+$)+(!+*%+(%+*!+()#*,#(,#*)#","F d d 2":" !#$%#345675 )+$,+3896:9(!+*%+;49<79()#*,#;85<:5","I m m 2":" !#$%# %#$!#()+*,+(,+*)+","I b a 2":" !#$%#(,#*)#()+*,+ %+$!+","I m a 2":" !#$%#(%#*!#()+*,+ ,+$)+","P 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!#","P 2/n 2/n 2/n":" !#$%#$!& %&*,-()-(,+*)+","P 2/c 2/c 2/m":" !#$%#$!- %-$%& !& %+$!+","P 2/b 2/a 2/n":" !#$%#$!& %&*,&()&(,#*)#","P 21/m 2/m 2/a":" !#*%#$!&(%&$%&(!& %#*!#","P 2/n 21/n 2/a":" !#*%#*)- ,-$%&(!&(,+$)+","P 2/m 2/n 21/a":" !#*%+*!- %&$%&(!-(%+$!#","P 21/c 2/c 2/a":" !#*%#$!-(%-$%&(!& %+*!+","P 21/b 21/a 2/m":" !#$%#*)&(,&$%& !&(,#*)#","P 21/c 21/c 2/n":" !#*,#$)-(%-$%&()& ,+*!+","P 2/b 21/c 21/m":" !#$%+$)- ,&$%& !- ,+$)#","P 21/n 21/n 2/m":" !#$%#*)-(,-$%& !&(,+*)+","P 21/m 21/m 2/n":" !#$%#*'&.,&*,&.'& %#$!#","P 21/b 2/c 21/n":" !#*,+$!-(,&$%&()- %+*)#","P 21/b 21/c 21/a":" !#*%+$)-(,&$%&(!- ,+*)#","P 21/n 21/m 21/a":" !#0%/$'&.12$%&.!2 1#0'/","C 2/m 2/c 21/m":" !#$%+$!- %&$%& !- %+$!#()#*,+*)-(,&*,&()-(,+*)#","C 2/m 2/c 21/a":" !#$,+$)- %&$%& )- ,+$!#()#*%+*!-(,&*,&(!-(%+*)#","C 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!#()#*,#*)&(,&*,&()&(,#*)#","C 2/c 2/c 2/m":" !#$%#$!- %-$%& !& %+$!+()#*,#*)-(,-*,&()&(,+*)+","C 2/m 2/m 2/a":" !#$,#$)& %&$%& )& ,#$!#()#*%#*!&(,&*,&(!&(%#*)#","C 2/c 2/c 2/a":" !#*,#$!&(,&$,-(!- ,+*!+()#$%#*)& %&*%- )-(%+$)+","F 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!# )+$,+$)- ,-$,- )- ,+$)+(!+*%+*!-(%-*%-(!-(%+*!+()#*,#*)&(,&*,&()&(,#*)#","F 2/d 2/d 2/d":" !#$%#$!& %&64=37=345675 )+$,+$)- ,-68>3:>3896:9(!+*%+*!-(%-<4>;7>;49<79()#*,#*)&(,&<8=;:=;85<:5","I 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!#()+*,+*)-(,-*,-()-(,+*)+","I 2/b 2/a 2/m":" !#$%#*)&(,&$%& !&(,#*)#()+*,+$!- %-*,-()- %+$!+","I 21/b 21/c 21/a":" !#*%+$)-(,&$%&(!- ,+*)#()+$,#*!& %-*,- )&(%#$!+","I 21/m 21/m 21/a":" !#$,#$)& %&$%& )& ,#$!#()+*%+*!-(,-*,-(!-(%+*)+","P 4":" !#$%#% #!$#","P 41":" !#$%+% 5!$9","P 42":" !#$%#% +!$+","P 43":" !#$%+% 9!$5","I 4":" !#$%#% #!$#()+*,+,(+)*+","I 41":" !#*,+%(5)$9()+$%#, 9!*5","P -4":" !#$%#!$&% &","I -4":" !#$%#!$&% &()+*,+)*-,(-","P 4/m":" !#$%#% #!$#$%& !&!$&% &","P 42/m":" !#$%#% +!$+$%& !&!$-% -","P 4/n":" !#$%#,(#)*#*,&()&!$&% &","P 42/n":" !#$%#,(+)*+*,-()-!$&% &","I 4/m":" !#$%#% #!$#$%& !&!$&% &()+*,+,(+)*+*,-()-)*-,(-","I 41/a":" !#*,+%(5)$9$,=(!>!$&,(-()+$%#, 9!*5*%> )=)*-% &","P 4 2 2":" !#$%#% #!$#$!& %&! &%$&","P 4 21 2":" !#$%#,(#)*#*)&(,&! &%$&","P 41 2 2":" !#$%+% 5!$9$!& %-! >%$=","P 41 21 2":" !#$%+,(5)*9*)=(,>! &%$-","P 42 2 2":" !#$%#% +!$+$!& %&! -%$-","P 42 21 2":" !#$%#,(+)*+*)-(,-! &%$&","P 43 2 2":" !#$%+% 9!$5$!& %-! =%$>","P 43 21 2":" !#$%+,(9)*5*)>(,=! &%$-","I 4 2 2":" !#$%#% #!$#$!& %&! &%$&()+*,+,(+)*+*)-(,-)(-,*-","I 41 2 2":" !#*,+%(5)$9*!> ,=)(-%$&()+$%#, 9!*5$)=(%>! &,*-","P 4 m m":" !#$%#% #!$# %#$!#%$#! #","P 4 b m":" !#$%#% #!$#(,#*)#,*#)(#","P 42 c m":" !#$%#% +!$+ %+$!+%$#! #","P 42 n m":" !#$%#,(+)*+(,+*)+%$#! #","P 4 c c":" !#$%#% #!$# %+$!+%$+! +","P 4 n c":" !#$%#% #!$#(,+*)+,*+)(+","P 42 m c":" !#$%#% +!$+ %#$!#%$+! +","P 42 b c":" !#$%#% +!$+(,#*)#,*+)(+","I 4 m m":" !#$%#% #!$# %#$!#%$#! #()+*,+,(+)*+(,+*)+,*+)(+","I 4 c m":" !#$%#% #!$# %+$!+%$+! +()+*,+,(+)*+(,#*)#,*#)(#","I 41 m d":" !#*,+%(5)$9 %#*)+%*5) 9()+$%#, 9!*5(,+$!#,$9!(5","I 41 c d":" !#*,+%(5)$9 %+*)#%*9) 5()+$%#, 9!*5(,#$!+,$5!(9","P -4 2 m":" !#$%#% &!$&$!& %&%$#! #","P -4 2 c":" !#$%#% &!$&$!- %-%$+! +","P -4 21 m":" !#$%#% &!$&*)&(,&,*#)(#","P -4 21 c":" !#$%#% &!$&*)-(,-,*+)(+","P -4 m 2":" !#$%#!$&% & %#$!#! &%$&","P -4 c 2":" !#$%#% &!$& %+$!+! -%$-","P -4 b 2":" !#$%#% &!$&(,#*)#)(&,*&","P -4 n 2":" !#$%#% &!$&(,+*)+)(-,*-","I -4 m 2":" !#$%#% &!$& %#$!#! &%$&()+*,+,(-)*-(,+*)+)(-,*-","I -4 c 2":" !#$%#% &!$& %+$!+! -%$-()+*,+,(-)*-(,#*)#)(&,*&","I -4 2 m":" !#$%#% &!$&$!& %&%$#! #()+*,+,(-)*-*)-(,-,*+)(+","I -4 2 d":" !#$%#% &!$&*!>(%>,$9) 9()+*,+,(-)*-$)= ,=%*5!(5","P 4/m 2/m 2/m":" !#$%#% #!$#$!& %&! &%$&$%& !&!$&% & %#$!#%$#! #","P 4/m 2/c 2/c":" !#$%#% #!$#$!- %-! -%$-$%& !&!$&% & %+$!+%$+! +","P 4/n 2/b 2/m":" !#$%#% #!$#$!& %&! &%$&*,&()&)*&,(&(,#*)#,*#)(#","P 4/n 2/n 2/c":" !#$%#% #!$#$!& %&! &%$&*,-()-)*-,(-(,+*)+,*+)(+","P 4/m 21/b 2/m":" !#$%#% #!$#*)&(,&)(&,*&$%& !&!$&% &(,#*)#,*#)(#","P 4/m 21/n 2/c":" !#$%#% #!$#*)-(,-)(-,*-$%& !&!$&% &(,+*)+,*+)(+","P 4/n 21/m 2/m":" !#$%#,(#)*#*)&(,&! &%$&*,&()&!$&% & %#$!#,*#)(#","P 4/n 2/c 2/c":" !#$%#,(#)*#*)-(,-! -%$-*,&()&!$&% & %+$!+,*+)(+","P 42/m 2/m 2/c":" !#$%#% +!$+$!& %&! -%$-$%& !&!$-% - %#$!#%$+! +","P 42/m 2/c 2/m":" !#$%#% +!$+$!- %-! &%$&$%& !&!$-% - %+$!+%$#! #","P 42/n 2/b 2/c":" !#$%#,(+)*+$!- %-)(&,*&*,-()-!$&% &(,#*)#%$+! +","P 42/n 2/n 2/m":" !#$%#,(+)*+$!& %&)(-,*-*,-()-!$&% &(,+*)+%$#! #","P 42/m 21/b 2/c":" !#$%#% +!$+*)&(,&)(-,*-$%& !&!$-% -(,#*)#,*+)(+","P 42/m 21/n 2/m":" !#$%#,./'*/*'-.,-! &%$&$%& !&'*-,.-.,/*'/%$#! #","P 42/n 21/m 2/c":" !#$%#,(+)*+*)-(,-! &%$&*,-()-!$&% & %#$!#,*+)(+","P 42/n 21/c 2/m":" !#$%#,(+)*+*)&(,&! -%$-*,-()-!$&% & %+$!+,*#)(#","I 4/m 2/m 2/m":" !#$%#% #!$#$!& %&! &%$&$%& !&!$&% & %#$!#%$#! #()+*,+,(+)*+*)-(,-)(-,*-*,-()-)*-,(-(,+*)+,*+)(+","I 4/m 2/c 2/m":" !#$%#% #!$#$!- %-! -%$-$%& !&!$&% & %+$!+%$+! +()+*,+,(+)*+*)&(,&)(&,*&*,-()-)*-,(-(,#*)#,*#)(#","I 41/a 2/m 2/d":" !#*,+%(5)$9*!> ,=)(-%$&$,=(!>!$&,(-(,+$!#,$9!(5()+$%#, 9!*5$)=(%>! &,*-*%> )=)*-% & %#*)+%*5) 9","I 41/a 2/c 2/d":" !#*,+%(5)$9*!= ,>)(&%$-$,=(!>!$&,(-(,#$!+,$5!(9()+$%#, 9!*5$)>(%=! -,*&*%> )=)*-% & %+*)#%*9) 5","P 3":" !#%?#@$#","P 31":" !#%?A@$B","P 32":" !#%?B@$A","H 3":" !#%?#@$#CDAEFAGHAIJBKLBMNB","R 3":" !## !!# ","P -3":" !#%?#@$#$%&!@&? &","H -3":" !#%?#@$#$%&!@&? &OPQRSQTUQVWXYZX[]X]Y^W[^ZV^UR_PT_SO_","R -3":" !## !!# $%&&$%%&$","P 3 1 2":" !#%?#@$#%$&@!& ?&","P 3 2 1":" !#%?#@$#! &?%&$@&","P 31 1 2":" !#%?Q@$^%$_@!X ?&","P 31 2 1":" !#%?A@$B! &?%_$@X","P 32 1 2":" !#%?^@$Q%$X@!_ ?&","P 32 2 1":" !#%?B@$A! &?%X$@_","H 3 2":" !#%?#@$#! &?%&$@&OPQRSQTUQY]X[WXVZX]Y^W[^ZV^PO_SR_UT_","R 3 2":" !## !!# %$&$&%&%$","P 3 m 1":" !#%?#@$#%$#@!# ?#","P 3 1 m":" !#%?#@$#! #?%#$@#","P 3 c 1":" !#%?#@$#%$+@!+ ?+","P 3 1 c":" !#%?#@$#! +?%+$@+","H 3 m":" !#%?#@$#%$#@!# ?#OPQRSQTUQRUQTPQOSQ]Y^W[^ZV^WV^ZY^][^","R 3 m":" !## !!# ! # #!#! ","H 3 c":" !#%?#@$#%$+@!+ ?+OPQRSQTUQRU`TP`OS`]Y^W[^ZV^WVaZYa][a","R 3 c":" !## !!# '././'/'.","P -3 1 2/m":" !#%?#@$#%$&@!& ?&$%&!@&? &! #?%#$@#","P -3 1 2/c":" !#%?#@$#%$-@!- ?-$%&!@&? &! +?%+$@+","P -3 2/m 1":" !#%?#@$#! &?%&$@&$%&!@&? &%$#@!# ?#","P -3 2/c 1":" !#%?#@$#! -?%-$@-$%&!@&? &%$+@!+ ?+","H -3 2/m":" !#%?#@$#! &?%&$@&$%&!@&? &%$#@!# ?#OPQRSQTUQY]X[WXVZXVWXYZX[]XRUQTPQOSQ]Y^W[^ZV^PO_SR_UT_UR_PT_SO_WV^ZY^][^","R -3 2/m":" !## !!# %$&$&%&%$$%&&$%%&$! # #!#! ","H -3 2/c":" !#%?#@$#! -?%-$@-$%&!@&? &%$+@!+ ?+OPQRSQTUQY]b[WbVZbVWXYZX[]XRU`TP`OS`]Y^W[^ZV^POcSRcUTcUR_PT_SO_WVaZYa][a","R -3 2/c":" !## !!# 102021210$%&&$%%&$'././'/'.","P 6":" !#%?#@$#$%#!@#? #","P 61":" !#%?A@$B$%/!@d? e","P 65":" !#%?B@$A$%/!@e? d","P 62":" !#%?^@$Q$%#!@^? Q","P 64":" !#%?Q@$^$%#!@Q? ^","P 63":" !#%?#@$#$%+!@+? +","P -6":" !#%?#@$# !&%?&@$&","P 6/m":" !#%?#@$#$%#!@#? #$%&!@&? & !&%?&@$&","P 63/m":" !#%?#@$#$%+!@+? +$%&!@&? & !-%?-@$-","P 6 2 2":" !#%?#@$#$%#!@#? #! &?%&$@&%$&@!& ?&","P 61 2 2":" !#%?Q@$^$%+!@`? a! X?%&$@_%$b@!- ?c","P 65 2 2":" !#%?^@$Q$%+!@a? `! _?%&$@X%$c@!- ?b","P 62 2 2":" !#%?^@$Q$%#!@^? Q! _?%&$@X%$_@!& ?X","P 64 2 2":" !#%?Q@$^$%#!@Q? ^! X?%&$@_%$X@!& ?_","P 63 2 2":" !#%?#@$#$%+!@+? +! &?%&$@&%$-@!- ?-","P 6 m m":" !#%?#@$#$%#!@#? #%$#@!# ?#! #?%#$@#","P 6 c c":" !#%?#@$#$%#!@#? #%$+@!+ ?+! +?%+$@+","P 63 c m":" !#%?#@$#$%+!@+? +%$+@!+ ?+! #?%#$@#","P 63 m c":" !#%?#@$#$%+!@+? +%$#@!# ?#! +?%+$@+","P -6 m 2":" !#%?#@$# !&%?&@$&%$#@!# ?#%$&@!& ?&","P -6 c 2":" !#%?#@$# !-%?-@$-%$+@!+ ?+%$&@!& ?&","P -6 2 m":" !#%?#@$# !&%?&@$&! &?%&$@&! #?%#$@#","P -6 2 c":" !#%?#@$# !-%?-@$-! &?%&$@&! +?%+$@+","P 6/m 2/m 2/m":" !#%?#@$#$%#!@#? #! &?%&$@&%$&@!& ?&$%&!@&? & !&@$&%?&%$#@!# ?#! #?%#$@#","P 6/m 2/c 2/c":" !#%?#@$#$%#!@#? #! -?%-$@-%$-@!- ?-$%&!@&? & !&@$&%?&%$+@!+ ?+! +?%+$@+","P 63/m 2/c 2/m":" !#%?#@$#$%+!@+? +! -?%-$@-%$&@!& ?&$%&!@&? & !-@$-%?-%$+@!+ ?+! #?%#$@#","P 63/m 2/m 2/c":" !#%?#@$#$%+!@+? +! &?%&$@&%$-@!- ?-$%&!@&? & !-@$-%?-%$#@!# ?#! +?%+$@+","P 2 3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ","F 2 3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ","I 2 3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-(","P 21 3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(","I 21 3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- ","P 2/m -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$","P 2/n -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& *,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*","F 2/m -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$ )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-($,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(*%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- *,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$","F 2/d -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& 64=37=345675=64=375345674=67=3453756 )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(68>3:>3896:9=<8=;:5;85<:4><7>;49;79<(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(<4>;7>;49<79>68>3:93896:8=<:=;85;:5<()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- <8=;:=;8f<:f><4>;79;49<78>6:>3893:96","I 2/m -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-(*,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*","P 21/a -3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&($%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*","I 21/a -3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&($%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*()+$,#*g& %-+()#$,&*!- %)+(,#$!&*%- *,- )&(%#$!+-*,& )#(%+$!,-*)& %#(!+$","P 4 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$","P 42 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*","F 4 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$ )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(-%*-!*+%(+ +,$+)$-, -)#)*#,(&)(&,*(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() -,$-)$+, +(#,*#)*&,(&)+!*+%(-!(-%*()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(&,*&)*#,(#(+%*+!*-%(-!+)$+, -) -,$","F 41 3 2":" !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=46 )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<(!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>86","I 4 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*","P 43 3 2":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(7;>46=:<5839398<5:6=4;>75:<983>7;=46","P 41 3 2":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<","I 41 3 2":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- 7;>46=:<5839398<5:6=4;>75:<983>7;=46","P -4 3 m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% ","F -4 3 m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(+%*+!*-%(- +)$+,$-) -,#)(#,*&)*&,((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() +,$+)$-, -(#)*#,*&)(&,+!(+%*-!*-%(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(#,*#)*&,(&(+!*+%*-!(-%+) +,$-)$-, ","I -4 3 m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,(","P -4 3 n":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,(","F -4 3 c":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,( )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-() #,$#)$&, &(#!*#%*&!(&%+! +%$-!$-% (!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(!(#%*#!*&%(& +!$+%$-! -%#) #,$&)$&, ()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ! +%$+!$-% - #)$#,$&) &,#!(#%*&!*&%(","I -4 3 d":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(7354<9:6>8;=357<946>:;=857394<>:6=8;()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- :;98657<=43>;9:658<=73>49:;586=7<>43","P 4/m -3 2/m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ","P 4/n -3 2/n":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$*,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(","P 42/m -3 2/n":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(","P 42/n -3 2/m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,**,-()-(,+*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(!+*%-*!-(%)+ ,+$)-$,- ! -%$-!$+% + #,$#)$&, &)#!*#%(&!(&%**,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$%$+! +% -!$-$&) &, #)$#,&%(&!*#%*#!(","F 41/d -3 2/m":" !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=4664=3:>;85<79=64>3:5;89<74=6:>385;79<,$+! #%(-)*&*&)(-% #!$+,-%(&)*+,$#! )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<68>37=;49<:5=<8>;753496:4><:=;893756,*#!(+% &)$-*-!(&, +)$#%-, &!$+%*#)((!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<<4>;:=389675>68=379;45<:8=<7>;453:96%$#) +,(&!*-$&! -,(#)*+%&% -)$#,*+!(()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>86<8=;7>3456:9><4=;:9385678>67=349;:5<%*+)(#, -!$&$-) &%(+!*#,&,(-!*#%$+) ","F 41/d -3 2/c":" !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=46<8>;7=3496:5><8=;793456:8><7=;493:56%*#)(+, &!$-$-! &,(+)*#%&, -!$#%*+)( )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<<4=;:>385679>64=3:9;85<78=67>345;:9<%$+) #,(-!*&$&) -%(#!*+,&%(-)*#,$+! (!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<68=37>;45<:9=<4>;:5389674>6:=389;75<,*+!(#% -)$&*-)(&% +!$#,-,(&!*+%$#) ()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>8664>3:=;89<75=68>375;49<:4=<:>;853796,$#! +%(&)*-*&!(-, #)$+%-% &)$+,*#!(","I 4/m -3 2/m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,**,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(","I 41/a -3 2/d":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<$%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*4<97358;=:6>6>:;=8357<94=8;>:694<573()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- 7;>46=:<5839398<5:6=4;>75:<983>7;=46*,- )&(%#$!+-*,& )#(%+$!,-*)& %#(!+$865:;943>7<=<=73>4;9:658>43=7<5869:;","P 1 1 2":" !#$%#","P 1 1 21":" !#$%+","B 1 1 2":" !#$%#(g+*%+","A 1 2 1":" !#$!& )+$)-","C 1 21 1":" !#$)&()#*!&","I 1 2 1":" !#$!&.'/0'2","I 1 21 1":" !#$)&.'/0!-","P 1 1 m":" !# !&","P 1 1 b":" !# )&","B 1 1 m":" !# !&(!+(!-","B 1 1 b":" !# )&(!+()-","P 1 1 2/m":" !# !&$%#$%&","P 1 1 21/m":" !#$%+$%& !-","B 1 1 2/m":" !# !&$%#$%&(!+(!-*%+*%-","P 1 1 2/b":" !#$,#$%& )&","P 1 1 21/b":" !#$%&$,+ )-","B 1 1 2/b":" !#$,#$%& )&(!+*,+*%-()-","P 21 2 2":" !#$!&(%&*%#","P 2 21 2":" !# ,&$)&$%#","P 21 21 2 (a)":" !#*,#.%&$'&","P 21 2 21":" !#$!&(%-*%+","P 2 21 21":" !# %&$)-$,+","C 2 2 21a)":" !#*%+(,&$)-()#$,+ %&*!-","C 2 2 2a":" !#*,#.%&$'&()#$%# ,&*!&","F 2 2 2a":" !#*,#.%&$'& '/*%/.12$!2.!/$,/ %20'2.'#$%# 1&0!&","I 2 2 2a":" !#*,#.%&$'&()+$%+*!- ,-","P 21/m 21/m 2/n a":" !#*,#$)&(%&$%&.'& ,#*!#","P 42 21 2a":" !#*,#%.+'$+$'&.%&! -,*-","I 2 3a":" !#*,#.%&$'&!# ,- '&$%/$# !-*!/$%&.%()+$%+ ,-*!-)+(%&(!-*,#*+()&$)#*,- ,"},Ea=/^[1-9]$/;function Fa(t){let e="";return t.length>0&&(e=":"+gt(t).join(" OR :")),new pe(e)}class La{constructor(t=""){this.name=t,this.partList=[]}get type(){return"Assembly"}addPart(t,e){const i=new Na(t,e);return this.partList.push(i),i}getAtomCount(t){return this.partList.reduce(((e,i)=>e+i.getAtomCount(t)),0)}getResidueCount(t){return this.partList.reduce(((e,i)=>e+i.getResidueCount(t)),0)}getInstanceCount(){let t=0;return this.partList.forEach((function(e){t+=e.matrixList.length})),t}isIdentity(t){if(1!==this.partList.length)return!1;const e=this.partList[0];if(1!==e.matrixList.length)return!1;if(!(new i).equals(e.matrixList[0]))return!1;let r=[];return t.eachChain((function(t){r.push(t.chainname)})),r=gt(r),e.chainList.length===r.length}getBoundingBox(t){const e=new a;return this.partList.forEach((function(i){const r=i.getBoundingBox(t);e.expandByPoint(r.min),e.expandByPoint(r.max)})),e}getCenter(t){return this.getBoundingBox(t).getCenter(new e)}getSelection(){let t=[];return this.partList.forEach((function(e){t=t.concat(e.chainList)})),Fa(t)}}class Na{constructor(t=[],e=[]){this.matrixList=t,this.chainList=e}get type(){return"AssemblyPart"}_getCount(t,e){let i=0;return t.eachChain((t=>{(0===this.chainList.length||this.chainList.includes(t.chainname))&&(i+=t[e])})),this.matrixList.length*i}getAtomCount(t){return this._getCount(t,"atomCount")}getResidueCount(t){return this._getCount(t,"residueCount")}getBoundingBox(t){const e=new a,i=new a,r=this.getSelection(),s=t.getBoundingBox(r);return this.matrixList.forEach((function(t){i.copy(s).applyMatrix4(t),e.expandByPoint(i.min),e.expandByPoint(i.max)})),e}getSelection(){return Fa(this.chainList)}getView(t){const e=this.getSelection();return e?t.getView(e):t}getInstanceList(){const t=[];for(let e=0,i=this.matrixList.length;e0&&this.addResidueType(this.ri-1),l.growIfFull(),l.resno[this.ri]=s,void 0!==o&&(l.sstruc[this.ri]=o.charCodeAt(0)),void 0!==a&&(l.inscode[this.ri]=a.charCodeAt(0)),l.atomOffset[this.ri]=this.ai,l.atomCount[this.ri]=0,l.count+=1,l.chainIndex[this.ri]=this.ci,h.residueCount[this.ci]+=1),c.count+=1,c.residueIndex[this.ai]=this.ri,l.atomCount[this.ri]+=1,this.currentModelindex=t,this.currentChainid=i,this.currentResname=r,this.currentResno=s,this.currentInscode=a,this.currentHetero=n}finalize(){this.previousResname=this.currentResname,this.previousHetero=this.currentHetero,this.ri>-1&&this.addResidueType(this.ri)}}function Va(t,e){if(!e)return;De&&Me.time("assignSecondaryStructure");const i=[];t.eachModel((function(t){t.eachChain((function(t){i.push(t.chainname)}))}));const r=i.slice().sort(),s=[];r.forEach((function(t){s.push(i.indexOf(t))}));const n=e.helices.filter((function(t){return pt(r,t[0])>=0}));n.sort((function(t,e){const i=t[0],n=e[0],o=t[1],a=e[1];if(i===n)return o===a?0:o=0}));a.sort((function(t,e){const i=t[0],n=e[0];if(i===n)return 0;const o=pt(r,i),a=pt(r,n);return s[o]=t.residueCount)continue;o.index=n+s,a.index=n+s+e,c.index=o.traceAtomIndex,l.index=a.traceAtomIndex;const h=c.distanceTo(l);if(Math.abs(h-i[e-2])>r)return!1}return!0},i=function(e,i){return t(e,i,[5.45,5.18,6.37],2.1)},r=function(e,i){return t(e,i,[6.1,10.4,13],1.42)};return function(t){De&&Me.time("calculateSecondaryStructure"),t.eachPolymer((function(t){if(t.residueCount<4)return;if(t.isCg())!function(t){const i=t.residueStore,r=t.residueIndexStart,s=new Pa(t).position,n=new e,o=new e;for(let e=0,a=t.residueCount;e1&&s.bending[e]<20&&(i.sstruc[r+e]="h".charCodeAt(0),i.sstruc[r+e+1]="h".charCodeAt(0))}}(t);else{if(!t.isProtein())return;!function(t){const e=t.residueStore,s=t.residueIndexStart;for(let n=0,o=t.residueCount;n=e;)i=Math.floor(i/e),s+=Ua[i%e],r+=1;return r>=5&&Me.warn("chainname overflow"),s}function Ha(t,e=!1){De&&Me.time("calculateChainnames");let i=!0;if(t.eachChain((function(t){t.chainname&&(i=!1)})),i){const i=t.modelStore,r=t.chainStore,s=t.residueStore,n=function(t,e,n,o){const a=r.count;for(let t=0;t{h.add(e),t.forEach((t=>{h.add(t)}))}))),t.eachResidue((function(t){if(!e&&l){const e=t.atomCount,s=t.atomOffset;if(e>500)return void Me.warn("more than 500 atoms, skip residue for auto-bonding",t.qualifiedName());if("auto"===i&&t.hetero)for(let e=t.atomOffset;e{u.forEach((i=>{e.push(t.clone().multiply(i))}))})),h.addPart(e)}else h.addPart(d);const m=new e,p=new La("SUPERCELL"),f=Array.prototype.concat.call(l(m.set(1,0,0)),l(m.set(0,1,0)),l(m.set(0,0,1)),l(m.set(-1,0,0)),l(m.set(0,-1,0)),l(m.set(0,0,-1)),l(m.set(1,1,0)),l(m.set(1,0,1)),l(m.set(0,1,1)),l(m.set(-1,-1,0)),l(m.set(-1,0,-1)),l(m.set(0,-1,-1)),l(m.set(1,-1,-1)),l(m.set(1,1,-1)),l(m.set(1,-1,1)),l(m.set(-1,1,1)),l(m.set(-1,-1,1)),l(m.set(-1,1,-1)),l(m.set(0,1,-1)),l(m.set(0,-1,1)),l(m.set(1,0,-1)),l(m.set(-1,0,1)),l(m.set(1,-1,0)),l(m.set(-1,1,0)),l(),l(m.set(1,1,1)),l(m.set(-1,-1,-1)));if(t.biomolDict.NCS){const t=[];f.forEach((function(e){u.forEach((function(i){t.push(e.clone().multiply(i))}))})),p.addPart(t)}else p.addPart(f);t.biomolDict.UNITCELL=h,t.biomolDict.SUPERCELL=p,De&&Me.timeEnd("buildUnitcellAssembly")}const Qa=["H","C","O","N","S","P"],Ja=["NA","CL","FE"];function tc(t){let e=t.toUpperCase(),i=0,r=0;for(let t=0;t0)break;++i}else r=t+1;(i>0||r=3&&-1!==Qa.indexOf(e[0])?e[0]:""}function ec(t){const e=t.bondHash,i=e.countArray,r=e.offsetArray,s=e.indexArray,n=t.getBondProxy();t.eachResidue((function(t){const e=t.residueType;if(void 0!==e.bonds)return;var o=t.atomOffset,a=[],c=[],l=[],h={};const d=o+t.atomCount;t.eachAtom((function(t){const e=t.index,u=r[e];for(let t=0,r=i[e];t=d)continue;let i=n.atomIndex2;if(i=d)continue;if(e>i){const t=i;i=e,e=t}const r=e+"|"+i;void 0===h[r]&&(h[r]=!0,a.push(e-o),c.push(i-o),l.push(n.bondOrder))}})),e.bonds={atomIndices1:a,atomIndices2:c,bondOrders:l}}))}function ic(t,...e){De&&Me.time("concatStructures");const i=new Cc(t,""),r=new za(i),s=i.atomStore,n=i.atomMap;s.addField("formalCharge",1,"int8"),s.addField("partialCharge",1,"float32");const o={};let a=0,c=0,l=0;e.forEach((t=>{t.eachAtom((t=>{s.growIfFull(),s.atomTypeId[a]=n.add(t.atomname,t.element),s.x[a]=t.x,s.y[a]=t.y,s.z[a]=t.z,s.serial[a]=t.serial,s.formalCharge[a]=t.formalCharge,s.partialCharge[a]=t.partialCharge,s.altloc[a]=t.altloc,s.occupancy[a]=t.occupancy,s.bfactor[a]=t.bfactor,r.addAtom(t.modelIndex+l,t.chainname,t.chainid,t.resname,t.resno,1===t.hetero,t.sstruc,t.inscode),o[t.index+c]=a,a+=1})),c+=t.atomStore.count,l+=t.modelStore.count}));const h=i.bondStore,d=i.getAtomProxy(),u=i.getAtomProxy();return c=0,e.forEach((t=>{t.eachBond((t=>{d.index=o[t.atomIndex1+c],u.index=o[t.atomIndex2+c],h.addBond(d,u,t.bondOrder)})),c+=t.atomStore.count})),r.finalize(),Ka(i,!0),Ya(i,!0),i.finalizeAtoms(),i.finalizeBonds(),ec(i),De&&Me.timeEnd("concatStructures"),i}const rc=[3,11,19,37,55,87],sc=[4,12,20,38,56,88],nc=[6,15,16,34],oc=[1,7,8,9,17,35,53],ac=[2,10,18,36,54,86],cc=[13,30,31,48,49,50,80,81,82,83,84,85,112],lc=[5,14,32,33,51,52,85],hc=[9,17,35,53,85];class dc{constructor(t,e,i){this.structure=t,this.atomname=e,i=i||tc(e),this.element=i,this.number=Xs[i]||0,this.vdw=Ys[this.number]||2,this.covalent=Ks[this.number]||1.6}getDefaultValence(){const t=Zs[this.number];return t?t[0]:-1}getValenceList(){return Zs[this.number]||[]}getOuterShellElectronCount(){return Qs[this.number]||2}isMetal(){return this.isAlkaliMetal()||this.isAlkalineEarthMetal()||this.isLanthanide()||this.isActinide()||this.isTransitionMetal()||this.isPostTransitionMetal()}isNonmetal(){return this.isDiatomicNonmetal()||this.isPolyatomicNonmetal()||this.isNobleGas()}isMetalloid(){return lc.includes(this.number)}isHalogen(){return hc.includes(this.number)}isDiatomicNonmetal(){return oc.includes(this.number)}isPolyatomicNonmetal(){return nc.includes(this.number)}isAlkaliMetal(){return rc.includes(this.number)}isAlkalineEarthMetal(){return sc.includes(this.number)}isNobleGas(){return ac.includes(this.number)}isTransitionMetal(){const t=this.number;return t>=21&&t<=29||t>=39&&t<=47||t>=72&&t<=79||t>=104&&t<=108}isPostTransitionMetal(){return cc.includes(this.number)}isLanthanide(){return this.number>=57&&this.number<=71}isActinide(){return this.number>=89&&this.number<=103}}class uc{constructor(t){this.structure=t,this.dict={},this.list=[],this.structure=t}add(t,e){const i=function(t,e){return t+"|"+e}(t=t.toUpperCase(),e=e?e.toUpperCase():tc(t));let r=this.dict[i];if(void 0===r){const s=new dc(this.structure,t,e);r=this.list.length,this.dict[i]=r,this.list.push(s)}return r}get(t){return this.list[t]}}class mc{constructor(t,e,i,r,s,n){this.structure=t,this.bondReferenceAtomIndices=[],this.resname=e,this.atomTypeIdList=i,this.hetero=r?1:0,this.chemCompType=s,this.bonds=n,this.atomCount=i.length,this.moleculeType=this.getMoleculeType(),this.backboneType=this.getBackboneType(0),this.backboneEndType=this.getBackboneType(-1),this.backboneStartType=this.getBackboneType(1),this.backboneIndexList=this.getBackboneIndexList();const o=mn[this.backboneType],a=mn[this.backboneStartType],c=mn[this.backboneEndType],l=this.getAtomIndexByName(o.trace);this.traceAtomIndex=st(l,-1);const h=this.getAtomIndexByName(o.direction1);this.direction1AtomIndex=st(h,-1);const d=this.getAtomIndexByName(o.direction2);this.direction2AtomIndex=st(d,-1);const u=this.getAtomIndexByName(a.backboneStart);this.backboneStartAtomIndex=st(u,-1);const m=this.getAtomIndexByName(c.backboneEnd);let p;this.backboneEndAtomIndex=st(m,-1),p=on.includes(e)?this.getAtomIndexByName("N1"):this.getAtomIndexByName("N3"),this.rungEndAtomIndex=st(p,-1)}getBackboneIndexList(){const t=[];let e;switch(this.moleculeType){case 3:e=dn;break;case 4:case 5:e=un;break;default:return t}const i=this.structure.atomMap,r=this.atomTypeIdList;for(let s=0,n=this.atomCount;s500)De&&Me.warn("more than 500 atoms, skip residue for auto-bonding",t.qualifiedName());else if(s>50){const e=new $a(t,!0),s=t.isCg()?1.2:2.3;for(let t=n;t=0||yc(t,e);this.rings={atomRings:t.atomRings,rings:t.rings}}isAromatic(t){return this.aromaticAtoms=this.getAromatic(t),1===this.aromaticAtoms[t.index-t.residueAtomOffset]}calculateAromatic(t){const e=this.aromaticAtoms=new Uint8Array(this.atomCount),i=this.getRings().rings,r=i.map((e=>function(t){if(t.some((t=>!pc.includes(t.number))))return!1;let e=0;const i=new ho(3,t.length),r=i.data;t.forEach((t=>{r[e+0]=t.x,r[e+1]=t.y,r[e+2]=t.z,e+=3}));return new ya(i).vecC.length()this.structure.getAtomProxy(e+t.atomOffset)))))),s=this.aromaticRings=[];i.forEach(((t,i)=>{r[i]&&(s.push(t),t.forEach((t=>e[t]=1)))}))}assignBondReferenceAtomIndices(){const t=this.getBondGraph(),e=this.getRings(),i=e.atomRings,r=e.rings,s=this.bonds,n=s.atomIndices1,o=s.atomIndices2,a=s.bondOrders,c=this.bondReferenceAtomIndices,l=s.atomIndices1.length;c.length=0;for(let e=0;e1)for(let i=0;i1)for(let i=0;i=0;t--)p[f++]=o[t];const g=t.rings.length;for(let e=0;e0?n[c]!==e&&n[e]!==c&&gc(t,e,c):(r[c]=1,s[a++]=c,n[c]=e)}}}const bc=4;class xc{constructor(t){this.structure=t,this.dict={},this.list=[]}add(t,e,i,r="",s){const n=function(t,e,i,r=""){return t+"|"+e.join(",")+"|"+(i?1:0)+"|"+r}(t=t.toUpperCase(),e,i,r);let o=this.dict[n];if(void 0===o){const a=new mc(this.structure,t,e,i,r,s);o=this.list.length,this.dict[n]=o,this.list.push(a)}return o}get(t){return this.list[t]}}class vc{constructor(t,i=0){this.structure=t,this.index=i,this.bondStore=t.bondStore,this._v12=new e,this._v13=new e,this._ap1=this.structure.getAtomProxy(),this._ap2=this.structure.getAtomProxy(),this._ap3=this.structure.getAtomProxy()}get atom1(){return this.structure.getAtomProxy(this.atomIndex1)}get atom2(){return this.structure.getAtomProxy(this.atomIndex2)}get atomIndex1(){return this.bondStore.atomIndex1[this.index]}set atomIndex1(t){this.bondStore.atomIndex1[this.index]=t}get atomIndex2(){return this.bondStore.atomIndex2[this.index]}set atomIndex2(t){this.bondStore.atomIndex2[this.index]=t}get bondOrder(){return this.bondStore.bondOrder[this.index]}set bondOrder(t){this.bondStore.bondOrder[this.index]=t}getOtherAtomIndex(t){return t===this.atomIndex1?this.atomIndex2:this.atomIndex1}getOtherAtom(t){return this.structure.getAtomProxy(this.getOtherAtomIndex(t.index))}getReferenceAtomIndex(){const t=this._ap1,e=this._ap2;if(t.index=this.atomIndex1,e.index=this.atomIndex2,t.residueIndex!==e.residueIndex)return;const i=t.index-t.residueAtomOffset,r=e.index-e.residueAtomOffset,s=t.residueType.getBondReferenceAtomIndex(i,r);if(void 0!==s)return s+t.residueAtomOffset;console.warn("No reference atom found",t.index,e.index)}calculateShiftDir(t=new e){const i=this._ap1,r=this._ap2,s=this._ap3,n=this._v12,o=this._v13;i.index=this.atomIndex1,r.index=this.atomIndex2;const a=this.getReferenceAtomIndex();n.subVectors(i,r).normalize(),void 0!==a?(s.index=a,o.subVectors(i,s)):o.copy(i),o.normalize();let c=n.dot(o);return 1-Math.abs(c)<1e-5&&(o.set(1,0,0),c=n.dot(o),1-Math.abs(c)<1e-5&&(o.set(0,1,0),c=n.dot(o))),t.copy(o.sub(n.multiplyScalar(c))).normalize()}qualifiedName(){return this.atomIndex1+"="+this.atomIndex2}clone(){return new vc(this.structure,this.index)}toObject(){return{atomIndex1:this.atomIndex1,atomIndex2:this.atomIndex2,bondOrder:this.bondOrder}}}class wc{constructor(t,e=0){this.structure=t,this.index=e,this.chainStore=t.chainStore,this.residueStore=t.residueStore,this.atomStore=t.atomStore,this.residueMap=t.residueMap,this.atomMap=t.atomMap}get entity(){return this.structure.entityList[this.entityIndex]}get entityIndex(){return this.chainStore.entityIndex[this.chainIndex]}get chain(){return this.structure.getChainProxy(this.chainIndex)}get chainIndex(){return this.residueStore.chainIndex[this.index]}set chainIndex(t){this.residueStore.chainIndex[this.index]=t}get atomOffset(){return this.residueStore.atomOffset[this.index]}set atomOffset(t){this.residueStore.atomOffset[this.index]=t}get atomCount(){return this.residueStore.atomCount[this.index]}set atomCount(t){this.residueStore.atomCount[this.index]=t}get atomEnd(){return this.atomOffset+this.atomCount-1}get modelIndex(){return this.chainStore.modelIndex[this.chainIndex]}get chainname(){return this.chainStore.getChainname(this.chainIndex)}get chainid(){return this.chainStore.getChainid(this.chainIndex)}get resno(){return this.residueStore.resno[this.index]}set resno(t){this.residueStore.resno[this.index]=t}get sstruc(){return this.residueStore.getSstruc(this.index)}set sstruc(t){this.residueStore.setSstruc(this.index,t)}get inscode(){return this.residueStore.getInscode(this.index)}set inscode(t){this.residueStore.setInscode(this.index,t)}get residueType(){return this.residueMap.get(this.residueStore.residueTypeId[this.index])}get resname(){return this.residueType.resname}get hetero(){return this.residueType.hetero}get moleculeType(){return this.residueType.moleculeType}get backboneType(){return this.residueType.backboneType}get backboneStartType(){return this.residueType.backboneStartType}get backboneEndType(){return this.residueType.backboneEndType}get traceAtomIndex(){return this.residueType.traceAtomIndex+this.atomOffset}get direction1AtomIndex(){return this.residueType.direction1AtomIndex+this.atomOffset}get direction2AtomIndex(){return this.residueType.direction2AtomIndex+this.atomOffset}get backboneStartAtomIndex(){return this.residueType.backboneStartAtomIndex+this.atomOffset}get backboneEndAtomIndex(){return this.residueType.backboneEndAtomIndex+this.atomOffset}get rungEndAtomIndex(){return this.residueType.rungEndAtomIndex+this.atomOffset}get x(){let t=0;for(let e=this.atomOffset;e<=this.atomEnd;++e)t+=this.atomStore.x[e];return t/this.atomCount}get y(){let t=0;for(let e=this.atomOffset;e<=this.atomEnd;++e)t+=this.atomStore.y[e];return t/this.atomCount}get z(){let t=0;for(let e=this.atomOffset;e<=this.atomEnd;++e)t+=this.atomStore.z[e];return t/this.atomCount}eachAtom(t,e){const i=this.atomCount,r=this.atomOffset,s=this.structure._ap,n=r+i;if(e&&e.atomOnlyTest){const i=e.atomOnlyTest;for(let e=r;e0)return this.entity.isPolymer();{const t=this.residueType.moleculeType;return 3===t||4===t||5===t}}isHetero(){return 1===this.residueType.hetero}isWater(){return 1===this.residueType.moleculeType}isIon(){return 2===this.residueType.moleculeType}isSaccharide(){return 6===this.residueType.moleculeType}isStandardAminoacid(){return this.residueType.isStandardAminoacid()}isStandardBase(){return this.residueType.isStandardBase()}isHelix(){return Hs.includes(this.sstruc)}isSheet(){return Ws.includes(this.sstruc)}isTurn(){return qs.includes(this.sstruc)&&this.isProtein()}getAtomType(t){return this.atomMap.get(this.atomStore.atomTypeId[t])}getResname1(){return en[this.resname.toUpperCase()]||"X"}getBackboneType(t){switch(t){case-1:return this.residueType.backboneStartType;case 1:return this.residueType.backboneEndType;default:return this.residueType.backboneType}}getAtomIndexByName(t){let e=this.residueType.getAtomIndexByName(t);return void 0!==e&&(e+=this.atomOffset),e}hasAtomWithName(t){return this.residueType.hasAtomWithName(t)}getAtomnameList(){console.warn("getAtomnameList - might be expensive");const t=this.atomCount,e=this.atomOffset,i=new Array(t);for(let r=0;r=e){const e=st(t,this.structure.getResidueProxy());if(e.index=i,e.connectedTo(this))return e}else if(i===e-1){const i=this.chainStore.residueCount[this.chainIndex],r=st(t,this.structure.getResidueProxy());if(r.index=e+i-1,r.connectedTo(this))return r}}getBonds(){return this.residueType.getBonds(this)}getRings(){return this.residueType.getRings()}getAromaticRings(){return this.residueType.getAromaticRings(this)}qualifiedName(t=!1){let e="";return this.resname&&!t&&(e+="["+this.resname+"]"),void 0!==this.resno&&(e+=this.resno),this.inscode&&(e+="^"+this.inscode),this.chain&&(e+=":"+this.chainname),e+="/"+this.modelIndex,e}clone(){return new wc(this.structure,this.index)}toObject(){return{index:this.index,chainIndex:this.chainIndex,atomOffset:this.atomOffset,atomCount:this.atomCount,resno:this.resno,resname:this.resname,sstruc:this.sstruc}}}class Ac{constructor(t,e,i){this.structure=t,this.residueIndexStart=e,this.residueIndexEnd=i,this.chainStore=t.chainStore,this.residueStore=t.residueStore,this.atomStore=t.atomStore,this.residueCount=i-e+1;const r=this.structure.getResidueProxy(this.residueIndexStart),s=this.structure.getResidueProxy(this.residueIndexEnd);this.isPrevConnected=void 0!==r.getPreviousConnectedResidue();const n=s.getNextConnectedResidue();this.isNextConnected=void 0!==n,this.isNextNextConnected=void 0!==n&&void 0!==n.getNextConnectedResidue(),this.isCyclic=s.connectedTo(r),this.__residueProxy=this.structure.getResidueProxy()}get chainIndex(){return this.residueStore.chainIndex[this.residueIndexStart]}get modelIndex(){return this.chainStore.modelIndex[this.chainIndex]}get chainname(){return this.chainStore.getChainname(this.chainIndex)}isProtein(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isProtein()}isCg(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isCg()}isNucleic(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isNucleic()}getMoleculeType(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.moleculeType}getBackboneType(t){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.getBackboneType(t)}getAtomIndexByType(t,e){this.isCyclic?-1===t?t=this.residueCount-1:t===this.residueCount&&(t=0):(-1!==t||this.isPrevConnected||(t+=1),t!==this.residueCount||this.isNextNextConnected||(t-=1));const i=this.__residueProxy;let r;switch(i.index=this.residueIndexStart+t,e){case"trace":r=i.traceAtomIndex;break;case"direction1":r=i.direction1AtomIndex;break;case"direction2":r=i.direction2AtomIndex;break;default:r=i.getAtomIndexByName(e)}return r}eachAtom(t,e){this.eachResidue((function(i){i.eachAtom(t,e)}))}eachAtomN(t,e,i){const r=this.residueCount,s=new Array(t);for(let e=0;e1&&t(new Ac(n,i,l.index)),i=r)):(o!==Ns&&l.index-i>1&&t(new Ac(n,i,l.index)),i=r)}r-i>1&&this.structure.getResidueProxy(i).backboneEndType&&t(new Ac(n,i,r))}qualifiedName(){return":"+this.chainname+"/"+this.modelIndex}clone(){return new _c(this.structure,this.index)}toObject(){return{index:this.index,residueOffset:this.residueOffset,residueCount:this.residueCount,chainname:this.chainname}}}class Sc{constructor(t,e=0){this.structure=t,this.index=e,this.modelStore=t.modelStore,this.chainStore=t.chainStore,this.residueStore=t.residueStore}get chainOffset(){return this.modelStore.chainOffset[this.index]}set chainOffset(t){this.modelStore.chainOffset[this.index]=t}get chainCount(){return this.modelStore.chainCount[this.index]}set chainCount(t){this.modelStore.chainCount[this.index]=t}get residueOffset(){return this.chainStore.residueOffset[this.chainOffset]}get atomOffset(){return this.residueStore.atomOffset[this.residueOffset]}get chainEnd(){return this.chainOffset+this.chainCount-1}get residueEnd(){return this.chainStore.residueOffset[this.chainEnd]+this.chainStore.residueCount[this.chainEnd]-1}get atomEnd(){return this.residueStore.atomOffset[this.residueEnd]+this.residueStore.atomCount[this.residueEnd]-1}get residueCount(){return 0===this.chainCount?0:this.residueEnd-this.residueOffset+1}get atomCount(){return 0===this.residueCount?0:this.atomEnd-this.atomOffset+1}eachAtom(t,e){this.eachChain((function(i){i.eachAtom(t,e)}),e)}eachResidue(t,e){this.eachChain((function(i){i.eachResidue(t,e)}),e)}eachPolymer(t,e){if(e&&e.chainOnlyTest){const i=e.chainOnlyTest;this.eachChain((function(r){i(r)&&r.eachPolymer(t,e)}))}else this.eachChain((function(i){i.eachPolymer(t,e)}))}eachChain(t,e){const i=this.chainCount,r=this.chainOffset,s=this.structure._cp,n=r+i;if(e&&e.test){const i=e.chainOnlyTest;if(i)for(let e=r;e{const i=3*e;a.index=t,l&&a.positionToArray(l,i),h&&n.atomColorToArray(a,h,i),d&&(d.array[e]=t),u&&(u[e]=s.atomRadius(a)),m&&(m[e]=t)})),o}getBondData(t){const i=Object.assign({},t);i.colorParams&&(i.colorParams.structure=this.getStructure());const r=i.what,s=st(i.bondSet,this.bondSet),n=st(i.multipleBond,"off"),o="off"!==n,a="offset"===n,c=st(i.bondScale,.4),l=st(i.bondSpacing,1);let h,d;const u={},m=this.getBondProxy();i.bondStore&&(m.bondStore=i.bondStore);const p=this.getAtomProxy(),f=this.getAtomProxy();let g;if(o){const t=m.bondStore.bondOrder;g=0,s.forEach((function(e){g+=t[e]}))}else g=s.getSize();r&&!r.position||(u.position1=new Float32Array(3*g),u.position2=new Float32Array(3*g)),r&&!r.color||!i.colorParams||(u.color=new Float32Array(3*g),u.color2=new Float32Array(3*g),d=Fe.getScheme(i.colorParams)),r&&!r.picking||(u.picking=new Zn(new Float32Array(g),this.getStructure(),i.bondStore)),(!r||r.radius||o&&r.position)&&(h=new pa(i.radiusParams)),r&&!r.radius||(u.radius=new Float32Array(g),i.radius2&&(u.radius2=new Float32Array(g)));const{position1:y,position2:b,color:x,color2:v,picking:w,radius:A,radius2:_}=u;let S,C,P,I,k,M,T=0;const B=new e,D=new e,$=new e;return s.forEach((t=>{if(C=3*T,m.index=t,p.index=m.atomIndex1,f.index=m.atomIndex2,I=m.bondOrder,y)if(o&&I>1){const t=h.atomRadius(p);M=t*c/(.5*I),m.calculateShiftDir($),a?(k=2*l*t,$.multiplyScalar(k),$.negate(),D.subVectors(f,p).multiplyScalar(Math.max(.1,k/1.88)),p.positionToArray(y,C),f.positionToArray(b,C),I>=2&&(B.addVectors(p,$).add(D).toArray(y,C+3),B.addVectors(f,$).sub(D).toArray(b,C+3),I>=3&&(B.subVectors(p,$).add(D).toArray(y,C+6),B.subVectors(f,$).sub(D).toArray(b,C+6)))):(k=(l-c)*t,$.multiplyScalar(k),2===I?(B.addVectors(p,$).toArray(y,C),B.subVectors(p,$).toArray(y,C+3),B.addVectors(f,$).toArray(b,C),B.subVectors(f,$).toArray(b,C+3)):3===I?(p.positionToArray(y,C),B.addVectors(p,$).toArray(y,C+3),B.subVectors(p,$).toArray(y,C+6),f.positionToArray(b,C),B.addVectors(f,$).toArray(b,C+3),B.subVectors(f,$).toArray(b,C+6)):(p.positionToArray(y,C),f.positionToArray(b,C)))}else p.positionToArray(y,C),f.positionToArray(b,C);if(x&&v&&(d.bondColorToArray(m,1,x,C),d.bondColorToArray(m,0,v,C),o&&I>1))for(S=1;S1))for(S=1;S1))for(M=A[T]*c/(a?1:.5*I),S=a?1:0;S1))for(M=_[T]*c/(a?1:.5*I),S=a?1:0;S{const e=t.x,a=t.y,l=t.z;en&&(n=e),a>o&&(o=a),l>c&&(c=l)}),t),e.min.set(i,r,s),e.max.set(n,o,c),De&&Me.timeEnd("getBoundingBox"),e}getPrincipalAxes(t){De&&Me.time("getPrincipalAxes");let e=0;const i=new ho(3,this.atomCount),r=i.data;return this.eachAtom((t=>{r[e+0]=t.x,r[e+1]=t.y,r[e+2]=t.z,e+=3}),t),De&&Me.timeEnd("getPrincipalAxes"),new ya(i)}atomCenter(t){return t?this.getBoundingBox(t).getCenter(new e):this.center.clone()}hasCoords(){if(void 0===this._hasCoords){const t=this.atomStore;this._hasCoords=0!==Di(t.x)||0!==Bi(t.x)||0!==Di(t.y)||0!==Bi(t.y)||0!==Di(t.z)||0!==Bi(t.z)||t.count/this.modelStore.count==1}return this._hasCoords}getSequence(t){const e=[],i=this.getResidueProxy();return this.eachAtom((function(t){i.index=t.residueIndex,t.index===i.traceAtomIndex&&e.push(i.getResname1())}),t),e}getAtomIndices(t){if(t&&t.string){const e=[];return this.eachAtom((function(t){e.push(t.index)}),t),new Uint32Array(e)}{const t={what:{index:!0}};return this.getAtomData(t).index}}getChainnameCount(t){const e=new Set;return this.eachChain((function(t){t.residueCount&&e.add(t.chainname)}),t),e.size}updatePosition(t,e=!0){let i=0;this.eachAtom((function(e){e.positionFromArray(t,i),i+=3}),void 0),this._hasCoords=void 0,e&&this.refreshPosition()}refreshPosition(){this.getBoundingBox(void 0,this.boundingBox),this.boundingBox.getCenter(this.center),this.spatialHash=new Ts(this.atomStore,this.boundingBox),this.signals.refreshed.dispatch(this)}dispose(){this.frames&&(this.frames.length=0),this.boxes&&(this.boxes.length=0),this.bondStore.dispose(),this.backboneBondStore.dispose(),this.rungBondStore.dispose(),this.atomStore.dispose(),this.residueStore.dispose(),this.chainStore.dispose(),this.modelStore.dispose(),delete this.bondSet,delete this.atomSet}}const Pc=new a,Ic=[_s,xs,Ss,As,Cs,vs,bs,ws,Is,Ps,ks,Ms],kc={aspectRatio:1.5,sphereDetail:2,radialSegments:50,disableImpostor:!1,openEnded:!1,dashedCylinder:!1,labelParams:{},pointSize:2,sizeAttenuation:!1,useTexture:!0,linewidth:2};class Mc{constructor(t="shape",e={}){this.boundingBox=new a,this.bufferList=[],this.meshCount=0,this._primitiveData={},this.name=t,this.parameters=nt(e,kc),Ic.forEach((t=>{Object.keys(t.fields).forEach((e=>{this._primitiveData[t.getShapeKey(e)]=[]})),this._primitiveData[t.getShapeKey("name")]=[]}))}addBuffer(t){this.bufferList.push(t);const e=t.geometry;return e.boundingBox||e.computeBoundingBox(),this.boundingBox.union(e.boundingBox),this}addMesh(t,e,i,r,s){let n;t=Ct(t),e=Ct(e),Array.isArray(i)&&(i=xt(i,t.length)),r&&(r=Ct(r)),n=void 0===r||0==r.length?{position:t,color:e,index:i}:{position:t,color:e,index:i,normal:r};const o=new io(this,Object.assign({serial:this.meshCount,name:s},n)),a=new Uo(Object.assign({picking:o},n));return this.bufferList.push(a),Pc.setFromArray(t),this.boundingBox.union(Pc),this.meshCount+=1,this}addSphere(t,e,i,r){return bs.objectToShape(this,{position:t,color:e,radius:i,name:r}),this}addEllipsoid(t,e,i,r,s,n){return Cs.objectToShape(this,{position:t,color:e,radius:i,majorAxis:r,minorAxis:s,name:n}),this}addTorus(t,e,i,r,s,n){return Ps.objectToShape(this,{position:t,color:e,radius:i,majorAxis:r,minorAxis:s,name:n}),this}addCylinder(t,e,i,r,s){return As.objectToShape(this,{position1:t,position2:e,color:i,radius:r,name:s}),this}addCone(t,e,i,r,s){return Ss.objectToShape(this,{position1:t,position2:e,color:i,radius:r,name:s}),this}addArrow(t,e,i,r,s){return _s.objectToShape(this,{position1:t,position2:e,color:i,radius:r,name:s}),this}addBox(t,e,i,r,s,n){return xs.objectToShape(this,{position:t,color:e,size:i,heightAxis:r,depthAxis:s,name:n}),this}addOctahedron(t,e,i,r,s,n){return vs.objectToShape(this,{position:t,color:e,size:i,heightAxis:r,depthAxis:s,name:n}),this}addTetrahedron(t,e,i,r,s,n){return ws.objectToShape(this,{position:t,color:e,size:i,heightAxis:r,depthAxis:s,name:n}),this}addText(t,e,i,r){return Is.objectToShape(this,{position:t,color:e,size:i,text:r}),this}addPoint(t,e,i){return ks.objectToShape(this,{position:t,color:e,name:i}),this}addWideline(t,e,i,r,s){return this.parameters.linewidth=r,Ms.objectToShape(this,{position1:t,position2:e,color:i,name:s}),this}addLabel(t,e,i,r){return console.warn("Shape.addLabel is deprecated, use .addText instead"),this.addText(t,e,i,r)}getBufferList(){const t=[];return Ic.forEach((e=>{this._primitiveData[e.getShapeKey("color")].length&&t.push(e.bufferFromShape(this,this.parameters))})),this.bufferList.concat(t)}dispose(){this.bufferList.forEach((function(t){t.dispose()})),this.bufferList.length=0,Ic.forEach((t=>{Object.keys(t.fields).forEach((e=>{this._primitiveData[t.getShapeKey(e)].length=0})),this._primitiveData[t.getShapeKey("name")].length=0}))}get center(){return this._center||(this._center=this.boundingBox.getCenter(new e)),this._center}get type(){return"Shape"}}class Tc extends zr{constructor(t,e,i){Array.isArray(t)||(t=[t]),super(t,e,i),this.type="buffer",this.parameters=Object.assign({},this.parameters,{colorScheme:null,colorScale:null,colorValue:null,colorDomain:null,colorMode:null}),this.buffer=t,this.init(i)}init(t){super.init(t),this.build()}create(){this.bufferList.push.apply(this.bufferList,this.buffer)}attach(t){this.bufferList.forEach((t=>{this.viewer.add(t),t.setParameters(this.getBufferParams())})),this.setVisibility(this.visible),t()}}const Bc=new i,Dc=new O;class $c extends Uo{constructor(t,e={},i){super(function(t,e){const i=e.attributes.position.array,r=e.index?e.index.array:void 0,s=t.position.length/3,n=i.length/3,o=s*n,a=new Float32Array(3*o),c=new Float32Array(3*o),l=new Float32Array(3*o);let h;return r&&(h=xt(s*r.length,o)),{position:a,color:l,index:h,normal:c,primitiveId:t.primitiveId||Ii(s,n),picking:t.picking}}(t,i),e),this.updateNormals=!1;const r=i.attributes.position.array,s=i.attributes.normal.array,n=i.index?i.index.array:void 0;this.geoPosition=r,this.geoNormal=s,this.geoIndex=n,this.positionCount=t.position.length/3,this.geoPositionCount=r.length/3,this.transformedGeoPosition=new Float32Array(3*this.geoPositionCount),this.transformedGeoNormal=new Float32Array(3*this.geoPositionCount);const o=this.geometry.attributes;if(this.meshPosition=o.position.array,this.meshColor=o.color.array,this.meshNormal=o.normal.array,this.setAttributes(t),n){const t=this.geometry.getIndex();if(!t)return void Me.error("Index is null");this.meshIndex=t.array,this.makeIndex()}}setAttributes(t={},e=!1){const i=this.geometry.attributes;let r,s,n,o,a,c,l,h,d;const u=this.updateNormals;t.position&&(r=t.position,n=this.geoPosition,l=this.meshPosition,a=this.transformedGeoPosition,i.position.needsUpdate=!0,(u||e)&&(o=this.geoNormal,d=this.meshNormal,c=this.transformedGeoNormal,i.normal.needsUpdate=!0)),t.color&&(s=t.color,h=this.meshColor,i.color.needsUpdate=!0);const m=this.positionCount,p=this.geoPositionCount;for(let t=0;t 0.0 ){\ncameraPos = rayDirection * posT + rayOrigin;\ninterior = true;\nflag2 = true;\n}\n#else\nif( calcDepth( cameraPos ) <= 0.0 ){\ncameraPos = rayDirection * posT + rayOrigin;\ninterior = true;\n}\n#endif\ncameraNormal = normalize( cameraPos - cameraSpherePos );\ncameraNormal *= float(!interior) * 2.0 - 1.0;\nreturn !interior;\n}\nvoid main(void){\nbool flag = Impostor( cameraPos, cameraNormal );\n#ifdef NEAR_CLIP\nif( calcClip( cameraPos ) > 0.0 )\ndiscard;\n#endif\ngl_FragDepthEXT = calcDepth( cameraPos );\nif( !flag ){\n#ifdef NEAR_CLIP\nif( flag2 ){\ngl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( clipNear - 0.5 ) ) ) + ( 0.0000001 / vRadius ) );\n}else if( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n#else\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n#endif\n}\nif (gl_FragDepthEXT < 0.0)\ndiscard;\nif (gl_FragDepthEXT > 1.0)\ndiscard;\n#ifdef PICKING\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 vNormal = cameraNormal;\nvec3 vViewPosition = -cameraPos;\nvec4 diffuseColor = vec4( diffuse, opacity );\nReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\nvec3 totalEmissiveLight = emissive;\n#include color_fragment\n#include roughnessmap_fragment\n#include metalnessmap_fragment\n#include normal_fragment_begin\n#include lights_physical_fragment\n#include lights_fragment_begin\n#include lights_fragment_end\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\nif( interior ){\n#ifdef USE_INTERIOR_COLOR\noutgoingLight.xyz = interiorColor;\n#else\n#ifdef DIFFUSE_INTERIOR\noutgoingLight.xyz = vColor;\n#endif\n#endif\noutgoingLight.xyz *= 1.0 - interiorDarkening;\n}\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");class Fc extends Go{constructor(t,e,i={}){super(e,i),this.index=xt(this.indexSize,this.attributeSize),this.makeIndex(),this.initIndex(this.index),this.addAttributes({mapping:{type:t,value:null}}),this.setAttributes({primitiveId:Pi(this.size)})}get attributeSize(){return this.size*this.mappingSize}get indexSize(){return this.size*this.mappingIndicesSize}addAttributes(t){const e={};for(const i in t){const r=t[i];e[i]={type:r.type,value:null}}super.addAttributes(e)}getAttributeIndex(t){return 3*t*this.mappingSize}setAttributes(t){t&&!t.position&&t.position1&&t.position2&&(t.position=Ai(t.position1,t.position2));const e=this.size,i=this.mappingSize,r=this.geometry.attributes;let s,n,o,a,c,l,h;for(const d in t)if("index"!==d&&"picking"!==d){n=t[d],s=r[d],o=s.itemSize,a=s.array;for(let t=0;t0&&this.parameters.alphaTest<=1&&(e.ALPHATEST=this.parameters.alphaTest.toPrecision(2)),e}setUniforms(t){t&&void 0!==t.edgeBleach&&(this.makeTexture(),t.map=this.tex),super.setUniforms(t)}dispose(){super.dispose(),this.tex&&this.tex.dispose()}}je.add("point",Wc);class qc extends zr{constructor(t,e,i){super(t,e,i),this.type="dot",this.parameters=Object.assign({thresholdType:{type:"select",rebuild:!0,options:{value:"value",sigma:"sigma"}},thresholdMin:{type:"number",precision:3,max:1/0,min:-1/0,rebuild:!0},thresholdMax:{type:"number",precision:3,max:1/0,min:-1/0,rebuild:!0},thresholdOut:{type:"boolean",rebuild:!0},dotType:{type:"select",rebuild:!0,options:{"":"",sphere:"sphere",point:"point"}},radiusType:{type:"select",options:{"":"",value:"value","abs-value":"abs-value","value-min":"value-min",deviation:"deviation",size:"size"}},radius:{type:"number",precision:3,max:10,min:.001,property:"size"},scale:{type:"number",precision:3,max:10,min:.001},sphereDetail:!0,disableImpostor:!0,pointSize:{type:"number",precision:1,max:100,min:0,buffer:!0},sizeAttenuation:{type:"boolean",buffer:!0},sortParticles:{type:"boolean",rebuild:!0},useTexture:{type:"boolean",buffer:!0},alphaTest:{type:"range",step:.001,max:1,min:0,buffer:!0},forceTransparent:{type:"boolean",buffer:!0},edgeBleach:{type:"range",step:.001,max:1,min:0,buffer:!0}},this.parameters,{colorScheme:{type:"select",update:"color",options:{"":"",value:"value",uniform:"uniform",random:"random"}}}),t instanceof Eo?(this.surface=void 0,this.volume=new ba(t)):(this.surface=t,this.volume=void 0),this.init(i)}init(t){var e=t||{};e.colorScheme=st(e.colorScheme,"uniform"),e.colorValue=st(e.colorValue,14540253),this.thresholdType=st(e.thresholdType,"sigma"),this.thresholdMin=st(e.thresholdMin,2),this.thresholdMax=st(e.thresholdMax,1/0),this.thresholdOut=st(e.thresholdOut,!1),this.dotType=st(e.dotType,"point"),this.radius=st(e.radius,.1),this.scale=st(e.scale,1),this.pointSize=st(e.pointSize,1),this.sizeAttenuation=st(e.sizeAttenuation,!0),this.sortParticles=st(e.sortParticles,!1),this.useTexture=st(e.useTexture,!1),this.alphaTest=st(e.alphaTest,.5),this.forceTransparent=st(e.forceTransparent,!1),this.edgeBleach=st(e.edgeBleach,0),super.init(e),this.build()}attach(t){this.bufferList.forEach((t=>{this.viewer.add(t)})),this.setVisibility(this.visible),t()}create(){var t={};if(this.volume){var e,i,r=this.volume;"sigma"===this.thresholdType?(e=r.getValueForSigma(this.thresholdMin),i=r.getValueForSigma(this.thresholdMax)):(e=this.thresholdMin,i=this.thresholdMax),r.setFilter(e,i,this.thresholdOut),Object.assign(t,{position:r.getDataPosition(),color:r.getDataColor(this.getColorParams())}),"sphere"===this.dotType&&Object.assign(t,{radius:r.getDataSize(this.radius,this.scale),picking:r.getDataPicking()})}else{var s=this.surface;Object.assign(t,{position:s.getPosition(),color:s.getColor(this.getColorParams())}),"sphere"===this.dotType&&Object.assign(t,{radius:s.getSize(this.radius,this.scale),picking:s.getPicking()})}"sphere"===this.dotType?this.dotBuffer=new Gc(t,this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!1})):this.dotBuffer=new Wc(t,this.getBufferParams({pointSize:this.pointSize,sizeAttenuation:this.sizeAttenuation,sortParticles:this.sortParticles,useTexture:this.useTexture,alphaTest:this.alphaTest,forceTransparent:this.forceTransparent,edgeBleach:this.edgeBleach})),this.bufferList.push(this.dotBuffer)}update(t={}){if(0===this.bufferList.length)return;const e={};t.color&&(this.volume?Object.assign(e,{color:this.volume.getDataColor(this.getColorParams())}):Object.assign(e,{color:this.surface.getColor(this.getColorParams())})),"sphere"===this.dotType&&(t.radius||t.scale)&&(this.volume?Object.assign(e,{radius:this.volume.getDataSize(this.radius,this.scale)}):Object.assign(e,{radius:this.surface.getSize(this.radius,this.scale)})),this.dotBuffer.setAttributes(e)}setParameters(t,e={},i){return t&&void 0!==t.thresholdType&&this.volume instanceof Eo&&("value"===this.thresholdType&&"sigma"===t.thresholdType?(this.thresholdMin=this.volume.getSigmaForValue(this.thresholdMin),this.thresholdMax=this.volume.getSigmaForValue(this.thresholdMax)):"sigma"===this.thresholdType&&"value"===t.thresholdType&&(this.thresholdMin=this.volume.getValueForSigma(this.thresholdMin),this.thresholdMax=this.volume.getValueForSigma(this.thresholdMax)),this.thresholdType=t.thresholdType),t&&void 0!==t.radiusType&&("radius"===t.radiusType?this.radius=.1:this.radius=parseFloat(t.radiusType),e.radius=!0,"sphere"!==this.dotType||Ie&&!this.disableImpostor||(i=!0)),t&&void 0!==t.radius&&(e.radius=!0,"sphere"!==this.dotType||Ie&&!this.disableImpostor||(i=!0)),t&&void 0!==t.scale&&(e.scale=!0,"sphere"!==this.dotType||Ie&&!this.disableImpostor||(i=!0)),super.setParameters(t,e,i),this}}Ve.add("shader/Image.vert","uniform float clipRadius;\nuniform vec3 clipCenter;\nvarying vec2 vUv;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvarying vec3 vViewPosition;\n#endif\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\nvoid main() {\n#include begin_vertex\n#include project_vertex\nvUv = uv;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvViewPosition = -mvPosition.xyz;\n#endif\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n}"),Ve.add("shader/Image.frag","uniform sampler2D map;\nuniform float opacity;\nuniform vec2 mapSize;\nuniform float clipNear;\nuniform float clipRadius;\nvarying vec2 vUv;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvarying vec3 vViewPosition;\n#endif\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#if defined( PICKING )\nuniform sampler2D pickingMap;\nuniform float objectId;\n#else\n#include fog_pars_fragment\n#endif\n#if defined( CUBIC_INTERPOLATION )\n#if defined( CATMULROM_FILTER ) || defined( MITCHELL_FILTER )\n#if defined( CATMULROM_FILTER )\nconst float B = 0.0;\nconst float C = 0.5;\n#elif defined( MITCHELL_FILTER )\nconst float B = 0.333;\nconst float C = 0.333;\n#endif\nfloat filter( float x ){\nfloat f = x;\nif( f < 0.0 ){\nf = -f;\n}\nif( f < 1.0 ){\nreturn ( ( 12.0 - 9.0 * B - 6.0 * C ) * ( f * f * f ) +\n( -18.0 + 12.0 * B + 6.0 *C ) * ( f * f ) +\n( 6.0 - 2.0 * B ) ) / 6.0;\n}else if( f >= 1.0 && f < 2.0 ){\nreturn ( ( -B - 6.0 * C ) * ( f * f * f )\n+ ( 6.0 * B + 30.0 * C ) * ( f *f ) +\n( - ( 12.0 * B ) - 48.0 * C ) * f +\n8.0 * B + 24.0 * C ) / 6.0;\n}else{\nreturn 0.0;\n}\n}\n#elif defined( BSPLINE_FILTER )\nfloat filter( float x ){\nfloat f = x;\nif( f < 0.0 ){\nf = -f;\n}\nif( f >= 0.0 && f <= 1.0 ){\nreturn ( 2.0 / 3.0 ) + ( 0.5 ) * ( f * f * f ) - ( f * f );\n}else if( f > 1.0 && f <= 2.0 ){\nreturn 1.0 / 6.0 * pow( ( 2.0 - f ), 3.0 );\n}\nreturn 1.0;\n}\n#else\nfloat filter( float x ){\nreturn 1.0;\n}\n#endif\nvec4 biCubic( sampler2D tex, vec2 texCoord ){\nvec2 texelSize = 1.0 / mapSize;\ntexCoord -= texelSize / 2.0;\nvec4 nSum = vec4( 0.0 );\nfloat nDenom = 0.0;\nvec2 cell = fract( texCoord * mapSize );\nfor( float m = -1.0; m <= 2.0; ++m ){\nfor( float n = -1.0; n <= 2.0; ++n ){\nvec4 vecData = texture2D(\ntex, texCoord + texelSize * vec2( m, n )\n);\nfloat c = filter( m - cell.x ) * filter( -n + cell.y );\nnSum += vecData * c;\nnDenom += c;\n}\n}\nreturn nSum / nDenom;\n}\n#endif\nvoid main(){\n#include nearclip_fragment\n#include radiusclip_fragment\n#if defined( CUBIC_INTERPOLATION )\ngl_FragColor = biCubic( map, vUv );\n#else\ngl_FragColor = texture2D( map, vUv );\n#endif\n#if defined( PICKING )\nif( gl_FragColor.a < 0.3 )\ndiscard;\ngl_FragColor = vec4( texture2D( pickingMap, vUv ).xyz, objectId );\n#else\nif( gl_FragColor.a < 0.01 )\ndiscard;\ngl_FragColor.a *= opacity;\n#include fog_fragment\n#endif\n}");const Xc=new Uint16Array([0,1,2,1,3,2]),Yc=new Float32Array([0,1,0,0,1,1,1,0]),Kc=Object.assign({filter:"nearest",forceTransparent:!0},zo),Zc=Object.assign({filter:{updateShader:!0,uniform:!0}},Vo);class Qc extends Go{constructor(e,i){super({position:e.position,index:Xc,picking:e.picking},i),this.parameterTypes=Zc,this.alwaysTransparent=!0,this.hasWireframe=!1,this.vertexShader="Image.vert",this.fragmentShader="Image.frag";const{imageData:r,width:s,height:n}=e,o=new G(r,s,n);o.flipY=!0,this.tex=o;const a=r.length,c=new Uint8Array(a);for(let t=0;t>16&255,c[t+1]=e>>8&255,c[t+2]=255&e}const l=new G(c,s,n);l.flipY=!0,l.minFilter=x,l.magFilter=x,this.pickingTex=l,this.addUniforms({map:{value:o},pickingMap:{value:l},mapSize:{value:new t(s,n)}}),this.geometry.setAttribute("uv",new M(Yc,2))}get defaultParameters(){return Kc}getDefines(t){const e=super.getDefines(t),i=this.parameters.filter;return i.startsWith("cubic")&&(e.CUBIC_INTERPOLATION=1,i.endsWith("bspline")?e.BSPLINE_FILTER=1:i.endsWith("catmulrom")?e.CATMULROM_FILTER=1:i.endsWith("mitchell")&&(e.MITCHELL_FILTER=1)),e}updateTexture(){const t=this.tex,e=this.parameters.filter;e.startsWith("cubic")?(t.minFilter=x,t.magFilter=x):"linear"===e?(t.minFilter=A,t.magFilter=A):(t.minFilter=x,t.magFilter=x),t.needsUpdate=!0,this.pickingTex.needsUpdate=!0}makeMaterial(){super.makeMaterial(),this.updateTexture();const t=this.material;t.uniforms.map.value=this.tex,t.blending=U,t.needsUpdate=!0;const e=this.wireframeMaterial;e.uniforms.map.value=this.tex,e.blending=U,e.needsUpdate=!0;const i=this.pickingMaterial;i.uniforms.map.value=this.tex,i.uniforms.pickingMap.value=this.pickingTex,i.blending=U,i.needsUpdate=!0}setUniforms(t){t&&void 0!==t.filter&&(this.updateTexture(),t.map=this.tex),super.setUniforms(t)}}class Jc{constructor(t,e){const i=e||{};this.dimension=st(i.dimension,"x"),this.positionType=st(i.positionType,"percent"),this.position=st(i.position,30),this.thresholdType=st(i.thresholdType,"sigma"),this.thresholdMin=st(i.thresholdMin,-1/0),this.thresholdMax=st(i.thresholdMax,1/0),this.normalize=st(i.normalize,!1),this.volume=t}getPositionFromCoordinate(t){const i=this.dimension,r=this.volume,s=r.matrix,n=(new e).setFromMatrixPosition(s)[i],o=(new e).setFromMatrixScale(s)[i];let a;return a="x"===i?r.nx:"y"===i?r.ny:r.nz,Math.round(((t-n)/(a/100)+1)/o)}getData(t){t=t||{};const i=this.volume,r=i.data,s=i.matrix;let n;function o(t){return Math.round(t/100*(n-1))}function a(t,e,r,s){return 3*(r*i.ny*i.nx+e*i.nx+t)+s}n="coordinate"===this.positionType?this.getPositionFromCoordinate(this.position):this.position;const c=new Float32Array(12),l=new e;let h,d,u,m,p,f=0,g=0,y=0,b=i.nx,x=i.ny,v=i.nz;function w(t,e,i,r){l.set(t,e,i).applyMatrix4(s).toArray(c,r)}"x"===this.dimension?(u=o(i.nx),m=i.ny-1,p=i.nz-1,h=i.nz,d=i.ny,f=u,b=f+1,w(u,0,0,0),w(u,m,0,3),w(u,0,p,6),w(u,m,p,9)):"y"===this.dimension?(u=i.nx-1,m=o(i.ny),p=i.nz-1,h=i.nz,d=i.nx,g=m,x=g+1,w(0,m,0,0),w(u,m,0,3),w(0,m,p,6),w(u,m,p,9)):"z"===this.dimension&&(u=i.nx-1,m=i.ny-1,p=o(i.nz),h=i.nx,d=i.ny,y=p,v=y+1,w(0,0,p,0),w(0,m,p,3),w(u,0,p,6),w(u,m,p,9));let A=0,_=0;const S=new Uint8Array(h*d*4),C=new Float32Array(h*d);let P,I;"sigma"===this.thresholdType?(P=i.getValueForSigma(this.thresholdMin),I=i.getValueForSigma(this.thresholdMax)):(P=this.thresholdMin,I=this.thresholdMax);const k=Object.assign({},t.colorParams,{volume:i});this.normalize&&(k.domain=[0,1]);const M=Fe.getScheme(k),T=new Float32Array(3),B=M.getScale();let D,$=0,O=0;if(this.normalize){$=1/0,D=-1/0;for(let t=g;tD&&(D=s)}O=D-$}for(let t=g;tP&&n{this.viewer.add(t)})),this.setVisibility(this.visible),t()}create(){const t=new Jc(this.volume,{positionType:this.positionType,position:this.position,dimension:this.dimension,thresholdType:this.thresholdType,thresholdMin:this.thresholdMin,thresholdMax:this.thresholdMax,normalize:this.normalize}),e=new Qc(t.getData({colorParams:this.getColorParams()}),this.getBufferParams({filter:this.filter}));this.bufferList.push(e)}}function el(t){Me.error(`makeRepresentation: representation type ${t} unknown`)}const il={name:"some element",status:""};class rl{constructor(t,e={}){this.stage=t,this.signals={statusChanged:new et,nameChanged:new et,disposed:new et},this.parameters=nt(e,this.defaultParameters),this.uuid=Bt()}get defaultParameters(){return il}get name(){return this.parameters.name}setStatus(t){return this.parameters.status=t,this.signals.statusChanged.dispatch(t),this}setName(t){return this.parameters.name=t,this.signals.nameChanged.dispatch(t),this}dispose(){this.signals.disposed.dispatch()}}const sl=Object.assign({visible:!0},il);class nl extends rl{constructor(t,e,i={},r){super(t,Object.assign({name:e.type},i)),this.parent=r,this.signals=Object.assign({visibilityChanged:new et,parametersChanged:new et},this.signals),this.setRepresentation(e)}get defaultParameters(){return sl}get visible(){return this.parameters.visible}get type(){return"representation"}getType(){return this.repr.type}setRepresentation(t){this._disposeRepresentation(),this.repr=t,this.stage.tasks.listen(this.repr.tasks),this.updateVisibility()}_disposeRepresentation(){this.repr&&(this.stage.tasks.unlisten(this.repr.tasks),this.repr.dispose())}dispose(){this.parent&&this.parent.hasRepresentation(this)?this.parent.removeRepresentation(this):(this._disposeRepresentation(),this.signals.disposed.dispatch())}setVisibility(t){return this.parameters.visible=t,this.updateVisibility(),this.signals.visibilityChanged.dispatch(this.parameters.visible),this}getVisibility(){return this.parent?this.parent.parameters.visible&&this.parameters.visible:this.parameters.visible}toggleVisibility(){return this.setVisibility(!this.parameters.visible)}updateVisibility(){this.repr.setVisibility(this.getVisibility())}update(t){return this.repr.update(t),this}build(t){return this.repr.build(t),this}setSelection(t){const e=this.repr;return e.setSelection&&e.setSelection(t),this}setParameters(t){return this.repr.setParameters(t),this.signals.parametersChanged.dispatch(this.repr.getParameters()),this}getParameters(){return this.repr.getParameters()}setColor(t){return this.repr.setColor(t),this}}const ol=new i,al=new e,cl={name:"",status:"",visible:!0};class ll{constructor(t,s,n={}){this.stage=t,this.object=s,this.signals={representationAdded:new et,representationRemoved:new et,visibilityChanged:new et,matrixChanged:new et,statusChanged:new et,nameChanged:new et,disposed:new et},this.reprList=[],this.annotationList=[],this.matrix=new i,this.position=new e,this.quaternion=new r,this.scale=new e(1,1,1),this.transform=new i,this.parameters=nt(n,this.defaultParameters),this.uuid=Bt(),this.viewer=t.viewer,this.controls=new ua(this)}get defaultParameters(){return cl}get name(){return this.parameters.name}get status(){return this.parameters.status}get visible(){return this.parameters.visible}setPosition(t){return Array.isArray(t)?this.position.fromArray(t):this.position.copy(t),this.updateMatrix(),this}setRotation(t){if(Array.isArray(t))if(3===t.length){const e=(new j).fromArray(t);this.quaternion.setFromEuler(e)}else this.quaternion.fromArray(t);else t instanceof j?this.quaternion.setFromEuler(t):this.quaternion.copy(t);return this.updateMatrix(),this}setScale(t){return this.scale.set(t,t,t),this.updateMatrix(),this}setTransform(t){return this.transform.copy(t),this.updateMatrix(),this}updateMatrix(){const t=this.getCenterUntransformed(al);this.matrix.makeTranslation(-t.x,-t.y,-t.z),ol.makeRotationFromQuaternion(this.quaternion),this.matrix.premultiply(ol),ol.makeScale(this.scale.x,this.scale.y,this.scale.z),this.matrix.premultiply(ol);const e=this.position;ol.makeTranslation(e.x+t.x,e.y+t.y,e.z+t.z),this.matrix.premultiply(ol),this.matrix.premultiply(this.transform),this.updateRepresentationMatrices(),this.stage.viewer.updateBoundingBox(),this.signals.matrixChanged.dispatch(this.matrix)}updateRepresentationMatrices(){this.reprList.forEach((t=>{t.setParameters({matrix:this.matrix})}))}addAnnotation(t,e,i){const r=new ca(this,t,e,i);return this.annotationList.push(r),r}eachAnnotation(t){this.annotationList.slice().forEach(t)}removeAnnotation(t){const e=this.annotationList.indexOf(t);-1!==e&&(this.annotationList.splice(e,1),t.dispose())}removeAllAnnotations(){this.eachAnnotation((t=>t.dispose())),this.annotationList.length=0}_addRepresentation(t,e,i,r=!1){const s=i||{},n=this.stage.getParameters();s.matrix=this.matrix.clone(),s.quality=s.quality||n.quality,s.disableImpostor=st(s.disableImpostor,!n.impostor),s.useWorker=st(s.useWorker,n.workerDefault),s.visible=st(s.visible,!0);const o=Object.assign({},s,{visible:this.parameters.visible&&s.visible}),a=function(t,e,i,r){var s;if(De&&Me.time("makeRepresentation "+t),e instanceof Cc){if(!(s=Ne.get(t)))return void el(t)}else if(e instanceof Oo)if("surface"===t)s=Yo;else{if("dot"!==t)return void el(t);s=qc}else if(e instanceof Eo)if("surface"===t)s=Yo;else if("dot"===t)s=qc;else{if("slice"!==t)return void el(t);s=tl}else if(e instanceof Mc)s=Tc,e=e.getBufferList();else{if("buffer"!==t)return void Me.error("makeRepresentation: object "+e+" unknown");s=Tc}const n=new s(e,i,r);return De&&Me.timeEnd("makeRepresentation "+t),n}(t,e,this.viewer,o),c=new nl(this.stage,a,s,this);return r||(this.reprList.push(c),this.signals.representationAdded.dispatch(c)),c}addBufferRepresentation(t,e){return this._addRepresentation.call(this,"buffer",t,e)}hasRepresentation(t){return-1!==this.reprList.indexOf(t)}eachRepresentation(t){this.reprList.slice().forEach(t)}removeRepresentation(t){const e=this.reprList.indexOf(t);-1!==e&&(this.reprList.splice(e,1),t.dispose(),this.signals.representationRemoved.dispatch(t))}updateRepresentations(t){this.reprList.forEach((e=>e.update(t))),this.stage.viewer.requestRender()}removeAllRepresentations(){this.eachRepresentation((t=>t.dispose()))}dispose(){this.removeAllAnnotations(),this.removeAllRepresentations(),this.reprList.length=0,this.signals.disposed.dispatch()}setVisibility(t){return this.parameters.visible=t,this.eachRepresentation((t=>t.updateVisibility())),this.eachAnnotation((t=>t.updateVisibility())),this.signals.visibilityChanged.dispatch(t),this}setStatus(t){return this.parameters.status=t,this.signals.statusChanged.dispatch(t),this}setName(t){return this.parameters.name=t,this.signals.nameChanged.dispatch(t),this}getBox(...t){return this.getBoxUntransformed(...t).clone().applyMatrix4(this.matrix)}getCenter(...t){return this.getCenterUntransformed(...t).clone().applyMatrix4(this.matrix)}getZoom(...t){return this.stage.getZoomForBox(this.getBox(...t))}getBoxUntransformed(...t){return new a}getCenterUntransformed(...t){return this.getBoxUntransformed().getCenter(new e)}autoView(t){this.stage.animationControls.zoomMove(this.getCenter(),this.getZoom(),st(t,0))}}class hl{constructor(t=[]){this.list=t;const e=t.length;for(let i=0;i0?this.list[0]:void 0}forEach(t){return this.list.forEach(t),this}dispose(){return this.forEach((t=>t.dispose()))}}class dl extends hl{setParameters(t){return this.forEach((e=>e.setParameters(t)))}setVisibility(t){return this.forEach((e=>e.setVisibility(t)))}setSelection(t){return this.forEach((e=>e.setSelection(t)))}setColor(t){return this.forEach((e=>e.setColor(t)))}update(t){return this.forEach((e=>e.update(t)))}build(t){return this.forEach((e=>e.build(t)))}dispose(t){return this.forEach((t=>t.dispose()))}}const ul=Object.assign({defaultStep:1,defaultTimeout:50,defaultInterpolateType:"",defaultInterpolateStep:5,defaultMode:"loop",defaultDirection:"forward",initialFrame:0},il);class ml extends rl{constructor(t,e,i={}){super(t,Object.assign({name:e.name},i)),this.trajectory=e,this.signals=Object.assign(this.signals,{frameChanged:new et,playerChanged:new et,countChanged:new et,parametersChanged:new et}),e.signals.frameChanged.add((t=>{this.signals.frameChanged.dispatch(t)})),e.signals.playerChanged.add((t=>{this.signals.playerChanged.dispatch(t)})),e.signals.countChanged.add((t=>{this.signals.countChanged.dispatch(t)})),void 0!==i.initialFrame&&this.setFrame(i.initialFrame)}get defaultParameters(){return ul}get type(){return"trajectory"}setFrame(t){this.trajectory.setFrame(t)}setParameters(t={}){this.trajectory.setParameters(t),this.signals.parametersChanged.dispatch(t)}dispose(){this.trajectory.dispose(),super.dispose()}}class pl{constructor(t,e){this.name=t,this.path=e,this.coordinates=[],this.boxes=[],this.times=[],this.timeOffset=0,this.deltaTime=1}get type(){return"Frames"}}class fl{constructor(t,e){let r,s;if(this.A=new ho(3,3),this.W=new ho(1,3),this.U=new ho(3,3),this.V=new ho(3,3),this.VH=new ho(3,3),this.R=new ho(3,3),this.tmp=new ho(3,3),this.c=new ho(3,3),t instanceof Cc)r=t.atomCount;else{if(!(t instanceof Float32Array))return;r=t.length/3}if(e instanceof Cc)s=e.atomCount;else{if(!(e instanceof Float32Array))return;s=e.length/3}const n=Math.min(r,s),o=new ho(3,n),a=new ho(3,n);this.coords1t=new ho(n,3),this.coords2t=new ho(n,3),this.transformationMatrix=new i,this.c.data.set([1,0,0,0,1,0,0,0,-1]),this.prepCoords(t,o,n,!1),this.prepCoords(e,a,n,!1),this._superpose(o,a)}_superpose(t,e){this.mean1=fo(t),this.mean2=fo(e),go(t,this.mean1),go(e,this.mean2),uo(this.coords1t,t),uo(this.coords2t,e),mo(this.A,this.coords2t,this.coords1t),wo(this.A,this.W,this.U,this.V),function(t,e){const i=t.data,r=e.data,s=i[4],n=i[8],o=i[5],a=i[7],c=i[0],l=c*s,h=c*o,d=i[3],u=i[1],m=d*u,p=i[2],f=d*p,g=i[6],y=g*u,b=g*p,x=1/(l*n-h*a-m*n+f*a+y*o-b*s);r[0]=(s*n-o*a)*x,r[1]=-(u*n-p*a)*x,r[2]=-(-u*o+p*s)*x,r[3]=-(d*n-o*g)*x,r[4]=(c*n-b)*x,r[5]=-(h-f)*x,r[6]=-(-d*a+s*g)*x,r[7]=-(c*a-y)*x,r[8]=(l-m)*x}(this.V,this.VH),po(this.R,this.U,this.VH),function(t){const e=t.data;return e[0]*e[4]*e[8]-e[0]*e[5]*e[7]-e[3]*e[1]*e[8]+e[3]*e[2]*e[7]+e[6]*e[1]*e[5]-e[6]*e[2]*e[4]}(this.R)<0&&(De&&Me.log("R not a right handed system"),po(this.tmp,this.c,this.VH),po(this.R,this.U,this.tmp));const i=new ho(4,4),r=new ho(4,4),s=new ho(4,4),n=new ho(4,4),o=new ho(4,4),a=new ho(4,4),c=this.R.data,l=this.mean1,h=this.mean2;n.data.set([1,0,0,-l[0],0,1,0,-l[1],0,0,1,-l[2],0,0,0,1]),o.data.set([c[0],c[1],c[2],0,c[3],c[4],c[5],0,c[6],c[7],c[8],0,0,0,0,1]),a.data.set([1,0,0,h[0],0,1,0,h[1],0,0,1,h[2],0,0,0,1]),uo(r,n),mo(i,o,r),uo(s,i),mo(r,a,s),uo(i,r),this.transformationMatrix.elements=i.data}prepCoords(t,e,i,r){let s=0;const n=e.data;let o=3,a=3*i;if(r&&(a=4*i,o=4),t instanceof Cc)t.eachAtom((function(t){s{t!==this&&this.pause()}),this);const i=st(t.frameCount,1);this.traj=t,this.parameters=nt(e,gl),this.parameters.end=Math.min(st(e.end,i-1),i-1),this.parameters.step=st(e.step,Math.ceil((i+1)/100)),this._currentFrame=this.parameters.start,this._direction="bounce"===this.parameters.direction?"forward":this.parameters.direction,t.signals.countChanged.add((t=>{this.parameters.end=Math.min(st(this.parameters.end,t-1),t-1)}),this),this._animate=this._animate.bind(this)}get isRunning(){return this._run}setParameters(t={}){ot(this.parameters,t),void 0!==t.direction&&"bounce"!==this.parameters.direction&&(this._direction=this.parameters.direction)}_animate(){if(!this._run)return;this._currentTime=window.performance.now();const t=this._currentTime-this._previousTime,e=this.parameters.interpolateType?this.parameters.interpolateStep:1,i=this.parameters.timeout/e,r=this.traj;if(r&&r.frameCount&&!r.inProgress&&t>=i)if(this.parameters.interpolateType)if(this._currentStep>this.parameters.interpolateStep&&(this._currentStep=1),1===this._currentStep&&(this._currentFrame=this._nextInterpolated()),r.hasFrame(this._currentFrame)){this._currentStep+=1;const t=this._currentStep/(this.parameters.interpolateStep+1),[e,i,s,n]=this._currentFrame;r.setFrameInterpolated(e,i,s,n,t,this.parameters.interpolateType),this._previousTime=this._currentTime}else r.loadFrame(this._currentFrame);else{const t=this._next();r.hasFrame(t)?(r.setFrame(t),this._previousTime=this._currentTime):r.loadFrame(t)}window.requestAnimationFrame(this._animate)}_next(){const t=this.parameters;let e;return e="forward"===this._direction?this.traj.currentFrame+t.step:this.traj.currentFrame-t.step,(e>t.end||e=t.end?i=t.start:"backward"===t.direction&&e<=t.start&&(i=t.end),this.traj.setFrame(i),this._run=!0,this._animate(),this.signals.startedRunning.dispatch()}}pause(){this._run=!1,this.signals.haltedRunning.dispatch()}stop(){this.pause(),this.traj.setFrame(this.parameters.start)}}class bl{constructor(t,e,i={}){this.signals={countChanged:new et,frameChanged:new et,playerChanged:new et},this.frameCache={},this.loadQueue={},this.boxCache={},this.pathCache={},this.frameCacheSize=0,this._frameCount=0,this._currentFrame=-1,this._disposed=!1,this.deltaTime=st(i.deltaTime,0),this.timeOffset=st(i.timeOffset,0),this.centerPbc=st(i.centerPbc,!1),this.removePbc=st(i.removePbc,!1),this.removePeriodicity=st(i.removePeriodicity,!1),this.superpose=st(i.superpose,!1),this.name=t.replace(/^.*[\\/]/,""),this.trajPath=t,this.selection=new pe(st(i.sele,"backbone and not hydrogen")),this.selection.signals.stringChanged.add((()=>{this.selectionIndices=this.structure.getAtomIndices(this.selection),this._resetCache(),this._saveInitialCoords(),this.setFrame(this._currentFrame)}))}get frameCount(){return this._frameCount}get currentFrame(){return this._currentFrame}_init(t){this.setStructure(t),this._loadFrameCount(),this.setPlayer(new yl(this))}_loadFrameCount(){}setStructure(t){this.structure=t,this.atomCount=t.atomCount,this.backboneIndices=this._getIndices(new pe("backbone and not hydrogen")),this._makeAtomIndices(),this._saveStructureCoords(),this.selectionIndices=this._getIndices(this.selection),this._resetCache(),this._saveInitialCoords(),this.setFrame(this._currentFrame)}_saveInitialCoords(){this.structure.hasCoords()?(this.initialCoords=new Float32Array(this.structureCoords),this._makeSuperposeCoords()):this.frameCache[0]?(this.initialCoords=new Float32Array(this.frameCache[0]),this._makeSuperposeCoords()):this.loadFrame(0,(()=>this._saveInitialCoords()))}_saveStructureCoords(){this.structureCoords=this.structure.getAtomData({what:{position:!0}}).position}setSelection(t){return this.selection.setString(t),this}_getIndices(t){let e=0;const i=t.test,r=[];return i&&this.structure.eachAtom((t=>{i(t)&&r.push(e),e+=1})),r}_makeSuperposeCoords(){const t=3*this.selectionIndices.length;this.coords1=new Float32Array(t),this.coords2=new Float32Array(t);const e=this.initialCoords,i=this.coords2;for(let r=0;r!!this.frameCache[t])):!!this.frameCache[t]}setFrame(t,e){return void 0===t||(this.inProgress=!0,-1===t||this.frameCache[t]?(this._updateStructure(t),e&&e()):this.loadFrame(t,(()=>{this._updateStructure(t),e&&e()}))),this}_interpolate(t,e,i,r,s,n){const o=this.frameCache;let a;a="spline"===n?function(t,e,i,r,s){const n=t.length,o=new Float32Array(n);for(let a=0;a{this._interpolate(t,e,i,r,s,n),o&&o()})):(this._interpolate(t,e,i,r,s,n),o&&o()),this}loadFrame(t,e){Array.isArray(t)?t.forEach((t=>{this.loadQueue[t]||this.frameCache[t]||(this.loadQueue[t]=!0,this._loadFrame(t,(()=>{delete this.loadQueue[t]})))})):this.loadQueue[t]||this.frameCache[t]||(this.loadQueue[t]=!0,this._loadFrame(t,(()=>{delete this.loadQueue[t],e&&e()})))}_loadFrame(t,e){Me.error("Trajectory._loadFrame not implemented",t,e)}_updateStructure(t){this._disposed?console.error("updateStructure: traj disposed"):(-1===t?this.structureCoords&&this.structure.updatePosition(this.structureCoords):this.structure.updatePosition(this.frameCache[t]),this.structure.trajectory={name:this.trajPath,frame:t},this._currentFrame=t,this.inProgress=!1,this.signals.frameChanged.dispatch(t))}_doSuperpose(t){const e=3*this.selectionIndices.length,i=this.coords1,r=this.coords2;for(let r=0;r0&&this.centerPbc){const t=[e[0],e[4],e[8]],r=function(t,e,i){return[wi(e,i[0],3,0,t),wi(e,i[1],3,1,t),wi(e,i[2],3,2,t)]}(this.backboneIndices,i,t);!function(t,e,i){if(0===i[0]||0===i[8]||0===i[4])return;const r=t.length,s=i[0],n=i[1],o=i[2],a=-e[0]+s+s/2,c=-e[1]+n+n/2,l=-e[2]+o+o/2;for(let e=0;e.5&&(t[s+r]-=e[3*r+r]*Math.round(n))}}(i,e,t)}this.removePbc&&function(t,e){if(0===e[0]||0===e[8]||0===e[4])return;const i=t.length;for(let r=3;r.9*e[3*i+i])if(s>0)for(let s=0;s<3;++s)t[r+s]-=e[3*i+s];else for(let s=0;s<3;++s)t[r+s]+=e[3*i+s]}}(i,e)}this.selectionIndices.length>0&&this.coords1&&this.superpose&&this._doSuperpose(i),this.frameCache[t]=i,this.boxCache[t]=e,this.frameCacheSize+=1}_setFrameCount(t){t!==this._frameCount&&(this._frameCount=t,this.signals.countChanged.dispatch(t))}dispose(){this._resetCache(),this._disposed=!0,this.player&&this.player.stop()}setPlayer(t){this.player=t,this.signals.playerChanged.dispatch(t)}getFrameTime(t){return this.timeOffset+t*this.deltaTime}}class xl extends bl{constructor(t,e,i){const r=i||{};r.timeOffset=st(r.timeOffset,t.timeOffset),r.deltaTime=st(r.deltaTime,t.deltaTime),super("",e,r),this.name=t.name,this.path=t.path,this.frames=t.coordinates,this.boxes=t.boxes,this._init(e)}get type(){return"frames"}_makeAtomIndices(){"StructureView"===this.structure.type?this.atomIndices=this.structure.getAtomIndices():this.atomIndices=void 0}_loadFrame(t,e){let i;const r=this.frames[t];if(this.atomIndices){const t=this.atomIndices,e=t.length;i=new Float32Array(3*e);for(let s=0;s{const s=i.response;if(!s)return void Me.error(`empty arrayBuffer for '${r}'`);const n=new Int32Array(s,0,1)[0],o=new Float32Array(s,8,9),a=new Float32Array(s,44);this._process(t,o,a,n),"function"==typeof e&&e()}),!1),i.send(s)}_loadFrameCount(){const t=new XMLHttpRequest,e=qe.getCountUrl(this.trajPath);t.open("GET",e,!0),t.addEventListener("load",(()=>{this._setFrameCount(parseInt(t.response))}),!1),t.send()}}class Al extends bl{constructor(t,e,i){super("",e,i),this.requestCallback=t,this._init(e)}get type(){return"callback"}_makeAtomIndices(){const t=[];if("StructureView"===this.structure.type){const e=this.structure.getAtomIndices(),i=e.length;let r=e[0],s=e[0];for(let n=1;n{this._process(t,i,r,s),"function"==typeof e&&e()}),t,this.atomIndices)}_loadFrameCount(){this.requestCallback((t=>this._setFrameCount(t)))}}Cc.prototype.getView=function(t){return new _l(this,t)};class _l extends Cc{constructor(t,i){super(),this.structure=t,this.selection=i,this.center=new e,this.boundingBox=new a,this._bp=this.getBondProxy(),this._ap=this.getAtomProxy(),this._rp=this.getResidueProxy(),this._cp=this.getChainProxy(),this.selection&&this.selection.signals.stringChanged.add(this.refresh,this),this.structure.signals.refreshed.add(this.refresh,this),this.refresh()}init(){}get type(){return"StructureView"}get name(){return this.structure.name}get path(){return this.structure.path}get title(){return this.structure.title}get id(){return this.structure.id}get data(){return this.structure.data}get atomSetDict(){return this.structure.atomSetDict}get biomolDict(){return this.structure.biomolDict}get entityList(){return this.structure.entityList}get unitcell(){return this.structure.unitcell}get frames(){return this.structure.frames}get boxes(){return this.structure.boxes}get validation(){return this.structure.validation}get bondStore(){return this.structure.bondStore}get backboneBondStore(){return this.structure.backboneBondStore}get rungBondStore(){return this.structure.rungBondStore}get atomStore(){return this.structure.atomStore}get residueStore(){return this.structure.residueStore}get chainStore(){return this.structure.chainStore}get modelStore(){return this.structure.modelStore}get atomMap(){return this.structure.atomMap}get residueMap(){return this.structure.residueMap}get bondHash(){return this.structure.bondHash}get spatialHash(){return this.structure.spatialHash}get _hasCoords(){return this.structure._hasCoords}set _hasCoords(t){this.structure._hasCoords=t}refresh(){De&&Me.time("StructureView.refresh"),this.atomSetCache={};const t=this.structure;if(this.selection.isAllSelection()&&t!==this&&t.atomSet&&t.bondSet){this.atomSet=t.atomSet.clone(),this.bondSet=t.bondSet.clone();for(let t in this.atomSetDict){const e=this.atomSetDict[t];this.atomSetCache["__"+t]=e.clone()}this.atomCount=t.atomCount,this.bondCount=t.bondCount,this.boundingBox.copy(t.boundingBox),this.center.copy(t.center)}else if(this.selection.isNoneSelection()&&t!==this&&t.atomSet&&t.bondSet){this.atomSet=new Os(t.atomCount),this.bondSet=new Os(t.bondCount);for(let e in this.atomSetDict)this.atomSetCache["__"+e]=new Os(t.atomCount);this.atomCount=0,this.bondCount=0,this.boundingBox.makeEmpty(),this.center.set(0,0,0)}else{this.atomSet=this.getAtomSet(this.selection,!0),t.atomSet&&(this.atomSet=this.atomSet.intersection(t.atomSet)),this.bondSet=this.getBondSet();for(let t in this.atomSetDict){const e=this.atomSetDict[t];this.atomSetCache["__"+t]=e.makeIntersection(this.atomSet)}this.atomCount=this.atomSet.getSize(),this.bondCount=this.bondSet.getSize(),this.boundingBox=this.getBoundingBox(),this.center=this.boundingBox.getCenter(new e)}De&&Me.timeEnd("StructureView.refresh"),this.signals.refreshed.dispatch()}setSelection(t){this.selection=t,this.refresh()}getSelection(t){const e=[];t&&t.string&&e.push(t.string);const i=this.structure.getSelection();i&&i.string&&e.push(i.string),this.selection&&this.selection.string&&e.push(this.selection.string);let r="";return e.length>0&&(r=`( ${e.join(" ) AND ( ")} )`),new pe(r)}getStructure(){return this.structure.getStructure()}eachBond(t,e){this.structure.eachBond(t,this.getSelection(e))}eachAtom(t,e){const i=this.getAtomProxy(),r=this.getAtomSet(e),s=this.atomStore.count;if(r.getSize()=this.V[i][r]?(e="S",this.score=this.S[i][r]):this.V[i][r]>=this.H[i][r]?(e="V",this.score=this.V[i][r]):(e="H",this.score=this.H[i][r]),De&&Me.log("Alignment: SCORE",this.score),De&&Me.log("Alignment: S, V, H",this.S[i][r],this.V[i][r],this.H[i][r]);i>0&&r>0;)"S"===e?this.S[i][r]===this.S[i-1][r-1]+t(i-1,r-1)?(this.ali1=this.seq1[i-1]+this.ali1,this.ali2=this.seq2[r-1]+this.ali2,--i,--r,e="S"):this.S[i][r]===this.V[i][r]?e="V":this.S[i][r]===this.H[i][r]?e="H":(--i,--r):"V"===e?this.V[i][r]===this.V[i-1][r]+this.gapExtensionPenalty?(this.ali1=this.seq1[i-1]+this.ali1,this.ali2="-"+this.ali2,--i,e="V"):this.V[i][r]===this.S[i-1][r]+this.gap(0)?(this.ali1=this.seq1[i-1]+this.ali1,this.ali2="-"+this.ali2,--i,e="S"):--i:"H"===e?this.H[i][r]===this.H[i][r-1]+this.gapExtensionPenalty?(this.ali1="-"+this.ali1,this.ali2=this.seq2[r-1]+this.ali2,--r,e="H"):this.H[i][r]===this.S[i][r-1]+this.gap(0)?(this.ali1="-"+this.ali1,this.ali2=this.seq2[r-1]+this.ali2,--r,e="S"):--r:Me.error("Alignment: no matrix");for(;i>0;)this.ali1=this.seq1[i-1]+this.ali1,this.ali2="-"+this.ali2,--i;for(;r>0;)this.ali1="-"+this.ali1,this.ali2=this.seq2[r-1]+this.ali2,--r;De&&Me.timeEnd("Alignment.trace"),De&&Me.log([this.ali1,this.ali2])}}function kl(t,e,i=!1,r="",s=""){let n,o,a,c,l;if(i){let i=t,h=e;r&&s&&(i=t.getView(new pe(r)),h=e.getView(new pe(s)));const d=i.getSequence(),u=h.getSequence(),m=new Il(d.join(""),u.join(""));let p,f;m.calc(),m.trace(),n=0,o=0,a=m.ali1.length;const g=[],y=[];for(let t=0;tt[e]))}}}(),this.spacefillRepresentation=this.addRepresentation("spacefill",{sele:"none",opacity:Te.opacity,color:Te.color,disablePicking:!0,radiusType:"data"},!0),this.distanceRepresentation=this.addRepresentation("distance",Te,!0),this.angleRepresentation=this.addRepresentation("angle",Te,!0),this.dihedralRepresentation=this.addRepresentation("dihedral",Te,!0),this.measureRepresentations=new dl([this.spacefillRepresentation,this.distanceRepresentation,this.angleRepresentation,this.dihedralRepresentation]),this.setDefaultAssembly(this.parameters.defaultAssembly),this.structure.signals.refreshed.add((()=>{this.updateRepresentations({position:!0})}))}get defaultParameters(){return Ml}get type(){return"structure"}initSelection(t){this.selection=new pe(t),this.structureView=new _l(this.structure,this.selection),this.selection.signals.stringChanged.add((()=>{this.structureView.setSelection(this.selection),this.rebuildRepresentations(),this.rebuildTrajectories()}))}setSelection(t){return this.parameters.sele=t,this.selection.setString(t),this}setDefaultAssembly(t){if(void 0===this.structure.biomolDict[t]&&(t=""),this.parameters.defaultAssembly!==t){const e={defaultAssembly:t};this.reprList.forEach((t=>t.setParameters(e))),this.measureRepresentations.setParameters(e),this.parameters.defaultAssembly=t,this.signals.defaultAssemblyChanged.dispatch(t)}return this}rebuildRepresentations(){this.reprList.forEach((t=>{t.build()})),this.measureRepresentations.build()}rebuildTrajectories(){this.trajList.forEach((t=>{t.trajectory.setStructure(this.structureView)}))}updateRepresentations(t){super.updateRepresentations(t),this.measureRepresentations.update(t)}updateRepresentationMatrices(){super.updateRepresentationMatrices(),this.measureRepresentations.setParameters({matrix:this.matrix})}addRepresentation(t,e={},i=!1){e.defaultAssembly=this.parameters.defaultAssembly;const r=this._addRepresentation(t,this.structureView,e,i);return i||r.signals.parametersChanged.add((()=>this.measureUpdate())),r}addTrajectory(t="",e={}){const i=function(t,e,i){let r;return r=t&&t instanceof pl?new xl(t,e,i):!t&&e.frames?new vl(t,e,i):t&&"function"==typeof t?new Al(t,e,i):new wl(t,e,i),r}(t,this.structureView,e),r=new ml(this.stage,i,e);return this.trajList.push(r),this.signals.trajectoryAdded.dispatch(r),r}removeTrajectory(t){const e=this.trajList.indexOf(t);-1!==e&&this.trajList.splice(e,1),t.dispose(),this.signals.trajectoryRemoved.dispatch(t)}dispose(){this.trajList.slice().forEach((t=>t.dispose())),this.trajList.length=0,this.structure.dispose(),this.measureRepresentations.dispose(),super.dispose()}autoView(t,e){"number"==typeof t&&(e=t,t=""),this.stage.animationControls.zoomMove(this.getCenter(t),this.getZoom(t),st(e,0))}getBoxUntransformed(t){let e;return e=t?this.structureView.getBoundingBox(new pe(t)):this.structureView.boundingBox,e}getCenterUntransformed(t){return t&&"string"==typeof t?this.structure.atomCenter(new pe(t)):this.structure.center}superpose(t,e,i,r){return kl(this.structureView,t.structureView,e,i,r),this.updateRepresentations({position:!0}),this}getMaxRepresentationRadius(t){let e=0;const i=this.structure.getAtomProxy(t);return this.eachRepresentation((t=>{if(t.getVisibility()){const r=t.repr;e=Math.max(r.getAtomRadius(i),e)}})),e}measurePick(t){const e=this.pickBuffer.count;if(this.lastPick===t.index&&e>=1){if(e>1){const t=this.pickBuffer.data,i=this.pickBuffer.data.sort();this.pickDict.has(i)?this.pickDict.del(i):this.pickDict.add(i,t),2===e?this.distanceRepresentation.setParameters({atomPair:this.pickDict.values.filter((t=>2===t.length))}):3===e?this.angleRepresentation.setParameters({atomTriple:this.pickDict.values.filter((t=>3===t.length))}):4===e&&this.dihedralRepresentation.setParameters({atomQuad:this.pickDict.values.filter((t=>4===t.length))})}this.pickBuffer.clear(),this.lastPick=void 0}else this.pickBuffer.has(t.index)||this.pickBuffer.push(t.index),this.lastPick=t.index;this.measureUpdate()}measureClear(){this.pickBuffer.clear(),this.lastPick=void 0,this.spacefillRepresentation.setSelection("none")}measureBuild(){const t=this.measureData();this.distanceRepresentation.setParameters({atomPair:t.distance}),this.angleRepresentation.setParameters({atomTriple:t.angle}),this.dihedralRepresentation.setParameters({atomQuad:t.dihedral})}measureUpdate(){const t=this.pickBuffer.data,e={};t.forEach((t=>{const i=Math.max(.1,this.getMaxRepresentationRadius(t));e[t]=i*(2.3-Rt(.1,2,i))})),this.spacefillRepresentation.setSelection(t.length?"@"+t.join(","):"none"),t.length&&this.spacefillRepresentation.setParameters({radiusData:e})}measureData(){const t=this.pickDict.values;return{distance:t.filter((t=>2===t.length)),angle:t.filter((t=>3===t.length)),dihedral:t.filter((t=>4===t.length))}}removeAllMeasurements(t){const e=this.pickDict,i=e.values,r=function(t){i.filter((e=>e.length===t)).forEach((t=>e.del(t.slice().sort())))};(!t||1&t)&&r(2),(!t||2&t)&&r(3),(!t||4&t)&&r(4),this.measureBuild()}removeMeasurement(t){this.pickDict.del(t.slice().sort()),this.measureBuild()}addMeasurement(t){if(t.length<2||t.length>4)return;const e=t.slice().sort();this.pickDict.has(e)||this.pickDict.add(e,t),this.measureBuild()}}Ue.add("structure",Tl),Ue.add("structureview",Tl);class Bl extends ll{constructor(t,e,i={}){super(t,e,Object.assign({name:e.name},i)),this.surface=e}get type(){return"surface"}addRepresentation(t,e={}){return this._addRepresentation(t,this.surface,e)}getBoxUntransformed(){return this.surface.boundingBox}getCenterUntransformed(){return this.surface.center}dispose(){this.surface.dispose(),super.dispose()}}Ue.add("surface",Bl);class Dl extends ll{constructor(t,e,i={}){super(t,e,Object.assign({name:e.name},i)),this.volume=e}get type(){return"volume"}addRepresentation(t,e={}){return this._addRepresentation(t,this.volume,e)}getBoxUntransformed(){return this.volume.boundingBox}getCenterUntransformed(){return this.volume.center}dispose(){this.volume.dispose(),super.dispose()}}Ue.add("volume",Dl);class $l extends hl{addRepresentation(t,e){return this.forEach((i=>i.addRepresentation(t,e)))}autoView(t){return this.forEach((e=>e.autoView(t)))}}function Ol(t,e){return t instanceof RegExp?null!==e.name.match(t):e.name===t}const Rl=new e,El={impostor:!0,quality:"medium",workerDefault:!0,sampleLevel:0,backgroundColor:"black",rotateSpeed:2,zoomSpeed:1.2,panSpeed:1,clipNear:0,clipFar:100,clipDist:10,clipMode:"scene",clipScale:"relative",fogNear:50,fogFar:100,cameraFov:40,cameraEyeSep:.3,cameraType:"perspective",lightColor:14540253,lightIntensity:1,ambientColor:14540253,ambientIntensity:.2,hoverTimeout:0,tooltip:!0,mousePreset:"default"};class Fl{constructor(t,e={}){this.signals={parametersChanged:new et,fullscreenChanged:new et,componentAdded:new et,componentRemoved:new et,clicked:new et,hovered:new et},this.tasks=new ui,this.compList=[],this.defaultFileParams={},this.logList=[],this.viewer=new Ji(t),this.viewer.renderer&&(this.tooltip=document.createElement("div"),Object.assign(this.tooltip.style,{display:"none",position:"fixed",zIndex:"1000000",pointerEvents:"none",backgroundColor:"rgba( 0, 0, 0, 0.6 )",color:"lightgrey",padding:"8px",fontFamily:"sans-serif"}),this.viewer.container.appendChild(this.tooltip),this.mouseObserver=new sr(this.viewer.renderer.domElement),this.viewerControls=new kr(this),this.trackballControls=new gr(this),this.pickingControls=new xr(this),this.animationControls=new Lr(this),this.mouseControls=new Jo(this),this.keyControls=new ia(this),this.pickingBehavior=new ra(this),this.mouseBehavior=new sa(this),this.animationBehavior=new na(this),this.keyBehavior=new aa(this),this.spinAnimation=this.animationControls.spin([0,1,0],.005),this.spinAnimation.pause(!0),this.rockAnimation=this.animationControls.rock([0,1,0],.005),this.rockAnimation.pause(!0),this.parameters=nt(e,El),this.setParameters(this.parameters),this.viewer.animate())}setParameters(t={}){ot(this.parameters,t);const e=t,i=this.parameters,r=this.viewer,s=this.trackballControls;return void 0!==e.quality&&this.setQuality(i.quality),void 0!==e.impostor&&this.setImpostor(i.impostor),void 0!==e.rotateSpeed&&(s.rotateSpeed=i.rotateSpeed),void 0!==e.zoomSpeed&&(s.zoomSpeed=i.zoomSpeed),void 0!==e.panSpeed&&(s.panSpeed=i.panSpeed),void 0!==e.mousePreset&&this.mouseControls.preset(i.mousePreset),this.mouseObserver.setParameters({hoverTimeout:i.hoverTimeout}),r.setClip(i.clipNear,i.clipFar,i.clipDist,i.clipMode,i.clipScale),r.setFog(void 0,i.fogNear,i.fogFar),r.setCamera(i.cameraType,i.cameraFov,i.cameraEyeSep),r.setSampling(i.sampleLevel),r.setBackground(i.backgroundColor),r.setLight(i.lightColor,i.lightIntensity,i.ambientColor,i.ambientIntensity),this.signals.parametersChanged.dispatch(this.getParameters()),this}log(t){console.log("STAGE LOG",t),this.logList.push(t)}getParameters(){return Object.assign({},this.parameters)}defaultFileRepresentation(t){if(t instanceof Tl){let e,i,r;t.setSelection("/0");const s=t.structure;if(s.biomolDict.BU1){const n=s.biomolDict.BU1;e=n.getAtomCount(s),i=n.getResidueCount(s),r=n.getInstanceCount(),t.setDefaultAssembly("BU1")}else e=s.getModelProxy(0).atomCount,i=s.getModelProxy(0).residueCount,r=1;let n=e;Se&&(n*=4);const o=s.atomStore.count/s.residueStore.count<2;o&&(n*=10);let a="chainname",c="RdYlBu",l=!1;if(1===s.getChainnameCount(new pe("polymer and /0"))&&(a="residueindex",c="Spectral",l=!0),De&&console.log(n,e,r,o),i/r<4)t.addRepresentation("ball+stick",{colorScheme:"element",radiusScale:2,aspectRatio:1.5,bondScale:.3,bondSpacing:.75,quality:"auto"});else if(r>5&&n>15e3||n>7e5){let e=Math.min(2,Math.max(.1,6e3/(n/r)));o&&(e=Math.min(e,.5)),t.addRepresentation("surface",{colorScheme:a,colorScale:c,colorReverse:l,sele:"polymer",surfaceType:"av",probeRadius:1.4,scaleFactor:e,useWorker:!1})}else n>25e4?t.addRepresentation("backbone",{colorScheme:a,colorScale:c,colorReverse:l,lineOnly:!0}):n>1e5?t.addRepresentation("backbone",{colorScheme:a,colorScale:c,colorReverse:l,quality:"low",disableImpostor:!0,radiusScale:2}):n>8e4?t.addRepresentation("backbone",{colorScheme:a,colorScale:c,colorReverse:l,radiusScale:2}):(t.addRepresentation("cartoon",{colorScheme:a,colorScale:c,colorReverse:l,radiusScale:.7,aspectRatio:5,quality:"auto"}),n<5e4&&t.addRepresentation("base",{colorScheme:a,colorScale:c,colorReverse:l,quality:"auto"}),t.addRepresentation("ball+stick",{sele:"ligand",colorScheme:"element",radiusScale:2,aspectRatio:1.5,bondScale:.3,bondSpacing:.75,quality:"auto"}));t.structure.frames.length&&t.addTrajectory()}else(t instanceof Bl||t instanceof Dl)&&t.addRepresentation("surface");this.tasks.onZeroOnce(this.autoView,this)}loadFile(t,e={}){const i=Object.assign({},this.defaultFileParams,e),r=ri(t).name;this.tasks.increment(),this.log(`loading file '${r}'`);const s=st(i.ext,ri(t).ext);let n;return n=ze.isTrajectory(s)?Promise.reject(new Error(`loadFile: ext '${s}' is a trajectory and must be loaded into a structure component`)):ni(t,i),n.then((t=>{this.log(`loaded '${r}'`);const e=this.addComponentFromObject(t,i);return i.defaultRepresentation&&this.defaultFileRepresentation(e),this.tasks.decrement(),e}),(t=>{this.tasks.decrement();const e=`error loading file: '${t}'`;throw this.log(e),e}))}loadScript(t){const e=ri(t).name;return this.log(`loading script '${e}'`),ni(t).then((t=>{this.tasks.increment(),this.log(`running script '${e}'`),t.run(this).then((()=>{this.tasks.decrement(),this.log(`finished script '${e}'`)})),this.log(`called script '${e}'`)}),(t=>{this.tasks.decrement();const i=`errored script '${e}' "${t}"`;throw this.log(i),i}))}addComponent(t){t?(this.compList.push(t),this.signals.componentAdded.dispatch(t)):Me.warn("Stage.addComponent: no component given")}addComponentFromObject(t,e={}){const i=Ue.get(t.type);if(i){const r=new i(this,t,e);return this.addComponent(r),r}Me.warn("no component for object type",t.type)}removeComponent(t){const e=this.compList.indexOf(t);-1!==e&&(this.compList.splice(e,1),t.dispose(),this.signals.componentRemoved.dispatch(t))}removeAllComponents(){this.compList.slice().forEach((t=>this.removeComponent(t)))}handleResize(){this.viewer.handleResize()}setSize(t,e){const i=this.viewer.container;i!==document.body&&(void 0!==t&&(i.style.width=t),void 0!==e&&(i.style.height=e),this.handleResize())}toggleFullscreen(t){if(!(document.fullscreenEnabled||document.mozFullScreenEnabled||document.webkitFullscreenEnabled||document.msFullscreenEnabled))return void Me.log("fullscreen mode (currently) not possible");const e=this;function i(){return document.fullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement||document.msFullscreenElement}function r(){if(!i()&&e.lastFullscreenElement){const t=e.lastFullscreenElement;t.style.width=t.dataset.normalWidth||"",t.style.height=t.dataset.normalHeight||"",document.removeEventListener("fullscreenchange",r),document.removeEventListener("mozfullscreenchange",r),document.removeEventListener("webkitfullscreenchange",r),document.removeEventListener("MSFullscreenChange",r),e.handleResize(),e.signals.fullscreenChanged.dispatch(!1)}}t=t||this.viewer.container,this.lastFullscreenElement=t,i()?document.exitFullscreen?document.exitFullscreen():document.msExitFullscreen?document.msExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen&&document.webkitExitFullscreen():(t.dataset.normalWidth=t.style.width||"",t.dataset.normalHeight=t.style.height||"",t.style.width=window.screen.width+"px",t.style.height=window.screen.height+"px",t.requestFullscreen?t.requestFullscreen():t.msRequestFullscreen?t.msRequestFullscreen():t.mozRequestFullScreen?t.mozRequestFullScreen():t.webkitRequestFullscreen&&t.webkitRequestFullscreen(),document.addEventListener("fullscreenchange",r),document.addEventListener("mozfullscreenchange",r),document.addEventListener("webkitfullscreenchange",r),document.addEventListener("MSFullscreenChange",r),this.handleResize(),this.signals.fullscreenChanged.dispatch(!0),setTimeout((function(){e.handleResize()}),100))}setSpin(t){t?(this.spinAnimation.resume(!0),this.rockAnimation.pause(!0)):this.spinAnimation.pause(!0)}setRock(t){t?(this.rockAnimation.resume(!0),this.spinAnimation.pause(!0)):this.rockAnimation.pause(!0)}toggleSpin(){this.setSpin(this.spinAnimation.paused)}toggleRock(){this.setRock(this.rockAnimation.paused)}getFocus(){const t=this.parameters;if("scene"!==t.clipMode)return 0;let e=t.clipNear;return"absolute"===t.clipScale&&(e=this.viewer.absoluteToRelative(e)),2*e}setFocus(t){if("scene"!==this.parameters.clipMode)return;let e,i,r,s;"relative"===this.parameters.clipScale?(e=Dt(t/2,0,49.9),i=100-e,r=50,s=function(t){return Dt(t,0,100)}(2*i-50)):(e=this.viewer.relativeToAbsolute(t/2),i=e,r=0,s=2*i),this.setParameters({clipNear:e,clipFar:i,fogNear:r,fogFar:s})}getZoomForBox(t){const e=t.getSize(Rl),i=Math.max(e.x,e.y,e.z),r=Math.min(e.x,e.y,e.z);let s=i+Math.sqrt(r);const n=kt(this.viewer.perspectiveCamera.fov),o=this.viewer.width,a=this.viewer.height,c=a{this.tasks.onZeroOnce((()=>{this.tasks.increment(),this.viewer.makeImage(t).then((t=>{this.tasks.decrement(),e(t)})).catch((t=>{this.tasks.decrement(),i(t)}))}))}))}setImpostor(t){this.parameters.impostor=t;const e=["spacefill","ball+stick","licorice","hyperball","backbone","rocket","helixorient","contact","distance","dot"];this.eachRepresentation((function(i){if(!e.includes(i.getType()))return;const r=i.getParameters();r.disableImpostor=!t,i.build(r)}))}setQuality(t){this.parameters.quality=t;const e=["tube","cartoon","ribbon","trace","rope"],i=["spacefill","ball+stick","licorice","hyperball","backbone","rocket","helixorient","contact","distance","dot"];this.eachRepresentation((function(r){const s=r.getParameters();if(!e.includes(r.getType())){if(!i.includes(r.getType()))return;if(!s.disableImpostor)return void(r.repr.quality=t)}s.quality=t,r.build(s)}))}eachComponent(t,e){this.compList.slice().forEach((i=>{void 0!==e&&e!==i.type||t(i)}))}eachRepresentation(t,e){this.eachComponent((i=>{i.reprList.slice().forEach((r=>{void 0!==e&&e!==r.getType()||t(r,i)}))}))}getComponentsByName(t){const e=[];return this.eachComponent((i=>{(void 0===t||Ol(t,i))&&e.push(i)})),new $l(e)}getComponentsByObject(t){const e=[];return this.eachComponent((i=>{i.object===t&&e.push(i)})),new $l(e)}getRepresentationsByName(t){const e=[];return this.eachRepresentation(((i,r)=>{(void 0===t||Ol(t,i))&&e.push(i)})),new dl(e)}measureClear(){this.eachComponent((t=>t.measureClear()),"structure")}measureUpdate(){this.eachComponent((t=>t.measureUpdate()),"structure")}dispose(){this.tasks.dispose(),this.viewer.dispose(),this.mouseObserver.dispose()}}class Ll extends ll{constructor(t,e,i={}){super(t,e,Object.assign({name:e.name},i)),this.shape=e}get type(){return"shape"}addRepresentation(t,e={}){return this._addRepresentation(t,this.shape,e)}getBoxUntransformed(){return this.shape.boundingBox}getCenterUntransformed(){return this.shape.center}dispose(){this.shape.dispose(),super.dispose()}}function Nl(t,e,i,r){var s,n=arguments.length,o=n<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(t,e,i,r);else for(var a=t.length-1;a>=0;a--)(s=t[a])&&(o=(n<3?s(o):n>3?s(e,i,o):s(e,i))||o);return n>3&&o&&Object.defineProperty(e,i,o),o}Ue.add("shape",Ll);class zl extends zt{constructor(t){super(t),t.scale||(this.parameters.scale="rainbow",this.parameters.reverse=st(t.reverse,!0)),this.scalePerModel={},t.structure.eachModel((t=>{this.parameters.domain=[t.atomOffset,t.atomEnd],this.scalePerModel[t.index]=this.getScale()}))}atomColor(t){return this.scalePerModel[t.modelIndex](t.index)}}Nl([Nt],zl.prototype,"atomColor",null),Fe.add("atomindex",zl);class Vl extends zt{constructor(t){if(super(t),t.scale||(this.parameters.scale="OrRd"),!t.domain){let e,i=1/0,r=-1/0;t.sele&&(e=new pe(t.sele)),t.structure.eachAtom((function(t){const e=t.bfactor;i=Math.min(i,e),r=Math.max(r,e)}),e),this.parameters.domain=[i,r]}this.bfactorScale=this.getScale()}atomColor(t){return this.bfactorScale(t.bfactor)}}Nl([Nt],Vl.prototype,"atomColor",null),Fe.add("bfactor",Vl);class Gl extends zt{constructor(t){super(t),this.chainidDictPerModel={},this.scalePerModel={},t.scale||(this.parameters.scale="Spectral"),t.structure.eachModel((t=>{let e=0;const i={};t.eachChain((function(t){void 0===i[t.chainid]&&(i[t.chainid]=e,e+=1)})),this.parameters.domain=[0,e-1],this.chainidDictPerModel[t.index]=i,this.scalePerModel[t.index]=this.getScale()}))}atomColor(t){const e=this.chainidDictPerModel[t.modelIndex];return this.scalePerModel[t.modelIndex](e[t.chainid])}}Nl([Nt],Gl.prototype,"atomColor",null),Fe.add("chainid",Gl);class Ul extends zt{constructor(t){super(t),this.scalePerModel={},t.scale||(this.parameters.scale="Spectral"),t.structure.eachModel((t=>{this.parameters.domain=[t.chainOffset,t.chainEnd],this.scalePerModel[t.index]=this.getScale()}))}atomColor(t){return this.scalePerModel[t.modelIndex](t.chainIndex)}}Nl([Nt],Ul.prototype,"atomColor",null),Fe.add("chainindex",Ul);class jl extends zt{constructor(t){super(t),this.chainnameDictPerModel={},this.scalePerModel={},t.scale||(this.parameters.scale="Spectral"),t.structure.eachModel((t=>{let e=0;const i={};t.eachChain((function(t){void 0===i[t.chainname]&&(i[t.chainname]=e,e+=1)})),this.parameters.domain=[0,e-1],this.chainnameDictPerModel[t.index]=i,this.scalePerModel[t.index]=this.getScale()}))}atomColor(t){const e=this.chainnameDictPerModel[t.modelIndex];return this.scalePerModel[t.modelIndex](e[t.chainname])}}Nl([Nt],jl.prototype,"atomColor",null),Fe.add("chainname",jl);class Hl extends zt{constructor(t){super(t),this.rsrzDict={},this.rsccDict={},t.scale||(this.parameters.scale="RdYlBu"),this.rsrzScale=this.getScale({domain:[2,0]}),this.rsccScale=this.getScale({domain:[.678,1]});const e=t.structure.validation;e&&(this.rsrzDict=e.rsrzDict,this.rsccDict=e.rsccDict)}atomColor(t){let e=t.resno+"";t.inscode&&(e+="^"+t.inscode),t.chainname&&(e+=":"+t.chainname),e+="/"+t.modelIndex;const i=this.rsrzDict[e];if(void 0!==i)return this.rsrzScale(i);const r=this.rsccDict[e];return void 0!==r?this.rsccScale(r):9474192}}Nl([Nt],Hl.prototype,"atomColor",null),Fe.add("densityfit",Hl);const Wl={ARG:{CD:.1,CZ:.5,NE:-.1},ASN:{CG:.55,OD1:-.55},ASP:{CB:-.16,CG:.36,OD1:-.6,OD2:-.6},CYS:{CB:.19,SG:-.19},GLN:{CD:.55,OE1:-.55},GLU:{CD:.36,CG:-.16,OE1:-.6,OE2:-.6},HIS:{CB:.1,CD2:.2,CE1:.45,CG:.15,ND1:.05,NE2:.05},LYS:{CE:.25,NZ:.75},MET:{CE:.06,CG:.06,SD:-.12},PTR:{C:.55,CA:.1,CZ:.25,N:-.35,O:-.55,O1P:-.85,O2P:-.85,O3P:-.85,OG1:-1.1,P:1.4},SEP:{C:.55,CA:.1,CB:.25,N:-.35,O:-.55,O1P:-.85,O2P:-.85,O3P:-.85,OG1:-1.1,P:1.4},SER:{CB:.25,OG:-.25},THR:{CB:.25,OG1:-.25},TPO:{C:.55,CA:.1,CB:.25,N:-.35,O:-.55,OG1:-1.1,O1P:-.85,O2P:-.85,O3P:-.85,P:1.4},TRP:{CD1:.06,CD2:.1,CE2:-.04,CE3:-.03,CG:-.03,NE1:-.06},TYR:{CZ:.25,OH:-.25},backbone:{C:.55,O:-.55,N:-.35,CA:.1}};class ql extends zt{constructor(t){super(t),this.delta=new e,this.hCharges=[],t.scale||(this.parameters.scale="rwb"),t.domain||(this.parameters.domain=[-50,50]),this.scale=this.getScale(),this.charges=new Float32Array(t.structure.atomCount);const i=[];t.structure.eachAtom((t=>{var r;if(this.charges[t.index]=(null!==(r=t).partialCharge?r.partialCharge:r.isProtein()&&(Wl[r.resname]&&Wl[r.resname][r.atomname]||Wl.backbone[r.atomname])||0)*t.occupancy,"N"===t.atomname){if(t.bondCount>=3)return;if(t.bondToElementCount(1))return;const r=function(t,i=new e){let r=!1,s=!1,n=!1;return i.set(2*t.x,2*t.y,2*t.z),t.eachBondedAtom((function(t){if(!r)return"H"===t.atomname?(i.set(t.x,t.y,t.z),void(r=!0)):void(s||"CA"!==t.atomname?n||"C"!==t.atomname||(n=!0,i.sub(t)):(i.sub(t),s=!0))})),r?i:s&&n?(i.normalize(),i.multiplyScalar(1.04),i.add(t),i):void 0}(t);void 0!==r&&(i.push(r),this.hCharges.push(.25*t.occupancy))}}));const r=t.structure.getBoundingBox();r.expandByScalar(1.04),this.hStore=function(t){const e=t.length,i=new Float32Array(e),r=new Float32Array(e),s=new Float32Array(e);for(let e=0;e{const s=e[t];0!==s&&(r+=s/i)})),this.hHash.eachWithin(t.x,t.y,t.z,12,((t,e)=>{const s=i[t];0!==s&&(r+=s/e)})),this.scale(332*r)}}Nl([Nt],ql.prototype,"positionColor",null),Fe.add("electrostatic",ql);const Xl={H:16777215,HE:14286847,LI:13402367,BE:12779264,B:16758197,C:9474192,N:3166456,O:16715021,F:9494608,NE:11789301,NA:11230450,MG:9109248,AL:12560038,SI:1578e4,P:16744448,S:16777008,CL:2093087,AR:8442339,K:9388244,CA:4062976,SC:15132390,TI:12567239,V:10921643,CR:9083335,MN:10255047,FE:14706227,CO:15765664,NI:5296208,CU:13140019,ZN:8224944,GA:12750735,GE:6721423,AS:12419299,SE:16752896,BR:10889513,KR:6076625,RB:7351984,SR:65280,Y:9764863,ZR:9756896,NB:7586505,MO:5551541,TC:3907230,RU:2396047,RH:687500,PD:27013,AG:12632256,CD:16767375,IN:10909043,SN:6717568,SB:10380213,TE:13924864,I:9699476,XE:9699476,CS:5707663,BA:51456,LA:7394559,CE:16777159,PR:14286791,ND:13107143,PM:10747847,SM:9437127,EU:6422471,GD:4587463,TB:3211207,DY:2097095,HO:65436,ER:58997,TM:54354,YB:48952,LU:43812,HF:5096191,TA:5089023,W:2200790,RE:2522539,OS:2516630,IR:1528967,PT:13684960,AU:16765219,HG:12105936,TL:10900557,PB:5724513,BI:10375093,PO:11230208,AT:7688005,RN:4358806,FR:4325478,RA:32e3,AC:7384058,TH:47871,PA:41471,U:36863,NP:33023,PU:27647,AM:5528818,CM:7888099,BK:9064419,CF:10565332,ES:11739092,FM:11739066,MD:11734438,NO:12389767,LR:13041766,RF:13369433,DB:13697103,SG:14221381,BH:14680120,HS:15073326,MT:15400998,DS:16777215,RG:16777215,CN:16777215,UUT:16777215,FL:16777215,UUP:16777215,LV:16777215,UUH:16777215,D:16777152,T:16777120};class Yl extends zt{constructor(t){t.value=st(t.value,Xl.C),super(t)}atomColor(t){const e=t.element;return"C"===e?this.parameters.value:Xl[e]||16777215}}Nl([Nt],Yl.prototype,"atomColor",null),Fe.add("element",Yl);class Kl extends zt{constructor(t){super(t),t.scale||(this.parameters.scale="Spectral"),t.domain||(this.parameters.domain=[0,t.structure.entityList.length-1]),this.entityindexScale=this.getScale()}atomColor(t){return this.entityindexScale(t.entityIndex)}}Nl([Nt],Kl.prototype,"atomColor",null),Fe.add("entityindex",Kl);class Zl extends zt{atomColor(t){const e=t.entity;switch(e?e.entityType:void 0){case 1:return 8374655;case 2:return 16629894;case 3:return 12496596;case 4:return 3697840;default:return 16777113}}}Nl([Nt],Zl.prototype,"atomColor",null),Fe.add("entitytype",Zl);class Ql extends zt{constructor(t){super(t),this.geoAtomDict={},this.geoDict={};const e=t.structure.validation;e&&(this.geoAtomDict=e.geoAtomDict,this.geoDict=e.geoDict)}atomColor(t){let e,i=t.resno+"";t.inscode&&(i+="^"+t.inscode),t.chainname&&(i+=":"+t.chainname),i+="/"+t.modelIndex;const r=this.geoAtomDict[i];if(void 0!==r){const i=r[t.atomname]||0;s=i,e=16843009*((s=(858993459&(s-=s>>1&1431655765))+(s>>2&858993459))+(s>>4)&252645135)>>24}else e=this.geoDict[i]||0;var s;return 0===e?2188972:1===e?16703627:2===e?16018755:e>=3?10813478:9474192}}Nl([Nt],Ql.prototype,"atomColor",null),Fe.add("geoquality",Ql);class Jl extends zt{constructor(t){super(t),this.resHF={},t.scale||(this.parameters.scale="RdYlGn");for(const t in Js)this.resHF[t]=Js[t][0];if(this.defaultResidueHydrophobicity=tn[0],!t.domain){let t=1/0,e=-1/0;for(const i in this.resHF){const r=this.resHF[i];t=Math.min(t,r),e=Math.max(e,r)}this.parameters.domain=[t,0,e]}this.hfScale=this.getScale()}atomColor(t){return this.hfScale(this.resHF[t.resname]||this.defaultResidueHydrophobicity)}}Nl([Nt],Jl.prototype,"atomColor",null),Fe.add("hydrophobicity",Jl);class th extends zt{constructor(t){super(t),t.scale||(this.parameters.scale="rainbow"),t.domain||(this.parameters.domain=[0,t.structure.modelStore.count]),this.modelindexScale=this.getScale()}atomColor(t){return this.modelindexScale(t.modelIndex)}}Nl([Nt],th.prototype,"atomColor",null),Fe.add("modelindex",th);class eh extends zt{atomColor(t){switch(t.residueType.moleculeType){case 1:return 3697840;case 2:return 15729279;case 3:return 12496596;case 4:return 16629894;case 5:return 12540695;case 6:return 8374655;default:return 16777113}}}Nl([Nt],eh.prototype,"atomColor",null),Fe.add("moleculetype",eh);class ih extends zt{constructor(t){super(t),t.scale||(this.parameters.scale="PuBu"),t.domain||(this.parameters.domain=[0,1]),this.occupancyScale=this.getScale()}atomColor(t){return this.occupancyScale(t.occupancy)}}Nl([Nt],ih.prototype,"atomColor",null),Fe.add("occupancy",ih);class rh extends zt{constructor(t){super(t),t.scale||(this.parameters.scale="rwb"),t.domain||(this.parameters.domain=[-1,1]),this.partialchargeScale=this.getScale()}atomColor(t){return this.partialchargeScale(t.partialCharge||0)}}function sh(){return 16777215*Math.random()}Nl([Nt],rh.prototype,"atomColor",null),Fe.add("partialcharge",rh);class nh extends zt{atomColor(){return sh()}volumeColor(){return sh()}positionColor(){return sh()}}Nl([Nt],nh.prototype,"atomColor",null),Nl([Nt],nh.prototype,"volumeColor",null),Nl([Nt],nh.prototype,"positionColor",null),Fe.add("random",nh);class oh extends zt{constructor(t){super(t),this.rciDict={},t.scale||(this.parameters.scale="RdYlBu"),this.rciScale=this.getScale({domain:[.6,0]});const e=t.structure.validation;e&&(this.rciDict=e.rciDict)}atomColor(t){let e=`[${t.resname}]${t.resno}`;t.chainname&&(e+=":"+t.chainname);const i=this.rciDict[e];return void 0!==i?this.rciScale(i):9474192}}Nl([Nt],oh.prototype,"atomColor",null),Fe.add("randomcoilindex",oh);class ah extends zt{constructor(t){super(t),this.scalePerChain={},t.scale||(this.parameters.scale="rainbow",this.parameters.reverse=st(t.reverse,!0)),t.structure.eachChain((t=>{this.parameters.domain=[t.residueOffset,t.residueEnd],this.scalePerChain[t.index]=this.getScale()}))}atomColor(t){return this.scalePerChain[t.chainIndex](t.residueIndex)}}Nl([Nt],ah.prototype,"atomColor",null),Fe.add("residueindex",ah);const ch={ALA:9240460,ARG:124,ASN:16743536,ASP:10485826,CYS:16777072,GLN:16731212,GLU:6684672,GLY:16777215,HIS:7368959,ILE:19456,LEU:4546117,LYS:4671416,MET:12099650,PHE:5459026,PRO:5395026,SER:16740418,THR:12078080,TRP:5195264,TYR:9203788,VAL:16747775,ASX:16711935,GLX:16711935,ASH:16711935,GLH:16711935,A:14423100,G:3329330,I:10145074,X:8190976,C:16766720,T:4286945,U:4251856,D:35723,DA:14423100,DG:3329330,DI:10145074,DX:8190976,DC:16766720,DT:4286945,DU:4251856,DD:35723};class lh extends zt{atomColor(t){return ch[t.resname]||16711935}}Nl([Nt],lh.prototype,"atomColor",null),Fe.add("resname",lh);const hh=16711808,dh=10485888,uh=6291584,mh=16762880,ph=6324479,fh=16777215,gh=11403518,yh=16580962,bh=10921722;class xh extends zt{constructor(t){super(t),this.residueProxy=t.structure.getResidueProxy()}atomColor(t){const e=t.sstruc,i=this.residueProxy;return"h"===e?hh:"g"===e?dh:"i"===e?uh:"e"===e||"b"===e?mh:"t"===e?ph:(i.index=t.residueIndex,i.isDna()?gh:i.isRna()?yh:i.isSaccharide()?bh:i.isProtein()||"s"===e||"l"===e?fh:8421504)}}Nl([Nt],xh.prototype,"atomColor",null),Fe.add("sstruc",xh);class vh extends zt{constructor(t){var e,i;super(t),t.scale||(this.parameters.scale="rwb"),this.atomData=null===(e=this.parameters.data)||void 0===e?void 0:e.atomData,this.bondData=null===(i=this.parameters.data)||void 0===i?void 0:i.bondData,this.scale=this.getScale(this.parameters)}atomColor(t){var e;const i=null===(e=this.atomData)||void 0===e?void 0:e[t.index];return void 0!==i?this.scale(i):this.parameters.value}bondColor(t,e){var i;const r=null===(i=this.bondData)||void 0===i?void 0:i[t.index];return void 0!==r?this.scale(r):this.atomProxy?(this.atomProxy.index=e?t.atomIndex1:t.atomIndex2,this.atomColor(this.atomProxy)):this.parameters.value}}Nl([Nt],vh.prototype,"atomColor",null),Nl([Nt],vh.prototype,"bondColor",null),Fe.add("structuredata",vh);class wh extends zt{atomColor(){return this.parameters.value}bondColor(){return this.parameters.value}valueColor(){return this.parameters.value}volumeColor(){return this.parameters.value}}Nl([Nt],wh.prototype,"atomColor",null),Nl([Nt],wh.prototype,"bondColor",null),Nl([Nt],wh.prototype,"valueColor",null),Nl([Nt],wh.prototype,"volumeColor",null),Fe.add("uniform",wh);class Ah extends zt{constructor(t){super(t),this.valueScale=this.getScale()}volumeColor(t){return this.valueScale(this.parameters.volume.data[t])}}Nl([Nt],Ah.prototype,"volumeColor",null),Fe.add("value",Ah);class _h extends zt{constructor(t){super(t),this.vec=new e,this.valueScale=this.getScale()}positionColor(t){const e=this.parameters.volume;if(!e||!e.inverseMatrix)return this.parameters.value;const i=this.vec,r=e.data,s=e.nx,n=e.ny,o=s*n;i.copy(t),i.applyMatrix4(e.inverseMatrix);const a=Math.floor(i.x),c=Math.floor(i.y),l=Math.floor(i.z),h=(l*n+c)*s+a,d=h+1,u=h+s,m=h+o,p=u+1,f=m+1,g=u+o,y=g+1,b=r[h],x=r[d],v=r[u],w=r[m],A=r[p],_=r[f],S=r[g],C=r[y],P=i.x-a,I=i.y-c,k=i.z-l,M=$t(b,x,P),T=$t(w,_,P),B=$t(v,A,P),D=$t(S,C,P),$=$t(M,B,I),O=$t(T,D,I),R=$t($,O,k);return this.valueScale(R)}}Nl([Nt],_h.prototype,"positionColor",null),Fe.add("volume",_h);class Sh extends zr{constructor(t,e,i){const r=i||{};if(super(t,e,r),this.type="structure",this.parameters=Object.assign({radiusType:{type:"select",options:pa.types},radiusData:{type:"hidden"},radiusSize:{type:"number",precision:3,max:10,min:.001},radiusScale:{type:"number",precision:3,max:10,min:.001},assembly:null,defaultAssembly:{type:"hidden"}},this.parameters),this.selection=new pe(r.sele),this.dataList=[],this.structure=t,this.structureView=this.structure.getView(this.selection),t.biomolDict){const e={default:"default","":t.unitcell?"AU":"FULL"};Object.keys(t.biomolDict).forEach((function(t){e[t]=t})),this.parameters.assembly={type:"select",options:e,rebuild:!0}}else this.parameters.assembly=null}get defaultScale(){return{vdw:1,covalent:1,bfactor:.01,sstruc:1}}init(t){const e=t||{};e.colorScheme=st(e.colorScheme,"element"),this.setRadius(e.radius,e),this.radiusType=st(e.radiusType,"vdw"),this.radiusData=st(e.radiusData,{}),this.radiusSize=st(e.radiusSize,1),this.radiusScale=st(e.radiusScale,1),this.assembly=st(e.assembly,"default"),this.defaultAssembly=st(e.defaultAssembly,""),"auto"===e.quality&&(e.quality=this.getQuality()),super.init(e),this.selection.signals.stringChanged.add((()=>{this.build()})),this.build()}setRadius(t,e){const i=Object.keys(ma);return"string"==typeof t&&i.includes(t.toLowerCase())?e.radiusType=t:void 0!==t&&(e.radiusType="size",e.radiusSize=t),this}getAssembly(){const t="default"===this.assembly?this.defaultAssembly:this.assembly;return this.structure.biomolDict[t]}getQuality(){let t;const e=this.structureView,i=this.getAssembly();t=i?i.getAtomCount(e):e.atomCount,Se&&(t*=4);return e.atomStore.count/e.residueStore.count<2&&(t*=10),t<15e3?"high":t<8e4?"medium":"low"}create(){if(0===this.structureView.atomCount)return;if(!this.structureView.hasCoords())return void(this.needsBuild=!0);this.needsBuild=!1;const t=this.getAssembly();if(t)t.partList.forEach(((t,e)=>{const i=t.getView(this.structureView);if(0===i.atomCount)return;const r=this.createData(i,e);r&&(r.sview=i,r.instanceList=t.getInstanceList(),this.dataList.push(r))}));else{const t=this.createData(this.structureView,0);t&&(t.sview=this.structureView,this.dataList.push(t))}}update(t){!this.lazy||this.visible?this.needsBuild?this.build():this.dataList.forEach((e=>{e.bufferList.length>0&&this.updateData(t,e)}),this):Object.assign(this.lazyProps.what,t)}updateData(t,e){this.build()}getColorParams(){return Object.assign(Object.assign({},super.getColorParams()),{structure:this.structure})}getRadiusParams(t){return{type:this.radiusType,scale:this.radiusScale,size:this.radiusSize,data:this.radiusData}}getAtomParams(t,e){return Object.assign({what:t,colorParams:this.getColorParams(),radiusParams:this.getRadiusParams()},e)}getBondParams(t,e){return Object.assign({what:t,colorParams:this.getColorParams(),radiusParams:this.getRadiusParams()},e)}getAtomRadius(t){if(this.structureView.atomSet.isSet(t.index)){return new pa(this.getRadiusParams()).atomRadius(t)}return 0}setSelection(t,e){return this.selection.setString(t,e),this}setParameters(t,e={},i=!1){const r=t||{};return this.setRadius(r.radius,r),void 0===r.radiusType&&void 0===r.radiusData&&void 0===r.radiusSize&&void 0===r.radiusScale||(e.radius=!0,Ie&&!this.disableImpostor||(i=!0)),void 0!==r.defaultAssembly&&r.defaultAssembly!==this.defaultAssembly&&("default"===this.assembly&&void 0===r.assembly||"default"===r.assembly)&&(i=!0),super.setParameters(r,e,i),this}getParameters(){return Object.assign(super.getParameters(),{sele:this.selection?this.selection.string:void 0,defaultAssembly:this.defaultAssembly})}attach(t){const e=this.viewer,i=this.bufferList;this.dataList.forEach((function(t){t.bufferList.forEach((function(r){i.push(r),e.add(r,t.instanceList)}))})),this.setVisibility(this.visible),t()}clear(){this.dataList.length=0,super.clear()}dispose(){this.structureView.dispose(),super.dispose()}}class Ch extends Sh{constructor(t,e,i){super(t,e,i),this.n=0,this.parameters=Object.assign({labelVisible:{type:"boolean"},labelSize:{type:"number",precision:3,max:10,min:.001},labelColor:{type:"color"},labelFontFamily:{type:"select",options:{"sans-serif":"sans-serif",monospace:"monospace",serif:"serif"},buffer:"fontFamily"},labelFontStyle:{type:"select",options:{normal:"normal",italic:"italic"},buffer:"fontStyle"},labelFontWeight:{type:"select",options:{normal:"normal",bold:"bold"},buffer:"fontWeight"},labelsdf:{type:"boolean",buffer:"sdf"},labelXOffset:{type:"number",precision:1,max:20,min:-20,buffer:"xOffset"},labelYOffset:{type:"number",precision:1,max:20,min:-20,buffer:"yOffset"},labelZOffset:{type:"number",precision:1,max:20,min:-20,buffer:"zOffset"},labelAttachment:{type:"select",options:{"bottom-left":"bottom-left","bottom-center":"bottom-center","bottom-right":"bottom-right","middle-left":"middle-left","middle-center":"middle-center","middle-right":"middle-right","top-left":"top-left","top-center":"top-center","top-right":"top-right"},rebuild:!0},labelBorder:{type:"boolean",buffer:"showBorder"},labelBorderColor:{type:"color",buffer:"borderColor"},labelBorderWidth:{type:"number",precision:2,max:.3,min:0,buffer:"borderWidth"},labelBackground:{type:"boolean",rebuild:!0},labelBackgroundColor:{type:"color",buffer:"backgroundColor"},labelBackgroundMargin:{type:"number",precision:2,max:2,min:0,rebuild:!0},labelBackgroundOpacity:{type:"range",step:.01,max:1,min:0,buffer:"backgroundOpacity"},labelFixedSize:{type:"boolean",buffer:"fixedSize"},lineOpacity:{type:"range",min:0,max:1,step:.01},linewidth:{type:"integer",max:50,min:1,buffer:!0}},this.parameters,{flatShaded:null})}init(t){const e=t||{};this.labelVisible=st(e.labelVisible,!0),this.labelSize=st(e.labelSize,2),this.labelColor=st(e.labelColor,16777215),this.labelFontFamily=st(e.labelFontFamily,"sans-serif"),this.labelFontStyle=st(e.labelFontstyle,"normal"),this.labelFontWeight=st(e.labelFontWeight,"bold"),this.labelsdf=st(e.labelsdf,"Chrome"===Ae),this.labelXOffset=st(e.labelXOffset,0),this.labelYOffset=st(e.labelYOffset,0),this.labelZOffset=st(e.labelZOffset,.5),this.labelAttachment=st(e.labelAttachment,"bottom-left"),this.labelBorder=st(e.labelBorder,!1),this.labelBorderColor=st(e.labelBorderColor,"lightgrey"),this.labelBorderWidth=st(e.labelBorderWidth,.15),this.labelBackground=st(e.labelBackground,!1),this.labelBackgroundColor=st(e.labelBackgroundColor,"lightgrey"),this.labelBackgroundMargin=st(e.labelBackgroundMargin,.5),this.labelBackgroundOpacity=st(e.labelBackgroundOpacity,1),this.labelFixedSize=st(e.labelFixedSize,!1),this.lineOpacity=st(e.lineOpacity,1),this.linewidth=st(e.linewidth,2),super.init(e)}update(t){t.position?this.build():super.update(t)}updateData(t,e){const i={};if(t&&!t.labelSize||Object.assign(i,{size:Si(this.n,this.labelSize)}),!t||t.labelColor){const t=new s(this.labelColor);Object.assign(i,{color:Ci(this.n,t.r,t.g,t.b)})}this.textBuffer.setAttributes(i)}setParameters(t,e={},i=!1){return t&&t.labelSize&&(e.labelSize=!0),t&&(t.labelColor||0===t.labelColor)&&(e.labelColor=!0,i=!0),super.setParameters(t,e,i),t&&void 0!==t.opacity&&this.textBuffer.setParameters({opacity:1}),t&&void 0!==t.labelVisible&&this.setVisibility(this.visible),this}setVisibility(t,e){return super.setVisibility(t,!0),this.textBuffer&&this.textBuffer.setVisibility(this.labelVisible&&this.visible),e||this.viewer.requestRender(),this}getLabelBufferParams(t={}){return super.getBufferParams(Object.assign({fontFamily:this.labelFontFamily,fontStyle:this.labelFontStyle,fontWeight:this.labelFontWeight,sdf:this.labelsdf,xOffset:this.labelXOffset,yOffset:this.labelYOffset,zOffset:this.labelZOffset,attachment:this.labelAttachment,showBorder:this.labelBorder,borderColor:this.labelBorderColor,borderWidth:this.labelBorderWidth,showBackground:this.labelBackground,backgroundColor:this.labelBackgroundColor,backgroundMargin:this.labelBackgroundMargin,backgroundOpacity:this.labelBackgroundOpacity,fixedSize:this.labelFixedSize,disablePicking:!0,visible:this.labelVisible},t,{opacity:1}))}getAtomRadius(){return 0}}function Ph(t,e){const i=t.getAtomProxy(),r=new pe,s=e.length;if(0===s)return new Float32Array(0);const n=e[0].length,o=t.getAtomSet(),a=new Float32Array(s*n*3);let c=0;return e.forEach((function(e){let s=!1;for(let l=0;l 1.0 ){\ngl_FragColor = vec4( backgroundColor, backgroundOpacity );\n}else{\nfloat sdf = texture2D( fontTexture, texCoord ).a;\nif( showBorder ) sdf += borderWidth;\nfloat a = smoothstep(padding - gamma, padding + gamma, sdf);\nif( a < 0.2 ) discard;\na *= opacity;\nvec3 outgoingLight = vColor;\nif( showBorder && sdf < ( padding + borderWidth ) ){\noutgoingLight = borderColor;\n}\ngl_FragColor = vec4( outgoingLight, a );\n}\n#if defined( PICKING )\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");const Th={};const Bh={font:"sans-serif",size:36,style:"normal",variant:"normal",weight:"normal",outline:3,width:1024,height:1024};class Dh{constructor(t={}){this.gamma=1,this.mapped={},this.scratchW=0,this.scratchH=0,this.currentX=0,this.currentY=0,this.cutoff=.25,this.parameters=nt(t,Bh);const e=this.parameters;this.radius=e.size/8,this.padding=e.size/3;const i=this.lineHeight=e.size+2*e.outline+Math.round(e.size/4),r=this.maxWidth=e.width/4,s=this.canvas=document.createElement("canvas");s.width=r,s.height=i;const n=this.context=this.canvas.getContext("2d");n.font=`${e.style} ${e.variant} ${e.weight} ${e.size}px ${e.font}`,n.fillStyle="black",n.textAlign="left",n.textBaseline="bottom",n.lineJoin="round",this.gridOuter=new Float64Array(i*r),this.gridInner=new Float64Array(i*r),this.f=new Float64Array(Math.max(i,r)),this.d=new Float64Array(Math.max(i,r)),this.z=new Float64Array(Math.max(i,r)+1),this.v=new Int16Array(Math.max(i,r)),this.data=new Uint8Array(e.width*e.height*4),this.canvas2=document.createElement("canvas"),this.canvas2.width=e.width,this.canvas2.height=e.height,this.context2=this.canvas2.getContext("2d"),this.placeholder=this.map(String.fromCharCode(65533));for(let t=32;t<=126;++t)this.map(String.fromCharCode(t));this.map(String.fromCharCode(176)),this.map(String.fromCharCode(8491)),this.texture=new H(this.canvas2),this.texture.flipY=!1,this.texture.needsUpdate=!0}map(t){const e=this.parameters;return void 0===this.mapped[t]&&(this.draw(t),this.currentX+this.scratchW>e.width&&(this.currentX=0,this.currentY+=this.scratchH),this.currentY+this.scratchH>e.height&&console.warn("canvas to small"),this.mapped[t]={x:this.currentX,y:this.currentY,w:this.scratchW,h:this.scratchH},this.context2.drawImage(this.canvas,0,0,this.scratchW,this.scratchH,this.currentX,this.currentY,this.scratchW,this.scratchH),this.currentX+=this.scratchW),this.mapped[t]}get(t){return this.mapped[t]||this.placeholder}draw(t){const e=this.parameters,i=this.lineHeight,r=e.outline,s=this.context,n=this.maxWidth,o=r,a=i-e.outline,c=s.measureText(t),l=Math.min(n,Math.ceil(c.width+2*o+1)),h=l*i;s.clearRect(0,0,l,i),s.fillText(t,o,a);const d=s.getImageData(0,0,l,i),u=d.data;for(let t=0;t= 0.0 ) {\ntrimSegment( start, end );\n} else if ( end.z < 0.0 && start.z >= 0.0 ) {\ntrimSegment( end, start );\n}\n}\nvec4 clipStart = projectionMatrix * start;\nvec4 clipEnd = projectionMatrix * end;\nvec2 ndcStart = clipStart.xy / clipStart.w;\nvec2 ndcEnd = clipEnd.xy / clipEnd.w;\nvec2 dir = ndcEnd - ndcStart;\ndir.x *= aspect;\ndir = normalize( dir );\nvec2 offset = vec2( dir.y, - dir.x );\ndir.x /= aspect;\noffset.x /= aspect;\nif ( mapping.x < 0.0 ) offset *= - 1.0;\noffset *= linewidth;\noffset /= resolution.y;\nvec4 clip = ( mapping.y < 0.5 ) ? clipStart : clipEnd;\noffset *= clip.w;\nclip.xy += offset;\ngl_Position = clip;\n#ifndef PICKING\nvViewPosition = ( projectionMatrixInverse * clip ).xyz;\n#endif\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n#include nearclip_vertex\n}"),Ve.add("shader/WideLine.frag","uniform vec3 diffuse;\nuniform float opacity;\nuniform float clipNear;\nuniform float clipRadius;\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#ifdef PICKING\nuniform float objectId;\nvarying vec3 vPickingColor;\n#else\n#include common\n#include fog_pars_fragment\nvarying vec3 vViewPosition;\nvarying vec3 vColor;\nvarying vec3 vColor2;\nvarying float flag;\n#endif\nvoid main() {\n#include nearclip_fragment\n#include radiusclip_fragment\n#if defined( PICKING )\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 outgoingLight = vec3( 0.0 );\nvec4 diffuseColor = vec4( diffuse, 1.0 );\nif ( flag < 0.0 ) {\ndiffuseColor.rgb *= vColor;\n} else {\ndiffuseColor.rgb *= vColor2;\n}\n#include alphatest_fragment\noutgoingLight = diffuseColor.rgb;\ngl_FragColor = vec4( outgoingLight, diffuseColor.a * opacity );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");const Fh=Object.assign({linewidth:2},zo),Lh=Object.assign({linewidth:{uniform:!0}},Vo);class Nh extends zc{constructor(e,r={}){super(e,r),this.parameterTypes=Lh,this.vertexShader="WideLine.vert",this.fragmentShader="WideLine.frag",!e.color2&&e.color&&(e.color2=e.color),this.addUniforms({linewidth:{value:this.parameters.linewidth},resolution:{value:new t},projectionMatrixInverse:{value:new i}}),this.addAttributes({position1:{type:"v3",value:null},position2:{type:"v3",value:null},color2:{type:"c",value:null}}),this.setAttributes(e),this.makeMapping()}get defaultParameters(){return Fh}setParameters(t){super.setParameters(t)}}je.add("wideline",Nh);class zh extends Ch{constructor(t,e,i){super(t,e,i),this.type="angle",this.parameters=Object.assign({atomTriple:{type:"hidden",rebuild:!0},vectorVisible:{type:"boolean",default:!0},arcVisible:{type:"boolean",default:!0},sectorVisible:{type:"boolean",default:!0}},this.parameters),this.init(i)}init(t){const e=t||{};e.side=st(e.side,"double"),e.opacity=st(e.opacity,.5),this.atomTriple=st(e.atomTriple,[]),this.arcVisible=st(e.arcVisible,!0),this.sectorVisible=st(e.sectorVisible,!0),this.vectorVisible=st(e.vectorVisible,!0),super.init(e)}createData(t){if(!t.atomCount||!this.atomTriple.length)return;const e=function(t,e){return function(t){const e=[],i=t.length/9;for(let r=0;r radius2) {\ndiscard;\n}\n#ifdef CAP\nsurface_point = front_point;\n_normal = axis;\n#else\nsurface_point = ray_target + ( (-a1 - sqrt(d)) / a2 ) * ray_direction;\ndNV = dot(-axis, ray_direction);\nnear = dot(axis, end) / dNV;\nnew_point2 = ray_direction * near + ray_origin;\nif (dot(new_point2 - end, new_point2-base) < radius2) {\ndiscard;\n}\ninterior = true;\n#endif\n}\nif( end_cap_test > 0.0 )\n{\nfloat dNV;\nfloat near;\nvec3 end_point;\nif ( ortho == 1.0 ) {\nend_point = ray_target;\n} else {\ndNV = dot(axis, ray_direction);\nif (dNV < 0.0) {\ndiscard;\n}\nnear = dot(axis, end) / dNV;\nend_point = ray_direction * near + ray_origin;\n}\n\nif( dot(end_point - end, end_point-base) > radius2 ) {\ndiscard;\n}\n#ifdef CAP\nsurface_point = end_point;\n_normal = axis;\n#else\nsurface_point = ray_target + ( (-a1 - sqrt(d)) / a2 ) * ray_direction;\ndNV = dot(-axis, ray_direction);\nnear = dot(-axis, (base)) / dNV;\nnew_point2 = ray_direction * near + ray_origin;\nif (dot(new_point2 - base, new_point2-base) < radius2) {\ndiscard;\n}\ninterior = true;\n#endif\n}\ngl_FragDepthEXT = calcDepth( surface_point );\n\n#ifdef NEAR_CLIP\nif( calcClip( surface_point ) > 0.0 ){\ndist = (-a1 - sqrt(d)) / a2;\nsurface_point = ray_target + dist * ray_direction;\nif( calcClip( surface_point ) > 0.0 ) {\ndiscard;\n}\ninterior = true;\ngl_FragDepthEXT = calcDepth( surface_point );\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( clipNear - 0.5 ) ) ) + ( 0.0000001 / vRadius ) );\n}\n}else if( gl_FragDepthEXT <= 0.0 ){\ndist = (-a1 - sqrt(d)) / a2;\nsurface_point = ray_target + dist * ray_direction;\ninterior = true;\ngl_FragDepthEXT = calcDepth( surface_point );\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n}\n#else\nif( gl_FragDepthEXT <= 0.0 ){\ndist = (-a1 - sqrt(d)) / a2;\nsurface_point = ray_target + dist * ray_direction;\ninterior = true;\ngl_FragDepthEXT = calcDepth( surface_point );\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n}\n#endif\nif (gl_FragDepthEXT < 0.0) {\ndiscard;\n}\nif (gl_FragDepthEXT > 1.0) {\ndiscard;\n}\n#ifdef PICKING\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 vViewPosition = -surface_point;\nvec3 vNormal = _normal;\nvec3 vColor;\nif( distSq3( surface_point, end ) < distSq3( surface_point, base ) ){\nif( b < 0.0 ){\nvColor = vColor1;\n}else{\nvColor = vColor2;\n}\n}else{\nif( b > 0.0 ){\nvColor = vColor1;\n}else{\nvColor = vColor2;\n}\n}\nvec4 diffuseColor = vec4( diffuse, opacity );\nReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\nvec3 totalEmissiveLight = emissive;\n#include color_fragment\n#include roughnessmap_fragment\n#include metalnessmap_fragment\nvec3 normal = normalize( vNormal );\nvec3 geometryNormal = normal;\n#include lights_physical_fragment\n#include lights_fragment_begin\n#include lights_fragment_end\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\nif( interior ){\n#ifdef USE_INTERIOR_COLOR\noutgoingLight.xyz = interiorColor;\n#else\n#ifdef DIFFUSE_INTERIOR\noutgoingLight.xyz = vColor;\n#endif\n#endif\noutgoingLight.xyz *= 1.0 - interiorDarkening;\n}\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");const Xh=new Float32Array([-1,1,-1,-1,-1,-1,1,1,-1,1,1,1,1,-1,-1,1,-1,1]),Yh=new Uint16Array([0,1,2,1,4,2,2,4,3,4,5,3]);class Kh extends Fc{constructor(t,e={}){super("v3",t,e)}get mapping(){return Xh}get mappingIndices(){return Yh}get mappingIndicesSize(){return 12}get mappingSize(){return 6}get mappingItemSize(){return 3}}const Zh=Object.assign({openEnded:!1},zo),Qh=Object.assign({openEnded:{updateShader:!0}},Vo);class Jh extends Kh{constructor(t,e={}){super(t,e),this.parameterTypes=Qh,this.isImpostor=!0,this.vertexShader="CylinderImpostor.vert",this.fragmentShader="CylinderImpostor.frag",this.addUniforms({modelViewMatrixInverse:{value:new i},ortho:{value:0}}),this.addAttributes({position1:{type:"v3",value:null},position2:{type:"v3",value:null},color2:{type:"c",value:null},radius:{type:"f",value:null}}),this.setAttributes(t),this.makeMapping()}get defaultParameters(){return Zh}getDefines(t){const e=Kh.prototype.getDefines.call(this,t);return this.parameters.openEnded||(e.CAP=1),e}}Object.assign({disableImpostor:!1},Hh,Zh);const td=class{constructor(t,e={}){return!t.color2&&t.color&&(t.color2=t.color),!Ie||e&&e.disableImpostor?new qh(t,e):new Jh(t,e)}};je.add("cylinder",td);class ed extends Sh{constructor(t,e,i){super(t,e,i),this.type="axes",this.parameters=Object.assign({radiusSize:{type:"number",precision:3,max:10,min:.001},sphereDetail:!0,radialSegments:!0,disableImpostor:!0,showAxes:{type:"boolean",rebuild:!0},showBox:{type:"boolean",rebuild:!0}},this.parameters,{assembly:null}),this.init(i)}init(t){const e=t||{};e.radiusSize=st(e.radiusSize,.5),e.colorValue=st(e.colorValue,"lightgreen"),e.useInteriorColor=st(e.useInteriorColor,!0),this.showAxes=st(e.showAxes,!0),this.showBox=st(e.showBox,!1),super.init(e)}getPrincipalAxes(){let t;const e=this.getAssembly();return e&&(t=e.partList[0].getSelection()),this.structureView.getPrincipalAxes(t)}getAxesData(t){const i=this.getPrincipalAxes(),r=new s(this.colorValue);let n=0,o=0;this.showAxes&&(n+=6,o+=3),this.showBox&&(n+=8,o+=12);const a=new Float32Array(3*n),c=Ci(n,r.r,r.g,r.b),l=Si(n,this.radiusSize),h=new Float32Array(3*o),d=new Float32Array(3*o),u=Ci(o,r.r,r.g,r.b),m=Si(o,this.radiusSize);let p=0;if(this.showAxes){const t=function(t,e){t.toArray(a,2*p),e.toArray(a,2*p+3),t.toArray(h,p),e.toArray(d,p),p+=3};t(i.begA,i.endA),t(i.begB,i.endB),t(i.begC,i.endC)}if(this.showBox){const r=new e,{d1a:s,d2a:n,d3a:o,d1b:c,d2b:l,d3b:u}=i.getProjectedScaleForAtoms(t);let m=2*p;const f=function(t,e,s){r.copy(i.center).addScaledVector(i.normVecA,t).addScaledVector(i.normVecB,e).addScaledVector(i.normVecC,s),r.toArray(a,m),m+=3};f(s,n,o),f(s,n,u),f(s,l,u),f(s,l,o),f(c,l,u),f(c,l,o),f(c,n,o),f(c,n,u);let g=p;const y=function(t,e){r.fromArray(a,2*p+3*t).toArray(h,g),r.fromArray(a,2*p+3*e).toArray(d,g),g+=3};y(0,1),y(0,3),y(0,6),y(1,2),y(1,7),y(2,3),y(2,4),y(3,5),y(4,5),y(4,7),y(5,6),y(6,7)}const f=new Kn(i);return{vertex:{position:a,color:c,radius:l,picking:f},edge:{position1:h,position2:d,color:u,color2:u,radius:m,picking:f}}}create(){const t=this.getAxesData(this.structureView);this.sphereBuffer=new Gc(t.vertex,this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0})),this.cylinderBuffer=new td(t.edge,this.getBufferParams({openEnded:!0,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0})),this.dataList.push({sview:this.structureView,bufferList:[this.sphereBuffer,this.cylinderBuffer]})}createData(t){}updateData(t,e){const i=this.getAxesData(e.sview),r={},s={};t&&!t.position||(Object.assign(r,{position:i.vertex.position}),Object.assign(s,{position1:i.edge.position1,position2:i.edge.position2})),t&&!t.color||(Object.assign(r,{color:i.vertex.color}),Object.assign(s,{color:i.edge.color,color2:i.edge.color})),t&&!t.radius||(Object.assign(r,{radius:i.vertex.radius}),Object.assign(s,{radius:i.edge.radius})),this.sphereBuffer.setAttributes(r),this.cylinderBuffer.setAttributes(s)}}Ne.add("axes",ed);class id extends Sh{constructor(t,e,i){super(t,e,i),this.type="ball+stick",this.parameters=Object.assign({sphereDetail:!0,radialSegments:!0,openEnded:!0,disableImpostor:!0,aspectRatio:{type:"number",precision:1,max:10,min:1},lineOnly:{type:"boolean",rebuild:!0},cylinderOnly:{type:"boolean",rebuild:!0},multipleBond:{type:"select",rebuild:!0,options:{off:"off",symmetric:"symmetric",offset:"offset"}},bondScale:{type:"number",precision:2,max:1,min:.01},bondSpacing:{type:"number",precision:2,max:2,min:.5},linewidth:{type:"integer",max:50,min:1,buffer:!0}},this.parameters),this.init(i)}init(t){var e=t||{};e.radiusType=st(e.radiusType,"size"),e.radiusSize=st(e.radiusSize,.15),e.useInteriorColor=st(e.useInteriorColor,!0),this.aspectRatio=st(e.aspectRatio,2),this.lineOnly=st(e.lineOnly,!1),this.cylinderOnly=st(e.cylinderOnly,!1),this.multipleBond=st(e.multipleBond,"off"),this.bondSpacing=st(e.bondSpacing,1),this.bondScale=st(e.bondScale,.4),this.linewidth=st(e.linewidth,2),super.init(e)}getAtomRadius(t){return this.aspectRatio*super.getAtomRadius(t)}getAtomParams(t,e){var i=super.getAtomParams(t,e);return i.radiusParams.scale*=this.aspectRatio,i}getAtomData(t,e,i){return t.getAtomData(this.getAtomParams(e,i))}getBondParams(t,e){return e=Object.assign({multipleBond:this.multipleBond,bondSpacing:this.bondSpacing,bondScale:this.bondScale},e),super.getBondParams(t,e)}getBondData(t,e,i){return t.getBondData(this.getBondParams(e,i))}createData(t){const e=[];if(this.lineOnly)this.lineBuffer=new Nh(this.getBondData(t,{position:!0,color:!0,picking:!0}),this.getBufferParams({linewidth:this.linewidth})),e.push(this.lineBuffer);else{const i=new td(this.getBondData(t),this.getBufferParams({openEnded:this.openEnded,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0}));if(e.push(i),!this.cylinderOnly){const i=new Gc(this.getAtomData(t),this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0}));e.push(i)}}return{bufferList:e}}updateData(t,e){"off"!==this.multipleBond&&t&&t.radius&&(t.position=!0);const i=this.getBondData(e.sview,t);if(this.lineOnly){const r={};t&&!t.position||Object.assign(r,{position1:i.position1,position2:i.position2}),t&&!t.color||Object.assign(r,{color:i.color,color2:i.color2}),e.bufferList[0].setAttributes(r)}else{var r={};if(t&&!t.position||Object.assign(r,{position1:i.position1,position2:i.position2}),t&&!t.color||Object.assign(r,{color:i.color,color2:i.color2}),t&&!t.radius||Object.assign(r,{radius:i.radius}),e.bufferList[0].setAttributes(r),!this.cylinderOnly){var s=this.getAtomData(e.sview,t),n={};t&&!t.position||Object.assign(n,{position:s.position}),t&&!t.color||Object.assign(n,{color:s.color}),t&&!t.radius||Object.assign(n,{radius:s.radius}),e.bufferList[1].setAttributes(n)}}}setParameters(t={}){let e=!1;const i={};return(t.aspectRatio||t.bondSpacing||t.bondScale)&&(Object.assign(i,{radius:!0}),Ie&&!this.disableImpostor||(e=!0)),super.setParameters(t,i,e),this}}Ne.add("ball+stick",id);class rd extends id{constructor(t,e,i){super(t,e,i),this.type="backbone",this.parameters=Object.assign({},this.parameters,{multipleBond:null,bondSpacing:null}),this.init(i)}init(t){var e=t||{};e.aspectRatio=st(e.aspectRatio,1),e.radiusSize=st(e.radiusSize,.25),super.init(e)}getAtomRadius(t){return t.isTrace()?super.getAtomRadius(t):0}getAtomData(t,e,i){return t.getBackboneAtomData(this.getAtomParams(e,i))}getBondData(t,e,i){return t.getBackboneBondData(this.getBondParams(e,i))}}Ne.add("backbone",rd);class sd extends id{constructor(t,e,i){super(t,e,i),this.type="base",this.parameters=Object.assign({},this.parameters,{multipleBond:null,bondSpacing:null})}init(t){let e=t||{};e.aspectRatio=st(e.aspectRatio,1),e.radiusSize=st(e.radiusSize,.3),super.init(e)}getAtomData(t,e,i){return t.getRungAtomData(this.getAtomParams(e,i))}getBondData(t,e,i){let r=this.getBondParams(e,i);return Object.assign(r.colorParams,{rung:!0}),t.getRungBondData(r)}}Ne.add("base",sd);class nd{constructor(t,i){this.m=t,this.tension=i,this.dt=1/this.m,this.delta=1e-4,this.vec1=new e,this.vec2=new e,this.vDir=new e,this.vTan=new e,this.vNorm=new e,this.vBin=new e,this.m2=Math.ceil(this.m/2)}interpolateToArr(t,e,i,r,s,n,o){n[o+0]=Ot(t.x,e.x,i.x,r.x,s,this.tension),n[o+1]=Ot(t.y,e.y,i.y,r.y,s,this.tension),n[o+2]=Ot(t.z,e.z,i.z,r.z,s,this.tension)}interpolateToVec(t,e,i,r,s,n){n.x=Ot(t.x,e.x,i.x,r.x,s,this.tension),n.y=Ot(t.y,e.y,i.y,r.y,s,this.tension),n.z=Ot(t.z,e.z,i.z,r.z,s,this.tension)}interpolatePosition(t,e,i,r,s,n){for(var o=0;o1&&(l=1),this.interpolateToVec(t,e,i,r,c,this.vec1),this.interpolateToVec(t,e,i,r,l,this.vec2),this.vec2.sub(this.vec1).normalize(),this.vec2.toArray(s,h)}}vectorSubdivide(t,e,i,r,s){let n,o=e.next(),a=e.next(),c=e.next();const l=e.size,h=l-1;let d=r||0;for(let r=0;r0&&e{if(t.residueCount<4)return;i.push(t);const r=this.getSpline(t),s=this.getAspectRatio(t),n=r.getSubdividedPosition(),o=r.getSubdividedOrientation(),a=r.getSubdividedColor(this.getColorParams()),c=r.getSubdividedPicking(),l=r.getSubdividedSize(this.getRadiusParams());e.push(new hd(Object.assign({},n,o,a,c,l),this.getBufferParams({radialSegments:this.radialSegments,aspectRatio:s,capped:this.capped})))}),t.getSelection()),{bufferList:e,polymerList:i}}updateData(t,e){De&&Me.time(this.type+" repr update"),t=t||{};for(var i=0,r=e.polymerList.length;i0;Qr(A,b,_);const s=Zr(A,v)<0;if(ns(A,v,Zr(v,x)),Qr(S,x,A),ns(A,v,Zr(v,w)),Qr(C,w,A),0===rs(S)||0===rs(C))continue;os(S,S),os(C,C);const D=n[T]=us(S,C);a[T]=(vi*D).toFixed(1)+String.fromCharCode(176),Kr(k,S,v),os(k,k),Zr(k,C)<0&&ds(k,k),Ih(A,_,S,k,D/2),es(A,o,3*T);const $=Math.ceil(D/i),O=$+(e.extendLine?4:2),R=e.extendLine?36:0,E=new Float32Array(3*O),F=new Float32Array(3*O),L=new Float32Array(9*$),N=new Float32Array(R);c[T]=E,l[T]=F,h[T]=L,d[T]=N,e.extendLine&&(r?(Qr(A,f,y),os(A,A),ns(P,A,1/Zr(S,A)),Jr(P,P,y)):(ns(P,x,1/Zr(S,x)),Jr(P,P,g)),s?(Qr(A,b,g),os(A,A),ns(I,A,1/Zr(C,A)),Jr(I,I,g)):(ns(I,w,1/Zr(C,w)),Jr(I,I,y))),Jr(M,_,S);let z=0;e.extendLine?(es(f,E,z),es(P,F,z),z+=3,es(P,E,z),es(M,F,z),z+=3,es(P,N,0),es(M,N,3),es(r?y:g,N,6),es(r?y:g,N,9),es(M,N,12),es(_,N,15)):(es(_,E,z),es(M,F,z),z+=3);const V=function(t,e){const i=9*e;es(_,L,i),es(M,L,i+3),es(M,E,z),Ih(M,_,S,k,t),es(M,L,i+6),es(M,F,z),z+=3};let G=0;for(let t=i;t{const e=pd(i,t);Object.assign(t,e)})),e.side=st(e.side,"double"),e.opacity=st(e.opacity,.5),e.radiusType=st(e.radiusType,"size"),e.radiusSize=st(e.radiusSize,.15),super.init(e)}getHistogramBinBorderBufferParameters(){return this.getBufferParams({linewidth:this.histogramBinBorderWidth,visible:this.histogramBinBorderVisible,opacity:this.histogramBinBorderOpacity})}getBondArrowsBufferParameters(){return this.getBufferParams({linewidth:this.bondArrowWidth,visible:this.bondArrowVisible,opacity:this.bondArrowOpacity})}getOpaqueMiddleDiscBufferParameters(){return this.getBufferParams({visible:this.opaqueMiddleDiscVisible,opacity:this.opaqueMiddleDiscOpacity})}getHistogramBufferParameters(){return this.getBufferParams({visible:!0,opacity:this.histogramOpacity,side:"double"})}createData(t){if(!t.atomCount||!this.histogramsData.length)return;this.histogramsData.forEach((e=>e.atomPositions=Ph(t,[e.atomQuad])));const e=this.scaleBinToSectorArea?function(t){return Math.sqrt(t)}:function(t){return t};function i(t){const e=t.map((t=>t.length)),i=new Float32Array($i(e));let r=0;for(let e=0;et.startPoints))),position2:i(t.map((t=>t.endPoints))),color:i(t.map((t=>t.startColors))),color2:i(t.map((t=>t.endColors)))},e)}function s(t,e){return new Uo({position:i(t.map((t=>t.triangles))),color:i(t.map((t=>t.triangleColors)))},e)}this.histogramsData.forEach((t=>t.histogram360Scaled=t.histogram360.map(e)));const n=[];for(let t=0;t=3&&(e=yd(i)),void 0!==e&&n.push(e)}return this.frontHistogramBinBordersBuffer=r(n.map((t=>t.frontHistogramBinBorders)),this.getHistogramBinBorderBufferParameters()),this.backHistogramBinBordersBuffer=r(n.map((t=>t.backHistogramBinBorders)),this.getHistogramBinBorderBufferParameters()),this.adjacentBondArrowsBuffer=r(n.map((t=>t.adjacentBondArrows)),this.getBondArrowsBufferParameters()),this.distantBondArrowsBuffer=r(n.map((t=>t.distantBondArrows)),this.getBondArrowsBufferParameters()),this.opaqueMiddleDiscBuffer=s(n.map((t=>t.opaqueMiddleDisc)),this.getOpaqueMiddleDiscBufferParameters()),this.frontHistogramBuffer=s(n.map((t=>t.frontHistogram)),this.getHistogramBufferParameters()),this.backHistogramBuffer=s(n.map((t=>t.backHistogram)),this.getHistogramBufferParameters()),{bufferList:[].concat(this.frontHistogramBinBordersBuffer,this.backHistogramBinBordersBuffer,this.adjacentBondArrowsBuffer,this.distantBondArrowsBuffer,this.opaqueMiddleDiscBuffer,this.frontHistogramBuffer,this.backHistogramBuffer)}}setParameters(t){return super.setParameters(t,{},!1),t&&void 0!==t.histogramBinBorderVisible&&this.setVisibility(this.visible),this}setVisibility(t,e){return super.setVisibility(t,!0),this.frontHistogramBinBordersBuffer&&this.frontHistogramBinBordersBuffer.setVisibility(this.histogramBinBorderVisible),this.backHistogramBinBordersBuffer&&this.backHistogramBinBordersBuffer.setVisibility(this.histogramBinBorderVisible),e||this.viewer.requestRender(),this}}function yd(t){const e=t.atomPositions,i=t.histogram360Scaled,r=i.length<=180?360:2*i.length,s={triangles:new Float32Array(3*r*3),triangleColors:fd(t.opaqueMiddleDiscColor,3*r)},n={triangles:new Float32Array(3*i.length*3),triangleColors:fd(t.frontHistogramColor,3*i.length)},o={triangles:new Float32Array(3*i.length*3),triangleColors:fd(t.backHistogramColor,3*i.length)},a={startPoints:new Float32Array(3*i.length),endPoints:new Float32Array(3*i.length),startColors:fd(t.histogramBinBorderColor,i.length),endColors:fd(t.histogramBinBorderColor,i.length)},c={startPoints:new Float32Array(3*i.length),endPoints:new Float32Array(3*i.length),startColors:fd(t.histogramBinBorderColor,i.length),endColors:fd(t.histogramBinBorderColor,i.length)},l={startPoints:new Float32Array(6),endPoints:new Float32Array(6),startColors:fd(t.adjacentBondArrowColor,i.length),endColors:fd(t.adjacentBondArrowColor,i.length)},h={startPoints:new Float32Array(6),endPoints:new Float32Array(6),startColors:fd(t.distantBondArrowColor,i.length),endColors:fd(t.distantBondArrowColor,i.length)},d=Yr(),u=Yr(),m=Yr(),p=Yr(),f=Yr(),g=Yr(),y=Yr(),b=Yr(),x=Yr(),v=Yr(),w=Yr(),A=Yr(),_=Yr(),S=Yr(),C=Yr(),P=Yr(),I=[d,u,m,p];for(let t=0;t{let u=e[0],m=e[1];if("number"==typeof u&&Number.isInteger(u)&&"number"==typeof m&&Number.isInteger(m)){if(!d.get(u)||!d.get(m))return void(h+=1);c.index=u,l.index=m}else{n.setString(u),o.setString(m);var p=t.getAtomIndices(n),f=t.getAtomIndices(o);if(!p.length||!f.length)return void(h+=1);c.index=p[0],l.index=f[0]}a.addBond(c,l,1),i-=h;var g=c.distanceTo(l);switch(this.labelUnit){case"angstrom":r[i]=g.toFixed(2)+" "+String.fromCharCode(8491);break;case"nm":r[i]=(g/10).toFixed(2)+" nm";break;default:r[i]=g.toFixed(2)}var y=3*i;s[y+0]=(c.x+l.x)/2,s[y+1]=(c.y+l.y)/2,s[y+2]=(c.z+l.z)/2})),h>0&&(i-=h,s=s.subarray(0,3*i));var u=new Os(a.count,!0);return{text:r,position:s,bondSet:u,bondStore:a}}getBondData(t,e,i){const r=t.getBondData(this.getBondParams(e,i));return r.picking&&(r.picking=new to(r.picking.array,r.picking.structure,i.bondStore)),r}createData(t){if(!t.atomCount||!this.atomPair.length)return;const e=this.atomPair.length,i=new s(this.labelColor),r=this.getDistanceData(t,this.atomPair);this.textBuffer=new Eh({position:r.position,size:Si(e,this.labelSize),color:Ci(e,i.r,i.g,i.b),text:r.text},this.getLabelBufferParams());const n={bondSet:r.bondSet,bondStore:r.bondStore},o=this.getBondData(t,{position:!0,color:!0,picking:!0,radius:this.useCylinder},n);return this.useCylinder?this.distanceBuffer=new td(o,this.getBufferParams({openEnded:this.openEnded,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0})):this.distanceBuffer=new Nh(ps(o),this.getBufferParams({linewidth:this.linewidth,visible:this.lineVisible,opacity:this.lineOpacity})),{bondSet:r.bondSet,bondStore:r.bondStore,position:r.position,bufferList:[this.textBuffer,this.distanceBuffer]}}updateData(t,e){super.updateData(t,e);const i={bondSet:e.bondSet,bondStore:e.bondStore},r=this.getBondData(e.sview,t,i),s={};t&&!t.color||Object.assign(s,{color:r.color,color2:r.color2}),t&&!t.radius||Object.assign(s,{radius:r.radius}),this.distanceBuffer.setAttributes(s)}setParameters(t){return super.setParameters(t,{},!1),this.useCylinder||(t&&t.lineOpacity&&this.distanceBuffer.setParameters({opacity:t.lineOpacity}),t&&void 0!==t.opacity&&this.distanceBuffer.setParameters({opacity:this.lineOpacity}),t&&t.linewidth&&this.distanceBuffer.setParameters({linewidth:t.linewidth})),this}}function xd(t){return 2*(t.position.length/3)*3}Ne.add("distance",bd);const vd=Object.assign({scale:1,color:"grey"},zo);class wd extends Go{constructor(t,e={}){super({position:new Float32Array(xd(t)),color:new Float32Array(xd(t))},e),this.isLine=!0,this.vertexShader="Line.vert",this.fragmentShader="Line.frag";const i=new s(this.parameters.color),r=this.geometry.attributes;Ci(xd(t)/3,i.r,i.g,i.b,r.color.array),this.setAttributes(t)}get defaultParameters(){return vd}setAttributes(t={}){const e=this.geometry.attributes;let i,r,s;t.position&&t.vector&&(i=t.position,r=t.vector,s=e.position.array,e.position.needsUpdate=!0);const n=this.size/2,o=this.parameters.scale;if(i&&r)for(let t=0;t{if(t.residueCount<4)return;i.push(t);const r=new Ca(t),s=r.getPosition(),n=r.getColor(this.getColorParams()),o=r.getSize(this.getRadiusParams()),a=r.getPicking();e.push(new Gc({position:s.center,color:n.color,radius:o.size,picking:a.picking},this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0})),new wd({position:s.center,vector:s.axis},this.getBufferParams({color:"skyblue",scale:1})),new wd({position:s.center,vector:s.resdir},this.getBufferParams({color:"lightgreen",scale:1})))}),t.getSelection()),{bufferList:e,polymerList:i}}updateData(t,e){De&&Me.time(this.type+" repr update"),t=t||{};for(let i=0,r=e.polymerList.length;i radius2) {\nspaceposition.y = mapping.y * 1.5 * radius1;\nspaceposition.x = mapping.x * 1.5 * radius1;\n} else {\nspaceposition.y = mapping.y * 1.5 * radius2;\nspaceposition.x = mapping.x * 1.5 * radius2;\n}\nspaceposition.w = 1.0;\nvec4 e3 = vec4( 1.0 );\nvec3 e1, e1_temp, e2, e2_temp;\ne3.xyz = normalize(position_atom1-position_atom2);\nif (e3.z == 0.0) { e3.z = 0.0000000000001;}\nif ( (position_atom1.x - position_atom2.x) == 0.0) { position_atom1.x += 0.001;}\nif ( (position_atom1.y - position_atom2.y) == 0.0) { position_atom1.y += 0.001;}\nif ( (position_atom1.z - position_atom2.z) == 0.0) { position_atom1.z += 0.001;}\nvec4 focus = vec4( 1.0 );\nfocus.x = ( position_atom1.x*position_atom1.x - position_atom2.x*position_atom2.x +\n( radius2*radius2 - radius1*radius1 )*e3.x*e3.x/shrink )/(2.0*(position_atom1.x - position_atom2.x));\nfocus.y = ( position_atom1.y*position_atom1.y - position_atom2.y*position_atom2.y +\n( radius2*radius2 - radius1*radius1 )*e3.y*e3.y/shrink )/(2.0*(position_atom1.y - position_atom2.y));\nfocus.z = ( position_atom1.z*position_atom1.z - position_atom2.z*position_atom2.z +\n( radius2*radius2 - radius1*radius1 )*e3.z*e3.z/shrink )/(2.0*(position_atom1.z - position_atom2.z));\ne1.x = 1.0;\ne1.y = 1.0;\ne1.z = ( (e3.x*focus.x + e3.y*focus.y + e3.z*focus.z) - e1.x*e3.x - e1.y*e3.y)/e3.z;\ne1_temp = e1 - focus.xyz;\ne1 = normalize(e1_temp);\ne2_temp = e1.yzx * e3.zxy - e1.zxy * e3.yzx;\ne2 = normalize(e2_temp);\nmat3 R= mat3( e1.xyz, e2.xyz, e3.xyz );\nvertex_position.xyz = R * spaceposition.xyz;\nvertex_position.w = 1.0;\nvertex_position.x += (position_atom1.x+position_atom2.x) / 2.0;\nvertex_position.y += (position_atom1.y+position_atom2.y) / 2.0;\nvertex_position.z += (position_atom1.z+position_atom2.z) / 2.0;\ngl_Position = modelViewProjectionMatrix * vertex_position;\nvec4 i_near, i_far;\nvec4 near = gl_Position;\nnear.z = 0.0 ;\nnear = modelViewProjectionMatrixInverse * near;\ni_near = near;\nvec4 far = gl_Position;\nfar.z = far.w ;\ni_far = modelViewProjectionMatrixInverse * far;\nprime1 = vec4( position_atom1 - (position_atom1 - focus.xyz)*shrink, 1.0 );\nprime2 = vec4( position_atom2 - (position_atom2 - focus.xyz)*shrink, 1.0 );\nfloat Rsquare = (radius1*radius1/shrink) - (\n(position_atom1.x - focus.x)*(position_atom1.x - focus.x) +\n(position_atom1.y - focus.y)*(position_atom1.y - focus.y) +\n(position_atom1.z - focus.z)*(position_atom1.z - focus.z)\n);\nfocus.w = Rsquare;\nmatrix_near = mat4( i_near, i_far, focus, e3 );\ngl_Position.z = 1.0;\n}"),Ve.add("shader/HyperballStickImpostor.frag","#define STANDARD\n#define IMPOSTOR\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 interiorColor;\nuniform float interiorDarkening;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\nuniform float clipNear;\nuniform float shrink;\nuniform mat4 modelViewMatrix;\nuniform mat4 modelViewProjectionMatrix;\nuniform mat4 modelViewMatrixInverseTranspose;\nuniform mat4 projectionMatrix;\nvarying mat4 matrix_near;\nvarying vec4 prime1;\nvarying vec4 prime2;\nvarying float vRadius;\nvarying float vRadius2;\n#ifdef PICKING\nuniform float objectId;\nvarying vec3 vPickingColor;\n#else\nvarying vec3 vColor1;\nvarying vec3 vColor2;\n#include common\n#include fog_pars_fragment\n#include bsdfs\n#include lights_pars_begin\n#include lights_physical_pars_fragment\n#endif\nbool interior = false;\nfloat calcClip( vec4 cameraPos ){\nreturn dot( cameraPos, vec4( 0.0, 0.0, 1.0, clipNear - 0.5 ) );\n}\nfloat calcClip( vec3 cameraPos ){\nreturn calcClip( vec4( cameraPos, 1.0 ) );\n}\nfloat calcDepth( in vec3 cameraPos ){\nvec2 clipZW = cameraPos.z * projectionMatrix[2].zw + projectionMatrix[3].zw;\nreturn 0.5 + 0.5 * clipZW.x / clipZW.y;\n}\nstruct Ray {\nvec3 origin ;\nvec3 direction ;\n};\nbool cutoff_plane (vec3 M, vec3 cutoff, vec3 x3){\nfloat a = x3.x;\nfloat b = x3.y;\nfloat c = x3.z;\nfloat d = -x3.x*cutoff.x-x3.y*cutoff.y-x3.z*cutoff.z;\nfloat l = a*M.x+b*M.y+c*M.z+d;\nif (l<0.0) {return true;}\nelse{return false;}\n}\nvec3 isect_surf(Ray r, mat4 matrix_coef){\nvec4 direction = vec4(r.direction, 0.0);\nvec4 origin = vec4(r.origin, 1.0);\nfloat a = dot(direction,(matrix_coef*direction));\nfloat b = dot(origin,(matrix_coef*direction));\nfloat c = dot(origin,(matrix_coef*origin));\nfloat delta =b*b-a*c;\ngl_FragColor.a = 1.0;\nif (delta<0.0){\ndiscard;\n}\nfloat t1 =(-b-sqrt(delta))/a;\nreturn r.origin+t1*r.direction;\n}\nvec3 isect_surf2(Ray r, mat4 matrix_coef){\nvec4 direction = vec4(r.direction, 0.0);\nvec4 origin = vec4(r.origin, 1.0);\nfloat a = dot(direction,(matrix_coef*direction));\nfloat b = dot(origin,(matrix_coef*direction));\nfloat c = dot(origin,(matrix_coef*origin));\nfloat delta =b*b-a*c;\ngl_FragColor.a = 1.0;\nif (delta<0.0){\ndiscard;\n}\nfloat t2 =(-b+sqrt(delta))/a;\nreturn r.origin+t2*r.direction;\n}\nRay primary_ray(vec4 near1, vec4 far1){\nvec3 near=near1.xyz/near1.w;\nvec3 far=far1.xyz/far1.w;\nreturn Ray(near,far-near);\n}\nfloat update_z_buffer(vec3 M, mat4 ModelViewP){\nfloat depth1;\nvec4 Ms=(ModelViewP*vec4(M,1.0));\nreturn depth1=(1.0+Ms.z/Ms.w)/2.0;\n}\nvoid main(){\nfloat radius = max( vRadius, vRadius2 );\nvec4 i_near, i_far, focus;\nvec3 e3, e1, e1_temp, e2;\ni_near = vec4(matrix_near[0][0],matrix_near[0][1],matrix_near[0][2],matrix_near[0][3]);\ni_far = vec4(matrix_near[1][0],matrix_near[1][1],matrix_near[1][2],matrix_near[1][3]);\nfocus = vec4(matrix_near[2][0],matrix_near[2][1],matrix_near[2][2],matrix_near[2][3]);\ne3 = vec3(matrix_near[3][0],matrix_near[3][1],matrix_near[3][2]);\ne1.x = 1.0;\ne1.y = 1.0;\ne1.z = ( (e3.x*focus.x + e3.y*focus.y + e3.z*focus.z) - e1.x*e3.x - e1.y*e3.y)/e3.z;\ne1_temp = e1 - focus.xyz;\ne1 = normalize(e1_temp);\ne2 = normalize(cross(e1,e3));\nvec4 equation = focus;\nfloat shrinkfactor = shrink;\nfloat t1 = -1.0/(1.0-shrinkfactor);\nfloat t2 = 1.0/(shrinkfactor);\nvec4 colonne1, colonne2, colonne3, colonne4;\nmat4 mat;\nvec3 equation1 = vec3(t2,t2,t1);\nfloat A1 = - e1.x*equation.x - e1.y*equation.y - e1.z*equation.z;\nfloat A2 = - e2.x*equation.x - e2.y*equation.y - e2.z*equation.z;\nfloat A3 = - e3.x*equation.x - e3.y*equation.y - e3.z*equation.z;\nfloat A11 = equation1.x*e1.x*e1.x + equation1.y*e2.x*e2.x + equation1.z*e3.x*e3.x;\nfloat A21 = equation1.x*e1.x*e1.y + equation1.y*e2.x*e2.y + equation1.z*e3.x*e3.y;\nfloat A31 = equation1.x*e1.x*e1.z + equation1.y*e2.x*e2.z + equation1.z*e3.x*e3.z;\nfloat A41 = equation1.x*e1.x*A1 + equation1.y*e2.x*A2 + equation1.z*e3.x*A3;\nfloat A22 = equation1.x*e1.y*e1.y + equation1.y*e2.y*e2.y + equation1.z*e3.y*e3.y;\nfloat A32 = equation1.x*e1.y*e1.z + equation1.y*e2.y*e2.z + equation1.z*e3.y*e3.z;\nfloat A42 = equation1.x*e1.y*A1 + equation1.y*e2.y*A2 + equation1.z*e3.y*A3;\nfloat A33 = equation1.x*e1.z*e1.z + equation1.y*e2.z*e2.z + equation1.z*e3.z*e3.z;\nfloat A43 = equation1.x*e1.z*A1 + equation1.y*e2.z*A2 + equation1.z*e3.z*A3;\nfloat A44 = equation1.x*A1*A1 + equation1.y*A2*A2 + equation1.z*A3*A3 - equation.w;\ncolonne1 = vec4(A11,A21,A31,A41);\ncolonne2 = vec4(A21,A22,A32,A42);\ncolonne3 = vec4(A31,A32,A33,A43);\ncolonne4 = vec4(A41,A42,A43,A44);\nmat = mat4(colonne1,colonne2,colonne3,colonne4);\nRay ray = primary_ray(i_near,i_far) ;\nvec3 M;\nM = isect_surf(ray, mat);\nif (cutoff_plane(M, prime1.xyz, -e3) || cutoff_plane(M, prime2.xyz, e3)){ discard; }\nvec4 M1 = vec4(M,1.0);\nvec4 M2 = mat*M1;\nvec3 _normal = ( modelViewMatrixInverseTranspose * M2 ).xyz;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix) ;\n#ifdef NEAR_CLIP\nif( calcClip( modelViewMatrix * vec4( M, 1.0 ) ) > 0.0 ){\nM = isect_surf2(ray, mat);\nif( calcClip( modelViewMatrix * vec4( M, 1.0 ) ) > 0.0 )\ndiscard;\ninterior = true;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix) ;\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( clipNear - 0.5 ) ) ) + ( 0.0000001 / radius ) );\n}\n}else if( gl_FragDepthEXT <= 0.0 ){\nM = isect_surf2(ray, mat);\ninterior = true;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix);\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / radius );\n}\n}\n#else\nif( gl_FragDepthEXT <= 0.0 ){\nM = isect_surf2(ray, mat);\ninterior = true;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix) ;\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / radius );\n}\n}\n#endif\nif (cutoff_plane(M, prime1.xyz, -e3) || cutoff_plane(M, prime2.xyz, e3)){ discard; }\nif (gl_FragDepthEXT < 0.0)\ndiscard;\nif (gl_FragDepthEXT > 1.0)\ndiscard;\nfloat distance_ratio = ((M.x-prime2.x)*e3.x + (M.y-prime2.y)*e3.y +(M.z-prime2.z)*e3.z) /\ndistance(prime2.xyz,prime1.xyz);\n#ifdef PICKING\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 vViewPosition = -( modelViewMatrix * vec4( M, 1.0 ) ).xyz;\nvec3 vNormal = _normal;\nvec3 vColor;\nif( distance_ratio>0.5 ){\nvColor = vColor1;\n}else{\nvColor = vColor2;\n}\nvec4 diffuseColor = vec4( diffuse, opacity );\nReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\nvec3 totalEmissiveLight = emissive;\n#include color_fragment\n#include roughnessmap_fragment\n#include metalnessmap_fragment\nvec3 normal = normalize( vNormal );\nvec3 geometryNormal = normal;\n#include lights_physical_fragment\n#include lights_fragment_begin\n#include lights_fragment_end\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\nif( interior ){\n#ifdef USE_INTERIOR_COLOR\noutgoingLight.xyz = interiorColor;\n#else\n#ifdef DIFFUSE_INTERIOR\noutgoingLight.xyz = vColor;\n#endif\n#endif\noutgoingLight.xyz *= 1.0 - interiorDarkening;\n}\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");const Sd=new Float32Array([-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,-1,1,-1,1,1,-1,1,1,1,-1,1,1]),Cd=new Uint16Array([0,1,2,0,2,3,1,5,6,1,6,2,4,6,5,4,7,6,0,7,4,0,3,7,0,5,1,0,4,5,3,2,6,3,6,7]);class Pd extends Fc{constructor(t,e={}){super("v3",t,e)}get mapping(){return Sd}get mappingIndices(){return Cd}get mappingIndicesSize(){return 36}get mappingSize(){return 8}get mappingItemSize(){return 3}}const Id=Object.assign({shrink:.14},zo),kd=Object.assign({shrink:{uniform:!0}},Vo);class Md extends Pd{constructor(t,e={}){super(t,e),this.parameterTypes=kd,this.isImpostor=!0,this.vertexShader="HyperballStickImpostor.vert",this.fragmentShader="HyperballStickImpostor.frag",this.addUniforms({modelViewProjectionMatrix:{value:new i},modelViewProjectionMatrixInverse:{value:new i},modelViewMatrixInverseTranspose:{value:new i},shrink:{value:this.parameters.shrink}}),this.addAttributes({position1:{type:"v3",value:null},position2:{type:"v3",value:null},color2:{type:"c",value:null},radius:{type:"f",value:null},radius2:{type:"f",value:null}}),this.setAttributes(t),this.makeMapping()}get defaultParameters(){return Id}}Object.assign({disableImpostor:!1},Hh,Id);const Td=class{constructor(t,e={}){return!Ie||e&&e.disableImpostor?(t.radius=function(t,e){const i=t.length,r=new Float32Array(i);for(let s=0;sa.push(r.atomLabel(t)))))}else if("residue"===this.labelGrouping){e&&!e.position||(c=[]),e&&!e.color||(h=[]),e&&!e.radius||(l=[]),e&&!e.text||(a=[]),i.colorParams&&(i.colorParams.structure=t.getStructure());const d=Fe.getScheme(i.colorParams),u=new pa(i.radiusParams),m=t.getAtomProxy();let p=0;t.eachResidue((t=>{const i=3*p;t.isProtein()||t.isNucleic()?(m.index=t.traceAtomIndex,e&&!e.position||m.positionToArray(c,i)):(m.index=t.atomOffset,e&&!e.position||t.positionToArray(c,i)),e&&!e.color||d.atomColorToArray(m,h,i),e&&!e.radius||(l[p]=u.atomRadius(m)),e&&!e.text||a.push(r.atomLabel(m)),++p})),e&&!e.position||(s=new Float32Array(c)),e&&!e.color||(o=new Float32Array(h)),e&&!e.radius||(n=new Float32Array(l))}return{position:s,size:n,color:o,text:a}}createData(t){return{bufferList:[new Eh(this.getTextData(t,{position:!0,color:!0,radius:!0,text:!0}),this.getBufferParams({fontFamily:this.fontFamily,fontStyle:this.fontStyle,fontWeight:this.fontWeight,xOffset:this.xOffset,yOffset:this.yOffset,zOffset:this.zOffset,attachment:this.attachment,showBorder:this.showBorder,borderColor:this.borderColor,borderWidth:this.borderWidth,showBackground:this.showBackground,backgroundColor:this.backgroundColor,backgroundMargin:this.backgroundMargin,backgroundOpacity:this.backgroundOpacity,fixedSize:this.fixedSize}))]}}updateData(t,e){e.bufferList[0].setAttributes(this.getTextData(e.sview,t))}getAtomRadius(){return 0}}function Od(t){const e=t.getAtomSet(),i=t.getBondSet(),r=t.getBondProxy();return i.forEach((function(t){r.index=t,e.clear(r.atomIndex1),e.clear(r.atomIndex2)})),e}Ne.add("label",$d);class Rd extends Sh{constructor(t,e,i){super(t,e,i),this.type="line",this.parameters=Object.assign({multipleBond:{type:"select",rebuild:!0,options:{off:"off",symmetric:"symmetric",offset:"offset"}},bondSpacing:{type:"number",precision:2,max:2,min:.5},linewidth:{type:"integer",max:50,min:1,buffer:!0},lines:{type:"boolean",rebuild:!0},crosses:{type:"select",rebuild:!0,options:{off:"off",lone:"lone",all:"all"}},crossSize:{type:"number",precision:2,max:2,min:.1}},this.parameters,{flatShaded:null,side:null,wireframe:null,roughness:null,metalness:null}),this.init(i)}init(t){var e=t||{};this.multipleBond=st(e.multipleBond,"off"),this.bondSpacing=st(e.bondSpacing,1),this.linewidth=st(e.linewidth,2),this.lines=st(e.lines,!0),this.crosses=st(e.crosses,"lone"),this.crossSize=st(e.crossSize,.4),super.init(e)}getAtomRadius(t){return.1}getBondParams(t,e){return e=Object.assign({multipleBond:this.multipleBond,bondSpacing:this.bondSpacing,radiusParams:{type:"size",size:.1,scale:1}},e),super.getBondParams(t,e)}_crossData(t,e){if(t&&!t.position&&!t.color)return;const i={};"lone"===this.crosses&&Object.assign(i,{atomSet:Od(e)});const r=e.getAtomData(this.getAtomParams(t,i)),s={},n=r.position,o=r.color,a=r.picking,c=(n||o).length,l=3*c;let h=new Float32Array(0),d=new Float32Array(0),u=new Float32Array(0),m=new Float32Array(0),p=0,f=new Float32Array(0);t&&!t.position||(h=s.position1=new Float32Array(l),d=s.position2=new Float32Array(l),p=this.crossSize/2),t&&!t.color||(u=s.color=new Float32Array(l),m=s.color2=new Float32Array(l)),t&&!t.picking||(f=new Float32Array(3*r.picking.array.length));for(let e=0;el?u[f]=-1:(c=Math.sqrt(l-a),u[f]=Math.floor(c)),++f;p[g]=d,m[g]=u}}function k(i){var r,s,n,a,d,f,b,v,w,A,S,C,P,I,k,M,T,B,D=3*i,$=i;r=Math.floor(.5+o*(t[D]+u[0])),s=Math.floor(.5+o*(t[D+1]+u[1])),n=Math.floor(.5+o*(t[D+2]+u[2]));var O,R=e[$],E=m[R],F=0,L=l*h,N=p[R];for(A=0;A=c||I>=l||k>=h)){var z=P*L+I*h+k;if(g)if(y[z]&_){if(y[z]&_){var V=x[z];V!==D&&b*b+v*v+w*w<(a=r+b-Math.floor(.5+o*(t[V]+u[0])))*a+(d=s+v-Math.floor(.5+o*(t[V+1]+u[1])))*d+(f=n+w-Math.floor(.5+o*(t[V+2]+u[2])))*f&&(x[z]=i)}}else y[z]|=_,x[z]=i;else y[z]|=_}F++}}function M(e){var i,r;for(console.time("EDTSurface fillvoxels"),i=0,r=y.length;i=c||_>=l||C>=h)){var L=A*F+_*h+C;if(y[L]&S){if(g){var N=x[L];b*b+v*v+w*w<(a=Math.floor(.5+o*(t[N]+u[0])))*a+(d=Math.floor(.5+o*(t[N+1]+u[1])))*d+(f=Math.floor(.5+o*(t[N+2]+u[2])))*f&&(x[L]=i)}}else y[L]|=S,g&&(x[L]=i)}R++}}function B(){var t,e,i,r;console.time("EDTSurface fastdistancemap");var s,n=Ed(c,l,h,Uint16Array,3),o=l*h,d=f*f,u=0;for(t=0;t0);var A,P=a*a,I=new Uint16Array(3);for(t=0;t=P)||(y[s]|=C,g&&y[s]&S&&(n.toArray(t,e,i,I),A=I[0]*o+I[1]*h+I[2],x[s]=x[A])));console.timeEnd("EDTSurface fastdistancemap")}function D(t,e,i,r){var s,n,o,a,d,u,m,p,f,g,x,v,w=new Uint16Array(3),A=0;if(0===i)return A;var I=-1,k=-1,M=-1,T=l*h;for(m=0,f=i;m-1&&k-1&&M-1&&(y[x=I*T+h*k+M]&_&&!(y[x]&S)?(e.fromArray(I,k,M,w),g=(a=I-w[0])*a+(d=k-w[1])*d+(u=M-w[2])*u,b[x]=g,y[x]|=S,y[x]|=C,r[A]=I,r[A+1]=k,r[A+2]=M,A+=3):y[x]&_&&y[x]&S&&(g=(a=I-w[0])*a+(d=k-w[1])*d+(u=M-w[2])*u)-1&&k-1&&M-1&&(y[x=I*T+h*k+M]&_&&!(y[x]&S)?(e.fromArray(I,k,M,w),g=(a=I-w[0])*a+(d=k-w[1])*d+(u=M-w[2])*u,b[x]=g,y[x]|=S,y[x]|=C,r[A]=I,r[A+1]=k,r[A+2]=M,A+=3):y[x]&_&&y[x]&S&&(g=(a=I-w[0])*a+(d=k-w[1])*d+(u=M-w[2])*u)-1&&k-1&&M-1&&(y[x=I*T+h*k+M]&_&&!(y[x]&S)?(e.fromArray(I,k,M,w),g=(a=I-w[0])*a+(d=k-w[1])*d+(u=M-w[2])*u,b[x]=g,y[x]|=S,y[x]|=C,r[A]=I,r[A+1]=k,r[A+2]=M,A+=3):y[x]&_&&y[x]&S&&(g=(a=I-w[0])*a+(d=k-w[1])*d+(u=M-w[2])*u)-1&&o-1&&d-1&&aT&&(T=O)}return{neighbourListLength:27*T+1,withinRadii:function(s,n,o,a,d){for(var u=0,m=p(s,c),f=p(n,l),g=p(o,h),y=Math.max(0,m-1),w=Math.max(0,f-1),_=Math.max(0,g-1),S=Math.min(b,m+2),C=Math.min(x,f+2),M=Math.min(v,g+2),T=y;Tu&&(u=h[t]);!function(){const t=$o(c,l,u,p,0);p=t.scaleFactor,y=t.dim,b=t.matrix,$=Math.max(5,2+Math.floor(m*p)),x=Si(y[0]*y[1]*y[2],-1001),v=new Int32Array(x.length),w=new Float32Array(y[0]),A=new Float32Array(y[1]),_=new Float32Array(y[2]),R(w,c[0],1/p),R(A,c[1],1/p),R(_,c[2],1/p)}(),function(){var t=0,e=2*Math.PI/g;C=new Float32Array(g),S=new Float32Array(g);for(var i=0;i=0;){if(n!==r&&n!==s&&F(n,t,e,i))return k=n,n;n=I[++o]}return k=-1,-1}function F(e,i,r,s){var n=3*e,o=d[e],a=t[n]-i,c=t[n+1]-r,l=t[n+2]-s;return a*a+c*c+l*l0&&u=0;)t{e(this._makeSurface(t.data.sd,i))}),(t=>{console.warn("MolecularSurface.getSurfaceWorker error - trying without worker",t),this.worker.terminate(),this.worker=void 0;const r=this.getSurface(i);e(r)}))}else{const t=this.getSurface(i);e(t)}}dispose(){this.worker&&this.worker.terminate()}}class Vd extends Sh{constructor(t,e,i){super(t,e,i),this.type="surface",this.parameters=Object.assign({surfaceType:{type:"select",rebuild:!0,options:{vws:"vws",sas:"sas",ms:"ms",ses:"ses",av:"av"}},probeRadius:{type:"number",precision:1,max:20,min:0,rebuild:!0},smooth:{type:"integer",precision:1,max:10,min:0,rebuild:!0},scaleFactor:{type:"number",precision:1,max:5,min:0,rebuild:!0},cutoff:{type:"number",precision:2,max:50,min:0,rebuild:!0},contour:{type:"boolean",rebuild:!0},background:{type:"boolean",rebuild:!0},opaqueBack:{type:"boolean",buffer:!0},filterSele:{type:"text",rebuild:!0},colorVolume:{type:"hidden"},useWorker:{type:"boolean",rebuild:!0}},this.parameters,{radius:null,scale:null}),this.__infoList=[],this.structure.signals.refreshed.add((()=>{this.__forceNewMolsurf=!0})),this.toBePrepared=!0,this.init(i)}init(t){const e=t||{};e.colorScheme=st(e.colorScheme,"uniform"),e.colorValue=st(e.colorValue,14540253),e.disablePicking=st(e.disablePicking,!0),this.surfaceType=st(e.surfaceType,"ms"),this.probeRadius=st(e.probeRadius,1.4),this.smooth=st(e.smooth,2),this.scaleFactor=st(e.scaleFactor,2),this.cutoff=st(e.cutoff,0),this.contour=st(e.contour,!1),this.background=st(e.background,!1),this.opaqueBack=st(e.opaqueBack,!0),this.filterSele=st(e.filterSele,""),this.colorVolume=st(e.colorVolume,void 0),this.useWorker=st(e.useWorker,!0),super.init(t)}prepareData(t,i,r){let s=this.__infoList[i];if(s||(s={},this.__infoList[i]=s),s.molsurf&&s.sele===t.selection.string)r(i);else{if(this.filterSele){const s=t.structure.getView(new pe(this.filterSele)),n=s.boundingBox.getSize(new e),o=Math.max(n.x,n.y,n.z),a=t.getAtomSetWithinPoint(s.center,o/2+6);if(0===(t=t.getView(new pe(t.getAtomSetWithinSelection(a,3).toSeleString()))).atomCount)return void r(i)}s.sele=t.selection.string,s.molsurf=new zd(t);const n=this.getSurfaceParams(),o=t=>{s.surface=t,r(i)};this.useWorker?s.molsurf.getSurfaceWorker(n,o):o(s.molsurf.getSurface(n))}}prepare(t){if((this.__forceNewMolsurf||this.__sele!==this.selection.string||this.__surfaceParams!==JSON.stringify(this.getSurfaceParams()))&&(this.__infoList.forEach((t=>{t&&t.molsurf&&t.molsurf.dispose()})),this.__infoList.length=0),0===this.structureView.atomCount)return void t();const e=()=>{this.__sele=this.selection.string,this.__surfaceParams=JSON.stringify(this.getSurfaceParams()),this.__forceNewMolsurf=!1,t()},i="default"===this.assembly?this.defaultAssembly:this.assembly,r=this.structure.biomolDict[i];r?r.partList.forEach(((t,i)=>{const s=t.getView(this.structureView);this.prepareData(s,i,(t=>{t===r.partList.length-1&&e()}))})):this.prepareData(this.structureView,0,e)}createData(t,e){const i=this.__infoList[e],r=i.surface;if(!r)return;const s={position:r.getPosition(),color:r.getColor(this.getColorParams()),index:r.getFilteredIndex(this.filterSele,t)},n=[];if(r.contour){const t=new Xo(s,this.getBufferParams({wireframe:!1}));n.push(t)}else{Object.assign(s,{normal:r.getNormal(),picking:r.getPicking(t.getStructure())});const e=new jo(s,this.getBufferParams({background:this.background,opaqueBack:this.opaqueBack,dullInterior:!1}));if("double"==this.getBufferParams().side){const t=new qo(e);n.push(t)}else n.push(e)}return{bufferList:n,info:i}}updateData(t,e){const i={};if(t.position||t.radius)return this.__forceNewMolsurf=!0,void this.build();t.color&&(i.color=e.info.surface.getColor(this.getColorParams())),t.index&&(i.index=e.info.surface.getFilteredIndex(this.filterSele,e.sview)),e.bufferList[0].setAttributes(i)}setParameters(t,e={},i){return t&&t.filterSele&&(e.index=!0),t&&void 0!==t.colorVolume&&(e.color=!0),t&&t.wireframe&&(t.contour||void 0===t.contour&&this.contour)&&(t.wireframe=!1),super.setParameters(t,e,i),this}getSurfaceParams(t={}){return Object.assign({type:this.surfaceType,probeRadius:this.probeRadius,scaleFactor:this.scaleFactor,smooth:this.smooth&&!this.contour,cutoff:this.cutoff,contour:this.contour,useWorker:this.useWorker,radiusParams:this.getRadiusParams()},t)}getColorParams(){const t=super.getColorParams();return t.volume=this.colorVolume,t}getAtomRadius(){return 0}clear(){super.clear()}dispose(){this.__infoList.forEach((t=>{t&&t.molsurf&&t.molsurf.dispose()})),this.__infoList.length=0,super.dispose()}}Ne.add("surface",Vd);class Gd extends Sh{constructor(t,e,i){super(t,e,i),this.type="point",this.parameters=Object.assign({pointSize:{type:"number",precision:1,max:100,min:0,buffer:!0},sizeAttenuation:{type:"boolean",buffer:!0},sortParticles:{type:"boolean",rebuild:!0},useTexture:{type:"boolean",buffer:!0},alphaTest:{type:"range",step:.001,max:1,min:0,buffer:!0},forceTransparent:{type:"boolean",buffer:!0},edgeBleach:{type:"range",step:.001,max:1,min:0,buffer:!0}},this.parameters,{flatShaded:null,wireframe:null,linewidth:null,side:null,roughness:null,metalness:null}),this.init(i)}init(t){var e=t||{};this.pointSize=st(e.pointSize,1),this.sizeAttenuation=st(e.sizeAttenuation,!0),this.sortParticles=st(e.sortParticles,!1),this.useTexture=st(e.useTexture,!1),this.alphaTest=st(e.alphaTest,.5),this.forceTransparent=st(e.forceTransparent,!1),this.edgeBleach=st(e.edgeBleach,0),super.init(e)}createData(t){var e=t.getAtomData(this.getAtomParams({position:!0,color:!0,picking:!0}));return{bufferList:[new Wc(e,this.getBufferParams({pointSize:this.pointSize,sizeAttenuation:this.sizeAttenuation,sortParticles:this.sortParticles,useTexture:this.useTexture,alphaTest:this.alphaTest,forceTransparent:this.forceTransparent,edgeBleach:this.edgeBleach}))]}}updateData(t,e){var i=e.sview.getAtomData(this.getAtomParams(t)),r={};t&&!t.position||Object.assign(r,{position:i.position}),t&&!t.color||Object.assign(r,{color:i.color}),e.bufferList[0].setAttributes(r)}getAtomRadius(){return.1}}Ne.add("point",Gd),Ve.add("shader/Ribbon.vert","#define STANDARD\nuniform float clipNear;\nuniform vec3 clipCenter;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvarying vec3 vViewPosition;\n#endif\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\nattribute vec3 dir;\nattribute float size;\n#ifdef PICKING\n#include unpack_color\nattribute float primitiveId;\nvarying vec3 vPickingColor;\n#else\n#include color_pars_vertex\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\n#endif\n#include common\nvoid main(void){\n#ifdef PICKING\nvPickingColor = unpackColor( primitiveId );\n#else\n#include color_vertex\n#include beginnormal_vertex\n#include defaultnormal_vertex\n#ifndef FLAT_SHADED\nvNormal = normalize( transformedNormal );\n#endif\n#endif\n#include begin_vertex\ntransformed += normalize( dir ) * size;\n#include project_vertex\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvViewPosition = -mvPosition.xyz;\n#endif\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n#include nearclip_vertex\n}");const Ud=new Uint16Array([0,1,2,1,3,2]);function jd(t){return 3*(4*(t.position.length/3-1))}class Hd extends Uo{constructor(t,e={}){super({position:new Float32Array(jd(t)),color:new Float32Array(jd(t)),index:xt(jd(t),jd(t)/3),normal:new Float32Array(jd(t)),picking:t.picking},e),this.vertexShader="Ribbon.vert";const i=t.position.length/3-1,r=4*i,s=3*r;this.addAttributes({dir:{type:"v3",value:new Float32Array(s)}}),this.addAttributes({size:{type:"f",value:new Float32Array(r)}}),t.primitiveId=Pi(i),this.setAttributes(t),this.makeIndex()}setAttributes(t={}){const e=this.size/4,i=this.geometry.attributes;let r,s,n,o,a,c,l,h,d,u,m,p,f,g,y,b,x,v,w;t.position&&(r=t.position,l=i.position.array,i.position.needsUpdate=!0),t.normal&&(s=t.normal,h=i.normal.array,i.normal.needsUpdate=!0),t.size&&(n=t.size,d=i.size.array,i.size.needsUpdate=!0),t.dir&&(o=t.dir,u=i.dir.array,i.dir.needsUpdate=!0),t.color&&(a=t.color,m=i.color.array,i.color.needsUpdate=!0),t.primitiveId&&(c=t.primitiveId,p=i.primitiveId.array,i.primitiveId.needsUpdate=!0);let A=n?n[0]:null;for(f=0;f{if(!(t.residueCount<4)){i.push(t);var r=new od(t,this.getSplineParams()),s=r.getSubdividedPosition(),n=r.getSubdividedOrientation(),o=r.getSubdividedColor(this.getColorParams()),a=r.getSubdividedPicking(),c=r.getSubdividedSize(this.getRadiusParams());e.push(new Hd({position:s.position,normal:n.binormal,dir:n.normal,color:o.color,size:c.size,picking:a.picking},this.getBufferParams()))}}),t.getSelection()),{bufferList:e,polymerList:i}}updateData(t,e){t=t||{};var i=0,r=e.polymerList.length;for(i=0;i{if(t.residueCount<4||t.isNucleic())return;const s=new Pa(t),n=s.getAxis(this.localAngle,this.centerDist,this.ssBorder,this.getColorParams(),this.getRadiusParams());e+=n.size.length,i.push(n),r.push(s)}),t.getSelection());const s={begin:new Float32Array(3*e),end:new Float32Array(3*e),size:new Float32Array(e),color:new Float32Array(3*e),picking:{}};let n=new Float32Array(e),o=0;i.forEach((function(t){s.begin.set(t.begin,3*o),s.end.set(t.end,3*o),s.size.set(t.size,o),s.color.set(t.color,3*o),n.set(t.picking.array,o),o+=t.size.length})),e&&(s.picking=new Yn(n,t.getStructure()));return{bufferList:[new td({position1:s.begin,position2:s.end,color:s.color,color2:s.color,radius:s.size,picking:s.picking},this.getBufferParams({openEnded:this.openEnded,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0}))],axisList:i,helixbundleList:r,axisData:s}}updateData(t,e){if((t=t||{}).position)this.build();else{var i={};if(t.color||t.radius){var r=0;e.helixbundleList.forEach((i=>{var s=i.getAxis(this.localAngle,this.centerDist,this.ssBorder,this.getColorParams(),this.getRadiusParams());t.color&&e.axisData.color.set(s.color,3*r),(t.radius||t.scale)&&e.axisData.size.set(s.size,r),r+=s.size.length})),t.color&&Object.assign(i,{color:e.axisData.color,color2:e.axisData.color}),(t.radius||t.scale)&&Object.assign(i,{radius:e.axisData.size})}e.bufferList[0].setAttributes(i)}}}Ne.add("rocket",qd);class Xd extends dd{constructor(t,e,i){super(t,e,i),this.type="rope",this.parameters=Object.assign({smooth:{type:"integer",max:15,min:0,rebuild:!0}},this.parameters,{aspectRatio:null,smoothSheet:null})}init(t){var e=t||{};e.aspectRatio=1,e.tension=st(e.tension,.5),e.radiusScale=st(e.radiusScale,5),e.smoothSheet=!1,this.smooth=st(e.smooth,2),super.init(e)}getSpline(t){var e=new Ca(t);return new od(t,this.getSplineParams({directional:!1,positionIterator:e.getCenterIterator(this.smooth)}))}}Ne.add("rope",Xd);class Yd extends Sh{constructor(t,e,i){super(t,e,i),this.type="spacefill",this.parameters=Object.assign({sphereDetail:!0,disableImpostor:!0},this.parameters),this.init(i)}init(t){var e=t||{};e.useInteriorColor=st(e.useInteriorColor,!0),super.init(e)}createData(t){return{bufferList:[new Gc(t.getAtomData(this.getAtomParams()),this.getBufferParams({sphereDetail:this.sphereDetail,dullInterior:!0,disableImpostor:this.disableImpostor}))]}}updateData(t,e){var i=e.sview.getAtomData(this.getAtomParams(t)),r={};t&&!t.position||Object.assign(r,{position:i.position}),t&&!t.color||Object.assign(r,{color:i.color}),t&&!t.radius||Object.assign(r,{radius:i.radius}),e.bufferList[0].setAttributes(r)}}function Kd(t){return 3*(t.position.length/3-1)*2}Ne.add("spacefill",Yd);class Zd extends Go{constructor(t,e={}){super({position:new Float32Array(Kd(t)),color:new Float32Array(Kd(t))},e),this.isLine=!0,this.vertexShader="Line.vert",this.fragmentShader="Line.frag",this.setAttributes(t)}setAttributes(t){let e,i,r,s;const n=this.geometry.attributes;if(t.position&&(e=t.position,r=n.position.array,n.position.needsUpdate=!0),t.color&&(i=t.color,s=n.color.array,n.color.needsUpdate=!0),!e&&!i)return void Me.warn("TraceBuffer.prototype.setAttributes no data");let o,a;const c=this.size-1;for(let t=0;t{if(!(t.residueCount<4)){i.push(t);var r=new od(t,this.getSplineParams()),s=r.getSubdividedPosition(),n=r.getSubdividedColor(this.getColorParams());e.push(new Zd(Object.assign({},s,n),this.getBufferParams()))}}),t.getSelection()),{bufferList:e,polymerList:i}}updateData(t,e){t=t||{};var i=0,r=e.polymerList.length;for(i=0;i{t.boundingBox||t.computeBoundingBox(),this.boundingBox.union(t.boundingBox)}))}}const lu=Object.assign({aspectRatio:1.5,radialSegments:50,openEnded:!1,disableImpostor:!1},zo);class hu{constructor(t,e={}){this.group=new m,this.wireframeGroup=new m,this.pickingGroup=new m,this.visible=!0,this.parameters=nt(e,this.defaultParameters),this.splitPosition=new Float32Array(t.position1.length),this.cylinderRadius=new Float32Array(t.radius.length);const r=this.makeAttributes(t),s={radialSegments:this.parameters.radialSegments,openEnded:this.parameters.openEnded,disableImpostor:this.parameters.disableImpostor};this.cylinderBuffer=new td(r.cylinder,s),this.coneBuffer=new au(r.cone,s),this.geometry=new cu([this.cylinderBuffer.geometry,this.coneBuffer.geometry]),this.matrix=st(e.matrix,new i),this.picking=t.picking}get defaultParameters(){return lu}set matrix(t){Go.prototype.setMatrix.call(this,t)}get matrix(){return this.group.matrix.clone()}get pickable(){return!!this.picking}makeAttributes(t={}){const i=this.splitPosition,r=this.cylinderRadius,s=this.parameters.aspectRatio;let n,o;const a={},c={};if(t.radius){for(n=0,o=r.length;n(this._beforeParse(),this._parse(),this._afterParse(),this[this.__objName])))}_parse(){}_beforeParse(){}_afterParse(){De&&Me.log(this[this.__objName])}}class Nu extends Lu{constructor(t,e){var i=e||{};super(t,i),this.firstModelOnly=st(i.firstModelOnly,!1),this.asTrajectory=st(i.asTrajectory,!1),this.cAlphaOnly=st(i.cAlphaOnly,!1),this.structure=new Cc(this.name,this.path),this.structureBuilder=new za(this.structure)}get type(){return"structure"}get __objName(){return"structure"}}class zu{constructor(t,e,i="",r,s=[]){this.structure=t,this.index=e,this.description=i,this.entityType=function(t){switch(t=t.toLowerCase()){case"polymer":return 1;case"non-polymer":return 2;case"macrolide":return 3;case"water":return 4;default:return 0}}(r||""),this.chainIndexList=s,s.forEach((function(i){t.chainStore.entityIndex[i]=e}))}get type(){return function(t){switch(t){case 1:return"polymer";case 2:return"non-polymer";case 3:return"macrolide";case 4:return"water";default:return}}(this.entityType)}getEntityType(){return this.entityType}isPolymer(){return 1===this.entityType}isNonPolymer(){return 2===this.entityType}isMacrolide(){return 3===this.entityType}isWater(){return 4===this.entityType}eachChain(t){const e=this.structure.getChainProxy();this.chainIndexList.forEach((function(i){e.index=i,t(e)}))}}const Vu={a:1,b:1,c:1,alpha:90,beta:90,gamma:90,spacegroup:"P 1"};class Gu{constructor(t=Vu){this.cartToFrac=new i,this.fracToCart=new i,this.a=t.a,this.b=t.b,this.c=t.c,this.alpha=t.alpha,this.beta=t.beta,this.gamma=t.gamma,this.spacegroup=t.spacegroup;const e=kt(this.alpha),r=kt(this.beta),s=kt(this.gamma),n=Math.cos(e),o=Math.cos(r),a=Math.cos(s),c=Math.sin(r),l=Math.sin(s);if(this.volume=this.a*this.b*this.c*Math.sqrt(1-n*n-o*o-a*a+2*n*o*a),void 0===t.cartToFrac){const t=this.a*this.b*l/this.volume,e=(o*a-n)/(c*l);this.fracToCart.set(this.a,0,0,0,this.b*a,this.b*l,0,0,this.c*o,-this.c*c*e,1/t,0,0,0,0,1).transpose(),this.cartToFrac.getInverse(this.fracToCart)}else this.cartToFrac.copy(t.cartToFrac),this.fracToCart.getInverse(this.cartToFrac)}getPosition(t){const i=new Float32Array(24);if(t.unitcell){const r=t.unitcell,s=t.center.clone().applyMatrix4(r.cartToFrac).floor(),n=new e;let o=0;const a=function(t,e,a){n.set(t,e,a).add(s).applyMatrix4(r.fracToCart).toArray(i,o),o+=3};a(0,0,0),a(1,0,0),a(0,1,0),a(0,0,1),a(1,1,0),a(1,0,1),a(0,1,1),a(1,1,1)}return i}getCenter(t){return function(t,i=new e){const r=t.length;for(let e=0;e0)continue;let e,i,r,s,a,g=0;if(n){if(s=S.split(Wu),g=10===s.length?1:0,D=s[2],p&&"CA"!==D)continue;e=parseFloat(s[6-g]),i=parseFloat(s[7-g]),r=parseFloat(s[8-g])}else{if(D=S.substr(12,4).trim(),p&&"CA"!==D)continue;e=parseFloat(S.substr(30,8)),i=parseFloat(S.substr(38,8)),r=parseFloat(S.substr(46,8))}if(m){const t=3*b;if(y[t+0]=e,y[t+1]=i,y[t+2]=r,b+=1,x)continue}n?(P=parseInt(s[1]),a="",$="H"===S[0],I=g?"":s[4],k=parseInt(s[5-g]),B="",M=s[3],R="",T=1):(P=parseInt(S.substr(6,5),h),l&&99999===P&&(h=16),$="H"===S[0],I=S[21].trim(),k=parseInt(S.substr(22,4),d),l&&9999===k&&(d=16),B=S[26].trim(),M=S.substr(17,4).trim()||"MOL",O=parseFloat(S.substr(60,6)),R=S[16].trim(),T=parseFloat(S.substr(54,6)),t||(o?(a=S.substr(76,3).trim(),a in pn&&(a=pn[a])):(a=S.substr(76,2).trim(),I||(I=S.substr(72,4).trim())),E=parseInt((S.substr(79,1)+S.substr(78,1)).trim()))),dt.growIfFull(),dt.atomTypeId[pt]=ht.add(D,a),dt.x[pt]=e,dt.y[pt]=i,dt.z[pt]=r,dt.serial[pt]=P,dt.altloc[pt]=R.charCodeAt(0),dt.occupancy[pt]=isNaN(T)?0:T,n?(dt.partialCharge[pt]=parseFloat(s[9-g]),dt.radius[pt]=parseFloat(s[10-g])):(dt.bfactor[pt]=isNaN(O)?0:O,o&&(dt.partialCharge[pt]=parseFloat(S.substr(70,6))),isFinite(E)&&(dt.formalCharge||dt.addField("formalCharge",1,"int8"),dt.formalCharge[pt]=E));const v=qu(k,I,B);!$||K[v]||ju.includes(M)?tt||et===I||(Q+=1,J=Q.toString()):et===I&&rt===M&&(cn.includes(M)||it===k&&st===B)||(Q+=1,J=Q.toString(),it=k,rt=M,st=B),c.addAtom(ft,I,J,M,k,$,void 0,B),U[P]=pt,pt+=1,tt=!1,et=I}else if("CONECT"===C){const t=U[parseInt(S.substr(6,5))],e=[11,16,21,26],i={};if(void 0===t)continue;for(let r=0;r<4;++r){let s=parseInt(S.substr(e[r],5));if(!Number.isNaN(s)&&(s=U[s],void 0!==s))if(t0)continue;const s=e[l].replace(Zu,"");if(k&&"CA"!==s)continue;const T=parseFloat(e[x]),$=parseFloat(e[v]),O=parseFloat(e[w]);if(I){const e=3*r;if(t[e+0]=T,t[e+1]=$,t[e+2]=O,r+=1,X>0)continue}const R=e[h],E=parseInt(e[-1!==a?a:c]);let F=e[b];F="?"===F?"":F;const L=e[o],N=e[d],z="H"===e[p][0],V=e[g],Y=parseFloat(e[A]),K=parseFloat(e[_]);let Z=e[m];if(Z="."===Z?"":Z,H.growIfFull(),H.atomTypeId[q]=j.add(s,V),H.x[q]=T,H.y[q]=$,H.z[q]=O,H.serial[q]=parseInt(e[f]),H.bfactor[q]=isNaN(Y)?0:Y,H.occupancy[q]=isNaN(K)?0:K,H.altloc[q]=Z.charCodeAt(0),C.addAtom(X,L,N,R,E,z,void 0,F),De){const t=B[N];void 0!==t&&t!==L&&De&&Me.warn(t,L)}B[N]=L;const Q=e[u];D[Q]||(D[Q]=new Set),D[Q].add(S.chainStore.count-1),q+=1}else{const t=n.match(Ku),e=t.length;N===L.length&&(N=0);for(let i=0;ic*c)return o.growIfFull(),o.atomTypeId[f]=o.atomTypeId[t],o.x[f]=u.x,o.y[f]=u.y,o.z[f]=u.z,o.occupancy[f]=o.occupancy[t],o.serial[f]=f,o.altloc[f]="A".charCodeAt(0),s.addAtom(0,"","","HET",1,!0),void(f+=1)}}}))}}(T,S,C),C.finalize(),S.finalizeAtoms(),Wa(S),S.finalizeBonds();else{var Y=function(t,e,i){var r,s,n,o,a=[],c=[],l=t.struct_conf;if(null==l?void 0:l.pdbx_PDB_helix_class)for(em(l,"id"),r=0,s=l.beg_auth_seq_id.length;r0){o=o.split("(");var l=c(o[0]),h=c(o[1]);Object.keys(l).forEach((function(t){Object.keys(h).forEach((function(e){var r=new i;r.multiplyMatrices(l[t],h[e]),s[t+"x"+e]=r}))}))}else s=c(o);var d=[];for(var u in s)d.push(s[u]);var m=t;/^(0|[1-9][0-9]*)$/.test(m)&&(m="BU"+m);for(var p=a.asym_id_list[e].split(","),f=0,g=p.length;fA){var _=w;w=A,A=_;var S=p;p=x,x=S}if(0!==w&&0!==A)for(var C=0;Cb)continue}d=I.substr(5,5).trim(),u=parseInt(I.substr(0,5)),m=parseInt(I.substr(15,5)),v.growIfFull(),v.atomTypeId[w]=x.add(h),v.x[w]=T,v.y[w]=B,v.z[w]=D,v.serial[w]=m,r.addAtom(A,"","",d,u,!1,"l"),w+=1}}}(0,i.length,i)})),r.finalize(),i.finalizeAtoms(),Ha(i),Wa(i),i.finalizeBonds(),Ga(i),De&&Me.timeEnd("GroParser._parse "+this.name)}});var om=["mmtfVersion","mmtfProducer","unitCell","spaceGroup","structureId","title","depositionDate","releaseDate","experimentalMethods","resolution","rFree","rWork","bioAssemblyList","ncsOperatorList","entityList","groupList","numBonds","numAtoms","numGroups","numChains","numModels","groupsPerChain","chainsPerModel"].concat(["xCoordList","yCoordList","zCoordList","groupIdList","groupTypeList","chainIdList","bFactorList","atomIdList","altLocList","occupancyList","secStructList","insCodeList","sequenceIndexList","chainNameList","bondAtomList","bondOrderList"]);function am(t,e,i){return e?new t(e.buffer,e.byteOffset,e.byteLength/(i||1)):void 0}function cm(t){return am(DataView,t)}function lm(t){return am(Int8Array,t)}function hm(t){return am(Int32Array,t,4)}function dm(t,e){var i=t.length/2;e||(e=new Int16Array(i));for(var r=0,s=0;rn&&++a;e=new Int32Array(a)}for(i=0,r=0;is){for(var n=[],o=0;o0&&(o.biomolDict[t]=e)}const O=a.unitCell;O&&Array.isArray(O)&&O[0]?o.unitcell=new Gu({a:O[0],b:O[1],c:O[2],alpha:O[3],beta:O[4],gamma:O[5],spacegroup:a.spaceGroup}):o.unitcell=void 0,Ka(o,!0),Ya(o,!0),o.finalizeAtoms(),o.finalizeBonds(),Za(o),De&&Me.timeEnd("MmtfParser._parse "+this.name)}});const _m=/\s+/,Sm={1:1,2:2,3:3,am:1,ar:1,du:1,un:1,nc:0};ze.add("mol2",class extends Nu{get type(){return"mol2"}_parse(){De&&Me.time("Mol2Parser._parse "+this.name);const t=this.structure,e=this.structureBuilder,i=this.firstModelOnly,r=this.asTrajectory,s=t.frames;let n,o,a=!1;const c=t.atomMap,l=t.atomStore;l.resize(Math.round(this.streamer.data.length/60)),l.addField("partialCharge",1,"float32");let h=0,d=0,u=0,m=-1,p=0,f=0;const g=t.getAtomProxy(),y=t.getAtomProxy();this.streamer.eachChunkOfLines((function(b){!function(b,x,v){for(let w=b;wMOLECULE"===b?(f=1,d=0,++m):"@ATOM"===b?(f=2,u=l.count,r&&(o=0,n=new Float32Array(3*p),s.push(n),m>0&&(a=!0))):f="@BOND"===b?3:0;else if(1===f){if(0===d)t.title=b,t.id=b;else if(1===d){const t=b.split(_m);p=parseInt(t[0])}++d}else if(2===f){const t=b.split(_m);if(i&&m>0)continue;const s=parseFloat(t[2]),d=parseFloat(t[3]),u=parseFloat(t[4]);if(r){const t=3*o;if(n[t+0]=s,n[t+1]=d,n[t+2]=u,o+=1,a)continue}const p=t[0],f=t[1],g=t[5].split(".")[0],y=t[6]?parseInt(t[6]):1,x=t[7]?t[7]:"",v=t[8]?parseFloat(t[8]):0;l.growIfFull(),l.atomTypeId[h]=c.add(f,g),l.x[h]=s,l.y[h]=d,l.z[h]=u,l.serial[h]=p,l.partialCharge[h]=v,e.addAtom(m,"","",x,y,!0),h+=1}else if(3===f){if(i&&m>0)continue;if(r&&m>0)continue;const e=b.split(_m);g.index=parseInt(e[1])-1+u,y.index=parseInt(e[2])-1+u;const s=Sm[e[3]];t.bondStore.addBond(g,y,s)}}}(0,b.length,b)})),e.finalize(),t.finalizeAtoms(),Ha(t),Ya(t,!0),Ka(t,!0),t.finalizeBonds(),ec(t),Ga(t),De&&Me.timeEnd("Mol2Parser._parse "+this.name)}});ze.add("pdbqt",class extends Xu{get type(){return"pdbqt"}});ze.add("pqr",class extends Xu{get type(){return"pqr"}});const Cm=/> +<(.+)>/;class Pm extends Nu{get type(){return"sdf"}_parse(){De&&Me.time("SdfParser._parse "+this.name);const t=this.structure,e=this.structureBuilder,i=this.firstModelOnly,r=this.asTrajectory,s=this.streamer.peekLines(2);t.id=s[0].trim(),t.title=s[1].trim();const n=t.frames;let o,a,c=!1;const l=t.atomMap,h=t.atomStore;h.resize(Math.round(this.streamer.data.length/50)),h.addField("formalCharge",1,"int8");const d=t.getAtomProxy(),u=t.getAtomProxy();let m=0,p=0,f=0,g=0;const y=[];let b,x,v,w,A,_,S,C,P,I,k,M,T,B,D=!1,$={};t.extraData.sdf=y;let O=!1,R=!1,E=!1,F=[],L=[];const N=new Map;this.streamer.eachChunkOfLines((function(s){!function(s,z,V){for(let G=s;G-1,O?N.clear():(x=parseInt(s.substr(0,3)),v=parseInt(s.substr(3,3)),w=4,A=w+x,_=A,S=_+v,r&&(a=0,o=new Float32Array(3*x),n.push(o),f>0&&(c=!0)));else if(O&&"COUNTS"===F[0])x=parseInt(F[1]),r&&(a=0,o=new Float32Array(3*x),n.push(o),f>0&&(c=!0));else if(O&&2==F.length)"ATOM"===F[1]?"BEGIN"===F[0]?R=!0:"END"===F[0]&&(R=!1):"BOND"===F[1]&&("BEGIN"===F[0]?E=!0:"END"===F[0]&&(E=!1));else if(R||!O&&p>=w&&p0)continue;let t=0;if(O){if(C=parseFloat(F[2]),P=parseFloat(F[3]),I=parseFloat(F[4]),M=F[1],T=parseInt(F[0]),N.set(T,m),k=M+T,F.length>6){let e=F.slice(6).find((t=>0===t.indexOf("CHG=")));e&&(t=parseInt(e.substring(4)))}}else C=parseFloat(s.substr(0,10)),P=parseFloat(s.substr(10,10)),I=parseFloat(s.substr(20,10)),M=s.substr(31,3).trim(),k=M+(m-g+1);if(r){const t=3*a;if(o[t+0]=C,o[t+1]=P,o[t+2]=I,a+=1,c)continue}h.growIfFull(),h.atomTypeId[m]=l.add(k,M),h.x[m]=C,h.y[m]=P,h.z[m]=I,h.serial[m]=O?T:m,h.formalCharge[m]=t,e.addAtom(f,"","","HET",1,!0),m+=1}else if(E||!O&&p>=_&&p0)continue;if(r&&f>0)continue;O?(d.index=N.get(parseInt(F[2])),u.index=N.get(parseInt(F[3])),B=parseInt(F[1])):(d.index=parseInt(s.substr(0,3))-1+g,u.index=parseInt(s.substr(3,3))-1+g,B=parseInt(s.substr(6,3))),t.bondStore.addBond(d,u,B)}else if("M CHG"===s.substr(0,6)){const t=parseInt(s.substr(6,3));for(let e=0,i=10;e"===s.charAt(0)&&(b=s.match(Cm))?(D=b[1],$[D]=[]):!1!==D&&s&&$[D].push(s);++p}}}(0,s.length,s)})),e.finalize(),t.finalizeAtoms(),t.finalizeBonds(),ec(t),De&&Me.timeEnd("SdfParser._parse "+this.name)}_postProcess(){ec(this.structure)}}ze.add("sdf",Pm),ze.add("sd",Pm),ze.add("mol",Pm);function Im(t,e,i){return parseInt(t.substr(e,i).trim())}class km extends Nu{get type(){return"prmtop"}_parse(){De&&Me.time("PrmtopParser._parse "+this.name);const t=this.structure,e=this.structureBuilder,i=t.atomMap,r=t.atomStore;r.addField("partialCharge",1,"float32"),r.addField("radius",1,"float32");const s=[],n={},o=["NATOM","NTYPES","NBONH","MBONA","NTHETH","MTHETA","NPHIH","MPHIA","NHPARM","NPARM","NNB","NRES","NBONA","NTHETA","NPHIA","NUMBND","NUMANG","NPTRA","NATYP","NPHB","IFPERT","NBPER","NGPER","NDPER","MBPER","MGPER","MDPER","IFBOX","NMXRS","IFCAP","NUMEXTRA","NCOPY"];let a,c,l,h,d;o.forEach((t=>{n[t]=0}));let u,m,p,f,g,y=new Uint8Array(0);this.streamer.eachChunkOfLines((function(t){!function(t,e,i){for(let b=t;b0)return void Me.error("dcd format with fixed atoms unsupported, aborting");const p=n.NATOM,f=4*p;for(let i=0,a=n.NSET;i=1&&(i.timeOffset=(n.ISTART-1)*i.deltaTime),De&&Me.timeEnd("DcdParser._parse "+this.name)}});const Fm={BYTE:1,CHAR:2,SHORT:3,INT:4,FLOAT:5,DOUBLE:6};function Lm(t){switch(Number(t)){case Fm.BYTE:return"byte";case Fm.CHAR:return"char";case Fm.SHORT:return"short";case Fm.INT:return"int";case Fm.FLOAT:return"float";case Fm.DOUBLE:return"double";default:return"undefined"}}function Nm(t){switch(Number(t)){case Fm.BYTE:case Fm.CHAR:return 1;case Fm.SHORT:return 2;case Fm.INT:case Fm.FLOAT:return 4;case Fm.DOUBLE:return 8;default:return-1}}function zm(t){switch(String(t)){case"byte":return Fm.BYTE;case"char":return Fm.CHAR;case"short":return Fm.SHORT;case"int":return Fm.INT;case"float":return Fm.FLOAT;case"double":return Fm.DOUBLE;default:return-1}}function Vm(t,e){if(1!==t){const i=new Array(t);for(let r=0;r6,"non valid type "+h);const d=t.readUint32();let u=t.readUint32();2===i&&(Om(u>0,"offsets larger than 4GB not supported"),u=t.readUint32()),c[0]===e&&(n+=d),s[r]={name:o,dimensions:c,attributes:l,type:Lm(h),size:d,offset:u,record:c[0]===e}}}return{variables:s,recordStep:n}}(t,r.recordId,e);return i.variables=s.variables,i.recordDimension.recordStep=s.recordStep,i}function Xm(t){let e;const i=t.readUint32();if(i===Um)return Om(t.readUint32()!==Um,"wrong empty tag for list of attributes"),[];{Om(i!==Wm,"wrong tag for list of attributes");const r=t.readUint32();e=new Array(r);for(let i=0;i6,"non valid type "+s);const n=t.readUint32(),o=Gm(t,s,n);Rm(t),e[i]={name:r,type:Lm(s),value:o}}}return e}class Ym{constructor(t){const e=new hi(t);e.setBigEndian(),Om("CDF"!==e.readChars(3),"should start with CDF");const i=e.readByte();Om(i>2,"unknown version"),this.header=qm(e,i),this.buffer=e}get version(){return 1===this.header.version?"classic format":"64-bit offset format"}get recordDimension(){return this.header.recordDimension}get dimensions(){return this.header.dimensions}get globalAttributes(){return this.header.globalAttributes}get variables(){return this.header.variables}hasDataVariable(t){return-1!==this.header.variables.findIndex((function(e){return e.name===t}))}getDataVariable(t){let e;return e="string"==typeof t?this.header.variables.find((function(e){return e.name===t})):t,Om(void 0===e,"variable not found"),this.buffer.seek(e.offset),e.record?function(t,e,i){const r=zm(e.type),s=e.size?e.size/Nm(r):1,n=i.length,o=new Array(n),a=i.recordStep;for(let e=0;e=1&&(e.timeOffset=s[0]),s.length>=2&&(e.deltaTime=s[1]-s[0]),De&&Me.timeEnd("NctrajParser._parse "+this.name)}}ze.add("nctraj",Km),ze.add("ncdf",Km),ze.add("nc",Km);ze.add("trr",class extends $m{get type(){return"trr"}get isBinary(){return!0}_parse(){De&&Me.time("TrrParser._parse "+this.name);const t=vt(this.streamer.data),e=new DataView(t),i=this.frames,r=i.coordinates,s=i.boxes,n=i.times;let o=0;for(;;){o+=8;const i=e.getInt32(o);o+=4,o+=i;const a=e.getInt32(o+8),c=e.getInt32(o+12),l=e.getInt32(o+16),h=e.getInt32(o+28),d=e.getInt32(o+32),u=e.getInt32(o+36),m=e.getInt32(o+40);o+=52;const p=a/9,f=3*m;if(8===p?n.push(e.getFloat64(o)):n.push(e.getFloat32(o)),o+=2*p,a){const t=new Float32Array(9);if(8===p)for(let i=0;i<9;++i)t[i]=10*e.getFloat64(o),o+=8;else for(let i=0;i<9;++i)t[i]=10*e.getFloat32(o),o+=4;s.push(t)}if(o+=c,o+=l,h){let i;if(8===p){i=new Float32Array(f);for(let t=0;t>8&65280|i>>24&255}i=new Float32Array(t,o,f);for(let t=0;t=t.byteLength)break}n.length>=1&&(i.timeOffset=n[0]),n.length>=2&&(i.deltaTime=n[1]-n[0]),De&&Me.timeEnd("TrrParser._parse "+this.name)}});const Zm=new Uint32Array([0,0,0,0,0,0,0,0,0,8,10,12,16,20,25,32,40,50,64,80,101,128,161,203,256,322,406,512,645,812,1024,1290,1625,2048,2580,3250,4096,5060,6501,8192,10321,13003,16384,20642,26007,32768,41285,52015,65536,82570,104031,131072,165140,208063,262144,330280,416127,524287,660561,832255,1048576,1321122,1664510,2097152,2642245,3329021,4194304,5284491,6658042,8388607,10568983,13316085,16777216]);function Qm(t){let e=1,i=0;for(;t>=e&&i<32;)i++,e<<=1;return i}const Jm=new Uint8Array(32);function tp(t,e){let i=1,r=0;Jm[0]=1;for(let r=0;r>=8;for(;0!==s;)Jm[t++]=255&s,s>>=8;i=t}let s=1;for(i--;Jm[i]>=s;)r++,s*=2;return r+8*i}function ep(t,e,i,r){const s=(1<=8;)o=o<<8|e[a++],c|=o>>n<0&&(n>n&(1<8;)ip[a++]=ep(t,e,8,o),r-=8;r>0&&(ip[a++]=ep(t,e,r,o));for(let t=i-1;t>0;t--){let e=0;for(let i=a-1;i>=0;i--){e=e<<8|ip[i];const r=e/s[t]|0;ip[i]=r,e-=r*s[t]}n[t]=e}n[0]=ip[0]|ip[1]<<8|ip[2]<<16|ip[3]<<24}ze.add("xtc",class extends $m{get type(){return"xtc"}get isBinary(){return!0}_parse(){De&&Me.time("XtcParser._parse "+this.name);const t=vt(this.streamer.data),e=new DataView(t),i=this.frames,r=i.coordinates,s=i.boxes,n=i.times,o=new Int32Array(6),a=new Int32Array(3),c=new Int32Array(3),l=new Uint32Array(3),h=new Float32Array(3),d=new Float32Array(3);let u=0;const m=new Int32Array(3),p=new Uint32Array(m.buffer);for(;;){let i;const f=e.getInt32(u+4);u+=12;const g=3*f;n.push(e.getFloat32(u)),u+=4;const y=new Float32Array(9);for(let t=0;t<9;++t)y[t]=10*e.getFloat32(u),u+=4;if(s.push(y),f<=9){i=new Float32Array(f);for(let t=0;t16777215?(c[0]=Qm(a[0]),c[1]=Qm(a[1]),c[2]=Qm(a[2]),f=0):f=tp(3,a);let y=e.getInt32(u);u+=4;let b=y-1;b=9>b?9:b;let x=Zm[b]/2|0,v=Zm[y]/2|0;l[0]=l[1]=l[2]=Zm[y];let w=4*Math.ceil(e.getInt32(u)/4);u+=4;const A=1/n;let _=0,S=0;const C=new Uint8Array(t,u);for(h[0]=h[1]=h[2]=0;S0){h[0]=h[1]=h[2]=0;for(let t=0;t<_;t+=3){if(rp(m,C,3,y,l,h,p),S++,h[0]+=d[0]-v,h[1]+=d[1]-v,h[2]+=d[2]-v,0===t){let t=h[0];h[0]=d[0],d[0]=t,t=h[1],h[1]=d[1],d[1]=t,t=h[2],h[2]=d[2],d[2]=t,i[r++]=d[0]*A,i[r++]=d[1]*A,i[r++]=d[2]*A}else d[0]=h[0],d[1]=h[1],d[2]=h[2];i[r++]=h[0]*A,i[r++]=h[1]*A,i[r++]=h[2]*A}}else i[r++]=h[0]*A,i[r++]=h[1]*A,i[r++]=h[2]*A;if(y+=t,t<0?(v=x,x=y>9?Zm[y-1]/2|0:0):t>0&&(x=v,v=Zm[y]/2|0),l[0]=l[1]=l[2]=Zm[y],0===l[0]||0===l[1]||0===l[2])return void console.error("(xdrfile error) Undefined error.")}u+=w}for(let t=0;t=t.byteLength)break}n.length>=1&&(i.timeOffset=n[0]),n.length>=2&&(i.deltaTime=n[1]-n[0]),De&&Me.timeEnd("XtcParser._parse "+this.name)}});class sp extends Lu{constructor(t,e){const i=e||{};super(t,i),this.volume=new Eo(this.name,this.path),this.voxelSize=st(i.voxelSize,1)}get type(){return"volume"}get __objName(){return"volume"}_afterParse(){this.volume.setMatrix(this.getMatrix()),super._afterParse()}getMatrix(){return new i}}const np=/\s+/,op=/-?\d+(?:\.\d*)?(?:[eE][+-]?\d+)?/g,ap=.529177210859;class cp extends sp{get type(){return"cube"}_parse(){De&&Me.time("CubeParser._parse "+this.name);const t=this.volume,i=this.streamer.peekLines(6),r={},s=ap*this.voxelSize;function n(t,e){var r=i[t].trim().split(np)[e];return parseFloat(r)}r.atomCount=Math.abs(n(2,0)),r.originX=n(2,1)*ap,r.originY=n(2,2)*ap,r.originZ=n(2,3)*ap,r.NVX=n(3,0),r.NVY=n(4,0),r.NVZ=n(5,0),r.basisX=new e(n(3,1),n(3,2),n(3,3)).multiplyScalar(s),r.basisY=new e(n(4,1),n(4,2),n(4,3)).multiplyScalar(s),r.basisZ=new e(n(5,1),n(5,2),n(5,3)).multiplyScalar(s);const o=new Float32Array(r.NVX*r.NVY*r.NVZ);let a=0,c=0;const l=n(2,0)>0?0:1;this.streamer.eachChunkOfLines((function(t){!function(t,e,i){for(let s=t;s=r.atomCount+6+l){const e=t.match(op);for(let t=0,i=e.length;t>8&255}e.xStart=n[0],e.yStart=n[1],e.zStart=n[2],e.xExtent=n[3],e.yExtent=n[4],e.zExtent=n[5],e.xRate=n[6],e.yRate=n[7],e.zRate=n[8];const t=1/n[17],s=t*this.voxelSize;e.xlen=n[9]*s,e.ylen=n[10]*s,e.zlen=n[11]*s,e.alpha=n[12]*t,e.beta=n[13]*t,e.gamma=n[14]*t,i=n[15]/100,r=n[16],e.gamma=n[14]*t}t.header=e,De&&Me.log(e,i,r);const c=new Float32Array(e.xExtent*e.yExtent*e.zExtent);let l=512;const h=Math.ceil(e.xExtent/8),d=Math.ceil(e.yExtent/8),u=Math.ceil(e.zExtent/8);for(var m=0;ms){const t=i[r].trim();if(""!==t){const e=t.split(hp);for(let t=0,i=e.length;t=s&&(p-s)%u!=0&&m=0?i-1:i+e/3)},parseNormalIndex:function(t,e){var i=parseInt(t,10);return 3*(i>=0?i-1:i+e/3)},addVertex:function(t,e,i){var r=this.vertices,s=this.object.geometry.vertices;s.push(r[t+0]),s.push(r[t+1]),s.push(r[t+2]),s.push(r[e+0]),s.push(r[e+1]),s.push(r[e+2]),s.push(r[i+0]),s.push(r[i+1]),s.push(r[i+2])},addVertexLine:function(t){var e=this.vertices,i=this.object.geometry.vertices;i.push(e[t+0]),i.push(e[t+1]),i.push(e[t+2])},addNormal:function(t,e,i){var r=this.normals,s=this.object.geometry.normals;s.push(r[t+0]),s.push(r[t+1]),s.push(r[t+2]),s.push(r[e+0]),s.push(r[e+1]),s.push(r[e+2]),s.push(r[i+0]),s.push(r[i+1]),s.push(r[i+2])},addFace:function(t,e,i,r,s,n,o,a){var c,l=this.vertices.length,h=this.parseVertexIndex(t,l),d=this.parseVertexIndex(e,l),u=this.parseVertexIndex(i,l);if(void 0===r?this.addVertex(h,d,u):(c=this.parseVertexIndex(r,l),this.addVertex(h,d,c),this.addVertex(d,u,c)),void 0!==s){var m=this.normals.length;h=this.parseNormalIndex(s,m),d=s===n?h:this.parseNormalIndex(n,m),u=s===o?h:this.parseNormalIndex(o,m),void 0===r?this.addNormal(h,d,u):(c=this.parseNormalIndex(a,m),this.addNormal(h,d,c),this.addNormal(d,u,c))}},addLineGeometry:function(t){this.object.geometry.type="Line";for(var e=this.vertices.length,i=0,r=t.length;i0?x.setAttribute("normal",new M(new Float32Array(b.normals),3)):x.computeVertexNormals(),y.push(x)}}return y}};ze.add("obj",class extends kp{get type(){return"obj"}getLoader(){return new Mp}});const Tp=function(){this.propertyNameMapping={}};Tp.prototype={constructor:Tp,setPropertyNameMapping:function(t){this.propertyNameMapping=t},bin2str:function(t){for(var e=new Uint8Array(t),i="",r=0;r=r.elements[o].count&&(o++,a=0);var h=this.parseASCIIElement(r.elements[o].properties,l);this.handleElement(i,r.elements[o].name,h),a++}}return this.postProcess(i)},postProcess:function(t){if(t.useColor){for(var e=0;e{const s=r.length;for(let n=0;n/g,""),{declaration:e(),root:i()};function e(){if(!s(/^<\?xml\s*/))return;const t={attributes:{}};for(;!n()&&!o("?>");){const e=r();if(!e)return t;t.attributes[e.name]=e.value}return s(/\?>\s*/),t}function i(){const t=s($p);if(!t)return;const e={name:t[1],attributes:{},children:[]};for(;!(n()||o(">")||o("?>")||o("/>"));){const t=r();if(!t)return e;e.attributes[t.name]=t.value}if(s(/^\s*\/>\s*/))return e;let a;for(s(/\??>\s*/),e.content=function(){const t=s(Op);return t?t[1]:""}();a=i();)e.children.push(a);return s(/^<\/[\w-:.]+>\s*/),e}function r(){const t=s(Rp);var e;if(t)return{name:t[1],value:(e=t[2],e.replace(Dp,""))}}function s(e){const i=t.match(e);if(i)return t=t.slice(i[0].length),i}function n(){return 0===t.length}function o(e){return 0===t.indexOf(e)}}class Fp extends Lu{constructor(t,e){const i=e||{};super(t,i),this.useDomParser=st(i.useDomParser,!1),this.xml={name:this.name,path:this.path,data:{}}}get type(){return"xml"}get __objName(){return"xml"}get isXml(){return!0}__xmlParser(t){return Ep(t)}__domParser(t){return(new window.DOMParser).parseFromString(t,"text/xml")}_parse(){De&&Me.time("XmlParser._parse "+this.name),this.useDomParser?this.streamer.data instanceof Document?this.xml.data=this.streamer.data:this.xml.data=this.__domParser(this.streamer.asText()):this.xml.data=this.__xmlParser(this.streamer.asText()),De&&Me.timeEnd("XmlParser._parse "+this.name)}}function Lp(t,e){const i=t.getNamedItem(e);return null!==i?i.value:""}function Np(t,e,i=!1){const r=Lp(t,"icode").trim(),s=Lp(t,"chain").trim(),n=Lp(t,"altcode");let o=Lp(t,"resnum");return r&&(o+="^"+r),s&&(o+=":"+s),e&&(o+="."+e),i&&n.trim()&&(o+="%"+n),o+="/"+(parseInt(Lp(t,"model"))-1),o}function zp(t){const e=Lp(t,"chain").trim();let i=`[${Lp(t,"rescode")}]${Lp(t,"resnum")}`;return e&&(i+=`:${e}`),i}function Vp(t,e,i){void 0===t[e]?t[e]=i:t[e]|=i}function Gp(t,e){return null!==t&&t.value===e}function Up(t,e,i){let r=0;const s=e.getElementsByTagName("clash");for(let e=0,i=s.length;e0&&(r+=1);e.getElementsByTagName("bond-outlier").length>0&&(r+=1);return e.getElementsByTagName("plane-outlier").length>0&&(r+=1),Gp(i.getNamedItem("rota"),"OUTLIER")&&(r+=1),Gp(i.getNamedItem("rama"),"OUTLIER")&&(r+=1),Gp(i.getNamedItem("RNApucker"),"outlier")&&(r+=1),r}ze.add("xml",Fp);class jp{constructor(t,e){this.name=t,this.path=e,this.rsrzDict={},this.rsccDict={},this.rciDict={},this.clashDict={},this.clashArray=[],this.geoDict={},this.geoAtomDict={},this.atomDict={},this.clashSele="NONE"}get type(){return"validation"}fromXml(t){De&&Me.time("Validation.fromXml");const e=this.rsrzDict,i=this.rsccDict,r=this.rciDict,s=this.clashDict,n=this.clashArray,o=this.geoDict,a=this.geoAtomDict,c=this.atomDict,l=t.getElementsByTagName("Entry");if(1===l.length){const t=l[0].getElementsByTagName("chemical_shift_list");if(1===t.length){const e=t[0].getElementsByTagName("random_coil_index");for(let t=0,i=e.length;t0&&(o[r]=t)}else{const t=e.getElementsByTagName("clash"),i=e.getElementsByTagName("mog-bond-outlier"),n=e.getElementsByTagName("mog-angle-outlier");if(i.length>0||n.length>0||t.length>0){const e={};a[r]=e;for(let i=0,r=t.length;i>>16&65535|0,o=0;0!==i;){i-=o=i>2e3?2e3:i;do{n=n+(s=s+e[r++]|0)|0}while(--o);s%=65521,n%=65521}return s|n<<16|0}ze.add("validation",class extends Fp{constructor(t,e){super(t,e||{}),this.useDomParser=!0,this.validation=new jp(this.name,this.path)}get __objName(){return"validation"}get isXml(){return!0}_parse(){super._parse(),De&&Me.time("ValidationParser._parse "+this.name),this.validation.fromXml(this.xml.data),De&&Me.timeEnd("ValidationParser._parse "+this.name)}});var Xp=function(){for(var t,e=[],i=0;i<256;i++){t=i;for(var r=0;r<8;r++)t=1&t?3988292384^t>>>1:t>>>1;e[i]=t}return e}();function Yp(t,e,i,r){var s=Xp,n=r+i;t^=-1;for(var o=r;o>>8^s[255&(t^e[o])];return-1^t}var Kp=30,Zp=12;function Qp(t,e){var i,r,s,n,o,a,c,l,h,d,u,m,p,f,g,y,b,x,v,w,A,_,S,C,P;i=t.state,r=t.next_in,C=t.input,s=r+(t.avail_in-5),n=t.next_out,P=t.output,o=n-(e-t.avail_out),a=n+(t.avail_out-257),c=i.dmax,l=i.wsize,h=i.whave,d=i.wnext,u=i.window,m=i.hold,p=i.bits,f=i.lencode,g=i.distcode,y=(1<>>=v=x>>>24,p-=v,0===(v=x>>>16&255))P[n++]=65535&x;else{if(!(16&v)){if(0==(64&v)){x=f[(65535&x)+(m&(1<>>=v,p-=v),p<15&&(m+=C[r++]<>>=v=x>>>24,p-=v,!(16&(v=x>>>16&255))){if(0==(64&v)){x=g[(65535&x)+(m&(1<c){t.msg="invalid distance too far back",i.mode=Kp;break t}if(m>>>=v,p-=v,A>(v=n-o)){if((v=A-v)>h&&i.sane){t.msg="invalid distance too far back",i.mode=Kp;break t}if(_=0,S=u,0===d){if(_+=l-v,v2;)P[n++]=S[_++],P[n++]=S[_++],P[n++]=S[_++],w-=3;w&&(P[n++]=S[_++],w>1&&(P[n++]=S[_++]))}else{_=n-A;do{P[n++]=P[_++],P[n++]=P[_++],P[n++]=P[_++],w-=3}while(w>2);w&&(P[n++]=P[_++],w>1&&(P[n++]=P[_++]))}break}}break}}while(r>3,m&=(1<<(p-=w<<3))-1,t.next_in=r,t.next_out=n,t.avail_in=r=1&&0===T[w];w--);if(A>w&&(A=w),0===w)return s[n++]=20971520,s[n++]=20971520,a.bits=1,0;for(v=1;v0&&(t===rf||1!==w))return-1;for(B[1]=0,b=1;btf||t===nf&&P>ef)return 1;for(;;){p=b-S,o[x]m?(f=D[$+o[x]],g=k[M+o[x]]):(f=96,g=0),c=1<>S)+(l-=c)]=p<<24|f<<16|g|0}while(0!==l);for(c=1<>=1;if(0!==c?(I&=c-1,I+=c):I=0,x++,0==--T[b]){if(b===w)break;b=e[i+o[x]]}if(b>A&&(I&d)!==h){for(0===S&&(S=A),u+=v,C=1<<(_=b-S);_+Stf||t===nf&&P>ef)return 1;s[h=I&d]=A<<24|_<<16|u-n|0}}return 0!==I&&(s[u+I]=b-S<<24|64<<16|0),a.bits=A,0}var df=1,uf=2,mf=0,pf=-2,ff=1,gf=12,yf=30,bf=852,xf=592;function vf(t){return(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24)}function wf(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function Af(t){var e;return t&&t.state?((e=t.state).wsize=0,e.whave=0,e.wnext=0,function(t){var e;return t&&t.state?(e=t.state,t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=ff,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(bf),e.distcode=e.distdyn=new Int32Array(xf),e.sane=1,e.back=-1,mf):pf}(t)):pf}function _f(t,e){var i,r;return t?(r=new wf,t.state=r,r.window=null,i=function(t,e){var i,r;return t&&t.state?(r=t.state,e<0?(i=0,e=-e):(i=1+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?pf:(null!==r.window&&r.wbits!==e&&(r.window=null),r.wrap=i,r.wbits=e,Af(t))):pf}(t,e),i!==mf&&(t.state=null),i):pf}var Sf,Cf,Pf=!0;function If(t){if(Pf){var e;for(Sf=new Int32Array(512),Cf=new Int32Array(32),e=0;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(hf(df,t.lens,0,288,Sf,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;hf(uf,t.lens,0,32,Cf,0,t.work,{bits:5}),Pf=!1}t.lencode=Sf,t.lenbits=9,t.distcode=Cf,t.distbits=5}function kf(t,e,i,r){var s,n=t.state;return null===n.window&&(n.wsize=1<=n.wsize?(Wp(n.window,e,i-n.wsize,n.wsize,0),n.wnext=0,n.whave=n.wsize):((s=n.wsize-n.wnext)>r&&(s=r),Wp(n.window,e,i-r,s,n.wnext),(r-=s)?(Wp(n.window,e,i-r,r,0),n.wnext=r,n.whave=n.wsize):(n.wnext+=s,n.wnext===n.wsize&&(n.wnext=0),n.whave>>8&255,i.check=Yp(i.check,I,2,0),l=0,h=0,i.mode=2;break}if(i.flags=0,i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&l)<<8)+(l>>8))%31){t.msg="incorrect header check",i.mode=yf;break}if(8!=(15&l)){t.msg="unknown compression method",i.mode=yf;break}if(h-=4,A=8+(15&(l>>>=4)),0===i.wbits)i.wbits=A;else if(A>i.wbits){t.msg="invalid window size",i.mode=yf;break}i.dmax=1<>8&1),512&i.flags&&(I[0]=255&l,I[1]=l>>>8&255,i.check=Yp(i.check,I,2,0)),l=0,h=0,i.mode=3;case 3:for(;h<32;){if(0===a)break t;a--,l+=r[n++]<>>8&255,I[2]=l>>>16&255,I[3]=l>>>24&255,i.check=Yp(i.check,I,4,0)),l=0,h=0,i.mode=4;case 4:for(;h<16;){if(0===a)break t;a--,l+=r[n++]<>8),512&i.flags&&(I[0]=255&l,I[1]=l>>>8&255,i.check=Yp(i.check,I,2,0)),l=0,h=0,i.mode=5;case 5:if(1024&i.flags){for(;h<16;){if(0===a)break t;a--,l+=r[n++]<>>8&255,i.check=Yp(i.check,I,2,0)),l=0,h=0}else i.head&&(i.head.extra=null);i.mode=6;case 6:if(1024&i.flags&&((m=i.length)>a&&(m=a),m&&(i.head&&(A=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Array(i.head.extra_len)),Wp(i.head.extra,r,n,m,A)),512&i.flags&&(i.check=Yp(i.check,r,m,n)),a-=m,n+=m,i.length-=m),i.length))break t;i.length=0,i.mode=7;case 7:if(2048&i.flags){if(0===a)break t;m=0;do{A=r[n+m++],i.head&&A&&i.length<65536&&(i.head.name+=String.fromCharCode(A))}while(A&&m>9&1,i.head.done=!0),t.adler=i.check=0,i.mode=gf;break;case 10:for(;h<32;){if(0===a)break t;a--,l+=r[n++]<>>=7&h,h-=7&h,i.mode=27;break}for(;h<3;){if(0===a)break t;a--,l+=r[n++]<>>=1)){case 0:i.mode=14;break;case 1:if(If(i),i.mode=20,6===e){l>>>=2,h-=2;break t}break;case 2:i.mode=17;break;case 3:t.msg="invalid block type",i.mode=yf}l>>>=2,h-=2;break;case 14:for(l>>>=7&h,h-=7&h;h<32;){if(0===a)break t;a--,l+=r[n++]<>>16^65535)){t.msg="invalid stored block lengths",i.mode=yf;break}if(i.length=65535&l,l=0,h=0,i.mode=15,6===e)break t;case 15:i.mode=16;case 16:if(m=i.length){if(m>a&&(m=a),m>c&&(m=c),0===m)break t;Wp(s,r,n,m,o),a-=m,n+=m,c-=m,o+=m,i.length-=m;break}i.mode=gf;break;case 17:for(;h<14;){if(0===a)break t;a--,l+=r[n++]<>>=5,h-=5,i.ndist=1+(31&l),l>>>=5,h-=5,i.ncode=4+(15&l),l>>>=4,h-=4,i.nlen>286||i.ndist>30){t.msg="too many length or distance symbols",i.mode=yf;break}i.have=0,i.mode=18;case 18:for(;i.have>>=3,h-=3}for(;i.have<19;)i.lens[k[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,S={bits:i.lenbits},_=hf(0,i.lens,0,19,i.lencode,0,i.work,S),i.lenbits=S.bits,_){t.msg="invalid code lengths set",i.mode=yf;break}i.have=0,i.mode=19;case 19:for(;i.have>>16&255,b=65535&P,!((g=P>>>24)<=h);){if(0===a)break t;a--,l+=r[n++]<>>=g,h-=g,i.lens[i.have++]=b;else{if(16===b){for(C=g+2;h>>=g,h-=g,0===i.have){t.msg="invalid bit length repeat",i.mode=yf;break}A=i.lens[i.have-1],m=3+(3&l),l>>>=2,h-=2}else if(17===b){for(C=g+3;h>>=g)),l>>>=3,h-=3}else{for(C=g+7;h>>=g)),l>>>=7,h-=7}if(i.have+m>i.nlen+i.ndist){t.msg="invalid bit length repeat",i.mode=yf;break}for(;m--;)i.lens[i.have++]=A}}if(i.mode===yf)break;if(0===i.lens[256]){t.msg="invalid code -- missing end-of-block",i.mode=yf;break}if(i.lenbits=9,S={bits:i.lenbits},_=hf(df,i.lens,0,i.nlen,i.lencode,0,i.work,S),i.lenbits=S.bits,_){t.msg="invalid literal/lengths set",i.mode=yf;break}if(i.distbits=6,i.distcode=i.distdyn,S={bits:i.distbits},_=hf(uf,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,S),i.distbits=S.bits,_){t.msg="invalid distances set",i.mode=yf;break}if(i.mode=20,6===e)break t;case 20:i.mode=21;case 21:if(a>=6&&c>=258){t.next_out=o,t.avail_out=c,t.next_in=n,t.avail_in=a,i.hold=l,i.bits=h,Qp(t,u),o=t.next_out,s=t.output,c=t.avail_out,n=t.next_in,r=t.input,a=t.avail_in,l=i.hold,h=i.bits,i.mode===gf&&(i.back=-1);break}for(i.back=0;y=(P=i.lencode[l&(1<>>16&255,b=65535&P,!((g=P>>>24)<=h);){if(0===a)break t;a--,l+=r[n++]<>x)])>>>16&255,b=65535&P,!(x+(g=P>>>24)<=h);){if(0===a)break t;a--,l+=r[n++]<>>=x,h-=x,i.back+=x}if(l>>>=g,h-=g,i.back+=g,i.length=b,0===y){i.mode=26;break}if(32&y){i.back=-1,i.mode=gf;break}if(64&y){t.msg="invalid literal/length code",i.mode=yf;break}i.extra=15&y,i.mode=22;case 22:if(i.extra){for(C=i.extra;h>>=i.extra,h-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=23;case 23:for(;y=(P=i.distcode[l&(1<>>16&255,b=65535&P,!((g=P>>>24)<=h);){if(0===a)break t;a--,l+=r[n++]<>x)])>>>16&255,b=65535&P,!(x+(g=P>>>24)<=h);){if(0===a)break t;a--,l+=r[n++]<>>=x,h-=x,i.back+=x}if(l>>>=g,h-=g,i.back+=g,64&y){t.msg="invalid distance code",i.mode=yf;break}i.offset=b,i.extra=15&y,i.mode=24;case 24:if(i.extra){for(C=i.extra;h>>=i.extra,h-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){t.msg="invalid distance too far back",i.mode=yf;break}i.mode=25;case 25:if(0===c)break t;if(m=u-c,i.offset>m){if((m=i.offset-m)>i.whave&&i.sane){t.msg="invalid distance too far back",i.mode=yf;break}m>i.wnext?(m-=i.wnext,p=i.wsize-m):p=i.wnext-m,m>i.length&&(m=i.length),f=i.window}else f=s,p=o-i.offset,m=i.length;m>c&&(m=c),c-=m,i.length-=m;do{s[o++]=f[p++]}while(--m);0===i.length&&(i.mode=21);break;case 26:if(0===c)break t;s[o++]=i.length,c--,i.mode=21;break;case 27:if(i.wrap){for(;h<32;){if(0===a)break t;a--,l|=r[n++]<=252?6:Of>=248?5:Of>=240?4:Of>=224?3:Of>=192?2:1;function Rf(t){var e,i,r,s,n,o=t.length,a=0;for(s=0;s>>6,e[n++]=128|63&i):i<65536?(e[n++]=224|i>>>12,e[n++]=128|i>>>6&63,e[n++]=128|63&i):(e[n++]=240|i>>>18,e[n++]=128|i>>>12&63,e[n++]=128|i>>>6&63,e[n++]=128|63&i);return e}function Ef(t,e){var i,r,s,n,o=e||t.length,a=new Array(2*o);for(r=0,i=0;i4)a[r++]=65533,i+=n-1;else{for(s&=2===n?31:3===n?15:7;n>1&&i1?a[r++]=65533:s<65536?a[r++]=s:(s-=65536,a[r++]=55296|s>>10&1023,a[r++]=56320|1023&s)}return function(t,e){if(e<65537&&(t.subarray&&Df||!t.subarray&&Bf))return String.fromCharCode.apply(null,Hp(t,e));for(var i="",r=0;rt.length&&(e=t.length),i=e-1;i>=0&&128==(192&t[i]);)i--;return i<0||0===i?e:i+$f[t[i]]>e?i:e}$f[254]=$f[254]=1;var Lf=0,Nf={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"};function zf(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}function Vf(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var Gf=Object.prototype.toString;function Uf(t){if(!(this instanceof Uf))return new Uf(t);this.options=function(t){for(var e=Array.prototype.slice.call(arguments,1);e.length;){var i=e.shift();if(i){if("object"!=typeof i)throw new TypeError(i+"must be non-object");for(var r in i)i.hasOwnProperty(r)&&(t[r]=i[r])}}return t}({chunkSize:16384,windowBits:0,to:""},t||{});var e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&0==(15&e.windowBits)&&(e.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new zf,this.strm.avail_out=0;var i,r,s,n=_f(this.strm,e.windowBits);if(n!==Lf)throw new Error(Nf[n]);this.header=new Vf,i=this.strm,r=this.header,i&&i.state&&(0==(2&(s=i.state).wrap)||(s.head=r,r.done=!1))}Uf.prototype.push=function(t,e){var i,r,s,n,o,a,c=this.strm,l=this.options.chunkSize,h=this.options.dictionary,d=!1;if(this.ended)return!1;r=e===~~e?e:!0===e?4:0,"string"==typeof t?c.input=function(t){for(var e=new Uint8Array(t.length),i=0,r=e.length;i0||0===c.avail_out)&&1!==i);return 1===i&&(r=4),4===r?(i=function(t){if(!t||!t.state)return pf;var e=t.state;return e.window&&(e.window=null),t.state=null,mf}(this.strm),this.onEnd(i),this.ended=!0,i===Lf):2!==r||(this.onEnd(Lf),c.avail_out=0,!0)},Uf.prototype.onData=function(t){this.chunks.push(t)},Uf.prototype.onEnd=function(t){t===Lf&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=function(t){var e,i,r,s,n,o;for(r=0,e=0,i=t.length;e({path:t,data:e.data})))}getUrl(t){const e=ri(t);return`${this.baseUrl}file/${e.path}${e.query}`}getCountUrl(t){const e=ri(t);return`${this.baseUrl}traj/numframes/${e.path}${e.query}`}getFrameUrl(t,e){const i=ri(t);return`${this.baseUrl}traj/frame/${e}/${i.path}${i.query}`}getFrameParams(t,e){return`atomIndices=${e.join(";")}`}getPathUrl(t,e){const i=ri(t);return`${this.baseUrl}traj/path/${e}/${i.path}${i.query}`}getExt(t){return ri(t).ext}}function ig(t,e){return{type:"integer",max:t,min:e}}function rg(t,e,i){return{type:"number",precision:t,max:e,min:i}}function sg(t,e,i){return{type:"range",step:t,max:e,min:i}}function ng(...t){return{type:"select",options:t.reduce(((t,e)=>Object.assign(Object.assign({},t),{[e]:e})),{})}}const og={backgroundColor:{type:"color"},quality:ng("auto","low","medium","high"),sampleLevel:sg(1,5,-1),impostor:{type:"boolean"},workerDefault:{type:"boolean"},rotateSpeed:rg(1,10,0),zoomSpeed:rg(1,10,0),panSpeed:rg(1,10,0),clipNear:sg(1,100,0),clipFar:sg(1,100,0),clipDist:ig(200,0),clipMode:ng("scene","camera"),clipScale:ng("relative","absolute"),fogNear:sg(1,100,0),fogFar:sg(1,100,0),cameraType:ng("perspective","orthographic","stereo"),cameraEyeSep:rg(3,1,.01),cameraFov:sg(1,120,15),lightColor:{type:"color"},lightIntensity:rg(2,10,0),ambientColor:{type:"color"},ambientIntensity:rg(2,10,0),hoverTimeout:ig(1e4,-1),tooltip:{type:"boolean"},mousePreset:ng(...Object.keys(Zo))};const ag="2.2.1";export{zh as AngleRepresentation,hu as ArrowBuffer,La as Assembly,ed as AxesRepresentation,rd as BackboneRepresentation,id as BallAndStickRepresentation,sd as BaseRepresentation,fu as BoxBuffer,Tc as BufferRepresentation,dd as CartoonRepresentation,hl as Collection,zt as Colormaker,Fe as ColormakerRegistry,ll as Component,$l as ComponentCollection,au as ConeBuffer,ud as ContactRepresentation,ui as Counter,td as CylinderBuffer,Le as DatasourceRegistry,De as Debug,Ge as DecompressorRegistry,gd as DihedralHistogramRepresentation,md as DihedralRepresentation,bd as DistanceRepresentation,wu as EllipsoidBuffer,pl as Frames,Ad as HelixorientRepresentation,Bd as HyperballRepresentation,$a as Kdtree,ta as KeyActions,$d as LabelRepresentation,tr as LeftMouseButton,_d as LicoriceRepresentation,Rd as LineRepresentation,We as ListingDatasource,eg as MdsrvDatasource,Te as MeasurementDefaultParams,Uo as MeshBuffer,er as MiddleMouseButton,zd as MolecularSurface,Vd as MolecularSurfaceRepresentation,Ko as MouseActions,Pu as OctahedronBuffer,ze as ParserRegistry,ai as PdbWriter,br as PickingProxy,Wc as PointBuffer,Gd as PointRepresentation,Nr as Queue,dl as RepresentationCollection,nl as RepresentationElement,Ne as RepresentationRegistry,Wd as RibbonRepresentation,ir as RightMouseButton,qd as RocketRepresentation,Xd as RopeRepresentation,Re as ScriptExtensions,ci as SdfWriter,pe as Selection,Mc as Shape,Ll as ShapeComponent,Yd as SpacefillRepresentation,Ts as SpatialHash,Gc as SphereBuffer,Fl as Stage,tg as StaticDatasource,di as StlWriter,Cc as Structure,Tl as StructureComponent,Ml as StructureComponentDefaultParameters,Sh as StructureRepresentation,fl as Superposition,Bl as SurfaceComponent,Bu as TetrahedronBuffer,Eh as TextBuffer,Fu as TorusBuffer,Qd as TraceRepresentation,qe as TrajectoryDatasource,yl as TrajectoryPlayer,Jd as TubeRepresentation,og as UIStageParameters,tu as UnitcellRepresentation,eu as ValidationRepresentation,ag as Version,Ji as Viewer,Eo as Volume,Dl as VolumeComponent,Nh as WidelineBuffer,ni as autoLoad,ic as concatStructures,dt as download,at as flatten,si as getDataInfo,ri as getFileInfo,rt as getQuery,tc as guessElement,Oe as setDebug,Xe as setListingDatasource,Be as setMeasurementDefaultParams,Ye as setTrajectoryDatasource,kl as superpose,ut as throttle,gt as uniqueArray}; //# sourceMappingURL=ngl.esm.js.map diff --git a/dist/ngl.esm.js.map b/dist/ngl.esm.js.map index 2bbd9f61..a71d0fd1 100644 --- a/dist/ngl.esm.js.map +++ b/dist/ngl.esm.js.map @@ -1 +1 @@ -{"version":3,"file":"ngl.esm.js","sources":["../src/utils.ts","../src/utils/registry.ts","../src/math/math-utils.ts","../src/color/colormaker.ts","../src/selection/selection-constants.ts","../src/selection/selection-test.ts","../src/selection/selection.ts","../src/selection/selection-parser.ts","../src/color/selection-colormaker.ts","../src/color/colormaker-registry.ts","../src/worker/worker-utils.ts","../src/globals.ts","../src/worker/worker-registry.ts","../src/parser/parser-registry.ts","../src/streamer/streamer.ts","../src/streamer/file-streamer.ts","../src/streamer/network-streamer.ts","../src/loader/loader.ts","../src/loader/parser-loader.ts","../src/script.ts","../src/loader/script-loader.ts","../src/loader/loader-utils.ts","../src/writer/writer.ts","../src/writer/pdb-writer.ts","../src/writer/sdf-writer.ts","../src/utils/io-buffer.ts","../src/writer/stl-writer.ts","../src/utils/counter.ts","../src/viewer/stats.ts","../src/shader/shader-utils.ts","../src/viewer/viewer-constants.ts","../src/viewer/tiled-renderer.ts","../src/math/math-constants.ts","../src/math/array-utils.ts","../src/viewer/viewer-utils.ts","../src/viewer/gl-utils.ts","../src/viewer/viewer.ts","../src/constants.ts","../src/stage/mouse-observer.ts","../src/controls/trackball-controls.ts","../src/controls/picking-proxy.ts","../src/controls/picking-controls.ts","../src/controls/viewer-controls.ts","../src/animation/animation.ts","../src/controls/animation-controls.ts","../src/utils/queue.ts","../src/representation/representation.ts","../src/worker/worker.ts","../src/worker/worker-pool.ts","../src/math/vector-utils.ts","../src/geometry/dash.ts","../src/geometry/primitive.ts","../src/geometry/spatial-hash.ts","../src/store/store.ts","../src/store/contact-store.ts","../src/utils/bitarray.ts","../src/utils/adjacency-list.ts","../src/chemistry/interactions/features.ts","../src/structure/structure-constants.ts","../src/chemistry/geometry.ts","../src/chemistry/valence-model.ts","../src/structure/data.ts","../src/chemistry/functional-groups.ts","../src/chemistry/interactions/charged.ts","../src/chemistry/interactions/hydrogen-bonds.ts","../src/chemistry/interactions/metal-binding.ts","../src/chemistry/interactions/halogen-bonds.ts","../src/chemistry/interactions/refine-contacts.ts","../src/chemistry/interactions/contact.ts","../src/chemistry/interactions/hydrophobic.ts","../src/utils/picker.ts","../src/surface/marching-cubes.ts","../src/math/matrix-utils.ts","../src/surface/surface-utils.ts","../src/surface/surface.ts","../src/surface/volume.ts","../src/buffer/buffer.ts","../src/buffer/mesh-buffer.ts","../src/buffer/surface-buffer.ts","../src/buffer/doublesided-buffer.ts","../src/buffer/contour-buffer.ts","../src/representation/surface-representation.ts","../src/controls/mouse-actions.ts","../src/controls/mouse-controls.ts","../src/controls/key-actions.ts","../src/controls/key-controls.ts","../src/stage/picking-behavior.ts","../src/stage/mouse-behavior.ts","../src/stage/animation-behavior.ts","../src/stage/key-behavior.ts","../src/component/annotation.ts","../src/controls/component-controls.ts","../src/utils/radius-factory.ts","../src/math/principal-axes.ts","../src/surface/filtered-volume.ts","../src/store/bond-hash.ts","../src/store/bond-store.ts","../src/store/atom-store.ts","../src/store/residue-store.ts","../src/store/chain-store.ts","../src/store/model-store.ts","../src/geometry/helixorient.ts","../src/geometry/helixbundle.ts","../src/utils/binary-heap.ts","../src/utils/kdtree.ts","../src/proxy/atom-proxy.ts","../src/geometry/kdtree.ts","../src/symmetry/symmetry-constants.ts","../src/symmetry/symmetry-utils.ts","../src/symmetry/assembly.ts","../src/structure/structure-builder.ts","../src/structure/structure-utils.ts","../src/store/atom-type.ts","../src/store/atom-map.ts","../src/store/residue-type.ts","../src/store/residue-map.ts","../src/proxy/bond-proxy.ts","../src/proxy/residue-proxy.ts","../src/proxy/polymer.ts","../src/proxy/chain-proxy.ts","../src/proxy/model-proxy.ts","../src/structure/structure.ts","../src/geometry/shape.ts","../src/representation/buffer-representation.ts","../src/buffer/geometry-buffer.ts","../src/buffer/spheregeometry-buffer.ts","../src/buffer/mapped-buffer.ts","../src/buffer/mappedquad-buffer.ts","../src/buffer/sphereimpostor-buffer.ts","../src/buffer/sphere-buffer.ts","../src/buffer/point-buffer.ts","../src/representation/dot-representation.ts","../src/buffer/image-buffer.ts","../src/surface/volume-slice.ts","../src/representation/slice-representation.ts","../src/representation/representation-utils.ts","../src/component/element.ts","../src/component/representation-element.ts","../src/component/component.ts","../src/component/collection.ts","../src/component/representation-collection.ts","../src/component/trajectory-element.ts","../src/trajectory/frames.ts","../src/align/superposition.ts","../src/trajectory/trajectory-player.ts","../src/trajectory/trajectory.ts","../src/trajectory/frames-trajectory.ts","../src/trajectory/structure-trajectory.ts","../src/trajectory/remote-trajectory.ts","../src/trajectory/callback-trajectory.ts","../src/structure/structure-view.ts","../src/align/alignment.ts","../src/align/align-utils.ts","../src/component/structure-component.ts","../src/trajectory/trajectory-utils.ts","../src/component/surface-component.ts","../src/component/volume-component.ts","../src/component/component-collection.ts","../src/stage/stage.ts","../src/component/shape-component.ts","../node_modules/tslib/tslib.es6.js","../src/color/atomindex-colormaker.ts","../src/color/bfactor-colormaker.ts","../src/color/chainid-colormaker.ts","../src/color/chainindex-colormaker.ts","../src/color/chainname-colormaker.ts","../src/color/densityfit-colormaker.ts","../src/color/electrostatic-colormaker.ts","../src/color/element-colormaker.ts","../src/color/entityindex-colormaker.ts","../src/color/entitytype-colormaker.ts","../src/color/geoquality-colormaker.ts","../src/color/hydrophobicity-colormaker.ts","../src/color/modelindex-colormaker.ts","../src/color/moleculetype-colormaker.ts","../src/color/occupancy-colormaker.ts","../src/color/partialcharge-colormaker.ts","../src/color/random-colormaker.ts","../src/color/randomcoilindex-colormaker.ts","../src/color/residueindex-colormaker.ts","../src/color/resname-colormaker.ts","../src/color/sstruc-colormaker.ts","../src/color/structuredata-colormaker.ts","../src/color/uniform-colormaker.ts","../src/color/value-colormaker.ts","../src/color/volume-colormaker.ts","../src/representation/structure-representation.ts","../src/representation/measurement-representation.ts","../src/utils/edt.ts","../src/buffer/text-buffer.ts","../src/buffer/wideline-buffer.ts","../src/representation/angle-representation.ts","../src/buffer/cylindergeometry-buffer.ts","../src/buffer/mappedalignedbox-buffer.ts","../src/buffer/cylinderimpostor-buffer.ts","../src/buffer/cylinder-buffer.ts","../src/representation/axes-representation.ts","../src/representation/ballandstick-representation.ts","../src/representation/backbone-representation.ts","../src/representation/base-representation.ts","../src/geometry/spline.ts","../src/buffer/tubemesh-buffer.ts","../src/representation/cartoon-representation.ts","../src/representation/contact-representation.ts","../src/representation/dihedral-representation.ts","../src/representation/dihedral-histogram-representation.ts","../src/representation/distance-representation.ts","../src/buffer/vector-buffer.ts","../src/representation/helixorient-representation.ts","../src/representation/licorice-representation.ts","../src/buffer/mappedbox-buffer.ts","../src/buffer/hyperballstickimpostor-buffer.ts","../src/buffer/hyperballstick-buffer.ts","../src/representation/hyperball-representation.ts","../src/utils/label-factory.ts","../src/representation/label-representation.ts","../src/representation/line-representation.ts","../src/geometry/grid.ts","../src/surface/edt-surface.ts","../src/surface/av-surface.ts","../src/surface/molecular-surface.ts","../src/representation/molecularsurface-representation.ts","../src/representation/point-representation.ts","../src/buffer/ribbon-buffer.ts","../src/representation/ribbon-representation.ts","../src/representation/rocket-representation.ts","../src/representation/rope-representation.ts","../src/representation/spacefill-representation.ts","../src/buffer/trace-buffer.ts","../src/representation/trace-representation.ts","../src/representation/tube-representation.ts","../src/representation/unitcell-representation.ts","../src/representation/validation-representation.ts","../src/buffer/cone-buffer.ts","../src/viewer/geometry-group.ts","../src/buffer/arrow-buffer.ts","../src/buffer/box-buffer.ts","../src/buffer/ellipsoid-buffer.ts","../src/buffer/octahedron-buffer.ts","../src/buffer/tetrahedron-buffer.ts","../src/buffer/torus-buffer.ts","../src/parser/parser.ts","../src/parser/structure-parser.ts","../src/structure/entity.ts","../src/symmetry/unitcell.ts","../src/parser/pdb-parser.ts","../src/parser/cif-parser.ts","../src/parser/gro-parser.ts","../lib/mmtf.es6.js","../src/parser/mmtf-parser.ts","../src/parser/mol2-parser.ts","../src/parser/pdbqt-parser.ts","../src/parser/pqr-parser.ts","../src/parser/sdf-parser.ts","../src/parser/prmtop-parser.ts","../src/parser/psf-parser.ts","../src/parser/top-parser.ts","../src/parser/trajectory-parser.ts","../src/utils/netcdf-reader.ts","../src/parser/dcd-parser.ts","../src/parser/nctraj-parser.ts","../src/parser/trr-parser.ts","../src/parser/xtc-parser.ts","../src/parser/volume-parser.ts","../src/parser/cube-parser.ts","../src/parser/dsn6-parser.ts","../src/parser/dx-parser.ts","../src/parser/dxbin-parser.ts","../src/parser/mrc-parser.ts","../src/parser/xplor-parser.ts","../src/parser/kin-parser.ts","../src/parser/surface-parser.ts","../src/parser/obj-parser.ts","../src/parser/ply-parser.ts","../src/parser/csv-parser.ts","../src/parser/json-parser.ts","../src/parser/msgpack-parser.ts","../src/parser/netcdf-parser.ts","../src/parser/text-parser.ts","../src/utils/parse-xml.ts","../src/parser/xml-parser.ts","../src/structure/validation.ts","../lib/pako_inflate.es6.js","../src/parser/validation-parser.ts","../src/utils/gzip-decompressor.ts","../src/datasource/datasource.ts","../src/datasource/rcsb-datasource.ts","../src/datasource/pubchem-datasource.ts","../src/datasource/passthrough-datasource.ts","../src/datasource/alphafold-datasource.ts","../src/datasource/static-datasource.ts","../src/datasource/mdsrv-datasource.ts","../src/ui/parameters.ts","../src/version.ts"],"sourcesContent":["/**\n * @file Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector2, Vector3, Matrix4, Quaternion } from 'three'\n\nexport function getQuery (id: string) {\n if (typeof window === 'undefined') return undefined\n\n const a = new RegExp(`${id}=([^&#=]*)`)\n const m = a.exec(window.location.search)\n\n if (m) {\n return decodeURIComponent(m[1])\n } else {\n return undefined\n }\n}\n\nexport function boolean (value: any) {\n if (!value) {\n return false\n }\n\n if (typeof value === 'string') {\n return /^1|true|t|yes|y$/i.test(value)\n }\n\n return true\n}\n\nexport function defaults (value: any, defaultValue: any) {\n return value !== undefined ? value : defaultValue\n}\n\nexport function createParams (params: {[k in keyof T]?: any}, defaultParams: T) {\n const o: any = Object.assign({}, params)\n for (const k in defaultParams) {\n const value = params[k]\n if (value === undefined) o[k] = defaultParams[k]\n }\n return o as T\n}\n\nexport function updateParams (params: T, newParams: {[k in keyof T]?: any}) {\n for (const k in newParams) {\n const value = newParams[k]\n if (value !== undefined) params[k] = value\n }\n return params as T\n}\n\nexport function pick (object: { [index: string]: any }) {\n const properties = [].slice.call(arguments, 1)\n return properties.reduce((a: { [index: string]: any }, e: any) => {\n a[ e ] = object[ e ]\n return a\n }, {})\n}\n\nexport function flatten (array: any[], ret: any[]) {\n ret = defaults(ret, [])\n for (let i = 0; i < array.length; i++) {\n if (Array.isArray(array[i])) {\n flatten(array[i], ret)\n } else {\n ret.push(array[i])\n }\n }\n return ret\n}\n\nexport function getProtocol () {\n const protocol = window.location.protocol\n return protocol.match(/http(s)?:/gi) === null ? 'http:' : protocol\n}\n\nexport function getBrowser () {\n if (typeof window === 'undefined') return false\n\n const ua = window.navigator.userAgent\n\n if (/Opera|OPR/.test(ua)) {\n return 'Opera'\n } else if (/Chrome/i.test(ua)) {\n return 'Chrome'\n } else if (/Firefox/i.test(ua)) {\n return 'Firefox'\n } else if (/Mobile(\\/.*)? Safari/i.test(ua)) {\n return 'Mobile Safari'\n } else if (/MSIE/i.test(ua)) {\n return 'Internet Explorer'\n } else if (/Safari/i.test(ua)) {\n return 'Safari'\n }\n\n return false\n}\n\nexport function getAbsolutePath (relativePath: string) {\n const loc = window.location\n const pn = loc.pathname\n const basePath = pn.substring(0, pn.lastIndexOf('/') + 1)\n\n return loc.origin + basePath + relativePath\n}\n\nexport function deepCopy (src: any) {\n if (typeof src !== 'object') {\n return src\n }\n\n const dst: { [index: string]: any } = Array.isArray(src) ? [] : {}\n\n for (let key in src) {\n dst[ key ] = deepCopy(src[ key ])\n }\n\n return dst\n}\n\nexport function deepEqual(a: any, b: any) {\n // from https://github.com/epoberezkin/fast-deep-equal MIT\n if (a === b) return true;\n\n const arrA = Array.isArray(a)\n const arrB = Array.isArray(b)\n\n if (arrA && arrB) {\n if (a.length !== b.length) return false\n for (let i = 0; i < a.length; i++) {\n if (!deepEqual(a[i], b[i])) return false\n }\n return true\n }\n\n if (arrA !== arrB) return false\n\n if (a && b && typeof a === 'object' && typeof b === 'object') {\n const keys = Object.keys(a)\n if (keys.length !== Object.keys(b).length) return false;\n\n const dateA = a instanceof Date\n const dateB = b instanceof Date\n if (dateA && dateB) return a.getTime() === b.getTime()\n if (dateA !== dateB) return false\n\n const regexpA = a instanceof RegExp\n const regexpB = b instanceof RegExp\n if (regexpA && regexpB) return a.toString() === b.toString()\n if (regexpA !== regexpB) return false\n\n for (let i = 0; i < keys.length; i++) {\n if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false\n }\n\n for (let i = 0; i < keys.length; i++) {\n if(!deepEqual(a[keys[i]], b[keys[i]])) return false\n }\n\n return true\n }\n\n return false\n}\n\nfunction openUrl (url: string) {\n const opened = window.open(url, '_blank')\n if (!opened) {\n window.location.href = url\n }\n}\n\nexport function download (data: Blob|string, downloadName = 'download') {\n // using ideas from https://github.com/eligrey/FileSaver.js/blob/master/FileSaver.js\n\n if (!data) return\n\n const isSafari = getBrowser() === 'Safari'\n const isChromeIos = /CriOS\\/[\\d]+/.test(window.navigator.userAgent)\n\n const a = document.createElement('a')\n\n function open (str: string) {\n openUrl(isChromeIos ? str : str.replace(/^data:[^;]*;/, 'data:attachment/file;'))\n }\n\n if (typeof navigator !== 'undefined' && (navigator as any).msSaveOrOpenBlob) {\n // native saveAs in IE 10+\n (navigator as any).msSaveOrOpenBlob(data, downloadName)\n } else if ((isSafari || isChromeIos) && FileReader) {\n if (data instanceof Blob) {\n // no downloading of blob urls in Safari\n var reader = new FileReader()\n reader.onloadend = function () {\n open(reader.result as string)\n }\n reader.readAsDataURL(data)\n } else {\n open(data)\n }\n } else {\n let objectUrlCreated = false\n if (data instanceof Blob) {\n data = URL.createObjectURL(data)\n objectUrlCreated = true\n }\n\n if ('download' in a) {\n // download link available\n a.style.display = 'hidden'\n document.body.appendChild(a)\n a.href = data\n a.download = downloadName\n a.target = '_blank'\n a.click()\n document.body.removeChild(a)\n } else {\n openUrl(data)\n }\n\n if (objectUrlCreated) {\n window.URL.revokeObjectURL(data)\n }\n }\n}\n\nexport function submit (url: string, data: FormData, callback: Function, onerror: Function) {\n const xhr = new XMLHttpRequest()\n xhr.open('POST', url)\n\n xhr.addEventListener('load', function () {\n if (xhr.status === 200 || xhr.status === 304) {\n callback(xhr.response)\n } else {\n if (typeof onerror === 'function') {\n onerror(xhr.status)\n }\n }\n }, false)\n\n xhr.send(data)\n}\n\ninterface HTMLInputEvent extends Event {\n target: HTMLInputElement & EventTarget\n}\n\nexport function open (callback: Function, extensionList = ['*']) {\n const fileInput = document.createElement('input')\n fileInput.type = 'file'\n fileInput.multiple = true\n fileInput.style.display = 'hidden'\n document.body.appendChild(fileInput)\n fileInput.accept = '.' + extensionList.join(',.')\n fileInput.addEventListener('change', function (e: HTMLInputEvent) {\n callback(e.target.files)\n }, false)\n\n fileInput.click()\n}\n\nexport function throttle (func: Function, wait: number, options: { leading?: boolean, trailing?: boolean }) {\n // from http://underscorejs.org/docs/underscore.html\n\n let context: any\n let args: any\n let result: any\n let timeout: any = null\n let previous = 0\n\n if (!options) options = {}\n\n function later () {\n previous = options.leading === false ? 0 : Date.now()\n timeout = null\n result = func.apply(context, args)\n if (!timeout) context = args = null\n }\n\n return function throttle (this: any) {\n var now = Date.now()\n if (!previous && options.leading === false) previous = now\n var remaining = wait - (now - previous)\n context = this\n args = arguments\n if (remaining <= 0 || remaining > wait) {\n if (timeout) {\n clearTimeout(timeout)\n timeout = null\n }\n previous = now\n result = func.apply(context, args)\n if (!timeout) context = args = null\n } else if (!timeout && options.trailing !== false) {\n timeout = setTimeout(later, remaining)\n }\n\n return result\n }\n}\n\nexport function lexicographicCompare (elm1: T, elm2: T) {\n if (elm1 < elm2) return -1\n if (elm1 > elm2) return 1\n return 0\n}\n\n/**\n * Does a binary search to get the index of an element in the input array\n * @function\n * @example\n * var array = [ 1, 2, 3, 4, 5, 6 ];\n * var element = 4;\n * binarySearchIndexOf( array, element ); // returns 3\n *\n * @param {Array} array - sorted array\n * @param {Anything} element - element to search for in the array\n * @param {Function} [compareFunction] - compare function\n * @return {Number} the index of the element or -1 if not in the array\n */\nexport function binarySearchIndexOf (array: T[], element: T, compareFunction = lexicographicCompare) {\n let low = 0\n let high = array.length - 1\n while (low <= high) {\n const mid = (low + high) >> 1\n const cmp = compareFunction(element, array[ mid ])\n if (cmp > 0) {\n low = mid + 1\n } else if (cmp < 0) {\n high = mid - 1\n } else {\n return mid\n }\n }\n return -low - 1\n}\n\nexport function binarySearchForLeftRange (array: number[], leftRange: number) {\n let high = array.length - 1\n if (array[ high ] < leftRange) return -1\n let low = 0\n while (low <= high) {\n const mid = (low + high) >> 1\n if (array[ mid ] >= leftRange) {\n high = mid - 1\n } else {\n low = mid + 1\n }\n }\n return high + 1\n}\n\nexport function binarySearchForRightRange (array: number[], rightRange: number) {\n if (array[ 0 ] > rightRange) return -1\n let low = 0\n let high = array.length - 1\n while (low <= high) {\n const mid = (low + high) >> 1\n if (array[ mid ] > rightRange) {\n high = mid - 1\n } else {\n low = mid + 1\n }\n }\n return low - 1\n}\n\nexport function rangeInSortedArray (array: number[], min: number, max: number) {\n const indexLeft = binarySearchForLeftRange(array, min)\n const indexRight = binarySearchForRightRange(array, max)\n if (indexLeft === -1 || indexRight === -1 || indexLeft > indexRight) {\n return 0\n } else {\n return indexRight - indexLeft + 1\n }\n}\n\nexport function dataURItoImage (dataURI: string) {\n const img = document.createElement('img')\n img.src = dataURI\n return img\n}\n\nexport function uniqueArray (array: any[]) {\n return array.sort().filter(function (value, index, sorted) {\n return (index === 0) || (value !== sorted[ index - 1 ])\n })\n}\n\n// String/arraybuffer conversion\n\nexport function uint8ToString (u8a: Uint8Array) {\n const chunkSize = 0x7000\n\n if (u8a.length > chunkSize) {\n const c = []\n\n for (let i = 0; i < u8a.length; i += chunkSize) {\n c.push(String.fromCharCode.apply(\n null, u8a.subarray(i, i + chunkSize)\n ))\n }\n\n return c.join('')\n } else {\n return String.fromCharCode.apply(null, u8a)\n }\n}\n\nexport function uint8ToLines (u8a: Uint8Array, chunkSize = 1024 * 1024 * 10, newline = '\\n') {\n let partialLine = ''\n let lines: string[] = []\n\n for (let i = 0; i < u8a.length; i += chunkSize) {\n const str = uint8ToString(u8a.subarray(i, i + chunkSize))\n const idx = str.lastIndexOf(newline)\n\n if (idx === -1) {\n partialLine += str\n } else {\n const str2 = partialLine + str.substr(0, idx)\n lines = lines.concat(str2.split(newline))\n\n if (idx === str.length - newline.length) {\n partialLine = ''\n } else {\n partialLine = str.substr(idx + newline.length)\n }\n }\n }\n\n if (partialLine !== '') {\n lines.push(partialLine)\n }\n\n return lines\n}\n\nexport type TypedArrayString = 'int8'|'int16'|'int32'|'uint8'|'uint16'|'uint32'|'float32'\nexport function getTypedArray (arrayType: TypedArrayString, arraySize: number) {\n switch (arrayType) {\n case 'int8':\n return new Int8Array(arraySize)\n case 'int16':\n return new Int16Array(arraySize)\n case 'int32':\n return new Int32Array(arraySize)\n case 'uint8':\n return new Uint8Array(arraySize)\n case 'uint16':\n return new Uint16Array(arraySize)\n case 'uint32':\n return new Uint32Array(arraySize)\n case 'float32':\n return new Float32Array(arraySize)\n default:\n throw new Error('arrayType unknown: ' + arrayType)\n }\n}\n\nexport function getUintArray (sizeOrArray: any, maxUint: number) { // TODO\n const TypedArray = maxUint > 65535 ? Uint32Array : Uint16Array\n return new TypedArray(sizeOrArray)\n}\n\nexport function ensureArray (value: any) {\n return Array.isArray(value) ? value : [value]\n}\n\nexport function ensureBuffer (a: any) { // TODO\n return (a.buffer && a.buffer instanceof ArrayBuffer) ? a.buffer : a\n}\n\nfunction _ensureClassFromArg (arg: any, constructor: { new (arg: any): any }) {\n return arg instanceof constructor ? arg : new constructor(arg)\n}\n\nfunction _ensureClassFromArray (array: any, constructor: { new (): any }) {\n if (array === undefined) {\n array = new constructor()\n } else if (Array.isArray(array)) {\n array = new constructor().fromArray(array)\n }\n return array\n}\n\nexport function ensureVector2 (v?: number[]|Vector2) {\n return _ensureClassFromArray(v, Vector2)\n}\n\nexport function ensureVector3 (v?: number[]|Vector3) {\n return _ensureClassFromArray(v, Vector3)\n}\n\nexport function ensureMatrix4 (m?: number[]|Matrix4) {\n return _ensureClassFromArray(m, Matrix4)\n}\n\nexport function ensureQuaternion (q?: number[]|Quaternion) {\n return _ensureClassFromArray(q, Quaternion)\n}\n\nexport function ensureFloat32Array (a?: number[]|Float32Array) {\n return _ensureClassFromArg(a, Float32Array)\n}\n\nexport interface RingBuffer {\n has: (value: T) => boolean\n get: (value: number) => T\n push: (value: T) => void\n count: number\n data: T[]\n clear: () => void\n}\n\nexport function createRingBuffer (length: number): RingBuffer {\n let pointer = 0\n let count = 0\n const buffer: T[] = []\n\n return {\n has: function (value: any) { return buffer.indexOf(value) !== -1 },\n get: function (idx: number) { return buffer[idx] },\n push: function (item: any) {\n buffer[pointer] = item\n pointer = (length + pointer + 1) % length\n ++count\n },\n get count () { return count },\n get data () { return buffer.slice(0, Math.min(count, length)) },\n clear: function () {\n count = 0\n pointer = 0\n buffer.length = 0\n }\n }\n}\n\nexport interface SimpleDict {\n has: (k: K) => boolean\n add: (k: K, v: V) => void\n del: (k: K) => void\n values: V[]\n}\n\nexport function createSimpleDict (): SimpleDict {\n const set: { [k: string]: V } = {}\n\n return {\n has: function (k: K) { return set[JSON.stringify(k)] !== undefined },\n add: function (k: K, v: V) { set[JSON.stringify(k)] = v },\n del: function (k: K) { delete set[JSON.stringify(k)] },\n get values () { return Object.keys(set).map(k => set[k]) }\n }\n}\n\nexport interface SimpleSet {\n has: (value: T) => boolean\n add: (value: T) => void\n del: (value: T) => void\n list: T[]\n}\n\nexport function createSimpleSet (): SimpleSet {\n const set: { [k: string]: T } = {}\n\n return {\n has: function (v: T) { return set[JSON.stringify(v)] !== undefined },\n add: function (v: T) { set[JSON.stringify(v)] = v },\n del: function (v: T) { delete set[JSON.stringify(v)] },\n get list () { return Object.keys(set).map(k => set[k]) },\n }\n}\n","/**\n * @file Registry\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\n\nfunction toLowerCaseString (value: string) {\n return defaults(value, '').toString().toLowerCase()\n}\n\nexport default class Registry {\n name: string\n private _dict: {[k: string]: any}\n\n constructor (name: string) {\n this.name = name\n this._dict = {}\n }\n\n add (key: string, value: any) {\n this._dict[ toLowerCaseString(key) ] = value\n }\n\n get (key: string) {\n return this._dict[ toLowerCaseString(key) ]\n }\n\n get names () {\n return Object.keys(this._dict)\n }\n}","/**\n * @file Math Utils\n * @author Alexander Rose \n * @private\n */\n\nexport function degToRad (deg: number) {\n return deg * 0.01745 // deg * Math.PI / 180\n}\n\nexport function radToDeg (rad: number) {\n return rad * 57.29578 // rad * 180 / Math.PI\n}\n\n// http://www.broofa.com/Tools/Math.uuid.htm\nconst chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('')\nconst uuid = new Array(36)\n\nexport function generateUUID () {\n let rnd = 0\n let r\n\n for (let i = 0; i < 36; i++) {\n if (i === 8 || i === 13 || i === 18 || i === 23) {\n uuid[ i ] = '-'\n } else if (i === 14) {\n uuid[ i ] = '4'\n } else {\n if (rnd <= 0x02) rnd = 0x2000000 + (Math.random() * 0x1000000) | 0\n r = rnd & 0xf\n rnd = rnd >> 4\n uuid[ i ] = chars[ (i === 19) ? (r & 0x3) | 0x8 : r ]\n }\n }\n\n return uuid.join('')\n}\n\nexport function countSetBits (i: number) {\n i = i - ((i >> 1) & 0x55555555)\n i = (i & 0x33333333) + ((i >> 2) & 0x33333333)\n return (((i + (i >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24\n}\n\nexport function normalize (value: number, min: number, max: number) {\n return (value - min) / (max - min)\n}\n\nexport function clamp (value: number, min: number, max: number) {\n return Math.max(min, Math.min(max, value))\n}\n\nexport function pclamp (value: number) {\n return clamp(value, 0, 100)\n}\n\nexport function saturate (value: number) {\n return clamp(value, 0, 1)\n}\n\nexport function lerp (start: number, stop: number, alpha: number) {\n return start + (stop - start) * alpha\n}\n\nexport function spline (p0: number, p1: number, p2: number, p3: number, t: number, tension: number) {\n const v0 = (p2 - p0) * tension\n const v1 = (p3 - p1) * tension\n const t2 = t * t\n const t3 = t * t2\n return (2 * p1 - 2 * p2 + v0 + v1) * t3 +\n (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 +\n v0 * t + p1\n}\n\nexport function smoothstep (min: number, max: number, x: number) {\n x = saturate(normalize(x, min, max))\n return x * x * (3 - 2 * x)\n}\n\nexport function smootherstep (min: number, max: number, x: number) {\n x = saturate(normalize(x, min, max))\n return x * x * x * (x * (x * 6 - 15) + 10)\n}\n\nexport function smootheststep (min: number, max: number, x: number) {\n x = saturate(normalize(x, min, max))\n return (\n -20 * Math.pow(x, 7) +\n 70 * Math.pow(x, 6) -\n 84 * Math.pow(x, 5) +\n 35 * Math.pow(x, 4)\n )\n}\n\nexport function almostIdentity (value: number, start: number, stop: number) {\n if (value > start) return value\n const a = 2 * stop - start\n const b = 2 * start - 3 * stop\n const t = value / start\n return (a * t + b) * t * t + stop\n}","/**\n * @file Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Color } from 'three'\nimport * as chroma from 'chroma-js'\n\nimport { createParams } from '../utils'\nimport { NumberArray } from '../types'\nimport Structure from '../structure/structure'\nimport Surface from '../surface/surface'\nimport Volume from '../surface/volume'\nimport AtomProxy from '../proxy/atom-proxy'\nimport BondProxy from '../proxy/bond-proxy'\n\nexport type ColorMode = 'rgb'|'hsv'|'hsl'|'hsi'|'lab'|'hcl'\nexport type ColorSpace = 'sRGB' | 'linear'\n\n/**\n * Internal color space for all colors (global).\n * Colors are always specified as sRGB; if this is set to\n * 'linear' then colors get linearized when used internally\n * as vertex or texture colors.\n * @see setColorSpace/getColorSpace.\n */\nvar colorSpace: ColorSpace = 'sRGB' // default: don't linearize\n\n/** Set the global internal color space for colormakers */\nexport function setColorSpace(space: ColorSpace) {\n colorSpace = space\n}\n\n/** Get the global internal color space for colormakers */\nexport function getColorSpace() {\n return colorSpace\n}\n\nexport const ScaleDefaultParameters = {\n scale: 'uniform' as string|string[],\n mode: 'hcl' as ColorMode,\n domain: [ 0, 1 ] as number[],\n value: 0xFFFFFF,\n reverse: false,\n}\nexport type ScaleParameters = typeof ScaleDefaultParameters\n\nexport interface ColorData {\n atomData?: number[],\n bondData?: number[]\n}\n\nexport interface ColormakerParameters extends ScaleParameters {\n structure?: Structure\n volume?: Volume\n surface?: Surface\n data?: ColorData\n}\n\nexport type StuctureColormakerParams = { structure: Structure } & Partial\nexport type VolumeColormakerParams = { volume: Volume } & Partial\nexport type ColormakerScale = (v: number) => number\n\nconst tmpColor = new Color()\n\n/** Decorator for optionally linearizing a numeric color */\ntype colorFuncType = (value: any, fromTo?: boolean) => number // decorator applies to functions with this shape\nexport function manageColor\n (_target: Object,\n _name: string | symbol,\n descriptor: TypedPropertyDescriptor): PropertyDescriptor {\n const originalMethod = descriptor.value\n const linearize: colorFuncType = function (this: T, value: any, fromTo?: boolean) {\n let result = originalMethod!.bind(this, value, fromTo)()\n if (colorSpace == 'linear') {\n tmpColor.set(result)\n tmpColor.convertSRGBToLinear()\n return tmpColor.getHex()\n } else {\n return result\n }\n }\n descriptor.value = linearize\n return descriptor\n }\n\n/**\n * Class for making colors.\n * @interface\n */\nabstract class Colormaker {\n parameters: ColormakerParameters\n atomProxy?: AtomProxy\n\n /**\n * Create a colormaker instance\n * @param {ColormakerParameters} params - colormaker parameter\n */\n constructor (params: Partial = {}) {\n this.parameters = createParams(params, ScaleDefaultParameters)\n\n if (typeof this.parameters.value === 'string') {\n this.parameters.value = tmpColor.set(this.parameters.value).getHex()\n }\n\n if (this.parameters.structure) {\n this.atomProxy = this.parameters.structure.getAtomProxy()\n }\n }\n\n getScale (params: Partial = {}) {\n const p = createParams(params, this.parameters)\n\n if (p.scale === 'rainbow') {\n p.scale = [ 'red', 'orange', 'yellow', 'green', 'blue' ]\n } else if (p.scale === 'rwb') {\n p.scale = [ 'red', 'white', 'blue' ]\n }\n\n if (p.reverse) {\n p.domain = p.domain.slice().reverse()\n }\n return chroma\n .scale(p.scale as any) // TODO\n .mode(p.mode)\n .domain(p.domain)\n .out('num' as any) // returns RGB color as numeric (not string \"#ffffff\")\n }\n\n /**\n * save a color to an array\n * @param {Integer} color - hex color value\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n colorToArray (color: number, array: NumberArray = [], offset = 0) {\n array[ offset ] = (color >> 16 & 255) / 255\n array[ offset + 1 ] = (color >> 8 & 255) / 255\n array[ offset + 2 ] = (color & 255) / 255\n\n return array\n }\n\n atomColor? (atom: AtomProxy): number\n\n /**\n * save an atom color to an array\n * @param {AtomProxy} atom - atom to get color for\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n atomColorToArray (atom: AtomProxy, array: NumberArray, offset: number) {\n return this.colorToArray(\n this.atomColor ? this.atomColor(atom) : 0x000000, array, offset\n )\n }\n\n /**\n * return the color for an bond\n * @param {BondProxy} bond - bond to get color for\n * @param {Boolean} fromTo - whether to use the first or second atom of the bond\n * @return {Integer} hex bond color\n */\n bondColor (bond: BondProxy, fromTo: boolean) {\n if (this.atomProxy && this.atomColor) {\n this.atomProxy.index = fromTo ? bond.atomIndex1 : bond.atomIndex2\n return this.atomColor(this.atomProxy)\n } else {\n return 0x000000\n }\n }\n\n /**\n * safe a bond color to an array\n * @param {BondProxy} bond - bond to get color for\n * @param {Boolean} fromTo - whether to use the first or second atom of the bond\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n bondColorToArray (bond: BondProxy, fromTo: boolean, array: NumberArray, offset: number) {\n return this.colorToArray(\n this.bondColor(bond, fromTo), array, offset\n )\n }\n\n volumeColor? (index: number): number\n\n /**\n * safe a volume cell color to an array\n * @param {Integer} index - volume cell index\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n volumeColorToArray (index: number, array: NumberArray, offset: number) {\n return this.colorToArray(\n this.volumeColor ? this.volumeColor(index) : 0x000000, array, offset\n )\n }\n\n positionColor? (position: Vector3): number\n\n /**\n * safe a color for coordinates in space to an array\n * @param {Vector3} coords - xyz coordinates\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n positionColorToArray (coords: Vector3, array: NumberArray, offset: number) {\n return this.colorToArray(\n this.positionColor ? this.positionColor(coords) : 0x000000, array, offset\n )\n }\n}\n\nexport default Colormaker\n","/**\n * @file Selection Constants\n * @author Alexander Rose \n * @private\n */\n\nexport enum kwd {\n PROTEIN = 1,\n NUCLEIC = 2,\n RNA = 3,\n DNA = 4,\n POLYMER = 5,\n WATER = 6,\n HELIX = 7,\n SHEET = 8,\n TURN = 9,\n BACKBONE = 10,\n SIDECHAIN = 11,\n ALL = 12,\n HETERO = 13,\n ION = 14,\n SACCHARIDE = 15,\n SUGAR = 15,\n BONDED = 16,\n RING = 17,\n AROMATICRING = 18,\n METAL = 19,\n POLARH = 20,\n NONE = 21\n}\n\nexport const SelectAllKeyword = [ '*', '', 'ALL' ]\nexport const SelectNoneKeyword = [ 'NONE' ]\n\nexport const AtomOnlyKeywords = [\n kwd.BACKBONE, kwd.SIDECHAIN, kwd.BONDED, kwd.RING, kwd.AROMATICRING, kwd.METAL, kwd.POLARH\n]\n\nexport const ChainKeywords = [\n kwd.POLYMER, kwd.WATER\n]\n\nexport const SmallResname = [ 'ALA', 'GLY', 'SER' ]\nexport const NucleophilicResname = [ 'CYS', 'SER', 'THR' ]\nexport const HydrophobicResname = [ 'ALA', 'ILE', 'LEU', 'MET', 'PHE', 'PRO', 'TRP', 'VAL' ]\nexport const AromaticResname = [ 'PHE', 'TRP', 'TYR', 'HIS' ]\nexport const AmideResname = [ 'ASN', 'GLN' ]\nexport const AcidicResname = [ 'ASP', 'GLU' ]\nexport const BasicResname = [ 'ARG', 'HIS', 'LYS' ]\nexport const ChargedResname = [ 'ARG', 'ASP', 'GLU', 'HIS', 'LYS' ]\nexport const PolarResname = [ 'ASN', 'ARG', 'ASP', 'CYS', 'GLY', 'GLN', 'GLU', 'HIS', 'LYS', 'SER', 'THR', 'TYR' ]\nexport const NonpolarResname = [ 'ALA', 'ILE', 'LEU', 'MET', 'PHE', 'PRO', 'TRP', 'VAL' ]\nexport const CyclicResname = [ 'HIS', 'PHE', 'PRO', 'TRP', 'TYR' ]\nexport const AliphaticResname = [ 'ALA', 'GLY', 'ILE', 'LEU', 'VAL' ]\n","/**\n * @file Selection Test\n * @author Alexander Rose \n * @private\n */\n\nimport { binarySearchIndexOf, rangeInSortedArray } from '../utils'\nimport { kwd, AtomOnlyKeywords, ChainKeywords } from './selection-constants'\n\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\nexport type ProxyEntity = AtomProxy|ResidueProxy|ChainProxy|ModelProxy\ntype TestEntityFn = (e: ProxyEntity, s: SelectionRule) => boolean|-1\ntype FilterFn = (s: SelectionRule) => boolean\nexport type SelectionTest = false|((e: ProxyEntity) => boolean|-1)\n\nexport type SelectionOperator = 'AND'|'OR'\nexport interface SelectionRule {\n keyword?: any\n atomname?: string\n element?: string\n atomindex?: number[]\n altloc?: string\n inscode?: string\n resname?: string|string[]\n sstruc?: string\n resno?: number|[number, number]\n chainname?: string\n model?: number\n\n error?: string\n rules?: SelectionRule[]\n negate?: boolean\n operator?: SelectionOperator\n}\n\nfunction atomTestFn (a: AtomProxy, s: SelectionRule) {\n // returning -1 means the rule is not applicable\n if (s.atomname === undefined && s.element === undefined &&\n s.altloc === undefined && s.atomindex === undefined &&\n s.keyword === undefined && s.inscode === undefined &&\n s.resname === undefined && s.sstruc === undefined &&\n s.resno === undefined && s.chainname === undefined &&\n s.model === undefined\n ) return -1\n\n if (s.keyword !== undefined) {\n if (s.keyword === kwd.BACKBONE && !a.isBackbone()) return false\n if (s.keyword === kwd.SIDECHAIN && !a.isSidechain()) return false\n if (s.keyword === kwd.BONDED && !a.isBonded()) return false\n if (s.keyword === kwd.RING && !a.isRing()) return false\n if (s.keyword === kwd.AROMATICRING && !a.isAromatic()) return false\n\n if (s.keyword === kwd.HETERO && !a.isHetero()) return false\n if (s.keyword === kwd.PROTEIN && !a.isProtein()) return false\n if (s.keyword === kwd.NUCLEIC && !a.isNucleic()) return false\n if (s.keyword === kwd.RNA && !a.isRna()) return false\n if (s.keyword === kwd.DNA && !a.isDna()) return false\n if (s.keyword === kwd.POLYMER && !a.isPolymer()) return false\n if (s.keyword === kwd.WATER && !a.isWater()) return false\n if (s.keyword === kwd.HELIX && !a.isHelix()) return false\n if (s.keyword === kwd.SHEET && !a.isSheet()) return false\n if (s.keyword === kwd.TURN && !a.isTurn()) return false\n if (s.keyword === kwd.ION && !a.isIon()) return false\n if (s.keyword === kwd.SACCHARIDE && !a.isSaccharide()) return false\n if (s.keyword === kwd.METAL && !a.isMetal()) return false\n if (s.keyword === kwd.POLARH && !a.isPolarHydrogen()) return false\n }\n\n if (s.atomname !== undefined && s.atomname !== a.atomname) return false\n if (s.element !== undefined && s.element !== a.element) return false\n if (s.altloc !== undefined && s.altloc !== a.altloc) return false\n\n if (s.atomindex !== undefined &&\n binarySearchIndexOf(s.atomindex, a.index) < 0\n ) return false\n\n if (s.resname !== undefined) {\n if (Array.isArray(s.resname)) {\n if (!s.resname.includes(a.resname)) return false\n } else {\n if (s.resname !== a.resname) return false\n }\n }\n if (s.sstruc !== undefined && s.sstruc !== a.sstruc) return false\n if (s.resno !== undefined) {\n if (Array.isArray(s.resno) && s.resno.length === 2) {\n if (s.resno[0] > a.resno || s.resno[1] < a.resno) return false\n } else {\n if (s.resno !== a.resno) return false\n }\n }\n if (s.inscode !== undefined && s.inscode !== a.inscode) return false\n\n if (s.chainname !== undefined && s.chainname !== a.chainname) return false\n if (s.model !== undefined && s.model !== a.modelIndex) return false\n\n return true\n}\n\nfunction residueTestFn (r: ResidueProxy, s: SelectionRule) {\n // returning -1 means the rule is not applicable\n if (s.resname === undefined && s.resno === undefined && s.inscode === undefined &&\n s.sstruc === undefined && s.model === undefined && s.chainname === undefined &&\n s.atomindex === undefined &&\n (s.keyword === undefined || AtomOnlyKeywords.includes(s.keyword))\n ) return -1\n\n if (s.keyword !== undefined) {\n if (s.keyword === kwd.HETERO && !r.isHetero()) return false\n if (s.keyword === kwd.PROTEIN && !r.isProtein()) return false\n if (s.keyword === kwd.NUCLEIC && !r.isNucleic()) return false\n if (s.keyword === kwd.RNA && !r.isRna()) return false\n if (s.keyword === kwd.DNA && !r.isDna()) return false\n if (s.keyword === kwd.POLYMER && !r.isPolymer()) return false\n if (s.keyword === kwd.WATER && !r.isWater()) return false\n if (s.keyword === kwd.HELIX && !r.isHelix()) return false\n if (s.keyword === kwd.SHEET && !r.isSheet()) return false\n if (s.keyword === kwd.TURN && !r.isTurn()) return false\n if (s.keyword === kwd.ION && !r.isIon()) return false\n if (s.keyword === kwd.SACCHARIDE && !r.isSaccharide()) return false\n }\n\n if (s.atomindex !== undefined &&\n rangeInSortedArray(s.atomindex, r.atomOffset, r.atomEnd) === 0\n ) return false\n\n if (s.resname !== undefined) {\n if (Array.isArray(s.resname)) {\n if (!s.resname.includes(r.resname)) return false\n } else {\n if (s.resname !== r.resname) return false\n }\n }\n if (s.sstruc !== undefined && s.sstruc !== r.sstruc) return false\n if (s.resno !== undefined) {\n if (Array.isArray(s.resno) && s.resno.length === 2) {\n if (s.resno[0] > r.resno || s.resno[1] < r.resno) return false\n } else {\n if (s.resno !== r.resno) return false\n }\n }\n if (s.inscode !== undefined && s.inscode !== r.inscode) return false\n\n if (s.chainname !== undefined && s.chainname !== r.chainname) return false\n if (s.model !== undefined && s.model !== r.modelIndex) return false\n\n return true\n}\n\nfunction chainTestFn (c: ChainProxy, s: SelectionRule) {\n // returning -1 means the rule is not applicable\n if (s.chainname === undefined && s.model === undefined && s.atomindex === undefined &&\n (s.keyword === undefined || !ChainKeywords.includes(s.keyword) || !c.entity)\n ) return -1\n\n if (s.keyword !== undefined) {\n if (s.keyword === kwd.POLYMER && !c.entity.isPolymer()) return false\n if (s.keyword === kwd.WATER && !c.entity.isWater()) return false\n }\n\n if (s.atomindex !== undefined &&\n rangeInSortedArray(s.atomindex, c.atomOffset, c.atomEnd) === 0\n ) return false\n\n if (s.chainname !== undefined && s.chainname !== c.chainname) return false\n\n if (s.model !== undefined && s.model !== c.modelIndex) return false\n\n return true\n}\n\nfunction modelTestFn (m: ModelProxy, s: SelectionRule) {\n // returning -1 means the rule is not applicable\n if (s.model === undefined && s.atomindex === undefined) return -1\n\n if (s.atomindex !== undefined &&\n rangeInSortedArray(s.atomindex, m.atomOffset, m.atomEnd) === 0\n ) return false\n\n if (s.model !== undefined && s.model !== m.index) return false\n\n return true\n}\n\nfunction makeTest (selection: SelectionRule|null, fn: TestEntityFn) {\n if (selection === null) return false\n if (selection.error) return false\n if (!selection.rules || selection.rules.length === 0) return false\n\n const n = selection.rules.length\n\n const t = !selection.negate\n const f = !!selection.negate\n\n const subTests: SelectionTest[] = []\n for (let i = 0; i < n; ++i) {\n const s = selection.rules[ i ]\n if (s.hasOwnProperty('operator')) {\n subTests[ i ] = makeTest(s, fn) as SelectionTest // TODO\n }\n }\n\n // ( x and y ) can short circuit on false\n // ( x or y ) can short circuit on true\n // not ( x and y )\n\n return function test (entity: ProxyEntity) {\n const and = selection.operator === 'AND'\n let na = false\n\n for (let i = 0; i < n; ++i) {\n const s = selection.rules![ i ] // TODO\n let ret\n\n if (s.hasOwnProperty('operator')) {\n const test = subTests[ i ]\n if (test !== false) {\n ret = test(entity)\n } else {\n ret = -1\n }\n\n if (ret === -1) {\n na = true\n continue\n } else if (ret === true) {\n if (and) { continue } else { return t }\n } else {\n if (and) { return f } else { continue }\n }\n } else {\n if (s.keyword === kwd.ALL) {\n if (and) { continue } else { return t }\n } else if (s.keyword === kwd.NONE) {\n if (and) { continue } else { return f }\n }\n\n ret = fn(entity, s)\n\n // console.log( entity.qualifiedName(), ret, s, selection.negate, \"t\", t, \"f\", f )\n\n if (ret === -1) {\n na = true\n continue\n } else if (ret === true) {\n if (and) { continue } else { return t }\n } else {\n if (and) { return f } else { continue }\n }\n }\n }\n\n if (na) {\n return -1\n } else {\n if (and) { return t } else { return f }\n }\n } as SelectionTest\n}\n\nfunction filter (selection: SelectionRule, fn: FilterFn) {\n if (selection.error) return selection\n if (!selection.rules || selection.rules.length === 0) return selection\n\n const n = selection.rules.length\n\n const filtered: SelectionRule = {\n operator: selection.operator,\n rules: []\n }\n if (selection.hasOwnProperty('negate')) {\n filtered.negate = selection.negate\n }\n\n for (let i = 0; i < n; ++i) {\n const s = selection.rules[ i ]\n if (s.hasOwnProperty('operator')) {\n const fs = filter(s, fn)\n if (fs !== null) filtered.rules!.push(fs) // TODO\n } else if (!fn(s)) {\n filtered.rules!.push(s) // TODO\n }\n }\n\n if (filtered.rules!.length > 0) { // TODO\n // TODO maybe the filtered rules could be returned\n // in some case, but the way how tests are applied\n // e.g. when traversing a structure would also need\n // to change\n return selection\n // return filtered;\n } else {\n return null\n }\n}\n\nfunction makeAtomTest (selection: SelectionRule, atomOnly = false) {\n let filteredSelection: SelectionRule|null = selection\n if (atomOnly) {\n filteredSelection = filter(selection, function (s) {\n if (s.keyword !== undefined && !AtomOnlyKeywords.includes(s.keyword)) return true\n if (s.model !== undefined) return true\n if (s.chainname !== undefined) return true\n if (s.resname !== undefined) return true\n if (s.resno !== undefined) return true\n if (s.sstruc !== undefined) return true\n return false\n })\n }\n return makeTest(filteredSelection, atomTestFn)\n}\n\nfunction makeResidueTest (selection: SelectionRule, residueOnly = false) {\n let filteredSelection: SelectionRule|null = selection\n if (residueOnly) {\n filteredSelection = filter(selection, function (s) {\n if (s.keyword !== undefined && AtomOnlyKeywords.includes(s.keyword)) return true\n if (s.model !== undefined) return true\n if (s.chainname !== undefined) return true\n if (s.atomname !== undefined) return true\n if (s.element !== undefined) return true\n if (s.altloc !== undefined) return true\n return false\n })\n }\n return makeTest(filteredSelection, residueTestFn)\n}\n\nfunction makeChainTest (selection: SelectionRule, chainOnly = false) {\n let filteredSelection: SelectionRule|null = selection\n if (chainOnly) {\n filteredSelection = filter(selection, function (s) {\n if (s.keyword !== undefined && !ChainKeywords.includes(s.keyword)) return true\n // if( s.model!==undefined ) return true;\n if (s.resname !== undefined) return true\n if (s.resno !== undefined) return true\n if (s.atomname !== undefined) return true\n if (s.element !== undefined) return true\n if (s.altloc !== undefined) return true\n if (s.sstruc !== undefined) return true\n if (s.inscode !== undefined) return true\n return false\n })\n }\n return makeTest(filteredSelection, chainTestFn)\n}\n\nfunction makeModelTest (selection: SelectionRule, modelOnly = false) {\n let filteredSelection: SelectionRule|null = selection\n if (modelOnly) {\n filteredSelection = filter(selection, function (s) {\n if (s.keyword !== undefined) return true\n if (s.chainname !== undefined) return true\n if (s.resname !== undefined) return true\n if (s.resno !== undefined) return true\n if (s.atomname !== undefined) return true\n if (s.element !== undefined) return true\n if (s.altloc !== undefined) return true\n if (s.sstruc !== undefined) return true\n if (s.inscode !== undefined) return true\n return false\n })\n }\n return makeTest(filteredSelection, modelTestFn)\n}\n\nexport {\n makeAtomTest,\n makeResidueTest,\n makeChainTest,\n makeModelTest\n}\n","/**\n * @file Selection\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { parseSele } from './selection-parser'\nimport {\n SelectionTest, SelectionRule,\n makeAtomTest, makeResidueTest, makeChainTest, makeModelTest\n} from './selection-test'\nimport { SelectAllKeyword, SelectNoneKeyword } from './selection-constants'\n\nexport type SelectionSignals = {\n stringChanged: Signal\n}\n\n/**\n * Selection\n */\nclass Selection {\n signals: SelectionSignals\n string: string\n selection: SelectionRule\n\n test: SelectionTest\n residueTest: SelectionTest\n chainTest: SelectionTest\n modelTest: SelectionTest\n\n atomOnlyTest: SelectionTest\n residueOnlyTest: SelectionTest\n chainOnlyTest: SelectionTest\n modelOnlyTest: SelectionTest\n\n /**\n * Create Selection\n * @param {String} string - selection string, see {@tutorial selection-language}\n */\n constructor (string?: string) {\n this.signals = {\n stringChanged: new Signal()\n }\n\n this.setString(string)\n }\n\n get type () { return 'selection' }\n\n setString (string?: string, silent?: boolean) {\n if (string === undefined) string = this.string || ''\n if (string === this.string) return\n\n try {\n this.selection = parseSele(string)\n } catch (e) {\n // Log.error( e.stack );\n this.selection = { 'error': e.message }\n }\n const selection = this.selection\n\n this.string = string\n\n this.test = makeAtomTest(selection)\n this.residueTest = makeResidueTest(selection)\n this.chainTest = makeChainTest(selection)\n this.modelTest = makeModelTest(selection)\n\n this.atomOnlyTest = makeAtomTest(selection, true)\n this.residueOnlyTest = makeResidueTest(selection, true)\n this.chainOnlyTest = makeChainTest(selection, true)\n this.modelOnlyTest = makeModelTest(selection, true)\n\n if (!silent) {\n this.signals.stringChanged.dispatch(this.string)\n }\n }\n\n isAllSelection () {\n return SelectAllKeyword.includes(this.string.toUpperCase())\n }\n\n isNoneSelection () {\n return SelectNoneKeyword.includes(this.string.toUpperCase())\n }\n}\n\nexport default Selection\n","/**\n * @file Selection Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { SelectionRule, SelectionOperator } from './selection-test'\nimport {\n kwd, SelectAllKeyword,\n SmallResname, NucleophilicResname, HydrophobicResname, AromaticResname,\n AmideResname, AcidicResname, BasicResname, ChargedResname,\n PolarResname, NonpolarResname, CyclicResname, AliphaticResname\n} from './selection-constants'\n\nfunction parseSele (string: string) {\n let retSelection: SelectionRule = {\n operator: undefined,\n rules: []\n }\n\n if (!string) {\n return retSelection\n }\n\n let selection = retSelection\n let newSelection: SelectionRule\n let oldSelection: SelectionRule\n const selectionStack: SelectionRule[] = []\n\n string = string.replace(/\\(/g, ' ( ').replace(/\\)/g, ' ) ').trim()\n if (string.charAt(0) === '(' && string.substr(-1) === ')') {\n string = string.slice(1, -1).trim()\n }\n const chunks = string.split(/\\s+/)\n\n // Log.log( string, chunks )\n\n const createNewContext = (operator?: SelectionOperator) => {\n newSelection = {\n operator,\n rules: []\n }\n if (selection === undefined) {\n selection = newSelection\n retSelection = newSelection\n } else {\n selection.rules!.push(newSelection)\n selectionStack.push(selection)\n selection = newSelection\n }\n }\n\n const getPrevContext = function (operator?: SelectionOperator) {\n oldSelection = selection\n selection = selectionStack.pop()!\n if (selection === undefined) {\n createNewContext(operator)\n pushRule(oldSelection)\n }\n }\n\n const pushRule = function (rule: SelectionRule) {\n selection.rules!.push(rule)\n }\n\n let not: false|0|1|2 = false\n\n for (let i = 0; i < chunks.length; ++i) {\n const c = chunks[ i ]\n const cu = c.toUpperCase()\n\n // handle parens\n\n if (c === '(') {\n // Log.log( \"(\" );\n not = false\n createNewContext()\n continue\n } else if (c === ')') {\n // Log.log( \")\" );\n getPrevContext()\n if (selection.negate) {\n getPrevContext()\n }\n continue\n }\n\n // leave 'not' context\n\n if (not > 0) {\n if (cu === 'NOT') {\n not = 1\n } else if (not === 1) {\n not = 2\n } else if (not === 2) {\n not = false\n getPrevContext()\n } else {\n throw new Error(\"something went wrong with 'not'\")\n }\n }\n\n // handle logic operators\n\n if (cu === 'AND') {\n // Log.log( \"AND\" );\n if (selection.operator === 'OR') {\n const lastRule = selection.rules!.pop()!\n createNewContext('AND')\n pushRule(lastRule)\n } else {\n selection.operator = 'AND'\n }\n continue\n } else if (cu === 'OR') {\n // Log.log( \"OR\" );\n if (selection.operator === 'AND') {\n getPrevContext('OR')\n } else {\n selection.operator = 'OR'\n }\n continue\n } else if (c.toUpperCase() === 'NOT') {\n // Log.log( \"NOT\", j );\n not = 1\n createNewContext()\n selection.negate = true\n continue\n } else {\n // Log.log( \"chunk\", c, j, selection );\n }\n\n // handle keyword attributes\n\n // ensure `cu` is not a number before testing if it is in the\n // kwd enum dictionary which includes the enum numbers as well...\n if (+cu !== +cu) {\n const keyword = (kwd as any)[ cu ]\n if (keyword !== undefined) {\n pushRule({ keyword })\n continue\n }\n }\n\n if (cu === 'HYDROGEN') {\n pushRule({\n operator: 'OR',\n rules: [\n { element: 'H' },\n { element: 'D' }\n ]\n })\n continue\n }\n\n if (cu === 'SMALL') {\n pushRule({ resname: SmallResname })\n continue\n }\n\n if (cu === 'NUCLEOPHILIC') {\n pushRule({ resname: NucleophilicResname })\n continue\n }\n\n if (cu === 'HYDROPHOBIC') {\n pushRule({ resname: HydrophobicResname })\n continue\n }\n\n if (cu === 'AROMATIC') {\n pushRule({ resname: AromaticResname })\n continue\n }\n\n if (cu === 'AMIDE') {\n pushRule({ resname: AmideResname })\n continue\n }\n\n if (cu === 'ACIDIC') {\n pushRule({ resname: AcidicResname })\n continue\n }\n\n if (cu === 'BASIC') {\n pushRule({ resname: BasicResname })\n continue\n }\n\n if (cu === 'CHARGED') {\n pushRule({ resname: ChargedResname })\n continue\n }\n\n if (cu === 'POLAR') {\n pushRule({ resname: PolarResname })\n continue\n }\n\n if (cu === 'NONPOLAR') {\n pushRule({ resname: NonpolarResname })\n continue\n }\n\n if (cu === 'CYCLIC') {\n pushRule({ resname: CyclicResname })\n continue\n }\n\n if (cu === 'ALIPHATIC') {\n pushRule({ resname: AliphaticResname })\n continue\n }\n\n if (cu === 'SIDECHAINATTACHED') {\n pushRule({\n operator: 'OR',\n rules: [\n { keyword: kwd.SIDECHAIN },\n {\n operator: 'AND',\n negate: false,\n rules: [\n { keyword: kwd.PROTEIN },\n {\n operator: 'OR',\n negate: false,\n rules: [\n { atomname: 'CA' },\n { atomname: 'BB' }\n ]\n }\n ]\n },\n {\n operator: 'AND',\n negate: false,\n rules: [\n { resname: 'PRO' },\n { atomname: 'N' }\n ]\n },\n {\n operator: 'AND',\n negate: false,\n rules: [\n { keyword: kwd.NUCLEIC },\n {\n operator: 'OR',\n negate: true,\n rules: [\n { atomname: 'P' },\n { atomname: 'OP1' },\n { atomname: 'OP2' },\n { atomname: \"O3'\" },\n { atomname: 'O3*' },\n { atomname: \"HO3'\"},\n { atomname: \"O5'\" },\n { atomname: 'O5*' },\n { atomname: \"HO5'\"},\n { atomname: \"C5'\" },\n { atomname: 'C5*' },\n { atomname: \"H5'\" },\n { atomname: \"H5''\"}\n ]\n }\n ]\n }\n ]\n })\n continue\n }\n\n if (cu === 'APOLARH') {\n pushRule({\n operator: 'AND',\n negate: false,\n rules: [\n { element: 'H' },\n {\n negate: true,\n operator: undefined,\n rules: [\n { keyword: kwd.POLARH }\n ]\n }\n ]\n })\n continue\n }\n\n if (cu === 'LIGAND') {\n pushRule({\n operator: 'AND',\n rules: [\n {\n operator: 'OR',\n rules: [\n {\n operator: 'AND',\n rules: [\n { keyword: kwd.HETERO },\n {\n negate: true,\n operator: undefined,\n rules: [\n { keyword: kwd.POLYMER }\n ]\n }\n ]\n },\n {\n negate: true,\n operator: undefined,\n rules: [\n { keyword: kwd.POLYMER }\n ]\n }\n ]\n },\n {\n negate: true,\n operator: undefined,\n rules: [\n {\n operator: 'OR',\n rules: [\n { keyword: kwd.WATER },\n { keyword: kwd.ION }\n ]\n }\n ]\n }\n ]\n })\n continue\n }\n\n if (SelectAllKeyword.indexOf(cu) !== -1) {\n pushRule({ keyword: kwd.ALL })\n continue\n }\n\n // handle atom expressions\n\n if (c.charAt(0) === '@') {\n const indexList = c.substr(1).split(',').map(x => parseInt(x))\n indexList.sort(function (a, b) { return a - b })\n pushRule({ atomindex: indexList })\n continue\n }\n\n if (c.charAt(0) === '#') {\n console.error('# for element selection deprecated, use _')\n pushRule({ element: cu.substr(1) })\n continue\n }\n if (c.charAt(0) === '_') {\n pushRule({ element: cu.substr(1) })\n continue\n }\n\n if (c[0] === '[' && c[c.length - 1] === ']') {\n const resnameList = cu.substr(1, c.length - 2).split(',')\n const resname = resnameList.length > 1 ? resnameList : resnameList[ 0 ]\n pushRule({ resname: resname })\n continue\n } else if (\n (c.length >= 1 && c.length <= 4) &&\n c[0] !== '^' && c[0] !== ':' && c[0] !== '.' && c[0] !== '%' && c[0] !== '/' &&\n isNaN(parseInt(c))\n ) {\n pushRule({ resname: cu })\n continue\n }\n\n // there must be only one constraint per rule\n // otherwise a test quickly becomes not applicable\n // e.g. chainTest for chainname when resno is present too\n\n const sele: SelectionRule = {\n operator: 'AND',\n rules: []\n }\n\n const model = c.split('/')\n if (model.length > 1 && model[1]) {\n if (isNaN(parseInt(model[1]))) {\n throw new Error('model must be an integer')\n }\n sele.rules!.push({\n model: parseInt(model[1])\n })\n }\n\n const altloc = model[0].split('%')\n if (altloc.length > 1) {\n sele.rules!.push({\n altloc: altloc[1]\n })\n }\n\n const atomname = altloc[0].split('.')\n if (atomname.length > 1 && atomname[1]) {\n if (atomname[1].length > 4) {\n throw new Error('atomname must be one to four characters')\n }\n sele.rules!.push({\n atomname: atomname[1].substring(0, 4).toUpperCase()\n })\n }\n\n const chain = atomname[0].split(':')\n if (chain.length > 1 && chain[1]) {\n sele.rules!.push({\n chainname: chain[1]\n })\n }\n\n const inscode = chain[0].split('^')\n if (inscode.length > 1) {\n sele.rules!.push({\n inscode: inscode[1]\n })\n }\n\n if (inscode[0]) {\n let negate, negate2\n if (inscode[0][0] === '-') {\n inscode[0] = inscode[0].substr(1)\n negate = true\n }\n if (inscode[0].includes('--')) {\n inscode[0] = inscode[0].replace('--', '-')\n negate2 = true\n }\n let resi = inscode[0].split('-')\n if (resi.length === 1) {\n let resiSingle = parseInt(resi[0])\n if (isNaN(resiSingle)) {\n throw new Error('resi must be an integer')\n }\n if (negate) resiSingle *= -1\n sele.rules!.push({\n resno: resiSingle\n })\n } else if (resi.length === 2) {\n const resiRange = resi.map(x => parseInt(x))\n if (negate) resiRange[0] *= -1\n if (negate2) resiRange[1] *= -1\n sele.rules!.push({\n resno: [resiRange[0], resiRange[1]]\n })\n } else {\n throw new Error(\"resi range must contain one '-'\")\n }\n }\n\n // round up\n\n if (sele.rules!.length === 1) {\n pushRule(sele.rules![ 0 ])\n } else if (sele.rules!.length > 1) {\n pushRule(sele)\n } else {\n throw new Error('empty selection chunk')\n }\n }\n\n // cleanup\n\n if (\n retSelection.operator === undefined &&\n retSelection.rules!.length === 1 &&\n retSelection.rules![ 0 ].hasOwnProperty('operator')\n ) {\n retSelection = retSelection.rules![ 0 ]\n }\n\n return retSelection\n}\n\nexport {\n parseSele\n}\n","/**\n * @file Selection Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { Color } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport Selection from '../selection/selection'\nimport Colormaker, { ColormakerParameters } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Structure from '../structure/structure'\n\nexport type SelectionSchemeData = [ string, string, ColormakerParameters|undefined ]\n\n/**\n * Color based on {@link Selection}\n */\nclass SelectionColormaker extends Colormaker {\n colormakerList: any[] = [] // TODO\n selectionList: Selection[] = []\n\n constructor (params: { structure: Structure, dataList: SelectionSchemeData[] } & Partial) {\n super(params)\n\n const dataList = params.dataList || []\n\n dataList.forEach((data: SelectionSchemeData) => {\n const [ scheme, sele, params = {} ] = data\n\n if (ColormakerRegistry.hasScheme(scheme)) {\n Object.assign(params, {\n scheme: scheme,\n structure: this.parameters.structure\n })\n } else {\n Object.assign(params, {\n scheme: 'uniform',\n value: new Color(scheme).getHex()\n })\n }\n\n this.colormakerList.push(ColormakerRegistry.getScheme(params as { scheme: string } & ColormakerParameters))\n this.selectionList.push(new Selection(sele))\n })\n }\n\n // NOT NEEDED @manageColor\n atomColor (a: AtomProxy) {\n for (let i = 0, n = this.selectionList.length; i < n; ++i) {\n const test = this.selectionList[ i ].test\n if (test && test(a)) {\n return this.colormakerList[ i ].atomColor(a)\n }\n }\n\n return 0xFFFFFF\n }\n}\n\nexport default SelectionColormaker\n","/**\n * @file Colormaker Registry\n * @author Alexander Rose \n * @private\n */\n\nimport { generateUUID } from '../math/math-utils'\nimport Colormaker, { ColormakerParameters } from './colormaker'\nimport SelectionColormaker, { SelectionSchemeData } from './selection-colormaker'\nimport Structure from '../structure/structure'\n\nconst ColormakerScales = {\n '': '',\n\n // Sequential\n OrRd: '[S] Orange-Red',\n PuBu: '[S] Purple-Blue',\n BuPu: '[S] Blue-Purple',\n Oranges: '[S] Oranges',\n BuGn: '[S] Blue-Green',\n YlOrBr: '[S] Yellow-Orange-Brown',\n YlGn: '[S] Yellow-Green',\n Reds: '[S] Reds',\n RdPu: '[S] Red-Purple',\n Greens: '[S] Greens',\n YlGnBu: '[S] Yellow-Green-Blue',\n Purples: '[S] Purples',\n GnBu: '[S] Green-Blue',\n Greys: '[S] Greys',\n YlOrRd: '[S] Yellow-Orange-Red',\n PuRd: '[S] Purple-Red',\n Blues: '[S] Blues',\n PuBuGn: '[S] Purple-Blue-Green',\n\n // Diverging\n Viridis: '[D] Viridis',\n Spectral: '[D] Spectral',\n RdYlGn: '[D] Red-Yellow-Green',\n RdBu: '[D] Red-Blue',\n PiYG: '[D] Pink-Yellowgreen',\n PRGn: '[D] Purplered-Green',\n RdYlBu: '[D] Red-Yellow-Blue',\n BrBG: '[D] Brown-Bluegreen',\n RdGy: '[D] Red-Grey',\n PuOr: '[D] Purple-Orange',\n\n // Qualitative\n Set1: '[Q] Set1',\n Set2: '[Q] Set2',\n Set3: '[Q] Set3',\n Dark2: '[Q] Dark2',\n Paired: '[Q] Paired',\n Pastel1: '[Q] Pastel1',\n Pastel2: '[Q] Pastel2',\n Accent: '[Q] Accent',\n\n // Other\n rainbow: '[?] Rainbow',\n rwb: '[?] Red-White-Blue'\n}\n\nconst ColormakerModes = {\n '': '',\n\n rgb: 'Red Green Blue',\n hsv: 'Hue Saturation Value',\n hsl: 'Hue Saturation Lightness',\n hsi: 'Hue Saturation Intensity',\n lab: 'CIE L*a*b*',\n hcl: 'Hue Chroma Lightness'\n}\n\n/**\n * Class for registering {@link Colormaker}s. Generally use the\n * global {@link src/globals.js~ColormakerRegistry} instance.\n */\nclass ColormakerRegistry {\n schemes: { [k: string]: any }\n userSchemes: { [k: string]: any }\n\n constructor () {\n this.schemes = {}\n this.userSchemes = {}\n }\n\n getScheme (params: Partial<{ scheme: string } & ColormakerParameters>) {\n const p = params || {}\n const id = (p.scheme || '').toLowerCase()\n\n let SchemeClass\n\n if (id in this.schemes) {\n SchemeClass = this.schemes[ id ]\n } else if (id in this.userSchemes) {\n SchemeClass = this.userSchemes[ id ]\n } else {\n SchemeClass = Colormaker\n }\n\n return new SchemeClass(params)\n }\n\n /**\n * Get an description of available schemes as an\n * object with id-label as key-value pairs\n * @return {Object} available schemes\n */\n getSchemes () {\n const types: { [k: string]: any } = {}\n\n Object.keys(this.schemes).forEach(function (k) {\n types[ k ] = k\n })\n\n Object.keys(this.userSchemes).forEach(function (k) {\n types[ k ] = k.split('|')[ 1 ]\n })\n\n return types\n }\n\n /**\n * Get an description of available scales as an\n * object with id-label as key-value pairs\n * @return {Object} available scales\n */\n getScales () {\n return ColormakerScales\n }\n\n getModes () {\n return ColormakerModes\n }\n\n /**\n * Add a scheme with a hardcoded id\n * @param {String} id - the id\n * @param {Colormaker} scheme - the colormaker\n * @return {undefined}\n */\n add (id: string, scheme: typeof Colormaker) {\n id = id.toLowerCase()\n this.schemes[ id ] = scheme\n }\n\n /**\n * Register a custom scheme\n *\n * @example\n * // Create a class with a `atomColor` method that returns a hex color.\n * var schemeId = NGL.ColormakerRegistry.addScheme( function( params ){\n * this.atomColor = function( atom ){\n * if( atom.serial < 1000 ){\n * return 0x0000FF; // blue\n * }else if( atom.serial > 2000 ){\n * return 0xFF0000; // red\n * }else{\n * return 0x00FF00; // green\n * }\n * };\n * } );\n *\n * stage.loadFile( \"rcsb://3dqb.pdb\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\", { color: schemeId } ); // pass schemeId here\n * o.autoView();\n * } );\n *\n * @param {Function|Colormaker} scheme - constructor or {@link Colormaker} instance\n * @param {String} label - scheme label\n * @return {String} id to refer to the registered scheme\n */\n addScheme (scheme: any, label?: string) {\n if (!(scheme instanceof Colormaker)) {\n scheme = this._createScheme(scheme)\n }\n\n return this._addUserScheme(scheme, label)\n }\n\n /**\n * Add a user-defined scheme\n * @param {Colormaker} scheme - the user-defined scheme\n * @param {String} [label] - scheme label\n * @return {String} id to refer to the registered scheme\n */\n _addUserScheme (scheme: any, label?: string) {\n label = label || ''\n const id = `${generateUUID()}|${label}`.toLowerCase()\n this.userSchemes[ id ] = scheme\n\n return id\n }\n\n /**\n * Remove the scheme with the given id\n * @param {String} id - scheme to remove\n * @return {undefined}\n */\n removeScheme (id: string) {\n id = id.toLowerCase()\n delete this.userSchemes[ id ]\n }\n\n _createScheme (constructor: any) {\n const _Colormaker = function (this: any, params: ColormakerParameters) {\n Colormaker.call(this, params)\n constructor.call(this, params)\n }\n\n _Colormaker.prototype = Colormaker.prototype\n _Colormaker.prototype.constructor = Colormaker\n\n return _Colormaker\n }\n\n /**\n * Create and a selection-based coloring scheme. Supply a list with pairs\n * of colorname and selection for coloring by selections. Use the last\n * entry as a default (catch all) coloring definition.\n *\n * @example\n * var schemeId = NGL.ColormakerRegistry.addSelectionScheme( [\n * [ \"red\", \"64-74 or 134-154 or 222-254 or 310-310 or 322-326\" ],\n * [ \"green\", \"311-322\" ],\n * [ \"yellow\", \"40-63 or 75-95 or 112-133 or 155-173 or 202-221 or 255-277 or 289-309\" ],\n * [ \"blue\", \"1-39 or 96-112 or 174-201 or 278-288\" ],\n * [ \"white\", \"*\" ]\n * ], \"Transmembrane 3dqb\" );\n *\n * stage.loadFile( \"rcsb://3dqb.pdb\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\", { color: schemeId } ); // pass schemeId here\n * o.autoView();\n * } );\n *\n * @param {Array} dataList - cloror-selection pairs\n * @param {String} label - scheme name\n * @return {String} id to refer to the registered scheme\n */\n addSelectionScheme (dataList: SelectionSchemeData[], label?: string) {\n class MySelectionColormaker extends SelectionColormaker {\n constructor (params: { structure: Structure } & ColormakerParameters) {\n super(Object.assign({ dataList }, params))\n }\n }\n\n return this._addUserScheme(MySelectionColormaker, label)\n }\n\n /**\n * Check if a scheme with the given id exists\n * @param {String} id - the id to check\n * @return {Boolean} flag indicating if the scheme exists\n */\n hasScheme (id: string) {\n id = id.toLowerCase()\n return id in this.schemes || id in this.userSchemes\n }\n}\n\nexport default ColormakerRegistry\n","/**\n * @file Worker Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { uniqueArray } from '../utils'\n\nexport type FunctionWithDeps = { __deps?: Function[] } & Function\nexport interface WorkerEvent {\n data: {\n __name: string\n __postId: string\n }\n}\n\nfunction getWorkerDeps (vars: FunctionWithDeps[]) {\n const deps = vars\n vars.forEach(function (sym) {\n if (sym.__deps) {\n Array.prototype.push.apply(deps, getWorkerDeps(sym.__deps))\n }\n })\n return deps\n}\n\nfunction makeWorkerString (vars: any) {\n const deps = uniqueArray(getWorkerDeps(vars))\n return deps.map(function (sym) {\n return sym.toString()\n }).join('\\n\\n\\n')\n}\n\nfunction onmessage (e: WorkerEvent) {\n const name = e.data.__name\n const postId = e.data.__postId\n\n /* global self */\n if (name === undefined) {\n console.error('message __name undefined')\n } else if ((self as any).func === undefined) {\n console.error('worker func undefined', name)\n } else {\n const callback = function (aMessage: any, transferList: any[]) {\n aMessage = aMessage || {}\n if (postId !== undefined) aMessage.__postId = postId\n\n try {\n (self as any).postMessage(aMessage, transferList)\n } catch (error) {\n console.error('self.postMessage:', error);\n (self as any).postMessage(aMessage)\n }\n };\n (self as any).func(e, callback)\n }\n}\n\nexport function makeWorkerBlob (func: Function, deps: Function[]) {\n let str = \"'use strict';\\n\\n\" + makeWorkerString(deps)\n str += '\\n\\n\\nself.func = ' + func.toString() + ';'\n str += '\\n\\n\\nself.onmessage = ' + onmessage.toString() + ';'\n // console.log(str);\n return new Blob([ str ], { type: 'application/javascript' })\n}\n","/**\n * @file Globals\n * @author Alexander Rose \n * @private\n */\n\nimport { getBrowser, getQuery, boolean } from './utils'\nimport Registry from './utils/registry'\nimport _ColormakerRegistry from './color/colormaker-registry'\nimport _ParserRegistry from './parser/parser-registry'\nimport _WorkerRegistry from './worker/worker-registry'\nimport { MeasurementRepresentationParameters } from './representation/measurement-representation';\n\n/**\n * The browser name: \"Opera\", \"Chrome\", \"Firefox\", \"Mobile Safari\",\n * \"Internet Explorer\", \"Safari\" or false.\n */\nexport const Browser = getBrowser()\n\n/**\n * Flag indicating support for the 'passive' option for event handler\n */\nexport let SupportsPassiveEventHandler = false\ntry {\n // Test via a getter in the options object to see if the passive property is accessed\n const opts = Object.defineProperty({}, 'passive', {\n get: function () {\n SupportsPassiveEventHandler = true\n }\n })\n window.addEventListener('test', e => {}, opts)\n} catch (e) {}\n\n/**\n * Flag indicating a mobile browser\n */\nexport const Mobile = typeof window !== 'undefined' ? typeof window.orientation !== 'undefined' : false\n\nexport let SupportsReadPixelsFloat = false\nexport function setSupportsReadPixelsFloat (value: boolean) {\n SupportsReadPixelsFloat = value\n}\n\n/**\n * Flag indicating support for the `EXT_frag_depth` WebGL extension\n * (Always present in WebGL2)\n */\nexport let ExtensionFragDepth = false\nexport function setExtensionFragDepth (value: boolean) {\n ExtensionFragDepth = value\n}\n\nexport const Log = {\n log: Function.prototype.bind.call(console.log, console),\n info: Function.prototype.bind.call(console.info, console),\n warn: Function.prototype.bind.call(console.warn, console),\n error: Function.prototype.bind.call(console.error, console),\n time: Function.prototype.bind.call(console.time, console),\n timeEnd: Function.prototype.bind.call(console.timeEnd, console)\n}\n\nexport let MeasurementDefaultParams: Partial = {\n color: 'green',\n labelColor: 0x808080,\n labelAttachment: 'bottom-center',\n labelSize: 0.7,\n labelZOffset: 0.5,\n labelYOffset: 0.1,\n labelBorder: true,\n labelBorderColor: 0xd3d3d3,\n labelBorderWidth: 0.25,\n lineOpacity: 0.8,\n linewidth: 5.0,\n opacity: 0.6,\n\n labelUnit: 'angstrom',\n arcVisible: true,\n planeVisible: false\n}\nexport function setMeasurementDefaultParams (params = {}) {\n Object.assign(MeasurementDefaultParams, params)\n}\n\nexport let Debug = boolean(getQuery('debug'))\nexport function setDebug (value: boolean) {\n Debug = value\n}\n\nexport const WebglErrorMessage = '

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

Find out how to get it here.

'\n\n/**\n * List of file extensions to be recognized as scripts\n */\nexport const ScriptExtensions = [ 'ngl', 'js' ]\n\nexport const WorkerRegistry = new _WorkerRegistry()\nexport const ColormakerRegistry = new _ColormakerRegistry()\nexport const DatasourceRegistry = new Registry('datasource')\nexport const RepresentationRegistry = new Registry('representatation')\nexport const ParserRegistry = new _ParserRegistry()\nexport const ShaderRegistry = new Registry('shader')\nexport const DecompressorRegistry = new Registry('decompressor')\nexport const ComponentRegistry = new Registry('component')\nexport const BufferRegistry = new Registry('buffer')\nexport const PickerRegistry = new Registry('picker')\n\nexport let ListingDatasource: any\nexport function setListingDatasource (value: any) {\n ListingDatasource = value\n}\n\nexport let TrajectoryDatasource: any // TODO should accept mdsrvDatasource\nexport function setTrajectoryDatasource (value: any) {\n TrajectoryDatasource = value\n}\n","/**\n * @file Worker Registry\n * @author Alexander Rose \n * @private\n */\n\nimport { makeWorkerBlob } from './worker-utils'\n\nclass WorkerRegistry {\n activeWorkerCount = 0\n\n private _funcDict: { [k: string]: Function } = {}\n private _depsDict: { [k: string]: Function[] } = {}\n private _blobDict: { [k: string]: Blob } = {}\n\n add (name: string, func: Function, deps: Function[]) {\n this._funcDict[ name ] = func\n this._depsDict[ name ] = deps\n }\n\n get (name: string) {\n if (!this._blobDict[ name ]) {\n this._blobDict[ name ] = makeWorkerBlob(\n this._funcDict[ name ], this._depsDict[ name ]\n )\n }\n return this._blobDict[ name ]\n }\n}\n\nexport default WorkerRegistry\n","/**\n * @file Parser Registry\n * @author Alexander Rose \n * @private\n */\n\nimport Registry from '../utils/registry'\n\nclass ParserRegistry extends Registry {\n constructor () {\n super('parser')\n }\n\n __hasObjName (key: string, objName: string) {\n const parser = this.get(key)\n return parser && parser.prototype.__objName === objName\n }\n\n isTrajectory (key: string) {\n return this.__hasObjName(key, 'frames')\n }\n\n isStructure (key: string) {\n return this.__hasObjName(key, 'structure')\n }\n\n isVolume (key: string) {\n return this.__hasObjName(key, 'volume')\n }\n\n isSurface (key: string) {\n return this.__hasObjName(key, 'surface')\n }\n\n isBinary (key: string) {\n const parser = this.get(key)\n return parser && parser.prototype.isBinary\n }\n\n isXml (key: string) {\n const parser = this.get(key)\n return parser && parser.prototype.isXml\n }\n\n isJson (key: string) {\n const parser = this.get(key)\n return parser && parser.prototype.isJson\n }\n\n getTrajectoryExtensions () {\n return this.names.filter(name => this.isTrajectory(name))\n }\n\n getStructureExtensions () {\n return this.names.filter(name => this.isStructure(name))\n }\n\n getVolumeExtensions () {\n return this.names.filter(name => this.isVolume(name))\n }\n\n getSurfaceExtensions () {\n return this.names.filter(name => this.isSurface(name))\n }\n}\n\nexport default ParserRegistry\n","/**\n * @file Streamer\n * @author Alexander Rose \n * @private\n */\n\nimport { DecompressorRegistry } from '../globals'\nimport { uint8ToString, defaults } from '../utils'\n\nexport interface StreamerParams {\n compressed?: string|false\n binary?: boolean\n json?: boolean\n xml?: boolean\n}\n\nabstract class Streamer {\n src: any\n data: any\n\n compressed: string|false\n binary: boolean\n json: boolean\n xml: boolean\n\n chunkSize = 1024 * 1024 * 10\n newline = '\\n'\n\n protected __pointer = 0\n protected __partialLine = ''\n\n constructor (src: any, params: StreamerParams = {}) {\n this.compressed = defaults(params.compressed, false)\n this.binary = defaults(params.binary, false)\n this.json = defaults(params.json, false)\n this.xml = defaults(params.xml, false)\n\n this.src = src\n }\n\n isBinary () {\n return this.binary || this.compressed\n }\n\n read () {\n return this._read().then(data => {\n const decompressFn = this.compressed ? DecompressorRegistry.get(this.compressed) : undefined\n\n if (this.compressed && decompressFn) {\n this.data = decompressFn(data)\n } else {\n if ((this.binary || this.compressed) && data instanceof ArrayBuffer) {\n data = new Uint8Array(data)\n }\n this.data = data\n }\n\n return this.data\n })\n }\n\n protected abstract _read (): Promise\n\n protected _chunk (start: number, end: number) {\n end = Math.min(this.data.length, end)\n\n if (start === 0 && this.data.length === end) {\n return this.data\n } else {\n if (this.isBinary()) {\n return this.data.subarray(start, end)\n } else {\n return this.data.substring(start, end)\n }\n }\n }\n\n chunk (start: number) {\n const end = start + this.chunkSize\n\n return this._chunk(start, end)\n }\n\n peekLines (m: number) {\n const data = this.data\n const n = data.length\n\n // FIXME does not work for multi-char newline\n const newline = this.isBinary() ? this.newline.charCodeAt(0) : this.newline\n\n let i\n let count = 0\n for (i = 0; i < n; ++i) {\n if (data[ i ] === newline) ++count\n if (count === m) break\n }\n\n const chunk = this._chunk(0, i + 1)\n const d = this.chunkToLines(chunk, '', i > n)\n\n return d.lines\n }\n\n chunkCount () {\n return Math.floor(this.data.length / this.chunkSize) + 1\n }\n\n asText () {\n return this.isBinary() ? uint8ToString(this.data) : this.data\n }\n\n chunkToLines (chunk: string|Uint8Array, partialLine: string, isLast: boolean) {\n const newline = this.newline\n\n if (!this.isBinary() && chunk.length === this.data.length) {\n return {\n lines: (chunk as string).split(newline),\n partialLine: ''\n }\n }\n\n let lines: string[] = []\n const str = this.isBinary() ? uint8ToString(chunk as Uint8Array) : chunk\n const idx = str.lastIndexOf(newline)\n\n if (idx === -1) {\n partialLine += str\n } else {\n const str2 = partialLine + str.substr(0, idx)\n lines = lines.concat(str2.split(newline))\n\n if (idx === str.length - newline.length) {\n partialLine = ''\n } else {\n partialLine = str.substr(idx + newline.length)\n }\n }\n\n if (isLast && partialLine !== '') {\n lines.push(partialLine)\n }\n\n return {\n lines: lines,\n partialLine: partialLine\n }\n }\n\n nextChunk () {\n const start = this.__pointer\n\n if (start > this.data.length) {\n return undefined\n }\n\n this.__pointer += this.chunkSize\n return this.chunk(start)\n }\n\n nextChunkOfLines () {\n const chunk = this.nextChunk()\n\n if (chunk === undefined) {\n return undefined\n }\n\n const isLast = this.__pointer > this.data.length\n const d = this.chunkToLines(chunk, this.__partialLine, isLast)\n\n this.__partialLine = d.partialLine\n\n return d.lines\n }\n\n eachChunk (callback: (chunk: string|Uint8Array, chunkNo: number, chunkCount: number) => void) {\n const chunkSize = this.chunkSize\n const n = this.data.length\n const chunkCount = this.chunkCount()\n\n for (let i = 0; i < n; i += chunkSize) {\n const chunk = this.chunk(i)\n const chunkNo = Math.round(i / chunkSize)\n\n callback(chunk, chunkNo, chunkCount)\n }\n }\n\n eachChunkOfLines (callback: (chunk: string[], chunkNo: number, chunkCount: number) => void) {\n this.eachChunk((chunk, chunkNo, chunkCount) => {\n const isLast = chunkNo === chunkCount + 1\n const d = this.chunkToLines(chunk, this.__partialLine, isLast)\n\n this.__partialLine = d.partialLine\n\n callback(d.lines, chunkNo, chunkCount)\n })\n }\n\n dispose () {\n delete this.src\n }\n}\n\nexport default Streamer\n","/**\n * @file File Streamer\n * @author Alexander Rose \n * @private\n */\n\nimport Streamer from './streamer'\n\ninterface FileReaderEventTarget extends EventTarget {\n result:string | ArrayBuffer | null\n}\n\ninterface FileReaderEvent extends ProgressEvent {\n target: FileReaderEventTarget | null;\n}\n\nclass FileStreamer extends Streamer {\n _read () {\n return new Promise((resolve, reject) => {\n const file = this.src\n const reader = new FileReader()\n\n reader.onload = (event: FileReaderEvent) => {\n if(event.target) resolve(event.target.result)\n }\n\n // if (typeof this.onprogress === 'function') {\n // reader.onprogress = event => this.onprogress(event)\n // }\n\n reader.onerror = event => reject(event)\n\n if (this.binary || this.compressed) {\n reader.readAsArrayBuffer(file)\n } else {\n reader.readAsText(file)\n }\n })\n }\n}\n\nexport default FileStreamer\n","/**\n * @file Network Streamer\n * @author Alexander Rose \n * @private\n */\n\nimport Streamer from './streamer'\n\nclass NetworkStreamer extends Streamer {\n _read () {\n return new Promise((resolve, reject) => {\n const url = this.src\n const xhr = new XMLHttpRequest()\n\n xhr.open('GET', url, true)\n\n xhr.addEventListener('load', () => {\n if (xhr.status === 200 || xhr.status === 304 ||\n // when requesting from local file system\n // the status in Google Chrome/Chromium is 0\n xhr.status === 0\n ) {\n try {\n resolve(xhr.response)\n } catch (e) {\n reject(e)\n }\n } else {\n reject(xhr.statusText)\n }\n }, false)\n\n // if (typeof this.onprogress === 'function') {\n // xhr.addEventListener('progress', event => this.onprogress(event), false);\n // }\n\n xhr.addEventListener('error', event => reject('network error'), false)\n\n if (this.isBinary()) {\n xhr.responseType = 'arraybuffer'\n } else if (this.json) {\n xhr.responseType = 'json'\n } else if (this.xml) {\n xhr.responseType = 'document'\n } else {\n xhr.responseType = 'text'\n }\n // xhr.crossOrigin = true;\n\n xhr.send()\n })\n }\n}\n\nexport default NetworkStreamer\n","/**\n * @file Loader\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport { createParams } from '../utils'\nimport FileStreamer from '../streamer/file-streamer'\nimport NetworkStreamer from '../streamer/network-streamer'\nimport { LoaderParameters, LoaderInput } from './loader-utils'\n\n/**\n * Loader parameter object.\n * @typedef {Object} LoaderParameters - loader parameters\n * @property {String} ext - file extension, determines file type\n * @property {Boolean} compressed - flag data as compressed\n * @property {Boolean} binary - flag data as binary\n * @property {String} name - set data name\n */\n\n/**\n * Loader base class\n */\nabstract class Loader {\n parameters: LoaderParameters\n streamer: FileStreamer | NetworkStreamer\n\n /**\n * Construct a loader object\n * @param {String|File|Blob} src - data source, string is interpreted as an URL\n * @param {LoaderParameters} params - parameters object\n */\n constructor (src: LoaderInput, params: Partial = {}) {\n this.parameters = createParams(params, {\n ext: '',\n compressed: false,\n binary: ParserRegistry.isBinary(params.ext || ''),\n name: '',\n\n dir: '',\n path: '',\n protocol: ''\n } as LoaderParameters)\n\n const streamerParams = {\n compressed: this.parameters.compressed as string|false,\n binary: this.parameters.binary,\n json: ParserRegistry.isJson(this.parameters.ext),\n xml: ParserRegistry.isXml(this.parameters.ext)\n }\n\n if ((typeof File !== 'undefined' && src instanceof File) ||\n (typeof Blob !== 'undefined' && src instanceof Blob)\n ) {\n this.streamer = new FileStreamer(src, streamerParams)\n } else {\n this.streamer = new NetworkStreamer(src, streamerParams)\n }\n }\n\n /**\n * Load data\n * @abstract\n * @return {Promise} resolves to the loaded data {@link Object}\n */\n abstract load (): Promise\n}\n\nexport default Loader\n","/**\n * @file Parser Loader\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport type { InferBondsOptions } from '../structure/structure-utils'\nimport Loader from './loader'\nimport { LoaderParameters, LoaderInput } from './loader-utils'\n\nexport interface ParserParams {\n voxelSize?: number\n firstModelOnly?: boolean\n asTrajectory?: boolean\n cAlphaOnly?: boolean\n name?: string\n path?: string\n delimiter?: string\n comment?: string\n columnNames?: string\n inferBonds?: InferBondsOptions\n}\n\n/**\n * Parser loader class\n * @extends Loader\n */\nclass ParserLoader extends Loader {\n parserParams: ParserParams\n\n constructor (src: LoaderInput, params: Partial & ParserParams = {}) {\n super(src, params)\n this.parserParams = {\n voxelSize: params.voxelSize,\n firstModelOnly: params.firstModelOnly,\n asTrajectory: params.asTrajectory,\n cAlphaOnly: params.cAlphaOnly,\n delimiter: params.delimiter,\n comment: params.comment,\n columnNames: params.columnNames,\n inferBonds: params.inferBonds,\n name: this.parameters.name,\n path: this.parameters.path\n }\n }\n\n /**\n * Load parsed object\n * @return {Promise} resolves to the loaded & parsed {@link Structure},\n * {@link Volume}, {@link Surface} or data object\n */\n load () {\n var ParserClass = ParserRegistry.get(this.parameters.ext)\n var parser = new ParserClass(this.streamer, this.parserParams)\n\n return parser.parse()\n }\n}\n\nexport default ParserLoader\n","/**\n * @file Script\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { Log } from './globals'\nimport Stage from './stage/stage'\n\nexport interface ScriptSignals {\n elementAdded: Signal\n elementRemoved: Signal\n nameChanged: Signal\n}\n\n/**\n * Script class\n */\nclass Script {\n readonly signals: ScriptSignals = {\n elementAdded: new Signal(),\n elementRemoved: new Signal(),\n nameChanged: new Signal()\n }\n\n readonly dir: string\n readonly fn: Function\n\n readonly type = 'Script'\n\n /**\n * Create a script instance\n * @param {String} functionBody - the function source\n * @param {String} name - name of the script\n * @param {String} path - path of the script\n */\n constructor (functionBody: string, readonly name: string, readonly path: string) {\n this.dir = path.substring(0, path.lastIndexOf('/') + 1)\n\n try {\n /* eslint-disable no-new-func */\n this.fn = new Function('stage', '__name', '__path', '__dir', functionBody)\n } catch (e) {\n Log.error('Script compilation failed', e)\n this.fn = function () {}\n }\n }\n\n /**\n * Execute the script\n * @param {Stage} stage - the stage context\n * @return {Promise} - resolve when script finished running\n */\n run (stage: Stage): Promise {\n return new Promise((resolve, reject) => {\n try {\n this.fn.apply(null, [ stage, this.name, this.path, this.dir ])\n resolve()\n } catch (e) {\n Log.error('Script.fn', e)\n reject(e)\n }\n })\n }\n}\n\nexport default Script\n","/**\n * @file Script Loader\n * @author Alexander Rose \n * @private\n */\n\nimport Loader from './loader'\nimport Script from '../script'\n\n/**\n * Script loader class\n * @extends Loader\n */\nclass ScriptLoader extends Loader {\n /**\n * Load script\n * @return {Promise} resolves to the loaded {@link Script}\n */\n load () {\n return this.streamer.read().then(() => {\n return new Script(\n this.streamer.asText(), this.parameters.name, this.parameters.path\n )\n })\n }\n}\n\nexport default ScriptLoader\n","/**\n * @file Loader Utils\n * @author Alexander Rose \n * @private\n */\n\nimport {\n DatasourceRegistry, DecompressorRegistry, ParserRegistry, ScriptExtensions\n} from '../globals'\nimport ParserLoader, { ParserParams } from './parser-loader'\nimport ScriptLoader from './script-loader'\n\nexport interface LoaderParameters {\n ext: string // file extension, determines file type\n compressed: string|false // flag data as compressed\n binary: boolean // flag data as binary\n name: string // set data name\n\n dir: string\n path: string\n protocol: string\n}\n\nexport type LoaderInput = File|Blob|string\n\nexport function getFileInfo (file: LoaderInput) {\n const compressedExtList = DecompressorRegistry.names\n\n let path: string\n let compressed: string|false\n let protocol = ''\n\n if (file instanceof File) {\n path = file.name\n } else if (file instanceof Blob) {\n path = ''\n } else {\n path = file\n }\n const queryIndex = path.lastIndexOf('?')\n const query = queryIndex !== -1 ? path.substring(queryIndex) : ''\n path = path.substring(0, queryIndex === -1 ? path.length : queryIndex)\n\n const name = path.replace(/^.*[\\\\/]/, '')\n let base = name.substring(0, name.lastIndexOf('.'))\n\n const nameSplit = name.split('.')\n let ext = nameSplit.length > 1 ? (nameSplit.pop() || '').toLowerCase() : ''\n\n const protocolMatch = path.match(/^(.+):\\/\\/(.+)$/)\n if (protocolMatch) {\n protocol = protocolMatch[ 1 ].toLowerCase()\n path = protocolMatch[ 2 ] || ''\n }\n\n const dir = path.substring(0, path.lastIndexOf('/') + 1)\n\n if (compressedExtList.includes(ext)) {\n compressed = ext\n const n = path.length - ext.length - 1\n ext = (path.substr(0, n).split('.').pop() || '').toLowerCase()\n const m = base.length - ext.length - 1\n base = base.substr(0, m)\n } else {\n compressed = false\n }\n\n return { path, name, ext, base, dir, compressed, protocol, query, 'src': file }\n}\n\nexport function getDataInfo (src: LoaderInput) {\n let info = getFileInfo(src)\n const datasource = DatasourceRegistry.get(info.protocol)\n if (datasource) {\n info = getFileInfo(datasource.getUrl(info.src))\n if (!info.ext && datasource.getExt) {\n info.ext = datasource.getExt(src)\n }\n }\n return info\n}\n\n/**\n * Load a file\n *\n * @example\n * // load from URL\n * NGL.autoLoad( \"http://files.rcsb.org/download/5IOS.cif\" );\n *\n * @example\n * // load binary data in CCP4 format via a Blob\n * var binaryBlob = new Blob( [ ccp4Data ], { type: 'application/octet-binary'} );\n * NGL.autoLoad( binaryBlob, { ext: \"ccp4\" } );\n *\n * @example\n * // load string data in PDB format via a Blob\n * var stringBlob = new Blob( [ pdbData ], { type: 'text/plain'} );\n * NGL.autoLoad( stringBlob, { ext: \"pdb\" } );\n *\n * @example\n * // load a File object\n * NGL.autoLoad( file );\n *\n * @param {String|File|Blob} file - either a URL or an object containing the file data\n * @param {LoaderParameters} params - loading parameters\n * @return {Promise} Promise resolves to the loaded data\n */\nexport function autoLoad (file: LoaderInput, params: Partial = {}) {\n const p = Object.assign(getDataInfo(file), params)\n\n let loader\n if (ParserRegistry.names.includes(p.ext)) {\n loader = new ParserLoader(p.src, p)\n } else if (ScriptExtensions.includes(p.ext)) {\n loader = new ScriptLoader(p.src, p)\n }\n\n if (loader) {\n return loader.load()\n } else {\n return Promise.reject(new Error(`autoLoad: ext '${p.ext}' unknown`))\n }\n}\n","/**\n * @file Writer\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults, download } from '../utils'\n\n/**\n * Base class for writers\n * @interface\n */\nabstract class Writer {\n readonly mimeType: string\n readonly defaultName: string\n readonly defaultExt: string\n\n /**\n * @abstract\n * @return {Anything} the data to be written\n */\n abstract getData (): any\n\n /**\n * Get a blob with the written data\n * @return {Blob} the blob\n */\n getBlob () {\n return new Blob([ this.getData() ], { type: this.mimeType })\n }\n\n /**\n * Trigger a download of the\n * @param {[type]} name [description]\n * @param {[type]} ext [description]\n * @return {[type]} [description]\n */\n download (name?: string, ext?: string) {\n name = defaults(name, this.defaultName)\n ext = defaults(ext, this.defaultExt)\n\n download(this.getBlob(), `${name}.${ext}`)\n }\n}\n\nexport default Writer","/**\n * @file Pdb Writer\n * @author Alexander Rose \n * @private\n */\n\nimport { sprintf } from 'sprintf-js'\n\nimport Writer from './writer'\nimport { defaults, ensureArray } from '../utils'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\n\n// http://www.wwpdb.org/documentation/file-format\n\n// Sample PDB line, the coords X,Y,Z are fields 5,6,7 on each line.\n// ATOM 1 N ARG 1 29.292 13.212 -12.751 1.00 33.78 1BPT 108\n\nconst AtomFormat =\n 'ATOM %5d %-4s %3s %1s%4d %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%1s%1s'\n\nconst HetatmFormat =\n 'HETATM%5d %-4s %3s %1s%4d %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%1s%1s'\n\nexport interface PdbWriterParams {\n renumberSerial: boolean\n remarks: string[]\n}\n\n/**\n * Create a PDB file from a Structure object\n */\nexport default class PdbWriter extends Writer {\n readonly mimeType = 'text/plain'\n readonly defaultName = 'structure'\n readonly defaultExt = 'pdb'\n\n renumberSerial: boolean\n remarks: string[]\n\n structure: Structure\n private _records: string[]\n\n /**\n * @param {Structure} structure - the structure object\n * @param {Object} params - parameters]\n */\n constructor (structure: Structure, params?: PdbWriterParams) {\n super()\n\n const p = Object.assign({}, params)\n\n this.renumberSerial = defaults(p.renumberSerial, true)\n this.remarks = ensureArray(defaults(p.remarks, []))\n\n this.structure = structure\n this._records = []\n }\n\n private _writeRecords () {\n this._records.length = 0\n\n this._writeTitle()\n this._writeRemarks()\n this._writeAtoms()\n }\n\n private _writeTitle () {\n // FIXME multiline if title line longer than 80 chars\n this._records.push(sprintf('TITLE %-74s', this.structure.name))\n }\n\n private _writeRemarks () {\n this.remarks.forEach(str => {\n this._records.push(sprintf('REMARK %-73s', str))\n })\n\n if (this.structure.trajectory) {\n this._records.push(sprintf(\n 'REMARK %-73s',\n \"Trajectory '\" + this.structure.trajectory.name + \"'\"\n ))\n this._records.push(sprintf(\n 'REMARK %-73s',\n `Frame ${(this.structure.trajectory as any).frame}` // TODO\n ))\n }\n }\n\n private _writeAtoms () {\n let ia = 1\n let im = 1\n let charge = \" \"\n let chargeSign = \" \"\n const hasModels = this.structure.modelStore.count > 1\n\n this.structure.eachModel(m => {\n if (hasModels) this._records.push(sprintf('MODEL %4d%-66s', im++, ''))\n\n m.eachAtom((a: AtomProxy) => {\n const formatString = a.hetero ? HetatmFormat : AtomFormat\n const serial = this.renumberSerial ? ia : a.serial\n\n // Formal PDB spec\n // Alignment of one-letter atom name such as C starts at column 14,\n // while two-letter atom name such as FE starts at column 13.\n\n // This, however, leaves Calcium and C-alpha ambiguous\n // The convention (from earlier versions of the spec, see 1992, and also: \n // https://www.cgl.ucsf.edu/chimera/docs/UsersGuide/tutorials/pdbintro.html#misalignment)\n // is that element is right-justified in 13-14, modifiers are left justified in columns 15-16\n // A single-character element symmbol should not appear in column 13 unless the atom name has four characters\n let atomname = a.atomname\n\n if (atomname.length === 1) {\n // Simple case\n atomname = ' ' + atomname\n } else if (atomname.length < 4) {\n // 2 or 3-letter name, if element symbol is single char and matches name, add a space\n if (a.element.length === 1 && atomname[0] === a.element) {\n atomname = ' ' + atomname\n }\n }\n\n if (a.formalCharge) { // Skip nulls and zeros\n charge = Math.abs(a.formalCharge).toPrecision(1)\n chargeSign = (a.formalCharge > 0) ? \"+\" : \"-\"\n } else {\n charge = \" \"\n chargeSign = \" \"\n }\n\n this._records.push(sprintf(\n formatString,\n\n serial,\n atomname,\n a.resname,\n defaults(a.chainname, ' '),\n a.resno,\n a.x, a.y, a.z,\n defaults(a.occupancy, 1.0),\n defaults(a.bfactor, 0.0),\n '', // segid\n defaults(a.element, ''),\n charge,\n chargeSign\n ))\n ia += 1\n }, this.structure.getSelection())\n\n if (hasModels) this._records.push(sprintf('%-80s', 'ENDMDL'))\n })\n\n this._records.push(sprintf('%-80s', 'END'))\n }\n\n getString () {\n console.warn('PdbWriter.getString() is deprecated, use .getData instead')\n return this.getData()\n }\n\n /**\n * Get string containing the PDB file data\n * @return {String} PDB file\n */\n getData () {\n this._writeRecords()\n return this._records.join('\\n')\n }\n}\n","/**\n * Writer class for sdf/mol files.\n */\n\nimport { sprintf } from 'sprintf-js'\n\nimport Writer from './writer'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\nimport BondProxy from '../proxy/bond-proxy'\n\n// Hard-coded chiral as false as we don't specify it any atoms\nconst CountFormat = '%3i%3i 0 0 0 0 0 0 0 0999 V2000'\nconst AtomLine = '%10.4f%10.4f%10.4f %-3s 0%3i 0 0 0'\nconst BondFormat = '%3i%3i%3i 0 0 0'\n\nclass SdfWriter extends Writer {\n readonly mimeType = 'text/plain'\n readonly defaultName = 'structure'\n readonly defaultExt = 'sdf'\n\n structure: Structure\n private _records: string[]\n\n /**\n * @param {Structure} structure - structure to write\n * @param {Object} params - parameters\n */\n constructor (structure: Structure) {\n super()\n\n this.structure = structure\n // Follow the pdb-writer example:\n this._records = []\n }\n\n get idString () {\n return this.structure.id\n }\n\n get titleString () {\n return ' ' + this.structure.title\n }\n\n get countsString () {\n return sprintf(\n CountFormat,\n this.structure.atomCount,\n this.structure.bondCount\n )\n }\n\n get chargeLines () {\n const pairs: [number, number][] = []\n this.structure.eachAtom(ap => {\n if (ap.formalCharge != null && ap.formalCharge !== 0) {\n pairs.push([ap.index, ap.formalCharge])\n }\n })\n const lines = []\n for (let i = 0; i < pairs.length; i += 8) {\n const nCharges = Math.min(8, pairs.length - i)\n let s = sprintf('M CHG%3i', nCharges)\n for (let j = i; j < i + nCharges; j++) {\n s += sprintf(' %3i %3i', pairs[j][0] + 1, pairs[j][1])\n }\n lines.push(s)\n }\n return lines\n }\n\n formatAtom (ap: AtomProxy) {\n let charge = 0\n if (ap.formalCharge != null && ap.formalCharge !== 0) {\n charge = 4 - ap.formalCharge\n }\n const line = sprintf(\n AtomLine, ap.x, ap.y, ap.z, ap.element, charge\n )\n if (line.length !== 48) { throw new Error('Incompatible atom for sdf format') }\n\n return line\n }\n\n formatBond (bp: BondProxy) {\n return sprintf(\n BondFormat,\n bp.atomIndex1 + 1,\n bp.atomIndex2 + 1,\n bp.bondOrder)\n }\n\n _writeRecords () {\n this._records.length = 0\n this._writeHeader()\n this._writeCTab()\n this._writeFooter()\n }\n\n _writeHeader () {\n this._records.push(this.idString, this.titleString, '')\n }\n\n _writeCTab () {\n this._records.push(this.countsString)\n this.structure.eachAtom(ap => {\n this._records.push(this.formatAtom(ap))\n })\n this.structure.eachBond(bp => {\n this._records.push(this.formatBond(bp))\n })\n this.chargeLines.forEach(line => {\n this._records.push(line)\n })\n this._records.push('M END')\n }\n\n _writeFooter () {\n this._records.push('$$$$')\n }\n\n getData () {\n this._writeRecords()\n return this._records.join('\\n')\n }\n}\n\nexport default SdfWriter\n","/**\n * @file IO Buffer\n * @author Alexander Rose \n * @private\n *\n * Adapted and converted to TypeScript from https://github.com/image-js/iobuffer\n * MIT License, Copyright (c) 2015 Michaël Zasso\n */\n\nimport { TypedArray } from '../types'\n\nconst defaultByteLength = 1024 * 8\nconst charArray: string[] = []\n\nexport interface IOBufferParameters {\n offset?: number // Ignore the first n bytes of the ArrayBuffer\n}\n\n/**\n * Class for writing and reading binary data\n */\nclass IOBuffer {\n private _lastWrittenByte: number\n private _mark = 0\n private _marks: number[] = []\n private _data: DataView\n\n offset = 0 // The current offset of the buffer's pointer\n littleEndian = true\n buffer: ArrayBuffer // Reference to the internal ArrayBuffer object\n length: number // Byte length of the internal ArrayBuffer\n byteLength: number // Byte length of the internal ArrayBuffer\n byteOffset: number // Byte offset of the internal ArrayBuffer\n\n /**\n * If it's a number, it will initialize the buffer with the number as\n * the buffer's length. If it's undefined, it will initialize the buffer\n * with a default length of 8 Kb. If its an ArrayBuffer, a TypedArray,\n * it will create a view over the underlying ArrayBuffer.\n */\n constructor (data: number|ArrayBuffer|TypedArray, params: IOBufferParameters = {}) {\n let dataIsGiven = false\n if (data === undefined) {\n data = defaultByteLength\n }\n if (typeof data === 'number') {\n data = new ArrayBuffer(data)\n } else {\n dataIsGiven = true\n }\n\n const offset = params.offset ? params.offset >>> 0 : 0\n let byteLength = data.byteLength - offset\n let dvOffset = offset\n if (!(data instanceof ArrayBuffer)) {\n if (data.byteLength !== data.buffer.byteLength) {\n dvOffset = data.byteOffset + offset\n }\n data = data.buffer\n }\n if (dataIsGiven) {\n this._lastWrittenByte = byteLength\n } else {\n this._lastWrittenByte = 0\n }\n\n this.buffer = data\n this.length = byteLength\n this.byteLength = byteLength\n this.byteOffset = dvOffset\n\n this._data = new DataView(this.buffer, dvOffset, byteLength)\n }\n\n /**\n * Checks if the memory allocated to the buffer is sufficient to store more bytes after the offset\n * @param {number} [byteLength=1] The needed memory in bytes\n * @return {boolean} Returns true if there is sufficient space and false otherwise\n */\n available (byteLength: number) {\n if (byteLength === undefined) byteLength = 1\n return (this.offset + byteLength) <= this.length\n }\n\n /**\n * Check if little-endian mode is used for reading and writing multi-byte values\n * @return {boolean} Returns true if little-endian mode is used, false otherwise\n */\n isLittleEndian () {\n return this.littleEndian\n }\n\n /**\n * Set little-endian mode for reading and writing multi-byte values\n * @return {IOBuffer}\n */\n setLittleEndian () {\n this.littleEndian = true\n return this\n }\n\n /**\n * Check if big-endian mode is used for reading and writing multi-byte values\n * @return {boolean} Returns true if big-endian mode is used, false otherwise\n */\n isBigEndian () {\n return !this.littleEndian\n }\n\n /**\n * Switches to big-endian mode for reading and writing multi-byte values\n * @return {IOBuffer}\n */\n setBigEndian () {\n this.littleEndian = false\n return this\n }\n\n /**\n * Move the pointer n bytes forward\n * @param {number} n\n * @return {IOBuffer}\n */\n skip (n: number) {\n if (n === undefined) n = 1\n this.offset += n\n return this\n }\n\n /**\n * Move the pointer to the given offset\n * @param {number} offset\n * @return {IOBuffer}\n */\n seek (offset: number) {\n this.offset = offset\n return this\n }\n\n /**\n * Store the current pointer offset.\n * @see {@link IOBuffer#reset}\n * @return {IOBuffer}\n */\n mark () {\n this._mark = this.offset\n return this\n }\n\n /**\n * Move the pointer back to the last pointer offset set by mark\n * @see {@link IOBuffer#mark}\n * @return {IOBuffer}\n */\n reset () {\n this.offset = this._mark\n return this\n }\n\n /**\n * Push the current pointer offset to the mark stack\n * @see {@link IOBuffer#popMark}\n * @return {IOBuffer}\n */\n pushMark () {\n this._marks.push(this.offset)\n return this\n }\n\n /**\n * Pop the last pointer offset from the mark stack, and set the current pointer offset to the popped value\n * @see {@link IOBuffer#pushMark}\n * @return {IOBuffer}\n */\n popMark () {\n const offset = this._marks.pop()\n if (offset === undefined) throw new Error('Mark stack empty')\n this.seek(offset)\n return this\n }\n\n /**\n * Move the pointer offset back to 0\n * @return {IOBuffer}\n */\n rewind () {\n this.offset = 0\n return this\n }\n\n /**\n * Make sure the buffer has sufficient memory to write a given byteLength at the current pointer offset\n * If the buffer's memory is insufficient, this method will create a new buffer (a copy) with a length\n * that is twice (byteLength + current offset)\n * @param {number} [byteLength = 1]\n * @return {IOBuffer}\n */\n ensureAvailable (byteLength: number) {\n if (byteLength === undefined) byteLength = 1\n if (!this.available(byteLength)) {\n const lengthNeeded = this.offset + byteLength\n const newLength = lengthNeeded * 2\n const newArray = new Uint8Array(newLength)\n newArray.set(new Uint8Array(this.buffer))\n this.buffer = newArray.buffer\n this.length = this.byteLength = newLength\n this._data = new DataView(this.buffer)\n }\n return this\n }\n\n /**\n * Read a byte and return false if the byte's value is 0, or true otherwise\n * Moves pointer forward\n * @return {boolean}\n */\n readBoolean () {\n return this.readUint8() !== 0\n }\n\n /**\n * Read a signed 8-bit integer and move pointer forward\n * @return {number}\n */\n readInt8 () {\n return this._data.getInt8(this.offset++)\n }\n\n /**\n * Read an unsigned 8-bit integer and move pointer forward\n * @return {number}\n */\n readUint8 () {\n return this._data.getUint8(this.offset++)\n }\n\n /**\n * Alias for {@link IOBuffer#readUint8}\n * @return {number}\n */\n readByte () {\n return this.readUint8()\n }\n\n /**\n * Read n bytes and move pointer forward.\n * @param {number} n\n * @return {Uint8Array}\n */\n readBytes (n: number) {\n if (n === undefined) n = 1\n var bytes = new Uint8Array(n)\n for (var i = 0; i < n; i++) {\n bytes[i] = this.readByte()\n }\n return bytes\n }\n\n /**\n * Read a 16-bit signed integer and move pointer forward\n * @return {number}\n */\n readInt16 () {\n var value = this._data.getInt16(this.offset, this.littleEndian)\n this.offset += 2\n return value\n }\n\n /**\n * Read a 16-bit unsigned integer and move pointer forward\n * @return {number}\n */\n readUint16 () {\n var value = this._data.getUint16(this.offset, this.littleEndian)\n this.offset += 2\n return value\n }\n\n /**\n * Read a 32-bit signed integer and move pointer forward\n * @return {number}\n */\n readInt32 () {\n var value = this._data.getInt32(this.offset, this.littleEndian)\n this.offset += 4\n return value\n }\n\n /**\n * Read a 32-bit unsigned integer and move pointer forward\n * @return {number}\n */\n readUint32 () {\n var value = this._data.getUint32(this.offset, this.littleEndian)\n this.offset += 4\n return value\n }\n\n /**\n * Read a 32-bit floating number and move pointer forward\n * @return {number}\n */\n readFloat32 () {\n var value = this._data.getFloat32(this.offset, this.littleEndian)\n this.offset += 4\n return value\n }\n\n /**\n * Read a 64-bit floating number and move pointer forward\n * @return {number}\n */\n readFloat64 () {\n var value = this._data.getFloat64(this.offset, this.littleEndian)\n this.offset += 8\n return value\n }\n\n /**\n * Read 1-byte ascii character and move pointer forward\n * @return {string}\n */\n readChar () {\n return String.fromCharCode(this.readInt8())\n }\n\n /**\n * Read n 1-byte ascii characters and move pointer forward\n * @param {number} n\n * @return {string}\n */\n readChars (n = 1) {\n charArray.length = n\n for (var i = 0; i < n; i++) {\n charArray[i] = this.readChar()\n }\n return charArray.join('')\n }\n\n /**\n * Write 0xff if the passed value is truthy, 0x00 otherwise\n * @param {any} value\n * @return {IOBuffer}\n */\n writeBoolean (value = false) {\n this.writeUint8(value ? 0xff : 0x00)\n return this\n }\n\n /**\n * Write value as an 8-bit signed integer\n * @param {number} value\n * @return {IOBuffer}\n */\n writeInt8 (value: number) {\n this.ensureAvailable(1)\n this._data.setInt8(this.offset++, value)\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write value as a 8-bit unsigned integer\n * @param {number} value\n * @return {IOBuffer}\n */\n writeUint8 (value: number) {\n this.ensureAvailable(1)\n this._data.setUint8(this.offset++, value)\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * An alias for {@link IOBuffer#writeUint8}\n * @param {number} value\n * @return {IOBuffer}\n */\n writeByte (value: number) {\n return this.writeUint8(value)\n }\n\n /**\n * Write bytes\n * @param {Array|Uint8Array} bytes\n * @return {IOBuffer}\n */\n writeBytes (bytes: number[]|Uint8Array) {\n this.ensureAvailable(bytes.length)\n for (var i = 0; i < bytes.length; i++) {\n this._data.setUint8(this.offset++, bytes[i])\n }\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write value as an 16-bit signed integer\n * @param {number} value\n * @return {IOBuffer}\n */\n writeInt16 (value: number) {\n this.ensureAvailable(2)\n this._data.setInt16(this.offset, value, this.littleEndian)\n this.offset += 2\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write value as a 16-bit unsigned integer\n * @param {number} value\n * @return {IOBuffer}\n */\n writeUint16 (value: number) {\n this.ensureAvailable(2)\n this._data.setUint16(this.offset, value, this.littleEndian)\n this.offset += 2\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write a 32-bit signed integer at the current pointer offset\n * @param {number} value\n * @return {IOBuffer}\n */\n writeInt32 (value: number) {\n this.ensureAvailable(4)\n this._data.setInt32(this.offset, value, this.littleEndian)\n this.offset += 4\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write a 32-bit unsigned integer at the current pointer offset\n * @param {number} value - The value to set\n * @return {IOBuffer}\n */\n writeUint32 (value: number) {\n this.ensureAvailable(4)\n this._data.setUint32(this.offset, value, this.littleEndian)\n this.offset += 4\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write a 32-bit floating number at the current pointer offset\n * @param {number} value - The value to set\n * @return {IOBuffer}\n */\n writeFloat32 (value: number) {\n this.ensureAvailable(4)\n this._data.setFloat32(this.offset, value, this.littleEndian)\n this.offset += 4\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write a 64-bit floating number at the current pointer offset\n * @param {number} value\n * @return {IOBuffer}\n */\n writeFloat64 (value: number) {\n this.ensureAvailable(8)\n this._data.setFloat64(this.offset, value, this.littleEndian)\n this.offset += 8\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write the charCode of the passed string's first character to the current pointer offset\n * @param {string} str - The character to set\n * @return {IOBuffer}\n */\n writeChar (str: string) {\n return this.writeUint8(str.charCodeAt(0))\n }\n\n /**\n * Write the charCodes of the passed string's characters to the current pointer offset\n * @param {string} str\n * @return {IOBuffer}\n */\n writeChars (str: string) {\n for (var i = 0; i < str.length; i++) {\n this.writeUint8(str.charCodeAt(i))\n }\n return this\n }\n\n /**\n * Export a Uint8Array view of the internal buffer.\n * The view starts at the byte offset and its length\n * is calculated to stop at the last written byte or the original length.\n * @return {Uint8Array}\n */\n toArray () {\n return new Uint8Array(this.buffer, this.byteOffset, this._lastWrittenByte)\n }\n\n /**\n * Update the last written byte offset\n * @private\n */\n _updateLastWrittenByte () {\n if (this.offset > this._lastWrittenByte) {\n this._lastWrittenByte = this.offset\n }\n }\n}\n\nexport default IOBuffer\n","/**\n * @file STL Writer\n * @author Paul Pillot \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport Writer from './writer'\nimport IOBuffer from '../utils/io-buffer'\nimport Surface from '../surface/surface'\n\n// https://en.wikipedia.org/wiki/STL_(file_format)#ASCII_STL\n\n/**\n * Create an STL File from a surface Object (e.g. for 3D printing)\n *\n * @example\n * molsurf = new MolecularSurface(structure)\n * surf = molsurf.getSurface({type: 'av', probeRadius: 1.4})\n * stl = new StlWriter(surf)\n * stl.download('myFileName')\n */\nexport default class StlWriter extends Writer {\n readonly mimeType = 'application/vnd.ms-pki.stl'\n readonly defaultName = 'surface'\n readonly defaultExt = 'stl'\n\n surface: any // TODO\n\n /**\n * @param {Surface} surface - the surface to write out\n */\n constructor (surface: Surface) {\n super()\n\n this.surface = surface\n }\n\n /*\n * Get STL Binary data\n *\n * Adapted from: https://github.com/mrdoob/three.js/blob/master/examples/js/exporters/STLBinaryExporter.js\n * see https://en.wikipedia.org/wiki/STL_(file_format)#Binary_STL for the file format description\n *\n * @return {DataView} the data\n */\n getData () {\n const triangles = this.surface.index.length / 3\n const bufferLength = triangles * 2 + triangles * 3 * 4 * 4 + 80 + 4\n const output = new IOBuffer(bufferLength)\n\n output.skip(80) // skip header\n output.writeUint32(triangles)\n\n const vector = new Vector3()\n const vectorNorm1 = new Vector3()\n const vectorNorm2 = new Vector3()\n const vectorNorm3 = new Vector3()\n\n // traversing vertices\n for (let i = 0; i < triangles; i++) {\n const indices = [\n this.surface.index[i * 3],\n this.surface.index[i * 3 + 1],\n this.surface.index[i * 3 + 2]\n ]\n\n vectorNorm1.fromArray(this.surface.normal, indices[0] * 3)\n vectorNorm2.fromArray(this.surface.normal, indices[1] * 3)\n vectorNorm3.fromArray(this.surface.normal, indices[2] * 3)\n\n vector.addVectors(vectorNorm1, vectorNorm2).add(vectorNorm3).normalize()\n\n output.writeFloat32(vector.x)\n output.writeFloat32(vector.y)\n output.writeFloat32(vector.z)\n\n for (let j = 0; j < 3; j++) {\n vector.fromArray(this.surface.position, indices[j] * 3)\n\n output.writeFloat32(vector.x) // vertices\n output.writeFloat32(vector.y)\n output.writeFloat32(vector.z)\n }\n\n output.writeUint16(0) // attribute byte count\n }\n\n return new DataView(output.buffer)\n }\n}","/**\n * @file Counter\n * @author Alexander Rose \n * @private\n */\n\nimport { Log } from '../globals'\n\nimport * as signalsWrapper from 'signals'\n\n/**\n * {@link Signal}, dispatched when the `count` changes\n * @example\n * counter.signals.countChanged.add( function( delta ){ ... } );\n * @event Counter#countChanged\n * @type {Integer}\n */\n\nexport interface CounterSignals {\n countChanged: signalsWrapper.Signal\n}\n\n/**\n * Counter class for keeping track of counts\n */\nclass Counter {\n count = 0\n\n signals: CounterSignals = {\n countChanged: new signalsWrapper.Signal()\n }\n\n /**\n * Set the `count` to zero\n * @return {undefined}\n */\n clear () {\n this.change(-this.count)\n }\n\n /**\n * Change the `count`\n * @fires Counter#countChanged\n * @param {Integer} delta - count change\n * @return {undefined}\n */\n change (delta: number) {\n this.count += delta\n this.signals.countChanged.dispatch(delta, this.count)\n\n if (this.count < 0) {\n Log.warn('Counter.count below zero', this.count)\n }\n }\n\n /**\n * Increments the `count` by one.\n * @return {undefined}\n */\n increment () {\n this.change(1)\n }\n\n /**\n * Decrements the `count` by one.\n * @return {undefined}\n */\n decrement () {\n this.change(-1)\n }\n\n /**\n * Listen to another counter object and change this `count` by the\n * same amount\n * @param {Counter} counter - the counter object to listen to\n * @return {undefined}\n */\n listen (counter: Counter) {\n this.change(counter.count)\n counter.signals.countChanged.add(this.change, this)\n }\n\n /**\n * Stop listening to the other counter object\n * @param {Counter} counter - the counter object to stop listening to\n * @return {undefined}\n */\n unlisten (counter: Counter) {\n const countChanged = counter.signals.countChanged\n if (countChanged.has(this.change, this)) {\n countChanged.remove(this.change, this)\n }\n }\n\n /**\n * Invole the callback function once, when the `count` becomes zero\n * @param {Function} callback - the callback function\n * @param {Object} context - the context for the callback function\n * @return {undefined}\n */\n onZeroOnce (callback: () => void, context?: any) {\n if (this.count === 0) {\n callback.call(context)\n } else {\n const fn = () => {\n if (this.count === 0) {\n this.signals.countChanged.remove(fn, this)\n callback.call(context)\n }\n }\n this.signals.countChanged.add(fn, this)\n }\n }\n\n dispose () {\n this.clear()\n this.signals.countChanged.dispose()\n }\n}\n\nexport default Counter\n","/**\n * @file Stats\n * @author Alexander Rose \n * @private\n */\n\nimport * as signalsWrapper from 'signals'\n\nexport default class Stats {\n signals = {\n updated: new signalsWrapper.Signal()\n }\n\n maxDuration = -Infinity\n minDuration = Infinity\n avgDuration = 14\n lastDuration = Infinity\n\n prevFpsTime = 0\n lastFps = Infinity\n lastFrames = 1\n frames = 0\n count = 0\n\n startTime: number\n currentTime: number\n\n constructor () {\n this.begin()\n }\n\n update () {\n this.startTime = this.end()\n this.currentTime = this.startTime\n this.signals.updated.dispatch()\n }\n\n begin () {\n this.startTime = window.performance.now()\n this.lastFrames = this.frames\n }\n\n end () {\n const time = window.performance.now()\n\n this.count += 1\n this.frames += 1\n\n this.lastDuration = time - this.startTime\n this.minDuration = Math.min(this.minDuration, this.lastDuration)\n this.maxDuration = Math.max(this.maxDuration, this.lastDuration)\n this.avgDuration -= this.avgDuration / 30\n this.avgDuration += this.lastDuration / 30\n\n if (time > this.prevFpsTime + 1000) {\n this.lastFps = this.frames\n this.prevFpsTime = time\n this.frames = 0\n }\n\n return time\n }\n}","/**\n * @file Shader Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { ShaderChunk } from 'three'\n\nimport './chunk/fog_fragment.glsl'\nimport './chunk/interior_fragment.glsl'\nimport './chunk/matrix_scale.glsl'\nimport './chunk/nearclip_vertex.glsl'\nimport './chunk/nearclip_fragment.glsl'\nimport './chunk/opaque_back_fragment.glsl'\nimport './chunk/radiusclip_vertex.glsl'\nimport './chunk/radiusclip_fragment.glsl'\nimport './chunk/unpack_color.glsl'\n\nimport { ShaderRegistry } from '../globals'\n\nexport type ShaderDefine = (\n 'NEAR_CLIP'|'RADIUS_CLIP'|'PICKING'|'NOLIGHT'|'FLAT_SHADED'|'OPAQUE_BACK'|\n 'DIFFUSE_INTERIOR'|'USE_INTERIOR_COLOR'|\n 'USE_SIZEATTENUATION'|'USE_MAP'|'ALPHATEST'|'SDF'|'FIXED_SIZE'|\n 'CUBIC_INTERPOLATION'|'BSPLINE_FILTER'|'CATMULROM_FILTER'|'MITCHELL_FILTER'\n)\nexport type ShaderDefines = {\n [k in ShaderDefine]?: number|string\n}\n\nfunction getDefines (defines: ShaderDefines) {\n if (defines === undefined) return ''\n\n const lines = []\n\n for (const name in defines) {\n const value = defines[ name as keyof ShaderDefines ]\n\n if (!value) continue\n\n lines.push(`#define ${name} ${value}`)\n }\n\n return lines.join('\\n') + '\\n'\n}\n\nconst reInclude = /^(?!\\/\\/)\\s*#include\\s+(\\S+)/gmi\nconst shaderCache: { [k: string]: string } = {}\n\nexport function getShader (name: string, defines: ShaderDefines = {}) {\n let hash = name + '|'\n for (const key in defines) {\n hash += key + ':' + defines[ key as keyof ShaderDefines ]\n }\n\n if (!shaderCache[ hash ]) {\n const definesText = getDefines(defines)\n\n let shaderText = ShaderRegistry.get(`shader/${name}`) as string\n if (!shaderText) {\n throw new Error(`empty shader, '${name}'`)\n }\n shaderText = shaderText.replace(reInclude, function (match, p1) {\n const path = `shader/chunk/${p1}.glsl`\n const chunk = ShaderRegistry.get(path) || ShaderChunk[ p1 ]\n if (!chunk) {\n throw new Error(`empty chunk, '${p1}'`)\n }\n return chunk\n })\n\n shaderCache[ hash ] = definesText + shaderText\n }\n\n return shaderCache[ hash ]\n}\n","/**\n * @file Viewer Constants\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug } from '../globals'\n\nif (typeof WebGLRenderingContext !== 'undefined') {\n const wrcp = WebGLRenderingContext.prototype\n\n // wrap WebGL debug function used by three.js and\n // ignore calls to them when the debug flag is not set\n\n const _getShaderParameter = wrcp.getShaderParameter\n wrcp.getShaderParameter = function getShaderParameter (this: WebGLRenderingContext) {\n if (Debug) {\n return _getShaderParameter.apply(this, arguments)\n } else {\n return true\n }\n }\n\n const _getShaderInfoLog = wrcp.getShaderInfoLog\n wrcp.getShaderInfoLog = function getShaderInfoLog (this: WebGLRenderingContext) {\n if (Debug) {\n return _getShaderInfoLog.apply(this, arguments)\n } else {\n return ''\n }\n }\n\n const _getProgramParameter = wrcp.getProgramParameter\n wrcp.getProgramParameter = function getProgramParameter (this: WebGLRenderingContext, program, pname) {\n if (Debug || pname !== wrcp.LINK_STATUS) {\n return _getProgramParameter.apply(this, arguments)\n } else {\n return true\n }\n }\n\n const _getProgramInfoLog = wrcp.getProgramInfoLog\n wrcp.getProgramInfoLog = function getProgramInfoLog (this: WebGLRenderingContext) {\n if (Debug) {\n return _getProgramInfoLog.apply(this, arguments)\n } else {\n return ''\n }\n }\n}\n\nexport const JitterVectors = [\n [\n [ 0, 0 ]\n ],\n [\n [ 4, 4 ], [ -4, -4 ]\n ],\n [\n [ -2, -6 ], [ 6, -2 ], [ -6, 2 ], [ 2, 6 ]\n ],\n [\n [ 1, -3 ], [ -1, 3 ], [ 5, 1 ], [ -3, -5 ],\n [ -5, 5 ], [ -7, -1 ], [ 3, 7 ], [ 7, -7 ]\n ],\n [\n [ 1, 1 ], [ -1, -3 ], [ -3, 2 ], [ 4, -1 ],\n [ -5, -2 ], [ 2, 5 ], [ 5, 3 ], [ 3, -5 ],\n [ -2, 6 ], [ 0, -7 ], [ -4, -6 ], [ -6, 4 ],\n [ -8, 0 ], [ 7, -4 ], [ 6, 7 ], [ -7, -8 ]\n ],\n [\n [ -4, -7 ], [ -7, -5 ], [ -3, -5 ], [ -5, -4 ],\n [ -1, -4 ], [ -2, -2 ], [ -6, -1 ], [ -4, 0 ],\n [ -7, 1 ], [ -1, 2 ], [ -6, 3 ], [ -3, 3 ],\n [ -7, 6 ], [ -3, 6 ], [ -5, 7 ], [ -1, 7 ],\n [ 5, -7 ], [ 1, -6 ], [ 6, -5 ], [ 4, -4 ],\n [ 2, -3 ], [ 7, -2 ], [ 1, -1 ], [ 4, -1 ],\n [ 2, 1 ], [ 6, 2 ], [ 0, 4 ], [ 4, 4 ],\n [ 2, 5 ], [ 7, 5 ], [ 5, 6 ], [ 3, 7 ]\n ]\n]\n\nJitterVectors.forEach(offsetList => {\n offsetList.forEach(offset => {\n // 0.0625 = 1 / 16\n offset[ 0 ] *= 0.0625\n offset[ 1 ] *= 0.0625\n })\n})\n","/**\n * @file Tiled Renderer\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { Camera, WebGLRenderer } from 'three'\nimport Viewer from './viewer'\n\nexport interface TiledRendererParams {\n factor?: number\n antialias?: boolean\n onProgress?: Function\n onFinish?: Function\n}\n\nclass TiledRenderer {\n canvas = document.createElement('canvas')\n\n private _width: number\n private _height: number\n private _n: number\n private _factor: number\n private _antialias: boolean\n private _viewerSampleLevel: number\n\n private _viewer: Viewer\n private _onProgress?: Function\n private _onFinish?: Function\n private _ctx: CanvasRenderingContext2D\n\n constructor(renderer: WebGLRenderer, camera: Camera, viewer: Viewer, params: TiledRendererParams) {\n this._viewer = viewer\n\n this._factor = defaults(params.factor, 2)\n this._antialias = defaults(params.antialias, false)\n\n this._onProgress = params.onProgress\n this._onFinish = params.onFinish\n\n if (this._antialias) this._factor *= 2\n this._n = this._factor * this._factor\n\n // canvas\n\n this._width = this._viewer.width\n this._height = this._viewer.height\n\n if (this._antialias) {\n this.canvas.width = this._width * this._factor / 2\n this.canvas.height = this._height * this._factor / 2\n } else {\n this.canvas.width = this._width * this._factor\n this.canvas.height = this._height * this._factor\n }\n\n this._ctx = this.canvas.getContext('2d')!\n\n this._viewerSampleLevel = viewer.sampleLevel\n this._viewer.setSampling(-1)\n }\n\n private _renderTile (i: number) {\n const viewer = this._viewer\n const width = this._width\n const height = this._height\n const factor = this._factor\n\n const x = i % factor\n const y = Math.floor(i / factor)\n\n const offsetX = x * width\n const offsetY = y * height\n\n viewer.camera.setViewOffset(\n width * factor,\n height * factor,\n offsetX,\n offsetY,\n width,\n height\n )\n\n viewer.render()\n\n if (this._antialias) {\n const w = Math.round((offsetX + width) / 2) - Math.round (offsetX / 2);\n const h = Math.round((offsetY + height) / 2) - Math.round (offsetY / 2);\n this._ctx.drawImage(\n viewer.renderer.domElement,\n Math.round(offsetX / 2),\n Math.round(offsetY / 2),\n w,\n h\n )\n } else {\n this._ctx.drawImage(\n viewer.renderer.domElement,\n Math.floor(offsetX),\n Math.floor(offsetY),\n Math.ceil(width),\n Math.ceil(height)\n )\n }\n\n if (typeof this._onProgress === 'function') {\n this._onProgress(i + 1, this._n, false)\n }\n }\n\n private _finalize () {\n this._viewer.setSampling(this._viewerSampleLevel)\n this._viewer.camera.view = null! // TODO\n\n if (typeof this._onFinish === 'function') {\n this._onFinish(this._n + 1, this._n, false)\n }\n }\n\n render () {\n for (let i = 0; i <= this._n; ++i) {\n if (i === this._n) {\n this._finalize()\n } else {\n this._renderTile(i)\n }\n }\n }\n\n renderAsync () {\n let count = 0\n const n = this._n\n\n const fn = () => {\n if (count === n) {\n this._finalize()\n } else {\n this._renderTile(count)\n }\n count += 1\n }\n\n for (let i = 0; i <= n; ++i) {\n setTimeout(fn, 0)\n }\n }\n}\n\nexport default TiledRenderer\n","/**\n * @file Math Constants\n * @author Alexander Rose \n * @private\n */\n\nexport const EPS = 0.0000001\nexport const TwoPI = 2 * Math.PI\n\nexport const DEG2RAD = Math.PI / 180\nexport const RAD2DEG = 180 / Math.PI\n","/**\n * @file Array Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { NumberArray } from '../types'\nimport { TwoPI } from './math-constants'\n\nexport function circularMean (array: NumberArray, max: number, stride = 1, offset = 0, indices?: NumberArray) {\n // http://en.wikipedia.org/wiki/Center_of_mass#Systems_with_periodic_boundary_conditions\n\n // Bai, Linge; Breen, David (2008). Calculating Center of Mass in an Unbounded 2D Environment. Journal of Graphics, GPU, and Game Tools 13 (4): 53–60.\n\n // http://stackoverflow.com/questions/18166507/using-fft-to-find-the-center-of-mass-under-periodic-boundary-conditions\n\n const n = indices ? indices.length : array.length / stride\n\n let cosMean = 0\n let sinMean = 0\n\n if (indices) {\n for (let i = 0; i < n; ++i) {\n const c = (array[ indices[ i ] * stride + offset ] + max) % max\n const angle = (c / max) * TwoPI - Math.PI\n\n cosMean += Math.cos(angle)\n sinMean += Math.sin(angle)\n }\n } else {\n for (let i = offset; i < n; i += stride) {\n const c = (array[ i ] + max) % max\n const angle = (c / max) * TwoPI - Math.PI\n\n cosMean += Math.cos(angle)\n sinMean += Math.sin(angle)\n }\n }\n\n cosMean /= n\n sinMean /= n\n\n const meanAngle = Math.atan2(sinMean, cosMean)\n const mean = (meanAngle + Math.PI) / TwoPI * max\n\n return mean\n}\n\nexport function calculateCenterArray (array1: NumberArray, array2: NumberArray, center?: T, offset = 0): T {\n const n = array1.length\n const c = center || new Float32Array(n)\n\n for (let i = 0; i < n; i += 3) {\n c[ offset + i + 0 ] = (array1[ i + 0 ] + array2[ i + 0 ]) / 2.0\n c[ offset + i + 1 ] = (array1[ i + 1 ] + array2[ i + 1 ]) / 2.0\n c[ offset + i + 2 ] = (array1[ i + 2 ] + array2[ i + 2 ]) / 2.0\n }\n\n return c as T\n}\n\nexport function calculateDirectionArray (array1: NumberArray, array2: NumberArray) {\n const n = array1.length\n const direction = new Float32Array(n)\n\n for (let i = 0; i < n; i += 3) {\n direction[ i + 0 ] = array2[ i + 0 ] - array1[ i + 0 ]\n direction[ i + 1 ] = array2[ i + 1 ] - array1[ i + 1 ]\n direction[ i + 2 ] = array2[ i + 2 ] - array1[ i + 2 ]\n }\n\n return direction\n}\n\nexport function uniformArray (n: number, a: number, optionalTarget?: T): T {\n const array = optionalTarget || new Float32Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = a\n }\n\n return array as T\n}\n\nexport function uniformArray3 (n: number, a: number, b: number, c: number, optionalTarget?: NumberArray) {\n const array = optionalTarget || new Float32Array(n * 3)\n\n for (let i = 0; i < n; ++i) {\n const j = i * 3\n\n array[ j + 0 ] = a\n array[ j + 1 ] = b\n array[ j + 2 ] = c\n }\n\n return array\n}\n\nexport function centerArray3 (array: NumberArray, center = new Vector3()) {\n const n = array.length\n\n for (let i = 0; i < n; i += 3) {\n center.x += array[ i ]\n center.y += array[ i + 1 ]\n center.z += array[ i + 2 ]\n }\n\n center.divideScalar(n / 3)\n\n return center\n}\n\nexport function serialArray (n: number) {\n const array = new Float32Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = i\n }\n\n return array\n}\n\nexport function serialBlockArray (n: number, b: number, offset = 0, optionalTarget?: NumberArray) {\n const array = optionalTarget || new Float32Array(n * b)\n\n for (let i = 0; i < n; ++i) {\n const k = offset + i * b\n\n for (let j = 0; j < b; ++j) {\n array[ k + j ] = i\n }\n }\n\n return array\n}\n\nexport function randomColorArray (n: number) {\n const array = new Float32Array(n * 3)\n\n for (let i = 0; i < n; ++i) {\n const j = i * 3\n\n array[ j + 0 ] = Math.random()\n array[ j + 1 ] = Math.random()\n array[ j + 2 ] = Math.random()\n }\n\n return array\n}\n\nexport function replicateArrayEntries (array: NumberArray, m: number) {\n const n = array.length\n const repArr = new Float32Array(n * m)\n\n for (let i = 0; i < n; ++i) {\n const k = i * m\n const a = array[ i ]\n\n for (let j = 0; j < m; ++j) {\n repArr[ k + j ] = a\n }\n }\n\n return repArr\n}\n\nexport function replicateArray3Entries (array: NumberArray, m: number) {\n const n = array.length / 3\n const repArr = new Float32Array(n * m * 3)\n\n for (let i = 0; i < n; ++i) {\n const v = i * 3\n const k = i * m * 3\n\n const a = array[ v + 0 ]\n const b = array[ v + 1 ]\n const c = array[ v + 2 ]\n\n for (let j = 0; j < m; ++j) {\n const l = k + j * 3\n\n repArr[ l + 0 ] = a\n repArr[ l + 1 ] = b\n repArr[ l + 2 ] = c\n }\n }\n\n return repArr\n}\n\nexport function calculateMeanArray (array1: NumberArray, array2: NumberArray) {\n const n = array1.length\n const mean = new Float32Array(n)\n\n for (let i = 0; i < n; i++) {\n mean[ i ] = (array1[ i ] + array2[ i ]) / 2.0\n }\n\n return mean\n}\n\nexport function calculateMinArray (array1: NumberArray, array2: NumberArray) {\n const n = array1.length\n const min = new Float32Array(n)\n\n for (let i = 0; i < n; i++) {\n min[ i ] = Math.min(array1[ i ], array2[ i ])\n }\n\n return min\n}\n\nexport function copyArray (src: T, dst: T, srcOffset: number, dstOffset: number, length: number) {\n for (let i = 0; i < length; ++i) {\n dst[ dstOffset + i ] = src[ srcOffset + i ]\n }\n}\n\nexport function copyWithin (array: NumberArray|any[], srcOffset: number, dstOffset: number, length: number) {\n copyArray(array, array, srcOffset, dstOffset, length)\n}\n\nconst swap = new Float32Array(4)\nconst temp = new Float32Array(4)\n/**\n * quicksortIP\n * @function\n * @author Roman Bolzern , 2013\n * @author I4DS http://www.fhnw.ch/i4ds, 2013\n * @license MIT License \n * @description\n * In-place quicksort for typed arrays (e.g. for Float32Array)\n * provides fast sorting\n * useful e.g. for a custom shader and/or BufferGeometry\n * Complexity: http://bigocheatsheet.com/ see Quicksort\n *\n * @example\n * points: [x, y, z, x, y, z, x, y, z, ...]\n * eleSize: 3 //because of (x, y, z)\n * orderElement: 0 //order according to x\n *\n * @param {TypedArray} arr - array to be sorted\n * @param {Integer} eleSize - element size\n * @param {Integer} orderElement - index of element used for sorting, < eleSize\n * @param {Integer} [begin] - start index for range to be sorted\n * @param {Integer} [end] - end index for range to be sorted\n * @return {TypedArray} the input array\n */\nexport function quicksortIP (arr: NumberArray, eleSize: number, orderElement: number, begin = 0, end?: number) {\n end = (end || (arr.length / eleSize)) - 1\n\n const stack = []\n let sp = -1\n let left = begin\n let right = end\n let tmp = 0.0\n let x = 0\n let y = 0\n\n const swapF = function (a: number, b: number) {\n a *= eleSize; b *= eleSize\n for (y = 0; y < eleSize; y++) {\n tmp = arr[ a + y ]\n arr[ a + y ] = arr[ b + y ]\n arr[ b + y ] = tmp\n }\n }\n\n let i, j\n\n while (true) {\n if (right - left <= 25) {\n for (j = left + 1; j <= right; j++) {\n for (x = 0; x < eleSize; x++) {\n swap[ x ] = arr[ j * eleSize + x ]\n }\n\n i = j - 1\n\n while (i >= left && arr[ i * eleSize + orderElement ] > swap[ orderElement ]) {\n for (x = 0; x < eleSize; x++) {\n arr[ (i + 1) * eleSize + x ] = arr[ i * eleSize + x ]\n }\n i--\n }\n\n for (x = 0; x < eleSize; x++) {\n arr[ (i + 1) * eleSize + x ] = swap[ x ]\n }\n }\n\n if (sp === -1) break\n\n right = stack[ sp-- ] // ?\n left = stack[ sp-- ]\n } else {\n const median = (left + right) >> 1\n\n i = left + 1\n j = right\n\n swapF(median, i)\n\n if (arr[ left * eleSize + orderElement ] > arr[ right * eleSize + orderElement ]) {\n swapF(left, right)\n }\n\n if (arr[ i * eleSize + orderElement ] > arr[ right * eleSize + orderElement ]) {\n swapF(i, right)\n }\n\n if (arr[ left * eleSize + orderElement ] > arr[ i * eleSize + orderElement ]) {\n swapF(left, i)\n }\n\n for (x = 0; x < eleSize; x++) {\n temp[ x ] = arr[ i * eleSize + x ]\n }\n\n while (true) {\n do i++; while (arr[ i * eleSize + orderElement ] < temp[ orderElement ])\n do j--; while (arr[ j * eleSize + orderElement ] > temp[ orderElement ])\n if (j < i) break\n swapF(i, j)\n }\n\n for (x = 0; x < eleSize; x++) {\n arr[ (left + 1) * eleSize + x ] = arr[ j * eleSize + x ]\n arr[ j * eleSize + x ] = temp[ x ]\n }\n\n if (right - i + 1 >= j - left) {\n stack[ ++sp ] = i\n stack[ ++sp ] = right\n right = j - 1\n } else {\n stack[ ++sp ] = left\n stack[ ++sp ] = j - 1\n left = i\n }\n }\n }\n\n return arr\n}\n\nexport function quicksortCmp (arr: NumberArray|T[], cmp?: (a: number|T, b: number|T) => number, begin = 0, end?: number) {\n cmp = cmp || function cmp (a, b) {\n if (a > b) return 1\n if (a < b) return -1\n return 0\n }\n end = (end || arr.length) - 1\n\n const stack = []\n let sp = -1\n let left = begin\n let right = end\n let tmp: number|T\n\n function swap (a: number, b: number) {\n const tmp2 = arr[ a ]\n arr[ a ] = arr[ b ]\n arr[ b ] = tmp2\n }\n\n let i, j\n\n while (true) {\n if (right - left <= 25) {\n for (let k = left + 1; k <= right; ++k) {\n tmp = arr[ k ]\n i = k - 1\n\n while (i >= left && cmp(arr[ i ], tmp) > 0) {\n arr[ i + 1 ] = arr[ i ]\n --i\n }\n\n arr[ i + 1 ] = tmp\n }\n\n if (sp === -1) break\n\n right = stack[ sp-- ] // ?\n left = stack[ sp-- ]\n } else {\n const median = (left + right) >> 1\n\n i = left + 1\n j = right\n\n swap(median, i)\n\n if (cmp(arr[ left ], arr[ right ]) > 0) {\n swap(left, right)\n }\n\n if (cmp(arr[ i ], arr[ right ]) > 0) {\n swap(i, right)\n }\n\n if (cmp(arr[ left ], arr[ i ]) > 0) {\n swap(left, i)\n }\n\n tmp = arr[ i ]\n\n while (true) {\n do i++; while (cmp(arr[ i ], tmp) < 0)\n do j--; while (cmp(arr[ j ], tmp) > 0)\n if (j < i) break\n swap(i, j)\n }\n\n arr[ left + 1 ] = arr[ j ]\n arr[ j ] = tmp\n\n if (right - i + 1 >= j - left) {\n stack[ ++sp ] = i\n stack[ ++sp ] = right\n right = j - 1\n } else {\n stack[ ++sp ] = left\n stack[ ++sp ] = j - 1\n left = i\n }\n }\n }\n\n return arr\n}\n\nexport function quickselectCmp (arr: NumberArray|T[], n: number, cmp?: (a: number|T, b: number|T) => number, left = 0, right?: number) {\n cmp = cmp || function cmp (a, b) {\n if (a > b) return 1\n if (a < b) return -1\n return 0\n }\n right = (right || arr.length) - 1\n\n let pivotIndex, pivotValue, storeIndex\n\n function swap (a: number, b: number) {\n const tmp = arr[ a ]\n arr[ a ] = arr[ b ]\n arr[ b ] = tmp\n }\n\n while (true) {\n if (left === right) {\n return arr[ left ]\n }\n pivotIndex = (left + right) >> 1\n pivotValue = arr[ pivotIndex ]\n swap(pivotIndex, right)\n storeIndex = left\n for (let i = left; i < right; ++i) {\n if (cmp(arr[ i ], pivotValue) < 0) {\n swap(storeIndex, i)\n ++storeIndex\n }\n }\n swap(right, storeIndex)\n pivotIndex = storeIndex\n if (n === pivotIndex) {\n return arr[ n ]\n } else if (n < pivotIndex) {\n right = pivotIndex - 1\n } else {\n left = pivotIndex + 1\n }\n }\n}\n\nexport function arrayMax (array: NumberArray) {\n let max = -Infinity\n for (let i = 0, il = array.length; i < il; ++i) {\n if (array[ i ] > max) max = array[ i ]\n }\n return max\n}\n\nexport function arrayMin (array: NumberArray) {\n let min = Infinity\n for (let i = 0, il = array.length; i < il; ++i) {\n if (array[ i ] < min) min = array[ i ]\n }\n return min\n}\n\nexport function arraySum (array: NumberArray, stride = 1, offset = 0) {\n const n = array.length\n let sum = 0\n for (let i = offset; i < n; i += stride) {\n sum += array[ i ]\n }\n return sum\n}\n\nexport function arrayMean (array: NumberArray, stride = 1, offset = 0) {\n return arraySum(array, stride, offset) / (array.length / stride)\n}\n\nexport function arrayRms (array: NumberArray) {\n const n = array.length\n let sumSq = 0\n for (let i = 0; i < n; ++i) {\n const di = array[ i ]\n sumSq += di * di\n }\n return Math.sqrt(sumSq / n)\n}\n\nexport function arraySorted (array: NumberArray) {\n for (let i = 1, il = array.length; i < il; ++i) {\n if (array[ i - 1 ] > array[ i ]) return false\n }\n return true\n}\n\nexport function arraySortedCmp (array: NumberArray|T[], cmp: (a: number|T, b: number|T) => number) {\n for (let i = 1, il = array.length; i < il; ++i) {\n if (cmp(array[ i - 1 ], array[ i ]) > 0) return false\n }\n return true\n}\n","/**\n * @file Viewer Utils\n * @author Alexander Rose \n * @private\n */\n\nimport {\n Vector2, Vector3, Matrix4, Points, Scene, Camera,\n Object3D, WebGLRenderer\n} from 'three'\n\nimport { createParams } from '../utils'\nimport TiledRenderer from './tiled-renderer'\nimport { quicksortCmp } from '../math/array-utils'\nimport Viewer from './viewer'\n\nfunction _trimCanvas (canvas: HTMLCanvasElement, r: number, g: number, b: number, a: number) {\n const canvasHeight = canvas.height\n const canvasWidth = canvas.width\n\n const ctx = canvas.getContext('2d')!\n const pixels = ctx.getImageData(0, 0, canvasWidth, canvasHeight).data\n\n let x, y, doBreak, off\n\n doBreak = false\n for (y = 0; y < canvasHeight; y++) {\n for (x = 0; x < canvasWidth; x++) {\n off = (y * canvasWidth + x) * 4\n if (pixels[ off ] !== r || pixels[ off + 1 ] !== g ||\n pixels[ off + 2 ] !== b || pixels[ off + 3 ] !== a\n ) {\n doBreak = true\n break\n }\n }\n if (doBreak) {\n break\n }\n }\n const topY = y\n\n doBreak = false\n for (x = 0; x < canvasWidth; x++) {\n for (y = 0; y < canvasHeight; y++) {\n off = (y * canvasWidth + x) * 4\n if (pixels[ off ] !== r || pixels[ off + 1 ] !== g ||\n pixels[ off + 2 ] !== b || pixels[ off + 3 ] !== a\n ) {\n doBreak = true\n break\n }\n }\n if (doBreak) {\n break\n }\n }\n const topX = x\n\n doBreak = false\n for (y = canvasHeight - 1; y >= 0; y--) {\n for (x = canvasWidth - 1; x >= 0; x--) {\n off = (y * canvasWidth + x) * 4\n if (pixels[ off ] !== r || pixels[ off + 1 ] !== g ||\n pixels[ off + 2 ] !== b || pixels[ off + 3 ] !== a\n ) {\n doBreak = true\n break\n }\n }\n if (doBreak) {\n break\n }\n }\n const bottomY = y\n\n doBreak = false\n for (x = canvasWidth - 1; x >= 0; x--) {\n for (y = canvasHeight - 1; y >= 0; y--) {\n off = (y * canvasWidth + x) * 4\n if (pixels[ off ] !== r || pixels[ off + 1 ] !== g ||\n pixels[ off + 2 ] !== b || pixels[ off + 3 ] !== a\n ) {\n doBreak = true\n break\n }\n }\n if (doBreak) {\n break\n }\n }\n const bottomX = x\n\n const trimedCanvas = document.createElement('canvas')\n trimedCanvas.width = bottomX - topX\n trimedCanvas.height = bottomY - topY\n\n const trimedCtx = trimedCanvas.getContext('2d')!\n trimedCtx.drawImage(\n canvas,\n topX, topY,\n trimedCanvas.width, trimedCanvas.height,\n 0, 0,\n trimedCanvas.width, trimedCanvas.height\n )\n\n return trimedCanvas\n}\n\n/**\n * Image parameter object.\n * @typedef {Object} ImageParameters - image generation parameters\n * @property {Boolean} trim - trim the image\n * @property {Integer} factor - scaling factor to apply to the viewer canvas\n * @property {Boolean} antialias - antialias the image\n * @property {Boolean} transparent - transparent image background\n */\n\nexport const ImageDefaultParameters = {\n trim: false,\n factor: 1,\n antialias: false,\n transparent: false,\n onProgress: undefined as Function|undefined\n}\nexport type ImageParameters = typeof ImageDefaultParameters\n\n/**\n * Make image from what is shown in a viewer canvas\n * @param {Viewer} viewer - the viewer\n * @param {ImageParameters} params - parameters object\n * @return {Promise} A Promise object that resolves to an image {@link Blob}.\n */\nexport function makeImage (viewer: Viewer, params: Partial = {}) {\n const {trim, factor, antialias, transparent} = createParams(params, ImageDefaultParameters)\n\n const renderer = viewer.renderer\n const camera = viewer.camera\n\n const originalClearAlpha = renderer.getClearAlpha()\n const backgroundColor = renderer.getClearColor()\n\n function setLineWidthAndPixelSize (invert = false) {\n let _factor = factor\n if (antialias) _factor *= 2\n if (invert) _factor = 1 / _factor\n viewer.scene.traverse(function (o: any) { // TODO\n const m = o.material\n if (m && m.linewidth) {\n m.linewidth *= _factor\n }\n if (m && m.uniforms && m.uniforms.size) {\n if (m.uniforms.size.__seen === undefined) {\n m.uniforms.size.value *= _factor\n m.uniforms.size.__seen = true\n }\n }\n if (m && m.uniforms && m.uniforms.linewidth) {\n if (m.uniforms.linewidth.__seen === undefined) {\n m.uniforms.linewidth.value *= _factor\n m.uniforms.linewidth.__seen = true\n }\n }\n })\n viewer.scene.traverse(function (o: any) { // TODO\n const m = o.material\n if (m && m.uniforms && m.uniforms.size) {\n delete m.uniforms.size.__seen\n }\n if (m && m.uniforms && m.uniforms.linewidth) {\n delete m.uniforms.linewidth.__seen\n }\n })\n }\n\n function trimCanvas (canvas: HTMLCanvasElement) {\n if (trim) {\n const bg = backgroundColor\n const r = transparent ? 0 : bg.r * 255\n const g = transparent ? 0 : bg.g * 255\n const b = transparent ? 0 : bg.b * 255\n const a = transparent ? 0 : 255\n return _trimCanvas(canvas, r, g, b, a)\n } else {\n return canvas\n }\n }\n\n function onProgress (i: number, n: number, finished: boolean) {\n if (typeof params.onProgress === 'function') {\n params.onProgress(i, n, finished)\n }\n }\n\n return new Promise(function (resolve, reject) {\n const tiledRenderer = new TiledRenderer(\n renderer, camera, viewer,\n { factor, antialias, onProgress, onFinish }\n )\n\n renderer.setClearAlpha(transparent ? 0 : 1)\n setLineWidthAndPixelSize()\n tiledRenderer.renderAsync()\n\n function onFinish (i: number, n: number) {\n const canvas = trimCanvas(tiledRenderer.canvas)\n canvas.toBlob(\n function (blob) {\n renderer.setClearAlpha(originalClearAlpha)\n setLineWidthAndPixelSize(true)\n viewer.requestRender()\n onProgress(n, n, true)\n if (blob) {\n resolve(blob)\n } else {\n reject('error creating image')\n }\n },\n 'image/png'\n )\n }\n })\n}\n\nconst vertex = new Vector3()\nconst matrix = new Matrix4()\nconst modelViewProjectionMatrix = new Matrix4()\n\nexport function sortProjectedPosition (scene: Scene, camera: Camera) {\n // console.time( \"sort\" );\n\n scene.traverseVisible(function (o) {\n if (!(o instanceof Points) || !o.userData.buffer.parameters.sortParticles) {\n return\n }\n\n const attributes = (o.geometry as any).attributes // TODO\n const n = attributes.position.count\n\n if (n === 0) return\n\n matrix.multiplyMatrices(\n camera.matrixWorldInverse, o.matrixWorld\n )\n modelViewProjectionMatrix.multiplyMatrices(\n camera.projectionMatrix, matrix\n )\n\n let sortData, sortArray, zArray: Float32Array, cmpFn\n\n if (!o.userData.sortData) {\n zArray = new Float32Array(n)\n sortArray = new Uint32Array(n)\n cmpFn = function (ai: number, bi: number) {\n const a = zArray[ ai ]\n const b = zArray[ bi ]\n if (a > b) return 1\n if (a < b) return -1\n return 0\n }\n\n sortData = {\n __zArray: zArray,\n __sortArray: sortArray,\n __cmpFn: cmpFn\n }\n\n o.userData.sortData = sortData\n } else {\n sortData = o.userData.sortData\n zArray = sortData.__zArray\n sortArray = sortData.__sortArray\n cmpFn = sortData.__cmpFn\n }\n\n for (let i = 0; i < n; ++i) {\n vertex.fromArray(attributes.position.array, i * 3)\n vertex.applyMatrix4(modelViewProjectionMatrix)\n\n // negate, so that sorting order is reversed\n zArray[ i ] = -vertex.z\n sortArray[ i ] = i\n }\n\n quicksortCmp(sortArray, cmpFn)\n\n let index, indexSrc, indexDst, tmpTab\n\n for (let name in attributes) {\n const attr = attributes[ name ]\n const array = attr.array\n const itemSize = attr.itemSize\n\n if (!sortData[ name ]) {\n sortData[ name ] = new Float32Array(itemSize * n)\n }\n\n tmpTab = sortData[ name ]\n sortData[ name ] = array\n\n for (let i = 0; i < n; ++i) {\n index = sortArray[ i ]\n\n for (let j = 0; j < itemSize; ++j) {\n indexSrc = index * itemSize + j\n indexDst = i * itemSize + j\n tmpTab[ indexDst ] = array[ indexSrc ]\n }\n }\n\n attributes[ name ].array = tmpTab\n attributes[ name ].needsUpdate = true\n }\n })\n\n // console.timeEnd( \"sort\" );\n}\n\nconst resolution = new Vector2()\nconst projectionMatrixInverse = new Matrix4()\nconst projectionMatrixTranspose = new Matrix4()\n\nexport function updateMaterialUniforms (group: Object3D, camera: Camera, renderer: WebGLRenderer, cDist: number, bRadius: number) {\n let size = new Vector2()\n renderer.getSize(size)\n const canvasHeight = size.height\n const pixelRatio = renderer.getPixelRatio()\n const ortho = camera.type === 'OrthographicCamera'\n\n resolution.set(size.width, size.height)\n projectionMatrixInverse.getInverse(camera.projectionMatrix)\n projectionMatrixTranspose.copy(camera.projectionMatrix).transpose()\n\n group.traverse(function (o: any) {\n const m = o.material\n if (!m) return\n\n const u = m.uniforms\n if (!u) return\n\n if (m.clipNear) {\n const nearFactor = (50 - m.clipNear) / 50\n const nearClip = cDist - (bRadius * nearFactor)\n u.clipNear.value = nearClip\n }\n\n if (u.canvasHeight) {\n u.canvasHeight.value = canvasHeight\n }\n\n if (u.resolution) {\n u.resolution.value.copy(resolution)\n }\n\n if (u.pixelRatio) {\n u.pixelRatio.value = pixelRatio\n }\n\n if (u.projectionMatrixInverse) {\n u.projectionMatrixInverse.value.copy(projectionMatrixInverse)\n }\n\n if (u.projectionMatrixTranspose) {\n u.projectionMatrixTranspose.value.copy(projectionMatrixTranspose)\n }\n\n if (u.ortho) {\n u.ortho.value = ortho\n }\n })\n}\n\nexport function updateCameraUniforms (group: Object3D, camera: Camera) {\n projectionMatrixInverse.getInverse(camera.projectionMatrix)\n projectionMatrixTranspose.copy(camera.projectionMatrix).transpose()\n\n group.traverse(function (o: any) {\n const m = o.material\n if (!m) return\n\n const u = m.uniforms\n if (!u) return\n\n if (u.projectionMatrixInverse) {\n u.projectionMatrixInverse.value.copy(projectionMatrixInverse)\n }\n\n if (u.projectionMatrixTranspose) {\n u.projectionMatrixTranspose.value.copy(projectionMatrixTranspose)\n }\n })\n}\n","/**\n * @file Viewer\n * @author Alexander Rose \n * @private\n */\n\n// adapted from https://webglfundamentals.org/webgl/resources/webgl-utils.js\n// Copyright 2012, Gregg Tavares. Modified BSD License\n\nexport function createProgram(gl: WebGLRenderingContext, shaders: WebGLShader[], attribs?: string[], locations?: number[]) {\n const program = gl.createProgram()\n if (!program) {\n console.log(`error creating WebGL program`)\n return\n }\n shaders.forEach(shader => gl.attachShader(program, shader))\n if (attribs) {\n attribs.forEach((attrib, i) => {\n gl.bindAttribLocation(program, locations ? locations[i] : i, attrib)\n })\n }\n gl.linkProgram(program);\n\n // Check the link status\n const linked = gl.getProgramParameter(program, gl.LINK_STATUS)\n if (!linked) {\n console.log(`error linking program: ${gl.getProgramInfoLog(program)}`)\n gl.deleteProgram(program)\n return null\n }\n return program\n}\n\nexport function loadShader(gl: WebGLRenderingContext, shaderSource: string, shaderType: number) {\n const shader = gl.createShader(shaderType)\n if (!shader) {\n console.log(`error creating WebGL shader ${shaderType}`)\n return // can't create shader\n }\n gl.shaderSource(shader, shaderSource)\n gl.compileShader(shader)\n\n // Check the compile status\n const compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS)\n if (!compiled) {\n console.log(`error compiling shader ${shader}: ${gl.getShaderInfoLog(shader)}`)\n gl.deleteShader(shader)\n return null\n }\n\n return shader\n}\n\n//\n\nexport function getErrorDescription(gl: WebGLRenderingContext, error: number) {\n switch (error) {\n case gl.NO_ERROR: return 'no error'\n case gl.INVALID_ENUM: return 'invalid enum'\n case gl.INVALID_VALUE: return 'invalid value'\n case gl.INVALID_OPERATION: return 'invalid operation'\n case gl.INVALID_FRAMEBUFFER_OPERATION: return 'invalid framebuffer operation'\n case gl.OUT_OF_MEMORY: return 'out of memory'\n case gl.CONTEXT_LOST_WEBGL: return 'context lost'\n }\n return 'unknown error'\n}\n\nexport function getExtension (gl: WebGLRenderingContext, name: string) {\n const ext = gl.getExtension(name)\n if (!ext) console.log(`extension '${name}' not available`)\n return ext\n}\n\nconst TextureTestVertShader = `\nattribute vec4 a_position;\n\nvoid main() {\n gl_Position = a_position;\n}`\n\nconst TextureTestFragShader = `\nprecision mediump float;\nuniform vec4 u_color;\nuniform sampler2D u_texture;\n\nvoid main() {\n gl_FragColor = texture2D(u_texture, vec2(0.5, 0.5)) * u_color;\n}`\n\nconst TextureTestTexCoords = new Float32Array([\n -1.0, -1.0, 1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0\n])\n\nexport function testTextureSupport (type: number) {\n // adapted from\n // https://stackoverflow.com/questions/28827511/webgl-ios-render-to-floating-point-texture\n\n // Get A WebGL context\n const canvas = document.createElement('canvas')\n canvas.width = 16\n canvas.height = 16\n canvas.style.width = 16 + 'px'\n canvas.style.height = 16 + 'px'\n const gl = canvas.getContext(\"webgl\") || canvas.getContext(\"experimental-webgl\");\n if (!gl) {\n console.log(`error creating webgl context for ${type}`)\n return false\n }\n if (!(gl instanceof WebGLRenderingContext)) {\n console.log(`Got unexpected type for WebGL rendering context`)\n return false\n }\n\n getExtension(gl, 'OES_texture_float')\n getExtension(gl, 'OES_texture_half_float')\n getExtension(gl, 'WEBGL_color_buffer_float')\n\n // setup shaders\n const vertShader = loadShader(gl, TextureTestVertShader, gl.VERTEX_SHADER)\n const fragShader = loadShader(gl, TextureTestFragShader, gl.FRAGMENT_SHADER)\n if (!vertShader || !fragShader) return false\n\n // setup program\n const program = createProgram(gl, [ vertShader, fragShader ])\n if (!program) {\n console.log(`error creating WebGL program`)\n return false\n }\n gl.useProgram(program);\n\n // look up where the vertex data needs to go.\n const positionLocation = gl.getAttribLocation(program, \"a_position\");\n const colorLoc = gl.getUniformLocation(program, \"u_color\");\n if (!colorLoc) {\n console.log(`error getting 'u_color' uniform location`)\n return false\n }\n\n // provide texture coordinates for the rectangle.\n const positionBuffer = gl.createBuffer()\n gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer)\n gl.bufferData(gl.ARRAY_BUFFER, TextureTestTexCoords, gl.STATIC_DRAW)\n gl.enableVertexAttribArray(positionLocation)\n gl.vertexAttribPointer(positionLocation, 2, gl.FLOAT, false, 0, 0)\n\n const whiteTex = gl.createTexture()\n const whiteData = new Uint8Array([255, 255, 255, 255])\n gl.bindTexture(gl.TEXTURE_2D, whiteTex)\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, whiteData)\n\n const tex = gl.createTexture()\n gl.bindTexture(gl.TEXTURE_2D, tex)\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, type, null)\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST)\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST)\n\n const fb = gl.createFramebuffer()\n gl.bindFramebuffer(gl.FRAMEBUFFER, fb)\n gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, tex, 0)\n const status = gl.checkFramebufferStatus(gl.FRAMEBUFFER)\n if (status !== gl.FRAMEBUFFER_COMPLETE) {\n console.log(`error creating framebuffer for ${type}`)\n return false\n }\n\n // Draw the rectangle.\n gl.bindTexture(gl.TEXTURE_2D, whiteTex)\n gl.uniform4fv(colorLoc, [0, 10, 20, 1])\n gl.drawArrays(gl.TRIANGLES, 0, 6)\n\n gl.bindTexture(gl.TEXTURE_2D, tex)\n gl.bindFramebuffer(gl.FRAMEBUFFER, null)\n gl.clearColor(1, 0, 0, 1)\n gl.clear(gl.COLOR_BUFFER_BIT)\n gl.uniform4fv(colorLoc, [0, 1/10, 1/20, 1])\n gl.drawArrays(gl.TRIANGLES, 0, 6)\n\n // Check if rendered correctly\n const pixel = new Uint8Array(4)\n gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, pixel)\n if (pixel[0] !== 0 || pixel[1] < 248 || pixel[2] < 248 || pixel[3] < 254) {\n console.log(`not able to actually render to ${type} texture`)\n return false\n }\n\n // Check reading from float texture\n if (type === gl.FLOAT) {\n gl.bindFramebuffer(gl.FRAMEBUFFER, fb)\n const floatPixel = new Float32Array(4)\n gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.FLOAT, floatPixel)\n const error = gl.getError()\n if (error) {\n console.log(`error reading pixels as float: '${getErrorDescription(gl, error)}'`)\n return false\n }\n }\n\n return true\n}\n","/**\n * @file Viewer\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\nimport {\n PerspectiveCamera, OrthographicCamera, StereoCamera,\n Vector2, Box3, Vector3, Matrix4, Color,\n WebGLRenderer, WebGLRenderTarget,\n NearestFilter, LinearFilter, AdditiveBlending,\n RGBAFormat, FloatType, /*HalfFloatType, */UnsignedByteType,\n ShaderMaterial,\n PlaneGeometry, Geometry,\n Scene, Mesh, Group, Object3D, Uniform,\n Fog, SpotLight, AmbientLight,\n BufferGeometry, BufferAttribute,\n LineSegments,\n LinearEncoding, sRGBEncoding, TextureEncoding\n} from 'three'\nimport '../shader/BasicLine.vert'\nimport '../shader/BasicLine.frag'\nimport '../shader/Quad.vert'\nimport '../shader/Quad.frag'\n\nimport {\n Debug, Log, WebglErrorMessage, Browser,\n setExtensionFragDepth, SupportsReadPixelsFloat, setSupportsReadPixelsFloat\n} from '../globals'\nimport { degToRad } from '../math/math-utils'\nimport Stats from './stats'\nimport { getShader } from '../shader/shader-utils'\nimport { setColorSpace } from '../color/colormaker'\nimport { JitterVectors } from './viewer-constants'\nimport {\n makeImage, ImageParameters,\n sortProjectedPosition, updateMaterialUniforms, updateCameraUniforms\n} from './viewer-utils'\nimport { testTextureSupport } from './gl-utils'\n\nimport Buffer from '../buffer/buffer'\n\nconst pixelBufferFloat = new Float32Array(4 * 25)\nconst pixelBufferUint = new Uint8Array(4 * 25)\n\n// When picking, we read a 25 pixel (5x5) array (readRenderTargetPixels)\n// We read the pixels in the order below to find what was picked.\n// This starts at the center and tries successively further points.\n// (Many points will be at equal distance to the center, their order\n// is arbitrary).\nconst pixelOrder = [12,7,13,17,11,6,8,18,16,2,14,22,10,1,3,9,19,23,21,15,5,0,4,24,20]\n\n\nconst tmpMatrix = new Matrix4()\n\nfunction onBeforeRender (this: Object3D, renderer: WebGLRenderer, scene: Scene, camera: PerspectiveCamera|OrthographicCamera, geometry: Geometry, material: ShaderMaterial/*, group */) {\n const u = material.uniforms\n const updateList = []\n\n if (!u) return // See #908 - some materials may not have uniforms, ignore these\n\n if (u.objectId) {\n u.objectId.value = SupportsReadPixelsFloat ? this.id : this.id / 255\n updateList.push('objectId')\n }\n\n if (u.modelViewMatrixInverse || u.modelViewMatrixInverseTranspose ||\n u.modelViewProjectionMatrix || u.modelViewProjectionMatrixInverse\n ) {\n this.modelViewMatrix.multiplyMatrices(camera.matrixWorldInverse, this.matrixWorld)\n }\n\n if (u.modelViewMatrixInverse) {\n u.modelViewMatrixInverse.value.getInverse(this.modelViewMatrix)\n updateList.push('modelViewMatrixInverse')\n }\n\n if (u.modelViewMatrixInverseTranspose) {\n if (u.modelViewMatrixInverse) {\n u.modelViewMatrixInverseTranspose.value.copy(\n u.modelViewMatrixInverse.value\n ).transpose()\n } else {\n u.modelViewMatrixInverseTranspose.value\n .getInverse(this.modelViewMatrix)\n .transpose()\n }\n updateList.push('modelViewMatrixInverseTranspose')\n }\n\n if (u.modelViewProjectionMatrix) {\n u.modelViewProjectionMatrix.value.multiplyMatrices(\n camera.projectionMatrix, this.modelViewMatrix\n )\n updateList.push('modelViewProjectionMatrix')\n }\n\n if (u.modelViewProjectionMatrixInverse) {\n if (u.modelViewProjectionMatrix) {\n tmpMatrix.copy(\n u.modelViewProjectionMatrix.value\n )\n u.modelViewProjectionMatrixInverse.value.getInverse(\n tmpMatrix\n )\n } else {\n tmpMatrix.multiplyMatrices(\n camera.projectionMatrix, this.modelViewMatrix\n )\n u.modelViewProjectionMatrixInverse.value.getInverse(\n tmpMatrix\n )\n }\n updateList.push('modelViewProjectionMatrixInverse')\n }\n\n if (updateList.length) {\n const materialProperties = renderer.properties.get(material)\n\n if (materialProperties.program) {\n const gl = renderer.getContext()\n const p = materialProperties.program\n gl.useProgram(p.program)\n const pu = p.getUniforms()\n\n updateList.forEach(function (name) {\n pu.setValue(gl, name, u[ name ].value)\n })\n }\n }\n}\n\nexport type CameraType = 'perspective'|'orthographic'|'stereo'\nexport type ColorWorkflow = 'linear' | 'sRGB'\n\nexport interface ViewerSignals {\n ticked: Signal,\n rendered: Signal\n}\n\nexport interface ViewerParameters {\n fogColor: Color\n fogNear: number\n fogFar: number\n\n backgroundColor: Color\n\n cameraType: CameraType\n cameraFov: number\n cameraEyeSep: number\n cameraZ: number\n\n clipNear: number\n clipFar: number\n clipDist: number\n clipMode: string // \"scene\" or \"camera\"\n clipScale: string // \"relative\" or \"absolute\"\n\n lightColor: Color\n lightIntensity: number\n ambientColor: Color\n ambientIntensity: number\n\n sampleLevel: number\n\n rendererEncoding: TextureEncoding // default is three.LinearEncoding; three.sRGBEncoding gives more correct results\n}\n\nexport interface BufferInstance {\n matrix: Matrix4\n}\n\n/**\n * Viewer class\n * @class\n * @param {String|Element} [idOrElement] - dom id or element\n */\nexport default class Viewer {\n signals: ViewerSignals\n\n container: HTMLElement\n wrapper: HTMLElement\n\n private rendering: boolean\n private renderPending: boolean\n private lastRenderedPicking: boolean\n private isStill: boolean\n private frameRequest: number\n\n sampleLevel: number\n private cDist: number\n private bRadius: number\n\n private parameters: ViewerParameters\n stats: Stats\n\n perspectiveCamera: PerspectiveCamera\n private orthographicCamera: OrthographicCamera\n private stereoCamera: StereoCamera\n camera: PerspectiveCamera|OrthographicCamera\n\n width: number\n height: number\n\n scene: Scene\n private spotLight: SpotLight\n private ambientLight: AmbientLight\n rotationGroup: Group\n translationGroup: Group\n private modelGroup: Group\n private pickingGroup: Group\n private backgroundGroup: Group\n private helperGroup: Group\n\n renderer: WebGLRenderer\n private supportsHalfFloat: boolean\n\n private pickingTarget: WebGLRenderTarget\n private sampleTarget: WebGLRenderTarget\n private holdTarget: WebGLRenderTarget\n\n private compositeUniforms: {\n tForeground: Uniform\n scale: Uniform\n }\n private compositeMaterial: ShaderMaterial\n private compositeCamera: OrthographicCamera\n private compositeScene: Scene\n\n private boundingBoxMesh: LineSegments\n boundingBox = new Box3()\n private boundingBoxSize = new Vector3()\n private boundingBoxLength = 0\n\n private info = {\n memory: {\n programs: 0,\n geometries: 0,\n textures: 0\n },\n render: {\n calls: 0,\n vertices: 0,\n faces: 0,\n points: 0\n }\n }\n\n private distVector = new Vector3()\n\n constructor (idOrElement: string|HTMLElement) {\n this.signals = {\n ticked: new Signal(),\n rendered: new Signal()\n }\n\n if (typeof idOrElement === 'string') {\n const elm = document.getElementById(idOrElement)\n if (elm === null) {\n this.container = document.createElement('div')\n }else {\n this.container = elm\n }\n } else if (idOrElement instanceof HTMLElement) {\n this.container = idOrElement\n } else {\n this.container = document.createElement('div')\n }\n\n if (this.container === document.body) {\n this.width = window.innerWidth || 1\n this.height = window.innerHeight || 1\n } else {\n const box = this.container.getBoundingClientRect()\n this.width = box.width || 1\n this.height = box.height || 1\n this.container.style.overflow = 'hidden'\n }\n\n this.wrapper = document.createElement('div')\n this.wrapper.style.position = 'relative'\n this.container.appendChild(this.wrapper)\n\n this._initParams()\n this._initStats()\n this._initCamera()\n this._initScene()\n\n if (this._initRenderer() === false) {\n Log.error('Viewer: could not initialize renderer')\n return\n }\n\n this._initHelper()\n\n // fog & background\n this.setBackground()\n this.setFog()\n\n this.animate = this.animate.bind(this)\n }\n\n private _initParams () {\n this.parameters = {\n fogColor: new Color(0x000000),\n fogNear: 50,\n fogFar: 100,\n\n backgroundColor: new Color(0x000000),\n\n cameraType: 'perspective',\n cameraFov: 40,\n cameraEyeSep: 0.3,\n cameraZ: -80, // FIXME initial value should be automatically determined\n\n clipNear: 0,\n clipFar: 100,\n clipDist: 10,\n clipMode: 'scene',\n clipScale: 'relative',\n\n lightColor: new Color(0xdddddd),\n lightIntensity: 1.0,\n ambientColor: new Color(0xdddddd),\n ambientIntensity: 0.2,\n\n sampleLevel: 0,\n\n // output encoding: use sRGB for a linear internal workflow, linear for traditional sRGB workflow.\n rendererEncoding: LinearEncoding,\n }\n }\n\n private _initCamera () {\n const lookAt = new Vector3(0, 0, 0)\n const {width, height} = this\n\n this.perspectiveCamera = new PerspectiveCamera(\n this.parameters.cameraFov, width / height\n )\n this.perspectiveCamera.position.z = this.parameters.cameraZ\n this.perspectiveCamera.lookAt(lookAt)\n\n this.orthographicCamera = new OrthographicCamera(\n width / -2, width / 2, height / 2, height / -2\n )\n this.orthographicCamera.position.z = this.parameters.cameraZ\n this.orthographicCamera.lookAt(lookAt)\n\n this.stereoCamera = new StereoCamera()\n this.stereoCamera.aspect = 0.5\n this.stereoCamera.eyeSep = this.parameters.cameraEyeSep\n\n const cameraType = this.parameters.cameraType\n if (cameraType === 'orthographic') {\n this.camera = this.orthographicCamera\n } else if(cameraType === 'perspective' || cameraType === 'stereo') {\n this.camera = this.perspectiveCamera\n } else {\n throw new Error(`Unknown cameraType '${cameraType}'`)\n }\n this.camera.updateProjectionMatrix()\n }\n\n private _initStats () {\n this.stats = new Stats()\n }\n\n private _initScene () {\n if (!this.scene) {\n this.scene = new Scene()\n this.scene.name = 'scene'\n }\n\n this.rotationGroup = new Group()\n this.rotationGroup.name = 'rotationGroup'\n this.scene.add(this.rotationGroup)\n\n this.translationGroup = new Group()\n this.translationGroup.name = 'translationGroup'\n this.rotationGroup.add(this.translationGroup)\n\n this.modelGroup = new Group()\n this.modelGroup.name = 'modelGroup'\n this.translationGroup.add(this.modelGroup)\n\n this.pickingGroup = new Group()\n this.pickingGroup.name = 'pickingGroup'\n this.translationGroup.add(this.pickingGroup)\n\n this.backgroundGroup = new Group()\n this.backgroundGroup.name = 'backgroundGroup'\n this.translationGroup.add(this.backgroundGroup)\n\n this.helperGroup = new Group()\n this.helperGroup.name = 'helperGroup'\n this.translationGroup.add(this.helperGroup)\n\n // fog\n\n this.scene.fog = new Fog(this.parameters.fogColor.getHex())\n\n // light\n\n this.spotLight = new SpotLight(\n this.parameters.lightColor.getHex(), this.parameters.lightIntensity\n )\n this.scene.add(this.spotLight)\n\n this.ambientLight = new AmbientLight(\n this.parameters.ambientColor.getHex(), this.parameters.ambientIntensity\n )\n this.scene.add(this.ambientLight)\n }\n\n private _initRenderer () {\n const dpr = window.devicePixelRatio\n const {width, height} = this\n\n try {\n this.renderer = new WebGLRenderer({\n preserveDrawingBuffer: true,\n alpha: true,\n antialias: true\n })\n } catch (e) {\n this.wrapper.innerHTML = WebglErrorMessage\n return false\n }\n this.renderer.setPixelRatio(dpr)\n this.renderer.setSize(width, height)\n this.renderer.autoClear = false\n this.renderer.sortObjects = true\n this.renderer.outputEncoding = this.parameters.rendererEncoding\n\n const gl = this.renderer.getContext()\n // console.log(gl.getContextAttributes().antialias)\n // console.log(gl.getParameter(gl.SAMPLES))\n\n // For WebGL1, extensions must be explicitly enabled.\n // The following are builtin to WebGL2 (and don't appear as\n // extensions)\n // EXT_frag_depth, OES_element_index_uint, OES_texture_float\n // OES_texture_half_float\n\n // The WEBGL_color_buffer_float extension is replaced by\n // EXT_color_buffer_float\n\n // If not webgl2 context, explicitly check for these\n if (!this.renderer.capabilities.isWebGL2) {\n setExtensionFragDepth(this.renderer.extensions.get('EXT_frag_depth'))\n this.renderer.extensions.get('OES_element_index_uint')\n\n setSupportsReadPixelsFloat(\n (this.renderer.extensions.get('OES_texture_float') &&\n this.renderer.extensions.get('WEBGL_color_buffer_float')) ||\n (this.renderer.extensions.get('OES_texture_float') &&\n testTextureSupport(gl.FLOAT))\n )\n // picking texture\n\n this.renderer.extensions.get('OES_texture_float')\n\n this.supportsHalfFloat = (\n this.renderer.extensions.get('OES_texture_half_float') &&\n testTextureSupport(0x8D61)\n )\n\n } else {\n setExtensionFragDepth(true)\n setSupportsReadPixelsFloat(\n this.renderer.extensions.get('EXT_color_buffer_float')\n )\n this.supportsHalfFloat = true\n }\n\n this.wrapper.appendChild(this.renderer.domElement)\n\n const dprWidth = width * dpr\n const dprHeight = height * dpr\n\n\n if (Debug) {\n console.log(JSON.stringify({\n 'Browser': Browser,\n 'OES_texture_float': !!this.renderer.extensions.get('OES_texture_float'),\n 'OES_texture_half_float': !!this.renderer.extensions.get('OES_texture_half_float'),\n 'WEBGL_color_buffer_float': !!this.renderer.extensions.get('WEBGL_color_buffer_float'),\n 'testTextureSupport Float': testTextureSupport(gl.FLOAT),\n 'testTextureSupport HalfFloat': testTextureSupport(0x8D61),\n 'this.supportsHalfFloat': this.supportsHalfFloat,\n 'SupportsReadPixelsFloat': SupportsReadPixelsFloat\n }, null, 2))\n }\n\n this.pickingTarget = new WebGLRenderTarget(\n dprWidth, dprHeight,\n {\n minFilter: NearestFilter,\n magFilter: NearestFilter,\n stencilBuffer: false,\n format: RGBAFormat,\n type: SupportsReadPixelsFloat ? FloatType : UnsignedByteType\n }\n )\n this.pickingTarget.texture.generateMipmaps = false\n this.pickingTarget.texture.encoding = this.parameters.rendererEncoding\n\n // workaround to reset the gl state after using testTextureSupport\n // fixes some bug where nothing is rendered to the canvas\n // when animations are started on page load\n this.renderer.setRenderTarget(this.pickingTarget)\n this.renderer.clear()\n this.renderer.setRenderTarget(null!)\n\n // ssaa textures\n\n this.sampleTarget = new WebGLRenderTarget(\n dprWidth, dprHeight,\n {\n minFilter: LinearFilter,\n magFilter: LinearFilter,\n format: RGBAFormat\n }\n )\n this.sampleTarget.texture.encoding = this.parameters.rendererEncoding\n\n this.holdTarget = new WebGLRenderTarget(\n dprWidth, dprHeight,\n {\n minFilter: NearestFilter,\n magFilter: NearestFilter,\n format: RGBAFormat,\n type: UnsignedByteType\n // using HalfFloatType or FloatType does not work on some Chrome 61 installations\n // type: this.supportsHalfFloat ? HalfFloatType : (\n // SupportsReadPixelsFloat ? FloatType : UnsignedByteType\n // )\n }\n )\n this.holdTarget.texture.encoding = this.parameters.rendererEncoding\n\n this.compositeUniforms = {\n 'tForeground': new Uniform(this.sampleTarget.texture),\n 'scale': new Uniform(1.0)\n }\n\n this.compositeMaterial = new ShaderMaterial({\n uniforms: this.compositeUniforms,\n vertexShader: getShader('Quad.vert'),\n fragmentShader: getShader('Quad.frag'),\n premultipliedAlpha: true,\n transparent: true,\n blending: AdditiveBlending,\n depthTest: false,\n depthWrite: false\n })\n\n this.compositeCamera = new OrthographicCamera(-1, 1, 1, -1, 0, 1)\n this.compositeScene = new Scene()\n this.compositeScene.name = 'compositeScene'\n this.compositeScene.add(new Mesh(\n new PlaneGeometry(2, 2), this.compositeMaterial\n ))\n }\n\n private _initHelper () {\n const indices = new Uint16Array([\n 0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6,\n 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7\n ])\n const positions = new Float32Array(8 * 3)\n\n const bbGeometry = new BufferGeometry()\n bbGeometry.setIndex(new BufferAttribute(indices, 1))\n bbGeometry.setAttribute('position', new BufferAttribute(positions, 3))\n const bbMaterial = new ShaderMaterial({\n uniforms: { 'uColor': { value: new Color('skyblue') } },\n vertexShader: getShader('BasicLine.vert'),\n fragmentShader: getShader('BasicLine.frag')\n })\n\n this.boundingBoxMesh = new LineSegments(bbGeometry, bbMaterial)\n this.helperGroup.add(this.boundingBoxMesh)\n }\n\n updateHelper () {\n const position = ((this.boundingBoxMesh.geometry as BufferGeometry).attributes as any).position // TODO\n const array = position.array\n const {min, max} = this.boundingBox\n\n array[ 0 ] = max.x; array[ 1 ] = max.y; array[ 2 ] = max.z\n array[ 3 ] = min.x; array[ 4 ] = max.y; array[ 5 ] = max.z\n array[ 6 ] = min.x; array[ 7 ] = min.y; array[ 8 ] = max.z\n array[ 9 ] = max.x; array[ 10 ] = min.y; array[ 11 ] = max.z\n array[ 12 ] = max.x; array[ 13 ] = max.y; array[ 14 ] = min.z\n array[ 15 ] = min.x; array[ 16 ] = max.y; array[ 17 ] = min.z\n array[ 18 ] = min.x; array[ 19 ] = min.y; array[ 20 ] = min.z\n array[ 21 ] = max.x; array[ 22 ] = min.y; array[ 23 ] = min.z\n\n position.needsUpdate = true\n\n if (!this.boundingBox.isEmpty()) {\n this.boundingBoxMesh.geometry.computeBoundingSphere()\n }\n }\n\n /** Distance from origin (lookAt point) */\n get cameraDistance(): number {\n return Math.abs(this.camera.position.z)\n }\n\n /** Set distance from origin (lookAt point); along the -z axis */\n set cameraDistance(d: number) {\n this.camera.position.z = -d\n }\n\n add (buffer: Buffer, instanceList?: BufferInstance[]) {\n // Log.time( \"Viewer.add\" );\n\n if (instanceList) {\n instanceList.forEach(instance => this.addBuffer(buffer, instance))\n } else {\n this.addBuffer(buffer)\n }\n\n buffer.group.name = 'meshGroup'\n buffer.wireframeGroup.name = 'wireframeGroup'\n if (buffer.parameters.background) {\n this.backgroundGroup.add(buffer.group)\n this.backgroundGroup.add(buffer.wireframeGroup)\n } else {\n this.modelGroup.add(buffer.group)\n this.modelGroup.add(buffer.wireframeGroup)\n }\n\n if (buffer.pickable) {\n this.pickingGroup.add(buffer.pickingGroup)\n }\n\n if (Debug) this.updateHelper()\n\n // Log.timeEnd( \"Viewer.add\" );\n }\n\n addBuffer (buffer: Buffer, instance?: BufferInstance) {\n // Log.time( \"Viewer.addBuffer\" );\n\n function setUserData (object: Object3D) {\n if (object instanceof Group) {\n object.children.forEach(setUserData)\n } else {\n object.userData.buffer = buffer\n object.userData.instance = instance\n object.onBeforeRender = onBeforeRender\n }\n }\n\n const mesh = buffer.getMesh()\n if (instance) {\n mesh.applyMatrix4(instance.matrix)\n }\n setUserData(mesh)\n buffer.group.add(mesh)\n\n const wireframeMesh = buffer.getWireframeMesh()\n if (instance) {\n // wireframeMesh.applyMatrix( instance.matrix );\n wireframeMesh.matrix.copy(mesh.matrix)\n wireframeMesh.position.copy(mesh.position)\n wireframeMesh.quaternion.copy(mesh.quaternion)\n wireframeMesh.scale.copy(mesh.scale)\n }\n setUserData(wireframeMesh)\n buffer.wireframeGroup.add(wireframeMesh)\n\n if (buffer.pickable) {\n const pickingMesh = buffer.getPickingMesh()\n if (instance) {\n // pickingMesh.applyMatrix( instance.matrix );\n pickingMesh.matrix.copy(mesh.matrix)\n pickingMesh.position.copy(mesh.position)\n pickingMesh.quaternion.copy(mesh.quaternion)\n pickingMesh.scale.copy(mesh.scale)\n }\n setUserData(pickingMesh)\n buffer.pickingGroup.add(pickingMesh)\n }\n\n if (instance) {\n this._updateBoundingBox(buffer.geometry, buffer.matrix, instance.matrix)\n } else {\n this._updateBoundingBox(buffer.geometry, buffer.matrix)\n }\n\n // Log.timeEnd( \"Viewer.addBuffer\" );\n }\n\n remove (buffer: Buffer) {\n this.translationGroup.children.forEach(function (group) {\n group.remove(buffer.group)\n group.remove(buffer.wireframeGroup)\n })\n\n if (buffer.pickable) {\n this.pickingGroup.remove(buffer.pickingGroup)\n }\n\n this.updateBoundingBox()\n if (Debug) this.updateHelper()\n\n // this.requestRender();\n }\n\n private _updateBoundingBox (geometry?: BufferGeometry, matrix?: Matrix4, instanceMatrix?: Matrix4) {\n const boundingBox = this.boundingBox\n\n function updateGeometry (geometry: BufferGeometry, matrix?: Matrix4, instanceMatrix?: Matrix4) {\n if (geometry.boundingBox == null) {\n geometry.computeBoundingBox()\n }\n\n const geoBoundingBox = (geometry.boundingBox as Box3).clone()\n\n if (matrix) {\n geoBoundingBox.applyMatrix4(matrix)\n }\n if (instanceMatrix) {\n geoBoundingBox.applyMatrix4(instanceMatrix)\n }\n\n if (geoBoundingBox.min.equals(geoBoundingBox.max)) {\n // mainly to give a single impostor geometry some volume\n // as it is only expanded in the shader on the GPU\n geoBoundingBox.expandByScalar(5)\n }\n\n boundingBox.union(geoBoundingBox)\n }\n\n function updateNode (node: Mesh) {\n if (node.geometry !== undefined) {\n let matrix, instanceMatrix\n if (node.userData.buffer) {\n matrix = node.userData.buffer.matrix\n }\n if (node.userData.instance) {\n instanceMatrix = node.userData.instance.matrix\n }\n updateGeometry(node.geometry as BufferGeometry, matrix, instanceMatrix) // TODO\n }\n }\n\n if (geometry) {\n updateGeometry(geometry, matrix, instanceMatrix)\n } else {\n boundingBox.makeEmpty()\n this.modelGroup.traverse(updateNode)\n this.backgroundGroup.traverse(updateNode)\n }\n\n boundingBox.getSize(this.boundingBoxSize)\n this.boundingBoxLength = this.boundingBoxSize.length()\n }\n\n updateBoundingBox () {\n this._updateBoundingBox()\n if (Debug) this.updateHelper()\n }\n\n getPickingPixels () {\n const {width, height} = this\n\n const n = width * height * 4\n const imgBuffer = SupportsReadPixelsFloat ? new Float32Array(n) : new Uint8Array(n)\n\n this.render(true)\n this.renderer.readRenderTargetPixels(\n this.pickingTarget, 0, 0, width, height, imgBuffer\n )\n\n return imgBuffer\n }\n\n getImage (picking: boolean) {\n return new Promise(resolve => {\n if (picking) {\n const {width, height} = this\n const n = width * height * 4\n let imgBuffer = this.getPickingPixels()\n\n if (SupportsReadPixelsFloat) {\n const imgBuffer2 = new Uint8Array(n)\n for (let i = 0; i < n; ++i) {\n imgBuffer2[ i ] = Math.round(imgBuffer[ i ] * 255)\n }\n imgBuffer = imgBuffer2\n }\n\n const canvas = document.createElement('canvas')\n canvas.width = width\n canvas.height = height\n const ctx = canvas.getContext('2d')! // TODO\n const imgData = ctx.getImageData(0, 0, width, height)\n imgData.data.set(imgBuffer as any) // TODO\n ctx.putImageData(imgData, 0, 0)\n canvas.toBlob(resolve as any, 'image/png') // TODO\n } else {\n this.renderer.domElement.toBlob(resolve as any, 'image/png') // TODO\n }\n })\n }\n\n makeImage (params: Partial = {}) {\n return makeImage(this, params)\n }\n\n setLight (color: Color|number|string, intensity: number, ambientColor: Color|number|string, ambientIntensity: number) {\n const p = this.parameters\n\n if (color !== undefined) p.lightColor.set(color as string) // TODO\n if (intensity !== undefined) p.lightIntensity = intensity\n if (ambientColor !== undefined) p.ambientColor.set(ambientColor as string) // TODO\n if (ambientIntensity !== undefined) p.ambientIntensity = ambientIntensity\n\n this.requestRender()\n }\n\n setFog (color?: Color|number|string, near?: number, far?: number) {\n const p = this.parameters\n\n if (color !== undefined) p.fogColor.set(color as string) // TODO\n if (near !== undefined) p.fogNear = near\n if (far !== undefined) p.fogFar = far\n\n this.requestRender()\n }\n\n setBackground (color?: Color|number|string) {\n const p = this.parameters\n\n if (color) p.backgroundColor.set(color as string) // TODO\n\n this.setFog(p.backgroundColor)\n this.renderer.setClearColor(p.backgroundColor, 0)\n this.renderer.domElement.style.backgroundColor = p.backgroundColor.getStyle()\n\n this.requestRender()\n }\n\n setSampling (level: number) {\n if (level !== undefined) {\n this.parameters.sampleLevel = level\n this.sampleLevel = level\n }\n\n this.requestRender()\n }\n\n /**\n * Set the output color encoding, i.e. how the renderer translates\n * colorspaces as it renders to the screen.\n\n * The default is LinearEncoding, because the internals of NGL are\n * already sRGB so no translation is needed to show sRGB colors.\n * Set to sRGBEncoding to create a linear workflow, and also call\n * `setColorEncoding(LinearEncoding)` to linearize colors on input.\n * @see setColorEncoding\n */\n private setOutputEncoding (encoding: TextureEncoding) {\n this.parameters.rendererEncoding = encoding\n this.renderer.outputEncoding = encoding\n this.pickingTarget.texture.encoding = encoding\n this.sampleTarget.texture.encoding = encoding\n this.holdTarget.texture.encoding = encoding\n }\n\n /**\n * Set the internal color workflow, linear or sRGB.\n * sRGB, the default, is more \"vibrant\" at the cost of accuracy.\n * Linear gives more accurate results, especially for transparent objects.\n * In all cases, the output is always sRGB; this just affects how colors are computed internally.\n * Call this just after creating the viewer, before loading any models.\n */\n setColorWorkflow (encoding: ColorWorkflow) {\n if (encoding != 'linear' && encoding != 'sRGB')\n throw new Error(`setColorWorkflow: invalid color workflow ${encoding}`)\n setColorSpace(encoding == 'linear' ? 'linear' : 'sRGB')\n this.setOutputEncoding(encoding == 'linear' ? sRGBEncoding : LinearEncoding)\n // Note: this doesn't rebuild models, so existing geometry will have\n // the old color encoding.\n this.requestRender()\n }\n\n setCamera (type: CameraType, fov?: number, eyeSep?: number) {\n const p = this.parameters\n\n if (type) p.cameraType = type\n if (fov) p.cameraFov = fov\n if (eyeSep) p.cameraEyeSep = eyeSep\n\n if (p.cameraType === 'orthographic') {\n if (this.camera !== this.orthographicCamera) {\n this.camera = this.orthographicCamera\n this.camera.position.copy(this.perspectiveCamera.position)\n this.camera.up.copy(this.perspectiveCamera.up)\n this.updateZoom()\n }\n } else if (p.cameraType === 'perspective' || p.cameraType === 'stereo') {\n if (this.camera !== this.perspectiveCamera) {\n this.camera = this.perspectiveCamera\n this.camera.position.copy(this.orthographicCamera.position)\n this.camera.up.copy(this.orthographicCamera.up)\n }\n } else {\n throw new Error(`Unknown cameraType '${p.cameraType}'`)\n }\n\n this.perspectiveCamera.fov = p.cameraFov\n this.stereoCamera.eyeSep = p.cameraEyeSep\n this.camera.updateProjectionMatrix()\n\n this.requestRender()\n }\n\n setClip (near: number, far: number, dist: number, clipMode?: string, clipScale?: string) {\n const p = this.parameters\n\n if (near !== undefined) p.clipNear = near\n if (far !== undefined) p.clipFar = far\n if (dist !== undefined) p.clipDist = dist\n if (clipMode !== undefined) p.clipMode = clipMode\n if (clipScale !== undefined) p.clipScale = clipScale\n\n this.requestRender()\n }\n\n setSize (width: number, height: number) {\n this.width = width || 1\n this.height = height || 1\n\n this.perspectiveCamera.aspect = this.width / this.height\n this.orthographicCamera.left = -this.width / 2\n this.orthographicCamera.right = this.width / 2\n this.orthographicCamera.top = this.height / 2\n this.orthographicCamera.bottom = -this.height / 2\n this.camera.updateProjectionMatrix()\n\n const dpr = window.devicePixelRatio\n\n this.renderer.setPixelRatio(dpr)\n this.renderer.setSize(width, height)\n\n const dprWidth = this.width * dpr\n const dprHeight = this.height * dpr\n\n this.pickingTarget.setSize(dprWidth, dprHeight)\n this.sampleTarget.setSize(dprWidth, dprHeight)\n this.holdTarget.setSize(dprWidth, dprHeight)\n\n this.requestRender()\n }\n\n handleResize () {\n if (this.container === document.body) {\n this.setSize(window.innerWidth, window.innerHeight)\n } else {\n const box = this.container.getBoundingClientRect()\n this.setSize(box.width, box.height)\n }\n }\n\n updateInfo (reset?: boolean) {\n const { memory, render } = this.info\n\n if (reset) {\n memory.programs = 0\n memory.geometries = 0\n memory.textures = 0\n\n render.calls = 0\n render.vertices = 0\n render.points = 0\n } else {\n const rInfo = this.renderer.info\n const rMemory = rInfo.memory\n const rRender = rInfo.render\n\n memory.geometries = rMemory.geometries\n memory.textures = rMemory.textures\n\n render.calls += rRender.calls\n render.faces += rRender.triangles\n render.points += rRender.points\n }\n }\n\n animate () {\n this.signals.ticked.dispatch(this.stats)\n const delta = window.performance.now() - this.stats.startTime\n\n if (delta > 500 && !this.isStill && this.sampleLevel < 3 && this.sampleLevel !== -1) {\n const currentSampleLevel = this.sampleLevel\n this.sampleLevel = 3\n this.renderPending = true\n this.render()\n this.isStill = true\n this.sampleLevel = currentSampleLevel\n if (Debug) Log.log('rendered still frame')\n }\n\n this.frameRequest = window.requestAnimationFrame(this.animate)\n }\n\n pick (x: number, y: number) {\n if (this.parameters.cameraType === 'stereo') {\n // TODO picking broken for stereo camera\n return {\n 'pid': 0,\n 'instance': undefined,\n 'picker': undefined\n }\n }\n\n x *= window.devicePixelRatio\n y *= window.devicePixelRatio\n\n x = Math.max(x - 2, 0)\n y = Math.max(y - 2, 0)\n\n let pid = 0, instance, picker\n const pixelBuffer = SupportsReadPixelsFloat ? pixelBufferFloat : pixelBufferUint\n\n this.render(true)\n this.renderer.readRenderTargetPixels(\n this.pickingTarget, x, y, 5, 5, pixelBuffer\n )\n\n for (let i = 0; i < pixelOrder.length; i++) {\n\n const offset = pixelOrder[i] * 4\n\n const oid = Math.round(pixelBuffer[ offset + 3 ])\n const object = this.pickingGroup.getObjectById(oid)\n if (object) {\n instance = object.userData.instance\n picker = object.userData.buffer.picking\n } else {\n continue\n }\n\n if (SupportsReadPixelsFloat) {\n pid =\n ((Math.round(pixelBuffer[offset] * 255) << 16) & 0xFF0000) |\n ((Math.round(pixelBuffer[offset + 1] * 255) << 8) & 0x00FF00) |\n ((Math.round(pixelBuffer[offset + 2] * 255)) & 0x0000FF)\n } else {\n pid =\n (pixelBuffer[offset] << 16) |\n (pixelBuffer[offset + 1] << 8) |\n (pixelBuffer[offset + 2])\n }\n }\n // if( Debug ){\n // const rgba = Array.apply( [], pixelBuffer );\n // Log.log( pixelBuffer );\n // Log.log(\n // \"picked color\",\n // rgba.map( c => { return c.toPrecision( 2 ) } )\n // );\n // Log.log( \"picked pid\", pid );\n // Log.log( \"picked oid\", oid );\n // Log.log( \"picked object\", object );\n // Log.log( \"picked instance\", instance );\n // Log.log( \"picked position\", x, y );\n // Log.log( \"devicePixelRatio\", window.devicePixelRatio );\n // }\n\n return { pid, instance, picker }\n }\n\n requestRender () {\n if (this.renderPending) {\n // Log.info(\"there is still a 'render' call pending\")\n return\n }\n\n // start gathering stats anew after inactivity\n if (window.performance.now() - this.stats.startTime > 22) {\n this.stats.begin()\n this.isStill = false\n }\n\n this.renderPending = true\n\n window.requestAnimationFrame(() => {\n this.render()\n this.stats.update()\n })\n }\n\n updateZoom () {\n const fov = degToRad(this.perspectiveCamera.fov)\n const height = 2 * Math.tan(fov / 2) * this.cameraDistance\n this.orthographicCamera.zoom = this.height / height\n }\n\n /**\n * Convert an absolute clip value to a relative one using bRadius.\n *\n * 0.0 -> 50.0\n * bRadius -> 0.0\n */\n absoluteToRelative (d: number) :number {\n return 50 * (1 - d / this.bRadius)\n }\n\n /**\n * Convert a relative clip value to an absolute one using bRadius\n *\n * 0.0 -> bRadius\n * 50.0 -> 0.0\n */\n relativeToAbsolute (d: number) : number {\n return this.bRadius * (1 - d / 50)\n }\n\n /**\n * Intepret clipMode, clipScale and set the camera and fog clipping.\n * Also ensures bRadius and cDist are valid\n */\n private __updateClipping () {\n const p = this.parameters\n\n // bRadius must always be updated for material-based clipping\n // and for focus calculations\n this.bRadius = Math.max(10, this.boundingBoxLength * 0.5)\n\n // FL: Removed below, but leaving commented as I don't understand intention\n // this.bRadius += this.boundingBox.getCenter(this.distVector).length()\n\n if (!isFinite(this.bRadius)) {\n this.bRadius = 50\n }\n\n this.camera.getWorldPosition(this.distVector)\n this.cDist = this.distVector.length()\n if (!this.cDist) {\n // recover from a broken (NaN) camera position\n this.cameraDistance = Math.abs(p.cameraZ)\n this.cDist = Math.abs(p.cameraZ)\n }\n\n // fog\n const fog = this.scene.fog as Fog\n fog.color.set(p.fogColor)\n\n if (p.clipMode === 'camera') {\n // Always interpret clipScale as absolute for clipMode camera\n\n this.camera.near = p.clipNear\n this.camera.far = p.clipFar\n fog.near = p.fogNear\n fog.far = p.fogFar\n\n } else {\n // scene mode\n\n if (p.clipScale === 'absolute') {\n // absolute scene mode; offset clip planes from scene center\n // (note: positive values move near plane towards camera and rear plane away)\n\n this.camera.near = this.cDist - p.clipNear\n this.camera.far = this.cDist + p.clipFar\n fog.near = this.cDist - p.fogNear\n fog.far = this.cDist + p.fogFar\n\n } else {\n // relative scene mode (default): convert pecentages to Angstroms\n\n const nearFactor = (50 - p.clipNear) / 50\n const farFactor = -(50 - p.clipFar) / 50\n this.camera.near = this.cDist - (this.bRadius * nearFactor)\n this.camera.far = this.cDist + (this.bRadius * farFactor)\n\n const fogNearFactor = (50 - p.fogNear) / 50\n const fogFarFactor = -(50 - p.fogFar) / 50\n fog.near = this.cDist - (this.bRadius * fogNearFactor)\n fog.far = this.cDist + (this.bRadius * fogFarFactor)\n }\n }\n\n if (p.clipMode !== 'camera') {\n\n if (this.camera.type === 'PerspectiveCamera') {\n\n this.camera.near = Math.max(0.1, p.clipDist, this.camera.near)\n this.camera.far = Math.max(1, this.camera.far)\n fog.near = Math.max(0.1, fog.near)\n fog.far = Math.max(1, fog.far)\n } else if (this.camera.type === 'OrthographicCamera') {\n\n if (p.clipDist > 0) {\n this.camera.near = Math.max(p.clipDist, this.camera.near)\n }\n }\n }\n }\n\n private __updateCamera () {\n const camera = this.camera\n camera.updateMatrix()\n camera.updateMatrixWorld(true)\n camera.updateProjectionMatrix()\n\n updateMaterialUniforms(this.scene, camera, this.renderer, this.cDist, this.bRadius)\n sortProjectedPosition(this.scene, camera)\n }\n\n private __setVisibility (model: boolean, picking: boolean, background: boolean, helper: boolean) {\n this.modelGroup.visible = model\n this.pickingGroup.visible = picking\n this.backgroundGroup.visible = background\n this.helperGroup.visible = helper\n }\n\n private __updateLights () {\n this.spotLight.color.set(this.parameters.lightColor)\n this.spotLight.intensity = this.parameters.lightIntensity\n\n this.distVector.copy(this.camera.position).setLength(this.boundingBoxLength * 100)\n this.spotLight.position.copy(this.camera.position).add(this.distVector)\n\n this.ambientLight.color.set(this.parameters.ambientColor)\n this.ambientLight.intensity = this.parameters.ambientIntensity\n }\n\n private __renderPickingGroup (camera: PerspectiveCamera|OrthographicCamera) {\n this.renderer.setRenderTarget(this.pickingTarget || null)\n this.renderer.clear()\n this.__setVisibility(false, true, false, false)\n this.renderer.render(this.scene, camera)\n // back to standard render target\n this.renderer.setRenderTarget(null)\n this.updateInfo()\n\n // if (Debug) {\n // this.__setVisibility(false, true, false, true);\n\n // this.renderer.clear();\n // this.renderer.render(this.scene, camera);\n // }\n }\n\n private __renderModelGroup (camera: PerspectiveCamera|OrthographicCamera, renderTarget?: WebGLRenderTarget) {\n this.renderer.setRenderTarget(renderTarget || null)\n this.renderer.clear()\n this.__setVisibility(false, false, true, false)\n this.renderer.render(this.scene, camera)\n this.renderer.clear(false, true, true)\n this.updateInfo()\n\n this.__setVisibility(true, false, false, Debug)\n this.renderer.render(this.scene, camera)\n this.renderer.setRenderTarget(null) // set back to default canvas\n this.updateInfo()\n }\n\n private __renderSuperSample (camera: PerspectiveCamera|OrthographicCamera, renderTarget?: WebGLRenderTarget) {\n // based on the Supersample Anti-Aliasing Render Pass\n // contributed to three.js by bhouston / http://clara.io/\n //\n // This manual approach to SSAA re-renders the scene ones for\n // each sample with camera jitter and accumulates the results.\n // References: https://en.wikipedia.org/wiki/Supersampling\n const offsetList = JitterVectors[ Math.max(0, Math.min(this.sampleLevel, 5)) ]\n\n const baseSampleWeight = 1.0 / offsetList.length\n const roundingRange = 1 / 32\n\n this.compositeUniforms.tForeground.value = this.sampleTarget.texture\n\n let width = this.sampleTarget.width\n const height = this.sampleTarget.height\n if (this.parameters.cameraType === 'stereo') {\n width /= 2\n }\n\n // render the scene multiple times, each slightly jitter offset\n // from the last and accumulate the results.\n for (let i = 0; i < offsetList.length; ++i) {\n const offset = offsetList[ i ]\n camera.setViewOffset(\n width, height, offset[ 0 ], offset[ 1 ], width, height\n )\n camera.updateProjectionMatrix()\n updateCameraUniforms(this.scene, camera)\n\n let sampleWeight = baseSampleWeight\n // the theory is that equal weights for each sample lead to an\n // accumulation of rounding errors.\n // The following equation varies the sampleWeight per sample\n // so that it is uniformly distributed across a range of values\n // whose rounding errors cancel each other out.\n const uniformCenteredDistribution = -0.5 + (i + 0.5) / offsetList.length\n sampleWeight += roundingRange * uniformCenteredDistribution\n this.compositeUniforms.scale.value = sampleWeight\n\n this.__renderModelGroup(camera, this.sampleTarget)\n this.renderer.setRenderTarget(this.holdTarget)\n if (i === 0) {\n this.renderer.clear()\n }\n\n this.renderer.render(this.compositeScene, this.compositeCamera)\n }\n\n this.compositeUniforms.scale.value = 1.0\n this.compositeUniforms.tForeground.value = this.holdTarget.texture\n\n camera.clearViewOffset()\n this.renderer.setRenderTarget(renderTarget || null)\n this.renderer.clear()\n this.renderer.render(this.compositeScene, this.compositeCamera)\n }\n\n private __renderStereo (picking = false, _renderTarget?: WebGLRenderTarget) {\n const stereoCamera = this.stereoCamera\n stereoCamera.update(this.perspectiveCamera);\n\n const renderer = this.renderer\n let size = new Vector2()\n renderer.getSize(size)\n\n renderer.setScissorTest(true)\n\n renderer.setScissor(0, 0, size.width / 2, size.height)\n renderer.setViewport(0, 0, size.width / 2, size.height)\n updateCameraUniforms(this.scene, stereoCamera.cameraL)\n this.__render(picking, stereoCamera.cameraL)\n\n renderer.setScissor(size.width / 2, 0, size.width / 2, size.height)\n renderer.setViewport(size.width / 2, 0, size.width / 2, size.height)\n updateCameraUniforms(this.scene, stereoCamera.cameraR)\n this.__render(picking, stereoCamera.cameraR)\n\n renderer.setScissorTest(false)\n renderer.setViewport(0, 0, size.width, size.height)\n }\n\n private __render(picking = false, camera: PerspectiveCamera|OrthographicCamera, renderTarget?: WebGLRenderTarget) {\n if (picking) {\n if (!this.lastRenderedPicking) this.__renderPickingGroup(camera)\n } else if (this.sampleLevel > 0 && this.parameters.cameraType !== 'stereo') {\n // TODO super sample broken for stereo camera\n this.__renderSuperSample(camera, renderTarget)\n } else {\n this.__renderModelGroup(camera, renderTarget)\n }\n }\n\n render (picking = false, renderTarget?: WebGLRenderTarget) {\n if (this.rendering) {\n Log.warn(\"'tried to call 'render' from within 'render'\")\n return\n }\n\n // Log.time('Viewer.render')\n\n this.rendering = true\n\n try {\n this.__updateClipping()\n this.__updateCamera()\n this.__updateLights()\n this.updateInfo(true)\n\n // render\n if (this.parameters.cameraType === 'stereo') {\n this.__renderStereo(picking, renderTarget)\n } else {\n this.__render(picking, this.camera, renderTarget)\n }\n this.lastRenderedPicking = picking\n } finally {\n this.rendering = false\n this.renderPending = false\n }\n this.signals.rendered.dispatch()\n\n // Log.timeEnd('Viewer.render')\n // Log.log(this.info.memory, this.info.render)\n }\n\n clear () {\n Log.log('scene cleared')\n this.scene.remove(this.rotationGroup)\n this._initScene()\n this.renderer.clear()\n }\n\n dispose () {\n this.renderer.dispose()\n window.cancelAnimationFrame(this.frameRequest)\n }\n}\n","/**\n * @file Constants\n * @author Alexander Rose \n * @private\n */\n\nexport const LeftMouseButton = 1\nexport const MiddleMouseButton = 2\nexport const RightMouseButton = 3\n","/**\n * @file Mouse Observer\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector2 } from 'three'\nimport { Signal } from 'signals'\n\nimport { LeftMouseButton, RightMouseButton } from '../constants'\nimport { defaults } from '../utils'\nimport Viewer from '../viewer/viewer'\nimport MouseControls from '../controls/mouse-controls'\n\ntype Optional = Pick, K> & Omit;\n\n/**\n * @example\n * mouseObserver.signals.scrolled.add( function( delta ){ ... } );\n *\n * @typedef {Object} MouseSignals\n * @property {Signal} moved - on move: deltaX, deltaY\n * @property {Signal} scrolled - on scroll: delta\n * @property {Signal} dragged - on drag: deltaX, deltaY\n * @property {Signal} dropped - on drop\n * @property {Signal} clicked - on click\n * @property {Signal} hovered - on hover\n */\n\nfunction getTouchDistance (event: TouchEvent) {\n const dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX\n const dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY\n return Math.sqrt(dx * dx + dy * dy)\n}\n\nfunction getMouseButtons (event: MouseEvent) {\n if (typeof event === 'object') {\n if ('buttons' in event) {\n return event.buttons\n } else if ('which' in event as any) {\n const b = (event as any).which\n if (b === 2) {\n return 4\n } else if (b === 3) {\n return 2\n } else if (b > 0) {\n return 1 << (b - 1)\n }\n } else if ('button' in event as any) {\n const b = (event as any).button\n if (b === 1) {\n return 4\n } else if (b === 2) {\n return 2\n } else if (b >= 0) {\n return 1 << b\n }\n }\n }\n return 0\n}\n\nexport interface MouseSignals {\n moved: Signal // on move: deltaX, deltaY\n scrolled: Signal // on scroll: delta\n dragged: Signal // on drag: deltaX, deltaY\n dropped: Signal // on drop\n clicked: Signal // on click\n hovered: Signal // on hover\n doubleClicked: Signal\n}\n\nexport interface MouseParams {\n hoverTimeout?: number\n handleScroll?:boolean\n doubleClickSpeed?: number\n}\n\n/**\n * Mouse observer\n *\n * @example\n * // listen to mouse moving (and touch-moving) events\n * mouseObserver.moved.moved.add( function( deltaX, deltaY ){ ... } );\n *\n * @example\n * // listen to scrolling (and pinching) events\n * mouseObserver.signals.scrolled.add( function( delta ){ ... } );\n *\n * @example\n * // listen to dragging (and touch-dragging) events\n * mouseObserver.signals.dragged.add( function( deltaX, deltaY ){ ... } );\n *\n * @example\n * // listen to clicking (and tapping) events\n * mouseObserver.signals.clicked.add( function(){ ... } );\n *\n * @example\n * // listen to double clicking (and double tapping) events\n * mouseObserver.signals.doubleClicked.add( function(){ ... } );\n *\n * @example\n * // listen to hovering events\n * mouseObserver.signals.hovered.add( function(){ ... } );\n */\nclass MouseObserver {\n signals: MouseSignals = {\n moved: new Signal(),\n scrolled: new Signal(),\n dragged: new Signal(),\n dropped: new Signal(),\n clicked: new Signal(),\n hovered: new Signal(),\n doubleClicked: new Signal()\n }\n\n hoverTimeout: number\n handleScroll:boolean\n doubleClickSpeed: number\n\n viewer: Viewer\n mouse: MouseObserver\n controls: MouseControls\n\n position = new Vector2() // Position on page\n prevPosition = new Vector2() // Previous position on page\n down = new Vector2() // Position on page when clicked\n canvasPosition = new Vector2() // Position on dom element\n prevClickCP = new Vector2()\n\n moving = false // Flag indicating if the mouse is moving\n hovering = true // Flag indicating if the mouse is hovering\n scrolled = false // Flag indicating if there was a scolling event since the last mouse move\n lastMoved = Infinity // Timestamp of last mouse move\n which? = 0 // 0: No button; 1: Left button; 2: Middle button; 3: Right button\n buttons? = 0 // 0: No button; 1: Left button; 2: Right button; 4: Middle button\n pressed? = false // Flag indicating if the mouse is pressed down\n altKey = false // Flag indicating if the alt key is pressed\n ctrlKey = false // Flag indicating if the ctrl key is pressed\n metaKey = false // Flag indicating if the meta key is pressed\n shiftKey = false // Flag indicating if the shift key is pressed\n\n doubleClickPending: boolean\n lastClicked: number\n overElement: boolean\n lastTouchDistance: number\n private frameRequest: number\n\n /**\n * @param {Element} domElement - the dom element to observe mouse events in\n * @param {Object} params - parameters object\n * @param {Integer} params.hoverTimeout - timeout in ms until the {@link MouseSignals.hovered}\n * signal is fired, set to -1 to ignore hovering\n * @param {Boolean} params.handleScroll - whether or not to handle scroll events\n * @param {Integer} params.doubleClickSpeed - max time in ms to trigger double click\n */\n constructor (readonly domElement: HTMLCanvasElement, params: MouseParams = {}) {\n this.domElement.style.touchAction = 'none'\n\n this.hoverTimeout = defaults(params.hoverTimeout, 50)\n this.handleScroll = defaults(params.handleScroll, true)\n this.doubleClickSpeed = defaults(params.doubleClickSpeed, 500)\n\n this._listen = this._listen.bind(this)\n this._onMousewheel = this._onMousewheel.bind(this)\n this._onMousemove = this._onMousemove.bind(this)\n this._onMousedown = this._onMousedown.bind(this)\n this._onMouseup = this._onMouseup.bind(this)\n this._onContextmenu = this._onContextmenu.bind(this)\n this._onTouchstart = this._onTouchstart.bind(this)\n this._onTouchend = this._onTouchend.bind(this)\n this._onTouchmove = this._onTouchmove.bind(this)\n\n this._listen()\n\n const opt = { passive: false } // treat as 'passive' so preventDefault can be called\n document.addEventListener('mousewheel', this._onMousewheel, opt)\n document.addEventListener('wheel', this._onMousewheel, opt)\n document.addEventListener('MozMousePixelScroll', this._onMousewheel, opt)\n document.addEventListener('mousemove', this._onMousemove, opt)\n document.addEventListener('mousedown', this._onMousedown, opt)\n document.addEventListener('mouseup', this._onMouseup, opt)\n document.addEventListener('contextmenu', this._onContextmenu, opt)\n document.addEventListener('touchstart', this._onTouchstart, opt)\n document.addEventListener('touchend', this._onTouchend, opt)\n document.addEventListener('touchmove', this._onTouchmove, opt)\n }\n\n get key () {\n let key = 0\n if (this.altKey) key += 1\n if (this.ctrlKey) key += 2\n if (this.metaKey) key += 4\n if (this.shiftKey) key += 8\n return key\n }\n\n setParameters (params: MouseParams = {}) {\n this.hoverTimeout = defaults(params.hoverTimeout, this.hoverTimeout)\n }\n\n /**\n * listen to mouse actions\n * @emits {MouseSignals.clicked} when clicked\n * @emits {MouseSignals.hovered} when hovered\n * @return {undefined}\n */\n _listen () {\n const now = window.performance.now()\n const cp = this.canvasPosition\n if (this.doubleClickPending && now - this.lastClicked > this.doubleClickSpeed) {\n this.doubleClickPending = false\n }\n if (now - this.lastMoved > this.hoverTimeout) {\n this.moving = false\n }\n if (this.scrolled || (!this.moving && !this.hovering)) {\n this.scrolled = false\n if (this.hoverTimeout !== -1 && this.overElement) {\n this.hovering = true\n this.signals.hovered.dispatch(cp.x, cp.y)\n }\n }\n this.frameRequest = window.requestAnimationFrame(this._listen)\n }\n\n /**\n * handle mouse scroll\n * @emits {MouseSignals.scrolled} when scrolled\n * @param {Event} event - mouse event\n * @return {undefined}\n */\n _onMousewheel(event: Optional & { wheelDelta?: number, wheelDeltaY?: number }) {\n if (event.target !== this.domElement || !this.handleScroll) {\n return\n }\n event.preventDefault()\n this._setKeys(event as any)\n\n let delta = 0\n // This has to be written in a particular way to handle old browsers that\n // all send events with different properties set in different ways.\n if ('deltaY' in event && 'deltaMode' in event &&\n event.deltaY !== undefined && event.deltaMode !== undefined) {\n // all modern browsers, using WheelEvent; deltaY + down (toward user)\n if (event.deltaMode === WheelEvent.DOM_DELTA_PIXEL)\n // everything except Firefox: normally 100 per wheel click\n delta = -event.deltaY * (2.5 / 100.0)\n else if (event.deltaMode === WheelEvent.DOM_DELTA_LINE)\n // Firefox in line mode, normally 3 per wheel click\n delta = -event.deltaY * (2.5 / 3.0)\n else // page mode: 1 per wheel click\n delta = -event.deltaY * 2.5\n } else if ('deltaY' in event && !('detail' in event)) {\n // Old Firefox or IE 11: deltaY but no deltaMode; treat as pixels\n delta = -event.deltaY * (2.5 / 100.0)\n } else if (event.wheelDelta !== undefined) {\n delta = -event.wheelDelta * (2.5 / 100)\n } else if (event.wheelDeltaY !== undefined) {\n delta = -event.wheelDeltaY * (2.5 / 100)\n } else if (event.detail !== undefined){\n // Old Firefox, MouseWheelEvent\n delta = -event.detail / 3\n }\n this.signals.scrolled.dispatch(delta)\n\n setTimeout(() => {\n this.scrolled = true\n }, this.hoverTimeout)\n }\n\n /**\n * handle mouse move\n * @emits {MouseSignals.moved} when moved\n * @emits {MouseSignals.dragged} when dragged\n * @param {Event} event - mouse event\n * @return {undefined}\n */\n _onMousemove (event: MouseEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n this.overElement = true\n } else {\n this.overElement = false\n }\n this._setKeys(event)\n this.moving = true\n this.hovering = false\n this.lastMoved = window.performance.now()\n this.prevPosition.copy(this.position)\n this.position.set(event.clientX, event.clientY)\n this._setCanvasPosition(event)\n const dx = this.prevPosition.x - this.position.x\n const dy = this.prevPosition.y - this.position.y\n this.signals.moved.dispatch(dx, dy)\n if (this.pressed) {\n this.signals.dragged.dispatch(dx, dy)\n }\n }\n\n _onMousedown (event: MouseEvent) {\n if (event.target !== this.domElement) {\n return\n }\n event.preventDefault()\n this._setKeys(event)\n this.moving = false\n this.hovering = false\n this.down.set(event.clientX, event.clientY)\n this.position.set(event.clientX, event.clientY)\n this.which = event.which\n this.buttons = getMouseButtons(event)\n this.pressed = true\n this._setCanvasPosition(event)\n }\n\n /**\n * handle mouse up\n * @emits {MouseSignals.doubleClicked} when double clicked\n * @emits {MouseSignals.dropped} when dropped\n * @param {Event} event - mouse event\n * @return {undefined}\n */\n _onMouseup (event: MouseEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n }\n this._setKeys(event)\n const cp = this.canvasPosition\n if (this._distance() < 4) {\n this.lastClicked = window.performance.now()\n if (this.doubleClickPending && this.prevClickCP.distanceTo(cp) < 4) {\n this.signals.doubleClicked.dispatch(cp.x, cp.y)\n this.doubleClickPending = false\n }\n this.signals.clicked.dispatch(cp.x, cp.y)\n this.doubleClickPending = true\n this.prevClickCP.copy(cp)\n }\n this.which = undefined\n this.buttons = undefined\n this.pressed = undefined\n // if (this._distance() > 3 || event.which === RightMouseButton) {\n // this.signals.dropped.dispatch();\n // }\n }\n\n _onContextmenu (event: MouseEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n }\n }\n\n _onTouchstart (event: TouchEvent) {\n if (event.target !== this.domElement) {\n return\n }\n event.preventDefault()\n this.pressed = true\n switch (event.touches.length) {\n case 1: {\n this.moving = false\n this.hovering = false\n this.down.set(\n event.touches[ 0 ].pageX,\n event.touches[ 0 ].pageY\n )\n this.position.set(\n event.touches[ 0 ].pageX,\n event.touches[ 0 ].pageY\n )\n this._setCanvasPosition(event.touches[ 0 ])\n break\n }\n\n case 2: {\n this.down.set(\n (event.touches[ 0 ].pageX + event.touches[ 1 ].pageX) / 2,\n (event.touches[ 0 ].pageY + event.touches[ 1 ].pageY) / 2\n )\n this.position.set(\n (event.touches[ 0 ].pageX + event.touches[ 1 ].pageX) / 2,\n (event.touches[ 0 ].pageY + event.touches[ 1 ].pageY) / 2\n )\n this.lastTouchDistance = getTouchDistance(event)\n }\n }\n }\n\n _onTouchend (event: TouchEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n }\n this.which = undefined\n this.buttons = undefined\n this.pressed = undefined\n }\n\n _onTouchmove (event: TouchEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n this.overElement = true\n } else {\n this.overElement = false\n }\n switch (event.touches.length) {\n case 1: {\n this._setKeys(event)\n this.which = LeftMouseButton\n this.buttons = 1\n this.moving = true\n this.hovering = false\n this.lastMoved = window.performance.now()\n this.prevPosition.copy(this.position)\n this.position.set(\n event.touches[ 0 ].pageX,\n event.touches[ 0 ].pageY\n )\n this._setCanvasPosition(event.touches[ 0 ])\n const dx = this.prevPosition.x - this.position.x\n const dy = this.prevPosition.y - this.position.y\n this.signals.moved.dispatch(dx, dy)\n if (this.pressed) {\n this.signals.dragged.dispatch(dx, dy)\n }\n break\n }\n\n case 2: {\n const touchDistance = getTouchDistance(event)\n const delta = touchDistance - this.lastTouchDistance\n this.lastTouchDistance = touchDistance\n this.prevPosition.copy(this.position)\n this.position.set(\n (event.touches[ 0 ].pageX + event.touches[ 1 ].pageX) / 2,\n (event.touches[ 0 ].pageY + event.touches[ 1 ].pageY) / 2\n )\n if (Math.abs(delta) > 2 && this.handleScroll &&\n this.position.distanceTo(this.prevPosition) < 2\n ) {\n this.which = 0\n this.buttons = 0\n this.signals.scrolled.dispatch(delta / 2)\n } else {\n this.which = RightMouseButton\n this.buttons = 2\n const dx = this.prevPosition.x - this.position.x\n const dy = this.prevPosition.y - this.position.y\n this.signals.moved.dispatch(dx, dy)\n if (this.pressed) {\n this.signals.dragged.dispatch(dx, dy)\n }\n }\n }\n }\n }\n\n _distance () {\n return this.position.distanceTo(this.down)\n }\n\n _setCanvasPosition (event: any) { // TODO\n const box = this.domElement.getBoundingClientRect()\n let offsetX, offsetY;\n if ('clientX' in event && 'clientY' in event) {\n offsetX = event.clientX - box.left\n offsetY = event.clientY - box.top\n } else {\n offsetX = event.offsetX\n offsetY = event.offsetY\n }\n this.canvasPosition.set(offsetX, box.height - offsetY)\n }\n\n _setKeys (event: MouseEvent|TouchEvent) {\n this.altKey = event.altKey\n this.ctrlKey = event.ctrlKey\n this.metaKey = event.metaKey\n this.shiftKey = event.shiftKey\n }\n\n dispose () {\n document.removeEventListener('mousewheel', this._onMousewheel)\n document.removeEventListener('wheel', this._onMousewheel)\n document.removeEventListener('MozMousePixelScroll', this._onMousewheel)\n document.removeEventListener('mousemove', this._onMousemove)\n document.removeEventListener('mousedown', this._onMousedown)\n document.removeEventListener('mouseup', this._onMouseup)\n document.removeEventListener('contextmenu', this._onContextmenu)\n document.removeEventListener('touchstart', this._onTouchstart)\n document.removeEventListener('touchend', this._onTouchend)\n document.removeEventListener('touchmove', this._onTouchmove)\n window.cancelAnimationFrame(this.frameRequest)\n }\n}\n\nexport default MouseObserver\n","/**\n * @file Trackball Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4, Quaternion } from 'three'\n\nimport { defaults } from '../utils'\nimport Stage from '../stage/stage'\nimport MouseObserver from '../stage/mouse-observer'\nimport Viewer from '../viewer/viewer'\nimport ViewerControls from './viewer-controls'\nimport AtomProxy from '../proxy/atom-proxy';\nimport Component from '../component/component';\n\nconst tmpRotateXMatrix = new Matrix4()\nconst tmpRotateYMatrix = new Matrix4()\nconst tmpRotateZMatrix = new Matrix4()\nconst tmpRotateMatrix = new Matrix4()\nconst tmpRotateCameraMatrix = new Matrix4()\nconst tmpRotateVector = new Vector3()\nconst tmpRotateQuaternion = new Quaternion()\nconst tmpRotateQuaternion2 = new Quaternion()\nconst tmpPanMatrix = new Matrix4()\nconst tmpPanVector = new Vector3()\nconst tmpAtomVector = new Vector3()\n\nexport interface TrackballControlsParams {\n rotateSpeed?: number\n zoomSpeed?: number\n panSpeed?: number\n}\n\n/**\n * Trackball controls\n */\nclass TrackballControls {\n viewer: Viewer\n mouse: MouseObserver\n controls: ViewerControls\n\n rotateSpeed: number\n zoomSpeed: number\n panSpeed: number\n\n constructor (readonly stage: Stage, params: TrackballControlsParams = {}) {\n this.rotateSpeed = defaults(params.rotateSpeed, 2.0)\n this.zoomSpeed = defaults(params.zoomSpeed, 1.2)\n this.panSpeed = defaults(params.panSpeed, 1.0)\n\n this.viewer = stage.viewer\n this.mouse = stage.mouseObserver\n this.controls = stage.viewerControls\n }\n\n get component (): Component|undefined {\n return this.stage.transformComponent\n }\n\n get atom (): AtomProxy|undefined {\n return this.stage.transformAtom\n }\n\n private _setPanVector (x: number, y: number, z = 0) {\n const scaleFactor = this.controls.getCanvasScaleFactor(z)\n tmpPanVector.set(x, y, 0)\n tmpPanVector.multiplyScalar(this.panSpeed * scaleFactor)\n }\n\n private _getRotateXY (x: number, y: number) {\n return [\n this.rotateSpeed * -x * 0.01,\n this.rotateSpeed * y * 0.01\n ]\n }\n\n private _getCameraRotation(m: Matrix4) {\n m.extractRotation(this.viewer.camera.matrixWorld)\n m.multiply(tmpRotateYMatrix.makeRotationY(Math.PI))\n\n return m\n }\n\n private _transformPanVector () {\n if (!this.component) return\n\n // Adjust for component and scene rotation\n tmpPanMatrix.extractRotation(this.component.transform)\n tmpPanMatrix.premultiply(this.viewer.rotationGroup.matrix)\n tmpPanMatrix.getInverse(tmpPanMatrix)\n\n // Adjust for camera rotation\n tmpPanMatrix.multiply(this._getCameraRotation(tmpRotateMatrix))\n\n tmpPanVector.applyMatrix4(tmpPanMatrix)\n }\n\n zoom (delta: number) {\n this.controls.zoom(this.zoomSpeed * delta * 0.02)\n }\n\n pan (x: number, y: number) {\n this._setPanVector(x, y)\n\n // Adjust for scene rotation\n tmpPanMatrix.getInverse(this.viewer.rotationGroup.matrix)\n\n // Adjust for camera rotation\n tmpPanMatrix.multiply(this._getCameraRotation(tmpRotateMatrix))\n\n tmpPanVector.applyMatrix4(tmpPanMatrix)\n this.controls.translate(tmpPanVector)\n }\n\n panComponent (x: number, y: number) {\n if (!this.component) return\n\n this._setPanVector(x, y)\n this._transformPanVector()\n\n this.component.position.add(tmpPanVector)\n this.component.updateMatrix()\n }\n\n panAtom (x: number, y: number) {\n if (!this.atom || !this.component) return\n\n this.atom.positionToVector3(tmpAtomVector)\n tmpAtomVector.add(this.viewer.translationGroup.position)\n tmpAtomVector.applyMatrix4(this.viewer.rotationGroup.matrix)\n\n this._setPanVector(x, y, tmpAtomVector.z)\n this._transformPanVector()\n\n this.atom.positionAdd(tmpPanVector)\n this.component.updateRepresentations({ 'position': true })\n }\n\n rotate (x: number, y: number) {\n const [ dx, dy ] = this._getRotateXY(x, y)\n\n // rotate around screen X then screen Y\n this._getCameraRotation(tmpRotateMatrix)\n tmpRotateVector.set(1, 0, 0) // X axis\n tmpRotateVector.applyMatrix4(tmpRotateMatrix) // screen X\n tmpRotateQuaternion.setFromAxisAngle(tmpRotateVector, dy)\n\n tmpRotateVector.set(0, 1, 0) // Y axis\n tmpRotateVector.applyMatrix4(tmpRotateMatrix) // screen Y\n tmpRotateQuaternion2.setFromAxisAngle(tmpRotateVector, dx)\n\n tmpRotateQuaternion.multiply(tmpRotateQuaternion2)\n tmpRotateMatrix.makeRotationFromQuaternion(tmpRotateQuaternion)\n this.controls.applyMatrix(tmpRotateMatrix)\n }\n\n zRotate (x: number, y: number) {\n const dz = this.rotateSpeed * ((-x + y) / -2) * 0.01\n\n tmpRotateZMatrix.makeRotationZ(dz)\n this.controls.applyMatrix(tmpRotateZMatrix)\n }\n\n rotateComponent (x: number, y: number) {\n if (!this.component) return\n\n const [ dx, dy ] = this._getRotateXY(x, y)\n\n this._getCameraRotation(tmpRotateCameraMatrix)\n\n tmpRotateMatrix.extractRotation(this.component.transform)\n tmpRotateMatrix.premultiply(this.viewer.rotationGroup.matrix)\n tmpRotateMatrix.getInverse(tmpRotateMatrix)\n tmpRotateMatrix.premultiply(tmpRotateCameraMatrix)\n\n tmpRotateVector.set(1, 0, 0)\n tmpRotateVector.applyMatrix4(tmpRotateMatrix)\n tmpRotateXMatrix.makeRotationAxis(tmpRotateVector, dy)\n\n tmpRotateVector.set(0, 1, 0)\n tmpRotateVector.applyMatrix4(tmpRotateMatrix)\n tmpRotateYMatrix.makeRotationAxis(tmpRotateVector, dx)\n\n tmpRotateXMatrix.multiply(tmpRotateYMatrix)\n tmpRotateQuaternion.setFromRotationMatrix(tmpRotateXMatrix)\n this.component.quaternion.premultiply(tmpRotateQuaternion)\n this.component.quaternion.normalize()\n this.component.updateMatrix()\n }\n}\n\nexport default TrackballControls\n","/**\n * @file Picking Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4, Vector2 } from 'three'\n\nimport Stage from '../stage/stage'\nimport StructureComponent from '../component/structure-component'\nimport MouseObserver from '../stage/mouse-observer'\nimport { Picker } from '../utils/picker'\nimport ViewerControls from './viewer-controls'\nimport Shape from '../geometry/shape'\nimport Structure from '../structure/structure'\nimport BondProxy from '../proxy/bond-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Surface from '../surface/surface'\nimport Volume from '../surface/volume'\nimport Unitcell from '../symmetry/unitcell'\nimport Component from '../component/component';\n\nconst tmpVec = new Vector3()\n\nexport interface ShapePrimitive {\n name: string\n shape: Shape\n}\n\nfunction closer (x: Vector3, a: Vector3, b: Vector3) {\n return x.distanceTo(a) < x.distanceTo(b)\n}\n\n/**\n * Picking data object.\n * @typedef {Object} PickingData - picking data\n * @property {Number} [pid] - picking id\n * @property {Object} [instance] - instance data\n * @property {Integer} instance.id - instance id\n * @property {String|Integer} instance.name - instance name\n * @property {Matrix4} instance.matrix - transformation matrix of the instance\n * @property {Picker} [picker] - picker object\n */\n\nexport interface InstanceData {\n id: number\n name: number|string\n matrix: Matrix4\n}\n\nexport interface PickingData {\n pid: number\n instance: InstanceData\n picker: Picker\n}\n\n/**\n * Picking proxy class.\n */\nclass PickingProxy {\n pid: number\n picker: Picker\n instance: InstanceData\n controls: ViewerControls\n mouse: MouseObserver\n\n /**\n * Create picking proxy object\n * @param {PickingData} pickingData - picking data\n * @param {Stage} stage - stage object\n */\n constructor (pickingData: PickingData, readonly stage: Stage) {\n this.pid = pickingData.pid\n this.picker = pickingData.picker\n\n /**\n * @type {Object}\n */\n this.instance = pickingData.instance\n\n /**\n * @type {Stage}\n */\n this.stage = stage\n /**\n * @type {ViewerControls}\n */\n this.controls = stage.viewerControls\n /**\n * @type {MouseObserver}\n */\n this.mouse = stage.mouseObserver\n }\n\n /**\n * Kind of the picked data\n * @type {String}\n */\n get type () { return this.picker.type }\n\n /**\n * If the `alt` key was pressed\n * @type {Boolean}\n */\n get altKey () { return this.mouse.altKey }\n /**\n * If the `ctrl` key was pressed\n * @type {Boolean}\n */\n get ctrlKey () { return this.mouse.ctrlKey }\n /**\n * If the `meta` key was pressed\n * @type {Boolean}\n */\n get metaKey () { return this.mouse.metaKey }\n /**\n * If the `shift` key was pressed\n * @type {Boolean}\n */\n get shiftKey () { return this.mouse.shiftKey }\n\n /**\n * Position of the mouse on the canvas\n * @type {Vector2}\n */\n get canvasPosition (): Vector2 { return this.mouse.canvasPosition }\n\n /**\n * The component the picked data is part of\n * @type {Component}\n */\n get component (): Component {\n return this.stage.getComponentsByObject(this.picker.data as any).list[ 0 ] // TODO\n }\n\n /**\n * The picked object data\n * @type {Object}\n */\n get object () {\n return this.picker.getObject(this.pid)\n }\n\n /**\n * The 3d position in the scene of the picked object\n * @type {Vector3}\n */\n get position () {\n return this.picker.getPosition(this.pid, this.instance, this.component)\n }\n\n /**\n * The atom of a picked bond that is closest to the mouse\n * @type {AtomProxy}\n */\n get closestBondAtom (): AtomProxy|undefined {\n if (this.type !== 'bond' || !this.bond) return undefined\n\n const bond = this.bond\n const controls = this.controls\n const cp = this.canvasPosition\n\n const v1 = bond.atom1.positionToVector3()\n const v2 = bond.atom2.positionToVector3()\n\n v1.applyMatrix4(this.component.matrix)\n v2.applyMatrix4(this.component.matrix)\n\n const acp1 = controls.getPositionOnCanvas(v1)\n const acp2 = controls.getPositionOnCanvas(v2)\n\n return closer(cp as any, acp1, acp2) ? bond.atom1 : bond.atom2\n }\n\n /**\n * Close-by atom\n * @type {AtomProxy}\n */\n get closeAtom (): AtomProxy|undefined {\n const cp = this.canvasPosition\n const ca = this.closestBondAtom\n if (!ca) return undefined\n\n const v = ca.positionToVector3().applyMatrix4(this.component.matrix)\n\n const acp = this.controls.getPositionOnCanvas(v)\n\n ca.positionToVector3(tmpVec)\n if (this.instance) tmpVec.applyMatrix4(this.instance.matrix)\n tmpVec.applyMatrix4(this.component.matrix)\n const viewer = this.controls.viewer\n tmpVec.add(viewer.translationGroup.position)\n tmpVec.applyMatrix4(viewer.rotationGroup.matrix)\n\n const scaleFactor = this.controls.getCanvasScaleFactor(tmpVec.z)\n const sc = this.component as StructureComponent\n const radius = sc.getMaxRepresentationRadius(ca.index)\n //console.log(scaleFactor, cp.distanceTo(acp), radius/scaleFactor, radius)\n\n if (cp.distanceTo(acp) <= radius/scaleFactor) {\n return ca\n } else {\n return undefined\n }\n }\n\n /**\n * @type {Object}\n */\n get arrow () { return this._objectIfType('arrow') as ShapePrimitive }\n /**\n * @type {AtomProxy}\n */\n get atom () { return this._objectIfType('atom') as AtomProxy }\n /**\n * @type {Object}\n */\n get axes () { return this._objectIfType('axes') }\n /**\n * @type {BondProxy}\n */\n get bond () { return this._objectIfType('bond') as BondProxy }\n /**\n * @type {Object}\n */\n get box () { return this._objectIfType('box') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get cone () { return this._objectIfType('cone') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get clash () { return this._objectIfType('clash') as { clash: { sele1: string, sele2: string } } }\n /**\n * @type {BondProxy}\n */\n get contact () { return this._objectIfType('contact') as { type: string, atom1: AtomProxy, atom2: AtomProxy } }\n /**\n * @type {Object}\n */\n get cylinder () { return this._objectIfType('cylinder') as ShapePrimitive }\n /**\n * @type {BondProxy}\n */\n get distance () { return this._objectIfType('distance') as BondProxy }\n /**\n * @type {Object}\n */\n get ellipsoid () { return this._objectIfType('ellipsoid') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get octahedron () { return this._objectIfType('octahedron') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get point () { return this._objectIfType('point') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get mesh () { return this._objectIfType('mesh') as { name: string, shape: Shape, serial: number } }\n /**\n * @type {Object}\n */\n get slice () { return this._objectIfType('slice') as { volume: Volume, value: number } }\n /**\n * @type {Object}\n */\n get sphere () { return this._objectIfType('sphere') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get tetrahedron () { return this._objectIfType('tetrahedron') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get torus () { return this._objectIfType('torus') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get surface () { return this._objectIfType('surface') as { surface: Surface, index: number } }\n /**\n * @type {Object}\n */\n get unitcell () { return this._objectIfType('unitcell') as { unitcell: Unitcell, structure: Structure } }\n /**\n * @type {Object}\n */\n get unknown () { return this._objectIfType('unknown') }\n /**\n * @type {Object}\n */\n get volume () { return this._objectIfType('volume') as { volume: Volume, value: number } }\n /**\n * @type {Object}\n */\n get wideline () { return this._objectIfType('wideline') as ShapePrimitive }\n\n _objectIfType (type: string) {\n return this.type === type ? this.object : undefined\n }\n\n getLabel () {\n const atom = this.atom || this.closeAtom\n let msg = 'nothing'\n if (this.arrow) {\n msg = this.arrow.name\n } else if (atom) {\n msg = `atom: ${atom.qualifiedName()} (${atom.structure.name})`\n } else if (this.axes) {\n msg = 'axes'\n } else if (this.bond) {\n msg = `bond: ${this.bond.atom1.qualifiedName()} - ${this.bond.atom2.qualifiedName()} (${this.bond.structure.name})`\n } else if (this.box) {\n msg = this.box.name\n } else if (this.cone) {\n msg = this.cone.name\n } else if (this.clash) {\n msg = `clash: ${this.clash.clash.sele1} - ${this.clash.clash.sele2}`\n } else if (this.contact) {\n msg = `${this.contact.type}: ${this.contact.atom1.qualifiedName()} - ${this.contact.atom2.qualifiedName()} (${this.contact.atom1.structure.name})`\n } else if (this.cylinder) {\n msg = this.cylinder.name\n } else if (this.distance) {\n msg = `distance: ${this.distance.atom1.qualifiedName()} - ${this.distance.atom2.qualifiedName()} (${this.distance.structure.name})`\n } else if (this.ellipsoid) {\n msg = this.ellipsoid.name\n } else if (this.octahedron) {\n msg = this.octahedron.name\n } else if (this.point) {\n msg = this.point.name\n } else if (this.mesh) {\n msg = `mesh: ${this.mesh.name || this.mesh.serial} (${this.mesh.shape.name})`\n } else if (this.slice) {\n msg = `slice: ${this.slice.value.toPrecision(3)} (${this.slice.volume.name})`\n } else if (this.sphere) {\n msg = this.sphere.name\n } else if (this.surface) {\n msg = `surface: ${this.surface.surface.name}`\n } else if (this.tetrahedron) {\n msg = this.tetrahedron.name\n } else if (this.torus) {\n msg = this.torus.name\n } else if (this.unitcell) {\n msg = `unitcell: ${this.unitcell.unitcell.spacegroup} (${this.unitcell.structure.name})`\n } else if (this.unknown) {\n msg = 'unknown'\n } else if (this.volume) {\n msg = `volume: ${this.volume.value.toPrecision(3)} (${this.volume.volume.name})`\n } else if (this.wideline) {\n msg = this.wideline.name\n }\n return msg\n }\n}\n\nexport default PickingProxy\n","/**\n * @file Picking Controls\n * @author Alexander Rose \n * @private\n */\n\nimport PickingProxy from './picking-proxy'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\n\n/**\n * Picking controls\n */\nclass PickingControls {\n viewer: Viewer\n\n constructor (readonly stage: Stage) {\n this.viewer = stage.viewer\n }\n\n /**\n * get picking data\n * @param {Number} x - canvas x coordinate\n * @param {Number} y - canvas y coordinate\n * @return {PickingProxy|undefined} picking proxy\n */\n pick (x: number, y: number) {\n const pickingData = this.viewer.pick(x, y)\n\n if (pickingData.picker &&\n pickingData.picker.type !== 'ignore' &&\n pickingData.pid !== undefined\n ) {\n const pickerArray = pickingData.picker.array\n if (pickerArray && pickingData.pid >= pickerArray.length) {\n console.error('pid >= picker.array.length')\n } else {\n return new PickingProxy(pickingData, this.stage)\n }\n }\n }\n}\n\nexport default PickingControls\n","/**\n * @file Viewer Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector2, Vector3, Matrix4, Quaternion, OrthographicCamera } from 'three'\nimport * as signalsWrapper from 'signals'\n\nimport {\n ensureVector2, ensureVector3, ensureMatrix4, ensureQuaternion\n} from '../utils'\nimport { degToRad } from '../math/math-utils'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\n\n/**\n * Orientation matrix, a 4x4 transformation matrix with rotation part\n * used for scene rotation, scale part for scene camera distance and\n * position part for scene translation\n * @typedef {Matrix4} OrientationMatrix - orientation matrix\n */\n\nconst tmpQ = new Quaternion()\nconst tmpP = new Vector3()\nconst tmpS = new Vector3()\n\nconst tmpCanvasVector = new Vector3()\nconst tmpScaleVector = new Vector3()\nconst tmpRotateMatrix = new Matrix4()\nconst tmpRotateVector = new Vector3()\nconst tmpAlignMatrix = new Matrix4()\n\n/**\n * Viewer controls\n */\nclass ViewerControls {\n signals = {\n changed: new signalsWrapper.Signal()\n }\n\n viewer: Viewer\n\n /**\n * @param {Stage} stage - the stage object\n */\n constructor (readonly stage: Stage) {\n this.viewer = stage.viewer\n }\n\n /**\n * scene center position\n * @type {Vector3}\n */\n get position () {\n return this.viewer.translationGroup.position\n }\n\n /**\n * scene rotation\n * @type {Quaternion}\n */\n get rotation () {\n return this.viewer.rotationGroup.quaternion\n }\n\n /**\n * Trigger render and emit changed event\n * @emits {ViewerControls.signals.changed}\n * @return {undefined}\n */\n changed () {\n this.viewer.requestRender()\n this.signals.changed.dispatch()\n }\n\n getPositionOnCanvas (position: Vector3, optionalTarget?: Vector2) {\n const canvasPosition = ensureVector2(optionalTarget)\n const viewer = this.viewer\n\n tmpCanvasVector.copy(position)\n .add(viewer.translationGroup.position)\n .applyMatrix4(viewer.rotationGroup.matrix)\n .project(viewer.camera)\n\n return canvasPosition.set(\n (tmpCanvasVector.x + 1) * viewer.width / 2,\n (tmpCanvasVector.y + 1) * viewer.height / 2\n )\n }\n\n getCanvasScaleFactor (z = 0) {\n const camera = this.viewer.camera\n if (camera instanceof OrthographicCamera) {\n return 1 / camera.zoom\n } else {\n z = Math.abs(z)\n z += this.getCameraDistance()\n const fov = degToRad(camera.fov)\n const unitHeight = 2.0 * z * Math.tan(fov / 2)\n return unitHeight / this.viewer.height\n }\n }\n\n /**\n * get scene orientation\n * @param {Matrix4} optionalTarget - pre-allocated target matrix\n * @return {OrientationMatrix} scene orientation\n */\n getOrientation (optionalTarget?: Matrix4) {\n const m = ensureMatrix4(optionalTarget)\n\n m.copy(this.viewer.rotationGroup.matrix)\n const z = this.getCameraDistance()\n m.scale(tmpScaleVector.set(z, z, z))\n m.setPosition(this.viewer.translationGroup.position)\n\n return m\n }\n\n /**\n * set scene orientation\n * @param {OrientationMatrix|Array} orientation - scene orientation\n * @return {undefined}\n */\n orient (orientation?: Matrix4) {\n ensureMatrix4(orientation).decompose(tmpP, tmpQ, tmpS)\n\n const v = this.viewer\n v.rotationGroup.setRotationFromQuaternion(tmpQ)\n v.translationGroup.position.copy(tmpP)\n v.cameraDistance = tmpS.z\n v.updateZoom()\n this.changed()\n }\n\n /**\n * translate scene\n * @param {Vector3|Array} vector - translation vector\n * @return {undefined}\n */\n translate (vector: Vector3|number[]) {\n this.viewer.translationGroup.position\n .add(ensureVector3(vector))\n this.changed()\n }\n\n /**\n * center scene\n * @param {Vector3|Array} position - center position\n * @return {undefined}\n */\n center (position: Vector3|number[]) {\n this.viewer.translationGroup.position\n .copy(ensureVector3(position)).negate()\n this.changed()\n }\n\n /**\n * \"zoom\" scene by moving camera closer to origin\n * @param {Number} delta - zoom change\n * @return {undefined}\n */\n zoom (delta: number) {\n this.distance(this.getCameraDistance() * (1 - delta))\n }\n\n /**\n * get camera distance\n */\n getCameraDistance(): number {\n return this.viewer.cameraDistance\n }\n\n /**\n * camera distance\n * @param {Number} z - distance\n * @return {undefined}\n */\n distance (distance: number) {\n // Math.abs because distance used to be \"z\", normally negative.\n // Math.max to prevent us from getting _too_ close.\n this.viewer.cameraDistance = Math.max(Math.abs(distance), 0.2)\n this.viewer.updateZoom()\n this.changed()\n }\n\n /**\n * spin scene on axis\n * @param {Vector3|Array} axis - rotation axis\n * @param {Number} angle - amount to spin\n * @return {undefined}\n */\n spin (axis: Vector3|number[], angle: number) {\n tmpRotateMatrix.getInverse(this.viewer.rotationGroup.matrix)\n tmpRotateVector\n .copy(ensureVector3(axis)).applyMatrix4(tmpRotateMatrix)\n\n this.viewer.rotationGroup.rotateOnAxis(tmpRotateVector, angle)\n this.changed()\n }\n\n /**\n * rotate scene\n * @param {Quaternion|Array} quaternion - rotation quaternion\n * @return {undefined}\n */\n rotate (quaternion: Quaternion|number[]) {\n this.viewer.rotationGroup\n .setRotationFromQuaternion(ensureQuaternion(quaternion))\n this.changed()\n }\n\n /**\n * align scene to basis matrix\n * @param {Matrix4|Array} basis - basis matrix\n * @return {undefined}\n */\n align (basis: Matrix4|number[]) {\n tmpAlignMatrix.getInverse(ensureMatrix4(basis))\n\n this.viewer.rotationGroup.setRotationFromMatrix(tmpAlignMatrix)\n this.changed()\n }\n\n /**\n * apply rotation matrix to scene\n * @param {Matrix4|Array} matrix - rotation matrix\n * @return {undefined}\n */\n applyMatrix (matrix: Matrix4|number[]) {\n this.viewer.rotationGroup.applyMatrix4(ensureMatrix4(matrix))\n this.changed()\n }\n}\n\nexport default ViewerControls\n","/**\n * @file Animation\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Quaternion } from 'three'\n\nimport { defaults, ensureVector3, ensureQuaternion } from '../utils'\nimport { lerp, smoothstep } from '../math/math-utils'\nimport ViewerControls from '../controls/viewer-controls'\nimport Stats from '../viewer/stats'\n\n/**\n * Animation. Base animation class.\n * @interface\n */\nabstract class Animation {\n duration: number\n controls: ViewerControls\n\n alpha: number\n startTime: number\n\n pausedTime = -1\n elapsedDuration = 0\n pausedDuration = 0\n ignoreGlobalToggle = false\n\n private _paused = false\n private _resolveList: Function[] = []\n private _hold: boolean\n\n constructor (duration: number|undefined, controls: ViewerControls, ...args: any[]) {\n this.duration = defaults(duration, 1000)\n this.controls = controls\n\n this.startTime = window.performance.now()\n\n this._init(...args)\n }\n\n /**\n * True when animation has finished\n */\n get done () {\n return this.alpha === 1\n }\n\n /**\n * True when animation is paused\n */\n get paused () {\n return this._paused\n }\n\n /**\n * init animation\n */\n abstract _init (...args: any[]): void\n\n /**\n * called on every tick\n */\n abstract _tick (stats?: Stats): void\n\n tick (stats: Stats) {\n if (this._paused) return\n\n this.elapsedDuration = stats.currentTime - this.startTime - this.pausedDuration\n\n if (this.duration === 0) {\n this.alpha = 1\n } else {\n this.alpha = smoothstep(0, 1, this.elapsedDuration / this.duration)\n }\n\n this._tick(stats)\n\n if (this.done) {\n this._resolveList.forEach(resolve => resolve())\n }\n\n return this.done\n }\n\n /**\n * Pause animation\n * @param {boolean} [hold] - put animation on a hold which\n * must be release before it can be resumed\n */\n pause (hold?: boolean) {\n if (hold) this._hold = true\n\n if (this.pausedTime === -1) {\n this.pausedTime = window.performance.now()\n }\n this._paused = true\n }\n\n /**\n * Resume animation\n * @param {Boolean} [releaseHold] - release a hold on the animation\n */\n resume (releaseHold?: boolean) {\n if (!releaseHold && this._hold) return\n\n this.pausedDuration += window.performance.now() - this.pausedTime\n this._paused = false\n this._hold = false\n this.pausedTime = -1\n }\n\n /**\n * Toggle animation\n */\n toggle () {\n if (this._paused) {\n this.resume()\n } else {\n this.pause()\n }\n }\n\n /**\n * Promise-like interface\n */\n then (callback: Function) {\n let p: Promise\n\n if (this.done) {\n p = Promise.resolve()\n } else {\n p = new Promise(resolve => this._resolveList.push(resolve))\n }\n\n return p.then(callback as any)\n }\n}\n\nexport default Animation\n\n/**\n * Spin animation. Spin around an axis.\n */\nexport class SpinAnimation extends Animation {\n axis: Vector3\n angle: number\n\n constructor (duration: number|undefined, controls: ViewerControls, ...args: any[]) {\n super(defaults(duration, Infinity), controls, ...args)\n }\n\n _init (axis: number[]|Vector3, angle: number) {\n if (Array.isArray(axis)) {\n this.axis = new Vector3().fromArray(axis)\n } else {\n this.axis = defaults(axis, new Vector3(0, 1, 0))\n }\n this.angle = defaults(angle, 0.01)\n }\n\n _tick (stats: Stats) {\n if (!this.axis || !this.angle) return\n\n this.controls.spin(\n this.axis, this.angle * stats.lastDuration / 16\n )\n }\n}\n\n/**\n * Rock animation. Rock around an axis.\n */\nexport class RockAnimation extends Animation {\n axis: Vector3\n angleStep: number\n angleEnd: number\n angleSum = 0\n direction = 1\n\n constructor (duration: number|undefined, controls: ViewerControls, ...args: any[]) {\n super(defaults(duration, Infinity), controls, ...args)\n }\n\n _init (axis: number[]|Vector3, angleStep: number, angleEnd: number) {\n if (Array.isArray(axis)) {\n this.axis = new Vector3().fromArray(axis)\n } else {\n this.axis = defaults(axis, new Vector3(0, 1, 0))\n }\n this.angleStep = defaults(angleStep, 0.01)\n this.angleEnd = defaults(angleEnd, 0.2)\n }\n\n _tick (stats: Stats) {\n if (!this.axis || !this.angleStep || !this.angleEnd) return\n\n const alpha = smoothstep(\n 0, 1, Math.abs(this.angleSum) / this.angleEnd\n )\n const angle = this.angleStep * this.direction * (1.1 - alpha)\n\n this.controls.spin(\n this.axis, angle * stats.lastDuration / 16\n )\n\n this.angleSum += this.angleStep\n\n if (this.angleSum >= this.angleEnd) {\n this.direction *= -1\n this.angleSum = -this.angleEnd\n }\n }\n}\n\n/**\n * Move animation. Move from one position to another.\n */\nexport class MoveAnimation extends Animation {\n moveFrom: Vector3\n moveTo: Vector3\n\n _init (moveFrom: number[]|Vector3, moveTo: number[]|Vector3) {\n this.moveFrom = ensureVector3(defaults(moveFrom, new Vector3()))\n this.moveTo = ensureVector3(defaults(moveTo, new Vector3()))\n }\n\n _tick (/* stats */) {\n this.controls.position.lerpVectors(\n this.moveFrom, this.moveTo, this.alpha\n ).negate()\n this.controls.changed()\n }\n}\n\n/**\n * Zoom animation. Gradually change the zoom level.\n */\nexport class ZoomAnimation extends Animation {\n zoomFrom: number\n zoomTo: number\n\n _init (zoomFrom: number, zoomTo: number) {\n this.zoomFrom = zoomFrom\n this.zoomTo = zoomTo\n }\n\n _tick () {\n this.controls.distance(lerp(this.zoomFrom, this.zoomTo, this.alpha))\n }\n}\n\n/**\n * Rotate animation. Rotate from one orientation to another.\n */\nexport class RotateAnimation extends Animation {\n rotateFrom: Quaternion\n rotateTo: Quaternion\n\n private _currentRotation = new Quaternion()\n\n _init (rotateFrom: number[]|Quaternion, rotateTo: number[]|Quaternion) {\n this.rotateFrom = ensureQuaternion(rotateFrom)\n this.rotateTo = ensureQuaternion(rotateTo)\n\n this._currentRotation = new Quaternion()\n }\n\n _tick () {\n this._currentRotation\n .copy(this.rotateFrom)\n .slerp(this.rotateTo, this.alpha)\n\n this.controls.rotate(this._currentRotation)\n }\n}\n\n/**\n * Value animation. Call callback with interpolated value.\n */\nexport class ValueAnimation extends Animation {\n valueFrom: number\n valueTo: number\n callback: Function\n\n _init (valueFrom: number, valueTo: number, callback: Function) {\n this.valueFrom = valueFrom\n this.valueTo = valueTo\n\n this.callback = callback\n }\n\n _tick (/* stats */) {\n this.callback(lerp(this.valueFrom, this.valueTo, this.alpha))\n }\n}\n\n/**\n * Timeout animation. Call callback after duration.\n */\nexport class TimeoutAnimation extends Animation {\n callback: Function\n\n _init (callback: Function) {\n this.callback = callback\n }\n\n _tick () {\n if (this.alpha === 1) this.callback()\n }\n}\n\n/**\n * Animation list.\n */\nexport class AnimationList {\n _list: Animation[]\n _resolveList: Function[] = []\n\n constructor (list: Animation[] = []) {\n this._list = list\n }\n\n /**\n * True when all animations have finished\n */\n get done () {\n return this._list.every(animation => {\n return animation.done\n })\n }\n\n /**\n * Promise-like interface\n */\n then (callback: Function) {\n let p: Promise\n\n if (this.done) {\n p = Promise.resolve()\n } else {\n p = new Promise(resolve => {\n this._resolveList.push(resolve)\n this._list.forEach(animation => {\n animation.then(() => {\n this._resolveList.forEach(callback => {\n callback()\n })\n this._resolveList.length = 0\n })\n })\n })\n }\n\n return p.then(callback as any)\n }\n}\n","/**\n * @file Animation Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Quaternion, Matrix4 } from 'three'\n\nimport { ensureMatrix4 } from '../utils'\nimport Animation, {\n SpinAnimation, RockAnimation, MoveAnimation, ZoomAnimation,\n RotateAnimation, ValueAnimation, TimeoutAnimation, AnimationList\n} from '../animation/animation'\nimport Stage from '../stage/stage'\nimport Component from '../component/component'\nimport Viewer from '../viewer/viewer'\nimport Stats from '../viewer/stats'\nimport ViewerControls from './viewer-controls'\n\n/**\n * Animation controls\n */\nclass AnimationControls {\n viewer: Viewer\n controls: ViewerControls\n\n animationList: Animation[] = []\n finishedList: Animation[] = []\n\n /**\n * Create animation controls\n * @param {Stage} stage - the stage object\n */\n constructor (readonly stage: Stage) {\n this.viewer = stage.viewer\n this.controls = stage.viewerControls\n }\n\n /**\n * True when all animations are paused\n * @type {Boolean}\n */\n get paused () {\n return this.animationList.every((animation: Animation) => animation.paused)\n }\n\n /**\n * Add an animation\n */\n add (animation: Animation) {\n if (animation.duration === 0) {\n animation.tick(this.viewer.stats)\n } else {\n this.animationList.push(animation)\n }\n\n return animation\n }\n\n /**\n * Remove an animation\n */\n remove (animation: Animation) {\n const list = this.animationList\n const index = list.indexOf(animation)\n\n if (index > -1) {\n list.splice(index, 1)\n }\n }\n\n /**\n * Run all animations\n */\n run (stats: Stats) {\n const finishedList = this.finishedList\n const animationList = this.animationList\n\n const n = animationList.length\n for (let i = 0; i < n; ++i) {\n const animation = animationList[ i ]\n // tick returns true when finished\n if (animation.tick(stats)) {\n finishedList.push(animation)\n }\n }\n\n const m = finishedList.length\n if (m) {\n for (let j = 0; j < m; ++j) {\n this.remove(finishedList[ j ])\n }\n finishedList.length = 0\n }\n }\n\n /**\n * Add a spin animation\n * @param {Vector3} axis - axis to spin around\n * @param {Number} angle - amount to spin per frame, radians\n * @param {Number} duration - animation time in milliseconds\n * @return {SpinAnimation} the animation\n */\n spin (axis: Vector3|number[], angle?: number, duration?: number) {\n return this.add(\n new SpinAnimation(duration, this.controls, axis, angle)\n )\n }\n\n /**\n * Add a rock animation\n * @param {Vector3} axis - axis to rock around\n * @param {Number} angle - amount to spin per frame, radians\n * @param {Number} end - maximum extend of motion, radians\n * @param {Number} duration - animation time in milliseconds\n * @return {SpinAnimation} the animation\n */\n rock (axis: Vector3|number[], angle?: number, end?: number, duration?: number) {\n return this.add(\n new RockAnimation(duration, this.controls, axis, angle, end)\n )\n }\n\n /**\n * Add a rotate animation\n * @param {Quaternion} rotateTo - target rotation\n * @param {Number} duration - animation time in milliseconds\n * @return {RotateAnimation} the animation\n */\n rotate (rotateTo: Quaternion|number[], duration?: number) {\n const rotateFrom = this.viewer.rotationGroup.quaternion.clone()\n\n return this.add(\n new RotateAnimation(duration, this.controls, rotateFrom, rotateTo)\n )\n }\n\n /**\n * Add a move animation\n * @param {Vector3} moveTo - target position\n * @param {Number} duration - animation time in milliseconds\n * @return {MoveAnimation} the animation\n */\n move (moveTo: Vector3|number[], duration?: number) {\n const moveFrom = this.controls.position.clone().negate()\n\n return this.add(\n new MoveAnimation(duration, this.controls, moveFrom, moveTo)\n )\n }\n\n /**\n * Add a zoom animation\n * @param {Number} zoomTo - target distance\n * @param {Number} duration - animation time in milliseconds\n * @return {ZoomAnimation} the animation\n */\n zoom (zoomTo: number, duration?: number) {\n const zoomFrom = this.viewer.camera.position.z\n\n return this.add(\n new ZoomAnimation(duration, this.controls, zoomFrom, zoomTo)\n )\n }\n\n /**\n * Add a zoom and a move animation\n * @param {Vector3} moveTo - target position\n * @param {Number} zoomTo - target distance\n * @param {Number} duration - animation time in milliseconds\n * @return {Array} the animations\n */\n zoomMove (moveTo: Vector3, zoomTo: number, duration?: number) {\n return new AnimationList([\n this.move(moveTo, duration),\n this.zoom(zoomTo, duration)\n ])\n }\n\n /**\n * Add an orient animation\n * @param {OrientationMatrix|Array} orientTo - target orientation\n * @param {Number} duration - animation time in milliseconds\n * @return {Array} the animations\n */\n orient (orientTo: Matrix4|number[], duration?: number) {\n const p = new Vector3()\n const q = new Quaternion()\n const s = new Vector3()\n\n ensureMatrix4(orientTo).decompose(p, q, s)\n\n return new AnimationList([\n this.move(p.negate(), duration),\n this.rotate(q, duration),\n this.zoom(-s.x, duration)\n ])\n }\n\n /**\n * Add a value animation\n * @param {Number} valueFrom - start value\n * @param {Number} valueTo - target value\n * @param {Function} callback - called on every tick\n * @param {Number} duration - animation time in milliseconds\n * @return {ValueAnimation} the animation\n */\n value (valueFrom: number, valueTo: number, callback: Function, duration?: number) {\n return this.add(\n new ValueAnimation(duration, this.controls, valueFrom, valueTo, callback)\n )\n }\n\n /**\n * Add a timeout animation\n * @param {Function} callback - called after duration\n * @param {Number} duration - timeout in milliseconds\n * @return {TimeoutAnimation} the animation\n */\n timeout (callback: Function, duration?: number) {\n return this.add(\n new TimeoutAnimation(duration, this.controls, callback)\n )\n }\n\n /**\n * Add a component spin animation\n * @param {Component} component - object to move\n * @param {Vector3} axis - axis to spin around\n * @param {Number} angle - amount to spin per frame, radians\n * @param {Number} duration - animation time in milliseconds\n * @return {SpinAnimation} the animation\n */\n spinComponent (component: Component, axis?: Vector3|number[], angle?: number, duration?: number) {\n return this.add(\n // TODO\n new SpinAnimation(duration, component.controls as any, axis, angle)\n )\n }\n\n /**\n * Add a component rock animation\n * @param {Component} component - object to move\n * @param {Vector3} axis - axis to rock around\n * @param {Number} angle - amount to spin per frame, radians\n * @param {Number} end - maximum extend of motion, radians\n * @param {Number} duration - animation time in milliseconds\n * @return {SpinAnimation} the animation\n */\n rockComponent (component: Component, axis: Vector3|number[], angle?: number, end?: number, duration?: number) {\n return this.add(\n // TODO\n new RockAnimation(duration, component.controls as any, axis, angle, end)\n )\n }\n\n /**\n * Add a component move animation\n * @param {Component} component - object to move\n * @param {Vector3} moveTo - target position\n * @param {Number} duration - animation time in milliseconds\n * @return {MoveAnimation} the animation\n */\n moveComponent (component: Component, moveTo: Vector3|number[], duration?: number) {\n const moveFrom = component.controls.position.clone().negate()\n\n return this.add(\n // TODO\n new MoveAnimation(duration, component.controls as any, moveFrom, moveTo)\n )\n }\n\n /**\n * Pause all animations\n * @return {undefined}\n */\n pause () {\n this.animationList.forEach(animation => animation.pause())\n }\n\n /**\n * Resume all animations\n * @return {undefined}\n */\n resume () {\n this.animationList.forEach(animation => animation.resume())\n }\n\n /**\n * Toggle all animations\n * @return {undefined}\n */\n toggle () {\n if (this.paused) {\n this.resume()\n } else {\n this.pause()\n }\n }\n\n /**\n * Clear all animations\n * @return {undefined}\n */\n clear () {\n this.animationList.length = 0\n }\n\n dispose () {\n this.clear()\n }\n}\n\nexport default AnimationControls\n","/**\n * @file Queue\n * @author Alexander Rose \n * @private\n */\n\nclass Queue {\n queue: T[] = []\n pending = false\n\n constructor(readonly fn: Function, argList?: T[]) {\n this.next = this.next.bind(this)\n\n if (argList) {\n for (let i = 0, il = argList.length; i < il; ++i) {\n this.queue.push(argList[ i ])\n }\n this.next()\n }\n }\n\n private run (arg: any) {\n this.fn(arg, this.next)\n }\n\n private next () {\n const arg = this.queue.shift()\n if (arg !== undefined) {\n this.pending = true\n setTimeout(() => this.run(arg))\n } else {\n this.pending = false\n }\n }\n\n push (arg: T) {\n this.queue.push(arg)\n if (!this.pending) this.next()\n }\n\n kill () {\n this.queue.length = 0\n }\n\n length () {\n return this.queue.length\n }\n}\n\nexport default Queue\n","/**\n * @file Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { Color, Vector3, Matrix4 } from 'three'\n\nimport { Debug, Log, ColormakerRegistry, ExtensionFragDepth } from '../globals'\nimport { defaults } from '../utils'\nimport Queue from '../utils/queue'\nimport Counter from '../utils/counter'\nimport Viewer from '../viewer/viewer'\nimport { BufferParameters, BufferSide, default as Buffer } from '../buffer/buffer';\nimport { ColorData, ColormakerParameters, ColorMode } from '../color/colormaker';\nimport { GenericColor } from '../types'\n\nexport interface RepresentationParameters {\n name: string\n lazy: boolean,\n clipNear: number,\n clipRadius: number,\n clipCenter: Vector3,\n flatShaded: boolean,\n opacity: number,\n depthWrite: boolean,\n side: BufferSide,\n wireframe: boolean,\n colorData: ColorData,\n colorScheme: string,\n colorScale: string | number[],\n colorReverse: boolean,\n colorValue: GenericColor,\n colorDomain: number[],\n colorMode: ColorMode,\n colorSpace: 'sRGB' | 'linear',\n roughness: number,\n metalness: number,\n diffuse: GenericColor,\n diffuseInterior: boolean,\n useInteriorColor: boolean,\n interiorColor: GenericColor,\n interiorDarkening: number,\n disablePicking: boolean,\n matrix: Matrix4\n quality: string,\n visible: boolean,\n color: GenericColor,\n sphereDetail: number,\n radialSegments: number,\n openEnded: boolean\n disableImpostor: boolean\n [key: string]: any//boolean | number | undefined | Color | string | Vector3 | Matrix4 | number[]\n}\n/**\n * Representation parameter object.\n * @typedef {Object} RepresentationParameters - representation parameters\n * @property {Boolean} [lazy] - only build & update the representation when visible\n * otherwise defer changes until set visible again\n * @property {Integer} [clipNear] - position of camera near/front clipping plane\n * in percent of scene bounding box\n * @property {Integer} [clipRadius] - radius of clipping sphere\n * @property {Vector3} [clipCenter] - position of for spherical clipping\n * @property {Boolean} [flatShaded] - render flat shaded\n * @property {Float} [opacity] - translucency: 1 is fully opaque, 0 is fully transparent\n * @property {Boolean} [depthWrite] - depth write\n * @property {String} [side] - which triangle sides to render, \"front\" front-side,\n * \"back\" back-side, \"double\" front- and back-side\n * @property {Boolean} [wireframe] - render as wireframe\n * @property {ColorData} [colorData] - atom or bond indexed data for coloring\n * @property {String} [colorScheme] - color scheme\n * @property {String} [colorScale] - color scale, either a string for a\n * predefined scale or an array of\n * colors to be used as the scale\n * @property {Boolean} [colorReverse] - reverse color scale\n * @property {Color} [colorValue] - color value\n * @property {Integer[]} [colorDomain] - scale value range\n * @property {Integer} colorDomain.0 - min value\n * @property {Integer} colorDomain.1 - max value\n * @property {String} [colorMode] - color mode, one of rgb, hsv, hsl, hsi, lab, hcl\n * @property {Float} [roughness] - how rough the material is, between 0 and 1\n * @property {Float} [metalness] - how metallic the material is, between 0 and 1\n * @property {Color} [diffuse] - diffuse color for lighting\n * @property {Boolean} [diffuseInterior] - diffuse interior, i.e. ignore normal\n * @property {Boolean} [useInteriorColor] - use interior color\n * @property {Color} [interiorColor] - interior color\n * @property {Float} [interiorDarkening] - interior darkening: 0 no darking, 1 fully darkened\n * @property {Boolean} [disablePicking] - disable picking\n */\n\n/**\n * Representation object\n * @interface\n * @param {Object} object - the object to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {RepresentationParameters} [params] - representation parameters\n */\nclass Representation {\n parameters: any\n type: string\n viewer: Viewer\n tasks: Counter\n private queue: Queue\n bufferList: Buffer[]\n\n lazy: boolean\n lazyProps: { build: boolean, bufferParams: BufferParameters | {}, what: {}}\n protected name: string\n protected clipNear: number\n protected clipRadius: number\n protected clipCenter: Vector3\n protected flatShaded: boolean\n protected opacity: number\n protected depthWrite: boolean\n protected side: BufferSide\n protected wireframe: boolean\n protected colorData: ColorData\n protected colorScheme: string\n protected colorScale: string | string[]\n protected colorReverse: boolean\n protected colorValue: number\n protected colorDomain: number[]\n protected colorMode: ColorMode\n protected roughness: number\n protected metalness: number\n protected diffuse: GenericColor\n protected diffuseInterior?: boolean\n protected useInteriorColor?: boolean\n protected interiorColor: GenericColor\n protected interiorDarkening: number\n protected disablePicking: boolean\n protected sphereDetail: number\n protected radialSegments: number\n protected openEnded: boolean\n protected disableImpostor: boolean\n protected disposed: boolean\n\n protected matrix: Matrix4\n\n private quality: string\n visible: boolean\n\n protected manualAttach: ()=> any\n\n protected toBePrepared: boolean\n\n [key: string]: any\n\n constructor (object: any, viewer: Viewer, params: Partial) {\n // eslint-disable-next-line no-unused-vars\n // const p = params || {}\n\n this.type = ''\n\n this.parameters = {\n\n lazy: {\n type: 'boolean'\n },\n\n clipNear: {\n type: 'range', step: 1, max: 100, min: 0, buffer: true\n },\n clipRadius: {\n type: 'number', precision: 1, max: 1000, min: 0, buffer: true\n },\n clipCenter: {\n type: 'vector3', precision: 1, buffer: true\n },\n flatShaded: {\n type: 'boolean', buffer: true\n },\n opacity: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n depthWrite: {\n type: 'boolean', buffer: true\n },\n side: {\n type: 'select',\n buffer: true,\n options: { front: 'front', back: 'back', double: 'double' }\n },\n wireframe: {\n type: 'boolean', buffer: true\n },\n\n colorData: {\n type: 'hidden',\n update: 'color',\n },\n\n colorScheme: {\n type: 'select',\n update: 'color',\n options: {}\n },\n colorScale: {\n type: 'select',\n update: 'color',\n options: ColormakerRegistry.getScales()\n },\n colorReverse: {\n type: 'boolean', update: 'color'\n },\n colorValue: {\n type: 'color', update: 'color'\n },\n colorDomain: {\n type: 'hidden', update: 'color'\n },\n colorMode: {\n type: 'select',\n update: 'color',\n options: ColormakerRegistry.getModes()\n },\n\n roughness: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n metalness: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n diffuse: {\n type: 'color', buffer: true\n },\n\n diffuseInterior: {\n type: 'boolean', buffer: true\n },\n useInteriorColor: {\n type: 'boolean', buffer: true\n },\n interiorColor: {\n type: 'color', buffer: true\n },\n interiorDarkening: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n\n matrix: {\n type: 'hidden', buffer: true\n },\n\n disablePicking: {\n type: 'boolean', rebuild: true\n }\n\n }\n\n /**\n * @type {Viewer}\n */\n this.viewer = viewer\n\n /**\n * Counter that keeps track of tasks related to the creation of\n * the representation, including surface calculations.\n * @type {Counter}\n */\n this.tasks = new Counter()\n\n /**\n * @type {Queue}\n * @private\n */\n this.queue = new Queue(this.make.bind(this))\n\n /**\n * @type {Array}\n * @private\n */\n this.bufferList = []\n\n if (this.parameters.colorScheme) {\n this.parameters.colorScheme.options = ColormakerRegistry.getSchemes()\n }\n\n this.toBePrepared = false\n }\n\n init (params: Partial) {\n const p = params || {}\n\n this.clipNear = defaults(p.clipNear, 0)\n this.clipRadius = defaults(p.clipRadius, 0)\n this.clipCenter = defaults(p.clipCenter, new Vector3())\n this.flatShaded = defaults(p.flatShaded, false)\n this.side = defaults(p.side, 'double')\n this.opacity = defaults(p.opacity, 1.0)\n this.depthWrite = defaults(p.depthWrite, true)\n this.wireframe = defaults(p.wireframe, false)\n\n this.setColor(p.color, p)\n\n this.colorData = defaults(p.colorData, undefined)\n this.colorScheme = defaults(p.colorScheme, 'uniform')\n this.colorScale = defaults(p.colorScale, '')\n this.colorReverse = defaults(p.colorReverse, false)\n this.colorValue = defaults(p.colorValue, 0x909090)\n this.colorDomain = defaults(p.colorDomain, undefined)\n this.colorMode = defaults(p.colorMode, 'hcl')\n\n this.visible = defaults(p.visible, true)\n this.quality = defaults(p.quality, undefined)\n\n this.roughness = defaults(p.roughness, 0.4)\n this.metalness = defaults(p.metalness, 0.0)\n this.diffuse = defaults(p.diffuse, 0xffffff)\n\n this.diffuseInterior = defaults(p.diffuseInterior, false)\n this.useInteriorColor = defaults(p.useInteriorColor, false)\n this.interiorColor = defaults(p.interiorColor, 0x222222)\n this.interiorDarkening = defaults(p.interiorDarkening, 0)\n\n this.lazy = defaults(p.lazy, false)\n this.lazyProps = {\n build: false,\n bufferParams: {},\n what: {}\n }\n\n this.matrix = defaults(p.matrix, new Matrix4())\n\n this.disablePicking = defaults(p.disablePicking, false)\n\n // handle common parameters when applicable\n\n const tp = this.parameters\n\n if (tp.sphereDetail === true) {\n tp.sphereDetail = {\n type: 'integer', max: 3, min: 0, rebuild: 'impostor'\n }\n }\n if (tp.radialSegments === true) {\n tp.radialSegments = {\n type: 'integer', max: 25, min: 5, rebuild: 'impostor'\n }\n }\n if (tp.openEnded === true) {\n tp.openEnded = {\n type: 'boolean', rebuild: 'impostor', buffer: true\n }\n }\n if (tp.disableImpostor === true) {\n tp.disableImpostor = {\n type: 'boolean', rebuild: true\n }\n }\n\n if (p.quality === 'low') {\n if (tp.sphereDetail) this.sphereDetail = 0\n if (tp.radialSegments) this.radialSegments = 5\n } else if (p.quality === 'medium') {\n if (tp.sphereDetail) this.sphereDetail = 1\n if (tp.radialSegments) this.radialSegments = 10\n } else if (p.quality === 'high') {\n if (tp.sphereDetail) this.sphereDetail = 2\n if (tp.radialSegments) this.radialSegments = 20\n } else {\n if (tp.sphereDetail) {\n this.sphereDetail = defaults(p.sphereDetail, 1)\n }\n if (tp.radialSegments) {\n this.radialSegments = defaults(p.radialSegments, 10)\n }\n }\n\n if (tp.openEnded) {\n this.openEnded = defaults(p.openEnded, true)\n }\n\n if (tp.disableImpostor) {\n this.disableImpostor = defaults(p.disableImpostor, false)\n }\n\n }\n\n getColorParams (p?: {[k: string]: any}): { scheme: string, [k: string]: any } & ColormakerParameters {\n return Object.assign({\n\n data: this.colorData,\n scheme: this.colorScheme,\n scale: this.colorScale,\n reverse: this.colorReverse,\n value: this.colorValue,\n domain: this.colorDomain,\n mode: this.colorMode,\n colorSpace: this.colorSpace,\n\n }, p)\n }\n\n getBufferParams (p: {[k: string]: any} = {}) {\n return Object.assign({\n\n clipNear: this.clipNear,\n clipRadius: this.clipRadius,\n clipCenter: this.clipCenter,\n flatShaded: this.flatShaded,\n opacity: this.opacity,\n depthWrite: this.depthWrite,\n side: this.side,\n wireframe: this.wireframe,\n\n roughness: this.roughness,\n metalness: this.metalness,\n diffuse: this.diffuse,\n\n diffuseInterior: this.diffuseInterior,\n useInteriorColor: this.useInteriorColor,\n interiorColor: this.interiorColor,\n interiorDarkening: this.interiorDarkening,\n\n matrix: this.matrix,\n\n disablePicking: this.disablePicking\n\n }, p)\n }\n\n setColor (value: number | string | Color | undefined , p?: Partial) {\n const types = Object.keys(ColormakerRegistry.getSchemes())\n\n if (typeof value === 'string' && types.includes(value.toLowerCase())) {\n if (p) {\n p.colorScheme = value\n } else {\n this.setParameters({ colorScheme: value })\n }\n } else if (value !== undefined) {\n let val = new Color(value as string).getHex() //TODO\n if (p) {\n p.colorScheme = 'uniform'\n p.colorValue = val\n } else {\n this.setParameters({\n colorScheme: 'uniform', colorValue: val\n })\n }\n }\n\n return this\n }\n\n // TODO\n prepare (cb: ()=> void) {\n\n }\n\n create () {\n // this.bufferList.length = 0;\n }\n\n update (what?: any) {\n this.build()\n }\n\n build (updateWhat?: {[k: string]: boolean}) {\n if (this.lazy && (!this.visible || !this.opacity)) {\n this.lazyProps.build = true\n return\n }\n\n if (!this.toBePrepared) {\n this.tasks.increment()\n this.make()\n return\n }\n\n // don't let tasks accumulate\n if (this.queue.length() > 0) {\n this.tasks.change(1 - this.queue.length())\n this.queue.kill()\n } else {\n this.tasks.increment()\n }\n\n this.queue.push(updateWhat || false)\n }\n\n make (updateWhat?: boolean, callback?: () => void) {\n if (Debug) Log.time('Representation.make ' + this.type)\n\n const _make = () => {\n if (updateWhat) {\n this.update(updateWhat)\n this.viewer.requestRender()\n this.tasks.decrement()\n if (callback) callback()\n } else {\n this.clear()\n this.create()\n if (!this.manualAttach && !this.disposed) {\n if (Debug) Log.time('Representation.attach ' + this.type)\n this.attach(() => {\n if (Debug) Log.timeEnd('Representation.attach ' + this.type)\n this.tasks.decrement()\n if (callback) callback()\n })\n }\n }\n\n if (Debug) Log.timeEnd('Representation.make ' + this.type)\n }\n\n if (this.toBePrepared) {\n this.prepare(_make)\n } else {\n _make()\n }\n }\n\n attach (callback: () => void) {\n this.setVisibility(this.visible)\n\n callback()\n }\n\n /**\n * Set the visibility of the representation\n * @param {Boolean} value - visibility flag\n * @param {Boolean} [noRenderRequest] - whether or not to request a re-render from the viewer\n * @return {Representation} this object\n */\n setVisibility (value: boolean, noRenderRequest?: boolean): Representation {\n this.visible = value\n\n if (this.visible && this.opacity) {\n const lazyProps = this.lazyProps\n const bufferParams = lazyProps.bufferParams\n const what = lazyProps.what\n\n if (lazyProps.build) {\n lazyProps.build = false\n this.build()\n return this\n } else if (Object.keys(bufferParams).length || Object.keys(what).length) {\n lazyProps.bufferParams = {}\n lazyProps.what = {}\n this.updateParameters(bufferParams, what)\n }\n }\n\n this.bufferList.forEach(function (buffer) {\n buffer.setVisibility(value)\n })\n\n if (!noRenderRequest) this.viewer.requestRender()\n\n return this\n }\n\n /**\n * Set the visibility of the representation\n * @param {RepresentationParameters} params - parameters object\n * @param {Object} [what] - buffer data attributes to be updated,\n * note that this needs to be implemented in the\n * derived classes. Generally it allows more\n * fine-grained control over updating than\n * forcing a rebuild.\n * @param {Boolean} what.position - update position data\n * @param {Boolean} what.color - update color data\n * @param {Boolean} [rebuild] - whether or not to rebuild the representation\n * @return {Representation} this object\n */\n setParameters (params: Partial, what:{[propName: string]: any} = {}, rebuild = false) {\n const p = params || {}\n const tp = this.parameters\n const bufferParams: BufferParameters = {}\n\n if (!this.opacity && p.opacity !== undefined) {\n if (this.lazyProps.build) {\n this.lazyProps.build = false\n rebuild = true\n } else {\n Object.assign(bufferParams, this.lazyProps.bufferParams)\n Object.assign(what, this.lazyProps.what)\n this.lazyProps.bufferParams = {}\n this.lazyProps.what = {}\n }\n }\n\n this.setColor(p.color, p)\n\n for (let name in p) {\n if (p[ name ] === undefined) continue\n if (tp[ name ] == undefined ) continue // Skip nulls as well as undefined\n\n if (tp[ name ].int) p[ name ] = parseInt(p[ name ] as string)\n if (tp[ name ].float) p[ name ] = parseFloat(p[ name ] as string)\n\n // no value change\n if (p[ name ] === this[ name ] && (\n !p[ name ].equals || p[ name ].equals(this[ name ])\n )) continue\n\n if (this[ name ] && this[ name ].copy && p[ name ].copy) {\n this[ name ].copy(p[ name ])\n } else if (this[ name ] && this[ name ].set) {\n this[ name ].set(p[ name ])\n } else {\n this[ name ] = p[ name ]\n }\n\n // buffer param\n if (tp[ name ].buffer) {\n if (tp[ name ].buffer === true) {\n (bufferParams[ name as keyof BufferParameters ] as any) = p[ name ]\n } else {\n let key: (keyof BufferParameters) = tp[ name ].buffer;\n (bufferParams[ key ] as any) = p[ name ]\n }\n }\n\n // mark for update\n if (tp[ name ].update) {\n what[ tp[ name ].update ] = true\n }\n\n // mark for rebuild\n if (tp[ name ].rebuild &&\n !(tp[ name ].rebuild === 'impostor' &&\n ExtensionFragDepth && !this.disableImpostor)\n ) {\n rebuild = true\n }\n }\n\n //\n\n if (rebuild) {\n this.build()\n } else {\n this.updateParameters(bufferParams, what)\n }\n\n return this\n }\n\n updateParameters (bufferParams: BufferParameters | {} = {}, what?: any) {\n if (this.lazy && (!this.visible || !this.opacity) && bufferParams.hasOwnProperty('opacity') === false) {\n Object.assign(this.lazyProps.bufferParams, bufferParams)\n Object.assign(this.lazyProps.what, what)\n return\n }\n\n this.bufferList.forEach(function (buffer) {\n buffer.setParameters(bufferParams)\n })\n\n if (Object.keys(what).length) {\n this.update(what) // update buffer attribute\n }\n\n this.viewer.requestRender()\n }\n\n getParameters () {\n const params: Partial = {\n lazy: this.lazy,\n visible: this.visible,\n quality: this.quality\n }\n\n Object.keys(this.parameters).forEach(name => {\n if (this.parameters[ name ] !== null) {\n params[ name ] = this[ name ]\n }\n })\n\n return params\n }\n\n clear () {\n this.bufferList.forEach(buffer => {\n this.viewer.remove(buffer)\n buffer.dispose()\n })\n this.bufferList.length = 0\n\n this.viewer.requestRender()\n }\n\n dispose () {\n this.disposed = true\n this.queue.kill()\n this.tasks.dispose()\n this.clear()\n }\n}\n\nexport default Representation\n","/**\n * @file Worker\n * @author Alexander Rose \n * @private\n */\n\nimport { Log, Debug, WorkerRegistry } from '../globals'\n\nexport default class _Worker {\n\n pending = 0\n postCount = 0\n onmessageDict: { [k: number]: Function|undefined } = {}\n onerrorDict: { [k: number]: Function|undefined } = {}\n\n name: string\n blobUrl: string\n worker: Worker\n\n constructor (name: string) {\n\n this.name = name\n this.blobUrl = window.URL.createObjectURL(WorkerRegistry.get(name))\n this.worker = new Worker(this.blobUrl)\n\n WorkerRegistry.activeWorkerCount += 1\n\n this.worker.onmessage = (event: any) => {\n this.pending -= 1\n const postId = event.data.__postId\n\n if (Debug) Log.timeEnd('Worker.postMessage ' + name + ' #' + postId)\n\n const onmessage = this.onmessageDict[ postId ]\n if (onmessage) {\n onmessage.call(this.worker, event)\n } else {\n // Log.debug('No onmessage', postId, name)\n }\n\n delete this.onmessageDict[ postId ]\n delete this.onerrorDict[ postId ]\n }\n\n this.worker.onerror = (event: any) => {\n this.pending -= 1\n if (event.data) {\n const postId = event.data.__postId\n\n const onerror = this.onerrorDict[ postId ]\n if (onerror) {\n onerror.call(this.worker, event)\n } else {\n Log.error('Worker.onerror', postId, name, event)\n }\n\n delete this.onmessageDict[ postId ]\n delete this.onerrorDict[ postId ]\n } else {\n Log.error('Worker.onerror', name, event)\n }\n }\n }\n\n post (aMessage: any = {}, transferList?: any, onmessage?: Function, onerror?: Function) {\n this.onmessageDict[ this.postCount ] = onmessage\n this.onerrorDict[ this.postCount ] = onerror\n\n aMessage.__name = this.name\n aMessage.__postId = this.postCount\n aMessage.__debug = Debug\n\n if (Debug) Log.time(`Worker.postMessage ${this.name} #${this.postCount}`)\n\n try {\n this.worker.postMessage(aMessage, transferList)\n } catch (error) {\n Log.error('worker.post:', error)\n this.worker.postMessage(aMessage)\n }\n\n this.pending += 1\n this.postCount += 1\n\n return this\n }\n\n terminate () {\n if (this.worker) {\n this.worker.terminate()\n window.URL.revokeObjectURL(this.blobUrl)\n WorkerRegistry.activeWorkerCount -= 1\n } else {\n Log.log('no worker to terminate')\n }\n }\n}\n","/**\n * @file Worker Pool\n * @author Alexander Rose \n * @private\n */\n\nimport Worker from './worker'\n\nclass WorkerPool {\n maxCount: number\n pool: Worker[] = []\n count = 0\n name: string\n\n constructor (name: string, maxCount = 2) {\n this.maxCount = Math.min(8, maxCount)\n this.name = name\n }\n\n post (aMessage: any = {}, transferList?: any, onmessage?: Function, onerror?: Function) {\n const worker = this.getNextWorker()\n if (worker) {\n worker.post(aMessage, transferList, onmessage, onerror)\n } else {\n console.error('unable to get worker from pool')\n }\n\n return this\n }\n\n terminate () {\n this.pool.forEach(function (worker) {\n worker.terminate()\n })\n }\n\n getNextWorker () {\n let nextWorker\n let minPending = Infinity\n\n for (let i = 0; i < this.maxCount; ++i) {\n if (i >= this.count) {\n nextWorker = new Worker(this.name)\n this.pool.push(nextWorker)\n this.count += 1\n break\n }\n\n const worker = this.pool[ i ]\n\n if (worker.pending === 0) {\n nextWorker = worker\n break\n } else if (worker.pending < minPending) {\n minPending = worker.pending\n nextWorker = worker\n }\n }\n\n return nextWorker\n }\n}\n\nWorkerPool.prototype.constructor = WorkerPool\n\nexport default WorkerPool\n","/**\n * @file Vector Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { NumberArray } from '../types'\nimport { EPS } from './math-constants'\n\n/**\n * Calculate the two intersection points\n * Converted to JavaScript from\n * {@link http://paulbourke.net/geometry/pointlineplane/lineline.c}\n */\nexport function lineLineIntersect (p1: Vector3, p2: Vector3, p3: Vector3, p4: Vector3) {\n const p13 = new Vector3()\n const p43 = new Vector3()\n const p21 = new Vector3()\n let d1343, d4321, d1321, d4343, d2121\n let denom, numer\n\n p13.x = p1.x - p3.x\n p13.y = p1.y - p3.y\n p13.z = p1.z - p3.z\n p43.x = p4.x - p3.x\n p43.y = p4.y - p3.y\n p43.z = p4.z - p3.z\n if (Math.abs(p43.x) < EPS && Math.abs(p43.y) < EPS && Math.abs(p43.z) < EPS) { return null }\n\n p21.x = p2.x - p1.x\n p21.y = p2.y - p1.y\n p21.z = p2.z - p1.z\n if (Math.abs(p21.x) < EPS && Math.abs(p21.y) < EPS && Math.abs(p21.z) < EPS) { return null }\n\n d1343 = p13.x * p43.x + p13.y * p43.y + p13.z * p43.z\n d4321 = p43.x * p21.x + p43.y * p21.y + p43.z * p21.z\n d1321 = p13.x * p21.x + p13.y * p21.y + p13.z * p21.z\n d4343 = p43.x * p43.x + p43.y * p43.y + p43.z * p43.z\n d2121 = p21.x * p21.x + p21.y * p21.y + p21.z * p21.z\n\n denom = d2121 * d4343 - d4321 * d4321\n if (Math.abs(denom) < EPS) { return null }\n numer = d1343 * d4321 - d1321 * d4343\n\n const mua = numer / denom\n const mub = (d1343 + d4321 * mua) / d4343\n\n const pa = new Vector3(\n p1.x + mua * p21.x,\n p1.y + mua * p21.y,\n p1.z + mua * p21.z\n )\n const pb = new Vector3(\n p3.x + mub * p43.x,\n p3.y + mub * p43.y,\n p3.z + mub * p43.z\n )\n\n return [ pa, pb ]\n}\n\nexport function calculateMeanVector3 (array: NumberArray) {\n const n = array.length\n const m = n / 3\n\n let x = 0\n let y = 0\n let z = 0\n\n for (let i = 0; i < n; i += 3) {\n x += array[ i + 0 ]\n y += array[ i + 1 ]\n z += array[ i + 2 ]\n }\n\n return new Vector3(x / m, y / m, z / m)\n}\n\nexport function isPointOnSegment (p: Vector3, l1: Vector3, l2: Vector3) {\n const len = l1.distanceTo(l2)\n\n return p.distanceTo(l1) <= len && p.distanceTo(l2) <= len\n}\n\nexport function projectPointOnVector (point: Vector3, vector: Vector3, origin?: Vector3) {\n if (origin) {\n point.sub(origin).projectOnVector(vector).add(origin)\n } else {\n point.projectOnVector(vector)\n }\n\n return point\n}\n\nexport function computeBoundingBox (array: NumberArray) {\n let minX = +Infinity\n let minY = +Infinity\n let minZ = +Infinity\n let maxX = -Infinity\n let maxY = -Infinity\n let maxZ = -Infinity\n for (let i = 0, l = array.length; i < l; i += 3) {\n const x = array[ i ]\n const y = array[ i + 1 ]\n const z = array[ i + 2 ]\n if (x < minX) minX = x\n if (y < minY) minY = y\n if (z < minZ) minZ = z\n if (x > maxX) maxX = x\n if (y > maxY) maxY = y\n if (z > maxZ) maxZ = z\n }\n return [\n v3new([ minX, minY, minZ ]),\n v3new([ maxX, maxY, maxZ ])\n ]\n}\n(computeBoundingBox as any).__deps = [ v3new ]\n\nexport function applyMatrix4toVector3array (m: Float32Array, a: Float32Array) {\n for (let i = 0, il = a.length; i < il; i += 3) {\n const x = a[ i ]\n const y = a[ i + 1 ]\n const z = a[ i + 2 ]\n a[ i ] = m[ 0 ] * x + m[ 4 ] * y + m[ 8 ] * z + m[ 12 ]\n a[ i + 1 ] = m[ 1 ] * x + m[ 5 ] * y + m[ 9 ] * z + m[ 13 ]\n a[ i + 2 ] = m[ 2 ] * x + m[ 6 ] * y + m[ 10 ] * z + m[ 14 ]\n }\n}\n\nexport function applyMatrix3toVector3array (m: Float32Array, a: Float32Array) {\n for (let i = 0, il = a.length; i < il; i += 3) {\n const x = a[ i ]\n const y = a[ i + 1 ]\n const z = a[ i + 2 ]\n a[ i ] = m[ 0 ] * x + m[ 3 ] * y + m[ 6 ] * z\n a[ i + 1 ] = m[ 1 ] * x + m[ 4 ] * y + m[ 7 ] * z\n a[ i + 2 ] = m[ 2 ] * x + m[ 5 ] * y + m[ 8 ] * z\n }\n}\n\nexport function normalizeVector3array (a: Float32Array) {\n for (let i = 0, il = a.length; i < il; i += 3) {\n const x = a[ i ]\n const y = a[ i + 1 ]\n const z = a[ i + 2 ]\n const len2 = x * x + y * y + z * z\n if (len2 > 0) { // avoid divide by zero\n const s = 1 / Math.sqrt(len2)\n a[ i ] = x * s\n a[ i + 1 ] = y * s\n a[ i + 2 ] = z * s\n }\n // else leave as all zeros\n }\n}\n\nexport function v3new (array?: NumberArray) {\n return new Float32Array(array as any || 3) // TODO\n}\n\nexport function v3cross (out: Float32Array, a: Float32Array, b: Float32Array) {\n const ax = a[0]\n const ay = a[1]\n const az = a[2]\n const bx = b[0]\n const by = b[1]\n const bz = b[2]\n out[0] = ay * bz - az * by\n out[1] = az * bx - ax * bz\n out[2] = ax * by - ay * bx\n}\n\nexport function v3dot (a: Float32Array, b: Float32Array) {\n return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]\n}\n\nexport function v3sub (out: Float32Array, a: Float32Array, b: Float32Array) {\n out[0] = a[0] - b[0]\n out[1] = a[1] - b[1]\n out[2] = a[2] - b[2]\n}\n\nexport function v3add (out: Float32Array, a: Float32Array, b: Float32Array) {\n out[0] = a[0] + b[0]\n out[1] = a[1] + b[1]\n out[2] = a[2] + b[2]\n}\n\nexport function v3fromArray (out: Float32Array, array: Float32Array, offset = 0) {\n out[0] = array[offset]\n out[1] = array[offset + 1]\n out[2] = array[offset + 2]\n}\n\nexport function v3toArray (input: Float32Array, array: Float32Array, offset = 0) {\n array[offset] = input[0]\n array[offset + 1] = input[1]\n array[offset + 2] = input[2]\n}\n\nexport function v3forEach (array: Float32Array, fn: (i: Float32Array, j: Float32Array, k: Float32Array) => void, b: Float32Array) {\n const a = v3new()\n for (let i = 0, n = array.length; i < n; i += 3) {\n v3fromArray(a, array, i)\n fn(a, a, b)\n v3toArray(a, array, i)\n }\n}\n(v3forEach as any).__deps = [ v3new, v3fromArray, v3toArray ]\n\nexport function v3length2 (a: Float32Array) {\n return a[0] * a[0] + a[1] * a[1] + a[2] * a[2]\n}\n\nexport function v3length (a: Float32Array) {\n return Math.sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2])\n}\n\nexport function v3divide (out: Float32Array, a: Float32Array, b: Float32Array) {\n out[0] = a[0] / b[0]\n out[1] = a[1] / b[1]\n out[2] = a[2] / b[2]\n}\n\nexport function v3multiply (out: Float32Array, a: Float32Array, b: Float32Array) {\n out[0] = a[0] * b[0]\n out[1] = a[1] * b[1]\n out[2] = a[2] * b[2]\n}\n\nexport function v3divideScalar (out: Float32Array, a: Float32Array, s: number) {\n v3multiplyScalar(out, a, 1 / s)\n}\n(v3divideScalar as any).__deps = [ v3multiplyScalar ]\n\nexport function v3multiplyScalar (out: Float32Array, a: Float32Array, s: number) {\n out[0] = a[0] * s\n out[1] = a[1] * s\n out[2] = a[2] * s\n}\n\nexport function v3normalize (out: Float32Array, a: Float32Array) {\n const length2 = v3length2(a)\n if (length2 == 0) {\n out[0] = a[0]\n out[1] = a[1]\n out[2] = a[2]\n } else {\n v3multiplyScalar(out, a, 1 / Math.sqrt(length2))\n }\n}\n(v3normalize as any).__deps = [ v3multiplyScalar, v3length2 ]\n\nexport function v3subScalar (out: Float32Array, a: Float32Array, s: number) {\n out[0] = a[0] - s\n out[1] = a[1] - s\n out[2] = a[2] - s\n}\n\nexport function v3addScalar (out: Float32Array, a: Float32Array, s: number) {\n out[0] = a[0] + s\n out[1] = a[1] + s\n out[2] = a[2] + s\n}\n\nexport function v3floor (out: Float32Array, a: Float32Array) {\n out[0] = Math.floor(a[0])\n out[1] = Math.floor(a[1])\n out[2] = Math.floor(a[2])\n}\n\nexport function v3ceil (out: Float32Array, a: Float32Array) {\n out[0] = Math.ceil(a[0])\n out[1] = Math.ceil(a[1])\n out[2] = Math.ceil(a[2])\n}\n\nexport function v3round (out: Float32Array, a: Float32Array) {\n out[0] = Math.round(a[0])\n out[1] = Math.round(a[1])\n out[2] = Math.round(a[2])\n}\n\nexport function v3negate (out: Float32Array, a: Float32Array) {\n out[0] = -a[0]\n out[1] = -a[1]\n out[2] = -a[2]\n}\n\nexport function v3angle (a: Float32Array, b: Float32Array) {\n const ax = a[0]\n const ay = a[1]\n const az = a[2]\n const bx = b[0]\n const by = b[1]\n const bz = b[2]\n const cx = ay * bz - az * by\n const cy = az * bx - ax * bz\n const cz = ax * by - ay * bx\n const s = Math.sqrt(cx * cx + cy * cy + cz * cz)\n const c = ax * bx + ay * by + az * bz\n return Math.atan2(s, c)\n}\n","/**\n * @file Dash\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport { WideLineBufferData } from '../buffer/wideline-buffer'\nimport {\n calculateDirectionArray, calculateCenterArray,\n replicateArrayEntries, replicateArray3Entries\n} from '../math/array-utils'\n\nexport function getFixedCountDashData (data: T, segmentCount: number = 9) {\n\n const s = Math.floor(segmentCount / 2)\n const n = data.position1.length / 3\n const sn = s * n\n const sn3 = sn * 3\n const step = 1 / segmentCount\n\n const direction = calculateDirectionArray(data.position1, data.position2)\n const position1 = new Float32Array(sn3)\n const position2 = new Float32Array(sn3)\n\n const v = new Vector3()\n\n for (let i = 0; i < n; ++i) {\n const i3 = i * 3\n v.set(direction[ i3 ], direction[ i3 + 1 ], direction[ i3 + 2 ])\n\n const x = data.position1[ i3 ]\n const y = data.position1[ i3 + 1 ]\n const z = data.position1[ i3 + 2 ]\n\n for (let j = 0; j < s; ++j) {\n const j3 = s * i3 + j * 3\n\n const f1 = step * (j * 2 + 1)\n const f2 = step * (j * 2 + 2)\n\n position1[ j3 ] = x + v.x * f1\n position1[ j3 + 1 ] = y + v.y * f1\n position1[ j3 + 2 ] = z + v.z * f1\n\n position2[ j3 ] = x + v.x * f2\n position2[ j3 + 1 ] = y + v.y * f2\n position2[ j3 + 2 ] = z + v.z * f2\n }\n }\n\n const position = calculateCenterArray(position1, position2) as Float32Array\n const color = replicateArray3Entries(data.color!, s) // TODO\n const color2 = color\n\n const d: any = { position, position1, position2, color, color2 }\n\n if ((data as any).radius) { // TODO\n d.radius = replicateArrayEntries((data as any).radius, s) // TODO\n }\n\n if (data.picking && data.picking.array) {\n data.picking.array = replicateArrayEntries(data.picking.array, s)\n d.picking = data.picking\n }\n if (data.primitiveId) {\n d.primitiveId = replicateArrayEntries(data.primitiveId, s)\n }\n\n return d as T\n}\n\nexport function getFixedLengthDashData (data: T, segmentLength: number = 0.1) {\n\n const direction = calculateDirectionArray(data.position1, data.position2)\n const pos1: number[] = []\n const pos2: number[] = []\n const col: number[] = []\n const rad: number[]|undefined = (data as any).radius ? [] : undefined\n const pick: number[]|undefined = (data as any).picking ? [] : undefined\n const id: number[]|undefined = (data as any).primitiveId ? [] : undefined\n\n const v = new Vector3()\n const n = data.position1.length / 3\n\n let k = 0\n\n for (let i = 0; i < n; ++i) {\n const i3 = i * 3\n v.set(direction[ i3 ], direction[ i3 + 1 ], direction[ i3 + 2 ])\n\n const vl = v.length()\n const segmentCount = vl / segmentLength\n const s = Math.floor(segmentCount / 2)\n const step = 1 / segmentCount\n\n const x = data.position1[ i3 ]\n const y = data.position1[ i3 + 1 ]\n const z = data.position1[ i3 + 2 ]\n\n for (let j = 0; j < s; ++j) {\n const j3 = k * 3 + j * 3\n\n const f1 = step * (j * 2 + 1)\n const f2 = step * (j * 2 + 2)\n\n pos1[ j3 ] = x + v.x * f1\n pos1[ j3 + 1 ] = y + v.y * f1\n pos1[ j3 + 2 ] = z + v.z * f1\n\n pos2[ j3 ] = x + v.x * f2\n pos2[ j3 + 1 ] = y + v.y * f2\n pos2[ j3 + 2 ] = z + v.z * f2\n\n if (data.color) {\n col[ j3 ] = data.color[ i3 ]\n col[ j3 + 1 ] = data.color[ i3 + 1 ]\n col[ j3 + 2 ] = data.color[ i3 + 2 ]\n }\n\n if (rad) rad[ k + j ] = (data as any).radius[ i ]\n if (pick) {\n if ((data as any).picking.array) {\n pick[ k + j ] = (data as any).picking.array[ i ]\n } else {\n pick[ k + j ] = i\n }\n }\n if (id) id[ k + j ] = (data as any).primitiveId[ i ]\n }\n\n k += s\n }\n\n const position1 = new Float32Array(pos1)\n const position2 = new Float32Array(pos2)\n const position = calculateCenterArray(position1, position2) as Float32Array\n const color = new Float32Array(col)\n const color2 = color\n\n const d: any = { position, position1, position2, color, color2 }\n\n if (rad) d.radius = new Float32Array(rad)\n if (pick && data.picking) {\n data.picking.array = new Float32Array(pick)\n d.picking = data.picking\n }\n if (id) d.primitiveId = new Float32Array(id)\n\n return d as T\n}\n\nexport function getFixedLengthWrappedDashData (data: T, segmentLength: number = 0.1) {\n\n const direction = calculateDirectionArray(data.position1, data.position2)\n const pos1: number[] = []\n const pos2: number[] = []\n const col: number[] = []\n const rad: number[]|undefined = (data as any).radius ? [] : undefined\n const pick: number[]|undefined = (data as any).picking ? [] : undefined\n const id: number[]|undefined = (data as any).primitiveId ? [] : undefined\n\n const v = new Vector3()\n const n = data.position1.length / 3\n\n let remaining = segmentLength\n let drawing = true\n\n let k = 0\n let k3 = 0\n let kprev = 0\n\n for (let i = 0; i < n; ++i) {\n const i3 = i * 3\n const x = data.position1[ i3 ]\n const y = data.position1[ i3 + 1 ]\n const z = data.position1[ i3 + 2 ]\n\n v.set(direction[ i3 ], direction[ i3 + 1 ], direction[ i3 + 2 ])\n const vl = v.length()\n\n if (drawing) {\n pos1[ k3 ] = x\n pos1[ k3 + 1 ] = y\n pos1[ k3 + 2 ] = z\n }\n\n let dist = remaining\n const inv = 1 / vl\n while (dist < vl) {\n const a = drawing ? pos2 : pos1\n a[ k3 ] = x + v.x * dist * inv\n a[ k3 + 1 ] = y + v.y * dist * inv\n a[ k3 + 2 ] = z + v.z * dist * inv\n if (drawing) {\n k++\n k3 = k * 3\n }\n drawing = !drawing\n remaining = segmentLength\n dist += segmentLength\n }\n\n if (drawing) {\n pos2[ k3 ] = data.position2[ i3 ]\n pos2[ k3 + 1 ] = data.position2[ i3 + 1 ]\n pos2[ k3 + 2 ] = data.position2[ i3 + 2 ]\n k++\n k3 = k * 3\n }\n\n remaining = dist - vl\n\n for (let j = kprev; j < k ; j++){\n if (data.color) {\n const j3 = j * 3\n col[ j3 ] = data.color[ i3 ]\n col[ j3 + 1 ] = data.color[ i3 + 1 ]\n col[ j3 + 2 ] = data.color[ i3 + 2 ]\n }\n\n if (rad) rad[ j ] = (data as any).radius[ i ]\n if (pick) {\n if ((data as any).picking.array) {\n pick[ j ] = (data as any).picking.array[ i ]\n } else {\n pick[ j ] = i\n }\n }\n if (id) id[ j ] = (data as any).primitiveId[ i ]\n }\n\n kprev = k\n\n }\n\n if (!drawing && n > 0) {\n const k3 = k * 3\n pos2[ k3 ] = data.position2[ 3 * n - 3 ]\n pos2[ k3 + 1 ] = data.position2[ 3 * n - 2 ]\n pos2[ k3 + 1 ] = data.position2[ 3 * n - 1 ]\n }\n\n const position1 = new Float32Array(pos1)\n const position2 = new Float32Array(pos2)\n const position = calculateCenterArray(position1, position2) as Float32Array\n const color = new Float32Array(col)\n const color2 = color\n\n const d: any = { position, position1, position2, color, color2 }\n\n if (rad) d.radius = new Float32Array(rad)\n if (pick && data.picking) {\n data.picking.array = new Float32Array(pick)\n d.picking = data.picking\n }\n if (id) d.primitiveId = new Float32Array(id)\n\n return d as T\n}\n","/**\n * @file Primitive\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Color, Box3 } from 'three'\n\nimport { BufferRegistry, PickerRegistry } from '../globals'\nimport Shape from './shape'\nimport { getFixedLengthDashData } from './dash'\n\nfunction addElement (elm: any, array: any[]) {\n if (elm.toArray !== undefined) {\n elm = elm.toArray()\n } else if (elm.x !== undefined) {\n elm = [ elm.x, elm.y, elm.z ]\n } else if (elm.r !== undefined) {\n elm = [ elm.r, elm.g, elm.b ]\n }\n array.push.apply(array, elm)\n}\n\nconst tmpVec = new Vector3()\n\nexport type PrimitiveFields = { [k: string]: string }\n\n/**\n * Base class for geometry primitives\n * @interface\n */\nexport abstract class Primitive {\n static type = ''\n static fields: PrimitiveFields = {}\n\n static get Picker () { return PickerRegistry.get(this.type) }\n static get Buffer () { return BufferRegistry.get(this.type) }\n\n static getShapeKey (name: string) {\n return this.type + name[0].toUpperCase() + name.substr(1)\n }\n\n static expandBoundingBox (box: Box3, data: any) {}\n\n static valueToShape (shape: Shape, name: string, value: any) {\n const data = shape._primitiveData[this.getShapeKey(name)]\n const type = this.fields[name]\n\n switch (type) {\n case 'v3':\n case 'c':\n addElement(value, data)\n break\n default:\n data.push(value)\n }\n }\n\n static objectToShape (shape: Shape, data: any) {\n Object.keys(this.fields).forEach(name => {\n this.valueToShape(shape, name, data[name])\n })\n this.valueToShape(shape, 'name', data.name)\n this.expandBoundingBox(shape.boundingBox, data)\n }\n\n static valueFromShape (shape: Shape, pid: number, name: string) {\n const data = shape._primitiveData[this.getShapeKey(name)]\n const type = this.fields[name]\n\n switch (type) {\n case 'v3':\n return new Vector3().fromArray(data, 3 * pid)\n case 'c':\n return new Color().fromArray(data, 3 * pid)\n default:\n return data[pid]\n }\n }\n\n static objectFromShape (shape: Shape, pid: number) {\n let name = this.valueFromShape(shape, pid, 'name')\n if (name === undefined) {\n name = `${this.type}: ${pid} (${shape.name})`\n }\n const o: any = { shape, name }\n\n Object.keys(this.fields).forEach(name => {\n o[name] = this.valueFromShape(shape, pid, name)\n })\n\n return o\n }\n\n static arrayFromShape (shape: Shape, name: string) {\n const data = shape._primitiveData[this.getShapeKey(name)]\n const type = this.fields[name]\n\n switch (type) {\n case 's':\n return data\n default:\n return new Float32Array(data)\n }\n }\n\n static dataFromShape (shape: Shape) {\n const data: any = {}\n\n if (this.Picker) {\n data.picking = new this.Picker(shape)\n }\n\n Object.keys(this.fields).forEach(name => {\n data[name] = this.arrayFromShape(shape, name)\n })\n\n return data\n }\n\n static bufferFromShape (shape: Shape, params: any) {\n return new this.Buffer(this.dataFromShape(shape), params)\n }\n}\n\n/**\n * Sphere geometry primitive\n */\nexport class SpherePrimitive extends Primitive {\n static type = 'sphere'\n\n static fields = {\n position: 'v3',\n color: 'c',\n radius: 'f'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n return this.valueFromShape(shape, pid, 'position')\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position))\n }\n}\n\n/**\n * Box geometry primitive\n */\nexport class BoxPrimitive extends Primitive {\n static type = 'box'\n\n static fields = {\n position: 'v3',\n color: 'c',\n size: 'f',\n heightAxis: 'v3',\n depthAxis: 'v3'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n return this.valueFromShape(shape, pid, 'position')\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position))\n }\n}\n\n/**\n * Octahedron geometry primitive\n */\nexport class OctahedronPrimitive extends BoxPrimitive {\n static type = 'octahedron'\n}\n\n/**\n * Tetrahedron geometry primitive\n */\nexport class TetrahedronPrimitive extends BoxPrimitive {\n static type = 'tetrahedron'\n}\n\n/**\n * Cylinder geometry primitive\n */\nexport class CylinderPrimitive extends Primitive {\n static type = 'cylinder'\n\n static fields = {\n position1: 'v3',\n position2: 'v3',\n color: 'c',\n radius: 'f'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n const p1 = this.valueFromShape(shape, pid, 'position1')\n const p2 = this.valueFromShape(shape, pid, 'position2')\n return p1.add(p2).multiplyScalar(0.5)\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position1))\n box.expandByPoint(tmpVec.fromArray(data.position2))\n }\n\n static bufferFromShape (shape: Shape, params: any = {}) {\n let data = this.dataFromShape(shape)\n if (this.type === 'cylinder' && params.dashedCylinder) {\n data = getFixedLengthDashData(data)\n }\n return new this.Buffer(data, params)\n }\n}\n\n/**\n * Arrow geometry primitive\n */\nexport class ArrowPrimitive extends CylinderPrimitive {\n static type = 'arrow'\n}\n\n/**\n * Cone geometry primitive\n */\nexport class ConePrimitive extends CylinderPrimitive {\n static type = 'cone'\n}\n\n/**\n * Ellipsoid geometry primitive\n */\nexport class EllipsoidPrimitive extends SpherePrimitive {\n static type = 'ellipsoid'\n\n static fields = {\n position: 'v3',\n color: 'c',\n radius: 'f',\n majorAxis: 'v3',\n minorAxis: 'v3'\n }\n}\n\n/**\n * Torus geometry primitive\n */\nexport class TorusPrimitive extends EllipsoidPrimitive {\n static type = 'torus'\n}\n\n/**\n * Text geometry primitive\n */\nexport class TextPrimitive extends Primitive {\n static type = 'text'\n\n static fields = {\n position: 'v3',\n color: 'c',\n size: 'f',\n text: 's'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n return this.valueFromShape(shape, pid, 'position')\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position))\n }\n}\n\n/**\n * Point primitive\n */\nexport class PointPrimitive extends Primitive {\n static type = 'point'\n\n static fields = {\n position: 'v3',\n color: 'c',\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n return this.valueFromShape(shape, pid, 'position')\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position))\n }\n}\n\n/**\n * Wideline geometry primitive\n */\nexport class WidelinePrimitive extends Primitive {\n static type = 'wideline'\n\n static fields = {\n position1: 'v3',\n position2: 'v3',\n color: 'c'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n const p1 = this.valueFromShape(shape, pid, 'position1')\n const p2 = this.valueFromShape(shape, pid, 'position2')\n return p1.add(p2).multiplyScalar(0.5)\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position1))\n box.expandByPoint(tmpVec.fromArray(data.position2))\n }\n}\n","/**\n * @file Spatial Hash\n * @author Alexander Rose \n * @private\n */\n\nimport { Box3 } from 'three'\n\nexport type Positions = {\n x: ArrayLike,\n y: ArrayLike,\n z: ArrayLike,\n count?:number\n}\n\nfunction createBoundingBox(positions: Positions) {\n const { x, y, z } = positions\n const boundingBox = new Box3()\n const count = x.length\n const { min, max } = boundingBox\n\n for (let i = 0; i < count; i++) {\n min.x = Math.min(x[i], min.x)\n min.y = Math.min(y[i], min.y)\n min.z = Math.min(z[i], min.z)\n max.x = Math.max(x[i], max.x)\n max.y = Math.max(y[i], max.y)\n max.z = Math.max(z[i], max.z)\n }\n\n return boundingBox\n}\n\nexport default class SpatialHash {\n exp = 3\n\n minX: number\n minY: number\n minZ: number\n\n boundX: number\n boundY: number\n boundZ: number\n\n grid: Uint32Array\n bucketCount: Uint16Array\n bucketOffset: Uint32Array\n bucketArray: Int32Array\n\n xArray: ArrayLike\n yArray: ArrayLike\n zArray: ArrayLike\n\n constructor(positions: Positions, boundingBox?: Box3) {\n const bb = boundingBox || createBoundingBox(positions)\n this.minX = bb.min.x\n this.minY = bb.min.y\n this.minZ = bb.min.z\n this.boundX = ((bb.max.x - this.minX) >> this.exp) + 1\n this.boundY = ((bb.max.y - this.minY) >> this.exp) + 1\n this.boundZ = ((bb.max.z - this.minZ) >> this.exp) + 1\n\n const n = this.boundX * this.boundY * this.boundZ\n const an = (positions.count !== undefined) ? positions.count : positions.x.length\n\n const xArray = positions.x\n const yArray = positions.y\n const zArray = positions.z\n\n let count = 0\n const grid = new Uint32Array(n)\n const bucketIndex = new Int32Array(an)\n for (let i = 0; i < an; ++i) {\n const x = (xArray[ i ] - this.minX) >> this.exp\n const y = (yArray[ i ] - this.minY) >> this.exp\n const z = (zArray[ i ] - this.minZ) >> this.exp\n const idx = (((x * this.boundY) + y) * this.boundZ) + z\n if ((grid[ idx ] += 1) === 1) {\n count += 1\n }\n bucketIndex[ i ] = idx\n }\n\n const bucketCount = new Uint16Array(count)\n for (let i = 0, j = 0; i < n; ++i) {\n const c = grid[ i ]\n if (c > 0) {\n grid[ i ] = j + 1\n bucketCount[ j ] = c\n j += 1\n }\n }\n\n const bucketOffset = new Uint32Array(count)\n for (let i = 1; i < count; ++i) {\n bucketOffset[ i ] += bucketOffset[ i - 1 ] + bucketCount[ i - 1 ]\n }\n\n const bucketFill = new Uint16Array(count)\n const bucketArray = new Int32Array(an)\n for (let i = 0; i < an; ++i) {\n const bucketIdx = grid[ bucketIndex[ i ] ]\n if (bucketIdx > 0) {\n const k = bucketIdx - 1\n bucketArray[ bucketOffset[ k ] + bucketFill[ k ] ] = i\n bucketFill[ k ] += 1\n }\n }\n\n this.grid = grid\n this.bucketCount = bucketCount\n this.bucketOffset = bucketOffset\n this.bucketArray = bucketArray\n\n this.xArray = xArray\n this.yArray = yArray\n this.zArray = zArray\n }\n\n within (x: number, y: number, z: number, r: number) {\n const result: number[] = []\n\n this.eachWithin(x, y, z, r, atomIndex => result.push(atomIndex))\n\n return result\n }\n\n eachWithin (x: number, y: number, z: number, r: number, callback: (atomIndex: number, dSq: number) => void) {\n const rSq = r * r\n\n const loX = Math.max(0, (x - r - this.minX) >> this.exp)\n const loY = Math.max(0, (y - r - this.minY) >> this.exp)\n const loZ = Math.max(0, (z - r - this.minZ) >> this.exp)\n\n const hiX = Math.min(this.boundX, ((x + r - this.minX) >> this.exp) + 1)\n const hiY = Math.min(this.boundY, ((y + r - this.minY) >> this.exp) + 1)\n const hiZ = Math.min(this.boundZ, ((z + r - this.minZ) >> this.exp) + 1)\n\n for (let ix = loX; ix < hiX; ++ix) {\n for (let iy = loY; iy < hiY; ++iy) {\n for (let iz = loZ; iz < hiZ; ++iz) {\n const idx = (((ix * this.boundY) + iy) * this.boundZ) + iz\n const bucketIdx = this.grid[ idx ]\n\n if (bucketIdx > 0) {\n const k = bucketIdx - 1\n const offset = this.bucketOffset[ k ]\n const count = this.bucketCount[ k ]\n const end = offset + count\n\n for (let i = offset; i < end; ++i) {\n const atomIndex = this.bucketArray[ i ]\n const dx = this.xArray[ atomIndex ] - x\n const dy = this.yArray[ atomIndex ] - y\n const dz = this.zArray[ atomIndex ] - z\n\n const dSq = dx * dx + dy * dy + dz * dz\n if (dSq <= rSq) callback(atomIndex, dSq)\n }\n }\n }\n }\n }\n }\n}","/**\n * @file Store\n * @author Alexander Rose \n * @private\n */\n\nimport { Log } from '../globals'\nimport { getTypedArray, TypedArrayString } from '../utils'\n\nexport type StoreField = [string, number, TypedArrayString]\n\n/**\n * Store base class\n * @interface\n */\nexport default class Store {\n [k: string]: any\n\n length: number\n count: number\n\n _fields: StoreField[]\n get _defaultFields(): StoreField[] { return [] }\n\n /**\n * @param {Integer} [size] - initial size\n */\n constructor (size = 0) {\n this._fields = this._defaultFields\n this._init(0)\n }\n\n /**\n * Initialize the store\n * @param {Integer} size - size to initialize\n * @return {undefined}\n */\n _init (size: number) {\n this.length = size\n this.count = 0\n\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const [name, size, type]: StoreField = this._fields[ i ]\n this._initField(name, size, type)\n }\n }\n\n /**\n * Initialize a field\n * @param {String} name - field name\n * @param {Integer} size - element size\n * @param {String} type - data type, one of int8, int16, int32,\n * uint8, uint16, uint32, float32\n * @return {undefined}\n */\n _initField (name: string, size: number, type: TypedArrayString) {\n this[ name ] = getTypedArray(type, this.length * size)\n }\n\n /**\n * Add a field\n * @param {String} name - field name\n * @param {Integer} size - element size\n * @param {String} type - data type, one of int8, int16, int32,\n * uint8, uint16, uint32, float32\n * @return {undefined}\n */\n addField (name: string, size: number, type: TypedArrayString) {\n this._fields.push([name, size, type])\n this._initField(name, size, type)\n }\n\n /**\n * Resize the store to the new size\n * @param {Integer} size - new size\n * @return {undefined}\n */\n resize (size?: number) {\n // Log.time( \"Store.resize\" );\n\n this.length = Math.round(size || 0)\n this.count = Math.min(this.count, this.length)\n\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const name = this._fields[ i ][ 0 ]\n const itemSize = this._fields[ i ][ 1 ]\n const arraySize = this.length * itemSize\n const tmpArray = new this[ name ].constructor(arraySize)\n\n if (this[ name ].length > arraySize) {\n tmpArray.set(this[ name ].subarray(0, arraySize))\n } else {\n tmpArray.set(this[ name ])\n }\n this[ name ] = tmpArray\n }\n\n // Log.timeEnd( \"Store.resize\" );\n }\n\n /**\n * Resize the store to 1.5 times its current size if full\n * @return {undefined}\n */\n growIfFull () {\n if (this.count >= this.length) {\n const size = Math.round(this.length * 1.5)\n this.resize(Math.max(256, size))\n }\n }\n\n /**\n * Copy data from one store to another\n * @param {Store} other - store to copy from\n * @param {Integer} thisOffset - offset to start copying to\n * @param {Integer} otherOffset - offset to start copying from\n * @param {Integer} length - number of entries to copy\n * @return {undefined}\n */\n copyFrom (other: Store, thisOffset: number, otherOffset: number, length: number) {\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const name = this._fields[ i ][ 0 ]\n const itemSize = this._fields[ i ][ 1 ]\n const thisField = this[ name ]\n const otherField = other[ name ]\n\n for (let j = 0; j < length; ++j) {\n const thisIndex = itemSize * (thisOffset + j)\n const otherIndex = itemSize * (otherOffset + j)\n for (let k = 0; k < itemSize; ++k) {\n thisField[ thisIndex + k ] = otherField[ otherIndex + k ]\n }\n }\n }\n }\n\n /**\n * Copy data within this store\n * @param {Integer} thisOffset - offset to start copying to\n * @param {Integer} otherOffset - offset to start copying from\n * @param {Integer} length - number of entries to copy\n * @return {undefined}\n */\n copyWithin (offsetTarget: number, offsetSource: number, length: number) {\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const name = this._fields[ i ][ 0 ]\n const itemSize = this._fields[ i ][ 1 ]\n const thisField = this[ name ]\n\n for (let j = 0; j < length; ++j) {\n const targetIndex = itemSize * (offsetTarget + j)\n const sourceIndex = itemSize * (offsetSource + j)\n for (let k = 0; k < itemSize; ++k) {\n thisField[ targetIndex + k ] = thisField[ sourceIndex + k ]\n }\n }\n }\n }\n\n /**\n * Sort entries in the store given the compare function\n * @param {[type]} compareFunction - function to sort by\n * @return {undefined}\n */\n sort (compareFunction: (a: any, b: any) => number) {\n Log.time('Store.sort')\n\n const thisStore = this\n const tmpStore = new (this.constructor as any)(1)\n\n function swap (index1: number, index2: number) {\n if (index1 === index2) return\n tmpStore.copyFrom(thisStore, 0, index1, 1)\n thisStore.copyWithin(index1, index2, 1)\n thisStore.copyFrom(tmpStore, index2, 0, 1)\n }\n\n function quicksort (left: number, right: number) {\n if (left < right) {\n let pivot = Math.floor((left + right) / 2)\n let leftNew = left\n let rightNew = right\n do {\n while (compareFunction(leftNew, pivot) < 0) {\n leftNew += 1\n }\n while (compareFunction(rightNew, pivot) > 0) {\n rightNew -= 1\n }\n if (leftNew <= rightNew) {\n if (leftNew === pivot) {\n pivot = rightNew\n } else if (rightNew === pivot) {\n pivot = leftNew\n }\n swap(leftNew, rightNew)\n leftNew += 1\n rightNew -= 1\n }\n } while (leftNew <= rightNew)\n quicksort(left, rightNew)\n quicksort(leftNew, right)\n }\n }\n\n quicksort(0, this.count - 1)\n\n Log.timeEnd('Store.sort')\n }\n\n /**\n * Empty the store\n * @return {undefined}\n */\n clear () {\n this.count = 0\n }\n\n /**\n * Dispose of the store entries and fields\n * @return {undefined}\n */\n dispose () {\n\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const name = this._fields[ i ][ 0 ]\n delete this[ name ]\n }\n }\n}\n","/**\n * @file Contact Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Bond store\n */\nexport default class ContactStore extends Store {\n index1: Uint32Array\n index2: Uint32Array\n type: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'index1', 1, 'int32' ],\n [ 'index2', 1, 'int32' ],\n [ 'type', 1, 'int8' ]\n ] as StoreField[]\n }\n\n addContact (index1: number, index2: number, type?: number) {\n this.growIfFull()\n\n const i = this.count\n\n if (index1 < index2) {\n this.index1[ i ] = index1\n this.index2[ i ] = index2\n } else {\n this.index2[ i ] = index1\n this.index1[ i ] = index2\n }\n if (type) this.type[ i ] = type\n\n this.count += 1\n }\n}","/**\n * @file Bit array\n * @author Alexander Rose \n * @author Paul Pillot \n * @private\n */\n\n/**\n * Compute the Hamming weight of a 32-bit unsigned integer\n * @param {Integer} v - a 32-bit unsigned integer\n * @return {Integer} the Hamming weight\n */\nfunction hammingWeight (v: number) {\n // works with signed or unsigned shifts\n v -= ((v >>> 1) & 0x55555555)\n v = (v & 0x33333333) + ((v >>> 2) & 0x33333333)\n return ((v + (v >>> 4) & 0xF0F0F0F) * 0x1010101) >>> 24\n}\n\n/**\n * Bit array\n *\n * Based heavily on https://github.com/lemire/FastBitSet.js\n * which is licensed under the Apache License, Version 2.0.\n */\nexport default class BitArray {\n private _words: Uint32Array\n public length: number\n\n /**\n * @param {Integer} length - array length\n * @param {Boolean} [setAll] - initialize with true\n */\n constructor (length: number, setAll?: boolean) {\n this.length = length\n this._words = new Uint32Array((length + 32) >>> 5)\n if (setAll === true) {\n this.setAll()\n }\n }\n\n /**\n * Get value at index\n * @param {Integer} index - the index\n * @return {Boolean} value\n */\n get (index: number) {\n return (this._words[ index >>> 5 ] & (1 << index)) !== 0\n }\n\n /**\n * Set value at index to true\n * @param {Integer} index - the index\n * @return {undefined}\n */\n set (index: number) {\n this._words[ index >>> 5 ] |= 1 << index\n }\n\n /**\n * Set value at index to false\n * @param {Integer} index - the index\n * @return {undefined}\n */\n clear (index: number) {\n this._words[ index >>> 5 ] &= ~(1 << index)\n }\n\n /**\n * Flip value at index\n * @param {Integer} index - the index\n * @return {undefined}\n */\n flip (index: number) {\n this._words[ index >>> 5 ] ^= 1 << index\n }\n\n _assignRange (start: number, end: number, value: boolean) {\n if (end < start) return\n const words = this._words\n const wordValue = value === true ? 0xFFFFFFFF : 0\n const wordStart = start >>> 5\n const wordEnd = end >>> 5\n // set complete words when applicable\n for (let k = wordStart + 1; k < wordEnd; ++k) {\n words[ k ] = wordValue\n }\n // set parts of the range not spanning complete words\n const startWord = wordStart << 5\n const endWord = wordEnd << 5\n if (value === true) {\n if (end - start < 32) {\n for (let i = start, n = end + 1; i < n; ++i) {\n words[ i >>> 5 ] |= 1 << i\n }\n } else {\n for (let i = start, n = startWord + 32; i < n; ++i) {\n words[ i >>> 5 ] |= 1 << i\n }\n for (let i = endWord, n = end + 1; i < n; ++i) {\n words[ i >>> 5 ] |= 1 << i\n }\n }\n } else {\n if (end - start < 32) {\n for (let i = start, n = end + 1; i < n; ++i) {\n words[ i >>> 5 ] &= ~(1 << i)\n }\n } else {\n for (let i = start, n = startWord + 32; i < n; ++i) {\n words[ i >>> 5 ] &= ~(1 << i)\n }\n for (let i = endWord, n = end + 1; i < n; ++i) {\n words[ i >>> 5 ] &= ~(1 << i)\n }\n }\n }\n return this\n }\n\n /**\n * Set bits of the given range\n * @param {Integer} start - start index\n * @param {Integer} end - end index\n * @return {BitArray} this object\n */\n setRange (start: number, end: number) {\n return this._assignRange(start, end, true)\n }\n\n /**\n * Clear bits of the given range\n * @param {Integer} start - start index\n * @param {Integer} end - end index\n * @return {BitArray} this object\n */\n clearRange (start: number, end: number) {\n return this._assignRange(start, end, false)\n }\n\n /**\n * Set bits at all given indices\n * @param {...Integer} arguments - indices\n * @return {Boolean} this object\n */\n setBits (...indices: number[]) {\n const words = this._words\n const n = indices.length\n for (let i = 0; i < n; ++i) {\n const index = indices[ i ]\n words[ index >>> 5 ] |= 1 << index\n }\n return this\n }\n\n /**\n * Clear bits at all given indices\n * @param {...Integer} arguments - indices\n * @return {Boolean} this object\n */\n clearBits (...indices: number[]) {\n const words = this._words\n const n = indices.length\n for (let i = 0; i < n; ++i) {\n const index = indices[ i ]\n words[ index >>> 5 ] &= ~(1 << index)\n }\n return this\n }\n\n /**\n * Set all bits of the array\n * @return {BitArray} this object\n */\n setAll () {\n return this._assignRange(0, this.length - 1, true)\n }\n\n /**\n * Clear all bits of the array\n * @return {BitArray} this object\n */\n clearAll () {\n return this._assignRange(0, this.length - 1, false)\n }\n\n /**\n * Flip all the values in the array\n * @return {BitArray} this object\n */\n flipAll () {\n const count = this._words.length\n const words = this._words\n const bs = 32 - this.length % 32\n for (let k = 0; k < count - 1; ++k) {\n words[k] = ~words[ k ]\n }\n words[ count - 1 ] = (~(words[ count - 1 ] << bs)) >>> bs\n return this\n }\n\n _isRangeValue (start: number, end: number, value: boolean) {\n if (end < start) return\n const words = this._words\n const wordValue = value === true ? 0xFFFFFFFF : 0\n const wordStart = start >>> 5\n const wordEnd = end >>> 5\n // set complete words when applicable\n for (let k = wordStart + 1; k < wordEnd; ++k) {\n if (words[ k ] !== wordValue) return false\n }\n // set parts of the range not spanning complete words\n if (end - start < 32) {\n for (let i = start, n = end + 1; i < n; ++i) {\n if (!!(words[ i >>> 5 ] & (1 << i)) !== value) return false\n }\n } else {\n const startWord = wordStart << 5\n const endWord = wordEnd << 5\n for (let i = start, n = startWord + 32; i < n; ++i) {\n if (!!(words[ i >>> 5 ] & (1 << i)) !== value) return false\n }\n for (let i = endWord, n = end + 1; i < n; ++i) {\n if (!!(words[ i >>> 5 ] & (1 << i)) !== value) return false\n }\n }\n return true\n }\n\n /**\n * Test if bits in given range are set\n * @param {Integer} start - start index\n * @param {Integer} end - end index\n * @return {BitArray} this object\n */\n isRangeSet (start: number, end: number) {\n return this._isRangeValue(start, end, true)\n }\n\n /**\n * Test if bits in given range are clear\n * @param {Integer} start - start index\n * @param {Integer} end - end index\n * @return {BitArray} this object\n */\n isRangeClear (start: number, end: number) {\n return this._isRangeValue(start, end, false)\n }\n\n /**\n * Test if all bits in the array are set\n * @return {Boolean} test result\n */\n isAllSet () {\n return this._isRangeValue(0, this.length - 1, true)\n }\n\n /**\n * Test if all bits in the array are clear\n * @return {Boolean} test result\n */\n isAllClear () {\n return this._isRangeValue(0, this.length - 1, false)\n }\n\n /**\n * Test if bits at all given indices are set\n * @param {...Integer} arguments - indices\n * @return {Boolean} test result\n */\n isSet (...indices: number[]) {\n const words = this._words\n const n = indices.length\n for (let i = 0; i < n; ++i) {\n const index = indices[ i ]\n if ((words[ index >>> 5 ] & (1 << index)) === 0) return false\n }\n return true\n }\n\n /**\n * Test if bits at all given indices are clear\n * @param {...Integer} arguments - indices\n * @return {Boolean} test result\n */\n isClear (...indices: number[]) {\n const words = this._words\n const n = indices.length\n for (let i = 0; i < n; ++i) {\n const index = indices[ i ]\n if ((words[ index >>> 5 ] & (1 << index)) !== 0) return false\n }\n return true\n }\n\n /**\n * Test if two BitArrays are identical in all their values\n * @param {BitArray} otherBitarray - the other BitArray\n * @return {Boolean} test result\n */\n isEqualTo (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n if (words1[ k ] !== words2[ k ]) {\n return false\n }\n }\n return true\n }\n\n /**\n * How many set bits?\n * @return {Integer} number of set bits\n */\n getSize () {\n const count = this._words.length\n const words = this._words\n let size = 0\n for (let i = 0; i < count; ++i) {\n size += hammingWeight(words[ i ])\n }\n return size\n }\n\n /**\n * Calculate difference betwen this and another bit array.\n * Store result in this object.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {BitArray} this object\n */\n difference (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n words1[ k ] = words1[ k ] & ~words2[ k ]\n }\n for (let k = words1.length; k < count; ++k) {\n words1[ k ] = 0\n }\n return this\n }\n\n /**\n * Calculate union betwen this and another bit array.\n * Store result in this object.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {BitArray} this object\n */\n union (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n words1[ k ] |= words2[ k ]\n }\n for (let k = words1.length; k < count; ++k) {\n words1[ k ] = 0\n }\n return this\n }\n\n /**\n * Calculate intersection betwen this and another bit array.\n * Store result in this object.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {BitArray} this object\n */\n intersection (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n words1[ k ] &= words2[ k ]\n }\n for (let k = words1.length; k < count; ++k) {\n words1[ k ] = 0\n }\n return this\n }\n\n /**\n * Test if there is any intersection betwen this and another bit array.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {Boolean} test result\n */\n intersects (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n if ((words1[ k ] & words2[ k ]) !== 0) {\n return true\n }\n }\n return false\n }\n\n /**\n * Calculate the number of bits in common betwen this and another bit array.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {Integer} size\n */\n getIntersectionSize (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n let size = 0\n for (let k = 0; k < count; ++k) {\n size += hammingWeight(words1[ k ] & words2[ k ])\n }\n return size\n }\n\n /**\n * Calculate intersection betwen this and another bit array.\n * Store result in a new bit array.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {BitArray} the new bit array\n */\n makeIntersection (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n const wordsA = new Uint32Array(count)\n const intersection = Object.create(BitArray.prototype)\n intersection._words = wordsA\n intersection.length = Math.min(this.length, otherBitarray.length)\n for (let k = 0; k < count; ++k) {\n wordsA[ k ] = words1[ k ] & words2[ k ]\n }\n return intersection\n }\n\n /**\n * Iterate over all set bits in the array\n * @param {function( index: Integer, i: Integer )} callback - the callback\n * @return {undefined}\n */\n forEach (callback: (index: number, i: number) => any) {\n const count = this._words.length\n const words = this._words\n let i = 0\n for (let k = 0; k < count; ++k) {\n let w = words[ k ]\n while (w !== 0) {\n const t = w & -w\n const index = (k << 5) + hammingWeight(t - 1)\n callback(index, i)\n w ^= t\n ++i\n }\n }\n }\n\n /**\n * Get an array with the set bits\n * @return {Array} bit indices\n */\n toArray () {\n const words = this._words\n const answer = new Array(this.getSize())\n const count = this._words.length\n let pos = 0\n for (let k = 0; k < count; ++k) {\n let w = words[ k ]\n while (w !== 0) {\n const t = w & -w\n answer[ pos++ ] = (k << 5) + hammingWeight(t - 1)\n w ^= t\n }\n }\n return answer\n }\n\n toString () {\n return '{' + this.toArray().join(',') + '}'\n }\n\n toSeleString () {\n const sele = this.toArray().join(',')\n return sele ? '@' + sele : 'NONE'\n }\n\n /**\n * Clone this object\n * @return {BitArray} the cloned object\n */\n clone () {\n const clone = Object.create(BitArray.prototype)\n clone.length = this.length\n clone._words = new Uint32Array(this._words)\n return clone\n }\n}","/**\n * @file Adjacency List\n * @author Alexander Rose \n * @private\n */\n\nexport interface Edges {\n nodeArray1: ArrayLike\n nodeArray2: ArrayLike\n edgeCount: number\n nodeCount: number\n}\n\nexport interface AdjacencyList {\n /* number of edges for each node */\n countArray: Uint8Array\n /* offset into indexArray for each node */\n offsetArray: Int32Array\n /* edge indices, grouped by nodes */\n indexArray: Int32Array\n}\n\nexport function createAdjacencyList (edges: Edges): AdjacencyList {\n const { edgeCount, nodeCount, nodeArray1, nodeArray2 } = edges\n\n const countArray = new Uint8Array(nodeCount)\n const offsetArray = new Int32Array(nodeCount)\n\n // count edges per node\n for (let i = 0; i < edgeCount; ++i) {\n countArray[ nodeArray1[ i ] ] += 1\n countArray[ nodeArray2[ i ] ] += 1\n }\n\n // get offsets to node edges\n for (let i = 1; i < nodeCount; ++i) {\n offsetArray[ i ] += offsetArray[ i - 1 ] + countArray[ i - 1 ]\n }\n\n // prepare index array\n const bondCount2 = edgeCount * 2\n const indexArray = new Int32Array(bondCount2)\n for (let j = 0; j < bondCount2; ++j) {\n indexArray[ j ] = -1\n }\n\n // build index array\n for (let i = 0; i < edgeCount; ++i) {\n const idx1 = nodeArray1[ i ]\n const idx2 = nodeArray2[ i ]\n let j1 = offsetArray[ idx1 ]\n while (indexArray[ j1 ] !== -1 && j1 < bondCount2) {\n j1 += 1\n }\n indexArray[ j1 ] = i\n let j2 = offsetArray[ idx2 ]\n while (indexArray[ j2 ] !== -1 && j2 < bondCount2) {\n j2 += 1\n }\n indexArray[ j2 ] = i\n }\n\n return { countArray, offsetArray, indexArray }\n}\n","/**\n * @file Features\n * @author Alexander Rose \n */\n\nimport AtomProxy from '../../proxy/atom-proxy'\n\nexport interface Features {\n types: FeatureType[]\n groups: FeatureGroup[]\n centers: { x: number[], y: number[], z: number[] }\n atomSets: number[][]\n}\n\nexport const enum FeatureType {\n Unknown = 0,\n PositiveCharge = 1,\n NegativeCharge = 2,\n AromaticRing = 3,\n HydrogenDonor = 4,\n HydrogenAcceptor = 5,\n HalogenDonor = 6,\n HalogenAcceptor = 7,\n Hydrophobic = 8,\n WeakHydrogenDonor = 9,\n IonicTypePartner = 10,\n DativeBondPartner = 11,\n TransitionMetal = 12,\n IonicTypeMetal = 13\n}\n\nexport const enum FeatureGroup {\n Unknown = 0,\n QuaternaryAmine = 1,\n TertiaryAmine = 2,\n Sulfonium = 3,\n SulfonicAcid = 4,\n Sulfate = 5,\n Phosphate = 6,\n Halocarbon = 7,\n Guanidine = 8,\n Acetamidine = 9,\n Carboxylate = 10\n}\n\nexport function createFeatures (): Features {\n return {\n types: [],\n groups: [],\n centers: { x: [], y: [], z: [] },\n atomSets: []\n }\n}\n\nexport interface FeatureState {\n type: FeatureType\n group: FeatureGroup\n x: number\n y: number\n z: number\n atomSet: number[]\n}\n\nexport function createFeatureState(type = FeatureType.Unknown, group = FeatureGroup.Unknown): FeatureState {\n return { type, group, x: 0, y: 0, z: 0, atomSet: [] }\n}\n\nexport function addAtom (state: FeatureState, atom: AtomProxy) {\n state.x += atom.x\n state.y += atom.y\n state.z += atom.z\n state.atomSet.push(atom.index)\n}\n\nexport function addFeature (features: Features, state: FeatureState) {\n const n = state.atomSet.length\n if (n > 0) {\n const { types, groups, centers, atomSets } = features\n types.push(state.type)\n groups.push(state.group)\n centers.x.push(state.x / n)\n centers.y.push(state.y / n)\n centers.z.push(state.z / n)\n atomSets.push(state.atomSet)\n }\n}\n","/**\n * @file Structure Constants\n * @author Alexander Rose \n * @private\n */\n\n// entity types\nexport const UnknownEntity = 0\nexport const PolymerEntity = 1\nexport const NonPolymerEntity = 2\nexport const MacrolideEntity = 3\nexport const WaterEntity = 4\n\n// molecule types\nexport const UnknownType = 0\nexport const WaterType = 1\nexport const IonType = 2\nexport const ProteinType = 3\nexport const RnaType = 4\nexport const DnaType = 5\nexport const SaccharideType = 6\n\n// backbone types\nexport const UnknownBackboneType = 0\nexport const ProteinBackboneType = 1\nexport const RnaBackboneType = 2\nexport const DnaBackboneType = 3\nexport const CgProteinBackboneType = 4\nexport const CgRnaBackboneType = 5\nexport const CgDnaBackboneType = 6\n\n// chemical component types\nexport const ChemCompProtein = [\n 'D-BETA-PEPTIDE, C-GAMMA LINKING', 'D-GAMMA-PEPTIDE, C-DELTA LINKING',\n 'D-PEPTIDE COOH CARBOXY TERMINUS', 'D-PEPTIDE NH3 AMINO TERMINUS', 'D-PEPTIDE LINKING',\n 'L-BETA-PEPTIDE, C-GAMMA LINKING', 'L-GAMMA-PEPTIDE, C-DELTA LINKING',\n 'L-PEPTIDE COOH CARBOXY TERMINUS', 'L-PEPTIDE NH3 AMINO TERMINUS', 'L-PEPTIDE LINKING',\n 'PEPTIDE LINKING', 'PEPTIDE-LIKE'\n]\nexport const ChemCompRna = [\n 'RNA OH 3 PRIME TERMINUS', 'RNA OH 5 PRIME TERMINUS', 'RNA LINKING'\n]\nexport const ChemCompDna = [\n 'DNA OH 3 PRIME TERMINUS', 'DNA OH 5 PRIME TERMINUS', 'DNA LINKING',\n 'L-DNA LINKING', 'L-RNA LINKING'\n]\nexport const ChemCompSaccharide = [\n 'D-SACCHARIDE', 'D-SACCHARIDE 1,4 AND 1,4 LINKING', 'D-SACCHARIDE 1,4 AND 1,6 LINKING',\n 'L-SACCHARIDE', 'L-SACCHARIDE 1,4 AND 1,4 LINKING', 'L-SACCHARIDE 1,4 AND 1,6 LINKING',\n 'SACCHARIDE'\n]\nexport const ChemCompOther = [\n 'OTHER'\n]\nexport const ChemCompNonPolymer = [\n 'NON-POLYMER'\n]\nexport const ChemCompHetero = ChemCompNonPolymer.concat(ChemCompOther, ChemCompSaccharide)\n\n// secondary structure\nexport const SecStrucHelix = [ 'h', 'g', 'i' ]\nexport const SecStrucSheet = [ 'e', 'b' ]\nexport const SecStrucTurn = [ 's', 't', 'l', '' ]\n\nexport const AtomicNumbers: { [e: string]: number | undefined } = {\n 'H': 1, 'D': 1, 'T': 1, 'HE': 2, 'LI': 3, 'BE': 4, 'B': 5, 'C': 6, 'N': 7, 'O': 8, 'F': 9, 'NE': 10, 'NA': 11, 'MG': 12, 'AL': 13, 'SI': 14, 'P': 15, 'S': 16, 'CL': 17, 'AR': 18, 'K': 19, 'CA': 20, 'SC': 21, 'TI': 22, 'V': 23, 'CR': 24, 'MN': 25, 'FE': 26, 'CO': 27, 'NI': 28, 'CU': 29, 'ZN': 30, 'GA': 31, 'GE': 32, 'AS': 33, 'SE': 34, 'BR': 35, 'KR': 36, 'RB': 37, 'SR': 38, 'Y': 39, 'ZR': 40, 'NB': 41, 'MO': 42, 'TC': 43, 'RU': 44, 'RH': 45, 'PD': 46, 'AG': 47, 'CD': 48, 'IN': 49, 'SN': 50, 'SB': 51, 'TE': 52, 'I': 53, 'XE': 54, 'CS': 55, 'BA': 56, 'LA': 57, 'CE': 58, 'PR': 59, 'ND': 60, 'PM': 61, 'SM': 62, 'EU': 63, 'GD': 64, 'TB': 65, 'DY': 66, 'HO': 67, 'ER': 68, 'TM': 69, 'YB': 70, 'LU': 71, 'HF': 72, 'TA': 73, 'W': 74, 'RE': 75, 'OS': 76, 'IR': 77, 'PT': 78, 'AU': 79, 'HG': 80, 'TL': 81, 'PB': 82, 'BI': 83, 'PO': 84, 'AT': 85, 'RN': 86, 'FR': 87, 'RA': 88, 'AC': 89, 'TH': 90, 'PA': 91, 'U': 92, 'NP': 93, 'PU': 94, 'AM': 95, 'CM': 96, 'BK': 97, 'CF': 98, 'ES': 99, 'FM': 100, 'MD': 101, 'NO': 102, 'LR': 103, 'RF': 104, 'DB': 105, 'SG': 106, 'BH': 107, 'HS': 108, 'MT': 109, 'DS': 110, 'RG': 111, 'CN': 112, 'NH': 113, 'FL': 114, 'MC': 115, 'LV': 116, 'TS': 117, 'OG': 118\n}\nexport const DefaultAtomicNumber = 0\n\n/**\n * Enum mapping element to atomic number\n */\nexport const enum Elements {\n H = 1, D = 1, T = 1, HE = 2, LI = 3, BE = 4, B = 5, C = 6, N = 7, O = 8, F = 9, NE = 10, NA = 11, MG = 12, AL = 13, SI = 14, P = 15, S = 16, CL = 17, AR = 18, K = 19, CA = 20, SC = 21, TI = 22, V = 23, CR = 24, MN = 25, FE = 26, CO = 27, NI = 28, CU = 29, ZN = 30, GA = 31, GE = 32, AS = 33, SE = 34, BR = 35, KR = 36, RB = 37, SR = 38, Y = 39, ZR = 40, NB = 41, MO = 42, TC = 43, RU = 44, RH = 45, PD = 46, AG = 47, CD = 48, IN = 49, SN = 50, SB = 51, TE = 52, I = 53, XE = 54, CS = 55, BA = 56, LA = 57, CE = 58, PR = 59, ND = 60, PM = 61, SM = 62, EU = 63, GD = 64, TB = 65, DY = 66, HO = 67, ER = 68, TM = 69, YB = 70, LU = 71, HF = 72, TA = 73, W = 74, RE = 75, OS = 76, IR = 77, PT = 78, AU = 79, HG = 80, TL = 81, PB = 82, BI = 83, PO = 84, AT = 85, RN = 86, FR = 87, RA = 88, AC = 89, TH = 90, PA = 91, U = 92, NP = 93, PU = 94, AM = 95, CM = 96, BK = 97, CF = 98, ES = 99, FM = 100, MD = 101, NO = 102, LR = 103, RF = 104, DB = 105, SG = 106, BH = 107, HS = 108, MT = 109, DS = 110, RG = 111, CN = 112, NH = 113, FL = 114, MC = 115, LV = 116, TS = 117, OG = 118\n}\n\n// https://doi.org/10.1515/pac-2015-0305 (table 2, 3, and 4)\nexport const AtomWeights: { [e: number]: number | undefined } = {\n 1: 1.008, 2: 4.0026, 3: 6.94, 4: 9.0122, 5: 10.81, 6: 10.81, 7: 14.007, 8: 15.999, 9: 18.998, 10: 20.180, 11: 22.990, 12: 24.305, 13: 26.982, 14: 28.085, 15: 30.974, 16: 32.06, 17: 35.45, 18: 39.948, 19: 39.098, 20: 40.078, 21: 44.956, 22: 47.867, 23: 50.942, 24: 51.996, 25: 54.938, 26: 55.845, 27: 58.933, 28: 58.693, 29: 63.546, 30: 65.38, 31: 69.723, 32: 72.630, 33: 74.922, 34: 78.971, 35: 79.904, 36: 83.798, 37: 85.468, 38: 87.62, 39: 88.906, 40: 91.224, 41: 92.906, 42: 95.95, 43: 96.906, 44: 101.07, 45: 102.91, 46: 106.42, 47: 107.87, 48: 112.41, 49: 114.82, 50: 118.71, 51: 121.76, 52: 127.60, 53: 127.60, 54: 131.29, 55: 132.91, 56: 137.33, 57: 138.91, 58: 140.12, 59: 140.91, 60: 144.24, 61: 144.912, 62: 150.36, 63: 151.96, 64: 157.25, 65: 158.93, 66: 162.50, 67: 164.93, 68: 167.26, 69: 168.93, 70: 173.05, 71: 174.97, 72: 178.49, 73: 180.95, 74: 183.84, 75: 186.21, 76: 190.23, 77: 192.22, 78: 195.08, 79: 196.97, 80: 200.59, 81: 204.38, 82: 207.2, 83: 208.98, 84: 1.97, 85: 2.02, 86: 2.2, 87: 3.48, 88: 2.83, 89: 2.0, 90: 232.04, 91: 231.04, 92: 238.03, 93: 237.048, 94: 244.064, 95: 243.061, 96: 247.070, 97: 247.070, 98: 251.079, 99: 252.083, 100: 257.095, 101: 258.098, 102: 259.101, 103: 262.110, 104: 267.122, 105: 270.131, 106: 271.134, 107: 270.133, 108: 270.134, 109: 278.156, 110: 281.165, 111: 281.166, 112: 285.177, 113: 286.182, 114: 289.190, 115: 289.194, 116: 293.204, 117: 293.208, 118: 294.214\n}\nexport const DefaultAtomWeight = 10.81 // C\n\n// http://dx.doi.org/10.1021/jp8111556 (or 2.0)\nexport const VdwRadii: { [e: number]: number | undefined } = {\n 1: 1.1, 2: 1.4, 3: 1.81, 4: 1.53, 5: 1.92, 6: 1.7, 7: 1.55, 8: 1.52, 9: 1.47, 10: 1.54, 11: 2.27, 12: 1.73, 13: 1.84, 14: 2.1, 15: 1.8, 16: 1.8, 17: 1.75, 18: 1.88, 19: 2.75, 20: 2.31, 21: 2.3, 22: 2.15, 23: 2.05, 24: 2.05, 25: 2.05, 26: 2.05, 27: 2.0, 28: 2.0, 29: 2.0, 30: 2.1, 31: 1.87, 32: 2.11, 33: 1.85, 34: 1.9, 35: 1.83, 36: 2.02, 37: 3.03, 38: 2.49, 39: 2.4, 40: 2.3, 41: 2.15, 42: 2.1, 43: 2.05, 44: 2.05, 45: 2.0, 46: 2.05, 47: 2.1, 48: 2.2, 49: 2.2, 50: 1.93, 51: 2.17, 52: 2.06, 53: 1.98, 54: 2.16, 55: 3.43, 56: 2.68, 57: 2.5, 58: 2.48, 59: 2.47, 60: 2.45, 61: 2.43, 62: 2.42, 63: 2.4, 64: 2.38, 65: 2.37, 66: 2.35, 67: 2.33, 68: 2.32, 69: 2.3, 70: 2.28, 71: 2.27, 72: 2.25, 73: 2.2, 74: 2.1, 75: 2.05, 76: 2.0, 77: 2.0, 78: 2.05, 79: 2.1, 80: 2.05, 81: 1.96, 82: 2.02, 83: 2.07, 84: 1.97, 85: 2.02, 86: 2.2, 87: 3.48, 88: 2.83, 89: 2.0, 90: 2.4, 91: 2.0, 92: 2.3, 93: 2.0, 94: 2.0, 95: 2.0, 96: 2.0, 97: 2.0, 98: 2.0, 99: 2.0, 100: 2.0, 101: 2.0, 102: 2.0, 103: 2.0, 104: 2.0, 105: 2.0, 106: 2.0, 107: 2.0, 108: 2.0, 109: 2.0, 110: 2.0, 111: 2.0, 112: 2.0, 113: 2.0, 114: 2.0, 115: 2.0, 116: 2.0, 117: 2.0, 118: 2.0\n}\nexport const DefaultVdwRadius = 2.0 // C\n\n// Peter Rose (peter.rose@rcsb.org), private communication, average accross PDB\nexport const ResidueRadii: { [k: string]: number } = {\n '2QY': 6.58,\n 'CY0': 11.98,\n '2QZ': 2.52,\n 'CY1': 6.59,\n 'HHK': 5.11,\n 'CXM': 4.69,\n 'HHI': 4.58,\n 'CY4': 4.57,\n 'S12': 18.57,\n 'CY3': 2.79,\n 'C5C': 5.35,\n 'PFX': 11.84,\n '2R3': 6.94,\n '2R1': 3.78,\n 'ILX': 4.99,\n '32S': 5.68,\n 'BTK': 8.59,\n '32T': 5.72,\n 'FAK': 9.8,\n 'B27': 2.78,\n 'ILM': 3.84,\n 'C4R': 5.63,\n '32L': 6.75,\n 'SYS': 3.01,\n '1MH': 5.04,\n 'ILE': 3.65,\n 'YNM': 6.39,\n '2RX': 4.91,\n 'B3A': 2.48,\n 'GEE': 4.76,\n '7MN': 7.34,\n 'B3E': 5.4,\n 'ARG': 6.33,\n '200': 6.89,\n 'HIP': 5.47,\n 'HIA': 4.64,\n 'B3K': 5.89,\n 'HIC': 5.76,\n 'B3L': 4.96,\n 'B3M': 5.07,\n 'ARM': 6.86,\n 'ARO': 7.35,\n 'AR4': 8.42,\n 'PG1': 10.67,\n 'YOF': 6.44,\n 'IML': 3.74,\n 'SXE': 6.65,\n 'HIQ': 7.98,\n 'PFF': 6.31,\n 'HIS': 4.52,\n '0TD': 3.62,\n 'C3Y': 5.24,\n '1OP': 11.55,\n '02Y': 4.77,\n '02V': 4.83,\n 'ASB': 5.59,\n '30V': 8.53,\n 'S2P': 4.81,\n 'ASP': 3.55,\n 'ASN': 3.54,\n '2OR': 6.91,\n 'QMM': 6.13,\n '2P0': 8.52,\n 'ASL': 5.36,\n 'HFA': 5.14,\n '5PG': 5.69,\n 'B3X': 4.38,\n 'AS9': 4.1,\n 'ARV': 7.59,\n 'B3U': 6.06,\n 'S2C': 7.54,\n 'B3T': 3.34,\n '175': 5.64,\n 'GFT': 8.18,\n 'HG7': 6.8,\n 'B3Q': 4.48,\n 'ASA': 3.64,\n '02K': 2.94,\n 'B3Y': 7.45,\n 'PHD': 5.35,\n 'C6C': 6.42,\n 'BUC': 5.8,\n 'HGL': 8.07,\n 'PHE': 5.06,\n '03Y': 2.6,\n 'PHA': 5.11,\n 'OCY': 5.0,\n '4PH': 6.79,\n '5OH': 4.7,\n '31Q': 10.46,\n 'BTR': 7.98,\n '3PX': 4.7,\n '1PA': 8.07,\n 'ASX': 3.54,\n 'IOR': 7.23,\n '03E': 3.38,\n 'PHL': 5.17,\n 'KWS': 5.09,\n 'PHI': 7.12,\n 'NAL': 7.22,\n 'S1H': 19.21,\n '2ML': 3.86,\n '2MR': 7.35,\n 'GHG': 4.83,\n 'TYY': 6.54,\n '2MT': 3.67,\n '56A': 13.01,\n 'SVA': 5.46,\n 'TYX': 8.31,\n 'TYS': 8.59,\n 'TYR': 6.38,\n 'TYQ': 6.43,\n 'HLU': 3.99,\n 'MYK': 19.47,\n 'TYO': 7.71,\n 'HLX': 4.98,\n 'TYN': 9.87,\n 'TYJ': 6.25,\n 'TYI': 6.49,\n 'LYH': 5.13,\n 'LYF': 12.19,\n 'SUN': 6.73,\n 'LYR': 18.28,\n 'TYB': 6.46,\n '11W': 14.39,\n 'LYS': 5.54,\n 'LYN': 4.8,\n '11Q': 4.85,\n 'LYO': 4.71,\n 'LYZ': 1.76,\n 'TXY': 6.44,\n 'MYN': 4.71,\n 'TY5': 10.6,\n 'HMR': 5.09,\n '01W': 8.55,\n 'LYX': 13.36,\n 'TY8': 7.22,\n 'TY2': 6.49,\n 'KYN': 6.18,\n 'KYQ': 9.75,\n 'CZZ': 5.14,\n 'IIL': 3.81,\n 'HNC': 10.41,\n 'OIC': 4.62,\n 'LVN': 2.89,\n 'QIL': 3.84,\n 'JJL': 8.3,\n 'VAH': 3.88,\n 'JJJ': 7.5,\n 'JJK': 7.43,\n 'VAD': 2.56,\n 'CYW': 4.65,\n '0QL': 5.72,\n '143': 8.22,\n 'SVX': 7.04,\n 'CYJ': 11.64,\n 'SVY': 7.1,\n 'SVZ': 6.6,\n 'CYG': 8.03,\n 'CYF': 13.54,\n 'SVV': 5.09,\n 'GL3': 2.72,\n '8SP': 14.26,\n 'CYS': 2.78,\n '004': 4.33,\n 'CYR': 10.33,\n 'PLJ': 3.71,\n 'EXY': 7.37,\n 'HL2': 3.75,\n 'A5N': 5.21,\n 'CYQ': 5.67,\n 'CZ2': 5.16,\n 'LWY': 4.12,\n 'PM3': 8.78,\n 'OHS': 6.98,\n 'OHI': 5.35,\n '3TY': 8.42,\n 'CYD': 8.55,\n 'DYS': 7.87,\n 'DAH': 6.47,\n '4IK': 11.81,\n '3EG': 3.66,\n 'AYA': 3.65,\n '4IN': 6.31,\n 'DAB': 3.48,\n '4HT': 6.03,\n 'RGL': 7.03,\n 'DAM': 2.49,\n 'NFA': 5.04,\n 'WFP': 6.07,\n '2JC': 2.97,\n 'HAR': 7.55,\n '2JG': 5.67,\n 'MH6': 1.72,\n '2JF': 9.13,\n '3FG': 4.96,\n 'MGN': 4.84,\n 'AZH': 5.36,\n 'AZK': 6.03,\n 'ZBZ': 7.79,\n 'TBG': 2.58,\n 'VAL': 2.51,\n 'MGG': 7.34,\n 'AZS': 5.61,\n 'FHL': 9.75,\n '2JH': 4.56,\n 'IEL': 7.07,\n 'FHO': 6.75,\n 'DA2': 7.79,\n 'FH7': 6.99,\n 'ME0': 4.52,\n '3GL': 4.84,\n 'MDO': 5.03,\n 'AZY': 7.37,\n 'A8E': 3.76,\n 'ZCL': 6.71,\n 'MDH': 2.58,\n 'LA2': 14.07,\n '4FW': 6.1,\n 'YCM': 5.32,\n 'MDF': 4.95,\n 'YCP': 3.01,\n 'TEF': 8.63,\n 'FGP': 4.34,\n 'UF0': 19.72,\n 'XCN': 4.57,\n 'FGL': 2.56,\n 'MF3': 6.37,\n 'MEQ': 5.13,\n 'LAA': 3.23,\n 'IGL': 5.52,\n 'MET': 4.49,\n 'NIY': 6.81,\n 'QCS': 5.18,\n 'TCQ': 8.56,\n 'MEN': 4.33,\n '4HL': 8.79,\n 'MEA': 4.95,\n 'EFC': 5.28,\n 'LAL': 2.41,\n '2HF': 5.52,\n 'KBE': 5.64,\n 'OCS': 3.94,\n 'CAF': 5.46,\n 'NC1': 11.4,\n 'NBQ': 9.82,\n 'CAB': 4.19,\n 'MBQ': 9.55,\n '193': 7.38,\n '192': 2.44,\n '0WZ': 7.61,\n 'CAS': 5.35,\n 'NB8': 11.98,\n 'OBS': 11.71,\n '1AC': 2.42,\n 'PCA': 3.48,\n 'MCL': 9.73,\n 'LBY': 7.75,\n 'GAU': 4.67,\n 'PBF': 9.75,\n 'MCG': 6.46,\n 'DDE': 6.86,\n '19W': 3.94,\n 'MD5': 9.33,\n 'MD6': 6.44,\n 'MD3': 8.41,\n 'MCS': 7.56,\n 'OBF': 3.64,\n 'UAL': 4.68,\n 'PAT': 6.05,\n 'IAM': 8.88,\n 'PAQ': 8.77,\n 'FDL': 9.49,\n 'NCB': 3.45,\n 'LCK': 9.81,\n 'DDZ': 2.52,\n '2FM': 5.54,\n 'IAR': 6.77,\n 'OAS': 4.8,\n 'HBN': 8.8,\n 'TA4': 5.55,\n '1C3': 7.43,\n 'ECX': 5.51,\n 'PF5': 6.28,\n 'RE3': 5.29,\n 'FCL': 6.25,\n 'ECC': 4.79,\n 'LDH': 7.06,\n 'NCY': 2.91,\n 'CCS': 4.58,\n 'PEC': 6.54,\n '2CO': 4.45,\n 'LE1': 2.72,\n 'HCM': 5.53,\n '07O': 8.05,\n 'HCL': 4.96,\n 'NEP': 6.94,\n 'PE1': 8.01,\n 'LEF': 4.37,\n 'FC0': 5.18,\n 'LED': 4.34,\n 'HCS': 4.09,\n 'DBU': 2.49,\n 'RE0': 5.53,\n 'LEN': 3.82,\n '1E3': 8.71,\n 'BB9': 2.56,\n 'BB8': 5.14,\n 'PCS': 5.05,\n 'BB7': 4.56,\n 'BB6': 2.62,\n 'LEU': 3.83,\n 'DBZ': 7.08,\n 'LET': 11.29,\n 'DBY': 6.46,\n 'ICY': 7.76,\n 'MAA': 2.4,\n 'CGA': 7.91,\n '5CS': 8.34,\n 'UGY': 3.7,\n 'LGY': 11.71,\n 'N10': 8.96,\n 'AAR': 6.39,\n 'FT6': 7.5,\n 'MOD': 12.62,\n '5CW': 7.21,\n 'PVH': 4.58,\n 'BBC': 6.42,\n 'YYA': 7.3,\n 'O12': 14.08,\n 'NOT': 7.15,\n 'KGC': 9.88,\n 'MP4': 5.86,\n '0CS': 4.07,\n 'MP8': 3.75,\n 'VLL': 2.54,\n 'VLM': 2.51,\n 'BCS': 8.03,\n 'MNL': 4.9,\n 'AA4': 4.47,\n 'SAC': 3.49,\n 'BCX': 2.99,\n '3CF': 6.47,\n 'SAH': 11.7,\n 'NNH': 6.86,\n 'CGU': 4.71,\n 'SIB': 12.41,\n 'TLY': 8.78,\n 'SIC': 4.81,\n 'VMS': 8.82,\n 'TMD': 6.76,\n 'MMO': 6.53,\n 'PXU': 2.46,\n '4AW': 6.22,\n 'OTH': 3.6,\n 'DLS': 6.84,\n 'MME': 4.99,\n 'DM0': 6.99,\n '0FL': 2.76,\n 'SBL': 8.96,\n 'CDV': 3.72,\n 'OTY': 6.51,\n 'PYA': 7.75,\n '2AS': 3.57,\n 'DMH': 4.92,\n 'ELY': 7.42,\n 'GVL': 9.6,\n 'FVA': 2.9,\n 'SAR': 2.48,\n '4BF': 6.92,\n 'EME': 4.69,\n 'CDE': 2.51,\n '3AR': 7.86,\n '3AH': 9.11,\n 'AC5': 2.44,\n 'FTR': 6.08,\n 'MLL': 3.76,\n 'NPH': 11.66,\n 'NPI': 6.9,\n 'DMT': 6.67,\n 'PYX': 11.3,\n 'MLE': 3.87,\n 'PYL': 9.67,\n 'ZZU': 6.94,\n 'H5M': 3.61,\n 'SCH': 4.46,\n 'DMK': 3.52,\n 'FTY': 9.07,\n '2AG': 3.7,\n 'ABA': 2.55,\n 'ZZJ': 2.44,\n 'MLZ': 6.8,\n 'MLY': 6.88,\n 'KCX': 7.28,\n 'ZZD': 8.16,\n '3A5': 5.37,\n 'LHC': 7.75,\n '9AT': 2.47,\n 'OZT': 3.4,\n 'THO': 2.62,\n 'THR': 2.5,\n 'DFI': 3.93,\n 'MKD': 6.42,\n '4CY': 4.6,\n 'SDP': 6.07,\n 'DFO': 3.94,\n '0A0': 3.45,\n '4DB': 9.73,\n 'ML3': 6.26,\n 'BG1': 8.02,\n 'SD4': 4.57,\n 'THC': 3.8,\n 'SCS': 5.48,\n 'TH5': 4.65,\n 'BFD': 5.33,\n 'AEI': 6.34,\n 'TH6': 2.85,\n 'SCY': 4.53,\n 'TIS': 4.81,\n 'SEE': 4.53,\n 'BHD': 3.48,\n 'SEB': 8.18,\n 'SEC': 2.96,\n 'SEP': 4.8,\n 'CLH': 7.13,\n 'TIH': 5.02,\n 'CLG': 13.62,\n 'SEN': 6.43,\n 'XXA': 7.34,\n 'SEL': 2.46,\n 'SE7': 4.19,\n '4CF': 7.72,\n 'G8M': 3.57,\n 'BH2': 3.51,\n 'UN2': 3.22,\n 'VR0': 10.51,\n 'MK8': 4.76,\n 'DHA': 2.32,\n 'LMQ': 4.69,\n 'SFE': 5.01,\n 'AHB': 3.47,\n 'OXX': 7.05,\n 'BIF': 9.63,\n 'IZO': 4.47,\n 'NMM': 8.25,\n '0BN': 7.0,\n 'HZP': 3.12,\n 'NMC': 4.23,\n 'DHL': 2.69,\n '9DS': 9.29,\n 'SER': 2.41,\n 'CHG': 4.2,\n 'MIR': 6.54,\n 'AGQ': 7.79,\n 'SET': 2.46,\n 'MIS': 6.32,\n '4FB': 3.08,\n '0AR': 8.46,\n 'LME': 3.99,\n 'FZN': 24.42,\n 'AGT': 9.04,\n 'IYR': 6.46,\n '9DN': 9.31,\n 'CHP': 5.75,\n 'UNK': 1.64,\n 'XX1': 9.92,\n 'AGM': 6.57,\n '0AH': 5.78,\n 'LLP': 10.22,\n '0AF': 6.72,\n '4DP': 9.28,\n 'HYP': 2.25,\n 'DIR': 5.8,\n 'LLY': 8.71,\n '0AK': 6.11,\n 'NLE': 4.67,\n 'OYL': 6.42,\n 'WVL': 4.69,\n '0A8': 8.1,\n 'NLY': 6.37,\n 'MHO': 4.89,\n 'VOL': 2.55,\n '0A1': 7.1,\n 'MHL': 3.92,\n 'NLP': 4.81,\n 'NLQ': 4.65,\n 'MHW': 2.74,\n 'BIL': 4.7,\n 'NLO': 4.8,\n 'MHU': 7.51,\n 'XW1': 9.36,\n 'LLO': 10.13,\n 'SGB': 6.88,\n 'MHV': 3.6,\n 'MHS': 4.51,\n '0A9': 5.17,\n '0LF': 9.96,\n 'HT7': 6.82,\n 'X2W': 6.6,\n 'YPZ': 9.38,\n 'I58': 6.73,\n 'FLA': 2.4,\n 'M0H': 4.83,\n 'HSL': 2.46,\n 'FLE': 6.17,\n 'KOR': 10.1,\n '1VR': 3.89,\n 'HSO': 4.56,\n 'TTS': 9.41,\n 'RVX': 7.01,\n 'TTQ': 7.71,\n 'H14': 5.27,\n 'HTI': 7.8,\n 'ONH': 6.14,\n 'LP6': 8.58,\n 'ONL': 4.83,\n 'AHH': 5.06,\n 'HS8': 7.4,\n 'HS9': 4.71,\n 'BL2': 5.82,\n 'AHP': 5.26,\n '6HN': 7.34,\n 'HRP': 5.46,\n 'POM': 3.6,\n 'WPA': 5.11,\n '2ZC': 4.29,\n 'CPC': 2.65,\n 'AIB': 2.4,\n 'XSN': 3.47,\n 'M2S': 5.28,\n 'GND': 6.67,\n 'GNC': 4.6,\n 'MVA': 2.56,\n 'OLZ': 5.32,\n 'M2L': 6.15,\n 'TRF': 6.69,\n 'NZH': 7.66,\n 'SRZ': 5.27,\n 'OLD': 10.47,\n 'CME': 5.86,\n 'CMH': 5.3,\n 'ALA': 2.38,\n 'TRQ': 7.36,\n 'PPN': 7.24,\n 'TRP': 6.07,\n 'TRO': 5.82,\n 'TRN': 5.95,\n 'NYS': 8.1,\n 'ALC': 5.26,\n 'U3X': 11.7,\n 'HVA': 2.58,\n 'TS9': 3.92,\n 'TRX': 7.27,\n 'TRW': 11.8,\n 'LPL': 7.51,\n 'GMA': 4.4,\n 'OMT': 5.07,\n 'CMT': 3.54,\n 'GME': 4.66,\n 'NYB': 6.07,\n 'PR3': 5.12,\n 'LPD': 2.48,\n 'GLU': 4.49,\n '1X6': 6.84,\n 'LPG': 2.39,\n 'GLX': 4.52,\n 'PR4': 4.52,\n 'CML': 6.16,\n 'FME': 4.52,\n 'HTR': 6.48,\n 'PR7': 4.66,\n 'Z3E': 7.2,\n 'GLZ': 2.39,\n 'BMT': 6.37,\n 'WRP': 8.16,\n 'GLY': 2.37,\n 'OMY': 6.11,\n 'MTY': 5.46,\n 'OMX': 6.15,\n 'GLN': 4.46,\n '2XA': 8.25,\n '28X': 7.84,\n '7JA': 9.46,\n 'FLT': 9.65,\n 'GLJ': 3.7,\n 'OMH': 5.26,\n 'TSY': 4.26,\n 'PRV': 4.28,\n 'CS4': 11.21,\n 'DOA': 12.33,\n '23P': 5.42,\n 'CS3': 8.24,\n '6CL': 6.47,\n 'PRR': 5.58,\n 'KST': 11.58,\n 'CS1': 7.23,\n 'PRS': 2.63,\n 'ZYJ': 11.4,\n 'IT1': 9.75,\n 'UU5': 4.98,\n 'ESB': 6.69,\n 'UU4': 2.49,\n 'ESC': 5.65,\n 'LSO': 10.58,\n 'ZYK': 11.45,\n '9NV': 8.99,\n '23F': 5.27,\n 'ORN': 4.25,\n 'HOX': 6.61,\n 'CSD': 3.95,\n 'FP9': 3.03,\n 'DO2': 4.44,\n 'SLL': 11.53,\n 'P3Q': 9.54,\n 'ORQ': 6.04,\n 'MSL': 5.21,\n 'DNP': 2.45,\n 'CSB': 3.51,\n 'WLU': 4.24,\n 'CSA': 5.7,\n 'MT2': 5.51,\n 'CSO': 3.53,\n 'TPO': 4.73,\n 'MSP': 13.11,\n '23S': 6.09,\n 'MSO': 4.96,\n 'PRO': 2.41,\n 'TPL': 5.41,\n 'DNS': 8.79,\n 'CSK': 3.91,\n 'Z70': 7.4,\n 'CSJ': 7.51,\n 'DNW': 7.97,\n 'PRK': 9.15,\n 'GSU': 11.81,\n 'LTA': 6.57,\n 'HPE': 6.63,\n 'TPQ': 6.48,\n 'PRJ': 5.26,\n 'PSW': 4.65,\n 'L3O': 3.89,\n 'CSU': 4.89,\n 'ALY': 7.38,\n 'M3L': 7.12,\n 'CSW': 3.68,\n 'XPR': 7.68,\n 'D4P': 5.66,\n 'FOE': 8.17,\n 'SLZ': 5.69,\n 'CSP': 5.26,\n 'TQI': 7.68,\n 'ALT': 2.72,\n 'CSR': 5.42,\n 'CSS': 3.61,\n 'M3R': 7.18,\n 'ALO': 2.57,\n 'R4K': 4.67,\n 'SMF': 9.0,\n 'MSA': 2.73,\n 'SMC': 3.39,\n 'CSX': 3.47,\n 'SME': 4.8,\n 'ETA': 2.4,\n 'CSZ': 3.6,\n '22G': 8.8,\n 'MSE': 4.62,\n 'ALN': 6.16,\n 'PSH': 7.26,\n 'CTE': 7.27,\n 'DON': 6.72,\n 'CTH': 3.45,\n 'U2X': 11.54,\n '6CW': 7.56,\n 'TQZ': 6.97,\n '3YM': 6.52,\n 'OSE': 4.49,\n '2VA': 9.82,\n 'TQQ': 7.76,\n 'NRG': 8.35,\n 'BPE': 7.24,\n 'F2F': 6.25,\n '1TQ': 8.58,\n 'I2M': 3.13,\n 'NVA': 3.76,\n 'R1A': 8.2,\n 'QPA': 6.95,\n 'C1X': 11.63,\n 'FRD': 5.05,\n 'HR7': 6.98,\n 'SNC': 3.93,\n 'QPH': 5.15,\n '26B': 8.39,\n 'DPQ': 6.54,\n 'DPP': 2.51,\n '2TY': 8.65,\n 'TNR': 6.88,\n 'PTH': 8.35,\n 'DPL': 3.58,\n 'APK': 8.79,\n '1TY': 8.84,\n 'HRG': 7.36,\n 'PTM': 8.74,\n '1U8': 3.62,\n 'PTR': 8.64,\n 'LVG': 3.01,\n '6FL': 4.85,\n 'SOC': 4.05,\n 'KPI': 9.79,\n 'IPG': 2.91,\n 'P2Y': 2.51,\n 'N2C': 3.55,\n 'T0I': 7.34,\n 'MPH': 5.29,\n 'R2T': 4.71,\n 'TOX': 6.78,\n 'P2Q': 9.8,\n 'GPL': 10.77,\n 'MPJ': 5.07,\n 'F2Y': 6.2,\n 'T11': 8.58,\n '9NR': 9.33,\n 'FPR': 8.85,\n '9NF': 8.93,\n 'KPY': 10.17,\n '9NE': 9.77,\n 'TOQ': 7.5,\n 'MPQ': 4.2,\n 'FPK': 3.08,\n 'HQA': 7.25,\n 'SOY': 10.94\n}\nexport const DefaultResidueRadius = 5.0\n\n// http://dx.doi.org/10.1039/b801115j (or 1.6)\nexport const CovalentRadii: { [e: number]: number | undefined } = {\n 1: 0.31, 2: 0.28, 3: 1.28, 4: 0.96, 5: 0.84, 6: 0.76, 7: 0.71, 8: 0.66, 9: 0.57, 10: 0.58, 11: 1.66, 12: 1.41, 13: 1.21, 14: 1.11, 15: 1.07, 16: 1.05, 17: 1.02, 18: 1.06, 19: 2.03, 20: 1.76, 21: 1.7, 22: 1.6, 23: 1.53, 24: 1.39, 25: 1.39, 26: 1.32, 27: 1.26, 28: 1.24, 29: 1.32, 30: 1.22, 31: 1.22, 32: 1.2, 33: 1.19, 34: 1.2, 35: 1.2, 36: 1.16, 37: 2.2, 38: 1.95, 39: 1.9, 40: 1.75, 41: 1.64, 42: 1.54, 43: 1.47, 44: 1.46, 45: 1.42, 46: 1.39, 47: 1.45, 48: 1.44, 49: 1.42, 50: 1.39, 51: 1.39, 52: 1.38, 53: 1.39, 54: 1.4, 55: 2.44, 56: 2.15, 57: 2.07, 58: 2.04, 59: 2.03, 60: 2.01, 61: 1.99, 62: 1.98, 63: 1.98, 64: 1.96, 65: 1.94, 66: 1.92, 67: 1.92, 68: 1.89, 69: 1.9, 70: 1.87, 71: 1.87, 72: 1.75, 73: 1.7, 74: 1.62, 75: 1.51, 76: 1.44, 77: 1.41, 78: 1.36, 79: 1.36, 80: 1.32, 81: 1.45, 82: 1.46, 83: 1.48, 84: 1.4, 85: 1.5, 86: 1.5, 87: 2.6, 88: 2.21, 89: 2.15, 90: 2.06, 91: 2.0, 92: 1.96, 93: 1.9, 94: 1.87, 95: 1.8, 96: 1.69, 97: 1.6, 98: 1.6, 99: 1.6, 100: 1.6, 101: 1.6, 102: 1.6, 103: 1.6, 104: 1.6, 105: 1.6, 106: 1.6, 107: 1.6, 108: 1.6, 109: 1.6, 110: 1.6, 111: 1.6, 112: 1.6, 113: 1.6, 114: 1.6, 115: 1.6, 116: 1.6, 117: 1.6, 118: 1.6\n}\nexport const DefaultCovalentRadius = 1.6\n\nexport const Valences: { [e: number]: number[] | undefined } = {\n 1: [ 1 ],\n 2: [ 0 ],\n 3: [ 1 ],\n 4: [ 2 ],\n 5: [ 3 ],\n 6: [ 4 ],\n 7: [ 3 ],\n 8: [ 2 ],\n 9: [ 1 ],\n 10: [ 0 ],\n 11: [ 1 ],\n 12: [ 2 ],\n 13: [ 6 ],\n 14: [ 6 ],\n 15: [ 3, 5, 7 ],\n 16: [ 2, 4, 6 ],\n 17: [ 1 ],\n 18: [ 0 ],\n 19: [ 1 ],\n 20: [ 2 ],\n\n 31: [ 3 ],\n 32: [ 4 ],\n 33: [ 3, 5 ],\n 34: [ 2, 4, 6 ],\n 35: [ 1 ],\n 36: [ 0 ],\n 37: [ 1 ],\n 38: [ 2 ],\n\n 49: [ 3 ],\n 50: [ 4 ],\n 51: [ 3, 5 ],\n 52: [ 2 ],\n 53: [ 1, 2, 5 ],\n 54: [ 0, 2 ],\n 55: [ 1 ],\n 56: [ 2 ],\n\n 81: [ 3 ],\n 82: [ 4 ],\n 83: [ 3 ],\n 84: [ 2 ],\n 85: [ 1 ],\n 86: [ 0 ],\n 87: [ 1 ],\n 88: [ 2 ]\n}\nexport const DefaultValence = -1\n\nexport const OuterShellElectronCounts: { [e: number]: number | undefined } = {\n1: 1, 2: 2, 3: 1, 4: 2, 5: 3, 6: 4, 7: 5, 8: 6, 9: 7, 10: 8, 11: 1, 12: 2, 13: 3, 14: 4, 15: 5, 16: 6, 17: 7, 18: 8, 19: 1, 20: 2, 21: 3, 22: 4, 23: 5, 24: 6, 25: 7, 26: 8, 27: 9, 28: 10, 29: 11, 30: 2, 31: 3, 32: 4, 33: 5, 34: 6, 35: 7, 36: 8, 37: 1, 38: 2, 39: 3, 40: 4, 41: 5, 42: 6, 43: 7, 44: 8, 45: 9, 46: 10, 47: 11, 48: 2, 49: 3, 50: 4, 51: 5, 52: 6, 53: 7, 54: 8, 55: 1, 56: 2, 57: 3, 58: 4, 59: 3, 60: 4, 61: 5, 62: 6, 63: 7, 64: 8, 65: 9, 66: 10, 67: 11, 68: 12, 69: 13, 70: 14, 71: 15, 72: 4, 73: 5, 74: 6, 75: 7, 76: 8, 77: 9, 78: 10, 79: 11, 80: 2, 81: 3, 82: 4, 83: 5, 84: 6, 85: 7, 86: 8, 87: 1, 88: 2, 89: 3, 90: 4, 91: 3, 92: 4, 93: 5, 94: 6, 95: 7, 96: 8, 97: 9, 98: 10, 99: 11, 100: 12, 101: 13, 102: 14, 103: 15, 104: 2, 105: 2, 106: 2, 107: 2, 108: 2, 109: 2, 110: 2, 111: 2, 112: 2, 113: 3, 114: 4, 115: 5, 116: 6, 117: 7, 118: 8\n}\nexport const DefaultOuterShellElectronCount = 2\n\n// http://blanco.biomol.uci.edu/Whole_residue_HFscales.txt\n// https://www.nature.com/articles/nsb1096-842\nexport const ResidueHydrophobicity: { [k: string]: [number, number, number] } = {\n // AA DGwif DGwoct Oct-IF\n 'ALA': [ 0.17, 0.50, 0.33 ],\n 'ARG': [ 0.81, 1.81, 1.00 ],\n 'ASN': [ 0.42, 0.85, 0.43 ],\n 'ASP': [ 1.23, 3.64, 2.41 ],\n 'ASH': [ -0.07, 0.43, 0.50 ],\n 'CYS': [ -0.24, -0.02, 0.22 ],\n 'GLN': [ 0.58, 0.77, 0.19 ],\n 'GLU': [ 2.02, 3.63, 1.61 ],\n 'GLH': [ -0.01, 0.11, 0.12 ],\n 'GLY': [ 0.01, 1.15, 1.14 ],\n // \"His+\": [ 0.96, 2.33, 1.37 ],\n 'HIS': [ 0.17, 0.11, -0.06 ],\n 'ILE': [ -0.31, -1.12, -0.81 ],\n 'LEU': [ -0.56, -1.25, -0.69 ],\n 'LYS': [ 0.99, 2.80, 1.81 ],\n 'MET': [ -0.23, -0.67, -0.44 ],\n 'PHE': [ -1.13, -1.71, -0.58 ],\n 'PRO': [ 0.45, 0.14, -0.31 ],\n 'SER': [ 0.13, 0.46, 0.33 ],\n 'THR': [ 0.14, 0.25, 0.11 ],\n 'TRP': [ -1.85, -2.09, -0.24 ],\n 'TYR': [ -0.94, -0.71, 0.23 ],\n 'VAL': [ 0.07, -0.46, -0.53 ]\n}\nexport const DefaultResidueHydrophobicity = [ 0.00, 0.00, 0.00 ]\n\nexport const AA1: { [k: string]: string } = {\n 'HIS': 'H',\n 'ARG': 'R',\n 'LYS': 'K',\n 'ILE': 'I',\n 'PHE': 'F',\n 'LEU': 'L',\n 'TRP': 'W',\n 'ALA': 'A',\n 'MET': 'M',\n 'PRO': 'P',\n 'CYS': 'C',\n 'ASN': 'N',\n 'VAL': 'V',\n 'GLY': 'G',\n 'SER': 'S',\n 'GLN': 'Q',\n 'TYR': 'Y',\n 'ASP': 'D',\n 'GLU': 'E',\n 'THR': 'T',\n\n 'SEC': 'U', // as per IUPAC definition\n 'PYL': 'O', // as per IUPAC definition\n}\n\nexport const AA3 = Object.keys(AA1)\n\nexport const RnaBases = [ 'A', 'C', 'T', 'G', 'U', 'I' ]\n\nexport const DnaBases = [ 'DA', 'DC', 'DT', 'DG', 'DU', 'DI' ]\n\nexport const PurinBases = [ 'A', 'G', 'I', 'DA', 'DG', 'DI' ]\n\nexport const Bases = RnaBases.concat(DnaBases)\n\nexport const WaterNames = [\n 'SOL', 'WAT', 'HOH', 'H2O', 'W', 'DOD', 'D3O', 'TIP3', 'TIP4', 'SPC'\n]\n\n// all chemical components with the word \"ion\" in their name, Sep 2016\n//\n// SET SESSION group_concat_max_len = 1000000;\n// SELECT GROUP_CONCAT(id_ ORDER BY id_ ASC SEPARATOR '\", \"') from\n// (\n// SELECT count(obj_id) as c, id_\n// FROM pdb.chem_comp WHERE name LIKE \"% ION%\"\n// GROUP BY id_\n// ) AS t1;\nexport const IonNames = [\n '118', '119', '1AL', '1CU', '2FK', '2HP', '2OF', '3CO',\n '3MT', '3NI', '3OF', '3P8', '4MO', '4PU', '543', '6MO', 'ACT', 'AG', 'AL',\n 'ALF', 'AM', 'ATH', 'AU', 'AU3', 'AUC', 'AZI', 'BA', 'BCT', 'BEF', 'BF4', 'BO4',\n 'BR', 'BS3', 'BSY', 'CA', 'CAC', 'CD', 'CD1', 'CD3', 'CD5', 'CE', 'CHT', 'CL',\n 'CO', 'CO3', 'CO5', 'CON', 'CR', 'CS', 'CSB', 'CU', 'CU1', 'CU3', 'CUA', 'CUZ',\n 'CYN', 'DME', 'DMI', 'DSC', 'DTI', 'DY', 'E4N', 'EDR', 'EMC', 'ER3', 'EU',\n 'EU3', 'F', 'FE', 'FE2', 'FPO', 'GA', 'GD3', 'GEP', 'HAI', 'HG', 'HGC', 'IN',\n 'IOD', 'IR', 'IR3', 'IRI', 'IUM', 'K', 'KO4', 'LA', 'LCO', 'LCP', 'LI', 'LU',\n 'MAC', 'MG', 'MH2', 'MH3', 'MLI', 'MLT', 'MMC', 'MN', 'MN3', 'MN5', 'MN6',\n 'MO1', 'MO2', 'MO3', 'MO4', 'MO5', 'MO6', 'MOO', 'MOS', 'MOW', 'MW1', 'MW2',\n 'MW3', 'NA', 'NA2', 'NA5', 'NA6', 'NAO', 'NAW', 'NCO', 'NET', 'NH4', 'NI',\n 'NI1', 'NI2', 'NI3', 'NO2', 'NO3', 'NRU', 'O4M', 'OAA', 'OC1', 'OC2', 'OC3',\n 'OC4', 'OC5', 'OC6', 'OC7', 'OC8', 'OCL', 'OCM', 'OCN', 'OCO', 'OF1', 'OF2',\n 'OF3', 'OH', 'OS', 'OS4', 'OXL', 'PB', 'PBM', 'PD', 'PDV', 'PER', 'PI', 'PO3',\n 'PO4', 'PR', 'PT', 'PT4', 'PTN', 'RB', 'RH3', 'RHD', 'RU', 'SB', 'SCN', 'SE4',\n 'SEK', 'SM', 'SMO', 'SO3', 'SO4', 'SR', 'T1A', 'TB', 'TBA', 'TCN', 'TEA', 'TH',\n 'THE', 'TL', 'TMA', 'TRA', 'UNX', 'V', 'VN3', 'VO4', 'W', 'WO5', 'Y1', 'YB',\n 'YB2', 'YH', 'YT3', 'ZCM', 'ZN', 'ZN2', 'ZN3', 'ZNO', 'ZO3',\n // additional ion names\n 'OHX'\n]\n\n// all chemical components with the word \"%saccharide%\" in their type, Sep 2016\n//\n// SET SESSION group_concat_max_len = 1000000;\n// select GROUP_CONCAT(id_ ORDER BY id_ ASC SEPARATOR '\", \"') from\n// (\n// SELECT count(obj_id), id_\n// FROM pdb.chem_comp WHERE type like \"%SACCHARIDE%\"\n// GROUP BY id_\n// ) AS t1;\nexport const SaccharideNames = [\n '045', '0AT', '0BD', '0MK', '0NZ', '0TS', '0V4', '0XY', '0YT', '10M',\n '147', '149', '14T', '15L', '16G', '18T', '18Y', '1AR', '1BW', '1GL', '1GN',\n '1JB', '1LL', '1NA', '1S3', '26M', '26Q', '26R', '26V', '26W', '26Y', '27C',\n '289', '291', '293', '2DG', '2F8', '2FG', '2FL', '2FP', '2GL', '2M4', '2M5',\n '32O', '34V', '3CM', '3DO', '3DY', '3FM', '3LR', '3MF', '3MG', '3SA', '3ZW',\n '46D', '46M', '46Z', '48Z', '4CQ', '4GC', '4NN', '50A', '5DI', '5GF', '5MM',\n '5RP', '5SA', '5SP', '64K', '6PG', '6SA', '7JZ', '7SA', 'A1Q', 'A2G', 'AAB',\n 'AAL', 'AAO', 'ABC', 'ABD', 'ABE', 'ABF', 'ABL', 'ACG', 'ACI', 'ACR', 'ACX',\n 'ADA', 'ADG', 'ADR', 'AF1', 'AFD', 'AFL', 'AFO', 'AFP', 'AFR', 'AGC', 'AGH',\n 'AGL', 'AHR', 'AIG', 'ALL', 'ALX', 'AMU', 'AOG', 'AOS', 'ARA', 'ARB', 'ARE',\n 'ARI', 'ASG', 'ASO', 'AXP', 'AXR', 'B0D', 'B16', 'B2G', 'B4G', 'B6D', 'B8D',\n 'B9D', 'BBK', 'BCD', 'BDG', 'BDP', 'BDR', 'BEM', 'BFP', 'BGC', 'BGL', 'BGP',\n 'BGS', 'BHG', 'BMA', 'BMX', 'BNG', 'BNX', 'BOG', 'BRI', 'BXF', 'BXP', 'BXX',\n 'BXY', 'C3X', 'C4X', 'C5X', 'CAP', 'CBI', 'CBK', 'CBS', 'CDR', 'CEG', 'CGF',\n 'CHO', 'CR1', 'CR6', 'CRA', 'CT3', 'CTO', 'CTR', 'CTT', 'D6G', 'DAF', 'DAG',\n 'DDA', 'DDB', 'DDL', 'DEL', 'DFR', 'DFX', 'DG0', 'DGC', 'DGD', 'DGM', 'DGS',\n 'DIG', 'DLF', 'DLG', 'DMU', 'DNO', 'DOM', 'DP5', 'DQQ', 'DQR', 'DR2', 'DR3',\n 'DR4', 'DRI', 'DSR', 'DT6', 'DVC', 'E4P', 'E5G', 'EAG', 'EBG', 'EBQ', 'EGA',\n 'EJT', 'EPG', 'ERE', 'ERI', 'F1P', 'F1X', 'F6P', 'FBP', 'FCA', 'FCB', 'FCT',\n 'FDP', 'FDQ', 'FFC', 'FIX', 'FMO', 'FRU', 'FSI', 'FU4', 'FUB', 'FUC', 'FUD',\n 'FUL', 'FXP', 'G16', 'G1P', 'G2F', 'G3I', 'G4D', 'G4S', 'G6D', 'G6P', 'G6S',\n 'GAC', 'GAD', 'GAL', 'GC1', 'GC4', 'GCD', 'GCN', 'GCO', 'GCS', 'GCT', 'GCU',\n 'GCV', 'GCW', 'GCX', 'GE1', 'GFG', 'GFP', 'GIV', 'GL0', 'GL2', 'GL5', 'GL6',\n 'GL7', 'GL9', 'GLA', 'GLB', 'GLC', 'GLD', 'GLF', 'GLG', 'GLO', 'GLP', 'GLS',\n 'GLT', 'GLW', 'GMH', 'GN1', 'GNX', 'GP1', 'GP4', 'GPH', 'GPM', 'GQ1', 'GQ2',\n 'GQ4', 'GS1', 'GS4', 'GSA', 'GSD', 'GTE', 'GTH', 'GTK', 'GTR', 'GTZ', 'GU0',\n 'GU1', 'GU2', 'GU3', 'GU4', 'GU5', 'GU6', 'GU8', 'GU9', 'GUF', 'GUP', 'GUZ',\n 'GYP', 'GYV', 'H2P', 'HDL', 'HMS', 'HS2', 'HSD', 'HSG', 'HSH', 'HSJ', 'HSQ',\n 'HSR', 'HSU', 'HSX', 'HSY', 'HSZ', 'IAB', 'IDG', 'IDR', 'IDS', 'IDT', 'IDU',\n 'IDX', 'IDY', 'IMK', 'IN1', 'IPT', 'ISL', 'KBG', 'KD2', 'KDA', 'KDM', 'KDO',\n 'KFN', 'KO1', 'KO2', 'KTU', 'L6S', 'LAG', 'LAI', 'LAK', 'LAO', 'LAT', 'LB2',\n 'LBT', 'LCN', 'LDY', 'LGC', 'LGU', 'LM2', 'LMT', 'LMU', 'LOG', 'LOX', 'LPK',\n 'LSM', 'LTM', 'LVZ', 'LXB', 'LXZ', 'M1F', 'M3M', 'M6P', 'M8C', 'MA1', 'MA2',\n 'MA3', 'MAB', 'MAG', 'MAL', 'MAN', 'MAT', 'MAV', 'MAW', 'MBG', 'MCU', 'MDA',\n 'MDM', 'MDP', 'MFA', 'MFB', 'MFU', 'MG5', 'MGA', 'MGL', 'MLB', 'MMA', 'MMN',\n 'MN0', 'MRP', 'MTT', 'MUG', 'MVP', 'MXY', 'N1L', 'N9S', 'NAA', 'NAG', 'NBG',\n 'NDG', 'NED', 'NG1', 'NG6', 'NGA', 'NGB', 'NGC', 'NGE', 'NGF', 'NGL', 'NGS',\n 'NGY', 'NHF', 'NM6', 'NM9', 'NTF', 'NTO', 'NTP', 'NXD', 'NYT', 'OPG', 'OPM',\n 'ORP', 'OX2', 'P3M', 'P53', 'P6P', 'PA5', 'PNA', 'PNG', 'PNW', 'PRP', 'PSJ',\n 'PSV', 'PTQ', 'QDK', 'QPS', 'QV4', 'R1P', 'R1X', 'R2B', 'R5P', 'RAA', 'RAE',\n 'RAF', 'RAM', 'RAO', 'RAT', 'RB5', 'RBL', 'RCD', 'RDP', 'REL', 'RER', 'RF5',\n 'RG1', 'RGG', 'RHA', 'RIB', 'RIP', 'RNS', 'RNT', 'ROB', 'ROR', 'RPA', 'RST',\n 'RUB', 'RUU', 'RZM', 'S6P', 'S7P', 'SA0', 'SCR', 'SDD', 'SF6', 'SF9', 'SG4',\n 'SG5', 'SG6', 'SG7', 'SGA', 'SGC', 'SGD', 'SGN', 'SGS', 'SHB', 'SHG', 'SI3',\n 'SIO', 'SOE', 'SOL', 'SSG', 'SUC', 'SUP', 'SUS', 'T6P', 'T6T', 'TAG', 'TCB',\n 'TDG', 'TGK', 'TGY', 'TH1', 'TIA', 'TM5', 'TM6', 'TM9', 'TMR', 'TMX', 'TOA',\n 'TOC', 'TRE', 'TYV', 'UCD', 'UDC', 'VG1', 'X0X', 'X1X', 'X2F', 'X4S', 'X5S',\n 'X6X', 'XBP', 'XDN', 'XDP', 'XIF', 'XIM', 'XLF', 'XLS', 'XMM', 'XUL', 'XXR',\n 'XYP', 'XYS', 'YO5', 'Z3Q', 'Z6J', 'Z9M', 'ZDC', 'ZDM'\n]\n\nexport const ProteinBackboneAtoms = [\n 'CA', 'C', 'N', 'O',\n 'O1', 'O2', 'OC1', 'OC2', 'OX1', 'OXT', 'OT1', 'OT2',\n 'H', 'H1', 'H2', 'H3', 'HA', 'HN',\n 'BB'\n]\n\nexport const NucleicBackboneAtoms = [\n 'P', 'OP1', 'OP2', 'HOP2', 'HOP3',\n \"O2'\", \"O3'\", \"O4'\", \"O5'\", \"C1'\", \"C2'\", \"C3'\", \"C4'\", \"C5'\",\n \"H1'\", \"H2'\", \"H2''\", \"HO2'\", \"H3'\", \"H4'\", \"H5'\", \"H5''\", \"HO3'\", \"HO5'\",\n 'O2*', 'O3*', 'O4*', 'O5*', 'C1*', 'C2*', 'C3*', 'C4*', 'C5*'\n]\n\nexport const ResidueTypeAtoms: { [k: number]: { [k: string]: string|string[] } } = {}\n\nResidueTypeAtoms[ ProteinBackboneType ] = {\n trace: 'CA',\n direction1: 'C',\n direction2: [ 'O', 'OC1', 'O1', 'OX1', 'OXT', 'OT1', 'OT2' ],\n backboneStart: 'N',\n backboneEnd: 'C'\n}\n\nResidueTypeAtoms[ RnaBackboneType ] = {\n trace: [ \"C4'\", 'C4*' ],\n direction1: [ \"C1'\", 'C1*' ],\n direction2: [ \"C3'\", 'C3*' ],\n backboneStart: 'P',\n backboneEnd: [ \"O3'\", 'O3*' ]\n}\n\nResidueTypeAtoms[ DnaBackboneType ] = {\n trace: [ \"C3'\", 'C3*' ],\n direction1: [ \"C2'\", 'C2*' ],\n direction2: [ \"O4'\", 'O4*' ],\n backboneStart: 'P',\n backboneEnd: [ \"O3'\", 'O3*' ]\n}\n\nResidueTypeAtoms[ CgProteinBackboneType ] = {\n trace: [ 'CA', 'BB' ],\n backboneStart: [ 'CA', 'BB' ],\n backboneEnd: [ 'CA', 'BB' ]\n}\n\nResidueTypeAtoms[ CgRnaBackboneType ] = {\n trace: [ \"C4'\", 'C4*', 'P' ],\n backboneStart: [ \"C4'\", 'C4*', 'P' ],\n backboneEnd: [ \"C4'\", 'C4*', 'P' ]\n}\n\nResidueTypeAtoms[ CgDnaBackboneType ] = {\n trace: [ \"C3'\", 'C3*', \"C2'\", 'P' ], // C2' is used in martini ff\n backboneStart: [ \"C3'\", 'C3*', \"C2'\", 'P' ],\n backboneEnd: [ \"C3'\", 'C3*', \"C2'\", 'P' ]\n}\n\nResidueTypeAtoms[ UnknownBackboneType ] = {}\n\n// Mappings taken from Meeko: https://github.com/forlilab/Meeko/blob/develop/meeko/utils/autodock4_atom_types_elements.py\nexport const PDBQTSpecialElements = {\n 'HD': 'H',\n 'HS': 'H',\n 'A': 'C',\n 'NA': 'N',\n 'NS': 'N',\n 'OA': 'O',\n 'OS': 'O',\n 'SA': 'S',\n 'G0': 'C',\n 'G1': 'C',\n 'G2': 'C',\n 'G3': 'C',\n 'CG0': 'C',\n 'CG1': 'C',\n 'CG2': 'C',\n 'CG3': 'C',\n 'W': 'O'\n}","/**\n * @file Geometry\n * @author Fred Ludlow \n * @author Alexander Rose \n */\n\nimport { Vector3 } from 'three'\n\nimport { Elements } from '../structure/structure-constants'\nimport { degToRad } from '../math/math-utils'\nimport AtomProxy from '../proxy/atom-proxy'\n\n// Changed numbering so they're mostly inline with coordination number\n// from VSEPR\nexport const enum AtomGeometry {\n Spherical = 0,\n Terminal = 1,\n Linear = 2,\n Trigonal = 3,\n Tetrahedral = 4,\n TrigonalBiPyramidal = 5,\n Octahedral = 6,\n SquarePlanar = 7, // Okay, it breaks down somewhere!\n Unknown = 8\n}\n\nexport function assignGeometry (totalCoordination: number): AtomGeometry {\n switch(totalCoordination){\n case 0:\n return AtomGeometry.Spherical\n case 1:\n return AtomGeometry.Terminal\n case 2:\n return AtomGeometry.Linear\n case 3:\n return AtomGeometry.Trigonal\n case 4:\n return AtomGeometry.Tetrahedral\n default:\n return AtomGeometry.Unknown\n }\n}\n\nexport const Angles = new Map([\n [ AtomGeometry.Linear, degToRad(180) ],\n [ AtomGeometry.Trigonal, degToRad(120) ],\n [ AtomGeometry.Tetrahedral, degToRad(109.4721) ],\n [ AtomGeometry.Octahedral, degToRad(90) ]\n])\n\n/**\n * Calculate the angles x-1-2 for all x where x is a heavy atom bonded to ap1.\n * @param {AtomProxy} ap1 First atom (angle centre)\n * @param {AtomProxy} ap2 Second atom\n * @return {number[]} Angles in radians\n */\nexport function calcAngles (ap1: AtomProxy, ap2: AtomProxy): number[] {\n let angles: number[] = []\n const d1 = new Vector3()\n const d2 = new Vector3()\n d1.subVectors(ap2 as any, ap1 as any)\n ap1.eachBondedAtom( x => {\n if (x.number !== Elements.H) {\n d2.subVectors(x as any, ap1 as any)\n angles.push(d1.angleTo(d2))\n }\n })\n return angles\n}\n\n/**\n * Find two neighbours of ap1 to define a plane (if possible) and\n * measure angle out of plane to ap2\n * @param {AtomProxy} ap1 First atom (angle centre)\n * @param {AtomProxy} ap2 Second atom (out-of-plane)\n * @return {number} Angle from plane to second atom\n */\nexport function calcPlaneAngle (ap1: AtomProxy, ap2: AtomProxy): number | undefined {\n const x1 = ap1.clone()\n\n const v12 = new Vector3()\n v12.subVectors(ap2 as any, ap1 as any)\n\n const neighbours = [new Vector3(), new Vector3()]\n let ni = 0\n ap1.eachBondedAtom( x => {\n if (ni > 1) { return }\n if (x.number !== Elements.H) {\n x1.index = x.index\n neighbours[ni++].subVectors(x as any, ap1 as any)\n }\n })\n if (ni === 1) {\n x1.eachBondedAtom( x => {\n if (ni > 1) { return }\n if (x.number !== Elements.H && x.index !== ap1.index){\n neighbours[ni++].subVectors(x as any, ap1 as any)\n }\n })\n }\n if (ni !== 2) {\n return\n }\n\n const cp = neighbours[0].cross(neighbours[1])\n return Math.abs((Math.PI / 2) - cp.angleTo(v12))\n}\n","/**\n * @file Valence Model\n * @author Fred Ludlow \n * @author Alexander Rose \n */\n\n/**\n * Reworked ValenceModel\n *\n * TODO:\n * Ensure proper treatment of disorder/models. e.g. V257 N in 5vim\n * Formal charge of 255 for SO4 anion (e.g. 5ghl)\n * Have removed a lot of explicit features (as I think they're more\n * generally captured by better VM).\n * Could we instead have a \"delocalised negative/positive\" charge\n * feature and flag these up?\n *\n */\nimport { Data } from '../structure/data'\nimport AtomProxy from '../proxy/atom-proxy'\nimport { AtomGeometry, assignGeometry } from './geometry'\nimport { Elements } from '../structure/structure-constants'\n\n/**\n * Are we involved in some kind of pi system. Either explicitly forming\n * double bond or N, O next to a double bond, except:\n *\n * N,O with degree 4 cannot be conjugated.\n * N,O adjacent to P=O or S=O do not qualify (keeps sulfonamide N sp3 geom)\n */\nfunction isConjugated (a: AtomProxy) {\n const _bp = a.structure.getBondProxy()\n const atomicNumber = a.number\n const hetero = atomicNumber === Elements.O || atomicNumber === Elements.N\n\n if (hetero && a.bondCount === 4) {\n return false\n }\n\n let flag = false\n\n a.eachBond(b => {\n if (b.bondOrder > 1) {\n flag = true\n return\n }\n if (hetero) {\n const a2 = b.getOtherAtom(a)\n\n a2.eachBond(b2 => {\n if (b2.bondOrder > 1) {\n const atomicNumber2 = a2.number\n if (\n (atomicNumber2 === Elements.P || atomicNumber2 === Elements.S) &&\n b2.getOtherAtom(a2).number === Elements.O\n ) {\n return\n }\n flag = true\n }\n }, _bp) // Avoid reuse of structure._bp\n }\n })\n\n return flag\n}\n\n/* function hasExplicitCharge(r: ResidueProxy) {\n let flag = false\n r.eachAtom(a => {\n if (a.formalCharge != null && a.formalCharge !== 0) flag = true\n })\n return flag\n}\n\nfunction hasExplicitHydrogen(r: ResidueProxy) {\n let flag = false\n r.eachAtom(a => {\n if (a.number === Elements.H) flag = true\n })\n return flag\n} */\n\nexport function explicitValence (a: AtomProxy) {\n let v = 0\n a.eachBond(b => v += b.bondOrder)\n return v\n}\n\n/**\n * Attempts to produce a consistent charge and implicit\n * H-count for an atom.\n *\n * If both params.assignCharge and params.assignH, this\n * approximately followsthe rules described in\n * https://docs.eyesopen.com/toolkits/python/oechemtk/valence.html#openeye-hydrogen-count-model\n *\n * If only charge or hydrogens are to be assigned it takes\n * a much simpler view and deduces one from the other\n *\n * @param {AtomProxy} a Atom to analyze\n * @param {assignChargeHParams} params What to assign\n */\nexport function calculateHydrogensCharge (a: AtomProxy, params: ValenceModelParams) {\n const hydrogenCount = a.bondToElementCount(Elements.H)\n let charge = a.formalCharge || 0\n\n const assignCharge = (params.assignCharge === 'always' ||\n (params.assignCharge === 'auto' && charge === 0))\n const assignH = (params.assignH === 'always' ||\n (params.assignH === 'auto' && hydrogenCount === 0))\n\n const degree = a.bondCount\n const valence = explicitValence(a)\n\n const conjugated = isConjugated(a)\n const multiBond = (valence - degree > 0)\n\n\n let implicitHCount = 0\n let geom = AtomGeometry.Unknown\n\n switch (a.number) {\n case Elements.H:\n if (assignCharge){\n if (degree === 0){\n charge = 1\n geom = AtomGeometry.Spherical\n } else if (degree === 1) {\n charge = 0\n geom = AtomGeometry.Terminal\n }\n }\n break\n\n case Elements.C:\n // TODO: Isocyanide?\n if (assignCharge) {\n charge = 0 // Assume carbon always neutral\n }\n if (assignH) {\n // Carbocation/carbanion are 3-valent\n implicitHCount = Math.max(0, 4 - valence - Math.abs(charge))\n }\n // Carbocation is planar, carbanion is tetrahedral\n geom = assignGeometry(degree + implicitHCount + Math.max(0, -charge))\n break\n\n case Elements.N:\n if (assignCharge) {\n if (!assignH) { // Trust input H explicitly:\n charge = valence - 3\n } else if (conjugated && valence < 4) {\n // Neutral unless amidine/guanidine double-bonded N:\n if (degree - hydrogenCount === 1 && valence - hydrogenCount === 2) {\n charge = 1\n } else {\n charge = 0\n }\n } else {\n // Sulfonamide nitrogen and classed as sp3 in conjugation model but\n // they won't be charged\n // Don't assign charge to nitrogens bound to metals\n let flag = false\n a.eachBondedAtom(ba => {\n if (ba.number === Elements.S || ba.isMetal()) flag = true\n })\n if (flag) charge = 0\n else charge = 1\n // TODO: Planarity sanity check?\n }\n\n }\n\n if (assignH) {\n // NH4+ -> 4, 1' amide -> 2, nitro N/N+ depiction -> 0\n implicitHCount = Math.max(0, 3 - valence + charge)\n }\n\n if (conjugated && !multiBond) {\n // Amide, anilinic N etc. cannot consider lone-pair for geometry purposes\n // Anilinic N geometry is depenent on ring electronics, for our purposes we\n // assume it's trigonal!\n geom = assignGeometry(degree + implicitHCount - charge)\n } else {\n // Everything else, pyridine, amine, nitrile, lp plays normal role:\n geom = assignGeometry(degree + implicitHCount + 1 - charge)\n }\n break\n\n case Elements.O:\n if (assignCharge) {\n if (!assignH) {\n charge = valence - 2 //\n }\n if (valence === 1) {\n a.eachBondedAtom(ba => {\n ba.eachBond(b => {\n const oa = b.getOtherAtom(ba)\n if (oa.index !== a.index && oa.number === Elements.O && b.bondOrder === 2){\n charge = -1\n }\n })\n })\n }\n }\n if (assignH) {\n // ethanol -> 1, carboxylate -> -1\n implicitHCount = Math.max(0, 2 - valence + charge)\n }\n if (conjugated && !multiBond){\n // carboxylate OH, phenol OH, one lone-pair taken up with conjugation\n geom = assignGeometry(degree + implicitHCount - charge + 1)\n } else {\n // Carbonyl (trigonal)\n geom = assignGeometry(degree + implicitHCount - charge + 2)\n }\n break\n\n // Only handles thiols/thiolates/thioether/sulfonium. Sulfoxides and higher\n // oxidiation states are assumed neutral S (charge carried on O if required)\n case Elements.S:\n if (assignCharge) {\n if (!assignH) {\n if (valence <= 3 && !a.bondToElementCount(Elements.O)) {\n charge = valence - 2 // e.g. explicitly deprotonated thiol\n } else {\n charge = 0\n }\n }\n }\n if (assignH){\n if (valence < 2){\n implicitHCount = Math.max(0, 2 - valence + charge)\n }\n }\n if (valence <= 3){\n // Thiol, thiolate, tioether -> tetrahedral\n geom = assignGeometry(degree + implicitHCount - charge + 2)\n }\n\n break\n\n case Elements.F:\n case Elements.CL:\n case Elements.BR:\n case Elements.I:\n case Elements.AT:\n // Never implicitly protonate halides\n if (assignCharge) {\n charge = valence - 1\n }\n break\n\n case Elements.LI:\n case Elements.NA:\n case Elements.K:\n case Elements.RB:\n case Elements.CS:\n case Elements.FR:\n if (assignCharge) {\n charge = 1 - valence\n }\n break\n\n case Elements.BE:\n case Elements.MG:\n case Elements.CA:\n case Elements.SR:\n case Elements.BA:\n case Elements.RA:\n if (assignCharge) {\n charge = 2 - valence\n }\n break\n\n default:\n console.warn('Requested charge, protonation for an unhandled element', a.element)\n }\n\n return [ charge, implicitHCount, implicitHCount + hydrogenCount, geom ]\n}\n\n\nexport interface ValenceModel {\n charge: Int8Array,\n implicitH: Int8Array,\n totalH: Int8Array,\n idealGeometry: Int8Array\n}\n\nexport interface ValenceModelParams {\n assignCharge: string,\n assignH: string\n}\n\nexport function ValenceModel (data: Data, params: ValenceModelParams) {\n const structure = data.structure\n const n = structure.atomCount\n\n const charge = new Int8Array(n)\n const implicitH = new Int8Array(n)\n const totalH = new Int8Array(n)\n const idealGeometry = new Int8Array(n)\n\n structure.eachAtom(a => {\n const i = a.index\n const [ chg, implH, totH, geom ] = calculateHydrogensCharge(a, params)\n charge[ i ] = chg\n implicitH[ i ] = implH\n totalH[ i ] = totH\n idealGeometry[ i ] = geom\n })\n\n return { charge, implicitH, totalH, idealGeometry }\n}","\nimport Structure from './structure'\nimport SpatialHash from '../geometry/spatial-hash'\nimport { ValenceModel } from '../chemistry/valence-model'\n\nexport interface Data {\n structure: Structure\n '@spatialLookup': SpatialHash | undefined\n '@valenceModel': ValenceModel | undefined\n}\n\nexport function createData(structure: Structure): Data {\n return {\n structure,\n '@spatialLookup': undefined,\n '@valenceModel': undefined\n }\n}\n\nexport function spatialLookup(data: Data): SpatialHash {\n if (data['@spatialLookup']) return data['@spatialLookup']!\n const lookup = new SpatialHash(data.structure.atomStore, data.structure.boundingBox)\n data['@spatialLookup'] = lookup\n return lookup\n}\n\nexport function valenceModel(data: Data): ValenceModel {\n if (data['@valenceModel']) return data['@valenceModel']!\n const valenceModel = ValenceModel(data, {assignCharge: 'auto', assignH: 'auto'})\n data['@valenceModel'] = valenceModel\n return valenceModel\n}\n","/**\n * @file Functional Groups\n * @author Alexander Rose \n */\n\nimport AtomProxy from '../proxy/atom-proxy'\nimport { Elements } from '../structure/structure-constants'\n\n/**\n * Nitrogen in a quaternary amine\n */\nexport function isQuaternaryAmine (a: AtomProxy) {\n return (\n a.number === 7 &&\n a.bondCount === 4 &&\n a.bondToElementCount(Elements.H) === 0\n )\n}\n\n/**\n * Nitrogen in a tertiary amine\n */\nexport function isTertiaryAmine (a: AtomProxy, idealValence: number) {\n return (\n a.number === 7 &&\n a.bondCount >= 3 &&\n idealValence === 3\n )\n}\n\n/**\n * Nitrogen in an imide\n */\nexport function isImide (a: AtomProxy) {\n let flag = false\n if (a.number === Elements.N && (a.bondCount - a.bondToElementCount(Elements.H)) === 2) {\n let carbonylCount = 0\n a.eachBondedAtom(ba => {\n if (isCarbonyl(ba)) ++carbonylCount\n })\n flag = carbonylCount === 2\n }\n return flag\n}\n\n/**\n * Nitrogen in an amide\n */\nexport function isAmide (a: AtomProxy) {\n let flag = false\n if (a.number === Elements.N && (a.bondCount - a.bondToElementCount(Elements.H)) === 2) {\n let carbonylCount = 0\n a.eachBondedAtom(ba => {\n if (isCarbonyl(ba)) ++carbonylCount\n })\n flag = carbonylCount === 1\n }\n return flag\n}\n\n/**\n * Sulfur in a sulfonium group\n */\nexport function isSulfonium (a: AtomProxy) {\n return (\n a.number === 16 &&\n a.bondCount === 3 &&\n a.bondToElementCount(Elements.H) === 0\n )\n}\n\n/**\n * Sulfur in a sulfonic acid or sulfonate group\n */\nexport function isSulfonicAcid (a: AtomProxy) {\n return (\n a.number === 16 &&\n a.bondToElementCount(Elements.O) === 3\n )\n}\n\n/**\n * Sulfur in a sulfate group\n */\nexport function isSulfate (a: AtomProxy) {\n return (\n a.number === 16 &&\n a.bondToElementCount(Elements.O) === 4\n )\n}\n\n/**\n * Phosphor in a phosphate group\n */\nexport function isPhosphate (a: AtomProxy) {\n return (\n a.number === 15 &&\n a.bondToElementCount(Elements.O) === a.bondCount\n )\n}\n\n/**\n * Halogen with one bond to a carbon\n */\nexport function isHalocarbon (a: AtomProxy) {\n return (\n a.isHalogen() &&\n a.bondCount === 1 &&\n a.bondToElementCount(Elements.C) === 1\n )\n}\n\n/**\n * Carbon in a carbonyl/acyl group\n */\nexport function isCarbonyl (a: AtomProxy) {\n let flag = false\n if (a.number === Elements.C) {\n a.eachBond(b => {\n if (b.bondOrder === 2 && b.getOtherAtom(a).number === Elements.O) {\n flag = true\n }\n })\n }\n return flag\n}\n\n/**\n * Carbon in a carboxylate group\n */\nexport function isCarboxylate (a: AtomProxy) {\n let terminalOxygenCount = 0\n if (\n a.number === 6 &&\n a.bondToElementCount(Elements.O) === 2 &&\n a.bondToElementCount(Elements.C) === 1\n ) {\n a.eachBondedAtom(ba => {\n if (ba.number === 8 && ba.bondCount - ba.bondToElementCount(Elements.H) === 1) {\n ++terminalOxygenCount\n }\n })\n }\n return terminalOxygenCount === 2\n}\n\n/**\n * Carbon in a guanidine group\n */\nexport function isGuanidine (a: AtomProxy) {\n let terminalNitrogenCount = 0\n if (\n a.number === 6 &&\n a.bondCount === 3 &&\n a.bondToElementCount(Elements.N) === 3\n ) {\n a.eachBondedAtom(ba => {\n if (ba.bondCount - ba.bondToElementCount(Elements.H) === 1) {\n ++terminalNitrogenCount\n }\n })\n }\n return terminalNitrogenCount === 2\n}\n\n/**\n * Carbon in a acetamidine group\n */\nexport function isAcetamidine (a: AtomProxy) {\n let terminalNitrogenCount = 0\n if (\n a.number === 6 &&\n a.bondCount === 3 &&\n a.bondToElementCount(Elements.N) === 2 &&\n a.bondToElementCount(Elements.C) === 1\n ) {\n a.eachBondedAtom(ba => {\n if (ba.bondCount - ba.bondToElementCount(Elements.H) === 1) {\n ++terminalNitrogenCount\n }\n })\n }\n return terminalNitrogenCount === 2\n}\n\nconst PolarElements = [\n Elements.N, Elements.O, Elements.S,\n Elements.F, Elements.CL, Elements.BR, Elements.I\n]\n\nexport function isPolar (a: AtomProxy) {\n return PolarElements.includes(a.number)\n}\n\nexport function hasPolarNeighbour (a: AtomProxy) {\n let flag = false\n a.eachBondedAtom(ba => {\n if (isPolar(ba)) flag = true\n })\n return flag\n}\n\nexport function hasAromaticNeighbour (a: AtomProxy) {\n let flag = false\n a.eachBondedAtom(function (bap) {\n if (bap.aromatic) flag = true\n })\n return flag\n}\n","/**\n * @file Charged\n * @author Alexander Rose \n * @author Fred Ludlow \n */\n\nimport { Vector3 } from 'three'\n\nimport { defaults } from '../../utils'\nimport { radToDeg } from '../../math/math-utils'\nimport Structure from '../../structure/structure'\nimport { AA3, Bases, Elements } from '../../structure/structure-constants'\nimport { valenceModel } from '../../structure/data'\nimport {\n isGuanidine, isAcetamidine, isSulfonicAcid, isPhosphate, isSulfate, isCarboxylate\n} from '../functional-groups'\nimport {\n Features, FeatureType, FeatureGroup,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\n\nconst PositvelyCharged = [ 'ARG', 'HIS', 'LYS' ]\nconst NegativelyCharged = [ 'GLU', 'ASP' ]\n\nexport function addPositiveCharges (structure: Structure, features: Features) {\n const { charge } = valenceModel(structure.data)\n const atomInGroupDict: { [atomIndex: number]: true } = {}\n\n structure.eachResidue(r => {\n if (PositvelyCharged.includes(r.resname)) {\n const state = createFeatureState(FeatureType.PositiveCharge)\n r.eachAtom(a => {\n if (a.number === Elements.N && a.isSidechain()) {\n addAtom(state, a)\n }\n })\n addFeature(features, state)\n } else if(!AA3.includes(r.resname) && !r.isNucleic()) {\n r.eachAtom(a => {\n let addGroup = false\n const state = createFeatureState(FeatureType.PositiveCharge)\n if (isGuanidine(a)) {\n state.group = FeatureGroup.Guanidine\n addGroup = true\n } else if (isAcetamidine(a)) {\n state.group = FeatureGroup.Acetamidine\n addGroup = true\n }\n if (addGroup) {\n a.eachBondedAtom(a => {\n if (a.number === Elements.N) {\n atomInGroupDict[a.index] = true\n addAtom(state, a)\n }\n })\n addFeature(features, state)\n }\n })\n r.eachAtom(a => {\n const state = createFeatureState(FeatureType.PositiveCharge)\n if (charge[a.index] > 0) {\n if (!atomInGroupDict[a.index]) {\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n })\n }\n })\n}\n\nexport function addNegativeCharges (structure: Structure, features: Features) {\n const { charge } = valenceModel(structure.data)\n const atomInGroupDict: { [atomIndex: number]: true } = {}\n\n structure.eachResidue(r => {\n if (NegativelyCharged.includes(r.resname)) {\n const state = createFeatureState(FeatureType.NegativeCharge)\n r.eachAtom(a => {\n if (a.number === Elements.O && a.isSidechain()) {\n addAtom(state, a)\n }\n })\n addFeature(features, state)\n } else if (Bases.includes(r.resname)) {\n const state = createFeatureState(FeatureType.NegativeCharge)\n r.eachAtom(a => {\n if (isPhosphate(a)) {\n state.group = FeatureGroup.Phosphate\n a.eachBondedAtom(a => {\n if (a.number === Elements.O) addAtom(state, a)\n })\n addFeature(features, state)\n }\n })\n } else if(!AA3.includes(r.resname) && !Bases.includes(r.resname)) {\n r.eachAtom(a => {\n let addGroup = false\n const state = createFeatureState(FeatureType.NegativeCharge)\n if (isSulfonicAcid(a)) {\n state.group = FeatureGroup.SulfonicAcid\n addGroup = true\n } else if (isPhosphate(a)) {\n state.group = FeatureGroup.Phosphate\n addGroup = true\n } else if (isSulfate(a)) {\n state.group = FeatureGroup.Sulfate\n addGroup = true\n } else if (isCarboxylate(a)) {\n state.group = FeatureGroup.Carboxylate\n addGroup = true\n }\n if (addGroup) {\n a.eachBondedAtom(a => {\n if (a.number === Elements.O) {\n atomInGroupDict[a.index] = true\n addAtom(state, a)\n }\n })\n addFeature(features, state)\n }\n })\n r.eachAtom(a => {\n const state = createFeatureState(FeatureType.NegativeCharge)\n if (charge[a.index] < 0) {\n if (!atomInGroupDict[a.index]) {\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n })\n }\n })\n}\n\nexport function addAromaticRings (structure: Structure, features: Features) {\n const a = structure.getAtomProxy()\n structure.eachResidue(r => {\n const rings = r.getAromaticRings()\n if (rings) {\n const offset = r.atomOffset\n rings.forEach(ring => {\n const state = createFeatureState(FeatureType.AromaticRing)\n ring.forEach(i => {\n a.index = i + offset\n addAtom(state, a)\n })\n addFeature(features, state)\n })\n }\n })\n}\n\nfunction isIonicInteraction (ti: FeatureType, tj: FeatureType) {\n return (\n (ti === FeatureType.NegativeCharge && tj === FeatureType.PositiveCharge) ||\n (ti === FeatureType.PositiveCharge && tj === FeatureType.NegativeCharge)\n )\n}\n\nfunction isPiStacking (ti: FeatureType, tj: FeatureType) {\n return ti === FeatureType.AromaticRing && tj === FeatureType.AromaticRing\n}\n\nfunction isCationPi (ti: FeatureType, tj: FeatureType) {\n return (\n (ti === FeatureType.AromaticRing && tj === FeatureType.PositiveCharge) ||\n (ti === FeatureType.PositiveCharge && tj === FeatureType.AromaticRing)\n )\n}\n\nexport interface ChargedContactsParams {\n maxIonicDist?: number\n maxPiStackingDist?: number\n maxPiStackingOffset?: number\n maxPiStackingAngle?: number\n maxCationPiDist?: number\n maxCationPiOffset?: number\n masterModelIndex?: number\n}\n\nexport function addChargedContacts (structure: Structure, contacts: Contacts, params: ChargedContactsParams = {}) {\n const maxIonicDist = defaults(params.maxIonicDist, ContactDefaultParams.maxIonicDist)\n const maxPiStackingDist = defaults(params.maxPiStackingDist, ContactDefaultParams.maxPiStackingDist)\n const maxPiStackingOffset = defaults(params.maxPiStackingOffset, ContactDefaultParams.maxPiStackingOffset)\n const maxPiStackingAngle = defaults(params.maxPiStackingAngle, ContactDefaultParams.maxPiStackingAngle)\n const maxCationPiDist = defaults(params.maxCationPiDist, ContactDefaultParams.maxCationPiDist)\n const maxCationPiOffset = defaults(params.maxCationPiOffset, ContactDefaultParams.maxCationPiOffset)\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const maxDistance = Math.max(maxIonicDist + 2, maxPiStackingDist, maxCationPiDist)\n // const maxSaltBridgeDistSq = maxSaltBridgeDist * maxSaltBridgeDist\n const maxPiStackingDistSq = maxPiStackingDist * maxPiStackingDist\n const maxCationPiDistSq = maxCationPiDist * maxCationPiDist\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const ax = structure.atomStore.x\n const ay = structure.atomStore.y\n const az = structure.atomStore.z\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n const areAtomSetsWithinDist = function (atomSet1: number[], atomSet2: number[], maxDist: number) {\n const sn = atomSet1.length\n const sm = atomSet2.length\n for (let si = 0; si < sn; ++si) {\n ap1.index = atomSet1[ si ]\n for (let sj = 0; sj < sm; ++sj) {\n ap2.index = atomSet2[ sj ]\n if (ap1.distanceTo(ap2) <= maxDist) {\n return true\n }\n }\n }\n return false\n }\n\n const v1 = new Vector3()\n const v2 = new Vector3()\n const v3 = new Vector3()\n const d1 = new Vector3()\n const d2 = new Vector3()\n const n1 = new Vector3()\n const n2 = new Vector3()\n\n const getNormal = function (atoms: number[], normal: Vector3) {\n v1.set(ax[ atoms[ 0 ] ], ay[ atoms[ 0 ] ], az[ atoms[ 0 ] ])\n v2.set(ax[ atoms[ 1 ] ], ay[ atoms[ 1 ] ], az[ atoms[ 1 ] ])\n v3.set(ax[ atoms[ 2 ] ], ay[ atoms[ 2 ] ], az[ atoms[ 2 ] ])\n d1.subVectors(v1, v2)\n d2.subVectors(v1, v3)\n normal.crossVectors(d1, d2)\n }\n\n const getOffset = function (i: number, j: number, normal: Vector3) {\n v1.set(x[ i ], y[ i ], z[ i ])\n v2.set(x[ j ], y[ j ], z[ j ])\n return v1.sub(v2).projectOnPlane(normal).add(v2).distanceTo(v2)\n }\n\n const add = function (i: number, j: number, ct: ContactType) {\n featureSet.setBits(i, j)\n contactStore.addContact(i, j, ct)\n }\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxDistance, (j, dSq) => {\n if (j <= i) return\n\n ap1.index = atomSets[ i ][ 0 ]\n ap2.index = atomSets[ j ][ 0 ]\n\n if (invalidAtomContact(ap1, ap2, masterIdx)) return\n\n const ti = types[ i ]\n const tj = types[ j ]\n\n if (isIonicInteraction(ti, tj)) {\n if (areAtomSetsWithinDist(atomSets[ i ], atomSets[ j ], maxIonicDist)) {\n add(i, j, ContactType.IonicInteraction)\n }\n } else if (isPiStacking(ti, tj)) {\n if (dSq <= maxPiStackingDistSq) {\n getNormal(atomSets[ i ], n1)\n getNormal(atomSets[ j ], n2)\n\n const angle = radToDeg(n1.angleTo(n2))\n const offset = Math.min(getOffset(i, j, n2), getOffset(j, i, n1))\n if (offset <= maxPiStackingOffset) {\n if (angle <= maxPiStackingAngle || angle >= 180 - maxPiStackingAngle) {\n add(i, j, ContactType.PiStacking) // parallel\n } else if (angle <= maxPiStackingAngle + 90 && angle >= 90 - maxPiStackingAngle) {\n add(i, j, ContactType.PiStacking) // t-shaped\n }\n }\n }\n } else if (isCationPi(ti, tj)) {\n if (dSq <= maxCationPiDistSq) {\n const [ l, k ] = ti === FeatureType.AromaticRing ? [ i, j ] : [ j, i ]\n\n getNormal(atomSets[ l ], n1)\n const offset = getOffset(k, l, n1)\n if (offset <= maxCationPiOffset) {\n add(l, k, ContactType.CationPi)\n }\n }\n }\n })\n }\n}\n","/**\n * @file Hydrogen Bonds\n * @author Alexander Rose \n * @author Fred Ludlow \n */\nimport { defaults } from '../../utils'\nimport { degToRad } from '../../math/math-utils'\nimport Structure from '../../structure/structure'\nimport AtomProxy from '../../proxy/atom-proxy'\nimport { valenceModel } from '../../structure/data'\nimport { Elements } from '../../structure/structure-constants'\nimport { Angles, AtomGeometry, calcAngles, calcPlaneAngle } from '../geometry'\nimport {\n Features, FeatureType,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\n\n\n// Geometric characteristics of hydrogen bonds involving sulfur atoms in proteins\n// https://doi.org/10.1002/prot.22327\n\n// Satisfying Hydrogen Bonding Potential in Proteins (HBPLUS)\n// https://doi.org/10.1006/jmbi.1994.1334\n// http://www.csb.yale.edu/userguides/datamanip/hbplus/hbplus_descrip.html\n\n/**\n * Potential hydrogen donor\n */\nexport function addHydrogenDonors (structure: Structure, features: Features) {\n const { totalH } = valenceModel(structure.data)\n\n structure.eachAtom(a => {\n const state = createFeatureState(FeatureType.HydrogenDonor)\n\n const an = a.number\n if (isHistidineNitrogen(a)) {\n // include both nitrogen atoms in histidine due to\n // their often ambiguous protonation assignment\n addAtom(state, a)\n addFeature(features, state)\n } else if (\n totalH[ a.index ] > 0 &&\n (an === Elements.N || an === Elements.O || an === Elements.S)\n ) {\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\n/**\n * Weak hydrogen donor.\n */\nexport function addWeakHydrogenDonors (structure: Structure, features: Features) {\n const { totalH } = valenceModel(structure.data)\n\n structure.eachAtom(a => {\n if (\n a.number === Elements.C &&\n totalH[ a.index ] > 0 &&\n (\n a.bondToElementCount(Elements.N) > 0 ||\n a.bondToElementCount(Elements.O) > 0 ||\n inAromaticRingWithElectronNegativeElement(a)\n )\n ) {\n const state = createFeatureState(FeatureType.WeakHydrogenDonor)\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\nfunction inAromaticRingWithElectronNegativeElement (a: AtomProxy) {\n if (!a.isAromatic()) return false\n\n const ringData = a.residueType.getRings()\n if (!ringData) return false\n\n let hasElement = false\n const rings = ringData.rings\n rings.forEach(ring => {\n if (hasElement) return // already found one\n if (ring.some(idx => (a.index - a.residueAtomOffset) === idx)) { // in ring\n hasElement = ring.some(idx => {\n const atomTypeId = a.residueType.atomTypeIdList[ idx ]\n const number = a.atomMap.get(atomTypeId).number\n return number === Elements.N || number === Elements.O\n })\n }\n })\n\n return hasElement\n}\n\n/**\n * Potential hydrogen acceptor\n */\nexport function addHydrogenAcceptors (structure: Structure, features: Features) {\n const { charge, implicitH, idealGeometry } = valenceModel(structure.data)\n\n structure.eachAtom(a => {\n const state = createFeatureState(FeatureType.HydrogenAcceptor)\n\n const an = a.number\n if (an === Elements.O) {\n // Basically assume all oxygen atoms are acceptors!\n addAtom(state, a)\n addFeature(features, state)\n }else if (an === Elements.N) {\n if (isHistidineNitrogen(a)) {\n // include both nitrogen atoms in histidine due to\n // their often ambiguous protonation assignment\n addAtom(state, a)\n addFeature(features, state)\n } else if (charge[ a.index ] < 1){\n // Neutral nitrogen might be an acceptor\n // It must have at least one lone pair not conjugated\n const totalBonds = a.bondCount + implicitH[ a.index ]\n const ig = idealGeometry[ a.index ]\n if (\n (ig === AtomGeometry.Tetrahedral && totalBonds < 4) ||\n (ig === AtomGeometry.Trigonal && totalBonds < 3) ||\n (ig === AtomGeometry.Linear && totalBonds < 2)\n ) {\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n }else if (an === 16) { // S\n if (a.resname === 'CYS' || a.resname === 'MET' || a.formalCharge === -1) {\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n })\n}\n\n/**\n * Atom that is only bound to carbon or hydrogen\n */\n// function isHydrocarbon (atom: AtomProxy) {\n// let flag = true\n// atom.eachBondedAtom(ap => {\n// const e = ap.element\n// if (e !== 'C' && e !== 'H') flag = false\n// })\n// return flag\n// }\n\nfunction isHistidineNitrogen (ap: AtomProxy) {\n return ap.resname === 'HIS' && ap.number == Elements.N && ap.isRing()\n}\n\nfunction isBackboneHydrogenBond (ap1: AtomProxy, ap2: AtomProxy) {\n return ap1.isBackbone() && ap2.isBackbone()\n}\n\nfunction isWaterHydrogenBond (ap1: AtomProxy, ap2: AtomProxy) {\n return ap1.isWater() && ap2.isWater()\n}\n\nfunction isHydrogenBond (ti: FeatureType, tj: FeatureType) {\n return (\n (ti === FeatureType.HydrogenAcceptor && tj === FeatureType.HydrogenDonor) ||\n (ti === FeatureType.HydrogenDonor && tj === FeatureType.HydrogenAcceptor)\n )\n}\n\nfunction isWeakHydrogenBond (ti: FeatureType, tj: FeatureType){\n return (\n (ti === FeatureType.WeakHydrogenDonor && tj === FeatureType.HydrogenAcceptor) ||\n (ti === FeatureType.HydrogenAcceptor && tj === FeatureType.WeakHydrogenDonor)\n )\n}\n\nfunction getHydrogenBondType (ap1: AtomProxy, ap2: AtomProxy) {\n if (isWaterHydrogenBond(ap1, ap2)) {\n return ContactType.WaterHydrogenBond\n } else if (isBackboneHydrogenBond(ap1, ap2)) {\n return ContactType.BackboneHydrogenBond\n } else {\n return ContactType.HydrogenBond\n }\n}\n\nexport interface HydrogenBondParams {\n maxHbondDist?: number\n maxHbondSulfurDist?: number\n maxHbondAccAngle?: number\n maxHbondDonAngle?: number\n maxHbondAccPlaneAngle?: number\n maxHbondDonPlaneAngle?: number\n backboneHbond?: boolean\n waterHbond?: boolean\n masterModelIndex?: number\n}\n\n/**\n * All pairs of hydrogen donor and acceptor atoms\n */\nexport function addHydrogenBonds (structure: Structure, contacts: Contacts, params: HydrogenBondParams = {}) {\n const maxHbondDist = defaults(params.maxHbondDist, ContactDefaultParams.maxHbondDist)\n const maxHbondSulfurDist = defaults(params.maxHbondSulfurDist, ContactDefaultParams.maxHbondSulfurDist)\n const maxHbondAccAngle = degToRad(defaults(params.maxHbondAccAngle, ContactDefaultParams.maxHbondAccAngle))\n const maxHbondDonAngle = degToRad(defaults(params.maxHbondDonAngle, ContactDefaultParams.maxHbondDonAngle))\n const maxHbondAccPlaneAngle = degToRad(defaults(params.maxHbondAccPlaneAngle, ContactDefaultParams.maxHbondAccPlaneAngle))\n const maxHbondDonPlaneAngle = degToRad(defaults(params.maxHbondDonPlaneAngle, ContactDefaultParams.maxHbondDonPlaneAngle))\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const maxDist = Math.max(maxHbondDist, maxHbondSulfurDist)\n const maxHbondDistSq = maxHbondDist * maxHbondDist\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const { idealGeometry } = valenceModel(structure.data)\n\n const donor = structure.getAtomProxy()\n const acceptor = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxDist, (j, dSq) => {\n if (j <= i) return\n\n const ti = types[ i ]\n const tj = types[ j ]\n\n const isWeak = isWeakHydrogenBond(ti, tj)\n if (!isWeak && !isHydrogenBond(ti, tj)) return\n\n const [ l, k ] = tj === FeatureType.HydrogenAcceptor ? [ i, j ] : [ j, i ]\n\n donor.index = atomSets[ l ][ 0 ]\n acceptor.index = atomSets[ k ][ 0 ]\n\n if (acceptor.index === donor.index) return // DA to self\n\n if (invalidAtomContact(donor, acceptor, masterIdx)) return\n if (donor.number !== Elements.S && acceptor.number !== Elements.S && dSq > maxHbondDistSq) return\n if (donor.connectedTo(acceptor)) return\n\n const donorAngles = calcAngles(donor, acceptor)\n const idealDonorAngle = Angles.get(idealGeometry[donor.index]) || degToRad(120)\n if (donorAngles.some(donorAngle => {\n return Math.abs(idealDonorAngle - donorAngle) > maxHbondDonAngle\n })) return\n\n if (idealGeometry[donor.index] === AtomGeometry.Trigonal){\n const outOfPlane = calcPlaneAngle(donor, acceptor)\n if (outOfPlane !== undefined && outOfPlane > maxHbondDonPlaneAngle) return\n }\n\n const acceptorAngles = calcAngles(acceptor, donor)\n const idealAcceptorAngle = Angles.get(idealGeometry[acceptor.index]) || degToRad(120)\n if (acceptorAngles.some(acceptorAngle => {\n // Do not limit large acceptor angles\n return idealAcceptorAngle - acceptorAngle > maxHbondAccAngle\n })) return\n\n if (idealGeometry[acceptor.index] === AtomGeometry.Trigonal){\n const outOfPlane = calcPlaneAngle(acceptor, donor)\n if (outOfPlane !== undefined && outOfPlane > maxHbondAccPlaneAngle) return\n }\n\n featureSet.setBits(l, k)\n const bondType = isWeak ? ContactType.WeakHydrogenBond : getHydrogenBondType(donor, acceptor)\n contactStore.addContact(l, k, bondType)\n })\n }\n}\n","/**\n * @file Metal Binding\n * @author Alexander Rose \n */\n\nimport { defaults } from '../../utils'\nimport Structure from '../../structure/structure'\n// import { valenceModel } from '../../structure/data'\nimport { Elements, AA3, Bases } from '../../structure/structure-constants'\n// import { hasAromaticNeighbour } from '../functional-groups'\nimport {\n Features, FeatureType,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\n\nconst IonicTypeMetals = [\n Elements.LI, Elements.NA, Elements.K, Elements.RB, Elements.CS,\n Elements.MG, Elements.CA, Elements.SR, Elements.BA, Elements.AL,\n Elements.GA, Elements.IN, Elements.TL, Elements.SC, Elements.SN,\n Elements.PB, Elements.BI, Elements.SB, Elements.HG\n]\n\n/**\n * Metal binding partners (dative bond or ionic-type interaction)\n */\nexport function addMetalBinding (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n let dative = false\n let ionic = false\n\n const isStandardAminoacid = AA3.includes(a.resname)\n const isStandardBase = Bases.includes(a.resname)\n\n if (!isStandardAminoacid && !isStandardBase) {\n if (a.isHalogen() || a.number === Elements.O || a.number === Elements.S) {\n dative = true\n ionic = true\n } else if (a.number === Elements.N) {\n dative = true\n }\n } else if (isStandardAminoacid){\n // main chain oxygen atom or oxygen, nitrogen and sulfur from specific amino acids\n if (a.number === Elements.O) {\n if(['ASP', 'GLU', 'SER', 'THR', 'TYR', 'ASN', 'GLN'].includes(a.resname) && a.isSidechain()) {\n dative = true\n ionic = true\n } else if (a.isBackbone()) {\n dative = true\n ionic = true\n }\n } else if (a.number === Elements.S && 'CYS' === a.resname) {\n dative = true\n ionic = true\n } else if (a.number === Elements.N) {\n if(a.resname === 'HIS' && a.isSidechain()) {\n dative = true\n }\n }\n } else if (isStandardBase){\n // http://pubs.acs.org/doi/pdf/10.1021/acs.accounts.6b00253\n // http://onlinelibrary.wiley.com/doi/10.1002/anie.200900399/full\n if (a.number === Elements.O && a.isBackbone()) {\n dative = true\n ionic = true\n } else if(['N3', 'N4', 'N7'].includes(a.atomname)) {\n dative = true\n } else if(['O2', 'O4', 'O6'].includes(a.atomname)) {\n dative = true\n ionic = true\n }\n }\n if (dative) {\n const state = createFeatureState(FeatureType.DativeBondPartner)\n addAtom(state, a)\n addFeature(features, state)\n }\n if (ionic) {\n const state = createFeatureState(FeatureType.IonicTypePartner)\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\n/**\n * Metal Pi complexation partner\n */\n// export function addMetalPiPartners (structure: Structure, features: Features) {\n// const { charge } = valenceModel(structure.data)\n\n// structure.eachAtom(a => {\n// const state = createFeatureState(FeatureType.MetalPiPartner)\n\n// const resname = a.resname\n// const element = a.element\n// const atomname = a.atomname\n// if (!a.isPolymer()) {\n// // water oxygen, as well as oxygen from carboxylate, phosphoryl, phenolate, alcohol;\n// // nitrogen from imidazole; sulfur from thiolate\n// if (element === 'O') {\n// // Water oxygen\n// if (a.bondCount === 0 || a.isWater()) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// // Oxygen in alcohol (R-[O]-H)\n// if (a.bondCount === 2 && charge[ a.index ] || a.hasBondToElement('H')) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// // Phenolate oxygen\n// if (hasAromaticNeighbour(a) && !a.aromatic) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// // Carboxylic acid oxygen\n// if (a.bondToElementCount('C') === 1) {\n// let flag = false\n// a.eachBondedAtom(ba => {\n// if (ba.element === 'C' && ba.bondToElementCount('O') === 2 && ba.bondToElementCount('C') === 1) {\n// flag = true\n// }\n// })\n// if (flag) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// }\n// // Phosphoryl oxygen\n// if (a.bondToElementCount('P') === 1) {\n// let flag = false\n// a.eachBondedAtom(ba => {\n// if (ba.element === 'P' && ba.bondToElementCount('O') >= 3) {\n// flag = true\n// }\n// })\n// if (flag) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// }\n// } else if (element === 'N') {\n// // Imidazole/pyrrole or similar\n// if (a.bondToElementCount('C') === 2) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// } else if (element === 'S') {\n// // Thiolate\n// if (hasAromaticNeighbour(a) && !a.aromatic) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// // Sulfur in Iron sulfur cluster\n// const ironCount = a.bondToElementCount('FE')\n// if (ironCount > 0 && ironCount === a.bondCount) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// }\n// }\n// })\n// }\n\nexport function addMetals (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n if (a.isTransitionMetal() || a.number === Elements.ZN || a.number === Elements.CD) {\n const state = createFeatureState(FeatureType.TransitionMetal)\n addAtom(state, a)\n addFeature(features, state)\n } else if (IonicTypeMetals.includes(a.number)) {\n const state = createFeatureState(FeatureType.IonicTypeMetal)\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\nfunction isMetalComplex (ti: FeatureType, tj: FeatureType) {\n if (ti === FeatureType.TransitionMetal) {\n return (\n tj === FeatureType.DativeBondPartner ||\n tj === FeatureType.TransitionMetal\n )\n } else if (ti === FeatureType.IonicTypeMetal) {\n return (\n tj === FeatureType.IonicTypePartner\n )\n }\n}\n\nexport interface MetalComplexationParams {\n maxMetalDist?: number\n masterModelIndex?: number\n}\n\n/**\n * Metal complexes of metals and appropriate groups in protein and ligand, including water\n */\nexport function addMetalComplexation (structure: Structure, contacts: Contacts, params: MetalComplexationParams = {}) {\n const maxMetalDist = defaults(params.maxMetalDist, ContactDefaultParams.maxMetalDist)\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxMetalDist, (j, dSq) => {\n if (j <= i) return\n\n ap1.index = atomSets[ i ][ 0 ]\n ap2.index = atomSets[ j ][ 0 ]\n\n if (invalidAtomContact(ap1, ap2, masterIdx)) return\n\n const m1 = ap1.isMetal()\n const m2 = ap2.isMetal()\n if (!m1 && !m2) return\n\n const [ ti, tj ] = m1 ? [ types[ i ],types[ j ] ] : [ types[ j ],types[ i ] ]\n\n if (isMetalComplex(ti, tj)) {\n featureSet.setBits(i, j)\n contactStore.addContact(i, j, ContactType.MetalCoordination)\n }\n })\n }\n}\n","/**\n * @file Halogen Bonds\n * @author Alexander Rose \n * @author Fred Ludlow \n */\n\nimport { defaults } from '../../utils'\nimport Structure from '../../structure/structure'\nimport { Elements } from '../../structure/structure-constants'\nimport { degToRad } from '../../math/math-utils'\nimport {\n Features, FeatureType,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\nimport { calcAngles } from '../geometry'\n\nconst halBondElements = [17, 35, 53, 85]\n\n/**\n * Halogen bond donors (X-C, with X one of Cl, Br, I or At) not F!\n */\nexport function addHalogenDonors (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n if (halBondElements.includes(a.number) && a.bondToElementCount(Elements.C) === 1) {\n const state = createFeatureState(FeatureType.HalogenDonor)\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\nconst X = [ Elements.N, Elements.O, Elements.S ]\nconst Y = [ Elements.C, Elements.N, Elements.P, Elements.S ]\n\n/**\n * Halogen bond acceptors (Y-{O|N|S}, with Y=C,P,N,S)\n */\nexport function addHalogenAcceptors (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n if (X.includes(a.number)) {\n let flag = false\n a.eachBondedAtom(ba => {\n if (Y.includes(ba.number)) {\n flag = true\n }\n })\n if (flag) {\n const state = createFeatureState(FeatureType.HalogenAcceptor)\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n })\n}\n\nfunction isHalogenBond (ti: FeatureType, tj: FeatureType) {\n return (\n (ti === FeatureType.HalogenAcceptor && tj === FeatureType.HalogenDonor) ||\n (ti === FeatureType.HalogenDonor && tj === FeatureType.HalogenAcceptor)\n )\n}\n\nexport interface HalogenBondsParams {\n maxHalogenBondDist?: number\n maxHalogenBondAngle?: number\n masterModelIndex?: number\n}\n\n// http://www.pnas.org/content/101/48/16789.full\nconst OptimalHalogenAngle = degToRad(180) // adjusted from 165 to account for spherical statistics\nconst OptimalAcceptorAngle = degToRad(120)\n\n/**\n * All pairs of halogen donor and acceptor atoms\n */\nexport function addHalogenBonds (structure: Structure, contacts: Contacts, params: HalogenBondsParams = {}) {\n const maxHalogenBondDist = defaults(params.maxHalogenBondDist, ContactDefaultParams.maxHalogenBondDist)\n const maxHalogenBondAngle = degToRad(defaults(params.maxHalogenBondAngle, ContactDefaultParams.maxHalogenBondAngle))\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxHalogenBondDist, (j, dSq) => {\n if (j <= i) return\n\n ap1.index = atomSets[ i ][ 0 ]\n ap2.index = atomSets[ j ][ 0 ]\n\n if (invalidAtomContact(ap1, ap2, masterIdx)) return\n if (!isHalogenBond(types[ i ], types[ j ])) return\n\n const [ halogen, acceptor ] = types[ i ] === FeatureType.HalogenDonor ? [ ap1, ap2 ] : [ ap2, ap1 ]\n\n const halogenAngles = calcAngles(halogen, acceptor)\n // Singly bonded halogen only (not bromide ion for example)\n if (halogenAngles.length !== 1) return\n if (OptimalHalogenAngle - halogenAngles[0] > maxHalogenBondAngle) return\n\n const acceptorAngles = calcAngles(acceptor, halogen)\n // Angle must be defined. Excludes water as acceptor. Debatable\n if (acceptorAngles.length === 0) return\n if (acceptorAngles.some(acceptorAngle => {\n return (OptimalAcceptorAngle - acceptorAngle > maxHalogenBondAngle)\n })) return\n\n\n featureSet.setBits(i, j)\n contactStore.addContact(i, j, ContactType.HalogenBond)\n\n })\n }\n}\n","/**\n * @file Refine Contacts\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { Debug, Log } from '../../globals'\nimport { defaults } from '../../utils'\nimport Structure from '../../structure/structure'\nimport AtomProxy from '../../proxy/atom-proxy'\nimport { Elements } from '../../structure/structure-constants'\nimport { FrozenContacts, ContactType, ContactDefaultParams, isMasterContact } from './contact'\nimport { FeatureType } from './features'\n\nexport interface LineOfSightParams {\n lineOfSightDistFactor?: number\n masterModelIndex?: number\n}\n\n// also allows intra-residue contacts\nexport function invalidAtomContact (ap1: AtomProxy, ap2: AtomProxy, masterIdx: number) {\n return !isMasterContact(ap1, ap2, masterIdx) && (\n ap1.modelIndex !== ap2.modelIndex ||\n (ap1.altloc && ap2.altloc && ap1.altloc !== ap2.altloc)\n )\n}\n\nexport function refineLineOfSight (structure: Structure, contacts: FrozenContacts, params: LineOfSightParams = {}) {\n if (Debug) Log.time('refineLineOfSight')\n\n const lineOfSightDistFactor = defaults(params.lineOfSightDistFactor, ContactDefaultParams.lineOfSightDistFactor)\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const spatialHash = structure.spatialHash!\n const { contactSet, contactStore, features } = contacts\n const { index1, index2 } = contactStore\n const { centers, atomSets } = features\n const { x, y, z } = centers\n\n const ac1 = structure.getAtomProxy()\n const ac2 = structure.getAtomProxy()\n const aw = structure.getAtomProxy()\n\n const c1 = new Vector3()\n const c2 = new Vector3()\n\n const lineOfSightDist = 3 * lineOfSightDistFactor\n const lineOfSightDistFactorSq = lineOfSightDistFactor * lineOfSightDistFactor\n\n contactSet.forEach(i => {\n c1.set(x[index1[i]], y[index1[i]], z[index1[i]])\n c2.set(x[index2[i]], y[index2[i]], z[index2[i]])\n\n const cx = ( c1.x + c2.x ) / 2\n const cy = ( c1.y + c2.y ) / 2\n const cz = ( c1.z + c2.z ) / 2\n\n const as1 = atomSets[ index1[ i ] ]\n const as2 = atomSets[ index2[ i ] ]\n\n ac1.index = as1[ 0 ]\n ac2.index = as2[ 0 ]\n\n spatialHash.eachWithin(cx, cy, cz, lineOfSightDist, (j, dSq) => {\n aw.index = j\n if (\n aw.number !== Elements.H &&\n (aw.vdw * aw.vdw * lineOfSightDistFactorSq) > dSq &&\n !invalidAtomContact(ac1, aw, masterIdx) &&\n !invalidAtomContact(ac2, aw, masterIdx) &&\n !as1.includes(j) &&\n !as2.includes(j) &&\n // to ignore atoms in the center of functional groups\n c1.distanceToSquared(aw as any) > 1 &&\n c2.distanceToSquared(aw as any) > 1\n ) {\n contactSet.clear(i)\n if (Debug) Log.log('removing', ac1.qualifiedName(), ac2.qualifiedName(), 'because', aw.qualifiedName())\n }\n })\n })\n\n if (Debug) Log.timeEnd('refineLineOfSight')\n}\n\n/**\n * For atoms interacting with several atoms in the same residue\n * only the one with the closest distance is kept.\n */\nexport function refineHydrophobicContacts (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features } = contacts\n const { type, index1, index2 } = contactStore\n const { atomSets } = features\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n const residueContactDict: { [k: string]: number[] } = {}\n\n /* keep only closest contact between residues */\n const handleResidueContact = function (dist: number, i: number, key: string) {\n const [ minDist, minIndex ] = residueContactDict[ key ] || [ Infinity, -1 ]\n if (dist < minDist) {\n if (minIndex !== -1) contactSet.clear(minIndex)\n residueContactDict[ key ] = [ dist, i ]\n } else {\n contactSet.clear(i)\n }\n }\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.Hydrophobic) return\n\n ap1.index = atomSets[ index1[ i ] ][ 0 ]\n ap2.index = atomSets[ index2[ i ] ][ 0 ]\n\n const dist = ap1.distanceTo(ap2)\n handleResidueContact(dist, i, `${ap1.index}|${ap2.residueIndex}`)\n handleResidueContact(dist, i, `${ap2.index}|${ap1.residueIndex}`)\n })\n}\n\nfunction isHydrogenBondType (type: number) {\n return (\n type === ContactType.HydrogenBond ||\n type === ContactType.WaterHydrogenBond ||\n type === ContactType.BackboneHydrogenBond\n )\n}\n\n/**\n * Remove weak hydrogen bonds when the acceptor is involved in\n * a normal/strong hydrogen bond\n */\nexport function refineWeakHydrogenBonds (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features, adjacencyList } = contacts\n const { type, index1, index2 } = contactStore\n const { types } = features\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.WeakHydrogenBond) return\n\n let accFeat: number\n if (types[ index1[ i ] ] === FeatureType.WeakHydrogenDonor) {\n accFeat = index2[ i ]\n } else {\n accFeat = index1[ i ]\n }\n\n const n = adjacencyList.countArray[ accFeat ]\n const offset = adjacencyList.offsetArray[ accFeat ]\n for (let j = 0; j < n; ++j) {\n const ci = adjacencyList.indexArray[ offset + j ]\n if (isHydrogenBondType(type[ ci ])) {\n contactSet.clear(i)\n return\n }\n }\n })\n}\n\n/**\n * Remove hydrogen bonds between groups that also form\n * a salt bridge between each other\n */\nexport function refineSaltBridges (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features } = contacts\n const { type, index1, index2 } = contactStore\n const { atomSets } = features\n\n const ionicInteractionDict: { [atomIndex: number]: number[] } = {}\n\n const add = function(idx: number, i: number) {\n if (!ionicInteractionDict[ idx ]) ionicInteractionDict[ idx ] = []\n ionicInteractionDict[ idx ].push(i)\n }\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.IonicInteraction) return\n atomSets[ index1[ i ] ].forEach(idx => add(idx, i))\n atomSets[ index2[ i ] ].forEach(idx => add(idx, i))\n })\n\n contactSet.forEach(i => {\n if (!isHydrogenBondType(type[ i ])) return\n\n const iil1 = ionicInteractionDict[ atomSets[ index1[ i ] ][ 0 ] ]\n const iil2 = ionicInteractionDict[ atomSets[ index2[ i ] ][ 0 ] ]\n if (!iil1 || !iil2) return\n\n const n = iil1.length\n for (let j = 0; j < n; ++j) {\n if (iil2.includes(iil1[j])) {\n contactSet.clear(i)\n return\n }\n }\n })\n}\n\n/**\n * Remove hydrophobic and cation-pi interactions between groups that also form\n * a pi-stacking interaction between each other\n */\nexport function refinePiStacking (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features } = contacts\n const { type, index1, index2 } = contactStore\n const { atomSets } = features\n\n const piStackingDict: { [atomIndex: number]: number[] } = {}\n\n const add = function(idx: number, i: number) {\n if (!piStackingDict[ idx ]) piStackingDict[ idx ] = []\n piStackingDict[ idx ].push(i)\n }\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.PiStacking) return\n atomSets[ index1[ i ] ].forEach(idx => add(idx, i))\n atomSets[ index2[ i ] ].forEach(idx => add(idx, i))\n })\n\n contactSet.forEach(i => {\n if (\n type[ i ] !== ContactType.Hydrophobic &&\n type[ i ] !== ContactType.CationPi\n ) return\n\n const pil1 = piStackingDict[ atomSets[ index1[ i ] ][ 0 ] ]\n const pil2 = piStackingDict[ atomSets[ index2[ i ] ][ 0 ] ]\n if (!pil1 || !pil2) return\n\n const n = pil1.length\n for (let j = 0; j < n; ++j) {\n if (pil2.includes(pil1[j])) {\n contactSet.clear(i)\n return\n }\n }\n })\n}\n\n/**\n * Remove ionic interactions between groups that also form\n * a metal coordination between each other\n */\nexport function refineMetalCoordination (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features } = contacts\n const { type, index1, index2 } = contactStore\n const { atomSets } = features\n\n const ionicInteractionDict: { [atomIndex: number]: number[] } = {}\n\n const add = function(idx: number, i: number) {\n if (!ionicInteractionDict[ idx ]) ionicInteractionDict[ idx ] = []\n ionicInteractionDict[ idx ].push(i)\n }\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.IonicInteraction) return\n atomSets[ index1[ i ] ].forEach(idx => add(idx, i))\n atomSets[ index2[ i ] ].forEach(idx => add(idx, i))\n })\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.MetalCoordination) return\n\n const iil1 = ionicInteractionDict[ atomSets[ index1[ i ] ][ 0 ] ]\n const iil2 = ionicInteractionDict[ atomSets[ index2[ i ] ][ 0 ] ]\n if (!iil1 || !iil2) return\n\n const n = iil1.length\n for (let j = 0; j < n; ++j) {\n if (iil2.includes(iil1[j])) {\n contactSet.clear(iil1[j])\n return\n }\n }\n })\n}\n\n// TODO: refactor refineSaltBridges, refinePiStacking and refineMetalCoordination to be DRY\n","/**\n * @file Contact\n * @author Alexander Rose \n */\n\nimport { Color } from 'three'\n\nimport { Debug, Log } from '../../globals'\nimport { createParams } from '../../utils'\nimport { TextBufferData } from '../../buffer/text-buffer'\nimport Structure from '../../structure/structure'\nimport AtomProxy from '../../proxy/atom-proxy'\nimport SpatialHash from '../../geometry/spatial-hash'\nimport { calculateCenterArray, calculateDirectionArray, uniformArray } from '../../math/array-utils'\nimport ContactStore from '../../store/contact-store'\nimport BitArray from '../../utils/bitarray'\nimport Selection from '../../selection/selection'\nimport { ContactPicker } from '../../utils/picker'\nimport { createAdjacencyList, AdjacencyList } from '../../utils/adjacency-list'\nimport { createFeatures, Features } from './features'\nimport { addAromaticRings, addNegativeCharges, addPositiveCharges, addChargedContacts } from './charged'\nimport { addHydrogenAcceptors, addHydrogenDonors, addHydrogenBonds, addWeakHydrogenDonors } from './hydrogen-bonds'\nimport { addMetalBinding, addMetals, addMetalComplexation } from './metal-binding'\nimport { addHydrophobic, addHydrophobicContacts } from './hydrophobic'\nimport { addHalogenAcceptors, addHalogenDonors, addHalogenBonds } from './halogen-bonds'\nimport {\n refineLineOfSight,\n refineHydrophobicContacts, refineSaltBridges, refinePiStacking, refineMetalCoordination\n} from './refine-contacts'\n\nexport interface Contacts {\n features: Features\n spatialHash: SpatialHash\n contactStore: ContactStore\n featureSet: BitArray\n}\n\nexport interface FrozenContacts extends Contacts {\n contactSet: BitArray\n adjacencyList: AdjacencyList\n}\n\nexport const enum ContactType {\n Unknown = 0,\n IonicInteraction = 1,\n CationPi = 2,\n PiStacking = 3,\n HydrogenBond = 4,\n HalogenBond = 5,\n Hydrophobic = 6,\n MetalCoordination = 7,\n WeakHydrogenBond = 8,\n WaterHydrogenBond = 9,\n BackboneHydrogenBond = 10\n}\n\nexport const ContactDefaultParams = {\n maxHydrophobicDist: 4.0,\n maxHbondDist: 3.5,\n maxHbondSulfurDist: 4.1,\n maxHbondAccAngle: 45,\n maxHbondDonAngle: 45,\n maxHbondAccPlaneAngle: 90,\n maxHbondDonPlaneAngle: 30,\n maxPiStackingDist: 5.5,\n maxPiStackingOffset: 2.0,\n maxPiStackingAngle: 30,\n maxCationPiDist: 6.0,\n maxCationPiOffset: 2.0,\n maxIonicDist: 5.0,\n maxHalogenBondDist: 4.0,\n maxHalogenBondAngle: 30,\n maxMetalDist: 3.0,\n refineSaltBridges: true,\n masterModelIndex: -1,\n lineOfSightDistFactor: 1.0\n}\n\nexport function isMasterContact (ap1: AtomProxy, ap2: AtomProxy, masterIdx: number) {\n return (\n (ap1.modelIndex === masterIdx && ap2.modelIndex !== masterIdx) ||\n (ap2.modelIndex === masterIdx && ap1.modelIndex !== masterIdx)\n )\n}\n\nexport function invalidAtomContact (ap1: AtomProxy, ap2: AtomProxy, masterIdx: number) {\n return !isMasterContact(ap1, ap2, masterIdx) && (\n ap1.modelIndex !== ap2.modelIndex ||\n ap1.residueIndex === ap2.residueIndex ||\n (ap1.altloc && ap2.altloc && ap1.altloc !== ap2.altloc)\n )\n}\n\nexport function createContacts (features: Features): Contacts {\n const { types, centers } = features\n\n const spatialHash = new SpatialHash(centers)\n const contactStore = new ContactStore()\n const featureSet = new BitArray(types.length, false)\n\n return { features, spatialHash, contactStore, featureSet }\n}\n\nexport function createFrozenContacts (contacts: Contacts): FrozenContacts {\n const { index1, index2, count } = contacts.contactStore\n\n const adjacencyList = createAdjacencyList({\n nodeArray1: index1,\n nodeArray2: index2,\n edgeCount: count,\n nodeCount: contacts.featureSet.length\n })\n const contactSet = new BitArray(contacts.contactStore.count, true)\n\n return Object.assign({ adjacencyList, contactSet }, contacts)\n}\n\nfunction calculateFeatures (structure: Structure) {\n const features = createFeatures()\n\n if (Debug) Log.time('calculateFeatures')\n\n addPositiveCharges(structure, features)\n addNegativeCharges(structure, features)\n addAromaticRings(structure, features)\n\n addHydrogenAcceptors(structure, features)\n addHydrogenDonors(structure, features)\n addWeakHydrogenDonors(structure, features)\n\n addMetalBinding(structure, features)\n addMetals(structure, features)\n\n addHydrophobic(structure, features)\n\n addHalogenAcceptors(structure, features)\n addHalogenDonors(structure, features)\n\n if (Debug) Log.timeEnd('calculateFeatures')\n\n return features\n}\n\nexport function calculateContacts (structure: Structure, params = ContactDefaultParams) {\n const features = calculateFeatures(structure)\n const contacts = createContacts(features)\n\n if (Debug) Log.time('calculateContacts')\n\n addChargedContacts(structure, contacts, params)\n addHydrogenBonds(structure, contacts, params)\n addMetalComplexation(structure, contacts, params)\n addHydrophobicContacts(structure, contacts, params)\n addHalogenBonds(structure, contacts, params)\n\n const frozenContacts = createFrozenContacts(contacts)\n\n refineLineOfSight(structure, frozenContacts, params)\n refineHydrophobicContacts(structure, frozenContacts)\n if (params.refineSaltBridges) refineSaltBridges(structure, frozenContacts)\n refinePiStacking(structure, frozenContacts)\n refineMetalCoordination(structure, frozenContacts)\n\n if (Debug) Log.timeEnd('calculateContacts')\n\n return frozenContacts\n}\n\nexport function contactTypeName (type: ContactType) {\n switch (type) {\n case ContactType.HydrogenBond:\n case ContactType.WaterHydrogenBond:\n case ContactType.BackboneHydrogenBond:\n return 'hydrogen bond'\n case ContactType.Hydrophobic:\n return 'hydrophobic contact'\n case ContactType.HalogenBond:\n return 'halogen bond'\n case ContactType.IonicInteraction:\n return 'ionic interaction'\n case ContactType.MetalCoordination:\n return 'metal coordination'\n case ContactType.CationPi:\n return 'cation-pi interaction'\n case ContactType.PiStacking:\n return 'pi-pi stacking'\n case ContactType.WeakHydrogenBond:\n return 'weak hydrogen bond'\n default:\n return 'unknown contact'\n }\n}\n\nexport const ContactDataDefaultParams = {\n hydrogenBond: true,\n hydrophobic: true,\n halogenBond: true,\n ionicInteraction: true,\n metalCoordination: true,\n cationPi: true,\n piStacking: true,\n weakHydrogenBond: true,\n waterHydrogenBond: true,\n backboneHydrogenBond: true,\n radius: 1,\n filterSele: ''\n}\nexport type ContactDataParams = typeof ContactDataDefaultParams\n | { filterSele: string|[string, string] }\n\nexport const ContactLabelDefaultParams = {\n unit: '',\n size: 2.0\n}\n\nexport type ContactLabelParams = typeof ContactLabelDefaultParams\n\nconst tmpColor = new Color()\nfunction contactColor (type: ContactType) {\n switch (type) {\n case ContactType.HydrogenBond:\n case ContactType.WaterHydrogenBond:\n case ContactType.BackboneHydrogenBond:\n return tmpColor.setHex(0x2B83BA).toArray()\n case ContactType.Hydrophobic:\n return tmpColor.setHex(0x808080).toArray()\n case ContactType.HalogenBond:\n return tmpColor.setHex(0x40FFBF).toArray()\n case ContactType.IonicInteraction:\n return tmpColor.setHex(0xF0C814).toArray()\n case ContactType.MetalCoordination:\n return tmpColor.setHex(0x8C4099).toArray()\n case ContactType.CationPi:\n return tmpColor.setHex(0xFF8000).toArray()\n case ContactType.PiStacking:\n return tmpColor.setHex(0x8CB366).toArray()\n case ContactType.WeakHydrogenBond:\n return tmpColor.setHex(0xC5DDEC).toArray()\n default:\n return tmpColor.setHex(0xCCCCCC).toArray()\n }\n}\n\nexport interface ContactData {\n position1: Float32Array,\n position2: Float32Array,\n color: Float32Array,\n color2: Float32Array,\n radius: Float32Array,\n picking: ContactPicker\n}\n\nexport function getContactData (contacts: FrozenContacts, structure: Structure, params: ContactDataParams): ContactData {\n const p = createParams(params, ContactDataDefaultParams)\n const types: ContactType[] = []\n if (p.hydrogenBond) types.push(ContactType.HydrogenBond)\n if (p.hydrophobic) types.push(ContactType.Hydrophobic)\n if (p.halogenBond) types.push(ContactType.HalogenBond)\n if (p.ionicInteraction) types.push(ContactType.IonicInteraction)\n if (p.metalCoordination) types.push(ContactType.MetalCoordination)\n if (p.cationPi) types.push(ContactType.CationPi)\n if (p.piStacking) types.push(ContactType.PiStacking)\n if (p.weakHydrogenBond) types.push(ContactType.WeakHydrogenBond)\n if (p.waterHydrogenBond) types.push(ContactType.WaterHydrogenBond)\n if (p.backboneHydrogenBond) types.push(ContactType.BackboneHydrogenBond)\n\n const { features, contactSet, contactStore } = contacts\n const { centers, atomSets } = features\n const { x, y, z } = centers\n const { index1, index2, type } = contactStore\n\n const position1: number[] = []\n const position2: number[] = []\n const color: number[] = []\n const radius: number[] = []\n const picking: number[] = []\n\n let filterSet: BitArray | BitArray[] | undefined\n if (p.filterSele) {\n if (Array.isArray(p.filterSele)) {\n filterSet = p.filterSele.map(sele => {\n return structure.getAtomSet(new Selection(sele))\n })\n } else {\n filterSet = structure.getAtomSet(new Selection(p.filterSele))\n }\n }\n\n contactSet.forEach(i => {\n const ti = type[ i ]\n if (!types.includes(ti)) return\n\n if (filterSet) {\n const idx1 = atomSets[index1[i]][0]\n const idx2 = atomSets[index2[i]][0]\n\n if (Array.isArray(filterSet)) {\n if (!(filterSet[0].isSet(idx1) && filterSet[1].isSet(idx2) || (filterSet[1].isSet(idx1) && filterSet[0].isSet(idx2)))) return\n } else {\n if (!filterSet.isSet(idx1) && !filterSet.isSet(idx2)) return\n }\n }\n\n const k = index1[i]\n const l = index2[i]\n position1.push(x[k], y[k], z[k])\n position2.push(x[l], y[l], z[l])\n color.push(...contactColor(ti))\n radius.push(p.radius)\n picking.push(i)\n })\n\n return {\n position1: new Float32Array(position1),\n position2: new Float32Array(position2),\n color: new Float32Array(color),\n color2: new Float32Array(color),\n radius: new Float32Array(radius),\n picking: new ContactPicker(picking, contacts, structure)\n }\n}\n\nexport function getLabelData (contactData: ContactData, params: ContactLabelParams): TextBufferData {\n\n const position = calculateCenterArray(contactData.position1, contactData.position2)\n const text: string[] = []\n\n const direction = calculateDirectionArray(contactData.position1, contactData.position2)\n\n const n = direction.length / 3\n for (let i=0; i\n */\n\nimport { defaults } from '../../utils'\nimport Structure from '../../structure/structure'\nimport { Elements } from '../../structure/structure-constants'\nimport {\n Features, FeatureType,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\n\n/**\n * Hydrophobic carbon (only bonded to carbon or hydrogen); fluorine\n */\nexport function addHydrophobic (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n const state = createFeatureState(FeatureType.Hydrophobic)\n let flag = false\n if (a.number === Elements.C) {\n flag = true\n a.eachBondedAtom(ap => {\n const an = ap.number\n if (an !== Elements.C && an !== Elements.H) flag = false\n })\n } else if (a.number === Elements.F) {\n flag = true\n }\n if (flag) {\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\nfunction isHydrophobicContact (ti: FeatureType, tj: FeatureType) {\n return ti === FeatureType.Hydrophobic && tj === FeatureType.Hydrophobic\n}\n\nexport interface HydrophobicContactsParams {\n maxHydrophobicDist?: number\n masterModelIndex?: number\n}\n\n/**\n * All hydrophobic contacts\n */\nexport function addHydrophobicContacts (structure: Structure, contacts: Contacts, params: HydrophobicContactsParams = {}) {\n const maxHydrophobicDist = defaults(params.maxHydrophobicDist, ContactDefaultParams.maxHydrophobicDist)\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxHydrophobicDist, (j, dSq) => {\n if (j <= i) return\n\n ap1.index = atomSets[ i ][ 0 ]\n ap2.index = atomSets[ j ][ 0 ]\n\n if (invalidAtomContact(ap1, ap2, masterIdx)) return\n if (ap1.number === Elements.F && ap2.number === Elements.F) return\n if (ap1.connectedTo(ap2)) return\n\n if (isHydrophobicContact(types[ i ], types[ j ])) {\n featureSet.setBits(i, j)\n contactStore.addContact(i, j, ContactType.Hydrophobic)\n }\n })\n }\n}\n","/**\n * @file Picker\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { PickerRegistry } from '../globals'\nimport { calculateMeanVector3 } from '../math/vector-utils'\nimport Selection from '../selection/selection'\nimport {\n ArrowPrimitive, BoxPrimitive, ConePrimitive, CylinderPrimitive,\n EllipsoidPrimitive, OctahedronPrimitive, SpherePrimitive,\n TetrahedronPrimitive, TorusPrimitive, PointPrimitive, WidelinePrimitive\n} from '../geometry/primitive'\nimport { contactTypeName, Contacts } from '../chemistry/interactions/contact'\nimport { TypedArray } from '../types';\nimport Component from '../component/component';\nimport { Shape, Structure, Volume } from '../ngl';\nimport BondStore from '../store/bond-store';\nimport Validation from '../structure/validation';\nimport PrincipalAxes from '../math/principal-axes';\nimport Surface from '../surface/surface';\nimport Unitcell from '../symmetry/unitcell';\nimport BondProxy from '../proxy/bond-proxy';\nimport AtomProxy from '../proxy/atom-proxy';\n\n/**\n * Picker class\n * @interface\n */\nclass Picker {\n array: number[]|TypedArray|undefined\n /**\n * @param {Array|TypedArray} [array] - mapping\n */\n constructor (array?: number[]|TypedArray) {\n this.array = array\n }\n\n get type () { return '' }\n get data () { return {} }\n\n /**\n * Get the index for the given picking id\n * @param {Integer} pid - the picking id\n * @return {Integer} the index\n */\n getIndex (pid: number) {\n return this.array ? this.array[ pid ] : pid\n }\n\n /**\n * Get object data\n * @abstract\n * @param {Integer} pid - the picking id\n * @return {Object} the object data\n */\n getObject (pid: number) {\n return {}\n }\n\n _applyTransformations (vector: Vector3, instance: any, component: Component) {\n if (instance) {\n vector.applyMatrix4(instance.matrix)\n }\n if (component) {\n vector.applyMatrix4(component.matrix)\n }\n return vector\n }\n\n /**\n * Get object position\n * @abstract\n * @param {Integer} pid - the picking id\n * @return {Vector3} the object position\n */\n _getPosition (pid: number) {\n return new Vector3()\n }\n\n /**\n * Get position for the given picking id\n * @param {Integer} pid - the picking id\n * @param {Object} instance - the instance that should be applied\n * @param {Component} component - the component of the picked object\n * @return {Vector3} the position\n */\n getPosition (pid: number, instance: any, component: Component) {\n return this._applyTransformations(\n this._getPosition(pid), instance, component\n )\n }\n}\n\n/**\n * Shape picker class\n * @interface\n */\nclass ShapePicker extends Picker {\n shape: Shape\n /**\n * @param {Shape} shape - shape object\n */\n constructor (shape: Shape) {\n super()\n this.shape = shape\n }\n\n get primitive (): any { return }\n\n get data () { return this.shape }\n get type () { return this.primitive.type }\n\n getObject (pid: number) {\n return this.primitive.objectFromShape(this.shape, this.getIndex(pid))\n }\n\n _getPosition (pid: number) {\n return this.primitive.positionFromShape(this.shape, this.getIndex(pid))\n }\n}\n\n//\n\nclass CylinderPicker extends ShapePicker {\n get primitive () { return CylinderPrimitive }\n}\n\nclass ArrowPicker extends ShapePicker {\n get primitive () { return ArrowPrimitive }\n}\n\nclass AtomPicker extends Picker {\n structure: Structure\n constructor (array: Float32Array, structure: Structure) {\n super(array)\n this.structure = structure\n }\n\n get type () { return 'atom' }\n get data () { return this.structure }\n\n getObject (pid: number): AtomProxy {\n return this.structure.getAtomProxy(this.getIndex(pid))\n }\n\n _getPosition (pid: number) {\n return new Vector3().copy(this.getObject(pid) as any)\n }\n}\n\nclass AxesPicker extends Picker {\n axes: PrincipalAxes\n constructor (axes: PrincipalAxes) {\n super()\n this.axes = axes\n }\n\n get type () { return 'axes' }\n get data () { return this.axes }\n\n getObject (/* pid */) {\n return {\n axes: this.axes\n }\n }\n\n _getPosition (/* pid */) {\n return this.axes.center.clone()\n }\n}\n\nclass BondPicker extends Picker {\n structure: Structure\n bondStore: BondStore\n constructor (array: number[]|TypedArray|undefined, structure: Structure, bondStore?: BondStore) {\n super(array)\n this.structure = structure\n this.bondStore = bondStore || structure.bondStore\n }\n\n get type () { return 'bond' }\n get data () { return this.structure }\n\n getObject (pid: number): BondProxy {\n const bp = this.structure.getBondProxy(this.getIndex(pid))\n bp.bondStore = this.bondStore\n return bp\n }\n\n _getPosition (pid: number) {\n const b = this.getObject(pid)\n return new Vector3()\n .copy(b.atom1 as any)\n .add(b.atom2 as any)\n .multiplyScalar(0.5)\n }\n}\n\nclass ContactPicker extends Picker {\n contacts: Contacts\n structure: Structure\n constructor (array: number[]|TypedArray|undefined, contacts: Contacts, structure: Structure) {\n super(array)\n this.contacts = contacts\n this.structure = structure\n }\n\n get type () { return 'contact' }\n get data () { return this.contacts }\n\n getObject (pid: number) {\n const idx = this.getIndex(pid)\n const { features, contactStore } = this.contacts\n const { centers, atomSets } = features\n const { x, y, z } = centers\n const { index1, index2, type } = contactStore\n const k = index1[idx]\n const l = index2[idx]\n return {\n center1: new Vector3(x[k], y[k], z[k]),\n center2: new Vector3(x[l], y[l], z[l]),\n atom1: this.structure.getAtomProxy(atomSets[k][0]),\n atom2: this.structure.getAtomProxy(atomSets[l][0]),\n type: contactTypeName(type[idx])\n }\n }\n\n _getPosition (pid: number) {\n const { center1, center2 } = this.getObject(pid)\n return new Vector3().addVectors(center1, center2).multiplyScalar(0.5)\n }\n}\n\nclass ConePicker extends ShapePicker {\n get primitive () { return ConePrimitive }\n}\n\nclass ClashPicker extends Picker {\n validation: Validation\n structure: Structure\n constructor (array: number[]|TypedArray|undefined, validation: Validation, structure: Structure) {\n super(array)\n this.validation = validation\n this.structure = structure\n }\n\n get type () { return 'clash' }\n get data () { return this.validation }\n\n getObject (pid: number) {\n const val = this.validation\n const idx = this.getIndex(pid)\n return {\n validation: val,\n index: idx,\n clash: val.clashArray[ idx ]\n }\n }\n\n _getAtomProxyFromSele (sele: string) {\n const selection = new Selection(sele)\n const idx = this.structure.getAtomIndices(selection)![ 0 ]\n return this.structure.getAtomProxy(idx)\n }\n\n _getPosition (pid: number) {\n const clash = this.getObject(pid).clash\n const ap1 = this._getAtomProxyFromSele(clash.sele1)\n const ap2 = this._getAtomProxyFromSele(clash.sele2)\n return new Vector3().copy(ap1 as any).add(ap2 as any).multiplyScalar(0.5)\n }\n}\n\nclass DistancePicker extends BondPicker {\n get type () { return 'distance' }\n}\n\nclass EllipsoidPicker extends ShapePicker {\n get primitive () { return EllipsoidPrimitive }\n}\n\nclass OctahedronPicker extends ShapePicker {\n get primitive () { return OctahedronPrimitive }\n}\n\nclass BoxPicker extends ShapePicker {\n get primitive () { return BoxPrimitive }\n}\n\nclass IgnorePicker extends Picker {\n get type () { return 'ignore' }\n}\n\nexport interface MeshData {\n name: string|undefined\n serial: number\n index: Uint32Array|Uint16Array|number[]\n normal?: Float32Array|number[]\n position: Float32Array|number[]\n color: Float32Array|number[]\n}\nclass MeshPicker extends ShapePicker {\n mesh: MeshData\n __position: Vector3\n\n constructor (shape: Shape, mesh: MeshData) {\n super(shape)\n this.mesh = mesh\n }\n\n get type () { return 'mesh' }\n\n getObject (/* pid */) {\n const m = this.mesh\n return {\n shape: this.shape,\n name: m.name,\n serial: m.serial\n }\n }\n\n _getPosition (/* pid */) {\n if (!this.__position) {\n this.__position = calculateMeanVector3(this.mesh.position as any)\n }\n return this.__position\n }\n}\n\nclass SpherePicker extends ShapePicker {\n get primitive () { return SpherePrimitive }\n}\n\nclass SurfacePicker extends Picker {\n surface: Surface\n constructor (array: number[]|TypedArray|undefined, surface: Surface) {\n super(array)\n this.surface = surface\n }\n\n get type () { return 'surface' }\n get data () { return this.surface }\n\n getObject (pid: number) {\n return {\n surface: this.surface,\n index: this.getIndex(pid)\n }\n }\n\n _getPosition (/* pid */) {\n return this.surface.center.clone()\n }\n}\n\nclass TetrahedronPicker extends ShapePicker {\n get primitive () { return TetrahedronPrimitive }\n}\n\nclass TorusPicker extends ShapePicker {\n get primitive () { return TorusPrimitive }\n}\n\nclass UnitcellPicker extends Picker {\n unitcell: Unitcell\n structure: Structure\n\n constructor (unitcell: Unitcell, structure: Structure) {\n super()\n this.unitcell = unitcell\n this.structure = structure\n }\n\n get type () { return 'unitcell' }\n get data () { return this.unitcell }\n\n getObject (/* pid */) {\n return {\n unitcell: this.unitcell,\n structure: this.structure\n }\n }\n\n _getPosition (/* pid */) {\n return this.unitcell.getCenter(this.structure)\n }\n}\n\nclass UnknownPicker extends Picker {\n get type () { return 'unknown' }\n}\n\nclass VolumePicker extends Picker {\n volume: Volume\n constructor (array: TypedArray, volume: Volume) {\n super(array)\n this.volume = volume\n }\n\n get type () { return 'volume' }\n get data () { return this.volume }\n\n getObject (pid: number) {\n const vol = this.volume\n const idx = this.getIndex(pid)\n return {\n volume: vol,\n index: idx,\n value: vol.data[ idx ]\n }\n }\n\n _getPosition (pid: number) {\n const dp = this.volume.position\n const idx = this.getIndex(pid)\n return new Vector3(\n dp[ idx * 3 ],\n dp[ idx * 3 + 1 ],\n dp[ idx * 3 + 2 ]\n )\n }\n}\n\nclass SlicePicker extends VolumePicker {\n get type () { return 'slice' }\n}\n\nclass PointPicker extends ShapePicker {\n get primitive () { return PointPrimitive }\n}\n\nclass WidelinePicker extends ShapePicker {\n get primitive () { return WidelinePrimitive }\n}\n\nPickerRegistry.add('arrow', ArrowPicker)\nPickerRegistry.add('box', BoxPicker)\nPickerRegistry.add('cone', ConePicker)\nPickerRegistry.add('cylinder', CylinderPicker)\nPickerRegistry.add('ellipsoid', EllipsoidPicker)\nPickerRegistry.add('octahedron', OctahedronPicker)\nPickerRegistry.add('sphere', SpherePicker)\nPickerRegistry.add('tetrahedron', TetrahedronPicker)\nPickerRegistry.add('torus', TorusPicker)\nPickerRegistry.add('point', PointPicker)\nPickerRegistry.add('wideline', WidelinePicker)\n\nexport {\n Picker,\n ShapePicker,\n ArrowPicker,\n AtomPicker,\n AxesPicker,\n BondPicker,\n BoxPicker,\n ConePicker,\n ContactPicker,\n CylinderPicker,\n ClashPicker,\n DistancePicker,\n EllipsoidPicker,\n IgnorePicker,\n OctahedronPicker,\n MeshPicker,\n SlicePicker,\n SpherePicker,\n SurfacePicker,\n TetrahedronPicker,\n TorusPicker,\n UnitcellPicker,\n UnknownPicker,\n VolumePicker,\n PointPicker,\n WidelinePicker\n}\n","/**\n * @file Marching Cubes\n * @author Alexander Rose \n * @private\n */\n\nimport { getUintArray } from '../utils'\n\nfunction getEdgeTable () {\n return new Uint32Array([\n 0x0, 0x109, 0x203, 0x30a, 0x406, 0x50f, 0x605, 0x70c,\n 0x80c, 0x905, 0xa0f, 0xb06, 0xc0a, 0xd03, 0xe09, 0xf00,\n 0x190, 0x99, 0x393, 0x29a, 0x596, 0x49f, 0x795, 0x69c,\n 0x99c, 0x895, 0xb9f, 0xa96, 0xd9a, 0xc93, 0xf99, 0xe90,\n 0x230, 0x339, 0x33, 0x13a, 0x636, 0x73f, 0x435, 0x53c,\n 0xa3c, 0xb35, 0x83f, 0x936, 0xe3a, 0xf33, 0xc39, 0xd30,\n 0x3a0, 0x2a9, 0x1a3, 0xaa, 0x7a6, 0x6af, 0x5a5, 0x4ac,\n 0xbac, 0xaa5, 0x9af, 0x8a6, 0xfaa, 0xea3, 0xda9, 0xca0,\n 0x460, 0x569, 0x663, 0x76a, 0x66, 0x16f, 0x265, 0x36c,\n 0xc6c, 0xd65, 0xe6f, 0xf66, 0x86a, 0x963, 0xa69, 0xb60,\n 0x5f0, 0x4f9, 0x7f3, 0x6fa, 0x1f6, 0xff, 0x3f5, 0x2fc,\n 0xdfc, 0xcf5, 0xfff, 0xef6, 0x9fa, 0x8f3, 0xbf9, 0xaf0,\n 0x650, 0x759, 0x453, 0x55a, 0x256, 0x35f, 0x55, 0x15c,\n 0xe5c, 0xf55, 0xc5f, 0xd56, 0xa5a, 0xb53, 0x859, 0x950,\n 0x7c0, 0x6c9, 0x5c3, 0x4ca, 0x3c6, 0x2cf, 0x1c5, 0xcc,\n 0xfcc, 0xec5, 0xdcf, 0xcc6, 0xbca, 0xac3, 0x9c9, 0x8c0,\n 0x8c0, 0x9c9, 0xac3, 0xbca, 0xcc6, 0xdcf, 0xec5, 0xfcc,\n 0xcc, 0x1c5, 0x2cf, 0x3c6, 0x4ca, 0x5c3, 0x6c9, 0x7c0,\n 0x950, 0x859, 0xb53, 0xa5a, 0xd56, 0xc5f, 0xf55, 0xe5c,\n 0x15c, 0x55, 0x35f, 0x256, 0x55a, 0x453, 0x759, 0x650,\n 0xaf0, 0xbf9, 0x8f3, 0x9fa, 0xef6, 0xfff, 0xcf5, 0xdfc,\n 0x2fc, 0x3f5, 0xff, 0x1f6, 0x6fa, 0x7f3, 0x4f9, 0x5f0,\n 0xb60, 0xa69, 0x963, 0x86a, 0xf66, 0xe6f, 0xd65, 0xc6c,\n 0x36c, 0x265, 0x16f, 0x66, 0x76a, 0x663, 0x569, 0x460,\n 0xca0, 0xda9, 0xea3, 0xfaa, 0x8a6, 0x9af, 0xaa5, 0xbac,\n 0x4ac, 0x5a5, 0x6af, 0x7a6, 0xaa, 0x1a3, 0x2a9, 0x3a0,\n 0xd30, 0xc39, 0xf33, 0xe3a, 0x936, 0x83f, 0xb35, 0xa3c,\n 0x53c, 0x435, 0x73f, 0x636, 0x13a, 0x33, 0x339, 0x230,\n 0xe90, 0xf99, 0xc93, 0xd9a, 0xa96, 0xb9f, 0x895, 0x99c,\n 0x69c, 0x795, 0x49f, 0x596, 0x29a, 0x393, 0x99, 0x190,\n 0xf00, 0xe09, 0xd03, 0xc0a, 0xb06, 0xa0f, 0x905, 0x80c,\n 0x70c, 0x605, 0x50f, 0x406, 0x30a, 0x203, 0x109, 0x0\n ])\n}\n\nfunction getTriTable (): Int32Array {\n return new Int32Array([\n -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 8, 3, 9, 8, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 2, 10, 0, 2, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 8, 3, 2, 10, 8, 10, 9, 8, -1, -1, -1, -1, -1, -1, -1,\n 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 11, 2, 8, 11, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 9, 0, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 11, 2, 1, 9, 11, 9, 8, 11, -1, -1, -1, -1, -1, -1, -1,\n 3, 10, 1, 11, 10, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 10, 1, 0, 8, 10, 8, 11, 10, -1, -1, -1, -1, -1, -1, -1,\n 3, 9, 0, 3, 11, 9, 11, 10, 9, -1, -1, -1, -1, -1, -1, -1,\n 9, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 3, 0, 7, 3, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 9, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 1, 9, 4, 7, 1, 7, 3, 1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 4, 7, 3, 0, 4, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1,\n 9, 2, 10, 9, 0, 2, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1,\n 2, 10, 9, 2, 9, 7, 2, 7, 3, 7, 9, 4, -1, -1, -1, -1,\n 8, 4, 7, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 11, 4, 7, 11, 2, 4, 2, 0, 4, -1, -1, -1, -1, -1, -1, -1,\n 9, 0, 1, 8, 4, 7, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1,\n 4, 7, 11, 9, 4, 11, 9, 11, 2, 9, 2, 1, -1, -1, -1, -1,\n 3, 10, 1, 3, 11, 10, 7, 8, 4, -1, -1, -1, -1, -1, -1, -1,\n 1, 11, 10, 1, 4, 11, 1, 0, 4, 7, 11, 4, -1, -1, -1, -1,\n 4, 7, 8, 9, 0, 11, 9, 11, 10, 11, 0, 3, -1, -1, -1, -1,\n 4, 7, 11, 4, 11, 9, 9, 11, 10, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 4, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 5, 4, 1, 5, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 8, 5, 4, 8, 3, 5, 3, 1, 5, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 8, 1, 2, 10, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1,\n 5, 2, 10, 5, 4, 2, 4, 0, 2, -1, -1, -1, -1, -1, -1, -1,\n 2, 10, 5, 3, 2, 5, 3, 5, 4, 3, 4, 8, -1, -1, -1, -1,\n 9, 5, 4, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 11, 2, 0, 8, 11, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1,\n 0, 5, 4, 0, 1, 5, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1,\n 2, 1, 5, 2, 5, 8, 2, 8, 11, 4, 8, 5, -1, -1, -1, -1,\n 10, 3, 11, 10, 1, 3, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1,\n 4, 9, 5, 0, 8, 1, 8, 10, 1, 8, 11, 10, -1, -1, -1, -1,\n 5, 4, 0, 5, 0, 11, 5, 11, 10, 11, 0, 3, -1, -1, -1, -1,\n 5, 4, 8, 5, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1,\n 9, 7, 8, 5, 7, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 3, 0, 9, 5, 3, 5, 7, 3, -1, -1, -1, -1, -1, -1, -1,\n 0, 7, 8, 0, 1, 7, 1, 5, 7, -1, -1, -1, -1, -1, -1, -1,\n 1, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 7, 8, 9, 5, 7, 10, 1, 2, -1, -1, -1, -1, -1, -1, -1,\n 10, 1, 2, 9, 5, 0, 5, 3, 0, 5, 7, 3, -1, -1, -1, -1,\n 8, 0, 2, 8, 2, 5, 8, 5, 7, 10, 5, 2, -1, -1, -1, -1,\n 2, 10, 5, 2, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1,\n 7, 9, 5, 7, 8, 9, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 7, 9, 7, 2, 9, 2, 0, 2, 7, 11, -1, -1, -1, -1,\n 2, 3, 11, 0, 1, 8, 1, 7, 8, 1, 5, 7, -1, -1, -1, -1,\n 11, 2, 1, 11, 1, 7, 7, 1, 5, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 8, 8, 5, 7, 10, 1, 3, 10, 3, 11, -1, -1, -1, -1,\n 5, 7, 0, 5, 0, 9, 7, 11, 0, 1, 0, 10, 11, 10, 0, -1,\n 11, 10, 0, 11, 0, 3, 10, 5, 0, 8, 0, 7, 5, 7, 0, -1,\n 11, 10, 5, 7, 11, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 0, 1, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 8, 3, 1, 9, 8, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1,\n 1, 6, 5, 2, 6, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 6, 5, 1, 2, 6, 3, 0, 8, -1, -1, -1, -1, -1, -1, -1,\n 9, 6, 5, 9, 0, 6, 0, 2, 6, -1, -1, -1, -1, -1, -1, -1,\n 5, 9, 8, 5, 8, 2, 5, 2, 6, 3, 2, 8, -1, -1, -1, -1,\n 2, 3, 11, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 11, 0, 8, 11, 2, 0, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 9, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1,\n 5, 10, 6, 1, 9, 2, 9, 11, 2, 9, 8, 11, -1, -1, -1, -1,\n 6, 3, 11, 6, 5, 3, 5, 1, 3, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 11, 0, 11, 5, 0, 5, 1, 5, 11, 6, -1, -1, -1, -1,\n 3, 11, 6, 0, 3, 6, 0, 6, 5, 0, 5, 9, -1, -1, -1, -1,\n 6, 5, 9, 6, 9, 11, 11, 9, 8, -1, -1, -1, -1, -1, -1, -1,\n 5, 10, 6, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 3, 0, 4, 7, 3, 6, 5, 10, -1, -1, -1, -1, -1, -1, -1,\n 1, 9, 0, 5, 10, 6, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1,\n 10, 6, 5, 1, 9, 7, 1, 7, 3, 7, 9, 4, -1, -1, -1, -1,\n 6, 1, 2, 6, 5, 1, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 5, 5, 2, 6, 3, 0, 4, 3, 4, 7, -1, -1, -1, -1,\n 8, 4, 7, 9, 0, 5, 0, 6, 5, 0, 2, 6, -1, -1, -1, -1,\n 7, 3, 9, 7, 9, 4, 3, 2, 9, 5, 9, 6, 2, 6, 9, -1,\n 3, 11, 2, 7, 8, 4, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1,\n 5, 10, 6, 4, 7, 2, 4, 2, 0, 2, 7, 11, -1, -1, -1, -1,\n 0, 1, 9, 4, 7, 8, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1,\n 9, 2, 1, 9, 11, 2, 9, 4, 11, 7, 11, 4, 5, 10, 6, -1,\n 8, 4, 7, 3, 11, 5, 3, 5, 1, 5, 11, 6, -1, -1, -1, -1,\n 5, 1, 11, 5, 11, 6, 1, 0, 11, 7, 11, 4, 0, 4, 11, -1,\n 0, 5, 9, 0, 6, 5, 0, 3, 6, 11, 6, 3, 8, 4, 7, -1,\n 6, 5, 9, 6, 9, 11, 4, 7, 9, 7, 11, 9, -1, -1, -1, -1,\n 10, 4, 9, 6, 4, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 10, 6, 4, 9, 10, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1,\n 10, 0, 1, 10, 6, 0, 6, 4, 0, -1, -1, -1, -1, -1, -1, -1,\n 8, 3, 1, 8, 1, 6, 8, 6, 4, 6, 1, 10, -1, -1, -1, -1,\n 1, 4, 9, 1, 2, 4, 2, 6, 4, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 8, 1, 2, 9, 2, 4, 9, 2, 6, 4, -1, -1, -1, -1,\n 0, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 8, 3, 2, 8, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1,\n 10, 4, 9, 10, 6, 4, 11, 2, 3, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 2, 2, 8, 11, 4, 9, 10, 4, 10, 6, -1, -1, -1, -1,\n 3, 11, 2, 0, 1, 6, 0, 6, 4, 6, 1, 10, -1, -1, -1, -1,\n 6, 4, 1, 6, 1, 10, 4, 8, 1, 2, 1, 11, 8, 11, 1, -1,\n 9, 6, 4, 9, 3, 6, 9, 1, 3, 11, 6, 3, -1, -1, -1, -1,\n 8, 11, 1, 8, 1, 0, 11, 6, 1, 9, 1, 4, 6, 4, 1, -1,\n 3, 11, 6, 3, 6, 0, 0, 6, 4, -1, -1, -1, -1, -1, -1, -1,\n 6, 4, 8, 11, 6, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 7, 10, 6, 7, 8, 10, 8, 9, 10, -1, -1, -1, -1, -1, -1, -1,\n 0, 7, 3, 0, 10, 7, 0, 9, 10, 6, 7, 10, -1, -1, -1, -1,\n 10, 6, 7, 1, 10, 7, 1, 7, 8, 1, 8, 0, -1, -1, -1, -1,\n 10, 6, 7, 10, 7, 1, 1, 7, 3, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 6, 1, 6, 8, 1, 8, 9, 8, 6, 7, -1, -1, -1, -1,\n 2, 6, 9, 2, 9, 1, 6, 7, 9, 0, 9, 3, 7, 3, 9, -1,\n 7, 8, 0, 7, 0, 6, 6, 0, 2, -1, -1, -1, -1, -1, -1, -1,\n 7, 3, 2, 6, 7, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 3, 11, 10, 6, 8, 10, 8, 9, 8, 6, 7, -1, -1, -1, -1,\n 2, 0, 7, 2, 7, 11, 0, 9, 7, 6, 7, 10, 9, 10, 7, -1,\n 1, 8, 0, 1, 7, 8, 1, 10, 7, 6, 7, 10, 2, 3, 11, -1,\n 11, 2, 1, 11, 1, 7, 10, 6, 1, 6, 7, 1, -1, -1, -1, -1,\n 8, 9, 6, 8, 6, 7, 9, 1, 6, 11, 6, 3, 1, 3, 6, -1,\n 0, 9, 1, 11, 6, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 7, 8, 0, 7, 0, 6, 3, 11, 0, 11, 6, 0, -1, -1, -1, -1,\n 7, 11, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 8, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 9, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 8, 1, 9, 8, 3, 1, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1,\n 10, 1, 2, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 3, 0, 8, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1,\n 2, 9, 0, 2, 10, 9, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1,\n 6, 11, 7, 2, 10, 3, 10, 8, 3, 10, 9, 8, -1, -1, -1, -1,\n 7, 2, 3, 6, 2, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 7, 0, 8, 7, 6, 0, 6, 2, 0, -1, -1, -1, -1, -1, -1, -1,\n 2, 7, 6, 2, 3, 7, 0, 1, 9, -1, -1, -1, -1, -1, -1, -1,\n 1, 6, 2, 1, 8, 6, 1, 9, 8, 8, 7, 6, -1, -1, -1, -1,\n 10, 7, 6, 10, 1, 7, 1, 3, 7, -1, -1, -1, -1, -1, -1, -1,\n 10, 7, 6, 1, 7, 10, 1, 8, 7, 1, 0, 8, -1, -1, -1, -1,\n 0, 3, 7, 0, 7, 10, 0, 10, 9, 6, 10, 7, -1, -1, -1, -1,\n 7, 6, 10, 7, 10, 8, 8, 10, 9, -1, -1, -1, -1, -1, -1, -1,\n 6, 8, 4, 11, 8, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 6, 11, 3, 0, 6, 0, 4, 6, -1, -1, -1, -1, -1, -1, -1,\n 8, 6, 11, 8, 4, 6, 9, 0, 1, -1, -1, -1, -1, -1, -1, -1,\n 9, 4, 6, 9, 6, 3, 9, 3, 1, 11, 3, 6, -1, -1, -1, -1,\n 6, 8, 4, 6, 11, 8, 2, 10, 1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 3, 0, 11, 0, 6, 11, 0, 4, 6, -1, -1, -1, -1,\n 4, 11, 8, 4, 6, 11, 0, 2, 9, 2, 10, 9, -1, -1, -1, -1,\n 10, 9, 3, 10, 3, 2, 9, 4, 3, 11, 3, 6, 4, 6, 3, -1,\n 8, 2, 3, 8, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1,\n 0, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 9, 0, 2, 3, 4, 2, 4, 6, 4, 3, 8, -1, -1, -1, -1,\n 1, 9, 4, 1, 4, 2, 2, 4, 6, -1, -1, -1, -1, -1, -1, -1,\n 8, 1, 3, 8, 6, 1, 8, 4, 6, 6, 10, 1, -1, -1, -1, -1,\n 10, 1, 0, 10, 0, 6, 6, 0, 4, -1, -1, -1, -1, -1, -1, -1,\n 4, 6, 3, 4, 3, 8, 6, 10, 3, 0, 3, 9, 10, 9, 3, -1,\n 10, 9, 4, 6, 10, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 9, 5, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 4, 9, 5, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1,\n 5, 0, 1, 5, 4, 0, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1,\n 11, 7, 6, 8, 3, 4, 3, 5, 4, 3, 1, 5, -1, -1, -1, -1,\n 9, 5, 4, 10, 1, 2, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1,\n 6, 11, 7, 1, 2, 10, 0, 8, 3, 4, 9, 5, -1, -1, -1, -1,\n 7, 6, 11, 5, 4, 10, 4, 2, 10, 4, 0, 2, -1, -1, -1, -1,\n 3, 4, 8, 3, 5, 4, 3, 2, 5, 10, 5, 2, 11, 7, 6, -1,\n 7, 2, 3, 7, 6, 2, 5, 4, 9, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 4, 0, 8, 6, 0, 6, 2, 6, 8, 7, -1, -1, -1, -1,\n 3, 6, 2, 3, 7, 6, 1, 5, 0, 5, 4, 0, -1, -1, -1, -1,\n 6, 2, 8, 6, 8, 7, 2, 1, 8, 4, 8, 5, 1, 5, 8, -1,\n 9, 5, 4, 10, 1, 6, 1, 7, 6, 1, 3, 7, -1, -1, -1, -1,\n 1, 6, 10, 1, 7, 6, 1, 0, 7, 8, 7, 0, 9, 5, 4, -1,\n 4, 0, 10, 4, 10, 5, 0, 3, 10, 6, 10, 7, 3, 7, 10, -1,\n 7, 6, 10, 7, 10, 8, 5, 4, 10, 4, 8, 10, -1, -1, -1, -1,\n 6, 9, 5, 6, 11, 9, 11, 8, 9, -1, -1, -1, -1, -1, -1, -1,\n 3, 6, 11, 0, 6, 3, 0, 5, 6, 0, 9, 5, -1, -1, -1, -1,\n 0, 11, 8, 0, 5, 11, 0, 1, 5, 5, 6, 11, -1, -1, -1, -1,\n 6, 11, 3, 6, 3, 5, 5, 3, 1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 9, 5, 11, 9, 11, 8, 11, 5, 6, -1, -1, -1, -1,\n 0, 11, 3, 0, 6, 11, 0, 9, 6, 5, 6, 9, 1, 2, 10, -1,\n 11, 8, 5, 11, 5, 6, 8, 0, 5, 10, 5, 2, 0, 2, 5, -1,\n 6, 11, 3, 6, 3, 5, 2, 10, 3, 10, 5, 3, -1, -1, -1, -1,\n 5, 8, 9, 5, 2, 8, 5, 6, 2, 3, 8, 2, -1, -1, -1, -1,\n 9, 5, 6, 9, 6, 0, 0, 6, 2, -1, -1, -1, -1, -1, -1, -1,\n 1, 5, 8, 1, 8, 0, 5, 6, 8, 3, 8, 2, 6, 2, 8, -1,\n 1, 5, 6, 2, 1, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 3, 6, 1, 6, 10, 3, 8, 6, 5, 6, 9, 8, 9, 6, -1,\n 10, 1, 0, 10, 0, 6, 9, 5, 0, 5, 6, 0, -1, -1, -1, -1,\n 0, 3, 8, 5, 6, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 10, 5, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 11, 5, 10, 7, 5, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 11, 5, 10, 11, 7, 5, 8, 3, 0, -1, -1, -1, -1, -1, -1, -1,\n 5, 11, 7, 5, 10, 11, 1, 9, 0, -1, -1, -1, -1, -1, -1, -1,\n 10, 7, 5, 10, 11, 7, 9, 8, 1, 8, 3, 1, -1, -1, -1, -1,\n 11, 1, 2, 11, 7, 1, 7, 5, 1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 1, 2, 7, 1, 7, 5, 7, 2, 11, -1, -1, -1, -1,\n 9, 7, 5, 9, 2, 7, 9, 0, 2, 2, 11, 7, -1, -1, -1, -1,\n 7, 5, 2, 7, 2, 11, 5, 9, 2, 3, 2, 8, 9, 8, 2, -1,\n 2, 5, 10, 2, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1,\n 8, 2, 0, 8, 5, 2, 8, 7, 5, 10, 2, 5, -1, -1, -1, -1,\n 9, 0, 1, 5, 10, 3, 5, 3, 7, 3, 10, 2, -1, -1, -1, -1,\n 9, 8, 2, 9, 2, 1, 8, 7, 2, 10, 2, 5, 7, 5, 2, -1,\n 1, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 7, 0, 7, 1, 1, 7, 5, -1, -1, -1, -1, -1, -1, -1,\n 9, 0, 3, 9, 3, 5, 5, 3, 7, -1, -1, -1, -1, -1, -1, -1,\n 9, 8, 7, 5, 9, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 5, 8, 4, 5, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1,\n 5, 0, 4, 5, 11, 0, 5, 10, 11, 11, 3, 0, -1, -1, -1, -1,\n 0, 1, 9, 8, 4, 10, 8, 10, 11, 10, 4, 5, -1, -1, -1, -1,\n 10, 11, 4, 10, 4, 5, 11, 3, 4, 9, 4, 1, 3, 1, 4, -1,\n 2, 5, 1, 2, 8, 5, 2, 11, 8, 4, 5, 8, -1, -1, -1, -1,\n 0, 4, 11, 0, 11, 3, 4, 5, 11, 2, 11, 1, 5, 1, 11, -1,\n 0, 2, 5, 0, 5, 9, 2, 11, 5, 4, 5, 8, 11, 8, 5, -1,\n 9, 4, 5, 2, 11, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 5, 10, 3, 5, 2, 3, 4, 5, 3, 8, 4, -1, -1, -1, -1,\n 5, 10, 2, 5, 2, 4, 4, 2, 0, -1, -1, -1, -1, -1, -1, -1,\n 3, 10, 2, 3, 5, 10, 3, 8, 5, 4, 5, 8, 0, 1, 9, -1,\n 5, 10, 2, 5, 2, 4, 1, 9, 2, 9, 4, 2, -1, -1, -1, -1,\n 8, 4, 5, 8, 5, 3, 3, 5, 1, -1, -1, -1, -1, -1, -1, -1,\n 0, 4, 5, 1, 0, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 8, 4, 5, 8, 5, 3, 9, 0, 5, 0, 3, 5, -1, -1, -1, -1,\n 9, 4, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 11, 7, 4, 9, 11, 9, 10, 11, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 4, 9, 7, 9, 11, 7, 9, 10, 11, -1, -1, -1, -1,\n 1, 10, 11, 1, 11, 4, 1, 4, 0, 7, 4, 11, -1, -1, -1, -1,\n 3, 1, 4, 3, 4, 8, 1, 10, 4, 7, 4, 11, 10, 11, 4, -1,\n 4, 11, 7, 9, 11, 4, 9, 2, 11, 9, 1, 2, -1, -1, -1, -1,\n 9, 7, 4, 9, 11, 7, 9, 1, 11, 2, 11, 1, 0, 8, 3, -1,\n 11, 7, 4, 11, 4, 2, 2, 4, 0, -1, -1, -1, -1, -1, -1, -1,\n 11, 7, 4, 11, 4, 2, 8, 3, 4, 3, 2, 4, -1, -1, -1, -1,\n 2, 9, 10, 2, 7, 9, 2, 3, 7, 7, 4, 9, -1, -1, -1, -1,\n 9, 10, 7, 9, 7, 4, 10, 2, 7, 8, 7, 0, 2, 0, 7, -1,\n 3, 7, 10, 3, 10, 2, 7, 4, 10, 1, 10, 0, 4, 0, 10, -1,\n 1, 10, 2, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 9, 1, 4, 1, 7, 7, 1, 3, -1, -1, -1, -1, -1, -1, -1,\n 4, 9, 1, 4, 1, 7, 0, 8, 1, 8, 7, 1, -1, -1, -1, -1,\n 4, 0, 3, 7, 4, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 8, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 9, 3, 9, 11, 11, 9, 10, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 10, 0, 10, 8, 8, 10, 11, -1, -1, -1, -1, -1, -1, -1,\n 3, 1, 10, 11, 3, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 11, 1, 11, 9, 9, 11, 8, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 9, 3, 9, 11, 1, 2, 9, 2, 11, 9, -1, -1, -1, -1,\n 0, 2, 11, 8, 0, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 2, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 3, 8, 2, 8, 10, 10, 8, 9, -1, -1, -1, -1, -1, -1, -1,\n 9, 10, 2, 0, 9, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 3, 8, 2, 8, 10, 0, 1, 8, 1, 10, 8, -1, -1, -1, -1,\n 1, 10, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 3, 8, 9, 1, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 9, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 3, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1\n ])\n}\n\ninterface MarchingCubes {\n new (field: number[], nx: number, ny: number, nz: number, atomindex: number[]): void\n triangulate: (_isolevel: number, _noNormals: boolean, _box: number[][]|undefined, _contour: boolean, _wrap: boolean) => {\n position: Float32Array\n normal: undefined|Float32Array\n index: Uint32Array|Uint16Array\n atomindex: Int32Array|undefined\n contour: boolean\n }\n}\nfunction MarchingCubes (this: MarchingCubes, field: number[], nx: number, ny: number, nz: number, atomindex: number[]) {\n // Based on alteredq / http://alteredqualia.com/\n // port of greggman's ThreeD version of marching cubes to Three.js\n // http://webglsamples.googlecode.com/hg/blob/blob.html\n //\n // Adapted for NGL by Alexander Rose\n\n // Triangles are constructed between points on cube edges.\n // allowedContours[edge1][edge1] indicates which lines from a given\n // triangle should be shown in line mode.\n\n // Values are bitmasks:\n // In loop over cubes we keep another bitmask indicating whether our current\n // cell is the first x-value (1),\n // first y-value (2) or first z-value (4) of the current loop.\n // We draw all lines on leading faces but only draw trailing face lines the first\n // time through the loop\n // A value of 8 below means the edge is always drawn (leading face)\n\n // E.g. the first row, lines between edge0 and other edges in the bottom\n // x-y plane are only drawn for the first value of z, edges in the\n // x-z plane are only drawn for the first value of y. No other lines\n // are drawn as they're redundant\n // The line between edge 1 and 5 is always drawn as it's on the leading edge\n var allowedContours = [\n\n [ 0, 4, 4, 4, 2, 0, 0, 0, 2, 2, 0, 0 ], // 1 2 3 4 8 9\n [ 4, 0, 4, 4, 0, 8, 0, 0, 0, 8, 8, 0 ], // 0 2 3 5 9 10\n [ 4, 4, 0, 4, 0, 0, 8, 0, 0, 0, 8, 8 ], // 0 1 3 6 10 11\n [ 4, 4, 4, 0, 0, 0, 0, 1, 1, 0, 0, 1 ], // 0 1 2 7 8 11\n [ 2, 0, 0, 0, 0, 8, 8, 8, 2, 2, 0, 0 ], // 0 5 6 7 8 9\n [ 0, 8, 0, 0, 8, 0, 8, 8, 0, 8, 8, 0 ], // And rotate it\n [ 0, 0, 8, 0, 8, 8, 0, 8, 0, 0, 8, 8 ],\n [ 0, 0, 0, 1, 8, 8, 8, 0, 1, 0, 0, 1 ],\n [ 2, 0, 0, 1, 2, 0, 0, 1, 0, 2, 0, 1 ], // 0 3 4 7 9 11\n [ 2, 8, 0, 0, 2, 8, 0, 0, 2, 0, 8, 0 ], // And rotate some more\n [ 0, 8, 8, 0, 0, 8, 8, 0, 0, 8, 0, 8 ],\n [ 0, 0, 8, 1, 0, 0, 8, 1, 1, 0, 8, 0 ]\n\n ]\n\n var isolevel = 0\n var noNormals = false\n var contour = false\n var wrap = false\n var isNegativeIso = false\n var normalFactor = -1\n\n\n var n = nx * ny * nz\n\n // deltas\n var yd = nx\n var zd = nx * ny\n\n var normalCache: Float32Array, vertexIndex: Int32Array\n var count: number, icount: number\n\n var ilist = new Int32Array(12)\n\n var positionArray: number[] = []\n var normalArray: number[] = []\n var indexArray: number[] = []\n var atomindexArray: number[] = []\n\n var edgeTable = getEdgeTable()\n var triTable = getTriTable()\n\n var mx: number, my: number, mz: number\n\n //\n\n this.triangulate = function (_isolevel: number, _noNormals: boolean, _box: number[][]|undefined, _contour: boolean, _wrap: boolean) {\n isolevel = _isolevel\n isNegativeIso = isolevel < 0.0\n contour = _contour\n wrap = _wrap\n // Normals currently disabled in contour mode for performance (unused)\n noNormals = _noNormals || contour\n\n if (!noNormals) {\n normalFactor = isolevel > 0 ? -1.0 : 1.0\n if (!normalCache) {\n normalCache = new Float32Array(n * 3)\n } \n }\n\n var vIndexLength = n * 3\n\n if (!vertexIndex || vertexIndex.length !== vIndexLength) {\n vertexIndex = new Int32Array(vIndexLength)\n }\n\n count = 0\n icount = 0\n\n if (_box !== undefined) {\n var min = _box[ 0 ].map(Math.round)\n var max = _box[ 1 ].map(Math.round)\n\n mx = nx * Math.ceil(Math.abs(min[ 0 ]) / nx)\n my = ny * Math.ceil(Math.abs(min[ 1 ]) / ny)\n mz = nz * Math.ceil(Math.abs(min[ 2 ]) / nz)\n\n triangulate(\n min[ 0 ], min[ 1 ], min[ 2 ],\n max[ 0 ], max[ 1 ], max[ 2 ]\n )\n } else {\n mx = my = mz = 0\n\n triangulate()\n }\n\n positionArray.length = count * 3\n if (!noNormals) normalArray.length = count * 3\n indexArray.length = icount\n if (atomindex) atomindexArray.length = count\n\n return {\n position: new Float32Array(positionArray),\n normal: noNormals ? undefined : new Float32Array(normalArray),\n index: getUintArray(indexArray, positionArray.length / 3),\n atomindex: atomindex ? new Int32Array(atomindexArray) : undefined,\n contour: contour\n }\n }\n\n // polygonization\n\n function lerp (a: number, b: number, t: number) { return a + (b - a) * t }\n\n function index (x: number, y: number, z: number) {\n x = (x + mx) % nx\n y = (y + my) % ny\n z = (z + mz) % nz\n return ((zd * z) + yd * y) + x\n }\n\n function VIntX (q: number, offset: number, x: number, y: number, z: number, valp1: number, valp2: number) {\n var _q = 3 * q\n\n if (vertexIndex[ _q ] < 0) {\n var mu = (isolevel - valp1) / (valp2 - valp1)\n var nc = normalCache\n\n var c = count * 3\n\n positionArray[ c ] = x + mu\n positionArray[ c + 1 ] = y\n positionArray[ c + 2 ] = z\n\n if (!noNormals) {\n var q3 = q * 3\n\n normalArray[ c ] = normalFactor * lerp(nc[ q3 ], nc[ q3 + 3 ], mu)\n normalArray[ c + 1 ] = normalFactor * lerp(nc[ q3 + 1 ], nc[ q3 + 4 ], mu)\n normalArray[ c + 2 ] = normalFactor * lerp(nc[ q3 + 2 ], nc[ q3 + 5 ], mu)\n }\n\n if (atomindex) atomindexArray[ count ] = atomindex[ q + Math.round(mu) ]\n\n vertexIndex[ _q ] = count\n ilist[ offset ] = count\n\n count += 1\n } else {\n ilist[ offset ] = vertexIndex[ _q ]\n }\n }\n\n function VIntY (q: number, offset: number, x: number, y: number, z: number, valp1: number, valp2: number) {\n var _q = 3 * q + 1\n\n if (vertexIndex[ _q ] < 0) {\n var mu = (isolevel - valp1) / (valp2 - valp1)\n var nc = normalCache\n\n var c = count * 3\n\n positionArray[ c ] = x\n positionArray[ c + 1 ] = y + mu\n positionArray[ c + 2 ] = z\n\n if (!noNormals) {\n var q3 = q * 3\n var q6 = q3 + yd * 3\n\n normalArray[ c ] = normalFactor * lerp(nc[ q3 ], nc[ q6 ], mu)\n normalArray[ c + 1 ] = normalFactor * lerp(nc[ q3 + 1 ], nc[ q6 + 1 ], mu)\n normalArray[ c + 2 ] = normalFactor * lerp(nc[ q3 + 2 ], nc[ q6 + 2 ], mu)\n }\n\n if (atomindex) atomindexArray[ count ] = atomindex[ q + Math.round(mu) * yd ]\n\n vertexIndex[ _q ] = count\n ilist[ offset ] = count\n\n count += 1\n } else {\n ilist[ offset ] = vertexIndex[ _q ]\n }\n }\n\n function VIntZ (q: number, offset: number, x: number, y: number, z: number, valp1: number, valp2: number) {\n var _q = 3 * q + 2\n\n if (vertexIndex[ _q ] < 0) {\n var mu = (isolevel - valp1) / (valp2 - valp1)\n var nc = normalCache\n\n var c = count * 3\n\n positionArray[ c ] = x\n positionArray[ c + 1 ] = y\n positionArray[ c + 2 ] = z + mu\n\n if (!noNormals) {\n var q3 = q * 3\n var q6 = q3 + zd * 3\n\n normalArray[ c ] = normalFactor * lerp(nc[ q3 ], nc[ q6 ], mu)\n normalArray[ c + 1 ] = normalFactor * lerp(nc[ q3 + 1 ], nc[ q6 + 1 ], mu)\n normalArray[ c + 2 ] = normalFactor * lerp(nc[ q3 + 2 ], nc[ q6 + 2 ], mu)\n }\n\n if (atomindex) atomindexArray[ count ] = atomindex[ q + Math.round(mu) * zd ]\n\n vertexIndex[ _q ] = count\n ilist[ offset ] = count\n\n count += 1\n } else {\n ilist[ offset ] = vertexIndex[ _q ]\n }\n }\n\n function compNorm (q: number) {\n var q3 = q * 3\n\n if (normalCache[ q3 ] === 0.0) {\n normalCache[ q3 ] = field[ (q - 1 + n) % n ] - field[ (q + 1) % n ]\n normalCache[ q3 + 1 ] = field[ (q - yd + n) % n ] - field[ (q + yd) % n ]\n normalCache[ q3 + 2 ] = field[ (q - zd + n) % n ] - field[ (q + zd) % n ]\n }\n }\n\n function polygonize (fx: number, fy: number, fz: number, q: number, edgeFilter: number) {\n // cache indices\n var q1\n var qy\n var qz\n var q1y\n var q1z\n var qyz\n var q1yz\n if (wrap) {\n q = index(fx, fy, fz)\n q1 = index(fx + 1, fy, fz)\n qy = index(fx, fy + 1, fz)\n qz = index(fx, fy, fz + 1)\n q1y = index(fx + 1, fy + 1, fz)\n q1z = index(fx + 1, fy, fz + 1)\n qyz = index(fx, fy + 1, fz + 1)\n q1yz = index(fx + 1, fy + 1, fz + 1)\n } else {\n q1 = q + 1\n qy = q + yd\n qz = q + zd\n q1y = qy + 1\n q1z = qz + 1\n qyz = qy + zd\n q1yz = qyz + 1\n }\n\n var cubeindex = 0\n var field0 = field[ q ]\n var field1 = field[ q1 ]\n var field2 = field[ qy ]\n var field3 = field[ q1y ]\n var field4 = field[ qz ]\n var field5 = field[ q1z ]\n var field6 = field[ qyz ]\n var field7 = field[ q1yz ]\n\n if (field0 < isolevel) cubeindex |= 1\n if (field1 < isolevel) cubeindex |= 2\n if (field2 < isolevel) cubeindex |= 8\n if (field3 < isolevel) cubeindex |= 4\n if (field4 < isolevel) cubeindex |= 16\n if (field5 < isolevel) cubeindex |= 32\n if (field6 < isolevel) cubeindex |= 128\n if (field7 < isolevel) cubeindex |= 64\n\n // if cube is entirely in/out of the surface - bail, nothing to draw\n\n var bits = edgeTable[ cubeindex ]\n if (bits === 0) return 0\n\n var fx2 = fx + 1\n var fy2 = fy + 1\n var fz2 = fz + 1\n\n // top of the cube\n\n if (bits & 1) {\n if (!noNormals) {\n compNorm(q)\n compNorm(q1)\n }\n VIntX(q, 0, fx, fy, fz, field0, field1)\n }\n\n if (bits & 2) {\n if (!noNormals) {\n compNorm(q1)\n compNorm(q1y)\n }\n VIntY(q1, 1, fx2, fy, fz, field1, field3)\n }\n\n if (bits & 4) {\n if (!noNormals) {\n compNorm(qy)\n compNorm(q1y)\n }\n VIntX(qy, 2, fx, fy2, fz, field2, field3)\n }\n\n if (bits & 8) {\n if (!noNormals) {\n compNorm(q)\n compNorm(qy)\n }\n VIntY(q, 3, fx, fy, fz, field0, field2)\n }\n\n // bottom of the cube\n\n if (bits & 16) {\n if (!noNormals) {\n compNorm(qz)\n compNorm(q1z)\n }\n VIntX(qz, 4, fx, fy, fz2, field4, field5)\n }\n\n if (bits & 32) {\n if (!noNormals) {\n compNorm(q1z)\n compNorm(q1yz)\n }\n VIntY(q1z, 5, fx2, fy, fz2, field5, field7)\n }\n\n if (bits & 64) {\n if (!noNormals) {\n compNorm(qyz)\n compNorm(q1yz)\n }\n VIntX(qyz, 6, fx, fy2, fz2, field6, field7)\n }\n\n if (bits & 128) {\n if (!noNormals) {\n compNorm(qz)\n compNorm(qyz)\n }\n VIntY(qz, 7, fx, fy, fz2, field4, field6)\n }\n\n // vertical lines of the cube\n\n if (bits & 256) {\n if (!noNormals) {\n compNorm(q)\n compNorm(qz)\n }\n VIntZ(q, 8, fx, fy, fz, field0, field4)\n }\n\n if (bits & 512) {\n if (!noNormals) {\n compNorm(q1)\n compNorm(q1z)\n }\n VIntZ(q1, 9, fx2, fy, fz, field1, field5)\n }\n\n if (bits & 1024) {\n if (!noNormals) {\n compNorm(q1y)\n compNorm(q1yz)\n }\n VIntZ(q1y, 10, fx2, fy2, fz, field3, field7)\n }\n\n if (bits & 2048) {\n if (!noNormals) {\n compNorm(qy)\n compNorm(qyz)\n }\n VIntZ(qy, 11, fx, fy2, fz, field2, field6)\n }\n\n var triIndex = cubeindex << 4 // re-purpose cubeindex into an offset into triTable\n\n var e1\n var e2\n var e3\n var i = 0\n\n // here is where triangles are created\n\n while (triTable[ triIndex + i ] !== -1) {\n e1 = triTable[ triIndex + i ]\n e2 = triTable[ triIndex + i + 1 ]\n e3 = triTable[ triIndex + i + 2 ]\n\n if (contour) {\n if (allowedContours[ e1 ][ e2 ] & edgeFilter) {\n indexArray[ icount++ ] = ilist[ e1 ]\n indexArray[ icount++ ] = ilist[ e2 ]\n }\n if (allowedContours[ e2 ][ e3 ] & edgeFilter) {\n indexArray[ icount++ ] = ilist[ e2 ]\n indexArray[ icount++ ] = ilist[ e3 ]\n }\n if (allowedContours[ e1 ][ e3 ] & edgeFilter) {\n indexArray[ icount++ ] = ilist[ e1 ]\n indexArray[ icount++ ] = ilist[ e3 ]\n }\n } else {\n indexArray[ icount++ ] = ilist[ isNegativeIso ? e1 : e2 ]\n indexArray[ icount++ ] = ilist[ isNegativeIso ? e2 : e1 ]\n indexArray[ icount++ ] = ilist[ e3 ]\n }\n\n i += 3\n }\n }\n\n function triangulate (xBeg?: number, yBeg?: number, zBeg?: number, xEnd?: number, yEnd?: number, zEnd?: number) {\n let q\n let q3\n let x\n let y\n let z\n let yOffset\n let zOffset\n\n xBeg = xBeg !== undefined ? xBeg : 0\n yBeg = yBeg !== undefined ? yBeg : 0\n zBeg = zBeg !== undefined ? zBeg : 0\n\n xEnd = xEnd !== undefined ? xEnd : nx - 1\n yEnd = yEnd !== undefined ? yEnd : ny - 1\n zEnd = zEnd !== undefined ? zEnd : nz - 1\n\n if (!wrap) {\n if (noNormals) {\n xBeg = Math.max(0, xBeg)\n yBeg = Math.max(0, yBeg)\n zBeg = Math.max(0, zBeg)\n\n xEnd = Math.min(nx - 1, xEnd)\n yEnd = Math.min(ny - 1, yEnd)\n zEnd = Math.min(nz - 1, zEnd)\n } else {\n xBeg = Math.max(1, xBeg)\n yBeg = Math.max(1, yBeg)\n zBeg = Math.max(1, zBeg)\n\n xEnd = Math.min(nx - 2, xEnd)\n yEnd = Math.min(ny - 2, yEnd)\n zEnd = Math.min(nz - 2, zEnd)\n }\n }\n\n let xBeg2, yBeg2, zBeg2, xEnd2, yEnd2, zEnd2\n\n if (!wrap) {\n // init part of the vertexIndex\n // (takes a significant amount of time to do for all)\n\n xBeg2 = Math.max(0, xBeg - 2)\n yBeg2 = Math.max(0, yBeg - 2)\n zBeg2 = Math.max(0, zBeg - 2)\n\n xEnd2 = Math.min(nx, xEnd + 2)\n yEnd2 = Math.min(ny, yEnd + 2)\n zEnd2 = Math.min(nz, zEnd + 2)\n\n for (z = zBeg2; z < zEnd2; ++z) {\n zOffset = zd * z\n for (y = yBeg2; y < yEnd2; ++y) {\n yOffset = zOffset + yd * y\n for (x = xBeg2; x < xEnd2; ++x) {\n q = 3 * (yOffset + x)\n vertexIndex[ q ] = -1\n vertexIndex[ q + 1 ] = -1\n vertexIndex[ q + 2 ] = -1\n }\n }\n }\n } else {\n xBeg2 = xBeg - 2\n yBeg2 = yBeg - 2\n zBeg2 = zBeg - 2\n\n xEnd2 = xEnd + 2\n yEnd2 = yEnd + 2\n zEnd2 = zEnd + 2\n\n for (z = zBeg2; z < zEnd2; ++z) {\n for (y = yBeg2; y < yEnd2; ++y) {\n for (x = xBeg2; x < xEnd2; ++x) {\n q3 = index(x, y, z) * 3\n vertexIndex[ q3 ] = -1\n vertexIndex[ q3 + 1 ] = -1\n vertexIndex[ q3 + 2 ] = -1\n }\n }\n }\n }\n\n if (!wrap) {\n // clip space where the isovalue is too low\n\n var __break\n var __xBeg = xBeg; var __yBeg = yBeg; var __zBeg = zBeg\n var __xEnd = xEnd; var __yEnd = yEnd; var __zEnd = zEnd\n\n __break = false\n for (z = zBeg; z < zEnd; ++z) {\n for (y = yBeg; y < yEnd; ++y) {\n for (x = xBeg; x < xEnd; ++x) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __zBeg = z\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (y = yBeg; y < yEnd; ++y) {\n for (z = __zBeg; z < zEnd; ++z) {\n for (x = xBeg; x < xEnd; ++x) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __yBeg = y\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (x = xBeg; x < xEnd; ++x) {\n for (y = __yBeg; y < yEnd; ++y) {\n for (z = __zBeg; z < zEnd; ++z) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __xBeg = x\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (z = zEnd; z >= zBeg; --z) {\n for (y = yEnd; y >= yBeg; --y) {\n for (x = xEnd; x >= xBeg; --x) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __zEnd = z\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (y = yEnd; y >= yBeg; --y) {\n for (z = __zEnd; z >= zBeg; --z) {\n for (x = xEnd; x >= xBeg; --x) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __yEnd = y\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (x = xEnd; x >= xBeg; --x) {\n for (y = __yEnd; y >= yBeg; --y) {\n for (z = __zEnd; z >= zBeg; --z) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __xEnd = x\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n //\n\n if (noNormals) {\n xBeg = Math.max(0, __xBeg - 1)\n yBeg = Math.max(0, __yBeg - 1)\n zBeg = Math.max(0, __zBeg - 1)\n\n xEnd = Math.min(nx - 1, __xEnd + 1)\n yEnd = Math.min(ny - 1, __yEnd + 1)\n zEnd = Math.min(nz - 1, __zEnd + 1)\n } else {\n xBeg = Math.max(1, __xBeg - 1)\n yBeg = Math.max(1, __yBeg - 1)\n zBeg = Math.max(1, __zBeg - 1)\n\n xEnd = Math.min(nx - 2, __xEnd + 1)\n yEnd = Math.min(ny - 2, __yEnd + 1)\n zEnd = Math.min(nz - 2, __zEnd + 1)\n }\n }\n\n // polygonize part of the grid\n var edgeFilter = 15\n for (z = zBeg; z < zEnd; ++z, edgeFilter &= ~4) {\n zOffset = zd * z\n edgeFilter |= 2\n for (y = yBeg; y < yEnd; ++y, edgeFilter &= ~2) {\n yOffset = zOffset + yd * y\n edgeFilter |= 1\n for (x = xBeg; x < xEnd; ++x, edgeFilter &= ~1) {\n q = yOffset + x\n polygonize(x, y, z, q, edgeFilter)\n }\n }\n }\n }\n}\nObject.assign(MarchingCubes, {__deps: [ getEdgeTable, getTriTable, getUintArray ]})\n\nexport default MarchingCubes\n","/**\n * @file Matrix Utils\n * @private\n * @author Alexander Rose \n *\n * svd methods from Eugene Zatepyakin / http://inspirit.github.io/jsfeat/\n */\n\nimport { NumberArray } from '../types'\nimport { v3new, v3cross } from './vector-utils'\n\nexport class Matrix {\n size: number\n data: Float32Array\n\n constructor (readonly cols: number, readonly rows: number) {\n this.size = this.cols * this.rows\n this.data = new Float32Array(this.size)\n }\n\n copyTo (matrix: Matrix) {\n matrix.data.set(this.data)\n }\n}\n\nexport function transpose (At: Matrix, A: Matrix) {\n let i = 0\n let j = 0\n const nrows = A.rows\n const ncols = A.cols\n let Ai = 0\n let Ati = 0\n let pAt = 0\n const ad = A.data\n const atd = At.data\n\n for (; i < nrows; Ati += 1, Ai += ncols, i++) {\n pAt = Ati\n for (j = 0; j < ncols; pAt += nrows, j++) atd[pAt] = ad[Ai + j]\n }\n}\n\n// C = A * B\nexport function multiply (C: Matrix, A: Matrix, B: Matrix) {\n let i = 0\n let j = 0\n let k = 0\n let Ap = 0\n let pA = 0\n let pB = 0\n let _pB = 0\n let Cp = 0\n const ncols = A.cols\n const nrows = A.rows\n const mcols = B.cols\n const ad = A.data\n const bd = B.data\n const cd = C.data\n let sum = 0.0\n\n for (; i < nrows; Ap += ncols, i++) {\n for (_pB = 0, j = 0; j < mcols; Cp++, _pB++, j++) {\n pB = _pB\n pA = Ap\n sum = 0.0\n for (k = 0; k < ncols; pA++, pB += mcols, k++) {\n sum += ad[pA] * bd[pB]\n }\n cd[Cp] = sum\n }\n }\n}\n\n// C = A * B'\nexport function multiplyABt (C: Matrix, A: Matrix, B: Matrix) {\n let i = 0\n let j = 0\n let k = 0\n let Ap = 0\n let pA = 0\n let pB = 0\n let Cp = 0\n const ncols = A.cols\n const nrows = A.rows\n const mrows = B.rows\n const ad = A.data\n const bd = B.data\n const cd = C.data\n let sum = 0.0\n\n for (; i < nrows; Ap += ncols, i++) {\n for (pB = 0, j = 0; j < mrows; Cp++, j++) {\n pA = Ap\n sum = 0.0\n for (k = 0; k < ncols; pA++, pB++, k++) {\n sum += ad[pA] * bd[pB]\n }\n cd[Cp] = sum\n }\n }\n}\n\n// C = A' * B\nexport function multiplyAtB (C: Matrix, A: Matrix, B: Matrix) {\n let i = 0\n let j = 0\n let k = 0\n let Ap = 0\n let pA = 0\n let pB = 0\n let _pB = 0\n let Cp = 0\n const ncols = A.cols\n const nrows = A.rows\n const mcols = B.cols\n const ad = A.data\n const bd = B.data\n const cd = C.data\n let sum = 0.0\n\n for (; i < ncols; Ap++, i++) {\n for (_pB = 0, j = 0; j < mcols; Cp++, _pB++, j++) {\n pB = _pB\n pA = Ap\n sum = 0.0\n for (k = 0; k < nrows; pA += ncols, pB += mcols, k++) {\n sum += ad[pA] * bd[pB]\n }\n cd[Cp] = sum\n }\n }\n}\n\nexport function invert3x3 (from: Matrix, to: Matrix) {\n const A = from.data\n const invA = to.data\n const t1 = A[4]\n const t2 = A[8]\n const t4 = A[5]\n const t5 = A[7]\n const t8 = A[0]\n\n const t9 = t8 * t1\n const t11 = t8 * t4\n const t13 = A[3]\n const t14 = A[1]\n const t15 = t13 * t14\n const t17 = A[2]\n const t18 = t13 * t17\n const t20 = A[6]\n const t21 = t20 * t14\n const t23 = t20 * t17\n const t26 = 1.0 / (t9 * t2 - t11 * t5 - t15 * t2 + t18 * t5 + t21 * t4 - t23 * t1)\n invA[0] = (t1 * t2 - t4 * t5) * t26\n invA[1] = -(t14 * t2 - t17 * t5) * t26\n invA[2] = -(-t14 * t4 + t17 * t1) * t26\n invA[3] = -(t13 * t2 - t4 * t20) * t26\n invA[4] = (t8 * t2 - t23) * t26\n invA[5] = -(t11 - t18) * t26\n invA[6] = -(-t13 * t5 + t1 * t20) * t26\n invA[7] = -(t8 * t5 - t21) * t26\n invA[8] = (t9 - t15) * t26\n}\n\nexport function mat3x3determinant (M: Matrix) {\n const md = M.data\n return md[0] * md[4] * md[8] -\n md[0] * md[5] * md[7] -\n md[3] * md[1] * md[8] +\n md[3] * md[2] * md[7] +\n md[6] * md[1] * md[5] -\n md[6] * md[2] * md[4]\n}\n\n// C = A * B\nexport function multiply3x3 (C: Matrix, A: Matrix, B: Matrix) {\n const Cd = C.data\n const Ad = A.data\n const Bd = B.data\n const m10 = Ad[0]\n const m11 = Ad[1]\n const m12 = Ad[2]\n const m13 = Ad[3]\n const m14 = Ad[4]\n const m15 = Ad[5]\n const m16 = Ad[6]\n const m17 = Ad[7]\n const m18 = Ad[8]\n\n const m20 = Bd[0]\n const m21 = Bd[1]\n const m22 = Bd[2]\n const m23 = Bd[3]\n const m24 = Bd[4]\n const m25 = Bd[5]\n const m26 = Bd[6]\n const m27 = Bd[7]\n const m28 = Bd[8]\n\n Cd[0] = m10 * m20 + m11 * m23 + m12 * m26\n Cd[1] = m10 * m21 + m11 * m24 + m12 * m27\n Cd[2] = m10 * m22 + m11 * m25 + m12 * m28\n Cd[3] = m13 * m20 + m14 * m23 + m15 * m26\n Cd[4] = m13 * m21 + m14 * m24 + m15 * m27\n Cd[5] = m13 * m22 + m14 * m25 + m15 * m28\n Cd[6] = m16 * m20 + m17 * m23 + m18 * m26\n Cd[7] = m16 * m21 + m17 * m24 + m18 * m27\n Cd[8] = m16 * m22 + m17 * m25 + m18 * m28\n}\n\nexport function meanRows (A: Matrix) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n const mean = new Array(ncols)\n\n for (let j = 0; j < ncols; ++j) {\n mean[ j ] = 0.0\n }\n\n for (let i = 0, p = 0; i < nrows; ++i) {\n for (let j = 0; j < ncols; ++j, ++p) {\n mean[ j ] += Ad[ p ]\n }\n }\n\n for (let j = 0; j < ncols; ++j) {\n mean[ j ] /= nrows\n }\n\n return mean\n}\n\nexport function meanCols (A: Matrix) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n const mean = new Array(nrows)\n\n for (let j = 0; j < nrows; ++j) {\n mean[ j ] = 0.0\n }\n\n for (let i = 0, p = 0; i < ncols; ++i) {\n for (let j = 0; j < nrows; ++j, ++p) {\n mean[ j ] += Ad[ p ]\n }\n }\n\n for (let j = 0; j < nrows; ++j) {\n mean[ j ] /= ncols\n }\n\n return mean\n}\n\nexport function subRows (A: Matrix, row: number[]) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n\n for (let i = 0, p = 0; i < nrows; ++i) {\n for (let j = 0; j < ncols; ++j, ++p) {\n Ad[ p ] -= row[ j ]\n }\n }\n}\n\nexport function subCols (A: Matrix, col: number[]) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n\n for (let i = 0, p = 0; i < ncols; ++i) {\n for (let j = 0; j < nrows; ++j, ++p) {\n Ad[ p ] -= col[ j ]\n }\n }\n}\n\nexport function addRows (A: Matrix, row: number[]) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n\n for (let i = 0, p = 0; i < nrows; ++i) {\n for (let j = 0; j < ncols; ++j, ++p) {\n Ad[ p ] += row[ j ]\n }\n }\n}\n\nexport function addCols (A: Matrix, col: number[]) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n\n for (let i = 0, p = 0; i < ncols; ++i) {\n for (let j = 0; j < nrows; ++j, ++p) {\n Ad[ p ] += col[ j ]\n }\n }\n}\n\nexport function swap (A: NumberArray, i0: number, i1: number, t: number) {\n t = A[i0]\n A[i0] = A[i1]\n A[i1] = t\n}\n\nexport function hypot (a: number, b: number) {\n a = Math.abs(a)\n b = Math.abs(b)\n if (a > b) {\n b /= a\n return a * Math.sqrt(1.0 + b * b)\n }\n if (b > 0) {\n a /= b\n return b * Math.sqrt(1.0 + a * a)\n }\n return 0.0\n}\n\nconst EPSILON = 0.0000001192092896\nconst FLT_MIN = 1E-37\n\nexport function JacobiSVDImpl (At: NumberArray, astep: number, _W: NumberArray, Vt: NumberArray, vstep: number, m: number, n: number, n1: number) {\n const eps = EPSILON * 2.0\n const minval = FLT_MIN\n let i = 0\n let j = 0\n let k = 0\n let iter = 0\n const maxIter = Math.max(m, 30)\n let Ai = 0\n let Aj = 0\n let Vi = 0\n let Vj = 0\n let changed = 0\n let c = 0.0\n let s = 0.0\n let t = 0.0\n let t0 = 0.0\n let t1 = 0.0\n let sd = 0.0\n let beta = 0.0\n let gamma = 0.0\n let delta = 0.0\n let a = 0.0\n let p = 0.0\n let b = 0.0\n let seed = 0x1234\n let val = 0.0\n let val0 = 0.0\n let asum = 0.0\n\n const W = new Float64Array(n << 3)\n\n for (; i < n; i++) {\n for (k = 0, sd = 0; k < m; k++) {\n t = At[i * astep + k]\n sd += t * t\n }\n W[i] = sd\n\n if (Vt) {\n for (k = 0; k < n; k++) {\n Vt[i * vstep + k] = 0\n }\n Vt[i * vstep + i] = 1\n }\n }\n\n for (; iter < maxIter; iter++) {\n changed = 0\n\n for (i = 0; i < n - 1; i++) {\n for (j = i + 1; j < n; j++) {\n Ai = (i * astep) | 0\n Aj = (j * astep) | 0\n a = W[i]\n p = 0\n b = W[j]\n\n k = 2\n p += At[Ai] * At[Aj]\n p += At[Ai + 1] * At[Aj + 1]\n\n for (; k < m; k++) { p += At[Ai + k] * At[Aj + k] }\n\n if (Math.abs(p) <= eps * Math.sqrt(a * b)) continue\n\n p *= 2.0\n beta = a - b\n gamma = hypot(p, beta)\n if (beta < 0) {\n delta = (gamma - beta) * 0.5\n s = Math.sqrt(delta / gamma)\n c = (p / (gamma * s * 2.0))\n } else {\n c = Math.sqrt((gamma + beta) / (gamma * 2.0))\n s = (p / (gamma * c * 2.0))\n }\n\n a = 0.0\n b = 0.0\n\n k = 2 // unroll\n t0 = c * At[Ai] + s * At[Aj]\n t1 = -s * At[Ai] + c * At[Aj]\n At[Ai] = t0; At[Aj] = t1\n a += t0 * t0; b += t1 * t1\n\n t0 = c * At[Ai + 1] + s * At[Aj + 1]\n t1 = -s * At[Ai + 1] + c * At[Aj + 1]\n At[Ai + 1] = t0; At[Aj + 1] = t1\n a += t0 * t0; b += t1 * t1\n\n for (; k < m; k++) {\n t0 = c * At[Ai + k] + s * At[Aj + k]\n t1 = -s * At[Ai + k] + c * At[Aj + k]\n At[Ai + k] = t0; At[Aj + k] = t1\n\n a += t0 * t0; b += t1 * t1\n }\n\n W[i] = a\n W[j] = b\n\n changed = 1\n\n if (Vt) {\n Vi = (i * vstep) | 0\n Vj = (j * vstep) | 0\n\n k = 2\n t0 = c * Vt[Vi] + s * Vt[Vj]\n t1 = -s * Vt[Vi] + c * Vt[Vj]\n Vt[Vi] = t0; Vt[Vj] = t1\n\n t0 = c * Vt[Vi + 1] + s * Vt[Vj + 1]\n t1 = -s * Vt[Vi + 1] + c * Vt[Vj + 1]\n Vt[Vi + 1] = t0; Vt[Vj + 1] = t1\n\n for (; k < n; k++) {\n t0 = c * Vt[Vi + k] + s * Vt[Vj + k]\n t1 = -s * Vt[Vi + k] + c * Vt[Vj + k]\n Vt[Vi + k] = t0; Vt[Vj + k] = t1\n }\n }\n }\n }\n if (changed === 0) break\n }\n\n for (i = 0; i < n; i++) {\n for (k = 0, sd = 0; k < m; k++) {\n t = At[i * astep + k]\n sd += t * t\n }\n W[i] = Math.sqrt(sd)\n }\n\n for (i = 0; i < n - 1; i++) {\n j = i\n for (k = i + 1; k < n; k++) {\n if (W[j] < W[k]) { j = k }\n }\n if (i !== j) {\n swap(W, i, j, sd)\n if (Vt) {\n for (k = 0; k < m; k++) {\n swap(At, i * astep + k, j * astep + k, t)\n }\n\n for (k = 0; k < n; k++) {\n swap(Vt, i * vstep + k, j * vstep + k, t)\n }\n }\n }\n }\n\n for (i = 0; i < n; i++) {\n _W[i] = W[i]\n }\n\n if (!Vt) {\n return\n }\n\n for (i = 0; i < n1; i++) {\n sd = i < n ? W[i] : 0\n\n while (sd <= minval) {\n // if we got a zero singular value, then in order to get the corresponding left singular vector\n // we generate a random vector, project it to the previously computed left singular vectors,\n // subtract the projection and normalize the difference.\n val0 = (1.0 / m)\n for (k = 0; k < m; k++) {\n seed = (seed * 214013 + 2531011)\n val = (((seed >> 16) & 0x7fff) & 256) !== 0 ? val0 : -val0\n At[i * astep + k] = val\n }\n for (iter = 0; iter < 2; iter++) {\n for (j = 0; j < i; j++) {\n sd = 0\n for (k = 0; k < m; k++) {\n sd += At[i * astep + k] * At[j * astep + k]\n }\n asum = 0.0\n for (k = 0; k < m; k++) {\n t = (At[i * astep + k] - sd * At[j * astep + k])\n At[i * astep + k] = t\n asum += Math.abs(t)\n }\n asum = asum ? 1.0 / asum : 0\n for (k = 0; k < m; k++) {\n At[i * astep + k] *= asum\n }\n }\n }\n sd = 0\n for (k = 0; k < m; k++) {\n t = At[i * astep + k]\n sd += t * t\n }\n sd = Math.sqrt(sd)\n }\n\n s = (1.0 / sd)\n for (k = 0; k < m; k++) {\n At[i * astep + k] *= s\n }\n }\n}\n\nexport function svd (A: Matrix, W: Matrix, U: Matrix, V: Matrix) {\n let at = 0\n let i = 0\n const _m = A.rows\n const _n = A.cols\n let m = _m\n let n = _n\n\n if (m < n) {\n at = 1\n i = m\n m = n\n n = i\n }\n\n const amt = new Matrix(m, m)\n const wmt = new Matrix(1, n)\n const vmt = new Matrix(n, n)\n\n if (at === 0) {\n transpose(amt, A)\n } else {\n for (i = 0; i < _n * _m; i++) {\n amt.data[i] = A.data[i]\n }\n for (; i < n * m; i++) {\n amt.data[i] = 0\n }\n }\n\n JacobiSVDImpl(amt.data, m, wmt.data, vmt.data, n, m, n, m)\n\n if (W) {\n for (i = 0; i < n; i++) {\n W.data[i] = wmt.data[i]\n }\n for (; i < _n; i++) {\n W.data[i] = 0\n }\n }\n\n if (at === 0) {\n if (U) transpose(U, amt)\n if (V) transpose(V, vmt)\n } else {\n if (U) transpose(U, vmt)\n if (V) transpose(V, amt)\n }\n}\n\n//\n\nexport function m4new () {\n return new Float32Array([\n 1, 0, 0, 0,\n 0, 1, 0, 0,\n 0, 0, 1, 0,\n 0, 0, 0, 1\n ])\n}\n\nexport function m4set (out: Float32Array, n11: number, n12: number, n13: number, n14: number, n21: number, n22: number, n23: number, n24: number, n31: number, n32: number, n33: number, n34: number, n41: number, n42: number, n43: number, n44: number) {\n out[ 0 ] = n11; out[ 4 ] = n12; out[ 8 ] = n13; out[ 12 ] = n14\n out[ 1 ] = n21; out[ 5 ] = n22; out[ 9 ] = n23; out[ 13 ] = n24\n out[ 2 ] = n31; out[ 6 ] = n32; out[ 10 ] = n33; out[ 14 ] = n34\n out[ 3 ] = n41; out[ 7 ] = n42; out[ 11 ] = n43; out[ 15 ] = n44\n}\n\nexport function m4identity (out: Float32Array) {\n m4set(out,\n 1, 0, 0, 0,\n 0, 1, 0, 0,\n 0, 0, 1, 0,\n 0, 0, 0, 1\n )\n}\n(m4identity as any).__deps = [ m4set ]\n\nexport function m4multiply (out: Float32Array, a: Float32Array, b: Float32Array) {\n const a11 = a[ 0 ]\n const a12 = a[ 4 ]\n const a13 = a[ 8 ]\n const a14 = a[ 12 ]\n const a21 = a[ 1 ]\n const a22 = a[ 5 ]\n const a23 = a[ 9 ]\n const a24 = a[ 13 ]\n const a31 = a[ 2 ]\n const a32 = a[ 6 ]\n const a33 = a[ 10 ]\n const a34 = a[ 14 ]\n const a41 = a[ 3 ]\n const a42 = a[ 7 ]\n const a43 = a[ 11 ]\n const a44 = a[ 15 ]\n\n const b11 = b[ 0 ]\n const b12 = b[ 4 ]\n const b13 = b[ 8 ]\n const b14 = b[ 12 ]\n const b21 = b[ 1 ]\n const b22 = b[ 5 ]\n const b23 = b[ 9 ]\n const b24 = b[ 13 ]\n const b31 = b[ 2 ]\n const b32 = b[ 6 ]\n const b33 = b[ 10 ]\n const b34 = b[ 14 ]\n const b41 = b[ 3 ]\n const b42 = b[ 7 ]\n const b43 = b[ 11 ]\n const b44 = b[ 15 ]\n\n out[ 0 ] = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41\n out[ 4 ] = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42\n out[ 8 ] = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43\n out[ 12 ] = a11 * b14 + a12 * b24 + a13 * b34 + a14 * b44\n\n out[ 1 ] = a21 * b11 + a22 * b21 + a23 * b31 + a24 * b41\n out[ 5 ] = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42\n out[ 9 ] = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43\n out[ 13 ] = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44\n\n out[ 2 ] = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41\n out[ 6 ] = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42\n out[ 10 ] = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43\n out[ 14 ] = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44\n\n out[ 3 ] = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41\n out[ 7 ] = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42\n out[ 11 ] = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43\n out[ 15 ] = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44\n}\n\nexport function m4makeScale (out: Float32Array, x: number, y: number, z: number) {\n m4set(out,\n x, 0, 0, 0,\n 0, y, 0, 0,\n 0, 0, z, 0,\n 0, 0, 0, 1\n )\n}\n(m4makeScale as any).__deps = [ m4set ]\n\nexport function m4makeTranslation (out: Float32Array, x: number, y: number, z: number) {\n m4set(out,\n 1, 0, 0, x,\n 0, 1, 0, y,\n 0, 0, 1, z,\n 0, 0, 0, 1\n )\n}\n(m4makeTranslation as any).__deps = [ m4set ]\n\nexport function m4makeRotationY (out: Float32Array, theta: number) {\n const c = Math.cos(theta)\n const s = Math.sin(theta)\n m4set(out,\n c, 0, s, 0,\n 0, 1, 0, 0,\n -s, 0, c, 0,\n 0, 0, 0, 1\n )\n}\n(m4makeRotationY as any).__deps = [ m4set ]\n\n//\n\nexport function m3new () {\n return new Float32Array([\n 1, 0, 0,\n 0, 1, 0,\n 0, 0, 1\n ])\n}\n\nexport function m3makeNormal (out: Float32Array, m4: Float32Array) {\n const r0 = v3new([ m4[0], m4[1], m4[2] ])\n const r1 = v3new([ m4[4], m4[5], m4[6] ])\n const r2 = v3new([ m4[8], m4[9], m4[10] ])\n const cp = v3new()\n // [ r0 ] [ r1 x r2 ]\n // M3x3 = [ r1 ] N = [ r2 x r0 ]\n // [ r2 ] [ r0 x r1 ]\n v3cross(cp, r1, r2)\n out[ 0 ] = cp[ 0 ]\n out[ 1 ] = cp[ 1 ]\n out[ 2 ] = cp[ 2 ]\n v3cross(cp, r2, r0)\n out[ 3 ] = cp[ 0 ]\n out[ 4 ] = cp[ 1 ]\n out[ 5 ] = cp[ 2 ]\n v3cross(cp, r0, r1)\n out[ 6 ] = cp[ 0 ]\n out[ 7 ] = cp[ 1 ]\n out[ 8 ] = cp[ 2 ]\n}\n(m3makeNormal as any).__deps = [ v3new, v3cross ]\n","/**\n * @file Surface Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { degToRad } from '../math/math-utils'\nimport {\n m4new, m4multiply, m4makeTranslation, m4makeScale, m4makeRotationY\n} from '../math/matrix-utils'\nimport {\n v3addScalar, v3subScalar, v3divideScalar, v3multiplyScalar,\n v3floor, v3ceil, v3sub, v3negate,\n v3cross, v3fromArray, normalizeVector3array\n} from '../math/vector-utils'\nimport { NumberArray } from '../types'\n\nfunction laplacianSmooth (verts: Float32Array, faces: Float32Array, numiter: number, inflate: boolean) {\n // based on D. Xu, Y. Zhang (2009) Generating Triangulated Macromolecular\n // Surfaces by Euclidean Distance Transform. PLoS ONE 4(12): e8140.\n //\n // Permission to use, copy, modify, and distribute this program for\n // any purpose, with or without fee, is hereby granted, provided that\n // the notices on the head, the reference information, and this\n // copyright notice appear in all copies or substantial portions of\n // the Software. It is provided \"as is\" without express or implied\n // warranty.\n //\n // ported to JavaScript and adapted to NGL by Alexander Rose\n\n numiter = numiter || 1\n inflate = inflate || true\n\n const nv = verts.length / 3\n const nf = faces.length / 3\n let norms: Float32Array | undefined = undefined\n\n if (inflate) {\n norms = new Float32Array(nv * 3)\n }\n\n const tps = new Float32Array(nv * 3)\n\n let i\n const ndeg = 20\n const vertdeg = new Array(ndeg)\n\n for (i = 0; i < ndeg; ++i) {\n vertdeg[ i ] = new Uint32Array(nv)\n }\n\n for (i = 0; i < nv; ++i) {\n vertdeg[ 0 ][ i ] = 0\n }\n\n let j, jl\n let flagvert: boolean\n\n // for each face\n\n for (i = 0; i < nf; ++i) {\n var ao = i * 3\n var bo = i * 3 + 1\n var co = i * 3 + 2\n\n // vertex a\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ao] ]; j < jl; ++j) {\n if (faces[ bo ] === vertdeg[ j + 1 ][ faces[ ao ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ ao ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ ao ] ] ][ faces[ ao ] ] = faces[ bo ]\n }\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ ao ] ]; j < jl; ++j) {\n if (faces[ co ] === vertdeg[ j + 1 ][ faces[ ao ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ ao ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ ao ] ] ][ faces[ ao ] ] = faces[ co ]\n }\n\n // vertex b\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ bo ] ]; j < jl; ++j) {\n if (faces[ ao ] === vertdeg[ j + 1 ][ faces[ bo ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ bo ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ bo ] ] ][ faces[ bo ] ] = faces[ ao ]\n }\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ bo ] ]; j < jl; ++j) {\n if (faces[ co ] === vertdeg[ j + 1 ][ faces[ bo ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ bo ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ bo ] ] ][ faces[ bo ] ] = faces[ co ]\n }\n\n // vertex c\n\n flagvert = true\n for (j = 0; j < vertdeg[ 0 ][ faces[ co ] ]; ++j) {\n if (faces[ ao ] === vertdeg[ j + 1 ][ faces[ co ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ co ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ co ] ] ][ faces[ co ] ] = faces[ ao ]\n }\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ co ] ]; j < jl; ++j) {\n if (faces[ bo ] === vertdeg[ j + 1 ][ faces[ co ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ co ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ co ] ] ][ faces[ co ] ] = faces[ bo ]\n }\n }\n\n var wt = 1.0\n var wt2 = 0.5\n var i3, vi3, vdi, wtvi, wt2vi\n var ssign = -1\n var scaleFactor = 1\n var outwt = 0.75 / (scaleFactor + 3.5) // area-preserving\n\n // smoothing iterations\n\n for (var k = 0; k < numiter; ++k) {\n // for each vertex\n\n for (i = 0; i < nv; ++i) {\n i3 = i * 3\n vdi = vertdeg[ 0 ][ i ]\n\n if (vdi < 3) {\n tps[ i3 ] = verts[ i3 ]\n tps[ i3 + 1 ] = verts[ i3 + 1 ]\n tps[ i3 + 2 ] = verts[ i3 + 2 ]\n } else if (vdi === 3 || vdi === 4) {\n tps[ i3 ] = 0\n tps[ i3 + 1 ] = 0\n tps[ i3 + 2 ] = 0\n\n for (j = 0; j < vdi; ++j) {\n vi3 = vertdeg[ j + 1 ][ i ] * 3\n tps[ i3 ] += verts[ vi3 ]\n tps[ i3 + 1 ] += verts[ vi3 + 1 ]\n tps[ i3 + 2 ] += verts[ vi3 + 2 ]\n }\n\n tps[ i3 ] += wt2 * verts[ i3 ]\n tps[ i3 + 1 ] += wt2 * verts[ i3 + 1 ]\n tps[ i3 + 2 ] += wt2 * verts[ i3 + 2 ]\n\n wt2vi = wt2 + vdi\n tps[ i3 ] /= wt2vi\n tps[ i3 + 1 ] /= wt2vi\n tps[ i3 + 2 ] /= wt2vi\n } else {\n tps[ i3 ] = 0\n tps[ i3 + 1 ] = 0\n tps[ i3 + 2 ] = 0\n\n for (j = 0; j < vdi; ++j) {\n vi3 = vertdeg[ j + 1 ][ i ] * 3\n tps[ i3 ] += verts[ vi3 ]\n tps[ i3 + 1 ] += verts[ vi3 + 1 ]\n tps[ i3 + 2 ] += verts[ vi3 + 2 ]\n }\n\n tps[ i3 ] += wt * verts[ i3 ]\n tps[ i3 + 1 ] += wt * verts[ i3 + 1 ]\n tps[ i3 + 2 ] += wt * verts[ i3 + 2 ]\n\n wtvi = wt + vdi\n tps[ i3 ] /= wtvi\n tps[ i3 + 1 ] /= wtvi\n tps[ i3 + 2 ] /= wtvi\n }\n }\n\n verts.set(tps) // copy smoothed positions\n\n if (inflate) {\n computeVertexNormals(verts, faces, norms)\n var nv3 = nv * 3\n\n for (i3 = 0; i3 < nv3; i3 += 3) {\n // if(verts[i].inout) ssign=1;\n // else ssign=-1;\n\n verts[ i3 ] += ssign * outwt * norms![ i3 ]\n verts[ i3 + 1 ] += ssign * outwt * norms![ i3 + 1 ]\n verts[ i3 + 2 ] += ssign * outwt * norms![ i3 + 2 ]\n }\n }\n }\n}\nObject.assign(laplacianSmooth, {__deps: [ computeVertexNormals ]})\n\nfunction computeVertexNormals (position: Float32Array, index?: NumberArray, normal?: Float32Array) {\n var i, il\n\n if (normal === undefined) {\n normal = new Float32Array(position.length)\n } else {\n // reset existing normals to zero\n for (i = 0, il = normal.length; i < il; i++) {\n normal[ i ] = 0\n }\n }\n\n var a = new Float32Array(3)\n var b = new Float32Array(3)\n var c = new Float32Array(3)\n var cb = new Float32Array(3)\n var ab = new Float32Array(3)\n\n if (index) {\n // indexed elements\n for (i = 0, il = index.length; i < il; i += 3) {\n var ai = index[ i ] * 3\n var bi = index[ i + 1 ] * 3\n var ci = index[ i + 2 ] * 3\n\n v3fromArray(a, position, ai)\n v3fromArray(b, position, bi)\n v3fromArray(c, position, ci)\n\n v3sub(cb, c, b)\n v3sub(ab, a, b)\n v3cross(cb, cb, ab)\n\n normal[ ai ] += cb[ 0 ]\n normal[ ai + 1 ] += cb[ 1 ]\n normal[ ai + 2 ] += cb[ 2 ]\n\n normal[ bi ] += cb[ 0 ]\n normal[ bi + 1 ] += cb[ 1 ]\n normal[ bi + 2 ] += cb[ 2 ]\n\n normal[ ci ] += cb[ 0 ]\n normal[ ci + 1 ] += cb[ 1 ]\n normal[ ci + 2 ] += cb[ 2 ]\n }\n } else {\n // non-indexed elements (unconnected triangle soup)\n for (i = 0, il = position.length; i < il; i += 9) {\n v3fromArray(a, position, i)\n v3fromArray(b, position, i + 3)\n v3fromArray(c, position, i + 6)\n\n v3sub(cb, c, b)\n v3sub(ab, a, b)\n v3cross(cb, cb, ab)\n\n normal[ i ] = cb[ 0 ]\n normal[ i + 1 ] = cb[ 1 ]\n normal[ i + 2 ] = cb[ 2 ]\n\n normal[ i + 3 ] = cb[ 0 ]\n normal[ i + 4 ] = cb[ 1 ]\n normal[ i + 5 ] = cb[ 2 ]\n\n normal[ i + 6 ] = cb[ 0 ]\n normal[ i + 7 ] = cb[ 1 ]\n normal[ i + 8 ] = cb[ 2 ]\n }\n }\n\n normalizeVector3array(normal)\n\n return normal\n}\nObject.assign(computeVertexNormals, {__deps: [\n v3sub, v3cross, v3fromArray, normalizeVector3array\n]})\n\nfunction getRadiusDict (radiusList: number[]) {\n var radiusDict: {[k: number]: boolean} = {}\n for (var i = 0, il = radiusList.length; i < il; ++i) {\n radiusDict[ radiusList[ i ] ] = true\n }\n return radiusDict\n}\n\nfunction getSurfaceGrid (min: Float32Array, max: Float32Array, maxRadius: number, scaleFactor: number, extraMargin: number) {\n // need margin to avoid boundary/round off effects\n var margin = (1 / scaleFactor) * 3\n margin += maxRadius\n\n v3subScalar(min, min, extraMargin + margin)\n v3addScalar(max, max, extraMargin + margin)\n\n v3multiplyScalar(min, min, scaleFactor)\n v3floor(min, min)\n v3divideScalar(min, min, scaleFactor)\n\n v3multiplyScalar(max, max, scaleFactor)\n v3ceil(max, max)\n v3divideScalar(max, max, scaleFactor)\n\n var dim = new Float32Array(3)\n v3sub(dim, max, min)\n v3multiplyScalar(dim, dim, scaleFactor)\n v3ceil(dim, dim)\n v3addScalar(dim, dim, 1)\n\n var maxSize = Math.pow(10, 6) * 256\n var tmpSize = dim[ 0 ] * dim[ 1 ] * dim[ 2 ] * 3\n\n if (maxSize <= tmpSize) {\n scaleFactor *= Math.pow(maxSize / tmpSize, 1 / 3)\n\n v3multiplyScalar(min, min, scaleFactor)\n v3floor(min, min)\n v3divideScalar(min, min, scaleFactor)\n\n v3multiplyScalar(max, max, scaleFactor)\n v3ceil(max, max)\n v3divideScalar(max, max, scaleFactor)\n\n v3sub(dim, max, min)\n v3multiplyScalar(dim, dim, scaleFactor)\n v3ceil(dim, dim)\n v3addScalar(dim, dim, 1)\n }\n\n var tran = new Float32Array(min)\n v3negate(tran, tran)\n\n // coordinate transformation matrix\n var matrix = m4new()\n var mroty = m4new()\n m4makeRotationY(mroty, degToRad(90))\n m4multiply(matrix, matrix, mroty)\n\n var mscale = m4new()\n m4makeScale(\n mscale,\n -1 / scaleFactor,\n 1 / scaleFactor,\n 1 / scaleFactor\n )\n m4multiply(matrix, matrix, mscale)\n\n var mtrans = m4new()\n m4makeTranslation(\n mtrans,\n -scaleFactor * tran[2],\n -scaleFactor * tran[1],\n -scaleFactor * tran[0]\n )\n m4multiply(matrix, matrix, mtrans)\n\n return {\n dim: dim,\n tran: tran,\n matrix: matrix,\n scaleFactor: scaleFactor\n }\n}\nObject.assign(getSurfaceGrid, {__deps: [\n degToRad,\n v3subScalar, v3addScalar, v3divideScalar, v3multiplyScalar,\n v3floor, v3ceil, v3sub, v3negate,\n m4new, m4multiply, m4makeTranslation, m4makeScale, m4makeRotationY\n]})\n\nexport {\n laplacianSmooth,\n computeVertexNormals,\n getRadiusDict,\n getSurfaceGrid\n}\n","/**\n * @file Surface\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3, Geometry, BufferGeometry, Group, Color } from 'three'\n\nimport { Debug, Log, ColormakerRegistry } from '../globals'\nimport { getUintArray } from '../utils'\nimport { AtomPicker, SurfacePicker } from '../utils/picker'\nimport { uniformArray, uniformArray3, serialArray } from '../math/array-utils'\nimport Selection from '../selection/selection'\nimport { ColormakerParameters } from '../color/colormaker';\nimport { Structure, Volume } from '../ngl';\n\nexport interface SurfaceData {\n position: Float32Array\n index: Uint32Array|Uint16Array|undefined\n normal: Float32Array\n color: Float32Array\n atomindex: Int32Array\n contour: boolean\n}\n/**\n * Surface\n */\nclass Surface {\n name: string\n path: string\n position: Float32Array\n index: Uint32Array|Uint16Array|undefined\n normal: Float32Array|undefined\n color: Float32Array|undefined\n atomindex: Int32Array|undefined\n contour: boolean\n center: Vector3\n boundingBox: Box3\n size: number\n info: {\n type?: string\n probeRadius?: number\n scaleFactor?: number\n smooth?: number\n cutoff?: number\n isolevel?: number\n volume?: Volume\n }\n\n /**\n * @param {String} name - surface name\n * @param {String} path - source path\n * @param {Object} data - surface data\n * @param {Float32Array} data.position - surface positions\n * @param {Int32Array} data.index - surface indices\n * @param {Float32Array} data.normal - surface normals\n * @param {Float32Array} data.color - surface colors\n * @param {Int32Array} data.atomindex - atom indices\n * @param {boolean} data.contour - contour mode flag\n */\n constructor (name: string, path: string, data?: SurfaceData) {\n this.name = name || ''\n this.path = path || ''\n this.info = {}\n\n this.center = new Vector3()\n this.boundingBox = new Box3()\n\n if (data instanceof Geometry ||\n data instanceof BufferGeometry ||\n data instanceof Group\n ) {\n // to be removed\n this.fromGeometry(data)\n } else if (data) {\n this.set(\n data.position,\n data.index,\n data.normal,\n data.color,\n data.atomindex,\n data.contour\n )\n\n this.boundingBox.setFromArray(data.position)\n this.boundingBox.getCenter(this.center)\n }\n }\n\n get type () { return 'Surface' }\n\n /**\n * set surface data\n * @param {Float32Array} position - surface positions\n * @param {Int32Array} index - surface indices\n * @param {Float32Array} normal - surface normals\n * @param {Float32Array} color - surface colors\n * @param {Int32Array} atomindex - atom indices\n * @param {boolean} contour - contour mode flag\n * @return {undefined}\n */\n set (position: Float32Array,\n index: Uint32Array|Uint16Array|undefined,\n normal: Float32Array|undefined,\n color: Float32Array|undefined,\n atomindex: Int32Array|undefined,\n contour: boolean = false) {\n /**\n * @type {Float32Array}\n */\n this.position = position\n /**\n * @type {Uint32Array|Uint16Array|undefined}\n */\n this.index = index\n /**\n * @type {Float32Array|undefined}\n */\n this.normal = normal\n /**\n * @type {Float32Array|undefined}\n */\n this.color = color\n /**\n * @type {Int32Array|undefined}\n */\n this.atomindex = atomindex\n\n this.size = position.length / 3\n this.contour = contour\n }\n\n fromGeometry (geometry: Geometry|BufferGeometry|Group) {\n if (Debug) Log.time('GeometrySurface.fromGeometry')\n\n let geo\n\n if (geometry instanceof Geometry) {\n geometry.computeVertexNormals(true)\n geo = new BufferGeometry().fromGeometry(geometry)\n } else if (geometry instanceof BufferGeometry) {\n geo = geometry\n } else {\n geo = (geometry as any)[ 0 ]\n }\n\n if (!geo.boundingBox) geo.computeBoundingBox()\n\n this.boundingBox.copy(geo.boundingBox)\n this.boundingBox.getCenter(this.center)\n\n let position, color, index, normal\n\n if (geo instanceof BufferGeometry) {\n const attr = geo.attributes\n const an = (attr as any).normal ? (attr as any).normal.array : false\n\n // assume there are no normals if the first is zero\n if (!an || (an[ 0 ] === 0 && an[ 1 ] === 0 && an[ 2 ] === 0)) {\n geo.computeVertexNormals()\n }\n\n position = (attr).position.array\n index = (attr).index ? (attr).index.array : null\n normal = (attr).normal.array\n }\n\n this.set(position, index, normal, color, undefined)\n\n if (Debug) Log.timeEnd('GeometrySurface.setGeometry')\n }\n\n getPosition () {\n return this.position\n }\n\n getColor (params: ColormakerParameters&{ scheme: string}) {\n const p = params || {}\n p.surface = this\n\n const n = this.size\n const array = new Float32Array(n * 3)\n const colormaker = ColormakerRegistry.getScheme(p)\n\n if (colormaker.volumeColor || p.scheme === 'random') {\n for (let i = 0; i < n; ++i) {\n colormaker.volumeColorToArray(i, array, i * 3)\n }\n } else if (colormaker.positionColor) {\n const v = new Vector3()\n const pos = this.position\n\n for (let i = 0; i < n; ++i) {\n var i3 = i * 3\n v.set(pos[ i3 ], pos[ i3 + 1 ], pos[ i3 + 2 ])\n colormaker.positionColorToArray(v, array, i3)\n }\n } else if (colormaker.atomColor && this.atomindex) {\n const atomProxy = p.structure!.getAtomProxy()\n const atomindex = this.atomindex\n\n for (let i = 0; i < n; ++i) {\n atomProxy.index = atomindex[ i ]\n colormaker.atomColorToArray(atomProxy, array, i * 3)\n }\n } else {\n const tc = new Color(p.value)\n uniformArray3(n, tc.r, tc.g, tc.b, array)\n }\n\n return array\n }\n\n getPicking (structure?: Structure) {\n if (this.atomindex && structure) {\n return new AtomPicker(this.atomindex as any, structure)\n } else {\n return new SurfacePicker(serialArray(this.size), this)\n }\n }\n\n getNormal () {\n return this.normal\n }\n\n getSize (size: number, scale: number) {\n return uniformArray(this.size, size * scale)\n }\n\n getIndex () {\n return this.index\n }\n\n getFilteredIndex (sele: string, structure: Structure) {\n if (sele && this.atomindex) {\n const selection = new Selection(sele)\n const atomSet = structure.getAtomSet(selection)\n const filteredIndex = []\n\n const atomindex = this.atomindex\n const index = this.index\n const n = index!.length\n const elementSize = this.contour ? 2 : 3\n\n let j = 0\n\n for (let i = 0; i < n; i += elementSize) {\n let include = true\n\n for (let a = 0; a < elementSize; a++) {\n const idx = index![ i + a ]\n const ai = atomindex[ idx ]\n if (!atomSet.get(ai)) {\n include = false\n break\n }\n }\n\n if (!include) { continue }\n\n for (let a = 0; a < elementSize; a++, j++) {\n filteredIndex[ j ] = index![ i + a ]\n }\n }\n\n return getUintArray(filteredIndex, this.position.length / 3)\n } else {\n return this.index\n }\n }\n\n getAtomindex () {\n return this.atomindex\n }\n\n dispose () {\n\n //\n\n }\n}\n\nexport default Surface\n","/**\n * @file Volume\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3, Matrix3, Matrix4 } from 'three'\n\nimport { WorkerRegistry, ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport WorkerPool from '../worker/worker-pool'\nimport { VolumePicker } from '../utils/picker'\nimport {\n uniformArray, serialArray,\n arrayMin, arrayMax, arraySum, arrayMean, arrayRms\n} from '../math/array-utils'\nimport MarchingCubes from './marching-cubes'\nimport { laplacianSmooth, computeVertexNormals } from './surface-utils'\nimport {\n applyMatrix4toVector3array, applyMatrix3toVector3array\n} from '../math/vector-utils'\nimport { m3new, m3makeNormal } from '../math/matrix-utils'\nimport Surface from './surface'\nimport { NumberArray } from '../types';\nimport { ColormakerParameters } from '../color/colormaker';\n\nexport interface VolumeSurface {\n new (data: NumberArray, nx: number, ny: number, nz: number, atomindex: NumberArray): void\n getSurface: (isolevel: number, smooth: boolean|number, box: number[][]|undefined, matrix: Float32Array, contour: boolean, wrap?: boolean) => {\n position: Float32Array\n normal: undefined|Float32Array\n index: Uint32Array|Uint16Array\n atomindex: Int32Array|undefined\n contour: boolean\n }\n}\nexport function VolumeSurface (this: VolumeSurface,data: NumberArray, nx: number, ny: number, nz: number, atomindex: NumberArray) {\n var mc = new (MarchingCubes as any)(data, nx, ny, nz, atomindex) as MarchingCubes\n\n function getSurface (isolevel: number, smooth: boolean|number, box: number[][]|undefined, matrix: Float32Array, contour: boolean, wrap: boolean = false) {\n const sd = mc.triangulate(isolevel, smooth as boolean, box, contour, wrap)\n if (smooth && !contour) {\n laplacianSmooth(sd.position, sd.index as any, smooth as number, true)\n sd.normal = computeVertexNormals(sd.position, sd.index as any)\n }\n if (matrix) {\n applyMatrix4toVector3array(matrix, sd.position)\n if (sd.normal) {\n const normalMatrix = m3new()\n m3makeNormal(normalMatrix, matrix)\n applyMatrix3toVector3array(normalMatrix, sd.normal)\n }\n }\n return sd\n }\n\n this.getSurface = getSurface\n}\nObject.assign(VolumeSurface, {__deps: [\n laplacianSmooth, computeVertexNormals, MarchingCubes,\n applyMatrix4toVector3array, applyMatrix3toVector3array,\n m3new, m3makeNormal\n]})\n\nWorkerRegistry.add('surf', function func (e: any, callback: (data: any, transferList: any) => void) {\n const a = e.data.args\n const p = e.data.params\n if (a) {\n /* global self */\n (self as any).volsurf = new (VolumeSurface as any)(a[0], a[1], a[2], a[3], a[4]) as VolumeSurface\n }\n if (p) {\n const sd = ((self as any).volsurf as VolumeSurface).getSurface(\n p.isolevel, p.smooth, p.box, p.matrix, p.contour, p.wrap\n )\n const transferList = [ sd.position.buffer, sd.index.buffer ]\n if (sd.normal) transferList.push(sd.normal.buffer)\n if (sd.atomindex) transferList.push(sd.atomindex.buffer)\n const data = {\n sd: sd,\n p: p\n }\n callback(data, transferList)\n }\n}, [ VolumeSurface ])\n\nexport type VolumeSize = 'value'|'abs-value'|'value-min'|'deviation'\n/**\n * Volume\n */\nclass Volume {\n name: string\n path: string\n\n matrix: Matrix4\n normalMatrix: Matrix3\n inverseMatrix: Matrix4\n center: Vector3\n boundingBox: Box3\n\n nx: number\n ny: number\n nz: number\n data: Float32Array\n\n worker: Worker\n workerPool: WorkerPool\n _position: Float32Array\n _min: number|undefined\n _max: number|undefined\n _mean: number|undefined\n _rms: number|undefined\n _sum: number|undefined\n __box: Box3|undefined\n\n atomindex: Int32Array|undefined\n volsurf: VolumeSurface|undefined\n header: any\n /**\n * Make Volume instance\n * @param {String} name - volume name\n * @param {String} path - source path\n * @param {Float32array} data - volume 3d grid\n * @param {Integer} nx - x dimension of the 3d volume\n * @param {Integer} ny - y dimension of the 3d volume\n * @param {Integer} nz - z dimension of the 3d volume\n * @param {Int32Array} atomindex - atom indices corresponding to the cells in the 3d grid\n */\n constructor (name: string, path: string, data?: Float32Array, nx?: number, ny?: number, nz?: number, atomindex?: Int32Array) {\n this.name = name\n this.path = path\n\n this.matrix = new Matrix4()\n this.normalMatrix = new Matrix3()\n this.inverseMatrix = new Matrix4()\n this.center = new Vector3()\n this.boundingBox = new Box3()\n\n this.setData(data, nx, ny, nz, atomindex)\n }\n\n get type () { return 'Volume' }\n\n /**\n * set volume data\n * @param {Float32array} data - volume 3d grid\n * @param {Integer} nx - x dimension of the 3d volume\n * @param {Integer} ny - y dimension of the 3d volume\n * @param {Integer} nz - z dimension of the 3d volume\n * @param {Int32Array} atomindex - atom indices corresponding to the cells in the 3d grid\n * @return {undefined}\n */\n setData (data?: Float32Array, nx?: number, ny?: number, nz?: number, atomindex?: Int32Array) {\n this.nx = nx || 1\n this.ny = ny || 1\n this.nz = nz || 1\n\n this.data = data || new Float32Array(1)\n this.setAtomindex(atomindex)\n\n this._position = new Float32Array()\n\n delete this._min\n delete this._max\n delete this._mean\n delete this._rms\n\n if (this.worker) this.worker.terminate()\n }\n\n /**\n * Set statistics, which can be different from the data in this volume,\n * if this volume is a slice of a bigger volume\n * @param {Number|undefined} min - minimum value of the whole data set\n * @param {Number|undefined} max - maximum value of the whole data set\n * @param {Number|undefined} mean - average value of the whole data set\n * @param {Number|undefined} rms - sigma value of the whole data set\n */\n setStats (min: number|undefined, max: number|undefined, mean: number|undefined, rms: number|undefined) {\n this._min = min\n this._max = max\n this._mean = mean\n this._rms = rms\n }\n\n /**\n * set transformation matrix\n * @param {Matrix4} matrix - 4x4 transformation matrix\n * @return {undefined}\n */\n setMatrix (matrix: Matrix4) {\n this.matrix.copy(matrix)\n\n const bb = this.boundingBox\n const v = this.center // temporary re-purposing\n\n const x = this.nx - 1\n const y = this.ny - 1\n const z = this.nz - 1\n\n bb.makeEmpty()\n\n bb.expandByPoint(v.set(x, y, z))\n bb.expandByPoint(v.set(x, y, 0))\n bb.expandByPoint(v.set(x, 0, z))\n bb.expandByPoint(v.set(x, 0, 0))\n bb.expandByPoint(v.set(0, y, z))\n bb.expandByPoint(v.set(0, 0, z))\n bb.expandByPoint(v.set(0, y, 0))\n bb.expandByPoint(v.set(0, 0, 0))\n\n bb.applyMatrix4(this.matrix)\n bb.getCenter(this.center)\n\n // make normal matrix\n\n const me = this.matrix.elements\n const r0 = new Vector3(me[0], me[1], me[2])\n const r1 = new Vector3(me[4], me[5], me[6])\n const r2 = new Vector3(me[8], me[9], me[10])\n const cp = new Vector3()\n // [ r0 ] [ r1 x r2 ]\n // M3x3 = [ r1 ] N = [ r2 x r0 ]\n // [ r2 ] [ r0 x r1 ]\n const ne = this.normalMatrix.elements\n cp.crossVectors(r1, r2)\n ne[ 0 ] = cp.x\n ne[ 1 ] = cp.y\n ne[ 2 ] = cp.z\n cp.crossVectors(r2, r0)\n ne[ 3 ] = cp.x\n ne[ 4 ] = cp.y\n ne[ 5 ] = cp.z\n cp.crossVectors(r0, r1)\n ne[ 6 ] = cp.x\n ne[ 7 ] = cp.y\n ne[ 8 ] = cp.z\n\n this.inverseMatrix.getInverse(this.matrix)\n }\n\n /**\n * set atom indices\n * @param {Int32Array} atomindex - atom indices corresponding to the cells in the 3d grid\n * @return {undefined}\n */\n setAtomindex (atomindex?: Int32Array) {\n this.atomindex = atomindex\n }\n\n getBox (center: Vector3, size: number, target: Box3) {\n if (!target) target = new Box3()\n\n target.set(center, center)\n target.expandByScalar(size)\n target.applyMatrix4(this.inverseMatrix)\n\n target.min.round()\n target.max.round()\n\n return target\n }\n\n _getBox (center: Vector3|undefined, size: number) {\n if (!center || !size) return\n\n if (!this.__box) this.__box = new Box3()\n const box = this.getBox(center, size, this.__box)\n return [ box.min.toArray(), box.max.toArray() ]\n }\n\n _makeSurface (sd: any, isolevel: number, smooth: number) {\n const name = this.name + '@' + isolevel.toPrecision(2)\n const surface = new Surface(name, '', sd)\n surface.info.isolevel = isolevel\n surface.info.smooth = smooth\n surface.info.volume = this\n\n return surface\n }\n\n getSurface (isolevel: number, smooth: number, center: Vector3, size: number, contour: boolean, wrap: boolean = false) {\n isolevel = isNaN(isolevel) ? this.getValueForSigma(2) : isolevel\n smooth = defaults(smooth, 0)\n\n //\n\n if (this.volsurf === undefined) {\n this.volsurf = new (VolumeSurface as any)(\n this.data, this.nx, this.ny, this.nz, this.atomindex\n ) as VolumeSurface\n }\n\n const box = this._getBox(center, size)\n const sd = this.volsurf.getSurface(\n isolevel, smooth, box!, this.matrix.elements as unknown as Float32Array, contour, wrap\n )\n\n return this._makeSurface(sd, isolevel, smooth)\n }\n\n getSurfaceWorker (isolevel: number, smooth: number, center: Vector3, size: number, contour: boolean, wrap: boolean, callback: (s: Surface) => void) {\n isolevel = isNaN(isolevel) ? this.getValueForSigma(2) : isolevel\n smooth = smooth || 0\n\n //\n\n if (window.hasOwnProperty('Worker')) {\n if (this.workerPool === undefined) {\n this.workerPool = new WorkerPool('surf', 2)\n }\n\n const msg = {}\n const worker = this.workerPool.getNextWorker()\n\n if (worker!.postCount === 0) {\n Object.assign(msg, {\n args: [\n this.data, this.nx, this.ny, this.nz, this.atomindex\n ]\n })\n }\n\n Object.assign(msg, {\n params: {\n isolevel: isolevel,\n smooth: smooth,\n box: this._getBox(center, size),\n matrix: this.matrix.elements,\n contour: contour,\n wrap: wrap\n }\n })\n\n worker!.post(msg, undefined,\n (e: any) => {\n const sd = e.data.sd\n const p = e.data.p\n callback(this._makeSurface(sd, p.isolevel, p.smooth))\n },\n (e : string) => {\n console.warn(\n 'Volume.getSurfaceWorker error - trying without worker', e\n )\n const surface = this.getSurface(isolevel, smooth, center, size, contour, wrap)\n callback(surface)\n }\n )\n } else {\n const surface = this.getSurface(isolevel, smooth, center, size, contour, wrap)\n callback(surface)\n }\n }\n\n getValueForSigma (sigma: number) {\n return this.mean + defaults(sigma, 2) * this.rms\n }\n\n getSigmaForValue (value: number) {\n return (defaults(value, 0) - this.mean) / this.rms\n }\n\n get position () {\n if (!this._position) {\n const nz = this.nz\n const ny = this.ny\n const nx = this.nx\n const position = new Float32Array(nx * ny * nz * 3)\n\n let p = 0\n for (let z = 0; z < nz; ++z) {\n for (let y = 0; y < ny; ++y) {\n for (let x = 0; x < nx; ++x) {\n position[ p + 0 ] = x\n position[ p + 1 ] = y\n position[ p + 2 ] = z\n p += 3\n }\n }\n }\n\n applyMatrix4toVector3array(this.matrix.elements as unknown as Float32Array, position)\n this._position = position\n }\n\n return this._position\n }\n\n getDataAtomindex () {\n return this.atomindex\n }\n\n getDataPosition () {\n return this.position\n }\n\n getDataColor (params: ColormakerParameters & {scheme: string}) {\n const p = params || {}\n p.volume = this\n p.scale = p.scale || 'Spectral'\n p.domain = p.domain || [ this.min, this.max ]\n\n const colormaker = ColormakerRegistry.getScheme(p)\n\n const n = this.position.length / 3\n const array = new Float32Array(n * 3)\n\n // var atoms = p.structure.atoms;\n // var atomindex = this.atomindex;\n\n for (let i = 0; i < n; ++i) {\n colormaker.volumeColorToArray(i, array, i * 3)\n // a = atoms[ atomindex[ i ] ];\n // if( a ) colormaker.atomColorToArray( a, array, i * 3 );\n }\n\n return array\n }\n\n getDataPicking () {\n const picking = serialArray(this.position.length / 3)\n return new VolumePicker(picking, this)\n }\n\n getDataSize (size: VolumeSize|number, scale: number) {\n const data = this.data\n const n = this.position.length / 3\n let array\n\n switch (size) {\n case 'value':\n array = new Float32Array(data)\n break\n\n case 'abs-value':\n array = new Float32Array(data)\n for (let i = 0; i < n; ++i) {\n array[ i ] = Math.abs(array[ i ])\n }\n break\n\n case 'value-min': {\n array = new Float32Array(data)\n const min = this.min\n for (let i = 0; i < n; ++i) {\n array[ i ] -= min\n }\n break\n }\n\n case 'deviation':\n array = new Float32Array(data)\n break\n\n default:\n array = uniformArray(n, size)\n break\n }\n\n if (scale !== 1.0) {\n for (let i = 0; i < n; ++i) {\n array[ i ] *= scale\n }\n }\n\n return array\n }\n\n get min () {\n if (this._min === undefined) {\n this._min = arrayMin(this.data)\n }\n return this._min\n }\n\n get max () {\n if (this._max === undefined) {\n this._max = arrayMax(this.data)\n }\n return this._max\n }\n\n get sum () {\n if (this._sum === undefined) {\n this._sum = arraySum(this.data)\n }\n return this._sum\n }\n\n get mean () {\n if (this._mean === undefined) {\n this._mean = arrayMean(this.data)\n }\n return this._mean\n }\n\n get rms () {\n if (this._rms === undefined) {\n this._rms = arrayRms(this.data)\n }\n return this._rms\n }\n\n clone () {\n const vol = new Volume(\n this.name,\n this.path,\n\n this.data,\n\n this.nx,\n this.ny,\n this.nz,\n\n this.atomindex\n )\n\n vol.matrix.copy(this.matrix)\n vol.header = Object.assign({}, this.header)\n\n return vol\n }\n\n dispose () {\n if (this.workerPool) this.workerPool.terminate()\n }\n}\n\nexport default Volume\n","/**\n * @file Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport {\n Color, Vector3, Matrix4,\n FrontSide, BackSide, DoubleSide,\n // VertexColors,\n NoBlending,\n BufferGeometry, BufferAttribute,\n UniformsUtils, UniformsLib, Uniform,\n Group, LineSegments, Points, Mesh, Object3D,\n ShaderMaterial\n} from 'three'\n\nimport { Log } from '../globals'\nimport { createParams, getTypedArray, getUintArray } from '../utils'\nimport { GenericColor, NumberArray } from '../types'\nimport { getShader, ShaderDefines } from '../shader/shader-utils'\nimport { serialArray } from '../math/array-utils'\nimport { Picker } from '../utils/picker'\n\nexport type BufferSide = 'front'|'back'|'double'\n\nfunction getThreeSide (side: BufferSide) {\n if (side === 'front') {\n return FrontSide\n } else if (side === 'back') {\n return BackSide\n } else if (side === 'double') {\n return DoubleSide\n } else {\n return DoubleSide\n }\n}\n\nconst itemSize = {\n 'f': 1, 'v2': 2, 'v3': 3, 'c': 3\n}\n\nfunction setObjectMatrix (object: Object3D, matrix: Matrix4) {\n object.matrix.copy(matrix)\n object.matrix.decompose(object.position, object.quaternion, object.scale)\n object.matrixWorldNeedsUpdate = true\n}\n\nexport type BufferTypes = 'picking'|'background'\nexport type BufferMaterials = 'material'|'wireframeMaterial'|'pickingMaterial'\n\nexport interface _BufferAttribute {\n type: 'f'|'v2'|'v3'|'c'\n value?: NumberArray\n}\n\nexport type Uniforms = { [k: string]: Uniform|{ value: any } }\n\nexport const BufferDefaultParameters = {\n opaqueBack: false,\n side: 'double' as BufferSide, // which triangle sides to render\n opacity: 1.0, // translucency: 1 is fully opaque, 0 is fully transparent\n depthWrite: true,\n clipNear: 0, // position of camera near/front clipping plane in percent of scene bounding box\n clipRadius: 0,\n clipCenter: new Vector3(),\n flatShaded: false, // render flat shaded\n wireframe: false, // render as wireframe\n roughness: 0.4, // how rough the material is, between 0 and 1\n metalness: 0.0, // how metallic the material is, between 0 and 1\n diffuse: 0xffffff, // diffuse color for lighting\n diffuseInterior: false,\n useInteriorColor: false, // render back-side with interior color\n interiorColor: 0xdddddd, // interior color\n interiorDarkening: 0, // interior darkening factor\n forceTransparent: false, // force the material to allow transparency\n matrix: new Matrix4(), // additional transformation matrix\n disablePicking: false, // disable picking\n sortParticles: false,\n background: false\n}\nexport type BufferParameters = Omit & { diffuse: GenericColor; interiorColor: GenericColor }\n\nexport const BufferParameterTypes = {\n opaqueBack: { updateShader: true },\n side: { updateShader: true, property: true },\n opacity: { uniform: true },\n depthWrite: { property: true },\n clipNear: { updateShader: true, property: true },\n clipRadius: { updateShader: true, uniform: true },\n clipCenter: { uniform: true },\n flatShaded: { updateShader: true },\n background: { updateShader: true },\n wireframe: { updateVisibility: true },\n roughness: { uniform: true },\n metalness: { uniform: true },\n diffuse: { uniform: true },\n diffuseInterior: { updateShader: true },\n useInteriorColor: { updateShader: true },\n interiorColor: { uniform: true },\n interiorDarkening: { uniform: true },\n matrix: {}\n}\n\nexport interface BufferData {\n position?: Float32Array\n position1?: Float32Array // TODO\n color?: Float32Array\n index?: Uint32Array|Uint16Array\n normal?: Float32Array\n\n picking?: Picker\n primitiveId?: Float32Array\n}\n\n/**\n * Buffer class. Base class for buffers.\n * @interface\n */\nclass Buffer {\n parameterTypes = BufferParameterTypes\n get defaultParameters() { return BufferDefaultParameters }\n parameters: BufferParameters\n uniforms: Uniforms\n pickingUniforms: Uniforms\n\n private _positionDataSize: number\n\n geometry = new BufferGeometry()\n indexVersion = 0\n wireframeIndexVersion = -1\n group = new Group()\n wireframeGroup = new Group()\n pickingGroup = new Group()\n\n vertexShader = ''\n fragmentShader = ''\n isImpostor = false\n isText = false\n isSurface = false\n isPoint = false\n isLine = false\n dynamic = true\n visible = true\n\n picking?: Picker\n\n material: ShaderMaterial\n wireframeMaterial: ShaderMaterial\n pickingMaterial: ShaderMaterial\n\n wireframeIndex?: Uint32Array|Uint16Array\n wireframeIndexCount = 0\n wireframeGeometry?: BufferGeometry\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Uint32Array|Uint16Array} data.index - triangle indices\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} params - parameters object\n */\n constructor (data: BufferData, params: Partial = {}) {\n this.parameters = createParams(params, this.defaultParameters)\n\n this.uniforms = UniformsUtils.merge([\n UniformsLib.common,\n {\n fogColor: { value: new Color(0x000000) },\n fogNear: { value: 0.0 },\n fogFar: { value: 0.0 },\n opacity: { value: this.parameters.opacity },\n clipNear: { value: 0.0 },\n clipRadius: { value: this.parameters.clipRadius },\n clipCenter: { value: this.parameters.clipCenter }\n },\n {\n emissive: { value: new Color(0x000000) },\n roughness: { value: this.parameters.roughness },\n metalness: { value: this.parameters.metalness },\n interiorColor: { value: new Color(this.parameters.interiorColor) },\n interiorDarkening: { value: this.parameters.interiorDarkening },\n },\n UniformsLib.lights\n ])\n\n this.uniforms.diffuse.value.set(this.parameters.diffuse)\n\n this.pickingUniforms = {\n clipNear: { value: 0.0 },\n objectId: { value: 0 },\n opacity: { value: this.parameters.opacity }\n }\n\n //\n\n const position = data.position || data.position1\n this._positionDataSize = position ? position.length / 3 : 0\n\n if (!data.primitiveId) {\n data.primitiveId = serialArray(this._positionDataSize)\n }\n\n this.addAttributes({\n position: { type: 'v3', value: data.position },\n color: { type: 'c', value: data.color },\n primitiveId: { type: 'f', value: data.primitiveId }\n })\n\n if (params.matrix) {\n this.matrix = params.matrix\n }\n\n if (data.index) {\n this.initIndex(data.index)\n }\n this.picking = data.picking\n\n this.makeWireframeGeometry()\n }\n\n set matrix (m) {\n this.setMatrix(m)\n }\n get matrix () {\n return this.group.matrix.clone()\n }\n\n get transparent () {\n return this.parameters.opacity < 1 || this.parameters.forceTransparent\n }\n\n get size () {\n return this._positionDataSize\n }\n\n get attributeSize () {\n return this.size\n }\n\n get pickable () {\n return !!this.picking && !this.parameters.disablePicking\n }\n\n setMatrix (m: Matrix4) {\n setObjectMatrix(this.group, m)\n setObjectMatrix(this.wireframeGroup, m)\n setObjectMatrix(this.pickingGroup, m)\n }\n\n initIndex (index: Uint32Array|Uint16Array) {\n this.geometry.setIndex(\n new BufferAttribute(index, 1)\n )\n const nindex = this.geometry.getIndex();\n if (!nindex) { Log.error('Index is null'); return; }\n nindex.setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n }\n\n makeMaterial () {\n const side = getThreeSide(this.parameters.side)\n\n const m = new ShaderMaterial({\n uniforms: this.uniforms,\n vertexShader: '',\n fragmentShader: '',\n depthTest: true,\n transparent: this.transparent,\n depthWrite: this.parameters.depthWrite,\n lights: true,\n fog: true,\n side: side\n })\n m.vertexColors = true\n m.extensions.derivatives = true\n m.extensions.fragDepth = this.isImpostor\n\n const wm = new ShaderMaterial({\n uniforms: this.uniforms,\n vertexShader: '',\n fragmentShader: '',\n depthTest: true,\n transparent: this.transparent,\n depthWrite: this.parameters.depthWrite,\n lights: false,\n fog: true,\n side: side\n })\n wm.vertexColors = true\n\n const pm = new ShaderMaterial({\n uniforms: this.pickingUniforms,\n vertexShader: '',\n fragmentShader: '',\n depthTest: true,\n transparent: false,\n depthWrite: this.parameters.depthWrite,\n lights: false,\n fog: false,\n side: side,\n blending: NoBlending\n })\n pm.vertexColors = true\n pm.extensions.fragDepth = this.isImpostor\n\n ;(m as any).clipNear = this.parameters.clipNear\n ;(wm as any).clipNear = this.parameters.clipNear\n ;(pm as any).clipNear = this.parameters.clipNear\n\n this.material = m\n this.wireframeMaterial = wm\n this.pickingMaterial = pm\n\n // also sets vertexShader/fragmentShader\n this.updateShader()\n }\n\n makeWireframeGeometry () {\n this.makeWireframeIndex()\n\n const geometry = this.geometry\n const wireframeIndex = this.wireframeIndex\n const wireframeGeometry = new BufferGeometry()\n\n wireframeGeometry.attributes = geometry.attributes\n if (wireframeIndex) {\n wireframeGeometry.setIndex(\n new BufferAttribute(wireframeIndex, 1).setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n wireframeGeometry.setDrawRange(0, this.wireframeIndexCount)\n }\n\n this.wireframeGeometry = wireframeGeometry\n }\n\n makeWireframeIndex () {\n const edges: number[][] = []\n\n function checkEdge (a: number, b: number) {\n if (a > b) {\n const tmp = a\n a = b\n b = tmp\n }\n\n const list = edges[ a ]\n\n if (list === undefined) {\n edges[ a ] = [ b ]\n return true\n } else if (!list.includes(b)) {\n list.push(b)\n return true\n }\n\n return false\n }\n\n const geometry = this.geometry\n const index = geometry.index\n\n if (!this.parameters.wireframe) {\n this.wireframeIndex = new Uint16Array(0)\n this.wireframeIndexCount = 0\n } else if (index) {\n const array = index.array\n let n = array.length\n if (geometry.drawRange.count !== Infinity) {\n n = geometry.drawRange.count\n }\n let wireframeIndex\n if (this.wireframeIndex && this.wireframeIndex.length > n * 2) {\n wireframeIndex = this.wireframeIndex\n } else {\n const count = (geometry.attributes as any).position.count // TODO\n wireframeIndex = getUintArray(n * 2, count)\n }\n\n let j = 0\n edges.length = 0\n\n for (let i = 0; i < n; i += 3) {\n const a = array[ i + 0 ]\n const b = array[ i + 1 ]\n const c = array[ i + 2 ]\n\n if (checkEdge(a, b)) {\n wireframeIndex[ j + 0 ] = a\n wireframeIndex[ j + 1 ] = b\n j += 2\n }\n if (checkEdge(b, c)) {\n wireframeIndex[ j + 0 ] = b\n wireframeIndex[ j + 1 ] = c\n j += 2\n }\n if (checkEdge(c, a)) {\n wireframeIndex[ j + 0 ] = c\n wireframeIndex[ j + 1 ] = a\n j += 2\n }\n }\n\n this.wireframeIndex = wireframeIndex\n this.wireframeIndexCount = j\n this.wireframeIndexVersion = this.indexVersion\n } else {\n const n = (geometry.attributes as any).position.count // TODO\n\n let wireframeIndex\n if (this.wireframeIndex && this.wireframeIndex.length > n * 2) {\n wireframeIndex = this.wireframeIndex\n } else {\n wireframeIndex = getUintArray(n * 2, n)\n }\n\n for (let i = 0, j = 0; i < n; i += 3) {\n wireframeIndex[ j + 0 ] = i\n wireframeIndex[ j + 1 ] = i + 1\n wireframeIndex[ j + 2 ] = i + 1\n wireframeIndex[ j + 3 ] = i + 2\n wireframeIndex[ j + 4 ] = i + 2\n wireframeIndex[ j + 5 ] = i\n\n j += 6\n }\n\n this.wireframeIndex = wireframeIndex\n this.wireframeIndexCount = n * 2\n this.wireframeIndexVersion = this.indexVersion\n }\n }\n\n updateWireframeIndex () {\n if (!this.wireframeGeometry || !this.wireframeIndex) return\n\n this.wireframeGeometry.setDrawRange(0, Infinity)\n if (this.wireframeIndexVersion < this.indexVersion) this.makeWireframeIndex()\n\n if (this.wireframeGeometry.index &&\n this.wireframeIndex.length > this.wireframeGeometry.index.array.length) {\n this.wireframeGeometry.setIndex(\n new BufferAttribute(this.wireframeIndex, 1).setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n } else {\n const index = this.wireframeGeometry.getIndex()\n if (!index) { Log.error('Index is null'); return; }\n index.set(this.wireframeIndex)\n index.needsUpdate = this.wireframeIndexCount > 0\n index.updateRange.count = this.wireframeIndexCount\n }\n\n this.wireframeGeometry.setDrawRange(0, this.wireframeIndexCount)\n }\n\n getRenderOrder () {\n let renderOrder = 0\n\n if (this.isText) {\n renderOrder = 1\n } else if (this.transparent) {\n if (this.isSurface) {\n renderOrder = 3\n } else {\n renderOrder = 2\n }\n }\n\n return renderOrder\n }\n\n _getMesh (materialName: BufferMaterials) {\n if (!this.material) this.makeMaterial()\n\n const g = this.geometry\n const m = this[ materialName ]\n\n let mesh\n\n if (this.isLine) {\n mesh = new LineSegments(g, m)\n } else if (this.isPoint) {\n mesh = new Points(g, m)\n } else {\n mesh = new Mesh(g, m)\n }\n\n mesh.frustumCulled = false\n mesh.renderOrder = this.getRenderOrder()\n\n return mesh\n }\n\n getMesh () {\n return this._getMesh('material')\n }\n\n getWireframeMesh () {\n let mesh\n\n if (!this.material) this.makeMaterial()\n if (!this.wireframeGeometry) this.makeWireframeGeometry()\n\n mesh = new LineSegments(\n this.wireframeGeometry, this.wireframeMaterial\n )\n\n mesh.frustumCulled = false\n mesh.renderOrder = this.getRenderOrder()\n\n return mesh\n }\n\n getPickingMesh () {\n return this._getMesh('pickingMaterial')\n }\n\n getShader (name: string, type?: BufferTypes) {\n return getShader(name, this.getDefines(type))\n }\n\n getVertexShader (type?: BufferTypes) {\n return this.getShader(this.vertexShader, type)\n }\n\n getFragmentShader (type?: BufferTypes) {\n return this.getShader(this.fragmentShader, type)\n }\n\n getDefines (type?: BufferTypes) {\n const defines: ShaderDefines = {}\n\n if (this.parameters.clipNear) {\n defines.NEAR_CLIP = 1\n }\n\n if (this.parameters.clipRadius) {\n defines.RADIUS_CLIP = 1\n }\n\n if (type === 'picking') {\n defines.PICKING = 1\n } else {\n if (type === 'background' || this.parameters.background) {\n defines.NOLIGHT = 1\n }\n if (this.parameters.flatShaded) {\n defines.FLAT_SHADED = 1\n }\n if (this.parameters.opaqueBack) {\n defines.OPAQUE_BACK = 1\n }\n if (this.parameters.diffuseInterior) {\n defines.DIFFUSE_INTERIOR = 1\n }\n if (this.parameters.useInteriorColor) {\n defines.USE_INTERIOR_COLOR = 1\n }\n }\n\n return defines\n }\n\n getParameters () {\n return this.parameters\n }\n\n addUniforms (uniforms: Uniforms) {\n this.uniforms = UniformsUtils.merge(\n [ this.uniforms, uniforms ]\n )\n\n this.pickingUniforms = UniformsUtils.merge(\n [ this.pickingUniforms, uniforms ]\n )\n }\n\n addAttributes (attributes: { [k: string]: _BufferAttribute }) {\n for (let name in attributes) {\n let buf\n const a = attributes[ name ]\n const arraySize = this.attributeSize * itemSize[ a.type ]\n\n if (a.value) {\n if (arraySize !== a.value.length) {\n Log.error('attribute value has wrong length', name)\n }\n buf = a.value\n } else {\n buf = getTypedArray('float32', arraySize)\n }\n\n this.geometry.setAttribute(\n name,\n new BufferAttribute(buf, itemSize[ a.type ]).setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n }\n }\n\n updateRenderOrder () {\n const renderOrder = this.getRenderOrder()\n function setRenderOrder (mesh: Object3D) {\n mesh.renderOrder = renderOrder\n }\n\n this.group.children.forEach(setRenderOrder)\n if (this.pickingGroup) {\n this.pickingGroup.children.forEach(setRenderOrder)\n }\n }\n\n updateShader () {\n const m = this.material\n const wm = this.wireframeMaterial\n const pm = this.pickingMaterial\n\n m.vertexShader = this.getVertexShader()\n m.fragmentShader = this.getFragmentShader()\n m.needsUpdate = true\n\n wm.vertexShader = this.getShader('Line.vert')\n wm.fragmentShader = this.getShader('Line.frag')\n wm.needsUpdate = true\n\n pm.vertexShader = this.getVertexShader('picking')\n pm.fragmentShader = this.getFragmentShader('picking')\n pm.needsUpdate = true\n }\n\n /**\n * Set buffer parameters\n * @param {BufferParameters} params - buffer parameters object\n * @return {undefined}\n */\n setParameters (params: Partial) {\n const p = params as any\n const pt = this.parameterTypes as any\n const pv = this.parameters as any\n\n const propertyData: { [k: string]: any } = {}\n const uniformData: { [k: string]: any } = {}\n let doShaderUpdate = false\n let doVisibilityUpdate = false\n\n for (const name in p) {\n const value = p[ name ]\n\n if (value === undefined) continue\n pv[ name ] = value\n\n if (pt[ name ] === undefined) continue\n\n if (pt[ name ].property) {\n if (pt[ name ].property !== true) {\n propertyData[ pt[ name ].property as any ] = value\n } else {\n propertyData[ name ] = value\n }\n }\n\n if (pt[ name ].uniform) {\n if (pt[ name ].uniform !== true) {\n uniformData[ pt[ name ].uniform as any ] = value\n } else {\n uniformData[ name ] = value\n }\n }\n\n if (pt[ name ].updateShader) {\n doShaderUpdate = true\n }\n\n if (pt[ name ].updateVisibility) {\n doVisibilityUpdate = true\n }\n\n if (this.dynamic && name === 'wireframe' && value === true) {\n this.updateWireframeIndex()\n }\n\n if (name === 'forceTransparent') {\n propertyData.transparent = this.transparent\n }\n\n if (name === 'matrix') {\n this.matrix = value\n }\n }\n\n this.setProperties(propertyData)\n this.setUniforms(uniformData)\n if (doShaderUpdate) this.updateShader()\n if (doVisibilityUpdate) this.setVisibility(this.visible)\n }\n\n /**\n * Sets buffer attributes\n * @param {Object} data - An object where the keys are the attribute names\n * and the values are the attribute data.\n * @example\n * var buffer = new Buffer();\n * buffer.setAttributes({ attrName: attrData });\n */\n setAttributes (data: any) { // TODO\n const geometry = this.geometry\n const attributes = geometry.attributes as any // TODO\n\n for (const name in data) {\n if (name === 'picking') continue\n\n const array = data[ name ]\n const length = array.length\n\n if (name === 'index') {\n const index = geometry.getIndex()\n if (!index) { Log.error('Index is null'); continue; }\n geometry.setDrawRange(0, Infinity)\n\n if (length > index.array.length) {\n geometry.setIndex(\n new BufferAttribute(array, 1)\n .setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n } else {\n index.set(array)\n index.count = length\n index.needsUpdate = length > 0\n index.updateRange.count = length\n geometry.setDrawRange(0, length)\n }\n\n this.indexVersion++\n if (this.parameters.wireframe) this.updateWireframeIndex()\n } else {\n const attribute = attributes[ name ]\n\n if (length > attribute.array.length) {\n geometry.setAttribute(\n name,\n new BufferAttribute(array, attribute.itemSize)\n .setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n } else {\n attributes[ name ].set(array)\n attributes[ name ].needsUpdate = length > 0\n attributes[ name ].updateRange.count = length\n }\n }\n }\n }\n\n setUniforms (data: any) { // TODO\n if (!data) return\n\n const u = this.material.uniforms\n const wu = this.wireframeMaterial.uniforms\n const pu = this.pickingMaterial.uniforms\n\n for (let name in data) {\n if (name === 'opacity') {\n this.setProperties({ transparent: this.transparent })\n }\n\n if (u[ name ] !== undefined) {\n if (u[ name ].value.isVector3) {\n u[ name ].value.copy(data[ name ])\n } else if (u[ name ].value.set) {\n u[ name ].value.set(data[ name ])\n } else {\n u[ name ].value = data[ name ]\n }\n }\n\n if (wu[ name ] !== undefined) {\n if (wu[ name ].value.isVector3) {\n wu[ name ].value.copy(data[ name ])\n } else if (wu[ name ].value.set) {\n wu[ name ].value.set(data[ name ])\n } else {\n wu[ name ].value = data[ name ]\n }\n }\n\n if (pu[ name ] !== undefined) {\n if (pu[ name ].value.isVector3) {\n pu[ name ].value.copy(data[ name ])\n } else if (pu[ name ].value.set) {\n pu[ name ].value.set(data[ name ])\n } else {\n pu[ name ].value = data[ name ]\n }\n }\n }\n }\n\n setProperties (data: any) { // TODO\n if (!data) return\n\n const m = this.material\n const wm = this.wireframeMaterial\n const pm = this.pickingMaterial\n\n for (const _name in data) {\n const name = _name as 'side'|'transparent' // TODO\n\n let value = data[ name ]\n\n if (name === 'transparent') {\n this.updateRenderOrder()\n } else if (name === 'side') {\n value = getThreeSide(value)\n }\n\n (m[ name ] as any) = value;\n (wm[ name ] as any) = value;\n (pm[ name ] as any) = value\n }\n\n m.needsUpdate = true\n wm.needsUpdate = true\n pm.needsUpdate = true\n }\n\n /**\n * Set buffer visibility\n * @param {Boolean} value - visibility value\n * @return {undefined}\n */\n setVisibility (value: boolean) {\n this.visible = value\n\n if (this.parameters.wireframe) {\n this.group.visible = false\n this.wireframeGroup.visible = value\n if (this.pickable) {\n this.pickingGroup.visible = false\n }\n } else {\n this.group.visible = value\n this.wireframeGroup.visible = false\n if (this.pickable) {\n this.pickingGroup.visible = value\n }\n }\n }\n\n /**\n * Free buffer resources\n * @return {undefined}\n */\n dispose () {\n if (this.material) this.material.dispose()\n if (this.wireframeMaterial) this.wireframeMaterial.dispose()\n if (this.pickingMaterial) this.pickingMaterial.dispose()\n\n this.geometry.dispose()\n if (this.wireframeGeometry) this.wireframeGeometry.dispose()\n }\n\n /**\n * Customize JSON serialization to avoid circular references\n */\n toJSON () {\n var result: any = {};\n for (var x in this) {\n if (x !== \"group\" && x !== \"wireframeGroup\" && x != \"pickingGroup\"\n && x !== \"picking\") {\n result[x] = this[x];\n }\n }\n return result;\n }\n}\n\nexport default Buffer\n","/**\n * @file Mesh Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport '../shader/Mesh.vert'\nimport '../shader/Mesh.frag'\n\nimport Buffer, { BufferParameters, BufferData } from './buffer'\n\n/**\n * Mesh buffer. Draws a triangle mesh.\n *\n * @example\n * var meshBuffer = new MeshBuffer({\n * position: new Float32Array(\n * [ 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1 ]\n * ),\n * color: new Float32Array(\n * [ 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0 ]\n * )\n * });\n */\nclass MeshBuffer extends Buffer {\n vertexShader = 'Mesh.vert'\n fragmentShader = 'Mesh.frag'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} [data.index] - triangle indices\n * @param {Float32Array} [data.normal] - radii\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: BufferData, params: Partial = {}) {\n super(data, params)\n\n this.addAttributes({\n 'normal': { type: 'v3', value: data.normal }\n })\n\n if (data.normal === undefined) {\n this.geometry.computeVertexNormals()\n }\n }\n}\n\nexport default MeshBuffer\n","/**\n * @file Surface Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport MeshBuffer from './mesh-buffer'\n\n/**\n * Surface buffer. Like a {@link MeshBuffer}, but with `.isSurface` set to `true`.\n */\nclass SurfaceBuffer extends MeshBuffer {\n isSurface = true\n}\n\nexport default SurfaceBuffer\n","/**\n * @file Double Sided Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { Group, BufferGeometry, Object3D, Mesh, LineSegments, Vector3, Matrix4 } from 'three'\n\nimport Buffer, { BufferSide } from './buffer'\nimport { Picker } from '../utils/picker'\n\nfunction setVisibilityTrue (m: Object3D) { m.visible = true }\nfunction setVisibilityFalse (m: Object3D) { m.visible = false }\n\n/**\n * A double-sided mesh buffer. Takes a buffer and renders the front and\n * the back as seperate objects to avoid some artifacts when rendering\n * transparent meshes. Also allows to render the back of a mesh opaque\n * while the front is transparent.\n * @implements {Buffer}\n *\n * @example\n * var sphereGeometryBuffer = new SphereGeometryBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n * var doubleSidedBuffer = new DoubleSidedBuffer(sphereGeometryBuffer);\n */\nclass DoubleSidedBuffer {\n size: number\n side: BufferSide\n visible: boolean\n wireframe: boolean\n geometry: BufferGeometry\n\n picking?: Picker\n\n group = new Group()\n wireframeGroup = new Group()\n pickingGroup = new Group()\n\n frontMeshes: (Mesh|LineSegments)[] = []\n backMeshes: (Mesh|LineSegments)[] = []\n\n buffer: Buffer\n frontBuffer: Buffer\n backBuffer: Buffer\n\n /**\n * Create a double sided buffer\n * @param {Buffer} buffer - the buffer to be rendered double-sided\n */\n constructor (buffer: Buffer) {\n this.size = buffer.size\n this.side = buffer.parameters.side\n this.visible = buffer.visible\n this.geometry = buffer.geometry\n this.picking = buffer.picking\n\n this.group = new Group()\n this.wireframeGroup = new Group()\n this.pickingGroup = new Group()\n\n // requires Group objects to be present\n this.matrix = buffer.matrix\n\n const frontBuffer = buffer\n const backBuffer = new (buffer as any).constructor({ // TODO\n position: new Float32Array(0)\n }) as Buffer\n\n frontBuffer.makeMaterial()\n backBuffer.makeMaterial()\n\n backBuffer.picking = buffer.picking\n backBuffer.geometry = buffer.geometry\n backBuffer.wireframeGeometry = buffer.wireframeGeometry\n backBuffer.setParameters(buffer.getParameters())\n backBuffer.updateShader()\n\n frontBuffer.setParameters({\n side: 'front'\n })\n backBuffer.setParameters({\n side: 'back',\n opacity: backBuffer.parameters.opacity\n })\n\n this.buffer = buffer\n this.frontBuffer = frontBuffer\n this.backBuffer = backBuffer\n }\n\n set matrix (m) {\n Buffer.prototype.setMatrix.call(this, m)\n }\n get matrix () {\n return this.group.matrix.clone()\n }\n\n get pickable () {\n return !!this.picking && !this.parameters.disablePicking\n }\n\n get parameters () {\n return this.buffer.parameters\n }\n\n getParameters () {\n const p = Object.assign({}, this.buffer.parameters)\n p.side = this.side\n return p\n }\n\n getMesh (picking: boolean) {\n let front, back\n\n if (picking) {\n back = this.backBuffer.getPickingMesh()\n front = this.frontBuffer.getPickingMesh()\n } else {\n back = this.backBuffer.getMesh()\n front = this.frontBuffer.getMesh()\n }\n\n this.frontMeshes.push(front)\n this.backMeshes.push(back)\n\n this.setParameters({ side: this.side })\n\n return new Group().add(back, front)\n }\n\n getWireframeMesh () {\n return this.buffer.getWireframeMesh()\n }\n\n getPickingMesh () {\n return this.getMesh(true)\n }\n\n setAttributes (data: any) { // TODO\n this.buffer.setAttributes(data)\n }\n\n setParameters (data: any) { // TODO\n data = Object.assign({}, data)\n\n if (data.side === 'front') {\n this.frontMeshes.forEach(setVisibilityTrue)\n this.backMeshes.forEach(setVisibilityFalse)\n } else if (data.side === 'back') {\n this.frontMeshes.forEach(setVisibilityFalse)\n this.backMeshes.forEach(setVisibilityTrue)\n } else if (data.side === 'double') {\n this.frontMeshes.forEach(setVisibilityTrue)\n this.backMeshes.forEach(setVisibilityTrue)\n }\n\n if (data.side !== undefined) {\n this.side = data.side\n }\n delete data.side\n\n if (data.matrix !== undefined) {\n this.matrix = data.matrix\n }\n delete data.matrix\n\n this.frontBuffer.setParameters(data)\n\n if (data.wireframe !== undefined) {\n this.wireframe = data.wireframe\n this.setVisibility(this.visible)\n }\n delete data.wireframe\n\n this.backBuffer.setParameters(data)\n }\n\n setVisibility (value: boolean) {\n this.visible = value\n\n if (this.parameters.wireframe) {\n this.group.visible = false\n this.wireframeGroup.visible = value\n if (this.pickable) {\n this.pickingGroup.visible = false\n }\n } else {\n this.group.visible = value\n this.wireframeGroup.visible = false\n if (this.pickable) {\n this.pickingGroup.visible = value\n }\n }\n }\n\n dispose () {\n this.frontBuffer.dispose()\n this.backBuffer.dispose()\n }\n\n /**\n * Customize JSON serialization to avoid circular references.\n * Only export simple params which could be useful.\n */\n toJSON () {\n var result: any = {};\n for (var x in this) {\n if (['side', 'size', 'visible', 'matrix', 'parameters'].includes(x)) {\n result[x] = this[x];\n }\n }\n return result;\n }\n}\n\nexport default DoubleSidedBuffer\n","/**\n * @file Contour Buffer\n * @author Fred ludlow \n * @private\n */\n\nimport '../shader/Line.vert'\nimport '../shader/Line.frag'\n\nimport Buffer from './buffer'\n\n/**\n * Contour buffer. A buffer that draws lines (instead of triangle meshes).\n */\nclass ContourBuffer extends Buffer {\n isLine = true\n vertexShader = 'Line.vert'\n fragmentShader = 'Line.frag'\n}\n\nexport default ContourBuffer\n","/**\n * @file Surface Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3, Box3 } from 'three'\n\nimport { defaults } from '../utils'\nimport Representation, { RepresentationParameters } from './representation'\nimport Volume from '../surface/volume'\nimport SurfaceBuffer from '../buffer/surface-buffer'\nimport DoubleSidedBuffer from '../buffer/doublesided-buffer'\nimport ContourBuffer from '../buffer/contour-buffer'\nimport Surface from '../surface/surface';\nimport Viewer from '../viewer/viewer';\nimport {SurfaceData} from '../surface/surface'\n// @ts-ignore: unused import ColormakerParameters required for declaration only\nimport { ColormakerParameters } from '../color/colormaker';\nexport type SurfaceDataFields = {position: boolean, color: boolean, index: boolean, normal: boolean, radius: boolean}\n\n/**\n * Surface representation parameter object. Extends {@link RepresentationParameters}\n *\n * @typedef {Object} SurfaceRepresentationParameters - surface representation parameters\n *\n * @property {String} isolevelType - Meaning of the isolevel value. Either *value* for the literal value or *sigma* as a factor of the sigma of the data. For volume data only.\n * @property {Float} isolevel - The value at which to create the isosurface. For volume data only.\n * @property {Boolean} negateIsolevel - For volume data only.\n * @property {Boolean} isolevelScroll - For volume data only\n * @property {Integer} smooth - How many iterations of laplacian smoothing after surface triangulation. For volume data only.\n * @property {Boolean} background - Render the surface in the background, unlit.\n * @property {Boolean} opaqueBack - Render the back-faces (where normals point away from the camera) of the surface opaque, ignoring the transparency parameter.\n * @property {Integer} boxSize - Size of the box to triangulate volume data in. Set to zero to triangulate the whole volume. For volume data only.\n * @property {Boolean} useWorker - Weather or not to triangulate the volume asynchronously in a Web Worker. For volume data only.\n * @property {Boolean} wrap - Wrap volume data around the edges; use in conjuction with boxSize but not larger than the volume dimension. For volume data only.\n */\nexport interface SurfaceRepresentationParameters extends RepresentationParameters {\n isolevelType: 'value'|'sigma'\n isolevel: number\n smooth: number\n background: boolean\n opaqueBack: boolean\n boxSize: number\n useWorker: boolean\n wrap: boolean\n}\n/**\n * Surface representation\n */\n/**\n * Create Surface representation object\n * @param {Surface|Volume} surface - the surface or volume to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {SurfaceRepresentationParameters} params - surface representation parameters\n */\nclass SurfaceRepresentation extends Representation {\n protected surface: Surface|Volume|undefined\n protected volume: Volume|undefined\n protected boxCenter: Vector3\n protected __boxCenter: Vector3\n protected box: Box3\n protected __box: Box3\n protected _position: Vector3\n protected isolevelType: 'value'|'sigma'\n protected isolevel: number\n protected negateIsolevel: boolean\n protected isolevelScroll: boolean\n protected smooth: number\n protected background: boolean\n protected opaqueBack: boolean\n protected boxSize: number\n protected inverseMatrix: Matrix4\n protected colorVolume: Volume\n protected contour: boolean\n protected useWorker: boolean\n protected wrap: boolean\n\n protected __isolevel: number\n protected __smooth: number\n protected __contour: boolean\n protected __wrap: boolean\n protected __boxSize: number\n\n setBox: () => void\n\n constructor (surface: Surface, viewer: Viewer, params: Partial) {\n super(surface, viewer, params)\n\n this.type = 'surface'\n\n this.parameters = Object.assign({\n\n isolevelType: {\n type: 'select',\n options: {\n 'value': 'value', 'sigma': 'sigma'\n }\n },\n isolevel: {\n type: 'number', precision: 2, max: 1000, min: -1000\n },\n negateIsolevel: {\n type: 'boolean'\n },\n isolevelScroll: {\n type: 'boolean'\n },\n smooth: {\n type: 'integer', precision: 1, max: 10, min: 0\n },\n background: {\n type: 'boolean', rebuild: true // FIXME\n },\n opaqueBack: {\n type: 'boolean', buffer: true\n },\n boxSize: {\n type: 'integer', precision: 1, max: 100, min: 0\n },\n colorVolume: {\n type: 'hidden'\n },\n contour: {\n type: 'boolean', rebuild: true\n },\n useWorker: {\n type: 'boolean', rebuild: true\n },\n wrap: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters)\n\n if (surface instanceof Volume) {\n this.surface = undefined\n this.volume = surface\n } else {\n this.surface = surface\n this.volume = undefined\n }\n\n this.boxCenter = new Vector3()\n this.__boxCenter = new Vector3()\n this.box = new Box3()\n this.__box = new Box3()\n\n this._position = new Vector3()\n this.inverseMatrix = new Matrix4()\n\n this.setBox = function setBox () {\n this._position.copy(viewer.translationGroup.position).negate()\n this._position.applyMatrix4(this.inverseMatrix)\n if (!this._position.equals(this.boxCenter)) {\n this.setParameters({ 'boxCenter': this._position })\n }\n }\n\n this.toBePrepared = true\n\n this.viewer.signals.ticked.add(this.setBox, this)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'uniform')\n p.colorValue = defaults(p.colorValue, 0xDDDDDD)\n\n this.isolevelType = defaults(p.isolevelType, 'sigma')\n this.isolevel = defaults(p.isolevel, 2.0)\n this.negateIsolevel = defaults(p.negateIsolevel, false)\n this.isolevelScroll = defaults(p.isolevelScroll, false)\n this.smooth = defaults(p.smooth, 0)\n this.background = defaults(p.background, false)\n this.opaqueBack = defaults(p.opaqueBack, true)\n this.boxSize = defaults(p.boxSize, 0)\n this.colorVolume = defaults(p.colorVolume, undefined)\n this.contour = defaults(p.contour, false)\n this.useWorker = defaults(p.useWorker, true)\n this.wrap = defaults(p.wrap, false)\n\n super.init(p)\n\n this.inverseMatrix.getInverse(this.matrix)\n\n this.build()\n }\n\n attach (callback: () => void) {\n this.bufferList.forEach(buffer => {\n this.viewer.add(buffer)\n })\n\n this.setVisibility(this.visible)\n\n callback()\n }\n\n prepare (callback: () => void) {\n if (this.volume) {\n let isolevel\n\n if (this.isolevelType === 'sigma') {\n isolevel = this.volume.getValueForSigma(this.isolevel)\n } else {\n isolevel = this.isolevel\n }\n if (this.negateIsolevel) isolevel *= -1\n\n if (!this.surface ||\n this.__isolevel !== isolevel ||\n this.__smooth !== this.smooth ||\n this.__contour !== this.contour ||\n this.__wrap !== this.wrap ||\n this.__boxSize !== this.boxSize ||\n (this.boxSize > 0 &&\n !this.__boxCenter.equals(this.boxCenter))\n ) {\n this.__isolevel = isolevel\n this.__smooth = this.smooth\n this.__contour = this.contour\n this.__wrap = this.wrap\n this.__boxSize = this.boxSize\n this.__boxCenter.copy(this.boxCenter)\n this.__box.copy(this.box)\n\n const onSurfaceFinish = (surface: Surface) => {\n this.surface = surface\n callback()\n }\n\n if (this.useWorker) {\n this.volume.getSurfaceWorker(\n isolevel, this.smooth, this.boxCenter, this.boxSize,\n this.contour, this.wrap, onSurfaceFinish\n )\n } else {\n onSurfaceFinish(\n this.volume.getSurface(\n isolevel, this.smooth, this.boxCenter, this.boxSize,\n this.contour, this.wrap\n )\n )\n }\n } else {\n callback()\n }\n } else {\n callback()\n }\n }\n\n create () {\n const sd = {\n position: (this.surface as Surface).getPosition(),\n color: (this.surface as Surface).getColor(this.getColorParams()),\n index: (this.surface as Surface).getIndex()\n }\n\n let buffer\n\n if (this.contour) {\n buffer = new ContourBuffer(\n sd,\n this.getBufferParams({ wireframe: false })\n )\n } else {\n Object.assign(sd, {\n normal: (this.surface as Surface).getNormal(),\n picking: (this.surface as Surface).getPicking()\n })\n\n const surfaceBuffer = new SurfaceBuffer(\n sd,\n this.getBufferParams({\n background: this.background,\n opaqueBack: this.opaqueBack,\n dullInterior: false\n })\n )\n\n buffer = new DoubleSidedBuffer(surfaceBuffer)\n }\n\n this.bufferList.push(buffer as ContourBuffer)\n }\n\n update (what: SurfaceDataFields) {\n if (this.bufferList.length === 0) return\n\n what = what || {}\n\n const surfaceData: Partial = {}\n\n if (what.position) {\n surfaceData.position = (this.surface as Surface).getPosition()\n }\n\n if (what.color) {\n surfaceData.color = (this.surface as Surface).getColor(\n this.getColorParams()\n )\n }\n\n if (what.index) {\n surfaceData.index = (this.surface as Surface).getIndex()\n }\n\n if (what.normal) {\n surfaceData.normal = (this.surface as Surface).getNormal()\n }\n\n this.bufferList.forEach(function (buffer) {\n buffer.setAttributes(surfaceData)\n })\n }\n\n /**\n * Set representation parameters\n * @alias SurfaceRepresentation#setParameters\n * @param {SurfaceRepresentationParameters} params - surface parameter object\n * @param {Object} [what] - buffer data attributes to be updated,\n * note that this needs to be implemented in the\n * derived classes. Generally it allows more\n * fine-grained control over updating than\n * forcing a rebuild.\n * @param {Boolean} what.position - update position data\n * @param {Boolean} what.color - update color data\n * @param {Boolean} [rebuild] - whether or not to rebuild the representation\n * @return {SurfaceRepresentation} this object\n */\n setParameters (params: Partial, what?: SurfaceDataFields, rebuild?: boolean) {\n if (params && params.isolevelType !== undefined &&\n this.volume\n ) {\n if (this.isolevelType === 'value' &&\n params.isolevelType === 'sigma'\n ) {\n this.isolevel = this.volume.getSigmaForValue(this.isolevel)\n } else if (this.isolevelType === 'sigma' &&\n params.isolevelType === 'value'\n ) {\n this.isolevel = this.volume.getValueForSigma(this.isolevel)\n }\n\n this.isolevelType = params.isolevelType\n }\n\n if (params && params.boxCenter) {\n this.boxCenter.copy(params.boxCenter)\n delete params.boxCenter\n }\n\n // Forbid wireframe && contour as in molsurface\n if (params && params.wireframe && (\n params.contour || (params.contour === undefined && this.contour)\n )) {\n params.wireframe = false\n }\n\n super.setParameters(params, what, rebuild)\n\n if (params.matrix) {\n this.inverseMatrix.getInverse(params.matrix)\n }\n\n if (this.volume) {\n this.volume.getBox(this.boxCenter, this.boxSize, this.box)\n }\n\n if (params && params.colorVolume !== undefined) {\n if (what) what.color = true\n }\n\n if (this.surface && (\n params.isolevel !== undefined ||\n params.negateIsolevel !== undefined ||\n params.smooth !== undefined ||\n params.wrap !== undefined ||\n params.boxSize !== undefined ||\n (this.boxSize > 0 &&\n !this.__box.equals(this.box))\n )) {\n this.build({\n 'position': true,\n 'color': true,\n 'index': true,\n 'normal': !this.contour\n })\n }\n\n return this\n }\n\n getColorParams () {\n const p = super.getColorParams()\n\n p.volume = this.colorVolume\n\n return p\n }\n\n dispose () {\n this.viewer.signals.ticked.remove(this.setBox, this)\n\n super.dispose()\n }\n}\n\nexport default SurfaceRepresentation\n","/**\n * @file Mouse Actions\n * @author Alexander Rose \n * @private\n */\n\nimport PickingProxy from './picking-proxy'\nimport { almostIdentity } from '../math/math-utils'\nimport Stage from '../stage/stage'\nimport StructureComponent from '../component/structure-component'\nimport SurfaceRepresentation from '../representation/surface-representation'\n\nexport type ScrollCallback = (stage: Stage, delta: number) => void\nexport type DragCallback = (stage: Stage, dx: number, dy: number) => void\nexport type PickCallback = (stage: Stage, pickingProxy: PickingProxy) => void\nexport type MouseActionCallback = ScrollCallback | DragCallback | PickCallback\n\n/**\n * Mouse actions provided as static methods\n */\nclass MouseActions {\n /**\n * Zoom scene based on scroll-delta\n * @param {Stage} stage - the stage\n * @param {Number} delta - amount to zoom\n * @return {undefined}\n */\n static zoomScroll (stage: Stage, delta: number) {\n stage.trackballControls.zoom(delta)\n }\n\n /**\n * Move near clipping plane based on scroll-delta\n * @param {Stage} stage - the stage\n * @param {Number} delta - amount to move clipping plane\n * @return {undefined}\n */\n static clipNearScroll (stage: Stage, delta: number) {\n const sp = stage.getParameters()\n stage.setParameters({ clipNear: sp.clipNear + delta / 10 })\n }\n\n /**\n * Move clipping planes based on scroll-delta.\n * @param {Stage} stage - the stage\n * @param {Number} delta - direction to move planes\n * @return {undefined}\n */\n static focusScroll (stage: Stage, delta: number) {\n const focus = stage.getFocus()\n const sign = Math.sign(delta)\n const step = sign * almostIdentity((100 - focus) / 10, 5, 0.2)\n stage.setFocus(focus + step)\n }\n\n /**\n * Zoom scene based on scroll-delta and\n * move focus planes based on camera position (zoom)\n * @param {Stage} stage - the stage\n * @param {Number} delta - amount to move focus planes and zoom\n * @return {undefined}\n */\n static zoomFocusScroll (stage: Stage, delta: number) {\n stage.trackballControls.zoom(delta)\n const z = stage.viewer.camera.position.z\n stage.setFocus(100 - Math.abs(z / 8))\n }\n\n /**\n * Change isolevel of volume surfaces based on scroll-delta\n * @param {Stage} stage - the stage\n * @param {Number} delta - amount to change isolevel\n * @return {undefined}\n */\n static isolevelScroll (stage: Stage, delta: number) {\n const d = Math.sign(delta) / 10\n stage.eachRepresentation((reprElem, comp) => {\n if (reprElem.repr instanceof SurfaceRepresentation) {\n const p = reprElem.getParameters() as any // TODO\n if (p.isolevelScroll) {\n reprElem.setParameters({ isolevel: p.isolevel + d })\n }\n }\n })\n }\n\n /**\n * Pan scene based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to pan in x direction\n * @param {Number} dy - amount to pan in y direction\n * @return {undefined}\n */\n static panDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.pan(dx, dy)\n }\n\n /**\n * Rotate scene based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to rotate in x direction\n * @param {Number} dy - amount to rotate in y direction\n * @return {undefined}\n */\n static rotateDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.rotate(dx, dy)\n }\n\n /**\n * Rotate scene around z axis based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to rotate in x direction\n * @param {Number} dy - amount to rotate in y direction\n * @return {undefined}\n */\n static zRotateDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.zRotate(dx, dy)\n }\n\n /**\n * Zoom scene based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to zoom\n * @param {Number} dy - amount to zoom\n * @return {undefined}\n */\n static zoomDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.zoom((dx + dy) / -2)\n }\n\n /**\n * Zoom scene based on mouse coordinate changes and\n * move focus planes based on camera position (zoom)\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to zoom and focus\n * @param {Number} dy - amount to zoom and focus\n * @return {undefined}\n */\n static zoomFocusDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.zoom((dx + dy) / -2)\n const z = stage.viewer.camera.position.z\n stage.setFocus(100 - Math.abs(z / 8))\n }\n\n /**\n * Pan picked component based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to pan in x direction\n * @param {Number} dy - amount to pan in y direction\n * @return {undefined}\n */\n static panComponentDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.panComponent(dx, dy)\n }\n\n /**\n * Pan picked atom based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to pan in x direction\n * @param {Number} dy - amount to pan in y direction\n * @return {undefined}\n */\n static panAtomDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.panAtom(dx, dy)\n }\n\n /**\n * Rotate picked component based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to rotate in x direction\n * @param {Number} dy - amount to rotate in y direction\n * @return {undefined}\n */\n static rotateComponentDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.rotateComponent(dx, dy)\n }\n\n /**\n * Move picked element to the center of the screen\n * @param {Stage} stage - the stage\n * @param {PickingProxy} pickingProxy - the picking data object\n * @return {undefined}\n */\n static movePick (stage: Stage, pickingProxy: PickingProxy) {\n if (pickingProxy) {\n stage.animationControls.move(pickingProxy.position.clone())\n }\n }\n\n /**\n * Show tooltip with information of picked element\n * @param {Stage} stage - the stage\n * @param {PickingProxy} pickingProxy - the picking data object\n * @return {undefined}\n */\n static tooltipPick (stage: Stage, pickingProxy: PickingProxy) {\n const tt = stage.tooltip\n const sp = stage.getParameters() as any\n if (sp.tooltip && pickingProxy) {\n const mp = pickingProxy.mouse.position\n tt.innerText = pickingProxy.getLabel()\n tt.style.bottom = (window.innerHeight - mp.y + 3) + 'px'\n tt.style.left = (mp.x + 3) + 'px'\n tt.style.display = 'block'\n } else {\n tt.style.display = 'none'\n }\n }\n\n static measurePick (stage: Stage, pickingProxy: PickingProxy) {\n if (pickingProxy && (pickingProxy.atom || pickingProxy.bond)) {\n const atom = pickingProxy.atom || pickingProxy.closestBondAtom\n const sc = pickingProxy.component as StructureComponent\n sc.measurePick(atom)\n } else {\n stage.measureClear()\n }\n }\n}\n\ntype MouseActionPreset = [ string, MouseActionCallback ][]\nexport const MouseActionPresets = {\n default: [\n [ 'scroll', MouseActions.zoomScroll ],\n [ 'scroll-shift', MouseActions.focusScroll ],\n [ 'scroll-ctrl', MouseActions.isolevelScroll ],\n [ 'scroll-shift-ctrl', MouseActions.zoomFocusScroll ],\n\n [ 'drag-left', MouseActions.rotateDrag ],\n [ 'drag-right', MouseActions.panDrag ],\n [ 'drag-ctrl-left', MouseActions.panDrag ],\n [ 'drag-ctrl-right', MouseActions.zRotateDrag ],\n [ 'drag-shift-left', MouseActions.zoomDrag ],\n [ 'drag-middle', MouseActions.zoomFocusDrag ],\n\n [ 'drag-ctrl-shift-right', MouseActions.panComponentDrag ],\n [ 'drag-ctrl-shift-left', MouseActions.rotateComponentDrag ],\n\n [ 'clickPick-right', MouseActions.measurePick ],\n [ 'clickPick-ctrl-left', MouseActions.measurePick ],\n [ 'clickPick-middle', MouseActions.movePick ],\n [ 'clickPick-left', MouseActions.movePick ],\n [ 'hoverPick', MouseActions.tooltipPick ]\n ] as MouseActionPreset,\n pymol: [\n [ 'drag-left', MouseActions.rotateDrag ],\n [ 'drag-middle', MouseActions.panDrag ],\n [ 'drag-right', MouseActions.zoomDrag ],\n [ 'scroll', MouseActions.focusScroll ],\n [ 'drag-shift-right', MouseActions.focusScroll ],\n\n [ 'clickPick-ctrl+shift-middle', MouseActions.movePick ],\n [ 'hoverPick', MouseActions.tooltipPick ]\n ] as MouseActionPreset,\n coot: [\n [ 'scroll', MouseActions.isolevelScroll ],\n\n [ 'drag-left', MouseActions.rotateDrag ],\n [ 'drag-middle', MouseActions.panDrag ],\n [ 'drag-ctrl-left', MouseActions.panDrag ],\n [ 'drag-right', MouseActions.zoomFocusDrag ],\n [ 'drag-ctrl-right', MouseActions.focusScroll ],\n\n [ 'clickPick-middle', MouseActions.movePick ],\n [ 'hoverPick', MouseActions.tooltipPick ]\n ] as MouseActionPreset,\n astexviewer: [\n [ 'drag-left', MouseActions.rotateDrag ],\n [ 'drag-ctrl-left', MouseActions.panDrag ],\n [ 'drag-shift-left', MouseActions.zoomDrag ],\n [ 'scroll', MouseActions.focusScroll ],\n [ 'clickPick-middle', MouseActions.movePick ],\n [ 'hoverPick', MouseActions.tooltipPick ]\n ] as MouseActionPreset\n}\n\nexport default MouseActions\n","/**\n * @file Mouse Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { MouseActionPresets, MouseActionCallback } from './mouse-actions'\nimport Stage from '../stage/stage'\nimport MouseObserver from '../stage/mouse-observer'\n\nexport type MouseControlPreset = keyof typeof MouseActionPresets\nexport interface MouseControlsParams {\n preset?: MouseControlPreset\n disabled?: boolean\n}\n\nexport type MouseActionType = ''|'scroll'|'drag'|'click'|'doubleClick'|'hover'|'clickPick'|'hoverPick'\nexport interface MouseAction {\n type: MouseActionType\n key: number\n button: number\n callback: MouseActionCallback\n}\n\n/**\n * Strings to describe mouse events (including optional keyboard modifiers).\n * Must contain an event type: \"scroll\", \"drag\", \"click\", \"doubleClick\",\n * \"hover\", \"clickPick\" or \"hoverPick\". Optionally contain one or more\n * (seperated by plus signs) keyboard modifiers: \"alt\", \"ctrl\", \"meta\" or\n * \"shift\". Can contain the mouse button performing the event: \"left\",\n * \"middle\" or \"right\". The type, key and button parts must be seperated by\n * dashes.\n *\n * @example\n * // triggered on scroll event (no key or button)\n * \"scroll\"\n *\n * @example\n * // triggered on scroll event while shift key is pressed\n * \"scroll-shift\"\n *\n * @example\n * // triggered on drag event with left mouse button\n * \"drag-left\"\n *\n * @example\n * // triggered on drag event with right mouse button\n * // while ctrl and shift keys are pressed\n * \"drag-right-ctrl+shift\"\n *\n * @typedef {String} TriggerString\n */\n\n/**\n * Get event type, key and button\n * @param {TriggerString} str - input trigger string\n * @return {Array} event type, key and button\n */\nfunction triggerFromString (str: string) {\n const tokens = str.split(/[-+]/)\n\n let type = ''\n if (tokens.includes('scroll')) type = 'scroll'\n if (tokens.includes('drag')) type = 'drag'\n if (tokens.includes('click')) type = 'click'\n if (tokens.includes('doubleClick')) type = 'doubleClick'\n if (tokens.includes('hover')) type = 'hover'\n if (tokens.includes('clickPick')) type = 'clickPick'\n if (tokens.includes('hoverPick')) type = 'hoverPick'\n\n let key = 0\n if (tokens.includes('alt')) key += 1\n if (tokens.includes('ctrl')) key += 2\n if (tokens.includes('meta')) key += 4\n if (tokens.includes('shift')) key += 8\n\n let button = 0\n if (tokens.includes('left')) button += 1\n if (tokens.includes('right')) button += 2\n if (tokens.includes('middle')) button += 4\n\n return [ type, key, button ] as [ MouseActionType, number, number ]\n}\n\n/**\n * Mouse controls\n */\nclass MouseControls {\n actionList: MouseAction[] = []\n mouse: MouseObserver\n\n disabled: boolean // Flag to disable all actions\n\n /**\n * @param {Stage} stage - the stage object\n * @param {Object} [params] - the parameters\n * @param {String} params.preset - one of \"default\", \"pymol\", \"coot\"\n * @param {String} params.disabled - flag to disable all actions\n */\n constructor (readonly stage: Stage, params: MouseControlsParams = {}) {\n this.mouse = stage.mouseObserver\n this.disabled = params.disabled || false\n this.preset(params.preset || 'default')\n }\n\n run (type: MouseActionType, ...args: any[]) {\n if (this.disabled) return\n\n const key = this.mouse.key || 0\n const button = this.mouse.buttons || 0\n\n this.actionList.forEach(a => {\n if (a.type === type && a.key === key && a.button === button) {\n (a.callback as any)(this.stage, ...args) // TODO\n }\n })\n }\n\n /**\n * Add a new mouse action triggered by an event, key and button combination.\n * The {@link MouseActions} class provides a number of static methods for\n * use as callback functions.\n *\n * @example\n * // change ambient light intensity on mouse scroll\n * // while the ctrl and shift keys are pressed\n * stage.mouseControls.add( \"scroll-ctrl+shift\", function( stage, delta ){\n * var ai = stage.getParameters().ambientIntensity;\n * stage.setParameters( { ambientIntensity: Math.max( 0, ai + delta / 50 ) } );\n * } );\n *\n * @example\n * // Call the MouseActions.zoomDrag method on mouse drag events\n * // with left and right mouse buttons simultaneous\n * stage.mouseControls.add( \"drag-left+right\", MouseActions.zoomDrag );\n *\n * @param {TriggerString} triggerStr - the trigger for the action\n * @param {function(stage: Stage, ...args: Any)} callback - the callback function for the action\n * @return {undefined}\n */\n add (triggerStr: string, callback: MouseActionCallback) {\n const [ type, key, button ] = triggerFromString(triggerStr)\n\n this.actionList.push({ type, key, button, callback })\n }\n\n /**\n * Remove a mouse action. The trigger string can contain an asterix (*)\n * as a wildcard for any key or mouse button. When the callback function\n * is given, only actions that call that function are removed.\n *\n * @example\n * // remove actions triggered solely by a scroll event\n * stage.mouseControls.remove( \"scroll\" );\n *\n * @example\n * // remove actions triggered by a scroll event, including\n * // those requiring a key pressed or mouse button used\n * stage.mouseControls.remove( \"scroll-*\" );\n *\n * @example\n * // remove actions triggered by a scroll event\n * // while the shift key is pressed\n * stage.mouseControls.remove( \"scroll-shift\" );\n *\n * @param {TriggerString} triggerStr - the trigger for the action\n * @param {Function} [callback] - the callback function for the action\n * @return {undefined}\n */\n remove (triggerStr: string, callback?: MouseActionCallback) {\n const wildcard = triggerStr.includes('*')\n const [ type, key, button ] = triggerFromString(triggerStr)\n\n const actionList = this.actionList.filter(function (a) {\n return !(\n (a.type === type || (wildcard && type === '')) &&\n (a.key === key || (wildcard && key === 0)) &&\n (a.button === button || (wildcard && button === 0)) &&\n (a.callback === callback || callback === undefined)\n )\n })\n\n this.actionList = actionList\n }\n\n /**\n * Set mouse action preset\n * @param {String} name - one of \"default\", \"pymol\", \"coot\"\n * @return {undefined}\n */\n preset (name: MouseControlPreset) {\n this.clear()\n\n const list = MouseActionPresets[ name ] || []\n\n list.forEach(action => this.add(action[0], action[1]))\n }\n\n /**\n * Remove all mouse actions\n * @return {undefined}\n */\n clear () {\n this.actionList.length = 0\n }\n}\n\nexport default MouseControls\n","/**\n * @file Key Actions\n * @author Alexander Rose \n * @private\n */\n\nimport Stage from '../stage/stage'\n\nexport type KeyActionCallback = (stage: Stage) => void\n\n/**\n * Key actions provided as static methods\n */\nclass KeyActions {\n /**\n * Stage auto view\n */\n static autoView (stage: Stage) {\n stage.autoView(1000)\n }\n\n /**\n * Toggle stage animations\n */\n static toggleAnimations (stage: Stage) {\n stage.animationControls.toggle()\n }\n\n /**\n * Toggle stage rocking\n */\n static toggleRock (stage: Stage) {\n stage.toggleRock()\n }\n\n /**\n * Toggle stage spinning\n */\n static toggleSpin (stage: Stage) {\n stage.toggleSpin()\n }\n\n /**\n * Toggle anti-aliasing\n */\n static toggleAntialiasing (stage: Stage) {\n const p = stage.getParameters()\n stage.setParameters({ sampleLevel: p.sampleLevel === -1 ? 0 : -1 })\n }\n}\n\ntype KeyActionPreset = [ string, KeyActionCallback ][]\nexport const KeyActionPresets = {\n default: [\n [ 'i', KeyActions.toggleSpin ],\n [ 'k', KeyActions.toggleRock ],\n [ 'p', KeyActions.toggleAnimations ],\n [ 'a', KeyActions.toggleAntialiasing ],\n [ 'r', KeyActions.autoView ]\n ] as KeyActionPreset\n}\n\nexport default KeyActions\n","/**\n * @file Key Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { KeyActionPresets, KeyActionCallback } from './key-actions'\nimport Stage from '../stage/stage'\n\nexport type KeyControlPreset = keyof typeof KeyActionPresets\nexport interface KeyControlsParams {\n preset?: KeyControlPreset\n disabled?: boolean\n}\n\nexport interface KeyAction {\n key: string,\n callback: KeyActionCallback\n}\n\n/**\n * Mouse controls\n */\nclass KeyControls {\n actionList: KeyAction[] = []\n\n disabled: boolean // Flag to disable all actions\n\n /**\n * @param {Stage} stage - the stage object\n * @param {Object} [params] - the parameters\n * @param {String} params.preset - one of \"default\"\n * @param {String} params.disabled - flag to disable all actions\n */\n constructor (readonly stage: Stage, params: KeyControlsParams = {}) {\n this.disabled = params.disabled || false\n this.preset(params.preset || 'default')\n }\n\n run (key: string) {\n if (this.disabled) return\n\n this.actionList.forEach(a => {\n if (a.key === key) {\n a.callback(this.stage)\n }\n })\n }\n\n /**\n * Add a key action triggered by pressing the given character.\n * The {@link KeyActions} class provides a number of static methods for\n * use as callback functions.\n *\n * @example\n * // call KeyActions.toggleRock when \"k\" is pressed\n * stage.keyControls.remove( \"k\", KeyActions.toggleRock );\n *\n * @param {Char} char - the key/character\n * @param {Function} callback - the callback function for the action\n * @return {undefined}\n */\n add (char: string, callback: KeyActionCallback) {\n this.actionList.push({ key: char, callback })\n }\n\n /**\n * Remove a key action. When the callback function\n * is given, only actions that call that function are removed.\n *\n * @example\n * // remove all actions triggered by pressing \"k\"\n * stage.keyControls.remove( \"k\" );\n *\n * @example\n * // remove action `toggleRock` triggered by pressing \"k\"\n * stage.keyControls.remove( \"k\", toggleRock );\n *\n * @param {Char} char - the key/character\n * @param {Function} [callback] - the callback function for the action\n * @return {undefined}\n */\n remove (char: string, callback: KeyActionCallback) {\n\n const actionList = this.actionList.filter(function (a) {\n return !(\n (a.key === char) &&\n (a.callback === callback || callback === undefined)\n )\n })\n\n this.actionList = actionList\n }\n\n /**\n * Set key action preset\n * @param {String} name - one of \"default\"\n * @return {undefined}\n */\n preset (name: KeyControlPreset) {\n this.clear()\n\n const list = KeyActionPresets[ name ] || []\n\n list.forEach(action => this.add(action[0], action[1]))\n }\n\n /**\n * Remove all key actions\n * @return {undefined}\n */\n clear () {\n this.actionList.length = 0\n }\n}\n\nexport default KeyControls\n","/**\n * @file Picking Behavior\n * @author Alexander Rose \n * @private\n */\n\nimport Stage from './stage'\nimport MouseObserver from './mouse-observer'\nimport Viewer from '../viewer/viewer'\nimport MouseControls from '../controls/mouse-controls'\n\nclass PickingBehavior {\n viewer: Viewer\n mouse: MouseObserver\n controls: MouseControls\n\n constructor (readonly stage: Stage) {\n this.stage = stage\n this.mouse = stage.mouseObserver\n this.controls = stage.mouseControls\n\n this.mouse.signals.clicked.add(this._onClick, this)\n this.mouse.signals.hovered.add(this._onHover, this)\n }\n\n _onClick (x: number, y: number) {\n const pickingProxy = this.stage.pickingControls.pick(x, y)\n this.stage.signals.clicked.dispatch(pickingProxy)\n this.controls.run('clickPick', pickingProxy)\n }\n\n _onHover (x: number, y: number) {\n const pickingProxy = this.stage.pickingControls.pick(x, y)\n if (pickingProxy && this.mouse.down.equals(this.mouse.position)) {\n this.stage.transformComponent = pickingProxy.component\n this.stage.transformAtom = pickingProxy.atom\n }\n this.stage.signals.hovered.dispatch(pickingProxy)\n this.controls.run('hoverPick', pickingProxy)\n }\n\n dispose () {\n this.mouse.signals.clicked.remove(this._onClick, this)\n this.mouse.signals.hovered.remove(this._onHover, this)\n }\n}\n\nexport default PickingBehavior\n","/**\n * @file Mouse Behavior\n * @author Alexander Rose \n * @private\n */\n\nimport Stage from './stage'\nimport MouseObserver from './mouse-observer'\nimport Viewer from '../viewer/viewer'\nimport MouseControls from '../controls/mouse-controls'\n\nclass MouseBehavior {\n viewer: Viewer\n mouse: MouseObserver\n controls: MouseControls\n domElement: HTMLCanvasElement\n\n constructor (readonly stage: Stage) {\n this.stage = stage\n this.mouse = stage.mouseObserver\n this.controls = stage.mouseControls\n\n this.mouse.signals.moved.add(this._onMove, this)\n this.mouse.signals.scrolled.add(this._onScroll, this)\n this.mouse.signals.dragged.add(this._onDrag, this)\n this.mouse.signals.clicked.add(this._onClick, this)\n this.mouse.signals.hovered.add(this._onHover, this)\n this.mouse.signals.doubleClicked.add(this._onDblclick, this)\n }\n\n _onMove (/* x, y */) {\n this.stage.tooltip.style.display = 'none'\n }\n\n _onScroll (delta: number) {\n this.controls.run('scroll', delta)\n }\n\n _onDrag (dx: number, dy: number) {\n this.controls.run('drag', dx, dy)\n }\n\n _onClick (x: number, y: number) {\n this.controls.run('click', x, y)\n }\n\n _onDblclick (x: number, y: number) {\n this.controls.run('doubleClick', x, y)\n }\n\n _onHover (x: number, y: number) {\n this.controls.run('hover', x, y)\n }\n\n dispose () {\n this.mouse.signals.moved.remove(this._onMove, this)\n this.mouse.signals.scrolled.remove(this._onScroll, this)\n this.mouse.signals.dragged.remove(this._onDrag, this)\n this.mouse.signals.clicked.remove(this._onClick, this)\n this.mouse.signals.hovered.remove(this._onHover, this)\n }\n}\n\nexport default MouseBehavior\n","/**\n * @file Animation Behavior\n * @author Alexander Rose \n * @private\n */\n\nimport Stage from './stage'\nimport Viewer from '../viewer/viewer'\nimport Stats from '../viewer/stats'\nimport AnimationControls from '../controls/animation-controls'\n\nclass AnimationBehavior {\n viewer: Viewer\n animationControls: AnimationControls\n\n constructor (readonly stage: Stage) {\n this.viewer = stage.viewer\n this.animationControls = stage.animationControls\n\n this.viewer.signals.ticked.add(this._onTick, this)\n }\n\n _onTick (stats: Stats) {\n this.animationControls.run(stats)\n }\n\n dispose () {\n this.viewer.signals.ticked.remove(this._onTick, this)\n }\n}\n\nexport default AnimationBehavior\n","/**\n * @file Key Behavior\n * @author Alexander Rose \n * @private\n */\n\nimport { SupportsPassiveEventHandler } from '../globals'\nimport Stage from './stage'\nimport Viewer from '../viewer/viewer'\nimport KeyControls from '../controls/key-controls'\n\nconst passive = SupportsPassiveEventHandler ? { passive: true } : false\n\nclass KeyBehavior {\n viewer: Viewer\n controls: KeyControls\n domElement: HTMLCanvasElement\n\n /**\n * @param {Stage} stage - the stage object\n */\n constructor (readonly stage: Stage) {\n this.stage = stage\n this.controls = stage.keyControls\n this.domElement = stage.viewer.renderer.domElement\n\n // ensure the domElement is focusable\n this.domElement.setAttribute('tabIndex', '-1')\n this.domElement.style.outline = 'none'\n\n this._focusDomElement = this._focusDomElement.bind(this)\n this._onKeydown = this._onKeydown.bind(this)\n this._onKeyup = this._onKeyup.bind(this)\n this._onKeypress = this._onKeypress.bind(this)\n\n this.domElement.addEventListener('mousedown', this._focusDomElement)\n this.domElement.addEventListener('touchstart', this._focusDomElement, passive as any) // TODO\n this.domElement.addEventListener('keydown', this._onKeydown)\n this.domElement.addEventListener('keyup', this._onKeyup)\n this.domElement.addEventListener('keypress', this._onKeypress)\n }\n\n /**\n * handle key down\n * @param {Event} event - key event\n * @return {undefined}\n */\n _onKeydown (/* event */) {\n // console.log( \"down\", event.keyCode, String.fromCharCode( event.keyCode ) );\n }\n\n /**\n * handle key up\n * @param {Event} event - key event\n * @return {undefined}\n */\n _onKeyup (/* event */) {\n // console.log( \"up\", event.keyCode, String.fromCharCode( event.keyCode ) );\n }\n\n /**\n * handle key press\n * @param {Event} event - key event\n * @return {undefined}\n */\n _onKeypress (event: KeyboardEvent) {\n // console.log( \"press\", event.keyCode, String.fromCharCode( event.keyCode ) );\n let pressedKey: string;\n if (\"key\" in KeyboardEvent.prototype) {\n pressedKey = event.key;\n // some mobile browsers don't support this attribute\n } else {\n pressedKey = String.fromCharCode(event.which || event.keyCode);\n }\n this.controls.run(pressedKey);\n }\n\n _focusDomElement () {\n this.domElement.focus()\n }\n\n dispose () {\n this.domElement.removeEventListener('mousedown', this._focusDomElement)\n this.domElement.removeEventListener('touchstart', this._focusDomElement, passive as any) // TODO\n this.domElement.removeEventListener('keydown', this._onKeypress)\n this.domElement.removeEventListener('keyup', this._onKeypress)\n this.domElement.removeEventListener('keypress', this._onKeypress)\n }\n}\n\nexport default KeyBehavior\n","/**\n * @file Annotation\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector2, Vector3 } from 'three'\n\nimport { defaults } from '../utils'\nimport { smoothstep } from '../math/math-utils'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\nimport Component from './component'\n\nexport interface AnnotationParams {\n offsetX?: number\n offsetY?: number\n visible?: boolean\n}\n\n/**\n * Annotation HTML element floating on top of a position rendered in 3d\n */\nexport default class Annotation {\n offsetX: number\n offsetY: number\n visible: boolean\n\n stage: Stage\n viewer: Viewer\n element: HTMLElement\n\n private _viewerPosition: Vector3\n private _canvasPosition: Vector2\n private _cameraPosition: Vector3\n private _clientRect: ClientRect\n\n /**\n * @param {Component} component - the associated component\n * @param {Vector3} position - position in 3d\n * @param {String|Element} content - HTML content\n * @param {Object} [params] - parameters\n * @param {Integer} params.offsetX - 2d offset in x direction\n * @param {Integer} params.offsetY - 2d offset in y direction\n * @param {Boolean} params.visible - visibility flag\n */\n constructor (readonly component: Component, readonly position: Vector3, content: string|HTMLElement, params: AnnotationParams = {}) {\n this.offsetX = defaults(params.offsetX, 0)\n this.offsetY = defaults(params.offsetY, 0)\n this.visible = defaults(params.visible, true)\n\n this.stage = component.stage\n this.viewer = component.stage.viewer\n\n this._viewerPosition = new Vector3()\n this._updateViewerPosition()\n this._canvasPosition = new Vector2()\n this._cameraPosition = new Vector3()\n\n this.element = document.createElement('div')\n Object.assign(this.element.style, {\n display: 'block',\n position: 'absolute',\n pointerEvents: 'none',\n whiteSpace: 'nowrap',\n left: '-10000px'\n })\n\n this.viewer.wrapper.appendChild(this.element)\n this.setContent(content)\n this.updateVisibility()\n this.viewer.signals.rendered.add(this._update, this)\n this.component.signals.matrixChanged.add(this._updateViewerPosition, this)\n }\n\n /**\n * Set HTML content of the annotation\n * @param {String|Element} value - HTML content\n * @return {undefined}\n */\n setContent (value: string|HTMLElement) {\n const displayValue = this.element.style.display\n if (displayValue === 'none') {\n this.element.style.left = '-10000px'\n this.element.style.display = 'block'\n }\n\n if (value instanceof HTMLElement) {\n this.element.appendChild(value)\n } else {\n const content = document.createElement('div')\n content.innerText = value\n Object.assign(content.style, {\n backgroundColor: 'rgba( 0, 0, 0, 0.6 )',\n color: 'lightgrey',\n padding: '8px',\n fontFamily: 'sans-serif',\n })\n this.element.appendChild(content)\n }\n\n this._clientRect = this.element.getBoundingClientRect()\n\n if (displayValue === 'none') {\n this.element.style.display = displayValue\n }\n }\n\n /**\n * Set visibility of the annotation\n * @param {Boolean} value - visibility flag\n * @return {undefined}\n */\n setVisibility (value: boolean) {\n this.visible = value\n this.updateVisibility()\n }\n\n getVisibility () {\n return this.visible && this.component.parameters.visible\n }\n\n updateVisibility () {\n this.element.style.display = this.getVisibility() ? 'block' : 'none'\n }\n\n _updateViewerPosition () {\n this._viewerPosition\n .copy(this.position)\n .applyMatrix4(this.component.matrix)\n }\n\n _update () {\n if (!this.getVisibility()) return\n\n const s = this.element.style\n const cp = this._canvasPosition\n const vp = this._viewerPosition\n const cr = this._clientRect\n\n this._cameraPosition.copy(vp)\n .add(this.viewer.translationGroup.position)\n .applyMatrix4(this.viewer.rotationGroup.matrix)\n .sub(this.viewer.camera.position)\n\n if (this._cameraPosition.z < 0) {\n s.display = 'none'\n return\n } else {\n s.display = 'block'\n }\n\n const depth = this._cameraPosition.length()\n const fog = this.viewer.scene.fog as any // TODO\n\n s.opacity = (1 - smoothstep(fog.near, fog.far, depth)).toString()\n s.zIndex = (Math.round((fog.far - depth) * 100)).toString()\n\n this.stage.viewerControls.getPositionOnCanvas(vp, cp)\n\n s.bottom = (this.offsetX + cp.y + cr.height / 2) + 'px'\n s.left = (this.offsetY + cp.x - cr.width / 2) + 'px'\n }\n\n /**\n * Safely remove the annotation\n * @return {undefined}\n */\n dispose () {\n this.viewer.wrapper.removeChild(this.element)\n this.viewer.signals.ticked.remove(this._update, this)\n this.component.signals.matrixChanged.remove(this._updateViewerPosition, this)\n }\n}","/**\n * @file Component Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4, Quaternion } from 'three'\nimport * as signalsWrapper from 'signals'\n\nimport { ensureVector3 } from '../utils'\nimport Component from '../component/component'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\n\nconst tmpRotateMatrix = new Matrix4()\nconst tmpRotateVector = new Vector3()\nconst tmpRotateQuaternion = new Quaternion()\n\n/**\n * Component controls\n */\nclass ComponentControls {\n signals = {\n changed: new signalsWrapper.Signal()\n }\n\n stage: Stage\n viewer: Viewer\n\n /**\n * @param {Component} component - the component object\n */\n constructor (readonly component: Component) {\n this.stage = component.stage\n this.viewer = component.stage.viewer\n }\n\n /**\n * component center position\n * @type {Vector3}\n */\n get position () {\n return this.component.position\n }\n\n /**\n * component rotation\n * @type {Quaternion}\n */\n get rotation () {\n return this.component.quaternion\n }\n\n /**\n * Trigger render and emit changed event\n * @emits {ComponentControls.signals.changed}\n * @return {undefined}\n */\n changed () {\n this.component.updateMatrix()\n this.viewer.requestRender()\n this.signals.changed.dispatch()\n }\n\n /**\n * spin component on axis\n * @param {Vector3|Array} axis - rotation axis\n * @param {Number} angle - amount to spin\n * @return {undefined}\n */\n spin (axis: Vector3, angle: number) {\n tmpRotateMatrix.getInverse(this.viewer.rotationGroup.matrix)\n tmpRotateVector\n .copy(ensureVector3(axis)).applyMatrix4(tmpRotateMatrix)\n\n tmpRotateMatrix.extractRotation(this.component.transform)\n tmpRotateMatrix.premultiply(this.viewer.rotationGroup.matrix)\n tmpRotateMatrix.getInverse(tmpRotateMatrix)\n\n tmpRotateVector.copy(ensureVector3(axis))\n tmpRotateVector.applyMatrix4(tmpRotateMatrix)\n tmpRotateMatrix.makeRotationAxis(tmpRotateVector, angle)\n tmpRotateQuaternion.setFromRotationMatrix(tmpRotateMatrix)\n\n this.component.quaternion.premultiply(tmpRotateQuaternion)\n this.changed()\n }\n}\n\nexport default ComponentControls\n","/**\n * @file Radius Factory\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { NucleicBackboneAtoms } from '../structure/structure-constants'\nimport AtomProxy from '../proxy/atom-proxy'\n\nexport const RadiusFactoryTypes = {\n '': '',\n 'vdw': 'by vdW radius',\n 'covalent': 'by covalent radius',\n 'sstruc': 'by secondary structure',\n 'bfactor': 'by bfactor',\n 'size': 'size',\n 'data': 'data',\n 'explicit' : 'explicit'\n}\nexport type RadiusType = keyof typeof RadiusFactoryTypes\n\nexport interface RadiusParams {\n type?: RadiusType\n scale?: number\n size?: number\n data?: { [k: number]: number }\n}\n\nclass RadiusFactory {\n max = 10\n\n static types = RadiusFactoryTypes\n\n readonly type: RadiusType\n readonly scale: number\n readonly size: number\n readonly data: { [k: number]: number }\n\n constructor (params: RadiusParams = {}) {\n this.type = defaults(params.type, 'size')\n this.scale = defaults(params.scale, 1)\n this.size = defaults(params.size, 1)\n this.data = defaults(params.data, {})\n }\n\n atomRadius (a: AtomProxy) {\n let r\n\n switch (this.type) {\n case 'vdw':\n r = a.vdw\n break\n\n case 'covalent':\n r = a.covalent\n break\n\n case 'bfactor':\n r = a.bfactor || 1.0\n break\n\n case 'sstruc':\n const sstruc = a.sstruc\n if (sstruc === 'h') {\n r = 0.25\n } else if (sstruc === 'g') {\n r = 0.25\n } else if (sstruc === 'i') {\n r = 0.25\n } else if (sstruc === 'e') {\n r = 0.25\n } else if (sstruc === 'b') {\n r = 0.25\n } else if (NucleicBackboneAtoms.includes(a.atomname)) {\n r = 0.4\n } else {\n r = 0.1\n }\n break\n\n case 'data':\n r = defaults(this.data[ a.index ], 1.0)\n break\n\n case 'explicit':\n // defaults is inappropriate as AtomProxy.radius returns\n // null for missing radii\n r = a.radius\n if (r === null) r = this.size\n break\n\n default:\n r = this.size\n break\n }\n\n return Math.min(r * this.scale, this.max)\n }\n\n}\n\nexport default RadiusFactory\n","/**\n * @file Principal Axes\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4, Quaternion } from 'three'\n\nimport {\n Matrix, meanRows, subRows, transpose, multiplyABt, svd\n} from './matrix-utils'\nimport { projectPointOnVector } from './vector-utils'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\n\nconst negateVector = new Vector3(-1, -1, -1)\nconst tmpMatrix = new Matrix4()\n\n/**\n * Principal axes\n */\nclass PrincipalAxes {\n begA: Vector3\n endA: Vector3\n begB: Vector3\n endB: Vector3\n begC: Vector3\n endC: Vector3\n\n center: Vector3\n\n vecA: Vector3\n vecB: Vector3\n vecC: Vector3\n\n normVecA: Vector3\n normVecB: Vector3\n normVecC: Vector3\n\n /**\n * @param {Matrix} points - 3 by N matrix\n */\n constructor (points: Matrix) {\n // console.time( \"PrincipalAxes\" );\n\n const n = points.rows\n const n3 = n / 3\n const pointsT = new Matrix(n, 3)\n const A = new Matrix(3, 3)\n const W = new Matrix(1, 3)\n const U = new Matrix(3, 3)\n const V = new Matrix(3, 3)\n\n // calculate\n const mean = meanRows(points)\n subRows(points, mean)\n transpose(pointsT, points)\n multiplyABt(A, pointsT, pointsT)\n svd(A, W, U, V)\n\n // console.log( points, pointsT, mean )\n // console.log( n, A, W, U, V );\n\n // center\n const vm = new Vector3(mean[0], mean[1], mean[2])\n\n // normalized\n const van = new Vector3(U.data[0], U.data[3], U.data[6])\n const vbn = new Vector3(U.data[1], U.data[4], U.data[7])\n const vcn = new Vector3(U.data[2], U.data[5], U.data[8])\n\n // scaled\n const va = van.clone().multiplyScalar(Math.sqrt(W.data[0] / n3))\n const vb = vbn.clone().multiplyScalar(Math.sqrt(W.data[1] / n3))\n const vc = vcn.clone().multiplyScalar(Math.sqrt(W.data[2] / n3))\n\n // points\n this.begA = vm.clone().sub(va)\n this.endA = vm.clone().add(va)\n this.begB = vm.clone().sub(vb)\n this.endB = vm.clone().add(vb)\n this.begC = vm.clone().sub(vc)\n this.endC = vm.clone().add(vc)\n\n //\n\n this.center = vm\n\n this.vecA = va\n this.vecB = vb\n this.vecC = vc\n\n this.normVecA = van\n this.normVecB = vbn\n this.normVecC = vcn\n\n // console.timeEnd( \"PrincipalAxes\" );\n }\n\n /**\n * Get the basis matrix descriping the axes\n * @param {Matrix4} [optionalTarget] - target object\n * @return {Matrix4} the basis\n */\n getBasisMatrix (optionalTarget = new Matrix4()) {\n const basis = optionalTarget\n\n basis.makeBasis(this.normVecB, this.normVecA, this.normVecC)\n if (basis.determinant() < 0) {\n basis.scale(negateVector)\n }\n\n return basis\n }\n\n /**\n * Get a quaternion descriping the axes rotation\n * @param {Quaternion} [optionalTarget] - target object\n * @return {Quaternion} the rotation\n */\n getRotationQuaternion (optionalTarget = new Quaternion()) {\n const q = optionalTarget\n q.setFromRotationMatrix(this.getBasisMatrix(tmpMatrix))\n\n return q.inverse()\n }\n\n /**\n * Get the scale/length for each dimension for a box around the axes\n * to enclose the atoms of a structure\n * @param {Structure|StructureView} structure - the structure\n * @return {{d1a: Number, d2a: Number, d3a: Number, d1b: Number, d2b: Number, d3b: Number}} scale\n */\n getProjectedScaleForAtoms (structure: Structure) {\n let d1a = -Infinity\n let d1b = -Infinity\n let d2a = -Infinity\n let d2b = -Infinity\n let d3a = -Infinity\n let d3b = -Infinity\n\n const p = new Vector3()\n const t = new Vector3()\n\n const center = this.center\n const ax1 = this.normVecA\n const ax2 = this.normVecB\n const ax3 = this.normVecC\n\n structure.eachAtom(function (ap: AtomProxy) {\n projectPointOnVector(p.copy(ap as any), ax1, center) // TODO\n const dp1 = t.subVectors(p, center).normalize().dot(ax1)\n const dt1 = p.distanceTo(center)\n if (dp1 > 0) {\n if (dt1 > d1a) d1a = dt1\n } else {\n if (dt1 > d1b) d1b = dt1\n }\n\n projectPointOnVector(p.copy(ap as any), ax2, center)\n const dp2 = t.subVectors(p, center).normalize().dot(ax2)\n const dt2 = p.distanceTo(center)\n if (dp2 > 0) {\n if (dt2 > d2a) d2a = dt2\n } else {\n if (dt2 > d2b) d2b = dt2\n }\n\n projectPointOnVector(p.copy(ap as any), ax3, center)\n const dp3 = t.subVectors(p, center).normalize().dot(ax3)\n const dt3 = p.distanceTo(center)\n if (dp3 > 0) {\n if (dt3 > d3a) d3a = dt3\n } else {\n if (dt3 > d3b) d3b = dt3\n }\n })\n\n return {\n d1a: d1a,\n d2a: d2a,\n d3a: d3a,\n d1b: -d1b,\n d2b: -d2b,\n d3b: -d3b\n }\n }\n}\n\nexport default PrincipalAxes\n","/**\n * @file Filtered Volume\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport Volume from './volume'\nimport { Box3, Matrix4, Matrix3, Vector3 } from 'three';\n\nclass FilteredVolume {\n volume: Volume\n data: Float32Array\n position: Float32Array\n atomindex: Int32Array\n _filterHash: string\n _dataBuffer: ArrayBuffer\n _positionBuffer: ArrayBuffer\n _atomindexBuffer: ArrayBuffer\n getValueForSigma: typeof Volume.prototype.getValueForSigma\n getSigmaForValue: typeof Volume.prototype.getSigmaForValue\n getDataAtomindex: typeof Volume.prototype.getDataAtomindex\n getDataPosition: typeof Volume.prototype.getDataPosition\n getDataColor: typeof Volume.prototype.getDataColor\n getDataPicking: typeof Volume.prototype.getDataPicking\n getDataSize: typeof Volume.prototype.getDataSize\n\n\n constructor (volume: Volume, minValue?: number, maxValue?: number, outside?: boolean) {\n this.volume = volume\n this.setFilter(minValue, maxValue, outside)\n }\n\n get header () { return this.volume.header }\n get matrix (): Matrix4 { return this.volume.matrix }\n get normalMatrix (): Matrix3 { return this.volume.normalMatrix }\n get inverseMatrix (): Matrix4 { return this.volume.inverseMatrix }\n get center (): Vector3 { return this.volume.center }\n get boundingBox (): Box3 { return this.volume.boundingBox }\n get min () { return this.volume.min }\n get max () { return this.volume.max }\n get mean () { return this.volume.mean }\n get rms () { return this.volume.rms }\n\n _getFilterHash (minValue: number, maxValue: number, outside: boolean) {\n return JSON.stringify([ minValue, maxValue, outside ])\n }\n\n setFilter (minValue: number|undefined, maxValue: number|undefined, outside: boolean|undefined) {\n if (isNaN(minValue) && this.header) {\n minValue = this.header.DMEAN + 2.0 * this.header.ARMS\n }\n\n minValue = (minValue !== undefined && !isNaN(minValue)) ? minValue : -Infinity\n maxValue = defaults(maxValue, Infinity) as number\n outside = defaults(outside, false) as boolean\n\n const data = this.volume.data\n const position = this.volume.position\n const atomindex = this.volume.atomindex\n\n const filterHash = this._getFilterHash(minValue, maxValue, outside)\n\n if (filterHash === this._filterHash) {\n // already filtered\n return\n } else if (minValue === -Infinity && maxValue === Infinity) {\n this.data = data\n this.position = position\n this.atomindex = atomindex!\n } else {\n const n = data.length\n\n if (!this._dataBuffer) {\n // ArrayBuffer for re-use as Float32Array backend\n\n this._dataBuffer = new ArrayBuffer(n * 4)\n this._positionBuffer = new ArrayBuffer(n * 3 * 4)\n if (atomindex) this._atomindexBuffer = new ArrayBuffer(n * 4)\n }\n\n const filteredData = new Float32Array(this._dataBuffer)\n const filteredPosition = new Float32Array(this._positionBuffer)\n let filteredAtomindex\n if (atomindex) filteredAtomindex = new Uint32Array(this._atomindexBuffer)\n\n let j = 0\n\n for (let i = 0; i < n; ++i) {\n const i3 = i * 3\n const v = data[ i ]\n\n if ((!outside && v >= minValue && v <= maxValue) ||\n (outside && (v < minValue || v > maxValue))\n ) {\n const j3 = j * 3\n\n filteredData[ j ] = v\n\n filteredPosition[ j3 + 0 ] = position[ i3 + 0 ]\n filteredPosition[ j3 + 1 ] = position[ i3 + 1 ]\n filteredPosition[ j3 + 2 ] = position[ i3 + 2 ]\n\n if (atomindex && filteredAtomindex) filteredAtomindex[ j ] = atomindex[ i ]\n\n j += 1\n }\n }\n\n // set views\n\n this.data = new Float32Array(this._dataBuffer, 0, j)\n this.position = new Float32Array(this._positionBuffer, 0, j * 3)\n if (atomindex) this.atomindex = new Int32Array(this._atomindexBuffer, 0, j)\n }\n\n this._filterHash = filterHash\n }\n}\n\nFilteredVolume.prototype.getValueForSigma = Volume.prototype.getValueForSigma\nFilteredVolume.prototype.getSigmaForValue = Volume.prototype.getSigmaForValue\n\nFilteredVolume.prototype.getDataAtomindex = Volume.prototype.getDataAtomindex\nFilteredVolume.prototype.getDataPosition = Volume.prototype.getDataPosition\nFilteredVolume.prototype.getDataColor = Volume.prototype.getDataColor\nFilteredVolume.prototype.getDataPicking = Volume.prototype.getDataPicking\nFilteredVolume.prototype.getDataSize = Volume.prototype.getDataSize\n\nexport default FilteredVolume\n","/**\n * @file Bond Hash\n * @author Alexander Rose \n * @private\n */\n\nimport BondStore from './bond-store'\nimport { createAdjacencyList } from '../utils/adjacency-list'\n\nclass BondHash {\n countArray: Uint8Array\n offsetArray: Int32Array\n indexArray: Int32Array\n\n constructor (bondStore: BondStore, atomCount: number) {\n const al = createAdjacencyList({\n nodeArray1: bondStore.atomIndex1,\n nodeArray2: bondStore.atomIndex2,\n edgeCount: bondStore.count,\n nodeCount: atomCount\n })\n\n this.countArray = al.countArray\n this.offsetArray = al.offsetArray\n this.indexArray = al.indexArray\n }\n}\n\nexport default BondHash\n","/**\n * @file Bond Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Bond store\n */\nexport default class BondStore extends Store {\n atomIndex1: Uint32Array\n atomIndex2: Uint32Array\n bondOrder: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'atomIndex1', 1, 'int32' ],\n [ 'atomIndex2', 1, 'int32' ],\n [ 'bondOrder', 1, 'int8' ]\n ] as StoreField[]\n }\n\n addBond (atom1: AtomProxy, atom2: AtomProxy, bondOrder?: number) {\n this.growIfFull()\n\n const i = this.count\n const ai1 = atom1.index\n const ai2 = atom2.index\n\n if (ai1 < ai2) {\n this.atomIndex1[ i ] = ai1\n this.atomIndex2[ i ] = ai2\n } else {\n this.atomIndex2[ i ] = ai1\n this.atomIndex1[ i ] = ai2\n }\n if (bondOrder) this.bondOrder[ i ] = bondOrder\n\n this.count += 1\n }\n\n addBondIfConnected (atom1: AtomProxy, atom2: AtomProxy, bondOrder?: number) {\n if (atom1.connectedTo(atom2)) {\n this.addBond(atom1, atom2, bondOrder)\n return true\n }\n\n return false\n }\n}","/**\n * @file Atom Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Atom store\n */\nexport default class AtomStore extends Store {\n residueIndex: Uint32Array\n atomTypeId: Uint16Array\n\n x: Float32Array\n y: Float32Array\n z: Float32Array\n serial: Int32Array\n bfactor: Float32Array\n altloc: Uint8Array\n occupancy: Float32Array\n\n partialCharge?: Float32Array\n formalCharge?: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'residueIndex', 1, 'uint32' ],\n [ 'atomTypeId', 1, 'uint16' ],\n\n [ 'x', 1, 'float32' ],\n [ 'y', 1, 'float32' ],\n [ 'z', 1, 'float32' ],\n [ 'serial', 1, 'int32' ],\n [ 'bfactor', 1, 'float32' ],\n [ 'altloc', 1, 'uint8' ],\n [ 'occupancy', 1, 'float32' ]\n ] as StoreField[]\n }\n\n setAltloc (i: number, str: string) {\n this.altloc[ i ] = str.charCodeAt(0)\n }\n\n getAltloc (i: number) {\n const code = this.altloc[ i ]\n return code ? String.fromCharCode(code) : ''\n }\n}","/**\n * @file Residue Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Residue store\n */\nexport default class ResidueStore extends Store {\n chainIndex: Uint32Array\n atomOffset: Uint32Array\n atomCount: Uint32Array\n residueTypeId: Uint16Array\n\n resno: Uint32Array\n sstruc: Uint8Array\n inscode: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'chainIndex', 1, 'uint32' ],\n [ 'atomOffset', 1, 'uint32' ],\n [ 'atomCount', 1, 'uint32' ],\n [ 'residueTypeId', 1, 'uint16' ],\n\n [ 'resno', 1, 'int32' ],\n [ 'sstruc', 1, 'uint8' ],\n [ 'inscode', 1, 'uint8' ]\n ] as StoreField[]\n }\n\n setSstruc (i: number, str: string) {\n this.sstruc[ i ] = str.charCodeAt(0)\n }\n\n getSstruc (i: number) {\n const code = this.sstruc[ i ]\n return code ? String.fromCharCode(code) : ''\n }\n\n setInscode (i: number, str: string) {\n this.inscode[ i ] = str.charCodeAt(0)\n }\n\n getInscode (i: number) {\n const code = this.inscode[ i ]\n return code ? String.fromCharCode(code) : ''\n }\n}","/**\n * @file Chain Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Chain store\n */\nexport default class ChainStore extends Store {\n entityIndex: Uint16Array\n modelIndex: Uint16Array\n residueOffset: Uint32Array\n residueCount: Uint32Array\n\n chainname: Uint8Array\n chainid: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'entityIndex', 1, 'uint16' ],\n [ 'modelIndex', 1, 'uint16' ],\n [ 'residueOffset', 1, 'uint32' ],\n [ 'residueCount', 1, 'uint32' ],\n\n [ 'chainname', 4, 'uint8' ],\n [ 'chainid', 4, 'uint8' ]\n ] as StoreField[]\n }\n\n setChainname (i: number, str: string) {\n const j = 4 * i\n this.chainname[ j ] = str.charCodeAt(0)\n this.chainname[ j + 1 ] = str.charCodeAt(1)\n this.chainname[ j + 2 ] = str.charCodeAt(2)\n this.chainname[ j + 3 ] = str.charCodeAt(3)\n }\n\n getChainname (i: number) {\n let chainname = ''\n for (let k = 0; k < 4; ++k) {\n const code = this.chainname[ 4 * i + k ]\n if (code) {\n chainname += String.fromCharCode(code)\n } else {\n break\n }\n }\n return chainname\n }\n\n setChainid (i: number, str: string) {\n const j = 4 * i\n this.chainid[ j ] = str.charCodeAt(0)\n this.chainid[ j + 1 ] = str.charCodeAt(1)\n this.chainid[ j + 2 ] = str.charCodeAt(2)\n this.chainid[ j + 3 ] = str.charCodeAt(3)\n }\n\n getChainid (i: number) {\n let chainid = ''\n for (let k = 0; k < 4; ++k) {\n const code = this.chainid[ 4 * i + k ]\n if (code) {\n chainid += String.fromCharCode(code)\n } else {\n break\n }\n }\n return chainid\n }\n}\n","/**\n * @file Model Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Model store\n */\nexport default class ModelStore extends Store {\n\tchainOffset: Uint32Array\n\tchainCount: Uint32Array\n\n get _defaultFields () {\n return [\n [ 'chainOffset', 1, 'uint32' ],\n [ 'chainCount', 1, 'uint32' ]\n ] as StoreField[]\n }\n}","/**\n * @file Helixorient\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport { ColormakerParameters } from '../color/colormaker'\nimport { AtomPicker } from '../utils/picker'\nimport RadiusFactory, { RadiusParams } from '../utils/radius-factory'\nimport { copyArray } from '../math/array-utils'\nimport { projectPointOnVector } from '../math/vector-utils'\nimport Polymer from '../proxy/polymer'\n\nexport interface HelixIterator {\n size: number\n next: () => Vector3\n get: (idx: number) => Vector3\n reset: () => void\n}\n\nexport interface HelixPosition {\n center: Float32Array\n axis: Float32Array\n bending: Float32Array\n radius: Float32Array\n rise: Float32Array\n twist: Float32Array\n resdir: Float32Array\n}\n\nclass Helixorient {\n size: number\n\n constructor (readonly polymer: Polymer) {\n this.size = polymer.residueCount\n }\n\n getCenterIterator (smooth = 0): HelixIterator {\n const center = this.getPosition().center\n const size = center.length / 3\n\n let i = 0\n let j = -1\n\n const cache = [\n new Vector3(),\n new Vector3(),\n new Vector3(),\n new Vector3()\n ]\n\n function next (this: HelixIterator) {\n const vector = this.get(j)\n j += 1\n return vector\n }\n\n function get (idx: number) {\n idx = Math.min(size - 1, Math.max(0, idx))\n const v = cache[ i % 4 ]\n const idx3 = 3 * idx\n v.fromArray(center as any, idx3) // TODO\n if (smooth) {\n const w = Math.min(smooth, idx, size - idx - 1)\n for (let k = 1; k <= w; ++k) {\n const l = k * 3\n const t = (w + 1 - k) / (w + 1)\n v.x += t * center[ idx3 - l + 0 ] + t * center[ idx3 + l + 0 ]\n v.y += t * center[ idx3 - l + 1 ] + t * center[ idx3 + l + 1 ]\n v.z += t * center[ idx3 - l + 2 ] + t * center[ idx3 + l + 2 ]\n }\n v.x /= w + 1\n v.y /= w + 1\n v.z /= w + 1\n }\n i += 1\n return v\n }\n\n function reset () {\n i = 0\n j = -1\n }\n\n return { size, next, get, reset }\n }\n\n getColor (params: { scheme: string } & ColormakerParameters) {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const residueIndexStart = polymer.residueIndexStart\n\n const col = new Float32Array(n * 3)\n\n const p = params || {}\n p.structure = structure\n\n const colormaker = ColormakerRegistry.getScheme(p)\n\n const rp = structure.getResidueProxy()\n const ap = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n rp.index = residueIndexStart + i\n ap.index = rp.traceAtomIndex\n\n colormaker.atomColorToArray(ap, col, i * 3)\n }\n\n return {\n 'color': col\n }\n }\n\n getPicking () {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const residueIndexStart = polymer.residueIndexStart\n\n const pick = new Float32Array(n)\n const rp = structure.getResidueProxy()\n\n for (let i = 0; i < n; ++i) {\n rp.index = residueIndexStart + i\n pick[ i ] = rp.traceAtomIndex\n }\n\n return {\n 'picking': new AtomPicker(pick, structure)\n }\n }\n\n getSize (params: RadiusParams) {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const residueIndexStart = polymer.residueIndexStart\n\n const size = new Float32Array(n)\n const radiusFactory = new RadiusFactory(params)\n\n const rp = structure.getResidueProxy()\n const ap = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n rp.index = residueIndexStart + i\n ap.index = rp.traceAtomIndex\n size[ i ] = radiusFactory.atomRadius(ap)\n }\n\n return { size }\n }\n\n getPosition (): HelixPosition {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const n3 = n - 3\n\n const center = new Float32Array(3 * n)\n const axis = new Float32Array(3 * n)\n const diff = new Float32Array(n)\n const radius = new Float32Array(n)\n const rise = new Float32Array(n)\n const twist = new Float32Array(n)\n const resdir = new Float32Array(3 * n)\n\n const r12 = new Vector3()\n const r23 = new Vector3()\n const r34 = new Vector3()\n\n const diff13 = new Vector3()\n const diff24 = new Vector3()\n\n const v1 = new Vector3()\n const v2 = new Vector3()\n const vt = new Vector3()\n\n const _axis = new Vector3()\n const _prevAxis = new Vector3()\n\n const _resdir = new Vector3()\n const _center = new Vector3(0, 0, 0)\n\n const type = 'trace'\n const a1 = structure.getAtomProxy()\n const a2 = structure.getAtomProxy(polymer.getAtomIndexByType(0, type))\n const a3 = structure.getAtomProxy(polymer.getAtomIndexByType(1, type))\n const a4 = structure.getAtomProxy(polymer.getAtomIndexByType(2, type))\n\n for (let i = 0; i < n3; ++i) {\n a1.index = a2.index\n a2.index = a3.index\n a3.index = a4.index\n a4.index = polymer.getAtomIndexByType(i + 3, type)! // TODO\n\n const j = 3 * i\n\n // ported from GROMACS src/tools/gmx_helixorient.c\n\n r12.subVectors(a2 as any, a1 as any) // TODO\n r23.subVectors(a3 as any, a2 as any) // TODO\n r34.subVectors(a4 as any, a3 as any) // TODO\n\n diff13.subVectors(r12, r23)\n diff24.subVectors(r23, r34)\n\n _axis.crossVectors(diff13, diff24).normalize()\n _axis.toArray(axis as any, j) // TODO\n\n if (i > 0) {\n diff[ i ] = _axis.angleTo(_prevAxis)\n }\n\n const tmp = Math.cos(diff13.angleTo(diff24))\n twist[ i ] = 180.0 / Math.PI * Math.acos(tmp)\n\n const diff13Length = diff13.length()\n const diff24Length = diff24.length()\n\n radius[ i ] = (\n Math.sqrt(diff24Length * diff13Length) /\n // clamp, to avoid instabilities for when\n // angle between diff13 and diff24 is near 0\n Math.max(2.0, 2.0 * (1.0 - tmp))\n )\n\n rise[ i ] = Math.abs(r23.dot(_axis))\n\n //\n\n v1.copy(diff13).multiplyScalar(radius[ i ] / diff13Length)\n v2.copy(diff24).multiplyScalar(radius[ i ] / diff24Length)\n\n v1.subVectors(a2 as any, v1) // TODO\n v2.subVectors(a3 as any, v2) // TODO\n\n v1.toArray(center as any, j + 3) // TODO\n v2.toArray(center as any, j + 6) // TODO\n\n //\n\n _resdir.subVectors(a1 as any, _center) // TODO\n _resdir.toArray(resdir as any, j) // TODO\n\n _prevAxis.copy(_axis)\n _center.copy(v1)\n }\n\n //\n\n // calc axis as dir of second and third center pos\n // project first traceAtom onto axis to get first center pos\n v1.fromArray(center as any, 3) // TODO\n v2.fromArray(center as any, 6) // TODO\n _axis.subVectors(v1, v2).normalize()\n // _center.copy( res[ 0 ].getTraceAtom() );\n a1.index = polymer.getAtomIndexByType(0, type)! // TODO\n _center.copy(a1 as any) // TODO\n vt.copy(a1 as any) // TODO\n projectPointOnVector(vt, _axis, v1)\n vt.toArray(center as any, 0) // TODO\n\n // calc first resdir\n _resdir.subVectors(_center, v1)\n _resdir.toArray(resdir as any, 0) // TODO\n\n // calc axis as dir of n-1 and n-2 center pos\n // project last traceAtom onto axis to get last center pos\n v1.fromArray(center as any, 3 * n - 6) // TODO\n v2.fromArray(center as any, 3 * n - 9) // TODO\n _axis.subVectors(v1, v2).normalize()\n // _center.copy( res[ n - 1 ].getTraceAtom() );\n a1.index = polymer.getAtomIndexByType(n - 1, type)! // TODO\n _center.copy(a1 as any) // TODO\n vt.copy(a1 as any) // TODO\n projectPointOnVector(vt, _axis, v1)\n vt.toArray(center as any, 3 * n - 3) // TODO\n\n // calc last three resdir\n for (let i = n - 3; i < n; ++i) {\n v1.fromArray(center as any, 3 * i) // TODO\n // _center.copy( res[ i ].getTraceAtom() );\n a1.index = polymer.getAtomIndexByType(i, type)! // TODO\n _center.copy(a1 as any) // TODO\n\n _resdir.subVectors(_center, v1)\n _resdir.toArray(resdir as any, 3 * i) // TODO\n }\n\n // average measures to define them on the residues\n\n const resRadius = new Float32Array(n)\n const resTwist = new Float32Array(n)\n const resRise = new Float32Array(n)\n const resBending = new Float32Array(n)\n\n resRadius[ 1 ] = radius[ 0 ]\n resTwist[ 1 ] = twist[ 0 ]\n resRise[ 1 ] = radius[ 0 ]\n\n for (let i = 2; i < n - 2; ++i) {\n resRadius[ i ] = 0.5 * (radius[ i - 2 ] + radius[ i - 1 ])\n resTwist[ i ] = 0.5 * (twist[ i - 2 ] + twist[ i - 1 ])\n resRise[ i ] = 0.5 * (rise[ i - 2 ] + rise[ i - 1 ])\n\n v1.fromArray(axis as any, 3 * (i - 2)) // TODO\n v2.fromArray(axis as any, 3 * (i - 1)) // TODO\n resBending[ i ] = 180.0 / Math.PI * Math.acos(Math.cos(v1.angleTo(v2)))\n }\n\n resRadius[ n - 2 ] = radius[ n - 4 ]\n resTwist[ n - 2 ] = twist[ n - 4 ]\n resRise[ n - 2 ] = rise[ n - 4 ]\n\n // average helix axes to define them on the residues\n\n const resAxis = new Float32Array(3 * n)\n\n copyArray(axis, resAxis, 0, 0, 3)\n copyArray(axis, resAxis, 0, 3, 3)\n\n for (let i = 2; i < n - 2; ++i) {\n v1.fromArray(axis as any, 3 * (i - 2)) // TODO\n v2.fromArray(axis as any, 3 * (i - 1)) // TODO\n\n _axis.addVectors(v2, v1).multiplyScalar(0.5).normalize()\n _axis.toArray(resAxis as any, 3 * i) // TODO\n }\n\n copyArray(axis, resAxis, 3 * n - 12, 3 * n - 6, 3)\n copyArray(axis, resAxis, 3 * n - 12, 3 * n - 3, 3)\n\n return {\n center,\n axis: resAxis,\n bending: resBending,\n radius: resRadius,\n rise: resRise,\n twist: resTwist,\n resdir: resdir\n }\n }\n\n}\n\nexport default Helixorient\n","/**\n * @file Helixbundle\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport { AtomPicker } from '../utils/picker'\nimport RadiusFactory, { RadiusParams } from '../utils/radius-factory'\nimport Helixorient, { HelixPosition } from './helixorient'\nimport { calculateMeanVector3, projectPointOnVector } from '../math/vector-utils'\nimport Polymer from '../proxy/polymer'\nimport { ColormakerParameters } from '../color/colormaker';\n\nexport interface Axis {\n axis: Float32Array\n center: Float32Array\n begin: Float32Array\n end: Float32Array\n color: Float32Array\n picking: AtomPicker\n size: Float32Array\n residueOffset: number[]\n residueCount: number[]\n}\n\nclass Helixbundle {\n helixorient: Helixorient;\n position: HelixPosition;\n\n constructor (readonly polymer: Polymer) {\n\n this.helixorient = new Helixorient(polymer)\n this.position = this.helixorient.getPosition()\n }\n\n getAxis (localAngle: number, centerDist: number, ssBorder: boolean, colorParams: { scheme: string} & ColormakerParameters, radiusParams: RadiusParams): Axis {\n localAngle = localAngle || 30\n centerDist = centerDist || 2.5\n ssBorder = ssBorder === undefined ? false : ssBorder\n\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const residueIndexStart = polymer.residueIndexStart\n\n const pos = this.position\n\n const cp = colorParams || {}\n cp.structure = structure\n\n const colormaker = ColormakerRegistry.getScheme(cp)\n\n const radiusFactory = new RadiusFactory(radiusParams)\n\n let j = 0\n let k = 0\n\n const axis: number[] = []\n const center: number[] = []\n const beg: number[] = []\n const end: number[] = []\n const col: number[] = []\n const pick = []\n const size = []\n const residueOffset = []\n const residueCount = []\n\n let tmpAxis = new Float32Array(n * 3)\n let tmpCenter = new Float32Array(n * 3)\n\n let _axis, _center\n const _beg = new Vector3()\n const _end = new Vector3()\n\n const rp1 = structure.getResidueProxy()\n const rp2 = structure.getResidueProxy()\n const ap = structure.getAtomProxy()\n\n const c1 = new Vector3()\n const c2 = new Vector3()\n\n let split = false\n\n for (let i = 0; i < n; ++i) {\n rp1.index = residueIndexStart + i\n c1.fromArray(pos.center as any, i * 3)\n\n if (i === n - 1) {\n split = true\n } else {\n rp2.index = residueIndexStart + i + 1\n c2.fromArray(pos.center as any, i * 3 + 3)\n\n if (ssBorder && rp1.sstruc !== rp2.sstruc) {\n split = true\n } else if (c1.distanceTo(c2) > centerDist) {\n split = true\n } else if (pos.bending[ i ] > localAngle) {\n split = true\n }\n }\n\n if (split) {\n if (i - j < 4) {\n j = i\n split = false\n continue\n }\n\n ap.index = rp1.traceAtomIndex\n\n // ignore first and last axis\n tmpAxis = pos.axis.subarray(j * 3 + 3, i * 3)\n tmpCenter = pos.center.subarray(j * 3, i * 3 + 3)\n\n _axis = calculateMeanVector3(tmpAxis).normalize()\n _center = calculateMeanVector3(tmpCenter)\n\n _beg.fromArray(tmpCenter as any)\n projectPointOnVector(_beg, _axis, _center)\n\n _end.fromArray(tmpCenter as any, tmpCenter.length - 3)\n projectPointOnVector(_end, _axis, _center)\n\n _axis.subVectors(_end, _beg)\n\n _axis.toArray(axis as any, k)\n _center.toArray(center as any, k)\n _beg.toArray(beg as any, k)\n _end.toArray(end as any, k)\n\n colormaker.atomColorToArray(ap, col, k)\n\n pick.push(ap.index)\n\n size.push(radiusFactory.atomRadius(ap))\n\n residueOffset.push(residueIndexStart + j)\n residueCount.push(residueIndexStart + i + 1 - j)\n\n k += 3\n j = i\n split = false\n }\n }\n\n const picking = new Float32Array(pick)\n\n return {\n axis: new Float32Array(axis),\n center: new Float32Array(center),\n begin: new Float32Array(beg),\n end: new Float32Array(end),\n color: new Float32Array(col),\n picking: new AtomPicker(picking, structure),\n size: new Float32Array(size),\n residueOffset: residueOffset,\n residueCount: residueCount\n }\n }\n}\n\nexport default Helixbundle\n","/**\n * @file Binary Heap\n * @author Alexander Rose \n * @private\n */\n\n/**\n * Binary heap implementation\n * @class\n * @author http://eloquentjavascript.net/appendix2.htm\n * @param {Function} scoreFunction - the heap scoring function\n */\nclass BinaryHeap {\n content: T[] = []\n\n constructor(readonly scoreFunction: (x: T) => number) {\n\n this.scoreFunction = scoreFunction\n }\n\n push (element: T) {\n // Add the new element to the end of the array.\n this.content.push(element)\n\n // Allow it to bubble up.\n this.bubbleUp(this.content.length - 1)\n }\n\n pop () {\n // Store the first element so we can return it later.\n const result = this.content[ 0 ]\n\n // Get the element at the end of the array.\n const end = this.content.pop()\n\n // If there are any elements left, put the end element at the\n // start, and let it sink down.\n if (end && this.content.length > 0) {\n this.content[ 0 ] = end\n this.sinkDown(0)\n }\n\n return result\n }\n\n peek () {\n return this.content[ 0 ]\n }\n\n remove (element: T) {\n const len = this.content.length\n\n // To remove a value, we must search through the array to find it.\n for (let i = 0; i < len; i++) {\n if (this.content[ i ] === element) {\n // When it is found, the process seen in 'pop' is repeated\n // to fill up the hole.\n const end = this.content.pop()\n\n if (end && i !== len - 1) {\n this.content[ i ] = end\n\n if (this.scoreFunction(end) < this.scoreFunction(element)) {\n this.bubbleUp(i)\n } else {\n this.sinkDown(i)\n }\n }\n\n return\n }\n }\n\n throw new Error('Node not found.')\n }\n\n size () {\n return this.content.length\n }\n\n bubbleUp (n: number) {\n // Fetch the element that has to be moved.\n const element = this.content[ n ]\n\n // When at 0, an element can not go up any further.\n while (n > 0) {\n // Compute the parent element's index, and fetch it.\n const parentN = Math.floor((n + 1) / 2) - 1\n const parent = this.content[ parentN ]\n\n // Swap the elements if the parent is greater.\n if (this.scoreFunction(element) < this.scoreFunction(parent)) {\n this.content[ parentN ] = element\n this.content[ n ] = parent\n\n // Update 'n' to continue at the new position.\n n = parentN\n } else {\n // Found a parent that is less, no need to move it further.\n break\n }\n }\n }\n\n sinkDown (n: number) {\n // Look up the target element and its score.\n const length = this.content.length\n const element = this.content[ n ]\n const elemScore = this.scoreFunction(element)\n\n let child1Score = 0\n let child2Score = 0\n\n while (true) {\n // Compute the indices of the child elements.\n const child2N = (n + 1) * 2\n const child1N = child2N - 1\n\n // This is used to store the new position of the element, if any.\n let swap = null\n\n // If the first child exists (is inside the array)...\n if (child1N < length) {\n // Look it up and compute its score.\n const child1 = this.content[ child1N ]\n child1Score = this.scoreFunction(child1)\n\n // If the score is less than our element's, we need to swap.\n if (child1Score < elemScore) swap = child1N\n }\n\n // Do the same checks for the other child.\n if (child2N < length) {\n const child2 = this.content[ child2N ]\n child2Score = this.scoreFunction(child2)\n\n if (child2Score < (swap === null ? elemScore : child1Score)) swap = child2N\n }\n\n // If the element needs to be moved, swap it, and continue.\n if (swap !== null) {\n this.content[ n ] = this.content[ swap ]\n this.content[ swap ] = element\n n = swap\n } else {\n // Otherwise, we are done.\n break\n }\n }\n }\n\n}\n\nexport default BinaryHeap\n","/**\n * @file Kdtree\n * @author Alexander Rose \n * @private\n */\n\nimport { NumberArray } from '../types'\nimport BinaryHeap from './binary-heap'\n\n/**\n * Kdtree\n * @class\n * @author Alexander Rose , 2016\n * @author Roman Bolzern , 2013\n * @author I4DS http://www.fhnw.ch/i4ds, 2013\n * @license MIT License \n * @description\n * k-d Tree for typed arrays of 3d points (e.g. for Float32Array), in-place\n * provides fast nearest neighbour search\n *\n * Based on https://github.com/ubilabs/kd-tree-javascript by Ubilabs\n *\n * Further information (including mathematical properties)\n * http://en.wikipedia.org/wiki/Binary_tree\n * http://en.wikipedia.org/wiki/K-d_tree\n *\n * @example\n * points: [x, y, z, x, y, z, x, y, z, ...]\n * metric: function(a, b){\n * return Math.pow(a[0]-b[0], 2) + Math.pow(a[1]-b[1], 2) + Math.pow(a[2]-b[2], 2);\n * }\n *\n * @param {Float32Array} points - points\n * @param {Function} metric - metric\n */\nclass Kdtree {\n indices: Uint32Array\n nodes: Int32Array\n rootIndex: number\n\n maxDepth = 0\n currentNode = 0\n\n constructor(readonly points: NumberArray, readonly metric: (a: NumberArray, b: NumberArray) => number) {\n const n = points.length / 3\n\n const indices = new Uint32Array(n)\n for (let i = 0; i < n; ++i) {\n indices[ i ] = i\n }\n this.indices = indices\n this.nodes = new Int32Array(n * 4)\n this.rootIndex = this.buildTree(0, -1, 0, n)\n }\n\n buildTree (depth: number, parent: number, arrBegin: number, arrEnd: number) {\n if (depth > this.maxDepth) this.maxDepth = depth\n\n const plength = arrEnd - arrBegin\n if (plength === 0) {\n return -1\n }\n\n const nodeIndex = this.currentNode * 4\n const nodes = this.nodes\n\n this.currentNode += 1\n if (plength === 1) {\n nodes[ nodeIndex ] = arrBegin\n nodes[ nodeIndex + 1 ] = -1\n nodes[ nodeIndex + 2 ] = -1\n nodes[ nodeIndex + 3 ] = parent\n return nodeIndex\n }\n // if(plength <= 32){\n // return nodeIndex;\n // }\n\n const indices = this.indices\n const points = this.points\n\n const arrMedian = arrBegin + Math.floor(plength / 2)\n const currentDim = depth % 3\n\n // inlined quickselect function\n let j, tmp, pivotIndex, pivotValue, storeIndex\n let left = arrBegin\n let right = arrEnd - 1\n while (right > left) {\n pivotIndex = (left + right) >> 1\n pivotValue = points[ indices[ pivotIndex ] * 3 + currentDim ]\n // swap( pivotIndex, right );\n tmp = indices[ pivotIndex ]\n indices[ pivotIndex ] = indices[ right ]\n indices[ right ] = tmp\n storeIndex = left\n for (j = left; j < right; ++j) {\n if (points[ indices[ j ] * 3 + currentDim ] < pivotValue) {\n // swap( storeIndex, j );\n tmp = indices[ storeIndex ]\n indices[ storeIndex ] = indices[ j ]\n indices[ j ] = tmp\n ++storeIndex\n }\n }\n // swap( right, storeIndex );\n tmp = indices[ right ]\n indices[ right ] = indices[ storeIndex ]\n indices[ storeIndex ] = tmp\n pivotIndex = storeIndex\n if (arrMedian === pivotIndex) {\n break\n } else if (arrMedian < pivotIndex) {\n right = pivotIndex - 1\n } else {\n left = pivotIndex + 1\n }\n }\n\n nodes[ nodeIndex ] = arrMedian\n nodes[ nodeIndex + 1 ] = this.buildTree(depth + 1, nodeIndex, arrBegin, arrMedian)\n nodes[ nodeIndex + 2 ] = this.buildTree(depth + 1, nodeIndex, arrMedian + 1, arrEnd)\n nodes[ nodeIndex + 3 ] = parent\n\n return nodeIndex\n }\n\n getNodeDepth (nodeIndex: number): number {\n const parentIndex = this.nodes[ nodeIndex + 3 ]\n return (parentIndex === -1) ? 0 : this.getNodeDepth(parentIndex) + 1\n }\n\n // TODO\n // function getNodePos (node) {}\n\n /**\n * find nearest points\n * @param {Array} point - array of size 3\n * @param {Integer} maxNodes - max amount of nodes to return\n * @param {Float} maxDistance - maximum distance of point to result nodes\n * @return {Array} array of point, distance pairs\n */\n nearest (point: NumberArray, maxNodes: number, maxDistance: number) {\n const bestNodes = new BinaryHeap<[number, number]>(e => -e[ 1 ])\n\n const nodes = this.nodes\n const points = this.points\n const indices = this.indices\n\n const nearestSearch = (nodeIndex: number) => {\n let bestChild, otherChild\n const dimension = this.getNodeDepth(nodeIndex) % 3\n const pointIndex = indices[ nodes[ nodeIndex ] ] * 3\n const ownPoint = [\n points[ pointIndex + 0 ],\n points[ pointIndex + 1 ],\n points[ pointIndex + 2 ]\n ]\n const ownDistance = this.metric(point, ownPoint)\n\n function saveNode (nodeIndex: number, distance: number) {\n bestNodes.push([ nodeIndex, distance ])\n if (bestNodes.size() > maxNodes) {\n bestNodes.pop()\n }\n }\n\n const leftIndex = nodes[ nodeIndex + 1 ]\n const rightIndex = nodes[ nodeIndex + 2 ]\n\n // if it's a leaf\n if (rightIndex === -1 && leftIndex === -1) {\n if ((bestNodes.size() < maxNodes || ownDistance < bestNodes.peek()[ 1 ]) &&\n ownDistance <= maxDistance\n ) {\n saveNode(nodeIndex, ownDistance)\n }\n return\n }\n\n if (rightIndex === -1) {\n bestChild = leftIndex\n } else if (leftIndex === -1) {\n bestChild = rightIndex\n } else {\n if (point[ dimension ] <= points[ pointIndex + dimension ]) {\n bestChild = leftIndex\n } else {\n bestChild = rightIndex\n }\n }\n\n // recursive search\n nearestSearch(bestChild)\n\n if ((bestNodes.size() < maxNodes || ownDistance < bestNodes.peek()[ 1 ]) &&\n ownDistance <= maxDistance\n ) {\n saveNode(nodeIndex, ownDistance)\n }\n\n // if there's still room or the current distance is nearer than the best distance\n const linearPoint = []\n for (let i = 0; i < 3; i += 1) {\n if (i === dimension) {\n linearPoint[ i ] = point[ i ]\n } else {\n linearPoint[ i ] = points[ pointIndex + i ]\n }\n }\n const linearDistance = this.metric(linearPoint, ownPoint)\n\n if ((bestNodes.size() < maxNodes || Math.abs(linearDistance) < bestNodes.peek()[ 1 ]) &&\n Math.abs(linearDistance) <= maxDistance\n ) {\n if (bestChild === leftIndex) {\n otherChild = rightIndex\n } else {\n otherChild = leftIndex\n }\n if (otherChild !== -1) {\n nearestSearch(otherChild)\n }\n }\n }\n\n nearestSearch(this.rootIndex)\n\n const result = []\n for (let i = 0, il = Math.min(bestNodes.size(), maxNodes); i < il; i += 1) {\n result.push(bestNodes.content[ i ])\n }\n\n return result\n }\n\n verify (nodeIndex?: number, depth = 0) {\n let count = 1\n\n if (nodeIndex === undefined) {\n nodeIndex = this.rootIndex\n }\n\n if (nodeIndex === -1) {\n throw new Error('node is null')\n }\n\n const dim = depth % 3\n const nodes = this.nodes\n const points = this.points\n const indices = this.indices\n\n const leftIndex = nodes[ nodeIndex + 1 ]\n const rightIndex = nodes[ nodeIndex + 2 ]\n\n if (leftIndex !== -1) {\n if (points[ indices[ nodes[ leftIndex ] ] * 3 + dim ] >\n points[ indices[ nodes[ nodeIndex ] ] * 3 + dim ]\n ) {\n throw new Error('left child is > parent!')\n }\n count += this.verify(leftIndex, depth + 1)\n }\n\n if (rightIndex !== -1) {\n if (points[ indices[ nodes[ rightIndex ] ] * 3 + dim ] <\n points[ indices[ nodes[ nodeIndex ] ] * 3 + dim ]\n ) {\n throw new Error('right child is < parent!')\n }\n count += this.verify(rightIndex, depth + 1)\n }\n\n return count\n }\n}\n\nexport default Kdtree\n","/**\n * @file Atom Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { NumberArray } from '../types'\nimport {\n Elements,\n SecStrucHelix, SecStrucSheet, SecStrucTurn,\n ProteinType, RnaType, DnaType, WaterType, IonType, SaccharideType,\n CgProteinBackboneType, CgRnaBackboneType, CgDnaBackboneType\n} from '../structure/structure-constants'\n\nimport Structure from '../structure/structure'\n\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\nimport AtomStore from '../store/atom-store'\n\nimport AtomMap from '../store/atom-map'\nimport ResidueMap from '../store/residue-map'\n\nimport BondProxy from '../proxy/bond-proxy'\nimport AtomType from '../store/atom-type';\nimport ResidueType from '../store/residue-type';\nimport ResidueProxy from './residue-proxy';\nimport Entity from '../structure/entity';\nimport BondHash from '../store/bond-hash';\n\n/**\n * Atom proxy\n */\nclass AtomProxy {\n index: number\n\n chainStore: ChainStore\n residueStore: ResidueStore\n atomStore: AtomStore\n\n residueMap: ResidueMap\n atomMap: AtomMap\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n this.atomStore = structure.atomStore\n this.residueMap = structure.residueMap\n this.atomMap = structure.atomMap\n }\n\n /**\n * @type {BondHash}\n */\n get bondHash (): BondHash|undefined { return this.structure.bondHash }\n\n /**\n * Molecular enity\n * @type {Entity}\n */\n get entity (): Entity {\n return this.structure.entityList[ this.entityIndex ]\n }\n get entityIndex () {\n return this.chainStore.entityIndex[ this.chainIndex ]\n }\n get modelIndex () {\n return this.chainStore.modelIndex[ this.chainIndex ]\n }\n get chainIndex () {\n return this.residueStore.chainIndex[ this.residueIndex ]\n }\n /**\n * @type {ResidueProxy}\n */\n get residue (): ResidueProxy {\n console.warn('residue - might be expensive')\n return this.structure.getResidueProxy(this.residueIndex)\n }\n\n get residueIndex () {\n return this.atomStore.residueIndex[ this.index ]\n }\n set residueIndex (value) {\n this.atomStore.residueIndex[ this.index ] = value\n }\n\n //\n\n /**\n * Secondary structure code\n * @type {String}\n */\n get sstruc () {\n return this.residueStore.getSstruc(this.residueIndex)\n }\n /**\n * Insertion code\n * @type {String}\n */\n get inscode () {\n return this.residueStore.getInscode(this.residueIndex)\n }\n /**\n * Residue number/label\n * @type {Integer}\n */\n get resno () {\n return this.residueStore.resno[ this.residueIndex ]\n }\n /**\n * Chain name\n * @type {String}\n */\n get chainname () {\n return this.chainStore.getChainname(this.chainIndex)\n }\n /**\n * Chain id\n * @type {String}\n */\n get chainid () {\n return this.chainStore.getChainid(this.chainIndex)\n }\n\n //\n\n /**\n * @type {ResidueType}\n */\n get residueType (): ResidueType {\n return this.residueMap.get(this.residueStore.residueTypeId[ this.residueIndex ])\n }\n /**\n * @type {AtomType}\n */\n get atomType (): AtomType {\n return this.atomMap.get(this.atomStore.atomTypeId[ this.index ])\n }\n get residueAtomOffset () {\n return this.residueStore.atomOffset[ this.residueIndex ]\n }\n\n //\n\n /**\n * Residue name\n */\n get resname () {\n return this.residueType.resname\n }\n /**\n * Hetero flag\n */\n get hetero () {\n return this.residueType.hetero\n }\n\n //\n\n /**\n * Atom name\n */\n get atomname () {\n return this.atomType.atomname\n }\n /**\n * Atomic number\n */\n get number () {\n return this.atomType.number\n }\n /**\n * Element\n */\n get element () {\n return this.atomType.element\n }\n /**\n * Van-der-Waals radius\n */\n get vdw () {\n return this.atomType.vdw\n }\n /**\n * Covalent radius\n */\n get covalent () {\n return this.atomType.covalent\n }\n\n //\n\n /**\n * X coordinate\n */\n get x () {\n return this.atomStore.x[ this.index ]\n }\n set x (value) {\n this.atomStore.x[ this.index ] = value\n }\n\n /**\n * Y coordinate\n */\n get y () {\n return this.atomStore.y[ this.index ]\n }\n set y (value) {\n this.atomStore.y[ this.index ] = value\n }\n\n /**\n * Z coordinate\n */\n get z () {\n return this.atomStore.z[ this.index ]\n }\n set z (value) {\n this.atomStore.z[ this.index ] = value\n }\n\n /**\n * Serial number\n */\n get serial () {\n return this.atomStore.serial[ this.index ]\n }\n set serial (value) {\n this.atomStore.serial[ this.index ] = value\n }\n\n /**\n * B-factor value\n */\n get bfactor () {\n return this.atomStore.bfactor[ this.index ]\n }\n set bfactor (value) {\n this.atomStore.bfactor[ this.index ] = value\n }\n\n /**\n * Occupancy value\n */\n get occupancy () {\n return this.atomStore.occupancy[ this.index ]\n }\n set occupancy (value) {\n this.atomStore.occupancy[ this.index ] = value\n }\n\n /**\n * Alternate location identifier\n */\n get altloc () {\n return this.atomStore.getAltloc(this.index)\n }\n set altloc (value) {\n this.atomStore.setAltloc(this.index, value)\n }\n\n /**\n * Partial charge\n */\n get partialCharge () {\n return this.atomStore.partialCharge ? this.atomStore.partialCharge[ this.index ] : null\n }\n set partialCharge (value) {\n if (this.atomStore.partialCharge) {\n this.atomStore.partialCharge[ this.index ] = value as number\n }\n }\n\n /**\n * Explicit radius\n */\n get radius () {\n return this.atomStore.radius ? this.atomStore.radius[ this.index ] : null\n }\n set radius (value) {\n if (this.atomStore.radius) {\n this.atomStore.radius[ this.index ] = value as number\n }\n }\n\n /**\n * Formal charge\n */\n get formalCharge () {\n return this.atomStore.formalCharge ? this.atomStore.formalCharge[ this.index ] : null\n }\n set formalCharge (value) {\n if (this.atomStore.formalCharge) {\n this.atomStore.formalCharge[ this.index ] = value as number\n }\n }\n\n /**\n * Aromaticity flag\n */\n get aromatic () {\n if (this.atomStore.aromatic) {\n return this.atomStore.aromatic[ this.index ] as number\n } else {\n return this.residueType.isAromatic(this) ? 1 : 0\n }\n }\n set aromatic (value) {\n if (this.atomStore.aromatic) {\n this.atomStore.aromatic[ this.index ] = value as number\n }\n }\n\n //\n\n get bondCount () {\n return this.bondHash!.countArray[ this.index ] // TODO\n }\n\n //\n\n /**\n * Iterate over each bond\n * @param {function(bond: BondProxy)} callback - iterator callback function\n * @param {BondProxy} [bp] - optional target bond proxy for use in the callback\n * @return {undefined}\n */\n eachBond (callback: (bp: BondProxy) => void, bp?: BondProxy) {\n bp = bp || this.structure._bp\n const idx = this.index\n const bondHash = this.bondHash! // TODO\n const indexArray = bondHash.indexArray\n const n = bondHash.countArray[ idx ]\n const offset = bondHash.offsetArray[ idx ]\n\n for (let i = 0; i < n; ++i) {\n bp.index = indexArray[ offset + i ]\n callback(bp)\n }\n }\n\n /**\n * Iterate over each bonded atom\n * @param {function(atom: AtomProxy)} callback - iterator callback function\n * @param {AtomProxy} [ap] - optional target atom proxy for use in the callback\n * @return {undefined}\n */\n eachBondedAtom (callback: (ap: AtomProxy) => void, _ap?: AtomProxy) {\n const ap = _ap ? _ap : this.structure._ap\n const idx = this.index\n\n this.eachBond(function (bp) {\n ap.index = idx !== bp.atomIndex1 ? bp.atomIndex1 : bp.atomIndex2\n callback(ap)\n })\n this.index = idx\n }\n\n /**\n * Check if this atom is bonded to the given atom,\n * assumes both atoms are from the same structure\n * @param {AtomProxy} ap - the given atom\n * @return {Boolean} whether a bond exists or not\n */\n hasBondTo (ap: AtomProxy) {\n let flag = false\n this.eachBondedAtom(function (bap) {\n if (ap.index === bap.index) flag = true\n })\n return flag\n }\n\n bondToElementCount (element: Elements) {\n let count = 0\n const idx = this.index // Avoid reentrancy problems\n this.eachBondedAtom(function (bap) {\n if (bap.number === element) count += 1\n })\n this.index = idx\n return count\n }\n\n hasBondToElement (element: Elements) {\n return this.bondToElementCount(element) > 0\n }\n\n //\n\n /**\n * If atom is part of a backbone\n * @return {Boolean} flag\n */\n isBackbone () {\n const backboneIndexList = this.residueType.backboneIndexList\n if (backboneIndexList.length > 0) {\n return backboneIndexList.includes(this.index - this.residueAtomOffset)\n } else {\n return false\n }\n }\n\n /**\n * If atom is part of a polymer\n * @return {Boolean} flag\n */\n isPolymer () {\n if (this.structure.entityList.length > 0) {\n return this.entity.isPolymer()\n } else {\n const moleculeType = this.residueType.moleculeType\n return (\n moleculeType === ProteinType ||\n moleculeType === RnaType ||\n moleculeType === DnaType\n )\n }\n }\n\n /**\n * If atom is part of a sidechin\n * @return {Boolean} flag\n */\n isSidechain () {\n return this.isPolymer() && !this.isBackbone()\n }\n\n /**\n * If atom is part of a coarse-grain group\n * @return {Boolean} flag\n */\n isCg () {\n const backboneType = this.residueType.backboneType\n return (\n backboneType === CgProteinBackboneType ||\n backboneType === CgRnaBackboneType ||\n backboneType === CgDnaBackboneType\n )\n }\n\n isTrace () {\n return this.index === (this.residueType.traceAtomIndex + this.residueAtomOffset)\n }\n\n /**\n * If atom is part of a hetero group\n * @return {Boolean} flag\n */\n isHetero () {\n return this.residueType.hetero === 1\n }\n\n /**\n * If atom is part of a protein molecule\n * @return {Boolean} flag\n */\n isProtein () {\n return this.residueType.moleculeType === ProteinType\n }\n\n /**\n * If atom is part of a nucleic molecule\n * @return {Boolean} flag\n */\n isNucleic () {\n const moleculeType = this.residueType.moleculeType\n return moleculeType === RnaType || moleculeType === DnaType\n }\n\n /**\n * If atom is part of a rna\n * @return {Boolean} flag\n */\n isRna () {\n return this.residueType.moleculeType === RnaType\n }\n\n /**\n * If atom is part of a dna\n * @return {Boolean} flag\n */\n isDna () {\n return this.residueType.moleculeType === DnaType\n }\n\n /**\n * If atom is part of a water molecule\n * @return {Boolean} flag\n */\n isWater () {\n return this.residueType.moleculeType === WaterType\n }\n\n /**\n * If atom is part of an ion\n * @return {Boolean} flag\n */\n isIon () {\n return this.residueType.moleculeType === IonType\n }\n\n /**\n * If atom is part of a saccharide\n * @return {Boolean} flag\n */\n isSaccharide () {\n return this.residueType.moleculeType === SaccharideType\n }\n\n /**\n * If atom is part of a helix\n * @return {Boolean} flag\n */\n isHelix () {\n return SecStrucHelix.includes(this.sstruc)\n }\n\n /**\n * If atom is part of a sheet\n * @return {Boolean} flag\n */\n isSheet () {\n return SecStrucSheet.includes(this.sstruc)\n }\n\n /**\n * If atom is part of a turn\n * @return {Boolean} flag\n */\n isTurn () {\n return SecStrucTurn.includes(this.sstruc) && this.isProtein()\n }\n\n isBonded () {\n return this.bondHash!.countArray[ this.index ] !== 0 // TODO\n }\n\n /**\n * If atom is part of a ring\n * @return {Boolean} flag\n */\n isRing () {\n const atomRings = this.residueType.getRings()!.atomRings // TODO\n return atomRings[ this.index - this.residueAtomOffset ] !== undefined\n }\n\n isAromatic () {\n return this.aromatic === 1\n }\n\n isPolarHydrogen () {\n let result = false\n\n if (this.number !== 1) return result\n\n result = !this.hasBondToElement(Elements.C)\n\n return result\n }\n\n isMetal () { return this.atomType.isMetal() }\n isNonmetal () { return this.atomType.isNonmetal() }\n isMetalloid () { return this.atomType.isMetalloid() }\n isHalogen () { return this.atomType.isHalogen() }\n isDiatomicNonmetal () { return this.atomType.isDiatomicNonmetal() }\n isPolyatomicNonmetal () { return this.atomType.isPolyatomicNonmetal() }\n isAlkaliMetal () { return this.atomType.isAlkaliMetal() }\n isAlkalineEarthMetal () { return this.atomType.isAlkalineEarthMetal() }\n isNobleGas () { return this.atomType.isNobleGas() }\n isTransitionMetal () { return this.atomType.isTransitionMetal() }\n isPostTransitionMetal () { return this.atomType.isPostTransitionMetal() }\n isLanthanide () { return this.atomType.isLanthanide() }\n isActinide () { return this.atomType.isActinide() }\n\n getDefaultValence () { return this.atomType.getDefaultValence() }\n getValenceList () { return this.atomType.getValenceList() }\n getOuterShellElectronCount () { return this.atomType.getOuterShellElectronCount() }\n\n /**\n * Distance to another atom\n * @param {AtomProxy} atom - the other atom\n * @return {Number} the distance\n */\n distanceTo (atom: AtomProxy) {\n const taa = this.atomStore\n const aaa = atom.atomStore\n const ti = this.index\n const ai = atom.index\n const x = taa.x[ ti ] - aaa.x[ ai ]\n const y = taa.y[ ti ] - aaa.y[ ai ]\n const z = taa.z[ ti ] - aaa.z[ ai ]\n const distSquared = x * x + y * y + z * z\n return Math.sqrt(distSquared)\n }\n\n /**\n * If connected to another atom\n * @param {AtomProxy} atom - the other atom\n * @return {Boolean} flag\n */\n connectedTo (atom: AtomProxy) {\n const taa = this.atomStore\n const aaa = atom.atomStore\n const ti = this.index\n const ai = atom.index\n\n if (taa.altloc && aaa.altloc) {\n const ta = taa.altloc[ ti ] // use Uint8 value to compare\n const aa = aaa.altloc[ ai ] // no need to convert to char\n // 0 is the Null character, 32 is the space character\n if (!(ta === 0 || aa === 0 || ta === 32 || aa === 32 || (ta === aa))) return false\n }\n\n const x = taa.x[ ti ] - aaa.x[ ai ]\n const y = taa.y[ ti ] - aaa.y[ ai ]\n const z = taa.z[ ti ] - aaa.z[ ai ]\n\n const distSquared = x * x + y * y + z * z\n\n // if( this.isCg() ) console.log( this.qualifiedName(), Math.sqrt( distSquared ), distSquared )\n if (distSquared < 48.0 && this.isCg()) return true\n\n if (isNaN(distSquared)) return false\n\n const d = this.covalent + atom.covalent\n const d1 = d + 0.3\n const d2 = d - 0.5\n\n return distSquared < (d1 * d1) && distSquared > (d2 * d2)\n }\n\n /**\n * Set atom position from array\n * @param {Array|TypedArray} array - input array\n * @param {Integer} [offset] - the offset\n * @return {AtomProxy} this object\n */\n positionFromArray (array: NumberArray, offset = 0) {\n this.x = array[ offset + 0 ]\n this.y = array[ offset + 1 ]\n this.z = array[ offset + 2 ]\n\n return this\n }\n\n /**\n * Write atom position to array\n * @param {Array|TypedArray} [array] - target array\n * @param {Integer} [offset] - the offset\n * @return {Array|TypedArray} target array\n */\n positionToArray (array: NumberArray = [], offset = 0) {\n const index = this.index\n const atomStore = this.atomStore\n\n array[ offset + 0 ] = atomStore.x[ index ]\n array[ offset + 1 ] = atomStore.y[ index ]\n array[ offset + 2 ] = atomStore.z[ index ]\n\n return array\n }\n\n /**\n * Write atom position to vector\n * @param {Vector3} [v] - target vector\n * @return {Vector3} target vector\n */\n positionToVector3 (v?: Vector3) {\n if (v === undefined) v = new Vector3()\n\n v.x = this.x\n v.y = this.y\n v.z = this.z\n\n return v\n }\n\n /**\n * Set atom position from vector\n * @param {Vector3} v - input vector\n * @return {AtomProxy} this object\n */\n positionFromVector3 (v: Vector3) {\n this.x = v.x\n this.y = v.y\n this.z = v.z\n\n return this\n }\n\n /**\n * Add vector to atom position\n * @param {Vector3} v - input vector\n * @return {AtomProxy} this object\n */\n positionAdd (v: Vector3|AtomProxy) {\n this.x += v.x\n this.y += v.y\n this.z += v.z\n\n return this\n }\n\n /**\n * Subtract vector from atom position\n * @param {Vector3} v - input vector\n * @return {AtomProxy} this object\n */\n positionSub (v: Vector3|AtomProxy) {\n this.x -= v.x\n this.y -= v.y\n this.z -= v.z\n\n return this\n }\n\n /**\n * Get intra group/residue bonds\n * @param {Boolean} firstOnly - immediately return the first connected atomIndex\n * @return {Integer[]|Integer|undefined} connected atomIndices\n */\n getResidueBonds (firstOnly = false) {\n const residueAtomOffset = this.residueAtomOffset\n const relativeIndex = this.index - this.residueAtomOffset\n const bonds = this.residueType.getBonds()! // TODO\n const atomIndices1 = bonds.atomIndices1\n const atomIndices2 = bonds.atomIndices2\n let idx1, idx2, connectedAtomIndex\n let connectedAtomIndices: number[]|undefined\n\n if (!firstOnly) connectedAtomIndices = []\n\n idx1 = atomIndices1.indexOf(relativeIndex)\n while (idx1 !== -1) {\n connectedAtomIndex = atomIndices2[ idx1 ] + residueAtomOffset\n if (connectedAtomIndices) {\n connectedAtomIndices.push(connectedAtomIndex)\n idx1 = atomIndices1.indexOf(relativeIndex, idx1 + 1)\n } else {\n return connectedAtomIndex\n }\n }\n\n idx2 = atomIndices2.indexOf(relativeIndex)\n while (idx2 !== -1) {\n connectedAtomIndex = atomIndices1[ idx2 ] + residueAtomOffset\n if (connectedAtomIndices) {\n connectedAtomIndices.push(connectedAtomIndex)\n idx2 = atomIndices2.indexOf(relativeIndex, idx2 + 1)\n } else {\n return connectedAtomIndex\n }\n }\n\n return connectedAtomIndices\n }\n\n //\n\n qualifiedName (noResname = false) {\n var name = ''\n if (this.resname && !noResname) name += '[' + this.resname + ']'\n if (this.resno !== undefined) name += this.resno\n if (this.inscode) name += '^' + this.inscode\n if (this.chainname) name += ':' + this.chainname\n if (this.atomname) name += '.' + this.atomname\n if (this.altloc) name += '%' + this.altloc\n if (this.structure.modelStore.count > 1) name += '/' + this.modelIndex\n return name\n }\n\n /**\n * Clone object\n * @return {AtomProxy} cloned atom\n */\n clone () {\n return new AtomProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n index: this.index,\n residueIndex: this.residueIndex,\n\n resname: this.resname,\n x: this.x,\n y: this.y,\n z: this.z,\n element: this.element,\n chainname: this.chainname,\n resno: this.resno,\n serial: this.serial,\n vdw: this.vdw,\n covalent: this.covalent,\n hetero: this.hetero,\n bfactor: this.bfactor,\n altloc: this.altloc,\n atomname: this.atomname,\n modelIndex: this.modelIndex\n }\n }\n}\n\nexport default AtomProxy\n","/**\n * @file Kdtree\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { Debug, Log } from '../globals'\nimport _Kdtree from '../utils/kdtree'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\n\nfunction euclideanDistSq(a: number[], b: number[]) {\n const dx = a[0] - b[0]\n const dy = a[1] - b[1]\n const dz = a[2] - b[2]\n return dx * dx + dy * dy + dz * dz\n}\n\nfunction euclideanDist(a: number[], b: number[]) {\n return Math.sqrt(euclideanDistSq(a, b))\n}\n\nconst pointArray = new Float32Array(3)\n\nclass Kdtree {\n points: Float32Array\n atomIndices: Uint32Array\n kdtree: _Kdtree\n\n constructor(structure: Structure|ResidueProxy, useSquaredDist = false) {\n if (Debug) Log.time('Kdtree build')\n\n const metric = useSquaredDist ? euclideanDistSq : euclideanDist\n\n const points = new Float32Array(structure.atomCount * 3)\n const atomIndices = new Uint32Array(structure.atomCount)\n let i = 0\n\n structure.eachAtom(function (ap) {\n points[ i + 0 ] = ap.x\n points[ i + 1 ] = ap.y\n points[ i + 2 ] = ap.z\n atomIndices[ i / 3 ] = ap.index\n i += 3\n })\n\n this.atomIndices = atomIndices\n this.points = points\n this.kdtree = new _Kdtree(points, metric)\n\n if (Debug) Log.timeEnd('Kdtree build')\n\n // console.log(\"this.kdtree.verify()\", this.kdtree.verify())\n }\n\n nearest (point: number[]|Vector3, maxNodes: number, maxDistance: number) {\n // Log.time( \"Kdtree nearest\" );\n\n if (point instanceof Vector3) {\n point.toArray(pointArray as any)\n } else if (point instanceof AtomProxy) {\n point.positionToArray(pointArray)\n }\n\n const nodeList = this.kdtree.nearest(pointArray, maxNodes, maxDistance)\n\n const indices = this.kdtree.indices\n const nodes = this.kdtree.nodes\n const atomIndices = this.atomIndices\n const resultList = []\n\n for (let i = 0, n = nodeList.length; i < n; ++i) {\n const d = nodeList[ i ]\n const nodeIndex = d[ 0 ]\n const dist = d[ 1 ]\n\n resultList.push({\n index: atomIndices[ indices[ nodes[ nodeIndex ] ] ],\n distance: dist\n })\n }\n\n // Log.timeEnd( \"Kdtree nearest\" );\n\n return resultList\n }\n}\n\nexport default Kdtree\n","/**\n * @file Symmetry Constants\n * @author Alexander Rose \n * @private\n */\n\nexport const SymOpCode: { [k: string]: string } = {\n ' ': 'X',\n '!': 'Y',\n '#': 'Z',\n '$': '-X',\n '%': '-Y',\n '&': '-Z',\n \"'\": 'Y+1/2',\n '(': '1/2+X',\n ')': '1/2+Y',\n '*': '1/2-X',\n '+': '1/2+Z',\n ',': '1/2-Y',\n '-': '1/2-Z',\n '.': 'X+1/2',\n '/': 'Z+1/2',\n '0': '-X+1/2',\n '1': '-Y+1/2',\n '2': '-Z+1/2',\n '3': '1/4+X',\n '4': '1/4-Y',\n '5': '1/4+Z',\n '6': '1/4-X',\n '7': '1/4+Y',\n '8': '3/4-Y',\n '9': '3/4+Z',\n ':': '3/4+Y',\n ';': '3/4+X',\n '<': '3/4-X',\n '=': '1/4-Z',\n '>': '3/4-Z',\n '?': 'X-Y',\n '@': 'Y-X',\n 'A': 'Z+1/3',\n 'B': 'Z+2/3',\n 'C': 'X+2/3',\n 'D': 'Y+1/3',\n 'E': '-Y+2/3',\n 'F': 'X-Y+1/3',\n 'G': 'Y-X+2/3',\n 'H': '-X+1/3',\n 'I': 'X+1/3',\n 'J': 'Y+2/3',\n 'K': '-Y+1/3',\n 'L': 'X-Y+2/3',\n 'M': 'Y-X+1/3',\n 'N': '-X+2/3',\n 'O': '2/3+X',\n 'P': '1/3+Y',\n 'Q': '1/3+Z',\n 'R': '2/3-Y',\n 'S': '1/3+X-Y',\n 'T': '2/3+Y-X',\n 'U': '1/3-X',\n 'V': '2/3-X',\n 'W': '1/3-Y',\n 'X': '1/3-Z',\n 'Y': '2/3+Y',\n 'Z': '1/3+Y-X',\n '[': '2/3+X-Y',\n ']': '1/3+X',\n '^': '2/3+Z',\n '_': '2/3-Z',\n '`': '5/6+Z',\n 'a': '1/6+Z',\n 'b': '5/6-Z',\n 'c': '1/6-Z',\n 'd': 'Z+5/6',\n 'e': 'Z+1/6',\n 'f': 'Z+1/4',\n 'g': '+Y'\n}\n\n// encoded, originally from CCP4 symop.lib\nexport const EncodedSymOp: { [k: string]: string } = {\n 'P 1': ' !#',\n 'P -1': ' !#$%&',\n 'P 1 2 1': ' !#$!&',\n 'P 1 21 1': \" !#$'&\",\n 'C 1 2 1': ' !#$!&()#*)&',\n 'P 1 m 1': ' !# %#',\n 'P 1 c 1': ' !# %+',\n 'C 1 m 1': ' !# %#()#(,#',\n 'C 1 c 1': ' !# %+()#(,+',\n 'P 1 2/m 1': ' !# %#$!&$%&',\n 'P 1 21/m 1': ' !#$)&$%& ,#',\n 'C 1 2/m 1': ' !# %#$!&$%&()#(,#*)&*,&',\n 'P 1 2/c 1': ' !#$!-$%& %+',\n 'P 1 21/c 1': ' !#$%&$)- ,+',\n 'C 1 2/c 1': ' !#$!-$%& %+()#*)-*,&(,+',\n 'P 2 2 2': ' !#$%#$!& %&',\n 'P 2 2 21': ' !#$%+$!- %&',\n 'P 21 21 2': ' !#$%#*)&(,&',\n 'P 21 21 21': ' !#*%+$)-(,&',\n 'C 2 2 21': ' !#$%+$!- %&()#*,+*)-(,&',\n 'C 2 2 2': ' !#$%#$!& %&()#*,#*)&(,&',\n 'F 2 2 2': ' !#$%#$!& %& )+$,+$)- ,-(!+*%+*!-(%-()#*,#*)&(,&',\n 'I 2 2 2': \" !#$%# %&$!&.'/01/.120'2\",\n 'I 21 21 21': ' !#*%+$)-(,&()+$,#*!& %-',\n 'P m m 2': ' !#$%# %#$!#',\n 'P m c 21': ' !#$%+ %+$!#',\n 'P c c 2': ' !#$%# %+$!+',\n 'P m a 2': ' !#$%#(%#*!#',\n 'P c a 21': ' !#$%+(%#*!+',\n 'P n c 2': ' !#$%# ,+$)+',\n 'P m n 21': ' !#*%+(%+$!#',\n 'P b a 2': ' !#$%#(,#*)#',\n 'P n a 21': ' !#$%+(,#*)+',\n 'P n n 2': ' !#$%#(,+*)+',\n 'C m m 2': ' !#$%# %#$!#()#*,#(,#*)#',\n 'C m c 21': ' !#$%+ %+$!#()#*,+(,+*)#',\n 'C c c 2': ' !#$%# %+$!+()#*,#(,+*)+',\n 'A m m 2': ' !#$%# %#$!# )+$,+ ,+$)+',\n 'A b m 2': ' !#$%# ,#$)# )+$,+ %+$!+',\n 'A m a 2': ' !#$%#(%#*!# )+$,+(,+*)+',\n 'A b a 2': ' !#$%#(,#*)# )+$,+(%+*!+',\n 'F m m 2': ' !#$%# %#$!# )+$,+ ,+$)+(!+*%+(%+*!+()#*,#(,#*)#',\n 'F d d 2': ' !#$%#345675 )+$,+3896:9(!+*%+;49<79()#*,#;85<:5',\n 'I m m 2': ' !#$%# %#$!#()+*,+(,+*)+',\n 'I b a 2': ' !#$%#(,#*)#()+*,+ %+$!+',\n 'I m a 2': ' !#$%#(%#*!#()+*,+ ,+$)+',\n 'P 2/m 2/m 2/m': ' !#$%#$!& %&$%& !& %#$!#',\n 'P 2/n 2/n 2/n': ' !#$%#$!& %&*,-()-(,+*)+',\n 'P 2/c 2/c 2/m': ' !#$%#$!- %-$%& !& %+$!+',\n 'P 2/b 2/a 2/n': ' !#$%#$!& %&*,&()&(,#*)#',\n 'P 21/m 2/m 2/a': ' !#*%#$!&(%&$%&(!& %#*!#',\n 'P 2/n 21/n 2/a': ' !#*%#*)- ,-$%&(!&(,+$)+',\n 'P 2/m 2/n 21/a': ' !#*%+*!- %&$%&(!-(%+$!#',\n 'P 21/c 2/c 2/a': ' !#*%#$!-(%-$%&(!& %+*!+',\n 'P 21/b 21/a 2/m': ' !#$%#*)&(,&$%& !&(,#*)#',\n 'P 21/c 21/c 2/n': ' !#*,#$)-(%-$%&()& ,+*!+',\n 'P 2/b 21/c 21/m': ' !#$%+$)- ,&$%& !- ,+$)#',\n 'P 21/n 21/n 2/m': ' !#$%#*)-(,-$%& !&(,+*)+',\n 'P 21/m 21/m 2/n': \" !#$%#*'&.,&*,&.'& %#$!#\",\n 'P 21/b 2/c 21/n': ' !#*,+$!-(,&$%&()- %+*)#',\n 'P 21/b 21/c 21/a': ' !#*%+$)-(,&$%&(!- ,+*)#',\n 'P 21/n 21/m 21/a': \" !#0%/$'&.12$%&.!2 1#0'/\",\n 'C 2/m 2/c 21/m': ' !#$%+$!- %&$%& !- %+$!#()#*,+*)-(,&*,&()-(,+*)#',\n 'C 2/m 2/c 21/a': ' !#$,+$)- %&$%& )- ,+$!#()#*%+*!-(,&*,&(!-(%+*)#',\n 'C 2/m 2/m 2/m': ' !#$%#$!& %&$%& !& %#$!#()#*,#*)&(,&*,&()&(,#*)#',\n 'C 2/c 2/c 2/m': ' !#$%#$!- %-$%& !& %+$!+()#*,#*)-(,-*,&()&(,+*)+',\n 'C 2/m 2/m 2/a': ' !#$,#$)& %&$%& )& ,#$!#()#*%#*!&(,&*,&(!&(%#*)#',\n 'C 2/c 2/c 2/a': ' !#*,#$!&(,&$,-(!- ,+*!+()#$%#*)& %&*%- )-(%+$)+',\n 'F 2/m 2/m 2/m': ' !#$%#$!& %&$%& !& %#$!# )+$,+$)- ,-$,- )- ,+$)+(!+*%+*!-(%-*%-(!-(%+*!+()#*,#*)&(,&*,&()&(,#*)#',\n 'F 2/d 2/d 2/d': ' !#$%#$!& %&64=37=345675 )+$,+$)- ,-68>3:>3896:9(!+*%+*!-(%-<4>;7>;49<79()#*,#*)&(,&<8=;:=;85<:5',\n 'I 2/m 2/m 2/m': ' !#$%#$!& %&$%& !& %#$!#()+*,+*)-(,-*,-()-(,+*)+',\n 'I 2/b 2/a 2/m': ' !#$%#*)&(,&$%& !&(,#*)#()+*,+$!- %-*,-()- %+$!+',\n 'I 21/b 21/c 21/a': ' !#*%+$)-(,&$%&(!- ,+*)#()+$,#*!& %-*,- )&(%#$!+',\n 'I 21/m 21/m 21/a': ' !#$,#$)& %&$%& )& ,#$!#()+*%+*!-(,-*,-(!-(%+*)+',\n 'P 4': ' !#$%#% #!$#',\n 'P 41': ' !#$%+% 5!$9',\n 'P 42': ' !#$%#% +!$+',\n 'P 43': ' !#$%+% 9!$5',\n 'I 4': ' !#$%#% #!$#()+*,+,(+)*+',\n 'I 41': ' !#*,+%(5)$9()+$%#, 9!*5',\n 'P -4': ' !#$%#!$&% &',\n 'I -4': ' !#$%#!$&% &()+*,+)*-,(-',\n 'P 4/m': ' !#$%#% #!$#$%& !&!$&% &',\n 'P 42/m': ' !#$%#% +!$+$%& !&!$-% -',\n 'P 4/n': ' !#$%#,(#)*#*,&()&!$&% &',\n 'P 42/n': ' !#$%#,(+)*+*,-()-!$&% &',\n 'I 4/m': ' !#$%#% #!$#$%& !&!$&% &()+*,+,(+)*+*,-()-)*-,(-',\n 'I 41/a': ' !#*,+%(5)$9$,=(!>!$&,(-()+$%#, 9!*5*%> )=)*-% &',\n 'P 4 2 2': ' !#$%#% #!$#$!& %&! &%$&',\n 'P 4 21 2': ' !#$%#,(#)*#*)&(,&! &%$&',\n 'P 41 2 2': ' !#$%+% 5!$9$!& %-! >%$=',\n 'P 41 21 2': ' !#$%+,(5)*9*)=(,>! &%$-',\n 'P 42 2 2': ' !#$%#% +!$+$!& %&! -%$-',\n 'P 42 21 2': ' !#$%#,(+)*+*)-(,-! &%$&',\n 'P 43 2 2': ' !#$%+% 9!$5$!& %-! =%$>',\n 'P 43 21 2': ' !#$%+,(9)*5*)>(,=! &%$-',\n 'I 4 2 2': ' !#$%#% #!$#$!& %&! &%$&()+*,+,(+)*+*)-(,-)(-,*-',\n 'I 41 2 2': ' !#*,+%(5)$9*!> ,=)(-%$&()+$%#, 9!*5$)=(%>! &,*-',\n 'P 4 m m': ' !#$%#% #!$# %#$!#%$#! #',\n 'P 4 b m': ' !#$%#% #!$#(,#*)#,*#)(#',\n 'P 42 c m': ' !#$%#% +!$+ %+$!+%$#! #',\n 'P 42 n m': ' !#$%#,(+)*+(,+*)+%$#! #',\n 'P 4 c c': ' !#$%#% #!$# %+$!+%$+! +',\n 'P 4 n c': ' !#$%#% #!$#(,+*)+,*+)(+',\n 'P 42 m c': ' !#$%#% +!$+ %#$!#%$+! +',\n 'P 42 b c': ' !#$%#% +!$+(,#*)#,*+)(+',\n 'I 4 m m': ' !#$%#% #!$# %#$!#%$#! #()+*,+,(+)*+(,+*)+,*+)(+',\n 'I 4 c m': ' !#$%#% #!$# %+$!+%$+! +()+*,+,(+)*+(,#*)#,*#)(#',\n 'I 41 m d': ' !#*,+%(5)$9 %#*)+%*5) 9()+$%#, 9!*5(,+$!#,$9!(5',\n 'I 41 c d': ' !#*,+%(5)$9 %+*)#%*9) 5()+$%#, 9!*5(,#$!+,$5!(9',\n 'P -4 2 m': ' !#$%#% &!$&$!& %&%$#! #',\n 'P -4 2 c': ' !#$%#% &!$&$!- %-%$+! +',\n 'P -4 21 m': ' !#$%#% &!$&*)&(,&,*#)(#',\n 'P -4 21 c': ' !#$%#% &!$&*)-(,-,*+)(+',\n 'P -4 m 2': ' !#$%#!$&% & %#$!#! &%$&',\n 'P -4 c 2': ' !#$%#% &!$& %+$!+! -%$-',\n 'P -4 b 2': ' !#$%#% &!$&(,#*)#)(&,*&',\n 'P -4 n 2': ' !#$%#% &!$&(,+*)+)(-,*-',\n 'I -4 m 2': ' !#$%#% &!$& %#$!#! &%$&()+*,+,(-)*-(,+*)+)(-,*-',\n 'I -4 c 2': ' !#$%#% &!$& %+$!+! -%$-()+*,+,(-)*-(,#*)#)(&,*&',\n 'I -4 2 m': ' !#$%#% &!$&$!& %&%$#! #()+*,+,(-)*-*)-(,-,*+)(+',\n 'I -4 2 d': ' !#$%#% &!$&*!>(%>,$9) 9()+*,+,(-)*-$)= ,=%*5!(5',\n 'P 4/m 2/m 2/m': ' !#$%#% #!$#$!& %&! &%$&$%& !&!$&% & %#$!#%$#! #',\n 'P 4/m 2/c 2/c': ' !#$%#% #!$#$!- %-! -%$-$%& !&!$&% & %+$!+%$+! +',\n 'P 4/n 2/b 2/m': ' !#$%#% #!$#$!& %&! &%$&*,&()&)*&,(&(,#*)#,*#)(#',\n 'P 4/n 2/n 2/c': ' !#$%#% #!$#$!& %&! &%$&*,-()-)*-,(-(,+*)+,*+)(+',\n 'P 4/m 21/b 2/m': ' !#$%#% #!$#*)&(,&)(&,*&$%& !&!$&% &(,#*)#,*#)(#',\n 'P 4/m 21/n 2/c': ' !#$%#% #!$#*)-(,-)(-,*-$%& !&!$&% &(,+*)+,*+)(+',\n 'P 4/n 21/m 2/m': ' !#$%#,(#)*#*)&(,&! &%$&*,&()&!$&% & %#$!#,*#)(#',\n 'P 4/n 2/c 2/c': ' !#$%#,(#)*#*)-(,-! -%$-*,&()&!$&% & %+$!+,*+)(+',\n 'P 42/m 2/m 2/c': ' !#$%#% +!$+$!& %&! -%$-$%& !&!$-% - %#$!#%$+! +',\n 'P 42/m 2/c 2/m': ' !#$%#% +!$+$!- %-! &%$&$%& !&!$-% - %+$!+%$#! #',\n 'P 42/n 2/b 2/c': ' !#$%#,(+)*+$!- %-)(&,*&*,-()-!$&% &(,#*)#%$+! +',\n 'P 42/n 2/n 2/m': ' !#$%#,(+)*+$!& %&)(-,*-*,-()-!$&% &(,+*)+%$#! #',\n 'P 42/m 21/b 2/c': ' !#$%#% +!$+*)&(,&)(-,*-$%& !&!$-% -(,#*)#,*+)(+',\n 'P 42/m 21/n 2/m': \" !#$%#,./'*/*'-.,-! &%$&$%& !&'*-,.-.,/*'/%$#! #\",\n 'P 42/n 21/m 2/c': ' !#$%#,(+)*+*)-(,-! &%$&*,-()-!$&% & %#$!#,*+)(+',\n 'P 42/n 21/c 2/m': ' !#$%#,(+)*+*)&(,&! -%$-*,-()-!$&% & %+$!+,*#)(#',\n 'I 4/m 2/m 2/m': ' !#$%#% #!$#$!& %&! &%$&$%& !&!$&% & %#$!#%$#! #()+*,+,(+)*+*)-(,-)(-,*-*,-()-)*-,(-(,+*)+,*+)(+',\n 'I 4/m 2/c 2/m': ' !#$%#% #!$#$!- %-! -%$-$%& !&!$&% & %+$!+%$+! +()+*,+,(+)*+*)&(,&)(&,*&*,-()-)*-,(-(,#*)#,*#)(#',\n 'I 41/a 2/m 2/d': ' !#*,+%(5)$9*!> ,=)(-%$&$,=(!>!$&,(-(,+$!#,$9!(5()+$%#, 9!*5$)=(%>! &,*-*%> )=)*-% & %#*)+%*5) 9',\n 'I 41/a 2/c 2/d': ' !#*,+%(5)$9*!= ,>)(&%$-$,=(!>!$&,(-(,#$!+,$5!(9()+$%#, 9!*5$)>(%=! -,*&*%> )=)*-% & %+*)#%*9) 5',\n 'P 3': ' !#%?#@$#',\n 'P 31': ' !#%?A@$B',\n 'P 32': ' !#%?B@$A',\n 'H 3': ' !#%?#@$#CDAEFAGHAIJBKLBMNB',\n 'R 3': ' !## !!# ',\n 'P -3': ' !#%?#@$#$%&!@&? &',\n 'H -3': ' !#%?#@$#$%&!@&? &OPQRSQTUQVWXYZX[]X]Y^W[^ZV^UR_PT_SO_',\n 'R -3': ' !## !!# $%&&$%%&$',\n 'P 3 1 2': ' !#%?#@$#%$&@!& ?&',\n 'P 3 2 1': ' !#%?#@$#! &?%&$@&',\n 'P 31 1 2': ' !#%?Q@$^%$_@!X ?&',\n 'P 31 2 1': ' !#%?A@$B! &?%_$@X',\n 'P 32 1 2': ' !#%?^@$Q%$X@!_ ?&',\n 'P 32 2 1': ' !#%?B@$A! &?%X$@_',\n 'H 3 2': ' !#%?#@$#! &?%&$@&OPQRSQTUQY]X[WXVZX]Y^W[^ZV^PO_SR_UT_',\n 'R 3 2': ' !## !!# %$&$&%&%$',\n 'P 3 m 1': ' !#%?#@$#%$#@!# ?#',\n 'P 3 1 m': ' !#%?#@$#! #?%#$@#',\n 'P 3 c 1': ' !#%?#@$#%$+@!+ ?+',\n 'P 3 1 c': ' !#%?#@$#! +?%+$@+',\n 'H 3 m': ' !#%?#@$#%$#@!# ?#OPQRSQTUQRUQTPQOSQ]Y^W[^ZV^WV^ZY^][^',\n 'R 3 m': ' !## !!# ! # #!#! ',\n 'H 3 c': ' !#%?#@$#%$+@!+ ?+OPQRSQTUQRU`TP`OS`]Y^W[^ZV^WVaZYa][a',\n 'R 3 c': \" !## !!# '././'/'.\",\n 'P -3 1 2/m': ' !#%?#@$#%$&@!& ?&$%&!@&? &! #?%#$@#',\n 'P -3 1 2/c': ' !#%?#@$#%$-@!- ?-$%&!@&? &! +?%+$@+',\n 'P -3 2/m 1': ' !#%?#@$#! &?%&$@&$%&!@&? &%$#@!# ?#',\n 'P -3 2/c 1': ' !#%?#@$#! -?%-$@-$%&!@&? &%$+@!+ ?+',\n 'H -3 2/m': ' !#%?#@$#! &?%&$@&$%&!@&? &%$#@!# ?#OPQRSQTUQY]X[WXVZXVWXYZX[]XRUQTPQOSQ]Y^W[^ZV^PO_SR_UT_UR_PT_SO_WV^ZY^][^',\n 'R -3 2/m': ' !## !!# %$&$&%&%$$%&&$%%&$! # #!#! ',\n 'H -3 2/c': ' !#%?#@$#! -?%-$@-$%&!@&? &%$+@!+ ?+OPQRSQTUQY]b[WbVZbVWXYZX[]XRU`TP`OS`]Y^W[^ZV^POcSRcUTcUR_PT_SO_WVaZYa][a',\n 'R -3 2/c': \" !## !!# 102021210$%&&$%%&$'././'/'.\",\n 'P 6': ' !#%?#@$#$%#!@#? #',\n 'P 61': ' !#%?A@$B$%/!@d? e',\n 'P 65': ' !#%?B@$A$%/!@e? d',\n 'P 62': ' !#%?^@$Q$%#!@^? Q',\n 'P 64': ' !#%?Q@$^$%#!@Q? ^',\n 'P 63': ' !#%?#@$#$%+!@+? +',\n 'P -6': ' !#%?#@$# !&%?&@$&',\n 'P 6/m': ' !#%?#@$#$%#!@#? #$%&!@&? & !&%?&@$&',\n 'P 63/m': ' !#%?#@$#$%+!@+? +$%&!@&? & !-%?-@$-',\n 'P 6 2 2': ' !#%?#@$#$%#!@#? #! &?%&$@&%$&@!& ?&',\n 'P 61 2 2': ' !#%?Q@$^$%+!@`? a! X?%&$@_%$b@!- ?c',\n 'P 65 2 2': ' !#%?^@$Q$%+!@a? `! _?%&$@X%$c@!- ?b',\n 'P 62 2 2': ' !#%?^@$Q$%#!@^? Q! _?%&$@X%$_@!& ?X',\n 'P 64 2 2': ' !#%?Q@$^$%#!@Q? ^! X?%&$@_%$X@!& ?_',\n 'P 63 2 2': ' !#%?#@$#$%+!@+? +! &?%&$@&%$-@!- ?-',\n 'P 6 m m': ' !#%?#@$#$%#!@#? #%$#@!# ?#! #?%#$@#',\n 'P 6 c c': ' !#%?#@$#$%#!@#? #%$+@!+ ?+! +?%+$@+',\n 'P 63 c m': ' !#%?#@$#$%+!@+? +%$+@!+ ?+! #?%#$@#',\n 'P 63 m c': ' !#%?#@$#$%+!@+? +%$#@!# ?#! +?%+$@+',\n 'P -6 m 2': ' !#%?#@$# !&%?&@$&%$#@!# ?#%$&@!& ?&',\n 'P -6 c 2': ' !#%?#@$# !-%?-@$-%$+@!+ ?+%$&@!& ?&',\n 'P -6 2 m': ' !#%?#@$# !&%?&@$&! &?%&$@&! #?%#$@#',\n 'P -6 2 c': ' !#%?#@$# !-%?-@$-! &?%&$@&! +?%+$@+',\n 'P 6/m 2/m 2/m': ' !#%?#@$#$%#!@#? #! &?%&$@&%$&@!& ?&$%&!@&? & !&@$&%?&%$#@!# ?#! #?%#$@#',\n 'P 6/m 2/c 2/c': ' !#%?#@$#$%#!@#? #! -?%-$@-%$-@!- ?-$%&!@&? & !&@$&%?&%$+@!+ ?+! +?%+$@+',\n 'P 63/m 2/c 2/m': ' !#%?#@$#$%+!@+? +! -?%-$@-%$&@!& ?&$%&!@&? & !-@$-%?-%$+@!+ ?+! #?%#$@#',\n 'P 63/m 2/m 2/c': ' !#%?#@$#$%+!@+? +! &?%&$@&%$-@!- ?-$%&!@&? & !-@$-%?-%$#@!# ?#! +?%+$@+',\n 'P 2 3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ',\n 'F 2 3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ',\n 'I 2 3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-(',\n 'P 21 3': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(',\n 'I 21 3': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- ',\n 'P 2/m -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$',\n 'P 2/n -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& *,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*',\n 'F 2/m -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$ )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-($,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(*%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- *,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$',\n 'F 2/d -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& 64=37=345675=64=375345674=67=3453756 )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(68>3:>3896:9=<8=;:5;85<:4><7>;49;79<(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(<4>;7>;49<79>68>3:93896:8=<:=;85;:5<()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- <8=;:=;8f<:f><4>;79;49<78>6:>3893:96',\n 'I 2/m -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-(*,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*',\n 'P 21/a -3': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&($%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*',\n 'I 21/a -3': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&($%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*()+$,#*g& %-+()#$,&*!- %)+(,#$!&*%- *,- )&(%#$!+-*,& )#(%+$!,-*)& %#(!+$',\n 'P 4 3 2': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$',\n 'P 42 3 2': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*',\n 'F 4 3 2': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$ )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(-%*-!*+%(+ +,$+)$-, -)#)*#,(&)(&,*(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() -,$-)$+, +(#,*#)*&,(&)+!*+%(-!(-%*()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(&,*&)*#,(#(+%*+!*-%(-!+)$+, -) -,$',\n 'F 41 3 2': ' !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=46 )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<(!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>86',\n 'I 4 3 2': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*',\n 'P 43 3 2': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(7;>46=:<5839398<5:6=4;>75:<983>7;=46',\n 'P 41 3 2': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<',\n 'I 41 3 2': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- 7;>46=:<5839398<5:6=4;>75:<983>7;=46',\n 'P -4 3 m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% ',\n 'F -4 3 m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(+%*+!*-%(- +)$+,$-) -,#)(#,*&)*&,((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() +,$+)$-, -(#)*#,*&)(&,+!(+%*-!*-%(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(#,*#)*&,(&(+!*+%*-!(-%+) +,$-)$-, ',\n 'I -4 3 m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,(',\n 'P -4 3 n': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,(',\n 'F -4 3 c': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,( )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-() #,$#)$&, &(#!*#%*&!(&%+! +%$-!$-% (!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(!(#%*#!*&%(& +!$+%$-! -%#) #,$&)$&, ()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ! +%$+!$-% - #)$#,$&) &,#!(#%*&!*&%(',\n 'I -4 3 d': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(7354<9:6>8;=357<946>:;=857394<>:6=8;()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- :;98657<=43>;9:658<=73>49:;586=7<>43',\n 'P 4/m -3 2/m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ',\n 'P 4/n -3 2/n': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$*,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(',\n 'P 42/m -3 2/n': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(',\n 'P 42/n -3 2/m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,**,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ',\n 'F 4/m -3 2/m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(-%*-!*+%(+ +,$+)$-, -)#)*#,(&)(&,*$,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*%*+!(+%(-!*-$-) -, +)$+,&,(&)*#,*#)((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() -,$-)$+, +(#,*#)*&,(&)+!*+%(-!(-%**%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*,$+) +, -)$-*&)(&,(#)*#,-%(-!*+%*+!(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(&,*&)*#,(#(+%*+!*-%(-!+)$+, -) -,$*,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$,*#)(#,(&)*&*-!(-%(+!*+%-, -)$+,$+) ',\n 'F 4/m -3 2/c': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)( )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-() &,$&)$#, #(#%*#!*&%(&!+!$+% -! -%$$,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*,$#) #, &)$&*&!(&%(#!*#%-% -!$+%$+! (!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(!(&%*&!*#%(# +%$+!$-% -!#)$#, &) &,$*%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*%*#!(#%(&!*&$-! -% +!$+%&, &)$#,$#) ()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ! -%$-!$+% + #,$#)$&, &)#!*#%(&!(&%**,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$%$+! +% -!$-$&) &, #)$#,&%(&!*#%*#!(',\n 'F 41/d -3 2/m': ' !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=4664=3:>;85<79=64>3:5;89<74=6:>385;79<,$+! #%(-)*&*&)(-% #!$+,-%(&)*+,$#! )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<68>37=;49<:5=<8>;753496:4><:=;893756,*#!(+% &)$-*-!(&, +)$#%-, &!$+%*#)((!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<<4>;:=389675>68=379;45<:8=<7>;453:96%$#) +,(&!*-$&! -,(#)*+%&% -)$#,*+!(()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>86<8=;7>3456:9><4=;:9385678>67=349;:5<%*+)(#, -!$&$-) &%(+!*#,&,(-!*#%$+) ',\n 'F 41/d -3 2/c': ' !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=46<8>;7=3496:5><8=;793456:8><7=;493:56%*#)(+, &!$-$-! &,(+)*#%&, -!$#%*+)( )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<<4=;:>385679>64=3:9;85<78=67>345;:9<%$+) #,(-!*&$&) -%(#!*+,&%(-)*#,$+! (!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<68=37>;45<:9=<4>;:5389674>6:=389;75<,*+!(#% -)$&*-)(&% +!$#,-,(&!*+%$#) ()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>8664>3:=;89<75=68>375;49<:4=<:>;853796,$#! +%(&)*-*&!(-, #)$+%-% &)$+,*#!(',\n 'I 4/m -3 2/m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,**,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(',\n 'I 41/a -3 2/d': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<$%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*4<97358;=:6>6>:;=8357<94=8;>:694<573()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- 7;>46=:<5839398<5:6=4;>75:<983>7;=46*,- )&(%#$!+-*,& )#(%+$!,-*)& %#(!+$865:;943>7<=<=73>4;9:658>43=7<5869:;',\n 'P 1 1 2': ' !#$%#',\n 'P 1 1 21': ' !#$%+',\n 'B 1 1 2': ' !#$%#(g+*%+',\n 'A 1 2 1': ' !#$!& )+$)-',\n 'C 1 21 1': ' !#$)&()#*!&',\n 'I 1 2 1': \" !#$!&.'/0'2\",\n 'I 1 21 1': \" !#$)&.'/0!-\",\n 'P 1 1 m': ' !# !&',\n 'P 1 1 b': ' !# )&',\n 'B 1 1 m': ' !# !&(!+(!-',\n 'B 1 1 b': ' !# )&(!+()-',\n 'P 1 1 2/m': ' !# !&$%#$%&',\n 'P 1 1 21/m': ' !#$%+$%& !-',\n 'B 1 1 2/m': ' !# !&$%#$%&(!+(!-*%+*%-',\n 'P 1 1 2/b': ' !#$,#$%& )&',\n 'P 1 1 21/b': ' !#$%&$,+ )-',\n 'B 1 1 2/b': ' !#$,#$%& )&(!+*,+*%-()-',\n 'P 21 2 2': ' !#$!&(%&*%#',\n 'P 2 21 2': ' !# ,&$)&$%#',\n 'P 21 21 2 (a)': \" !#*,#.%&$'&\",\n 'P 21 2 21': ' !#$!&(%-*%+',\n 'P 2 21 21': ' !# %&$)-$,+',\n 'C 2 2 21a)': ' !#*%+(,&$)-()#$,+ %&*!-',\n 'C 2 2 2a': \" !#*,#.%&$'&()#$%# ,&*!&\",\n 'F 2 2 2a': \" !#*,#.%&$'& '/*%/.12$!2.!/$,/ %20'2.'#$%# 1&0!&\",\n 'I 2 2 2a': \" !#*,#.%&$'&()+$%+*!- ,-\",\n 'P 21/m 21/m 2/n a': \" !#*,#$)&(%&$%&.'& ,#*!#\",\n 'P 42 21 2a': \" !#*,#%.+'$+$'&.%&! -,*-\",\n 'I 2 3a': \" !#*,#.%&$'&!# ,- '&$%/$# !-*!/$%&.%()+$%+ ,-*!-)+(%&(!-*,#*+()&$)#*,- ,\"\n}\n","/**\n * @file Symmetry Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Log } from '../globals'\nimport { EncodedSymOp, SymOpCode } from './symmetry-constants'\n\nconst reInteger = /^[1-9]$/\n\nexport function getSymmetryOperations (spacegroup: string) {\n const encodedSymopList = EncodedSymOp[ spacegroup ]\n const matrixDict: { [k: string]: Matrix4 } = {}\n\n if (encodedSymopList === undefined) {\n console.warn(`spacegroup '${spacegroup}' not found in symop library`)\n return matrixDict\n }\n\n const symopList = []\n for (let i = 0, il = encodedSymopList.length; i < il; i += 3) {\n const symop = []\n for (let j = 0; j < 3; ++j) {\n symop.push(SymOpCode[ encodedSymopList[ i + j ] ])\n }\n symopList.push(symop)\n }\n\n symopList.forEach(function (symop) {\n let row = 0\n const matrix = new Matrix4().set(\n 0, 0, 0, 0,\n 0, 0, 0, 0,\n 0, 0, 0, 0,\n 0, 0, 0, 1\n )\n const me = matrix.elements\n\n matrixDict[ symop.toString() ] = matrix\n\n symop.forEach(function (elm) {\n let negate = false\n let denominator = false\n\n for (let i = 0, n = elm.length; i < n; ++i) {\n const c = elm[ i ]\n\n if (c === '-') {\n negate = true\n } else if (c === '+') {\n negate = false\n } else if (c === '/') {\n denominator = true\n } else if (c === 'X') {\n me[ 0 + row ] = negate ? -1 : 1\n } else if (c === 'Y') {\n me[ 4 + row ] = negate ? -1 : 1\n } else if (c === 'Z') {\n me[ 8 + row ] = negate ? -1 : 1\n } else if (reInteger.test(c)) {\n const integer = parseInt(c)\n if (denominator) {\n me[ 12 + row ] /= integer\n } else {\n me[ 12 + row ] = integer\n }\n } else {\n Log.warn(`getSymmetryOperations: unknown token '${c}'`)\n }\n }\n\n row += 1\n })\n })\n\n return matrixDict\n}\n","/**\n * @file Assembly\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Box3, Vector3 } from 'three'\n\nimport { uniqueArray } from '../utils'\nimport Selection from '../selection/selection'\nimport Structure from '../structure/structure'\nimport StructureView from '../structure/structure-view';\n\nfunction selectionFromChains (chainList: string[]) {\n let sele = ''\n if (chainList.length > 0) {\n sele = ':' + uniqueArray(chainList).join(' OR :')\n }\n return new Selection(sele)\n}\n\n/**\n * Assembly of transformed parts of a {@link Structure}\n */\nclass Assembly {\n partList: AssemblyPart[] = []\n\n /**\n * @param {String} name - assembly name\n */\n constructor (readonly name = '') {}\n\n get type () { return 'Assembly' }\n\n /**\n * Add transformed parts to the assembly\n * @example\n * var m1 = new NGL.Matrix4().set( ... );\n * var m2 = new NGL.Matrix4().set( ... );\n * var assembly = new NGL.Assembly( \"myAssembly\" );\n * // add part that transforms chain 'A' and 'B' using matrices `m1` and `m2`\n * assembly.addPart( [ m1, m2 ], [ \"A\", \"B\" ] )\n *\n * @param {Matrix4[]} matrixList - array of 4x4 transformation matrices\n * @param {String[]} chainList - array of chain names\n * @return {AssemblyPart} the added assembly part\n */\n addPart (matrixList?: Matrix4[], chainList?: string[]) {\n const part = new AssemblyPart(matrixList, chainList)\n this.partList.push(part)\n return part\n }\n\n /**\n * Get the number of atom for a given structure\n * @param {Structure} structure - the given structure\n * @return {Integer} number of atoms in the assembly\n */\n getAtomCount (structure: Structure) {\n return this.partList.reduce(\n (count, part) => count + part.getAtomCount(structure), 0\n )\n }\n\n /**\n * Get the number of residues for a given structure\n * @param {Structure} structure - the given structure\n * @return {Integer} number of residues in the assembly\n */\n getResidueCount (structure: Structure) {\n return this.partList.reduce(\n (count, part) => count + part.getResidueCount(structure), 0\n )\n }\n\n /**\n * Get number of instances the assembly will produce, i.e.\n * the number of transformations performed by the assembly\n * @return {Integer} number of instances\n */\n getInstanceCount () {\n let instanceCount = 0\n\n this.partList.forEach(function (part) {\n instanceCount += part.matrixList.length\n })\n\n return instanceCount\n }\n\n /**\n * Determine if the assembly is the full and untransformed structure\n * @param {Structure} structure - the given structure\n * @return {Boolean} whether the assembly is identical to the structure\n */\n isIdentity (structure: Structure) {\n if (this.partList.length !== 1) return false\n\n const part = this.partList[ 0 ]\n if (part.matrixList.length !== 1) return false\n\n const identityMatrix = new Matrix4()\n if (!identityMatrix.equals(part.matrixList[ 0 ])) return false\n\n let structureChainList: string[] = []\n structure.eachChain(function (cp) {\n structureChainList.push(cp.chainname)\n })\n structureChainList = uniqueArray(structureChainList)\n if (part.chainList.length !== structureChainList.length) return false\n\n return true\n }\n\n getBoundingBox (structure: Structure) {\n const boundingBox = new Box3()\n\n this.partList.forEach(function (part) {\n const partBox = part.getBoundingBox(structure)\n boundingBox.expandByPoint(partBox.min)\n boundingBox.expandByPoint(partBox.max)\n })\n\n return boundingBox\n }\n\n getCenter (structure: Structure) {\n return this.getBoundingBox(structure).getCenter(new Vector3())\n }\n\n getSelection () {\n let chainList: string[] = []\n this.partList.forEach(function (part) {\n chainList = chainList.concat(part.chainList)\n })\n return selectionFromChains(chainList)\n }\n}\n\nexport class AssemblyPart {\n constructor (readonly matrixList: Matrix4[] = [], readonly chainList: string[] = []) {}\n\n get type () { return 'AssemblyPart' }\n\n _getCount (structure: Structure, propertyName: 'atomCount'|'residueCount') {\n let count = 0\n\n structure.eachChain(cp => {\n if (this.chainList.length === 0 || this.chainList.includes(cp.chainname)) {\n count += cp[ propertyName ]\n }\n })\n\n return this.matrixList.length * count\n }\n\n getAtomCount (structure: Structure) {\n return this._getCount(structure, 'atomCount')\n }\n\n getResidueCount (structure: Structure) {\n return this._getCount(structure, 'residueCount')\n }\n\n getBoundingBox (structure: Structure) {\n const partBox = new Box3()\n const instanceBox = new Box3()\n\n const selection = this.getSelection()\n const structureBox = structure.getBoundingBox(selection)\n\n this.matrixList.forEach(function (matrix) {\n instanceBox.copy(structureBox).applyMatrix4(matrix)\n partBox.expandByPoint(instanceBox.min)\n partBox.expandByPoint(instanceBox.max)\n })\n\n return partBox\n }\n\n getSelection () {\n return selectionFromChains(this.chainList)\n }\n\n getView (structure: Structure): Structure | StructureView {\n const selection = this.getSelection()\n if (selection) {\n return structure.getView(selection)\n } else {\n return structure\n }\n }\n\n getInstanceList () {\n const instanceList = []\n for (let j = 0, jl = this.matrixList.length; j < jl; ++j) {\n instanceList.push({\n id: j + 1,\n name: j,\n matrix: this.matrixList[ j ]\n })\n }\n return instanceList\n }\n}\n\nexport default Assembly\n","/**\n * @file Structure Builder\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from './structure'\n\nclass StructureBuilder {\n currentModelindex: number|null = null\n currentChainid: string|null = null\n currentResname: string|null = null\n currentResno: number|null = null\n currentInscode: string|undefined = undefined\n currentHetero: boolean|null = null\n\n previousResname: string|null = ''\n previousHetero: boolean|null = null\n\n ai = -1\n ri = -1\n ci = -1\n mi = -1\n\n constructor(readonly structure: Structure) {}\n\n addResidueType (ri: number) {\n const atomStore = this.structure.atomStore\n const residueStore = this.structure.residueStore\n const residueMap = this.structure.residueMap\n\n const count = residueStore.atomCount[ ri ]\n const offset = residueStore.atomOffset[ ri ]\n const atomTypeIdList = new Array(count)\n for (let i = 0; i < count; ++i) {\n atomTypeIdList[ i ] = atomStore.atomTypeId[ offset + i ]\n }\n residueStore.residueTypeId[ ri ] = residueMap.add(\n this.previousResname!, atomTypeIdList, this.previousHetero! // TODO\n )\n }\n\n addAtom (modelindex: number, chainname: string, chainid: string, resname: string, resno: number, hetero: boolean, sstruc?: string|undefined, inscode?: string|undefined) {\n const atomStore = this.structure.atomStore\n const residueStore = this.structure.residueStore\n const chainStore = this.structure.chainStore\n const modelStore = this.structure.modelStore\n\n let addModel = false\n let addChain = false\n let addResidue = false\n\n if (this.currentModelindex !== modelindex) {\n addModel = true\n addChain = true\n addResidue = true\n this.mi += 1\n this.ci += 1\n this.ri += 1\n } else if (this.currentChainid !== chainid) {\n addChain = true\n addResidue = true\n this.ci += 1\n this.ri += 1\n } else if (this.currentResno !== resno || this.currentResname !== resname || this.currentInscode !== inscode) {\n addResidue = true\n this.ri += 1\n }\n this.ai += 1\n\n if (addModel) {\n modelStore.growIfFull()\n modelStore.chainOffset[ this.mi ] = this.ci\n modelStore.chainCount[ this.mi ] = 0\n modelStore.count += 1\n chainStore.modelIndex[ this.ci ] = this.mi\n }\n\n if (addChain) {\n chainStore.growIfFull()\n chainStore.setChainname(this.ci, chainname)\n chainStore.setChainid(this.ci, chainid)\n chainStore.residueOffset[ this.ci ] = this.ri\n chainStore.residueCount[ this.ci ] = 0\n chainStore.count += 1\n chainStore.modelIndex[ this.ci ] = this.mi\n modelStore.chainCount[ this.mi ] += 1\n residueStore.chainIndex[ this.ri ] = this.ci\n }\n\n if (addResidue) {\n this.previousResname = this.currentResname\n this.previousHetero = this.currentHetero\n if (this.ri > 0) this.addResidueType(this.ri - 1)\n residueStore.growIfFull()\n residueStore.resno[ this.ri ] = resno\n if (sstruc !== undefined) {\n residueStore.sstruc[ this.ri ] = sstruc.charCodeAt(0)\n }\n if (inscode !== undefined) {\n residueStore.inscode[ this.ri ] = inscode.charCodeAt(0)\n }\n residueStore.atomOffset[ this.ri ] = this.ai\n residueStore.atomCount[ this.ri ] = 0\n residueStore.count += 1\n residueStore.chainIndex[ this.ri ] = this.ci\n chainStore.residueCount[ this.ci ] += 1\n }\n\n atomStore.count += 1\n atomStore.residueIndex[ this.ai ] = this.ri\n residueStore.atomCount[ this.ri ] += 1\n\n this.currentModelindex = modelindex\n this.currentChainid = chainid\n this.currentResname = resname\n this.currentResno = resno\n this.currentInscode = inscode\n this.currentHetero = hetero\n }\n\n finalize () {\n this.previousResname = this.currentResname\n this.previousHetero = this.currentHetero\n if (this.ri > -1) this.addResidueType(this.ri)\n }\n}\n\nexport default StructureBuilder\n","/**\n * @file Structure Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4 } from 'three'\n\nimport { Debug, Log } from '../globals'\nimport { binarySearchIndexOf } from '../utils'\nimport Helixbundle from '../geometry/helixbundle'\nimport Kdtree from '../geometry/kdtree'\nimport { getSymmetryOperations } from '../symmetry/symmetry-utils'\nimport Assembly from '../symmetry/assembly'\nimport Structure from '../structure/structure'\nimport StructureBuilder from '../structure/structure-builder'\nimport Polymer from '../proxy/polymer'\nimport ResidueProxy from '../proxy/residue-proxy'\n\nimport { UnknownBackboneType, AA3, Bases, AtomicNumbers } from './structure-constants'\n\nexport function reorderAtoms (structure: Structure) {\n if (Debug) Log.time('reorderAtoms')\n\n var ap1 = structure.getAtomProxy()\n var ap2 = structure.getAtomProxy()\n\n function compareModelChainResno (index1: number, index2: number) {\n ap1.index = index1\n ap2.index = index2\n if (ap1.modelIndex < ap2.modelIndex) {\n return -1\n } else if (ap1.modelIndex > ap2.modelIndex) {\n return 1\n } else {\n if (ap1.chainname < ap2.chainname) {\n return -1\n } else if (ap1.chainname > ap2.chainname) {\n return 1\n } else {\n if (ap1.resno < ap2.resno) {\n return -1\n } else if (ap1.resno > ap2.resno) {\n return 1\n } else {\n return 0\n }\n }\n }\n }\n\n structure.atomStore.sort(compareModelChainResno)\n\n if (Debug) Log.timeEnd('reorderAtoms')\n}\n\nexport interface SecStruct {\n helices: [string, number, string, string, number, string, number][]\n sheets: [string, number, string, string, number, string][]\n}\n\nexport function assignSecondaryStructure (structure: Structure, secStruct: SecStruct) {\n if (!secStruct) return\n\n if (Debug) Log.time('assignSecondaryStructure')\n\n const chainnames: string[] = []\n structure.eachModel(function (mp) {\n mp.eachChain(function (cp) {\n chainnames.push(cp.chainname)\n })\n })\n\n const chainnamesSorted = chainnames.slice().sort()\n const chainnamesIndex: number[] = []\n chainnamesSorted.forEach(function (c) {\n chainnamesIndex.push(chainnames.indexOf(c))\n })\n\n // helix assignment\n\n const helices = secStruct.helices.filter(function (h) {\n return binarySearchIndexOf(chainnamesSorted, h[ 0 ]) >= 0\n })\n\n helices.sort(function (h1, h2) {\n const c1 = h1[ 0 ]\n const c2 = h2[ 0 ]\n const r1 = h1[ 1 ]\n const r2 = h2[ 1 ]\n\n if (c1 === c2) {\n if (r1 === r2) {\n return 0\n } else {\n return r1 < r2 ? -1 : 1\n }\n } else {\n const idx1 = binarySearchIndexOf(chainnamesSorted, c1)\n const idx2 = binarySearchIndexOf(chainnamesSorted, c2)\n return chainnamesIndex[ idx1 ] < chainnamesIndex[ idx2 ] ? -1 : 1\n }\n })\n\n const residueStore = structure.residueStore\n\n structure.eachModel(function (mp) {\n let i = 0\n const n = helices.length\n if (n === 0) return\n let helix = helices[ i ]\n let helixRun = false\n let done = false\n\n mp.eachChain(function (cp) {\n let chainChange = false\n\n if (cp.chainname === helix[ 0 ]) {\n const count = cp.residueCount\n const offset = cp.residueOffset\n const end = offset + count\n\n for (let j = offset; j < end; ++j) {\n if (residueStore.resno[ j ] === helix[ 1 ] && // resnoBeg\n residueStore.getInscode(j) === helix[ 2 ] // inscodeBeg\n ) {\n helixRun = true\n }\n\n if (helixRun) {\n residueStore.sstruc[ j ] = helix[ 6 ]\n\n if (residueStore.resno[ j ] === helix[ 4 ] && // resnoEnd\n residueStore.getInscode(j) === helix[ 5 ] // inscodeEnd\n ) {\n helixRun = false\n i += 1\n\n if (i < n) {\n // must look at previous residues as\n // residues may not be ordered by resno\n j = offset - 1\n helix = helices[ i ]\n chainChange = cp.chainname !== helix[ 0 ]\n } else {\n done = true\n }\n }\n }\n\n if (chainChange || done) return\n }\n }\n })\n })\n\n // sheet assignment\n\n const sheets = secStruct.sheets.filter(function (s) {\n return binarySearchIndexOf(chainnamesSorted, s[ 0 ]) >= 0\n })\n\n sheets.sort(function (s1, s2) {\n const c1 = s1[ 0 ]\n const c2 = s2[ 0 ]\n\n if (c1 === c2) return 0\n const idx1 = binarySearchIndexOf(chainnamesSorted, c1)\n const idx2 = binarySearchIndexOf(chainnamesSorted, c2)\n return chainnamesIndex[ idx1 ] < chainnamesIndex[ idx2 ] ? -1 : 1\n })\n\n const strandCharCode = 'e'.charCodeAt(0)\n structure.eachModel(function (mp) {\n let i = 0\n const n = sheets.length\n if (n === 0) return\n let sheet = sheets[ i ]\n let sheetRun = false\n let done = false\n\n mp.eachChain(function (cp) {\n let chainChange = false\n\n if (cp.chainname === sheet[ 0 ]) {\n const count = cp.residueCount\n const offset = cp.residueOffset\n const end = offset + count\n\n for (let j = offset; j < end; ++j) {\n if (residueStore.resno[ j ] === sheet[ 1 ] && // resnoBeg\n residueStore.getInscode(j) === sheet[ 2 ] // inscodeBeg\n ) {\n sheetRun = true\n }\n\n if (sheetRun) {\n residueStore.sstruc[ j ] = strandCharCode\n\n if (residueStore.resno[ j ] === sheet[ 4 ] && // resnoEnd\n residueStore.getInscode(j) === sheet[ 5 ] // inscodeEnd\n ) {\n sheetRun = false\n i += 1\n\n if (i < n) {\n // must look at previous residues as\n // residues may not be ordered by resno\n j = offset - 1\n sheet = sheets[ i ]\n chainChange = cp.chainname !== sheet[ 0 ]\n } else {\n done = true\n }\n }\n }\n\n if (chainChange || done) return\n }\n }\n })\n })\n\n if (Debug) Log.timeEnd('assignSecondaryStructure')\n}\n\nexport const calculateSecondaryStructure = (function () {\n // Implementation for proteins based on \"pv\"\n //\n // assigns secondary structure information based on a simple and very fast\n // algorithm published by Zhang and Skolnick in their TM-align paper.\n // Reference:\n //\n // TM-align: a protein structure alignment algorithm based on the Tm-score\n // (2005) NAR, 33(7) 2302-2309\n\n const zhangSkolnickSS = function (polymer: Polymer, i: number, distances: number[], delta: number) {\n const structure = polymer.structure\n const offset = polymer.residueIndexStart\n const rp1 = structure.getResidueProxy()\n const rp2 = structure.getResidueProxy()\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n for (let j = Math.max(0, i - 2); j <= i; ++j) {\n for (let k = 2; k < 5; ++k) {\n if (j + k >= polymer.residueCount) {\n continue\n }\n\n rp1.index = offset + j\n rp2.index = offset + j + k\n ap1.index = rp1.traceAtomIndex\n ap2.index = rp2.traceAtomIndex\n\n const d = ap1.distanceTo(ap2)\n\n if (Math.abs(d - distances[ k - 2 ]) > delta) {\n return false\n }\n }\n }\n\n return true\n }\n\n const isHelical = function (polymer: Polymer, i: number) {\n const helixDistances = [ 5.45, 5.18, 6.37 ]\n const helixDelta = 2.1\n return zhangSkolnickSS(polymer, i, helixDistances, helixDelta)\n }\n\n const isSheet = function (polymer: Polymer, i: number) {\n const sheetDistances = [ 6.1, 10.4, 13.0 ]\n const sheetDelta = 1.42\n return zhangSkolnickSS(polymer, i, sheetDistances, sheetDelta)\n }\n\n const proteinPolymer = function (p: Polymer) {\n const residueStore = p.residueStore\n const offset = p.residueIndexStart\n for (let i = 0, il = p.residueCount; i < il; ++i) {\n let sstruc = 'c'\n if (isHelical(p, i)) {\n sstruc = 'h'\n } else if (isSheet(p, i)) {\n sstruc = 'e'\n }\n residueStore.sstruc[ offset + i ] = sstruc.charCodeAt(0)\n }\n }\n\n const cgPolymer = function (p: Polymer) {\n const localAngle = 20\n const centerDist = 2.0\n\n const residueStore = p.residueStore\n const offset = p.residueIndexStart\n\n const helixbundle = new Helixbundle(p)\n const pos = helixbundle.position\n\n const c1 = new Vector3()\n const c2 = new Vector3()\n\n for (let i = 0, il = p.residueCount; i < il; ++i) {\n c1.fromArray(pos.center as any, i * 3) // TODO\n c2.fromArray(pos.center as any, i * 3 + 3) // TODO\n const d = c1.distanceTo(c2)\n\n if (d < centerDist && d > 1.0 && pos.bending[ i ] < localAngle) {\n residueStore.sstruc[ offset + i ] = 'h'.charCodeAt(0)\n residueStore.sstruc[ offset + i + 1 ] = 'h'.charCodeAt(0)\n }\n }\n }\n\n return function calculateSecondaryStructure (structure: Structure) {\n if (Debug) Log.time('calculateSecondaryStructure')\n\n structure.eachPolymer(function (p) {\n // assign secondary structure\n if (p.residueCount < 4) return\n if (p.isCg()) {\n cgPolymer(p)\n } else if (p.isProtein()) {\n proteinPolymer(p)\n } else {\n return\n }\n\n // set lone secondary structure assignments to \"c\"\n let prevSstruc: string\n let sstrucCount = 0\n p.eachResidue(function (r: ResidueProxy) {\n if (r.sstruc === prevSstruc) {\n sstrucCount += 1\n } else {\n if (sstrucCount === 1) {\n r.index -= 1\n r.sstruc = 'c'\n }\n sstrucCount = 1\n prevSstruc = r.sstruc\n }\n })\n })\n\n if (Debug) Log.timeEnd('calculateSecondaryStructure')\n }\n}())\n\n// const ChainnameAlphabet = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\" +\n// \"abcdefghijklmnopqrstuvwxyz\" +\n// \"0123456789\";\nconst ChainnameAlphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\n\nexport function getChainname (index: number) {\n const n = ChainnameAlphabet.length\n let j = index\n let k = 0\n let chainname = ChainnameAlphabet[j % n]\n while (j >= n) {\n j = Math.floor(j / n)\n chainname += ChainnameAlphabet[j % n]\n k += 1\n }\n if (k >= 5) {\n Log.warn('chainname overflow')\n }\n return chainname\n}\n\ninterface ChainData {\n mIndex: number\n chainname: string\n rStart: number\n rCount: number\n}\n\n/**\n * When no chain names are set for the given structure, calculates\n * chains based on:\n * - polymer connectivity: when adjacent residues are not bonded, a new chain is created.\n * - non polymer chemical type: adjacent residues which are not polymers but are of the same\n * chemical type (e.g. water molecules) are grouped into the same chain.\n **/\nexport function calculateChainnames (structure: Structure, useExistingBonds = false) {\n if (Debug) Log.time('calculateChainnames')\n\n let doAutoChainName = true\n structure.eachChain(function (c) {\n if (c.chainname) doAutoChainName = false\n })\n\n if (doAutoChainName) {\n const modelStore = structure.modelStore\n const chainStore = structure.chainStore\n const residueStore = structure.residueStore\n\n const addChain = function (mIndex: number, chainname: string, rOffset: number, rCount: number) {\n const ci = chainStore.count\n for (let i = 0; i < rCount; ++i) {\n residueStore.chainIndex[ rOffset + i ] = ci\n }\n chainStore.growIfFull()\n chainStore.modelIndex[ ci ] = mIndex\n chainStore.setChainname(ci, chainname)\n chainStore.setChainid(ci, chainname)\n chainStore.residueOffset[ ci ] = rOffset\n chainStore.residueCount[ ci ] = rCount\n chainStore.count += 1\n modelStore.chainCount[ mIndex ] += 1\n }\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n let i = 0\n let mi = 0\n let rStart = 0\n let rEnd = 0\n const chainData: ChainData[] = []\n\n if (residueStore.count === 1) {\n chainData.push({\n mIndex: 0,\n chainname: 'A',\n rStart: 0,\n rCount: 1\n })\n } else {\n structure.eachResidueN(2, function (rp1: ResidueProxy, rp2: ResidueProxy) {\n let newChain = false\n\n const bbType1 = rp1.backboneType\n const bbType2 = rp2.backboneType\n const bbTypeUnk = UnknownBackboneType\n\n rEnd = rp1.index\n\n if (rp1.modelIndex !== rp2.modelIndex) {\n newChain = true\n } else if (rp1.moleculeType !== rp2.moleculeType) {\n newChain = true\n } else if (bbType1 !== bbTypeUnk && bbType1 === bbType2) {\n ap1.index = rp1.backboneEndAtomIndex\n ap2.index = rp2.backboneStartAtomIndex\n if (useExistingBonds) {\n newChain = !ap1.hasBondTo(ap2)\n } else {\n newChain = !ap1.connectedTo(ap2)\n }\n }\n\n // current chain goes to end of the structure\n if (!newChain && rp2.index === residueStore.count - 1) {\n newChain = true\n rEnd = rp2.index\n }\n\n if (newChain) {\n chainData.push({\n mIndex: mi,\n chainname: getChainname(i),\n rStart: rStart,\n rCount: rEnd - rStart + 1\n })\n\n i += 1\n\n if (rp1.modelIndex !== rp2.modelIndex) {\n i = 0\n mi += 1\n }\n\n // new chain for the last residue of the structure\n if (rp2.index === residueStore.count - 1 && rEnd !== rp2.index) {\n chainData.push({\n mIndex: mi,\n chainname: getChainname(i),\n rStart: residueStore.count - 1,\n rCount: 1\n })\n }\n\n rStart = rp2.index\n rEnd = rp2.index\n }\n })\n }\n\n //\n\n chainStore.count = 0\n modelStore.chainCount.fill(0, 0, modelStore.count)\n modelStore.chainOffset.fill(0, 0, modelStore.count)\n chainData.forEach(function (d) {\n addChain(d.mIndex, d.chainname, d.rStart, d.rCount)\n })\n\n let chainOffset = 0\n structure.eachModel(function (mp) {\n modelStore.chainOffset[ mp.index ] = chainOffset\n chainOffset += modelStore.chainCount[ mp.index ]\n })\n }\n\n if (Debug) Log.timeEnd('calculateChainnames')\n}\n\nexport function calculateBonds (structure: Structure, inferBonds: InferBondsOptions='all') {\n if (inferBonds === 'none') return \n if (Debug) Log.time('calculateBonds')\n\n calculateBondsWithin(structure, false, inferBonds)\n calculateBondsBetween(structure)\n\n if (Debug) Log.timeEnd('calculateBonds')\n}\n\n/**\n * Should Bonds be inferred for `all` atoms, `none` or `auto`\n * If `auto`, any hetgroup residue with at least one CONECT record will \n * not have bonding inferred, and will rely on the CONECT records\n */\nexport type InferBondsOptions = 'all' | 'none' | 'auto'\n\nexport interface ResidueBonds {\n atomIndices1: number[]\n atomIndices2: number[]\n bondOrders: number[]\n}\n\n\nconst BondOrderTable: { [k: string]: number } = {\n 'HIS|CD2|CG': 2,\n 'HIS|CE1|ND1': 2,\n 'ARG|CZ|NH2': 2,\n 'PHE|CE1|CZ': 2,\n 'PHE|CD2|CE2': 2,\n 'PHE|CD1|CG': 2,\n 'TRP|CD1|CG': 2,\n 'TRP|CD2|CE2': 2,\n 'TRP|CE3|CZ3': 2,\n 'TRP|CH2|CZ2': 2,\n 'ASN|CG|OD1': 2,\n 'GLN|CD|OE1': 2,\n 'TYR|CD1|CG': 2,\n 'TYR|CD2|CE2': 2,\n 'TYR|CE1|CZ': 2,\n 'ASP|CG|OD1': 2,\n 'GLU|CD|OE1': 2,\n\n 'G|C8|N7': 2,\n 'G|C4|C5': 2,\n 'G|C2|N3': 2,\n 'G|C6|O6': 2,\n 'C|C4|N3': 2,\n 'C|C5|C6': 2,\n 'C|C2|O2': 2,\n 'A|C2|N3': 2,\n 'A|C6|N1': 2,\n 'A|C4|C5': 2,\n 'A|C8|N7': 2,\n 'U|C5|C6': 2,\n 'U|C2|O2': 2,\n 'U|C4|O4': 2,\n\n 'DG|C8|N7': 2,\n 'DG|C4|C5': 2,\n 'DG|C2|N3': 2,\n 'DG|C6|O6': 2,\n 'DC|C4|N3': 2,\n 'DC|C5|C6': 2,\n 'DC|C2|O2': 2,\n 'DA|C2|N3': 2,\n 'DA|C6|N1': 2,\n 'DA|C4|C5': 2,\n 'DA|C8|N7': 2,\n 'DT|C5|C6': 2,\n 'DT|C2|O2': 2,\n 'DT|C4|O4': 2\n}\nfunction getBondOrderFromTable (resname: string, atomname1: string, atomname2: string) {\n [ atomname1, atomname2 ] = atomname1 < atomname2 ? [ atomname1, atomname2 ] : [ atomname2, atomname1 ]\n if (AA3.includes(resname) && atomname1 === 'C' && atomname2 === 'O') return 2\n if (Bases.includes(resname) && atomname1 === 'OP1' && atomname2 === 'P') return 2\n return BondOrderTable[ `${resname}|${atomname1}|${atomname2}` ] || 1\n}\n\nexport function calculateResidueBonds (r: ResidueProxy) {\n const structure = r.structure\n const a1 = structure.getAtomProxy()\n const a2 = structure.getAtomProxy()\n\n const count = r.atomCount\n const offset = r.atomOffset\n const end = offset + count\n const end1 = end - 1\n\n const atomIndices1 = []\n const atomIndices2 = []\n const bondOrders = []\n\n if (count > 500) {\n if (Debug) Log.warn('more than 500 atoms, skip residue for auto-bonding', r.qualifiedName())\n } else {\n if (count > 50) {\n const kdtree = new Kdtree(r, true)\n const radius = r.isCg() ? 1.2 : 2.3\n\n for (let i = offset; i < end1; ++i) {\n a1.index = i\n const maxd = a1.covalent + radius + 0.3\n const nearestAtoms = kdtree.nearest(a1 as any, Infinity, maxd * maxd) // TODO\n const m = nearestAtoms.length\n for (let j = 0; j < m; ++j) {\n a2.index = nearestAtoms[ j ].index\n if (a1.index < a2.index) {\n if (a1.connectedTo(a2)) {\n atomIndices1.push(a1.index - offset)\n atomIndices2.push(a2.index - offset)\n bondOrders.push(getBondOrderFromTable(a1.resname, a1.atomname, a2.atomname))\n }\n }\n }\n }\n } else {\n for (let i = offset; i < end1; ++i) {\n a1.index = i\n for (let j = i + 1; j <= end1; ++j) {\n a2.index = j\n if (a1.connectedTo(a2)) {\n atomIndices1.push(i - offset)\n atomIndices2.push(j - offset)\n bondOrders.push(getBondOrderFromTable(a1.resname, a1.atomname, a2.atomname))\n }\n }\n }\n }\n }\n\n return {\n atomIndices1: atomIndices1,\n atomIndices2: atomIndices2,\n bondOrders: bondOrders\n }\n}\n\nexport function calculateAtomBondMap (structure: Structure) {\n if (Debug) Log.time('calculateAtomBondMap')\n\n var atomBondMap: number[][] = []\n\n structure.eachBond(function (bp) {\n var ai1 = bp.atomIndex1\n var ai2 = bp.atomIndex2\n if (atomBondMap[ ai1 ] === undefined) atomBondMap[ ai1 ] = []\n atomBondMap[ ai1 ][ ai2 ] = bp.index\n })\n\n if (Debug) Log.timeEnd('calculateAtomBondMap')\n\n return atomBondMap\n}\n\nexport function calculateBondsWithin (structure: Structure, onlyAddRung = false, inferBonds: InferBondsOptions='all') {\n if (Debug) Log.time('calculateBondsWithin')\n\n const bondStore = structure.bondStore\n const rungBondStore = structure.rungBondStore\n const rungAtomSet = structure.getAtomSet(false)\n const a1 = structure.getAtomProxy()\n const a2 = structure.getAtomProxy()\n const bp = structure.getBondProxy()\n const atomBondMap = onlyAddRung ? null : calculateAtomBondMap(structure)\n\n let bondedAtoms: Set\n if (!onlyAddRung && inferBonds === 'auto') {\n bondedAtoms = new Set()\n atomBondMap!.forEach((a, i) => {\n bondedAtoms.add(i)\n a.forEach(j => {bondedAtoms.add(j)})\n })\n }\n\n structure.eachResidue(function (r) {\n if (!onlyAddRung && atomBondMap) {\n const count = r.atomCount\n const offset = r.atomOffset\n\n if (count > 500) {\n Log.warn('more than 500 atoms, skip residue for auto-bonding', r.qualifiedName())\n return\n }\n\n if (inferBonds === 'auto' && r.hetero) {\n // Are bonds present on this residue?\n for (let rai=r.atomOffset; rai {\n ncsMatrixList.forEach(nm => {\n ncsUnitcellMatrixList.push(sm.clone().multiply(nm))\n })\n })\n unitcellAssembly.addPart(ncsUnitcellMatrixList)\n } else {\n unitcellAssembly.addPart(unitcellMatrixList)\n }\n\n const vec = new Vector3()\n const supercellAssembly = new Assembly('SUPERCELL')\n const supercellMatrixList = Array.prototype.concat.call(\n getMatrixList(vec.set(1, 0, 0)), // 655\n getMatrixList(vec.set(0, 1, 0)), // 565\n getMatrixList(vec.set(0, 0, 1)), // 556\n\n getMatrixList(vec.set(-1, 0, 0)), // 455\n getMatrixList(vec.set(0, -1, 0)), // 545\n getMatrixList(vec.set(0, 0, -1)), // 554\n\n getMatrixList(vec.set(1, 1, 0)), // 665\n getMatrixList(vec.set(1, 0, 1)), // 656\n getMatrixList(vec.set(0, 1, 1)), // 566\n\n getMatrixList(vec.set(-1, -1, 0)), // 445\n getMatrixList(vec.set(-1, 0, -1)), // 454\n getMatrixList(vec.set(0, -1, -1)), // 544\n\n getMatrixList(vec.set(1, -1, -1)), // 644\n getMatrixList(vec.set(1, 1, -1)), // 664\n getMatrixList(vec.set(1, -1, 1)), // 646\n getMatrixList(vec.set(-1, 1, 1)), // 466\n getMatrixList(vec.set(-1, -1, 1)), // 446\n getMatrixList(vec.set(-1, 1, -1)), // 464\n\n getMatrixList(vec.set(0, 1, -1)), // 564\n getMatrixList(vec.set(0, -1, 1)), // 546\n getMatrixList(vec.set(1, 0, -1)), // 654\n getMatrixList(vec.set(-1, 0, 1)), // 456\n getMatrixList(vec.set(1, -1, 0)), // 645\n getMatrixList(vec.set(-1, 1, 0)), // 465\n\n getMatrixList(), // 555\n getMatrixList(vec.set(1, 1, 1)), // 666\n getMatrixList(vec.set(-1, -1, -1)) // 444\n )\n if (structure.biomolDict.NCS) {\n const ncsSupercellMatrixList: Matrix4[] = []\n supercellMatrixList.forEach(function (sm: Matrix4) {\n ncsMatrixList.forEach(function (nm) {\n ncsSupercellMatrixList.push(sm.clone().multiply(nm))\n })\n })\n supercellAssembly.addPart(ncsSupercellMatrixList)\n } else {\n supercellAssembly.addPart(supercellMatrixList)\n }\n\n structure.biomolDict.UNITCELL = unitcellAssembly\n structure.biomolDict.SUPERCELL = supercellAssembly\n\n if (Debug) Log.timeEnd('buildUnitcellAssembly')\n}\n\nconst elm1 = [ 'H', 'C', 'O', 'N', 'S', 'P' ]\nconst elm2 = [ 'NA', 'CL', 'FE' ]\n\nexport function guessElement (atomName: string) {\n // Retain first group of letters in atomName\n let at = atomName.toUpperCase()\n let begin = 0, end = 0\n for (let i = 0; i < at.length ; i++) {\n if (at.charCodeAt(i) < 65) {\n if (end > 0) break\n ++begin\n }\n else end = i + 1\n }\n if (begin > 0 || end < at.length) at = at.substring(begin, end)\n \n const n = at.length\n\n if (n === 0) return ''\n if (n === 1) return at\n if (n === 2) {\n if (elm2.indexOf(at) !== -1) return at\n if (elm1.indexOf(at[0]) !== -1) return at[0]\n if (at in AtomicNumbers) return at\n }\n if (n >= 3) {\n if (elm1.indexOf(at[0]) !== -1) return at[0]\n }\n return ''\n}\n\n/**\n * Assigns ResidueType bonds.\n * @param {Structure} structure - the structure object\n * @return {undefined}\n */\nexport function assignResidueTypeBonds (structure: Structure) {\n // if( Debug ) Log.time( \"assignResidueTypeBonds\" )\n\n const bondHash = structure.bondHash! // TODO\n const countArray = bondHash.countArray\n const offsetArray = bondHash.offsetArray\n const indexArray = bondHash.indexArray\n const bp = structure.getBondProxy()\n\n structure.eachResidue(function (rp) {\n const residueType = rp.residueType\n if (residueType.bonds !== undefined) return\n\n var atomOffset = rp.atomOffset\n var atomIndices1: number[] = []\n var atomIndices2: number[] = []\n var bondOrders: number[] = []\n var bondDict: { [k: string]: boolean } = {}\n\n const nextAtomOffset = atomOffset + rp.atomCount\n\n rp.eachAtom(function (ap) {\n const index = ap.index\n const offset = offsetArray[ index ]\n const count = countArray[ index ]\n for (let i = 0, il = count; i < il; ++i) {\n bp.index = indexArray[ offset + i ]\n let idx1 = bp.atomIndex1\n if (idx1 < atomOffset || idx1 >= nextAtomOffset) {\n // Don't add bonds outside of this resiude\n continue\n }\n let idx2 = bp.atomIndex2\n if (idx2 < atomOffset || idx2 >= nextAtomOffset) {\n continue\n }\n\n if (idx1 > idx2) {\n const tmp = idx2\n idx2 = idx1\n idx1 = tmp\n }\n const hash = idx1 + '|' + idx2\n if (bondDict[ hash ] === undefined) {\n bondDict[ hash ] = true\n atomIndices1.push(idx1 - atomOffset)\n atomIndices2.push(idx2 - atomOffset)\n bondOrders.push(bp.bondOrder)\n }\n }\n })\n\n residueType.bonds = {\n atomIndices1: atomIndices1,\n atomIndices2: atomIndices2,\n bondOrders: bondOrders\n }\n })\n\n // if( Debug ) Log.timeEnd( \"assignResidueTypeBonds\" )\n}\n\nexport function concatStructures (name: string, ...structures: Structure[]) {\n if( Debug ) Log.time( \"concatStructures\" )\n\n const s = new Structure(name, '')\n const sb = new StructureBuilder(s)\n\n const atomStore = s.atomStore as any\n const atomMap = s.atomMap\n atomStore.addField('formalCharge', 1, 'int8')\n atomStore.addField('partialCharge', 1, 'float32')\n\n const atomIndexDict: { [k: number]: number } = {}\n\n let idx = 0\n let atomCount = 0\n let modelCount = 0\n structures.forEach(structure => {\n structure.eachAtom(a => {\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(a.atomname, a.element)\n\n atomStore.x[ idx ] = a.x\n atomStore.y[ idx ] = a.y\n atomStore.z[ idx ] = a.z\n atomStore.serial[ idx ] = a.serial\n atomStore.formalCharge[ idx ] = a.formalCharge\n atomStore.partialCharge[ idx ] = a.partialCharge\n atomStore.altloc[ idx ] = a.altloc\n atomStore.occupancy[ idx ] = a.occupancy\n atomStore.bfactor[ idx ] = a.bfactor\n\n sb.addAtom(\n a.modelIndex + modelCount,\n a.chainname,\n a.chainid,\n a.resname,\n a.resno,\n a.hetero === 1,\n a.sstruc,\n a.inscode\n )\n\n atomIndexDict[a.index + atomCount] = idx\n idx += 1\n })\n atomCount += structure.atomStore.count\n modelCount += structure.modelStore.count\n })\n\n const bondStore = s.bondStore\n const a1 = s.getAtomProxy()\n const a2 = s.getAtomProxy()\n\n atomCount = 0\n structures.forEach(structure => {\n structure.eachBond(b => {\n a1.index = atomIndexDict[ b.atomIndex1 + atomCount ]\n a2.index = atomIndexDict[ b.atomIndex2 + atomCount ]\n bondStore.addBond(a1, a2, b.bondOrder)\n })\n atomCount += structure.atomStore.count\n })\n\n sb.finalize()\n\n calculateBondsBetween(s, true) // calculate backbone bonds\n calculateBondsWithin(s, true) // calculate rung bonds\n\n s.finalizeAtoms()\n s.finalizeBonds()\n assignResidueTypeBonds(s)\n\n if( Debug ) Log.timeEnd( \"concatStructures\" )\n\n return s\n}\n","/**\n * @file Atom Type\n * @author Alexander Rose \n * @private\n */\n\nimport { guessElement } from '../structure/structure-utils'\nimport {\n AtomicNumbers, DefaultAtomicNumber,\n VdwRadii, DefaultVdwRadius,\n CovalentRadii, DefaultCovalentRadius,\n Valences, DefaultValence,\n OuterShellElectronCounts, DefaultOuterShellElectronCount\n} from '../structure/structure-constants'\nimport Structure from '../structure/structure'\n\n// Li, Na, K, Rb, Cs Fr\nconst AlkaliMetals = [ 3, 11, 19, 37, 55, 87 ]\n\n// Be, Mg, Ca, Sr, Ba, Ra\nconst AlkalineEarthMetals = [ 4, 12, 20, 38, 56, 88 ]\n\n// C, P, S, Se\nconst PolyatomicNonmetals = [ 6, 15, 16, 34, ]\n\n// H, N, O, F, Cl, Br, I\nconst DiatomicNonmetals = [ 1, 7, 8, 9, 17, 35, 53 ]\n\n// He, Ne, Ar, Kr, Xe, Rn\nconst NobleGases = [ 2, 10, 18, 36, 54, 86 ]\n\n// Zn, Ga, Cd, In, Sn, Hg, Ti, Pb, Bi, Po, Cn\nconst PostTransitionMetals = [ 13, 30, 31, 48, 49, 50, 80, 81, 82, 83, 84, 85, 112 ]\n\n// B, Si, Ge, As, Sb, Te, At\nconst Metalloids = [ 5, 14, 32, 33, 51, 52, 85 ]\n\n// F, Cl, Br, I, At\nconst Halogens = [ 9, 17, 35, 53, 85 ]\n\n/**\n * Atom type\n */\nclass AtomType {\n element: string\n number: number\n vdw: number\n covalent: number\n\n /**\n * @param {Structure} structure - the structure object\n * @param {String} atomname - the name of the atom\n * @param {String} element - the chemical element\n */\n constructor (readonly structure: Structure, readonly atomname: string, element?: string) {\n element = element || guessElement(atomname)\n\n this.element = element\n this.number = AtomicNumbers[ element ] || DefaultAtomicNumber\n this.vdw = VdwRadii[ this.number ] || DefaultVdwRadius\n this.covalent = CovalentRadii[ this.number ] || DefaultCovalentRadius\n }\n\n getDefaultValence() {\n const vl = Valences[ this.number ]\n return vl ? vl[ 0 ] : DefaultValence\n }\n\n getValenceList () {\n return Valences[ this.number ] || []\n }\n\n getOuterShellElectronCount () {\n return OuterShellElectronCounts[ this.number ] || DefaultOuterShellElectronCount\n }\n\n isMetal () {\n return (\n this.isAlkaliMetal() ||\n this.isAlkalineEarthMetal() ||\n this.isLanthanide() ||\n this.isActinide() ||\n this.isTransitionMetal() ||\n this.isPostTransitionMetal()\n )\n }\n\n isNonmetal () {\n return (\n this.isDiatomicNonmetal() ||\n this.isPolyatomicNonmetal() ||\n this.isNobleGas()\n )\n }\n\n isMetalloid () {\n return Metalloids.includes(this.number)\n }\n\n isHalogen () {\n return Halogens.includes(this.number)\n }\n\n isDiatomicNonmetal () {\n return DiatomicNonmetals.includes(this.number)\n }\n\n isPolyatomicNonmetal () {\n return PolyatomicNonmetals.includes(this.number)\n }\n\n isAlkaliMetal () {\n return AlkaliMetals.includes(this.number)\n }\n\n isAlkalineEarthMetal () {\n return AlkalineEarthMetals.includes(this.number)\n }\n\n isNobleGas () {\n return NobleGases.includes(this.number)\n }\n\n isTransitionMetal () {\n const no = this.number\n return (\n (no >= 21 && no <= 29) ||\n (no >= 39 && no <= 47) ||\n (no >= 72 && no <= 79) ||\n (no >= 104 && no <= 108)\n )\n }\n\n isPostTransitionMetal () {\n return PostTransitionMetals.includes(this.number)\n }\n\n isLanthanide () {\n return this.number >= 57 && this.number <= 71\n }\n\n isActinide () {\n return this.number >= 89 && this.number <= 103\n }\n\n}\n\nexport default AtomType","/**\n * @file Atom Map\n * @author Alexander Rose \n * @private\n */\n\nimport AtomType from './atom-type'\nimport { guessElement } from '../structure/structure-utils'\nimport Structure from '../structure/structure'\n\nfunction getHash (atomname: string, element: string) {\n return atomname + '|' + element\n}\n\nclass AtomMap {\n dict: { [k: string]: number } = {}\n list: AtomType[] = []\n\n constructor (readonly structure: Structure) {\n this.structure = structure\n }\n\n add (atomname: string, element?: string) {\n atomname = atomname.toUpperCase()\n if (!element) {\n element = guessElement(atomname)\n } else {\n element = element.toUpperCase()\n }\n const hash = getHash(atomname, element)\n let id = this.dict[ hash ]\n if (id === undefined) {\n const atomType = new AtomType(this.structure, atomname, element)\n id = this.list.length\n this.dict[ hash ] = id\n this.list.push(atomType)\n }\n return id\n }\n\n get (id: number) {\n return this.list[ id ]\n }\n}\n\nexport default AtomMap\n","/**\n * @file Residue Type\n * @author Alexander Rose \n * @author Fred Ludlow\n * @private\n */\n\nimport { defaults } from '../utils'\nimport PrincipalAxes from '../math/principal-axes'\nimport { Matrix } from '../math/matrix-utils'\nimport { calculateResidueBonds, ResidueBonds } from '../structure/structure-utils'\nimport {\n Elements,\n ProteinType, RnaType, DnaType, WaterType, IonType, SaccharideType, UnknownType,\n ProteinBackboneType, RnaBackboneType, DnaBackboneType, UnknownBackboneType,\n CgProteinBackboneType, CgRnaBackboneType, CgDnaBackboneType,\n ChemCompProtein, ChemCompRna, ChemCompDna, ChemCompSaccharide,\n AA3, PurinBases, RnaBases, DnaBases, Bases, IonNames, WaterNames, SaccharideNames,\n ProteinBackboneAtoms, NucleicBackboneAtoms, ResidueTypeAtoms\n} from '../structure/structure-constants'\nimport Structure from '../structure/structure'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\n\nexport interface BondGraph {\n [k: number]: number[]\n}\n\nexport interface RingData {\n atomRings: number[][] // sparse array:\n // atomRings[atomIdx] -> array of ring indices\n rings: number[][] // rings as arrays of indices\n}\n\n/**\n * Residue type\n */\nexport default class ResidueType {\n resname: string\n atomTypeIdList: number[]\n hetero: number\n chemCompType: string\n bonds?: ResidueBonds\n rings?: RingData\n bondGraph?: BondGraph\n aromaticAtoms?: Uint8Array\n aromaticRings?: number[][]\n\n atomCount: number\n\n moleculeType: number\n backboneType: number\n backboneEndType: number\n backboneStartType: number\n backboneIndexList: number[]\n\n traceAtomIndex: number\n direction1AtomIndex: number\n direction2AtomIndex: number\n backboneStartAtomIndex: number\n backboneEndAtomIndex: number\n rungEndAtomIndex: number\n\n // Sparse array containing the reference atom index for each bond.\n bondReferenceAtomIndices: number[] = []\n\n /**\n * @param {Structure} structure - the structure object\n * @param {String} resname - name of the residue\n * @param {Array} atomTypeIdList - list of IDs of {@link AtomType}s corresponding\n * to the atoms of the residue\n * @param {Boolean} hetero - hetero flag\n * @param {String} chemCompType - chemical component type\n * @param {Object} [bonds] - TODO\n */\n constructor (readonly structure: Structure, resname: string, atomTypeIdList: number[], hetero: boolean, chemCompType: string, bonds?: ResidueBonds) {\n this.resname = resname\n this.atomTypeIdList = atomTypeIdList\n this.hetero = hetero ? 1 : 0\n this.chemCompType = chemCompType\n this.bonds = bonds\n this.atomCount = atomTypeIdList.length\n\n this.moleculeType = this.getMoleculeType()\n this.backboneType = this.getBackboneType(0)\n this.backboneEndType = this.getBackboneType(-1)\n this.backboneStartType = this.getBackboneType(1)\n this.backboneIndexList = this.getBackboneIndexList()\n\n const atomnames = ResidueTypeAtoms[ this.backboneType ]\n const atomnamesStart = ResidueTypeAtoms[ this.backboneStartType ]\n const atomnamesEnd = ResidueTypeAtoms[ this.backboneEndType ]\n\n const traceIndex = this.getAtomIndexByName(atomnames.trace)\n this.traceAtomIndex = defaults(traceIndex, -1)\n\n const dir1Index = this.getAtomIndexByName(atomnames.direction1)\n this.direction1AtomIndex = defaults(dir1Index, -1)\n\n const dir2Index = this.getAtomIndexByName(atomnames.direction2)\n this.direction2AtomIndex = defaults(dir2Index, -1)\n\n const bbStartIndex = this.getAtomIndexByName(atomnamesStart.backboneStart)\n this.backboneStartAtomIndex = defaults(bbStartIndex, -1)\n\n const bbEndIndex = this.getAtomIndexByName(atomnamesEnd.backboneEnd)\n this.backboneEndAtomIndex = defaults(bbEndIndex, -1)\n\n let rungEndIndex\n if (PurinBases.includes(resname)) {\n rungEndIndex = this.getAtomIndexByName('N1')\n } else {\n rungEndIndex = this.getAtomIndexByName('N3')\n }\n this.rungEndAtomIndex = defaults(rungEndIndex, -1)\n }\n\n getBackboneIndexList () {\n const backboneIndexList: number[] = []\n let atomnameList\n switch (this.moleculeType) {\n case ProteinType:\n atomnameList = ProteinBackboneAtoms\n break\n case RnaType:\n case DnaType:\n atomnameList = NucleicBackboneAtoms\n break\n default:\n return backboneIndexList\n }\n const atomMap = this.structure.atomMap\n const atomTypeIdList = this.atomTypeIdList\n for (let i = 0, il = this.atomCount; i < il; ++i) {\n const atomType = atomMap.get(atomTypeIdList[ i ])\n if (atomnameList.includes(atomType.atomname)) {\n backboneIndexList.push(i)\n }\n }\n return backboneIndexList\n }\n\n getMoleculeType () {\n if (this.isProtein()) {\n return ProteinType\n } else if (this.isRna()) {\n return RnaType\n } else if (this.isDna()) {\n return DnaType\n } else if (this.isWater()) {\n return WaterType\n } else if (this.isIon()) {\n return IonType\n } else if (this.isSaccharide()) {\n return SaccharideType\n } else {\n return UnknownType\n }\n }\n\n getBackboneType (position: number) {\n if (this.hasProteinBackbone(position)) {\n return ProteinBackboneType\n } else if (this.hasRnaBackbone(position)) {\n return RnaBackboneType\n } else if (this.hasDnaBackbone(position)) {\n return DnaBackboneType\n } else if (this.hasCgProteinBackbone(position)) {\n return CgProteinBackboneType\n } else if (this.hasCgRnaBackbone(position)) {\n return CgRnaBackboneType\n } else if (this.hasCgDnaBackbone(position)) {\n return CgDnaBackboneType\n } else {\n return UnknownBackboneType\n }\n }\n\n isProtein () {\n if (this.chemCompType) {\n return ChemCompProtein.includes(this.chemCompType)\n } else {\n return (\n this.hasAtomWithName('CA', 'C', 'N') ||\n AA3.includes(this.resname)\n )\n }\n }\n\n isCg () {\n const backboneType = this.backboneType\n return (\n backboneType === CgProteinBackboneType ||\n backboneType === CgRnaBackboneType ||\n backboneType === CgDnaBackboneType\n )\n }\n\n isNucleic () {\n return this.isRna() || this.isDna()\n }\n\n isRna () {\n if (this.chemCompType) {\n return ChemCompRna.includes(this.chemCompType)\n } else if (this.hetero === 1) {\n return false\n } else {\n return (\n this.hasAtomWithName(\n [ 'P', \"O3'\", 'O3*' ], [ \"C4'\", 'C4*' ], [ \"O2'\", 'O2*', \"F2'\", 'F2*' ]\n ) ||\n (RnaBases.includes(this.resname) &&\n (this.hasAtomWithName([ \"O2'\", 'O2*', \"F2'\", 'F2*' ])))\n )\n }\n }\n\n isDna () {\n if (this.chemCompType) {\n return ChemCompDna.includes(this.chemCompType)\n } else if (this.hetero === 1) {\n return false\n } else {\n return (\n (this.hasAtomWithName([ 'P', \"O3'\", 'O3*' ], [ \"C3'\", 'C3*' ]) &&\n !this.hasAtomWithName([ \"O2'\", 'O2*', \"F2'\", 'F2*' ])) ||\n DnaBases.includes(this.resname)\n )\n }\n }\n\n isHetero () {\n return this.hetero === 1\n }\n\n isIon () {\n return IonNames.includes(this.resname)\n }\n\n isWater () {\n return WaterNames.includes(this.resname)\n }\n\n isSaccharide () {\n if (this.chemCompType) {\n return ChemCompSaccharide.includes(this.chemCompType)\n } else {\n return SaccharideNames.includes(this.resname)\n }\n }\n\n isStandardAminoacid () {\n return AA3.includes(this.resname)\n }\n\n isStandardBase () {\n return Bases.includes(this.resname)\n }\n\n hasBackboneAtoms (position: number, type: number) {\n const atomnames = ResidueTypeAtoms[ type ]\n if (position === -1) {\n return this.hasAtomWithName(\n atomnames.trace,\n atomnames.backboneEnd,\n atomnames.direction1,\n atomnames.direction2\n )\n } else if (position === 0) {\n return this.hasAtomWithName(\n atomnames.trace,\n atomnames.direction1,\n atomnames.direction2\n )\n } else if (position === 1) {\n return this.hasAtomWithName(\n atomnames.trace,\n atomnames.backboneStart,\n atomnames.direction1,\n atomnames.direction2\n )\n } else {\n return this.hasAtomWithName(\n atomnames.trace,\n atomnames.backboneStart,\n atomnames.backboneEnd,\n atomnames.direction1,\n atomnames.direction2\n )\n }\n }\n\n hasProteinBackbone (position: number) {\n return (\n this.isProtein() &&\n this.hasBackboneAtoms(position, ProteinBackboneType)\n )\n }\n\n hasRnaBackbone (position: number) {\n return (\n this.isRna() &&\n this.hasBackboneAtoms(position, RnaBackboneType)\n )\n }\n\n hasDnaBackbone (position: number) {\n return (\n this.isDna() &&\n this.hasBackboneAtoms(position, DnaBackboneType)\n )\n }\n\n hasCgProteinBackbone (position: number) {\n return (\n this.atomCount < 7 &&\n this.isProtein() &&\n this.hasBackboneAtoms(position, CgProteinBackboneType)\n )\n }\n\n hasCgRnaBackbone (position: number) {\n return (\n this.atomCount < 11 &&\n this.isRna() &&\n this.hasBackboneAtoms(position, CgRnaBackboneType)\n )\n }\n\n hasCgDnaBackbone (position: number) {\n return (\n this.atomCount < 11 &&\n this.isDna() &&\n this.hasBackboneAtoms(position, CgDnaBackboneType)\n )\n }\n\n hasBackbone (position: number) {\n return (\n this.hasProteinBackbone(position) ||\n this.hasRnaBackbone(position) ||\n this.hasDnaBackbone(position) ||\n this.hasCgProteinBackbone(position) ||\n this.hasCgRnaBackbone(position) ||\n this.hasCgDnaBackbone(position)\n )\n }\n\n getAtomIndexByName (atomname: string|string[]) {\n const n = this.atomCount\n const atomMap = this.structure.atomMap\n const atomTypeIdList = this.atomTypeIdList\n if (Array.isArray(atomname)) {\n for (let i = 0; i < n; ++i) {\n const index = atomTypeIdList[ i ]\n if (atomname.includes(atomMap.get(index).atomname)) {\n return i\n }\n }\n } else {\n for (let i = 0; i < n; ++i) {\n const index = atomTypeIdList[ i ]\n if (atomname === atomMap.get(index).atomname) {\n return i\n }\n }\n }\n return undefined\n }\n\n hasAtomWithName (...atomnames: (string|string[])[]) {\n const n = atomnames.length\n for (let i = 0; i < n; ++i) {\n if (atomnames[ i ] === undefined) continue\n if (this.getAtomIndexByName(atomnames[ i ]) === undefined) {\n return false\n }\n }\n return true\n }\n\n getBonds (r?: ResidueProxy) {\n if (this.bonds === undefined) {\n this.bonds = calculateResidueBonds(r!) // TODO\n }\n return this.bonds\n }\n\n getRings () {\n if (this.rings === undefined) {\n this.calculateRings()\n }\n return this.rings\n }\n\n getBondGraph () {\n if (this.bondGraph === undefined) {\n this.calculateBondGraph()\n }\n return this.bondGraph\n }\n\n getAromatic (a?: AtomProxy) {\n if (this.aromaticAtoms === undefined) {\n this.calculateAromatic(this.structure.getResidueProxy((a!).residueIndex)) // TODO\n }\n return this.aromaticAtoms\n }\n\n getAromaticRings (r?: ResidueProxy) {\n if (this.aromaticRings === undefined) {\n this.calculateAromatic(r!) // TODO\n }\n return this.aromaticRings\n }\n\n /**\n * @return {Object} bondGraph - represents the bonding in this\n * residue: { ai1: [ ai2, ai3, ...], ...}\n */\n calculateBondGraph () {\n const bondGraph: BondGraph = this.bondGraph = {}\n const bonds = this.getBonds()\n const nb = bonds.atomIndices1.length\n const atomIndices1 = bonds.atomIndices1\n const atomIndices2 = bonds.atomIndices2\n\n for (let i = 0; i < nb; ++i) {\n const ai1 = atomIndices1[i]\n const ai2 = atomIndices2[i]\n\n const a1 = bondGraph[ ai1 ] = bondGraph[ ai1 ] || []\n a1.push(ai2)\n\n const a2 = bondGraph[ ai2 ] = bondGraph[ ai2 ] || []\n a2.push(ai1)\n }\n }\n\n /**\n * Find all rings up to 2 * RingFinderMaxDepth\n */\n calculateRings () {\n const bondGraph = this.getBondGraph()! // TODO\n const state = RingFinderState(bondGraph, this.atomCount)\n\n for (let i = 0; i < state.count; i++) {\n if (state.visited[i] >= 0) continue\n findRings(state, i)\n }\n\n this.rings = { atomRings: state.atomRings, rings: state.rings }\n }\n\n isAromatic (atom: AtomProxy) {\n this.aromaticAtoms = this.getAromatic(atom)! // TODO\n return this.aromaticAtoms[atom.index - atom.residueAtomOffset] === 1\n }\n\n calculateAromatic (r: ResidueProxy) {\n const aromaticAtoms = this.aromaticAtoms = new Uint8Array(this.atomCount)\n const rings = this.getRings()!.rings\n\n const aromaticRingFlags = rings.map(ring => {\n return isRingAromatic(ring.map(idx => {\n return this.structure.getAtomProxy(idx + r.atomOffset)\n }))\n })\n\n const aromaticRings: number[][] = this.aromaticRings = []\n rings.forEach((ring, i) => {\n if (aromaticRingFlags[i]) {\n aromaticRings.push(ring)\n ring.forEach(idx => aromaticAtoms[idx] = 1)\n }\n })\n }\n\n /**\n * For bonds with order > 1, pick a reference atom\n * @return {undefined}\n */\n assignBondReferenceAtomIndices () {\n const bondGraph = this.getBondGraph()! // TODO\n const rings = this.getRings()! // TODO\n const atomRings = rings.atomRings\n const ringData = rings.rings\n\n const bonds = this.bonds! // TODO\n const atomIndices1 = bonds.atomIndices1\n const atomIndices2 = bonds.atomIndices2\n const bondOrders = bonds.bondOrders\n const bondReferenceAtomIndices = this.bondReferenceAtomIndices\n\n const nb = bonds.atomIndices1.length\n\n bondReferenceAtomIndices.length = 0 // reset array\n\n for (let i = 0; i < nb; ++i) {\n // Not required for single bonds\n if (bondOrders[i] <= 1) continue\n\n let refRing\n\n const ai1 = atomIndices1[i]\n const ai2 = atomIndices2[i]\n\n const rings1 = atomRings[ ai1 ]\n const rings2 = atomRings[ ai2 ]\n // Are both atoms in a ring?\n if (rings1 && rings2) {\n // Are they in the same ring? (If not, ignore ring info)\n for (let ri1 = 0; ri1 < rings1.length; ri1++){\n if (rings2.indexOf(rings1[ ri1 ]) !== -1) {\n refRing = ringData[ rings1[ ri1 ] ]\n break\n }\n }\n }\n\n // Find the first neighbour.\n if (bondGraph[ ai1 ].length > 1) {\n for (let j = 0; j < bondGraph[ ai1 ].length; ++j) {\n const ai3 = bondGraph[ ai1 ][ j ]\n if (ai3 !== ai2) {\n if (refRing === undefined || refRing.indexOf(ai3) !== -1){\n bondReferenceAtomIndices[i] = ai3\n break\n }\n }\n }\n } else if (bondGraph[ ai2 ].length > 1) {\n for (let j = 0; j < bondGraph[ ai2 ].length; ++j) {\n const ai3 = bondGraph[ ai2 ][ j ]\n if (ai3 !== ai1) {\n if (refRing === undefined || refRing.indexOf(ai3) !== -1){\n bondReferenceAtomIndices[i] = ai3\n break\n }\n }\n }\n } // No reference atom could be found (e.g. diatomic molecule/fragment)\n }\n }\n\n getBondIndex (atomIndex1: number, atomIndex2: number) {\n const bonds = this.bonds! // TODO\n const atomIndices1 = bonds.atomIndices1\n const atomIndices2 = bonds.atomIndices2\n let idx1 = atomIndices1.indexOf(atomIndex1)\n let idx2 = atomIndices2.indexOf(atomIndex2)\n const _idx2 = idx2\n while (idx1 !== -1) {\n while (idx2 !== -1) {\n if (idx1 === idx2) return idx1\n idx2 = atomIndices2.indexOf(atomIndex2, idx2 + 1)\n }\n idx1 = atomIndices1.indexOf(atomIndex1, idx1 + 1)\n idx2 = _idx2\n }\n // returns undefined when no bond is found\n }\n\n getBondReferenceAtomIndex (atomIndex1: number, atomIndex2: number) {\n const bondIndex = this.getBondIndex(atomIndex1, atomIndex2)\n if (bondIndex === undefined) return undefined\n if (this.bondReferenceAtomIndices.length === 0) {\n this.assignBondReferenceAtomIndices()\n }\n return this.bondReferenceAtomIndices[ bondIndex ]\n }\n}\n\n//\n\nconst AromaticRingElements = [\n Elements.B, Elements.C, Elements.N, Elements.O,\n Elements.SI, Elements.P, Elements.S,\n Elements.GE, Elements.AS,\n Elements.SN, Elements.SB,\n Elements.BI\n]\nconst AromaticRingPlanarityThreshold = 0.05\n\nfunction isRingAromatic (ring: AtomProxy[]) {\n if (ring.some(a => !AromaticRingElements.includes(a.number))) return false\n\n let i = 0\n const coords = new Matrix(3, ring.length)\n const cd = coords.data\n\n ring.forEach(a => {\n cd[ i + 0 ] = a.x\n cd[ i + 1 ] = a.y\n cd[ i + 2 ] = a.z\n i += 3\n })\n\n const pa = new PrincipalAxes(coords)\n\n return pa.vecC.length() < AromaticRingPlanarityThreshold\n}\n\n//\n\n/**\n * Ring finding code below adapted from MolQL\n * Copyright (c) 2017 MolQL contributors, licensed under MIT\n * @author David Sehnal \n */\n\nfunction addRing(state: RingFinderState, a: number, b: number) {\n // only \"monotonous\" rings\n if (b < a) return\n\n const { pred, color, left, right } = state\n const nc = ++state.currentColor\n\n let current = a\n\n for (let t = 0; t < RingFinderMaxDepth; t++) {\n color[current] = nc\n current = pred[current]\n if (current < 0) break\n }\n\n let leftOffset = 0\n let rightOffset = 0\n\n let found = false\n let target = 0\n current = b\n for (let t = 0; t < RingFinderMaxDepth; t++) {\n if (color[current] === nc) {\n target = current\n found = true\n break\n }\n right[rightOffset++] = current\n current = pred[current]\n if (current < 0) break\n }\n if (!found) return\n\n current = a\n for (let t = 0; t < RingFinderMaxDepth; t++) {\n left[leftOffset++] = current\n if (target === current) break\n current = pred[current]\n if (current < 0) break\n }\n\n const rn = leftOffset + rightOffset\n const ring: number[] = new Array(rn)\n let ringOffset = 0;\n for (let t = 0; t < leftOffset; t++) {\n ring[ringOffset++] = left[t]\n }\n for (let t = rightOffset - 1; t >= 0; t--) {\n ring[ringOffset++] = right[t]\n }\n\n const ri = state.rings.length\n // set atomRing indices:\n for (let i = 0; i < rn; ++i) {\n const ai = ring[i]\n if (state.atomRings[ai]) {\n state.atomRings[ai].push(ri)\n } else {\n state.atomRings[ai] = [ri]\n }\n }\n\n state.rings.push(ring)\n}\n\nfunction findRings(state: RingFinderState, from: number) {\n const { bonds, visited, queue, pred } = state\n\n visited[from] = 1\n queue[0] = from\n\n let head = 0\n let size = 1\n\n while (head < size) {\n const top = queue[head++]\n const start = 0\n if (bonds[top] === undefined) {\n continue\n }\n const end = bonds[top].length\n\n for (let i = start; i < end; i++) {\n const other = bonds[top][i]\n\n if (visited[other] > 0) {\n if (pred[other] !== top && pred[top] !== other) {\n addRing(state, top, other)\n }\n continue\n }\n\n visited[other] = 1\n queue[size++] = other\n pred[other] = top\n }\n }\n}\n\nconst RingFinderMaxDepth = 4\n\ninterface RingFinderState {\n count: number,\n visited: Int32Array,\n queue: Int32Array,\n color: Int32Array,\n pred: Int32Array,\n\n left: Int32Array,\n right: Int32Array,\n\n currentColor: number,\n\n rings: number[][],\n atomRings: number[][],\n\n bonds: BondGraph\n}\n\nfunction RingFinderState(bonds: BondGraph, capacity: number): RingFinderState {\n const state = {\n count: capacity,\n visited: new Int32Array(capacity),\n queue: new Int32Array(capacity),\n pred: new Int32Array(capacity),\n left: new Int32Array(RingFinderMaxDepth),\n right: new Int32Array(RingFinderMaxDepth),\n color: new Int32Array(capacity),\n currentColor: 0,\n rings: [],\n atomRings: [],\n bonds\n }\n for (let i = 0; i < capacity; i++) {\n state.visited[i] = -1\n state.pred[i] = -1\n }\n return state\n}\n","/**\n * @file Residue Map\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport { ResidueBonds } from '../structure/structure-utils'\nimport ResidueType from './residue-type'\n\nfunction getHash (resname: string, atomTypeIdList: number[], hetero: boolean, chemCompType = '') {\n return (\n resname + '|' +\n atomTypeIdList.join(',') + '|' +\n (hetero ? 1 : 0) + '|' +\n chemCompType\n )\n}\n\nclass ResidueMap {\n dict: { [k: string]: number } = {}\n list: ResidueType[] = []\n\n constructor (readonly structure: Structure) {}\n\n add (resname: string, atomTypeIdList: number[], hetero: boolean, chemCompType = '', bonds?: ResidueBonds) {\n resname = resname.toUpperCase()\n const hash = getHash(resname, atomTypeIdList, hetero, chemCompType)\n let id = this.dict[ hash ]\n if (id === undefined) {\n const residueType = new ResidueType(\n this.structure, resname, atomTypeIdList, hetero, chemCompType, bonds\n )\n id = this.list.length\n this.dict[ hash ] = id\n this.list.push(residueType)\n }\n return id\n }\n\n get (id: number) {\n return this.list[ id ]\n }\n}\n\nexport default ResidueMap\n","/**\n * @file Bond Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport Structure from '../structure/structure'\nimport BondStore from '../store/bond-store'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Bond proxy\n */\nclass BondProxy {\n index: number\n\n bondStore: BondStore\n\n private _v12: Vector3\n private _v13: Vector3\n private _ap1: AtomProxy\n private _ap2: AtomProxy\n private _ap3: AtomProxy\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.bondStore = structure.bondStore\n\n this._v12 = new Vector3()\n this._v13 = new Vector3()\n this._ap1 = this.structure.getAtomProxy()\n this._ap2 = this.structure.getAtomProxy()\n this._ap3 = this.structure.getAtomProxy()\n }\n\n /**\n * @type {AtomProxy}\n */\n get atom1 () {\n return this.structure.getAtomProxy(this.atomIndex1)\n }\n\n /**\n * @type {AtomProxy}\n */\n get atom2 () {\n return this.structure.getAtomProxy(this.atomIndex2)\n }\n\n /**\n * @type {Integer}\n */\n get atomIndex1 () {\n return this.bondStore.atomIndex1[ this.index ]\n }\n set atomIndex1 (value) {\n this.bondStore.atomIndex1[ this.index ] = value\n }\n\n /**\n * @type {Integer}\n */\n get atomIndex2 () {\n return this.bondStore.atomIndex2[ this.index ]\n }\n set atomIndex2 (value) {\n this.bondStore.atomIndex2[ this.index ] = value\n }\n\n /**\n * @type {Integer}\n */\n get bondOrder () {\n return this.bondStore.bondOrder[ this.index ]\n }\n set bondOrder (value) {\n this.bondStore.bondOrder[ this.index ] = value\n }\n\n getOtherAtomIndex (atomIndex: number) {\n return atomIndex === this.atomIndex1 ? this.atomIndex2 : this.atomIndex1\n }\n\n getOtherAtom (atom: AtomProxy) {\n return this.structure.getAtomProxy(this.getOtherAtomIndex(atom.index))\n }\n\n /**\n * Get reference atom index for the bond\n * @return {Integer|undefined} atom index, or `undefined` if unavailable\n */\n getReferenceAtomIndex () {\n const ap1 = this._ap1\n const ap2 = this._ap2\n ap1.index = this.atomIndex1\n ap2.index = this.atomIndex2\n if (ap1.residueIndex !== ap2.residueIndex) {\n return undefined // Bond between residues, for now ignore (could detect)\n }\n const typeAtomIndex1 = ap1.index - ap1.residueAtomOffset\n const typeAtomIndex2 = ap2.index - ap2.residueAtomOffset\n const residueType = ap1.residueType\n const ix = residueType.getBondReferenceAtomIndex(typeAtomIndex1, typeAtomIndex2)\n if (ix !== undefined) {\n return ix + ap1.residueAtomOffset\n } else {\n console.warn('No reference atom found', ap1.index, ap2.index)\n }\n }\n\n /**\n * calculate shift direction for displaying double/triple bonds\n * @param {Vector3} [v] pre-allocated output vector\n * @return {Vector3} the shift direction vector\n */\n calculateShiftDir (v = new Vector3()) {\n const ap1 = this._ap1\n const ap2 = this._ap2\n const ap3 = this._ap3\n const v12 = this._v12\n const v13 = this._v13\n\n ap1.index = this.atomIndex1\n ap2.index = this.atomIndex2\n const ai3 = this.getReferenceAtomIndex()\n\n v12.subVectors(ap1 as any, ap2 as any).normalize() // TODO\n if (ai3 !== undefined) {\n ap3.index = ai3\n v13.subVectors(ap1 as any, ap3 as any) // TODO\n } else {\n v13.copy(ap1 as any) // no reference point, use origin // TODO\n }\n v13.normalize()\n\n // make sure v13 and v12 are not colinear\n let dp = v12.dot(v13)\n if (1 - Math.abs(dp) < 1e-5) {\n v13.set(1, 0, 0)\n dp = v12.dot(v13)\n if (1 - Math.abs(dp) < 1e-5) {\n v13.set(0, 1, 0)\n dp = v12.dot(v13)\n }\n }\n\n return v.copy(v13.sub(v12.multiplyScalar(dp))).normalize()\n }\n\n qualifiedName () {\n return this.atomIndex1 + '=' + this.atomIndex2\n }\n\n /**\n * Clone object\n * @return {BondProxy} cloned bond\n */\n clone () {\n return new BondProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n atomIndex1: this.atomIndex1,\n atomIndex2: this.atomIndex2,\n bondOrder: this.bondOrder\n }\n }\n}\n\nexport default BondProxy\n","/**\n * @file Residue Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { NumberArray } from '../types'\nimport { defaults } from '../utils'\nimport {\n SecStrucHelix, SecStrucSheet, SecStrucTurn,\n ProteinType, RnaType, DnaType, WaterType, IonType, SaccharideType,\n CgProteinBackboneType, CgRnaBackboneType, CgDnaBackboneType,\n AA1\n} from '../structure/structure-constants'\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\n\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\nimport AtomStore from '../store/atom-store'\n\nimport AtomMap from '../store/atom-map'\nimport ResidueMap from '../store/residue-map'\n\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueType, { RingData } from '../store/residue-type';\nimport { ResidueBonds } from '../structure/structure-utils';\nimport AtomType from '../store/atom-type';\nimport ChainProxy from './chain-proxy';\nimport Entity from '../structure/entity';\n\n/**\n * Residue proxy\n */\nclass ResidueProxy {\n index: number\n\n chainStore: ChainStore\n residueStore: ResidueStore\n atomStore: AtomStore\n\n residueMap: ResidueMap\n atomMap: AtomMap\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n this.atomStore = structure.atomStore\n this.residueMap = structure.residueMap\n this.atomMap = structure.atomMap\n }\n\n /**\n * Entity\n * @type {Entity}\n */\n get entity (): Entity {\n return this.structure.entityList[ this.entityIndex ]\n }\n get entityIndex () {\n return this.chainStore.entityIndex[ this.chainIndex ]\n }\n /**\n * Chain\n * @type {ChainProxy}\n */\n get chain (): ChainProxy {\n return this.structure.getChainProxy(this.chainIndex)\n }\n\n get chainIndex () {\n return this.residueStore.chainIndex[ this.index ]\n }\n set chainIndex (value) {\n this.residueStore.chainIndex[ this.index ] = value\n }\n\n get atomOffset () {\n return this.residueStore.atomOffset[ this.index ]\n }\n set atomOffset (value) {\n this.residueStore.atomOffset[ this.index ] = value\n }\n\n /**\n * Atom count\n * @type {Integer}\n */\n get atomCount () {\n return this.residueStore.atomCount[ this.index ]\n }\n set atomCount (value) {\n this.residueStore.atomCount[ this.index ] = value\n }\n\n get atomEnd () {\n return this.atomOffset + this.atomCount - 1\n }\n\n //\n\n get modelIndex () {\n return this.chainStore.modelIndex[ this.chainIndex ]\n }\n /**\n * Chain name\n * @type {String}\n */\n get chainname () {\n return this.chainStore.getChainname(this.chainIndex)\n }\n /**\n * Chain id\n * @type {String}\n */\n get chainid () {\n return this.chainStore.getChainid(this.chainIndex)\n }\n\n //\n\n /**\n * Residue number/label\n * @type {Integer}\n */\n get resno () {\n return this.residueStore.resno[ this.index ]\n }\n set resno (value) {\n this.residueStore.resno[ this.index ] = value\n }\n\n /**\n * Secondary structure code\n * @type {String}\n */\n get sstruc () {\n return this.residueStore.getSstruc(this.index)\n }\n set sstruc (value) {\n this.residueStore.setSstruc(this.index, value)\n }\n\n /**\n * Insertion code\n * @type {String}\n */\n get inscode () {\n return this.residueStore.getInscode(this.index)\n }\n set inscode (value) {\n this.residueStore.setInscode(this.index, value)\n }\n\n //\n\n get residueType (): ResidueType {\n return this.residueMap.get(this.residueStore.residueTypeId[ this.index ])\n }\n\n /**\n * Residue name\n * @type {String}\n */\n get resname () {\n return this.residueType.resname\n }\n /**\n * Hetero flag\n * @type {Boolean}\n */\n get hetero () {\n return this.residueType.hetero\n }\n get moleculeType () {\n return this.residueType.moleculeType\n }\n get backboneType () {\n return this.residueType.backboneType\n }\n get backboneStartType () {\n return this.residueType.backboneStartType\n }\n get backboneEndType () {\n return this.residueType.backboneEndType\n }\n get traceAtomIndex () {\n return this.residueType.traceAtomIndex + this.atomOffset\n }\n get direction1AtomIndex () {\n return this.residueType.direction1AtomIndex + this.atomOffset\n }\n get direction2AtomIndex () {\n return this.residueType.direction2AtomIndex + this.atomOffset\n }\n get backboneStartAtomIndex () {\n return this.residueType.backboneStartAtomIndex + this.atomOffset\n }\n get backboneEndAtomIndex () {\n return this.residueType.backboneEndAtomIndex + this.atomOffset\n }\n get rungEndAtomIndex () {\n return this.residueType.rungEndAtomIndex + this.atomOffset\n }\n\n //\n\n get x () {\n let x = 0\n for (let i = this.atomOffset; i <= this.atomEnd; ++i) {\n x += this.atomStore.x[ i ]\n }\n return x / this.atomCount\n }\n\n get y () {\n let y = 0\n for (let i = this.atomOffset; i <= this.atomEnd; ++i) {\n y += this.atomStore.y[ i ]\n }\n return y / this.atomCount\n }\n\n get z () {\n let z = 0\n for (let i = this.atomOffset; i <= this.atomEnd; ++i) {\n z += this.atomStore.z[ i ]\n }\n return z / this.atomCount\n }\n\n //\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (ap: AtomProxy) => void, selection?: Selection) {\n const count = this.atomCount\n const offset = this.atomOffset\n const ap = this.structure._ap\n const end = offset + count\n\n if (selection && selection.atomOnlyTest) {\n const atomOnlyTest = selection.atomOnlyTest\n for (let i = offset; i < end; ++i) {\n ap.index = i\n if (atomOnlyTest(ap)) callback(ap)\n }\n } else {\n for (let i = offset; i < end; ++i) {\n ap.index = i\n callback(ap)\n }\n }\n }\n\n //\n\n /**\n * Write residue center position to array\n * @param {Array|TypedArray} [array] - target array\n * @param {Integer} [offset] - the offset\n * @return {Array|TypedArray} target array\n */\n positionToArray (array: NumberArray = [], offset = 0) {\n array[ offset + 0 ] = this.x\n array[ offset + 1 ] = this.y\n array[ offset + 2 ] = this.z\n\n return array\n }\n\n //\n\n /**\n * If residue is from a protein\n * @return {Boolean} flag\n */\n isProtein () {\n return this.residueType.moleculeType === ProteinType\n }\n\n /**\n * If residue is nucleic\n * @return {Boolean} flag\n */\n isNucleic () {\n const moleculeType = this.residueType.moleculeType\n return moleculeType === RnaType || moleculeType === DnaType\n }\n\n /**\n * If residue is rna\n * @return {Boolean} flag\n */\n isRna () {\n return this.residueType.moleculeType === RnaType\n }\n\n /**\n * If residue is dna\n * @return {Boolean} flag\n */\n isDna () {\n return this.residueType.moleculeType === DnaType\n }\n\n /**\n * If residue is coarse-grain\n * @return {Boolean} flag\n */\n isCg () {\n const backboneType = this.residueType.backboneType\n return (\n backboneType === CgProteinBackboneType ||\n backboneType === CgRnaBackboneType ||\n backboneType === CgDnaBackboneType\n )\n }\n\n /**\n * If residue is from a polymer\n * @return {Boolean} flag\n */\n isPolymer () {\n if (this.structure.entityList.length > 0) {\n return this.entity.isPolymer()\n } else {\n const moleculeType = this.residueType.moleculeType\n return (\n moleculeType === ProteinType ||\n moleculeType === RnaType ||\n moleculeType === DnaType\n )\n }\n }\n\n /**\n * If residue is hetero\n * @return {Boolean} flag\n */\n isHetero () {\n return this.residueType.hetero === 1\n }\n\n /**\n * If residue is a water molecule\n * @return {Boolean} flag\n */\n isWater () {\n return this.residueType.moleculeType === WaterType\n }\n\n /**\n * If residue is an ion\n * @return {Boolean} flag\n */\n isIon () {\n return this.residueType.moleculeType === IonType\n }\n\n /**\n * If residue is a saccharide\n * @return {Boolean} flag\n */\n isSaccharide () {\n return this.residueType.moleculeType === SaccharideType\n }\n\n isStandardAminoacid () {\n return this.residueType.isStandardAminoacid()\n }\n\n isStandardBase () {\n return this.residueType.isStandardBase()\n }\n\n /**\n * If residue is part of a helix\n * @return {Boolean} flag\n */\n isHelix () {\n return SecStrucHelix.includes(this.sstruc)\n }\n\n /**\n * If residue is part of a sheet\n * @return {Boolean} flag\n */\n isSheet () {\n return SecStrucSheet.includes(this.sstruc)\n }\n\n /**\n * If residue is part of a turn\n * @return {Boolean} flag\n */\n isTurn () {\n return SecStrucTurn.includes(this.sstruc) && this.isProtein()\n }\n\n getAtomType (index: number): AtomType {\n return this.atomMap.get(this.atomStore.atomTypeId[ index ])\n }\n\n getResname1 () {\n // FIXME nucleic support\n return AA1[ this.resname.toUpperCase() ] || 'X'\n }\n\n getBackboneType (position: number) {\n switch (position) {\n case -1:\n return this.residueType.backboneStartType\n case 1:\n return this.residueType.backboneEndType\n default:\n return this.residueType.backboneType\n }\n }\n\n getAtomIndexByName (atomname: string) {\n let index = this.residueType.getAtomIndexByName(atomname)\n if (index !== undefined) {\n index += this.atomOffset\n }\n return index\n }\n\n hasAtomWithName (atomname: string) {\n return this.residueType.hasAtomWithName(atomname)\n }\n\n getAtomnameList () {\n console.warn('getAtomnameList - might be expensive')\n\n const n = this.atomCount\n const offset = this.atomOffset\n const list = new Array(n)\n for (let i = 0; i < n; ++i) {\n list[ i ] = this.getAtomType(offset + i).atomname\n }\n return list\n }\n\n /**\n * If residue is connected to another\n * @param {ResidueProxy} rNext - the other residue\n * @return {Boolean} - flag\n */\n connectedTo (rNext: ResidueProxy) {\n const bbAtomEnd = this.structure.getAtomProxy(this.backboneEndAtomIndex)\n const bbAtomStart = this.structure.getAtomProxy(rNext.backboneStartAtomIndex)\n if (bbAtomEnd && bbAtomStart) {\n return bbAtomEnd.connectedTo(bbAtomStart)\n } else {\n return false\n }\n }\n\n getNextConnectedResidue () {\n const rOffset = this.chainStore.residueOffset[ this.chainIndex ]\n const rCount = this.chainStore.residueCount[ this.chainIndex ]\n const nextIndex = this.index + 1\n if (nextIndex < rOffset + rCount) {\n const rpNext = this.structure.getResidueProxy(nextIndex)\n if (this.connectedTo(rpNext)) {\n return rpNext\n }\n } else if (nextIndex === rOffset + rCount) { // cyclic\n const rpFirst = this.structure.getResidueProxy(rOffset)\n if (this.connectedTo(rpFirst)) {\n return rpFirst\n }\n }\n return undefined\n }\n\n getPreviousConnectedResidue (residueProxy?: ResidueProxy) {\n const rOffset = this.chainStore.residueOffset[ this.chainIndex ]\n const prevIndex = this.index - 1\n if (prevIndex >= rOffset) {\n const rpPrev = defaults(residueProxy, this.structure.getResidueProxy())\n rpPrev.index = prevIndex\n if (rpPrev.connectedTo(this)) {\n return rpPrev\n }\n } else if (prevIndex === rOffset - 1) { // cyclic\n const rCount = this.chainStore.residueCount[ this.chainIndex ]\n const rpLast = defaults(residueProxy, this.structure.getResidueProxy())\n rpLast.index = rOffset + rCount - 1\n if (rpLast.connectedTo(this)) {\n return rpLast\n }\n }\n return undefined\n }\n\n getBonds (): ResidueBonds {\n return this.residueType.getBonds(this)\n }\n\n getRings (): RingData|undefined {\n return this.residueType.getRings()\n }\n\n getAromaticRings () {\n return this.residueType.getAromaticRings(this)\n }\n\n qualifiedName (noResname = false) {\n let name = ''\n if (this.resname && !noResname) name += '[' + this.resname + ']'\n if (this.resno !== undefined) name += this.resno\n if (this.inscode) name += '^' + this.inscode\n if (this.chain) name += ':' + this.chainname\n name += '/' + this.modelIndex\n return name\n }\n\n /**\n * Clone object\n * @return {ResidueProxy} cloned residue\n */\n clone () {\n return new ResidueProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n index: this.index,\n chainIndex: this.chainIndex,\n atomOffset: this.atomOffset,\n atomCount: this.atomCount,\n\n resno: this.resno,\n resname: this.resname,\n sstruc: this.sstruc\n }\n }\n}\n\nexport default ResidueProxy\n","/**\n * @file Polymer\n * @author Alexander Rose \n * @private\n */\n\n// import { Log } from '../globals'\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\n\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\nimport AtomStore from '../store/atom-store'\n\nimport ResidueProxy from '../proxy/residue-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Polymer\n */\nclass Polymer {\n chainStore: ChainStore\n residueStore: ResidueStore\n atomStore: AtomStore\n\n residueCount: number\n\n isPrevConnected: boolean\n isNextConnected: boolean\n isNextNextConnected: boolean\n isCyclic: boolean\n\n private __residueProxy: ResidueProxy\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} residueIndexStart - the index of the first residue\n * @param {Integer} residueIndexEnd - the index of the last residue\n */\n constructor (readonly structure: Structure, readonly residueIndexStart: number, readonly residueIndexEnd: number) {\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n this.atomStore = structure.atomStore\n\n /**\n * @type {Integer}\n */\n this.residueCount = residueIndexEnd - residueIndexStart + 1\n\n const rpStart = this.structure.getResidueProxy(this.residueIndexStart)\n const rpEnd = this.structure.getResidueProxy(this.residueIndexEnd)\n this.isPrevConnected = rpStart.getPreviousConnectedResidue() !== undefined\n const rpNext = rpEnd.getNextConnectedResidue()\n this.isNextConnected = rpNext !== undefined\n this.isNextNextConnected = rpNext !== undefined && rpNext.getNextConnectedResidue() !== undefined\n this.isCyclic = rpEnd.connectedTo(rpStart)\n\n this.__residueProxy = this.structure.getResidueProxy()\n\n // console.log( this.qualifiedName(), this );\n }\n\n get chainIndex () {\n return this.residueStore.chainIndex[ this.residueIndexStart ]\n }\n get modelIndex () {\n return this.chainStore.modelIndex[ this.chainIndex ]\n }\n\n /**\n * @type {String}\n */\n get chainname () {\n return this.chainStore.getChainname(this.chainIndex)\n }\n\n //\n\n /**\n * If first residue is from aprotein\n * @return {Boolean} flag\n */\n isProtein () {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.isProtein()\n }\n\n /**\n * If atom is part of a coarse-grain group\n * @return {Boolean} flag\n */\n isCg () {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.isCg()\n }\n\n /**\n * If atom is part of a nucleic molecule\n * @return {Boolean} flag\n */\n isNucleic () {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.isNucleic()\n }\n\n getMoleculeType () {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.moleculeType\n }\n\n getBackboneType (position: number) {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.getBackboneType(position)\n }\n\n getAtomIndexByType (index: number, type: string) {\n // TODO pre-calculate, add to residueStore???\n\n if (this.isCyclic) {\n if (index === -1) {\n index = this.residueCount - 1\n } else if (index === this.residueCount) {\n index = 0\n }\n } else {\n if (index === -1 && !this.isPrevConnected) index += 1\n if (index === this.residueCount && !this.isNextNextConnected) index -= 1\n // if( index === this.residueCount - 1 && !this.isNextConnected ) index -= 1;\n }\n\n const rp = this.__residueProxy\n rp.index = this.residueIndexStart + index\n let aIndex\n\n switch (type) {\n case 'trace':\n aIndex = rp.traceAtomIndex\n break\n case 'direction1':\n aIndex = rp.direction1AtomIndex\n break\n case 'direction2':\n aIndex = rp.direction2AtomIndex\n break\n default:\n aIndex = rp.getAtomIndexByName(type)\n }\n\n // if (!ap){\n // console.log(this, type, rp.residueType)\n // // console.log(rp.qualifiedName(), rp.index, index, this.residueCount - 1)\n // // rp.index = this.residueIndexStart;\n // // console.log(rp.qualifiedName(), this.residueIndexStart)\n // // rp.index = this.residueIndexEnd;\n // // console.log(rp.qualifiedName(), this.residueIndexEnd)\n // }\n\n return aIndex\n }\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (ap: AtomProxy) => void, selection?: Selection) {\n this.eachResidue(function (rp) {\n rp.eachAtom(callback, selection)\n })\n }\n\n eachAtomN (n: number, callback: (...apArray: AtomProxy[]) => void, type: string) {\n const m = this.residueCount\n const array: AtomProxy[] = new Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = this.structure.getAtomProxy(this.getAtomIndexByType(i, type))\n }\n callback.apply(this, array)\n\n for (var j = n; j < m; ++j) {\n for (let i = 1; i < n; ++i) {\n array[ i - 1 ].index = array[ i ].index\n }\n array[ n - 1 ].index = this.getAtomIndexByType(j, type)! // TODO\n callback.apply(this, array)\n }\n }\n\n /**\n * Residue iterator\n * @param {function(residue: ResidueProxy)} callback - the callback\n * @return {undefined}\n */\n eachResidue (callback: (rp: ResidueProxy) => void) {\n const rp = this.structure.getResidueProxy()\n const n = this.residueCount\n const rStartIndex = this.residueIndexStart\n\n for (let i = 0; i < n; ++i) {\n rp.index = rStartIndex + i\n callback(rp)\n }\n }\n\n qualifiedName () {\n const rpStart = this.structure.getResidueProxy(this.residueIndexStart)\n const rpEnd = this.structure.getResidueProxy(this.residueIndexEnd)\n return rpStart.qualifiedName() + ' - ' + rpEnd.qualifiedName()\n }\n}\n\nexport default Polymer\n","/**\n * @file Chain Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { UnknownBackboneType } from '../structure/structure-constants'\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\n\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\n\nimport Polymer from '../proxy/polymer'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ModelProxy from './model-proxy';\nimport Entity from '../structure/entity';\n\n/**\n * Chain proxy\n */\nclass ChainProxy {\n index: number\n\n chainStore: ChainStore\n residueStore: ResidueStore\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n }\n\n /**\n * Entity\n * @type {Entity}\n */\n get entity (): Entity {\n return this.structure.entityList[ this.entityIndex ]\n }\n /**\n * Model\n * @type {ModelProxy}\n */\n get model (): ModelProxy {\n return this.structure.getModelProxy(this.modelIndex)\n }\n\n get entityIndex () {\n return this.chainStore.entityIndex[ this.index ]\n }\n set entityIndex (value) {\n this.chainStore.entityIndex[ this.index ] = value\n }\n\n get modelIndex () {\n return this.chainStore.modelIndex[ this.index ]\n }\n set modelIndex (value) {\n this.chainStore.modelIndex[ this.index ] = value\n }\n\n get residueOffset () {\n return this.chainStore.residueOffset[ this.index ]\n }\n set residueOffset (value) {\n this.chainStore.residueOffset[ this.index ] = value\n }\n\n /**\n * Residue count\n * @type {Integer}\n */\n get residueCount () {\n return this.chainStore.residueCount[ this.index ]\n }\n set residueCount (value) {\n this.chainStore.residueCount[ this.index ] = value\n }\n\n get residueEnd () {\n return this.residueOffset + this.residueCount - 1\n }\n\n get atomOffset () {\n return this.residueStore.atomOffset[ this.residueOffset ]\n }\n get atomEnd () {\n return (\n this.residueStore.atomOffset[ this.residueEnd ] +\n this.residueStore.atomCount[ this.residueEnd ] - 1\n )\n }\n /**\n * Atom count\n * @type {Integer}\n */\n get atomCount () {\n if (this.residueCount === 0) {\n return 0\n } else {\n return this.atomEnd - this.atomOffset + 1\n }\n }\n\n //\n\n /**\n * Chain name\n * @type {String}\n */\n get chainname () {\n return this.chainStore.getChainname(this.index)\n }\n set chainname (value) {\n this.chainStore.setChainname(this.index, value)\n }\n\n /**\n * Chain id\n * @type {String}\n */\n get chainid () {\n return this.chainStore.getChainid(this.index)\n }\n set chainid (value) {\n this.chainStore.setChainid(this.index, value)\n }\n\n //\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (ap: AtomProxy) => void, selection?: Selection) {\n this.eachResidue(function (rp) {\n rp.eachAtom(callback, selection)\n }, selection)\n }\n\n /**\n * Residue iterator\n * @param {function(residue: ResidueProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachResidue (callback: (rp: ResidueProxy) => void, selection?: Selection) {\n const count = this.residueCount\n const offset = this.residueOffset\n const rp = this.structure._rp\n const end = offset + count\n\n if (selection && selection.test) {\n const residueOnlyTest = selection.residueOnlyTest\n if (residueOnlyTest) {\n for (let i = offset; i < end; ++i) {\n rp.index = i\n if (residueOnlyTest(rp)) {\n callback(rp)\n }\n }\n } else {\n for (let i = offset; i < end; ++i) {\n rp.index = i\n callback(rp)\n }\n }\n } else {\n for (let i = offset; i < end; ++i) {\n rp.index = i\n callback(rp)\n }\n }\n }\n\n /**\n * Multi-residue iterator\n * @param {Integer} n - window size\n * @param {function(residueList: ResidueProxy[])} callback - the callback\n * @return {undefined}\n */\n eachResidueN (n: number, callback: (...rpArray: ResidueProxy[]) => void) {\n const count = this.residueCount\n const offset = this.residueOffset\n const end = offset + count\n if (count < n) return\n const array: ResidueProxy[] = new Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = this.structure.getResidueProxy(offset + i)\n }\n callback.apply(this, array)\n\n for (let j = offset + n; j < end; ++j) {\n for (let i = 0; i < n; ++i) {\n array[ i ].index += 1\n }\n callback.apply(this, array)\n }\n }\n\n /**\n * Polymer iterator\n * @param {function(polymer: Polymer)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachPolymer (callback: (p: Polymer) => void, selection?: Selection) {\n let rStartIndex = 0\n let rNextIndex = 0\n const test = selection ? selection.residueOnlyTest : undefined\n const structure = this.model.structure\n\n const count = this.residueCount\n const offset = this.residueOffset\n const end = offset + count\n\n const rp1 = this.structure.getResidueProxy()\n const rp2 = this.structure.getResidueProxy(offset)\n\n const ap1 = this.structure.getAtomProxy()\n const ap2 = this.structure.getAtomProxy()\n\n let first = true\n\n for (let i = offset + 1; i < end; ++i) {\n rp1.index = rp2.index\n rp2.index = i\n\n const bbType1 = first ? rp1.backboneEndType : rp1.backboneType\n const bbType2 = rp2.backboneType\n\n if (first) {\n rStartIndex = rp1.index\n first = false\n }\n rNextIndex = rp2.index\n\n if (bbType1 !== UnknownBackboneType && bbType1 === bbType2) {\n ap1.index = rp1.backboneEndAtomIndex\n ap2.index = rp2.backboneStartAtomIndex\n } else {\n if (bbType1 !== UnknownBackboneType) {\n if (rp1.index - rStartIndex > 1) {\n // console.log(\"FOO1\",rStartIndex, rp1.index)\n callback(new Polymer(structure, rStartIndex, rp1.index))\n }\n }\n rStartIndex = rNextIndex\n\n continue\n }\n\n if (!ap1 || !ap2 || !ap1.connectedTo(ap2) ||\n (test && (!test(rp1) || !test(rp2)))\n ) {\n if (rp1.index - rStartIndex > 1) {\n // console.log(\"FOO2\",rStartIndex, rp1.index)\n callback(new Polymer(structure, rStartIndex, rp1.index))\n }\n rStartIndex = rNextIndex\n }\n }\n\n if (rNextIndex - rStartIndex > 1) {\n if (this.structure.getResidueProxy(rStartIndex).backboneEndType) {\n // console.log(\"FOO3\",rStartIndex, rNextIndex)\n callback(new Polymer(structure, rStartIndex, rNextIndex))\n }\n }\n }\n\n //\n\n qualifiedName () {\n var name = ':' + this.chainname + '/' + this.modelIndex\n return name\n }\n\n /**\n * Clone object\n * @return {ChainProxy} cloned chain\n */\n clone () {\n return new ChainProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n index: this.index,\n residueOffset: this.residueOffset,\n residueCount: this.residueCount,\n\n chainname: this.chainname\n }\n }\n}\n\nexport default ChainProxy\n","/**\n * @file Model Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\n\nimport ModelStore from '../store/model-store'\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\n\nimport ChainProxy from '../proxy/chain-proxy'\nimport Polymer from '../proxy/polymer'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Model proxy\n */\nclass ModelProxy {\n index: number\n\n modelStore: ModelStore\n chainStore: ChainStore\n residueStore: ResidueStore\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.modelStore = structure.modelStore\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n }\n\n get chainOffset () {\n return this.modelStore.chainOffset[ this.index ]\n }\n set chainOffset (value) {\n this.modelStore.chainOffset[ this.index ] = value\n }\n\n get chainCount () {\n return this.modelStore.chainCount[ this.index ]\n }\n set chainCount (value) {\n this.modelStore.chainCount[ this.index ] = value\n }\n\n get residueOffset () {\n return this.chainStore.residueOffset[ this.chainOffset ]\n }\n get atomOffset () {\n return this.residueStore.atomOffset[ this.residueOffset ]\n }\n\n get chainEnd () {\n return this.chainOffset + this.chainCount - 1\n }\n get residueEnd () {\n return (\n this.chainStore.residueOffset[ this.chainEnd ] +\n this.chainStore.residueCount[ this.chainEnd ] - 1\n )\n }\n get atomEnd () {\n return (\n this.residueStore.atomOffset[ this.residueEnd ] +\n this.residueStore.atomCount[ this.residueEnd ] - 1\n )\n }\n\n /**\n * Residue count\n * @type {Integer}\n */\n get residueCount () {\n if (this.chainCount === 0) {\n return 0\n } else {\n return this.residueEnd - this.residueOffset + 1\n }\n }\n\n /**\n * Atom count\n * @type {Integer}\n */\n get atomCount () {\n if (this.residueCount === 0) {\n return 0\n } else {\n return this.atomEnd - this.atomOffset + 1\n }\n }\n\n //\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (ap: AtomProxy) => void, selection?: Selection) {\n this.eachChain(function (cp) {\n cp.eachAtom(callback, selection)\n }, selection)\n }\n\n /**\n * Residue iterator\n * @param {function(residue: ResidueProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachResidue (callback: (rp: ResidueProxy) => void, selection?: Selection) {\n this.eachChain(function (cp) {\n cp.eachResidue(callback, selection)\n }, selection)\n }\n\n /**\n * Polymer iterator\n * @param {function(polymer: Polymer)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachPolymer (callback: (p: Polymer) => void, selection?: Selection) {\n if (selection && selection.chainOnlyTest) {\n const chainOnlyTest = selection.chainOnlyTest\n\n this.eachChain(function (cp) {\n if (chainOnlyTest(cp)) {\n cp.eachPolymer(callback, selection)\n }\n })\n } else {\n this.eachChain(function (cp) {\n cp.eachPolymer(callback, selection)\n })\n }\n }\n\n /**\n * Chain iterator\n * @param {function(chain: ChainProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachChain (callback: (cp: ChainProxy) => void, selection?: Selection) {\n const count = this.chainCount\n const offset = this.chainOffset\n const cp = this.structure._cp\n const end = offset + count\n\n if (selection && selection.test) {\n const chainOnlyTest = selection.chainOnlyTest\n if (chainOnlyTest) {\n for (let i = offset; i < end; ++i) {\n cp.index = i\n if (chainOnlyTest(cp)) {\n callback(cp)\n }\n }\n } else {\n for (let i = offset; i < end; ++i) {\n cp.index = i\n callback(cp)\n }\n }\n } else {\n for (let i = offset; i < end; ++i) {\n cp.index = i\n callback(cp)\n }\n }\n }\n\n //\n\n qualifiedName () {\n const name = '/' + this.index\n return name\n }\n\n /**\n * Clone object\n * @return {ModelProxy} cloned model\n */\n clone () {\n return new ModelProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n index: this.index,\n chainOffset: this.chainOffset,\n chainCount: this.chainCount\n }\n }\n}\n\nexport default ModelProxy\n","/**\n * @file Structure\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3 } from 'three'\nimport { Signal } from 'signals'\n\nimport { Debug, Log, ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { AtomPicker, BondPicker } from '../utils/picker'\nimport { copyWithin, arrayMin, arrayMax } from '../math/array-utils'\nimport BitArray from '../utils/bitarray'\nimport RadiusFactory, { RadiusParams } from '../utils/radius-factory'\nimport { Matrix } from '../math/matrix-utils'\nimport PrincipalAxes from '../math/principal-axes'\nimport SpatialHash from '../geometry/spatial-hash'\nimport FilteredVolume from '../surface/filtered-volume'\nimport StructureView from './structure-view'\nimport { AtomDataParams, AtomData, BondDataParams, BondData } from './structure-data'\nimport { Data, createData } from './data'\n\nimport Entity from './entity'\nimport Unitcell from '../symmetry/unitcell'\nimport Validation from './validation'\nimport Selection from '../selection/selection'\nimport Assembly from '../symmetry/assembly'\nimport Volume from '../surface/volume'\nimport Polymer from '../proxy/polymer'\n\nimport BondHash from '../store/bond-hash'\nimport BondStore from '../store/bond-store'\nimport AtomStore from '../store/atom-store'\nimport ResidueStore from '../store/residue-store'\nimport ChainStore from '../store/chain-store'\nimport ModelStore from '../store/model-store'\n\nimport AtomMap from '../store/atom-map'\nimport ResidueMap from '../store/residue-map'\n\nimport BondProxy from '../proxy/bond-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\ninterface Structure {\n signals: StructureSignals\n\n name: string\n path: string\n title: string\n id: string\n\n data: Data\n\n atomCount: number\n bondCount: number\n\n header: StructureHeader\n extraData: StructureExtraData\n\n atomSetCache: { [k: string]: BitArray }\n atomSetDict: { [k: string]: BitArray }\n biomolDict: { [k: string]: Assembly }\n\n entityList: Entity[]\n unitcell?: Unitcell\n\n frames: Float32Array[]\n boxes: Float32Array[]\n\n validation?: Validation\n\n bondStore: BondStore\n backboneBondStore: BondStore\n rungBondStore: BondStore\n atomStore: AtomStore\n residueStore: ResidueStore\n chainStore: ChainStore\n modelStore: ModelStore\n\n atomMap: AtomMap\n residueMap: ResidueMap\n\n bondHash?: BondHash\n spatialHash?: SpatialHash\n\n atomSet?: BitArray\n bondSet?: BitArray\n\n center: Vector3\n boundingBox: Box3\n\n trajectory?: {\n name: string\n frame: number\n }\n\n getView(selection: Selection): StructureView\n\n _hasCoords?: boolean\n\n _bp: BondProxy\n _ap: AtomProxy\n _rp: ResidueProxy\n _cp: ChainProxy\n}\n\nexport type StructureHeader = {\n releaseDate?: string\n depositionDate?: string\n resolution?: number\n rFree?: number\n rWork?: number\n experimentalMethods?: string[]\n}\n\nexport type StructureExtraData = {\n cif?: object\n sdf?: object[]\n}\n\nexport type StructureSignals = {\n refreshed: Signal\n}\n\n/**\n * Structure\n */\nclass Structure implements Structure{\n signals: StructureSignals = {\n refreshed: new Signal()\n }\n\n /**\n * @param {String} name - structure name\n * @param {String} path - source path\n */\n constructor (name = '', path = '') {\n this.init(name, path)\n }\n\n init (name: string, path: string) {\n this.name = name\n this.path = path\n this.title = ''\n this.id = ''\n\n this.data = createData(this)\n\n this.header = {}\n this.extraData = {}\n\n this.atomSetCache = {}\n this.atomSetDict = {}\n this.biomolDict = {}\n\n this.entityList = []\n this.unitcell = undefined\n\n this.frames = []\n this.boxes = []\n\n this.validation = undefined\n\n this.bondStore = new BondStore(0)\n this.backboneBondStore = new BondStore(0)\n this.rungBondStore = new BondStore(0)\n this.atomStore = new AtomStore(0)\n this.residueStore = new ResidueStore(0)\n this.chainStore = new ChainStore(0)\n this.modelStore = new ModelStore(0)\n\n this.atomMap = new AtomMap(this)\n this.residueMap = new ResidueMap(this)\n\n this.bondHash = undefined\n this.spatialHash = undefined\n\n this.atomSet = undefined\n this.bondSet = undefined\n\n this.center = new Vector3()\n this.boundingBox = new Box3()\n\n this._bp = this.getBondProxy()\n this._ap = this.getAtomProxy()\n this._rp = this.getResidueProxy()\n this._cp = this.getChainProxy()\n }\n\n get type () { return 'Structure' }\n\n finalizeAtoms () {\n this.atomSet = this.getAtomSet()\n this.atomCount = this.atomStore.count\n this.boundingBox = this.getBoundingBox(undefined, this.boundingBox)\n this.center = this.boundingBox.getCenter(new Vector3())\n this.spatialHash = new SpatialHash(this.atomStore, this.boundingBox)\n }\n\n finalizeBonds () {\n this.bondSet = this.getBondSet()\n this.bondCount = this.bondStore.count\n this.bondHash = new BondHash(this.bondStore, this.atomStore.count)\n\n this.atomSetCache = {}\n if (!this.atomSetDict.rung) {\n this.atomSetDict.rung = this.getAtomSet(false)\n }\n\n for (let name in this.atomSetDict) {\n this.atomSetCache[ '__' + name ] = this.atomSetDict[ name ].clone()\n }\n }\n\n //\n\n getBondProxy (index?: number) {\n return new BondProxy(this, index)\n }\n\n getAtomProxy (index?: number) {\n return new AtomProxy(this, index)\n }\n\n getResidueProxy (index?: number) {\n return new ResidueProxy(this, index)\n }\n\n getChainProxy (index?: number) {\n return new ChainProxy(this, index)\n }\n\n getModelProxy (index?: number) {\n return new ModelProxy(this, index)\n }\n\n //\n\n getBondSet (/* selection */) {\n // TODO implement selection parameter\n\n const n = this.bondStore.count\n const bondSet = new BitArray(n)\n const atomSet = this.atomSet\n\n if (atomSet) {\n if (atomSet.isAllSet()) {\n bondSet.setAll()\n } else if (atomSet.isAllClear()) {\n bondSet.clearAll()\n } else {\n const bp = this.getBondProxy()\n\n for (let i = 0; i < n; ++i) {\n bp.index = i\n if (atomSet.isSet(bp.atomIndex1, bp.atomIndex2)) {\n bondSet.set(bp.index)\n }\n }\n }\n } else {\n bondSet.setAll()\n }\n\n return bondSet\n }\n\n getBackboneBondSet (/* selection */) {\n // TODO implement selection parameter\n\n const n = this.backboneBondStore.count\n const backboneBondSet = new BitArray(n)\n const backboneAtomSet = this.atomSetCache.__backbone\n\n if (backboneAtomSet) {\n const bp = this.getBondProxy()\n bp.bondStore = this.backboneBondStore\n\n for (let i = 0; i < n; ++i) {\n bp.index = i\n if (backboneAtomSet.isSet(bp.atomIndex1, bp.atomIndex2)) {\n backboneBondSet.set(bp.index)\n }\n }\n } else {\n backboneBondSet.setAll()\n }\n\n return backboneBondSet\n }\n\n getRungBondSet (/* selection */) {\n // TODO implement selection parameter\n\n const n = this.rungBondStore.count\n const rungBondSet = new BitArray(n)\n const rungAtomSet = this.atomSetCache.__rung\n\n if (rungAtomSet) {\n const bp = this.getBondProxy()\n bp.bondStore = this.rungBondStore\n\n for (let i = 0; i < n; ++i) {\n bp.index = i\n if (rungAtomSet.isSet(bp.atomIndex1, bp.atomIndex2)) {\n rungBondSet.set(bp.index)\n }\n }\n } else {\n rungBondSet.setAll()\n }\n\n return rungBondSet\n }\n\n /**\n * Get a set of atoms\n * @param {Boolean|Selection|BitArray} selection - object defining how to\n * initialize the atom set.\n * Boolean: init with value;\n * Selection: init with selection;\n * BitArray: return bit array\n * @return {BitArray} set of atoms\n */\n getAtomSet (selection?: boolean|Selection|BitArray) {\n const n = this.atomStore.count\n\n if (selection === undefined) {\n return new BitArray(n, true)\n } else if (selection instanceof BitArray) {\n return selection\n } else if (selection === true) {\n return new BitArray(n, true)\n } else if (selection && selection.test) {\n const seleString = selection.string\n if (seleString in this.atomSetCache) {\n return this.atomSetCache[ seleString ]\n } else {\n if (seleString === '') {\n return new BitArray(n, true)\n } else {\n const atomSet = new BitArray(n)\n this.eachAtom(function (ap: AtomProxy) {\n atomSet.set(ap.index)\n }, selection)\n this.atomSetCache[ seleString ] = atomSet\n return atomSet\n }\n }\n } else if (selection === false) {\n return new BitArray(n)\n }\n\n return new BitArray(n, true)\n }\n\n /**\n * Get set of atoms around a set of atoms from a selection\n * @param {Selection} selection - the selection object\n * @param {Number} radius - radius to select within\n * @return {BitArray} set of atoms\n */\n getAtomSetWithinSelection (selection: boolean|Selection|BitArray, radius: number) {\n const spatialHash = this.spatialHash\n const atomSet = this.getAtomSet(false)\n const ap = this.getAtomProxy()\n\n if (!spatialHash) return atomSet\n\n this.getAtomSet(selection).forEach(function (idx: number) {\n ap.index = idx\n spatialHash.within(ap.x, ap.y, ap.z, radius).forEach(function (idx2: number) {\n atomSet.set(idx2)\n })\n })\n\n return atomSet\n }\n\n /**\n * Get set of atoms around a point\n * @param {Vector3|AtomProxy} point - the point\n * @param {Number} radius - radius to select within\n * @return {BitArray} set of atoms\n */\n getAtomSetWithinPoint (point: Vector3|AtomProxy, radius: number) {\n const p = point\n const atomSet = this.getAtomSet(false)\n\n if (!this.spatialHash) return atomSet\n\n this.spatialHash.within(p.x, p.y, p.z, radius).forEach(function (idx: number) {\n atomSet.set(idx)\n })\n\n return atomSet\n }\n\n /**\n * Get set of atoms within a volume\n * @param {Volume} volume - the volume\n * @param {Number} radius - radius to select within\n * @param {[type]} minValue - minimum value to be considered as within the volume\n * @param {[type]} maxValue - maximum value to be considered as within the volume\n * @param {[type]} outside - use only values falling outside of the min/max values\n * @return {BitArray} set of atoms\n */\n getAtomSetWithinVolume (volume: Volume, radius: number, minValue: number, maxValue: number, outside: boolean) {\n const fv = new FilteredVolume(volume, minValue, maxValue, outside) as any // TODO\n\n const dp = fv.getDataPosition()\n const n = dp.length\n const r = fv.matrix.getMaxScaleOnAxis()\n const atomSet = this.getAtomSet(false)\n\n if (!this.spatialHash) return atomSet\n\n for (let i = 0; i < n; i += 3) {\n this.spatialHash.within(dp[ i ], dp[ i + 1 ], dp[ i + 2 ], r).forEach(function (idx) {\n atomSet.set(idx)\n })\n }\n\n return atomSet\n }\n\n /**\n * Get set of all atoms within the groups of a selection\n * @param {Selection} selection - the selection object\n * @return {BitArray} set of atoms\n */\n getAtomSetWithinGroup (selection: boolean|Selection|BitArray) {\n const atomResidueIndex = this.atomStore.residueIndex\n const atomSet = this.getAtomSet(false)\n const rp = this.getResidueProxy()\n\n this.getAtomSet(selection).forEach(function (idx) {\n rp.index = atomResidueIndex[ idx ]\n for (let idx2 = rp.atomOffset; idx2 <= rp.atomEnd; ++idx2) {\n atomSet.set(idx2)\n }\n })\n\n return atomSet\n }\n\n //\n\n getSelection (): undefined|Selection {\n return\n }\n\n getStructure (): Structure|StructureView {\n return this\n }\n\n /**\n * Entity iterator\n * @param {function(entity: Entity)} callback - the callback\n * @param {EntityType} type - entity type\n * @return {undefined}\n */\n eachEntity (callback: (entity: Entity) => void, type: number) {\n this.entityList.forEach(function (entity) {\n if (type === undefined || entity.getEntityType() === type) {\n callback(entity)\n }\n })\n }\n\n /**\n * Bond iterator\n * @param {function(bond: BondProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachBond (callback: (entity: BondProxy) => void, selection?: Selection) {\n const bp = this.getBondProxy()\n let bondSet\n\n if (selection && selection.test) {\n bondSet = this.getBondSet(/*selection*/)\n if (this.bondSet) {\n bondSet.intersection(this.bondSet)\n }\n }\n\n if (bondSet) {\n bondSet.forEach(function (index) {\n bp.index = index\n callback(bp)\n })\n } else {\n const n = this.bondStore.count\n for (let i = 0; i < n; ++i) {\n bp.index = i\n callback(bp)\n }\n }\n }\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (entity: AtomProxy) => void, selection?: Selection) {\n if (selection && selection.test) {\n this.eachModel(function (mp) {\n mp.eachAtom(callback, selection)\n }, selection)\n } else {\n const an = this.atomStore.count\n const ap = this.getAtomProxy()\n for (let i = 0; i < an; ++i) {\n ap.index = i\n callback(ap)\n }\n }\n }\n\n /**\n * Residue iterator\n * @param {function(residue: ResidueProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachResidue (callback: (entity: ResidueProxy) => void, selection?: Selection) {\n if (selection && selection.test) {\n const mn = this.modelStore.count\n const mp = this.getModelProxy()\n const modelOnlyTest = selection.modelOnlyTest\n if (modelOnlyTest) {\n for (let i = 0; i < mn; ++i) {\n mp.index = i\n if (modelOnlyTest(mp)) {\n mp.eachResidue(callback, selection)\n }\n }\n } else {\n for (let i = 0; i < mn; ++i) {\n mp.index = i\n mp.eachResidue(callback, selection)\n }\n }\n } else {\n const rn = this.residueStore.count\n const rp = this.getResidueProxy()\n for (let i = 0; i < rn; ++i) {\n rp.index = i\n callback(rp)\n }\n }\n }\n\n /**\n * Multi-residue iterator\n * @param {Integer} n - window size\n * @param {function(residueList: ResidueProxy[])} callback - the callback\n * @return {undefined}\n */\n eachResidueN (n: number, callback: (...entityArray: ResidueProxy[]) => void) {\n const rn = this.residueStore.count\n if (rn < n) return\n const array: ResidueProxy[] = new Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = this.getResidueProxy(i)\n }\n callback.apply(this, array)\n\n for (let j = n; j < rn; ++j) {\n for (let i = 0; i < n; ++i) {\n array[ i ].index += 1\n }\n callback.apply(this, array)\n }\n }\n\n /**\n * Polymer iterator\n * @param {function(polymer: Polymer)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachPolymer (callback: (entity: Polymer) => void, selection?: Selection) {\n if (selection && selection.modelOnlyTest) {\n const modelOnlyTest = selection.modelOnlyTest\n\n this.eachModel(function (mp) {\n if (modelOnlyTest(mp)) {\n mp.eachPolymer(callback, selection)\n }\n })\n } else {\n this.eachModel(function (mp) {\n mp.eachPolymer(callback, selection)\n })\n }\n }\n\n /**\n * Chain iterator\n * @param {function(chain: ChainProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachChain (callback: (entity: ChainProxy) => void, selection?: Selection) {\n if (selection && selection.test) {\n this.eachModel(function (mp) {\n mp.eachChain(callback, selection)\n })\n } else {\n const cn = this.chainStore.count\n const cp = this.getChainProxy()\n for (let i = 0; i < cn; ++i) {\n cp.index = i\n callback(cp)\n }\n }\n }\n\n /**\n * Model iterator\n * @param {function(model: ModelProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachModel (callback: (entity: ModelProxy) => void, selection?: Selection) {\n const n = this.modelStore.count\n const mp = this.getModelProxy()\n\n if (selection && selection.test) {\n const modelOnlyTest = selection.modelOnlyTest\n if (modelOnlyTest) {\n for (let i = 0; i < n; ++i) {\n mp.index = i\n if (modelOnlyTest(mp)) {\n callback(mp)\n }\n }\n } else {\n for (let i = 0; i < n; ++i) {\n mp.index = i\n callback(mp)\n }\n }\n } else {\n for (let i = 0; i < n; ++i) {\n mp.index = i\n callback(mp)\n }\n }\n }\n\n //\n\n getAtomData (params: AtomDataParams) {\n const p = Object.assign({}, params)\n if (p.colorParams) p.colorParams.structure = this.getStructure()\n\n const what = p.what\n const atomSet = defaults(p.atomSet, this.atomSet)\n\n let radiusFactory: any // TODO\n let colormaker: any // TODO\n\n const atomData: AtomData = {}\n const ap = this.getAtomProxy()\n const atomCount = atomSet.getSize()\n\n if (!what || what.position) {\n atomData.position = new Float32Array(atomCount * 3)\n }\n if ((!what || what.color) && p.colorParams) {\n atomData.color = new Float32Array(atomCount * 3)\n colormaker = ColormakerRegistry.getScheme(p.colorParams)\n }\n if (!what || what.picking) {\n atomData.picking = new AtomPicker(new Float32Array(atomCount), this.getStructure())\n }\n if (!what || what.radius) {\n atomData.radius = new Float32Array(atomCount)\n radiusFactory = new RadiusFactory(p.radiusParams as RadiusParams)\n }\n if (!what || what.index) {\n atomData.index = new Uint32Array(atomCount)\n }\n\n const {position, color, picking, radius, index} = atomData\n\n atomSet.forEach((idx: number, i: number) => {\n const i3 = i * 3\n ap.index = idx\n if (position) {\n ap.positionToArray(position, i3)\n }\n if (color) {\n colormaker.atomColorToArray(ap, color, i3)\n }\n if (picking) {\n picking.array![ i ] = idx\n }\n if (radius) {\n radius[ i ] = radiusFactory.atomRadius(ap)\n }\n if (index) {\n index[ i ] = idx\n }\n })\n return atomData\n }\n\n getBondData (params: BondDataParams) {\n const p = Object.assign({}, params)\n if (p.colorParams) p.colorParams.structure = this.getStructure()\n\n const what = p.what\n const bondSet = defaults(p.bondSet, this.bondSet)\n const multipleBond = defaults(p.multipleBond, 'off')\n const isMulti = multipleBond !== 'off'\n const isOffset = multipleBond === 'offset'\n const bondScale = defaults(p.bondScale, 0.4)\n const bondSpacing = defaults(p.bondSpacing, 1.0)\n\n let radiusFactory: any // TODO\n let colormaker: any // TODO\n\n const bondData: BondData = {}\n const bp = this.getBondProxy()\n if (p.bondStore) bp.bondStore = p.bondStore\n const ap1 = this.getAtomProxy()\n const ap2 = this.getAtomProxy()\n\n let bondCount: number\n if (isMulti) {\n const storeBondOrder = bp.bondStore.bondOrder\n bondCount = 0\n bondSet.forEach(function (index: number) {\n bondCount += storeBondOrder[ index ]\n })\n } else {\n bondCount = bondSet.getSize()\n }\n\n if (!what || what.position) {\n bondData.position1 = new Float32Array(bondCount * 3)\n bondData.position2 = new Float32Array(bondCount * 3)\n }\n if ((!what || what.color) && p.colorParams) {\n bondData.color = new Float32Array(bondCount * 3)\n bondData.color2 = new Float32Array(bondCount * 3)\n colormaker = ColormakerRegistry.getScheme(p.colorParams)\n }\n if (!what || what.picking) {\n bondData.picking = new BondPicker(new Float32Array(bondCount), this.getStructure(), p.bondStore)\n }\n if (!what || what.radius || (isMulti && what.position)) {\n radiusFactory = new RadiusFactory(p.radiusParams as RadiusParams)\n }\n if (!what || what.radius) {\n bondData.radius = new Float32Array(bondCount)\n if (p.radius2) {\n bondData.radius2 = new Float32Array(bondCount)\n }\n }\n\n const {position1, position2, color, color2, picking, radius, radius2} = bondData\n\n let i = 0\n let j, i3, k, bondOrder, absOffset\n let multiRadius\n\n const vt = new Vector3()\n const vShortening = new Vector3()\n const vShift = new Vector3()\n\n bondSet.forEach((index: number) => {\n i3 = i * 3\n bp.index = index\n ap1.index = bp.atomIndex1\n ap2.index = bp.atomIndex2\n bondOrder = bp.bondOrder\n if (position1) {\n if (isMulti && bondOrder > 1) {\n const atomRadius = radiusFactory.atomRadius(ap1)\n multiRadius = atomRadius * bondScale / (0.5 * bondOrder)\n\n bp.calculateShiftDir(vShift)\n\n if (isOffset) {\n absOffset = 2 * bondSpacing * atomRadius\n vShift.multiplyScalar(absOffset)\n vShift.negate()\n\n // Shortening is calculated so that neighbouring double\n // bonds on tetrahedral geometry (e.g. sulphonamide)\n // are not quite touching (arccos(1.9 / 2) ~ 109deg)\n // but don't shorten beyond 10% each end or it looks odd\n vShortening.subVectors(ap2 as any, ap1 as any).multiplyScalar( // TODO\n Math.max(0.1, absOffset / 1.88)\n )\n ap1.positionToArray(position1, i3)\n ap2.positionToArray(position2, i3)\n\n if (bondOrder >= 2) {\n vt.addVectors(ap1 as any, vShift).add(vShortening).toArray(position1 as any, i3 + 3) // TODO\n vt.addVectors(ap2 as any, vShift).sub(vShortening).toArray(position2 as any, i3 + 3) // TODO\n\n if (bondOrder >= 3) {\n vt.subVectors(ap1 as any, vShift).add(vShortening).toArray(position1 as any, i3 + 6) // TODO\n vt.subVectors(ap2 as any, vShift).sub(vShortening).toArray(position2 as any, i3 + 6) // TODO\n }\n }\n } else {\n absOffset = (bondSpacing - bondScale) * atomRadius\n vShift.multiplyScalar(absOffset)\n\n if (bondOrder === 2) {\n vt.addVectors(ap1 as any, vShift).toArray(position1 as any, i3) // TODO\n vt.subVectors(ap1 as any, vShift).toArray(position1 as any, i3 + 3) // TODO\n vt.addVectors(ap2 as any, vShift).toArray(position2 as any, i3) // TODO\n vt.subVectors(ap2 as any, vShift).toArray(position2 as any, i3 + 3) // TODO\n } else if (bondOrder === 3) {\n ap1.positionToArray(position1, i3)\n vt.addVectors(ap1 as any, vShift).toArray(position1 as any, i3 + 3) // TODO\n vt.subVectors(ap1 as any, vShift).toArray(position1 as any, i3 + 6) // TODO\n ap2.positionToArray(position2, i3)\n vt.addVectors(ap2 as any, vShift).toArray(position2 as any, i3 + 3) // TODO\n vt.subVectors(ap2 as any, vShift).toArray(position2 as any, i3 + 6) // TODO\n } else {\n // todo, better fallback\n ap1.positionToArray(position1, i3)\n ap2.positionToArray(position2, i3)\n }\n }\n } else {\n ap1.positionToArray(position1, i3)\n ap2.positionToArray(position2, i3)\n }\n }\n if (color && color2) {\n colormaker.bondColorToArray(bp, 1, color, i3)\n colormaker.bondColorToArray(bp, 0, color2, i3)\n if (isMulti && bondOrder > 1) {\n for (j = 1; j < bondOrder; ++j) {\n k = j * 3 + i3\n copyWithin(color, i3, k, 3)\n copyWithin(color2, i3, k, 3)\n }\n }\n }\n if (picking && picking.array) {\n picking.array[ i ] = index\n if (isMulti && bondOrder > 1) {\n for (j = 1; j < bondOrder; ++j) {\n picking.array[ i + j ] = index\n }\n }\n }\n if (radius) {\n radius[ i ] = radiusFactory.atomRadius(ap1)\n if (isMulti && bondOrder > 1) {\n multiRadius = radius[ i ] * bondScale / (isOffset ? 1 : (0.5 * bondOrder))\n for (j = isOffset ? 1 : 0; j < bondOrder; ++j) {\n radius[ i + j ] = multiRadius\n }\n }\n }\n if (radius2) {\n radius2[ i ] = radiusFactory.atomRadius(ap2)\n if (isMulti && bondOrder > 1) {\n multiRadius = radius2[ i ] * bondScale / (isOffset ? 1 : (0.5 * bondOrder))\n for (j = isOffset ? 1 : 0; j < bondOrder; ++j) {\n radius2[ i + j ] = multiRadius\n }\n }\n }\n i += isMulti ? bondOrder : 1\n })\n\n return bondData\n }\n\n getBackboneAtomData (params: AtomDataParams) {\n params = Object.assign({\n atomSet: this.atomSetCache.__backbone\n }, params)\n\n return this.getAtomData(params)\n }\n\n getBackboneBondData (params: BondDataParams) {\n params = Object.assign({\n bondSet: this.getBackboneBondSet(),\n bondStore: this.backboneBondStore\n }, params)\n\n return this.getBondData(params)\n }\n\n getRungAtomData (params: AtomDataParams) {\n params = Object.assign({\n atomSet: this.atomSetCache.__rung\n }, params)\n\n return this.getAtomData(params)\n }\n\n getRungBondData (params: BondDataParams) {\n params = Object.assign({\n bondSet: this.getRungBondSet(),\n bondStore: this.rungBondStore\n }, params)\n\n return this.getBondData(params)\n }\n\n //\n\n /**\n * Gets the bounding box of the (selected) structure atoms\n * @param {Selection} [selection] - the selection\n * @param {Box3} [box] - optional target\n * @return {Vector3} the box\n */\n getBoundingBox (selection?: Selection, box?: Box3) {\n if (Debug) Log.time('getBoundingBox')\n\n box = box || new Box3()\n\n let minX = +Infinity\n let minY = +Infinity\n let minZ = +Infinity\n\n let maxX = -Infinity\n let maxY = -Infinity\n let maxZ = -Infinity\n\n this.eachAtom(ap => {\n const x = ap.x\n const y = ap.y\n const z = ap.z\n\n if (x < minX) minX = x\n if (y < minY) minY = y\n if (z < minZ) minZ = z\n\n if (x > maxX) maxX = x\n if (y > maxY) maxY = y\n if (z > maxZ) maxZ = z\n }, selection)\n\n box.min.set(minX, minY, minZ)\n box.max.set(maxX, maxY, maxZ)\n\n if (Debug) Log.timeEnd('getBoundingBox')\n\n return box\n }\n\n /**\n * Gets the principal axes of the (selected) structure atoms\n * @param {Selection} [selection] - the selection\n * @return {PrincipalAxes} the principal axes\n */\n getPrincipalAxes (selection?: Selection) {\n if (Debug) Log.time('getPrincipalAxes')\n\n let i = 0\n const coords = new Matrix(3, this.atomCount)\n const cd = coords.data\n\n this.eachAtom(a => {\n cd[ i + 0 ] = a.x\n cd[ i + 1 ] = a.y\n cd[ i + 2 ] = a.z\n i += 3\n }, selection)\n\n if (Debug) Log.timeEnd('getPrincipalAxes')\n\n return new PrincipalAxes(coords)\n }\n\n /**\n * Gets the center of the (selected) structure atoms\n * @param {Selection} [selection] - the selection\n * @return {Vector3} the center\n */\n atomCenter (selection?: Selection) {\n if (selection) {\n return this.getBoundingBox(selection).getCenter(new Vector3())\n } else {\n return this.center.clone()\n }\n }\n\n hasCoords () {\n if (this._hasCoords === undefined) {\n const atomStore = this.atomStore\n this._hasCoords = (\n arrayMin(atomStore.x) !== 0 || arrayMax(atomStore.x) !== 0 ||\n arrayMin(atomStore.y) !== 0 || arrayMax(atomStore.y) !== 0 ||\n arrayMin(atomStore.z) !== 0 || arrayMax(atomStore.z) !== 0\n ) || (\n // allow models with a single atom at the origin\n atomStore.count / this.modelStore.count === 1\n )\n }\n return this._hasCoords;\n }\n\n getSequence (selection?: Selection) {\n const seq: string[] = []\n const rp = this.getResidueProxy()\n\n this.eachAtom(function (ap: AtomProxy) {\n rp.index = ap.residueIndex\n if (ap.index === rp.traceAtomIndex) {\n seq.push(rp.getResname1())\n }\n }, selection)\n\n return seq\n }\n\n getAtomIndices (selection?: Selection) {\n if (selection && selection.string) {\n const indices: number[] = []\n this.eachAtom(function (ap: AtomProxy) {\n indices.push(ap.index)\n }, selection)\n return new Uint32Array(indices)\n } else {\n const p = { what: { index: true } }\n return this.getAtomData(p).index\n }\n }\n\n /**\n * Get number of unique chainnames\n * @param {Selection} selection - limit count to selection\n * @return {Integer} count\n */\n getChainnameCount (selection?: Selection) {\n const chainnames = new Set()\n this.eachChain(function (cp: ChainProxy) {\n if (cp.residueCount) {\n chainnames.add(cp.chainname)\n }\n }, selection)\n\n return chainnames.size\n }\n\n /**\n * Update atomic positions\n * @param position - Array to copy positions from\n * @param refresh - Whether or not to issue a full refresh (automatically\n * triggers re-calculation of bounding boxes, spatial hash,\n * representations etc etc). This provides compatibility with\n * the old behaviour\n */\n updatePosition (position: Float32Array|number[], refresh: boolean = true) {\n let i = 0\n\n this.eachAtom(function (ap: AtomProxy) {\n ap.positionFromArray(position, i)\n i += 3\n }, undefined)\n\n this._hasCoords = undefined // to trigger recalculation (of the _hasCoords value)\n\n if (refresh) { \n this.refreshPosition() // Recalculate bounds - structure-component listener will \n // trigger representation rebuild\n }\n\n }\n\n refreshPosition () {\n this.getBoundingBox(undefined, this.boundingBox)\n this.boundingBox.getCenter(this.center)\n this.spatialHash = new SpatialHash(this.atomStore, this.boundingBox)\n\n this.signals.refreshed.dispatch(this)\n }\n\n /**\n * Calls dispose() method of property objects.\n * Unsets properties to help garbage collection.\n * @return {undefined}\n */\n dispose () {\n if (this.frames) this.frames.length = 0\n if (this.boxes) this.boxes.length = 0\n\n this.bondStore.dispose()\n this.backboneBondStore.dispose()\n this.rungBondStore.dispose()\n this.atomStore.dispose()\n this.residueStore.dispose()\n this.chainStore.dispose()\n this.modelStore.dispose()\n\n // can't delete non-optional properties as of TS 4\n // and since we've already disposed them, don't need to.\n\n delete this.bondSet\n delete this.atomSet\n }\n}\n\nexport default Structure\n","/**\n * @file Shape\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Matrix4 required for declaration only\nimport { Box3, Vector3, Color, Matrix4 } from 'three'\n\nimport { createParams, ensureFloat32Array, getUintArray } from '../utils'\nimport {\n ArrowPrimitive, BoxPrimitive, ConePrimitive, CylinderPrimitive, EllipsoidPrimitive,\n OctahedronPrimitive, SpherePrimitive, TetrahedronPrimitive, TextPrimitive,\n TorusPrimitive, PointPrimitive, WidelinePrimitive\n} from './primitive'\nimport { MeshPicker } from '../utils/picker'\nimport Buffer from '../buffer/buffer'\nimport MeshBuffer from '../buffer/mesh-buffer'\nimport { TextBufferParameters } from '../buffer/text-buffer'\n\nconst tmpBox = new Box3()\n\nconst Primitives = [\n ArrowPrimitive, BoxPrimitive, ConePrimitive, CylinderPrimitive,\n EllipsoidPrimitive, OctahedronPrimitive, SpherePrimitive, TetrahedronPrimitive,\n TextPrimitive, TorusPrimitive, PointPrimitive, WidelinePrimitive\n]\n\nexport const ShapeDefaultParameters = {\n aspectRatio: 1.5,\n sphereDetail: 2,\n radialSegments: 50,\n disableImpostor: false,\n openEnded: false,\n dashedCylinder: false,\n labelParams: {} as Partial,\n pointSize: 2,\n sizeAttenuation: false,\n useTexture: true,\n linewidth: 2\n}\nexport type ShapeParameters = typeof ShapeDefaultParameters\n\n/**\n * Class for building custom shapes.\n *\n * @example\n * var shape = new NGL.Shape('shape', { disableImpostor: true });\n * shape.addSphere([ 0, 0, 9 ], [ 1, 0, 0 ], 1.5 );\n * shape.addEllipsoid([ 6, 0, 0 ], [ 1, 0, 0 ], 1.5, [ 3, 0, 0 ], [ 0, 2, 0 ]);\n * shape.addCylinder([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ], 0.5);\n * shape.addCone([ 0, 2, 7 ], [ 0, 3, 3 ], [ 1, 1, 0 ], 1.5);\n * shape.addArrow([ 1, 2, 7 ], [ 30, 3, 3 ], [ 1, 0, 1 ], 1.0);\n * shape.addBox([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);\n * var shapeComp = stage.addComponentFromObject(shape);\n * geoComp.addRepresentation('buffer');\n */\nclass Shape {\n name: string\n parameters: ShapeParameters\n\n boundingBox = new Box3()\n bufferList: Buffer[] = []\n meshCount = 0\n\n _center?: Vector3\n _primitiveData: { [k: string]: any } = {}\n\n /**\n * @param {String} name - name\n * @param {Object} params - parameter object\n * @param {Integer} params.aspectRatio - arrow aspect ratio, used for cylinder radius and cone length\n * @param {Integer} params.sphereDetail - sphere quality (icosahedron subdivisions)\n * @param {Integer} params.radialSegments - cylinder quality (number of segments)\n * @param {Boolean} params.disableImpostor - disable use of raycasted impostors for rendering\n * @param {Boolean} params.openEnded - capped or not\n * @param {TextBufferParameters} params.labelParams - label parameters\n */\n constructor (name = 'shape', params: Partial = {}) {\n this.name = name\n\n this.parameters = createParams(params, ShapeDefaultParameters)\n\n Primitives.forEach(P => {\n Object.keys(P.fields).forEach(name => {\n this._primitiveData[ P.getShapeKey(name) ] = []\n })\n this._primitiveData[ P.getShapeKey('name') ] = []\n })\n }\n\n /**\n * Add a buffer\n * @param {Buffer} buffer - buffer object\n * @return {Shape} this object\n */\n addBuffer (buffer: Buffer) {\n this.bufferList.push(buffer)\n\n const geometry = (buffer as any).geometry // TODO\n if (!geometry.boundingBox) {\n geometry.computeBoundingBox()\n }\n this.boundingBox.union(geometry.boundingBox)\n\n return this\n }\n\n /**\n * Add a mesh\n * @example\n * shape.addMesh(\n * [ 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1 ],\n * [ 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0 ]\n * );\n *\n * @param {Float32Array|Array} position - positions\n * @param {Float32Array|Array} color - colors\n * @param {Uint32Array|Uint16Array|Array} [index] - indices\n * @param {Float32Array|Array} [normal] - normals\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addMesh (position: Float32Array|number[], color:Float32Array|number[], index: Uint32Array|Uint16Array|number[], normal?: Float32Array|number[], name?: string) {\n position = ensureFloat32Array(position)\n color = ensureFloat32Array(color)\n\n if (Array.isArray(index)) {\n index = getUintArray(index, position.length)\n }\n if (normal) {\n normal = ensureFloat32Array(normal)\n }\n\n let data\n if (normal === undefined || normal.length == 0 ) {\n data = { position, color, index }\n } else {\n data = { position, color, index, normal }\n }\n //const data = { position, color, index, normal }\n const picking = new MeshPicker(\n this, Object.assign({ serial: this.meshCount, name }, data)\n )\n const meshBuffer = new MeshBuffer(\n Object.assign({ picking }, data) as any\n )\n this.bufferList.push(meshBuffer)\n\n tmpBox.setFromArray(position)\n this.boundingBox.union(tmpBox)\n this.meshCount += 1\n\n return this\n }\n\n /**\n * Add a sphere\n * @example\n * shape.addSphere([ 0, 0, 9 ], [ 1, 0, 0 ], 1.5);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addSphere (position: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, name: string) {\n SpherePrimitive.objectToShape(\n this, { position, color, radius, name }\n )\n return this\n }\n\n /**\n * Add an ellipsoid\n * @example\n * shape.addEllipsoid([ 6, 0, 0 ], [ 1, 0, 0 ], 1.5, [ 3, 0, 0 ], [ 0, 2, 0 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {Vector3|Array} majorAxis - major axis vector or array\n * @param {Vector3|Array} minorAxis - minor axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addEllipsoid (position: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, majorAxis: Vector3|[number, number, number], minorAxis: Vector3|[number, number, number], name: string) {\n EllipsoidPrimitive.objectToShape(\n this, { position, color, radius, majorAxis, minorAxis, name }\n )\n return this\n }\n\n /**\n * Add a torus\n * @example\n * shape.addTorus([ 6, 0, 0 ], [ 1, 0, 0 ], 1.5, [ 3, 0, 0 ], [ 0, 2, 0 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {Vector3|Array} majorAxis - major axis vector or array\n * @param {Vector3|Array} minorAxis - minor axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addTorus (position: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, majorAxis: Vector3|[number, number, number], minorAxis: Vector3|[number, number, number], name: string) {\n TorusPrimitive.objectToShape(\n this, { position, color, radius, majorAxis, minorAxis, name }\n )\n return this\n }\n\n /**\n * Add a cylinder\n * @example\n * shape.addCylinder([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ], 0.5);\n *\n * @param {Vector3|Array} position1 - from position vector or array\n * @param {Vector3|Array} position2 - to position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addCylinder (position1: Vector3|[number, number, number], position2: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, name: string) {\n CylinderPrimitive.objectToShape(\n this, { position1, position2, color, radius, name }\n )\n return this\n }\n\n /**\n * Add a cone\n * @example\n * shape.addCone([ 0, 2, 7 ], [ 0, 3, 3 ], [ 1, 1, 0 ], 1.5);\n *\n * @param {Vector3|Array} position1 - from position vector or array\n * @param {Vector3|Array} position2 - to position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addCone (position1: Vector3|[number, number, number], position2: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, name: string) {\n ConePrimitive.objectToShape(\n this, { position1, position2, color, radius, name }\n )\n return this\n }\n\n /**\n * Add an arrow\n * @example\n * shape.addArrow([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ], 0.5);\n *\n * @param {Vector3|Array} position1 - from position vector or array\n * @param {Vector3|Array} position2 - to position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addArrow (position1: Vector3|[number, number, number], position2: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, name: string) {\n ArrowPrimitive.objectToShape(\n this, { position1, position2, color, radius, name }\n )\n return this\n }\n\n /**\n * Add a box\n * @example\n * shape.addBox([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} size - size value\n * @param {Vector3|Array} heightAxis - height axis vector or array\n * @param {Vector3|Array} depthAxis - depth axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addBox (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, heightAxis: Vector3|[number, number, number], depthAxis: Vector3|[number, number, number], name: string) {\n BoxPrimitive.objectToShape(\n this, { position, color, size, heightAxis, depthAxis, name }\n )\n return this\n }\n\n /**\n * Add an octahedron\n * @example\n * shape.addOctahedron([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} size - size value\n * @param {Vector3|Array} heightAxis - height axis vector or array\n * @param {Vector3|Array} depthAxis - depth axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addOctahedron (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, heightAxis: Vector3|[number, number, number], depthAxis: Vector3|[number, number, number], name: string) {\n OctahedronPrimitive.objectToShape(\n this, { position, color, size, heightAxis, depthAxis, name }\n )\n return this\n }\n\n /**\n * Add a tetrahedron\n * @example\n * shape.addTetrahedron([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} size - size value\n * @param {Vector3|Array} heightAxis - height axis vector or array\n * @param {Vector3|Array} depthAxis - depth axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addTetrahedron (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, heightAxis: Vector3|[number, number, number], depthAxis: Vector3|[number, number, number], name: string) {\n TetrahedronPrimitive.objectToShape(\n this, { position, color, size, heightAxis, depthAxis, name }\n )\n return this\n }\n\n /**\n * Add text\n * @example\n * shape.addText([ 10, -2, 4 ], [ 0.2, 0.5, 0.8 ], 0.5, \"Hello\");\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} size - size value\n * @param {String} text - text value\n * @return {Shape} this object\n */\n addText (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, text: string) {\n TextPrimitive.objectToShape(\n this, { position, color, size, text }\n )\n return this\n }\n\n /**\n * Add point\n * @example\n * shape.addPoint([ 10, -2, 4 ], [ 0.2, 0.5, 0.8 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addPoint (position: Vector3|[number, number, number], color: Color|[number, number, number], name: string) {\n PointPrimitive.objectToShape(\n this, { position, color, name }\n )\n return this\n }\n\n /**\n * Add a wideline\n * @example\n * shape.addWideline([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ]);\n *\n * @param {Vector3|Array} position1 - from position vector or array\n * @param {Vector3|Array} position2 - to position vector or array\n * @param {Color|Array} color - color object or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addWideline (position1: Vector3|[number, number, number], position2: Vector3|[number, number, number], color: Color|[number, number, number], linewidth: number, name: string) {\n this.parameters.linewidth = linewidth\n WidelinePrimitive.objectToShape(\n this, { position1, position2, color, name }\n )\n return this\n }\n\n /**\n * Deprecated, use `.addText`\n */\n addLabel (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, text: string) {\n console.warn('Shape.addLabel is deprecated, use .addText instead')\n return this.addText(position, color, size, text)\n }\n\n getBufferList () {\n const buffers: Buffer[] = []\n\n Primitives.forEach(P => {\n if (this._primitiveData[ P.getShapeKey('color') ].length) {\n buffers.push(P.bufferFromShape(this, this.parameters))\n }\n })\n\n return this.bufferList.concat(buffers)\n }\n\n dispose () {\n this.bufferList.forEach(function (buffer) {\n buffer.dispose()\n })\n this.bufferList.length = 0\n\n Primitives.forEach(P => {\n Object.keys(P.fields).forEach(name => {\n this._primitiveData[ P.getShapeKey(name) ].length = 0\n })\n this._primitiveData[ P.getShapeKey('name') ].length = 0\n })\n }\n\n get center () {\n if (!this._center) {\n this._center = this.boundingBox.getCenter(new Vector3())\n }\n return this._center\n }\n\n get type () { return 'Shape' }\n}\n\nexport default Shape\n","/**\n * @file Buffer Representation\n * @author Alexander Rose \n * @private\n */\n\nimport Representation, { RepresentationParameters } from './representation'\nimport Viewer from '../viewer/viewer';\n\n/**\n * Representation for showing buffer objects. Good for efficiently showing\n * large amounts of geometric primitives e.g. spheres via {@link SphereBuffer}.\n * Smaller numbers of geometric primitives are more easily shown with help\n * from the {@link Shape} class.\n *\n * __Name:__ _buffer_\n *\n * @example\n * // add a single red sphere from a buffer to a shape instance\n * var shape = new NGL.Shape( \"shape\" );\n * var sphereBuffer = new NGL.SphereBuffer( {\n * position: new Float32Array( [ 0, 0, 0 ] ),\n * color: new Float32Array( [ 1, 0, 0 ] ),\n * radius: new Float32Array( [ 1 ] )\n * } );\n * shape.addBuffer( sphereBuffer );\n * var shapeComp = stage.addComponentFromObject( shape );\n * shapeComp.addRepresentation( \"buffer\" );\n *\n * @example\n * // add a single red sphere from a buffer to a structure component instance\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * var sphereBuffer = new NGL.SphereBuffer( {\n * position: new Float32Array( [ 0, 0, 0 ] ),\n * color: new Float32Array( [ 1, 0, 0 ] ),\n * radius: new Float32Array( [ 1 ] )\n * } );\n * o.addBufferRepresentation( sphereBuffer, { opacity: 0.5 } );\n * } );\n */\nclass BufferRepresentation extends Representation {\n buffer: Buffer[]\n /**\n * Create Buffer representation\n * @param {Buffer} buffer - a buffer object\n * @param {Viewer} viewer - a viewer object\n * @param {RepresentationParameters} params - representation parameters\n */\n constructor (buffer: Buffer|Buffer[], viewer: Viewer, params: Partial) {\n if (!Array.isArray(buffer)) {\n buffer = [ buffer ]\n }\n\n super(buffer, viewer, params)\n\n this.type = 'buffer'\n\n this.parameters = Object.assign({\n\n }, this.parameters, {\n\n colorScheme: null,\n colorScale: null,\n colorValue: null,\n colorDomain: null,\n colorMode: null\n\n })\n\n this.buffer = buffer\n\n this.init(params)\n }\n\n init (params: Partial) {\n super.init(params)\n\n this.build()\n }\n\n create () {\n this.bufferList.push.apply(this.bufferList, this.buffer)\n }\n\n attach (callback: ()=> void) {\n this.bufferList.forEach(buffer => {\n this.viewer.add(buffer)\n buffer.setParameters(this.getBufferParams())\n })\n this.setVisibility(this.visible)\n\n callback()\n }\n}\n\nexport default BufferRepresentation\n","/**\n * @file Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3 required for declaration only\n import { Vector3, Matrix4, Matrix3, BufferGeometry } from 'three'\n\nimport { getUintArray } from '../utils'\nimport { serialBlockArray } from '../math/array-utils'\nimport { applyMatrix3toVector3array, applyMatrix4toVector3array } from '../math/vector-utils'\nimport MeshBuffer from './mesh-buffer'\nimport { BufferParameters, BufferData } from './buffer'\nimport {Log} from \"../globals\";\n\nconst matrix = new Matrix4()\nconst normalMatrix = new Matrix3()\n\nfunction getData(data: BufferData, geo: BufferGeometry){\n const geoPosition = (geo.attributes as any).position.array\n const geoIndex = geo.index ? geo.index.array : undefined\n\n const n = data.position!.length / 3\n const m = geoPosition.length / 3\n\n const size = n * m\n\n const meshPosition = new Float32Array(size * 3)\n const meshNormal = new Float32Array(size * 3)\n const meshColor = new Float32Array(size * 3)\n\n let meshIndex\n if (geoIndex) {\n meshIndex = getUintArray(n * geoIndex.length, size)\n }\n\n return {\n position: meshPosition,\n color: meshColor,\n index: meshIndex,\n normal: meshNormal,\n primitiveId: data.primitiveId || serialBlockArray(n, m) as Float32Array,\n picking: data.picking\n }\n}\n\n/**\n * Geometry buffer. Base class for geometry-based buffers. Used to draw\n * geometry primitives given a mesh.\n * @interface\n */\nabstract class GeometryBuffer extends MeshBuffer {\n updateNormals = false\n\n geoPosition: Float32Array\n geoNormal: Float32Array\n geoIndex?: Uint32Array|Uint16Array\n\n positionCount: number\n geoPositionCount: number\n\n transformedGeoPosition: Float32Array\n transformedGeoNormal: Float32Array\n\n meshPosition: Float32Array\n meshColor: Float32Array\n meshIndex: Uint32Array|Uint16Array\n meshNormal: Float32Array\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n * @param {BufferGeometry} geo - geometry object\n */\n constructor (data: BufferData, params: Partial = {}, geo: BufferGeometry) {\n super(getData(data, geo), params)\n\n const geoPosition = (geo.attributes as any).position.array\n const geoNormal = (geo.attributes as any).normal.array\n const geoIndex = geo.index ? (geo.index.array as Uint32Array|Uint16Array) : undefined\n\n this.geoPosition = geoPosition\n this.geoNormal = geoNormal\n this.geoIndex = geoIndex\n\n this.positionCount = data.position!.length / 3\n this.geoPositionCount = geoPosition.length / 3\n\n this.transformedGeoPosition = new Float32Array(this.geoPositionCount * 3)\n this.transformedGeoNormal = new Float32Array(this.geoPositionCount * 3)\n\n const attributes = this.geometry.attributes as any // TODO\n this.meshPosition = attributes.position.array\n this.meshColor = attributes.color.array\n this.meshNormal = attributes.normal.array\n\n this.setAttributes(data)\n\n if (geoIndex) {\n const index = this.geometry.getIndex()\n if (!index) { Log.error('Index is null'); return; }\n this.meshIndex = index.array as Uint32Array|Uint16Array\n this.makeIndex()\n }\n }\n\n abstract applyPositionTransform (matrix: Matrix4, i: number, i3?: number): void\n\n setAttributes (data: Partial = {}, initNormals = false) {\n const attributes = this.geometry.attributes as any // TODO\n\n let position, color\n let geoPosition, geoNormal\n let transformedGeoPosition, transformedGeoNormal\n let meshPosition, meshColor, meshNormal\n\n const updateNormals = this.updateNormals\n\n if (data.position) {\n position = data.position\n geoPosition = this.geoPosition\n meshPosition = this.meshPosition\n transformedGeoPosition = this.transformedGeoPosition\n attributes.position.needsUpdate = true\n if (updateNormals || initNormals) {\n geoNormal = this.geoNormal\n meshNormal = this.meshNormal\n transformedGeoNormal = this.transformedGeoNormal\n attributes.normal.needsUpdate = true\n }\n }\n\n if (data.color) {\n color = data.color\n meshColor = this.meshColor\n attributes.color.needsUpdate = true\n }\n\n const n = this.positionCount\n const m = this.geoPositionCount\n\n for (let i = 0; i < n; ++i) {\n let j, l\n const k = i * m * 3\n const i3 = i * 3\n\n if (position && transformedGeoPosition && meshPosition && meshNormal && geoPosition && geoNormal) {\n transformedGeoPosition.set(geoPosition)\n matrix.makeTranslation(\n position[ i3 ], position[ i3 + 1 ], position[ i3 + 2 ]\n )\n this.applyPositionTransform(matrix, i, i3)\n applyMatrix4toVector3array(matrix.elements as unknown as Float32Array,\n transformedGeoPosition)\n\n meshPosition.set(transformedGeoPosition, k)\n\n if (updateNormals && transformedGeoNormal) {\n transformedGeoNormal.set(geoNormal)\n normalMatrix.getNormalMatrix(matrix)\n applyMatrix3toVector3array(normalMatrix.elements as unknown as Float32Array,\n transformedGeoNormal)\n\n meshNormal.set(transformedGeoNormal, k)\n } else if (initNormals) {\n meshNormal.set(geoNormal, k)\n }\n }\n\n if (color && meshColor) {\n for (j = 0; j < m; ++j) {\n l = k + 3 * j\n\n meshColor[ l ] = color[ i3 ]\n meshColor[ l + 1 ] = color[ i3 + 1 ]\n meshColor[ l + 2 ] = color[ i3 + 2 ]\n }\n }\n }\n }\n\n makeIndex () {\n const geoIndex = this.geoIndex\n const meshIndex = this.meshIndex\n\n if (!geoIndex) return\n\n const n = this.positionCount\n const m = this.geoPositionCount\n const o = geoIndex.length / 3\n\n const o3 = o * 3\n\n for (let i = 0; i < n; ++i) {\n const j = i * o3\n const q = j + o3\n\n meshIndex.set(geoIndex, j)\n for (let p = j; p < q; ++p) meshIndex[ p ] += i * m\n }\n }\n}\n\nexport default GeometryBuffer\n","/**\n * @file Sphere Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { IcosahedronBufferGeometry, Vector3, Matrix4 } from 'three'\nimport { defaults } from '../utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { SphereBufferData } from './sphere-buffer'\nimport { BufferDefaultParameters, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\n\nexport const SphereGeometryBufferDefaultParameters = Object.assign({\n sphereDetail: 1\n}, BufferDefaultParameters)\nexport type SphereGeometryBufferParameters = BufferParameters & { sphereDetail: number }\n\n/**\n * Sphere geometry buffer.\n *\n * @example\n * var sphereGeometryBuffer = new SphereGeometryBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass SphereGeometryBuffer extends GeometryBuffer {\n get defaultParameters() { return SphereGeometryBufferDefaultParameters }\n parameters: SphereGeometryBufferParameters\n\n private _radius: Float32Array\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: SphereBufferData, params: Partial = {}) {\n super(data, params, new IcosahedronBufferGeometry(1, defaults(params.sphereDetail, 1)))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number) {\n const r = this._radius[ i ]\n scale.set(r, r, r)\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.radius) this._radius = data.radius\n\n super.setAttributes(data, initNormals)\n }\n}\n\nexport default SphereGeometryBuffer\n","/**\n * @file Mapped Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { getUintArray } from '../utils'\nimport { calculateCenterArray, serialArray } from '../math/array-utils'\nimport Buffer, { BufferParameters, BufferData } from './buffer'\n\nexport type MappingType = 'v2'|'v3'\n\n/**\n * Mapped buffer. Sends mapping attribute to the GPU and repeats data in\n * others attributes. Used to render imposters.\n * @interface\n */\nabstract class MappedBuffer extends Buffer {\n index: Uint32Array|Uint16Array\n\n constructor (mappingType: MappingType, data: BufferData, params: Partial = {}) {\n super(data, params)\n\n this.index = getUintArray(this.indexSize, this.attributeSize)\n this.makeIndex()\n this.initIndex(this.index)\n\n this.addAttributes({\n 'mapping': { type: mappingType, value: null }\n })\n\n this.setAttributes({ primitiveId: serialArray(this.size) })\n }\n\n abstract get mapping (): Float32Array\n abstract get mappingIndices (): Uint32Array|Uint16Array\n abstract get mappingIndicesSize (): number\n abstract get mappingSize (): number\n abstract get mappingItemSize (): number\n\n get attributeSize () {\n return this.size * this.mappingSize\n }\n\n get indexSize () {\n return this.size * this.mappingIndicesSize\n }\n\n addAttributes (attributes: any) {\n const nullValueAttributes: any = {}\n for (const name in attributes) {\n const a = attributes[ name ]\n nullValueAttributes[ name ] = {\n type: a.type,\n value: null\n }\n }\n\n super.addAttributes(nullValueAttributes)\n }\n\n getAttributeIndex (dataIndex: number) {\n return dataIndex * 3 * this.mappingSize\n }\n\n setAttributes (data: any) { // TODO\n if (data && !data.position && data.position1 && data.position2) {\n data.position = calculateCenterArray(data.position1, data.position2)\n }\n\n const size = this.size\n const mappingSize = this.mappingSize\n const attributes = this.geometry.attributes as any // TODO\n\n let a, d, itemSize, array, n, i, j\n\n for (const name in data) {\n if (name === 'index' || name === 'picking') continue\n\n d = data[ name ]\n a = attributes[ name ]\n itemSize = a.itemSize\n array = a.array\n\n for (let k = 0; k < size; ++k) {\n n = k * itemSize\n i = n * mappingSize\n\n for (let l = 0; l < mappingSize; ++l) {\n j = i + (itemSize * l)\n\n for (let m = 0; m < itemSize; ++m) {\n array[ j + m ] = d[ n + m ]\n }\n }\n }\n\n a.needsUpdate = true\n }\n }\n\n makeMapping () {\n const size = this.size\n const mapping = this.mapping\n const mappingSize = this.mappingSize\n const mappingItemSize = this.mappingItemSize\n\n const attributes = this.geometry.attributes as any // TODO\n const aMapping = attributes.mapping.array\n\n for (let v = 0; v < size; v++) {\n aMapping.set(mapping, v * mappingItemSize * mappingSize)\n }\n }\n\n makeIndex () {\n const size = this.size\n const mappingSize = this.mappingSize\n const mappingIndices = this.mappingIndices\n const mappingIndicesSize = this.mappingIndicesSize\n\n const index = this.index\n\n for (let v = 0; v < size; v++) {\n const ix = v * mappingIndicesSize\n const it = v * mappingSize\n\n index.set(mappingIndices, ix)\n\n for (let s = 0; s < mappingIndicesSize; ++s) {\n index[ ix + s ] += it\n }\n }\n }\n}\n\nexport default MappedBuffer\n","/**\n * @file Mapped Quad Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { BufferParameters, BufferData } from './buffer'\nimport MappedBuffer from './mapped-buffer'\n\nconst mapping = new Float32Array([\n -1.0, 1.0,\n -1.0, -1.0,\n 1.0, 1.0,\n 1.0, -1.0\n])\n\nconst mappingIndices = new Uint16Array([\n 0, 1, 2,\n 1, 3, 2\n])\n\n/**\n * Mapped Quad buffer. Draws screen-aligned quads. Used to render impostors.\n * @interface\n */\nclass MappedQuadBuffer extends MappedBuffer {\n constructor(data: BufferData, params: Partial = {}) {\n super('v2', data, params)\n }\n get mapping () { return mapping }\n get mappingIndices () { return mappingIndices }\n get mappingIndicesSize () { return 6 }\n get mappingSize () { return 4 }\n get mappingItemSize () { return 2 }\n}\n\nexport default MappedQuadBuffer\n","/**\n * @file Sphere Impostor Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport '../shader/SphereImpostor.vert'\nimport '../shader/SphereImpostor.frag'\n\nimport MappedQuadBuffer from './mappedquad-buffer'\nimport { SphereBufferData } from './sphere-buffer'\nimport { BufferParameters } from './buffer'\n\n/**\n * Sphere impostor buffer.\n *\n * @example\n * var sphereImpostorBuffer = new SphereImpostorBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass SphereImpostorBuffer extends MappedQuadBuffer {\n isImpostor = true\n vertexShader = 'SphereImpostor.vert'\n fragmentShader = 'SphereImpostor.frag'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: SphereBufferData, params: Partial = {}) {\n super(data, params)\n\n this.addUniforms({\n 'projectionMatrixInverse': { value: new Matrix4() },\n 'ortho': { value: 0.0 }\n })\n\n this.addAttributes({\n 'radius': { type: 'f', value: null }\n })\n\n this.setAttributes(data)\n this.makeMapping()\n }\n}\n\nexport default SphereImpostorBuffer\n","/**\n * @file Sphere Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only \nimport { Vector3, Matrix4 } from 'three'\nimport { BufferRegistry, ExtensionFragDepth } from '../globals'\nimport SphereGeometryBuffer, { SphereGeometryBufferDefaultParameters, SphereGeometryBufferParameters } from './spheregeometry-buffer'\nimport SphereImpostorBuffer from './sphereimpostor-buffer'\nimport { BufferData } from './buffer'\n\nexport interface SphereBufferData extends BufferData {\n radius: Float32Array\n}\n\nexport const SphereBufferDefaultParameters = Object.assign({\n disableImpostor: false\n}, SphereGeometryBufferDefaultParameters)\nexport type SphereBufferParameters = SphereGeometryBufferParameters & { disableImpostor: boolean }\n\nclass SphereBufferImpl {\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} params - parameters object\n * @return {SphereGeometryBuffer|SphereImpostorBuffer} the buffer object\n */\n constructor (data: SphereBufferData, params: SphereBufferParameters) {\n if (!ExtensionFragDepth || (params && params.disableImpostor)) {\n return new SphereGeometryBuffer(data, params)\n } else {\n return new SphereImpostorBuffer(data, params)\n }\n }\n}\n\n/**\n * Sphere buffer. Depending on the value {@link ExtensionFragDepth} and\n * `params.disableImpostor` the constructor returns either a\n * {@link SphereGeometryBuffer} or a {@link SphereImpostorBuffer}\n * @implements {Buffer}\n *\n * @example\n * var sphereBuffer = new SphereBuffer( {\n * position: new Float32Array( [ 0, 0, 0 ] ),\n * color: new Float32Array( [ 1, 0, 0 ] ),\n * radius: new Float32Array( [ 1 ] )\n * } );\n */\n//@ts-expect-error Incompatible constructor signatures\nconst SphereBuffer: {\n new(data: SphereBufferData, params: SphereBufferParameters): SphereGeometryBuffer | SphereImpostorBuffer;\n} = SphereBufferImpl;\n\ntype SphereBuffer = SphereGeometryBuffer | SphereImpostorBuffer;\n\nBufferRegistry.add('sphere', SphereBuffer)\n\nexport default SphereBuffer\n","/**\n * @file Point Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { DataTexture, Vector3, Matrix4 } from 'three'\n\nimport '../shader/Point.vert'\nimport '../shader/Point.frag'\n\nimport { BufferRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { smoothstep } from '../math/math-utils'\nimport Buffer, { BufferDefaultParameters, BufferParameterTypes, BufferData, BufferTypes, BufferParameters } from './buffer'\n\nfunction distance (x0: number, y0: number, x1: number, y1: number) {\n const dx = x1 - x0\n const dy = y1 - y0\n return Math.sqrt(dx * dx + dy * dy)\n}\n\ninterface PointTextureParams {\n width?: number\n height?: number\n delta?: number\n}\n\nfunction makePointTexture (params: PointTextureParams) {\n const p = params || {}\n\n const width = defaults(p.width, 256)\n const height = defaults(p.height, 256)\n const center = [ width / 2, height / 2 ]\n const radius = Math.min(width / 2, height / 2)\n const delta = defaults(p.delta, 1 / (radius + 1)) * radius\n\n let x = 0\n let y = 0\n const data = new Uint8Array(width * height * 4)\n\n for (let i = 0, il = data.length; i < il; i += 4) {\n const dist = distance(x, y, center[ 0 ], center[ 1 ])\n const value = 1 - smoothstep(radius - delta, radius, dist)\n\n data[ i ] = value * 255\n data[ i + 1 ] = value * 255\n data[ i + 2 ] = value * 255\n data[ i + 3 ] = value * 255\n\n if (++x === width) {\n x = 0\n y++\n }\n }\n\n const tex = new DataTexture(data, width, height)\n tex.needsUpdate = true\n\n return tex\n}\n\nexport const PointBufferDefaultParameters = Object.assign({\n pointSize: 1,\n sizeAttenuation: true,\n sortParticles: false,\n alphaTest: 0.5,\n useTexture: false,\n forceTransparent: false,\n edgeBleach: 0.0\n}, BufferDefaultParameters)\nexport type PointBufferParameters = BufferParameters & {\n pointSize: number,\n sizeAttenuation: boolean,\n sortParticles: boolean,\n alphaTest: number,\n useTexture: boolean,\n forceTransparent: boolean,\n edgeBleach: number\n}\n\nconst PointBufferParameterTypes = Object.assign({\n pointSize: { uniform: 'size' },\n sizeAttenuation: { updateShader: true },\n sortParticles: {},\n alphaTest: { updateShader: true },\n useTexture: { updateShader: true },\n forceTransparent: {},\n edgeBleach: { uniform: true }\n}, BufferParameterTypes)\n\n/**\n * Point buffer. Draws points. Optionally textured.\n *\n * @example\n * var pointBuffer = new PointBuffer( {\n * position: new Float32Array( [ 0, 0, 0 ] ),\n * color: new Float32Array( [ 1, 0, 0 ] )\n * } );\n */\nclass PointBuffer extends Buffer {\n parameterTypes = PointBufferParameterTypes\n get defaultParameters() { return PointBufferDefaultParameters }\n parameters: PointBufferParameters\n\n vertexShader = 'Point.vert'\n fragmentShader ='Point.frag'\n\n isPoint = true\n tex: DataTexture\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: BufferData, params: Partial = {}) {\n super(data, params)\n\n this.addUniforms({\n 'size': { value: this.parameters.pointSize },\n 'canvasHeight': { value: 1.0 },\n 'pixelRatio': { value: 1.0 },\n 'map': { value: null }\n })\n }\n\n makeMaterial () {\n super.makeMaterial()\n\n this.makeTexture()\n\n const m = this.material\n const wm = this.wireframeMaterial\n const pm = this.pickingMaterial\n\n m.uniforms.map.value = this.tex\n m.needsUpdate = true\n\n wm.uniforms.map.value = this.tex\n wm.needsUpdate = true\n\n pm.uniforms.map.value = this.tex\n pm.needsUpdate = true\n }\n\n makeTexture () {\n if (this.tex) this.tex.dispose()\n this.tex = makePointTexture({ delta: this.parameters.edgeBleach })\n }\n\n getDefines (type?: BufferTypes) {\n const defines = super.getDefines(type)\n\n if (this.parameters.sizeAttenuation) {\n defines.USE_SIZEATTENUATION = 1\n }\n\n if (this.parameters.useTexture) {\n defines.USE_MAP = 1\n }\n\n if (this.parameters.alphaTest > 0 && this.parameters.alphaTest <= 1) {\n defines.ALPHATEST = this.parameters.alphaTest.toPrecision(2)\n }\n\n return defines\n }\n\n setUniforms (data: any) {\n if (data && data.edgeBleach !== undefined) {\n this.makeTexture()\n data.map = this.tex\n }\n\n super.setUniforms(data)\n }\n\n dispose () {\n super.dispose()\n\n if (this.tex) this.tex.dispose()\n }\n}\n\nBufferRegistry.add('point', PointBuffer)\n\nexport default PointBuffer\n","/**\n * @file Dot Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { ExtensionFragDepth } from '../globals'\nimport { defaults } from '../utils'\nimport Representation, { RepresentationParameters } from './representation'\nimport Volume from '../surface/volume'\nimport FilteredVolume from '../surface/filtered-volume'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport PointBuffer from '../buffer/point-buffer'\nimport Surface from '../surface/surface';\nimport Viewer from '../viewer/viewer';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\n\nexport interface DotDataFields {\n color?: boolean,\n radius?: boolean,\n scale?: boolean\n}\n\n/**\n * Dot representation parameter object. Extends {@link RepresentationParameters}\n *\n * @typedef {Object} DotRepresentationParameters - dot representation parameters\n *\n * @property {String} thresholdType - Meaning of the threshold values. Either *value* for the literal value or *sigma* as a factor of the sigma of the data. For volume data only.\n * @property {Number} thresholdMin - Minimum value to be displayed. For volume data only.\n * @property {Number} thresholdMax - Maximum value to be displayed. For volume data only.\n * @property {Number} thresholdOut - Show only values falling outside of the treshold minumum and maximum. For volume data only.\n */\nexport interface DotRepresentationParameters extends RepresentationParameters {\n thresholdType: 'value'|'value'|'sigma'|'sigma'\n thresholdMin: number\n thresholdMax: number\n thresholdOut: boolean\n dotType: ''|'sphere'|'point'\n radiusType: ''|'value'|'abs-value'|'value-min'|'deviation'|'size'|'radius' //TODO had to add 'radius' because of test in line 333\n radius: number\n scale: number\n sphereDetail: number\n disableImpostor: boolean\n pointSize: number\n sizeAttenuation: boolean\n sortParticles: boolean\n useTexture: boolean\n alphaTest: number\n forceTransparent: boolean\n edgeBleach: number\n}\n/**\n * Dot representation\n */\nclass DotRepresentation extends Representation {\n protected thresholdType: 'value'|'value'|'sigma'|'sigma'\n protected thresholdMin: number\n protected thresholdMax: number\n protected thresholdOut: boolean\n protected dotType: ''|'sphere'|'point'\n protected radiusType: ''|'value'|'abs-value'|'value-min'|'deviation'|'size'|'radius' //TODO had to add 'radius' because of test in line 333\n protected radius: number\n protected scale: number\n protected sphereDetail: number\n protected disableImpostor: boolean\n protected pointSize: number\n protected sizeAttenuation: boolean\n protected sortParticles: boolean\n protected useTexture: boolean\n protected alphaTest: number\n protected forceTransparent: boolean\n protected edgeBleach: number\n\n protected surface: Surface|undefined\n protected volume: FilteredVolume|undefined\n protected dotBuffer: SphereBuffer|PointBuffer\n /**\n * Create Dot representation object\n * @param {Surface|Volume} surface - the surface or volume to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {DotRepresentationParameters} params - dot representation parameters\n */\n constructor (surface: Surface, viewer: Viewer, params: Partial) {\n super(surface, viewer, params)\n\n this.type = 'dot'\n\n this.parameters = Object.assign({\n\n thresholdType: {\n type: 'select',\n rebuild: true,\n options: {\n 'value': 'value', 'sigma': 'sigma'\n }\n },\n thresholdMin: {\n type: 'number', precision: 3, max: Infinity, min: -Infinity, rebuild: true\n },\n thresholdMax: {\n type: 'number', precision: 3, max: Infinity, min: -Infinity, rebuild: true\n },\n thresholdOut: {\n type: 'boolean', rebuild: true\n },\n dotType: {\n type: 'select',\n rebuild: true,\n options: {\n '': '',\n 'sphere': 'sphere',\n 'point': 'point'\n }\n },\n radiusType: {\n type: 'select',\n options: {\n '': '',\n 'value': 'value',\n 'abs-value': 'abs-value',\n 'value-min': 'value-min',\n 'deviation': 'deviation',\n 'size': 'size'\n }\n },\n radius: {\n type: 'number', precision: 3, max: 10.0, min: 0.001, property: 'size'\n },\n scale: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n sphereDetail: true,\n disableImpostor: true,\n\n pointSize: {\n type: 'number', precision: 1, max: 100, min: 0, buffer: true\n },\n sizeAttenuation: {\n type: 'boolean', buffer: true\n },\n sortParticles: {\n type: 'boolean', rebuild: true\n },\n useTexture: {\n type: 'boolean', buffer: true\n },\n alphaTest: {\n type: 'range', step: 0.001, max: 1, min: 0, buffer: true\n },\n forceTransparent: {\n type: 'boolean', buffer: true\n },\n edgeBleach: {\n type: 'range', step: 0.001, max: 1, min: 0, buffer: true\n }\n\n }, this.parameters, {\n\n colorScheme: {\n type: 'select',\n update: 'color',\n options: {\n '': '',\n 'value': 'value',\n 'uniform': 'uniform',\n 'random': 'random'\n }\n }\n\n })\n\n if (surface instanceof Volume) {\n this.surface = undefined\n this.volume = new FilteredVolume(surface)\n } else {\n this.surface = surface\n this.volume = undefined\n }\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'uniform')\n p.colorValue = defaults(p.colorValue, 0xDDDDDD)\n\n this.thresholdType = defaults(p.thresholdType, 'sigma')\n this.thresholdMin = defaults(p.thresholdMin, 2.0)\n this.thresholdMax = defaults(p.thresholdMax, Infinity)\n this.thresholdOut = defaults(p.thresholdOut, false)\n this.dotType = defaults(p.dotType, 'point')\n this.radius = defaults(p.radius, 0.1)\n this.scale = defaults(p.scale, 1.0)\n\n this.pointSize = defaults(p.pointSize, 1)\n this.sizeAttenuation = defaults(p.sizeAttenuation, true)\n this.sortParticles = defaults(p.sortParticles, false)\n this.useTexture = defaults(p.useTexture, false)\n this.alphaTest = defaults(p.alphaTest, 0.5)\n this.forceTransparent = defaults(p.forceTransparent, false)\n this.edgeBleach = defaults(p.edgeBleach, 0.0)\n\n super.init(p)\n\n this.build()\n }\n\n attach (callback: () => void) {\n this.bufferList.forEach(buffer => {\n this.viewer.add(buffer)\n })\n this.setVisibility(this.visible)\n\n callback()\n }\n\n create () {\n var dotData: SphereBufferData|{} = {}\n\n if (this.volume) {\n var volume = this.volume\n var thresholdMin, thresholdMax\n\n if (this.thresholdType === 'sigma') {\n thresholdMin = volume.getValueForSigma(this.thresholdMin)\n thresholdMax = volume.getValueForSigma(this.thresholdMax)\n } else {\n thresholdMin = this.thresholdMin\n thresholdMax = this.thresholdMax\n }\n volume.setFilter(thresholdMin, thresholdMax, this.thresholdOut)\n\n Object.assign(dotData, {\n position: volume.getDataPosition(),\n color: volume.getDataColor(this.getColorParams())\n })\n if (this.dotType === 'sphere') {\n Object.assign(dotData, {\n radius: volume.getDataSize(this.radius, this.scale),\n picking: volume.getDataPicking()\n })\n }\n } else {\n var surface = this.surface\n Object.assign(dotData, {\n position: (surface as Surface).getPosition(),\n color: (surface as Surface).getColor(this.getColorParams())\n })\n if (this.dotType === 'sphere') {\n Object.assign(dotData, {\n radius: (surface as Surface).getSize(this.radius, this.scale),\n picking: (surface as Surface).getPicking()\n })\n }\n }\n\n if (this.dotType === 'sphere') {\n this.dotBuffer = new SphereBuffer(\n dotData as SphereBufferData,\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: false\n }) as SphereBufferParameters\n ) as SphereGeometryBuffer\n } else {\n this.dotBuffer = new PointBuffer(\n dotData,\n this.getBufferParams({\n pointSize: this.pointSize,\n sizeAttenuation: this.sizeAttenuation,\n sortParticles: this.sortParticles,\n useTexture: this.useTexture,\n alphaTest: this.alphaTest,\n forceTransparent: this.forceTransparent,\n edgeBleach: this.edgeBleach\n })\n )\n }\n\n this.bufferList.push(this.dotBuffer as SphereGeometryBuffer)\n }\n\n update (what: DotDataFields = {}) {\n if (this.bufferList.length === 0) return\n\n const dotData: SphereBufferData|{} = {}\n\n if (what.color) {\n if (this.volume) {\n Object.assign(dotData, {\n color: this.volume.getDataColor(\n this.getColorParams()\n )\n })\n } else {\n Object.assign(dotData, {\n color: (this.surface as Surface).getColor(\n this.getColorParams()\n )\n })\n }\n }\n\n if (this.dotType === 'sphere' && (what.radius || what.scale)) {\n if (this.volume) {\n Object.assign(dotData, {\n radius: this.volume.getDataSize(\n this.radius, this.scale\n )\n })\n } else {\n Object.assign(dotData, {\n radius: (this.surface as Surface).getSize(\n this.radius, this.scale\n )\n })\n }\n }\n\n (this.dotBuffer as SphereGeometryBuffer).setAttributes(dotData)\n }\n\n setParameters (params: Partial, what: DotDataFields = {}, rebuild: boolean) {\n \n if (params && params.thresholdType !== undefined &&\n this.volume instanceof Volume\n ) {\n if (this.thresholdType === 'value' &&\n params.thresholdType === 'sigma'\n ) {\n this.thresholdMin = this.volume.getSigmaForValue(\n this.thresholdMin\n )\n this.thresholdMax = this.volume.getSigmaForValue(\n this.thresholdMax\n )\n } else if (this.thresholdType === 'sigma' &&\n params.thresholdType === 'value'\n ) {\n this.thresholdMin = this.volume.getValueForSigma(\n this.thresholdMin\n )\n this.thresholdMax = this.volume.getValueForSigma(\n this.thresholdMax\n )\n }\n\n this.thresholdType = params.thresholdType\n }\n\n if (params && params.radiusType !== undefined) {\n if (params.radiusType === 'radius') {\n this.radius = 0.1\n } else {\n this.radius = parseFloat(params.radiusType)\n }\n what.radius = true\n if (this.dotType === 'sphere' &&\n (!ExtensionFragDepth || this.disableImpostor)\n ) {\n rebuild = true\n }\n }\n\n if (params && params.radius !== undefined) {\n what.radius = true\n if (this.dotType === 'sphere' &&\n (!ExtensionFragDepth || this.disableImpostor)\n ) {\n rebuild = true\n }\n }\n\n if (params && params.scale !== undefined) {\n what.scale = true\n if (this.dotType === 'sphere' &&\n (!ExtensionFragDepth || this.disableImpostor)\n ) {\n rebuild = true\n }\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nexport default DotRepresentation\n","/**\n * @file Image Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport {\n // @ts-ignore: unused import Vector3, Matrix4 required for declaration only\n Vector2, Vector3, Matrix4, BufferAttribute, DataTexture,\n NormalBlending, NearestFilter, LinearFilter\n} from 'three'\n\nimport '../shader/Image.vert'\nimport '../shader/Image.frag'\n\nimport { Picker } from '../utils/picker'\nimport Buffer, { BufferDefaultParameters, BufferParameterTypes, BufferTypes } from './buffer'\n\n\nconst quadIndices = new Uint16Array([\n 0, 1, 2,\n 1, 3, 2\n])\n\nconst quadUvs = new Float32Array([\n 0, 1,\n 0, 0,\n 1, 1,\n 1, 0\n])\n\ntype ImageFilterTypes = 'nearest'|'linear'|'cubic-bspline'|'cubic-catmulrom'|'cubic-mitchell'\n\nexport interface ImageBufferData {\n position: Float32Array\n imageData: Uint8Array\n width: number\n height: number\n\n picking?: Picker\n}\n\nexport const ImageBufferDefaultParameters = Object.assign({\n filter: 'nearest' as ImageFilterTypes,\n forceTransparent: true\n}, BufferDefaultParameters)\nexport type ImageBufferParameters = typeof ImageBufferDefaultParameters\n\nexport const ImageBufferParameterTypes = Object.assign({\n filter: { updateShader: true, uniform: true }\n}, BufferParameterTypes)\n\n/**\n * Image buffer. Draw a single image. Optionally interpolate.\n */\nclass ImageBuffer extends Buffer {\n parameterTypes = ImageBufferParameterTypes\n get defaultParameters() { return ImageBufferDefaultParameters }\n parameters: ImageBufferParameters\n\n alwaysTransparent = true\n hasWireframe = false\n vertexShader = 'Image.vert'\n fragmentShader = 'Image.frag'\n\n tex: DataTexture\n pickingTex: DataTexture\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position - image position\n * @param {Float32Array} data.imageData - image data, rgba channels\n * @param {Float32Array} data.width - image width\n * @param {Float32Array} data.height - image height\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n */\n constructor (data: ImageBufferData, params: ImageBufferParameters) {\n super({\n position: data.position,\n index: quadIndices,\n picking: data.picking\n }, params)\n\n const {imageData, width, height} = data\n\n const tex = new DataTexture(imageData, width, height)\n tex.flipY = true\n this.tex = tex\n\n const n = imageData.length\n const pickingData = new Uint8Array(n)\n for (let i = 0; i < n; i += 4) {\n const j = i / 4\n pickingData[ i ] = j >> 16 & 255\n pickingData[ i + 1 ] = j >> 8 & 255\n pickingData[ i + 2 ] = j & 255\n }\n\n const pickingTex = new DataTexture(pickingData, width, height)\n pickingTex.flipY = true\n pickingTex.minFilter = NearestFilter\n pickingTex.magFilter = NearestFilter\n this.pickingTex = pickingTex\n\n this.addUniforms({\n 'map': { value: tex },\n 'pickingMap': { value: pickingTex },\n 'mapSize': { value: new Vector2(width, height) }\n })\n\n this.geometry.setAttribute('uv', new BufferAttribute(quadUvs, 2))\n }\n\n getDefines (type: BufferTypes) {\n const defines = super.getDefines(type)\n const filter = this.parameters.filter\n\n if (filter.startsWith('cubic')) {\n defines.CUBIC_INTERPOLATION = 1\n if (filter.endsWith('bspline')) {\n defines.BSPLINE_FILTER = 1\n } else if (filter.endsWith('catmulrom')) {\n defines.CATMULROM_FILTER = 1\n } else if (filter.endsWith('mitchell')) {\n defines.MITCHELL_FILTER = 1\n }\n }\n\n return defines\n }\n\n updateTexture () {\n const tex = this.tex\n const filter = this.parameters.filter\n\n if (filter.startsWith('cubic')) {\n tex.minFilter = NearestFilter\n tex.magFilter = NearestFilter\n } else if (filter === 'linear') {\n tex.minFilter = LinearFilter\n tex.magFilter = LinearFilter\n } else { // filter === \"nearest\"\n tex.minFilter = NearestFilter\n tex.magFilter = NearestFilter\n }\n\n tex.needsUpdate = true\n this.pickingTex.needsUpdate = true\n }\n\n makeMaterial () {\n super.makeMaterial()\n this.updateTexture()\n\n const m = this.material\n m.uniforms.map.value = this.tex\n m.blending = NormalBlending\n m.needsUpdate = true\n\n const wm = this.wireframeMaterial\n wm.uniforms.map.value = this.tex\n wm.blending = NormalBlending\n wm.needsUpdate = true\n\n const pm = this.pickingMaterial\n pm.uniforms.map.value = this.tex\n pm.uniforms.pickingMap.value = this.pickingTex\n pm.blending = NormalBlending\n pm.needsUpdate = true\n }\n\n setUniforms (data: any) { // TODO\n if (data && data.filter !== undefined) {\n this.updateTexture()\n data.map = this.tex\n }\n\n super.setUniforms(data)\n }\n}\n\nexport default ImageBuffer\n","/**\n * @file Volume Slice\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { SlicePicker } from '../utils/picker'\nimport { Volume } from '../ngl';\nimport { SliceRepresentationParameters } from '../representation/slice-representation';\n\nclass VolumeSlice {\n dimension: 'x'|'y'|'z'\n positionType: 'percent'|'coordinate'\n position: number\n thresholdType: 'sigma'|'value'\n thresholdMin: number\n thresholdMax: number\n normalize: boolean\n volume: Volume\n\n constructor (volume: Volume, params: Partial) {\n const p = params || {}\n\n this.dimension = defaults(p.dimension, 'x')\n this.positionType = defaults(p.positionType, 'percent')\n this.position = defaults(p.position, 30)\n this.thresholdType = defaults(p.thresholdType, 'sigma')\n this.thresholdMin = defaults(p.thresholdMin, -Infinity)\n this.thresholdMax = defaults(p.thresholdMax, Infinity)\n this.normalize = defaults(p.normalize, false)\n\n this.volume = volume\n }\n\n getPositionFromCoordinate (coord: number) {\n const dim = this.dimension\n const v = this.volume\n const m = v.matrix\n\n const mp = new Vector3().setFromMatrixPosition(m)[ dim ]\n const ms = new Vector3().setFromMatrixScale(m)[ dim ]\n\n let vn\n if (dim === 'x') {\n vn = v.nx\n } else if (dim === 'y') {\n vn = v.ny\n } else {\n vn = v.nz\n }\n\n return Math.round((((coord - mp) / (vn / 100)) + 1) / ms)\n }\n\n getData (params: any) {\n params = params || {}\n\n const v = this.volume\n const d = v.data\n const m = v.matrix\n\n let p: number\n if (this.positionType === 'coordinate') {\n p = this.getPositionFromCoordinate(this.position)\n } else {\n p = this.position\n }\n\n function pos (dimLen: number) {\n return Math.round((dimLen / 100) * (p - 1))\n }\n\n function index (x: number, y: number, z: number, i: number) {\n return (z * v.ny * v.nx + y * v.nx + x) * 3 + i\n }\n\n const position = new Float32Array(4 * 3)\n const vec = new Vector3()\n\n let width, height\n let x\n let y\n let z\n let x0 = 0\n let y0 = 0\n let z0 = 0\n let nx = v.nx\n let ny = v.ny\n let nz = v.nz\n\n function setVec (x: number, y: number, z: number, offset: number) {\n vec.set(x, y, z).applyMatrix4(m).toArray(position as any, offset)\n }\n\n if (this.dimension === 'x') {\n x = pos(v.nx)\n y = v.ny - 1\n z = v.nz - 1\n\n width = v.nz\n height = v.ny\n\n x0 = x\n nx = x0 + 1\n\n setVec(x, 0, 0, 0)\n setVec(x, y, 0, 3)\n setVec(x, 0, z, 6)\n setVec(x, y, z, 9)\n } else if (this.dimension === 'y') {\n x = v.nx - 1\n y = pos(v.ny)\n z = v.nz - 1\n\n width = v.nz\n height = v.nx\n\n y0 = y\n ny = y0 + 1\n\n setVec(0, y, 0, 0)\n setVec(x, y, 0, 3)\n setVec(0, y, z, 6)\n setVec(x, y, z, 9)\n } else if (this.dimension === 'z') {\n x = v.nx - 1\n y = v.ny - 1\n z = pos(v.nz)\n\n width = v.nx\n height = v.ny\n\n z0 = z\n nz = z0 + 1\n\n setVec(0, 0, z, 0)\n setVec(0, y, z, 3)\n setVec(x, 0, z, 6)\n setVec(x, y, z, 9)\n }\n\n let i = 0\n let j = 0\n const imageData = new Uint8Array(width * height * 4)\n const pickingArray = new Float32Array(width * height)\n\n let tMin, tMax\n if (this.thresholdType === 'sigma') {\n tMin = v.getValueForSigma(this.thresholdMin)\n tMax = v.getValueForSigma(this.thresholdMax)\n } else {\n tMin = this.thresholdMin\n tMax = this.thresholdMax\n }\n\n const cp = Object.assign({}, params.colorParams, { volume: v })\n if (this.normalize) {\n cp.domain = [ 0, 1 ]\n }\n const colormaker = ColormakerRegistry.getScheme(cp)\n const tmp = new Float32Array(3)\n const scale = colormaker.getScale()\n\n let min = 0, max, diff = 0\n if (this.normalize) {\n min = +Infinity\n max = -Infinity\n for (let iy = y0; iy < ny; ++iy) {\n for (let ix = x0; ix < nx; ++ix) {\n for (let iz = z0; iz < nz; ++iz) {\n const idx = index(ix, iy, iz, 0) / 3\n const val = d[ idx ]\n if (val < min) min = val\n if (val > max) max = val\n }\n }\n }\n diff = max - min\n }\n\n for (let iy = y0; iy < ny; ++iy) {\n for (let ix = x0; ix < nx; ++ix) {\n for (let iz = z0; iz < nz; ++iz) {\n const idx = index(ix, iy, iz, 0) / 3\n let val = d[ idx ]\n if (this.normalize) {\n val = (val - min) / diff\n }\n\n colormaker.colorToArray(scale(val), tmp)\n imageData[ i ] = Math.round(tmp[ 0 ] * 255)\n imageData[ i + 1 ] = Math.round(tmp[ 1 ] * 255)\n imageData[ i + 2 ] = Math.round(tmp[ 2 ] * 255)\n imageData[ i + 3 ] = (val > tMin && val < tMax) ? 255 : 0\n\n pickingArray[ j ] = idx\n\n ++j\n i += 4\n }\n }\n }\n\n const picking = new SlicePicker(pickingArray, v)\n\n return { position, imageData, width, height, picking }\n }\n}\n\nexport default VolumeSlice\n","/**\n * @file Slice Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport Representation, { RepresentationParameters } from './representation'\nimport ImageBuffer, { ImageBufferParameters, ImageBufferData } from '../buffer/image-buffer'\nimport VolumeSlice from '../surface/volume-slice'\nimport Viewer from '../viewer/viewer';\nimport { Volume } from '../ngl';\n\n/**\n * Slice representation parameter object. Extends {@link RepresentationParameters}\n *\n * @typedef {Object} SliceRepresentationParameters - slice representation parameters\n *\n * @property {String} filter - filter applied to map the volume data on the slice, one of \"nearest\", \"linear\", \"cubic-bspline\", \"cubic-catmulrom\", \"cubic-mitchell\".\n * @property {String} positionType - Meaning of the position value. Either \"percent\" od \"coordinate\".\n * @property {Number} position - position of the slice.\n * @property {String} dimension - one of \"x\", \"y\" or \"z\"\n * @property {String} thresholdType - Meaning of the threshold values. Either *value* for the literal value or *sigma* as a factor of the sigma of the data. For volume data only.\n * @property {Number} thresholdMin - Minimum value to be displayed. For volume data only.\n * @property {Number} thresholdMax - Maximum value to be displayed. For volume data only.\n * @property {Boolean} normalize - Flag indicating wheather to normalize the data in a slice when coloring.\n */\nexport interface SliceRepresentationParameters extends RepresentationParameters {\n filter: 'nearest'|'linear'|'cubic-bspline'|'cubic-catmulrom'|'cubic-mitchell'\n positionType: 'percent'|'coordinate'\n position: number\n dimension: 'x'|'y'|'z'\n thresholdType: 'value'|'sigma'\n thresholdMin: number\n thresholdMax: number\n normalize: boolean\n}\n/**\n * Slice representation\n */\nclass SliceRepresentation extends Representation {\n protected filter: 'nearest'|'linear'|'cubic-bspline'|'cubic-catmulrom'|'cubic-mitchell'\n protected positionType: 'percent'|'coordinate'\n protected position: number\n protected dimension: 'x'|'y'|'z'\n protected thresholdType: 'value'|'sigma'\n protected thresholdMin: number\n protected thresholdMax: number\n protected normalize: boolean\n protected volume: Volume\n /**\n * Create Slice representation object\n * @param {Volume} surface - the volume to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {SliceRepresentationParameters} params - slice representation parameters\n */\n constructor (volume: Volume, viewer: Viewer, params: Partial) {\n super(volume, viewer, params)\n\n this.type = 'slice'\n\n this.parameters = Object.assign({\n\n filter: {\n type: 'select',\n buffer: true,\n options: {\n 'nearest': 'nearest',\n 'linear': 'linear',\n 'cubic-bspline': 'cubic-bspline',\n 'cubic-catmulrom': 'cubic-catmulrom',\n 'cubic-mitchell': 'cubic-mitchell'\n }\n },\n positionType: {\n type: 'select',\n rebuild: true,\n options: {\n 'percent': 'percent', 'coordinate': 'coordinate'\n }\n },\n position: {\n type: 'range',\n step: 0.1,\n max: 100,\n min: 1,\n rebuild: true\n },\n dimension: {\n type: 'select',\n rebuild: true,\n options: {\n 'x': 'x', 'y': 'y', 'z': 'z'\n }\n },\n thresholdType: {\n type: 'select',\n rebuild: true,\n options: {\n 'value': 'value', 'sigma': 'sigma'\n }\n },\n thresholdMin: {\n type: 'number', precision: 3, max: Infinity, min: -Infinity, rebuild: true\n },\n thresholdMax: {\n type: 'number', precision: 3, max: Infinity, min: -Infinity, rebuild: true\n },\n normalize: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n\n flatShaded: null,\n side: null,\n wireframe: null,\n linewidth: null,\n colorScheme: null,\n\n roughness: null,\n metalness: null,\n diffuse: null\n\n })\n\n this.volume = volume\n\n this.init(params)\n }\n\n init (params: Partial) {\n const v = this.volume\n const p = params || {}\n p.colorDomain = defaults(p.colorDomain, [ v.min, v.max ])\n p.colorScheme = defaults(p.colorScheme, 'value')\n p.colorScale = defaults(p.colorScale, 'Spectral')\n\n this.colorScheme = 'value'\n this.dimension = defaults(p.dimension, 'x')\n this.filter = defaults(p.filter, 'cubic-bspline')\n this.positionType = defaults(p.positionType, 'percent')\n this.position = defaults(p.position, 30)\n this.thresholdType = defaults(p.thresholdType, 'sigma')\n this.thresholdMin = defaults(p.thresholdMin, -Infinity)\n this.thresholdMax = defaults(p.thresholdMax, Infinity)\n this.normalize = defaults(p.normalize, false)\n\n super.init(p)\n\n this.build()\n }\n\n attach (callback: () => void) {\n this.bufferList.forEach(buffer => {\n this.viewer.add(buffer)\n })\n this.setVisibility(this.visible)\n\n callback()\n }\n\n create () {\n const volumeSlice = new VolumeSlice(this.volume, {\n positionType: this.positionType,\n position: this.position,\n dimension: this.dimension,\n thresholdType: this.thresholdType,\n thresholdMin: this.thresholdMin,\n thresholdMax: this.thresholdMax,\n normalize: this.normalize\n })\n\n const sliceBuffer = new ImageBuffer(\n volumeSlice.getData({ colorParams: this.getColorParams() }) as ImageBufferData,\n this.getBufferParams({\n filter: this.filter\n }) as ImageBufferParameters\n )\n\n this.bufferList.push(sliceBuffer)\n }\n}\n\nexport default SliceRepresentation\n","/**\n * @file Representation Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, RepresentationRegistry } from '../globals'\n\nimport Viewer from '../viewer/viewer'\nimport Structure from '../structure/structure'\nimport Surface from '../surface/surface'\nimport Volume from '../surface/volume'\nimport Shape from '../geometry/shape'\n\nimport BufferRepresentation from './buffer-representation'\nimport SurfaceRepresentation from './surface-representation'\nimport DotRepresentation from './dot-representation'\nimport SliceRepresentation from './slice-representation'\n\nfunction logReprUnknown (type: string) {\n Log.error(`makeRepresentation: representation type ${type} unknown`)\n}\n\nexport function makeRepresentation (type: string, object: any, viewer: Viewer, params: any) { // TODO\n if (Debug) Log.time('makeRepresentation ' + type)\n\n var ReprClass\n\n if (object instanceof Structure) {\n ReprClass = RepresentationRegistry.get(type)\n\n if (!ReprClass) {\n logReprUnknown(type)\n return\n }\n } else if (object instanceof Surface) {\n if (type === 'surface') {\n ReprClass = SurfaceRepresentation\n } else if (type === 'dot') {\n ReprClass = DotRepresentation\n } else {\n logReprUnknown(type)\n return\n }\n } else if (object instanceof Volume) {\n if (type === 'surface') {\n ReprClass = SurfaceRepresentation\n } else if (type === 'dot') {\n ReprClass = DotRepresentation\n } else if (type === 'slice') {\n ReprClass = SliceRepresentation\n } else {\n logReprUnknown(type)\n return\n }\n } else if (object instanceof Shape) {\n ReprClass = BufferRepresentation\n object = object.getBufferList()\n } else if (type === 'buffer') {\n ReprClass = BufferRepresentation\n } else {\n Log.error('makeRepresentation: object ' + object + ' unknown')\n return\n }\n\n const repr = new ReprClass(object, viewer, params)\n\n if (Debug) Log.timeEnd('makeRepresentation ' + type)\n\n return repr\n}\n","/**\n * @file Element\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { createParams } from '../utils'\nimport { generateUUID } from '../math/math-utils'\nimport Stage from '../stage/stage'\n\nexport const ElementDefaultParameters = {\n name: 'some element',\n status: ''\n}\nexport type ElementParameters = typeof ElementDefaultParameters\n\nexport interface ElementSignals {\n statusChanged: Signal // on status change\n nameChanged: Signal // on name change\n disposed: Signal // on dispose\n}\n\n/**\n * Element base class\n */\nabstract class Element {\n /**\n * Events emitted by the element\n */\n signals: ElementSignals = {\n statusChanged: new Signal(),\n nameChanged: new Signal(),\n disposed: new Signal()\n }\n readonly parameters: ElementParameters\n readonly uuid: string\n\n get defaultParameters() { return ElementDefaultParameters }\n\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {ElementParameters} params - component parameters\n */\n constructor (readonly stage: Stage, params: Partial = {}) {\n this.parameters = createParams(params, this.defaultParameters)\n this.uuid = generateUUID()\n }\n\n abstract get type (): string\n\n get name () { return this.parameters.name }\n\n setStatus (value: string) {\n this.parameters.status = value\n this.signals.statusChanged.dispatch(value)\n\n return this\n }\n\n setName (value: string) {\n this.parameters.name = value\n this.signals.nameChanged.dispatch(value)\n\n return this\n }\n\n dispose () {\n this.signals.disposed.dispatch()\n }\n}\n\nexport default Element\n","/**\n * @file Representation Element\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\nimport { Color } from 'three'\n\nimport Stage from '../stage/stage'\nimport Representation, { RepresentationParameters } from '../representation/representation'\nimport Component from './component'\nimport Element, { ElementDefaultParameters, ElementSignals } from './element'\n\nexport const RepresentationElementDefaultParameters = Object.assign({\n visible: true\n}, ElementDefaultParameters)\nexport type RepresentationElementParameters = typeof RepresentationElementDefaultParameters\n\nexport interface RepresentationElementSignals extends ElementSignals {\n visibilityChanged: Signal // on visibility change\n parametersChanged: Signal // on parameters change\n}\n\n/**\n * Element wrapping a {@link Representation} object\n */\nclass RepresentationElement extends Element {\n signals: RepresentationElementSignals\n parameters: RepresentationElementParameters\n get defaultParameters() { return RepresentationElementDefaultParameters }\n\n repr: Representation\n\n /**\n * Create representation component\n * @param {Stage} stage - stage object the component belongs to\n * @param {Representation} repr - representation object to wrap\n * @param {RepresentationParameters} [params] - component parameters\n * @param {Component} [parent] - parent component\n */\n constructor (stage: Stage, repr: Representation, params: Partial = {}, readonly parent: Component) {\n super(stage, Object.assign({ name: repr.type }, params))\n\n this.signals = Object.assign({\n visibilityChanged: new Signal(),\n parametersChanged: new Signal()\n }, this.signals)\n\n this.setRepresentation(repr)\n }\n\n get visible () { return this.parameters.visible }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'representation' }\n\n getType () {\n return this.repr.type\n }\n\n setRepresentation (repr: Representation) {\n this._disposeRepresentation()\n this.repr = repr\n // this.name = repr.type;\n this.stage.tasks.listen(this.repr.tasks)\n this.updateVisibility()\n }\n\n _disposeRepresentation () {\n if (this.repr) {\n this.stage.tasks.unlisten(this.repr.tasks)\n this.repr.dispose()\n }\n }\n\n dispose () {\n if (this.parent && this.parent.hasRepresentation(this)) {\n this.parent.removeRepresentation(this)\n } else {\n this._disposeRepresentation()\n this.signals.disposed.dispatch()\n }\n }\n\n /**\n * Set the visibility of the component, takes parent visibility into account\n * @param {Boolean} value - visibility flag\n * @return {RepresentationElement} this object\n */\n setVisibility (value: boolean) {\n this.parameters.visible = value\n this.updateVisibility()\n this.signals.visibilityChanged.dispatch(this.parameters.visible)\n\n return this\n }\n\n getVisibility () {\n if (this.parent) {\n return this.parent.parameters.visible && this.parameters.visible\n } else {\n return this.parameters.visible\n }\n }\n\n /**\n * Toggle visibility of the component, takes parent visibility into account\n * @return {RepresentationElement} this object\n */\n toggleVisibility () {\n return this.setVisibility(!this.parameters.visible)\n }\n\n updateVisibility () {\n this.repr.setVisibility(this.getVisibility())\n }\n\n /**\n * Set selection\n * @param {Object} what - flags indicating what attributes to update\n * @param {Boolean} what.position - update position attribute\n * @param {Boolean} what.color - update color attribute\n * @param {Boolean} what.radius - update radius attribute\n * @return {RepresentationElement} this object\n */\n update (what: any) { // TODO\n (this.repr as any).update(what) // TODO\n\n return this\n }\n\n build (params?: any) { // TODO\n this.repr.build(params)\n\n return this\n }\n\n /**\n * Set selection\n * @param {String} string - selection string\n * @return {RepresentationElement} this object\n */\n setSelection (string: string) {\n const repr: any = this.repr // TODO\n\n if (repr.setSelection) {\n repr.setSelection(string)\n }\n\n return this\n }\n\n /**\n * Set representation parameters\n * @param {RepresentationParameters} params - parameter object\n * @return {RepresentationElement} this object\n */\n setParameters (params: any) { // TODO\n this.repr.setParameters(params)\n this.signals.parametersChanged.dispatch(\n this.repr.getParameters()\n )\n\n return this\n }\n\n /**\n * Get representation parameters\n * @return {RepresentationParameters} parameter object\n */\n getParameters (): Partial {\n return this.repr.getParameters()\n }\n\n /**\n * Set color\n * @param {String|Color|Hex} value - color value\n * @return {RepresentationElement} this object\n */\n setColor (value: string|number|Color) {\n this.repr.setColor(value)\n\n return this\n }\n}\n\nexport default RepresentationElement\n","\n/**\n * @file Component\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Quaternion, Matrix4, Euler, Box3 } from 'three'\nimport { Signal } from 'signals'\n\nimport { defaults, createParams } from '../utils'\nimport { generateUUID } from '../math/math-utils'\nimport Annotation, { AnnotationParams } from '../component/annotation'\nimport ComponentControls from '../controls/component-controls'\nimport { makeRepresentation } from '../representation/representation-utils'\nimport RepresentationElement from './representation-element'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\n\nconst _m = new Matrix4()\nconst _v = new Vector3()\n\nexport const ComponentDefaultParameters = {\n name: '',\n status: '',\n visible: true\n}\nexport type ComponentParameters = typeof ComponentDefaultParameters\n\n\nexport interface ComponentSignals {\n representationAdded: Signal // when a representation is added\n representationRemoved: Signal // when a representation is removed\n visibilityChanged: Signal // on visibility change\n matrixChanged: Signal // on matrix change\n statusChanged: Signal // on status change\n nameChanged: Signal // on name change\n disposed: Signal // on dispose\n}\n\n/**\n * Base class for components\n */\nabstract class Component {\n /**\n * Events emitted by the component\n */\n readonly signals: ComponentSignals = {\n representationAdded: new Signal(),\n representationRemoved: new Signal(),\n visibilityChanged: new Signal(),\n matrixChanged: new Signal(),\n statusChanged: new Signal(),\n nameChanged: new Signal(),\n disposed: new Signal()\n }\n\n readonly parameters: ComponentParameters\n get defaultParameters () { return ComponentDefaultParameters }\n\n readonly uuid: string\n readonly viewer: Viewer\n\n reprList: RepresentationElement[] = []\n annotationList: Annotation[] = []\n\n matrix = new Matrix4()\n position = new Vector3()\n quaternion = new Quaternion()\n scale = new Vector3(1, 1, 1)\n transform = new Matrix4()\n\n controls: ComponentControls\n\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {ComponentParameters} params - parameter object\n */\n constructor (readonly stage: Stage, readonly object: any, params: Partial = {}) {\n this.parameters = createParams(params, this.defaultParameters)\n this.uuid = generateUUID()\n this.viewer = stage.viewer\n\n this.controls = new ComponentControls(this)\n }\n\n abstract get type (): string\n\n get name () { return this.parameters.name }\n get status () { return this.parameters.status }\n get visible () { return this.parameters.visible }\n\n /**\n * Set position transform\n *\n * @example\n * // translate by 25 angstrom along x axis\n * component.setPosition([ 25, 0, 0 ]);\n *\n * @param {Vector3|Array} p - the coordinates\n * @return {Component} this object\n */\n setPosition (p: [number, number, number]|Vector3) {\n if (Array.isArray(p)) {\n this.position.fromArray(p)\n } else {\n this.position.copy(p)\n }\n this.updateMatrix()\n\n return this\n }\n\n /**\n * Set local rotation transform\n * (for global rotation use setTransform)\n *\n * @example\n * // rotate by 2 degree radians on x axis\n * component.setRotation( [ 2, 0, 0 ] );\n *\n * @param {Quaternion|Euler|Array} r - the rotation\n * @return {Component} this object\n */\n setRotation (r: [number, number, number]|Euler|Quaternion) {\n if (Array.isArray(r)) {\n if (r.length === 3) {\n const e = new Euler().fromArray(r)\n this.quaternion.setFromEuler(e)\n } else {\n this.quaternion.fromArray(r)\n }\n } else if (r instanceof Euler) {\n this.quaternion.setFromEuler(r)\n } else {\n this.quaternion.copy(r)\n }\n this.updateMatrix()\n\n return this\n }\n\n /**\n * Set scale transform\n *\n * @example\n * // scale by factor of two\n * component.setScale( 2 );\n *\n * @param {Number} s - the scale\n * @return {Component} this object\n */\n setScale (s: number) {\n this.scale.set(s, s, s)\n this.updateMatrix()\n\n return this\n }\n\n /**\n * Set general transform. Is applied before and in addition\n * to the position, rotation and scale transformations\n *\n * @example\n * component.setTransform( matrix );\n *\n * @param {Matrix4} m - the matrix\n * @return {Component} this object\n */\n setTransform (m: Matrix4) {\n this.transform.copy(m)\n this.updateMatrix()\n\n return this\n }\n\n updateMatrix () {\n const c = this.getCenterUntransformed(_v)\n this.matrix.makeTranslation(-c.x, -c.y, -c.z)\n\n _m.makeRotationFromQuaternion(this.quaternion)\n this.matrix.premultiply(_m)\n\n _m.makeScale(this.scale.x, this.scale.y, this.scale.z)\n this.matrix.premultiply(_m)\n\n const p = this.position\n _m.makeTranslation(p.x + c.x, p.y + c.y, p.z + c.z)\n this.matrix.premultiply(_m)\n\n this.matrix.premultiply(this.transform)\n\n this.updateRepresentationMatrices()\n\n this.stage.viewer.updateBoundingBox()\n\n this.signals.matrixChanged.dispatch(this.matrix)\n }\n\n /**\n * Propogates our matrix to each representation\n */\n updateRepresentationMatrices () {\n this.reprList.forEach(repr => {\n repr.setParameters({ matrix: this.matrix })\n })\n }\n\n /**\n * Add an anotation object\n * @param {Vector3} position - the 3d position\n * @param {String|Element} content - the HTML content\n * @param {Object} [params] - parameters\n * @param {Integer} params.offsetX - 2d offset in x direction\n * @param {Integer} params.offsetY - 2d offset in y direction\n * @return {Annotation} the added annotation object\n */\n addAnnotation (position: Vector3, content: string|HTMLElement, params: AnnotationParams) {\n const annotation = new Annotation(this, position, content, params)\n this.annotationList.push(annotation)\n\n return annotation\n }\n\n /**\n * Iterator over each annotation and executing the callback\n * @param {Function} callback - function to execute\n * @return {undefined}\n */\n eachAnnotation (callback: (a: Annotation) => void) {\n this.annotationList.slice().forEach(callback)\n }\n\n /**\n * Remove the give annotation from the component\n * @param {Annotation} annotation - the annotation to remove\n * @return {undefined}\n */\n removeAnnotation (annotation: Annotation) {\n const idx = this.annotationList.indexOf(annotation)\n if (idx !== -1) {\n this.annotationList.splice(idx, 1)\n annotation.dispose()\n }\n }\n\n /**\n * Remove all annotations from the component\n * @return {undefined}\n */\n removeAllAnnotations () {\n this.eachAnnotation(annotation => annotation.dispose())\n this.annotationList.length = 0\n }\n\n /**\n * Add a new representation to the component\n * @param {String} type - the name of the representation\n * @param {Object} object - the object on which the representation should be based\n * @param {RepresentationParameters} [params] - representation parameters\n * @return {RepresentationElement} the created representation wrapped into\n * a representation element object\n */\n protected _addRepresentation (type: string, object: any, params: any, hidden = false) { // TODO\n const p = params || {}\n const sp = this.stage.getParameters() as any // TODO\n p.matrix = this.matrix.clone()\n p.quality = p.quality || sp.quality\n p.disableImpostor = defaults(p.disableImpostor, !sp.impostor)\n p.useWorker = defaults(p.useWorker, sp.workerDefault)\n p.visible = defaults(p.visible, true)\n\n const p2 = Object.assign({}, p, { visible: this.parameters.visible && p.visible })\n const repr = makeRepresentation(type, object, this.viewer, p2)\n const reprElem = new RepresentationElement(this.stage, repr, p, this)\n\n if (!hidden) {\n this.reprList.push(reprElem)\n this.signals.representationAdded.dispatch(reprElem)\n }\n return reprElem\n }\n\n abstract addRepresentation (type: any, params: any): any\n\n addBufferRepresentation (buffer: any, params: any) { // TODO\n return this._addRepresentation.call(this, 'buffer', buffer, params)\n }\n\n hasRepresentation (repr: RepresentationElement) {\n return this.reprList.indexOf(repr) !== -1\n }\n\n /**\n * Iterator over each representation and executing the callback\n * @param {Function} callback - function to execute\n * @return {undefined}\n */\n eachRepresentation (callback: (repr: RepresentationElement) => void) {\n this.reprList.slice().forEach(callback)\n }\n\n /**\n * Removes a representation component\n * @param {RepresentationElement} repr - the representation element\n * @return {undefined}\n */\n removeRepresentation (repr: RepresentationElement) {\n const idx = this.reprList.indexOf(repr)\n if (idx !== -1) {\n this.reprList.splice(idx, 1)\n repr.dispose()\n this.signals.representationRemoved.dispatch(repr)\n }\n }\n\n updateRepresentations (what: any) { // TODO\n this.reprList.forEach(repr => repr.update(what))\n this.stage.viewer.requestRender()\n }\n\n /**\n * Removes all representation components\n * @return {undefined}\n */\n removeAllRepresentations () {\n this.eachRepresentation(repr => repr.dispose())\n }\n\n dispose () {\n this.removeAllAnnotations()\n this.removeAllRepresentations()\n\n this.reprList.length = 0\n\n this.signals.disposed.dispatch()\n }\n\n /**\n * Set the visibility of the component, including added representations\n * @param {Boolean} value - visibility flag\n * @return {Component} this object\n */\n setVisibility (value: boolean) {\n this.parameters.visible = value\n\n this.eachRepresentation((repr: RepresentationElement) => repr.updateVisibility())\n this.eachAnnotation((annotation: Annotation) => annotation.updateVisibility())\n\n this.signals.visibilityChanged.dispatch(value)\n\n return this\n }\n\n setStatus (value: string) {\n this.parameters.status = value\n this.signals.statusChanged.dispatch(value)\n\n return this\n }\n\n setName (value: string) {\n this.parameters.name = value\n this.signals.nameChanged.dispatch(value)\n\n return this\n }\n\n /**\n * @return {Box3} the component's bounding box\n */\n getBox (...args: any[]) {\n return this.getBoxUntransformed(...args)\n .clone().applyMatrix4(this.matrix)\n }\n\n /**\n * @return {Vector3} the component's center position\n */\n getCenter (...args: any[]) {\n return this.getCenterUntransformed(...args)\n .clone().applyMatrix4(this.matrix)\n }\n\n getZoom (...args: any[]) {\n return this.stage.getZoomForBox(this.getBox(...args))\n }\n\n /**\n * @abstract\n * @return {Box3} the untransformed component's bounding box\n */\n getBoxUntransformed (...args: any[]): Box3 {\n return new Box3()\n }\n\n getCenterUntransformed (...args: any[]) {\n return this.getBoxUntransformed().getCenter(new Vector3())\n }\n\n /**\n * Automatically center and zoom the component\n * @param {Integer} [duration] - duration of the animation, defaults to 0\n * @return {undefined}\n */\n autoView (duration?: number) {\n this.stage.animationControls.zoomMove(\n this.getCenter(),\n this.getZoom(),\n defaults(duration, 0)\n )\n }\n}\n\nexport default Component\n","/**\n * @file Collection\n * @author Alexander Rose \n * @private\n */\n\nimport Component from './component'\nimport Element from './element'\n\nclass Collection {\n constructor (readonly list: T[] = []) {\n // remove elements from list when they get disposed\n const n = list.length\n\n for (let i = 0; i < n; ++i) {\n const elm = list[ i ]\n elm.signals.disposed.add(this._remove, this)\n }\n }\n\n _remove (elm: T) {\n const idx = this.list.indexOf(elm)\n\n if (idx !== -1) {\n this.list.splice(idx, 1)\n }\n }\n\n get first () {\n return this.list.length > 0 ? this.list[0] : undefined\n }\n\n forEach (fn: (x: T) => any) {\n this.list.forEach(fn)\n\n return this\n }\n\n dispose () {\n return this.forEach((elm) => elm.dispose())\n }\n}\n\nexport default Collection\n","/**\n * @file Component Collection\n * @author Alexander Rose \n * @private\n */\n\nimport RepresentationElement from './representation-element'\nimport Collection from './collection'\nimport { GenericColor } from '../types'\n\nclass RepresentationCollection extends Collection {\n setParameters (params: any) {\n return this.forEach((repr) => repr.setParameters(params))\n }\n\n setVisibility (value: boolean) {\n return this.forEach((repr) => repr.setVisibility(value))\n }\n\n setSelection (string: string) {\n return this.forEach((repr) => repr.setSelection(string))\n }\n\n setColor (color: GenericColor) {\n return this.forEach((repr) => repr.setColor(color))\n }\n\n update (what: any) {\n return this.forEach((repr) => repr.update(what))\n }\n\n build (params?: any) {\n return this.forEach((repr) => repr.build(params))\n }\n\n dispose (params?: any) {\n return this.forEach((repr) => repr.dispose())\n }\n}\n\nexport default RepresentationCollection\n","/**\n * @file Trajectory Component\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport Element, { ElementSignals, ElementDefaultParameters } from './element'\nimport Stage from '../stage/stage'\nimport Trajectory, { TrajectoryParameters } from '../trajectory/trajectory'\nimport TrajectoryPlayer, {\n TrajectoryPlayerDirection, TrajectoryPlayerMode, TrajectoryPlayerInterpolateType\n} from '../trajectory/trajectory-player'\n\n/**\n * Trajectory component parameter object.\n * @typedef {Object} TrajectoryComponentParameters - component parameters\n *\n * @property {String} name - component name\n * @property {Integer} initialFrame - initial frame the trajectory is set to\n * @property {Integer} defaultStep - default step size to be used by trajectory players\n * @property {Integer} defaultTimeout - default timeout to be used by trajectory players\n * @property {String} defaultInterpolateType - one of \"\" (empty string), \"linear\" or \"spline\"\n * @property {Integer} defaultInterpolateStep - window size used for interpolation\n * @property {String} defaultMode - either \"loop\" or \"once\"\n * @property {String} defaultDirection - either \"forward\" or \"backward\"\n */\n\nexport const TrajectoryElementDefaultParameters = Object.assign({\n defaultStep: 1,\n defaultTimeout: 50,\n defaultInterpolateType: '' as TrajectoryPlayerInterpolateType,\n defaultInterpolateStep: 5,\n defaultMode: 'loop' as TrajectoryPlayerMode,\n defaultDirection: 'forward' as TrajectoryPlayerDirection,\n initialFrame: 0\n}, ElementDefaultParameters)\nexport type TrajectoryElementParameters = typeof TrajectoryElementDefaultParameters\n\nexport interface TrajectoryElementSignals extends ElementSignals {\n frameChanged: Signal // on frame change\n playerChanged: Signal // on player change\n countChanged: Signal // when frame count is available\n parametersChanged: Signal // on parameters change\n}\n\n/**\n * Component wrapping a {@link Trajectory} object\n */\nclass TrajectoryElement extends Element {\n signals: TrajectoryElementSignals\n parameters: TrajectoryElementParameters\n get defaultParameters () { return TrajectoryElementDefaultParameters }\n\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {Trajectory} trajectory - the trajectory object\n * @param {TrajectoryComponentParameters} params - component parameters\n * @param {StructureComponent} parent - the parent structure\n */\n constructor (stage: Stage, readonly trajectory: Trajectory, params: Partial = {}) {\n super(stage, Object.assign({ name: trajectory.name }, params))\n\n this.signals = Object.assign(this.signals, {\n frameChanged: new Signal(),\n playerChanged: new Signal(),\n countChanged: new Signal(),\n parametersChanged: new Signal()\n })\n\n // signals\n\n trajectory.signals.frameChanged.add((i: number) => {\n this.signals.frameChanged.dispatch(i)\n })\n\n trajectory.signals.playerChanged.add((player: TrajectoryPlayer) => {\n this.signals.playerChanged.dispatch(player)\n })\n\n trajectory.signals.countChanged.add((n: number) => {\n this.signals.countChanged.dispatch(n)\n })\n\n //\n\n if (params.initialFrame !== undefined) {\n this.setFrame(params.initialFrame)\n }\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'trajectory' }\n\n /**\n * Set the frame of the trajectory\n * @param {Integer} i - frame number\n * @return {undefined}\n */\n setFrame (i: number) {\n this.trajectory.setFrame(i)\n }\n\n /**\n * Set trajectory parameters\n * @param {TrajectoryParameters} params - trajectory parameters\n * @return {undefined}\n */\n setParameters (params: Partial = {}) {\n this.trajectory.setParameters(params)\n this.signals.parametersChanged.dispatch(params)\n }\n\n dispose () {\n this.trajectory.dispose()\n super.dispose()\n }\n}\n\nexport default TrajectoryElement\n","/**\n * @file Frames\n * @author Alexander Rose \n * @private\n */\n\nexport default class Frames {\n coordinates = []\n boxes = []\n times = []\n\n timeOffset = 0\n deltaTime = 1\n\n constructor (readonly name: string, readonly path: string) {}\n\n get type () { return 'Frames' }\n}\n","/**\n * @file Superposition\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\nimport { Debug, Log } from '../globals'\nimport {\n Matrix, svd, meanRows, subRows, transpose,\n multiplyABt, invert3x3, multiply3x3, mat3x3determinant, multiply\n} from '../math/matrix-utils'\nimport Structure from '../structure/structure'\n\nclass Superposition {\n coords1t: Matrix\n coords2t: Matrix\n\n transformationMatrix: Matrix4\n\n mean1: number[]\n mean2: number[]\n\n A = new Matrix(3, 3)\n W = new Matrix(1, 3)\n U = new Matrix(3, 3)\n V = new Matrix(3, 3)\n VH = new Matrix(3, 3)\n R = new Matrix(3, 3)\n\n private tmp = new Matrix(3, 3)\n private c = new Matrix(3, 3)\n\n constructor (atoms1: Structure|Float32Array, atoms2: Structure|Float32Array) {\n // allocate & init data structures\n\n let n1\n if (atoms1 instanceof Structure) {\n n1 = atoms1.atomCount\n } else if (atoms1 instanceof Float32Array) {\n n1 = atoms1.length / 3\n } else {\n return\n }\n\n let n2\n if (atoms2 instanceof Structure) {\n n2 = atoms2.atomCount\n } else if (atoms2 instanceof Float32Array) {\n n2 = atoms2.length / 3\n } else {\n return\n }\n\n const n = Math.min(n1, n2)\n\n const coords1 = new Matrix(3, n)\n const coords2 = new Matrix(3, n)\n\n this.coords1t = new Matrix(n, 3)\n this.coords2t = new Matrix(n, 3)\n\n this.transformationMatrix = new Matrix4()\n\n this.c.data.set([ 1, 0, 0, 0, 1, 0, 0, 0, -1 ])\n\n // prep coords\n\n this.prepCoords(atoms1, coords1, n, false)\n this.prepCoords(atoms2, coords2, n, false)\n\n // superpose\n\n this._superpose(coords1, coords2)\n }\n\n _superpose (coords1: Matrix, coords2: Matrix) {\n this.mean1 = meanRows(coords1)\n this.mean2 = meanRows(coords2)\n\n subRows(coords1, this.mean1)\n subRows(coords2, this.mean2)\n\n transpose(this.coords1t, coords1)\n transpose(this.coords2t, coords2)\n\n multiplyABt(this.A, this.coords2t, this.coords1t)\n\n svd(this.A, this.W, this.U, this.V)\n\n invert3x3(this.V, this.VH)\n multiply3x3(this.R, this.U, this.VH)\n\n if (mat3x3determinant(this.R) < 0.0) {\n if (Debug) Log.log('R not a right handed system')\n\n multiply3x3(this.tmp, this.c, this.VH)\n multiply3x3(this.R, this.U, this.tmp)\n }\n\n //get the transformation matrix\n\n const transformMat_ = new Matrix(4,4)\n const tmp_1 = new Matrix(4,4)\n const tmp_2 = new Matrix(4,4)\n\n const sub = new Matrix(4,4)\n const mult = new Matrix(4,4)\n const add = new Matrix(4,4)\n\n const R = this.R.data\n const M1 = this.mean1\n const M2 = this.mean2\n\n sub.data.set([ 1, 0, 0, -M1[0],\n 0, 1, 0, -M1[1],\n 0, 0, 1, -M1[2],\n 0, 0, 0, 1 ])\n\n mult.data.set([ R[0], R[1], R[2], 0,\n R[3], R[4], R[5], 0,\n R[6], R[7], R[8], 0,\n 0, 0, 0, 1 ])\n\n add.data.set([ 1, 0, 0, M2[0],\n 0, 1, 0, M2[1],\n 0, 0, 1, M2[2],\n 0, 0, 0, 1 ])\n\n transpose(tmp_1,sub)\n multiplyABt(transformMat_,mult,tmp_1)\n transpose(tmp_2,transformMat_)\n multiplyABt(tmp_1,add,tmp_2)\n\n transpose(transformMat_,tmp_1)\n this.transformationMatrix.elements = transformMat_.data as unknown as number[]\n\n }\n\n prepCoords (atoms: Structure|Float32Array, coords: Matrix, n: number, is4X4: boolean) {\n let i = 0\n const cd = coords.data\n\n let c = 3\n let d = n * 3\n\n if (is4X4) {\n d = n * 4\n c = 4\n }\n if (atoms instanceof Structure) {\n atoms.eachAtom(function (a) {\n if (i < d) {\n cd[ i + 0 ] = a.x\n cd[ i + 1 ] = a.y\n cd[ i + 2 ] = a.z\n if (is4X4) cd[ i + 3 ] = 1\n\n i += c\n }\n })\n } else if (atoms instanceof Float32Array) {\n for (; i < d; i += c){\n if (i < d) {\n cd[ i ] = atoms[ i ]\n cd[ i + 1 ] = atoms[ i + 1 ]\n cd[ i + 2 ] = atoms[ i + 2 ]\n if (is4X4) cd[ i + 3 ] = 1\n }\n }\n } else {\n Log.warn('prepCoords: input type unknown')\n }\n }\n\n transform (atoms: Structure|Float32Array) {\n // allocate data structures\n\n let n\n if (atoms instanceof Structure) {\n n = atoms.atomCount\n } else if (atoms instanceof Float32Array) {\n n = atoms.length / 3\n } else {\n return\n }\n\n const coords = new Matrix(4, n)\n const tCoords = new Matrix(n,4)\n\n // prep coords\n\n this.prepCoords(atoms, coords, n, true)\n\n // check for transformation matrix correctness\n\n const transform = this.transformationMatrix\n const det = transform.determinant()\n if (!det){\n return det\n }\n\n // do transform\n\n const mult = new Matrix(4,4)\n mult.data = transform.elements as unknown as Float32Array\n multiply(tCoords,coords,mult)\n\n let i = 0\n const cd = tCoords.data\n if (atoms instanceof Structure) {\n atoms.eachAtom(function (a) {\n a.x = cd[ i ]\n a.y = cd[ i + 1 ]\n a.z = cd[ i + 2 ]\n i += 4\n })\n\n //update transformation matrices for each assembly\n\n const invertTrasform = new Matrix4()\n invertTrasform.getInverse(transform)\n\n const biomolDict = atoms.biomolDict\n\n for (let key in biomolDict) {\n\n if (biomolDict.hasOwnProperty(key)) {\n let assembly = biomolDict[key]\n\n assembly.partList.forEach(function(part){\n\n part.matrixList.forEach(function(mat){\n\n mat.premultiply(transform)\n mat.multiply(invertTrasform)\n\n })\n })\n }\n }\n } else if (atoms instanceof Float32Array) {\n\n const n4 = n * 4\n for (; i < n4; i += 4){\n\n atoms[ i ] = cd[ i ]\n atoms[ i + 1 ] = cd[ i + 1 ]\n atoms[ i + 2 ] = cd[ i + 2 ]\n\n }\n } else {\n Log.warn('transform: input type unknown')\n }\n\n return this.transformationMatrix\n }\n}\nexport default Superposition\n","/**\n * @file Trajectory Player\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { defaults, createParams, updateParams } from '../utils'\nimport Trajectory from './trajectory'\n\nexport type TrajectoryPlayerInterpolateType = ''|'linear'|'spline'\nexport type TrajectoryPlayerMode = 'loop'|'once'\nexport type TrajectoryPlayerDirection = 'forward'|'backward'|'bounce'\n\nexport const TrajectoryPlayerDefaultParameters = {\n step: 1, // how many frames to advance when playing\n timeout: 50, // how many milliseconds to wait between playing frames\n start: 0, // first frame to play\n end: 0, // last frame to play\n interpolateType: '' as TrajectoryPlayerInterpolateType,\n interpolateStep: 5, // window size used for interpolation\n mode: 'loop' as TrajectoryPlayerMode,\n direction: 'forward' as TrajectoryPlayerDirection\n}\nexport type TrajectoryPlayerParameters = typeof TrajectoryPlayerDefaultParameters\n\nexport interface TrajectoryPlayerSignals {\n startedRunning: Signal\n haltedRunning: Signal\n}\n\n/**\n * Trajectory player for animating coordinate frames\n * @example\n * var player = new TrajectoryPlayer(trajectory, {step: 1, timeout: 50});\n * player.play();\n */\nclass TrajectoryPlayer {\n signals: TrajectoryPlayerSignals = {\n startedRunning: new Signal(),\n haltedRunning: new Signal()\n }\n\n parameters: TrajectoryPlayerParameters\n traj: Trajectory\n\n private _run = false\n private _previousTime = 0\n private _currentTime = 0\n private _currentStep = 1\n private _currentFrame: number|[number, number, number, number]\n private _direction: TrajectoryPlayerDirection\n\n /**\n * make trajectory player\n * @param {Trajectory} traj - the trajectory\n * @param {TrajectoryPlayerParameters} [params] - parameter object\n */\n constructor (traj: Trajectory, params: Partial = {}) {\n traj.signals.playerChanged.add((player: TrajectoryPlayer) => {\n if (player !== this) {\n this.pause()\n }\n }, this)\n\n const n = defaults(traj.frameCount, 1)\n\n this.traj = traj\n this.parameters = createParams(params, TrajectoryPlayerDefaultParameters)\n this.parameters.end = Math.min(defaults(params.end, n - 1), n - 1)\n this.parameters.step = defaults(params.step, Math.ceil((n + 1) / 100))\n\n this._currentFrame = this.parameters.start\n this._direction = this.parameters.direction === 'bounce' ? 'forward' : this.parameters.direction\n\n traj.signals.countChanged.add((n: number) => {\n this.parameters.end = Math.min(defaults(this.parameters.end, n - 1), n - 1)\n }, this)\n\n this._animate = this._animate.bind(this)\n }\n\n get isRunning () { return this._run }\n\n /**\n * set player parameters\n * @param {TrajectoryPlayerParameters} [params] - parameter object\n */\n setParameters (params: Partial = {}) {\n updateParams(this.parameters, params)\n\n if (params.direction !== undefined && this.parameters.direction !== 'bounce') {\n this._direction = this.parameters.direction\n }\n }\n\n _animate () {\n if (!this._run) return\n\n this._currentTime = window.performance.now()\n const dt = this._currentTime - this._previousTime\n const step = this.parameters.interpolateType ? this.parameters.interpolateStep : 1\n const timeout = this.parameters.timeout / step\n const traj = this.traj\n\n if (traj && traj.frameCount && !traj.inProgress && dt >= timeout) {\n if (this.parameters.interpolateType) {\n if (this._currentStep > this.parameters.interpolateStep) {\n this._currentStep = 1\n }\n if (this._currentStep === 1) {\n this._currentFrame = this._nextInterpolated()\n }\n if (traj.hasFrame(this._currentFrame)) {\n this._currentStep += 1\n const t = this._currentStep / (this.parameters.interpolateStep + 1)\n const [i, ip, ipp, ippp] = this._currentFrame as [number, number, number, number]\n traj.setFrameInterpolated(\n i, ip, ipp, ippp, t, this.parameters.interpolateType\n )\n this._previousTime = this._currentTime\n } else {\n traj.loadFrame(this._currentFrame)\n }\n } else {\n const i = this._next()\n if (traj.hasFrame(i)) {\n traj.setFrame(i)\n this._previousTime = this._currentTime\n } else {\n traj.loadFrame(i)\n }\n }\n }\n\n window.requestAnimationFrame(this._animate)\n }\n\n _next () {\n const p = this.parameters\n let i\n\n if (this._direction === 'forward') {\n i = this.traj.currentFrame + p.step\n } else {\n i = this.traj.currentFrame - p.step\n }\n\n if (i > p.end || i < p.start) {\n if (p.direction === 'bounce') {\n if (this._direction === 'forward') {\n this._direction = 'backward'\n } else {\n this._direction = 'forward'\n }\n }\n\n if (p.mode === 'once') {\n this.pause()\n\n if (p.direction === 'forward') {\n i = p.end\n } else if (p.direction === 'backward') {\n i = p.start\n } else {\n if (this._direction === 'forward') {\n i = p.start\n } else {\n i = p.end\n }\n }\n } else {\n if (this._direction === 'forward') {\n i = p.start\n if (p.interpolateType) {\n i = Math.min(p.end, i + p.step)\n }\n } else {\n i = p.end\n if (p.interpolateType) {\n i = Math.max(p.start, i - p.step)\n }\n }\n }\n }\n\n return i\n }\n\n _nextInterpolated () {\n const p = this.parameters\n const i = this._next()\n let ip, ipp, ippp\n\n if (this._direction === 'forward') {\n ip = Math.max(p.start, i - p.step)\n ipp = Math.max(p.start, i - 2 * p.step)\n ippp = Math.max(p.start, i - 3 * p.step)\n } else {\n ip = Math.min(p.end, i + p.step)\n ipp = Math.min(p.end, i + 2 * p.step)\n ippp = Math.min(p.end, i + 3 * p.step)\n }\n\n return [i, ip, ipp, ippp] as [number, number, number, number]\n }\n\n /**\n * toggle between playing and pausing the animation\n * @return {undefined}\n */\n toggle () {\n if (this._run) {\n this.pause()\n } else {\n this.play()\n }\n }\n\n /**\n * start the animation\n * @return {undefined}\n */\n play () {\n if (!this._run) {\n if (this.traj.player !== this) {\n this.traj.setPlayer(this)\n }\n this._currentStep = 1\n\n const p = this.parameters\n const frame = this.traj.currentFrame\n\n // snap to the grid implied by this.step division and multiplication\n // thus minimizing cache misses\n let i = Math.ceil(frame / p.step) * p.step\n // wrap when restarting from the limit (i.e. end or start)\n if (p.direction === 'forward' && frame >= p.end) {\n i = p.start\n } else if (p.direction === 'backward' && frame <= p.start) {\n i = p.end\n }\n\n this.traj.setFrame(i)\n\n this._run = true\n this._animate()\n this.signals.startedRunning.dispatch()\n }\n }\n\n /**\n * pause the animation\n * @return {undefined}\n */\n pause () {\n this._run = false\n this.signals.haltedRunning.dispatch()\n }\n\n /**\n * stop the animation (pause and go to start-frame)\n * @return {undefined}\n */\n stop () {\n this.pause()\n this.traj.setFrame(this.parameters.start)\n }\n}\n\nexport default TrajectoryPlayer\n","/**\n * @file Trajectory\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { Log } from '../globals'\nimport { defaults } from '../utils'\nimport { NumberArray } from '../types'\nimport { circularMean, arrayMean } from '../math/array-utils'\nimport { lerp, spline } from '../math/math-utils'\nimport Selection from '../selection/selection'\nimport Superposition from '../align/superposition'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\nimport TrajectoryPlayer, { TrajectoryPlayerInterpolateType } from './trajectory-player'\n\n\nfunction centerPbc (coords: NumberArray, mean: number[], box: ArrayLike) {\n if (box[ 0 ] === 0 || box[ 8 ] === 0 || box[ 4 ] === 0) {\n return\n }\n\n const n = coords.length\n\n const bx = box[ 0 ]\n const by = box[ 1 ]\n const bz = box[ 2 ]\n const mx = mean[ 0 ]\n const my = mean[ 1 ]\n const mz = mean[ 2 ]\n\n const fx = -mx + bx + bx / 2\n const fy = -my + by + by / 2\n const fz = -mz + bz + bz / 2\n\n for (let i = 0; i < n; i += 3) {\n coords[ i + 0 ] = (coords[ i + 0 ] + fx) % bx\n coords[ i + 1 ] = (coords[ i + 1 ] + fy) % by\n coords[ i + 2 ] = (coords[ i + 2 ] + fz) % bz\n }\n}\n\nfunction removePbc (x: NumberArray, box: ArrayLike) {\n if (box[ 0 ] === 0 || box[ 8 ] === 0 || box[ 4 ] === 0) {\n return\n }\n\n // ported from GROMACS src/gmxlib/rmpbc.c:rm_gropbc()\n // in-place\n\n const n = x.length\n\n for (let i = 3; i < n; i += 3) {\n for (let j = 0; j < 3; ++j) {\n const dist = x[ i + j ] - x[ i - 3 + j ]\n\n if (Math.abs(dist) > 0.9 * box[ j * 3 + j ]) {\n if (dist > 0) {\n for (let d = 0; d < 3; ++d) {\n x[ i + d ] -= box[ j * 3 + d ]\n }\n } else {\n for (let d = 0; d < 3; ++d) {\n x[ i + d ] += box[ j * 3 + d ]\n }\n }\n }\n }\n }\n\n return x\n}\n\nfunction removePeriodicity (x: NumberArray, box: ArrayLike, mean: number[]) {\n if (box[ 0 ] === 0 || box[ 8 ] === 0 || box[ 4 ] === 0) {\n return\n }\n\n const n = x.length\n for (let i = 3; i < n; i += 3) {\n for (let j = 0; j < 3; ++j) {\n const f = (x[ i + j ] - mean[ j ]) / box[ j * 3 + j ]\n if (Math.abs(f) > 0.5) {\n x[ i + j ] -= box[ j * 3 + j ] * Math.round(f)\n }\n }\n }\n\n return x\n}\n\nfunction circularMean3 (indices: NumberArray, coords: NumberArray, box: ArrayLike) {\n return [\n circularMean(coords, box[ 0 ], 3, 0, indices),\n circularMean(coords, box[ 1 ], 3, 1, indices),\n circularMean(coords, box[ 2 ], 3, 2, indices)\n ]\n}\n\nfunction arrayMean3 (coords: NumberArray) {\n return [\n arrayMean(coords, 3, 0),\n arrayMean(coords, 3, 1),\n arrayMean(coords, 3, 2)\n ]\n}\n\nfunction interpolateSpline (c: NumberArray, cp: NumberArray, cpp: NumberArray, cppp: NumberArray, t: number) {\n const m = c.length\n const coords = new Float32Array(m)\n\n for (let j0 = 0; j0 < m; j0 += 3) {\n const j1 = j0 + 1\n const j2 = j0 + 2\n coords[ j0 ] = spline(cppp[ j0 ], cpp[ j0 ], cp[ j0 ], c[ j0 ], t, 1)\n coords[ j1 ] = spline(cppp[ j1 ], cpp[ j1 ], cp[ j1 ], c[ j1 ], t, 1)\n coords[ j2 ] = spline(cppp[ j2 ], cpp[ j2 ], cp[ j2 ], c[ j2 ], t, 1)\n }\n\n return coords\n}\n\nfunction interpolateLerp (c: NumberArray, cp: NumberArray, t: number) {\n const m = c.length\n const coords = new Float32Array(m)\n\n for (let j0 = 0; j0 < m; j0 += 3) {\n const j1 = j0 + 1\n const j2 = j0 + 2\n coords[ j0 ] = lerp(cp[ j0 ], c[ j0 ], t)\n coords[ j1 ] = lerp(cp[ j1 ], c[ j1 ], t)\n coords[ j2 ] = lerp(cp[ j2 ], c[ j2 ], t)\n }\n\n return coords\n}\n\n/**\n * Trajectory parameter object.\n * @typedef {Object} TrajectoryParameters - parameters\n *\n * @property {Number} deltaTime - timestep between frames in picoseconds\n * @property {Number} timeOffset - starting time of frames in picoseconds\n * @property {String} sele - to restrict atoms used for superposition\n * @property {Boolean} centerPbc - center on initial frame\n * @property {Boolean} removePeriodicity - move atoms into the origin box\n * @property {Boolean} remo - try fixing periodic boundary discontinuities\n * @property {Boolean} superpose - superpose on initial frame\n */\n\n/**\n * @example\n * trajectory.signals.frameChanged.add( function(i){ ... } );\n *\n * @typedef {Object} TrajectorySignals\n * @property {Signal} countChanged - when the frame count is changed\n * @property {Signal} frameChanged - when the set frame is changed\n * @property {Signal} playerChanged - when the player is changed\n */\n\nexport interface TrajectoryParameters {\n deltaTime: number // timestep between frames in picoseconds\n timeOffset: number // starting time of frames in picoseconds\n sele: string // to restrict atoms used for superposition\n centerPbc: boolean // center on initial frame\n removePbc: boolean // move atoms into the origin box\n removePeriodicity: boolean // try fixing periodic boundary discontinuities\n superpose: boolean // superpose on initial frame\n}\n\nexport interface TrajectorySignals {\n countChanged: Signal\n frameChanged: Signal\n playerChanged: Signal\n}\n\n/**\n * Base class for trajectories, tying structures and coordinates together\n * @interface\n */\nclass Trajectory {\n signals: TrajectorySignals = {\n countChanged: new Signal(),\n frameChanged: new Signal(),\n playerChanged: new Signal()\n }\n\n deltaTime: number\n timeOffset: number\n sele: string\n centerPbc: boolean\n removePbc: boolean\n removePeriodicity: boolean\n superpose: boolean\n\n name: string\n frame: number\n trajPath: string\n\n initialCoords: Float32Array\n structureCoords: Float32Array\n selectionIndices: NumberArray\n backboneIndices: NumberArray\n\n coords1: Float32Array\n coords2: Float32Array\n\n frameCache: { [k: number]: Float32Array } = {}\n loadQueue: { [k: number]: boolean } = {}\n boxCache: { [k: number]: ArrayLike } = {}\n pathCache = {}\n frameCacheSize = 0\n\n atomCount: number\n inProgress: boolean\n\n selection: Selection // selection to restrict atoms used for superposition\n structure: Structure\n player: TrajectoryPlayer\n\n private _frameCount = 0\n private _currentFrame = -1\n private _disposed = false\n\n /**\n * @param {String} trajPath - trajectory source\n * @param {Structure} structure - the structure object\n * @param {TrajectoryParameters} params - trajectory parameters\n */\n constructor (trajPath: string, structure: Structure, params: Partial = {}) {\n this.deltaTime = defaults(params.deltaTime, 0)\n this.timeOffset = defaults(params.timeOffset, 0)\n this.centerPbc = defaults(params.centerPbc, false)\n this.removePbc = defaults(params.removePbc, false)\n this.removePeriodicity = defaults(params.removePeriodicity, false)\n this.superpose = defaults(params.superpose, false)\n\n this.name = trajPath.replace(/^.*[\\\\/]/, '')\n this.trajPath = trajPath\n\n this.selection = new Selection(\n defaults(params.sele, 'backbone and not hydrogen')\n )\n\n this.selection.signals.stringChanged.add(() => {\n this.selectionIndices = this.structure.getAtomIndices(this.selection)!\n this._resetCache()\n this._saveInitialCoords()\n this.setFrame(this._currentFrame)\n })\n }\n\n /**\n * Number of frames in the trajectory\n */\n get frameCount () {\n return this._frameCount\n }\n\n /**\n * Currently set frame of the trajectory\n */\n get currentFrame () {\n return this._currentFrame\n }\n\n _init (structure: Structure) {\n this.setStructure(structure)\n this._loadFrameCount()\n this.setPlayer(new TrajectoryPlayer(this))\n }\n\n _loadFrameCount () {}\n\n setStructure (structure: Structure) {\n this.structure = structure\n this.atomCount = structure.atomCount\n\n this.backboneIndices = this._getIndices(\n new Selection('backbone and not hydrogen')\n )\n this._makeAtomIndices()\n this._saveStructureCoords()\n\n this.selectionIndices = this._getIndices(this.selection)\n this._resetCache()\n this._saveInitialCoords()\n this.setFrame(this._currentFrame)\n }\n\n _saveInitialCoords () {\n if (this.structure.hasCoords()) {\n this.initialCoords = new Float32Array(this.structureCoords)\n this._makeSuperposeCoords()\n } else if (this.frameCache[0]) {\n this.initialCoords = new Float32Array(this.frameCache[0])\n this._makeSuperposeCoords()\n } else {\n this.loadFrame(0, () => this._saveInitialCoords())\n }\n }\n\n _saveStructureCoords () {\n const p = { what: { position: true } }\n this.structureCoords = this.structure.getAtomData(p).position!\n }\n\n setSelection (string: string) {\n this.selection.setString(string)\n return this\n }\n\n _getIndices (selection: Selection) {\n let i = 0\n const test = selection.test\n const indices: number[] = []\n\n if (test) {\n this.structure.eachAtom((ap: AtomProxy) => {\n if (test(ap)) indices.push(i)\n i += 1\n })\n }\n\n return indices\n }\n\n _makeSuperposeCoords () {\n const n = this.selectionIndices.length * 3\n\n this.coords1 = new Float32Array(n)\n this.coords2 = new Float32Array(n)\n\n const y = this.initialCoords\n const coords2 = this.coords2\n\n for (let i = 0; i < n; i += 3) {\n const j = this.selectionIndices[ i / 3 ] * 3\n\n coords2[ i + 0 ] = y[ j + 0 ]\n coords2[ i + 1 ] = y[ j + 1 ]\n coords2[ i + 2 ] = y[ j + 2 ]\n }\n }\n\n _makeAtomIndices () {\n Log.error('Trajectory._makeAtomIndices not implemented')\n }\n\n _resetCache () {\n this.frameCache = {}\n this.loadQueue = {}\n this.boxCache = {}\n this.pathCache = {}\n this.frameCacheSize = 0\n this.initialCoords = new Float32Array(0)\n }\n\n setParameters (params: Partial = {}) {\n let resetCache = false\n\n if (params.centerPbc !== undefined && params.centerPbc !== this.centerPbc) {\n this.centerPbc = params.centerPbc\n resetCache = true\n }\n\n if (params.removePeriodicity !== undefined && params.removePeriodicity !== this.removePeriodicity) {\n this.removePeriodicity = params.removePeriodicity\n resetCache = true\n }\n\n if (params.removePbc !== undefined && params.removePbc !== this.removePbc) {\n this.removePbc = params.removePbc\n resetCache = true\n }\n\n if (params.superpose !== undefined && params.superpose !== this.superpose) {\n this.superpose = params.superpose\n resetCache = true\n }\n\n this.deltaTime = defaults(params.deltaTime, this.deltaTime)\n this.timeOffset = defaults(params.timeOffset, this.timeOffset)\n\n if (resetCache) {\n this._resetCache()\n this.setFrame(this._currentFrame)\n }\n }\n\n /**\n * Check if a frame is available\n * @param {Integer|Integer[]} i - the frame index\n * @return {Boolean} frame availability\n */\n hasFrame (i: number|number[]) {\n if (Array.isArray(i)) {\n return i.every(j => !!this.frameCache[j])\n } else {\n return !!this.frameCache[i]\n }\n }\n\n /**\n * Set trajectory to a frame index\n * @param {Integer} i - the frame index\n * @param {Function} [callback] - fired when the frame has been set\n */\n setFrame (i: number, callback?: Function) {\n if (i === undefined) return this\n\n this.inProgress = true\n\n // i = parseInt(i) // TODO\n\n if (i === -1 || this.frameCache[ i ]) {\n this._updateStructure(i)\n if (callback) callback()\n } else {\n this.loadFrame(i, () => {\n this._updateStructure(i)\n if (callback) callback()\n })\n }\n\n return this\n }\n\n _interpolate (i: number, ip: number, ipp: number, ippp: number, t: number, type: TrajectoryPlayerInterpolateType) {\n const fc = this.frameCache\n\n let coords\n if (type === 'spline') {\n coords = interpolateSpline(fc[ i ], fc[ ip ], fc[ ipp ], fc[ ippp ], t)\n } else {\n coords = interpolateLerp(fc[ i ], fc[ ip ], t)\n }\n\n this.structure.updatePosition(coords)\n this._currentFrame = i\n this.signals.frameChanged.dispatch(i)\n }\n\n /**\n * Interpolated and set trajectory to frame indices\n * @param {Integer} i - the frame index\n * @param {Integer} ip - one before frame index\n * @param {Integer} ipp - two before frame index\n * @param {Integer} ippp - three before frame index\n * @param {Number} t - interpolation step [0,1]\n * @param {String} type - interpolation type, '', 'spline' or 'linear'\n * @param {Function} callback - fired when the frame has been set\n */\n setFrameInterpolated (i: number, ip: number, ipp: number, ippp: number, t: number, type: TrajectoryPlayerInterpolateType, callback?: Function) {\n if (i === undefined) return this\n\n const fc = this.frameCache\n const iList: number[] = []\n\n if (!fc[ ippp ]) iList.push(ippp)\n if (!fc[ ipp ]) iList.push(ipp)\n if (!fc[ ip ]) iList.push(ip)\n if (!fc[ i ]) iList.push(i)\n\n if (iList.length) {\n this.loadFrame(iList, () => {\n this._interpolate(i, ip, ipp, ippp, t, type)\n if (callback) callback()\n })\n } else {\n this._interpolate(i, ip, ipp, ippp, t, type)\n if (callback) callback()\n }\n\n return this\n }\n\n /**\n * Load frame index\n * @param {Integer|Integer[]} i - the frame index\n * @param {Function} callback - fired when the frame has been loaded\n */\n loadFrame (i: number|number[], callback?: Function) {\n if (Array.isArray(i)) {\n i.forEach(j => {\n if (!this.loadQueue[j] && !this.frameCache[j]) {\n this.loadQueue[j] = true\n this._loadFrame(j, () => {\n delete this.loadQueue[j]\n })\n }\n })\n } else {\n if (!this.loadQueue[i] && !this.frameCache[i]) {\n this.loadQueue[i] = true\n this._loadFrame(i, () => {\n delete this.loadQueue[i]\n if (callback) callback()\n })\n }\n }\n }\n\n /**\n * Load frame index\n * @abstract\n * @param {Integer} i - the frame index\n * @param {Function} callback - fired when the frame has been loaded\n */\n _loadFrame (i: number, callback?: Function) {\n Log.error('Trajectory._loadFrame not implemented', i, callback)\n }\n\n _updateStructure (i: number) {\n if (this._disposed) {\n console.error('updateStructure: traj disposed')\n return\n }\n\n if (i === -1) {\n if (this.structureCoords) {\n this.structure.updatePosition(this.structureCoords)\n }\n } else {\n this.structure.updatePosition(this.frameCache[ i ])\n }\n\n this.structure.trajectory = {\n name: this.trajPath,\n frame: i\n }\n\n this._currentFrame = i\n this.inProgress = false\n this.signals.frameChanged.dispatch(i)\n }\n\n _doSuperpose (x: Float32Array) {\n const n = this.selectionIndices.length * 3\n\n const coords1 = this.coords1\n const coords2 = this.coords2\n\n for (let i = 0; i < n; i += 3) {\n const j = this.selectionIndices[ i / 3 ] * 3\n\n coords1[ i + 0 ] = x[ j + 0 ]\n coords1[ i + 1 ] = x[ j + 1 ]\n coords1[ i + 2 ] = x[ j + 2 ]\n }\n\n // TODO re-use superposition object\n const sp = new Superposition(coords1, coords2)\n sp.transform(x)\n }\n\n _process (i: number, box: ArrayLike, coords: Float32Array, frameCount: number) {\n this._setFrameCount(frameCount)\n\n if (box) {\n if (this.backboneIndices.length > 0 && this.centerPbc) {\n const box2 = [ box[ 0 ], box[ 4 ], box[ 8 ] ]\n const circMean = circularMean3(this.backboneIndices, coords, box2)\n centerPbc(coords, circMean, box2)\n }\n\n if (this.removePeriodicity) {\n const mean = arrayMean3(coords)\n removePeriodicity(coords, box, mean)\n }\n\n if (this.removePbc) {\n removePbc(coords, box)\n }\n }\n\n if (this.selectionIndices.length > 0 && this.coords1 && this.superpose) {\n this._doSuperpose(coords)\n }\n\n this.frameCache[ i ] = coords\n this.boxCache[ i ] = box\n this.frameCacheSize += 1\n }\n\n _setFrameCount (n: number) {\n if (n !== this._frameCount) {\n this._frameCount = n\n this.signals.countChanged.dispatch(n)\n }\n }\n\n /**\n * Dispose of the trajectory object\n * @return {undefined}\n */\n dispose () {\n this._resetCache() // aid GC\n this._disposed = true\n if (this.player) this.player.stop()\n }\n\n /**\n * Set player for this trajectory\n * @param {TrajectoryPlayer} player - the player\n */\n setPlayer (player: TrajectoryPlayer) {\n this.player = player\n this.signals.playerChanged.dispatch(player)\n }\n\n /**\n * Get time for frame\n * @param {Integer} i - frame index\n * @return {Number} time in picoseconds\n */\n getFrameTime (i: number) {\n return this.timeOffset + i * this.deltaTime\n }\n}\n\nexport default Trajectory\n","/**\n * @file Frames Trajectory\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport Structure from '../structure/structure'\nimport Frames from './frames'\nimport Trajectory, { TrajectoryParameters } from './trajectory'\n\n/**\n * Frames trajectory class. Gets data from a frames object.\n */\nclass FramesTrajectory extends Trajectory {\n path: string\n\n frames: ArrayLike[]\n boxes: ArrayLike[]\n\n atomIndices?: ArrayLike\n\n constructor (frames: Frames, structure: Structure, params: TrajectoryParameters) {\n const p = params || {}\n p.timeOffset = defaults(p.timeOffset, frames.timeOffset)\n p.deltaTime = defaults(p.deltaTime, frames.deltaTime)\n\n super('', structure, p)\n\n this.name = frames.name\n this.path = frames.path\n\n this.frames = frames.coordinates\n this.boxes = frames.boxes\n\n this._init(structure)\n }\n\n get type () { return 'frames' }\n\n _makeAtomIndices () {\n if (this.structure.type === 'StructureView') {\n this.atomIndices = this.structure.getAtomIndices()\n } else {\n this.atomIndices = undefined\n }\n }\n\n _loadFrame (i: number, callback?: Function) {\n let coords\n const frame = this.frames[ i ]\n\n if (this.atomIndices) {\n const indices = this.atomIndices\n const m = indices.length\n\n coords = new Float32Array(m * 3)\n\n for (let j = 0; j < m; ++j) {\n const j3 = j * 3\n const idx3 = indices[ j ] * 3\n\n coords[ j3 + 0 ] = frame[ idx3 + 0 ]\n coords[ j3 + 1 ] = frame[ idx3 + 1 ]\n coords[ j3 + 2 ] = frame[ idx3 + 2 ]\n }\n } else {\n coords = new Float32Array(frame)\n }\n\n const box = this.boxes[ i ]\n const frameCount = this.frames.length\n\n this._process(i, box, coords, frameCount)\n\n if (typeof callback === 'function') {\n callback()\n }\n }\n\n _loadFrameCount () {\n if (this.frames) {\n this._setFrameCount(this.frames.length)\n }\n }\n}\n\nexport default FramesTrajectory\n","/**\n * @file Structure Trajectory\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Trajectory, { TrajectoryParameters } from './trajectory'\n\n/**\n * Structure trajectory class. Gets data from a structure object.\n */\nclass StructureTrajectory extends Trajectory {\n atomIndices?: ArrayLike\n\n constructor (trajPath: string, structure: Structure, params: TrajectoryParameters) {\n super('', structure, params)\n this._init(structure)\n }\n\n get type () { return 'structure' }\n\n _makeAtomIndices () {\n if (this.structure.atomSet && this.structure.atomSet.getSize() < this.structure.atomStore.count) {\n this.atomIndices = this.structure.getAtomIndices()\n } else {\n this.atomIndices = undefined\n }\n }\n\n _loadFrame (i: number, callback?: Function) {\n let coords\n const structure = this.structure\n const frame = structure.frames[ i ]\n\n if (this.atomIndices) {\n const indices = this.atomIndices\n const m = indices.length\n\n coords = new Float32Array(m * 3)\n\n for (let j = 0; j < m; ++j) {\n const j3 = j * 3\n const idx3 = indices[ j ] * 3\n\n coords[ j3 + 0 ] = frame[ idx3 + 0 ]\n coords[ j3 + 1 ] = frame[ idx3 + 1 ]\n coords[ j3 + 2 ] = frame[ idx3 + 2 ]\n }\n } else {\n coords = new Float32Array(frame)\n }\n\n const box = structure.boxes[ i ]\n const frameCount = structure.frames.length\n\n this._process(i, box, coords, frameCount)\n\n if (typeof callback === 'function') {\n callback()\n }\n }\n\n _loadFrameCount () {\n this._setFrameCount(this.structure.frames.length)\n }\n}\n\nexport default StructureTrajectory\n","/**\n * @file Remote Trajectory\n * @author Alexander Rose \n * @private\n */\n\nimport { Log, TrajectoryDatasource } from '../globals'\nimport Structure from '../structure/structure'\nimport Trajectory, { TrajectoryParameters } from './trajectory'\n\n/**\n * Remote trajectory class. Gets data from an MDsrv instance.\n */\nclass RemoteTrajectory extends Trajectory {\n atomIndices: number[][]\n\n constructor (trajPath: string, structure: Structure, params: TrajectoryParameters) {\n super(trajPath, structure, params)\n this._init(structure)\n }\n\n get type () { return 'remote' }\n\n _makeAtomIndices () {\n const atomIndices = []\n\n if (this.structure.type === 'StructureView') {\n const indices = this.structure.getAtomIndices()! // TODO\n const n = indices.length\n\n let p = indices[ 0 ]\n let q = indices[ 0 ]\n\n for (let i = 1; i < n; ++i) {\n const r = indices[ i ]\n\n if (q + 1 < r) {\n atomIndices.push([ p, q + 1 ])\n p = r\n }\n\n q = r\n }\n\n atomIndices.push([ p, q + 1 ])\n } else {\n atomIndices.push([ 0, this.atomCount ])\n }\n\n this.atomIndices = atomIndices\n }\n\n _loadFrame (i: number, callback?: Function) {\n // TODO implement max frameCache size, re-use arrays\n\n const request = new XMLHttpRequest()\n\n const url = TrajectoryDatasource.getFrameUrl(this.trajPath, i)\n const params = TrajectoryDatasource.getFrameParams(this.trajPath, this.atomIndices)\n\n request.open('POST', url, true)\n request.responseType = 'arraybuffer'\n request.setRequestHeader(\n 'Content-type', 'application/x-www-form-urlencoded'\n )\n\n request.addEventListener('load', () => {\n const arrayBuffer = request.response\n if (!arrayBuffer) {\n Log.error(`empty arrayBuffer for '${url}'`)\n return\n }\n\n const frameCount = new Int32Array(arrayBuffer, 0, 1)[ 0 ]\n // const time = new Float32Array( arrayBuffer, 1 * 4, 1 )[ 0 ];\n const box = new Float32Array(arrayBuffer, 2 * 4, 9)\n const coords = new Float32Array(arrayBuffer, 11 * 4)\n\n this._process(i, box, coords, frameCount)\n if (typeof callback === 'function') {\n callback()\n }\n }, false)\n\n request.send(params)\n }\n\n _loadFrameCount () {\n const request = new XMLHttpRequest()\n\n const url = TrajectoryDatasource.getCountUrl(this.trajPath)\n\n request.open('GET', url, true)\n request.addEventListener('load', () => {\n this._setFrameCount(parseInt(request.response))\n }, false)\n request.send()\n }\n}\n\nexport default RemoteTrajectory\n","/**\n * @file Callback Trajectory\n * @author Tarn W. Burton \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Trajectory, { TrajectoryParameters } from './trajectory'\n\ntype RequestCallback = (responseCallback: Function, i?: number, atomIndices?: number[][]) => void\n\n/**\n * Callback trajectory class. Gets data from an JavaScript function.\n */\nclass CallbackTrajectory extends Trajectory {\n atomIndices: number[][]\n requestCallback: RequestCallback\n\n constructor (requestCallback: RequestCallback, structure: Structure, params: TrajectoryParameters) {\n super('', structure, params)\n this.requestCallback = requestCallback;\n this._init(structure)\n }\n\n get type () { return 'callback' }\n\n _makeAtomIndices () {\n const atomIndices = []\n\n if (this.structure.type === 'StructureView') {\n const indices = this.structure.getAtomIndices()! // TODO\n const n = indices.length\n\n let p = indices[ 0 ]\n let q = indices[ 0 ]\n\n for (let i = 1; i < n; ++i) {\n const r = indices[ i ]\n\n if (q + 1 < r) {\n atomIndices.push([ p, q + 1 ])\n p = r\n }\n\n q = r\n }\n\n atomIndices.push([ p, q + 1 ])\n } else {\n atomIndices.push([ 0, this.atomCount ])\n }\n\n this.atomIndices = atomIndices\n }\n\n _loadFrame (i: number, callback?: Function) {\n this.requestCallback(\n (i: number, box: ArrayLike, coords: Float32Array, frameCount: number) => {\n this._process(i, box, coords, frameCount)\n if (typeof callback === 'function') {\n callback()\n }\n }, i, this.atomIndices)\n }\n\n _loadFrameCount () {\n this.requestCallback((count: number) => this._setFrameCount(count))\n }\n}\n\nexport default CallbackTrajectory\n\n","/**\n * @file Structure View\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3 } from 'three'\n\nimport { Debug, Log } from '../globals'\nimport Structure from './structure'\nimport Selection from '../selection/selection'\nimport BitArray from '../utils/bitarray'\n\nimport BondProxy from '../proxy/bond-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\nimport SpatialHash from '../geometry/spatial-hash';\nimport BondHash from '../store/bond-hash';\nimport ResidueMap from '../store/residue-map';\nimport AtomMap from '../store/atom-map';\nimport ModelStore from '../store/model-store';\nimport ChainStore from '../store/chain-store';\nimport ResidueStore from '../store/residue-store';\nimport AtomStore from '../store/atom-store';\nimport BondStore from '../store/bond-store';\nimport Validation from './validation';\nimport Unitcell from '../symmetry/unitcell';\nimport Entity from './entity';\nimport Assembly from '../symmetry/assembly';\nimport { Data } from './data';\n\n/**\n * Get view on structure restricted to the selection\n * @param {Selection} selection - the selection\n * @return {StructureView} the view on the structure\n */\nStructure.prototype.getView = function (this: Structure, selection: Selection) {\n // added here to avoid cyclic import dependency\n return new StructureView(this, selection)\n}\n\n/**\n * View on the structure, restricted to the selection\n */\nclass StructureView extends Structure {\n structure: Structure\n selection: Selection\n\n /**\n * @param {Structure} structure - the structure\n * @param {Selection} selection - the selection\n */\n constructor (structure: Structure, selection: Selection) {\n super()\n\n this.structure = structure\n this.selection = selection\n\n this.center = new Vector3()\n this.boundingBox = new Box3()\n\n this._bp = this.getBondProxy()\n this._ap = this.getAtomProxy()\n this._rp = this.getResidueProxy()\n this._cp = this.getChainProxy()\n\n if (this.selection) {\n this.selection.signals.stringChanged.add(this.refresh, this)\n }\n\n this.structure.signals.refreshed.add(this.refresh, this)\n\n this.refresh()\n }\n\n init () {}\n\n get type () { return 'StructureView' }\n\n get name () { return this.structure.name }\n get path () { return this.structure.path }\n get title () { return this.structure.title }\n get id () { return this.structure.id }\n get data (): Data { return this.structure.data }\n get atomSetDict () { return this.structure.atomSetDict }\n get biomolDict (): {[k: string]: Assembly} { return this.structure.biomolDict }\n get entityList (): Entity[] { return this.structure.entityList }\n get unitcell (): Unitcell|undefined { return this.structure.unitcell }\n get frames () { return this.structure.frames }\n get boxes () { return this.structure.boxes }\n get validation (): Validation|undefined { return this.structure.validation }\n get bondStore () { return this.structure.bondStore }\n get backboneBondStore () { return this.structure.backboneBondStore }\n get rungBondStore (): BondStore { return this.structure.rungBondStore }\n get atomStore (): AtomStore { return this.structure.atomStore }\n get residueStore (): ResidueStore { return this.structure.residueStore }\n get chainStore (): ChainStore { return this.structure.chainStore }\n get modelStore (): ModelStore { return this.structure.modelStore }\n get atomMap (): AtomMap { return this.structure.atomMap }\n get residueMap (): ResidueMap { return this.structure.residueMap }\n get bondHash (): BondHash|undefined { return this.structure.bondHash }\n get spatialHash (): SpatialHash|undefined { return this.structure.spatialHash }\n\n get _hasCoords () { return this.structure._hasCoords }\n set _hasCoords (value) { this.structure._hasCoords = value }\n\n /**\n * Updates atomSet, bondSet, atomSetCache, atomCount, bondCount, boundingBox, center.\n * @emits {Structure.signals.refreshed} when refreshed\n * @return {undefined}\n */\n refresh () {\n if (Debug) Log.time('StructureView.refresh')\n\n this.atomSetCache = {}\n const structure = this.structure\n\n if (this.selection.isAllSelection() &&\n structure !== this && structure.atomSet && structure.bondSet\n ) {\n this.atomSet = structure.atomSet.clone()\n this.bondSet = structure.bondSet.clone()\n\n for (let name in this.atomSetDict) {\n const atomSet = this.atomSetDict[ name ]\n this.atomSetCache[ '__' + name ] = atomSet.clone()\n }\n\n this.atomCount = structure.atomCount\n this.bondCount = structure.bondCount\n\n this.boundingBox.copy(structure.boundingBox)\n this.center.copy(structure.center)\n } else if (this.selection.isNoneSelection() &&\n structure !== this && structure.atomSet && structure.bondSet\n ) {\n this.atomSet = new BitArray(structure.atomCount)\n this.bondSet = new BitArray(structure.bondCount)\n\n for (let name in this.atomSetDict) {\n this.atomSetCache[ '__' + name ] = new BitArray(structure.atomCount)\n }\n\n this.atomCount = 0\n this.bondCount = 0\n\n this.boundingBox.makeEmpty()\n this.center.set(0, 0, 0)\n } else {\n this.atomSet = this.getAtomSet(this.selection, true)\n if (structure.atomSet) {\n this.atomSet = this.atomSet.intersection(structure.atomSet)\n }\n\n this.bondSet = this.getBondSet()\n\n for (let name in this.atomSetDict) {\n const atomSet = this.atomSetDict[ name ]\n this.atomSetCache[ '__' + name ] = atomSet.makeIntersection(this.atomSet)\n }\n\n this.atomCount = this.atomSet.getSize()\n this.bondCount = this.bondSet.getSize()\n\n this.boundingBox = this.getBoundingBox()\n this.center = this.boundingBox.getCenter(new Vector3())\n }\n\n if (Debug) Log.timeEnd('StructureView.refresh')\n\n this.signals.refreshed.dispatch()\n }\n\n //\n\n setSelection (selection: Selection) {\n this.selection = selection\n\n this.refresh()\n }\n\n getSelection (selection?: Selection) {\n const seleList: string[] = []\n\n if (selection && selection.string) {\n seleList.push(selection.string)\n }\n\n const parentSelection = this.structure.getSelection()\n if (parentSelection && parentSelection.string) {\n seleList.push(parentSelection.string)\n }\n\n if (this.selection && this.selection.string) {\n seleList.push(this.selection.string)\n }\n\n let sele = ''\n if (seleList.length > 0) {\n sele = `( ${seleList.join(' ) AND ( ')} )`\n }\n\n return new Selection(sele)\n }\n\n getStructure () {\n return this.structure.getStructure()\n }\n\n //\n\n eachBond (callback: (entity: BondProxy) => any, selection?: Selection) {\n this.structure.eachBond(callback, this.getSelection(selection))\n }\n\n eachAtom (callback: (entity: AtomProxy) => any, selection?: Selection) {\n const ap = this.getAtomProxy()\n const atomSet = this.getAtomSet(selection)\n const n = this.atomStore.count\n\n if (atomSet.getSize() < n) {\n atomSet.forEach(function (index) {\n ap.index = index\n callback(ap)\n })\n } else {\n for (let i = 0; i < n; ++i) {\n ap.index = i\n callback(ap)\n }\n }\n }\n\n eachResidue (callback: (entity: ResidueProxy) => any, selection?: Selection) {\n this.structure.eachResidue(callback, this.getSelection(selection))\n }\n\n /**\n * Not implemented\n * @alias StructureView#eachResidueN\n * @return {undefined}\n */\n eachResidueN (n: number, callback: (entity: ResidueProxy) => any) {\n console.error('StructureView.eachResidueN() not implemented')\n }\n\n eachChain (callback: (entity: ChainProxy) => any, selection?: Selection) {\n this.structure.eachChain(callback, this.getSelection(selection))\n }\n\n eachModel (callback: (entity: ModelProxy) => any, selection?: Selection) {\n this.structure.eachModel(callback, this.getSelection(selection))\n }\n\n //\n\n getAtomSet (selection?: boolean|Selection|BitArray, ignoreView = false) {\n let atomSet = this.structure.getAtomSet(selection)\n if (!ignoreView && this.atomSet) {\n atomSet = atomSet.makeIntersection(this.atomSet)\n }\n\n return atomSet\n }\n\n //\n\n getAtomIndices (selection?: Selection) {\n return this.structure.getAtomIndices(this.getSelection(selection))\n }\n\n refreshPosition () {\n return this.structure.refreshPosition()\n }\n\n //\n\n dispose () {\n if (this.selection) {\n this.selection.signals.stringChanged.remove(this.refresh, this)\n }\n\n this.structure.signals.refreshed.remove(this.refresh, this)\n\n this.structure = new Structure() // delete old data\n\n delete this.atomSet\n delete this.bondSet\n\n }\n}\n\nexport default StructureView\n","/**\n * @file Alignment\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log } from '../globals'\n\n// const nucleotides = 'ACTG';\nconst aminoacidsX = 'ACDEFGHIKLMNPQRSTVWY'\nconst aminoacids = 'ARNDCQEGHILKMFPSTWYVBZ?'\n\nconst blosum62x = [\n [4, 0, -2, -1, -2, 0, -2, -1, -1, -1, -1, -2, -1, -1, -1, 1, 0, 0, -3, -2], // A\n [0, 9, -3, -4, -2, -3, -3, -1, -3, -1, -1, -3, -3, -3, -3, -1, -1, -1, -2, -2], // C\n [-2, -3, 6, 2, -3, -1, -1, -3, -1, -4, -3, 1, -1, 0, -2, 0, -1, -3, -4, -3], // D\n [-1, -4, 2, 5, -3, -2, 0, -3, 1, -3, -2, 0, -1, 2, 0, 0, -1, -2, -3, -2], // E\n [-2, -2, -3, -3, 6, -3, -1, 0, -3, 0, 0, -3, -4, -3, -3, -2, -2, -1, 1, 3], // F\n [0, -3, -1, -2, -3, 6, -2, -4, -2, -4, -3, 0, -2, -2, -2, 0, -2, -3, -2, -3], // G\n [-2, -3, -1, 0, -1, -2, 8, -3, -1, -3, -2, 1, -2, 0, 0, -1, -2, -3, -2, 2], // H\n [-1, -1, -3, -3, 0, -4, -3, 4, -3, 2, 1, -3, -3, -3, -3, -2, -1, 3, -3, -1], // I\n [-1, -3, -1, 1, -3, -2, -1, -3, 5, -2, -1, 0, -1, 1, 2, 0, -1, -2, -3, -2], // K\n [-1, -1, -4, -3, 0, -4, -3, 2, -2, 4, 2, -3, -3, -2, -2, -2, -1, 1, -2, -1], // L\n [-1, -1, -3, -2, 0, -3, -2, 1, -1, 2, 5, -2, -2, 0, -1, -1, -1, 1, -1, -1], // M\n [-2, -3, 1, 0, -3, 0, 1, -3, 0, -3, -2, 6, -2, 0, 0, 1, 0, -3, -4, -2], // N\n [-1, -3, -1, -1, -4, -2, -2, -3, -1, -3, -2, -2, 7, -1, -2, -1, -1, -2, -4, -3], // P\n [-1, -3, 0, 2, -3, -2, 0, -3, 1, -2, 0, 0, -1, 5, 1, 0, -1, -2, -2, -1], // Q\n [-1, -3, -2, 0, -3, -2, 0, -3, 2, -2, -1, 0, -2, 1, 5, -1, -1, -3, -3, -2], // R\n [1, -1, 0, 0, -2, 0, -1, -2, 0, -2, -1, 1, -1, 0, -1, 4, 1, -2, -3, -2], // S\n [0, -1, -1, -1, -2, -2, -2, -1, -1, -1, -1, 0, -1, -1, -1, 1, 5, 0, -2, -2], // T\n [0, -1, -3, -2, -1, -3, -3, 3, -2, 1, 1, -3, -2, -2, -3, -2, 0, 4, -3, -1], // V\n [-3, -2, -4, -3, 1, -2, -2, -3, -3, -2, -1, -4, -4, -2, -3, -3, -2, -3, 11, 2], // W\n [-2, -2, -3, -2, 3, -3, 2, -1, -2, -1, -1, -2, -3, -1, -2, -2, -2, -1, 2, 7] // Y\n]\n\nconst blosum62 = [\n // A R N D C Q E G H I L K M F P S T W Y V B Z X\n [4, -1, -2, -2, 0, -1, -1, 0, -2, -1, -1, -1, -1, -2, -1, 1, 0, -3, -2, 0, -2, -1, 0], // A\n [-1, 5, 0, -2, -3, 1, 0, -2, 0, -3, -2, 2, -1, -3, -2, -1, -1, -3, -2, -3, -1, 0, -1], // R\n [-2, 0, 6, 1, -3, 0, 0, 0, 1, -3, -3, 0, -2, -3, -2, 1, 0, -4, -2, -3, 3, 0, -1], // N\n [-2, -2, 1, 6, -3, 0, 2, -1, -1, -3, -4, -1, -3, -3, -1, 0, -1, -4, -3, -3, 4, 1, -1], // D\n [0, -3, -3, -3, 9, -3, -4, -3, -3, -1, -1, -3, -1, -2, -3, -1, -1, -2, -2, -1, -3, -3, -2], // C\n [-1, 1, 0, 0, -3, 5, 2, -2, 0, -3, -2, 1, 0, -3, -1, 0, -1, -2, -1, -2, 0, 3, -1], // Q\n [-1, 0, 0, 2, -4, 2, 5, -2, 0, -3, -3, 1, -2, -3, -1, 0, -1, -3, -2, -2, 1, 4, -1], // E\n [0, -2, 0, -1, -3, -2, -2, 6, -2, -4, -4, -2, -3, -3, -2, 0, -2, -2, -3, -3, -1, -2, -1], // G\n [-2, 0, 1, -1, -3, 0, 0, -2, 8, -3, -3, -1, -2, -1, -2, -1, -2, -2, 2, -3, 0, 0, -1], // H\n [-1, -3, -3, -3, -1, -3, -3, -4, -3, 4, 2, -3, 1, 0, -3, -2, -1, -3, -1, 3, -3, -3, -1], // I\n [-1, -2, -3, -4, -1, -2, -3, -4, -3, 2, 4, -2, 2, 0, -3, -2, -1, -2, -1, 1, -4, -3, -1], // L\n [-1, 2, 0, -1, -3, 1, 1, -2, -1, -3, -2, 5, -1, -3, -1, 0, -1, -3, -2, -2, 0, 1, -1], // K\n [-1, -1, -2, -3, -1, 0, -2, -3, -2, 1, 2, -1, 5, 0, -2, -1, -1, -1, -1, 1, -3, -1, -1], // M\n [-2, -3, -3, -3, -2, -3, -3, -3, -1, 0, 0, -3, 0, 6, -4, -2, -2, 1, 3, -1, -3, -3, -1], // F\n [-1, -2, -2, -1, -3, -1, -1, -2, -2, -3, -3, -1, -2, -4, 7, -1, -1, -4, -3, -2, -2, -1, -2], // P\n [1, -1, 1, 0, -1, 0, 0, 0, -1, -2, -2, 0, -1, -2, -1, 4, 1, -3, -2, -2, 0, 0, 0], // S\n [0, -1, 0, -1, -1, -1, -1, -2, -2, -1, -1, -1, -1, -2, -1, 1, 5, -2, -2, 0, -1, -1, 0], // T\n [-3, -3, -4, -4, -2, -2, -3, -2, -2, -3, -2, -3, -1, 1, -4, -3, -2, 11, 2, -3, -4, -3, -2], // W\n [-2, -2, -2, -3, -2, -1, -2, -3, 2, -1, -1, -2, -1, 3, -3, -2, -2, 2, 7, -1, -3, -2, -1], // Y\n [0, -3, -3, -3, -1, -2, -2, -3, -3, 3, 1, -2, 1, -1, -2, -2, 0, -3, -1, 4, -3, -2, -1], // V\n [-2, -1, 3, 4, -3, 0, 1, -1, 0, -3, -4, 0, -3, -3, -2, 0, -1, -4, -3, -3, 4, 1, -1], // B\n [-1, 0, 0, 1, -3, 3, 4, -2, 0, -3, -3, 1, -1, -3, -1, 0, -1, -3, -2, -2, 1, 4, -1], // Z\n [0, -1, -1, -1, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, 0, 0, -2, -1, -1, -1, -1, -1] // X\n]\n\nfunction prepareMatrix (cellNames: string, mat: number[][]) {\n let j: number\n let i = 0\n const matDict: { [k: string]: { [k: string]: number } } = {}\n mat.forEach(function (row) {\n j = 0\n const rowDict: { [k: string]: number } = {}\n row.forEach(function (elm) {\n rowDict[ cellNames[ j++ ] ] = elm\n })\n matDict[ cellNames[ i++ ] ] = rowDict\n })\n return matDict\n}\n\nconst SubstitutionMatrices = (function () {\n return {\n blosum62: prepareMatrix(aminoacids, blosum62),\n blosum62x: prepareMatrix(aminoacidsX, blosum62x)\n }\n}())\nexport type SubstitutionMatrix = ''|'blosum62'|'blosum62x'\n\nclass Alignment {\n substMatrix: { [k: string]: { [k: string]: number } }\n\n n: number\n m: number\n score?: number\n ali: string\n\n S: number[][]\n V: number[][]\n H: number[][]\n\n ali1: string\n ali2: string\n\n constructor (readonly seq1: string, readonly seq2: string, readonly gapPenalty = -10, readonly gapExtensionPenalty = -1, substMatrix: SubstitutionMatrix = 'blosum62') {\n // TODO try encoding seqs as integers and use array subst matrix, maybe faster\n\n if (substMatrix) {\n this.substMatrix = SubstitutionMatrices[ substMatrix ]\n }\n }\n\n initMatrices () {\n this.n = this.seq1.length\n this.m = this.seq2.length\n\n // Log.log(this.n, this.m);\n\n this.score = undefined\n this.ali = ''\n\n this.S = []\n this.V = []\n this.H = []\n\n for (let i = 0; i <= this.n; ++i) {\n this.S[ i ] = []\n this.V[ i ] = []\n this.H[ i ] = []\n\n for (let j = 0; j <= this.m; ++j) {\n this.S[ i ][ j ] = 0\n this.V[ i ][ j ] = 0\n this.H[ i ][ j ] = 0\n }\n }\n\n for (let i = 0; i <= this.n; ++i) {\n this.S[ i ][ 0 ] = this.gap(0)\n this.H[ i ][ 0 ] = -Infinity\n }\n\n for (let j = 0; j <= this.m; ++j) {\n this.S[ 0 ][ j ] = this.gap(0)\n this.V[ 0 ][ j ] = -Infinity\n }\n\n this.S[ 0 ][ 0 ] = 0\n\n // Log.log(this.S, this.V, this.H);\n }\n\n gap (len: number) {\n return this.gapPenalty + len * this.gapExtensionPenalty\n }\n\n makeScoreFn () {\n const seq1 = this.seq1\n const seq2 = this.seq2\n\n const substMatrix = this.substMatrix\n\n if (substMatrix) {\n return function score (i: number, j: number) {\n const c1 = seq1[ i ]\n const c2 = seq2[ j ]\n\n try {\n return substMatrix[ c1 ][ c2 ]\n } catch (e) {\n return -4\n }\n }\n } else {\n Log.warn('Alignment: no subst matrix')\n\n return function scoreNoSubstMat (i: number, j: number) {\n const c1 = seq1[ i ]\n const c2 = seq2[ j ]\n\n return c1 === c2 ? 5 : -3\n }\n }\n }\n\n calc () {\n if (Debug) Log.time('Alignment.calc')\n\n this.initMatrices()\n\n const gap0 = this.gap(0)\n const scoreFn = this.makeScoreFn()\n const gapExtensionPenalty = this.gapExtensionPenalty\n\n const V = this.V\n const H = this.H\n const S = this.S\n\n const n = this.n\n const m = this.m\n\n let Vi1, Si1, Vi, Hi, Si\n\n for (let i = 1; i <= n; ++i) {\n Si1 = S[ i - 1 ]\n Vi1 = V[ i - 1 ]\n\n Vi = V[ i ]\n Hi = H[ i ]\n Si = S[ i ]\n\n for (let j = 1; j <= m; ++j) {\n Vi[j] = Math.max(\n Si1[ j ] + gap0,\n Vi1[ j ] + gapExtensionPenalty\n )\n\n Hi[j] = Math.max(\n Si[ j - 1 ] + gap0,\n Hi[ j - 1 ] + gapExtensionPenalty\n )\n\n Si[j] = Math.max(\n Si1[ j - 1 ] + scoreFn(i - 1, j - 1), // match\n Vi[ j ], // del\n Hi[ j ] // ins\n )\n }\n }\n\n if (Debug) Log.timeEnd('Alignment.calc')\n\n if (Debug) Log.log(this.S, this.V, this.H)\n }\n\n trace () {\n if (Debug) Log.time('Alignment.trace')\n\n this.ali1 = ''\n this.ali2 = ''\n\n const scoreFn = this.makeScoreFn()\n\n let i = this.n\n let j = this.m\n let mat\n\n if (this.S[i][j] >= this.V[i][j]) {\n mat = 'S'\n this.score = this.S[i][j]\n } else if (this.V[i][j] >= this.H[i][j]) {\n mat = 'V'\n this.score = this.V[i][j]\n } else {\n mat = 'H'\n this.score = this.H[i][j]\n }\n\n if (Debug) Log.log('Alignment: SCORE', this.score)\n if (Debug) Log.log('Alignment: S, V, H', this.S[i][j], this.V[i][j], this.H[i][j])\n\n while (i > 0 && j > 0) {\n if (mat === 'S') {\n if (this.S[i][j] === this.S[i - 1][j - 1] + scoreFn(i - 1, j - 1)) {\n this.ali1 = this.seq1[i - 1] + this.ali1\n this.ali2 = this.seq2[j - 1] + this.ali2\n --i\n --j\n mat = 'S'\n } else if (this.S[i][j] === this.V[i][j]) {\n mat = 'V'\n } else if (this.S[i][j] === this.H[i][j]) {\n mat = 'H'\n } else {\n // Log.debug('Alignment: S');\n --i\n --j\n }\n } else if (mat === 'V') {\n if (this.V[i][j] === this.V[i - 1][j] + this.gapExtensionPenalty) {\n this.ali1 = this.seq1[i - 1] + this.ali1\n this.ali2 = '-' + this.ali2\n --i\n mat = 'V'\n } else if (this.V[i][j] === this.S[i - 1][j] + this.gap(0)) {\n this.ali1 = this.seq1[i - 1] + this.ali1\n this.ali2 = '-' + this.ali2\n --i\n mat = 'S'\n } else {\n // Log.debug('Alignment: V');\n --i\n }\n } else if (mat === 'H') {\n if (this.H[i][j] === this.H[i][j - 1] + this.gapExtensionPenalty) {\n this.ali1 = '-' + this.ali1\n this.ali2 = this.seq2[j - 1] + this.ali2\n --j\n mat = 'H'\n } else if (this.H[i][j] === this.S[i][j - 1] + this.gap(0)) {\n this.ali1 = '-' + this.ali1\n this.ali2 = this.seq2[j - 1] + this.ali2\n --j\n mat = 'S'\n } else {\n // Log.debug('Alignment: H');\n --j\n }\n } else {\n Log.error('Alignment: no matrix')\n }\n }\n\n while (i > 0) {\n this.ali1 = this.seq1[ i - 1 ] + this.ali1\n this.ali2 = '-' + this.ali2\n --i\n }\n\n while (j > 0) {\n this.ali1 = '-' + this.ali1\n this.ali2 = this.seq2[ j - 1 ] + this.ali2\n --j\n }\n\n if (Debug) Log.timeEnd('Alignment.trace')\n\n if (Debug) Log.log([this.ali1, this.ali2])\n }\n}\n\nexport default Alignment\n","/**\n * @file Align Utils\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\nimport Alignment from './alignment'\nimport Superposition from './superposition'\n\n/**\n * Perform structural superposition of two structures,\n * optionally guided by a sequence alignment\n * @param {Structure|StructureView} s1 - structure 1 which is superposed onto structure 2\n * @param {Structure|StructureView} s2 - structure 2 onto which structure 1 is superposed\n * @param {Boolean} [align] - guide the superposition by a sequence alignment\n * @param {String} [sele1] - selection string for structure 1\n * @param {String} [sele2] - selection string for structure 2\n * @return {undefined}\n */\nfunction superpose (s1: Structure, s2: Structure, align = false, sele1 = '', sele2 = '') {\n let i: number\n let j: number\n let n: number\n let atoms1\n let atoms2\n\n if (align) {\n let _s1 = s1\n let _s2 = s2\n\n if (sele1 && sele2) {\n _s1 = s1.getView(new Selection(sele1))\n _s2 = s2.getView(new Selection(sele2))\n }\n\n const seq1 = _s1.getSequence()\n const seq2 = _s2.getSequence()\n\n // Log.log( seq1.join(\"\") );\n // Log.log( seq2.join(\"\") );\n\n const ali = new Alignment(seq1.join(''), seq2.join(''))\n\n ali.calc()\n ali.trace()\n\n // Log.log( \"superpose alignment score\", ali.score );\n\n // Log.log( ali.ali1 );\n // Log.log( ali.ali2 );\n\n let _i, _j\n i = 0\n j = 0\n n = ali.ali1.length\n const aliIdx1: boolean[] = []\n const aliIdx2: boolean[] = []\n\n for (let l = 0; l < n; ++l) {\n const x = ali.ali1[ l ]\n const y = ali.ali2[ l ]\n\n _i = 0\n _j = 0\n\n if (x === '-') {\n aliIdx2[ j ] = false\n } else {\n aliIdx2[ j ] = true\n _i = 1\n }\n\n if (y === '-') {\n aliIdx1[ i ] = false\n } else {\n aliIdx1[ i ] = true\n _j = 1\n }\n\n i += _i\n j += _j\n }\n\n // Log.log( i, j );\n\n // Log.log( aliIdx1 );\n // Log.log( aliIdx2 );\n\n const _atoms1: number[] = []\n const _atoms2: number[] = []\n const ap1 = _s1.getAtomProxy()\n const ap2 = _s2.getAtomProxy()\n\n i = 0\n _s1.eachResidue(function (r) {\n if (r.traceAtomIndex === undefined ||\n r.traceAtomIndex !== r.getAtomIndexByName('CA')) return\n\n if (aliIdx1[ i ]) {\n ap1.index = r.getAtomIndexByName('CA')! // TODO\n _atoms1.push(ap1.x, ap1.y, ap1.z)\n }\n i += 1\n })\n\n i = 0\n _s2.eachResidue(function (r) {\n if (r.traceAtomIndex === undefined ||\n r.traceAtomIndex !== r.getAtomIndexByName('CA')) return\n\n if (aliIdx2[ i ]) {\n ap2.index = r.getAtomIndexByName('CA')! // TODO\n _atoms2.push(ap2.x, ap2.y, ap2.z)\n }\n i += 1\n })\n\n atoms1 = new Float32Array(_atoms1)\n atoms2 = new Float32Array(_atoms2)\n } else {\n const sviewCa1 = s1.getView(new Selection(`${sele1} and .CA`))\n const sviewCa2 = s2.getView(new Selection(`${sele2} and .CA`))\n\n atoms1 = sviewCa1\n atoms2 = sviewCa2\n }\n\n const superpose = new Superposition(atoms1, atoms2)\n const result = superpose.transform(s1)\n s1.refreshPosition()\n return result\n}\n\nexport {\n superpose\n}\n","/**\n * @file Sturucture Component\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { ComponentRegistry, MeasurementDefaultParams } from '../globals'\nimport {\n defaults, /*deepEqual, */createRingBuffer, RingBuffer, createSimpleDict, SimpleDict\n} from '../utils'\nimport { smoothstep } from '../math/math-utils'\nimport Component, { ComponentSignals, ComponentDefaultParameters } from './component'\nimport RepresentationCollection from './representation-collection'\nimport TrajectoryElement from './trajectory-element'\nimport RepresentationElement from './representation-element'\nimport { makeTrajectory } from '../trajectory/trajectory-utils'\nimport { TrajectoryParameters } from '../trajectory/trajectory'\nimport Selection from '../selection/selection'\nimport Structure from '../structure/structure'\nimport StructureView from '../structure/structure-view'\nimport { superpose } from '../align/align-utils'\nimport Stage from '../stage/stage'\nimport StructureRepresentation, { StructureRepresentationParameters } from '../representation/structure-representation'\nimport AtomProxy from '../proxy/atom-proxy'\nimport { Vector3, Box3 } from 'three';\nimport { AngleRepresentationParameters } from '../representation/angle-representation';\nimport { AxesRepresentationParameters } from '../representation/axes-representation';\nimport { BallAndStickRepresentationParameters } from '../representation/ballandstick-representation';\nimport { CartoonRepresentationParameters } from '../representation/cartoon-representation';\nimport { ContactRepresentationParameters } from '../representation/contact-representation';\nimport { DihedralRepresentationParameters } from '../representation/dihedral-representation';\nimport { DihedralHistogramRepresentationParameters } from '../representation/dihedral-histogram-representation';\nimport { DistanceRepresentationParameters } from '../representation/distance-representation';\nimport { HyperballRepresentationParameters } from '../representation/hyperball-representation';\nimport { LabelRepresentationParameters } from '../representation/label-representation';\nimport { LineRepresentationParameters } from '../representation/line-representation';\nimport { PointRepresentationParameters } from '../representation/point-representation';\nimport { SurfaceRepresentationParameters } from '../representation/surface-representation';\nimport { RibbonRepresentationParameters } from '../representation/ribbon-representation';\nimport { RocketRepresentationParameters } from '../representation/rocket-representation';\nimport { TraceRepresentationParameters } from '../representation/trace-representation';\nimport { UnitcellRepresentationParameters } from '../representation/unitcell-representation';\nimport { SliceRepresentationParameters } from '../representation/slice-representation'\nimport { MolecularSurfaceRepresentationParameters } from '../representation/molecularsurface-representation'\nimport { DotRepresentationParameters } from '../representation/dot-representation'\n\nexport type StructureRepresentationType = keyof StructureRepresentationParametersMap\n\ninterface StructureRepresentationParametersMap {\n 'angle': AngleRepresentationParameters,\n 'axes' : AxesRepresentationParameters,\n 'backbone': BallAndStickRepresentationParameters,\n 'ball+stick': BallAndStickRepresentationParameters,\n 'base': BallAndStickRepresentationParameters,\n 'cartoon': CartoonRepresentationParameters,\n 'contact': ContactRepresentationParameters,\n 'dihedral': DihedralRepresentationParameters,\n 'dihedral-histogram': DihedralHistogramRepresentationParameters,\n 'distance': DistanceRepresentationParameters,\n 'dot': DotRepresentationParameters,\n 'helixorient': StructureRepresentationParameters,\n 'hyperball': HyperballRepresentationParameters,\n 'label': LabelRepresentationParameters,\n 'licorice': BallAndStickRepresentationParameters,\n 'line': LineRepresentationParameters,\n 'molecularsurface': MolecularSurfaceRepresentationParameters,\n 'point': PointRepresentationParameters,\n 'ribbon': RibbonRepresentationParameters,\n 'rocket': RocketRepresentationParameters,\n 'rope': CartoonRepresentationParameters,\n 'slice': SliceRepresentationParameters,\n 'spacefill': BallAndStickRepresentationParameters,\n 'surface': SurfaceRepresentationParameters,\n 'trace': TraceRepresentationParameters,\n 'tube': CartoonRepresentationParameters,\n 'unitcell': UnitcellRepresentationParameters,\n 'validation': StructureRepresentationParameters\n}\n\nexport const StructureComponentDefaultParameters = Object.assign({\n sele: '',\n defaultAssembly: ''\n}, ComponentDefaultParameters)\nexport type StructureComponentParameters = typeof StructureComponentDefaultParameters\n\nexport interface StructureComponentSignals extends ComponentSignals {\n trajectoryAdded: Signal // when a trajectory is added\n trajectoryRemoved: Signal // when a trajectory is removed\n defaultAssemblyChanged: Signal // on default assembly change\n}\n\n/**\n * Component wrapping a {@link Structure} object\n *\n * @example\n * // get a structure component by loading a structure file into the stage\n * stage.loadFile( \"rcsb://4opj\" ).then( function( structureComponent ){\n * structureComponent.addRepresentation( \"cartoon\" );\n * structureComponent.autoView();\n * } );\n */\nclass StructureComponent extends Component {\n readonly signals: StructureComponentSignals\n readonly parameters: StructureComponentParameters\n get defaultParameters () { return StructureComponentDefaultParameters }\n\n selection: Selection\n structureView: StructureView\n readonly trajList: TrajectoryElement[] = []\n\n pickBuffer: RingBuffer\n pickDict: SimpleDict\n lastPick?: number\n\n spacefillRepresentation: RepresentationElement\n distanceRepresentation: RepresentationElement\n angleRepresentation: RepresentationElement\n dihedralRepresentation: RepresentationElement\n\n measureRepresentations: RepresentationCollection\n\n constructor (stage: Stage, readonly structure: Structure, params: Partial = {}) {\n super(stage, structure, Object.assign({ name: structure.name }, params))\n\n this.signals = Object.assign(this.signals, {\n trajectoryAdded: new Signal(),\n trajectoryRemoved: new Signal(),\n defaultAssemblyChanged: new Signal()\n })\n\n this.initSelection(this.parameters.sele)\n\n //\n\n this.pickBuffer = createRingBuffer(4)\n this.pickDict = createSimpleDict()\n\n this.spacefillRepresentation = this.addRepresentation('spacefill', {\n sele: 'none',\n opacity: MeasurementDefaultParams.opacity,\n color: MeasurementDefaultParams.color,\n disablePicking: true,\n radiusType: 'data'\n }, true)\n\n this.distanceRepresentation = this.addRepresentation(\n 'distance', MeasurementDefaultParams, true\n )\n this.angleRepresentation = this.addRepresentation(\n 'angle', MeasurementDefaultParams, true\n )\n this.dihedralRepresentation = this.addRepresentation(\n 'dihedral', MeasurementDefaultParams, true\n )\n\n this.measureRepresentations = new RepresentationCollection([\n this.spacefillRepresentation,\n this.distanceRepresentation,\n this.angleRepresentation,\n this.dihedralRepresentation\n ])\n\n //\n\n this.setDefaultAssembly(this.parameters.defaultAssembly)\n\n this.structure.signals.refreshed.add(() => {\n this.updateRepresentations({ position: true })\n })\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'structure' }\n\n /**\n * Initialize selection\n * @private\n * @param {String} sele - selection string\n * @return {undefined}\n */\n initSelection (sele: string) {\n /**\n * Selection for {@link StructureComponent#structureView}\n * @private\n * @type {Selection}\n */\n this.selection = new Selection(sele)\n\n /**\n * View on {@link StructureComponent#structure}.\n * Change its selection via {@link StructureComponent#setSelection}.\n * @type {StructureView}\n */\n this.structureView = new StructureView(\n this.structure, this.selection\n )\n\n this.selection.signals.stringChanged.add(() => {\n this.structureView.setSelection(this.selection)\n\n this.rebuildRepresentations()\n this.rebuildTrajectories()\n })\n }\n\n /**\n * Set selection of {@link StructureComponent#structureView}\n * @param {String} string - selection string\n * @return {StructureComponent} this object\n */\n setSelection (string: string) {\n this.parameters.sele = string\n this.selection.setString(string)\n return this\n }\n\n /**\n * Set the default assembly\n * @param {String} value - assembly name\n * @return {undefined}\n */\n setDefaultAssembly (value:string) {\n // filter out non-exsisting assemblies\n if (this.structure.biomolDict[value] === undefined) value = ''\n // only set default assembly when changed\n if (this.parameters.defaultAssembly !== value) {\n const reprParams = { defaultAssembly: value }\n this.reprList.forEach(repr => repr.setParameters(reprParams))\n this.measureRepresentations.setParameters(reprParams)\n this.parameters.defaultAssembly = value\n this.signals.defaultAssemblyChanged.dispatch(value)\n }\n return this\n }\n\n /**\n * Rebuild all representations\n * @return {undefined}\n */\n rebuildRepresentations () {\n this.reprList.forEach((repr: RepresentationElement) => {\n repr.build()\n })\n this.measureRepresentations.build()\n }\n\n /**\n * Rebuild all trajectories\n * @return {undefined}\n */\n rebuildTrajectories () {\n this.trajList.forEach(trajComp => {\n trajComp.trajectory.setStructure(this.structureView)\n })\n }\n\n updateRepresentations (what: any) {\n super.updateRepresentations(what)\n this.measureRepresentations.update(what)\n }\n\n /**\n * Overrides {@link Component.updateRepresentationMatrices} \n * to also update matrix for measureRepresentations \n */\n updateRepresentationMatrices () {\n super.updateRepresentationMatrices()\n this.measureRepresentations.setParameters({ matrix: this.matrix })\n }\n\n addRepresentation (\n type: K,\n params: Partial|{defaultAssembly: string} = {},\n hidden = false\n ) {\n params.defaultAssembly = this.parameters.defaultAssembly\n\n const reprComp = this._addRepresentation(type, this.structureView, params, hidden)\n if (!hidden) {\n reprComp.signals.parametersChanged.add(() => this.measureUpdate())\n }\n return reprComp\n }\n\n /**\n * Add a new trajectory component to the structure\n */\n addTrajectory (trajPath = '', params: { [k: string]: any } = {}) {\n const traj = makeTrajectory(trajPath, this.structureView, params as TrajectoryParameters)\n\n const trajComp = new TrajectoryElement(this.stage, traj, params)\n this.trajList.push(trajComp)\n this.signals.trajectoryAdded.dispatch(trajComp)\n\n return trajComp\n }\n\n removeTrajectory (traj: TrajectoryElement) {\n const idx = this.trajList.indexOf(traj)\n if (idx !== -1) {\n this.trajList.splice(idx, 1)\n }\n\n traj.dispose()\n\n this.signals.trajectoryRemoved.dispatch(traj)\n }\n\n dispose () {\n // copy via .slice because side effects may change trajList\n this.trajList.slice().forEach(traj => traj.dispose())\n\n this.trajList.length = 0\n this.structure.dispose()\n this.measureRepresentations.dispose()\n\n super.dispose()\n }\n\n /**\n * Automatically center and zoom the component\n * @param {String|Integer} [sele] - selection string or duration if integer\n * @param {Integer} [duration] - duration of the animation, defaults to 0\n * @return {undefined}\n */\n autoView (sele?: string|number, duration?: number) {\n if (typeof sele === 'number') {\n duration = sele\n sele = ''\n }\n\n this.stage.animationControls.zoomMove(\n this.getCenter(sele),\n this.getZoom(sele),\n defaults(duration, 0)\n )\n }\n\n getBoxUntransformed (sele: string): Box3 {\n let bb\n\n if (sele) {\n bb = this.structureView.getBoundingBox(new Selection(sele))\n } else {\n bb = this.structureView.boundingBox\n }\n\n return bb\n }\n\n getCenterUntransformed (sele: string): Vector3 {\n if (sele && typeof sele === 'string') {\n return this.structure.atomCenter(new Selection(sele))\n } else {\n return this.structure.center\n }\n }\n\n superpose (component: StructureComponent, align: boolean, sele1: string, sele2: string) {\n superpose(\n this.structureView, component.structureView, align, sele1, sele2\n )\n\n this.updateRepresentations({ 'position': true })\n\n return this\n }\n\n getMaxRepresentationRadius (atomIndex: number) {\n let maxRadius = 0\n const atom = this.structure.getAtomProxy(atomIndex)\n this.eachRepresentation(reprElem => {\n if (reprElem.getVisibility()) {\n const repr: StructureRepresentation = reprElem.repr as any // TODO\n maxRadius = Math.max(repr.getAtomRadius(atom), maxRadius)\n }\n })\n return maxRadius\n }\n\n measurePick (atom: AtomProxy) {\n const pickCount = this.pickBuffer.count\n\n if (this.lastPick === atom.index && pickCount >= 1) {\n if (pickCount > 1) {\n const atomList = this.pickBuffer.data\n const atomListSorted = this.pickBuffer.data.sort()\n if (this.pickDict.has(atomListSorted)) {\n this.pickDict.del(atomListSorted)\n } else {\n this.pickDict.add(atomListSorted, atomList)\n }\n if (pickCount === 2) {\n this.distanceRepresentation.setParameters({\n atomPair: this.pickDict.values.filter(l => l.length === 2)\n })\n } else if (pickCount === 3) {\n this.angleRepresentation.setParameters({\n atomTriple: this.pickDict.values.filter(l => l.length === 3)\n })\n } else if (pickCount === 4) {\n this.dihedralRepresentation.setParameters({\n atomQuad: this.pickDict.values.filter(l => l.length === 4)\n })\n }\n }\n this.pickBuffer.clear()\n this.lastPick = undefined\n } else {\n if (!this.pickBuffer.has(atom.index)) {\n this.pickBuffer.push(atom.index)\n }\n this.lastPick = atom.index\n }\n\n this.measureUpdate()\n }\n\n measureClear () {\n this.pickBuffer.clear()\n this.lastPick = undefined\n this.spacefillRepresentation.setSelection('none')\n }\n\n measureBuild () {\n const md = this.measureData()\n this.distanceRepresentation.setParameters({ atomPair: md.distance })\n this.angleRepresentation.setParameters({ atomTriple: md.angle })\n this.dihedralRepresentation.setParameters({ atomQuad: md.dihedral })\n }\n\n measureUpdate () {\n const pickData = this.pickBuffer.data\n const radiusData: { [k: number]: number } = {}\n pickData.forEach(ai => {\n const r = Math.max(0.1, this.getMaxRepresentationRadius(ai))\n radiusData[ ai ] = r * (2.3 - smoothstep(0.1, 2, r))\n })\n this.spacefillRepresentation.setSelection(\n pickData.length ? ( '@' + pickData.join(',') ) : 'none'\n )\n if (pickData.length)\n this.spacefillRepresentation.setParameters({ radiusData })\n }\n\n measureData () {\n const pv = this.pickDict.values\n return {\n distance: pv.filter(l => l.length === 2),\n angle: pv.filter(l => l.length === 3),\n dihedral: pv.filter(l => l.length === 4)\n }\n }\n\n /**\n * Remove all measurements, optionally limit to distance, angle or dihedral\n */\n removeAllMeasurements (type?: MeasurementFlags) {\n const pd = this.pickDict\n const pv = pd.values\n const remove = function (len: number) {\n pv.filter(l => l.length === len).forEach(l => pd.del(l.slice().sort()))\n }\n if (!type || type & MeasurementFlags.Distance) remove(2)\n if (!type || type & MeasurementFlags.Angle) remove(3)\n if (!type || type & MeasurementFlags.Dihedral) remove(4)\n this.measureBuild()\n }\n\n /**\n * Remove a measurement given as a pair, triple, quad of atom indices\n */\n removeMeasurement (atomList: number[]) {\n this.pickDict.del(atomList.slice().sort())\n this.measureBuild()\n }\n\n /**\n * Add a measurement given as a pair, triple, quad of atom indices\n */\n addMeasurement (atomList: number[]) {\n if (atomList.length < 2 || atomList.length > 4) return\n const atomListSorted = atomList.slice().sort()\n if (!this.pickDict.has(atomListSorted)) {\n this.pickDict.add(atomListSorted, atomList)\n }\n this.measureBuild()\n }\n}\n\nexport const enum MeasurementFlags {\n Distance = 0x1,\n Angle = 0x2,\n Dihedral = 0x4\n}\n\nComponentRegistry.add('structure', StructureComponent)\nComponentRegistry.add('structureview', StructureComponent)\n\nexport default StructureComponent\n","/**\n * @file Trajectory Utils\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Frames from './frames'\nimport { TrajectoryParameters } from './trajectory'\nimport FramesTrajectory from './frames-trajectory'\nimport StructureTrajectory from './structure-trajectory'\nimport RemoteTrajectory from './remote-trajectory'\nimport CallbackTrajectory from './callback-trajectory'\n\nexport function makeTrajectory (trajSrc: string|Frames, structure: Structure, params: TrajectoryParameters) {\n let traj\n\n if (trajSrc && trajSrc instanceof Frames) {\n traj = new FramesTrajectory(trajSrc, structure, params)\n } else if (!trajSrc && structure.frames) {\n traj = new StructureTrajectory(trajSrc, structure, params)\n } else if (trajSrc && typeof trajSrc === 'function') {\n traj = new CallbackTrajectory(trajSrc, structure, params)\n } else {\n traj = new RemoteTrajectory(trajSrc, structure, params)\n }\n\n return traj\n}\n\n","/**\n * @file Surface Component\n * @author Alexander Rose \n * @private\n */\n\nimport { ComponentRegistry } from '../globals'\nimport Component, { ComponentParameters } from './component'\nimport Stage from '../stage/stage'\nimport Surface from '../surface/surface'\nimport { Vector3, Box3 } from 'three';\nimport RepresentationElement from './representation-element';\n\nexport type SurfaceRepresentationType = 'surface'|'dot'\n\n/**\n * Component wrapping a {@link Surface} object\n *\n * @example\n * // get a surface component by loading a surface file into the stage\n * stage.loadFile( \"url/for/surface\" ).then( function( surfaceComponent ){\n * surfaceComponent.addRepresentation( \"surface\" );\n * surfaceComponent.autoView();\n * } );\n */\nclass SurfaceComponent extends Component {\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {Surface} surface - surface object to wrap\n * @param {ComponentParameters} params - component parameters\n */\n constructor (stage: Stage, readonly surface: Surface, params: Partial = {}) {\n super(stage, surface, Object.assign({ name: surface.name }, params))\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'surface' }\n\n /**\n * Add a new surface representation to the component\n * @param {String} type - the name of the representation, one of:\n * surface, dot.\n * @param {SurfaceRepresentationParameters} params - representation parameters\n * @return {RepresentationComponent} the created representation wrapped into\n * a representation component object\n */\n addRepresentation (type: SurfaceRepresentationType, params: { [k: string]: any } = {}): RepresentationElement {\n return this._addRepresentation(type, this.surface, params)\n }\n\n getBoxUntransformed (): Box3 {\n return this.surface.boundingBox\n }\n\n getCenterUntransformed (): Vector3 {\n return this.surface.center\n }\n\n dispose () {\n this.surface.dispose()\n super.dispose()\n }\n}\n\nComponentRegistry.add('surface', SurfaceComponent)\n\nexport default SurfaceComponent\n","/**\n * @file Volume Component\n * @author Alexander Rose \n * @private\n */\n\nimport { ComponentRegistry } from '../globals'\nimport Component, { ComponentParameters } from './component'\nimport Stage from '../stage/stage'\nimport Volume from '../surface/volume'\nimport { Box3, Vector3 } from 'three';\nimport RepresentationElement from './representation-element';\n\nexport type VolumeRepresentationType = 'surface'|'slice'|'dot'\n\n/**\n * Component wrapping a {@link Volume} object\n *\n * @example\n * // get a volume component by loading a volume file into the stage\n * stage.loadFile( \"url/for/volume\" ).then(function(volumeComponent){\n * volumeComponent.addRepresentation('surface');\n * volumeComponent.autoView();\n * });\n */\nclass VolumeComponent extends Component {\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {Volume} volume - volume object to wrap\n * @param {ComponentParameters} params - component parameters\n */\n constructor (stage: Stage, readonly volume: Volume, params: Partial = {}) {\n super(stage, volume, Object.assign({ name: volume.name }, params))\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'volume' }\n\n /**\n * Add a new volume representation to the component\n */\n addRepresentation (type: VolumeRepresentationType, params: { [k: string]: any } = {}): RepresentationElement {\n return this._addRepresentation(type, this.volume, params)\n }\n\n getBoxUntransformed (): Box3 {\n return this.volume.boundingBox\n }\n\n getCenterUntransformed (): Vector3 {\n return this.volume.center\n }\n\n dispose () {\n this.volume.dispose()\n\n super.dispose()\n }\n}\n\nComponentRegistry.add('volume', VolumeComponent)\n\nexport default VolumeComponent\n","/**\n * @file Component Collection\n * @author Alexander Rose \n * @private\n */\n\nimport Component from './component'\nimport Collection from './collection'\n\nclass ComponentCollection extends Collection {\n addRepresentation (name: string, params: any) {\n \treturn this.forEach((comp) => comp.addRepresentation(name, params))\n }\n\n autoView (duration: number) {\n return this.forEach((comp) => comp.autoView(duration))\n }\n}\n\nexport default ComponentCollection\n","/**\n * @file Stage\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3 } from 'three'\nimport { Signal } from 'signals'\n\nimport {\n Debug, Log, Mobile, ComponentRegistry, ParserRegistry\n} from '../globals'\nimport { defaults, createParams, updateParams } from '../utils'\nimport { degToRad, clamp, pclamp } from '../math/math-utils'\nimport Counter from '../utils/counter'\nimport Viewer from '../viewer/viewer'\nimport { ImageParameters } from '../viewer/viewer-utils'\nimport MouseObserver from './mouse-observer'\n\nimport TrackballControls from '../controls/trackball-controls'\nimport PickingControls from '../controls/picking-controls'\nimport ViewerControls from '../controls/viewer-controls'\nimport AnimationControls from '../controls/animation-controls'\nimport MouseControls, { MouseControlPreset } from '../controls/mouse-controls'\nimport KeyControls from '../controls/key-controls'\n\nimport PickingBehavior from './picking-behavior'\nimport MouseBehavior from './mouse-behavior'\nimport AnimationBehavior from './animation-behavior'\nimport KeyBehavior from './key-behavior'\n\nimport Component, { ComponentParameters } from '../component/component'\nimport RepresentationElement from '../component/representation-element'\nimport StructureComponent from '../component/structure-component'\nimport SurfaceComponent from '../component/surface-component'\nimport VolumeComponent from '../component/volume-component'\nimport ComponentCollection from '../component/component-collection'\nimport RepresentationCollection from '../component/representation-collection'\nimport { autoLoad, getFileInfo, LoaderParameters } from '../loader/loader-utils'\nimport { ParserParams } from '../loader/parser-loader'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Animation from '../animation/animation'\nimport Selection from '../selection/selection'\n\nimport Structure from '../structure/structure'\nimport Surface from '../surface/surface'\nimport Volume from '../surface/volume'\nimport Shape from '../geometry/shape'\nimport Script from '../script'\n\nfunction matchName (name: string|RegExp, object: { name: string }) {\n if (name instanceof RegExp) {\n return object.name.match(name) !== null\n } else {\n return object.name === name\n }\n}\n\nconst tmpZoomVector = new Vector3()\n\ndeclare global {\n interface Document {\n mozFullScreen: boolean\n mozFullScreenEnabled: boolean\n mozFullScreenElement: Element\n mozCancelFullScreen(): void\n\n msFullscreenEnabled: boolean\n msFullscreenElement: Element\n msExitFullscreen(): void\n }\n\n interface Element {\n mozRequestFullScreen(): void\n msRequestFullscreen(): void\n }\n}\n\n/**\n * Stage parameter object.\n * @typedef {Object} StageParameters - stage parameters\n * @property {Color} backgroundColor - background color\n * @property {Integer} sampleLevel - sampling level for antialiasing, between -1 and 5;\n * -1: no sampling, 0: only sampling when not moving\n * @property {Boolean} workerDefault - default value for useWorker parameter of representations\n * @property {Float} rotateSpeed - camera-controls rotation speed, between 0 and 10\n * @property {Float} zoomSpeed - camera-controls zoom speed, between 0 and 10\n * @property {Float} panSpeed - camera-controls pan speed, between 0 and 10\n * @property {Float} clipNear - position of camera near/front clipping plane\n * in percent of scene bounding box\n * @property {Float} clipFar - position of camera far/back clipping plane\n * in percent of scene bounding box\n * @property {Float} clipDist - camera clipping distance in Angstrom\n * @property {String} clipMode - how to interpret clipNear/Far and fogNear/Far values: \"scene\" for scene-relative, \"camera\" for camera-relative\n * @property {String} clipScale - \"relative\" or \"absolute\": interpret clipNear/Far and fogNear/Far as percentage of bounding box or absolute Angstroms (ignored when clipMode==camera)\n * @property {Float} fogNear - position of the start of the fog effect\n * in percent of scene bounding box\n * @property {Float} fogFar - position where the fog is in full effect\n * in percent of scene bounding box\n * @property {String} cameraType - type of camera, either 'persepective' or 'orthographic'\n * @property {Float} cameraFov - perspective camera field of view in degree, between 15 and 120\n * @property {Float} cameraEyeSep - stereo camera eye seperation\n * @property {Color} lightColor - point light color\n * @property {Float} lightIntensity - point light intensity\n * @property {Color} ambientColor - ambient light color\n * @property {Float} ambientIntensity - ambient light intensity\n * @property {Integer} hoverTimeout - timeout for hovering\n */\n\nexport interface StageSignals {\n parametersChanged: Signal\n fullscreenChanged: Signal\n componentAdded: Signal\n componentRemoved: Signal\n clicked: Signal\n hovered: Signal\n}\n\nexport type RenderQualityType = 'auto'|'low'|'medium'|'high'\n\nexport const StageDefaultParameters = {\n impostor: true,\n quality: 'medium' as RenderQualityType,\n workerDefault: true,\n sampleLevel: 0,\n backgroundColor: 'black' as string|number,\n rotateSpeed: 2.0,\n zoomSpeed: 1.2,\n panSpeed: 1.0,\n clipNear: 0,\n clipFar: 100,\n clipDist: 10,\n clipMode: 'scene',\n clipScale: 'relative',\n fogNear: 50,\n fogFar: 100,\n cameraFov: 40,\n cameraEyeSep: 0.3,\n cameraType: 'perspective' as 'perspective'|'orthographic'|'stereo',\n lightColor: 0xdddddd as string|number,\n lightIntensity: 1.0,\n ambientColor: 0xdddddd as string|number,\n ambientIntensity: 0.2,\n hoverTimeout: 0,\n tooltip: true,\n mousePreset: 'default' as MouseControlPreset\n}\nexport type StageParameters = typeof StageDefaultParameters\n\nexport interface StageLoadFileParams extends LoaderParameters {\n defaultRepresentation: boolean,\n assembly: string\n}\n\n/**\n * Stage class, central for creating molecular scenes with NGL.\n *\n * @example\n * var stage = new Stage( \"elementId\", { backgroundColor: \"white\" } );\n */\nclass Stage {\n signals: StageSignals = {\n parametersChanged: new Signal(),\n fullscreenChanged: new Signal(),\n componentAdded: new Signal(),\n componentRemoved: new Signal(),\n clicked: new Signal(),\n hovered: new Signal()\n }\n parameters: StageParameters\n\n /**\n * Counter that keeps track of various potentially long-running tasks,\n * including file loading and surface calculation.\n */\n tasks = new Counter()\n compList: Component[] = []\n defaultFileParams = {}\n logList: string[] = []\n\n transformComponent?: Component\n transformAtom?: AtomProxy\n\n viewer: Viewer\n tooltip: HTMLElement\n lastFullscreenElement: HTMLElement\n\n mouseObserver: MouseObserver\n viewerControls: ViewerControls\n trackballControls: TrackballControls\n pickingControls: PickingControls\n animationControls: AnimationControls\n mouseControls: MouseControls\n keyControls: KeyControls\n\n pickingBehavior: PickingBehavior\n mouseBehavior: MouseBehavior\n animationBehavior: AnimationBehavior\n keyBehavior: KeyBehavior\n\n spinAnimation: Animation\n rockAnimation: Animation\n\n constructor (idOrElement: string|HTMLElement, params: Partial = {}) {\n this.viewer = new Viewer(idOrElement)\n if (!this.viewer.renderer) return\n\n this.tooltip = document.createElement('div')\n Object.assign(this.tooltip.style, {\n display: 'none',\n position: 'fixed',\n zIndex: '1000000',\n pointerEvents: 'none',\n backgroundColor: 'rgba( 0, 0, 0, 0.6 )',\n color: 'lightgrey',\n padding: '8px',\n fontFamily: 'sans-serif'\n })\n this.viewer.container.appendChild(this.tooltip)\n\n this.mouseObserver = new MouseObserver(this.viewer.renderer.domElement)\n this.viewerControls = new ViewerControls(this)\n this.trackballControls = new TrackballControls(this)\n this.pickingControls = new PickingControls(this)\n this.animationControls = new AnimationControls(this)\n this.mouseControls = new MouseControls(this)\n this.keyControls = new KeyControls(this)\n\n this.pickingBehavior = new PickingBehavior(this)\n this.mouseBehavior = new MouseBehavior(this)\n this.animationBehavior = new AnimationBehavior(this)\n this.keyBehavior = new KeyBehavior(this)\n\n this.spinAnimation = this.animationControls.spin([ 0, 1, 0 ], 0.005)\n this.spinAnimation.pause(true)\n this.rockAnimation = this.animationControls.rock([ 0, 1, 0 ], 0.005)\n this.rockAnimation.pause(true)\n\n // must come after the viewer has been instantiated\n this.parameters = createParams(params, StageDefaultParameters)\n this.setParameters(this.parameters)\n\n this.viewer.animate()\n }\n\n /**\n * Set stage parameters\n */\n setParameters (params: Partial = {}) {\n updateParams(this.parameters, params)\n\n const p = params\n const tp = this.parameters\n\n const viewer = this.viewer\n const controls = this.trackballControls\n\n // apply parameters\n if (p.quality !== undefined) this.setQuality(tp.quality)\n if (p.impostor !== undefined) this.setImpostor(tp.impostor)\n if (p.rotateSpeed !== undefined) controls.rotateSpeed = tp.rotateSpeed\n if (p.zoomSpeed !== undefined) controls.zoomSpeed = tp.zoomSpeed\n if (p.panSpeed !== undefined) controls.panSpeed = tp.panSpeed\n if (p.mousePreset !== undefined) this.mouseControls.preset(tp.mousePreset)\n this.mouseObserver.setParameters({ hoverTimeout: tp.hoverTimeout })\n viewer.setClip(tp.clipNear, tp.clipFar, tp.clipDist, tp.clipMode, tp.clipScale)\n viewer.setFog(undefined, tp.fogNear, tp.fogFar)\n viewer.setCamera(tp.cameraType, tp.cameraFov, tp.cameraEyeSep)\n viewer.setSampling(tp.sampleLevel)\n viewer.setBackground(tp.backgroundColor)\n viewer.setLight(tp.lightColor, tp.lightIntensity, tp.ambientColor, tp.ambientIntensity)\n\n this.signals.parametersChanged.dispatch(this.getParameters())\n\n return this\n }\n\n log (msg: string) {\n console.log('STAGE LOG', msg)\n this.logList.push(msg)\n }\n\n /**\n * Get stage parameters\n */\n getParameters () {\n return Object.assign({}, this.parameters)\n }\n\n /**\n * Create default representations for the given component\n * @param {StructureComponent|SurfaceComponent} object - component to create the representations for\n * @return {undefined}\n */\n defaultFileRepresentation (component: Component) {\n if (component instanceof StructureComponent) {\n component.setSelection('/0')\n\n let atomCount, residueCount, instanceCount\n const structure = component.structure\n\n if (structure.biomolDict.BU1) {\n const assembly = structure.biomolDict.BU1\n atomCount = assembly.getAtomCount(structure)\n residueCount = assembly.getResidueCount(structure)\n instanceCount = assembly.getInstanceCount()\n component.setDefaultAssembly('BU1')\n } else {\n atomCount = structure.getModelProxy(0).atomCount\n residueCount = structure.getModelProxy(0).residueCount\n instanceCount = 1\n }\n\n let sizeScore = atomCount\n\n if (Mobile) {\n sizeScore *= 4\n }\n\n const backboneOnly = structure.atomStore.count / structure.residueStore.count < 2\n if (backboneOnly) {\n sizeScore *= 10\n }\n\n let colorScheme = 'chainname'\n let colorScale = 'RdYlBu'\n let colorReverse = false\n if (structure.getChainnameCount(new Selection('polymer and /0')) === 1) {\n colorScheme = 'residueindex'\n colorScale = 'Spectral'\n colorReverse = true\n }\n\n if (Debug) console.log(sizeScore, atomCount, instanceCount, backboneOnly)\n\n if (residueCount / instanceCount < 4) {\n component.addRepresentation('ball+stick', {\n colorScheme: 'element',\n radiusScale: 2.0,\n aspectRatio: 1.5,\n bondScale: 0.3,\n bondSpacing: 0.75,\n quality: 'auto'\n })\n } else if ((instanceCount > 5 && sizeScore > 15000) || sizeScore > 700000) {\n let scaleFactor = (\n Math.min(\n 2.0,\n Math.max(\n 0.1,\n 6000 / (sizeScore / instanceCount)\n )\n )\n )\n if (backboneOnly) scaleFactor = Math.min(scaleFactor, 0.5)\n\n component.addRepresentation('surface', {\n colorScheme, colorScale, colorReverse,\n sele: 'polymer',\n surfaceType: 'av',\n probeRadius: 1.4,\n scaleFactor: scaleFactor,\n useWorker: false\n })\n } else if (sizeScore > 250000) {\n component.addRepresentation('backbone', {\n colorScheme, colorScale, colorReverse,\n lineOnly: true\n })\n } else if (sizeScore > 100000) {\n component.addRepresentation('backbone', {\n colorScheme, colorScale, colorReverse,\n quality: 'low',\n disableImpostor: true,\n radiusScale: 2.0\n })\n } else if (sizeScore > 80000) {\n component.addRepresentation('backbone', {\n colorScheme, colorScale, colorReverse,\n radiusScale: 2.0\n })\n } else {\n component.addRepresentation('cartoon', {\n colorScheme, colorScale, colorReverse,\n radiusScale: 0.7,\n aspectRatio: 5,\n quality: 'auto'\n })\n if (sizeScore < 50000) {\n component.addRepresentation('base', {\n colorScheme, colorScale, colorReverse,\n quality: 'auto'\n })\n }\n component.addRepresentation('ball+stick', {\n sele: 'ligand',\n colorScheme: 'element',\n radiusScale: 2.0,\n aspectRatio: 1.5,\n bondScale: 0.3,\n bondSpacing: 0.75,\n quality: 'auto'\n })\n }\n\n // add frames as trajectory\n if (component.structure.frames.length) {\n component.addTrajectory()\n }\n } else if (component instanceof SurfaceComponent) {\n component.addRepresentation('surface')\n } else if (component instanceof VolumeComponent) {\n component.addRepresentation('surface')\n }\n\n this.tasks.onZeroOnce(this.autoView, this)\n }\n\n /**\n * Load a file onto the stage\n *\n * @example\n * // load from URL\n * stage.loadFile( \"http://files.rcsb.org/download/5IOS.cif\" );\n *\n * @example\n * // load binary data in CCP4 format via a Blob\n * var binaryBlob = new Blob( [ ccp4Data ], { type: 'application/octet-binary'} );\n * stage.loadFile( binaryBlob, { ext: \"ccp4\" } );\n *\n * @example\n * // load string data in PDB format via a Blob\n * var stringBlob = new Blob( [ pdbData ], { type: 'text/plain'} );\n * stage.loadFile( stringBlob, { ext: \"pdb\" } );\n *\n * @example\n * // load a File object\n * stage.loadFile( file );\n *\n * @example\n * // load from URL and add a 'ball+stick' representation with double/triple bonds\n * stage.loadFile( \"http://files.rcsb.org/download/1crn.cif\" ).then( function( comp ){\n * comp.addRepresentation( \"ball+stick\", { multipleBond: true } );\n * } );\n *\n * @param {String|File|Blob} path - either a URL or an object containing the file data\n * @param {LoaderParameters} params - loading parameters\n * @param {Boolean} params.asTrajectory - load multi-model structures as a trajectory\n * @return {Promise} A Promise object that resolves to a {@link StructureComponent},\n * a {@link SurfaceComponent} or a {@link ScriptComponent} object,\n * depending on the type of the loaded file.\n */\n loadFile (path: string|File|Blob, params: Partial = {}) {\n const p = Object.assign({}, this.defaultFileParams, params)\n const name = getFileInfo(path).name\n\n this.tasks.increment()\n this.log(`loading file '${name}'`)\n\n const onLoadFn = (object: Structure|Surface|Volume) => {\n this.log(`loaded '${name}'`)\n\n const component = this.addComponentFromObject(object, p)\n if (p.defaultRepresentation) {\n this.defaultFileRepresentation(component as Component)\n }\n this.tasks.decrement()\n\n return component\n }\n\n const onErrorFn = (e: Error|string) => {\n this.tasks.decrement()\n const errorMsg = `error loading file: '${e}'`\n this.log(errorMsg)\n throw errorMsg // throw so it can be catched\n }\n\n const ext = defaults(p.ext, getFileInfo(path).ext)\n let promise: Promise\n\n if (ParserRegistry.isTrajectory(ext)) {\n promise = Promise.reject(\n new Error(`loadFile: ext '${ext}' is a trajectory and must be loaded into a structure component`)\n )\n } else {\n promise = autoLoad(path, p)\n }\n\n return promise.then(onLoadFn, onErrorFn)\n }\n\n loadScript (path: string|File|Blob) {\n const name = getFileInfo(path).name\n\n this.log(`loading script '${name}'`)\n\n return autoLoad(path).then(\n (script: Script) => {\n this.tasks.increment()\n this.log(`running script '${name}'`)\n script.run(this).then(() => {\n this.tasks.decrement()\n this.log(`finished script '${name}'`)\n })\n this.log(`called script '${name}'`)\n },\n (error: Error|string) => {\n this.tasks.decrement()\n const errorMsg = `errored script '${name}' \"${error}\"`\n this.log(errorMsg)\n throw errorMsg // throw so it can be catched\n }\n )\n }\n\n /**\n * Add the given component to the stage\n * @param {Component} component - the component to add\n * @return {undefined}\n */\n addComponent (component: Component) {\n if (!component) {\n Log.warn('Stage.addComponent: no component given')\n return\n }\n\n this.compList.push(component)\n this.signals.componentAdded.dispatch(component)\n }\n\n /**\n * Create a component from the given object and add to the stage\n */\n addComponentFromObject (object: Structure|Surface|Volume|Shape, params: Partial = {}): void|Component {\n const CompClass = ComponentRegistry.get(object.type)\n\n if (CompClass) {\n const component = new CompClass(this, object, params)\n this.addComponent(component)\n return component\n }\n\n Log.warn('no component for object type', object.type)\n }\n\n /**\n * Remove the given component\n * @param {Component} component - the component to remove\n * @return {undefined}\n */\n removeComponent (component: Component) {\n const idx = this.compList.indexOf(component)\n if (idx !== -1) {\n this.compList.splice(idx, 1)\n component.dispose()\n this.signals.componentRemoved.dispatch(component)\n }\n }\n\n /**\n * Remove all components from the stage\n */\n removeAllComponents () {\n this.compList.slice().forEach(o => this.removeComponent(o))\n }\n\n /**\n * Handle any size-changes of the container element\n * @return {undefined}\n */\n handleResize () {\n this.viewer.handleResize()\n }\n\n /**\n * Set width and height\n * @param {String} width - CSS width value\n * @param {String} height - CSS height value\n * @return {undefined}\n */\n setSize (width: string, height: string) {\n const container = this.viewer.container\n\n if (container !== document.body) {\n if (width !== undefined) container.style.width = width\n if (height !== undefined) container.style.height = height\n this.handleResize()\n }\n }\n\n /**\n * Toggle fullscreen\n * @param {Element} [element] - document element to put into fullscreen,\n * defaults to the viewer container\n * @return {undefined}\n */\n toggleFullscreen (element: HTMLElement) {\n if (!document.fullscreenEnabled && !document.mozFullScreenEnabled &&\n !(document as any).webkitFullscreenEnabled && !document.msFullscreenEnabled\n ) {\n Log.log('fullscreen mode (currently) not possible')\n return\n }\n\n const self = this\n element = element || this.viewer.container\n this.lastFullscreenElement = element\n\n //\n\n function getFullscreenElement () {\n return document.fullscreenElement || document.mozFullScreenElement ||\n (document as any).webkitFullscreenElement || document.msFullscreenElement\n }\n\n function resizeElement () {\n if (!getFullscreenElement() && self.lastFullscreenElement) {\n const element = self.lastFullscreenElement\n element.style.width = element.dataset.normalWidth || ''\n element.style.height = element.dataset.normalHeight || ''\n\n document.removeEventListener('fullscreenchange', resizeElement)\n document.removeEventListener('mozfullscreenchange', resizeElement)\n document.removeEventListener('webkitfullscreenchange', resizeElement)\n document.removeEventListener('MSFullscreenChange', resizeElement)\n\n self.handleResize()\n self.signals.fullscreenChanged.dispatch(false)\n }\n }\n\n //\n\n if (!getFullscreenElement()) {\n element.dataset.normalWidth = element.style.width || ''\n element.dataset.normalHeight = element.style.height || ''\n element.style.width = window.screen.width + 'px'\n element.style.height = window.screen.height + 'px'\n\n if (element.requestFullscreen) {\n element.requestFullscreen()\n } else if (element.msRequestFullscreen) {\n element.msRequestFullscreen()\n } else if (element.mozRequestFullScreen) {\n element.mozRequestFullScreen()\n } else if ((element as any).webkitRequestFullscreen) {\n (element as any).webkitRequestFullscreen()\n }\n\n document.addEventListener('fullscreenchange', resizeElement)\n document.addEventListener('mozfullscreenchange', resizeElement)\n document.addEventListener('webkitfullscreenchange', resizeElement)\n document.addEventListener('MSFullscreenChange', resizeElement)\n\n this.handleResize()\n this.signals.fullscreenChanged.dispatch(true)\n\n // workaround for Safari\n setTimeout(function () { self.handleResize() }, 100)\n } else {\n if (document.exitFullscreen) {\n document.exitFullscreen()\n } else if (document.msExitFullscreen) {\n document.msExitFullscreen()\n } else if (document.mozCancelFullScreen) {\n document.mozCancelFullScreen()\n } else if ((document as any).webkitExitFullscreen) {\n (document as any).webkitExitFullscreen()\n }\n }\n }\n\n /**\n * Set spin\n * @param {Boolean} flag - if true start rocking and stop spinning\n * @return {undefined}\n */\n setSpin (flag: boolean) {\n if (flag) {\n this.spinAnimation.resume(true)\n this.rockAnimation.pause(true)\n } else {\n this.spinAnimation.pause(true)\n }\n }\n\n /**\n * Set rock\n * @param {Boolean} flag - if true start rocking and stop spinning\n * @return {undefined}\n */\n setRock (flag: boolean) {\n if (flag) {\n this.rockAnimation.resume(true)\n this.spinAnimation.pause(true)\n } else {\n this.rockAnimation.pause(true)\n }\n }\n\n /**\n * Toggle spin\n * @return {undefined}\n */\n toggleSpin () {\n this.setSpin(this.spinAnimation.paused)\n }\n\n /**\n * Toggle rock\n * @return {undefined}\n */\n toggleRock () {\n this.setRock(this.rockAnimation.paused)\n }\n\n /**\n * Get the current focus from the current clipNear value expressed\n * as 0 (full view) to 100 (completely clipped)\n * Negative values may be returned in some cases.\n *\n * In 'camera' clipMode focus isn't applicable, this method returns 0.0\n *\n * @return {number} focus\n */\n getFocus () : number {\n const p = this.parameters\n if (p.clipMode !== 'scene') return 0.0\n\n let clipNear = p.clipNear\n if (p.clipScale === 'absolute') {\n clipNear = this.viewer.absoluteToRelative(clipNear)\n }\n return clipNear * 2\n }\n\n\n /**\n * Set the focus, a value of 0 sets clipping planes to show full scene,\n * while a value of 100 will compltely clip the scene.\n *\n * @param {number} value focus\n */\n setFocus (value: number) {\n if (this.parameters.clipMode !== 'scene') return\n\n let clipNear\n let clipFar\n let fogNear\n let fogFar\n\n if (this.parameters.clipScale === 'relative') {\n clipNear = clamp(value / 2.0, 0.0, 49.9)\n clipFar = 100 - clipNear\n fogNear = 50\n fogFar = pclamp(2 * clipFar - 50)\n\n } else {\n clipNear = this.viewer.relativeToAbsolute(value / 2.0)\n clipFar = clipNear\n fogNear = 0\n fogFar = 2 * clipFar\n }\n\n this.setParameters({ clipNear, clipFar, fogNear, fogFar })\n }\n\n getZoomForBox (boundingBox: Box3) {\n const bbSize = boundingBox.getSize(tmpZoomVector)\n const maxSize = Math.max(bbSize.x, bbSize.y, bbSize.z)\n const minSize = Math.min(bbSize.x, bbSize.y, bbSize.z)\n let distance = maxSize + Math.sqrt(minSize)\n\n const fov = degToRad(this.viewer.perspectiveCamera.fov)\n const width = this.viewer.width\n const height = this.viewer.height\n const aspect = width / height\n const aspectFactor = (height < width ? 1 : aspect)\n\n distance = Math.abs(\n ((distance * 0.5) / aspectFactor) / Math.sin(fov / 2)\n )\n distance += this.parameters.clipDist\n return -distance\n }\n\n getBox () {\n return this.viewer.boundingBox\n }\n\n getZoom () {\n return this.getZoomForBox(this.getBox())\n }\n\n getCenter (optionalTarget?: Vector3) {\n return this.getBox().getCenter(optionalTarget || new Vector3())\n }\n\n /**\n * Add a zoom and a move animation with automatic targets\n * @param {Integer} duration - animation time in milliseconds\n * @return {undefined}\n */\n autoView (duration?: number) {\n this.animationControls.zoomMove(\n this.getCenter(),\n this.getZoom(),\n defaults(duration, 0)\n )\n }\n\n /**\n * Make image from what is shown in a viewer canvas\n */\n makeImage (params: Partial = {}) {\n return new Promise((resolve, reject) => {\n this.tasks.onZeroOnce(() => {\n this.tasks.increment()\n this.viewer.makeImage(params).then(blob => {\n this.tasks.decrement()\n resolve(blob)\n }).catch(e => {\n this.tasks.decrement()\n reject(e)\n })\n })\n })\n }\n\n setImpostor (value: boolean) {\n this.parameters.impostor = value\n\n const types = [\n 'spacefill', 'ball+stick', 'licorice', 'hyperball',\n 'backbone', 'rocket', 'helixorient', 'contact', 'distance',\n 'dot'\n ]\n\n this.eachRepresentation(function (reprElem) {\n if (!types.includes(reprElem.getType())) return\n\n const p = reprElem.getParameters() as any // TODO\n p.disableImpostor = !value\n reprElem.build(p)\n })\n }\n\n setQuality (value: RenderQualityType) {\n this.parameters.quality = value\n\n const types = [\n 'tube', 'cartoon', 'ribbon', 'trace', 'rope'\n ]\n\n const impostorTypes = [\n 'spacefill', 'ball+stick', 'licorice', 'hyperball',\n 'backbone', 'rocket', 'helixorient', 'contact', 'distance',\n 'dot'\n ]\n\n this.eachRepresentation(function (repr) {\n const p = repr.getParameters() as any // TODO\n\n if (!types.includes(repr.getType())) {\n if (!impostorTypes.includes(repr.getType())) return\n\n if (!p.disableImpostor) {\n (repr.repr as any).quality = value // TODO\n return\n }\n }\n\n p.quality = value\n repr.build(p)\n })\n }\n\n /**\n * Iterator over each component and executing the callback\n */\n eachComponent (callback: (comp: Component) => void, type?: string) {\n this.compList.slice().forEach(comp => {\n if (type === undefined || type === comp.type) callback(comp)\n })\n }\n\n /**\n * Iterator over each representation and executing the callback\n */\n eachRepresentation (callback: (reprElem: RepresentationElement, comp: Component) => void, type?: string) {\n this.eachComponent(comp => {\n comp.reprList.slice().forEach(reprElem => {\n if (type === undefined || type === reprElem.getType()) callback(reprElem, comp)\n })\n })\n }\n\n /**\n * Get collection of components by name\n */\n getComponentsByName (name: string|RegExp) {\n const compList: Component[] = []\n\n this.eachComponent(comp => {\n if (name === undefined || matchName(name, comp)) compList.push(comp)\n })\n\n return new ComponentCollection(compList)\n }\n\n /**\n * Get collection of components by object\n */\n getComponentsByObject (object: Structure|Surface|Volume|Shape) {\n const compList: Component[] = []\n\n this.eachComponent(comp => {\n if (comp.object === object) compList.push(comp)\n })\n\n return new ComponentCollection(compList)\n }\n\n /**\n * Get collection of representations by name\n */\n getRepresentationsByName (name: string|RegExp) {\n const reprList: RepresentationElement[] = []\n\n this.eachRepresentation((repr, comp) => {\n if (name === undefined || matchName(name, repr)) reprList.push(repr)\n })\n\n return new RepresentationCollection(reprList)\n }\n\n measureClear () {\n this.eachComponent((sc: StructureComponent) => sc.measureClear(), 'structure')\n }\n\n measureUpdate () {\n this.eachComponent((sc: StructureComponent) => sc.measureUpdate(), 'structure')\n }\n\n /**\n * Cleanup when disposing of a stage object\n */\n dispose () {\n this.tasks.dispose()\n this.viewer.dispose()\n this.mouseObserver.dispose()\n }\n}\n\nexport default Stage\n","/**\n * @file Shape Component\n * @author Alexander Rose \n * @private\n */\n\nimport { ComponentRegistry } from '../globals'\nimport Component, { ComponentParameters } from './component'\nimport Stage from '../stage/stage'\nimport Shape from '../geometry/shape'\nimport { Vector3, Box3 } from 'three';\nimport RepresentationElement from './representation-element';\n\nexport type ShapeRepresentationType = 'buffer'\n\n/**\n * Component wrapping a {@link Shape} object\n *\n * @example\n * // get a shape component by adding a shape object to the stage\n * var shape = new NGL.Shape( \"shape\" );\n * shape.addSphere( [ 0, 0, 0 ], [ 1, 0, 0 ], 1.5 );\n * var shapeComponent = stage.addComponentFromObject( shape );\n * shapeComponent.addRepresentation( \"buffer\" );\n */\nclass ShapeComponent extends Component {\n constructor (stage: Stage, readonly shape: Shape, params: Partial = {}) {\n super(stage, shape, Object.assign({ name: shape.name }, params))\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'shape' }\n\n /**\n * Add a new shape representation to the component\n * @param {String} type - the name of the representation, one of:\n * buffer.\n * @param {BufferRepresentationParameters} params - representation parameters\n * @return {RepresentationComponent} the created representation wrapped into\n * a representation component object\n */\n addRepresentation (type: ShapeRepresentationType, params: { [k: string]: any } = {}): RepresentationElement {\n return this._addRepresentation(type, this.shape, params)\n }\n\n getBoxUntransformed (): Box3 {\n return this.shape.boundingBox\n }\n\n getCenterUntransformed (): Vector3 {\n return this.shape.center\n }\n\n dispose () {\n this.shape.dispose()\n super.dispose()\n }\n}\n\nComponentRegistry.add('shape', ShapeComponent)\n\nexport default ShapeComponent\n","/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n}\r\n","/**\n * @file Atomindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\n/**\n * Color by atom index. The {@link AtomProxy.index} property is used for coloring.\n * Each {@link ModelProxy} of a {@link Structure} is colored seperately. The\n * `params.domain` parameter is ignored.\n *\n * __Name:__ _atomindex_\n *\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"ball+stick\", { colorScheme: \"atomindex\" } );\n * o.autoView();\n * } );\n */\nclass AtomindexColormaker extends Colormaker {\n scalePerModel: { [k: number]: ColormakerScale }\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rainbow'\n this.parameters.reverse = defaults(params.reverse, true)\n }\n\n this.scalePerModel = {}\n\n params.structure.eachModel((mp: ModelProxy) => {\n this.parameters.domain = [ mp.atomOffset, mp.atomEnd ]\n this.scalePerModel[ mp.index ] = this.getScale() // TODO\n })\n }\n\n /**\n * get color for an atom\n * @param {AtomProxy} atom - atom to get color for\n * @return {Integer} hex atom color\n */\n @manageColor\n atomColor (atom: AtomProxy) {\n return this.scalePerModel[ atom.modelIndex ](atom.index)\n }\n}\n\nColormakerRegistry.add('atomindex', AtomindexColormaker)\n\nexport default AtomindexColormaker\n","/**\n * @file Bfactor Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Selection from '../selection/selection'\n\n/**\n * Color by b-factor. The {@link AtomProxy.bfactor} property is used for coloring.\n * By default the min and max b-factor values are used for the scale`s domain.\n *\n * __Name:__ _bfactor_\n *\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"ball+stick\", { colorScheme: \"bfactor\" } );\n * o.autoView();\n * } );\n */\nclass BfactorColormaker extends Colormaker {\n bfactorScale: ColormakerScale\n\n constructor (params: { sele?: string } & StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'OrRd'\n }\n\n if (!params.domain) {\n let selection\n let min = Infinity\n let max = -Infinity\n\n if (params.sele) {\n selection = new Selection(params.sele)\n }\n\n params.structure.eachAtom(function (a) {\n const bfactor = a.bfactor\n min = Math.min(min, bfactor)\n max = Math.max(max, bfactor)\n }, selection)\n\n this.parameters.domain = [ min, max ]\n }\n\n this.bfactorScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.bfactorScale(a.bfactor)\n }\n}\n\nColormakerRegistry.add('bfactor', BfactorColormaker)\n\nexport default BfactorColormaker\n","/**\n * @file Chainid Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\nexport type ChainidDict = { [k: string]: number }\n\n/**\n * Color by chain id\n */\nclass ChainidColormaker extends Colormaker {\n chainidDictPerModel: { [k: number]: ChainidDict } = {}\n scalePerModel: { [k: number]: ColormakerScale } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'Spectral'\n }\n\n params.structure.eachModel((mp: ModelProxy) => {\n let i = 0\n const chainidDict: ChainidDict = {}\n mp.eachChain(function (cp: ChainProxy) {\n if (chainidDict[ cp.chainid ] === undefined) {\n chainidDict[ cp.chainid ] = i\n i += 1\n }\n })\n this.parameters.domain = [ 0, i - 1 ]\n this.chainidDictPerModel[ mp.index ] = chainidDict\n this.scalePerModel[ mp.index ] = this.getScale()\n })\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n const chainidDict = this.chainidDictPerModel[ a.modelIndex ]\n return this.scalePerModel[ a.modelIndex ](chainidDict[ a.chainid ])\n }\n}\n\nColormakerRegistry.add('chainid', ChainidColormaker)\n\nexport default ChainidColormaker\n","/**\n * @file Chainindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\n/**\n * Color by chain index\n */\nclass ChainindexColormaker extends Colormaker {\n scalePerModel: { [k: number]: ColormakerScale } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'Spectral'\n }\n\n params.structure.eachModel((mp: ModelProxy) => {\n this.parameters.domain = [ mp.chainOffset, mp.chainEnd ]\n this.scalePerModel[ mp.index ] = this.getScale()\n })\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.scalePerModel[ a.modelIndex ](a.chainIndex)\n }\n}\n\nColormakerRegistry.add('chainindex', ChainindexColormaker)\n\nexport default ChainindexColormaker\n","/**\n * @file Chainname Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\nexport type ChainnameDict = { [k: string]: number }\n\n/**\n * Color by chain name\n */\nclass ChainnameColormaker extends Colormaker {\n chainnameDictPerModel: { [k: number]: ChainnameDict } = {}\n scalePerModel: { [k: number]: ColormakerScale } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'Spectral'\n }\n\n params.structure.eachModel((mp: ModelProxy) => {\n let i = 0\n const chainnameDict: ChainnameDict = {}\n mp.eachChain(function (cp: ChainProxy) {\n if (chainnameDict[ cp.chainname ] === undefined) {\n chainnameDict[ cp.chainname ] = i\n i += 1\n }\n })\n this.parameters.domain = [ 0, i - 1 ]\n this.chainnameDictPerModel[ mp.index ] = chainnameDict\n this.scalePerModel[ mp.index ] = this.getScale()\n })\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n const chainnameDict = this.chainnameDictPerModel[ a.modelIndex ]\n return this.scalePerModel[ a.modelIndex ](chainnameDict[ a.chainname ])\n }\n}\n\nColormakerRegistry.add('chainname', ChainnameColormaker)\n\nexport default ChainnameColormaker\n","/**\n * @file Densityfit Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by validation density fit\n */\nclass DensityfitColormaker extends Colormaker {\n rsrzScale: ColormakerScale\n rsccScale: ColormakerScale\n\n rsrzDict: { [k: string]: number|undefined } = {}\n rsccDict: { [k: string]: number|undefined } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'RdYlBu'\n }\n\n this.rsrzScale = this.getScale({ domain: [ 2, 0 ] })\n this.rsccScale = this.getScale({ domain: [ 0.678, 1.0 ] })\n\n const val = params.structure.validation\n if (val) {\n this.rsrzDict = val.rsrzDict\n this.rsccDict = val.rsccDict\n }\n\n }\n\n @manageColor\n atomColor (atom: AtomProxy) {\n let sele = atom.resno + ''\n if (atom.inscode) sele += '^' + atom.inscode\n if (atom.chainname) sele += ':' + atom.chainname\n sele += '/' + atom.modelIndex\n\n const rsrz = this.rsrzDict[ sele ]\n if (rsrz !== undefined) {\n return this.rsrzScale(rsrz)\n }\n\n const rscc = this.rsccDict[ sele ]\n if (rscc !== undefined) {\n return this.rsccScale(rscc)\n }\n\n return 0x909090\n }\n}\n\nColormakerRegistry.add('densityfit', DensityfitColormaker)\n\nexport default DensityfitColormaker\n","/**\n * @file Atomindex Colormaker\n * @author Fred Ludlow \n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport SpatialHash from '../geometry/spatial-hash'\n\n// from CHARMM\nconst partialCharges: { [k: string]: { [k: string]: number } } = {\n 'ARG': {\n 'CD': 0.1,\n 'CZ': 0.5,\n 'NE': -0.1\n },\n 'ASN': {\n 'CG': 0.55,\n 'OD1': -0.55\n },\n 'ASP': {\n 'CB': -0.16,\n 'CG': 0.36,\n 'OD1': -0.6,\n 'OD2': -0.6\n },\n 'CYS': {\n 'CB': 0.19,\n 'SG': -0.19\n },\n 'GLN': {\n 'CD': 0.55,\n 'OE1': -0.55\n },\n 'GLU': {\n 'CD': 0.36,\n 'CG': -0.16,\n 'OE1': -0.6,\n 'OE2': -0.6\n },\n 'HIS': {\n 'CB': 0.1,\n 'CD2': 0.2,\n 'CE1': 0.45,\n 'CG': 0.15,\n 'ND1': 0.05,\n 'NE2': 0.05\n },\n 'LYS': {\n 'CE': 0.25,\n 'NZ': 0.75\n },\n 'MET': {\n 'CE': 0.06,\n 'CG': 0.06,\n 'SD': -0.12\n },\n 'PTR': {\n 'C': 0.55,\n 'CA': 0.1,\n 'CZ': 0.25,\n 'N': -0.35,\n 'O': -0.55,\n 'O1P': -0.85,\n 'O2P': -0.85,\n 'O3P': -0.85,\n 'OG1': -1.1,\n 'P': 1.4\n },\n 'SEP': {\n 'C': 0.55,\n 'CA': 0.1,\n 'CB': 0.25,\n 'N': -0.35,\n 'O': -0.55,\n 'O1P': -0.85,\n 'O2P': -0.85,\n 'O3P': -0.85,\n 'OG1': -1.1,\n 'P': 1.4\n },\n 'SER': {\n 'CB': 0.25,\n 'OG': -0.25\n },\n 'THR': {\n 'CB': 0.25,\n 'OG1': -0.25\n },\n 'TPO': {\n 'C': 0.55,\n 'CA': 0.1,\n 'CB': 0.25,\n 'N': -0.35,\n 'O': -0.55,\n 'OG1': -1.1,\n 'O1P': -0.85,\n 'O2P': -0.85,\n 'O3P': -0.85,\n 'P': 1.4\n },\n 'TRP': {\n 'CD1': 0.06,\n 'CD2': 0.1,\n 'CE2': -0.04,\n 'CE3': -0.03,\n 'CG': -0.03,\n 'NE1': -0.06\n },\n 'TYR': {\n 'CZ': 0.25,\n 'OH': -0.25\n },\n 'backbone': {\n 'C': 0.55,\n 'O': -0.55,\n 'N': -0.35,\n 'CA': 0.1\n }\n}\n\nconst maxRadius = 12.0\nconst nHBondDistance = 1.04\nconst nHCharge = 0.25\n\n/**\n * Populates position vector with location of implicit or explicit H\n * Returns position or undefined if not able to locate H\n *\n * @param {AtomProxy} ap - the nitrogen atom\n * @param {Vector3} [position] - optional target\n * @return {Vectors|undefined} the hydrogen atom position\n */\nfunction backboneNHPosition (ap: AtomProxy, position = new Vector3()) {\n let h = false\n let ca = false\n let c = false\n position.set(2 * ap.x, 2 * ap.y, 2 * ap.z)\n\n ap.eachBondedAtom(function (a2: AtomProxy) {\n // Any time we detect H, reset position and skip\n // future tests\n if (h) return\n if (a2.atomname === 'H') {\n position.set(a2.x, a2.y, a2.z)\n h = true\n return\n }\n if (!ca && a2.atomname === 'CA') {\n position.sub(a2 as any) // TODO\n ca = true\n } else if (!c && a2.atomname === 'C') {\n c = true\n position.sub(a2 as any) // TODO\n }\n })\n\n if (h) { return position }\n\n if (ca && c) {\n position.normalize()\n position.multiplyScalar(nHBondDistance)\n position.add(ap as any)\n return position\n }\n}\n\n/**\n * Takes an array of Vector3 objects and\n * converts to an object that looks like an AtomStore\n *\n * @param {Vector3[]} positions - array of positions\n * @return {Object} AtomStore-like object\n */\nfunction buildStoreLike (positions: Vector3[]) {\n const n = positions.length\n const x = new Float32Array(n)\n const y = new Float32Array(n)\n const z = new Float32Array(n)\n\n for (let i = 0; i < positions.length; i++) {\n const v = positions[ i ]\n x[ i ] = v.x\n y[ i ] = v.y\n z[ i ] = v.z\n }\n\n return { x: x, y: y, z: z, count: n }\n}\n\nfunction chargeForAtom (a: AtomProxy): number {\n if (a.partialCharge !== null) return a.partialCharge\n if (!a.isProtein()) { return 0.0 }\n return (\n (partialCharges[ a.resname ] &&\n partialCharges[ a.resname ][ a.atomname ]) ||\n partialCharges[ 'backbone' ][ a.atomname ] || 0.0\n )\n}\n\n/**\n * Color a surface by electrostatic charge. This is a highly approximate\n * calculation! The partial charges are CHARMM with hydrogens added to heavy\n * atoms and hydrogen positions generated for amides.\n *\n * __Name:__ _electrostatic_\n *\n * @example\n * stage.loadFile( \"rcsb://3dqb\" ).then( function( o ){\n * o.addRepresentation( \"surface\", { colorScheme: \"electrostatic\" } );\n * o.autoView();\n * } );\n */\nclass ElectrostaticColormaker extends Colormaker {\n scale: ColormakerScale\n hHash: SpatialHash\n hash: SpatialHash\n charges: Float32Array\n hStore: { x: Float32Array, y: Float32Array, z: Float32Array, count: number }\n atomProxy: AtomProxy\n\n delta = new Vector3()\n hCharges: number[] = []\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rwb'\n }\n if (!params.domain) {\n this.parameters.domain = [ -50, 50 ]\n }\n\n this.scale = this.getScale()\n\n this.charges = new Float32Array(params.structure.atomCount)\n const hPositions: Vector3[] = []\n\n params.structure.eachAtom((ap: AtomProxy) => {\n this.charges[ ap.index ] = chargeForAtom(ap) * ap.occupancy\n if (ap.atomname === 'N') {\n\n // In the specific case where N forms two bonds to\n // CA and C, try and place a dummy hydrogen\n\n if (ap.bondCount >= 3) return; // Skip if 3 bonds already (e.g. PRO)\n\n if (ap.bondToElementCount(1)) return; // Skip if any H specificed\n\n const hPos = backboneNHPosition(ap)\n if (hPos !== undefined) {\n hPositions.push(hPos)\n this.hCharges.push(nHCharge * ap.occupancy)\n }\n }\n })\n\n const bbox = params.structure.getBoundingBox()\n bbox.expandByScalar(nHBondDistance) // Worst case\n\n // SpatialHash requires x,y,z and count\n this.hStore = buildStoreLike(hPositions)\n this.hHash = new SpatialHash(this.hStore as any, bbox) // TODO\n this.hash = new SpatialHash(params.structure.atomStore, bbox)\n }\n\n @manageColor\n positionColor (v: Vector3) {\n\n const charges = this.charges\n const hCharges = this.hCharges\n\n let p = 0.0\n this.hash.eachWithin(v.x, v.y, v.z, maxRadius, (atomIndex, dSq) => {\n const charge = charges[atomIndex]\n if (charge === 0.0) return\n p += charge / dSq\n })\n\n this.hHash.eachWithin(v.x, v.y, v.z, maxRadius, (atomIndex, dSq) => {\n const charge = hCharges[atomIndex]\n if (charge === 0.0) return\n p += charge / dSq\n })\n\n return this.scale(p * 332) // 332 to convert to kcal/mol\n }\n}\n\nColormakerRegistry.add('electrostatic', ElectrostaticColormaker)\n\nexport default ElectrostaticColormaker\n","/**\n * @file Element Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Colormaker, { ColormakerParameters, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n// from Jmol http://jmol.sourceforge.net/jscolors/ (or 0xFFFFFF)\nconst ElementColors: { [k: string]: number } = {\n 'H': 0xFFFFFF,\n 'HE': 0xD9FFFF,\n 'LI': 0xCC80FF,\n 'BE': 0xC2FF00,\n 'B': 0xFFB5B5,\n 'C': 0x909090,\n 'N': 0x3050F8,\n 'O': 0xFF0D0D,\n 'F': 0x90E050,\n 'NE': 0xB3E3F5,\n 'NA': 0xAB5CF2,\n 'MG': 0x8AFF00,\n 'AL': 0xBFA6A6,\n 'SI': 0xF0C8A0,\n 'P': 0xFF8000,\n 'S': 0xFFFF30,\n 'CL': 0x1FF01F,\n 'AR': 0x80D1E3,\n 'K': 0x8F40D4,\n 'CA': 0x3DFF00,\n 'SC': 0xE6E6E6,\n 'TI': 0xBFC2C7,\n 'V': 0xA6A6AB,\n 'CR': 0x8A99C7,\n 'MN': 0x9C7AC7,\n 'FE': 0xE06633,\n 'CO': 0xF090A0,\n 'NI': 0x50D050,\n 'CU': 0xC88033,\n 'ZN': 0x7D80B0,\n 'GA': 0xC28F8F,\n 'GE': 0x668F8F,\n 'AS': 0xBD80E3,\n 'SE': 0xFFA100,\n 'BR': 0xA62929,\n 'KR': 0x5CB8D1,\n 'RB': 0x702EB0,\n 'SR': 0x00FF00,\n 'Y': 0x94FFFF,\n 'ZR': 0x94E0E0,\n 'NB': 0x73C2C9,\n 'MO': 0x54B5B5,\n 'TC': 0x3B9E9E,\n 'RU': 0x248F8F,\n 'RH': 0x0A7D8C,\n 'PD': 0x006985,\n 'AG': 0xC0C0C0,\n 'CD': 0xFFD98F,\n 'IN': 0xA67573,\n 'SN': 0x668080,\n 'SB': 0x9E63B5,\n 'TE': 0xD47A00,\n 'I': 0x940094,\n 'XE': 0x940094,\n 'CS': 0x57178F,\n 'BA': 0x00C900,\n 'LA': 0x70D4FF,\n 'CE': 0xFFFFC7,\n 'PR': 0xD9FFC7,\n 'ND': 0xC7FFC7,\n 'PM': 0xA3FFC7,\n 'SM': 0x8FFFC7,\n 'EU': 0x61FFC7,\n 'GD': 0x45FFC7,\n 'TB': 0x30FFC7,\n 'DY': 0x1FFFC7,\n 'HO': 0x00FF9C,\n 'ER': 0x00E675,\n 'TM': 0x00D452,\n 'YB': 0x00BF38,\n 'LU': 0x00AB24,\n 'HF': 0x4DC2FF,\n 'TA': 0x4DA6FF,\n 'W': 0x2194D6,\n 'RE': 0x267DAB,\n 'OS': 0x266696,\n 'IR': 0x175487,\n 'PT': 0xD0D0E0,\n 'AU': 0xFFD123,\n 'HG': 0xB8B8D0,\n 'TL': 0xA6544D,\n 'PB': 0x575961,\n 'BI': 0x9E4FB5,\n 'PO': 0xAB5C00,\n 'AT': 0x754F45,\n 'RN': 0x428296,\n 'FR': 0x420066,\n 'RA': 0x007D00,\n 'AC': 0x70ABFA,\n 'TH': 0x00BAFF,\n 'PA': 0x00A1FF,\n 'U': 0x008FFF,\n 'NP': 0x0080FF,\n 'PU': 0x006BFF,\n 'AM': 0x545CF2,\n 'CM': 0x785CE3,\n 'BK': 0x8A4FE3,\n 'CF': 0xA136D4,\n 'ES': 0xB31FD4,\n 'FM': 0xB31FBA,\n 'MD': 0xB30DA6,\n 'NO': 0xBD0D87,\n 'LR': 0xC70066,\n 'RF': 0xCC0059,\n 'DB': 0xD1004F,\n 'SG': 0xD90045,\n 'BH': 0xE00038,\n 'HS': 0xE6002E,\n 'MT': 0xEB0026,\n 'DS': 0xFFFFFF,\n 'RG': 0xFFFFFF,\n 'CN': 0xFFFFFF,\n 'UUT': 0xFFFFFF,\n 'FL': 0xFFFFFF,\n 'UUP': 0xFFFFFF,\n 'LV': 0xFFFFFF,\n 'UUH': 0xFFFFFF,\n\n 'D': 0xFFFFC0,\n 'T': 0xFFFFA0\n}\nconst DefaultElementColor = 0xFFFFFF\n\n/**\n * Color by element\n */\nclass ElementColormaker extends Colormaker {\n constructor (params: ColormakerParameters) {\n params.value = defaults(params.value, ElementColors.C)\n\n super(params)\n }\n\n\n @manageColor\n atomColor (a: AtomProxy) {\n const element = a.element\n\n if (element === 'C') {\n return this.parameters.value\n } else {\n return ElementColors[ element ] || DefaultElementColor\n }\n }\n}\n\nColormakerRegistry.add('element', ElementColormaker)\n\nexport default ElementColormaker\n","/**\n * @file Entityindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by entity index\n */\nclass EntityindexColormaker extends Colormaker {\n entityindexScale: ColormakerScale\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'Spectral'\n }\n if (!params.domain) {\n this.parameters.domain = [ 0, params.structure.entityList.length - 1 ]\n }\n\n this.entityindexScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.entityindexScale(a.entityIndex)\n }\n}\n\nColormakerRegistry.add('entityindex', EntityindexColormaker)\n\nexport default EntityindexColormaker\n","/**\n * @file Entitytype Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\nimport {\n PolymerEntity, NonPolymerEntity, MacrolideEntity, WaterEntity\n} from '../structure/structure-constants'\n\n/**\n * Color by entity type\n */\nclass EntitytypeColormaker extends Colormaker {\n @manageColor\n atomColor (a: AtomProxy) {\n const e = a.entity\n const et = e ? e.entityType : undefined\n switch (et) {\n case PolymerEntity:\n return 0x7fc97f\n case NonPolymerEntity:\n return 0xfdc086\n case MacrolideEntity:\n return 0xbeaed4\n case WaterEntity:\n return 0x386cb0\n default:\n return 0xffff99\n }\n }\n}\n\nColormakerRegistry.add('entitytype', EntitytypeColormaker)\n\nexport default EntitytypeColormaker\n","/**\n * @file Geoquality Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport { countSetBits } from '../math/math-utils'\n\n/**\n * Color by validation gometry quality\n */\nclass GeoqualityColormaker extends Colormaker {\n geoAtomDict: { [k: string]: { [k: string]: number } } = {}\n geoDict: { [k: string]: number|undefined } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n const val = params.structure.validation\n if (val) {\n this.geoAtomDict = val.geoAtomDict\n this.geoDict = val.geoDict\n }\n }\n\n @manageColor\n atomColor (atom: AtomProxy) {\n let sele = atom.resno + ''\n if (atom.inscode) sele += '^' + atom.inscode\n if (atom.chainname) sele += ':' + atom.chainname\n sele += '/' + atom.modelIndex\n\n let geoProblemCount\n const geoAtom = this.geoAtomDict[ sele ]\n if (geoAtom !== undefined) {\n const atomProblems: number = geoAtom[ atom.atomname ] || 0\n geoProblemCount = countSetBits(atomProblems)\n } else {\n geoProblemCount = this.geoDict[ sele ] || 0\n }\n\n if (geoProblemCount === 0) {\n return 0x2166ac\n } else if (geoProblemCount === 1) {\n return 0xfee08b\n } else if (geoProblemCount === 2) {\n return 0xf46d43\n } else if (geoProblemCount >= 3) {\n return 0xa50026\n }\n return 0x909090\n }\n}\n\nColormakerRegistry.add('geoquality', GeoqualityColormaker)\n\nexport default GeoqualityColormaker\n","/**\n * @file Hydrophobicity Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { ColormakerParameters, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\nimport {\n ResidueHydrophobicity, DefaultResidueHydrophobicity\n} from '../structure/structure-constants'\n\n/**\n * Color by hydrophobicity\n */\nclass HydrophobicityColormaker extends Colormaker {\n hfScale: ColormakerScale\n resHF: { [k: string]: number } = {}\n defaultResidueHydrophobicity: number\n\n constructor (params: ColormakerParameters) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'RdYlGn'\n }\n\n const idx = 0 // 0: DGwif, 1: DGwoct, 2: Oct-IF\n\n for (const name in ResidueHydrophobicity) {\n this.resHF[ name ] = ResidueHydrophobicity[ name ][ idx ]\n }\n this.defaultResidueHydrophobicity = DefaultResidueHydrophobicity[idx]\n\n if (!params.domain) {\n let min = Infinity\n let max = -Infinity\n\n for (const name in this.resHF) {\n const val = this.resHF[ name ]\n min = Math.min(min, val)\n max = Math.max(max, val)\n }\n\n this.parameters.domain = [ min, 0, max ]\n }\n\n this.hfScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.hfScale(this.resHF[ a.resname ] || this.defaultResidueHydrophobicity)\n }\n}\n\nColormakerRegistry.add('hydrophobicity', HydrophobicityColormaker)\n\nexport default HydrophobicityColormaker\n","/**\n * @file Modelindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by model index\n */\nclass ModelindexColormaker extends Colormaker {\n modelindexScale: ColormakerScale\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rainbow'\n }\n if (!params.domain) {\n this.parameters.domain = [ 0, params.structure.modelStore.count ]\n }\n\n this.modelindexScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.modelindexScale(a.modelIndex)\n }\n}\n\nColormakerRegistry.add('modelindex', ModelindexColormaker)\n\nexport default ModelindexColormaker\n","/**\n * @file Moleculetype Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\nimport {\n WaterType, IonType, ProteinType, RnaType, DnaType, SaccharideType\n} from '../structure/structure-constants'\n\n/**\n * Color by molecule type\n */\nclass MoleculetypeColormaker extends Colormaker {\n @manageColor\n atomColor (a: AtomProxy) {\n switch (a.residueType.moleculeType) {\n case WaterType:\n return 0x386cb0\n case IonType:\n return 0xf0027f\n case ProteinType:\n return 0xbeaed4\n case RnaType:\n return 0xfdc086\n case DnaType:\n return 0xbf5b17\n case SaccharideType:\n return 0x7fc97f\n default:\n return 0xffff99\n }\n }\n}\n\nColormakerRegistry.add('moleculetype', MoleculetypeColormaker)\n\nexport default MoleculetypeColormaker\n","/**\n * @file Occupancy Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { ColormakerParameters, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by occupancy\n */\nclass OccupancyColormaker extends Colormaker {\n occupancyScale: ColormakerScale\n\n constructor (params: ColormakerParameters) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'PuBu'\n }\n\n if (!params.domain) {\n this.parameters.domain = [ 0.0, 1.0 ]\n }\n\n this.occupancyScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.occupancyScale(a.occupancy)\n }\n}\n\nColormakerRegistry.add('occupancy', OccupancyColormaker)\n\nexport default OccupancyColormaker\n","/**\n * @file Partialcharge Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { ColormakerParameters, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by partial charge. The {@link AtomProxy.partialCharge} property is used for coloring.\n * The default domain is [-1, 1].\n *\n * __Name:__ _partialCharge_\n *\n * @example\n * stage.loadFile(\"rcsb://1crn\").then(function (o) {\n * o.addRepresentation(\"ball+stick\", {colorScheme: \"partialCharge\"});\n * o.autoView();\n * });\n */\nclass PartialchargeColormaker extends Colormaker {\n partialchargeScale: ColormakerScale\n\n constructor (params: ColormakerParameters) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rwb'\n }\n\n if (!params.domain) {\n this.parameters.domain = [-1, 1]\n }\n\n this.partialchargeScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.partialchargeScale(a.partialCharge || 0)\n }\n}\n\nColormakerRegistry.add('partialcharge', PartialchargeColormaker)\n\nexport default PartialchargeColormaker\n","/**\n * @file Random Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\n\nfunction randomColor () {\n return Math.random() * 0xFFFFFF\n}\n\n/**\n * Class by random color\n */\nclass RandomColormaker extends Colormaker {\n /**\n * get color for an atom\n * @return {Integer} random hex color\n */\n @manageColor\n atomColor () {\n return randomColor()\n }\n\n /**\n * get color for volume cell\n * @return {Integer} random hex color\n */\n @manageColor\n volumeColor () {\n return randomColor()\n }\n\n /**\n * get color for coordinates in space\n * @return {Integer} random hex color\n */\n @manageColor\n positionColor () {\n return randomColor()\n }\n}\n\nColormakerRegistry.add('random', RandomColormaker)\n\nexport default RandomColormaker\n","/**\n * @file Randomcoilindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by random coil index\n */\nclass RandomcoilindexColormaker extends Colormaker {\n rciScale: ColormakerScale\n rciDict: { [k: string]: number|undefined } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'RdYlBu'\n }\n\n this.rciScale = this.getScale({ domain: [ 0.6, 0 ] })\n\n const val = params.structure.validation\n if (val) this.rciDict = val.rciDict\n\n }\n\n @manageColor\n atomColor (atom: AtomProxy) {\n let sele = `[${atom.resname}]${atom.resno}`\n if (atom.chainname) sele += ':' + atom.chainname\n\n const rci = this.rciDict[ sele ]\n return rci !== undefined ? this.rciScale(rci) : 0x909090\n }\n}\n\nColormakerRegistry.add('randomcoilindex', RandomcoilindexColormaker)\n\nexport default RandomcoilindexColormaker\n","/**\n * @file Residueindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\n\n/**\n * Color by residue index\n */\nclass ResidueindexColormaker extends Colormaker {\n scalePerChain: { [k: number]: ColormakerScale } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rainbow'\n this.parameters.reverse = defaults(params.reverse, true)\n }\n\n params.structure.eachChain((cp: ChainProxy) => {\n this.parameters.domain = [ cp.residueOffset, cp.residueEnd ]\n this.scalePerChain[ cp.index ] = this.getScale()\n })\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.scalePerChain[ a.chainIndex ](a.residueIndex)\n }\n}\n\nColormakerRegistry.add('residueindex', ResidueindexColormaker)\n\nexport default ResidueindexColormaker\n","/**\n * @file Resname Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n// protein colors from Jmol http://jmol.sourceforge.net/jscolors/\nconst ResidueColors: { [k: string]: number } = {\n 'ALA': 0x8CFF8C,\n 'ARG': 0x00007C,\n 'ASN': 0xFF7C70,\n 'ASP': 0xA00042,\n 'CYS': 0xFFFF70,\n 'GLN': 0xFF4C4C,\n 'GLU': 0x660000,\n 'GLY': 0xFFFFFF,\n 'HIS': 0x7070FF,\n 'ILE': 0x004C00,\n 'LEU': 0x455E45,\n 'LYS': 0x4747B8,\n 'MET': 0xB8A042,\n 'PHE': 0x534C52,\n 'PRO': 0x525252,\n 'SER': 0xFF7042,\n 'THR': 0xB84C00,\n 'TRP': 0x4F4600,\n 'TYR': 0x8C704C,\n 'VAL': 0xFF8CFF,\n\n 'ASX': 0xFF00FF,\n 'GLX': 0xFF00FF,\n 'ASH': 0xFF00FF,\n 'GLH': 0xFF00FF,\n\n 'A': 0xDC143C, // Crimson Red\n 'G': 0x32CD32, // Lime Green\n 'I': 0x9ACD32, // Yellow Green\n 'X': 0x7CFC00, // Lawn Green\n 'C': 0xFFD700, // Gold Yellow\n 'T': 0x4169E1, // Royal Blue\n 'U': 0x40E0D0, // Turquoise Cyan\n 'D': 0x008B8B, // Dark Cyan\n\n 'DA': 0xDC143C,\n 'DG': 0x32CD32,\n 'DI': 0x9ACD32,\n 'DX': 0x7CFC00,\n 'DC': 0xFFD700,\n 'DT': 0x4169E1,\n 'DU': 0x40E0D0,\n 'DD': 0x008B8B\n}\nconst DefaultResidueColor = 0xFF00FF\n\n/**\n * Color by residue name\n */\nclass ResnameColormaker extends Colormaker {\n @manageColor\n atomColor (a: AtomProxy) {\n return ResidueColors[ a.resname ] || DefaultResidueColor\n }\n}\n\nColormakerRegistry.add('resname', ResnameColormaker)\n\nexport default ResnameColormaker\n","/**\n * @file Sstruc Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\n\n// from Jmol http://jmol.sourceforge.net/jscolors/ (shapely)\nconst StructureColors = {\n 'alphaHelix': 0xFF0080,\n 'threeTenHelix': 0xA00080,\n 'piHelix': 0x600080,\n 'betaStrand': 0xFFC800,\n 'betaTurn': 0x6080FF,\n 'coil': 0xFFFFFF,\n\n 'dna': 0xAE00FE,\n 'rna': 0xFD0162,\n\n 'carbohydrate': 0xA6A6FA\n}\nconst DefaultStructureColor = 0x808080\n\n/**\n * Color by secondary structure\n */\nclass SstrucColormaker extends Colormaker {\n residueProxy: ResidueProxy\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n this.residueProxy = params.structure.getResidueProxy()\n }\n\n @manageColor\n atomColor (ap: AtomProxy) {\n const sstruc = ap.sstruc\n const rp = this.residueProxy\n\n if (sstruc === 'h') {\n return StructureColors.alphaHelix\n } else if (sstruc === 'g') {\n return StructureColors.threeTenHelix\n } else if (sstruc === 'i') {\n return StructureColors.piHelix\n } else if (sstruc === 'e' || sstruc === 'b') {\n return StructureColors.betaStrand\n } else if (sstruc === 't') {\n return StructureColors.betaTurn\n } else {\n rp.index = ap.residueIndex\n if (rp.isDna()) {\n return StructureColors.dna\n } else if (rp.isRna()) {\n return StructureColors.rna\n } else if (rp.isSaccharide()) {\n return StructureColors.carbohydrate\n } else if (rp.isProtein() || sstruc === 's' || sstruc === 'l') {\n return StructureColors.coil\n } else {\n return DefaultStructureColor\n }\n }\n }\n}\n\nColormakerRegistry.add('sstruc', SstrucColormaker)\n\nexport default SstrucColormaker\n","/**\n * @file Colordata Colormaker\n * @author Fred Ludlow \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { ColorData, ColormakerScale, manageColor, StuctureColormakerParams } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport BondProxy from '../proxy/bond-proxy'\n\n\nclass StructuredataColormaker extends Colormaker {\n atomData?: ColorData['atomData']\n bondData?: ColorData['bondData']\n scale: ColormakerScale\n\n constructor(params: StuctureColormakerParams) {\n super(params)\n if (!params.scale) {\n this.parameters.scale = 'rwb'\n }\n this.atomData = this.parameters.data?.atomData\n this.bondData = this.parameters.data?.bondData\n this.scale = this.getScale(this.parameters)\n }\n\n @manageColor\n atomColor(a: AtomProxy) {\n const val = this.atomData?.[a.index]\n return (val !== undefined) ? this.scale(val) : this.parameters.value\n }\n\n @manageColor\n bondColor(bond: BondProxy, fromTo: boolean) {\n const val = this.bondData?.[bond.index]\n \n // Explicit bond data?\n if (val !== undefined) return this.scale(val)\n \n \n if (this.atomProxy) {\n this.atomProxy.index = fromTo ? bond.atomIndex1 : bond.atomIndex2\n return this.atomColor(this.atomProxy)\n } \n \n // Fallback\n return this.parameters.value\n }\n}\n\nColormakerRegistry.add('structuredata', StructuredataColormaker)\n\nexport default StructuredataColormaker","/**\n * @file Uniform Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\n\n/**\n * Color by uniform color\n */\nclass UniformColormaker extends Colormaker {\n @manageColor\n atomColor () {\n return this.parameters.value\n }\n\n @manageColor\n bondColor () {\n return this.parameters.value\n }\n\n @manageColor\n valueColor () {\n return this.parameters.value\n }\n\n @manageColor\n volumeColor () {\n return this.parameters.value\n }\n}\n\nColormakerRegistry.add('uniform', UniformColormaker)\n\nexport default UniformColormaker\n","/**\n * @file Value Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { VolumeColormakerParams, ColormakerScale, manageColor } from './colormaker'\n\n/**\n * Color by volume value\n */\nclass ValueColormaker extends Colormaker {\n valueScale: ColormakerScale\n\n constructor (params: VolumeColormakerParams) {\n super(params)\n this.valueScale = this.getScale()\n }\n\n /**\n * return the color for a volume cell\n * @param {Integer} index - volume cell index\n * @return {Integer} hex cell color\n */\n @manageColor\n volumeColor (index: number) {\n return this.valueScale((this.parameters.volume! as any).data[ index ]) // TODO\n }\n}\n\nColormakerRegistry.add('value', ValueColormaker)\n\nexport default ValueColormaker\n","/**\n * @file Volume Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\nimport { lerp } from '../math/math-utils'\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { VolumeColormakerParams, ColormakerScale, manageColor } from './colormaker'\n\n/**\n * Color by volume position\n */\nclass VolumeColormaker extends Colormaker {\n valueScale: ColormakerScale\n vec = new Vector3()\n\n constructor (params: VolumeColormakerParams) {\n super(params)\n this.valueScale = this.getScale()\n }\n\n /**\n * return the color for coordinates in space\n * @param {Vector3} coords - xyz coordinates\n * @return {Integer} hex coords color\n */\n @manageColor\n positionColor (coords: Vector3) {\n const volume = this.parameters.volume as any // TODO\n\n if (!volume || !volume.inverseMatrix) {\n return this.parameters.value\n }\n\n const vec = this.vec\n const data = volume.data\n const nx = volume.nx\n const ny = volume.ny\n const nxy = nx * ny\n\n vec.copy(coords)\n vec.applyMatrix4(volume.inverseMatrix)\n\n // position of grid cell\n const x0 = Math.floor(vec.x)\n const y0 = Math.floor(vec.y)\n const z0 = Math.floor(vec.z)\n\n // Indices\n const i = ((((z0 * ny) + y0) * nx) + x0)\n const i1 = i + 1\n const iy = i + nx\n const iz = i + nxy\n const i1y = iy + 1\n const i1z = iz + 1\n const iyz = iy + nxy\n const i1yz = iyz + 1\n\n // Values\n const v = data[ i ]\n const v1 = data[ i1 ]\n const vy = data[ iy ]\n const vz = data[ iz ]\n const v1y = data[ i1y ]\n const v1z = data[ i1z ]\n const vyz = data[ iyz ]\n const v1yz = data[ i1yz ]\n\n // Position of point in fraction of grid\n const xd = vec.x - x0\n const yd = vec.y - y0\n const zd = vec.z - z0\n\n // 1st Dimension\n const c00 = lerp(v, v1, xd)\n const c01 = lerp(vz, v1z, xd)\n const c10 = lerp(vy, v1y, xd)\n const c11 = lerp(vyz, v1yz, xd)\n\n // 2nd Dimension\n const c0 = lerp(c00, c10, yd)\n const c1 = lerp(c01, c11, yd)\n\n // 3rd Dimension\n const c = lerp(c0, c1, zd)\n\n return this.valueScale(c)\n }\n}\n\nColormakerRegistry.add('volume', VolumeColormaker)\n\nexport default VolumeColormaker\n","/**\n * @file Structure Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { ExtensionFragDepth, Mobile } from '../globals'\nimport { defaults } from '../utils'\nimport { RepresentationParameters, default as Representation } from './representation'\nimport Selection from '../selection/selection'\nimport RadiusFactory, { RadiusFactoryTypes, RadiusType } from '../utils/radius-factory'\nimport Structure from '../structure/structure'\nimport Viewer from '../viewer/viewer'\n// @ts-ignore: unused import Volume required for declaration only\nimport { Assembly, Volume } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport AtomProxy from '../proxy/atom-proxy';\nimport Polymer from '../proxy/polymer';\nimport Buffer from '../buffer/buffer';\nimport { AtomDataFields, BondDataFields, AtomDataParams, BondDataParams } from '../structure/structure-data';\n// @ts-ignore: unused import Surface required for declaration only\nimport Surface from '../surface/surface'\n\n/**\n * Structure representation parameter object.\n * @typedef {Object} StructureRepresentationParameters - structure representation parameters\n * @mixes RepresentationParameters\n *\n * @property {String} radiusType - A list of possible sources of the radius used for rendering the representation. The radius can be based on the *vdW radius*, the *covalent radius* or the *B-factor* value of the corresponding atom. Additionally the radius can be based on the *secondary structure*. Alternatively, when set to *size*, the value from the *radius* parameter is used for all atoms.\n * @property {Float} radius - A number providing a fixed radius used for rendering the representation.\n * @property {Float} scale - A number that scales the value defined by the *radius* or the *radiusType* parameter.\n * @property {String} assembly - name of an assembly object. Included are the asymmetric unit (*AU*) corresponding to the coordinates given in the structure file, biological assemblies from *PDB*, *mmCIF* or *MMTF* files (*BU1*, *BU2*, ...), a filled (crystallographic) unitcell of a given space group (*UNITCELL*), a supercell consisting of a center unitcell and its 26 direct neighbors (*SUPERCELL*). Set to *default* to use the default asemmbly of the structure object.\n */\nexport interface StructureRepresentationParameters extends RepresentationParameters {\n radiusType: string\n radius: number\n scale: number\n assembly: string\n}\nexport interface StructureRepresentationData {\n bufferList: Buffer[]\n polymerList?: Polymer[]\n sview?: StructureView | Structure\n [k: string]: any\n}\n/**\n * Structure representation\n * @interface\n */\nabstract class StructureRepresentation extends Representation {\n\n protected selection: Selection\n protected dataList: StructureRepresentationData[]\n structure: Structure\n structureView: StructureView\n\n protected radiusType: RadiusType\n protected radiusData: {[k: number]: number}\n protected radiusSize: number\n protected radiusScale: number\n protected assembly: string\n protected defaultAssembly: string\n protected needsBuild: boolean\n\n /**\n * Create Structure representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {StructureRepresentationParameters} params - structure representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n const p = params || {}\n\n super(structure, viewer, p)\n\n this.type = 'structure'\n\n this.parameters = Object.assign({\n radiusType: {\n type: 'select', options: RadiusFactory.types\n },\n radiusData: {\n type: 'hidden'\n },\n radiusSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n radiusScale: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n assembly: null,\n defaultAssembly: {\n type: 'hidden'\n }\n }, this.parameters)\n\n /**\n * @type {Selection}\n * @private\n */\n this.selection = new Selection(p.sele)\n\n /**\n * @type {Array}\n * @private\n */\n this.dataList = []\n\n /**\n * @type {Structure}\n */\n this.structure = structure\n\n /**\n * @type {StructureView}\n */\n this.structureView = this.structure.getView(this.selection)\n\n if (structure.biomolDict) {\n const biomolOptions:{[key: string]: string} = {\n 'default': 'default',\n '': (structure.unitcell ? 'AU' : 'FULL')\n }\n Object.keys(structure.biomolDict).forEach(function (k) {\n biomolOptions[ k ] = k\n })\n this.parameters.assembly = {\n type: 'select',\n options: biomolOptions,\n rebuild: true\n }\n } else {\n this.parameters.assembly = null\n }\n }\n\n get defaultScale () {\n return {\n 'vdw': 1.0,\n 'covalent': 1.0,\n 'bfactor': 0.01,\n 'sstruc': 1.0\n }\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'element')\n\n this.setRadius(p.radius, p)\n\n this.radiusType = defaults(p.radiusType, 'vdw')\n this.radiusData = defaults(p.radiusData, {})\n this.radiusSize = defaults(p.radiusSize, 1.0)\n this.radiusScale = defaults(p.radiusScale, 1.0)\n this.assembly = defaults(p.assembly, 'default')\n this.defaultAssembly = defaults(p.defaultAssembly, '')\n\n if (p.quality === 'auto') {\n p.quality = this.getQuality()\n }\n\n super.init(p)\n\n this.selection.signals.stringChanged.add((/* sele */) => {\n this.build()\n })\n\n this.build()\n }\n\n setRadius (value: string | number | undefined, p: Partial) {\n const types = Object.keys(RadiusFactoryTypes)\n\n if (typeof value === 'string' && types.includes(value.toLowerCase())) {\n p.radiusType = value\n } else if (value !== undefined) {\n p.radiusType = 'size'\n p.radiusSize = value\n }\n\n return this\n }\n\n getAssembly (): Assembly {\n const name = this.assembly === 'default' ? this.defaultAssembly : this.assembly\n return this.structure.biomolDict[ name ]\n }\n\n getQuality () {\n let atomCount\n const s = this.structureView\n const assembly = this.getAssembly()\n if (assembly) {\n atomCount = assembly.getAtomCount(s)\n } else {\n atomCount = s.atomCount\n }\n if (Mobile) {\n atomCount *= 4\n }\n const backboneOnly = s.atomStore.count / s.residueStore.count < 2\n if (backboneOnly) {\n atomCount *= 10\n }\n\n if (atomCount < 15000) {\n return 'high'\n } else if (atomCount < 80000) {\n return 'medium'\n } else {\n return 'low'\n }\n }\n\n create () {\n if (this.structureView.atomCount === 0) return\n\n if (!this.structureView.hasCoords()) {\n this.needsBuild = true\n return\n } else {\n this.needsBuild = false\n }\n\n const assembly = this.getAssembly()\n\n if (assembly) {\n assembly.partList.forEach((part, i) => {\n const sview = part.getView(this.structureView)\n if (sview.atomCount === 0) return\n const data = this.createData(sview, i)\n if (data) {\n data.sview = sview\n data.instanceList = part.getInstanceList()\n this.dataList.push(data)\n }\n })\n } else {\n const data = this.createData(this.structureView, 0)\n if (data) {\n data.sview = this.structureView\n this.dataList.push(data)\n }\n }\n }\n\n abstract createData (sview: StructureView, k?: number): StructureRepresentationData|undefined\n\n update (what: AtomDataFields|BondDataFields) {\n if (this.lazy && !this.visible) {\n Object.assign(this.lazyProps.what, what)\n return\n }\n\n if (this.needsBuild) {\n this.build()\n return\n }\n\n this.dataList.forEach((data) => {\n if (data.bufferList.length > 0) {\n this.updateData(what, data)\n }\n }, this)\n }\n\n updateData (what?: AtomDataFields|BondDataFields, data?: any) {\n this.build()\n }\n\n getColorParams () {\n return {\n ...super.getColorParams(),\n structure: this.structure\n }\n }\n\n getRadiusParams (param?: any) {\n return {\n type: this.radiusType,\n scale: this.radiusScale,\n size: this.radiusSize,\n data: this.radiusData\n }\n }\n\n getAtomParams (what?: AtomDataFields, params?: AtomDataParams) {\n return Object.assign({\n what: what,\n colorParams: this.getColorParams(),\n radiusParams: this.getRadiusParams()\n }, params)\n }\n\n getBondParams (what?: BondDataFields, params?: BondDataParams) {\n return Object.assign({\n what: what,\n colorParams: this.getColorParams(),\n radiusParams: this.getRadiusParams()\n }, params)\n }\n\n getAtomRadius (atom: AtomProxy) {\n if (this.structureView.atomSet!.isSet(atom.index)) {\n const radiusFactory = new RadiusFactory(this.getRadiusParams())\n return radiusFactory.atomRadius(atom)\n }\n return 0\n }\n\n /**\n * Set representation parameters\n * @alias StructureRepresentation#setSelection\n * @param {String} string - selection string, see {@tutorial selection-language}\n * @param {Boolean} [silent] - don't trigger a change event in the selection\n * @return {StructureRepresentation} this object\n */\n setSelection (string: string, silent?: boolean) {\n this.selection.setString(string, silent)\n\n return this\n }\n\n /**\n * Set representation parameters\n * @alias StructureRepresentation#setParameters\n * @param {StructureRepresentationParameters} params - structure parameter object\n * @param {Object} [what] - buffer data attributes to be updated,\n * note that this needs to be implemented in the\n * derived classes. Generally it allows more\n * fine-grained control over updating than\n * forcing a rebuild.\n * @param {Boolean} what.position - update position data\n * @param {Boolean} what.color - update color data\n * @param {Boolean} [rebuild] - whether or not to rebuild the representation\n * @return {StructureRepresentation} this object\n */\n setParameters (params: Partial, what: AtomDataFields = {}, rebuild = false) {\n const p = params || {}\n\n this.setRadius(p.radius, p)\n\n if (p.radiusType !== undefined || p.radiusData !== undefined || p.radiusSize !== undefined || p.radiusScale !== undefined) {\n what.radius = true\n if (!ExtensionFragDepth || this.disableImpostor) {\n rebuild = true\n }\n }\n\n if (p.defaultAssembly !== undefined &&\n p.defaultAssembly !== this.defaultAssembly &&\n ((this.assembly === 'default' && p.assembly === undefined) ||\n p.assembly === 'default')\n ) {\n rebuild = true\n }\n\n super.setParameters(p, what, rebuild)\n\n return this\n }\n\n getParameters () {\n const params = Object.assign(\n super.getParameters(),\n {\n sele: this.selection ? this.selection.string : undefined,\n defaultAssembly: this.defaultAssembly\n }\n )\n\n return params\n }\n\n attach (callback: ()=> void) {\n const viewer = this.viewer\n const bufferList = this.bufferList\n\n this.dataList.forEach(function (data) {\n data.bufferList.forEach(function (buffer) {\n bufferList.push(buffer)\n viewer.add(buffer, data.instanceList)\n })\n })\n\n this.setVisibility(this.visible)\n callback()\n }\n\n clear () {\n this.dataList.length = 0\n\n super.clear()\n }\n\n dispose () {\n this.structureView.dispose()\n\n super.dispose()\n }\n}\n\nexport default StructureRepresentation\n","/**\n * @file Measurement Representation\n * @author Fred Ludlow \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { Color, Vector3, Matrix4 } from 'three'\n\nimport Selection from '../selection/selection'\nimport { Browser } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport { uniformArray, uniformArray3 } from '../math/array-utils'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { LabelRepresentationParameters } from './label-representation';\nimport TextBuffer, { TextBufferData } from '../buffer/text-buffer';\nimport { GenericColor } from '../types'\n\nexport interface LabelDataField {\n position?: boolean\n labelColor?: boolean\n labelSize?: boolean\n radius?: boolean\n labelText?: boolean\n}\n\n/**\n * Measurement representation parameter object.\n * @typedef {Object} MeasurementRepresentationParameters - measurement representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n *\n * @property {Float} labelSize - size of the distance label\n * @property {Color} labelColor - color of the distance label\n * @property {Boolean} labelVisible - visibility of the distance label\n * @property {Float} labelZOffset - offset in z-direction (i.e. in camera direction)\n */\nexport interface MeasurementRepresentationParameters extends StructureRepresentationParameters {\n labelVisible: boolean\n labelSize: number\n labelColor: GenericColor\n labelType: 'atomname'|'atomindex'|'occupancy'|'bfactor'|'serial'|'element'|'atom'|'resname'|'resno'|'res'|'text'|'qualified'\n labelText: string\n labelFormat: string\n labelGrouping: 'atom'|'residue'\n labelFontFamily: 'sans-serif'|'monospace'|'serif'\n labelFontStyle: 'normal'|'italic'\n labelFontWeight: 'normal'|'bold'\n labelsdf: boolean\n labelXOffset: number\n labelYOffset: number\n labelZOffset: number\n labelAttachment: 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n labelBorder: boolean\n labelBorderColor: GenericColor\n labelBorderWidth: number\n labelBackground: boolean\n labelBackgroundColor: GenericColor\n labelBackgroundMargin: number\n labelBackgroundOpacity: number\n labelFixedSize: boolean\n lineOpacity: number\n linewidth: number\n}\n\n/**\n * Measurement representation\n * @interface\n */\nabstract class MeasurementRepresentation extends StructureRepresentation {\n protected n: number\n protected labelVisible: boolean\n protected labelSize: number\n protected labelColor: GenericColor\n protected labelType: 'atomname'|'atomindex'|'occupancy'|'bfactor'|'serial'|'element'|'atom'|'resname'|'resno'|'res'|'text'|'qualified'\n protected labelText: string\n protected labelFormat: string\n protected labelGrouping: 'atom'|'residue'\n protected labelFontFamily: 'sans-serif'|'monospace'|'serif'\n protected labelFontStyle: 'normal'|'italic'\n protected labelFontWeight: 'normal'|'bold'\n protected labelsdf: boolean\n protected labelXOffset: number\n protected labelYOffset: number\n protected labelZOffset: number\n protected labelAttachment: 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n protected labelBorder: boolean\n protected labelBorderColor: GenericColor\n protected labelBorderWidth: number\n protected labelBackground: boolean\n protected labelBackgroundColor: GenericColor\n protected labelBackgroundMargin: number\n protected labelBackgroundOpacity: number\n protected labelFixedSize: boolean\n protected lineOpacity: number\n protected linewidth: number\n protected lineVisible: boolean\n\n protected textBuffer: TextBuffer\n /**\n * Handles common label settings and position logic for\n * distance, angle and dihedral representations\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.n = 0 // Subclass create sets value\n this.parameters = Object.assign({\n labelVisible: {\n type: 'boolean'\n },\n labelSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n labelColor: {\n type: 'color'\n },\n labelFontFamily: {\n type: 'select',\n options: {\n 'sans-serif': 'sans-serif',\n 'monospace': 'monospace',\n 'serif': 'serif'\n },\n buffer: 'fontFamily'\n },\n labelFontStyle: {\n type: 'select',\n options: {\n 'normal': 'normal',\n 'italic': 'italic'\n },\n buffer: 'fontStyle'\n },\n labelFontWeight: {\n type: 'select',\n options: {\n 'normal': 'normal',\n 'bold': 'bold'\n },\n buffer: 'fontWeight'\n },\n labelsdf: {\n type: 'boolean', buffer: 'sdf'\n },\n labelXOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: 'xOffset'\n },\n labelYOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: 'yOffset'\n },\n labelZOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: 'zOffset'\n },\n labelAttachment: {\n type: 'select',\n options: {\n 'bottom-left': 'bottom-left',\n 'bottom-center': 'bottom-center',\n 'bottom-right': 'bottom-right',\n 'middle-left': 'middle-left',\n 'middle-center': 'middle-center',\n 'middle-right': 'middle-right',\n 'top-left': 'top-left',\n 'top-center': 'top-center',\n 'top-right': 'top-right'\n },\n rebuild: true\n },\n labelBorder: {\n type: 'boolean', buffer: 'showBorder'\n },\n labelBorderColor: {\n type: 'color', buffer: 'borderColor'\n },\n labelBorderWidth: {\n type: 'number', precision: 2, max: 0.3, min: 0, buffer: 'borderWidth'\n },\n labelBackground: {\n type: 'boolean', rebuild: true\n },\n labelBackgroundColor: {\n type: 'color', buffer: 'backgroundColor'\n },\n labelBackgroundMargin: {\n type: 'number', precision: 2, max: 2, min: 0, rebuild: true\n },\n labelBackgroundOpacity: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: 'backgroundOpacity'\n },\n labelFixedSize: {\n type: 'boolean', buffer: 'fixedSize'\n },\n lineOpacity: {\n type: 'range', min: 0.0, max: 1.0, step: 0.01\n },\n linewidth: {\n type: 'integer', max: 50, min: 1, buffer: true\n }\n }, this.parameters, {\n flatShaded: null\n })\n }\n\n init (params: Partial) {\n const p = params || {}\n this.labelVisible = defaults(p.labelVisible, true)\n this.labelSize = defaults(p.labelSize, 2.0)\n this.labelColor = defaults(p.labelColor, 0xFFFFFF)\n this.labelFontFamily = defaults(p.labelFontFamily, 'sans-serif')\n this.labelFontStyle = defaults(p.labelFontstyle, 'normal')\n this.labelFontWeight = defaults(p.labelFontWeight, 'bold')\n this.labelsdf = defaults(p.labelsdf, Browser === 'Chrome')\n this.labelXOffset = defaults(p.labelXOffset, 0.0)\n this.labelYOffset = defaults(p.labelYOffset, 0.0)\n this.labelZOffset = defaults(p.labelZOffset, 0.5)\n this.labelAttachment = defaults(p.labelAttachment, 'bottom-left')\n this.labelBorder = defaults(p.labelBorder, false)\n this.labelBorderColor = defaults(p.labelBorderColor, 'lightgrey')\n this.labelBorderWidth = defaults(p.labelBorderWidth, 0.15)\n this.labelBackground = defaults(p.labelBackground, false)\n this.labelBackgroundColor = defaults(p.labelBackgroundColor, 'lightgrey')\n this.labelBackgroundMargin = defaults(p.labelBackgroundMargin, 0.5)\n this.labelBackgroundOpacity = defaults(p.labelBackgroundOpacity, 1.0)\n this.labelFixedSize = defaults(p.labelFixedSize, false)\n this.lineOpacity = defaults(p.lineOpacity, 1.0)\n this.linewidth = defaults(p.linewidth, 2)\n\n super.init(p)\n }\n\n // All measurements need to rebuild on position change\n update (what: LabelDataField) {\n if (what.position) {\n this.build()\n } else {\n super.update(what)\n }\n }\n\n updateData (what: LabelDataField & {[k: string]: any}, data: any) {\n const textData: TextBufferData | {} = {}\n if (!what || what.labelSize) {\n Object.assign(textData, {size: uniformArray(this.n, this.labelSize)})\n }\n\n if (!what || what.labelColor) {\n const c = new Color(this.labelColor)\n Object.assign(textData, {color: uniformArray3(this.n, c.r, c.g, c.b)})\n }\n\n this.textBuffer.setAttributes(textData as TextBufferData)\n }\n\n setParameters (params: Partial, what: LabelDataField = {}, rebuild = false) {\n if (params && params.labelSize) {\n what.labelSize = true\n }\n\n if (params && (params.labelColor || params.labelColor === 0x000000)) {\n what.labelColor = true\n rebuild = true\n }\n\n super.setParameters(params, what, rebuild)\n\n if (params && params.opacity !== undefined) {\n this.textBuffer.setParameters({ opacity: 1.0 }) // only opaque labels\n }\n\n if (params && params.labelVisible !== undefined) {\n this.setVisibility(this.visible)\n }\n\n return this\n }\n\n setVisibility (value: boolean, noRenderRequest?: boolean) {\n super.setVisibility(value, true)\n if (this.textBuffer) {\n this.textBuffer.setVisibility(\n this.labelVisible && this.visible\n )\n }\n\n if (!noRenderRequest) this.viewer.requestRender()\n\n return this\n }\n\n getLabelBufferParams (params: Partial = {}) {\n return super.getBufferParams(Object.assign({\n fontFamily: this.labelFontFamily,\n fontStyle: this.labelFontStyle,\n fontWeight: this.labelFontWeight,\n sdf: this.labelsdf,\n xOffset: this.labelXOffset,\n yOffset: this.labelYOffset,\n zOffset: this.labelZOffset,\n attachment: this.labelAttachment,\n showBorder: this.labelBorder,\n borderColor: this.labelBorderColor,\n borderWidth: this.labelBorderWidth,\n showBackground: this.labelBackground,\n backgroundColor: this.labelBackgroundColor,\n backgroundMargin: this.labelBackgroundMargin,\n backgroundOpacity: this.labelBackgroundOpacity,\n fixedSize: this.labelFixedSize,\n disablePicking: true,\n visible: this.labelVisible\n }, params, {\n opacity: 1.0 // only opaque labels\n }))\n }\n\n getAtomRadius () {\n return 0\n }\n}\n\n/**\n * MeasurementRepresentations take atom[Pair|Triple|Quad] parameters.\n *\n * Parses nested array of either integer atom indices or selection\n * expressions into a flat array of coordinates.\n *\n * @param {Structure} sview The structure to which the atoms refer\n * @param {Array} atoms Nested array of atom pairs|triples|quads as\n * Integer indices or selection expressions\n * @return {Float32Array} Flattened array of position coordinates\n */\nfunction parseNestedAtoms (sview: StructureView, atoms: (number|string)[][]) {\n const ap = sview.getAtomProxy()\n const sele = new Selection()\n\n const nSets = atoms.length\n if (nSets === 0) return new Float32Array(0)\n\n // Peek-ahead at first item to determine order and parse mode\n const order = atoms[ 0 ].length\n const selected = sview.getAtomSet()\n\n const a = new Float32Array(nSets * order * 3)\n\n let p = 0\n atoms.forEach(function (group) {\n let _break = false\n for (let j = 0; j < order; j++) {\n const value = group[ j ]\n if (typeof (value) === 'number' && Number.isInteger(value)) {\n if (selected.get(value)) {\n ap.index = value\n } else {\n _break = true\n break\n }\n } else {\n sele.setString(value as string)\n const atomIndices = sview.getAtomIndices(sele)\n if (atomIndices!.length) {\n ap.index = atomIndices![ 0 ]\n } else {\n _break = true\n break\n }\n }\n\n let offset = p + j * 3\n a[ offset++ ] = ap.x\n a[ offset++ ] = ap.y\n a[ offset++ ] = ap.z\n }\n if (!_break) p += 3 * order\n })\n\n return a.subarray(0, p)\n}\n\n/* out = v1 * cos(angle) + v2 * sin(angle) */\nfunction calcArcPoint (out: Float32Array, center: Float32Array, v1: Float32Array, v2: Float32Array, angle: number) {\n const x = Math.cos(angle)\n const y = Math.sin(angle)\n out[ 0 ] = center[ 0 ] + v1[ 0 ] * x + v2[ 0 ] * y\n out[ 1 ] = center[ 1 ] + v1[ 1 ] * x + v2[ 1 ] * y\n out[ 2 ] = center[ 2 ] + v1[ 2 ] * x + v2[ 2 ] * y\n}\n\nexport {\n MeasurementRepresentation as default,\n calcArcPoint,\n parseNestedAtoms\n}\n","/**\n * @file Edt\n * @author Alexander Rose \n * @private\n */\n\nimport { NumberArray } from '../types'\n\n// 2D Euclidean distance transform by Felzenszwalb & Huttenlocher https://cs.brown.edu/~pff/papers/dt-final.pdf\nexport function edt(data: NumberArray, width: number, height: number, f: NumberArray, d: NumberArray, v: NumberArray, z: NumberArray) {\n for (let x = 0; x < width; x++) {\n for (let y = 0; y < height; y++) {\n f[y] = data[y * width + x]\n }\n edt1d(f, d, v, z, height)\n for (let y = 0; y < height; y++) {\n data[y * width + x] = d[y]\n }\n }\n for (let y = 0; y < height; y++) {\n for (let x = 0; x < width; x++) {\n f[x] = data[y * width + x]\n }\n edt1d(f, d, v, z, width)\n for (let x = 0; x < width; x++) {\n data[y * width + x] = Math.sqrt(d[x])\n }\n }\n}\n\n// 1D squared distance transform\nfunction edt1d(f: NumberArray, d: NumberArray, v: NumberArray, z: NumberArray, n: number) {\n v[0] = 0\n z[0] = Number.MIN_SAFE_INTEGER\n z[1] = Number.MAX_SAFE_INTEGER\n\n for (let q = 1, k = 0; q < n; q++) {\n let s = ((f[q] + q * q) - (f[v[k]] + v[k] * v[k])) / (2 * q - 2 * v[k])\n while (s <= z[k]) {\n k--\n s = ((f[q] + q * q) - (f[v[k]] + v[k] * v[k])) / (2 * q - 2 * v[k])\n }\n k++\n v[k] = q\n z[k] = s\n z[k + 1] = Number.MAX_SAFE_INTEGER\n }\n\n for (let q = 0, k = 0; q < n; q++) {\n while (z[k + 1] < q) k++\n d[q] = (q - v[k]) * (q - v[k]) + f[v[k]]\n }\n}\n","/**\n * @file Text Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { Color, CanvasTexture, Vector3, Matrix4 } from 'three'\n\nimport '../shader/SDFFont.vert'\nimport '../shader/SDFFont.frag'\n\nimport { BufferRegistry } from '../globals'\nimport { createParams } from '../utils'\nimport MappedQuadBuffer from './mappedquad-buffer'\nimport { IgnorePicker } from '../utils/picker'\nimport { edt } from '../utils/edt'\nimport { BufferDefaultParameters, BufferParameterTypes, BufferData, BufferTypes, BufferParameters } from './buffer'\nimport { GenericColor } from '../types'\n\nconst TextAtlasCache: { [k: string]: TextAtlas } = {}\n\nfunction getTextAtlas (params: Partial) {\n const hash = JSON.stringify(params)\n if (TextAtlasCache[ hash ] === undefined) {\n TextAtlasCache[ hash ] = new TextAtlas(params)\n }\n return TextAtlasCache[ hash ]\n}\n\ntype TextFonts = 'sans-serif'|'monospace'|'serif'\ntype TextStyles = 'normal'|'italic'\ntype TextVariants = 'normal'\ntype TextWeights = 'normal'|'bold'\n\nexport const TextAtlasDefaultParams = {\n font: 'sans-serif' as TextFonts,\n size: 36,\n style: 'normal' as TextStyles,\n variant: 'normal' as TextVariants,\n weight: 'normal' as TextWeights,\n outline: 3,\n width: 1024,\n height: 1024\n}\nexport type TextAtlasParams = typeof TextAtlasDefaultParams\n\nexport type TextAtlasMap = { x: number, y: number, w: number, h: number }\n\nexport class TextAtlas {\n parameters: TextAtlasParams\n\n gamma = 1\n mapped: { [k: string]: TextAtlasMap } = {}\n scratchW = 0\n scratchH = 0\n currentX = 0\n currentY = 0\n\n cutoff = 0.25\n padding: number\n radius: number\n\n gridOuter: Float64Array\n gridInner: Float64Array\n f: Float64Array\n d: Float64Array\n z: Float64Array\n v: Int16Array\n\n paddedSize: number\n middle: number\n\n texture: CanvasTexture\n canvas: HTMLCanvasElement\n context: CanvasRenderingContext2D\n\n lineHeight: number\n maxWidth: number\n colors: string[]\n scratch: Uint8Array\n canvas2: HTMLCanvasElement\n context2: CanvasRenderingContext2D\n data: Uint8Array\n\n placeholder: TextAtlasMap\n\n constructor (params: Partial = {}) {\n this.parameters = createParams(params, TextAtlasDefaultParams)\n const p = this.parameters\n\n this.radius = p.size / 8\n this.padding = p.size / 3\n\n // Prepare line-height with room for outline and descenders/ascenders\n const lineHeight = this.lineHeight = p.size + 2 * p.outline + Math.round(p.size / 4)\n const maxWidth = this.maxWidth = p.width / 4\n\n // Prepare scratch canvas\n const canvas = this.canvas = document.createElement('canvas')\n canvas.width = maxWidth\n canvas.height = lineHeight\n\n const ctx = this.context = this.canvas.getContext('2d')!\n ctx.font = `${p.style} ${p.variant} ${p.weight} ${p.size}px ${p.font}`\n ctx.fillStyle = 'black'\n ctx.textAlign = 'left'\n ctx.textBaseline = 'bottom'\n ctx.lineJoin = 'round'\n\n // temporary arrays for the distance transform\n this.gridOuter = new Float64Array(lineHeight * maxWidth)\n this.gridInner = new Float64Array(lineHeight * maxWidth)\n this.f = new Float64Array(Math.max(lineHeight, maxWidth))\n this.d = new Float64Array(Math.max(lineHeight, maxWidth))\n this.z = new Float64Array(Math.max(lineHeight, maxWidth) + 1)\n this.v = new Int16Array(Math.max(lineHeight, maxWidth))\n\n //\n this.data = new Uint8Array(p.width * p.height * 4)\n this.canvas2 = document.createElement('canvas')\n this.canvas2.width = p.width\n this.canvas2.height = p.height\n this.context2 = this.canvas2.getContext('2d')!\n\n // Replacement Character\n this.placeholder = this.map(String.fromCharCode(0xFFFD))\n\n // Basic Latin (subset)\n for (let i = 0x0020; i <= 0x007E; ++i) {\n this.map(String.fromCharCode(i))\n }\n\n // TODO: to slow to always prepare them\n // // Latin-1 Supplement (subset)\n // for (let i = 0x00A1; i <= 0x00FF; ++i) {\n // this.map(String.fromCharCode(i))\n // }\n\n // Degree sign\n this.map(String.fromCharCode(0x00B0))\n\n // // Greek and Coptic (subset)\n // for (let i = 0x0391; i <= 0x03C9; ++i) {\n // this.map(String.fromCharCode(i))\n // }\n\n // // Cyrillic (subset)\n // for (let i = 0x0400; i <= 0x044F; ++i) {\n // this.map(String.fromCharCode(i))\n // }\n\n // Angstrom Sign\n this.map(String.fromCharCode(0x212B))\n\n this.texture = new CanvasTexture(this.canvas2)\n this.texture.flipY = false\n this.texture.needsUpdate = true\n }\n\n map (text: string) {\n const p = this.parameters\n\n if (this.mapped[ text ] === undefined) {\n this.draw(text)\n\n if (this.currentX + this.scratchW > p.width) {\n this.currentX = 0\n this.currentY += this.scratchH\n }\n if (this.currentY + this.scratchH > p.height) {\n console.warn('canvas to small')\n }\n\n this.mapped[ text ] = {\n x: this.currentX,\n y: this.currentY,\n w: this.scratchW,\n h: this.scratchH\n }\n\n this.context2.drawImage(\n this.canvas,\n 0, 0,\n this.scratchW, this.scratchH,\n this.currentX, this.currentY,\n this.scratchW, this.scratchH\n )\n\n this.currentX += this.scratchW\n }\n\n return this.mapped[ text ]\n }\n\n get (text: string) {\n return this.mapped[ text ] || this.placeholder\n }\n\n draw (text: string) {\n const p = this.parameters\n\n const h = this.lineHeight\n const o = p.outline\n const ctx = this.context\n // const dst = this.scratch\n const max = this.maxWidth\n // const colors = this.colors\n\n // Bottom aligned, take outline into account\n const x = o\n const y = h - p.outline\n\n // Measure text\n const m = ctx.measureText(text)\n const w = Math.min(max, Math.ceil(m.width + 2 * x + 1))\n\n const n = w * h\n\n // Clear scratch area\n ctx.clearRect(0, 0, w, h)\n\n // Draw text\n ctx.fillText(text, x, y)\n\n const imageData = ctx.getImageData(0, 0, w, h)\n const data = imageData.data\n\n for (let i = 0; i < n; i++) {\n const a = imageData.data[i * 4 + 3] / 255; // alpha value\n this.gridOuter[i] = a === 1 ? 0 : a === 0 ? Number.MAX_SAFE_INTEGER : Math.pow(Math.max(0, 0.5 - a), 2);\n this.gridInner[i] = a === 1 ? Number.MAX_SAFE_INTEGER : a === 0 ? 0 : Math.pow(Math.max(0, a - 0.5), 2);\n }\n\n edt(this.gridOuter, w, h, this.f, this.d, this.v, this.z);\n edt(this.gridInner, w, h, this.f, this.d, this.v, this.z);\n\n for (let i = 0; i < n; i++) {\n const d = this.gridOuter[i] - this.gridInner[i];\n data[i * 4 + 3] = Math.max(0, Math.min(255, Math.round(255 - 255 * (d / this.radius + this.cutoff))));\n }\n\n ctx.putImageData(imageData, 0, 0)\n this.scratchW = w\n this.scratchH = h\n }\n}\n\n/**\n * Text buffer parameter object.\n * @typedef {Object} TextBufferParameters - text buffer parameters\n *\n * @property {Float} opacity - translucency: 1 is fully opaque, 0 is fully transparent\n * @property {Integer} clipNear - position of camera near/front clipping plane\n * in percent of scene bounding box\n * @property {String} labelType - type of the label, one of:\n * \"atomname\", \"atomindex\", \"occupancy\", \"bfactor\",\n * \"serial\", \"element\", \"atom\", \"resname\", \"resno\",\n * \"res\", \"text\", \"qualified\". When set to \"text\", the\n * `labelText` list is used.\n * @property {String[]} labelText - list of label strings, must set `labelType` to \"text\"\n * to take effect\n * @property {String} fontFamily - font family, one of: \"sans-serif\", \"monospace\", \"serif\"\n * @property {String} fontStyle - font style, \"normal\" or \"italic\"\n * @property {String} fontWeight - font weight, \"normal\" or \"bold\"\n * @property {Float} xOffset - offset in x-direction\n * @property {Float} yOffset - offset in y-direction\n * @property {Float} zOffset - offset in z-direction (i.e. in camera direction)\n * @property {String} attachment - attachment of the label, one of:\n * \"bottom-left\", \"bottom-center\", \"bottom-right\",\n * \"middle-left\", \"middle-center\", \"middle-right\",\n * \"top-left\", \"top-center\", \"top-right\"\n * @property {Boolean} showBorder - show border/outline\n * @property {Color} borderColor - color of the border/outline\n * @property {Float} borderWidth - width of the border/outline\n * @property {Boolean} showBackground - show background rectangle\n * @property {Color} backgroundColor - color of the background\n * @property {Float} backgroundMargin - width of the background\n * @property {Float} backgroundOpacity - opacity of the background\n * @property {Boolean} fixedSize - show text with a fixed pixel size\n */\n\nexport interface TextBufferData extends BufferData {\n size: Float32Array\n text: string[]\n}\n\ntype TextAttachments = 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n\nexport const TextBufferDefaultParameters = Object.assign({\n fontFamily: 'sans-serif' as TextFonts,\n fontStyle: 'normal' as TextStyles,\n fontWeight: 'bold' as TextWeights,\n fontSize: 36,\n xOffset: 0.0,\n yOffset: 0.0,\n zOffset: 0.5,\n attachment: 'bottom-left' as TextAttachments,\n showBorder: false,\n borderColor: 'lightgrey' as number|string,\n borderWidth: 0.15,\n showBackground: false,\n backgroundColor: 'lightgrey' as number|string,\n backgroundMargin: 0.5,\n backgroundOpacity: 1.0,\n forceTransparent: true,\n fixedSize: false\n}, BufferDefaultParameters)\nexport type TextBufferParameters = BufferParameters & {\n fontFamily: TextFonts,\n fontStyle: TextStyles,\n fontWeight: TextWeights,\n fontSize: number,\n xOffset: number,\n yOffset: number,\n zOffset: number,\n attachment: TextAttachments,\n showBorder: boolean,\n borderColor: GenericColor,\n borderWidth: number,\n showBackground: boolean,\n backgroundColor: GenericColor,\n backgroundMargin: number,\n backgroundOpacity: number,\n forceTransparent: boolean,\n fixedSize: boolean\n}\n\nconst TextBufferParameterTypes = Object.assign({\n fontFamily: { uniform: true },\n fontStyle: { uniform: true },\n fontWeight: { uniform: true },\n fontSize: { uniform: true },\n xOffset: { uniform: true },\n yOffset: { uniform: true },\n zOffset: { uniform: true },\n showBorder: { uniform: true },\n borderColor: { uniform: true },\n borderWidth: { uniform: true },\n backgroundColor: { uniform: true },\n backgroundOpacity: { uniform: true },\n fixedSize: { updateShader: true }\n}, BufferParameterTypes)\n\nfunction getCharCount (data: TextBufferData, params: Partial) {\n const n = data.position!.length / 3\n let charCount = 0\n for (let i = 0; i < n; ++i) {\n charCount += data.text[ i ].length\n }\n if (params.showBackground) charCount += n\n\n return charCount\n}\n\n/**\n * Text buffer. Renders screen-aligned text strings.\n *\n * @example\n * var textBuffer = new TextBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * size: new Float32Array([ 2 ]),\n * text: [ \"Hello\" ]\n * });\n */\nclass TextBuffer extends MappedQuadBuffer {\n parameterTypes = TextBufferParameterTypes\n get defaultParameters() { return TextBufferDefaultParameters }\n parameters: TextBufferParameters\n\n alwaysTransparent = true\n hasWireframe = false\n isText = true\n vertexShader = 'SDFFont.vert'\n fragmentShader = 'SDFFont.frag'\n\n text: string[]\n positionCount: number\n texture: CanvasTexture\n textAtlas: TextAtlas\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.size - sizes\n * @param {String[]} data.text - text strings\n * @param {TextBufferParameters} params - parameters object\n */\n constructor (data: TextBufferData, params: Partial = {}) {\n super({\n position: new Float32Array(getCharCount(data, params) * 3),\n color: new Float32Array(getCharCount(data, params) * 3),\n picking: new IgnorePicker()\n }, params)\n\n this.text = data.text\n this.positionCount = data.position!.length / 3\n\n this.addUniforms({\n 'fontTexture': { value: null },\n 'xOffset': { value: this.parameters.xOffset },\n 'yOffset': { value: this.parameters.yOffset },\n 'zOffset': { value: this.parameters.zOffset },\n 'ortho': { value: false },\n 'showBorder': { value: this.parameters.showBorder },\n 'borderColor': { value: new Color(this.parameters.borderColor as number) },\n 'borderWidth': { value: this.parameters.borderWidth },\n 'backgroundColor': { value: new Color(this.parameters.backgroundColor as number) },\n 'backgroundOpacity': { value: this.parameters.backgroundOpacity },\n 'canvasHeight': { value: 1.0 },\n 'pixelRatio': { value: 1.0 }\n })\n\n this.addAttributes({\n 'inputTexCoord': { type: 'v2', value: null },\n 'inputSize': { type: 'f', value: null }\n })\n\n this.setAttributes(data)\n\n this.makeTexture()\n this.makeMapping()\n }\n\n makeMaterial () {\n super.makeMaterial()\n\n const tex = this.texture\n\n const m = this.material\n m.transparent = true\n m.extensions.derivatives = true\n m.lights = false\n m.uniforms.fontTexture.value = tex\n m.needsUpdate = true\n\n const wm = this.wireframeMaterial\n wm.transparent = true\n wm.extensions.derivatives = true\n wm.lights = false\n wm.uniforms.fontTexture.value = tex\n wm.needsUpdate = true\n\n const pm = this.pickingMaterial\n pm.extensions.derivatives = true\n pm.lights = false\n pm.uniforms.fontTexture.value = tex\n pm.needsUpdate = true\n }\n\n setAttributes (data: Partial = {}) {\n let position, size, color\n let aPosition, inputSize, aColor\n\n const text = this.text\n const attributes = this.geometry.attributes as any // TODO\n\n if (data.position) {\n position = data.position\n aPosition = attributes.position.array\n attributes.position.needsUpdate = true\n }\n\n if (data.size) {\n size = data.size\n inputSize = attributes.inputSize.array\n attributes.inputSize.needsUpdate = true\n }\n\n if (data.color) {\n color = data.color\n aColor = attributes.color.array\n attributes.color.needsUpdate = true\n }\n\n const n = this.positionCount\n\n let j, o\n let iCharAll = 0\n let txt, iChar, nChar\n\n for (let v = 0; v < n; ++v) {\n o = 3 * v\n txt = text[ v ]\n nChar = txt.length\n if (this.parameters.showBackground) nChar += 1\n\n for (iChar = 0; iChar < nChar; ++iChar, ++iCharAll) {\n for (let m = 0; m < 4; m++) {\n j = iCharAll * 4 * 3 + (3 * m)\n\n if (position) {\n aPosition[ j ] = position[ o ]\n aPosition[ j + 1 ] = position[ o + 1 ]\n aPosition[ j + 2 ] = position[ o + 2 ]\n }\n\n if (size) {\n inputSize[ (iCharAll * 4) + m ] = size[ v ]\n }\n\n if (color) {\n aColor[ j ] = color[ o ]\n aColor[ j + 1 ] = color[ o + 1 ]\n aColor[ j + 2 ] = color[ o + 2 ]\n }\n }\n }\n }\n }\n\n makeTexture () {\n this.textAtlas = getTextAtlas({\n font: this.parameters.fontFamily,\n style: this.parameters.fontStyle,\n weight: this.parameters.fontWeight,\n size: this.parameters.fontSize\n })\n\n this.texture = this.textAtlas.texture\n }\n\n makeMapping () {\n const ta = this.textAtlas\n const text = this.text\n const attachment = this.parameters.attachment\n const margin = (ta.lineHeight * this.parameters.backgroundMargin * 0.1) - 10\n\n const attribs = this.geometry.attributes as any // TODO\n const inputTexCoord = attribs.inputTexCoord.array\n const inputMapping = attribs.mapping.array\n\n const n = this.positionCount\n let iCharAll = 0\n let c, i, txt, xadvance, iChar, nChar, xShift, yShift\n\n for (let v = 0; v < n; ++v) {\n txt = text[ v ]\n xadvance = 0\n nChar = txt.length\n\n // calculate width\n for (iChar = 0; iChar < nChar; ++iChar) {\n c = ta.get(txt[ iChar ])\n xadvance += c.w - 2 * ta.parameters.outline\n }\n\n // attachment\n if (attachment.startsWith('top')) {\n yShift = ta.lineHeight / 1.25\n } else if (attachment.startsWith('middle')) {\n yShift = ta.lineHeight / 2.5\n } else {\n yShift = 0 // \"bottom\"\n }\n if (attachment.endsWith('right')) {\n xShift = xadvance\n } else if (attachment.endsWith('center')) {\n xShift = xadvance / 2\n } else {\n xShift = 0 // \"left\"\n }\n xShift += ta.parameters.outline\n yShift += ta.parameters.outline\n\n // background\n if (this.parameters.showBackground) {\n i = iCharAll * 2 * 4\n inputMapping[ i + 0 ] = -ta.lineHeight / 6 - xShift - margin // top left\n inputMapping[ i + 1 ] = ta.lineHeight - yShift + margin\n inputMapping[ i + 2 ] = -ta.lineHeight / 6 - xShift - margin // bottom left\n inputMapping[ i + 3 ] = 0 - yShift - margin\n inputMapping[ i + 4 ] = xadvance + ta.lineHeight / 6 - xShift + 2 * ta.parameters.outline + margin // top right\n inputMapping[ i + 5 ] = ta.lineHeight - yShift + margin\n inputMapping[ i + 6 ] = xadvance + ta.lineHeight / 6 - xShift + 2 * ta.parameters.outline + margin // bottom right\n inputMapping[ i + 7 ] = 0 - yShift - margin\n inputTexCoord[ i + 0 ] = 10\n inputTexCoord[ i + 2 ] = 10\n inputTexCoord[ i + 4 ] = 10\n inputTexCoord[ i + 6 ] = 10\n iCharAll += 1\n }\n\n xadvance = 0\n\n for (iChar = 0; iChar < nChar; ++iChar, ++iCharAll) {\n c = ta.get(txt[ iChar ])\n i = iCharAll * 2 * 4\n\n inputMapping[ i + 0 ] = xadvance - xShift // top left\n inputMapping[ i + 1 ] = c.h - yShift\n inputMapping[ i + 2 ] = xadvance - xShift // bottom left\n inputMapping[ i + 3 ] = 0 - yShift\n inputMapping[ i + 4 ] = xadvance + c.w - xShift // top right\n inputMapping[ i + 5 ] = c.h - yShift\n inputMapping[ i + 6 ] = xadvance + c.w - xShift // bottom right\n inputMapping[ i + 7 ] = 0 - yShift\n\n const texWidth = ta.parameters.width\n const texHeight = ta.parameters.height\n\n const texCoords = [\n c.x / texWidth, c.y / texHeight, // top left\n c.x / texWidth, (c.y + c.h) / texHeight, // bottom left\n (c.x + c.w) / texWidth, c.y / texHeight, // top right\n (c.x + c.w) / texWidth, (c.y + c.h) / texHeight // bottom right\n ]\n inputTexCoord.set(texCoords, i)\n\n xadvance += c.w - 2 * ta.parameters.outline\n }\n }\n\n attribs.inputTexCoord.needsUpdate = true\n attribs.mapping.needsUpdate = true\n }\n\n getDefines (type: BufferTypes) {\n const defines = super.getDefines(type)\n\n if (this.parameters.fixedSize) {\n defines.FIXED_SIZE = 1\n }\n\n return defines\n }\n\n setUniforms (data: any) { // TODO\n if (data && (\n data.fontFamily !== undefined ||\n data.fontStyle !== undefined ||\n data.fontWeight !== undefined ||\n data.fontSize !== undefined\n )) {\n this.makeTexture()\n this.makeMapping()\n this.texture.needsUpdate = true\n data.fontTexture = this.texture\n }\n\n super.setUniforms(data)\n }\n}\n\nBufferRegistry.add('text', TextBuffer)\n\nexport default TextBuffer\n","/**\n * @file Wide Line Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3 required for declaration only\nimport { Vector2, Vector3, Matrix4 } from 'three'\n\nimport '../shader/WideLine.vert'\nimport '../shader/WideLine.frag'\n\nimport { BufferRegistry } from '../globals'\nimport MappedQuadBuffer from './mappedquad-buffer'\nimport { BufferDefaultParameters, BufferParameterTypes, BufferData, BufferParameters } from './buffer'\n\nexport interface WideLineBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n color2: Float32Array\n}\n\nexport const WideLineBufferDefaultParameters = Object.assign({\n linewidth: 2\n}, BufferDefaultParameters)\nexport type WideLineBufferParameters = BufferParameters & { linewidth: number }\n\nconst WideLineBufferParameterTypes = Object.assign({\n linewidth: { uniform: true }\n}, BufferParameterTypes)\n\n/**\n * Wide Line buffer. Draws lines with a fixed width in pixels.\n *\n * @example\n * var lineBuffer = new WideLineBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ])\n * });\n */\nclass WideLineBuffer extends MappedQuadBuffer {\n parameterTypes = WideLineBufferParameterTypes\n get defaultParameters() { return WideLineBufferDefaultParameters }\n parameters: WideLineBufferParameters\n\n vertexShader = 'WideLine.vert'\n fragmentShader ='WideLine.frag'\n\n constructor (data: Partial, params: Partial = {}) {\n super(data, params)\n\n if (!data.color2 && data.color) data.color2 = data.color\n\n this.addUniforms({\n 'linewidth': { value: this.parameters.linewidth },\n 'resolution': { value: new Vector2() },\n 'projectionMatrixInverse': { value: new Matrix4() }\n })\n\n this.addAttributes({\n 'position1': { type: 'v3', value: null },\n 'position2': { type: 'v3', value: null },\n 'color2': { type: 'c', value: null }\n })\n\n this.setAttributes(data)\n this.makeMapping()\n }\n\n setParameters (params: Partial) {\n super.setParameters(params)\n }\n}\n\nBufferRegistry.add('wideline', WideLineBuffer)\n\nexport default WideLineBuffer\n","/**\n * @file Angle Representation\n * @author Fred Ludlow \n * @private\n */\nimport { Color } from 'three'\n\nimport { RepresentationRegistry } from '../globals'\nimport MeasurementRepresentation, { parseNestedAtoms, calcArcPoint, MeasurementRepresentationParameters, LabelDataField } from './measurement-representation'\nimport { defaults } from '../utils'\n\nimport MeshBuffer from '../buffer/mesh-buffer'\nimport TextBuffer, { TextBufferData, TextBufferParameters } from '../buffer/text-buffer'\nimport WideLineBuffer, { WideLineBufferData } from '../buffer/wideline-buffer'\n\nimport { v3add, v3cross, v3dot, v3fromArray, v3length, v3new,\n v3normalize, v3sub, v3toArray } from '../math/vector-utils'\nimport { copyArray, uniformArray, uniformArray3 } from '../math/array-utils'\nimport { RAD2DEG } from '../math/math-constants'\nimport { getFixedLengthWrappedDashData } from '../geometry/dash'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { BufferData } from '../buffer/buffer';\nimport { StructureRepresentationData, StructureRepresentationParameters } from './structure-representation';\n\n/**\n * @typedef {Object} AngleRepresentationParameters - angle representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n * @mixes MeasurementRepresentationParameters\n *\n * @property {String} atomTriple - list of triplets of selection strings\n * or atom indices\n * @property {Boolean} vectorVisible - Indicate the 3 points for each angle by drawing lines 1-2-3\n * @property {Boolean} arcVisible - Show the arc outline for each angle\n * @property {Number} lineOpacity - opacity for the line part of the representation\n * @property {Number} linewidth - width for line part of representation\n * @property {Boolean} sectorVisible - Show the filled arc for each angle\n */\n\nexport interface AngleRepresentationParameters extends MeasurementRepresentationParameters {\n atomTriple: (number|string)[][]\n vectorVisible: boolean\n arcVisible: boolean\n lineOpacity: number\n lineWidth: number\n sectorVisible: boolean\n}\n\n/**\n * Angle representation object\n *\n * Reperesentation consists of four parts, visibility can be set for each\n * label - the text label with the angle size\n * vectors - lines joining the three points\n * sector - triangles representing the angle\n * arc - line bordering the sector\n *\n * @param {Structure} structure - the structure to measure angles in\n * @param {Viewer} viewer - a viewer object\n * @param {AngleRepresentationParameters} params - angle representation parameters\n */\nclass AngleRepresentation extends MeasurementRepresentation {\n protected atomTriple: (number|string)[][]\n protected vectorVisible: boolean\n protected arcVisible: boolean\n protected lineOpacity: number\n protected lineWidth: number\n protected sectorVisible: boolean\n protected vectorBuffer: WideLineBuffer\n arcLength: number\n sectorLength: number\n arcBuffer: WideLineBuffer\n sectorBuffer: MeshBuffer\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'angle'\n\n this.parameters = Object.assign({\n atomTriple: {\n type: 'hidden', rebuild: true\n },\n vectorVisible: {\n type: 'boolean', default: true\n },\n arcVisible: {\n type: 'boolean', default: true\n },\n sectorVisible: {\n type: 'boolean', default: true\n }\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.side = defaults(p.side, 'double')\n p.opacity = defaults(p.opacity, 0.5)\n\n this.atomTriple = defaults(p.atomTriple, [])\n this.arcVisible = defaults(p.arcVisible, true)\n this.sectorVisible = defaults(p.sectorVisible, true)\n this.vectorVisible = defaults(p.vectorVisible, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n if (!sview.atomCount || !this.atomTriple.length) return\n\n const atomPosition = atomTriplePositions(sview, this.atomTriple)\n const angleData = getAngleData(atomPosition)\n const n = this.n = angleData.labelPosition.length / 3\n\n const labelColor = new Color(this.labelColor)\n\n // Create buffers\n this.textBuffer = new TextBuffer({\n position: angleData.labelPosition,\n size: uniformArray(n, this.labelSize),\n color: uniformArray3(n, labelColor.r, labelColor.g, labelColor.b),\n text: angleData.labelText\n } as TextBufferData, this.getLabelBufferParams() as TextBufferParameters)\n\n const c = new Color(this.colorValue)\n\n this.vectorBuffer = new WideLineBuffer(\n getFixedLengthWrappedDashData({\n position1: angleData.vectorPosition1,\n position2: angleData.vectorPosition2,\n color: uniformArray3(2 * n, c.r, c.g, c.b),\n color2: uniformArray3(2 * n, c.r, c.g, c.b)\n } as WideLineBufferData),\n this.getBufferParams({\n linewidth: this.linewidth,\n visible: this.vectorVisible,\n opacity: this.lineOpacity\n })\n )\n\n this.arcLength = angleData.arcPosition1.length / 3\n\n this.arcBuffer = new WideLineBuffer(\n getFixedLengthWrappedDashData({\n position1: angleData.arcPosition1,\n position2: angleData.arcPosition2,\n color: uniformArray3(this.arcLength, c.r, c.g, c.b),\n color2: uniformArray3(this.arcLength, c.r, c.g, c.b)\n } as WideLineBufferData), this.getBufferParams({\n linewidth: this.linewidth,\n visible: this.arcVisible,\n opacity: this.lineOpacity\n }))\n\n this.sectorLength = angleData.sectorPosition.length / 3\n\n this.sectorBuffer = new MeshBuffer({\n position: angleData.sectorPosition,\n color: uniformArray3(this.sectorLength, c.r, c.g, c.b)\n } as BufferData, this.getBufferParams({\n visible: this.sectorVisible\n }))\n\n return {\n bufferList: [\n this.textBuffer,\n this.vectorBuffer,\n this.arcBuffer,\n this.sectorBuffer\n ]\n }\n }\n\n updateData (what: LabelDataField & {color?: boolean}, data: StructureRepresentationData) {\n super.updateData(what, data)\n const vectorData = {}\n const arcData = {}\n const sectorData = {}\n\n if (what.color) {\n const c = new Color(this.colorValue)\n Object.assign(vectorData, {\n color: uniformArray3(this.n * 2, c.r, c.g, c.b),\n color2: uniformArray3(this.n * 2, c.r, c.g, c.b)\n })\n Object.assign(arcData, {\n color: uniformArray3(this.arcLength, c.r, c.g, c.b),\n color2: uniformArray3(this.arcLength, c.r, c.g, c.b)\n })\n Object.assign(sectorData, {\n color: uniformArray3(this.sectorLength, c.r, c.g, c.b)\n })\n }\n\n // if (what.sectorOpacity) {\n // this.sectorBuffer.opacity = what.sectorOpacity\n // }\n\n this.vectorBuffer.setAttributes(vectorData)\n this.arcBuffer.setAttributes(arcData)\n this.sectorBuffer.setAttributes(sectorData)\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n super.setParameters(params, what, rebuild)\n\n if (params && (\n params.vectorVisible !== undefined ||\n params.arcVisible !== undefined ||\n params.sectorVisible !== undefined)) {\n this.setVisibility(this.visible)\n }\n\n if (params && params.lineOpacity) {\n this.vectorBuffer.setParameters({ opacity: params.lineOpacity })\n this.arcBuffer.setParameters({ opacity: params.lineOpacity })\n }\n\n if (params && params.opacity !== undefined) {\n this.vectorBuffer.setParameters({ opacity: this.lineOpacity })\n this.arcBuffer.setParameters({ opacity: this.lineOpacity })\n }\n\n if (params && params.linewidth) {\n this.vectorBuffer.setParameters({ linewidth: params.linewidth })\n this.arcBuffer.setParameters({ linewidth: params.linewidth })\n }\n\n return this\n }\n\n setVisibility (value: boolean, noRenderRequest?: boolean) {\n super.setVisibility(value, true)\n\n if (this.vectorBuffer) {\n this.vectorBuffer.setVisibility(this.vectorVisible && this.visible)\n }\n\n if (this.arcBuffer) {\n this.arcBuffer.setVisibility(this.arcVisible && this.visible)\n }\n\n if (this.sectorBuffer) {\n this.sectorBuffer.setVisibility(this.sectorVisible && this.visible)\n }\n\n if (!noRenderRequest) this.viewer.requestRender()\n\n return this\n }\n}\n\n/**\n * Ensure mid point does not coincide with first or second\n * @param {Float32Array} position 9*nAngle array of coordinates\n * @return {Float32Array} Filtered position array, may be shorter\n */\nfunction validatePositions (position: Float32Array) {\n const include = []\n const n = position.length / 9\n for (let i = 0; i < n; i++) {\n // Check that first point not same as second and that second not same as third\n let okay = true\n for (let j = i; j < i + 3; j += 3) {\n if (position[j] === position[j + 3] &&\n position[j + 1] === position[j + 4] &&\n position[j + 2] === position[j + 5]) {\n okay = false\n }\n }\n if (okay) include.push(i)\n }\n const outPosition = new Float32Array(include.length * 9)\n let outIdx = 0\n include.forEach(function (i) {\n copyArray(position, outPosition, i * 9, outIdx * 9, 9)\n outIdx++\n })\n return outPosition\n}\n\nfunction atomTriplePositions (sview: StructureView, atomTriple: (number|string)[][]) {\n return validatePositions(parseNestedAtoms(sview, atomTriple))\n}\n\n/**\n * Converts triple positions into data required to build various buffers.\n */\nfunction getAngleData (position: Float32Array, params: Partial = {}) {\n const angleStep = defaults(params.angleStep, Math.PI / 90)\n const n = position.length / 9\n const angles = new Float32Array(n)\n const labelPosition = new Float32Array(n * 3)\n const labelText = new Array(n)\n\n const vectorPosition1 = new Float32Array(n * 6) // Two lines per angle\n const vectorPosition2 = new Float32Array(n * 6)\n\n const arcPositionTmp1 = new Array(n) // Start points for arc lines\n const arcPositionTmp2 = new Array(n) // End points for arc lines\n const sectorPositionTmp = new Array(n) // Triangle points\n\n let totalSegments = 0\n\n // Re-used vectors etc\n const p1 = v3new() // Positions of points for each angel\n const p2 = v3new()\n const p3 = v3new()\n const v21 = v3new() // Vectors\n const v23 = v3new()\n const cross = v3new() // Cross product v21xv23\n const cross2 = v3new() // In-plane cross product v21 x (v21 x v23)\n const labelTmp = v3new()\n const arcPoint = v3new()\n\n for (var i = 0; i < n; i++) {\n let p = 9 * i\n v3fromArray(p1, position, p)\n v3fromArray(p2, position, p + 3)\n v3fromArray(p3, position, p + 6)\n\n let v = 6 * i\n v3toArray(p1, vectorPosition1, v)\n v3toArray(p2, vectorPosition2, v)\n v3toArray(p2, vectorPosition1, v + 3)\n v3toArray(p3, vectorPosition2, v + 3)\n\n v3sub(v21, p1, p2)\n v3sub(v23, p3, p2)\n\n v3normalize(v21, v21) // validatePositions ensures valid\n v3normalize(v23, v23)\n\n v3cross(cross, v21, v23)\n const crossLength = v3length(cross)\n const dot = v3dot(v21, v23)\n\n const angle = angles[i] = Math.atan2(crossLength, dot)\n labelText[i] = (RAD2DEG * angle).toFixed(1) + String.fromCharCode(0x00B0)\n\n if (v3length(cross) === 0.0) {\n // Angle exactly 0/180, pick an arbitrary direction\n cross[ 0 ] = 1.0\n cross[ 1 ] = 0.0\n cross[ 2 ] = 0.0\n }\n v3cross(cross2, cross, v21)\n v3normalize(cross2, cross2)\n\n calcArcPoint(labelTmp, p2, v21, cross2, angle / 2.0)\n // TODO: Scale label position?\n v3toArray(labelTmp, labelPosition, 3 * i)\n\n // Build the arc and sector\n\n const nSegments = Math.ceil(angle / angleStep)\n const sectorVertices = new Float32Array(nSegments * 9)\n sectorPositionTmp[ i ] = sectorVertices\n const arcVertices1 = new Float32Array(nSegments * 3)\n const arcVertices2 = new Float32Array(nSegments * 3)\n arcPositionTmp1[ i ] = arcVertices1\n arcPositionTmp2[ i ] = arcVertices2\n\n v3add(arcPoint, p2, v21) // Our initial arc point\n\n const appendArcSection = function (a: number, j: number) {\n const si = j * 9\n const ai = j * 3\n v3toArray(p2, sectorVertices, si)\n v3toArray(arcPoint, sectorVertices, si + 3)\n v3toArray(arcPoint, arcVertices1, ai)\n\n calcArcPoint(arcPoint, p2, v21, cross2, a)\n\n v3toArray(arcPoint, sectorVertices, si + 6)\n v3toArray(arcPoint, arcVertices2, ai)\n }\n\n let j = 0\n for (let a = angleStep; a < angle; a += angleStep) {\n appendArcSection(a, j)\n j++\n }\n appendArcSection(angle, j)\n totalSegments += nSegments\n }\n\n // Flatten nested arrays of arc/segment points\n const arcSize = totalSegments * 3\n const sectorSize = totalSegments * 9\n const arcPosition1 = new Float32Array(arcSize)\n const arcPosition2 = new Float32Array(arcSize)\n const sectorPosition = new Float32Array(sectorSize)\n\n let sectorOffset = 0\n let arcOffset = 0\n for (let i = 0; i < n; i++) {\n const ap1 = arcPositionTmp1[ i ]\n const ap2 = arcPositionTmp2[ i ]\n copyArray(ap1, arcPosition1, 0, arcOffset, ap1.length)\n copyArray(ap2, arcPosition2, 0, arcOffset, ap2.length)\n arcOffset += ap1.length // === ap2.length\n\n const sp = sectorPositionTmp[ i ]\n copyArray(sp, sectorPosition, 0, sectorOffset, sp.length)\n sectorOffset += sp.length\n }\n\n return {\n labelPosition,\n labelText,\n vectorPosition1,\n vectorPosition2,\n arcPosition1,\n arcPosition2,\n sectorPosition\n }\n}\n\nRepresentationRegistry.add('angle', AngleRepresentation)\n\nexport default AngleRepresentation\n","/**\n * @file Cylinder Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3, CylinderBufferGeometry } from 'three'\n\nimport { defaults } from '../utils'\nimport { calculateCenterArray, serialBlockArray } from '../math/array-utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { CylinderBufferData } from './cylinder-buffer'\nimport { BufferDefaultParameters, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\nconst eye = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3(0, 1, 0)\n\nexport const CylinderGeometryBufferDefaultParameters = Object.assign({\n radialSegments: 1,\n openEnded: true\n}, BufferDefaultParameters)\nexport type CylinderGeometryBufferParameters = BufferParameters & {radialSegments: number, openEnded: boolean}\n\nfunction getData (data: CylinderBufferData, params: Partial = {}) {\n const geo = getGeo(params)\n\n const n = data.position1.length\n\n const geoLength = (geo.attributes as any).position.array.length / 3\n const count = n / 3\n const primitiveId = new Float32Array(count * 2 * geoLength)\n serialBlockArray(count, geoLength, 0, primitiveId)\n serialBlockArray(count, geoLength, count * geoLength, primitiveId)\n\n const position = new Float32Array(n * 2)\n const color = new Float32Array(n * 2)\n\n return {\n position, color, primitiveId, picking: data.picking\n }\n}\n\nfunction getGeo (params: Partial = {}) {\n const radialSegments = defaults(params.radialSegments, 10)\n const openEnded = defaults(params.openEnded, true)\n const matrix = new Matrix4().makeRotationX(Math.PI / 2)\n\n const geo = new CylinderBufferGeometry(\n 1, // radiusTop,\n 1, // radiusBottom,\n 1, // height,\n radialSegments, // radialSegments,\n 1, // heightSegments,\n openEnded // openEnded\n )\n geo.applyMatrix4(matrix)\n\n return geo\n}\n\n/**\n * Cylinder geometry buffer.\n *\n * @example\n * var cylinderGeometryBuffer = new CylinderGeometryBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass CylinderGeometryBuffer extends GeometryBuffer {\n updateNormals = true\n\n get defaultParameters() { return CylinderGeometryBufferDefaultParameters }\n parameters: CylinderGeometryBufferParameters\n\n __center: Float32Array\n _position: Float32Array\n _color: Float32Array\n _from: Float32Array\n _to: Float32Array\n _radius: Float32Array\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - from colors\n * @param {Float32Array} data.color2 - to colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n */\n constructor (data: CylinderBufferData, params: Partial = {}) {\n super(getData(data, params), params, getGeo(params))\n\n const n = data.position1.length\n const m = data.radius.length\n\n this.__center = new Float32Array(n)\n this._position = new Float32Array(n * 2)\n this._color = new Float32Array(n * 2)\n this._from = new Float32Array(n * 2)\n this._to = new Float32Array(n * 2)\n this._radius = new Float32Array(m * 2)\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n eye.fromArray(this._from as any, i3)\n target.fromArray(this._to as any, i3)\n matrix.lookAt(eye, target, up)\n\n const r = this._radius[ i ]\n scale.set(r, r, eye.distanceTo(target))\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n const meshData: Partial = {}\n\n if (data.position1 && data.position2) {\n calculateCenterArray(\n data.position1, data.position2, this.__center\n )\n calculateCenterArray(\n data.position1, this.__center, this._position\n )\n calculateCenterArray(\n this.__center, data.position2, this._position, data.position1.length\n )\n this._from.set(data.position1)\n this._from.set(this.__center, data.position1.length)\n this._to.set(this.__center)\n this._to.set(data.position2, this.__center.length)\n meshData.position = this._position\n }\n\n if (data.color && data.color2) {\n this._color.set(data.color)\n this._color.set(data.color2, data.color.length)\n meshData.color = this._color\n }\n\n if (data.radius) {\n this._radius.set(data.radius)\n this._radius.set(data.radius, data.radius.length)\n meshData.radius = this._radius\n }\n\n super.setAttributes(meshData, initNormals)\n }\n}\n\nexport default CylinderGeometryBuffer\n","/**\n * @file Mapped Aligned Box Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { BufferParameters, BufferData } from './buffer'\nimport MappedBuffer from './mapped-buffer'\n\n// +Y /\n// 0**********2\n// * | / **\n// * |/ * *\n// -----------3---- +X\n// * /| * *\n// * / | * *\n// 1/**|******4\n// / | * *\n// / | ** \n// +Z | 5 \nconst mapping = new Float32Array([\n -1.0, 1.0, -1.0,\n -1.0, -1.0, -1.0,\n 1.0, 1.0, -1.0,\n 1.0, 1.0, 1.0,\n 1.0, -1.0, -1.0,\n 1.0, -1.0, 1.0\n])\n\nconst mappingIndices = new Uint16Array([\n 0, 1, 2,\n 1, 4, 2,\n 2, 4, 3,\n 4, 5, 3\n])\n\n/**\n * Mapped Aligned box buffer. Draws boxes where one side is always screen-space aligned.\n * Used to render cylinder imposters.\n * @interface\n */\nclass MappedAlignedBoxBuffer extends MappedBuffer {\n constructor(data: BufferData, params: Partial = {}) {\n super('v3', data, params)\n }\n get mapping () { return mapping }\n get mappingIndices () { return mappingIndices }\n get mappingIndicesSize () { return 12 }\n get mappingSize () { return 6 }\n get mappingItemSize () { return 3 }\n}\n\nexport default MappedAlignedBoxBuffer\n","/**\n * @file Cylinder Impostor Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3 required for declaration only\nimport { Matrix4, Vector3 } from 'three'\n\nimport '../shader/CylinderImpostor.vert'\nimport '../shader/CylinderImpostor.frag'\n\nimport MappedAlignedBoxBuffer from './mappedalignedbox-buffer'\nimport { BufferDefaultParameters, BufferParameters, BufferParameterTypes, BufferTypes } from './buffer'\nimport { CylinderBufferData } from './cylinder-buffer'\n\nexport const CylinderImpostorBufferDefaultParameters = Object.assign({\n openEnded: false\n}, BufferDefaultParameters)\nexport type CylinderImpostorBufferParameters = BufferParameters & { openEnded: boolean }\n\nconst CylinderImpostorBufferParameterTypes = Object.assign({\n openEnded: { updateShader: true }\n}, BufferParameterTypes)\n\n/**\n * Cylinder impostor buffer.\n *\n * @example\n * var cylinderimpostorBuffer = new CylinderImpostorBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass CylinderImpostorBuffer extends MappedAlignedBoxBuffer {\n parameterTypes = CylinderImpostorBufferParameterTypes\n get defaultParameters() { return CylinderImpostorBufferDefaultParameters }\n parameters: CylinderImpostorBufferParameters\n\n isImpostor = true\n vertexShader = 'CylinderImpostor.vert'\n fragmentShader = 'CylinderImpostor.frag'\n\n /**\n * make cylinder impostor buffer\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - from colors\n * @param {Float32Array} data.color2 - to colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} data.picking - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: CylinderBufferData, params: Partial = {}) {\n super(data, params)\n\n this.addUniforms({\n 'modelViewMatrixInverse': { value: new Matrix4() },\n 'ortho': { value: 0.0 }\n })\n\n this.addAttributes({\n 'position1': { type: 'v3', value: null },\n 'position2': { type: 'v3', value: null },\n 'color2': { type: 'c', value: null },\n 'radius': { type: 'f', value: null }\n })\n\n this.setAttributes(data)\n this.makeMapping()\n }\n\n getDefines (type?: BufferTypes) {\n const defines = MappedAlignedBoxBuffer.prototype.getDefines.call(this, type)\n\n if (!this.parameters.openEnded) {\n defines.CAP = 1\n }\n\n return defines\n }\n}\n\nexport default CylinderImpostorBuffer\n","/**\n * @file Cylinder Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import required for declaration only\nimport { Vector3, Matrix4 } from 'three'\nimport { BufferRegistry, ExtensionFragDepth } from '../globals'\nimport CylinderGeometryBuffer, { CylinderGeometryBufferDefaultParameters, CylinderGeometryBufferParameters } from './cylindergeometry-buffer'\nimport CylinderImpostorBuffer, { CylinderImpostorBufferDefaultParameters, CylinderImpostorBufferParameters } from './cylinderimpostor-buffer'\nimport { BufferData } from './buffer'\n\nexport interface CylinderBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n color2: Float32Array\n radius: Float32Array\n}\n\nexport const CylinderBufferDefaultParameters = Object.assign({\n disableImpostor: false\n}, CylinderGeometryBufferDefaultParameters, CylinderImpostorBufferDefaultParameters)\nexport type CylinderBufferParameters = (CylinderGeometryBufferParameters & {disableImpostor: boolean}) | (CylinderImpostorBufferParameters & {disableImpostor: boolean})\n\nclass CylinderBufferImpl {\n constructor (data: CylinderBufferData, params: Partial = {}) {\n if (!data.color2 && data.color) data.color2 = data.color\n if (!ExtensionFragDepth || (params && params.disableImpostor)) {\n return new CylinderGeometryBuffer(data, params)\n } else {\n return new CylinderImpostorBuffer(data, params)\n }\n }\n}\n\n/**\n * Cylinder buffer. Depending on the value {@link ExtensionFragDepth} and\n * `params.disableImpostor` the constructor returns either a\n * {@link CylinderGeometryBuffer} or a {@link CylinderImpostorBuffer}\n * @implements {Buffer}\n *\n * @example\n * var cylinderBuffer = new CylinderBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\n//@ts-expect-error Incompatible constructor signatures\nconst CylinderBuffer: {\n new(data: CylinderBufferData, params: Partial): CylinderGeometryBuffer | CylinderImpostorBuffer;\n} = CylinderBufferImpl;\n\ntype CylinderBuffer = CylinderGeometryBuffer | CylinderImpostorBuffer;\n\nBufferRegistry.add('cylinder', CylinderBuffer)\n\nexport default CylinderBuffer\n","/**\n * @file Axes Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { Color, Vector3 } from 'three'\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { AxesPicker } from '../utils/picker'\nimport { uniformArray, uniformArray3 } from '../math/array-utils'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport CylinderBuffer, { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport StructureView from '../structure/structure-view';\nimport Viewer from '../viewer/viewer';\nimport { Structure } from '../ngl';\nimport { AtomDataFields } from '../structure/structure-data';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport PrincipalAxes from '../math/principal-axes';\n\nexport interface AxesRepresentationParameters extends StructureRepresentationParameters {\n showAxes: boolean\n showBox: boolean\n}\n\n/**\n * Axes representation. Show principal axes and/or a box aligned with them\n * that fits the structure or selection.\n *\n * __Name:__ _axes_\n *\n * @example\n * stage.loadFile( \"rcsb://3pqr\", {\n * assembly: \"BU1\"\n * } ).then( function( o ){\n * o.addRepresentation( \"cartoon\" );\n * o.addRepresentation( \"axes\", {\n * sele: \"RET\", showAxes: false, showBox: true, radius: 0.2\n * } );\n * o.addRepresentation( \"ball+stick\", { sele: \"RET\" } );\n * o.addRepresentation( \"axes\", {\n * sele: \":B and backbone\", showAxes: false, showBox: true, radius: 0.2\n * } );\n * stage.autoView();\n * var pa = o.structure.getPrincipalAxes();\n * stage.animationControls.rotate( pa.getRotationQuaternion(), 1500 );\n * } );\n */\nclass AxesRepresentation extends StructureRepresentation {\n \n protected showAxes: boolean\n protected showBox: boolean\n protected sphereBuffer: SphereBuffer\n protected cylinderBuffer: CylinderBuffer\n /**\n * @param {Structure} structure - the structure object\n * @param {Viewer} viewer - the viewer object\n * @param {StructureRepresentationParameters} params - parameters object\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'axes'\n\n this.parameters = Object.assign({\n\n radiusSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n sphereDetail: true,\n radialSegments: true,\n disableImpostor: true,\n showAxes: {\n type: 'boolean', rebuild: true\n },\n showBox: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n assembly: null\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.radiusSize = defaults(p.radiusSize, 0.5)\n p.colorValue = defaults(p.colorValue, 'lightgreen')\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.showAxes = defaults(p.showAxes, true)\n this.showBox = defaults(p.showBox, false)\n\n super.init(p)\n }\n\n getPrincipalAxes (): PrincipalAxes {\n let selection\n const assembly = this.getAssembly()\n\n if (assembly) {\n selection = assembly.partList[ 0 ].getSelection()\n }\n\n return this.structureView.getPrincipalAxes(selection)\n }\n\n getAxesData (sview: StructureView) {\n const pa = this.getPrincipalAxes()\n const c = new Color(this.colorValue)\n\n let vn = 0\n let en = 0\n\n if (this.showAxes) {\n vn += 6\n en += 3\n }\n\n if (this.showBox) {\n vn += 8\n en += 12\n }\n\n const vertexPosition = new Float32Array(3 * vn)\n const vertexColor = uniformArray3(vn, c.r, c.g, c.b)\n const vertexRadius = uniformArray(vn, this.radiusSize)\n\n const edgePosition1 = new Float32Array(3 * en)\n const edgePosition2 = new Float32Array(3 * en)\n const edgeColor = uniformArray3(en, c.r, c.g, c.b)\n const edgeRadius = uniformArray(en, this.radiusSize)\n\n let offset = 0\n\n if (this.showAxes) {\n const addAxis = function (v1: Vector3, v2: Vector3) {\n v1.toArray(vertexPosition as any, offset * 2)\n v2.toArray(vertexPosition as any, offset * 2 + 3)\n v1.toArray(edgePosition1 as any, offset)\n v2.toArray(edgePosition2 as any, offset)\n offset += 3\n }\n\n addAxis(pa.begA, pa.endA)\n addAxis(pa.begB, pa.endB)\n addAxis(pa.begC, pa.endC)\n }\n\n if (this.showBox) {\n const v = new Vector3()\n const { d1a, d2a, d3a, d1b, d2b, d3b } = pa.getProjectedScaleForAtoms(sview)\n\n // console.log(d1a, d2a, d3a, d1b, d2b, d3b)\n\n let offset2 = offset * 2\n const addCorner = function (d1: number, d2: number, d3: number) {\n v.copy(pa.center)\n .addScaledVector(pa.normVecA, d1)\n .addScaledVector(pa.normVecB, d2)\n .addScaledVector(pa.normVecC, d3)\n v.toArray(vertexPosition as any, offset2)\n offset2 += 3\n }\n addCorner(d1a, d2a, d3a)\n addCorner(d1a, d2a, d3b)\n addCorner(d1a, d2b, d3b)\n addCorner(d1a, d2b, d3a)\n addCorner(d1b, d2b, d3b)\n addCorner(d1b, d2b, d3a)\n addCorner(d1b, d2a, d3a)\n addCorner(d1b, d2a, d3b)\n\n let edgeOffset = offset\n const addEdge = function (a: number, b: number) {\n v.fromArray(vertexPosition as any, offset * 2 + a * 3)\n .toArray(edgePosition1 as any, edgeOffset)\n v.fromArray(vertexPosition as any, offset * 2 + b * 3)\n .toArray(edgePosition2 as any, edgeOffset)\n edgeOffset += 3\n }\n addEdge(0, 1)\n addEdge(0, 3)\n addEdge(0, 6)\n addEdge(1, 2)\n addEdge(1, 7)\n addEdge(2, 3)\n addEdge(2, 4)\n addEdge(3, 5)\n addEdge(4, 5)\n addEdge(4, 7)\n addEdge(5, 6)\n addEdge(6, 7)\n }\n\n const picker = new AxesPicker(pa)\n\n return {\n vertex: {\n position: vertexPosition,\n color: vertexColor,\n radius: vertexRadius,\n picking: picker\n },\n edge: {\n position1: edgePosition1,\n position2: edgePosition2,\n color: edgeColor,\n color2: edgeColor,\n radius: edgeRadius,\n picking: picker\n }\n }\n }\n\n create () {\n const axesData = this.getAxesData(this.structureView)\n\n this.sphereBuffer = new SphereBuffer(\n axesData.vertex as SphereBufferData,\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters\n )\n\n this.cylinderBuffer = new CylinderBuffer(\n axesData.edge as CylinderBufferData,\n this.getBufferParams({\n openEnded: true,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n this.dataList.push({\n sview: this.structureView,\n bufferList: [ this.sphereBuffer as SphereGeometryBuffer, this.cylinderBuffer as CylinderGeometryBuffer]\n })\n }\n\n createData (sview: StructureView): undefined {\n return\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n const axesData = this.getAxesData(data.sview as StructureView)\n const sphereData = {}\n const cylinderData = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {\n position: axesData.vertex.position\n })\n Object.assign(cylinderData, {\n position1: axesData.edge.position1,\n position2: axesData.edge.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {\n color: axesData.vertex.color as Float32Array\n })\n Object.assign(cylinderData, {\n color: axesData.edge.color as Float32Array,\n color2: axesData.edge.color as Float32Array\n })\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {\n radius: axesData.vertex.radius as Float32Array\n })\n Object.assign(cylinderData, {\n radius: axesData.edge.radius as Float32Array\n })\n }\n\n (this.sphereBuffer as SphereGeometryBuffer).setAttributes(sphereData);\n (this.cylinderBuffer as CylinderGeometryBuffer).setAttributes(cylinderData)\n }\n}\n\nRepresentationRegistry.add('axes', AxesRepresentation)\n\nexport default AxesRepresentation\n","/**\n * @file Ball And Stick Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { ExtensionFragDepth, RepresentationRegistry } from '../globals'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport CylinderBuffer, { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport WideLineBuffer from '../buffer/wideline-buffer'\nimport Viewer from '../viewer/viewer';\n// @ts-ignore: unused import Volume required for declaration only\nimport { Structure, Volume } from '../ngl';\nimport AtomProxy from '../proxy/atom-proxy';\nimport { AtomDataParams, BondDataParams, BondDataFields, AtomDataFields, BondData, AtomData } from '../structure/structure-data';\nimport StructureView from '../structure/structure-view';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\n// @ts-ignore: unused import Surface required for declaration only\nimport Surface from '../surface/surface';\n\nexport interface BallAndStickRepresentationParameters extends StructureRepresentationParameters {\n sphereDetail: number\n radialSegments: number\n openEnded: boolean\n disableImpostor: boolean\n aspectRatio: number\n lineOnly: boolean\n lineWidth: number\n cylinderOnly: boolean\n multipleBond: 'off' | 'symmetric' | 'offset'\n bondSpacing: number\n bondScale: number\n linewidth: number\n}\n\n/**\n * Ball And Stick representation parameter object. Extends {@link RepresentationParameters} and\n * {@link StructureRepresentationParameters}.\n *\n * @typedef {Object} BallAndStickRepresentationParameters - ball and stick representation parameters\n *\n * @property {Integer} sphereDetail - sphere quality (icosahedron subdivisions)\n * @property {Integer} radialSegments - cylinder quality (number of segments)\n * @property {Boolean} openEnded - capped or not\n * @property {Boolean} disableImpostor - disable use of raycasted impostors for rendering\n * @property {Float} aspectRatio - size difference between atom and bond radii\n * @property {Boolean} lineOnly - render only bonds, and only as lines\n * @property {Integer} linewidth - width of lines\n * @property {Boolean} cylinderOnly - render only bonds (no atoms)\n * @property {String} multipleBond - one off \"off\", \"symmetric\", \"offset\"\n * @property {Float} bondSpacing - spacing for multiple bond rendering\n * @property {Float} bondScale - scale/radius for multiple bond rendering\n */\n\n/**\n * Ball And Stick representation. Show atoms as spheres and bonds as cylinders.\n *\n * __Name:__ _ball+stick_\n *\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"ball+stick\" );\n * o.autoView();\n * } );\n */\nclass BallAndStickRepresentation extends StructureRepresentation {\n protected sphereDetail: number\n protected radialSegments: number\n protected openEnded: boolean\n protected disableImpostor: boolean\n protected aspectRatio: number\n protected lineOnly: boolean\n protected lineWidth: number\n protected cylinderOnly: boolean\n protected multipleBond: 'off' | 'symmetric' | 'offset'\n protected bondSpacing: number\n protected bondScale: number\n protected linewidth: number\n\n protected lineBuffer: WideLineBuffer\n /**\n * Create Ball And Stick representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {BallAndStickRepresentationParameters} params - ball and stick representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'ball+stick'\n\n this.parameters = Object.assign({\n\n sphereDetail: true,\n radialSegments: true,\n openEnded: true,\n disableImpostor: true,\n aspectRatio: {\n type: 'number', precision: 1, max: 10.0, min: 1.0\n },\n lineOnly: {\n type: 'boolean', rebuild: true\n },\n cylinderOnly: {\n type: 'boolean', rebuild: true\n },\n multipleBond: {\n type: 'select',\n rebuild: true,\n options: {\n 'off': 'off',\n 'symmetric': 'symmetric',\n 'offset': 'offset'\n }\n },\n bondScale: {\n type: 'number', precision: 2, max: 1.0, min: 0.01\n },\n bondSpacing: {\n type: 'number', precision: 2, max: 2.0, min: 0.5\n },\n linewidth: {\n type: 'integer', max: 50, min: 1, buffer: true\n }\n\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.radiusType = defaults(p.radiusType, 'size')\n p.radiusSize = defaults(p.radiusSize, 0.15)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.aspectRatio = defaults(p.aspectRatio, 2.0)\n this.lineOnly = defaults(p.lineOnly, false)\n this.cylinderOnly = defaults(p.cylinderOnly, false)\n this.multipleBond = defaults(p.multipleBond, 'off')\n this.bondSpacing = defaults(p.bondSpacing, 1.0)\n this.bondScale = defaults(p.bondScale, 0.4)\n this.linewidth = defaults(p.linewidth, 2)\n\n super.init(p)\n }\n\n getAtomRadius (atom: AtomProxy) {\n return this.aspectRatio * super.getAtomRadius(atom)\n }\n\n getAtomParams (what?: AtomDataFields, params?: Partial) {\n var p = super.getAtomParams(what, params)\n p.radiusParams.scale *= this.aspectRatio\n\n return p\n }\n\n getAtomData (sview: StructureView, what?: AtomDataFields, params?: Partial): AtomData {\n return sview.getAtomData(this.getAtomParams(what, params))\n }\n\n getBondParams (what?: BondDataFields, params?: Partial) {\n params = Object.assign({\n multipleBond: this.multipleBond,\n bondSpacing: this.bondSpacing,\n bondScale: this.bondScale\n }, params)\n\n return super.getBondParams(what, params)\n }\n\n getBondData (sview: StructureView, what?: BondDataFields, params?: Partial): BondData {\n return sview.getBondData(this.getBondParams(what, params))\n }\n\n createData (sview: StructureView) {\n const bufferList: any[] = []\n\n if (this.lineOnly) {\n this.lineBuffer = new WideLineBuffer(\n this.getBondData(sview, { position: true, color: true, picking: true }),\n this.getBufferParams({ linewidth: this.linewidth })\n )\n\n bufferList.push(this.lineBuffer)\n } else {\n const cylinderBuffer = new CylinderBuffer(\n (this.getBondData(sview) as CylinderBufferData),\n this.getBufferParams({\n openEnded: this.openEnded,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n bufferList.push(cylinderBuffer as CylinderGeometryBuffer)\n\n if (!this.cylinderOnly) {\n const sphereBuffer = new SphereBuffer(\n (this.getAtomData(sview) as SphereBufferData),\n (this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters)\n )\n\n bufferList.push(sphereBuffer as SphereGeometryBuffer)\n }\n }\n\n return {\n bufferList: bufferList\n }\n }\n\n updateData (what: BondDataFields | AtomDataFields, data: StructureRepresentationData) {\n if (this.multipleBond !== 'off' && what && what.radius) {\n what.position = true\n }\n\n const bondData = this.getBondData(data.sview as StructureView, what)\n\n if (this.lineOnly) {\n const lineData:Partial = {}\n\n if (!what || what.position) {\n Object.assign(lineData, {\n position1: bondData.position1,\n position2: bondData.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(lineData, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n data.bufferList[ 0 ].setAttributes(lineData)\n } else {\n var cylinderData: Partial = {}\n\n if (!what || what.position) {\n Object.assign(cylinderData, {\n position1: bondData.position1,\n position2: bondData.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(cylinderData, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n if (!what || what.radius) {\n Object.assign(cylinderData, {\n radius: bondData.radius\n })\n }\n\n data.bufferList[ 0 ].setAttributes(cylinderData)\n\n if (!this.cylinderOnly) {\n var atomData = this.getAtomData(data.sview as StructureView, what)\n\n var sphereData: Partial = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {\n position: atomData.position\n })\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {\n color: atomData.color\n })\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {\n radius: atomData.radius\n })\n }\n\n data.bufferList[ 1 ].setAttributes(sphereData)\n }\n }\n }\n\n setParameters (params: Partial = {}) {\n let rebuild = false\n const what: AtomDataFields = {}\n\n if (params.aspectRatio || params.bondSpacing || params.bondScale) {\n Object.assign(what, {radius: true})\n if (!ExtensionFragDepth || this.disableImpostor) {\n rebuild = true\n }\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('ball+stick', BallAndStickRepresentation)\n\nexport default BallAndStickRepresentation\n","/**\n * @file Backbone Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport BallAndStickRepresentation, { BallAndStickRepresentationParameters } from './ballandstick-representation'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport StructureView from '../structure/structure-view';\nimport { AtomDataFields, AtomDataParams, BondDataFields, BondDataParams, BondData, AtomData } from '../structure/structure-data';\n\n/**\n * Backbone representation. Show cylinders (or lines) connecting .CA (protein)\n * or .C4'/.C3' (RNA/DNA) of polymers.\n *\n * __Name:__ _backbone_\n *\n * @example\n * stage.loadFile( \"rcsb://1sfi\" ).then( function( o ){\n * o.addRepresentation( \"backbone\" );\n * o.autoView();\n * } );\n */\nclass BackboneRepresentation extends BallAndStickRepresentation {\n /**\n * @param {Structure} structure - the structure object\n * @param {Viewer} viewer - the viewer object\n * @param {BallAndStickRepresentationParameters} params - parameters object\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'backbone'\n\n this.parameters = Object.assign({\n\n }, this.parameters, {\n\n multipleBond: null,\n bondSpacing: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.aspectRatio = defaults(p.aspectRatio, 1.0)\n p.radiusSize = defaults(p.radiusSize, 0.25)\n\n super.init(p)\n }\n\n getAtomRadius (atom: AtomProxy) {\n return atom.isTrace() ? super.getAtomRadius(atom) : 0\n }\n\n getAtomData (sview: StructureView, what?: AtomDataFields, params?: Partial): AtomData {\n return sview.getBackboneAtomData(this.getAtomParams(what, params))\n }\n\n getBondData (sview: StructureView, what?: BondDataFields, params?: Partial): BondData {\n return sview.getBackboneBondData(this.getBondParams(what, params))\n }\n}\n\nRepresentationRegistry.add('backbone', BackboneRepresentation)\n\nexport default BackboneRepresentation\n","/**\n * @file Base Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport BallAndStickRepresentation, { BallAndStickRepresentationParameters } from './ballandstick-representation'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { AtomDataFields, AtomDataParams, BondDataFields, BondDataParams, BondData, AtomData } from '../structure/structure-data';\n\n/**\n * Base representation. Show cylinders for RNA/DNA ladders.\n *\n * __Name:__ _base_\n *\n * @example\n * stage.loadFile( \"rcsb://1d66\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\", { sele: \"nucleic\" } );\n * o.addRepresentation( \"base\", { color: \"resname\" } );\n * o.autoView( \"nucleic\" );\n * } );\n */\nclass BaseRepresentation extends BallAndStickRepresentation {\n /**\n * @param {Structure} structure - the structure object\n * @param {Viewer} viewer - the viewer object\n * @param {BallAndStickRepresentationParameters} params - parameters object\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'base'\n\n this.parameters = Object.assign({\n\n }, this.parameters, {\n\n multipleBond: null,\n bondSpacing: null\n\n })\n }\n\n init (params: Partial) {\n let p = params || {}\n p.aspectRatio = defaults(p.aspectRatio, 1.0)\n p.radiusSize = defaults(p.radiusSize, 0.3)\n\n super.init(p)\n }\n\n getAtomData (sview: StructureView, what?: AtomDataFields, params?: AtomDataParams): AtomData {\n return sview.getRungAtomData(this.getAtomParams(what, params))\n }\n\n getBondData (sview: StructureView, what?: BondDataFields, params?: BondDataParams): BondData {\n let p = this.getBondParams(what, params)\n Object.assign(p.colorParams, {rung: true})\n\n return sview.getRungBondData(p)\n }\n}\n\nRepresentationRegistry.add('base', BaseRepresentation)\n\nexport default BaseRepresentation\n","/**\n * @file Spline\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport { AtomPicker } from '../utils/picker'\nimport RadiusFactory, { RadiusParams } from '../utils/radius-factory'\nimport { copyArray } from '../math/array-utils'\nimport { spline } from '../math/math-utils'\nimport Polymer from '../proxy/polymer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport { ColormakerParameters } from '../color/colormaker';\nimport { NumberArray } from '../types';\n\nexport class Interpolator {\n \n m: number\n tension: number\n dt: number\n delta: number\n vec1: Vector3\n vec2: Vector3\n vDir: Vector3 \n vTan: Vector3\n vNorm: Vector3\n vBin: Vector3\n m2: number\n\n constructor (m: number, tension: number) {\n this.m = m\n this.tension = tension\n this.dt = 1.0 / this.m\n this.delta = 0.0001\n\n this.vec1 = new Vector3()\n this.vec2 = new Vector3()\n\n this.vDir = new Vector3()\n this.vTan = new Vector3()\n this.vNorm = new Vector3()\n this.vBin = new Vector3()\n \n this.m2 = Math.ceil(this.m / 2)\n }\n\n private interpolateToArr (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, t: number, arr: Float32Array, offset: number) {\n arr[ offset + 0 ] = spline(v0.x, v1.x, v2.x, v3.x, t, this.tension)\n arr[ offset + 1 ] = spline(v0.y, v1.y, v2.y, v3.y, t, this.tension)\n arr[ offset + 2 ] = spline(v0.z, v1.z, v2.z, v3.z, t, this.tension)\n }\n\n private interpolateToVec (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, t: number, vec: Vector3) {\n vec.x = spline(v0.x, v1.x, v2.x, v3.x, t, this.tension)\n vec.y = spline(v0.y, v1.y, v2.y, v3.y, t, this.tension)\n vec.z = spline(v0.z, v1.z, v2.z, v3.z, t, this.tension)\n }\n\n private interpolatePosition (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, pos: Float32Array, offset: number) {\n for (var j = 0; j < this.m; ++j) {\n var l = offset + j * 3\n var d = this.dt * j\n this.interpolateToArr(v0, v1, v2, v3, d, pos, l)\n }\n }\n\n private interpolateTangent (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, tan: Float32Array, offset: number) {\n for (var j = 0; j < this.m; ++j) {\n var d = this.dt * j\n var d1 = d - this.delta\n var d2 = d + this.delta\n var l = offset + j * 3\n // capping as a precaution\n if (d1 < 0) d1 = 0\n if (d2 > 1) d2 = 1\n //\n this.interpolateToVec(v0, v1, v2, v3, d1, this.vec1)\n this.interpolateToVec(v0, v1, v2, v3, d2, this.vec2)\n //\n this.vec2.sub(this.vec1).normalize()\n this.vec2.toArray(tan as any, l)\n }\n }\n\n private vectorSubdivide (interpolationFn: (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, array: Float32Array, offset: number) => void,\n iterator: AtomIterator, array: Float32Array, offset: number, isCyclic: boolean) {\n let v0: Vector3\n let v1 = iterator.next()\n let v2 = iterator.next()\n let v3 = iterator.next()\n //\n const n = iterator.size\n const n1 = n - 1\n let k = offset || 0\n for (let i = 0; i < n1; ++i) {\n v0 = v1\n v1 = v2\n v2 = v3\n v3 = iterator.next()\n interpolationFn.apply(this, [v0, v1, v2, v3, array, k])\n k += 3 * this.m\n }\n if (isCyclic) {\n v0 = iterator.get(n - 2)\n v1 = iterator.get(n - 1)\n v2 = iterator.get(0)\n v3 = iterator.get(1)\n interpolationFn.apply(this, [v0, v1, v2, v3, array, k])\n k += 3 * this.m\n }\n }\n\n //\n\n public getPosition (iterator: AtomIterator, array: Float32Array, offset: number, isCyclic: boolean) {\n iterator.reset()\n this.vectorSubdivide(this.interpolatePosition, iterator, array, offset, isCyclic)\n var n1 = iterator.size - 1\n var k = n1 * this.m * 3\n if (isCyclic) k += this.m * 3\n var v = iterator.get(isCyclic ? 0 : n1)\n array[ k ] = v.x\n array[ k + 1 ] = v.y\n array[ k + 2 ] = v.z\n }\n\n public getTangent (iterator: AtomIterator, array: Float32Array, offset: number, isCyclic: boolean) {\n iterator.reset()\n this.vectorSubdivide(this.interpolateTangent, iterator, array, offset, isCyclic)\n const n1 = iterator.size - 1\n let k = n1 * this.m * 3\n if (isCyclic) k += this.m * 3\n copyArray(array, array, k - 3, k, 3)\n }\n\n private interpolateNormalDir (u0: Vector3, u1: Vector3, u2: Vector3, u3: Vector3,\n v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3,\n tan: Float32Array, norm: Float32Array, bin: Float32Array,\n offset: number, shift: boolean) {\n for (let j = 0; j < this.m; ++j) {\n let l = offset + j * 3\n if (shift) l += this.m2 * 3\n const d = this.dt * j\n this.interpolateToVec(u0, u1, u2, u3, d, this.vec1)\n this.interpolateToVec(v0, v1, v2, v3, d, this.vec2)\n this.vDir.subVectors(this.vec2, this.vec1).normalize()\n this.vTan.fromArray(tan as any, l)\n this.vBin.crossVectors(this.vDir, this.vTan).normalize()\n this.vBin.toArray(bin as any, l)\n this.vNorm.crossVectors(this.vTan, this.vBin).normalize()\n this.vNorm.toArray(norm as any, l)\n }\n }\n\n private interpolateNormal (vDir: Vector3, tan: Float32Array, norm: Float32Array, bin: Float32Array, offset: number) {\n for (var j = 0; j < this.m; ++j) {\n var l = offset + j * 3\n vDir.copy(this.vNorm)\n this.vTan.fromArray(tan as any, l)\n this.vBin.crossVectors(vDir, this.vTan).normalize()\n this.vBin.toArray(bin as any, l)\n this.vNorm.crossVectors(this.vTan, this.vBin).normalize()\n this.vNorm.toArray(norm as any, l)\n }\n }\n\n public getNormal (size: number, tan: Float32Array, norm: Float32Array, bin: Float32Array, offset: number, isCyclic: boolean) {\n this.vNorm.set(0, 0, 1)\n const n = size\n const n1 = n - 1\n let k = offset || 0\n for (var i = 0; i < n1; ++i) {\n this.interpolateNormal(this.vDir, tan, norm, bin, k)\n k += 3 * this.m\n }\n if (isCyclic) {\n this.interpolateNormal(this.vDir, tan, norm, bin, k)\n k += 3 * this.m\n }\n this.vBin.toArray(bin as any, k)\n this.vNorm.toArray(norm as any, k)\n }\n\n public getNormalDir (iterDir1: AtomIterator, iterDir2: AtomIterator, tan: Float32Array, norm: Float32Array, bin: Float32Array, offset: number, isCyclic: boolean, shift: boolean) {\n iterDir1.reset()\n iterDir2.reset()\n //\n const vSub1 = new Vector3()\n const vSub2 = new Vector3()\n const vSub3 = new Vector3()\n const vSub4 = new Vector3()\n //\n const d1v1 = new Vector3()\n const d1v2 = new Vector3().copy(iterDir1.next())\n const d1v3 = new Vector3().copy(iterDir1.next())\n const d1v4 = new Vector3().copy(iterDir1.next())\n const d2v1 = new Vector3()\n const d2v2 = new Vector3().copy(iterDir2.next())\n const d2v3 = new Vector3().copy(iterDir2.next())\n const d2v4 = new Vector3().copy(iterDir2.next())\n //\n this.vNorm.set(0, 0, 1)\n let n = iterDir1.size\n let n1 = n - 1\n let k = offset || 0\n for (var i = 0; i < n1; ++i) {\n d1v1.copy(d1v2)\n d1v2.copy(d1v3)\n d1v3.copy(d1v4)\n d1v4.copy(iterDir1.next())\n d2v1.copy(d2v2)\n d2v2.copy(d2v3)\n d2v3.copy(d2v4)\n d2v4.copy(iterDir2.next())\n //\n if (i === 0) {\n vSub1.subVectors(d2v1, d1v1)\n vSub2.subVectors(d2v2, d1v2)\n if (vSub1.dot(vSub2) < 0) {\n vSub2.multiplyScalar(-1)\n d2v2.addVectors(d1v2, vSub2)\n }\n vSub3.subVectors(d2v3, d1v3)\n if (vSub2.dot(vSub3) < 0) {\n vSub3.multiplyScalar(-1)\n d2v3.addVectors(d1v3, vSub3)\n }\n } else {\n vSub3.copy(vSub4)\n }\n vSub4.subVectors(d2v4, d1v4)\n if (vSub3.dot(vSub4) < 0) {\n vSub4.multiplyScalar(-1)\n d2v4.addVectors(d1v4, vSub4)\n }\n this.interpolateNormalDir(\n d1v1, d1v2, d1v3, d1v4,\n d2v1, d2v2, d2v3, d2v4,\n tan, norm, bin, k, shift\n )\n k += 3 * this.m\n }\n if (isCyclic) {\n d1v1.copy(iterDir1.get(n - 2))\n d1v2.copy(iterDir1.get(n - 1))\n d1v3.copy(iterDir1.get(0))\n d1v4.copy(iterDir1.get(1))\n d2v1.copy(iterDir2.get(n - 2))\n d2v2.copy(iterDir2.get(n - 1))\n d2v3.copy(iterDir2.get(0))\n d2v4.copy(iterDir2.get(1))\n //\n vSub3.copy(vSub4)\n vSub4.subVectors(d2v4, d1v4)\n if (vSub3.dot(vSub4) < 0) {\n vSub4.multiplyScalar(-1)\n d2v4.addVectors(d1v4, vSub4)\n }\n this.interpolateNormalDir(\n d1v1, d1v2, d1v3, d1v4,\n d2v1, d2v2, d2v3, d2v4,\n tan, norm, bin, k, shift\n )\n k += 3 * this.m\n }\n if (shift) {\n // FIXME shift requires data from one this.more preceeding residue\n this.vBin.fromArray(bin as any, this.m2 * 3)\n this.vNorm.fromArray(norm as any, this.m2 * 3)\n for (var j = 0; j < this.m2; ++j) {\n this.vBin.toArray(bin as any, j * 3)\n this.vNorm.toArray(norm as any, j * 3)\n }\n } else {\n this.vBin.toArray(bin as any, k)\n this.vNorm.toArray(norm as any, k)\n }\n }\n\n //\n\n private interpolateColor (item1: AtomProxy, item2: AtomProxy, colFn: (...arg: any[]) => void, col: any, offset: number) {\n var j, l\n for (j = 0; j < this.m2; ++j) {\n l = offset + j * 3\n colFn.apply(this, [item1, col, l]) // itemColorToArray\n }\n for (j = this.m2; j < this.m; ++j) {\n l = offset + j * 3\n colFn.apply(this, [item2, col, l]) // itemColorToArray\n }\n }\n\n public getColor (iterator: AtomIterator, colFn: (...arg: any[]) => void, col: any, offset: number, isCyclic: boolean) {\n iterator.reset()\n iterator.next() // first element not needed\n let i0: AtomProxy\n let i1 = iterator.next()\n //\n var n = iterator.size\n var n1 = n - 1\n var k = offset || 0\n for (var i = 0; i < n1; ++i) {\n i0 = i1\n i1 = iterator.next()\n this.interpolateColor(i0, i1, colFn, col, k)\n k += 3 * this.m\n }\n if (isCyclic) {\n i0 = iterator.get(n - 1)\n i1 = iterator.get(0)\n this.interpolateColor(i0, i1, colFn, col, k)\n k += 3 * this.m\n }\n //\n col[ k ] = col[ k - 3 ]\n col[ k + 1 ] = col[ k - 2 ]\n col[ k + 2 ] = col[ k - 1 ]\n }\n\n //\n\n private interpolatePicking (item1: AtomProxy, item2: AtomProxy, pickFn: (item: AtomProxy) => number, pick: Float32Array, offset: number) {\n var j\n for (j = 0; j < this.m2; ++j) {\n pick[ offset + j ] = pickFn.apply(this, [item1])\n }\n for (j = this.m2; j < this.m; ++j) {\n pick[ offset + j ] = pickFn.apply(this, [item2])\n }\n }\n\n public getPicking (iterator: AtomIterator, pickFn: (item: AtomProxy) => number, pick: Float32Array, offset: number, isCyclic: boolean) {\n iterator.reset()\n iterator.next() // first element not needed\n let i0: AtomProxy\n let i1 = iterator.next()\n //\n const n = iterator.size\n const n1 = n - 1\n let k = offset || 0\n for (var i = 0; i < n1; ++i) {\n i0 = i1\n i1 = iterator.next()\n this.interpolatePicking(i0, i1, pickFn, pick, k)\n k += this.m\n }\n if (isCyclic) {\n i0 = iterator.get(n - 1)\n i1 = iterator.get(0)\n this.interpolatePicking(i0, i1, pickFn, pick, k)\n k += this.m\n }\n //\n pick[ k ] = pick[ k - 1 ]\n }\n\n //\n\n private interpolateSize (item1: AtomProxy, item2: AtomProxy, sizeFn: (item: AtomProxy) => number, size: Float32Array, offset: number) {\n const s1: number = sizeFn.apply(this, [item1])\n const s2: number = sizeFn.apply(this, [item2])\n for (let j = 0; j < this.m; ++j) {\n // linear interpolation\n let t = j / this.m\n size[ offset + j ] = (1 - t) * s1 + t * s2\n }\n }\n\n public getSize (iterator: AtomIterator, sizeFn: (item: AtomProxy) => number, size: Float32Array, offset: number, isCyclic: boolean) {\n iterator.reset()\n iterator.next() // first element not needed\n let i0: AtomProxy\n let i1: AtomProxy = iterator.next()\n //\n const n = iterator.size\n const n1 = n - 1\n let k = offset || 0\n for (var i = 0; i < n1; ++i) {\n i0 = i1\n i1 = iterator.next()\n this.interpolateSize(i0, i1, sizeFn, size, k)\n k += this.m\n }\n if (isCyclic) {\n i0 = iterator.get(n - 1)\n i1 = iterator.get(0)\n this.interpolateSize(i0, i1, sizeFn, size, k)\n k += this.m\n }\n //\n size[ k ] = size[ k - 1 ]\n }\n}\n\nexport interface SplineParameters {\n directional?: boolean\n positionIterator?: boolean\n subdiv?: number\n smoothSheet?: boolean\n tension?: number\n}\nexport interface AtomIterator {\n size: number,\n next: () => AtomProxy | Vector3,\n get: (idx: number) => AtomProxy | Vector3,\n reset: () => void\n}\nclass Spline {\n\n polymer: Polymer\n size: number\n directional: boolean\n positionIterator: any\n subdiv: number\n smoothSheet: boolean\n tension: number\n interpolator: Interpolator\n\n constructor (polymer: Polymer, params?: SplineParameters) {\n this.polymer = polymer\n this.size = polymer.residueCount\n\n var p = params || {}\n this.directional = p.directional || false\n this.positionIterator = p.positionIterator || false\n this.subdiv = p.subdiv || 1\n this.smoothSheet = p.smoothSheet || false\n\n if (!p.tension) {\n this.tension = this.polymer.isNucleic() ? 0.5 : 0.9\n } else {\n this.tension = p.tension\n }\n\n this.interpolator = new Interpolator(this.subdiv, this.tension)\n }\n\n getAtomIterator (type: string, smooth?: boolean): AtomIterator {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n\n let i = 0\n let j = -1\n\n const cache = [\n structure.getAtomProxy(),\n structure.getAtomProxy(),\n structure.getAtomProxy(),\n structure.getAtomProxy()\n ]\n\n const cache2 = [\n new Vector3(),\n new Vector3(),\n new Vector3(),\n new Vector3()\n ]\n\n function next () {\n var atomProxy = get(j)\n j += 1\n return atomProxy\n }\n\n var apPrev = structure.getAtomProxy()\n var apNext = structure.getAtomProxy()\n\n function get (idx: number) {\n var atomProxy = cache[ i % 4 ]\n atomProxy.index = polymer.getAtomIndexByType(idx, type) as number\n if (smooth && idx > 0 && idx < n && atomProxy.sstruc === 'e') {\n var vec = cache2[ i % 4 ]\n apPrev.index = polymer.getAtomIndexByType(idx + 1, type) as number\n apNext.index = polymer.getAtomIndexByType(idx - 1, type) as number\n vec.addVectors(apPrev as any, apNext as any)\n .add(atomProxy as any).add(atomProxy as any)\n .multiplyScalar(0.25)\n i += 1\n return vec\n }\n i += 1\n return atomProxy\n }\n\n function reset () {\n i = 0\n j = -1\n }\n\n return {\n size: n,\n next: next,\n get: get,\n reset: reset\n }\n }\n\n getSubdividedColor (params: {scheme: string, [k: string]: any } & ColormakerParameters) {\n var m = this.subdiv\n var polymer = this.polymer\n var n = polymer.residueCount\n var n1 = n - 1\n var nCol = n1 * m * 3 + 3\n if (polymer.isCyclic) nCol += m * 3\n\n var col = new Float32Array(nCol)\n var iterator = this.getAtomIterator('trace')\n\n var p = params || {}\n p.structure = polymer.structure\n\n var colormaker = ColormakerRegistry.getScheme(p)\n\n function colFn (item: AtomProxy, array: NumberArray, offset: number) {\n colormaker.atomColorToArray(item, array, offset)\n }\n\n this.interpolator.getColor(\n iterator, colFn, col, 0, polymer.isCyclic\n )\n\n return {\n 'color': col\n }\n }\n \n getSubdividedPicking () {\n var m = this.subdiv\n var polymer = this.polymer\n var n = polymer.residueCount\n var n1 = n - 1\n var nCol = n1 * m + 1\n if (polymer.isCyclic) nCol += m\n\n var structure = polymer.structure\n var iterator = this.getAtomIterator('trace')\n var pick = new Float32Array(nCol)\n\n function pickFn (item: AtomProxy) {\n return item.index\n }\n\n this.interpolator.getPicking(\n iterator, pickFn, pick, 0, polymer.isCyclic\n )\n\n return {\n 'picking': new AtomPicker(pick, structure)\n }\n }\n\n getSubdividedPosition () {\n var pos = this.getPosition()\n\n return {\n 'position': pos\n }\n }\n \n getSubdividedOrientation () {\n const tan = this.getTangent()\n const normals = this.getNormals(tan)\n\n return {\n 'tangent': tan,\n 'normal': normals.normal,\n 'binormal': normals.binormal\n }\n }\n\n getSubdividedSize (params: RadiusParams) {\n var m = this.subdiv\n var polymer = this.polymer\n var n = polymer.residueCount\n var n1 = n - 1\n var nSize = n1 * m + 1\n if (polymer.isCyclic) nSize += m\n\n var size = new Float32Array(nSize)\n var iterator = this.getAtomIterator('trace')\n\n var radiusFactory = new RadiusFactory(params)\n\n function sizeFn (item: AtomProxy) {\n return radiusFactory.atomRadius(item)\n }\n\n this.interpolator.getSize(\n iterator, sizeFn, size, 0, polymer.isCyclic\n )\n\n return {\n 'size': size\n }\n }\n\n getPosition () {\n const m = this.subdiv\n const polymer = this.polymer\n const n = polymer.residueCount\n const n1 = n - 1\n let nPos = n1 * m * 3 + 3\n if (polymer.isCyclic) nPos += m * 3\n\n const pos = new Float32Array(nPos)\n const iterator = this.positionIterator || this.getAtomIterator('trace', this.smoothSheet)\n\n this.interpolator.getPosition(iterator, pos, 0, polymer.isCyclic)\n\n return pos\n }\n\n getTangent () {\n const m = this.subdiv\n const polymer = this.polymer\n const n = this.size\n const n1 = n - 1\n let nTan = n1 * m * 3 + 3\n if (polymer.isCyclic) nTan += m * 3\n\n const tan = new Float32Array(nTan)\n const iterator = this.positionIterator || this.getAtomIterator('trace', this.smoothSheet)\n\n this.interpolator.getTangent(iterator, tan, 0, polymer.isCyclic)\n\n return tan\n }\n\n getNormals (tan: Float32Array) {\n const m = this.subdiv\n const polymer = this.polymer\n const isProtein = polymer.isProtein()\n const n = this.size\n const n1 = n - 1\n let nNorm = n1 * m * 3 + 3\n if (polymer.isCyclic) nNorm += m * 3\n\n const norm = new Float32Array(nNorm)\n const bin = new Float32Array(nNorm)\n\n if (this.directional && !this.polymer.isCg()) {\n const iterDir1 = this.getAtomIterator('direction1')\n const iterDir2 = this.getAtomIterator('direction2')\n this.interpolator.getNormalDir(\n iterDir1, iterDir2, tan, norm, bin, 0, polymer.isCyclic, isProtein\n )\n } else {\n this.interpolator.getNormal(\n n, tan, norm, bin, 0, polymer.isCyclic\n )\n }\n\n return {\n 'normal': norm,\n 'binormal': bin\n }\n }\n\n}\n\nexport default Spline\n","/**\n * @file Tube Mesh Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Matrix4 required for declaration only\nimport { Vector3, Matrix4 } from 'three'\n\nimport { defaults, getUintArray } from '../utils'\nimport { serialArray } from '../math/array-utils'\nimport MeshBuffer from './mesh-buffer'\nimport { BufferDefaultParameters, BufferData, BufferParameters } from './buffer'\nimport {Log} from \"../globals\";\n\nconst vTangent = new Vector3()\nconst vMeshNormal = new Vector3()\n\nexport interface TubeMeshBufferData extends BufferData {\n binormal: Float32Array\n tangent: Float32Array\n size: Float32Array\n}\n\nexport const TubeMeshBufferDefaultParameters = Object.assign({\n radialSegments: 4,\n capped: false,\n aspectRatio: 1.0\n}, BufferDefaultParameters)\nexport type TubeMeshBufferParameters = BufferParameters & {\n radialSegments: number,\n capped: boolean,\n aspectRatio: number\n}\n\nfunction getData (data: TubeMeshBufferData, params: Partial = {}) {\n const radialSegments = defaults(params.radialSegments, 4)\n const capped = defaults(params.capped, false)\n\n const capVertices = capped ? radialSegments : 0\n const capTriangles = capped ? radialSegments - 2 : 0\n\n const n = data.position!.length / 3\n const n1 = n - 1\n const x = n * radialSegments * 3 + 2 * capVertices * 3\n const xi = n1 * 2 * radialSegments * 3 + 2 * capTriangles * 3\n\n return {\n position: new Float32Array(x),\n color: new Float32Array(x),\n index: getUintArray(xi, x / 3),\n normal: new Float32Array(x),\n picking: data.picking\n }\n}\n\n/**\n * Tube mesh buffer. Draws a tube.\n */\nclass TubeMeshBuffer extends MeshBuffer {\n get defaultParameters() { return TubeMeshBufferDefaultParameters }\n parameters: TubeMeshBufferParameters\n\n capVertices: number\n capTriangles: number\n size2: number\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.normal - normals\n * @param {Float32Array} data.binormal - binormals\n * @param {Float32Array} data.tangent - tangents\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.size - sizes\n * @param {Picker} data.picking - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: TubeMeshBufferData, params: Partial = {}) {\n super(getData(data, params), params)\n\n this.capVertices = this.parameters.capped ? this.parameters.radialSegments : 0\n this.capTriangles = this.parameters.capped ? this.parameters.radialSegments - 2 : 0\n\n this.size2 = data.position!.length / 3\n data.primitiveId = serialArray(this.size2)\n\n this.setAttributes(data)\n this.makeIndex()\n }\n\n setAttributes (data: Partial = {}) {\n const aspectRatio = this.parameters.aspectRatio\n\n const n = this.size2\n const n1 = n - 1\n const radialSegments = this.parameters.radialSegments\n\n const attributes = this.geometry.attributes as any\n\n let position, normal, binormal, tangent, color, size, primitiveId\n let meshPosition, meshColor, meshNormal, meshPrimitiveId\n\n if (data.position) {\n position = data.position\n normal = data.normal\n binormal = data.binormal\n tangent = data.tangent\n size = data.size\n\n meshPosition = attributes.position.array\n meshNormal = attributes.normal.array\n\n attributes.position.needsUpdate = true\n attributes.normal.needsUpdate = true\n }\n\n if (data.color) {\n color = data.color\n meshColor = attributes.color.array\n attributes.color.needsUpdate = true\n }\n\n if (data.primitiveId) {\n primitiveId = data.primitiveId\n meshPrimitiveId = attributes.primitiveId.array\n attributes.primitiveId.needsUpdate = true\n }\n\n let k, l\n let radius = 0\n\n let normX = 0\n let normY = 0\n let normZ = 0\n let biX = 0\n let biY = 0\n let biZ = 0\n let posX = 0\n let posY = 0\n let posZ = 0\n\n const cxArr = []\n const cyArr = []\n const cx1Arr = []\n const cy1Arr = []\n const cx2Arr = []\n const cy2Arr = []\n\n if (position) {\n for (let j = 0; j < radialSegments; ++j) {\n const v = (j / radialSegments) * 2 * Math.PI\n\n cxArr[ j ] = aspectRatio * Math.cos(v)\n cyArr[ j ] = Math.sin(v)\n\n cx1Arr[ j ] = aspectRatio * Math.cos(v - 0.01)\n cy1Arr[ j ] = Math.sin(v - 0.01)\n cx2Arr[ j ] = aspectRatio * Math.cos(v + 0.01)\n cy2Arr[ j ] = Math.sin(v + 0.01)\n }\n }\n\n for (let i = 0; i < n; ++i) {\n k = i * 3\n l = k * radialSegments\n\n if (position && tangent && normal && binormal && size) {\n vTangent.set(\n tangent[ k ], tangent[ k + 1 ], tangent[ k + 2 ]\n )\n\n normX = normal[ k ]\n normY = normal[ k + 1 ]\n normZ = normal[ k + 2 ]\n\n biX = binormal[ k ]\n biY = binormal[ k + 1 ]\n biZ = binormal[ k + 2 ]\n\n posX = position[ k ]\n posY = position[ k + 1 ]\n posZ = position[ k + 2 ]\n\n radius = size[ i ]\n }\n\n for (let j = 0; j < radialSegments; ++j) {\n const s = l + j * 3\n\n if (position) {\n const cx = -radius * cxArr[ j ] // TODO: Hack: Negating it so it faces outside.\n const cy = radius * cyArr[ j ]\n\n const cx1 = -radius * cx1Arr[ j ]\n const cy1 = radius * cy1Arr[ j ]\n const cx2 = -radius * cx2Arr[ j ]\n const cy2 = radius * cy2Arr[ j ]\n\n meshPosition[ s ] = posX + cx * normX + cy * biX\n meshPosition[ s + 1 ] = posY + cx * normY + cy * biY\n meshPosition[ s + 2 ] = posZ + cx * normZ + cy * biZ\n\n // TODO half of these are symmetric\n vMeshNormal.set(\n // ellipse tangent approximated as vector from/to adjacent points\n (cx2 * normX + cy2 * biX) - (cx1 * normX + cy1 * biX),\n (cx2 * normY + cy2 * biY) - (cx1 * normY + cy1 * biY),\n (cx2 * normZ + cy2 * biZ) - (cx1 * normZ + cy1 * biZ)\n ).cross(vTangent)\n\n meshNormal[ s ] = vMeshNormal.x\n meshNormal[ s + 1 ] = vMeshNormal.y\n meshNormal[ s + 2 ] = vMeshNormal.z\n }\n\n if (color) {\n meshColor[ s ] = color[ k ]\n meshColor[ s + 1 ] = color[ k + 1 ]\n meshColor[ s + 2 ] = color[ k + 2 ]\n }\n\n if (primitiveId) {\n meshPrimitiveId[ i * radialSegments + j ] = primitiveId[ i ]\n }\n }\n }\n\n // front cap\n\n k = 0\n l = n * 3 * radialSegments\n\n for (let j = 0; j < radialSegments; ++j) {\n const s = k + j * 3\n const t = l + j * 3\n\n if (position && tangent) {\n meshPosition[ t ] = meshPosition[ s ]\n meshPosition[ t + 1 ] = meshPosition[ s + 1 ]\n meshPosition[ t + 2 ] = meshPosition[ s + 2 ]\n\n meshNormal[ t ] = tangent[ k ]\n meshNormal[ t + 1 ] = tangent[ k + 1 ]\n meshNormal[ t + 2 ] = tangent[ k + 2 ]\n }\n\n if (color) {\n meshColor[ t ] = meshColor[ s ]\n meshColor[ t + 1 ] = meshColor[ s + 1 ]\n meshColor[ t + 2 ] = meshColor[ s + 2 ]\n }\n\n if (primitiveId) {\n meshPrimitiveId[ n * radialSegments + j ] = meshPrimitiveId[ 0 + j ]\n }\n }\n\n // back cap\n\n k = (n - 1) * 3 * radialSegments\n l = (n + 1) * 3 * radialSegments\n\n for (let j = 0; j < radialSegments; ++j) {\n const s = k + j * 3\n const t = l + j * 3\n\n if (position && tangent) {\n meshPosition[ t ] = meshPosition[ s ]\n meshPosition[ t + 1 ] = meshPosition[ s + 1 ]\n meshPosition[ t + 2 ] = meshPosition[ s + 2 ]\n\n meshNormal[ t ] = tangent[ n1 * 3 ]\n meshNormal[ t + 1 ] = tangent[ n1 * 3 + 1 ]\n meshNormal[ t + 2 ] = tangent[ n1 * 3 + 2 ]\n }\n\n if (color) {\n meshColor[ t ] = meshColor[ s ]\n meshColor[ t + 1 ] = meshColor[ s + 1 ]\n meshColor[ t + 2 ] = meshColor[ s + 2 ]\n }\n\n if (primitiveId) {\n meshPrimitiveId[ (n + 1) * radialSegments + j ] = meshPrimitiveId[ (n - 1) * radialSegments + j ]\n }\n }\n }\n\n makeIndex () {\n const index = this.geometry.getIndex()\n if (!index) { Log.error('Index is null'); return; }\n const meshIndex = index.array as Uint32Array|Uint16Array\n\n const n = this.size2\n const n1 = n - 1\n const capTriangles = this.capTriangles\n const radialSegments = this.parameters.radialSegments\n const radialSegments1 = this.parameters.radialSegments + 1\n\n let k, l\n\n for (let i = 0; i < n1; ++i) {\n const k = i * radialSegments * 3 * 2\n\n const irs = i * radialSegments\n const irs1 = (i + 1) * radialSegments\n\n for (let j = 0; j < radialSegments; ++j) {\n l = k + j * 3 * 2\n\n // meshIndex[ l + 0 ] = irs + ( ( j + 0 ) % radialSegments );\n meshIndex[ l ] = irs + j\n meshIndex[ l + 1 ] = irs + ((j + 1) % radialSegments)\n // meshIndex[ l + 2 ] = irs1 + ( ( j + 0 ) % radialSegments );\n meshIndex[ l + 2 ] = irs1 + j\n\n // meshIndex[ l + 3 ] = irs1 + ( ( j + 0 ) % radialSegments );\n meshIndex[ l + 3 ] = irs1 + j\n meshIndex[ l + 4 ] = irs + ((j + 1) % radialSegments)\n meshIndex[ l + 5 ] = irs1 + ((j + 1) % radialSegments)\n }\n }\n\n // capping\n\n const strip = [ 0 ]\n\n for (let j = 1; j < radialSegments1 / 2; ++j) {\n strip.push(j)\n if (radialSegments - j !== j) {\n strip.push(radialSegments - j)\n }\n }\n\n // front cap\n\n l = n1 * radialSegments * 3 * 2\n k = n * radialSegments\n\n for (let j = 0; j < strip.length - 2; ++j) {\n if (j % 2 === 0) {\n meshIndex[ l + j * 3 + 0 ] = k + strip[ j + 0 ]\n meshIndex[ l + j * 3 + 1 ] = k + strip[ j + 1 ]\n meshIndex[ l + j * 3 + 2 ] = k + strip[ j + 2 ]\n } else {\n meshIndex[ l + j * 3 + 0 ] = k + strip[ j + 2 ]\n meshIndex[ l + j * 3 + 1 ] = k + strip[ j + 1 ]\n meshIndex[ l + j * 3 + 2 ] = k + strip[ j + 0 ]\n }\n }\n\n // back cap\n\n l = n1 * radialSegments * 3 * 2 + 3 * capTriangles\n k = n * radialSegments + radialSegments\n\n for (let j = 0; j < strip.length - 2; ++j) {\n if (j % 2 === 0) {\n meshIndex[ l + j * 3 + 0 ] = k + strip[ j + 0 ]\n meshIndex[ l + j * 3 + 1 ] = k + strip[ j + 1 ]\n meshIndex[ l + j * 3 + 2 ] = k + strip[ j + 2 ]\n } else {\n meshIndex[ l + j * 3 + 0 ] = k + strip[ j + 2 ]\n meshIndex[ l + j * 3 + 1 ] = k + strip[ j + 1 ]\n meshIndex[ l + j * 3 + 2 ] = k + strip[ j + 0 ]\n }\n }\n }\n}\n\nexport default TubeMeshBuffer\n","/**\n * @file Cartoon Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { Debug, Log, RepresentationRegistry } from '../globals'\nimport Spline from '../geometry/spline'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport TubeMeshBuffer from '../buffer/tubemesh-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport Polymer from '../proxy/polymer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport StructureView from '../structure/structure-view';\nimport Buffer from '../buffer/buffer';\n\nexport interface CartoonRepresentationParameters extends StructureRepresentationParameters {\n aspectRatio: number\n subdiv: number\n radialSegments: number\n tension: number\n capped: boolean\n smoothSheet: boolean\n}\n\n/**\n * Cartoon representation. Show a thick ribbon that\n * smoothly connecting backbone atoms in polymers.\n *\n * __Name:__ _cartoon_\n *\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\" );\n * o.autoView();\n * } );\n */\nclass CartoonRepresentation extends StructureRepresentation {\n protected aspectRatio: number\n protected tension: number\n protected capped: boolean\n protected smoothSheet: boolean\n protected subdiv: number\n \n /**\n * Create Cartoon representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {StructureRepresentationParameters} params - representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'cartoon'\n\n this.parameters = Object.assign({\n\n aspectRatio: {\n type: 'number', precision: 1, max: 10.0, min: 1.0, rebuild: true\n },\n subdiv: {\n type: 'integer', max: 50, min: 1, rebuild: true\n },\n radialSegments: {\n type: 'integer', max: 50, min: 1, rebuild: true\n },\n tension: {\n type: 'number', precision: 1, max: 1.0, min: 0.1\n },\n capped: {\n type: 'boolean', rebuild: true\n },\n smoothSheet: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'chainname')\n p.colorScale = defaults(p.colorScale, 'RdYlBu')\n p.radiusType = defaults(p.radiusType, 'sstruc')\n p.radiusScale = defaults(p.radiusScale, 0.7)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.aspectRatio = defaults(p.aspectRatio, 5.0)\n this.tension = defaults(p.tension, NaN)\n this.capped = defaults(p.capped, true)\n this.smoothSheet = defaults(p.smoothSheet, false)\n\n if (p.quality === 'low') {\n this.subdiv = 3\n this.radialSegments = 6\n } else if (p.quality === 'medium') {\n this.subdiv = 6\n } else if (p.quality === 'high') {\n this.subdiv = 12\n } else {\n this.subdiv = defaults(p.subdiv, 6)\n }\n\n super.init(p)\n }\n\n getSplineParams (params?: Partial) {\n return Object.assign({\n subdiv: this.subdiv,\n tension: this.tension,\n directional: this.aspectRatio !== 1.0,\n smoothSheet: this.smoothSheet\n }, params)\n }\n\n getSpline (polymer: Polymer): Spline {\n return new Spline(polymer, this.getSplineParams())\n }\n\n getAspectRatio (polymer: Polymer): number {\n return polymer.isCg() ? 1.0 : this.aspectRatio\n }\n\n getAtomRadius (atom: AtomProxy): number {\n return atom.isTrace() ? super.getAtomRadius(atom) : 0\n }\n\n createData (sview: StructureView) {\n let bufferList: Buffer[] = []\n let polymerList: Polymer[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4) return\n polymerList.push(polymer)\n\n const spline = this.getSpline(polymer)\n const aspectRatio = this.getAspectRatio(polymer)\n\n const subPos = spline.getSubdividedPosition()\n const subOri = spline.getSubdividedOrientation()\n const subCol = spline.getSubdividedColor(this.getColorParams())\n const subPick = spline.getSubdividedPicking()\n const subSize = spline.getSubdividedSize(this.getRadiusParams())\n\n bufferList.push(\n new TubeMeshBuffer(\n Object.assign({}, subPos, subOri, subCol, subPick, subSize),\n this.getBufferParams({\n radialSegments: this.radialSegments,\n aspectRatio: aspectRatio,\n capped: this.capped\n })\n )\n )\n }, sview.getSelection())\n\n return {\n bufferList: bufferList,\n polymerList: polymerList\n }\n }\n\n updateData (what: any, data: StructureRepresentationData) {\n if (Debug) Log.time(this.type + ' repr update')\n\n what = what || {}\n\n for (var i = 0, il = data.polymerList!.length; i < il; ++i) {\n var bufferData: {[key: string]: any} = {}\n var polymer = data.polymerList![ i ]\n var spline = this.getSpline(polymer)\n var aspectRatio = this.getAspectRatio(polymer)\n\n Object.assign(data.bufferList[ i ], {aspectRatio: aspectRatio})\n\n if (what.position || what.radius) {\n var subPos = spline.getSubdividedPosition()\n var subOri = spline.getSubdividedOrientation()\n var subSize = spline.getSubdividedSize(this.getRadiusParams(aspectRatio))\n\n bufferData.position = subPos.position\n bufferData.normal = subOri.normal\n bufferData.binormal = subOri.binormal\n bufferData.tangent = subOri.tangent\n bufferData.size = subSize.size\n }\n\n if (what.color) {\n var subCol = spline.getSubdividedColor(this.getColorParams())\n bufferData.color = subCol.color\n }\n\n if (what.picking) {\n var subPick = spline.getSubdividedPicking()\n bufferData.picking = subPick.picking\n }\n\n data.bufferList[ i ].setAttributes(bufferData)\n }\n\n if (Debug) Log.timeEnd(this.type + ' repr update')\n }\n\n setParameters (params: Partial) {\n const rebuild = false\n var what: {[k: string]: any} = {}\n\n if (params && params.aspectRatio) {\n what.radius = true\n }\n\n if (params && params.tension) {\n what.position = true\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('cartoon', CartoonRepresentation)\n\nexport default CartoonRepresentation\n","/**\n * @file Contact Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { RepresentationRegistry } from '../globals'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport { calculateContacts, getContactData, getLabelData } from '../chemistry/interactions/contact'\nimport CylinderBuffer from '../buffer/cylinder-buffer'\nimport TextBuffer from '../buffer/text-buffer'\nimport { getFixedCountDashData } from '../geometry/dash'\nimport Viewer from '../viewer/viewer';\nimport { Structure } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport CylinderImpostorBuffer from '../buffer/cylinderimpostor-buffer';\n// @ts-ignore: unused import ContactPicker required for declaration only\nimport { ContactPicker } from '../utils/picker';\n\nexport interface ContactRepresentationParameters extends StructureRepresentationParameters {\n hydrogenBond: boolean\n weakHydrogenBond: boolean\n waterHydrogenBond: boolean\n backboneHydrogenBond: boolean\n hydrophobic: boolean\n halogenBond: boolean\n ionicInteraction: boolean\n metalCoordination: boolean\n cationPi: boolean\n piStacking: boolean\n filterSele: string|[string, string]\n maxHydrophobicDist: number\n maxHbondDist: number\n maxHbondSulfurDist: number\n maxHbondAccAngle: number\n maxHbondDonAngle: number\n maxHbondAccPlaneAngle: number\n maxHbondDonPlaneAngle: number\n maxPiStackingDist: number\n maxPiStackingOffset: number\n maxPiStackingAngle: number\n maxCationPiDist: number\n maxCationPiOffset: number\n maxIonicDist: number\n maxHalogenBondDist: number\n maxHalogenBondAngle: number\n maxMetalDist: number\n refineSaltBridges: boolean\n masterModelIndex: number\n lineOfSightDistFactor: number\n}\n\n/**\n * Contact representation.\n */\nclass ContactRepresentation extends StructureRepresentation {\n protected hydrogenBond: boolean\n protected weakHydrogenBond: boolean\n protected waterHydrogenBond: boolean\n protected backboneHydrogenBond: boolean\n protected hydrophobic: boolean\n protected halogenBond: boolean\n protected ionicInteraction: boolean\n protected metalCoordination: boolean\n protected cationPi: boolean\n protected piStacking: boolean\n protected filterSele: string|[string, string]\n protected maxHydrophobicDist: number\n protected maxHbondDist: number\n protected maxHbondSulfurDist: number\n protected maxHbondAccAngle: number\n protected maxHbondDonAngle: number\n protected maxHbondAccPlaneAngle: number\n protected maxHbondDonPlaneAngle: number\n protected maxPiStackingDist: number\n protected maxPiStackingOffset: number\n protected maxPiStackingAngle: number\n protected maxCationPiDist: number\n protected maxCationPiOffset: number\n protected maxIonicDist: number\n protected maxHalogenBondDist: number\n protected maxHalogenBondAngle: number\n protected maxMetalDist: number\n protected refineSaltBridges: boolean\n protected masterModelIndex: number\n protected lineOfSightDistFactor: number\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'contact'\n\n this.parameters = Object.assign({\n hydrogenBond: {\n type: 'boolean', rebuild: true\n },\n weakHydrogenBond: {\n type: 'boolean', rebuild: true\n },\n waterHydrogenBond: {\n type: 'boolean', rebuild: true\n },\n backboneHydrogenBond: {\n type: 'boolean', rebuild: true\n },\n hydrophobic: {\n type: 'boolean', rebuild: true\n },\n halogenBond: {\n type: 'boolean', rebuild: true\n },\n ionicInteraction: {\n type: 'boolean', rebuild: true\n },\n metalCoordination: {\n type: 'boolean', rebuild: true\n },\n cationPi: {\n type: 'boolean', rebuild: true\n },\n piStacking: {\n type: 'boolean', rebuild: true\n },\n\n filterSele: {\n type: 'text', rebuild: true\n },\n\n labelVisible: {\n type: 'boolean', rebuild: true\n },\n\n labelFixedSize: {\n type: 'boolean', buffer: 'fixedSize'\n },\n\n labelSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001, rebuild: true\n },\n\n labelUnit: {\n type: 'select',\n rebuild: true,\n options: { '': '', angstrom: 'angstrom', nm: 'nm' }\n },\n\n maxHydrophobicDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHbondDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHbondSulfurDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHbondAccAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n maxHbondDonAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n maxHbondAccPlaneAngle: {\n type: 'integer', max: 90, min: 0, rebuild: true\n },\n maxHbondDonPlaneAngle: {\n type: 'integer', max: 90, min: 0, rebuild: true\n },\n maxPiStackingDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxPiStackingOffset: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxPiStackingAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n maxCationPiDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxCationPiOffset: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxIonicDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHalogenBondDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHalogenBondAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n maxMetalDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n refineSaltBridges: {\n type: 'boolean', rebuild: true\n },\n masterModelIndex: {\n type: 'integer', max: 1000, min: -1, rebuild: true\n },\n lineOfSightDistFactor: {\n type: 'number', precision: 1, max: 10, min: 0.0, rebuild: true\n },\n\n radialSegments: true,\n disableImpostor: true\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.radiusSize = defaults(p.radiusSize, 0.05)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.hydrogenBond = defaults(p.hydrogenBond, true)\n this.weakHydrogenBond = defaults(p.weakHydrogenBond, false)\n this.waterHydrogenBond = defaults(p.waterHydrogenBond, false)\n this.backboneHydrogenBond = defaults(p.backboneHydrogenBond, false)\n this.hydrophobic = defaults(p.hydrophobic, false)\n this.halogenBond = defaults(p.halogenBond, true)\n this.ionicInteraction = defaults(p.ionicInteraction, true)\n this.metalCoordination = defaults(p.metalCoordination, true)\n this.cationPi = defaults(p.cationPi, true)\n this.piStacking = defaults(p.piStacking, true)\n\n this.filterSele = defaults(p.filterSele, '')\n this.labelVisible = defaults(p.labelVisible, false)\n this.labelFixedSize = defaults(p.labelFixedSize, false)\n this.labelSize = defaults(p.labelSize, 2.0)\n this.labelUnit = defaults(p.labelUnit, '')\n\n this.maxHydrophobicDist = defaults(p.maxHydrophobicDist, 4.0)\n this.maxHbondDist = defaults(p.maxHbondDist, 3.5)\n this.maxHbondSulfurDist = defaults(p.maxHbondSulfurDist, 4.1)\n this.maxHbondAccAngle = defaults(p.maxHbondAccAngle, 45)\n this.maxHbondDonAngle = defaults(p.maxHbondDonAngle, 45)\n this.maxHbondAccPlaneAngle = defaults(p.maxHbondAccPlaneAngle, 90)\n this.maxHbondDonPlaneAngle = defaults(p.maxHbondDonPlaneAngle, 30)\n this.maxPiStackingDist = defaults(p.maxPiStackingDist, 5.5)\n this.maxPiStackingOffset = defaults(p.maxPiStackingOffset, 2.0)\n this.maxPiStackingAngle = defaults(p.maxPiStackingAngle, 30)\n this.maxCationPiDist = defaults(p.maxCationPiDist, 6.0)\n this.maxCationPiOffset = defaults(p.maxCationPiOffset, 2.0)\n this.maxIonicDist = defaults(p.maxIonicDist, 5.0)\n this.maxHalogenBondDist = defaults(p.maxHalogenBondDist, 3.5)\n this.maxHalogenBondAngle = defaults(p.maxHalogenBondAngle, 30)\n this.maxMetalDist = defaults(p.maxMetalDist, 3.0)\n this.refineSaltBridges = defaults(p.refineSaltBridges, true)\n this.masterModelIndex = defaults(p.masterModelIndex, -1)\n this.lineOfSightDistFactor = defaults(p.lineOfSightDistFactor, 1.0)\n\n super.init(p)\n }\n\n getAtomRadius () {\n return 0\n }\n\n getContactData (sview: StructureView) {\n const params = {\n maxHydrophobicDist: this.maxHydrophobicDist,\n maxHbondDist: this.maxHbondDist,\n maxHbondSulfurDist: this.maxHbondSulfurDist,\n maxHbondAccAngle: this.maxHbondAccAngle,\n maxHbondDonAngle: this.maxHbondDonAngle,\n maxHbondAccPlaneAngle: this.maxHbondAccPlaneAngle,\n maxHbondDonPlaneAngle: this.maxHbondDonPlaneAngle,\n maxPiStackingDist: this.maxPiStackingDist,\n maxPiStackingOffset: this.maxPiStackingOffset,\n maxPiStackingAngle: this.maxPiStackingAngle,\n maxCationPiDist: this.maxCationPiDist,\n maxCationPiOffset: this.maxCationPiOffset,\n maxIonicDist: this.maxIonicDist,\n maxHalogenBondDist: this.maxHalogenBondDist,\n maxHalogenBondAngle: this.maxHalogenBondAngle,\n maxMetalDist: this.maxMetalDist,\n refineSaltBridges: this.refineSaltBridges,\n masterModelIndex: this.masterModelIndex,\n lineOfSightDistFactor: this.lineOfSightDistFactor\n }\n\n const dataParams = {\n hydrogenBond: this.hydrogenBond,\n weakHydrogenBond: this.weakHydrogenBond,\n waterHydrogenBond: this.waterHydrogenBond,\n backboneHydrogenBond: this.backboneHydrogenBond,\n hydrophobic: this.hydrophobic,\n halogenBond: this.halogenBond,\n ionicInteraction: this.ionicInteraction,\n metalCoordination: this.metalCoordination,\n cationPi: this.cationPi,\n piStacking: this.piStacking,\n radius: this.radiusSize * this.radiusScale,\n filterSele: this.filterSele\n }\n\n const contacts = calculateContacts(sview, params)\n return getContactData(contacts, sview, dataParams)\n }\n\n createData (sview: StructureView) {\n const contactData = this.getContactData(sview)\n\n const bufferList = [\n new CylinderBuffer(\n getFixedCountDashData(contactData),\n this.getBufferParams({\n sphereDetail: 1,\n dullInterior: true,\n disableImpostor: this.disableImpostor\n })\n ) as (CylinderGeometryBuffer | CylinderImpostorBuffer | TextBuffer)\n ]\n\n if (this.labelVisible) {\n const labelParams = {\n size: this.labelSize,\n unit: this.labelUnit\n }\n bufferList.push(new TextBuffer(\n getLabelData(contactData, labelParams),\n this.getBufferParams({fixedSize: this.labelFixedSize})\n ))\n }\n\n return { bufferList }\n }\n}\n\nRepresentationRegistry.add('contact', ContactRepresentation)\n\nexport default ContactRepresentation\n","/**\n * @file Dihedral Representation\n * @author Fred Ludlow \n * @private\n */\nimport { Color } from 'three'\n\nimport { RepresentationRegistry } from '../globals'\nimport MeasurementRepresentation, { calcArcPoint, parseNestedAtoms, MeasurementRepresentationParameters, LabelDataField } from './measurement-representation'\nimport { defaults } from '../utils'\n\nimport MeshBuffer from '../buffer/mesh-buffer'\nimport TextBuffer, { TextBufferData } from '../buffer/text-buffer'\nimport WideLineBuffer from '../buffer/wideline-buffer'\n\nimport { copyArray, uniformArray, uniformArray3 } from '../math/array-utils'\nimport { v3add, v3angle, v3cross, v3dot, v3multiplyScalar, v3fromArray, v3length,\n v3negate, v3new, v3normalize, v3sub, v3toArray } from '../math/vector-utils'\nimport { RAD2DEG } from '../math/math-constants'\nimport { getFixedLengthWrappedDashData } from '../geometry/dash'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { CylinderBufferData } from '../buffer/cylinder-buffer';\nimport { BufferData } from '../buffer/buffer';\nimport { StructureRepresentationData } from './structure-representation';\n\n/**\n * @typedef {Object} DihedralRepresentationParameters - dihedral representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n * @mixes MeasurementRepresentationParameters\n *\n * @property {String} atomQuad - list of quadruplets of selection strings\n * or atom indices\n * @property {Boolean} extendLine - Extend lines in planes\n * @property {Number} lineOpacity - Opacity for the line part of the representation\n * @property {Boolean} lineVisible - Display the line part of the representation\n * @property {Number} linewidth - width for line part of representation\n * @property {Boolean} planeVisible - Display the two planes corresponding to dihedral\n * @property {Boolean} sectorVisible - Display the filled arc for each angle\n */\n\nexport interface DihedralRepresentationParameters extends MeasurementRepresentationParameters {\n atomQuad: (number|string)[][]\n extendLine: boolean\n lineOpacity: number\n lineVisible: boolean\n linewidth: number\n planeVisible: boolean\n sectorVisible: boolean\n}\n\n/**\n * Dihedral representation object\n *\n * Reperesentation consists of three parts, visibility can be set for each\n * label - text label indicating dihedral angle\n * line - line indicating four positions that define the dihedral\n * sector - filled arc section\n *\n * @param {Structure} structure - the structure to measure angles in\n * @param {Viewer} viewer - a viewer object\n * @param {AngleRepresentationParameters} params - angle representation parameters\n */\nclass DihedralRepresentation extends MeasurementRepresentation {\n protected atomQuad: (number|string)[][]\n protected extendLine: boolean\n protected lineOpacity: number\n protected lineVisible: boolean\n protected linewidth: number\n protected planeVisible: boolean\n protected sectorVisible: boolean\n\n protected lineLength: number\n protected planeLength: number\n protected sectorLength: number\n\n protected lineBuffer: WideLineBuffer\n protected planeBuffer: MeshBuffer\n protected sectorBuffer: MeshBuffer\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'dihedral'\n\n this.parameters = Object.assign({\n atomQuad: {\n type: 'hidden', rebuild: true\n },\n extendLine: {\n type: 'boolean', rebuild: true, default: true\n },\n lineVisible: {\n type: 'boolean', default: true\n },\n planeVisible: {\n type: 'boolean', default: true\n },\n sectorVisible: {\n type: 'boolean', default: true\n }\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.side = defaults(p.side, 'double')\n p.opacity = defaults(p.opacity, 0.5)\n\n this.atomQuad = defaults(p.atomQuad, [])\n this.extendLine = defaults(p.extendLine, true)\n this.lineVisible = defaults(p.lineVisible, true)\n this.planeVisible = defaults(p.planeVisible, true)\n this.sectorVisible = defaults(p.sectorVisible, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n if (!sview.atomCount || !this.atomQuad.length) return\n\n const atomPosition = parseNestedAtoms(sview, this.atomQuad)\n const dihedralData = getDihedralData(\n atomPosition, {\n extendLine: this.extendLine\n }\n )\n\n const n = this.n = dihedralData.labelText.length\n const labelColor = new Color(this.labelColor)\n\n this.textBuffer = new TextBuffer({\n position: dihedralData.labelPosition,\n size: uniformArray(n, this.labelSize),\n color: uniformArray3(n, labelColor.r, labelColor.g, labelColor.b),\n text: dihedralData.labelText\n } as TextBufferData, this.getLabelBufferParams())\n\n const c = new Color(this.colorValue)\n this.lineLength = dihedralData.linePosition1.length / 3\n const lineColor = uniformArray3(this.lineLength, c.r, c.g, c.b)\n\n this.lineBuffer = new WideLineBuffer(\n getFixedLengthWrappedDashData({\n position1: dihedralData.linePosition1,\n position2: dihedralData.linePosition2,\n color: lineColor,\n color2: lineColor\n } as CylinderBufferData) ,\n this.getBufferParams({\n linewidth: this.linewidth,\n visible: this.lineVisible,\n opacity: this.lineOpacity\n })\n )\n\n this.planeLength = dihedralData.planePosition.length / 3\n this.planeBuffer = new MeshBuffer({\n position: dihedralData.planePosition,\n color: uniformArray3(this.planeLength, c.r, c.g, c.b)\n } as BufferData, this.getBufferParams({\n visible: this.planeVisible\n }))\n\n this.sectorLength = dihedralData.sectorPosition.length / 3\n this.sectorBuffer = new MeshBuffer({\n position: dihedralData.sectorPosition,\n color: uniformArray3(this.sectorLength, c.r, c.g, c.b)\n } as BufferData, this.getBufferParams({\n visible: this.sectorVisible\n }))\n\n return {\n bufferList: [\n this.textBuffer,\n this.lineBuffer,\n this.planeBuffer,\n this.sectorBuffer\n ]\n }\n }\n\n updateData (what: LabelDataField & {color?: boolean}, data: StructureRepresentationData) {\n super.updateData(what, data)\n const lineData = {}\n const planeData = {}\n const sectorData = {}\n\n if (what.color) {\n const c = new Color(this.colorValue)\n Object.assign(lineData, {\n color: uniformArray3(this.lineLength, c.r, c.g, c.b),\n color2: uniformArray3(this.lineLength, c.r, c.g, c.b)\n })\n Object.assign(planeData, {\n color: uniformArray3(this.planeLength, c.r, c.g, c.b)\n })\n Object.assign(sectorData, {\n color: uniformArray3(this.sectorLength, c.r, c.g, c.b)\n })\n }\n\n this.lineBuffer.setAttributes(lineData)\n this.planeBuffer.setAttributes(planeData)\n this.sectorBuffer.setAttributes(sectorData)\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n super.setParameters(params, what, rebuild)\n\n if (params && (\n params.lineVisible !== undefined ||\n params.sectorVisible !== undefined ||\n params.planeVisible !== undefined)) {\n this.setVisibility(this.visible)\n }\n\n if (params && params.lineOpacity) {\n this.lineBuffer.setParameters({ opacity: params.lineOpacity })\n }\n\n if (params && params.opacity !== undefined) {\n this.lineBuffer.setParameters({ opacity: this.lineOpacity })\n }\n\n if (params && params.linewidth) {\n this.lineBuffer.setParameters({ linewidth: params.linewidth })\n }\n\n return this\n }\n\n setVisibility (value: boolean, noRenderRequest?: boolean) {\n super.setVisibility(value, true)\n\n if (this.lineBuffer) {\n this.lineBuffer.setVisibility(this.lineVisible && this.visible)\n }\n\n if (this.planeBuffer) {\n this.planeBuffer.setVisibility(this.planeVisible && this.visible)\n }\n\n if (this.sectorBuffer) {\n this.sectorBuffer.setVisibility(this.sectorVisible && this.visible)\n }\n\n if (!noRenderRequest) this.viewer.requestRender()\n\n return this\n }\n}\n\n/**\n * Build the data required to create {Buffer} objects, given positions\n * @param {Float32Array} atomPosition 3*4*nDihedral array of coordinates\n * @return {Object} Arrays for building buffers\n */\nfunction getDihedralData (position: Float32Array, params: Partial = {}) {\n const angleStep = defaults(params.angleStep, Math.PI / 90)\n const nPos = position.length\n const n = position.length / 12\n const angles = new Float32Array(n)\n const labelPosition = new Float32Array(n * 3)\n const labelText = new Array(n)\n\n // Temporary arrays as don't know output length yet\n const lineTmp1 = new Array(n)\n const lineTmp2 = new Array(n)\n const sectorTmp = new Array(n)\n const planeTmp = new Array(n)\n\n // Eventual sizes of output arrays\n let totalLines = 0\n let totalSegments = 0\n let totalPlanes = 0\n\n const p1 = v3new()\n const p2 = v3new()\n const p3 = v3new()\n const p4 = v3new()\n\n const v21 = v3new()\n const v23 = v3new()\n const v34 = v3new()\n\n const tmp = v3new()\n const mid = v3new()\n const inPlane1 = v3new()\n const inPlane2 = v3new()\n const start = v3new()\n const end = v3new()\n\n const cross = v3new()\n const arcPoint = v3new()\n\n let i = 0 // Actual output index (after skipping inappropriate)\n\n for (var p = 0; p < nPos; p += 12) {\n // Set Positions\n v3fromArray(p1, position, p)\n v3fromArray(p2, position, p + 3)\n v3fromArray(p3, position, p + 6)\n v3fromArray(p4, position, p + 9)\n\n // Vectors between points\n v3sub(v21, p1, p2)\n v3sub(v23, p3, p2)\n if (v3length(v23) === 0.0) {\n continue // Can't define axis\n }\n\n v3sub(v34, p4, p3)\n\n v3multiplyScalar(tmp, v23, 0.5)\n v3add(mid, p2, tmp)\n\n v3normalize(v21, v21)\n v3normalize(v23, v23)\n v3normalize(v34, v34)\n\n // Which side of plane are p1, p4 (are we measuring something that\n // looks more like an improper? e.g. C, CA, CB, N)\n v3sub(tmp, p1, mid)\n const improperStart = v3dot(tmp, v23) > 0.0\n v3sub(tmp, p4, mid)\n const improperEnd = v3dot(tmp, v23) < 0.0\n\n // Calculate vectors perp to v23 (lying in plane (1,2,3) and (2,3,4))\n v3multiplyScalar(tmp, v23, v3dot(v23, v21))\n v3sub(inPlane1, v21, tmp)\n\n v3multiplyScalar(tmp, v23, v3dot(v23, v34))\n v3sub(inPlane2, v34, tmp)\n\n if (v3length(inPlane1) === 0.0 || v3length(inPlane2) === 0.0) {\n continue // Indeterminate angle\n }\n\n v3normalize(inPlane1, inPlane1)\n v3normalize(inPlane2, inPlane2)\n\n const angle = angles[ i ] = v3angle(inPlane1, inPlane2)\n labelText[ i ] = (RAD2DEG * angle).toFixed(1) + String.fromCharCode(0x00B0)\n\n v3cross(cross, inPlane1, v23)\n v3normalize(cross, cross)\n if (v3dot(cross, inPlane2) < 0.0) {\n v3negate(cross, cross) // Ensure cp faces correct way\n }\n\n calcArcPoint(tmp, mid, inPlane1, cross, angle / 2.0)\n v3toArray(tmp, labelPosition, 3 * i)\n\n const nSegments = Math.ceil(angle / angleStep)\n // For extended display mode, 4 straight lines plus arc/segment edge\n // For non-extended, 2 straight lines plus segment edge\n const nLines = nSegments + ((params.extendLine) ? 4 : 2)\n\n // Don't draw planes if not extending lines\n const nPlanes = params.extendLine ? 36 : 0\n\n const line1 = new Float32Array(nLines * 3)\n const line2 = new Float32Array(nLines * 3)\n const sector = new Float32Array(nSegments * 9)\n // 2 planes, 2 triangles each per dihedral (2*2*9)\n const plane = new Float32Array(nPlanes)\n\n lineTmp1[ i ] = line1\n lineTmp2[ i ] = line2\n sectorTmp[ i ] = sector\n planeTmp[ i ] = plane\n\n // Start points for lines/planes, only required\n // if extending lines\n if (params.extendLine) {\n if (improperStart) { // We'll start on the v3->1 line (tmp)\n v3sub(tmp, p1, p3)\n v3normalize(tmp, tmp)\n v3multiplyScalar(start, tmp, 1.0 / v3dot(inPlane1, tmp))\n v3add(start, start, p3)\n } else { // start on the 2->1 line\n v3multiplyScalar(start, v21, 1.0 / v3dot(inPlane1, v21))\n v3add(start, start, p2)\n }\n\n if (improperEnd) { // Finish on 2->4 line\n v3sub(tmp, p4, p2)\n v3normalize(tmp, tmp)\n v3multiplyScalar(end, tmp, 1.0 / v3dot(inPlane2, tmp))\n v3add(end, end, p2)\n } else { // end on the 3->4 line\n v3multiplyScalar(end, v34, 1.0 / v3dot(inPlane2, v34))\n v3add(end, end, p3)\n }\n }\n\n v3add(arcPoint, mid, inPlane1)\n\n // index into line1, line2\n let li = 0\n // If extending lines, there's a bit of stuff to do here\n // figuring out start and end positions\n if (params.extendLine) {\n v3toArray(p1, line1, li)\n v3toArray(start, line2, li)\n li += 3\n v3toArray(start, line1, li)\n v3toArray(arcPoint, line2, li)\n li += 3\n\n // Construct plane at start, if not extening lines\n // this is skipped\n v3toArray(start, plane, 0)\n v3toArray(arcPoint, plane, 3)\n v3toArray(improperStart ? p3 : p2, plane, 6)\n v3toArray(improperStart ? p3 : p2, plane, 9)\n v3toArray(arcPoint, plane, 12)\n v3toArray(mid, plane, 15)\n } else {\n // Not extending lines\n v3toArray(mid, line1, li)\n v3toArray(arcPoint, line2, li)\n li += 3\n }\n\n const appendArcSection = function (a: number, j: number) {\n const si = j * 9\n\n v3toArray(mid, sector, si)\n v3toArray(arcPoint, sector, si + 3)\n v3toArray(arcPoint, line1, li)\n\n calcArcPoint(arcPoint, mid, inPlane1, cross, a)\n\n v3toArray(arcPoint, sector, si + 6)\n v3toArray(arcPoint, line2, li)\n li += 3\n }\n\n let j = 0\n for (let a = angleStep; a < angle; a += angleStep) {\n appendArcSection(a, j++)\n }\n appendArcSection(angle, j++)\n\n if (params.extendLine) {\n v3toArray(arcPoint, line1, (nLines - 2) * 3)\n v3toArray(end, line2, (nLines - 2) * 3)\n v3toArray(end, line1, (nLines - 1) * 3)\n v3toArray(p4, line2, (nLines - 1) * 3)\n\n // Construct plane at end\n v3toArray(end, plane, 18)\n v3toArray(arcPoint, plane, 21)\n v3toArray(improperEnd ? p2 : p3, plane, 24)\n v3toArray(improperEnd ? p2 : p3, plane, 27)\n v3toArray(arcPoint, plane, 30)\n v3toArray(mid, plane, 33)\n } else {\n v3toArray(arcPoint, line1, li)\n v3toArray(mid, line2, li)\n li += 3\n }\n\n totalLines += nLines * 3\n totalSegments += nSegments * 9\n totalPlanes += nPlanes\n i += 1\n }\n\n const nSuccess = i\n\n const linePosition1 = new Float32Array(totalLines)\n const linePosition2 = new Float32Array(totalLines)\n const sectorPosition = new Float32Array(totalSegments)\n const planePosition = new Float32Array(totalPlanes)\n\n let lineOffset = 0\n let sectorOffset = 0\n let planeOffset = 0\n\n for (let i = 0; i < nSuccess; i++) {\n const lp1 = lineTmp1[ i ]\n const lp2 = lineTmp2[ i ]\n const sp = sectorTmp[ i ]\n const pp = planeTmp[ i ]\n\n copyArray(lp1, linePosition1, 0, lineOffset, lp1.length)\n copyArray(lp2, linePosition2, 0, lineOffset, lp2.length)\n copyArray(sp, sectorPosition, 0, sectorOffset, sp.length)\n copyArray(pp, planePosition, 0, planeOffset, pp.length)\n\n lineOffset += lp1.length\n sectorOffset += sp.length\n planeOffset += pp.length\n }\n\n return {\n labelPosition: labelPosition.subarray(0, nSuccess * 3),\n labelText: labelText.slice(0, nSuccess),\n linePosition1,\n linePosition2,\n planePosition,\n sectorPosition\n }\n}\n\nRepresentationRegistry.add('dihedral', DihedralRepresentation)\n\nexport default DihedralRepresentation\n","/**\n * @file Dihedral Histogram Representation\n * @author Rudolfs Petrovs \n * @private\n */\nimport { Color } from 'three'\n\nimport { calcArcPoint, parseNestedAtoms } from './measurement-representation'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\n\nimport { RepresentationRegistry } from '../globals'\nimport { Structure } from '../ngl'\nimport { defaults } from '../utils'\n\nimport { BufferData } from '../buffer/buffer'\nimport MeshBuffer from '../buffer/mesh-buffer'\nimport WideLineBuffer, { WideLineBufferData } from '../buffer/wideline-buffer'\n\nimport { copyArray, uniformArray3, arraySum } from '../math/array-utils'\nimport {\n v3add, v3cross, v3dot, v3multiplyScalar, v3fromArray,\n v3negate, v3new, v3normalize, v3sub, v3toArray, v3length\n} from '../math/vector-utils'\n\nimport StructureView from '../structure/structure-view'\n\nimport Viewer from '../viewer/viewer'\n\n\nconst pointLength = 3 // One Point Length (number of coordinates of one point in 3D)\nconst pointsInTriangle = 3\n\ntype ColorDefinition = Color | string | number | undefined\n\ninterface HistogramColorParameters {\n histogramBinBorderColor: ColorDefinition\n adjacentBondArrowColor: ColorDefinition\n distantBondArrowColor: ColorDefinition\n frontHistogramColor: ColorDefinition\n backHistogramColor: ColorDefinition\n opaqueMiddleDiscColor: ColorDefinition\n}\n\ninterface HistogramInputData extends Partial {\n atomQuad: (number | string)[]\n histogram360: number[]\n}\n\ninterface HistogramData extends HistogramInputData {\n atomPositions: Float32Array\n histogram360Scaled: number[]\n}\n\ninterface WideLineData {\n startPoints: Float32Array\n endPoints: Float32Array\n startColors: Float32Array\n endColors: Float32Array\n}\n\ninterface MeshData {\n triangles: Float32Array\n triangleColors: Float32Array\n}\n\nfunction createUpdatedObject(o: Object, updateSource: Object) {\n function hasKey(obj: O, key: keyof any): key is keyof O {\n return key in obj\n }\n\n const result = { ...o } // Shallow copy\n for (const key in result) {\n if (hasKey(result, key) && hasKey(updateSource, key)) {\n result[key] = defaults(updateSource[key], result[key])\n }\n }\n return result\n}\n\nfunction createColorArray(color: ColorDefinition, arrayLength: number) {\n const colorValue = new Color(color)\n const targetArray = new Float32Array(arrayLength * 3)\n uniformArray3(arrayLength, colorValue.r, colorValue.g, colorValue.b, targetArray)\n return targetArray\n}\n\n/**\n * @typedef {Object} DihedralHistogramRepresentationParameters - dihedral representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n *\n * @property {HistogramInputData[]} histogramsData\n * List of HistogramInputData objects, which properties specifies each particular\n * histogram, and can contain particular histogram-specific parameters.\n * Obligatory properties are:\n * atomQuad - Quadruplet of selection strings or atom indices\n * histogram360 - List of values, representing histogram from 0 to 360 degrees.\n * @property {Boolean} histogramBinBorderVisible - Display the lines that separate circular histogram bins\n * @property {Boolean} scaleBinToSectorArea - Should sector-based histogram bins'\n * area be proportional to the bins' value\n */\n\nexport interface DihedralHistogramRepresentationParameters extends StructureRepresentationParameters {\n histogramsData: HistogramInputData[]\n\n histogramBinBorderVisible: boolean\n scaleBinToSectorArea: boolean\n}\n\n/**\n * Dihedral Histogram representation object\n *\n * Reperesentation consists of several parts:\n * opaqueMiddleDisc - opaque disc in the middle of the dihedral between front and back histograms\n * frontHistogram - circular histogram from the adjacent bond viewpoint\n * backHistogram - circular histogram from the distant bond viewpoint\n * histogramBinBorder - lines, which separate histogram bins\n * bondArrows - lines, which show the actual angle on the histogram disc\n *\n * @param {Structure} structure - the structure to measure angles in\n * @param {Viewer} viewer - a viewer object\n * @param {DihedralHistogramRepresentationParameters} params - Dihedral histogram representation parameters\n */\nclass DihedralHistogramRepresentation extends StructureRepresentation {\n protected histogramsData: HistogramData[]\n\n protected histogramBinBorderVisible: boolean\n protected histogramBinBorderWidth: number\n protected histogramBinBorderColor: ColorDefinition\n protected histogramBinBorderOpacity: number\n\n protected bondArrowVisible: boolean\n protected bondArrowWidth: number\n protected bondArrowOpacity: number\n\n protected adjacentBondArrowColor: ColorDefinition\n protected distantBondArrowColor: ColorDefinition\n\n protected histogramOpacity: number\n protected frontHistogramColor: ColorDefinition\n protected backHistogramColor: ColorDefinition\n\n protected opaqueMiddleDiscVisible: boolean\n protected opaqueMiddleDiscColor: ColorDefinition\n protected opaqueMiddleDiscOpacity: number\n\n protected scaleBinToSectorArea: boolean\n\n constructor(structure: Structure, viewer: Viewer, params: DihedralHistogramRepresentationParameters) {\n super(structure, viewer, params)\n\n this.type = 'dihedral-histogram'\n\n this.parameters = Object.assign({\n histogramsData: {\n type: 'hidden', rebuild: true\n },\n histogramBinBorderVisible: {\n type: 'boolean', default: true\n },\n scaleBinToSectorArea: {\n type: 'boolean',\n rebuild: true,\n default: false\n }\n }, this.parameters)\n\n this.init(params)\n }\n\n init(params: Partial) {\n const p = params || {}\n\n const defaultColorData = {\n histogramBinBorderColor: 'grey',\n adjacentBondArrowColor: 'black',\n distantBondArrowColor: 'magenta',\n frontHistogramColor: 'green',\n backHistogramColor: 'blue',\n opaqueMiddleDiscColor: 'white'\n }\n\n const colorData = createUpdatedObject(defaultColorData, p)\n Object.assign(this, colorData)\n\n const defaultParameters = {\n histogramsData: [],\n histogramOpacity: 1.0,\n\n opaqueMiddleDiscVisible: true,\n opaqueMiddleDiscOpacity: 1.0,\n\n histogramBinBorderVisible: true,\n histogramBinBorderWidth: 1,\n histogramBinBorderOpacity: 0.5,\n\n bondArrowVisible: true,\n bondArrowWidth: 2,\n bondArrowOpacity: 1.0,\n\n scaleBinToSectorArea: false,\n }\n const parameters = createUpdatedObject(defaultParameters, p)\n Object.assign(this, parameters)\n\n this.histogramsData.forEach(x => {\n const specificColorData = createUpdatedObject(colorData, x)\n Object.assign(x, specificColorData)\n })\n\n p.side = defaults(p.side, 'double')\n p.opacity = defaults(p.opacity, 0.5)\n p.radiusType = defaults(p.radiusType, 'size')\n p.radiusSize = defaults(p.radiusSize, 0.15)\n\n super.init(p)\n }\n\n getHistogramBinBorderBufferParameters() {\n return this.getBufferParams({\n linewidth: this.histogramBinBorderWidth,\n visible: this.histogramBinBorderVisible,\n opacity: this.histogramBinBorderOpacity,\n })\n }\n\n getBondArrowsBufferParameters() {\n return this.getBufferParams({\n linewidth: this.bondArrowWidth,\n visible: this.bondArrowVisible,\n opacity: this.bondArrowOpacity,\n })\n }\n\n getOpaqueMiddleDiscBufferParameters() {\n return this.getBufferParams({\n visible: this.opaqueMiddleDiscVisible,\n opacity: this.opaqueMiddleDiscOpacity\n })\n }\n\n getHistogramBufferParameters() {\n return this.getBufferParams({\n visible: true,\n opacity: this.histogramOpacity,\n side: \"double\"\n })\n }\n\n createData(sview: StructureView) {\n if (!sview.atomCount || !this.histogramsData.length) return\n this.histogramsData.forEach(x => x.atomPositions = parseNestedAtoms(sview, [x.atomQuad]))\n const scaleData = this.scaleBinToSectorArea ? function (y: number) { return Math.sqrt(y) } : function (y: number) { return y }\n this.histogramsData.forEach(x => x.histogram360Scaled = x.histogram360.map(scaleData))\n function Float32Concat(arrays: Float32Array[]) {\n const lengths = arrays.map(x => x.length)\n const result = new Float32Array(arraySum(lengths))\n let accumulatedOffset = 0\n for (let i = 0; i < arrays.length; i++) {\n result.set(arrays[i], accumulatedOffset)\n accumulatedOffset += arrays[i].length\n }\n return result\n }\n\n function createWideLineBuffer(linesList: WideLineData[], params: {}) {\n return new WideLineBuffer(\n {\n position1: Float32Concat(linesList.map(x => x.startPoints)),\n position2: Float32Concat(linesList.map(x => x.endPoints)),\n color: Float32Concat(linesList.map(x => x.startColors)),\n color2: Float32Concat(linesList.map(x => x.endColors)),\n } as WideLineBufferData,\n params)\n }\n\n function createMeshBuffer(mesh: MeshData[], params: {}) {\n return new MeshBuffer(\n {\n position: Float32Concat(mesh.map(x => x.triangles)),\n color: Float32Concat(mesh.map(x => x.triangleColors))\n } as BufferData,\n params)\n }\n\n const dihedralDataArray = []\n\n for (let i = 0; i < this.histogramsData.length; i++) {\n let dihedralData = undefined\n let currentHistogramData = this.histogramsData[i]\n let currentHistogram360 = currentHistogramData.histogram360\n if (currentHistogram360.length >= 3) {\n dihedralData = calculateDihedralHistogram(currentHistogramData)\n }\n if (typeof dihedralData === \"undefined\") continue\n dihedralDataArray.push(dihedralData)\n }\n\n this.frontHistogramBinBordersBuffer = createWideLineBuffer(\n dihedralDataArray.map(x => x.frontHistogramBinBorders),\n this.getHistogramBinBorderBufferParameters()\n )\n\n this.backHistogramBinBordersBuffer = createWideLineBuffer(\n dihedralDataArray.map(x => x.backHistogramBinBorders),\n this.getHistogramBinBorderBufferParameters()\n )\n\n this.adjacentBondArrowsBuffer = createWideLineBuffer(\n dihedralDataArray.map(x => x.adjacentBondArrows),\n this.getBondArrowsBufferParameters()\n )\n\n this.distantBondArrowsBuffer = createWideLineBuffer(\n dihedralDataArray.map(x => x.distantBondArrows),\n this.getBondArrowsBufferParameters()\n )\n\n this.opaqueMiddleDiscBuffer = createMeshBuffer(\n dihedralDataArray.map(x => x.opaqueMiddleDisc),\n this.getOpaqueMiddleDiscBufferParameters()\n )\n\n this.frontHistogramBuffer = createMeshBuffer(\n dihedralDataArray.map(x => x.frontHistogram),\n this.getHistogramBufferParameters()\n )\n\n this.backHistogramBuffer = createMeshBuffer(\n dihedralDataArray.map(x => x.backHistogram),\n this.getHistogramBufferParameters()\n )\n\n return {\n bufferList: [].concat(\n this.frontHistogramBinBordersBuffer,\n this.backHistogramBinBordersBuffer,\n this.adjacentBondArrowsBuffer,\n this.distantBondArrowsBuffer,\n this.opaqueMiddleDiscBuffer,\n this.frontHistogramBuffer,\n this.backHistogramBuffer\n )\n }\n }\n\n setParameters(params: Partial) {\n const rebuild = false\n const what = {}\n super.setParameters(params, what, rebuild)\n\n if (params && (params.histogramBinBorderVisible !== undefined)) {\n this.setVisibility(this.visible)\n }\n return this\n }\n\n setVisibility(value: boolean, noRenderRequest?: boolean) {\n super.setVisibility(value, true)\n if (this.frontHistogramBinBordersBuffer) {\n this.frontHistogramBinBordersBuffer.setVisibility(this.histogramBinBorderVisible)\n }\n if (this.backHistogramBinBordersBuffer) {\n this.backHistogramBinBordersBuffer.setVisibility(this.histogramBinBorderVisible)\n }\n if (!noRenderRequest) this.viewer.requestRender()\n return this\n }\n}\n\n/**\n * Calculates the data required to create {Buffer} objects for one histogram, given positions\n * @param Float32Array positionOfDihedralAtoms 3*4 array of coordinates\n * @param NumberArray histogram array of coordinates\n * @return Arrays for building buffers\n */\nfunction calculateDihedralHistogram(histogramData: HistogramData) {\n const positionOfDihedralAtoms = histogramData.atomPositions\n const histogram = histogramData.histogram360Scaled;\n const totalSectorTrianglesInOpaqueMiddleDisc = histogram.length <= 180 ? 360 : histogram.length * 2\n const frontAndBack = 2\n\n const opaqueMiddleDisc = {\n triangles: new Float32Array(totalSectorTrianglesInOpaqueMiddleDisc * pointsInTriangle * pointLength),\n triangleColors: createColorArray(histogramData.opaqueMiddleDiscColor, totalSectorTrianglesInOpaqueMiddleDisc * pointsInTriangle)\n }\n\n const frontHistogram = {\n triangles: new Float32Array(histogram.length * pointsInTriangle * pointLength),\n triangleColors: createColorArray(histogramData.frontHistogramColor, histogram.length * pointsInTriangle)\n }\n\n const backHistogram = {\n triangles: new Float32Array(histogram.length * pointsInTriangle * pointLength),\n triangleColors: createColorArray(histogramData.backHistogramColor, histogram.length * pointsInTriangle)\n }\n\n const frontHistogramBinBorders = {\n startPoints: new Float32Array(histogram.length * pointLength),\n endPoints: new Float32Array(histogram.length * pointLength),\n startColors: createColorArray(histogramData.histogramBinBorderColor, histogram.length),\n endColors: createColorArray(histogramData.histogramBinBorderColor, histogram.length)\n }\n\n const backHistogramBinBorders = {\n startPoints: new Float32Array(histogram.length * pointLength),\n endPoints: new Float32Array(histogram.length * pointLength),\n startColors: createColorArray(histogramData.histogramBinBorderColor, histogram.length),\n endColors: createColorArray(histogramData.histogramBinBorderColor, histogram.length)\n }\n\n const adjacentBondArrows = {\n startPoints: new Float32Array(frontAndBack * pointLength),\n endPoints: new Float32Array(frontAndBack * pointLength),\n startColors: createColorArray(histogramData.adjacentBondArrowColor, histogram.length),\n endColors: createColorArray(histogramData.adjacentBondArrowColor, histogram.length)\n }\n const distantBondArrows = {\n startPoints: new Float32Array(frontAndBack * pointLength),\n endPoints: new Float32Array(frontAndBack * pointLength),\n startColors: createColorArray(histogramData.distantBondArrowColor, histogram.length),\n endColors: createColorArray(histogramData.distantBondArrowColor, histogram.length)\n }\n\n const p1 = v3new()\n const p2 = v3new()\n const p3 = v3new()\n const p4 = v3new()\n\n const v21 = v3new()\n const v23 = v3new()\n const v32 = v3new()\n const v34 = v3new()\n\n const mid = v3new()\n const inPlane1 = v3new()\n const inPlane2 = v3new()\n\n const cross1 = v3new()\n const cross2 = v3new()\n\n const arcPoint = v3new()\n const tmp = v3new()\n const tmp2 = v3new()\n\n // Set Atom Coordinates\n const dihedralAtomVectors = [p1, p2, p3, p4]\n\n for (let i = 0; i < dihedralAtomVectors.length; i++) {\n v3fromArray(dihedralAtomVectors[i], positionOfDihedralAtoms, i * pointLength)\n }\n\n // Vectors between points\n v3sub(v21, p1, p2)\n v3sub(v23, p3, p2)\n v3sub(v34, p4, p3)\n if (v3length(v23) === 0.0) {\n return // Can't define axis\n }\n\n v3multiplyScalar(tmp, v23, 0.5)\n v3add(mid, p2, tmp)\n\n v3normalize(v21, v21)\n v3normalize(v23, v23)\n v3normalize(v34, v34)\n\n v3negate(v32, v23)\n // Calculate vectors perp to v23 (lying in plane (1,2,3) and (2,3,4))\n v3multiplyScalar(tmp, v32, v3dot(v32, v21))\n v3sub(inPlane1, v21, tmp)\n\n v3multiplyScalar(tmp, v23, v3dot(v23, v34))\n v3sub(inPlane2, v34, tmp)\n\n if (v3length(inPlane1) === 0.0 || v3length(inPlane2) === 0.0) {\n return // Indeterminate angle\n }\n\n v3normalize(inPlane1, inPlane1)\n v3normalize(inPlane2, inPlane2)\n\n // Can use acos as normalized and non-zero\n const absAngle = Math.acos(v3dot(inPlane1, inPlane2))\n\n v3cross(cross1, v32, inPlane1)\n v3cross(cross2, v23, inPlane2)\n v3normalize(cross1, cross1)\n v3normalize(cross2, cross2)\n\n let angle = absAngle\n if (v3dot(cross1, inPlane2) < 0.0) {\n angle = -absAngle\n }\n\n v3add(arcPoint, mid, inPlane1)\n\n // Calculate necessary constants\n const maxHist = Math.max.apply(null, histogram)\n const histBinAngleStep = (Math.PI * 2) / histogram.length\n\n function setHistogramBinCoordinates(out: Float32Array, ind: number, zeroDegreeVector: Float32Array, crossVector: Float32Array, histBinAngleStep: number) {\n const startOffset = ind * pointsInTriangle * pointLength\n v3toArray(mid, out, startOffset)\n const scalingFactor = Number(histogram[ind]) / maxHist\n v3multiplyScalar(tmp, zeroDegreeVector, scalingFactor)\n v3multiplyScalar(tmp2, crossVector, scalingFactor)\n calcArcPoint(arcPoint, mid, tmp, tmp2, ind * histBinAngleStep)\n v3toArray(arcPoint, out, startOffset + 1 * pointLength)\n calcArcPoint(arcPoint, mid, tmp, tmp2, (ind + 1) * histBinAngleStep)\n v3toArray(arcPoint, out, startOffset + 2 * pointLength)\n }\n\n function setOneSideHistogram(discHistogram: MeshData, binBorders: { startPoints: Float32Array, endPoints: Float32Array }, ind: number, zeroDegreeVector: Float32Array, crossVector: Float32Array) {\n // Set Bond Arrows\n\n copyArray(mid, adjacentBondArrows.startPoints, 0, ind * pointLength, mid.length)\n calcArcPoint(tmp, mid, zeroDegreeVector, crossVector, 0 + histBinAngleStep * 0)\n copyArray(tmp, adjacentBondArrows.endPoints, 0, ind * pointLength, mid.length)\n\n copyArray(mid, distantBondArrows.startPoints, 0, ind * pointLength, mid.length)\n calcArcPoint(tmp, mid, zeroDegreeVector, crossVector, angle)\n copyArray(tmp, distantBondArrows.endPoints, 0, ind * pointLength, mid.length)\n\n // Set Histogram Bin Borders\n\n for (let i = 0; i < histogram.length; i++) {\n copyArray(mid, binBorders.startPoints, 0, i * 3, mid.length)\n calcArcPoint(tmp, mid, zeroDegreeVector, crossVector, 0 + histBinAngleStep * i)\n copyArray(tmp, binBorders.endPoints, 0, i * 3, tmp.length)\n }\n\n // Set Histogram Bins\n\n for (let sectionIndex = 0; sectionIndex < histogram.length; sectionIndex++) {\n setHistogramBinCoordinates(discHistogram.triangles, sectionIndex, zeroDegreeVector, crossVector, histBinAngleStep)\n }\n }\n\n // Opaque disc\n const opaqueCircleSectorAngleStep = Math.PI * 2 / totalSectorTrianglesInOpaqueMiddleDisc\n\n for (let sectionIndex = 0; sectionIndex < totalSectorTrianglesInOpaqueMiddleDisc; sectionIndex++) {\n const startOffset = sectionIndex * pointsInTriangle * pointLength\n v3toArray(mid, opaqueMiddleDisc.triangles, startOffset)\n calcArcPoint(arcPoint, mid, inPlane1, cross1, sectionIndex * opaqueCircleSectorAngleStep)\n v3toArray(arcPoint, opaqueMiddleDisc.triangles, startOffset + 1 * pointLength)\n calcArcPoint(arcPoint, mid, inPlane1, cross1, (sectionIndex + 1) * opaqueCircleSectorAngleStep)\n v3toArray(arcPoint, opaqueMiddleDisc.triangles, startOffset + 2 * pointLength)\n }\n\n // Front Histogram\n const distanceToOpaqueDisc = 0.01\n v3multiplyScalar(tmp, v23, -distanceToOpaqueDisc) // Get a vector to move \"mid\" just a bit from opaque disc\n v3add(mid, mid, tmp)\n setOneSideHistogram(frontHistogram, frontHistogramBinBorders, 0, inPlane1, cross1)\n\n // Back Histogram\n v3multiplyScalar(tmp, v23, 2 * distanceToOpaqueDisc) // Get a vector to move \"mid\" back and plus just a bit from opaque disc the other way\n v3add(mid, mid, tmp)\n setOneSideHistogram(backHistogram, backHistogramBinBorders, 1, inPlane2, cross2)\n\n return {\n opaqueMiddleDisc,\n frontHistogram,\n backHistogram,\n frontHistogramBinBorders,\n backHistogramBinBorders,\n adjacentBondArrows,\n distantBondArrows\n }\n}\n\nRepresentationRegistry.add('dihedral-histogram', DihedralHistogramRepresentation)\n\nexport default DihedralHistogramRepresentation\n","/**\n * @file Distance Representation\n * @author Alexander Rose \n * @author Fred Ludlow \n * @private\n */\n\nimport { Color } from 'three'\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { DistancePicker } from '../utils/picker'\nimport { uniformArray, uniformArray3 } from '../math/array-utils'\nimport BitArray from '../utils/bitarray'\nimport MeasurementRepresentation, { MeasurementRepresentationParameters } from './measurement-representation'\nimport Selection from '../selection/selection'\nimport BondStore from '../store/bond-store'\nimport TextBuffer, { TextBufferData, TextBufferParameters } from '../buffer/text-buffer'\nimport WideLineBuffer from '../buffer/wideline-buffer'\nimport CylinderBuffer, { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport { getFixedLengthDashData } from '../geometry/dash'\nimport Viewer from '../viewer/viewer';\nimport { Structure } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport { BondDataFields, BondDataParams, BondData } from '../structure/structure-data';\nimport { StructureRepresentationData } from './structure-representation';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\n\n/**\n * Distance representation parameter object.\n * @typedef {Object} DistanceRepresentationParameters - distance representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n * @mixes MeasurementRepresentationParameters\n *\n * @property {String} labelUnit - distance unit (e.g. \"angstrom\" or \"nm\"). If set, a distance\n * symbol is appended to the label (i.e. 'nm' or '\\u00C5'). In case of 'nm', the\n * distance value is computed in nanometers instead of Angstroms.\n * @property {Array[]} atomPair - list of pairs of selection strings (see {@link Selection})\n * or pairs of atom indices. Using atom indices is much more\n * efficient when the representation is updated often, e.g. by\n * changing the selection or the atom positions, as there\n * are no selection strings to be evaluated.\n */\nexport interface DistanceRepresentationParameters extends MeasurementRepresentationParameters {\n labelUnit: string\n atomPair: AtomPair\n useCylinder: boolean\n}\nexport type AtomPair = (number|string)[][]\n/**\n * Distance representation\n */\nclass DistanceRepresentation extends MeasurementRepresentation {\n protected labelUnit: string\n protected atomPair: AtomPair\n protected useCylinder: boolean\n protected distanceBuffer: WideLineBuffer|CylinderGeometryBuffer\n /**\n * Create Distance representation object\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\" );\n * // either give selections (uses first selected atom) ...\n * var atomPair = [ [ \"1.CA\", \"4.CA\" ], [ \"7.CA\", \"13.CA\" ] ];\n * // or atom indices\n * var atomPair = [ [ 8, 28 ], [ 173, 121 ] ];\n * o.addRepresentation( \"distance\", { atomPair: atomPair } );\n * stage.autoView();\n * } );\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {DistanceRepresentationParameters} params - distance representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'distance'\n\n this.parameters = Object.assign({\n radialSegments: true,\n openEnded: true,\n disableImpostor: true,\n labelUnit: {\n type: 'select',\n rebuild: true,\n options: { '': '', angstrom: 'angstrom', nm: 'nm' }\n },\n useCylinder: {\n type: 'boolean', rebuild: true\n },\n atomPair: {\n type: 'hidden', rebuild: true\n }\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.linewidth = defaults(p.linewidth, 5.0)\n p.radiusType = defaults(p.radiusType, 'size')\n p.radiusSize = defaults(p.radiusSize, 0.2)\n\n this.labelUnit = defaults(p.labelUnit, '')\n this.useCylinder = defaults(p.useCylinder, false)\n this.atomPair = defaults(p.atomPair, [])\n\n super.init(p)\n }\n\n getDistanceData (sview: StructureView, atomPair: AtomPair) {\n let n = atomPair.length\n const text = new Array(n)\n let position = new Float32Array(n * 3)\n const sele1 = new Selection()\n const sele2 = new Selection()\n\n const bondStore = new BondStore()\n\n const ap1 = sview.getAtomProxy()\n const ap2 = sview.getAtomProxy()\n\n let j = 0 // Skipped pairs\n const selected = sview.getAtomSet()\n\n atomPair.forEach((pair, i) => {\n let v1 = pair[ 0 ]\n let v2 = pair[ 1 ]\n\n if (typeof(v1) === 'number' && Number.isInteger(v1) && typeof(v2) === 'number' && Number.isInteger(v2)) {\n if (selected.get(v1) && selected.get(v2)) {\n ap1.index = v1\n ap2.index = v2\n } else {\n j += 1\n return\n }\n } else {\n sele1.setString(v1 as string)\n sele2.setString(v2 as string)\n\n var atomIndices1 = sview.getAtomIndices(sele1)\n var atomIndices2 = sview.getAtomIndices(sele2)\n\n if (atomIndices1!.length && atomIndices2!.length) {\n ap1.index = atomIndices1![ 0 ]\n ap2.index = atomIndices2![ 0 ]\n } else {\n j += 1\n return\n }\n }\n\n bondStore.addBond(ap1, ap2, 1)\n\n i -= j\n var d = ap1.distanceTo(ap2)\n switch (this.labelUnit) {\n case 'angstrom':\n text[ i ] = d.toFixed(2) + ' ' + String.fromCharCode(0x212B)\n break\n case 'nm':\n text[ i ] = (d / 10).toFixed(2) + ' nm'\n break\n default:\n text[ i ] = d.toFixed(2)\n break\n }\n\n var i3 = i * 3\n position[ i3 + 0 ] = (ap1.x + ap2.x) / 2\n position[ i3 + 1 ] = (ap1.y + ap2.y) / 2\n position[ i3 + 2 ] = (ap1.z + ap2.z) / 2\n })\n\n if (j > 0) {\n n -= j\n position = position.subarray(0, n * 3)\n }\n\n var bondSet = new BitArray(bondStore.count, true)\n\n return {\n text: text,\n position: position,\n bondSet: bondSet,\n bondStore: bondStore\n }\n }\n\n getBondData (sview: StructureView, what: BondDataFields, params: BondDataParams): BondData {\n const bondData = sview.getBondData(this.getBondParams(what, params))\n if (bondData.picking) {\n bondData.picking = new DistancePicker(\n bondData.picking.array,\n bondData.picking.structure,\n params.bondStore!\n ) as any\n }\n return bondData\n }\n\n createData (sview: StructureView) {\n if (!sview.atomCount || !this.atomPair.length) return\n\n const n = this.atomPair.length\n const c = new Color(this.labelColor)\n const distanceData = this.getDistanceData(sview, this.atomPair)\n\n this.textBuffer = new TextBuffer({\n position: distanceData.position,\n size: uniformArray(n, this.labelSize),\n color: uniformArray3(n, c.r, c.g, c.b),\n text: distanceData.text\n } as TextBufferData, this.getLabelBufferParams() as TextBufferParameters)\n\n const bondParams = {\n bondSet: distanceData.bondSet,\n bondStore: distanceData.bondStore\n }\n\n const bondData = this.getBondData(\n sview,\n { position: true, color: true, picking: true, radius: this.useCylinder },\n bondParams\n )\n\n if (this.useCylinder) {\n this.distanceBuffer = new CylinderBuffer(\n bondData as CylinderBufferData,\n this.getBufferParams({\n openEnded: this.openEnded,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) \n ) as CylinderGeometryBuffer\n } else {\n this.distanceBuffer = new WideLineBuffer(\n getFixedLengthDashData(bondData as CylinderBufferData),\n this.getBufferParams({\n linewidth: this.linewidth,\n visible: this.lineVisible,\n opacity: this.lineOpacity\n })\n )\n }\n\n return {\n bondSet: distanceData.bondSet,\n bondStore: distanceData.bondStore,\n position: distanceData.position,\n bufferList: [ this.textBuffer, this.distanceBuffer ]\n }\n }\n\n updateData (what: BondDataFields, data: StructureRepresentationData) {\n super.updateData(what, data)\n\n const bondParams = {\n bondSet: data.bondSet,\n bondStore: data.bondStore\n }\n\n const bondData = this.getBondData(data.sview as StructureView, what, bondParams)\n const distanceData = {}\n\n if (!what || what.color) {\n Object.assign( distanceData, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n if (!what || what.radius) {\n Object.assign( distanceData, {radius: bondData.radius})\n }\n\n (this.distanceBuffer as CylinderGeometryBuffer).setAttributes(distanceData)\n }\n\n setParameters (params: Partial) {\n let rebuild = false\n const what = {}\n\n super.setParameters(params, what, rebuild)\n\n if (!this.useCylinder) {\n if (params && params.lineOpacity) {\n (this.distanceBuffer as WideLineBuffer).setParameters({ opacity: params.lineOpacity })\n }\n if (params && params.opacity !== undefined) {\n (this.distanceBuffer as WideLineBuffer).setParameters({ opacity: this.lineOpacity })\n }\n if (params && params.linewidth) {\n (this.distanceBuffer as WideLineBuffer).setParameters({ linewidth: params.linewidth })\n }\n }\n\n return this\n }\n}\n\nRepresentationRegistry.add('distance', DistanceRepresentation)\n\nexport default DistanceRepresentation\n","/**\n * @file Vector Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { Color, Matrix4, Vector3 } from 'three'\n\nimport '../shader/Line.vert'\nimport '../shader/Line.frag'\n\nimport { uniformArray3 } from '../math/array-utils'\nimport Buffer, { BufferDefaultParameters, BufferData, BufferParameters } from './buffer'\nimport { GenericColor } from '../types'\n\nfunction getSize(data: BufferData){\n const n = data.position!.length / 3\n return n * 2 * 3\n}\n\nexport interface VectorBufferData extends BufferData {\n vector: Float32Array\n}\n\nexport const VectorBufferDefaultParameters = Object.assign({\n scale: 1,\n color: 'grey'\n}, BufferDefaultParameters)\nexport type VectorBufferParameters = BufferParameters & { scale: number, color: GenericColor }\n\n/**\n * Vector buffer. Draws vectors as lines.\n */\nclass VectorBuffer extends Buffer {\n get defaultParameters() { return VectorBufferDefaultParameters }\n parameters: VectorBufferParameters\n\n isLine = true\n vertexShader = 'Line.vert'\n fragmentShader = 'Line.frag'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.vector - vectors\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: VectorBufferData, params: Partial = {}) {\n super({\n position: new Float32Array(getSize(data)),\n color: new Float32Array(getSize(data))\n }, params)\n\n const color = new Color(this.parameters.color)\n const attributes = this.geometry.attributes as any // TODO\n uniformArray3(getSize(data) / 3, color.r, color.g, color.b, attributes.color.array)\n\n this.setAttributes(data)\n }\n\n setAttributes (data: Partial = {}) {\n const attributes = this.geometry.attributes as any // TODO\n\n let position, vector\n let aPosition\n\n if (data.position && data.vector) {\n position = data.position\n vector = data.vector\n aPosition = attributes.position.array\n attributes.position.needsUpdate = true\n }\n\n const n = this.size / 2\n const scale = this.parameters.scale\n\n if (position && vector) {\n for (let v = 0; v < n; v++) {\n const i = v * 2 * 3\n const j = v * 3\n\n aPosition[ i + 0 ] = position[ j + 0 ]\n aPosition[ i + 1 ] = position[ j + 1 ]\n aPosition[ i + 2 ] = position[ j + 2 ]\n aPosition[ i + 3 ] = position[ j + 0 ] + vector[ j + 0 ] * scale\n aPosition[ i + 4 ] = position[ j + 1 ] + vector[ j + 1 ] * scale\n aPosition[ i + 5 ] = position[ j + 2 ] + vector[ j + 2 ] * scale\n }\n }\n }\n}\n\nexport default VectorBuffer\n","/**\n * @file Helixorient Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Helixorient from '../geometry/helixorient'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferParameters } from '../buffer/sphere-buffer'\nimport VectorBuffer from '../buffer/vector-buffer'\nimport Viewer from '../viewer/viewer';\nimport { Structure } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport Polymer from '../proxy/polymer';\nimport { AtomDataFields } from '../structure/structure-data';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\nimport SphereImpostorBuffer from '../buffer/sphereimpostor-buffer';\nimport { BufferData } from '../buffer/buffer';\n\n/**\n * Helixorient Representation\n */\nclass HelixorientRepresentation extends StructureRepresentation {\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'helixorient'\n\n this.parameters = Object.assign({\n sphereDetail: true,\n disableImpostor: true\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'sstruc')\n p.radiusType = defaults(p.radiusType, 'size')\n p.radiusSize = defaults(p.radiusSize, 0.15)\n p.radiusScale = defaults(p.radiusScale, 1.0)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n const bufferList: (SphereBuffer|VectorBuffer)[] = []\n const polymerList: Polymer[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4) return\n polymerList.push(polymer)\n\n const helixorient = new Helixorient(polymer)\n const position = helixorient.getPosition()\n const color = helixorient.getColor(this.getColorParams())\n const size = helixorient.getSize(this.getRadiusParams())\n const picking = helixorient.getPicking()\n\n bufferList.push(\n new SphereBuffer(\n {\n position: position.center,\n color: color.color,\n radius: size.size,\n picking: picking.picking\n },\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters\n ),\n new VectorBuffer(\n {\n position: position.center,\n vector: position.axis\n },\n this.getBufferParams({\n color: 'skyblue',\n scale: 1\n })\n ),\n new VectorBuffer(\n {\n position: position.center,\n vector: position.resdir\n },\n this.getBufferParams({\n color: 'lightgreen',\n scale: 1\n })\n )\n )\n }, sview.getSelection())\n\n return {\n bufferList: bufferList as (SphereGeometryBuffer|SphereImpostorBuffer|VectorBuffer)[],\n polymerList: polymerList\n }\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n if (Debug) Log.time(this.type + ' repr update')\n\n what = what || {}\n\n for (let i = 0, il = data.polymerList!.length; i < il; ++i) {\n const j = i * 3\n\n const bufferData: Partial = {}\n const polymer = data.polymerList![ i ]\n const helixorient = new Helixorient(polymer)\n\n if (what.position) {\n const position = helixorient.getPosition()\n\n Object.assign(bufferData, {position: position.center})\n\n data.bufferList[ j + 1 ].setAttributes({\n 'position': position.center,\n 'vector': position.axis\n })\n data.bufferList[ j + 2 ].setAttributes({\n 'position': position.center,\n 'vector': position.resdir\n })\n }\n\n data.bufferList[ j ].setAttributes(bufferData)\n }\n\n if (Debug) Log.timeEnd(this.type + ' repr update')\n }\n}\n\nRepresentationRegistry.add('helixorient', HelixorientRepresentation)\n\nexport default HelixorientRepresentation\n","/**\n * @file Licorice Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport BallAndStickRepresentation, { BallAndStickRepresentationParameters } from './ballandstick-representation'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\n\n/**\n * Licorice representation object ({@link BallAndStickRepresentation} with `aspectRatio` fixed at 1.0)\n */\nclass LicoriceRepresentation extends BallAndStickRepresentation {\n /**\n * Create Licorice representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {BallAndStickRepresentationParameters} params - ball and stick representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'licorice'\n\n this.parameters = Object.assign(\n {}, this.parameters, { aspectRatio: null }\n )\n }\n\n init (params: Partial) {\n var p = params || {}\n p.aspectRatio = 1.0\n\n super.init(p)\n }\n}\n\nRepresentationRegistry.add('licorice', LicoriceRepresentation)\n\nexport default LicoriceRepresentation\n","/**\n * @file Mapped Box Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { BufferParameters, BufferData } from './buffer'\nimport MappedBuffer from './mapped-buffer'\n\nconst mapping = new Float32Array([\n -1.0, -1.0, -1.0,\n 1.0, -1.0, -1.0,\n 1.0, -1.0, 1.0,\n -1.0, -1.0, 1.0,\n -1.0, 1.0, -1.0,\n 1.0, 1.0, -1.0,\n 1.0, 1.0, 1.0,\n -1.0, 1.0, 1.0\n])\n\nconst mappingIndices = new Uint16Array([\n 0, 1, 2,\n 0, 2, 3,\n 1, 5, 6,\n 1, 6, 2,\n 4, 6, 5,\n 4, 7, 6,\n 0, 7, 4,\n 0, 3, 7,\n 0, 5, 1,\n 0, 4, 5,\n 3, 2, 6,\n 3, 6, 7\n])\n\n/**\n * Mapped Box buffer. Draws boxes. Used to render general imposters.\n * @interface\n */\nclass MappedBoxBuffer extends MappedBuffer {\n constructor(data: BufferData, params: Partial = {}) {\n super('v3', data, params)\n }\n get mapping () { return mapping }\n get mappingIndices () { return mappingIndices }\n get mappingIndicesSize () { return 36 }\n get mappingSize () { return 8 }\n get mappingItemSize () { return 3 }\n}\n\nexport default MappedBoxBuffer\n","/**\n * @file Hyperball Stick Impostor Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3 required for declaration only\nimport { Matrix4, Vector3 } from 'three'\n\nimport '../shader/HyperballStickImpostor.vert'\nimport '../shader/HyperballStickImpostor.frag'\n\nimport MappedBoxBuffer from './mappedbox-buffer'\nimport { BufferDefaultParameters, BufferParameterTypes, BufferData, BufferParameters } from './buffer'\n\nexport interface HyperballStickImpostorBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n color2: Float32Array\n radius: Float32Array\n radius2: Float32Array\n}\n\nexport const HyperballStickImpostorBufferDefaultParameters = Object.assign({\n shrink: 0.14\n}, BufferDefaultParameters)\nexport type HyperballStickImpostorBufferParameters = BufferParameters & { shrink: number }\n\nconst HyperballStickImpostorBufferParameterTypes = Object.assign({\n shrink: { uniform: true }\n}, BufferParameterTypes)\n\n/**\n * Hyperball stick impostor buffer.\n *\n * @example\n * var hyperballStickImpostorBuffer = new HyperballStickImpostorBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 2, 2, 2 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ]),\n * radius2: new Float32Array([ 2 ])\n * });\n */\nclass HyperballStickImpostorBuffer extends MappedBoxBuffer {\n parameterTypes = HyperballStickImpostorBufferParameterTypes\n get defaultParameters() { return HyperballStickImpostorBufferDefaultParameters }\n parameters: HyperballStickImpostorBufferParameters\n\n isImpostor = true\n vertexShader = 'HyperballStickImpostor.vert'\n fragmentShader = 'HyperballStickImpostor.frag'\n\n constructor (data: HyperballStickImpostorBufferData, params: Partial = {}) {\n super(data, params)\n\n this.addUniforms({\n 'modelViewProjectionMatrix': { value: new Matrix4() },\n 'modelViewProjectionMatrixInverse': { value: new Matrix4() },\n 'modelViewMatrixInverseTranspose': { value: new Matrix4() },\n 'shrink': { value: this.parameters.shrink }\n })\n\n this.addAttributes({\n 'position1': { type: 'v3', value: null },\n 'position2': { type: 'v3', value: null },\n 'color2': { type: 'c', value: null },\n 'radius': { type: 'f', value: null },\n 'radius2': { type: 'f', value: null }\n })\n\n this.setAttributes(data)\n this.makeMapping()\n }\n}\n\nexport default HyperballStickImpostorBuffer\n","/**\n * @file Hyperball Stick Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import required for declaration only\nimport { Vector3, Matrix4 } from 'three'\nimport { ExtensionFragDepth } from '../globals'\nimport { calculateMinArray } from '../math/array-utils'\nimport CylinderGeometryBuffer, { CylinderGeometryBufferDefaultParameters, CylinderGeometryBufferParameters } from './cylindergeometry-buffer'\nimport HyperballStickImpostorBuffer, { HyperballStickImpostorBufferDefaultParameters, HyperballStickImpostorBufferParameters } from './hyperballstickimpostor-buffer'\nimport { BufferData } from './buffer'\n\nexport interface HyperballStickBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n color2: Float32Array\n radius: Float32Array\n radius2: Float32Array\n}\n\nexport const HyperballStickBufferDefaultParameters = Object.assign({\n disableImpostor: false\n}, CylinderGeometryBufferDefaultParameters, HyperballStickImpostorBufferDefaultParameters)\nexport type HyperballStickBufferParameters = HyperballStickImpostorBufferParameters & CylinderGeometryBufferParameters & { disableImpostor: boolean }\n\nclass HyperballStickBufferImpl {\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - from colors\n * @param {Float32Array} data.color2 - to colors\n * @param {Float32Array} data.radius - from radii\n * @param {Float32Array} data.radius2 - to radii\n * @param {Float32Array} data.picking - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: HyperballStickBufferData, params: Partial = {}) {\n if (!ExtensionFragDepth || (params && params.disableImpostor)) {\n data.radius = calculateMinArray(data.radius, data.radius2)\n return new CylinderGeometryBuffer(data, params)\n } else {\n return new HyperballStickImpostorBuffer(data, params)\n }\n }\n}\n\n/**\n * Hyperball stick buffer. Depending on the value {@link ExtensionFragDepth} and\n * `params.disableImpostor` the constructor returns either a\n * {@link CylinderGeometryBuffer} or a {@link HyperballStickImpostorBuffer}\n * @implements {Buffer}\n *\n * @example\n * var hyperballStickBuffer = new HyperballStickBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 2, 2, 2 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ]),\n * radius2: new Float32Array([ 2 ])\n * });\n */\n//@ts-expect-error Incompatible constructor signatures\nconst HyperballStickBuffer: {\n new(data: HyperballStickBufferData, params: Partial): CylinderGeometryBuffer | HyperballStickImpostorBuffer;\n} = HyperballStickBufferImpl;\n\ntype HyperballStickBuffer = CylinderGeometryBuffer | HyperballStickImpostorBuffer;\n\nexport default HyperballStickBuffer\n","/**\n * @file Hyperball Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { calculateCenterArray } from '../math/array-utils'\nimport LicoriceRepresentation from './licorice-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport HyperballStickBuffer, { HyperballStickBufferData } from '../buffer/hyperballstick-buffer'\nimport { BallAndStickRepresentationParameters } from './ballandstick-representation';\n// @ts-ignore: unused import Volume required for declaration only\nimport { Structure, Volume } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport { BondDataParams, BondDataFields, AtomDataFields } from '../structure/structure-data';\nimport StructureView from '../structure/structure-view';\nimport { StructureRepresentationData } from './structure-representation';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\n// @ts-ignore: unused import Surface required for declaration only\nimport Surface from '../surface/surface';\n\nexport interface HyperballRepresentationParameters extends BallAndStickRepresentationParameters {\n shrink: number\n}\n\n/**\n * Hyperball Representation\n */\nclass HyperballRepresentation extends LicoriceRepresentation {\n protected shrink: number\n protected __center: Float32Array\n \n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'hyperball'\n\n this.parameters = Object.assign({\n\n shrink: {\n type: 'number', precision: 3, max: 1.0, min: 0.001, buffer: true\n }\n\n }, this.parameters, {\n\n multipleBond: null,\n bondSpacing: null\n\n })\n }\n\n init (params: Partial) {\n var p = params || {}\n p.radiusScale = defaults(p.radiusScale, 0.2)\n p.radiusType = defaults(p.radiusType, 'vdw')\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.shrink = defaults(p.shrink, 0.12)\n\n super.init(p)\n }\n\n getBondParams (what?: BondDataFields, params?: BondDataParams) {\n if (!what || what.radius) {\n params = Object.assign({ radius2: true }, params)\n }\n\n return super.getBondParams(what, params)\n }\n\n createData (sview: StructureView) {\n var sphereBuffer = new SphereBuffer(\n (sview.getAtomData(this.getAtomParams()) as SphereBufferData),\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters\n ) as SphereGeometryBuffer\n\n this.__center = new Float32Array(sview.bondCount * 3)\n\n var stickBuffer = new HyperballStickBuffer(\n sview.getBondData(this.getBondParams()) as HyperballStickBufferData,\n this.getBufferParams({\n shrink: this.shrink,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n return {\n bufferList: [ sphereBuffer, stickBuffer ]\n }\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n var atomData = data.sview!.getAtomData(this.getAtomParams())\n var bondData = data.sview!.getBondData(this.getBondParams())\n var sphereData = {}\n var stickData = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {position: atomData.position})\n var from = bondData.position1\n var to = bondData.position2\n Object.assign(stickData, {\n position: calculateCenterArray(from!, to!, this.__center),\n position1: from,\n position2: to\n })\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {color: atomData.color})\n Object.assign(stickData, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {radius: atomData.radius})\n Object.assign(stickData, {\n radius: bondData.radius,\n radius2: bondData.radius2\n })\n }\n\n data.bufferList[ 0 ].setAttributes(sphereData)\n data.bufferList[ 1 ].setAttributes(stickData)\n }\n}\n\nRepresentationRegistry.add('hyperball', HyperballRepresentation)\n\nexport default HyperballRepresentation\n","/**\n * @file Label Factory\n * @author Alexander Rose \n * @private\n */\n\nimport { AA1 } from '../structure/structure-constants'\nimport AtomProxy from '../proxy/atom-proxy'\nimport { sprintf } from 'sprintf-js'\n\nexport const LabelFactoryTypes = {\n '': '',\n 'atomname': 'atom name',\n 'atomindex': 'atom index',\n 'occupancy': 'occupancy',\n 'bfactor': 'b-factor',\n 'serial': 'serial',\n 'element': 'element',\n 'atom': 'atom name + index',\n 'resname': 'residue name',\n 'resno': 'residue no',\n 'res': 'one letter code + no',\n 'residue': '[residue name] + no + inscode',\n 'text': 'text',\n 'format': 'format',\n 'qualified': 'qualified name'\n}\nexport type LabelType = keyof typeof LabelFactoryTypes\n\nclass LabelFactory {\n\n static types = LabelFactoryTypes\n errorLogged: boolean = false\n\n constructor(readonly type: LabelType, readonly text: { [k: number]: string } = {},\n readonly format: string = '') {}\n\n atomLabel (a: AtomProxy) {\n const type = this.type\n\n let l\n\n switch (type) {\n case 'atomname':\n l = a.atomname\n break\n\n case 'atomindex':\n l = `${a.index}`\n break\n\n case 'occupancy':\n l = a.occupancy.toFixed(2)\n break\n\n case 'bfactor':\n l = a.bfactor.toFixed(2)\n break\n\n case 'serial':\n l = `${a.serial}`\n break\n\n case 'element':\n l = a.element\n break\n\n case 'atom':\n l = `${a.atomname}|${a.index}`\n break\n\n case 'resname':\n l = a.resname\n break\n\n case 'resno':\n l = `${a.resno}`\n break\n\n case 'res':\n l = `${(AA1[ a.resname.toUpperCase() ] || a.resname)}${a.resno}`\n break\n\n case 'residue':\n const aa1 = AA1[ a.resname.toUpperCase() ]\n if (aa1 && !a.inscode) {\n l = `${aa1}${a.resno}`\n } else {\n l = `[${a.resname}]${a.resno}${a.inscode}`\n }\n break\n\n case 'text':\n l = this.text[ a.index ]\n break\n\n case 'format':\n try {\n l = sprintf(this.format, a)\n } catch (e) {\n if (!this.errorLogged) {\n this.errorLogged = true\n console.log(e.message)\n }\n }\n break\n\n // case \"qualified\":\n default:\n l = a.qualifiedName()\n break\n }\n\n return l === undefined ? '' : l\n }\n}\n\nexport default LabelFactory\n","/**\n * @file Label Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry, ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport LabelFactory, { LabelType } from '../utils/label-factory'\nimport RadiusFactory from '../utils/radius-factory'\nimport StructureRepresentation, { StructureRepresentationData } from './structure-representation'\nimport TextBuffer, { TextBufferData } from '../buffer/text-buffer'\nimport { RepresentationParameters } from './representation';\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { GenericColor } from '../types'\n\nexport interface TextDataField {\n position?: boolean\n color?: boolean\n radius?: boolean\n text?: boolean\n}\n\n/**\n * Label representation parameter object. Extends {@link RepresentationParameters} and\n * {@link StructureRepresentationParameters}.\n *\n * @typedef {Object} LabelRepresentationParameters - label representation parameters\n *\n * @property {Integer} clipNear - position of camera near/front clipping plane\n * in percent of scene bounding box\n * @property {Float} opacity - translucency: 1 is fully opaque, 0 is fully transparent\n * @property {String} labelType - type of the label, one of:\n * \"atomname\", \"atomindex\", \"occupancy\", \"bfactor\",\n * \"serial\", \"element\", \"atom\", \"resname\", \"resno\",\n * \"res\", \"text\", \"qualified\". When set to \"text\", the\n * `labelText` list is used.\n * @property {String[]} labelText - list of label strings, must set `labelType` to \"text\"\n * to take effect\n * @property {String} labelFormat - sprintf-js format string, any attribute of\n * {@link AtomProxy} can be used\n * @property {String} labelGrouping - grouping of the label, one of:\n * \"atom\", \"residue\".\n * @property {String} fontFamily - font family, one of: \"sans-serif\", \"monospace\", \"serif\"\n * @property {String} fontStyle - font style, \"normal\" or \"italic\"\n * @property {String} fontWeight - font weight, \"normal\" or \"bold\"\n * @property {Float} xOffset - offset in x-direction\n * @property {Float} yOffset - offset in y-direction\n * @property {Float} zOffset - offset in z-direction (i.e. in camera direction)\n * @property {String} attachment - attachment of the label, one of:\n * \"bottom-left\", \"bottom-center\", \"bottom-right\",\n * \"middle-left\", \"middle-center\", \"middle-right\",\n * \"top-left\", \"top-center\", \"top-right\"\n * @property {Boolean} showBorder - show border/outline\n * @property {Color} borderColor - color of the border/outline\n * @property {Float} borderWidth - width of the border/outline\n * @property {Boolean} showBackground - show background rectangle\n * @property {Color} backgroundColor - color of the background\n * @property {Float} backgroundMargin - width of the background\n * @property {Float} backgroundOpacity - opacity of the background\n * @property {Boolean} fixedSize - show text with a fixed pixel size\n */\nexport interface LabelRepresentationParameters extends RepresentationParameters {\n labelType: LabelType\n labelText: string[]\n labelFormat: string\n labelGrouping: 'atom'|'residue'\n fontFamily: 'sans-serif'|'monospace'|'serif'\n fontStyle: 'normal'|'italic'\n fontWeight: 'normal'|'bold'\n xOffset: number\n yOffset: number\n zOffset: number\n attachment: 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n showBorder: boolean\n borderColor: GenericColor\n borderWidth: number\n showBackground: boolean\n backgroundColor: GenericColor\n backgroundMargin: number\n backgroundOpacity: number\n fixedSize: boolean\n}\n/**\n * Label representation\n */\nclass LabelRepresentation extends StructureRepresentation {\n\n protected labelType: LabelType\n protected labelText: string[]\n protected labelFormat: string\n protected labelGrouping: 'atom'|'residue'\n protected fontFamily: 'sans-serif'|'monospace'|'serif'\n protected fontStyle: 'normal'|'italic'\n protected fontWeight: 'normal'|'bold'\n protected xOffset: number\n protected yOffset: number\n protected zOffset: number\n protected attachment: 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n protected showBorder: boolean\n protected borderColor: GenericColor\n protected borderWidth: number\n protected showBackground: boolean\n protected backgroundColor: GenericColor\n protected backgroundMargin: number\n protected backgroundOpacity: number\n protected fixedSize: boolean\n\n /**\n * Create Label representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {LabelRepresentationParameters} params - label representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'label'\n\n this.parameters = Object.assign({\n\n labelType: {\n type: 'select', options: LabelFactory.types, rebuild: true\n },\n labelText: {\n type: 'hidden', rebuild: true\n },\n labelFormat: {\n type: 'text', rebuild: true\n },\n labelGrouping: {\n type: 'select',\n options: {\n 'atom': 'atom',\n 'residue': 'residue'\n },\n rebuild: true\n },\n fontFamily: {\n type: 'select',\n options: {\n 'sans-serif': 'sans-serif',\n 'monospace': 'monospace',\n 'serif': 'serif'\n },\n buffer: true\n },\n fontStyle: {\n type: 'select',\n options: {\n 'normal': 'normal',\n 'italic': 'italic'\n },\n buffer: true\n },\n fontWeight: {\n type: 'select',\n options: {\n 'normal': 'normal',\n 'bold': 'bold'\n },\n buffer: true\n },\n xOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: true\n },\n yOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: true\n },\n zOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: true\n },\n attachment: {\n type: 'select',\n options: {\n 'bottom-left': 'bottom-left',\n 'bottom-center': 'bottom-center',\n 'bottom-right': 'bottom-right',\n 'middle-left': 'middle-left',\n 'middle-center': 'middle-center',\n 'middle-right': 'middle-right',\n 'top-left': 'top-left',\n 'top-center': 'top-center',\n 'top-right': 'top-right'\n },\n rebuild: true\n },\n showBorder: {\n type: 'boolean', buffer: true\n },\n borderColor: {\n type: 'color', buffer: true\n },\n borderWidth: {\n type: 'number', precision: 2, max: 0.3, min: 0, buffer: true\n },\n showBackground: {\n type: 'boolean', rebuild: true\n },\n backgroundColor: {\n type: 'color', buffer: true\n },\n backgroundMargin: {\n type: 'number', precision: 2, max: 2, min: 0, rebuild: true\n },\n backgroundOpacity: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n fixedSize: {\n type: 'boolean', buffer: true\n }\n\n }, this.parameters, {\n\n side: null,\n flatShaded: null,\n wireframe: null,\n linewidth: null,\n\n roughness: null,\n metalness: null,\n diffuse: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n\n this.labelType = defaults(p.labelType, 'res')\n this.labelText = defaults(p.labelText, {})\n this.labelFormat = defaults(p.labelFormat, '')\n this.labelGrouping = defaults(p.labelGrouping, 'atom')\n this.fontFamily = defaults(p.fontFamily, 'sans-serif')\n this.fontStyle = defaults(p.fontStyle, 'normal')\n this.fontWeight = defaults(p.fontWeight, 'bold')\n this.xOffset = defaults(p.xOffset, 0.0)\n this.yOffset = defaults(p.yOffset, 0.0)\n this.zOffset = defaults(p.zOffset, 0.5)\n this.attachment = defaults(p.attachment, 'bottom-left')\n this.showBorder = defaults(p.showBorder, false)\n this.borderColor = defaults(p.borderColor, 'lightgrey')\n this.borderWidth = defaults(p.borderWidth, 0.15)\n this.showBackground = defaults(p.showBackground, false)\n this.backgroundColor = defaults(p.backgroundColor, 'lightgrey')\n this.backgroundMargin = defaults(p.backgroundMargin, 0.5)\n this.backgroundOpacity = defaults(p.backgroundOpacity, 1.0)\n this.fixedSize = defaults(p.fixedSize, false)\n\n super.init(p)\n }\n\n getTextData (sview: StructureView, what?: TextDataField) {\n const p = this.getAtomParams(what)\n const labelFactory = new LabelFactory(this.labelType, this.labelText, this.labelFormat)\n let position: Float32Array, size: Float32Array, color: Float32Array, text: string[],\n positionN: number[], sizeN: number[], colorN: number[]\n if (this.labelGrouping === 'atom') {\n const atomData = sview.getAtomData(p)\n position = atomData.position as Float32Array\n size = atomData.radius as Float32Array\n color = atomData.color as Float32Array\n if (!what || what.text) {\n text = []\n sview.eachAtom(ap => text.push(labelFactory.atomLabel(ap)))\n }\n } else if (this.labelGrouping === 'residue') {\n if (!what || what.position) positionN = []\n if (!what || what.color) colorN = []\n if (!what || what.radius) sizeN = []\n if (!what || what.text) text = []\n if (p.colorParams) p.colorParams.structure = sview.getStructure()\n const colormaker = ColormakerRegistry.getScheme(p.colorParams)\n const radiusFactory = new RadiusFactory(p.radiusParams)\n const ap1 = sview.getAtomProxy()\n\n let i = 0\n sview.eachResidue(rp => {\n const i3 = i * 3\n if (rp.isProtein() || rp.isNucleic()) {\n ap1.index = rp.traceAtomIndex\n if (!what || what.position) {\n ap1.positionToArray(positionN, i3)\n }\n } else {\n ap1.index = rp.atomOffset\n if (!what || what.position) {\n rp.positionToArray(positionN, i3)\n }\n }\n if (!what || what.color) {\n colormaker.atomColorToArray(ap1, colorN, i3)\n }\n if (!what || what.radius) {\n sizeN[ i ] = radiusFactory.atomRadius(ap1)\n }\n if (!what || what.text) {\n text.push(labelFactory.atomLabel(ap1))\n }\n ++i\n })\n\n if (!what || what.position) position = new Float32Array(positionN!)\n if (!what || what.color) color = new Float32Array(colorN!)\n if (!what || what.radius) size = new Float32Array(sizeN!)\n }\n\n return { position: position!, size: size!, color: color!, text: text! }\n }\n\n createData (sview: StructureView) {\n const what: TextDataField = { position: true, color: true, radius: true, text: true }\n\n const textBuffer = new TextBuffer(\n this.getTextData(sview, what) as TextBufferData,\n this.getBufferParams({\n fontFamily: this.fontFamily,\n fontStyle: this.fontStyle,\n fontWeight: this.fontWeight,\n xOffset: this.xOffset,\n yOffset: this.yOffset,\n zOffset: this.zOffset,\n attachment: this.attachment,\n showBorder: this.showBorder,\n borderColor: this.borderColor,\n borderWidth: this.borderWidth,\n showBackground: this.showBackground,\n backgroundColor: this.backgroundColor,\n backgroundMargin: this.backgroundMargin,\n backgroundOpacity: this.backgroundOpacity,\n fixedSize: this.fixedSize\n })\n )\n\n return { bufferList: [ textBuffer ] }\n }\n\n updateData (what: TextDataField, data: StructureRepresentationData) {\n data.bufferList[ 0 ].setAttributes(this.getTextData(data.sview as StructureView, what))\n }\n\n getAtomRadius () {\n return 0\n }\n}\n\nRepresentationRegistry.add('label', LabelRepresentation)\n\nexport default LabelRepresentation\n","/**\n * @file Line Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { RepresentationRegistry } from '../globals'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport WideLineBuffer from '../buffer/wideline-buffer'\nimport { AtomPicker } from '../utils/picker'\n// @ts-ignore: unused import Volume required for declaration only\nimport { Structure, Volume } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport Viewer from '../viewer/viewer';\nimport AtomProxy from '../proxy/atom-proxy';\n// @ts-ignore: unused import Surface required for declaration only\nimport Surface from '../surface/surface';\n// @ts-ignore: unused import BondDataFields, BondDataParams required for declaration only\nimport { BondDataFields, BondDataParams } from '../structure/structure-data';\n\n/**\n * Determine which atoms in a Structure[View] form no bonds to any other atoms\n * in that Structure.\n *\n * This differs from setting the selection to \"nonbonded\" as it finds atoms\n * that have no bonds within the current selection.\n * @param {Structure} structure - The Structure or StructureView object\n * @return {AtomSet} AtomSet of lone atoms\n */\nfunction getLoneAtomSet (structure: Structure | StructureView) {\n const atomSet = structure.getAtomSet()\n const bondSet = structure.getBondSet()\n const bp = structure.getBondProxy()\n bondSet.forEach(function (idx) {\n bp.index = idx\n atomSet.clear(bp.atomIndex1)\n atomSet.clear(bp.atomIndex2)\n })\n return atomSet\n}\n\nexport interface LineRepresentationParameters extends StructureRepresentationParameters {\n multipleBond: 'off' | 'symmetric' | 'offset'\n bondSpacing: number\n linewidth: number\n lines: boolean\n crosses: 'off' | 'all' | 'lone'\n crossSize: number\n}\n\nexport interface CrossData {\n position1?: Float32Array\n position2?: Float32Array\n color?: Float32Array\n color2?: Float32Array\n picking?: AtomPicker\n}\n\n/**\n * Line representation\n */\nclass LineRepresentation extends StructureRepresentation {\n protected multipleBond: 'off' | 'symmetric' | 'offset'\n protected bondSpacing: number\n protected linewidth: number\n protected lines: boolean\n protected crosses: 'off' | 'all' | 'lone'\n protected crossSize: number\n /**\n * Create Line representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {RepresentationParameters} params - representation parameters, plus the properties listed below\n * @property {String} multipleBond - one off \"off\", \"symmetric\", \"offset\"\n * @param {Float} params.bondSpacing - spacing for multiple bond rendering\n * @param {Integer} params.linewidth - width of lines\n * @param {Boolean} params.lines - render bonds as lines\n * @param {String} params.crosses - render atoms as crosses: \"off\", \"all\" or \"lone\" (default)\n * @param {Float} params.crossSize - size of cross\n * @param {null} params.flatShaded - not available\n * @param {null} params.side - not available\n * @param {null} params.wireframe - not available\n * @param {null} params.roughness - not available\n * @param {null} params.metalness - not available\n * @param {null} params.diffuse - not available\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'line'\n\n this.parameters = Object.assign({\n\n multipleBond: {\n type: 'select',\n rebuild: true,\n options: {\n 'off': 'off',\n 'symmetric': 'symmetric',\n 'offset': 'offset'\n }\n },\n bondSpacing: {\n type: 'number', precision: 2, max: 2.0, min: 0.5\n },\n linewidth: {\n type: 'integer', max: 50, min: 1, buffer: true\n },\n lines: {\n type: 'boolean', rebuild: true\n },\n crosses: {\n type: 'select',\n rebuild: true,\n options: {\n 'off': 'off',\n 'lone': 'lone',\n 'all': 'all'\n }\n },\n crossSize: {\n type: 'number', precision: 2, max: 2.0, min: 0.1\n }\n\n }, this.parameters, {\n\n flatShaded: null,\n side: null,\n wireframe: null,\n\n roughness: null,\n metalness: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n\n this.multipleBond = defaults(p.multipleBond, 'off')\n this.bondSpacing = defaults(p.bondSpacing, 1.0)\n this.linewidth = defaults(p.linewidth, 2)\n this.lines = defaults(p.lines, true)\n this.crosses = defaults(p.crosses, 'lone')\n this.crossSize = defaults(p.crossSize, 0.4)\n\n super.init(p)\n }\n\n getAtomRadius (atom:AtomProxy) {\n return 0.1\n }\n\n getBondParams (what: any, params?: Partial) {\n params = Object.assign({\n multipleBond: this.multipleBond,\n bondSpacing: this.bondSpacing,\n radiusParams: { 'type': 'size', 'size': 0.1, 'scale': 1 }\n }, params)\n\n return super.getBondParams(what, params)\n }\n\n _crossData (what: any, sview: StructureView) {\n if (what) {\n if (!what.position && !what.color) return\n }\n\n const p = {}\n if (this.crosses === 'lone') {\n Object.assign(p, {atomSet : getLoneAtomSet(sview)})\n }\n\n const atomData = sview.getAtomData(this.getAtomParams(what, p))\n const crossData: CrossData = {}\n const position = atomData.position\n const color = atomData.color\n const picking = atomData.picking\n\n const size = (position! || color).length\n const attrSize = size * 3\n\n let cPosition1 = new Float32Array(0)\n let cPosition2 = new Float32Array(0)\n let cColor = new Float32Array(0)\n let cColor2 = new Float32Array(0)\n let cOffset: number = 0\n\n let pickingArray = new Float32Array(0)\n\n if (!what || what.position) {\n cPosition1 = crossData.position1 = new Float32Array(attrSize)\n cPosition2 = crossData.position2 = new Float32Array(attrSize)\n cOffset = this.crossSize / 2\n }\n if (!what || what.color) {\n cColor = crossData.color = new Float32Array(attrSize)\n cColor2 = crossData.color2 = new Float32Array(attrSize)\n }\n if (!what || what.picking) {\n pickingArray = new Float32Array(atomData.picking!.array!.length * 3) // Needs padding??\n }\n\n for (let v = 0; v < size; v++) {\n const j = v * 3\n const i = j * 3\n\n if (!what || what.position) {\n const x = position![ j ]\n const y = position![ j + 1 ]\n const z = position![ j + 2 ]\n\n cPosition1[ i ] = x - cOffset!\n cPosition1[ i + 1 ] = y\n cPosition1[ i + 2 ] = z\n cPosition2[ i ] = x + cOffset\n cPosition2[ i + 1 ] = y\n cPosition2[ i + 2 ] = z\n\n cPosition1[ i + 3 ] = x\n cPosition1[ i + 4 ] = y - cOffset\n cPosition1[ i + 5 ] = z\n cPosition2[ i + 3 ] = x\n cPosition2[ i + 4 ] = y + cOffset\n cPosition2[ i + 5 ] = z\n\n cPosition1[ i + 6 ] = x\n cPosition1[ i + 7 ] = y\n cPosition1[ i + 8 ] = z - cOffset\n cPosition2[ i + 6 ] = x\n cPosition2[ i + 7 ] = y\n cPosition2[ i + 8 ] = z + cOffset\n }\n\n if (!what || what.color) {\n const cimax = i + 9\n for (let ci = i; ci < cimax; ci += 3) {\n cColor[ ci ] = cColor2[ ci ] = color![ j ]\n cColor[ ci + 1 ] = cColor2[ ci + 1 ] = color![ j + 1 ]\n cColor[ ci + 2 ] = cColor2[ ci + 2 ] = color![ j + 2 ]\n }\n }\n\n if (!what || what.picking) {\n pickingArray[ j ] =\n pickingArray[ j + 1 ] =\n pickingArray[ j + 2 ] = picking!.array![ v ]\n }\n }\n\n if (!what || what.picking) {\n crossData.picking = new AtomPicker(\n pickingArray, picking!.structure\n )\n }\n\n return crossData\n }\n\n createData (sview: StructureView) {\n const what = { position: true, color: true, picking: true }\n\n const bufferList = []\n\n if (this.lines) {\n const bondData = sview.getBondData(this.getBondParams(what))\n\n const lineBuffer = new WideLineBuffer(\n bondData, this.getBufferParams({ linewidth: this.linewidth })\n )\n\n bufferList.push(lineBuffer)\n }\n\n if (this.crosses !== 'off') {\n const crossBuffer = new WideLineBuffer(\n (this._crossData(what, sview) as CrossData),\n this.getBufferParams({linewidth: this.linewidth})\n )\n bufferList.push(crossBuffer)\n }\n\n return {\n bufferList: bufferList\n }\n }\n\n updateData (what: any, data: StructureRepresentationData) {\n let bufferIdx = 0\n\n if (this.lines) {\n const bondData = data.sview!.getBondData(this.getBondParams(what))\n const lineAttributes = {}\n\n if (!what || what.position) {\n Object.assign(lineAttributes, {\n position1: bondData.position1,\n position2: bondData.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(lineAttributes, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n data.bufferList[ bufferIdx++ ].setAttributes(lineAttributes)\n }\n\n if (this.crosses !== 'off') {\n const crossData = this._crossData(what, (data.sview as StructureView))\n const crossAttributes = {}\n\n if (!what || what.position) {\n Object.assign(crossAttributes, {\n position1: crossData!.position1,\n position2: crossData!.position2\n })\n }\n if (!what || what.color) {\n Object.assign(crossAttributes, {\n color: crossData!.color,\n color2: crossData!.color2\n })\n }\n\n data.bufferList[ bufferIdx++ ].setAttributes(crossAttributes)\n }\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n if (params && (params.bondSpacing || params.crossSize)) {\n Object.assign(what, { position: true })\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('line', LineRepresentation)\n\nexport default LineRepresentation\n","import { NumberArray, TypedArray } from \"../types\";\n\n/**\n * @file Grid\n * @author Alexander Rose \n * @private\n */\nexport interface iGrid {\n data: TypedArray\n index: (x: number, y: number, z: number) => number\n set: (x: number, y: number, z: number, ...arg: number[]) => void\n toArray: (x: number, y: number, z: number, array?: NumberArray, offset?: number) => void\n fromArray: (x: number, y: number, z: number, array: NumberArray, offset?: number) => void\n copy: (grid: iGrid) => void\n // clone: () => iGrid\n}\n\nfunction makeGrid (length: number, width: number, height: number, DataCtor: any, elemSize: number) : iGrid {\n DataCtor = DataCtor || Int32Array\n elemSize = elemSize || 1\n\n const data = new DataCtor(length * width * height * elemSize)\n\n function index (x: number, y: number, z: number) {\n return ((((x * width) + y) * height) + z) * elemSize\n }\n\n function set (x: number, y: number, z: number, ...args: number[]) {\n const i = index(x, y, z)\n\n for (let j = 0; j < elemSize; ++j) {\n data[ i + j ] = args[ j ]\n }\n }\n\n function toArray (x: number, y: number, z: number, array: NumberArray = [], offset: number = 0) {\n const i = index(x, y, z)\n\n for (let j = 0; j < elemSize; ++j) {\n array[ offset + j ] = data[ i + j ]\n }\n }\n\n function fromArray(x: number, y: number, z: number, array: NumberArray, offset: number = 0) {\n const i = index(x, y, z)\n\n for (let j = 0; j < elemSize; ++j) {\n data[ i + j ] = array[ offset + j ]\n }\n }\n\n function copy(grid: iGrid) {\n data.set(grid.data)\n }\n\n // function clone() {\n // return makeGrid(\n // length, width, height, DataCtor, elemSize\n // ).copy(this)\n // }\n return { data, index, set, toArray, fromArray, copy }\n}\n\nexport { makeGrid }","/**\n * @file EDT Surface\n * @author Alexander Rose \n * @private\n */\n\nimport { VolumeSurface } from './volume'\nimport { iGrid, makeGrid } from '../geometry/grid'\nimport { computeBoundingBox } from '../math/vector-utils'\nimport { getRadiusDict, getSurfaceGrid } from './surface-utils'\nimport { TypedArray } from '../types';\n\ninterface EDTSurface {\n getVolume: (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean) => {\n data: TypedArray\n nx: number\n ny: number\n nz: number\n atomindex: TypedArray\n }\n getSurface: (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean, smooth: number, contour: boolean) => any\n}\n\nfunction EDTSurface (this: EDTSurface, coordList: Float32Array, radiusList: Float32Array, indexList: Uint16Array|Uint32Array) {\n // based on D. Xu, Y. Zhang (2009) Generating Triangulated Macromolecular\n // Surfaces by Euclidean Distance Transform. PLoS ONE 4(12): e8140.\n //\n // Permission to use, copy, modify, and distribute this program for\n // any purpose, with or without fee, is hereby granted, provided that\n // the notices on the head, the reference information, and this\n // copyright notice appear in all copies or substantial portions of\n // the Software. It is provided \"as is\" without express or implied\n // warranty.\n //\n // ported to JavaScript by biochem_fan (http://webglmol.sourceforge.jp/)\n // refactored by dkoes (https://github.com/dkoes)\n //\n // adapted to NGL by Alexander Rose\n\n var radiusDict = getRadiusDict(radiusList as any)\n var bbox = computeBoundingBox(coordList)\n if (coordList.length === 0) {\n bbox[ 0 ].set([ 0, 0, 0 ])\n bbox[ 1 ].set([ 0, 0, 0 ])\n }\n var min = bbox[ 0 ]\n var max = bbox[ 1 ]\n\n var probeRadius: number, scaleFactor: number, cutoff: number\n var pLength: number, pWidth: number, pHeight: number\n var matrix: Float32Array, ptran: Float32Array\n var depty: {[k: string]: TypedArray}, widxz: {[k: string]: number}\n var cutRadius: number\n var setAtomID: boolean\n var vpBits: TypedArray, vpDistance: TypedArray, vpAtomID: TypedArray\n\n function init (btype: boolean, _probeRadius: number, _scaleFactor: number, _cutoff: number, _setAtomID: boolean) {\n probeRadius = _probeRadius || 1.4\n scaleFactor = _scaleFactor || 2.0\n setAtomID = _setAtomID || true\n\n var maxRadius = 0\n for (var radius in radiusDict) {\n maxRadius = Math.max(maxRadius, radius as any)\n }\n\n var grid = getSurfaceGrid(\n min, max, maxRadius, scaleFactor, btype ? probeRadius : 0\n )\n\n pLength = grid.dim[0]\n pWidth = grid.dim[1]\n pHeight = grid.dim[2]\n\n matrix = grid.matrix\n ptran = grid.tran\n scaleFactor = grid.scaleFactor\n\n // boundingatom caches\n depty = {}\n widxz = {}\n boundingatom(btype)\n\n cutRadius = probeRadius * scaleFactor\n\n if (_cutoff) {\n cutoff = _cutoff\n } else {\n // cutoff = Math.max( 0.1, -1.2 + scaleFactor * probeRadius );\n cutoff = probeRadius / scaleFactor\n }\n\n vpBits = new Uint8Array(pLength * pWidth * pHeight)\n if (btype) {\n vpDistance = new Float64Array(pLength * pWidth * pHeight)\n }\n if (setAtomID) {\n vpAtomID = new Int32Array(pLength * pWidth * pHeight)\n }\n }\n\n // constants for vpBits bitmasks\n var INOUT = 1\n var ISDONE = 2\n var ISBOUND = 4\n\n var nb = [\n new Int32Array([ 1, 0, 0 ]), new Int32Array([ -1, 0, 0 ]),\n new Int32Array([ 0, 1, 0 ]), new Int32Array([ 0, -1, 0 ]),\n new Int32Array([ 0, 0, 1 ]), new Int32Array([ 0, 0, -1 ]),\n new Int32Array([ 1, 1, 0 ]), new Int32Array([ 1, -1, 0 ]),\n new Int32Array([ -1, 1, 0 ]), new Int32Array([ -1, -1, 0 ]),\n new Int32Array([ 1, 0, 1 ]), new Int32Array([ 1, 0, -1 ]),\n new Int32Array([ -1, 0, 1 ]), new Int32Array([ -1, 0, -1 ]),\n new Int32Array([ 0, 1, 1 ]), new Int32Array([ 0, 1, -1 ]),\n new Int32Array([ 0, -1, 1 ]), new Int32Array([ 0, -1, -1 ]),\n new Int32Array([ 1, 1, 1 ]), new Int32Array([ 1, 1, -1 ]),\n new Int32Array([ 1, -1, 1 ]), new Int32Array([ -1, 1, 1 ]),\n new Int32Array([ 1, -1, -1 ]), new Int32Array([ -1, -1, 1 ]),\n new Int32Array([ -1, 1, -1 ]), new Int32Array([ -1, -1, -1 ])\n ]\n\n //\n\n this.getVolume = function (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean) {\n console.time('EDTSurface.getVolume')\n\n var btype = type !== 'vws'\n\n init(btype, probeRadius, scaleFactor, cutoff, setAtomID)\n\n fillvoxels(btype)\n buildboundary()\n\n if (type === 'ms' || type === 'ses') {\n fastdistancemap()\n }\n\n if (type === 'ses') {\n boundingatom(false)\n fillvoxelswaals()\n }\n\n marchingcubeinit(type)\n\n // set atomindex in the volume data\n for (var i = 0, il = vpAtomID.length; i < il; ++i) {\n vpAtomID[ i ] = indexList[ vpAtomID[ i ] ]\n }\n\n console.timeEnd('EDTSurface.getVolume')\n\n return {\n data: vpBits,\n nx: pHeight,\n ny: pWidth,\n nz: pLength,\n atomindex: vpAtomID\n }\n }\n\n this.getSurface = function (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean, smooth: number, contour: boolean) {\n var vd = this.getVolume(\n type, probeRadius, scaleFactor, cutoff, setAtomID\n )\n\n var volsurf = new (VolumeSurface as any)(\n vd.data, vd.nx, vd.ny, vd.nz, vd.atomindex\n ) as VolumeSurface\n\n return (volsurf!.getSurface as any)(1, smooth, undefined, matrix, contour)\n }\n\n function boundingatom (btype: boolean) {\n var r\n var j\n var k\n var txz\n var tdept\n var sradius\n var tradius\n var widxzR\n var deptyName\n var indx\n\n for (var name in radiusDict) {\n r = parseFloat(name)\n\n if (depty[ name ]) continue\n\n if (!btype) {\n tradius = r * scaleFactor + 0.5\n } else {\n tradius = (r + probeRadius) * scaleFactor + 0.5\n }\n\n sradius = tradius * tradius\n widxzR = Math.floor(tradius) + 1\n deptyName = new Int32Array(widxzR * widxzR)\n indx = 0\n\n for (j = 0; j < widxzR; ++j) {\n for (k = 0; k < widxzR; ++k) {\n txz = j * j + k * k\n\n if (txz > sradius) {\n deptyName[ indx ] = -1\n } else {\n tdept = Math.sqrt(sradius - txz)\n deptyName[ indx ] = Math.floor(tdept)\n }\n\n ++indx\n }\n }\n\n widxz[ name ] = widxzR\n depty[ name ] = deptyName\n }\n }\n\n function fillatom (idx: number) {\n var ci = idx * 3\n var ri = idx\n\n var cx, cy, cz, ox, oy, oz, mi, mj, mk, i, j, k, si, sj, sk\n var ii, jj, kk\n\n cx = Math.floor(0.5 + scaleFactor * (coordList[ ci ] + ptran[0]))\n cy = Math.floor(0.5 + scaleFactor * (coordList[ ci + 1 ] + ptran[1]))\n cz = Math.floor(0.5 + scaleFactor * (coordList[ ci + 2 ] + ptran[2]))\n\n var at = radiusList[ ri ]\n var deptyAt = depty[ at ]\n var nind = 0\n var pWH = pWidth * pHeight\n var n = widxz[ at ]\n\n var deptyAtNind\n\n for (i = 0; i < n; ++i) {\n for (j = 0; j < n; ++j) {\n deptyAtNind = deptyAt[ nind ]\n\n if (deptyAtNind !== -1) {\n for (ii = -1; ii < 2; ++ii) {\n for (jj = -1; jj < 2; ++jj) {\n for (kk = -1; kk < 2; ++kk) {\n if (ii !== 0 && jj !== 0 && kk !== 0) {\n mi = ii * i\n mk = kk * j\n\n for (k = 0; k <= deptyAtNind; ++k) {\n mj = k * jj\n si = cx + mi\n sj = cy + mj\n sk = cz + mk\n\n if (si < 0 || sj < 0 || sk < 0 ||\n si >= pLength || sj >= pWidth || sk >= pHeight\n ) {\n continue\n }\n\n var index = si * pWH + sj * pHeight + sk\n\n if (!setAtomID) {\n vpBits[ index ] |= INOUT\n } else {\n if (!(vpBits[ index ] & INOUT)) {\n vpBits[ index ] |= INOUT\n vpAtomID[ index ] = idx\n } else if (vpBits[ index ] & INOUT) {\n var ci2 = vpAtomID[ index ]\n\n if (ci2 !== ci) {\n ox = cx + mi - Math.floor(0.5 + scaleFactor * (coordList[ci2] + ptran[0]))\n oy = cy + mj - Math.floor(0.5 + scaleFactor * (coordList[ci2 + 1] + ptran[1]))\n oz = cz + mk - Math.floor(0.5 + scaleFactor * (coordList[ci2 + 2] + ptran[2]))\n\n if (mi * mi + mj * mj + mk * mk < ox * ox + oy * oy + oz * oz) {\n vpAtomID[ index ] = idx\n }\n }\n }\n }\n } // k\n } // if\n } // kk\n } // jj\n } // ii\n } // if\n\n nind++\n } // j\n } // i\n }\n\n function fillvoxels (btype: boolean) {\n console.time('EDTSurface fillvoxels')\n\n var i, il\n\n for (i = 0, il = vpBits.length; i < il; ++i) {\n vpBits[ i ] = 0\n if (btype) vpDistance[ i ] = -1.0\n if (setAtomID) vpAtomID[ i ] = -1\n }\n\n for (i = 0, il = coordList.length / 3; i < il; ++i) {\n fillatom(i)\n }\n\n for (i = 0, il = vpBits.length; i < il; ++i) {\n if (vpBits[ i ] & INOUT) {\n vpBits[ i ] |= ISDONE\n }\n }\n\n console.timeEnd('EDTSurface fillvoxels')\n }\n\n function fillAtomWaals (idx: number) {\n var ci = idx * 3\n var ri = idx\n\n var cx\n var cy\n var cz\n var ox\n var oy\n var oz\n var nind = 0\n\n var mi\n var mj\n var mk\n var si\n var sj\n var sk\n var i\n var j\n var k\n var ii\n var jj\n var kk\n var n\n\n cx = Math.floor(0.5 + scaleFactor * (coordList[ ci ] + ptran[0]))\n cy = Math.floor(0.5 + scaleFactor * (coordList[ ci + 1 ] + ptran[1]))\n cz = Math.floor(0.5 + scaleFactor * (coordList[ ci + 2 ] + ptran[2]))\n\n var at = radiusList[ ri ]\n var pWH = pWidth * pHeight\n\n for (i = 0, n = widxz[at]; i < n; ++i) {\n for (j = 0; j < n; ++j) {\n if (depty[ at ][ nind ] !== -1) {\n for (ii = -1; ii < 2; ++ii) {\n for (jj = -1; jj < 2; ++jj) {\n for (kk = -1; kk < 2; ++kk) {\n if (ii !== 0 && jj !== 0 && kk !== 0) {\n mi = ii * i\n mk = kk * j\n\n for (k = 0; k <= depty[ at ][ nind ]; ++k) {\n mj = k * jj\n si = cx + mi\n sj = cy + mj\n sk = cz + mk\n\n if (si < 0 || sj < 0 || sk < 0 ||\n si >= pLength || sj >= pWidth || sk >= pHeight\n ) {\n continue\n }\n\n var index = si * pWH + sj * pHeight + sk\n\n if (!(vpBits[ index ] & ISDONE)) {\n vpBits[ index ] |= ISDONE\n if (setAtomID) vpAtomID[ index ] = idx\n } else if (setAtomID) {\n var ci2 = vpAtomID[ index ]\n\n ox = Math.floor(0.5 + scaleFactor * (coordList[ ci2 ] + ptran[0]))\n oy = Math.floor(0.5 + scaleFactor * (coordList[ ci2 + 1 ] + ptran[1]))\n oz = Math.floor(0.5 + scaleFactor * (coordList[ ci2 + 2 ] + ptran[2]))\n\n if (mi * mi + mj * mj + mk * mk < ox * ox + oy * oy + oz * oz) {\n vpAtomID[ index ] = idx\n }\n }\n } // k\n } // if\n } // kk\n } // jj\n } // ii\n } // if\n\n nind++\n } // j\n } // i\n }\n\n function fillvoxelswaals () {\n var i, il\n\n for (i = 0, il = vpBits.length; i < il; ++i) {\n vpBits[ i ] &= ~ISDONE // not isdone\n }\n\n for (i = 0, il = coordList.length / 3; i < il; ++i) {\n fillAtomWaals(i)\n }\n }\n\n function buildboundary () {\n var i, j, k\n var pWH = pWidth * pHeight\n\n for (i = 0; i < pLength; ++i) {\n for (j = 0; j < pHeight; ++j) {\n for (k = 0; k < pWidth; ++k) {\n var index = i * pWH + k * pHeight + j\n\n if (vpBits[ index ] & INOUT) {\n // var flagbound = false;\n var ii = 0\n\n // while( !flagbound && ii < 26 ){\n while (ii < 26) {\n var ti = i + nb[ ii ][ 0 ]\n var tj = j + nb[ ii ][ 2 ]\n var tk = k + nb[ ii ][ 1 ]\n\n if (ti > -1 && ti < pLength &&\n tk > -1 && tk < pWidth &&\n tj > -1 && tj < pHeight &&\n !(vpBits[ ti * pWH + tk * pHeight + tj ] & INOUT)\n ) {\n vpBits[ index ] |= ISBOUND\n // flagbound = true;\n break\n } else {\n ii++\n }\n }\n }\n } // k\n } // j\n } // i\n }\n\n function fastdistancemap () {\n console.time('EDTSurface fastdistancemap')\n\n var i, j, k, n\n\n var boundPoint = makeGrid(\n pLength, pWidth, pHeight, Uint16Array, 3\n )\n var pWH = pWidth * pHeight\n var cutRSq = cutRadius * cutRadius\n\n var totalsurfacevox = 0\n // var totalinnervox = 0;\n\n var index\n\n for (i = 0; i < pLength; ++i) {\n for (j = 0; j < pWidth; ++j) {\n for (k = 0; k < pHeight; ++k) {\n index = i * pWH + j * pHeight + k\n\n vpBits[ index ] &= ~ISDONE\n\n if (vpBits[ index ] & INOUT) {\n if (vpBits[ index ] & ISBOUND) {\n boundPoint.set(\n i, j, k,\n i, j, k\n )\n\n vpDistance[ index ] = 0\n vpBits[ index ] |= ISDONE\n\n totalsurfacevox += 1\n }/* else{\n totalinnervox += 1;\n } */\n }\n }\n }\n }\n\n var inarray = new Int32Array(3 * totalsurfacevox)\n var positin = 0\n var outarray = new Int32Array(3 * totalsurfacevox)\n var positout = 0\n\n for (i = 0; i < pLength; ++i) {\n for (j = 0; j < pWidth; ++j) {\n for (k = 0; k < pHeight; ++k) {\n index = i * pWH + j * pHeight + k\n\n if (vpBits[ index ] & ISBOUND) {\n inarray[ positin ] = i\n inarray[ positin + 1 ] = j\n inarray[ positin + 2 ] = k\n positin += 3\n\n vpBits[ index ] &= ~ISBOUND\n }\n }\n }\n }\n\n do {\n positout = fastoneshell(inarray, boundPoint, positin, outarray)\n positin = 0\n\n for (i = 0, n = positout; i < n; i += 3) {\n index = pWH * outarray[ i ] + pHeight * outarray[ i + 1 ] + outarray[ i + 2 ]\n vpBits[ index ] &= ~ISBOUND\n\n if (vpDistance[ index ] <= 1.0404 * cutRSq) {\n // if( vpDistance[ index ] <= 1.02 * cutRadius ){\n\n inarray[ positin ] = outarray[ i ]\n inarray[ positin + 1 ] = outarray[ i + 1 ]\n inarray[ positin + 2 ] = outarray[ i + 2 ]\n positin += 3\n }\n }\n } while (positin > 0)\n\n // var cutsf = Math.max( 0, scaleFactor - 0.5 );\n // cutoff = cutRadius - 0.5 / ( 0.1 + cutsf );\n var cutoffSq = cutoff * cutoff\n\n var index2\n var bp = new Uint16Array(3)\n\n for (i = 0; i < pLength; ++i) {\n for (j = 0; j < pWidth; ++j) {\n for (k = 0; k < pHeight; ++k) {\n index = i * pWH + j * pHeight + k\n vpBits[ index ] &= ~ISBOUND\n\n // ses solid\n\n if (vpBits[ index ] & INOUT) {\n if (!(vpBits[ index ] & ISDONE) ||\n ((vpBits[ index ] & ISDONE) && vpDistance[ index ] >= cutoffSq)\n ) {\n vpBits[ index ] |= ISBOUND\n\n if (setAtomID && (vpBits[ index ] & ISDONE)) {\n boundPoint.toArray(i, j, k, bp)\n index2 = bp[ 0 ] * pWH + bp[ 1 ] * pHeight + bp[ 2 ]\n\n vpAtomID[ index ] = vpAtomID[ index2 ]\n }\n }\n }\n }\n }\n }\n\n console.timeEnd('EDTSurface fastdistancemap')\n }\n\n function fastoneshell (inarray: Int32Array, boundPoint: iGrid, positin: number, outarray: Int32Array) {\n // *allocout,voxel2\n // ***boundPoint, int*\n // outnum, int *elimi)\n var tx, ty, tz\n var dx, dy, dz\n var i, j, n\n var square\n var index\n var nbj\n var bp = new Uint16Array(3)\n var positout = 0\n\n if (positin === 0) {\n return positout\n }\n\n var tnvix = -1\n var tnviy = -1\n var tnviz = -1\n\n var pWH = pWidth * pHeight\n\n for (i = 0, n = positin; i < n; i += 3) {\n tx = inarray[ i ]\n ty = inarray[ i + 1 ]\n tz = inarray[ i + 2 ]\n boundPoint.toArray(tx, ty, tz, bp)\n\n for (j = 0; j < 6; ++j) {\n nbj = nb[ j ]\n tnvix = tx + nbj[ 0 ]\n tnviy = ty + nbj[ 1 ]\n tnviz = tz + nbj[ 2 ]\n\n if (tnvix < pLength && tnvix > -1 &&\n tnviy < pWidth && tnviy > -1 &&\n tnviz < pHeight && tnviz > -1\n ) {\n index = tnvix * pWH + pHeight * tnviy + tnviz\n\n if ((vpBits[ index ] & INOUT) && !(vpBits[ index ] & ISDONE)) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n vpDistance[ index ] = square\n vpBits[ index ] |= ISDONE\n vpBits[ index ] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n } else if ((vpBits[ index ] & INOUT) && (vpBits[ index ] & ISDONE)) {\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n if (square < vpDistance[ index ]) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n vpDistance[ index ] = square\n\n if (!(vpBits[ index ] & ISBOUND)) {\n vpBits[ index ] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n }\n }\n }\n }\n }\n }\n\n for (i = 0, n = positin; i < n; i += 3) {\n tx = inarray[ i ]\n ty = inarray[ i + 1 ]\n tz = inarray[ i + 2 ]\n boundPoint.toArray(tx, ty, tz, bp)\n\n for (j = 6; j < 18; j++) {\n nbj = nb[ j ]\n tnvix = tx + nbj[ 0 ]\n tnviy = ty + nbj[ 1 ]\n tnviz = tz + nbj[ 2 ]\n\n if (tnvix < pLength && tnvix > -1 &&\n tnviy < pWidth && tnviy > -1 &&\n tnviz < pHeight && tnviz > -1\n ) {\n index = tnvix * pWH + pHeight * tnviy + tnviz\n\n if ((vpBits[index] & INOUT) && !(vpBits[index] & ISDONE)) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n vpDistance[index] = square\n vpBits[index] |= ISDONE\n vpBits[index] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n } else if ((vpBits[index] & INOUT) && (vpBits[index] & ISDONE)) {\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n if (square < vpDistance[index]) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n vpDistance[index] = square\n\n if (!(vpBits[index] & ISBOUND)) {\n vpBits[index] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n }\n }\n }\n }\n }\n }\n\n for (i = 0, n = positin; i < n; i += 3) {\n tx = inarray[ i ]\n ty = inarray[ i + 1 ]\n tz = inarray[ i + 2 ]\n boundPoint.toArray(tx, ty, tz, bp)\n\n for (j = 18; j < 26; j++) {\n nbj = nb[ j ]\n tnvix = tx + nbj[ 0 ]\n tnviy = ty + nbj[ 1 ]\n tnviz = tz + nbj[ 2 ]\n\n if (tnvix < pLength && tnvix > -1 &&\n tnviy < pWidth && tnviy > -1 &&\n tnviz < pHeight && tnviz > -1\n ) {\n index = tnvix * pWH + pHeight * tnviy + tnviz\n\n if ((vpBits[index] & INOUT) && !(vpBits[index] & ISDONE)) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n vpDistance[index] = square\n vpBits[index] |= ISDONE\n vpBits[index] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n } else if ((vpBits[index] & INOUT) && (vpBits[index] & ISDONE)) {\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n if (square < vpDistance[index]) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n vpDistance[index] = square\n\n if (!(vpBits[index] & ISBOUND)) {\n vpBits[index] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n }\n }\n }\n }\n }\n }\n\n return positout\n }\n\n function marchingcubeinit (stype: string) {\n var i\n var n = vpBits.length\n\n if (stype === 'vws') {\n for (i = 0; i < n; ++i) {\n vpBits[ i ] &= ~ISBOUND\n vpBits[ i ] = (vpBits[ i ] & ISDONE) ? 1 : 0\n }\n } else if (stype === 'ms') { // ses without vdw => ms\n for (i = 0; i < n; ++i) {\n vpBits[ i ] &= ~ISDONE\n if (vpBits[ i ] & ISBOUND) {\n vpBits[ i ] |= ISDONE\n }\n vpBits[ i ] &= ~ISBOUND\n vpBits[ i ] = (vpBits[ i ] & ISDONE) ? 1 : 0\n }\n } else if (stype === 'ses') {\n for (i = 0; i < n; ++i) {\n if ((vpBits[ i ] & ISBOUND) && (vpBits[ i ] & ISDONE)) {\n vpBits[ i ] &= ~ISBOUND\n } else if ((vpBits[ i ] & ISBOUND) && !(vpBits[ i ] & ISDONE)) {\n vpBits[ i ] |= ISDONE\n }\n vpBits[ i ] = (vpBits[ i ] & ISDONE) ? 1 : 0\n }\n } else if (stype === 'sas') {\n for (i = 0; i < n; ++i) {\n vpBits[ i ] &= ~ISBOUND\n vpBits[ i ] = (vpBits[ i ] & ISDONE) ? 1 : 0\n }\n }\n }\n}\nObject.assign(EDTSurface, {__deps: [\n getSurfaceGrid, getRadiusDict, VolumeSurface, computeBoundingBox, makeGrid\n]})\n\nexport default EDTSurface\n","/**\n * @file AV Surface\n * @author Fred Ludlow \n * @private\n */\n\nimport { getSurfaceGrid } from './surface-utils'\nimport { VolumeSurface } from './volume'\nimport { uniformArray } from '../math/array-utils'\nimport {\n computeBoundingBox, v3multiplyScalar, v3cross, v3normalize\n} from '../math/vector-utils'\nimport { defaults } from '../utils'\nimport { NumberArray } from '../types';\n\n\n/**\n * Modifed from SpatialHash\n *\n * Main differences are:\n * - Optimized grid size to ensure we only ever need to look +/-1 cell\n * - Aware of atomic radii and will only output atoms within rAtom + rExtra\n * (see withinRadii method)\n *\n * (Uses rounding rather than bitshifting as consequence of arbitrary grid size)\n * @class\n * @param {Float32Array} atomsX - x coordinates\n * @param {Float32Array} atomsY - y coordinates\n * @param {Float32Array} atomsZ - z coordinates\n * @param {Float32Array} atomsR - atom radii\n * @param {Float32Array} min - xyz min coordinates\n * @param {Float32Array} max - xyz max coordinates\n * @param {Float} maxDistance - max distance\n */\nexport interface iAVHash {\n neighbourListLength: number\n withinRadii: (x: number, y: number, z: number, rExtra: number, out: Int32Array) => void\n}\n\n\nfunction makeAVHash (atomsX: Float32Array, atomsY: Float32Array, atomsZ: Float32Array, atomsR: Float32Array, min: Float32Array, max: Float32Array, maxDistance: number): iAVHash {\n maxDistance = Math.max(0.1, maxDistance) // Avoid maxDistance of zero, see #802\n var nAtoms = atomsX.length\n\n var minX = min[ 0 ]\n var minY = min[ 1 ]\n var minZ = min[ 2 ]\n\n var maxX = max[ 0 ]\n var maxY = max[ 1 ]\n var maxZ = max[ 2 ]\n\n function hashFunc (w: number, minW: number) {\n return Math.floor((w - minW) / maxDistance)\n }\n\n var iDim = hashFunc(maxX, minX) + 1\n var jDim = hashFunc(maxY, minY) + 1\n var kDim = hashFunc(maxZ, minZ) + 1\n\n var nCells = iDim * jDim * kDim\n\n var jkDim = jDim * kDim\n\n /* Get cellID for cartesian x,y,z */\n var cellID = function (x: number, y: number, z: number) {\n return (((hashFunc(x, minX) * jDim) + hashFunc(y, minY)) * kDim) + hashFunc(z, minZ)\n }\n\n /* Initial building, could probably be optimized further */\n var preHash = [] // preHash[ cellID ] = [ atomId1, atomId2 ];\n\n for (var i = 0; i < nAtoms; i++) {\n var cid = cellID(atomsX[ i ], atomsY[ i ], atomsZ[ i ])\n\n if (preHash[ cid ] === undefined) {\n preHash[ cid ] = [ i ]\n } else {\n preHash[ cid ].push(i)\n }\n }\n\n var cellOffsets = new Uint32Array(nCells)\n var cellLengths = new Uint16Array(nCells)\n var data = new Uint32Array(nAtoms)\n\n var offset = 0\n var maxCellLength = 0\n\n for (i = 0; i < nCells; i++) {\n var start = cellOffsets[ i ] = offset\n\n var subArray = preHash[ i ]\n\n if (subArray !== undefined) {\n for (var j = 0; j < subArray.length; j++) {\n data[ offset ] = subArray[ j ]\n offset++\n }\n }\n\n var cellLength = offset - start\n cellLengths[ i ] = cellLength\n\n if (cellLength > maxCellLength) { maxCellLength = cellLength }\n }\n\n // Maximum number of neighbours we could ever produce (27 adjacent cells of equal population)\n const neighbourListLength = (27 * maxCellLength) + 1\n\n /**\n * Populate the supplied out array with atom indices that are within rAtom + rExtra\n * of x,y,z\n *\n * -1 in out array indicates the end of the list\n *\n * @param {Float} x - x coordinate\n * @param {Float} y - y coordinate\n * @param {Float} z - z coordinate\n * @param {Float} rExtra - additional radius\n * @param {Float32Array} out - pre-allocated output array\n * @return {undefined}\n */\n const withinRadii = function (x: number, y: number, z: number, rExtra: number, out: Int32Array) {\n var outIdx = 0\n\n var nearI = hashFunc(x, minX)\n var nearJ = hashFunc(y, minY)\n var nearK = hashFunc(z, minZ)\n\n var loI = Math.max(0, nearI - 1)\n var loJ = Math.max(0, nearJ - 1)\n var loK = Math.max(0, nearK - 1)\n\n var hiI = Math.min(iDim, nearI + 2)\n var hiJ = Math.min(jDim, nearJ + 2)\n var hiK = Math.min(kDim, nearK + 2)\n\n for (var i = loI; i < hiI; ++i) {\n var iOffset = i * jkDim\n\n for (var j = loJ; j < hiJ; ++j) {\n var jOffset = j * kDim\n\n for (var k = loK; k < hiK; ++k) {\n var cid = iOffset + jOffset + k\n\n var cellStart = cellOffsets[ cid ]\n var cellEnd = cellStart + cellLengths[ cid ]\n\n for (var dataIndex = cellStart; dataIndex < cellEnd; dataIndex++) {\n var atomIndex = data[ dataIndex ]\n var dx = atomsX[ atomIndex ] - x\n var dy = atomsY[ atomIndex ] - y\n var dz = atomsZ[ atomIndex ] - z\n var rSum = atomsR[ atomIndex ] + rExtra\n\n if ((dx * dx + dy * dy + dz * dz) <= (rSum * rSum)) {\n out[ outIdx++ ] = data[ dataIndex ]\n }\n }\n }\n }\n }\n // Add terminator\n out[ outIdx ] = -1\n }\n return {\n neighbourListLength: neighbourListLength,\n withinRadii: withinRadii\n }\n}\n\ninterface AVSurface {\n getSurface: (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean, smooth: number, contour: boolean) => any\n}\nfunction AVSurface (this: AVSurface, coordList: Float32Array, radiusList: Float32Array, indexList: Uint16Array|Uint32Array) {\n // Field generation method adapted from AstexViewer (Mike Hartshorn)\n // by Fred Ludlow.\n // Other parts based heavily on NGL (Alexander Rose) EDT Surface class\n //\n // Should work as a drop-in alternative to EDTSurface (though some of\n // the EDT paramters are not relevant in this method).\n\n const nAtoms = radiusList.length\n\n const x = new Float32Array(nAtoms)\n const y = new Float32Array(nAtoms)\n const z = new Float32Array(nAtoms)\n\n for (let i = 0; i < nAtoms; i++) {\n const ci = 3 * i\n x[ i ] = coordList[ ci ]\n y[ i ] = coordList[ ci + 1 ]\n z[ i ] = coordList[ ci + 2 ]\n }\n\n let bbox = computeBoundingBox(coordList)\n if (coordList.length === 0) {\n bbox[ 0 ].set([ 0, 0, 0 ])\n bbox[ 1 ].set([ 0, 0, 0 ])\n }\n const min = bbox[0]\n const max = bbox[1]\n\n let r: Float32Array, r2: Float32Array // Atom positions, expanded radii (squared)\n let maxRadius: number\n\n // Parameters\n let probeRadius: number, scaleFactor: number, setAtomID: boolean, probePositions: number\n\n // Cache last value for obscured test\n let lastClip = -1\n\n // Grid params\n let dim: Float32Array, matrix: Float32Array, grid: NumberArray, atomIndex: Int32Array\n\n // grid indices -> xyz coords\n let gridx: Float32Array, gridy: Float32Array, gridz: Float32Array\n\n // Lookup tables:\n let sinTable: Float32Array, cosTable: Float32Array\n\n // Spatial Hash\n let hash: iAVHash\n\n // Neighbour array to be filled by hash\n let neighbours: Int32Array\n\n // Vectors for Torus Projection\n const atob = new Float32Array([ 0.0, 0.0, 0.0 ])\n const mid = new Float32Array([ 0.0, 0.0, 0.0 ])\n const n1 = new Float32Array([ 0.0, 0.0, 0.0 ])\n const n2 = new Float32Array([ 0.0, 0.0, 0.0 ])\n\n let ngTorus: number\n\n function init (_probeRadius?: number, _scaleFactor?: number, _setAtomID?: boolean, _probePositions?: number) {\n probeRadius = defaults(_probeRadius, 1.4)\n scaleFactor = defaults(_scaleFactor, 2.0)\n setAtomID = defaults(_setAtomID, true)\n probePositions = defaults(_probePositions, 30)\n\n r = new Float32Array(nAtoms)\n r2 = new Float32Array(nAtoms)\n\n for (let i = 0; i < r.length; ++i) {\n var rExt = radiusList[ i ] + probeRadius\n r[ i ] = rExt\n r2[ i ] = rExt * rExt\n }\n\n maxRadius = 0\n for (let j = 0; j < r.length; ++j) {\n if (r[ j ] > maxRadius) maxRadius = r[ j ]\n }\n\n initializeGrid()\n initializeAngleTables()\n initializeHash()\n\n lastClip = -1\n }\n\n function fillGridDim (a: Float32Array, start: number, step: number) {\n for (let i = 0; i < a.length; i++) {\n a[i] = start + (step * i)\n }\n }\n\n function initializeGrid () {\n const surfGrid = getSurfaceGrid(\n min, max, maxRadius, scaleFactor, 0.0\n )\n\n scaleFactor = surfGrid.scaleFactor\n dim = surfGrid.dim\n matrix = surfGrid.matrix\n\n ngTorus = Math.max(5, 2 + Math.floor(probeRadius * scaleFactor))\n\n grid = uniformArray(dim[0] * dim[1] * dim[2], -1001.0)\n\n atomIndex = new Int32Array(grid.length)\n\n gridx = new Float32Array(dim[0])\n gridy = new Float32Array(dim[1])\n gridz = new Float32Array(dim[2])\n\n fillGridDim(gridx, min[0], 1 / scaleFactor)\n fillGridDim(gridy, min[1], 1 / scaleFactor)\n fillGridDim(gridz, min[2], 1 / scaleFactor)\n }\n\n function initializeAngleTables () {\n var theta = 0.0\n var step = 2 * Math.PI / probePositions\n\n cosTable = new Float32Array(probePositions)\n sinTable = new Float32Array(probePositions)\n for (var i = 0; i < probePositions; i++) {\n cosTable[ i ] = Math.cos(theta)\n sinTable[ i ] = Math.sin(theta)\n theta += step\n }\n }\n\n function initializeHash () {\n hash = makeAVHash(x, y, z, r, min, max, 2.01 * maxRadius)\n neighbours = new Int32Array(hash.neighbourListLength)\n }\n\n function obscured (x: number, y: number, z: number, a: number, b: number) {\n // Is the point at x,y,z obscured by any of the atoms\n // specifeid by indices in neighbours. Ignore indices\n // a and b (these are the relevant atoms in projectPoints/Torii)\n\n // Cache the last clipped atom (as very often the same one in\n // subsequent calls)\n let ai: number\n\n if (lastClip !== -1) {\n ai = lastClip\n if (ai !== a && ai !== b && singleAtomObscures(ai, x, y, z)) {\n return ai\n } else {\n lastClip = -1\n }\n }\n\n var ni = 0\n ai = neighbours[ ni ]\n while (ai >= 0) {\n if (ai !== a && ai !== b && singleAtomObscures(ai, x, y, z)) {\n lastClip = ai\n return ai\n }\n ai = neighbours[ ++ni ]\n }\n\n lastClip = -1\n\n return -1\n }\n\n function singleAtomObscures (ai: number, x: number, y: number, z: number) {\n var ci = 3 * ai\n var ra2 = r2[ ai ]\n var dx = coordList[ ci ] - x\n var dy = coordList[ ci + 1 ] - y\n var dz = coordList[ ci + 2 ] - z\n var d2 = dx * dx + dy * dy + dz * dz\n\n return d2 < ra2\n }\n\n function projectPoints () {\n // For each atom:\n // Iterate over a subsection of the grid, for each point:\n // If current value < 0.0, unvisited, set positive\n //\n // In any case: Project this point onto surface of the atomic sphere\n // If this projected point is not obscured by any other atom\n // Calcualte delta distance and set grid value to minimum of\n // itself and delta\n\n // Should we alias frequently accessed closure variables??\n // Assume JS engine capable of optimizing this\n // anyway...\n\n for (var i = 0; i < nAtoms; i++) {\n var ax = x[ i ]\n var ay = y[ i ]\n var az = z[ i ]\n var ar = r[ i ]\n var ar2 = r2[ i ]\n\n hash.withinRadii(ax, ay, az, ar, neighbours)\n\n // Number of grid points, round this up...\n var ng = Math.ceil(ar * scaleFactor)\n\n // Center of the atom, mapped to grid points (take floor)\n var iax = Math.floor(scaleFactor * (ax - min[ 0 ]))\n var iay = Math.floor(scaleFactor * (ay - min[ 1 ]))\n var iaz = Math.floor(scaleFactor * (az - min[ 2 ]))\n\n // Extents of grid to consider for this atom\n var minx = Math.max(0, iax - ng)\n var miny = Math.max(0, iay - ng)\n var minz = Math.max(0, iaz - ng)\n\n // Add two to these points:\n // - iax are floor'd values so this ensures coverage\n // - these are loop limits (exclusive)\n var maxx = Math.min(dim[ 0 ], iax + ng + 2)\n var maxy = Math.min(dim[ 1 ], iay + ng + 2)\n var maxz = Math.min(dim[ 2 ], iaz + ng + 2)\n\n for (var ix = minx; ix < maxx; ix++) {\n var dx = gridx[ ix ] - ax\n var xoffset = dim[ 1 ] * dim[ 2 ] * ix\n\n for (var iy = miny; iy < maxy; iy++) {\n var dy = gridy[ iy ] - ay\n var dxy2 = dx * dx + dy * dy\n var xyoffset = xoffset + dim[ 2 ] * iy\n\n for (var iz = minz; iz < maxz; iz++) {\n var dz = gridz[ iz ] - az\n var d2 = dxy2 + dz * dz\n\n if (d2 < ar2) {\n var idx = iz + xyoffset\n\n if (grid[idx] < 0.0) {\n // Unvisited, make positive\n grid[ idx ] = -grid[ idx ]\n }\n // Project on to the surface of the sphere\n // sp is the projected point ( dx, dy, dz ) * ( ra / d )\n var d = Math.sqrt(d2)\n var ap = ar / d\n var spx = dx * ap\n var spy = dy * ap\n var spz = dz * ap\n\n spx += ax\n spy += ay\n spz += az\n\n if (obscured(spx, spy, spz, i, -1) === -1) {\n var dd = ar - d\n if (dd < grid[ idx ]) {\n grid[ idx ] = dd\n if (setAtomID) atomIndex[ idx ] = i\n }\n }\n }\n }\n }\n }\n }\n }\n\n function projectTorii () {\n for (var i = 0; i < nAtoms; i++) {\n hash.withinRadii(x[ i ], y[ i ], z[ i ], r[ i ], neighbours)\n var ia = 0\n var ni = neighbours[ ia ]\n while (ni >= 0) {\n if (i < ni) {\n projectTorus(i, ni)\n }\n ni = neighbours[ ++ia ]\n }\n }\n }\n\n function projectTorus (a: number, b: number) {\n var r1 = r[ a ]\n var r2 = r[ b ]\n var dx = atob[ 0 ] = x[ b ] - x[ a ]\n var dy = atob[ 1 ] = y[ b ] - y[ a ]\n var dz = atob[ 2 ] = z[ b ] - z[ a ]\n var d2 = dx * dx + dy * dy + dz * dz\n\n // This check now redundant as already done in AVHash.withinRadii\n // if( d2 > (( r1 + r2 ) * ( r1 + r2 )) ){ return; }\n\n var d = Math.sqrt(d2)\n\n // Find angle between a->b vector and the circle\n // of their intersection by cosine rule\n var cosA = (r1 * r1 + d * d - r2 * r2) / (2.0 * r1 * d)\n\n // distance along a->b at intersection\n var dmp = r1 * cosA\n\n v3normalize(atob, atob)\n\n // Create normal to line\n normalToLine(n1 as any, atob)\n v3normalize(n1, n1)\n\n // Cross together for second normal vector\n v3cross(n2, atob, n1)\n v3normalize(n2, n2)\n\n // r is radius of circle of intersection\n var rInt = Math.sqrt(r1 * r1 - dmp * dmp)\n\n v3multiplyScalar(n1, n1, rInt)\n v3multiplyScalar(n2, n2, rInt)\n v3multiplyScalar(atob, atob, dmp)\n\n mid[ 0 ] = atob[ 0 ] + x[ a ]\n mid[ 1 ] = atob[ 1 ] + y[ a ]\n mid[ 2 ] = atob[ 2 ] + z[ a ]\n\n lastClip = -1\n\n var ng = ngTorus\n\n for (var i = 0; i < probePositions; i++) {\n var cost = cosTable[ i ]\n var sint = sinTable[ i ]\n\n var px = mid[ 0 ] + cost * n1[ 0 ] + sint * n2[ 0 ]\n var py = mid[ 1 ] + cost * n1[ 1 ] + sint * n2[ 1 ]\n var pz = mid[ 2 ] + cost * n1[ 2 ] + sint * n2[ 2 ]\n\n if (obscured(px, py, pz, a, b) === -1) {\n // As above, iterate over our grid...\n // px, py, pz in grid coords\n var iax = Math.floor(scaleFactor * (px - min[ 0 ]))\n var iay = Math.floor(scaleFactor * (py - min[ 1 ]))\n var iaz = Math.floor(scaleFactor * (pz - min[ 2 ]))\n\n var minx = Math.max(0, iax - ng)\n var miny = Math.max(0, iay - ng)\n var minz = Math.max(0, iaz - ng)\n\n var maxx = Math.min(dim[ 0 ], iax + ng + 2)\n var maxy = Math.min(dim[ 1 ], iay + ng + 2)\n var maxz = Math.min(dim[ 2 ], iaz + ng + 2)\n\n for (var ix = minx; ix < maxx; ix++) {\n dx = px - gridx[ ix ]\n var xoffset = dim[ 1 ] * dim[ 2 ] * ix\n\n for (var iy = miny; iy < maxy; iy++) {\n dy = py - gridy[ iy ]\n var dxy2 = dx * dx + dy * dy\n var xyoffset = xoffset + dim[ 2 ] * iy\n\n for (var iz = minz; iz < maxz; iz++) {\n dz = pz - gridz[ iz ]\n d2 = dxy2 + dz * dz\n var idx = iz + xyoffset\n var current = grid[ idx ]\n\n if (current > 0.0 && d2 < (current * current)) {\n grid[ idx ] = Math.sqrt(d2)\n if (setAtomID) {\n // Is this grid point closer to a or b?\n // Take dot product of atob and gridpoint->p (dx, dy, dz)\n const dp = dx * atob[ 0 ] + dy * atob [ 1 ] + dz * atob[ 2 ]\n atomIndex[ idx ] = dp < 0.0 ? b : a\n }\n }\n }\n }\n }\n }\n }\n }\n\n function normalToLine (out: Int32Array, p: Float32Array) {\n out[ 0 ] = out[ 1 ] = out[ 2 ] = 1.0\n if (p[ 0 ] !== 0) {\n out[ 0 ] = (p[ 1 ] + p[ 2 ]) / -p[ 0 ]\n } else if (p[ 1 ] !== 0) {\n out[ 1 ] = (p[ 0 ] + p[ 2 ]) / -p[ 1 ]\n } else if (p[ 2 ] !== 0) {\n out[ 2 ] = (p[ 0 ] + p[ 1 ]) / -p[ 2 ]\n }\n return out\n }\n\n function fixNegatives () {\n for (var i = 0; i < grid.length; i++) {\n if (grid[ i ] < 0) grid[ i ] = 0\n }\n }\n\n function fixAtomIDs () {\n for (var i = 0; i < atomIndex.length; i++) {\n atomIndex[ i ] = indexList[ atomIndex[ i ] ]\n }\n }\n\n function getVolume (probeRadius: number, scaleFactor: number, setAtomID: boolean) {\n // Basic steps are:\n // 1) Initialize\n // 2) Project points\n // 3) Project torii\n\n console.time('AVSurface.getVolume')\n\n console.time('AVSurface.init')\n init(probeRadius, scaleFactor, setAtomID)\n console.timeEnd('AVSurface.init')\n\n console.time('AVSurface.projectPoints')\n projectPoints()\n console.timeEnd('AVSurface.projectPoints')\n\n console.time('AVSurface.projectTorii')\n projectTorii()\n console.timeEnd('AVSurface.projectTorii')\n fixNegatives()\n fixAtomIDs()\n\n console.timeEnd('AVSurface.getVolume')\n }\n\n this.getSurface = function (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean, smooth: number, contour: boolean) {\n // type and cutoff left in for compatibility with EDTSurface.getSurface\n // function signature\n\n getVolume(probeRadius, scaleFactor, setAtomID)\n\n var volsurf = new (VolumeSurface as any)(\n grid, dim[ 2 ], dim[ 1 ], dim[ 0 ], atomIndex\n ) as VolumeSurface\n\n return volsurf.getSurface!(probeRadius, false, undefined, matrix, contour)\n }\n}\nObject.assign(AVSurface, {__deps: [\n getSurfaceGrid, VolumeSurface, uniformArray, computeBoundingBox,\n v3multiplyScalar, v3cross, v3normalize,\n makeAVHash,\n defaults\n]})\n\nexport { AVSurface, makeAVHash }\n","/**\n * @file Molecular Surface\n * @author Alexander Rose \n * @private\n */\n\nimport { WorkerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Worker from '../worker/worker'\nimport EDTSurface from './edt-surface'\nimport { AVSurface } from './av-surface'\nimport Surface, { SurfaceData } from './surface'\nimport { Structure } from '../ngl';\nimport { AtomData, RadiusParams } from '../structure/structure-data';\n\nWorkerRegistry.add('molsurf', function func (e: any, callback: (data: any, buffers: any[])=> void) {\n const a = e.data.args\n const p = e.data.params\n if (a && p) {\n const SurfClass = (p.type === 'av') ? AVSurface : EDTSurface\n const surf = new (SurfClass as any)(a.coordList, a.radiusList, a.indexList) as AVSurface|EDTSurface\n const sd = surf.getSurface(\n p.type, p.probeRadius, p.scaleFactor, p.cutoff, true, p.smooth, p.contour\n ) as SurfaceData\n const transferList = [ sd.position.buffer, sd.index!.buffer ]\n if (sd.normal) transferList.push(sd.normal.buffer)\n if (sd.atomindex) transferList.push(sd.atomindex.buffer)\n const data = {\n sd: sd,\n p: p\n }\n callback(data, transferList)\n }\n}, [ EDTSurface, AVSurface ])\n\n/**\n * Molecular surface parameter object.\n * @typedef {Object} MolecularSurfaceParameters - stage parameters\n * @property {String} type - \"av\" or \"edt\"\n * @property {Number} probeRadius - probe radius\n * @property {Number} scaleFactor - higher for better quality\n * @property {Integer} smooth - number of smoothing cycles to apply\n * @property {String} name - name for created surface\n */\nexport interface MolecularSurfaceParameters {\n type: 'av'|'edt'\n probeRadius: number\n scaleFactor: number\n smooth: number\n name: string\n cutoff: number\n contour: boolean,\n radiusParams: RadiusParams\n}\n/**\n * Create Molecular surfaces\n */\nclass MolecularSurface {\n structure: Structure\n worker: Worker|undefined\n\n constructor (structure: Structure) {\n this.structure = structure\n }\n\n _getAtomData (params: Partial): AtomData {\n return this.structure.getAtomData({\n what: { position: true, radius: true, index: true },\n radiusParams: defaults(params.radiusParams, {\n type: 'vdw', scale: 1.0\n })\n })\n }\n\n _makeSurface (sd: SurfaceData, p: Partial) {\n var surface = new Surface(p.name!, '', sd)\n\n surface.info.type = p.type\n surface.info.probeRadius = p.probeRadius\n surface.info.scaleFactor = p.scaleFactor\n surface.info.smooth = p.smooth\n surface.info.cutoff = p.cutoff\n\n return surface\n }\n\n /**\n * Get molecular surface\n * @param {MolecularSurfaceParameters} params - parameters for surface creation\n * @return {Surface} the surface\n */\n getSurface (params: Partial) {\n const p = params || {}\n\n const atomData = this._getAtomData(params)\n const coordList = atomData.position\n const radiusList = atomData.radius\n const indexList = atomData.index\n\n const SurfClass = (p.type === 'av') ? AVSurface : EDTSurface\n const surf = new (SurfClass as any)(coordList, radiusList, indexList) as AVSurface|EDTSurface\n const sd = surf.getSurface(\n p.type!, p.probeRadius!, p.scaleFactor!, p.cutoff!, true, p.smooth!, p.contour!\n )\n\n return this._makeSurface(sd, p)\n }\n\n /**\n * Get molecular surface asynchronous\n * @param {MolecularSurfaceParameters} params - parameters for surface creation\n * @param {function(surface: Surface)} callback - function to be called after surface is created\n * @return {undefined}\n */\n getSurfaceWorker (params: MolecularSurfaceParameters, callback: (s: Surface) => void) {\n const p = Object.assign({}, params)\n\n if (window.hasOwnProperty('Worker')) {\n if (this.worker === undefined) {\n this.worker = new Worker('molsurf')\n }\n\n const atomData = this._getAtomData(params)\n const coordList = atomData.position\n const radiusList = atomData.radius\n const indexList = atomData.index\n\n const msg = {\n args: {\n coordList: coordList,\n radiusList: radiusList,\n indexList: indexList\n },\n params: p\n }\n\n const transferList = [\n coordList!.buffer, radiusList!.buffer, indexList!.buffer\n ]\n\n this.worker.post(msg, transferList,\n\n (e: any) => {\n callback(this._makeSurface(e.data.sd, p))\n },\n\n (e: string) => {\n console.warn(\n 'MolecularSurface.getSurfaceWorker error - trying without worker', e\n )\n this.worker!.terminate()\n this.worker = undefined\n const surface = this.getSurface(p)\n callback(surface)\n }\n\n )\n } else {\n const surface = this.getSurface(p)\n callback(surface)\n }\n }\n\n /**\n * Cleanup\n * @return {undefined}\n */\n dispose () {\n if (this.worker) this.worker.terminate()\n }\n}\n\nexport default MolecularSurface\n","/**\n * @file Molecular Surface Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport MolecularSurface, { MolecularSurfaceParameters } from '../surface/molecular-surface'\nimport SurfaceBuffer from '../buffer/surface-buffer'\nimport ContourBuffer from '../buffer/contour-buffer'\nimport DoubleSidedBuffer from '../buffer/doublesided-buffer'\nimport Selection from '../selection/selection'\nimport Viewer from '../viewer/viewer';\n// @ts-ignore: unused import Volume required for declaration only\nimport { Structure, Vector3, Volume } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport { SurfaceDataFields } from './surface-representation';\nimport Surface, {SurfaceData} from '../surface/surface';\n\nexport interface MolecularSurfaceRepresentationParameters extends StructureRepresentationParameters {\n surfaceType: 'vws'|'sas'|'ms'|'ses'|'av'\n probeRadius: number\n smooth: number\n scaleFactor: number\n cutoff: number\n contour: boolean\n background: boolean\n opaqueBack: boolean\n filterSele: string\n colorVolume: any\n useWorker: boolean\n}\n\nexport interface MolecularSurfaceInfo {\n molsurf?: MolecularSurface\n sele?: string\n surface?: Surface\n}\n\n/**\n * Molecular Surface Representation\n */\nclass MolecularSurfaceRepresentation extends StructureRepresentation {\n protected surfaceType: 'vws'|'sas'|'ms'|'ses'|'av'\n protected probeRadius: number\n protected smooth: number\n protected scaleFactor: number\n protected cutoff: number\n protected contour: boolean\n protected background: boolean\n protected opaqueBack: boolean\n protected filterSele: string\n protected colorVolume: any\n protected useWorker: boolean\n\n protected __infoList: MolecularSurfaceInfo[]\n protected __forceNewMolsurf: boolean\n protected __sele: string\n protected __surfaceParams: string\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'surface'\n\n this.parameters = Object.assign({\n\n surfaceType: {\n type: 'select',\n rebuild: true,\n options: {\n 'vws': 'vws',\n 'sas': 'sas',\n 'ms': 'ms',\n 'ses': 'ses',\n 'av': 'av'\n }\n },\n probeRadius: {\n type: 'number',\n precision: 1,\n max: 20,\n min: 0,\n rebuild: true\n },\n smooth: {\n type: 'integer',\n precision: 1,\n max: 10,\n min: 0,\n rebuild: true\n },\n scaleFactor: {\n type: 'number',\n precision: 1,\n max: 5,\n min: 0,\n rebuild: true\n },\n cutoff: {\n type: 'number',\n precision: 2,\n max: 50,\n min: 0,\n rebuild: true\n },\n contour: {\n type: 'boolean', rebuild: true\n },\n background: {\n type: 'boolean', rebuild: true // FIXME\n },\n opaqueBack: {\n type: 'boolean', buffer: true\n },\n filterSele: {\n type: 'text', rebuild: true\n },\n colorVolume: {\n type: 'hidden'\n },\n useWorker: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n\n radius: null,\n scale: null\n\n })\n\n this.__infoList = []\n\n // TODO find a more direct way\n this.structure.signals.refreshed.add(() => {\n this.__forceNewMolsurf = true\n })\n\n this.toBePrepared = true\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'uniform')\n p.colorValue = defaults(p.colorValue, 0xDDDDDD)\n p.disablePicking = defaults(p.disablePicking, true)\n\n this.surfaceType = defaults(p.surfaceType, 'ms')\n this.probeRadius = defaults(p.probeRadius, 1.4)\n this.smooth = defaults(p.smooth, 2)\n this.scaleFactor = defaults(p.scaleFactor, 2.0)\n this.cutoff = defaults(p.cutoff, 0.0)\n this.contour = defaults(p.contour, false)\n this.background = defaults(p.background, false)\n this.opaqueBack = defaults(p.opaqueBack, true)\n this.filterSele = defaults(p.filterSele, '')\n this.colorVolume = defaults(p.colorVolume, undefined)\n this.useWorker = defaults(p.useWorker, true)\n\n super.init(params)\n }\n\n prepareData (sview: StructureView, i: number, callback: (i: number) => void) {\n let info: MolecularSurfaceInfo = this.__infoList[ i ]\n if (!info) {\n info = {}\n this.__infoList[ i ] = info\n }\n\n if (!info.molsurf || info.sele !== sview.selection.string) {\n if (this.filterSele) {\n const sviewFilter = sview.structure.getView(new Selection(this.filterSele))\n const bbSize = sviewFilter.boundingBox.getSize(new Vector3())\n const maxDim = Math.max(bbSize.x, bbSize.y, bbSize.z)\n const asWithin = sview.getAtomSetWithinPoint(sviewFilter.center, (maxDim / 2) + 6.0)\n sview = sview.getView(\n new Selection(sview.getAtomSetWithinSelection(asWithin, 3).toSeleString())\n )\n if (sview.atomCount === 0) {\n callback(i)\n return\n }\n }\n\n info.sele = sview.selection.string\n info.molsurf = new MolecularSurface(sview)\n\n const p = this.getSurfaceParams()\n const onSurfaceFinish = (surface: Surface) => {\n info.surface = surface\n callback(i)\n }\n\n if (this.useWorker) {\n info.molsurf.getSurfaceWorker(p as MolecularSurfaceParameters, onSurfaceFinish)\n } else {\n onSurfaceFinish(info.molsurf.getSurface(p as {name: string, type: 'av'|'edt' } & MolecularSurfaceRepresentationParameters))\n }\n } else {\n callback(i)\n }\n }\n\n prepare (callback: () => void) {\n if (this.__forceNewMolsurf || this.__sele !== this.selection.string ||\n this.__surfaceParams !== JSON.stringify(this.getSurfaceParams())) {\n this.__infoList.forEach((info: MolecularSurfaceInfo) => {\n if (info && info.molsurf) {\n info.molsurf.dispose()\n }\n })\n this.__infoList.length = 0\n }\n\n if (this.structureView.atomCount === 0) {\n callback()\n return\n }\n\n const after = () => {\n this.__sele = this.selection.string\n this.__surfaceParams = JSON.stringify(this.getSurfaceParams())\n this.__forceNewMolsurf = false\n callback()\n }\n\n const name = this.assembly === 'default' ? this.defaultAssembly : this.assembly\n const assembly = this.structure.biomolDict[ name ]\n\n if (assembly) {\n assembly.partList.forEach((part, i) => {\n const sview = part.getView(this.structureView)\n this.prepareData(sview as StructureView, i, (_i) => {\n if (_i === assembly.partList.length - 1) after()\n })\n })\n } else {\n this.prepareData(this.structureView, 0, after)\n }\n }\n\n createData (sview: StructureView, i: number) {\n const info = this.__infoList[ i ]\n const surface = info.surface\n\n if (!surface) {\n // Surface creation bailed (no surface generated for this sview)\n return\n }\n\n const surfaceData = {\n position: surface!.getPosition(),\n color: surface!.getColor(this.getColorParams()),\n index: surface!.getFilteredIndex(this.filterSele, sview)\n }\n\n const bufferList = []\n\n if (surface.contour) {\n const contourBuffer = new ContourBuffer(\n surfaceData,\n this.getBufferParams({\n wireframe: false\n })\n )\n\n bufferList.push(contourBuffer)\n } else {\n Object.assign(surfaceData, {\n normal: surface.getNormal(),\n picking: surface.getPicking(sview.getStructure())\n })\n\n const surfaceBuffer = new SurfaceBuffer(\n surfaceData,\n this.getBufferParams({\n background: this.background,\n opaqueBack: this.opaqueBack,\n dullInterior: false\n })\n )\n\n if (this.getBufferParams().side == 'double') {\n const doubleSidedBuffer = new DoubleSidedBuffer(surfaceBuffer)\n bufferList.push(doubleSidedBuffer)\n }\n else {\n bufferList.push(surfaceBuffer)\n }\n }\n\n return { bufferList, info } as StructureRepresentationData\n }\n\n updateData (what: SurfaceDataFields, data: StructureRepresentationData) {\n const surfaceData: Partial = {}\n\n if (what.position || what.radius) {\n this.__forceNewMolsurf = true\n this.build()\n return\n }\n\n if (what.color) {\n surfaceData.color = data.info.surface.getColor(this.getColorParams())\n }\n\n if (what.index) {\n surfaceData.index = data.info.surface.getFilteredIndex(this.filterSele, data.sview)\n }\n\n data.bufferList[ 0 ].setAttributes(surfaceData)\n }\n\n setParameters (params: Partial, what: Partial = {}, rebuild?: boolean) {\n if (params && params.filterSele) {\n what.index = true\n }\n\n if (params && params.colorVolume !== undefined) {\n what.color = true\n }\n\n // forbid setting wireframe to true when contour is true\n if (params && params.wireframe && (\n params.contour || (params.contour === undefined && this.contour)\n )\n ) {\n params.wireframe = false\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n\n getSurfaceParams (params: Partial = {}) {\n const p = Object.assign({\n type: this.surfaceType as string,\n probeRadius: this.probeRadius as number,\n scaleFactor: this.scaleFactor as number,\n smooth: this.smooth && !this.contour,\n cutoff: this.cutoff as number,\n contour: this.contour as boolean,\n useWorker: this.useWorker as boolean,\n radiusParams: this.getRadiusParams()\n }, params)\n\n return p\n }\n\n getColorParams () {\n const p = super.getColorParams()\n\n p.volume = this.colorVolume\n\n return p\n }\n\n getAtomRadius () {\n return 0\n }\n\n clear () {\n super.clear()\n }\n\n dispose () {\n this.__infoList.forEach((info: MolecularSurfaceInfo) => {\n if (info && info.molsurf) {\n info.molsurf.dispose()\n }\n })\n this.__infoList.length = 0\n\n super.dispose()\n }\n}\n\nRepresentationRegistry.add('surface', MolecularSurfaceRepresentation)\n\nexport default MolecularSurfaceRepresentation\n","/**\n * @file Point Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport PointBuffer from '../buffer/point-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { AtomDataFields } from '../structure/structure-data';\n\nexport interface PointRepresentationParameters extends StructureRepresentationParameters {\n pointSize: number\n sizeAttenuation: boolean\n sortParticles: boolean\n useTexture: boolean\n alphaTest: number\n forceTransparent: boolean\n edgeBleach: number\n}\n\n/**\n * Point Representation\n */\nclass PointRepresentation extends StructureRepresentation {\n protected pointSize: number\n protected sizeAttenuation: boolean\n protected sortParticles: boolean\n protected useTexture: boolean\n protected alphaTest: number\n protected forceTransparent: boolean\n protected edgeBleach: number\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'point'\n\n this.parameters = Object.assign({\n\n pointSize: {\n type: 'number', precision: 1, max: 100, min: 0, buffer: true\n },\n sizeAttenuation: {\n type: 'boolean', buffer: true\n },\n sortParticles: {\n type: 'boolean', rebuild: true\n },\n useTexture: {\n type: 'boolean', buffer: true\n },\n alphaTest: {\n type: 'range', step: 0.001, max: 1, min: 0, buffer: true\n },\n forceTransparent: {\n type: 'boolean', buffer: true\n },\n edgeBleach: {\n type: 'range', step: 0.001, max: 1, min: 0, buffer: true\n }\n\n }, this.parameters, {\n\n flatShaded: null,\n wireframe: null,\n linewidth: null,\n side: null,\n\n roughness: null,\n metalness: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n\n this.pointSize = defaults(p.pointSize, 1)\n this.sizeAttenuation = defaults(p.sizeAttenuation, true)\n this.sortParticles = defaults(p.sortParticles, false)\n this.useTexture = defaults(p.useTexture, false)\n this.alphaTest = defaults(p.alphaTest, 0.5)\n this.forceTransparent = defaults(p.forceTransparent, false)\n this.edgeBleach = defaults(p.edgeBleach, 0.0)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n var what = { position: true, color: true, picking: true }\n var atomData = sview.getAtomData(this.getAtomParams(what))\n\n var pointBuffer = new PointBuffer(\n atomData,\n this.getBufferParams({\n pointSize: this.pointSize,\n sizeAttenuation: this.sizeAttenuation,\n sortParticles: this.sortParticles,\n useTexture: this.useTexture,\n alphaTest: this.alphaTest,\n forceTransparent: this.forceTransparent,\n edgeBleach: this.edgeBleach\n })\n )\n\n return {\n bufferList: [ pointBuffer ]\n }\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n var atomData = data.sview!.getAtomData(this.getAtomParams(what))\n var pointData = {}\n\n if (!what || what.position) {\n Object.assign(pointData, {position: atomData.position})\n }\n\n if (!what || what.color) {\n Object.assign(pointData, {color: atomData.color})\n }\n\n data.bufferList[ 0 ].setAttributes(pointData)\n }\n\n getAtomRadius () {\n return 0.1\n }\n}\n\nRepresentationRegistry.add('point', PointRepresentation)\n\nexport default PointRepresentation\n","/**\n * @file Ribbon Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport '../shader/Ribbon.vert'\n\nimport { getUintArray } from '../utils'\nimport { serialArray } from '../math/array-utils'\nimport MeshBuffer from './mesh-buffer'\nimport { BufferParameters, BufferData } from './buffer'\nimport {Log} from \"../globals\";\n\nconst quadIndices = new Uint16Array([\n 0, 1, 2,\n 1, 3, 2\n])\n\nexport interface RibbonBufferData extends BufferData {\n normal: Float32Array\n dir: Float32Array\n size: Float32Array\n}\n\nfunction getSize(data: RibbonBufferData){\n const n = (data.position!.length / 3) - 1\n const n4 = n * 4\n const x = n4 * 3\n return x\n}\n\n/**\n * Ribbon buffer. Draws a thin ribbon.\n */\nclass RibbonBuffer extends MeshBuffer {\n vertexShader = 'Ribbon.vert'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.normal - normals\n * @param {Float32Array} data.dir - binormals\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.size - sizes\n * @param {Picker} data.picking - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: RibbonBufferData, params: Partial = {}) {\n super({\n position: new Float32Array(getSize(data)),\n color: new Float32Array(getSize(data)),\n index: getUintArray(getSize(data), getSize(data) / 3),\n normal: new Float32Array(getSize(data)),\n picking: data.picking\n }, params)\n\n const n = (data.position!.length / 3) - 1\n const n4 = n * 4\n const x = n4 * 3\n\n this.addAttributes({\n 'dir': { type: 'v3', value: new Float32Array(x) }\n })\n this.addAttributes({\n 'size': { type: 'f', value: new Float32Array(n4) }\n })\n\n data.primitiveId = serialArray(n)\n this.setAttributes(data)\n\n this.makeIndex()\n }\n\n setAttributes (data: Partial = {}) {\n const n4 = this.size\n const n = n4 / 4\n\n const attributes = this.geometry.attributes as any // TODO\n\n let position, normal, size, dir, color, primitiveId\n let aPosition, aNormal, aSize, aDir, aColor, aPrimitiveId\n\n if (data.position) {\n position = data.position\n aPosition = attributes.position.array\n attributes.position.needsUpdate = true\n }\n\n if (data.normal) {\n normal = data.normal\n aNormal = attributes.normal.array\n attributes.normal.needsUpdate = true\n }\n\n if (data.size) {\n size = data.size\n aSize = attributes.size.array\n attributes.size.needsUpdate = true\n }\n\n if (data.dir) {\n dir = data.dir\n aDir = attributes.dir.array\n attributes.dir.needsUpdate = true\n }\n\n if (data.color) {\n color = data.color\n aColor = attributes.color.array\n attributes.color.needsUpdate = true\n }\n\n if (data.primitiveId) {\n primitiveId = data.primitiveId\n aPrimitiveId = attributes.primitiveId.array\n attributes.primitiveId.needsUpdate = true\n }\n\n let v, i, k, p, l, v3\n let currSize\n let prevSize = size ? size[ 0 ] : null\n\n for (v = 0; v < n; ++v) {\n v3 = v * 3\n k = v * 3 * 4\n l = v * 4\n\n if (position) {\n aPosition[ k ] = aPosition[ k + 3 ] = position[ v3 ]\n aPosition[ k + 1 ] = aPosition[ k + 4 ] = position[ v3 + 1 ]\n aPosition[ k + 2 ] = aPosition[ k + 5 ] = position[ v3 + 2 ]\n\n aPosition[ k + 6 ] = aPosition[ k + 9 ] = position[ v3 + 3 ]\n aPosition[ k + 7 ] = aPosition[ k + 10 ] = position[ v3 + 4 ]\n aPosition[ k + 8 ] = aPosition[ k + 11 ] = position[ v3 + 5 ]\n }\n\n if (normal) {\n aNormal[ k ] = aNormal[ k + 3 ] = -normal[ v3 ]\n aNormal[ k + 1 ] = aNormal[ k + 4 ] = -normal[ v3 + 1 ]\n aNormal[ k + 2 ] = aNormal[ k + 5 ] = -normal[ v3 + 2 ]\n\n aNormal[ k + 6 ] = aNormal[ k + 9 ] = -normal[ v3 + 3 ]\n aNormal[ k + 7 ] = aNormal[ k + 10 ] = -normal[ v3 + 4 ]\n aNormal[ k + 8 ] = aNormal[ k + 11 ] = -normal[ v3 + 5 ]\n }\n\n for (i = 0; i < 4; ++i) {\n p = k + 3 * i\n\n if (color) {\n aColor[ p ] = color[ v3 ]\n aColor[ p + 1 ] = color[ v3 + 1 ]\n aColor[ p + 2 ] = color[ v3 + 2 ]\n }\n\n if (primitiveId) {\n aPrimitiveId[ l + i ] = primitiveId[ v ]\n }\n }\n\n if (size) {\n currSize = size[ v ]\n\n if (prevSize !== size[ v ]) {\n aSize[ l ] = prevSize\n aSize[ l + 1 ] = prevSize\n aSize[ l + 2 ] = currSize\n aSize[ l + 3 ] = currSize\n } else {\n aSize[ l ] = currSize\n aSize[ l + 1 ] = currSize\n aSize[ l + 2 ] = currSize\n aSize[ l + 3 ] = currSize\n }\n\n prevSize = currSize\n }\n\n if (dir) {\n aDir[ k ] = dir[ v3 ]\n aDir[ k + 1 ] = dir[ v3 + 1 ]\n aDir[ k + 2 ] = dir[ v3 + 2 ]\n\n aDir[ k + 3 ] = -dir[ v3 ]\n aDir[ k + 4 ] = -dir[ v3 + 1 ]\n aDir[ k + 5 ] = -dir[ v3 + 2 ]\n\n aDir[ k + 6 ] = dir[ v3 + 3 ]\n aDir[ k + 7 ] = dir[ v3 + 4 ]\n aDir[ k + 8 ] = dir[ v3 + 5 ]\n\n aDir[ k + 9 ] = -dir[ v3 + 3 ]\n aDir[ k + 10 ] = -dir[ v3 + 4 ]\n aDir[ k + 11 ] = -dir[ v3 + 5 ]\n }\n }\n }\n\n makeIndex () {\n const index = this.geometry.getIndex()\n if (!index) { Log.error('Index is null'); return; }\n const meshIndex = index.array as Uint32Array|Uint16Array\n const n = meshIndex.length / 4 / 3\n\n for (let v = 0; v < n; ++v) {\n const ix = v * 6\n const it = v * 4\n\n meshIndex.set(quadIndices, ix)\n for (let s = 0; s < 6; ++s) {\n meshIndex[ ix + s ] += it\n }\n }\n }\n}\n\nexport default RibbonBuffer\n","/**\n * @file Ribbon Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Spline, { SplineParameters } from '../geometry/spline'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport RibbonBuffer from '../buffer/ribbon-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport StructureView from '../structure/structure-view';\nimport Polymer from '../proxy/polymer';\n\nexport interface RibbonRepresentationParameters extends StructureRepresentationParameters {\n subdiv: number\n tension: number\n smoothSheet: boolean\n}\n\n/**\n * Ribbon Representation\n */\nclass RibbonRepresentation extends StructureRepresentation {\n protected subdiv: number\n protected tension: number\n protected smoothSheet: boolean\n \n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'ribbon'\n\n this.parameters = Object.assign({\n\n subdiv: {\n type: 'integer', max: 50, min: 1, rebuild: true\n },\n tension: {\n type: 'number', precision: 1, max: 1.0, min: 0.1\n },\n smoothSheet: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n\n side: null,\n wireframe: null,\n linewidth: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'chainname')\n p.colorScale = defaults(p.colorScale, 'RdYlBu')\n p.radiusType = defaults(p.radiusType, 'sstruc')\n p.radiusScale = defaults(p.radiusScale, 4.0)\n\n if (p.quality === 'low') {\n this.subdiv = 3\n } else if (p.quality === 'medium') {\n this.subdiv = 6\n } else if (p.quality === 'high') {\n this.subdiv = 12\n } else {\n this.subdiv = defaults(p.subdiv, 6)\n }\n\n this.tension = defaults(p.tension, NaN)\n this.smoothSheet = defaults(p.smoothSheet, false)\n\n super.init(p)\n }\n\n getSplineParams (params?: Partial) {\n return Object.assign({\n subdiv: this.subdiv,\n tension: this.tension,\n directional: true,\n smoothSheet: this.smoothSheet\n }, params)\n }\n\n getAtomRadius (atom: AtomProxy) {\n return atom.isTrace() ? super.getAtomRadius(atom) : 0\n }\n\n createData (sview: StructureView) {\n var bufferList: RibbonBuffer[] = []\n var polymerList: Polymer[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4) return\n polymerList.push(polymer)\n\n var spline = new Spline(polymer, this.getSplineParams())\n var subPos = spline.getSubdividedPosition()\n var subOri = spline.getSubdividedOrientation()\n var subCol = spline.getSubdividedColor(this.getColorParams())\n var subPick = spline.getSubdividedPicking()\n var subSize = spline.getSubdividedSize(this.getRadiusParams())\n\n bufferList.push(\n new RibbonBuffer(\n ({\n position: subPos.position,\n normal: subOri.binormal,\n dir: subOri.normal,\n color: subCol.color,\n size: subSize.size,\n picking: subPick.picking\n }),\n this.getBufferParams()\n )\n )\n }, sview.getSelection())\n\n return {\n bufferList: bufferList,\n polymerList: polymerList\n }\n }\n\n updateData (what: {position?: boolean, radius?: boolean, scale?: boolean, color?: boolean}, data: {polymerList: Polymer[], bufferList: RibbonBuffer[]}) {\n what = what || {}\n\n var i = 0\n var n = data.polymerList.length\n\n for (i = 0; i < n; ++i) {\n var bufferData = {}\n var spline = new Spline(data.polymerList[ i ], this.getSplineParams())\n\n if (what.position) {\n var subPos = spline.getSubdividedPosition()\n var subOri = spline.getSubdividedOrientation()\n Object.assign(bufferData, {\n position: subPos.position,\n normal: subOri.binormal,\n dir: subOri.normal\n })\n }\n\n if (what.radius || what.scale) {\n var subSize = spline.getSubdividedSize(this.getRadiusParams())\n Object.assign(bufferData, {size: subSize.size})\n }\n\n if (what.color) {\n var subCol = spline.getSubdividedColor(this.getColorParams())\n Object.assign(bufferData, {color: subCol.color})\n }\n\n data.bufferList[ i ].setAttributes(bufferData)\n }\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n if (params && params.tension) {\n Object.assign(what, {position: true})\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('ribbon', RibbonRepresentation)\n\nexport default RibbonRepresentation\n","/**\n * @file Rocket Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { AtomPicker } from '../utils/picker'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport Helixbundle, { Axis } from '../geometry/helixbundle'\nimport CylinderBuffer from '../buffer/cylinder-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport CylinderImpostorBuffer from '../buffer/cylinderimpostor-buffer';\n\nexport interface RocketRepresentationParameters extends StructureRepresentationParameters {\n localAngle: number\n centerDist: number\n ssBorder: boolean\n radialSegments: number\n openEnded: boolean\n disableImpostor: boolean\n}\n\nexport interface AxisData {\n begin: Float32Array\n end: Float32Array\n size: Float32Array\n color: Float32Array\n picking: AtomPicker\n}\n\n/**\n * Rocket Representation\n */\nclass RocketRepresentation extends StructureRepresentation {\n\n protected localAngle: number\n protected centerDist: number\n protected ssBorder: boolean\n protected radialSegments: number\n protected openEnded: boolean\n protected disableImpostor: boolean\n // protected helixbundleList: Helixbundle[]\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'rocket'\n\n this.parameters = Object.assign({\n\n localAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n centerDist: {\n type: 'number', precision: 1, max: 10, min: 0, rebuild: true\n },\n ssBorder: {\n type: 'boolean', rebuild: true\n },\n radialSegments: true,\n openEnded: true,\n disableImpostor: true\n\n }, this.parameters)\n\n // this.helixbundleList = []\n\n this.init(params)\n }\n\n init (params: Partial) {\n let p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'sstruc')\n p.radiusSize = defaults(p.radiusSize, 1.5)\n p.radiusScale = defaults(p.radiusScale, 1.0)\n p.openEnded = defaults(p.openEnded, false)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.localAngle = defaults(p.localAngle, 30)\n this.centerDist = defaults(p.centerDist, 2.5)\n this.ssBorder = defaults(p.ssBorder, false)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n let length = 0\n const axisList:Axis[] = []\n const helixbundleList:Helixbundle[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4 || polymer.isNucleic()) return\n\n const helixbundle = new Helixbundle(polymer)\n const axis = helixbundle.getAxis(\n this.localAngle, this.centerDist, this.ssBorder,\n this.getColorParams(), this.getRadiusParams()\n )\n\n length += axis.size.length\n axisList.push(axis)\n helixbundleList.push(helixbundle)\n }, sview.getSelection())\n\n const axisData = {\n begin: new Float32Array(length * 3),\n end: new Float32Array(length * 3),\n size: new Float32Array(length),\n color: new Float32Array(length * 3),\n picking: {}\n }\n\n let picking = new Float32Array(length)\n\n let offset = 0\n\n axisList.forEach(function (axis) {\n axisData.begin.set(axis.begin, offset * 3)\n axisData.end.set(axis.end, offset * 3)\n axisData.size.set(axis.size, offset)\n axisData.color.set(axis.color, offset * 3)\n picking.set(axis.picking.array!, offset)\n offset += axis.size.length\n })\n\n if (length) {\n axisData.picking = new AtomPicker(\n picking, sview.getStructure()\n )\n }\n\n const cylinderBuffer = new CylinderBuffer(\n {\n position1: axisData.begin,\n position2: axisData.end,\n color: axisData.color,\n color2: axisData.color,\n radius: axisData.size,\n picking: axisData.picking\n },\n this.getBufferParams({\n openEnded: this.openEnded,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n return {\n bufferList: [ cylinderBuffer as CylinderGeometryBuffer|CylinderImpostorBuffer ],\n axisList: axisList,\n helixbundleList: helixbundleList,\n axisData: axisData\n }\n }\n\n \n updateData (what: any, data: {bufferList: CylinderBuffer[], helixbundleList: Helixbundle[], axisList: Axis[], axisData: AxisData}) {\n what = what || {}\n\n if (what.position) {\n this.build()\n return\n }\n\n var cylinderData = {}\n\n if (what.color || what.radius) {\n var offset = 0\n\n data.helixbundleList.forEach((helixbundle) => {\n var axis = helixbundle.getAxis(\n this.localAngle, this.centerDist, this.ssBorder,\n this.getColorParams(), this.getRadiusParams()\n )\n if (what.color) {\n data.axisData.color.set(axis.color, offset * 3)\n }\n if (what.radius || what.scale) {\n data.axisData.size.set(axis.size, offset)\n }\n offset += axis.size.length\n })\n\n if (what.color) {\n Object.assign(cylinderData, {\n color: data.axisData.color,\n color2: data.axisData.color\n })\n }\n\n if (what.radius || what.scale) {\n Object.assign(cylinderData, {\n radius: data.axisData.size\n })\n }\n }\n\n (data.bufferList[ 0 ] as CylinderGeometryBuffer).setAttributes(cylinderData)\n }\n}\n\nRepresentationRegistry.add('rocket', RocketRepresentation)\n\nexport default RocketRepresentation\n","/**\n * @file Rope Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport CartoonRepresentation, { CartoonRepresentationParameters } from './cartoon-representation'\nimport Helixorient from '../geometry/helixorient'\nimport Spline from '../geometry/spline'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport Polymer from '../proxy/polymer';\n\n/**\n * Rope Representation\n */\nclass RopeRepresentation extends CartoonRepresentation {\n protected smooth: number\n \n constructor (structure: Structure, viewer: Viewer, params: Partial&{smooth: number}) {\n super(structure, viewer, params)\n\n this.type = 'rope'\n\n this.parameters = Object.assign({\n\n smooth: {\n type: 'integer', max: 15, min: 0, rebuild: true\n }\n\n }, this.parameters, {\n aspectRatio: null,\n smoothSheet: null\n })\n }\n\n init (params: Partial) {\n var p = params || {}\n p.aspectRatio = 1.0\n p.tension = defaults(p.tension, 0.5)\n p.radiusScale = defaults(p.radiusScale, 5.0)\n p.smoothSheet = false\n\n this.smooth = defaults(p.smooth, 2)\n\n super.init(p)\n }\n\n getSpline (polymer: Polymer) {\n var helixorient = new Helixorient(polymer)\n\n return new Spline(polymer, this.getSplineParams({\n directional: false,\n positionIterator: helixorient.getCenterIterator(this.smooth)\n }))\n }\n}\n\nRepresentationRegistry.add('rope', RopeRepresentation)\n\nexport default RopeRepresentation\n","/**\n * @file Spacefill Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { RepresentationRegistry } from '../globals'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\nimport { AtomDataFields } from '../structure/structure-data';\nimport SphereImpostorBuffer from '../buffer/sphereimpostor-buffer';\n\n/**\n * Spacefill Representation\n */\nclass SpacefillRepresentation extends StructureRepresentation {\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'spacefill'\n\n this.parameters = Object.assign({\n sphereDetail: true,\n disableImpostor: true\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n var sphereBuffer = new SphereBuffer(\n (sview.getAtomData(this.getAtomParams()) as SphereBufferData),\n (this.getBufferParams({\n sphereDetail: this.sphereDetail,\n dullInterior: true,\n disableImpostor: this.disableImpostor\n }) as SphereBufferParameters)\n )\n\n return {\n bufferList: [ sphereBuffer as SphereGeometryBuffer|SphereImpostorBuffer ]\n }\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n var atomData = data.sview!.getAtomData(this.getAtomParams(what))\n var sphereData: Partial = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {position: atomData.position})\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {color: atomData.color})\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {radius: atomData.radius})\n }\n\n data.bufferList[ 0 ].setAttributes(sphereData)\n }\n}\n\nRepresentationRegistry.add('spacefill', SpacefillRepresentation)\n\nexport default SpacefillRepresentation\n","/**\n * @file Trace Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport '../shader/Line.vert'\nimport '../shader/Line.frag'\n\nimport { Log } from '../globals'\nimport Buffer, { BufferParameters, BufferData } from './buffer'\n\nfunction getSize(data: BufferData){\n const n = data.position!.length / 3\n const n1 = n - 1\n return n1 * 3 * 2\n}\n\n/**\n * Trace buffer. Draws a series of lines.\n */\nclass TraceBuffer extends Buffer {\n isLine = true\n vertexShader = 'Line.vert'\n fragmentShader = 'Line.frag'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: BufferData, params: Partial = {}) {\n super({\n position: new Float32Array(getSize(data)),\n color: new Float32Array(getSize(data))\n }, params)\n\n this.setAttributes(data)\n }\n\n setAttributes (data: Partial) {\n let position, color\n let linePosition, lineColor\n\n const attributes = this.geometry.attributes as any // TODO\n\n if (data.position) {\n position = data.position\n linePosition = attributes.position.array\n attributes.position.needsUpdate = true\n }\n\n if (data.color) {\n color = data.color\n lineColor = attributes.color.array\n attributes.color.needsUpdate = true\n }\n\n if (!position && !color) {\n Log.warn('TraceBuffer.prototype.setAttributes no data')\n return\n }\n\n let v, v2\n const n = this.size\n const n1 = n - 1\n\n for (let i = 0; i < n1; ++i) {\n v = 3 * i\n v2 = 3 * i * 2\n\n if (position) {\n linePosition[ v2 ] = position[ v ]\n linePosition[ v2 + 1 ] = position[ v + 1 ]\n linePosition[ v2 + 2 ] = position[ v + 2 ]\n\n linePosition[ v2 + 3 ] = position[ v + 3 ]\n linePosition[ v2 + 4 ] = position[ v + 4 ]\n linePosition[ v2 + 5 ] = position[ v + 5 ]\n }\n\n if (color) {\n lineColor[ v2 ] = color[ v ]\n lineColor[ v2 + 1 ] = color[ v + 1 ]\n lineColor[ v2 + 2 ] = color[ v + 2 ]\n\n lineColor[ v2 + 3 ] = color[ v + 3 ]\n lineColor[ v2 + 4 ] = color[ v + 4 ]\n lineColor[ v2 + 5 ] = color[ v + 5 ]\n }\n }\n }\n}\n\nexport default TraceBuffer\n","/**\n * @file Trace Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Spline from '../geometry/spline'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport TraceBuffer from '../buffer/trace-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport StructureView from '../structure/structure-view';\nimport Polymer from '../proxy/polymer';\n\nexport interface TraceRepresentationParameters extends StructureRepresentationParameters {\n subdiv: number\n tension: number\n smoothSheet: boolean\n}\n/**\n * Trace Representation\n */\nclass TraceRepresentation extends StructureRepresentation {\n protected subdiv: number\n protected tension: number\n protected smoothSheet: boolean\n \n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'trace'\n\n this.parameters = Object.assign({\n\n subdiv: {\n type: 'integer', max: 50, min: 1, rebuild: true\n },\n tension: {\n type: 'number', precision: 1, max: 1.0, min: 0.1\n },\n smoothSheet: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n\n flatShaded: null,\n side: null,\n wireframe: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'chainname')\n p.colorScale = defaults(p.colorScale, 'RdYlBu')\n\n if (p.quality === 'low') {\n this.subdiv = 3\n } else if (p.quality === 'medium') {\n this.subdiv = 6\n } else if (p.quality === 'high') {\n this.subdiv = 12\n } else {\n this.subdiv = defaults(p.subdiv, 6)\n }\n\n this.tension = defaults(p.tension, NaN)\n this.smoothSheet = defaults(p.smoothSheet, false)\n\n super.init(p)\n }\n\n getSplineParams (params?: {[k:string]: any}) {\n return Object.assign({\n subdiv: this.subdiv,\n tension: this.tension,\n directional: false,\n smoothSheet: this.smoothSheet\n }, params)\n }\n\n getAtomRadius (atom: AtomProxy) {\n return atom.isTrace() ? 0.1 : 0\n }\n\n createData (sview: StructureView) {\n var bufferList: TraceBuffer[] = []\n var polymerList: Polymer[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4) return\n polymerList.push(polymer)\n\n var spline = new Spline(polymer, this.getSplineParams())\n var subPos = spline.getSubdividedPosition()\n var subCol = spline.getSubdividedColor(this.getColorParams())\n\n bufferList.push(\n new TraceBuffer(\n Object.assign({}, subPos, subCol),\n this.getBufferParams()\n )\n )\n }, sview.getSelection())\n\n return {\n bufferList: bufferList,\n polymerList: polymerList\n }\n }\n\n updateData (what: any, data: StructureRepresentationData) {\n what = what || {}\n\n var i = 0\n var n = data.polymerList!.length\n\n for (i = 0; i < n; ++i) {\n var bufferData = {}\n var spline = new Spline(data.polymerList![ i ], this.getSplineParams())\n\n if (what.position) {\n var subPos = spline.getSubdividedPosition()\n Object.assign(bufferData, { position: subPos.position })\n }\n\n if (what.color) {\n var subCol = spline.getSubdividedColor(this.getColorParams())\n Object.assign(bufferData, { color: subCol.color })\n }\n\n data.bufferList[ i ].setAttributes(bufferData)\n }\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n if (params && params.tension) {\n Object.assign(what, {position: true})\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('trace', TraceRepresentation)\n\nexport default TraceRepresentation\n","/**\n * @file Tube Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport CartoonRepresentation, {CartoonRepresentationParameters} from './cartoon-representation'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\n\n/**\n * Tube Representation\n */\nclass TubeRepresentation extends CartoonRepresentation {\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'tube'\n\n this.parameters = Object.assign(\n {}, this.parameters, { aspectRatio: null }\n )\n }\n\n init (params: Partial) {\n var p = params || {}\n p.aspectRatio = 1.0\n p.radiusScale = defaults(p.radiusScale, 2.0)\n\n if (p.quality === 'low') {\n this.radialSegments = 5\n }\n\n super.init(p)\n }\n\n getSplineParams (/* params */) {\n return super.getSplineParams({\n directional: false\n })\n }\n}\n\nRepresentationRegistry.add('tube', TubeRepresentation)\n\nexport default TubeRepresentation\n","/**\n * @file Unitcell Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport CylinderBuffer, { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport { AtomDataFields } from '../structure/structure-data';\nimport StructureView from '../structure/structure-view';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\n// @ts-ignore: unused import UnitcellPicker required for declaration only\nimport { UnitcellPicker } from '../utils/picker';\n\nexport interface UnitcellRepresentationParameters extends StructureRepresentationParameters {\n radiusSize: number\n sphereDetail: number\n radialSegments: number\n disableImpostor: boolean\n}\n\n/**\n * Unitcell Representation\n */\nclass UnitcellRepresentation extends StructureRepresentation {\n sphereBuffer: SphereBuffer\n cylinderBuffer: CylinderBuffer\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'unitcell'\n\n this.parameters = Object.assign({\n\n radiusSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n sphereDetail: true,\n radialSegments: true,\n disableImpostor: true\n\n }, this.parameters, {\n assembly: null\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n\n let defaultRadius = 0.5\n if (this.structure.unitcell) {\n defaultRadius = Math.cbrt(this.structure.unitcell.volume) / 200\n }\n\n p.radiusSize = defaults(p.radiusSize, defaultRadius)\n p.colorValue = defaults(p.colorValue, 'orange')\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n super.init(p)\n }\n\n getUnitcellData (structure: Structure) {\n return structure.unitcell!.getData(structure)\n }\n\n create () {\n const structure = this.structureView.getStructure()\n if (!structure.unitcell) return\n const unitcellData = this.getUnitcellData(structure)\n\n this.sphereBuffer = new SphereBuffer(\n unitcellData.vertex as SphereBufferData,\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters\n )\n\n this.cylinderBuffer = new CylinderBuffer(\n unitcellData.edge as CylinderBufferData,\n this.getBufferParams({\n openEnded: true,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n this.dataList.push({\n sview: this.structureView,\n bufferList: [ this.sphereBuffer as SphereGeometryBuffer, this.cylinderBuffer as CylinderGeometryBuffer ]\n })\n }\n\n createData (sview: StructureView): undefined {\n return\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n const structure = data.sview!.getStructure()\n if (!structure.unitcell) return\n const unitcellData = this.getUnitcellData(structure)\n const sphereData: Partial = {}\n const cylinderData: Partial = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {position: unitcellData.vertex.position})\n Object.assign(cylinderData, {\n position1: unitcellData.edge.position1,\n position2: unitcellData.edge.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {color: unitcellData.vertex.color})\n Object.assign(cylinderData, {\n color: unitcellData.edge.color,\n color2: unitcellData.edge.color2\n })\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {radius: unitcellData.vertex.radius})\n Object.assign(cylinderData, {radius: unitcellData.edge.radius})\n }\n\n (this.sphereBuffer as SphereGeometryBuffer).setAttributes(sphereData);\n (this.cylinderBuffer as CylinderGeometryBuffer).setAttributes(cylinderData)\n }\n}\n\nRepresentationRegistry.add('unitcell', UnitcellRepresentation)\n\nexport default UnitcellRepresentation\n","/**\n * @file Validation Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport CylinderBuffer from '../buffer/cylinder-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport CylinderImpostorBuffer from '../buffer/cylinderimpostor-buffer';\n\n/**\n * Validation representation\n */\nclass ValidationRepresentation extends StructureRepresentation {\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'validation'\n\n this.parameters = Object.assign({\n\n }, this.parameters, {\n radiusType: null,\n radiusSize: null,\n radiusScale: null\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorValue = defaults(p.colorValue, '#f0027f')\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n if (!sview.validation) return\n\n const clashData = sview.validation.getClashData({\n structure: sview,\n color: this.colorValue\n })\n\n const cylinderBuffer = new CylinderBuffer(\n clashData, this.getBufferParams({ openEnded: false })\n )\n\n return {\n bufferList: [ cylinderBuffer as CylinderGeometryBuffer|CylinderImpostorBuffer ]\n }\n }\n}\n\nRepresentationRegistry.add('validation', ValidationRepresentation)\n\nexport default ValidationRepresentation\n","/**\n * @file Cone Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3, ConeBufferGeometry } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { calculateCenterArray } from '../math/array-utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferDefaultParameters } from './buffer'\n\nconst scale = new Vector3()\nconst eye = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3(0, 1, 0)\n\nfunction getGeo (params: Partial = {}) {\n const geo = new ConeBufferGeometry(\n 1, // radius\n 1, // height\n defaults(params.radialSegments, 60), // radialSegments\n 1, // heightSegments\n defaults(params.openEnded, false) // openEnded\n )\n geo.applyMatrix4(new Matrix4().makeRotationX(-Math.PI / 2))\n\n return geo\n}\n\nexport interface ConeBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n radius: Float32Array\n}\n\nexport const ConeBufferDefaultParameters = Object.assign({\n radialSegments: 60,\n openEnded: false\n}, BufferDefaultParameters)\nexport type ConeBufferParameters = typeof ConeBufferDefaultParameters\n\n\n/**\n * Cone geometry buffer.\n *\n * @example\n * var coneBuffer = new ConeBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass ConeBuffer extends GeometryBuffer {\n updateNormals = true\n\n get defaultParameters() { return ConeBufferDefaultParameters }\n parameters: ConeBufferParameters\n\n _position: Float32Array\n _position1: Float32Array\n _position2: Float32Array\n _radius: Float32Array\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n */\n constructor (data: ConeBufferData, params: Partial = {}) {\n super({\n position: new Float32Array(data.position1.length),\n color: data.color,\n picking: data.picking\n }, params, getGeo(params))\n\n this._position = new Float32Array(data.position1.length)\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n eye.fromArray(this._position1 as any, i3)\n target.fromArray(this._position2 as any, i3)\n matrix.lookAt(eye, target, up)\n\n const r = this._radius[ i ]\n scale.set(r, r, eye.distanceTo(target))\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.position1 && data.position2) {\n calculateCenterArray(data.position1, data.position2, this._position)\n this._position1 = data.position1\n this._position2 = data.position2\n data.position = this._position\n }\n if (data.radius) this._radius = data.radius\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('cone', ConeBuffer)\n\nexport default ConeBuffer\n","/**\n * @file Geometry Group\n * @author Alexander Rose \n * @private\n */\n\nimport { Box3, BufferGeometry } from 'three'\n\nclass GeometryGroup {\n geometryList: BufferGeometry[]\n boundingBox: Box3\n\n constructor (geometryList: BufferGeometry[] = []) {\n this.geometryList = geometryList\n }\n\n computeBoundingBox () {\n if (!this.boundingBox) {\n this.boundingBox = new Box3()\n } else {\n this.boundingBox.empty()\n }\n\n this.geometryList.forEach(geo => {\n if (!geo.boundingBox) geo.computeBoundingBox()\n this.boundingBox.union(geo.boundingBox as Box3)\n })\n }\n}\n\nexport default GeometryGroup\n","/**\n * @file Arrow Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3, Group } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport { createParams, defaults } from '../utils'\nimport { Picker } from '../utils/picker'\nimport Buffer from './buffer'\nimport CylinderBuffer, { CylinderBufferData } from './cylinder-buffer'\nimport CylinderGeometryBuffer from './cylindergeometry-buffer'\nimport ConeBuffer, { ConeBufferData } from './cone-buffer'\nimport GeometryGroup from '../viewer/geometry-group'\nimport { BufferData, BufferDefaultParameters } from './buffer'\n\nexport interface ArrowBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n radius: Float32Array\n}\n\nexport const ArrowBufferDefaultParameters = Object.assign({\n aspectRatio: 1.5,\n radialSegments: 50,\n openEnded: false,\n disableImpostor: false\n}, BufferDefaultParameters)\nexport type ArrowBufferParameters = typeof ArrowBufferDefaultParameters\n\n/**\n * Arrow buffer. Draws arrows made from a cylinder and a cone.\n * @implements {Buffer}\n *\n * @example\n * var arrowBuffer = new ArrowBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 10, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass ArrowBuffer {\n parameters: ArrowBufferParameters\n get defaultParameters() { return ArrowBufferDefaultParameters }\n\n cylinderBuffer: CylinderGeometryBuffer\n coneBuffer: ConeBuffer\n\n splitPosition: Float32Array\n cylinderRadius: Float32Array\n\n geometry: GeometryGroup\n picking?: Picker\n\n group = new Group()\n wireframeGroup = new Group()\n pickingGroup = new Group()\n\n visible = true\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n */\n constructor (data: ArrowBufferData, params: Partial = {}) {\n this.parameters = createParams(params, this.defaultParameters)\n\n this.splitPosition = new Float32Array(data.position1.length)\n this.cylinderRadius = new Float32Array(data.radius.length)\n\n const attr = this.makeAttributes(data)\n const bufferParams = {\n radialSegments: this.parameters.radialSegments,\n openEnded: this.parameters.openEnded,\n disableImpostor: this.parameters.disableImpostor\n }\n\n this.cylinderBuffer = new CylinderBuffer(\n attr.cylinder as CylinderBufferData, bufferParams\n ) as CylinderGeometryBuffer\n this.coneBuffer = new ConeBuffer(\n attr.cone as ConeBufferData, bufferParams\n )\n\n this.geometry = new GeometryGroup([\n this.cylinderBuffer.geometry,\n this.coneBuffer.geometry\n ])\n\n // requires Group objects to be present\n this.matrix = defaults(params.matrix, new Matrix4())\n\n this.picking = data.picking\n }\n\n set matrix (m) {\n Buffer.prototype.setMatrix.call(this, m)\n }\n get matrix () {\n return this.group.matrix.clone()\n }\n\n get pickable () {\n return !!this.picking\n }\n\n makeAttributes (data: Partial = {}) {\n const splitPosition = this.splitPosition\n const cylinderRadius = this.cylinderRadius\n\n const aspectRatio = this.parameters.aspectRatio\n\n let i, il\n const cylinder: Partial = {}\n const cone: Partial = {}\n\n if (data.radius) {\n for (i = 0, il = cylinderRadius.length; i < il; ++i) {\n cylinderRadius[ i ] = data.radius[ i ] / aspectRatio\n }\n cylinder.radius = cylinderRadius\n cone.radius = data.radius\n }\n\n if (data.position1 && data.position2) {\n const vFrom = new Vector3()\n const vTo = new Vector3()\n const vDir = new Vector3()\n const vSplit = new Vector3()\n for (i = 0, il = splitPosition.length; i < il; i += 3) {\n vFrom.fromArray(data.position1 as any, i)\n vTo.fromArray(data.position2 as any, i)\n vDir.subVectors(vFrom, vTo)\n const fullLength = vDir.length()\n const coneLength = cylinderRadius[ i / 3 ] * aspectRatio * 2\n const length = Math.min(fullLength, coneLength)\n vDir.setLength(length)\n vSplit.copy(vTo).add(vDir)\n vSplit.toArray(splitPosition as any, i)\n }\n cylinder.position1 = data.position1\n cylinder.position2 = splitPosition\n cone.position1 = splitPosition\n cone.position2 = data.position2\n }\n\n if (data.color) {\n cylinder.color = data.color\n cylinder.color2 = data.color\n cone.color = data.color\n }\n\n return {\n cylinder: cylinder,\n cone: cone\n }\n }\n\n getMesh () {\n return new Group().add(\n this.cylinderBuffer.getMesh(),\n this.coneBuffer.getMesh()\n )\n }\n\n getWireframeMesh () {\n return new Group().add(\n this.cylinderBuffer.getWireframeMesh(),\n this.coneBuffer.getWireframeMesh()\n )\n }\n\n getPickingMesh () {\n return new Group().add(\n this.cylinderBuffer.getPickingMesh(),\n this.coneBuffer.getPickingMesh()\n )\n }\n\n setAttributes (data: Partial = {}) {\n const attr = this.makeAttributes(data)\n\n this.cylinderBuffer.setAttributes(attr.cylinder)\n this.coneBuffer.setAttributes(attr.cone)\n }\n\n /**\n * Set buffer parameters\n * @param {BufferParameters} params - buffer parameters object\n * @return {undefined}\n */\n setParameters (params: Partial = {}) {\n params = Object.assign({}, params)\n\n if (params && params.matrix !== undefined) {\n this.matrix = params.matrix\n }\n delete params.matrix\n\n if (params && params.wireframe !== undefined) {\n this.parameters.wireframe = params.wireframe\n this.setVisibility(this.visible)\n }\n\n this.cylinderBuffer.setParameters(params)\n this.coneBuffer.setParameters(params)\n }\n\n setVisibility (value: boolean) {\n Buffer.prototype.setVisibility.call(this, value)\n }\n\n dispose () {\n this.cylinderBuffer.dispose()\n this.coneBuffer.dispose()\n }\n}\n\nBufferRegistry.add('arrow', ArrowBuffer)\n\nexport default ArrowBuffer\n","/**\n * @file Box Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { BoxBufferGeometry, Vector3, Matrix4 } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface BoxBufferData extends BufferData {\n heightAxis: Float32Array\n depthAxis: Float32Array\n size: Float32Array\n}\n\n/**\n * Box buffer. Draws boxes.\n *\n * @example\n * var boxBuffer = new BoxBuffer({\n * position: new Float32Array([ 0, 3, 0, -2, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 1, 0, 1, 0 ]),\n * size: new Float32Array([ 2, 1.5 ]),\n * heightAxis: new Float32Array([ 0, 1, 1, 0, 2, 0 ]),\n * depthAxis: new Float32Array([ 1, 0, 1, 0, 0, 2 ])\n * })\n */\nclass BoxBuffer extends GeometryBuffer {\n updateNormals = true\n\n _heightAxis: Float32Array\n _depthAxis: Float32Array\n _size: Float32Array\n\n constructor (data: BoxBufferData, params: Partial = {}) {\n super(data, params, new BoxBufferGeometry(1, 1, 1))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._heightAxis as any, i3)\n up.fromArray(this._depthAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n scale.set(this._size[ i ], up.length(), target.length())\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.size) this._size = data.size\n if (data.heightAxis) this._heightAxis = data.heightAxis\n if (data.depthAxis) this._depthAxis = data.depthAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('box', BoxBuffer)\n\nexport default BoxBuffer\n","/**\n * @file Ellipsoid Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { IcosahedronBufferGeometry, Vector3, Matrix4 } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferDefaultParameters } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface EllipsoidBufferData extends BufferData {\n majorAxis: Float32Array\n minorAxis: Float32Array\n radius: Float32Array\n}\n\nexport const EllipsoidBufferDefaultParameters = Object.assign({\n sphereDetail: 2,\n}, BufferDefaultParameters)\nexport type EllipsoidBufferParameters = typeof EllipsoidBufferDefaultParameters\n\n/**\n * Ellipsoid buffer. Draws ellipsoids.\n *\n * @example\n * var ellipsoidBuffer = new EllipsoidBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ]),\n * majorAxis: new Float32Array([ 1, 1, 0 ]),\n * minorAxis: new Float32Array([ 0.5, 0, 0.5 ]),\n * });\n */\nclass EllipsoidBuffer extends GeometryBuffer {\n updateNormals = true\n\n get defaultParameters() { return EllipsoidBufferDefaultParameters }\n parameters: EllipsoidBufferParameters\n\n _majorAxis: Float32Array\n _minorAxis: Float32Array\n _radius: Float32Array\n\n constructor (data: EllipsoidBufferData, params: Partial = {}) {\n super(data, params, new IcosahedronBufferGeometry(1, defaults(params.sphereDetail, 2)))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._majorAxis as any, i3)\n up.fromArray(this._minorAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n scale.set(this._radius[ i ], up.length(), target.length())\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.radius) this._radius = data.radius\n if (data.majorAxis) this._majorAxis = data.majorAxis\n if (data.minorAxis) this._minorAxis = data.minorAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('ellipsoid', EllipsoidBuffer)\n\nexport default EllipsoidBuffer\n","/**\n * @file Octahedron Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { OctahedronBufferGeometry, Vector3, Matrix4 } from 'three'\nimport { BufferRegistry } from '../globals'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface OctahedronBufferData extends BufferData {\n heightAxis: Float32Array\n depthAxis: Float32Array\n size: Float32Array\n}\n\n/**\n * Octahedron buffer. Draws octahedrons.\n *\n * @example\n * var octahedronBuffer = new OctahedronBuffer({\n * position: new Float32Array([ 0, 3, 0, -2, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 1, 0, 1, 0 ]),\n * size: new Float32Array([ 2, 1.5 ]),\n * heightAxis: new Float32Array([ 0, 1, 1, 0, 2, 0 ]),\n * depthAxis: new Float32Array([ 1, 0, 1, 0, 0, 2 ])\n * })\n */\nclass OctahedronBuffer extends GeometryBuffer {\n updateNormals = true\n\n _heightAxis: Float32Array\n _depthAxis: Float32Array\n _size: Float32Array\n\n constructor (data: OctahedronBufferData, params: Partial = {}) {\n super(data, params, new OctahedronBufferGeometry(1, 0))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._heightAxis as any, i3)\n up.fromArray(this._depthAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n scale.set(this._size[ i ], up.length(), target.length())\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.size) this._size = data.size\n if (data.heightAxis) this._heightAxis = data.heightAxis\n if (data.depthAxis) this._depthAxis = data.depthAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('octahedron', OctahedronBuffer)\n\nexport default OctahedronBuffer\n","/**\n * @file Tetrahedron Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { TetrahedronBufferGeometry, Vector3, Matrix4 } from 'three'\nimport { BufferRegistry } from '../globals'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface TetrahedronBufferData extends BufferData {\n heightAxis: Float32Array\n depthAxis: Float32Array\n size: Float32Array\n}\n\n/**\n * Tetrahedron buffer. Draws tetrahedrons.\n *\n * @example\n * var tetrahedronBuffer = new TetrahedronBuffer({\n * position: new Float32Array([ 0, 3, 0, -2, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 1, 0, 1, 0 ]),\n * size: new Float32Array([ 2, 1.5 ]),\n * heightAxis: new Float32Array([ 0, 1, 1, 0, 2, 0 ]),\n * depthAxis: new Float32Array([ 1, 0, 1, 0, 0, 2 ])\n * })\n */\nclass TetrahedronBuffer extends GeometryBuffer {\n updateNormals = true\n\n _heightAxis: Float32Array\n _depthAxis: Float32Array\n _size: Float32Array\n\n constructor (data: TetrahedronBufferData, params: Partial = {}) {\n super(data, params, new TetrahedronBufferGeometry(1, 0))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._heightAxis as any, i3)\n up.fromArray(this._depthAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n scale.set(this._size[ i ], up.length(), target.length())\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.size) this._size = data.size\n if (data.heightAxis) this._heightAxis = data.heightAxis\n if (data.depthAxis) this._depthAxis = data.depthAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('tetrahedron', TetrahedronBuffer)\n\nexport default TetrahedronBuffer\n","/**\n * @file Tetrahedron Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { TorusBufferGeometry, Vector3, Matrix4 } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferDefaultParameters, BufferData } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface TorusBufferData extends BufferData {\n majorAxis: Float32Array\n minorAxis: Float32Array\n radius: Float32Array\n}\n\nexport const TorusBufferDefaultParameters = Object.assign({\n radiusRatio: 0.2,\n radialSegments: 16,\n tubularSegments: 32\n}, BufferDefaultParameters)\nexport type TorusBufferParameters = typeof TorusBufferDefaultParameters\n\n/**\n * Torus geometry buffer. Draws torii.\n *\n * @example\n * var torusBuffer = new TorusBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ]),\n * majorAxis: new Float32Array([ 1, 1, 0 ]),\n * minorAxis: new Float32Array([ 0.5, 0, 0.5 ]),\n * });\n */\nclass TorusBuffer extends GeometryBuffer {\n updateNormals = true\n\n get defaultParameters() { return TorusBufferDefaultParameters }\n parameters: TorusBufferParameters\n\n _majorAxis: Float32Array\n _minorAxis: Float32Array\n _radius: Float32Array\n\n constructor (data: TorusBufferData, params: Partial = {}) {\n super(data, params, new TorusBufferGeometry(\n 1,\n defaults(params.radiusRatio, 0.2),\n defaults(params.radialSegments, 16),\n defaults(params.tubularSegments, 32)\n ))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._majorAxis as any, i3)\n up.fromArray(this._minorAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n const r = this._radius[ i ]\n scale.set(r, r, r)\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.radius) this._radius = data.radius\n if (data.majorAxis) this._majorAxis = data.majorAxis\n if (data.minorAxis) this._minorAxis = data.minorAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('torus', TorusBuffer)\n\nexport default TorusBuffer\n","/**\n * @file Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log } from '../globals'\nimport { defaults } from '../utils'\nimport Streamer from '../streamer/streamer';\n\nexport interface ParserParameters {\n name: string\n path: string\n}\n\nclass Parser {\n streamer: Streamer\n name: string\n path: string\n [k: string]: any\n \n constructor (streamer: Streamer, params?: Partial) {\n var p = params || {}\n\n this.streamer = streamer\n\n this.name = defaults(p.name, '')\n this.path = defaults(p.path, '')\n }\n\n get type () { return '' }\n get __objName () { return '' }\n get isBinary () { return false }\n get isJson () { return false }\n get isXml () { return false }\n\n parse () {\n return this.streamer.read().then(() => {\n this._beforeParse()\n this._parse()\n this._afterParse()\n return this[ this.__objName ]\n })\n }\n\n _parse () {}\n\n _beforeParse () {}\n\n _afterParse () {\n if (Debug) Log.log(this[ this.__objName ])\n }\n}\n\nexport default Parser\n","/**\n * @file Structure Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport Parser, { ParserParameters } from './parser'\nimport Structure from '../structure/structure'\nimport StructureBuilder from '../structure/structure-builder'\nimport Streamer from '../streamer/streamer';\n\nexport interface StructureParserParameters extends ParserParameters {\n firstModelOnly: boolean\n asTrajectory: boolean\n cAlphaOnly: boolean\n}\nclass StructureParser extends Parser {\n\n structureBuilder: StructureBuilder\n\n constructor (streamer: Streamer, params?: Partial) {\n var p = params || {}\n\n super(streamer, p)\n\n this.firstModelOnly = defaults(p.firstModelOnly, false)\n this.asTrajectory = defaults(p.asTrajectory, false)\n this.cAlphaOnly = defaults(p.cAlphaOnly, false)\n\n this.structure = new Structure(this.name, this.path)\n this.structureBuilder = new StructureBuilder(this.structure)\n }\n\n get type () { return 'structure' }\n get __objName () { return 'structure' }\n}\n\nexport default StructureParser\n","/**\n * @file Entity\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from './structure'\nimport {\n UnknownEntity, PolymerEntity, NonPolymerEntity, MacrolideEntity, WaterEntity\n} from './structure-constants'\nimport ChainProxy from '../proxy/chain-proxy'\n\nfunction entityTypeFromString (string: string) {\n string = string.toLowerCase()\n switch (string) {\n case 'polymer':\n return PolymerEntity\n case 'non-polymer':\n return NonPolymerEntity\n case 'macrolide':\n return MacrolideEntity\n case 'water':\n return WaterEntity\n default:\n return UnknownEntity\n }\n}\n\nfunction entityFromType (type: number) {\n switch (type) {\n case PolymerEntity:\n return 'polymer'\n case NonPolymerEntity:\n return 'non-polymer'\n case MacrolideEntity:\n return 'macrolide'\n case WaterEntity:\n return 'water'\n default:\n return undefined\n }\n}\n\nexport const EntityTypeString = {\n 'polymer': PolymerEntity,\n 'non-polymer': NonPolymerEntity,\n 'macrolide': MacrolideEntity,\n 'water': WaterEntity,\n}\nexport type EntityTypeString = keyof typeof EntityTypeString\n\n/**\n * Entity of a {@link Structure}\n */\nexport default class Entity {\n structure: Structure\n index: number\n description: string\n entityType: number\n chainIndexList: number[]\n\n /**\n * @param {Structure} structure - structure the entity belongs to\n * @param {Integer} index - index within structure.entityList\n * @param {String} description - entity description\n * @param {String} type - entity type\n * @param {Array} chainIndexList - entity chainIndexList\n */\n constructor (structure: Structure, index: number, description = '', type?: EntityTypeString, chainIndexList: number[] = []) {\n this.structure = structure\n this.index = index\n this.description = description\n this.entityType = entityTypeFromString(type || '')\n this.chainIndexList = chainIndexList\n\n chainIndexList.forEach(function (ci: number) {\n structure.chainStore.entityIndex[ ci ] = index\n })\n }\n\n get type () { return entityFromType(this.entityType) }\n\n getEntityType () {\n return this.entityType\n }\n\n isPolymer () {\n return this.entityType === PolymerEntity\n }\n\n isNonPolymer () {\n return this.entityType === NonPolymerEntity\n }\n\n isMacrolide () {\n return this.entityType === MacrolideEntity\n }\n\n isWater () {\n return this.entityType === WaterEntity\n }\n\n eachChain (callback: (cp: ChainProxy) => any) {\n const cp = this.structure.getChainProxy()\n\n this.chainIndexList.forEach(function (index) {\n cp.index = index\n callback(cp)\n })\n }\n}","/**\n * @file Unitcell\n * @author Alexander Rose \n * @private\n */\n\nimport { Color, Vector3, Matrix4 } from 'three'\n\nimport { defaults } from '../utils'\nimport { degToRad } from '../math/math-utils'\nimport {\n uniformArray, uniformArray3, centerArray3\n} from '../math/array-utils'\nimport { UnitcellPicker } from '../utils/picker'\nimport Structure from '../structure/structure'\n\nexport interface UnitcellParams {\n a: number\n b: number\n c: number\n alpha: number\n beta: number\n gamma: number\n spacegroup: string\n cartToFrac?: Matrix4\n}\n\nconst DefaultBoxParams = {\n a: 1,\n b: 1,\n c: 1,\n alpha: 90,\n beta: 90,\n gamma: 90,\n spacegroup: 'P 1'\n}\n\nexport interface UnitcellDataParams {\n colorValue?: string|number,\n radius?: number\n}\n\n/**\n * Unitcell class\n */\nclass Unitcell {\n a: number\n b: number\n c: number\n alpha: number\n beta: number\n gamma: number\n\n spacegroup: string\n\n cartToFrac = new Matrix4()\n fracToCart = new Matrix4()\n\n volume: number\n\n /**\n * @param {Object} params - unitcell parameters\n * @param {Number} params.a - length a\n * @param {Number} params.b - length b\n * @param {Number} params.c - length c\n * @param {Number} params.alpha - angle alpha\n * @param {Number} params.beta - angle beta\n * @param {Number} params.gamma - angle gamma\n * @param {String} params.spacegroup - spacegroup\n * @param {Matrix4} [params.cartToFrac] - transformation matrix from\n * cartesian to fractional coordinates\n * @param {Matrix4} [params.scale] - alias for `params.cartToFrac`\n */\n constructor (params: UnitcellParams = DefaultBoxParams) {\n this.a = params.a\n this.b = params.b\n this.c = params.c\n this.alpha = params.alpha\n this.beta = params.beta\n this.gamma = params.gamma\n this.spacegroup = params.spacegroup\n\n const alphaRad = degToRad(this.alpha)\n const betaRad = degToRad(this.beta)\n const gammaRad = degToRad(this.gamma)\n const cosAlpha = Math.cos(alphaRad)\n const cosBeta = Math.cos(betaRad)\n const cosGamma = Math.cos(gammaRad)\n const sinBeta = Math.sin(betaRad)\n const sinGamma = Math.sin(gammaRad)\n\n this.volume = (\n this.a * this.b * this.c *\n Math.sqrt(\n 1 - cosAlpha * cosAlpha - cosBeta * cosBeta - cosGamma * cosGamma +\n 2.0 * cosAlpha * cosBeta * cosGamma\n )\n )\n\n if (params.cartToFrac === undefined) {\n // https://github.com/biojava/biojava/blob/master/biojava-structure/src/main/java/org/biojava/nbio/structure/xtal/CrystalCell.java\n\n const cStar = (this.a * this.b * sinGamma) / this.volume\n const cosAlphaStar = (\n (cosBeta * cosGamma - cosAlpha) / (sinBeta * sinGamma)\n )\n\n this.fracToCart.set(\n this.a, 0, 0, 0,\n this.b * cosGamma, this.b * sinGamma, 0, 0,\n this.c * cosBeta, -this.c * sinBeta * cosAlphaStar, 1.0 / cStar, 0,\n 0, 0, 0, 1\n ).transpose()\n this.cartToFrac.getInverse(this.fracToCart)\n } else {\n this.cartToFrac.copy(params.cartToFrac)\n this.fracToCart.getInverse(this.cartToFrac)\n }\n }\n\n getPosition (structure: Structure): Float32Array {\n const vertexPosition = new Float32Array(3 * 8)\n\n if (structure.unitcell) {\n const uc = structure.unitcell\n const centerFrac = structure.center.clone().applyMatrix4(uc.cartToFrac).floor()\n const v = new Vector3()\n\n let cornerOffset = 0\n const addCorner = function (x: number, y: number, z: number) {\n v.set(x, y, z)\n .add(centerFrac)\n .applyMatrix4(uc.fracToCart)\n .toArray(vertexPosition as any, cornerOffset)\n cornerOffset += 3\n }\n addCorner(0, 0, 0)\n addCorner(1, 0, 0)\n addCorner(0, 1, 0)\n addCorner(0, 0, 1)\n addCorner(1, 1, 0)\n addCorner(1, 0, 1)\n addCorner(0, 1, 1)\n addCorner(1, 1, 1)\n }\n\n return vertexPosition\n }\n\n getCenter (structure: Structure) {\n return centerArray3(this.getPosition(structure))\n }\n\n getData (structure: Structure, params: UnitcellDataParams = {}) {\n const colorValue = defaults(params.colorValue, 'orange')\n const radius = defaults(params.radius, Math.cbrt(this.volume) / 200)\n\n const c = new Color(colorValue)\n const v = new Vector3()\n\n const vertexPosition = this.getPosition(structure)\n const vertexColor = uniformArray3(8, c.r, c.g, c.b)\n const vertexRadius = uniformArray(8, radius)\n\n const edgePosition1 = new Float32Array(3 * 12)\n const edgePosition2 = new Float32Array(3 * 12)\n const edgeColor = uniformArray3(12, c.r, c.g, c.b)\n const edgeRadius = uniformArray(12, radius)\n\n let edgeOffset = 0\n function addEdge (a: number, b: number) {\n v.fromArray(vertexPosition as any, a * 3)\n .toArray(edgePosition1 as any, edgeOffset)\n v.fromArray(vertexPosition as any, b * 3)\n .toArray(edgePosition2 as any, edgeOffset)\n edgeOffset += 3\n }\n addEdge(0, 1)\n addEdge(0, 2)\n addEdge(0, 3)\n addEdge(1, 4)\n addEdge(1, 5)\n addEdge(2, 6)\n addEdge(3, 5)\n addEdge(4, 7)\n addEdge(5, 7)\n addEdge(2, 4)\n addEdge(7, 6)\n addEdge(3, 6)\n\n const picker = new UnitcellPicker(this, structure)\n\n return {\n vertex: {\n position: vertexPosition,\n color: vertexColor,\n radius: vertexRadius,\n picking: picker\n },\n edge: {\n position1: edgePosition1,\n position2: edgePosition2,\n color: edgeColor,\n color2: edgeColor,\n radius: edgeRadius,\n picking: picker\n }\n }\n }\n}\n\nexport default Unitcell\n","/**\n * @file Pdb Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureParser from './structure-parser'\nimport Entity, { EntityTypeString } from '../structure/entity'\nimport Unitcell, { UnitcellParams } from '../symmetry/unitcell'\nimport Assembly, { AssemblyPart } from '../symmetry/assembly'\nimport { PDBQTSpecialElements, WaterNames } from '../structure/structure-constants'\nimport {\n assignSecondaryStructure, InferBondsOptions, buildUnitcellAssembly,\n calculateBonds, calculateChainnames, calculateSecondaryStructure\n} from '../structure/structure-utils'\nimport Streamer from '../streamer/streamer';\nimport { ParserParameters } from './parser';\nimport { NumberArray } from '../types';\nimport { Structure } from '../ngl';\n\n// PDB helix record encoding\nconst HelixTypes: {[k: number]: string} = {\n 1: 'h', // Right-handed alpha (default)\n 2: 'h', // Right-handed omega\n 3: 'i', // Right-handed pi\n 4: 'h', // Right-handed gamma\n 5: 'g', // Right-handed 310\n 6: 'h', // Left-handed alpha\n 7: 'h', // Left-handed omega\n 8: 'h', // Left-handed gamma\n 9: 'h', // 27 ribbon/helix\n 10: 'h', // Polyproline\n 0: 'h' //Used to be ''\n}\n\nconst dAminoAcids = [\n 'DAL', // D-ALANINE\n 'DAR', // D-ARGININE\n 'DSG', // D-ASPARAGINE\n 'DAS', // D-ASPARTIC ACID\n 'DCY', // D-CYSTEINE\n 'DGL', // D-GLUTAMIC ACID\n 'DGN', // D-GLUTAMINE\n 'DHI', // D-HISTIDINE\n 'DIL', // D-ISOLEUCINE\n 'DLE', // D-LEUCINE\n 'DLY', // D-LYSINE\n 'MED', // D-METHIONINE\n 'DPN', // D-PHENYLALANINE\n 'DPR', // D-PROLINE\n 'DSN', // D-SERINE\n 'DTH', // D-THREONINE\n 'DTR', // D-TRYPTOPHAN\n 'DTY', // D-TYROSINE\n 'DVA', // D-VALINE\n\n 'DNE' // D-NORLEUCINE\n\n // ??? // D-SELENOCYSTEINE\n]\n\nconst entityKeyList = [\n 'MOL_ID', 'MOLECULE', 'CHAIN', 'FRAGMENT', 'SYNONYM',\n 'EC', 'ENGINEERED', 'MUTATION', 'OTHER_DETAILS'\n]\n\nconst reWhitespace = /\\s+/\n\nfunction getModresId (resno: number, chainname?: string, inscode?: string) {\n let id = `${resno}`\n if (chainname) id += `:${chainname}`\n if (inscode) id += `^${inscode}`\n return id\n}\n\nexport interface PdbParserParameters extends ParserParameters {\n hex: boolean\n inferBonds: InferBondsOptions\n}\n\nclass PdbParser extends StructureParser {\n\n hex: boolean\n inferBonds: InferBondsOptions\n\n /**\n * Create a pdb parser\n * @param {Streamer} streamer - streamer object\n * @param {Object} params - params object\n * @param {Boolean} params.hex - hexadecimal parsing of\n * atom numbers >99.999 and\n * residue numbers >9.999\n * @param {InferBondsOptions} params.inferBonds: 'all': use explicit bonds and detect by distance\n * 'auto': If a hetgroup residue has explicit bonds, don't auto-detect\n * 'none': Don't add any bonds automatically\n * @return {undefined}\n */\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.hex = defaults(p.hex, false)\n this.inferBonds = defaults(p.inferBonds, 'all')\n }\n\n get type () { return 'pdb' }\n\n _parse () {\n // http://www.wwpdb.org/documentation/file-format.php\n\n if (Debug) Log.time('PdbParser._parse ' + this.name)\n\n let isLegacy = false\n const headerLine = this.streamer.peekLines(1)[ 0 ]\n const headerId = headerLine.substr(62, 4)\n const legacyId = headerLine.substr(72, 4)\n if (headerId === legacyId && legacyId.trim()) {\n isLegacy = true\n }\n\n const isPqr = this.type === 'pqr'\n const isPdbqt = this.type === 'pdbqt'\n\n const s: Structure = this.structure\n const sb = this.structureBuilder\n\n const hex = this.hex\n let serialRadix = 10\n let resnoRadix = 10\n\n const firstModelOnly = this.firstModelOnly\n const asTrajectory = this.asTrajectory\n const cAlphaOnly = this.cAlphaOnly\n\n const frames = s.frames\n const boxes = s.boxes\n let doFrames = false\n let currentFrame: NumberArray, currentCoord: number\n\n const biomolDict = s.biomolDict\n let currentBiomol: Assembly\n let currentPart: AssemblyPart\n let currentMatrix: Matrix4\n\n let line, recordName\n let serial, chainname: string, resno: number, resname: string, occupancy: number\n let inscode: string, atomname, hetero: boolean, bfactor: number, altloc\n let formalCharge: number\n\n let startChain, startResi, startIcode\n let endChain, endResi, endIcode\n\n let serialDict: {[k: number]: number} = {}\n const unitcellDict: Partial<{\n origx: Matrix4\n scale: Matrix4\n a: number\n b: number\n c: number\n alpha: number\n beta: number\n gamma: number\n spacegroup: string\n }> = {}\n const bondDict: {[k: string]: boolean} = {}\n\n const entityDataList: {chainList: string[], name: string}[] = []\n let currentEntityData: {chainList: string[], name: string}\n let currentEntityKey: 'MOL_ID'|'MOLECULE'|'CHAIN'|'FRAGMENT'|'SYNONYM'|'EC'|'ENGINEERED'|'MUTATION'|'OTHER_DETAILS'\n // MOL_ID Numbers each component; also used in SOURCE to associate\n // the information.\n // MOLECULE Name of the macromolecule.\n // CHAIN Comma-separated list of chain identifier(s).\n // FRAGMENT Specifies a domain or region of the molecule.\n // SYNONYM Comma-separated list of synonyms for the MOLECULE.\n // EC The Enzyme Commission number associated with the molecule.\n // If there is more than one EC number, they are presented\n // as a comma-separated list.\n // ENGINEERED Indicates that the molecule was produced using\n // recombinant technology or by purely chemical synthesis.\n // MUTATION Indicates if there is a mutation.\n // OTHER_DETAILS Additional comments.\n\n const hetnameDict: {[k: string]: string} = {}\n const modresDict: {[k: string]: any} = {}\n\n const chainDict: {[k: string]: number} = {}\n let chainIdx: number, chainid: string, newChain: boolean\n let currentChainname: string, currentResno: number, currentResname: string, currentInscode: string\n\n const seqresDict: {[k: string]: string[]} = {}\n let currentSeqresChainname: string\n\n const secStruct = {\n helices: [] as any[],\n sheets: [] as any[]\n }\n const helices = secStruct.helices\n const sheets = secStruct.sheets\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.resize(Math.round(this.streamer.data.length / 80))\n if (isPqr || isPdbqt) atomStore.addField('partialCharge', 1, 'float32')\n if (isPqr) atomStore.addField('radius', 1, 'float32')\n\n const ap1 = s.getAtomProxy()\n const ap2 = s.getAtomProxy()\n\n let idx = 0\n let modelIdx = 0\n let pendingStart = true\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n line = lines[ i ]\n recordName = line.substr(0, 6)\n\n if (recordName === 'ATOM ' || recordName === 'HETATM') {\n // http://www.wwpdb.org/documentation/file-format-content/format33/sect9.html#ATOM\n // PQR: Field_name Atom_number Atom_name Residue_name Chain_ID Residue_number X Y Z Charge Radius\n\n if (pendingStart) {\n if (asTrajectory) {\n if (doFrames) {\n currentFrame = new Float32Array(atomStore.count * 3)\n frames.push(currentFrame)\n } else {\n currentFrame = []\n }\n currentCoord = 0\n } else {\n if (!firstModelOnly) serialDict = {}\n }\n\n chainIdx = 1\n chainid = chainIdx.toString()\n newChain = true\n\n pendingStart = false\n }\n\n if (firstModelOnly && modelIdx > 0) continue\n\n let x, y, z, ls: string[], dd = 0\n\n if (isPqr) {\n ls = line.split(reWhitespace)\n dd = ls.length === 10 ? 1 : 0\n\n atomname = ls[ 2 ]\n if (cAlphaOnly && atomname !== 'CA') continue\n\n x = parseFloat(ls[ 6 - dd ])\n y = parseFloat(ls[ 7 - dd ])\n z = parseFloat(ls[ 8 - dd ])\n } else {\n atomname = line.substr(12, 4).trim()\n if (cAlphaOnly && atomname !== 'CA') continue\n\n x = parseFloat(line.substr(30, 8))\n y = parseFloat(line.substr(38, 8))\n z = parseFloat(line.substr(46, 8))\n }\n\n if (asTrajectory) {\n const j = currentCoord * 3\n\n currentFrame[ j + 0 ] = x\n currentFrame[ j + 1 ] = y\n currentFrame[ j + 2 ] = z\n\n currentCoord += 1\n\n if (doFrames) continue\n }\n\n let element\n\n if (isPqr) {\n serial = parseInt(ls![ 1 ])\n element = ''\n hetero = (line[ 0 ] === 'H')\n chainname = dd ? '' : ls![ 4 ]\n resno = parseInt(ls![ 5 - dd! ])\n inscode = ''\n resname = ls![ 3 ]\n altloc = ''\n occupancy = 1.0\n } else {\n serial = parseInt(line.substr(6, 5), serialRadix)\n if (hex && serial === 99999) {\n serialRadix = 16\n }\n hetero = (line[ 0 ] === 'H')\n chainname = line[ 21 ].trim()\n resno = parseInt(line.substr(22, 4), resnoRadix)\n if (hex && resno === 9999) {\n resnoRadix = 16\n }\n inscode = line[ 26 ].trim()\n resname = line.substr(17, 4).trim() || 'MOL'\n bfactor = parseFloat(line.substr(60, 6))\n altloc = line[ 16 ].trim()\n occupancy = parseFloat(line.substr(54, 6))\n\n if (!isLegacy) {\n if (isPdbqt) {\n element = line.substr(76, 3).trim()\n // @ts-expect-error TS limitation on narrowing indexes types with `in`\n if (element in PDBQTSpecialElements) element = PDBQTSpecialElements[element]\n } else {\n element = line.substr(76, 2).trim()\n if (!chainname) {\n chainname = line.substr(72, 4).trim() // segid\n }\n }\n // Where specified, formalCharge is of form \"2-\" or \"1+\"\n formalCharge = parseInt((line.substr(79,1) + line.substr(78, 1)).trim())\n }\n }\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname, element)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = serial\n atomStore.altloc[ idx ] = altloc.charCodeAt(0)\n atomStore.occupancy[ idx ] = isNaN(occupancy) ? 0 : occupancy\n\n if (isPqr) {\n atomStore.partialCharge![ idx ] = parseFloat(ls![ 9 - dd! ])\n atomStore.radius[ idx ] = parseFloat(ls![ 10 - dd! ])\n } else {\n atomStore.bfactor[ idx ] = isNaN(bfactor) ? 0 : bfactor\n if (isPdbqt) {\n atomStore.partialCharge![ idx ] = parseFloat(line.substr(70, 6))\n }\n // isFinite check will reject undefined (in legacy case) and NaN values\n if (isFinite(formalCharge)) {\n if (!atomStore.formalCharge) {\n atomStore.addField('formalCharge', 1, 'int8')\n }\n atomStore.formalCharge![ idx ] = formalCharge\n }\n }\n\n const modresId = getModresId(resno, chainname, inscode)\n\n // TODO instead of looking at MODRES look at SEQRES and\n // missing residues in REMARK 465\n if (hetero && !modresDict[modresId] && !dAminoAcids.includes(resname)) {\n if (currentChainname !== chainname || currentResname !== resname ||\n (!WaterNames.includes(resname) &&\n (currentResno !== resno || currentInscode !== inscode))\n ) {\n chainIdx += 1\n chainid = chainIdx.toString()\n\n currentResno = resno\n currentResname = resname\n currentInscode = inscode\n }\n } else if (!newChain && currentChainname !== chainname) {\n chainIdx += 1\n chainid = chainIdx.toString()\n }\n\n sb.addAtom(modelIdx, chainname, chainid, resname, resno, hetero, undefined, inscode)\n\n serialDict[ serial ] = idx\n idx += 1\n newChain = false\n currentChainname = chainname\n } else if (recordName === 'CONECT') {\n const fromIdx = serialDict[ parseInt(line.substr(6, 5)) ]\n const pos = [ 11, 16, 21, 26 ]\n const bondIndex: {[k: number]: number} = {}\n\n if (fromIdx === undefined) {\n // Log.log( \"missing CONNECT serial\" );\n continue\n }\n\n for (let j = 0; j < 4; ++j) {\n let toIdx = parseInt(line.substr(pos[ j ], 5))\n if (Number.isNaN(toIdx)) continue\n toIdx = serialDict[ toIdx ]\n if (toIdx === undefined) {\n // Log.log( \"missing CONNECT serial\" );\n continue\n }/* else if( toIdx < fromIdx ){\n // likely a duplicate in standard PDB format\n // but not necessarily, so better remove duplicates\n // in a pass after parsing (and auto bonding)\n continue;\n } */\n\n if (fromIdx < toIdx) {\n ap1.index = fromIdx\n ap2.index = toIdx\n } else {\n ap1.index = toIdx\n ap2.index = fromIdx\n }\n\n // interpret records where a 'toIdx' atom is given multiple times\n // as double/triple bonds, e.g. CONECT 1529 1528 1528 is a double bond\n if (bondIndex[ toIdx ] !== undefined) {\n s.bondStore.bondOrder[ bondIndex[ toIdx ] ] += 1\n } else {\n const hash = ap1.index + '|' + ap2.index\n if (bondDict[ hash ] === undefined) {\n bondDict[ hash ] = true\n bondIndex[ toIdx ] = s.bondStore.count\n s.bondStore.addBond(ap1, ap2, 1) // start/assume with single bond\n }\n }\n }\n } else if (recordName === 'HELIX ') {\n startChain = line[ 19 ].trim()\n startResi = parseInt(line.substr(21, 4))\n startIcode = line[ 25 ].trim()\n endChain = line[ 31 ].trim()\n endResi = parseInt(line.substr(33, 4))\n endIcode = line[ 37 ].trim()\n let helixType = parseInt(line.substr(39, 1))\n helixType = (HelixTypes[ helixType ] || HelixTypes[0]).charCodeAt(0)\n helices.push([\n startChain, startResi, startIcode,\n endChain, endResi, endIcode,\n helixType\n ])\n } else if (recordName === 'SHEET ') {\n startChain = line[ 21 ].trim()\n startResi = parseInt(line.substr(22, 4))\n startIcode = line[ 26 ].trim()\n endChain = line[ 32 ].trim()\n endResi = parseInt(line.substr(33, 4))\n endIcode = line[ 37 ].trim()\n sheets.push([\n startChain, startResi, startIcode,\n endChain, endResi, endIcode\n ])\n } else if (recordName === 'HETNAM') {\n hetnameDict[ line.substr(11, 3) ] = line.substr(15).trim()\n } else if (recordName === 'SEQRES') {\n const seqresChainname = line[11].trim()\n if (seqresChainname !== currentSeqresChainname) {\n seqresDict[ seqresChainname ] = []\n currentSeqresChainname = seqresChainname\n }\n seqresDict[ seqresChainname ].push(\n ...line.substr(19).trim().split(reWhitespace)\n )\n } else if (recordName === 'MODRES') {\n // MODRES 2SRC PTR A 527 TYR O-PHOSPHOTYROSINE\n const resname = line.substr(12, 3).trim()\n const chainname = line[16].trim()\n const inscode = line[22].trim()\n const resno = parseInt(line.substr(18, 4).trim())\n const id = getModresId(resno, chainname, inscode)\n modresDict[ id ] = { resname, chainname, inscode, resno }\n } else if (recordName === 'COMPND') {\n const comp = line.substr(10, 70).trim()\n const keyEnd = comp.indexOf(':')\n const key = comp.substring(0, keyEnd)\n let value\n\n if (entityKeyList.includes(key)) {\n currentEntityKey = key as 'MOL_ID'|'MOLECULE'|'CHAIN'|'FRAGMENT'|'SYNONYM'|'EC'|'ENGINEERED'|'MUTATION'|'OTHER_DETAILS'\n value = comp.substring(keyEnd + 2)\n } else {\n value = comp\n }\n value = value.replace(/;$/, '')\n\n if (currentEntityKey === 'MOL_ID') {\n currentEntityData = {\n chainList: [],\n name: ''\n }\n entityDataList.push(currentEntityData)\n } else if (currentEntityKey === 'MOLECULE') {\n if (currentEntityData.name) currentEntityData.name += ' '\n currentEntityData.name += value\n } else if (currentEntityKey === 'CHAIN') {\n Array.prototype.push.apply(\n currentEntityData.chainList,\n value.split(/\\s*,\\s*/)\n )\n }\n } else if (line.startsWith('TER')) {\n const cp = s.getChainProxy(s.chainStore.count - 1)\n chainDict[ cp.chainname ] = cp.index\n chainIdx += 1\n chainid = chainIdx.toString()\n newChain = true\n } else if (recordName === 'REMARK' && line.substr(7, 3) === '350') {\n if (line.substr(11, 12) === 'BIOMOLECULE:') {\n let name = line.substr(23).trim()\n if (/^(0|[1-9][0-9]*)$/.test(name)) name = 'BU' + name\n\n currentBiomol = new Assembly(name)\n biomolDict[ name ] = currentBiomol\n } else if (line.substr(13, 5) === 'BIOMT') {\n const biomt = line.split(/\\s+/)\n const row = parseInt(line[ 18 ]) - 1\n\n if (row === 0) {\n currentMatrix = new Matrix4()\n currentPart.matrixList.push(currentMatrix)\n }\n\n const biomtElms = currentMatrix.elements\n\n biomtElms[ 4 * 0 + row ] = parseFloat(biomt[ 4 ])\n biomtElms[ 4 * 1 + row ] = parseFloat(biomt[ 5 ])\n biomtElms[ 4 * 2 + row ] = parseFloat(biomt[ 6 ])\n biomtElms[ 4 * 3 + row ] = parseFloat(biomt[ 7 ])\n } else if (\n line.substr(11, 30) === 'APPLY THE FOLLOWING TO CHAINS:' ||\n line.substr(11, 30) === ' AND CHAINS:'\n ) {\n if (line.substr(11, 5) === 'APPLY') {\n currentPart = currentBiomol.addPart()\n }\n\n const chainList = line.substr(41, 30).split(',')\n for (let j = 0, jl = chainList.length; j < jl; ++j) {\n const c = chainList[ j ].trim()\n if (c) currentPart.chainList.push(c)\n }\n }\n } else if (recordName === 'HEADER') {\n s.id = line.substr(62, 4)\n } else if (recordName === 'TITLE ') {\n s.title += (s.title ? ' ' : '') + line.substr(10, 70).trim()\n } else if (recordName === 'MODEL ') {\n pendingStart = true\n } else if (recordName === 'ENDMDL' || line.trim() === 'END') {\n if (pendingStart) continue\n\n if (asTrajectory && !doFrames) {\n frames.push(new Float32Array(currentFrame))\n doFrames = true\n }\n\n modelIdx += 1\n pendingStart = true\n } else if (line.substr(0, 5) === 'MTRIX') {\n // ignore 'given' operators\n if (line[ 59 ] === '1') continue\n\n if (!currentBiomol || currentBiomol.name !== 'NCS') {\n const ncsName = 'NCS'\n currentBiomol = new Assembly(ncsName)\n biomolDict[ ncsName ] = currentBiomol\n currentPart = currentBiomol.addPart()\n }\n\n const ncs = line.split(/\\s+/)\n const ncsRow = parseInt(line[ 5 ]) - 1\n\n if (ncsRow === 0) {\n currentMatrix = new Matrix4()\n currentPart.matrixList.push(currentMatrix)\n }\n\n const ncsElms = currentMatrix.elements\n\n ncsElms[ 4 * 0 + ncsRow ] = parseFloat(ncs[ 2 ])\n ncsElms[ 4 * 1 + ncsRow ] = parseFloat(ncs[ 3 ])\n ncsElms[ 4 * 2 + ncsRow ] = parseFloat(ncs[ 4 ])\n ncsElms[ 4 * 3 + ncsRow ] = parseFloat(ncs[ 5 ])\n } else if (line.substr(0, 5) === 'ORIGX') {\n if (!unitcellDict.origx) {\n unitcellDict.origx = new Matrix4()\n }\n\n const orgix = line.split(/\\s+/)\n const origxRow = parseInt(line[ 5 ]) - 1\n const origxElms = unitcellDict.origx.elements\n\n origxElms[ 4 * 0 + origxRow ] = parseFloat(orgix[ 1 ])\n origxElms[ 4 * 1 + origxRow ] = parseFloat(orgix[ 2 ])\n origxElms[ 4 * 2 + origxRow ] = parseFloat(orgix[ 3 ])\n origxElms[ 4 * 3 + origxRow ] = parseFloat(orgix[ 4 ])\n } else if (line.substr(0, 5) === 'SCALE') {\n if (!unitcellDict.scale) {\n unitcellDict.scale = new Matrix4()\n }\n\n const scale = line.split(/\\s+/)\n const scaleRow = parseInt(line[ 5 ]) - 1\n const scaleElms = unitcellDict.scale.elements\n\n scaleElms[ 4 * 0 + scaleRow ] = parseFloat(scale[ 1 ])\n scaleElms[ 4 * 1 + scaleRow ] = parseFloat(scale[ 2 ])\n scaleElms[ 4 * 2 + scaleRow ] = parseFloat(scale[ 3 ])\n scaleElms[ 4 * 3 + scaleRow ] = parseFloat(scale[ 4 ])\n } else if (recordName === 'CRYST1') {\n // CRYST1 55.989 55.989 55.989 90.00 90.00 90.00 P 1 1\n // 7 - 15 Real(9.3) a (Angstroms)\n // 16 - 24 Real(9.3) b (Angstroms)\n // 25 - 33 Real(9.3) c (Angstroms)\n // 34 - 40 Real(7.2) alpha alpha (degrees).\n // 41 - 47 Real(7.2) beta beta (degrees).\n // 48 - 54 Real(7.2) gamma gamma (degrees).\n // 56 - 66 LString sGroup Space group.\n // 67 - 70 Integer z Z value.\n\n const aLength = parseFloat(line.substr(6, 9))\n const bLength = parseFloat(line.substr(15, 9))\n const cLength = parseFloat(line.substr(24, 9))\n\n const alpha = parseFloat(line.substr(33, 7))\n const beta = parseFloat(line.substr(40, 7))\n const gamma = parseFloat(line.substr(47, 7))\n\n const sGroup = line.substr(55, 11).trim()\n // const zValue = parseInt( line.substr( 66, 4 ) );\n\n const box = new Float32Array(9)\n box[ 0 ] = aLength\n box[ 4 ] = bLength\n box[ 8 ] = cLength\n boxes.push(box)\n\n if (modelIdx === 0) {\n unitcellDict.a = aLength\n unitcellDict.b = bLength\n unitcellDict.c = cLength\n unitcellDict.alpha = alpha\n unitcellDict.beta = beta\n unitcellDict.gamma = gamma\n unitcellDict.spacegroup = sGroup\n }\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n\n // finalize ensures resname will be defined for all rp.resname\n // (required in entity handling below)\n sb.finalize()\n\n //\n\n const en = entityDataList.length\n\n if (en) {\n s.eachChain(function (cp) {\n cp.entityIndex = en\n })\n\n entityDataList.forEach(function (e, i) {\n const chainIndexList = e.chainList.map(function (chainname) {\n return chainDict[ chainname ]\n })\n s.entityList.push(new Entity(\n s, i, e.name, 'polymer', chainIndexList\n ))\n })\n\n let ei = entityDataList.length\n const rp = s.getResidueProxy()\n const residueDict: {[k: string]: number[]} = {}\n\n s.eachChain(function (cp) {\n if (cp.entityIndex === en) {\n rp.index = cp.residueOffset\n if (!residueDict[ rp.resname ]) {\n residueDict[ rp.resname ] = []\n }\n residueDict[ rp.resname ].push(cp.index)\n }\n })\n\n Object.keys(residueDict).forEach(function (resname) {\n const chainList = residueDict[ resname ]\n let type: EntityTypeString = 'non-polymer'\n let name = hetnameDict[ resname ] || resname\n if (WaterNames.includes(resname)) {\n name = 'water'\n type = 'water'\n }\n s.entityList.push(new Entity(\n s, ei, name, type, chainList\n ))\n ei += 1\n })\n }\n\n //\n\n if (unitcellDict.a !== undefined) {\n s.unitcell = new Unitcell(unitcellDict as UnitcellParams)\n } else {\n s.unitcell = undefined\n }\n\n if (helices.length || sheets.length) {\n assignSecondaryStructure(s, secStruct)\n }\n\n s.finalizeAtoms()\n if (!isLegacy) calculateChainnames(s)\n calculateBonds(s, this.inferBonds)\n s.finalizeBonds()\n\n if (!helices.length && !sheets.length) {\n calculateSecondaryStructure(s)\n }\n buildUnitcellAssembly(s)\n\n if (Debug) Log.timeEnd('PdbParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('pdb', PdbParser)\nParserRegistry.add('pdb1', PdbParser)\nParserRegistry.add('ent', PdbParser)\n\nexport default PdbParser\n\nexport {\n HelixTypes\n}\n","/**\n * @file Cif Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport { HelixTypes } from './pdb-parser'\nimport Entity from '../structure/entity'\nimport Unitcell, { UnitcellParams } from '../symmetry/unitcell'\nimport Assembly from '../symmetry/assembly'\nimport Selection from '../selection/selection'\nimport {\n assignResidueTypeBonds, assignSecondaryStructure, buildUnitcellAssembly,\n calculateBonds, calculateSecondaryStructure\n} from '../structure/structure-utils'\nimport { Structure } from '../ngl';\nimport StructureBuilder from '../structure/structure-builder';\nimport { NumberArray } from '../types';\n\nconst reWhitespace = /\\s+/\nconst reQuotedWhitespace = /'((?:(?!'\\s).)*)'|\"((?:(?!\"\\s).)*)\"|(\\S+)/g\nconst reDoubleQuote = /\"/g\nconst reTrimQuotes = /^['\"]+|['\"]+$/g\n\ninterface Cif {[k: string]: any}\n\nfunction trimQuotes (str: string) {\n if (str && str[0] === str[ str.length - 1 ] && (str[0] === \"'\" || str[0] === '\"')) {\n return str.substring(1, str.length - 1)\n } else {\n return str\n }\n}\n\nfunction ensureArray (dict: {[k: string]: any[]}, field: string) {\n if (!Array.isArray(dict[ field ])) {\n Object.keys(dict).forEach(function (key) {\n dict[ key ] = [ dict[ key ] ]\n })\n }\n}\n\nfunction hasValue (d: string) {\n return d !== '?'\n}\n\nfunction cifDefaults (value: string, defaultValue: string) {\n return hasValue(value) ? value : defaultValue\n}\n\nfunction getBondOrder (valueOrder: string) {\n switch (valueOrder.toLowerCase()) {\n case '?': // assume single bond\n case 'sing':\n return 1\n case 'doub':\n return 2\n case 'trip':\n return 3\n case 'quad':\n return 4\n }\n return 0\n}\n\nfunction parseChemComp (cif: Cif, structure: Structure, structureBuilder: StructureBuilder) {\n const atomStore = structure.atomStore\n const atomMap = structure.atomMap\n\n let i, n\n const cc = cif.chem_comp\n const cca = cif.chem_comp_atom\n const ccb = cif.chem_comp_bond\n\n if (cc) {\n if (cc.name) {\n structure.title = cc.name.trim().replace(reTrimQuotes, '')\n }\n if (cc.id) {\n structure.id = cc.id.trim().replace(reTrimQuotes, '')\n }\n }\n\n var atomnameDict: {[k: string]: number} = {}\n\n if (cca) {\n ensureArray(cca, 'comp_id')\n\n var atomname, element, resname, resno\n n = cca.comp_id.length\n\n for (i = 0; i < n; ++i) {\n atomStore.growIfFull()\n\n atomname = cca.atom_id[ i ].replace(reDoubleQuote, '')\n element = cca.type_symbol[ i ]\n\n atomnameDict[ atomname ] = i\n atomStore.atomTypeId[ i ] = atomMap.add(atomname, element)\n\n atomStore.x[ i ] = cca.model_Cartn_x[ i ]\n atomStore.y[ i ] = cca.model_Cartn_y[ i ]\n atomStore.z[ i ] = cca.model_Cartn_z[ i ]\n atomStore.serial[ i ] = i\n\n resname = cca.pdbx_component_comp_id[ i ]\n resno = cca.pdbx_residue_numbering ? cca.pdbx_residue_numbering[ i ] : 1\n\n structureBuilder.addAtom(0, '', '', resname, resno, true)\n }\n\n for (i = 0; i < n; ++i) {\n var j = i + n\n\n atomStore.growIfFull()\n\n atomname = cca.atom_id[ i ].replace(reDoubleQuote, '')\n element = cca.type_symbol[ i ]\n\n atomStore.atomTypeId[ j ] = atomMap.add(atomname, element)\n\n atomStore.x[ j ] = cca.pdbx_model_Cartn_x_ideal[ i ]\n atomStore.y[ j ] = cca.pdbx_model_Cartn_y_ideal[ i ]\n atomStore.z[ j ] = cca.pdbx_model_Cartn_z_ideal[ i ]\n atomStore.serial[ j ] = j\n\n resname = cca.pdbx_component_comp_id[ i ]\n resno = cca.pdbx_residue_numbering ? cca.pdbx_residue_numbering[ i ] : 1\n\n structureBuilder.addAtom(1, '', '', resname, resno, true)\n }\n }\n\n if (cca && ccb) {\n ensureArray(ccb, 'comp_id')\n\n var atomname1, atomname2, bondOrder\n n = ccb.comp_id.length\n var na = cca.comp_id.length\n\n var ap1 = structure.getAtomProxy()\n var ap2 = structure.getAtomProxy()\n\n for (i = 0; i < n; ++i) {\n atomname1 = ccb.atom_id_1[ i ].replace(reDoubleQuote, '')\n atomname2 = ccb.atom_id_2[ i ].replace(reDoubleQuote, '')\n bondOrder = getBondOrder(ccb.value_order[ i ])\n\n ap1.index = atomnameDict[ atomname1 ]\n ap2.index = atomnameDict[ atomname2 ]\n structure.bondStore.growIfFull()\n structure.bondStore.addBond(ap1, ap2, bondOrder)\n\n ap1.index += na\n ap2.index += na\n structure.bondStore.growIfFull()\n structure.bondStore.addBond(ap1, ap2, bondOrder)\n }\n }\n}\n\nfunction parseCore (cif: Cif, structure: Structure, structureBuilder: StructureBuilder) {\n var atomStore = structure.atomStore\n var atomMap = structure.atomMap\n\n if (cif.data) {\n structure.id = cif.data\n structure.name = cif.data\n }\n\n structure.unitcell = new Unitcell({\n a: parseFloat(cif.cell_length_a),\n b: parseFloat(cif.cell_length_b),\n c: parseFloat(cif.cell_length_c),\n alpha: parseFloat(cif.cell_angle_alpha),\n beta: parseFloat(cif.cell_angle_beta),\n gamma: parseFloat(cif.cell_angle_gamma),\n spacegroup: trimQuotes(cif['symmetry_space_group_name_H-M'])\n })\n\n const v = new Vector3()\n const c = new Vector3()\n const n = cif.atom_site_type_symbol.length\n\n for (let i = 0; i < n; ++i) {\n atomStore.growIfFull()\n\n const atomname = cif.atom_site_label[ i ]\n const element = cif.atom_site_type_symbol[ i ]\n\n atomStore.atomTypeId[ i ] = atomMap.add(atomname, element)\n\n v.set(\n cif.atom_site_fract_x[ i ],\n cif.atom_site_fract_y[ i ],\n cif.atom_site_fract_z[ i ]\n )\n v.applyMatrix4(structure.unitcell.fracToCart)\n c.add(v)\n\n atomStore.x[ i ] = v.x\n atomStore.y[ i ] = v.y\n atomStore.z[ i ] = v.z\n if (cif.atom_site_occupancy) {\n atomStore.occupancy[ i ] = parseFloat(cif.atom_site_occupancy[ i ])\n }\n atomStore.serial[ i ] = i\n\n structureBuilder.addAtom(0, '', '', 'HET', 1, true)\n }\n\n c.divideScalar(n)\n structure.center = c\n buildUnitcellAssembly(structure)\n\n const v2 = new Vector3()\n const v3 = new Vector3()\n const ml = structure.biomolDict.SUPERCELL.partList[ 0 ].matrixList\n\n let k = n\n\n function covalent (idx: number) {\n return atomMap.get(atomStore.atomTypeId[ idx ]).covalent\n }\n const identityMatrix = new Matrix4()\n\n for (let i = 0; i < n; ++i) {\n const covalentI = covalent(i)\n\n v.set(\n atomStore.x[ i ],\n atomStore.y[ i ],\n atomStore.z[ i ]\n )\n\n ml.forEach(function (m) {\n if (identityMatrix.equals(m)) return\n\n v2.copy(v)\n v2.applyMatrix4(m)\n\n for (let j = 0; j < n; ++j) {\n v3.set(\n atomStore.x[ j ],\n atomStore.y[ j ],\n atomStore.z[ j ]\n )\n\n const distSquared = v2.distanceToSquared(v3)\n const d = covalent(j) + covalentI\n const d1 = d + 0.3\n const d2 = d - 0.5\n\n if (distSquared < (d1 * d1) && distSquared > (d2 * d2)) {\n atomStore.growIfFull()\n\n atomStore.atomTypeId[ k ] = atomStore.atomTypeId[ i ]\n atomStore.x[ k ] = v2.x\n atomStore.y[ k ] = v2.y\n atomStore.z[ k ] = v2.z\n atomStore.occupancy[ k ] = atomStore.occupancy[ i ]\n atomStore.serial[ k ] = k\n atomStore.altloc[ k ] = 'A'.charCodeAt(0)\n\n structureBuilder.addAtom(0, '', '', 'HET', 1, true)\n\n k += 1\n return\n }\n }\n })\n }\n}\n\nfunction processSecondaryStructure (cif: Cif, structure: Structure, asymIdDict: {[k: string]: string}) {\n var helices: [string, number, string, string, number, string, number][] = []\n var sheets: [string, number, string, string, number, string][] = []\n\n var i, il, begIcode, endIcode\n\n // get helices\n var sc = cif.struct_conf\n\n if (sc?.pdbx_PDB_helix_class) {\n ensureArray(sc, 'id')\n\n for (i = 0, il = sc.beg_auth_seq_id.length; i < il; ++i) {\n var helixType = parseInt(sc.pdbx_PDB_helix_class[ i ])\n if (!Number.isNaN(helixType)) {\n begIcode = sc.pdbx_beg_PDB_ins_code[ i ]\n endIcode = sc.pdbx_end_PDB_ins_code[ i ]\n helices.push([\n asymIdDict[ sc.beg_label_asym_id[ i ] ],\n parseInt(sc.beg_auth_seq_id[ i ]),\n cifDefaults(begIcode, ''),\n asymIdDict[ sc.end_label_asym_id[ i ] ],\n parseInt(sc.end_auth_seq_id[ i ]),\n cifDefaults(endIcode, ''),\n (HelixTypes[ helixType ] || HelixTypes[0]).charCodeAt(0)\n ])\n }\n }\n }\n\n // get sheets\n var ssr = cif.struct_sheet_range\n\n if (ssr) {\n ensureArray(ssr, 'id')\n\n for (i = 0, il = ssr.beg_auth_seq_id.length; i < il; ++i) {\n begIcode = ssr.pdbx_beg_PDB_ins_code[ i ]\n endIcode = ssr.pdbx_end_PDB_ins_code[ i ]\n sheets.push([\n asymIdDict[ ssr.beg_label_asym_id[ i ] ],\n parseInt(ssr.beg_auth_seq_id[ i ]),\n cifDefaults(begIcode, ''),\n asymIdDict[ ssr.end_label_asym_id[ i ] ],\n parseInt(ssr.end_auth_seq_id[ i ]),\n cifDefaults(endIcode, '')\n ])\n }\n }\n\n if (sc || ssr) {\n return {\n helices: helices,\n sheets: sheets\n }\n } else {\n return false\n }\n}\n\nfunction processSymmetry (cif: Cif, structure: Structure, asymIdDict: {[k: string]: string}) {\n // biomol & ncs processing\n var operDict: {[k: string]: Matrix4} = {}\n var biomolDict = structure.biomolDict\n\n if (cif.pdbx_struct_oper_list) {\n var biomolOp = cif.pdbx_struct_oper_list\n ensureArray(biomolOp, 'id')\n\n biomolOp.id.forEach(function (id: number, i: number) {\n var m = new Matrix4()\n var elms = m.elements\n\n elms[ 0 ] = parseFloat(biomolOp[ 'matrix[1][1]' ][ i ])\n elms[ 1 ] = parseFloat(biomolOp[ 'matrix[1][2]' ][ i ])\n elms[ 2 ] = parseFloat(biomolOp[ 'matrix[1][3]' ][ i ])\n\n elms[ 4 ] = parseFloat(biomolOp[ 'matrix[2][1]' ][ i ])\n elms[ 5 ] = parseFloat(biomolOp[ 'matrix[2][2]' ][ i ])\n elms[ 6 ] = parseFloat(biomolOp[ 'matrix[2][3]' ][ i ])\n\n elms[ 8 ] = parseFloat(biomolOp[ 'matrix[3][1]' ][ i ])\n elms[ 9 ] = parseFloat(biomolOp[ 'matrix[3][2]' ][ i ])\n elms[ 10 ] = parseFloat(biomolOp[ 'matrix[3][3]' ][ i ])\n\n elms[ 3 ] = parseFloat(biomolOp[ 'vector[1]' ][ i ])\n elms[ 7 ] = parseFloat(biomolOp[ 'vector[2]' ][ i ])\n elms[ 11 ] = parseFloat(biomolOp[ 'vector[3]' ][ i ])\n\n m.transpose()\n\n operDict[ id ] = m\n })\n }\n\n if (cif.pdbx_struct_assembly_gen) {\n var gen = cif.pdbx_struct_assembly_gen\n ensureArray(gen, 'assembly_id')\n\n var getMatrixDict = function (expr: string) {\n var matDict: {[k: string]: Matrix4} = {}\n\n var l = expr.replace(/[()']/g, '').split(',')\n\n l.forEach(function (e) {\n if (e.includes('-')) {\n var es = e.split('-')\n\n var j = parseInt(es[ 0 ])\n var m = parseInt(es[ 1 ])\n\n for (; j <= m; ++j) {\n matDict[ j ] = operDict[ j ]\n }\n } else {\n matDict[ e ] = operDict[ e ]\n }\n })\n\n return matDict\n }\n\n gen.assembly_id.forEach(function (id: string, i: number) {\n var md:{[k: string]: Matrix4} = {}\n var oe = gen.oper_expression[ i ].replace(/['\"]\\(|['\"]/g, '')\n\n if (oe.includes(')(') || oe.indexOf('(') > 0) {\n oe = oe.split('(')\n\n var md1 = getMatrixDict(oe[ 0 ])\n var md2 = getMatrixDict(oe[ 1 ])\n\n Object.keys(md1).forEach(function (k1) {\n Object.keys(md2).forEach(function (k2) {\n var mat = new Matrix4()\n\n mat.multiplyMatrices(md1[ k1 ], md2[ k2 ])\n md[ k1 + 'x' + k2 ] = mat\n })\n })\n } else {\n md = getMatrixDict(oe)\n }\n\n var matrixList = []\n for (var k in md) {\n matrixList.push(md[ k ])\n }\n\n var name = id\n if (/^(0|[1-9][0-9]*)$/.test(name)) name = 'BU' + name\n\n var chainList = gen.asym_id_list[ i ].split(',')\n for (var j = 0, jl = chainList.length; j < jl; ++j) {\n chainList[ j ] = asymIdDict[ chainList[ j ] ]\n }\n\n if (biomolDict[ name ] === undefined) {\n biomolDict[ name ] = new Assembly(name)\n }\n biomolDict[ name ].addPart(matrixList, chainList)\n })\n }\n\n // non-crystallographic symmetry operations\n if (cif.struct_ncs_oper) {\n var ncsOp = cif.struct_ncs_oper\n ensureArray(ncsOp, 'id')\n\n var ncsName = 'NCS'\n biomolDict[ ncsName ] = new Assembly(ncsName)\n var ncsPart = biomolDict[ ncsName ].addPart()\n\n ncsOp.id.forEach(function (id: string, i: number) {\n // ignore 'given' operators\n if (ncsOp.code[ i ] === 'given') return\n\n var m = new Matrix4()\n var elms = m.elements\n\n elms[ 0 ] = parseFloat(ncsOp[ 'matrix[1][1]' ][ i ])\n elms[ 1 ] = parseFloat(ncsOp[ 'matrix[1][2]' ][ i ])\n elms[ 2 ] = parseFloat(ncsOp[ 'matrix[1][3]' ][ i ])\n\n elms[ 4 ] = parseFloat(ncsOp[ 'matrix[2][1]' ][ i ])\n elms[ 5 ] = parseFloat(ncsOp[ 'matrix[2][2]' ][ i ])\n elms[ 6 ] = parseFloat(ncsOp[ 'matrix[2][3]' ][ i ])\n\n elms[ 8 ] = parseFloat(ncsOp[ 'matrix[3][1]' ][ i ])\n elms[ 9 ] = parseFloat(ncsOp[ 'matrix[3][2]' ][ i ])\n elms[ 10 ] = parseFloat(ncsOp[ 'matrix[3][3]' ][ i ])\n\n elms[ 3 ] = parseFloat(ncsOp[ 'vector[1]' ][ i ])\n elms[ 7 ] = parseFloat(ncsOp[ 'vector[2]' ][ i ])\n elms[ 11 ] = parseFloat(ncsOp[ 'vector[3]' ][ i ])\n\n m.transpose()\n\n ncsPart.matrixList.push(m)\n })\n\n if (ncsPart.matrixList.length === 0) {\n delete biomolDict[ ncsName ]\n }\n }\n\n // cell & symmetry\n const unitcellDict: {\n a?: number\n b?: number\n c?: number\n alpha?: number\n beta?: number\n gamma?: number\n spacegroup?: string\n origx?: Matrix4\n scale?: Matrix4\n } = {}\n\n if (cif.cell) {\n const cell = cif.cell\n\n const a = parseFloat(cell.length_a)\n const b = parseFloat(cell.length_b)\n const c = parseFloat(cell.length_c)\n\n const box = new Float32Array(9)\n box[ 0 ] = a\n box[ 4 ] = b\n box[ 8 ] = c\n structure.boxes.push(box)\n\n unitcellDict.a = a\n unitcellDict.b = b\n unitcellDict.c = c\n unitcellDict.alpha = parseFloat(cell.angle_alpha)\n unitcellDict.beta = parseFloat(cell.angle_beta)\n unitcellDict.gamma = parseFloat(cell.angle_gamma)\n }\n\n if (cif.symmetry) {\n unitcellDict.spacegroup = trimQuotes(\n cif.symmetry[ 'space_group_name_H-M' ]\n )\n }\n\n // origx\n var origx = new Matrix4()\n\n if (cif.database_PDB_matrix) {\n var origxMat = cif.database_PDB_matrix\n var origxElms = origx.elements\n\n origxElms[ 0 ] = parseFloat(origxMat[ 'origx[1][1]' ])\n origxElms[ 1 ] = parseFloat(origxMat[ 'origx[1][2]' ])\n origxElms[ 2 ] = parseFloat(origxMat[ 'origx[1][3]' ])\n\n origxElms[ 4 ] = parseFloat(origxMat[ 'origx[2][1]' ])\n origxElms[ 5 ] = parseFloat(origxMat[ 'origx[2][2]' ])\n origxElms[ 6 ] = parseFloat(origxMat[ 'origx[2][3]' ])\n\n origxElms[ 8 ] = parseFloat(origxMat[ 'origx[3][1]' ])\n origxElms[ 9 ] = parseFloat(origxMat[ 'origx[3][2]' ])\n origxElms[ 10 ] = parseFloat(origxMat[ 'origx[3][3]' ])\n\n origxElms[ 3 ] = parseFloat(origxMat[ 'origx_vector[1]' ])\n origxElms[ 7 ] = parseFloat(origxMat[ 'origx_vector[2]' ])\n origxElms[ 11 ] = parseFloat(origxMat[ 'origx_vector[3]' ])\n\n origx.transpose()\n\n unitcellDict.origx = origx\n }\n\n // scale\n var scale = new Matrix4()\n\n if (cif.atom_sites) {\n var scaleMat = cif.atom_sites\n var scaleElms = scale.elements\n\n scaleElms[ 0 ] = parseFloat(scaleMat[ 'fract_transf_matrix[1][1]' ])\n scaleElms[ 1 ] = parseFloat(scaleMat[ 'fract_transf_matrix[1][2]' ])\n scaleElms[ 2 ] = parseFloat(scaleMat[ 'fract_transf_matrix[1][3]' ])\n\n scaleElms[ 4 ] = parseFloat(scaleMat[ 'fract_transf_matrix[2][1]' ])\n scaleElms[ 5 ] = parseFloat(scaleMat[ 'fract_transf_matrix[2][2]' ])\n scaleElms[ 6 ] = parseFloat(scaleMat[ 'fract_transf_matrix[2][3]' ])\n\n scaleElms[ 8 ] = parseFloat(scaleMat[ 'fract_transf_matrix[3][1]' ])\n scaleElms[ 9 ] = parseFloat(scaleMat[ 'fract_transf_matrix[3][2]' ])\n scaleElms[ 10 ] = parseFloat(scaleMat[ 'fract_transf_matrix[3][3]' ])\n\n scaleElms[ 3 ] = parseFloat(scaleMat[ 'fract_transf_vector[1]' ])\n scaleElms[ 7 ] = parseFloat(scaleMat[ 'fract_transf_vector[2]' ])\n scaleElms[ 11 ] = parseFloat(scaleMat[ 'fract_transf_vector[3]' ])\n\n scale.transpose()\n\n unitcellDict.scale = scale\n }\n\n if (unitcellDict.a !== undefined) {\n structure.unitcell = new Unitcell(unitcellDict as UnitcellParams)\n } else {\n structure.unitcell = undefined\n }\n}\n\nfunction processConnections (cif: Cif, structure: Structure, asymIdDict: {[k: string]: string}) {\n // add connections\n var sc = cif.struct_conn\n\n if (sc) {\n ensureArray(sc, 'id')\n\n var reDoubleQuote = /\"/g\n var ap1 = structure.getAtomProxy()\n var ap2 = structure.getAtomProxy()\n var atomIndicesCache: {[k: string]: Uint32Array|undefined} = {}\n\n for (var i = 0, il = sc.id.length; i < il; ++i) {\n // ignore:\n // hydrog - hydrogen bond\n // mismat - mismatched base pairs\n // saltbr - ionic interaction\n\n var connTypeId = sc.conn_type_id[ i ]\n if (connTypeId === 'hydrog' ||\n connTypeId === 'mismat' ||\n connTypeId === 'saltbr') continue\n\n // ignore bonds between symmetry mates\n if (sc.ptnr1_symmetry[ i ] !== '1_555' ||\n sc.ptnr2_symmetry[ i ] !== '1_555') continue\n\n // process:\n // covale - covalent bond\n // covale_base -\n // covalent modification of a nucleotide base\n // covale_phosphate -\n // covalent modification of a nucleotide phosphate\n // covale_sugar -\n // covalent modification of a nucleotide sugar\n // disulf - disulfide bridge\n // metalc - metal coordination\n // modres - covalent residue modification\n\n var inscode1 = sc.pdbx_ptnr1_PDB_ins_code[ i ]\n var altloc1 = sc.pdbx_ptnr1_label_alt_id[ i ]\n var sele1 = (\n sc.ptnr1_auth_seq_id[ i ] +\n (hasValue(inscode1) ? ('^' + inscode1) : '') +\n ':' + asymIdDict[ sc.ptnr1_label_asym_id[ i ] ] +\n '.' + sc.ptnr1_label_atom_id[ i ].replace(reDoubleQuote, '') +\n (hasValue(altloc1) ? ('%' + altloc1) : '')\n )\n var atomIndices1 = atomIndicesCache[ sele1 ]\n if (!atomIndices1) {\n var selection1 = new Selection(sele1)\n if (selection1.selection.error) {\n if (Debug) Log.warn('invalid selection for connection', sele1)\n continue\n }\n atomIndices1 = structure.getAtomIndices(selection1)\n atomIndicesCache[ sele1 ] = atomIndices1\n }\n\n var inscode2 = sc.pdbx_ptnr2_PDB_ins_code[ i ]\n var altloc2 = sc.pdbx_ptnr2_label_alt_id[ i ]\n var sele2 = (\n sc.ptnr2_auth_seq_id[ i ] +\n (hasValue(inscode2) ? ('^' + inscode2) : '') +\n ':' + asymIdDict[ sc.ptnr2_label_asym_id[ i ] ] +\n '.' + sc.ptnr2_label_atom_id[ i ].replace(reDoubleQuote, '') +\n (hasValue(altloc2) ? ('%' + altloc2) : '')\n )\n var atomIndices2 = atomIndicesCache[ sele2 ]\n if (!atomIndices2) {\n var selection2 = new Selection(sele2)\n if (selection2.selection.error) {\n if (Debug) Log.warn('invalid selection for connection', sele2)\n continue\n }\n atomIndices2 = structure.getAtomIndices(selection2)\n atomIndicesCache[ sele2 ] = atomIndices2\n }\n\n // cases with more than one atom per selection\n // - #altloc1 to #altloc2\n // - #model to #model\n // - #altloc1 * #model to #altloc2 * #model\n\n var k = atomIndices1!.length\n var l = atomIndices2!.length\n\n if (k > l) {\n var tmpA = k\n k = l\n l = tmpA\n var tmpB = atomIndices1\n atomIndices1 = atomIndices2\n atomIndices2 = tmpB\n }\n\n // console.log( k, l );\n\n if (k === 0 || l === 0) {\n if (Debug) Log.warn('no atoms found for', sele1, sele2)\n continue\n }\n\n for (var j = 0; j < l; ++j) {\n ap1.index = atomIndices1![ j % k ]\n ap2.index = atomIndices2![ j ]\n\n if (ap1 && ap2) {\n structure.bondStore.addBond(\n ap1, ap2, getBondOrder(sc.pdbx_value_order[ i ])\n )\n } else {\n Log.log('atoms for connection not found')\n }\n }\n }\n }\n}\n\nfunction processEntities (cif: Cif, structure: Structure, chainIndexDict: {[k: string]: Set}) {\n if (cif.entity) {\n ensureArray(cif.entity, 'id')\n var e = cif.entity\n var n = e.id.length\n for (var i = 0; i < n; ++i) {\n var description = e.pdbx_description[ i ]\n var type = e.type[ i ]\n var chainIndexList: number[] = Array.from(chainIndexDict[ e.id[ i ] ])\n structure.entityList[ i ] = new Entity(\n structure, i, description, type, chainIndexList\n )\n }\n }\n}\n\n//\n\nclass CifParser extends StructureParser {\n get type () { return 'cif' }\n\n _parse () {\n // http://mmcif.wwpdb.org/\n\n Log.time('CifParser._parse ' + this.name)\n\n var s = this.structure\n var sb = this.structureBuilder\n\n var firstModelOnly = this.firstModelOnly\n var asTrajectory = this.asTrajectory\n var cAlphaOnly = this.cAlphaOnly\n\n var frames = s.frames\n var currentFrame: NumberArray, currentCoord: number\n\n var rawline, line\n\n //\n\n var cif: Cif = {}\n var asymIdDict: {[k: string]: string} = {}\n var chainIndexDict:{[k: string]: Set} = {}\n\n var pendingString = false\n var currentString: string|null = null\n var pendingValue = false\n var pendingLoop = false\n var pendingName = false\n var loopPointers: string[][] = []\n var currentLoopIndex: number|null = null\n var currentCategory: string|null = null\n var currentName: string|boolean|null = null\n var first: boolean|null = null\n var pointerNames: string[] = []\n\n var authAsymId: number, authSeqId: number, labelSeqId: number,\n labelAtomId: number, labelCompId: number, labelAsymId: number, labelEntityId: number, labelAltId: number,\n groupPDB: number, id: number, typeSymbol: number, pdbxPDBmodelNum: number, pdbxPDBinsCode: number,\n CartnX: number, CartnY: number, CartnZ: number, bIsoOrEquiv: number, occupancy: number\n\n //\n\n var atomMap = s.atomMap\n var atomStore = s.atomStore\n atomStore.resize(this.streamer.data.length / 100)\n\n var idx = 0\n var modelIdx = 0\n var modelNum: number\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (var i = _i; i < _n; ++i) {\n rawline = lines[i]\n line = rawline.trim()\n\n if ((!line && !pendingString && !pendingLoop) || line[0] === '#') {\n // Log.log( \"NEW BLOCK\" );\n\n pendingString = false\n pendingLoop = false\n pendingValue = false\n loopPointers.length = 0\n currentLoopIndex = null\n currentCategory = null\n currentName = null\n first = null\n pointerNames.length = 0\n } else if (line.substring(0, 5) === 'data_') {\n cif.data = line.substring(5).trim()\n\n // Log.log( \"DATA\", data );\n } else if (line[0] === ';') {\n if (pendingString) {\n // Log.log( \"STRING END\", currentString );\n\n if (pendingLoop) {\n if (currentLoopIndex === loopPointers.length) {\n currentLoopIndex = 0\n }\n loopPointers[ currentLoopIndex as number ].push(currentString as string);\n (currentLoopIndex as number) += 1\n } else {\n if (currentName === false) {\n cif[ currentCategory as string ] = currentString\n } else {\n cif[ currentCategory as string ][ currentName as string ] = currentString //TODO currentname can equals null\n }\n }\n\n pendingString = false\n currentString = null\n } else {\n // Log.log( \"STRING START\" );\n\n pendingString = true\n currentString = line.substring(1)\n }\n } else if (line === 'loop_') {\n // Log.log( \"LOOP START\" );\n\n pendingLoop = true\n pendingName = true\n loopPointers.length = 0\n pointerNames.length = 0\n currentLoopIndex = 0\n } else if (line[0] === '_') {\n var keyParts, category, name\n\n if (pendingLoop && !pendingName) {\n pendingLoop = false\n }\n\n if (pendingLoop) {\n // Log.log( \"LOOP KEY\", line );\n\n keyParts = line.split('.')\n category = keyParts[ 0 ].substring(1)\n name = keyParts[ 1 ]\n\n if (keyParts.length === 1) {\n name = false\n if (!cif[ category ]) cif[ category ] = []\n loopPointers.push(cif[ category ])\n } else {\n if (!cif[ category ]) cif[ category ] = {}\n if (cif[ category ][ name ]) {\n if (Debug) Log.warn(category, name, 'already exists')\n } else {\n cif[ category ][ name ] = []\n loopPointers.push(cif[ category ][ name ])\n pointerNames.push(name)\n }\n }\n\n currentCategory = category\n currentName = name\n first = true\n } else {\n var keyValuePair = line.match(reQuotedWhitespace)\n var key = keyValuePair![ 0 ]\n var value = keyValuePair![ 1 ]\n keyParts = key.split('.')\n category = keyParts[ 0 ].substring(1)\n name = keyParts[ 1 ]\n\n if (keyParts.length === 1) {\n name = false\n cif[ category ] = value\n } else {\n if (!cif[ category ]) cif[ category ] = {}\n\n if (cif[ category ][ name ]) {\n if (Debug) Log.warn(category, name, 'already exists')\n } else {\n cif[ category ][ name ] = value\n }\n }\n\n if (!value) pendingValue = true\n\n currentCategory = category\n currentName = name\n }\n } else {\n if (pendingString) {\n // Log.log( \"STRING VALUE\", line );\n\n currentString += rawline\n } else if (pendingLoop) {\n // Log.log( \"LOOP VALUE\", line );\n\n if (!line) {\n continue\n } else if (currentCategory === 'atom_site') {\n const ls = line.split(reWhitespace)\n\n if (first) {\n authAsymId = pointerNames.indexOf('auth_asym_id')\n authSeqId = pointerNames.indexOf('auth_seq_id')\n labelSeqId = pointerNames.indexOf('label_seq_id')\n labelAtomId = pointerNames.indexOf('label_atom_id')\n labelCompId = pointerNames.indexOf('label_comp_id')\n labelAsymId = pointerNames.indexOf('label_asym_id')\n labelEntityId = pointerNames.indexOf('label_entity_id')\n labelAltId = pointerNames.indexOf('label_alt_id')\n CartnX = pointerNames.indexOf('Cartn_x')\n CartnY = pointerNames.indexOf('Cartn_y')\n CartnZ = pointerNames.indexOf('Cartn_z')\n id = pointerNames.indexOf('id')\n typeSymbol = pointerNames.indexOf('type_symbol')\n groupPDB = pointerNames.indexOf('group_PDB')\n bIsoOrEquiv = pointerNames.indexOf('B_iso_or_equiv')\n pdbxPDBmodelNum = pointerNames.indexOf('pdbx_PDB_model_num')\n\n pdbxPDBinsCode = pointerNames.indexOf('pdbx_PDB_ins_code')\n occupancy = pointerNames.indexOf('occupancy')\n\n first = false\n\n modelNum = parseInt(ls[ pdbxPDBmodelNum ])\n\n if (asTrajectory) {\n currentFrame = []\n currentCoord = 0\n }\n }\n\n //\n\n const _modelNum = parseInt(ls[ pdbxPDBmodelNum ])\n\n if (modelNum !== _modelNum) {\n if (asTrajectory) {\n if (modelIdx === 0) {\n frames.push(new Float32Array(currentFrame))\n }\n\n currentFrame = new Float32Array(atomStore.count * 3)\n frames.push(currentFrame)\n currentCoord = 0\n }\n\n modelIdx += 1\n }\n\n modelNum = _modelNum\n\n if (firstModelOnly && modelIdx > 0) continue\n\n //\n\n const atomname = ls[ labelAtomId ].replace(reDoubleQuote, '')\n if (cAlphaOnly && atomname !== 'CA') continue\n\n const x = parseFloat(ls[ CartnX ])\n const y = parseFloat(ls[ CartnY ])\n const z = parseFloat(ls[ CartnZ ])\n\n if (asTrajectory) {\n const frameOffset = currentCoord * 3\n\n currentFrame[ frameOffset + 0 ] = x\n currentFrame[ frameOffset + 1 ] = y\n currentFrame[ frameOffset + 2 ] = z\n\n currentCoord += 1\n\n if (modelIdx > 0) continue\n }\n\n //\n\n const resname = ls[ labelCompId ]\n const resno = parseInt(ls[ authSeqId !== -1 ? authSeqId : labelSeqId ])\n let inscode = ls[ pdbxPDBinsCode ]\n inscode = (inscode === '?') ? '' : inscode\n const chainname = ls[ authAsymId ]\n const chainid = ls[ labelAsymId ]\n const hetero = (ls[ groupPDB ][ 0 ] === 'H')\n\n //\n\n const element = ls[ typeSymbol ]\n const bfactor = parseFloat(ls[ bIsoOrEquiv ])\n const occ = parseFloat(ls[ occupancy ])\n let altloc = ls[ labelAltId ]\n altloc = (altloc === '.') ? '' : altloc\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname, element)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = parseInt(ls[ id ])\n atomStore.bfactor[ idx ] = isNaN(bfactor) ? 0 : bfactor\n atomStore.occupancy[ idx ] = isNaN(occ) ? 0 : occ\n atomStore.altloc[ idx ] = altloc.charCodeAt(0)\n\n sb.addAtom(modelIdx, chainname, chainid, resname, resno, hetero, undefined, inscode)\n\n if (Debug) {\n // check if one-to-many (chainname-asymId) relationship is\n // actually a many-to-many mapping\n const assignedChainname = asymIdDict[ chainid ]\n if (assignedChainname !== undefined && assignedChainname !== chainname) {\n if (Debug) Log.warn(assignedChainname, chainname)\n }\n }\n // chainname mapping: label_asym_id -> auth_asym_id\n asymIdDict[ chainid ] = chainname\n\n // entity mapping: chainIndex -> label_entity_id\n const entityId = ls[ labelEntityId ]\n if (!chainIndexDict[ entityId ]) {\n chainIndexDict[ entityId ] = new Set()\n }\n chainIndexDict[ entityId ].add(s.chainStore.count - 1)\n\n idx += 1\n } else {\n const ls = line.match(reQuotedWhitespace)\n const nn = ls!.length\n\n if (currentLoopIndex === loopPointers.length) {\n currentLoopIndex = 0\n }/* else if( currentLoopIndex + nn > loopPointers.length ){\n Log.warn( \"cif parsing error, wrong number of loop data entries\", nn, loopPointers.length );\n } */\n\n for (let j = 0; j < nn; ++j) {\n loopPointers[ currentLoopIndex + j ].push(ls![ j ])\n }\n\n (currentLoopIndex) += nn\n }\n\n pendingName = false\n } else if (line[0] === \"'\" && line[line.length - 1] === \"'\") {\n // Log.log( \"NEWLINE STRING\", line );\n\n const str = line.substring(1, line.length - 1)\n\n if (currentName === false) {\n cif[ currentCategory as string ] = str\n } else {\n cif[ currentCategory as string ][ currentName as string ] = str\n }\n } else if (pendingValue) {\n // Log.log( \"NEWLINE VALUE\", line );\n\n if (currentName === false) {\n cif[ currentCategory as string ] = line\n } else {\n cif[ currentCategory as string ][ currentName as string ] = line\n }\n } else {\n if (Debug) Log.log('CifParser._parse: unknown state', line)\n }\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n if (cif.chem_comp && cif.chem_comp_atom) {\n parseChemComp(cif, s, sb)\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n assignResidueTypeBonds(s)\n } else if (cif.atom_site_type_symbol && cif.atom_site_label && cif.atom_site_fract_x) {\n parseCore(cif, s, sb)\n sb.finalize()\n s.finalizeAtoms()\n calculateBonds(s)\n s.finalizeBonds()\n // assignResidueTypeBonds( s );\n } else {\n var secStruct = processSecondaryStructure(cif, s, asymIdDict)\n processSymmetry(cif, s, asymIdDict)\n processConnections(cif, s, asymIdDict)\n processEntities(cif, s, chainIndexDict)\n\n if (cif.struct && cif.struct.title) {\n s.title = cif.struct.title.trim().replace(reTrimQuotes, '')\n }\n if (cif.entry && cif.entry.id) {\n s.id = cif.entry.id.trim().replace(reTrimQuotes, '')\n }\n\n // structure header (mimicking biojava)\n if (cif.pdbx_audit_revision_history) {\n if (cif.pdbx_audit_revision_history.revision_date) {\n ensureArray(cif.pdbx_audit_revision_history, 'revision_date')\n const dates = cif.pdbx_audit_revision_history.revision_date.filter(hasValue)\n if (dates.length) {\n s.header.releaseDate = dates[ 0 ]\n }\n }\n if (cif.pdbx_database_status.recvd_initial_deposition_date) {\n ensureArray(cif.pdbx_database_status, 'recvd_initial_deposition_date')\n const depDates = cif.pdbx_database_status.recvd_initial_deposition_date.filter(hasValue)\n if (depDates.length) {\n s.header.depositionDate = depDates[ 0 ]\n }\n }\n } else if (cif.database_PDB_rev) {\n if (cif.database_PDB_rev.date) {\n ensureArray(cif.database_PDB_rev, 'date')\n const dates = cif.database_PDB_rev.date.filter(hasValue)\n if (dates.length) {\n s.header.releaseDate = dates[ 0 ]\n }\n }\n if (cif.database_PDB_rev.date_original) {\n ensureArray(cif.database_PDB_rev, 'date_original')\n const depDates = cif.database_PDB_rev.date_original.filter(hasValue)\n if (depDates.length) {\n s.header.depositionDate = depDates[ 0 ]\n }\n }\n }\n if (cif.reflns && cif.reflns.d_resolution_high) {\n if (hasValue(cif.reflns.d_resolution_high)) {\n s.header.resolution = parseFloat(cif.reflns.d_resolution_high)\n }\n } else if (cif.refine && cif.refine.ls_d_res_high) {\n if (hasValue(cif.refine.ls_d_res_high)) {\n s.header.resolution = parseFloat(cif.refine.ls_d_res_high)\n }\n }\n if (cif.refine && cif.refine.ls_R_factor_R_free) {\n if (hasValue(cif.refine.ls_R_factor_R_free)) {\n s.header.rFree = parseFloat(cif.refine.ls_R_factor_R_free)\n }\n }\n if (cif.refine && cif.refine.ls_R_factor_R_work) {\n if (hasValue(cif.refine.ls_R_factor_R_work)) {\n s.header.rWork = parseFloat(cif.refine.ls_R_factor_R_work)\n }\n }\n if (cif.exptl && cif.exptl.method) {\n ensureArray(cif.exptl, 'method')\n s.header.experimentalMethods = cif.exptl.method.map(function (m: string) {\n return m.replace(reTrimQuotes, '')\n })\n }\n\n sb.finalize()\n s.finalizeAtoms()\n calculateBonds(s)\n s.finalizeBonds()\n\n if (!secStruct) {\n calculateSecondaryStructure(s)\n } else {\n assignSecondaryStructure(s, secStruct)\n }\n buildUnitcellAssembly(s)\n\n s.extraData.cif = cif\n }\n\n if (Debug) Log.timeEnd('CifParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('cif', CifParser)\nParserRegistry.add('mcif', CifParser)\nParserRegistry.add('mmcif', CifParser)\n\nexport default CifParser\n","/**\n * @file Gro Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport {\n calculateBonds, calculateChainnames, calculateSecondaryStructure\n} from '../structure/structure-utils'\n\nclass GroParser extends StructureParser {\n get type () { return 'gro' }\n\n _parse () {\n // http://manual.gromacs.org/current/online/gro.html\n\n if (Debug) Log.time('GroParser._parse ' + this.name)\n\n var s = this.structure\n var sb = this.structureBuilder\n\n var firstModelOnly = this.firstModelOnly\n var asTrajectory = this.asTrajectory\n var cAlphaOnly = this.cAlphaOnly\n\n var frames = s.frames\n var boxes = s.boxes\n var currentFrame: Float32Array, currentCoord: number\n\n var firstLines = this.streamer.peekLines(3)\n\n s.title = firstLines[ 0 ].trim()\n\n // determine number of decimal places\n var ndec = firstLines[ 2 ].length - firstLines[ 2 ].lastIndexOf('.') - 1\n var lpos = 5 + ndec\n var xpos = 20\n var ypos = 20 + lpos\n var zpos = 20 + 2 * lpos\n\n //\n\n var atomname, resname, resno, serial\n\n var atomCount = parseInt(firstLines[ 1 ])\n var modelLineCount = atomCount + 3\n\n var atomMap = s.atomMap\n var atomStore = s.atomStore\n atomStore.resize(atomCount)\n\n var idx = 0\n var modelIdx = 0\n var lineNo = 0\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (var i = _i; i < _n; ++i) {\n ++lineNo\n var l = lineNo - 1\n\n var line = lines[ i ]\n\n if (!line) continue\n\n if (l % modelLineCount === 0) {\n // Log.log( \"title\", line )\n\n if (asTrajectory) {\n currentFrame = new Float32Array(atomCount * 3)\n frames.push(currentFrame)\n currentCoord = 0\n }\n } else if (l % modelLineCount === 1) {\n\n // Log.log( \"atomCount\", line )\n\n } else if (l % modelLineCount === modelLineCount - 1) {\n var str = line.trim().split(/\\s+/)\n var box = new Float32Array(9)\n box[ 0 ] = parseFloat(str[ 0 ]) * 10\n box[ 4 ] = parseFloat(str[ 1 ]) * 10\n box[ 8 ] = parseFloat(str[ 2 ]) * 10\n boxes.push(box)\n\n if (firstModelOnly) {\n return true\n }\n\n modelIdx += 1\n } else {\n atomname = line.substr(10, 5).trim()\n if (cAlphaOnly && atomname !== 'CA') continue\n\n var x = parseFloat(line.substr(xpos, lpos)) * 10\n var y = parseFloat(line.substr(ypos, lpos)) * 10\n var z = parseFloat(line.substr(zpos, lpos)) * 10\n\n if (asTrajectory) {\n var j = currentCoord * 3\n\n currentFrame[ j + 0 ] = x\n currentFrame[ j + 1 ] = y\n currentFrame[ j + 2 ] = z\n\n currentCoord += 1\n\n if (l > modelLineCount) continue\n }\n\n resname = line.substr(5, 5).trim()\n resno = parseInt(line.substr(0, 5))\n serial = parseInt(line.substr(15, 5))\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = serial\n\n sb.addAtom(modelIdx, '', '', resname, resno, false, 'l')\n\n idx += 1\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n sb.finalize()\n s.finalizeAtoms()\n calculateChainnames(s)\n calculateBonds(s)\n s.finalizeBonds()\n\n calculateSecondaryStructure(s)\n\n if (Debug) Log.timeEnd('GroParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('gro', GroParser)\n\nexport default GroParser\n","/**\n * @file utf8-utils\n * @private\n * @author Alexander Rose \n * mostly copied from https://github.com/creationix/msgpack-js-browser\n * by Tim Caswell , MIT License, Copyright (c) 2013\n */\n\n\n// Encode string as utf8 into dataview at offset\nfunction utf8Write(view, offset, string) {\n var byteLength = view.byteLength;\n for(var i = 0, l = string.length; i < l; i++) {\n var codePoint = string.charCodeAt(i);\n\n // One byte of UTF-8\n if (codePoint < 0x80) {\n view.setUint8(offset++, codePoint >>> 0 & 0x7f | 0x00);\n continue;\n }\n\n // Two bytes of UTF-8\n if (codePoint < 0x800) {\n view.setUint8(offset++, codePoint >>> 6 & 0x1f | 0xc0);\n view.setUint8(offset++, codePoint >>> 0 & 0x3f | 0x80);\n continue;\n }\n\n // Three bytes of UTF-8.\n if (codePoint < 0x10000) {\n view.setUint8(offset++, codePoint >>> 12 & 0x0f | 0xe0);\n view.setUint8(offset++, codePoint >>> 6 & 0x3f | 0x80);\n view.setUint8(offset++, codePoint >>> 0 & 0x3f | 0x80);\n continue;\n }\n\n // Four bytes of UTF-8\n if (codePoint < 0x110000) {\n view.setUint8(offset++, codePoint >>> 18 & 0x07 | 0xf0);\n view.setUint8(offset++, codePoint >>> 12 & 0x3f | 0x80);\n view.setUint8(offset++, codePoint >>> 6 & 0x3f | 0x80);\n view.setUint8(offset++, codePoint >>> 0 & 0x3f | 0x80);\n continue;\n }\n throw new Error(\"bad codepoint \" + codePoint);\n }\n}\n\nfunction utf8ByteCount(string) {\n var count = 0;\n for(var i = 0, l = string.length; i < l; i++) {\n var codePoint = string.charCodeAt(i);\n if (codePoint < 0x80) {\n count += 1;\n continue;\n }\n if (codePoint < 0x800) {\n count += 2;\n continue;\n }\n if (codePoint < 0x10000) {\n count += 3;\n continue;\n }\n if (codePoint < 0x110000) {\n count += 4;\n continue;\n }\n throw new Error(\"bad codepoint \" + codePoint);\n }\n return count;\n}\n\n/**\n * encode data value (recursively) into binary encoded MessagePack v5 (http://msgpack.org/)\n * @param {Object|Array|String|Number|Boolean|null} value [description]\n * @param {DataView} view [description]\n * @param {Integer} offset [description]\n * @return {Integer} number of bytes written into view\n */\nfunction encode$1(value, view, offset) {\n var type = typeof value;\n\n // Strings Bytes\n if (type === \"string\") {\n var length = utf8ByteCount(value);\n // fix str\n if (length < 0x20) {\n view.setUint8(offset, length | 0xa0);\n utf8Write(view, offset + 1, value);\n return 1 + length;\n }\n // str 8\n if (length < 0x100) {\n view.setUint8(offset, 0xd9);\n view.setUint8(offset + 1, length);\n utf8Write(view, offset + 2, value);\n return 2 + length;\n }\n // str 16\n if (length < 0x10000) {\n view.setUint8(offset, 0xda);\n view.setUint16(offset + 1, length);\n utf8Write(view, offset + 3, value);\n return 3 + length;\n }\n // str 32\n if (length < 0x100000000) {\n view.setUint8(offset, 0xdb);\n view.setUint32(offset + 1, length);\n utf8Write(view, offset + 5, value);\n return 5 + length;\n }\n }\n\n if (value instanceof Uint8Array) {\n var length = value.byteLength;\n var bytes = new Uint8Array(view.buffer);\n // bin 8\n if (length < 0x100) {\n view.setUint8(offset, 0xc4);\n view.setUint8(offset + 1, length);\n bytes.set(value, offset + 2);\n return 2 + length;\n }\n // bin 16\n if (length < 0x10000) {\n view.setUint8(offset, 0xc5);\n view.setUint16(offset + 1, length);\n bytes.set(value, offset + 3);\n return 3 + length;\n }\n // bin 32\n if (length < 0x100000000) {\n view.setUint8(offset, 0xc6);\n view.setUint32(offset + 1, length);\n bytes.set(value, offset + 5);\n return 5 + length;\n }\n }\n\n if (type === \"number\") {\n if (!isFinite(value)) {\n throw new Error(\"Number not finite: \" + value);\n }\n\n // Floating point\n if (Math.floor(value) !== value) {\n view.setUint8(offset, 0xcb);\n view.setFloat64(offset + 1, value);\n return 9;\n }\n\n // Integers\n if (value >=0) {\n // positive fixnum\n if (value < 0x80) {\n view.setUint8(offset, value);\n return 1;\n }\n // uint 8\n if (value < 0x100) {\n view.setUint8(offset, 0xcc);\n view.setUint8(offset + 1, value);\n return 2;\n }\n // uint 16\n if (value < 0x10000) {\n view.setUint8(offset, 0xcd);\n view.setUint16(offset + 1, value);\n return 3;\n }\n // uint 32\n if (value < 0x100000000) {\n view.setUint8(offset, 0xce);\n view.setUint32(offset + 1, value);\n return 5;\n }\n throw new Error(\"Number too big 0x\" + value.toString(16));\n }\n // negative fixnum\n if (value >= -0x20) {\n view.setInt8(offset, value);\n return 1;\n }\n // int 8\n if (value >= -0x80) {\n view.setUint8(offset, 0xd0);\n view.setInt8(offset + 1, value);\n return 2;\n }\n // int 16\n if (value >= -0x8000) {\n view.setUint8(offset, 0xd1);\n view.setInt16(offset + 1, value);\n return 3;\n }\n // int 32\n if (value >= -0x80000000) {\n view.setUint8(offset, 0xd2);\n view.setInt32(offset + 1, value);\n return 5;\n }\n throw new Error(\"Number too small -0x\" + (-value).toString(16).substr(1));\n }\n\n // null\n if (value === null) {\n view.setUint8(offset, 0xc0);\n return 1;\n }\n\n // Boolean\n if (type === \"boolean\") {\n view.setUint8(offset, value ? 0xc3 : 0xc2);\n return 1;\n }\n\n // Container Types\n if (type === \"object\") {\n var length, size = 0;\n var isArray = Array.isArray(value);\n\n if (isArray) {\n length = value.length;\n }\n else {\n var keys = Object.keys(value);\n length = keys.length;\n }\n\n var size;\n if (length < 0x10) {\n view.setUint8(offset, length | (isArray ? 0x90 : 0x80));\n size = 1;\n }\n else if (length < 0x10000) {\n view.setUint8(offset, isArray ? 0xdc : 0xde);\n view.setUint16(offset + 1, length);\n size = 3;\n }\n else if (length < 0x100000000) {\n view.setUint8(offset, isArray ? 0xdd : 0xdf);\n view.setUint32(offset + 1, length);\n size = 5;\n }\n\n if (isArray) {\n for (var i = 0; i < length; i++) {\n size += encode$1(value[i], view, offset + size);\n }\n }\n else {\n for (var i = 0; i < length; i++) {\n var key = keys[i];\n size += encode$1(key, view, offset + size);\n size += encode$1(value[key], view, offset + size);\n }\n }\n\n return size;\n }\n throw new Error(\"Unknown type \" + type);\n}\n\nfunction encodedSize(value) {\n var type = typeof value;\n\n // Raw Bytes\n if (type === \"string\") {\n var length = utf8ByteCount(value);\n if (length < 0x20) {\n return 1 + length;\n }\n if (length < 0x100) {\n return 2 + length;\n }\n if (length < 0x10000) {\n return 3 + length;\n }\n if (length < 0x100000000) {\n return 5 + length;\n }\n }\n\n if (value instanceof Uint8Array) {\n var length = value.byteLength;\n if (length < 0x100) {\n return 2 + length;\n }\n if (length < 0x10000) {\n return 3 + length;\n }\n if (length < 0x100000000) {\n return 5 + length;\n }\n }\n\n if (type === \"number\") {\n // Floating Point\n // double\n if (Math.floor(value) !== value) return 9;\n\n // Integers\n if (value >=0) {\n // positive fixnum\n if (value < 0x80) return 1;\n // uint 8\n if (value < 0x100) return 2;\n // uint 16\n if (value < 0x10000) return 3;\n // uint 32\n if (value < 0x100000000) return 5;\n throw new Error(\"Number too big 0x\" + value.toString(16));\n }\n // negative fixnum\n if (value >= -0x20) return 1;\n // int 8\n if (value >= -0x80) return 2;\n // int 16\n if (value >= -0x8000) return 3;\n // int 32\n if (value >= -0x80000000) return 5;\n throw new Error(\"Number too small -0x\" + value.toString(16).substr(1));\n }\n\n // Boolean, null\n if (type === \"boolean\" || value === null) return 1;\n\n // Container Types\n if (type === \"object\") {\n var length, size = 0;\n if (Array.isArray(value)) {\n length = value.length;\n for (var i = 0; i < length; i++) {\n size += encodedSize(value[i]);\n }\n }\n else {\n var keys = Object.keys(value);\n length = keys.length;\n for (var i = 0; i < length; i++) {\n var key = keys[i];\n size += encodedSize(key) + encodedSize(value[key]);\n }\n }\n if (length < 0x10) {\n return 1 + size;\n }\n if (length < 0x10000) {\n return 3 + size;\n }\n if (length < 0x100000000) {\n return 5 + size;\n }\n throw new Error(\"Array or object too long 0x\" + length.toString(16));\n }\n throw new Error(\"Unknown type \" + type);\n}\n\nfunction encodeMsgpack(value) {\n var buffer = new ArrayBuffer(encodedSize(value));\n var view = new DataView(buffer);\n encode$1(value, view, 0);\n return new Uint8Array(buffer);\n}\n\n/**\n * @file mmtf-constants\n * @private\n * @author Alexander Rose \n */\n\n\nvar PassThroughFields = [\n \"mmtfVersion\", \"mmtfProducer\",\n \"unitCell\", \"spaceGroup\", \"structureId\", \"title\",\n \"depositionDate\", \"releaseDate\",\n \"experimentalMethods\", \"resolution\", \"rFree\", \"rWork\",\n \"bioAssemblyList\", \"ncsOperatorList\", \"entityList\", \"groupList\",\n \"numBonds\", \"numAtoms\", \"numGroups\", \"numChains\", \"numModels\",\n \"groupsPerChain\", \"chainsPerModel\",\n];\n\nvar EncodedFields = [\n\t// required\n \"xCoordList\", \"yCoordList\", \"zCoordList\",\n \"groupIdList\", \"groupTypeList\",\n \"chainIdList\",\n // optional\n \"bFactorList\", \"atomIdList\", \"altLocList\", \"occupancyList\",\n \"secStructList\", \"insCodeList\", \"sequenceIndexList\",\n \"chainNameList\",\n \"bondAtomList\", \"bondOrderList\"\n];\n\nvar AllFields = PassThroughFields.concat( EncodedFields );\n\n/**\n * @file mmtf-utils\n * @private\n * @author Alexander Rose \n */\n\n/**\n * mmtf utils module.\n * @module MmtfUtils\n */\n\n\nfunction getView( ctor, typedArray, elemSize ){\n return typedArray ? new ctor(\n typedArray.buffer,\n typedArray.byteOffset,\n typedArray.byteLength / ( elemSize || 1 )\n ) : undefined;\n}\n\nfunction getDataView( typedArray ){\n return getView( DataView, typedArray );\n}\n\n/**\n * get an Uint8Array view on the input array memory\n * @static\n * @param {TypedArray} dataArray - input array\n * @return {Uint8Array} new view on the input array memory\n */\nfunction getUint8View( typedArray ){\n return getView( Uint8Array, typedArray );\n}\n\n/**\n * get an Int8Array view on the input array memory\n * @static\n * @param {TypedArray} dataArray - input array\n * @return {Int8Array} new view on the input array memory\n */\nfunction getInt8View( typedArray ){\n return getView( Int8Array, typedArray );\n}\n\n/**\n * get an Int32Array view on the input array memory\n * @static\n * @param {TypedArray} dataArray - input array\n * @return {Int32Array} new view on the input array memory\n */\nfunction getInt32View( typedArray ){\n return getView( Int32Array, typedArray, 4 );\n}\n\nfunction getFloat32View( typedArray ){\n return getView( Float32Array, typedArray, 4 );\n}\n\n\n/**\n * get an Int16Array copy of the the input array data\n * @static\n * @param {TypedArray} view - input data in big endian format\n * @param {Int16Array} [dataArray] - pre-allocated output array\n * @return {Int16Array} copy of the input array data\n */\nfunction decodeInt16( bytes, output ){\n var n = bytes.length / 2;\n if( !output ) output = new Int16Array( n );\n for( var i = 0, i2 = 0; i < n; ++i, i2 += 2 ){\n output[ i ] = bytes[ i2 ] << 8 ^ bytes[ i2 + 1 ] << 0;\n }\n return output;\n}\n\n/**\n * make big endian buffer of an int16 array\n * @static\n * @param {Array|TypedArray} array - array of int16 values\n * @return {ArrayBuffer} big endian buffer\n */\nfunction encodeInt16( array, output ){\n var n = array.length;\n if( !output ) output = new Uint8Array( 2 * n );\n var dv = getDataView( output );\n for( var i = 0; i < n; ++i ){\n dv.setInt16( 2 * i, array[ i ] );\n }\n return getUint8View( output );\n}\n\n/**\n * get an Int32Array copy of the the input array data\n * @static\n * @param {TypedArray} view - input data in big endian format\n * @param {Int32Array} [dataArray] - pre-allocated output array\n * @return {Int32Array} copy of the input array data\n */\nfunction decodeInt32( bytes, output ){\n var n = bytes.length / 4;\n if( !output ) output = new Int32Array( n );\n for( var i = 0, i4 = 0; i < n; ++i, i4 += 4 ){\n output[ i ] = (\n bytes[ i4 ] << 24 ^ bytes[ i4 + 1 ] << 16 ^\n bytes[ i4 + 2 ] << 8 ^ bytes[ i4 + 3 ] << 0\n );\n }\n return output;\n}\n\n/**\n * make big endian buffer of an int32 array\n * @static\n * @param {Array|TypedArray} array - array of int32 values\n * @return {ArrayBuffer} big endian buffer\n */\nfunction encodeInt32( array, output ){\n var n = array.length;\n if( !output ) output = new Uint8Array( 4 * n );\n var dv = getDataView( output );\n for( var i = 0; i < n; ++i ){\n dv.setInt32( 4 * i, array[ i ] );\n }\n return getUint8View( output );\n}\n\nfunction decodeFloat32( bytes, output ){\n var n = bytes.length;\n if( !output ) output = new Float32Array( n / 4 );\n var dvOut = getDataView( output );\n var dvIn = getDataView( bytes );\n for( var i = 0, i4 = 0, il = n / 4; i < il; ++i, i4 += 4 ){\n dvOut.setFloat32( i4, dvIn.getFloat32( i4 ), true );\n }\n return output;\n}\n\n/**\n * decode integers into floats using given divisor\n * example:\n * intArray: [ 12, 34, 543, 687, 2, 0, 4689 ]\n * divisor: 100\n * return: [ 0.12, 0.34, 5.43, 6.87, 0.02, 0.00, 46.89 ]\n * @static\n * @param {TypedArray|Array} intArray - input array containing integers\n * @param {Number} divisor - number to devide the integers to obtain floats\n * @param {Float32Array} [dataArray] - pre-allocated output array\n * @return {Float32Array} decoded array\n */\nfunction decodeInteger( intArray, divisor, output ){\n var n = intArray.length;\n var invDiv = 1/divisor;\n if( !output ) output = new Float32Array( n );\n for( var i = 0; i < n; ++i ){\n // multiply by inverse of the divisor which is faster then division\n output[ i ] = intArray[ i ] * invDiv;\n }\n return output;\n}\n\nfunction encodeInteger( floatArray, factor, output ){\n var n = floatArray.length;\n if( !output ) output = new Int32Array( n );\n for( var i = 0; i < n; ++i ){\n output[ i ] = Math.round( floatArray[ i ] * factor );\n }\n return output;\n}\n\n\n\n/**\n * perform run-length decoding of input array\n * example:\n * array: [ 0, 2, 3, 5 ] // pairs of values and length of a run\n * return: [ 0, 0, 3, 3, 3, 3, 3 ]\n * @static\n * @param {TypedArray|Array} array - run-length encoded input array\n * @param {TypedArray|Array} [dataArray] - pre-allocated output array\n * @return {TypedArray|Array} decoded array\n */\nfunction decodeRun( array, output ){\n var i, il;\n if( !output ){\n // calculate the length the decoded array will have\n var fullLength = 0;\n for( i = 0, il = array.length; i < il; i+=2 ){\n fullLength += array[ i + 1 ];\n }\n // create a new array of the same type of the input array\n output = new array.constructor( fullLength );\n }\n var dataOffset = 0;\n for( i = 0, il = array.length; i < il; i+=2 ){\n var value = array[ i ]; // value to be repeated\n var length = array[ i + 1 ]; // number of repeats\n for( var j = 0; j < length; ++j ){\n output[ dataOffset ] = value;\n ++dataOffset;\n }\n }\n return output;\n}\n\nfunction encodeRun( array ){\n if( array.length === 0 ) return new Int32Array();\n var i, il;\n // calculate output size\n var fullLength = 2;\n for( i = 1, il = array.length; i < il; ++i ){\n if( array[ i - 1 ] !== array[ i ] ){\n fullLength += 2;\n }\n }\n var output = new Int32Array( fullLength );\n var offset = 0;\n var runLength = 1;\n for( i = 1, il = array.length; i < il; ++i ){\n if( array[ i - 1 ] !== array[ i ] ){\n output[ offset ] = array[ i - 1 ];\n output[ offset + 1 ] = runLength;\n runLength = 1;\n offset += 2;\n }else{\n ++runLength;\n }\n }\n output[ offset ] = array[ array.length - 1 ];\n output[ offset + 1 ] = runLength;\n return output;\n}\n\n\n\n/**\n * perform delta decoding of the input array\n * by iterativly adding the ith element's value to the i+1th\n * example:\n * dataArray: [ 0, 2, 1, 2, 1, 1, -4, -2, 9 ]\n * return: [ 0, 2, 3, 5, 6, 7, 3, 1, 10 ]\n * @static\n * @param {TypedArray|Array} dataArray - delta encoded input array\n * @return {TypedArray|Array} decoded array\n */\nfunction decodeDelta( array, output ){\n var n = array.length;\n if( !output ) output = new array.constructor( n );\n if( n ) output[ 0 ] = array[ 0 ];\n for( var i = 1; i < n; ++i ){\n output[ i ] = array[ i ] + output[ i - 1 ];\n }\n return output;\n}\n\nfunction encodeDelta( array, output ){\n var n = array.length;\n if( !output ) output = new array.constructor( n );\n output[ 0 ] = array[ 0 ];\n for( var i = 1; i < n; ++i ){\n output[ i ] = array[ i ] - array[ i - 1 ];\n }\n return output;\n}\n\n\n\n/**\n * [decodePacking description]\n * @param {Int16Array|Int8Array} int16or8 [description]\n * @param {Int32Array} output [description]\n * @return {Int32Array} [description]\n */\nfunction decodePacking( int16or8, output ){\n var upperLimit = int16or8 instanceof Int8Array ? 0x7F : 0x7FFF;\n var lowerLimit = -upperLimit - 1;\n var n = int16or8.length;\n var i, j;\n if( !output ){\n var fullLength = 0;\n for( i = 0; i < n; ++i ){\n if( int16or8[ i ] < upperLimit && int16or8[ i ] > lowerLimit ){\n ++fullLength;\n }\n }\n output = new Int32Array( fullLength );\n }\n i = 0;\n j = 0;\n while( i < n ){\n var value = 0;\n while( int16or8[ i ] === upperLimit || int16or8[ i ] === lowerLimit ){\n value += int16or8[ i ];\n ++i;\n }\n value += int16or8[ i ];\n ++i;\n output[ j ] = value;\n ++j;\n }\n return output;\n}\n\n/**\n * integer packing using recursive indexing\n * @param {Array|TyepedArray} intArray [description]\n * @param {Boolean} useInt8 [description]\n * @return {Int16Array|Int8Array} [description]\n */\nfunction encodePacking( intArray, useInt8 ){\n var upperLimit = useInt8 ? 0x7F : 0x7FFF;\n var lowerLimit = -upperLimit - 1;\n var i;\n var n = intArray.length;\n var size = 0;\n for( i = 0; i < n; ++i ){\n var value = intArray[ i ];\n if( value === 0 ){\n ++size;\n }else if( value === upperLimit || value === lowerLimit ){\n size += 2;\n }else if( value > 0) {\n size += Math.ceil( value / upperLimit );\n }else {\n size += Math.ceil( value / lowerLimit );\n }\n }\n var output = useInt8 ? new Int8Array( size ) : new Int16Array( size );\n var j = 0;\n for( i = 0; i < n; ++i ){\n var value = intArray[ i ];\n if( value >= 0) {\n while( value >= upperLimit ){\n output[ j ] = upperLimit;\n ++j;\n value -= upperLimit;\n }\n }else{\n while( value <= lowerLimit ){\n output[ j ] = lowerLimit;\n ++j;\n value -= lowerLimit;\n }\n }\n output[ j ] = value;\n ++j;\n }\n return output;\n}\n\n\n\nfunction decodeDeltaRun( array, output ){\n return decodeDelta( decodeRun( array ), output );\n}\n\nfunction encodeDeltaRun( array ){\n return encodeRun( encodeDelta( array ) );\n}\n\n\n\n/**\n * perform run-length decoding followed (@see decodeRunLength)\n * by decoding integers into floats using given divisor (@see decodeIntegerToFloat)\n * example:\n * array: [ 320, 3, 100, 2 ]\n * divisor: 100\n * return: [ 3.20, 3.20, 3.20, 1.00, 1.00 ]\n * @static\n * @param {Uint8Array} array - run-length encoded int32 array as bytes in big endian format\n * @param {Integer} divisor - number to devide the integers to obtain floats\n * @param {Float32Array} dataArray - pre-allocated output array\n * @return {Float32Array} decoded array\n */\nfunction decodeIntegerRun( intArray, divisor, output ){\n return decodeInteger(\n decodeRun( intArray, getInt32View( output ) ), divisor, output\n );\n}\n\nfunction encodeIntegerRun( floatArray, factor ){\n return encodeRun( encodeInteger( floatArray, factor ) );\n}\n\n\n\nfunction decodeIntegerDelta( intArray, divisor, output ){\n return decodeInteger(\n decodeDelta( intArray, getInt32View( output ) ), divisor, output\n );\n}\n\nfunction encodeIntegerDelta( floatArray, factor, output ){\n return encodeDelta( encodeInteger( floatArray, factor ), output );\n}\n\n\n\nfunction decodeIntegerPacking( int16or8, divisor, output ){\n return decodeInteger(\n decodePacking( int16or8, getInt32View( output ) ), divisor, output\n );\n}\n\nfunction decodeIntegerDeltaPacking( int16or8, divisor, output ){\n var unpacked = decodePacking( int16or8, getInt32View( output ) );\n return decodeIntegerDelta( unpacked, divisor, getFloat32View( unpacked ) );\n}\n\nfunction encodeIntegerDeltaPacking( floatArray, factor, useInt8 ){\n return encodePacking( encodeIntegerDelta( floatArray, factor ), useInt8 );\n}\n\n\n\nfunction decodeBytes( bytes ){\n var dv = getDataView( bytes );\n var type = dv.getInt32( 0 );\n var size = dv.getInt32( 4 );\n var param = bytes.subarray( 8, 12 );\n var bytes = bytes.subarray( 12 );\n return [ type, bytes, size, param ];\n}\n\nfunction encodeBytes( type, size, param, bytes ){\n var buffer = new ArrayBuffer( 12 + bytes.byteLength );\n var out = new Uint8Array( buffer );\n var dv = new DataView( buffer );\n dv.setInt32( 0, type );\n dv.setInt32( 4, size );\n if( param ) out.set( param, 8 );\n out.set( bytes, 12 );\n return out;\n}\n\nfunction passInt8( int8 ){\n var size = int8.length;\n var bytes = getUint8View( int8 );\n return encodeBytes( 2, size, undefined, bytes );\n}\n\nfunction passInt32( int32 ){\n var size = int32.length;\n var bytes = encodeInt32( int32 );\n return encodeBytes( 4, size, undefined, bytes );\n}\n\nfunction passString( stringBytes, length ){\n var size = stringBytes.length / length;\n var param = encodeInt32([ length ]);\n var bytes = getUint8View( stringBytes );\n return encodeBytes( 5, size, param, bytes );\n}\n\nfunction runChar( charBytes ){\n var size = charBytes.length;\n var bytes = encodeInt32( encodeRun( charBytes ) );\n return encodeBytes( 6, size, undefined, bytes );\n}\n\nfunction deltaRun( int32 ){\n var size = int32.length;\n var bytes = encodeInt32( encodeDeltaRun( int32 ) );\n return encodeBytes( 8, size, undefined, bytes );\n}\n\nfunction integerRun( float32, factor ){\n var size = float32.length;\n var param = encodeInt32([ factor ]);\n var bytes = encodeInt32( encodeIntegerRun( float32, factor ) );\n return encodeBytes( 9, size, param, bytes );\n}\n\nfunction integerDeltaPacking16( float32, factor ){\n var size = float32.length;\n var param = encodeInt32([ factor ]);\n var bytes = encodeInt16( encodeIntegerDeltaPacking( float32, factor ) );\n return encodeBytes( 10, size, param, bytes );\n}\n\nfunction encodeMmtf( inputDict ){\n\n var outputDict = {};\n\n // copy some fields over from the input dict\n PassThroughFields.forEach( function( name ){\n if( inputDict[ name ] !== undefined ){\n outputDict[ name ] = inputDict[ name ];\n }\n } );\n\n //////////////\n // bond data\n\n // encode inter group bond atom indices, i.e. get bytes in big endian order\n if( inputDict.bondAtomList ){\n outputDict.bondAtomList = passInt32( inputDict.bondAtomList );\n }\n\n // encode inter group bond orders, i.e. get bytes\n if( inputDict.bondOrderList ){\n outputDict.bondOrderList = passInt8( inputDict.bondOrderList );\n }\n\n //////////////\n // atom data\n\n // split-list delta & integer encode x, y, z atom coords\n outputDict.xCoordList = integerDeltaPacking16( inputDict.xCoordList, 1000 );\n outputDict.yCoordList = integerDeltaPacking16( inputDict.yCoordList, 1000 );\n outputDict.zCoordList = integerDeltaPacking16( inputDict.zCoordList, 1000 );\n\n // split-list delta & integer encode b-factors\n if( inputDict.bFactorList ){\n outputDict.bFactorList = integerDeltaPacking16( inputDict.bFactorList, 100 );\n }\n\n // delta & run-length encode atom ids\n if( inputDict.atomIdList ){\n outputDict.atomIdList = deltaRun( inputDict.atomIdList );\n }\n\n // run-length encode alternate labels\n if( inputDict.altLocList ){\n outputDict.altLocList = runChar( inputDict.altLocList );\n }\n\n // run-length & integer encode occupancies\n if( inputDict.occupancyList ){\n outputDict.occupancyList = integerRun( inputDict.occupancyList, 100 );\n }\n\n ///////////////\n // group data\n\n // run-length & delta encode group numbers\n outputDict.groupIdList = deltaRun( inputDict.groupIdList );\n\n // encode group types, i.e. get int32 array\n outputDict.groupTypeList = passInt32( inputDict.groupTypeList );\n\n // encode secondary structure, i.e. get bytes\n if( inputDict.secStructList ){\n outputDict.secStructList = passInt8( inputDict.secStructList, 1 );\n }\n\n // run-length encode insertion codes\n if( inputDict.insCodeList ){\n outputDict.insCodeList = runChar( inputDict.insCodeList );\n }\n\n // run-length & delta encode sequence indices\n if( inputDict.sequenceIndexList ){\n outputDict.sequenceIndexList = deltaRun( inputDict.sequenceIndexList );\n }\n\n ///////////////\n // chain data\n\n // encode chain ids, i.e. get bytes\n outputDict.chainIdList = passString( inputDict.chainIdList, 4 );\n\n // encode chain names, i.e. get bytes\n if( inputDict.chainNameList ){\n outputDict.chainNameList = passString( inputDict.chainNameList, 4 );\n }\n\n return outputDict;\n\n}\n\n/**\n * @file msgpack-decode\n * @private\n * @author Alexander Rose \n */\n\n/**\n * msgpack decode module.\n * @module MsgpackDecode\n */\n\n/**\n * decode binary encoded MessagePack v5 (http://msgpack.org/) data\n * @static\n * @param {Uint8Array} buffer - binary encoded MessagePack data\n * @return {Object|Array|String|Number|Boolean|null} decoded Messagepack data\n */\nfunction decodeMsgpack(buffer) {\n // Loosely based on\n // The MIT License (MIT)\n // Copyright (c) 2013 Tim Caswell \n // https://github.com/creationix/msgpack-js\n var offset = 0;\n var dataView = new DataView(buffer.buffer);\n\n /**\n * decode all key-value pairs of a map into an object\n * @param {Integer} length - number of key-value pairs\n * @return {Object} decoded map\n */\n function map(length) {\n var value = {};\n for (var i = 0; i < length; i++) {\n var key = parse();\n value[key] = parse();\n }\n return value;\n }\n\n /**\n * decode binary array\n * @param {Integer} length - number of elements in the array\n * @return {Uint8Array} decoded array\n */\n function bin(length) {\n var value = buffer.subarray(offset, offset + length);\n offset += length;\n return value;\n }\n\n /**\n * decode string\n * @param {Integer} length - number string characters\n * @return {String} decoded string\n */\n function str(length) {\n var array = buffer.subarray(offset, offset + length);\n offset += length;\n // limit number of arguments to String.fromCharCode to something\n // browsers can handle, see http://stackoverflow.com/a/22747272\n var chunkSize = 0xffff;\n if(length > chunkSize){\n var c = [];\n for(var i = 0; i < array.length; i += chunkSize) {\n c.push(String.fromCharCode.apply(\n null, array.subarray(i, i + chunkSize)\n ));\n }\n return c.join(\"\");\n }else{\n return String.fromCharCode.apply(null, array);\n }\n }\n\n /**\n * decode array\n * @param {Integer} length - number of array elements\n * @return {Array} decoded array\n */\n function array(length) {\n var value = new Array(length);\n for (var i = 0; i < length; i++) {\n value[i] = parse();\n }\n return value;\n }\n\n /**\n * recursively parse the MessagePack data\n * @return {Object|Array|String|Number|Boolean|null} decoded MessagePack data\n */\n function parse() {\n var type = buffer[offset];\n var value, length, extType;\n // Positive FixInt\n if ((type & 0x80) === 0x00) {\n offset++;\n return type;\n }\n // FixMap\n if ((type & 0xf0) === 0x80) {\n length = type & 0x0f;\n offset++;\n return map(length);\n }\n // FixArray\n if ((type & 0xf0) === 0x90) {\n length = type & 0x0f;\n offset++;\n return array(length);\n }\n // FixStr\n if ((type & 0xe0) === 0xa0) {\n length = type & 0x1f;\n offset++;\n return str(length);\n }\n // Negative FixInt\n if ((type & 0xe0) === 0xe0) {\n value = dataView.getInt8(offset);\n offset++;\n return value;\n }\n switch (type) {\n // nil\n case 0xc0:\n offset++;\n return null;\n // 0xc1: (never used, could be employed for padding)\n // false\n case 0xc2:\n offset++;\n return false;\n // true\n case 0xc3:\n offset++;\n return true;\n // bin 8\n case 0xc4:\n length = dataView.getUint8(offset + 1);\n offset += 2;\n return bin(length);\n // bin 16\n case 0xc5:\n length = dataView.getUint16(offset + 1);\n offset += 3;\n return bin(length);\n // bin 32\n case 0xc6:\n length = dataView.getUint32(offset + 1);\n offset += 5;\n return bin(length);\n // // ext 8\n // case 0xc7:\n // length = dataView.getUint8(offset + 1);\n // extType = dataView.getUint8(offset + 2);\n // offset += 3;\n // return [extType, bin(length)];\n // // ext 16\n // case 0xc8:\n // length = dataView.getUint16(offset + 1);\n // extType = dataView.getUint8(offset + 3);\n // offset += 4;\n // return [extType, bin(length)];\n // // ext 32\n // case 0xc9:\n // length = dataView.getUint32(offset + 1);\n // extType = dataView.getUint8(offset + 5);\n // offset += 6;\n // return [extType, bin(length)];\n // float 32\n case 0xca:\n value = dataView.getFloat32(offset + 1);\n offset += 5;\n return value;\n // float 64\n case 0xcb:\n value = dataView.getFloat64(offset + 1);\n offset += 9;\n return value;\n // uint8\n case 0xcc:\n value = buffer[offset + 1];\n offset += 2;\n return value;\n // uint 16\n case 0xcd:\n value = dataView.getUint16(offset + 1);\n offset += 3;\n return value;\n // uint 32\n case 0xce:\n value = dataView.getUint32(offset + 1);\n offset += 5;\n return value;\n // // uint64\n // case 0xcf:\n // // FIXME not available/representable in JS\n // // largest possible int in JS is 2^53\n // // value = dataView.getUint64(offset + 1);\n // offset += 9;\n // return 0;\n // int 8\n case 0xd0:\n value = dataView.getInt8(offset + 1);\n offset += 2;\n return value;\n // int 16\n case 0xd1:\n value = dataView.getInt16(offset + 1);\n offset += 3;\n return value;\n // int 32\n case 0xd2:\n value = dataView.getInt32(offset + 1);\n offset += 5;\n return value;\n // // int 64\n // case 0xd3:\n // // FIXME not available/representable in JS\n // // largest possible int in JS is 2^53\n // // value = dataView.getInt64(offset + 1);\n // offset += 9;\n // return 0;\n\n // // fixext 1\n // case 0xd4:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(1)];\n // // fixext 2\n // case 0xd5:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(2)];\n // // fixext 4\n // case 0xd6:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(4)];\n // // fixext 8\n // case 0xd7:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(8)];\n // // fixext 16\n // case 0xd8:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(16)];\n // str 8\n case 0xd9:\n length = dataView.getUint8(offset + 1);\n offset += 2;\n return str(length);\n // str 16\n case 0xda:\n length = dataView.getUint16(offset + 1);\n offset += 3;\n return str(length);\n // str 32\n case 0xdb:\n length = dataView.getUint32(offset + 1);\n offset += 5;\n return str(length);\n // array 16\n case 0xdc:\n length = dataView.getUint16(offset + 1);\n offset += 3;\n return array(length);\n // array 32\n case 0xdd:\n length = dataView.getUint32(offset + 1);\n offset += 5;\n return array(length);\n // map 16:\n case 0xde:\n length = dataView.getUint16(offset + 1);\n offset += 3;\n return map(length);\n // map 32\n case 0xdf:\n length = dataView.getUint32(offset + 1);\n offset += 5;\n return map(length);\n }\n\n throw new Error(\"Unknown type 0x\" + type.toString(16));\n }\n\n // start the recursive parsing\n return parse();\n}\n\n/**\n * Fields shared in encoded and decoded mmtf data objects.\n * @typedef {Object} module:MmtfDecode.SharedMmtfData\n * @property {String} mmtfVersion - MMTF specification version\n * @property {String} mmtfProducer - Program that created the file\n * @property {Float[]} [unitCell] - Crystallographic unit cell\n * @property {Float} unitCell.0 - x length\n * @property {Float} unitCell.1 - y length\n * @property {Float} unitCell.2 - z length\n * @property {Float} unitCell.3 - alpha angle\n * @property {Float} unitCell.4 - beta angle\n * @property {Float} unitCell.5 - gamma angle\n * @property {String} [spaceGroup] - Hermann-Mauguin symbol\n * @property {String} [structureId] - Some reference, e.g. a PDB ID\n * @property {String} [title] - Short description\n * @property {String} [depositionDate] - Deposition date in YYYY-MM-DD format\n * @property {String} [releaseDate] - Release date in YYYY-MM-DD format\n * @property {String[]} [experimentalMethods] - Structure determination methods\n * @property {Float} [resolution] - Resolution in Å\n * @property {Float} [rFree] - R-free value\n * @property {Float} [rWork] - R-work value\n * @property {Integer} numBonds - Number of bonds\n * @property {Integer} numAtoms - Number of atoms\n * @property {Integer} numGroups - Number of groups (residues)\n * @property {Integer} numChains - Number of chains\n * @property {Integer} numModels - Number of models\n * @property {Integer[]} chainsPerModel - List of number of chains in each model\n * @property {Integer[]} groupsPerChain - List of number of groups in each chain\n * @property {Entity[]} [entityList] - List of entity objects\n * @property {Integer[]} entityList.chainIndexList - Pointers into chain data fields\n * @property {String} entityList.description - Description of the entity\n * @property {String} entityList.type - Name of the entity type\n * @property {String} entityList.sequence - One letter code sequence\n * @property {Assembly[]} [bioAssemblyList] - List of assembly objects\n * @property {Transform[]} bioAssemblyList.transformList - List of transform objects\n * @property {Integer[]} bioAssemblyList.transformList.chainIndexList - Pointers into chain data fields\n * @property {Float[]} bioAssemblyList.transformList.matrix - 4x4 transformation matrix\n * @property {Array[]} [ncsOperatorList] - List of ncs operator matrices\n * @property {Float[]} ncsOperatorList. - 4x4 transformation matrix\n * @property {GroupType[]} groupList - List of groupType objects\n * @property {Integer[]} groupList.formalChargeList - List of atom formal charges\n * @property {String[]} groupList.elementList - List of elements\n * @property {String[]} groupList.atomNameList - List of atom names\n * @property {Integer[]} groupList.bondAtomList - List of bonded atom indices\n * @property {Integer[]} groupList.bondOrderList - List of bond orders\n * @property {String} groupList.groupName - The name of the group\n * @property {String} groupList.singleLetterCode - The single letter code\n * @property {String} groupList.chemCompType - The chemical component type\n */\n\n/**\n * Encoded mmtf data object. Also includes the fields from {@link module:MmtfDecode.SharedMmtfData}. See MMTF specification on how they are encoded.\n * @typedef {Object} module:MmtfDecode.EncodedMmtfData\n * @mixes module:MmtfDecode.SharedMmtfData\n * @property {Uint8Array} [bondAtomList] - Encoded bonded atom indices\n * @property {Uint8Array} [bondOrderList] - Encoded bond orders\n * @property {Uint8Array} xCoordBig - Encoded x coordinates in Å, part 1\n * @property {Uint8Array} xCoordSmall - Encoded x coordinates in Å, part 2\n * @property {Uint8Array} yCoordBig - Encoded y coordinates in Å, part 1\n * @property {Uint8Array} yCoordSmall - Encoded y coordinates in Å, part 2\n * @property {Uint8Array} yCoordBig - Encoded y coordinates in Å, part 1\n * @property {Uint8Array} yCoordSmall - Encoded y coordinates in Å, part 2\n * @property {Uint8Array} [bFactorBig] - Encoded B-factors in Å^2, part 1\n * @property {Uint8Array} [bFactorSmall] - Encoded B-factors in Å^2, part 2\n * @property {Uint8Array} [atomIdList] - Encoded atom ids\n * @property {Uint8Array} [altLocList] - Encoded alternate location labels\n * @property {Uint8Array} [occupancyList] - Encoded occupancies\n * @property {Uint8Array} groupIdList - Encoded group ids\n * @property {Uint8Array} groupTypeList - Encoded group types\n * @property {Uint8Array} [secStructList] - Encoded secondary structure codes\n * @property {Uint8Array} [insCodeList] - Encoded insertion codes\n * @property {Uint8Array} [seuenceIdList] - Encoded sequence ids\n * @property {Uint8Array} chainIdList - Encoded chain ids\n * @property {Uint8Array} [chainNameList] - Encoded chain names\n */\n\n/**\n * Decoded mmtf data object. Also includes fields the from {@link module:MmtfDecode.SharedMmtfData}.\n * @typedef {Object} module:MmtfDecode.MmtfData\n * @mixes module:MmtfDecode.SharedMmtfData\n * @property {Int32Array} [bondAtomList] - List of bonded atom indices\n * @property {Uint8Array} [bondOrderList] - List of bond orders\n * @property {Float32Array} xCoordList - List of x coordinates in Å\n * @property {Float32Array} yCoordList - List of y coordinates in Å\n * @property {Float32Array} zCoordList - List of z coordinates in Å\n * @property {Float32Array} [bFactorList] - List of B-factors in Å^2\n * @property {Int32Array} [atomIdList] - List of atom ids\n * @property {Uint8Array} [altLocList] - List of alternate location labels\n * @property {Float32Array} [occupancyList] - List of occupancies\n * @property {Int32Array} groupIdList - List of group ids\n * @property {Int32Array} groupTypeList - List of group types\n * @property {Int8Array} [secStructList] - List of secondary structure codes, encoding\n * 0: pi helix, 1: bend, 2: alpha helix, 3: extended,\n * 4: 3-10 helix, 5: bridge, 6: turn, 7: coil, -1: undefined\n * @property {Uint8Array} [insCodeList] - List of insertion codes\n * @property {Int32Array} [seuenceIdList] - List of sequence ids\n * @property {Uint8Array} chainIdList - List of chain ids\n * @property {Uint8Array} [chainNameList] - List of chain names\n */\n\n\n/**\n * [performDecoding description]\n * @param {Integer} bytes [description]\n * @param {Integer} size [description]\n * @param {Uint8Array} param [description]\n * @return {TypedArray} [description]\n */\nfunction performDecoding( type, bytes, size, param ){\n\n switch( type ){\n case 1:\n return decodeFloat32( bytes );\n case 2:\n return getInt8View( bytes );\n case 3:\n return decodeInt16( bytes );\n case 4:\n return decodeInt32( bytes );\n case 5:\n // var length = decodeInt32( param )[ 0 ];\n return getUint8View( bytes ); // interpret as string array\n case 6:\n // interpret as char array\n return decodeRun( decodeInt32( bytes ), new Uint8Array( size ) );\n case 7:\n return decodeRun( decodeInt32( bytes ) )\n case 8:\n return decodeDeltaRun( decodeInt32( bytes ) );\n case 9:\n return decodeIntegerRun( decodeInt32( bytes ), decodeInt32( param )[ 0 ] );\n case 10:\n return decodeIntegerDeltaPacking( decodeInt16( bytes ), decodeInt32( param )[ 0 ] );\n case 11:\n return decodeInteger( decodeInt16( bytes ), decodeInt32( param )[ 0 ] );\n case 12:\n return decodeIntegerPacking( decodeInt16( bytes ), decodeInt32( param )[ 0 ] );\n case 13:\n return decodeIntegerPacking( getInt8View( bytes ), decodeInt32( param )[ 0 ] );\n case 14:\n return decodePacking( decodeInt16( bytes ) );\n case 15:\n return decodePacking( getInt8View( bytes ) );\n }\n\n};\n\n\n/**\n * Decode MMTF fields\n * @static\n * @param {Object} inputDict - encoded MMTF data\n * @param {Object} [params] - decoding parameters\n * @param {String[]} params.ignoreFields - names of optional fields not to decode\n * @return {module:MmtfDecode.MmtfData} mmtfData\n */\nfunction decodeMmtf( inputDict, params ){\n\n params = params || {};\n var ignoreFields = params.ignoreFields;\n var outputDict = {};\n\n AllFields.forEach( function( name ){\n var ignore = ignoreFields ? ignoreFields.indexOf( name ) !== -1 : false;\n var data = inputDict[ name ];\n if( !ignore && data !== undefined ){\n if( data instanceof Uint8Array ){\n outputDict[ name ] = performDecoding.apply( null, decodeBytes( data ) );\n }else{\n outputDict[ name ] = data;\n }\n }\n } );\n\n return outputDict;\n\n}\n\n/**\n * @file mmtf-traverse\n * @private\n * @author Alexander Rose \n */\n\n/**\n * mmtf traverse module.\n * @module MmtfTraverse\n */\n\n/**\n * Converts an array of ASCII codes trimming '\\0' bytes\n * @private\n * @param {Array} charCodeArray - array of ASCII char codes\n * @return {String} '\\0' trimmed string\n */\nfunction fromCharCode( charCodeArray ){\n return String.fromCharCode.apply( null, charCodeArray ).replace(/\\0/g, '');\n}\n\n\n/**\n * @callback module:MmtfTraverse.onModel\n * @param {Object} modelData\n * @param {Integer} modelData.chainCount - number of chains in the model\n * @param {Integer} modelData.modelIndex - index of the model\n */\n\n/**\n * @callback module:MmtfTraverse.onChain\n * @param {Object} chainData\n * @param {Integer} chainData.groupCount - number of groups in the chain\n * @param {Integer} chainData.chainIndex - index of the chain\n * @param {Integer} chainData.modelIndex - index of the parent model\n * @param {String} chainData.chainId - chain id\n * @param {?String} chainData.chainName - additional chain name\n */\n\n/**\n * @callback module:MmtfTraverse.onGroup\n * @param {Object} groupData\n * @param {Integer} groupData.atomCount - number of atoms in the group\n * @param {Integer} groupData.groupIndex - index of the group\n * @param {Integer} groupData.chainIndex - index of the parent chain\n * @param {Integer} groupData.modelIndex - index of the parent model\n * @param {Integer} groupData.groupId - group id (residue number)\n * @param {Integer} groupData.groupType - index to an entry in {@link module:MmtfDecode.MmtfData}#groupList\n * @param {String} groupData.groupName - name of the group, 0 to 5 characters\n * @param {Char} groupData.singleLetterCode - IUPAC single letter code, otherwise 'X', 1 character\n * @param {String} groupData.chemCompType - chemical component type from the mmCIF dictionary\n * @param {?Integer} groupData.secStruct - sencoded secondary structure |\n * 0: pi helix, 1: bend, 2: alpha helix, 3: extended,\n * 4: 3-10 helix, 5: bridge, 6: turn, 7: coil, -1: undefined\n * @param {?Char} groupData.insCode - insertion code\n * @param {?Integer} groupData.sequenceIndex - index to the `sequence` property of\n * the corresponding entity, -1 when the entity has no sequence\n */\n\n/**\n * @callback module:MmtfTraverse.onAtom\n * @param {Object} atomData\n * @param {Integer} atomData.atomIndex - index of the atom\n * @param {Integer} atomData.groupIndex - index of the parent group\n * @param {Integer} atomData.chainIndex - index of the parent chain\n * @param {Integer} atomData.modelIndex - index of the parent model\n * @param {?Integer} atomData.atomId - atom id\n * @param {String} atomData.element - IUPAC element name, 0 to 3 characters\n * @param {String} atomData.atomName - name of the atom, 0 to 5 characters\n * @param {Integer} atomData.formalCharge - formal charge of the atom\n * @param {Float} atomData.xCoord - x coordinate in Å\n * @param {Float} atomData.yCoord - y coordinate in Å\n * @param {Float} atomData.zCoord - z coordinate in Å\n * @param {?Float} atomData.bFactor - B-factor in in Å^2\n * @param {?Char} atomData.altLoc - alternate location identifier\n * @param {?Float} atomData.occupancy - occupancy of the atom\n */\n\n/**\n * @callback module:MmtfTraverse.onBond\n * @param {Object} bondData\n * @param {Integer} bondData.atomIndex1 - index of the first atom\n * @param {Integer} bondData.atomIndex2 - index of the secound atom\n * @param {Integer} bondData.bondOrder - bond order, allowed values are 1 to 3\n */\n\n\n/**\n * Traverse the MMTF structure data.\n * @static\n * @param {module:MmtfDecode.MmtfData} mmtfData - decoded mmtf data\n * @param {Object} eventCallbacks\n * @param {module:MmtfTraverse.onModel} [eventCallbacks.onModel] - called for each model\n * @param {module:MmtfTraverse.onChain} [eventCallbacks.onChain] - called for each chain\n * @param {module:MmtfTraverse.onGroup} [eventCallbacks.onGroup] - called for each group\n * @param {module:MmtfTraverse.onAtom} [eventCallbacks.onAtom] - called for each atom\n * @param {module:MmtfTraverse.onBond} [eventCallbacks.onBond] - called for each bond\n * @param {Object} [params] - traversal parameters\n * @param {Boolean} [params.firstModelOnly] - traverse only the first model\n */\nfunction traverseMmtf( mmtfData, eventCallbacks, params ){\n\n params = params || {};\n\n var firstModelOnly = params.firstModelOnly;\n\n // setup callbacks\n var onModel = eventCallbacks.onModel;\n var onChain = eventCallbacks.onChain;\n var onGroup = eventCallbacks.onGroup;\n var onAtom = eventCallbacks.onAtom;\n var onBond = eventCallbacks.onBond;\n\n // setup index counters\n var modelIndex = 0;\n var chainIndex = 0;\n var groupIndex = 0;\n var atomIndex = 0;\n\n var modelFirstAtomIndex = 0;\n var modelLastAtomIndex = -1;\n\n // setup optional fields\n var chainNameList = mmtfData.chainNameList;\n var secStructList = mmtfData.secStructList;\n var insCodeList = mmtfData.insCodeList;\n var sequenceIndexList = mmtfData.sequenceIndexList;\n var atomIdList = mmtfData.atomIdList;\n var bFactorList = mmtfData.bFactorList;\n var altLocList = mmtfData.altLocList;\n var occupancyList = mmtfData.occupancyList;\n var bondAtomList = mmtfData.bondAtomList;\n var bondOrderList = mmtfData.bondOrderList;\n\n // hoisted loop variables\n var o, ol, i, j, k, kl;\n\n // loop over all models\n for( o = 0, ol = mmtfData.chainsPerModel.length; o < ol; ++o ){\n\n if( firstModelOnly && modelIndex > 0 ) break;\n\n var modelChainCount = mmtfData.chainsPerModel[ modelIndex ];\n\n if( onModel ){\n onModel({\n chainCount: modelChainCount,\n modelIndex: modelIndex\n });\n }\n\n for( i = 0; i < modelChainCount; ++i ){\n\n var chainGroupCount = mmtfData.groupsPerChain[ chainIndex ];\n if( onChain ){\n var chainId = fromCharCode(\n mmtfData.chainIdList.subarray( chainIndex * 4, chainIndex * 4 + 4 )\n );\n var chainName = null;\n if( chainNameList ){\n chainName = fromCharCode(\n chainNameList.subarray( chainIndex * 4, chainIndex * 4 + 4 )\n );\n }\n onChain({\n groupCount: chainGroupCount,\n chainIndex: chainIndex,\n modelIndex: modelIndex,\n chainId: chainId,\n chainName: chainName\n });\n }\n\n for( j = 0; j < chainGroupCount; ++j ){\n\n var groupData = mmtfData.groupList[ mmtfData.groupTypeList[ groupIndex ] ];\n var groupAtomCount = groupData.atomNameList.length;\n if( onGroup ){\n var secStruct = null;\n if( secStructList ){\n secStruct = secStructList[ groupIndex ];\n }\n var insCode = null;\n if( mmtfData.insCodeList ){\n insCode = String.fromCharCode( insCodeList[ groupIndex ] );\n }\n var sequenceIndex = null;\n if( sequenceIndexList ){\n sequenceIndex = sequenceIndexList[ groupIndex ];\n }\n onGroup({\n atomCount: groupAtomCount,\n groupIndex: groupIndex,\n chainIndex: chainIndex,\n modelIndex: modelIndex,\n groupId: mmtfData.groupIdList[ groupIndex ],\n groupType: mmtfData.groupTypeList[ groupIndex ],\n groupName: groupData.groupName,\n singleLetterCode: groupData.singleLetterCode,\n chemCompType: groupData.chemCompType,\n secStruct: secStruct,\n insCode: insCode,\n sequenceIndex: sequenceIndex\n });\n }\n\n for( k = 0; k < groupAtomCount; ++k ){\n\n if( onAtom ){\n var atomId = null;\n if( atomIdList ){\n atomId = atomIdList[ atomIndex ];\n }\n var bFactor = null;\n if( bFactorList ){\n bFactor = bFactorList[ atomIndex ];\n }\n var altLoc = null;\n if( altLocList ){\n altLoc = String.fromCharCode( altLocList[ atomIndex ] );\n }\n var occupancy = null;\n if( occupancyList ){\n occupancy = occupancyList[ atomIndex ];\n }\n onAtom({\n atomIndex: atomIndex,\n groupIndex: groupIndex,\n chainIndex: chainIndex,\n modelIndex: modelIndex,\n atomId: atomId,\n element: groupData.elementList[ k ],\n atomName: groupData.atomNameList[ k ],\n formalCharge: groupData.formalChargeList[ k ],\n xCoord: mmtfData.xCoordList[ atomIndex ],\n yCoord: mmtfData.yCoordList[ atomIndex ],\n zCoord: mmtfData.zCoordList[ atomIndex ],\n bFactor: bFactor,\n altLoc: altLoc,\n occupancy: occupancy\n });\n }\n\n atomIndex += 1;\n }\n\n if( onBond ){\n // intra group bonds\n var groupBondAtomList = groupData.bondAtomList;\n for( k = 0, kl = groupData.bondOrderList.length; k < kl; ++k ){\n onBond({\n atomIndex1: atomIndex - groupAtomCount + groupBondAtomList[ k * 2 ],\n atomIndex2: atomIndex - groupAtomCount + groupBondAtomList[ k * 2 + 1 ],\n bondOrder: groupData.bondOrderList[ k ]\n });\n }\n }\n\n groupIndex += 1;\n }\n\n chainIndex += 1;\n }\n\n modelFirstAtomIndex = modelLastAtomIndex + 1;\n modelLastAtomIndex = atomIndex - 1; // subtract one as it already has been incremented\n\n if( onBond ){\n // inter group bonds\n if( bondAtomList ){\n for( k = 0, kl = bondAtomList.length; k < kl; k += 2 ){\n var atomIndex1 = bondAtomList[ k ];\n var atomIndex2 = bondAtomList[ k + 1 ];\n if( ( atomIndex1 >= modelFirstAtomIndex && atomIndex1 <= modelLastAtomIndex ) ||\n ( atomIndex2 >= modelFirstAtomIndex && atomIndex2 <= modelLastAtomIndex )\n ){\n onBond({\n atomIndex1: atomIndex1,\n atomIndex2: atomIndex2,\n bondOrder: bondOrderList ? bondOrderList[ k / 2 ] : null\n });\n }\n }\n }\n }\n\n modelIndex += 1;\n }\n\n}\n\n/**\n * Version name\n * @static\n * @type {String}\n */\nvar version = \"v1.1.0dev\";\n\n/**\n * Version name\n * @private\n * @type {String}\n */\nvar baseUrl = \"//mmtf.rcsb.org/v1.0/\";\n\n/**\n * URL of the RCSB webservice to obtain MMTF files\n * @static\n * @type {String}\n */\nvar fetchUrl = baseUrl + \"full/\";\n\n/**\n * URL of the RCSB webservice to obtain reduced MMTF files\n * @static\n * @type {String}\n */\nvar fetchReducedUrl = baseUrl + \"reduced/\";\n\n/**\n * Encode MMTF fields\n * @static\n * @param {module:MmtfDecode.MmtfData} mmtfData - mmtf data\n * @return {Uint8Array} encoded MMTF fields\n */\nfunction encode( mmtfData ){\n return encodeMsgpack( encodeMmtf( mmtfData ) );\n}\n\n/**\n * Decode MMTF fields\n * @static\n * @example\n * // bin is Uint8Array containing the mmtf msgpack\n * var mmtfData = MMTF.decode( bin );\n * console.log( mmtfData.numAtoms );\n *\n * @param {Uint8Array|ArrayBuffer|module:MmtfDecode.EncodedMmtfData} binOrDict - binary MessagePack or encoded MMTF data\n * @param {Object} [params] - decoding parameters\n * @param {String[]} params.ignoreFields - names of optional fields not to decode\n * @return {module:MmtfDecode.MmtfData} mmtfData\n */\nfunction decode( binOrDict, params ){\n\t// make sure binOrDict is not a plain Arraybuffer\n if( binOrDict instanceof ArrayBuffer ){\n binOrDict = new Uint8Array( binOrDict );\n }\n\n var inputDict;\n if( binOrDict instanceof Uint8Array ){\n // get dict from msgpack\n inputDict = decodeMsgpack( binOrDict );\n }else{\n // already a dict\n inputDict = binOrDict;\n }\n\n return decodeMmtf( inputDict, params );\n}\n\n/**\n * @callback module:MMTF.onLoad\n * @param {module:MmtfDecode.MmtfData} mmtfData - decoded mmtf data object\n */\n\n/**\n * helper method to fetch binary files from an URL\n * @private\n * @param {String} pdbid - PDB ID to fetch\n * @param {String} baseUrl - URL to fetch from\n * @param {module:MMTF.onLoad} onLoad - callback( mmtfData )\n * @param {Function} onError - callback( error )\n * @return {undefined}\n */\nfunction _fetch( pdbid, baseUrl, onLoad, onError ){\n var xhr = new XMLHttpRequest();\n function _onLoad(){\n try{\n var mmtfData = decode( xhr.response );\n onLoad( mmtfData );\n }catch( error ){\n onError( error );\n }\n }\n xhr.addEventListener( \"load\", _onLoad, true );\n xhr.addEventListener( \"error\", onError, true );\n xhr.responseType = \"arraybuffer\";\n xhr.open( \"GET\", baseUrl + pdbid.toUpperCase() );\n xhr.send();\n}\n\n/**\n * Fetch MMTF file from RCSB webservice which contains\n * @static\n * @example\n * MMTF.fetch(\n * \"3PQR\",\n * // onLoad callback\n * function( mmtfData ){ console.log( mmtfData ) },\n * // onError callback\n * function( error ){ console.error( error ) }\n * );\n *\n * @param {String} pdbid - PDB ID to fetch\n * @param {module:MMTF.onLoad} onLoad - callback( mmtfData )\n * @param {Function} onError - callback( error )\n * @return {undefined}\n */\nfunction fetch( pdbid, onLoad, onError ){\n _fetch( pdbid, fetchUrl, onLoad, onError );\n}\n\n/**\n * Fetch reduced MMTF file from RCSB webservice which contains\n * protein C-alpha, nucleotide phosphate and ligand atoms\n * @static\n * @example\n * MMTF.fetchReduced(\n * \"3PQR\",\n * // onLoad callback\n * function( mmtfData ){ console.log( mmtfData ) },\n * // onError callback\n * function( error ){ console.error( error ) }\n * );\n *\n * @param {String} pdbid - PDB ID to fetch\n * @param {module:MMTF.onLoad} onLoad - callback( mmtfData )\n * @param {Function} onError - callback( error )\n * @return {undefined}\n */\nfunction fetchReduced( pdbid, onLoad, onError ){\n _fetch( pdbid, fetchReducedUrl, onLoad, onError );\n}\n\nexport { encode, decode, traverseMmtf as traverse, fetch, fetchReduced, version, fetchUrl, fetchReducedUrl, encodeMsgpack, encodeMmtf, decodeMsgpack, decodeMmtf };","/**\n * @file Mmtf Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport {\n buildUnitcellAssembly, calculateBondsBetween, calculateBondsWithin\n} from '../structure/structure-utils'\nimport { ChemCompHetero } from '../structure/structure-constants'\nimport Entity from '../structure/entity'\nimport Unitcell from '../symmetry/unitcell'\nimport Assembly, { AssemblyPart } from '../symmetry/assembly'\n\nimport { decodeMsgpack, decodeMmtf } from '../../lib/mmtf.es6'\n\nconst SstrucMap: {[k: string]: number} = {\n '0': 'i'.charCodeAt(0), // pi helix\n '1': 's'.charCodeAt(0), // bend\n '2': 'h'.charCodeAt(0), // alpha helix\n '3': 'e'.charCodeAt(0), // extended\n '4': 'g'.charCodeAt(0), // 3-10 helix\n '5': 'b'.charCodeAt(0), // bridge\n '6': 't'.charCodeAt(0), // turn\n '7': 'l'.charCodeAt(0), // coil\n '-1': ''.charCodeAt(0) // NA\n}\n\nclass MmtfParser extends StructureParser {\n get type () { return 'mmtf' }\n get isBinary () { return true }\n\n _parse () {\n // https://github.com/rcsb/mmtf\n\n if (Debug) Log.time('MmtfParser._parse ' + this.name)\n\n let i, il, j, jl, groupData\n\n const s = this.structure\n const sd: {[k: string]: any} = decodeMmtf(decodeMsgpack(this.streamer.data))\n\n // structure header\n const headerFields = [\n 'depositionDate', 'releaseDate', 'resolution',\n 'rFree', 'rWork', 'experimentalMethods'\n ]\n headerFields.forEach(function (name) {\n if (sd[ name ] !== undefined) {\n s.header[ name ] = sd[ name ]\n }\n })\n\n let numBonds, numAtoms, numGroups, numChains, numModels\n let chainsPerModel\n\n s.id = sd.structureId\n s.title = sd.title\n\n s.atomStore.addField('formalCharge', 1, 'int8')\n\n if (this.firstModelOnly || this.asTrajectory) {\n numModels = 1\n numChains = sd.chainsPerModel[ 0 ]\n\n numGroups = 0\n for (i = 0, il = numChains; i < il; ++i) {\n numGroups += sd.groupsPerChain[ i ]\n }\n\n numAtoms = 0\n for (i = 0, il = numGroups; i < il; ++i) {\n groupData = sd.groupList[ sd.groupTypeList[ i ] ]\n numAtoms += groupData.atomNameList.length\n }\n\n numBonds = sd.numBonds\n\n chainsPerModel = [ numChains ]\n } else {\n numBonds = sd.numBonds\n numAtoms = sd.numAtoms\n numGroups = sd.numGroups\n numChains = sd.numChains\n numModels = sd.numModels\n\n chainsPerModel = sd.chainsPerModel\n }\n\n numBonds += numGroups // add numGroups to have space for polymer bonds\n\n //\n\n if (this.asTrajectory) {\n for (i = 0, il = sd.numModels; i < il; ++i) {\n const frame = new Float32Array(numAtoms * 3)\n const frameAtomOffset = numAtoms * i\n\n for (j = 0; j < numAtoms; ++j) {\n const j3 = j * 3\n const offset = j + frameAtomOffset\n frame[ j3 ] = sd.xCoordList[ offset ]\n frame[ j3 + 1 ] = sd.yCoordList[ offset ]\n frame[ j3 + 2 ] = sd.zCoordList[ offset ]\n }\n\n s.frames.push(frame)\n }\n }\n\n // bondStore\n const bAtomIndex1 = new Uint32Array(numBonds)\n const bAtomIndex2 = new Uint32Array(numBonds)\n const bBondOrder = new Uint8Array(numBonds)\n\n const aGroupIndex = new Uint32Array(numAtoms)\n const aFormalCharge = new Int8Array(numAtoms)\n\n const gChainIndex = new Uint32Array(numGroups)\n const gAtomOffset = new Uint32Array(numGroups)\n const gAtomCount = new Uint16Array(numGroups)\n\n const cModelIndex = new Uint16Array(numChains)\n const cGroupOffset = new Uint32Array(numChains)\n const cGroupCount = new Uint32Array(numChains)\n\n const mChainOffset = new Uint32Array(numModels)\n const mChainCount = new Uint32Array(numModels)\n\n // set-up model-chain relations\n let chainOffset = 0\n for (i = 0, il = numModels; i < il; ++i) {\n const modelChainCount = chainsPerModel[ i ]\n mChainOffset[ i ] = chainOffset\n mChainCount[ i ] = modelChainCount\n for (j = 0; j < modelChainCount; ++j) {\n cModelIndex[ j + chainOffset ] = i\n }\n chainOffset += modelChainCount\n }\n\n // set-up chain-residue relations\n const groupsPerChain = sd.groupsPerChain\n let groupOffset = 0\n for (i = 0, il = numChains; i < il; ++i) {\n const chainGroupCount = groupsPerChain[ i ]\n cGroupOffset[ i ] = groupOffset\n cGroupCount[ i ] = chainGroupCount\n for (j = 0; j < chainGroupCount; ++j) {\n gChainIndex[ j + groupOffset ] = i\n }\n groupOffset += chainGroupCount\n }\n\n /// ///\n // get data from group map\n\n let atomOffset = 0\n let bondOffset = 0\n\n for (i = 0, il = numGroups; i < il; ++i) {\n groupData = sd.groupList[ sd.groupTypeList[ i ] ]\n const groupAtomCount = groupData.atomNameList.length\n const groupFormalChargeList = groupData.formalChargeList\n\n const groupBondAtomList = groupData.bondAtomList\n const groupBondOrderList = groupData.bondOrderList\n\n for (j = 0, jl = groupBondOrderList.length; j < jl; ++j) {\n bAtomIndex1[ bondOffset ] = atomOffset + groupBondAtomList[ j * 2 ]\n bAtomIndex2[ bondOffset ] = atomOffset + groupBondAtomList[ j * 2 + 1 ]\n bBondOrder[ bondOffset ] = groupBondOrderList[ j ]\n bondOffset += 1\n }\n\n //\n\n gAtomOffset[ i ] = atomOffset\n gAtomCount[ i ] = groupAtomCount\n\n for (j = 0; j < groupAtomCount; ++j) {\n aGroupIndex[ atomOffset ] = i\n aFormalCharge[ atomOffset ] = groupFormalChargeList[ j ]\n atomOffset += 1\n }\n }\n\n // extra bonds\n\n const bondAtomList = sd.bondAtomList\n if (bondAtomList) {\n if (sd.bondOrderList) {\n bBondOrder.set(sd.bondOrderList, bondOffset)\n }\n\n for (i = 0, il = bondAtomList.length; i < il; i += 2) {\n const atomIndex1 = bondAtomList[ i ]\n const atomIndex2 = bondAtomList[ i + 1 ]\n if (atomIndex1 < numAtoms && atomIndex2 < numAtoms) {\n bAtomIndex1[ bondOffset ] = atomIndex1\n bAtomIndex2[ bondOffset ] = atomIndex2\n bondOffset += 1\n }\n }\n }\n\n //\n\n s.bondStore.length = bBondOrder.length\n s.bondStore.count = bondOffset\n s.bondStore.atomIndex1 = bAtomIndex1\n s.bondStore.atomIndex2 = bAtomIndex2\n s.bondStore.bondOrder = bBondOrder\n\n s.atomStore.length = numAtoms\n s.atomStore.count = numAtoms\n s.atomStore.residueIndex = aGroupIndex\n s.atomStore.atomTypeId = new Uint16Array(numAtoms)\n s.atomStore.x = sd.xCoordList.subarray(0, numAtoms)\n s.atomStore.y = sd.yCoordList.subarray(0, numAtoms)\n s.atomStore.z = sd.zCoordList.subarray(0, numAtoms)\n s.atomStore.serial = sd.atomIdList.subarray(0, numAtoms)\n s.atomStore.bfactor = sd.bFactorList.subarray(0, numAtoms)\n s.atomStore.altloc = sd.altLocList.subarray(0, numAtoms)\n s.atomStore.occupancy = sd.occupancyList.subarray(0, numAtoms)\n s.atomStore.formalCharge = aFormalCharge\n\n s.residueStore.length = numGroups\n s.residueStore.count = numGroups\n s.residueStore.chainIndex = gChainIndex\n s.residueStore.residueTypeId = sd.groupTypeList\n s.residueStore.atomOffset = gAtomOffset\n s.residueStore.atomCount = gAtomCount\n s.residueStore.resno = sd.groupIdList.subarray(0, numGroups)\n s.residueStore.sstruc = sd.secStructList.subarray(0, numGroups)\n s.residueStore.inscode = sd.insCodeList.subarray(0, numGroups)\n\n s.chainStore.length = numChains\n s.chainStore.count = numChains\n s.chainStore.entityIndex = new Uint16Array(numChains)\n s.chainStore.modelIndex = cModelIndex\n s.chainStore.residueOffset = cGroupOffset\n s.chainStore.residueCount = cGroupCount\n s.chainStore.chainname = sd.chainNameList.subarray(0, numChains * 4)\n s.chainStore.chainid = sd.chainIdList.subarray(0, numChains * 4)\n\n s.modelStore.length = numModels\n s.modelStore.count = numModels\n s.modelStore.chainOffset = mChainOffset\n s.modelStore.chainCount = mChainCount\n\n //\n\n let groupTypeDict: {[k: number]: any} = {}\n for (i = 0, il = sd.groupList.length; i < il; ++i) {\n const groupType = sd.groupList[ i ]\n const atomTypeIdList: number[] = []\n for (j = 0, jl = groupType.atomNameList.length; j < jl; ++j) {\n const element = groupType.elementList[ j ].toUpperCase()\n const atomname = groupType.atomNameList[ j ]\n atomTypeIdList.push(s.atomMap.add(atomname, element))\n }\n const chemCompType = groupType.chemCompType.toUpperCase()\n const hetFlag = ChemCompHetero.includes(chemCompType)\n\n const numGroupBonds = groupType.bondOrderList.length\n const atomIndices1 = new Array(numGroupBonds)\n const atomIndices2 = new Array(numGroupBonds)\n for (j = 0; j < numGroupBonds; ++j) {\n atomIndices1[ j ] = groupType.bondAtomList[ j * 2 ]\n atomIndices2[ j ] = groupType.bondAtomList[ j * 2 + 1 ]\n }\n const bonds = {\n atomIndices1: atomIndices1,\n atomIndices2: atomIndices2,\n bondOrders: groupType.bondOrderList\n }\n\n groupTypeDict[ i ] = s.residueMap.add(\n groupType.groupName, atomTypeIdList, hetFlag, chemCompType, bonds\n )\n }\n\n for (i = 0, il = numGroups; i < il; ++i) {\n s.residueStore.residueTypeId[ i ] = groupTypeDict[ s.residueStore.residueTypeId[ i ] ]\n }\n\n for (i = 0, il = s.atomStore.count; i < il; ++i) {\n const residueIndex = s.atomStore.residueIndex[ i ]\n const residueType = s.residueMap.list[ s.residueStore.residueTypeId[ residueIndex ] ]\n const resAtomOffset = s.residueStore.atomOffset[ residueIndex ]\n s.atomStore.atomTypeId[ i ] = residueType.atomTypeIdList[ i - resAtomOffset ]\n }\n\n if (sd.secStructList) {\n const secStructLength: number = sd.secStructList.length\n for (i = 0, il = s.residueStore.count; i < il; ++i) {\n // with ( i % secStructLength ) secStruct entries are reused\n const sstruc = SstrucMap[ s.residueStore.sstruc[ i % secStructLength ] ]\n if (sstruc !== undefined) s.residueStore.sstruc[ i ] = sstruc\n }\n }\n\n //\n\n if (sd.entityList) {\n sd.entityList.forEach(function (e: Entity, i: number) {\n s.entityList[ i ] = new Entity(\n s, i, e.description, e.type, e.chainIndexList\n )\n })\n }\n\n if (sd.bioAssemblyList) {\n sd.bioAssemblyList.forEach(function (_assembly: any, k: number) {\n const id = k + 1\n const assembly = new Assembly('' + id)\n s.biomolDict[ 'BU' + id ] = assembly\n let chainToPart: {[k: string]: AssemblyPart} = {}\n _assembly.transformList.forEach(function (_transform: any) {\n const matrix = new Matrix4().fromArray(_transform.matrix).transpose()\n const chainList: string[] = _transform.chainIndexList.map(function (chainIndex: number) {\n let chainname = ''\n for (let k = 0; k < 4; ++k) {\n const code = sd.chainNameList[ chainIndex * 4 + k ]\n if (code) {\n chainname += String.fromCharCode(code)\n } else {\n break\n }\n }\n return chainname\n })\n const part = chainToPart[ chainList.toString() ]\n if (part) {\n part.matrixList.push(matrix)\n } else {\n chainToPart[ chainList.toString() ] = assembly.addPart([ matrix ], chainList)\n }\n })\n })\n }\n\n if (sd.ncsOperatorList) {\n const ncsName = 'NCS'\n const ncsAssembly = new Assembly(ncsName)\n const ncsPart = ncsAssembly.addPart()\n sd.ncsOperatorList.forEach(function (_operator: number[]) {\n const matrix = new Matrix4().fromArray(_operator).transpose()\n ncsPart.matrixList.push(matrix)\n })\n if (ncsPart.matrixList.length > 0) {\n s.biomolDict[ ncsName ] = ncsAssembly\n }\n }\n\n const uc = sd.unitCell\n if (uc && Array.isArray(uc) && uc[ 0 ]) {\n s.unitcell = new Unitcell({\n a: uc[ 0 ],\n b: uc[ 1 ],\n c: uc[ 2 ],\n alpha: uc[ 3 ],\n beta: uc[ 4 ],\n gamma: uc[ 5 ],\n spacegroup: sd.spaceGroup\n })\n } else {\n s.unitcell = undefined\n }\n\n // calculate backbone bonds\n calculateBondsBetween(s, true)\n\n // calculate rung bonds\n calculateBondsWithin(s, true)\n\n s.finalizeAtoms()\n s.finalizeBonds()\n\n buildUnitcellAssembly(s)\n\n if (Debug) Log.timeEnd('MmtfParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('mmtf', MmtfParser)\n\nexport default MmtfParser\n","/**\n * @file Mol2 Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport {\n assignResidueTypeBonds,\n calculateChainnames, calculateSecondaryStructure,\n calculateBondsBetween, calculateBondsWithin\n} from '../structure/structure-utils'\nimport StructureParser from './structure-parser'\n\nconst reWhitespace = /\\s+/\nconst bondTypes: {[k: string]: number} = {\n '1': 1,\n '2': 2,\n '3': 3,\n 'am': 1, // amide\n 'ar': 1, // aromatic\n 'du': 1, // dummy\n 'un': 1, // unknown\n 'nc': 0 // not connected\n}\n\nclass Mol2Parser extends StructureParser {\n get type () { return 'mol2' }\n\n _parse () {\n // http://paulbourke.net/dataformats/mol2/\n\n if (Debug) Log.time('Mol2Parser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n const firstModelOnly = this.firstModelOnly\n const asTrajectory = this.asTrajectory\n\n const frames = s.frames\n let doFrames = false\n let currentFrame: Float32Array, currentCoord: number\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.resize(Math.round(this.streamer.data.length / 60))\n atomStore.addField('partialCharge', 1, 'float32')\n\n let idx = 0\n let moleculeLineNo = 0\n let modelAtomIdxStart = 0\n let modelIdx = -1\n let numAtoms = 0\n\n let currentRecordType = 0\n let moleculeRecordType = 1\n let atomRecordType = 2\n let bondRecordType = 3\n\n const ap1 = s.getAtomProxy()\n const ap2 = s.getAtomProxy()\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ].trim()\n\n if (line === '' || line[ 0 ] === '#') continue\n\n if (line[ 0 ] === '@') {\n if (line === '@MOLECULE') {\n currentRecordType = moleculeRecordType\n moleculeLineNo = 0\n\n ++modelIdx\n } else if (line === '@ATOM') {\n currentRecordType = atomRecordType\n modelAtomIdxStart = atomStore.count\n\n if (asTrajectory) {\n currentCoord = 0\n currentFrame = new Float32Array(numAtoms * 3)\n frames.push(currentFrame)\n\n if (modelIdx > 0) doFrames = true\n }\n } else if (line === '@BOND') {\n currentRecordType = bondRecordType\n } else {\n currentRecordType = 0\n }\n } else if (currentRecordType === moleculeRecordType) {\n if (moleculeLineNo === 0) {\n s.title = line\n s.id = line\n } else if (moleculeLineNo === 1) {\n const ls = line.split(reWhitespace)\n numAtoms = parseInt(ls[ 0 ])\n // num_atoms [num_bonds [num_subst [num_feat [num_sets]]]]\n } else if (moleculeLineNo === 2) {\n\n // const molType = line;\n // SMALL, BIOPOLYMER, PROTEIN, NUCLEIC_ACID, SACCHARIDE\n\n } else if (moleculeLineNo === 3) {\n\n // const chargeType = line;\n // NO_CHARGES, DEL_RE, GASTEIGER, GAST_HUCK, HUCKEL,\n // PULLMAN, GAUSS80_CHARGES, AMPAC_CHARGES,\n // MULLIKEN_CHARGES, DICT_ CHARGES, MMFF94_CHARGES,\n // USER_CHARGES\n\n } else if (moleculeLineNo === 4) {\n\n // const statusBits = line;\n\n } else if (moleculeLineNo === 5) {\n\n // const molComment = line;\n\n }\n\n ++moleculeLineNo\n } else if (currentRecordType === atomRecordType) {\n const ls = line.split(reWhitespace)\n\n if (firstModelOnly && modelIdx > 0) continue\n\n const x = parseFloat(ls[ 2 ])\n const y = parseFloat(ls[ 3 ])\n const z = parseFloat(ls[ 4 ])\n\n if (asTrajectory) {\n const j = currentCoord * 3\n\n currentFrame[ j + 0 ] = x\n currentFrame[ j + 1 ] = y\n currentFrame[ j + 2 ] = z\n\n currentCoord += 1\n\n if (doFrames) continue\n }\n\n const serial = ls[ 0 ]\n const atomname = ls[ 1 ]\n const element = ls[ 5 ].split('.')[ 0 ]\n const resno = ls[ 6 ] ? parseInt(ls[ 6 ]) : 1\n const resname = ls[ 7 ] ? ls[ 7 ] : ''\n const partialCharge = ls[ 8 ] ? parseFloat(ls[ 8 ]) : 0.0\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname, element)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = serial\n atomStore.partialCharge[ idx ] = partialCharge\n\n sb.addAtom(modelIdx, '', '', resname, resno, true)\n\n idx += 1\n } else if (currentRecordType === bondRecordType) {\n if (firstModelOnly && modelIdx > 0) continue\n if (asTrajectory && modelIdx > 0) continue\n\n const ls = line.split(reWhitespace)\n\n // ls[ 0 ] is bond id\n ap1.index = parseInt(ls[ 1 ]) - 1 + modelAtomIdxStart\n ap2.index = parseInt(ls[ 2 ]) - 1 + modelAtomIdxStart\n const order = bondTypes[ ls[ 3 ] ]\n\n s.bondStore.addBond(ap1, ap2, order)\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n sb.finalize()\n s.finalizeAtoms()\n calculateChainnames(s)\n calculateBondsWithin(s, true)\n calculateBondsBetween(s, true)\n s.finalizeBonds()\n assignResidueTypeBonds(s)\n calculateSecondaryStructure(s)\n\n if (Debug) Log.timeEnd('Mol2Parser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('mol2', Mol2Parser)\n\nexport default Mol2Parser\n","/**\n * @file Pdbqt Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport PdbParser from './pdb-parser'\n\n// autodock variant of PDB format with\n// - atom partial charges (empty column in pdb format)\n// - atom types (bfactor column in pdb format)\n// http://autodock.scripps.edu/faqs-help/faq/what-is-the-format-of-a-pdbqt-file\n\nclass PdbqtParser extends PdbParser {\n get type () { return 'pdbqt' }\n}\n\nParserRegistry.add('pdbqt', PdbqtParser)\n\nexport default PdbqtParser\n","/**\n * @file Pqr Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport PdbParser from './pdb-parser'\n\n// http://www.poissonboltzmann.org/docs/file-format-info/\n\nclass PqrParser extends PdbParser {\n get type () { return 'pqr' }\n}\n\nParserRegistry.add('pqr', PqrParser)\n\nexport default PqrParser\n","/**\n * @file Sdf Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { assignResidueTypeBonds } from '../structure/structure-utils'\nimport StructureParser from './structure-parser'\n\nconst reItem = /> +<(.+)>/\n\nclass SdfParser extends StructureParser {\n get type () { return 'sdf' }\n\n _parse () {\n // https://en.wikipedia.org/wiki/Chemical_table_file#SDF\n // http://download.accelrys.com/freeware/ctfile-formats/ctfile-formats.zip\n\n if (Debug) Log.time('SdfParser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n const firstModelOnly = this.firstModelOnly\n const asTrajectory = this.asTrajectory\n\n const headerLines = this.streamer.peekLines(2)\n\n s.id = headerLines[ 0 ].trim()\n s.title = headerLines[ 1 ].trim()\n\n const frames = s.frames\n let doFrames = false\n let currentFrame: Float32Array, currentCoord: number\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.resize(Math.round(this.streamer.data.length / 50))\n atomStore.addField('formalCharge', 1, 'int8')\n\n const ap1 = s.getAtomProxy()\n const ap2 = s.getAtomProxy()\n\n let idx = 0\n let lineNo = 0 // for V2000: current line number in currently parsed Mol file\n let modelIdx = 0\n let modelAtomIdxStart = 0\n\n const sdfData: {[k: string]: string[]}[] = []\n let currentItem: string|boolean = false\n let currentData: {[k: string]: string[]} = {}\n let mItem: RegExpMatchArray | null\n s.extraData.sdf = sdfData\n\n let atomCount, bondCount, atomStart: number, atomEnd: number, bondStart: number, bondEnd: number, x: number, y: number, z: number, atomname: string, element: string, atomindex: number, order: number\n let isV3000 = false, isAtomBlock = false, isBondBlock = false\n let tokens: string[] = [], acc: string[] = []\n const atomindexToStoreindex = new Map()\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n\n if (isV3000 && line) {\n tokens = line.substring(7).split(' ')\n\n // Entity properties may extend over multiple lines (hanging line finishes with '-')\n // Tokens are accumulated to be processed at the same time for a given entity\n if (acc.length) {\n tokens = [...acc, ...tokens]\n acc = []\n }\n if (tokens[tokens.length - 1] === '-') {\n tokens.pop();\n acc = tokens;\n continue;\n }\n }\n\n if (line.substr(0, 4) === '$$$$') {\n lineNo = -1\n ++modelIdx\n modelAtomIdxStart = atomStore.count\n sdfData.push(currentData)\n currentData = {}\n currentItem = false\n isV3000 = false\n } else if (lineNo === 3) {\n isV3000 = line.indexOf(' V3000') > -1\n\n if (isV3000) {\n atomindexToStoreindex.clear()\n } else {\n\n atomCount = parseInt(line.substr(0, 3))\n bondCount = parseInt(line.substr(3, 3))\n\n atomStart = 4\n atomEnd = atomStart + atomCount\n bondStart = atomEnd\n bondEnd = bondStart + bondCount\n\n if (asTrajectory) {\n currentCoord = 0\n currentFrame = new Float32Array(atomCount * 3)\n frames.push(currentFrame)\n\n if (modelIdx > 0) doFrames = true\n }\n }\n } else if (isV3000 && tokens[0] === 'COUNTS') {\n atomCount = parseInt(tokens[1]);\n\n if (asTrajectory) {\n currentCoord = 0\n currentFrame = new Float32Array(atomCount * 3)\n frames.push(currentFrame)\n\n if (modelIdx > 0) doFrames = true\n }\n } else if (isV3000 && tokens.length == 2) {\n if (tokens[1] === 'ATOM') {\n if (tokens[0] === 'BEGIN') isAtomBlock = true\n else if (tokens[0] === 'END') isAtomBlock = false\n } else if (tokens[1] === 'BOND') {\n if (tokens[0] === 'BEGIN') isBondBlock = true\n else if (tokens[0] === 'END') isBondBlock = false\n }\n } else if (\n isAtomBlock \n || (!isV3000 && lineNo >= atomStart && lineNo < atomEnd)\n ) {\n if (firstModelOnly && modelIdx > 0) continue\n\n let charge = 0\n if (isV3000) {\n x = parseFloat(tokens[2])\n y = parseFloat(tokens[3])\n z = parseFloat(tokens[4])\n\n element = tokens[1]\n atomindex = parseInt(tokens[0])\n atomindexToStoreindex.set(atomindex, idx)\n atomname = element + atomindex\n\n if (tokens.length > 6) {\n let chgTok = tokens.slice(6).find(t => t.indexOf('CHG=') === 0);\n if (chgTok) {\n charge = parseInt(chgTok.substring(4))\n }\n }\n } else {\n x = parseFloat(line.substr(0, 10))\n y = parseFloat(line.substr(10, 10))\n z = parseFloat(line.substr(20, 10))\n\n element = line.substr(31, 3).trim()\n atomname = element + (idx - modelAtomIdxStart + 1)\n }\n\n if (asTrajectory) {\n const j = currentCoord * 3\n\n currentFrame[ j + 0 ] = x\n currentFrame[ j + 1 ] = y\n currentFrame[ j + 2 ] = z\n\n currentCoord += 1\n\n if (doFrames) continue\n }\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname, element)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = isV3000 ? atomindex : idx\n atomStore.formalCharge[ idx ] = charge\n\n sb.addAtom(modelIdx, '', '', 'HET', 1, true)\n\n idx += 1\n } else if (\n isBondBlock \n || (!isV3000 && lineNo >= bondStart && lineNo < bondEnd)\n ) {\n if (firstModelOnly && modelIdx > 0) continue\n if (asTrajectory && modelIdx > 0) continue\n\n if (isV3000) {\n ap1.index = atomindexToStoreindex.get(parseInt(tokens[2]))\n ap2.index = atomindexToStoreindex.get(parseInt(tokens[3]))\n order = parseInt(tokens[1])\n } else {\n ap1.index = parseInt(line.substr(0, 3)) - 1 + modelAtomIdxStart\n ap2.index = parseInt(line.substr(3, 3)) - 1 + modelAtomIdxStart\n order = parseInt(line.substr(6, 3))\n }\n\n s.bondStore.addBond(ap1, ap2, order)\n } else if (line.substr(0, 6) === 'M CHG') {\n const chargeCount = parseInt(line.substr(6, 3))\n for (let ci = 0, coffset = 10; ci < chargeCount; ++ci, coffset += 8) {\n const aToken = parseInt(line.substr(coffset, 3))\n const atomIdx = aToken - 1 + modelAtomIdxStart\n const cToken = parseInt(line.substr(coffset + 4, 3))\n atomStore.formalCharge[ atomIdx ] = cToken\n }\n // eslint-disable-next-line no-cond-assign\n } else if (line.charAt(0) === '>' && (mItem = line.match(reItem))) {\n currentItem = mItem[ 1 ]\n currentData[ currentItem ] = []\n } else if (currentItem !== false && line) {\n currentData[ currentItem ].push(line)\n }\n\n ++lineNo\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n assignResidueTypeBonds(s)\n\n if (Debug) Log.timeEnd('SdfParser._parse ' + this.name)\n }\n\n _postProcess () {\n assignResidueTypeBonds(this.structure)\n }\n}\n\nParserRegistry.add('sdf', SdfParser)\nParserRegistry.add('sd', SdfParser)\nParserRegistry.add('mol', SdfParser)\n\nexport default SdfParser\n","/**\n * @file Prmtop Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport {\n assignResidueTypeBonds, calculateBondsBetween,\n calculateBondsWithin, calculateChainnames\n} from '../structure/structure-utils'\n\nconst amberChargeUnitFactor = 18.2223\n\nconst enum Mode {\n Title,\n Pointers,\n AtomName,\n Charge,\n Mass,\n ResidueLabel,\n ResiduePointer,\n BondsIncHydrogen,\n BondsWithoutHydrogen,\n Radii\n}\n\nfunction parseIntSubstr (line: string, start: number, length: number) {\n return parseInt(line.substr(start, length).trim())\n}\n\nclass PrmtopParser extends StructureParser {\n get type () { return 'prmtop' }\n\n _parse () {\n // http://ambermd.org/prmtop.pdf\n // http://ambermd.org/formats.html#topology\n\n if (Debug) Log.time('PrmtopParser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n //\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.addField('partialCharge', 1, 'float32')\n atomStore.addField('radius', 1, 'float32')\n\n const title: string[] = []\n const pointersDict: {[k: string]: number} = {}\n const pointers = [\n 'NATOM', 'NTYPES', 'NBONH', 'MBONA', 'NTHETH', 'MTHETA',\n 'NPHIH', 'MPHIA', 'NHPARM', 'NPARM', 'NNB', 'NRES',\n 'NBONA', 'NTHETA', 'NPHIA', 'NUMBND', 'NUMANG', 'NPTRA',\n 'NATYP', 'NPHB', 'IFPERT', 'NBPER', 'NGPER', 'NDPER',\n 'MBPER', 'MGPER', 'MDPER', 'IFBOX', 'NMXRS', 'IFCAP',\n 'NUMEXTRA', 'NCOPY'\n ]\n pointers.forEach(name => { pointersDict[ name ] = 0 })\n\n let atomNames: string[]\n let charges: Float32Array\n let radii: Float32Array\n let bAtomIndex1: Uint32Array\n let bAtomIndex2: Uint32Array\n let bBondOrder: Uint8Array = new Uint8Array(0)\n let residueLabels: string[]\n let residuePointers: Uint32Array\n\n let mode: number|undefined\n // let currentFormat\n let curIdx: number\n let bondIdx: number\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n const lt = line.trim()\n\n if (!lt) {\n continue\n } else if (line.startsWith('%FORMAT')) {\n // currentFormat = lt.substring(8, lt.length - 1)\n } else if (line.startsWith('%FLAG')) {\n const flag = line.substr(5).trim()\n curIdx = 0\n\n if (flag === 'TITLE') {\n mode = Mode.Title\n } else if (flag === 'POINTERS') {\n mode = Mode.Pointers\n } else if (flag === 'ATOM_NAME') {\n mode = Mode.AtomName\n } else if (flag === 'CHARGE') {\n mode = Mode.Charge\n } else if (flag === 'MASS') {\n mode = Mode.Mass\n } else if (flag === 'RESIDUE_LABEL') {\n mode = Mode.ResidueLabel\n } else if (flag === 'RESIDUE_POINTER') {\n mode = Mode.ResiduePointer\n } else if (flag === 'BONDS_INC_HYDROGEN') {\n bondIdx = 0\n mode = Mode.BondsIncHydrogen\n } else if (flag === 'BONDS_WITHOUT_HYDROGEN') {\n bondIdx = pointersDict['NBONH']\n mode = Mode.BondsWithoutHydrogen\n } else if (flag === 'RADII') {\n mode = Mode.Radii\n } else {\n mode = undefined\n }\n } else if (mode === Mode.Title) {\n title.push(lt)\n } else if (mode === Mode.Pointers) {\n const n = Math.min(curIdx + 10, 32)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n pointersDict[pointers[curIdx]] = parseInt(\n line.substr(i * 8, 8).trim()\n )\n }\n atomNames = new Array(pointersDict.NATOM)\n charges = new Float32Array(pointersDict.NATOM)\n radii = new Float32Array(pointersDict.NATOM)\n atomStore.resize(pointersDict.NATOM)\n const bondCount = pointersDict.NBONH + pointersDict.MBONA\n bAtomIndex1 = new Uint32Array(bondCount)\n bAtomIndex2 = new Uint32Array(bondCount)\n bBondOrder = new Uint8Array(bondCount)\n residueLabels = new Array(pointersDict.NRES)\n residuePointers = new Uint32Array(pointersDict.NRES)\n } else if (mode === Mode.AtomName) {\n const n = Math.min(curIdx + 20, pointersDict.NATOM)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n atomNames[curIdx] = line.substr(i * 4, 4).trim()\n }\n } else if (mode === Mode.Charge) {\n const n = Math.min(curIdx + 5, pointersDict.NATOM)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n charges[curIdx] = parseFloat(line.substr(i * 16, 16)) / amberChargeUnitFactor\n }\n } else if (mode === Mode.Mass) {\n\n // not currently used\n\n } else if (mode === Mode.ResidueLabel) {\n const n = Math.min(curIdx + 20, pointersDict.NRES)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n residueLabels[curIdx] = line.substr(i * 4, 4).trim()\n }\n } else if (mode === Mode.ResiduePointer) {\n const n = Math.min(curIdx + 10, pointersDict.NRES)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n residuePointers[curIdx] = parseIntSubstr(line, i * 8, 8)\n }\n } else if (mode === Mode.BondsIncHydrogen) {\n const n = Math.min(curIdx + 10, pointersDict.NBONH * 3)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n const r = curIdx % 3\n if (r === 0) {\n bAtomIndex1[bondIdx] = parseIntSubstr(line, i * 8, 8) / 3\n } if (r === 1) {\n bAtomIndex2[bondIdx] = parseIntSubstr(line, i * 8, 8) / 3\n bBondOrder[bondIdx] = 1\n ++bondIdx\n }\n }\n } else if (mode === Mode.BondsWithoutHydrogen) {\n const n = Math.min(curIdx + 10, pointersDict.MBONA * 3)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n const r = curIdx % 3\n if (r === 0) {\n bAtomIndex1[bondIdx] = parseIntSubstr(line, i * 8, 8) / 3\n } if (r === 1) {\n bAtomIndex2[bondIdx] = parseIntSubstr(line, i * 8, 8) / 3\n bBondOrder[bondIdx] = 1\n ++bondIdx\n }\n }\n } else if (mode === Mode.Radii) {\n const n = Math.min(curIdx + 5, pointersDict.NATOM)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n radii[curIdx] = parseFloat(line.substr(i * 16, 16))\n }\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n s.title = title.join(' ')\n\n const atomCount = pointersDict.NATOM\n let curResIdx = 0\n let curResname = residueLabels![0]\n let curResno = 1\n for (let i = 0; i < atomCount; ++i) {\n if (i + 1 === residuePointers![curResIdx + 1]) {\n ++curResIdx\n curResname = residueLabels![curResIdx]\n curResno = curResIdx + 1\n }\n atomStore.atomTypeId[i] = atomMap.add(atomNames![i])\n atomStore.serial[i] = i + 1\n sb.addAtom(0, '', '', curResname, curResno, false)\n }\n\n atomStore.partialCharge.set(charges!)\n atomStore.radius.set(radii!)\n\n s.bondStore.length = bBondOrder!.length\n s.bondStore.count = bBondOrder!.length\n s.bondStore.atomIndex1 = bAtomIndex1!\n s.bondStore.atomIndex2 = bAtomIndex2!\n s.bondStore.bondOrder = bBondOrder\n\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n calculateBondsWithin(s, true)\n calculateBondsBetween(s, true, true)\n calculateChainnames(s, true)\n assignResidueTypeBonds(s)\n\n if (Debug) Log.timeEnd('PrmtopParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('prmtop', PrmtopParser)\nParserRegistry.add('parm7', PrmtopParser)\n\nexport default PrmtopParser\n","/**\n * @file Psf Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport {\n assignResidueTypeBonds, calculateBondsBetween,\n calculateBondsWithin, getChainname\n} from '../structure/structure-utils'\n\nconst TitleMode = 1\nconst AtomMode = 2\nconst BondMode = 3\nconst AngleMode = 4\nconst DihedralMode = 5\nconst ImproperMode = 6\n\nconst reWhitespace = /\\s+/\nconst reTitle = /(^\\*|REMARK)*/\n\nclass PsfParser extends StructureParser {\n get type () { return 'psf' }\n\n _parse () {\n // http://www.ks.uiuc.edu/Training/Tutorials/namd/namd-tutorial-unix-html/node23.html\n\n if (Debug) Log.time('PsfParser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n //\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.addField('partialCharge', 1, 'float32')\n\n const title: string[] = []\n\n let mode: number|undefined\n let chainid: string\n let lastSegid: string\n let idx = 0\n let chainIdx = 0\n let bondIdx = 0\n let bAtomIndex1: Uint32Array, bAtomIndex2: Uint32Array, bBondOrder: Uint8Array\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ].trim()\n\n if (!line) {\n mode = undefined\n continue\n }\n\n if (mode === AtomMode) {\n const ls = line.split(reWhitespace)\n\n const serial = parseInt(ls[ 0 ])\n const segid = ls[ 1 ]\n const resno = parseInt(ls[ 2 ])\n const resname = ls[ 3 ]\n const atomname = ls[ 4 ]\n const charge = parseFloat(ls[ 6 ])\n\n if (segid !== lastSegid) {\n chainid = getChainname(chainIdx)\n ++chainIdx\n }\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname)\n\n atomStore.serial[ idx ] = serial\n atomStore.partialCharge[ idx ] = charge\n\n sb.addAtom(0, chainid, chainid, resname, resno, false)\n\n idx += 1\n lastSegid = segid\n } else if (mode === BondMode) {\n const ls = line.split(reWhitespace)\n\n for (let j = 0, m = ls.length; j < m; j += 2) {\n bAtomIndex1[ bondIdx ] = parseInt(ls[ j ]) - 1\n bAtomIndex2[ bondIdx ] = parseInt(ls[ j + 1 ]) - 1\n bBondOrder[ bondIdx ] = 1\n bondIdx += 1\n }\n } else if (mode === TitleMode) {\n title.push(line.replace(reTitle, '').trim())\n } else if (mode === AngleMode) {\n\n // currently not used\n\n } else if (mode === DihedralMode) {\n\n // currently not used\n\n } else if (mode === ImproperMode) {\n\n // currently not used\n\n } else if (line.includes('!NATOM')) {\n mode = AtomMode\n\n const numAtoms = parseInt(line.split(reWhitespace)[ 0 ])\n atomStore.resize(numAtoms)\n } else if (line.includes('!NBOND')) {\n mode = BondMode\n\n const numBonds = parseInt(line.split(reWhitespace)[ 0 ])\n bAtomIndex1 = new Uint32Array(numBonds)\n bAtomIndex2 = new Uint32Array(numBonds)\n bBondOrder = new Uint8Array(numBonds)\n } else if (line.includes('!NTITLE')) {\n mode = TitleMode\n } else if (line.includes('!NTHETA')) {\n mode = AngleMode\n } else if (line.includes('!NPHI')) {\n mode = DihedralMode\n } else if (line.includes('!NIMPHI')) {\n mode = ImproperMode\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n s.title = title.join(' ')\n\n s.bondStore.length = bBondOrder!.length\n s.bondStore.count = bondIdx\n s.bondStore.atomIndex1 = bAtomIndex1!\n s.bondStore.atomIndex2 = bAtomIndex2!\n s.bondStore.bondOrder = bBondOrder!\n\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n calculateBondsWithin(s, true)\n calculateBondsBetween(s, true, true)\n assignResidueTypeBonds(s)\n\n if (Debug) Log.timeEnd('PsfParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('psf', PsfParser)\n\nexport default PsfParser\n","/**\n * @file Top Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport { WaterNames } from '../structure/structure-constants'\nimport {\n assignResidueTypeBonds, calculateBondsBetween,\n calculateBondsWithin, getChainname\n} from '../structure/structure-utils'\n\nconst enum Mode {\n System,\n Molecules,\n Moleculetype,\n Atoms,\n Bonds\n}\n\nconst reField = /\\[ (.+) \\]/\nconst reWhitespace = /\\s+/\n\nclass TopParser extends StructureParser {\n get type () { return 'top' }\n\n _parse () {\n // http://manual.gromacs.org/online/top.html\n\n if (Debug) Log.time('TopParser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n //\n\n const atomMap = s.atomMap\n const bondStore = s.bondStore\n\n const atomStore = s.atomStore\n atomStore.addField('partialCharge', 1, 'float32')\n\n const molecules: [string, number][] = []\n const moleculetypeDict: {[k: string]: {atoms: any[], bonds: any[] }} = {}\n\n let currentMoleculetype: {\n atoms: [number, string, string, number][],\n bonds: [number, number][]\n }\n let mode: number|undefined\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n let lt = line.trim()\n\n if (!lt || lt[0] === '*' || lt[0] === ';') {\n continue\n }\n\n if (lt.startsWith('#include')) {\n throw new Error('TopParser: #include statements not allowed')\n }\n\n const fieldMatch = line.match(reField)\n if (fieldMatch !== null) {\n const name = fieldMatch[1]\n if (name === 'moleculetype') {\n mode = Mode.Moleculetype\n currentMoleculetype = {\n atoms: [],\n bonds: []\n }\n } else if (name === 'atoms') {\n mode = Mode.Atoms\n } else if (name === 'bonds') {\n mode = Mode.Bonds\n } else if (name === 'system') {\n mode = Mode.System\n } else if (name === 'molecules') {\n mode = Mode.Molecules\n } else {\n mode = undefined\n }\n continue\n }\n\n const cIdx = lt.indexOf(';')\n if (cIdx !== -1) {\n lt = lt.substring(0, cIdx).trim()\n }\n if (mode === Mode.Moleculetype) {\n const molName = lt.split(reWhitespace)[0]\n moleculetypeDict[molName] = currentMoleculetype\n } else if (mode === Mode.Atoms) {\n const ls = lt.split(reWhitespace)\n currentMoleculetype.atoms.push([\n parseInt(ls[2]), // resnr\n ls[3], // residue\n ls[4], // atom\n parseFloat(ls[6]) // charge\n ])\n } else if (mode === Mode.Bonds) {\n const ls = lt.split(reWhitespace)\n currentMoleculetype.bonds.push([\n parseInt(ls[0]), // ai\n parseInt(ls[1]) // aj\n ])\n } else if (mode === Mode.System) {\n s.title = lt\n } else if (mode === Mode.Molecules) {\n const ls = lt.split(reWhitespace)\n molecules.push([\n ls[0], // name\n parseInt(ls[1]) // count\n ])\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n let atomCount = 0\n let bondCount = 0\n molecules.forEach(function (val) {\n const [name, molCount] = val\n const molType = moleculetypeDict[name]\n atomCount += molCount * molType.atoms.length\n bondCount += molCount * molType.bonds.length\n })\n\n atomStore.resize(atomCount)\n bondStore.resize(bondCount)\n\n let atomIdx = 0\n let resIdx = 0\n let chainidIdx = 0\n let chainnameIdx = 0\n let bondIdx = 0\n let atomOffset = 0\n let lastResno: number\n\n molecules.forEach(function (val) {\n const [name, molCount] = val\n const molType = moleculetypeDict[name]\n const chainname = getChainname(chainnameIdx)\n for (let i = 0; i < molCount; ++i) {\n lastResno = -1\n const chainid = WaterNames.includes(name) ? chainname : getChainname(chainidIdx)\n molType.atoms.forEach(function (atomData) {\n const [resno, resname, atomname, charge] = atomData\n if (resno !== lastResno) {\n ++resIdx\n }\n atomStore.atomTypeId[atomIdx] = atomMap.add(atomname)\n atomStore.serial[atomIdx] = atomIdx + 1\n atomStore.partialCharge[atomIdx] = charge\n sb.addAtom(0, chainname, chainid, resname, resIdx + 1, false)\n ++atomIdx\n lastResno = resno\n })\n molType.bonds.forEach(function (bondData) {\n bondStore.atomIndex1[bondIdx] = atomOffset + bondData[0] - 1\n bondStore.atomIndex2[bondIdx] = atomOffset + bondData[1] - 1\n ++bondIdx\n })\n ++chainidIdx\n atomOffset += molType.atoms.length\n }\n ++chainnameIdx\n })\n\n bondStore.count = bondCount\n\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n calculateBondsWithin(s, true)\n calculateBondsBetween(s, true, true)\n assignResidueTypeBonds(s)\n\n if (Debug) Log.timeEnd('TopParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('top', TopParser)\n\nexport default TopParser\n","/**\n * @file Trajectory Parser\n * @author Alexander Rose \n * @private\n */\n\nimport Parser, { ParserParameters } from './parser'\nimport Frames from '../trajectory/frames'\nimport Streamer from '../streamer/streamer';\n\nclass TrajectoryParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n super(streamer, params)\n\n this.frames = new Frames(this.name, this.path)\n }\n\n get type () { return 'trajectory' }\n get __objName () { return 'frames' }\n}\n\nexport default TrajectoryParser\n","/**\n * @file Netcdf Reader\n * @author Alexander Rose \n * @private\n *\n * Adapted from https://github.com/cheminfo-js/netcdfjs\n * MIT License, Copyright (c) 2016 cheminfo\n */\n\nimport IOBuffer from './io-buffer'\n\nexport interface NetCDFRecordDimension {\n length: number,\n id?: number,\n name?: string,\n recordStep?: number\n}\n\nexport interface NetCDFHeader {\n recordDimension: NetCDFRecordDimension,\n version: number,\n dimensions: any[],\n globalAttributes: any[],\n variables: any[]\n}\n\nexport interface NetCDFDimension {\n name: string,\n size: number\n}\n\n/**\n * Throws a non-valid NetCDF exception if the statement it's true\n * @ignore\n * @param {boolean} statement - Throws if true\n * @param {string} reason - Reason to throw\n */\nfunction notNetcdf (statement: boolean, reason: string) {\n if (statement) {\n throw new TypeError('Not a valid NetCDF v3.x file: ' + reason)\n }\n}\n\n/**\n * Moves 1, 2, or 3 bytes to next 4-byte boundary\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n */\nfunction padding (buffer: IOBuffer) {\n if ((buffer.offset % 4) !== 0) {\n buffer.skip(4 - (buffer.offset % 4))\n }\n}\n\n/**\n * Reads the name\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @return {string} - Name\n */\nfunction readName (buffer: IOBuffer) {\n // Read name\n const nameLength = buffer.readUint32()\n const name = buffer.readChars(nameLength)\n\n // validate name\n // TODO\n\n // Apply padding\n padding(buffer)\n return name\n}\n\nconst types = {\n BYTE: 1,\n CHAR: 2,\n SHORT: 3,\n INT: 4,\n FLOAT: 5,\n DOUBLE: 6\n}\n\n/**\n * Parse a number into their respective type\n * @ignore\n * @param {number} type - integer that represents the type\n * @return {string} - parsed value of the type\n */\nfunction num2str (type: number) {\n switch (Number(type)) {\n case types.BYTE:\n return 'byte'\n case types.CHAR:\n return 'char'\n case types.SHORT:\n return 'short'\n case types.INT:\n return 'int'\n case types.FLOAT:\n return 'float'\n case types.DOUBLE:\n return 'double'\n default:\n return 'undefined'\n }\n}\n\n/**\n * Parse a number type identifier to his size in bytes\n * @ignore\n * @param {number} type - integer that represents the type\n * @return {number} -size of the type\n */\nfunction num2bytes (type: number) {\n switch (Number(type)) {\n case types.BYTE:\n return 1\n case types.CHAR:\n return 1\n case types.SHORT:\n return 2\n case types.INT:\n return 4\n case types.FLOAT:\n return 4\n case types.DOUBLE:\n return 8\n default:\n return -1\n }\n}\n\n/**\n * Reverse search of num2str\n * @ignore\n * @param {string} type - string that represents the type\n * @return {number} - parsed value of the type\n */\nfunction str2num (type: string) {\n switch (String(type)) {\n case 'byte':\n return types.BYTE\n case 'char':\n return types.CHAR\n case 'short':\n return types.SHORT\n case 'int':\n return types.INT\n case 'float':\n return types.FLOAT\n case 'double':\n return types.DOUBLE\n default:\n return -1\n }\n}\n\n/**\n * Auxiliary function to read numeric data\n * @ignore\n * @param {number} size - Size of the element to read\n * @param {function} bufferReader - Function to read next value\n * @return {Array|number}\n */\nfunction readNumber (size: number, bufferReader: Function) {\n if (size !== 1) {\n const numbers = new Array(size)\n for (let i = 0; i < size; i++) {\n numbers[i] = bufferReader()\n }\n return numbers\n } else {\n return bufferReader()\n }\n}\n\n/**\n * Given a type and a size reads the next element\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {number} type - Type of the data to read\n * @param {number} size - Size of the element to read\n * @return {string|Array|number}\n */\nfunction readType (buffer: IOBuffer, type: number, size: number) {\n switch (type) {\n case types.BYTE:\n return buffer.readBytes(size)\n case types.CHAR:\n return trimNull(buffer.readChars(size))\n case types.SHORT:\n return readNumber(size, buffer.readInt16.bind(buffer))\n case types.INT:\n return readNumber(size, buffer.readInt32.bind(buffer))\n case types.FLOAT:\n return readNumber(size, buffer.readFloat32.bind(buffer))\n case types.DOUBLE:\n return readNumber(size, buffer.readFloat64.bind(buffer))\n default:\n notNetcdf(true, 'non valid type ' + type)\n return undefined\n }\n}\n\n/**\n * Removes null terminate value\n * @ignore\n * @param {string} value - String to trim\n * @return {string} - Trimmed string\n */\nfunction trimNull (value: string) {\n if (value.charCodeAt(value.length - 1) === 0) {\n return value.substring(0, value.length - 1)\n }\n return value\n}\n\n// const STREAMING = 4294967295;\n\n/**\n * Read data for the given non-record variable\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {object} variable - Variable metadata\n * @return {Array} - Data of the element\n */\nfunction nonRecord (buffer: IOBuffer, variable: {type: string, size: number}) {\n // variable type\n const type = str2num(variable.type)\n\n // size of the data\n const size = variable.size / num2bytes(type)\n\n // iterates over the data\n const data = new Array(size)\n for (let i = 0; i < size; i++) {\n data[i] = readType(buffer, type, 1)\n }\n\n return data\n}\n\n/**\n * Read data for the given record variable\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {object} variable - Variable metadata\n * @param {object} recordDimension - Record dimension metadata\n * @return {Array} - Data of the element\n */\nfunction record (buffer:IOBuffer, variable: {type: string, size: number}, recordDimension: NetCDFRecordDimension) {\n // variable type\n const type = str2num(variable.type)\n const width = variable.size ? variable.size / num2bytes(type) : 1\n\n // size of the data\n // TODO streaming data\n const size = recordDimension.length\n\n // iterates over the data\n const data = new Array(size)\n const step = recordDimension.recordStep\n\n for (let i = 0; i < size; i++) {\n const currentOffset = buffer.offset\n data[i] = readType(buffer, type, width)\n buffer.seek(currentOffset + step!)\n }\n\n return data\n}\n\n// Grammar constants\nconst ZERO = 0\nconst NC_DIMENSION = 10\nconst NC_VARIABLE = 11\nconst NC_ATTRIBUTE = 12\n\n/**\n * Read the header of the file\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {number} version - Version of the file\n * @return {object} - Object with the fields:\n * * `recordDimension`: Number with the length of record dimension\n * * `dimensions`: List of dimensions\n * * `globalAttributes`: List of global attributes\n * * `variables`: List of variables\n */\nfunction header (buffer: IOBuffer, version: number) {\n // Length of record dimension\n // sum of the varSize's of all the record variables.\n const header: Partial = {recordDimension: {length: buffer.readUint32()}}\n\n // Version\n header.version = version\n\n // List of dimensions\n const dimList = dimensionsList(buffer) as {dimensions: NetCDFDimension[], recordId: number, recordName: string}\n header.recordDimension!.id = dimList.recordId\n header.recordDimension!.name = dimList.recordName\n header.dimensions = dimList.dimensions\n\n // List of global attributes\n header.globalAttributes = attributesList(buffer)\n\n // List of variables\n const variables = variablesList(buffer, dimList.recordId, version) as {variables: any[], recordStep: number}\n header.variables = variables.variables\n header.recordDimension!.recordStep = variables.recordStep\n\n return header\n}\n\n/**\n * List of dimensions\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @return {object} - List of dimensions and record dimension with:\n * * `name`: String with the name of the dimension\n * * `size`: Number with the size of the dimension\n */\nfunction dimensionsList (buffer: IOBuffer) {\n let dimensions: NetCDFDimension[], recordId, recordName\n const dimList = buffer.readUint32()\n if (dimList === ZERO) {\n notNetcdf((buffer.readUint32() !== ZERO), 'wrong empty tag for list of dimensions')\n return []\n } else {\n notNetcdf((dimList !== NC_DIMENSION), 'wrong tag for list of dimensions')\n\n // Length of dimensions\n const dimensionSize = buffer.readUint32()\n dimensions = new Array(dimensionSize)\n for (let dim = 0; dim < dimensionSize; dim++) {\n // Read name\n const name = readName(buffer)\n\n // Read dimension size\n const size = buffer.readUint32()\n if (size === 0) {\n recordId = dim\n recordName = name\n }\n\n dimensions[dim] = {\n name: name,\n size: size\n }\n }\n return {\n dimensions: dimensions,\n recordId: recordId,\n recordName: recordName\n }\n }\n}\n\n/**\n * List of attributes\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @return {Array} - List of attributes with:\n * * `name`: String with the name of the attribute\n * * `type`: String with the type of the attribute\n * * `value`: A number or string with the value of the attribute\n */\nfunction attributesList (buffer: IOBuffer) {\n let attributes\n const gAttList = buffer.readUint32()\n if (gAttList === ZERO) {\n notNetcdf((buffer.readUint32() !== ZERO), 'wrong empty tag for list of attributes')\n return []\n } else {\n notNetcdf((gAttList !== NC_ATTRIBUTE), 'wrong tag for list of attributes')\n\n // Length of attributes\n const attributeSize = buffer.readUint32()\n attributes = new Array(attributeSize)\n for (let gAtt = 0; gAtt < attributeSize; gAtt++) {\n // Read name\n const name = readName(buffer)\n\n // Read type\n const type = buffer.readUint32()\n notNetcdf(((type < 1) || (type > 6)), 'non valid type ' + type)\n\n // Read attribute\n const size = buffer.readUint32()\n const value = readType(buffer, type, size)\n\n // Apply padding\n padding(buffer)\n\n attributes[gAtt] = {\n name: name,\n type: num2str(type),\n value: value\n }\n }\n }\n return attributes\n}\n\n/**\n * List of variables\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {number} recordId - Id if the record dimension\n * @param {number} version - Version of the file\n * @return {object} - Number of recordStep and list of variables with:\n * * `name`: String with the name of the variable\n * * `dimensions`: Array with the dimension IDs of the variable\n * * `attributes`: Array with the attributes of the variable\n * * `type`: String with the type of the variable\n * * `size`: Number with the size of the variable\n * * `offset`: Number with the offset where of the variable begins\n * * `record`: True if is a record variable, false otherwise\n */\nfunction variablesList (buffer: IOBuffer, recordId: number, version: number) {\n const varList = buffer.readUint32()\n let recordStep = 0\n let variables\n if (varList === ZERO) {\n notNetcdf(\n (buffer.readUint32() !== ZERO),\n 'wrong empty tag for list of variables'\n )\n return []\n } else {\n notNetcdf((varList !== NC_VARIABLE), 'wrong tag for list of variables')\n\n // Length of variables\n const variableSize = buffer.readUint32()\n variables = new Array(variableSize)\n for (let v = 0; v < variableSize; v++) {\n // Read name\n const name = readName(buffer)\n\n // Read dimensionality of the variable\n const dimensionality = buffer.readUint32()\n\n // Index into the list of dimensions\n const dimensionsIds = new Array(dimensionality)\n for (let dim = 0; dim < dimensionality; dim++) {\n dimensionsIds[dim] = buffer.readUint32()\n }\n\n // Read variables size\n const attributes = attributesList(buffer)\n\n // Read type\n const type = buffer.readUint32()\n notNetcdf(((type < 1) && (type > 6)), 'non valid type ' + type)\n\n // Read variable size\n // The 32-bit varSize field is not large enough to contain the\n // size of variables that require more than 2^32 - 4 bytes,\n // so 2^32 - 1 is used in the varSize field for such variables.\n const varSize = buffer.readUint32()\n\n // Read offset\n let offset = buffer.readUint32()\n if (version === 2) {\n notNetcdf((offset > 0), 'offsets larger than 4GB not supported')\n offset = buffer.readUint32()\n }\n\n // Count amount of record variables\n if (dimensionsIds[0] === recordId) {\n recordStep += varSize\n }\n\n variables[v] = {\n name: name,\n dimensions: dimensionsIds,\n attributes: attributes,\n type: num2str(type),\n size: varSize,\n offset: offset,\n record: (dimensionsIds[0] === recordId)\n }\n }\n }\n\n return {\n variables: variables,\n recordStep: recordStep\n }\n}\n\n/**\n * Reads a NetCDF v3.x file\n * https://www.unidata.ucar.edu/software/netcdf/docs/file_format_specifications.html\n */\nclass NetcdfReader {\n header: Partial\n buffer: IOBuffer\n /**\n * @param {ArrayBuffer} data - ArrayBuffer or any Typed Array with the data\n */\n constructor (data: ArrayBuffer) {\n const buffer = new IOBuffer(data)\n buffer.setBigEndian()\n\n // Validate that it's a NetCDF file\n notNetcdf((buffer.readChars(3) !== 'CDF'), 'should start with CDF')\n\n // Check the NetCDF format\n const version = buffer.readByte()\n notNetcdf((version > 2), 'unknown version')\n\n // Read the header\n this.header = header(buffer, version)\n this.buffer = buffer\n }\n\n /**\n * @return {string} - Version for the NetCDF format\n */\n get version () {\n if (this.header.version === 1) {\n return 'classic format'\n } else {\n return '64-bit offset format'\n }\n }\n\n /**\n * @return {object} - Metadata for the record dimension\n * * `length`: Number of elements in the record dimension\n * * `id`: Id number in the list of dimensions for the record dimension\n * * `name`: String with the name of the record dimension\n * * `recordStep`: Number with the record variables step size\n */\n get recordDimension () {\n return this.header.recordDimension\n }\n\n /**\n * @return {Array} - List of dimensions with:\n * * `name`: String with the name of the dimension\n * * `size`: Number with the size of the dimension\n */\n get dimensions () {\n return this.header.dimensions\n }\n\n /**\n * @return {Array} - List of global attributes with:\n * * `name`: String with the name of the attribute\n * * `type`: String with the type of the attribute\n * * `value`: A number or string with the value of the attribute\n */\n get globalAttributes () {\n return this.header.globalAttributes\n }\n\n /**\n * @return {Array} - List of variables with:\n * * `name`: String with the name of the variable\n * * `dimensions`: Array with the dimension IDs of the variable\n * * `attributes`: Array with the attributes of the variable\n * * `type`: String with the type of the variable\n * * `size`: Number with the size of the variable\n * * `offset`: Number with the offset where of the variable begins\n * * `record`: True if is a record variable, false otherwise\n */\n get variables () {\n return this.header.variables\n }\n\n /**\n * Checks if a variable is available\n * @param {string|object} variableName - Name of the variable to check\n * @return {Boolean} - Variable existence\n */\n hasDataVariable (variableName: string) {\n return this.header.variables!.findIndex(function (val) {\n return val.name === variableName\n }) !== -1\n }\n\n /**\n * Retrieves the data for a given variable\n * @param {string|object} variableName - Name of the variable to search or variable object\n * @return {Array} - List with the variable values\n */\n getDataVariable (variableName: string|{}) {\n let variable\n if (typeof variableName === 'string') {\n // search the variable\n variable = this.header.variables!.find(function (val) {\n return val.name === variableName\n })\n } else {\n variable = variableName\n }\n\n // throws if variable not found\n notNetcdf((variable === undefined), 'variable not found')\n\n // go to the offset position\n this.buffer.seek(variable.offset)\n\n if (variable.record) {\n // record variable case\n return record(this.buffer, variable, this.header.recordDimension!)\n } else {\n // non-record variable case\n return nonRecord(this.buffer, variable)\n }\n }\n}\n\nexport default NetcdfReader\n","/**\n * @file Dcd Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { uint8ToString, ensureBuffer } from '../utils'\nimport TrajectoryParser from './trajectory-parser'\n\nconst charmmTimeUnitFactor = 20.45482949774598\n\ninterface DcdHeader {\n NSET: number,\n ISTART: number,\n NSAVC: number,\n NAMNF: number,\n DELTA: number,\n TITLE: string,\n NATOM: number\n}\n\nclass DcdParser extends TrajectoryParser {\n get type () { return 'dcd' }\n get isBinary () { return true }\n\n _parse () {\n // http://www.ks.uiuc.edu/Research/vmd/plugins/molfile/dcdplugin.html\n\n // The DCD format is structured as follows\n // (FORTRAN UNFORMATTED, with Fortran data type descriptions):\n // HDR NSET ISTRT NSAVC 5-ZEROS NATOM-NFREAT DELTA 9-ZEROS\n // `CORD' #files step 1 step zeroes (zero) timestep (zeroes)\n // interval\n // C*4 INT INT INT 5INT INT DOUBLE 9INT\n // ==========================================================================\n // NTITLE TITLE\n // INT (=2) C*MAXTITL\n // (=32)\n // ==========================================================================\n // NATOM\n // #atoms\n // INT\n // ==========================================================================\n // X(I), I=1,NATOM (DOUBLE)\n // Y(I), I=1,NATOM\n // Z(I), I=1,NATOM\n // ==========================================================================\n\n if (Debug) Log.time('DcdParser._parse ' + this.name)\n\n const bin = ensureBuffer(this.streamer.data)\n const dv = new DataView(bin)\n\n const f = this.frames\n const coordinates = f.coordinates\n const boxes = f.boxes\n const header: Partial = {}\n\n let nextPos = 0\n\n // header block\n\n const intView = new Int32Array(bin, 0, 23)\n const ef = intView[ 0 ] !== dv.getInt32(0) // endianess flag\n // swap byte order when big endian (84 indicates little endian)\n if (intView[ 0 ] !== 84) {\n const n = bin.byteLength\n for (let i = 0; i < n; i += 4) {\n dv.setFloat32(i, dv.getFloat32(i), true)\n }\n }\n if (intView[ 0 ] !== 84) {\n Log.error('dcd bad format, header block start')\n }\n // format indicator, should read 'CORD'\n const formatString = String.fromCharCode(\n dv.getUint8(4), dv.getUint8(5),\n dv.getUint8(6), dv.getUint8(7)\n )\n if (formatString !== 'CORD') {\n Log.error('dcd bad format, format string')\n }\n let isCharmm = false\n let extraBlock = false\n let fourDims = false\n // version field in charmm, unused in X-PLOR\n if (intView[ 22 ] !== 0) {\n isCharmm = true\n if (intView[ 12 ] !== 0) extraBlock = true\n if (intView[ 13 ] === 1) fourDims = true\n }\n header.NSET = intView[ 2 ]\n header.ISTART = intView[ 3 ]\n header.NSAVC = intView[ 4 ]\n header.NAMNF = intView[ 10 ]\n if (isCharmm) {\n header.DELTA = dv.getFloat32(44, ef)\n } else {\n header.DELTA = dv.getFloat64(44, ef)\n }\n if (intView[ 22 ] !== 84) {\n Log.error('dcd bad format, header block end')\n }\n nextPos = nextPos + 21 * 4 + 8\n\n // title block\n\n const titleLength = dv.getInt32(nextPos, ef)\n const titlePos = nextPos + 1\n if ((titleLength - 4) % 80 !== 0) {\n Log.error('dcd bad format, title block start')\n }\n header.TITLE = uint8ToString(\n new Uint8Array(bin, titlePos, titleLength)\n )\n if (dv.getInt32(titlePos + titleLength + 4 - 1, ef) !== titleLength) {\n Log.error('dcd bad format, title block end')\n }\n nextPos = nextPos + titleLength + 8\n\n // natom block\n\n if (dv.getInt32(nextPos, ef) !== 4) {\n Log.error('dcd bad format, natom block start')\n }\n header.NATOM = dv.getInt32(nextPos + 4, ef)\n if (dv.getInt32(nextPos + 8, ef) !== 4) {\n Log.error('dcd bad format, natom block end')\n }\n nextPos = nextPos + 4 + 8\n\n // fixed atoms block\n\n if (header.NAMNF > 0) {\n // TODO read coordinates and indices of fixed atoms\n Log.error('dcd format with fixed atoms unsupported, aborting')\n return\n }\n\n // frames\n\n const natom = header.NATOM\n const natom4 = natom * 4\n\n for (let i = 0, n = header.NSET; i < n; ++i) {\n if (extraBlock) {\n nextPos += 4 // block start\n // unitcell: A, alpha, B, beta, gamma, C (doubles)\n const box = new Float32Array(9)\n box[ 0 ] = dv.getFloat64(nextPos, ef)\n box[ 4 ] = dv.getFloat64(nextPos + 2 * 8, ef)\n box[ 8 ] = dv.getFloat64(nextPos + 5 * 8, ef)\n boxes.push(box)\n nextPos += 48\n nextPos += 4 // block end\n }\n\n // xyz coordinates\n const coord = new Float32Array(natom * 3)\n for (let j = 0; j < 3; ++j) {\n if (dv.getInt32(nextPos, ef) !== natom4) {\n Log.error('dcd bad format, coord block start', i, j)\n }\n nextPos += 4 // block start\n const c = new Float32Array(bin, nextPos, natom)\n for (let k = 0; k < natom; ++k) {\n coord[ 3 * k + j ] = c[ k ]\n }\n nextPos += natom4\n if (dv.getInt32(nextPos, ef) !== natom4) {\n Log.error('dcd bad format, coord block end', i, j)\n }\n nextPos += 4 // block end\n }\n coordinates.push(coord)\n\n if (fourDims) {\n const bytes = dv.getInt32(nextPos, ef)\n nextPos += 4 + bytes + 4 // block start + skip + block end\n }\n }\n\n if (header.DELTA) {\n f.deltaTime = header.DELTA * charmmTimeUnitFactor\n }\n if (header.ISTART >= 1) {\n f.timeOffset = (header.ISTART - 1) * f.deltaTime\n }\n\n // console.log(header)\n // console.log(header.TITLE)\n // console.log('isCharmm', isCharmm, 'extraBlock', extraBlock, 'fourDims, fourDims)\n\n if (Debug) Log.timeEnd('DcdParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('dcd', DcdParser)\n\nexport default DcdParser\n","/**\n * @file Nctraj Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport TrajectoryParser from './trajectory-parser'\nimport NetcdfReader from '../utils/netcdf-reader'\n\nclass NctrajParser extends TrajectoryParser {\n get type () { return 'nctraj' }\n get isBinary () { return true }\n\n _parse () {\n // http://ambermd.org/netcdf/nctraj.xhtml\n\n if (Debug) Log.time('NctrajParser._parse ' + this.name)\n\n const netcdfReader = new NetcdfReader(this.streamer.data)\n\n const f = this.frames\n const coordinates = f.coordinates\n const boxes = f.boxes\n const times = f.times\n\n netcdfReader.getDataVariable('coordinates').forEach(function (c) {\n coordinates.push(new Float32Array(c))\n })\n\n if (netcdfReader.hasDataVariable('cell_lengths')) {\n netcdfReader.getDataVariable('cell_lengths').forEach(function (b) {\n boxes.push(new Float32Array(b))\n })\n }\n\n if (netcdfReader.hasDataVariable('time')) {\n netcdfReader.getDataVariable('time').forEach(function (t) {\n times.push(t)\n })\n }\n\n if (times.length >= 1) {\n f.timeOffset = times[0]\n }\n if (times.length >= 2) {\n f.deltaTime = times[1] - times[0]\n }\n\n if (Debug) Log.timeEnd('NctrajParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('nctraj', NctrajParser)\nParserRegistry.add('ncdf', NctrajParser)\nParserRegistry.add('nc', NctrajParser)\n\nexport default NctrajParser\n","/**\n * @file Trr Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { ensureBuffer } from '../utils'\nimport TrajectoryParser from './trajectory-parser'\n\nclass TrrParser extends TrajectoryParser {\n get type () { return 'trr' }\n get isBinary () { return true }\n\n _parse () {\n // https://github.com/gromacs/gromacs/blob/master/src/gromacs/fileio/trrio.cpp\n\n if (Debug) Log.time('TrrParser._parse ' + this.name)\n\n const bin = ensureBuffer(this.streamer.data)\n const dv = new DataView(bin)\n\n const f = this.frames\n const coordinates = f.coordinates\n const boxes = f.boxes\n const times = f.times\n\n let offset = 0\n\n while (true) {\n // const magicnum = dv.getInt32(offset)\n // const i1 = dv.getFloat32(offset + 4)\n offset += 8\n\n const versionSize = dv.getInt32(offset)\n offset += 4\n offset += versionSize\n\n // const irSize = dv.getInt32(offset)\n // const eSize = dv.getInt32(offset + 4)\n const boxSize = dv.getInt32(offset + 8)\n const virSize = dv.getInt32(offset + 12)\n const presSize = dv.getInt32(offset + 16)\n // const topSize = dv.getInt32(offset + 20)\n // const symSize = dv.getInt32(offset + 24)\n const coordSize = dv.getInt32(offset + 28)\n const velocitySize = dv.getInt32(offset + 32)\n const forceSize = dv.getInt32(offset + 36)\n const natoms = dv.getInt32(offset + 40)\n // const step = dv.getInt32(offset + 44)\n // const nre = dv.getInt32(offset + 48)\n offset += 52\n\n const floatSize = boxSize / 9\n const natoms3 = natoms * 3\n\n // let lambda\n if (floatSize === 8) {\n times.push(dv.getFloat64(offset))\n // lambda = dv.getFloat64(offset + 8)\n } else {\n times.push(dv.getFloat32(offset))\n // lambda = dv.getFloat32(offset + 4)\n }\n offset += 2 * floatSize\n\n if (boxSize) {\n const box = new Float32Array(9)\n if (floatSize === 8) {\n for (let i = 0; i < 9; ++i) {\n box[i] = dv.getFloat64(offset) * 10\n offset += 8\n }\n } else {\n for (let i = 0; i < 9; ++i) {\n box[i] = dv.getFloat32(offset) * 10\n offset += 4\n }\n }\n boxes.push(box)\n }\n\n // ignore, unused\n offset += virSize\n\n // ignore, unused\n offset += presSize\n\n if (coordSize) {\n let frameCoords\n if (floatSize === 8) {\n frameCoords = new Float32Array(natoms3)\n for (let i = 0; i < natoms3; ++i) {\n frameCoords[i] = dv.getFloat64(offset) * 10\n offset += 8\n }\n } else {\n const tmp = new Uint32Array(bin, offset, natoms3)\n for (let i = 0; i < natoms3; ++i) {\n const value = tmp[i]\n tmp[i] = (\n ((value & 0xFF) << 24) | ((value & 0xFF00) << 8) |\n ((value >> 8) & 0xFF00) | ((value >> 24) & 0xFF)\n )\n }\n frameCoords = new Float32Array(bin, offset, natoms3)\n for (let i = 0; i < natoms3; ++i) {\n frameCoords[i] *= 10\n offset += 4\n }\n }\n coordinates.push(frameCoords)\n }\n\n // ignore, unused\n offset += velocitySize\n\n // ignore, unused\n offset += forceSize\n\n if (offset >= bin.byteLength) break\n }\n\n if (times.length >= 1) {\n f.timeOffset = times[0]\n }\n if (times.length >= 2) {\n f.deltaTime = times[1] - times[0]\n }\n\n if (Debug) Log.timeEnd('TrrParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('trr', TrrParser)\n\nexport default TrrParser\n","/**\n * @file Xtc Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { ensureBuffer } from '../utils'\nimport TrajectoryParser from './trajectory-parser'\nimport { NumberArray } from '../types';\n\nconst MagicInts = new Uint32Array([\n 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 10, 12, 16, 20, 25, 32, 40, 50, 64,\n 80, 101, 128, 161, 203, 256, 322, 406, 512, 645, 812, 1024, 1290,\n 1625, 2048, 2580, 3250, 4096, 5060, 6501, 8192, 10321, 13003,\n 16384, 20642, 26007, 32768, 41285, 52015, 65536, 82570, 104031,\n 131072, 165140, 208063, 262144, 330280, 416127, 524287, 660561,\n 832255, 1048576, 1321122, 1664510, 2097152, 2642245, 3329021,\n 4194304, 5284491, 6658042, 8388607, 10568983, 13316085, 16777216\n])\nconst FirstIdx = 9\n// const LastIdx = MagicInts.length\n\nfunction sizeOfInt (size: number) {\n let num = 1\n let numOfBits = 0\n while (size >= num && numOfBits < 32) {\n numOfBits++\n num <<= 1\n }\n return numOfBits\n}\n\nconst _tmpBytes = new Uint8Array(32)\n\nfunction sizeOfInts (numOfInts: number, sizes: Int32Array) {\n let numOfBytes = 1\n let numOfBits = 0\n _tmpBytes[0] = 1\n for (let i = 0; i < numOfInts; i++) {\n let bytecnt\n let tmp = 0\n for (bytecnt = 0; bytecnt < numOfBytes; bytecnt++) {\n tmp += _tmpBytes[bytecnt] * sizes[i]\n _tmpBytes[bytecnt] = tmp & 0xff\n tmp >>= 8\n }\n while (tmp !== 0) {\n _tmpBytes[bytecnt++] = tmp & 0xff\n tmp >>= 8\n }\n numOfBytes = bytecnt\n }\n let num = 1\n numOfBytes--\n while (_tmpBytes[numOfBytes] >= num) {\n numOfBits++\n num *= 2\n }\n return numOfBits + numOfBytes * 8\n}\n\nfunction decodeBits (buf: Int32Array, cbuf: Uint8Array, numOfBits: number, buf2: Uint32Array) {\n const mask = (1 << numOfBits) - 1\n let lastBB0 = buf2[1]\n let lastBB1 = buf2[2]\n let cnt = buf[0]\n let num = 0\n\n while (numOfBits >= 8) {\n lastBB1 = (lastBB1 << 8) | cbuf[cnt++]\n num |= (lastBB1 >> lastBB0) << (numOfBits - 8)\n numOfBits -= 8\n }\n\n if (numOfBits > 0) {\n if (lastBB0 < numOfBits) {\n lastBB0 += 8\n lastBB1 = (lastBB1 << 8) | cbuf[cnt++]\n }\n lastBB0 -= numOfBits\n num |= (lastBB1 >> lastBB0) & ((1 << numOfBits) - 1)\n }\n\n num &= mask\n buf[0] = cnt\n buf[1] = lastBB0\n buf[2] = lastBB1\n\n return num\n}\n\nconst _tmpIntBytes = new Int32Array(32)\n\nfunction decodeInts (buf: Int32Array, cbuf: Uint8Array, numOfInts: number, numOfBits: number, sizes: NumberArray, nums: Float32Array, buf2: Uint32Array) {\n let numOfBytes = 0\n _tmpIntBytes[1] = 0\n _tmpIntBytes[2] = 0\n _tmpIntBytes[3] = 0\n\n while (numOfBits > 8) {\n // this is inversed??? why??? because of the endiannness???\n _tmpIntBytes[numOfBytes++] = decodeBits(buf, cbuf, 8, buf2)\n numOfBits -= 8\n }\n\n if (numOfBits > 0) {\n _tmpIntBytes[numOfBytes++] = decodeBits(buf, cbuf, numOfBits, buf2)\n }\n\n for (let i = numOfInts - 1; i > 0; i--) {\n let num = 0\n for (let j = numOfBytes - 1; j >= 0; j--) {\n num = (num << 8) | _tmpIntBytes[j]\n const p = (num / sizes[i]) | 0\n _tmpIntBytes[j] = p\n num = num - p * sizes[i]\n }\n nums[i] = num\n }\n nums[0] = (\n _tmpIntBytes[0] |\n (_tmpIntBytes[1] << 8) |\n (_tmpIntBytes[2] << 16) |\n (_tmpIntBytes[3] << 24)\n )\n}\n\nclass XtcParser extends TrajectoryParser {\n get type () { return 'xtc' }\n get isBinary () { return true }\n\n _parse () {\n // https://github.com/gromacs/gromacs/blob/master/src/gromacs/fileio/xtcio.cpp\n // https://github.com/gromacs/gromacs/blob/master/src/gromacs/fileio/libxdrf.cpp\n\n if (Debug) Log.time('XtcParser._parse ' + this.name)\n\n const bin = ensureBuffer(this.streamer.data)\n const dv = new DataView(bin)\n\n const f = this.frames\n const coordinates = f.coordinates\n const boxes = f.boxes\n const times = f.times\n\n const minMaxInt = new Int32Array(6)\n const sizeint = new Int32Array(3)\n const bitsizeint = new Int32Array(3)\n const sizesmall = new Uint32Array(3)\n const thiscoord = new Float32Array(3)\n const prevcoord = new Float32Array(3)\n\n let offset = 0\n const buf = new Int32Array(3)\n const buf2 = new Uint32Array(buf.buffer)\n\n while (true) {\n let frameCoords: NumberArray\n\n // const magicnum = dv.getInt32(offset)\n const natoms = dv.getInt32(offset + 4)\n // const step = dv.getInt32(offset + 8)\n offset += 12\n\n const natoms3 = natoms * 3\n\n times.push(dv.getFloat32(offset))\n offset += 4\n\n const box = new Float32Array(9)\n for (let i = 0; i < 9; ++i) {\n box[i] = dv.getFloat32(offset) * 10\n offset += 4\n }\n boxes.push(box)\n\n if (natoms <= 9) { // no compression\n frameCoords = new Float32Array(natoms)\n for (let i = 0; i < natoms; ++i) {\n frameCoords[i] = dv.getFloat32(offset)\n offset += 4\n }\n } else {\n buf[0] = buf[1] = buf[2] = 0.0\n sizeint[0] = sizeint[1] = sizeint[2] = 0\n sizesmall[0] = sizesmall[1] = sizesmall[2] = 0\n bitsizeint[0] = bitsizeint[1] = bitsizeint[2] = 0\n thiscoord[0] = thiscoord[1] = thiscoord[2] = 0\n prevcoord[0] = prevcoord[1] = prevcoord[2] = 0\n\n frameCoords = new Float32Array(natoms3)\n let lfp = 0\n\n const lsize = dv.getInt32(offset)\n offset += 4\n const precision = dv.getFloat32(offset)\n offset += 4\n\n minMaxInt[0] = dv.getInt32(offset)\n minMaxInt[1] = dv.getInt32(offset + 4)\n minMaxInt[2] = dv.getInt32(offset + 8)\n minMaxInt[3] = dv.getInt32(offset + 12)\n minMaxInt[4] = dv.getInt32(offset + 16)\n minMaxInt[5] = dv.getInt32(offset + 20)\n sizeint[0] = minMaxInt[3] - minMaxInt[0] + 1\n sizeint[1] = minMaxInt[4] - minMaxInt[1] + 1\n sizeint[2] = minMaxInt[5] - minMaxInt[2] + 1\n offset += 24\n\n let bitsize\n if ((sizeint[0] | sizeint[1] | sizeint[2]) > 0xffffff) {\n bitsizeint[0] = sizeOfInt(sizeint[0])\n bitsizeint[1] = sizeOfInt(sizeint[1])\n bitsizeint[2] = sizeOfInt(sizeint[2])\n bitsize = 0 // flag the use of large sizes\n } else {\n bitsize = sizeOfInts(3, sizeint)\n }\n\n let smallidx = dv.getInt32(offset)\n offset += 4\n // if (smallidx == 0) {alert(\"Undocumented error 1\"); return;}\n\n // let tmpIdx = smallidx + 8\n // const maxidx = (LastIdx < tmpIdx) ? LastIdx : tmpIdx\n // const minidx = maxidx - 8 // often this equal smallidx\n let tmpIdx = smallidx - 1\n tmpIdx = (FirstIdx > tmpIdx) ? FirstIdx : tmpIdx\n let smaller = (MagicInts[tmpIdx] / 2) | 0\n let smallnum = (MagicInts[smallidx] / 2) | 0\n\n sizesmall[0] = sizesmall[1] = sizesmall[2] = MagicInts[smallidx]\n // larger = MagicInts[maxidx]\n\n let adz = Math.ceil(dv.getInt32(offset) / 4) * 4\n offset += 4\n // if (tmpIdx == 0) {alert(\"Undocumented error 2\"); return;}\n\n // buf = new Int32Array(bin, offset);\n // buf8 = new Uint8Array(bin, offset);\n\n // tmpIdx += 3; rndup = tmpIdx%4;\n // for (i=tmpIdx+rndup-1; i>=tmpIdx; i--) buf8[i] = 0;\n\n // now unpack buf2...\n\n const invPrecision = 1.0 / precision\n let run = 0\n let i = 0\n\n const buf8 = new Uint8Array(bin, offset) // 229...\n\n thiscoord[0] = thiscoord[1] = thiscoord[2] = 0\n\n while (i < lsize) {\n if (bitsize === 0) {\n thiscoord[0] = decodeBits(buf, buf8, bitsizeint[0], buf2)\n thiscoord[1] = decodeBits(buf, buf8, bitsizeint[1], buf2)\n thiscoord[2] = decodeBits(buf, buf8, bitsizeint[2], buf2)\n } else {\n decodeInts(buf, buf8, 3, bitsize, sizeint, thiscoord, buf2)\n }\n\n i++\n\n thiscoord[0] += minMaxInt[0]\n thiscoord[1] += minMaxInt[1]\n thiscoord[2] += minMaxInt[2]\n\n prevcoord[0] = thiscoord[0]\n prevcoord[1] = thiscoord[1]\n prevcoord[2] = thiscoord[2]\n\n const flag = decodeBits(buf, buf8, 1, buf2)\n let isSmaller = 0\n\n if (flag === 1) {\n run = decodeBits(buf, buf8, 5, buf2)\n isSmaller = run % 3\n run -= isSmaller\n isSmaller--\n }\n\n // if ((lfp-ptrstart)+run > size3){\n // fprintf(stderr, \"(xdrfile error) Buffer overrun during decompression.\\n\");\n // return 0;\n // }\n\n if (run > 0) {\n thiscoord[0] = thiscoord[1] = thiscoord[2] = 0\n\n for (let k = 0; k < run; k += 3) {\n decodeInts(buf, buf8, 3, smallidx, sizesmall, thiscoord, buf2)\n i++\n\n thiscoord[0] += prevcoord[0] - smallnum\n thiscoord[1] += prevcoord[1] - smallnum\n thiscoord[2] += prevcoord[2] - smallnum\n\n if (k === 0) {\n // interchange first with second atom for\n // better compression of water molecules\n let tmpSwap = thiscoord[0]\n thiscoord[0] = prevcoord[0]\n prevcoord[0] = tmpSwap\n\n tmpSwap = thiscoord[1]\n thiscoord[1] = prevcoord[1]\n prevcoord[1] = tmpSwap\n\n tmpSwap = thiscoord[2]\n thiscoord[2] = prevcoord[2]\n prevcoord[2] = tmpSwap\n\n frameCoords[lfp++] = prevcoord[0] * invPrecision\n frameCoords[lfp++] = prevcoord[1] * invPrecision\n frameCoords[lfp++] = prevcoord[2] * invPrecision\n } else {\n prevcoord[0] = thiscoord[0]\n prevcoord[1] = thiscoord[1]\n prevcoord[2] = thiscoord[2]\n }\n frameCoords[lfp++] = thiscoord[0] * invPrecision\n frameCoords[lfp++] = thiscoord[1] * invPrecision\n frameCoords[lfp++] = thiscoord[2] * invPrecision\n }\n } else {\n frameCoords[lfp++] = thiscoord[0] * invPrecision\n frameCoords[lfp++] = thiscoord[1] * invPrecision\n frameCoords[lfp++] = thiscoord[2] * invPrecision\n }\n\n smallidx += isSmaller\n\n if (isSmaller < 0) {\n smallnum = smaller\n if (smallidx > FirstIdx) {\n smaller = (MagicInts[smallidx - 1] / 2) | 0\n } else {\n smaller = 0\n }\n } else if (isSmaller > 0) {\n smaller = smallnum\n smallnum = (MagicInts[smallidx] / 2) | 0\n }\n sizesmall[0] = sizesmall[1] = sizesmall[2] = MagicInts[smallidx]\n\n if (sizesmall[0] === 0 || sizesmall[1] === 0 || sizesmall[2] === 0) {\n console.error('(xdrfile error) Undefined error.')\n return\n }\n }\n offset += adz\n }\n\n for (let c = 0; c < natoms3; c++) {\n frameCoords[c] *= 10\n }\n\n coordinates.push(frameCoords)\n\n if (offset >= bin.byteLength) break\n }\n\n if (times.length >= 1) {\n f.timeOffset = times[0]\n }\n if (times.length >= 2) {\n f.deltaTime = times[1] - times[0]\n }\n\n if (Debug) Log.timeEnd('XtcParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('xtc', XtcParser)\n\nexport default XtcParser\n","/**\n * @file Volume Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { defaults } from '../utils'\nimport Parser, { ParserParameters } from './parser'\nimport Volume from '../surface/volume'\nimport Streamer from '../streamer/streamer';\n\nexport interface VolumeParserParameters extends ParserParameters {\n voxelSize: number\n}\n\nclass VolumeParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.volume = new Volume(this.name, this.path)\n this.voxelSize = defaults(p.voxelSize, 1)\n }\n\n get type () { return 'volume' }\n get __objName () { return 'volume' }\n\n _afterParse () {\n this.volume.setMatrix(this.getMatrix())\n super._afterParse()\n }\n\n getMatrix () {\n return new Matrix4()\n }\n}\n\nexport default VolumeParser\n","/**\n * @file Cube Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport VolumeParser from './volume-parser'\n\n// @author Johanna Tiemann \n// @author Alexander Rose \n\nconst reWhitespace = /\\s+/\nconst reScientificNotation = /-?\\d+(?:\\.\\d*)?(?:[eE][+-]?\\d+)?/g\nconst bohrToAngstromFactor = 0.529177210859\ninterface Header {\n atomCount: number,\n originX: number,\n originY: number,\n originZ: number,\n NVX: number,\n NVY: number,\n NVZ: number,\n basisX: Vector3,\n basisY: Vector3,\n basisZ: Vector3\n}\n\nclass CubeParser extends VolumeParser {\n get type () { return 'cube' }\n\n _parse () {\n // http://paulbourke.net/dataformats/cube/\n\n if (Debug) Log.time('CubeParser._parse ' + this.name)\n\n const v = this.volume\n const headerLines = this.streamer.peekLines(6)\n const header: Partial
= {}\n\n const scaleFactor = bohrToAngstromFactor * this.voxelSize\n\n function h (k: number, l: number) {\n var field = headerLines[ k ].trim().split(reWhitespace)[ l ]\n return parseFloat(field)\n }\n\n header.atomCount = Math.abs(h(2, 0)) // Number of atoms\n header.originX = h(2, 1) * bohrToAngstromFactor // Position of origin of volumetric data\n header.originY = h(2, 2) * bohrToAngstromFactor\n header.originZ = h(2, 3) * bohrToAngstromFactor\n header.NVX = h(3, 0) // Number of voxels\n header.NVY = h(4, 0)\n header.NVZ = h(5, 0)\n\n header.basisX = new Vector3(h(3, 1), h(3, 2), h(3, 3))\n .multiplyScalar(scaleFactor)\n header.basisY = new Vector3(h(4, 1), h(4, 2), h(4, 3))\n .multiplyScalar(scaleFactor)\n header.basisZ = new Vector3(h(5, 1), h(5, 2), h(5, 3))\n .multiplyScalar(scaleFactor)\n\n const data = new Float32Array(header.NVX * header.NVY * header.NVZ)\n let count = 0\n let lineNo = 0\n const oribitalFlag = h(2, 0) > 0 ? 0 : 1\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ].trim()\n\n if (line !== '' && lineNo >= header.atomCount! + 6 + oribitalFlag) {\n const m = line.match(reScientificNotation) as RegExpMatchArray\n for (let j = 0, lj = m.length; j < lj; ++j) {\n data[ count ] = parseFloat(m[ j ])\n ++count\n }\n }\n\n ++lineNo\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n v.header = header\n v.setData(data, header.NVZ, header.NVY, header.NVX)\n\n if (Debug) Log.timeEnd('CubeParser._parse ' + this.name)\n }\n\n getMatrix () {\n const h = this.volume.header\n const matrix = new Matrix4()\n\n matrix.multiply(\n new Matrix4().makeTranslation(\n h.originX, h.originY, h.originZ\n )\n )\n\n matrix.multiply(\n new Matrix4().makeBasis(\n h.basisZ, h.basisY, h.basisX\n )\n )\n\n return matrix\n }\n}\n\nParserRegistry.add('cub', CubeParser)\nParserRegistry.add('cube', CubeParser)\n\nexport default CubeParser\n","/**\n * @file Dsn6 Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { ensureBuffer } from '../utils'\nimport { degToRad } from '../math/math-utils'\nimport VolumeParser from './volume-parser'\n\ninterface Dsn6Header {\n xStart: number,\n yStart: number,\n zStart: number,\n xExtent: number,\n yExtent: number,\n zExtent: number,\n xRate: number,\n yRate: number,\n zRate: number,\n xlen: number,\n ylen: number,\n zlen: number,\n alpha: number,\n beta: number,\n gamma: number,\n sigma: number\n}\n\nclass Dsn6Parser extends VolumeParser {\n get type () { return 'dsn6' }\n get isBinary () { return true }\n\n _parse () {\n // DSN6 http://www.uoxray.uoregon.edu/tnt/manual/node104.html\n // BRIX http://svn.cgl.ucsf.edu/svn/chimera/trunk/libs/VolumeData/dsn6/brix-1.html\n\n if (Debug) Log.time('Dsn6Parser._parse ' + this.name)\n\n const v = this.volume\n const header: Partial = {}\n let divisor, summand\n\n const bin = ensureBuffer(this.streamer.data)\n const intView = new Int16Array(bin)\n const byteView = new Uint8Array(bin)\n const brixStr = String.fromCharCode.apply(null, byteView.subarray(0, 512))\n\n if (brixStr.startsWith(':-)')) {\n header.xStart = parseInt(brixStr.substr(10, 5)) // NXSTART\n header.yStart = parseInt(brixStr.substr(15, 5))\n header.zStart = parseInt(brixStr.substr(20, 5))\n\n header.xExtent = parseInt(brixStr.substr(32, 5)) // NX\n header.yExtent = parseInt(brixStr.substr(38, 5))\n header.zExtent = parseInt(brixStr.substr(42, 5))\n\n header.xRate = parseInt(brixStr.substr(52, 5)) // MX\n header.yRate = parseInt(brixStr.substr(58, 5))\n header.zRate = parseInt(brixStr.substr(62, 5))\n\n header.xlen = parseFloat(brixStr.substr(73, 10)) * this.voxelSize\n header.ylen = parseFloat(brixStr.substr(83, 10)) * this.voxelSize\n header.zlen = parseFloat(brixStr.substr(93, 10)) * this.voxelSize\n\n header.alpha = parseFloat(brixStr.substr(103, 10))\n header.beta = parseFloat(brixStr.substr(113, 10))\n header.gamma = parseFloat(brixStr.substr(123, 10))\n\n divisor = parseFloat(brixStr.substr(138, 12)) / 100\n summand = parseInt(brixStr.substr(155, 8))\n\n header.sigma = parseFloat(brixStr.substr(170, 12)) * 100\n } else {\n // swap byte order when big endian\n if (intView[ 18 ] !== 100) {\n for (let i = 0, n = intView.length; i < n; ++i) {\n const val = intView[ i ]\n intView[ i ] = ((val & 0xff) << 8) | ((val >> 8) & 0xff)\n }\n }\n\n header.xStart = intView[ 0 ] // NXSTART\n header.yStart = intView[ 1 ]\n header.zStart = intView[ 2 ]\n\n header.xExtent = intView[ 3 ] // NX\n header.yExtent = intView[ 4 ]\n header.zExtent = intView[ 5 ]\n\n header.xRate = intView[ 6 ] // MX\n header.yRate = intView[ 7 ]\n header.zRate = intView[ 8 ]\n\n const factor = 1 / intView[ 17 ]\n const scalingFactor = factor * this.voxelSize\n\n header.xlen = intView[ 9 ] * scalingFactor\n header.ylen = intView[ 10 ] * scalingFactor\n header.zlen = intView[ 11 ] * scalingFactor\n\n header.alpha = intView[ 12 ] * factor\n header.beta = intView[ 13 ] * factor\n header.gamma = intView[ 14 ] * factor\n\n divisor = intView[ 15 ] / 100\n summand = intView[ 16 ]\n header.gamma = intView[ 14 ] * factor\n }\n\n v.header = header\n\n if (Debug) Log.log(header, divisor, summand)\n\n const data = new Float32Array(\n header.xExtent * header.yExtent * header.zExtent\n )\n\n let offset = 512\n const xBlocks = Math.ceil(header.xExtent / 8)\n const yBlocks = Math.ceil(header.yExtent / 8)\n const zBlocks = Math.ceil(header.zExtent / 8)\n\n // loop over blocks\n for (var zz = 0; zz < zBlocks; ++zz) {\n for (var yy = 0; yy < yBlocks; ++yy) {\n for (var xx = 0; xx < xBlocks; ++xx) {\n // loop inside block\n for (var k = 0; k < 8; ++k) {\n var z = 8 * zz + k\n for (var j = 0; j < 8; ++j) {\n var y = 8 * yy + j\n for (var i = 0; i < 8; ++i) {\n var x = 8 * xx + i\n\n // check if remaining slice-part contains data\n if (x < header.xExtent && y < header.yExtent && z < header.zExtent) {\n var idx = ((((x * header.yExtent) + y) * header.zExtent) + z)\n data[ idx ] = (byteView[ offset ] - summand) / divisor\n ++offset\n } else {\n offset += 8 - i\n break\n }\n }\n }\n }\n }\n }\n }\n\n v.setData(data, header.zExtent, header.yExtent, header.xExtent)\n if (header.sigma) {\n v.setStats(undefined, undefined, undefined, header.sigma)\n }\n\n if (Debug) Log.timeEnd('Dsn6Parser._parse ' + this.name)\n }\n\n getMatrix () {\n const h: Dsn6Header = this.volume.header\n\n const basisX = [\n h.xlen as number,\n 0,\n 0\n ]\n\n const basisY = [\n h.ylen * Math.cos(Math.PI / 180.0 * h.gamma),\n h.ylen * Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n\n const basisZ = [\n h.zlen * Math.cos(Math.PI / 180.0 * h.beta),\n h.zlen * (\n Math.cos(Math.PI / 180.0 * h.alpha) -\n Math.cos(Math.PI / 180.0 * h.gamma) *\n Math.cos(Math.PI / 180.0 * h.beta)\n ) / Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n basisZ[ 2 ] = Math.sqrt(\n h.zlen * h.zlen * Math.sin(Math.PI / 180.0 * h.beta) *\n Math.sin(Math.PI / 180.0 * h.beta) - basisZ[ 1 ] * basisZ[ 1 ]\n )\n\n const basis = [ [], basisX, basisY, basisZ ]\n const nxyz = [ 0, h.xRate, h.yRate, h.zRate ]\n const mapcrs = [ 0, 1, 2, 3 ]\n\n const matrix = new Matrix4()\n\n matrix.set(\n basis[ mapcrs[1] ][0] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][0] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][0] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][1] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][1] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][1] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][2] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][2] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][2] / nxyz[ mapcrs[3] ],\n 0,\n 0, 0, 0, 1\n )\n\n matrix.multiply(\n new Matrix4().makeRotationY(degToRad(90))\n )\n\n matrix.multiply(new Matrix4().makeTranslation(\n -h.zStart, h.yStart, h.xStart\n ))\n\n matrix.multiply(new Matrix4().makeScale(\n -1, 1, 1\n ))\n\n return matrix\n }\n}\n\nParserRegistry.add('dsn6', Dsn6Parser)\nParserRegistry.add('brix', Dsn6Parser)\n\nexport default Dsn6Parser\n","/**\n * @file Dx Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { degToRad } from '../math/math-utils'\nimport VolumeParser from './volume-parser'\n\nconst reWhitespace = /\\s+/\n\ninterface DxHeader {\n nx: number,\n ny: number,\n nz: number,\n xmin: number,\n ymin: number,\n zmin: number,\n hx: number,\n hy: number,\n hz: number\n}\n\nclass DxParser extends VolumeParser {\n get type () { return 'dx' }\n\n _parse () {\n // http://apbs.readthedocs.io/en/latest/formats/opendx.html\n\n if (Debug) Log.time('DxParser._parse ' + this.name)\n\n const v = this.volume\n const headerLines = this.streamer.peekLines(30)\n const headerInfo = this.parseHeaderLines(headerLines)\n const header = this.volume.header\n const dataLineStart = headerInfo.dataLineStart\n\n const size = header.nx * header.ny * header.nz\n const data = new Float32Array(size)\n let count = 0\n let lineNo = 0\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string []) {\n for (let i = _i; i < _n; ++i) {\n if (count < size && lineNo > dataLineStart) {\n const line = lines[ i ].trim()\n\n if (line !== '') {\n const ls = line.split(reWhitespace)\n\n for (let j = 0, lj = ls.length; j < lj; ++j) {\n data[ count ] = parseFloat(ls[ j ])\n ++count\n }\n }\n }\n\n ++lineNo\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n v.setData(data, header.nz, header.ny, header.nx)\n\n if (Debug) Log.timeEnd('DxParser._parse ' + this.name)\n }\n\n parseHeaderLines (headerLines: string []) {\n const header: Partial = {}\n const n = headerLines.length\n\n let dataLineStart = 0\n let headerByteCount = 0\n let deltaLineCount = 0\n\n for (let i = 0; i < n; ++i) {\n let ls\n const line = headerLines[ i ]\n\n if (line.startsWith('object 1')) {\n ls = line.split(reWhitespace)\n\n header.nx = parseInt(ls[ 5 ])\n header.ny = parseInt(ls[ 6 ])\n header.nz = parseInt(ls[ 7 ])\n } else if (line.startsWith('origin')) {\n ls = line.split(reWhitespace)\n\n header.xmin = parseFloat(ls[ 1 ])\n header.ymin = parseFloat(ls[ 2 ])\n header.zmin = parseFloat(ls[ 3 ])\n } else if (line.startsWith('delta')) {\n ls = line.split(reWhitespace)\n\n if (deltaLineCount === 0) {\n header.hx = parseFloat(ls[ 1 ]) * this.voxelSize\n } else if (deltaLineCount === 1) {\n header.hy = parseFloat(ls[ 2 ]) * this.voxelSize\n } else if (deltaLineCount === 2) {\n header.hz = parseFloat(ls[ 3 ]) * this.voxelSize\n }\n\n deltaLineCount += 1\n } else if (line.startsWith('object 3')) {\n dataLineStart = i\n headerByteCount += line.length + 1\n break\n }\n\n headerByteCount += line.length + 1\n }\n\n this.volume.header = header\n\n return {\n dataLineStart: dataLineStart,\n headerByteCount: headerByteCount\n }\n }\n\n getMatrix () {\n const h = this.volume.header\n const matrix = new Matrix4()\n\n matrix.multiply(\n new Matrix4().makeRotationY(degToRad(90))\n )\n\n matrix.multiply(\n new Matrix4().makeTranslation(\n -h.zmin, h.ymin, h.xmin\n )\n )\n\n matrix.multiply(\n new Matrix4().makeScale(\n -h.hz, h.hy, h.hx\n )\n )\n\n return matrix\n }\n}\n\nParserRegistry.add('dx', DxParser)\n\nexport default DxParser\n","/**\n * @file Dxbin Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { uint8ToLines, ensureBuffer } from '../utils'\nimport DxParser from './dx-parser'\n\nclass DxbinParser extends DxParser {\n get type () { return 'dxbin' }\n get isBinary () { return true }\n\n _parse () {\n // https://github.com/Electrostatics/apbs-pdb2pqr/issues/216\n\n if (Debug) Log.time('DxbinParser._parse ' + this.name)\n\n const bin = ensureBuffer(this.streamer.data)\n const headerLines = uint8ToLines(new Uint8Array(bin, 0, 1000))\n const headerInfo = this.parseHeaderLines(headerLines)\n const header = this.volume.header\n const headerByteCount = headerInfo.headerByteCount\n\n const size = header.nx * header.ny * header.nz\n const dv = new DataView(bin)\n const data = new Float32Array(size)\n\n for (let i = 0; i < size; ++i) {\n data[ i ] = dv.getFloat64(i * 8 + headerByteCount, true)\n }\n\n this.volume.setData(data, header.nz, header.ny, header.nx)\n\n if (Debug) Log.timeEnd('DxbinParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('dxbin', DxbinParser)\n\nexport default DxbinParser\n","/**\n * @file Mrc Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { ensureBuffer } from '../utils'\nimport VolumeParser from './volume-parser'\n\ninterface MrcHeader {\n MAP: string,\n MACHST: number [],\n NX: number,\n NY: number,\n NZ: number,\n MODE: number,\n NXSTART: number,\n NYSTART: number,\n NZSTART: number,\n MX: number,\n MY: number,\n MZ: number,\n xlen: number,\n ylen: number,\n zlen: number,\n alpha: number,\n beta: number,\n gamma: number,\n MAPC: number,\n MAPR: number,\n MAPS: number,\n DMIN: number,\n DMAX: number,\n DMEAN: number,\n ISPG: number,\n NSYMBT: number,\n LSKFLG: number,\n originX: number,\n originY: number,\n originZ: number,\n ARMS: number\n}\n\nclass MrcParser extends VolumeParser {\n get type () { return 'mrc' }\n get isBinary () { return true }\n\n _parse () {\n // MRC\n // http://ami.scripps.edu/software/mrctools/mrc_specification.php\n // http://www2.mrc-lmb.cam.ac.uk/research/locally-developed-software/image-processing-software/#image\n // http://bio3d.colorado.edu/imod/doc/mrc_format.txt\n\n // CCP4 (MAP)\n // http://www.ccp4.ac.uk/html/maplib.html\n\n // MRC format does not use the skew transformation header records (words 25-37)\n // CCP4 format does not use the ORIGIN header records (words 50-52)\n\n if (Debug) Log.time('MrcParser._parse ' + this.name)\n\n const v = this.volume\n const header: Partial = {}\n\n const bin = ensureBuffer(this.streamer.data)\n const intView = new Int32Array(bin, 0, 56)\n const floatView = new Float32Array(bin, 0, 56)\n const dv = new DataView(bin)\n\n // 53 MAP Character string 'MAP ' to identify file type\n header.MAP = String.fromCharCode(\n dv.getUint8(52 * 4), dv.getUint8(52 * 4 + 1),\n dv.getUint8(52 * 4 + 2), dv.getUint8(52 * 4 + 3)\n )\n\n // 54 MACHST Machine stamp indicating machine type which wrote file\n // 17 and 17 for big-endian or 68 and 65 for little-endian\n header.MACHST = [ dv.getUint8(53 * 4), dv.getUint8(53 * 4 + 1) ]\n\n // swap byte order when big endian\n if (header.MACHST[ 0 ] === 17 && header.MACHST[ 1 ] === 17) {\n const n = bin.byteLength\n for (let i = 0; i < n; i += 4) {\n dv.setFloat32(i, dv.getFloat32(i), true)\n }\n }\n\n header.NX = intView[ 0 ] // NC - columns (fastest changing)\n header.NY = intView[ 1 ] // NR - rows\n header.NZ = intView[ 2 ] // NS - sections (slowest changing)\n\n // mode\n // 0 image : signed 8-bit bytes range -128 to 127\n // 1 image : 16-bit halfwords\n // 2 image : 32-bit reals\n // 3 transform : complex 16-bit integers\n // 4 transform : complex 32-bit reals\n // 6 image : unsigned 16-bit range 0 to 65535\n // 16 image: unsigned char * 3 (for rgb data, non-standard)\n //\n // Note: Mode 2 is the normal mode used in the CCP4 programs.\n // Other modes than 2 and 0 may NOT WORK\n header.MODE = intView[ 3 ]\n\n // start\n header.NXSTART = intView[ 4 ] // NCSTART - first column\n header.NYSTART = intView[ 5 ] // NRSTART - first row\n header.NZSTART = intView[ 6 ] // NSSTART - first section\n\n // intervals\n header.MX = intView[ 7 ] // intervals along x\n header.MY = intView[ 8 ] // intervals along y\n header.MZ = intView[ 9 ] // intervals along z\n\n // cell length (Angstroms in CCP4)\n header.xlen = floatView[ 10 ] * this.voxelSize\n header.ylen = floatView[ 11 ] * this.voxelSize\n header.zlen = floatView[ 12 ] * this.voxelSize\n\n // cell angle (Degrees)\n header.alpha = floatView[ 13 ]\n header.beta = floatView[ 14 ]\n header.gamma = floatView[ 15 ]\n\n // axis correspondence (1,2,3 for X,Y,Z)\n header.MAPC = intView[ 16 ] // column\n header.MAPR = intView[ 17 ] // row\n header.MAPS = intView[ 18 ] // section\n\n // density statistics\n header.DMIN = floatView[ 19 ]\n header.DMAX = floatView[ 20 ]\n header.DMEAN = floatView[ 21 ]\n\n // space group number 0 or 1 (default=0)\n header.ISPG = intView[ 22 ]\n\n // number of bytes used for symmetry data (0 or 80)\n header.NSYMBT = intView[ 23 ]\n\n // Flag for skew transformation, =0 none, =1 if foll\n header.LSKFLG = intView[ 24 ]\n\n // 26-34 SKWMAT Skew matrix S (in order S11, S12, S13, S21 etc) if\n // LSKFLG .ne. 0.\n // 35-37 SKWTRN Skew translation t if LSKFLG != 0.\n // Skew transformation is from standard orthogonal\n // coordinate frame (as used for atoms) to orthogonal\n // map frame, as Xo(map) = S * (Xo(atoms) - t)\n\n // 38 future use (some of these are used by the MSUBSX routines\n // . \" in MAPBRICK, MAPCONT and FRODO)\n // . \" (all set to zero by default)\n // . \"\n // 52 \"\n\n // 50-52 origin in X,Y,Z used for transforms\n header.originX = floatView[ 49 ]\n header.originY = floatView[ 50 ]\n header.originZ = floatView[ 51 ]\n\n // 53 MAP Character string 'MAP ' to identify file type\n // => see top of this parser\n\n // 54 MACHST Machine stamp indicating machine type which wrote file\n // => see top of this parser\n\n // Rms deviation of map from mean density\n header.ARMS = floatView[ 54 ]\n\n // 56 NLABL Number of labels being used\n // 57-256 LABEL(20,10) 10 80 character text labels (ie. A4 format)\n\n v.header = header\n\n // Log.log( header );\n\n let data\n if (header.MODE === 2) {\n data = new Float32Array(\n bin, 256 * 4 + header.NSYMBT,\n header.NX * header.NY * header.NZ\n )\n } else if (header.MODE === 0) {\n data = new Float32Array(new Int8Array(\n bin, 256 * 4 + header.NSYMBT,\n header.NX * header.NY * header.NZ\n ))\n\n // based on uglymol (https://github.com/uglymol/uglymol) by Marcin Wojdyr (wojdyr)\n // if the file was converted by mapmode2to0 - scale the data\n if (intView[ 39 ] === -128 && intView[ 40 ] === 127) {\n // scaling f(x)=b1*x+b0 such that f(-128)=min and f(127)=max\n const b1 = (header.DMAX - header.DMIN) / 255.0\n const b0 = 0.5 * (header.DMIN + header.DMAX + b1)\n for (let j = 0, jl = data.length; j < jl; ++j) {\n data[ j ] = b1 * data[ j ] + b0\n }\n }\n } else {\n Log.error('MrcParser unknown mode', header.MODE)\n }\n\n v.setData(data, header.NX, header.NY, header.NZ)\n if (header.ARMS !== 0) {\n v.setStats(header.DMIN, header.DMAX, header.DMEAN, header.ARMS)\n }\n\n if (Debug) Log.timeEnd('MrcParser._parse ' + this.name)\n }\n\n getMatrix () {\n const h = this.volume.header\n\n const basisX = [\n h.xlen,\n 0,\n 0\n ]\n\n const basisY = [\n h.ylen * Math.cos(Math.PI / 180.0 * h.gamma),\n h.ylen * Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n\n const basisZ = [\n h.zlen * Math.cos(Math.PI / 180.0 * h.beta),\n h.zlen * (\n Math.cos(Math.PI / 180.0 * h.alpha) -\n Math.cos(Math.PI / 180.0 * h.gamma) *\n Math.cos(Math.PI / 180.0 * h.beta)\n ) / Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n basisZ[ 2 ] = Math.sqrt(\n h.zlen * h.zlen * Math.sin(Math.PI / 180.0 * h.beta) *\n Math.sin(Math.PI / 180.0 * h.beta) - basisZ[ 1 ] * basisZ[ 1 ]\n )\n\n const basis = [ [], basisX, basisY, basisZ ]\n const nxyz = [ 0, h.MX, h.MY, h.MZ ]\n const mapcrs = [ 0, h.MAPC, h.MAPR, h.MAPS ]\n\n const matrix = new Matrix4()\n\n matrix.set(\n basis[ mapcrs[1] ][0] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][0] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][0] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][1] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][1] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][1] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][2] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][2] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][2] / nxyz[ mapcrs[3] ],\n 0,\n 0, 0, 0, 1\n )\n\n matrix.setPosition(new Vector3(\n h.originX, h.originY, h.originZ\n ))\n\n matrix.multiply(new Matrix4().makeTranslation(\n h.NXSTART, h.NYSTART, h.NZSTART\n ))\n\n return matrix\n }\n}\n\nParserRegistry.add('mrc', MrcParser)\nParserRegistry.add('ccp4', MrcParser)\nParserRegistry.add('map', MrcParser)\n\nexport default MrcParser\n","/**\n * @file Xplor Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport VolumeParser from './volume-parser'\n\nconst reWhitespace = /\\s+/\n\nfunction parseNumberLine (line: string) {\n return line.trim().split(reWhitespace).map(parseFloat)\n}\n\ninterface XplorHeader {\n NA: number,\n AMIN: number,\n AMAX: number,\n NB: number,\n BMIN: number,\n BMAX: number,\n NC: number,\n CMIN: number,\n CMAX: number,\n a: number,\n b: number,\n c: number,\n alpha: number,\n beta: number,\n gamma: number,\n RAVE: number,\n RSIGMA: number\n}\n\nclass XplorParser extends VolumeParser {\n get type () { return 'xplor' }\n\n _parse () {\n // http://hincklab.uthscsa.edu/html/soft_packs/msi_docs/insight980/xplor/formats.html\n // http://www.mrc-lmb.cam.ac.uk/public/xtal/doc/cns/cns_1.3/tutorial/formats/maps/text.html\n\n if (Debug) Log.time('XplorParser._parse ' + this.name)\n\n const v = this.volume\n const headerLines = this.streamer.peekLines(8)\n const header: Partial = {}\n\n let infoStart\n if (headerLines[ 2 ].startsWith('REMARKS')) {\n infoStart = parseInt(headerLines[ 1 ].substring(0, 8)) + 2\n } else {\n infoStart = 5\n }\n const dataStart = infoStart + 3\n\n const gridInfo = parseNumberLine(headerLines[ infoStart ])\n header.NA = gridInfo[ 0 ]\n header.AMIN = gridInfo[ 1 ]\n header.AMAX = gridInfo[ 2 ]\n header.NB = gridInfo[ 3 ]\n header.BMIN = gridInfo[ 4 ]\n header.BMAX = gridInfo[ 5 ]\n header.NC = gridInfo[ 6 ]\n header.CMIN = gridInfo[ 7 ]\n header.CMAX = gridInfo[ 8 ]\n\n const cellInfo = parseNumberLine(headerLines[ infoStart + 1 ])\n header.a = cellInfo[ 0 ] * this.voxelSize\n header.b = cellInfo[ 1 ] * this.voxelSize\n header.c = cellInfo[ 2 ] * this.voxelSize\n header.alpha = cellInfo[ 3 ]\n header.beta = cellInfo[ 4 ]\n header.gamma = cellInfo[ 5 ]\n\n const na = header.AMAX - header.AMIN + 1\n const nb = header.BMAX - header.BMIN + 1\n const nc = header.CMAX - header.CMIN + 1\n const n = na * nb * nc\n\n const data = new Float32Array(n)\n const lineSection = Math.ceil(1 + (na * nb) / 6)\n let count = 0\n let lineNo = 0\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n\n if (lineNo >= dataStart && (lineNo - dataStart) % lineSection !== 0 && count < n) {\n for (let j = 0, lj = 6; j < lj; ++j) {\n const value = parseFloat(line.substr(12 * j, 12))\n if (isNaN(value)) { break } // Last line of map section\n data[count++] = value\n }\n } else if (count === n) {\n const lt = line.trim()\n if (lt && lt !== '-9999') {\n const ls = parseNumberLine(line)\n header.RAVE = ls[0]\n header.RSIGMA = ls[1]\n }\n }\n\n ++lineNo\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n v.header = header\n v.setData(data, na, nb, nc)\n if (header.RAVE !== 0 && header.RSIGMA !== 1) {\n v.setStats(undefined, undefined, header.RAVE, header.RSIGMA)\n }\n\n if (Debug) Log.timeEnd('XplorParser._parse ' + this.name)\n }\n\n getMatrix () {\n const h = this.volume.header\n\n const basisX = [\n h.a,\n 0,\n 0\n ]\n\n const basisY = [\n h.b * Math.cos(Math.PI / 180.0 * h.gamma),\n h.b * Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n\n const basisZ = [\n h.c * Math.cos(Math.PI / 180.0 * h.beta),\n h.c * (\n Math.cos(Math.PI / 180.0 * h.alpha) -\n Math.cos(Math.PI / 180.0 * h.gamma) *\n Math.cos(Math.PI / 180.0 * h.beta)\n ) / Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n basisZ[ 2 ] = Math.sqrt(\n h.c * h.c * Math.sin(Math.PI / 180.0 * h.beta) *\n Math.sin(Math.PI / 180.0 * h.beta) - basisZ[ 1 ] * basisZ[ 1 ]\n )\n\n const basis = [ [], basisX, basisY, basisZ ]\n const nxyz = [ 0, h.NA, h.NB, h.NC ]\n const mapcrs = [ 0, 1, 2, 3 ]\n\n const matrix = new Matrix4()\n\n matrix.set(\n basis[ mapcrs[1] ][0] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][0] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][0] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][1] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][1] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][1] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][2] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][2] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][2] / nxyz[ mapcrs[3] ],\n 0,\n 0, 0, 0, 1\n )\n\n matrix.multiply(new Matrix4().makeTranslation(\n h.AMIN, h.BMIN, h.CMIN\n ))\n\n return matrix\n }\n}\n\nParserRegistry.add('xplor', XplorParser)\nParserRegistry.add('cns', XplorParser)\n\nexport default XplorParser\n","/**\n * @file Kin Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { Vector3 } from 'three'\nimport Parser from './parser'\n\nfunction hsvToRgb (h: number, s: number, v: number) {\n h /= 360\n s /= 100\n v /= 100\n let r, g, b\n const i = Math.floor(h * 6)\n const f = h * 6 - i\n const p = v * (1 - s)\n const q = v * (1 - f * s)\n const t = v * (1 - (1 - f) * s)\n switch (i % 6) {\n case 0: r = v; g = t; b = p; break\n case 1: r = q; g = v; b = p; break\n case 2: r = p; g = v; b = t; break\n case 3: r = p; g = q; b = v; break\n case 4: r = t; g = p; b = v; break\n case 5: r = v; g = p; b = q; break\n }\n return [ r, g, b ] as number []\n}\n\nconst ColorDict: {[k: string]: number[]} = {\n red: hsvToRgb(0, 100, 100),\n orange: hsvToRgb(20, 100, 100),\n gold: hsvToRgb(40, 100, 100),\n yellow: hsvToRgb(60, 100, 100),\n lime: hsvToRgb(80, 100, 100),\n green: hsvToRgb(120, 80, 100),\n sea: hsvToRgb(150, 100, 100),\n cyan: hsvToRgb(180, 100, 85),\n sky: hsvToRgb(210, 75, 95),\n blue: hsvToRgb(240, 70, 100),\n purple: hsvToRgb(275, 75, 100),\n magenta: hsvToRgb(300, 95, 100),\n hotpink: hsvToRgb(335, 100, 100),\n pink: hsvToRgb(350, 55, 100),\n peach: hsvToRgb(25, 75, 100),\n lilac: hsvToRgb(275, 55, 100),\n pinktint: hsvToRgb(340, 30, 100),\n peachtint: hsvToRgb(25, 50, 100),\n yellowtint: hsvToRgb(60, 50, 100),\n greentint: hsvToRgb(135, 40, 100),\n bluetint: hsvToRgb(220, 40, 100),\n lilactint: hsvToRgb(275, 35, 100),\n white: hsvToRgb(0, 0, 100),\n gray: hsvToRgb(0, 0, 50),\n brown: hsvToRgb(20, 45, 75),\n deadwhite: [ 1, 1, 1 ],\n deadblack: [ 0, 0, 0 ],\n invisible: [ 0, 0, 0 ]\n}\n\nconst reWhitespaceComma = /[\\s,]+/\nconst reCurlyWhitespace = /[^{}\\s]*{[^{}]+}|[^{}\\s]+/g\nconst reTrimCurly = /^{+|}+$/g\nconst reTrimQuotes = /^['\"]+|['\"]+$/g\nconst reCollapseEqual = /\\s*=\\s*/g\n\nfunction parseListDef (line: string) {\n let name\n let defaultColor\n let master = []\n let width\n\n line = line.replace(reCollapseEqual, '=')\n\n const lm = line.match(reCurlyWhitespace) as RegExpMatchArray\n for (let j = 1; j < lm.length; ++j) {\n const e = lm[ j ]\n if (e[ 0 ] === '{') {\n name = e.substring(1, e.length - 1)\n } else {\n const es = e.split('=')\n if (es.length === 2) {\n if (es[ 0 ] === 'color') {\n defaultColor = ColorDict[ es[ 1 ] ]\n } else if (es[ 0 ] === 'width') {\n width = parseInt(es[ 1 ])\n } else if (es[ 0 ] === 'master') {\n master.push(es[ 1 ].replace(reTrimCurly, ''))\n }\n }\n }\n }\n\n return {\n listName: name,\n listColor: defaultColor,\n listMasters: master,\n listWidth: width\n }\n}\n\nfunction parseListElm (line: string) {\n line = line.trim()\n\n const idx1 = line.indexOf('{')\n const idx2 = line.indexOf('}')\n const ls = line.substr(idx2 + 1).split(reWhitespaceComma)\n\n const label = line.substr(idx1 + 1, idx2 - 1)\n const position = [\n parseFloat(ls[ ls.length - 3 ]),\n parseFloat(ls[ ls.length - 2 ]),\n parseFloat(ls[ ls.length - 1 ])\n ]\n let color, width, radius\n let lineBreak = false\n let triangleBreak = false\n for (let lsindex = 4; lsindex <= ls.length; lsindex++) {\n const literal = ls[ ls.length - lsindex ]\n if (literal in ColorDict) {\n color = ColorDict[ ls[ ls.length - lsindex ] ]\n }\n if (literal.startsWith('width')) {\n width = parseInt(literal.substring(5))\n }\n if (literal.startsWith('r=')) {\n radius = parseFloat(literal.split('=')[1])\n }\n if (literal.startsWith('P')) {\n lineBreak = true\n }\n if (literal.startsWith('X')) {\n triangleBreak = true\n }\n }\n // const color = line[ idx2 + 1 ] === ' ' ? undefined : ColorDict[ ls[ 0 ] ]\n\n return {\n label: label,\n position: position,\n color: color,\n radius: radius,\n width: width,\n isLineBreak: lineBreak,\n isTriangleBreak: triangleBreak\n }\n}\n\nfunction parseStr (line: string) {\n const start = line.indexOf('{')\n const end = line.indexOf('}')\n return line.substring(\n start !== -1 ? start + 1 : 0,\n end !== -1 ? end : undefined\n ).trim()\n}\n\nfunction parseFlag (line: string) {\n const end = line.indexOf('}')\n return end === -1 ? undefined : line.substr(end + 1).trim()\n}\n\nfunction parseGroup (line: string) {\n let name:string = ''\n let master:string[] = []\n let flags: {[k: string]: string|boolean} = {}\n\n line = line.replace(reCollapseEqual, '=')\n\n const lm = line.match(reCurlyWhitespace) as RegExpMatchArray\n for (let j = 1; j < lm.length; ++j) {\n const e = lm[ j ]\n if (e[ 0 ] === '{') {\n name = e.substring(1, e.length - 1)\n } else {\n const es = e.split('=')\n if (es.length === 2) {\n if (es[ 0 ] === 'master') {\n master.push(es[ 1 ].replace(reTrimCurly, ''))\n } else {\n flags[ es[ 0 ] ] = es[ 1 ].replace(reTrimCurly, '')\n }\n } else {\n flags[ es[ 0 ] ] = true\n }\n }\n }\n\n return { groupName: name,\n groupFlags: flags,\n groupMasters: master\n }\n}\ninterface RibbonObject {\n labelArray: string[],\n positionArray: number[],\n breakArray: boolean[],\n colorArray: number[],\n name?: string,\n masterArray: any[]\n}\nfunction convertKinTriangleArrays (ribbonObject: RibbonObject) {\n // have to convert ribbons/triangle lists from stripdrawmode to normal drawmode\n // index [ 0 1 2 3 4 5 6 7 8 91011 ]\n // label [ 0 1 2 3 4 5 ] to [ 0 1 2 1 2 3 2 3 4 3 4 5 ]\n // convertedindex [ 0 1 2 3 4 5 6 7 8 91011121314151617181920212223242526 ]\n // index [ 0 1 2 3 4 5 6 7 8 91011121314 ] [ 0 1 2 3 4 5 6 7 8 3 4 5 6 7 8 91011 6 7 8 91011121314 ]\n // position/color [ 0 0 0 1 1 1 2 2 2 3 3 3 4 4 4 ] to [ 0 0 0 1 1 1 2 2 2 1 1 1 2 2 2 3 3 3 2 2 2 3 3 3 4 4 4 ]\n let { labelArray, positionArray, colorArray, breakArray } = ribbonObject\n let convertedLabels = []\n for (let i = 0; i < (labelArray.length - 2) * 3; ++i) {\n convertedLabels[i] = labelArray[i - Math.floor(i / 3) * 2]\n }\n let convertedBreaks = []\n for (let i = 0; i < (breakArray.length - 2) * 3; ++i) {\n convertedBreaks[i] = breakArray[i - Math.floor(i / 3) * 2]\n }\n let convertedPositions = []\n for (let i = 0; i < (positionArray.length / 3 - 2) * 9; ++i) {\n convertedPositions[i] = positionArray[i - Math.floor(i / 9) * 6]\n }\n let convertedColors = []\n for (let i = 0; i < (colorArray.length / 3 - 2) * 9; ++i) {\n convertedColors[i] = colorArray[i - Math.floor(i / 9) * 6]\n }\n let vector3Positions = []\n for (let i = 0; i < (convertedPositions.length) / 3; ++i) {\n vector3Positions.push(new Vector3(convertedPositions[i * 3], convertedPositions[i * 3] + 1, convertedPositions[i * 3] + 2))\n }\n //let normals = []\n //for (let i = 0; i < vector3Positions.length - 1; ++i) {\n // let normalVec3 = vector3Positions[i].cross(vector3Positions[i + 1])\n // normals.push(normalVec3.x)\n // normals.push(normalVec3.y)\n // normals.push(normalVec3.z)\n //}\n return {\n name: ribbonObject.name,\n masterArray: ribbonObject.masterArray,\n labelArray: convertedLabels,\n positionArray: convertedPositions,\n breakArray: convertedBreaks,\n colorArray: convertedColors\n }\n}\n\nfunction removePointBreaksTriangleArrays (convertedRibbonObject: RibbonObject) {\n // after converting ribbon/triangle arrys to drawmode, removed point break triangles\n // label [ 0 1 2 3 4 5 ] to [ 0 1 2 1 2 3 2 3 4 3 4 5 ]\n // position/color [ 0 0 0 1 1 1 2 2 2 3 3 3 4 4 4 ] to [ 0 0 0 1 1 1 2 2 2 1 1 1 2 2 2 3 3 3 2 2 2 3 3 3 4 4 4 ]\n let { labelArray, positionArray, colorArray, breakArray } = convertedRibbonObject\n let editedLabels = []\n let editedPositions = []\n let editedColors = []\n let editedBreaks = []\n for (let i = 0; i < breakArray.length / 3; i++) {\n let breakPointer = i * 3\n let positionPointer = i * 9\n if (!breakArray[breakPointer+1]&&!breakArray[breakPointer+2]) {\n editedLabels.push(labelArray[breakPointer])\n editedLabels.push(labelArray[breakPointer+1])\n editedLabels.push(labelArray[breakPointer+2])\n editedBreaks.push(breakArray[breakPointer])\n editedBreaks.push(breakArray[breakPointer+1])\n editedBreaks.push(breakArray[breakPointer+2])\n editedPositions.push(positionArray[positionPointer])\n editedPositions.push(positionArray[positionPointer+1])\n editedPositions.push(positionArray[positionPointer+2])\n editedPositions.push(positionArray[positionPointer+3])\n editedPositions.push(positionArray[positionPointer+4])\n editedPositions.push(positionArray[positionPointer+5])\n editedPositions.push(positionArray[positionPointer+6])\n editedPositions.push(positionArray[positionPointer+7])\n editedPositions.push(positionArray[positionPointer+8])\n editedColors.push(colorArray[positionPointer])\n editedColors.push(colorArray[positionPointer+1])\n editedColors.push(colorArray[positionPointer+2])\n editedColors.push(colorArray[positionPointer+3])\n editedColors.push(colorArray[positionPointer+4])\n editedColors.push(colorArray[positionPointer+5])\n editedColors.push(colorArray[positionPointer+6])\n editedColors.push(colorArray[positionPointer+7])\n editedColors.push(colorArray[positionPointer+8])\n } else {\n //console.log('X triangle break found')\n //console.log('skipping: '+positionArray[positionPointer]+','+positionArray[positionPointer+1]+','+positionArray[positionPointer+2]+','\n // +positionArray[positionPointer+3]+','+positionArray[positionPointer+4]+','+positionArray[positionPointer+5]+','\n // +positionArray[positionPointer+6]+','+positionArray[positionPointer+7]+','+positionArray[positionPointer+8])\n }\n }\n return {\n name: convertedRibbonObject.name,\n masterArray: convertedRibbonObject.masterArray,\n labelArray: editedLabels,\n positionArray: editedPositions,\n breakArray: editedBreaks,\n colorArray: editedColors\n }\n}\n\ninterface Kinemage {\n kinemage?: number,\n onewidth?: any,\n '1viewid'?: string,\n pdbfile?: string,\n text: string,\n texts: string[],\n captions: string[],\n caption: string,\n groupDict: {[k:string]: {[k:string]: boolean}},\n subgroupDict: {[k: string]: any},\n masterDict: {[k:string]: {indent: boolean, visible: boolean}},\n pointmasterDict: {[k: string]: any},\n dotLists: DotList[],\n vectorLists: VectorList[],\n ballLists: any[],\n ribbonLists: RibbonObject[]\n}\n\ninterface DotList {\n name?: string,\n masterArray: any[],\n labelArray: any[],\n positionArray: any[],\n colorArray: any[]\n}\n\ninterface VectorList {\n name?: string,\n masterArray: any[],\n label1Array: string[],\n label2Array: string[],\n position1Array: number[],\n position2Array: number[],\n color1Array: number[],\n color2Array: number[],\n width: number[]\n}\n\nclass KinParser extends Parser {\n kinemage: Kinemage\n get type () { return 'kin' }\n get __objName () { return 'kinemage' }\n\n _parse () {\n // http://kinemage.biochem.duke.edu/software/king.php\n\n if (Debug) Log.time(`KinParser._parse ${this.name}`)\n\n const kinemage: Kinemage = {\n kinemage: undefined,\n onewidth: undefined,\n '1viewid': undefined,\n pdbfile: undefined,\n texts: [],\n text: '',\n captions: [],\n caption: '',\n groupDict: {},\n subgroupDict: {},\n masterDict: {},\n pointmasterDict: {},\n dotLists: [],\n vectorLists: [],\n ballLists: [],\n ribbonLists: []\n }\n this.kinemage = kinemage\n\n let currentGroupMasters: string[]\n let currentSubgroupMasters: string[]\n\n let isDotList = false\n let prevDotLabel = ''\n let dotDefaultColor: number[]\n let dotLabel: string[], dotPosition: number[], dotColor: number[]\n\n let isVectorList = false\n let prevVecLabel = ''\n let prevVecPosition: number[]|null = null\n let prevVecColor: number[]|null = null\n let vecDefaultColor: number[], vecDefaultWidth: number[]\n let vecLabel1: string[], vecLabel2: string[], vecPosition1: number[], vecPosition2: number[], vecColor1: number[], vecColor2: number[]\n\n let isBallList = false\n let prevBallLabel = ''\n let ballRadius: number[], ballDefaultColor: number[]\n let ballLabel: string[], ballPosition: number[], ballColor: number[]\n\n let isRibbonList = false\n let prevRibbonPointLabel = ''\n\n let ribbonListDefaultColor: number[]\n let ribbonPointLabelArray: string[], ribbonPointPositionArray: number[], ribbonPointBreakArray: boolean[], ribbonPointColorArray: number[]\n\n let isText = false\n let isCaption = false\n\n // @vectorlist {mc} color= white master= {mainchain}\n // { n thr A 1 B13.79 1crnFH} P 17.047, 14.099, 3.625 { n thr A 1 B13.79 1crnFH} L 17.047, 14.099, 3.625\n\n // @dotlist {x} color=white master={vdw contact} master={dots}\n // { CB THR 1 A}sky 'P' 18.915,14.199,5.024\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n\n if (line[ 0 ] === '@') {\n isDotList = false\n isVectorList = false\n isBallList = false\n isRibbonList = false\n isText = false\n isCaption = false\n }\n\n if (!line) {\n isDotList = false\n isVectorList = false\n isBallList = false\n isRibbonList = false\n } else if (line.startsWith('@dotlist')) {\n // @dotlist {x} color=white master={vdw contact} master={dots}\n\n let { listColor, listName, listMasters } = parseListDef(line)\n\n isDotList = true\n prevDotLabel = ''\n dotLabel = []\n dotPosition = []\n dotColor = []\n dotDefaultColor = listColor as number[]\n\n if (currentGroupMasters) {\n listMasters = listMasters.concat(currentGroupMasters)\n }\n if (currentSubgroupMasters) {\n listMasters = listMasters.concat(currentSubgroupMasters)\n }\n\n kinemage.dotLists.push({\n name: listName,\n masterArray: listMasters,\n labelArray: dotLabel,\n positionArray: dotPosition,\n colorArray: dotColor\n })\n } else if (line.startsWith('@vectorlist')) {\n // @vectorlist {x} color=white master={small overlap} master={dots}\n\n let { listMasters, listName, listWidth, listColor } = parseListDef(line)\n\n if (listMasters) {\n listMasters.forEach(function (name: string) {\n if (!kinemage.masterDict[ name ]) {\n kinemage.masterDict[ name ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n\n isVectorList = true\n prevVecLabel = ''\n prevVecPosition = null\n prevVecColor = null\n vecLabel1 = []\n vecLabel2 = []\n vecPosition1 = []\n vecPosition2 = []\n vecColor1 = []\n vecColor2 = []\n vecDefaultColor = listColor as number[]\n vecDefaultWidth = []\n if (listWidth) {\n vecDefaultWidth.push(listWidth)\n }\n\n if (currentGroupMasters) {\n listMasters = listMasters.concat(currentGroupMasters)\n }\n if (currentSubgroupMasters) {\n listMasters = listMasters.concat(currentSubgroupMasters)\n }\n\n kinemage.vectorLists.push({\n name: listName,\n masterArray: listMasters,\n label1Array: vecLabel1,\n label2Array: vecLabel2,\n position1Array: vecPosition1,\n position2Array: vecPosition2,\n color1Array: vecColor1,\n color2Array: vecColor2,\n width: vecDefaultWidth\n })\n } else if (line.startsWith('@balllist')) {\n let { listName, listColor, listMasters } = parseListDef(line)\n\n if (listMasters) {\n listMasters.forEach(function (name: string) {\n if (!kinemage.masterDict[ name ]) {\n kinemage.masterDict[ name ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n\n isBallList = true\n\n prevBallLabel = ''\n ballLabel = []\n ballRadius = []\n ballPosition = []\n ballColor = []\n ballDefaultColor = listColor as number[]\n\n if (currentGroupMasters) {\n listMasters = listMasters.concat(currentGroupMasters)\n }\n if (currentSubgroupMasters) {\n listMasters = listMasters.concat(currentSubgroupMasters)\n }\n\n kinemage.ballLists.push({\n name: listName,\n masterArray: listMasters,\n labelArray: ballLabel,\n radiusArray: ballRadius,\n positionArray: ballPosition,\n colorArray: ballColor\n })\n } else if (line.startsWith('@ribbonlist')||line.startsWith('@trianglelist')) {\n let { listMasters, listName, listColor } = parseListDef(line)\n\n if (listMasters) {\n listMasters.forEach(function (name: string) {\n if (!kinemage.masterDict[ name ]) {\n kinemage.masterDict[ name ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n isRibbonList = true\n prevRibbonPointLabel = ''\n ribbonPointLabelArray = []\n ribbonPointPositionArray = []\n ribbonPointBreakArray = []\n ribbonPointColorArray = []\n ribbonListDefaultColor = listColor as number[]\n\n if (currentGroupMasters) {\n listMasters = listMasters.concat(currentGroupMasters)\n }\n if (currentSubgroupMasters) {\n listMasters = listMasters.concat(currentSubgroupMasters)\n }\n\n kinemage.ribbonLists.push({\n name: listName,\n masterArray: listMasters,\n labelArray: ribbonPointLabelArray,\n positionArray: ribbonPointPositionArray,\n breakArray: ribbonPointBreakArray,\n colorArray: ribbonPointColorArray\n })\n } else if (line.startsWith('@text')) {\n isText = true\n kinemage.texts.push(line.substr(5))\n } else if (line.startsWith('@caption')) {\n isCaption = true\n kinemage.captions.push(line.substr(8))\n } else if (isDotList) {\n // { CB THR 1 A}sky 'P' 18.915,14.199,5.024\n\n let { label, color, position } = parseListElm(line)\n\n if (label === '\"') {\n label = prevDotLabel\n } else {\n prevDotLabel = label\n }\n\n if (color === undefined) {\n color = dotDefaultColor\n }\n\n dotLabel.push(label)\n dotPosition.push(...position)\n dotColor.push(...color)\n } else if (isVectorList) {\n // { n thr A 1 B13.79 1crnFH} P 17.047, 14.099, 3.625 { n thr A 1 B13.79 1crnFH} L 17.047, 14.099, 3.625\n\n let doubleLine = line.replace(/(?!^){/g, '\\n{')\n let splitLine = doubleLine.split(/\\n/)\n\n for (var i2 = 0; i2 < splitLine.length; i2++) {\n let singlePointLine = splitLine[i2]\n let { label, color, width, position, isLineBreak } = parseListElm(singlePointLine)\n\n if (label === '\"') {\n label = prevVecLabel\n } else {\n prevVecLabel = label\n }\n\n if (color === undefined) {\n color = vecDefaultColor\n }\n\n if (!isLineBreak) {\n if (prevVecPosition !== null) {\n if (width) {\n vecDefaultWidth.push(width)\n }\n\n vecLabel1.push(prevVecLabel)\n vecPosition1.push(...prevVecPosition)\n vecColor1.push(...prevVecColor as number[])\n\n vecLabel2.push(label)\n vecPosition2.push(...position)\n vecColor2.push(...color)\n\n }\n }\n\n prevVecLabel = label\n prevVecPosition = position\n prevVecColor = color\n }\n } else if (isBallList) {\n // {cb arg A 1 1.431 -106.80} r=1.431 39.085, 8.083, 22.182\n\n let { label, radius, color, position } = parseListElm(line)\n\n if (label === '\"') {\n label = prevBallLabel\n } else {\n prevBallLabel = label\n }\n\n if (radius === undefined) {\n radius = 1 // temporary default radius\n }\n\n if (color === undefined) {\n color = ballDefaultColor\n }\n\n ballLabel.push(label)\n ballRadius.push(radius)\n ballPosition.push(...position)\n ballColor.push(...color)\n } else if (isRibbonList) {\n let { label, color, position, isTriangleBreak } = parseListElm(line)\n\n if (label === '\"') {\n label = prevRibbonPointLabel\n } else {\n prevRibbonPointLabel = label\n }\n\n if (color === undefined) {\n color = ribbonListDefaultColor\n }\n\n ribbonPointLabelArray.push(label)\n ribbonPointPositionArray.push(...position)\n ribbonPointBreakArray.push(isTriangleBreak)\n ribbonPointColorArray.push(...color)\n } else if (isText) {\n kinemage.texts.push(line)\n } else if (isCaption) {\n kinemage.captions.push(line)\n } else if (line.startsWith('@kinemage')) {\n kinemage.kinemage = parseInt(line.substr(9).trim())\n } else if (line.startsWith('@onewidth')) {\n kinemage.onewidth = true\n } else if (line.startsWith('@1viewid')) {\n kinemage[ '1viewid' ] = parseStr(line)\n } else if (line.startsWith('@pdbfile')) {\n kinemage.pdbfile = parseStr(line)\n } else if (line.startsWith('@group')) {\n let { groupName, groupFlags, groupMasters } = parseGroup(line)\n if (!kinemage.groupDict[ groupName as string ]) {\n kinemage.groupDict[ groupName as string ] = {\n dominant: false,\n animate: false\n }\n currentGroupMasters = groupMasters\n }\n\n if (currentGroupMasters) {\n currentGroupMasters.forEach(function (master) {\n if (!kinemage.masterDict[ master ]) {\n kinemage.masterDict[ master ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n\n for (let key in groupFlags as {[k: string]: boolean}) {\n kinemage.groupDict[ groupName as string ][ key ] = (groupFlags as {[k: string]: boolean})[ key ]\n }\n } else if (line.startsWith('@subgroup')) {\n const { groupName, groupFlags, groupMasters } = parseGroup(line)\n\n if (!kinemage.subgroupDict[ groupName as string ]) {\n kinemage.subgroupDict[ groupName as string ] = {\n dominant: false,\n animate: false\n }\n currentSubgroupMasters = groupMasters\n }\n\n if (currentSubgroupMasters) {\n currentSubgroupMasters.forEach(function (master) {\n if (!kinemage.masterDict[ master ]) {\n kinemage.masterDict[ master ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n\n for (let key in groupFlags as {[k: string]: boolean}) {\n kinemage.subgroupDict[ groupName as string ][ key ] = (groupFlags as {[k: string]: boolean})[ key ]\n }\n } else if (line.startsWith('@master')) {\n const name = parseStr(line)\n const flag = parseFlag(line)\n\n if (!kinemage.masterDict[ name ]) {\n kinemage.masterDict[ name ] = {\n indent: false,\n visible: false\n }\n }\n\n if (flag === 'on') {\n kinemage.masterDict[ name ].visible = true\n } else if (flag === 'off') {\n kinemage.masterDict[ name ].visible = false\n } else if (flag === 'indent') {\n kinemage.masterDict[ name ].indent = true\n } else if (!flag) {\n // nothing to do\n }\n } else if (line.startsWith('@pointmaster')) {\n const { groupName, groupFlags } = parseGroup(line)\n\n kinemage.pointmasterDict[ groupName as string] = {\n id: Object.keys(groupFlags as {[k: string]: boolean})[ 0 ].replace(reTrimQuotes, '')\n }\n } else {\n console.log(line)\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n kinemage.text = kinemage.texts.join('\\n').trim()\n kinemage.caption = kinemage.captions.join('\\n').trim()\n if (kinemage.ribbonLists) {\n let convertedLists: RibbonObject[] = []\n kinemage.ribbonLists.forEach(function (listObject) {\n convertedLists.push(removePointBreaksTriangleArrays(convertKinTriangleArrays(listObject)))\n })\n kinemage.ribbonLists = convertedLists\n }\n\n if (Debug) Log.timeEnd(`KinParser._parse ${this.name}`)\n }\n}\n\nParserRegistry.add('kin', KinParser)\n\nexport default KinParser\n","/**\n * @file Surface Parser\n * @author Alexander Rose \n * @private\n */\n\nimport Parser, { ParserParameters } from './parser'\nimport Surface from '../surface/surface'\nimport Streamer from '../streamer/streamer';\n\nclass SurfaceParser extends Parser {\n constructor (streamer: Streamer, params?:Partial) {\n super(streamer, params)\n\n this.loader = this.getLoader()\n this.surface = new Surface(this.name, this.path)\n }\n\n get type () { return 'surface' }\n get __objName () { return 'surface' }\n\n _parse () {\n var geometry = this.loader.parse(this.streamer.asText())\n\n this.surface.fromGeometry(geometry)\n }\n}\n\nexport default SurfaceParser\n","/**\n * @file Obj Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { BufferGeometry, BufferAttribute } from 'three'\n\nimport { ParserRegistry } from '../globals'\nimport SurfaceParser from './surface-parser'\n\nexport interface _OBJLoader {\n regexp: {[k: string]: RegExp}\n}\n\ninterface _OBJLoaderConstructor {\n (this: _OBJLoader): void\n new(): _OBJLoader\n}\n\ninterface ObjectType {\n name: string,\n fromDeclaration: boolean,\n geometry: {\n vertices: number[],\n normals: number[],\n type?: string\n }\n}\n/**\n * OBJLoader\n * @class\n * @private\n * @author mrdoob / http://mrdoob.com/\n */\nconst OBJLoader = (function OBJLoader (this: _OBJLoader) {\n this.regexp = {\n // v float float float\n vertex_pattern: /^v\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)/,\n // vn float float float\n normal_pattern: /^vn\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)/,\n // vt float float\n uv_pattern: /^vt\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)/,\n // f vertex vertex vertex\n face_vertex: /^f\\s+(-?\\d+)\\s+(-?\\d+)\\s+(-?\\d+)(?:\\s+(-?\\d+))?/,\n // f vertex/uv vertex/uv vertex/uv\n face_vertex_uv: /^f\\s+(-?\\d+)\\/(-?\\d+)\\s+(-?\\d+)\\/(-?\\d+)\\s+(-?\\d+)\\/(-?\\d+)(?:\\s+(-?\\d+)\\/(-?\\d+))?/,\n // f vertex/uv/normal vertex/uv/normal vertex/uv/normal\n face_vertex_uv_normal: /^f\\s+(-?\\d+)\\/(-?\\d+)\\/(-?\\d+)\\s+(-?\\d+)\\/(-?\\d+)\\/(-?\\d+)\\s+(-?\\d+)\\/(-?\\d+)\\/(-?\\d+)(?:\\s+(-?\\d+)\\/(-?\\d+)\\/(-?\\d+))?/,\n // f vertex//normal vertex//normal vertex//normal\n face_vertex_normal: /^f\\s+(-?\\d+)\\/\\/(-?\\d+)\\s+(-?\\d+)\\/\\/(-?\\d+)\\s+(-?\\d+)\\/\\/(-?\\d+)(?:\\s+(-?\\d+)\\/\\/(-?\\d+))?/,\n // o object_name | g group_name\n object_pattern: /^[og]\\s*(.+)?/,\n // s boolean\n smoothing_pattern: /^s\\s+(\\d+|on|off)/,\n // mtllib file_reference\n material_library_pattern: /^mtllib /,\n // usemtl material_name\n material_use_pattern: /^usemtl /\n }\n}) as _OBJLoaderConstructor\n\nOBJLoader.prototype = {\n\n constructor: OBJLoader,\n\n setPath: function (value: string) {\n this.path = value\n },\n\n _createParserState: function () {\n var state = {\n objects: [] as ObjectType[],\n object: {} as ObjectType,\n\n vertices: [],\n normals: [],\n\n startObject: function (name: string, fromDeclaration: boolean) {\n // If the current object (initial from reset) is not from a g/o declaration in the parsed\n // file. We need to use it for the first parsed g/o to keep things in sync.\n if (this.object && this.object.fromDeclaration === false) {\n this.object.name = name\n this.object.fromDeclaration = (fromDeclaration !== false)\n return\n }\n\n this.object = {\n name: name || '',\n geometry: {\n vertices: [],\n normals: []\n },\n fromDeclaration: (fromDeclaration !== false)\n }\n\n this.objects.push(this.object)\n },\n\n parseVertexIndex: function (value: string, len: number) {\n var index = parseInt(value, 10)\n return (index >= 0 ? index - 1 : index + len / 3) * 3\n },\n\n parseNormalIndex: function (value: string, len: number) {\n var index = parseInt(value, 10)\n return (index >= 0 ? index - 1 : index + len / 3) * 3\n },\n\n addVertex: function (a: number, b: number, c: number) {\n var src = this.vertices\n var dst = this.object.geometry.vertices\n\n dst.push(src[ a + 0 ])\n dst.push(src[ a + 1 ])\n dst.push(src[ a + 2 ])\n dst.push(src[ b + 0 ])\n dst.push(src[ b + 1 ])\n dst.push(src[ b + 2 ])\n dst.push(src[ c + 0 ])\n dst.push(src[ c + 1 ])\n dst.push(src[ c + 2 ])\n },\n\n addVertexLine: function (a: number) {\n var src = this.vertices\n var dst = this.object.geometry.vertices\n\n dst.push(src[ a + 0 ])\n dst.push(src[ a + 1 ])\n dst.push(src[ a + 2 ])\n },\n\n addNormal: function (a: number, b: number, c: number) {\n var src = this.normals\n var dst = this.object.geometry.normals\n\n dst.push(src[ a + 0 ])\n dst.push(src[ a + 1 ])\n dst.push(src[ a + 2 ])\n dst.push(src[ b + 0 ])\n dst.push(src[ b + 1 ])\n dst.push(src[ b + 2 ])\n dst.push(src[ c + 0 ])\n dst.push(src[ c + 1 ])\n dst.push(src[ c + 2 ])\n },\n\n addFace: function (a: string, b: string, c: string, d?: string, na?: string, nb?: string, nc?: string, nd?: string) {\n var vLen = this.vertices.length\n\n var ia = this.parseVertexIndex(a, vLen)\n var ib = this.parseVertexIndex(b, vLen)\n var ic = this.parseVertexIndex(c, vLen)\n var id\n\n if (d === undefined) {\n this.addVertex(ia, ib, ic)\n } else {\n id = this.parseVertexIndex(d, vLen)\n\n this.addVertex(ia, ib, id)\n this.addVertex(ib, ic, id)\n }\n\n if (na !== undefined) {\n // Normals are many times the same. If so, skip function call and parseInt.\n var nLen = this.normals.length\n ia = this.parseNormalIndex(na, nLen)\n\n ib = na === nb ? ia : this.parseNormalIndex(nb!, nLen)\n ic = na === nc ? ia : this.parseNormalIndex(nc!, nLen)\n\n if (d === undefined) {\n this.addNormal(ia, ib, ic)\n } else {\n id = this.parseNormalIndex(nd!, nLen)\n\n this.addNormal(ia, ib, id)\n this.addNormal(ib, ic, id)\n }\n }\n },\n\n addLineGeometry: function (vertices: string[]) {\n this.object.geometry.type = 'Line'\n\n var vLen = this.vertices.length\n\n for (var vi = 0, l = vertices.length; vi < l; vi++) {\n this.addVertexLine(this.parseVertexIndex(vertices[ vi ], vLen))\n }\n }\n\n }\n\n state.startObject('', false)\n\n return state\n },\n\n parse: function (text: string) {\n var state = this._createParserState()\n\n if (text.indexOf('\\r\\n') !== -1) {\n // This is faster than String.split with regex that splits on both\n text = text.replace(/\\r\\n/g, '\\n')\n }\n\n if (text.indexOf('\\\\\\n') !== -1) {\n // join lines separated by a line continuation character (\\)\n text = text.replace(/\\\\\\n/g, '')\n }\n\n var i, l\n var lines = text.split('\\n')\n var line = ''\n var lineFirstChar = ''\n var lineSecondChar = ''\n var lineLength = 0\n var result = []\n\n // Faster to just trim left side of the line. Use if available.\n var trimLeft = (typeof ''.trimLeft === 'function')\n\n for (i = 0, l = lines.length; i < l; i++) {\n line = lines[ i ]\n\n line = trimLeft ? line.trimLeft() : line.trim()\n\n lineLength = line.length\n\n if (lineLength === 0) continue\n\n lineFirstChar = line.charAt(0)\n\n // @todo invoke passed in handler if any\n if (lineFirstChar === '#') continue\n\n if (lineFirstChar === 'v') {\n lineSecondChar = line.charAt(1)\n\n if (lineSecondChar === ' ' && (result = this.regexp.vertex_pattern.exec(line)) !== null) {\n // 0 1 2 3\n // [\"v 1.0 2.0 3.0\", \"1.0\", \"2.0\", \"3.0\"]\n\n state.vertices.push(\n parseFloat(result[ 1 ]),\n parseFloat(result[ 2 ]),\n parseFloat(result[ 3 ])\n )\n } else if (lineSecondChar === 'n' && (result = this.regexp.normal_pattern.exec(line)) !== null) {\n // 0 1 2 3\n // [\"vn 1.0 2.0 3.0\", \"1.0\", \"2.0\", \"3.0\"]\n\n state.normals.push(\n parseFloat(result[ 1 ]),\n parseFloat(result[ 2 ]),\n parseFloat(result[ 3 ])\n )\n } else if (lineSecondChar === 't' && this.regexp.uv_pattern.exec(line) !== null) {\n\n // ignore uv line\n\n } else {\n throw new Error(\"Unexpected vertex/normal/uv line: '\" + line + \"'\")\n }\n } else if (lineFirstChar === 'f') {\n if ((result = this.regexp.face_vertex_uv_normal.exec(line)) !== null) {\n // f vertex/uv/normal vertex/uv/normal vertex/uv/normal\n // 0 1 2 3 4 5 6 7 8 9 10 11 12\n // [\"f 1/1/1 2/2/2 3/3/3\", \"1\", \"1\", \"1\", \"2\", \"2\", \"2\", \"3\", \"3\", \"3\", undefined, undefined, undefined]\n\n state.addFace(\n result[ 1 ], result[ 4 ], result[ 7 ], result[ 10 ],\n // result[ 2 ], result[ 5 ], result[ 8 ], result[ 11 ], // ignore uv part\n result[ 3 ], result[ 6 ], result[ 9 ], result[ 12 ]\n )\n } else if (this.regexp.face_vertex_uv.exec(line) !== null) {\n\n // ignore uv line\n\n } else if ((result = this.regexp.face_vertex_normal.exec(line)) !== null) {\n // f vertex//normal vertex//normal vertex//normal\n // 0 1 2 3 4 5 6 7 8\n // [\"f 1//1 2//2 3//3\", \"1\", \"1\", \"2\", \"2\", \"3\", \"3\", undefined, undefined]\n\n state.addFace(\n result[ 1 ], result[ 3 ], result[ 5 ], result[ 7 ],\n result[ 2 ], result[ 4 ], result[ 6 ], result[ 8 ]\n )\n } else if ((result = this.regexp.face_vertex.exec(line)) !== null) {\n // f vertex vertex vertex\n // 0 1 2 3 4\n // [\"f 1 2 3\", \"1\", \"2\", \"3\", undefined]\n\n state.addFace(\n result[ 1 ], result[ 2 ], result[ 3 ], result[ 4 ]\n )\n } else {\n throw new Error(\"Unexpected face line: '\" + line + \"'\")\n }\n } else if (lineFirstChar === 'l') {\n var lineParts = line.substring(1).trim().split(' ')\n var lineVertices = []\n var lineUVs = []\n\n if (line.indexOf('/') === -1) {\n lineVertices = lineParts\n } else {\n for (var li = 0, llen = lineParts.length; li < llen; li++) {\n var parts = lineParts[ li ].split('/')\n\n if (parts[ 0 ] !== '') lineVertices.push(parts[ 0 ])\n if (parts[ 1 ] !== '') lineUVs.push(parts[ 1 ])\n }\n }\n state.addLineGeometry(lineVertices, lineUVs)\n } else if ((result = this.regexp.object_pattern.exec(line)) !== null) {\n // o object_name\n // or\n // g group_name\n\n var name = result[ 0 ].substr(1).trim()\n state.startObject(name)\n\n // ignore material related lines\n // eslint-disable-next-line no-empty\n } else if (this.regexp.material_use_pattern.test(line)) {\n // eslint-disable-next-line no-empty\n } else if (this.regexp.material_library_pattern.test(line)) {\n // eslint-disable-next-line no-empty\n } else if (this.regexp.smoothing_pattern.exec(line) !== null) {\n } else {\n // Handle null terminated files without exception\n if (line === '\\0') continue\n\n throw new Error(\"Unexpected line: '\" + line + \"'\")\n }\n }\n\n var container = []\n\n for (i = 0, l = state.objects.length; i < l; i++) {\n var object = state.objects[ i ]\n var geometry = object.geometry\n\n // Skip o/g line declarations that did not follow with any faces\n if (geometry.vertices.length === 0) continue\n\n var buffergeometry = new BufferGeometry()\n\n buffergeometry.setAttribute('position', new BufferAttribute(new Float32Array(geometry.vertices), 3))\n\n if (geometry.normals.length > 0) {\n buffergeometry.setAttribute('normal', new BufferAttribute(new Float32Array(geometry.normals), 3))\n } else {\n buffergeometry.computeVertexNormals()\n }\n\n container.push(buffergeometry)\n }\n\n return container\n }\n\n}\n\nclass ObjParser extends SurfaceParser {\n get type () { return 'obj' }\n\n getLoader () {\n return new OBJLoader()\n }\n}\n\nParserRegistry.add('obj', ObjParser)\n\nexport default ObjParser\n","/**\n * @file Ply Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Geometry, Vector3, Face3, Color } from 'three'\n\nimport { ParserRegistry } from '../globals'\nimport SurfaceParser from './surface-parser'\n\n/**\n * PLYLoader\n * @class\n * @private\n * @author Wei Meng / http://about.me/menway\n *\n * @description\n * A THREE loader for PLY ASCII files (known as the Polygon File Format or the Stanford Triangle Format).\n *\n * Limitations: ASCII decoding assumes file is UTF-8.\n *\n * @example\n * var loader = new THREE.PLYLoader();\n * loader.load('./models/ply/ascii/dolphins.ply', function (geometry) {\n * scene.add( new THREE.Mesh( geometry ) );\n * } );\n *\n * // If the PLY file uses non standard property names, they can be mapped while\n * // loading. For example, the following maps the properties\n * // “diffuse_(red|green|blue)” in the file to standard color names.\n *\n * loader.setPropertyNameMapping( {\n * diffuse_red: 'red',\n * diffuse_green: 'green',\n * diffuse_blue: 'blue'\n * } );\n *\n */\n\nexport interface _PLYLoader {\n propertyNameMapping: {[k: string]: string}\n}\n\ninterface _PLYLoaderConstructor {\n (this: _PLYLoader): void\n new(): _PLYLoader\n}\n\ninterface PLYProperty {\n type: string,\n name: string,\n countType: string,\n itemType: string\n}\n\ninterface PLYElement {\n name: string,\n count: number,\n properties: PLYProperty[],\n x: number,\n y: number,\n z: number,\n red: number,\n green: number,\n blue: number,\n [k:string]: any\n}\n\ninterface PLYHeader {\n format: string,\n version: string,\n comments: string[],\n elements: PLYElement[],\n headerLength: number\n}\n\ninterface GeometryPLY extends Geometry {\n useColor: boolean\n}\n\nconst PLYLoader = (function PLYLoader (this: _PLYLoader) {\n this.propertyNameMapping = {}\n}) as _PLYLoaderConstructor\n\nPLYLoader.prototype = {\n\n constructor: PLYLoader,\n\n setPropertyNameMapping: function (mapping: {[k: string]: string}) {\n this.propertyNameMapping = mapping\n },\n\n bin2str: function (buf: ArrayBuffer) {\n var arrayBuffer = new Uint8Array(buf)\n var str = ''\n for (var i = 0; i < buf.byteLength; i++) {\n str += String.fromCharCode(arrayBuffer[ i ]) // implicitly assumes little-endian\n }\n\n return str\n },\n\n isASCII: function (data: ArrayBuffer) {\n var header = this.parseHeader(this.bin2str(data))\n\n return header.format === 'ascii'\n },\n\n parse: function (data: string|ArrayBuffer) {\n if (data instanceof ArrayBuffer) {\n return (\n this.isASCII(data)\n ? this.parseASCII(this.bin2str(data))\n : this.parseBinary(data)\n )\n } else {\n return this.parseASCII(data)\n }\n },\n\n parseHeader: function (data: string) {\n var patternHeader = /ply([\\s\\S]*)end_header\\s/\n var headerText = ''\n var headerLength = 0\n var result = patternHeader.exec(data)\n if (result !== null) {\n headerText = result[ 1 ]\n headerLength = result[ 0 ].length\n }\n\n var header: Partial = {\n comments: [],\n elements: [],\n headerLength: headerLength\n }\n\n var lines = headerText.split('\\n')\n var currentElement: PLYElement|undefined, lineType, lineValues\n\n function makePlyElementProperty (propertValues: string[], propertyNameMapping: {[k: string]: string}) {\n var property = {\n type: propertValues[ 0 ]\n } as PLYProperty\n\n if (property.type === 'list') {\n property.name = propertValues[ 3 ]\n property.countType = propertValues[ 1 ]\n property.itemType = propertValues[ 2 ]\n } else {\n property.name = propertValues[ 1 ]\n }\n\n if (property.name in propertyNameMapping) {\n property.name = propertyNameMapping[ property.name ]\n }\n\n return property\n }\n\n for (var i = 0; i < lines.length; i++) {\n var line = lines[ i ]\n line = line.trim()\n if (line === '') {\n continue\n }\n lineValues = line.split(/\\s+/)\n lineType = lineValues.shift()\n line = lineValues.join(' ')\n\n switch (lineType) {\n case 'format':\n\n header.format = lineValues[ 0 ]\n header.version = lineValues[ 1 ]\n\n break\n\n case 'comment':\n\n header.comments!.push(line)\n\n break\n\n case 'element':\n\n if (currentElement !== undefined) {\n header.elements!.push(currentElement as PLYElement)\n }\n\n currentElement = {} as PLYElement\n currentElement.name = lineValues[ 0 ]\n currentElement.count = parseInt(lineValues[ 1 ])\n currentElement.properties = []\n\n break\n\n case 'property':\n\n currentElement!.properties.push(makePlyElementProperty(lineValues, this.propertyNameMapping))\n\n break\n\n default:\n\n console.log('unhandled', lineType, lineValues)\n }\n }\n\n if (currentElement !== undefined) {\n header.elements!.push(currentElement)\n }\n\n return header\n },\n\n parseASCIINumber: function (n: string, type: string) {\n switch (type) {\n case 'char': case 'uchar': case 'short': case 'ushort': case 'int': case 'uint':\n case 'int8': case 'uint8': case 'int16': case 'uint16': case 'int32': case 'uint32':\n\n return parseInt(n)\n\n case 'float': case 'double': case 'float32': case 'float64':\n\n return parseFloat(n)\n }\n },\n\n parseASCIIElement: function (properties: PLYProperty[], line: string) {\n var values = line.split(/\\s+/)\n\n var element = {} as PLYElement\n\n for (var i = 0; i < properties.length; i++) {\n if (properties[ i ].type === 'list') {\n var list = []\n var n = this.parseASCIINumber(values.shift(), properties[ i ].countType)\n\n for (var j = 0; j < n; j++) {\n list.push(this.parseASCIINumber(values.shift(), properties[ i ].itemType))\n }\n\n element[ properties[ i ].name ] = list\n } else {\n element[ properties[ i ].name ] = this.parseASCIINumber(values.shift(), properties[ i ].type)\n }\n }\n\n return element\n },\n\n parseASCII: function (data: string) {\n // PLY ascii format specification, as per http://en.wikipedia.org/wiki/PLY_(file_format)\n\n var geometry = new Geometry() as GeometryPLY\n\n var result\n\n var header = this.parseHeader(data)\n\n var patternBody = /end_header\\s([\\s\\S]*)$/\n var body = ''\n if ((result = patternBody.exec(data)) !== null) {\n body = result[ 1 ]\n }\n\n var lines = body.split('\\n')\n var currentElement = 0\n var currentElementCount = 0\n geometry.useColor = false\n\n for (var i = 0; i < lines.length; i++) {\n var line = lines[ i ]\n line = line.trim()\n if (line === '') {\n continue\n }\n\n if (currentElementCount >= header.elements[ currentElement ].count) {\n currentElement++\n currentElementCount = 0\n }\n\n var element = this.parseASCIIElement(header.elements[ currentElement ].properties, line)\n\n this.handleElement(geometry, header.elements[ currentElement ].name, element)\n\n currentElementCount++\n }\n\n return this.postProcess(geometry)\n },\n\n postProcess: function (geometry: GeometryPLY) {\n if (geometry.useColor) {\n for (var i = 0; i < geometry.faces.length; i++) {\n geometry.faces[ i ].vertexColors = [\n geometry.colors[ geometry.faces[ i ].a ],\n geometry.colors[ geometry.faces[ i ].b ],\n geometry.colors[ geometry.faces[ i ].c ]\n ]\n }\n\n geometry.elementsNeedUpdate = true\n }\n\n geometry.computeBoundingSphere()\n\n return geometry\n },\n\n handleElement: function (geometry: GeometryPLY, elementName: string, element: PLYElement) {\n if (elementName === 'vertex') {\n geometry.vertices.push(\n new Vector3(element.x, element.y, element.z)\n )\n\n if ('red' in element && 'green' in element && 'blue' in element) {\n geometry.useColor = true\n\n var color = new Color()\n color.setRGB(element.red / 255.0, element.green / 255.0, element.blue / 255.0)\n geometry.colors.push(color)\n }\n } else if (elementName === 'face') {\n var vertexIndices = element.vertex_indices\n\n if (vertexIndices.length === 3) {\n geometry.faces.push(\n new Face3(vertexIndices[ 0 ], vertexIndices[ 1 ], vertexIndices[ 2 ])\n )\n } else if (vertexIndices.length === 4) {\n geometry.faces.push(\n new Face3(vertexIndices[ 0 ], vertexIndices[ 1 ], vertexIndices[ 3 ]),\n new Face3(vertexIndices[ 1 ], vertexIndices[ 2 ], vertexIndices[ 3 ])\n )\n }\n }\n },\n\n binaryRead: function (dataview: DataView, at: number, type: string, littleEndian: boolean) {\n switch (type) {\n // corespondences for non-specific length types here match rply:\n case 'int8': case 'char': return [ dataview.getInt8(at), 1 ]\n\n case 'uint8': case 'uchar': return [ dataview.getUint8(at), 1 ]\n\n case 'int16': case 'short': return [ dataview.getInt16(at, littleEndian), 2 ]\n\n case 'uint16': case 'ushort': return [ dataview.getUint16(at, littleEndian), 2 ]\n\n case 'int32': case 'int': return [ dataview.getInt32(at, littleEndian), 4 ]\n\n case 'uint32': case 'uint': return [ dataview.getUint32(at, littleEndian), 4 ]\n\n case 'float32': case 'float': return [ dataview.getFloat32(at, littleEndian), 4 ]\n\n case 'float64': case 'double': return [ dataview.getFloat64(at, littleEndian), 8 ]\n }\n },\n\n binaryReadElement: function (dataview: DataView, at: number, properties: PLYProperty[], littleEndian: boolean) {\n var element = {} as PLYElement\n var result\n var read = 0\n\n for (var i = 0; i < properties.length; i++) {\n if (properties[ i ].type === 'list') {\n var list = []\n\n result = this.binaryRead(dataview, at + read, properties[ i ].countType, littleEndian)\n var n = result[ 0 ]\n read += result[ 1 ]\n\n for (var j = 0; j < n; j++) {\n result = this.binaryRead(dataview, at + read, properties[ i ].itemType, littleEndian)\n list.push(result[ 0 ])\n read += result[ 1 ]\n }\n\n element[ properties[ i ].name ] = list\n } else {\n result = this.binaryRead(dataview, at + read, properties[ i ].type, littleEndian)\n element[ properties[ i ].name ] = result[ 0 ]\n read += result[ 1 ]\n }\n }\n\n return [ element, read ]\n },\n\n parseBinary: function (data: ArrayBuffer) {\n var geometry = new Geometry()\n\n var header = this.parseHeader(this.bin2str(data))\n var littleEndian = (header.format === 'binary_little_endian')\n var body = new DataView(data, header.headerLength)\n var result\n var loc = 0\n\n for (var currentElement = 0; currentElement < header.elements.length; currentElement++) {\n for (var currentElementCount = 0; currentElementCount < header.elements[ currentElement ].count; currentElementCount++) {\n result = this.binaryReadElement(body, loc, header.elements[ currentElement ].properties, littleEndian)\n loc += result[ 1 ]\n var element = result[ 0 ]\n\n this.handleElement(geometry, header.elements[ currentElement ].name, element)\n }\n }\n\n return this.postProcess(geometry)\n }\n\n}\n\nclass PlyParser extends SurfaceParser {\n get type () { return 'ply' }\n\n getLoader () {\n return new PLYLoader()\n }\n}\n\nParserRegistry.add('ply', PlyParser)\n\nexport default PlyParser\n","/**\n * @file Csv Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { ParserRegistry } from '../globals'\nimport Parser, { ParserParameters } from './parser'\nimport Streamer from '../streamer/streamer';\n\nexport interface CsvParserParameters extends ParserParameters {\n delimiter: string\n comment: string\n columnNames: boolean\n}\n/**\n * CSV parser\n */\nclass CsvParser extends Parser {\n /**\n * [constructor description]\n * @param {Streamer} streamer - the streamer object\n * @param {Object} params - parameter object\n * @param {Char} params.delimiter - delimiter character\n * @param {Char} params.comment - comment character\n * @param {Boolean} params.columnNames - use first data line as column names\n */\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.delimiter = defaults(p.delimiter, ',')\n this.comment = defaults(p.comment, '#')\n this.columnNames = defaults(p.columnNames, false)\n\n this.table = {\n name: this.name,\n path: this.path,\n columnNames: [],\n data: []\n }\n }\n\n get type () { return 'csv' }\n get __objName () { return 'table' }\n\n _parse () {\n const data = this.table.data\n const reDelimiter = new RegExp('\\\\s*' + this.delimiter + '\\\\s*')\n\n let j = 0\n\n this.streamer.eachChunkOfLines(chunk => {\n const n = chunk.length\n\n for (let i = 0; i < n; ++i) {\n const line = chunk[ i ].trim()\n if (line.startsWith(this.comment)) continue\n const values = line.split(reDelimiter)\n\n if (j === 0) {\n this.table.columnNames = values\n } else if (line) {\n data.push(values)\n }\n ++j\n }\n })\n }\n}\n\nParserRegistry.add('csv', CsvParser)\n\nexport default CsvParser\n","/**\n * @file Json Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Parser, { ParserParameters } from './parser'\nimport Streamer from '../streamer/streamer';\n\nexport interface JsonParserParameters extends ParserParameters {\n string: boolean\n}\n\nclass JsonParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.string = defaults(p.string, false)\n\n this.json = {\n name: this.name,\n path: this.path,\n data: {}\n }\n }\n\n get type () { return 'json' }\n get __objName () { return 'json' }\n get isJson () { return true }\n\n _parse () {\n if (this.streamer.isBinary() || this.string) {\n this.json.data = JSON.parse(this.streamer.asText())\n } else {\n this.json.data = this.streamer.data\n }\n }\n}\n\nParserRegistry.add('json', JsonParser)\n\nexport default JsonParser\n","/**\n * @file Msgpack Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport Parser, { ParserParameters } from './parser'\n\nimport { decodeMsgpack } from '../../lib/mmtf.es6'\nimport Streamer from '../streamer/streamer';\n\nclass MsgpackParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.msgpack = {\n name: this.name,\n path: this.path,\n data: undefined\n }\n }\n\n get type () { return 'msgpack' }\n get __objName () { return 'msgpack' }\n get isBinary () { return true }\n\n _parse () {\n if (Debug) Log.time('MsgpackParser._parse ' + this.name)\n\n this.msgpack.data = decodeMsgpack(this.streamer.data)\n\n if (Debug) Log.timeEnd('MsgpackParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('msgpack', MsgpackParser)\n\nexport default MsgpackParser\n","/**\n * @file Netcdf Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport Parser, { ParserParameters } from './parser'\nimport NetcdfReader from '../utils/netcdf-reader'\nimport Streamer from '../streamer/streamer';\n\nclass NetcdfParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.netcdf = {\n name: this.name,\n path: this.path,\n data: undefined\n }\n }\n\n get type () { return 'netcdf' }\n get __objName () { return 'netcdf' }\n get isBinary () { return true }\n\n _parse () {\n if (Debug) Log.time('NetcdfParser._parse ' + this.name)\n\n this.netcdf.data = new NetcdfReader(this.streamer.data)\n\n if (Debug) Log.timeEnd('NetcdfParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('netcdf', NetcdfParser)\n\nexport default NetcdfParser\n","/**\n * @file Text Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport Parser, { ParserParameters } from './parser'\nimport Streamer from '../streamer/streamer';\n\nclass TextParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n super(streamer, params)\n\n this.text = {\n\n name: this.name,\n path: this.path,\n data: ''\n\n }\n }\n\n get type () { return 'text' }\n get __objName () { return 'text' }\n\n _parse () {\n this.text.data = this.streamer.asText()\n }\n}\n\nParserRegistry.add('txt', TextParser)\nParserRegistry.add('text', TextParser)\n\nexport default TextParser\n","/**\n * @file Parse Xml\n * @author Alexander Rose \n * @private\n */\n\n// https://github.com/segmentio/xml-parser\n// MIT license\n\nexport type XMLNodeAttributes = { [k: string]: any }\nexport interface XMLNode {\n name?: string\n content?: string\n attributes: XMLNodeAttributes\n children?: XMLNode[]\n}\n\nconst reStrip = /^['\"]|['\"]$/g\nconst reTag = /^<([\\w-:.]+)\\s*/\nconst reContent = /^([^<]*)/\nconst reAttr = /([\\w:-]+)\\s*=\\s*(\"[^\"]*\"|'[^']*'|\\w+)\\s*/\n\nfunction strip (val: string) {\n return val.replace(reStrip, '')\n}\n\nexport function parseXml (xml: string) {\n // trim and strip comments\n xml = xml.trim().replace(//g, '')\n\n return document()\n\n function document () {\n return {\n declaration: declaration(),\n root: tag()\n }\n }\n\n function declaration () {\n const m = match(/^<\\?xml\\s*/)\n if (!m) return\n\n // tag\n const node: XMLNode = {\n attributes: {}\n }\n\n // attributes\n while (!(eos() || is('?>'))) {\n const attr = attribute()\n if (!attr) return node\n node.attributes[attr.name] = attr.value\n }\n match(/\\?>\\s*/)\n return node\n }\n\n function tag () {\n const m = match(reTag)\n if (!m) return\n\n // name\n const node: XMLNode = {\n name: m[1],\n attributes: {},\n children: []\n }\n\n // attributes\n while (!(eos() || is('>') || is('?>') || is('/>'))) {\n const attr = attribute()\n if (!attr) return node\n node.attributes[attr.name] = attr.value\n }\n\n // self closing tag\n if (match(/^\\s*\\/>\\s*/)) {\n return node\n }\n match(/\\??>\\s*/)\n\n // content\n node.content = content()\n\n // children\n let child\n while ((child = tag())) {\n node.children!.push(child)\n }\n\n // closing\n match(/^<\\/[\\w-:.]+>\\s*/)\n return node\n }\n\n function content () {\n const m = match(reContent)\n if (m) return m[1]\n return ''\n }\n\n function attribute () {\n const m = match(reAttr)\n if (!m) return\n return { name: m[1], value: strip(m[2]) }\n }\n\n function match (re: RegExp) {\n const m = xml.match(re)\n if (!m) return\n xml = xml.slice(m[0].length)\n return m\n }\n\n function eos () {\n return xml.length === 0\n }\n\n function is (prefix: string) {\n return xml.indexOf(prefix) === 0\n }\n}\n","/**\n * @file Xml Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { defaults } from '../utils'\n// @ts-ignore: unused import XMLNode required for declaration only\nimport { parseXml, XMLNode } from '../utils/parse-xml'\nimport Parser, { ParserParameters } from './parser'\nimport Streamer from '../streamer/streamer';\n\nexport interface XmlParserParameters extends ParserParameters {\n useDomParser: boolean\n}\n\nclass XmlParser extends Parser {\n xml: {\n name: string\n path: string\n data: any\n }\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.useDomParser = defaults(p.useDomParser, false)\n\n this.xml = {\n name: this.name,\n path: this.path,\n data: {}\n }\n }\n\n get type () { return 'xml' }\n get __objName () { return 'xml' }\n get isXml () { return true }\n\n __xmlParser (xml: string) {\n return parseXml(xml)\n }\n\n __domParser (xml: string) {\n const domParser = new (window as any).DOMParser() as DOMParser\n return domParser.parseFromString(xml, 'text/xml')\n }\n\n _parse () {\n if (Debug) Log.time('XmlParser._parse ' + this.name)\n\n if (this.useDomParser) {\n if (this.streamer.data instanceof Document) { //TS conversion: stripped the window prefix from window.Document\n this.xml.data = this.streamer.data\n } else {\n this.xml.data = this.__domParser(this.streamer.asText())\n }\n } else {\n this.xml.data = this.__xmlParser(this.streamer.asText())\n }\n\n if (Debug) Log.timeEnd('XmlParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('xml', XmlParser)\n\nexport default XmlParser\n","/**\n * @file Validation\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Color } from 'three'\n\nimport { Debug, Log } from '../globals'\nimport { defaults } from '../utils'\nimport { ClashPicker } from '../utils/picker'\nimport { uniformArray3 } from '../math/array-utils'\nimport { guessElement } from '../structure/structure-utils'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Structure from '../structure/structure'\n\nfunction getNamedItem(a: NamedNodeMap, name: string) {\n const item = a.getNamedItem(name)\n return item !== null ? item.value : ''\n}\n\nfunction getSele (a: NamedNodeMap, atomname?: string, useAltcode = false) {\n const icode = getNamedItem(a, 'icode').trim()\n const chain = getNamedItem(a, 'chain').trim()\n const altcode = getNamedItem(a, 'altcode')\n let sele = getNamedItem(a, 'resnum')\n if (icode) sele += '^' + icode\n if (chain) sele += ':' + chain\n if (atomname) sele += '.' + atomname\n if (useAltcode && altcode.trim()) sele += '%' + altcode\n sele += '/' + (parseInt(getNamedItem(a, 'model')) - 1)\n return sele\n}\n\nfunction getResSele (a: NamedNodeMap) {\n const chain = getNamedItem(a, 'chain').trim()\n const rescode = getNamedItem(a, 'rescode')\n const resnum = getNamedItem(a, 'resnum')\n let sele = `[${rescode}]${resnum}`\n if (chain) sele += `:${chain}`\n return sele\n}\n\nfunction setBitDict (dict: { [k: string]: number }, key: string, bit: number) {\n if (dict[ key ] === undefined) {\n dict[ key ] = bit\n } else {\n dict[ key ] |= bit\n }\n}\n\nfunction hasAttrValue (attr: Attr|null, value: string) {\n return attr !== null && attr.value === value\n}\n\nfunction getAtomSele (ap: AtomProxy) {\n const icode = ap.inscode\n const chain = ap.chainname\n const atomname = ap.atomname\n const altcode = ap.altloc\n let sele = ap.resno + ''\n if (icode) sele += '^' + icode\n if (chain) sele += ':' + chain\n if (atomname) sele += '.' + atomname\n if (altcode) sele += '%' + altcode\n sele += '/' + ap.modelIndex\n return sele\n}\n\nfunction getProblemCount (clashDict: { [k: string]: { [k: string]: string } }, g: Element, ga: NamedNodeMap) {\n let geoProblemCount = 0\n\n const clashes = g.getElementsByTagName('clash')\n for (let j = 0, jl = clashes.length; j < jl; ++j) {\n if (clashDict[ getNamedItem(clashes[ j ].attributes, 'cid') ]) {\n geoProblemCount += 1\n break\n }\n }\n\n const angleOutliers = g.getElementsByTagName('angle-outlier')\n if (angleOutliers.length > 0) {\n geoProblemCount += 1\n }\n\n const bondOutliers = g.getElementsByTagName('bond-outlier')\n if (bondOutliers.length > 0) {\n geoProblemCount += 1\n }\n\n const planeOutliers = g.getElementsByTagName('plane-outlier')\n if (planeOutliers.length > 0) {\n geoProblemCount += 1\n }\n\n if (hasAttrValue(ga.getNamedItem('rota'), 'OUTLIER')) {\n geoProblemCount += 1\n }\n\n if (hasAttrValue(ga.getNamedItem('rama'), 'OUTLIER')) {\n geoProblemCount += 1\n }\n\n if (hasAttrValue(ga.getNamedItem('RNApucker'), 'outlier')) {\n geoProblemCount += 1\n }\n\n return geoProblemCount\n}\n\nclass Validation {\n rsrzDict: { [k: string]: number } = {}\n rsccDict: { [k: string]: number } = {}\n /**\n * Random Coil Index (RCI) - evaluates the proximity of residue structural\n * and dynamic properties to the properties of flexible random coil regions\n * from NMR chemical shifts.\n *\n * Mark V. Berjanskii and David S. Wishart (2005)\n * A Simple Method To Predict Protein Flexibility Using Secondary Chemical Shifts\n * J. Am. Chem. Soc., 2005, 127 (43), pp 14970–14971\n * http://pubs.acs.org/doi/abs/10.1021/ja054842f\n *\n * Mark V. Berjanskii and David S. Wishart (2008)\n * Application of the random coil index to studying protein flexibility.\n * J Biomol NMR. 2008 Jan;40(1):31-48. Epub 2007 Nov 6.\n * http://www.springerlink.com/content/2966482w10306126/\n */\n rciDict: { [k: string]: number } = {}\n clashDict: { [k: string]: { [k: string]: string } } = {}\n clashArray: { [k: string]: string }[] = []\n geoDict: { [k: string]: number } = {}\n geoAtomDict: { [k: string]: { [k: string]: number } } = {}\n atomDict: { [k: string]: boolean|number } = {}\n clashSele = 'NONE'\n\n constructor (readonly name: string, readonly path: string) {}\n\n get type () { return 'validation' }\n\n fromXml (xml: XMLDocument) {\n if (Debug) Log.time('Validation.fromXml')\n\n const rsrzDict = this.rsrzDict\n const rsccDict = this.rsccDict\n const rciDict = this.rciDict\n const clashDict = this.clashDict\n const clashArray = this.clashArray\n const geoDict = this.geoDict\n const geoAtomDict = this.geoAtomDict\n const atomDict = this.atomDict\n\n const entries = xml.getElementsByTagName('Entry')\n if (entries.length === 1) {\n const chemicalShiftLists = entries[0].getElementsByTagName('chemical_shift_list')\n if (chemicalShiftLists.length === 1) {\n const randomCoilIndices = chemicalShiftLists[0].getElementsByTagName('random_coil_index')\n for (let j = 0, jl = randomCoilIndices.length; j < jl; ++j) {\n const rcia = randomCoilIndices[ j ].attributes\n const sele = getResSele(rcia)\n rciDict[ sele ] = parseFloat(getNamedItem(rcia, 'value'))\n }\n }\n }\n\n const groups = xml.getElementsByTagName('ModelledSubgroup')\n\n const _clashDict: { [k: string]: { [k: string]: string } } = {}\n const clashList: string[] = []\n\n if (Debug) Log.time('Validation.fromXml#clashDict')\n\n for (let i = 0, il = groups.length; i < il; ++i) {\n const g = groups[ i ]\n const ga = g.attributes\n\n const sele = getSele(ga)\n if (ga.getNamedItem('rsrz') !== null) {\n rsrzDict[ sele ] = parseFloat(getNamedItem(ga, 'rsrz'))\n }\n if (ga.getNamedItem('rscc') !== null) {\n rsccDict[ sele ] = parseFloat(getNamedItem(ga, 'rscc'))\n }\n const seleAttr = xml.createAttribute('sele')\n seleAttr.value = sele\n ga.setNamedItem(seleAttr)\n\n const clashes = g.getElementsByTagName('clash')\n\n for (let j = 0, jl = clashes.length; j < jl; ++j) {\n const ca = clashes[ j ].attributes\n const atom = getNamedItem(ca, 'atom')\n\n if (guessElement(atom) !== 'H') {\n const cid = getNamedItem(ca, 'cid')\n const atomSele = getSele(ga, atom, true)\n atomDict[ atomSele ] = true\n\n if (_clashDict[ cid ] === undefined) {\n _clashDict[ cid ] = {\n sele1: atomSele,\n res1: sele\n }\n } else {\n const c = _clashDict[ cid ]\n if (c.res1 !== sele) {\n c.sele2 = atomSele\n c.res2 = sele\n clashList.push(c.res1, sele)\n clashDict[ cid ] = c\n clashArray.push(c)\n }\n }\n }\n }\n }\n\n if (Debug) Log.timeEnd('Validation.fromXml#clashDict')\n\n for (let i = 0, il = groups.length; i < il; ++i) {\n const g = groups[ i ]\n const ga = g.attributes\n\n const sele = getNamedItem(ga, 'sele')\n const isPolymer = getNamedItem(ga, 'seq') !== '.'\n\n if (isPolymer) {\n const geoProblemCount = getProblemCount(clashDict, g, ga)\n if (geoProblemCount > 0) {\n geoDict[ sele ] = geoProblemCount\n }\n } else {\n const clashes = g.getElementsByTagName('clash')\n const mogBondOutliers = g.getElementsByTagName('mog-bond-outlier')\n const mogAngleOutliers = g.getElementsByTagName('mog-angle-outlier')\n\n if (mogBondOutliers.length > 0 || mogAngleOutliers.length > 0 || clashes.length > 0) {\n const atomDict = {}\n geoAtomDict[ sele ] = atomDict\n\n for (let j = 0, jl = clashes.length; j < jl; ++j) {\n const ca = clashes[ j ].attributes\n if (clashDict[ getNamedItem(ca, 'cid') ]) {\n setBitDict(atomDict, getNamedItem(ca, 'atom'), 1)\n }\n }\n\n for (let j = 0, jl = mogBondOutliers.length; j < jl; ++j) {\n const mbo = mogBondOutliers[ j ].attributes\n getNamedItem(mbo, 'atoms').split(',').forEach(function (atomname) {\n setBitDict(atomDict, atomname, 2)\n })\n }\n\n for (let j = 0, jl = mogAngleOutliers.length; j < jl; ++j) {\n const mao = mogAngleOutliers[ j ].attributes\n getNamedItem(mao, 'atoms').split(',').forEach(function (atomname) {\n setBitDict(atomDict, atomname, 4)\n })\n }\n }\n }\n }\n\n this.clashSele = clashList.length ? clashList.join(' OR ') : 'NONE'\n\n if (Debug) Log.timeEnd('Validation.fromXml')\n }\n\n getClashData (params: { color: number|string|Color, structure: Structure }) {\n if (Debug) Log.time('Validation.getClashData')\n\n const p = params || {}\n\n const s = p.structure\n const atomSet = s.atomSet! // TODO\n const c = new Color(defaults(p.color, '#f0027f'))\n\n const ap1 = s.getAtomProxy()\n const ap2 = s.getAtomProxy()\n const vDir = new Vector3()\n const vPos1 = new Vector3()\n const vPos2 = new Vector3()\n\n const clashArray = this.clashArray\n const n = clashArray.length\n\n const position1 = new Float32Array(n * 3)\n const position2 = new Float32Array(n * 3)\n const color = uniformArray3(n, c.r, c.g, c.b) as Float32Array\n const radius = new Float32Array(n)\n const picking = new Float32Array(n)\n\n if (Debug) Log.time('Validation.getClashData#atomDict')\n\n const atomDict = this.atomDict\n\n s.eachAtom(function (ap) {\n const sele = getAtomSele(ap)\n if (atomDict[ sele ] === true) {\n atomDict[ sele ] = ap.index\n }\n })\n\n if (Debug) Log.timeEnd('Validation.getClashData#atomDict')\n\n let i = 0\n\n clashArray.forEach(function (c, idx) {\n ap1.index = atomDict[ c.sele1 ] as number // TODO\n ap2.index = atomDict[ c.sele2 ] as number // TODO\n\n if (ap1.index === undefined || ap2.index === undefined ||\n !atomSet.isSet(ap1.index, ap2.index)) return\n\n vDir.subVectors(ap2 as any, ap1 as any).setLength(ap1.vdw) // TODO\n vPos1.copy(ap1 as any).add(vDir) // TODO\n\n vDir.subVectors(ap1 as any, ap2 as any).setLength(ap2.vdw) // TODO\n vPos2.copy(ap2 as any).add(vDir) // TODO\n\n const dHalf = ap1.distanceTo(ap2) / 2\n const r1 = Math.sqrt(ap1.vdw * ap1.vdw - dHalf * dHalf)\n const r2 = Math.sqrt(ap2.vdw * ap2.vdw - dHalf * dHalf)\n\n vPos1.toArray(position1 as any, i * 3) // TODO\n vPos2.toArray(position2 as any, i * 3)\n radius[ i ] = (r1 + r2) / 2\n picking[ i ] = idx\n\n ++i\n })\n\n if (Debug) Log.timeEnd('Validation.getClashData')\n\n return {\n position1: position1.subarray(0, i * 3),\n position2: position2.subarray(0, i * 3),\n color: color.subarray(0, i * 3),\n color2: color.subarray(0, i * 3),\n radius: radius.subarray(0, i),\n picking: new ClashPicker(picking.subarray(0, i), this, s)\n }\n }\n}\n\nexport default Validation\n","\n// https://github.com/nodeca/pako\n// MIT License, Copyright (c) 2014 by Vitaly Puzrin\n\n\n// 'use strict';\n\n\n// var TYPED_OK = (typeof Uint8Array !== 'undefined') &&\n// (typeof Uint16Array !== 'undefined') &&\n// (typeof Int32Array !== 'undefined');\n\n\nfunction assign(obj /*from1, from2, from3, ...*/) {\n var sources = Array.prototype.slice.call(arguments, 1);\n while (sources.length) {\n var source = sources.shift();\n if (!source) { continue; }\n\n if (typeof source !== 'object') {\n throw new TypeError(source + 'must be non-object');\n }\n\n for (var p in source) {\n if (source.hasOwnProperty(p)) {\n obj[p] = source[p];\n }\n }\n }\n\n return obj;\n}\n\n\n// reduce buffer size, avoiding mem copy\nfunction shrinkBuf(buf, size) {\n if (buf.length === size) { return buf; }\n if (buf.subarray) { return buf.subarray(0, size); }\n buf.length = size;\n return buf;\n}\n\n\nfunction arraySet(dest, src, src_offs, len, dest_offs) {\n if (src.subarray && dest.subarray) {\n dest.set(src.subarray(src_offs, src_offs + len), dest_offs);\n return;\n }\n // Fallback to ordinary array\n for (var i = 0; i < len; i++) {\n dest[dest_offs + i] = src[src_offs + i];\n }\n}\n\n// Join array of chunks to single array.\nfunction flattenChunks(chunks) {\n var i, l, len, pos, chunk, result;\n\n // calculate data length\n len = 0;\n for (i = 0, l = chunks.length; i < l; i++) {\n len += chunks[i].length;\n }\n\n // join chunks\n result = new Uint8Array(len);\n pos = 0;\n for (i = 0, l = chunks.length; i < l; i++) {\n chunk = chunks[i];\n result.set(chunk, pos);\n pos += chunk.length;\n }\n\n return result;\n}\n\n// 'use strict';\n\n// Note: adler32 takes 12% for level 0 and 2% for level 6.\n// It doesn't worth to make additional optimizationa as in original.\n// Small size is preferable.\n\nfunction adler32(adler, buf, len, pos) {\n var s1 = (adler & 0xffff) |0,\n s2 = ((adler >>> 16) & 0xffff) |0,\n n = 0;\n\n while (len !== 0) {\n // Set limit ~ twice less than 5552, to keep\n // s2 in 31-bits, because we force signed ints.\n // in other case %= will fail.\n n = len > 2000 ? 2000 : len;\n len -= n;\n\n do {\n s1 = (s1 + buf[pos++]) |0;\n s2 = (s2 + s1) |0;\n } while (--n);\n\n s1 %= 65521;\n s2 %= 65521;\n }\n\n return (s1 | (s2 << 16)) |0;\n}\n\n// 'use strict';\n\n// Note: we can't get significant speed boost here.\n// So write code to minimize size - no pregenerated tables\n// and array tools dependencies.\n\n\n// Use ordinary array, since untyped makes no boost here\nfunction makeTable() {\n var c, table = [];\n\n for (var n = 0; n < 256; n++) {\n c = n;\n for (var k = 0; k < 8; k++) {\n c = ((c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));\n }\n table[n] = c;\n }\n\n return table;\n}\n\n// Create table on load. Just 255 signed longs. Not a problem.\nvar crcTable = makeTable();\n\n\nfunction crc32(crc, buf, len, pos) {\n var t = crcTable,\n end = pos + len;\n\n crc ^= -1;\n\n for (var i = pos; i < end; i++) {\n crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF];\n }\n\n return (crc ^ (-1)); // >>> 0;\n}\n\n// 'use strict';\n\n// See state defs from inflate.js\nvar BAD$1 = 30; /* got a data error -- remain here until reset */\nvar TYPE$1 = 12; /* i: waiting for type bits, including last-flag bit */\n\n/*\n Decode literal, length, and distance codes and write out the resulting\n literal and match bytes until either not enough input or output is\n available, an end-of-block is encountered, or a data error is encountered.\n When large enough input and output buffers are supplied to inflate(), for\n example, a 16K input buffer and a 64K output buffer, more than 95% of the\n inflate execution time is spent in this routine.\n\n Entry assumptions:\n\n state.mode === LEN\n strm.avail_in >= 6\n strm.avail_out >= 258\n start >= strm.avail_out\n state.bits < 8\n\n On return, state.mode is one of:\n\n LEN -- ran out of enough output space or enough available input\n TYPE -- reached end of block code, inflate() to interpret next block\n BAD -- error in block data\n\n Notes:\n\n - The maximum input bits used by a length/distance pair is 15 bits for the\n length code, 5 bits for the length extra, 15 bits for the distance code,\n and 13 bits for the distance extra. This totals 48 bits, or six bytes.\n Therefore if strm.avail_in >= 6, then there is enough input to avoid\n checking for available input while decoding.\n\n - The maximum bytes that a single length/distance pair can output is 258\n bytes, which is the maximum length that can be coded. inflate_fast()\n requires strm.avail_out >= 258 for each loop to avoid checking for\n output space.\n */\n// module.exports =\nfunction inflate_fast(strm, start) {\n var state;\n var _in; /* local strm.input */\n var last; /* have enough input while in < last */\n var _out; /* local strm.output */\n var beg; /* inflate()'s initial strm.output */\n var end; /* while out < end, enough space available */\n//#ifdef INFLATE_STRICT\n var dmax; /* maximum distance from zlib header */\n//#endif\n var wsize; /* window size or zero if not using window */\n var whave; /* valid bytes in the window */\n var wnext; /* window write index */\n // Use `s_window` instead `window`, avoid conflict with instrumentation tools\n var s_window; /* allocated sliding window, if wsize != 0 */\n var hold; /* local strm.hold */\n var bits; /* local strm.bits */\n var lcode; /* local strm.lencode */\n var dcode; /* local strm.distcode */\n var lmask; /* mask for first level of length codes */\n var dmask; /* mask for first level of distance codes */\n var here; /* retrieved table entry */\n var op; /* code bits, operation, extra bits, or */\n /* window position, window bytes to copy */\n var len; /* match length, unused bytes */\n var dist; /* match distance */\n var from; /* where to copy match from */\n var from_source;\n\n\n var input, output; // JS specific, because we have no pointers\n\n /* copy state to local variables */\n state = strm.state;\n //here = state.here;\n _in = strm.next_in;\n input = strm.input;\n last = _in + (strm.avail_in - 5);\n _out = strm.next_out;\n output = strm.output;\n beg = _out - (start - strm.avail_out);\n end = _out + (strm.avail_out - 257);\n//#ifdef INFLATE_STRICT\n dmax = state.dmax;\n//#endif\n wsize = state.wsize;\n whave = state.whave;\n wnext = state.wnext;\n s_window = state.window;\n hold = state.hold;\n bits = state.bits;\n lcode = state.lencode;\n dcode = state.distcode;\n lmask = (1 << state.lenbits) - 1;\n dmask = (1 << state.distbits) - 1;\n\n\n /* decode literals and length/distances until end-of-block or not enough\n input data or output space */\n\n top:\n do {\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n\n here = lcode[hold & lmask];\n\n dolen:\n for (;;) { // Goto emulation\n op = here >>> 24/*here.bits*/;\n hold >>>= op;\n bits -= op;\n op = (here >>> 16) & 0xff/*here.op*/;\n if (op === 0) { /* literal */\n //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n // \"inflate: literal '%c'\\n\" :\n // \"inflate: literal 0x%02x\\n\", here.val));\n output[_out++] = here & 0xffff/*here.val*/;\n }\n else if (op & 16) { /* length base */\n len = here & 0xffff/*here.val*/;\n op &= 15; /* number of extra bits */\n if (op) {\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n len += hold & ((1 << op) - 1);\n hold >>>= op;\n bits -= op;\n }\n //Tracevv((stderr, \"inflate: length %u\\n\", len));\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n here = dcode[hold & dmask];\n\n dodist:\n for (;;) { // goto emulation\n op = here >>> 24/*here.bits*/;\n hold >>>= op;\n bits -= op;\n op = (here >>> 16) & 0xff/*here.op*/;\n\n if (op & 16) { /* distance base */\n dist = here & 0xffff/*here.val*/;\n op &= 15; /* number of extra bits */\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n }\n dist += hold & ((1 << op) - 1);\n//#ifdef INFLATE_STRICT\n if (dist > dmax) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD$1;\n break top;\n }\n//#endif\n hold >>>= op;\n bits -= op;\n //Tracevv((stderr, \"inflate: distance %u\\n\", dist));\n op = _out - beg; /* max distance in output */\n if (dist > op) { /* see if copy from window */\n op = dist - op; /* distance back in window */\n if (op > whave) {\n if (state.sane) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD$1;\n break top;\n }\n\n// (!) This block is disabled in zlib defailts,\n// don't enable it for binary compatibility\n//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n// if (len <= op - whave) {\n// do {\n// output[_out++] = 0;\n// } while (--len);\n// continue top;\n// }\n// len -= op - whave;\n// do {\n// output[_out++] = 0;\n// } while (--op > whave);\n// if (op === 0) {\n// from = _out - dist;\n// do {\n// output[_out++] = output[from++];\n// } while (--len);\n// continue top;\n// }\n//#endif\n }\n from = 0; // window index\n from_source = s_window;\n if (wnext === 0) { /* very common case */\n from += wsize - op;\n if (op < len) { /* some from window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n else if (wnext < op) { /* wrap around window */\n from += wsize + wnext - op;\n op -= wnext;\n if (op < len) { /* some from end of window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = 0;\n if (wnext < len) { /* some from start of window */\n op = wnext;\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n }\n else { /* contiguous in window */\n from += wnext - op;\n if (op < len) { /* some from window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n while (len > 2) {\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n len -= 3;\n }\n if (len) {\n output[_out++] = from_source[from++];\n if (len > 1) {\n output[_out++] = from_source[from++];\n }\n }\n }\n else {\n from = _out - dist; /* copy direct from output */\n do { /* minimum length is three */\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n len -= 3;\n } while (len > 2);\n if (len) {\n output[_out++] = output[from++];\n if (len > 1) {\n output[_out++] = output[from++];\n }\n }\n }\n }\n else if ((op & 64) === 0) { /* 2nd level distance code */\n here = dcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n continue dodist;\n }\n else {\n strm.msg = 'invalid distance code';\n state.mode = BAD$1;\n break top;\n }\n\n break; // need to emulate goto via \"continue\"\n }\n }\n else if ((op & 64) === 0) { /* 2nd level length code */\n here = lcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n continue dolen;\n }\n else if (op & 32) { /* end-of-block */\n //Tracevv((stderr, \"inflate: end of block\\n\"));\n state.mode = TYPE$1;\n break top;\n }\n else {\n strm.msg = 'invalid literal/length code';\n state.mode = BAD$1;\n break top;\n }\n\n break; // need to emulate goto via \"continue\"\n }\n } while (_in < last && _out < end);\n\n /* return unused bytes (on entry, bits < 8, so in won't go too far back) */\n len = bits >> 3;\n _in -= len;\n bits -= len << 3;\n hold &= (1 << bits) - 1;\n\n /* update state and return */\n strm.next_in = _in;\n strm.next_out = _out;\n strm.avail_in = (_in < last ? 5 + (last - _in) : 5 - (_in - last));\n strm.avail_out = (_out < end ? 257 + (end - _out) : 257 - (_out - end));\n state.hold = hold;\n state.bits = bits;\n return;\n};\n\n// 'use strict';\n\n\n// var utils = require('../utils/common');\n\nvar MAXBITS = 15;\nvar ENOUGH_LENS$1 = 852;\nvar ENOUGH_DISTS$1 = 592;\n//var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);\n\nvar CODES$1 = 0;\nvar LENS$1 = 1;\nvar DISTS$1 = 2;\n\nvar lbase = [ /* Length codes 257..285 base */\n 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,\n 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0\n];\n\nvar lext = [ /* Length codes 257..285 extra */\n 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,\n 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78\n];\n\nvar dbase = [ /* Distance codes 0..29 base */\n 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,\n 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,\n 8193, 12289, 16385, 24577, 0, 0\n];\n\nvar dext = [ /* Distance codes 0..29 extra */\n 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,\n 23, 23, 24, 24, 25, 25, 26, 26, 27, 27,\n 28, 28, 29, 29, 64, 64\n];\n\n// module.exports =\nfunction inflate_table(type, lens, lens_index, codes, table, table_index, work, opts)\n{\n var bits = opts.bits;\n //here = opts.here; /* table entry for duplication */\n\n var len = 0; /* a code's length in bits */\n var sym = 0; /* index of code symbols */\n var min = 0, max = 0; /* minimum and maximum code lengths */\n var root = 0; /* number of index bits for root table */\n var curr = 0; /* number of index bits for current table */\n var drop = 0; /* code bits to drop for sub-table */\n var left = 0; /* number of prefix codes available */\n var used = 0; /* code entries in table used */\n var huff = 0; /* Huffman code */\n var incr; /* for incrementing code, index */\n var fill; /* index for replicating entries */\n var low; /* low bits for current root entry */\n var mask; /* mask for low root bits */\n var next; /* next available space in table */\n var base = null; /* base value table to use */\n var base_index = 0;\n// var shoextra; /* extra bits table to use */\n var end; /* use base and extra for symbol > end */\n var count = new Uint16Array(MAXBITS + 1); //[MAXBITS+1]; /* number of codes of each length */\n var offs = new Uint16Array(MAXBITS + 1); //[MAXBITS+1]; /* offsets in table for each length */\n var extra = null;\n var extra_index = 0;\n\n var here_bits, here_op, here_val;\n\n /*\n Process a set of code lengths to create a canonical Huffman code. The\n code lengths are lens[0..codes-1]. Each length corresponds to the\n symbols 0..codes-1. The Huffman code is generated by first sorting the\n symbols by length from short to long, and retaining the symbol order\n for codes with equal lengths. Then the code starts with all zero bits\n for the first code of the shortest length, and the codes are integer\n increments for the same length, and zeros are appended as the length\n increases. For the deflate format, these bits are stored backwards\n from their more natural integer increment ordering, and so when the\n decoding tables are built in the large loop below, the integer codes\n are incremented backwards.\n\n This routine assumes, but does not check, that all of the entries in\n lens[] are in the range 0..MAXBITS. The caller must assure this.\n 1..MAXBITS is interpreted as that code length. zero means that that\n symbol does not occur in this code.\n\n The codes are sorted by computing a count of codes for each length,\n creating from that a table of starting indices for each length in the\n sorted table, and then entering the symbols in order in the sorted\n table. The sorted table is work[], with that space being provided by\n the caller.\n\n The length counts are used for other purposes as well, i.e. finding\n the minimum and maximum length codes, determining if there are any\n codes at all, checking for a valid set of lengths, and looking ahead\n at length counts to determine sub-table sizes when building the\n decoding tables.\n */\n\n /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */\n for (len = 0; len <= MAXBITS; len++) {\n count[len] = 0;\n }\n for (sym = 0; sym < codes; sym++) {\n count[lens[lens_index + sym]]++;\n }\n\n /* bound code lengths, force root to be within code lengths */\n root = bits;\n for (max = MAXBITS; max >= 1; max--) {\n if (count[max] !== 0) { break; }\n }\n if (root > max) {\n root = max;\n }\n if (max === 0) { /* no symbols to code at all */\n //table.op[opts.table_index] = 64; //here.op = (var char)64; /* invalid code marker */\n //table.bits[opts.table_index] = 1; //here.bits = (var char)1;\n //table.val[opts.table_index++] = 0; //here.val = (var short)0;\n table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n\n //table.op[opts.table_index] = 64;\n //table.bits[opts.table_index] = 1;\n //table.val[opts.table_index++] = 0;\n table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n opts.bits = 1;\n return 0; /* no symbols, but wait for decoding to report error */\n }\n for (min = 1; min < max; min++) {\n if (count[min] !== 0) { break; }\n }\n if (root < min) {\n root = min;\n }\n\n /* check for an over-subscribed or incomplete set of lengths */\n left = 1;\n for (len = 1; len <= MAXBITS; len++) {\n left <<= 1;\n left -= count[len];\n if (left < 0) {\n return -1;\n } /* over-subscribed */\n }\n if (left > 0 && (type === CODES$1 || max !== 1)) {\n return -1; /* incomplete set */\n }\n\n /* generate offsets into symbol table for each length for sorting */\n offs[1] = 0;\n for (len = 1; len < MAXBITS; len++) {\n offs[len + 1] = offs[len] + count[len];\n }\n\n /* sort symbols by length, by symbol order within each length */\n for (sym = 0; sym < codes; sym++) {\n if (lens[lens_index + sym] !== 0) {\n work[offs[lens[lens_index + sym]]++] = sym;\n }\n }\n\n /*\n Create and fill in decoding tables. In this loop, the table being\n filled is at next and has curr index bits. The code being used is huff\n with length len. That code is converted to an index by dropping drop\n bits off of the bottom. For codes where len is less than drop + curr,\n those top drop + curr - len bits are incremented through all values to\n fill the table with replicated entries.\n\n root is the number of index bits for the root table. When len exceeds\n root, sub-tables are created pointed to by the root entry with an index\n of the low root bits of huff. This is saved in low to check for when a\n new sub-table should be started. drop is zero when the root table is\n being filled, and drop is root when sub-tables are being filled.\n\n When a new sub-table is needed, it is necessary to look ahead in the\n code lengths to determine what size sub-table is needed. The length\n counts are used for this, and so count[] is decremented as codes are\n entered in the tables.\n\n used keeps track of how many table entries have been allocated from the\n provided *table space. It is checked for LENS and DIST tables against\n the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in\n the initial root table size constants. See the comments in inftrees.h\n for more information.\n\n sym increments through all symbols, and the loop terminates when\n all codes of length max, i.e. all codes, have been processed. This\n routine permits incomplete codes, so another loop after this one fills\n in the rest of the decoding tables with invalid code markers.\n */\n\n /* set up for code type */\n // poor man optimization - use if-else instead of switch,\n // to avoid deopts in old v8\n if (type === CODES$1) {\n base = extra = work; /* dummy value--not used */\n end = 19;\n\n } else if (type === LENS$1) {\n base = lbase;\n base_index -= 257;\n extra = lext;\n extra_index -= 257;\n end = 256;\n\n } else { /* DISTS */\n base = dbase;\n extra = dext;\n end = -1;\n }\n\n /* initialize opts for loop */\n huff = 0; /* starting code */\n sym = 0; /* starting code symbol */\n len = min; /* starting code length */\n next = table_index; /* current table to fill in */\n curr = root; /* current table index bits */\n drop = 0; /* current bits to drop from code for index */\n low = -1; /* trigger new sub-table when len > root */\n used = 1 << root; /* use root table entries */\n mask = used - 1; /* mask for comparing low */\n\n /* check available table space */\n if ((type === LENS$1 && used > ENOUGH_LENS$1) ||\n (type === DISTS$1 && used > ENOUGH_DISTS$1)) {\n return 1;\n }\n\n var i = 0;\n /* process all codes and make table entries */\n for (;;) {\n i++;\n /* create table entry */\n here_bits = len - drop;\n if (work[sym] < end) {\n here_op = 0;\n here_val = work[sym];\n }\n else if (work[sym] > end) {\n here_op = extra[extra_index + work[sym]];\n here_val = base[base_index + work[sym]];\n }\n else {\n here_op = 32 + 64; /* end of block */\n here_val = 0;\n }\n\n /* replicate for those indices with low len bits equal to huff */\n incr = 1 << (len - drop);\n fill = 1 << curr;\n min = fill; /* save offset to next table */\n do {\n fill -= incr;\n table[next + (huff >> drop) + fill] = (here_bits << 24) | (here_op << 16) | here_val |0;\n } while (fill !== 0);\n\n /* backwards increment the len-bit code huff */\n incr = 1 << (len - 1);\n while (huff & incr) {\n incr >>= 1;\n }\n if (incr !== 0) {\n huff &= incr - 1;\n huff += incr;\n } else {\n huff = 0;\n }\n\n /* go to next symbol, update count, len */\n sym++;\n if (--count[len] === 0) {\n if (len === max) { break; }\n len = lens[lens_index + work[sym]];\n }\n\n /* create new sub-table if needed */\n if (len > root && (huff & mask) !== low) {\n /* if first time, transition to sub-tables */\n if (drop === 0) {\n drop = root;\n }\n\n /* increment past last table */\n next += min; /* here min is 1 << curr */\n\n /* determine length of next table */\n curr = len - drop;\n left = 1 << curr;\n while (curr + drop < max) {\n left -= count[curr + drop];\n if (left <= 0) { break; }\n curr++;\n left <<= 1;\n }\n\n /* check for enough space */\n used += 1 << curr;\n if ((type === LENS$1 && used > ENOUGH_LENS$1) ||\n (type === DISTS$1 && used > ENOUGH_DISTS$1)) {\n return 1;\n }\n\n /* point entry in root table to sub-table */\n low = huff & mask;\n /*table.op[low] = curr;\n table.bits[low] = root;\n table.val[low] = next - opts.table_index;*/\n table[low] = (root << 24) | (curr << 16) | (next - table_index) |0;\n }\n }\n\n /* fill in remaining table entry if code is incomplete (guaranteed to have\n at most one remaining entry, since if the code is incomplete, the\n maximum code length that was allowed to get this far is one bit) */\n if (huff !== 0) {\n //table.op[next + huff] = 64; /* invalid code marker */\n //table.bits[next + huff] = len - drop;\n //table.val[next + huff] = 0;\n table[next + huff] = ((len - drop) << 24) | (64 << 16) |0;\n }\n\n /* set return parameters */\n //opts.table_index += used;\n opts.bits = root;\n return 0;\n};\n\n// 'use strict';\n\n\n// var utils = require('../utils/common');\n// var adler32 = require('./adler32');\n// var crc32 = require('./crc32');\n// var inflate_fast = require('./inffast');\n// var inflate_table = require('./inftrees');\n\nvar CODES = 0;\nvar LENS = 1;\nvar DISTS = 2;\n\n/* Public constants ==========================================================*/\n/* ===========================================================================*/\n\n\n/* Allowed flush values; see deflate() and inflate() below for details */\n//var Z_NO_FLUSH = 0;\n//var Z_PARTIAL_FLUSH = 1;\n//var Z_SYNC_FLUSH = 2;\n//var Z_FULL_FLUSH = 3;\nvar Z_FINISH = 4;\nvar Z_BLOCK = 5;\nvar Z_TREES = 6;\n\n\n/* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\nvar Z_OK = 0;\nvar Z_STREAM_END = 1;\nvar Z_NEED_DICT = 2;\n//var Z_ERRNO = -1;\nvar Z_STREAM_ERROR = -2;\nvar Z_DATA_ERROR = -3;\nvar Z_MEM_ERROR = -4;\nvar Z_BUF_ERROR = -5;\n//var Z_VERSION_ERROR = -6;\n\n/* The deflate compression method */\nvar Z_DEFLATED = 8;\n\n\n/* STATES ====================================================================*/\n/* ===========================================================================*/\n\n\nvar HEAD = 1; /* i: waiting for magic header */\nvar FLAGS = 2; /* i: waiting for method and flags (gzip) */\nvar TIME = 3; /* i: waiting for modification time (gzip) */\nvar OS = 4; /* i: waiting for extra flags and operating system (gzip) */\nvar EXLEN = 5; /* i: waiting for extra length (gzip) */\nvar EXTRA = 6; /* i: waiting for extra bytes (gzip) */\nvar NAME = 7; /* i: waiting for end of file name (gzip) */\nvar COMMENT = 8; /* i: waiting for end of comment (gzip) */\nvar HCRC = 9; /* i: waiting for header crc (gzip) */\nvar DICTID = 10; /* i: waiting for dictionary check value */\nvar DICT = 11; /* waiting for inflateSetDictionary() call */\nvar TYPE = 12; /* i: waiting for type bits, including last-flag bit */\nvar TYPEDO = 13; /* i: same, but skip check to exit inflate on new block */\nvar STORED = 14; /* i: waiting for stored size (length and complement) */\nvar COPY_ = 15; /* i/o: same as COPY below, but only first time in */\nvar COPY = 16; /* i/o: waiting for input or output to copy stored block */\nvar TABLE = 17; /* i: waiting for dynamic block table lengths */\nvar LENLENS = 18; /* i: waiting for code length code lengths */\nvar CODELENS = 19; /* i: waiting for length/lit and distance code lengths */\nvar LEN_ = 20; /* i: same as LEN below, but only first time in */\nvar LEN = 21; /* i: waiting for length/lit/eob code */\nvar LENEXT = 22; /* i: waiting for length extra bits */\nvar DIST = 23; /* i: waiting for distance code */\nvar DISTEXT = 24; /* i: waiting for distance extra bits */\nvar MATCH = 25; /* o: waiting for output space to copy string */\nvar LIT = 26; /* o: waiting for output space to write literal */\nvar CHECK = 27; /* i: waiting for 32-bit check value */\nvar LENGTH = 28; /* i: waiting for 32-bit length (gzip) */\nvar DONE = 29; /* finished check, done -- remain here until reset */\nvar BAD = 30; /* got a data error -- remain here until reset */\nvar MEM = 31; /* got an inflate() memory error -- remain here until reset */\nvar SYNC = 32; /* looking for synchronization bytes to restart inflate() */\n\n/* ===========================================================================*/\n\n\n\nvar ENOUGH_LENS = 852;\nvar ENOUGH_DISTS = 592;\nfunction zswap32(q) {\n return (((q >>> 24) & 0xff) +\n ((q >>> 8) & 0xff00) +\n ((q & 0xff00) << 8) +\n ((q & 0xff) << 24));\n}\n\n\nfunction InflateState() {\n this.mode = 0; /* current inflate mode */\n this.last = false; /* true if processing last block */\n this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip */\n this.havedict = false; /* true if dictionary provided */\n this.flags = 0; /* gzip header method and flags (0 if zlib) */\n this.dmax = 0; /* zlib header max distance (INFLATE_STRICT) */\n this.check = 0; /* protected copy of check value */\n this.total = 0; /* protected copy of output count */\n // TODO: may be {}\n this.head = null; /* where to save gzip header information */\n\n /* sliding window */\n this.wbits = 0; /* log base 2 of requested window size */\n this.wsize = 0; /* window size or zero if not using window */\n this.whave = 0; /* valid bytes in the window */\n this.wnext = 0; /* window write index */\n this.window = null; /* allocated sliding window, if needed */\n\n /* bit accumulator */\n this.hold = 0; /* input bit accumulator */\n this.bits = 0; /* number of bits in \"in\" */\n\n /* for string and stored block copying */\n this.length = 0; /* literal or length of data to copy */\n this.offset = 0; /* distance back to copy string from */\n\n /* for table and code decoding */\n this.extra = 0; /* extra bits needed */\n\n /* fixed and dynamic code tables */\n this.lencode = null; /* starting table for length/literal codes */\n this.distcode = null; /* starting table for distance codes */\n this.lenbits = 0; /* index bits for lencode */\n this.distbits = 0; /* index bits for distcode */\n\n /* dynamic table building */\n this.ncode = 0; /* number of code length code lengths */\n this.nlen = 0; /* number of length code lengths */\n this.ndist = 0; /* number of distance code lengths */\n this.have = 0; /* number of code lengths in lens[] */\n this.next = null; /* next available space in codes[] */\n\n this.lens = new Uint16Array(320); /* temporary storage for code lengths */\n this.work = new Uint16Array(288); /* work area for code table building */\n\n /*\n because we don't have pointers in js, we use lencode and distcode directly\n as buffers so we don't need codes\n */\n //this.codes = new Buf32(ENOUGH); /* space for code tables */\n this.lendyn = null; /* dynamic table for length/literal codes (JS specific) */\n this.distdyn = null; /* dynamic table for distance codes (JS specific) */\n this.sane = 0; /* if false, allow invalid distance too far */\n this.back = 0; /* bits back of last unprocessed length/lit */\n this.was = 0; /* initial length of match */\n}\n\nfunction inflateResetKeep(strm) {\n var state;\n\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n strm.total_in = strm.total_out = state.total = 0;\n strm.msg = ''; /*Z_NULL*/\n if (state.wrap) { /* to support ill-conceived Java test suite */\n strm.adler = state.wrap & 1;\n }\n state.mode = HEAD;\n state.last = 0;\n state.havedict = 0;\n state.dmax = 32768;\n state.head = null/*Z_NULL*/;\n state.hold = 0;\n state.bits = 0;\n //state.lencode = state.distcode = state.next = state.codes;\n state.lencode = state.lendyn = new Int32Array(ENOUGH_LENS);\n state.distcode = state.distdyn = new Int32Array(ENOUGH_DISTS);\n\n state.sane = 1;\n state.back = -1;\n //Tracev((stderr, \"inflate: reset\\n\"));\n return Z_OK;\n}\n\nfunction inflateReset(strm) {\n var state;\n\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n state.wsize = 0;\n state.whave = 0;\n state.wnext = 0;\n return inflateResetKeep(strm);\n\n}\n\nfunction inflateReset2(strm, windowBits) {\n var wrap;\n var state;\n\n /* get the state */\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n\n /* extract wrap request from windowBits parameter */\n if (windowBits < 0) {\n wrap = 0;\n windowBits = -windowBits;\n }\n else {\n wrap = (windowBits >> 4) + 1;\n if (windowBits < 48) {\n windowBits &= 15;\n }\n }\n\n /* set number of window bits, free window if different */\n if (windowBits && (windowBits < 8 || windowBits > 15)) {\n return Z_STREAM_ERROR;\n }\n if (state.window !== null && state.wbits !== windowBits) {\n state.window = null;\n }\n\n /* update state and reset the rest of it */\n state.wrap = wrap;\n state.wbits = windowBits;\n return inflateReset(strm);\n}\n\nfunction inflateInit2(strm, windowBits) {\n var ret;\n var state;\n\n if (!strm) { return Z_STREAM_ERROR; }\n //strm.msg = Z_NULL; /* in case we return an error */\n\n state = new InflateState();\n\n //if (state === Z_NULL) return Z_MEM_ERROR;\n //Tracev((stderr, \"inflate: allocated\\n\"));\n strm.state = state;\n state.window = null/*Z_NULL*/;\n ret = inflateReset2(strm, windowBits);\n if (ret !== Z_OK) {\n strm.state = null/*Z_NULL*/;\n }\n return ret;\n}\n\n/*\n Return state with length and distance decoding tables and index sizes set to\n fixed code decoding. Normally this returns fixed tables from inffixed.h.\n If BUILDFIXED is defined, then instead this routine builds the tables the\n first time it's called, and returns those tables the first time and\n thereafter. This reduces the size of the code by about 2K bytes, in\n exchange for a little execution time. However, BUILDFIXED should not be\n used for threaded applications, since the rewriting of the tables and virgin\n may not be thread-safe.\n */\nvar virgin = true;\n\nvar lenfix;\nvar distfix;\n// We have no pointers in JS, so keep tables separate\n\nfunction fixedtables(state) {\n /* build fixed huffman tables if first call (may not be thread safe) */\n if (virgin) {\n var sym;\n\n lenfix = new Int32Array(512);\n distfix = new Int32Array(32);\n\n /* literal/length table */\n sym = 0;\n while (sym < 144) { state.lens[sym++] = 8; }\n while (sym < 256) { state.lens[sym++] = 9; }\n while (sym < 280) { state.lens[sym++] = 7; }\n while (sym < 288) { state.lens[sym++] = 8; }\n\n inflate_table(LENS, state.lens, 0, 288, lenfix, 0, state.work, { bits: 9 });\n\n /* distance table */\n sym = 0;\n while (sym < 32) { state.lens[sym++] = 5; }\n\n inflate_table(DISTS, state.lens, 0, 32, distfix, 0, state.work, { bits: 5 });\n\n /* do this just once */\n virgin = false;\n }\n\n state.lencode = lenfix;\n state.lenbits = 9;\n state.distcode = distfix;\n state.distbits = 5;\n}\n\n\n/*\n Update the window with the last wsize (normally 32K) bytes written before\n returning. If window does not exist yet, create it. This is only called\n when a window is already in use, or when output has been written during this\n inflate call, but the end of the deflate stream has not been reached yet.\n It is also called to create a window for dictionary data when a dictionary\n is loaded.\n\n Providing output buffers larger than 32K to inflate() should provide a speed\n advantage, since only the last 32K of output is copied to the sliding window\n upon return from inflate(), and since all distances after the first 32K of\n output will fall in the output data, making match copies simpler and faster.\n The advantage may be dependent on the size of the processor's data caches.\n */\nfunction updatewindow(strm, src, end, copy) {\n var dist;\n var state = strm.state;\n\n /* if it hasn't been done already, allocate space for the window */\n if (state.window === null) {\n state.wsize = 1 << state.wbits;\n state.wnext = 0;\n state.whave = 0;\n\n state.window = new Uint8Array(state.wsize);\n }\n\n /* copy state->wsize or less output bytes into the circular window */\n if (copy >= state.wsize) {\n arraySet(state.window, src, end - state.wsize, state.wsize, 0);\n state.wnext = 0;\n state.whave = state.wsize;\n }\n else {\n dist = state.wsize - state.wnext;\n if (dist > copy) {\n dist = copy;\n }\n //zmemcpy(state->window + state->wnext, end - copy, dist);\n arraySet(state.window, src, end - copy, dist, state.wnext);\n copy -= dist;\n if (copy) {\n //zmemcpy(state->window, end - copy, copy);\n arraySet(state.window, src, end - copy, copy, 0);\n state.wnext = copy;\n state.whave = state.wsize;\n }\n else {\n state.wnext += dist;\n if (state.wnext === state.wsize) { state.wnext = 0; }\n if (state.whave < state.wsize) { state.whave += dist; }\n }\n }\n return 0;\n}\n\nfunction inflate(strm, flush) {\n var state;\n var input, output; // input/output buffers\n var next; /* next input INDEX */\n var put; /* next output INDEX */\n var have, left; /* available input and output */\n var hold; /* bit buffer */\n var bits; /* bits in bit buffer */\n var _in, _out; /* save starting available input and output */\n var copy; /* number of stored or match bytes to copy */\n var from; /* where to copy match bytes from */\n var from_source;\n var here = 0; /* current decoding table entry */\n var here_bits, here_op, here_val; // paked \"here\" denormalized (JS specific)\n //var last; /* parent table entry */\n var last_bits, last_op, last_val; // paked \"last\" denormalized (JS specific)\n var len; /* length to copy for repeats, bits to drop */\n var ret; /* return code */\n var hbuf = new Uint8Array(4); /* buffer for gzip header crc calculation */\n var opts;\n\n var n; // temporary var for NEED_BITS\n\n var order = /* permutation of code lengths */\n [ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ];\n\n\n if (!strm || !strm.state || !strm.output ||\n (!strm.input && strm.avail_in !== 0)) {\n return Z_STREAM_ERROR;\n }\n\n state = strm.state;\n if (state.mode === TYPE) { state.mode = TYPEDO; } /* skip check */\n\n\n //--- LOAD() ---\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n //---\n\n _in = have;\n _out = left;\n ret = Z_OK;\n\n inf_leave: // goto emulation\n for (;;) {\n switch (state.mode) {\n case HEAD:\n if (state.wrap === 0) {\n state.mode = TYPEDO;\n break;\n }\n //=== NEEDBITS(16);\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if ((state.wrap & 2) && hold === 0x8b1f) { /* gzip header */\n state.check = 0/*crc32(0L, Z_NULL, 0)*/;\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = FLAGS;\n break;\n }\n state.flags = 0; /* expect zlib header */\n if (state.head) {\n state.head.done = false;\n }\n if (!(state.wrap & 1) || /* check if zlib header allowed */\n (((hold & 0xff)/*BITS(8)*/ << 8) + (hold >> 8)) % 31) {\n strm.msg = 'incorrect header check';\n state.mode = BAD;\n break;\n }\n if ((hold & 0x0f)/*BITS(4)*/ !== Z_DEFLATED) {\n strm.msg = 'unknown compression method';\n state.mode = BAD;\n break;\n }\n //--- DROPBITS(4) ---//\n hold >>>= 4;\n bits -= 4;\n //---//\n len = (hold & 0x0f)/*BITS(4)*/ + 8;\n if (state.wbits === 0) {\n state.wbits = len;\n }\n else if (len > state.wbits) {\n strm.msg = 'invalid window size';\n state.mode = BAD;\n break;\n }\n state.dmax = 1 << len;\n //Tracev((stderr, \"inflate: zlib header ok\\n\"));\n strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n state.mode = hold & 0x200 ? DICTID : TYPE;\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n break;\n case FLAGS:\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.flags = hold;\n if ((state.flags & 0xff) !== Z_DEFLATED) {\n strm.msg = 'unknown compression method';\n state.mode = BAD;\n break;\n }\n if (state.flags & 0xe000) {\n strm.msg = 'unknown header flags set';\n state.mode = BAD;\n break;\n }\n if (state.head) {\n state.head.text = ((hold >> 8) & 1);\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = TIME;\n /* falls through */\n case TIME:\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (state.head) {\n state.head.time = hold;\n }\n if (state.flags & 0x0200) {\n //=== CRC4(state.check, hold)\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n hbuf[2] = (hold >>> 16) & 0xff;\n hbuf[3] = (hold >>> 24) & 0xff;\n state.check = crc32(state.check, hbuf, 4, 0);\n //===\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = OS;\n /* falls through */\n case OS:\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (state.head) {\n state.head.xflags = (hold & 0xff);\n state.head.os = (hold >> 8);\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = EXLEN;\n /* falls through */\n case EXLEN:\n if (state.flags & 0x0400) {\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.length = hold;\n if (state.head) {\n state.head.extra_len = hold;\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n }\n else if (state.head) {\n state.head.extra = null/*Z_NULL*/;\n }\n state.mode = EXTRA;\n /* falls through */\n case EXTRA:\n if (state.flags & 0x0400) {\n copy = state.length;\n if (copy > have) { copy = have; }\n if (copy) {\n if (state.head) {\n len = state.head.extra_len - state.length;\n if (!state.head.extra) {\n // Use untyped array for more conveniend processing later\n state.head.extra = new Array(state.head.extra_len);\n }\n arraySet(\n state.head.extra,\n input,\n next,\n // extra field is limited to 65536 bytes\n // - no need for additional size check\n copy,\n /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/\n len\n );\n //zmemcpy(state.head.extra + len, next,\n // len + copy > state.head.extra_max ?\n // state.head.extra_max - len : copy);\n }\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n state.length -= copy;\n }\n if (state.length) { break inf_leave; }\n }\n state.length = 0;\n state.mode = NAME;\n /* falls through */\n case NAME:\n if (state.flags & 0x0800) {\n if (have === 0) { break inf_leave; }\n copy = 0;\n do {\n // TODO: 2 or 1 bytes?\n len = input[next + copy++];\n /* use constant limit because in js we should not preallocate memory */\n if (state.head && len &&\n (state.length < 65536 /*state.head.name_max*/)) {\n state.head.name += String.fromCharCode(len);\n }\n } while (len && copy < have);\n\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) { break inf_leave; }\n }\n else if (state.head) {\n state.head.name = null;\n }\n state.length = 0;\n state.mode = COMMENT;\n /* falls through */\n case COMMENT:\n if (state.flags & 0x1000) {\n if (have === 0) { break inf_leave; }\n copy = 0;\n do {\n len = input[next + copy++];\n /* use constant limit because in js we should not preallocate memory */\n if (state.head && len &&\n (state.length < 65536 /*state.head.comm_max*/)) {\n state.head.comment += String.fromCharCode(len);\n }\n } while (len && copy < have);\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) { break inf_leave; }\n }\n else if (state.head) {\n state.head.comment = null;\n }\n state.mode = HCRC;\n /* falls through */\n case HCRC:\n if (state.flags & 0x0200) {\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (hold !== (state.check & 0xffff)) {\n strm.msg = 'header crc mismatch';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n }\n if (state.head) {\n state.head.hcrc = ((state.flags >> 9) & 1);\n state.head.done = true;\n }\n strm.adler = state.check = 0;\n state.mode = TYPE;\n break;\n case DICTID:\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n strm.adler = state.check = zswap32(hold);\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = DICT;\n /* falls through */\n case DICT:\n if (state.havedict === 0) {\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n return Z_NEED_DICT;\n }\n strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n state.mode = TYPE;\n /* falls through */\n case TYPE:\n if (flush === Z_BLOCK || flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case TYPEDO:\n if (state.last) {\n //--- BYTEBITS() ---//\n hold >>>= bits & 7;\n bits -= bits & 7;\n //---//\n state.mode = CHECK;\n break;\n }\n //=== NEEDBITS(3); */\n while (bits < 3) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.last = (hold & 0x01)/*BITS(1)*/;\n //--- DROPBITS(1) ---//\n hold >>>= 1;\n bits -= 1;\n //---//\n\n switch ((hold & 0x03)/*BITS(2)*/) {\n case 0: /* stored block */\n //Tracev((stderr, \"inflate: stored block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = STORED;\n break;\n case 1: /* fixed block */\n fixedtables(state);\n //Tracev((stderr, \"inflate: fixed codes block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = LEN_; /* decode codes */\n if (flush === Z_TREES) {\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n break inf_leave;\n }\n break;\n case 2: /* dynamic block */\n //Tracev((stderr, \"inflate: dynamic codes block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = TABLE;\n break;\n case 3:\n strm.msg = 'invalid block type';\n state.mode = BAD;\n }\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n break;\n case STORED:\n //--- BYTEBITS() ---// /* go to byte boundary */\n hold >>>= bits & 7;\n bits -= bits & 7;\n //---//\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if ((hold & 0xffff) !== ((hold >>> 16) ^ 0xffff)) {\n strm.msg = 'invalid stored block lengths';\n state.mode = BAD;\n break;\n }\n state.length = hold & 0xffff;\n //Tracev((stderr, \"inflate: stored length %u\\n\",\n // state.length));\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = COPY_;\n if (flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case COPY_:\n state.mode = COPY;\n /* falls through */\n case COPY:\n copy = state.length;\n if (copy) {\n if (copy > have) { copy = have; }\n if (copy > left) { copy = left; }\n if (copy === 0) { break inf_leave; }\n //--- zmemcpy(put, next, copy); ---\n arraySet(output, input, next, copy, put);\n //---//\n have -= copy;\n next += copy;\n left -= copy;\n put += copy;\n state.length -= copy;\n break;\n }\n //Tracev((stderr, \"inflate: stored end\\n\"));\n state.mode = TYPE;\n break;\n case TABLE:\n //=== NEEDBITS(14); */\n while (bits < 14) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.nlen = (hold & 0x1f)/*BITS(5)*/ + 257;\n //--- DROPBITS(5) ---//\n hold >>>= 5;\n bits -= 5;\n //---//\n state.ndist = (hold & 0x1f)/*BITS(5)*/ + 1;\n //--- DROPBITS(5) ---//\n hold >>>= 5;\n bits -= 5;\n //---//\n state.ncode = (hold & 0x0f)/*BITS(4)*/ + 4;\n //--- DROPBITS(4) ---//\n hold >>>= 4;\n bits -= 4;\n //---//\n//#ifndef PKZIP_BUG_WORKAROUND\n if (state.nlen > 286 || state.ndist > 30) {\n strm.msg = 'too many length or distance symbols';\n state.mode = BAD;\n break;\n }\n//#endif\n //Tracev((stderr, \"inflate: table sizes ok\\n\"));\n state.have = 0;\n state.mode = LENLENS;\n /* falls through */\n case LENLENS:\n while (state.have < state.ncode) {\n //=== NEEDBITS(3);\n while (bits < 3) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.lens[order[state.have++]] = (hold & 0x07);//BITS(3);\n //--- DROPBITS(3) ---//\n hold >>>= 3;\n bits -= 3;\n //---//\n }\n while (state.have < 19) {\n state.lens[order[state.have++]] = 0;\n }\n // We have separate tables & no pointers. 2 commented lines below not needed.\n //state.next = state.codes;\n //state.lencode = state.next;\n // Switch to use dynamic table\n state.lencode = state.lendyn;\n state.lenbits = 7;\n\n opts = { bits: state.lenbits };\n ret = inflate_table(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts);\n state.lenbits = opts.bits;\n\n if (ret) {\n strm.msg = 'invalid code lengths set';\n state.mode = BAD;\n break;\n }\n //Tracev((stderr, \"inflate: code lengths ok\\n\"));\n state.have = 0;\n state.mode = CODELENS;\n /* falls through */\n case CODELENS:\n while (state.have < state.nlen + state.ndist) {\n for (;;) {\n here = state.lencode[hold & ((1 << state.lenbits) - 1)];/*BITS(state.lenbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if (here_val < 16) {\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.lens[state.have++] = here_val;\n }\n else {\n if (here_val === 16) {\n //=== NEEDBITS(here.bits + 2);\n n = here_bits + 2;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n if (state.have === 0) {\n strm.msg = 'invalid bit length repeat';\n state.mode = BAD;\n break;\n }\n len = state.lens[state.have - 1];\n copy = 3 + (hold & 0x03);//BITS(2);\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n }\n else if (here_val === 17) {\n //=== NEEDBITS(here.bits + 3);\n n = here_bits + 3;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n len = 0;\n copy = 3 + (hold & 0x07);//BITS(3);\n //--- DROPBITS(3) ---//\n hold >>>= 3;\n bits -= 3;\n //---//\n }\n else {\n //=== NEEDBITS(here.bits + 7);\n n = here_bits + 7;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n len = 0;\n copy = 11 + (hold & 0x7f);//BITS(7);\n //--- DROPBITS(7) ---//\n hold >>>= 7;\n bits -= 7;\n //---//\n }\n if (state.have + copy > state.nlen + state.ndist) {\n strm.msg = 'invalid bit length repeat';\n state.mode = BAD;\n break;\n }\n while (copy--) {\n state.lens[state.have++] = len;\n }\n }\n }\n\n /* handle error breaks in while */\n if (state.mode === BAD) { break; }\n\n /* check for end-of-block code (better have one) */\n if (state.lens[256] === 0) {\n strm.msg = 'invalid code -- missing end-of-block';\n state.mode = BAD;\n break;\n }\n\n /* build code tables -- note: do not change the lenbits or distbits\n values here (9 and 6) without reading the comments in inftrees.h\n concerning the ENOUGH constants, which depend on those values */\n state.lenbits = 9;\n\n opts = { bits: state.lenbits };\n ret = inflate_table(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts);\n // We have separate tables & no pointers. 2 commented lines below not needed.\n // state.next_index = opts.table_index;\n state.lenbits = opts.bits;\n // state.lencode = state.next;\n\n if (ret) {\n strm.msg = 'invalid literal/lengths set';\n state.mode = BAD;\n break;\n }\n\n state.distbits = 6;\n //state.distcode.copy(state.codes);\n // Switch to use dynamic table\n state.distcode = state.distdyn;\n opts = { bits: state.distbits };\n ret = inflate_table(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts);\n // We have separate tables & no pointers. 2 commented lines below not needed.\n // state.next_index = opts.table_index;\n state.distbits = opts.bits;\n // state.distcode = state.next;\n\n if (ret) {\n strm.msg = 'invalid distances set';\n state.mode = BAD;\n break;\n }\n //Tracev((stderr, 'inflate: codes ok\\n'));\n state.mode = LEN_;\n if (flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case LEN_:\n state.mode = LEN;\n /* falls through */\n case LEN:\n if (have >= 6 && left >= 258) {\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n inflate_fast(strm, _out);\n //--- LOAD() ---\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n //---\n\n if (state.mode === TYPE) {\n state.back = -1;\n }\n break;\n }\n state.back = 0;\n for (;;) {\n here = state.lencode[hold & ((1 << state.lenbits) - 1)]; /*BITS(state.lenbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if (here_bits <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if (here_op && (here_op & 0xf0) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (;;) {\n here = state.lencode[last_val +\n ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((last_bits + here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n //--- DROPBITS(last.bits) ---//\n hold >>>= last_bits;\n bits -= last_bits;\n //---//\n state.back += last_bits;\n }\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.back += here_bits;\n state.length = here_val;\n if (here_op === 0) {\n //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n // \"inflate: literal '%c'\\n\" :\n // \"inflate: literal 0x%02x\\n\", here.val));\n state.mode = LIT;\n break;\n }\n if (here_op & 32) {\n //Tracevv((stderr, \"inflate: end of block\\n\"));\n state.back = -1;\n state.mode = TYPE;\n break;\n }\n if (here_op & 64) {\n strm.msg = 'invalid literal/length code';\n state.mode = BAD;\n break;\n }\n state.extra = here_op & 15;\n state.mode = LENEXT;\n /* falls through */\n case LENEXT:\n if (state.extra) {\n //=== NEEDBITS(state.extra);\n n = state.extra;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.length += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n //--- DROPBITS(state.extra) ---//\n hold >>>= state.extra;\n bits -= state.extra;\n //---//\n state.back += state.extra;\n }\n //Tracevv((stderr, \"inflate: length %u\\n\", state.length));\n state.was = state.length;\n state.mode = DIST;\n /* falls through */\n case DIST:\n for (;;) {\n here = state.distcode[hold & ((1 << state.distbits) - 1)];/*BITS(state.distbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if ((here_op & 0xf0) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (;;) {\n here = state.distcode[last_val +\n ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((last_bits + here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n //--- DROPBITS(last.bits) ---//\n hold >>>= last_bits;\n bits -= last_bits;\n //---//\n state.back += last_bits;\n }\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.back += here_bits;\n if (here_op & 64) {\n strm.msg = 'invalid distance code';\n state.mode = BAD;\n break;\n }\n state.offset = here_val;\n state.extra = (here_op) & 15;\n state.mode = DISTEXT;\n /* falls through */\n case DISTEXT:\n if (state.extra) {\n //=== NEEDBITS(state.extra);\n n = state.extra;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.offset += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n //--- DROPBITS(state.extra) ---//\n hold >>>= state.extra;\n bits -= state.extra;\n //---//\n state.back += state.extra;\n }\n//#ifdef INFLATE_STRICT\n if (state.offset > state.dmax) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break;\n }\n//#endif\n //Tracevv((stderr, \"inflate: distance %u\\n\", state.offset));\n state.mode = MATCH;\n /* falls through */\n case MATCH:\n if (left === 0) { break inf_leave; }\n copy = _out - left;\n if (state.offset > copy) { /* copy from window */\n copy = state.offset - copy;\n if (copy > state.whave) {\n if (state.sane) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break;\n }\n// (!) This block is disabled in zlib defailts,\n// don't enable it for binary compatibility\n//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n// Trace((stderr, \"inflate.c too far\\n\"));\n// copy -= state.whave;\n// if (copy > state.length) { copy = state.length; }\n// if (copy > left) { copy = left; }\n// left -= copy;\n// state.length -= copy;\n// do {\n// output[put++] = 0;\n// } while (--copy);\n// if (state.length === 0) { state.mode = LEN; }\n// break;\n//#endif\n }\n if (copy > state.wnext) {\n copy -= state.wnext;\n from = state.wsize - copy;\n }\n else {\n from = state.wnext - copy;\n }\n if (copy > state.length) { copy = state.length; }\n from_source = state.window;\n }\n else { /* copy from output */\n from_source = output;\n from = put - state.offset;\n copy = state.length;\n }\n if (copy > left) { copy = left; }\n left -= copy;\n state.length -= copy;\n do {\n output[put++] = from_source[from++];\n } while (--copy);\n if (state.length === 0) { state.mode = LEN; }\n break;\n case LIT:\n if (left === 0) { break inf_leave; }\n output[put++] = state.length;\n left--;\n state.mode = LEN;\n break;\n case CHECK:\n if (state.wrap) {\n //=== NEEDBITS(32);\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n // Use '|' insdead of '+' to make sure that result is signed\n hold |= input[next++] << bits;\n bits += 8;\n }\n //===//\n _out -= left;\n strm.total_out += _out;\n state.total += _out;\n if (_out) {\n strm.adler = state.check =\n /*UPDATE(state.check, put - _out, _out);*/\n (state.flags ? crc32(state.check, output, _out, put - _out) : adler32(state.check, output, _out, put - _out));\n\n }\n _out = left;\n // NB: crc32 stored as signed 32-bit int, zswap32 returns signed too\n if ((state.flags ? hold : zswap32(hold)) !== state.check) {\n strm.msg = 'incorrect data check';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n //Tracev((stderr, \"inflate: check matches trailer\\n\"));\n }\n state.mode = LENGTH;\n /* falls through */\n case LENGTH:\n if (state.wrap && state.flags) {\n //=== NEEDBITS(32);\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (hold !== (state.total & 0xffffffff)) {\n strm.msg = 'incorrect length check';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n //Tracev((stderr, \"inflate: length matches trailer\\n\"));\n }\n state.mode = DONE;\n /* falls through */\n case DONE:\n ret = Z_STREAM_END;\n break inf_leave;\n case BAD:\n ret = Z_DATA_ERROR;\n break inf_leave;\n case MEM:\n return Z_MEM_ERROR;\n case SYNC:\n /* falls through */\n default:\n return Z_STREAM_ERROR;\n }\n }\n\n // inf_leave <- here is real place for \"goto inf_leave\", emulated via \"break inf_leave\"\n\n /*\n Return from inflate(), updating the total counts and the check value.\n If there was no progress during the inflate() call, return a buffer\n error. Call updatewindow() to create and/or update the window state.\n Note: a memory error from inflate() is non-recoverable.\n */\n\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n\n if (state.wsize || (_out !== strm.avail_out && state.mode < BAD &&\n (state.mode < CHECK || flush !== Z_FINISH))) {\n if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) {\n state.mode = MEM;\n return Z_MEM_ERROR;\n }\n }\n _in -= strm.avail_in;\n _out -= strm.avail_out;\n strm.total_in += _in;\n strm.total_out += _out;\n state.total += _out;\n if (state.wrap && _out) {\n strm.adler = state.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/\n (state.flags ? crc32(state.check, output, _out, strm.next_out - _out) : adler32(state.check, output, _out, strm.next_out - _out));\n }\n strm.data_type = state.bits + (state.last ? 64 : 0) +\n (state.mode === TYPE ? 128 : 0) +\n (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);\n if (((_in === 0 && _out === 0) || flush === Z_FINISH) && ret === Z_OK) {\n ret = Z_BUF_ERROR;\n }\n return ret;\n}\n\nfunction inflateEnd(strm) {\n\n if (!strm || !strm.state /*|| strm->zfree == (free_func)0*/) {\n return Z_STREAM_ERROR;\n }\n\n var state = strm.state;\n if (state.window) {\n state.window = null;\n }\n strm.state = null;\n return Z_OK;\n}\n\nfunction inflateGetHeader(strm, head) {\n var state;\n\n /* check state */\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n if ((state.wrap & 2) === 0) { return Z_STREAM_ERROR; }\n\n /* save header structure */\n state.head = head;\n head.done = false;\n return Z_OK;\n}\n\nfunction inflateSetDictionary(strm, dictionary) {\n var dictLength = dictionary.length;\n\n var state;\n var dictid;\n var ret;\n\n /* check state */\n if (!strm /* == Z_NULL */ || !strm.state /* == Z_NULL */) { return Z_STREAM_ERROR; }\n state = strm.state;\n\n if (state.wrap !== 0 && state.mode !== DICT) {\n return Z_STREAM_ERROR;\n }\n\n /* check for correct dictionary identifier */\n if (state.mode === DICT) {\n dictid = 1; /* adler32(0, null, 0)*/\n /* dictid = adler32(dictid, dictionary, dictLength); */\n dictid = adler32(dictid, dictionary, dictLength, 0);\n if (dictid !== state.check) {\n return Z_DATA_ERROR;\n }\n }\n /* copy dictionary to window using updatewindow(), which will amend the\n existing dictionary if appropriate */\n ret = updatewindow(strm, dictionary, dictLength, dictLength);\n if (ret) {\n state.mode = MEM;\n return Z_MEM_ERROR;\n }\n state.havedict = 1;\n // Tracev((stderr, \"inflate: dictionary set\\n\"));\n return Z_OK;\n}\n\n// String encode/decode helpers\n// 'use strict';\n\n\n// var utils = require('./common');\n\n\n// Quick check if we can use fast array to bin string conversion\n//\n// - apply(Array) can fail on Android 2.2\n// - apply(Uint8Array) can fail on iOS 5.1 Safary\n//\nvar STR_APPLY_OK = true;\nvar STR_APPLY_UIA_OK = true;\n\ntry { String.fromCharCode.apply(null, [ 0 ]); } catch (__) { STR_APPLY_OK = false; }\ntry { String.fromCharCode.apply(null, new Uint8Array(1)); } catch (__) { STR_APPLY_UIA_OK = false; }\n\n\n// Table with utf8 lengths (calculated by first byte of sequence)\n// Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS,\n// because max possible codepoint is 0x10ffff\nvar _utf8len = new Uint8Array(256);\nfor (var q = 0; q < 256; q++) {\n _utf8len[q] = (q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1);\n}\n_utf8len[254] = _utf8len[254] = 1; // Invalid sequence start\n\n\n// convert string to array (typed, when possible)\nfunction string2buf(str) {\n var buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;\n\n // count binary size\n for (m_pos = 0; m_pos < str_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n m_pos++;\n }\n }\n buf_len += c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4;\n }\n\n // allocate buffer\n buf = new Uint8Array(buf_len);\n\n // convert\n for (i = 0, m_pos = 0; i < buf_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n m_pos++;\n }\n }\n if (c < 0x80) {\n /* one byte */\n buf[i++] = c;\n } else if (c < 0x800) {\n /* two bytes */\n buf[i++] = 0xC0 | (c >>> 6);\n buf[i++] = 0x80 | (c & 0x3f);\n } else if (c < 0x10000) {\n /* three bytes */\n buf[i++] = 0xE0 | (c >>> 12);\n buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n buf[i++] = 0x80 | (c & 0x3f);\n } else {\n /* four bytes */\n buf[i++] = 0xf0 | (c >>> 18);\n buf[i++] = 0x80 | (c >>> 12 & 0x3f);\n buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n buf[i++] = 0x80 | (c & 0x3f);\n }\n }\n\n return buf;\n}\n\n// Helper (used in 2 places)\nfunction _buf2binstring(buf, len) {\n // use fallback for big arrays to avoid stack overflow\n if (len < 65537) {\n if ((buf.subarray && STR_APPLY_UIA_OK) || (!buf.subarray && STR_APPLY_OK)) {\n return String.fromCharCode.apply(null, shrinkBuf(buf, len));\n }\n }\n\n var result = '';\n for (var i = 0; i < len; i++) {\n result += String.fromCharCode(buf[i]);\n }\n return result;\n}\n\n\n// Convert binary string (typed, when possible)\nfunction binstring2buf(str) {\n var buf = new Uint8Array(str.length);\n for (var i = 0, len = buf.length; i < len; i++) {\n buf[i] = str.charCodeAt(i);\n }\n return buf;\n}\n\n\n// convert array to string\nfunction buf2string(buf, max) {\n var i, out, c, c_len;\n var len = max || buf.length;\n\n // Reserve max possible length (2 words per char)\n // NB: by unknown reasons, Array is significantly faster for\n // String.fromCharCode.apply than Uint16Array.\n var utf16buf = new Array(len * 2);\n\n for (out = 0, i = 0; i < len;) {\n c = buf[i++];\n // quick process ascii\n if (c < 0x80) { utf16buf[out++] = c; continue; }\n\n c_len = _utf8len[c];\n // skip 5 & 6 byte codes\n if (c_len > 4) { utf16buf[out++] = 0xfffd; i += c_len - 1; continue; }\n\n // apply mask on first byte\n c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07;\n // join the rest\n while (c_len > 1 && i < len) {\n c = (c << 6) | (buf[i++] & 0x3f);\n c_len--;\n }\n\n // terminated by end of string?\n if (c_len > 1) { utf16buf[out++] = 0xfffd; continue; }\n\n if (c < 0x10000) {\n utf16buf[out++] = c;\n } else {\n c -= 0x10000;\n utf16buf[out++] = 0xd800 | ((c >> 10) & 0x3ff);\n utf16buf[out++] = 0xdc00 | (c & 0x3ff);\n }\n }\n\n return _buf2binstring(utf16buf, out);\n}\n\n\n// Calculate max possible position in utf8 buffer,\n// that will not break sequence. If that's not possible\n// - (very small limits) return max size as is.\n//\n// buf[] - utf8 bytes array\n// max - length limit (mandatory);\nfunction utf8border(buf, max) {\n var pos;\n\n max = max || buf.length;\n if (max > buf.length) { max = buf.length; }\n\n // go back from last position, until start of sequence found\n pos = max - 1;\n while (pos >= 0 && (buf[pos] & 0xC0) === 0x80) { pos--; }\n\n // Fuckup - very small and broken sequence,\n // return max, because we should return something anyway.\n if (pos < 0) { return max; }\n\n // If we came to start of buffer - that means vuffer is too small,\n // return max too.\n if (pos === 0) { return max; }\n\n return (pos + _utf8len[buf[pos]] > max) ? pos : max;\n}\n\n/* Allowed flush values; see deflate() and inflate() below for details */\nvar Z_NO_FLUSH = 0;\nvar Z_SYNC_FLUSH = 2;\nvar Z_FINISH$1 = 4;\n/* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\nvar Z_OK$1 = 0;\nvar Z_STREAM_END$1 = 1;\nvar Z_NEED_DICT$1 = 2;\n//export var Z_MEM_ERROR = -4;\nvar Z_BUF_ERROR$1 = -5;\n\n// 'use strict';\n\nvar messages = {\n 2: 'need dictionary', /* Z_NEED_DICT 2 */\n 1: 'stream end', /* Z_STREAM_END 1 */\n 0: '', /* Z_OK 0 */\n '-1': 'file error', /* Z_ERRNO (-1) */\n '-2': 'stream error', /* Z_STREAM_ERROR (-2) */\n '-3': 'data error', /* Z_DATA_ERROR (-3) */\n '-4': 'insufficient memory', /* Z_MEM_ERROR (-4) */\n '-5': 'buffer error', /* Z_BUF_ERROR (-5) */\n '-6': 'incompatible version' /* Z_VERSION_ERROR (-6) */\n};\n\n// 'use strict';\n\n\nfunction ZStream() {\n /* next input byte */\n this.input = null; // JS specific, because we have no pointers\n this.next_in = 0;\n /* number of bytes available at input */\n this.avail_in = 0;\n /* total number of input bytes read so far */\n this.total_in = 0;\n /* next output byte should be put there */\n this.output = null; // JS specific, because we have no pointers\n this.next_out = 0;\n /* remaining free space at output */\n this.avail_out = 0;\n /* total number of bytes output so far */\n this.total_out = 0;\n /* last error message, NULL if no error */\n this.msg = ''/*Z_NULL*/;\n /* not visible by applications */\n this.state = null;\n /* best guess about the data type: binary or text */\n this.data_type = 2/*Z_UNKNOWN*/;\n /* adler32 value of the uncompressed data */\n this.adler = 0;\n}\n\n// 'use strict';\n\n\nfunction GZheader() {\n /* true if compressed data believed to be text */\n this.text = 0;\n /* modification time */\n this.time = 0;\n /* extra flags (not used when writing a gzip file) */\n this.xflags = 0;\n /* operating system */\n this.os = 0;\n /* pointer to extra field or Z_NULL if none */\n this.extra = null;\n /* extra field length (valid if extra != Z_NULL) */\n this.extra_len = 0; // Actually, we don't need it in JS,\n // but leave for few code modifications\n\n //\n // Setup limits is not necessary because in js we should not preallocate memory\n // for inflate use constant limit in 65536 bytes\n //\n\n /* space at extra (only when reading header) */\n // this.extra_max = 0;\n /* pointer to zero-terminated file name or Z_NULL */\n this.name = '';\n /* space at name (only when reading header) */\n // this.name_max = 0;\n /* pointer to zero-terminated comment or Z_NULL */\n this.comment = '';\n /* space at comment (only when reading header) */\n // this.comm_max = 0;\n /* true if there was or will be a header crc */\n this.hcrc = 0;\n /* true when done reading gzip header (not used when writing a gzip file) */\n this.done = false;\n}\n\n// 'use strict';\n\n\n// var zlib_inflate = require('./zlib/inflate');\n// var utils = require('./utils/common');\n// var strings = require('./utils/strings');\n// var c = require('./zlib/constants');\n// var msg = require('./zlib/messages');\n// var ZStream = require('./zlib/zstream');\n// var GZheader = require('./zlib/gzheader');\n\nvar toString = Object.prototype.toString;\n\n/**\n * class Inflate\n *\n * Generic JS-style wrapper for zlib calls. If you don't need\n * streaming behaviour - use more simple functions: [[inflate]]\n * and [[inflateRaw]].\n **/\n\n/* internal\n * inflate.chunks -> Array\n *\n * Chunks of output data, if [[Inflate#onData]] not overriden.\n **/\n\n/**\n * Inflate.result -> Uint8Array|Array|String\n *\n * Uncompressed result, generated by default [[Inflate#onData]]\n * and [[Inflate#onEnd]] handlers. Filled after you push last chunk\n * (call [[Inflate#push]] with `Z_FINISH` / `true` param) or if you\n * push a chunk with explicit flush (call [[Inflate#push]] with\n * `Z_SYNC_FLUSH` param).\n **/\n\n/**\n * Inflate.err -> Number\n *\n * Error code after inflate finished. 0 (Z_OK) on success.\n * Should be checked if broken data possible.\n **/\n\n/**\n * Inflate.msg -> String\n *\n * Error message, if [[Inflate.err]] != 0\n **/\n\n\n/**\n * new Inflate(options)\n * - options (Object): zlib inflate options.\n *\n * Creates new inflator instance with specified params. Throws exception\n * on bad params. Supported options:\n *\n * - `windowBits`\n * - `dictionary`\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information on these.\n *\n * Additional options, for internal needs:\n *\n * - `chunkSize` - size of generated data chunks (16K by default)\n * - `raw` (Boolean) - do raw inflate\n * - `to` (String) - if equal to 'string', then result will be converted\n * from utf8 to utf16 (javascript) string. When string output requested,\n * chunk length can differ from `chunkSize`, depending on content.\n *\n * By default, when no options set, autodetect deflate/gzip data format via\n * wrapper header.\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , chunk1 = Uint8Array([1,2,3,4,5,6,7,8,9])\n * , chunk2 = Uint8Array([10,11,12,13,14,15,16,17,18,19]);\n *\n * var inflate = new pako.Inflate({ level: 3});\n *\n * inflate.push(chunk1, false);\n * inflate.push(chunk2, true); // true -> last chunk\n *\n * if (inflate.err) { throw new Error(inflate.err); }\n *\n * console.log(inflate.result);\n * ```\n **/\nfunction Inflate(options) {\n if (!(this instanceof Inflate)) return new Inflate(options);\n\n this.options = assign({\n chunkSize: 16384,\n windowBits: 0,\n to: ''\n }, options || {});\n\n var opt = this.options;\n\n // Force window size for `raw` data, if not set directly,\n // because we have no header for autodetect.\n if (opt.raw && (opt.windowBits >= 0) && (opt.windowBits < 16)) {\n opt.windowBits = -opt.windowBits;\n if (opt.windowBits === 0) { opt.windowBits = -15; }\n }\n\n // If `windowBits` not defined (and mode not raw) - set autodetect flag for gzip/deflate\n if ((opt.windowBits >= 0) && (opt.windowBits < 16) &&\n !(options && options.windowBits)) {\n opt.windowBits += 32;\n }\n\n // Gzip header has no info about windows size, we can do autodetect only\n // for deflate. So, if window size not set, force it to max when gzip possible\n if ((opt.windowBits > 15) && (opt.windowBits < 48)) {\n // bit 3 (16) -> gzipped data\n // bit 4 (32) -> autodetect gzip/deflate\n if ((opt.windowBits & 15) === 0) {\n opt.windowBits |= 15;\n }\n }\n\n this.err = 0; // error code, if happens (0 = Z_OK)\n this.msg = ''; // error message\n this.ended = false; // used to avoid multiple onEnd() calls\n this.chunks = []; // chunks of compressed data\n\n this.strm = new ZStream();\n this.strm.avail_out = 0;\n\n var status = inflateInit2(\n this.strm,\n opt.windowBits\n );\n\n if (status !== Z_OK$1) {\n throw new Error(messages[status]);\n }\n\n this.header = new GZheader();\n\n inflateGetHeader(this.strm, this.header);\n}\n\n/**\n * Inflate#push(data[, mode]) -> Boolean\n * - data (Uint8Array|Array|ArrayBuffer|String): input data\n * - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.\n * See constants. Skipped or `false` means Z_NO_FLUSH, `true` meansh Z_FINISH.\n *\n * Sends input data to inflate pipe, generating [[Inflate#onData]] calls with\n * new output chunks. Returns `true` on success. The last data block must have\n * mode Z_FINISH (or `true`). That will flush internal pending buffers and call\n * [[Inflate#onEnd]]. For interim explicit flushes (without ending the stream) you\n * can use mode Z_SYNC_FLUSH, keeping the decompression context.\n *\n * On fail call [[Inflate#onEnd]] with error code and return false.\n *\n * We strongly recommend to use `Uint8Array` on input for best speed (output\n * format is detected automatically). Also, don't skip last param and always\n * use the same type in your code (boolean or number). That will improve JS speed.\n *\n * For regular `Array`-s make sure all elements are [0..255].\n *\n * ##### Example\n *\n * ```javascript\n * push(chunk, false); // push one of data chunks\n * ...\n * push(chunk, true); // push last chunk\n * ```\n **/\nInflate.prototype.push = function (data, mode) {\n var strm = this.strm;\n var chunkSize = this.options.chunkSize;\n var dictionary = this.options.dictionary;\n var status, _mode;\n var next_out_utf8, tail, utf8str;\n var dict;\n\n // Flag to properly process Z_BUF_ERROR on testing inflate call\n // when we check that all output data was flushed.\n var allowBufError = false;\n\n if (this.ended) { return false; }\n _mode = (mode === ~~mode) ? mode : ((mode === true) ? Z_FINISH$1 : Z_NO_FLUSH);\n\n // Convert data if needed\n if (typeof data === 'string') {\n // Only binary strings can be decompressed on practice\n strm.input = binstring2buf(data);\n } else if (toString.call(data) === '[object ArrayBuffer]') {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\n\n do {\n if (strm.avail_out === 0) {\n strm.output = new Uint8Array(chunkSize);\n strm.next_out = 0;\n strm.avail_out = chunkSize;\n }\n\n status = inflate(strm, Z_NO_FLUSH); /* no bad return value */\n\n if (status === Z_NEED_DICT$1 && dictionary) {\n // Convert data if needed\n if (typeof dictionary === 'string') {\n dict = string2buf(dictionary);\n } else if (toString.call(dictionary) === '[object ArrayBuffer]') {\n dict = new Uint8Array(dictionary);\n } else {\n dict = dictionary;\n }\n\n status = inflateSetDictionary(this.strm, dict);\n\n }\n\n if (status === Z_BUF_ERROR$1 && allowBufError === true) {\n status = Z_OK$1;\n allowBufError = false;\n }\n\n if (status !== Z_STREAM_END$1 && status !== Z_OK$1) {\n this.onEnd(status);\n this.ended = true;\n return false;\n }\n\n if (strm.next_out) {\n if (strm.avail_out === 0 || status === Z_STREAM_END$1 || (strm.avail_in === 0 && (_mode === Z_FINISH$1 || _mode === Z_SYNC_FLUSH))) {\n\n if (this.options.to === 'string') {\n\n next_out_utf8 = utf8border(strm.output, strm.next_out);\n\n tail = strm.next_out - next_out_utf8;\n utf8str = buf2string(strm.output, next_out_utf8);\n\n // move tail\n strm.next_out = tail;\n strm.avail_out = chunkSize - tail;\n if (tail) { arraySet(strm.output, strm.output, next_out_utf8, tail, 0); }\n\n this.onData(utf8str);\n\n } else {\n this.onData(shrinkBuf(strm.output, strm.next_out));\n }\n }\n }\n\n // When no more input data, we should check that internal inflate buffers\n // are flushed. The only way to do it when avail_out = 0 - run one more\n // inflate pass. But if output data not exists, inflate return Z_BUF_ERROR.\n // Here we set flag to process this error properly.\n //\n // NOTE. Deflate does not return error in this case and does not needs such\n // logic.\n if (strm.avail_in === 0 && strm.avail_out === 0) {\n allowBufError = true;\n }\n\n } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== Z_STREAM_END$1);\n\n if (status === Z_STREAM_END$1) {\n _mode = Z_FINISH$1;\n }\n\n // Finalize on the last chunk.\n if (_mode === Z_FINISH$1) {\n status = inflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return status === Z_OK$1;\n }\n\n // callback interim results if Z_SYNC_FLUSH.\n if (_mode === Z_SYNC_FLUSH) {\n this.onEnd(Z_OK$1);\n strm.avail_out = 0;\n return true;\n }\n\n return true;\n};\n\n\n/**\n * Inflate#onData(chunk) -> Void\n * - chunk (Uint8Array|Array|String): ouput data. Type of array depends\n * on js engine support. When string output requested, each chunk\n * will be string.\n *\n * By default, stores data blocks in `chunks[]` property and glue\n * those in `onEnd`. Override this handler, if you need another behaviour.\n **/\nInflate.prototype.onData = function (chunk) {\n this.chunks.push(chunk);\n};\n\n\n/**\n * Inflate#onEnd(status) -> Void\n * - status (Number): inflate status. 0 (Z_OK) on success,\n * other if not.\n *\n * Called either after you tell inflate that the input stream is\n * complete (Z_FINISH) or should be flushed (Z_SYNC_FLUSH)\n * or if an error happened. By default - join collected chunks,\n * free memory and fill `results` / `err` properties.\n **/\nInflate.prototype.onEnd = function (status) {\n // On success - join\n if (status === Z_OK$1) {\n if (this.options.to === 'string') {\n // Glue & convert here, until we teach pako to send\n // utf8 alligned strings to onData\n this.result = this.chunks.join('');\n } else {\n this.result = flattenChunks(this.chunks);\n }\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n};\n\n\n/**\n * inflate(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * Decompress `data` with inflate/ungzip and `options`. Autodetect\n * format via wrapper header by default. That's why we don't provide\n * separate `ungzip` method.\n *\n * Supported options are:\n *\n * - windowBits\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information.\n *\n * Sugar (options):\n *\n * - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify\n * negative windowBits implicitly.\n * - `to` (String) - if equal to 'string', then result will be converted\n * from utf8 to utf16 (javascript) string. When string output requested,\n * chunk length can differ from `chunkSize`, depending on content.\n *\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , input = pako.deflate([1,2,3,4,5,6,7,8,9])\n * , output;\n *\n * try {\n * output = pako.inflate(input);\n * } catch (err)\n * console.log(err);\n * }\n * ```\n **/\nfunction doInflate(input, options) {\n var inflator = new Inflate(options);\n\n inflator.push(input, true);\n\n // That will never happens, if you don't cheat with options :)\n if (inflator.err) { throw inflator.msg; }\n\n return inflator.result;\n}\n\nexport { doInflate as ungzip };","/**\n * @file Validation Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport XmlParser, { XmlParserParameters } from './xml-parser'\nimport Validation from '../structure/validation'\nimport Streamer from '../streamer/streamer';\n\nclass ValidationParser extends XmlParser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.useDomParser = true\n this.validation = new Validation(this.name, this.path)\n }\n\n get __objName () { return 'validation' }\n get isXml () { return true }\n\n _parse () {\n super._parse()\n\n if (Debug) Log.time('ValidationParser._parse ' + this.name)\n\n this.validation.fromXml(this.xml.data)\n\n if (Debug) Log.timeEnd('ValidationParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('validation', ValidationParser)\n\nexport default ValidationParser\n","/**\n * @file Gzip Decompressor\n * @author Alexander Rose \n * @private\n */\n\nimport { ungzip } from '../../lib/pako_inflate.es6'\n\nimport { DecompressorRegistry } from '../globals'\n\nfunction gzipDecompress (data: ArrayBuffer|Uint8Array) {\n let decompressedData\n\n if (data instanceof ArrayBuffer) {\n data = new Uint8Array(data)\n }\n\n try {\n decompressedData = ungzip(data as Uint8Array)\n } catch (e) {\n decompressedData = data // assume it is already uncompressed\n }\n\n return decompressedData\n}\n\nDecompressorRegistry.add('gz', gzipDecompress)\n","/**\n * @file Datasource\n * @author Alexander Rose \n * @private\n */\n\n/**\n * Datasource base class\n * @interface\n */\nabstract class Datasource {\n /**\n * Get full url\n * @abstract\n * @param {String} path - datasource string\n * @return {String} - url\n */\n abstract getUrl (path: string): string\n\n /**\n * Get file extension\n * @abstract\n * @param {String} path - datasource string\n * @return {String} - extension\n */\n abstract getExt (path: string): string\n}\n\nexport default Datasource\n","/**\n * @file RCSB Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { Log, DatasourceRegistry } from '../globals'\nimport { getProtocol } from '../utils'\nimport { getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nconst baseUrl = '//files.rcsb.org/download/'\nconst mmtfBaseUrl = '//mmtf.rcsb.org/v1.0/'\nconst mmtfFullUrl = mmtfBaseUrl + 'full/'\nconst mmtfReducedUrl = mmtfBaseUrl + 'reduced/'\n\nclass RcsbDatasource extends Datasource {\n getUrl (src: string) {\n // valid path are\n // XXXX.pdb, XXXX.pdb.gz, XXXX.cif, XXXX.cif.gz, XXXX.mmtf, XXXX.bb.mmtf\n // XXXX defaults to XXXX.cif\n const info = getFileInfo(src)\n const pdbid = info.name.substr(0, 4)\n let url\n if ([ 'pdb', 'cif' ].includes(info.ext) &&\n (info.compressed === false || info.compressed === 'gz')\n ) {\n url = baseUrl + info.path\n } else if (info.ext === 'mmtf') {\n if (info.base.endsWith('.bb')) {\n url = mmtfReducedUrl + pdbid\n } else {\n url = mmtfFullUrl + pdbid\n }\n } else if (!info.ext) {\n url = mmtfFullUrl + pdbid\n } else {\n Log.warn('unsupported ext', info.ext)\n url = mmtfFullUrl + pdbid\n }\n return getProtocol() + url\n }\n\n getExt (src: string) {\n const ext = getFileInfo(src).ext\n return ext ? ext : 'mmtf'\n }\n}\n\nDatasourceRegistry.add('rcsb', new RcsbDatasource())\n\nexport default RcsbDatasource\n","/**\n * @file PubChem Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { Log, DatasourceRegistry } from '../globals'\nimport { getProtocol } from '../utils'\nimport { getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nconst baseUrl = '//pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/'\nconst suffixUrl = '/SDF?record_type=3d'\n\nclass PubchemDatasource extends Datasource {\n getUrl (src: string) {\n const info = getFileInfo(src)\n const cid = info.name\n let url\n if (!info.ext || info.ext === 'sdf') {\n url = baseUrl + cid + suffixUrl\n } else {\n Log.warn('unsupported ext', info.ext)\n url = baseUrl + cid + suffixUrl\n }\n return getProtocol() + url\n }\n\n getExt (src: string) {\n const ext = getFileInfo(src).ext\n return ext ? ext : 'sdf'\n }\n}\n\nDatasourceRegistry.add('pubchem', new PubchemDatasource())\n\nexport default PubchemDatasource\n","/**\n * @file Pass Through Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { DatasourceRegistry } from '../globals'\nimport { getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nclass PassThroughDatasource extends Datasource {\n getUrl (path: string) {\n return path\n }\n\n getExt (path: string) {\n return getFileInfo(path).ext\n }\n}\n\nDatasourceRegistry.add('ftp', new PassThroughDatasource())\nDatasourceRegistry.add('http', new PassThroughDatasource())\nDatasourceRegistry.add('https', new PassThroughDatasource())\n\nexport default PassThroughDatasource\n","/**\r\n * @file Alphafold Datasource\r\n * @author Fredric Johansson \r\n * @private\r\n */\r\n\r\nimport { Log, DatasourceRegistry } from '../globals'\r\nimport { getProtocol } from '../utils'\r\nimport { getFileInfo } from '../loader/loader-utils'\r\nimport Datasource from './datasource'\r\n\r\nconst baseUrl = '//alphafold.ebi.ac.uk/files/AF-'\r\nconst suffixURL = '-F1-model_v2.pdb'\r\n\r\nclass AlphafoldDatasource extends Datasource {\r\n getUrl (src: string) {\r\n const info = getFileInfo(src)\r\n const uniprotid = info.name\r\n let url\r\n if (!info.ext || info.ext === 'pdb') {\r\n url = baseUrl + uniprotid + suffixURL\r\n } else {\r\n Log.warn('unsupported AF ext', info.ext)\r\n url = baseUrl + uniprotid + suffixURL\r\n }\r\n return getProtocol() + url\r\n }\r\n\r\n getExt (src: string) {\r\n const ext = getFileInfo(src).ext\r\n return ext ? ext : 'pdb'\r\n }\r\n}\r\n\r\nDatasourceRegistry.add('alphafold', new AlphafoldDatasource())\r\n\r\nexport default AlphafoldDatasource\r\n","/**\n * @file Static Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { getAbsolutePath } from '../utils'\nimport { getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nconst reProtocol = /^((http|https|ftp):)*\\/\\//\n\nclass StaticDatasource extends Datasource {\n baseUrl: string\n\n constructor (baseUrl: string = '') {\n super()\n this.baseUrl = baseUrl\n }\n\n getUrl (src: string) {\n const info = getFileInfo(src)\n let url = this.baseUrl + info.path\n if (!reProtocol.test(this.baseUrl)) {\n url = getAbsolutePath(url)\n }\n return url\n }\n\n getExt (src: string) {\n return getFileInfo(src).ext\n }\n}\n\nexport default StaticDatasource\n","/**\n * @file MDsrv Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { autoLoad, getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nclass MdsrvDatasource extends Datasource {\n baseUrl: string\n\n constructor (baseUrl: string = '') {\n super()\n this.baseUrl = baseUrl\n }\n\n getListing (path: string = '') {\n let url = `${this.baseUrl}dir/${path}`\n if (url[url.length - 1] !== '/') url += '/'\n return autoLoad(url, {\n ext: 'json'\n }).then((jsonData: any) => ({\n path: path,\n data: jsonData.data\n }))\n }\n\n getUrl (src: string) {\n const info = getFileInfo(src)\n return `${this.baseUrl}file/${info.path}${info.query}`\n }\n\n getCountUrl (src: string) {\n const info = getFileInfo(src)\n return `${this.baseUrl}traj/numframes/${info.path}${info.query}`\n }\n\n getFrameUrl (src: string, frameIndex: number|string) {\n const info = getFileInfo(src)\n return `${this.baseUrl}traj/frame/${frameIndex}/${info.path}${info.query}`\n }\n\n getFrameParams (src: string, atomIndices: (number|string)[]) {\n return `atomIndices=${atomIndices.join(';')}`\n }\n\n getPathUrl (src: string, atomIndex: number|string) {\n const info = getFileInfo(src)\n return `${this.baseUrl}traj/path/${atomIndex}/${info.path}${info.query}`\n }\n\n getExt (src: string) {\n return getFileInfo(src).ext\n }\n}\n\nexport default MdsrvDatasource\n","/**\n * @file UI Parameters\n * @author Alexander Rose \n */\n\nimport { StageParameters } from '../stage/stage'\nimport { MouseActionPresets } from '../controls/mouse-actions'\n\nexport type BooleanParam = { type: 'boolean' }\nfunction BooleanParam () { return { type: 'boolean' } as BooleanParam }\n\nexport type ColorParam = { type: 'color' }\nfunction ColorParam () { return { type: 'color' } as ColorParam }\n\nexport type IntegerParam = { type: 'integer', max: number, min: number }\nfunction IntegerParam (max: number, min: number) {\n return { type: 'integer', max, min } as IntegerParam\n}\n\nexport type NumberParam = { type: 'number', precision: number, max: number, min: number }\nfunction NumberParam (precision: number, max: number, min: number) {\n return { type: 'number', precision, max, min } as NumberParam\n}\n\nexport type RangeParam = { type: 'range', step: number, max: number, min: number }\nfunction RangeParam (step: number, max: number, min: number) {\n return { type: 'range', step, max, min } as RangeParam\n}\n\nexport type SelectParam = { type: 'select', options: { [k: string]: string } }\nfunction SelectParam (...options: string[]) {\n return { type: 'select', options: options.reduce((o, k) => ({ ...o, [k]: k}), {}) } as SelectParam\n}\n\nexport type ParamType = BooleanParam|ColorParam|IntegerParam|NumberParam|RangeParam|SelectParam\n\nexport const UIStageParameters: { [k in keyof StageParameters]: ParamType } = {\n backgroundColor: ColorParam(),\n quality: SelectParam('auto', 'low', 'medium', 'high'),\n sampleLevel: RangeParam(1, 5, -1),\n impostor: BooleanParam(),\n workerDefault: BooleanParam(),\n rotateSpeed: NumberParam(1, 10, 0),\n zoomSpeed: NumberParam(1, 10, 0),\n panSpeed: NumberParam(1, 10, 0),\n clipNear: RangeParam(1, 100, 0),\n clipFar: RangeParam(1, 100, 0),\n clipDist: IntegerParam(200, 0),\n clipMode: SelectParam('scene', 'camera'),\n clipScale: SelectParam('relative', 'absolute'),\n fogNear: RangeParam(1, 100, 0),\n fogFar: RangeParam(1, 100, 0),\n cameraType: SelectParam('perspective', 'orthographic', 'stereo'),\n cameraEyeSep: NumberParam(3, 1.0, 0.01),\n cameraFov: RangeParam(1, 120, 15),\n lightColor: ColorParam(),\n lightIntensity: NumberParam(2, 10, 0),\n ambientColor: ColorParam(),\n ambientIntensity: NumberParam(2, 10, 0),\n hoverTimeout: IntegerParam(10000, -1),\n tooltip: BooleanParam(),\n mousePreset: SelectParam(...Object.keys(MouseActionPresets))\n}\n","/**\n * @file Version\n * @private\n * @author Alexander Rose \n */\n\nimport * as data from '../package.json'\n\n/**\n * Version name\n * @type {String}\n */\nconst Version = (data as any).version as string\n\nexport default Version\n"],"names":["getQuery","id","window","m","RegExp","exec","location","search","decodeURIComponent","defaults","value","defaultValue","undefined","createParams","params","defaultParams","o","Object","assign","k","updateParams","newParams","flatten","array","ret","i","length","Array","isArray","push","getProtocol","protocol","match","getBrowser","ua","navigator","userAgent","test","openUrl","url","open","href","download","data","downloadName","isSafari","isChromeIos","a","document","createElement","str","replace","msSaveOrOpenBlob","FileReader","Blob","reader","onloadend","result","readAsDataURL","objectUrlCreated","URL","createObjectURL","style","display","body","appendChild","target","click","removeChild","revokeObjectURL","throttle","func","wait","options","context","args","timeout","previous","later","leading","Date","now","apply","remaining","this","arguments","clearTimeout","trailing","setTimeout","lexicographicCompare","elm1","elm2","binarySearchIndexOf","element","compareFunction","low","high","mid","cmp","rangeInSortedArray","min","max","indexLeft","leftRange","binarySearchForLeftRange","indexRight","rightRange","binarySearchForRightRange","uniqueArray","sort","filter","index","sorted","uint8ToString","u8a","chunkSize","c","String","fromCharCode","subarray","join","getTypedArray","arrayType","arraySize","Int8Array","Int16Array","Int32Array","Uint8Array","Uint16Array","Uint32Array","Float32Array","Error","getUintArray","sizeOrArray","maxUint","ensureBuffer","buffer","ArrayBuffer","_ensureClassFromArray","constructor","fromArray","ensureVector3","v","Vector3","ensureMatrix4","Matrix4","ensureQuaternion","q","Quaternion","ensureFloat32Array","arg","toLowerCaseString","toString","toLowerCase","Registry","name","_dict","add","key","get","names","keys","degToRad","deg","chars","split","uuid","generateUUID","r","rnd","Math","random","clamp","lerp","start","stop","alpha","spline","p0","p1","p2","p3","t","tension","v0","v1","t2","smoothstep","x","normalize","colorSpace","ScaleDefaultParameters","scale","mode","domain","reverse","tmpColor","Color","manageColor","_target","_name","descriptor","originalMethod","fromTo","bind","set","convertSRGBToLinear","getHex","Colormaker","parameters","structure","atomProxy","getAtomProxy","getScale","p","slice","chroma","out","colorToArray","color","offset","atomColorToArray","atom","atomColor","bondColor","bond","atomIndex1","atomIndex2","bondColorToArray","volumeColorToArray","volumeColor","positionColorToArray","coords","positionColor","kwd","SelectAllKeyword","SelectNoneKeyword","AtomOnlyKeywords","BACKBONE","SIDECHAIN","BONDED","RING","AROMATICRING","METAL","POLARH","ChainKeywords","POLYMER","WATER","SmallResname","NucleophilicResname","HydrophobicResname","AromaticResname","AmideResname","AcidicResname","BasicResname","ChargedResname","PolarResname","NonpolarResname","CyclicResname","AliphaticResname","atomTestFn","s","atomname","altloc","atomindex","keyword","inscode","resname","sstruc","resno","chainname","model","isBackbone","isSidechain","isBonded","isRing","isAromatic","HETERO","isHetero","PROTEIN","isProtein","NUCLEIC","isNucleic","RNA","isRna","DNA","isDna","isPolymer","isWater","HELIX","isHelix","SHEET","isSheet","TURN","isTurn","ION","isIon","SACCHARIDE","isSaccharide","isMetal","isPolarHydrogen","includes","modelIndex","residueTestFn","atomOffset","atomEnd","chainTestFn","entity","modelTestFn","makeTest","selection","fn","error","rules","n","negate","f","subTests","hasOwnProperty","and","operator","na","ALL","NONE","filtered","fs","makeAtomTest","atomOnly","filteredSelection","makeResidueTest","residueOnly","makeChainTest","chainOnly","makeModelTest","modelOnly","Selection","string","signals","stringChanged","Signal","setString","type","silent","retSelection","newSelection","oldSelection","selectionStack","trim","charAt","substr","chunks","createNewContext","getPrevContext","pop","pushRule","rule","not","cu","toUpperCase","lastRule","indexOf","indexList","map","parseInt","b","console","resnameList","isNaN","sele","substring","chain","negate2","resi","resiSingle","resiRange","parseSele","e","message","residueTest","chainTest","modelTest","atomOnlyTest","residueOnlyTest","chainOnlyTest","modelOnlyTest","dispatch","isAllSelection","isNoneSelection","SelectionColormaker","super","colormakerList","selectionList","dataList","forEach","scheme","ColormakerRegistry","hasScheme","getScheme","ColormakerScales","OrRd","PuBu","BuPu","Oranges","BuGn","YlOrBr","YlGn","Reds","RdPu","Greens","YlGnBu","Purples","GnBu","Greys","YlOrRd","PuRd","Blues","PuBuGn","Viridis","Spectral","RdYlGn","RdBu","PiYG","PRGn","RdYlBu","BrBG","RdGy","PuOr","Set1","Set2","Set3","Dark2","Paired","Pastel1","Pastel2","Accent","rainbow","rwb","ColormakerModes","rgb","hsv","hsl","hsi","lab","hcl","getWorkerDeps","vars","deps","sym","__deps","prototype","makeWorkerString","onmessage","__name","postId","__postId","self","callback","aMessage","transferList","postMessage","makeWorkerBlob","Browser","SupportsPassiveEventHandler","opts","defineProperty","addEventListener","Mobile","orientation","SupportsReadPixelsFloat","setSupportsReadPixelsFloat","ExtensionFragDepth","setExtensionFragDepth","Log","log","Function","call","info","warn","time","timeEnd","MeasurementDefaultParams","labelColor","labelAttachment","labelSize","labelZOffset","labelYOffset","labelBorder","labelBorderColor","labelBorderWidth","lineOpacity","linewidth","opacity","labelUnit","arcVisible","planeVisible","setMeasurementDefaultParams","Debug","setDebug","ScriptExtensions","WorkerRegistry","activeWorkerCount","_funcDict","_depsDict","_blobDict","schemes","userSchemes","SchemeClass","getSchemes","types","getScales","getModes","addScheme","label","_createScheme","_addUserScheme","removeScheme","_Colormaker","addSelectionScheme","DatasourceRegistry","RepresentationRegistry","ParserRegistry","__hasObjName","objName","parser","__objName","isTrajectory","isStructure","isVolume","isSurface","isBinary","isXml","isJson","getTrajectoryExtensions","getStructureExtensions","getVolumeExtensions","getSurfaceExtensions","ShaderRegistry","DecompressorRegistry","ComponentRegistry","BufferRegistry","PickerRegistry","ListingDatasource","TrajectoryDatasource","setListingDatasource","setTrajectoryDatasource","Streamer","src","newline","__pointer","__partialLine","compressed","binary","json","xml","read","_read","then","decompressFn","_chunk","end","chunk","peekLines","charCodeAt","count","chunkToLines","lines","chunkCount","floor","asText","partialLine","isLast","idx","lastIndexOf","str2","concat","nextChunk","nextChunkOfLines","d","eachChunk","round","eachChunkOfLines","chunkNo","dispose","FileStreamer","Promise","resolve","reject","file","onload","event","onerror","readAsArrayBuffer","readAsText","NetworkStreamer","xhr","XMLHttpRequest","status","response","statusText","responseType","send","Loader","ext","dir","path","streamerParams","File","streamer","ParserLoader","parserParams","voxelSize","firstModelOnly","asTrajectory","cAlphaOnly","delimiter","comment","columnNames","inferBonds","load","parse","Script","functionBody","elementAdded","elementRemoved","nameChanged","run","stage","ScriptLoader","getFileInfo","compressedExtList","queryIndex","query","base","nameSplit","protocolMatch","getDataInfo","datasource","getUrl","getExt","autoLoad","loader","Writer","getBlob","getData","mimeType","defaultName","defaultExt","PdbWriter","renumberSerial","remarks","ensureArray","_records","_writeRecords","_writeTitle","_writeRemarks","_writeAtoms","sprintf","trajectory","frame","ia","im","charge","chargeSign","hasModels","modelStore","eachModel","eachAtom","formatString","hetero","serial","formalCharge","abs","toPrecision","y","z","occupancy","bfactor","getSelection","getString","SdfWriter","idString","titleString","title","countsString","atomCount","bondCount","chargeLines","pairs","ap","nCharges","j","formatAtom","line","formatBond","bp","bondOrder","_writeHeader","_writeCTab","_writeFooter","eachBond","charArray","IOBuffer","_mark","_marks","littleEndian","dataIsGiven","byteLength","dvOffset","byteOffset","_lastWrittenByte","_data","DataView","available","isLittleEndian","setLittleEndian","isBigEndian","setBigEndian","skip","seek","mark","reset","pushMark","popMark","rewind","ensureAvailable","newLength","newArray","readBoolean","readUint8","readInt8","getInt8","getUint8","readByte","readBytes","bytes","readInt16","getInt16","readUint16","getUint16","readInt32","getInt32","readUint32","getUint32","readFloat32","getFloat32","readFloat64","getFloat64","readChar","readChars","writeBoolean","writeUint8","writeInt8","setInt8","_updateLastWrittenByte","setUint8","writeByte","writeBytes","writeInt16","setInt16","writeUint16","setUint16","writeInt32","setInt32","writeUint32","setUint32","writeFloat32","setFloat32","writeFloat64","setFloat64","writeChar","writeChars","toArray","StlWriter","surface","triangles","output","vector","vectorNorm1","vectorNorm2","vectorNorm3","indices","normal","addVectors","position","Counter","countChanged","signalsWrapper","clear","change","delta","increment","decrement","listen","counter","unlisten","has","remove","onZeroOnce","Stats","updated","maxDuration","Infinity","minDuration","avgDuration","lastDuration","prevFpsTime","lastFps","lastFrames","frames","begin","update","startTime","currentTime","performance","reInclude","shaderCache","getShader","defines","hash","definesText","getDefines","shaderText","ShaderChunk","WebGLRenderingContext","wrcp","_getShaderParameter","getShaderParameter","_getShaderInfoLog","getShaderInfoLog","_getProgramParameter","getProgramParameter","program","pname","LINK_STATUS","_getProgramInfoLog","getProgramInfoLog","JitterVectors","offsetList","TiledRenderer","renderer","camera","viewer","canvas","_viewer","_factor","factor","_antialias","antialias","_onProgress","onProgress","_onFinish","onFinish","_n","_width","width","_height","height","_ctx","getContext","_viewerSampleLevel","sampleLevel","setSampling","_renderTile","offsetX","offsetY","setViewOffset","render","w","h","drawImage","domElement","ceil","_finalize","view","renderAsync","TwoPI","PI","RAD2DEG","circularMean","stride","cosMean","sinMean","angle","cos","sin","atan2","calculateCenterArray","array1","array2","center","calculateDirectionArray","direction","uniformArray","optionalTarget","uniformArray3","serialArray","serialBlockArray","replicateArrayEntries","repArr","copyArray","dst","srcOffset","dstOffset","copyWithin","arrayMax","il","arrayMin","arraySum","sum","arrayMean","ImageDefaultParameters","transparent","makeImage","originalClearAlpha","getClearAlpha","backgroundColor","getClearColor","setLineWidthAndPixelSize","invert","scene","traverse","material","uniforms","size","__seen","trimCanvas","bg","g","canvasHeight","canvasWidth","pixels","getImageData","doBreak","off","topY","topX","bottomY","bottomX","trimedCanvas","_trimCanvas","finished","tiledRenderer","toBlob","blob","setClearAlpha","requestRender","vertex","matrix","modelViewProjectionMatrix","resolution","Vector2","projectionMatrixInverse","projectionMatrixTranspose","updateCameraUniforms","group","getInverse","projectionMatrix","copy","transpose","u","loadShader","gl","shaderSource","shaderType","shader","createShader","compileShader","COMPILE_STATUS","deleteShader","getExtension","TextureTestTexCoords","testTextureSupport","vertShader","VERTEX_SHADER","fragShader","FRAGMENT_SHADER","shaders","attribs","locations","createProgram","attachShader","attrib","bindAttribLocation","linkProgram","deleteProgram","useProgram","positionLocation","getAttribLocation","colorLoc","getUniformLocation","positionBuffer","createBuffer","bindBuffer","ARRAY_BUFFER","bufferData","STATIC_DRAW","enableVertexAttribArray","vertexAttribPointer","FLOAT","whiteTex","createTexture","whiteData","bindTexture","TEXTURE_2D","texImage2D","RGBA","UNSIGNED_BYTE","tex","texParameteri","TEXTURE_MIN_FILTER","NEAREST","TEXTURE_MAG_FILTER","fb","createFramebuffer","bindFramebuffer","FRAMEBUFFER","framebufferTexture2D","COLOR_ATTACHMENT0","checkFramebufferStatus","FRAMEBUFFER_COMPLETE","uniform4fv","drawArrays","TRIANGLES","clearColor","COLOR_BUFFER_BIT","pixel","readPixels","floatPixel","getError","NO_ERROR","INVALID_ENUM","INVALID_VALUE","INVALID_OPERATION","INVALID_FRAMEBUFFER_OPERATION","OUT_OF_MEMORY","CONTEXT_LOST_WEBGL","getErrorDescription","pixelBufferFloat","pixelBufferUint","pixelOrder","tmpMatrix","onBeforeRender","geometry","updateList","objectId","modelViewMatrixInverse","modelViewMatrixInverseTranspose","modelViewProjectionMatrixInverse","modelViewMatrix","multiplyMatrices","matrixWorldInverse","matrixWorld","materialProperties","properties","pu","getUniforms","setValue","Viewer","idOrElement","boundingBox","Box3","boundingBoxSize","boundingBoxLength","memory","programs","geometries","textures","calls","vertices","faces","points","distVector","ticked","rendered","elm","getElementById","container","HTMLElement","innerWidth","innerHeight","box","getBoundingClientRect","overflow","wrapper","_initParams","_initStats","_initCamera","_initScene","_initRenderer","_initHelper","setBackground","setFog","animate","fogColor","fogNear","fogFar","cameraType","cameraFov","cameraEyeSep","cameraZ","clipNear","clipFar","clipDist","clipMode","clipScale","lightColor","lightIntensity","ambientColor","ambientIntensity","rendererEncoding","LinearEncoding","lookAt","perspectiveCamera","PerspectiveCamera","orthographicCamera","OrthographicCamera","stereoCamera","StereoCamera","aspect","eyeSep","updateProjectionMatrix","stats","Scene","rotationGroup","Group","translationGroup","modelGroup","pickingGroup","backgroundGroup","helperGroup","fog","Fog","spotLight","SpotLight","ambientLight","AmbientLight","dpr","devicePixelRatio","WebGLRenderer","preserveDrawingBuffer","innerHTML","setPixelRatio","setSize","autoClear","sortObjects","outputEncoding","capabilities","isWebGL2","extensions","supportsHalfFloat","dprWidth","dprHeight","JSON","stringify","OES_texture_float","OES_texture_half_float","WEBGL_color_buffer_float","pickingTarget","WebGLRenderTarget","minFilter","NearestFilter","magFilter","stencilBuffer","format","RGBAFormat","FloatType","UnsignedByteType","texture","generateMipmaps","encoding","setRenderTarget","sampleTarget","LinearFilter","holdTarget","compositeUniforms","tForeground","Uniform","compositeMaterial","ShaderMaterial","vertexShader","fragmentShader","premultipliedAlpha","blending","AdditiveBlending","depthTest","depthWrite","compositeCamera","compositeScene","Mesh","PlaneGeometry","positions","bbGeometry","BufferGeometry","setIndex","BufferAttribute","setAttribute","bbMaterial","uColor","boundingBoxMesh","LineSegments","updateHelper","attributes","needsUpdate","isEmpty","computeBoundingSphere","cameraDistance","instanceList","instance","addBuffer","wireframeGroup","background","pickable","setUserData","object","children","userData","mesh","getMesh","applyMatrix4","wireframeMesh","getWireframeMesh","quaternion","pickingMesh","getPickingMesh","_updateBoundingBox","updateBoundingBox","instanceMatrix","updateGeometry","computeBoundingBox","geoBoundingBox","clone","equals","expandByScalar","union","updateNode","node","makeEmpty","getSize","getPickingPixels","imgBuffer","readRenderTargetPixels","getImage","picking","imgBuffer2","ctx","imgData","putImageData","setLight","intensity","near","far","setClearColor","getStyle","level","setOutputEncoding","setColorWorkflow","sRGBEncoding","setCamera","fov","up","updateZoom","setClip","dist","left","right","top","bottom","handleResize","updateInfo","rInfo","rMemory","rRender","isStill","currentSampleLevel","renderPending","frameRequest","requestAnimationFrame","pick","pid","picker","pixelBuffer","oid","getObjectById","tan","zoom","absoluteToRelative","bRadius","relativeToAbsolute","__updateClipping","isFinite","getWorldPosition","cDist","nearFactor","farFactor","fogNearFactor","fogFarFactor","__updateCamera","updateMatrix","updateMatrixWorld","pixelRatio","getPixelRatio","ortho","nearClip","updateMaterialUniforms","traverseVisible","Points","sortParticles","sortData","sortArray","zArray","cmpFn","indexSrc","indexDst","tmpTab","__zArray","__sortArray","__cmpFn","ai","bi","arr","stack","tmp","sp","swap","tmp2","quicksortCmp","attr","itemSize","sortProjectedPosition","__setVisibility","helper","visible","__updateLights","setLength","__renderPickingGroup","__renderModelGroup","renderTarget","__renderSuperSample","baseSampleWeight","sampleWeight","clearViewOffset","__renderStereo","_renderTarget","setScissorTest","setScissor","setViewport","cameraL","__render","cameraR","lastRenderedPicking","rendering","cancelAnimationFrame","LeftMouseButton","MiddleMouseButton","RightMouseButton","getTouchDistance","dx","touches","pageX","dy","pageY","sqrt","MouseObserver","moved","scrolled","dragged","dropped","clicked","hovered","doubleClicked","prevPosition","down","canvasPosition","prevClickCP","moving","hovering","lastMoved","which","buttons","pressed","altKey","ctrlKey","metaKey","shiftKey","touchAction","hoverTimeout","handleScroll","doubleClickSpeed","_listen","_onMousewheel","_onMousemove","_onMousedown","_onMouseup","_onContextmenu","_onTouchstart","_onTouchend","_onTouchmove","opt","passive","setParameters","cp","doubleClickPending","lastClicked","overElement","preventDefault","_setKeys","deltaY","deltaMode","WheelEvent","DOM_DELTA_PIXEL","DOM_DELTA_LINE","wheelDelta","wheelDeltaY","detail","clientX","clientY","_setCanvasPosition","button","getMouseButtons","_distance","distanceTo","lastTouchDistance","touchDistance","removeEventListener","tmpRotateXMatrix","tmpRotateYMatrix","tmpRotateZMatrix","tmpRotateMatrix","tmpRotateCameraMatrix","tmpRotateVector","tmpRotateQuaternion","tmpRotateQuaternion2","tmpPanMatrix","tmpPanVector","tmpAtomVector","TrackballControls","rotateSpeed","zoomSpeed","panSpeed","mouse","mouseObserver","controls","viewerControls","component","transformComponent","transformAtom","_setPanVector","scaleFactor","getCanvasScaleFactor","multiplyScalar","_getRotateXY","_getCameraRotation","extractRotation","multiply","makeRotationY","_transformPanVector","transform","premultiply","pan","translate","panComponent","panAtom","positionToVector3","positionAdd","updateRepresentations","rotate","setFromAxisAngle","makeRotationFromQuaternion","applyMatrix","zRotate","dz","makeRotationZ","rotateComponent","makeRotationAxis","setFromRotationMatrix","tmpVec","PickingProxy","pickingData","getComponentsByObject","list","getObject","getPosition","closestBondAtom","atom1","v2","atom2","acp1","getPositionOnCanvas","acp2","closeAtom","ca","acp","radius","getMaxRepresentationRadius","arrow","_objectIfType","axes","cone","clash","contact","cylinder","distance","ellipsoid","octahedron","point","sphere","tetrahedron","torus","unitcell","unknown","volume","wideline","getLabel","msg","qualifiedName","sele1","sele2","shape","spacegroup","PickingControls","pickerArray","tmpQ","tmpP","tmpS","tmpCanvasVector","tmpScaleVector","tmpAlignMatrix","ViewerControls","changed","rotation","project","getCameraDistance","getOrientation","setPosition","orient","decompose","setRotationFromQuaternion","spin","axis","rotateOnAxis","align","basis","setRotationFromMatrix","Animation","duration","pausedTime","elapsedDuration","pausedDuration","ignoreGlobalToggle","_paused","_resolveList","_init","done","paused","tick","_tick","pause","hold","_hold","resume","releaseHold","toggle","SpinAnimation","RockAnimation","angleSum","angleStep","angleEnd","MoveAnimation","moveFrom","moveTo","lerpVectors","ZoomAnimation","zoomFrom","zoomTo","RotateAnimation","_currentRotation","rotateFrom","rotateTo","slerp","ValueAnimation","valueFrom","valueTo","TimeoutAnimation","AnimationList","_list","every","animation","AnimationControls","animationList","finishedList","splice","rock","move","zoomMove","orientTo","spinComponent","rockComponent","moveComponent","Queue","argList","queue","pending","next","shift","kill","Representation","lazy","step","clipRadius","precision","clipCenter","flatShaded","side","front","back","double","wireframe","colorData","colorScheme","colorScale","colorReverse","colorValue","colorDomain","colorMode","roughness","metalness","diffuse","diffuseInterior","useInteriorColor","interiorColor","interiorDarkening","disablePicking","rebuild","tasks","make","bufferList","toBePrepared","init","setColor","quality","lazyProps","build","bufferParams","what","tp","sphereDetail","radialSegments","openEnded","disableImpostor","getColorParams","getBufferParams","val","prepare","cb","create","updateWhat","_make","manualAttach","disposed","attach","setVisibility","noRenderRequest","updateParameters","int","float","parseFloat","getParameters","_Worker","postCount","onmessageDict","onerrorDict","blobUrl","worker","Worker","post","__debug","terminate","WorkerPool","maxCount","pool","getNextWorker","nextWorker","minPending","calculateMeanVector3","projectPointOnVector","origin","sub","projectOnVector","minX","minY","minZ","maxX","maxY","maxZ","l","v3new","applyMatrix4toVector3array","applyMatrix3toVector3array","normalizeVector3array","len2","v3cross","ax","ay","az","bx","by","bz","v3dot","v3sub","v3add","v3fromArray","v3toArray","input","v3length2","v3length","v3divideScalar","v3multiplyScalar","v3normalize","length2","v3subScalar","v3addScalar","v3floor","v3ceil","v3negate","v3angle","cx","cy","cz","getFixedCountDashData","segmentCount","position1","sn3","position2","i3","j3","f1","f2","replicateArray3Entries","color2","primitiveId","getFixedLengthDashData","segmentLength","pos1","pos2","col","rad","getFixedLengthWrappedDashData","drawing","k3","kprev","vl","inv","Primitive","Picker","Buffer","static","_primitiveData","getShapeKey","fields","valueToShape","expandBoundingBox","valueFromShape","arrayFromShape","dataFromShape","SpherePrimitive","expandByPoint","BoxPrimitive","heightAxis","depthAxis","OctahedronPrimitive","TetrahedronPrimitive","CylinderPrimitive","dashedCylinder","ArrowPrimitive","ConePrimitive","EllipsoidPrimitive","majorAxis","minorAxis","TorusPrimitive","TextPrimitive","text","PointPrimitive","WidelinePrimitive","SpatialHash","exp","bb","createBoundingBox","boundX","boundY","boundZ","an","xArray","yArray","grid","bucketIndex","bucketCount","bucketOffset","bucketFill","bucketArray","bucketIdx","within","eachWithin","atomIndex","rSq","loX","loY","loZ","hiX","hiY","hiZ","ix","iy","iz","dSq","Store","_fields","_defaultFields","_initField","addField","resize","tmpArray","growIfFull","copyFrom","other","thisOffset","otherOffset","thisField","otherField","thisIndex","otherIndex","offsetTarget","offsetSource","targetIndex","sourceIndex","thisStore","tmpStore","quicksort","pivot","leftNew","rightNew","index1","index2","ContactStore","addContact","hammingWeight","BitArray","setAll","_words","flip","_assignRange","words","wordValue","wordStart","wordEnd","startWord","endWord","setRange","clearRange","setBits","clearBits","clearAll","flipAll","bs","_isRangeValue","isRangeSet","isRangeClear","isAllSet","isAllClear","isSet","isClear","isEqualTo","otherBitarray","words1","words2","difference","intersection","intersects","getIntersectionSize","makeIntersection","wordsA","answer","pos","toSeleString","createAdjacencyList","edges","edgeCount","nodeCount","nodeArray1","nodeArray2","countArray","offsetArray","bondCount2","indexArray","idx1","idx2","j1","j2","createFeatureState","atomSet","addAtom","state","addFeature","features","groups","centers","atomSets","UnknownBackboneType","ChemCompProtein","ChemCompRna","ChemCompDna","ChemCompSaccharide","ChemCompHetero","SecStrucHelix","SecStrucSheet","SecStrucTurn","AtomicNumbers","H","D","T","HE","LI","BE","B","C","N","O","F","NE","NA","MG","AL","SI","P","S","CL","AR","K","CA","SC","TI","V","CR","MN","FE","CO","NI","CU","ZN","GA","GE","AS","SE","BR","KR","RB","SR","Y","ZR","NB","MO","TC","RU","RH","PD","AG","CD","IN","SN","SB","TE","I","XE","CS","BA","LA","CE","PR","ND","PM","SM","EU","GD","TB","DY","HO","ER","TM","YB","LU","HF","TA","W","RE","OS","IR","PT","AU","HG","TL","PB","BI","PO","AT","RN","FR","RA","AC","TH","PA","U","NP","PU","AM","CM","BK","CF","ES","FM","MD","NO","LR","RF","DB","SG","BH","HS","MT","DS","RG","CN","NH","FL","MC","LV","TS","OG","VdwRadii","CovalentRadii","Valences","OuterShellElectronCounts","ResidueHydrophobicity","ALA","ARG","ASN","ASP","ASH","CYS","GLN","GLU","GLH","GLY","HIS","ILE","LEU","LYS","MET","PHE","PRO","SER","THR","TRP","TYR","VAL","DefaultResidueHydrophobicity","AA1","SEC","PYL","AA3","RnaBases","DnaBases","PurinBases","Bases","WaterNames","IonNames","SaccharideNames","ProteinBackboneAtoms","NucleicBackboneAtoms","ResidueTypeAtoms","trace","direction1","direction2","backboneStart","backboneEnd","PDBQTSpecialElements","HD","A","NS","OA","SA","G0","G1","G2","G3","CG0","CG1","CG2","CG3","assignGeometry","totalCoordination","Angles","Map","calcAngles","ap1","ap2","angles","d1","d2","subVectors","eachBondedAtom","number","angleTo","calcPlaneAngle","x1","v12","neighbours","ni","cross","ValenceModel","implicitH","totalH","idealGeometry","chg","implH","totH","geom","hydrogenCount","bondToElementCount","assignCharge","assignH","degree","valence","explicitValence","conjugated","_bp","getBondProxy","atomicNumber","flag","a2","getOtherAtom","b2","atomicNumber2","isConjugated","multiBond","implicitHCount","ba","oa","calculateHydrogensCharge","valenceModel","isPhosphate","PositvelyCharged","NegativelyCharged","isIonicInteraction","ti","tj","isPiStacking","isCationPi","isHistidineNitrogen","isHydrogenBond","isWeakHydrogenBond","IonicTypeMetals","isMetalComplex","halBondElements","X","OptimalHalogenAngle","OptimalAcceptorAngle","invalidAtomContact","masterIdx","isMasterContact","ContactDefaultParams","maxHydrophobicDist","maxHbondDist","maxHbondSulfurDist","maxHbondAccAngle","maxHbondDonAngle","maxHbondAccPlaneAngle","maxHbondDonPlaneAngle","maxPiStackingDist","maxPiStackingOffset","maxPiStackingAngle","maxCationPiDist","maxCationPiOffset","maxIonicDist","maxHalogenBondDist","maxHalogenBondAngle","maxMetalDist","refineSaltBridges","masterModelIndex","lineOfSightDistFactor","residueIndex","calculateFeatures","atomInGroupDict","eachResidue","addGroup","terminalNitrogenCount","isGuanidine","isAcetamidine","addPositiveCharges","isSulfonicAcid","isSulfate","terminalOxygenCount","isCarboxylate","addNegativeCharges","rings","getAromaticRings","ring","addAromaticRings","totalBonds","ig","addHydrogenAcceptors","addHydrogenDonors","ringData","residueType","getRings","hasElement","some","residueAtomOffset","atomTypeId","atomTypeIdList","atomMap","inAromaticRingWithElectronNegativeElement","addWeakHydrogenDonors","dative","ionic","isStandardAminoacid","isStandardBase","isHalogen","addMetalBinding","isTransitionMetal","addMetals","addHydrophobic","addHalogenAcceptors","addHalogenDonors","calculateContacts","contacts","spatialHash","contactStore","featureSet","createContacts","maxDistance","maxPiStackingDistSq","maxCationPiDistSq","atomStore","areAtomSetsWithinDist","atomSet1","atomSet2","maxDist","sn","sm","si","sj","v3","n1","n2","getNormal","atoms","crossVectors","getOffset","projectOnPlane","ct","addChargedContacts","maxHbondDistSq","donor","acceptor","isWeak","connectedTo","donorAngles","idealDonorAngle","donorAngle","outOfPlane","acceptorAngles","idealAcceptorAngle","acceptorAngle","bondType","isWaterHydrogenBond","isBackboneHydrogenBond","addHydrogenBonds","m1","m2","addMetalComplexation","addHydrophobicContacts","halogen","halogenAngles","addHalogenBonds","frozenContacts","adjacencyList","contactSet","createFrozenContacts","ac1","ac2","aw","c1","c2","lineOfSightDist","lineOfSightDistFactorSq","as1","as2","vdw","distanceToSquared","refineLineOfSight","residueContactDict","handleResidueContact","minDist","minIndex","refineHydrophobicContacts","ionicInteractionDict","isHydrogenBondType","iil1","iil2","piStackingDict","pil1","pil2","refinePiStacking","refineMetalCoordination","contactTypeName","ContactDataDefaultParams","hydrogenBond","hydrophobic","halogenBond","ionicInteraction","metalCoordination","cationPi","piStacking","weakHydrogenBond","waterHydrogenBond","backboneHydrogenBond","filterSele","getContactData","filterSet","getAtomSet","setHex","contactColor","ContactPicker","getIndex","_applyTransformations","_getPosition","ShapePicker","primitive","objectFromShape","positionFromShape","AtomPicker","AxesPicker","BondPicker","bondStore","center1","center2","ClashPicker","validation","clashArray","_getAtomProxyFromSele","getAtomIndices","DistancePicker","IgnorePicker","MeshPicker","__position","SurfacePicker","UnitcellPicker","getCenter","VolumePicker","vol","dp","SlicePicker","getEdgeTable","getTriTable","MarchingCubes","field","nx","ny","nz","normalCache","vertexIndex","icount","mx","my","mz","allowedContours","isolevel","noNormals","contour","wrap","isNegativeIso","normalFactor","yd","zd","ilist","positionArray","normalArray","atomindexArray","edgeTable","triTable","VIntX","valp1","valp2","_q","mu","nc","q3","VIntY","q6","VIntZ","compNorm","polygonize","fx","fy","fz","edgeFilter","q1","qy","qz","q1y","q1z","qyz","q1yz","cubeindex","field0","field1","field2","field3","field4","field5","field6","field7","bits","fx2","fy2","fz2","e1","e2","e3","triIndex","triangulate","xBeg","yBeg","zBeg","xEnd","yEnd","zEnd","yOffset","zOffset","xBeg2","yBeg2","zBeg2","xEnd2","yEnd2","zEnd2","__break","__xBeg","__yBeg","__zBeg","__xEnd","__yEnd","__zEnd","_isolevel","_noNormals","_box","_contour","_wrap","vIndexLength","Matrix","cols","rows","copyTo","At","nrows","ncols","Ai","Ati","pAt","ad","atd","multiplyABt","Ap","pA","pB","Cp","mrows","bd","cd","multiply3x3","Cd","Ad","Bd","m10","m11","m12","m13","m14","m15","m16","m17","m18","m20","m21","m22","m23","m24","m25","m26","m27","m28","meanRows","mean","subRows","row","i0","i1","hypot","EPSILON","FLT_MIN","svd","at","_m","amt","wmt","vmt","astep","_W","Vt","vstep","eps","minval","iter","maxIter","Aj","Vi","Vj","t0","t1","sd","beta","gamma","seed","val0","asum","Float64Array","JacobiSVDImpl","m4new","m4set","n11","n12","n13","n14","n21","n22","n23","n24","n31","n32","n33","n34","n41","n42","n43","n44","m4multiply","a11","a12","a13","a14","a21","a22","a23","a24","a31","a32","a33","a34","a41","a42","a43","a44","b11","b12","b13","b14","b21","b22","b23","b24","b31","b32","b33","b34","b41","b42","b43","b44","m4makeScale","m4makeTranslation","m4makeRotationY","theta","m3new","m3makeNormal","m4","r0","r1","r2","laplacianSmooth","verts","numiter","inflate","nv","nf","norms","tps","vertdeg","jl","flagvert","ao","bo","co","vi3","vdi","wtvi","wt2vi","wt2","outwt","computeVertexNormals","nv3","ab","ci","getRadiusDict","radiusList","radiusDict","getSurfaceGrid","maxRadius","extraMargin","margin","dim","maxSize","pow","tmpSize","tran","mroty","mscale","mtrans","Surface","Geometry","fromGeometry","setFromArray","geo","getColor","colormaker","tc","getPicking","getFilteredIndex","filteredIndex","elementSize","include","getAtomindex","VolumeSurface","mc","getSurface","smooth","normalMatrix","volsurf","Volume","Matrix3","inverseMatrix","setData","setAtomindex","_position","_min","_max","_mean","_rms","setStats","rms","setMatrix","me","elements","ne","getBox","_getBox","__box","_makeSurface","getValueForSigma","getSurfaceWorker","workerPool","sigma","getSigmaForValue","getDataAtomindex","getDataPosition","getDataColor","getDataPicking","getDataSize","_sum","sumSq","di","arrayRms","header","getThreeSide","FrontSide","BackSide","DoubleSide","setObjectMatrix","matrixWorldNeedsUpdate","BufferDefaultParameters","opaqueBack","forceTransparent","BufferParameterTypes","updateShader","property","uniform","updateVisibility","parameterTypes","indexVersion","wireframeIndexVersion","isImpostor","isText","isPoint","isLine","dynamic","wireframeIndexCount","defaultParameters","UniformsUtils","merge","UniformsLib","common","emissive","lights","pickingUniforms","_positionDataSize","addAttributes","initIndex","makeWireframeGeometry","attributeSize","nindex","setUsage","DYNAMIC_DRAW","makeMaterial","vertexColors","derivatives","fragDepth","wm","pm","NoBlending","wireframeMaterial","pickingMaterial","makeWireframeIndex","wireframeIndex","wireframeGeometry","setDrawRange","checkEdge","drawRange","updateWireframeIndex","updateRange","getRenderOrder","renderOrder","_getMesh","materialName","frustumCulled","getVertexShader","getFragmentShader","NEAR_CLIP","RADIUS_CLIP","PICKING","NOLIGHT","FLAT_SHADED","OPAQUE_BACK","DIFFUSE_INTERIOR","USE_INTERIOR_COLOR","addUniforms","buf","updateRenderOrder","setRenderOrder","pt","pv","propertyData","uniformData","doShaderUpdate","doVisibilityUpdate","setProperties","setUniforms","setAttributes","attribute","wu","isVector3","toJSON","MeshBuffer","SurfaceBuffer","setVisibilityTrue","setVisibilityFalse","DoubleSidedBuffer","frontMeshes","backMeshes","frontBuffer","backBuffer","ContourBuffer","SurfaceRepresentation","isolevelType","negateIsolevel","isolevelScroll","boxSize","colorVolume","useWorker","boxCenter","__boxCenter","setBox","__isolevel","__smooth","__contour","__wrap","__boxSize","onSurfaceFinish","surfaceBuffer","dullInterior","surfaceData","MouseActions","trackballControls","focus","getFocus","sign","almostIdentity","setFocus","eachRepresentation","reprElem","comp","repr","pickingProxy","animationControls","tt","tooltip","mp","innerText","measurePick","measureClear","MouseActionPresets","default","zoomScroll","focusScroll","zoomFocusScroll","rotateDrag","panDrag","zRotateDrag","zoomDrag","zoomFocusDrag","panComponentDrag","rotateComponentDrag","movePick","tooltipPick","pymol","coot","astexviewer","triggerFromString","tokens","MouseControls","actionList","disabled","preset","triggerStr","wildcard","action","KeyActions","autoView","toggleRock","toggleSpin","KeyActionPresets","toggleAnimations","toggleAntialiasing","KeyControls","char","PickingBehavior","mouseControls","_onClick","_onHover","pickingControls","MouseBehavior","_onMove","_onScroll","_onDrag","_onDblclick","AnimationBehavior","_onTick","KeyBehavior","keyControls","outline","_focusDomElement","_onKeydown","_onKeyup","_onKeypress","pressedKey","KeyboardEvent","keyCode","Annotation","content","_viewerPosition","_updateViewerPosition","_canvasPosition","_cameraPosition","pointerEvents","whiteSpace","setContent","_update","matrixChanged","displayValue","padding","fontFamily","_clientRect","getVisibility","vp","cr","depth","zIndex","ComponentControls","RadiusFactoryTypes","covalent","explicit","RadiusFactory","atomRadius","negateVector","PrincipalAxes","n3","pointsT","vm","van","vbn","vcn","va","vb","vc","begA","endA","begB","endB","begC","endC","vecA","vecB","vecC","normVecA","normVecB","normVecC","getBasisMatrix","makeBasis","determinant","getRotationQuaternion","inverse","getProjectedScaleForAtoms","d1a","d1b","d2a","d2b","d3a","d3b","ax1","ax2","ax3","dp1","dot","dt1","dp2","dt2","dp3","dt3","FilteredVolume","minValue","maxValue","outside","setFilter","_getFilterHash","DMEAN","ARMS","filterHash","_filterHash","_dataBuffer","_positionBuffer","_atomindexBuffer","filteredData","filteredPosition","filteredAtomindex","BondHash","al","BondStore","addBond","ai1","ai2","addBondIfConnected","AtomStore","setAltloc","getAltloc","code","ResidueStore","setSstruc","getSstruc","setInscode","getInscode","ChainStore","setChainname","getChainname","setChainid","chainid","getChainid","ModelStore","Helixorient","polymer","residueCount","getCenterIterator","cache","idx3","residueIndexStart","rp","getResidueProxy","traceAtomIndex","radiusFactory","diff","rise","twist","resdir","r12","r23","r34","diff13","diff24","vt","_axis","_prevAxis","_resdir","_center","a1","getAtomIndexByType","a3","a4","acos","diff13Length","diff24Length","resRadius","resTwist","resRise","resBending","resAxis","bending","Helixbundle","helixorient","getAxis","localAngle","centerDist","ssBorder","colorParams","radiusParams","beg","residueOffset","tmpAxis","tmpCenter","_beg","_end","rp1","rp2","BinaryHeap","scoreFunction","bubbleUp","sinkDown","peek","len","parentN","parent","elemScore","child1Score","child2Score","child2N","child1N","child1","child2","Kdtree","metric","maxDepth","currentNode","nodes","rootIndex","buildTree","arrBegin","arrEnd","plength","nodeIndex","arrMedian","currentDim","pivotIndex","pivotValue","storeIndex","getNodeDepth","parentIndex","nearest","maxNodes","bestNodes","nearestSearch","bestChild","otherChild","dimension","pointIndex","ownPoint","ownDistance","saveNode","leftIndex","rightIndex","linearPoint","linearDistance","verify","AtomProxy","chainStore","residueStore","residueMap","bondHash","entityList","entityIndex","chainIndex","residue","residueTypeId","atomType","partialCharge","aromatic","_ap","hasBondTo","bap","hasBondToElement","backboneIndexList","moleculeType","isCg","backboneType","isTrace","atomRings","isNonmetal","isMetalloid","isDiatomicNonmetal","isPolyatomicNonmetal","isAlkaliMetal","isAlkalineEarthMetal","isNobleGas","isPostTransitionMetal","isLanthanide","isActinide","getDefaultValence","getValenceList","getOuterShellElectronCount","taa","aaa","distSquared","ta","aa","positionFromArray","positionToArray","positionFromVector3","positionSub","getResidueBonds","firstOnly","relativeIndex","bonds","getBonds","atomIndices1","atomIndices2","connectedAtomIndex","connectedAtomIndices","noResname","toObject","euclideanDistSq","euclideanDist","pointArray","useSquaredDist","atomIndices","kdtree","_Kdtree","nodeList","resultList","SymOpCode","$","E","G","J","L","M","Q","R","Z","_","EncodedSymOp","reInteger","selectionFromChains","chainList","Assembly","partList","addPart","matrixList","part","AssemblyPart","getAtomCount","reduce","getResidueCount","getInstanceCount","instanceCount","isIdentity","structureChainList","eachChain","getBoundingBox","partBox","_getCount","propertyName","instanceBox","structureBox","getView","getInstanceList","StructureBuilder","currentModelindex","currentChainid","currentResname","currentResno","currentInscode","currentHetero","previousResname","previousHetero","ri","mi","addResidueType","modelindex","addModel","addChain","addResidue","chainOffset","chainCount","finalize","assignSecondaryStructure","secStruct","chainnames","chainnamesSorted","chainnamesIndex","helices","h1","h2","helix","helixRun","chainChange","sheets","s1","s2","strandCharCode","sheet","sheetRun","calculateSecondaryStructure","zhangSkolnickSS","distances","isHelical","eachPolymer","cgPolymer","proteinPolymer","prevSstruc","sstrucCount","ChainnameAlphabet","calculateChainnames","useExistingBonds","doAutoChainName","mIndex","rOffset","rCount","rStart","rEnd","chainData","eachResidueN","newChain","bbType1","bbType2","bbTypeUnk","backboneEndAtomIndex","backboneStartAtomIndex","fill","calculateBonds","calculateBondsWithin","calculateBondsBetween","BondOrderTable","getBondOrderFromTable","atomname1","atomname2","onlyAddRung","rungBondStore","rungAtomSet","atomBondMap","calculateAtomBondMap","bondedAtoms","Set","rai","bondOrders","nn","rai1","rai2","getBondIndex","rungEndAtomIndex","atomSetDict","rung","onlyAddBackbone","backboneBondStore","backboneAtomSet","needsBond","needsBackbone","backbone","buildUnitcellAssembly","uc","structureCenterFrac","cartToFrac","centerFrac","symopDict","encodedSymopList","matrixDict","symopList","symop","denominator","integer","getSymmetryOperations","centerFracSymop","positionFracSymop","getMatrixList","setFromMatrixPosition","fracToCart","unitcellAssembly","unitcellMatrixList","ncsMatrixList","biomolDict","NCS","ncsUnitcellMatrixList","nm","vec","supercellAssembly","supercellMatrixList","ncsSupercellMatrixList","UNITCELL","SUPERCELL","guessElement","atomName","assignResidueTypeBonds","bondDict","nextAtomOffset","concatStructures","structures","Structure","sb","atomIndexDict","modelCount","finalizeAtoms","finalizeBonds","AlkaliMetals","AlkalineEarthMetals","PolyatomicNonmetals","DiatomicNonmetals","NobleGases","PostTransitionMetals","Metalloids","Halogens","AtomType","no","AtomMap","dict","getHash","ResidueType","chemCompType","bondReferenceAtomIndices","getMoleculeType","getBackboneType","backboneEndType","backboneStartType","getBackboneIndexList","atomnames","atomnamesStart","atomnamesEnd","traceIndex","getAtomIndexByName","dir1Index","direction1AtomIndex","dir2Index","direction2AtomIndex","bbStartIndex","bbEndIndex","rungEndIndex","atomnameList","hasProteinBackbone","hasRnaBackbone","hasDnaBackbone","hasCgProteinBackbone","hasCgRnaBackbone","hasCgDnaBackbone","hasAtomWithName","hasBackboneAtoms","hasBackbone","end1","maxd","nearestAtoms","calculateResidueBonds","calculateRings","getBondGraph","bondGraph","calculateBondGraph","getAromatic","aromaticAtoms","calculateAromatic","aromaticRings","nb","capacity","visited","pred","RingFinderMaxDepth","currentColor","RingFinderState","findRings","aromaticRingFlags","AromaticRingElements","AromaticRingPlanarityThreshold","isRingAromatic","assignBondReferenceAtomIndices","refRing","rings1","rings2","ri1","ai3","_idx2","getBondReferenceAtomIndex","bondIndex","addRing","current","leftOffset","rightOffset","found","rn","ringOffset","from","head","ResidueMap","BondProxy","_v12","_v13","_ap1","_ap2","_ap3","getOtherAtomIndex","getReferenceAtomIndex","typeAtomIndex1","typeAtomIndex2","calculateShiftDir","ap3","v13","ResidueProxy","getChainProxy","getAtomType","getResname1","getAtomnameList","rNext","bbAtomEnd","bbAtomStart","getNextConnectedResidue","nextIndex","rpNext","rpFirst","getPreviousConnectedResidue","residueProxy","prevIndex","rpPrev","rpLast","Polymer","residueIndexEnd","rpStart","rpEnd","isPrevConnected","isNextConnected","isNextNextConnected","isCyclic","__residueProxy","aIndex","eachAtomN","rStartIndex","ChainProxy","getModelProxy","residueEnd","_rp","rNextIndex","first","ModelProxy","chainEnd","_cp","refreshed","extraData","atomSetCache","boxes","bondSet","getBondSet","getBackboneBondSet","backboneBondSet","__backbone","getRungBondSet","rungBondSet","__rung","seleString","getAtomSetWithinSelection","getAtomSetWithinPoint","getAtomSetWithinVolume","fv","getMaxScaleOnAxis","getAtomSetWithinGroup","atomResidueIndex","getStructure","eachEntity","getEntityType","mn","cn","getAtomData","atomData","getBondData","multipleBond","isMulti","isOffset","bondScale","bondSpacing","bondData","storeBondOrder","radius2","absOffset","multiRadius","vShortening","vShift","getBackboneAtomData","getBackboneBondData","getRungAtomData","getRungBondData","getPrincipalAxes","atomCenter","hasCoords","_hasCoords","getSequence","seq","getChainnameCount","updatePosition","refresh","refreshPosition","tmpBox","Primitives","ShapeDefaultParameters","aspectRatio","labelParams","pointSize","sizeAttenuation","useTexture","Shape","meshCount","addMesh","meshBuffer","addSphere","objectToShape","addEllipsoid","addTorus","addCylinder","addCone","addArrow","addBox","addOctahedron","addTetrahedron","addText","addPoint","addWideline","addLabel","getBufferList","buffers","bufferFromShape","BufferRepresentation","GeometryBuffer","geoPosition","geoIndex","meshPosition","meshNormal","meshColor","meshIndex","updateNormals","geoNormal","positionCount","geoPositionCount","transformedGeoPosition","transformedGeoNormal","makeIndex","initNormals","makeTranslation","applyPositionTransform","getNormalMatrix","o3","SphereGeometryBufferDefaultParameters","SphereGeometryBuffer","IcosahedronBufferGeometry","_radius","MappedBuffer","mappingType","indexSize","mapping","mappingSize","mappingIndicesSize","nullValueAttributes","getAttributeIndex","dataIndex","makeMapping","mappingItemSize","aMapping","mappingIndices","it","MappedQuadBuffer","SphereImpostorBuffer","SphereBuffer","x0","y0","y1","PointBufferDefaultParameters","alphaTest","edgeBleach","PointBufferParameterTypes","PointBuffer","makeTexture","DataTexture","makePointTexture","USE_SIZEATTENUATION","USE_MAP","ALPHATEST","DotRepresentation","thresholdType","thresholdMin","thresholdMax","thresholdOut","dotType","radiusType","deviation","dotData","dotBuffer","quadIndices","quadUvs","ImageBufferDefaultParameters","ImageBufferParameterTypes","ImageBuffer","alwaysTransparent","hasWireframe","imageData","flipY","pickingTex","pickingMap","mapSize","startsWith","CUBIC_INTERPOLATION","endsWith","BSPLINE_FILTER","CATMULROM_FILTER","MITCHELL_FILTER","updateTexture","NormalBlending","VolumeSlice","positionType","getPositionFromCoordinate","coord","ms","setFromMatrixScale","vn","dimLen","z0","setVec","pickingArray","tMin","tMax","SliceRepresentation","linear","percent","coordinate","volumeSlice","sliceBuffer","logReprUnknown","ElementDefaultParameters","Element","statusChanged","setStatus","setName","RepresentationElementDefaultParameters","RepresentationElement","visibilityChanged","parametersChanged","setRepresentation","getType","_disposeRepresentation","hasRepresentation","removeRepresentation","toggleVisibility","setSelection","_v","ComponentDefaultParameters","Component","representationAdded","representationRemoved","reprList","annotationList","setRotation","Euler","setFromEuler","setScale","setTransform","getCenterUntransformed","makeScale","updateRepresentationMatrices","addAnnotation","annotation","eachAnnotation","removeAnnotation","removeAllAnnotations","_addRepresentation","hidden","impostor","workerDefault","ReprClass","makeRepresentation","addBufferRepresentation","removeAllRepresentations","getBoxUntransformed","getZoom","getZoomForBox","Collection","_remove","RepresentationCollection","TrajectoryElementDefaultParameters","defaultStep","defaultTimeout","defaultInterpolateType","defaultInterpolateStep","defaultMode","defaultDirection","initialFrame","TrajectoryElement","frameChanged","playerChanged","player","setFrame","Frames","coordinates","times","timeOffset","deltaTime","Superposition","atoms1","atoms2","VH","coords1","coords2","coords1t","coords2t","transformationMatrix","prepCoords","_superpose","mean1","mean2","to","invA","t4","t5","t8","t9","t11","t13","t14","t15","t17","t18","t20","t21","t23","t26","invert3x3","md","mat3x3determinant","transformMat_","tmp_1","tmp_2","mult","M1","M2","is4X4","tCoords","det","_pB","mcols","invertTrasform","mat","n4","TrajectoryPlayerDefaultParameters","interpolateType","interpolateStep","TrajectoryPlayer","traj","startedRunning","haltedRunning","_run","_previousTime","_currentTime","_currentStep","frameCount","_currentFrame","_direction","_animate","isRunning","dt","inProgress","_nextInterpolated","hasFrame","ip","ipp","ippp","setFrameInterpolated","loadFrame","_next","currentFrame","play","setPlayer","Trajectory","trajPath","frameCache","loadQueue","boxCache","pathCache","frameCacheSize","_frameCount","_disposed","centerPbc","removePbc","removePeriodicity","superpose","selectionIndices","_resetCache","_saveInitialCoords","setStructure","_loadFrameCount","backboneIndices","_getIndices","_makeAtomIndices","_saveStructureCoords","initialCoords","structureCoords","_makeSuperposeCoords","resetCache","_updateStructure","_interpolate","fc","cpp","cppp","j0","interpolateSpline","interpolateLerp","iList","_loadFrame","_doSuperpose","_process","_setFrameCount","box2","circMean","circularMean3","arrayMean3","getFrameTime","FramesTrajectory","StructureTrajectory","RemoteTrajectory","request","getFrameUrl","getFrameParams","setRequestHeader","arrayBuffer","getCountUrl","CallbackTrajectory","requestCallback","StructureView","seleList","parentSelection","ignoreView","blosum62x","prepareMatrix","cellNames","matDict","rowDict","SubstitutionMatrices","blosum62","Alignment","seq1","seq2","gapPenalty","gapExtensionPenalty","substMatrix","initMatrices","score","ali","gap","makeScoreFn","calc","gap0","scoreFn","Vi1","Si1","Hi","Si","ali1","ali2","_s1","_s2","_i","_j","aliIdx1","aliIdx2","_atoms1","_atoms2","StructureComponentDefaultParameters","defaultAssembly","StructureComponent","trajList","trajectoryAdded","trajectoryRemoved","defaultAssemblyChanged","initSelection","pickBuffer","pointer","item","createRingBuffer","pickDict","del","values","createSimpleDict","spacefillRepresentation","addRepresentation","distanceRepresentation","angleRepresentation","dihedralRepresentation","measureRepresentations","setDefaultAssembly","structureView","rebuildRepresentations","rebuildTrajectories","reprParams","trajComp","reprComp","measureUpdate","addTrajectory","trajSrc","makeTrajectory","removeTrajectory","getAtomRadius","pickCount","lastPick","atomList","atomListSorted","atomPair","atomTriple","atomQuad","measureBuild","measureData","dihedral","pickData","radiusData","removeAllMeasurements","pd","removeMeasurement","addMeasurement","SurfaceComponent","VolumeComponent","ComponentCollection","matchName","tmpZoomVector","StageDefaultParameters","mousePreset","Stage","fullscreenChanged","componentAdded","componentRemoved","compList","defaultFileParams","logList","pickingBehavior","mouseBehavior","animationBehavior","keyBehavior","spinAnimation","rockAnimation","setQuality","setImpostor","defaultFileRepresentation","BU1","assembly","sizeScore","backboneOnly","radiusScale","surfaceType","probeRadius","lineOnly","loadFile","promise","addComponentFromObject","defaultRepresentation","errorMsg","loadScript","script","addComponent","CompClass","removeComponent","removeAllComponents","toggleFullscreen","fullscreenEnabled","mozFullScreenEnabled","webkitFullscreenEnabled","msFullscreenEnabled","getFullscreenElement","fullscreenElement","mozFullScreenElement","webkitFullscreenElement","msFullscreenElement","resizeElement","lastFullscreenElement","dataset","normalWidth","normalHeight","exitFullscreen","msExitFullscreen","mozCancelFullScreen","webkitExitFullscreen","screen","requestFullscreen","msRequestFullscreen","mozRequestFullScreen","webkitRequestFullscreen","setSpin","setRock","pclamp","bbSize","minSize","aspectFactor","catch","impostorTypes","eachComponent","getComponentsByName","getRepresentationsByName","sc","ShapeComponent","__decorate","decorators","desc","getOwnPropertyDescriptor","Reflect","decorate","AtomindexColormaker","scalePerModel","BfactorColormaker","bfactorScale","ChainidColormaker","chainidDictPerModel","chainidDict","ChainindexColormaker","ChainnameColormaker","chainnameDictPerModel","chainnameDict","DensityfitColormaker","rsrzDict","rsccDict","rsrzScale","rsccScale","rsrz","rscc","partialCharges","CZ","CG","OD1","CB","OD2","OE1","OE2","CD2","CE1","ND1","NE2","NZ","SD","PTR","O1P","O2P","O3P","OG1","SEP","TPO","CD1","CE2","CE3","NE1","OH","ElectrostaticColormaker","hCharges","charges","hPositions","hPos","backboneNHPosition","bbox","hStore","buildStoreLike","hHash","ElementColors","UUT","UUP","UUH","ElementColormaker","EntityindexColormaker","entityindexScale","EntitytypeColormaker","entityType","GeoqualityColormaker","geoAtomDict","geoDict","geoProblemCount","geoAtom","atomProblems","HydrophobicityColormaker","resHF","defaultResidueHydrophobicity","hfScale","ModelindexColormaker","modelindexScale","MoleculetypeColormaker","OccupancyColormaker","occupancyScale","PartialchargeColormaker","partialchargeScale","randomColor","RandomColormaker","RandomcoilindexColormaker","rciDict","rciScale","rci","ResidueindexColormaker","scalePerChain","ResidueColors","ASX","GLX","DA","DG","DI","DX","DC","DT","DU","DD","ResnameColormaker","StructureColors","SstrucColormaker","StructuredataColormaker","_a","_b","UniformColormaker","valueColor","ValueColormaker","valueScale","VolumeColormaker","nxy","i1y","i1z","iyz","i1yz","vy","vz","v1y","v1z","vyz","v1yz","xd","c00","c01","c10","c11","c0","StructureRepresentation","radiusSize","biomolOptions","defaultScale","setRadius","getQuality","getAssembly","needsBuild","sview","createData","updateData","getRadiusParams","param","getAtomParams","getBondParams","MeasurementRepresentation","labelVisible","labelFontFamily","monospace","serif","labelFontStyle","italic","labelFontWeight","bold","labelsdf","labelXOffset","labelBackground","labelBackgroundColor","labelBackgroundMargin","labelBackgroundOpacity","labelFixedSize","labelFontstyle","textData","textBuffer","getLabelBufferParams","fontStyle","fontWeight","sdf","xOffset","attachment","showBorder","borderColor","borderWidth","showBackground","backgroundMargin","backgroundOpacity","fixedSize","parseNestedAtoms","nSets","order","selected","_break","Number","isInteger","calcArcPoint","edt","edt1d","MIN_SAFE_INTEGER","MAX_SAFE_INTEGER","TextAtlasCache","TextAtlasDefaultParams","font","variant","weight","TextAtlas","mapped","scratchW","scratchH","currentX","currentY","cutoff","lineHeight","maxWidth","fillStyle","textAlign","textBaseline","lineJoin","gridOuter","gridInner","canvas2","context2","placeholder","CanvasTexture","draw","measureText","clearRect","fillText","TextBufferDefaultParameters","fontSize","TextBufferParameterTypes","getCharCount","charCount","TextBuffer","fontTexture","inputTexCoord","inputSize","aPosition","aColor","txt","iChar","nChar","iCharAll","textAtlas","getTextAtlas","inputMapping","xadvance","xShift","yShift","texWidth","texHeight","texCoords","FIXED_SIZE","WideLineBufferDefaultParameters","WideLineBufferParameterTypes","WideLineBuffer","AngleRepresentation","vectorVisible","sectorVisible","atomPosition","okay","outPosition","outIdx","validatePositions","atomTriplePositions","angleData","labelPosition","labelText","vectorPosition1","vectorPosition2","arcPositionTmp1","arcPositionTmp2","sectorPositionTmp","totalSegments","v21","v23","cross2","labelTmp","arcPoint","crossLength","toFixed","nSegments","sectorVertices","arcVertices1","arcVertices2","appendArcSection","arcSize","sectorSize","arcPosition1","arcPosition2","sectorPosition","sectorOffset","arcOffset","getAngleData","vectorBuffer","arcLength","arcBuffer","sectorLength","sectorBuffer","vectorData","arcData","sectorData","eye","CylinderGeometryBufferDefaultParameters","getGeo","makeRotationX","CylinderBufferGeometry","CylinderGeometryBuffer","geoLength","__center","_color","_from","_to","meshData","MappedAlignedBoxBuffer","CylinderImpostorBufferDefaultParameters","CylinderImpostorBufferParameterTypes","CylinderImpostorBuffer","CAP","CylinderBuffer","AxesRepresentation","showAxes","showBox","getAxesData","pa","en","vertexPosition","vertexColor","vertexRadius","edgePosition1","edgePosition2","edgeColor","edgeRadius","addAxis","offset2","addCorner","d3","addScaledVector","edgeOffset","addEdge","edge","axesData","sphereBuffer","cylinderBuffer","sphereData","cylinderData","BallAndStickRepresentation","cylinderOnly","symmetric","lineBuffer","lineData","BackboneRepresentation","BaseRepresentation","Interpolator","vec1","vec2","vDir","vTan","vNorm","vBin","interpolateToArr","interpolateToVec","interpolatePosition","interpolateTangent","vectorSubdivide","interpolationFn","iterator","getTangent","interpolateNormalDir","u0","u1","u2","u3","norm","bin","interpolateNormal","getNormalDir","iterDir1","iterDir2","vSub1","vSub2","vSub3","vSub4","d1v1","d1v2","d1v3","d1v4","d2v1","d2v2","d2v3","d2v4","interpolateColor","item1","item2","colFn","interpolatePicking","pickFn","interpolateSize","sizeFn","Spline","directional","positionIterator","subdiv","smoothSheet","interpolator","getAtomIterator","cache2","apPrev","apNext","getSubdividedColor","nCol","getSubdividedPicking","getSubdividedPosition","getSubdividedOrientation","normals","getNormals","tangent","binormal","getSubdividedSize","nSize","nPos","nTan","nNorm","vTangent","vMeshNormal","TubeMeshBufferDefaultParameters","capped","TubeMeshBuffer","capVertices","capTriangles","xi","size2","meshPrimitiveId","normX","normY","normZ","biX","biY","biZ","posX","posY","posZ","cxArr","cyArr","cx1Arr","cy1Arr","cx2Arr","cy2Arr","cx1","cy1","cx2","cy2","radialSegments1","irs","irs1","strip","CartoonRepresentation","NaN","getSplineParams","getSpline","getAspectRatio","polymerList","subPos","subOri","subCol","subPick","subSize","ContactRepresentation","angstrom","dataParams","contactData","unit","getLabelData","DihedralRepresentation","extendLine","lineVisible","dihedralData","lineTmp1","lineTmp2","sectorTmp","planeTmp","totalLines","totalPlanes","p4","v34","inPlane1","inPlane2","improperStart","improperEnd","nLines","nPlanes","line1","line2","sector","plane","li","nSuccess","linePosition1","linePosition2","planePosition","lineOffset","planeOffset","lp1","lp2","pp","getDihedralData","lineLength","lineColor","planeLength","planeBuffer","planeData","createUpdatedObject","updateSource","hasKey","obj","createColorArray","arrayLength","targetArray","DihedralHistogramRepresentation","histogramsData","histogramBinBorderVisible","scaleBinToSectorArea","histogramBinBorderColor","adjacentBondArrowColor","distantBondArrowColor","frontHistogramColor","backHistogramColor","opaqueMiddleDiscColor","histogramOpacity","opaqueMiddleDiscVisible","opaqueMiddleDiscOpacity","histogramBinBorderWidth","histogramBinBorderOpacity","bondArrowVisible","bondArrowWidth","bondArrowOpacity","specificColorData","getHistogramBinBorderBufferParameters","getBondArrowsBufferParameters","getOpaqueMiddleDiscBufferParameters","getHistogramBufferParameters","atomPositions","scaleData","Float32Concat","arrays","lengths","accumulatedOffset","createWideLineBuffer","linesList","startPoints","endPoints","startColors","endColors","createMeshBuffer","triangleColors","histogram360Scaled","histogram360","dihedralDataArray","currentHistogramData","calculateDihedralHistogram","frontHistogramBinBordersBuffer","frontHistogramBinBorders","backHistogramBinBordersBuffer","backHistogramBinBorders","adjacentBondArrowsBuffer","adjacentBondArrows","distantBondArrowsBuffer","distantBondArrows","opaqueMiddleDiscBuffer","opaqueMiddleDisc","frontHistogramBuffer","frontHistogram","backHistogramBuffer","backHistogram","histogramData","positionOfDihedralAtoms","histogram","totalSectorTrianglesInOpaqueMiddleDisc","frontAndBack","v32","cross1","dihedralAtomVectors","absAngle","maxHist","histBinAngleStep","setHistogramBinCoordinates","ind","zeroDegreeVector","crossVector","startOffset","scalingFactor","setOneSideHistogram","discHistogram","binBorders","sectionIndex","opaqueCircleSectorAngleStep","DistanceRepresentation","useCylinder","getDistanceData","pair","distanceData","bondParams","distanceBuffer","VectorBufferDefaultParameters","VectorBuffer","HelixorientRepresentation","LicoriceRepresentation","MappedBoxBuffer","HyperballStickImpostorBufferDefaultParameters","shrink","HyperballStickImpostorBufferParameterTypes","HyperballStickImpostorBuffer","HyperballStickBuffer","calculateMinArray","HyperballRepresentation","stickData","LabelFactory","errorLogged","atomLabel","aa1","res","qualified","LabelRepresentation","labelType","labelFormat","labelGrouping","getTextData","labelFactory","positionN","sizeN","colorN","getLoneAtomSet","LineRepresentation","crosses","lone","all","crossSize","_crossData","crossData","attrSize","cPosition1","cPosition2","cColor","cColor2","cOffset","cimax","crossBuffer","bufferIdx","lineAttributes","crossAttributes","makeGrid","DataCtor","elemSize","EDTSurface","coordList","pLength","pWidth","pHeight","ptran","depty","widxz","cutRadius","setAtomID","vpBits","vpDistance","vpAtomID","btype","_probeRadius","_scaleFactor","_cutoff","_setAtomID","boundingatom","INOUT","ISDONE","ISBOUND","txz","tdept","sradius","tradius","widxzR","deptyName","indx","fillatom","ox","oy","oz","mj","mk","sk","ii","jj","kk","deptyAtNind","deptyAt","nind","pWH","ci2","fillvoxels","fillAtomWaals","fastdistancemap","boundPoint","cutRSq","totalsurfacevox","inarray","positin","outarray","positout","fastoneshell","cutoffSq","tx","ty","tz","square","nbj","tnvix","tnviy","tnviz","getVolume","tk","buildboundary","fillvoxelswaals","stype","marchingcubeinit","vd","makeAVHash","atomsX","atomsY","atomsZ","atomsR","nAtoms","hashFunc","minW","iDim","jDim","kDim","nCells","jkDim","preHash","cid","cellOffsets","cellLengths","maxCellLength","subArray","cellLength","neighbourListLength","withinRadii","rExtra","nearI","nearJ","nearK","loI","loJ","loK","hiI","hiJ","hiK","iOffset","jOffset","cellStart","cellEnd","rSum","AVSurface","probePositions","gridx","gridy","gridz","sinTable","cosTable","lastClip","atob","ngTorus","_probePositions","rExt","surfGrid","fillGridDim","initializeGrid","initializeAngleTables","obscured","singleAtomObscures","ra2","projectPoints","ar","ar2","ng","iax","iay","iaz","minx","miny","minz","maxx","maxy","maxz","xoffset","dxy2","xyoffset","spx","spy","spz","dd","projectTorus","dmp","normalToLine","rInt","cost","sint","px","py","pz","projectTorii","fixNegatives","fixAtomIDs","MolecularSurface","_getAtomData","MolecularSurfaceRepresentation","vws","sas","ses","av","__infoList","__forceNewMolsurf","prepareData","molsurf","sviewFilter","maxDim","asWithin","getSurfaceParams","__sele","__surfaceParams","after","contourBuffer","doubleSidedBuffer","PointRepresentation","pointData","RibbonBuffer","aNormal","aSize","aDir","aPrimitiveId","currSize","prevSize","RibbonRepresentation","RocketRepresentation","axisList","helixbundleList","helixbundle","axisData","RopeRepresentation","SpacefillRepresentation","TraceBuffer","linePosition","TraceRepresentation","TubeRepresentation","UnitcellRepresentation","defaultRadius","cbrt","getUnitcellData","unitcellData","ValidationRepresentation","clashData","getClashData","ConeBufferDefaultParameters","ConeBuffer","ConeBufferGeometry","_position1","_position2","GeometryGroup","geometryList","empty","ArrowBufferDefaultParameters","ArrowBuffer","splitPosition","cylinderRadius","makeAttributes","coneBuffer","vFrom","vTo","vSplit","fullLength","coneLength","BoxBuffer","BoxBufferGeometry","_heightAxis","_depthAxis","_size","EllipsoidBufferDefaultParameters","EllipsoidBuffer","_majorAxis","_minorAxis","OctahedronBuffer","OctahedronBufferGeometry","TetrahedronBuffer","TetrahedronBufferGeometry","TorusBufferDefaultParameters","radiusRatio","tubularSegments","TorusBuffer","TorusBufferGeometry","Parser","_beforeParse","_parse","_afterParse","StructureParser","structureBuilder","Entity","description","chainIndexList","entityTypeFromString","entityFromType","isNonPolymer","isMacrolide","DefaultBoxParams","Unitcell","alphaRad","betaRad","gammaRad","cosAlpha","cosBeta","cosGamma","sinBeta","sinGamma","cStar","cosAlphaStar","cornerOffset","divideScalar","centerArray3","HelixTypes","dAminoAcids","entityKeyList","reWhitespace","getModresId","PdbParser","hex","isLegacy","headerLine","headerId","legacyId","isPqr","isPdbqt","serialRadix","resnoRadix","currentCoord","doFrames","currentBiomol","currentPart","currentMatrix","recordName","startChain","startResi","startIcode","endChain","endResi","endIcode","serialDict","unitcellDict","entityDataList","currentEntityData","currentEntityKey","hetnameDict","modresDict","chainDict","chainIdx","currentChainname","seqresDict","currentSeqresChainname","modelIdx","pendingStart","ls","modresId","fromIdx","toIdx","helixType","seqresChainname","keyEnd","biomt","biomtElms","ncsName","ncs","ncsRow","ncsElms","origx","orgix","origxRow","origxElms","scaleRow","scaleElms","aLength","bLength","cLength","sGroup","_parseChunkOfLines","ei","residueDict","reQuotedWhitespace","reDoubleQuote","reTrimQuotes","trimQuotes","hasValue","cifDefaults","getBondOrder","valueOrder","CifParser","rawline","authAsymId","authSeqId","labelSeqId","labelAtomId","labelCompId","labelAsymId","labelEntityId","labelAltId","groupPDB","typeSymbol","pdbxPDBmodelNum","pdbxPDBinsCode","CartnX","CartnY","CartnZ","bIsoOrEquiv","cif","asymIdDict","chainIndexDict","pendingString","currentString","pendingValue","pendingLoop","pendingName","loopPointers","currentLoopIndex","currentCategory","currentName","pointerNames","modelNum","keyParts","category","keyValuePair","_modelNum","frameOffset","occ","assignedChainname","entityId","chem_comp","chem_comp_atom","cc","cca","ccb","chem_comp_bond","atomnameDict","comp_id","atom_id","type_symbol","model_Cartn_x","model_Cartn_y","model_Cartn_z","pdbx_component_comp_id","pdbx_residue_numbering","pdbx_model_Cartn_x_ideal","pdbx_model_Cartn_y_ideal","pdbx_model_Cartn_z_ideal","atom_id_1","atom_id_2","value_order","parseChemComp","atom_site_type_symbol","atom_site_label","atom_site_fract_x","cell_length_a","cell_length_b","cell_length_c","cell_angle_alpha","cell_angle_beta","cell_angle_gamma","atom_site_fract_y","atom_site_fract_z","atom_site_occupancy","ml","identityMatrix","covalentI","parseCore","begIcode","struct_conf","pdbx_PDB_helix_class","beg_auth_seq_id","pdbx_beg_PDB_ins_code","pdbx_end_PDB_ins_code","beg_label_asym_id","end_label_asym_id","end_auth_seq_id","ssr","struct_sheet_range","processSecondaryStructure","operDict","pdbx_struct_oper_list","biomolOp","elms","pdbx_struct_assembly_gen","gen","getMatrixDict","expr","es","assembly_id","oe","oper_expression","md1","md2","k1","k2","asym_id_list","struct_ncs_oper","ncsOp","ncsPart","cell","length_a","length_b","length_c","angle_alpha","angle_beta","angle_gamma","symmetry","database_PDB_matrix","origxMat","atom_sites","scaleMat","processSymmetry","struct_conn","atomIndicesCache","connTypeId","conn_type_id","ptnr1_symmetry","ptnr2_symmetry","inscode1","pdbx_ptnr1_PDB_ins_code","altloc1","pdbx_ptnr1_label_alt_id","ptnr1_auth_seq_id","ptnr1_label_asym_id","ptnr1_label_atom_id","selection1","inscode2","pdbx_ptnr2_PDB_ins_code","altloc2","pdbx_ptnr2_label_alt_id","ptnr2_auth_seq_id","ptnr2_label_asym_id","ptnr2_label_atom_id","selection2","tmpA","tmpB","pdbx_value_order","processConnections","pdbx_description","processEntities","struct","entry","pdbx_audit_revision_history","revision_date","dates","releaseDate","pdbx_database_status","recvd_initial_deposition_date","depDates","depositionDate","database_PDB_rev","date","date_original","reflns","d_resolution_high","refine","ls_d_res_high","ls_R_factor_R_free","rFree","ls_R_factor_R_work","rWork","exptl","method","experimentalMethods","firstLines","lpos","ypos","zpos","modelLineCount","lineNo","AllFields","ctor","typedArray","getDataView","getInt8View","getInt32View","decodeInt16","i2","decodeInt32","i4","decodeInteger","intArray","divisor","invDiv","decodeRun","dataOffset","decodeDelta","decodePacking","int16or8","upperLimit","lowerLimit","decodeIntegerPacking","decodeIntegerDeltaPacking","unpacked","decodeIntegerDelta","decodeMsgpack","dataView","performDecoding","dvOut","dvIn","decodeFloat32","decodeIntegerRun","decodeMmtf","inputDict","ignoreFields","outputDict","dv","ignore","SstrucMap","groupData","numBonds","numAtoms","numGroups","numChains","numModels","chainsPerModel","structureId","groupsPerChain","groupList","groupTypeList","atomNameList","frameAtomOffset","xCoordList","yCoordList","zCoordList","bAtomIndex1","bAtomIndex2","bBondOrder","aGroupIndex","aFormalCharge","gChainIndex","gAtomOffset","gAtomCount","cModelIndex","cGroupOffset","cGroupCount","mChainOffset","mChainCount","modelChainCount","groupOffset","chainGroupCount","bondOffset","groupAtomCount","groupFormalChargeList","formalChargeList","groupBondAtomList","bondAtomList","groupBondOrderList","bondOrderList","atomIdList","bFactorList","altLocList","occupancyList","groupIdList","secStructList","insCodeList","chainNameList","chainIdList","groupTypeDict","groupType","elementList","hetFlag","numGroupBonds","groupName","resAtomOffset","secStructLength","bioAssemblyList","_assembly","chainToPart","transformList","_transform","ncsOperatorList","ncsAssembly","_operator","unitCell","spaceGroup","bondTypes","am","du","un","moleculeLineNo","modelAtomIdxStart","currentRecordType","reItem","SdfParser","headerLines","sdfData","mItem","atomStart","bondStart","bondEnd","currentItem","currentData","isV3000","isAtomBlock","isBondBlock","acc","atomindexToStoreindex","chgTok","find","chargeCount","coffset","atomIdx","cToken","_postProcess","parseIntSubstr","PrmtopParser","pointersDict","pointers","atomNames","radii","residueLabels","residuePointers","curIdx","bondIdx","lt","NATOM","NBONH","MBONA","NRES","curResIdx","curResname","curResno","reTitle","lastSegid","segid","reField","molecules","moleculetypeDict","currentMoleculetype","fieldMatch","cIdx","molName","molCount","molType","lastResno","resIdx","chainidIdx","chainnameIdx","TrajectoryParser","notNetcdf","statement","reason","TypeError","readName","nameLength","nextPos","intView","ef","isCharmm","extraBlock","fourDims","NSET","ISTART","NSAVC","NAMNF","DELTA","titleLength","titlePos","TITLE","natom","natom4","BYTE","CHAR","SHORT","INT","DOUBLE","num2str","num2bytes","str2num","readNumber","bufferReader","numbers","readType","trimNull","ZERO","NC_DIMENSION","NC_VARIABLE","NC_ATTRIBUTE","version","recordDimension","dimList","dimensions","recordId","dimensionSize","dimensionsList","globalAttributes","attributesList","variables","varList","recordStep","variableSize","dimensionality","dimensionsIds","varSize","record","variablesList","gAttList","gAtt","NetcdfReader","hasDataVariable","variableName","findIndex","getDataVariable","variable","currentOffset","nonRecord","NctrajParser","netcdfReader","versionSize","virSize","presSize","coordSize","velocitySize","forceSize","natoms","floatSize","natoms3","frameCoords","MagicInts","sizeOfInt","num","numOfBits","_tmpBytes","sizeOfInts","numOfInts","sizes","numOfBytes","bytecnt","decodeBits","cbuf","buf2","mask","lastBB0","lastBB1","cnt","_tmpIntBytes","decodeInts","nums","minMaxInt","sizeint","bitsizeint","sizesmall","thiscoord","prevcoord","lfp","lsize","bitsize","smallidx","tmpIdx","smaller","smallnum","adz","invPrecision","buf8","isSmaller","tmpSwap","VolumeParser","getMatrix","reScientificNotation","bohrToAngstromFactor","CubeParser","originX","originY","originZ","NVX","NVY","NVZ","basisX","basisY","basisZ","oribitalFlag","lj","Dsn6Parser","summand","byteView","brixStr","xStart","yStart","zStart","xExtent","yExtent","zExtent","xRate","yRate","zRate","xlen","ylen","zlen","xBlocks","yBlocks","zBlocks","zz","yy","xx","nxyz","mapcrs","DxParser","headerInfo","parseHeaderLines","dataLineStart","headerByteCount","deltaLineCount","xmin","ymin","zmin","hx","hy","hz","uint8ToLines","MrcParser","floatView","MAP","MACHST","NX","NY","MODE","NXSTART","NYSTART","NZSTART","MX","MY","MZ","MAPC","MAPR","MAPS","DMIN","DMAX","ISPG","NSYMBT","LSKFLG","b1","b0","parseNumberLine","XplorParser","infoStart","dataStart","gridInfo","AMIN","AMAX","BMIN","BMAX","NC","CMIN","CMAX","cellInfo","lineSection","RAVE","RSIGMA","hsvToRgb","ColorDict","red","orange","gold","yellow","lime","green","sea","cyan","sky","blue","purple","magenta","hotpink","pink","peach","lilac","pinktint","peachtint","yellowtint","greentint","bluetint","lilactint","white","gray","brown","deadwhite","deadblack","invisible","reWhitespaceComma","reCurlyWhitespace","reTrimCurly","reCollapseEqual","parseListDef","defaultColor","master","lm","listName","listColor","listMasters","listWidth","parseListElm","lineBreak","triangleBreak","lsindex","literal","isLineBreak","isTriangleBreak","parseStr","parseFlag","parseGroup","flags","groupFlags","groupMasters","kinemage","onewidth","pdbfile","texts","captions","caption","groupDict","subgroupDict","masterDict","pointmasterDict","dotLists","vectorLists","ballLists","ribbonLists","currentGroupMasters","currentSubgroupMasters","dotDefaultColor","dotLabel","dotPosition","dotColor","vecDefaultColor","vecDefaultWidth","vecLabel1","vecLabel2","vecPosition1","vecPosition2","vecColor1","vecColor2","ballRadius","ballDefaultColor","ballLabel","ballPosition","ballColor","ribbonListDefaultColor","ribbonPointLabelArray","ribbonPointPositionArray","ribbonPointBreakArray","ribbonPointColorArray","isDotList","prevDotLabel","isVectorList","prevVecLabel","prevVecPosition","prevVecColor","isBallList","prevBallLabel","isRibbonList","prevRibbonPointLabel","isCaption","masterArray","labelArray","colorArray","indent","label1Array","label2Array","position1Array","position2Array","color1Array","color2Array","radiusArray","breakArray","splitLine","singlePointLine","dominant","convertedLists","listObject","convertedRibbonObject","editedLabels","editedPositions","editedColors","editedBreaks","breakPointer","positionPointer","removePointBreaksTriangleArrays","ribbonObject","convertedLabels","convertedBreaks","convertedPositions","convertedColors","vector3Positions","convertKinTriangleArrays","SurfaceParser","getLoader","OBJLoader","regexp","vertex_pattern","normal_pattern","uv_pattern","face_vertex","face_vertex_uv","face_vertex_uv_normal","face_vertex_normal","object_pattern","smoothing_pattern","material_library_pattern","material_use_pattern","setPath","_createParserState","objects","startObject","fromDeclaration","parseVertexIndex","parseNormalIndex","addVertex","addVertexLine","addNormal","addFace","nd","vLen","ib","ic","nLen","addLineGeometry","vi","lineFirstChar","lineSecondChar","trimLeft","lineParts","lineVertices","lineUVs","llen","parts","buffergeometry","PLYLoader","propertyNameMapping","setPropertyNameMapping","bin2str","isASCII","parseHeader","parseASCII","parseBinary","headerText","headerLength","currentElement","lineType","lineValues","propertValues","comments","countType","itemType","parseASCIINumber","parseASCIIElement","currentElementCount","useColor","handleElement","postProcess","colors","elementsNeedUpdate","elementName","setRGB","vertexIndices","vertex_indices","Face3","binaryRead","dataview","binaryReadElement","loc","table","reDelimiter","msgpack","netcdf","TextParser","reStrip","reTag","reContent","reAttr","parseXml","declaration","root","tag","eos","is","child","re","prefix","XmlParser","useDomParser","__xmlParser","__domParser","DOMParser","parseFromString","Document","getNamedItem","getSele","useAltcode","icode","altcode","getResSele","setBitDict","bit","hasAttrValue","getProblemCount","clashDict","ga","clashes","getElementsByTagName","Validation","atomDict","clashSele","fromXml","entries","chemicalShiftLists","randomCoilIndices","rcia","_clashDict","clashList","seleAttr","createAttribute","setNamedItem","atomSele","res1","res2","mogBondOutliers","mogAngleOutliers","vPos1","vPos2","getAtomSele","dHalf","shrinkBuf","arraySet","dest","src_offs","dest_offs","adler32","adler","crcTable","makeTable","crc32","crc","BAD$1","TYPE$1","inflate_fast","strm","_in","last","_out","dmax","wsize","whave","wnext","s_window","lcode","dcode","lmask","dmask","here","op","from_source","next_in","avail_in","next_out","avail_out","lencode","distcode","lenbits","distbits","dolen","dodist","sane","MAXBITS","ENOUGH_LENS$1","ENOUGH_DISTS$1","CODES$1","LENS$1","DISTS$1","lbase","lext","dbase","dext","inflate_table","lens","lens_index","codes","table_index","work","incr","here_bits","here_op","here_val","curr","drop","used","huff","base_index","offs","extra","extra_index","LENS","DISTS","Z_OK","Z_STREAM_ERROR","HEAD","TYPE","BAD","ENOUGH_LENS","ENOUGH_DISTS","zswap32","InflateState","havedict","check","total","wbits","ncode","nlen","ndist","have","lendyn","distdyn","was","inflateReset","total_in","total_out","inflateResetKeep","inflateInit2","windowBits","inflateReset2","lenfix","distfix","virgin","fixedtables","updatewindow","flush","put","last_bits","last_op","last_val","hbuf","inf_leave","xflags","os","extra_len","hcrc","data_type","inflateSetDictionary","dictionary","dictLength","STR_APPLY_OK","STR_APPLY_UIA_OK","__","_utf8len","string2buf","m_pos","str_len","buf_len","buf2string","c_len","utf16buf","_buf2binstring","utf8border","Z_OK$1","messages","ZStream","GZheader","Inflate","sources","source","raw","err","ended","_mode","next_out_utf8","tail","utf8str","allowBufError","binstring2buf","onEnd","onData","inflateEnd","flattenChunks","decompressedData","inflator","ungzip","Datasource","mmtfBaseUrl","mmtfFullUrl","mmtfReducedUrl","pdbid","baseUrl","suffixUrl","PassThroughDatasource","suffixURL","uniprotid","reProtocol","StaticDatasource","relativePath","pn","pathname","basePath","getAbsolutePath","MdsrvDatasource","getListing","jsonData","frameIndex","getPathUrl","IntegerParam","NumberParam","RangeParam","SelectParam","UIStageParameters","Version"],"mappings":"grCAQM,SAAUA,GAAUC,GACxB,GAAsB,oBAAXC,OAAwB,OAEnC,MACMC,EADI,IAAIC,OAAO,GAAGH,eACZI,KAAKH,OAAOI,SAASC,QAEjC,OAAIJ,EACKK,mBAAmBL,EAAE,SAE5B,CAEJ,CAcgB,SAAAM,GAAUC,EAAYC,GACpC,YAAiBC,IAAVF,EAAsBA,EAAQC,CACvC,CAEgB,SAAAE,GAAiBC,EAAgCC,GAC/D,MAAMC,EAASC,OAAOC,OAAO,CAAE,EAAEJ,GACjC,IAAK,MAAMK,KAAKJ,EAAe,MAEfH,IADAE,EAAOK,KACIH,EAAEG,GAAKJ,EAAcI,GAC/C,CACD,OAAOH,CACT,CAEgB,SAAAI,GAAiBN,EAAWO,GAC1C,IAAK,MAAMF,KAAKE,EAAW,CACzB,MAAMX,EAAQW,EAAUF,QACVP,IAAVF,IAAqBI,EAAOK,GAAKT,EACtC,CACD,OAAOI,CACT,CAUgB,SAAAQ,GAASC,EAAcC,GACrCA,EAAMf,GAASe,EAAK,IACpB,IAAK,IAAIC,EAAI,EAAGA,EAAIF,EAAMG,OAAQD,IAC5BE,MAAMC,QAAQL,EAAME,IACtBH,GAAQC,EAAME,GAAID,GAElBA,EAAIK,KAAKN,EAAME,IAGnB,OAAOD,CACT,UAEgBM,KACd,MAAMC,EAAW7B,OAAOI,SAASyB,SACjC,OAAyC,OAAlCA,EAASC,MAAM,eAA0B,QAAUD,CAC5D,UAEgBE,KACd,GAAsB,oBAAX/B,OAAwB,OAAO,EAE1C,MAAMgC,EAAKhC,OAAOiC,UAAUC,UAE5B,MAAI,YAAYC,KAAKH,GACZ,QACE,UAAUG,KAAKH,GACjB,SACE,WAAWG,KAAK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["../src/utils.ts","../src/utils/registry.ts","../src/math/math-utils.ts","../src/color/colormaker.ts","../src/selection/selection-constants.ts","../src/selection/selection-test.ts","../src/selection/selection.ts","../src/selection/selection-parser.ts","../src/color/selection-colormaker.ts","../src/color/colormaker-registry.ts","../src/worker/worker-utils.ts","../src/globals.ts","../src/worker/worker-registry.ts","../src/parser/parser-registry.ts","../src/streamer/streamer.ts","../src/streamer/file-streamer.ts","../src/streamer/network-streamer.ts","../src/loader/loader.ts","../src/loader/parser-loader.ts","../src/script.ts","../src/loader/script-loader.ts","../src/loader/loader-utils.ts","../src/writer/writer.ts","../src/writer/pdb-writer.ts","../src/writer/sdf-writer.ts","../src/utils/io-buffer.ts","../src/writer/stl-writer.ts","../src/utils/counter.ts","../src/viewer/stats.ts","../src/shader/shader-utils.ts","../src/viewer/viewer-constants.ts","../src/viewer/tiled-renderer.ts","../src/math/math-constants.ts","../src/math/array-utils.ts","../src/viewer/viewer-utils.ts","../src/viewer/gl-utils.ts","../src/viewer/viewer.ts","../src/constants.ts","../src/stage/mouse-observer.ts","../src/controls/trackball-controls.ts","../src/controls/picking-proxy.ts","../src/controls/picking-controls.ts","../src/controls/viewer-controls.ts","../src/animation/animation.ts","../src/controls/animation-controls.ts","../src/utils/queue.ts","../src/representation/representation.ts","../src/worker/worker.ts","../src/worker/worker-pool.ts","../src/math/vector-utils.ts","../src/geometry/dash.ts","../src/geometry/primitive.ts","../src/geometry/spatial-hash.ts","../src/store/store.ts","../src/store/contact-store.ts","../src/utils/bitarray.ts","../src/utils/adjacency-list.ts","../src/chemistry/interactions/features.ts","../src/structure/structure-constants.ts","../src/chemistry/geometry.ts","../src/chemistry/valence-model.ts","../src/structure/data.ts","../src/chemistry/functional-groups.ts","../src/chemistry/interactions/charged.ts","../src/chemistry/interactions/hydrogen-bonds.ts","../src/chemistry/interactions/metal-binding.ts","../src/chemistry/interactions/halogen-bonds.ts","../src/chemistry/interactions/refine-contacts.ts","../src/chemistry/interactions/contact.ts","../src/chemistry/interactions/hydrophobic.ts","../src/utils/picker.ts","../src/surface/marching-cubes.ts","../src/math/matrix-utils.ts","../src/surface/surface-utils.ts","../src/surface/surface.ts","../src/surface/volume.ts","../src/buffer/buffer.ts","../src/buffer/mesh-buffer.ts","../src/buffer/surface-buffer.ts","../src/buffer/doublesided-buffer.ts","../src/buffer/contour-buffer.ts","../src/representation/surface-representation.ts","../src/controls/mouse-actions.ts","../src/controls/mouse-controls.ts","../src/controls/key-actions.ts","../src/controls/key-controls.ts","../src/stage/picking-behavior.ts","../src/stage/mouse-behavior.ts","../src/stage/animation-behavior.ts","../src/stage/key-behavior.ts","../src/component/annotation.ts","../src/controls/component-controls.ts","../src/utils/radius-factory.ts","../src/math/principal-axes.ts","../src/surface/filtered-volume.ts","../src/store/bond-hash.ts","../src/store/bond-store.ts","../src/store/atom-store.ts","../src/store/residue-store.ts","../src/store/chain-store.ts","../src/store/model-store.ts","../src/geometry/helixorient.ts","../src/geometry/helixbundle.ts","../src/utils/binary-heap.ts","../src/utils/kdtree.ts","../src/proxy/atom-proxy.ts","../src/geometry/kdtree.ts","../src/symmetry/symmetry-constants.ts","../src/symmetry/symmetry-utils.ts","../src/symmetry/assembly.ts","../src/structure/structure-builder.ts","../src/structure/structure-utils.ts","../src/store/atom-type.ts","../src/store/atom-map.ts","../src/store/residue-type.ts","../src/store/residue-map.ts","../src/proxy/bond-proxy.ts","../src/proxy/residue-proxy.ts","../src/proxy/polymer.ts","../src/proxy/chain-proxy.ts","../src/proxy/model-proxy.ts","../src/structure/structure.ts","../src/geometry/shape.ts","../src/representation/buffer-representation.ts","../src/buffer/geometry-buffer.ts","../src/buffer/spheregeometry-buffer.ts","../src/buffer/mapped-buffer.ts","../src/buffer/mappedquad-buffer.ts","../src/buffer/sphereimpostor-buffer.ts","../src/buffer/sphere-buffer.ts","../src/buffer/point-buffer.ts","../src/representation/dot-representation.ts","../src/buffer/image-buffer.ts","../src/surface/volume-slice.ts","../src/representation/slice-representation.ts","../src/representation/representation-utils.ts","../src/component/element.ts","../src/component/representation-element.ts","../src/component/component.ts","../src/component/collection.ts","../src/component/representation-collection.ts","../src/component/trajectory-element.ts","../src/trajectory/frames.ts","../src/align/superposition.ts","../src/trajectory/trajectory-player.ts","../src/trajectory/trajectory.ts","../src/trajectory/frames-trajectory.ts","../src/trajectory/structure-trajectory.ts","../src/trajectory/remote-trajectory.ts","../src/trajectory/callback-trajectory.ts","../src/structure/structure-view.ts","../src/align/alignment.ts","../src/align/align-utils.ts","../src/component/structure-component.ts","../src/trajectory/trajectory-utils.ts","../src/component/surface-component.ts","../src/component/volume-component.ts","../src/component/component-collection.ts","../src/stage/stage.ts","../src/component/shape-component.ts","../node_modules/tslib/tslib.es6.js","../src/color/atomindex-colormaker.ts","../src/color/bfactor-colormaker.ts","../src/color/chainid-colormaker.ts","../src/color/chainindex-colormaker.ts","../src/color/chainname-colormaker.ts","../src/color/densityfit-colormaker.ts","../src/color/electrostatic-colormaker.ts","../src/color/element-colormaker.ts","../src/color/entityindex-colormaker.ts","../src/color/entitytype-colormaker.ts","../src/color/geoquality-colormaker.ts","../src/color/hydrophobicity-colormaker.ts","../src/color/modelindex-colormaker.ts","../src/color/moleculetype-colormaker.ts","../src/color/occupancy-colormaker.ts","../src/color/partialcharge-colormaker.ts","../src/color/random-colormaker.ts","../src/color/randomcoilindex-colormaker.ts","../src/color/residueindex-colormaker.ts","../src/color/resname-colormaker.ts","../src/color/sstruc-colormaker.ts","../src/color/structuredata-colormaker.ts","../src/color/uniform-colormaker.ts","../src/color/value-colormaker.ts","../src/color/volume-colormaker.ts","../src/representation/structure-representation.ts","../src/representation/measurement-representation.ts","../src/utils/edt.ts","../src/buffer/text-buffer.ts","../src/buffer/wideline-buffer.ts","../src/representation/angle-representation.ts","../src/buffer/cylindergeometry-buffer.ts","../src/buffer/mappedalignedbox-buffer.ts","../src/buffer/cylinderimpostor-buffer.ts","../src/buffer/cylinder-buffer.ts","../src/representation/axes-representation.ts","../src/representation/ballandstick-representation.ts","../src/representation/backbone-representation.ts","../src/representation/base-representation.ts","../src/geometry/spline.ts","../src/buffer/tubemesh-buffer.ts","../src/representation/cartoon-representation.ts","../src/representation/contact-representation.ts","../src/representation/dihedral-representation.ts","../src/representation/dihedral-histogram-representation.ts","../src/representation/distance-representation.ts","../src/buffer/vector-buffer.ts","../src/representation/helixorient-representation.ts","../src/representation/licorice-representation.ts","../src/buffer/mappedbox-buffer.ts","../src/buffer/hyperballstickimpostor-buffer.ts","../src/buffer/hyperballstick-buffer.ts","../src/representation/hyperball-representation.ts","../src/utils/label-factory.ts","../src/representation/label-representation.ts","../src/representation/line-representation.ts","../src/geometry/grid.ts","../src/surface/edt-surface.ts","../src/surface/av-surface.ts","../src/surface/molecular-surface.ts","../src/representation/molecularsurface-representation.ts","../src/representation/point-representation.ts","../src/buffer/ribbon-buffer.ts","../src/representation/ribbon-representation.ts","../src/representation/rocket-representation.ts","../src/representation/rope-representation.ts","../src/representation/spacefill-representation.ts","../src/buffer/trace-buffer.ts","../src/representation/trace-representation.ts","../src/representation/tube-representation.ts","../src/representation/unitcell-representation.ts","../src/representation/validation-representation.ts","../src/buffer/cone-buffer.ts","../src/viewer/geometry-group.ts","../src/buffer/arrow-buffer.ts","../src/buffer/box-buffer.ts","../src/buffer/ellipsoid-buffer.ts","../src/buffer/octahedron-buffer.ts","../src/buffer/tetrahedron-buffer.ts","../src/buffer/torus-buffer.ts","../src/parser/parser.ts","../src/parser/structure-parser.ts","../src/structure/entity.ts","../src/symmetry/unitcell.ts","../src/parser/pdb-parser.ts","../src/parser/cif-parser.ts","../src/parser/gro-parser.ts","../lib/mmtf.es6.js","../src/parser/mmtf-parser.ts","../src/parser/mol2-parser.ts","../src/parser/pdbqt-parser.ts","../src/parser/pqr-parser.ts","../src/parser/sdf-parser.ts","../src/parser/prmtop-parser.ts","../src/parser/psf-parser.ts","../src/parser/top-parser.ts","../src/parser/trajectory-parser.ts","../src/utils/netcdf-reader.ts","../src/parser/dcd-parser.ts","../src/parser/nctraj-parser.ts","../src/parser/trr-parser.ts","../src/parser/xtc-parser.ts","../src/parser/volume-parser.ts","../src/parser/cube-parser.ts","../src/parser/dsn6-parser.ts","../src/parser/dx-parser.ts","../src/parser/dxbin-parser.ts","../src/parser/mrc-parser.ts","../src/parser/xplor-parser.ts","../src/parser/kin-parser.ts","../src/parser/surface-parser.ts","../src/parser/obj-parser.ts","../src/parser/ply-parser.ts","../src/parser/csv-parser.ts","../src/parser/json-parser.ts","../src/parser/msgpack-parser.ts","../src/parser/netcdf-parser.ts","../src/parser/text-parser.ts","../src/utils/parse-xml.ts","../src/parser/xml-parser.ts","../src/structure/validation.ts","../lib/pako_inflate.es6.js","../src/parser/validation-parser.ts","../src/utils/gzip-decompressor.ts","../src/datasource/datasource.ts","../src/datasource/rcsb-datasource.ts","../src/datasource/pubchem-datasource.ts","../src/datasource/passthrough-datasource.ts","../src/datasource/alphafold-datasource.ts","../src/datasource/static-datasource.ts","../src/datasource/mdsrv-datasource.ts","../src/ui/parameters.ts","../src/version.ts"],"sourcesContent":["/**\n * @file Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector2, Vector3, Matrix4, Quaternion } from 'three'\n\nexport function getQuery (id: string) {\n if (typeof window === 'undefined') return undefined\n\n const a = new RegExp(`${id}=([^&#=]*)`)\n const m = a.exec(window.location.search)\n\n if (m) {\n return decodeURIComponent(m[1])\n } else {\n return undefined\n }\n}\n\nexport function boolean (value: any) {\n if (!value) {\n return false\n }\n\n if (typeof value === 'string') {\n return /^1|true|t|yes|y$/i.test(value)\n }\n\n return true\n}\n\nexport function defaults (value: any, defaultValue: any) {\n return value !== undefined ? value : defaultValue\n}\n\nexport function createParams (params: {[k in keyof T]?: any}, defaultParams: T) {\n const o: any = Object.assign({}, params)\n for (const k in defaultParams) {\n const value = params[k]\n if (value === undefined) o[k] = defaultParams[k]\n }\n return o as T\n}\n\nexport function updateParams (params: T, newParams: {[k in keyof T]?: any}) {\n for (const k in newParams) {\n const value = newParams[k]\n if (value !== undefined) params[k] = value\n }\n return params as T\n}\n\nexport function pick (object: { [index: string]: any }) {\n const properties = [].slice.call(arguments, 1)\n return properties.reduce((a: { [index: string]: any }, e: any) => {\n a[ e ] = object[ e ]\n return a\n }, {})\n}\n\nexport function flatten (array: any[], ret: any[]) {\n ret = defaults(ret, [])\n for (let i = 0; i < array.length; i++) {\n if (Array.isArray(array[i])) {\n flatten(array[i], ret)\n } else {\n ret.push(array[i])\n }\n }\n return ret\n}\n\nexport function getProtocol () {\n const protocol = window.location.protocol\n return protocol.match(/http(s)?:/gi) === null ? 'http:' : protocol\n}\n\nexport function getBrowser () {\n if (typeof window === 'undefined') return false\n\n const ua = window.navigator.userAgent\n\n if (/Opera|OPR/.test(ua)) {\n return 'Opera'\n } else if (/Chrome/i.test(ua)) {\n return 'Chrome'\n } else if (/Firefox/i.test(ua)) {\n return 'Firefox'\n } else if (/Mobile(\\/.*)? Safari/i.test(ua)) {\n return 'Mobile Safari'\n } else if (/MSIE/i.test(ua)) {\n return 'Internet Explorer'\n } else if (/Safari/i.test(ua)) {\n return 'Safari'\n }\n\n return false\n}\n\nexport function getAbsolutePath (relativePath: string) {\n const loc = window.location\n const pn = loc.pathname\n const basePath = pn.substring(0, pn.lastIndexOf('/') + 1)\n\n return loc.origin + basePath + relativePath\n}\n\nexport function deepCopy (src: any) {\n if (typeof src !== 'object') {\n return src\n }\n\n const dst: { [index: string]: any } = Array.isArray(src) ? [] : {}\n\n for (let key in src) {\n dst[ key ] = deepCopy(src[ key ])\n }\n\n return dst\n}\n\nexport function deepEqual(a: any, b: any) {\n // from https://github.com/epoberezkin/fast-deep-equal MIT\n if (a === b) return true;\n\n const arrA = Array.isArray(a)\n const arrB = Array.isArray(b)\n\n if (arrA && arrB) {\n if (a.length !== b.length) return false\n for (let i = 0; i < a.length; i++) {\n if (!deepEqual(a[i], b[i])) return false\n }\n return true\n }\n\n if (arrA !== arrB) return false\n\n if (a && b && typeof a === 'object' && typeof b === 'object') {\n const keys = Object.keys(a)\n if (keys.length !== Object.keys(b).length) return false;\n\n const dateA = a instanceof Date\n const dateB = b instanceof Date\n if (dateA && dateB) return a.getTime() === b.getTime()\n if (dateA !== dateB) return false\n\n const regexpA = a instanceof RegExp\n const regexpB = b instanceof RegExp\n if (regexpA && regexpB) return a.toString() === b.toString()\n if (regexpA !== regexpB) return false\n\n for (let i = 0; i < keys.length; i++) {\n if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false\n }\n\n for (let i = 0; i < keys.length; i++) {\n if(!deepEqual(a[keys[i]], b[keys[i]])) return false\n }\n\n return true\n }\n\n return false\n}\n\nfunction openUrl (url: string) {\n const opened = window.open(url, '_blank')\n if (!opened) {\n window.location.href = url\n }\n}\n\nexport function download (data: Blob|string, downloadName = 'download') {\n // using ideas from https://github.com/eligrey/FileSaver.js/blob/master/FileSaver.js\n\n if (!data) return\n\n const isSafari = getBrowser() === 'Safari'\n const isChromeIos = /CriOS\\/[\\d]+/.test(window.navigator.userAgent)\n\n const a = document.createElement('a')\n\n function open (str: string) {\n openUrl(isChromeIos ? str : str.replace(/^data:[^;]*;/, 'data:attachment/file;'))\n }\n\n if (typeof navigator !== 'undefined' && (navigator as any).msSaveOrOpenBlob) {\n // native saveAs in IE 10+\n (navigator as any).msSaveOrOpenBlob(data, downloadName)\n } else if ((isSafari || isChromeIos) && FileReader) {\n if (data instanceof Blob) {\n // no downloading of blob urls in Safari\n var reader = new FileReader()\n reader.onloadend = function () {\n open(reader.result as string)\n }\n reader.readAsDataURL(data)\n } else {\n open(data)\n }\n } else {\n let objectUrlCreated = false\n if (data instanceof Blob) {\n data = URL.createObjectURL(data)\n objectUrlCreated = true\n }\n\n if ('download' in a) {\n // download link available\n a.style.display = 'hidden'\n document.body.appendChild(a)\n a.href = data\n a.download = downloadName\n a.target = '_blank'\n a.click()\n document.body.removeChild(a)\n } else {\n openUrl(data)\n }\n\n if (objectUrlCreated) {\n window.URL.revokeObjectURL(data)\n }\n }\n}\n\nexport function submit (url: string, data: FormData, callback: Function, onerror: Function) {\n const xhr = new XMLHttpRequest()\n xhr.open('POST', url)\n\n xhr.addEventListener('load', function () {\n if (xhr.status === 200 || xhr.status === 304) {\n callback(xhr.response)\n } else {\n if (typeof onerror === 'function') {\n onerror(xhr.status)\n }\n }\n }, false)\n\n xhr.send(data)\n}\n\ninterface HTMLInputEvent extends Event {\n target: HTMLInputElement & EventTarget\n}\n\nexport function open (callback: Function, extensionList = ['*']) {\n const fileInput = document.createElement('input')\n fileInput.type = 'file'\n fileInput.multiple = true\n fileInput.style.display = 'hidden'\n document.body.appendChild(fileInput)\n fileInput.accept = '.' + extensionList.join(',.')\n fileInput.addEventListener('change', function (e: HTMLInputEvent) {\n callback(e.target.files)\n }, false)\n\n fileInput.click()\n}\n\nexport function throttle (func: Function, wait: number, options: { leading?: boolean, trailing?: boolean }) {\n // from http://underscorejs.org/docs/underscore.html\n\n let context: any\n let args: any\n let result: any\n let timeout: any = null\n let previous = 0\n\n if (!options) options = {}\n\n function later () {\n previous = options.leading === false ? 0 : Date.now()\n timeout = null\n result = func.apply(context, args)\n if (!timeout) context = args = null\n }\n\n return function throttle (this: any) {\n var now = Date.now()\n if (!previous && options.leading === false) previous = now\n var remaining = wait - (now - previous)\n context = this\n args = arguments\n if (remaining <= 0 || remaining > wait) {\n if (timeout) {\n clearTimeout(timeout)\n timeout = null\n }\n previous = now\n result = func.apply(context, args)\n if (!timeout) context = args = null\n } else if (!timeout && options.trailing !== false) {\n timeout = setTimeout(later, remaining)\n }\n\n return result\n }\n}\n\nexport function lexicographicCompare (elm1: T, elm2: T) {\n if (elm1 < elm2) return -1\n if (elm1 > elm2) return 1\n return 0\n}\n\n/**\n * Does a binary search to get the index of an element in the input array\n * @function\n * @example\n * var array = [ 1, 2, 3, 4, 5, 6 ];\n * var element = 4;\n * binarySearchIndexOf( array, element ); // returns 3\n *\n * @param {Array} array - sorted array\n * @param {Anything} element - element to search for in the array\n * @param {Function} [compareFunction] - compare function\n * @return {Number} the index of the element or -1 if not in the array\n */\nexport function binarySearchIndexOf (array: T[], element: T, compareFunction = lexicographicCompare) {\n let low = 0\n let high = array.length - 1\n while (low <= high) {\n const mid = (low + high) >> 1\n const cmp = compareFunction(element, array[ mid ])\n if (cmp > 0) {\n low = mid + 1\n } else if (cmp < 0) {\n high = mid - 1\n } else {\n return mid\n }\n }\n return -low - 1\n}\n\nexport function binarySearchForLeftRange (array: number[], leftRange: number) {\n let high = array.length - 1\n if (array[ high ] < leftRange) return -1\n let low = 0\n while (low <= high) {\n const mid = (low + high) >> 1\n if (array[ mid ] >= leftRange) {\n high = mid - 1\n } else {\n low = mid + 1\n }\n }\n return high + 1\n}\n\nexport function binarySearchForRightRange (array: number[], rightRange: number) {\n if (array[ 0 ] > rightRange) return -1\n let low = 0\n let high = array.length - 1\n while (low <= high) {\n const mid = (low + high) >> 1\n if (array[ mid ] > rightRange) {\n high = mid - 1\n } else {\n low = mid + 1\n }\n }\n return low - 1\n}\n\nexport function rangeInSortedArray (array: number[], min: number, max: number) {\n const indexLeft = binarySearchForLeftRange(array, min)\n const indexRight = binarySearchForRightRange(array, max)\n if (indexLeft === -1 || indexRight === -1 || indexLeft > indexRight) {\n return 0\n } else {\n return indexRight - indexLeft + 1\n }\n}\n\nexport function dataURItoImage (dataURI: string) {\n const img = document.createElement('img')\n img.src = dataURI\n return img\n}\n\nexport function uniqueArray (array: any[]) {\n return array.sort().filter(function (value, index, sorted) {\n return (index === 0) || (value !== sorted[ index - 1 ])\n })\n}\n\n// String/arraybuffer conversion\n\nexport function uint8ToString (u8a: Uint8Array) {\n const chunkSize = 0x7000\n\n if (u8a.length > chunkSize) {\n const c = []\n\n for (let i = 0; i < u8a.length; i += chunkSize) {\n c.push(String.fromCharCode.apply(\n null, u8a.subarray(i, i + chunkSize)\n ))\n }\n\n return c.join('')\n } else {\n return String.fromCharCode.apply(null, u8a)\n }\n}\n\nexport function uint8ToLines (u8a: Uint8Array, chunkSize = 1024 * 1024 * 10, newline = '\\n') {\n let partialLine = ''\n let lines: string[] = []\n\n for (let i = 0; i < u8a.length; i += chunkSize) {\n const str = uint8ToString(u8a.subarray(i, i + chunkSize))\n const idx = str.lastIndexOf(newline)\n\n if (idx === -1) {\n partialLine += str\n } else {\n const str2 = partialLine + str.substr(0, idx)\n lines = lines.concat(str2.split(newline))\n\n if (idx === str.length - newline.length) {\n partialLine = ''\n } else {\n partialLine = str.substr(idx + newline.length)\n }\n }\n }\n\n if (partialLine !== '') {\n lines.push(partialLine)\n }\n\n return lines\n}\n\nexport type TypedArrayString = 'int8'|'int16'|'int32'|'uint8'|'uint16'|'uint32'|'float32'\nexport function getTypedArray (arrayType: TypedArrayString, arraySize: number) {\n switch (arrayType) {\n case 'int8':\n return new Int8Array(arraySize)\n case 'int16':\n return new Int16Array(arraySize)\n case 'int32':\n return new Int32Array(arraySize)\n case 'uint8':\n return new Uint8Array(arraySize)\n case 'uint16':\n return new Uint16Array(arraySize)\n case 'uint32':\n return new Uint32Array(arraySize)\n case 'float32':\n return new Float32Array(arraySize)\n default:\n throw new Error('arrayType unknown: ' + arrayType)\n }\n}\n\nexport function getUintArray (sizeOrArray: any, maxUint: number) { // TODO\n const TypedArray = maxUint > 65535 ? Uint32Array : Uint16Array\n return new TypedArray(sizeOrArray)\n}\n\nexport function ensureArray (value: any) {\n return Array.isArray(value) ? value : [value]\n}\n\nexport function ensureBuffer (a: any) { // TODO\n return (a.buffer && a.buffer instanceof ArrayBuffer) ? a.buffer : a\n}\n\nfunction _ensureClassFromArg (arg: any, constructor: { new (arg: any): any }) {\n return arg instanceof constructor ? arg : new constructor(arg)\n}\n\nfunction _ensureClassFromArray (array: any, constructor: { new (): any }) {\n if (array === undefined) {\n array = new constructor()\n } else if (Array.isArray(array)) {\n array = new constructor().fromArray(array)\n }\n return array\n}\n\nexport function ensureVector2 (v?: number[]|Vector2) {\n return _ensureClassFromArray(v, Vector2)\n}\n\nexport function ensureVector3 (v?: number[]|Vector3) {\n return _ensureClassFromArray(v, Vector3)\n}\n\nexport function ensureMatrix4 (m?: number[]|Matrix4) {\n return _ensureClassFromArray(m, Matrix4)\n}\n\nexport function ensureQuaternion (q?: number[]|Quaternion) {\n return _ensureClassFromArray(q, Quaternion)\n}\n\nexport function ensureFloat32Array (a?: number[]|Float32Array) {\n return _ensureClassFromArg(a, Float32Array)\n}\n\nexport interface RingBuffer {\n has: (value: T) => boolean\n get: (value: number) => T\n push: (value: T) => void\n count: number\n data: T[]\n clear: () => void\n}\n\nexport function createRingBuffer (length: number): RingBuffer {\n let pointer = 0\n let count = 0\n const buffer: T[] = []\n\n return {\n has: function (value: any) { return buffer.indexOf(value) !== -1 },\n get: function (idx: number) { return buffer[idx] },\n push: function (item: any) {\n buffer[pointer] = item\n pointer = (length + pointer + 1) % length\n ++count\n },\n get count () { return count },\n get data () { return buffer.slice(0, Math.min(count, length)) },\n clear: function () {\n count = 0\n pointer = 0\n buffer.length = 0\n }\n }\n}\n\nexport interface SimpleDict {\n has: (k: K) => boolean\n add: (k: K, v: V) => void\n del: (k: K) => void\n values: V[]\n}\n\nexport function createSimpleDict (): SimpleDict {\n const set: { [k: string]: V } = {}\n\n return {\n has: function (k: K) { return set[JSON.stringify(k)] !== undefined },\n add: function (k: K, v: V) { set[JSON.stringify(k)] = v },\n del: function (k: K) { delete set[JSON.stringify(k)] },\n get values () { return Object.keys(set).map(k => set[k]) }\n }\n}\n\nexport interface SimpleSet {\n has: (value: T) => boolean\n add: (value: T) => void\n del: (value: T) => void\n list: T[]\n}\n\nexport function createSimpleSet (): SimpleSet {\n const set: { [k: string]: T } = {}\n\n return {\n has: function (v: T) { return set[JSON.stringify(v)] !== undefined },\n add: function (v: T) { set[JSON.stringify(v)] = v },\n del: function (v: T) { delete set[JSON.stringify(v)] },\n get list () { return Object.keys(set).map(k => set[k]) },\n }\n}\n","/**\n * @file Registry\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\n\nfunction toLowerCaseString (value: string) {\n return defaults(value, '').toString().toLowerCase()\n}\n\nexport default class Registry {\n name: string\n private _dict: {[k: string]: any}\n\n constructor (name: string) {\n this.name = name\n this._dict = {}\n }\n\n add (key: string, value: any) {\n this._dict[ toLowerCaseString(key) ] = value\n }\n\n get (key: string) {\n return this._dict[ toLowerCaseString(key) ]\n }\n\n get names () {\n return Object.keys(this._dict)\n }\n}","/**\n * @file Math Utils\n * @author Alexander Rose \n * @private\n */\n\nexport function degToRad (deg: number) {\n return deg * 0.01745 // deg * Math.PI / 180\n}\n\nexport function radToDeg (rad: number) {\n return rad * 57.29578 // rad * 180 / Math.PI\n}\n\n// http://www.broofa.com/Tools/Math.uuid.htm\nconst chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('')\nconst uuid = new Array(36)\n\nexport function generateUUID () {\n let rnd = 0\n let r\n\n for (let i = 0; i < 36; i++) {\n if (i === 8 || i === 13 || i === 18 || i === 23) {\n uuid[ i ] = '-'\n } else if (i === 14) {\n uuid[ i ] = '4'\n } else {\n if (rnd <= 0x02) rnd = 0x2000000 + (Math.random() * 0x1000000) | 0\n r = rnd & 0xf\n rnd = rnd >> 4\n uuid[ i ] = chars[ (i === 19) ? (r & 0x3) | 0x8 : r ]\n }\n }\n\n return uuid.join('')\n}\n\nexport function countSetBits (i: number) {\n i = i - ((i >> 1) & 0x55555555)\n i = (i & 0x33333333) + ((i >> 2) & 0x33333333)\n return (((i + (i >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24\n}\n\nexport function normalize (value: number, min: number, max: number) {\n return (value - min) / (max - min)\n}\n\nexport function clamp (value: number, min: number, max: number) {\n return Math.max(min, Math.min(max, value))\n}\n\nexport function pclamp (value: number) {\n return clamp(value, 0, 100)\n}\n\nexport function saturate (value: number) {\n return clamp(value, 0, 1)\n}\n\nexport function lerp (start: number, stop: number, alpha: number) {\n return start + (stop - start) * alpha\n}\n\nexport function spline (p0: number, p1: number, p2: number, p3: number, t: number, tension: number) {\n const v0 = (p2 - p0) * tension\n const v1 = (p3 - p1) * tension\n const t2 = t * t\n const t3 = t * t2\n return (2 * p1 - 2 * p2 + v0 + v1) * t3 +\n (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 +\n v0 * t + p1\n}\n\nexport function smoothstep (min: number, max: number, x: number) {\n x = saturate(normalize(x, min, max))\n return x * x * (3 - 2 * x)\n}\n\nexport function smootherstep (min: number, max: number, x: number) {\n x = saturate(normalize(x, min, max))\n return x * x * x * (x * (x * 6 - 15) + 10)\n}\n\nexport function smootheststep (min: number, max: number, x: number) {\n x = saturate(normalize(x, min, max))\n return (\n -20 * Math.pow(x, 7) +\n 70 * Math.pow(x, 6) -\n 84 * Math.pow(x, 5) +\n 35 * Math.pow(x, 4)\n )\n}\n\nexport function almostIdentity (value: number, start: number, stop: number) {\n if (value > start) return value\n const a = 2 * stop - start\n const b = 2 * start - 3 * stop\n const t = value / start\n return (a * t + b) * t * t + stop\n}","/**\n * @file Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Color } from 'three'\nimport * as chroma from 'chroma-js'\n\nimport { createParams } from '../utils'\nimport { NumberArray } from '../types'\nimport Structure from '../structure/structure'\nimport Surface from '../surface/surface'\nimport Volume from '../surface/volume'\nimport AtomProxy from '../proxy/atom-proxy'\nimport BondProxy from '../proxy/bond-proxy'\n\nexport type ColorMode = 'rgb'|'hsv'|'hsl'|'hsi'|'lab'|'hcl'\nexport type ColorSpace = 'sRGB' | 'linear'\n\n/**\n * Internal color space for all colors (global).\n * Colors are always specified as sRGB; if this is set to\n * 'linear' then colors get linearized when used internally\n * as vertex or texture colors.\n * @see setColorSpace/getColorSpace.\n */\nvar colorSpace: ColorSpace = 'sRGB' // default: don't linearize\n\n/** Set the global internal color space for colormakers */\nexport function setColorSpace(space: ColorSpace) {\n colorSpace = space\n}\n\n/** Get the global internal color space for colormakers */\nexport function getColorSpace() {\n return colorSpace\n}\n\nexport const ScaleDefaultParameters = {\n scale: 'uniform' as string|string[],\n mode: 'hcl' as ColorMode,\n domain: [ 0, 1 ] as number[],\n value: 0xFFFFFF,\n reverse: false,\n}\nexport type ScaleParameters = typeof ScaleDefaultParameters\n\nexport interface ColorData {\n atomData?: number[],\n bondData?: number[]\n}\n\nexport interface ColormakerParameters extends ScaleParameters {\n structure?: Structure\n volume?: Volume\n surface?: Surface\n data?: ColorData\n}\n\nexport type StuctureColormakerParams = { structure: Structure } & Partial\nexport type VolumeColormakerParams = { volume: Volume } & Partial\nexport type ColormakerScale = (v: number) => number\n\nconst tmpColor = new Color()\n\n/** Decorator for optionally linearizing a numeric color */\ntype colorFuncType = (value: any, fromTo?: boolean) => number // decorator applies to functions with this shape\nexport function manageColor\n (_target: Object,\n _name: string | symbol,\n descriptor: TypedPropertyDescriptor): PropertyDescriptor {\n const originalMethod = descriptor.value\n const linearize: colorFuncType = function (this: T, value: any, fromTo?: boolean) {\n let result = originalMethod!.bind(this, value, fromTo)()\n if (colorSpace == 'linear') {\n tmpColor.set(result)\n tmpColor.convertSRGBToLinear()\n return tmpColor.getHex()\n } else {\n return result\n }\n }\n descriptor.value = linearize\n return descriptor\n }\n\n/**\n * Class for making colors.\n * @interface\n */\nabstract class Colormaker {\n parameters: ColormakerParameters\n atomProxy?: AtomProxy\n\n /**\n * Create a colormaker instance\n * @param {ColormakerParameters} params - colormaker parameter\n */\n constructor (params: Partial = {}) {\n this.parameters = createParams(params, ScaleDefaultParameters)\n\n if (typeof this.parameters.value === 'string') {\n this.parameters.value = tmpColor.set(this.parameters.value).getHex()\n }\n\n if (this.parameters.structure) {\n this.atomProxy = this.parameters.structure.getAtomProxy()\n }\n }\n\n getScale (params: Partial = {}) {\n const p = createParams(params, this.parameters)\n\n if (p.scale === 'rainbow') {\n p.scale = [ 'red', 'orange', 'yellow', 'green', 'blue' ]\n } else if (p.scale === 'rwb') {\n p.scale = [ 'red', 'white', 'blue' ]\n }\n\n if (p.reverse) {\n p.domain = p.domain.slice().reverse()\n }\n return chroma\n .scale(p.scale as any) // TODO\n .mode(p.mode)\n .domain(p.domain)\n .out('num' as any) // returns RGB color as numeric (not string \"#ffffff\")\n }\n\n /**\n * save a color to an array\n * @param {Integer} color - hex color value\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n colorToArray (color: number, array: NumberArray = [], offset = 0) {\n array[ offset ] = (color >> 16 & 255) / 255\n array[ offset + 1 ] = (color >> 8 & 255) / 255\n array[ offset + 2 ] = (color & 255) / 255\n\n return array\n }\n\n atomColor? (atom: AtomProxy): number\n\n /**\n * save an atom color to an array\n * @param {AtomProxy} atom - atom to get color for\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n atomColorToArray (atom: AtomProxy, array: NumberArray, offset: number) {\n return this.colorToArray(\n this.atomColor ? this.atomColor(atom) : 0x000000, array, offset\n )\n }\n\n /**\n * return the color for an bond\n * @param {BondProxy} bond - bond to get color for\n * @param {Boolean} fromTo - whether to use the first or second atom of the bond\n * @return {Integer} hex bond color\n */\n bondColor (bond: BondProxy, fromTo: boolean) {\n if (this.atomProxy && this.atomColor) {\n this.atomProxy.index = fromTo ? bond.atomIndex1 : bond.atomIndex2\n return this.atomColor(this.atomProxy)\n } else {\n return 0x000000\n }\n }\n\n /**\n * safe a bond color to an array\n * @param {BondProxy} bond - bond to get color for\n * @param {Boolean} fromTo - whether to use the first or second atom of the bond\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n bondColorToArray (bond: BondProxy, fromTo: boolean, array: NumberArray, offset: number) {\n return this.colorToArray(\n this.bondColor(bond, fromTo), array, offset\n )\n }\n\n volumeColor? (index: number): number\n\n /**\n * safe a volume cell color to an array\n * @param {Integer} index - volume cell index\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n volumeColorToArray (index: number, array: NumberArray, offset: number) {\n return this.colorToArray(\n this.volumeColor ? this.volumeColor(index) : 0x000000, array, offset\n )\n }\n\n positionColor? (position: Vector3): number\n\n /**\n * safe a color for coordinates in space to an array\n * @param {Vector3} coords - xyz coordinates\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n positionColorToArray (coords: Vector3, array: NumberArray, offset: number) {\n return this.colorToArray(\n this.positionColor ? this.positionColor(coords) : 0x000000, array, offset\n )\n }\n}\n\nexport default Colormaker\n","/**\n * @file Selection Constants\n * @author Alexander Rose \n * @private\n */\n\nexport enum kwd {\n PROTEIN = 1,\n NUCLEIC = 2,\n RNA = 3,\n DNA = 4,\n POLYMER = 5,\n WATER = 6,\n HELIX = 7,\n SHEET = 8,\n TURN = 9,\n BACKBONE = 10,\n SIDECHAIN = 11,\n ALL = 12,\n HETERO = 13,\n ION = 14,\n SACCHARIDE = 15,\n SUGAR = 15,\n BONDED = 16,\n RING = 17,\n AROMATICRING = 18,\n METAL = 19,\n POLARH = 20,\n NONE = 21\n}\n\nexport const SelectAllKeyword = [ '*', '', 'ALL' ]\nexport const SelectNoneKeyword = [ 'NONE' ]\n\nexport const AtomOnlyKeywords = [\n kwd.BACKBONE, kwd.SIDECHAIN, kwd.BONDED, kwd.RING, kwd.AROMATICRING, kwd.METAL, kwd.POLARH\n]\n\nexport const ChainKeywords = [\n kwd.POLYMER, kwd.WATER\n]\n\nexport const SmallResname = [ 'ALA', 'GLY', 'SER' ]\nexport const NucleophilicResname = [ 'CYS', 'SER', 'THR' ]\nexport const HydrophobicResname = [ 'ALA', 'ILE', 'LEU', 'MET', 'PHE', 'PRO', 'TRP', 'VAL' ]\nexport const AromaticResname = [ 'PHE', 'TRP', 'TYR', 'HIS' ]\nexport const AmideResname = [ 'ASN', 'GLN' ]\nexport const AcidicResname = [ 'ASP', 'GLU' ]\nexport const BasicResname = [ 'ARG', 'HIS', 'LYS' ]\nexport const ChargedResname = [ 'ARG', 'ASP', 'GLU', 'HIS', 'LYS' ]\nexport const PolarResname = [ 'ASN', 'ARG', 'ASP', 'CYS', 'GLY', 'GLN', 'GLU', 'HIS', 'LYS', 'SER', 'THR', 'TYR' ]\nexport const NonpolarResname = [ 'ALA', 'ILE', 'LEU', 'MET', 'PHE', 'PRO', 'TRP', 'VAL' ]\nexport const CyclicResname = [ 'HIS', 'PHE', 'PRO', 'TRP', 'TYR' ]\nexport const AliphaticResname = [ 'ALA', 'GLY', 'ILE', 'LEU', 'VAL' ]\n","/**\n * @file Selection Test\n * @author Alexander Rose \n * @private\n */\n\nimport { binarySearchIndexOf, rangeInSortedArray } from '../utils'\nimport { kwd, AtomOnlyKeywords, ChainKeywords } from './selection-constants'\n\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\nexport type ProxyEntity = AtomProxy|ResidueProxy|ChainProxy|ModelProxy\ntype TestEntityFn = (e: ProxyEntity, s: SelectionRule) => boolean|-1\ntype FilterFn = (s: SelectionRule) => boolean\nexport type SelectionTest = false|((e: ProxyEntity) => boolean|-1)\n\nexport type SelectionOperator = 'AND'|'OR'\nexport interface SelectionRule {\n keyword?: any\n atomname?: string\n element?: string\n atomindex?: number[]\n altloc?: string\n inscode?: string\n resname?: string|string[]\n sstruc?: string\n resno?: number|[number, number]\n chainname?: string\n model?: number\n\n error?: string\n rules?: SelectionRule[]\n negate?: boolean\n operator?: SelectionOperator\n}\n\nfunction atomTestFn (a: AtomProxy, s: SelectionRule) {\n // returning -1 means the rule is not applicable\n if (s.atomname === undefined && s.element === undefined &&\n s.altloc === undefined && s.atomindex === undefined &&\n s.keyword === undefined && s.inscode === undefined &&\n s.resname === undefined && s.sstruc === undefined &&\n s.resno === undefined && s.chainname === undefined &&\n s.model === undefined\n ) return -1\n\n if (s.keyword !== undefined) {\n if (s.keyword === kwd.BACKBONE && !a.isBackbone()) return false\n if (s.keyword === kwd.SIDECHAIN && !a.isSidechain()) return false\n if (s.keyword === kwd.BONDED && !a.isBonded()) return false\n if (s.keyword === kwd.RING && !a.isRing()) return false\n if (s.keyword === kwd.AROMATICRING && !a.isAromatic()) return false\n\n if (s.keyword === kwd.HETERO && !a.isHetero()) return false\n if (s.keyword === kwd.PROTEIN && !a.isProtein()) return false\n if (s.keyword === kwd.NUCLEIC && !a.isNucleic()) return false\n if (s.keyword === kwd.RNA && !a.isRna()) return false\n if (s.keyword === kwd.DNA && !a.isDna()) return false\n if (s.keyword === kwd.POLYMER && !a.isPolymer()) return false\n if (s.keyword === kwd.WATER && !a.isWater()) return false\n if (s.keyword === kwd.HELIX && !a.isHelix()) return false\n if (s.keyword === kwd.SHEET && !a.isSheet()) return false\n if (s.keyword === kwd.TURN && !a.isTurn()) return false\n if (s.keyword === kwd.ION && !a.isIon()) return false\n if (s.keyword === kwd.SACCHARIDE && !a.isSaccharide()) return false\n if (s.keyword === kwd.METAL && !a.isMetal()) return false\n if (s.keyword === kwd.POLARH && !a.isPolarHydrogen()) return false\n }\n\n if (s.atomname !== undefined && s.atomname !== a.atomname) return false\n if (s.element !== undefined && s.element !== a.element) return false\n if (s.altloc !== undefined && s.altloc !== a.altloc) return false\n\n if (s.atomindex !== undefined &&\n binarySearchIndexOf(s.atomindex, a.index) < 0\n ) return false\n\n if (s.resname !== undefined) {\n if (Array.isArray(s.resname)) {\n if (!s.resname.includes(a.resname)) return false\n } else {\n if (s.resname !== a.resname) return false\n }\n }\n if (s.sstruc !== undefined && s.sstruc !== a.sstruc) return false\n if (s.resno !== undefined) {\n if (Array.isArray(s.resno) && s.resno.length === 2) {\n if (s.resno[0] > a.resno || s.resno[1] < a.resno) return false\n } else {\n if (s.resno !== a.resno) return false\n }\n }\n if (s.inscode !== undefined && s.inscode !== a.inscode) return false\n\n if (s.chainname !== undefined && s.chainname !== a.chainname) return false\n if (s.model !== undefined && s.model !== a.modelIndex) return false\n\n return true\n}\n\nfunction residueTestFn (r: ResidueProxy, s: SelectionRule) {\n // returning -1 means the rule is not applicable\n if (s.resname === undefined && s.resno === undefined && s.inscode === undefined &&\n s.sstruc === undefined && s.model === undefined && s.chainname === undefined &&\n s.atomindex === undefined &&\n (s.keyword === undefined || AtomOnlyKeywords.includes(s.keyword))\n ) return -1\n\n if (s.keyword !== undefined) {\n if (s.keyword === kwd.HETERO && !r.isHetero()) return false\n if (s.keyword === kwd.PROTEIN && !r.isProtein()) return false\n if (s.keyword === kwd.NUCLEIC && !r.isNucleic()) return false\n if (s.keyword === kwd.RNA && !r.isRna()) return false\n if (s.keyword === kwd.DNA && !r.isDna()) return false\n if (s.keyword === kwd.POLYMER && !r.isPolymer()) return false\n if (s.keyword === kwd.WATER && !r.isWater()) return false\n if (s.keyword === kwd.HELIX && !r.isHelix()) return false\n if (s.keyword === kwd.SHEET && !r.isSheet()) return false\n if (s.keyword === kwd.TURN && !r.isTurn()) return false\n if (s.keyword === kwd.ION && !r.isIon()) return false\n if (s.keyword === kwd.SACCHARIDE && !r.isSaccharide()) return false\n }\n\n if (s.atomindex !== undefined &&\n rangeInSortedArray(s.atomindex, r.atomOffset, r.atomEnd) === 0\n ) return false\n\n if (s.resname !== undefined) {\n if (Array.isArray(s.resname)) {\n if (!s.resname.includes(r.resname)) return false\n } else {\n if (s.resname !== r.resname) return false\n }\n }\n if (s.sstruc !== undefined && s.sstruc !== r.sstruc) return false\n if (s.resno !== undefined) {\n if (Array.isArray(s.resno) && s.resno.length === 2) {\n if (s.resno[0] > r.resno || s.resno[1] < r.resno) return false\n } else {\n if (s.resno !== r.resno) return false\n }\n }\n if (s.inscode !== undefined && s.inscode !== r.inscode) return false\n\n if (s.chainname !== undefined && s.chainname !== r.chainname) return false\n if (s.model !== undefined && s.model !== r.modelIndex) return false\n\n return true\n}\n\nfunction chainTestFn (c: ChainProxy, s: SelectionRule) {\n // returning -1 means the rule is not applicable\n if (s.chainname === undefined && s.model === undefined && s.atomindex === undefined &&\n (s.keyword === undefined || !ChainKeywords.includes(s.keyword) || !c.entity)\n ) return -1\n\n if (s.keyword !== undefined) {\n if (s.keyword === kwd.POLYMER && !c.entity.isPolymer()) return false\n if (s.keyword === kwd.WATER && !c.entity.isWater()) return false\n }\n\n if (s.atomindex !== undefined &&\n rangeInSortedArray(s.atomindex, c.atomOffset, c.atomEnd) === 0\n ) return false\n\n if (s.chainname !== undefined && s.chainname !== c.chainname) return false\n\n if (s.model !== undefined && s.model !== c.modelIndex) return false\n\n return true\n}\n\nfunction modelTestFn (m: ModelProxy, s: SelectionRule) {\n // returning -1 means the rule is not applicable\n if (s.model === undefined && s.atomindex === undefined) return -1\n\n if (s.atomindex !== undefined &&\n rangeInSortedArray(s.atomindex, m.atomOffset, m.atomEnd) === 0\n ) return false\n\n if (s.model !== undefined && s.model !== m.index) return false\n\n return true\n}\n\nfunction makeTest (selection: SelectionRule|null, fn: TestEntityFn) {\n if (selection === null) return false\n if (selection.error) return false\n if (!selection.rules || selection.rules.length === 0) return false\n\n const n = selection.rules.length\n\n const t = !selection.negate\n const f = !!selection.negate\n\n const subTests: SelectionTest[] = []\n for (let i = 0; i < n; ++i) {\n const s = selection.rules[ i ]\n if (s.hasOwnProperty('operator')) {\n subTests[ i ] = makeTest(s, fn) as SelectionTest // TODO\n }\n }\n\n // ( x and y ) can short circuit on false\n // ( x or y ) can short circuit on true\n // not ( x and y )\n\n return function test (entity: ProxyEntity) {\n const and = selection.operator === 'AND'\n let na = false\n\n for (let i = 0; i < n; ++i) {\n const s = selection.rules![ i ] // TODO\n let ret\n\n if (s.hasOwnProperty('operator')) {\n const test = subTests[ i ]\n if (test !== false) {\n ret = test(entity)\n } else {\n ret = -1\n }\n\n if (ret === -1) {\n na = true\n continue\n } else if (ret === true) {\n if (and) { continue } else { return t }\n } else {\n if (and) { return f } else { continue }\n }\n } else {\n if (s.keyword === kwd.ALL) {\n if (and) { continue } else { return t }\n } else if (s.keyword === kwd.NONE) {\n if (and) { continue } else { return f }\n }\n\n ret = fn(entity, s)\n\n // console.log( entity.qualifiedName(), ret, s, selection.negate, \"t\", t, \"f\", f )\n\n if (ret === -1) {\n na = true\n continue\n } else if (ret === true) {\n if (and) { continue } else { return t }\n } else {\n if (and) { return f } else { continue }\n }\n }\n }\n\n if (na) {\n return -1\n } else {\n if (and) { return t } else { return f }\n }\n } as SelectionTest\n}\n\nfunction filter (selection: SelectionRule, fn: FilterFn) {\n if (selection.error) return selection\n if (!selection.rules || selection.rules.length === 0) return selection\n\n const n = selection.rules.length\n\n const filtered: SelectionRule = {\n operator: selection.operator,\n rules: []\n }\n if (selection.hasOwnProperty('negate')) {\n filtered.negate = selection.negate\n }\n\n for (let i = 0; i < n; ++i) {\n const s = selection.rules[ i ]\n if (s.hasOwnProperty('operator')) {\n const fs = filter(s, fn)\n if (fs !== null) filtered.rules!.push(fs) // TODO\n } else if (!fn(s)) {\n filtered.rules!.push(s) // TODO\n }\n }\n\n if (filtered.rules!.length > 0) { // TODO\n // TODO maybe the filtered rules could be returned\n // in some case, but the way how tests are applied\n // e.g. when traversing a structure would also need\n // to change\n return selection\n // return filtered;\n } else {\n return null\n }\n}\n\nfunction makeAtomTest (selection: SelectionRule, atomOnly = false) {\n let filteredSelection: SelectionRule|null = selection\n if (atomOnly) {\n filteredSelection = filter(selection, function (s) {\n if (s.keyword !== undefined && !AtomOnlyKeywords.includes(s.keyword)) return true\n if (s.model !== undefined) return true\n if (s.chainname !== undefined) return true\n if (s.resname !== undefined) return true\n if (s.resno !== undefined) return true\n if (s.sstruc !== undefined) return true\n return false\n })\n }\n return makeTest(filteredSelection, atomTestFn)\n}\n\nfunction makeResidueTest (selection: SelectionRule, residueOnly = false) {\n let filteredSelection: SelectionRule|null = selection\n if (residueOnly) {\n filteredSelection = filter(selection, function (s) {\n if (s.keyword !== undefined && AtomOnlyKeywords.includes(s.keyword)) return true\n if (s.model !== undefined) return true\n if (s.chainname !== undefined) return true\n if (s.atomname !== undefined) return true\n if (s.element !== undefined) return true\n if (s.altloc !== undefined) return true\n return false\n })\n }\n return makeTest(filteredSelection, residueTestFn)\n}\n\nfunction makeChainTest (selection: SelectionRule, chainOnly = false) {\n let filteredSelection: SelectionRule|null = selection\n if (chainOnly) {\n filteredSelection = filter(selection, function (s) {\n if (s.keyword !== undefined && !ChainKeywords.includes(s.keyword)) return true\n // if( s.model!==undefined ) return true;\n if (s.resname !== undefined) return true\n if (s.resno !== undefined) return true\n if (s.atomname !== undefined) return true\n if (s.element !== undefined) return true\n if (s.altloc !== undefined) return true\n if (s.sstruc !== undefined) return true\n if (s.inscode !== undefined) return true\n return false\n })\n }\n return makeTest(filteredSelection, chainTestFn)\n}\n\nfunction makeModelTest (selection: SelectionRule, modelOnly = false) {\n let filteredSelection: SelectionRule|null = selection\n if (modelOnly) {\n filteredSelection = filter(selection, function (s) {\n if (s.keyword !== undefined) return true\n if (s.chainname !== undefined) return true\n if (s.resname !== undefined) return true\n if (s.resno !== undefined) return true\n if (s.atomname !== undefined) return true\n if (s.element !== undefined) return true\n if (s.altloc !== undefined) return true\n if (s.sstruc !== undefined) return true\n if (s.inscode !== undefined) return true\n return false\n })\n }\n return makeTest(filteredSelection, modelTestFn)\n}\n\nexport {\n makeAtomTest,\n makeResidueTest,\n makeChainTest,\n makeModelTest\n}\n","/**\n * @file Selection\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { parseSele } from './selection-parser'\nimport {\n SelectionTest, SelectionRule,\n makeAtomTest, makeResidueTest, makeChainTest, makeModelTest\n} from './selection-test'\nimport { SelectAllKeyword, SelectNoneKeyword } from './selection-constants'\n\nexport type SelectionSignals = {\n stringChanged: Signal\n}\n\n/**\n * Selection\n */\nclass Selection {\n signals: SelectionSignals\n string: string\n selection: SelectionRule\n\n test: SelectionTest\n residueTest: SelectionTest\n chainTest: SelectionTest\n modelTest: SelectionTest\n\n atomOnlyTest: SelectionTest\n residueOnlyTest: SelectionTest\n chainOnlyTest: SelectionTest\n modelOnlyTest: SelectionTest\n\n /**\n * Create Selection\n * @param {String} string - selection string, see {@tutorial selection-language}\n */\n constructor (string?: string) {\n this.signals = {\n stringChanged: new Signal()\n }\n\n this.setString(string)\n }\n\n get type () { return 'selection' }\n\n setString (string?: string, silent?: boolean) {\n if (string === undefined) string = this.string || ''\n if (string === this.string) return\n\n try {\n this.selection = parseSele(string)\n } catch (e) {\n // Log.error( e.stack );\n this.selection = { 'error': e.message }\n }\n const selection = this.selection\n\n this.string = string\n\n this.test = makeAtomTest(selection)\n this.residueTest = makeResidueTest(selection)\n this.chainTest = makeChainTest(selection)\n this.modelTest = makeModelTest(selection)\n\n this.atomOnlyTest = makeAtomTest(selection, true)\n this.residueOnlyTest = makeResidueTest(selection, true)\n this.chainOnlyTest = makeChainTest(selection, true)\n this.modelOnlyTest = makeModelTest(selection, true)\n\n if (!silent) {\n this.signals.stringChanged.dispatch(this.string)\n }\n }\n\n isAllSelection () {\n return SelectAllKeyword.includes(this.string.toUpperCase())\n }\n\n isNoneSelection () {\n return SelectNoneKeyword.includes(this.string.toUpperCase())\n }\n}\n\nexport default Selection\n","/**\n * @file Selection Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { SelectionRule, SelectionOperator } from './selection-test'\nimport {\n kwd, SelectAllKeyword,\n SmallResname, NucleophilicResname, HydrophobicResname, AromaticResname,\n AmideResname, AcidicResname, BasicResname, ChargedResname,\n PolarResname, NonpolarResname, CyclicResname, AliphaticResname\n} from './selection-constants'\n\nfunction parseSele (string: string) {\n let retSelection: SelectionRule = {\n operator: undefined,\n rules: []\n }\n\n if (!string) {\n return retSelection\n }\n\n let selection = retSelection\n let newSelection: SelectionRule\n let oldSelection: SelectionRule\n const selectionStack: SelectionRule[] = []\n\n string = string.replace(/\\(/g, ' ( ').replace(/\\)/g, ' ) ').trim()\n if (string.charAt(0) === '(' && string.substr(-1) === ')') {\n string = string.slice(1, -1).trim()\n }\n const chunks = string.split(/\\s+/)\n\n // Log.log( string, chunks )\n\n const createNewContext = (operator?: SelectionOperator) => {\n newSelection = {\n operator,\n rules: []\n }\n if (selection === undefined) {\n selection = newSelection\n retSelection = newSelection\n } else {\n selection.rules!.push(newSelection)\n selectionStack.push(selection)\n selection = newSelection\n }\n }\n\n const getPrevContext = function (operator?: SelectionOperator) {\n oldSelection = selection\n selection = selectionStack.pop()!\n if (selection === undefined) {\n createNewContext(operator)\n pushRule(oldSelection)\n }\n }\n\n const pushRule = function (rule: SelectionRule) {\n selection.rules!.push(rule)\n }\n\n let not: false|0|1|2 = false\n\n for (let i = 0; i < chunks.length; ++i) {\n const c = chunks[ i ]\n const cu = c.toUpperCase()\n\n // handle parens\n\n if (c === '(') {\n // Log.log( \"(\" );\n not = false\n createNewContext()\n continue\n } else if (c === ')') {\n // Log.log( \")\" );\n getPrevContext()\n if (selection.negate) {\n getPrevContext()\n }\n continue\n }\n\n // leave 'not' context\n\n if (not > 0) {\n if (cu === 'NOT') {\n not = 1\n } else if (not === 1) {\n not = 2\n } else if (not === 2) {\n not = false\n getPrevContext()\n } else {\n throw new Error(\"something went wrong with 'not'\")\n }\n }\n\n // handle logic operators\n\n if (cu === 'AND') {\n // Log.log( \"AND\" );\n if (selection.operator === 'OR') {\n const lastRule = selection.rules!.pop()!\n createNewContext('AND')\n pushRule(lastRule)\n } else {\n selection.operator = 'AND'\n }\n continue\n } else if (cu === 'OR') {\n // Log.log( \"OR\" );\n if (selection.operator === 'AND') {\n getPrevContext('OR')\n } else {\n selection.operator = 'OR'\n }\n continue\n } else if (c.toUpperCase() === 'NOT') {\n // Log.log( \"NOT\", j );\n not = 1\n createNewContext()\n selection.negate = true\n continue\n } else {\n // Log.log( \"chunk\", c, j, selection );\n }\n\n // handle keyword attributes\n\n // ensure `cu` is not a number before testing if it is in the\n // kwd enum dictionary which includes the enum numbers as well...\n if (+cu !== +cu) {\n const keyword = (kwd as any)[ cu ]\n if (keyword !== undefined) {\n pushRule({ keyword })\n continue\n }\n }\n\n if (cu === 'HYDROGEN') {\n pushRule({\n operator: 'OR',\n rules: [\n { element: 'H' },\n { element: 'D' }\n ]\n })\n continue\n }\n\n if (cu === 'SMALL') {\n pushRule({ resname: SmallResname })\n continue\n }\n\n if (cu === 'NUCLEOPHILIC') {\n pushRule({ resname: NucleophilicResname })\n continue\n }\n\n if (cu === 'HYDROPHOBIC') {\n pushRule({ resname: HydrophobicResname })\n continue\n }\n\n if (cu === 'AROMATIC') {\n pushRule({ resname: AromaticResname })\n continue\n }\n\n if (cu === 'AMIDE') {\n pushRule({ resname: AmideResname })\n continue\n }\n\n if (cu === 'ACIDIC') {\n pushRule({ resname: AcidicResname })\n continue\n }\n\n if (cu === 'BASIC') {\n pushRule({ resname: BasicResname })\n continue\n }\n\n if (cu === 'CHARGED') {\n pushRule({ resname: ChargedResname })\n continue\n }\n\n if (cu === 'POLAR') {\n pushRule({ resname: PolarResname })\n continue\n }\n\n if (cu === 'NONPOLAR') {\n pushRule({ resname: NonpolarResname })\n continue\n }\n\n if (cu === 'CYCLIC') {\n pushRule({ resname: CyclicResname })\n continue\n }\n\n if (cu === 'ALIPHATIC') {\n pushRule({ resname: AliphaticResname })\n continue\n }\n\n if (cu === 'SIDECHAINATTACHED') {\n pushRule({\n operator: 'OR',\n rules: [\n { keyword: kwd.SIDECHAIN },\n {\n operator: 'AND',\n negate: false,\n rules: [\n { keyword: kwd.PROTEIN },\n {\n operator: 'OR',\n negate: false,\n rules: [\n { atomname: 'CA' },\n { atomname: 'BB' }\n ]\n }\n ]\n },\n {\n operator: 'AND',\n negate: false,\n rules: [\n { resname: 'PRO' },\n { atomname: 'N' }\n ]\n },\n {\n operator: 'AND',\n negate: false,\n rules: [\n { keyword: kwd.NUCLEIC },\n {\n operator: 'OR',\n negate: true,\n rules: [\n { atomname: 'P' },\n { atomname: 'OP1' },\n { atomname: 'OP2' },\n { atomname: \"O3'\" },\n { atomname: 'O3*' },\n { atomname: \"HO3'\"},\n { atomname: \"O5'\" },\n { atomname: 'O5*' },\n { atomname: \"HO5'\"},\n { atomname: \"C5'\" },\n { atomname: 'C5*' },\n { atomname: \"H5'\" },\n { atomname: \"H5''\"}\n ]\n }\n ]\n }\n ]\n })\n continue\n }\n\n if (cu === 'APOLARH') {\n pushRule({\n operator: 'AND',\n negate: false,\n rules: [\n { element: 'H' },\n {\n negate: true,\n operator: undefined,\n rules: [\n { keyword: kwd.POLARH }\n ]\n }\n ]\n })\n continue\n }\n\n if (cu === 'LIGAND') {\n pushRule({\n operator: 'AND',\n rules: [\n {\n operator: 'OR',\n rules: [\n {\n operator: 'AND',\n rules: [\n { keyword: kwd.HETERO },\n {\n negate: true,\n operator: undefined,\n rules: [\n { keyword: kwd.POLYMER }\n ]\n }\n ]\n },\n {\n negate: true,\n operator: undefined,\n rules: [\n { keyword: kwd.POLYMER }\n ]\n }\n ]\n },\n {\n negate: true,\n operator: undefined,\n rules: [\n {\n operator: 'OR',\n rules: [\n { keyword: kwd.WATER },\n { keyword: kwd.ION }\n ]\n }\n ]\n }\n ]\n })\n continue\n }\n\n if (SelectAllKeyword.indexOf(cu) !== -1) {\n pushRule({ keyword: kwd.ALL })\n continue\n }\n\n // handle atom expressions\n\n if (c.charAt(0) === '@') {\n const indexList = c.substr(1).split(',').map(x => parseInt(x))\n indexList.sort(function (a, b) { return a - b })\n pushRule({ atomindex: indexList })\n continue\n }\n\n if (c.charAt(0) === '#') {\n console.error('# for element selection deprecated, use _')\n pushRule({ element: cu.substr(1) })\n continue\n }\n if (c.charAt(0) === '_') {\n pushRule({ element: cu.substr(1) })\n continue\n }\n\n if (c[0] === '[' && c[c.length - 1] === ']') {\n const resnameList = cu.substr(1, c.length - 2).split(',')\n const resname = resnameList.length > 1 ? resnameList : resnameList[ 0 ]\n pushRule({ resname: resname })\n continue\n } else if (\n (c.length >= 1 && c.length <= 4) &&\n c[0] !== '^' && c[0] !== ':' && c[0] !== '.' && c[0] !== '%' && c[0] !== '/' &&\n isNaN(parseInt(c))\n ) {\n pushRule({ resname: cu })\n continue\n }\n\n // there must be only one constraint per rule\n // otherwise a test quickly becomes not applicable\n // e.g. chainTest for chainname when resno is present too\n\n const sele: SelectionRule = {\n operator: 'AND',\n rules: []\n }\n\n const model = c.split('/')\n if (model.length > 1 && model[1]) {\n if (isNaN(parseInt(model[1]))) {\n throw new Error('model must be an integer')\n }\n sele.rules!.push({\n model: parseInt(model[1])\n })\n }\n\n const altloc = model[0].split('%')\n if (altloc.length > 1) {\n sele.rules!.push({\n altloc: altloc[1]\n })\n }\n\n const atomname = altloc[0].split('.')\n if (atomname.length > 1 && atomname[1]) {\n if (atomname[1].length > 4) {\n throw new Error('atomname must be one to four characters')\n }\n sele.rules!.push({\n atomname: atomname[1].substring(0, 4).toUpperCase()\n })\n }\n\n const chain = atomname[0].split(':')\n if (chain.length > 1 && chain[1]) {\n sele.rules!.push({\n chainname: chain[1]\n })\n }\n\n const inscode = chain[0].split('^')\n if (inscode.length > 1) {\n sele.rules!.push({\n inscode: inscode[1]\n })\n }\n\n if (inscode[0]) {\n let negate, negate2\n if (inscode[0][0] === '-') {\n inscode[0] = inscode[0].substr(1)\n negate = true\n }\n if (inscode[0].includes('--')) {\n inscode[0] = inscode[0].replace('--', '-')\n negate2 = true\n }\n let resi = inscode[0].split('-')\n if (resi.length === 1) {\n let resiSingle = parseInt(resi[0])\n if (isNaN(resiSingle)) {\n throw new Error('resi must be an integer')\n }\n if (negate) resiSingle *= -1\n sele.rules!.push({\n resno: resiSingle\n })\n } else if (resi.length === 2) {\n const resiRange = resi.map(x => parseInt(x))\n if (negate) resiRange[0] *= -1\n if (negate2) resiRange[1] *= -1\n sele.rules!.push({\n resno: [resiRange[0], resiRange[1]]\n })\n } else {\n throw new Error(\"resi range must contain one '-'\")\n }\n }\n\n // round up\n\n if (sele.rules!.length === 1) {\n pushRule(sele.rules![ 0 ])\n } else if (sele.rules!.length > 1) {\n pushRule(sele)\n } else {\n throw new Error('empty selection chunk')\n }\n }\n\n // cleanup\n\n if (\n retSelection.operator === undefined &&\n retSelection.rules!.length === 1 &&\n retSelection.rules![ 0 ].hasOwnProperty('operator')\n ) {\n retSelection = retSelection.rules![ 0 ]\n }\n\n return retSelection\n}\n\nexport {\n parseSele\n}\n","/**\n * @file Selection Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { Color } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport Selection from '../selection/selection'\nimport Colormaker, { ColormakerParameters } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Structure from '../structure/structure'\n\nexport type SelectionSchemeData = [ string, string, ColormakerParameters|undefined ]\n\n/**\n * Color based on {@link Selection}\n */\nclass SelectionColormaker extends Colormaker {\n colormakerList: any[] = [] // TODO\n selectionList: Selection[] = []\n\n constructor (params: { structure: Structure, dataList: SelectionSchemeData[] } & Partial) {\n super(params)\n\n const dataList = params.dataList || []\n\n dataList.forEach((data: SelectionSchemeData) => {\n const [ scheme, sele, params = {} ] = data\n\n if (ColormakerRegistry.hasScheme(scheme)) {\n Object.assign(params, {\n scheme: scheme,\n structure: this.parameters.structure\n })\n } else {\n Object.assign(params, {\n scheme: 'uniform',\n value: new Color(scheme).getHex()\n })\n }\n\n this.colormakerList.push(ColormakerRegistry.getScheme(params as { scheme: string } & ColormakerParameters))\n this.selectionList.push(new Selection(sele))\n })\n }\n\n // NOT NEEDED @manageColor\n atomColor (a: AtomProxy) {\n for (let i = 0, n = this.selectionList.length; i < n; ++i) {\n const test = this.selectionList[ i ].test\n if (test && test(a)) {\n return this.colormakerList[ i ].atomColor(a)\n }\n }\n\n return 0xFFFFFF\n }\n}\n\nexport default SelectionColormaker\n","/**\n * @file Colormaker Registry\n * @author Alexander Rose \n * @private\n */\n\nimport { generateUUID } from '../math/math-utils'\nimport Colormaker, { ColormakerParameters } from './colormaker'\nimport SelectionColormaker, { SelectionSchemeData } from './selection-colormaker'\nimport Structure from '../structure/structure'\n\nconst ColormakerScales = {\n '': '',\n\n // Sequential\n OrRd: '[S] Orange-Red',\n PuBu: '[S] Purple-Blue',\n BuPu: '[S] Blue-Purple',\n Oranges: '[S] Oranges',\n BuGn: '[S] Blue-Green',\n YlOrBr: '[S] Yellow-Orange-Brown',\n YlGn: '[S] Yellow-Green',\n Reds: '[S] Reds',\n RdPu: '[S] Red-Purple',\n Greens: '[S] Greens',\n YlGnBu: '[S] Yellow-Green-Blue',\n Purples: '[S] Purples',\n GnBu: '[S] Green-Blue',\n Greys: '[S] Greys',\n YlOrRd: '[S] Yellow-Orange-Red',\n PuRd: '[S] Purple-Red',\n Blues: '[S] Blues',\n PuBuGn: '[S] Purple-Blue-Green',\n\n // Diverging\n Viridis: '[D] Viridis',\n Spectral: '[D] Spectral',\n RdYlGn: '[D] Red-Yellow-Green',\n RdBu: '[D] Red-Blue',\n PiYG: '[D] Pink-Yellowgreen',\n PRGn: '[D] Purplered-Green',\n RdYlBu: '[D] Red-Yellow-Blue',\n BrBG: '[D] Brown-Bluegreen',\n RdGy: '[D] Red-Grey',\n PuOr: '[D] Purple-Orange',\n\n // Qualitative\n Set1: '[Q] Set1',\n Set2: '[Q] Set2',\n Set3: '[Q] Set3',\n Dark2: '[Q] Dark2',\n Paired: '[Q] Paired',\n Pastel1: '[Q] Pastel1',\n Pastel2: '[Q] Pastel2',\n Accent: '[Q] Accent',\n\n // Other\n rainbow: '[?] Rainbow',\n rwb: '[?] Red-White-Blue'\n}\n\nconst ColormakerModes = {\n '': '',\n\n rgb: 'Red Green Blue',\n hsv: 'Hue Saturation Value',\n hsl: 'Hue Saturation Lightness',\n hsi: 'Hue Saturation Intensity',\n lab: 'CIE L*a*b*',\n hcl: 'Hue Chroma Lightness'\n}\n\n/**\n * Class for registering {@link Colormaker}s. Generally use the\n * global {@link src/globals.js~ColormakerRegistry} instance.\n */\nclass ColormakerRegistry {\n schemes: { [k: string]: any }\n userSchemes: { [k: string]: any }\n\n constructor () {\n this.schemes = {}\n this.userSchemes = {}\n }\n\n getScheme (params: Partial<{ scheme: string } & ColormakerParameters>) {\n const p = params || {}\n const id = (p.scheme || '').toLowerCase()\n\n let SchemeClass\n\n if (id in this.schemes) {\n SchemeClass = this.schemes[ id ]\n } else if (id in this.userSchemes) {\n SchemeClass = this.userSchemes[ id ]\n } else {\n SchemeClass = Colormaker\n }\n\n return new SchemeClass(params)\n }\n\n /**\n * Get an description of available schemes as an\n * object with id-label as key-value pairs\n * @return {Object} available schemes\n */\n getSchemes () {\n const types: { [k: string]: any } = {}\n\n Object.keys(this.schemes).forEach(function (k) {\n types[ k ] = k\n })\n\n Object.keys(this.userSchemes).forEach(function (k) {\n types[ k ] = k.split('|')[ 1 ]\n })\n\n return types\n }\n\n /**\n * Get an description of available scales as an\n * object with id-label as key-value pairs\n * @return {Object} available scales\n */\n getScales () {\n return ColormakerScales\n }\n\n getModes () {\n return ColormakerModes\n }\n\n /**\n * Add a scheme with a hardcoded id\n * @param {String} id - the id\n * @param {Colormaker} scheme - the colormaker\n * @return {undefined}\n */\n add (id: string, scheme: typeof Colormaker) {\n id = id.toLowerCase()\n this.schemes[ id ] = scheme\n }\n\n /**\n * Register a custom scheme\n *\n * @example\n * // Create a class with a `atomColor` method that returns a hex color.\n * var schemeId = NGL.ColormakerRegistry.addScheme( function( params ){\n * this.atomColor = function( atom ){\n * if( atom.serial < 1000 ){\n * return 0x0000FF; // blue\n * }else if( atom.serial > 2000 ){\n * return 0xFF0000; // red\n * }else{\n * return 0x00FF00; // green\n * }\n * };\n * } );\n *\n * stage.loadFile( \"rcsb://3dqb.pdb\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\", { color: schemeId } ); // pass schemeId here\n * o.autoView();\n * } );\n *\n * @param {Function|Colormaker} scheme - constructor or {@link Colormaker} instance\n * @param {String} label - scheme label\n * @return {String} id to refer to the registered scheme\n */\n addScheme (scheme: any, label?: string) {\n if (!(scheme instanceof Colormaker)) {\n scheme = this._createScheme(scheme)\n }\n\n return this._addUserScheme(scheme, label)\n }\n\n /**\n * Add a user-defined scheme\n * @param {Colormaker} scheme - the user-defined scheme\n * @param {String} [label] - scheme label\n * @return {String} id to refer to the registered scheme\n */\n _addUserScheme (scheme: any, label?: string) {\n label = label || ''\n const id = `${generateUUID()}|${label}`.toLowerCase()\n this.userSchemes[ id ] = scheme\n\n return id\n }\n\n /**\n * Remove the scheme with the given id\n * @param {String} id - scheme to remove\n * @return {undefined}\n */\n removeScheme (id: string) {\n id = id.toLowerCase()\n delete this.userSchemes[ id ]\n }\n\n _createScheme (constructor: any) {\n const _Colormaker = function (this: any, params: ColormakerParameters) {\n Colormaker.call(this, params)\n constructor.call(this, params)\n }\n\n _Colormaker.prototype = Colormaker.prototype\n _Colormaker.prototype.constructor = Colormaker\n\n return _Colormaker\n }\n\n /**\n * Create and a selection-based coloring scheme. Supply a list with pairs\n * of colorname and selection for coloring by selections. Use the last\n * entry as a default (catch all) coloring definition.\n *\n * @example\n * var schemeId = NGL.ColormakerRegistry.addSelectionScheme( [\n * [ \"red\", \"64-74 or 134-154 or 222-254 or 310-310 or 322-326\" ],\n * [ \"green\", \"311-322\" ],\n * [ \"yellow\", \"40-63 or 75-95 or 112-133 or 155-173 or 202-221 or 255-277 or 289-309\" ],\n * [ \"blue\", \"1-39 or 96-112 or 174-201 or 278-288\" ],\n * [ \"white\", \"*\" ]\n * ], \"Transmembrane 3dqb\" );\n *\n * stage.loadFile( \"rcsb://3dqb.pdb\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\", { color: schemeId } ); // pass schemeId here\n * o.autoView();\n * } );\n *\n * @param {Array} dataList - cloror-selection pairs\n * @param {String} label - scheme name\n * @return {String} id to refer to the registered scheme\n */\n addSelectionScheme (dataList: SelectionSchemeData[], label?: string) {\n class MySelectionColormaker extends SelectionColormaker {\n constructor (params: { structure: Structure } & ColormakerParameters) {\n super(Object.assign({ dataList }, params))\n }\n }\n\n return this._addUserScheme(MySelectionColormaker, label)\n }\n\n /**\n * Check if a scheme with the given id exists\n * @param {String} id - the id to check\n * @return {Boolean} flag indicating if the scheme exists\n */\n hasScheme (id: string) {\n id = id.toLowerCase()\n return id in this.schemes || id in this.userSchemes\n }\n}\n\nexport default ColormakerRegistry\n","/**\n * @file Worker Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { uniqueArray } from '../utils'\n\nexport type FunctionWithDeps = { __deps?: Function[] } & Function\nexport interface WorkerEvent {\n data: {\n __name: string\n __postId: string\n }\n}\n\nfunction getWorkerDeps (vars: FunctionWithDeps[]) {\n const deps = vars\n vars.forEach(function (sym) {\n if (sym.__deps) {\n Array.prototype.push.apply(deps, getWorkerDeps(sym.__deps))\n }\n })\n return deps\n}\n\nfunction makeWorkerString (vars: any) {\n const deps = uniqueArray(getWorkerDeps(vars))\n return deps.map(function (sym) {\n return sym.toString()\n }).join('\\n\\n\\n')\n}\n\nfunction onmessage (e: WorkerEvent) {\n const name = e.data.__name\n const postId = e.data.__postId\n\n /* global self */\n if (name === undefined) {\n console.error('message __name undefined')\n } else if ((self as any).func === undefined) {\n console.error('worker func undefined', name)\n } else {\n const callback = function (aMessage: any, transferList: any[]) {\n aMessage = aMessage || {}\n if (postId !== undefined) aMessage.__postId = postId\n\n try {\n (self as any).postMessage(aMessage, transferList)\n } catch (error) {\n console.error('self.postMessage:', error);\n (self as any).postMessage(aMessage)\n }\n };\n (self as any).func(e, callback)\n }\n}\n\nexport function makeWorkerBlob (func: Function, deps: Function[]) {\n let str = \"'use strict';\\n\\n\" + makeWorkerString(deps)\n str += '\\n\\n\\nself.func = ' + func.toString() + ';'\n str += '\\n\\n\\nself.onmessage = ' + onmessage.toString() + ';'\n // console.log(str);\n return new Blob([ str ], { type: 'application/javascript' })\n}\n","/**\n * @file Globals\n * @author Alexander Rose \n * @private\n */\n\nimport { getBrowser, getQuery, boolean } from './utils'\nimport Registry from './utils/registry'\nimport _ColormakerRegistry from './color/colormaker-registry'\nimport _ParserRegistry from './parser/parser-registry'\nimport _WorkerRegistry from './worker/worker-registry'\nimport { MeasurementRepresentationParameters } from './representation/measurement-representation';\n\n/**\n * The browser name: \"Opera\", \"Chrome\", \"Firefox\", \"Mobile Safari\",\n * \"Internet Explorer\", \"Safari\" or false.\n */\nexport const Browser = getBrowser()\n\n/**\n * Flag indicating support for the 'passive' option for event handler\n */\nexport let SupportsPassiveEventHandler = false\ntry {\n // Test via a getter in the options object to see if the passive property is accessed\n const opts = Object.defineProperty({}, 'passive', {\n get: function () {\n SupportsPassiveEventHandler = true\n }\n })\n window.addEventListener('test', e => {}, opts)\n} catch (e) {}\n\n/**\n * Flag indicating a mobile browser\n */\nexport const Mobile = typeof window !== 'undefined' ? typeof window.orientation !== 'undefined' : false\n\nexport let SupportsReadPixelsFloat = false\nexport function setSupportsReadPixelsFloat (value: boolean) {\n SupportsReadPixelsFloat = value\n}\n\n/**\n * Flag indicating support for the `EXT_frag_depth` WebGL extension\n * (Always present in WebGL2)\n */\nexport let ExtensionFragDepth = false\nexport function setExtensionFragDepth (value: boolean) {\n ExtensionFragDepth = value\n}\n\nexport const Log = {\n log: Function.prototype.bind.call(console.log, console),\n info: Function.prototype.bind.call(console.info, console),\n warn: Function.prototype.bind.call(console.warn, console),\n error: Function.prototype.bind.call(console.error, console),\n time: Function.prototype.bind.call(console.time, console),\n timeEnd: Function.prototype.bind.call(console.timeEnd, console)\n}\n\nexport let MeasurementDefaultParams: Partial = {\n color: 'green',\n labelColor: 0x808080,\n labelAttachment: 'bottom-center',\n labelSize: 0.7,\n labelZOffset: 0.5,\n labelYOffset: 0.1,\n labelBorder: true,\n labelBorderColor: 0xd3d3d3,\n labelBorderWidth: 0.25,\n lineOpacity: 0.8,\n linewidth: 5.0,\n opacity: 0.6,\n\n labelUnit: 'angstrom',\n arcVisible: true,\n planeVisible: false\n}\nexport function setMeasurementDefaultParams (params = {}) {\n Object.assign(MeasurementDefaultParams, params)\n}\n\nexport let Debug = boolean(getQuery('debug'))\nexport function setDebug (value: boolean) {\n Debug = value\n}\n\nexport const WebglErrorMessage = '

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

Find out how to get it here.

'\n\n/**\n * List of file extensions to be recognized as scripts\n */\nexport const ScriptExtensions = [ 'ngl', 'js' ]\n\nexport const WorkerRegistry = new _WorkerRegistry()\nexport const ColormakerRegistry = new _ColormakerRegistry()\nexport const DatasourceRegistry = new Registry('datasource')\nexport const RepresentationRegistry = new Registry('representatation')\nexport const ParserRegistry = new _ParserRegistry()\nexport const ShaderRegistry = new Registry('shader')\nexport const DecompressorRegistry = new Registry('decompressor')\nexport const ComponentRegistry = new Registry('component')\nexport const BufferRegistry = new Registry('buffer')\nexport const PickerRegistry = new Registry('picker')\n\nexport let ListingDatasource: any\nexport function setListingDatasource (value: any) {\n ListingDatasource = value\n}\n\nexport let TrajectoryDatasource: any // TODO should accept mdsrvDatasource\nexport function setTrajectoryDatasource (value: any) {\n TrajectoryDatasource = value\n}\n","/**\n * @file Worker Registry\n * @author Alexander Rose \n * @private\n */\n\nimport { makeWorkerBlob } from './worker-utils'\n\nclass WorkerRegistry {\n activeWorkerCount = 0\n\n private _funcDict: { [k: string]: Function } = {}\n private _depsDict: { [k: string]: Function[] } = {}\n private _blobDict: { [k: string]: Blob } = {}\n\n add (name: string, func: Function, deps: Function[]) {\n this._funcDict[ name ] = func\n this._depsDict[ name ] = deps\n }\n\n get (name: string) {\n if (!this._blobDict[ name ]) {\n this._blobDict[ name ] = makeWorkerBlob(\n this._funcDict[ name ], this._depsDict[ name ]\n )\n }\n return this._blobDict[ name ]\n }\n}\n\nexport default WorkerRegistry\n","/**\n * @file Parser Registry\n * @author Alexander Rose \n * @private\n */\n\nimport Registry from '../utils/registry'\n\nclass ParserRegistry extends Registry {\n constructor () {\n super('parser')\n }\n\n __hasObjName (key: string, objName: string) {\n const parser = this.get(key)\n return parser && parser.prototype.__objName === objName\n }\n\n isTrajectory (key: string) {\n return this.__hasObjName(key, 'frames')\n }\n\n isStructure (key: string) {\n return this.__hasObjName(key, 'structure')\n }\n\n isVolume (key: string) {\n return this.__hasObjName(key, 'volume')\n }\n\n isSurface (key: string) {\n return this.__hasObjName(key, 'surface')\n }\n\n isBinary (key: string) {\n const parser = this.get(key)\n return parser && parser.prototype.isBinary\n }\n\n isXml (key: string) {\n const parser = this.get(key)\n return parser && parser.prototype.isXml\n }\n\n isJson (key: string) {\n const parser = this.get(key)\n return parser && parser.prototype.isJson\n }\n\n getTrajectoryExtensions () {\n return this.names.filter(name => this.isTrajectory(name))\n }\n\n getStructureExtensions () {\n return this.names.filter(name => this.isStructure(name))\n }\n\n getVolumeExtensions () {\n return this.names.filter(name => this.isVolume(name))\n }\n\n getSurfaceExtensions () {\n return this.names.filter(name => this.isSurface(name))\n }\n}\n\nexport default ParserRegistry\n","/**\n * @file Streamer\n * @author Alexander Rose \n * @private\n */\n\nimport { DecompressorRegistry } from '../globals'\nimport { uint8ToString, defaults } from '../utils'\n\nexport interface StreamerParams {\n compressed?: string|false\n binary?: boolean\n json?: boolean\n xml?: boolean\n}\n\nabstract class Streamer {\n src: any\n data: any\n\n compressed: string|false\n binary: boolean\n json: boolean\n xml: boolean\n\n chunkSize = 1024 * 1024 * 10\n newline = '\\n'\n\n protected __pointer = 0\n protected __partialLine = ''\n\n constructor (src: any, params: StreamerParams = {}) {\n this.compressed = defaults(params.compressed, false)\n this.binary = defaults(params.binary, false)\n this.json = defaults(params.json, false)\n this.xml = defaults(params.xml, false)\n\n this.src = src\n }\n\n isBinary () {\n return this.binary || this.compressed\n }\n\n read () {\n return this._read().then(data => {\n const decompressFn = this.compressed ? DecompressorRegistry.get(this.compressed) : undefined\n\n if (this.compressed && decompressFn) {\n this.data = decompressFn(data)\n } else {\n if ((this.binary || this.compressed) && data instanceof ArrayBuffer) {\n data = new Uint8Array(data)\n }\n this.data = data\n }\n\n return this.data\n })\n }\n\n protected abstract _read (): Promise\n\n protected _chunk (start: number, end: number) {\n end = Math.min(this.data.length, end)\n\n if (start === 0 && this.data.length === end) {\n return this.data\n } else {\n if (this.isBinary()) {\n return this.data.subarray(start, end)\n } else {\n return this.data.substring(start, end)\n }\n }\n }\n\n chunk (start: number) {\n const end = start + this.chunkSize\n\n return this._chunk(start, end)\n }\n\n peekLines (m: number) {\n const data = this.data\n const n = data.length\n\n // FIXME does not work for multi-char newline\n const newline = this.isBinary() ? this.newline.charCodeAt(0) : this.newline\n\n let i\n let count = 0\n for (i = 0; i < n; ++i) {\n if (data[ i ] === newline) ++count\n if (count === m) break\n }\n\n const chunk = this._chunk(0, i + 1)\n const d = this.chunkToLines(chunk, '', i > n)\n\n return d.lines\n }\n\n chunkCount () {\n return Math.floor(this.data.length / this.chunkSize) + 1\n }\n\n asText () {\n return this.isBinary() ? uint8ToString(this.data) : this.data\n }\n\n chunkToLines (chunk: string|Uint8Array, partialLine: string, isLast: boolean) {\n const newline = this.newline\n\n if (!this.isBinary() && chunk.length === this.data.length) {\n return {\n lines: (chunk as string).split(newline),\n partialLine: ''\n }\n }\n\n let lines: string[] = []\n const str = this.isBinary() ? uint8ToString(chunk as Uint8Array) : chunk\n const idx = str.lastIndexOf(newline)\n\n if (idx === -1) {\n partialLine += str\n } else {\n const str2 = partialLine + str.substr(0, idx)\n lines = lines.concat(str2.split(newline))\n\n if (idx === str.length - newline.length) {\n partialLine = ''\n } else {\n partialLine = str.substr(idx + newline.length)\n }\n }\n\n if (isLast && partialLine !== '') {\n lines.push(partialLine)\n }\n\n return {\n lines: lines,\n partialLine: partialLine\n }\n }\n\n nextChunk () {\n const start = this.__pointer\n\n if (start > this.data.length) {\n return undefined\n }\n\n this.__pointer += this.chunkSize\n return this.chunk(start)\n }\n\n nextChunkOfLines () {\n const chunk = this.nextChunk()\n\n if (chunk === undefined) {\n return undefined\n }\n\n const isLast = this.__pointer > this.data.length\n const d = this.chunkToLines(chunk, this.__partialLine, isLast)\n\n this.__partialLine = d.partialLine\n\n return d.lines\n }\n\n eachChunk (callback: (chunk: string|Uint8Array, chunkNo: number, chunkCount: number) => void) {\n const chunkSize = this.chunkSize\n const n = this.data.length\n const chunkCount = this.chunkCount()\n\n for (let i = 0; i < n; i += chunkSize) {\n const chunk = this.chunk(i)\n const chunkNo = Math.round(i / chunkSize)\n\n callback(chunk, chunkNo, chunkCount)\n }\n }\n\n eachChunkOfLines (callback: (chunk: string[], chunkNo: number, chunkCount: number) => void) {\n this.eachChunk((chunk, chunkNo, chunkCount) => {\n const isLast = chunkNo === chunkCount + 1\n const d = this.chunkToLines(chunk, this.__partialLine, isLast)\n\n this.__partialLine = d.partialLine\n\n callback(d.lines, chunkNo, chunkCount)\n })\n }\n\n dispose () {\n delete this.src\n }\n}\n\nexport default Streamer\n","/**\n * @file File Streamer\n * @author Alexander Rose \n * @private\n */\n\nimport Streamer from './streamer'\n\ninterface FileReaderEventTarget extends EventTarget {\n result:string | ArrayBuffer | null\n}\n\ninterface FileReaderEvent extends ProgressEvent {\n target: FileReaderEventTarget | null;\n}\n\nclass FileStreamer extends Streamer {\n _read () {\n return new Promise((resolve, reject) => {\n const file = this.src\n const reader = new FileReader()\n\n reader.onload = (event: FileReaderEvent) => {\n if(event.target) resolve(event.target.result)\n }\n\n // if (typeof this.onprogress === 'function') {\n // reader.onprogress = event => this.onprogress(event)\n // }\n\n reader.onerror = event => reject(event)\n\n if (this.binary || this.compressed) {\n reader.readAsArrayBuffer(file)\n } else {\n reader.readAsText(file)\n }\n })\n }\n}\n\nexport default FileStreamer\n","/**\n * @file Network Streamer\n * @author Alexander Rose \n * @private\n */\n\nimport Streamer from './streamer'\n\nclass NetworkStreamer extends Streamer {\n _read () {\n return new Promise((resolve, reject) => {\n const url = this.src\n const xhr = new XMLHttpRequest()\n\n xhr.open('GET', url, true)\n\n xhr.addEventListener('load', () => {\n if (xhr.status === 200 || xhr.status === 304 ||\n // when requesting from local file system\n // the status in Google Chrome/Chromium is 0\n xhr.status === 0\n ) {\n try {\n resolve(xhr.response)\n } catch (e) {\n reject(e)\n }\n } else {\n reject(xhr.statusText)\n }\n }, false)\n\n // if (typeof this.onprogress === 'function') {\n // xhr.addEventListener('progress', event => this.onprogress(event), false);\n // }\n\n xhr.addEventListener('error', event => reject('network error'), false)\n\n if (this.isBinary()) {\n xhr.responseType = 'arraybuffer'\n } else if (this.json) {\n xhr.responseType = 'json'\n } else if (this.xml) {\n xhr.responseType = 'document'\n } else {\n xhr.responseType = 'text'\n }\n // xhr.crossOrigin = true;\n\n xhr.send()\n })\n }\n}\n\nexport default NetworkStreamer\n","/**\n * @file Loader\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport { createParams } from '../utils'\nimport FileStreamer from '../streamer/file-streamer'\nimport NetworkStreamer from '../streamer/network-streamer'\nimport { LoaderParameters, LoaderInput } from './loader-utils'\n\n/**\n * Loader parameter object.\n * @typedef {Object} LoaderParameters - loader parameters\n * @property {String} ext - file extension, determines file type\n * @property {Boolean} compressed - flag data as compressed\n * @property {Boolean} binary - flag data as binary\n * @property {String} name - set data name\n */\n\n/**\n * Loader base class\n */\nabstract class Loader {\n parameters: LoaderParameters\n streamer: FileStreamer | NetworkStreamer\n\n /**\n * Construct a loader object\n * @param {String|File|Blob} src - data source, string is interpreted as an URL\n * @param {LoaderParameters} params - parameters object\n */\n constructor (src: LoaderInput, params: Partial = {}) {\n this.parameters = createParams(params, {\n ext: '',\n compressed: false,\n binary: ParserRegistry.isBinary(params.ext || ''),\n name: '',\n\n dir: '',\n path: '',\n protocol: ''\n } as LoaderParameters)\n\n const streamerParams = {\n compressed: this.parameters.compressed as string|false,\n binary: this.parameters.binary,\n json: ParserRegistry.isJson(this.parameters.ext),\n xml: ParserRegistry.isXml(this.parameters.ext)\n }\n\n if ((typeof File !== 'undefined' && src instanceof File) ||\n (typeof Blob !== 'undefined' && src instanceof Blob)\n ) {\n this.streamer = new FileStreamer(src, streamerParams)\n } else {\n this.streamer = new NetworkStreamer(src, streamerParams)\n }\n }\n\n /**\n * Load data\n * @abstract\n * @return {Promise} resolves to the loaded data {@link Object}\n */\n abstract load (): Promise\n}\n\nexport default Loader\n","/**\n * @file Parser Loader\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport type { InferBondsOptions } from '../structure/structure-utils'\nimport Loader from './loader'\nimport { LoaderParameters, LoaderInput } from './loader-utils'\n\nexport interface ParserParams {\n voxelSize?: number\n firstModelOnly?: boolean\n asTrajectory?: boolean\n cAlphaOnly?: boolean\n name?: string\n path?: string\n delimiter?: string\n comment?: string\n columnNames?: string\n inferBonds?: InferBondsOptions\n}\n\n/**\n * Parser loader class\n * @extends Loader\n */\nclass ParserLoader extends Loader {\n parserParams: ParserParams\n\n constructor (src: LoaderInput, params: Partial & ParserParams = {}) {\n super(src, params)\n this.parserParams = {\n voxelSize: params.voxelSize,\n firstModelOnly: params.firstModelOnly,\n asTrajectory: params.asTrajectory,\n cAlphaOnly: params.cAlphaOnly,\n delimiter: params.delimiter,\n comment: params.comment,\n columnNames: params.columnNames,\n inferBonds: params.inferBonds,\n name: this.parameters.name,\n path: this.parameters.path\n }\n }\n\n /**\n * Load parsed object\n * @return {Promise} resolves to the loaded & parsed {@link Structure},\n * {@link Volume}, {@link Surface} or data object\n */\n load () {\n var ParserClass = ParserRegistry.get(this.parameters.ext)\n var parser = new ParserClass(this.streamer, this.parserParams)\n\n return parser.parse()\n }\n}\n\nexport default ParserLoader\n","/**\n * @file Script\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { Log } from './globals'\nimport Stage from './stage/stage'\n\nexport interface ScriptSignals {\n elementAdded: Signal\n elementRemoved: Signal\n nameChanged: Signal\n}\n\n/**\n * Script class\n */\nclass Script {\n readonly signals: ScriptSignals = {\n elementAdded: new Signal(),\n elementRemoved: new Signal(),\n nameChanged: new Signal()\n }\n\n readonly dir: string\n readonly fn: Function\n\n readonly type = 'Script'\n\n /**\n * Create a script instance\n * @param {String} functionBody - the function source\n * @param {String} name - name of the script\n * @param {String} path - path of the script\n */\n constructor (functionBody: string, readonly name: string, readonly path: string) {\n this.dir = path.substring(0, path.lastIndexOf('/') + 1)\n\n try {\n /* eslint-disable no-new-func */\n this.fn = new Function('stage', '__name', '__path', '__dir', functionBody)\n } catch (e) {\n Log.error('Script compilation failed', e)\n this.fn = function () {}\n }\n }\n\n /**\n * Execute the script\n * @param {Stage} stage - the stage context\n * @return {Promise} - resolve when script finished running\n */\n run (stage: Stage): Promise {\n return new Promise((resolve, reject) => {\n try {\n this.fn.apply(null, [ stage, this.name, this.path, this.dir ])\n resolve()\n } catch (e) {\n Log.error('Script.fn', e)\n reject(e)\n }\n })\n }\n}\n\nexport default Script\n","/**\n * @file Script Loader\n * @author Alexander Rose \n * @private\n */\n\nimport Loader from './loader'\nimport Script from '../script'\n\n/**\n * Script loader class\n * @extends Loader\n */\nclass ScriptLoader extends Loader {\n /**\n * Load script\n * @return {Promise} resolves to the loaded {@link Script}\n */\n load () {\n return this.streamer.read().then(() => {\n return new Script(\n this.streamer.asText(), this.parameters.name, this.parameters.path\n )\n })\n }\n}\n\nexport default ScriptLoader\n","/**\n * @file Loader Utils\n * @author Alexander Rose \n * @private\n */\n\nimport {\n DatasourceRegistry, DecompressorRegistry, ParserRegistry, ScriptExtensions\n} from '../globals'\nimport ParserLoader, { ParserParams } from './parser-loader'\nimport ScriptLoader from './script-loader'\n\nexport interface LoaderParameters {\n ext: string // file extension, determines file type\n compressed: string|false // flag data as compressed\n binary: boolean // flag data as binary\n name: string // set data name\n\n dir: string\n path: string\n protocol: string\n}\n\nexport type LoaderInput = File|Blob|string\n\nexport function getFileInfo (file: LoaderInput) {\n const compressedExtList = DecompressorRegistry.names\n\n let path: string\n let compressed: string|false\n let protocol = ''\n\n if (file instanceof File) {\n path = file.name\n } else if (file instanceof Blob) {\n path = ''\n } else {\n path = file\n }\n const queryIndex = path.lastIndexOf('?')\n const query = queryIndex !== -1 ? path.substring(queryIndex) : ''\n path = path.substring(0, queryIndex === -1 ? path.length : queryIndex)\n\n const name = path.replace(/^.*[\\\\/]/, '')\n let base = name.substring(0, name.lastIndexOf('.'))\n\n const nameSplit = name.split('.')\n let ext = nameSplit.length > 1 ? (nameSplit.pop() || '').toLowerCase() : ''\n\n const protocolMatch = path.match(/^(.+):\\/\\/(.+)$/)\n if (protocolMatch) {\n protocol = protocolMatch[ 1 ].toLowerCase()\n path = protocolMatch[ 2 ] || ''\n }\n\n const dir = path.substring(0, path.lastIndexOf('/') + 1)\n\n if (compressedExtList.includes(ext)) {\n compressed = ext\n const n = path.length - ext.length - 1\n ext = (path.substr(0, n).split('.').pop() || '').toLowerCase()\n const m = base.length - ext.length - 1\n base = base.substr(0, m)\n } else {\n compressed = false\n }\n\n return { path, name, ext, base, dir, compressed, protocol, query, 'src': file }\n}\n\nexport function getDataInfo (src: LoaderInput) {\n let info = getFileInfo(src)\n const datasource = DatasourceRegistry.get(info.protocol)\n if (datasource) {\n info = getFileInfo(datasource.getUrl(info.src))\n if (!info.ext && datasource.getExt) {\n info.ext = datasource.getExt(src)\n }\n }\n return info\n}\n\n/**\n * Load a file\n *\n * @example\n * // load from URL\n * NGL.autoLoad( \"http://files.rcsb.org/download/5IOS.cif\" );\n *\n * @example\n * // load binary data in CCP4 format via a Blob\n * var binaryBlob = new Blob( [ ccp4Data ], { type: 'application/octet-binary'} );\n * NGL.autoLoad( binaryBlob, { ext: \"ccp4\" } );\n *\n * @example\n * // load string data in PDB format via a Blob\n * var stringBlob = new Blob( [ pdbData ], { type: 'text/plain'} );\n * NGL.autoLoad( stringBlob, { ext: \"pdb\" } );\n *\n * @example\n * // load a File object\n * NGL.autoLoad( file );\n *\n * @param {String|File|Blob} file - either a URL or an object containing the file data\n * @param {LoaderParameters} params - loading parameters\n * @return {Promise} Promise resolves to the loaded data\n */\nexport function autoLoad (file: LoaderInput, params: Partial = {}) {\n const p = Object.assign(getDataInfo(file), params)\n\n let loader\n if (ParserRegistry.names.includes(p.ext)) {\n loader = new ParserLoader(p.src, p)\n } else if (ScriptExtensions.includes(p.ext)) {\n loader = new ScriptLoader(p.src, p)\n }\n\n if (loader) {\n return loader.load()\n } else {\n return Promise.reject(new Error(`autoLoad: ext '${p.ext}' unknown`))\n }\n}\n","/**\n * @file Writer\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults, download } from '../utils'\n\n/**\n * Base class for writers\n * @interface\n */\nabstract class Writer {\n readonly mimeType: string\n readonly defaultName: string\n readonly defaultExt: string\n\n /**\n * @abstract\n * @return {Anything} the data to be written\n */\n abstract getData (): any\n\n /**\n * Get a blob with the written data\n * @return {Blob} the blob\n */\n getBlob () {\n return new Blob([ this.getData() ], { type: this.mimeType })\n }\n\n /**\n * Trigger a download of the\n * @param {[type]} name [description]\n * @param {[type]} ext [description]\n * @return {[type]} [description]\n */\n download (name?: string, ext?: string) {\n name = defaults(name, this.defaultName)\n ext = defaults(ext, this.defaultExt)\n\n download(this.getBlob(), `${name}.${ext}`)\n }\n}\n\nexport default Writer","/**\n * @file Pdb Writer\n * @author Alexander Rose \n * @private\n */\n\nimport { sprintf } from 'sprintf-js'\n\nimport Writer from './writer'\nimport { defaults, ensureArray } from '../utils'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\n\n// http://www.wwpdb.org/documentation/file-format\n\n// Sample PDB line, the coords X,Y,Z are fields 5,6,7 on each line.\n// ATOM 1 N ARG 1 29.292 13.212 -12.751 1.00 33.78 1BPT 108\n\nconst AtomFormat =\n 'ATOM %5d %-4s %3s %1s%4d %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%1s%1s'\n\nconst HetatmFormat =\n 'HETATM%5d %-4s %3s %1s%4d %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%1s%1s'\n\nexport interface PdbWriterParams {\n renumberSerial: boolean\n remarks: string[]\n}\n\n/**\n * Create a PDB file from a Structure object\n */\nexport default class PdbWriter extends Writer {\n readonly mimeType = 'text/plain'\n readonly defaultName = 'structure'\n readonly defaultExt = 'pdb'\n\n renumberSerial: boolean\n remarks: string[]\n\n structure: Structure\n private _records: string[]\n\n /**\n * @param {Structure} structure - the structure object\n * @param {Object} params - parameters]\n */\n constructor (structure: Structure, params?: PdbWriterParams) {\n super()\n\n const p = Object.assign({}, params)\n\n this.renumberSerial = defaults(p.renumberSerial, true)\n this.remarks = ensureArray(defaults(p.remarks, []))\n\n this.structure = structure\n this._records = []\n }\n\n private _writeRecords () {\n this._records.length = 0\n\n this._writeTitle()\n this._writeRemarks()\n this._writeAtoms()\n }\n\n private _writeTitle () {\n // FIXME multiline if title line longer than 80 chars\n this._records.push(sprintf('TITLE %-74s', this.structure.name))\n }\n\n private _writeRemarks () {\n this.remarks.forEach(str => {\n this._records.push(sprintf('REMARK %-73s', str))\n })\n\n if (this.structure.trajectory) {\n this._records.push(sprintf(\n 'REMARK %-73s',\n \"Trajectory '\" + this.structure.trajectory.name + \"'\"\n ))\n this._records.push(sprintf(\n 'REMARK %-73s',\n `Frame ${(this.structure.trajectory as any).frame}` // TODO\n ))\n }\n }\n\n private _writeAtoms () {\n let ia = 1\n let im = 1\n let charge = \" \"\n let chargeSign = \" \"\n const hasModels = this.structure.modelStore.count > 1\n\n this.structure.eachModel(m => {\n if (hasModels) this._records.push(sprintf('MODEL %4d%-66s', im++, ''))\n\n m.eachAtom((a: AtomProxy) => {\n const formatString = a.hetero ? HetatmFormat : AtomFormat\n const serial = this.renumberSerial ? ia : a.serial\n\n // Formal PDB spec\n // Alignment of one-letter atom name such as C starts at column 14,\n // while two-letter atom name such as FE starts at column 13.\n\n // This, however, leaves Calcium and C-alpha ambiguous\n // The convention (from earlier versions of the spec, see 1992, and also: \n // https://www.cgl.ucsf.edu/chimera/docs/UsersGuide/tutorials/pdbintro.html#misalignment)\n // is that element is right-justified in 13-14, modifiers are left justified in columns 15-16\n // A single-character element symmbol should not appear in column 13 unless the atom name has four characters\n let atomname = a.atomname\n\n if (atomname.length === 1) {\n // Simple case\n atomname = ' ' + atomname\n } else if (atomname.length < 4) {\n // 2 or 3-letter name, if element symbol is single char and matches name, add a space\n if (a.element.length === 1 && atomname[0] === a.element) {\n atomname = ' ' + atomname\n }\n }\n\n if (a.formalCharge) { // Skip nulls and zeros\n charge = Math.abs(a.formalCharge).toPrecision(1)\n chargeSign = (a.formalCharge > 0) ? \"+\" : \"-\"\n } else {\n charge = \" \"\n chargeSign = \" \"\n }\n\n this._records.push(sprintf(\n formatString,\n\n serial,\n atomname,\n a.resname,\n defaults(a.chainname, ' '),\n a.resno,\n a.x, a.y, a.z,\n defaults(a.occupancy, 1.0),\n defaults(a.bfactor, 0.0),\n '', // segid\n defaults(a.element, ''),\n charge,\n chargeSign\n ))\n ia += 1\n }, this.structure.getSelection())\n\n if (hasModels) this._records.push(sprintf('%-80s', 'ENDMDL'))\n })\n\n this._records.push(sprintf('%-80s', 'END'))\n }\n\n getString () {\n console.warn('PdbWriter.getString() is deprecated, use .getData instead')\n return this.getData()\n }\n\n /**\n * Get string containing the PDB file data\n * @return {String} PDB file\n */\n getData () {\n this._writeRecords()\n return this._records.join('\\n')\n }\n}\n","/**\n * Writer class for sdf/mol files.\n */\n\nimport { sprintf } from 'sprintf-js'\n\nimport Writer from './writer'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\nimport BondProxy from '../proxy/bond-proxy'\n\n// Hard-coded chiral as false as we don't specify it any atoms\nconst CountFormat = '%3i%3i 0 0 0 0 0 0 0 0999 V2000'\nconst AtomLine = '%10.4f%10.4f%10.4f %-3s 0%3i 0 0 0'\nconst BondFormat = '%3i%3i%3i 0 0 0'\n\nclass SdfWriter extends Writer {\n readonly mimeType = 'text/plain'\n readonly defaultName = 'structure'\n readonly defaultExt = 'sdf'\n\n structure: Structure\n private _records: string[]\n\n /**\n * @param {Structure} structure - structure to write\n * @param {Object} params - parameters\n */\n constructor (structure: Structure) {\n super()\n\n this.structure = structure\n // Follow the pdb-writer example:\n this._records = []\n }\n\n get idString () {\n return this.structure.id\n }\n\n get titleString () {\n return ' ' + this.structure.title\n }\n\n get countsString () {\n return sprintf(\n CountFormat,\n this.structure.atomCount,\n this.structure.bondCount\n )\n }\n\n get chargeLines () {\n const pairs: [number, number][] = []\n this.structure.eachAtom(ap => {\n if (ap.formalCharge != null && ap.formalCharge !== 0) {\n pairs.push([ap.index, ap.formalCharge])\n }\n })\n const lines = []\n for (let i = 0; i < pairs.length; i += 8) {\n const nCharges = Math.min(8, pairs.length - i)\n let s = sprintf('M CHG%3i', nCharges)\n for (let j = i; j < i + nCharges; j++) {\n s += sprintf(' %3i %3i', pairs[j][0] + 1, pairs[j][1])\n }\n lines.push(s)\n }\n return lines\n }\n\n formatAtom (ap: AtomProxy) {\n let charge = 0\n if (ap.formalCharge != null && ap.formalCharge !== 0) {\n charge = 4 - ap.formalCharge\n }\n const line = sprintf(\n AtomLine, ap.x, ap.y, ap.z, ap.element, charge\n )\n if (line.length !== 48) { throw new Error('Incompatible atom for sdf format') }\n\n return line\n }\n\n formatBond (bp: BondProxy) {\n return sprintf(\n BondFormat,\n bp.atomIndex1 + 1,\n bp.atomIndex2 + 1,\n bp.bondOrder)\n }\n\n _writeRecords () {\n this._records.length = 0\n this._writeHeader()\n this._writeCTab()\n this._writeFooter()\n }\n\n _writeHeader () {\n this._records.push(this.idString, this.titleString, '')\n }\n\n _writeCTab () {\n this._records.push(this.countsString)\n this.structure.eachAtom(ap => {\n this._records.push(this.formatAtom(ap))\n })\n this.structure.eachBond(bp => {\n this._records.push(this.formatBond(bp))\n })\n this.chargeLines.forEach(line => {\n this._records.push(line)\n })\n this._records.push('M END')\n }\n\n _writeFooter () {\n this._records.push('$$$$')\n }\n\n getData () {\n this._writeRecords()\n return this._records.join('\\n')\n }\n}\n\nexport default SdfWriter\n","/**\n * @file IO Buffer\n * @author Alexander Rose \n * @private\n *\n * Adapted and converted to TypeScript from https://github.com/image-js/iobuffer\n * MIT License, Copyright (c) 2015 Michaël Zasso\n */\n\nimport { TypedArray } from '../types'\n\nconst defaultByteLength = 1024 * 8\nconst charArray: string[] = []\n\nexport interface IOBufferParameters {\n offset?: number // Ignore the first n bytes of the ArrayBuffer\n}\n\n/**\n * Class for writing and reading binary data\n */\nclass IOBuffer {\n private _lastWrittenByte: number\n private _mark = 0\n private _marks: number[] = []\n private _data: DataView\n\n offset = 0 // The current offset of the buffer's pointer\n littleEndian = true\n buffer: ArrayBuffer // Reference to the internal ArrayBuffer object\n length: number // Byte length of the internal ArrayBuffer\n byteLength: number // Byte length of the internal ArrayBuffer\n byteOffset: number // Byte offset of the internal ArrayBuffer\n\n /**\n * If it's a number, it will initialize the buffer with the number as\n * the buffer's length. If it's undefined, it will initialize the buffer\n * with a default length of 8 Kb. If its an ArrayBuffer, a TypedArray,\n * it will create a view over the underlying ArrayBuffer.\n */\n constructor (data: number|ArrayBuffer|TypedArray, params: IOBufferParameters = {}) {\n let dataIsGiven = false\n if (data === undefined) {\n data = defaultByteLength\n }\n if (typeof data === 'number') {\n data = new ArrayBuffer(data)\n } else {\n dataIsGiven = true\n }\n\n const offset = params.offset ? params.offset >>> 0 : 0\n let byteLength = data.byteLength - offset\n let dvOffset = offset\n if (!(data instanceof ArrayBuffer)) {\n if (data.byteLength !== data.buffer.byteLength) {\n dvOffset = data.byteOffset + offset\n }\n data = data.buffer\n }\n if (dataIsGiven) {\n this._lastWrittenByte = byteLength\n } else {\n this._lastWrittenByte = 0\n }\n\n this.buffer = data\n this.length = byteLength\n this.byteLength = byteLength\n this.byteOffset = dvOffset\n\n this._data = new DataView(this.buffer, dvOffset, byteLength)\n }\n\n /**\n * Checks if the memory allocated to the buffer is sufficient to store more bytes after the offset\n * @param {number} [byteLength=1] The needed memory in bytes\n * @return {boolean} Returns true if there is sufficient space and false otherwise\n */\n available (byteLength: number) {\n if (byteLength === undefined) byteLength = 1\n return (this.offset + byteLength) <= this.length\n }\n\n /**\n * Check if little-endian mode is used for reading and writing multi-byte values\n * @return {boolean} Returns true if little-endian mode is used, false otherwise\n */\n isLittleEndian () {\n return this.littleEndian\n }\n\n /**\n * Set little-endian mode for reading and writing multi-byte values\n * @return {IOBuffer}\n */\n setLittleEndian () {\n this.littleEndian = true\n return this\n }\n\n /**\n * Check if big-endian mode is used for reading and writing multi-byte values\n * @return {boolean} Returns true if big-endian mode is used, false otherwise\n */\n isBigEndian () {\n return !this.littleEndian\n }\n\n /**\n * Switches to big-endian mode for reading and writing multi-byte values\n * @return {IOBuffer}\n */\n setBigEndian () {\n this.littleEndian = false\n return this\n }\n\n /**\n * Move the pointer n bytes forward\n * @param {number} n\n * @return {IOBuffer}\n */\n skip (n: number) {\n if (n === undefined) n = 1\n this.offset += n\n return this\n }\n\n /**\n * Move the pointer to the given offset\n * @param {number} offset\n * @return {IOBuffer}\n */\n seek (offset: number) {\n this.offset = offset\n return this\n }\n\n /**\n * Store the current pointer offset.\n * @see {@link IOBuffer#reset}\n * @return {IOBuffer}\n */\n mark () {\n this._mark = this.offset\n return this\n }\n\n /**\n * Move the pointer back to the last pointer offset set by mark\n * @see {@link IOBuffer#mark}\n * @return {IOBuffer}\n */\n reset () {\n this.offset = this._mark\n return this\n }\n\n /**\n * Push the current pointer offset to the mark stack\n * @see {@link IOBuffer#popMark}\n * @return {IOBuffer}\n */\n pushMark () {\n this._marks.push(this.offset)\n return this\n }\n\n /**\n * Pop the last pointer offset from the mark stack, and set the current pointer offset to the popped value\n * @see {@link IOBuffer#pushMark}\n * @return {IOBuffer}\n */\n popMark () {\n const offset = this._marks.pop()\n if (offset === undefined) throw new Error('Mark stack empty')\n this.seek(offset)\n return this\n }\n\n /**\n * Move the pointer offset back to 0\n * @return {IOBuffer}\n */\n rewind () {\n this.offset = 0\n return this\n }\n\n /**\n * Make sure the buffer has sufficient memory to write a given byteLength at the current pointer offset\n * If the buffer's memory is insufficient, this method will create a new buffer (a copy) with a length\n * that is twice (byteLength + current offset)\n * @param {number} [byteLength = 1]\n * @return {IOBuffer}\n */\n ensureAvailable (byteLength: number) {\n if (byteLength === undefined) byteLength = 1\n if (!this.available(byteLength)) {\n const lengthNeeded = this.offset + byteLength\n const newLength = lengthNeeded * 2\n const newArray = new Uint8Array(newLength)\n newArray.set(new Uint8Array(this.buffer))\n this.buffer = newArray.buffer\n this.length = this.byteLength = newLength\n this._data = new DataView(this.buffer)\n }\n return this\n }\n\n /**\n * Read a byte and return false if the byte's value is 0, or true otherwise\n * Moves pointer forward\n * @return {boolean}\n */\n readBoolean () {\n return this.readUint8() !== 0\n }\n\n /**\n * Read a signed 8-bit integer and move pointer forward\n * @return {number}\n */\n readInt8 () {\n return this._data.getInt8(this.offset++)\n }\n\n /**\n * Read an unsigned 8-bit integer and move pointer forward\n * @return {number}\n */\n readUint8 () {\n return this._data.getUint8(this.offset++)\n }\n\n /**\n * Alias for {@link IOBuffer#readUint8}\n * @return {number}\n */\n readByte () {\n return this.readUint8()\n }\n\n /**\n * Read n bytes and move pointer forward.\n * @param {number} n\n * @return {Uint8Array}\n */\n readBytes (n: number) {\n if (n === undefined) n = 1\n var bytes = new Uint8Array(n)\n for (var i = 0; i < n; i++) {\n bytes[i] = this.readByte()\n }\n return bytes\n }\n\n /**\n * Read a 16-bit signed integer and move pointer forward\n * @return {number}\n */\n readInt16 () {\n var value = this._data.getInt16(this.offset, this.littleEndian)\n this.offset += 2\n return value\n }\n\n /**\n * Read a 16-bit unsigned integer and move pointer forward\n * @return {number}\n */\n readUint16 () {\n var value = this._data.getUint16(this.offset, this.littleEndian)\n this.offset += 2\n return value\n }\n\n /**\n * Read a 32-bit signed integer and move pointer forward\n * @return {number}\n */\n readInt32 () {\n var value = this._data.getInt32(this.offset, this.littleEndian)\n this.offset += 4\n return value\n }\n\n /**\n * Read a 32-bit unsigned integer and move pointer forward\n * @return {number}\n */\n readUint32 () {\n var value = this._data.getUint32(this.offset, this.littleEndian)\n this.offset += 4\n return value\n }\n\n /**\n * Read a 32-bit floating number and move pointer forward\n * @return {number}\n */\n readFloat32 () {\n var value = this._data.getFloat32(this.offset, this.littleEndian)\n this.offset += 4\n return value\n }\n\n /**\n * Read a 64-bit floating number and move pointer forward\n * @return {number}\n */\n readFloat64 () {\n var value = this._data.getFloat64(this.offset, this.littleEndian)\n this.offset += 8\n return value\n }\n\n /**\n * Read 1-byte ascii character and move pointer forward\n * @return {string}\n */\n readChar () {\n return String.fromCharCode(this.readInt8())\n }\n\n /**\n * Read n 1-byte ascii characters and move pointer forward\n * @param {number} n\n * @return {string}\n */\n readChars (n = 1) {\n charArray.length = n\n for (var i = 0; i < n; i++) {\n charArray[i] = this.readChar()\n }\n return charArray.join('')\n }\n\n /**\n * Write 0xff if the passed value is truthy, 0x00 otherwise\n * @param {any} value\n * @return {IOBuffer}\n */\n writeBoolean (value = false) {\n this.writeUint8(value ? 0xff : 0x00)\n return this\n }\n\n /**\n * Write value as an 8-bit signed integer\n * @param {number} value\n * @return {IOBuffer}\n */\n writeInt8 (value: number) {\n this.ensureAvailable(1)\n this._data.setInt8(this.offset++, value)\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write value as a 8-bit unsigned integer\n * @param {number} value\n * @return {IOBuffer}\n */\n writeUint8 (value: number) {\n this.ensureAvailable(1)\n this._data.setUint8(this.offset++, value)\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * An alias for {@link IOBuffer#writeUint8}\n * @param {number} value\n * @return {IOBuffer}\n */\n writeByte (value: number) {\n return this.writeUint8(value)\n }\n\n /**\n * Write bytes\n * @param {Array|Uint8Array} bytes\n * @return {IOBuffer}\n */\n writeBytes (bytes: number[]|Uint8Array) {\n this.ensureAvailable(bytes.length)\n for (var i = 0; i < bytes.length; i++) {\n this._data.setUint8(this.offset++, bytes[i])\n }\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write value as an 16-bit signed integer\n * @param {number} value\n * @return {IOBuffer}\n */\n writeInt16 (value: number) {\n this.ensureAvailable(2)\n this._data.setInt16(this.offset, value, this.littleEndian)\n this.offset += 2\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write value as a 16-bit unsigned integer\n * @param {number} value\n * @return {IOBuffer}\n */\n writeUint16 (value: number) {\n this.ensureAvailable(2)\n this._data.setUint16(this.offset, value, this.littleEndian)\n this.offset += 2\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write a 32-bit signed integer at the current pointer offset\n * @param {number} value\n * @return {IOBuffer}\n */\n writeInt32 (value: number) {\n this.ensureAvailable(4)\n this._data.setInt32(this.offset, value, this.littleEndian)\n this.offset += 4\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write a 32-bit unsigned integer at the current pointer offset\n * @param {number} value - The value to set\n * @return {IOBuffer}\n */\n writeUint32 (value: number) {\n this.ensureAvailable(4)\n this._data.setUint32(this.offset, value, this.littleEndian)\n this.offset += 4\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write a 32-bit floating number at the current pointer offset\n * @param {number} value - The value to set\n * @return {IOBuffer}\n */\n writeFloat32 (value: number) {\n this.ensureAvailable(4)\n this._data.setFloat32(this.offset, value, this.littleEndian)\n this.offset += 4\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write a 64-bit floating number at the current pointer offset\n * @param {number} value\n * @return {IOBuffer}\n */\n writeFloat64 (value: number) {\n this.ensureAvailable(8)\n this._data.setFloat64(this.offset, value, this.littleEndian)\n this.offset += 8\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write the charCode of the passed string's first character to the current pointer offset\n * @param {string} str - The character to set\n * @return {IOBuffer}\n */\n writeChar (str: string) {\n return this.writeUint8(str.charCodeAt(0))\n }\n\n /**\n * Write the charCodes of the passed string's characters to the current pointer offset\n * @param {string} str\n * @return {IOBuffer}\n */\n writeChars (str: string) {\n for (var i = 0; i < str.length; i++) {\n this.writeUint8(str.charCodeAt(i))\n }\n return this\n }\n\n /**\n * Export a Uint8Array view of the internal buffer.\n * The view starts at the byte offset and its length\n * is calculated to stop at the last written byte or the original length.\n * @return {Uint8Array}\n */\n toArray () {\n return new Uint8Array(this.buffer, this.byteOffset, this._lastWrittenByte)\n }\n\n /**\n * Update the last written byte offset\n * @private\n */\n _updateLastWrittenByte () {\n if (this.offset > this._lastWrittenByte) {\n this._lastWrittenByte = this.offset\n }\n }\n}\n\nexport default IOBuffer\n","/**\n * @file STL Writer\n * @author Paul Pillot \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport Writer from './writer'\nimport IOBuffer from '../utils/io-buffer'\nimport Surface from '../surface/surface'\n\n// https://en.wikipedia.org/wiki/STL_(file_format)#ASCII_STL\n\n/**\n * Create an STL File from a surface Object (e.g. for 3D printing)\n *\n * @example\n * molsurf = new MolecularSurface(structure)\n * surf = molsurf.getSurface({type: 'av', probeRadius: 1.4})\n * stl = new StlWriter(surf)\n * stl.download('myFileName')\n */\nexport default class StlWriter extends Writer {\n readonly mimeType = 'application/vnd.ms-pki.stl'\n readonly defaultName = 'surface'\n readonly defaultExt = 'stl'\n\n surface: any // TODO\n\n /**\n * @param {Surface} surface - the surface to write out\n */\n constructor (surface: Surface) {\n super()\n\n this.surface = surface\n }\n\n /*\n * Get STL Binary data\n *\n * Adapted from: https://github.com/mrdoob/three.js/blob/master/examples/js/exporters/STLBinaryExporter.js\n * see https://en.wikipedia.org/wiki/STL_(file_format)#Binary_STL for the file format description\n *\n * @return {DataView} the data\n */\n getData () {\n const triangles = this.surface.index.length / 3\n const bufferLength = triangles * 2 + triangles * 3 * 4 * 4 + 80 + 4\n const output = new IOBuffer(bufferLength)\n\n output.skip(80) // skip header\n output.writeUint32(triangles)\n\n const vector = new Vector3()\n const vectorNorm1 = new Vector3()\n const vectorNorm2 = new Vector3()\n const vectorNorm3 = new Vector3()\n\n // traversing vertices\n for (let i = 0; i < triangles; i++) {\n const indices = [\n this.surface.index[i * 3],\n this.surface.index[i * 3 + 1],\n this.surface.index[i * 3 + 2]\n ]\n\n vectorNorm1.fromArray(this.surface.normal, indices[0] * 3)\n vectorNorm2.fromArray(this.surface.normal, indices[1] * 3)\n vectorNorm3.fromArray(this.surface.normal, indices[2] * 3)\n\n vector.addVectors(vectorNorm1, vectorNorm2).add(vectorNorm3).normalize()\n\n output.writeFloat32(vector.x)\n output.writeFloat32(vector.y)\n output.writeFloat32(vector.z)\n\n for (let j = 0; j < 3; j++) {\n vector.fromArray(this.surface.position, indices[j] * 3)\n\n output.writeFloat32(vector.x) // vertices\n output.writeFloat32(vector.y)\n output.writeFloat32(vector.z)\n }\n\n output.writeUint16(0) // attribute byte count\n }\n\n return new DataView(output.buffer)\n }\n}","/**\n * @file Counter\n * @author Alexander Rose \n * @private\n */\n\nimport { Log } from '../globals'\n\nimport * as signalsWrapper from 'signals'\n\n/**\n * {@link Signal}, dispatched when the `count` changes\n * @example\n * counter.signals.countChanged.add( function( delta ){ ... } );\n * @event Counter#countChanged\n * @type {Integer}\n */\n\nexport interface CounterSignals {\n countChanged: signalsWrapper.Signal\n}\n\n/**\n * Counter class for keeping track of counts\n */\nclass Counter {\n count = 0\n\n signals: CounterSignals = {\n countChanged: new signalsWrapper.Signal()\n }\n\n /**\n * Set the `count` to zero\n * @return {undefined}\n */\n clear () {\n this.change(-this.count)\n }\n\n /**\n * Change the `count`\n * @fires Counter#countChanged\n * @param {Integer} delta - count change\n * @return {undefined}\n */\n change (delta: number) {\n this.count += delta\n this.signals.countChanged.dispatch(delta, this.count)\n\n if (this.count < 0) {\n Log.warn('Counter.count below zero', this.count)\n }\n }\n\n /**\n * Increments the `count` by one.\n * @return {undefined}\n */\n increment () {\n this.change(1)\n }\n\n /**\n * Decrements the `count` by one.\n * @return {undefined}\n */\n decrement () {\n this.change(-1)\n }\n\n /**\n * Listen to another counter object and change this `count` by the\n * same amount\n * @param {Counter} counter - the counter object to listen to\n * @return {undefined}\n */\n listen (counter: Counter) {\n this.change(counter.count)\n counter.signals.countChanged.add(this.change, this)\n }\n\n /**\n * Stop listening to the other counter object\n * @param {Counter} counter - the counter object to stop listening to\n * @return {undefined}\n */\n unlisten (counter: Counter) {\n const countChanged = counter.signals.countChanged\n if (countChanged.has(this.change, this)) {\n countChanged.remove(this.change, this)\n }\n }\n\n /**\n * Invole the callback function once, when the `count` becomes zero\n * @param {Function} callback - the callback function\n * @param {Object} context - the context for the callback function\n * @return {undefined}\n */\n onZeroOnce (callback: () => void, context?: any) {\n if (this.count === 0) {\n callback.call(context)\n } else {\n const fn = () => {\n if (this.count === 0) {\n this.signals.countChanged.remove(fn, this)\n callback.call(context)\n }\n }\n this.signals.countChanged.add(fn, this)\n }\n }\n\n dispose () {\n this.clear()\n this.signals.countChanged.dispose()\n }\n}\n\nexport default Counter\n","/**\n * @file Stats\n * @author Alexander Rose \n * @private\n */\n\nimport * as signalsWrapper from 'signals'\n\nexport default class Stats {\n signals = {\n updated: new signalsWrapper.Signal()\n }\n\n maxDuration = -Infinity\n minDuration = Infinity\n avgDuration = 14\n lastDuration = Infinity\n\n prevFpsTime = 0\n lastFps = Infinity\n lastFrames = 1\n frames = 0\n count = 0\n\n startTime: number\n currentTime: number\n\n constructor () {\n this.begin()\n }\n\n update () {\n this.startTime = this.end()\n this.currentTime = this.startTime\n this.signals.updated.dispatch()\n }\n\n begin () {\n this.startTime = window.performance.now()\n this.lastFrames = this.frames\n }\n\n end () {\n const time = window.performance.now()\n\n this.count += 1\n this.frames += 1\n\n this.lastDuration = time - this.startTime\n this.minDuration = Math.min(this.minDuration, this.lastDuration)\n this.maxDuration = Math.max(this.maxDuration, this.lastDuration)\n this.avgDuration -= this.avgDuration / 30\n this.avgDuration += this.lastDuration / 30\n\n if (time > this.prevFpsTime + 1000) {\n this.lastFps = this.frames\n this.prevFpsTime = time\n this.frames = 0\n }\n\n return time\n }\n}","/**\n * @file Shader Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { ShaderChunk } from 'three'\n\nimport './chunk/fog_fragment.glsl'\nimport './chunk/interior_fragment.glsl'\nimport './chunk/matrix_scale.glsl'\nimport './chunk/nearclip_vertex.glsl'\nimport './chunk/nearclip_fragment.glsl'\nimport './chunk/opaque_back_fragment.glsl'\nimport './chunk/radiusclip_vertex.glsl'\nimport './chunk/radiusclip_fragment.glsl'\nimport './chunk/unpack_color.glsl'\n\nimport { ShaderRegistry } from '../globals'\n\nexport type ShaderDefine = (\n 'NEAR_CLIP'|'RADIUS_CLIP'|'PICKING'|'NOLIGHT'|'FLAT_SHADED'|'OPAQUE_BACK'|\n 'DIFFUSE_INTERIOR'|'USE_INTERIOR_COLOR'|\n 'USE_SIZEATTENUATION'|'USE_MAP'|'ALPHATEST'|'SDF'|'FIXED_SIZE'|\n 'CUBIC_INTERPOLATION'|'BSPLINE_FILTER'|'CATMULROM_FILTER'|'MITCHELL_FILTER'\n)\nexport type ShaderDefines = {\n [k in ShaderDefine]?: number|string\n}\n\nfunction getDefines (defines: ShaderDefines) {\n if (defines === undefined) return ''\n\n const lines = []\n\n for (const name in defines) {\n const value = defines[ name as keyof ShaderDefines ]\n\n if (!value) continue\n\n lines.push(`#define ${name} ${value}`)\n }\n\n return lines.join('\\n') + '\\n'\n}\n\nconst reInclude = /^(?!\\/\\/)\\s*#include\\s+(\\S+)/gmi\nconst shaderCache: { [k: string]: string } = {}\n\nexport function getShader (name: string, defines: ShaderDefines = {}) {\n let hash = name + '|'\n for (const key in defines) {\n hash += key + ':' + defines[ key as keyof ShaderDefines ]\n }\n\n if (!shaderCache[ hash ]) {\n const definesText = getDefines(defines)\n\n let shaderText = ShaderRegistry.get(`shader/${name}`) as string\n if (!shaderText) {\n throw new Error(`empty shader, '${name}'`)\n }\n shaderText = shaderText.replace(reInclude, function (match, p1) {\n const path = `shader/chunk/${p1}.glsl`\n const chunk = ShaderRegistry.get(path) || ShaderChunk[ p1 ]\n if (!chunk) {\n throw new Error(`empty chunk, '${p1}'`)\n }\n return chunk\n })\n\n shaderCache[ hash ] = definesText + shaderText\n }\n\n return shaderCache[ hash ]\n}\n","/**\n * @file Viewer Constants\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug } from '../globals'\n\nif (typeof WebGLRenderingContext !== 'undefined') {\n const wrcp = WebGLRenderingContext.prototype\n\n // wrap WebGL debug function used by three.js and\n // ignore calls to them when the debug flag is not set\n\n const _getShaderParameter = wrcp.getShaderParameter\n wrcp.getShaderParameter = function getShaderParameter (this: WebGLRenderingContext) {\n if (Debug) {\n return _getShaderParameter.apply(this, arguments)\n } else {\n return true\n }\n }\n\n const _getShaderInfoLog = wrcp.getShaderInfoLog\n wrcp.getShaderInfoLog = function getShaderInfoLog (this: WebGLRenderingContext) {\n if (Debug) {\n return _getShaderInfoLog.apply(this, arguments)\n } else {\n return ''\n }\n }\n\n const _getProgramParameter = wrcp.getProgramParameter\n wrcp.getProgramParameter = function getProgramParameter (this: WebGLRenderingContext, program, pname) {\n if (Debug || pname !== wrcp.LINK_STATUS) {\n return _getProgramParameter.apply(this, arguments)\n } else {\n return true\n }\n }\n\n const _getProgramInfoLog = wrcp.getProgramInfoLog\n wrcp.getProgramInfoLog = function getProgramInfoLog (this: WebGLRenderingContext) {\n if (Debug) {\n return _getProgramInfoLog.apply(this, arguments)\n } else {\n return ''\n }\n }\n}\n\nexport const JitterVectors = [\n [\n [ 0, 0 ]\n ],\n [\n [ 4, 4 ], [ -4, -4 ]\n ],\n [\n [ -2, -6 ], [ 6, -2 ], [ -6, 2 ], [ 2, 6 ]\n ],\n [\n [ 1, -3 ], [ -1, 3 ], [ 5, 1 ], [ -3, -5 ],\n [ -5, 5 ], [ -7, -1 ], [ 3, 7 ], [ 7, -7 ]\n ],\n [\n [ 1, 1 ], [ -1, -3 ], [ -3, 2 ], [ 4, -1 ],\n [ -5, -2 ], [ 2, 5 ], [ 5, 3 ], [ 3, -5 ],\n [ -2, 6 ], [ 0, -7 ], [ -4, -6 ], [ -6, 4 ],\n [ -8, 0 ], [ 7, -4 ], [ 6, 7 ], [ -7, -8 ]\n ],\n [\n [ -4, -7 ], [ -7, -5 ], [ -3, -5 ], [ -5, -4 ],\n [ -1, -4 ], [ -2, -2 ], [ -6, -1 ], [ -4, 0 ],\n [ -7, 1 ], [ -1, 2 ], [ -6, 3 ], [ -3, 3 ],\n [ -7, 6 ], [ -3, 6 ], [ -5, 7 ], [ -1, 7 ],\n [ 5, -7 ], [ 1, -6 ], [ 6, -5 ], [ 4, -4 ],\n [ 2, -3 ], [ 7, -2 ], [ 1, -1 ], [ 4, -1 ],\n [ 2, 1 ], [ 6, 2 ], [ 0, 4 ], [ 4, 4 ],\n [ 2, 5 ], [ 7, 5 ], [ 5, 6 ], [ 3, 7 ]\n ]\n]\n\nJitterVectors.forEach(offsetList => {\n offsetList.forEach(offset => {\n // 0.0625 = 1 / 16\n offset[ 0 ] *= 0.0625\n offset[ 1 ] *= 0.0625\n })\n})\n","/**\n * @file Tiled Renderer\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { Camera, WebGLRenderer } from 'three'\nimport Viewer from './viewer'\n\nexport interface TiledRendererParams {\n factor?: number\n antialias?: boolean\n onProgress?: Function\n onFinish?: Function\n}\n\nclass TiledRenderer {\n canvas = document.createElement('canvas')\n\n private _width: number\n private _height: number\n private _n: number\n private _factor: number\n private _antialias: boolean\n private _viewerSampleLevel: number\n\n private _viewer: Viewer\n private _onProgress?: Function\n private _onFinish?: Function\n private _ctx: CanvasRenderingContext2D\n\n constructor(renderer: WebGLRenderer, camera: Camera, viewer: Viewer, params: TiledRendererParams) {\n this._viewer = viewer\n\n this._factor = defaults(params.factor, 2)\n this._antialias = defaults(params.antialias, false)\n\n this._onProgress = params.onProgress\n this._onFinish = params.onFinish\n\n if (this._antialias) this._factor *= 2\n this._n = this._factor * this._factor\n\n // canvas\n\n this._width = this._viewer.width\n this._height = this._viewer.height\n\n if (this._antialias) {\n this.canvas.width = this._width * this._factor / 2\n this.canvas.height = this._height * this._factor / 2\n } else {\n this.canvas.width = this._width * this._factor\n this.canvas.height = this._height * this._factor\n }\n\n this._ctx = this.canvas.getContext('2d')!\n\n this._viewerSampleLevel = viewer.sampleLevel\n this._viewer.setSampling(-1)\n }\n\n private _renderTile (i: number) {\n const viewer = this._viewer\n const width = this._width\n const height = this._height\n const factor = this._factor\n\n const x = i % factor\n const y = Math.floor(i / factor)\n\n const offsetX = x * width\n const offsetY = y * height\n\n viewer.camera.setViewOffset(\n width * factor,\n height * factor,\n offsetX,\n offsetY,\n width,\n height\n )\n\n viewer.render()\n\n if (this._antialias) {\n const w = Math.round((offsetX + width) / 2) - Math.round (offsetX / 2);\n const h = Math.round((offsetY + height) / 2) - Math.round (offsetY / 2);\n this._ctx.drawImage(\n viewer.renderer.domElement,\n Math.round(offsetX / 2),\n Math.round(offsetY / 2),\n w,\n h\n )\n } else {\n this._ctx.drawImage(\n viewer.renderer.domElement,\n Math.floor(offsetX),\n Math.floor(offsetY),\n Math.ceil(width),\n Math.ceil(height)\n )\n }\n\n if (typeof this._onProgress === 'function') {\n this._onProgress(i + 1, this._n, false)\n }\n }\n\n private _finalize () {\n this._viewer.setSampling(this._viewerSampleLevel)\n this._viewer.camera.view = null! // TODO\n\n if (typeof this._onFinish === 'function') {\n this._onFinish(this._n + 1, this._n, false)\n }\n }\n\n render () {\n for (let i = 0; i <= this._n; ++i) {\n if (i === this._n) {\n this._finalize()\n } else {\n this._renderTile(i)\n }\n }\n }\n\n renderAsync () {\n let count = 0\n const n = this._n\n\n const fn = () => {\n if (count === n) {\n this._finalize()\n } else {\n this._renderTile(count)\n }\n count += 1\n }\n\n for (let i = 0; i <= n; ++i) {\n setTimeout(fn, 0)\n }\n }\n}\n\nexport default TiledRenderer\n","/**\n * @file Math Constants\n * @author Alexander Rose \n * @private\n */\n\nexport const EPS = 0.0000001\nexport const TwoPI = 2 * Math.PI\n\nexport const DEG2RAD = Math.PI / 180\nexport const RAD2DEG = 180 / Math.PI\n","/**\n * @file Array Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { NumberArray } from '../types'\nimport { TwoPI } from './math-constants'\n\nexport function circularMean (array: NumberArray, max: number, stride = 1, offset = 0, indices?: NumberArray) {\n // http://en.wikipedia.org/wiki/Center_of_mass#Systems_with_periodic_boundary_conditions\n\n // Bai, Linge; Breen, David (2008). Calculating Center of Mass in an Unbounded 2D Environment. Journal of Graphics, GPU, and Game Tools 13 (4): 53–60.\n\n // http://stackoverflow.com/questions/18166507/using-fft-to-find-the-center-of-mass-under-periodic-boundary-conditions\n\n const n = indices ? indices.length : array.length / stride\n\n let cosMean = 0\n let sinMean = 0\n\n if (indices) {\n for (let i = 0; i < n; ++i) {\n const c = (array[ indices[ i ] * stride + offset ] + max) % max\n const angle = (c / max) * TwoPI - Math.PI\n\n cosMean += Math.cos(angle)\n sinMean += Math.sin(angle)\n }\n } else {\n for (let i = offset; i < n; i += stride) {\n const c = (array[ i ] + max) % max\n const angle = (c / max) * TwoPI - Math.PI\n\n cosMean += Math.cos(angle)\n sinMean += Math.sin(angle)\n }\n }\n\n cosMean /= n\n sinMean /= n\n\n const meanAngle = Math.atan2(sinMean, cosMean)\n const mean = (meanAngle + Math.PI) / TwoPI * max\n\n return mean\n}\n\nexport function calculateCenterArray (array1: NumberArray, array2: NumberArray, center?: T, offset = 0): T {\n const n = array1.length\n const c = center || new Float32Array(n)\n\n for (let i = 0; i < n; i += 3) {\n c[ offset + i + 0 ] = (array1[ i + 0 ] + array2[ i + 0 ]) / 2.0\n c[ offset + i + 1 ] = (array1[ i + 1 ] + array2[ i + 1 ]) / 2.0\n c[ offset + i + 2 ] = (array1[ i + 2 ] + array2[ i + 2 ]) / 2.0\n }\n\n return c as T\n}\n\nexport function calculateDirectionArray (array1: NumberArray, array2: NumberArray) {\n const n = array1.length\n const direction = new Float32Array(n)\n\n for (let i = 0; i < n; i += 3) {\n direction[ i + 0 ] = array2[ i + 0 ] - array1[ i + 0 ]\n direction[ i + 1 ] = array2[ i + 1 ] - array1[ i + 1 ]\n direction[ i + 2 ] = array2[ i + 2 ] - array1[ i + 2 ]\n }\n\n return direction\n}\n\nexport function uniformArray (n: number, a: number, optionalTarget?: T): T {\n const array = optionalTarget || new Float32Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = a\n }\n\n return array as T\n}\n\nexport function uniformArray3 (n: number, a: number, b: number, c: number, optionalTarget?: NumberArray) {\n const array = optionalTarget || new Float32Array(n * 3)\n\n for (let i = 0; i < n; ++i) {\n const j = i * 3\n\n array[ j + 0 ] = a\n array[ j + 1 ] = b\n array[ j + 2 ] = c\n }\n\n return array\n}\n\nexport function centerArray3 (array: NumberArray, center = new Vector3()) {\n const n = array.length\n\n for (let i = 0; i < n; i += 3) {\n center.x += array[ i ]\n center.y += array[ i + 1 ]\n center.z += array[ i + 2 ]\n }\n\n center.divideScalar(n / 3)\n\n return center\n}\n\nexport function serialArray (n: number) {\n const array = new Float32Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = i\n }\n\n return array\n}\n\nexport function serialBlockArray (n: number, b: number, offset = 0, optionalTarget?: NumberArray) {\n const array = optionalTarget || new Float32Array(n * b)\n\n for (let i = 0; i < n; ++i) {\n const k = offset + i * b\n\n for (let j = 0; j < b; ++j) {\n array[ k + j ] = i\n }\n }\n\n return array\n}\n\nexport function randomColorArray (n: number) {\n const array = new Float32Array(n * 3)\n\n for (let i = 0; i < n; ++i) {\n const j = i * 3\n\n array[ j + 0 ] = Math.random()\n array[ j + 1 ] = Math.random()\n array[ j + 2 ] = Math.random()\n }\n\n return array\n}\n\nexport function replicateArrayEntries (array: NumberArray, m: number) {\n const n = array.length\n const repArr = new Float32Array(n * m)\n\n for (let i = 0; i < n; ++i) {\n const k = i * m\n const a = array[ i ]\n\n for (let j = 0; j < m; ++j) {\n repArr[ k + j ] = a\n }\n }\n\n return repArr\n}\n\nexport function replicateArray3Entries (array: NumberArray, m: number) {\n const n = array.length / 3\n const repArr = new Float32Array(n * m * 3)\n\n for (let i = 0; i < n; ++i) {\n const v = i * 3\n const k = i * m * 3\n\n const a = array[ v + 0 ]\n const b = array[ v + 1 ]\n const c = array[ v + 2 ]\n\n for (let j = 0; j < m; ++j) {\n const l = k + j * 3\n\n repArr[ l + 0 ] = a\n repArr[ l + 1 ] = b\n repArr[ l + 2 ] = c\n }\n }\n\n return repArr\n}\n\nexport function calculateMeanArray (array1: NumberArray, array2: NumberArray) {\n const n = array1.length\n const mean = new Float32Array(n)\n\n for (let i = 0; i < n; i++) {\n mean[ i ] = (array1[ i ] + array2[ i ]) / 2.0\n }\n\n return mean\n}\n\nexport function calculateMinArray (array1: NumberArray, array2: NumberArray) {\n const n = array1.length\n const min = new Float32Array(n)\n\n for (let i = 0; i < n; i++) {\n min[ i ] = Math.min(array1[ i ], array2[ i ])\n }\n\n return min\n}\n\nexport function copyArray (src: T, dst: T, srcOffset: number, dstOffset: number, length: number) {\n for (let i = 0; i < length; ++i) {\n dst[ dstOffset + i ] = src[ srcOffset + i ]\n }\n}\n\nexport function copyWithin (array: NumberArray|any[], srcOffset: number, dstOffset: number, length: number) {\n copyArray(array, array, srcOffset, dstOffset, length)\n}\n\nconst swap = new Float32Array(4)\nconst temp = new Float32Array(4)\n/**\n * quicksortIP\n * @function\n * @author Roman Bolzern , 2013\n * @author I4DS http://www.fhnw.ch/i4ds, 2013\n * @license MIT License \n * @description\n * In-place quicksort for typed arrays (e.g. for Float32Array)\n * provides fast sorting\n * useful e.g. for a custom shader and/or BufferGeometry\n * Complexity: http://bigocheatsheet.com/ see Quicksort\n *\n * @example\n * points: [x, y, z, x, y, z, x, y, z, ...]\n * eleSize: 3 //because of (x, y, z)\n * orderElement: 0 //order according to x\n *\n * @param {TypedArray} arr - array to be sorted\n * @param {Integer} eleSize - element size\n * @param {Integer} orderElement - index of element used for sorting, < eleSize\n * @param {Integer} [begin] - start index for range to be sorted\n * @param {Integer} [end] - end index for range to be sorted\n * @return {TypedArray} the input array\n */\nexport function quicksortIP (arr: NumberArray, eleSize: number, orderElement: number, begin = 0, end?: number) {\n end = (end || (arr.length / eleSize)) - 1\n\n const stack = []\n let sp = -1\n let left = begin\n let right = end\n let tmp = 0.0\n let x = 0\n let y = 0\n\n const swapF = function (a: number, b: number) {\n a *= eleSize; b *= eleSize\n for (y = 0; y < eleSize; y++) {\n tmp = arr[ a + y ]\n arr[ a + y ] = arr[ b + y ]\n arr[ b + y ] = tmp\n }\n }\n\n let i, j\n\n while (true) {\n if (right - left <= 25) {\n for (j = left + 1; j <= right; j++) {\n for (x = 0; x < eleSize; x++) {\n swap[ x ] = arr[ j * eleSize + x ]\n }\n\n i = j - 1\n\n while (i >= left && arr[ i * eleSize + orderElement ] > swap[ orderElement ]) {\n for (x = 0; x < eleSize; x++) {\n arr[ (i + 1) * eleSize + x ] = arr[ i * eleSize + x ]\n }\n i--\n }\n\n for (x = 0; x < eleSize; x++) {\n arr[ (i + 1) * eleSize + x ] = swap[ x ]\n }\n }\n\n if (sp === -1) break\n\n right = stack[ sp-- ] // ?\n left = stack[ sp-- ]\n } else {\n const median = (left + right) >> 1\n\n i = left + 1\n j = right\n\n swapF(median, i)\n\n if (arr[ left * eleSize + orderElement ] > arr[ right * eleSize + orderElement ]) {\n swapF(left, right)\n }\n\n if (arr[ i * eleSize + orderElement ] > arr[ right * eleSize + orderElement ]) {\n swapF(i, right)\n }\n\n if (arr[ left * eleSize + orderElement ] > arr[ i * eleSize + orderElement ]) {\n swapF(left, i)\n }\n\n for (x = 0; x < eleSize; x++) {\n temp[ x ] = arr[ i * eleSize + x ]\n }\n\n while (true) {\n do i++; while (arr[ i * eleSize + orderElement ] < temp[ orderElement ])\n do j--; while (arr[ j * eleSize + orderElement ] > temp[ orderElement ])\n if (j < i) break\n swapF(i, j)\n }\n\n for (x = 0; x < eleSize; x++) {\n arr[ (left + 1) * eleSize + x ] = arr[ j * eleSize + x ]\n arr[ j * eleSize + x ] = temp[ x ]\n }\n\n if (right - i + 1 >= j - left) {\n stack[ ++sp ] = i\n stack[ ++sp ] = right\n right = j - 1\n } else {\n stack[ ++sp ] = left\n stack[ ++sp ] = j - 1\n left = i\n }\n }\n }\n\n return arr\n}\n\nexport function quicksortCmp (arr: NumberArray|T[], cmp?: (a: number|T, b: number|T) => number, begin = 0, end?: number) {\n cmp = cmp || function cmp (a, b) {\n if (a > b) return 1\n if (a < b) return -1\n return 0\n }\n end = (end || arr.length) - 1\n\n const stack = []\n let sp = -1\n let left = begin\n let right = end\n let tmp: number|T\n\n function swap (a: number, b: number) {\n const tmp2 = arr[ a ]\n arr[ a ] = arr[ b ]\n arr[ b ] = tmp2\n }\n\n let i, j\n\n while (true) {\n if (right - left <= 25) {\n for (let k = left + 1; k <= right; ++k) {\n tmp = arr[ k ]\n i = k - 1\n\n while (i >= left && cmp(arr[ i ], tmp) > 0) {\n arr[ i + 1 ] = arr[ i ]\n --i\n }\n\n arr[ i + 1 ] = tmp\n }\n\n if (sp === -1) break\n\n right = stack[ sp-- ] // ?\n left = stack[ sp-- ]\n } else {\n const median = (left + right) >> 1\n\n i = left + 1\n j = right\n\n swap(median, i)\n\n if (cmp(arr[ left ], arr[ right ]) > 0) {\n swap(left, right)\n }\n\n if (cmp(arr[ i ], arr[ right ]) > 0) {\n swap(i, right)\n }\n\n if (cmp(arr[ left ], arr[ i ]) > 0) {\n swap(left, i)\n }\n\n tmp = arr[ i ]\n\n while (true) {\n do i++; while (cmp(arr[ i ], tmp) < 0)\n do j--; while (cmp(arr[ j ], tmp) > 0)\n if (j < i) break\n swap(i, j)\n }\n\n arr[ left + 1 ] = arr[ j ]\n arr[ j ] = tmp\n\n if (right - i + 1 >= j - left) {\n stack[ ++sp ] = i\n stack[ ++sp ] = right\n right = j - 1\n } else {\n stack[ ++sp ] = left\n stack[ ++sp ] = j - 1\n left = i\n }\n }\n }\n\n return arr\n}\n\nexport function quickselectCmp (arr: NumberArray|T[], n: number, cmp?: (a: number|T, b: number|T) => number, left = 0, right?: number) {\n cmp = cmp || function cmp (a, b) {\n if (a > b) return 1\n if (a < b) return -1\n return 0\n }\n right = (right || arr.length) - 1\n\n let pivotIndex, pivotValue, storeIndex\n\n function swap (a: number, b: number) {\n const tmp = arr[ a ]\n arr[ a ] = arr[ b ]\n arr[ b ] = tmp\n }\n\n while (true) {\n if (left === right) {\n return arr[ left ]\n }\n pivotIndex = (left + right) >> 1\n pivotValue = arr[ pivotIndex ]\n swap(pivotIndex, right)\n storeIndex = left\n for (let i = left; i < right; ++i) {\n if (cmp(arr[ i ], pivotValue) < 0) {\n swap(storeIndex, i)\n ++storeIndex\n }\n }\n swap(right, storeIndex)\n pivotIndex = storeIndex\n if (n === pivotIndex) {\n return arr[ n ]\n } else if (n < pivotIndex) {\n right = pivotIndex - 1\n } else {\n left = pivotIndex + 1\n }\n }\n}\n\nexport function arrayMax (array: NumberArray) {\n let max = -Infinity\n for (let i = 0, il = array.length; i < il; ++i) {\n if (array[ i ] > max) max = array[ i ]\n }\n return max\n}\n\nexport function arrayMin (array: NumberArray) {\n let min = Infinity\n for (let i = 0, il = array.length; i < il; ++i) {\n if (array[ i ] < min) min = array[ i ]\n }\n return min\n}\n\nexport function arraySum (array: NumberArray, stride = 1, offset = 0) {\n const n = array.length\n let sum = 0\n for (let i = offset; i < n; i += stride) {\n sum += array[ i ]\n }\n return sum\n}\n\nexport function arrayMean (array: NumberArray, stride = 1, offset = 0) {\n return arraySum(array, stride, offset) / (array.length / stride)\n}\n\nexport function arrayRms (array: NumberArray) {\n const n = array.length\n let sumSq = 0\n for (let i = 0; i < n; ++i) {\n const di = array[ i ]\n sumSq += di * di\n }\n return Math.sqrt(sumSq / n)\n}\n\nexport function arraySorted (array: NumberArray) {\n for (let i = 1, il = array.length; i < il; ++i) {\n if (array[ i - 1 ] > array[ i ]) return false\n }\n return true\n}\n\nexport function arraySortedCmp (array: NumberArray|T[], cmp: (a: number|T, b: number|T) => number) {\n for (let i = 1, il = array.length; i < il; ++i) {\n if (cmp(array[ i - 1 ], array[ i ]) > 0) return false\n }\n return true\n}\n","/**\n * @file Viewer Utils\n * @author Alexander Rose \n * @private\n */\n\nimport {\n Vector2, Vector3, Matrix4, Points, Scene, Camera,\n Object3D, WebGLRenderer\n} from 'three'\n\nimport { createParams } from '../utils'\nimport TiledRenderer from './tiled-renderer'\nimport { quicksortCmp } from '../math/array-utils'\nimport Viewer from './viewer'\n\nfunction _trimCanvas (canvas: HTMLCanvasElement, r: number, g: number, b: number, a: number) {\n const canvasHeight = canvas.height\n const canvasWidth = canvas.width\n\n const ctx = canvas.getContext('2d')!\n const pixels = ctx.getImageData(0, 0, canvasWidth, canvasHeight).data\n\n let x, y, doBreak, off\n\n doBreak = false\n for (y = 0; y < canvasHeight; y++) {\n for (x = 0; x < canvasWidth; x++) {\n off = (y * canvasWidth + x) * 4\n if (pixels[ off ] !== r || pixels[ off + 1 ] !== g ||\n pixels[ off + 2 ] !== b || pixels[ off + 3 ] !== a\n ) {\n doBreak = true\n break\n }\n }\n if (doBreak) {\n break\n }\n }\n const topY = y\n\n doBreak = false\n for (x = 0; x < canvasWidth; x++) {\n for (y = 0; y < canvasHeight; y++) {\n off = (y * canvasWidth + x) * 4\n if (pixels[ off ] !== r || pixels[ off + 1 ] !== g ||\n pixels[ off + 2 ] !== b || pixels[ off + 3 ] !== a\n ) {\n doBreak = true\n break\n }\n }\n if (doBreak) {\n break\n }\n }\n const topX = x\n\n doBreak = false\n for (y = canvasHeight - 1; y >= 0; y--) {\n for (x = canvasWidth - 1; x >= 0; x--) {\n off = (y * canvasWidth + x) * 4\n if (pixels[ off ] !== r || pixels[ off + 1 ] !== g ||\n pixels[ off + 2 ] !== b || pixels[ off + 3 ] !== a\n ) {\n doBreak = true\n break\n }\n }\n if (doBreak) {\n break\n }\n }\n const bottomY = y\n\n doBreak = false\n for (x = canvasWidth - 1; x >= 0; x--) {\n for (y = canvasHeight - 1; y >= 0; y--) {\n off = (y * canvasWidth + x) * 4\n if (pixels[ off ] !== r || pixels[ off + 1 ] !== g ||\n pixels[ off + 2 ] !== b || pixels[ off + 3 ] !== a\n ) {\n doBreak = true\n break\n }\n }\n if (doBreak) {\n break\n }\n }\n const bottomX = x\n\n const trimedCanvas = document.createElement('canvas')\n trimedCanvas.width = bottomX - topX\n trimedCanvas.height = bottomY - topY\n\n const trimedCtx = trimedCanvas.getContext('2d')!\n trimedCtx.drawImage(\n canvas,\n topX, topY,\n trimedCanvas.width, trimedCanvas.height,\n 0, 0,\n trimedCanvas.width, trimedCanvas.height\n )\n\n return trimedCanvas\n}\n\n/**\n * Image parameter object.\n * @typedef {Object} ImageParameters - image generation parameters\n * @property {Boolean} trim - trim the image\n * @property {Integer} factor - scaling factor to apply to the viewer canvas\n * @property {Boolean} antialias - antialias the image\n * @property {Boolean} transparent - transparent image background\n */\n\nexport const ImageDefaultParameters = {\n trim: false,\n factor: 1,\n antialias: false,\n transparent: false,\n onProgress: undefined as Function|undefined\n}\nexport type ImageParameters = typeof ImageDefaultParameters\n\n/**\n * Make image from what is shown in a viewer canvas\n * @param {Viewer} viewer - the viewer\n * @param {ImageParameters} params - parameters object\n * @return {Promise} A Promise object that resolves to an image {@link Blob}.\n */\nexport function makeImage (viewer: Viewer, params: Partial = {}) {\n const {trim, factor, antialias, transparent} = createParams(params, ImageDefaultParameters)\n\n const renderer = viewer.renderer\n const camera = viewer.camera\n\n const originalClearAlpha = renderer.getClearAlpha()\n const backgroundColor = renderer.getClearColor()\n\n function setLineWidthAndPixelSize (invert = false) {\n let _factor = factor\n if (antialias) _factor *= 2\n if (invert) _factor = 1 / _factor\n viewer.scene.traverse(function (o: any) { // TODO\n const m = o.material\n if (m && m.linewidth) {\n m.linewidth *= _factor\n }\n if (m && m.uniforms && m.uniforms.size) {\n if (m.uniforms.size.__seen === undefined) {\n m.uniforms.size.value *= _factor\n m.uniforms.size.__seen = true\n }\n }\n if (m && m.uniforms && m.uniforms.linewidth) {\n if (m.uniforms.linewidth.__seen === undefined) {\n m.uniforms.linewidth.value *= _factor\n m.uniforms.linewidth.__seen = true\n }\n }\n })\n viewer.scene.traverse(function (o: any) { // TODO\n const m = o.material\n if (m && m.uniforms && m.uniforms.size) {\n delete m.uniforms.size.__seen\n }\n if (m && m.uniforms && m.uniforms.linewidth) {\n delete m.uniforms.linewidth.__seen\n }\n })\n }\n\n function trimCanvas (canvas: HTMLCanvasElement) {\n if (trim) {\n const bg = backgroundColor\n const r = transparent ? 0 : bg.r * 255\n const g = transparent ? 0 : bg.g * 255\n const b = transparent ? 0 : bg.b * 255\n const a = transparent ? 0 : 255\n return _trimCanvas(canvas, r, g, b, a)\n } else {\n return canvas\n }\n }\n\n function onProgress (i: number, n: number, finished: boolean) {\n if (typeof params.onProgress === 'function') {\n params.onProgress(i, n, finished)\n }\n }\n\n return new Promise(function (resolve, reject) {\n const tiledRenderer = new TiledRenderer(\n renderer, camera, viewer,\n { factor, antialias, onProgress, onFinish }\n )\n\n renderer.setClearAlpha(transparent ? 0 : 1)\n setLineWidthAndPixelSize()\n tiledRenderer.renderAsync()\n\n function onFinish (i: number, n: number) {\n const canvas = trimCanvas(tiledRenderer.canvas)\n canvas.toBlob(\n function (blob) {\n renderer.setClearAlpha(originalClearAlpha)\n setLineWidthAndPixelSize(true)\n viewer.requestRender()\n onProgress(n, n, true)\n if (blob) {\n resolve(blob)\n } else {\n reject('error creating image')\n }\n },\n 'image/png'\n )\n }\n })\n}\n\nconst vertex = new Vector3()\nconst matrix = new Matrix4()\nconst modelViewProjectionMatrix = new Matrix4()\n\nexport function sortProjectedPosition (scene: Scene, camera: Camera) {\n // console.time( \"sort\" );\n\n scene.traverseVisible(function (o) {\n if (!(o instanceof Points) || !o.userData.buffer.parameters.sortParticles) {\n return\n }\n\n const attributes = (o.geometry as any).attributes // TODO\n const n = attributes.position.count\n\n if (n === 0) return\n\n matrix.multiplyMatrices(\n camera.matrixWorldInverse, o.matrixWorld\n )\n modelViewProjectionMatrix.multiplyMatrices(\n camera.projectionMatrix, matrix\n )\n\n let sortData, sortArray, zArray: Float32Array, cmpFn\n\n if (!o.userData.sortData) {\n zArray = new Float32Array(n)\n sortArray = new Uint32Array(n)\n cmpFn = function (ai: number, bi: number) {\n const a = zArray[ ai ]\n const b = zArray[ bi ]\n if (a > b) return 1\n if (a < b) return -1\n return 0\n }\n\n sortData = {\n __zArray: zArray,\n __sortArray: sortArray,\n __cmpFn: cmpFn\n }\n\n o.userData.sortData = sortData\n } else {\n sortData = o.userData.sortData\n zArray = sortData.__zArray\n sortArray = sortData.__sortArray\n cmpFn = sortData.__cmpFn\n }\n\n for (let i = 0; i < n; ++i) {\n vertex.fromArray(attributes.position.array, i * 3)\n vertex.applyMatrix4(modelViewProjectionMatrix)\n\n // negate, so that sorting order is reversed\n zArray[ i ] = -vertex.z\n sortArray[ i ] = i\n }\n\n quicksortCmp(sortArray, cmpFn)\n\n let index, indexSrc, indexDst, tmpTab\n\n for (let name in attributes) {\n const attr = attributes[ name ]\n const array = attr.array\n const itemSize = attr.itemSize\n\n if (!sortData[ name ]) {\n sortData[ name ] = new Float32Array(itemSize * n)\n }\n\n tmpTab = sortData[ name ]\n sortData[ name ] = array\n\n for (let i = 0; i < n; ++i) {\n index = sortArray[ i ]\n\n for (let j = 0; j < itemSize; ++j) {\n indexSrc = index * itemSize + j\n indexDst = i * itemSize + j\n tmpTab[ indexDst ] = array[ indexSrc ]\n }\n }\n\n attributes[ name ].array = tmpTab\n attributes[ name ].needsUpdate = true\n }\n })\n\n // console.timeEnd( \"sort\" );\n}\n\nconst resolution = new Vector2()\nconst projectionMatrixInverse = new Matrix4()\nconst projectionMatrixTranspose = new Matrix4()\n\nexport function updateMaterialUniforms (group: Object3D, camera: Camera, renderer: WebGLRenderer, cDist: number, bRadius: number) {\n let size = new Vector2()\n renderer.getSize(size)\n const canvasHeight = size.height\n const pixelRatio = renderer.getPixelRatio()\n const ortho = camera.type === 'OrthographicCamera'\n\n resolution.set(size.width, size.height)\n projectionMatrixInverse.getInverse(camera.projectionMatrix)\n projectionMatrixTranspose.copy(camera.projectionMatrix).transpose()\n\n group.traverse(function (o: any) {\n const m = o.material\n if (!m) return\n\n const u = m.uniforms\n if (!u) return\n\n if (m.clipNear) {\n const nearFactor = (50 - m.clipNear) / 50\n const nearClip = cDist - (bRadius * nearFactor)\n u.clipNear.value = nearClip\n }\n\n if (u.canvasHeight) {\n u.canvasHeight.value = canvasHeight\n }\n\n if (u.resolution) {\n u.resolution.value.copy(resolution)\n }\n\n if (u.pixelRatio) {\n u.pixelRatio.value = pixelRatio\n }\n\n if (u.projectionMatrixInverse) {\n u.projectionMatrixInverse.value.copy(projectionMatrixInverse)\n }\n\n if (u.projectionMatrixTranspose) {\n u.projectionMatrixTranspose.value.copy(projectionMatrixTranspose)\n }\n\n if (u.ortho) {\n u.ortho.value = ortho\n }\n })\n}\n\nexport function updateCameraUniforms (group: Object3D, camera: Camera) {\n projectionMatrixInverse.getInverse(camera.projectionMatrix)\n projectionMatrixTranspose.copy(camera.projectionMatrix).transpose()\n\n group.traverse(function (o: any) {\n const m = o.material\n if (!m) return\n\n const u = m.uniforms\n if (!u) return\n\n if (u.projectionMatrixInverse) {\n u.projectionMatrixInverse.value.copy(projectionMatrixInverse)\n }\n\n if (u.projectionMatrixTranspose) {\n u.projectionMatrixTranspose.value.copy(projectionMatrixTranspose)\n }\n })\n}\n","/**\n * @file Viewer\n * @author Alexander Rose \n * @private\n */\n\n// adapted from https://webglfundamentals.org/webgl/resources/webgl-utils.js\n// Copyright 2012, Gregg Tavares. Modified BSD License\n\nexport function createProgram(gl: WebGLRenderingContext, shaders: WebGLShader[], attribs?: string[], locations?: number[]) {\n const program = gl.createProgram()\n if (!program) {\n console.log(`error creating WebGL program`)\n return\n }\n shaders.forEach(shader => gl.attachShader(program, shader))\n if (attribs) {\n attribs.forEach((attrib, i) => {\n gl.bindAttribLocation(program, locations ? locations[i] : i, attrib)\n })\n }\n gl.linkProgram(program);\n\n // Check the link status\n const linked = gl.getProgramParameter(program, gl.LINK_STATUS)\n if (!linked) {\n console.log(`error linking program: ${gl.getProgramInfoLog(program)}`)\n gl.deleteProgram(program)\n return null\n }\n return program\n}\n\nexport function loadShader(gl: WebGLRenderingContext, shaderSource: string, shaderType: number) {\n const shader = gl.createShader(shaderType)\n if (!shader) {\n console.log(`error creating WebGL shader ${shaderType}`)\n return // can't create shader\n }\n gl.shaderSource(shader, shaderSource)\n gl.compileShader(shader)\n\n // Check the compile status\n const compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS)\n if (!compiled) {\n console.log(`error compiling shader ${shader}: ${gl.getShaderInfoLog(shader)}`)\n gl.deleteShader(shader)\n return null\n }\n\n return shader\n}\n\n//\n\nexport function getErrorDescription(gl: WebGLRenderingContext, error: number) {\n switch (error) {\n case gl.NO_ERROR: return 'no error'\n case gl.INVALID_ENUM: return 'invalid enum'\n case gl.INVALID_VALUE: return 'invalid value'\n case gl.INVALID_OPERATION: return 'invalid operation'\n case gl.INVALID_FRAMEBUFFER_OPERATION: return 'invalid framebuffer operation'\n case gl.OUT_OF_MEMORY: return 'out of memory'\n case gl.CONTEXT_LOST_WEBGL: return 'context lost'\n }\n return 'unknown error'\n}\n\nexport function getExtension (gl: WebGLRenderingContext, name: string) {\n const ext = gl.getExtension(name)\n if (!ext) console.log(`extension '${name}' not available`)\n return ext\n}\n\nconst TextureTestVertShader = `\nattribute vec4 a_position;\n\nvoid main() {\n gl_Position = a_position;\n}`\n\nconst TextureTestFragShader = `\nprecision mediump float;\nuniform vec4 u_color;\nuniform sampler2D u_texture;\n\nvoid main() {\n gl_FragColor = texture2D(u_texture, vec2(0.5, 0.5)) * u_color;\n}`\n\nconst TextureTestTexCoords = new Float32Array([\n -1.0, -1.0, 1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0\n])\n\nexport function testTextureSupport (type: number) {\n // adapted from\n // https://stackoverflow.com/questions/28827511/webgl-ios-render-to-floating-point-texture\n\n // Get A WebGL context\n const canvas = document.createElement('canvas')\n canvas.width = 16\n canvas.height = 16\n canvas.style.width = 16 + 'px'\n canvas.style.height = 16 + 'px'\n const gl = canvas.getContext(\"webgl\") || canvas.getContext(\"experimental-webgl\");\n if (!gl) {\n console.log(`error creating webgl context for ${type}`)\n return false\n }\n if (!(gl instanceof WebGLRenderingContext)) {\n console.log(`Got unexpected type for WebGL rendering context`)\n return false\n }\n\n getExtension(gl, 'OES_texture_float')\n getExtension(gl, 'OES_texture_half_float')\n getExtension(gl, 'WEBGL_color_buffer_float')\n\n // setup shaders\n const vertShader = loadShader(gl, TextureTestVertShader, gl.VERTEX_SHADER)\n const fragShader = loadShader(gl, TextureTestFragShader, gl.FRAGMENT_SHADER)\n if (!vertShader || !fragShader) return false\n\n // setup program\n const program = createProgram(gl, [ vertShader, fragShader ])\n if (!program) {\n console.log(`error creating WebGL program`)\n return false\n }\n gl.useProgram(program);\n\n // look up where the vertex data needs to go.\n const positionLocation = gl.getAttribLocation(program, \"a_position\");\n const colorLoc = gl.getUniformLocation(program, \"u_color\");\n if (!colorLoc) {\n console.log(`error getting 'u_color' uniform location`)\n return false\n }\n\n // provide texture coordinates for the rectangle.\n const positionBuffer = gl.createBuffer()\n gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer)\n gl.bufferData(gl.ARRAY_BUFFER, TextureTestTexCoords, gl.STATIC_DRAW)\n gl.enableVertexAttribArray(positionLocation)\n gl.vertexAttribPointer(positionLocation, 2, gl.FLOAT, false, 0, 0)\n\n const whiteTex = gl.createTexture()\n const whiteData = new Uint8Array([255, 255, 255, 255])\n gl.bindTexture(gl.TEXTURE_2D, whiteTex)\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, whiteData)\n\n const tex = gl.createTexture()\n gl.bindTexture(gl.TEXTURE_2D, tex)\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, type, null)\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST)\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST)\n\n const fb = gl.createFramebuffer()\n gl.bindFramebuffer(gl.FRAMEBUFFER, fb)\n gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, tex, 0)\n const status = gl.checkFramebufferStatus(gl.FRAMEBUFFER)\n if (status !== gl.FRAMEBUFFER_COMPLETE) {\n console.log(`error creating framebuffer for ${type}`)\n return false\n }\n\n // Draw the rectangle.\n gl.bindTexture(gl.TEXTURE_2D, whiteTex)\n gl.uniform4fv(colorLoc, [0, 10, 20, 1])\n gl.drawArrays(gl.TRIANGLES, 0, 6)\n\n gl.bindTexture(gl.TEXTURE_2D, tex)\n gl.bindFramebuffer(gl.FRAMEBUFFER, null)\n gl.clearColor(1, 0, 0, 1)\n gl.clear(gl.COLOR_BUFFER_BIT)\n gl.uniform4fv(colorLoc, [0, 1/10, 1/20, 1])\n gl.drawArrays(gl.TRIANGLES, 0, 6)\n\n // Check if rendered correctly\n const pixel = new Uint8Array(4)\n gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, pixel)\n if (pixel[0] !== 0 || pixel[1] < 248 || pixel[2] < 248 || pixel[3] < 254) {\n console.log(`not able to actually render to ${type} texture`)\n return false\n }\n\n // Check reading from float texture\n if (type === gl.FLOAT) {\n gl.bindFramebuffer(gl.FRAMEBUFFER, fb)\n const floatPixel = new Float32Array(4)\n gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.FLOAT, floatPixel)\n const error = gl.getError()\n if (error) {\n console.log(`error reading pixels as float: '${getErrorDescription(gl, error)}'`)\n return false\n }\n }\n\n return true\n}\n","/**\n * @file Viewer\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\nimport {\n PerspectiveCamera, OrthographicCamera, StereoCamera,\n Vector2, Box3, Vector3, Matrix4, Color,\n WebGLRenderer, WebGLRenderTarget,\n NearestFilter, LinearFilter, AdditiveBlending,\n RGBAFormat, FloatType, /*HalfFloatType, */UnsignedByteType,\n ShaderMaterial,\n PlaneGeometry, Geometry,\n Scene, Mesh, Group, Object3D, Uniform,\n Fog, SpotLight, AmbientLight,\n BufferGeometry, BufferAttribute,\n LineSegments,\n LinearEncoding, sRGBEncoding, TextureEncoding\n} from 'three'\nimport '../shader/BasicLine.vert'\nimport '../shader/BasicLine.frag'\nimport '../shader/Quad.vert'\nimport '../shader/Quad.frag'\n\nimport {\n Debug, Log, WebglErrorMessage, Browser,\n setExtensionFragDepth, SupportsReadPixelsFloat, setSupportsReadPixelsFloat\n} from '../globals'\nimport { degToRad } from '../math/math-utils'\nimport Stats from './stats'\nimport { getShader } from '../shader/shader-utils'\nimport { setColorSpace } from '../color/colormaker'\nimport { JitterVectors } from './viewer-constants'\nimport {\n makeImage, ImageParameters,\n sortProjectedPosition, updateMaterialUniforms, updateCameraUniforms\n} from './viewer-utils'\nimport { testTextureSupport } from './gl-utils'\n\nimport Buffer from '../buffer/buffer'\n\nconst pixelBufferFloat = new Float32Array(4 * 25)\nconst pixelBufferUint = new Uint8Array(4 * 25)\n\n// When picking, we read a 25 pixel (5x5) array (readRenderTargetPixels)\n// We read the pixels in the order below to find what was picked.\n// This starts at the center and tries successively further points.\n// (Many points will be at equal distance to the center, their order\n// is arbitrary).\nconst pixelOrder = [12,7,13,17,11,6,8,18,16,2,14,22,10,1,3,9,19,23,21,15,5,0,4,24,20]\n\n\nconst tmpMatrix = new Matrix4()\n\nfunction onBeforeRender (this: Object3D, renderer: WebGLRenderer, scene: Scene, camera: PerspectiveCamera|OrthographicCamera, geometry: Geometry, material: ShaderMaterial/*, group */) {\n const u = material.uniforms\n const updateList = []\n\n if (!u) return // See #908 - some materials may not have uniforms, ignore these\n\n if (u.objectId) {\n u.objectId.value = SupportsReadPixelsFloat ? this.id : this.id / 255\n updateList.push('objectId')\n }\n\n if (u.modelViewMatrixInverse || u.modelViewMatrixInverseTranspose ||\n u.modelViewProjectionMatrix || u.modelViewProjectionMatrixInverse\n ) {\n this.modelViewMatrix.multiplyMatrices(camera.matrixWorldInverse, this.matrixWorld)\n }\n\n if (u.modelViewMatrixInverse) {\n u.modelViewMatrixInverse.value.getInverse(this.modelViewMatrix)\n updateList.push('modelViewMatrixInverse')\n }\n\n if (u.modelViewMatrixInverseTranspose) {\n if (u.modelViewMatrixInverse) {\n u.modelViewMatrixInverseTranspose.value.copy(\n u.modelViewMatrixInverse.value\n ).transpose()\n } else {\n u.modelViewMatrixInverseTranspose.value\n .getInverse(this.modelViewMatrix)\n .transpose()\n }\n updateList.push('modelViewMatrixInverseTranspose')\n }\n\n if (u.modelViewProjectionMatrix) {\n u.modelViewProjectionMatrix.value.multiplyMatrices(\n camera.projectionMatrix, this.modelViewMatrix\n )\n updateList.push('modelViewProjectionMatrix')\n }\n\n if (u.modelViewProjectionMatrixInverse) {\n if (u.modelViewProjectionMatrix) {\n tmpMatrix.copy(\n u.modelViewProjectionMatrix.value\n )\n u.modelViewProjectionMatrixInverse.value.getInverse(\n tmpMatrix\n )\n } else {\n tmpMatrix.multiplyMatrices(\n camera.projectionMatrix, this.modelViewMatrix\n )\n u.modelViewProjectionMatrixInverse.value.getInverse(\n tmpMatrix\n )\n }\n updateList.push('modelViewProjectionMatrixInverse')\n }\n\n if (updateList.length) {\n const materialProperties = renderer.properties.get(material)\n\n if (materialProperties.program) {\n const gl = renderer.getContext()\n const p = materialProperties.program\n gl.useProgram(p.program)\n const pu = p.getUniforms()\n\n updateList.forEach(function (name) {\n pu.setValue(gl, name, u[ name ].value)\n })\n }\n }\n}\n\nexport type CameraType = 'perspective'|'orthographic'|'stereo'\nexport type ColorWorkflow = 'linear' | 'sRGB'\n\nexport interface ViewerSignals {\n ticked: Signal,\n rendered: Signal\n}\n\nexport interface ViewerParameters {\n fogColor: Color\n fogNear: number\n fogFar: number\n\n backgroundColor: Color\n\n cameraType: CameraType\n cameraFov: number\n cameraEyeSep: number\n cameraZ: number\n\n clipNear: number\n clipFar: number\n clipDist: number\n clipMode: string // \"scene\" or \"camera\"\n clipScale: string // \"relative\" or \"absolute\"\n\n lightColor: Color\n lightIntensity: number\n ambientColor: Color\n ambientIntensity: number\n\n sampleLevel: number\n\n rendererEncoding: TextureEncoding // default is three.LinearEncoding; three.sRGBEncoding gives more correct results\n}\n\nexport interface BufferInstance {\n matrix: Matrix4\n}\n\n/**\n * Viewer class\n * @class\n * @param {String|Element} [idOrElement] - dom id or element\n */\nexport default class Viewer {\n signals: ViewerSignals\n\n container: HTMLElement\n wrapper: HTMLElement\n\n private rendering: boolean\n private renderPending: boolean\n private lastRenderedPicking: boolean\n private isStill: boolean\n private frameRequest: number\n\n sampleLevel: number\n private cDist: number\n private bRadius: number\n\n private parameters: ViewerParameters\n stats: Stats\n\n perspectiveCamera: PerspectiveCamera\n private orthographicCamera: OrthographicCamera\n private stereoCamera: StereoCamera\n camera: PerspectiveCamera|OrthographicCamera\n\n width: number\n height: number\n\n scene: Scene\n private spotLight: SpotLight\n private ambientLight: AmbientLight\n rotationGroup: Group\n translationGroup: Group\n private modelGroup: Group\n private pickingGroup: Group\n private backgroundGroup: Group\n private helperGroup: Group\n\n renderer: WebGLRenderer\n private supportsHalfFloat: boolean\n\n private pickingTarget: WebGLRenderTarget\n private sampleTarget: WebGLRenderTarget\n private holdTarget: WebGLRenderTarget\n\n private compositeUniforms: {\n tForeground: Uniform\n scale: Uniform\n }\n private compositeMaterial: ShaderMaterial\n private compositeCamera: OrthographicCamera\n private compositeScene: Scene\n\n private boundingBoxMesh: LineSegments\n boundingBox = new Box3()\n private boundingBoxSize = new Vector3()\n private boundingBoxLength = 0\n\n private info = {\n memory: {\n programs: 0,\n geometries: 0,\n textures: 0\n },\n render: {\n calls: 0,\n vertices: 0,\n faces: 0,\n points: 0\n }\n }\n\n private distVector = new Vector3()\n\n constructor (idOrElement: string|HTMLElement) {\n this.signals = {\n ticked: new Signal(),\n rendered: new Signal()\n }\n\n if (typeof idOrElement === 'string') {\n const elm = document.getElementById(idOrElement)\n if (elm === null) {\n this.container = document.createElement('div')\n }else {\n this.container = elm\n }\n } else if (idOrElement instanceof HTMLElement) {\n this.container = idOrElement\n } else {\n this.container = document.createElement('div')\n }\n\n if (this.container === document.body) {\n this.width = window.innerWidth || 1\n this.height = window.innerHeight || 1\n } else {\n const box = this.container.getBoundingClientRect()\n this.width = box.width || 1\n this.height = box.height || 1\n this.container.style.overflow = 'hidden'\n }\n\n this.wrapper = document.createElement('div')\n this.wrapper.style.position = 'relative'\n this.container.appendChild(this.wrapper)\n\n this._initParams()\n this._initStats()\n this._initCamera()\n this._initScene()\n\n if (this._initRenderer() === false) {\n Log.error('Viewer: could not initialize renderer')\n return\n }\n\n this._initHelper()\n\n // fog & background\n this.setBackground()\n this.setFog()\n\n this.animate = this.animate.bind(this)\n }\n\n private _initParams () {\n this.parameters = {\n fogColor: new Color(0x000000),\n fogNear: 50,\n fogFar: 100,\n\n backgroundColor: new Color(0x000000),\n\n cameraType: 'perspective',\n cameraFov: 40,\n cameraEyeSep: 0.3,\n cameraZ: -80, // FIXME initial value should be automatically determined\n\n clipNear: 0,\n clipFar: 100,\n clipDist: 10,\n clipMode: 'scene',\n clipScale: 'relative',\n\n lightColor: new Color(0xdddddd),\n lightIntensity: 1.0,\n ambientColor: new Color(0xdddddd),\n ambientIntensity: 0.2,\n\n sampleLevel: 0,\n\n // output encoding: use sRGB for a linear internal workflow, linear for traditional sRGB workflow.\n rendererEncoding: LinearEncoding,\n }\n }\n\n private _initCamera () {\n const lookAt = new Vector3(0, 0, 0)\n const {width, height} = this\n\n this.perspectiveCamera = new PerspectiveCamera(\n this.parameters.cameraFov, width / height\n )\n this.perspectiveCamera.position.z = this.parameters.cameraZ\n this.perspectiveCamera.lookAt(lookAt)\n\n this.orthographicCamera = new OrthographicCamera(\n width / -2, width / 2, height / 2, height / -2\n )\n this.orthographicCamera.position.z = this.parameters.cameraZ\n this.orthographicCamera.lookAt(lookAt)\n\n this.stereoCamera = new StereoCamera()\n this.stereoCamera.aspect = 0.5\n this.stereoCamera.eyeSep = this.parameters.cameraEyeSep\n\n const cameraType = this.parameters.cameraType\n if (cameraType === 'orthographic') {\n this.camera = this.orthographicCamera\n } else if(cameraType === 'perspective' || cameraType === 'stereo') {\n this.camera = this.perspectiveCamera\n } else {\n throw new Error(`Unknown cameraType '${cameraType}'`)\n }\n this.camera.updateProjectionMatrix()\n }\n\n private _initStats () {\n this.stats = new Stats()\n }\n\n private _initScene () {\n if (!this.scene) {\n this.scene = new Scene()\n this.scene.name = 'scene'\n }\n\n this.rotationGroup = new Group()\n this.rotationGroup.name = 'rotationGroup'\n this.scene.add(this.rotationGroup)\n\n this.translationGroup = new Group()\n this.translationGroup.name = 'translationGroup'\n this.rotationGroup.add(this.translationGroup)\n\n this.modelGroup = new Group()\n this.modelGroup.name = 'modelGroup'\n this.translationGroup.add(this.modelGroup)\n\n this.pickingGroup = new Group()\n this.pickingGroup.name = 'pickingGroup'\n this.translationGroup.add(this.pickingGroup)\n\n this.backgroundGroup = new Group()\n this.backgroundGroup.name = 'backgroundGroup'\n this.translationGroup.add(this.backgroundGroup)\n\n this.helperGroup = new Group()\n this.helperGroup.name = 'helperGroup'\n this.translationGroup.add(this.helperGroup)\n\n // fog\n\n this.scene.fog = new Fog(this.parameters.fogColor.getHex())\n\n // light\n\n this.spotLight = new SpotLight(\n this.parameters.lightColor.getHex(), this.parameters.lightIntensity\n )\n this.scene.add(this.spotLight)\n\n this.ambientLight = new AmbientLight(\n this.parameters.ambientColor.getHex(), this.parameters.ambientIntensity\n )\n this.scene.add(this.ambientLight)\n }\n\n private _initRenderer () {\n const dpr = window.devicePixelRatio\n const {width, height} = this\n\n try {\n this.renderer = new WebGLRenderer({\n preserveDrawingBuffer: true,\n alpha: true,\n antialias: true\n })\n } catch (e) {\n this.wrapper.innerHTML = WebglErrorMessage\n return false\n }\n this.renderer.setPixelRatio(dpr)\n this.renderer.setSize(width, height)\n this.renderer.autoClear = false\n this.renderer.sortObjects = true\n this.renderer.outputEncoding = this.parameters.rendererEncoding\n\n const gl = this.renderer.getContext()\n // console.log(gl.getContextAttributes().antialias)\n // console.log(gl.getParameter(gl.SAMPLES))\n\n // For WebGL1, extensions must be explicitly enabled.\n // The following are builtin to WebGL2 (and don't appear as\n // extensions)\n // EXT_frag_depth, OES_element_index_uint, OES_texture_float\n // OES_texture_half_float\n\n // The WEBGL_color_buffer_float extension is replaced by\n // EXT_color_buffer_float\n\n // If not webgl2 context, explicitly check for these\n if (!this.renderer.capabilities.isWebGL2) {\n setExtensionFragDepth(this.renderer.extensions.get('EXT_frag_depth'))\n this.renderer.extensions.get('OES_element_index_uint')\n\n setSupportsReadPixelsFloat(\n (this.renderer.extensions.get('OES_texture_float') &&\n this.renderer.extensions.get('WEBGL_color_buffer_float')) ||\n (this.renderer.extensions.get('OES_texture_float') &&\n testTextureSupport(gl.FLOAT))\n )\n // picking texture\n\n this.renderer.extensions.get('OES_texture_float')\n\n this.supportsHalfFloat = (\n this.renderer.extensions.get('OES_texture_half_float') &&\n testTextureSupport(0x8D61)\n )\n\n } else {\n setExtensionFragDepth(true)\n setSupportsReadPixelsFloat(\n this.renderer.extensions.get('EXT_color_buffer_float')\n )\n this.supportsHalfFloat = true\n }\n\n this.wrapper.appendChild(this.renderer.domElement)\n\n const dprWidth = width * dpr\n const dprHeight = height * dpr\n\n\n if (Debug) {\n console.log(JSON.stringify({\n 'Browser': Browser,\n 'OES_texture_float': !!this.renderer.extensions.get('OES_texture_float'),\n 'OES_texture_half_float': !!this.renderer.extensions.get('OES_texture_half_float'),\n 'WEBGL_color_buffer_float': !!this.renderer.extensions.get('WEBGL_color_buffer_float'),\n 'testTextureSupport Float': testTextureSupport(gl.FLOAT),\n 'testTextureSupport HalfFloat': testTextureSupport(0x8D61),\n 'this.supportsHalfFloat': this.supportsHalfFloat,\n 'SupportsReadPixelsFloat': SupportsReadPixelsFloat\n }, null, 2))\n }\n\n this.pickingTarget = new WebGLRenderTarget(\n dprWidth, dprHeight,\n {\n minFilter: NearestFilter,\n magFilter: NearestFilter,\n stencilBuffer: false,\n format: RGBAFormat,\n type: SupportsReadPixelsFloat ? FloatType : UnsignedByteType\n }\n )\n this.pickingTarget.texture.generateMipmaps = false\n this.pickingTarget.texture.encoding = this.parameters.rendererEncoding\n\n // workaround to reset the gl state after using testTextureSupport\n // fixes some bug where nothing is rendered to the canvas\n // when animations are started on page load\n this.renderer.setRenderTarget(this.pickingTarget)\n this.renderer.clear()\n this.renderer.setRenderTarget(null!)\n\n // ssaa textures\n\n this.sampleTarget = new WebGLRenderTarget(\n dprWidth, dprHeight,\n {\n minFilter: LinearFilter,\n magFilter: LinearFilter,\n format: RGBAFormat\n }\n )\n this.sampleTarget.texture.encoding = this.parameters.rendererEncoding\n\n this.holdTarget = new WebGLRenderTarget(\n dprWidth, dprHeight,\n {\n minFilter: NearestFilter,\n magFilter: NearestFilter,\n format: RGBAFormat,\n type: UnsignedByteType\n // using HalfFloatType or FloatType does not work on some Chrome 61 installations\n // type: this.supportsHalfFloat ? HalfFloatType : (\n // SupportsReadPixelsFloat ? FloatType : UnsignedByteType\n // )\n }\n )\n this.holdTarget.texture.encoding = this.parameters.rendererEncoding\n\n this.compositeUniforms = {\n 'tForeground': new Uniform(this.sampleTarget.texture),\n 'scale': new Uniform(1.0)\n }\n\n this.compositeMaterial = new ShaderMaterial({\n uniforms: this.compositeUniforms,\n vertexShader: getShader('Quad.vert'),\n fragmentShader: getShader('Quad.frag'),\n premultipliedAlpha: true,\n transparent: true,\n blending: AdditiveBlending,\n depthTest: false,\n depthWrite: false\n })\n\n this.compositeCamera = new OrthographicCamera(-1, 1, 1, -1, 0, 1)\n this.compositeScene = new Scene()\n this.compositeScene.name = 'compositeScene'\n this.compositeScene.add(new Mesh(\n new PlaneGeometry(2, 2), this.compositeMaterial\n ))\n }\n\n private _initHelper () {\n const indices = new Uint16Array([\n 0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6,\n 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7\n ])\n const positions = new Float32Array(8 * 3)\n\n const bbGeometry = new BufferGeometry()\n bbGeometry.setIndex(new BufferAttribute(indices, 1))\n bbGeometry.setAttribute('position', new BufferAttribute(positions, 3))\n const bbMaterial = new ShaderMaterial({\n uniforms: { 'uColor': { value: new Color('skyblue') } },\n vertexShader: getShader('BasicLine.vert'),\n fragmentShader: getShader('BasicLine.frag')\n })\n\n this.boundingBoxMesh = new LineSegments(bbGeometry, bbMaterial)\n this.helperGroup.add(this.boundingBoxMesh)\n }\n\n updateHelper () {\n const position = ((this.boundingBoxMesh.geometry as BufferGeometry).attributes as any).position // TODO\n const array = position.array\n const {min, max} = this.boundingBox\n\n array[ 0 ] = max.x; array[ 1 ] = max.y; array[ 2 ] = max.z\n array[ 3 ] = min.x; array[ 4 ] = max.y; array[ 5 ] = max.z\n array[ 6 ] = min.x; array[ 7 ] = min.y; array[ 8 ] = max.z\n array[ 9 ] = max.x; array[ 10 ] = min.y; array[ 11 ] = max.z\n array[ 12 ] = max.x; array[ 13 ] = max.y; array[ 14 ] = min.z\n array[ 15 ] = min.x; array[ 16 ] = max.y; array[ 17 ] = min.z\n array[ 18 ] = min.x; array[ 19 ] = min.y; array[ 20 ] = min.z\n array[ 21 ] = max.x; array[ 22 ] = min.y; array[ 23 ] = min.z\n\n position.needsUpdate = true\n\n if (!this.boundingBox.isEmpty()) {\n this.boundingBoxMesh.geometry.computeBoundingSphere()\n }\n }\n\n /** Distance from origin (lookAt point) */\n get cameraDistance(): number {\n return Math.abs(this.camera.position.z)\n }\n\n /** Set distance from origin (lookAt point); along the -z axis */\n set cameraDistance(d: number) {\n this.camera.position.z = -d\n }\n\n add (buffer: Buffer, instanceList?: BufferInstance[]) {\n // Log.time( \"Viewer.add\" );\n\n if (instanceList) {\n instanceList.forEach(instance => this.addBuffer(buffer, instance))\n } else {\n this.addBuffer(buffer)\n }\n\n buffer.group.name = 'meshGroup'\n buffer.wireframeGroup.name = 'wireframeGroup'\n if (buffer.parameters.background) {\n this.backgroundGroup.add(buffer.group)\n this.backgroundGroup.add(buffer.wireframeGroup)\n } else {\n this.modelGroup.add(buffer.group)\n this.modelGroup.add(buffer.wireframeGroup)\n }\n\n if (buffer.pickable) {\n this.pickingGroup.add(buffer.pickingGroup)\n }\n\n if (Debug) this.updateHelper()\n\n // Log.timeEnd( \"Viewer.add\" );\n }\n\n addBuffer (buffer: Buffer, instance?: BufferInstance) {\n // Log.time( \"Viewer.addBuffer\" );\n\n function setUserData (object: Object3D) {\n if (object instanceof Group) {\n object.children.forEach(setUserData)\n } else {\n object.userData.buffer = buffer\n object.userData.instance = instance\n object.onBeforeRender = onBeforeRender\n }\n }\n\n const mesh = buffer.getMesh()\n if (instance) {\n mesh.applyMatrix4(instance.matrix)\n }\n setUserData(mesh)\n buffer.group.add(mesh)\n\n const wireframeMesh = buffer.getWireframeMesh()\n if (instance) {\n // wireframeMesh.applyMatrix( instance.matrix );\n wireframeMesh.matrix.copy(mesh.matrix)\n wireframeMesh.position.copy(mesh.position)\n wireframeMesh.quaternion.copy(mesh.quaternion)\n wireframeMesh.scale.copy(mesh.scale)\n }\n setUserData(wireframeMesh)\n buffer.wireframeGroup.add(wireframeMesh)\n\n if (buffer.pickable) {\n const pickingMesh = buffer.getPickingMesh()\n if (instance) {\n // pickingMesh.applyMatrix( instance.matrix );\n pickingMesh.matrix.copy(mesh.matrix)\n pickingMesh.position.copy(mesh.position)\n pickingMesh.quaternion.copy(mesh.quaternion)\n pickingMesh.scale.copy(mesh.scale)\n }\n setUserData(pickingMesh)\n buffer.pickingGroup.add(pickingMesh)\n }\n\n if (instance) {\n this._updateBoundingBox(buffer.geometry, buffer.matrix, instance.matrix)\n } else {\n this._updateBoundingBox(buffer.geometry, buffer.matrix)\n }\n\n // Log.timeEnd( \"Viewer.addBuffer\" );\n }\n\n remove (buffer: Buffer) {\n this.translationGroup.children.forEach(function (group) {\n group.remove(buffer.group)\n group.remove(buffer.wireframeGroup)\n })\n\n if (buffer.pickable) {\n this.pickingGroup.remove(buffer.pickingGroup)\n }\n\n this.updateBoundingBox()\n if (Debug) this.updateHelper()\n\n // this.requestRender();\n }\n\n private _updateBoundingBox (geometry?: BufferGeometry, matrix?: Matrix4, instanceMatrix?: Matrix4) {\n const boundingBox = this.boundingBox\n\n function updateGeometry (geometry: BufferGeometry, matrix?: Matrix4, instanceMatrix?: Matrix4) {\n if (geometry.boundingBox == null) {\n geometry.computeBoundingBox()\n }\n\n const geoBoundingBox = (geometry.boundingBox as Box3).clone()\n\n if (matrix) {\n geoBoundingBox.applyMatrix4(matrix)\n }\n if (instanceMatrix) {\n geoBoundingBox.applyMatrix4(instanceMatrix)\n }\n\n if (geoBoundingBox.min.equals(geoBoundingBox.max)) {\n // mainly to give a single impostor geometry some volume\n // as it is only expanded in the shader on the GPU\n geoBoundingBox.expandByScalar(5)\n }\n\n boundingBox.union(geoBoundingBox)\n }\n\n function updateNode (node: Mesh) {\n if (node.geometry !== undefined) {\n let matrix, instanceMatrix\n if (node.userData.buffer) {\n matrix = node.userData.buffer.matrix\n }\n if (node.userData.instance) {\n instanceMatrix = node.userData.instance.matrix\n }\n updateGeometry(node.geometry as BufferGeometry, matrix, instanceMatrix) // TODO\n }\n }\n\n if (geometry) {\n updateGeometry(geometry, matrix, instanceMatrix)\n } else {\n boundingBox.makeEmpty()\n this.modelGroup.traverse(updateNode)\n this.backgroundGroup.traverse(updateNode)\n }\n\n boundingBox.getSize(this.boundingBoxSize)\n this.boundingBoxLength = this.boundingBoxSize.length()\n }\n\n updateBoundingBox () {\n this._updateBoundingBox()\n if (Debug) this.updateHelper()\n }\n\n getPickingPixels () {\n const {width, height} = this\n\n const n = width * height * 4\n const imgBuffer = SupportsReadPixelsFloat ? new Float32Array(n) : new Uint8Array(n)\n\n this.render(true)\n this.renderer.readRenderTargetPixels(\n this.pickingTarget, 0, 0, width, height, imgBuffer\n )\n\n return imgBuffer\n }\n\n getImage (picking: boolean) {\n return new Promise(resolve => {\n if (picking) {\n const {width, height} = this\n const n = width * height * 4\n let imgBuffer = this.getPickingPixels()\n\n if (SupportsReadPixelsFloat) {\n const imgBuffer2 = new Uint8Array(n)\n for (let i = 0; i < n; ++i) {\n imgBuffer2[ i ] = Math.round(imgBuffer[ i ] * 255)\n }\n imgBuffer = imgBuffer2\n }\n\n const canvas = document.createElement('canvas')\n canvas.width = width\n canvas.height = height\n const ctx = canvas.getContext('2d')! // TODO\n const imgData = ctx.getImageData(0, 0, width, height)\n imgData.data.set(imgBuffer as any) // TODO\n ctx.putImageData(imgData, 0, 0)\n canvas.toBlob(resolve as any, 'image/png') // TODO\n } else {\n this.renderer.domElement.toBlob(resolve as any, 'image/png') // TODO\n }\n })\n }\n\n makeImage (params: Partial = {}) {\n return makeImage(this, params)\n }\n\n setLight (color: Color|number|string, intensity: number, ambientColor: Color|number|string, ambientIntensity: number) {\n const p = this.parameters\n\n if (color !== undefined) p.lightColor.set(color as string) // TODO\n if (intensity !== undefined) p.lightIntensity = intensity\n if (ambientColor !== undefined) p.ambientColor.set(ambientColor as string) // TODO\n if (ambientIntensity !== undefined) p.ambientIntensity = ambientIntensity\n\n this.requestRender()\n }\n\n setFog (color?: Color|number|string, near?: number, far?: number) {\n const p = this.parameters\n\n if (color !== undefined) p.fogColor.set(color as string) // TODO\n if (near !== undefined) p.fogNear = near\n if (far !== undefined) p.fogFar = far\n\n this.requestRender()\n }\n\n setBackground (color?: Color|number|string) {\n const p = this.parameters\n\n if (color) p.backgroundColor.set(color as string) // TODO\n\n this.setFog(p.backgroundColor)\n this.renderer.setClearColor(p.backgroundColor, 0)\n this.renderer.domElement.style.backgroundColor = p.backgroundColor.getStyle()\n\n this.requestRender()\n }\n\n setSampling (level: number) {\n if (level !== undefined) {\n this.parameters.sampleLevel = level\n this.sampleLevel = level\n }\n\n this.requestRender()\n }\n\n /**\n * Set the output color encoding, i.e. how the renderer translates\n * colorspaces as it renders to the screen.\n\n * The default is LinearEncoding, because the internals of NGL are\n * already sRGB so no translation is needed to show sRGB colors.\n * Set to sRGBEncoding to create a linear workflow, and also call\n * `setColorEncoding(LinearEncoding)` to linearize colors on input.\n * @see setColorEncoding\n */\n private setOutputEncoding (encoding: TextureEncoding) {\n this.parameters.rendererEncoding = encoding\n this.renderer.outputEncoding = encoding\n this.pickingTarget.texture.encoding = encoding\n this.sampleTarget.texture.encoding = encoding\n this.holdTarget.texture.encoding = encoding\n }\n\n /**\n * Set the internal color workflow, linear or sRGB.\n * sRGB, the default, is more \"vibrant\" at the cost of accuracy.\n * Linear gives more accurate results, especially for transparent objects.\n * In all cases, the output is always sRGB; this just affects how colors are computed internally.\n * Call this just after creating the viewer, before loading any models.\n */\n setColorWorkflow (encoding: ColorWorkflow) {\n if (encoding != 'linear' && encoding != 'sRGB')\n throw new Error(`setColorWorkflow: invalid color workflow ${encoding}`)\n setColorSpace(encoding == 'linear' ? 'linear' : 'sRGB')\n this.setOutputEncoding(encoding == 'linear' ? sRGBEncoding : LinearEncoding)\n // Note: this doesn't rebuild models, so existing geometry will have\n // the old color encoding.\n this.requestRender()\n }\n\n setCamera (type: CameraType, fov?: number, eyeSep?: number) {\n const p = this.parameters\n\n if (type) p.cameraType = type\n if (fov) p.cameraFov = fov\n if (eyeSep) p.cameraEyeSep = eyeSep\n\n if (p.cameraType === 'orthographic') {\n if (this.camera !== this.orthographicCamera) {\n this.camera = this.orthographicCamera\n this.camera.position.copy(this.perspectiveCamera.position)\n this.camera.up.copy(this.perspectiveCamera.up)\n this.updateZoom()\n }\n } else if (p.cameraType === 'perspective' || p.cameraType === 'stereo') {\n if (this.camera !== this.perspectiveCamera) {\n this.camera = this.perspectiveCamera\n this.camera.position.copy(this.orthographicCamera.position)\n this.camera.up.copy(this.orthographicCamera.up)\n }\n } else {\n throw new Error(`Unknown cameraType '${p.cameraType}'`)\n }\n\n this.perspectiveCamera.fov = p.cameraFov\n this.stereoCamera.eyeSep = p.cameraEyeSep\n this.camera.updateProjectionMatrix()\n\n this.requestRender()\n }\n\n setClip (near: number, far: number, dist: number, clipMode?: string, clipScale?: string) {\n const p = this.parameters\n\n if (near !== undefined) p.clipNear = near\n if (far !== undefined) p.clipFar = far\n if (dist !== undefined) p.clipDist = dist\n if (clipMode !== undefined) p.clipMode = clipMode\n if (clipScale !== undefined) p.clipScale = clipScale\n\n this.requestRender()\n }\n\n setSize (width: number, height: number) {\n this.width = width || 1\n this.height = height || 1\n\n this.perspectiveCamera.aspect = this.width / this.height\n this.orthographicCamera.left = -this.width / 2\n this.orthographicCamera.right = this.width / 2\n this.orthographicCamera.top = this.height / 2\n this.orthographicCamera.bottom = -this.height / 2\n this.camera.updateProjectionMatrix()\n\n const dpr = window.devicePixelRatio\n\n this.renderer.setPixelRatio(dpr)\n this.renderer.setSize(width, height)\n\n const dprWidth = this.width * dpr\n const dprHeight = this.height * dpr\n\n this.pickingTarget.setSize(dprWidth, dprHeight)\n this.sampleTarget.setSize(dprWidth, dprHeight)\n this.holdTarget.setSize(dprWidth, dprHeight)\n\n this.requestRender()\n }\n\n handleResize () {\n if (this.container === document.body) {\n this.setSize(window.innerWidth, window.innerHeight)\n } else {\n const box = this.container.getBoundingClientRect()\n this.setSize(box.width, box.height)\n }\n }\n\n updateInfo (reset?: boolean) {\n const { memory, render } = this.info\n\n if (reset) {\n memory.programs = 0\n memory.geometries = 0\n memory.textures = 0\n\n render.calls = 0\n render.vertices = 0\n render.points = 0\n } else {\n const rInfo = this.renderer.info\n const rMemory = rInfo.memory\n const rRender = rInfo.render\n\n memory.geometries = rMemory.geometries\n memory.textures = rMemory.textures\n\n render.calls += rRender.calls\n render.faces += rRender.triangles\n render.points += rRender.points\n }\n }\n\n animate () {\n this.signals.ticked.dispatch(this.stats)\n const delta = window.performance.now() - this.stats.startTime\n\n if (delta > 500 && !this.isStill && this.sampleLevel < 3 && this.sampleLevel !== -1) {\n const currentSampleLevel = this.sampleLevel\n this.sampleLevel = 3\n this.renderPending = true\n this.render()\n this.isStill = true\n this.sampleLevel = currentSampleLevel\n if (Debug) Log.log('rendered still frame')\n }\n\n this.frameRequest = window.requestAnimationFrame(this.animate)\n }\n\n pick (x: number, y: number) {\n if (this.parameters.cameraType === 'stereo') {\n // TODO picking broken for stereo camera\n return {\n 'pid': 0,\n 'instance': undefined,\n 'picker': undefined\n }\n }\n\n x *= window.devicePixelRatio\n y *= window.devicePixelRatio\n\n x = Math.max(x - 2, 0)\n y = Math.max(y - 2, 0)\n\n let pid = 0, instance, picker\n const pixelBuffer = SupportsReadPixelsFloat ? pixelBufferFloat : pixelBufferUint\n\n this.render(true)\n this.renderer.readRenderTargetPixels(\n this.pickingTarget, x, y, 5, 5, pixelBuffer\n )\n\n for (let i = 0; i < pixelOrder.length; i++) {\n\n const offset = pixelOrder[i] * 4\n\n const oid = Math.round(pixelBuffer[ offset + 3 ])\n const object = this.pickingGroup.getObjectById(oid)\n if (object) {\n instance = object.userData.instance\n picker = object.userData.buffer.picking\n } else {\n continue\n }\n\n if (SupportsReadPixelsFloat) {\n pid =\n ((Math.round(pixelBuffer[offset] * 255) << 16) & 0xFF0000) |\n ((Math.round(pixelBuffer[offset + 1] * 255) << 8) & 0x00FF00) |\n ((Math.round(pixelBuffer[offset + 2] * 255)) & 0x0000FF)\n } else {\n pid =\n (pixelBuffer[offset] << 16) |\n (pixelBuffer[offset + 1] << 8) |\n (pixelBuffer[offset + 2])\n }\n }\n // if( Debug ){\n // const rgba = Array.apply( [], pixelBuffer );\n // Log.log( pixelBuffer );\n // Log.log(\n // \"picked color\",\n // rgba.map( c => { return c.toPrecision( 2 ) } )\n // );\n // Log.log( \"picked pid\", pid );\n // Log.log( \"picked oid\", oid );\n // Log.log( \"picked object\", object );\n // Log.log( \"picked instance\", instance );\n // Log.log( \"picked position\", x, y );\n // Log.log( \"devicePixelRatio\", window.devicePixelRatio );\n // }\n\n return { pid, instance, picker }\n }\n\n requestRender () {\n if (this.renderPending) {\n // Log.info(\"there is still a 'render' call pending\")\n return\n }\n\n // start gathering stats anew after inactivity\n if (window.performance.now() - this.stats.startTime > 22) {\n this.stats.begin()\n this.isStill = false\n }\n\n this.renderPending = true\n\n window.requestAnimationFrame(() => {\n this.render()\n this.stats.update()\n })\n }\n\n updateZoom () {\n const fov = degToRad(this.perspectiveCamera.fov)\n const height = 2 * Math.tan(fov / 2) * this.cameraDistance\n this.orthographicCamera.zoom = this.height / height\n }\n\n /**\n * Convert an absolute clip value to a relative one using bRadius.\n *\n * 0.0 -> 50.0\n * bRadius -> 0.0\n */\n absoluteToRelative (d: number) :number {\n return 50 * (1 - d / this.bRadius)\n }\n\n /**\n * Convert a relative clip value to an absolute one using bRadius\n *\n * 0.0 -> bRadius\n * 50.0 -> 0.0\n */\n relativeToAbsolute (d: number) : number {\n return this.bRadius * (1 - d / 50)\n }\n\n /**\n * Intepret clipMode, clipScale and set the camera and fog clipping.\n * Also ensures bRadius and cDist are valid\n */\n private __updateClipping () {\n const p = this.parameters\n\n // bRadius must always be updated for material-based clipping\n // and for focus calculations\n this.bRadius = Math.max(10, this.boundingBoxLength * 0.5)\n\n // FL: Removed below, but leaving commented as I don't understand intention\n // this.bRadius += this.boundingBox.getCenter(this.distVector).length()\n\n if (!isFinite(this.bRadius)) {\n this.bRadius = 50\n }\n\n this.camera.getWorldPosition(this.distVector)\n this.cDist = this.distVector.length()\n if (!this.cDist) {\n // recover from a broken (NaN) camera position\n this.cameraDistance = Math.abs(p.cameraZ)\n this.cDist = Math.abs(p.cameraZ)\n }\n\n // fog\n const fog = this.scene.fog as Fog\n fog.color.set(p.fogColor)\n\n if (p.clipMode === 'camera') {\n // Always interpret clipScale as absolute for clipMode camera\n\n this.camera.near = p.clipNear\n this.camera.far = p.clipFar\n fog.near = p.fogNear\n fog.far = p.fogFar\n\n } else {\n // scene mode\n\n if (p.clipScale === 'absolute') {\n // absolute scene mode; offset clip planes from scene center\n // (note: positive values move near plane towards camera and rear plane away)\n\n this.camera.near = this.cDist - p.clipNear\n this.camera.far = this.cDist + p.clipFar\n fog.near = this.cDist - p.fogNear\n fog.far = this.cDist + p.fogFar\n\n } else {\n // relative scene mode (default): convert pecentages to Angstroms\n\n const nearFactor = (50 - p.clipNear) / 50\n const farFactor = -(50 - p.clipFar) / 50\n this.camera.near = this.cDist - (this.bRadius * nearFactor)\n this.camera.far = this.cDist + (this.bRadius * farFactor)\n\n const fogNearFactor = (50 - p.fogNear) / 50\n const fogFarFactor = -(50 - p.fogFar) / 50\n fog.near = this.cDist - (this.bRadius * fogNearFactor)\n fog.far = this.cDist + (this.bRadius * fogFarFactor)\n }\n }\n\n if (p.clipMode !== 'camera') {\n\n if (this.camera.type === 'PerspectiveCamera') {\n\n this.camera.near = Math.max(0.1, p.clipDist, this.camera.near)\n this.camera.far = Math.max(1, this.camera.far)\n fog.near = Math.max(0.1, fog.near)\n fog.far = Math.max(1, fog.far)\n } else if (this.camera.type === 'OrthographicCamera') {\n\n if (p.clipDist > 0) {\n this.camera.near = Math.max(p.clipDist, this.camera.near)\n }\n }\n }\n }\n\n private __updateCamera () {\n const camera = this.camera\n camera.updateMatrix()\n camera.updateMatrixWorld(true)\n camera.updateProjectionMatrix()\n\n updateMaterialUniforms(this.scene, camera, this.renderer, this.cDist, this.bRadius)\n sortProjectedPosition(this.scene, camera)\n }\n\n private __setVisibility (model: boolean, picking: boolean, background: boolean, helper: boolean) {\n this.modelGroup.visible = model\n this.pickingGroup.visible = picking\n this.backgroundGroup.visible = background\n this.helperGroup.visible = helper\n }\n\n private __updateLights () {\n this.spotLight.color.set(this.parameters.lightColor)\n this.spotLight.intensity = this.parameters.lightIntensity\n\n this.distVector.copy(this.camera.position).setLength(this.boundingBoxLength * 100)\n this.spotLight.position.copy(this.camera.position).add(this.distVector)\n\n this.ambientLight.color.set(this.parameters.ambientColor)\n this.ambientLight.intensity = this.parameters.ambientIntensity\n }\n\n private __renderPickingGroup (camera: PerspectiveCamera|OrthographicCamera) {\n this.renderer.setRenderTarget(this.pickingTarget || null)\n this.renderer.clear()\n this.__setVisibility(false, true, false, false)\n this.renderer.render(this.scene, camera)\n // back to standard render target\n this.renderer.setRenderTarget(null)\n this.updateInfo()\n\n // if (Debug) {\n // this.__setVisibility(false, true, false, true);\n\n // this.renderer.clear();\n // this.renderer.render(this.scene, camera);\n // }\n }\n\n private __renderModelGroup (camera: PerspectiveCamera|OrthographicCamera, renderTarget?: WebGLRenderTarget) {\n this.renderer.setRenderTarget(renderTarget || null)\n this.renderer.clear()\n this.__setVisibility(false, false, true, false)\n this.renderer.render(this.scene, camera)\n this.renderer.clear(false, true, true)\n this.updateInfo()\n\n this.__setVisibility(true, false, false, Debug)\n this.renderer.render(this.scene, camera)\n this.renderer.setRenderTarget(null) // set back to default canvas\n this.updateInfo()\n }\n\n private __renderSuperSample (camera: PerspectiveCamera|OrthographicCamera, renderTarget?: WebGLRenderTarget) {\n // based on the Supersample Anti-Aliasing Render Pass\n // contributed to three.js by bhouston / http://clara.io/\n //\n // This manual approach to SSAA re-renders the scene ones for\n // each sample with camera jitter and accumulates the results.\n // References: https://en.wikipedia.org/wiki/Supersampling\n const offsetList = JitterVectors[ Math.max(0, Math.min(this.sampleLevel, 5)) ]\n\n const baseSampleWeight = 1.0 / offsetList.length\n const roundingRange = 1 / 32\n\n this.compositeUniforms.tForeground.value = this.sampleTarget.texture\n\n let width = this.sampleTarget.width\n const height = this.sampleTarget.height\n if (this.parameters.cameraType === 'stereo') {\n width /= 2\n }\n\n // render the scene multiple times, each slightly jitter offset\n // from the last and accumulate the results.\n for (let i = 0; i < offsetList.length; ++i) {\n const offset = offsetList[ i ]\n camera.setViewOffset(\n width, height, offset[ 0 ], offset[ 1 ], width, height\n )\n camera.updateProjectionMatrix()\n updateCameraUniforms(this.scene, camera)\n\n let sampleWeight = baseSampleWeight\n // the theory is that equal weights for each sample lead to an\n // accumulation of rounding errors.\n // The following equation varies the sampleWeight per sample\n // so that it is uniformly distributed across a range of values\n // whose rounding errors cancel each other out.\n const uniformCenteredDistribution = -0.5 + (i + 0.5) / offsetList.length\n sampleWeight += roundingRange * uniformCenteredDistribution\n this.compositeUniforms.scale.value = sampleWeight\n\n this.__renderModelGroup(camera, this.sampleTarget)\n this.renderer.setRenderTarget(this.holdTarget)\n if (i === 0) {\n this.renderer.clear()\n }\n\n this.renderer.render(this.compositeScene, this.compositeCamera)\n }\n\n this.compositeUniforms.scale.value = 1.0\n this.compositeUniforms.tForeground.value = this.holdTarget.texture\n\n camera.clearViewOffset()\n this.renderer.setRenderTarget(renderTarget || null)\n this.renderer.clear()\n this.renderer.render(this.compositeScene, this.compositeCamera)\n }\n\n private __renderStereo (picking = false, _renderTarget?: WebGLRenderTarget) {\n const stereoCamera = this.stereoCamera\n stereoCamera.update(this.perspectiveCamera);\n\n const renderer = this.renderer\n let size = new Vector2()\n renderer.getSize(size)\n\n renderer.setScissorTest(true)\n\n renderer.setScissor(0, 0, size.width / 2, size.height)\n renderer.setViewport(0, 0, size.width / 2, size.height)\n updateCameraUniforms(this.scene, stereoCamera.cameraL)\n this.__render(picking, stereoCamera.cameraL)\n\n renderer.setScissor(size.width / 2, 0, size.width / 2, size.height)\n renderer.setViewport(size.width / 2, 0, size.width / 2, size.height)\n updateCameraUniforms(this.scene, stereoCamera.cameraR)\n this.__render(picking, stereoCamera.cameraR)\n\n renderer.setScissorTest(false)\n renderer.setViewport(0, 0, size.width, size.height)\n }\n\n private __render(picking = false, camera: PerspectiveCamera|OrthographicCamera, renderTarget?: WebGLRenderTarget) {\n if (picking) {\n if (!this.lastRenderedPicking) this.__renderPickingGroup(camera)\n } else if (this.sampleLevel > 0 && this.parameters.cameraType !== 'stereo') {\n // TODO super sample broken for stereo camera\n this.__renderSuperSample(camera, renderTarget)\n } else {\n this.__renderModelGroup(camera, renderTarget)\n }\n }\n\n render (picking = false, renderTarget?: WebGLRenderTarget) {\n if (this.rendering) {\n Log.warn(\"'tried to call 'render' from within 'render'\")\n return\n }\n\n // Log.time('Viewer.render')\n\n this.rendering = true\n\n try {\n this.__updateClipping()\n this.__updateCamera()\n this.__updateLights()\n this.updateInfo(true)\n\n // render\n if (this.parameters.cameraType === 'stereo') {\n this.__renderStereo(picking, renderTarget)\n } else {\n this.__render(picking, this.camera, renderTarget)\n }\n this.lastRenderedPicking = picking\n } finally {\n this.rendering = false\n this.renderPending = false\n }\n this.signals.rendered.dispatch()\n\n // Log.timeEnd('Viewer.render')\n // Log.log(this.info.memory, this.info.render)\n }\n\n clear () {\n Log.log('scene cleared')\n this.scene.remove(this.rotationGroup)\n this._initScene()\n this.renderer.clear()\n }\n\n dispose () {\n this.renderer.dispose()\n window.cancelAnimationFrame(this.frameRequest)\n }\n}\n","/**\n * @file Constants\n * @author Alexander Rose \n * @private\n */\n\nexport const LeftMouseButton = 1\nexport const MiddleMouseButton = 2\nexport const RightMouseButton = 3\n","/**\n * @file Mouse Observer\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector2 } from 'three'\nimport { Signal } from 'signals'\n\nimport { LeftMouseButton, RightMouseButton } from '../constants'\nimport { defaults } from '../utils'\nimport Viewer from '../viewer/viewer'\nimport MouseControls from '../controls/mouse-controls'\n\ntype Optional = Pick, K> & Omit;\n\n/**\n * @example\n * mouseObserver.signals.scrolled.add( function( delta ){ ... } );\n *\n * @typedef {Object} MouseSignals\n * @property {Signal} moved - on move: deltaX, deltaY\n * @property {Signal} scrolled - on scroll: delta\n * @property {Signal} dragged - on drag: deltaX, deltaY\n * @property {Signal} dropped - on drop\n * @property {Signal} clicked - on click\n * @property {Signal} hovered - on hover\n */\n\nfunction getTouchDistance (event: TouchEvent) {\n const dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX\n const dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY\n return Math.sqrt(dx * dx + dy * dy)\n}\n\nfunction getMouseButtons (event: MouseEvent) {\n if (typeof event === 'object') {\n if ('buttons' in event) {\n return event.buttons\n } else if ('which' in event as any) {\n const b = (event as any).which\n if (b === 2) {\n return 4\n } else if (b === 3) {\n return 2\n } else if (b > 0) {\n return 1 << (b - 1)\n }\n } else if ('button' in event as any) {\n const b = (event as any).button\n if (b === 1) {\n return 4\n } else if (b === 2) {\n return 2\n } else if (b >= 0) {\n return 1 << b\n }\n }\n }\n return 0\n}\n\nexport interface MouseSignals {\n moved: Signal // on move: deltaX, deltaY\n scrolled: Signal // on scroll: delta\n dragged: Signal // on drag: deltaX, deltaY\n dropped: Signal // on drop\n clicked: Signal // on click\n hovered: Signal // on hover\n doubleClicked: Signal\n}\n\nexport interface MouseParams {\n hoverTimeout?: number\n handleScroll?:boolean\n doubleClickSpeed?: number\n}\n\n/**\n * Mouse observer\n *\n * @example\n * // listen to mouse moving (and touch-moving) events\n * mouseObserver.moved.moved.add( function( deltaX, deltaY ){ ... } );\n *\n * @example\n * // listen to scrolling (and pinching) events\n * mouseObserver.signals.scrolled.add( function( delta ){ ... } );\n *\n * @example\n * // listen to dragging (and touch-dragging) events\n * mouseObserver.signals.dragged.add( function( deltaX, deltaY ){ ... } );\n *\n * @example\n * // listen to clicking (and tapping) events\n * mouseObserver.signals.clicked.add( function(){ ... } );\n *\n * @example\n * // listen to double clicking (and double tapping) events\n * mouseObserver.signals.doubleClicked.add( function(){ ... } );\n *\n * @example\n * // listen to hovering events\n * mouseObserver.signals.hovered.add( function(){ ... } );\n */\nclass MouseObserver {\n signals: MouseSignals = {\n moved: new Signal(),\n scrolled: new Signal(),\n dragged: new Signal(),\n dropped: new Signal(),\n clicked: new Signal(),\n hovered: new Signal(),\n doubleClicked: new Signal()\n }\n\n hoverTimeout: number\n handleScroll:boolean\n doubleClickSpeed: number\n\n viewer: Viewer\n mouse: MouseObserver\n controls: MouseControls\n\n position = new Vector2() // Position on page\n prevPosition = new Vector2() // Previous position on page\n down = new Vector2() // Position on page when clicked\n canvasPosition = new Vector2() // Position on dom element\n prevClickCP = new Vector2()\n\n moving = false // Flag indicating if the mouse is moving\n hovering = true // Flag indicating if the mouse is hovering\n scrolled = false // Flag indicating if there was a scolling event since the last mouse move\n lastMoved = Infinity // Timestamp of last mouse move\n which? = 0 // 0: No button; 1: Left button; 2: Middle button; 3: Right button\n buttons? = 0 // 0: No button; 1: Left button; 2: Right button; 4: Middle button\n pressed? = false // Flag indicating if the mouse is pressed down\n altKey = false // Flag indicating if the alt key is pressed\n ctrlKey = false // Flag indicating if the ctrl key is pressed\n metaKey = false // Flag indicating if the meta key is pressed\n shiftKey = false // Flag indicating if the shift key is pressed\n\n doubleClickPending: boolean\n lastClicked: number\n overElement: boolean\n lastTouchDistance: number\n private frameRequest: number\n\n /**\n * @param {Element} domElement - the dom element to observe mouse events in\n * @param {Object} params - parameters object\n * @param {Integer} params.hoverTimeout - timeout in ms until the {@link MouseSignals.hovered}\n * signal is fired, set to -1 to ignore hovering\n * @param {Boolean} params.handleScroll - whether or not to handle scroll events\n * @param {Integer} params.doubleClickSpeed - max time in ms to trigger double click\n */\n constructor (readonly domElement: HTMLCanvasElement, params: MouseParams = {}) {\n this.domElement.style.touchAction = 'none'\n\n this.hoverTimeout = defaults(params.hoverTimeout, 50)\n this.handleScroll = defaults(params.handleScroll, true)\n this.doubleClickSpeed = defaults(params.doubleClickSpeed, 500)\n\n this._listen = this._listen.bind(this)\n this._onMousewheel = this._onMousewheel.bind(this)\n this._onMousemove = this._onMousemove.bind(this)\n this._onMousedown = this._onMousedown.bind(this)\n this._onMouseup = this._onMouseup.bind(this)\n this._onContextmenu = this._onContextmenu.bind(this)\n this._onTouchstart = this._onTouchstart.bind(this)\n this._onTouchend = this._onTouchend.bind(this)\n this._onTouchmove = this._onTouchmove.bind(this)\n\n this._listen()\n\n const opt = { passive: false } // treat as 'passive' so preventDefault can be called\n document.addEventListener('mousewheel', this._onMousewheel, opt)\n document.addEventListener('wheel', this._onMousewheel, opt)\n document.addEventListener('MozMousePixelScroll', this._onMousewheel, opt)\n document.addEventListener('mousemove', this._onMousemove, opt)\n document.addEventListener('mousedown', this._onMousedown, opt)\n document.addEventListener('mouseup', this._onMouseup, opt)\n document.addEventListener('contextmenu', this._onContextmenu, opt)\n document.addEventListener('touchstart', this._onTouchstart, opt)\n document.addEventListener('touchend', this._onTouchend, opt)\n document.addEventListener('touchmove', this._onTouchmove, opt)\n }\n\n get key () {\n let key = 0\n if (this.altKey) key += 1\n if (this.ctrlKey) key += 2\n if (this.metaKey) key += 4\n if (this.shiftKey) key += 8\n return key\n }\n\n setParameters (params: MouseParams = {}) {\n this.hoverTimeout = defaults(params.hoverTimeout, this.hoverTimeout)\n }\n\n /**\n * listen to mouse actions\n * @emits {MouseSignals.clicked} when clicked\n * @emits {MouseSignals.hovered} when hovered\n * @return {undefined}\n */\n _listen () {\n const now = window.performance.now()\n const cp = this.canvasPosition\n if (this.doubleClickPending && now - this.lastClicked > this.doubleClickSpeed) {\n this.doubleClickPending = false\n }\n if (now - this.lastMoved > this.hoverTimeout) {\n this.moving = false\n }\n if (this.scrolled || (!this.moving && !this.hovering)) {\n this.scrolled = false\n if (this.hoverTimeout !== -1 && this.overElement) {\n this.hovering = true\n this.signals.hovered.dispatch(cp.x, cp.y)\n }\n }\n this.frameRequest = window.requestAnimationFrame(this._listen)\n }\n\n /**\n * handle mouse scroll\n * @emits {MouseSignals.scrolled} when scrolled\n * @param {Event} event - mouse event\n * @return {undefined}\n */\n _onMousewheel(event: Optional & { wheelDelta?: number, wheelDeltaY?: number }) {\n if (event.target !== this.domElement || !this.handleScroll) {\n return\n }\n event.preventDefault()\n this._setKeys(event as any)\n\n let delta = 0\n // This has to be written in a particular way to handle old browsers that\n // all send events with different properties set in different ways.\n if ('deltaY' in event && 'deltaMode' in event &&\n event.deltaY !== undefined && event.deltaMode !== undefined) {\n // all modern browsers, using WheelEvent; deltaY + down (toward user)\n if (event.deltaMode === WheelEvent.DOM_DELTA_PIXEL)\n // everything except Firefox: normally 100 per wheel click\n delta = -event.deltaY * (2.5 / 100.0)\n else if (event.deltaMode === WheelEvent.DOM_DELTA_LINE)\n // Firefox in line mode, normally 3 per wheel click\n delta = -event.deltaY * (2.5 / 3.0)\n else // page mode: 1 per wheel click\n delta = -event.deltaY * 2.5\n } else if ('deltaY' in event && !('detail' in event)) {\n // Old Firefox or IE 11: deltaY but no deltaMode; treat as pixels\n delta = -event.deltaY * (2.5 / 100.0)\n } else if (event.wheelDelta !== undefined) {\n delta = -event.wheelDelta * (2.5 / 100)\n } else if (event.wheelDeltaY !== undefined) {\n delta = -event.wheelDeltaY * (2.5 / 100)\n } else if (event.detail !== undefined){\n // Old Firefox, MouseWheelEvent\n delta = -event.detail / 3\n }\n this.signals.scrolled.dispatch(delta)\n\n setTimeout(() => {\n this.scrolled = true\n }, this.hoverTimeout)\n }\n\n /**\n * handle mouse move\n * @emits {MouseSignals.moved} when moved\n * @emits {MouseSignals.dragged} when dragged\n * @param {Event} event - mouse event\n * @return {undefined}\n */\n _onMousemove (event: MouseEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n this.overElement = true\n } else {\n this.overElement = false\n }\n this._setKeys(event)\n this.moving = true\n this.hovering = false\n this.lastMoved = window.performance.now()\n this.prevPosition.copy(this.position)\n this.position.set(event.clientX, event.clientY)\n this._setCanvasPosition(event)\n const dx = this.prevPosition.x - this.position.x\n const dy = this.prevPosition.y - this.position.y\n this.signals.moved.dispatch(dx, dy)\n if (this.pressed) {\n this.signals.dragged.dispatch(dx, dy)\n }\n }\n\n _onMousedown (event: MouseEvent) {\n if (event.target !== this.domElement) {\n return\n }\n event.preventDefault()\n this._setKeys(event)\n this.moving = false\n this.hovering = false\n this.down.set(event.clientX, event.clientY)\n this.position.set(event.clientX, event.clientY)\n this.which = event.which\n this.buttons = getMouseButtons(event)\n this.pressed = true\n this._setCanvasPosition(event)\n }\n\n /**\n * handle mouse up\n * @emits {MouseSignals.doubleClicked} when double clicked\n * @emits {MouseSignals.dropped} when dropped\n * @param {Event} event - mouse event\n * @return {undefined}\n */\n _onMouseup (event: MouseEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n }\n this._setKeys(event)\n const cp = this.canvasPosition\n if (this._distance() < 4) {\n this.lastClicked = window.performance.now()\n if (this.doubleClickPending && this.prevClickCP.distanceTo(cp) < 4) {\n this.signals.doubleClicked.dispatch(cp.x, cp.y)\n this.doubleClickPending = false\n }\n this.signals.clicked.dispatch(cp.x, cp.y)\n this.doubleClickPending = true\n this.prevClickCP.copy(cp)\n }\n this.which = undefined\n this.buttons = undefined\n this.pressed = undefined\n // if (this._distance() > 3 || event.which === RightMouseButton) {\n // this.signals.dropped.dispatch();\n // }\n }\n\n _onContextmenu (event: MouseEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n }\n }\n\n _onTouchstart (event: TouchEvent) {\n if (event.target !== this.domElement) {\n return\n }\n event.preventDefault()\n this.pressed = true\n switch (event.touches.length) {\n case 1: {\n this.moving = false\n this.hovering = false\n this.down.set(\n event.touches[ 0 ].pageX,\n event.touches[ 0 ].pageY\n )\n this.position.set(\n event.touches[ 0 ].pageX,\n event.touches[ 0 ].pageY\n )\n this._setCanvasPosition(event.touches[ 0 ])\n break\n }\n\n case 2: {\n this.down.set(\n (event.touches[ 0 ].pageX + event.touches[ 1 ].pageX) / 2,\n (event.touches[ 0 ].pageY + event.touches[ 1 ].pageY) / 2\n )\n this.position.set(\n (event.touches[ 0 ].pageX + event.touches[ 1 ].pageX) / 2,\n (event.touches[ 0 ].pageY + event.touches[ 1 ].pageY) / 2\n )\n this.lastTouchDistance = getTouchDistance(event)\n }\n }\n }\n\n _onTouchend (event: TouchEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n }\n this.which = undefined\n this.buttons = undefined\n this.pressed = undefined\n }\n\n _onTouchmove (event: TouchEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n this.overElement = true\n } else {\n this.overElement = false\n }\n switch (event.touches.length) {\n case 1: {\n this._setKeys(event)\n this.which = LeftMouseButton\n this.buttons = 1\n this.moving = true\n this.hovering = false\n this.lastMoved = window.performance.now()\n this.prevPosition.copy(this.position)\n this.position.set(\n event.touches[ 0 ].pageX,\n event.touches[ 0 ].pageY\n )\n this._setCanvasPosition(event.touches[ 0 ])\n const dx = this.prevPosition.x - this.position.x\n const dy = this.prevPosition.y - this.position.y\n this.signals.moved.dispatch(dx, dy)\n if (this.pressed) {\n this.signals.dragged.dispatch(dx, dy)\n }\n break\n }\n\n case 2: {\n const touchDistance = getTouchDistance(event)\n const delta = touchDistance - this.lastTouchDistance\n this.lastTouchDistance = touchDistance\n this.prevPosition.copy(this.position)\n this.position.set(\n (event.touches[ 0 ].pageX + event.touches[ 1 ].pageX) / 2,\n (event.touches[ 0 ].pageY + event.touches[ 1 ].pageY) / 2\n )\n if (Math.abs(delta) > 2 && this.handleScroll &&\n this.position.distanceTo(this.prevPosition) < 2\n ) {\n this.which = 0\n this.buttons = 0\n this.signals.scrolled.dispatch(delta / 2)\n } else {\n this.which = RightMouseButton\n this.buttons = 2\n const dx = this.prevPosition.x - this.position.x\n const dy = this.prevPosition.y - this.position.y\n this.signals.moved.dispatch(dx, dy)\n if (this.pressed) {\n this.signals.dragged.dispatch(dx, dy)\n }\n }\n }\n }\n }\n\n _distance () {\n return this.position.distanceTo(this.down)\n }\n\n _setCanvasPosition (event: any) { // TODO\n const box = this.domElement.getBoundingClientRect()\n let offsetX, offsetY;\n if ('clientX' in event && 'clientY' in event) {\n offsetX = event.clientX - box.left\n offsetY = event.clientY - box.top\n } else {\n offsetX = event.offsetX\n offsetY = event.offsetY\n }\n this.canvasPosition.set(offsetX, box.height - offsetY)\n }\n\n _setKeys (event: MouseEvent|TouchEvent) {\n this.altKey = event.altKey\n this.ctrlKey = event.ctrlKey\n this.metaKey = event.metaKey\n this.shiftKey = event.shiftKey\n }\n\n dispose () {\n document.removeEventListener('mousewheel', this._onMousewheel)\n document.removeEventListener('wheel', this._onMousewheel)\n document.removeEventListener('MozMousePixelScroll', this._onMousewheel)\n document.removeEventListener('mousemove', this._onMousemove)\n document.removeEventListener('mousedown', this._onMousedown)\n document.removeEventListener('mouseup', this._onMouseup)\n document.removeEventListener('contextmenu', this._onContextmenu)\n document.removeEventListener('touchstart', this._onTouchstart)\n document.removeEventListener('touchend', this._onTouchend)\n document.removeEventListener('touchmove', this._onTouchmove)\n window.cancelAnimationFrame(this.frameRequest)\n }\n}\n\nexport default MouseObserver\n","/**\n * @file Trackball Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4, Quaternion } from 'three'\n\nimport { defaults } from '../utils'\nimport Stage from '../stage/stage'\nimport MouseObserver from '../stage/mouse-observer'\nimport Viewer from '../viewer/viewer'\nimport ViewerControls from './viewer-controls'\nimport AtomProxy from '../proxy/atom-proxy';\nimport Component from '../component/component';\n\nconst tmpRotateXMatrix = new Matrix4()\nconst tmpRotateYMatrix = new Matrix4()\nconst tmpRotateZMatrix = new Matrix4()\nconst tmpRotateMatrix = new Matrix4()\nconst tmpRotateCameraMatrix = new Matrix4()\nconst tmpRotateVector = new Vector3()\nconst tmpRotateQuaternion = new Quaternion()\nconst tmpRotateQuaternion2 = new Quaternion()\nconst tmpPanMatrix = new Matrix4()\nconst tmpPanVector = new Vector3()\nconst tmpAtomVector = new Vector3()\n\nexport interface TrackballControlsParams {\n rotateSpeed?: number\n zoomSpeed?: number\n panSpeed?: number\n}\n\n/**\n * Trackball controls\n */\nclass TrackballControls {\n viewer: Viewer\n mouse: MouseObserver\n controls: ViewerControls\n\n rotateSpeed: number\n zoomSpeed: number\n panSpeed: number\n\n constructor (readonly stage: Stage, params: TrackballControlsParams = {}) {\n this.rotateSpeed = defaults(params.rotateSpeed, 2.0)\n this.zoomSpeed = defaults(params.zoomSpeed, 1.2)\n this.panSpeed = defaults(params.panSpeed, 1.0)\n\n this.viewer = stage.viewer\n this.mouse = stage.mouseObserver\n this.controls = stage.viewerControls\n }\n\n get component (): Component|undefined {\n return this.stage.transformComponent\n }\n\n get atom (): AtomProxy|undefined {\n return this.stage.transformAtom\n }\n\n private _setPanVector (x: number, y: number, z = 0) {\n const scaleFactor = this.controls.getCanvasScaleFactor(z)\n tmpPanVector.set(x, y, 0)\n tmpPanVector.multiplyScalar(this.panSpeed * scaleFactor)\n }\n\n private _getRotateXY (x: number, y: number) {\n return [\n this.rotateSpeed * -x * 0.01,\n this.rotateSpeed * y * 0.01\n ]\n }\n\n private _getCameraRotation(m: Matrix4) {\n m.extractRotation(this.viewer.camera.matrixWorld)\n m.multiply(tmpRotateYMatrix.makeRotationY(Math.PI))\n\n return m\n }\n\n private _transformPanVector () {\n if (!this.component) return\n\n // Adjust for component and scene rotation\n tmpPanMatrix.extractRotation(this.component.transform)\n tmpPanMatrix.premultiply(this.viewer.rotationGroup.matrix)\n tmpPanMatrix.getInverse(tmpPanMatrix)\n\n // Adjust for camera rotation\n tmpPanMatrix.multiply(this._getCameraRotation(tmpRotateMatrix))\n\n tmpPanVector.applyMatrix4(tmpPanMatrix)\n }\n\n zoom (delta: number) {\n this.controls.zoom(this.zoomSpeed * delta * 0.02)\n }\n\n pan (x: number, y: number) {\n this._setPanVector(x, y)\n\n // Adjust for scene rotation\n tmpPanMatrix.getInverse(this.viewer.rotationGroup.matrix)\n\n // Adjust for camera rotation\n tmpPanMatrix.multiply(this._getCameraRotation(tmpRotateMatrix))\n\n tmpPanVector.applyMatrix4(tmpPanMatrix)\n this.controls.translate(tmpPanVector)\n }\n\n panComponent (x: number, y: number) {\n if (!this.component) return\n\n this._setPanVector(x, y)\n this._transformPanVector()\n\n this.component.position.add(tmpPanVector)\n this.component.updateMatrix()\n }\n\n panAtom (x: number, y: number) {\n if (!this.atom || !this.component) return\n\n this.atom.positionToVector3(tmpAtomVector)\n tmpAtomVector.add(this.viewer.translationGroup.position)\n tmpAtomVector.applyMatrix4(this.viewer.rotationGroup.matrix)\n\n this._setPanVector(x, y, tmpAtomVector.z)\n this._transformPanVector()\n\n this.atom.positionAdd(tmpPanVector)\n this.component.updateRepresentations({ 'position': true })\n }\n\n rotate (x: number, y: number) {\n const [ dx, dy ] = this._getRotateXY(x, y)\n\n // rotate around screen X then screen Y\n this._getCameraRotation(tmpRotateMatrix)\n tmpRotateVector.set(1, 0, 0) // X axis\n tmpRotateVector.applyMatrix4(tmpRotateMatrix) // screen X\n tmpRotateQuaternion.setFromAxisAngle(tmpRotateVector, dy)\n\n tmpRotateVector.set(0, 1, 0) // Y axis\n tmpRotateVector.applyMatrix4(tmpRotateMatrix) // screen Y\n tmpRotateQuaternion2.setFromAxisAngle(tmpRotateVector, dx)\n\n tmpRotateQuaternion.multiply(tmpRotateQuaternion2)\n tmpRotateMatrix.makeRotationFromQuaternion(tmpRotateQuaternion)\n this.controls.applyMatrix(tmpRotateMatrix)\n }\n\n zRotate (x: number, y: number) {\n const dz = this.rotateSpeed * ((-x + y) / -2) * 0.01\n\n tmpRotateZMatrix.makeRotationZ(dz)\n this.controls.applyMatrix(tmpRotateZMatrix)\n }\n\n rotateComponent (x: number, y: number) {\n if (!this.component) return\n\n const [ dx, dy ] = this._getRotateXY(x, y)\n\n this._getCameraRotation(tmpRotateCameraMatrix)\n\n tmpRotateMatrix.extractRotation(this.component.transform)\n tmpRotateMatrix.premultiply(this.viewer.rotationGroup.matrix)\n tmpRotateMatrix.getInverse(tmpRotateMatrix)\n tmpRotateMatrix.premultiply(tmpRotateCameraMatrix)\n\n tmpRotateVector.set(1, 0, 0)\n tmpRotateVector.applyMatrix4(tmpRotateMatrix)\n tmpRotateXMatrix.makeRotationAxis(tmpRotateVector, dy)\n\n tmpRotateVector.set(0, 1, 0)\n tmpRotateVector.applyMatrix4(tmpRotateMatrix)\n tmpRotateYMatrix.makeRotationAxis(tmpRotateVector, dx)\n\n tmpRotateXMatrix.multiply(tmpRotateYMatrix)\n tmpRotateQuaternion.setFromRotationMatrix(tmpRotateXMatrix)\n this.component.quaternion.premultiply(tmpRotateQuaternion)\n this.component.quaternion.normalize()\n this.component.updateMatrix()\n }\n}\n\nexport default TrackballControls\n","/**\n * @file Picking Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4, Vector2 } from 'three'\n\nimport Stage from '../stage/stage'\nimport StructureComponent from '../component/structure-component'\nimport MouseObserver from '../stage/mouse-observer'\nimport { Picker } from '../utils/picker'\nimport ViewerControls from './viewer-controls'\nimport Shape from '../geometry/shape'\nimport Structure from '../structure/structure'\nimport BondProxy from '../proxy/bond-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Surface from '../surface/surface'\nimport Volume from '../surface/volume'\nimport Unitcell from '../symmetry/unitcell'\nimport Component from '../component/component';\n\nconst tmpVec = new Vector3()\n\nexport interface ShapePrimitive {\n name: string\n shape: Shape\n}\n\nfunction closer (x: Vector3, a: Vector3, b: Vector3) {\n return x.distanceTo(a) < x.distanceTo(b)\n}\n\n/**\n * Picking data object.\n * @typedef {Object} PickingData - picking data\n * @property {Number} [pid] - picking id\n * @property {Object} [instance] - instance data\n * @property {Integer} instance.id - instance id\n * @property {String|Integer} instance.name - instance name\n * @property {Matrix4} instance.matrix - transformation matrix of the instance\n * @property {Picker} [picker] - picker object\n */\n\nexport interface InstanceData {\n id: number\n name: number|string\n matrix: Matrix4\n}\n\nexport interface PickingData {\n pid: number\n instance: InstanceData\n picker: Picker\n}\n\n/**\n * Picking proxy class.\n */\nclass PickingProxy {\n pid: number\n picker: Picker\n instance: InstanceData\n controls: ViewerControls\n mouse: MouseObserver\n\n /**\n * Create picking proxy object\n * @param {PickingData} pickingData - picking data\n * @param {Stage} stage - stage object\n */\n constructor (pickingData: PickingData, readonly stage: Stage) {\n this.pid = pickingData.pid\n this.picker = pickingData.picker\n\n /**\n * @type {Object}\n */\n this.instance = pickingData.instance\n\n /**\n * @type {Stage}\n */\n this.stage = stage\n /**\n * @type {ViewerControls}\n */\n this.controls = stage.viewerControls\n /**\n * @type {MouseObserver}\n */\n this.mouse = stage.mouseObserver\n }\n\n /**\n * Kind of the picked data\n * @type {String}\n */\n get type () { return this.picker.type }\n\n /**\n * If the `alt` key was pressed\n * @type {Boolean}\n */\n get altKey () { return this.mouse.altKey }\n /**\n * If the `ctrl` key was pressed\n * @type {Boolean}\n */\n get ctrlKey () { return this.mouse.ctrlKey }\n /**\n * If the `meta` key was pressed\n * @type {Boolean}\n */\n get metaKey () { return this.mouse.metaKey }\n /**\n * If the `shift` key was pressed\n * @type {Boolean}\n */\n get shiftKey () { return this.mouse.shiftKey }\n\n /**\n * Position of the mouse on the canvas\n * @type {Vector2}\n */\n get canvasPosition (): Vector2 { return this.mouse.canvasPosition }\n\n /**\n * The component the picked data is part of\n * @type {Component}\n */\n get component (): Component {\n return this.stage.getComponentsByObject(this.picker.data as any).list[ 0 ] // TODO\n }\n\n /**\n * The picked object data\n * @type {Object}\n */\n get object () {\n return this.picker.getObject(this.pid)\n }\n\n /**\n * The 3d position in the scene of the picked object\n * @type {Vector3}\n */\n get position () {\n return this.picker.getPosition(this.pid, this.instance, this.component)\n }\n\n /**\n * The atom of a picked bond that is closest to the mouse\n * @type {AtomProxy}\n */\n get closestBondAtom (): AtomProxy|undefined {\n if (this.type !== 'bond' || !this.bond) return undefined\n\n const bond = this.bond\n const controls = this.controls\n const cp = this.canvasPosition\n\n const v1 = bond.atom1.positionToVector3()\n const v2 = bond.atom2.positionToVector3()\n\n v1.applyMatrix4(this.component.matrix)\n v2.applyMatrix4(this.component.matrix)\n\n const acp1 = controls.getPositionOnCanvas(v1)\n const acp2 = controls.getPositionOnCanvas(v2)\n\n return closer(cp as any, acp1, acp2) ? bond.atom1 : bond.atom2\n }\n\n /**\n * Close-by atom\n * @type {AtomProxy}\n */\n get closeAtom (): AtomProxy|undefined {\n const cp = this.canvasPosition\n const ca = this.closestBondAtom\n if (!ca) return undefined\n\n const v = ca.positionToVector3().applyMatrix4(this.component.matrix)\n\n const acp = this.controls.getPositionOnCanvas(v)\n\n ca.positionToVector3(tmpVec)\n if (this.instance) tmpVec.applyMatrix4(this.instance.matrix)\n tmpVec.applyMatrix4(this.component.matrix)\n const viewer = this.controls.viewer\n tmpVec.add(viewer.translationGroup.position)\n tmpVec.applyMatrix4(viewer.rotationGroup.matrix)\n\n const scaleFactor = this.controls.getCanvasScaleFactor(tmpVec.z)\n const sc = this.component as StructureComponent\n const radius = sc.getMaxRepresentationRadius(ca.index)\n //console.log(scaleFactor, cp.distanceTo(acp), radius/scaleFactor, radius)\n\n if (cp.distanceTo(acp) <= radius/scaleFactor) {\n return ca\n } else {\n return undefined\n }\n }\n\n /**\n * @type {Object}\n */\n get arrow () { return this._objectIfType('arrow') as ShapePrimitive }\n /**\n * @type {AtomProxy}\n */\n get atom () { return this._objectIfType('atom') as AtomProxy }\n /**\n * @type {Object}\n */\n get axes () { return this._objectIfType('axes') }\n /**\n * @type {BondProxy}\n */\n get bond () { return this._objectIfType('bond') as BondProxy }\n /**\n * @type {Object}\n */\n get box () { return this._objectIfType('box') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get cone () { return this._objectIfType('cone') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get clash () { return this._objectIfType('clash') as { clash: { sele1: string, sele2: string } } }\n /**\n * @type {BondProxy}\n */\n get contact () { return this._objectIfType('contact') as { type: string, atom1: AtomProxy, atom2: AtomProxy } }\n /**\n * @type {Object}\n */\n get cylinder () { return this._objectIfType('cylinder') as ShapePrimitive }\n /**\n * @type {BondProxy}\n */\n get distance () { return this._objectIfType('distance') as BondProxy }\n /**\n * @type {Object}\n */\n get ellipsoid () { return this._objectIfType('ellipsoid') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get octahedron () { return this._objectIfType('octahedron') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get point () { return this._objectIfType('point') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get mesh () { return this._objectIfType('mesh') as { name: string, shape: Shape, serial: number } }\n /**\n * @type {Object}\n */\n get slice () { return this._objectIfType('slice') as { volume: Volume, value: number } }\n /**\n * @type {Object}\n */\n get sphere () { return this._objectIfType('sphere') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get tetrahedron () { return this._objectIfType('tetrahedron') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get torus () { return this._objectIfType('torus') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get surface () { return this._objectIfType('surface') as { surface: Surface, index: number } }\n /**\n * @type {Object}\n */\n get unitcell () { return this._objectIfType('unitcell') as { unitcell: Unitcell, structure: Structure } }\n /**\n * @type {Object}\n */\n get unknown () { return this._objectIfType('unknown') }\n /**\n * @type {Object}\n */\n get volume () { return this._objectIfType('volume') as { volume: Volume, value: number } }\n /**\n * @type {Object}\n */\n get wideline () { return this._objectIfType('wideline') as ShapePrimitive }\n\n _objectIfType (type: string) {\n return this.type === type ? this.object : undefined\n }\n\n getLabel () {\n const atom = this.atom || this.closeAtom\n let msg = 'nothing'\n if (this.arrow) {\n msg = this.arrow.name\n } else if (atom) {\n msg = `atom: ${atom.qualifiedName()} (${atom.structure.name})`\n } else if (this.axes) {\n msg = 'axes'\n } else if (this.bond) {\n msg = `bond: ${this.bond.atom1.qualifiedName()} - ${this.bond.atom2.qualifiedName()} (${this.bond.structure.name})`\n } else if (this.box) {\n msg = this.box.name\n } else if (this.cone) {\n msg = this.cone.name\n } else if (this.clash) {\n msg = `clash: ${this.clash.clash.sele1} - ${this.clash.clash.sele2}`\n } else if (this.contact) {\n msg = `${this.contact.type}: ${this.contact.atom1.qualifiedName()} - ${this.contact.atom2.qualifiedName()} (${this.contact.atom1.structure.name})`\n } else if (this.cylinder) {\n msg = this.cylinder.name\n } else if (this.distance) {\n msg = `distance: ${this.distance.atom1.qualifiedName()} - ${this.distance.atom2.qualifiedName()} (${this.distance.structure.name})`\n } else if (this.ellipsoid) {\n msg = this.ellipsoid.name\n } else if (this.octahedron) {\n msg = this.octahedron.name\n } else if (this.point) {\n msg = this.point.name\n } else if (this.mesh) {\n msg = `mesh: ${this.mesh.name || this.mesh.serial} (${this.mesh.shape.name})`\n } else if (this.slice) {\n msg = `slice: ${this.slice.value.toPrecision(3)} (${this.slice.volume.name})`\n } else if (this.sphere) {\n msg = this.sphere.name\n } else if (this.surface) {\n msg = `surface: ${this.surface.surface.name}`\n } else if (this.tetrahedron) {\n msg = this.tetrahedron.name\n } else if (this.torus) {\n msg = this.torus.name\n } else if (this.unitcell) {\n msg = `unitcell: ${this.unitcell.unitcell.spacegroup} (${this.unitcell.structure.name})`\n } else if (this.unknown) {\n msg = 'unknown'\n } else if (this.volume) {\n msg = `volume: ${this.volume.value.toPrecision(3)} (${this.volume.volume.name})`\n } else if (this.wideline) {\n msg = this.wideline.name\n }\n return msg\n }\n}\n\nexport default PickingProxy\n","/**\n * @file Picking Controls\n * @author Alexander Rose \n * @private\n */\n\nimport PickingProxy from './picking-proxy'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\n\n/**\n * Picking controls\n */\nclass PickingControls {\n viewer: Viewer\n\n constructor (readonly stage: Stage) {\n this.viewer = stage.viewer\n }\n\n /**\n * get picking data\n * @param {Number} x - canvas x coordinate\n * @param {Number} y - canvas y coordinate\n * @return {PickingProxy|undefined} picking proxy\n */\n pick (x: number, y: number) {\n const pickingData = this.viewer.pick(x, y)\n\n if (pickingData.picker &&\n pickingData.picker.type !== 'ignore' &&\n pickingData.pid !== undefined\n ) {\n const pickerArray = pickingData.picker.array\n if (pickerArray && pickingData.pid >= pickerArray.length) {\n console.error('pid >= picker.array.length')\n } else {\n return new PickingProxy(pickingData, this.stage)\n }\n }\n }\n}\n\nexport default PickingControls\n","/**\n * @file Viewer Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector2, Vector3, Matrix4, Quaternion, OrthographicCamera } from 'three'\nimport * as signalsWrapper from 'signals'\n\nimport {\n ensureVector2, ensureVector3, ensureMatrix4, ensureQuaternion\n} from '../utils'\nimport { degToRad } from '../math/math-utils'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\n\n/**\n * Orientation matrix, a 4x4 transformation matrix with rotation part\n * used for scene rotation, scale part for scene camera distance and\n * position part for scene translation\n * @typedef {Matrix4} OrientationMatrix - orientation matrix\n */\n\nconst tmpQ = new Quaternion()\nconst tmpP = new Vector3()\nconst tmpS = new Vector3()\n\nconst tmpCanvasVector = new Vector3()\nconst tmpScaleVector = new Vector3()\nconst tmpRotateMatrix = new Matrix4()\nconst tmpRotateVector = new Vector3()\nconst tmpAlignMatrix = new Matrix4()\n\n/**\n * Viewer controls\n */\nclass ViewerControls {\n signals = {\n changed: new signalsWrapper.Signal()\n }\n\n viewer: Viewer\n\n /**\n * @param {Stage} stage - the stage object\n */\n constructor (readonly stage: Stage) {\n this.viewer = stage.viewer\n }\n\n /**\n * scene center position\n * @type {Vector3}\n */\n get position () {\n return this.viewer.translationGroup.position\n }\n\n /**\n * scene rotation\n * @type {Quaternion}\n */\n get rotation () {\n return this.viewer.rotationGroup.quaternion\n }\n\n /**\n * Trigger render and emit changed event\n * @emits {ViewerControls.signals.changed}\n * @return {undefined}\n */\n changed () {\n this.viewer.requestRender()\n this.signals.changed.dispatch()\n }\n\n getPositionOnCanvas (position: Vector3, optionalTarget?: Vector2) {\n const canvasPosition = ensureVector2(optionalTarget)\n const viewer = this.viewer\n\n tmpCanvasVector.copy(position)\n .add(viewer.translationGroup.position)\n .applyMatrix4(viewer.rotationGroup.matrix)\n .project(viewer.camera)\n\n return canvasPosition.set(\n (tmpCanvasVector.x + 1) * viewer.width / 2,\n (tmpCanvasVector.y + 1) * viewer.height / 2\n )\n }\n\n getCanvasScaleFactor (z = 0) {\n const camera = this.viewer.camera\n if (camera instanceof OrthographicCamera) {\n return 1 / camera.zoom\n } else {\n z = Math.abs(z)\n z += this.getCameraDistance()\n const fov = degToRad(camera.fov)\n const unitHeight = 2.0 * z * Math.tan(fov / 2)\n return unitHeight / this.viewer.height\n }\n }\n\n /**\n * get scene orientation\n * @param {Matrix4} optionalTarget - pre-allocated target matrix\n * @return {OrientationMatrix} scene orientation\n */\n getOrientation (optionalTarget?: Matrix4) {\n const m = ensureMatrix4(optionalTarget)\n\n m.copy(this.viewer.rotationGroup.matrix)\n const z = this.getCameraDistance()\n m.scale(tmpScaleVector.set(z, z, z))\n m.setPosition(this.viewer.translationGroup.position)\n\n return m\n }\n\n /**\n * set scene orientation\n * @param {OrientationMatrix|Array} orientation - scene orientation\n * @return {undefined}\n */\n orient (orientation?: Matrix4) {\n ensureMatrix4(orientation).decompose(tmpP, tmpQ, tmpS)\n\n const v = this.viewer\n v.rotationGroup.setRotationFromQuaternion(tmpQ)\n v.translationGroup.position.copy(tmpP)\n v.cameraDistance = tmpS.z\n v.updateZoom()\n this.changed()\n }\n\n /**\n * translate scene\n * @param {Vector3|Array} vector - translation vector\n * @return {undefined}\n */\n translate (vector: Vector3|number[]) {\n this.viewer.translationGroup.position\n .add(ensureVector3(vector))\n this.changed()\n }\n\n /**\n * center scene\n * @param {Vector3|Array} position - center position\n * @return {undefined}\n */\n center (position: Vector3|number[]) {\n this.viewer.translationGroup.position\n .copy(ensureVector3(position)).negate()\n this.changed()\n }\n\n /**\n * \"zoom\" scene by moving camera closer to origin\n * @param {Number} delta - zoom change\n * @return {undefined}\n */\n zoom (delta: number) {\n this.distance(this.getCameraDistance() * (1 - delta))\n }\n\n /**\n * get camera distance\n */\n getCameraDistance(): number {\n return this.viewer.cameraDistance\n }\n\n /**\n * camera distance\n * @param {Number} z - distance\n * @return {undefined}\n */\n distance (distance: number) {\n // Math.abs because distance used to be \"z\", normally negative.\n // Math.max to prevent us from getting _too_ close.\n this.viewer.cameraDistance = Math.max(Math.abs(distance), 0.2)\n this.viewer.updateZoom()\n this.changed()\n }\n\n /**\n * spin scene on axis\n * @param {Vector3|Array} axis - rotation axis\n * @param {Number} angle - amount to spin\n * @return {undefined}\n */\n spin (axis: Vector3|number[], angle: number) {\n tmpRotateMatrix.getInverse(this.viewer.rotationGroup.matrix)\n tmpRotateVector\n .copy(ensureVector3(axis)).applyMatrix4(tmpRotateMatrix)\n\n this.viewer.rotationGroup.rotateOnAxis(tmpRotateVector, angle)\n this.changed()\n }\n\n /**\n * rotate scene\n * @param {Quaternion|Array} quaternion - rotation quaternion\n * @return {undefined}\n */\n rotate (quaternion: Quaternion|number[]) {\n this.viewer.rotationGroup\n .setRotationFromQuaternion(ensureQuaternion(quaternion))\n this.changed()\n }\n\n /**\n * align scene to basis matrix\n * @param {Matrix4|Array} basis - basis matrix\n * @return {undefined}\n */\n align (basis: Matrix4|number[]) {\n tmpAlignMatrix.getInverse(ensureMatrix4(basis))\n\n this.viewer.rotationGroup.setRotationFromMatrix(tmpAlignMatrix)\n this.changed()\n }\n\n /**\n * apply rotation matrix to scene\n * @param {Matrix4|Array} matrix - rotation matrix\n * @return {undefined}\n */\n applyMatrix (matrix: Matrix4|number[]) {\n this.viewer.rotationGroup.applyMatrix4(ensureMatrix4(matrix))\n this.changed()\n }\n}\n\nexport default ViewerControls\n","/**\n * @file Animation\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Quaternion } from 'three'\n\nimport { defaults, ensureVector3, ensureQuaternion } from '../utils'\nimport { lerp, smoothstep } from '../math/math-utils'\nimport ViewerControls from '../controls/viewer-controls'\nimport Stats from '../viewer/stats'\n\n/**\n * Animation. Base animation class.\n * @interface\n */\nabstract class Animation {\n duration: number\n controls: ViewerControls\n\n alpha: number\n startTime: number\n\n pausedTime = -1\n elapsedDuration = 0\n pausedDuration = 0\n ignoreGlobalToggle = false\n\n private _paused = false\n private _resolveList: Function[] = []\n private _hold: boolean\n\n constructor (duration: number|undefined, controls: ViewerControls, ...args: any[]) {\n this.duration = defaults(duration, 1000)\n this.controls = controls\n\n this.startTime = window.performance.now()\n\n this._init(...args)\n }\n\n /**\n * True when animation has finished\n */\n get done () {\n return this.alpha === 1\n }\n\n /**\n * True when animation is paused\n */\n get paused () {\n return this._paused\n }\n\n /**\n * init animation\n */\n abstract _init (...args: any[]): void\n\n /**\n * called on every tick\n */\n abstract _tick (stats?: Stats): void\n\n tick (stats: Stats) {\n if (this._paused) return\n\n this.elapsedDuration = stats.currentTime - this.startTime - this.pausedDuration\n\n if (this.duration === 0) {\n this.alpha = 1\n } else {\n this.alpha = smoothstep(0, 1, this.elapsedDuration / this.duration)\n }\n\n this._tick(stats)\n\n if (this.done) {\n this._resolveList.forEach(resolve => resolve())\n }\n\n return this.done\n }\n\n /**\n * Pause animation\n * @param {boolean} [hold] - put animation on a hold which\n * must be release before it can be resumed\n */\n pause (hold?: boolean) {\n if (hold) this._hold = true\n\n if (this.pausedTime === -1) {\n this.pausedTime = window.performance.now()\n }\n this._paused = true\n }\n\n /**\n * Resume animation\n * @param {Boolean} [releaseHold] - release a hold on the animation\n */\n resume (releaseHold?: boolean) {\n if (!releaseHold && this._hold) return\n\n this.pausedDuration += window.performance.now() - this.pausedTime\n this._paused = false\n this._hold = false\n this.pausedTime = -1\n }\n\n /**\n * Toggle animation\n */\n toggle () {\n if (this._paused) {\n this.resume()\n } else {\n this.pause()\n }\n }\n\n /**\n * Promise-like interface\n */\n then (callback: Function) {\n let p: Promise\n\n if (this.done) {\n p = Promise.resolve()\n } else {\n p = new Promise(resolve => this._resolveList.push(resolve))\n }\n\n return p.then(callback as any)\n }\n}\n\nexport default Animation\n\n/**\n * Spin animation. Spin around an axis.\n */\nexport class SpinAnimation extends Animation {\n axis: Vector3\n angle: number\n\n constructor (duration: number|undefined, controls: ViewerControls, ...args: any[]) {\n super(defaults(duration, Infinity), controls, ...args)\n }\n\n _init (axis: number[]|Vector3, angle: number) {\n if (Array.isArray(axis)) {\n this.axis = new Vector3().fromArray(axis)\n } else {\n this.axis = defaults(axis, new Vector3(0, 1, 0))\n }\n this.angle = defaults(angle, 0.01)\n }\n\n _tick (stats: Stats) {\n if (!this.axis || !this.angle) return\n\n this.controls.spin(\n this.axis, this.angle * stats.lastDuration / 16\n )\n }\n}\n\n/**\n * Rock animation. Rock around an axis.\n */\nexport class RockAnimation extends Animation {\n axis: Vector3\n angleStep: number\n angleEnd: number\n angleSum = 0\n direction = 1\n\n constructor (duration: number|undefined, controls: ViewerControls, ...args: any[]) {\n super(defaults(duration, Infinity), controls, ...args)\n }\n\n _init (axis: number[]|Vector3, angleStep: number, angleEnd: number) {\n if (Array.isArray(axis)) {\n this.axis = new Vector3().fromArray(axis)\n } else {\n this.axis = defaults(axis, new Vector3(0, 1, 0))\n }\n this.angleStep = defaults(angleStep, 0.01)\n this.angleEnd = defaults(angleEnd, 0.2)\n }\n\n _tick (stats: Stats) {\n if (!this.axis || !this.angleStep || !this.angleEnd) return\n\n const alpha = smoothstep(\n 0, 1, Math.abs(this.angleSum) / this.angleEnd\n )\n const angle = this.angleStep * this.direction * (1.1 - alpha)\n\n this.controls.spin(\n this.axis, angle * stats.lastDuration / 16\n )\n\n this.angleSum += this.angleStep\n\n if (this.angleSum >= this.angleEnd) {\n this.direction *= -1\n this.angleSum = -this.angleEnd\n }\n }\n}\n\n/**\n * Move animation. Move from one position to another.\n */\nexport class MoveAnimation extends Animation {\n moveFrom: Vector3\n moveTo: Vector3\n\n _init (moveFrom: number[]|Vector3, moveTo: number[]|Vector3) {\n this.moveFrom = ensureVector3(defaults(moveFrom, new Vector3()))\n this.moveTo = ensureVector3(defaults(moveTo, new Vector3()))\n }\n\n _tick (/* stats */) {\n this.controls.position.lerpVectors(\n this.moveFrom, this.moveTo, this.alpha\n ).negate()\n this.controls.changed()\n }\n}\n\n/**\n * Zoom animation. Gradually change the zoom level.\n */\nexport class ZoomAnimation extends Animation {\n zoomFrom: number\n zoomTo: number\n\n _init (zoomFrom: number, zoomTo: number) {\n this.zoomFrom = zoomFrom\n this.zoomTo = zoomTo\n }\n\n _tick () {\n this.controls.distance(lerp(this.zoomFrom, this.zoomTo, this.alpha))\n }\n}\n\n/**\n * Rotate animation. Rotate from one orientation to another.\n */\nexport class RotateAnimation extends Animation {\n rotateFrom: Quaternion\n rotateTo: Quaternion\n\n private _currentRotation = new Quaternion()\n\n _init (rotateFrom: number[]|Quaternion, rotateTo: number[]|Quaternion) {\n this.rotateFrom = ensureQuaternion(rotateFrom)\n this.rotateTo = ensureQuaternion(rotateTo)\n\n this._currentRotation = new Quaternion()\n }\n\n _tick () {\n this._currentRotation\n .copy(this.rotateFrom)\n .slerp(this.rotateTo, this.alpha)\n\n this.controls.rotate(this._currentRotation)\n }\n}\n\n/**\n * Value animation. Call callback with interpolated value.\n */\nexport class ValueAnimation extends Animation {\n valueFrom: number\n valueTo: number\n callback: Function\n\n _init (valueFrom: number, valueTo: number, callback: Function) {\n this.valueFrom = valueFrom\n this.valueTo = valueTo\n\n this.callback = callback\n }\n\n _tick (/* stats */) {\n this.callback(lerp(this.valueFrom, this.valueTo, this.alpha))\n }\n}\n\n/**\n * Timeout animation. Call callback after duration.\n */\nexport class TimeoutAnimation extends Animation {\n callback: Function\n\n _init (callback: Function) {\n this.callback = callback\n }\n\n _tick () {\n if (this.alpha === 1) this.callback()\n }\n}\n\n/**\n * Animation list.\n */\nexport class AnimationList {\n _list: Animation[]\n _resolveList: Function[] = []\n\n constructor (list: Animation[] = []) {\n this._list = list\n }\n\n /**\n * True when all animations have finished\n */\n get done () {\n return this._list.every(animation => {\n return animation.done\n })\n }\n\n /**\n * Promise-like interface\n */\n then (callback: Function) {\n let p: Promise\n\n if (this.done) {\n p = Promise.resolve()\n } else {\n p = new Promise(resolve => {\n this._resolveList.push(resolve)\n this._list.forEach(animation => {\n animation.then(() => {\n this._resolveList.forEach(callback => {\n callback()\n })\n this._resolveList.length = 0\n })\n })\n })\n }\n\n return p.then(callback as any)\n }\n}\n","/**\n * @file Animation Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Quaternion, Matrix4 } from 'three'\n\nimport { ensureMatrix4 } from '../utils'\nimport Animation, {\n SpinAnimation, RockAnimation, MoveAnimation, ZoomAnimation,\n RotateAnimation, ValueAnimation, TimeoutAnimation, AnimationList\n} from '../animation/animation'\nimport Stage from '../stage/stage'\nimport Component from '../component/component'\nimport Viewer from '../viewer/viewer'\nimport Stats from '../viewer/stats'\nimport ViewerControls from './viewer-controls'\n\n/**\n * Animation controls\n */\nclass AnimationControls {\n viewer: Viewer\n controls: ViewerControls\n\n animationList: Animation[] = []\n finishedList: Animation[] = []\n\n /**\n * Create animation controls\n * @param {Stage} stage - the stage object\n */\n constructor (readonly stage: Stage) {\n this.viewer = stage.viewer\n this.controls = stage.viewerControls\n }\n\n /**\n * True when all animations are paused\n * @type {Boolean}\n */\n get paused () {\n return this.animationList.every((animation: Animation) => animation.paused)\n }\n\n /**\n * Add an animation\n */\n add (animation: Animation) {\n if (animation.duration === 0) {\n animation.tick(this.viewer.stats)\n } else {\n this.animationList.push(animation)\n }\n\n return animation\n }\n\n /**\n * Remove an animation\n */\n remove (animation: Animation) {\n const list = this.animationList\n const index = list.indexOf(animation)\n\n if (index > -1) {\n list.splice(index, 1)\n }\n }\n\n /**\n * Run all animations\n */\n run (stats: Stats) {\n const finishedList = this.finishedList\n const animationList = this.animationList\n\n const n = animationList.length\n for (let i = 0; i < n; ++i) {\n const animation = animationList[ i ]\n // tick returns true when finished\n if (animation.tick(stats)) {\n finishedList.push(animation)\n }\n }\n\n const m = finishedList.length\n if (m) {\n for (let j = 0; j < m; ++j) {\n this.remove(finishedList[ j ])\n }\n finishedList.length = 0\n }\n }\n\n /**\n * Add a spin animation\n * @param {Vector3} axis - axis to spin around\n * @param {Number} angle - amount to spin per frame, radians\n * @param {Number} duration - animation time in milliseconds\n * @return {SpinAnimation} the animation\n */\n spin (axis: Vector3|number[], angle?: number, duration?: number) {\n return this.add(\n new SpinAnimation(duration, this.controls, axis, angle)\n )\n }\n\n /**\n * Add a rock animation\n * @param {Vector3} axis - axis to rock around\n * @param {Number} angle - amount to spin per frame, radians\n * @param {Number} end - maximum extend of motion, radians\n * @param {Number} duration - animation time in milliseconds\n * @return {SpinAnimation} the animation\n */\n rock (axis: Vector3|number[], angle?: number, end?: number, duration?: number) {\n return this.add(\n new RockAnimation(duration, this.controls, axis, angle, end)\n )\n }\n\n /**\n * Add a rotate animation\n * @param {Quaternion} rotateTo - target rotation\n * @param {Number} duration - animation time in milliseconds\n * @return {RotateAnimation} the animation\n */\n rotate (rotateTo: Quaternion|number[], duration?: number) {\n const rotateFrom = this.viewer.rotationGroup.quaternion.clone()\n\n return this.add(\n new RotateAnimation(duration, this.controls, rotateFrom, rotateTo)\n )\n }\n\n /**\n * Add a move animation\n * @param {Vector3} moveTo - target position\n * @param {Number} duration - animation time in milliseconds\n * @return {MoveAnimation} the animation\n */\n move (moveTo: Vector3|number[], duration?: number) {\n const moveFrom = this.controls.position.clone().negate()\n\n return this.add(\n new MoveAnimation(duration, this.controls, moveFrom, moveTo)\n )\n }\n\n /**\n * Add a zoom animation\n * @param {Number} zoomTo - target distance\n * @param {Number} duration - animation time in milliseconds\n * @return {ZoomAnimation} the animation\n */\n zoom (zoomTo: number, duration?: number) {\n const zoomFrom = this.viewer.camera.position.z\n\n return this.add(\n new ZoomAnimation(duration, this.controls, zoomFrom, zoomTo)\n )\n }\n\n /**\n * Add a zoom and a move animation\n * @param {Vector3} moveTo - target position\n * @param {Number} zoomTo - target distance\n * @param {Number} duration - animation time in milliseconds\n * @return {Array} the animations\n */\n zoomMove (moveTo: Vector3, zoomTo: number, duration?: number) {\n return new AnimationList([\n this.move(moveTo, duration),\n this.zoom(zoomTo, duration)\n ])\n }\n\n /**\n * Add an orient animation\n * @param {OrientationMatrix|Array} orientTo - target orientation\n * @param {Number} duration - animation time in milliseconds\n * @return {Array} the animations\n */\n orient (orientTo: Matrix4|number[], duration?: number) {\n const p = new Vector3()\n const q = new Quaternion()\n const s = new Vector3()\n\n ensureMatrix4(orientTo).decompose(p, q, s)\n\n return new AnimationList([\n this.move(p.negate(), duration),\n this.rotate(q, duration),\n this.zoom(-s.x, duration)\n ])\n }\n\n /**\n * Add a value animation\n * @param {Number} valueFrom - start value\n * @param {Number} valueTo - target value\n * @param {Function} callback - called on every tick\n * @param {Number} duration - animation time in milliseconds\n * @return {ValueAnimation} the animation\n */\n value (valueFrom: number, valueTo: number, callback: Function, duration?: number) {\n return this.add(\n new ValueAnimation(duration, this.controls, valueFrom, valueTo, callback)\n )\n }\n\n /**\n * Add a timeout animation\n * @param {Function} callback - called after duration\n * @param {Number} duration - timeout in milliseconds\n * @return {TimeoutAnimation} the animation\n */\n timeout (callback: Function, duration?: number) {\n return this.add(\n new TimeoutAnimation(duration, this.controls, callback)\n )\n }\n\n /**\n * Add a component spin animation\n * @param {Component} component - object to move\n * @param {Vector3} axis - axis to spin around\n * @param {Number} angle - amount to spin per frame, radians\n * @param {Number} duration - animation time in milliseconds\n * @return {SpinAnimation} the animation\n */\n spinComponent (component: Component, axis?: Vector3|number[], angle?: number, duration?: number) {\n return this.add(\n // TODO\n new SpinAnimation(duration, component.controls as any, axis, angle)\n )\n }\n\n /**\n * Add a component rock animation\n * @param {Component} component - object to move\n * @param {Vector3} axis - axis to rock around\n * @param {Number} angle - amount to spin per frame, radians\n * @param {Number} end - maximum extend of motion, radians\n * @param {Number} duration - animation time in milliseconds\n * @return {SpinAnimation} the animation\n */\n rockComponent (component: Component, axis: Vector3|number[], angle?: number, end?: number, duration?: number) {\n return this.add(\n // TODO\n new RockAnimation(duration, component.controls as any, axis, angle, end)\n )\n }\n\n /**\n * Add a component move animation\n * @param {Component} component - object to move\n * @param {Vector3} moveTo - target position\n * @param {Number} duration - animation time in milliseconds\n * @return {MoveAnimation} the animation\n */\n moveComponent (component: Component, moveTo: Vector3|number[], duration?: number) {\n const moveFrom = component.controls.position.clone().negate()\n\n return this.add(\n // TODO\n new MoveAnimation(duration, component.controls as any, moveFrom, moveTo)\n )\n }\n\n /**\n * Pause all animations\n * @return {undefined}\n */\n pause () {\n this.animationList.forEach(animation => animation.pause())\n }\n\n /**\n * Resume all animations\n * @return {undefined}\n */\n resume () {\n this.animationList.forEach(animation => animation.resume())\n }\n\n /**\n * Toggle all animations\n * @return {undefined}\n */\n toggle () {\n if (this.paused) {\n this.resume()\n } else {\n this.pause()\n }\n }\n\n /**\n * Clear all animations\n * @return {undefined}\n */\n clear () {\n this.animationList.length = 0\n }\n\n dispose () {\n this.clear()\n }\n}\n\nexport default AnimationControls\n","/**\n * @file Queue\n * @author Alexander Rose \n * @private\n */\n\nclass Queue {\n queue: T[] = []\n pending = false\n\n constructor(readonly fn: Function, argList?: T[]) {\n this.next = this.next.bind(this)\n\n if (argList) {\n for (let i = 0, il = argList.length; i < il; ++i) {\n this.queue.push(argList[ i ])\n }\n this.next()\n }\n }\n\n private run (arg: any) {\n this.fn(arg, this.next)\n }\n\n private next () {\n const arg = this.queue.shift()\n if (arg !== undefined) {\n this.pending = true\n setTimeout(() => this.run(arg))\n } else {\n this.pending = false\n }\n }\n\n push (arg: T) {\n this.queue.push(arg)\n if (!this.pending) this.next()\n }\n\n kill () {\n this.queue.length = 0\n }\n\n length () {\n return this.queue.length\n }\n}\n\nexport default Queue\n","/**\n * @file Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { Color, Vector3, Matrix4 } from 'three'\n\nimport { Debug, Log, ColormakerRegistry, ExtensionFragDepth } from '../globals'\nimport { defaults } from '../utils'\nimport Queue from '../utils/queue'\nimport Counter from '../utils/counter'\nimport Viewer from '../viewer/viewer'\nimport { BufferParameters, BufferSide, default as Buffer } from '../buffer/buffer';\nimport { ColorData, ColormakerParameters, ColorMode } from '../color/colormaker';\nimport { GenericColor } from '../types'\n\nexport interface RepresentationParameters {\n name: string\n lazy: boolean,\n clipNear: number,\n clipRadius: number,\n clipCenter: Vector3,\n flatShaded: boolean,\n opacity: number,\n depthWrite: boolean,\n side: BufferSide,\n wireframe: boolean,\n colorData: ColorData,\n colorScheme: string,\n colorScale: string | number[],\n colorReverse: boolean,\n colorValue: GenericColor,\n colorDomain: number[],\n colorMode: ColorMode,\n colorSpace: 'sRGB' | 'linear',\n roughness: number,\n metalness: number,\n diffuse: GenericColor,\n diffuseInterior: boolean,\n useInteriorColor: boolean,\n interiorColor: GenericColor,\n interiorDarkening: number,\n disablePicking: boolean,\n matrix: Matrix4\n quality: string,\n visible: boolean,\n color: GenericColor,\n sphereDetail: number,\n radialSegments: number,\n openEnded: boolean\n disableImpostor: boolean\n [key: string]: any//boolean | number | undefined | Color | string | Vector3 | Matrix4 | number[]\n}\n/**\n * Representation parameter object.\n * @typedef {Object} RepresentationParameters - representation parameters\n * @property {Boolean} [lazy] - only build & update the representation when visible\n * otherwise defer changes until set visible again\n * @property {Integer} [clipNear] - position of camera near/front clipping plane\n * in percent of scene bounding box\n * @property {Integer} [clipRadius] - radius of clipping sphere\n * @property {Vector3} [clipCenter] - position of for spherical clipping\n * @property {Boolean} [flatShaded] - render flat shaded\n * @property {Float} [opacity] - translucency: 1 is fully opaque, 0 is fully transparent\n * @property {Boolean} [depthWrite] - depth write\n * @property {String} [side] - which triangle sides to render, \"front\" front-side,\n * \"back\" back-side, \"double\" front- and back-side\n * @property {Boolean} [wireframe] - render as wireframe\n * @property {ColorData} [colorData] - atom or bond indexed data for coloring\n * @property {String} [colorScheme] - color scheme\n * @property {String} [colorScale] - color scale, either a string for a\n * predefined scale or an array of\n * colors to be used as the scale\n * @property {Boolean} [colorReverse] - reverse color scale\n * @property {Color} [colorValue] - color value\n * @property {Integer[]} [colorDomain] - scale value range\n * @property {Integer} colorDomain.0 - min value\n * @property {Integer} colorDomain.1 - max value\n * @property {String} [colorMode] - color mode, one of rgb, hsv, hsl, hsi, lab, hcl\n * @property {Float} [roughness] - how rough the material is, between 0 and 1\n * @property {Float} [metalness] - how metallic the material is, between 0 and 1\n * @property {Color} [diffuse] - diffuse color for lighting\n * @property {Boolean} [diffuseInterior] - diffuse interior, i.e. ignore normal\n * @property {Boolean} [useInteriorColor] - use interior color\n * @property {Color} [interiorColor] - interior color\n * @property {Float} [interiorDarkening] - interior darkening: 0 no darking, 1 fully darkened\n * @property {Boolean} [disablePicking] - disable picking\n */\n\n/**\n * Representation object\n * @interface\n * @param {Object} object - the object to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {RepresentationParameters} [params] - representation parameters\n */\nclass Representation {\n parameters: any\n type: string\n viewer: Viewer\n tasks: Counter\n private queue: Queue\n bufferList: Buffer[]\n\n lazy: boolean\n lazyProps: { build: boolean, bufferParams: BufferParameters | {}, what: {}}\n protected name: string\n protected clipNear: number\n protected clipRadius: number\n protected clipCenter: Vector3\n protected flatShaded: boolean\n protected opacity: number\n protected depthWrite: boolean\n protected side: BufferSide\n protected wireframe: boolean\n protected colorData: ColorData\n protected colorScheme: string\n protected colorScale: string | string[]\n protected colorReverse: boolean\n protected colorValue: number\n protected colorDomain: number[]\n protected colorMode: ColorMode\n protected roughness: number\n protected metalness: number\n protected diffuse: GenericColor\n protected diffuseInterior?: boolean\n protected useInteriorColor?: boolean\n protected interiorColor: GenericColor\n protected interiorDarkening: number\n protected disablePicking: boolean\n protected sphereDetail: number\n protected radialSegments: number\n protected openEnded: boolean\n protected disableImpostor: boolean\n protected disposed: boolean\n\n protected matrix: Matrix4\n\n private quality: string\n visible: boolean\n\n protected manualAttach: ()=> any\n\n protected toBePrepared: boolean\n\n [key: string]: any\n\n constructor (object: any, viewer: Viewer, params: Partial) {\n // eslint-disable-next-line no-unused-vars\n // const p = params || {}\n\n this.type = ''\n\n this.parameters = {\n\n lazy: {\n type: 'boolean'\n },\n\n clipNear: {\n type: 'range', step: 1, max: 100, min: 0, buffer: true\n },\n clipRadius: {\n type: 'number', precision: 1, max: 1000, min: 0, buffer: true\n },\n clipCenter: {\n type: 'vector3', precision: 1, buffer: true\n },\n flatShaded: {\n type: 'boolean', buffer: true\n },\n opacity: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n depthWrite: {\n type: 'boolean', buffer: true\n },\n side: {\n type: 'select',\n buffer: true,\n options: { front: 'front', back: 'back', double: 'double' }\n },\n wireframe: {\n type: 'boolean', buffer: true\n },\n\n colorData: {\n type: 'hidden',\n update: 'color',\n },\n\n colorScheme: {\n type: 'select',\n update: 'color',\n options: {}\n },\n colorScale: {\n type: 'select',\n update: 'color',\n options: ColormakerRegistry.getScales()\n },\n colorReverse: {\n type: 'boolean', update: 'color'\n },\n colorValue: {\n type: 'color', update: 'color'\n },\n colorDomain: {\n type: 'hidden', update: 'color'\n },\n colorMode: {\n type: 'select',\n update: 'color',\n options: ColormakerRegistry.getModes()\n },\n\n roughness: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n metalness: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n diffuse: {\n type: 'color', buffer: true\n },\n\n diffuseInterior: {\n type: 'boolean', buffer: true\n },\n useInteriorColor: {\n type: 'boolean', buffer: true\n },\n interiorColor: {\n type: 'color', buffer: true\n },\n interiorDarkening: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n\n matrix: {\n type: 'hidden', buffer: true\n },\n\n disablePicking: {\n type: 'boolean', rebuild: true\n }\n\n }\n\n /**\n * @type {Viewer}\n */\n this.viewer = viewer\n\n /**\n * Counter that keeps track of tasks related to the creation of\n * the representation, including surface calculations.\n * @type {Counter}\n */\n this.tasks = new Counter()\n\n /**\n * @type {Queue}\n * @private\n */\n this.queue = new Queue(this.make.bind(this))\n\n /**\n * @type {Array}\n * @private\n */\n this.bufferList = []\n\n if (this.parameters.colorScheme) {\n this.parameters.colorScheme.options = ColormakerRegistry.getSchemes()\n }\n\n this.toBePrepared = false\n }\n\n init (params: Partial) {\n const p = params || {}\n\n this.clipNear = defaults(p.clipNear, 0)\n this.clipRadius = defaults(p.clipRadius, 0)\n this.clipCenter = defaults(p.clipCenter, new Vector3())\n this.flatShaded = defaults(p.flatShaded, false)\n this.side = defaults(p.side, 'double')\n this.opacity = defaults(p.opacity, 1.0)\n this.depthWrite = defaults(p.depthWrite, true)\n this.wireframe = defaults(p.wireframe, false)\n\n this.setColor(p.color, p)\n\n this.colorData = defaults(p.colorData, undefined)\n this.colorScheme = defaults(p.colorScheme, 'uniform')\n this.colorScale = defaults(p.colorScale, '')\n this.colorReverse = defaults(p.colorReverse, false)\n this.colorValue = defaults(p.colorValue, 0x909090)\n this.colorDomain = defaults(p.colorDomain, undefined)\n this.colorMode = defaults(p.colorMode, 'hcl')\n\n this.visible = defaults(p.visible, true)\n this.quality = defaults(p.quality, undefined)\n\n this.roughness = defaults(p.roughness, 0.4)\n this.metalness = defaults(p.metalness, 0.0)\n this.diffuse = defaults(p.diffuse, 0xffffff)\n\n this.diffuseInterior = defaults(p.diffuseInterior, false)\n this.useInteriorColor = defaults(p.useInteriorColor, false)\n this.interiorColor = defaults(p.interiorColor, 0x222222)\n this.interiorDarkening = defaults(p.interiorDarkening, 0)\n\n this.lazy = defaults(p.lazy, false)\n this.lazyProps = {\n build: false,\n bufferParams: {},\n what: {}\n }\n\n this.matrix = defaults(p.matrix, new Matrix4())\n\n this.disablePicking = defaults(p.disablePicking, false)\n\n // handle common parameters when applicable\n\n const tp = this.parameters\n\n if (tp.sphereDetail === true) {\n tp.sphereDetail = {\n type: 'integer', max: 3, min: 0, rebuild: 'impostor'\n }\n }\n if (tp.radialSegments === true) {\n tp.radialSegments = {\n type: 'integer', max: 25, min: 5, rebuild: 'impostor'\n }\n }\n if (tp.openEnded === true) {\n tp.openEnded = {\n type: 'boolean', rebuild: 'impostor', buffer: true\n }\n }\n if (tp.disableImpostor === true) {\n tp.disableImpostor = {\n type: 'boolean', rebuild: true\n }\n }\n\n if (p.quality === 'low') {\n if (tp.sphereDetail) this.sphereDetail = 0\n if (tp.radialSegments) this.radialSegments = 5\n } else if (p.quality === 'medium') {\n if (tp.sphereDetail) this.sphereDetail = 1\n if (tp.radialSegments) this.radialSegments = 10\n } else if (p.quality === 'high') {\n if (tp.sphereDetail) this.sphereDetail = 2\n if (tp.radialSegments) this.radialSegments = 20\n } else {\n if (tp.sphereDetail) {\n this.sphereDetail = defaults(p.sphereDetail, 1)\n }\n if (tp.radialSegments) {\n this.radialSegments = defaults(p.radialSegments, 10)\n }\n }\n\n if (tp.openEnded) {\n this.openEnded = defaults(p.openEnded, true)\n }\n\n if (tp.disableImpostor) {\n this.disableImpostor = defaults(p.disableImpostor, false)\n }\n\n }\n\n getColorParams (p?: {[k: string]: any}): { scheme: string, [k: string]: any } & ColormakerParameters {\n return Object.assign({\n\n data: this.colorData,\n scheme: this.colorScheme,\n scale: this.colorScale,\n reverse: this.colorReverse,\n value: this.colorValue,\n domain: this.colorDomain,\n mode: this.colorMode,\n colorSpace: this.colorSpace,\n\n }, p)\n }\n\n getBufferParams (p: {[k: string]: any} = {}) {\n return Object.assign({\n\n clipNear: this.clipNear,\n clipRadius: this.clipRadius,\n clipCenter: this.clipCenter,\n flatShaded: this.flatShaded,\n opacity: this.opacity,\n depthWrite: this.depthWrite,\n side: this.side,\n wireframe: this.wireframe,\n\n roughness: this.roughness,\n metalness: this.metalness,\n diffuse: this.diffuse,\n\n diffuseInterior: this.diffuseInterior,\n useInteriorColor: this.useInteriorColor,\n interiorColor: this.interiorColor,\n interiorDarkening: this.interiorDarkening,\n\n matrix: this.matrix,\n\n disablePicking: this.disablePicking\n\n }, p)\n }\n\n setColor (value: number | string | Color | undefined , p?: Partial) {\n const types = Object.keys(ColormakerRegistry.getSchemes())\n\n if (typeof value === 'string' && types.includes(value.toLowerCase())) {\n if (p) {\n p.colorScheme = value\n } else {\n this.setParameters({ colorScheme: value })\n }\n } else if (value !== undefined) {\n let val = new Color(value as string).getHex() //TODO\n if (p) {\n p.colorScheme = 'uniform'\n p.colorValue = val\n } else {\n this.setParameters({\n colorScheme: 'uniform', colorValue: val\n })\n }\n }\n\n return this\n }\n\n // TODO\n prepare (cb: ()=> void) {\n\n }\n\n create () {\n // this.bufferList.length = 0;\n }\n\n update (what?: any) {\n this.build()\n }\n\n build (updateWhat?: {[k: string]: boolean}) {\n if (this.lazy && (!this.visible || !this.opacity)) {\n this.lazyProps.build = true\n return\n }\n\n if (!this.toBePrepared) {\n this.tasks.increment()\n this.make()\n return\n }\n\n // don't let tasks accumulate\n if (this.queue.length() > 0) {\n this.tasks.change(1 - this.queue.length())\n this.queue.kill()\n } else {\n this.tasks.increment()\n }\n\n this.queue.push(updateWhat || false)\n }\n\n make (updateWhat?: boolean, callback?: () => void) {\n if (Debug) Log.time('Representation.make ' + this.type)\n\n const _make = () => {\n if (updateWhat) {\n this.update(updateWhat)\n this.viewer.requestRender()\n this.tasks.decrement()\n if (callback) callback()\n } else {\n this.clear()\n this.create()\n if (!this.manualAttach && !this.disposed) {\n if (Debug) Log.time('Representation.attach ' + this.type)\n this.attach(() => {\n if (Debug) Log.timeEnd('Representation.attach ' + this.type)\n this.tasks.decrement()\n if (callback) callback()\n })\n }\n }\n\n if (Debug) Log.timeEnd('Representation.make ' + this.type)\n }\n\n if (this.toBePrepared) {\n this.prepare(_make)\n } else {\n _make()\n }\n }\n\n attach (callback: () => void) {\n this.setVisibility(this.visible)\n\n callback()\n }\n\n /**\n * Set the visibility of the representation\n * @param {Boolean} value - visibility flag\n * @param {Boolean} [noRenderRequest] - whether or not to request a re-render from the viewer\n * @return {Representation} this object\n */\n setVisibility (value: boolean, noRenderRequest?: boolean): Representation {\n this.visible = value\n\n if (this.visible && this.opacity) {\n const lazyProps = this.lazyProps\n const bufferParams = lazyProps.bufferParams\n const what = lazyProps.what\n\n if (lazyProps.build) {\n lazyProps.build = false\n this.build()\n return this\n } else if (Object.keys(bufferParams).length || Object.keys(what).length) {\n lazyProps.bufferParams = {}\n lazyProps.what = {}\n this.updateParameters(bufferParams, what)\n }\n }\n\n this.bufferList.forEach(function (buffer) {\n buffer.setVisibility(value)\n })\n\n if (!noRenderRequest) this.viewer.requestRender()\n\n return this\n }\n\n /**\n * Set the visibility of the representation\n * @param {RepresentationParameters} params - parameters object\n * @param {Object} [what] - buffer data attributes to be updated,\n * note that this needs to be implemented in the\n * derived classes. Generally it allows more\n * fine-grained control over updating than\n * forcing a rebuild.\n * @param {Boolean} what.position - update position data\n * @param {Boolean} what.color - update color data\n * @param {Boolean} [rebuild] - whether or not to rebuild the representation\n * @return {Representation} this object\n */\n setParameters (params: Partial, what:{[propName: string]: any} = {}, rebuild = false) {\n const p = params || {}\n const tp = this.parameters\n const bufferParams: BufferParameters = {}\n\n if (!this.opacity && p.opacity !== undefined) {\n if (this.lazyProps.build) {\n this.lazyProps.build = false\n rebuild = true\n } else {\n Object.assign(bufferParams, this.lazyProps.bufferParams)\n Object.assign(what, this.lazyProps.what)\n this.lazyProps.bufferParams = {}\n this.lazyProps.what = {}\n }\n }\n\n this.setColor(p.color, p)\n\n for (let name in p) {\n if (p[ name ] === undefined) continue\n if (tp[ name ] == undefined ) continue // Skip nulls as well as undefined\n\n if (tp[ name ].int) p[ name ] = parseInt(p[ name ] as string)\n if (tp[ name ].float) p[ name ] = parseFloat(p[ name ] as string)\n\n // no value change\n if (p[ name ] === this[ name ] && (\n !p[ name ].equals || p[ name ].equals(this[ name ])\n )) continue\n\n if (this[ name ] && this[ name ].copy && p[ name ].copy) {\n this[ name ].copy(p[ name ])\n } else if (this[ name ] && this[ name ].set) {\n this[ name ].set(p[ name ])\n } else {\n this[ name ] = p[ name ]\n }\n\n // buffer param\n if (tp[ name ].buffer) {\n if (tp[ name ].buffer === true) {\n (bufferParams[ name as keyof BufferParameters ] as any) = p[ name ]\n } else {\n let key: (keyof BufferParameters) = tp[ name ].buffer;\n (bufferParams[ key ] as any) = p[ name ]\n }\n }\n\n // mark for update\n if (tp[ name ].update) {\n what[ tp[ name ].update ] = true\n }\n\n // mark for rebuild\n if (tp[ name ].rebuild &&\n !(tp[ name ].rebuild === 'impostor' &&\n ExtensionFragDepth && !this.disableImpostor)\n ) {\n rebuild = true\n }\n }\n\n //\n\n if (rebuild) {\n this.build()\n } else {\n this.updateParameters(bufferParams, what)\n }\n\n return this\n }\n\n updateParameters (bufferParams: BufferParameters | {} = {}, what?: any) {\n if (this.lazy && (!this.visible || !this.opacity) && bufferParams.hasOwnProperty('opacity') === false) {\n Object.assign(this.lazyProps.bufferParams, bufferParams)\n Object.assign(this.lazyProps.what, what)\n return\n }\n\n this.bufferList.forEach(function (buffer) {\n buffer.setParameters(bufferParams)\n })\n\n if (Object.keys(what).length) {\n this.update(what) // update buffer attribute\n }\n\n this.viewer.requestRender()\n }\n\n getParameters () {\n const params: Partial = {\n lazy: this.lazy,\n visible: this.visible,\n quality: this.quality\n }\n\n Object.keys(this.parameters).forEach(name => {\n if (this.parameters[ name ] !== null) {\n params[ name ] = this[ name ]\n }\n })\n\n return params\n }\n\n clear () {\n this.bufferList.forEach(buffer => {\n this.viewer.remove(buffer)\n buffer.dispose()\n })\n this.bufferList.length = 0\n\n this.viewer.requestRender()\n }\n\n dispose () {\n this.disposed = true\n this.queue.kill()\n this.tasks.dispose()\n this.clear()\n }\n}\n\nexport default Representation\n","/**\n * @file Worker\n * @author Alexander Rose \n * @private\n */\n\nimport { Log, Debug, WorkerRegistry } from '../globals'\n\nexport default class _Worker {\n\n pending = 0\n postCount = 0\n onmessageDict: { [k: number]: Function|undefined } = {}\n onerrorDict: { [k: number]: Function|undefined } = {}\n\n name: string\n blobUrl: string\n worker: Worker\n\n constructor (name: string) {\n\n this.name = name\n this.blobUrl = window.URL.createObjectURL(WorkerRegistry.get(name))\n this.worker = new Worker(this.blobUrl)\n\n WorkerRegistry.activeWorkerCount += 1\n\n this.worker.onmessage = (event: any) => {\n this.pending -= 1\n const postId = event.data.__postId\n\n if (Debug) Log.timeEnd('Worker.postMessage ' + name + ' #' + postId)\n\n const onmessage = this.onmessageDict[ postId ]\n if (onmessage) {\n onmessage.call(this.worker, event)\n } else {\n // Log.debug('No onmessage', postId, name)\n }\n\n delete this.onmessageDict[ postId ]\n delete this.onerrorDict[ postId ]\n }\n\n this.worker.onerror = (event: any) => {\n this.pending -= 1\n if (event.data) {\n const postId = event.data.__postId\n\n const onerror = this.onerrorDict[ postId ]\n if (onerror) {\n onerror.call(this.worker, event)\n } else {\n Log.error('Worker.onerror', postId, name, event)\n }\n\n delete this.onmessageDict[ postId ]\n delete this.onerrorDict[ postId ]\n } else {\n Log.error('Worker.onerror', name, event)\n }\n }\n }\n\n post (aMessage: any = {}, transferList?: any, onmessage?: Function, onerror?: Function) {\n this.onmessageDict[ this.postCount ] = onmessage\n this.onerrorDict[ this.postCount ] = onerror\n\n aMessage.__name = this.name\n aMessage.__postId = this.postCount\n aMessage.__debug = Debug\n\n if (Debug) Log.time(`Worker.postMessage ${this.name} #${this.postCount}`)\n\n try {\n this.worker.postMessage(aMessage, transferList)\n } catch (error) {\n Log.error('worker.post:', error)\n this.worker.postMessage(aMessage)\n }\n\n this.pending += 1\n this.postCount += 1\n\n return this\n }\n\n terminate () {\n if (this.worker) {\n this.worker.terminate()\n window.URL.revokeObjectURL(this.blobUrl)\n WorkerRegistry.activeWorkerCount -= 1\n } else {\n Log.log('no worker to terminate')\n }\n }\n}\n","/**\n * @file Worker Pool\n * @author Alexander Rose \n * @private\n */\n\nimport Worker from './worker'\n\nclass WorkerPool {\n maxCount: number\n pool: Worker[] = []\n count = 0\n name: string\n\n constructor (name: string, maxCount = 2) {\n this.maxCount = Math.min(8, maxCount)\n this.name = name\n }\n\n post (aMessage: any = {}, transferList?: any, onmessage?: Function, onerror?: Function) {\n const worker = this.getNextWorker()\n if (worker) {\n worker.post(aMessage, transferList, onmessage, onerror)\n } else {\n console.error('unable to get worker from pool')\n }\n\n return this\n }\n\n terminate () {\n this.pool.forEach(function (worker) {\n worker.terminate()\n })\n }\n\n getNextWorker () {\n let nextWorker\n let minPending = Infinity\n\n for (let i = 0; i < this.maxCount; ++i) {\n if (i >= this.count) {\n nextWorker = new Worker(this.name)\n this.pool.push(nextWorker)\n this.count += 1\n break\n }\n\n const worker = this.pool[ i ]\n\n if (worker.pending === 0) {\n nextWorker = worker\n break\n } else if (worker.pending < minPending) {\n minPending = worker.pending\n nextWorker = worker\n }\n }\n\n return nextWorker\n }\n}\n\nWorkerPool.prototype.constructor = WorkerPool\n\nexport default WorkerPool\n","/**\n * @file Vector Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { NumberArray } from '../types'\nimport { EPS } from './math-constants'\n\n/**\n * Calculate the two intersection points\n * Converted to JavaScript from\n * {@link http://paulbourke.net/geometry/pointlineplane/lineline.c}\n */\nexport function lineLineIntersect (p1: Vector3, p2: Vector3, p3: Vector3, p4: Vector3) {\n const p13 = new Vector3()\n const p43 = new Vector3()\n const p21 = new Vector3()\n let d1343, d4321, d1321, d4343, d2121\n let denom, numer\n\n p13.x = p1.x - p3.x\n p13.y = p1.y - p3.y\n p13.z = p1.z - p3.z\n p43.x = p4.x - p3.x\n p43.y = p4.y - p3.y\n p43.z = p4.z - p3.z\n if (Math.abs(p43.x) < EPS && Math.abs(p43.y) < EPS && Math.abs(p43.z) < EPS) { return null }\n\n p21.x = p2.x - p1.x\n p21.y = p2.y - p1.y\n p21.z = p2.z - p1.z\n if (Math.abs(p21.x) < EPS && Math.abs(p21.y) < EPS && Math.abs(p21.z) < EPS) { return null }\n\n d1343 = p13.x * p43.x + p13.y * p43.y + p13.z * p43.z\n d4321 = p43.x * p21.x + p43.y * p21.y + p43.z * p21.z\n d1321 = p13.x * p21.x + p13.y * p21.y + p13.z * p21.z\n d4343 = p43.x * p43.x + p43.y * p43.y + p43.z * p43.z\n d2121 = p21.x * p21.x + p21.y * p21.y + p21.z * p21.z\n\n denom = d2121 * d4343 - d4321 * d4321\n if (Math.abs(denom) < EPS) { return null }\n numer = d1343 * d4321 - d1321 * d4343\n\n const mua = numer / denom\n const mub = (d1343 + d4321 * mua) / d4343\n\n const pa = new Vector3(\n p1.x + mua * p21.x,\n p1.y + mua * p21.y,\n p1.z + mua * p21.z\n )\n const pb = new Vector3(\n p3.x + mub * p43.x,\n p3.y + mub * p43.y,\n p3.z + mub * p43.z\n )\n\n return [ pa, pb ]\n}\n\nexport function calculateMeanVector3 (array: NumberArray) {\n const n = array.length\n const m = n / 3\n\n let x = 0\n let y = 0\n let z = 0\n\n for (let i = 0; i < n; i += 3) {\n x += array[ i + 0 ]\n y += array[ i + 1 ]\n z += array[ i + 2 ]\n }\n\n return new Vector3(x / m, y / m, z / m)\n}\n\nexport function isPointOnSegment (p: Vector3, l1: Vector3, l2: Vector3) {\n const len = l1.distanceTo(l2)\n\n return p.distanceTo(l1) <= len && p.distanceTo(l2) <= len\n}\n\nexport function projectPointOnVector (point: Vector3, vector: Vector3, origin?: Vector3) {\n if (origin) {\n point.sub(origin).projectOnVector(vector).add(origin)\n } else {\n point.projectOnVector(vector)\n }\n\n return point\n}\n\nexport function computeBoundingBox (array: NumberArray) {\n let minX = +Infinity\n let minY = +Infinity\n let minZ = +Infinity\n let maxX = -Infinity\n let maxY = -Infinity\n let maxZ = -Infinity\n for (let i = 0, l = array.length; i < l; i += 3) {\n const x = array[ i ]\n const y = array[ i + 1 ]\n const z = array[ i + 2 ]\n if (x < minX) minX = x\n if (y < minY) minY = y\n if (z < minZ) minZ = z\n if (x > maxX) maxX = x\n if (y > maxY) maxY = y\n if (z > maxZ) maxZ = z\n }\n return [\n v3new([ minX, minY, minZ ]),\n v3new([ maxX, maxY, maxZ ])\n ]\n}\n(computeBoundingBox as any).__deps = [ v3new ]\n\nexport function applyMatrix4toVector3array (m: Float32Array, a: Float32Array) {\n for (let i = 0, il = a.length; i < il; i += 3) {\n const x = a[ i ]\n const y = a[ i + 1 ]\n const z = a[ i + 2 ]\n a[ i ] = m[ 0 ] * x + m[ 4 ] * y + m[ 8 ] * z + m[ 12 ]\n a[ i + 1 ] = m[ 1 ] * x + m[ 5 ] * y + m[ 9 ] * z + m[ 13 ]\n a[ i + 2 ] = m[ 2 ] * x + m[ 6 ] * y + m[ 10 ] * z + m[ 14 ]\n }\n}\n\nexport function applyMatrix3toVector3array (m: Float32Array, a: Float32Array) {\n for (let i = 0, il = a.length; i < il; i += 3) {\n const x = a[ i ]\n const y = a[ i + 1 ]\n const z = a[ i + 2 ]\n a[ i ] = m[ 0 ] * x + m[ 3 ] * y + m[ 6 ] * z\n a[ i + 1 ] = m[ 1 ] * x + m[ 4 ] * y + m[ 7 ] * z\n a[ i + 2 ] = m[ 2 ] * x + m[ 5 ] * y + m[ 8 ] * z\n }\n}\n\nexport function normalizeVector3array (a: Float32Array) {\n for (let i = 0, il = a.length; i < il; i += 3) {\n const x = a[ i ]\n const y = a[ i + 1 ]\n const z = a[ i + 2 ]\n const len2 = x * x + y * y + z * z\n if (len2 > 0) { // avoid divide by zero\n const s = 1 / Math.sqrt(len2)\n a[ i ] = x * s\n a[ i + 1 ] = y * s\n a[ i + 2 ] = z * s\n }\n // else leave as all zeros\n }\n}\n\nexport function v3new (array?: NumberArray) {\n return new Float32Array(array as any || 3) // TODO\n}\n\nexport function v3cross (out: Float32Array, a: Float32Array, b: Float32Array) {\n const ax = a[0]\n const ay = a[1]\n const az = a[2]\n const bx = b[0]\n const by = b[1]\n const bz = b[2]\n out[0] = ay * bz - az * by\n out[1] = az * bx - ax * bz\n out[2] = ax * by - ay * bx\n}\n\nexport function v3dot (a: Float32Array, b: Float32Array) {\n return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]\n}\n\nexport function v3sub (out: Float32Array, a: Float32Array, b: Float32Array) {\n out[0] = a[0] - b[0]\n out[1] = a[1] - b[1]\n out[2] = a[2] - b[2]\n}\n\nexport function v3add (out: Float32Array, a: Float32Array, b: Float32Array) {\n out[0] = a[0] + b[0]\n out[1] = a[1] + b[1]\n out[2] = a[2] + b[2]\n}\n\nexport function v3fromArray (out: Float32Array, array: Float32Array, offset = 0) {\n out[0] = array[offset]\n out[1] = array[offset + 1]\n out[2] = array[offset + 2]\n}\n\nexport function v3toArray (input: Float32Array, array: Float32Array, offset = 0) {\n array[offset] = input[0]\n array[offset + 1] = input[1]\n array[offset + 2] = input[2]\n}\n\nexport function v3forEach (array: Float32Array, fn: (i: Float32Array, j: Float32Array, k: Float32Array) => void, b: Float32Array) {\n const a = v3new()\n for (let i = 0, n = array.length; i < n; i += 3) {\n v3fromArray(a, array, i)\n fn(a, a, b)\n v3toArray(a, array, i)\n }\n}\n(v3forEach as any).__deps = [ v3new, v3fromArray, v3toArray ]\n\nexport function v3length2 (a: Float32Array) {\n return a[0] * a[0] + a[1] * a[1] + a[2] * a[2]\n}\n\nexport function v3length (a: Float32Array) {\n return Math.sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2])\n}\n\nexport function v3divide (out: Float32Array, a: Float32Array, b: Float32Array) {\n out[0] = a[0] / b[0]\n out[1] = a[1] / b[1]\n out[2] = a[2] / b[2]\n}\n\nexport function v3multiply (out: Float32Array, a: Float32Array, b: Float32Array) {\n out[0] = a[0] * b[0]\n out[1] = a[1] * b[1]\n out[2] = a[2] * b[2]\n}\n\nexport function v3divideScalar (out: Float32Array, a: Float32Array, s: number) {\n v3multiplyScalar(out, a, 1 / s)\n}\n(v3divideScalar as any).__deps = [ v3multiplyScalar ]\n\nexport function v3multiplyScalar (out: Float32Array, a: Float32Array, s: number) {\n out[0] = a[0] * s\n out[1] = a[1] * s\n out[2] = a[2] * s\n}\n\nexport function v3normalize (out: Float32Array, a: Float32Array) {\n const length2 = v3length2(a)\n if (length2 == 0) {\n out[0] = a[0]\n out[1] = a[1]\n out[2] = a[2]\n } else {\n v3multiplyScalar(out, a, 1 / Math.sqrt(length2))\n }\n}\n(v3normalize as any).__deps = [ v3multiplyScalar, v3length2 ]\n\nexport function v3subScalar (out: Float32Array, a: Float32Array, s: number) {\n out[0] = a[0] - s\n out[1] = a[1] - s\n out[2] = a[2] - s\n}\n\nexport function v3addScalar (out: Float32Array, a: Float32Array, s: number) {\n out[0] = a[0] + s\n out[1] = a[1] + s\n out[2] = a[2] + s\n}\n\nexport function v3floor (out: Float32Array, a: Float32Array) {\n out[0] = Math.floor(a[0])\n out[1] = Math.floor(a[1])\n out[2] = Math.floor(a[2])\n}\n\nexport function v3ceil (out: Float32Array, a: Float32Array) {\n out[0] = Math.ceil(a[0])\n out[1] = Math.ceil(a[1])\n out[2] = Math.ceil(a[2])\n}\n\nexport function v3round (out: Float32Array, a: Float32Array) {\n out[0] = Math.round(a[0])\n out[1] = Math.round(a[1])\n out[2] = Math.round(a[2])\n}\n\nexport function v3negate (out: Float32Array, a: Float32Array) {\n out[0] = -a[0]\n out[1] = -a[1]\n out[2] = -a[2]\n}\n\nexport function v3angle (a: Float32Array, b: Float32Array) {\n const ax = a[0]\n const ay = a[1]\n const az = a[2]\n const bx = b[0]\n const by = b[1]\n const bz = b[2]\n const cx = ay * bz - az * by\n const cy = az * bx - ax * bz\n const cz = ax * by - ay * bx\n const s = Math.sqrt(cx * cx + cy * cy + cz * cz)\n const c = ax * bx + ay * by + az * bz\n return Math.atan2(s, c)\n}\n","/**\n * @file Dash\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport { WideLineBufferData } from '../buffer/wideline-buffer'\nimport {\n calculateDirectionArray, calculateCenterArray,\n replicateArrayEntries, replicateArray3Entries\n} from '../math/array-utils'\n\nexport function getFixedCountDashData (data: T, segmentCount: number = 9) {\n\n const s = Math.floor(segmentCount / 2)\n const n = data.position1.length / 3\n const sn = s * n\n const sn3 = sn * 3\n const step = 1 / segmentCount\n\n const direction = calculateDirectionArray(data.position1, data.position2)\n const position1 = new Float32Array(sn3)\n const position2 = new Float32Array(sn3)\n\n const v = new Vector3()\n\n for (let i = 0; i < n; ++i) {\n const i3 = i * 3\n v.set(direction[ i3 ], direction[ i3 + 1 ], direction[ i3 + 2 ])\n\n const x = data.position1[ i3 ]\n const y = data.position1[ i3 + 1 ]\n const z = data.position1[ i3 + 2 ]\n\n for (let j = 0; j < s; ++j) {\n const j3 = s * i3 + j * 3\n\n const f1 = step * (j * 2 + 1)\n const f2 = step * (j * 2 + 2)\n\n position1[ j3 ] = x + v.x * f1\n position1[ j3 + 1 ] = y + v.y * f1\n position1[ j3 + 2 ] = z + v.z * f1\n\n position2[ j3 ] = x + v.x * f2\n position2[ j3 + 1 ] = y + v.y * f2\n position2[ j3 + 2 ] = z + v.z * f2\n }\n }\n\n const position = calculateCenterArray(position1, position2) as Float32Array\n const color = replicateArray3Entries(data.color!, s) // TODO\n const color2 = color\n\n const d: any = { position, position1, position2, color, color2 }\n\n if ((data as any).radius) { // TODO\n d.radius = replicateArrayEntries((data as any).radius, s) // TODO\n }\n\n if (data.picking && data.picking.array) {\n data.picking.array = replicateArrayEntries(data.picking.array, s)\n d.picking = data.picking\n }\n if (data.primitiveId) {\n d.primitiveId = replicateArrayEntries(data.primitiveId, s)\n }\n\n return d as T\n}\n\nexport function getFixedLengthDashData (data: T, segmentLength: number = 0.1) {\n\n const direction = calculateDirectionArray(data.position1, data.position2)\n const pos1: number[] = []\n const pos2: number[] = []\n const col: number[] = []\n const rad: number[]|undefined = (data as any).radius ? [] : undefined\n const pick: number[]|undefined = (data as any).picking ? [] : undefined\n const id: number[]|undefined = (data as any).primitiveId ? [] : undefined\n\n const v = new Vector3()\n const n = data.position1.length / 3\n\n let k = 0\n\n for (let i = 0; i < n; ++i) {\n const i3 = i * 3\n v.set(direction[ i3 ], direction[ i3 + 1 ], direction[ i3 + 2 ])\n\n const vl = v.length()\n const segmentCount = vl / segmentLength\n const s = Math.floor(segmentCount / 2)\n const step = 1 / segmentCount\n\n const x = data.position1[ i3 ]\n const y = data.position1[ i3 + 1 ]\n const z = data.position1[ i3 + 2 ]\n\n for (let j = 0; j < s; ++j) {\n const j3 = k * 3 + j * 3\n\n const f1 = step * (j * 2 + 1)\n const f2 = step * (j * 2 + 2)\n\n pos1[ j3 ] = x + v.x * f1\n pos1[ j3 + 1 ] = y + v.y * f1\n pos1[ j3 + 2 ] = z + v.z * f1\n\n pos2[ j3 ] = x + v.x * f2\n pos2[ j3 + 1 ] = y + v.y * f2\n pos2[ j3 + 2 ] = z + v.z * f2\n\n if (data.color) {\n col[ j3 ] = data.color[ i3 ]\n col[ j3 + 1 ] = data.color[ i3 + 1 ]\n col[ j3 + 2 ] = data.color[ i3 + 2 ]\n }\n\n if (rad) rad[ k + j ] = (data as any).radius[ i ]\n if (pick) {\n if ((data as any).picking.array) {\n pick[ k + j ] = (data as any).picking.array[ i ]\n } else {\n pick[ k + j ] = i\n }\n }\n if (id) id[ k + j ] = (data as any).primitiveId[ i ]\n }\n\n k += s\n }\n\n const position1 = new Float32Array(pos1)\n const position2 = new Float32Array(pos2)\n const position = calculateCenterArray(position1, position2) as Float32Array\n const color = new Float32Array(col)\n const color2 = color\n\n const d: any = { position, position1, position2, color, color2 }\n\n if (rad) d.radius = new Float32Array(rad)\n if (pick && data.picking) {\n data.picking.array = new Float32Array(pick)\n d.picking = data.picking\n }\n if (id) d.primitiveId = new Float32Array(id)\n\n return d as T\n}\n\nexport function getFixedLengthWrappedDashData (data: T, segmentLength: number = 0.1) {\n\n const direction = calculateDirectionArray(data.position1, data.position2)\n const pos1: number[] = []\n const pos2: number[] = []\n const col: number[] = []\n const rad: number[]|undefined = (data as any).radius ? [] : undefined\n const pick: number[]|undefined = (data as any).picking ? [] : undefined\n const id: number[]|undefined = (data as any).primitiveId ? [] : undefined\n\n const v = new Vector3()\n const n = data.position1.length / 3\n\n let remaining = segmentLength\n let drawing = true\n\n let k = 0\n let k3 = 0\n let kprev = 0\n\n for (let i = 0; i < n; ++i) {\n const i3 = i * 3\n const x = data.position1[ i3 ]\n const y = data.position1[ i3 + 1 ]\n const z = data.position1[ i3 + 2 ]\n\n v.set(direction[ i3 ], direction[ i3 + 1 ], direction[ i3 + 2 ])\n const vl = v.length()\n\n if (drawing) {\n pos1[ k3 ] = x\n pos1[ k3 + 1 ] = y\n pos1[ k3 + 2 ] = z\n }\n\n let dist = remaining\n const inv = 1 / vl\n while (dist < vl) {\n const a = drawing ? pos2 : pos1\n a[ k3 ] = x + v.x * dist * inv\n a[ k3 + 1 ] = y + v.y * dist * inv\n a[ k3 + 2 ] = z + v.z * dist * inv\n if (drawing) {\n k++\n k3 = k * 3\n }\n drawing = !drawing\n remaining = segmentLength\n dist += segmentLength\n }\n\n if (drawing) {\n pos2[ k3 ] = data.position2[ i3 ]\n pos2[ k3 + 1 ] = data.position2[ i3 + 1 ]\n pos2[ k3 + 2 ] = data.position2[ i3 + 2 ]\n k++\n k3 = k * 3\n }\n\n remaining = dist - vl\n\n for (let j = kprev; j < k ; j++){\n if (data.color) {\n const j3 = j * 3\n col[ j3 ] = data.color[ i3 ]\n col[ j3 + 1 ] = data.color[ i3 + 1 ]\n col[ j3 + 2 ] = data.color[ i3 + 2 ]\n }\n\n if (rad) rad[ j ] = (data as any).radius[ i ]\n if (pick) {\n if ((data as any).picking.array) {\n pick[ j ] = (data as any).picking.array[ i ]\n } else {\n pick[ j ] = i\n }\n }\n if (id) id[ j ] = (data as any).primitiveId[ i ]\n }\n\n kprev = k\n\n }\n\n if (!drawing && n > 0) {\n const k3 = k * 3\n pos2[ k3 ] = data.position2[ 3 * n - 3 ]\n pos2[ k3 + 1 ] = data.position2[ 3 * n - 2 ]\n pos2[ k3 + 1 ] = data.position2[ 3 * n - 1 ]\n }\n\n const position1 = new Float32Array(pos1)\n const position2 = new Float32Array(pos2)\n const position = calculateCenterArray(position1, position2) as Float32Array\n const color = new Float32Array(col)\n const color2 = color\n\n const d: any = { position, position1, position2, color, color2 }\n\n if (rad) d.radius = new Float32Array(rad)\n if (pick && data.picking) {\n data.picking.array = new Float32Array(pick)\n d.picking = data.picking\n }\n if (id) d.primitiveId = new Float32Array(id)\n\n return d as T\n}\n","/**\n * @file Primitive\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Color, Box3 } from 'three'\n\nimport { BufferRegistry, PickerRegistry } from '../globals'\nimport Shape from './shape'\nimport { getFixedLengthDashData } from './dash'\n\nfunction addElement (elm: any, array: any[]) {\n if (elm.toArray !== undefined) {\n elm = elm.toArray()\n } else if (elm.x !== undefined) {\n elm = [ elm.x, elm.y, elm.z ]\n } else if (elm.r !== undefined) {\n elm = [ elm.r, elm.g, elm.b ]\n }\n array.push.apply(array, elm)\n}\n\nconst tmpVec = new Vector3()\n\nexport type PrimitiveFields = { [k: string]: string }\n\n/**\n * Base class for geometry primitives\n * @interface\n */\nexport abstract class Primitive {\n static type = ''\n static fields: PrimitiveFields = {}\n\n static get Picker () { return PickerRegistry.get(this.type) }\n static get Buffer () { return BufferRegistry.get(this.type) }\n\n static getShapeKey (name: string) {\n return this.type + name[0].toUpperCase() + name.substr(1)\n }\n\n static expandBoundingBox (box: Box3, data: any) {}\n\n static valueToShape (shape: Shape, name: string, value: any) {\n const data = shape._primitiveData[this.getShapeKey(name)]\n const type = this.fields[name]\n\n switch (type) {\n case 'v3':\n case 'c':\n addElement(value, data)\n break\n default:\n data.push(value)\n }\n }\n\n static objectToShape (shape: Shape, data: any) {\n Object.keys(this.fields).forEach(name => {\n this.valueToShape(shape, name, data[name])\n })\n this.valueToShape(shape, 'name', data.name)\n this.expandBoundingBox(shape.boundingBox, data)\n }\n\n static valueFromShape (shape: Shape, pid: number, name: string) {\n const data = shape._primitiveData[this.getShapeKey(name)]\n const type = this.fields[name]\n\n switch (type) {\n case 'v3':\n return new Vector3().fromArray(data, 3 * pid)\n case 'c':\n return new Color().fromArray(data, 3 * pid)\n default:\n return data[pid]\n }\n }\n\n static objectFromShape (shape: Shape, pid: number) {\n let name = this.valueFromShape(shape, pid, 'name')\n if (name === undefined) {\n name = `${this.type}: ${pid} (${shape.name})`\n }\n const o: any = { shape, name }\n\n Object.keys(this.fields).forEach(name => {\n o[name] = this.valueFromShape(shape, pid, name)\n })\n\n return o\n }\n\n static arrayFromShape (shape: Shape, name: string) {\n const data = shape._primitiveData[this.getShapeKey(name)]\n const type = this.fields[name]\n\n switch (type) {\n case 's':\n return data\n default:\n return new Float32Array(data)\n }\n }\n\n static dataFromShape (shape: Shape) {\n const data: any = {}\n\n if (this.Picker) {\n data.picking = new this.Picker(shape)\n }\n\n Object.keys(this.fields).forEach(name => {\n data[name] = this.arrayFromShape(shape, name)\n })\n\n return data\n }\n\n static bufferFromShape (shape: Shape, params: any) {\n return new this.Buffer(this.dataFromShape(shape), params)\n }\n}\n\n/**\n * Sphere geometry primitive\n */\nexport class SpherePrimitive extends Primitive {\n static type = 'sphere'\n\n static fields = {\n position: 'v3',\n color: 'c',\n radius: 'f'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n return this.valueFromShape(shape, pid, 'position')\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position))\n }\n}\n\n/**\n * Box geometry primitive\n */\nexport class BoxPrimitive extends Primitive {\n static type = 'box'\n\n static fields = {\n position: 'v3',\n color: 'c',\n size: 'f',\n heightAxis: 'v3',\n depthAxis: 'v3'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n return this.valueFromShape(shape, pid, 'position')\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position))\n }\n}\n\n/**\n * Octahedron geometry primitive\n */\nexport class OctahedronPrimitive extends BoxPrimitive {\n static type = 'octahedron'\n}\n\n/**\n * Tetrahedron geometry primitive\n */\nexport class TetrahedronPrimitive extends BoxPrimitive {\n static type = 'tetrahedron'\n}\n\n/**\n * Cylinder geometry primitive\n */\nexport class CylinderPrimitive extends Primitive {\n static type = 'cylinder'\n\n static fields = {\n position1: 'v3',\n position2: 'v3',\n color: 'c',\n radius: 'f'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n const p1 = this.valueFromShape(shape, pid, 'position1')\n const p2 = this.valueFromShape(shape, pid, 'position2')\n return p1.add(p2).multiplyScalar(0.5)\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position1))\n box.expandByPoint(tmpVec.fromArray(data.position2))\n }\n\n static bufferFromShape (shape: Shape, params: any = {}) {\n let data = this.dataFromShape(shape)\n if (this.type === 'cylinder' && params.dashedCylinder) {\n data = getFixedLengthDashData(data)\n }\n return new this.Buffer(data, params)\n }\n}\n\n/**\n * Arrow geometry primitive\n */\nexport class ArrowPrimitive extends CylinderPrimitive {\n static type = 'arrow'\n}\n\n/**\n * Cone geometry primitive\n */\nexport class ConePrimitive extends CylinderPrimitive {\n static type = 'cone'\n}\n\n/**\n * Ellipsoid geometry primitive\n */\nexport class EllipsoidPrimitive extends SpherePrimitive {\n static type = 'ellipsoid'\n\n static fields = {\n position: 'v3',\n color: 'c',\n radius: 'f',\n majorAxis: 'v3',\n minorAxis: 'v3'\n }\n}\n\n/**\n * Torus geometry primitive\n */\nexport class TorusPrimitive extends EllipsoidPrimitive {\n static type = 'torus'\n}\n\n/**\n * Text geometry primitive\n */\nexport class TextPrimitive extends Primitive {\n static type = 'text'\n\n static fields = {\n position: 'v3',\n color: 'c',\n size: 'f',\n text: 's'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n return this.valueFromShape(shape, pid, 'position')\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position))\n }\n}\n\n/**\n * Point primitive\n */\nexport class PointPrimitive extends Primitive {\n static type = 'point'\n\n static fields = {\n position: 'v3',\n color: 'c',\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n return this.valueFromShape(shape, pid, 'position')\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position))\n }\n}\n\n/**\n * Wideline geometry primitive\n */\nexport class WidelinePrimitive extends Primitive {\n static type = 'wideline'\n\n static fields = {\n position1: 'v3',\n position2: 'v3',\n color: 'c'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n const p1 = this.valueFromShape(shape, pid, 'position1')\n const p2 = this.valueFromShape(shape, pid, 'position2')\n return p1.add(p2).multiplyScalar(0.5)\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position1))\n box.expandByPoint(tmpVec.fromArray(data.position2))\n }\n}\n","/**\n * @file Spatial Hash\n * @author Alexander Rose \n * @private\n */\n\nimport { Box3 } from 'three'\n\nexport type Positions = {\n x: ArrayLike,\n y: ArrayLike,\n z: ArrayLike,\n count?:number\n}\n\nfunction createBoundingBox(positions: Positions) {\n const { x, y, z } = positions\n const boundingBox = new Box3()\n const count = x.length\n const { min, max } = boundingBox\n\n for (let i = 0; i < count; i++) {\n min.x = Math.min(x[i], min.x)\n min.y = Math.min(y[i], min.y)\n min.z = Math.min(z[i], min.z)\n max.x = Math.max(x[i], max.x)\n max.y = Math.max(y[i], max.y)\n max.z = Math.max(z[i], max.z)\n }\n\n return boundingBox\n}\n\nexport default class SpatialHash {\n exp = 3\n\n minX: number\n minY: number\n minZ: number\n\n boundX: number\n boundY: number\n boundZ: number\n\n grid: Uint32Array\n bucketCount: Uint16Array\n bucketOffset: Uint32Array\n bucketArray: Int32Array\n\n xArray: ArrayLike\n yArray: ArrayLike\n zArray: ArrayLike\n\n constructor(positions: Positions, boundingBox?: Box3) {\n const bb = boundingBox || createBoundingBox(positions)\n this.minX = bb.min.x\n this.minY = bb.min.y\n this.minZ = bb.min.z\n this.boundX = ((bb.max.x - this.minX) >> this.exp) + 1\n this.boundY = ((bb.max.y - this.minY) >> this.exp) + 1\n this.boundZ = ((bb.max.z - this.minZ) >> this.exp) + 1\n\n const n = this.boundX * this.boundY * this.boundZ\n const an = (positions.count !== undefined) ? positions.count : positions.x.length\n\n const xArray = positions.x\n const yArray = positions.y\n const zArray = positions.z\n\n let count = 0\n const grid = new Uint32Array(n)\n const bucketIndex = new Int32Array(an)\n for (let i = 0; i < an; ++i) {\n const x = (xArray[ i ] - this.minX) >> this.exp\n const y = (yArray[ i ] - this.minY) >> this.exp\n const z = (zArray[ i ] - this.minZ) >> this.exp\n const idx = (((x * this.boundY) + y) * this.boundZ) + z\n if ((grid[ idx ] += 1) === 1) {\n count += 1\n }\n bucketIndex[ i ] = idx\n }\n\n const bucketCount = new Uint16Array(count)\n for (let i = 0, j = 0; i < n; ++i) {\n const c = grid[ i ]\n if (c > 0) {\n grid[ i ] = j + 1\n bucketCount[ j ] = c\n j += 1\n }\n }\n\n const bucketOffset = new Uint32Array(count)\n for (let i = 1; i < count; ++i) {\n bucketOffset[ i ] += bucketOffset[ i - 1 ] + bucketCount[ i - 1 ]\n }\n\n const bucketFill = new Uint16Array(count)\n const bucketArray = new Int32Array(an)\n for (let i = 0; i < an; ++i) {\n const bucketIdx = grid[ bucketIndex[ i ] ]\n if (bucketIdx > 0) {\n const k = bucketIdx - 1\n bucketArray[ bucketOffset[ k ] + bucketFill[ k ] ] = i\n bucketFill[ k ] += 1\n }\n }\n\n this.grid = grid\n this.bucketCount = bucketCount\n this.bucketOffset = bucketOffset\n this.bucketArray = bucketArray\n\n this.xArray = xArray\n this.yArray = yArray\n this.zArray = zArray\n }\n\n within (x: number, y: number, z: number, r: number) {\n const result: number[] = []\n\n this.eachWithin(x, y, z, r, atomIndex => result.push(atomIndex))\n\n return result\n }\n\n eachWithin (x: number, y: number, z: number, r: number, callback: (atomIndex: number, dSq: number) => void) {\n const rSq = r * r\n\n const loX = Math.max(0, (x - r - this.minX) >> this.exp)\n const loY = Math.max(0, (y - r - this.minY) >> this.exp)\n const loZ = Math.max(0, (z - r - this.minZ) >> this.exp)\n\n const hiX = Math.min(this.boundX, ((x + r - this.minX) >> this.exp) + 1)\n const hiY = Math.min(this.boundY, ((y + r - this.minY) >> this.exp) + 1)\n const hiZ = Math.min(this.boundZ, ((z + r - this.minZ) >> this.exp) + 1)\n\n for (let ix = loX; ix < hiX; ++ix) {\n for (let iy = loY; iy < hiY; ++iy) {\n for (let iz = loZ; iz < hiZ; ++iz) {\n const idx = (((ix * this.boundY) + iy) * this.boundZ) + iz\n const bucketIdx = this.grid[ idx ]\n\n if (bucketIdx > 0) {\n const k = bucketIdx - 1\n const offset = this.bucketOffset[ k ]\n const count = this.bucketCount[ k ]\n const end = offset + count\n\n for (let i = offset; i < end; ++i) {\n const atomIndex = this.bucketArray[ i ]\n const dx = this.xArray[ atomIndex ] - x\n const dy = this.yArray[ atomIndex ] - y\n const dz = this.zArray[ atomIndex ] - z\n\n const dSq = dx * dx + dy * dy + dz * dz\n if (dSq <= rSq) callback(atomIndex, dSq)\n }\n }\n }\n }\n }\n }\n}","/**\n * @file Store\n * @author Alexander Rose \n * @private\n */\n\nimport { Log } from '../globals'\nimport { getTypedArray, TypedArrayString } from '../utils'\n\nexport type StoreField = [string, number, TypedArrayString]\n\n/**\n * Store base class\n * @interface\n */\nexport default class Store {\n [k: string]: any\n\n length: number\n count: number\n\n _fields: StoreField[]\n get _defaultFields(): StoreField[] { return [] }\n\n /**\n * @param {Integer} [size] - initial size\n */\n constructor (size = 0) {\n this._fields = this._defaultFields\n this._init(0)\n }\n\n /**\n * Initialize the store\n * @param {Integer} size - size to initialize\n * @return {undefined}\n */\n _init (size: number) {\n this.length = size\n this.count = 0\n\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const [name, size, type]: StoreField = this._fields[ i ]\n this._initField(name, size, type)\n }\n }\n\n /**\n * Initialize a field\n * @param {String} name - field name\n * @param {Integer} size - element size\n * @param {String} type - data type, one of int8, int16, int32,\n * uint8, uint16, uint32, float32\n * @return {undefined}\n */\n _initField (name: string, size: number, type: TypedArrayString) {\n this[ name ] = getTypedArray(type, this.length * size)\n }\n\n /**\n * Add a field\n * @param {String} name - field name\n * @param {Integer} size - element size\n * @param {String} type - data type, one of int8, int16, int32,\n * uint8, uint16, uint32, float32\n * @return {undefined}\n */\n addField (name: string, size: number, type: TypedArrayString) {\n this._fields.push([name, size, type])\n this._initField(name, size, type)\n }\n\n /**\n * Resize the store to the new size\n * @param {Integer} size - new size\n * @return {undefined}\n */\n resize (size?: number) {\n // Log.time( \"Store.resize\" );\n\n this.length = Math.round(size || 0)\n this.count = Math.min(this.count, this.length)\n\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const name = this._fields[ i ][ 0 ]\n const itemSize = this._fields[ i ][ 1 ]\n const arraySize = this.length * itemSize\n const tmpArray = new this[ name ].constructor(arraySize)\n\n if (this[ name ].length > arraySize) {\n tmpArray.set(this[ name ].subarray(0, arraySize))\n } else {\n tmpArray.set(this[ name ])\n }\n this[ name ] = tmpArray\n }\n\n // Log.timeEnd( \"Store.resize\" );\n }\n\n /**\n * Resize the store to 1.5 times its current size if full\n * @return {undefined}\n */\n growIfFull () {\n if (this.count >= this.length) {\n const size = Math.round(this.length * 1.5)\n this.resize(Math.max(256, size))\n }\n }\n\n /**\n * Copy data from one store to another\n * @param {Store} other - store to copy from\n * @param {Integer} thisOffset - offset to start copying to\n * @param {Integer} otherOffset - offset to start copying from\n * @param {Integer} length - number of entries to copy\n * @return {undefined}\n */\n copyFrom (other: Store, thisOffset: number, otherOffset: number, length: number) {\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const name = this._fields[ i ][ 0 ]\n const itemSize = this._fields[ i ][ 1 ]\n const thisField = this[ name ]\n const otherField = other[ name ]\n\n for (let j = 0; j < length; ++j) {\n const thisIndex = itemSize * (thisOffset + j)\n const otherIndex = itemSize * (otherOffset + j)\n for (let k = 0; k < itemSize; ++k) {\n thisField[ thisIndex + k ] = otherField[ otherIndex + k ]\n }\n }\n }\n }\n\n /**\n * Copy data within this store\n * @param {Integer} thisOffset - offset to start copying to\n * @param {Integer} otherOffset - offset to start copying from\n * @param {Integer} length - number of entries to copy\n * @return {undefined}\n */\n copyWithin (offsetTarget: number, offsetSource: number, length: number) {\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const name = this._fields[ i ][ 0 ]\n const itemSize = this._fields[ i ][ 1 ]\n const thisField = this[ name ]\n\n for (let j = 0; j < length; ++j) {\n const targetIndex = itemSize * (offsetTarget + j)\n const sourceIndex = itemSize * (offsetSource + j)\n for (let k = 0; k < itemSize; ++k) {\n thisField[ targetIndex + k ] = thisField[ sourceIndex + k ]\n }\n }\n }\n }\n\n /**\n * Sort entries in the store given the compare function\n * @param {[type]} compareFunction - function to sort by\n * @return {undefined}\n */\n sort (compareFunction: (a: any, b: any) => number) {\n Log.time('Store.sort')\n\n const thisStore = this\n const tmpStore = new (this.constructor as any)(1)\n\n function swap (index1: number, index2: number) {\n if (index1 === index2) return\n tmpStore.copyFrom(thisStore, 0, index1, 1)\n thisStore.copyWithin(index1, index2, 1)\n thisStore.copyFrom(tmpStore, index2, 0, 1)\n }\n\n function quicksort (left: number, right: number) {\n if (left < right) {\n let pivot = Math.floor((left + right) / 2)\n let leftNew = left\n let rightNew = right\n do {\n while (compareFunction(leftNew, pivot) < 0) {\n leftNew += 1\n }\n while (compareFunction(rightNew, pivot) > 0) {\n rightNew -= 1\n }\n if (leftNew <= rightNew) {\n if (leftNew === pivot) {\n pivot = rightNew\n } else if (rightNew === pivot) {\n pivot = leftNew\n }\n swap(leftNew, rightNew)\n leftNew += 1\n rightNew -= 1\n }\n } while (leftNew <= rightNew)\n quicksort(left, rightNew)\n quicksort(leftNew, right)\n }\n }\n\n quicksort(0, this.count - 1)\n\n Log.timeEnd('Store.sort')\n }\n\n /**\n * Empty the store\n * @return {undefined}\n */\n clear () {\n this.count = 0\n }\n\n /**\n * Dispose of the store entries and fields\n * @return {undefined}\n */\n dispose () {\n\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const name = this._fields[ i ][ 0 ]\n delete this[ name ]\n }\n }\n}\n","/**\n * @file Contact Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Bond store\n */\nexport default class ContactStore extends Store {\n index1: Uint32Array\n index2: Uint32Array\n type: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'index1', 1, 'int32' ],\n [ 'index2', 1, 'int32' ],\n [ 'type', 1, 'int8' ]\n ] as StoreField[]\n }\n\n addContact (index1: number, index2: number, type?: number) {\n this.growIfFull()\n\n const i = this.count\n\n if (index1 < index2) {\n this.index1[ i ] = index1\n this.index2[ i ] = index2\n } else {\n this.index2[ i ] = index1\n this.index1[ i ] = index2\n }\n if (type) this.type[ i ] = type\n\n this.count += 1\n }\n}","/**\n * @file Bit array\n * @author Alexander Rose \n * @author Paul Pillot \n * @private\n */\n\n/**\n * Compute the Hamming weight of a 32-bit unsigned integer\n * @param {Integer} v - a 32-bit unsigned integer\n * @return {Integer} the Hamming weight\n */\nfunction hammingWeight (v: number) {\n // works with signed or unsigned shifts\n v -= ((v >>> 1) & 0x55555555)\n v = (v & 0x33333333) + ((v >>> 2) & 0x33333333)\n return ((v + (v >>> 4) & 0xF0F0F0F) * 0x1010101) >>> 24\n}\n\n/**\n * Bit array\n *\n * Based heavily on https://github.com/lemire/FastBitSet.js\n * which is licensed under the Apache License, Version 2.0.\n */\nexport default class BitArray {\n private _words: Uint32Array\n public length: number\n\n /**\n * @param {Integer} length - array length\n * @param {Boolean} [setAll] - initialize with true\n */\n constructor (length: number, setAll?: boolean) {\n this.length = length\n this._words = new Uint32Array((length + 32) >>> 5)\n if (setAll === true) {\n this.setAll()\n }\n }\n\n /**\n * Get value at index\n * @param {Integer} index - the index\n * @return {Boolean} value\n */\n get (index: number) {\n return (this._words[ index >>> 5 ] & (1 << index)) !== 0\n }\n\n /**\n * Set value at index to true\n * @param {Integer} index - the index\n * @return {undefined}\n */\n set (index: number) {\n this._words[ index >>> 5 ] |= 1 << index\n }\n\n /**\n * Set value at index to false\n * @param {Integer} index - the index\n * @return {undefined}\n */\n clear (index: number) {\n this._words[ index >>> 5 ] &= ~(1 << index)\n }\n\n /**\n * Flip value at index\n * @param {Integer} index - the index\n * @return {undefined}\n */\n flip (index: number) {\n this._words[ index >>> 5 ] ^= 1 << index\n }\n\n _assignRange (start: number, end: number, value: boolean) {\n if (end < start) return\n const words = this._words\n const wordValue = value === true ? 0xFFFFFFFF : 0\n const wordStart = start >>> 5\n const wordEnd = end >>> 5\n // set complete words when applicable\n for (let k = wordStart + 1; k < wordEnd; ++k) {\n words[ k ] = wordValue\n }\n // set parts of the range not spanning complete words\n const startWord = wordStart << 5\n const endWord = wordEnd << 5\n if (value === true) {\n if (end - start < 32) {\n for (let i = start, n = end + 1; i < n; ++i) {\n words[ i >>> 5 ] |= 1 << i\n }\n } else {\n for (let i = start, n = startWord + 32; i < n; ++i) {\n words[ i >>> 5 ] |= 1 << i\n }\n for (let i = endWord, n = end + 1; i < n; ++i) {\n words[ i >>> 5 ] |= 1 << i\n }\n }\n } else {\n if (end - start < 32) {\n for (let i = start, n = end + 1; i < n; ++i) {\n words[ i >>> 5 ] &= ~(1 << i)\n }\n } else {\n for (let i = start, n = startWord + 32; i < n; ++i) {\n words[ i >>> 5 ] &= ~(1 << i)\n }\n for (let i = endWord, n = end + 1; i < n; ++i) {\n words[ i >>> 5 ] &= ~(1 << i)\n }\n }\n }\n return this\n }\n\n /**\n * Set bits of the given range\n * @param {Integer} start - start index\n * @param {Integer} end - end index\n * @return {BitArray} this object\n */\n setRange (start: number, end: number) {\n return this._assignRange(start, end, true)\n }\n\n /**\n * Clear bits of the given range\n * @param {Integer} start - start index\n * @param {Integer} end - end index\n * @return {BitArray} this object\n */\n clearRange (start: number, end: number) {\n return this._assignRange(start, end, false)\n }\n\n /**\n * Set bits at all given indices\n * @param {...Integer} arguments - indices\n * @return {Boolean} this object\n */\n setBits (...indices: number[]) {\n const words = this._words\n const n = indices.length\n for (let i = 0; i < n; ++i) {\n const index = indices[ i ]\n words[ index >>> 5 ] |= 1 << index\n }\n return this\n }\n\n /**\n * Clear bits at all given indices\n * @param {...Integer} arguments - indices\n * @return {Boolean} this object\n */\n clearBits (...indices: number[]) {\n const words = this._words\n const n = indices.length\n for (let i = 0; i < n; ++i) {\n const index = indices[ i ]\n words[ index >>> 5 ] &= ~(1 << index)\n }\n return this\n }\n\n /**\n * Set all bits of the array\n * @return {BitArray} this object\n */\n setAll () {\n return this._assignRange(0, this.length - 1, true)\n }\n\n /**\n * Clear all bits of the array\n * @return {BitArray} this object\n */\n clearAll () {\n return this._assignRange(0, this.length - 1, false)\n }\n\n /**\n * Flip all the values in the array\n * @return {BitArray} this object\n */\n flipAll () {\n const count = this._words.length\n const words = this._words\n const bs = 32 - this.length % 32\n for (let k = 0; k < count - 1; ++k) {\n words[k] = ~words[ k ]\n }\n words[ count - 1 ] = (~(words[ count - 1 ] << bs)) >>> bs\n return this\n }\n\n _isRangeValue (start: number, end: number, value: boolean) {\n if (end < start) return\n const words = this._words\n const wordValue = value === true ? 0xFFFFFFFF : 0\n const wordStart = start >>> 5\n const wordEnd = end >>> 5\n // set complete words when applicable\n for (let k = wordStart + 1; k < wordEnd; ++k) {\n if (words[ k ] !== wordValue) return false\n }\n // set parts of the range not spanning complete words\n if (end - start < 32) {\n for (let i = start, n = end + 1; i < n; ++i) {\n if (!!(words[ i >>> 5 ] & (1 << i)) !== value) return false\n }\n } else {\n const startWord = wordStart << 5\n const endWord = wordEnd << 5\n for (let i = start, n = startWord + 32; i < n; ++i) {\n if (!!(words[ i >>> 5 ] & (1 << i)) !== value) return false\n }\n for (let i = endWord, n = end + 1; i < n; ++i) {\n if (!!(words[ i >>> 5 ] & (1 << i)) !== value) return false\n }\n }\n return true\n }\n\n /**\n * Test if bits in given range are set\n * @param {Integer} start - start index\n * @param {Integer} end - end index\n * @return {BitArray} this object\n */\n isRangeSet (start: number, end: number) {\n return this._isRangeValue(start, end, true)\n }\n\n /**\n * Test if bits in given range are clear\n * @param {Integer} start - start index\n * @param {Integer} end - end index\n * @return {BitArray} this object\n */\n isRangeClear (start: number, end: number) {\n return this._isRangeValue(start, end, false)\n }\n\n /**\n * Test if all bits in the array are set\n * @return {Boolean} test result\n */\n isAllSet () {\n return this._isRangeValue(0, this.length - 1, true)\n }\n\n /**\n * Test if all bits in the array are clear\n * @return {Boolean} test result\n */\n isAllClear () {\n return this._isRangeValue(0, this.length - 1, false)\n }\n\n /**\n * Test if bits at all given indices are set\n * @param {...Integer} arguments - indices\n * @return {Boolean} test result\n */\n isSet (...indices: number[]) {\n const words = this._words\n const n = indices.length\n for (let i = 0; i < n; ++i) {\n const index = indices[ i ]\n if ((words[ index >>> 5 ] & (1 << index)) === 0) return false\n }\n return true\n }\n\n /**\n * Test if bits at all given indices are clear\n * @param {...Integer} arguments - indices\n * @return {Boolean} test result\n */\n isClear (...indices: number[]) {\n const words = this._words\n const n = indices.length\n for (let i = 0; i < n; ++i) {\n const index = indices[ i ]\n if ((words[ index >>> 5 ] & (1 << index)) !== 0) return false\n }\n return true\n }\n\n /**\n * Test if two BitArrays are identical in all their values\n * @param {BitArray} otherBitarray - the other BitArray\n * @return {Boolean} test result\n */\n isEqualTo (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n if (words1[ k ] !== words2[ k ]) {\n return false\n }\n }\n return true\n }\n\n /**\n * How many set bits?\n * @return {Integer} number of set bits\n */\n getSize () {\n const count = this._words.length\n const words = this._words\n let size = 0\n for (let i = 0; i < count; ++i) {\n size += hammingWeight(words[ i ])\n }\n return size\n }\n\n /**\n * Calculate difference betwen this and another bit array.\n * Store result in this object.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {BitArray} this object\n */\n difference (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n words1[ k ] = words1[ k ] & ~words2[ k ]\n }\n for (let k = words1.length; k < count; ++k) {\n words1[ k ] = 0\n }\n return this\n }\n\n /**\n * Calculate union betwen this and another bit array.\n * Store result in this object.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {BitArray} this object\n */\n union (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n words1[ k ] |= words2[ k ]\n }\n for (let k = words1.length; k < count; ++k) {\n words1[ k ] = 0\n }\n return this\n }\n\n /**\n * Calculate intersection betwen this and another bit array.\n * Store result in this object.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {BitArray} this object\n */\n intersection (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n words1[ k ] &= words2[ k ]\n }\n for (let k = words1.length; k < count; ++k) {\n words1[ k ] = 0\n }\n return this\n }\n\n /**\n * Test if there is any intersection betwen this and another bit array.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {Boolean} test result\n */\n intersects (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n if ((words1[ k ] & words2[ k ]) !== 0) {\n return true\n }\n }\n return false\n }\n\n /**\n * Calculate the number of bits in common betwen this and another bit array.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {Integer} size\n */\n getIntersectionSize (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n let size = 0\n for (let k = 0; k < count; ++k) {\n size += hammingWeight(words1[ k ] & words2[ k ])\n }\n return size\n }\n\n /**\n * Calculate intersection betwen this and another bit array.\n * Store result in a new bit array.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {BitArray} the new bit array\n */\n makeIntersection (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n const wordsA = new Uint32Array(count)\n const intersection = Object.create(BitArray.prototype)\n intersection._words = wordsA\n intersection.length = Math.min(this.length, otherBitarray.length)\n for (let k = 0; k < count; ++k) {\n wordsA[ k ] = words1[ k ] & words2[ k ]\n }\n return intersection\n }\n\n /**\n * Iterate over all set bits in the array\n * @param {function( index: Integer, i: Integer )} callback - the callback\n * @return {undefined}\n */\n forEach (callback: (index: number, i: number) => any) {\n const count = this._words.length\n const words = this._words\n let i = 0\n for (let k = 0; k < count; ++k) {\n let w = words[ k ]\n while (w !== 0) {\n const t = w & -w\n const index = (k << 5) + hammingWeight(t - 1)\n callback(index, i)\n w ^= t\n ++i\n }\n }\n }\n\n /**\n * Get an array with the set bits\n * @return {Array} bit indices\n */\n toArray () {\n const words = this._words\n const answer = new Array(this.getSize())\n const count = this._words.length\n let pos = 0\n for (let k = 0; k < count; ++k) {\n let w = words[ k ]\n while (w !== 0) {\n const t = w & -w\n answer[ pos++ ] = (k << 5) + hammingWeight(t - 1)\n w ^= t\n }\n }\n return answer\n }\n\n toString () {\n return '{' + this.toArray().join(',') + '}'\n }\n\n toSeleString () {\n const sele = this.toArray().join(',')\n return sele ? '@' + sele : 'NONE'\n }\n\n /**\n * Clone this object\n * @return {BitArray} the cloned object\n */\n clone () {\n const clone = Object.create(BitArray.prototype)\n clone.length = this.length\n clone._words = new Uint32Array(this._words)\n return clone\n }\n}","/**\n * @file Adjacency List\n * @author Alexander Rose \n * @private\n */\n\nexport interface Edges {\n nodeArray1: ArrayLike\n nodeArray2: ArrayLike\n edgeCount: number\n nodeCount: number\n}\n\nexport interface AdjacencyList {\n /* number of edges for each node */\n countArray: Uint8Array\n /* offset into indexArray for each node */\n offsetArray: Int32Array\n /* edge indices, grouped by nodes */\n indexArray: Int32Array\n}\n\nexport function createAdjacencyList (edges: Edges): AdjacencyList {\n const { edgeCount, nodeCount, nodeArray1, nodeArray2 } = edges\n\n const countArray = new Uint8Array(nodeCount)\n const offsetArray = new Int32Array(nodeCount)\n\n // count edges per node\n for (let i = 0; i < edgeCount; ++i) {\n countArray[ nodeArray1[ i ] ] += 1\n countArray[ nodeArray2[ i ] ] += 1\n }\n\n // get offsets to node edges\n for (let i = 1; i < nodeCount; ++i) {\n offsetArray[ i ] += offsetArray[ i - 1 ] + countArray[ i - 1 ]\n }\n\n // prepare index array\n const bondCount2 = edgeCount * 2\n const indexArray = new Int32Array(bondCount2)\n for (let j = 0; j < bondCount2; ++j) {\n indexArray[ j ] = -1\n }\n\n // build index array\n for (let i = 0; i < edgeCount; ++i) {\n const idx1 = nodeArray1[ i ]\n const idx2 = nodeArray2[ i ]\n let j1 = offsetArray[ idx1 ]\n while (indexArray[ j1 ] !== -1 && j1 < bondCount2) {\n j1 += 1\n }\n indexArray[ j1 ] = i\n let j2 = offsetArray[ idx2 ]\n while (indexArray[ j2 ] !== -1 && j2 < bondCount2) {\n j2 += 1\n }\n indexArray[ j2 ] = i\n }\n\n return { countArray, offsetArray, indexArray }\n}\n","/**\n * @file Features\n * @author Alexander Rose \n */\n\nimport AtomProxy from '../../proxy/atom-proxy'\n\nexport interface Features {\n types: FeatureType[]\n groups: FeatureGroup[]\n centers: { x: number[], y: number[], z: number[] }\n atomSets: number[][]\n}\n\nexport const enum FeatureType {\n Unknown = 0,\n PositiveCharge = 1,\n NegativeCharge = 2,\n AromaticRing = 3,\n HydrogenDonor = 4,\n HydrogenAcceptor = 5,\n HalogenDonor = 6,\n HalogenAcceptor = 7,\n Hydrophobic = 8,\n WeakHydrogenDonor = 9,\n IonicTypePartner = 10,\n DativeBondPartner = 11,\n TransitionMetal = 12,\n IonicTypeMetal = 13\n}\n\nexport const enum FeatureGroup {\n Unknown = 0,\n QuaternaryAmine = 1,\n TertiaryAmine = 2,\n Sulfonium = 3,\n SulfonicAcid = 4,\n Sulfate = 5,\n Phosphate = 6,\n Halocarbon = 7,\n Guanidine = 8,\n Acetamidine = 9,\n Carboxylate = 10\n}\n\nexport function createFeatures (): Features {\n return {\n types: [],\n groups: [],\n centers: { x: [], y: [], z: [] },\n atomSets: []\n }\n}\n\nexport interface FeatureState {\n type: FeatureType\n group: FeatureGroup\n x: number\n y: number\n z: number\n atomSet: number[]\n}\n\nexport function createFeatureState(type = FeatureType.Unknown, group = FeatureGroup.Unknown): FeatureState {\n return { type, group, x: 0, y: 0, z: 0, atomSet: [] }\n}\n\nexport function addAtom (state: FeatureState, atom: AtomProxy) {\n state.x += atom.x\n state.y += atom.y\n state.z += atom.z\n state.atomSet.push(atom.index)\n}\n\nexport function addFeature (features: Features, state: FeatureState) {\n const n = state.atomSet.length\n if (n > 0) {\n const { types, groups, centers, atomSets } = features\n types.push(state.type)\n groups.push(state.group)\n centers.x.push(state.x / n)\n centers.y.push(state.y / n)\n centers.z.push(state.z / n)\n atomSets.push(state.atomSet)\n }\n}\n","/**\n * @file Structure Constants\n * @author Alexander Rose \n * @private\n */\n\n// entity types\nexport const UnknownEntity = 0\nexport const PolymerEntity = 1\nexport const NonPolymerEntity = 2\nexport const MacrolideEntity = 3\nexport const WaterEntity = 4\n\n// molecule types\nexport const UnknownType = 0\nexport const WaterType = 1\nexport const IonType = 2\nexport const ProteinType = 3\nexport const RnaType = 4\nexport const DnaType = 5\nexport const SaccharideType = 6\n\n// backbone types\nexport const UnknownBackboneType = 0\nexport const ProteinBackboneType = 1\nexport const RnaBackboneType = 2\nexport const DnaBackboneType = 3\nexport const CgProteinBackboneType = 4\nexport const CgRnaBackboneType = 5\nexport const CgDnaBackboneType = 6\n\n// chemical component types\nexport const ChemCompProtein = [\n 'D-BETA-PEPTIDE, C-GAMMA LINKING', 'D-GAMMA-PEPTIDE, C-DELTA LINKING',\n 'D-PEPTIDE COOH CARBOXY TERMINUS', 'D-PEPTIDE NH3 AMINO TERMINUS', 'D-PEPTIDE LINKING',\n 'L-BETA-PEPTIDE, C-GAMMA LINKING', 'L-GAMMA-PEPTIDE, C-DELTA LINKING',\n 'L-PEPTIDE COOH CARBOXY TERMINUS', 'L-PEPTIDE NH3 AMINO TERMINUS', 'L-PEPTIDE LINKING',\n 'PEPTIDE LINKING', 'PEPTIDE-LIKE'\n]\nexport const ChemCompRna = [\n 'RNA OH 3 PRIME TERMINUS', 'RNA OH 5 PRIME TERMINUS', 'RNA LINKING'\n]\nexport const ChemCompDna = [\n 'DNA OH 3 PRIME TERMINUS', 'DNA OH 5 PRIME TERMINUS', 'DNA LINKING',\n 'L-DNA LINKING', 'L-RNA LINKING'\n]\nexport const ChemCompSaccharide = [\n 'D-SACCHARIDE', 'D-SACCHARIDE 1,4 AND 1,4 LINKING', 'D-SACCHARIDE 1,4 AND 1,6 LINKING',\n 'L-SACCHARIDE', 'L-SACCHARIDE 1,4 AND 1,4 LINKING', 'L-SACCHARIDE 1,4 AND 1,6 LINKING',\n 'SACCHARIDE'\n]\nexport const ChemCompOther = [\n 'OTHER'\n]\nexport const ChemCompNonPolymer = [\n 'NON-POLYMER'\n]\nexport const ChemCompHetero = ChemCompNonPolymer.concat(ChemCompOther, ChemCompSaccharide)\n\n// secondary structure\nexport const SecStrucHelix = [ 'h', 'g', 'i' ]\nexport const SecStrucSheet = [ 'e', 'b' ]\nexport const SecStrucTurn = [ 's', 't', 'l', '' ]\n\nexport const AtomicNumbers: { [e: string]: number | undefined } = {\n 'H': 1, 'D': 1, 'T': 1, 'HE': 2, 'LI': 3, 'BE': 4, 'B': 5, 'C': 6, 'N': 7, 'O': 8, 'F': 9, 'NE': 10, 'NA': 11, 'MG': 12, 'AL': 13, 'SI': 14, 'P': 15, 'S': 16, 'CL': 17, 'AR': 18, 'K': 19, 'CA': 20, 'SC': 21, 'TI': 22, 'V': 23, 'CR': 24, 'MN': 25, 'FE': 26, 'CO': 27, 'NI': 28, 'CU': 29, 'ZN': 30, 'GA': 31, 'GE': 32, 'AS': 33, 'SE': 34, 'BR': 35, 'KR': 36, 'RB': 37, 'SR': 38, 'Y': 39, 'ZR': 40, 'NB': 41, 'MO': 42, 'TC': 43, 'RU': 44, 'RH': 45, 'PD': 46, 'AG': 47, 'CD': 48, 'IN': 49, 'SN': 50, 'SB': 51, 'TE': 52, 'I': 53, 'XE': 54, 'CS': 55, 'BA': 56, 'LA': 57, 'CE': 58, 'PR': 59, 'ND': 60, 'PM': 61, 'SM': 62, 'EU': 63, 'GD': 64, 'TB': 65, 'DY': 66, 'HO': 67, 'ER': 68, 'TM': 69, 'YB': 70, 'LU': 71, 'HF': 72, 'TA': 73, 'W': 74, 'RE': 75, 'OS': 76, 'IR': 77, 'PT': 78, 'AU': 79, 'HG': 80, 'TL': 81, 'PB': 82, 'BI': 83, 'PO': 84, 'AT': 85, 'RN': 86, 'FR': 87, 'RA': 88, 'AC': 89, 'TH': 90, 'PA': 91, 'U': 92, 'NP': 93, 'PU': 94, 'AM': 95, 'CM': 96, 'BK': 97, 'CF': 98, 'ES': 99, 'FM': 100, 'MD': 101, 'NO': 102, 'LR': 103, 'RF': 104, 'DB': 105, 'SG': 106, 'BH': 107, 'HS': 108, 'MT': 109, 'DS': 110, 'RG': 111, 'CN': 112, 'NH': 113, 'FL': 114, 'MC': 115, 'LV': 116, 'TS': 117, 'OG': 118\n}\nexport const DefaultAtomicNumber = 0\n\n/**\n * Enum mapping element to atomic number\n */\nexport const enum Elements {\n H = 1, D = 1, T = 1, HE = 2, LI = 3, BE = 4, B = 5, C = 6, N = 7, O = 8, F = 9, NE = 10, NA = 11, MG = 12, AL = 13, SI = 14, P = 15, S = 16, CL = 17, AR = 18, K = 19, CA = 20, SC = 21, TI = 22, V = 23, CR = 24, MN = 25, FE = 26, CO = 27, NI = 28, CU = 29, ZN = 30, GA = 31, GE = 32, AS = 33, SE = 34, BR = 35, KR = 36, RB = 37, SR = 38, Y = 39, ZR = 40, NB = 41, MO = 42, TC = 43, RU = 44, RH = 45, PD = 46, AG = 47, CD = 48, IN = 49, SN = 50, SB = 51, TE = 52, I = 53, XE = 54, CS = 55, BA = 56, LA = 57, CE = 58, PR = 59, ND = 60, PM = 61, SM = 62, EU = 63, GD = 64, TB = 65, DY = 66, HO = 67, ER = 68, TM = 69, YB = 70, LU = 71, HF = 72, TA = 73, W = 74, RE = 75, OS = 76, IR = 77, PT = 78, AU = 79, HG = 80, TL = 81, PB = 82, BI = 83, PO = 84, AT = 85, RN = 86, FR = 87, RA = 88, AC = 89, TH = 90, PA = 91, U = 92, NP = 93, PU = 94, AM = 95, CM = 96, BK = 97, CF = 98, ES = 99, FM = 100, MD = 101, NO = 102, LR = 103, RF = 104, DB = 105, SG = 106, BH = 107, HS = 108, MT = 109, DS = 110, RG = 111, CN = 112, NH = 113, FL = 114, MC = 115, LV = 116, TS = 117, OG = 118\n}\n\n// https://doi.org/10.1515/pac-2015-0305 (table 2, 3, and 4)\nexport const AtomWeights: { [e: number]: number | undefined } = {\n 1: 1.008, 2: 4.0026, 3: 6.94, 4: 9.0122, 5: 10.81, 6: 10.81, 7: 14.007, 8: 15.999, 9: 18.998, 10: 20.180, 11: 22.990, 12: 24.305, 13: 26.982, 14: 28.085, 15: 30.974, 16: 32.06, 17: 35.45, 18: 39.948, 19: 39.098, 20: 40.078, 21: 44.956, 22: 47.867, 23: 50.942, 24: 51.996, 25: 54.938, 26: 55.845, 27: 58.933, 28: 58.693, 29: 63.546, 30: 65.38, 31: 69.723, 32: 72.630, 33: 74.922, 34: 78.971, 35: 79.904, 36: 83.798, 37: 85.468, 38: 87.62, 39: 88.906, 40: 91.224, 41: 92.906, 42: 95.95, 43: 96.906, 44: 101.07, 45: 102.91, 46: 106.42, 47: 107.87, 48: 112.41, 49: 114.82, 50: 118.71, 51: 121.76, 52: 127.60, 53: 127.60, 54: 131.29, 55: 132.91, 56: 137.33, 57: 138.91, 58: 140.12, 59: 140.91, 60: 144.24, 61: 144.912, 62: 150.36, 63: 151.96, 64: 157.25, 65: 158.93, 66: 162.50, 67: 164.93, 68: 167.26, 69: 168.93, 70: 173.05, 71: 174.97, 72: 178.49, 73: 180.95, 74: 183.84, 75: 186.21, 76: 190.23, 77: 192.22, 78: 195.08, 79: 196.97, 80: 200.59, 81: 204.38, 82: 207.2, 83: 208.98, 84: 1.97, 85: 2.02, 86: 2.2, 87: 3.48, 88: 2.83, 89: 2.0, 90: 232.04, 91: 231.04, 92: 238.03, 93: 237.048, 94: 244.064, 95: 243.061, 96: 247.070, 97: 247.070, 98: 251.079, 99: 252.083, 100: 257.095, 101: 258.098, 102: 259.101, 103: 262.110, 104: 267.122, 105: 270.131, 106: 271.134, 107: 270.133, 108: 270.134, 109: 278.156, 110: 281.165, 111: 281.166, 112: 285.177, 113: 286.182, 114: 289.190, 115: 289.194, 116: 293.204, 117: 293.208, 118: 294.214\n}\nexport const DefaultAtomWeight = 10.81 // C\n\n// http://dx.doi.org/10.1021/jp8111556 (or 2.0)\nexport const VdwRadii: { [e: number]: number | undefined } = {\n 1: 1.1, 2: 1.4, 3: 1.81, 4: 1.53, 5: 1.92, 6: 1.7, 7: 1.55, 8: 1.52, 9: 1.47, 10: 1.54, 11: 2.27, 12: 1.73, 13: 1.84, 14: 2.1, 15: 1.8, 16: 1.8, 17: 1.75, 18: 1.88, 19: 2.75, 20: 2.31, 21: 2.3, 22: 2.15, 23: 2.05, 24: 2.05, 25: 2.05, 26: 2.05, 27: 2.0, 28: 2.0, 29: 2.0, 30: 2.1, 31: 1.87, 32: 2.11, 33: 1.85, 34: 1.9, 35: 1.83, 36: 2.02, 37: 3.03, 38: 2.49, 39: 2.4, 40: 2.3, 41: 2.15, 42: 2.1, 43: 2.05, 44: 2.05, 45: 2.0, 46: 2.05, 47: 2.1, 48: 2.2, 49: 2.2, 50: 1.93, 51: 2.17, 52: 2.06, 53: 1.98, 54: 2.16, 55: 3.43, 56: 2.68, 57: 2.5, 58: 2.48, 59: 2.47, 60: 2.45, 61: 2.43, 62: 2.42, 63: 2.4, 64: 2.38, 65: 2.37, 66: 2.35, 67: 2.33, 68: 2.32, 69: 2.3, 70: 2.28, 71: 2.27, 72: 2.25, 73: 2.2, 74: 2.1, 75: 2.05, 76: 2.0, 77: 2.0, 78: 2.05, 79: 2.1, 80: 2.05, 81: 1.96, 82: 2.02, 83: 2.07, 84: 1.97, 85: 2.02, 86: 2.2, 87: 3.48, 88: 2.83, 89: 2.0, 90: 2.4, 91: 2.0, 92: 2.3, 93: 2.0, 94: 2.0, 95: 2.0, 96: 2.0, 97: 2.0, 98: 2.0, 99: 2.0, 100: 2.0, 101: 2.0, 102: 2.0, 103: 2.0, 104: 2.0, 105: 2.0, 106: 2.0, 107: 2.0, 108: 2.0, 109: 2.0, 110: 2.0, 111: 2.0, 112: 2.0, 113: 2.0, 114: 2.0, 115: 2.0, 116: 2.0, 117: 2.0, 118: 2.0\n}\nexport const DefaultVdwRadius = 2.0 // C\n\n// Peter Rose (peter.rose@rcsb.org), private communication, average accross PDB\nexport const ResidueRadii: { [k: string]: number } = {\n '2QY': 6.58,\n 'CY0': 11.98,\n '2QZ': 2.52,\n 'CY1': 6.59,\n 'HHK': 5.11,\n 'CXM': 4.69,\n 'HHI': 4.58,\n 'CY4': 4.57,\n 'S12': 18.57,\n 'CY3': 2.79,\n 'C5C': 5.35,\n 'PFX': 11.84,\n '2R3': 6.94,\n '2R1': 3.78,\n 'ILX': 4.99,\n '32S': 5.68,\n 'BTK': 8.59,\n '32T': 5.72,\n 'FAK': 9.8,\n 'B27': 2.78,\n 'ILM': 3.84,\n 'C4R': 5.63,\n '32L': 6.75,\n 'SYS': 3.01,\n '1MH': 5.04,\n 'ILE': 3.65,\n 'YNM': 6.39,\n '2RX': 4.91,\n 'B3A': 2.48,\n 'GEE': 4.76,\n '7MN': 7.34,\n 'B3E': 5.4,\n 'ARG': 6.33,\n '200': 6.89,\n 'HIP': 5.47,\n 'HIA': 4.64,\n 'B3K': 5.89,\n 'HIC': 5.76,\n 'B3L': 4.96,\n 'B3M': 5.07,\n 'ARM': 6.86,\n 'ARO': 7.35,\n 'AR4': 8.42,\n 'PG1': 10.67,\n 'YOF': 6.44,\n 'IML': 3.74,\n 'SXE': 6.65,\n 'HIQ': 7.98,\n 'PFF': 6.31,\n 'HIS': 4.52,\n '0TD': 3.62,\n 'C3Y': 5.24,\n '1OP': 11.55,\n '02Y': 4.77,\n '02V': 4.83,\n 'ASB': 5.59,\n '30V': 8.53,\n 'S2P': 4.81,\n 'ASP': 3.55,\n 'ASN': 3.54,\n '2OR': 6.91,\n 'QMM': 6.13,\n '2P0': 8.52,\n 'ASL': 5.36,\n 'HFA': 5.14,\n '5PG': 5.69,\n 'B3X': 4.38,\n 'AS9': 4.1,\n 'ARV': 7.59,\n 'B3U': 6.06,\n 'S2C': 7.54,\n 'B3T': 3.34,\n '175': 5.64,\n 'GFT': 8.18,\n 'HG7': 6.8,\n 'B3Q': 4.48,\n 'ASA': 3.64,\n '02K': 2.94,\n 'B3Y': 7.45,\n 'PHD': 5.35,\n 'C6C': 6.42,\n 'BUC': 5.8,\n 'HGL': 8.07,\n 'PHE': 5.06,\n '03Y': 2.6,\n 'PHA': 5.11,\n 'OCY': 5.0,\n '4PH': 6.79,\n '5OH': 4.7,\n '31Q': 10.46,\n 'BTR': 7.98,\n '3PX': 4.7,\n '1PA': 8.07,\n 'ASX': 3.54,\n 'IOR': 7.23,\n '03E': 3.38,\n 'PHL': 5.17,\n 'KWS': 5.09,\n 'PHI': 7.12,\n 'NAL': 7.22,\n 'S1H': 19.21,\n '2ML': 3.86,\n '2MR': 7.35,\n 'GHG': 4.83,\n 'TYY': 6.54,\n '2MT': 3.67,\n '56A': 13.01,\n 'SVA': 5.46,\n 'TYX': 8.31,\n 'TYS': 8.59,\n 'TYR': 6.38,\n 'TYQ': 6.43,\n 'HLU': 3.99,\n 'MYK': 19.47,\n 'TYO': 7.71,\n 'HLX': 4.98,\n 'TYN': 9.87,\n 'TYJ': 6.25,\n 'TYI': 6.49,\n 'LYH': 5.13,\n 'LYF': 12.19,\n 'SUN': 6.73,\n 'LYR': 18.28,\n 'TYB': 6.46,\n '11W': 14.39,\n 'LYS': 5.54,\n 'LYN': 4.8,\n '11Q': 4.85,\n 'LYO': 4.71,\n 'LYZ': 1.76,\n 'TXY': 6.44,\n 'MYN': 4.71,\n 'TY5': 10.6,\n 'HMR': 5.09,\n '01W': 8.55,\n 'LYX': 13.36,\n 'TY8': 7.22,\n 'TY2': 6.49,\n 'KYN': 6.18,\n 'KYQ': 9.75,\n 'CZZ': 5.14,\n 'IIL': 3.81,\n 'HNC': 10.41,\n 'OIC': 4.62,\n 'LVN': 2.89,\n 'QIL': 3.84,\n 'JJL': 8.3,\n 'VAH': 3.88,\n 'JJJ': 7.5,\n 'JJK': 7.43,\n 'VAD': 2.56,\n 'CYW': 4.65,\n '0QL': 5.72,\n '143': 8.22,\n 'SVX': 7.04,\n 'CYJ': 11.64,\n 'SVY': 7.1,\n 'SVZ': 6.6,\n 'CYG': 8.03,\n 'CYF': 13.54,\n 'SVV': 5.09,\n 'GL3': 2.72,\n '8SP': 14.26,\n 'CYS': 2.78,\n '004': 4.33,\n 'CYR': 10.33,\n 'PLJ': 3.71,\n 'EXY': 7.37,\n 'HL2': 3.75,\n 'A5N': 5.21,\n 'CYQ': 5.67,\n 'CZ2': 5.16,\n 'LWY': 4.12,\n 'PM3': 8.78,\n 'OHS': 6.98,\n 'OHI': 5.35,\n '3TY': 8.42,\n 'CYD': 8.55,\n 'DYS': 7.87,\n 'DAH': 6.47,\n '4IK': 11.81,\n '3EG': 3.66,\n 'AYA': 3.65,\n '4IN': 6.31,\n 'DAB': 3.48,\n '4HT': 6.03,\n 'RGL': 7.03,\n 'DAM': 2.49,\n 'NFA': 5.04,\n 'WFP': 6.07,\n '2JC': 2.97,\n 'HAR': 7.55,\n '2JG': 5.67,\n 'MH6': 1.72,\n '2JF': 9.13,\n '3FG': 4.96,\n 'MGN': 4.84,\n 'AZH': 5.36,\n 'AZK': 6.03,\n 'ZBZ': 7.79,\n 'TBG': 2.58,\n 'VAL': 2.51,\n 'MGG': 7.34,\n 'AZS': 5.61,\n 'FHL': 9.75,\n '2JH': 4.56,\n 'IEL': 7.07,\n 'FHO': 6.75,\n 'DA2': 7.79,\n 'FH7': 6.99,\n 'ME0': 4.52,\n '3GL': 4.84,\n 'MDO': 5.03,\n 'AZY': 7.37,\n 'A8E': 3.76,\n 'ZCL': 6.71,\n 'MDH': 2.58,\n 'LA2': 14.07,\n '4FW': 6.1,\n 'YCM': 5.32,\n 'MDF': 4.95,\n 'YCP': 3.01,\n 'TEF': 8.63,\n 'FGP': 4.34,\n 'UF0': 19.72,\n 'XCN': 4.57,\n 'FGL': 2.56,\n 'MF3': 6.37,\n 'MEQ': 5.13,\n 'LAA': 3.23,\n 'IGL': 5.52,\n 'MET': 4.49,\n 'NIY': 6.81,\n 'QCS': 5.18,\n 'TCQ': 8.56,\n 'MEN': 4.33,\n '4HL': 8.79,\n 'MEA': 4.95,\n 'EFC': 5.28,\n 'LAL': 2.41,\n '2HF': 5.52,\n 'KBE': 5.64,\n 'OCS': 3.94,\n 'CAF': 5.46,\n 'NC1': 11.4,\n 'NBQ': 9.82,\n 'CAB': 4.19,\n 'MBQ': 9.55,\n '193': 7.38,\n '192': 2.44,\n '0WZ': 7.61,\n 'CAS': 5.35,\n 'NB8': 11.98,\n 'OBS': 11.71,\n '1AC': 2.42,\n 'PCA': 3.48,\n 'MCL': 9.73,\n 'LBY': 7.75,\n 'GAU': 4.67,\n 'PBF': 9.75,\n 'MCG': 6.46,\n 'DDE': 6.86,\n '19W': 3.94,\n 'MD5': 9.33,\n 'MD6': 6.44,\n 'MD3': 8.41,\n 'MCS': 7.56,\n 'OBF': 3.64,\n 'UAL': 4.68,\n 'PAT': 6.05,\n 'IAM': 8.88,\n 'PAQ': 8.77,\n 'FDL': 9.49,\n 'NCB': 3.45,\n 'LCK': 9.81,\n 'DDZ': 2.52,\n '2FM': 5.54,\n 'IAR': 6.77,\n 'OAS': 4.8,\n 'HBN': 8.8,\n 'TA4': 5.55,\n '1C3': 7.43,\n 'ECX': 5.51,\n 'PF5': 6.28,\n 'RE3': 5.29,\n 'FCL': 6.25,\n 'ECC': 4.79,\n 'LDH': 7.06,\n 'NCY': 2.91,\n 'CCS': 4.58,\n 'PEC': 6.54,\n '2CO': 4.45,\n 'LE1': 2.72,\n 'HCM': 5.53,\n '07O': 8.05,\n 'HCL': 4.96,\n 'NEP': 6.94,\n 'PE1': 8.01,\n 'LEF': 4.37,\n 'FC0': 5.18,\n 'LED': 4.34,\n 'HCS': 4.09,\n 'DBU': 2.49,\n 'RE0': 5.53,\n 'LEN': 3.82,\n '1E3': 8.71,\n 'BB9': 2.56,\n 'BB8': 5.14,\n 'PCS': 5.05,\n 'BB7': 4.56,\n 'BB6': 2.62,\n 'LEU': 3.83,\n 'DBZ': 7.08,\n 'LET': 11.29,\n 'DBY': 6.46,\n 'ICY': 7.76,\n 'MAA': 2.4,\n 'CGA': 7.91,\n '5CS': 8.34,\n 'UGY': 3.7,\n 'LGY': 11.71,\n 'N10': 8.96,\n 'AAR': 6.39,\n 'FT6': 7.5,\n 'MOD': 12.62,\n '5CW': 7.21,\n 'PVH': 4.58,\n 'BBC': 6.42,\n 'YYA': 7.3,\n 'O12': 14.08,\n 'NOT': 7.15,\n 'KGC': 9.88,\n 'MP4': 5.86,\n '0CS': 4.07,\n 'MP8': 3.75,\n 'VLL': 2.54,\n 'VLM': 2.51,\n 'BCS': 8.03,\n 'MNL': 4.9,\n 'AA4': 4.47,\n 'SAC': 3.49,\n 'BCX': 2.99,\n '3CF': 6.47,\n 'SAH': 11.7,\n 'NNH': 6.86,\n 'CGU': 4.71,\n 'SIB': 12.41,\n 'TLY': 8.78,\n 'SIC': 4.81,\n 'VMS': 8.82,\n 'TMD': 6.76,\n 'MMO': 6.53,\n 'PXU': 2.46,\n '4AW': 6.22,\n 'OTH': 3.6,\n 'DLS': 6.84,\n 'MME': 4.99,\n 'DM0': 6.99,\n '0FL': 2.76,\n 'SBL': 8.96,\n 'CDV': 3.72,\n 'OTY': 6.51,\n 'PYA': 7.75,\n '2AS': 3.57,\n 'DMH': 4.92,\n 'ELY': 7.42,\n 'GVL': 9.6,\n 'FVA': 2.9,\n 'SAR': 2.48,\n '4BF': 6.92,\n 'EME': 4.69,\n 'CDE': 2.51,\n '3AR': 7.86,\n '3AH': 9.11,\n 'AC5': 2.44,\n 'FTR': 6.08,\n 'MLL': 3.76,\n 'NPH': 11.66,\n 'NPI': 6.9,\n 'DMT': 6.67,\n 'PYX': 11.3,\n 'MLE': 3.87,\n 'PYL': 9.67,\n 'ZZU': 6.94,\n 'H5M': 3.61,\n 'SCH': 4.46,\n 'DMK': 3.52,\n 'FTY': 9.07,\n '2AG': 3.7,\n 'ABA': 2.55,\n 'ZZJ': 2.44,\n 'MLZ': 6.8,\n 'MLY': 6.88,\n 'KCX': 7.28,\n 'ZZD': 8.16,\n '3A5': 5.37,\n 'LHC': 7.75,\n '9AT': 2.47,\n 'OZT': 3.4,\n 'THO': 2.62,\n 'THR': 2.5,\n 'DFI': 3.93,\n 'MKD': 6.42,\n '4CY': 4.6,\n 'SDP': 6.07,\n 'DFO': 3.94,\n '0A0': 3.45,\n '4DB': 9.73,\n 'ML3': 6.26,\n 'BG1': 8.02,\n 'SD4': 4.57,\n 'THC': 3.8,\n 'SCS': 5.48,\n 'TH5': 4.65,\n 'BFD': 5.33,\n 'AEI': 6.34,\n 'TH6': 2.85,\n 'SCY': 4.53,\n 'TIS': 4.81,\n 'SEE': 4.53,\n 'BHD': 3.48,\n 'SEB': 8.18,\n 'SEC': 2.96,\n 'SEP': 4.8,\n 'CLH': 7.13,\n 'TIH': 5.02,\n 'CLG': 13.62,\n 'SEN': 6.43,\n 'XXA': 7.34,\n 'SEL': 2.46,\n 'SE7': 4.19,\n '4CF': 7.72,\n 'G8M': 3.57,\n 'BH2': 3.51,\n 'UN2': 3.22,\n 'VR0': 10.51,\n 'MK8': 4.76,\n 'DHA': 2.32,\n 'LMQ': 4.69,\n 'SFE': 5.01,\n 'AHB': 3.47,\n 'OXX': 7.05,\n 'BIF': 9.63,\n 'IZO': 4.47,\n 'NMM': 8.25,\n '0BN': 7.0,\n 'HZP': 3.12,\n 'NMC': 4.23,\n 'DHL': 2.69,\n '9DS': 9.29,\n 'SER': 2.41,\n 'CHG': 4.2,\n 'MIR': 6.54,\n 'AGQ': 7.79,\n 'SET': 2.46,\n 'MIS': 6.32,\n '4FB': 3.08,\n '0AR': 8.46,\n 'LME': 3.99,\n 'FZN': 24.42,\n 'AGT': 9.04,\n 'IYR': 6.46,\n '9DN': 9.31,\n 'CHP': 5.75,\n 'UNK': 1.64,\n 'XX1': 9.92,\n 'AGM': 6.57,\n '0AH': 5.78,\n 'LLP': 10.22,\n '0AF': 6.72,\n '4DP': 9.28,\n 'HYP': 2.25,\n 'DIR': 5.8,\n 'LLY': 8.71,\n '0AK': 6.11,\n 'NLE': 4.67,\n 'OYL': 6.42,\n 'WVL': 4.69,\n '0A8': 8.1,\n 'NLY': 6.37,\n 'MHO': 4.89,\n 'VOL': 2.55,\n '0A1': 7.1,\n 'MHL': 3.92,\n 'NLP': 4.81,\n 'NLQ': 4.65,\n 'MHW': 2.74,\n 'BIL': 4.7,\n 'NLO': 4.8,\n 'MHU': 7.51,\n 'XW1': 9.36,\n 'LLO': 10.13,\n 'SGB': 6.88,\n 'MHV': 3.6,\n 'MHS': 4.51,\n '0A9': 5.17,\n '0LF': 9.96,\n 'HT7': 6.82,\n 'X2W': 6.6,\n 'YPZ': 9.38,\n 'I58': 6.73,\n 'FLA': 2.4,\n 'M0H': 4.83,\n 'HSL': 2.46,\n 'FLE': 6.17,\n 'KOR': 10.1,\n '1VR': 3.89,\n 'HSO': 4.56,\n 'TTS': 9.41,\n 'RVX': 7.01,\n 'TTQ': 7.71,\n 'H14': 5.27,\n 'HTI': 7.8,\n 'ONH': 6.14,\n 'LP6': 8.58,\n 'ONL': 4.83,\n 'AHH': 5.06,\n 'HS8': 7.4,\n 'HS9': 4.71,\n 'BL2': 5.82,\n 'AHP': 5.26,\n '6HN': 7.34,\n 'HRP': 5.46,\n 'POM': 3.6,\n 'WPA': 5.11,\n '2ZC': 4.29,\n 'CPC': 2.65,\n 'AIB': 2.4,\n 'XSN': 3.47,\n 'M2S': 5.28,\n 'GND': 6.67,\n 'GNC': 4.6,\n 'MVA': 2.56,\n 'OLZ': 5.32,\n 'M2L': 6.15,\n 'TRF': 6.69,\n 'NZH': 7.66,\n 'SRZ': 5.27,\n 'OLD': 10.47,\n 'CME': 5.86,\n 'CMH': 5.3,\n 'ALA': 2.38,\n 'TRQ': 7.36,\n 'PPN': 7.24,\n 'TRP': 6.07,\n 'TRO': 5.82,\n 'TRN': 5.95,\n 'NYS': 8.1,\n 'ALC': 5.26,\n 'U3X': 11.7,\n 'HVA': 2.58,\n 'TS9': 3.92,\n 'TRX': 7.27,\n 'TRW': 11.8,\n 'LPL': 7.51,\n 'GMA': 4.4,\n 'OMT': 5.07,\n 'CMT': 3.54,\n 'GME': 4.66,\n 'NYB': 6.07,\n 'PR3': 5.12,\n 'LPD': 2.48,\n 'GLU': 4.49,\n '1X6': 6.84,\n 'LPG': 2.39,\n 'GLX': 4.52,\n 'PR4': 4.52,\n 'CML': 6.16,\n 'FME': 4.52,\n 'HTR': 6.48,\n 'PR7': 4.66,\n 'Z3E': 7.2,\n 'GLZ': 2.39,\n 'BMT': 6.37,\n 'WRP': 8.16,\n 'GLY': 2.37,\n 'OMY': 6.11,\n 'MTY': 5.46,\n 'OMX': 6.15,\n 'GLN': 4.46,\n '2XA': 8.25,\n '28X': 7.84,\n '7JA': 9.46,\n 'FLT': 9.65,\n 'GLJ': 3.7,\n 'OMH': 5.26,\n 'TSY': 4.26,\n 'PRV': 4.28,\n 'CS4': 11.21,\n 'DOA': 12.33,\n '23P': 5.42,\n 'CS3': 8.24,\n '6CL': 6.47,\n 'PRR': 5.58,\n 'KST': 11.58,\n 'CS1': 7.23,\n 'PRS': 2.63,\n 'ZYJ': 11.4,\n 'IT1': 9.75,\n 'UU5': 4.98,\n 'ESB': 6.69,\n 'UU4': 2.49,\n 'ESC': 5.65,\n 'LSO': 10.58,\n 'ZYK': 11.45,\n '9NV': 8.99,\n '23F': 5.27,\n 'ORN': 4.25,\n 'HOX': 6.61,\n 'CSD': 3.95,\n 'FP9': 3.03,\n 'DO2': 4.44,\n 'SLL': 11.53,\n 'P3Q': 9.54,\n 'ORQ': 6.04,\n 'MSL': 5.21,\n 'DNP': 2.45,\n 'CSB': 3.51,\n 'WLU': 4.24,\n 'CSA': 5.7,\n 'MT2': 5.51,\n 'CSO': 3.53,\n 'TPO': 4.73,\n 'MSP': 13.11,\n '23S': 6.09,\n 'MSO': 4.96,\n 'PRO': 2.41,\n 'TPL': 5.41,\n 'DNS': 8.79,\n 'CSK': 3.91,\n 'Z70': 7.4,\n 'CSJ': 7.51,\n 'DNW': 7.97,\n 'PRK': 9.15,\n 'GSU': 11.81,\n 'LTA': 6.57,\n 'HPE': 6.63,\n 'TPQ': 6.48,\n 'PRJ': 5.26,\n 'PSW': 4.65,\n 'L3O': 3.89,\n 'CSU': 4.89,\n 'ALY': 7.38,\n 'M3L': 7.12,\n 'CSW': 3.68,\n 'XPR': 7.68,\n 'D4P': 5.66,\n 'FOE': 8.17,\n 'SLZ': 5.69,\n 'CSP': 5.26,\n 'TQI': 7.68,\n 'ALT': 2.72,\n 'CSR': 5.42,\n 'CSS': 3.61,\n 'M3R': 7.18,\n 'ALO': 2.57,\n 'R4K': 4.67,\n 'SMF': 9.0,\n 'MSA': 2.73,\n 'SMC': 3.39,\n 'CSX': 3.47,\n 'SME': 4.8,\n 'ETA': 2.4,\n 'CSZ': 3.6,\n '22G': 8.8,\n 'MSE': 4.62,\n 'ALN': 6.16,\n 'PSH': 7.26,\n 'CTE': 7.27,\n 'DON': 6.72,\n 'CTH': 3.45,\n 'U2X': 11.54,\n '6CW': 7.56,\n 'TQZ': 6.97,\n '3YM': 6.52,\n 'OSE': 4.49,\n '2VA': 9.82,\n 'TQQ': 7.76,\n 'NRG': 8.35,\n 'BPE': 7.24,\n 'F2F': 6.25,\n '1TQ': 8.58,\n 'I2M': 3.13,\n 'NVA': 3.76,\n 'R1A': 8.2,\n 'QPA': 6.95,\n 'C1X': 11.63,\n 'FRD': 5.05,\n 'HR7': 6.98,\n 'SNC': 3.93,\n 'QPH': 5.15,\n '26B': 8.39,\n 'DPQ': 6.54,\n 'DPP': 2.51,\n '2TY': 8.65,\n 'TNR': 6.88,\n 'PTH': 8.35,\n 'DPL': 3.58,\n 'APK': 8.79,\n '1TY': 8.84,\n 'HRG': 7.36,\n 'PTM': 8.74,\n '1U8': 3.62,\n 'PTR': 8.64,\n 'LVG': 3.01,\n '6FL': 4.85,\n 'SOC': 4.05,\n 'KPI': 9.79,\n 'IPG': 2.91,\n 'P2Y': 2.51,\n 'N2C': 3.55,\n 'T0I': 7.34,\n 'MPH': 5.29,\n 'R2T': 4.71,\n 'TOX': 6.78,\n 'P2Q': 9.8,\n 'GPL': 10.77,\n 'MPJ': 5.07,\n 'F2Y': 6.2,\n 'T11': 8.58,\n '9NR': 9.33,\n 'FPR': 8.85,\n '9NF': 8.93,\n 'KPY': 10.17,\n '9NE': 9.77,\n 'TOQ': 7.5,\n 'MPQ': 4.2,\n 'FPK': 3.08,\n 'HQA': 7.25,\n 'SOY': 10.94\n}\nexport const DefaultResidueRadius = 5.0\n\n// http://dx.doi.org/10.1039/b801115j (or 1.6)\nexport const CovalentRadii: { [e: number]: number | undefined } = {\n 1: 0.31, 2: 0.28, 3: 1.28, 4: 0.96, 5: 0.84, 6: 0.76, 7: 0.71, 8: 0.66, 9: 0.57, 10: 0.58, 11: 1.66, 12: 1.41, 13: 1.21, 14: 1.11, 15: 1.07, 16: 1.05, 17: 1.02, 18: 1.06, 19: 2.03, 20: 1.76, 21: 1.7, 22: 1.6, 23: 1.53, 24: 1.39, 25: 1.39, 26: 1.32, 27: 1.26, 28: 1.24, 29: 1.32, 30: 1.22, 31: 1.22, 32: 1.2, 33: 1.19, 34: 1.2, 35: 1.2, 36: 1.16, 37: 2.2, 38: 1.95, 39: 1.9, 40: 1.75, 41: 1.64, 42: 1.54, 43: 1.47, 44: 1.46, 45: 1.42, 46: 1.39, 47: 1.45, 48: 1.44, 49: 1.42, 50: 1.39, 51: 1.39, 52: 1.38, 53: 1.39, 54: 1.4, 55: 2.44, 56: 2.15, 57: 2.07, 58: 2.04, 59: 2.03, 60: 2.01, 61: 1.99, 62: 1.98, 63: 1.98, 64: 1.96, 65: 1.94, 66: 1.92, 67: 1.92, 68: 1.89, 69: 1.9, 70: 1.87, 71: 1.87, 72: 1.75, 73: 1.7, 74: 1.62, 75: 1.51, 76: 1.44, 77: 1.41, 78: 1.36, 79: 1.36, 80: 1.32, 81: 1.45, 82: 1.46, 83: 1.48, 84: 1.4, 85: 1.5, 86: 1.5, 87: 2.6, 88: 2.21, 89: 2.15, 90: 2.06, 91: 2.0, 92: 1.96, 93: 1.9, 94: 1.87, 95: 1.8, 96: 1.69, 97: 1.6, 98: 1.6, 99: 1.6, 100: 1.6, 101: 1.6, 102: 1.6, 103: 1.6, 104: 1.6, 105: 1.6, 106: 1.6, 107: 1.6, 108: 1.6, 109: 1.6, 110: 1.6, 111: 1.6, 112: 1.6, 113: 1.6, 114: 1.6, 115: 1.6, 116: 1.6, 117: 1.6, 118: 1.6\n}\nexport const DefaultCovalentRadius = 1.6\n\nexport const Valences: { [e: number]: number[] | undefined } = {\n 1: [ 1 ],\n 2: [ 0 ],\n 3: [ 1 ],\n 4: [ 2 ],\n 5: [ 3 ],\n 6: [ 4 ],\n 7: [ 3 ],\n 8: [ 2 ],\n 9: [ 1 ],\n 10: [ 0 ],\n 11: [ 1 ],\n 12: [ 2 ],\n 13: [ 6 ],\n 14: [ 6 ],\n 15: [ 3, 5, 7 ],\n 16: [ 2, 4, 6 ],\n 17: [ 1 ],\n 18: [ 0 ],\n 19: [ 1 ],\n 20: [ 2 ],\n\n 31: [ 3 ],\n 32: [ 4 ],\n 33: [ 3, 5 ],\n 34: [ 2, 4, 6 ],\n 35: [ 1 ],\n 36: [ 0 ],\n 37: [ 1 ],\n 38: [ 2 ],\n\n 49: [ 3 ],\n 50: [ 4 ],\n 51: [ 3, 5 ],\n 52: [ 2 ],\n 53: [ 1, 2, 5 ],\n 54: [ 0, 2 ],\n 55: [ 1 ],\n 56: [ 2 ],\n\n 81: [ 3 ],\n 82: [ 4 ],\n 83: [ 3 ],\n 84: [ 2 ],\n 85: [ 1 ],\n 86: [ 0 ],\n 87: [ 1 ],\n 88: [ 2 ]\n}\nexport const DefaultValence = -1\n\nexport const OuterShellElectronCounts: { [e: number]: number | undefined } = {\n1: 1, 2: 2, 3: 1, 4: 2, 5: 3, 6: 4, 7: 5, 8: 6, 9: 7, 10: 8, 11: 1, 12: 2, 13: 3, 14: 4, 15: 5, 16: 6, 17: 7, 18: 8, 19: 1, 20: 2, 21: 3, 22: 4, 23: 5, 24: 6, 25: 7, 26: 8, 27: 9, 28: 10, 29: 11, 30: 2, 31: 3, 32: 4, 33: 5, 34: 6, 35: 7, 36: 8, 37: 1, 38: 2, 39: 3, 40: 4, 41: 5, 42: 6, 43: 7, 44: 8, 45: 9, 46: 10, 47: 11, 48: 2, 49: 3, 50: 4, 51: 5, 52: 6, 53: 7, 54: 8, 55: 1, 56: 2, 57: 3, 58: 4, 59: 3, 60: 4, 61: 5, 62: 6, 63: 7, 64: 8, 65: 9, 66: 10, 67: 11, 68: 12, 69: 13, 70: 14, 71: 15, 72: 4, 73: 5, 74: 6, 75: 7, 76: 8, 77: 9, 78: 10, 79: 11, 80: 2, 81: 3, 82: 4, 83: 5, 84: 6, 85: 7, 86: 8, 87: 1, 88: 2, 89: 3, 90: 4, 91: 3, 92: 4, 93: 5, 94: 6, 95: 7, 96: 8, 97: 9, 98: 10, 99: 11, 100: 12, 101: 13, 102: 14, 103: 15, 104: 2, 105: 2, 106: 2, 107: 2, 108: 2, 109: 2, 110: 2, 111: 2, 112: 2, 113: 3, 114: 4, 115: 5, 116: 6, 117: 7, 118: 8\n}\nexport const DefaultOuterShellElectronCount = 2\n\n// http://blanco.biomol.uci.edu/Whole_residue_HFscales.txt\n// https://www.nature.com/articles/nsb1096-842\nexport const ResidueHydrophobicity: { [k: string]: [number, number, number] } = {\n // AA DGwif DGwoct Oct-IF\n 'ALA': [ 0.17, 0.50, 0.33 ],\n 'ARG': [ 0.81, 1.81, 1.00 ],\n 'ASN': [ 0.42, 0.85, 0.43 ],\n 'ASP': [ 1.23, 3.64, 2.41 ],\n 'ASH': [ -0.07, 0.43, 0.50 ],\n 'CYS': [ -0.24, -0.02, 0.22 ],\n 'GLN': [ 0.58, 0.77, 0.19 ],\n 'GLU': [ 2.02, 3.63, 1.61 ],\n 'GLH': [ -0.01, 0.11, 0.12 ],\n 'GLY': [ 0.01, 1.15, 1.14 ],\n // \"His+\": [ 0.96, 2.33, 1.37 ],\n 'HIS': [ 0.17, 0.11, -0.06 ],\n 'ILE': [ -0.31, -1.12, -0.81 ],\n 'LEU': [ -0.56, -1.25, -0.69 ],\n 'LYS': [ 0.99, 2.80, 1.81 ],\n 'MET': [ -0.23, -0.67, -0.44 ],\n 'PHE': [ -1.13, -1.71, -0.58 ],\n 'PRO': [ 0.45, 0.14, -0.31 ],\n 'SER': [ 0.13, 0.46, 0.33 ],\n 'THR': [ 0.14, 0.25, 0.11 ],\n 'TRP': [ -1.85, -2.09, -0.24 ],\n 'TYR': [ -0.94, -0.71, 0.23 ],\n 'VAL': [ 0.07, -0.46, -0.53 ]\n}\nexport const DefaultResidueHydrophobicity = [ 0.00, 0.00, 0.00 ]\n\nexport const AA1: { [k: string]: string } = {\n 'HIS': 'H',\n 'ARG': 'R',\n 'LYS': 'K',\n 'ILE': 'I',\n 'PHE': 'F',\n 'LEU': 'L',\n 'TRP': 'W',\n 'ALA': 'A',\n 'MET': 'M',\n 'PRO': 'P',\n 'CYS': 'C',\n 'ASN': 'N',\n 'VAL': 'V',\n 'GLY': 'G',\n 'SER': 'S',\n 'GLN': 'Q',\n 'TYR': 'Y',\n 'ASP': 'D',\n 'GLU': 'E',\n 'THR': 'T',\n\n 'SEC': 'U', // as per IUPAC definition\n 'PYL': 'O', // as per IUPAC definition\n}\n\nexport const AA3 = Object.keys(AA1)\n\nexport const RnaBases = [ 'A', 'C', 'T', 'G', 'U', 'I' ]\n\nexport const DnaBases = [ 'DA', 'DC', 'DT', 'DG', 'DU', 'DI' ]\n\nexport const PurinBases = [ 'A', 'G', 'I', 'DA', 'DG', 'DI' ]\n\nexport const Bases = RnaBases.concat(DnaBases)\n\nexport const WaterNames = [\n 'SOL', 'WAT', 'HOH', 'H2O', 'W', 'DOD', 'D3O', 'TIP3', 'TIP4', 'SPC'\n]\n\n// all chemical components with the word \"ion\" in their name, Sep 2016\n//\n// SET SESSION group_concat_max_len = 1000000;\n// SELECT GROUP_CONCAT(id_ ORDER BY id_ ASC SEPARATOR '\", \"') from\n// (\n// SELECT count(obj_id) as c, id_\n// FROM pdb.chem_comp WHERE name LIKE \"% ION%\"\n// GROUP BY id_\n// ) AS t1;\nexport const IonNames = [\n '118', '119', '1AL', '1CU', '2FK', '2HP', '2OF', '3CO',\n '3MT', '3NI', '3OF', '3P8', '4MO', '4PU', '543', '6MO', 'ACT', 'AG', 'AL',\n 'ALF', 'AM', 'ATH', 'AU', 'AU3', 'AUC', 'AZI', 'BA', 'BCT', 'BEF', 'BF4', 'BO4',\n 'BR', 'BS3', 'BSY', 'CA', 'CAC', 'CD', 'CD1', 'CD3', 'CD5', 'CE', 'CHT', 'CL',\n 'CO', 'CO3', 'CO5', 'CON', 'CR', 'CS', 'CSB', 'CU', 'CU1', 'CU3', 'CUA', 'CUZ',\n 'CYN', 'DME', 'DMI', 'DSC', 'DTI', 'DY', 'E4N', 'EDR', 'EMC', 'ER3', 'EU',\n 'EU3', 'F', 'FE', 'FE2', 'FPO', 'GA', 'GD3', 'GEP', 'HAI', 'HG', 'HGC', 'IN',\n 'IOD', 'IR', 'IR3', 'IRI', 'IUM', 'K', 'KO4', 'LA', 'LCO', 'LCP', 'LI', 'LU',\n 'MAC', 'MG', 'MH2', 'MH3', 'MLI', 'MLT', 'MMC', 'MN', 'MN3', 'MN5', 'MN6',\n 'MO1', 'MO2', 'MO3', 'MO4', 'MO5', 'MO6', 'MOO', 'MOS', 'MOW', 'MW1', 'MW2',\n 'MW3', 'NA', 'NA2', 'NA5', 'NA6', 'NAO', 'NAW', 'NCO', 'NET', 'NH4', 'NI',\n 'NI1', 'NI2', 'NI3', 'NO2', 'NO3', 'NRU', 'O4M', 'OAA', 'OC1', 'OC2', 'OC3',\n 'OC4', 'OC5', 'OC6', 'OC7', 'OC8', 'OCL', 'OCM', 'OCN', 'OCO', 'OF1', 'OF2',\n 'OF3', 'OH', 'OS', 'OS4', 'OXL', 'PB', 'PBM', 'PD', 'PDV', 'PER', 'PI', 'PO3',\n 'PO4', 'PR', 'PT', 'PT4', 'PTN', 'RB', 'RH3', 'RHD', 'RU', 'SB', 'SCN', 'SE4',\n 'SEK', 'SM', 'SMO', 'SO3', 'SO4', 'SR', 'T1A', 'TB', 'TBA', 'TCN', 'TEA', 'TH',\n 'THE', 'TL', 'TMA', 'TRA', 'UNX', 'V', 'VN3', 'VO4', 'W', 'WO5', 'Y1', 'YB',\n 'YB2', 'YH', 'YT3', 'ZCM', 'ZN', 'ZN2', 'ZN3', 'ZNO', 'ZO3',\n // additional ion names\n 'OHX'\n]\n\n// all chemical components with the word \"%saccharide%\" in their type, Sep 2016\n//\n// SET SESSION group_concat_max_len = 1000000;\n// select GROUP_CONCAT(id_ ORDER BY id_ ASC SEPARATOR '\", \"') from\n// (\n// SELECT count(obj_id), id_\n// FROM pdb.chem_comp WHERE type like \"%SACCHARIDE%\"\n// GROUP BY id_\n// ) AS t1;\nexport const SaccharideNames = [\n '045', '0AT', '0BD', '0MK', '0NZ', '0TS', '0V4', '0XY', '0YT', '10M',\n '147', '149', '14T', '15L', '16G', '18T', '18Y', '1AR', '1BW', '1GL', '1GN',\n '1JB', '1LL', '1NA', '1S3', '26M', '26Q', '26R', '26V', '26W', '26Y', '27C',\n '289', '291', '293', '2DG', '2F8', '2FG', '2FL', '2FP', '2GL', '2M4', '2M5',\n '32O', '34V', '3CM', '3DO', '3DY', '3FM', '3LR', '3MF', '3MG', '3SA', '3ZW',\n '46D', '46M', '46Z', '48Z', '4CQ', '4GC', '4NN', '50A', '5DI', '5GF', '5MM',\n '5RP', '5SA', '5SP', '64K', '6PG', '6SA', '7JZ', '7SA', 'A1Q', 'A2G', 'AAB',\n 'AAL', 'AAO', 'ABC', 'ABD', 'ABE', 'ABF', 'ABL', 'ACG', 'ACI', 'ACR', 'ACX',\n 'ADA', 'ADG', 'ADR', 'AF1', 'AFD', 'AFL', 'AFO', 'AFP', 'AFR', 'AGC', 'AGH',\n 'AGL', 'AHR', 'AIG', 'ALL', 'ALX', 'AMU', 'AOG', 'AOS', 'ARA', 'ARB', 'ARE',\n 'ARI', 'ASG', 'ASO', 'AXP', 'AXR', 'B0D', 'B16', 'B2G', 'B4G', 'B6D', 'B8D',\n 'B9D', 'BBK', 'BCD', 'BDG', 'BDP', 'BDR', 'BEM', 'BFP', 'BGC', 'BGL', 'BGP',\n 'BGS', 'BHG', 'BMA', 'BMX', 'BNG', 'BNX', 'BOG', 'BRI', 'BXF', 'BXP', 'BXX',\n 'BXY', 'C3X', 'C4X', 'C5X', 'CAP', 'CBI', 'CBK', 'CBS', 'CDR', 'CEG', 'CGF',\n 'CHO', 'CR1', 'CR6', 'CRA', 'CT3', 'CTO', 'CTR', 'CTT', 'D6G', 'DAF', 'DAG',\n 'DDA', 'DDB', 'DDL', 'DEL', 'DFR', 'DFX', 'DG0', 'DGC', 'DGD', 'DGM', 'DGS',\n 'DIG', 'DLF', 'DLG', 'DMU', 'DNO', 'DOM', 'DP5', 'DQQ', 'DQR', 'DR2', 'DR3',\n 'DR4', 'DRI', 'DSR', 'DT6', 'DVC', 'E4P', 'E5G', 'EAG', 'EBG', 'EBQ', 'EGA',\n 'EJT', 'EPG', 'ERE', 'ERI', 'F1P', 'F1X', 'F6P', 'FBP', 'FCA', 'FCB', 'FCT',\n 'FDP', 'FDQ', 'FFC', 'FIX', 'FMO', 'FRU', 'FSI', 'FU4', 'FUB', 'FUC', 'FUD',\n 'FUL', 'FXP', 'G16', 'G1P', 'G2F', 'G3I', 'G4D', 'G4S', 'G6D', 'G6P', 'G6S',\n 'GAC', 'GAD', 'GAL', 'GC1', 'GC4', 'GCD', 'GCN', 'GCO', 'GCS', 'GCT', 'GCU',\n 'GCV', 'GCW', 'GCX', 'GE1', 'GFG', 'GFP', 'GIV', 'GL0', 'GL2', 'GL5', 'GL6',\n 'GL7', 'GL9', 'GLA', 'GLB', 'GLC', 'GLD', 'GLF', 'GLG', 'GLO', 'GLP', 'GLS',\n 'GLT', 'GLW', 'GMH', 'GN1', 'GNX', 'GP1', 'GP4', 'GPH', 'GPM', 'GQ1', 'GQ2',\n 'GQ4', 'GS1', 'GS4', 'GSA', 'GSD', 'GTE', 'GTH', 'GTK', 'GTR', 'GTZ', 'GU0',\n 'GU1', 'GU2', 'GU3', 'GU4', 'GU5', 'GU6', 'GU8', 'GU9', 'GUF', 'GUP', 'GUZ',\n 'GYP', 'GYV', 'H2P', 'HDL', 'HMS', 'HS2', 'HSD', 'HSG', 'HSH', 'HSJ', 'HSQ',\n 'HSR', 'HSU', 'HSX', 'HSY', 'HSZ', 'IAB', 'IDG', 'IDR', 'IDS', 'IDT', 'IDU',\n 'IDX', 'IDY', 'IMK', 'IN1', 'IPT', 'ISL', 'KBG', 'KD2', 'KDA', 'KDM', 'KDO',\n 'KFN', 'KO1', 'KO2', 'KTU', 'L6S', 'LAG', 'LAI', 'LAK', 'LAO', 'LAT', 'LB2',\n 'LBT', 'LCN', 'LDY', 'LGC', 'LGU', 'LM2', 'LMT', 'LMU', 'LOG', 'LOX', 'LPK',\n 'LSM', 'LTM', 'LVZ', 'LXB', 'LXZ', 'M1F', 'M3M', 'M6P', 'M8C', 'MA1', 'MA2',\n 'MA3', 'MAB', 'MAG', 'MAL', 'MAN', 'MAT', 'MAV', 'MAW', 'MBG', 'MCU', 'MDA',\n 'MDM', 'MDP', 'MFA', 'MFB', 'MFU', 'MG5', 'MGA', 'MGL', 'MLB', 'MMA', 'MMN',\n 'MN0', 'MRP', 'MTT', 'MUG', 'MVP', 'MXY', 'N1L', 'N9S', 'NAA', 'NAG', 'NBG',\n 'NDG', 'NED', 'NG1', 'NG6', 'NGA', 'NGB', 'NGC', 'NGE', 'NGF', 'NGL', 'NGS',\n 'NGY', 'NHF', 'NM6', 'NM9', 'NTF', 'NTO', 'NTP', 'NXD', 'NYT', 'OPG', 'OPM',\n 'ORP', 'OX2', 'P3M', 'P53', 'P6P', 'PA5', 'PNA', 'PNG', 'PNW', 'PRP', 'PSJ',\n 'PSV', 'PTQ', 'QDK', 'QPS', 'QV4', 'R1P', 'R1X', 'R2B', 'R5P', 'RAA', 'RAE',\n 'RAF', 'RAM', 'RAO', 'RAT', 'RB5', 'RBL', 'RCD', 'RDP', 'REL', 'RER', 'RF5',\n 'RG1', 'RGG', 'RHA', 'RIB', 'RIP', 'RNS', 'RNT', 'ROB', 'ROR', 'RPA', 'RST',\n 'RUB', 'RUU', 'RZM', 'S6P', 'S7P', 'SA0', 'SCR', 'SDD', 'SF6', 'SF9', 'SG4',\n 'SG5', 'SG6', 'SG7', 'SGA', 'SGC', 'SGD', 'SGN', 'SGS', 'SHB', 'SHG', 'SI3',\n 'SIO', 'SOE', 'SOL', 'SSG', 'SUC', 'SUP', 'SUS', 'T6P', 'T6T', 'TAG', 'TCB',\n 'TDG', 'TGK', 'TGY', 'TH1', 'TIA', 'TM5', 'TM6', 'TM9', 'TMR', 'TMX', 'TOA',\n 'TOC', 'TRE', 'TYV', 'UCD', 'UDC', 'VG1', 'X0X', 'X1X', 'X2F', 'X4S', 'X5S',\n 'X6X', 'XBP', 'XDN', 'XDP', 'XIF', 'XIM', 'XLF', 'XLS', 'XMM', 'XUL', 'XXR',\n 'XYP', 'XYS', 'YO5', 'Z3Q', 'Z6J', 'Z9M', 'ZDC', 'ZDM'\n]\n\nexport const ProteinBackboneAtoms = [\n 'CA', 'C', 'N', 'O',\n 'O1', 'O2', 'OC1', 'OC2', 'OX1', 'OXT', 'OT1', 'OT2',\n 'H', 'H1', 'H2', 'H3', 'HA', 'HN',\n 'BB'\n]\n\nexport const NucleicBackboneAtoms = [\n 'P', 'OP1', 'OP2', 'HOP2', 'HOP3',\n \"O2'\", \"O3'\", \"O4'\", \"O5'\", \"C1'\", \"C2'\", \"C3'\", \"C4'\", \"C5'\",\n \"H1'\", \"H2'\", \"H2''\", \"HO2'\", \"H3'\", \"H4'\", \"H5'\", \"H5''\", \"HO3'\", \"HO5'\",\n 'O2*', 'O3*', 'O4*', 'O5*', 'C1*', 'C2*', 'C3*', 'C4*', 'C5*'\n]\n\nexport const ResidueTypeAtoms: { [k: number]: { [k: string]: string|string[] } } = {}\n\nResidueTypeAtoms[ ProteinBackboneType ] = {\n trace: 'CA',\n direction1: 'C',\n direction2: [ 'O', 'OC1', 'O1', 'OX1', 'OXT', 'OT1', 'OT2' ],\n backboneStart: 'N',\n backboneEnd: 'C'\n}\n\nResidueTypeAtoms[ RnaBackboneType ] = {\n trace: [ \"C4'\", 'C4*' ],\n direction1: [ \"C1'\", 'C1*' ],\n direction2: [ \"C3'\", 'C3*' ],\n backboneStart: 'P',\n backboneEnd: [ \"O3'\", 'O3*' ]\n}\n\nResidueTypeAtoms[ DnaBackboneType ] = {\n trace: [ \"C3'\", 'C3*' ],\n direction1: [ \"C2'\", 'C2*' ],\n direction2: [ \"O4'\", 'O4*' ],\n backboneStart: 'P',\n backboneEnd: [ \"O3'\", 'O3*' ]\n}\n\nResidueTypeAtoms[ CgProteinBackboneType ] = {\n trace: [ 'CA', 'BB' ],\n backboneStart: [ 'CA', 'BB' ],\n backboneEnd: [ 'CA', 'BB' ]\n}\n\nResidueTypeAtoms[ CgRnaBackboneType ] = {\n trace: [ \"C4'\", 'C4*', 'P' ],\n backboneStart: [ \"C4'\", 'C4*', 'P' ],\n backboneEnd: [ \"C4'\", 'C4*', 'P' ]\n}\n\nResidueTypeAtoms[ CgDnaBackboneType ] = {\n trace: [ \"C3'\", 'C3*', \"C2'\", 'P' ], // C2' is used in martini ff\n backboneStart: [ \"C3'\", 'C3*', \"C2'\", 'P' ],\n backboneEnd: [ \"C3'\", 'C3*', \"C2'\", 'P' ]\n}\n\nResidueTypeAtoms[ UnknownBackboneType ] = {}\n\n// Mappings taken from Meeko: https://github.com/forlilab/Meeko/blob/develop/meeko/utils/autodock4_atom_types_elements.py\nexport const PDBQTSpecialElements = {\n 'HD': 'H',\n 'HS': 'H',\n 'A': 'C',\n 'NA': 'N',\n 'NS': 'N',\n 'OA': 'O',\n 'OS': 'O',\n 'SA': 'S',\n 'G0': 'C',\n 'G1': 'C',\n 'G2': 'C',\n 'G3': 'C',\n 'CG0': 'C',\n 'CG1': 'C',\n 'CG2': 'C',\n 'CG3': 'C',\n 'W': 'O'\n}","/**\n * @file Geometry\n * @author Fred Ludlow \n * @author Alexander Rose \n */\n\nimport { Vector3 } from 'three'\n\nimport { Elements } from '../structure/structure-constants'\nimport { degToRad } from '../math/math-utils'\nimport AtomProxy from '../proxy/atom-proxy'\n\n// Changed numbering so they're mostly inline with coordination number\n// from VSEPR\nexport const enum AtomGeometry {\n Spherical = 0,\n Terminal = 1,\n Linear = 2,\n Trigonal = 3,\n Tetrahedral = 4,\n TrigonalBiPyramidal = 5,\n Octahedral = 6,\n SquarePlanar = 7, // Okay, it breaks down somewhere!\n Unknown = 8\n}\n\nexport function assignGeometry (totalCoordination: number): AtomGeometry {\n switch(totalCoordination){\n case 0:\n return AtomGeometry.Spherical\n case 1:\n return AtomGeometry.Terminal\n case 2:\n return AtomGeometry.Linear\n case 3:\n return AtomGeometry.Trigonal\n case 4:\n return AtomGeometry.Tetrahedral\n default:\n return AtomGeometry.Unknown\n }\n}\n\nexport const Angles = new Map([\n [ AtomGeometry.Linear, degToRad(180) ],\n [ AtomGeometry.Trigonal, degToRad(120) ],\n [ AtomGeometry.Tetrahedral, degToRad(109.4721) ],\n [ AtomGeometry.Octahedral, degToRad(90) ]\n])\n\n/**\n * Calculate the angles x-1-2 for all x where x is a heavy atom bonded to ap1.\n * @param {AtomProxy} ap1 First atom (angle centre)\n * @param {AtomProxy} ap2 Second atom\n * @return {number[]} Angles in radians\n */\nexport function calcAngles (ap1: AtomProxy, ap2: AtomProxy): number[] {\n let angles: number[] = []\n const d1 = new Vector3()\n const d2 = new Vector3()\n d1.subVectors(ap2 as any, ap1 as any)\n ap1.eachBondedAtom( x => {\n if (x.number !== Elements.H) {\n d2.subVectors(x as any, ap1 as any)\n angles.push(d1.angleTo(d2))\n }\n })\n return angles\n}\n\n/**\n * Find two neighbours of ap1 to define a plane (if possible) and\n * measure angle out of plane to ap2\n * @param {AtomProxy} ap1 First atom (angle centre)\n * @param {AtomProxy} ap2 Second atom (out-of-plane)\n * @return {number} Angle from plane to second atom\n */\nexport function calcPlaneAngle (ap1: AtomProxy, ap2: AtomProxy): number | undefined {\n const x1 = ap1.clone()\n\n const v12 = new Vector3()\n v12.subVectors(ap2 as any, ap1 as any)\n\n const neighbours = [new Vector3(), new Vector3()]\n let ni = 0\n ap1.eachBondedAtom( x => {\n if (ni > 1) { return }\n if (x.number !== Elements.H) {\n x1.index = x.index\n neighbours[ni++].subVectors(x as any, ap1 as any)\n }\n })\n if (ni === 1) {\n x1.eachBondedAtom( x => {\n if (ni > 1) { return }\n if (x.number !== Elements.H && x.index !== ap1.index){\n neighbours[ni++].subVectors(x as any, ap1 as any)\n }\n })\n }\n if (ni !== 2) {\n return\n }\n\n const cp = neighbours[0].cross(neighbours[1])\n return Math.abs((Math.PI / 2) - cp.angleTo(v12))\n}\n","/**\n * @file Valence Model\n * @author Fred Ludlow \n * @author Alexander Rose \n */\n\n/**\n * Reworked ValenceModel\n *\n * TODO:\n * Ensure proper treatment of disorder/models. e.g. V257 N in 5vim\n * Formal charge of 255 for SO4 anion (e.g. 5ghl)\n * Have removed a lot of explicit features (as I think they're more\n * generally captured by better VM).\n * Could we instead have a \"delocalised negative/positive\" charge\n * feature and flag these up?\n *\n */\nimport { Data } from '../structure/data'\nimport AtomProxy from '../proxy/atom-proxy'\nimport { AtomGeometry, assignGeometry } from './geometry'\nimport { Elements } from '../structure/structure-constants'\n\n/**\n * Are we involved in some kind of pi system. Either explicitly forming\n * double bond or N, O next to a double bond, except:\n *\n * N,O with degree 4 cannot be conjugated.\n * N,O adjacent to P=O or S=O do not qualify (keeps sulfonamide N sp3 geom)\n */\nfunction isConjugated (a: AtomProxy) {\n const _bp = a.structure.getBondProxy()\n const atomicNumber = a.number\n const hetero = atomicNumber === Elements.O || atomicNumber === Elements.N\n\n if (hetero && a.bondCount === 4) {\n return false\n }\n\n let flag = false\n\n a.eachBond(b => {\n if (b.bondOrder > 1) {\n flag = true\n return\n }\n if (hetero) {\n const a2 = b.getOtherAtom(a)\n\n a2.eachBond(b2 => {\n if (b2.bondOrder > 1) {\n const atomicNumber2 = a2.number\n if (\n (atomicNumber2 === Elements.P || atomicNumber2 === Elements.S) &&\n b2.getOtherAtom(a2).number === Elements.O\n ) {\n return\n }\n flag = true\n }\n }, _bp) // Avoid reuse of structure._bp\n }\n })\n\n return flag\n}\n\n/* function hasExplicitCharge(r: ResidueProxy) {\n let flag = false\n r.eachAtom(a => {\n if (a.formalCharge != null && a.formalCharge !== 0) flag = true\n })\n return flag\n}\n\nfunction hasExplicitHydrogen(r: ResidueProxy) {\n let flag = false\n r.eachAtom(a => {\n if (a.number === Elements.H) flag = true\n })\n return flag\n} */\n\nexport function explicitValence (a: AtomProxy) {\n let v = 0\n a.eachBond(b => v += b.bondOrder)\n return v\n}\n\n/**\n * Attempts to produce a consistent charge and implicit\n * H-count for an atom.\n *\n * If both params.assignCharge and params.assignH, this\n * approximately followsthe rules described in\n * https://docs.eyesopen.com/toolkits/python/oechemtk/valence.html#openeye-hydrogen-count-model\n *\n * If only charge or hydrogens are to be assigned it takes\n * a much simpler view and deduces one from the other\n *\n * @param {AtomProxy} a Atom to analyze\n * @param {assignChargeHParams} params What to assign\n */\nexport function calculateHydrogensCharge (a: AtomProxy, params: ValenceModelParams) {\n const hydrogenCount = a.bondToElementCount(Elements.H)\n let charge = a.formalCharge || 0\n\n const assignCharge = (params.assignCharge === 'always' ||\n (params.assignCharge === 'auto' && charge === 0))\n const assignH = (params.assignH === 'always' ||\n (params.assignH === 'auto' && hydrogenCount === 0))\n\n const degree = a.bondCount\n const valence = explicitValence(a)\n\n const conjugated = isConjugated(a)\n const multiBond = (valence - degree > 0)\n\n\n let implicitHCount = 0\n let geom = AtomGeometry.Unknown\n\n switch (a.number) {\n case Elements.H:\n if (assignCharge){\n if (degree === 0){\n charge = 1\n geom = AtomGeometry.Spherical\n } else if (degree === 1) {\n charge = 0\n geom = AtomGeometry.Terminal\n }\n }\n break\n\n case Elements.C:\n // TODO: Isocyanide?\n if (assignCharge) {\n charge = 0 // Assume carbon always neutral\n }\n if (assignH) {\n // Carbocation/carbanion are 3-valent\n implicitHCount = Math.max(0, 4 - valence - Math.abs(charge))\n }\n // Carbocation is planar, carbanion is tetrahedral\n geom = assignGeometry(degree + implicitHCount + Math.max(0, -charge))\n break\n\n case Elements.N:\n if (assignCharge) {\n if (!assignH) { // Trust input H explicitly:\n charge = valence - 3\n } else if (conjugated && valence < 4) {\n // Neutral unless amidine/guanidine double-bonded N:\n if (degree - hydrogenCount === 1 && valence - hydrogenCount === 2) {\n charge = 1\n } else {\n charge = 0\n }\n } else {\n // Sulfonamide nitrogen and classed as sp3 in conjugation model but\n // they won't be charged\n // Don't assign charge to nitrogens bound to metals\n let flag = false\n a.eachBondedAtom(ba => {\n if (ba.number === Elements.S || ba.isMetal()) flag = true\n })\n if (flag) charge = 0\n else charge = 1\n // TODO: Planarity sanity check?\n }\n\n }\n\n if (assignH) {\n // NH4+ -> 4, 1' amide -> 2, nitro N/N+ depiction -> 0\n implicitHCount = Math.max(0, 3 - valence + charge)\n }\n\n if (conjugated && !multiBond) {\n // Amide, anilinic N etc. cannot consider lone-pair for geometry purposes\n // Anilinic N geometry is depenent on ring electronics, for our purposes we\n // assume it's trigonal!\n geom = assignGeometry(degree + implicitHCount - charge)\n } else {\n // Everything else, pyridine, amine, nitrile, lp plays normal role:\n geom = assignGeometry(degree + implicitHCount + 1 - charge)\n }\n break\n\n case Elements.O:\n if (assignCharge) {\n if (!assignH) {\n charge = valence - 2 //\n }\n if (valence === 1) {\n a.eachBondedAtom(ba => {\n ba.eachBond(b => {\n const oa = b.getOtherAtom(ba)\n if (oa.index !== a.index && oa.number === Elements.O && b.bondOrder === 2){\n charge = -1\n }\n })\n })\n }\n }\n if (assignH) {\n // ethanol -> 1, carboxylate -> -1\n implicitHCount = Math.max(0, 2 - valence + charge)\n }\n if (conjugated && !multiBond){\n // carboxylate OH, phenol OH, one lone-pair taken up with conjugation\n geom = assignGeometry(degree + implicitHCount - charge + 1)\n } else {\n // Carbonyl (trigonal)\n geom = assignGeometry(degree + implicitHCount - charge + 2)\n }\n break\n\n // Only handles thiols/thiolates/thioether/sulfonium. Sulfoxides and higher\n // oxidiation states are assumed neutral S (charge carried on O if required)\n case Elements.S:\n if (assignCharge) {\n if (!assignH) {\n if (valence <= 3 && !a.bondToElementCount(Elements.O)) {\n charge = valence - 2 // e.g. explicitly deprotonated thiol\n } else {\n charge = 0\n }\n }\n }\n if (assignH){\n if (valence < 2){\n implicitHCount = Math.max(0, 2 - valence + charge)\n }\n }\n if (valence <= 3){\n // Thiol, thiolate, tioether -> tetrahedral\n geom = assignGeometry(degree + implicitHCount - charge + 2)\n }\n\n break\n\n case Elements.F:\n case Elements.CL:\n case Elements.BR:\n case Elements.I:\n case Elements.AT:\n // Never implicitly protonate halides\n if (assignCharge) {\n charge = valence - 1\n }\n break\n\n case Elements.LI:\n case Elements.NA:\n case Elements.K:\n case Elements.RB:\n case Elements.CS:\n case Elements.FR:\n if (assignCharge) {\n charge = 1 - valence\n }\n break\n\n case Elements.BE:\n case Elements.MG:\n case Elements.CA:\n case Elements.SR:\n case Elements.BA:\n case Elements.RA:\n if (assignCharge) {\n charge = 2 - valence\n }\n break\n\n default:\n console.warn('Requested charge, protonation for an unhandled element', a.element)\n }\n\n return [ charge, implicitHCount, implicitHCount + hydrogenCount, geom ]\n}\n\n\nexport interface ValenceModel {\n charge: Int8Array,\n implicitH: Int8Array,\n totalH: Int8Array,\n idealGeometry: Int8Array\n}\n\nexport interface ValenceModelParams {\n assignCharge: string,\n assignH: string\n}\n\nexport function ValenceModel (data: Data, params: ValenceModelParams) {\n const structure = data.structure\n const n = structure.atomCount\n\n const charge = new Int8Array(n)\n const implicitH = new Int8Array(n)\n const totalH = new Int8Array(n)\n const idealGeometry = new Int8Array(n)\n\n structure.eachAtom(a => {\n const i = a.index\n const [ chg, implH, totH, geom ] = calculateHydrogensCharge(a, params)\n charge[ i ] = chg\n implicitH[ i ] = implH\n totalH[ i ] = totH\n idealGeometry[ i ] = geom\n })\n\n return { charge, implicitH, totalH, idealGeometry }\n}","\nimport Structure from './structure'\nimport SpatialHash from '../geometry/spatial-hash'\nimport { ValenceModel } from '../chemistry/valence-model'\n\nexport interface Data {\n structure: Structure\n '@spatialLookup': SpatialHash | undefined\n '@valenceModel': ValenceModel | undefined\n}\n\nexport function createData(structure: Structure): Data {\n return {\n structure,\n '@spatialLookup': undefined,\n '@valenceModel': undefined\n }\n}\n\nexport function spatialLookup(data: Data): SpatialHash {\n if (data['@spatialLookup']) return data['@spatialLookup']!\n const lookup = new SpatialHash(data.structure.atomStore, data.structure.boundingBox)\n data['@spatialLookup'] = lookup\n return lookup\n}\n\nexport function valenceModel(data: Data): ValenceModel {\n if (data['@valenceModel']) return data['@valenceModel']!\n const valenceModel = ValenceModel(data, {assignCharge: 'auto', assignH: 'auto'})\n data['@valenceModel'] = valenceModel\n return valenceModel\n}\n","/**\n * @file Functional Groups\n * @author Alexander Rose \n */\n\nimport AtomProxy from '../proxy/atom-proxy'\nimport { Elements } from '../structure/structure-constants'\n\n/**\n * Nitrogen in a quaternary amine\n */\nexport function isQuaternaryAmine (a: AtomProxy) {\n return (\n a.number === 7 &&\n a.bondCount === 4 &&\n a.bondToElementCount(Elements.H) === 0\n )\n}\n\n/**\n * Nitrogen in a tertiary amine\n */\nexport function isTertiaryAmine (a: AtomProxy, idealValence: number) {\n return (\n a.number === 7 &&\n a.bondCount >= 3 &&\n idealValence === 3\n )\n}\n\n/**\n * Nitrogen in an imide\n */\nexport function isImide (a: AtomProxy) {\n let flag = false\n if (a.number === Elements.N && (a.bondCount - a.bondToElementCount(Elements.H)) === 2) {\n let carbonylCount = 0\n a.eachBondedAtom(ba => {\n if (isCarbonyl(ba)) ++carbonylCount\n })\n flag = carbonylCount === 2\n }\n return flag\n}\n\n/**\n * Nitrogen in an amide\n */\nexport function isAmide (a: AtomProxy) {\n let flag = false\n if (a.number === Elements.N && (a.bondCount - a.bondToElementCount(Elements.H)) === 2) {\n let carbonylCount = 0\n a.eachBondedAtom(ba => {\n if (isCarbonyl(ba)) ++carbonylCount\n })\n flag = carbonylCount === 1\n }\n return flag\n}\n\n/**\n * Sulfur in a sulfonium group\n */\nexport function isSulfonium (a: AtomProxy) {\n return (\n a.number === 16 &&\n a.bondCount === 3 &&\n a.bondToElementCount(Elements.H) === 0\n )\n}\n\n/**\n * Sulfur in a sulfonic acid or sulfonate group\n */\nexport function isSulfonicAcid (a: AtomProxy) {\n return (\n a.number === 16 &&\n a.bondToElementCount(Elements.O) === 3\n )\n}\n\n/**\n * Sulfur in a sulfate group\n */\nexport function isSulfate (a: AtomProxy) {\n return (\n a.number === 16 &&\n a.bondToElementCount(Elements.O) === 4\n )\n}\n\n/**\n * Phosphor in a phosphate group\n */\nexport function isPhosphate (a: AtomProxy) {\n return (\n a.number === 15 &&\n a.bondToElementCount(Elements.O) === a.bondCount\n )\n}\n\n/**\n * Halogen with one bond to a carbon\n */\nexport function isHalocarbon (a: AtomProxy) {\n return (\n a.isHalogen() &&\n a.bondCount === 1 &&\n a.bondToElementCount(Elements.C) === 1\n )\n}\n\n/**\n * Carbon in a carbonyl/acyl group\n */\nexport function isCarbonyl (a: AtomProxy) {\n let flag = false\n if (a.number === Elements.C) {\n a.eachBond(b => {\n if (b.bondOrder === 2 && b.getOtherAtom(a).number === Elements.O) {\n flag = true\n }\n })\n }\n return flag\n}\n\n/**\n * Carbon in a carboxylate group\n */\nexport function isCarboxylate (a: AtomProxy) {\n let terminalOxygenCount = 0\n if (\n a.number === 6 &&\n a.bondToElementCount(Elements.O) === 2 &&\n a.bondToElementCount(Elements.C) === 1\n ) {\n a.eachBondedAtom(ba => {\n if (ba.number === 8 && ba.bondCount - ba.bondToElementCount(Elements.H) === 1) {\n ++terminalOxygenCount\n }\n })\n }\n return terminalOxygenCount === 2\n}\n\n/**\n * Carbon in a guanidine group\n */\nexport function isGuanidine (a: AtomProxy) {\n let terminalNitrogenCount = 0\n if (\n a.number === 6 &&\n a.bondCount === 3 &&\n a.bondToElementCount(Elements.N) === 3\n ) {\n a.eachBondedAtom(ba => {\n if (ba.bondCount - ba.bondToElementCount(Elements.H) === 1) {\n ++terminalNitrogenCount\n }\n })\n }\n return terminalNitrogenCount === 2\n}\n\n/**\n * Carbon in a acetamidine group\n */\nexport function isAcetamidine (a: AtomProxy) {\n let terminalNitrogenCount = 0\n if (\n a.number === 6 &&\n a.bondCount === 3 &&\n a.bondToElementCount(Elements.N) === 2 &&\n a.bondToElementCount(Elements.C) === 1\n ) {\n a.eachBondedAtom(ba => {\n if (ba.bondCount - ba.bondToElementCount(Elements.H) === 1) {\n ++terminalNitrogenCount\n }\n })\n }\n return terminalNitrogenCount === 2\n}\n\nconst PolarElements = [\n Elements.N, Elements.O, Elements.S,\n Elements.F, Elements.CL, Elements.BR, Elements.I\n]\n\nexport function isPolar (a: AtomProxy) {\n return PolarElements.includes(a.number)\n}\n\nexport function hasPolarNeighbour (a: AtomProxy) {\n let flag = false\n a.eachBondedAtom(ba => {\n if (isPolar(ba)) flag = true\n })\n return flag\n}\n\nexport function hasAromaticNeighbour (a: AtomProxy) {\n let flag = false\n a.eachBondedAtom(function (bap) {\n if (bap.aromatic) flag = true\n })\n return flag\n}\n","/**\n * @file Charged\n * @author Alexander Rose \n * @author Fred Ludlow \n */\n\nimport { Vector3 } from 'three'\n\nimport { defaults } from '../../utils'\nimport { radToDeg } from '../../math/math-utils'\nimport Structure from '../../structure/structure'\nimport { AA3, Bases, Elements } from '../../structure/structure-constants'\nimport { valenceModel } from '../../structure/data'\nimport {\n isGuanidine, isAcetamidine, isSulfonicAcid, isPhosphate, isSulfate, isCarboxylate\n} from '../functional-groups'\nimport {\n Features, FeatureType, FeatureGroup,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\n\nconst PositvelyCharged = [ 'ARG', 'HIS', 'LYS' ]\nconst NegativelyCharged = [ 'GLU', 'ASP' ]\n\nexport function addPositiveCharges (structure: Structure, features: Features) {\n const { charge } = valenceModel(structure.data)\n const atomInGroupDict: { [atomIndex: number]: true } = {}\n\n structure.eachResidue(r => {\n if (PositvelyCharged.includes(r.resname)) {\n const state = createFeatureState(FeatureType.PositiveCharge)\n r.eachAtom(a => {\n if (a.number === Elements.N && a.isSidechain()) {\n addAtom(state, a)\n }\n })\n addFeature(features, state)\n } else if(!AA3.includes(r.resname) && !r.isNucleic()) {\n r.eachAtom(a => {\n let addGroup = false\n const state = createFeatureState(FeatureType.PositiveCharge)\n if (isGuanidine(a)) {\n state.group = FeatureGroup.Guanidine\n addGroup = true\n } else if (isAcetamidine(a)) {\n state.group = FeatureGroup.Acetamidine\n addGroup = true\n }\n if (addGroup) {\n a.eachBondedAtom(a => {\n if (a.number === Elements.N) {\n atomInGroupDict[a.index] = true\n addAtom(state, a)\n }\n })\n addFeature(features, state)\n }\n })\n r.eachAtom(a => {\n const state = createFeatureState(FeatureType.PositiveCharge)\n if (charge[a.index] > 0) {\n if (!atomInGroupDict[a.index]) {\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n })\n }\n })\n}\n\nexport function addNegativeCharges (structure: Structure, features: Features) {\n const { charge } = valenceModel(structure.data)\n const atomInGroupDict: { [atomIndex: number]: true } = {}\n\n structure.eachResidue(r => {\n if (NegativelyCharged.includes(r.resname)) {\n const state = createFeatureState(FeatureType.NegativeCharge)\n r.eachAtom(a => {\n if (a.number === Elements.O && a.isSidechain()) {\n addAtom(state, a)\n }\n })\n addFeature(features, state)\n } else if (Bases.includes(r.resname)) {\n const state = createFeatureState(FeatureType.NegativeCharge)\n r.eachAtom(a => {\n if (isPhosphate(a)) {\n state.group = FeatureGroup.Phosphate\n a.eachBondedAtom(a => {\n if (a.number === Elements.O) addAtom(state, a)\n })\n addFeature(features, state)\n }\n })\n } else if(!AA3.includes(r.resname) && !Bases.includes(r.resname)) {\n r.eachAtom(a => {\n let addGroup = false\n const state = createFeatureState(FeatureType.NegativeCharge)\n if (isSulfonicAcid(a)) {\n state.group = FeatureGroup.SulfonicAcid\n addGroup = true\n } else if (isPhosphate(a)) {\n state.group = FeatureGroup.Phosphate\n addGroup = true\n } else if (isSulfate(a)) {\n state.group = FeatureGroup.Sulfate\n addGroup = true\n } else if (isCarboxylate(a)) {\n state.group = FeatureGroup.Carboxylate\n addGroup = true\n }\n if (addGroup) {\n a.eachBondedAtom(a => {\n if (a.number === Elements.O) {\n atomInGroupDict[a.index] = true\n addAtom(state, a)\n }\n })\n addFeature(features, state)\n }\n })\n r.eachAtom(a => {\n const state = createFeatureState(FeatureType.NegativeCharge)\n if (charge[a.index] < 0) {\n if (!atomInGroupDict[a.index]) {\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n })\n }\n })\n}\n\nexport function addAromaticRings (structure: Structure, features: Features) {\n const a = structure.getAtomProxy()\n structure.eachResidue(r => {\n const rings = r.getAromaticRings()\n if (rings) {\n const offset = r.atomOffset\n rings.forEach(ring => {\n const state = createFeatureState(FeatureType.AromaticRing)\n ring.forEach(i => {\n a.index = i + offset\n addAtom(state, a)\n })\n addFeature(features, state)\n })\n }\n })\n}\n\nfunction isIonicInteraction (ti: FeatureType, tj: FeatureType) {\n return (\n (ti === FeatureType.NegativeCharge && tj === FeatureType.PositiveCharge) ||\n (ti === FeatureType.PositiveCharge && tj === FeatureType.NegativeCharge)\n )\n}\n\nfunction isPiStacking (ti: FeatureType, tj: FeatureType) {\n return ti === FeatureType.AromaticRing && tj === FeatureType.AromaticRing\n}\n\nfunction isCationPi (ti: FeatureType, tj: FeatureType) {\n return (\n (ti === FeatureType.AromaticRing && tj === FeatureType.PositiveCharge) ||\n (ti === FeatureType.PositiveCharge && tj === FeatureType.AromaticRing)\n )\n}\n\nexport interface ChargedContactsParams {\n maxIonicDist?: number\n maxPiStackingDist?: number\n maxPiStackingOffset?: number\n maxPiStackingAngle?: number\n maxCationPiDist?: number\n maxCationPiOffset?: number\n masterModelIndex?: number\n}\n\nexport function addChargedContacts (structure: Structure, contacts: Contacts, params: ChargedContactsParams = {}) {\n const maxIonicDist = defaults(params.maxIonicDist, ContactDefaultParams.maxIonicDist)\n const maxPiStackingDist = defaults(params.maxPiStackingDist, ContactDefaultParams.maxPiStackingDist)\n const maxPiStackingOffset = defaults(params.maxPiStackingOffset, ContactDefaultParams.maxPiStackingOffset)\n const maxPiStackingAngle = defaults(params.maxPiStackingAngle, ContactDefaultParams.maxPiStackingAngle)\n const maxCationPiDist = defaults(params.maxCationPiDist, ContactDefaultParams.maxCationPiDist)\n const maxCationPiOffset = defaults(params.maxCationPiOffset, ContactDefaultParams.maxCationPiOffset)\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const maxDistance = Math.max(maxIonicDist + 2, maxPiStackingDist, maxCationPiDist)\n // const maxSaltBridgeDistSq = maxSaltBridgeDist * maxSaltBridgeDist\n const maxPiStackingDistSq = maxPiStackingDist * maxPiStackingDist\n const maxCationPiDistSq = maxCationPiDist * maxCationPiDist\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const ax = structure.atomStore.x\n const ay = structure.atomStore.y\n const az = structure.atomStore.z\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n const areAtomSetsWithinDist = function (atomSet1: number[], atomSet2: number[], maxDist: number) {\n const sn = atomSet1.length\n const sm = atomSet2.length\n for (let si = 0; si < sn; ++si) {\n ap1.index = atomSet1[ si ]\n for (let sj = 0; sj < sm; ++sj) {\n ap2.index = atomSet2[ sj ]\n if (ap1.distanceTo(ap2) <= maxDist) {\n return true\n }\n }\n }\n return false\n }\n\n const v1 = new Vector3()\n const v2 = new Vector3()\n const v3 = new Vector3()\n const d1 = new Vector3()\n const d2 = new Vector3()\n const n1 = new Vector3()\n const n2 = new Vector3()\n\n const getNormal = function (atoms: number[], normal: Vector3) {\n v1.set(ax[ atoms[ 0 ] ], ay[ atoms[ 0 ] ], az[ atoms[ 0 ] ])\n v2.set(ax[ atoms[ 1 ] ], ay[ atoms[ 1 ] ], az[ atoms[ 1 ] ])\n v3.set(ax[ atoms[ 2 ] ], ay[ atoms[ 2 ] ], az[ atoms[ 2 ] ])\n d1.subVectors(v1, v2)\n d2.subVectors(v1, v3)\n normal.crossVectors(d1, d2)\n }\n\n const getOffset = function (i: number, j: number, normal: Vector3) {\n v1.set(x[ i ], y[ i ], z[ i ])\n v2.set(x[ j ], y[ j ], z[ j ])\n return v1.sub(v2).projectOnPlane(normal).add(v2).distanceTo(v2)\n }\n\n const add = function (i: number, j: number, ct: ContactType) {\n featureSet.setBits(i, j)\n contactStore.addContact(i, j, ct)\n }\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxDistance, (j, dSq) => {\n if (j <= i) return\n\n ap1.index = atomSets[ i ][ 0 ]\n ap2.index = atomSets[ j ][ 0 ]\n\n if (invalidAtomContact(ap1, ap2, masterIdx)) return\n\n const ti = types[ i ]\n const tj = types[ j ]\n\n if (isIonicInteraction(ti, tj)) {\n if (areAtomSetsWithinDist(atomSets[ i ], atomSets[ j ], maxIonicDist)) {\n add(i, j, ContactType.IonicInteraction)\n }\n } else if (isPiStacking(ti, tj)) {\n if (dSq <= maxPiStackingDistSq) {\n getNormal(atomSets[ i ], n1)\n getNormal(atomSets[ j ], n2)\n\n const angle = radToDeg(n1.angleTo(n2))\n const offset = Math.min(getOffset(i, j, n2), getOffset(j, i, n1))\n if (offset <= maxPiStackingOffset) {\n if (angle <= maxPiStackingAngle || angle >= 180 - maxPiStackingAngle) {\n add(i, j, ContactType.PiStacking) // parallel\n } else if (angle <= maxPiStackingAngle + 90 && angle >= 90 - maxPiStackingAngle) {\n add(i, j, ContactType.PiStacking) // t-shaped\n }\n }\n }\n } else if (isCationPi(ti, tj)) {\n if (dSq <= maxCationPiDistSq) {\n const [ l, k ] = ti === FeatureType.AromaticRing ? [ i, j ] : [ j, i ]\n\n getNormal(atomSets[ l ], n1)\n const offset = getOffset(k, l, n1)\n if (offset <= maxCationPiOffset) {\n add(l, k, ContactType.CationPi)\n }\n }\n }\n })\n }\n}\n","/**\n * @file Hydrogen Bonds\n * @author Alexander Rose \n * @author Fred Ludlow \n */\nimport { defaults } from '../../utils'\nimport { degToRad } from '../../math/math-utils'\nimport Structure from '../../structure/structure'\nimport AtomProxy from '../../proxy/atom-proxy'\nimport { valenceModel } from '../../structure/data'\nimport { Elements } from '../../structure/structure-constants'\nimport { Angles, AtomGeometry, calcAngles, calcPlaneAngle } from '../geometry'\nimport {\n Features, FeatureType,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\n\n\n// Geometric characteristics of hydrogen bonds involving sulfur atoms in proteins\n// https://doi.org/10.1002/prot.22327\n\n// Satisfying Hydrogen Bonding Potential in Proteins (HBPLUS)\n// https://doi.org/10.1006/jmbi.1994.1334\n// http://www.csb.yale.edu/userguides/datamanip/hbplus/hbplus_descrip.html\n\n/**\n * Potential hydrogen donor\n */\nexport function addHydrogenDonors (structure: Structure, features: Features) {\n const { totalH } = valenceModel(structure.data)\n\n structure.eachAtom(a => {\n const state = createFeatureState(FeatureType.HydrogenDonor)\n\n const an = a.number\n if (isHistidineNitrogen(a)) {\n // include both nitrogen atoms in histidine due to\n // their often ambiguous protonation assignment\n addAtom(state, a)\n addFeature(features, state)\n } else if (\n totalH[ a.index ] > 0 &&\n (an === Elements.N || an === Elements.O || an === Elements.S)\n ) {\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\n/**\n * Weak hydrogen donor.\n */\nexport function addWeakHydrogenDonors (structure: Structure, features: Features) {\n const { totalH } = valenceModel(structure.data)\n\n structure.eachAtom(a => {\n if (\n a.number === Elements.C &&\n totalH[ a.index ] > 0 &&\n (\n a.bondToElementCount(Elements.N) > 0 ||\n a.bondToElementCount(Elements.O) > 0 ||\n inAromaticRingWithElectronNegativeElement(a)\n )\n ) {\n const state = createFeatureState(FeatureType.WeakHydrogenDonor)\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\nfunction inAromaticRingWithElectronNegativeElement (a: AtomProxy) {\n if (!a.isAromatic()) return false\n\n const ringData = a.residueType.getRings()\n if (!ringData) return false\n\n let hasElement = false\n const rings = ringData.rings\n rings.forEach(ring => {\n if (hasElement) return // already found one\n if (ring.some(idx => (a.index - a.residueAtomOffset) === idx)) { // in ring\n hasElement = ring.some(idx => {\n const atomTypeId = a.residueType.atomTypeIdList[ idx ]\n const number = a.atomMap.get(atomTypeId).number\n return number === Elements.N || number === Elements.O\n })\n }\n })\n\n return hasElement\n}\n\n/**\n * Potential hydrogen acceptor\n */\nexport function addHydrogenAcceptors (structure: Structure, features: Features) {\n const { charge, implicitH, idealGeometry } = valenceModel(structure.data)\n\n structure.eachAtom(a => {\n const state = createFeatureState(FeatureType.HydrogenAcceptor)\n\n const an = a.number\n if (an === Elements.O) {\n // Basically assume all oxygen atoms are acceptors!\n addAtom(state, a)\n addFeature(features, state)\n }else if (an === Elements.N) {\n if (isHistidineNitrogen(a)) {\n // include both nitrogen atoms in histidine due to\n // their often ambiguous protonation assignment\n addAtom(state, a)\n addFeature(features, state)\n } else if (charge[ a.index ] < 1){\n // Neutral nitrogen might be an acceptor\n // It must have at least one lone pair not conjugated\n const totalBonds = a.bondCount + implicitH[ a.index ]\n const ig = idealGeometry[ a.index ]\n if (\n (ig === AtomGeometry.Tetrahedral && totalBonds < 4) ||\n (ig === AtomGeometry.Trigonal && totalBonds < 3) ||\n (ig === AtomGeometry.Linear && totalBonds < 2)\n ) {\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n }else if (an === 16) { // S\n if (a.resname === 'CYS' || a.resname === 'MET' || a.formalCharge === -1) {\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n })\n}\n\n/**\n * Atom that is only bound to carbon or hydrogen\n */\n// function isHydrocarbon (atom: AtomProxy) {\n// let flag = true\n// atom.eachBondedAtom(ap => {\n// const e = ap.element\n// if (e !== 'C' && e !== 'H') flag = false\n// })\n// return flag\n// }\n\nfunction isHistidineNitrogen (ap: AtomProxy) {\n return ap.resname === 'HIS' && ap.number == Elements.N && ap.isRing()\n}\n\nfunction isBackboneHydrogenBond (ap1: AtomProxy, ap2: AtomProxy) {\n return ap1.isBackbone() && ap2.isBackbone()\n}\n\nfunction isWaterHydrogenBond (ap1: AtomProxy, ap2: AtomProxy) {\n return ap1.isWater() && ap2.isWater()\n}\n\nfunction isHydrogenBond (ti: FeatureType, tj: FeatureType) {\n return (\n (ti === FeatureType.HydrogenAcceptor && tj === FeatureType.HydrogenDonor) ||\n (ti === FeatureType.HydrogenDonor && tj === FeatureType.HydrogenAcceptor)\n )\n}\n\nfunction isWeakHydrogenBond (ti: FeatureType, tj: FeatureType){\n return (\n (ti === FeatureType.WeakHydrogenDonor && tj === FeatureType.HydrogenAcceptor) ||\n (ti === FeatureType.HydrogenAcceptor && tj === FeatureType.WeakHydrogenDonor)\n )\n}\n\nfunction getHydrogenBondType (ap1: AtomProxy, ap2: AtomProxy) {\n if (isWaterHydrogenBond(ap1, ap2)) {\n return ContactType.WaterHydrogenBond\n } else if (isBackboneHydrogenBond(ap1, ap2)) {\n return ContactType.BackboneHydrogenBond\n } else {\n return ContactType.HydrogenBond\n }\n}\n\nexport interface HydrogenBondParams {\n maxHbondDist?: number\n maxHbondSulfurDist?: number\n maxHbondAccAngle?: number\n maxHbondDonAngle?: number\n maxHbondAccPlaneAngle?: number\n maxHbondDonPlaneAngle?: number\n backboneHbond?: boolean\n waterHbond?: boolean\n masterModelIndex?: number\n}\n\n/**\n * All pairs of hydrogen donor and acceptor atoms\n */\nexport function addHydrogenBonds (structure: Structure, contacts: Contacts, params: HydrogenBondParams = {}) {\n const maxHbondDist = defaults(params.maxHbondDist, ContactDefaultParams.maxHbondDist)\n const maxHbondSulfurDist = defaults(params.maxHbondSulfurDist, ContactDefaultParams.maxHbondSulfurDist)\n const maxHbondAccAngle = degToRad(defaults(params.maxHbondAccAngle, ContactDefaultParams.maxHbondAccAngle))\n const maxHbondDonAngle = degToRad(defaults(params.maxHbondDonAngle, ContactDefaultParams.maxHbondDonAngle))\n const maxHbondAccPlaneAngle = degToRad(defaults(params.maxHbondAccPlaneAngle, ContactDefaultParams.maxHbondAccPlaneAngle))\n const maxHbondDonPlaneAngle = degToRad(defaults(params.maxHbondDonPlaneAngle, ContactDefaultParams.maxHbondDonPlaneAngle))\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const maxDist = Math.max(maxHbondDist, maxHbondSulfurDist)\n const maxHbondDistSq = maxHbondDist * maxHbondDist\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const { idealGeometry } = valenceModel(structure.data)\n\n const donor = structure.getAtomProxy()\n const acceptor = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxDist, (j, dSq) => {\n if (j <= i) return\n\n const ti = types[ i ]\n const tj = types[ j ]\n\n const isWeak = isWeakHydrogenBond(ti, tj)\n if (!isWeak && !isHydrogenBond(ti, tj)) return\n\n const [ l, k ] = tj === FeatureType.HydrogenAcceptor ? [ i, j ] : [ j, i ]\n\n donor.index = atomSets[ l ][ 0 ]\n acceptor.index = atomSets[ k ][ 0 ]\n\n if (acceptor.index === donor.index) return // DA to self\n\n if (invalidAtomContact(donor, acceptor, masterIdx)) return\n if (donor.number !== Elements.S && acceptor.number !== Elements.S && dSq > maxHbondDistSq) return\n if (donor.connectedTo(acceptor)) return\n\n const donorAngles = calcAngles(donor, acceptor)\n const idealDonorAngle = Angles.get(idealGeometry[donor.index]) || degToRad(120)\n if (donorAngles.some(donorAngle => {\n return Math.abs(idealDonorAngle - donorAngle) > maxHbondDonAngle\n })) return\n\n if (idealGeometry[donor.index] === AtomGeometry.Trigonal){\n const outOfPlane = calcPlaneAngle(donor, acceptor)\n if (outOfPlane !== undefined && outOfPlane > maxHbondDonPlaneAngle) return\n }\n\n const acceptorAngles = calcAngles(acceptor, donor)\n const idealAcceptorAngle = Angles.get(idealGeometry[acceptor.index]) || degToRad(120)\n if (acceptorAngles.some(acceptorAngle => {\n // Do not limit large acceptor angles\n return idealAcceptorAngle - acceptorAngle > maxHbondAccAngle\n })) return\n\n if (idealGeometry[acceptor.index] === AtomGeometry.Trigonal){\n const outOfPlane = calcPlaneAngle(acceptor, donor)\n if (outOfPlane !== undefined && outOfPlane > maxHbondAccPlaneAngle) return\n }\n\n featureSet.setBits(l, k)\n const bondType = isWeak ? ContactType.WeakHydrogenBond : getHydrogenBondType(donor, acceptor)\n contactStore.addContact(l, k, bondType)\n })\n }\n}\n","/**\n * @file Metal Binding\n * @author Alexander Rose \n */\n\nimport { defaults } from '../../utils'\nimport Structure from '../../structure/structure'\n// import { valenceModel } from '../../structure/data'\nimport { Elements, AA3, Bases } from '../../structure/structure-constants'\n// import { hasAromaticNeighbour } from '../functional-groups'\nimport {\n Features, FeatureType,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\n\nconst IonicTypeMetals = [\n Elements.LI, Elements.NA, Elements.K, Elements.RB, Elements.CS,\n Elements.MG, Elements.CA, Elements.SR, Elements.BA, Elements.AL,\n Elements.GA, Elements.IN, Elements.TL, Elements.SC, Elements.SN,\n Elements.PB, Elements.BI, Elements.SB, Elements.HG\n]\n\n/**\n * Metal binding partners (dative bond or ionic-type interaction)\n */\nexport function addMetalBinding (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n let dative = false\n let ionic = false\n\n const isStandardAminoacid = AA3.includes(a.resname)\n const isStandardBase = Bases.includes(a.resname)\n\n if (!isStandardAminoacid && !isStandardBase) {\n if (a.isHalogen() || a.number === Elements.O || a.number === Elements.S) {\n dative = true\n ionic = true\n } else if (a.number === Elements.N) {\n dative = true\n }\n } else if (isStandardAminoacid){\n // main chain oxygen atom or oxygen, nitrogen and sulfur from specific amino acids\n if (a.number === Elements.O) {\n if(['ASP', 'GLU', 'SER', 'THR', 'TYR', 'ASN', 'GLN'].includes(a.resname) && a.isSidechain()) {\n dative = true\n ionic = true\n } else if (a.isBackbone()) {\n dative = true\n ionic = true\n }\n } else if (a.number === Elements.S && 'CYS' === a.resname) {\n dative = true\n ionic = true\n } else if (a.number === Elements.N) {\n if(a.resname === 'HIS' && a.isSidechain()) {\n dative = true\n }\n }\n } else if (isStandardBase){\n // http://pubs.acs.org/doi/pdf/10.1021/acs.accounts.6b00253\n // http://onlinelibrary.wiley.com/doi/10.1002/anie.200900399/full\n if (a.number === Elements.O && a.isBackbone()) {\n dative = true\n ionic = true\n } else if(['N3', 'N4', 'N7'].includes(a.atomname)) {\n dative = true\n } else if(['O2', 'O4', 'O6'].includes(a.atomname)) {\n dative = true\n ionic = true\n }\n }\n if (dative) {\n const state = createFeatureState(FeatureType.DativeBondPartner)\n addAtom(state, a)\n addFeature(features, state)\n }\n if (ionic) {\n const state = createFeatureState(FeatureType.IonicTypePartner)\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\n/**\n * Metal Pi complexation partner\n */\n// export function addMetalPiPartners (structure: Structure, features: Features) {\n// const { charge } = valenceModel(structure.data)\n\n// structure.eachAtom(a => {\n// const state = createFeatureState(FeatureType.MetalPiPartner)\n\n// const resname = a.resname\n// const element = a.element\n// const atomname = a.atomname\n// if (!a.isPolymer()) {\n// // water oxygen, as well as oxygen from carboxylate, phosphoryl, phenolate, alcohol;\n// // nitrogen from imidazole; sulfur from thiolate\n// if (element === 'O') {\n// // Water oxygen\n// if (a.bondCount === 0 || a.isWater()) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// // Oxygen in alcohol (R-[O]-H)\n// if (a.bondCount === 2 && charge[ a.index ] || a.hasBondToElement('H')) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// // Phenolate oxygen\n// if (hasAromaticNeighbour(a) && !a.aromatic) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// // Carboxylic acid oxygen\n// if (a.bondToElementCount('C') === 1) {\n// let flag = false\n// a.eachBondedAtom(ba => {\n// if (ba.element === 'C' && ba.bondToElementCount('O') === 2 && ba.bondToElementCount('C') === 1) {\n// flag = true\n// }\n// })\n// if (flag) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// }\n// // Phosphoryl oxygen\n// if (a.bondToElementCount('P') === 1) {\n// let flag = false\n// a.eachBondedAtom(ba => {\n// if (ba.element === 'P' && ba.bondToElementCount('O') >= 3) {\n// flag = true\n// }\n// })\n// if (flag) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// }\n// } else if (element === 'N') {\n// // Imidazole/pyrrole or similar\n// if (a.bondToElementCount('C') === 2) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// } else if (element === 'S') {\n// // Thiolate\n// if (hasAromaticNeighbour(a) && !a.aromatic) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// // Sulfur in Iron sulfur cluster\n// const ironCount = a.bondToElementCount('FE')\n// if (ironCount > 0 && ironCount === a.bondCount) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// }\n// }\n// })\n// }\n\nexport function addMetals (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n if (a.isTransitionMetal() || a.number === Elements.ZN || a.number === Elements.CD) {\n const state = createFeatureState(FeatureType.TransitionMetal)\n addAtom(state, a)\n addFeature(features, state)\n } else if (IonicTypeMetals.includes(a.number)) {\n const state = createFeatureState(FeatureType.IonicTypeMetal)\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\nfunction isMetalComplex (ti: FeatureType, tj: FeatureType) {\n if (ti === FeatureType.TransitionMetal) {\n return (\n tj === FeatureType.DativeBondPartner ||\n tj === FeatureType.TransitionMetal\n )\n } else if (ti === FeatureType.IonicTypeMetal) {\n return (\n tj === FeatureType.IonicTypePartner\n )\n }\n}\n\nexport interface MetalComplexationParams {\n maxMetalDist?: number\n masterModelIndex?: number\n}\n\n/**\n * Metal complexes of metals and appropriate groups in protein and ligand, including water\n */\nexport function addMetalComplexation (structure: Structure, contacts: Contacts, params: MetalComplexationParams = {}) {\n const maxMetalDist = defaults(params.maxMetalDist, ContactDefaultParams.maxMetalDist)\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxMetalDist, (j, dSq) => {\n if (j <= i) return\n\n ap1.index = atomSets[ i ][ 0 ]\n ap2.index = atomSets[ j ][ 0 ]\n\n if (invalidAtomContact(ap1, ap2, masterIdx)) return\n\n const m1 = ap1.isMetal()\n const m2 = ap2.isMetal()\n if (!m1 && !m2) return\n\n const [ ti, tj ] = m1 ? [ types[ i ],types[ j ] ] : [ types[ j ],types[ i ] ]\n\n if (isMetalComplex(ti, tj)) {\n featureSet.setBits(i, j)\n contactStore.addContact(i, j, ContactType.MetalCoordination)\n }\n })\n }\n}\n","/**\n * @file Halogen Bonds\n * @author Alexander Rose \n * @author Fred Ludlow \n */\n\nimport { defaults } from '../../utils'\nimport Structure from '../../structure/structure'\nimport { Elements } from '../../structure/structure-constants'\nimport { degToRad } from '../../math/math-utils'\nimport {\n Features, FeatureType,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\nimport { calcAngles } from '../geometry'\n\nconst halBondElements = [17, 35, 53, 85]\n\n/**\n * Halogen bond donors (X-C, with X one of Cl, Br, I or At) not F!\n */\nexport function addHalogenDonors (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n if (halBondElements.includes(a.number) && a.bondToElementCount(Elements.C) === 1) {\n const state = createFeatureState(FeatureType.HalogenDonor)\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\nconst X = [ Elements.N, Elements.O, Elements.S ]\nconst Y = [ Elements.C, Elements.N, Elements.P, Elements.S ]\n\n/**\n * Halogen bond acceptors (Y-{O|N|S}, with Y=C,P,N,S)\n */\nexport function addHalogenAcceptors (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n if (X.includes(a.number)) {\n let flag = false\n a.eachBondedAtom(ba => {\n if (Y.includes(ba.number)) {\n flag = true\n }\n })\n if (flag) {\n const state = createFeatureState(FeatureType.HalogenAcceptor)\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n })\n}\n\nfunction isHalogenBond (ti: FeatureType, tj: FeatureType) {\n return (\n (ti === FeatureType.HalogenAcceptor && tj === FeatureType.HalogenDonor) ||\n (ti === FeatureType.HalogenDonor && tj === FeatureType.HalogenAcceptor)\n )\n}\n\nexport interface HalogenBondsParams {\n maxHalogenBondDist?: number\n maxHalogenBondAngle?: number\n masterModelIndex?: number\n}\n\n// http://www.pnas.org/content/101/48/16789.full\nconst OptimalHalogenAngle = degToRad(180) // adjusted from 165 to account for spherical statistics\nconst OptimalAcceptorAngle = degToRad(120)\n\n/**\n * All pairs of halogen donor and acceptor atoms\n */\nexport function addHalogenBonds (structure: Structure, contacts: Contacts, params: HalogenBondsParams = {}) {\n const maxHalogenBondDist = defaults(params.maxHalogenBondDist, ContactDefaultParams.maxHalogenBondDist)\n const maxHalogenBondAngle = degToRad(defaults(params.maxHalogenBondAngle, ContactDefaultParams.maxHalogenBondAngle))\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxHalogenBondDist, (j, dSq) => {\n if (j <= i) return\n\n ap1.index = atomSets[ i ][ 0 ]\n ap2.index = atomSets[ j ][ 0 ]\n\n if (invalidAtomContact(ap1, ap2, masterIdx)) return\n if (!isHalogenBond(types[ i ], types[ j ])) return\n\n const [ halogen, acceptor ] = types[ i ] === FeatureType.HalogenDonor ? [ ap1, ap2 ] : [ ap2, ap1 ]\n\n const halogenAngles = calcAngles(halogen, acceptor)\n // Singly bonded halogen only (not bromide ion for example)\n if (halogenAngles.length !== 1) return\n if (OptimalHalogenAngle - halogenAngles[0] > maxHalogenBondAngle) return\n\n const acceptorAngles = calcAngles(acceptor, halogen)\n // Angle must be defined. Excludes water as acceptor. Debatable\n if (acceptorAngles.length === 0) return\n if (acceptorAngles.some(acceptorAngle => {\n return (OptimalAcceptorAngle - acceptorAngle > maxHalogenBondAngle)\n })) return\n\n\n featureSet.setBits(i, j)\n contactStore.addContact(i, j, ContactType.HalogenBond)\n\n })\n }\n}\n","/**\n * @file Refine Contacts\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { Debug, Log } from '../../globals'\nimport { defaults } from '../../utils'\nimport Structure from '../../structure/structure'\nimport AtomProxy from '../../proxy/atom-proxy'\nimport { Elements } from '../../structure/structure-constants'\nimport { FrozenContacts, ContactType, ContactDefaultParams, isMasterContact } from './contact'\nimport { FeatureType } from './features'\n\nexport interface LineOfSightParams {\n lineOfSightDistFactor?: number\n masterModelIndex?: number\n}\n\n// also allows intra-residue contacts\nexport function invalidAtomContact (ap1: AtomProxy, ap2: AtomProxy, masterIdx: number) {\n return !isMasterContact(ap1, ap2, masterIdx) && (\n ap1.modelIndex !== ap2.modelIndex ||\n (ap1.altloc && ap2.altloc && ap1.altloc !== ap2.altloc)\n )\n}\n\nexport function refineLineOfSight (structure: Structure, contacts: FrozenContacts, params: LineOfSightParams = {}) {\n if (Debug) Log.time('refineLineOfSight')\n\n const lineOfSightDistFactor = defaults(params.lineOfSightDistFactor, ContactDefaultParams.lineOfSightDistFactor)\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const spatialHash = structure.spatialHash!\n const { contactSet, contactStore, features } = contacts\n const { index1, index2 } = contactStore\n const { centers, atomSets } = features\n const { x, y, z } = centers\n\n const ac1 = structure.getAtomProxy()\n const ac2 = structure.getAtomProxy()\n const aw = structure.getAtomProxy()\n\n const c1 = new Vector3()\n const c2 = new Vector3()\n\n const lineOfSightDist = 3 * lineOfSightDistFactor\n const lineOfSightDistFactorSq = lineOfSightDistFactor * lineOfSightDistFactor\n\n contactSet.forEach(i => {\n c1.set(x[index1[i]], y[index1[i]], z[index1[i]])\n c2.set(x[index2[i]], y[index2[i]], z[index2[i]])\n\n const cx = ( c1.x + c2.x ) / 2\n const cy = ( c1.y + c2.y ) / 2\n const cz = ( c1.z + c2.z ) / 2\n\n const as1 = atomSets[ index1[ i ] ]\n const as2 = atomSets[ index2[ i ] ]\n\n ac1.index = as1[ 0 ]\n ac2.index = as2[ 0 ]\n\n spatialHash.eachWithin(cx, cy, cz, lineOfSightDist, (j, dSq) => {\n aw.index = j\n if (\n aw.number !== Elements.H &&\n (aw.vdw * aw.vdw * lineOfSightDistFactorSq) > dSq &&\n !invalidAtomContact(ac1, aw, masterIdx) &&\n !invalidAtomContact(ac2, aw, masterIdx) &&\n !as1.includes(j) &&\n !as2.includes(j) &&\n // to ignore atoms in the center of functional groups\n c1.distanceToSquared(aw as any) > 1 &&\n c2.distanceToSquared(aw as any) > 1\n ) {\n contactSet.clear(i)\n if (Debug) Log.log('removing', ac1.qualifiedName(), ac2.qualifiedName(), 'because', aw.qualifiedName())\n }\n })\n })\n\n if (Debug) Log.timeEnd('refineLineOfSight')\n}\n\n/**\n * For atoms interacting with several atoms in the same residue\n * only the one with the closest distance is kept.\n */\nexport function refineHydrophobicContacts (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features } = contacts\n const { type, index1, index2 } = contactStore\n const { atomSets } = features\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n const residueContactDict: { [k: string]: number[] } = {}\n\n /* keep only closest contact between residues */\n const handleResidueContact = function (dist: number, i: number, key: string) {\n const [ minDist, minIndex ] = residueContactDict[ key ] || [ Infinity, -1 ]\n if (dist < minDist) {\n if (minIndex !== -1) contactSet.clear(minIndex)\n residueContactDict[ key ] = [ dist, i ]\n } else {\n contactSet.clear(i)\n }\n }\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.Hydrophobic) return\n\n ap1.index = atomSets[ index1[ i ] ][ 0 ]\n ap2.index = atomSets[ index2[ i ] ][ 0 ]\n\n const dist = ap1.distanceTo(ap2)\n handleResidueContact(dist, i, `${ap1.index}|${ap2.residueIndex}`)\n handleResidueContact(dist, i, `${ap2.index}|${ap1.residueIndex}`)\n })\n}\n\nfunction isHydrogenBondType (type: number) {\n return (\n type === ContactType.HydrogenBond ||\n type === ContactType.WaterHydrogenBond ||\n type === ContactType.BackboneHydrogenBond\n )\n}\n\n/**\n * Remove weak hydrogen bonds when the acceptor is involved in\n * a normal/strong hydrogen bond\n */\nexport function refineWeakHydrogenBonds (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features, adjacencyList } = contacts\n const { type, index1, index2 } = contactStore\n const { types } = features\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.WeakHydrogenBond) return\n\n let accFeat: number\n if (types[ index1[ i ] ] === FeatureType.WeakHydrogenDonor) {\n accFeat = index2[ i ]\n } else {\n accFeat = index1[ i ]\n }\n\n const n = adjacencyList.countArray[ accFeat ]\n const offset = adjacencyList.offsetArray[ accFeat ]\n for (let j = 0; j < n; ++j) {\n const ci = adjacencyList.indexArray[ offset + j ]\n if (isHydrogenBondType(type[ ci ])) {\n contactSet.clear(i)\n return\n }\n }\n })\n}\n\n/**\n * Remove hydrogen bonds between groups that also form\n * a salt bridge between each other\n */\nexport function refineSaltBridges (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features } = contacts\n const { type, index1, index2 } = contactStore\n const { atomSets } = features\n\n const ionicInteractionDict: { [atomIndex: number]: number[] } = {}\n\n const add = function(idx: number, i: number) {\n if (!ionicInteractionDict[ idx ]) ionicInteractionDict[ idx ] = []\n ionicInteractionDict[ idx ].push(i)\n }\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.IonicInteraction) return\n atomSets[ index1[ i ] ].forEach(idx => add(idx, i))\n atomSets[ index2[ i ] ].forEach(idx => add(idx, i))\n })\n\n contactSet.forEach(i => {\n if (!isHydrogenBondType(type[ i ])) return\n\n const iil1 = ionicInteractionDict[ atomSets[ index1[ i ] ][ 0 ] ]\n const iil2 = ionicInteractionDict[ atomSets[ index2[ i ] ][ 0 ] ]\n if (!iil1 || !iil2) return\n\n const n = iil1.length\n for (let j = 0; j < n; ++j) {\n if (iil2.includes(iil1[j])) {\n contactSet.clear(i)\n return\n }\n }\n })\n}\n\n/**\n * Remove hydrophobic and cation-pi interactions between groups that also form\n * a pi-stacking interaction between each other\n */\nexport function refinePiStacking (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features } = contacts\n const { type, index1, index2 } = contactStore\n const { atomSets } = features\n\n const piStackingDict: { [atomIndex: number]: number[] } = {}\n\n const add = function(idx: number, i: number) {\n if (!piStackingDict[ idx ]) piStackingDict[ idx ] = []\n piStackingDict[ idx ].push(i)\n }\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.PiStacking) return\n atomSets[ index1[ i ] ].forEach(idx => add(idx, i))\n atomSets[ index2[ i ] ].forEach(idx => add(idx, i))\n })\n\n contactSet.forEach(i => {\n if (\n type[ i ] !== ContactType.Hydrophobic &&\n type[ i ] !== ContactType.CationPi\n ) return\n\n const pil1 = piStackingDict[ atomSets[ index1[ i ] ][ 0 ] ]\n const pil2 = piStackingDict[ atomSets[ index2[ i ] ][ 0 ] ]\n if (!pil1 || !pil2) return\n\n const n = pil1.length\n for (let j = 0; j < n; ++j) {\n if (pil2.includes(pil1[j])) {\n contactSet.clear(i)\n return\n }\n }\n })\n}\n\n/**\n * Remove ionic interactions between groups that also form\n * a metal coordination between each other\n */\nexport function refineMetalCoordination (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features } = contacts\n const { type, index1, index2 } = contactStore\n const { atomSets } = features\n\n const ionicInteractionDict: { [atomIndex: number]: number[] } = {}\n\n const add = function(idx: number, i: number) {\n if (!ionicInteractionDict[ idx ]) ionicInteractionDict[ idx ] = []\n ionicInteractionDict[ idx ].push(i)\n }\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.IonicInteraction) return\n atomSets[ index1[ i ] ].forEach(idx => add(idx, i))\n atomSets[ index2[ i ] ].forEach(idx => add(idx, i))\n })\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.MetalCoordination) return\n\n const iil1 = ionicInteractionDict[ atomSets[ index1[ i ] ][ 0 ] ]\n const iil2 = ionicInteractionDict[ atomSets[ index2[ i ] ][ 0 ] ]\n if (!iil1 || !iil2) return\n\n const n = iil1.length\n for (let j = 0; j < n; ++j) {\n if (iil2.includes(iil1[j])) {\n contactSet.clear(iil1[j])\n return\n }\n }\n })\n}\n\n// TODO: refactor refineSaltBridges, refinePiStacking and refineMetalCoordination to be DRY\n","/**\n * @file Contact\n * @author Alexander Rose \n */\n\nimport { Color } from 'three'\n\nimport { Debug, Log } from '../../globals'\nimport { createParams } from '../../utils'\nimport { TextBufferData } from '../../buffer/text-buffer'\nimport Structure from '../../structure/structure'\nimport AtomProxy from '../../proxy/atom-proxy'\nimport SpatialHash from '../../geometry/spatial-hash'\nimport { calculateCenterArray, calculateDirectionArray, uniformArray } from '../../math/array-utils'\nimport ContactStore from '../../store/contact-store'\nimport BitArray from '../../utils/bitarray'\nimport Selection from '../../selection/selection'\nimport { ContactPicker } from '../../utils/picker'\nimport { createAdjacencyList, AdjacencyList } from '../../utils/adjacency-list'\nimport { createFeatures, Features } from './features'\nimport { addAromaticRings, addNegativeCharges, addPositiveCharges, addChargedContacts } from './charged'\nimport { addHydrogenAcceptors, addHydrogenDonors, addHydrogenBonds, addWeakHydrogenDonors } from './hydrogen-bonds'\nimport { addMetalBinding, addMetals, addMetalComplexation } from './metal-binding'\nimport { addHydrophobic, addHydrophobicContacts } from './hydrophobic'\nimport { addHalogenAcceptors, addHalogenDonors, addHalogenBonds } from './halogen-bonds'\nimport {\n refineLineOfSight,\n refineHydrophobicContacts, refineSaltBridges, refinePiStacking, refineMetalCoordination\n} from './refine-contacts'\n\nexport interface Contacts {\n features: Features\n spatialHash: SpatialHash\n contactStore: ContactStore\n featureSet: BitArray\n}\n\nexport interface FrozenContacts extends Contacts {\n contactSet: BitArray\n adjacencyList: AdjacencyList\n}\n\nexport const enum ContactType {\n Unknown = 0,\n IonicInteraction = 1,\n CationPi = 2,\n PiStacking = 3,\n HydrogenBond = 4,\n HalogenBond = 5,\n Hydrophobic = 6,\n MetalCoordination = 7,\n WeakHydrogenBond = 8,\n WaterHydrogenBond = 9,\n BackboneHydrogenBond = 10\n}\n\nexport const ContactDefaultParams = {\n maxHydrophobicDist: 4.0,\n maxHbondDist: 3.5,\n maxHbondSulfurDist: 4.1,\n maxHbondAccAngle: 45,\n maxHbondDonAngle: 45,\n maxHbondAccPlaneAngle: 90,\n maxHbondDonPlaneAngle: 30,\n maxPiStackingDist: 5.5,\n maxPiStackingOffset: 2.0,\n maxPiStackingAngle: 30,\n maxCationPiDist: 6.0,\n maxCationPiOffset: 2.0,\n maxIonicDist: 5.0,\n maxHalogenBondDist: 4.0,\n maxHalogenBondAngle: 30,\n maxMetalDist: 3.0,\n refineSaltBridges: true,\n masterModelIndex: -1,\n lineOfSightDistFactor: 1.0\n}\n\nexport function isMasterContact (ap1: AtomProxy, ap2: AtomProxy, masterIdx: number) {\n return (\n (ap1.modelIndex === masterIdx && ap2.modelIndex !== masterIdx) ||\n (ap2.modelIndex === masterIdx && ap1.modelIndex !== masterIdx)\n )\n}\n\nexport function invalidAtomContact (ap1: AtomProxy, ap2: AtomProxy, masterIdx: number) {\n return !isMasterContact(ap1, ap2, masterIdx) && (\n ap1.modelIndex !== ap2.modelIndex ||\n ap1.residueIndex === ap2.residueIndex ||\n (ap1.altloc && ap2.altloc && ap1.altloc !== ap2.altloc)\n )\n}\n\nexport function createContacts (features: Features): Contacts {\n const { types, centers } = features\n\n const spatialHash = new SpatialHash(centers)\n const contactStore = new ContactStore()\n const featureSet = new BitArray(types.length, false)\n\n return { features, spatialHash, contactStore, featureSet }\n}\n\nexport function createFrozenContacts (contacts: Contacts): FrozenContacts {\n const { index1, index2, count } = contacts.contactStore\n\n const adjacencyList = createAdjacencyList({\n nodeArray1: index1,\n nodeArray2: index2,\n edgeCount: count,\n nodeCount: contacts.featureSet.length\n })\n const contactSet = new BitArray(contacts.contactStore.count, true)\n\n return Object.assign({ adjacencyList, contactSet }, contacts)\n}\n\nfunction calculateFeatures (structure: Structure) {\n const features = createFeatures()\n\n if (Debug) Log.time('calculateFeatures')\n\n addPositiveCharges(structure, features)\n addNegativeCharges(structure, features)\n addAromaticRings(structure, features)\n\n addHydrogenAcceptors(structure, features)\n addHydrogenDonors(structure, features)\n addWeakHydrogenDonors(structure, features)\n\n addMetalBinding(structure, features)\n addMetals(structure, features)\n\n addHydrophobic(structure, features)\n\n addHalogenAcceptors(structure, features)\n addHalogenDonors(structure, features)\n\n if (Debug) Log.timeEnd('calculateFeatures')\n\n return features\n}\n\nexport function calculateContacts (structure: Structure, params = ContactDefaultParams) {\n const features = calculateFeatures(structure)\n const contacts = createContacts(features)\n\n if (Debug) Log.time('calculateContacts')\n\n addChargedContacts(structure, contacts, params)\n addHydrogenBonds(structure, contacts, params)\n addMetalComplexation(structure, contacts, params)\n addHydrophobicContacts(structure, contacts, params)\n addHalogenBonds(structure, contacts, params)\n\n const frozenContacts = createFrozenContacts(contacts)\n\n refineLineOfSight(structure, frozenContacts, params)\n refineHydrophobicContacts(structure, frozenContacts)\n if (params.refineSaltBridges) refineSaltBridges(structure, frozenContacts)\n refinePiStacking(structure, frozenContacts)\n refineMetalCoordination(structure, frozenContacts)\n\n if (Debug) Log.timeEnd('calculateContacts')\n\n return frozenContacts\n}\n\nexport function contactTypeName (type: ContactType) {\n switch (type) {\n case ContactType.HydrogenBond:\n case ContactType.WaterHydrogenBond:\n case ContactType.BackboneHydrogenBond:\n return 'hydrogen bond'\n case ContactType.Hydrophobic:\n return 'hydrophobic contact'\n case ContactType.HalogenBond:\n return 'halogen bond'\n case ContactType.IonicInteraction:\n return 'ionic interaction'\n case ContactType.MetalCoordination:\n return 'metal coordination'\n case ContactType.CationPi:\n return 'cation-pi interaction'\n case ContactType.PiStacking:\n return 'pi-pi stacking'\n case ContactType.WeakHydrogenBond:\n return 'weak hydrogen bond'\n default:\n return 'unknown contact'\n }\n}\n\nexport const ContactDataDefaultParams = {\n hydrogenBond: true,\n hydrophobic: true,\n halogenBond: true,\n ionicInteraction: true,\n metalCoordination: true,\n cationPi: true,\n piStacking: true,\n weakHydrogenBond: true,\n waterHydrogenBond: true,\n backboneHydrogenBond: true,\n radius: 1,\n filterSele: ''\n}\nexport type ContactDataParams = typeof ContactDataDefaultParams\n | { filterSele: string|[string, string] }\n\nexport const ContactLabelDefaultParams = {\n unit: '',\n size: 2.0\n}\n\nexport type ContactLabelParams = typeof ContactLabelDefaultParams\n\nconst tmpColor = new Color()\nfunction contactColor (type: ContactType) {\n switch (type) {\n case ContactType.HydrogenBond:\n case ContactType.WaterHydrogenBond:\n case ContactType.BackboneHydrogenBond:\n return tmpColor.setHex(0x2B83BA).toArray()\n case ContactType.Hydrophobic:\n return tmpColor.setHex(0x808080).toArray()\n case ContactType.HalogenBond:\n return tmpColor.setHex(0x40FFBF).toArray()\n case ContactType.IonicInteraction:\n return tmpColor.setHex(0xF0C814).toArray()\n case ContactType.MetalCoordination:\n return tmpColor.setHex(0x8C4099).toArray()\n case ContactType.CationPi:\n return tmpColor.setHex(0xFF8000).toArray()\n case ContactType.PiStacking:\n return tmpColor.setHex(0x8CB366).toArray()\n case ContactType.WeakHydrogenBond:\n return tmpColor.setHex(0xC5DDEC).toArray()\n default:\n return tmpColor.setHex(0xCCCCCC).toArray()\n }\n}\n\nexport interface ContactData {\n position1: Float32Array,\n position2: Float32Array,\n color: Float32Array,\n color2: Float32Array,\n radius: Float32Array,\n picking: ContactPicker\n}\n\nexport function getContactData (contacts: FrozenContacts, structure: Structure, params: ContactDataParams): ContactData {\n const p = createParams(params, ContactDataDefaultParams)\n const types: ContactType[] = []\n if (p.hydrogenBond) types.push(ContactType.HydrogenBond)\n if (p.hydrophobic) types.push(ContactType.Hydrophobic)\n if (p.halogenBond) types.push(ContactType.HalogenBond)\n if (p.ionicInteraction) types.push(ContactType.IonicInteraction)\n if (p.metalCoordination) types.push(ContactType.MetalCoordination)\n if (p.cationPi) types.push(ContactType.CationPi)\n if (p.piStacking) types.push(ContactType.PiStacking)\n if (p.weakHydrogenBond) types.push(ContactType.WeakHydrogenBond)\n if (p.waterHydrogenBond) types.push(ContactType.WaterHydrogenBond)\n if (p.backboneHydrogenBond) types.push(ContactType.BackboneHydrogenBond)\n\n const { features, contactSet, contactStore } = contacts\n const { centers, atomSets } = features\n const { x, y, z } = centers\n const { index1, index2, type } = contactStore\n\n const position1: number[] = []\n const position2: number[] = []\n const color: number[] = []\n const radius: number[] = []\n const picking: number[] = []\n\n let filterSet: BitArray | BitArray[] | undefined\n if (p.filterSele) {\n if (Array.isArray(p.filterSele)) {\n filterSet = p.filterSele.map(sele => {\n return structure.getAtomSet(new Selection(sele))\n })\n } else {\n filterSet = structure.getAtomSet(new Selection(p.filterSele))\n }\n }\n\n contactSet.forEach(i => {\n const ti = type[ i ]\n if (!types.includes(ti)) return\n\n if (filterSet) {\n const idx1 = atomSets[index1[i]][0]\n const idx2 = atomSets[index2[i]][0]\n\n if (Array.isArray(filterSet)) {\n if (!(filterSet[0].isSet(idx1) && filterSet[1].isSet(idx2) || (filterSet[1].isSet(idx1) && filterSet[0].isSet(idx2)))) return\n } else {\n if (!filterSet.isSet(idx1) && !filterSet.isSet(idx2)) return\n }\n }\n\n const k = index1[i]\n const l = index2[i]\n position1.push(x[k], y[k], z[k])\n position2.push(x[l], y[l], z[l])\n color.push(...contactColor(ti))\n radius.push(p.radius)\n picking.push(i)\n })\n\n return {\n position1: new Float32Array(position1),\n position2: new Float32Array(position2),\n color: new Float32Array(color),\n color2: new Float32Array(color),\n radius: new Float32Array(radius),\n picking: new ContactPicker(picking, contacts, structure)\n }\n}\n\nexport function getLabelData (contactData: ContactData, params: ContactLabelParams): TextBufferData {\n\n const position = calculateCenterArray(contactData.position1, contactData.position2)\n const text: string[] = []\n\n const direction = calculateDirectionArray(contactData.position1, contactData.position2)\n\n const n = direction.length / 3\n for (let i=0; i\n */\n\nimport { defaults } from '../../utils'\nimport Structure from '../../structure/structure'\nimport { Elements } from '../../structure/structure-constants'\nimport {\n Features, FeatureType,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\n\n/**\n * Hydrophobic carbon (only bonded to carbon or hydrogen); fluorine\n */\nexport function addHydrophobic (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n const state = createFeatureState(FeatureType.Hydrophobic)\n let flag = false\n if (a.number === Elements.C) {\n flag = true\n a.eachBondedAtom(ap => {\n const an = ap.number\n if (an !== Elements.C && an !== Elements.H) flag = false\n })\n } else if (a.number === Elements.F) {\n flag = true\n }\n if (flag) {\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\nfunction isHydrophobicContact (ti: FeatureType, tj: FeatureType) {\n return ti === FeatureType.Hydrophobic && tj === FeatureType.Hydrophobic\n}\n\nexport interface HydrophobicContactsParams {\n maxHydrophobicDist?: number\n masterModelIndex?: number\n}\n\n/**\n * All hydrophobic contacts\n */\nexport function addHydrophobicContacts (structure: Structure, contacts: Contacts, params: HydrophobicContactsParams = {}) {\n const maxHydrophobicDist = defaults(params.maxHydrophobicDist, ContactDefaultParams.maxHydrophobicDist)\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxHydrophobicDist, (j, dSq) => {\n if (j <= i) return\n\n ap1.index = atomSets[ i ][ 0 ]\n ap2.index = atomSets[ j ][ 0 ]\n\n if (invalidAtomContact(ap1, ap2, masterIdx)) return\n if (ap1.number === Elements.F && ap2.number === Elements.F) return\n if (ap1.connectedTo(ap2)) return\n\n if (isHydrophobicContact(types[ i ], types[ j ])) {\n featureSet.setBits(i, j)\n contactStore.addContact(i, j, ContactType.Hydrophobic)\n }\n })\n }\n}\n","/**\n * @file Picker\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { PickerRegistry } from '../globals'\nimport { calculateMeanVector3 } from '../math/vector-utils'\nimport Selection from '../selection/selection'\nimport {\n ArrowPrimitive, BoxPrimitive, ConePrimitive, CylinderPrimitive,\n EllipsoidPrimitive, OctahedronPrimitive, SpherePrimitive,\n TetrahedronPrimitive, TorusPrimitive, PointPrimitive, WidelinePrimitive\n} from '../geometry/primitive'\nimport { contactTypeName, Contacts } from '../chemistry/interactions/contact'\nimport { TypedArray } from '../types';\nimport Component from '../component/component';\nimport { Shape, Structure, Volume } from '../ngl';\nimport BondStore from '../store/bond-store';\nimport Validation from '../structure/validation';\nimport PrincipalAxes from '../math/principal-axes';\nimport Surface from '../surface/surface';\nimport Unitcell from '../symmetry/unitcell';\nimport BondProxy from '../proxy/bond-proxy';\nimport AtomProxy from '../proxy/atom-proxy';\n\n/**\n * Picker class\n * @interface\n */\nclass Picker {\n array: number[]|TypedArray|undefined\n /**\n * @param {Array|TypedArray} [array] - mapping\n */\n constructor (array?: number[]|TypedArray) {\n this.array = array\n }\n\n get type () { return '' }\n get data () { return {} }\n\n /**\n * Get the index for the given picking id\n * @param {Integer} pid - the picking id\n * @return {Integer} the index\n */\n getIndex (pid: number) {\n return this.array ? this.array[ pid ] : pid\n }\n\n /**\n * Get object data\n * @abstract\n * @param {Integer} pid - the picking id\n * @return {Object} the object data\n */\n getObject (pid: number) {\n return {}\n }\n\n _applyTransformations (vector: Vector3, instance: any, component: Component) {\n if (instance) {\n vector.applyMatrix4(instance.matrix)\n }\n if (component) {\n vector.applyMatrix4(component.matrix)\n }\n return vector\n }\n\n /**\n * Get object position\n * @abstract\n * @param {Integer} pid - the picking id\n * @return {Vector3} the object position\n */\n _getPosition (pid: number) {\n return new Vector3()\n }\n\n /**\n * Get position for the given picking id\n * @param {Integer} pid - the picking id\n * @param {Object} instance - the instance that should be applied\n * @param {Component} component - the component of the picked object\n * @return {Vector3} the position\n */\n getPosition (pid: number, instance: any, component: Component) {\n return this._applyTransformations(\n this._getPosition(pid), instance, component\n )\n }\n}\n\n/**\n * Shape picker class\n * @interface\n */\nclass ShapePicker extends Picker {\n shape: Shape\n /**\n * @param {Shape} shape - shape object\n */\n constructor (shape: Shape) {\n super()\n this.shape = shape\n }\n\n get primitive (): any { return }\n\n get data () { return this.shape }\n get type () { return this.primitive.type }\n\n getObject (pid: number) {\n return this.primitive.objectFromShape(this.shape, this.getIndex(pid))\n }\n\n _getPosition (pid: number) {\n return this.primitive.positionFromShape(this.shape, this.getIndex(pid))\n }\n}\n\n//\n\nclass CylinderPicker extends ShapePicker {\n get primitive () { return CylinderPrimitive }\n}\n\nclass ArrowPicker extends ShapePicker {\n get primitive () { return ArrowPrimitive }\n}\n\nclass AtomPicker extends Picker {\n structure: Structure\n constructor (array: Float32Array, structure: Structure) {\n super(array)\n this.structure = structure\n }\n\n get type () { return 'atom' }\n get data () { return this.structure }\n\n getObject (pid: number): AtomProxy {\n return this.structure.getAtomProxy(this.getIndex(pid))\n }\n\n _getPosition (pid: number) {\n return new Vector3().copy(this.getObject(pid) as any)\n }\n}\n\nclass AxesPicker extends Picker {\n axes: PrincipalAxes\n constructor (axes: PrincipalAxes) {\n super()\n this.axes = axes\n }\n\n get type () { return 'axes' }\n get data () { return this.axes }\n\n getObject (/* pid */) {\n return {\n axes: this.axes\n }\n }\n\n _getPosition (/* pid */) {\n return this.axes.center.clone()\n }\n}\n\nclass BondPicker extends Picker {\n structure: Structure\n bondStore: BondStore\n constructor (array: number[]|TypedArray|undefined, structure: Structure, bondStore?: BondStore) {\n super(array)\n this.structure = structure\n this.bondStore = bondStore || structure.bondStore\n }\n\n get type () { return 'bond' }\n get data () { return this.structure }\n\n getObject (pid: number): BondProxy {\n const bp = this.structure.getBondProxy(this.getIndex(pid))\n bp.bondStore = this.bondStore\n return bp\n }\n\n _getPosition (pid: number) {\n const b = this.getObject(pid)\n return new Vector3()\n .copy(b.atom1 as any)\n .add(b.atom2 as any)\n .multiplyScalar(0.5)\n }\n}\n\nclass ContactPicker extends Picker {\n contacts: Contacts\n structure: Structure\n constructor (array: number[]|TypedArray|undefined, contacts: Contacts, structure: Structure) {\n super(array)\n this.contacts = contacts\n this.structure = structure\n }\n\n get type () { return 'contact' }\n get data () { return this.contacts }\n\n getObject (pid: number) {\n const idx = this.getIndex(pid)\n const { features, contactStore } = this.contacts\n const { centers, atomSets } = features\n const { x, y, z } = centers\n const { index1, index2, type } = contactStore\n const k = index1[idx]\n const l = index2[idx]\n return {\n center1: new Vector3(x[k], y[k], z[k]),\n center2: new Vector3(x[l], y[l], z[l]),\n atom1: this.structure.getAtomProxy(atomSets[k][0]),\n atom2: this.structure.getAtomProxy(atomSets[l][0]),\n type: contactTypeName(type[idx])\n }\n }\n\n _getPosition (pid: number) {\n const { center1, center2 } = this.getObject(pid)\n return new Vector3().addVectors(center1, center2).multiplyScalar(0.5)\n }\n}\n\nclass ConePicker extends ShapePicker {\n get primitive () { return ConePrimitive }\n}\n\nclass ClashPicker extends Picker {\n validation: Validation\n structure: Structure\n constructor (array: number[]|TypedArray|undefined, validation: Validation, structure: Structure) {\n super(array)\n this.validation = validation\n this.structure = structure\n }\n\n get type () { return 'clash' }\n get data () { return this.validation }\n\n getObject (pid: number) {\n const val = this.validation\n const idx = this.getIndex(pid)\n return {\n validation: val,\n index: idx,\n clash: val.clashArray[ idx ]\n }\n }\n\n _getAtomProxyFromSele (sele: string) {\n const selection = new Selection(sele)\n const idx = this.structure.getAtomIndices(selection)![ 0 ]\n return this.structure.getAtomProxy(idx)\n }\n\n _getPosition (pid: number) {\n const clash = this.getObject(pid).clash\n const ap1 = this._getAtomProxyFromSele(clash.sele1)\n const ap2 = this._getAtomProxyFromSele(clash.sele2)\n return new Vector3().copy(ap1 as any).add(ap2 as any).multiplyScalar(0.5)\n }\n}\n\nclass DistancePicker extends BondPicker {\n get type () { return 'distance' }\n}\n\nclass EllipsoidPicker extends ShapePicker {\n get primitive () { return EllipsoidPrimitive }\n}\n\nclass OctahedronPicker extends ShapePicker {\n get primitive () { return OctahedronPrimitive }\n}\n\nclass BoxPicker extends ShapePicker {\n get primitive () { return BoxPrimitive }\n}\n\nclass IgnorePicker extends Picker {\n get type () { return 'ignore' }\n}\n\nexport interface MeshData {\n name: string|undefined\n serial: number\n index: Uint32Array|Uint16Array|number[]\n normal?: Float32Array|number[]\n position: Float32Array|number[]\n color: Float32Array|number[]\n}\nclass MeshPicker extends ShapePicker {\n mesh: MeshData\n __position: Vector3\n\n constructor (shape: Shape, mesh: MeshData) {\n super(shape)\n this.mesh = mesh\n }\n\n get type () { return 'mesh' }\n\n getObject (/* pid */) {\n const m = this.mesh\n return {\n shape: this.shape,\n name: m.name,\n serial: m.serial\n }\n }\n\n _getPosition (/* pid */) {\n if (!this.__position) {\n this.__position = calculateMeanVector3(this.mesh.position as any)\n }\n return this.__position\n }\n}\n\nclass SpherePicker extends ShapePicker {\n get primitive () { return SpherePrimitive }\n}\n\nclass SurfacePicker extends Picker {\n surface: Surface\n constructor (array: number[]|TypedArray|undefined, surface: Surface) {\n super(array)\n this.surface = surface\n }\n\n get type () { return 'surface' }\n get data () { return this.surface }\n\n getObject (pid: number) {\n return {\n surface: this.surface,\n index: this.getIndex(pid)\n }\n }\n\n _getPosition (/* pid */) {\n return this.surface.center.clone()\n }\n}\n\nclass TetrahedronPicker extends ShapePicker {\n get primitive () { return TetrahedronPrimitive }\n}\n\nclass TorusPicker extends ShapePicker {\n get primitive () { return TorusPrimitive }\n}\n\nclass UnitcellPicker extends Picker {\n unitcell: Unitcell\n structure: Structure\n\n constructor (unitcell: Unitcell, structure: Structure) {\n super()\n this.unitcell = unitcell\n this.structure = structure\n }\n\n get type () { return 'unitcell' }\n get data () { return this.unitcell }\n\n getObject (/* pid */) {\n return {\n unitcell: this.unitcell,\n structure: this.structure\n }\n }\n\n _getPosition (/* pid */) {\n return this.unitcell.getCenter(this.structure)\n }\n}\n\nclass UnknownPicker extends Picker {\n get type () { return 'unknown' }\n}\n\nclass VolumePicker extends Picker {\n volume: Volume\n constructor (array: TypedArray, volume: Volume) {\n super(array)\n this.volume = volume\n }\n\n get type () { return 'volume' }\n get data () { return this.volume }\n\n getObject (pid: number) {\n const vol = this.volume\n const idx = this.getIndex(pid)\n return {\n volume: vol,\n index: idx,\n value: vol.data[ idx ]\n }\n }\n\n _getPosition (pid: number) {\n const dp = this.volume.position\n const idx = this.getIndex(pid)\n return new Vector3(\n dp[ idx * 3 ],\n dp[ idx * 3 + 1 ],\n dp[ idx * 3 + 2 ]\n )\n }\n}\n\nclass SlicePicker extends VolumePicker {\n get type () { return 'slice' }\n}\n\nclass PointPicker extends ShapePicker {\n get primitive () { return PointPrimitive }\n}\n\nclass WidelinePicker extends ShapePicker {\n get primitive () { return WidelinePrimitive }\n}\n\nPickerRegistry.add('arrow', ArrowPicker)\nPickerRegistry.add('box', BoxPicker)\nPickerRegistry.add('cone', ConePicker)\nPickerRegistry.add('cylinder', CylinderPicker)\nPickerRegistry.add('ellipsoid', EllipsoidPicker)\nPickerRegistry.add('octahedron', OctahedronPicker)\nPickerRegistry.add('sphere', SpherePicker)\nPickerRegistry.add('tetrahedron', TetrahedronPicker)\nPickerRegistry.add('torus', TorusPicker)\nPickerRegistry.add('point', PointPicker)\nPickerRegistry.add('wideline', WidelinePicker)\n\nexport {\n Picker,\n ShapePicker,\n ArrowPicker,\n AtomPicker,\n AxesPicker,\n BondPicker,\n BoxPicker,\n ConePicker,\n ContactPicker,\n CylinderPicker,\n ClashPicker,\n DistancePicker,\n EllipsoidPicker,\n IgnorePicker,\n OctahedronPicker,\n MeshPicker,\n SlicePicker,\n SpherePicker,\n SurfacePicker,\n TetrahedronPicker,\n TorusPicker,\n UnitcellPicker,\n UnknownPicker,\n VolumePicker,\n PointPicker,\n WidelinePicker\n}\n","/**\n * @file Marching Cubes\n * @author Alexander Rose \n * @private\n */\n\nimport { getUintArray } from '../utils'\n\nfunction getEdgeTable () {\n return new Uint32Array([\n 0x0, 0x109, 0x203, 0x30a, 0x406, 0x50f, 0x605, 0x70c,\n 0x80c, 0x905, 0xa0f, 0xb06, 0xc0a, 0xd03, 0xe09, 0xf00,\n 0x190, 0x99, 0x393, 0x29a, 0x596, 0x49f, 0x795, 0x69c,\n 0x99c, 0x895, 0xb9f, 0xa96, 0xd9a, 0xc93, 0xf99, 0xe90,\n 0x230, 0x339, 0x33, 0x13a, 0x636, 0x73f, 0x435, 0x53c,\n 0xa3c, 0xb35, 0x83f, 0x936, 0xe3a, 0xf33, 0xc39, 0xd30,\n 0x3a0, 0x2a9, 0x1a3, 0xaa, 0x7a6, 0x6af, 0x5a5, 0x4ac,\n 0xbac, 0xaa5, 0x9af, 0x8a6, 0xfaa, 0xea3, 0xda9, 0xca0,\n 0x460, 0x569, 0x663, 0x76a, 0x66, 0x16f, 0x265, 0x36c,\n 0xc6c, 0xd65, 0xe6f, 0xf66, 0x86a, 0x963, 0xa69, 0xb60,\n 0x5f0, 0x4f9, 0x7f3, 0x6fa, 0x1f6, 0xff, 0x3f5, 0x2fc,\n 0xdfc, 0xcf5, 0xfff, 0xef6, 0x9fa, 0x8f3, 0xbf9, 0xaf0,\n 0x650, 0x759, 0x453, 0x55a, 0x256, 0x35f, 0x55, 0x15c,\n 0xe5c, 0xf55, 0xc5f, 0xd56, 0xa5a, 0xb53, 0x859, 0x950,\n 0x7c0, 0x6c9, 0x5c3, 0x4ca, 0x3c6, 0x2cf, 0x1c5, 0xcc,\n 0xfcc, 0xec5, 0xdcf, 0xcc6, 0xbca, 0xac3, 0x9c9, 0x8c0,\n 0x8c0, 0x9c9, 0xac3, 0xbca, 0xcc6, 0xdcf, 0xec5, 0xfcc,\n 0xcc, 0x1c5, 0x2cf, 0x3c6, 0x4ca, 0x5c3, 0x6c9, 0x7c0,\n 0x950, 0x859, 0xb53, 0xa5a, 0xd56, 0xc5f, 0xf55, 0xe5c,\n 0x15c, 0x55, 0x35f, 0x256, 0x55a, 0x453, 0x759, 0x650,\n 0xaf0, 0xbf9, 0x8f3, 0x9fa, 0xef6, 0xfff, 0xcf5, 0xdfc,\n 0x2fc, 0x3f5, 0xff, 0x1f6, 0x6fa, 0x7f3, 0x4f9, 0x5f0,\n 0xb60, 0xa69, 0x963, 0x86a, 0xf66, 0xe6f, 0xd65, 0xc6c,\n 0x36c, 0x265, 0x16f, 0x66, 0x76a, 0x663, 0x569, 0x460,\n 0xca0, 0xda9, 0xea3, 0xfaa, 0x8a6, 0x9af, 0xaa5, 0xbac,\n 0x4ac, 0x5a5, 0x6af, 0x7a6, 0xaa, 0x1a3, 0x2a9, 0x3a0,\n 0xd30, 0xc39, 0xf33, 0xe3a, 0x936, 0x83f, 0xb35, 0xa3c,\n 0x53c, 0x435, 0x73f, 0x636, 0x13a, 0x33, 0x339, 0x230,\n 0xe90, 0xf99, 0xc93, 0xd9a, 0xa96, 0xb9f, 0x895, 0x99c,\n 0x69c, 0x795, 0x49f, 0x596, 0x29a, 0x393, 0x99, 0x190,\n 0xf00, 0xe09, 0xd03, 0xc0a, 0xb06, 0xa0f, 0x905, 0x80c,\n 0x70c, 0x605, 0x50f, 0x406, 0x30a, 0x203, 0x109, 0x0\n ])\n}\n\nfunction getTriTable (): Int32Array {\n return new Int32Array([\n -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 8, 3, 9, 8, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 2, 10, 0, 2, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 8, 3, 2, 10, 8, 10, 9, 8, -1, -1, -1, -1, -1, -1, -1,\n 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 11, 2, 8, 11, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 9, 0, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 11, 2, 1, 9, 11, 9, 8, 11, -1, -1, -1, -1, -1, -1, -1,\n 3, 10, 1, 11, 10, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 10, 1, 0, 8, 10, 8, 11, 10, -1, -1, -1, -1, -1, -1, -1,\n 3, 9, 0, 3, 11, 9, 11, 10, 9, -1, -1, -1, -1, -1, -1, -1,\n 9, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 3, 0, 7, 3, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 9, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 1, 9, 4, 7, 1, 7, 3, 1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 4, 7, 3, 0, 4, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1,\n 9, 2, 10, 9, 0, 2, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1,\n 2, 10, 9, 2, 9, 7, 2, 7, 3, 7, 9, 4, -1, -1, -1, -1,\n 8, 4, 7, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 11, 4, 7, 11, 2, 4, 2, 0, 4, -1, -1, -1, -1, -1, -1, -1,\n 9, 0, 1, 8, 4, 7, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1,\n 4, 7, 11, 9, 4, 11, 9, 11, 2, 9, 2, 1, -1, -1, -1, -1,\n 3, 10, 1, 3, 11, 10, 7, 8, 4, -1, -1, -1, -1, -1, -1, -1,\n 1, 11, 10, 1, 4, 11, 1, 0, 4, 7, 11, 4, -1, -1, -1, -1,\n 4, 7, 8, 9, 0, 11, 9, 11, 10, 11, 0, 3, -1, -1, -1, -1,\n 4, 7, 11, 4, 11, 9, 9, 11, 10, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 4, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 5, 4, 1, 5, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 8, 5, 4, 8, 3, 5, 3, 1, 5, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 8, 1, 2, 10, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1,\n 5, 2, 10, 5, 4, 2, 4, 0, 2, -1, -1, -1, -1, -1, -1, -1,\n 2, 10, 5, 3, 2, 5, 3, 5, 4, 3, 4, 8, -1, -1, -1, -1,\n 9, 5, 4, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 11, 2, 0, 8, 11, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1,\n 0, 5, 4, 0, 1, 5, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1,\n 2, 1, 5, 2, 5, 8, 2, 8, 11, 4, 8, 5, -1, -1, -1, -1,\n 10, 3, 11, 10, 1, 3, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1,\n 4, 9, 5, 0, 8, 1, 8, 10, 1, 8, 11, 10, -1, -1, -1, -1,\n 5, 4, 0, 5, 0, 11, 5, 11, 10, 11, 0, 3, -1, -1, -1, -1,\n 5, 4, 8, 5, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1,\n 9, 7, 8, 5, 7, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 3, 0, 9, 5, 3, 5, 7, 3, -1, -1, -1, -1, -1, -1, -1,\n 0, 7, 8, 0, 1, 7, 1, 5, 7, -1, -1, -1, -1, -1, -1, -1,\n 1, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 7, 8, 9, 5, 7, 10, 1, 2, -1, -1, -1, -1, -1, -1, -1,\n 10, 1, 2, 9, 5, 0, 5, 3, 0, 5, 7, 3, -1, -1, -1, -1,\n 8, 0, 2, 8, 2, 5, 8, 5, 7, 10, 5, 2, -1, -1, -1, -1,\n 2, 10, 5, 2, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1,\n 7, 9, 5, 7, 8, 9, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 7, 9, 7, 2, 9, 2, 0, 2, 7, 11, -1, -1, -1, -1,\n 2, 3, 11, 0, 1, 8, 1, 7, 8, 1, 5, 7, -1, -1, -1, -1,\n 11, 2, 1, 11, 1, 7, 7, 1, 5, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 8, 8, 5, 7, 10, 1, 3, 10, 3, 11, -1, -1, -1, -1,\n 5, 7, 0, 5, 0, 9, 7, 11, 0, 1, 0, 10, 11, 10, 0, -1,\n 11, 10, 0, 11, 0, 3, 10, 5, 0, 8, 0, 7, 5, 7, 0, -1,\n 11, 10, 5, 7, 11, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 0, 1, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 8, 3, 1, 9, 8, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1,\n 1, 6, 5, 2, 6, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 6, 5, 1, 2, 6, 3, 0, 8, -1, -1, -1, -1, -1, -1, -1,\n 9, 6, 5, 9, 0, 6, 0, 2, 6, -1, -1, -1, -1, -1, -1, -1,\n 5, 9, 8, 5, 8, 2, 5, 2, 6, 3, 2, 8, -1, -1, -1, -1,\n 2, 3, 11, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 11, 0, 8, 11, 2, 0, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 9, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1,\n 5, 10, 6, 1, 9, 2, 9, 11, 2, 9, 8, 11, -1, -1, -1, -1,\n 6, 3, 11, 6, 5, 3, 5, 1, 3, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 11, 0, 11, 5, 0, 5, 1, 5, 11, 6, -1, -1, -1, -1,\n 3, 11, 6, 0, 3, 6, 0, 6, 5, 0, 5, 9, -1, -1, -1, -1,\n 6, 5, 9, 6, 9, 11, 11, 9, 8, -1, -1, -1, -1, -1, -1, -1,\n 5, 10, 6, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 3, 0, 4, 7, 3, 6, 5, 10, -1, -1, -1, -1, -1, -1, -1,\n 1, 9, 0, 5, 10, 6, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1,\n 10, 6, 5, 1, 9, 7, 1, 7, 3, 7, 9, 4, -1, -1, -1, -1,\n 6, 1, 2, 6, 5, 1, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 5, 5, 2, 6, 3, 0, 4, 3, 4, 7, -1, -1, -1, -1,\n 8, 4, 7, 9, 0, 5, 0, 6, 5, 0, 2, 6, -1, -1, -1, -1,\n 7, 3, 9, 7, 9, 4, 3, 2, 9, 5, 9, 6, 2, 6, 9, -1,\n 3, 11, 2, 7, 8, 4, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1,\n 5, 10, 6, 4, 7, 2, 4, 2, 0, 2, 7, 11, -1, -1, -1, -1,\n 0, 1, 9, 4, 7, 8, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1,\n 9, 2, 1, 9, 11, 2, 9, 4, 11, 7, 11, 4, 5, 10, 6, -1,\n 8, 4, 7, 3, 11, 5, 3, 5, 1, 5, 11, 6, -1, -1, -1, -1,\n 5, 1, 11, 5, 11, 6, 1, 0, 11, 7, 11, 4, 0, 4, 11, -1,\n 0, 5, 9, 0, 6, 5, 0, 3, 6, 11, 6, 3, 8, 4, 7, -1,\n 6, 5, 9, 6, 9, 11, 4, 7, 9, 7, 11, 9, -1, -1, -1, -1,\n 10, 4, 9, 6, 4, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 10, 6, 4, 9, 10, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1,\n 10, 0, 1, 10, 6, 0, 6, 4, 0, -1, -1, -1, -1, -1, -1, -1,\n 8, 3, 1, 8, 1, 6, 8, 6, 4, 6, 1, 10, -1, -1, -1, -1,\n 1, 4, 9, 1, 2, 4, 2, 6, 4, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 8, 1, 2, 9, 2, 4, 9, 2, 6, 4, -1, -1, -1, -1,\n 0, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 8, 3, 2, 8, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1,\n 10, 4, 9, 10, 6, 4, 11, 2, 3, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 2, 2, 8, 11, 4, 9, 10, 4, 10, 6, -1, -1, -1, -1,\n 3, 11, 2, 0, 1, 6, 0, 6, 4, 6, 1, 10, -1, -1, -1, -1,\n 6, 4, 1, 6, 1, 10, 4, 8, 1, 2, 1, 11, 8, 11, 1, -1,\n 9, 6, 4, 9, 3, 6, 9, 1, 3, 11, 6, 3, -1, -1, -1, -1,\n 8, 11, 1, 8, 1, 0, 11, 6, 1, 9, 1, 4, 6, 4, 1, -1,\n 3, 11, 6, 3, 6, 0, 0, 6, 4, -1, -1, -1, -1, -1, -1, -1,\n 6, 4, 8, 11, 6, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 7, 10, 6, 7, 8, 10, 8, 9, 10, -1, -1, -1, -1, -1, -1, -1,\n 0, 7, 3, 0, 10, 7, 0, 9, 10, 6, 7, 10, -1, -1, -1, -1,\n 10, 6, 7, 1, 10, 7, 1, 7, 8, 1, 8, 0, -1, -1, -1, -1,\n 10, 6, 7, 10, 7, 1, 1, 7, 3, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 6, 1, 6, 8, 1, 8, 9, 8, 6, 7, -1, -1, -1, -1,\n 2, 6, 9, 2, 9, 1, 6, 7, 9, 0, 9, 3, 7, 3, 9, -1,\n 7, 8, 0, 7, 0, 6, 6, 0, 2, -1, -1, -1, -1, -1, -1, -1,\n 7, 3, 2, 6, 7, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 3, 11, 10, 6, 8, 10, 8, 9, 8, 6, 7, -1, -1, -1, -1,\n 2, 0, 7, 2, 7, 11, 0, 9, 7, 6, 7, 10, 9, 10, 7, -1,\n 1, 8, 0, 1, 7, 8, 1, 10, 7, 6, 7, 10, 2, 3, 11, -1,\n 11, 2, 1, 11, 1, 7, 10, 6, 1, 6, 7, 1, -1, -1, -1, -1,\n 8, 9, 6, 8, 6, 7, 9, 1, 6, 11, 6, 3, 1, 3, 6, -1,\n 0, 9, 1, 11, 6, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 7, 8, 0, 7, 0, 6, 3, 11, 0, 11, 6, 0, -1, -1, -1, -1,\n 7, 11, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 8, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 9, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 8, 1, 9, 8, 3, 1, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1,\n 10, 1, 2, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 3, 0, 8, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1,\n 2, 9, 0, 2, 10, 9, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1,\n 6, 11, 7, 2, 10, 3, 10, 8, 3, 10, 9, 8, -1, -1, -1, -1,\n 7, 2, 3, 6, 2, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 7, 0, 8, 7, 6, 0, 6, 2, 0, -1, -1, -1, -1, -1, -1, -1,\n 2, 7, 6, 2, 3, 7, 0, 1, 9, -1, -1, -1, -1, -1, -1, -1,\n 1, 6, 2, 1, 8, 6, 1, 9, 8, 8, 7, 6, -1, -1, -1, -1,\n 10, 7, 6, 10, 1, 7, 1, 3, 7, -1, -1, -1, -1, -1, -1, -1,\n 10, 7, 6, 1, 7, 10, 1, 8, 7, 1, 0, 8, -1, -1, -1, -1,\n 0, 3, 7, 0, 7, 10, 0, 10, 9, 6, 10, 7, -1, -1, -1, -1,\n 7, 6, 10, 7, 10, 8, 8, 10, 9, -1, -1, -1, -1, -1, -1, -1,\n 6, 8, 4, 11, 8, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 6, 11, 3, 0, 6, 0, 4, 6, -1, -1, -1, -1, -1, -1, -1,\n 8, 6, 11, 8, 4, 6, 9, 0, 1, -1, -1, -1, -1, -1, -1, -1,\n 9, 4, 6, 9, 6, 3, 9, 3, 1, 11, 3, 6, -1, -1, -1, -1,\n 6, 8, 4, 6, 11, 8, 2, 10, 1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 3, 0, 11, 0, 6, 11, 0, 4, 6, -1, -1, -1, -1,\n 4, 11, 8, 4, 6, 11, 0, 2, 9, 2, 10, 9, -1, -1, -1, -1,\n 10, 9, 3, 10, 3, 2, 9, 4, 3, 11, 3, 6, 4, 6, 3, -1,\n 8, 2, 3, 8, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1,\n 0, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 9, 0, 2, 3, 4, 2, 4, 6, 4, 3, 8, -1, -1, -1, -1,\n 1, 9, 4, 1, 4, 2, 2, 4, 6, -1, -1, -1, -1, -1, -1, -1,\n 8, 1, 3, 8, 6, 1, 8, 4, 6, 6, 10, 1, -1, -1, -1, -1,\n 10, 1, 0, 10, 0, 6, 6, 0, 4, -1, -1, -1, -1, -1, -1, -1,\n 4, 6, 3, 4, 3, 8, 6, 10, 3, 0, 3, 9, 10, 9, 3, -1,\n 10, 9, 4, 6, 10, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 9, 5, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 4, 9, 5, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1,\n 5, 0, 1, 5, 4, 0, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1,\n 11, 7, 6, 8, 3, 4, 3, 5, 4, 3, 1, 5, -1, -1, -1, -1,\n 9, 5, 4, 10, 1, 2, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1,\n 6, 11, 7, 1, 2, 10, 0, 8, 3, 4, 9, 5, -1, -1, -1, -1,\n 7, 6, 11, 5, 4, 10, 4, 2, 10, 4, 0, 2, -1, -1, -1, -1,\n 3, 4, 8, 3, 5, 4, 3, 2, 5, 10, 5, 2, 11, 7, 6, -1,\n 7, 2, 3, 7, 6, 2, 5, 4, 9, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 4, 0, 8, 6, 0, 6, 2, 6, 8, 7, -1, -1, -1, -1,\n 3, 6, 2, 3, 7, 6, 1, 5, 0, 5, 4, 0, -1, -1, -1, -1,\n 6, 2, 8, 6, 8, 7, 2, 1, 8, 4, 8, 5, 1, 5, 8, -1,\n 9, 5, 4, 10, 1, 6, 1, 7, 6, 1, 3, 7, -1, -1, -1, -1,\n 1, 6, 10, 1, 7, 6, 1, 0, 7, 8, 7, 0, 9, 5, 4, -1,\n 4, 0, 10, 4, 10, 5, 0, 3, 10, 6, 10, 7, 3, 7, 10, -1,\n 7, 6, 10, 7, 10, 8, 5, 4, 10, 4, 8, 10, -1, -1, -1, -1,\n 6, 9, 5, 6, 11, 9, 11, 8, 9, -1, -1, -1, -1, -1, -1, -1,\n 3, 6, 11, 0, 6, 3, 0, 5, 6, 0, 9, 5, -1, -1, -1, -1,\n 0, 11, 8, 0, 5, 11, 0, 1, 5, 5, 6, 11, -1, -1, -1, -1,\n 6, 11, 3, 6, 3, 5, 5, 3, 1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 9, 5, 11, 9, 11, 8, 11, 5, 6, -1, -1, -1, -1,\n 0, 11, 3, 0, 6, 11, 0, 9, 6, 5, 6, 9, 1, 2, 10, -1,\n 11, 8, 5, 11, 5, 6, 8, 0, 5, 10, 5, 2, 0, 2, 5, -1,\n 6, 11, 3, 6, 3, 5, 2, 10, 3, 10, 5, 3, -1, -1, -1, -1,\n 5, 8, 9, 5, 2, 8, 5, 6, 2, 3, 8, 2, -1, -1, -1, -1,\n 9, 5, 6, 9, 6, 0, 0, 6, 2, -1, -1, -1, -1, -1, -1, -1,\n 1, 5, 8, 1, 8, 0, 5, 6, 8, 3, 8, 2, 6, 2, 8, -1,\n 1, 5, 6, 2, 1, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 3, 6, 1, 6, 10, 3, 8, 6, 5, 6, 9, 8, 9, 6, -1,\n 10, 1, 0, 10, 0, 6, 9, 5, 0, 5, 6, 0, -1, -1, -1, -1,\n 0, 3, 8, 5, 6, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 10, 5, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 11, 5, 10, 7, 5, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 11, 5, 10, 11, 7, 5, 8, 3, 0, -1, -1, -1, -1, -1, -1, -1,\n 5, 11, 7, 5, 10, 11, 1, 9, 0, -1, -1, -1, -1, -1, -1, -1,\n 10, 7, 5, 10, 11, 7, 9, 8, 1, 8, 3, 1, -1, -1, -1, -1,\n 11, 1, 2, 11, 7, 1, 7, 5, 1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 1, 2, 7, 1, 7, 5, 7, 2, 11, -1, -1, -1, -1,\n 9, 7, 5, 9, 2, 7, 9, 0, 2, 2, 11, 7, -1, -1, -1, -1,\n 7, 5, 2, 7, 2, 11, 5, 9, 2, 3, 2, 8, 9, 8, 2, -1,\n 2, 5, 10, 2, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1,\n 8, 2, 0, 8, 5, 2, 8, 7, 5, 10, 2, 5, -1, -1, -1, -1,\n 9, 0, 1, 5, 10, 3, 5, 3, 7, 3, 10, 2, -1, -1, -1, -1,\n 9, 8, 2, 9, 2, 1, 8, 7, 2, 10, 2, 5, 7, 5, 2, -1,\n 1, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 7, 0, 7, 1, 1, 7, 5, -1, -1, -1, -1, -1, -1, -1,\n 9, 0, 3, 9, 3, 5, 5, 3, 7, -1, -1, -1, -1, -1, -1, -1,\n 9, 8, 7, 5, 9, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 5, 8, 4, 5, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1,\n 5, 0, 4, 5, 11, 0, 5, 10, 11, 11, 3, 0, -1, -1, -1, -1,\n 0, 1, 9, 8, 4, 10, 8, 10, 11, 10, 4, 5, -1, -1, -1, -1,\n 10, 11, 4, 10, 4, 5, 11, 3, 4, 9, 4, 1, 3, 1, 4, -1,\n 2, 5, 1, 2, 8, 5, 2, 11, 8, 4, 5, 8, -1, -1, -1, -1,\n 0, 4, 11, 0, 11, 3, 4, 5, 11, 2, 11, 1, 5, 1, 11, -1,\n 0, 2, 5, 0, 5, 9, 2, 11, 5, 4, 5, 8, 11, 8, 5, -1,\n 9, 4, 5, 2, 11, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 5, 10, 3, 5, 2, 3, 4, 5, 3, 8, 4, -1, -1, -1, -1,\n 5, 10, 2, 5, 2, 4, 4, 2, 0, -1, -1, -1, -1, -1, -1, -1,\n 3, 10, 2, 3, 5, 10, 3, 8, 5, 4, 5, 8, 0, 1, 9, -1,\n 5, 10, 2, 5, 2, 4, 1, 9, 2, 9, 4, 2, -1, -1, -1, -1,\n 8, 4, 5, 8, 5, 3, 3, 5, 1, -1, -1, -1, -1, -1, -1, -1,\n 0, 4, 5, 1, 0, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 8, 4, 5, 8, 5, 3, 9, 0, 5, 0, 3, 5, -1, -1, -1, -1,\n 9, 4, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 11, 7, 4, 9, 11, 9, 10, 11, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 4, 9, 7, 9, 11, 7, 9, 10, 11, -1, -1, -1, -1,\n 1, 10, 11, 1, 11, 4, 1, 4, 0, 7, 4, 11, -1, -1, -1, -1,\n 3, 1, 4, 3, 4, 8, 1, 10, 4, 7, 4, 11, 10, 11, 4, -1,\n 4, 11, 7, 9, 11, 4, 9, 2, 11, 9, 1, 2, -1, -1, -1, -1,\n 9, 7, 4, 9, 11, 7, 9, 1, 11, 2, 11, 1, 0, 8, 3, -1,\n 11, 7, 4, 11, 4, 2, 2, 4, 0, -1, -1, -1, -1, -1, -1, -1,\n 11, 7, 4, 11, 4, 2, 8, 3, 4, 3, 2, 4, -1, -1, -1, -1,\n 2, 9, 10, 2, 7, 9, 2, 3, 7, 7, 4, 9, -1, -1, -1, -1,\n 9, 10, 7, 9, 7, 4, 10, 2, 7, 8, 7, 0, 2, 0, 7, -1,\n 3, 7, 10, 3, 10, 2, 7, 4, 10, 1, 10, 0, 4, 0, 10, -1,\n 1, 10, 2, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 9, 1, 4, 1, 7, 7, 1, 3, -1, -1, -1, -1, -1, -1, -1,\n 4, 9, 1, 4, 1, 7, 0, 8, 1, 8, 7, 1, -1, -1, -1, -1,\n 4, 0, 3, 7, 4, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 8, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 9, 3, 9, 11, 11, 9, 10, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 10, 0, 10, 8, 8, 10, 11, -1, -1, -1, -1, -1, -1, -1,\n 3, 1, 10, 11, 3, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 11, 1, 11, 9, 9, 11, 8, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 9, 3, 9, 11, 1, 2, 9, 2, 11, 9, -1, -1, -1, -1,\n 0, 2, 11, 8, 0, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 2, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 3, 8, 2, 8, 10, 10, 8, 9, -1, -1, -1, -1, -1, -1, -1,\n 9, 10, 2, 0, 9, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 3, 8, 2, 8, 10, 0, 1, 8, 1, 10, 8, -1, -1, -1, -1,\n 1, 10, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 3, 8, 9, 1, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 9, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 3, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1\n ])\n}\n\ninterface MarchingCubes {\n new (field: number[], nx: number, ny: number, nz: number, atomindex: number[]): void\n triangulate: (_isolevel: number, _noNormals: boolean, _box: number[][]|undefined, _contour: boolean, _wrap: boolean) => {\n position: Float32Array\n normal: undefined|Float32Array\n index: Uint32Array|Uint16Array\n atomindex: Int32Array|undefined\n contour: boolean\n }\n}\nfunction MarchingCubes (this: MarchingCubes, field: number[], nx: number, ny: number, nz: number, atomindex: number[]) {\n // Based on alteredq / http://alteredqualia.com/\n // port of greggman's ThreeD version of marching cubes to Three.js\n // http://webglsamples.googlecode.com/hg/blob/blob.html\n //\n // Adapted for NGL by Alexander Rose\n\n // Triangles are constructed between points on cube edges.\n // allowedContours[edge1][edge1] indicates which lines from a given\n // triangle should be shown in line mode.\n\n // Values are bitmasks:\n // In loop over cubes we keep another bitmask indicating whether our current\n // cell is the first x-value (1),\n // first y-value (2) or first z-value (4) of the current loop.\n // We draw all lines on leading faces but only draw trailing face lines the first\n // time through the loop\n // A value of 8 below means the edge is always drawn (leading face)\n\n // E.g. the first row, lines between edge0 and other edges in the bottom\n // x-y plane are only drawn for the first value of z, edges in the\n // x-z plane are only drawn for the first value of y. No other lines\n // are drawn as they're redundant\n // The line between edge 1 and 5 is always drawn as it's on the leading edge\n var allowedContours = [\n\n [ 0, 4, 4, 4, 2, 0, 0, 0, 2, 2, 0, 0 ], // 1 2 3 4 8 9\n [ 4, 0, 4, 4, 0, 8, 0, 0, 0, 8, 8, 0 ], // 0 2 3 5 9 10\n [ 4, 4, 0, 4, 0, 0, 8, 0, 0, 0, 8, 8 ], // 0 1 3 6 10 11\n [ 4, 4, 4, 0, 0, 0, 0, 1, 1, 0, 0, 1 ], // 0 1 2 7 8 11\n [ 2, 0, 0, 0, 0, 8, 8, 8, 2, 2, 0, 0 ], // 0 5 6 7 8 9\n [ 0, 8, 0, 0, 8, 0, 8, 8, 0, 8, 8, 0 ], // And rotate it\n [ 0, 0, 8, 0, 8, 8, 0, 8, 0, 0, 8, 8 ],\n [ 0, 0, 0, 1, 8, 8, 8, 0, 1, 0, 0, 1 ],\n [ 2, 0, 0, 1, 2, 0, 0, 1, 0, 2, 0, 1 ], // 0 3 4 7 9 11\n [ 2, 8, 0, 0, 2, 8, 0, 0, 2, 0, 8, 0 ], // And rotate some more\n [ 0, 8, 8, 0, 0, 8, 8, 0, 0, 8, 0, 8 ],\n [ 0, 0, 8, 1, 0, 0, 8, 1, 1, 0, 8, 0 ]\n\n ]\n\n var isolevel = 0\n var noNormals = false\n var contour = false\n var wrap = false\n var isNegativeIso = false\n var normalFactor = -1\n\n\n var n = nx * ny * nz\n\n // deltas\n var yd = nx\n var zd = nx * ny\n\n var normalCache: Float32Array, vertexIndex: Int32Array\n var count: number, icount: number\n\n var ilist = new Int32Array(12)\n\n var positionArray: number[] = []\n var normalArray: number[] = []\n var indexArray: number[] = []\n var atomindexArray: number[] = []\n\n var edgeTable = getEdgeTable()\n var triTable = getTriTable()\n\n var mx: number, my: number, mz: number\n\n //\n\n this.triangulate = function (_isolevel: number, _noNormals: boolean, _box: number[][]|undefined, _contour: boolean, _wrap: boolean) {\n isolevel = _isolevel\n isNegativeIso = isolevel < 0.0\n contour = _contour\n wrap = _wrap\n // Normals currently disabled in contour mode for performance (unused)\n noNormals = _noNormals || contour\n\n if (!noNormals) {\n normalFactor = isolevel > 0 ? -1.0 : 1.0\n if (!normalCache) {\n normalCache = new Float32Array(n * 3)\n } \n }\n\n var vIndexLength = n * 3\n\n if (!vertexIndex || vertexIndex.length !== vIndexLength) {\n vertexIndex = new Int32Array(vIndexLength)\n }\n\n count = 0\n icount = 0\n\n if (_box !== undefined) {\n var min = _box[ 0 ].map(Math.round)\n var max = _box[ 1 ].map(Math.round)\n\n mx = nx * Math.ceil(Math.abs(min[ 0 ]) / nx)\n my = ny * Math.ceil(Math.abs(min[ 1 ]) / ny)\n mz = nz * Math.ceil(Math.abs(min[ 2 ]) / nz)\n\n triangulate(\n min[ 0 ], min[ 1 ], min[ 2 ],\n max[ 0 ], max[ 1 ], max[ 2 ]\n )\n } else {\n mx = my = mz = 0\n\n triangulate()\n }\n\n positionArray.length = count * 3\n if (!noNormals) normalArray.length = count * 3\n indexArray.length = icount\n if (atomindex) atomindexArray.length = count\n\n return {\n position: new Float32Array(positionArray),\n normal: noNormals ? undefined : new Float32Array(normalArray),\n index: getUintArray(indexArray, positionArray.length / 3),\n atomindex: atomindex ? new Int32Array(atomindexArray) : undefined,\n contour: contour\n }\n }\n\n // polygonization\n\n function lerp (a: number, b: number, t: number) { return a + (b - a) * t }\n\n function index (x: number, y: number, z: number) {\n x = (x + mx) % nx\n y = (y + my) % ny\n z = (z + mz) % nz\n return ((zd * z) + yd * y) + x\n }\n\n function VIntX (q: number, offset: number, x: number, y: number, z: number, valp1: number, valp2: number) {\n var _q = 3 * q\n\n if (vertexIndex[ _q ] < 0) {\n var mu = (isolevel - valp1) / (valp2 - valp1)\n var nc = normalCache\n\n var c = count * 3\n\n positionArray[ c ] = x + mu\n positionArray[ c + 1 ] = y\n positionArray[ c + 2 ] = z\n\n if (!noNormals) {\n var q3 = q * 3\n\n normalArray[ c ] = normalFactor * lerp(nc[ q3 ], nc[ q3 + 3 ], mu)\n normalArray[ c + 1 ] = normalFactor * lerp(nc[ q3 + 1 ], nc[ q3 + 4 ], mu)\n normalArray[ c + 2 ] = normalFactor * lerp(nc[ q3 + 2 ], nc[ q3 + 5 ], mu)\n }\n\n if (atomindex) atomindexArray[ count ] = atomindex[ q + Math.round(mu) ]\n\n vertexIndex[ _q ] = count\n ilist[ offset ] = count\n\n count += 1\n } else {\n ilist[ offset ] = vertexIndex[ _q ]\n }\n }\n\n function VIntY (q: number, offset: number, x: number, y: number, z: number, valp1: number, valp2: number) {\n var _q = 3 * q + 1\n\n if (vertexIndex[ _q ] < 0) {\n var mu = (isolevel - valp1) / (valp2 - valp1)\n var nc = normalCache\n\n var c = count * 3\n\n positionArray[ c ] = x\n positionArray[ c + 1 ] = y + mu\n positionArray[ c + 2 ] = z\n\n if (!noNormals) {\n var q3 = q * 3\n var q6 = q3 + yd * 3\n\n normalArray[ c ] = normalFactor * lerp(nc[ q3 ], nc[ q6 ], mu)\n normalArray[ c + 1 ] = normalFactor * lerp(nc[ q3 + 1 ], nc[ q6 + 1 ], mu)\n normalArray[ c + 2 ] = normalFactor * lerp(nc[ q3 + 2 ], nc[ q6 + 2 ], mu)\n }\n\n if (atomindex) atomindexArray[ count ] = atomindex[ q + Math.round(mu) * yd ]\n\n vertexIndex[ _q ] = count\n ilist[ offset ] = count\n\n count += 1\n } else {\n ilist[ offset ] = vertexIndex[ _q ]\n }\n }\n\n function VIntZ (q: number, offset: number, x: number, y: number, z: number, valp1: number, valp2: number) {\n var _q = 3 * q + 2\n\n if (vertexIndex[ _q ] < 0) {\n var mu = (isolevel - valp1) / (valp2 - valp1)\n var nc = normalCache\n\n var c = count * 3\n\n positionArray[ c ] = x\n positionArray[ c + 1 ] = y\n positionArray[ c + 2 ] = z + mu\n\n if (!noNormals) {\n var q3 = q * 3\n var q6 = q3 + zd * 3\n\n normalArray[ c ] = normalFactor * lerp(nc[ q3 ], nc[ q6 ], mu)\n normalArray[ c + 1 ] = normalFactor * lerp(nc[ q3 + 1 ], nc[ q6 + 1 ], mu)\n normalArray[ c + 2 ] = normalFactor * lerp(nc[ q3 + 2 ], nc[ q6 + 2 ], mu)\n }\n\n if (atomindex) atomindexArray[ count ] = atomindex[ q + Math.round(mu) * zd ]\n\n vertexIndex[ _q ] = count\n ilist[ offset ] = count\n\n count += 1\n } else {\n ilist[ offset ] = vertexIndex[ _q ]\n }\n }\n\n function compNorm (q: number) {\n var q3 = q * 3\n\n if (normalCache[ q3 ] === 0.0) {\n normalCache[ q3 ] = field[ (q - 1 + n) % n ] - field[ (q + 1) % n ]\n normalCache[ q3 + 1 ] = field[ (q - yd + n) % n ] - field[ (q + yd) % n ]\n normalCache[ q3 + 2 ] = field[ (q - zd + n) % n ] - field[ (q + zd) % n ]\n }\n }\n\n function polygonize (fx: number, fy: number, fz: number, q: number, edgeFilter: number) {\n // cache indices\n var q1\n var qy\n var qz\n var q1y\n var q1z\n var qyz\n var q1yz\n if (wrap) {\n q = index(fx, fy, fz)\n q1 = index(fx + 1, fy, fz)\n qy = index(fx, fy + 1, fz)\n qz = index(fx, fy, fz + 1)\n q1y = index(fx + 1, fy + 1, fz)\n q1z = index(fx + 1, fy, fz + 1)\n qyz = index(fx, fy + 1, fz + 1)\n q1yz = index(fx + 1, fy + 1, fz + 1)\n } else {\n q1 = q + 1\n qy = q + yd\n qz = q + zd\n q1y = qy + 1\n q1z = qz + 1\n qyz = qy + zd\n q1yz = qyz + 1\n }\n\n var cubeindex = 0\n var field0 = field[ q ]\n var field1 = field[ q1 ]\n var field2 = field[ qy ]\n var field3 = field[ q1y ]\n var field4 = field[ qz ]\n var field5 = field[ q1z ]\n var field6 = field[ qyz ]\n var field7 = field[ q1yz ]\n\n if (field0 < isolevel) cubeindex |= 1\n if (field1 < isolevel) cubeindex |= 2\n if (field2 < isolevel) cubeindex |= 8\n if (field3 < isolevel) cubeindex |= 4\n if (field4 < isolevel) cubeindex |= 16\n if (field5 < isolevel) cubeindex |= 32\n if (field6 < isolevel) cubeindex |= 128\n if (field7 < isolevel) cubeindex |= 64\n\n // if cube is entirely in/out of the surface - bail, nothing to draw\n\n var bits = edgeTable[ cubeindex ]\n if (bits === 0) return 0\n\n var fx2 = fx + 1\n var fy2 = fy + 1\n var fz2 = fz + 1\n\n // top of the cube\n\n if (bits & 1) {\n if (!noNormals) {\n compNorm(q)\n compNorm(q1)\n }\n VIntX(q, 0, fx, fy, fz, field0, field1)\n }\n\n if (bits & 2) {\n if (!noNormals) {\n compNorm(q1)\n compNorm(q1y)\n }\n VIntY(q1, 1, fx2, fy, fz, field1, field3)\n }\n\n if (bits & 4) {\n if (!noNormals) {\n compNorm(qy)\n compNorm(q1y)\n }\n VIntX(qy, 2, fx, fy2, fz, field2, field3)\n }\n\n if (bits & 8) {\n if (!noNormals) {\n compNorm(q)\n compNorm(qy)\n }\n VIntY(q, 3, fx, fy, fz, field0, field2)\n }\n\n // bottom of the cube\n\n if (bits & 16) {\n if (!noNormals) {\n compNorm(qz)\n compNorm(q1z)\n }\n VIntX(qz, 4, fx, fy, fz2, field4, field5)\n }\n\n if (bits & 32) {\n if (!noNormals) {\n compNorm(q1z)\n compNorm(q1yz)\n }\n VIntY(q1z, 5, fx2, fy, fz2, field5, field7)\n }\n\n if (bits & 64) {\n if (!noNormals) {\n compNorm(qyz)\n compNorm(q1yz)\n }\n VIntX(qyz, 6, fx, fy2, fz2, field6, field7)\n }\n\n if (bits & 128) {\n if (!noNormals) {\n compNorm(qz)\n compNorm(qyz)\n }\n VIntY(qz, 7, fx, fy, fz2, field4, field6)\n }\n\n // vertical lines of the cube\n\n if (bits & 256) {\n if (!noNormals) {\n compNorm(q)\n compNorm(qz)\n }\n VIntZ(q, 8, fx, fy, fz, field0, field4)\n }\n\n if (bits & 512) {\n if (!noNormals) {\n compNorm(q1)\n compNorm(q1z)\n }\n VIntZ(q1, 9, fx2, fy, fz, field1, field5)\n }\n\n if (bits & 1024) {\n if (!noNormals) {\n compNorm(q1y)\n compNorm(q1yz)\n }\n VIntZ(q1y, 10, fx2, fy2, fz, field3, field7)\n }\n\n if (bits & 2048) {\n if (!noNormals) {\n compNorm(qy)\n compNorm(qyz)\n }\n VIntZ(qy, 11, fx, fy2, fz, field2, field6)\n }\n\n var triIndex = cubeindex << 4 // re-purpose cubeindex into an offset into triTable\n\n var e1\n var e2\n var e3\n var i = 0\n\n // here is where triangles are created\n\n while (triTable[ triIndex + i ] !== -1) {\n e1 = triTable[ triIndex + i ]\n e2 = triTable[ triIndex + i + 1 ]\n e3 = triTable[ triIndex + i + 2 ]\n\n if (contour) {\n if (allowedContours[ e1 ][ e2 ] & edgeFilter) {\n indexArray[ icount++ ] = ilist[ e1 ]\n indexArray[ icount++ ] = ilist[ e2 ]\n }\n if (allowedContours[ e2 ][ e3 ] & edgeFilter) {\n indexArray[ icount++ ] = ilist[ e2 ]\n indexArray[ icount++ ] = ilist[ e3 ]\n }\n if (allowedContours[ e1 ][ e3 ] & edgeFilter) {\n indexArray[ icount++ ] = ilist[ e1 ]\n indexArray[ icount++ ] = ilist[ e3 ]\n }\n } else {\n indexArray[ icount++ ] = ilist[ isNegativeIso ? e1 : e2 ]\n indexArray[ icount++ ] = ilist[ isNegativeIso ? e2 : e1 ]\n indexArray[ icount++ ] = ilist[ e3 ]\n }\n\n i += 3\n }\n }\n\n function triangulate (xBeg?: number, yBeg?: number, zBeg?: number, xEnd?: number, yEnd?: number, zEnd?: number) {\n let q\n let q3\n let x\n let y\n let z\n let yOffset\n let zOffset\n\n xBeg = xBeg !== undefined ? xBeg : 0\n yBeg = yBeg !== undefined ? yBeg : 0\n zBeg = zBeg !== undefined ? zBeg : 0\n\n xEnd = xEnd !== undefined ? xEnd : nx - 1\n yEnd = yEnd !== undefined ? yEnd : ny - 1\n zEnd = zEnd !== undefined ? zEnd : nz - 1\n\n if (!wrap) {\n if (noNormals) {\n xBeg = Math.max(0, xBeg)\n yBeg = Math.max(0, yBeg)\n zBeg = Math.max(0, zBeg)\n\n xEnd = Math.min(nx - 1, xEnd)\n yEnd = Math.min(ny - 1, yEnd)\n zEnd = Math.min(nz - 1, zEnd)\n } else {\n xBeg = Math.max(1, xBeg)\n yBeg = Math.max(1, yBeg)\n zBeg = Math.max(1, zBeg)\n\n xEnd = Math.min(nx - 2, xEnd)\n yEnd = Math.min(ny - 2, yEnd)\n zEnd = Math.min(nz - 2, zEnd)\n }\n }\n\n let xBeg2, yBeg2, zBeg2, xEnd2, yEnd2, zEnd2\n\n if (!wrap) {\n // init part of the vertexIndex\n // (takes a significant amount of time to do for all)\n\n xBeg2 = Math.max(0, xBeg - 2)\n yBeg2 = Math.max(0, yBeg - 2)\n zBeg2 = Math.max(0, zBeg - 2)\n\n xEnd2 = Math.min(nx, xEnd + 2)\n yEnd2 = Math.min(ny, yEnd + 2)\n zEnd2 = Math.min(nz, zEnd + 2)\n\n for (z = zBeg2; z < zEnd2; ++z) {\n zOffset = zd * z\n for (y = yBeg2; y < yEnd2; ++y) {\n yOffset = zOffset + yd * y\n for (x = xBeg2; x < xEnd2; ++x) {\n q = 3 * (yOffset + x)\n vertexIndex[ q ] = -1\n vertexIndex[ q + 1 ] = -1\n vertexIndex[ q + 2 ] = -1\n }\n }\n }\n } else {\n xBeg2 = xBeg - 2\n yBeg2 = yBeg - 2\n zBeg2 = zBeg - 2\n\n xEnd2 = xEnd + 2\n yEnd2 = yEnd + 2\n zEnd2 = zEnd + 2\n\n for (z = zBeg2; z < zEnd2; ++z) {\n for (y = yBeg2; y < yEnd2; ++y) {\n for (x = xBeg2; x < xEnd2; ++x) {\n q3 = index(x, y, z) * 3\n vertexIndex[ q3 ] = -1\n vertexIndex[ q3 + 1 ] = -1\n vertexIndex[ q3 + 2 ] = -1\n }\n }\n }\n }\n\n if (!wrap) {\n // clip space where the isovalue is too low\n\n var __break\n var __xBeg = xBeg; var __yBeg = yBeg; var __zBeg = zBeg\n var __xEnd = xEnd; var __yEnd = yEnd; var __zEnd = zEnd\n\n __break = false\n for (z = zBeg; z < zEnd; ++z) {\n for (y = yBeg; y < yEnd; ++y) {\n for (x = xBeg; x < xEnd; ++x) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __zBeg = z\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (y = yBeg; y < yEnd; ++y) {\n for (z = __zBeg; z < zEnd; ++z) {\n for (x = xBeg; x < xEnd; ++x) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __yBeg = y\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (x = xBeg; x < xEnd; ++x) {\n for (y = __yBeg; y < yEnd; ++y) {\n for (z = __zBeg; z < zEnd; ++z) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __xBeg = x\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (z = zEnd; z >= zBeg; --z) {\n for (y = yEnd; y >= yBeg; --y) {\n for (x = xEnd; x >= xBeg; --x) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __zEnd = z\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (y = yEnd; y >= yBeg; --y) {\n for (z = __zEnd; z >= zBeg; --z) {\n for (x = xEnd; x >= xBeg; --x) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __yEnd = y\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (x = xEnd; x >= xBeg; --x) {\n for (y = __yEnd; y >= yBeg; --y) {\n for (z = __zEnd; z >= zBeg; --z) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __xEnd = x\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n //\n\n if (noNormals) {\n xBeg = Math.max(0, __xBeg - 1)\n yBeg = Math.max(0, __yBeg - 1)\n zBeg = Math.max(0, __zBeg - 1)\n\n xEnd = Math.min(nx - 1, __xEnd + 1)\n yEnd = Math.min(ny - 1, __yEnd + 1)\n zEnd = Math.min(nz - 1, __zEnd + 1)\n } else {\n xBeg = Math.max(1, __xBeg - 1)\n yBeg = Math.max(1, __yBeg - 1)\n zBeg = Math.max(1, __zBeg - 1)\n\n xEnd = Math.min(nx - 2, __xEnd + 1)\n yEnd = Math.min(ny - 2, __yEnd + 1)\n zEnd = Math.min(nz - 2, __zEnd + 1)\n }\n }\n\n // polygonize part of the grid\n var edgeFilter = 15\n for (z = zBeg; z < zEnd; ++z, edgeFilter &= ~4) {\n zOffset = zd * z\n edgeFilter |= 2\n for (y = yBeg; y < yEnd; ++y, edgeFilter &= ~2) {\n yOffset = zOffset + yd * y\n edgeFilter |= 1\n for (x = xBeg; x < xEnd; ++x, edgeFilter &= ~1) {\n q = yOffset + x\n polygonize(x, y, z, q, edgeFilter)\n }\n }\n }\n }\n}\nObject.assign(MarchingCubes, {__deps: [ getEdgeTable, getTriTable, getUintArray ]})\n\nexport default MarchingCubes\n","/**\n * @file Matrix Utils\n * @private\n * @author Alexander Rose \n *\n * svd methods from Eugene Zatepyakin / http://inspirit.github.io/jsfeat/\n */\n\nimport { NumberArray } from '../types'\nimport { v3new, v3cross } from './vector-utils'\n\nexport class Matrix {\n size: number\n data: Float32Array\n\n constructor (readonly cols: number, readonly rows: number) {\n this.size = this.cols * this.rows\n this.data = new Float32Array(this.size)\n }\n\n copyTo (matrix: Matrix) {\n matrix.data.set(this.data)\n }\n}\n\nexport function transpose (At: Matrix, A: Matrix) {\n let i = 0\n let j = 0\n const nrows = A.rows\n const ncols = A.cols\n let Ai = 0\n let Ati = 0\n let pAt = 0\n const ad = A.data\n const atd = At.data\n\n for (; i < nrows; Ati += 1, Ai += ncols, i++) {\n pAt = Ati\n for (j = 0; j < ncols; pAt += nrows, j++) atd[pAt] = ad[Ai + j]\n }\n}\n\n// C = A * B\nexport function multiply (C: Matrix, A: Matrix, B: Matrix) {\n let i = 0\n let j = 0\n let k = 0\n let Ap = 0\n let pA = 0\n let pB = 0\n let _pB = 0\n let Cp = 0\n const ncols = A.cols\n const nrows = A.rows\n const mcols = B.cols\n const ad = A.data\n const bd = B.data\n const cd = C.data\n let sum = 0.0\n\n for (; i < nrows; Ap += ncols, i++) {\n for (_pB = 0, j = 0; j < mcols; Cp++, _pB++, j++) {\n pB = _pB\n pA = Ap\n sum = 0.0\n for (k = 0; k < ncols; pA++, pB += mcols, k++) {\n sum += ad[pA] * bd[pB]\n }\n cd[Cp] = sum\n }\n }\n}\n\n// C = A * B'\nexport function multiplyABt (C: Matrix, A: Matrix, B: Matrix) {\n let i = 0\n let j = 0\n let k = 0\n let Ap = 0\n let pA = 0\n let pB = 0\n let Cp = 0\n const ncols = A.cols\n const nrows = A.rows\n const mrows = B.rows\n const ad = A.data\n const bd = B.data\n const cd = C.data\n let sum = 0.0\n\n for (; i < nrows; Ap += ncols, i++) {\n for (pB = 0, j = 0; j < mrows; Cp++, j++) {\n pA = Ap\n sum = 0.0\n for (k = 0; k < ncols; pA++, pB++, k++) {\n sum += ad[pA] * bd[pB]\n }\n cd[Cp] = sum\n }\n }\n}\n\n// C = A' * B\nexport function multiplyAtB (C: Matrix, A: Matrix, B: Matrix) {\n let i = 0\n let j = 0\n let k = 0\n let Ap = 0\n let pA = 0\n let pB = 0\n let _pB = 0\n let Cp = 0\n const ncols = A.cols\n const nrows = A.rows\n const mcols = B.cols\n const ad = A.data\n const bd = B.data\n const cd = C.data\n let sum = 0.0\n\n for (; i < ncols; Ap++, i++) {\n for (_pB = 0, j = 0; j < mcols; Cp++, _pB++, j++) {\n pB = _pB\n pA = Ap\n sum = 0.0\n for (k = 0; k < nrows; pA += ncols, pB += mcols, k++) {\n sum += ad[pA] * bd[pB]\n }\n cd[Cp] = sum\n }\n }\n}\n\nexport function invert3x3 (from: Matrix, to: Matrix) {\n const A = from.data\n const invA = to.data\n const t1 = A[4]\n const t2 = A[8]\n const t4 = A[5]\n const t5 = A[7]\n const t8 = A[0]\n\n const t9 = t8 * t1\n const t11 = t8 * t4\n const t13 = A[3]\n const t14 = A[1]\n const t15 = t13 * t14\n const t17 = A[2]\n const t18 = t13 * t17\n const t20 = A[6]\n const t21 = t20 * t14\n const t23 = t20 * t17\n const t26 = 1.0 / (t9 * t2 - t11 * t5 - t15 * t2 + t18 * t5 + t21 * t4 - t23 * t1)\n invA[0] = (t1 * t2 - t4 * t5) * t26\n invA[1] = -(t14 * t2 - t17 * t5) * t26\n invA[2] = -(-t14 * t4 + t17 * t1) * t26\n invA[3] = -(t13 * t2 - t4 * t20) * t26\n invA[4] = (t8 * t2 - t23) * t26\n invA[5] = -(t11 - t18) * t26\n invA[6] = -(-t13 * t5 + t1 * t20) * t26\n invA[7] = -(t8 * t5 - t21) * t26\n invA[8] = (t9 - t15) * t26\n}\n\nexport function mat3x3determinant (M: Matrix) {\n const md = M.data\n return md[0] * md[4] * md[8] -\n md[0] * md[5] * md[7] -\n md[3] * md[1] * md[8] +\n md[3] * md[2] * md[7] +\n md[6] * md[1] * md[5] -\n md[6] * md[2] * md[4]\n}\n\n// C = A * B\nexport function multiply3x3 (C: Matrix, A: Matrix, B: Matrix) {\n const Cd = C.data\n const Ad = A.data\n const Bd = B.data\n const m10 = Ad[0]\n const m11 = Ad[1]\n const m12 = Ad[2]\n const m13 = Ad[3]\n const m14 = Ad[4]\n const m15 = Ad[5]\n const m16 = Ad[6]\n const m17 = Ad[7]\n const m18 = Ad[8]\n\n const m20 = Bd[0]\n const m21 = Bd[1]\n const m22 = Bd[2]\n const m23 = Bd[3]\n const m24 = Bd[4]\n const m25 = Bd[5]\n const m26 = Bd[6]\n const m27 = Bd[7]\n const m28 = Bd[8]\n\n Cd[0] = m10 * m20 + m11 * m23 + m12 * m26\n Cd[1] = m10 * m21 + m11 * m24 + m12 * m27\n Cd[2] = m10 * m22 + m11 * m25 + m12 * m28\n Cd[3] = m13 * m20 + m14 * m23 + m15 * m26\n Cd[4] = m13 * m21 + m14 * m24 + m15 * m27\n Cd[5] = m13 * m22 + m14 * m25 + m15 * m28\n Cd[6] = m16 * m20 + m17 * m23 + m18 * m26\n Cd[7] = m16 * m21 + m17 * m24 + m18 * m27\n Cd[8] = m16 * m22 + m17 * m25 + m18 * m28\n}\n\nexport function meanRows (A: Matrix) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n const mean = new Array(ncols)\n\n for (let j = 0; j < ncols; ++j) {\n mean[ j ] = 0.0\n }\n\n for (let i = 0, p = 0; i < nrows; ++i) {\n for (let j = 0; j < ncols; ++j, ++p) {\n mean[ j ] += Ad[ p ]\n }\n }\n\n for (let j = 0; j < ncols; ++j) {\n mean[ j ] /= nrows\n }\n\n return mean\n}\n\nexport function meanCols (A: Matrix) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n const mean = new Array(nrows)\n\n for (let j = 0; j < nrows; ++j) {\n mean[ j ] = 0.0\n }\n\n for (let i = 0, p = 0; i < ncols; ++i) {\n for (let j = 0; j < nrows; ++j, ++p) {\n mean[ j ] += Ad[ p ]\n }\n }\n\n for (let j = 0; j < nrows; ++j) {\n mean[ j ] /= ncols\n }\n\n return mean\n}\n\nexport function subRows (A: Matrix, row: number[]) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n\n for (let i = 0, p = 0; i < nrows; ++i) {\n for (let j = 0; j < ncols; ++j, ++p) {\n Ad[ p ] -= row[ j ]\n }\n }\n}\n\nexport function subCols (A: Matrix, col: number[]) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n\n for (let i = 0, p = 0; i < ncols; ++i) {\n for (let j = 0; j < nrows; ++j, ++p) {\n Ad[ p ] -= col[ j ]\n }\n }\n}\n\nexport function addRows (A: Matrix, row: number[]) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n\n for (let i = 0, p = 0; i < nrows; ++i) {\n for (let j = 0; j < ncols; ++j, ++p) {\n Ad[ p ] += row[ j ]\n }\n }\n}\n\nexport function addCols (A: Matrix, col: number[]) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n\n for (let i = 0, p = 0; i < ncols; ++i) {\n for (let j = 0; j < nrows; ++j, ++p) {\n Ad[ p ] += col[ j ]\n }\n }\n}\n\nexport function swap (A: NumberArray, i0: number, i1: number, t: number) {\n t = A[i0]\n A[i0] = A[i1]\n A[i1] = t\n}\n\nexport function hypot (a: number, b: number) {\n a = Math.abs(a)\n b = Math.abs(b)\n if (a > b) {\n b /= a\n return a * Math.sqrt(1.0 + b * b)\n }\n if (b > 0) {\n a /= b\n return b * Math.sqrt(1.0 + a * a)\n }\n return 0.0\n}\n\nconst EPSILON = 0.0000001192092896\nconst FLT_MIN = 1E-37\n\nexport function JacobiSVDImpl (At: NumberArray, astep: number, _W: NumberArray, Vt: NumberArray, vstep: number, m: number, n: number, n1: number) {\n const eps = EPSILON * 2.0\n const minval = FLT_MIN\n let i = 0\n let j = 0\n let k = 0\n let iter = 0\n const maxIter = Math.max(m, 30)\n let Ai = 0\n let Aj = 0\n let Vi = 0\n let Vj = 0\n let changed = 0\n let c = 0.0\n let s = 0.0\n let t = 0.0\n let t0 = 0.0\n let t1 = 0.0\n let sd = 0.0\n let beta = 0.0\n let gamma = 0.0\n let delta = 0.0\n let a = 0.0\n let p = 0.0\n let b = 0.0\n let seed = 0x1234\n let val = 0.0\n let val0 = 0.0\n let asum = 0.0\n\n const W = new Float64Array(n << 3)\n\n for (; i < n; i++) {\n for (k = 0, sd = 0; k < m; k++) {\n t = At[i * astep + k]\n sd += t * t\n }\n W[i] = sd\n\n if (Vt) {\n for (k = 0; k < n; k++) {\n Vt[i * vstep + k] = 0\n }\n Vt[i * vstep + i] = 1\n }\n }\n\n for (; iter < maxIter; iter++) {\n changed = 0\n\n for (i = 0; i < n - 1; i++) {\n for (j = i + 1; j < n; j++) {\n Ai = (i * astep) | 0\n Aj = (j * astep) | 0\n a = W[i]\n p = 0\n b = W[j]\n\n k = 2\n p += At[Ai] * At[Aj]\n p += At[Ai + 1] * At[Aj + 1]\n\n for (; k < m; k++) { p += At[Ai + k] * At[Aj + k] }\n\n if (Math.abs(p) <= eps * Math.sqrt(a * b)) continue\n\n p *= 2.0\n beta = a - b\n gamma = hypot(p, beta)\n if (beta < 0) {\n delta = (gamma - beta) * 0.5\n s = Math.sqrt(delta / gamma)\n c = (p / (gamma * s * 2.0))\n } else {\n c = Math.sqrt((gamma + beta) / (gamma * 2.0))\n s = (p / (gamma * c * 2.0))\n }\n\n a = 0.0\n b = 0.0\n\n k = 2 // unroll\n t0 = c * At[Ai] + s * At[Aj]\n t1 = -s * At[Ai] + c * At[Aj]\n At[Ai] = t0; At[Aj] = t1\n a += t0 * t0; b += t1 * t1\n\n t0 = c * At[Ai + 1] + s * At[Aj + 1]\n t1 = -s * At[Ai + 1] + c * At[Aj + 1]\n At[Ai + 1] = t0; At[Aj + 1] = t1\n a += t0 * t0; b += t1 * t1\n\n for (; k < m; k++) {\n t0 = c * At[Ai + k] + s * At[Aj + k]\n t1 = -s * At[Ai + k] + c * At[Aj + k]\n At[Ai + k] = t0; At[Aj + k] = t1\n\n a += t0 * t0; b += t1 * t1\n }\n\n W[i] = a\n W[j] = b\n\n changed = 1\n\n if (Vt) {\n Vi = (i * vstep) | 0\n Vj = (j * vstep) | 0\n\n k = 2\n t0 = c * Vt[Vi] + s * Vt[Vj]\n t1 = -s * Vt[Vi] + c * Vt[Vj]\n Vt[Vi] = t0; Vt[Vj] = t1\n\n t0 = c * Vt[Vi + 1] + s * Vt[Vj + 1]\n t1 = -s * Vt[Vi + 1] + c * Vt[Vj + 1]\n Vt[Vi + 1] = t0; Vt[Vj + 1] = t1\n\n for (; k < n; k++) {\n t0 = c * Vt[Vi + k] + s * Vt[Vj + k]\n t1 = -s * Vt[Vi + k] + c * Vt[Vj + k]\n Vt[Vi + k] = t0; Vt[Vj + k] = t1\n }\n }\n }\n }\n if (changed === 0) break\n }\n\n for (i = 0; i < n; i++) {\n for (k = 0, sd = 0; k < m; k++) {\n t = At[i * astep + k]\n sd += t * t\n }\n W[i] = Math.sqrt(sd)\n }\n\n for (i = 0; i < n - 1; i++) {\n j = i\n for (k = i + 1; k < n; k++) {\n if (W[j] < W[k]) { j = k }\n }\n if (i !== j) {\n swap(W, i, j, sd)\n if (Vt) {\n for (k = 0; k < m; k++) {\n swap(At, i * astep + k, j * astep + k, t)\n }\n\n for (k = 0; k < n; k++) {\n swap(Vt, i * vstep + k, j * vstep + k, t)\n }\n }\n }\n }\n\n for (i = 0; i < n; i++) {\n _W[i] = W[i]\n }\n\n if (!Vt) {\n return\n }\n\n for (i = 0; i < n1; i++) {\n sd = i < n ? W[i] : 0\n\n while (sd <= minval) {\n // if we got a zero singular value, then in order to get the corresponding left singular vector\n // we generate a random vector, project it to the previously computed left singular vectors,\n // subtract the projection and normalize the difference.\n val0 = (1.0 / m)\n for (k = 0; k < m; k++) {\n seed = (seed * 214013 + 2531011)\n val = (((seed >> 16) & 0x7fff) & 256) !== 0 ? val0 : -val0\n At[i * astep + k] = val\n }\n for (iter = 0; iter < 2; iter++) {\n for (j = 0; j < i; j++) {\n sd = 0\n for (k = 0; k < m; k++) {\n sd += At[i * astep + k] * At[j * astep + k]\n }\n asum = 0.0\n for (k = 0; k < m; k++) {\n t = (At[i * astep + k] - sd * At[j * astep + k])\n At[i * astep + k] = t\n asum += Math.abs(t)\n }\n asum = asum ? 1.0 / asum : 0\n for (k = 0; k < m; k++) {\n At[i * astep + k] *= asum\n }\n }\n }\n sd = 0\n for (k = 0; k < m; k++) {\n t = At[i * astep + k]\n sd += t * t\n }\n sd = Math.sqrt(sd)\n }\n\n s = (1.0 / sd)\n for (k = 0; k < m; k++) {\n At[i * astep + k] *= s\n }\n }\n}\n\nexport function svd (A: Matrix, W: Matrix, U: Matrix, V: Matrix) {\n let at = 0\n let i = 0\n const _m = A.rows\n const _n = A.cols\n let m = _m\n let n = _n\n\n if (m < n) {\n at = 1\n i = m\n m = n\n n = i\n }\n\n const amt = new Matrix(m, m)\n const wmt = new Matrix(1, n)\n const vmt = new Matrix(n, n)\n\n if (at === 0) {\n transpose(amt, A)\n } else {\n for (i = 0; i < _n * _m; i++) {\n amt.data[i] = A.data[i]\n }\n for (; i < n * m; i++) {\n amt.data[i] = 0\n }\n }\n\n JacobiSVDImpl(amt.data, m, wmt.data, vmt.data, n, m, n, m)\n\n if (W) {\n for (i = 0; i < n; i++) {\n W.data[i] = wmt.data[i]\n }\n for (; i < _n; i++) {\n W.data[i] = 0\n }\n }\n\n if (at === 0) {\n if (U) transpose(U, amt)\n if (V) transpose(V, vmt)\n } else {\n if (U) transpose(U, vmt)\n if (V) transpose(V, amt)\n }\n}\n\n//\n\nexport function m4new () {\n return new Float32Array([\n 1, 0, 0, 0,\n 0, 1, 0, 0,\n 0, 0, 1, 0,\n 0, 0, 0, 1\n ])\n}\n\nexport function m4set (out: Float32Array, n11: number, n12: number, n13: number, n14: number, n21: number, n22: number, n23: number, n24: number, n31: number, n32: number, n33: number, n34: number, n41: number, n42: number, n43: number, n44: number) {\n out[ 0 ] = n11; out[ 4 ] = n12; out[ 8 ] = n13; out[ 12 ] = n14\n out[ 1 ] = n21; out[ 5 ] = n22; out[ 9 ] = n23; out[ 13 ] = n24\n out[ 2 ] = n31; out[ 6 ] = n32; out[ 10 ] = n33; out[ 14 ] = n34\n out[ 3 ] = n41; out[ 7 ] = n42; out[ 11 ] = n43; out[ 15 ] = n44\n}\n\nexport function m4identity (out: Float32Array) {\n m4set(out,\n 1, 0, 0, 0,\n 0, 1, 0, 0,\n 0, 0, 1, 0,\n 0, 0, 0, 1\n )\n}\n(m4identity as any).__deps = [ m4set ]\n\nexport function m4multiply (out: Float32Array, a: Float32Array, b: Float32Array) {\n const a11 = a[ 0 ]\n const a12 = a[ 4 ]\n const a13 = a[ 8 ]\n const a14 = a[ 12 ]\n const a21 = a[ 1 ]\n const a22 = a[ 5 ]\n const a23 = a[ 9 ]\n const a24 = a[ 13 ]\n const a31 = a[ 2 ]\n const a32 = a[ 6 ]\n const a33 = a[ 10 ]\n const a34 = a[ 14 ]\n const a41 = a[ 3 ]\n const a42 = a[ 7 ]\n const a43 = a[ 11 ]\n const a44 = a[ 15 ]\n\n const b11 = b[ 0 ]\n const b12 = b[ 4 ]\n const b13 = b[ 8 ]\n const b14 = b[ 12 ]\n const b21 = b[ 1 ]\n const b22 = b[ 5 ]\n const b23 = b[ 9 ]\n const b24 = b[ 13 ]\n const b31 = b[ 2 ]\n const b32 = b[ 6 ]\n const b33 = b[ 10 ]\n const b34 = b[ 14 ]\n const b41 = b[ 3 ]\n const b42 = b[ 7 ]\n const b43 = b[ 11 ]\n const b44 = b[ 15 ]\n\n out[ 0 ] = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41\n out[ 4 ] = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42\n out[ 8 ] = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43\n out[ 12 ] = a11 * b14 + a12 * b24 + a13 * b34 + a14 * b44\n\n out[ 1 ] = a21 * b11 + a22 * b21 + a23 * b31 + a24 * b41\n out[ 5 ] = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42\n out[ 9 ] = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43\n out[ 13 ] = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44\n\n out[ 2 ] = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41\n out[ 6 ] = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42\n out[ 10 ] = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43\n out[ 14 ] = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44\n\n out[ 3 ] = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41\n out[ 7 ] = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42\n out[ 11 ] = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43\n out[ 15 ] = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44\n}\n\nexport function m4makeScale (out: Float32Array, x: number, y: number, z: number) {\n m4set(out,\n x, 0, 0, 0,\n 0, y, 0, 0,\n 0, 0, z, 0,\n 0, 0, 0, 1\n )\n}\n(m4makeScale as any).__deps = [ m4set ]\n\nexport function m4makeTranslation (out: Float32Array, x: number, y: number, z: number) {\n m4set(out,\n 1, 0, 0, x,\n 0, 1, 0, y,\n 0, 0, 1, z,\n 0, 0, 0, 1\n )\n}\n(m4makeTranslation as any).__deps = [ m4set ]\n\nexport function m4makeRotationY (out: Float32Array, theta: number) {\n const c = Math.cos(theta)\n const s = Math.sin(theta)\n m4set(out,\n c, 0, s, 0,\n 0, 1, 0, 0,\n -s, 0, c, 0,\n 0, 0, 0, 1\n )\n}\n(m4makeRotationY as any).__deps = [ m4set ]\n\n//\n\nexport function m3new () {\n return new Float32Array([\n 1, 0, 0,\n 0, 1, 0,\n 0, 0, 1\n ])\n}\n\nexport function m3makeNormal (out: Float32Array, m4: Float32Array) {\n const r0 = v3new([ m4[0], m4[1], m4[2] ])\n const r1 = v3new([ m4[4], m4[5], m4[6] ])\n const r2 = v3new([ m4[8], m4[9], m4[10] ])\n const cp = v3new()\n // [ r0 ] [ r1 x r2 ]\n // M3x3 = [ r1 ] N = [ r2 x r0 ]\n // [ r2 ] [ r0 x r1 ]\n v3cross(cp, r1, r2)\n out[ 0 ] = cp[ 0 ]\n out[ 1 ] = cp[ 1 ]\n out[ 2 ] = cp[ 2 ]\n v3cross(cp, r2, r0)\n out[ 3 ] = cp[ 0 ]\n out[ 4 ] = cp[ 1 ]\n out[ 5 ] = cp[ 2 ]\n v3cross(cp, r0, r1)\n out[ 6 ] = cp[ 0 ]\n out[ 7 ] = cp[ 1 ]\n out[ 8 ] = cp[ 2 ]\n}\n(m3makeNormal as any).__deps = [ v3new, v3cross ]\n","/**\n * @file Surface Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { degToRad } from '../math/math-utils'\nimport {\n m4new, m4multiply, m4makeTranslation, m4makeScale, m4makeRotationY\n} from '../math/matrix-utils'\nimport {\n v3addScalar, v3subScalar, v3divideScalar, v3multiplyScalar,\n v3floor, v3ceil, v3sub, v3negate,\n v3cross, v3fromArray, normalizeVector3array\n} from '../math/vector-utils'\nimport { NumberArray } from '../types'\n\nfunction laplacianSmooth (verts: Float32Array, faces: Float32Array, numiter: number, inflate: boolean) {\n // based on D. Xu, Y. Zhang (2009) Generating Triangulated Macromolecular\n // Surfaces by Euclidean Distance Transform. PLoS ONE 4(12): e8140.\n //\n // Permission to use, copy, modify, and distribute this program for\n // any purpose, with or without fee, is hereby granted, provided that\n // the notices on the head, the reference information, and this\n // copyright notice appear in all copies or substantial portions of\n // the Software. It is provided \"as is\" without express or implied\n // warranty.\n //\n // ported to JavaScript and adapted to NGL by Alexander Rose\n\n numiter = numiter || 1\n inflate = inflate || true\n\n const nv = verts.length / 3\n const nf = faces.length / 3\n let norms: Float32Array | undefined = undefined\n\n if (inflate) {\n norms = new Float32Array(nv * 3)\n }\n\n const tps = new Float32Array(nv * 3)\n\n let i\n const ndeg = 20\n const vertdeg = new Array(ndeg)\n\n for (i = 0; i < ndeg; ++i) {\n vertdeg[ i ] = new Uint32Array(nv)\n }\n\n for (i = 0; i < nv; ++i) {\n vertdeg[ 0 ][ i ] = 0\n }\n\n let j, jl\n let flagvert: boolean\n\n // for each face\n\n for (i = 0; i < nf; ++i) {\n var ao = i * 3\n var bo = i * 3 + 1\n var co = i * 3 + 2\n\n // vertex a\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ao] ]; j < jl; ++j) {\n if (faces[ bo ] === vertdeg[ j + 1 ][ faces[ ao ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ ao ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ ao ] ] ][ faces[ ao ] ] = faces[ bo ]\n }\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ ao ] ]; j < jl; ++j) {\n if (faces[ co ] === vertdeg[ j + 1 ][ faces[ ao ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ ao ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ ao ] ] ][ faces[ ao ] ] = faces[ co ]\n }\n\n // vertex b\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ bo ] ]; j < jl; ++j) {\n if (faces[ ao ] === vertdeg[ j + 1 ][ faces[ bo ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ bo ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ bo ] ] ][ faces[ bo ] ] = faces[ ao ]\n }\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ bo ] ]; j < jl; ++j) {\n if (faces[ co ] === vertdeg[ j + 1 ][ faces[ bo ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ bo ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ bo ] ] ][ faces[ bo ] ] = faces[ co ]\n }\n\n // vertex c\n\n flagvert = true\n for (j = 0; j < vertdeg[ 0 ][ faces[ co ] ]; ++j) {\n if (faces[ ao ] === vertdeg[ j + 1 ][ faces[ co ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ co ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ co ] ] ][ faces[ co ] ] = faces[ ao ]\n }\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ co ] ]; j < jl; ++j) {\n if (faces[ bo ] === vertdeg[ j + 1 ][ faces[ co ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ co ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ co ] ] ][ faces[ co ] ] = faces[ bo ]\n }\n }\n\n var wt = 1.0\n var wt2 = 0.5\n var i3, vi3, vdi, wtvi, wt2vi\n var ssign = -1\n var scaleFactor = 1\n var outwt = 0.75 / (scaleFactor + 3.5) // area-preserving\n\n // smoothing iterations\n\n for (var k = 0; k < numiter; ++k) {\n // for each vertex\n\n for (i = 0; i < nv; ++i) {\n i3 = i * 3\n vdi = vertdeg[ 0 ][ i ]\n\n if (vdi < 3) {\n tps[ i3 ] = verts[ i3 ]\n tps[ i3 + 1 ] = verts[ i3 + 1 ]\n tps[ i3 + 2 ] = verts[ i3 + 2 ]\n } else if (vdi === 3 || vdi === 4) {\n tps[ i3 ] = 0\n tps[ i3 + 1 ] = 0\n tps[ i3 + 2 ] = 0\n\n for (j = 0; j < vdi; ++j) {\n vi3 = vertdeg[ j + 1 ][ i ] * 3\n tps[ i3 ] += verts[ vi3 ]\n tps[ i3 + 1 ] += verts[ vi3 + 1 ]\n tps[ i3 + 2 ] += verts[ vi3 + 2 ]\n }\n\n tps[ i3 ] += wt2 * verts[ i3 ]\n tps[ i3 + 1 ] += wt2 * verts[ i3 + 1 ]\n tps[ i3 + 2 ] += wt2 * verts[ i3 + 2 ]\n\n wt2vi = wt2 + vdi\n tps[ i3 ] /= wt2vi\n tps[ i3 + 1 ] /= wt2vi\n tps[ i3 + 2 ] /= wt2vi\n } else {\n tps[ i3 ] = 0\n tps[ i3 + 1 ] = 0\n tps[ i3 + 2 ] = 0\n\n for (j = 0; j < vdi; ++j) {\n vi3 = vertdeg[ j + 1 ][ i ] * 3\n tps[ i3 ] += verts[ vi3 ]\n tps[ i3 + 1 ] += verts[ vi3 + 1 ]\n tps[ i3 + 2 ] += verts[ vi3 + 2 ]\n }\n\n tps[ i3 ] += wt * verts[ i3 ]\n tps[ i3 + 1 ] += wt * verts[ i3 + 1 ]\n tps[ i3 + 2 ] += wt * verts[ i3 + 2 ]\n\n wtvi = wt + vdi\n tps[ i3 ] /= wtvi\n tps[ i3 + 1 ] /= wtvi\n tps[ i3 + 2 ] /= wtvi\n }\n }\n\n verts.set(tps) // copy smoothed positions\n\n if (inflate) {\n computeVertexNormals(verts, faces, norms)\n var nv3 = nv * 3\n\n for (i3 = 0; i3 < nv3; i3 += 3) {\n // if(verts[i].inout) ssign=1;\n // else ssign=-1;\n\n verts[ i3 ] += ssign * outwt * norms![ i3 ]\n verts[ i3 + 1 ] += ssign * outwt * norms![ i3 + 1 ]\n verts[ i3 + 2 ] += ssign * outwt * norms![ i3 + 2 ]\n }\n }\n }\n}\nObject.assign(laplacianSmooth, {__deps: [ computeVertexNormals ]})\n\nfunction computeVertexNormals (position: Float32Array, index?: NumberArray, normal?: Float32Array) {\n var i, il\n\n if (normal === undefined) {\n normal = new Float32Array(position.length)\n } else {\n // reset existing normals to zero\n for (i = 0, il = normal.length; i < il; i++) {\n normal[ i ] = 0\n }\n }\n\n var a = new Float32Array(3)\n var b = new Float32Array(3)\n var c = new Float32Array(3)\n var cb = new Float32Array(3)\n var ab = new Float32Array(3)\n\n if (index) {\n // indexed elements\n for (i = 0, il = index.length; i < il; i += 3) {\n var ai = index[ i ] * 3\n var bi = index[ i + 1 ] * 3\n var ci = index[ i + 2 ] * 3\n\n v3fromArray(a, position, ai)\n v3fromArray(b, position, bi)\n v3fromArray(c, position, ci)\n\n v3sub(cb, c, b)\n v3sub(ab, a, b)\n v3cross(cb, cb, ab)\n\n normal[ ai ] += cb[ 0 ]\n normal[ ai + 1 ] += cb[ 1 ]\n normal[ ai + 2 ] += cb[ 2 ]\n\n normal[ bi ] += cb[ 0 ]\n normal[ bi + 1 ] += cb[ 1 ]\n normal[ bi + 2 ] += cb[ 2 ]\n\n normal[ ci ] += cb[ 0 ]\n normal[ ci + 1 ] += cb[ 1 ]\n normal[ ci + 2 ] += cb[ 2 ]\n }\n } else {\n // non-indexed elements (unconnected triangle soup)\n for (i = 0, il = position.length; i < il; i += 9) {\n v3fromArray(a, position, i)\n v3fromArray(b, position, i + 3)\n v3fromArray(c, position, i + 6)\n\n v3sub(cb, c, b)\n v3sub(ab, a, b)\n v3cross(cb, cb, ab)\n\n normal[ i ] = cb[ 0 ]\n normal[ i + 1 ] = cb[ 1 ]\n normal[ i + 2 ] = cb[ 2 ]\n\n normal[ i + 3 ] = cb[ 0 ]\n normal[ i + 4 ] = cb[ 1 ]\n normal[ i + 5 ] = cb[ 2 ]\n\n normal[ i + 6 ] = cb[ 0 ]\n normal[ i + 7 ] = cb[ 1 ]\n normal[ i + 8 ] = cb[ 2 ]\n }\n }\n\n normalizeVector3array(normal)\n\n return normal\n}\nObject.assign(computeVertexNormals, {__deps: [\n v3sub, v3cross, v3fromArray, normalizeVector3array\n]})\n\nfunction getRadiusDict (radiusList: number[]) {\n var radiusDict: {[k: number]: boolean} = {}\n for (var i = 0, il = radiusList.length; i < il; ++i) {\n radiusDict[ radiusList[ i ] ] = true\n }\n return radiusDict\n}\n\nfunction getSurfaceGrid (min: Float32Array, max: Float32Array, maxRadius: number, scaleFactor: number, extraMargin: number) {\n // need margin to avoid boundary/round off effects\n var margin = (1 / scaleFactor) * 3\n margin += maxRadius\n\n v3subScalar(min, min, extraMargin + margin)\n v3addScalar(max, max, extraMargin + margin)\n\n v3multiplyScalar(min, min, scaleFactor)\n v3floor(min, min)\n v3divideScalar(min, min, scaleFactor)\n\n v3multiplyScalar(max, max, scaleFactor)\n v3ceil(max, max)\n v3divideScalar(max, max, scaleFactor)\n\n var dim = new Float32Array(3)\n v3sub(dim, max, min)\n v3multiplyScalar(dim, dim, scaleFactor)\n v3ceil(dim, dim)\n v3addScalar(dim, dim, 1)\n\n var maxSize = Math.pow(10, 6) * 256\n var tmpSize = dim[ 0 ] * dim[ 1 ] * dim[ 2 ] * 3\n\n if (maxSize <= tmpSize) {\n scaleFactor *= Math.pow(maxSize / tmpSize, 1 / 3)\n\n v3multiplyScalar(min, min, scaleFactor)\n v3floor(min, min)\n v3divideScalar(min, min, scaleFactor)\n\n v3multiplyScalar(max, max, scaleFactor)\n v3ceil(max, max)\n v3divideScalar(max, max, scaleFactor)\n\n v3sub(dim, max, min)\n v3multiplyScalar(dim, dim, scaleFactor)\n v3ceil(dim, dim)\n v3addScalar(dim, dim, 1)\n }\n\n var tran = new Float32Array(min)\n v3negate(tran, tran)\n\n // coordinate transformation matrix\n var matrix = m4new()\n var mroty = m4new()\n m4makeRotationY(mroty, degToRad(90))\n m4multiply(matrix, matrix, mroty)\n\n var mscale = m4new()\n m4makeScale(\n mscale,\n -1 / scaleFactor,\n 1 / scaleFactor,\n 1 / scaleFactor\n )\n m4multiply(matrix, matrix, mscale)\n\n var mtrans = m4new()\n m4makeTranslation(\n mtrans,\n -scaleFactor * tran[2],\n -scaleFactor * tran[1],\n -scaleFactor * tran[0]\n )\n m4multiply(matrix, matrix, mtrans)\n\n return {\n dim: dim,\n tran: tran,\n matrix: matrix,\n scaleFactor: scaleFactor\n }\n}\nObject.assign(getSurfaceGrid, {__deps: [\n degToRad,\n v3subScalar, v3addScalar, v3divideScalar, v3multiplyScalar,\n v3floor, v3ceil, v3sub, v3negate,\n m4new, m4multiply, m4makeTranslation, m4makeScale, m4makeRotationY\n]})\n\nexport {\n laplacianSmooth,\n computeVertexNormals,\n getRadiusDict,\n getSurfaceGrid\n}\n","/**\n * @file Surface\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3, Geometry, BufferGeometry, Group, Color } from 'three'\n\nimport { Debug, Log, ColormakerRegistry } from '../globals'\nimport { getUintArray } from '../utils'\nimport { AtomPicker, SurfacePicker } from '../utils/picker'\nimport { uniformArray, uniformArray3, serialArray } from '../math/array-utils'\nimport Selection from '../selection/selection'\nimport { ColormakerParameters } from '../color/colormaker';\nimport { Structure, Volume } from '../ngl';\n\nexport interface SurfaceData {\n position: Float32Array\n index: Uint32Array|Uint16Array|undefined\n normal: Float32Array\n color: Float32Array\n atomindex: Int32Array\n contour: boolean\n}\n/**\n * Surface\n */\nclass Surface {\n name: string\n path: string\n position: Float32Array\n index: Uint32Array|Uint16Array|undefined\n normal: Float32Array|undefined\n color: Float32Array|undefined\n atomindex: Int32Array|undefined\n contour: boolean\n center: Vector3\n boundingBox: Box3\n size: number\n info: {\n type?: string\n probeRadius?: number\n scaleFactor?: number\n smooth?: number\n cutoff?: number\n isolevel?: number\n volume?: Volume\n }\n\n /**\n * @param {String} name - surface name\n * @param {String} path - source path\n * @param {Object} data - surface data\n * @param {Float32Array} data.position - surface positions\n * @param {Int32Array} data.index - surface indices\n * @param {Float32Array} data.normal - surface normals\n * @param {Float32Array} data.color - surface colors\n * @param {Int32Array} data.atomindex - atom indices\n * @param {boolean} data.contour - contour mode flag\n */\n constructor (name: string, path: string, data?: SurfaceData) {\n this.name = name || ''\n this.path = path || ''\n this.info = {}\n\n this.center = new Vector3()\n this.boundingBox = new Box3()\n\n if (data instanceof Geometry ||\n data instanceof BufferGeometry ||\n data instanceof Group\n ) {\n // to be removed\n this.fromGeometry(data)\n } else if (data) {\n this.set(\n data.position,\n data.index,\n data.normal,\n data.color,\n data.atomindex,\n data.contour\n )\n\n this.boundingBox.setFromArray(data.position)\n this.boundingBox.getCenter(this.center)\n }\n }\n\n get type () { return 'Surface' }\n\n /**\n * set surface data\n * @param {Float32Array} position - surface positions\n * @param {Int32Array} index - surface indices\n * @param {Float32Array} normal - surface normals\n * @param {Float32Array} color - surface colors\n * @param {Int32Array} atomindex - atom indices\n * @param {boolean} contour - contour mode flag\n * @return {undefined}\n */\n set (position: Float32Array,\n index: Uint32Array|Uint16Array|undefined,\n normal: Float32Array|undefined,\n color: Float32Array|undefined,\n atomindex: Int32Array|undefined,\n contour: boolean = false) {\n /**\n * @type {Float32Array}\n */\n this.position = position\n /**\n * @type {Uint32Array|Uint16Array|undefined}\n */\n this.index = index\n /**\n * @type {Float32Array|undefined}\n */\n this.normal = normal\n /**\n * @type {Float32Array|undefined}\n */\n this.color = color\n /**\n * @type {Int32Array|undefined}\n */\n this.atomindex = atomindex\n\n this.size = position.length / 3\n this.contour = contour\n }\n\n fromGeometry (geometry: Geometry|BufferGeometry|Group) {\n if (Debug) Log.time('GeometrySurface.fromGeometry')\n\n let geo\n\n if (geometry instanceof Geometry) {\n geometry.computeVertexNormals(true)\n geo = new BufferGeometry().fromGeometry(geometry)\n } else if (geometry instanceof BufferGeometry) {\n geo = geometry\n } else {\n geo = (geometry as any)[ 0 ]\n }\n\n if (!geo.boundingBox) geo.computeBoundingBox()\n\n this.boundingBox.copy(geo.boundingBox)\n this.boundingBox.getCenter(this.center)\n\n let position, color, index, normal\n\n if (geo instanceof BufferGeometry) {\n const attr = geo.attributes\n const an = (attr as any).normal ? (attr as any).normal.array : false\n\n // assume there are no normals if the first is zero\n if (!an || (an[ 0 ] === 0 && an[ 1 ] === 0 && an[ 2 ] === 0)) {\n geo.computeVertexNormals()\n }\n\n position = (attr).position.array\n index = (attr).index ? (attr).index.array : null\n normal = (attr).normal.array\n }\n\n this.set(position, index, normal, color, undefined)\n\n if (Debug) Log.timeEnd('GeometrySurface.setGeometry')\n }\n\n getPosition () {\n return this.position\n }\n\n getColor (params: ColormakerParameters&{ scheme: string}) {\n const p = params || {}\n p.surface = this\n\n const n = this.size\n const array = new Float32Array(n * 3)\n const colormaker = ColormakerRegistry.getScheme(p)\n\n if (colormaker.volumeColor || p.scheme === 'random') {\n for (let i = 0; i < n; ++i) {\n colormaker.volumeColorToArray(i, array, i * 3)\n }\n } else if (colormaker.positionColor) {\n const v = new Vector3()\n const pos = this.position\n\n for (let i = 0; i < n; ++i) {\n var i3 = i * 3\n v.set(pos[ i3 ], pos[ i3 + 1 ], pos[ i3 + 2 ])\n colormaker.positionColorToArray(v, array, i3)\n }\n } else if (colormaker.atomColor && this.atomindex) {\n const atomProxy = p.structure!.getAtomProxy()\n const atomindex = this.atomindex\n\n for (let i = 0; i < n; ++i) {\n atomProxy.index = atomindex[ i ]\n colormaker.atomColorToArray(atomProxy, array, i * 3)\n }\n } else {\n const tc = new Color(p.value)\n uniformArray3(n, tc.r, tc.g, tc.b, array)\n }\n\n return array\n }\n\n getPicking (structure?: Structure) {\n if (this.atomindex && structure) {\n return new AtomPicker(this.atomindex as any, structure)\n } else {\n return new SurfacePicker(serialArray(this.size), this)\n }\n }\n\n getNormal () {\n return this.normal\n }\n\n getSize (size: number, scale: number) {\n return uniformArray(this.size, size * scale)\n }\n\n getIndex () {\n return this.index\n }\n\n getFilteredIndex (sele: string, structure: Structure) {\n if (sele && this.atomindex) {\n const selection = new Selection(sele)\n const atomSet = structure.getAtomSet(selection)\n const filteredIndex = []\n\n const atomindex = this.atomindex\n const index = this.index\n const n = index!.length\n const elementSize = this.contour ? 2 : 3\n\n let j = 0\n\n for (let i = 0; i < n; i += elementSize) {\n let include = true\n\n for (let a = 0; a < elementSize; a++) {\n const idx = index![ i + a ]\n const ai = atomindex[ idx ]\n if (!atomSet.get(ai)) {\n include = false\n break\n }\n }\n\n if (!include) { continue }\n\n for (let a = 0; a < elementSize; a++, j++) {\n filteredIndex[ j ] = index![ i + a ]\n }\n }\n\n return getUintArray(filteredIndex, this.position.length / 3)\n } else {\n return this.index\n }\n }\n\n getAtomindex () {\n return this.atomindex\n }\n\n dispose () {\n\n //\n\n }\n}\n\nexport default Surface\n","/**\n * @file Volume\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3, Matrix3, Matrix4 } from 'three'\n\nimport { WorkerRegistry, ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport WorkerPool from '../worker/worker-pool'\nimport { VolumePicker } from '../utils/picker'\nimport {\n uniformArray, serialArray,\n arrayMin, arrayMax, arraySum, arrayMean, arrayRms\n} from '../math/array-utils'\nimport MarchingCubes from './marching-cubes'\nimport { laplacianSmooth, computeVertexNormals } from './surface-utils'\nimport {\n applyMatrix4toVector3array, applyMatrix3toVector3array\n} from '../math/vector-utils'\nimport { m3new, m3makeNormal } from '../math/matrix-utils'\nimport Surface from './surface'\nimport { NumberArray } from '../types';\nimport { ColormakerParameters } from '../color/colormaker';\n\nexport interface VolumeSurface {\n new (data: NumberArray, nx: number, ny: number, nz: number, atomindex: NumberArray): void\n getSurface: (isolevel: number, smooth: boolean|number, box: number[][]|undefined, matrix: Float32Array, contour: boolean, wrap?: boolean) => {\n position: Float32Array\n normal: undefined|Float32Array\n index: Uint32Array|Uint16Array\n atomindex: Int32Array|undefined\n contour: boolean\n }\n}\nexport function VolumeSurface (this: VolumeSurface,data: NumberArray, nx: number, ny: number, nz: number, atomindex: NumberArray) {\n var mc = new (MarchingCubes as any)(data, nx, ny, nz, atomindex) as MarchingCubes\n\n function getSurface (isolevel: number, smooth: boolean|number, box: number[][]|undefined, matrix: Float32Array, contour: boolean, wrap: boolean = false) {\n const sd = mc.triangulate(isolevel, smooth as boolean, box, contour, wrap)\n if (smooth && !contour) {\n laplacianSmooth(sd.position, sd.index as any, smooth as number, true)\n sd.normal = computeVertexNormals(sd.position, sd.index as any)\n }\n if (matrix) {\n applyMatrix4toVector3array(matrix, sd.position)\n if (sd.normal) {\n const normalMatrix = m3new()\n m3makeNormal(normalMatrix, matrix)\n applyMatrix3toVector3array(normalMatrix, sd.normal)\n }\n }\n return sd\n }\n\n this.getSurface = getSurface\n}\nObject.assign(VolumeSurface, {__deps: [\n laplacianSmooth, computeVertexNormals, MarchingCubes,\n applyMatrix4toVector3array, applyMatrix3toVector3array,\n m3new, m3makeNormal\n]})\n\nWorkerRegistry.add('surf', function func (e: any, callback: (data: any, transferList: any) => void) {\n const a = e.data.args\n const p = e.data.params\n if (a) {\n /* global self */\n (self as any).volsurf = new (VolumeSurface as any)(a[0], a[1], a[2], a[3], a[4]) as VolumeSurface\n }\n if (p) {\n const sd = ((self as any).volsurf as VolumeSurface).getSurface(\n p.isolevel, p.smooth, p.box, p.matrix, p.contour, p.wrap\n )\n const transferList = [ sd.position.buffer, sd.index.buffer ]\n if (sd.normal) transferList.push(sd.normal.buffer)\n if (sd.atomindex) transferList.push(sd.atomindex.buffer)\n const data = {\n sd: sd,\n p: p\n }\n callback(data, transferList)\n }\n}, [ VolumeSurface ])\n\nexport type VolumeSize = 'value'|'abs-value'|'value-min'|'deviation'\n/**\n * Volume\n */\nclass Volume {\n name: string\n path: string\n\n matrix: Matrix4\n normalMatrix: Matrix3\n inverseMatrix: Matrix4\n center: Vector3\n boundingBox: Box3\n\n nx: number\n ny: number\n nz: number\n data: Float32Array\n\n worker: Worker\n workerPool: WorkerPool\n _position: Float32Array\n _min: number|undefined\n _max: number|undefined\n _mean: number|undefined\n _rms: number|undefined\n _sum: number|undefined\n __box: Box3|undefined\n\n atomindex: Int32Array|undefined\n volsurf: VolumeSurface|undefined\n header: any\n /**\n * Make Volume instance\n * @param {String} name - volume name\n * @param {String} path - source path\n * @param {Float32array} data - volume 3d grid\n * @param {Integer} nx - x dimension of the 3d volume\n * @param {Integer} ny - y dimension of the 3d volume\n * @param {Integer} nz - z dimension of the 3d volume\n * @param {Int32Array} atomindex - atom indices corresponding to the cells in the 3d grid\n */\n constructor (name: string, path: string, data?: Float32Array, nx?: number, ny?: number, nz?: number, atomindex?: Int32Array) {\n this.name = name\n this.path = path\n\n this.matrix = new Matrix4()\n this.normalMatrix = new Matrix3()\n this.inverseMatrix = new Matrix4()\n this.center = new Vector3()\n this.boundingBox = new Box3()\n\n this.setData(data, nx, ny, nz, atomindex)\n }\n\n get type () { return 'Volume' }\n\n /**\n * set volume data\n * @param {Float32array} data - volume 3d grid\n * @param {Integer} nx - x dimension of the 3d volume\n * @param {Integer} ny - y dimension of the 3d volume\n * @param {Integer} nz - z dimension of the 3d volume\n * @param {Int32Array} atomindex - atom indices corresponding to the cells in the 3d grid\n * @return {undefined}\n */\n setData (data?: Float32Array, nx?: number, ny?: number, nz?: number, atomindex?: Int32Array) {\n this.nx = nx || 1\n this.ny = ny || 1\n this.nz = nz || 1\n\n this.data = data || new Float32Array(1)\n this.setAtomindex(atomindex)\n\n this._position = new Float32Array()\n\n delete this._min\n delete this._max\n delete this._mean\n delete this._rms\n\n if (this.worker) this.worker.terminate()\n }\n\n /**\n * Set statistics, which can be different from the data in this volume,\n * if this volume is a slice of a bigger volume\n * @param {Number|undefined} min - minimum value of the whole data set\n * @param {Number|undefined} max - maximum value of the whole data set\n * @param {Number|undefined} mean - average value of the whole data set\n * @param {Number|undefined} rms - sigma value of the whole data set\n */\n setStats (min: number|undefined, max: number|undefined, mean: number|undefined, rms: number|undefined) {\n this._min = min\n this._max = max\n this._mean = mean\n this._rms = rms\n }\n\n /**\n * set transformation matrix\n * @param {Matrix4} matrix - 4x4 transformation matrix\n * @return {undefined}\n */\n setMatrix (matrix: Matrix4) {\n this.matrix.copy(matrix)\n\n const bb = this.boundingBox\n const v = this.center // temporary re-purposing\n\n const x = this.nx - 1\n const y = this.ny - 1\n const z = this.nz - 1\n\n bb.makeEmpty()\n\n bb.expandByPoint(v.set(x, y, z))\n bb.expandByPoint(v.set(x, y, 0))\n bb.expandByPoint(v.set(x, 0, z))\n bb.expandByPoint(v.set(x, 0, 0))\n bb.expandByPoint(v.set(0, y, z))\n bb.expandByPoint(v.set(0, 0, z))\n bb.expandByPoint(v.set(0, y, 0))\n bb.expandByPoint(v.set(0, 0, 0))\n\n bb.applyMatrix4(this.matrix)\n bb.getCenter(this.center)\n\n // make normal matrix\n\n const me = this.matrix.elements\n const r0 = new Vector3(me[0], me[1], me[2])\n const r1 = new Vector3(me[4], me[5], me[6])\n const r2 = new Vector3(me[8], me[9], me[10])\n const cp = new Vector3()\n // [ r0 ] [ r1 x r2 ]\n // M3x3 = [ r1 ] N = [ r2 x r0 ]\n // [ r2 ] [ r0 x r1 ]\n const ne = this.normalMatrix.elements\n cp.crossVectors(r1, r2)\n ne[ 0 ] = cp.x\n ne[ 1 ] = cp.y\n ne[ 2 ] = cp.z\n cp.crossVectors(r2, r0)\n ne[ 3 ] = cp.x\n ne[ 4 ] = cp.y\n ne[ 5 ] = cp.z\n cp.crossVectors(r0, r1)\n ne[ 6 ] = cp.x\n ne[ 7 ] = cp.y\n ne[ 8 ] = cp.z\n\n this.inverseMatrix.getInverse(this.matrix)\n }\n\n /**\n * set atom indices\n * @param {Int32Array} atomindex - atom indices corresponding to the cells in the 3d grid\n * @return {undefined}\n */\n setAtomindex (atomindex?: Int32Array) {\n this.atomindex = atomindex\n }\n\n getBox (center: Vector3, size: number, target: Box3) {\n if (!target) target = new Box3()\n\n target.set(center, center)\n target.expandByScalar(size)\n target.applyMatrix4(this.inverseMatrix)\n\n target.min.round()\n target.max.round()\n\n return target\n }\n\n _getBox (center: Vector3|undefined, size: number) {\n if (!center || !size) return\n\n if (!this.__box) this.__box = new Box3()\n const box = this.getBox(center, size, this.__box)\n return [ box.min.toArray(), box.max.toArray() ]\n }\n\n _makeSurface (sd: any, isolevel: number, smooth: number) {\n const name = this.name + '@' + isolevel.toPrecision(2)\n const surface = new Surface(name, '', sd)\n surface.info.isolevel = isolevel\n surface.info.smooth = smooth\n surface.info.volume = this\n\n return surface\n }\n\n getSurface (isolevel: number, smooth: number, center: Vector3, size: number, contour: boolean, wrap: boolean = false) {\n isolevel = isNaN(isolevel) ? this.getValueForSigma(2) : isolevel\n smooth = defaults(smooth, 0)\n\n //\n\n if (this.volsurf === undefined) {\n this.volsurf = new (VolumeSurface as any)(\n this.data, this.nx, this.ny, this.nz, this.atomindex\n ) as VolumeSurface\n }\n\n const box = this._getBox(center, size)\n const sd = this.volsurf.getSurface(\n isolevel, smooth, box!, this.matrix.elements as unknown as Float32Array, contour, wrap\n )\n\n return this._makeSurface(sd, isolevel, smooth)\n }\n\n getSurfaceWorker (isolevel: number, smooth: number, center: Vector3, size: number, contour: boolean, wrap: boolean, callback: (s: Surface) => void) {\n isolevel = isNaN(isolevel) ? this.getValueForSigma(2) : isolevel\n smooth = smooth || 0\n\n //\n\n if (window.hasOwnProperty('Worker')) {\n if (this.workerPool === undefined) {\n this.workerPool = new WorkerPool('surf', 2)\n }\n\n const msg = {}\n const worker = this.workerPool.getNextWorker()\n\n if (worker!.postCount === 0) {\n Object.assign(msg, {\n args: [\n this.data, this.nx, this.ny, this.nz, this.atomindex\n ]\n })\n }\n\n Object.assign(msg, {\n params: {\n isolevel: isolevel,\n smooth: smooth,\n box: this._getBox(center, size),\n matrix: this.matrix.elements,\n contour: contour,\n wrap: wrap\n }\n })\n\n worker!.post(msg, undefined,\n (e: any) => {\n const sd = e.data.sd\n const p = e.data.p\n callback(this._makeSurface(sd, p.isolevel, p.smooth))\n },\n (e : string) => {\n console.warn(\n 'Volume.getSurfaceWorker error - trying without worker', e\n )\n const surface = this.getSurface(isolevel, smooth, center, size, contour, wrap)\n callback(surface)\n }\n )\n } else {\n const surface = this.getSurface(isolevel, smooth, center, size, contour, wrap)\n callback(surface)\n }\n }\n\n getValueForSigma (sigma: number) {\n return this.mean + defaults(sigma, 2) * this.rms\n }\n\n getSigmaForValue (value: number) {\n return (defaults(value, 0) - this.mean) / this.rms\n }\n\n get position () {\n if (!this._position) {\n const nz = this.nz\n const ny = this.ny\n const nx = this.nx\n const position = new Float32Array(nx * ny * nz * 3)\n\n let p = 0\n for (let z = 0; z < nz; ++z) {\n for (let y = 0; y < ny; ++y) {\n for (let x = 0; x < nx; ++x) {\n position[ p + 0 ] = x\n position[ p + 1 ] = y\n position[ p + 2 ] = z\n p += 3\n }\n }\n }\n\n applyMatrix4toVector3array(this.matrix.elements as unknown as Float32Array, position)\n this._position = position\n }\n\n return this._position\n }\n\n getDataAtomindex () {\n return this.atomindex\n }\n\n getDataPosition () {\n return this.position\n }\n\n getDataColor (params: ColormakerParameters & {scheme: string}) {\n const p = params || {}\n p.volume = this\n p.scale = p.scale || 'Spectral'\n p.domain = p.domain || [ this.min, this.max ]\n\n const colormaker = ColormakerRegistry.getScheme(p)\n\n const n = this.position.length / 3\n const array = new Float32Array(n * 3)\n\n // var atoms = p.structure.atoms;\n // var atomindex = this.atomindex;\n\n for (let i = 0; i < n; ++i) {\n colormaker.volumeColorToArray(i, array, i * 3)\n // a = atoms[ atomindex[ i ] ];\n // if( a ) colormaker.atomColorToArray( a, array, i * 3 );\n }\n\n return array\n }\n\n getDataPicking () {\n const picking = serialArray(this.position.length / 3)\n return new VolumePicker(picking, this)\n }\n\n getDataSize (size: VolumeSize|number, scale: number) {\n const data = this.data\n const n = this.position.length / 3\n let array\n\n switch (size) {\n case 'value':\n array = new Float32Array(data)\n break\n\n case 'abs-value':\n array = new Float32Array(data)\n for (let i = 0; i < n; ++i) {\n array[ i ] = Math.abs(array[ i ])\n }\n break\n\n case 'value-min': {\n array = new Float32Array(data)\n const min = this.min\n for (let i = 0; i < n; ++i) {\n array[ i ] -= min\n }\n break\n }\n\n case 'deviation':\n array = new Float32Array(data)\n break\n\n default:\n array = uniformArray(n, size)\n break\n }\n\n if (scale !== 1.0) {\n for (let i = 0; i < n; ++i) {\n array[ i ] *= scale\n }\n }\n\n return array\n }\n\n get min () {\n if (this._min === undefined) {\n this._min = arrayMin(this.data)\n }\n return this._min\n }\n\n get max () {\n if (this._max === undefined) {\n this._max = arrayMax(this.data)\n }\n return this._max\n }\n\n get sum () {\n if (this._sum === undefined) {\n this._sum = arraySum(this.data)\n }\n return this._sum\n }\n\n get mean () {\n if (this._mean === undefined) {\n this._mean = arrayMean(this.data)\n }\n return this._mean\n }\n\n get rms () {\n if (this._rms === undefined) {\n this._rms = arrayRms(this.data)\n }\n return this._rms\n }\n\n clone () {\n const vol = new Volume(\n this.name,\n this.path,\n\n this.data,\n\n this.nx,\n this.ny,\n this.nz,\n\n this.atomindex\n )\n\n vol.matrix.copy(this.matrix)\n vol.header = Object.assign({}, this.header)\n\n return vol\n }\n\n dispose () {\n if (this.workerPool) this.workerPool.terminate()\n }\n}\n\nexport default Volume\n","/**\n * @file Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport {\n Color, Vector3, Matrix4,\n FrontSide, BackSide, DoubleSide,\n // VertexColors,\n NoBlending,\n BufferGeometry, BufferAttribute,\n UniformsUtils, UniformsLib, Uniform,\n Group, LineSegments, Points, Mesh, Object3D,\n ShaderMaterial\n} from 'three'\n\nimport { Log } from '../globals'\nimport { createParams, getTypedArray, getUintArray } from '../utils'\nimport { GenericColor, NumberArray } from '../types'\nimport { getShader, ShaderDefines } from '../shader/shader-utils'\nimport { serialArray } from '../math/array-utils'\nimport { Picker } from '../utils/picker'\n\nexport type BufferSide = 'front'|'back'|'double'\n\nfunction getThreeSide (side: BufferSide) {\n if (side === 'front') {\n return FrontSide\n } else if (side === 'back') {\n return BackSide\n } else if (side === 'double') {\n return DoubleSide\n } else {\n return DoubleSide\n }\n}\n\nconst itemSize = {\n 'f': 1, 'v2': 2, 'v3': 3, 'c': 3\n}\n\nfunction setObjectMatrix (object: Object3D, matrix: Matrix4) {\n object.matrix.copy(matrix)\n object.matrix.decompose(object.position, object.quaternion, object.scale)\n object.matrixWorldNeedsUpdate = true\n}\n\nexport type BufferTypes = 'picking'|'background'\nexport type BufferMaterials = 'material'|'wireframeMaterial'|'pickingMaterial'\n\nexport interface _BufferAttribute {\n type: 'f'|'v2'|'v3'|'c'\n value?: NumberArray\n}\n\nexport type Uniforms = { [k: string]: Uniform|{ value: any } }\n\nexport const BufferDefaultParameters = {\n opaqueBack: false,\n side: 'double' as BufferSide, // which triangle sides to render\n opacity: 1.0, // translucency: 1 is fully opaque, 0 is fully transparent\n depthWrite: true,\n clipNear: 0, // position of camera near/front clipping plane in percent of scene bounding box\n clipRadius: 0,\n clipCenter: new Vector3(),\n flatShaded: false, // render flat shaded\n wireframe: false, // render as wireframe\n roughness: 0.4, // how rough the material is, between 0 and 1\n metalness: 0.0, // how metallic the material is, between 0 and 1\n diffuse: 0xffffff, // diffuse color for lighting\n diffuseInterior: false,\n useInteriorColor: false, // render back-side with interior color\n interiorColor: 0xdddddd, // interior color\n interiorDarkening: 0, // interior darkening factor\n forceTransparent: false, // force the material to allow transparency\n matrix: new Matrix4(), // additional transformation matrix\n disablePicking: false, // disable picking\n sortParticles: false,\n background: false\n}\nexport type BufferParameters = Omit & { diffuse: GenericColor; interiorColor: GenericColor }\n\nexport const BufferParameterTypes = {\n opaqueBack: { updateShader: true },\n side: { updateShader: true, property: true },\n opacity: { uniform: true },\n depthWrite: { property: true },\n clipNear: { updateShader: true, property: true },\n clipRadius: { updateShader: true, uniform: true },\n clipCenter: { uniform: true },\n flatShaded: { updateShader: true },\n background: { updateShader: true },\n wireframe: { updateVisibility: true },\n roughness: { uniform: true },\n metalness: { uniform: true },\n diffuse: { uniform: true },\n diffuseInterior: { updateShader: true },\n useInteriorColor: { updateShader: true },\n interiorColor: { uniform: true },\n interiorDarkening: { uniform: true },\n matrix: {}\n}\n\nexport interface BufferData {\n position?: Float32Array\n position1?: Float32Array // TODO\n color?: Float32Array\n index?: Uint32Array|Uint16Array\n normal?: Float32Array\n\n picking?: Picker\n primitiveId?: Float32Array\n}\n\n/**\n * Buffer class. Base class for buffers.\n * @interface\n */\nclass Buffer {\n parameterTypes = BufferParameterTypes\n get defaultParameters() { return BufferDefaultParameters }\n parameters: BufferParameters\n uniforms: Uniforms\n pickingUniforms: Uniforms\n\n private _positionDataSize: number\n\n geometry = new BufferGeometry()\n indexVersion = 0\n wireframeIndexVersion = -1\n group = new Group()\n wireframeGroup = new Group()\n pickingGroup = new Group()\n\n vertexShader = ''\n fragmentShader = ''\n isImpostor = false\n isText = false\n isSurface = false\n isPoint = false\n isLine = false\n dynamic = true\n visible = true\n\n picking?: Picker\n\n material: ShaderMaterial\n wireframeMaterial: ShaderMaterial\n pickingMaterial: ShaderMaterial\n\n wireframeIndex?: Uint32Array|Uint16Array\n wireframeIndexCount = 0\n wireframeGeometry?: BufferGeometry\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Uint32Array|Uint16Array} data.index - triangle indices\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} params - parameters object\n */\n constructor (data: BufferData, params: Partial = {}) {\n this.parameters = createParams(params, this.defaultParameters)\n\n this.uniforms = UniformsUtils.merge([\n UniformsLib.common,\n {\n fogColor: { value: new Color(0x000000) },\n fogNear: { value: 0.0 },\n fogFar: { value: 0.0 },\n opacity: { value: this.parameters.opacity },\n clipNear: { value: 0.0 },\n clipRadius: { value: this.parameters.clipRadius },\n clipCenter: { value: this.parameters.clipCenter }\n },\n {\n emissive: { value: new Color(0x000000) },\n roughness: { value: this.parameters.roughness },\n metalness: { value: this.parameters.metalness },\n interiorColor: { value: new Color(this.parameters.interiorColor) },\n interiorDarkening: { value: this.parameters.interiorDarkening },\n },\n UniformsLib.lights\n ])\n\n this.uniforms.diffuse.value.set(this.parameters.diffuse)\n\n this.pickingUniforms = {\n clipNear: { value: 0.0 },\n objectId: { value: 0 },\n opacity: { value: this.parameters.opacity }\n }\n\n //\n\n const position = data.position || data.position1\n this._positionDataSize = position ? position.length / 3 : 0\n\n if (!data.primitiveId) {\n data.primitiveId = serialArray(this._positionDataSize)\n }\n\n this.addAttributes({\n position: { type: 'v3', value: data.position },\n color: { type: 'c', value: data.color },\n primitiveId: { type: 'f', value: data.primitiveId }\n })\n\n if (params.matrix) {\n this.matrix = params.matrix\n }\n\n if (data.index) {\n this.initIndex(data.index)\n }\n this.picking = data.picking\n\n this.makeWireframeGeometry()\n }\n\n set matrix (m) {\n this.setMatrix(m)\n }\n get matrix () {\n return this.group.matrix.clone()\n }\n\n get transparent () {\n return this.parameters.opacity < 1 || this.parameters.forceTransparent\n }\n\n get size () {\n return this._positionDataSize\n }\n\n get attributeSize () {\n return this.size\n }\n\n get pickable () {\n return !!this.picking && !this.parameters.disablePicking\n }\n\n setMatrix (m: Matrix4) {\n setObjectMatrix(this.group, m)\n setObjectMatrix(this.wireframeGroup, m)\n setObjectMatrix(this.pickingGroup, m)\n }\n\n initIndex (index: Uint32Array|Uint16Array) {\n this.geometry.setIndex(\n new BufferAttribute(index, 1)\n )\n const nindex = this.geometry.getIndex();\n if (!nindex) { Log.error('Index is null'); return; }\n nindex.setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n }\n\n makeMaterial () {\n const side = getThreeSide(this.parameters.side)\n\n const m = new ShaderMaterial({\n uniforms: this.uniforms,\n vertexShader: '',\n fragmentShader: '',\n depthTest: true,\n transparent: this.transparent,\n depthWrite: this.parameters.depthWrite,\n lights: true,\n fog: true,\n side: side\n })\n m.vertexColors = true\n m.extensions.derivatives = true\n m.extensions.fragDepth = this.isImpostor\n\n const wm = new ShaderMaterial({\n uniforms: this.uniforms,\n vertexShader: '',\n fragmentShader: '',\n depthTest: true,\n transparent: this.transparent,\n depthWrite: this.parameters.depthWrite,\n lights: false,\n fog: true,\n side: side\n })\n wm.vertexColors = true\n\n const pm = new ShaderMaterial({\n uniforms: this.pickingUniforms,\n vertexShader: '',\n fragmentShader: '',\n depthTest: true,\n transparent: false,\n depthWrite: this.parameters.depthWrite,\n lights: false,\n fog: false,\n side: side,\n blending: NoBlending\n })\n pm.vertexColors = true\n pm.extensions.fragDepth = this.isImpostor\n\n ;(m as any).clipNear = this.parameters.clipNear\n ;(wm as any).clipNear = this.parameters.clipNear\n ;(pm as any).clipNear = this.parameters.clipNear\n\n this.material = m\n this.wireframeMaterial = wm\n this.pickingMaterial = pm\n\n // also sets vertexShader/fragmentShader\n this.updateShader()\n }\n\n makeWireframeGeometry () {\n this.makeWireframeIndex()\n\n const geometry = this.geometry\n const wireframeIndex = this.wireframeIndex\n const wireframeGeometry = new BufferGeometry()\n\n wireframeGeometry.attributes = geometry.attributes\n if (wireframeIndex) {\n wireframeGeometry.setIndex(\n new BufferAttribute(wireframeIndex, 1).setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n wireframeGeometry.setDrawRange(0, this.wireframeIndexCount)\n }\n\n this.wireframeGeometry = wireframeGeometry\n }\n\n makeWireframeIndex () {\n const edges: number[][] = []\n\n function checkEdge (a: number, b: number) {\n if (a > b) {\n const tmp = a\n a = b\n b = tmp\n }\n\n const list = edges[ a ]\n\n if (list === undefined) {\n edges[ a ] = [ b ]\n return true\n } else if (!list.includes(b)) {\n list.push(b)\n return true\n }\n\n return false\n }\n\n const geometry = this.geometry\n const index = geometry.index\n\n if (!this.parameters.wireframe) {\n this.wireframeIndex = new Uint16Array(0)\n this.wireframeIndexCount = 0\n } else if (index) {\n const array = index.array\n let n = array.length\n if (geometry.drawRange.count !== Infinity) {\n n = geometry.drawRange.count\n }\n let wireframeIndex\n if (this.wireframeIndex && this.wireframeIndex.length > n * 2) {\n wireframeIndex = this.wireframeIndex\n } else {\n const count = (geometry.attributes as any).position.count // TODO\n wireframeIndex = getUintArray(n * 2, count)\n }\n\n let j = 0\n edges.length = 0\n\n for (let i = 0; i < n; i += 3) {\n const a = array[ i + 0 ]\n const b = array[ i + 1 ]\n const c = array[ i + 2 ]\n\n if (checkEdge(a, b)) {\n wireframeIndex[ j + 0 ] = a\n wireframeIndex[ j + 1 ] = b\n j += 2\n }\n if (checkEdge(b, c)) {\n wireframeIndex[ j + 0 ] = b\n wireframeIndex[ j + 1 ] = c\n j += 2\n }\n if (checkEdge(c, a)) {\n wireframeIndex[ j + 0 ] = c\n wireframeIndex[ j + 1 ] = a\n j += 2\n }\n }\n\n this.wireframeIndex = wireframeIndex\n this.wireframeIndexCount = j\n this.wireframeIndexVersion = this.indexVersion\n } else {\n const n = (geometry.attributes as any).position.count // TODO\n\n let wireframeIndex\n if (this.wireframeIndex && this.wireframeIndex.length > n * 2) {\n wireframeIndex = this.wireframeIndex\n } else {\n wireframeIndex = getUintArray(n * 2, n)\n }\n\n for (let i = 0, j = 0; i < n; i += 3) {\n wireframeIndex[ j + 0 ] = i\n wireframeIndex[ j + 1 ] = i + 1\n wireframeIndex[ j + 2 ] = i + 1\n wireframeIndex[ j + 3 ] = i + 2\n wireframeIndex[ j + 4 ] = i + 2\n wireframeIndex[ j + 5 ] = i\n\n j += 6\n }\n\n this.wireframeIndex = wireframeIndex\n this.wireframeIndexCount = n * 2\n this.wireframeIndexVersion = this.indexVersion\n }\n }\n\n updateWireframeIndex () {\n if (!this.wireframeGeometry || !this.wireframeIndex) return\n\n this.wireframeGeometry.setDrawRange(0, Infinity)\n if (this.wireframeIndexVersion < this.indexVersion) this.makeWireframeIndex()\n\n if (this.wireframeGeometry.index &&\n this.wireframeIndex.length > this.wireframeGeometry.index.array.length) {\n this.wireframeGeometry.setIndex(\n new BufferAttribute(this.wireframeIndex, 1).setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n } else {\n const index = this.wireframeGeometry.getIndex()\n if (!index) { Log.error('Index is null'); return; }\n index.set(this.wireframeIndex)\n index.needsUpdate = this.wireframeIndexCount > 0\n index.updateRange.count = this.wireframeIndexCount\n }\n\n this.wireframeGeometry.setDrawRange(0, this.wireframeIndexCount)\n }\n\n getRenderOrder () {\n let renderOrder = 0\n\n if (this.isText) {\n renderOrder = 1\n } else if (this.transparent) {\n if (this.isSurface) {\n renderOrder = 3\n } else {\n renderOrder = 2\n }\n }\n\n return renderOrder\n }\n\n _getMesh (materialName: BufferMaterials) {\n if (!this.material) this.makeMaterial()\n\n const g = this.geometry\n const m = this[ materialName ]\n\n let mesh\n\n if (this.isLine) {\n mesh = new LineSegments(g, m)\n } else if (this.isPoint) {\n mesh = new Points(g, m)\n } else {\n mesh = new Mesh(g, m)\n }\n\n mesh.frustumCulled = false\n mesh.renderOrder = this.getRenderOrder()\n\n return mesh\n }\n\n getMesh () {\n return this._getMesh('material')\n }\n\n getWireframeMesh () {\n let mesh\n\n if (!this.material) this.makeMaterial()\n if (!this.wireframeGeometry) this.makeWireframeGeometry()\n\n mesh = new LineSegments(\n this.wireframeGeometry, this.wireframeMaterial\n )\n\n mesh.frustumCulled = false\n mesh.renderOrder = this.getRenderOrder()\n\n return mesh\n }\n\n getPickingMesh () {\n return this._getMesh('pickingMaterial')\n }\n\n getShader (name: string, type?: BufferTypes) {\n return getShader(name, this.getDefines(type))\n }\n\n getVertexShader (type?: BufferTypes) {\n return this.getShader(this.vertexShader, type)\n }\n\n getFragmentShader (type?: BufferTypes) {\n return this.getShader(this.fragmentShader, type)\n }\n\n getDefines (type?: BufferTypes) {\n const defines: ShaderDefines = {}\n\n if (this.parameters.clipNear) {\n defines.NEAR_CLIP = 1\n }\n\n if (this.parameters.clipRadius) {\n defines.RADIUS_CLIP = 1\n }\n\n if (type === 'picking') {\n defines.PICKING = 1\n } else {\n if (type === 'background' || this.parameters.background) {\n defines.NOLIGHT = 1\n }\n if (this.parameters.flatShaded) {\n defines.FLAT_SHADED = 1\n }\n if (this.parameters.opaqueBack) {\n defines.OPAQUE_BACK = 1\n }\n if (this.parameters.diffuseInterior) {\n defines.DIFFUSE_INTERIOR = 1\n }\n if (this.parameters.useInteriorColor) {\n defines.USE_INTERIOR_COLOR = 1\n }\n }\n\n return defines\n }\n\n getParameters () {\n return this.parameters\n }\n\n addUniforms (uniforms: Uniforms) {\n this.uniforms = UniformsUtils.merge(\n [ this.uniforms, uniforms ]\n )\n\n this.pickingUniforms = UniformsUtils.merge(\n [ this.pickingUniforms, uniforms ]\n )\n }\n\n addAttributes (attributes: { [k: string]: _BufferAttribute }) {\n for (let name in attributes) {\n let buf\n const a = attributes[ name ]\n const arraySize = this.attributeSize * itemSize[ a.type ]\n\n if (a.value) {\n if (arraySize !== a.value.length) {\n Log.error('attribute value has wrong length', name)\n }\n buf = a.value\n } else {\n buf = getTypedArray('float32', arraySize)\n }\n\n this.geometry.setAttribute(\n name,\n new BufferAttribute(buf, itemSize[ a.type ]).setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n }\n }\n\n updateRenderOrder () {\n const renderOrder = this.getRenderOrder()\n function setRenderOrder (mesh: Object3D) {\n mesh.renderOrder = renderOrder\n }\n\n this.group.children.forEach(setRenderOrder)\n if (this.pickingGroup) {\n this.pickingGroup.children.forEach(setRenderOrder)\n }\n }\n\n updateShader () {\n const m = this.material\n const wm = this.wireframeMaterial\n const pm = this.pickingMaterial\n\n m.vertexShader = this.getVertexShader()\n m.fragmentShader = this.getFragmentShader()\n m.needsUpdate = true\n\n wm.vertexShader = this.getShader('Line.vert')\n wm.fragmentShader = this.getShader('Line.frag')\n wm.needsUpdate = true\n\n pm.vertexShader = this.getVertexShader('picking')\n pm.fragmentShader = this.getFragmentShader('picking')\n pm.needsUpdate = true\n }\n\n /**\n * Set buffer parameters\n * @param {BufferParameters} params - buffer parameters object\n * @return {undefined}\n */\n setParameters (params: Partial) {\n const p = params as any\n const pt = this.parameterTypes as any\n const pv = this.parameters as any\n\n const propertyData: { [k: string]: any } = {}\n const uniformData: { [k: string]: any } = {}\n let doShaderUpdate = false\n let doVisibilityUpdate = false\n\n for (const name in p) {\n const value = p[ name ]\n\n if (value === undefined) continue\n pv[ name ] = value\n\n if (pt[ name ] === undefined) continue\n\n if (pt[ name ].property) {\n if (pt[ name ].property !== true) {\n propertyData[ pt[ name ].property as any ] = value\n } else {\n propertyData[ name ] = value\n }\n }\n\n if (pt[ name ].uniform) {\n if (pt[ name ].uniform !== true) {\n uniformData[ pt[ name ].uniform as any ] = value\n } else {\n uniformData[ name ] = value\n }\n }\n\n if (pt[ name ].updateShader) {\n doShaderUpdate = true\n }\n\n if (pt[ name ].updateVisibility) {\n doVisibilityUpdate = true\n }\n\n if (this.dynamic && name === 'wireframe' && value === true) {\n this.updateWireframeIndex()\n }\n\n if (name === 'forceTransparent') {\n propertyData.transparent = this.transparent\n }\n\n if (name === 'matrix') {\n this.matrix = value\n }\n }\n\n this.setProperties(propertyData)\n this.setUniforms(uniformData)\n if (doShaderUpdate) this.updateShader()\n if (doVisibilityUpdate) this.setVisibility(this.visible)\n }\n\n /**\n * Sets buffer attributes\n * @param {Object} data - An object where the keys are the attribute names\n * and the values are the attribute data.\n * @example\n * var buffer = new Buffer();\n * buffer.setAttributes({ attrName: attrData });\n */\n setAttributes (data: any) { // TODO\n const geometry = this.geometry\n const attributes = geometry.attributes as any // TODO\n\n for (const name in data) {\n if (name === 'picking') continue\n\n const array = data[ name ]\n const length = array.length\n\n if (name === 'index') {\n const index = geometry.getIndex()\n if (!index) { Log.error('Index is null'); continue; }\n geometry.setDrawRange(0, Infinity)\n\n if (length > index.array.length) {\n geometry.setIndex(\n new BufferAttribute(array, 1)\n .setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n } else {\n index.set(array)\n index.count = length\n index.needsUpdate = length > 0\n index.updateRange.count = length\n geometry.setDrawRange(0, length)\n }\n\n this.indexVersion++\n if (this.parameters.wireframe) this.updateWireframeIndex()\n } else {\n const attribute = attributes[ name ]\n\n if (length > attribute.array.length) {\n geometry.setAttribute(\n name,\n new BufferAttribute(array, attribute.itemSize)\n .setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n } else {\n attributes[ name ].set(array)\n attributes[ name ].needsUpdate = length > 0\n attributes[ name ].updateRange.count = length\n }\n }\n }\n }\n\n setUniforms (data: any) { // TODO\n if (!data) return\n\n const u = this.material.uniforms\n const wu = this.wireframeMaterial.uniforms\n const pu = this.pickingMaterial.uniforms\n\n for (let name in data) {\n if (name === 'opacity') {\n this.setProperties({ transparent: this.transparent })\n }\n\n if (u[ name ] !== undefined) {\n if (u[ name ].value.isVector3) {\n u[ name ].value.copy(data[ name ])\n } else if (u[ name ].value.set) {\n u[ name ].value.set(data[ name ])\n } else {\n u[ name ].value = data[ name ]\n }\n }\n\n if (wu[ name ] !== undefined) {\n if (wu[ name ].value.isVector3) {\n wu[ name ].value.copy(data[ name ])\n } else if (wu[ name ].value.set) {\n wu[ name ].value.set(data[ name ])\n } else {\n wu[ name ].value = data[ name ]\n }\n }\n\n if (pu[ name ] !== undefined) {\n if (pu[ name ].value.isVector3) {\n pu[ name ].value.copy(data[ name ])\n } else if (pu[ name ].value.set) {\n pu[ name ].value.set(data[ name ])\n } else {\n pu[ name ].value = data[ name ]\n }\n }\n }\n }\n\n setProperties (data: any) { // TODO\n if (!data) return\n\n const m = this.material\n const wm = this.wireframeMaterial\n const pm = this.pickingMaterial\n\n for (const _name in data) {\n const name = _name as 'side'|'transparent' // TODO\n\n let value = data[ name ]\n\n if (name === 'transparent') {\n this.updateRenderOrder()\n } else if (name === 'side') {\n value = getThreeSide(value)\n }\n\n (m[ name ] as any) = value;\n (wm[ name ] as any) = value;\n (pm[ name ] as any) = value\n }\n\n m.needsUpdate = true\n wm.needsUpdate = true\n pm.needsUpdate = true\n }\n\n /**\n * Set buffer visibility\n * @param {Boolean} value - visibility value\n * @return {undefined}\n */\n setVisibility (value: boolean) {\n this.visible = value\n\n if (this.parameters.wireframe) {\n this.group.visible = false\n this.wireframeGroup.visible = value\n if (this.pickable) {\n this.pickingGroup.visible = false\n }\n } else {\n this.group.visible = value\n this.wireframeGroup.visible = false\n if (this.pickable) {\n this.pickingGroup.visible = value\n }\n }\n }\n\n /**\n * Free buffer resources\n * @return {undefined}\n */\n dispose () {\n if (this.material) this.material.dispose()\n if (this.wireframeMaterial) this.wireframeMaterial.dispose()\n if (this.pickingMaterial) this.pickingMaterial.dispose()\n\n this.geometry.dispose()\n if (this.wireframeGeometry) this.wireframeGeometry.dispose()\n }\n\n /**\n * Customize JSON serialization to avoid circular references\n */\n toJSON () {\n var result: any = {};\n for (var x in this) {\n if (x !== \"group\" && x !== \"wireframeGroup\" && x != \"pickingGroup\"\n && x !== \"picking\") {\n result[x] = this[x];\n }\n }\n return result;\n }\n}\n\nexport default Buffer\n","/**\n * @file Mesh Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport '../shader/Mesh.vert'\nimport '../shader/Mesh.frag'\n\nimport Buffer, { BufferParameters, BufferData } from './buffer'\n\n/**\n * Mesh buffer. Draws a triangle mesh.\n *\n * @example\n * var meshBuffer = new MeshBuffer({\n * position: new Float32Array(\n * [ 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1 ]\n * ),\n * color: new Float32Array(\n * [ 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0 ]\n * )\n * });\n */\nclass MeshBuffer extends Buffer {\n vertexShader = 'Mesh.vert'\n fragmentShader = 'Mesh.frag'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} [data.index] - triangle indices\n * @param {Float32Array} [data.normal] - radii\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: BufferData, params: Partial = {}) {\n super(data, params)\n\n this.addAttributes({\n 'normal': { type: 'v3', value: data.normal }\n })\n\n if (data.normal === undefined) {\n this.geometry.computeVertexNormals()\n }\n }\n}\n\nexport default MeshBuffer\n","/**\n * @file Surface Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport MeshBuffer from './mesh-buffer'\n\n/**\n * Surface buffer. Like a {@link MeshBuffer}, but with `.isSurface` set to `true`.\n */\nclass SurfaceBuffer extends MeshBuffer {\n isSurface = true\n}\n\nexport default SurfaceBuffer\n","/**\n * @file Double Sided Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { Group, BufferGeometry, Object3D, Mesh, LineSegments, Vector3, Matrix4 } from 'three'\n\nimport Buffer, { BufferSide } from './buffer'\nimport { Picker } from '../utils/picker'\n\nfunction setVisibilityTrue (m: Object3D) { m.visible = true }\nfunction setVisibilityFalse (m: Object3D) { m.visible = false }\n\n/**\n * A double-sided mesh buffer. Takes a buffer and renders the front and\n * the back as seperate objects to avoid some artifacts when rendering\n * transparent meshes. Also allows to render the back of a mesh opaque\n * while the front is transparent.\n * @implements {Buffer}\n *\n * @example\n * var sphereGeometryBuffer = new SphereGeometryBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n * var doubleSidedBuffer = new DoubleSidedBuffer(sphereGeometryBuffer);\n */\nclass DoubleSidedBuffer {\n size: number\n side: BufferSide\n visible: boolean\n wireframe: boolean\n geometry: BufferGeometry\n\n picking?: Picker\n\n group = new Group()\n wireframeGroup = new Group()\n pickingGroup = new Group()\n\n frontMeshes: (Mesh|LineSegments)[] = []\n backMeshes: (Mesh|LineSegments)[] = []\n\n buffer: Buffer\n frontBuffer: Buffer\n backBuffer: Buffer\n\n /**\n * Create a double sided buffer\n * @param {Buffer} buffer - the buffer to be rendered double-sided\n */\n constructor (buffer: Buffer) {\n this.size = buffer.size\n this.side = buffer.parameters.side\n this.visible = buffer.visible\n this.geometry = buffer.geometry\n this.picking = buffer.picking\n\n this.group = new Group()\n this.wireframeGroup = new Group()\n this.pickingGroup = new Group()\n\n // requires Group objects to be present\n this.matrix = buffer.matrix\n\n const frontBuffer = buffer\n const backBuffer = new (buffer as any).constructor({ // TODO\n position: new Float32Array(0)\n }) as Buffer\n\n frontBuffer.makeMaterial()\n backBuffer.makeMaterial()\n\n backBuffer.picking = buffer.picking\n backBuffer.geometry = buffer.geometry\n backBuffer.wireframeGeometry = buffer.wireframeGeometry\n backBuffer.setParameters(buffer.getParameters())\n backBuffer.updateShader()\n\n frontBuffer.setParameters({\n side: 'front'\n })\n backBuffer.setParameters({\n side: 'back',\n opacity: backBuffer.parameters.opacity\n })\n\n this.buffer = buffer\n this.frontBuffer = frontBuffer\n this.backBuffer = backBuffer\n }\n\n set matrix (m) {\n Buffer.prototype.setMatrix.call(this, m)\n }\n get matrix () {\n return this.group.matrix.clone()\n }\n\n get pickable () {\n return !!this.picking && !this.parameters.disablePicking\n }\n\n get parameters () {\n return this.buffer.parameters\n }\n\n getParameters () {\n const p = Object.assign({}, this.buffer.parameters)\n p.side = this.side\n return p\n }\n\n getMesh (picking: boolean) {\n let front, back\n\n if (picking) {\n back = this.backBuffer.getPickingMesh()\n front = this.frontBuffer.getPickingMesh()\n } else {\n back = this.backBuffer.getMesh()\n front = this.frontBuffer.getMesh()\n }\n\n this.frontMeshes.push(front)\n this.backMeshes.push(back)\n\n this.setParameters({ side: this.side })\n\n return new Group().add(back, front)\n }\n\n getWireframeMesh () {\n return this.buffer.getWireframeMesh()\n }\n\n getPickingMesh () {\n return this.getMesh(true)\n }\n\n setAttributes (data: any) { // TODO\n this.buffer.setAttributes(data)\n }\n\n setParameters (data: any) { // TODO\n data = Object.assign({}, data)\n\n if (data.side === 'front') {\n this.frontMeshes.forEach(setVisibilityTrue)\n this.backMeshes.forEach(setVisibilityFalse)\n } else if (data.side === 'back') {\n this.frontMeshes.forEach(setVisibilityFalse)\n this.backMeshes.forEach(setVisibilityTrue)\n } else if (data.side === 'double') {\n this.frontMeshes.forEach(setVisibilityTrue)\n this.backMeshes.forEach(setVisibilityTrue)\n }\n\n if (data.side !== undefined) {\n this.side = data.side\n }\n delete data.side\n\n if (data.matrix !== undefined) {\n this.matrix = data.matrix\n }\n delete data.matrix\n\n this.frontBuffer.setParameters(data)\n\n if (data.wireframe !== undefined) {\n this.wireframe = data.wireframe\n this.setVisibility(this.visible)\n }\n delete data.wireframe\n\n this.backBuffer.setParameters(data)\n }\n\n setVisibility (value: boolean) {\n this.visible = value\n\n if (this.parameters.wireframe) {\n this.group.visible = false\n this.wireframeGroup.visible = value\n if (this.pickable) {\n this.pickingGroup.visible = false\n }\n } else {\n this.group.visible = value\n this.wireframeGroup.visible = false\n if (this.pickable) {\n this.pickingGroup.visible = value\n }\n }\n }\n\n dispose () {\n this.frontBuffer.dispose()\n this.backBuffer.dispose()\n }\n\n /**\n * Customize JSON serialization to avoid circular references.\n * Only export simple params which could be useful.\n */\n toJSON () {\n var result: any = {};\n for (var x in this) {\n if (['side', 'size', 'visible', 'matrix', 'parameters'].includes(x)) {\n result[x] = this[x];\n }\n }\n return result;\n }\n}\n\nexport default DoubleSidedBuffer\n","/**\n * @file Contour Buffer\n * @author Fred ludlow \n * @private\n */\n\nimport '../shader/Line.vert'\nimport '../shader/Line.frag'\n\nimport Buffer from './buffer'\n\n/**\n * Contour buffer. A buffer that draws lines (instead of triangle meshes).\n */\nclass ContourBuffer extends Buffer {\n isLine = true\n vertexShader = 'Line.vert'\n fragmentShader = 'Line.frag'\n}\n\nexport default ContourBuffer\n","/**\n * @file Surface Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3, Box3 } from 'three'\n\nimport { defaults } from '../utils'\nimport Representation, { RepresentationParameters } from './representation'\nimport Volume from '../surface/volume'\nimport SurfaceBuffer from '../buffer/surface-buffer'\nimport DoubleSidedBuffer from '../buffer/doublesided-buffer'\nimport ContourBuffer from '../buffer/contour-buffer'\nimport Surface from '../surface/surface';\nimport Viewer from '../viewer/viewer';\nimport {SurfaceData} from '../surface/surface'\n// @ts-ignore: unused import ColormakerParameters required for declaration only\nimport { ColormakerParameters } from '../color/colormaker';\nexport type SurfaceDataFields = {position: boolean, color: boolean, index: boolean, normal: boolean, radius: boolean}\n\n/**\n * Surface representation parameter object. Extends {@link RepresentationParameters}\n *\n * @typedef {Object} SurfaceRepresentationParameters - surface representation parameters\n *\n * @property {String} isolevelType - Meaning of the isolevel value. Either *value* for the literal value or *sigma* as a factor of the sigma of the data. For volume data only.\n * @property {Float} isolevel - The value at which to create the isosurface. For volume data only.\n * @property {Boolean} negateIsolevel - For volume data only.\n * @property {Boolean} isolevelScroll - For volume data only\n * @property {Integer} smooth - How many iterations of laplacian smoothing after surface triangulation. For volume data only.\n * @property {Boolean} background - Render the surface in the background, unlit.\n * @property {Boolean} opaqueBack - Render the back-faces (where normals point away from the camera) of the surface opaque, ignoring the transparency parameter.\n * @property {Integer} boxSize - Size of the box to triangulate volume data in. Set to zero to triangulate the whole volume. For volume data only.\n * @property {Boolean} useWorker - Weather or not to triangulate the volume asynchronously in a Web Worker. For volume data only.\n * @property {Boolean} wrap - Wrap volume data around the edges; use in conjuction with boxSize but not larger than the volume dimension. For volume data only.\n */\nexport interface SurfaceRepresentationParameters extends RepresentationParameters {\n isolevelType: 'value'|'sigma'\n isolevel: number\n smooth: number\n background: boolean\n opaqueBack: boolean\n boxSize: number\n useWorker: boolean\n wrap: boolean\n}\n/**\n * Surface representation\n */\n/**\n * Create Surface representation object\n * @param {Surface|Volume} surface - the surface or volume to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {SurfaceRepresentationParameters} params - surface representation parameters\n */\nclass SurfaceRepresentation extends Representation {\n protected surface: Surface|Volume|undefined\n protected volume: Volume|undefined\n protected boxCenter: Vector3\n protected __boxCenter: Vector3\n protected box: Box3\n protected __box: Box3\n protected _position: Vector3\n protected isolevelType: 'value'|'sigma'\n protected isolevel: number\n protected negateIsolevel: boolean\n protected isolevelScroll: boolean\n protected smooth: number\n protected background: boolean\n protected opaqueBack: boolean\n protected boxSize: number\n protected inverseMatrix: Matrix4\n protected colorVolume: Volume\n protected contour: boolean\n protected useWorker: boolean\n protected wrap: boolean\n\n protected __isolevel: number\n protected __smooth: number\n protected __contour: boolean\n protected __wrap: boolean\n protected __boxSize: number\n\n setBox: () => void\n\n constructor (surface: Surface, viewer: Viewer, params: Partial) {\n super(surface, viewer, params)\n\n this.type = 'surface'\n\n this.parameters = Object.assign({\n\n isolevelType: {\n type: 'select',\n options: {\n 'value': 'value', 'sigma': 'sigma'\n }\n },\n isolevel: {\n type: 'number', precision: 2, max: 1000, min: -1000\n },\n negateIsolevel: {\n type: 'boolean'\n },\n isolevelScroll: {\n type: 'boolean'\n },\n smooth: {\n type: 'integer', precision: 1, max: 10, min: 0\n },\n background: {\n type: 'boolean', rebuild: true // FIXME\n },\n opaqueBack: {\n type: 'boolean', buffer: true\n },\n boxSize: {\n type: 'integer', precision: 1, max: 100, min: 0\n },\n colorVolume: {\n type: 'hidden'\n },\n contour: {\n type: 'boolean', rebuild: true\n },\n useWorker: {\n type: 'boolean', rebuild: true\n },\n wrap: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters)\n\n if (surface instanceof Volume) {\n this.surface = undefined\n this.volume = surface\n } else {\n this.surface = surface\n this.volume = undefined\n }\n\n this.boxCenter = new Vector3()\n this.__boxCenter = new Vector3()\n this.box = new Box3()\n this.__box = new Box3()\n\n this._position = new Vector3()\n this.inverseMatrix = new Matrix4()\n\n this.setBox = function setBox () {\n this._position.copy(viewer.translationGroup.position).negate()\n this._position.applyMatrix4(this.inverseMatrix)\n if (!this._position.equals(this.boxCenter)) {\n this.setParameters({ 'boxCenter': this._position })\n }\n }\n\n this.toBePrepared = true\n\n this.viewer.signals.ticked.add(this.setBox, this)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'uniform')\n p.colorValue = defaults(p.colorValue, 0xDDDDDD)\n\n this.isolevelType = defaults(p.isolevelType, 'sigma')\n this.isolevel = defaults(p.isolevel, 2.0)\n this.negateIsolevel = defaults(p.negateIsolevel, false)\n this.isolevelScroll = defaults(p.isolevelScroll, false)\n this.smooth = defaults(p.smooth, 0)\n this.background = defaults(p.background, false)\n this.opaqueBack = defaults(p.opaqueBack, true)\n this.boxSize = defaults(p.boxSize, 0)\n this.colorVolume = defaults(p.colorVolume, undefined)\n this.contour = defaults(p.contour, false)\n this.useWorker = defaults(p.useWorker, true)\n this.wrap = defaults(p.wrap, false)\n\n super.init(p)\n\n this.inverseMatrix.getInverse(this.matrix)\n\n this.build()\n }\n\n attach (callback: () => void) {\n this.bufferList.forEach(buffer => {\n this.viewer.add(buffer)\n })\n\n this.setVisibility(this.visible)\n\n callback()\n }\n\n prepare (callback: () => void) {\n if (this.volume) {\n let isolevel\n\n if (this.isolevelType === 'sigma') {\n isolevel = this.volume.getValueForSigma(this.isolevel)\n } else {\n isolevel = this.isolevel\n }\n if (this.negateIsolevel) isolevel *= -1\n\n if (!this.surface ||\n this.__isolevel !== isolevel ||\n this.__smooth !== this.smooth ||\n this.__contour !== this.contour ||\n this.__wrap !== this.wrap ||\n this.__boxSize !== this.boxSize ||\n (this.boxSize > 0 &&\n !this.__boxCenter.equals(this.boxCenter))\n ) {\n this.__isolevel = isolevel\n this.__smooth = this.smooth\n this.__contour = this.contour\n this.__wrap = this.wrap\n this.__boxSize = this.boxSize\n this.__boxCenter.copy(this.boxCenter)\n this.__box.copy(this.box)\n\n const onSurfaceFinish = (surface: Surface) => {\n this.surface = surface\n callback()\n }\n\n if (this.useWorker) {\n this.volume.getSurfaceWorker(\n isolevel, this.smooth, this.boxCenter, this.boxSize,\n this.contour, this.wrap, onSurfaceFinish\n )\n } else {\n onSurfaceFinish(\n this.volume.getSurface(\n isolevel, this.smooth, this.boxCenter, this.boxSize,\n this.contour, this.wrap\n )\n )\n }\n } else {\n callback()\n }\n } else {\n callback()\n }\n }\n\n create () {\n const sd = {\n position: (this.surface as Surface).getPosition(),\n color: (this.surface as Surface).getColor(this.getColorParams()),\n index: (this.surface as Surface).getIndex()\n }\n\n let buffer\n\n if (this.contour) {\n buffer = new ContourBuffer(\n sd,\n this.getBufferParams({ wireframe: false })\n )\n } else {\n Object.assign(sd, {\n normal: (this.surface as Surface).getNormal(),\n picking: (this.surface as Surface).getPicking()\n })\n\n const surfaceBuffer = new SurfaceBuffer(\n sd,\n this.getBufferParams({\n background: this.background,\n opaqueBack: this.opaqueBack,\n dullInterior: false\n })\n )\n\n buffer = new DoubleSidedBuffer(surfaceBuffer)\n }\n\n this.bufferList.push(buffer as ContourBuffer)\n }\n\n update (what: SurfaceDataFields) {\n if (this.bufferList.length === 0) return\n\n what = what || {}\n\n const surfaceData: Partial = {}\n\n if (what.position) {\n surfaceData.position = (this.surface as Surface).getPosition()\n }\n\n if (what.color) {\n surfaceData.color = (this.surface as Surface).getColor(\n this.getColorParams()\n )\n }\n\n if (what.index) {\n surfaceData.index = (this.surface as Surface).getIndex()\n }\n\n if (what.normal) {\n surfaceData.normal = (this.surface as Surface).getNormal()\n }\n\n this.bufferList.forEach(function (buffer) {\n buffer.setAttributes(surfaceData)\n })\n }\n\n /**\n * Set representation parameters\n * @alias SurfaceRepresentation#setParameters\n * @param {SurfaceRepresentationParameters} params - surface parameter object\n * @param {Object} [what] - buffer data attributes to be updated,\n * note that this needs to be implemented in the\n * derived classes. Generally it allows more\n * fine-grained control over updating than\n * forcing a rebuild.\n * @param {Boolean} what.position - update position data\n * @param {Boolean} what.color - update color data\n * @param {Boolean} [rebuild] - whether or not to rebuild the representation\n * @return {SurfaceRepresentation} this object\n */\n setParameters (params: Partial, what?: SurfaceDataFields, rebuild?: boolean) {\n if (params && params.isolevelType !== undefined &&\n this.volume\n ) {\n if (this.isolevelType === 'value' &&\n params.isolevelType === 'sigma'\n ) {\n this.isolevel = this.volume.getSigmaForValue(this.isolevel)\n } else if (this.isolevelType === 'sigma' &&\n params.isolevelType === 'value'\n ) {\n this.isolevel = this.volume.getValueForSigma(this.isolevel)\n }\n\n this.isolevelType = params.isolevelType\n }\n\n if (params && params.boxCenter) {\n this.boxCenter.copy(params.boxCenter)\n delete params.boxCenter\n }\n\n // Forbid wireframe && contour as in molsurface\n if (params && params.wireframe && (\n params.contour || (params.contour === undefined && this.contour)\n )) {\n params.wireframe = false\n }\n\n super.setParameters(params, what, rebuild)\n\n if (params.matrix) {\n this.inverseMatrix.getInverse(params.matrix)\n }\n\n if (this.volume) {\n this.volume.getBox(this.boxCenter, this.boxSize, this.box)\n }\n\n if (params && params.colorVolume !== undefined) {\n if (what) what.color = true\n }\n\n if (this.surface && (\n params.isolevel !== undefined ||\n params.negateIsolevel !== undefined ||\n params.smooth !== undefined ||\n params.wrap !== undefined ||\n params.boxSize !== undefined ||\n (this.boxSize > 0 &&\n !this.__box.equals(this.box))\n )) {\n this.build({\n 'position': true,\n 'color': true,\n 'index': true,\n 'normal': !this.contour\n })\n }\n\n return this\n }\n\n getColorParams () {\n const p = super.getColorParams()\n\n p.volume = this.colorVolume\n\n return p\n }\n\n dispose () {\n this.viewer.signals.ticked.remove(this.setBox, this)\n\n super.dispose()\n }\n}\n\nexport default SurfaceRepresentation\n","/**\n * @file Mouse Actions\n * @author Alexander Rose \n * @private\n */\n\nimport PickingProxy from './picking-proxy'\nimport { almostIdentity } from '../math/math-utils'\nimport Stage from '../stage/stage'\nimport StructureComponent from '../component/structure-component'\nimport SurfaceRepresentation from '../representation/surface-representation'\n\nexport type ScrollCallback = (stage: Stage, delta: number) => void\nexport type DragCallback = (stage: Stage, dx: number, dy: number) => void\nexport type PickCallback = (stage: Stage, pickingProxy: PickingProxy) => void\nexport type MouseActionCallback = ScrollCallback | DragCallback | PickCallback\n\n/**\n * Mouse actions provided as static methods\n */\nclass MouseActions {\n /**\n * Zoom scene based on scroll-delta\n * @param {Stage} stage - the stage\n * @param {Number} delta - amount to zoom\n * @return {undefined}\n */\n static zoomScroll (stage: Stage, delta: number) {\n stage.trackballControls.zoom(delta)\n }\n\n /**\n * Move near clipping plane based on scroll-delta\n * @param {Stage} stage - the stage\n * @param {Number} delta - amount to move clipping plane\n * @return {undefined}\n */\n static clipNearScroll (stage: Stage, delta: number) {\n const sp = stage.getParameters()\n stage.setParameters({ clipNear: sp.clipNear + delta / 10 })\n }\n\n /**\n * Move clipping planes based on scroll-delta.\n * @param {Stage} stage - the stage\n * @param {Number} delta - direction to move planes\n * @return {undefined}\n */\n static focusScroll (stage: Stage, delta: number) {\n const focus = stage.getFocus()\n const sign = Math.sign(delta)\n const step = sign * almostIdentity((100 - focus) / 10, 5, 0.2)\n stage.setFocus(focus + step)\n }\n\n /**\n * Zoom scene based on scroll-delta and\n * move focus planes based on camera position (zoom)\n * @param {Stage} stage - the stage\n * @param {Number} delta - amount to move focus planes and zoom\n * @return {undefined}\n */\n static zoomFocusScroll (stage: Stage, delta: number) {\n stage.trackballControls.zoom(delta)\n const z = stage.viewer.camera.position.z\n stage.setFocus(100 - Math.abs(z / 8))\n }\n\n /**\n * Change isolevel of volume surfaces based on scroll-delta\n * @param {Stage} stage - the stage\n * @param {Number} delta - amount to change isolevel\n * @return {undefined}\n */\n static isolevelScroll (stage: Stage, delta: number) {\n const d = Math.sign(delta) / 10\n stage.eachRepresentation((reprElem, comp) => {\n if (reprElem.repr instanceof SurfaceRepresentation) {\n const p = reprElem.getParameters() as any // TODO\n if (p.isolevelScroll) {\n reprElem.setParameters({ isolevel: p.isolevel + d })\n }\n }\n })\n }\n\n /**\n * Pan scene based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to pan in x direction\n * @param {Number} dy - amount to pan in y direction\n * @return {undefined}\n */\n static panDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.pan(dx, dy)\n }\n\n /**\n * Rotate scene based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to rotate in x direction\n * @param {Number} dy - amount to rotate in y direction\n * @return {undefined}\n */\n static rotateDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.rotate(dx, dy)\n }\n\n /**\n * Rotate scene around z axis based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to rotate in x direction\n * @param {Number} dy - amount to rotate in y direction\n * @return {undefined}\n */\n static zRotateDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.zRotate(dx, dy)\n }\n\n /**\n * Zoom scene based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to zoom\n * @param {Number} dy - amount to zoom\n * @return {undefined}\n */\n static zoomDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.zoom((dx + dy) / -2)\n }\n\n /**\n * Zoom scene based on mouse coordinate changes and\n * move focus planes based on camera position (zoom)\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to zoom and focus\n * @param {Number} dy - amount to zoom and focus\n * @return {undefined}\n */\n static zoomFocusDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.zoom((dx + dy) / -2)\n const z = stage.viewer.camera.position.z\n stage.setFocus(100 - Math.abs(z / 8))\n }\n\n /**\n * Pan picked component based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to pan in x direction\n * @param {Number} dy - amount to pan in y direction\n * @return {undefined}\n */\n static panComponentDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.panComponent(dx, dy)\n }\n\n /**\n * Pan picked atom based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to pan in x direction\n * @param {Number} dy - amount to pan in y direction\n * @return {undefined}\n */\n static panAtomDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.panAtom(dx, dy)\n }\n\n /**\n * Rotate picked component based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to rotate in x direction\n * @param {Number} dy - amount to rotate in y direction\n * @return {undefined}\n */\n static rotateComponentDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.rotateComponent(dx, dy)\n }\n\n /**\n * Move picked element to the center of the screen\n * @param {Stage} stage - the stage\n * @param {PickingProxy} pickingProxy - the picking data object\n * @return {undefined}\n */\n static movePick (stage: Stage, pickingProxy: PickingProxy) {\n if (pickingProxy) {\n stage.animationControls.move(pickingProxy.position.clone())\n }\n }\n\n /**\n * Show tooltip with information of picked element\n * @param {Stage} stage - the stage\n * @param {PickingProxy} pickingProxy - the picking data object\n * @return {undefined}\n */\n static tooltipPick (stage: Stage, pickingProxy: PickingProxy) {\n const tt = stage.tooltip\n const sp = stage.getParameters() as any\n if (sp.tooltip && pickingProxy) {\n const mp = pickingProxy.mouse.position\n tt.innerText = pickingProxy.getLabel()\n tt.style.bottom = (window.innerHeight - mp.y + 3) + 'px'\n tt.style.left = (mp.x + 3) + 'px'\n tt.style.display = 'block'\n } else {\n tt.style.display = 'none'\n }\n }\n\n static measurePick (stage: Stage, pickingProxy: PickingProxy) {\n if (pickingProxy && (pickingProxy.atom || pickingProxy.bond)) {\n const atom = pickingProxy.atom || pickingProxy.closestBondAtom\n const sc = pickingProxy.component as StructureComponent\n sc.measurePick(atom)\n } else {\n stage.measureClear()\n }\n }\n}\n\ntype MouseActionPreset = [ string, MouseActionCallback ][]\nexport const MouseActionPresets = {\n default: [\n [ 'scroll', MouseActions.zoomScroll ],\n [ 'scroll-shift', MouseActions.focusScroll ],\n [ 'scroll-ctrl', MouseActions.isolevelScroll ],\n [ 'scroll-shift-ctrl', MouseActions.zoomFocusScroll ],\n\n [ 'drag-left', MouseActions.rotateDrag ],\n [ 'drag-right', MouseActions.panDrag ],\n [ 'drag-ctrl-left', MouseActions.panDrag ],\n [ 'drag-ctrl-right', MouseActions.zRotateDrag ],\n [ 'drag-shift-left', MouseActions.zoomDrag ],\n [ 'drag-middle', MouseActions.zoomFocusDrag ],\n\n [ 'drag-ctrl-shift-right', MouseActions.panComponentDrag ],\n [ 'drag-ctrl-shift-left', MouseActions.rotateComponentDrag ],\n\n [ 'clickPick-right', MouseActions.measurePick ],\n [ 'clickPick-ctrl-left', MouseActions.measurePick ],\n [ 'clickPick-middle', MouseActions.movePick ],\n [ 'clickPick-left', MouseActions.movePick ],\n [ 'hoverPick', MouseActions.tooltipPick ]\n ] as MouseActionPreset,\n pymol: [\n [ 'drag-left', MouseActions.rotateDrag ],\n [ 'drag-middle', MouseActions.panDrag ],\n [ 'drag-right', MouseActions.zoomDrag ],\n [ 'scroll', MouseActions.focusScroll ],\n [ 'drag-shift-right', MouseActions.focusScroll ],\n\n [ 'clickPick-ctrl+shift-middle', MouseActions.movePick ],\n [ 'hoverPick', MouseActions.tooltipPick ]\n ] as MouseActionPreset,\n coot: [\n [ 'scroll', MouseActions.isolevelScroll ],\n\n [ 'drag-left', MouseActions.rotateDrag ],\n [ 'drag-middle', MouseActions.panDrag ],\n [ 'drag-ctrl-left', MouseActions.panDrag ],\n [ 'drag-right', MouseActions.zoomFocusDrag ],\n [ 'drag-ctrl-right', MouseActions.focusScroll ],\n\n [ 'clickPick-middle', MouseActions.movePick ],\n [ 'hoverPick', MouseActions.tooltipPick ]\n ] as MouseActionPreset,\n astexviewer: [\n [ 'drag-left', MouseActions.rotateDrag ],\n [ 'drag-ctrl-left', MouseActions.panDrag ],\n [ 'drag-shift-left', MouseActions.zoomDrag ],\n [ 'scroll', MouseActions.focusScroll ],\n [ 'clickPick-middle', MouseActions.movePick ],\n [ 'hoverPick', MouseActions.tooltipPick ]\n ] as MouseActionPreset\n}\n\nexport default MouseActions\n","/**\n * @file Mouse Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { MouseActionPresets, MouseActionCallback } from './mouse-actions'\nimport Stage from '../stage/stage'\nimport MouseObserver from '../stage/mouse-observer'\n\nexport type MouseControlPreset = keyof typeof MouseActionPresets\nexport interface MouseControlsParams {\n preset?: MouseControlPreset\n disabled?: boolean\n}\n\nexport type MouseActionType = ''|'scroll'|'drag'|'click'|'doubleClick'|'hover'|'clickPick'|'hoverPick'\nexport interface MouseAction {\n type: MouseActionType\n key: number\n button: number\n callback: MouseActionCallback\n}\n\n/**\n * Strings to describe mouse events (including optional keyboard modifiers).\n * Must contain an event type: \"scroll\", \"drag\", \"click\", \"doubleClick\",\n * \"hover\", \"clickPick\" or \"hoverPick\". Optionally contain one or more\n * (seperated by plus signs) keyboard modifiers: \"alt\", \"ctrl\", \"meta\" or\n * \"shift\". Can contain the mouse button performing the event: \"left\",\n * \"middle\" or \"right\". The type, key and button parts must be seperated by\n * dashes.\n *\n * @example\n * // triggered on scroll event (no key or button)\n * \"scroll\"\n *\n * @example\n * // triggered on scroll event while shift key is pressed\n * \"scroll-shift\"\n *\n * @example\n * // triggered on drag event with left mouse button\n * \"drag-left\"\n *\n * @example\n * // triggered on drag event with right mouse button\n * // while ctrl and shift keys are pressed\n * \"drag-right-ctrl+shift\"\n *\n * @typedef {String} TriggerString\n */\n\n/**\n * Get event type, key and button\n * @param {TriggerString} str - input trigger string\n * @return {Array} event type, key and button\n */\nfunction triggerFromString (str: string) {\n const tokens = str.split(/[-+]/)\n\n let type = ''\n if (tokens.includes('scroll')) type = 'scroll'\n if (tokens.includes('drag')) type = 'drag'\n if (tokens.includes('click')) type = 'click'\n if (tokens.includes('doubleClick')) type = 'doubleClick'\n if (tokens.includes('hover')) type = 'hover'\n if (tokens.includes('clickPick')) type = 'clickPick'\n if (tokens.includes('hoverPick')) type = 'hoverPick'\n\n let key = 0\n if (tokens.includes('alt')) key += 1\n if (tokens.includes('ctrl')) key += 2\n if (tokens.includes('meta')) key += 4\n if (tokens.includes('shift')) key += 8\n\n let button = 0\n if (tokens.includes('left')) button += 1\n if (tokens.includes('right')) button += 2\n if (tokens.includes('middle')) button += 4\n\n return [ type, key, button ] as [ MouseActionType, number, number ]\n}\n\n/**\n * Mouse controls\n */\nclass MouseControls {\n actionList: MouseAction[] = []\n mouse: MouseObserver\n\n disabled: boolean // Flag to disable all actions\n\n /**\n * @param {Stage} stage - the stage object\n * @param {Object} [params] - the parameters\n * @param {String} params.preset - one of \"default\", \"pymol\", \"coot\"\n * @param {String} params.disabled - flag to disable all actions\n */\n constructor (readonly stage: Stage, params: MouseControlsParams = {}) {\n this.mouse = stage.mouseObserver\n this.disabled = params.disabled || false\n this.preset(params.preset || 'default')\n }\n\n run (type: MouseActionType, ...args: any[]) {\n if (this.disabled) return\n\n const key = this.mouse.key || 0\n const button = this.mouse.buttons || 0\n\n this.actionList.forEach(a => {\n if (a.type === type && a.key === key && a.button === button) {\n (a.callback as any)(this.stage, ...args) // TODO\n }\n })\n }\n\n /**\n * Add a new mouse action triggered by an event, key and button combination.\n * The {@link MouseActions} class provides a number of static methods for\n * use as callback functions.\n *\n * @example\n * // change ambient light intensity on mouse scroll\n * // while the ctrl and shift keys are pressed\n * stage.mouseControls.add( \"scroll-ctrl+shift\", function( stage, delta ){\n * var ai = stage.getParameters().ambientIntensity;\n * stage.setParameters( { ambientIntensity: Math.max( 0, ai + delta / 50 ) } );\n * } );\n *\n * @example\n * // Call the MouseActions.zoomDrag method on mouse drag events\n * // with left and right mouse buttons simultaneous\n * stage.mouseControls.add( \"drag-left+right\", MouseActions.zoomDrag );\n *\n * @param {TriggerString} triggerStr - the trigger for the action\n * @param {function(stage: Stage, ...args: Any)} callback - the callback function for the action\n * @return {undefined}\n */\n add (triggerStr: string, callback: MouseActionCallback) {\n const [ type, key, button ] = triggerFromString(triggerStr)\n\n this.actionList.push({ type, key, button, callback })\n }\n\n /**\n * Remove a mouse action. The trigger string can contain an asterix (*)\n * as a wildcard for any key or mouse button. When the callback function\n * is given, only actions that call that function are removed.\n *\n * @example\n * // remove actions triggered solely by a scroll event\n * stage.mouseControls.remove( \"scroll\" );\n *\n * @example\n * // remove actions triggered by a scroll event, including\n * // those requiring a key pressed or mouse button used\n * stage.mouseControls.remove( \"scroll-*\" );\n *\n * @example\n * // remove actions triggered by a scroll event\n * // while the shift key is pressed\n * stage.mouseControls.remove( \"scroll-shift\" );\n *\n * @param {TriggerString} triggerStr - the trigger for the action\n * @param {Function} [callback] - the callback function for the action\n * @return {undefined}\n */\n remove (triggerStr: string, callback?: MouseActionCallback) {\n const wildcard = triggerStr.includes('*')\n const [ type, key, button ] = triggerFromString(triggerStr)\n\n const actionList = this.actionList.filter(function (a) {\n return !(\n (a.type === type || (wildcard && type === '')) &&\n (a.key === key || (wildcard && key === 0)) &&\n (a.button === button || (wildcard && button === 0)) &&\n (a.callback === callback || callback === undefined)\n )\n })\n\n this.actionList = actionList\n }\n\n /**\n * Set mouse action preset\n * @param {String} name - one of \"default\", \"pymol\", \"coot\"\n * @return {undefined}\n */\n preset (name: MouseControlPreset) {\n this.clear()\n\n const list = MouseActionPresets[ name ] || []\n\n list.forEach(action => this.add(action[0], action[1]))\n }\n\n /**\n * Remove all mouse actions\n * @return {undefined}\n */\n clear () {\n this.actionList.length = 0\n }\n}\n\nexport default MouseControls\n","/**\n * @file Key Actions\n * @author Alexander Rose \n * @private\n */\n\nimport Stage from '../stage/stage'\n\nexport type KeyActionCallback = (stage: Stage) => void\n\n/**\n * Key actions provided as static methods\n */\nclass KeyActions {\n /**\n * Stage auto view\n */\n static autoView (stage: Stage) {\n stage.autoView(1000)\n }\n\n /**\n * Toggle stage animations\n */\n static toggleAnimations (stage: Stage) {\n stage.animationControls.toggle()\n }\n\n /**\n * Toggle stage rocking\n */\n static toggleRock (stage: Stage) {\n stage.toggleRock()\n }\n\n /**\n * Toggle stage spinning\n */\n static toggleSpin (stage: Stage) {\n stage.toggleSpin()\n }\n\n /**\n * Toggle anti-aliasing\n */\n static toggleAntialiasing (stage: Stage) {\n const p = stage.getParameters()\n stage.setParameters({ sampleLevel: p.sampleLevel === -1 ? 0 : -1 })\n }\n}\n\ntype KeyActionPreset = [ string, KeyActionCallback ][]\nexport const KeyActionPresets = {\n default: [\n [ 'i', KeyActions.toggleSpin ],\n [ 'k', KeyActions.toggleRock ],\n [ 'p', KeyActions.toggleAnimations ],\n [ 'a', KeyActions.toggleAntialiasing ],\n [ 'r', KeyActions.autoView ]\n ] as KeyActionPreset\n}\n\nexport default KeyActions\n","/**\n * @file Key Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { KeyActionPresets, KeyActionCallback } from './key-actions'\nimport Stage from '../stage/stage'\n\nexport type KeyControlPreset = keyof typeof KeyActionPresets\nexport interface KeyControlsParams {\n preset?: KeyControlPreset\n disabled?: boolean\n}\n\nexport interface KeyAction {\n key: string,\n callback: KeyActionCallback\n}\n\n/**\n * Mouse controls\n */\nclass KeyControls {\n actionList: KeyAction[] = []\n\n disabled: boolean // Flag to disable all actions\n\n /**\n * @param {Stage} stage - the stage object\n * @param {Object} [params] - the parameters\n * @param {String} params.preset - one of \"default\"\n * @param {String} params.disabled - flag to disable all actions\n */\n constructor (readonly stage: Stage, params: KeyControlsParams = {}) {\n this.disabled = params.disabled || false\n this.preset(params.preset || 'default')\n }\n\n run (key: string) {\n if (this.disabled) return\n\n this.actionList.forEach(a => {\n if (a.key === key) {\n a.callback(this.stage)\n }\n })\n }\n\n /**\n * Add a key action triggered by pressing the given character.\n * The {@link KeyActions} class provides a number of static methods for\n * use as callback functions.\n *\n * @example\n * // call KeyActions.toggleRock when \"k\" is pressed\n * stage.keyControls.remove( \"k\", KeyActions.toggleRock );\n *\n * @param {Char} char - the key/character\n * @param {Function} callback - the callback function for the action\n * @return {undefined}\n */\n add (char: string, callback: KeyActionCallback) {\n this.actionList.push({ key: char, callback })\n }\n\n /**\n * Remove a key action. When the callback function\n * is given, only actions that call that function are removed.\n *\n * @example\n * // remove all actions triggered by pressing \"k\"\n * stage.keyControls.remove( \"k\" );\n *\n * @example\n * // remove action `toggleRock` triggered by pressing \"k\"\n * stage.keyControls.remove( \"k\", toggleRock );\n *\n * @param {Char} char - the key/character\n * @param {Function} [callback] - the callback function for the action\n * @return {undefined}\n */\n remove (char: string, callback: KeyActionCallback) {\n\n const actionList = this.actionList.filter(function (a) {\n return !(\n (a.key === char) &&\n (a.callback === callback || callback === undefined)\n )\n })\n\n this.actionList = actionList\n }\n\n /**\n * Set key action preset\n * @param {String} name - one of \"default\"\n * @return {undefined}\n */\n preset (name: KeyControlPreset) {\n this.clear()\n\n const list = KeyActionPresets[ name ] || []\n\n list.forEach(action => this.add(action[0], action[1]))\n }\n\n /**\n * Remove all key actions\n * @return {undefined}\n */\n clear () {\n this.actionList.length = 0\n }\n}\n\nexport default KeyControls\n","/**\n * @file Picking Behavior\n * @author Alexander Rose \n * @private\n */\n\nimport Stage from './stage'\nimport MouseObserver from './mouse-observer'\nimport Viewer from '../viewer/viewer'\nimport MouseControls from '../controls/mouse-controls'\n\nclass PickingBehavior {\n viewer: Viewer\n mouse: MouseObserver\n controls: MouseControls\n\n constructor (readonly stage: Stage) {\n this.stage = stage\n this.mouse = stage.mouseObserver\n this.controls = stage.mouseControls\n\n this.mouse.signals.clicked.add(this._onClick, this)\n this.mouse.signals.hovered.add(this._onHover, this)\n }\n\n _onClick (x: number, y: number) {\n const pickingProxy = this.stage.pickingControls.pick(x, y)\n this.stage.signals.clicked.dispatch(pickingProxy)\n this.controls.run('clickPick', pickingProxy)\n }\n\n _onHover (x: number, y: number) {\n const pickingProxy = this.stage.pickingControls.pick(x, y)\n if (pickingProxy && this.mouse.down.equals(this.mouse.position)) {\n this.stage.transformComponent = pickingProxy.component\n this.stage.transformAtom = pickingProxy.atom\n }\n this.stage.signals.hovered.dispatch(pickingProxy)\n this.controls.run('hoverPick', pickingProxy)\n }\n\n dispose () {\n this.mouse.signals.clicked.remove(this._onClick, this)\n this.mouse.signals.hovered.remove(this._onHover, this)\n }\n}\n\nexport default PickingBehavior\n","/**\n * @file Mouse Behavior\n * @author Alexander Rose \n * @private\n */\n\nimport Stage from './stage'\nimport MouseObserver from './mouse-observer'\nimport Viewer from '../viewer/viewer'\nimport MouseControls from '../controls/mouse-controls'\n\nclass MouseBehavior {\n viewer: Viewer\n mouse: MouseObserver\n controls: MouseControls\n domElement: HTMLCanvasElement\n\n constructor (readonly stage: Stage) {\n this.stage = stage\n this.mouse = stage.mouseObserver\n this.controls = stage.mouseControls\n\n this.mouse.signals.moved.add(this._onMove, this)\n this.mouse.signals.scrolled.add(this._onScroll, this)\n this.mouse.signals.dragged.add(this._onDrag, this)\n this.mouse.signals.clicked.add(this._onClick, this)\n this.mouse.signals.hovered.add(this._onHover, this)\n this.mouse.signals.doubleClicked.add(this._onDblclick, this)\n }\n\n _onMove (/* x, y */) {\n this.stage.tooltip.style.display = 'none'\n }\n\n _onScroll (delta: number) {\n this.controls.run('scroll', delta)\n }\n\n _onDrag (dx: number, dy: number) {\n this.controls.run('drag', dx, dy)\n }\n\n _onClick (x: number, y: number) {\n this.controls.run('click', x, y)\n }\n\n _onDblclick (x: number, y: number) {\n this.controls.run('doubleClick', x, y)\n }\n\n _onHover (x: number, y: number) {\n this.controls.run('hover', x, y)\n }\n\n dispose () {\n this.mouse.signals.moved.remove(this._onMove, this)\n this.mouse.signals.scrolled.remove(this._onScroll, this)\n this.mouse.signals.dragged.remove(this._onDrag, this)\n this.mouse.signals.clicked.remove(this._onClick, this)\n this.mouse.signals.hovered.remove(this._onHover, this)\n }\n}\n\nexport default MouseBehavior\n","/**\n * @file Animation Behavior\n * @author Alexander Rose \n * @private\n */\n\nimport Stage from './stage'\nimport Viewer from '../viewer/viewer'\nimport Stats from '../viewer/stats'\nimport AnimationControls from '../controls/animation-controls'\n\nclass AnimationBehavior {\n viewer: Viewer\n animationControls: AnimationControls\n\n constructor (readonly stage: Stage) {\n this.viewer = stage.viewer\n this.animationControls = stage.animationControls\n\n this.viewer.signals.ticked.add(this._onTick, this)\n }\n\n _onTick (stats: Stats) {\n this.animationControls.run(stats)\n }\n\n dispose () {\n this.viewer.signals.ticked.remove(this._onTick, this)\n }\n}\n\nexport default AnimationBehavior\n","/**\n * @file Key Behavior\n * @author Alexander Rose \n * @private\n */\n\nimport { SupportsPassiveEventHandler } from '../globals'\nimport Stage from './stage'\nimport Viewer from '../viewer/viewer'\nimport KeyControls from '../controls/key-controls'\n\nconst passive = SupportsPassiveEventHandler ? { passive: true } : false\n\nclass KeyBehavior {\n viewer: Viewer\n controls: KeyControls\n domElement: HTMLCanvasElement\n\n /**\n * @param {Stage} stage - the stage object\n */\n constructor (readonly stage: Stage) {\n this.stage = stage\n this.controls = stage.keyControls\n this.domElement = stage.viewer.renderer.domElement\n\n // ensure the domElement is focusable\n this.domElement.setAttribute('tabIndex', '-1')\n this.domElement.style.outline = 'none'\n\n this._focusDomElement = this._focusDomElement.bind(this)\n this._onKeydown = this._onKeydown.bind(this)\n this._onKeyup = this._onKeyup.bind(this)\n this._onKeypress = this._onKeypress.bind(this)\n\n this.domElement.addEventListener('mousedown', this._focusDomElement)\n this.domElement.addEventListener('touchstart', this._focusDomElement, passive as any) // TODO\n this.domElement.addEventListener('keydown', this._onKeydown)\n this.domElement.addEventListener('keyup', this._onKeyup)\n this.domElement.addEventListener('keypress', this._onKeypress)\n }\n\n /**\n * handle key down\n * @param {Event} event - key event\n * @return {undefined}\n */\n _onKeydown (/* event */) {\n // console.log( \"down\", event.keyCode, String.fromCharCode( event.keyCode ) );\n }\n\n /**\n * handle key up\n * @param {Event} event - key event\n * @return {undefined}\n */\n _onKeyup (/* event */) {\n // console.log( \"up\", event.keyCode, String.fromCharCode( event.keyCode ) );\n }\n\n /**\n * handle key press\n * @param {Event} event - key event\n * @return {undefined}\n */\n _onKeypress (event: KeyboardEvent) {\n // console.log( \"press\", event.keyCode, String.fromCharCode( event.keyCode ) );\n let pressedKey: string;\n if (\"key\" in KeyboardEvent.prototype) {\n pressedKey = event.key;\n // some mobile browsers don't support this attribute\n } else {\n pressedKey = String.fromCharCode(event.which || event.keyCode);\n }\n this.controls.run(pressedKey);\n }\n\n _focusDomElement () {\n this.domElement.focus()\n }\n\n dispose () {\n this.domElement.removeEventListener('mousedown', this._focusDomElement)\n this.domElement.removeEventListener('touchstart', this._focusDomElement, passive as any) // TODO\n this.domElement.removeEventListener('keydown', this._onKeypress)\n this.domElement.removeEventListener('keyup', this._onKeypress)\n this.domElement.removeEventListener('keypress', this._onKeypress)\n }\n}\n\nexport default KeyBehavior\n","/**\n * @file Annotation\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector2, Vector3 } from 'three'\n\nimport { defaults } from '../utils'\nimport { smoothstep } from '../math/math-utils'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\nimport Component from './component'\n\nexport interface AnnotationParams {\n offsetX?: number\n offsetY?: number\n visible?: boolean\n}\n\n/**\n * Annotation HTML element floating on top of a position rendered in 3d\n */\nexport default class Annotation {\n offsetX: number\n offsetY: number\n visible: boolean\n\n stage: Stage\n viewer: Viewer\n element: HTMLElement\n\n private _viewerPosition: Vector3\n private _canvasPosition: Vector2\n private _cameraPosition: Vector3\n private _clientRect: ClientRect\n\n /**\n * @param {Component} component - the associated component\n * @param {Vector3} position - position in 3d\n * @param {String|Element} content - HTML content\n * @param {Object} [params] - parameters\n * @param {Integer} params.offsetX - 2d offset in x direction\n * @param {Integer} params.offsetY - 2d offset in y direction\n * @param {Boolean} params.visible - visibility flag\n */\n constructor (readonly component: Component, readonly position: Vector3, content: string|HTMLElement, params: AnnotationParams = {}) {\n this.offsetX = defaults(params.offsetX, 0)\n this.offsetY = defaults(params.offsetY, 0)\n this.visible = defaults(params.visible, true)\n\n this.stage = component.stage\n this.viewer = component.stage.viewer\n\n this._viewerPosition = new Vector3()\n this._updateViewerPosition()\n this._canvasPosition = new Vector2()\n this._cameraPosition = new Vector3()\n\n this.element = document.createElement('div')\n Object.assign(this.element.style, {\n display: 'block',\n position: 'absolute',\n pointerEvents: 'none',\n whiteSpace: 'nowrap',\n left: '-10000px'\n })\n\n this.viewer.wrapper.appendChild(this.element)\n this.setContent(content)\n this.updateVisibility()\n this.viewer.signals.rendered.add(this._update, this)\n this.component.signals.matrixChanged.add(this._updateViewerPosition, this)\n }\n\n /**\n * Set HTML content of the annotation\n * @param {String|Element} value - HTML content\n * @return {undefined}\n */\n setContent (value: string|HTMLElement) {\n const displayValue = this.element.style.display\n if (displayValue === 'none') {\n this.element.style.left = '-10000px'\n this.element.style.display = 'block'\n }\n\n if (value instanceof HTMLElement) {\n this.element.appendChild(value)\n } else {\n const content = document.createElement('div')\n content.innerText = value\n Object.assign(content.style, {\n backgroundColor: 'rgba( 0, 0, 0, 0.6 )',\n color: 'lightgrey',\n padding: '8px',\n fontFamily: 'sans-serif',\n })\n this.element.appendChild(content)\n }\n\n this._clientRect = this.element.getBoundingClientRect()\n\n if (displayValue === 'none') {\n this.element.style.display = displayValue\n }\n }\n\n /**\n * Set visibility of the annotation\n * @param {Boolean} value - visibility flag\n * @return {undefined}\n */\n setVisibility (value: boolean) {\n this.visible = value\n this.updateVisibility()\n }\n\n getVisibility () {\n return this.visible && this.component.parameters.visible\n }\n\n updateVisibility () {\n this.element.style.display = this.getVisibility() ? 'block' : 'none'\n }\n\n _updateViewerPosition () {\n this._viewerPosition\n .copy(this.position)\n .applyMatrix4(this.component.matrix)\n }\n\n _update () {\n if (!this.getVisibility()) return\n\n const s = this.element.style\n const cp = this._canvasPosition\n const vp = this._viewerPosition\n const cr = this._clientRect\n\n this._cameraPosition.copy(vp)\n .add(this.viewer.translationGroup.position)\n .applyMatrix4(this.viewer.rotationGroup.matrix)\n .sub(this.viewer.camera.position)\n\n if (this._cameraPosition.z < 0) {\n s.display = 'none'\n return\n } else {\n s.display = 'block'\n }\n\n const depth = this._cameraPosition.length()\n const fog = this.viewer.scene.fog as any // TODO\n\n s.opacity = (1 - smoothstep(fog.near, fog.far, depth)).toString()\n s.zIndex = (Math.round((fog.far - depth) * 100)).toString()\n\n this.stage.viewerControls.getPositionOnCanvas(vp, cp)\n\n s.bottom = (this.offsetX + cp.y + cr.height / 2) + 'px'\n s.left = (this.offsetY + cp.x - cr.width / 2) + 'px'\n }\n\n /**\n * Safely remove the annotation\n * @return {undefined}\n */\n dispose () {\n this.viewer.wrapper.removeChild(this.element)\n this.viewer.signals.ticked.remove(this._update, this)\n this.component.signals.matrixChanged.remove(this._updateViewerPosition, this)\n }\n}","/**\n * @file Component Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4, Quaternion } from 'three'\nimport * as signalsWrapper from 'signals'\n\nimport { ensureVector3 } from '../utils'\nimport Component from '../component/component'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\n\nconst tmpRotateMatrix = new Matrix4()\nconst tmpRotateVector = new Vector3()\nconst tmpRotateQuaternion = new Quaternion()\n\n/**\n * Component controls\n */\nclass ComponentControls {\n signals = {\n changed: new signalsWrapper.Signal()\n }\n\n stage: Stage\n viewer: Viewer\n\n /**\n * @param {Component} component - the component object\n */\n constructor (readonly component: Component) {\n this.stage = component.stage\n this.viewer = component.stage.viewer\n }\n\n /**\n * component center position\n * @type {Vector3}\n */\n get position () {\n return this.component.position\n }\n\n /**\n * component rotation\n * @type {Quaternion}\n */\n get rotation () {\n return this.component.quaternion\n }\n\n /**\n * Trigger render and emit changed event\n * @emits {ComponentControls.signals.changed}\n * @return {undefined}\n */\n changed () {\n this.component.updateMatrix()\n this.viewer.requestRender()\n this.signals.changed.dispatch()\n }\n\n /**\n * spin component on axis\n * @param {Vector3|Array} axis - rotation axis\n * @param {Number} angle - amount to spin\n * @return {undefined}\n */\n spin (axis: Vector3, angle: number) {\n tmpRotateMatrix.getInverse(this.viewer.rotationGroup.matrix)\n tmpRotateVector\n .copy(ensureVector3(axis)).applyMatrix4(tmpRotateMatrix)\n\n tmpRotateMatrix.extractRotation(this.component.transform)\n tmpRotateMatrix.premultiply(this.viewer.rotationGroup.matrix)\n tmpRotateMatrix.getInverse(tmpRotateMatrix)\n\n tmpRotateVector.copy(ensureVector3(axis))\n tmpRotateVector.applyMatrix4(tmpRotateMatrix)\n tmpRotateMatrix.makeRotationAxis(tmpRotateVector, angle)\n tmpRotateQuaternion.setFromRotationMatrix(tmpRotateMatrix)\n\n this.component.quaternion.premultiply(tmpRotateQuaternion)\n this.changed()\n }\n}\n\nexport default ComponentControls\n","/**\n * @file Radius Factory\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { NucleicBackboneAtoms } from '../structure/structure-constants'\nimport AtomProxy from '../proxy/atom-proxy'\n\nexport const RadiusFactoryTypes = {\n '': '',\n 'vdw': 'by vdW radius',\n 'covalent': 'by covalent radius',\n 'sstruc': 'by secondary structure',\n 'bfactor': 'by bfactor',\n 'size': 'size',\n 'data': 'data',\n 'explicit' : 'explicit'\n}\nexport type RadiusType = keyof typeof RadiusFactoryTypes\n\nexport interface RadiusParams {\n type?: RadiusType\n scale?: number\n size?: number\n data?: { [k: number]: number }\n}\n\nclass RadiusFactory {\n max = 10\n\n static types = RadiusFactoryTypes\n\n readonly type: RadiusType\n readonly scale: number\n readonly size: number\n readonly data: { [k: number]: number }\n\n constructor (params: RadiusParams = {}) {\n this.type = defaults(params.type, 'size')\n this.scale = defaults(params.scale, 1)\n this.size = defaults(params.size, 1)\n this.data = defaults(params.data, {})\n }\n\n atomRadius (a: AtomProxy) {\n let r\n\n switch (this.type) {\n case 'vdw':\n r = a.vdw\n break\n\n case 'covalent':\n r = a.covalent\n break\n\n case 'bfactor':\n r = a.bfactor || 1.0\n break\n\n case 'sstruc':\n const sstruc = a.sstruc\n if (sstruc === 'h') {\n r = 0.25\n } else if (sstruc === 'g') {\n r = 0.25\n } else if (sstruc === 'i') {\n r = 0.25\n } else if (sstruc === 'e') {\n r = 0.25\n } else if (sstruc === 'b') {\n r = 0.25\n } else if (NucleicBackboneAtoms.includes(a.atomname)) {\n r = 0.4\n } else {\n r = 0.1\n }\n break\n\n case 'data':\n r = defaults(this.data[ a.index ], 1.0)\n break\n\n case 'explicit':\n // defaults is inappropriate as AtomProxy.radius returns\n // null for missing radii\n r = a.radius\n if (r === null) r = this.size\n break\n\n default:\n r = this.size\n break\n }\n\n return Math.min(r * this.scale, this.max)\n }\n\n}\n\nexport default RadiusFactory\n","/**\n * @file Principal Axes\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4, Quaternion } from 'three'\n\nimport {\n Matrix, meanRows, subRows, transpose, multiplyABt, svd\n} from './matrix-utils'\nimport { projectPointOnVector } from './vector-utils'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\n\nconst negateVector = new Vector3(-1, -1, -1)\nconst tmpMatrix = new Matrix4()\n\n/**\n * Principal axes\n */\nclass PrincipalAxes {\n begA: Vector3\n endA: Vector3\n begB: Vector3\n endB: Vector3\n begC: Vector3\n endC: Vector3\n\n center: Vector3\n\n vecA: Vector3\n vecB: Vector3\n vecC: Vector3\n\n normVecA: Vector3\n normVecB: Vector3\n normVecC: Vector3\n\n /**\n * @param {Matrix} points - 3 by N matrix\n */\n constructor (points: Matrix) {\n // console.time( \"PrincipalAxes\" );\n\n const n = points.rows\n const n3 = n / 3\n const pointsT = new Matrix(n, 3)\n const A = new Matrix(3, 3)\n const W = new Matrix(1, 3)\n const U = new Matrix(3, 3)\n const V = new Matrix(3, 3)\n\n // calculate\n const mean = meanRows(points)\n subRows(points, mean)\n transpose(pointsT, points)\n multiplyABt(A, pointsT, pointsT)\n svd(A, W, U, V)\n\n // console.log( points, pointsT, mean )\n // console.log( n, A, W, U, V );\n\n // center\n const vm = new Vector3(mean[0], mean[1], mean[2])\n\n // normalized\n const van = new Vector3(U.data[0], U.data[3], U.data[6])\n const vbn = new Vector3(U.data[1], U.data[4], U.data[7])\n const vcn = new Vector3(U.data[2], U.data[5], U.data[8])\n\n // scaled\n const va = van.clone().multiplyScalar(Math.sqrt(W.data[0] / n3))\n const vb = vbn.clone().multiplyScalar(Math.sqrt(W.data[1] / n3))\n const vc = vcn.clone().multiplyScalar(Math.sqrt(W.data[2] / n3))\n\n // points\n this.begA = vm.clone().sub(va)\n this.endA = vm.clone().add(va)\n this.begB = vm.clone().sub(vb)\n this.endB = vm.clone().add(vb)\n this.begC = vm.clone().sub(vc)\n this.endC = vm.clone().add(vc)\n\n //\n\n this.center = vm\n\n this.vecA = va\n this.vecB = vb\n this.vecC = vc\n\n this.normVecA = van\n this.normVecB = vbn\n this.normVecC = vcn\n\n // console.timeEnd( \"PrincipalAxes\" );\n }\n\n /**\n * Get the basis matrix descriping the axes\n * @param {Matrix4} [optionalTarget] - target object\n * @return {Matrix4} the basis\n */\n getBasisMatrix (optionalTarget = new Matrix4()) {\n const basis = optionalTarget\n\n basis.makeBasis(this.normVecB, this.normVecA, this.normVecC)\n if (basis.determinant() < 0) {\n basis.scale(negateVector)\n }\n\n return basis\n }\n\n /**\n * Get a quaternion descriping the axes rotation\n * @param {Quaternion} [optionalTarget] - target object\n * @return {Quaternion} the rotation\n */\n getRotationQuaternion (optionalTarget = new Quaternion()) {\n const q = optionalTarget\n q.setFromRotationMatrix(this.getBasisMatrix(tmpMatrix))\n\n return q.inverse()\n }\n\n /**\n * Get the scale/length for each dimension for a box around the axes\n * to enclose the atoms of a structure\n * @param {Structure|StructureView} structure - the structure\n * @return {{d1a: Number, d2a: Number, d3a: Number, d1b: Number, d2b: Number, d3b: Number}} scale\n */\n getProjectedScaleForAtoms (structure: Structure) {\n let d1a = -Infinity\n let d1b = -Infinity\n let d2a = -Infinity\n let d2b = -Infinity\n let d3a = -Infinity\n let d3b = -Infinity\n\n const p = new Vector3()\n const t = new Vector3()\n\n const center = this.center\n const ax1 = this.normVecA\n const ax2 = this.normVecB\n const ax3 = this.normVecC\n\n structure.eachAtom(function (ap: AtomProxy) {\n projectPointOnVector(p.copy(ap as any), ax1, center) // TODO\n const dp1 = t.subVectors(p, center).normalize().dot(ax1)\n const dt1 = p.distanceTo(center)\n if (dp1 > 0) {\n if (dt1 > d1a) d1a = dt1\n } else {\n if (dt1 > d1b) d1b = dt1\n }\n\n projectPointOnVector(p.copy(ap as any), ax2, center)\n const dp2 = t.subVectors(p, center).normalize().dot(ax2)\n const dt2 = p.distanceTo(center)\n if (dp2 > 0) {\n if (dt2 > d2a) d2a = dt2\n } else {\n if (dt2 > d2b) d2b = dt2\n }\n\n projectPointOnVector(p.copy(ap as any), ax3, center)\n const dp3 = t.subVectors(p, center).normalize().dot(ax3)\n const dt3 = p.distanceTo(center)\n if (dp3 > 0) {\n if (dt3 > d3a) d3a = dt3\n } else {\n if (dt3 > d3b) d3b = dt3\n }\n })\n\n return {\n d1a: d1a,\n d2a: d2a,\n d3a: d3a,\n d1b: -d1b,\n d2b: -d2b,\n d3b: -d3b\n }\n }\n}\n\nexport default PrincipalAxes\n","/**\n * @file Filtered Volume\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport Volume from './volume'\nimport { Box3, Matrix4, Matrix3, Vector3 } from 'three';\n\nclass FilteredVolume {\n volume: Volume\n data: Float32Array\n position: Float32Array\n atomindex: Int32Array\n _filterHash: string\n _dataBuffer: ArrayBuffer\n _positionBuffer: ArrayBuffer\n _atomindexBuffer: ArrayBuffer\n getValueForSigma: typeof Volume.prototype.getValueForSigma\n getSigmaForValue: typeof Volume.prototype.getSigmaForValue\n getDataAtomindex: typeof Volume.prototype.getDataAtomindex\n getDataPosition: typeof Volume.prototype.getDataPosition\n getDataColor: typeof Volume.prototype.getDataColor\n getDataPicking: typeof Volume.prototype.getDataPicking\n getDataSize: typeof Volume.prototype.getDataSize\n\n\n constructor (volume: Volume, minValue?: number, maxValue?: number, outside?: boolean) {\n this.volume = volume\n this.setFilter(minValue, maxValue, outside)\n }\n\n get header () { return this.volume.header }\n get matrix (): Matrix4 { return this.volume.matrix }\n get normalMatrix (): Matrix3 { return this.volume.normalMatrix }\n get inverseMatrix (): Matrix4 { return this.volume.inverseMatrix }\n get center (): Vector3 { return this.volume.center }\n get boundingBox (): Box3 { return this.volume.boundingBox }\n get min () { return this.volume.min }\n get max () { return this.volume.max }\n get mean () { return this.volume.mean }\n get rms () { return this.volume.rms }\n\n _getFilterHash (minValue: number, maxValue: number, outside: boolean) {\n return JSON.stringify([ minValue, maxValue, outside ])\n }\n\n setFilter (minValue: number|undefined, maxValue: number|undefined, outside: boolean|undefined) {\n if (isNaN(minValue) && this.header) {\n minValue = this.header.DMEAN + 2.0 * this.header.ARMS\n }\n\n minValue = (minValue !== undefined && !isNaN(minValue)) ? minValue : -Infinity\n maxValue = defaults(maxValue, Infinity) as number\n outside = defaults(outside, false) as boolean\n\n const data = this.volume.data\n const position = this.volume.position\n const atomindex = this.volume.atomindex\n\n const filterHash = this._getFilterHash(minValue, maxValue, outside)\n\n if (filterHash === this._filterHash) {\n // already filtered\n return\n } else if (minValue === -Infinity && maxValue === Infinity) {\n this.data = data\n this.position = position\n this.atomindex = atomindex!\n } else {\n const n = data.length\n\n if (!this._dataBuffer) {\n // ArrayBuffer for re-use as Float32Array backend\n\n this._dataBuffer = new ArrayBuffer(n * 4)\n this._positionBuffer = new ArrayBuffer(n * 3 * 4)\n if (atomindex) this._atomindexBuffer = new ArrayBuffer(n * 4)\n }\n\n const filteredData = new Float32Array(this._dataBuffer)\n const filteredPosition = new Float32Array(this._positionBuffer)\n let filteredAtomindex\n if (atomindex) filteredAtomindex = new Uint32Array(this._atomindexBuffer)\n\n let j = 0\n\n for (let i = 0; i < n; ++i) {\n const i3 = i * 3\n const v = data[ i ]\n\n if ((!outside && v >= minValue && v <= maxValue) ||\n (outside && (v < minValue || v > maxValue))\n ) {\n const j3 = j * 3\n\n filteredData[ j ] = v\n\n filteredPosition[ j3 + 0 ] = position[ i3 + 0 ]\n filteredPosition[ j3 + 1 ] = position[ i3 + 1 ]\n filteredPosition[ j3 + 2 ] = position[ i3 + 2 ]\n\n if (atomindex && filteredAtomindex) filteredAtomindex[ j ] = atomindex[ i ]\n\n j += 1\n }\n }\n\n // set views\n\n this.data = new Float32Array(this._dataBuffer, 0, j)\n this.position = new Float32Array(this._positionBuffer, 0, j * 3)\n if (atomindex) this.atomindex = new Int32Array(this._atomindexBuffer, 0, j)\n }\n\n this._filterHash = filterHash\n }\n}\n\nFilteredVolume.prototype.getValueForSigma = Volume.prototype.getValueForSigma\nFilteredVolume.prototype.getSigmaForValue = Volume.prototype.getSigmaForValue\n\nFilteredVolume.prototype.getDataAtomindex = Volume.prototype.getDataAtomindex\nFilteredVolume.prototype.getDataPosition = Volume.prototype.getDataPosition\nFilteredVolume.prototype.getDataColor = Volume.prototype.getDataColor\nFilteredVolume.prototype.getDataPicking = Volume.prototype.getDataPicking\nFilteredVolume.prototype.getDataSize = Volume.prototype.getDataSize\n\nexport default FilteredVolume\n","/**\n * @file Bond Hash\n * @author Alexander Rose \n * @private\n */\n\nimport BondStore from './bond-store'\nimport { createAdjacencyList } from '../utils/adjacency-list'\n\nclass BondHash {\n countArray: Uint8Array\n offsetArray: Int32Array\n indexArray: Int32Array\n\n constructor (bondStore: BondStore, atomCount: number) {\n const al = createAdjacencyList({\n nodeArray1: bondStore.atomIndex1,\n nodeArray2: bondStore.atomIndex2,\n edgeCount: bondStore.count,\n nodeCount: atomCount\n })\n\n this.countArray = al.countArray\n this.offsetArray = al.offsetArray\n this.indexArray = al.indexArray\n }\n}\n\nexport default BondHash\n","/**\n * @file Bond Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Bond store\n */\nexport default class BondStore extends Store {\n atomIndex1: Uint32Array\n atomIndex2: Uint32Array\n bondOrder: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'atomIndex1', 1, 'int32' ],\n [ 'atomIndex2', 1, 'int32' ],\n [ 'bondOrder', 1, 'int8' ]\n ] as StoreField[]\n }\n\n addBond (atom1: AtomProxy, atom2: AtomProxy, bondOrder?: number) {\n this.growIfFull()\n\n const i = this.count\n const ai1 = atom1.index\n const ai2 = atom2.index\n\n if (ai1 < ai2) {\n this.atomIndex1[ i ] = ai1\n this.atomIndex2[ i ] = ai2\n } else {\n this.atomIndex2[ i ] = ai1\n this.atomIndex1[ i ] = ai2\n }\n if (bondOrder) this.bondOrder[ i ] = bondOrder\n\n this.count += 1\n }\n\n addBondIfConnected (atom1: AtomProxy, atom2: AtomProxy, bondOrder?: number) {\n if (atom1.connectedTo(atom2)) {\n this.addBond(atom1, atom2, bondOrder)\n return true\n }\n\n return false\n }\n}","/**\n * @file Atom Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Atom store\n */\nexport default class AtomStore extends Store {\n residueIndex: Uint32Array\n atomTypeId: Uint16Array\n\n x: Float32Array\n y: Float32Array\n z: Float32Array\n serial: Int32Array\n bfactor: Float32Array\n altloc: Uint8Array\n occupancy: Float32Array\n\n partialCharge?: Float32Array\n formalCharge?: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'residueIndex', 1, 'uint32' ],\n [ 'atomTypeId', 1, 'uint16' ],\n\n [ 'x', 1, 'float32' ],\n [ 'y', 1, 'float32' ],\n [ 'z', 1, 'float32' ],\n [ 'serial', 1, 'int32' ],\n [ 'bfactor', 1, 'float32' ],\n [ 'altloc', 1, 'uint8' ],\n [ 'occupancy', 1, 'float32' ]\n ] as StoreField[]\n }\n\n setAltloc (i: number, str: string) {\n this.altloc[ i ] = str.charCodeAt(0)\n }\n\n getAltloc (i: number) {\n const code = this.altloc[ i ]\n return code ? String.fromCharCode(code) : ''\n }\n}","/**\n * @file Residue Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Residue store\n */\nexport default class ResidueStore extends Store {\n chainIndex: Uint32Array\n atomOffset: Uint32Array\n atomCount: Uint32Array\n residueTypeId: Uint16Array\n\n resno: Uint32Array\n sstruc: Uint8Array\n inscode: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'chainIndex', 1, 'uint32' ],\n [ 'atomOffset', 1, 'uint32' ],\n [ 'atomCount', 1, 'uint32' ],\n [ 'residueTypeId', 1, 'uint16' ],\n\n [ 'resno', 1, 'int32' ],\n [ 'sstruc', 1, 'uint8' ],\n [ 'inscode', 1, 'uint8' ]\n ] as StoreField[]\n }\n\n setSstruc (i: number, str: string) {\n this.sstruc[ i ] = str.charCodeAt(0)\n }\n\n getSstruc (i: number) {\n const code = this.sstruc[ i ]\n return code ? String.fromCharCode(code) : ''\n }\n\n setInscode (i: number, str: string) {\n this.inscode[ i ] = str.charCodeAt(0)\n }\n\n getInscode (i: number) {\n const code = this.inscode[ i ]\n return code ? String.fromCharCode(code) : ''\n }\n}","/**\n * @file Chain Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Chain store\n */\nexport default class ChainStore extends Store {\n entityIndex: Uint16Array\n modelIndex: Uint16Array\n residueOffset: Uint32Array\n residueCount: Uint32Array\n\n chainname: Uint8Array\n chainid: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'entityIndex', 1, 'uint16' ],\n [ 'modelIndex', 1, 'uint16' ],\n [ 'residueOffset', 1, 'uint32' ],\n [ 'residueCount', 1, 'uint32' ],\n\n [ 'chainname', 4, 'uint8' ],\n [ 'chainid', 4, 'uint8' ]\n ] as StoreField[]\n }\n\n setChainname (i: number, str: string) {\n const j = 4 * i\n this.chainname[ j ] = str.charCodeAt(0)\n this.chainname[ j + 1 ] = str.charCodeAt(1)\n this.chainname[ j + 2 ] = str.charCodeAt(2)\n this.chainname[ j + 3 ] = str.charCodeAt(3)\n }\n\n getChainname (i: number) {\n let chainname = ''\n for (let k = 0; k < 4; ++k) {\n const code = this.chainname[ 4 * i + k ]\n if (code) {\n chainname += String.fromCharCode(code)\n } else {\n break\n }\n }\n return chainname\n }\n\n setChainid (i: number, str: string) {\n const j = 4 * i\n this.chainid[ j ] = str.charCodeAt(0)\n this.chainid[ j + 1 ] = str.charCodeAt(1)\n this.chainid[ j + 2 ] = str.charCodeAt(2)\n this.chainid[ j + 3 ] = str.charCodeAt(3)\n }\n\n getChainid (i: number) {\n let chainid = ''\n for (let k = 0; k < 4; ++k) {\n const code = this.chainid[ 4 * i + k ]\n if (code) {\n chainid += String.fromCharCode(code)\n } else {\n break\n }\n }\n return chainid\n }\n}\n","/**\n * @file Model Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Model store\n */\nexport default class ModelStore extends Store {\n\tchainOffset: Uint32Array\n\tchainCount: Uint32Array\n\n get _defaultFields () {\n return [\n [ 'chainOffset', 1, 'uint32' ],\n [ 'chainCount', 1, 'uint32' ]\n ] as StoreField[]\n }\n}","/**\n * @file Helixorient\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport { ColormakerParameters } from '../color/colormaker'\nimport { AtomPicker } from '../utils/picker'\nimport RadiusFactory, { RadiusParams } from '../utils/radius-factory'\nimport { copyArray } from '../math/array-utils'\nimport { projectPointOnVector } from '../math/vector-utils'\nimport Polymer from '../proxy/polymer'\n\nexport interface HelixIterator {\n size: number\n next: () => Vector3\n get: (idx: number) => Vector3\n reset: () => void\n}\n\nexport interface HelixPosition {\n center: Float32Array\n axis: Float32Array\n bending: Float32Array\n radius: Float32Array\n rise: Float32Array\n twist: Float32Array\n resdir: Float32Array\n}\n\nclass Helixorient {\n size: number\n\n constructor (readonly polymer: Polymer) {\n this.size = polymer.residueCount\n }\n\n getCenterIterator (smooth = 0): HelixIterator {\n const center = this.getPosition().center\n const size = center.length / 3\n\n let i = 0\n let j = -1\n\n const cache = [\n new Vector3(),\n new Vector3(),\n new Vector3(),\n new Vector3()\n ]\n\n function next (this: HelixIterator) {\n const vector = this.get(j)\n j += 1\n return vector\n }\n\n function get (idx: number) {\n idx = Math.min(size - 1, Math.max(0, idx))\n const v = cache[ i % 4 ]\n const idx3 = 3 * idx\n v.fromArray(center as any, idx3) // TODO\n if (smooth) {\n const w = Math.min(smooth, idx, size - idx - 1)\n for (let k = 1; k <= w; ++k) {\n const l = k * 3\n const t = (w + 1 - k) / (w + 1)\n v.x += t * center[ idx3 - l + 0 ] + t * center[ idx3 + l + 0 ]\n v.y += t * center[ idx3 - l + 1 ] + t * center[ idx3 + l + 1 ]\n v.z += t * center[ idx3 - l + 2 ] + t * center[ idx3 + l + 2 ]\n }\n v.x /= w + 1\n v.y /= w + 1\n v.z /= w + 1\n }\n i += 1\n return v\n }\n\n function reset () {\n i = 0\n j = -1\n }\n\n return { size, next, get, reset }\n }\n\n getColor (params: { scheme: string } & ColormakerParameters) {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const residueIndexStart = polymer.residueIndexStart\n\n const col = new Float32Array(n * 3)\n\n const p = params || {}\n p.structure = structure\n\n const colormaker = ColormakerRegistry.getScheme(p)\n\n const rp = structure.getResidueProxy()\n const ap = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n rp.index = residueIndexStart + i\n ap.index = rp.traceAtomIndex\n\n colormaker.atomColorToArray(ap, col, i * 3)\n }\n\n return {\n 'color': col\n }\n }\n\n getPicking () {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const residueIndexStart = polymer.residueIndexStart\n\n const pick = new Float32Array(n)\n const rp = structure.getResidueProxy()\n\n for (let i = 0; i < n; ++i) {\n rp.index = residueIndexStart + i\n pick[ i ] = rp.traceAtomIndex\n }\n\n return {\n 'picking': new AtomPicker(pick, structure)\n }\n }\n\n getSize (params: RadiusParams) {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const residueIndexStart = polymer.residueIndexStart\n\n const size = new Float32Array(n)\n const radiusFactory = new RadiusFactory(params)\n\n const rp = structure.getResidueProxy()\n const ap = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n rp.index = residueIndexStart + i\n ap.index = rp.traceAtomIndex\n size[ i ] = radiusFactory.atomRadius(ap)\n }\n\n return { size }\n }\n\n getPosition (): HelixPosition {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const n3 = n - 3\n\n const center = new Float32Array(3 * n)\n const axis = new Float32Array(3 * n)\n const diff = new Float32Array(n)\n const radius = new Float32Array(n)\n const rise = new Float32Array(n)\n const twist = new Float32Array(n)\n const resdir = new Float32Array(3 * n)\n\n const r12 = new Vector3()\n const r23 = new Vector3()\n const r34 = new Vector3()\n\n const diff13 = new Vector3()\n const diff24 = new Vector3()\n\n const v1 = new Vector3()\n const v2 = new Vector3()\n const vt = new Vector3()\n\n const _axis = new Vector3()\n const _prevAxis = new Vector3()\n\n const _resdir = new Vector3()\n const _center = new Vector3(0, 0, 0)\n\n const type = 'trace'\n const a1 = structure.getAtomProxy()\n const a2 = structure.getAtomProxy(polymer.getAtomIndexByType(0, type))\n const a3 = structure.getAtomProxy(polymer.getAtomIndexByType(1, type))\n const a4 = structure.getAtomProxy(polymer.getAtomIndexByType(2, type))\n\n for (let i = 0; i < n3; ++i) {\n a1.index = a2.index\n a2.index = a3.index\n a3.index = a4.index\n a4.index = polymer.getAtomIndexByType(i + 3, type)! // TODO\n\n const j = 3 * i\n\n // ported from GROMACS src/tools/gmx_helixorient.c\n\n r12.subVectors(a2 as any, a1 as any) // TODO\n r23.subVectors(a3 as any, a2 as any) // TODO\n r34.subVectors(a4 as any, a3 as any) // TODO\n\n diff13.subVectors(r12, r23)\n diff24.subVectors(r23, r34)\n\n _axis.crossVectors(diff13, diff24).normalize()\n _axis.toArray(axis as any, j) // TODO\n\n if (i > 0) {\n diff[ i ] = _axis.angleTo(_prevAxis)\n }\n\n const tmp = Math.cos(diff13.angleTo(diff24))\n twist[ i ] = 180.0 / Math.PI * Math.acos(tmp)\n\n const diff13Length = diff13.length()\n const diff24Length = diff24.length()\n\n radius[ i ] = (\n Math.sqrt(diff24Length * diff13Length) /\n // clamp, to avoid instabilities for when\n // angle between diff13 and diff24 is near 0\n Math.max(2.0, 2.0 * (1.0 - tmp))\n )\n\n rise[ i ] = Math.abs(r23.dot(_axis))\n\n //\n\n v1.copy(diff13).multiplyScalar(radius[ i ] / diff13Length)\n v2.copy(diff24).multiplyScalar(radius[ i ] / diff24Length)\n\n v1.subVectors(a2 as any, v1) // TODO\n v2.subVectors(a3 as any, v2) // TODO\n\n v1.toArray(center as any, j + 3) // TODO\n v2.toArray(center as any, j + 6) // TODO\n\n //\n\n _resdir.subVectors(a1 as any, _center) // TODO\n _resdir.toArray(resdir as any, j) // TODO\n\n _prevAxis.copy(_axis)\n _center.copy(v1)\n }\n\n //\n\n // calc axis as dir of second and third center pos\n // project first traceAtom onto axis to get first center pos\n v1.fromArray(center as any, 3) // TODO\n v2.fromArray(center as any, 6) // TODO\n _axis.subVectors(v1, v2).normalize()\n // _center.copy( res[ 0 ].getTraceAtom() );\n a1.index = polymer.getAtomIndexByType(0, type)! // TODO\n _center.copy(a1 as any) // TODO\n vt.copy(a1 as any) // TODO\n projectPointOnVector(vt, _axis, v1)\n vt.toArray(center as any, 0) // TODO\n\n // calc first resdir\n _resdir.subVectors(_center, v1)\n _resdir.toArray(resdir as any, 0) // TODO\n\n // calc axis as dir of n-1 and n-2 center pos\n // project last traceAtom onto axis to get last center pos\n v1.fromArray(center as any, 3 * n - 6) // TODO\n v2.fromArray(center as any, 3 * n - 9) // TODO\n _axis.subVectors(v1, v2).normalize()\n // _center.copy( res[ n - 1 ].getTraceAtom() );\n a1.index = polymer.getAtomIndexByType(n - 1, type)! // TODO\n _center.copy(a1 as any) // TODO\n vt.copy(a1 as any) // TODO\n projectPointOnVector(vt, _axis, v1)\n vt.toArray(center as any, 3 * n - 3) // TODO\n\n // calc last three resdir\n for (let i = n - 3; i < n; ++i) {\n v1.fromArray(center as any, 3 * i) // TODO\n // _center.copy( res[ i ].getTraceAtom() );\n a1.index = polymer.getAtomIndexByType(i, type)! // TODO\n _center.copy(a1 as any) // TODO\n\n _resdir.subVectors(_center, v1)\n _resdir.toArray(resdir as any, 3 * i) // TODO\n }\n\n // average measures to define them on the residues\n\n const resRadius = new Float32Array(n)\n const resTwist = new Float32Array(n)\n const resRise = new Float32Array(n)\n const resBending = new Float32Array(n)\n\n resRadius[ 1 ] = radius[ 0 ]\n resTwist[ 1 ] = twist[ 0 ]\n resRise[ 1 ] = radius[ 0 ]\n\n for (let i = 2; i < n - 2; ++i) {\n resRadius[ i ] = 0.5 * (radius[ i - 2 ] + radius[ i - 1 ])\n resTwist[ i ] = 0.5 * (twist[ i - 2 ] + twist[ i - 1 ])\n resRise[ i ] = 0.5 * (rise[ i - 2 ] + rise[ i - 1 ])\n\n v1.fromArray(axis as any, 3 * (i - 2)) // TODO\n v2.fromArray(axis as any, 3 * (i - 1)) // TODO\n resBending[ i ] = 180.0 / Math.PI * Math.acos(Math.cos(v1.angleTo(v2)))\n }\n\n resRadius[ n - 2 ] = radius[ n - 4 ]\n resTwist[ n - 2 ] = twist[ n - 4 ]\n resRise[ n - 2 ] = rise[ n - 4 ]\n\n // average helix axes to define them on the residues\n\n const resAxis = new Float32Array(3 * n)\n\n copyArray(axis, resAxis, 0, 0, 3)\n copyArray(axis, resAxis, 0, 3, 3)\n\n for (let i = 2; i < n - 2; ++i) {\n v1.fromArray(axis as any, 3 * (i - 2)) // TODO\n v2.fromArray(axis as any, 3 * (i - 1)) // TODO\n\n _axis.addVectors(v2, v1).multiplyScalar(0.5).normalize()\n _axis.toArray(resAxis as any, 3 * i) // TODO\n }\n\n copyArray(axis, resAxis, 3 * n - 12, 3 * n - 6, 3)\n copyArray(axis, resAxis, 3 * n - 12, 3 * n - 3, 3)\n\n return {\n center,\n axis: resAxis,\n bending: resBending,\n radius: resRadius,\n rise: resRise,\n twist: resTwist,\n resdir: resdir\n }\n }\n\n}\n\nexport default Helixorient\n","/**\n * @file Helixbundle\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport { AtomPicker } from '../utils/picker'\nimport RadiusFactory, { RadiusParams } from '../utils/radius-factory'\nimport Helixorient, { HelixPosition } from './helixorient'\nimport { calculateMeanVector3, projectPointOnVector } from '../math/vector-utils'\nimport Polymer from '../proxy/polymer'\nimport { ColormakerParameters } from '../color/colormaker';\n\nexport interface Axis {\n axis: Float32Array\n center: Float32Array\n begin: Float32Array\n end: Float32Array\n color: Float32Array\n picking: AtomPicker\n size: Float32Array\n residueOffset: number[]\n residueCount: number[]\n}\n\nclass Helixbundle {\n helixorient: Helixorient;\n position: HelixPosition;\n\n constructor (readonly polymer: Polymer) {\n\n this.helixorient = new Helixorient(polymer)\n this.position = this.helixorient.getPosition()\n }\n\n getAxis (localAngle: number, centerDist: number, ssBorder: boolean, colorParams: { scheme: string} & ColormakerParameters, radiusParams: RadiusParams): Axis {\n localAngle = localAngle || 30\n centerDist = centerDist || 2.5\n ssBorder = ssBorder === undefined ? false : ssBorder\n\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const residueIndexStart = polymer.residueIndexStart\n\n const pos = this.position\n\n const cp = colorParams || {}\n cp.structure = structure\n\n const colormaker = ColormakerRegistry.getScheme(cp)\n\n const radiusFactory = new RadiusFactory(radiusParams)\n\n let j = 0\n let k = 0\n\n const axis: number[] = []\n const center: number[] = []\n const beg: number[] = []\n const end: number[] = []\n const col: number[] = []\n const pick = []\n const size = []\n const residueOffset = []\n const residueCount = []\n\n let tmpAxis = new Float32Array(n * 3)\n let tmpCenter = new Float32Array(n * 3)\n\n let _axis, _center\n const _beg = new Vector3()\n const _end = new Vector3()\n\n const rp1 = structure.getResidueProxy()\n const rp2 = structure.getResidueProxy()\n const ap = structure.getAtomProxy()\n\n const c1 = new Vector3()\n const c2 = new Vector3()\n\n let split = false\n\n for (let i = 0; i < n; ++i) {\n rp1.index = residueIndexStart + i\n c1.fromArray(pos.center as any, i * 3)\n\n if (i === n - 1) {\n split = true\n } else {\n rp2.index = residueIndexStart + i + 1\n c2.fromArray(pos.center as any, i * 3 + 3)\n\n if (ssBorder && rp1.sstruc !== rp2.sstruc) {\n split = true\n } else if (c1.distanceTo(c2) > centerDist) {\n split = true\n } else if (pos.bending[ i ] > localAngle) {\n split = true\n }\n }\n\n if (split) {\n if (i - j < 4) {\n j = i\n split = false\n continue\n }\n\n ap.index = rp1.traceAtomIndex\n\n // ignore first and last axis\n tmpAxis = pos.axis.subarray(j * 3 + 3, i * 3)\n tmpCenter = pos.center.subarray(j * 3, i * 3 + 3)\n\n _axis = calculateMeanVector3(tmpAxis).normalize()\n _center = calculateMeanVector3(tmpCenter)\n\n _beg.fromArray(tmpCenter as any)\n projectPointOnVector(_beg, _axis, _center)\n\n _end.fromArray(tmpCenter as any, tmpCenter.length - 3)\n projectPointOnVector(_end, _axis, _center)\n\n _axis.subVectors(_end, _beg)\n\n _axis.toArray(axis as any, k)\n _center.toArray(center as any, k)\n _beg.toArray(beg as any, k)\n _end.toArray(end as any, k)\n\n colormaker.atomColorToArray(ap, col, k)\n\n pick.push(ap.index)\n\n size.push(radiusFactory.atomRadius(ap))\n\n residueOffset.push(residueIndexStart + j)\n residueCount.push(residueIndexStart + i + 1 - j)\n\n k += 3\n j = i\n split = false\n }\n }\n\n const picking = new Float32Array(pick)\n\n return {\n axis: new Float32Array(axis),\n center: new Float32Array(center),\n begin: new Float32Array(beg),\n end: new Float32Array(end),\n color: new Float32Array(col),\n picking: new AtomPicker(picking, structure),\n size: new Float32Array(size),\n residueOffset: residueOffset,\n residueCount: residueCount\n }\n }\n}\n\nexport default Helixbundle\n","/**\n * @file Binary Heap\n * @author Alexander Rose \n * @private\n */\n\n/**\n * Binary heap implementation\n * @class\n * @author http://eloquentjavascript.net/appendix2.htm\n * @param {Function} scoreFunction - the heap scoring function\n */\nclass BinaryHeap {\n content: T[] = []\n\n constructor(readonly scoreFunction: (x: T) => number) {\n\n this.scoreFunction = scoreFunction\n }\n\n push (element: T) {\n // Add the new element to the end of the array.\n this.content.push(element)\n\n // Allow it to bubble up.\n this.bubbleUp(this.content.length - 1)\n }\n\n pop () {\n // Store the first element so we can return it later.\n const result = this.content[ 0 ]\n\n // Get the element at the end of the array.\n const end = this.content.pop()\n\n // If there are any elements left, put the end element at the\n // start, and let it sink down.\n if (end && this.content.length > 0) {\n this.content[ 0 ] = end\n this.sinkDown(0)\n }\n\n return result\n }\n\n peek () {\n return this.content[ 0 ]\n }\n\n remove (element: T) {\n const len = this.content.length\n\n // To remove a value, we must search through the array to find it.\n for (let i = 0; i < len; i++) {\n if (this.content[ i ] === element) {\n // When it is found, the process seen in 'pop' is repeated\n // to fill up the hole.\n const end = this.content.pop()\n\n if (end && i !== len - 1) {\n this.content[ i ] = end\n\n if (this.scoreFunction(end) < this.scoreFunction(element)) {\n this.bubbleUp(i)\n } else {\n this.sinkDown(i)\n }\n }\n\n return\n }\n }\n\n throw new Error('Node not found.')\n }\n\n size () {\n return this.content.length\n }\n\n bubbleUp (n: number) {\n // Fetch the element that has to be moved.\n const element = this.content[ n ]\n\n // When at 0, an element can not go up any further.\n while (n > 0) {\n // Compute the parent element's index, and fetch it.\n const parentN = Math.floor((n + 1) / 2) - 1\n const parent = this.content[ parentN ]\n\n // Swap the elements if the parent is greater.\n if (this.scoreFunction(element) < this.scoreFunction(parent)) {\n this.content[ parentN ] = element\n this.content[ n ] = parent\n\n // Update 'n' to continue at the new position.\n n = parentN\n } else {\n // Found a parent that is less, no need to move it further.\n break\n }\n }\n }\n\n sinkDown (n: number) {\n // Look up the target element and its score.\n const length = this.content.length\n const element = this.content[ n ]\n const elemScore = this.scoreFunction(element)\n\n let child1Score = 0\n let child2Score = 0\n\n while (true) {\n // Compute the indices of the child elements.\n const child2N = (n + 1) * 2\n const child1N = child2N - 1\n\n // This is used to store the new position of the element, if any.\n let swap = null\n\n // If the first child exists (is inside the array)...\n if (child1N < length) {\n // Look it up and compute its score.\n const child1 = this.content[ child1N ]\n child1Score = this.scoreFunction(child1)\n\n // If the score is less than our element's, we need to swap.\n if (child1Score < elemScore) swap = child1N\n }\n\n // Do the same checks for the other child.\n if (child2N < length) {\n const child2 = this.content[ child2N ]\n child2Score = this.scoreFunction(child2)\n\n if (child2Score < (swap === null ? elemScore : child1Score)) swap = child2N\n }\n\n // If the element needs to be moved, swap it, and continue.\n if (swap !== null) {\n this.content[ n ] = this.content[ swap ]\n this.content[ swap ] = element\n n = swap\n } else {\n // Otherwise, we are done.\n break\n }\n }\n }\n\n}\n\nexport default BinaryHeap\n","/**\n * @file Kdtree\n * @author Alexander Rose \n * @private\n */\n\nimport { NumberArray } from '../types'\nimport BinaryHeap from './binary-heap'\n\n/**\n * Kdtree\n * @class\n * @author Alexander Rose , 2016\n * @author Roman Bolzern , 2013\n * @author I4DS http://www.fhnw.ch/i4ds, 2013\n * @license MIT License \n * @description\n * k-d Tree for typed arrays of 3d points (e.g. for Float32Array), in-place\n * provides fast nearest neighbour search\n *\n * Based on https://github.com/ubilabs/kd-tree-javascript by Ubilabs\n *\n * Further information (including mathematical properties)\n * http://en.wikipedia.org/wiki/Binary_tree\n * http://en.wikipedia.org/wiki/K-d_tree\n *\n * @example\n * points: [x, y, z, x, y, z, x, y, z, ...]\n * metric: function(a, b){\n * return Math.pow(a[0]-b[0], 2) + Math.pow(a[1]-b[1], 2) + Math.pow(a[2]-b[2], 2);\n * }\n *\n * @param {Float32Array} points - points\n * @param {Function} metric - metric\n */\nclass Kdtree {\n indices: Uint32Array\n nodes: Int32Array\n rootIndex: number\n\n maxDepth = 0\n currentNode = 0\n\n constructor(readonly points: NumberArray, readonly metric: (a: NumberArray, b: NumberArray) => number) {\n const n = points.length / 3\n\n const indices = new Uint32Array(n)\n for (let i = 0; i < n; ++i) {\n indices[ i ] = i\n }\n this.indices = indices\n this.nodes = new Int32Array(n * 4)\n this.rootIndex = this.buildTree(0, -1, 0, n)\n }\n\n buildTree (depth: number, parent: number, arrBegin: number, arrEnd: number) {\n if (depth > this.maxDepth) this.maxDepth = depth\n\n const plength = arrEnd - arrBegin\n if (plength === 0) {\n return -1\n }\n\n const nodeIndex = this.currentNode * 4\n const nodes = this.nodes\n\n this.currentNode += 1\n if (plength === 1) {\n nodes[ nodeIndex ] = arrBegin\n nodes[ nodeIndex + 1 ] = -1\n nodes[ nodeIndex + 2 ] = -1\n nodes[ nodeIndex + 3 ] = parent\n return nodeIndex\n }\n // if(plength <= 32){\n // return nodeIndex;\n // }\n\n const indices = this.indices\n const points = this.points\n\n const arrMedian = arrBegin + Math.floor(plength / 2)\n const currentDim = depth % 3\n\n // inlined quickselect function\n let j, tmp, pivotIndex, pivotValue, storeIndex\n let left = arrBegin\n let right = arrEnd - 1\n while (right > left) {\n pivotIndex = (left + right) >> 1\n pivotValue = points[ indices[ pivotIndex ] * 3 + currentDim ]\n // swap( pivotIndex, right );\n tmp = indices[ pivotIndex ]\n indices[ pivotIndex ] = indices[ right ]\n indices[ right ] = tmp\n storeIndex = left\n for (j = left; j < right; ++j) {\n if (points[ indices[ j ] * 3 + currentDim ] < pivotValue) {\n // swap( storeIndex, j );\n tmp = indices[ storeIndex ]\n indices[ storeIndex ] = indices[ j ]\n indices[ j ] = tmp\n ++storeIndex\n }\n }\n // swap( right, storeIndex );\n tmp = indices[ right ]\n indices[ right ] = indices[ storeIndex ]\n indices[ storeIndex ] = tmp\n pivotIndex = storeIndex\n if (arrMedian === pivotIndex) {\n break\n } else if (arrMedian < pivotIndex) {\n right = pivotIndex - 1\n } else {\n left = pivotIndex + 1\n }\n }\n\n nodes[ nodeIndex ] = arrMedian\n nodes[ nodeIndex + 1 ] = this.buildTree(depth + 1, nodeIndex, arrBegin, arrMedian)\n nodes[ nodeIndex + 2 ] = this.buildTree(depth + 1, nodeIndex, arrMedian + 1, arrEnd)\n nodes[ nodeIndex + 3 ] = parent\n\n return nodeIndex\n }\n\n getNodeDepth (nodeIndex: number): number {\n const parentIndex = this.nodes[ nodeIndex + 3 ]\n return (parentIndex === -1) ? 0 : this.getNodeDepth(parentIndex) + 1\n }\n\n // TODO\n // function getNodePos (node) {}\n\n /**\n * find nearest points\n * @param {Array} point - array of size 3\n * @param {Integer} maxNodes - max amount of nodes to return\n * @param {Float} maxDistance - maximum distance of point to result nodes\n * @return {Array} array of point, distance pairs\n */\n nearest (point: NumberArray, maxNodes: number, maxDistance: number) {\n const bestNodes = new BinaryHeap<[number, number]>(e => -e[ 1 ])\n\n const nodes = this.nodes\n const points = this.points\n const indices = this.indices\n\n const nearestSearch = (nodeIndex: number) => {\n let bestChild, otherChild\n const dimension = this.getNodeDepth(nodeIndex) % 3\n const pointIndex = indices[ nodes[ nodeIndex ] ] * 3\n const ownPoint = [\n points[ pointIndex + 0 ],\n points[ pointIndex + 1 ],\n points[ pointIndex + 2 ]\n ]\n const ownDistance = this.metric(point, ownPoint)\n\n function saveNode (nodeIndex: number, distance: number) {\n bestNodes.push([ nodeIndex, distance ])\n if (bestNodes.size() > maxNodes) {\n bestNodes.pop()\n }\n }\n\n const leftIndex = nodes[ nodeIndex + 1 ]\n const rightIndex = nodes[ nodeIndex + 2 ]\n\n // if it's a leaf\n if (rightIndex === -1 && leftIndex === -1) {\n if ((bestNodes.size() < maxNodes || ownDistance < bestNodes.peek()[ 1 ]) &&\n ownDistance <= maxDistance\n ) {\n saveNode(nodeIndex, ownDistance)\n }\n return\n }\n\n if (rightIndex === -1) {\n bestChild = leftIndex\n } else if (leftIndex === -1) {\n bestChild = rightIndex\n } else {\n if (point[ dimension ] <= points[ pointIndex + dimension ]) {\n bestChild = leftIndex\n } else {\n bestChild = rightIndex\n }\n }\n\n // recursive search\n nearestSearch(bestChild)\n\n if ((bestNodes.size() < maxNodes || ownDistance < bestNodes.peek()[ 1 ]) &&\n ownDistance <= maxDistance\n ) {\n saveNode(nodeIndex, ownDistance)\n }\n\n // if there's still room or the current distance is nearer than the best distance\n const linearPoint = []\n for (let i = 0; i < 3; i += 1) {\n if (i === dimension) {\n linearPoint[ i ] = point[ i ]\n } else {\n linearPoint[ i ] = points[ pointIndex + i ]\n }\n }\n const linearDistance = this.metric(linearPoint, ownPoint)\n\n if ((bestNodes.size() < maxNodes || Math.abs(linearDistance) < bestNodes.peek()[ 1 ]) &&\n Math.abs(linearDistance) <= maxDistance\n ) {\n if (bestChild === leftIndex) {\n otherChild = rightIndex\n } else {\n otherChild = leftIndex\n }\n if (otherChild !== -1) {\n nearestSearch(otherChild)\n }\n }\n }\n\n nearestSearch(this.rootIndex)\n\n const result = []\n for (let i = 0, il = Math.min(bestNodes.size(), maxNodes); i < il; i += 1) {\n result.push(bestNodes.content[ i ])\n }\n\n return result\n }\n\n verify (nodeIndex?: number, depth = 0) {\n let count = 1\n\n if (nodeIndex === undefined) {\n nodeIndex = this.rootIndex\n }\n\n if (nodeIndex === -1) {\n throw new Error('node is null')\n }\n\n const dim = depth % 3\n const nodes = this.nodes\n const points = this.points\n const indices = this.indices\n\n const leftIndex = nodes[ nodeIndex + 1 ]\n const rightIndex = nodes[ nodeIndex + 2 ]\n\n if (leftIndex !== -1) {\n if (points[ indices[ nodes[ leftIndex ] ] * 3 + dim ] >\n points[ indices[ nodes[ nodeIndex ] ] * 3 + dim ]\n ) {\n throw new Error('left child is > parent!')\n }\n count += this.verify(leftIndex, depth + 1)\n }\n\n if (rightIndex !== -1) {\n if (points[ indices[ nodes[ rightIndex ] ] * 3 + dim ] <\n points[ indices[ nodes[ nodeIndex ] ] * 3 + dim ]\n ) {\n throw new Error('right child is < parent!')\n }\n count += this.verify(rightIndex, depth + 1)\n }\n\n return count\n }\n}\n\nexport default Kdtree\n","/**\n * @file Atom Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { NumberArray } from '../types'\nimport {\n Elements,\n SecStrucHelix, SecStrucSheet, SecStrucTurn,\n ProteinType, RnaType, DnaType, WaterType, IonType, SaccharideType,\n CgProteinBackboneType, CgRnaBackboneType, CgDnaBackboneType\n} from '../structure/structure-constants'\n\nimport Structure from '../structure/structure'\n\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\nimport AtomStore from '../store/atom-store'\n\nimport AtomMap from '../store/atom-map'\nimport ResidueMap from '../store/residue-map'\n\nimport BondProxy from '../proxy/bond-proxy'\nimport AtomType from '../store/atom-type';\nimport ResidueType from '../store/residue-type';\nimport ResidueProxy from './residue-proxy';\nimport Entity from '../structure/entity';\nimport BondHash from '../store/bond-hash';\n\n/**\n * Atom proxy\n */\nclass AtomProxy {\n index: number\n\n chainStore: ChainStore\n residueStore: ResidueStore\n atomStore: AtomStore\n\n residueMap: ResidueMap\n atomMap: AtomMap\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n this.atomStore = structure.atomStore\n this.residueMap = structure.residueMap\n this.atomMap = structure.atomMap\n }\n\n /**\n * @type {BondHash}\n */\n get bondHash (): BondHash|undefined { return this.structure.bondHash }\n\n /**\n * Molecular enity\n * @type {Entity}\n */\n get entity (): Entity {\n return this.structure.entityList[ this.entityIndex ]\n }\n get entityIndex () {\n return this.chainStore.entityIndex[ this.chainIndex ]\n }\n get modelIndex () {\n return this.chainStore.modelIndex[ this.chainIndex ]\n }\n get chainIndex () {\n return this.residueStore.chainIndex[ this.residueIndex ]\n }\n /**\n * @type {ResidueProxy}\n */\n get residue (): ResidueProxy {\n console.warn('residue - might be expensive')\n return this.structure.getResidueProxy(this.residueIndex)\n }\n\n get residueIndex () {\n return this.atomStore.residueIndex[ this.index ]\n }\n set residueIndex (value) {\n this.atomStore.residueIndex[ this.index ] = value\n }\n\n //\n\n /**\n * Secondary structure code\n * @type {String}\n */\n get sstruc () {\n return this.residueStore.getSstruc(this.residueIndex)\n }\n /**\n * Insertion code\n * @type {String}\n */\n get inscode () {\n return this.residueStore.getInscode(this.residueIndex)\n }\n /**\n * Residue number/label\n * @type {Integer}\n */\n get resno () {\n return this.residueStore.resno[ this.residueIndex ]\n }\n /**\n * Chain name\n * @type {String}\n */\n get chainname () {\n return this.chainStore.getChainname(this.chainIndex)\n }\n /**\n * Chain id\n * @type {String}\n */\n get chainid () {\n return this.chainStore.getChainid(this.chainIndex)\n }\n\n //\n\n /**\n * @type {ResidueType}\n */\n get residueType (): ResidueType {\n return this.residueMap.get(this.residueStore.residueTypeId[ this.residueIndex ])\n }\n /**\n * @type {AtomType}\n */\n get atomType (): AtomType {\n return this.atomMap.get(this.atomStore.atomTypeId[ this.index ])\n }\n get residueAtomOffset () {\n return this.residueStore.atomOffset[ this.residueIndex ]\n }\n\n //\n\n /**\n * Residue name\n */\n get resname () {\n return this.residueType.resname\n }\n /**\n * Hetero flag\n */\n get hetero () {\n return this.residueType.hetero\n }\n\n //\n\n /**\n * Atom name\n */\n get atomname () {\n return this.atomType.atomname\n }\n /**\n * Atomic number\n */\n get number () {\n return this.atomType.number\n }\n /**\n * Element\n */\n get element () {\n return this.atomType.element\n }\n /**\n * Van-der-Waals radius\n */\n get vdw () {\n return this.atomType.vdw\n }\n /**\n * Covalent radius\n */\n get covalent () {\n return this.atomType.covalent\n }\n\n //\n\n /**\n * X coordinate\n */\n get x () {\n return this.atomStore.x[ this.index ]\n }\n set x (value) {\n this.atomStore.x[ this.index ] = value\n }\n\n /**\n * Y coordinate\n */\n get y () {\n return this.atomStore.y[ this.index ]\n }\n set y (value) {\n this.atomStore.y[ this.index ] = value\n }\n\n /**\n * Z coordinate\n */\n get z () {\n return this.atomStore.z[ this.index ]\n }\n set z (value) {\n this.atomStore.z[ this.index ] = value\n }\n\n /**\n * Serial number\n */\n get serial () {\n return this.atomStore.serial[ this.index ]\n }\n set serial (value) {\n this.atomStore.serial[ this.index ] = value\n }\n\n /**\n * B-factor value\n */\n get bfactor () {\n return this.atomStore.bfactor[ this.index ]\n }\n set bfactor (value) {\n this.atomStore.bfactor[ this.index ] = value\n }\n\n /**\n * Occupancy value\n */\n get occupancy () {\n return this.atomStore.occupancy[ this.index ]\n }\n set occupancy (value) {\n this.atomStore.occupancy[ this.index ] = value\n }\n\n /**\n * Alternate location identifier\n */\n get altloc () {\n return this.atomStore.getAltloc(this.index)\n }\n set altloc (value) {\n this.atomStore.setAltloc(this.index, value)\n }\n\n /**\n * Partial charge\n */\n get partialCharge () {\n return this.atomStore.partialCharge ? this.atomStore.partialCharge[ this.index ] : null\n }\n set partialCharge (value) {\n if (this.atomStore.partialCharge) {\n this.atomStore.partialCharge[ this.index ] = value as number\n }\n }\n\n /**\n * Explicit radius\n */\n get radius () {\n return this.atomStore.radius ? this.atomStore.radius[ this.index ] : null\n }\n set radius (value) {\n if (this.atomStore.radius) {\n this.atomStore.radius[ this.index ] = value as number\n }\n }\n\n /**\n * Formal charge\n */\n get formalCharge () {\n return this.atomStore.formalCharge ? this.atomStore.formalCharge[ this.index ] : null\n }\n set formalCharge (value) {\n if (this.atomStore.formalCharge) {\n this.atomStore.formalCharge[ this.index ] = value as number\n }\n }\n\n /**\n * Aromaticity flag\n */\n get aromatic () {\n if (this.atomStore.aromatic) {\n return this.atomStore.aromatic[ this.index ] as number\n } else {\n return this.residueType.isAromatic(this) ? 1 : 0\n }\n }\n set aromatic (value) {\n if (this.atomStore.aromatic) {\n this.atomStore.aromatic[ this.index ] = value as number\n }\n }\n\n //\n\n get bondCount () {\n return this.bondHash!.countArray[ this.index ] // TODO\n }\n\n //\n\n /**\n * Iterate over each bond\n * @param {function(bond: BondProxy)} callback - iterator callback function\n * @param {BondProxy} [bp] - optional target bond proxy for use in the callback\n * @return {undefined}\n */\n eachBond (callback: (bp: BondProxy) => void, bp?: BondProxy) {\n bp = bp || this.structure._bp\n const idx = this.index\n const bondHash = this.bondHash! // TODO\n const indexArray = bondHash.indexArray\n const n = bondHash.countArray[ idx ]\n const offset = bondHash.offsetArray[ idx ]\n\n for (let i = 0; i < n; ++i) {\n bp.index = indexArray[ offset + i ]\n callback(bp)\n }\n }\n\n /**\n * Iterate over each bonded atom\n * @param {function(atom: AtomProxy)} callback - iterator callback function\n * @param {AtomProxy} [ap] - optional target atom proxy for use in the callback\n * @return {undefined}\n */\n eachBondedAtom (callback: (ap: AtomProxy) => void, _ap?: AtomProxy) {\n const ap = _ap ? _ap : this.structure._ap\n const idx = this.index\n\n this.eachBond(function (bp) {\n ap.index = idx !== bp.atomIndex1 ? bp.atomIndex1 : bp.atomIndex2\n callback(ap)\n })\n this.index = idx\n }\n\n /**\n * Check if this atom is bonded to the given atom,\n * assumes both atoms are from the same structure\n * @param {AtomProxy} ap - the given atom\n * @return {Boolean} whether a bond exists or not\n */\n hasBondTo (ap: AtomProxy) {\n let flag = false\n this.eachBondedAtom(function (bap) {\n if (ap.index === bap.index) flag = true\n })\n return flag\n }\n\n bondToElementCount (element: Elements) {\n let count = 0\n const idx = this.index // Avoid reentrancy problems\n this.eachBondedAtom(function (bap) {\n if (bap.number === element) count += 1\n })\n this.index = idx\n return count\n }\n\n hasBondToElement (element: Elements) {\n return this.bondToElementCount(element) > 0\n }\n\n //\n\n /**\n * If atom is part of a backbone\n * @return {Boolean} flag\n */\n isBackbone () {\n const backboneIndexList = this.residueType.backboneIndexList\n if (backboneIndexList.length > 0) {\n return backboneIndexList.includes(this.index - this.residueAtomOffset)\n } else {\n return false\n }\n }\n\n /**\n * If atom is part of a polymer\n * @return {Boolean} flag\n */\n isPolymer () {\n if (this.structure.entityList.length > 0) {\n return this.entity.isPolymer()\n } else {\n const moleculeType = this.residueType.moleculeType\n return (\n moleculeType === ProteinType ||\n moleculeType === RnaType ||\n moleculeType === DnaType\n )\n }\n }\n\n /**\n * If atom is part of a sidechin\n * @return {Boolean} flag\n */\n isSidechain () {\n return this.isPolymer() && !this.isBackbone()\n }\n\n /**\n * If atom is part of a coarse-grain group\n * @return {Boolean} flag\n */\n isCg () {\n const backboneType = this.residueType.backboneType\n return (\n backboneType === CgProteinBackboneType ||\n backboneType === CgRnaBackboneType ||\n backboneType === CgDnaBackboneType\n )\n }\n\n isTrace () {\n return this.index === (this.residueType.traceAtomIndex + this.residueAtomOffset)\n }\n\n /**\n * If atom is part of a hetero group\n * @return {Boolean} flag\n */\n isHetero () {\n return this.residueType.hetero === 1\n }\n\n /**\n * If atom is part of a protein molecule\n * @return {Boolean} flag\n */\n isProtein () {\n return this.residueType.moleculeType === ProteinType\n }\n\n /**\n * If atom is part of a nucleic molecule\n * @return {Boolean} flag\n */\n isNucleic () {\n const moleculeType = this.residueType.moleculeType\n return moleculeType === RnaType || moleculeType === DnaType\n }\n\n /**\n * If atom is part of a rna\n * @return {Boolean} flag\n */\n isRna () {\n return this.residueType.moleculeType === RnaType\n }\n\n /**\n * If atom is part of a dna\n * @return {Boolean} flag\n */\n isDna () {\n return this.residueType.moleculeType === DnaType\n }\n\n /**\n * If atom is part of a water molecule\n * @return {Boolean} flag\n */\n isWater () {\n return this.residueType.moleculeType === WaterType\n }\n\n /**\n * If atom is part of an ion\n * @return {Boolean} flag\n */\n isIon () {\n return this.residueType.moleculeType === IonType\n }\n\n /**\n * If atom is part of a saccharide\n * @return {Boolean} flag\n */\n isSaccharide () {\n return this.residueType.moleculeType === SaccharideType\n }\n\n /**\n * If atom is part of a helix\n * @return {Boolean} flag\n */\n isHelix () {\n return SecStrucHelix.includes(this.sstruc)\n }\n\n /**\n * If atom is part of a sheet\n * @return {Boolean} flag\n */\n isSheet () {\n return SecStrucSheet.includes(this.sstruc)\n }\n\n /**\n * If atom is part of a turn\n * @return {Boolean} flag\n */\n isTurn () {\n return SecStrucTurn.includes(this.sstruc) && this.isProtein()\n }\n\n isBonded () {\n return this.bondHash!.countArray[ this.index ] !== 0 // TODO\n }\n\n /**\n * If atom is part of a ring\n * @return {Boolean} flag\n */\n isRing () {\n const atomRings = this.residueType.getRings()!.atomRings // TODO\n return atomRings[ this.index - this.residueAtomOffset ] !== undefined\n }\n\n isAromatic () {\n return this.aromatic === 1\n }\n\n isPolarHydrogen () {\n let result = false\n\n if (this.number !== 1) return result\n\n result = !this.hasBondToElement(Elements.C)\n\n return result\n }\n\n isMetal () { return this.atomType.isMetal() }\n isNonmetal () { return this.atomType.isNonmetal() }\n isMetalloid () { return this.atomType.isMetalloid() }\n isHalogen () { return this.atomType.isHalogen() }\n isDiatomicNonmetal () { return this.atomType.isDiatomicNonmetal() }\n isPolyatomicNonmetal () { return this.atomType.isPolyatomicNonmetal() }\n isAlkaliMetal () { return this.atomType.isAlkaliMetal() }\n isAlkalineEarthMetal () { return this.atomType.isAlkalineEarthMetal() }\n isNobleGas () { return this.atomType.isNobleGas() }\n isTransitionMetal () { return this.atomType.isTransitionMetal() }\n isPostTransitionMetal () { return this.atomType.isPostTransitionMetal() }\n isLanthanide () { return this.atomType.isLanthanide() }\n isActinide () { return this.atomType.isActinide() }\n\n getDefaultValence () { return this.atomType.getDefaultValence() }\n getValenceList () { return this.atomType.getValenceList() }\n getOuterShellElectronCount () { return this.atomType.getOuterShellElectronCount() }\n\n /**\n * Distance to another atom\n * @param {AtomProxy} atom - the other atom\n * @return {Number} the distance\n */\n distanceTo (atom: AtomProxy) {\n const taa = this.atomStore\n const aaa = atom.atomStore\n const ti = this.index\n const ai = atom.index\n const x = taa.x[ ti ] - aaa.x[ ai ]\n const y = taa.y[ ti ] - aaa.y[ ai ]\n const z = taa.z[ ti ] - aaa.z[ ai ]\n const distSquared = x * x + y * y + z * z\n return Math.sqrt(distSquared)\n }\n\n /**\n * If connected to another atom\n * @param {AtomProxy} atom - the other atom\n * @return {Boolean} flag\n */\n connectedTo (atom: AtomProxy) {\n const taa = this.atomStore\n const aaa = atom.atomStore\n const ti = this.index\n const ai = atom.index\n\n if (taa.altloc && aaa.altloc) {\n const ta = taa.altloc[ ti ] // use Uint8 value to compare\n const aa = aaa.altloc[ ai ] // no need to convert to char\n // 0 is the Null character, 32 is the space character\n if (!(ta === 0 || aa === 0 || ta === 32 || aa === 32 || (ta === aa))) return false\n }\n\n const x = taa.x[ ti ] - aaa.x[ ai ]\n const y = taa.y[ ti ] - aaa.y[ ai ]\n const z = taa.z[ ti ] - aaa.z[ ai ]\n\n const distSquared = x * x + y * y + z * z\n\n // if( this.isCg() ) console.log( this.qualifiedName(), Math.sqrt( distSquared ), distSquared )\n if (distSquared < 48.0 && this.isCg()) return true\n\n if (isNaN(distSquared)) return false\n\n const d = this.covalent + atom.covalent\n const d1 = d + 0.3\n const d2 = d - 0.5\n\n return distSquared < (d1 * d1) && distSquared > (d2 * d2)\n }\n\n /**\n * Set atom position from array\n * @param {Array|TypedArray} array - input array\n * @param {Integer} [offset] - the offset\n * @return {AtomProxy} this object\n */\n positionFromArray (array: NumberArray, offset = 0) {\n this.x = array[ offset + 0 ]\n this.y = array[ offset + 1 ]\n this.z = array[ offset + 2 ]\n\n return this\n }\n\n /**\n * Write atom position to array\n * @param {Array|TypedArray} [array] - target array\n * @param {Integer} [offset] - the offset\n * @return {Array|TypedArray} target array\n */\n positionToArray (array: NumberArray = [], offset = 0) {\n const index = this.index\n const atomStore = this.atomStore\n\n array[ offset + 0 ] = atomStore.x[ index ]\n array[ offset + 1 ] = atomStore.y[ index ]\n array[ offset + 2 ] = atomStore.z[ index ]\n\n return array\n }\n\n /**\n * Write atom position to vector\n * @param {Vector3} [v] - target vector\n * @return {Vector3} target vector\n */\n positionToVector3 (v?: Vector3) {\n if (v === undefined) v = new Vector3()\n\n v.x = this.x\n v.y = this.y\n v.z = this.z\n\n return v\n }\n\n /**\n * Set atom position from vector\n * @param {Vector3} v - input vector\n * @return {AtomProxy} this object\n */\n positionFromVector3 (v: Vector3) {\n this.x = v.x\n this.y = v.y\n this.z = v.z\n\n return this\n }\n\n /**\n * Add vector to atom position\n * @param {Vector3} v - input vector\n * @return {AtomProxy} this object\n */\n positionAdd (v: Vector3|AtomProxy) {\n this.x += v.x\n this.y += v.y\n this.z += v.z\n\n return this\n }\n\n /**\n * Subtract vector from atom position\n * @param {Vector3} v - input vector\n * @return {AtomProxy} this object\n */\n positionSub (v: Vector3|AtomProxy) {\n this.x -= v.x\n this.y -= v.y\n this.z -= v.z\n\n return this\n }\n\n /**\n * Get intra group/residue bonds\n * @param {Boolean} firstOnly - immediately return the first connected atomIndex\n * @return {Integer[]|Integer|undefined} connected atomIndices\n */\n getResidueBonds (firstOnly = false) {\n const residueAtomOffset = this.residueAtomOffset\n const relativeIndex = this.index - this.residueAtomOffset\n const bonds = this.residueType.getBonds()! // TODO\n const atomIndices1 = bonds.atomIndices1\n const atomIndices2 = bonds.atomIndices2\n let idx1, idx2, connectedAtomIndex\n let connectedAtomIndices: number[]|undefined\n\n if (!firstOnly) connectedAtomIndices = []\n\n idx1 = atomIndices1.indexOf(relativeIndex)\n while (idx1 !== -1) {\n connectedAtomIndex = atomIndices2[ idx1 ] + residueAtomOffset\n if (connectedAtomIndices) {\n connectedAtomIndices.push(connectedAtomIndex)\n idx1 = atomIndices1.indexOf(relativeIndex, idx1 + 1)\n } else {\n return connectedAtomIndex\n }\n }\n\n idx2 = atomIndices2.indexOf(relativeIndex)\n while (idx2 !== -1) {\n connectedAtomIndex = atomIndices1[ idx2 ] + residueAtomOffset\n if (connectedAtomIndices) {\n connectedAtomIndices.push(connectedAtomIndex)\n idx2 = atomIndices2.indexOf(relativeIndex, idx2 + 1)\n } else {\n return connectedAtomIndex\n }\n }\n\n return connectedAtomIndices\n }\n\n //\n\n qualifiedName (noResname = false) {\n var name = ''\n if (this.resname && !noResname) name += '[' + this.resname + ']'\n if (this.resno !== undefined) name += this.resno\n if (this.inscode) name += '^' + this.inscode\n if (this.chainname) name += ':' + this.chainname\n if (this.atomname) name += '.' + this.atomname\n if (this.altloc) name += '%' + this.altloc\n if (this.structure.modelStore.count > 1) name += '/' + this.modelIndex\n return name\n }\n\n /**\n * Clone object\n * @return {AtomProxy} cloned atom\n */\n clone () {\n return new AtomProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n index: this.index,\n residueIndex: this.residueIndex,\n\n resname: this.resname,\n x: this.x,\n y: this.y,\n z: this.z,\n element: this.element,\n chainname: this.chainname,\n resno: this.resno,\n serial: this.serial,\n vdw: this.vdw,\n covalent: this.covalent,\n hetero: this.hetero,\n bfactor: this.bfactor,\n altloc: this.altloc,\n atomname: this.atomname,\n modelIndex: this.modelIndex\n }\n }\n}\n\nexport default AtomProxy\n","/**\n * @file Kdtree\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { Debug, Log } from '../globals'\nimport _Kdtree from '../utils/kdtree'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\n\nfunction euclideanDistSq(a: number[], b: number[]) {\n const dx = a[0] - b[0]\n const dy = a[1] - b[1]\n const dz = a[2] - b[2]\n return dx * dx + dy * dy + dz * dz\n}\n\nfunction euclideanDist(a: number[], b: number[]) {\n return Math.sqrt(euclideanDistSq(a, b))\n}\n\nconst pointArray = new Float32Array(3)\n\nclass Kdtree {\n points: Float32Array\n atomIndices: Uint32Array\n kdtree: _Kdtree\n\n constructor(structure: Structure|ResidueProxy, useSquaredDist = false) {\n if (Debug) Log.time('Kdtree build')\n\n const metric = useSquaredDist ? euclideanDistSq : euclideanDist\n\n const points = new Float32Array(structure.atomCount * 3)\n const atomIndices = new Uint32Array(structure.atomCount)\n let i = 0\n\n structure.eachAtom(function (ap) {\n points[ i + 0 ] = ap.x\n points[ i + 1 ] = ap.y\n points[ i + 2 ] = ap.z\n atomIndices[ i / 3 ] = ap.index\n i += 3\n })\n\n this.atomIndices = atomIndices\n this.points = points\n this.kdtree = new _Kdtree(points, metric)\n\n if (Debug) Log.timeEnd('Kdtree build')\n\n // console.log(\"this.kdtree.verify()\", this.kdtree.verify())\n }\n\n nearest (point: number[]|Vector3, maxNodes: number, maxDistance: number) {\n // Log.time( \"Kdtree nearest\" );\n\n if (point instanceof Vector3) {\n point.toArray(pointArray as any)\n } else if (point instanceof AtomProxy) {\n point.positionToArray(pointArray)\n }\n\n const nodeList = this.kdtree.nearest(pointArray, maxNodes, maxDistance)\n\n const indices = this.kdtree.indices\n const nodes = this.kdtree.nodes\n const atomIndices = this.atomIndices\n const resultList = []\n\n for (let i = 0, n = nodeList.length; i < n; ++i) {\n const d = nodeList[ i ]\n const nodeIndex = d[ 0 ]\n const dist = d[ 1 ]\n\n resultList.push({\n index: atomIndices[ indices[ nodes[ nodeIndex ] ] ],\n distance: dist\n })\n }\n\n // Log.timeEnd( \"Kdtree nearest\" );\n\n return resultList\n }\n}\n\nexport default Kdtree\n","/**\n * @file Symmetry Constants\n * @author Alexander Rose \n * @private\n */\n\nexport const SymOpCode: { [k: string]: string } = {\n ' ': 'X',\n '!': 'Y',\n '#': 'Z',\n '$': '-X',\n '%': '-Y',\n '&': '-Z',\n \"'\": 'Y+1/2',\n '(': '1/2+X',\n ')': '1/2+Y',\n '*': '1/2-X',\n '+': '1/2+Z',\n ',': '1/2-Y',\n '-': '1/2-Z',\n '.': 'X+1/2',\n '/': 'Z+1/2',\n '0': '-X+1/2',\n '1': '-Y+1/2',\n '2': '-Z+1/2',\n '3': '1/4+X',\n '4': '1/4-Y',\n '5': '1/4+Z',\n '6': '1/4-X',\n '7': '1/4+Y',\n '8': '3/4-Y',\n '9': '3/4+Z',\n ':': '3/4+Y',\n ';': '3/4+X',\n '<': '3/4-X',\n '=': '1/4-Z',\n '>': '3/4-Z',\n '?': 'X-Y',\n '@': 'Y-X',\n 'A': 'Z+1/3',\n 'B': 'Z+2/3',\n 'C': 'X+2/3',\n 'D': 'Y+1/3',\n 'E': '-Y+2/3',\n 'F': 'X-Y+1/3',\n 'G': 'Y-X+2/3',\n 'H': '-X+1/3',\n 'I': 'X+1/3',\n 'J': 'Y+2/3',\n 'K': '-Y+1/3',\n 'L': 'X-Y+2/3',\n 'M': 'Y-X+1/3',\n 'N': '-X+2/3',\n 'O': '2/3+X',\n 'P': '1/3+Y',\n 'Q': '1/3+Z',\n 'R': '2/3-Y',\n 'S': '1/3+X-Y',\n 'T': '2/3+Y-X',\n 'U': '1/3-X',\n 'V': '2/3-X',\n 'W': '1/3-Y',\n 'X': '1/3-Z',\n 'Y': '2/3+Y',\n 'Z': '1/3+Y-X',\n '[': '2/3+X-Y',\n ']': '1/3+X',\n '^': '2/3+Z',\n '_': '2/3-Z',\n '`': '5/6+Z',\n 'a': '1/6+Z',\n 'b': '5/6-Z',\n 'c': '1/6-Z',\n 'd': 'Z+5/6',\n 'e': 'Z+1/6',\n 'f': 'Z+1/4',\n 'g': '+Y'\n}\n\n// encoded, originally from CCP4 symop.lib\nexport const EncodedSymOp: { [k: string]: string } = {\n 'P 1': ' !#',\n 'P -1': ' !#$%&',\n 'P 1 2 1': ' !#$!&',\n 'P 1 21 1': \" !#$'&\",\n 'C 1 2 1': ' !#$!&()#*)&',\n 'P 1 m 1': ' !# %#',\n 'P 1 c 1': ' !# %+',\n 'C 1 m 1': ' !# %#()#(,#',\n 'C 1 c 1': ' !# %+()#(,+',\n 'P 1 2/m 1': ' !# %#$!&$%&',\n 'P 1 21/m 1': ' !#$)&$%& ,#',\n 'C 1 2/m 1': ' !# %#$!&$%&()#(,#*)&*,&',\n 'P 1 2/c 1': ' !#$!-$%& %+',\n 'P 1 21/c 1': ' !#$%&$)- ,+',\n 'C 1 2/c 1': ' !#$!-$%& %+()#*)-*,&(,+',\n 'P 2 2 2': ' !#$%#$!& %&',\n 'P 2 2 21': ' !#$%+$!- %&',\n 'P 21 21 2': ' !#$%#*)&(,&',\n 'P 21 21 21': ' !#*%+$)-(,&',\n 'C 2 2 21': ' !#$%+$!- %&()#*,+*)-(,&',\n 'C 2 2 2': ' !#$%#$!& %&()#*,#*)&(,&',\n 'F 2 2 2': ' !#$%#$!& %& )+$,+$)- ,-(!+*%+*!-(%-()#*,#*)&(,&',\n 'I 2 2 2': \" !#$%# %&$!&.'/01/.120'2\",\n 'I 21 21 21': ' !#*%+$)-(,&()+$,#*!& %-',\n 'P m m 2': ' !#$%# %#$!#',\n 'P m c 21': ' !#$%+ %+$!#',\n 'P c c 2': ' !#$%# %+$!+',\n 'P m a 2': ' !#$%#(%#*!#',\n 'P c a 21': ' !#$%+(%#*!+',\n 'P n c 2': ' !#$%# ,+$)+',\n 'P m n 21': ' !#*%+(%+$!#',\n 'P b a 2': ' !#$%#(,#*)#',\n 'P n a 21': ' !#$%+(,#*)+',\n 'P n n 2': ' !#$%#(,+*)+',\n 'C m m 2': ' !#$%# %#$!#()#*,#(,#*)#',\n 'C m c 21': ' !#$%+ %+$!#()#*,+(,+*)#',\n 'C c c 2': ' !#$%# %+$!+()#*,#(,+*)+',\n 'A m m 2': ' !#$%# %#$!# )+$,+ ,+$)+',\n 'A b m 2': ' !#$%# ,#$)# )+$,+ %+$!+',\n 'A m a 2': ' !#$%#(%#*!# )+$,+(,+*)+',\n 'A b a 2': ' !#$%#(,#*)# )+$,+(%+*!+',\n 'F m m 2': ' !#$%# %#$!# )+$,+ ,+$)+(!+*%+(%+*!+()#*,#(,#*)#',\n 'F d d 2': ' !#$%#345675 )+$,+3896:9(!+*%+;49<79()#*,#;85<:5',\n 'I m m 2': ' !#$%# %#$!#()+*,+(,+*)+',\n 'I b a 2': ' !#$%#(,#*)#()+*,+ %+$!+',\n 'I m a 2': ' !#$%#(%#*!#()+*,+ ,+$)+',\n 'P 2/m 2/m 2/m': ' !#$%#$!& %&$%& !& %#$!#',\n 'P 2/n 2/n 2/n': ' !#$%#$!& %&*,-()-(,+*)+',\n 'P 2/c 2/c 2/m': ' !#$%#$!- %-$%& !& %+$!+',\n 'P 2/b 2/a 2/n': ' !#$%#$!& %&*,&()&(,#*)#',\n 'P 21/m 2/m 2/a': ' !#*%#$!&(%&$%&(!& %#*!#',\n 'P 2/n 21/n 2/a': ' !#*%#*)- ,-$%&(!&(,+$)+',\n 'P 2/m 2/n 21/a': ' !#*%+*!- %&$%&(!-(%+$!#',\n 'P 21/c 2/c 2/a': ' !#*%#$!-(%-$%&(!& %+*!+',\n 'P 21/b 21/a 2/m': ' !#$%#*)&(,&$%& !&(,#*)#',\n 'P 21/c 21/c 2/n': ' !#*,#$)-(%-$%&()& ,+*!+',\n 'P 2/b 21/c 21/m': ' !#$%+$)- ,&$%& !- ,+$)#',\n 'P 21/n 21/n 2/m': ' !#$%#*)-(,-$%& !&(,+*)+',\n 'P 21/m 21/m 2/n': \" !#$%#*'&.,&*,&.'& %#$!#\",\n 'P 21/b 2/c 21/n': ' !#*,+$!-(,&$%&()- %+*)#',\n 'P 21/b 21/c 21/a': ' !#*%+$)-(,&$%&(!- ,+*)#',\n 'P 21/n 21/m 21/a': \" !#0%/$'&.12$%&.!2 1#0'/\",\n 'C 2/m 2/c 21/m': ' !#$%+$!- %&$%& !- %+$!#()#*,+*)-(,&*,&()-(,+*)#',\n 'C 2/m 2/c 21/a': ' !#$,+$)- %&$%& )- ,+$!#()#*%+*!-(,&*,&(!-(%+*)#',\n 'C 2/m 2/m 2/m': ' !#$%#$!& %&$%& !& %#$!#()#*,#*)&(,&*,&()&(,#*)#',\n 'C 2/c 2/c 2/m': ' !#$%#$!- %-$%& !& %+$!+()#*,#*)-(,-*,&()&(,+*)+',\n 'C 2/m 2/m 2/a': ' !#$,#$)& %&$%& )& ,#$!#()#*%#*!&(,&*,&(!&(%#*)#',\n 'C 2/c 2/c 2/a': ' !#*,#$!&(,&$,-(!- ,+*!+()#$%#*)& %&*%- )-(%+$)+',\n 'F 2/m 2/m 2/m': ' !#$%#$!& %&$%& !& %#$!# )+$,+$)- ,-$,- )- ,+$)+(!+*%+*!-(%-*%-(!-(%+*!+()#*,#*)&(,&*,&()&(,#*)#',\n 'F 2/d 2/d 2/d': ' !#$%#$!& %&64=37=345675 )+$,+$)- ,-68>3:>3896:9(!+*%+*!-(%-<4>;7>;49<79()#*,#*)&(,&<8=;:=;85<:5',\n 'I 2/m 2/m 2/m': ' !#$%#$!& %&$%& !& %#$!#()+*,+*)-(,-*,-()-(,+*)+',\n 'I 2/b 2/a 2/m': ' !#$%#*)&(,&$%& !&(,#*)#()+*,+$!- %-*,-()- %+$!+',\n 'I 21/b 21/c 21/a': ' !#*%+$)-(,&$%&(!- ,+*)#()+$,#*!& %-*,- )&(%#$!+',\n 'I 21/m 21/m 21/a': ' !#$,#$)& %&$%& )& ,#$!#()+*%+*!-(,-*,-(!-(%+*)+',\n 'P 4': ' !#$%#% #!$#',\n 'P 41': ' !#$%+% 5!$9',\n 'P 42': ' !#$%#% +!$+',\n 'P 43': ' !#$%+% 9!$5',\n 'I 4': ' !#$%#% #!$#()+*,+,(+)*+',\n 'I 41': ' !#*,+%(5)$9()+$%#, 9!*5',\n 'P -4': ' !#$%#!$&% &',\n 'I -4': ' !#$%#!$&% &()+*,+)*-,(-',\n 'P 4/m': ' !#$%#% #!$#$%& !&!$&% &',\n 'P 42/m': ' !#$%#% +!$+$%& !&!$-% -',\n 'P 4/n': ' !#$%#,(#)*#*,&()&!$&% &',\n 'P 42/n': ' !#$%#,(+)*+*,-()-!$&% &',\n 'I 4/m': ' !#$%#% #!$#$%& !&!$&% &()+*,+,(+)*+*,-()-)*-,(-',\n 'I 41/a': ' !#*,+%(5)$9$,=(!>!$&,(-()+$%#, 9!*5*%> )=)*-% &',\n 'P 4 2 2': ' !#$%#% #!$#$!& %&! &%$&',\n 'P 4 21 2': ' !#$%#,(#)*#*)&(,&! &%$&',\n 'P 41 2 2': ' !#$%+% 5!$9$!& %-! >%$=',\n 'P 41 21 2': ' !#$%+,(5)*9*)=(,>! &%$-',\n 'P 42 2 2': ' !#$%#% +!$+$!& %&! -%$-',\n 'P 42 21 2': ' !#$%#,(+)*+*)-(,-! &%$&',\n 'P 43 2 2': ' !#$%+% 9!$5$!& %-! =%$>',\n 'P 43 21 2': ' !#$%+,(9)*5*)>(,=! &%$-',\n 'I 4 2 2': ' !#$%#% #!$#$!& %&! &%$&()+*,+,(+)*+*)-(,-)(-,*-',\n 'I 41 2 2': ' !#*,+%(5)$9*!> ,=)(-%$&()+$%#, 9!*5$)=(%>! &,*-',\n 'P 4 m m': ' !#$%#% #!$# %#$!#%$#! #',\n 'P 4 b m': ' !#$%#% #!$#(,#*)#,*#)(#',\n 'P 42 c m': ' !#$%#% +!$+ %+$!+%$#! #',\n 'P 42 n m': ' !#$%#,(+)*+(,+*)+%$#! #',\n 'P 4 c c': ' !#$%#% #!$# %+$!+%$+! +',\n 'P 4 n c': ' !#$%#% #!$#(,+*)+,*+)(+',\n 'P 42 m c': ' !#$%#% +!$+ %#$!#%$+! +',\n 'P 42 b c': ' !#$%#% +!$+(,#*)#,*+)(+',\n 'I 4 m m': ' !#$%#% #!$# %#$!#%$#! #()+*,+,(+)*+(,+*)+,*+)(+',\n 'I 4 c m': ' !#$%#% #!$# %+$!+%$+! +()+*,+,(+)*+(,#*)#,*#)(#',\n 'I 41 m d': ' !#*,+%(5)$9 %#*)+%*5) 9()+$%#, 9!*5(,+$!#,$9!(5',\n 'I 41 c d': ' !#*,+%(5)$9 %+*)#%*9) 5()+$%#, 9!*5(,#$!+,$5!(9',\n 'P -4 2 m': ' !#$%#% &!$&$!& %&%$#! #',\n 'P -4 2 c': ' !#$%#% &!$&$!- %-%$+! +',\n 'P -4 21 m': ' !#$%#% &!$&*)&(,&,*#)(#',\n 'P -4 21 c': ' !#$%#% &!$&*)-(,-,*+)(+',\n 'P -4 m 2': ' !#$%#!$&% & %#$!#! &%$&',\n 'P -4 c 2': ' !#$%#% &!$& %+$!+! -%$-',\n 'P -4 b 2': ' !#$%#% &!$&(,#*)#)(&,*&',\n 'P -4 n 2': ' !#$%#% &!$&(,+*)+)(-,*-',\n 'I -4 m 2': ' !#$%#% &!$& %#$!#! &%$&()+*,+,(-)*-(,+*)+)(-,*-',\n 'I -4 c 2': ' !#$%#% &!$& %+$!+! -%$-()+*,+,(-)*-(,#*)#)(&,*&',\n 'I -4 2 m': ' !#$%#% &!$&$!& %&%$#! #()+*,+,(-)*-*)-(,-,*+)(+',\n 'I -4 2 d': ' !#$%#% &!$&*!>(%>,$9) 9()+*,+,(-)*-$)= ,=%*5!(5',\n 'P 4/m 2/m 2/m': ' !#$%#% #!$#$!& %&! &%$&$%& !&!$&% & %#$!#%$#! #',\n 'P 4/m 2/c 2/c': ' !#$%#% #!$#$!- %-! -%$-$%& !&!$&% & %+$!+%$+! +',\n 'P 4/n 2/b 2/m': ' !#$%#% #!$#$!& %&! &%$&*,&()&)*&,(&(,#*)#,*#)(#',\n 'P 4/n 2/n 2/c': ' !#$%#% #!$#$!& %&! &%$&*,-()-)*-,(-(,+*)+,*+)(+',\n 'P 4/m 21/b 2/m': ' !#$%#% #!$#*)&(,&)(&,*&$%& !&!$&% &(,#*)#,*#)(#',\n 'P 4/m 21/n 2/c': ' !#$%#% #!$#*)-(,-)(-,*-$%& !&!$&% &(,+*)+,*+)(+',\n 'P 4/n 21/m 2/m': ' !#$%#,(#)*#*)&(,&! &%$&*,&()&!$&% & %#$!#,*#)(#',\n 'P 4/n 2/c 2/c': ' !#$%#,(#)*#*)-(,-! -%$-*,&()&!$&% & %+$!+,*+)(+',\n 'P 42/m 2/m 2/c': ' !#$%#% +!$+$!& %&! -%$-$%& !&!$-% - %#$!#%$+! +',\n 'P 42/m 2/c 2/m': ' !#$%#% +!$+$!- %-! &%$&$%& !&!$-% - %+$!+%$#! #',\n 'P 42/n 2/b 2/c': ' !#$%#,(+)*+$!- %-)(&,*&*,-()-!$&% &(,#*)#%$+! +',\n 'P 42/n 2/n 2/m': ' !#$%#,(+)*+$!& %&)(-,*-*,-()-!$&% &(,+*)+%$#! #',\n 'P 42/m 21/b 2/c': ' !#$%#% +!$+*)&(,&)(-,*-$%& !&!$-% -(,#*)#,*+)(+',\n 'P 42/m 21/n 2/m': \" !#$%#,./'*/*'-.,-! &%$&$%& !&'*-,.-.,/*'/%$#! #\",\n 'P 42/n 21/m 2/c': ' !#$%#,(+)*+*)-(,-! &%$&*,-()-!$&% & %#$!#,*+)(+',\n 'P 42/n 21/c 2/m': ' !#$%#,(+)*+*)&(,&! -%$-*,-()-!$&% & %+$!+,*#)(#',\n 'I 4/m 2/m 2/m': ' !#$%#% #!$#$!& %&! &%$&$%& !&!$&% & %#$!#%$#! #()+*,+,(+)*+*)-(,-)(-,*-*,-()-)*-,(-(,+*)+,*+)(+',\n 'I 4/m 2/c 2/m': ' !#$%#% #!$#$!- %-! -%$-$%& !&!$&% & %+$!+%$+! +()+*,+,(+)*+*)&(,&)(&,*&*,-()-)*-,(-(,#*)#,*#)(#',\n 'I 41/a 2/m 2/d': ' !#*,+%(5)$9*!> ,=)(-%$&$,=(!>!$&,(-(,+$!#,$9!(5()+$%#, 9!*5$)=(%>! &,*-*%> )=)*-% & %#*)+%*5) 9',\n 'I 41/a 2/c 2/d': ' !#*,+%(5)$9*!= ,>)(&%$-$,=(!>!$&,(-(,#$!+,$5!(9()+$%#, 9!*5$)>(%=! -,*&*%> )=)*-% & %+*)#%*9) 5',\n 'P 3': ' !#%?#@$#',\n 'P 31': ' !#%?A@$B',\n 'P 32': ' !#%?B@$A',\n 'H 3': ' !#%?#@$#CDAEFAGHAIJBKLBMNB',\n 'R 3': ' !## !!# ',\n 'P -3': ' !#%?#@$#$%&!@&? &',\n 'H -3': ' !#%?#@$#$%&!@&? &OPQRSQTUQVWXYZX[]X]Y^W[^ZV^UR_PT_SO_',\n 'R -3': ' !## !!# $%&&$%%&$',\n 'P 3 1 2': ' !#%?#@$#%$&@!& ?&',\n 'P 3 2 1': ' !#%?#@$#! &?%&$@&',\n 'P 31 1 2': ' !#%?Q@$^%$_@!X ?&',\n 'P 31 2 1': ' !#%?A@$B! &?%_$@X',\n 'P 32 1 2': ' !#%?^@$Q%$X@!_ ?&',\n 'P 32 2 1': ' !#%?B@$A! &?%X$@_',\n 'H 3 2': ' !#%?#@$#! &?%&$@&OPQRSQTUQY]X[WXVZX]Y^W[^ZV^PO_SR_UT_',\n 'R 3 2': ' !## !!# %$&$&%&%$',\n 'P 3 m 1': ' !#%?#@$#%$#@!# ?#',\n 'P 3 1 m': ' !#%?#@$#! #?%#$@#',\n 'P 3 c 1': ' !#%?#@$#%$+@!+ ?+',\n 'P 3 1 c': ' !#%?#@$#! +?%+$@+',\n 'H 3 m': ' !#%?#@$#%$#@!# ?#OPQRSQTUQRUQTPQOSQ]Y^W[^ZV^WV^ZY^][^',\n 'R 3 m': ' !## !!# ! # #!#! ',\n 'H 3 c': ' !#%?#@$#%$+@!+ ?+OPQRSQTUQRU`TP`OS`]Y^W[^ZV^WVaZYa][a',\n 'R 3 c': \" !## !!# '././'/'.\",\n 'P -3 1 2/m': ' !#%?#@$#%$&@!& ?&$%&!@&? &! #?%#$@#',\n 'P -3 1 2/c': ' !#%?#@$#%$-@!- ?-$%&!@&? &! +?%+$@+',\n 'P -3 2/m 1': ' !#%?#@$#! &?%&$@&$%&!@&? &%$#@!# ?#',\n 'P -3 2/c 1': ' !#%?#@$#! -?%-$@-$%&!@&? &%$+@!+ ?+',\n 'H -3 2/m': ' !#%?#@$#! &?%&$@&$%&!@&? &%$#@!# ?#OPQRSQTUQY]X[WXVZXVWXYZX[]XRUQTPQOSQ]Y^W[^ZV^PO_SR_UT_UR_PT_SO_WV^ZY^][^',\n 'R -3 2/m': ' !## !!# %$&$&%&%$$%&&$%%&$! # #!#! ',\n 'H -3 2/c': ' !#%?#@$#! -?%-$@-$%&!@&? &%$+@!+ ?+OPQRSQTUQY]b[WbVZbVWXYZX[]XRU`TP`OS`]Y^W[^ZV^POcSRcUTcUR_PT_SO_WVaZYa][a',\n 'R -3 2/c': \" !## !!# 102021210$%&&$%%&$'././'/'.\",\n 'P 6': ' !#%?#@$#$%#!@#? #',\n 'P 61': ' !#%?A@$B$%/!@d? e',\n 'P 65': ' !#%?B@$A$%/!@e? d',\n 'P 62': ' !#%?^@$Q$%#!@^? Q',\n 'P 64': ' !#%?Q@$^$%#!@Q? ^',\n 'P 63': ' !#%?#@$#$%+!@+? +',\n 'P -6': ' !#%?#@$# !&%?&@$&',\n 'P 6/m': ' !#%?#@$#$%#!@#? #$%&!@&? & !&%?&@$&',\n 'P 63/m': ' !#%?#@$#$%+!@+? +$%&!@&? & !-%?-@$-',\n 'P 6 2 2': ' !#%?#@$#$%#!@#? #! &?%&$@&%$&@!& ?&',\n 'P 61 2 2': ' !#%?Q@$^$%+!@`? a! X?%&$@_%$b@!- ?c',\n 'P 65 2 2': ' !#%?^@$Q$%+!@a? `! _?%&$@X%$c@!- ?b',\n 'P 62 2 2': ' !#%?^@$Q$%#!@^? Q! _?%&$@X%$_@!& ?X',\n 'P 64 2 2': ' !#%?Q@$^$%#!@Q? ^! X?%&$@_%$X@!& ?_',\n 'P 63 2 2': ' !#%?#@$#$%+!@+? +! &?%&$@&%$-@!- ?-',\n 'P 6 m m': ' !#%?#@$#$%#!@#? #%$#@!# ?#! #?%#$@#',\n 'P 6 c c': ' !#%?#@$#$%#!@#? #%$+@!+ ?+! +?%+$@+',\n 'P 63 c m': ' !#%?#@$#$%+!@+? +%$+@!+ ?+! #?%#$@#',\n 'P 63 m c': ' !#%?#@$#$%+!@+? +%$#@!# ?#! +?%+$@+',\n 'P -6 m 2': ' !#%?#@$# !&%?&@$&%$#@!# ?#%$&@!& ?&',\n 'P -6 c 2': ' !#%?#@$# !-%?-@$-%$+@!+ ?+%$&@!& ?&',\n 'P -6 2 m': ' !#%?#@$# !&%?&@$&! &?%&$@&! #?%#$@#',\n 'P -6 2 c': ' !#%?#@$# !-%?-@$-! &?%&$@&! +?%+$@+',\n 'P 6/m 2/m 2/m': ' !#%?#@$#$%#!@#? #! &?%&$@&%$&@!& ?&$%&!@&? & !&@$&%?&%$#@!# ?#! #?%#$@#',\n 'P 6/m 2/c 2/c': ' !#%?#@$#$%#!@#? #! -?%-$@-%$-@!- ?-$%&!@&? & !&@$&%?&%$+@!+ ?+! +?%+$@+',\n 'P 63/m 2/c 2/m': ' !#%?#@$#$%+!@+? +! -?%-$@-%$&@!& ?&$%&!@&? & !-@$-%?-%$+@!+ ?+! #?%#$@#',\n 'P 63/m 2/m 2/c': ' !#%?#@$#$%+!@+? +! &?%&$@&%$-@!- ?-$%&!@&? & !-@$-%?-%$#@!# ?#! +?%+$@+',\n 'P 2 3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ',\n 'F 2 3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ',\n 'I 2 3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-(',\n 'P 21 3': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(',\n 'I 21 3': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- ',\n 'P 2/m -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$',\n 'P 2/n -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& *,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*',\n 'F 2/m -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$ )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-($,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(*%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- *,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$',\n 'F 2/d -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& 64=37=345675=64=375345674=67=3453756 )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(68>3:>3896:9=<8=;:5;85<:4><7>;49;79<(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(<4>;7>;49<79>68>3:93896:8=<:=;85;:5<()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- <8=;:=;8f<:f><4>;79;49<78>6:>3893:96',\n 'I 2/m -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-(*,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*',\n 'P 21/a -3': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&($%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*',\n 'I 21/a -3': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&($%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*()+$,#*g& %-+()#$,&*!- %)+(,#$!&*%- *,- )&(%#$!+-*,& )#(%+$!,-*)& %#(!+$',\n 'P 4 3 2': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$',\n 'P 42 3 2': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*',\n 'F 4 3 2': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$ )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(-%*-!*+%(+ +,$+)$-, -)#)*#,(&)(&,*(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() -,$-)$+, +(#,*#)*&,(&)+!*+%(-!(-%*()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(&,*&)*#,(#(+%*+!*-%(-!+)$+, -) -,$',\n 'F 41 3 2': ' !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=46 )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<(!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>86',\n 'I 4 3 2': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*',\n 'P 43 3 2': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(7;>46=:<5839398<5:6=4;>75:<983>7;=46',\n 'P 41 3 2': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<',\n 'I 41 3 2': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- 7;>46=:<5839398<5:6=4;>75:<983>7;=46',\n 'P -4 3 m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% ',\n 'F -4 3 m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(+%*+!*-%(- +)$+,$-) -,#)(#,*&)*&,((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() +,$+)$-, -(#)*#,*&)(&,+!(+%*-!*-%(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(#,*#)*&,(&(+!*+%*-!(-%+) +,$-)$-, ',\n 'I -4 3 m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,(',\n 'P -4 3 n': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,(',\n 'F -4 3 c': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,( )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-() #,$#)$&, &(#!*#%*&!(&%+! +%$-!$-% (!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(!(#%*#!*&%(& +!$+%$-! -%#) #,$&)$&, ()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ! +%$+!$-% - #)$#,$&) &,#!(#%*&!*&%(',\n 'I -4 3 d': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(7354<9:6>8;=357<946>:;=857394<>:6=8;()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- :;98657<=43>;9:658<=73>49:;586=7<>43',\n 'P 4/m -3 2/m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ',\n 'P 4/n -3 2/n': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$*,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(',\n 'P 42/m -3 2/n': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(',\n 'P 42/n -3 2/m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,**,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ',\n 'F 4/m -3 2/m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(-%*-!*+%(+ +,$+)$-, -)#)*#,(&)(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,-%(&)*+,$#! )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<68>37=;49<:5=<8>;753496:4><:=;893756,*#!(+% &)$-*-!(&, +)$#%-, &!$+%*#)((!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<<4>;:=389675>68=379;45<:8=<7>;453:96%$#) +,(&!*-$&! -,(#)*+%&% -)$#,*+!(()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>86<8=;7>3456:9><4=;:9385678>67=349;:5<%*+)(#, -!$&$-) &%(+!*#,&,(-!*#%$+) ',\n 'F 41/d -3 2/c': ' !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=46<8>;7=3496:5><8=;793456:8><7=;493:56%*#)(+, &!$-$-! &,(+)*#%&, -!$#%*+)( )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<<4=;:>385679>64=3:9;85<78=67>345;:9<%$+) #,(-!*&$&) -%(#!*+,&%(-)*#,$+! (!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<68=37>;45<:9=<4>;:5389674>6:=389;75<,*+!(#% -)$&*-)(&% +!$#,-,(&!*+%$#) ()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>8664>3:=;89<75=68>375;49<:4=<:>;853796,$#! +%(&)*-*&!(-, #)$+%-% &)$+,*#!(',\n 'I 4/m -3 2/m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,**,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(',\n 'I 41/a -3 2/d': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<$%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*4<97358;=:6>6>:;=8357<94=8;>:694<573()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- 7;>46=:<5839398<5:6=4;>75:<983>7;=46*,- )&(%#$!+-*,& )#(%+$!,-*)& %#(!+$865:;943>7<=<=73>4;9:658>43=7<5869:;',\n 'P 1 1 2': ' !#$%#',\n 'P 1 1 21': ' !#$%+',\n 'B 1 1 2': ' !#$%#(g+*%+',\n 'A 1 2 1': ' !#$!& )+$)-',\n 'C 1 21 1': ' !#$)&()#*!&',\n 'I 1 2 1': \" !#$!&.'/0'2\",\n 'I 1 21 1': \" !#$)&.'/0!-\",\n 'P 1 1 m': ' !# !&',\n 'P 1 1 b': ' !# )&',\n 'B 1 1 m': ' !# !&(!+(!-',\n 'B 1 1 b': ' !# )&(!+()-',\n 'P 1 1 2/m': ' !# !&$%#$%&',\n 'P 1 1 21/m': ' !#$%+$%& !-',\n 'B 1 1 2/m': ' !# !&$%#$%&(!+(!-*%+*%-',\n 'P 1 1 2/b': ' !#$,#$%& )&',\n 'P 1 1 21/b': ' !#$%&$,+ )-',\n 'B 1 1 2/b': ' !#$,#$%& )&(!+*,+*%-()-',\n 'P 21 2 2': ' !#$!&(%&*%#',\n 'P 2 21 2': ' !# ,&$)&$%#',\n 'P 21 21 2 (a)': \" !#*,#.%&$'&\",\n 'P 21 2 21': ' !#$!&(%-*%+',\n 'P 2 21 21': ' !# %&$)-$,+',\n 'C 2 2 21a)': ' !#*%+(,&$)-()#$,+ %&*!-',\n 'C 2 2 2a': \" !#*,#.%&$'&()#$%# ,&*!&\",\n 'F 2 2 2a': \" !#*,#.%&$'& '/*%/.12$!2.!/$,/ %20'2.'#$%# 1&0!&\",\n 'I 2 2 2a': \" !#*,#.%&$'&()+$%+*!- ,-\",\n 'P 21/m 21/m 2/n a': \" !#*,#$)&(%&$%&.'& ,#*!#\",\n 'P 42 21 2a': \" !#*,#%.+'$+$'&.%&! -,*-\",\n 'I 2 3a': \" !#*,#.%&$'&!# ,- '&$%/$# !-*!/$%&.%()+$%+ ,-*!-)+(%&(!-*,#*+()&$)#*,- ,\"\n}\n","/**\n * @file Symmetry Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Log } from '../globals'\nimport { EncodedSymOp, SymOpCode } from './symmetry-constants'\n\nconst reInteger = /^[1-9]$/\n\nexport function getSymmetryOperations (spacegroup: string) {\n const encodedSymopList = EncodedSymOp[ spacegroup ]\n const matrixDict: { [k: string]: Matrix4 } = {}\n\n if (encodedSymopList === undefined) {\n console.warn(`spacegroup '${spacegroup}' not found in symop library`)\n return matrixDict\n }\n\n const symopList = []\n for (let i = 0, il = encodedSymopList.length; i < il; i += 3) {\n const symop = []\n for (let j = 0; j < 3; ++j) {\n symop.push(SymOpCode[ encodedSymopList[ i + j ] ])\n }\n symopList.push(symop)\n }\n\n symopList.forEach(function (symop) {\n let row = 0\n const matrix = new Matrix4().set(\n 0, 0, 0, 0,\n 0, 0, 0, 0,\n 0, 0, 0, 0,\n 0, 0, 0, 1\n )\n const me = matrix.elements\n\n matrixDict[ symop.toString() ] = matrix\n\n symop.forEach(function (elm) {\n let negate = false\n let denominator = false\n\n for (let i = 0, n = elm.length; i < n; ++i) {\n const c = elm[ i ]\n\n if (c === '-') {\n negate = true\n } else if (c === '+') {\n negate = false\n } else if (c === '/') {\n denominator = true\n } else if (c === 'X') {\n me[ 0 + row ] = negate ? -1 : 1\n } else if (c === 'Y') {\n me[ 4 + row ] = negate ? -1 : 1\n } else if (c === 'Z') {\n me[ 8 + row ] = negate ? -1 : 1\n } else if (reInteger.test(c)) {\n const integer = parseInt(c)\n if (denominator) {\n me[ 12 + row ] /= integer\n } else {\n me[ 12 + row ] = integer\n }\n } else {\n Log.warn(`getSymmetryOperations: unknown token '${c}'`)\n }\n }\n\n row += 1\n })\n })\n\n return matrixDict\n}\n","/**\n * @file Assembly\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Box3, Vector3 } from 'three'\n\nimport { uniqueArray } from '../utils'\nimport Selection from '../selection/selection'\nimport Structure from '../structure/structure'\nimport StructureView from '../structure/structure-view';\n\nfunction selectionFromChains (chainList: string[]) {\n let sele = ''\n if (chainList.length > 0) {\n sele = ':' + uniqueArray(chainList).join(' OR :')\n }\n return new Selection(sele)\n}\n\n/**\n * Assembly of transformed parts of a {@link Structure}\n */\nclass Assembly {\n partList: AssemblyPart[] = []\n\n /**\n * @param {String} name - assembly name\n */\n constructor (readonly name = '') {}\n\n get type () { return 'Assembly' }\n\n /**\n * Add transformed parts to the assembly\n * @example\n * var m1 = new NGL.Matrix4().set( ... );\n * var m2 = new NGL.Matrix4().set( ... );\n * var assembly = new NGL.Assembly( \"myAssembly\" );\n * // add part that transforms chain 'A' and 'B' using matrices `m1` and `m2`\n * assembly.addPart( [ m1, m2 ], [ \"A\", \"B\" ] )\n *\n * @param {Matrix4[]} matrixList - array of 4x4 transformation matrices\n * @param {String[]} chainList - array of chain names\n * @return {AssemblyPart} the added assembly part\n */\n addPart (matrixList?: Matrix4[], chainList?: string[]) {\n const part = new AssemblyPart(matrixList, chainList)\n this.partList.push(part)\n return part\n }\n\n /**\n * Get the number of atom for a given structure\n * @param {Structure} structure - the given structure\n * @return {Integer} number of atoms in the assembly\n */\n getAtomCount (structure: Structure) {\n return this.partList.reduce(\n (count, part) => count + part.getAtomCount(structure), 0\n )\n }\n\n /**\n * Get the number of residues for a given structure\n * @param {Structure} structure - the given structure\n * @return {Integer} number of residues in the assembly\n */\n getResidueCount (structure: Structure) {\n return this.partList.reduce(\n (count, part) => count + part.getResidueCount(structure), 0\n )\n }\n\n /**\n * Get number of instances the assembly will produce, i.e.\n * the number of transformations performed by the assembly\n * @return {Integer} number of instances\n */\n getInstanceCount () {\n let instanceCount = 0\n\n this.partList.forEach(function (part) {\n instanceCount += part.matrixList.length\n })\n\n return instanceCount\n }\n\n /**\n * Determine if the assembly is the full and untransformed structure\n * @param {Structure} structure - the given structure\n * @return {Boolean} whether the assembly is identical to the structure\n */\n isIdentity (structure: Structure) {\n if (this.partList.length !== 1) return false\n\n const part = this.partList[ 0 ]\n if (part.matrixList.length !== 1) return false\n\n const identityMatrix = new Matrix4()\n if (!identityMatrix.equals(part.matrixList[ 0 ])) return false\n\n let structureChainList: string[] = []\n structure.eachChain(function (cp) {\n structureChainList.push(cp.chainname)\n })\n structureChainList = uniqueArray(structureChainList)\n if (part.chainList.length !== structureChainList.length) return false\n\n return true\n }\n\n getBoundingBox (structure: Structure) {\n const boundingBox = new Box3()\n\n this.partList.forEach(function (part) {\n const partBox = part.getBoundingBox(structure)\n boundingBox.expandByPoint(partBox.min)\n boundingBox.expandByPoint(partBox.max)\n })\n\n return boundingBox\n }\n\n getCenter (structure: Structure) {\n return this.getBoundingBox(structure).getCenter(new Vector3())\n }\n\n getSelection () {\n let chainList: string[] = []\n this.partList.forEach(function (part) {\n chainList = chainList.concat(part.chainList)\n })\n return selectionFromChains(chainList)\n }\n}\n\nexport class AssemblyPart {\n constructor (readonly matrixList: Matrix4[] = [], readonly chainList: string[] = []) {}\n\n get type () { return 'AssemblyPart' }\n\n _getCount (structure: Structure, propertyName: 'atomCount'|'residueCount') {\n let count = 0\n\n structure.eachChain(cp => {\n if (this.chainList.length === 0 || this.chainList.includes(cp.chainname)) {\n count += cp[ propertyName ]\n }\n })\n\n return this.matrixList.length * count\n }\n\n getAtomCount (structure: Structure) {\n return this._getCount(structure, 'atomCount')\n }\n\n getResidueCount (structure: Structure) {\n return this._getCount(structure, 'residueCount')\n }\n\n getBoundingBox (structure: Structure) {\n const partBox = new Box3()\n const instanceBox = new Box3()\n\n const selection = this.getSelection()\n const structureBox = structure.getBoundingBox(selection)\n\n this.matrixList.forEach(function (matrix) {\n instanceBox.copy(structureBox).applyMatrix4(matrix)\n partBox.expandByPoint(instanceBox.min)\n partBox.expandByPoint(instanceBox.max)\n })\n\n return partBox\n }\n\n getSelection () {\n return selectionFromChains(this.chainList)\n }\n\n getView (structure: Structure): Structure | StructureView {\n const selection = this.getSelection()\n if (selection) {\n return structure.getView(selection)\n } else {\n return structure\n }\n }\n\n getInstanceList () {\n const instanceList = []\n for (let j = 0, jl = this.matrixList.length; j < jl; ++j) {\n instanceList.push({\n id: j + 1,\n name: j,\n matrix: this.matrixList[ j ]\n })\n }\n return instanceList\n }\n}\n\nexport default Assembly\n","/**\n * @file Structure Builder\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from './structure'\n\nclass StructureBuilder {\n currentModelindex: number|null = null\n currentChainid: string|null = null\n currentResname: string|null = null\n currentResno: number|null = null\n currentInscode: string|undefined = undefined\n currentHetero: boolean|null = null\n\n previousResname: string|null = ''\n previousHetero: boolean|null = null\n\n ai = -1\n ri = -1\n ci = -1\n mi = -1\n\n constructor(readonly structure: Structure) {}\n\n addResidueType (ri: number) {\n const atomStore = this.structure.atomStore\n const residueStore = this.structure.residueStore\n const residueMap = this.structure.residueMap\n\n const count = residueStore.atomCount[ ri ]\n const offset = residueStore.atomOffset[ ri ]\n const atomTypeIdList = new Array(count)\n for (let i = 0; i < count; ++i) {\n atomTypeIdList[ i ] = atomStore.atomTypeId[ offset + i ]\n }\n residueStore.residueTypeId[ ri ] = residueMap.add(\n this.previousResname!, atomTypeIdList, this.previousHetero! // TODO\n )\n }\n\n addAtom (modelindex: number, chainname: string, chainid: string, resname: string, resno: number, hetero: boolean, sstruc?: string|undefined, inscode?: string|undefined) {\n const atomStore = this.structure.atomStore\n const residueStore = this.structure.residueStore\n const chainStore = this.structure.chainStore\n const modelStore = this.structure.modelStore\n\n let addModel = false\n let addChain = false\n let addResidue = false\n\n if (this.currentModelindex !== modelindex) {\n addModel = true\n addChain = true\n addResidue = true\n this.mi += 1\n this.ci += 1\n this.ri += 1\n } else if (this.currentChainid !== chainid) {\n addChain = true\n addResidue = true\n this.ci += 1\n this.ri += 1\n } else if (this.currentResno !== resno || this.currentResname !== resname || this.currentInscode !== inscode) {\n addResidue = true\n this.ri += 1\n }\n this.ai += 1\n\n if (addModel) {\n modelStore.growIfFull()\n modelStore.chainOffset[ this.mi ] = this.ci\n modelStore.chainCount[ this.mi ] = 0\n modelStore.count += 1\n chainStore.modelIndex[ this.ci ] = this.mi\n }\n\n if (addChain) {\n chainStore.growIfFull()\n chainStore.setChainname(this.ci, chainname)\n chainStore.setChainid(this.ci, chainid)\n chainStore.residueOffset[ this.ci ] = this.ri\n chainStore.residueCount[ this.ci ] = 0\n chainStore.count += 1\n chainStore.modelIndex[ this.ci ] = this.mi\n modelStore.chainCount[ this.mi ] += 1\n residueStore.chainIndex[ this.ri ] = this.ci\n }\n\n if (addResidue) {\n this.previousResname = this.currentResname\n this.previousHetero = this.currentHetero\n if (this.ri > 0) this.addResidueType(this.ri - 1)\n residueStore.growIfFull()\n residueStore.resno[ this.ri ] = resno\n if (sstruc !== undefined) {\n residueStore.sstruc[ this.ri ] = sstruc.charCodeAt(0)\n }\n if (inscode !== undefined) {\n residueStore.inscode[ this.ri ] = inscode.charCodeAt(0)\n }\n residueStore.atomOffset[ this.ri ] = this.ai\n residueStore.atomCount[ this.ri ] = 0\n residueStore.count += 1\n residueStore.chainIndex[ this.ri ] = this.ci\n chainStore.residueCount[ this.ci ] += 1\n }\n\n atomStore.count += 1\n atomStore.residueIndex[ this.ai ] = this.ri\n residueStore.atomCount[ this.ri ] += 1\n\n this.currentModelindex = modelindex\n this.currentChainid = chainid\n this.currentResname = resname\n this.currentResno = resno\n this.currentInscode = inscode\n this.currentHetero = hetero\n }\n\n finalize () {\n this.previousResname = this.currentResname\n this.previousHetero = this.currentHetero\n if (this.ri > -1) this.addResidueType(this.ri)\n }\n}\n\nexport default StructureBuilder\n","/**\n * @file Structure Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4 } from 'three'\n\nimport { Debug, Log } from '../globals'\nimport { binarySearchIndexOf } from '../utils'\nimport Helixbundle from '../geometry/helixbundle'\nimport Kdtree from '../geometry/kdtree'\nimport { getSymmetryOperations } from '../symmetry/symmetry-utils'\nimport Assembly from '../symmetry/assembly'\nimport Structure from '../structure/structure'\nimport StructureBuilder from '../structure/structure-builder'\nimport Polymer from '../proxy/polymer'\nimport ResidueProxy from '../proxy/residue-proxy'\n\nimport { UnknownBackboneType, AA3, Bases, AtomicNumbers } from './structure-constants'\n\nexport function reorderAtoms (structure: Structure) {\n if (Debug) Log.time('reorderAtoms')\n\n var ap1 = structure.getAtomProxy()\n var ap2 = structure.getAtomProxy()\n\n function compareModelChainResno (index1: number, index2: number) {\n ap1.index = index1\n ap2.index = index2\n if (ap1.modelIndex < ap2.modelIndex) {\n return -1\n } else if (ap1.modelIndex > ap2.modelIndex) {\n return 1\n } else {\n if (ap1.chainname < ap2.chainname) {\n return -1\n } else if (ap1.chainname > ap2.chainname) {\n return 1\n } else {\n if (ap1.resno < ap2.resno) {\n return -1\n } else if (ap1.resno > ap2.resno) {\n return 1\n } else {\n return 0\n }\n }\n }\n }\n\n structure.atomStore.sort(compareModelChainResno)\n\n if (Debug) Log.timeEnd('reorderAtoms')\n}\n\nexport interface SecStruct {\n helices: [string, number, string, string, number, string, number][]\n sheets: [string, number, string, string, number, string][]\n}\n\nexport function assignSecondaryStructure (structure: Structure, secStruct: SecStruct) {\n if (!secStruct) return\n\n if (Debug) Log.time('assignSecondaryStructure')\n\n const chainnames: string[] = []\n structure.eachModel(function (mp) {\n mp.eachChain(function (cp) {\n chainnames.push(cp.chainname)\n })\n })\n\n const chainnamesSorted = chainnames.slice().sort()\n const chainnamesIndex: number[] = []\n chainnamesSorted.forEach(function (c) {\n chainnamesIndex.push(chainnames.indexOf(c))\n })\n\n // helix assignment\n\n const helices = secStruct.helices.filter(function (h) {\n return binarySearchIndexOf(chainnamesSorted, h[ 0 ]) >= 0\n })\n\n helices.sort(function (h1, h2) {\n const c1 = h1[ 0 ]\n const c2 = h2[ 0 ]\n const r1 = h1[ 1 ]\n const r2 = h2[ 1 ]\n\n if (c1 === c2) {\n if (r1 === r2) {\n return 0\n } else {\n return r1 < r2 ? -1 : 1\n }\n } else {\n const idx1 = binarySearchIndexOf(chainnamesSorted, c1)\n const idx2 = binarySearchIndexOf(chainnamesSorted, c2)\n return chainnamesIndex[ idx1 ] < chainnamesIndex[ idx2 ] ? -1 : 1\n }\n })\n\n const residueStore = structure.residueStore\n\n structure.eachModel(function (mp) {\n let i = 0\n const n = helices.length\n if (n === 0) return\n let helix = helices[ i ]\n let helixRun = false\n let done = false\n\n mp.eachChain(function (cp) {\n let chainChange = false\n\n if (cp.chainname === helix[ 0 ]) {\n const count = cp.residueCount\n const offset = cp.residueOffset\n const end = offset + count\n\n for (let j = offset; j < end; ++j) {\n if (residueStore.resno[ j ] === helix[ 1 ] && // resnoBeg\n residueStore.getInscode(j) === helix[ 2 ] // inscodeBeg\n ) {\n helixRun = true\n }\n\n if (helixRun) {\n residueStore.sstruc[ j ] = helix[ 6 ]\n\n if (residueStore.resno[ j ] === helix[ 4 ] && // resnoEnd\n residueStore.getInscode(j) === helix[ 5 ] // inscodeEnd\n ) {\n helixRun = false\n i += 1\n\n if (i < n) {\n // must look at previous residues as\n // residues may not be ordered by resno\n j = offset - 1\n helix = helices[ i ]\n chainChange = cp.chainname !== helix[ 0 ]\n } else {\n done = true\n }\n }\n }\n\n if (chainChange || done) return\n }\n }\n })\n })\n\n // sheet assignment\n\n const sheets = secStruct.sheets.filter(function (s) {\n return binarySearchIndexOf(chainnamesSorted, s[ 0 ]) >= 0\n })\n\n sheets.sort(function (s1, s2) {\n const c1 = s1[ 0 ]\n const c2 = s2[ 0 ]\n\n if (c1 === c2) return 0\n const idx1 = binarySearchIndexOf(chainnamesSorted, c1)\n const idx2 = binarySearchIndexOf(chainnamesSorted, c2)\n return chainnamesIndex[ idx1 ] < chainnamesIndex[ idx2 ] ? -1 : 1\n })\n\n const strandCharCode = 'e'.charCodeAt(0)\n structure.eachModel(function (mp) {\n let i = 0\n const n = sheets.length\n if (n === 0) return\n let sheet = sheets[ i ]\n let sheetRun = false\n let done = false\n\n mp.eachChain(function (cp) {\n let chainChange = false\n\n if (cp.chainname === sheet[ 0 ]) {\n const count = cp.residueCount\n const offset = cp.residueOffset\n const end = offset + count\n\n for (let j = offset; j < end; ++j) {\n if (residueStore.resno[ j ] === sheet[ 1 ] && // resnoBeg\n residueStore.getInscode(j) === sheet[ 2 ] // inscodeBeg\n ) {\n sheetRun = true\n }\n\n if (sheetRun) {\n residueStore.sstruc[ j ] = strandCharCode\n\n if (residueStore.resno[ j ] === sheet[ 4 ] && // resnoEnd\n residueStore.getInscode(j) === sheet[ 5 ] // inscodeEnd\n ) {\n sheetRun = false\n i += 1\n\n if (i < n) {\n // must look at previous residues as\n // residues may not be ordered by resno\n j = offset - 1\n sheet = sheets[ i ]\n chainChange = cp.chainname !== sheet[ 0 ]\n } else {\n done = true\n }\n }\n }\n\n if (chainChange || done) return\n }\n }\n })\n })\n\n if (Debug) Log.timeEnd('assignSecondaryStructure')\n}\n\nexport const calculateSecondaryStructure = (function () {\n // Implementation for proteins based on \"pv\"\n //\n // assigns secondary structure information based on a simple and very fast\n // algorithm published by Zhang and Skolnick in their TM-align paper.\n // Reference:\n //\n // TM-align: a protein structure alignment algorithm based on the Tm-score\n // (2005) NAR, 33(7) 2302-2309\n\n const zhangSkolnickSS = function (polymer: Polymer, i: number, distances: number[], delta: number) {\n const structure = polymer.structure\n const offset = polymer.residueIndexStart\n const rp1 = structure.getResidueProxy()\n const rp2 = structure.getResidueProxy()\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n for (let j = Math.max(0, i - 2); j <= i; ++j) {\n for (let k = 2; k < 5; ++k) {\n if (j + k >= polymer.residueCount) {\n continue\n }\n\n rp1.index = offset + j\n rp2.index = offset + j + k\n ap1.index = rp1.traceAtomIndex\n ap2.index = rp2.traceAtomIndex\n\n const d = ap1.distanceTo(ap2)\n\n if (Math.abs(d - distances[ k - 2 ]) > delta) {\n return false\n }\n }\n }\n\n return true\n }\n\n const isHelical = function (polymer: Polymer, i: number) {\n const helixDistances = [ 5.45, 5.18, 6.37 ]\n const helixDelta = 2.1\n return zhangSkolnickSS(polymer, i, helixDistances, helixDelta)\n }\n\n const isSheet = function (polymer: Polymer, i: number) {\n const sheetDistances = [ 6.1, 10.4, 13.0 ]\n const sheetDelta = 1.42\n return zhangSkolnickSS(polymer, i, sheetDistances, sheetDelta)\n }\n\n const proteinPolymer = function (p: Polymer) {\n const residueStore = p.residueStore\n const offset = p.residueIndexStart\n for (let i = 0, il = p.residueCount; i < il; ++i) {\n let sstruc = 'c'\n if (isHelical(p, i)) {\n sstruc = 'h'\n } else if (isSheet(p, i)) {\n sstruc = 'e'\n }\n residueStore.sstruc[ offset + i ] = sstruc.charCodeAt(0)\n }\n }\n\n const cgPolymer = function (p: Polymer) {\n const localAngle = 20\n const centerDist = 2.0\n\n const residueStore = p.residueStore\n const offset = p.residueIndexStart\n\n const helixbundle = new Helixbundle(p)\n const pos = helixbundle.position\n\n const c1 = new Vector3()\n const c2 = new Vector3()\n\n for (let i = 0, il = p.residueCount; i < il; ++i) {\n c1.fromArray(pos.center as any, i * 3) // TODO\n c2.fromArray(pos.center as any, i * 3 + 3) // TODO\n const d = c1.distanceTo(c2)\n\n if (d < centerDist && d > 1.0 && pos.bending[ i ] < localAngle) {\n residueStore.sstruc[ offset + i ] = 'h'.charCodeAt(0)\n residueStore.sstruc[ offset + i + 1 ] = 'h'.charCodeAt(0)\n }\n }\n }\n\n return function calculateSecondaryStructure (structure: Structure) {\n if (Debug) Log.time('calculateSecondaryStructure')\n\n structure.eachPolymer(function (p) {\n // assign secondary structure\n if (p.residueCount < 4) return\n if (p.isCg()) {\n cgPolymer(p)\n } else if (p.isProtein()) {\n proteinPolymer(p)\n } else {\n return\n }\n\n // set lone secondary structure assignments to \"c\"\n let prevSstruc: string\n let sstrucCount = 0\n p.eachResidue(function (r: ResidueProxy) {\n if (r.sstruc === prevSstruc) {\n sstrucCount += 1\n } else {\n if (sstrucCount === 1) {\n r.index -= 1\n r.sstruc = 'c'\n }\n sstrucCount = 1\n prevSstruc = r.sstruc\n }\n })\n })\n\n if (Debug) Log.timeEnd('calculateSecondaryStructure')\n }\n}())\n\n// const ChainnameAlphabet = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\" +\n// \"abcdefghijklmnopqrstuvwxyz\" +\n// \"0123456789\";\nconst ChainnameAlphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\n\nexport function getChainname (index: number) {\n const n = ChainnameAlphabet.length\n let j = index\n let k = 0\n let chainname = ChainnameAlphabet[j % n]\n while (j >= n) {\n j = Math.floor(j / n)\n chainname += ChainnameAlphabet[j % n]\n k += 1\n }\n if (k >= 5) {\n Log.warn('chainname overflow')\n }\n return chainname\n}\n\ninterface ChainData {\n mIndex: number\n chainname: string\n rStart: number\n rCount: number\n}\n\n/**\n * When no chain names are set for the given structure, calculates\n * chains based on:\n * - polymer connectivity: when adjacent residues are not bonded, a new chain is created.\n * - non polymer chemical type: adjacent residues which are not polymers but are of the same\n * chemical type (e.g. water molecules) are grouped into the same chain.\n **/\nexport function calculateChainnames (structure: Structure, useExistingBonds = false) {\n if (Debug) Log.time('calculateChainnames')\n\n let doAutoChainName = true\n structure.eachChain(function (c) {\n if (c.chainname) doAutoChainName = false\n })\n\n if (doAutoChainName) {\n const modelStore = structure.modelStore\n const chainStore = structure.chainStore\n const residueStore = structure.residueStore\n\n const addChain = function (mIndex: number, chainname: string, rOffset: number, rCount: number) {\n const ci = chainStore.count\n for (let i = 0; i < rCount; ++i) {\n residueStore.chainIndex[ rOffset + i ] = ci\n }\n chainStore.growIfFull()\n chainStore.modelIndex[ ci ] = mIndex\n chainStore.setChainname(ci, chainname)\n chainStore.setChainid(ci, chainname)\n chainStore.residueOffset[ ci ] = rOffset\n chainStore.residueCount[ ci ] = rCount\n chainStore.count += 1\n modelStore.chainCount[ mIndex ] += 1\n }\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n let i = 0\n let mi = 0\n let rStart = 0\n let rEnd = 0\n const chainData: ChainData[] = []\n\n if (residueStore.count === 1) {\n chainData.push({\n mIndex: 0,\n chainname: 'A',\n rStart: 0,\n rCount: 1\n })\n } else {\n structure.eachResidueN(2, function (rp1: ResidueProxy, rp2: ResidueProxy) {\n let newChain = false\n\n const bbType1 = rp1.backboneType\n const bbType2 = rp2.backboneType\n const bbTypeUnk = UnknownBackboneType\n\n rEnd = rp1.index\n\n if (rp1.modelIndex !== rp2.modelIndex) {\n newChain = true\n } else if (rp1.moleculeType !== rp2.moleculeType) {\n newChain = true\n } else if (bbType1 !== bbTypeUnk && bbType1 === bbType2) {\n ap1.index = rp1.backboneEndAtomIndex\n ap2.index = rp2.backboneStartAtomIndex\n if (useExistingBonds) {\n newChain = !ap1.hasBondTo(ap2)\n } else {\n newChain = !ap1.connectedTo(ap2)\n }\n }\n\n // current chain goes to end of the structure\n if (!newChain && rp2.index === residueStore.count - 1) {\n newChain = true\n rEnd = rp2.index\n }\n\n if (newChain) {\n chainData.push({\n mIndex: mi,\n chainname: getChainname(i),\n rStart: rStart,\n rCount: rEnd - rStart + 1\n })\n\n i += 1\n\n if (rp1.modelIndex !== rp2.modelIndex) {\n i = 0\n mi += 1\n }\n\n // new chain for the last residue of the structure\n if (rp2.index === residueStore.count - 1 && rEnd !== rp2.index) {\n chainData.push({\n mIndex: mi,\n chainname: getChainname(i),\n rStart: residueStore.count - 1,\n rCount: 1\n })\n }\n\n rStart = rp2.index\n rEnd = rp2.index\n }\n })\n }\n\n //\n\n chainStore.count = 0\n modelStore.chainCount.fill(0, 0, modelStore.count)\n modelStore.chainOffset.fill(0, 0, modelStore.count)\n chainData.forEach(function (d) {\n addChain(d.mIndex, d.chainname, d.rStart, d.rCount)\n })\n\n let chainOffset = 0\n structure.eachModel(function (mp) {\n modelStore.chainOffset[ mp.index ] = chainOffset\n chainOffset += modelStore.chainCount[ mp.index ]\n })\n }\n\n if (Debug) Log.timeEnd('calculateChainnames')\n}\n\nexport function calculateBonds (structure: Structure, inferBonds: InferBondsOptions='all') {\n if (inferBonds === 'none') return \n if (Debug) Log.time('calculateBonds')\n\n calculateBondsWithin(structure, false, inferBonds)\n calculateBondsBetween(structure)\n\n if (Debug) Log.timeEnd('calculateBonds')\n}\n\n/**\n * Should Bonds be inferred for `all` atoms, `none` or `auto`\n * If `auto`, any hetgroup residue with at least one CONECT record will \n * not have bonding inferred, and will rely on the CONECT records\n */\nexport type InferBondsOptions = 'all' | 'none' | 'auto'\n\nexport interface ResidueBonds {\n atomIndices1: number[]\n atomIndices2: number[]\n bondOrders: number[]\n}\n\n\nconst BondOrderTable: { [k: string]: number } = {\n 'HIS|CD2|CG': 2,\n 'HIS|CE1|ND1': 2,\n 'ARG|CZ|NH2': 2,\n 'PHE|CE1|CZ': 2,\n 'PHE|CD2|CE2': 2,\n 'PHE|CD1|CG': 2,\n 'TRP|CD1|CG': 2,\n 'TRP|CD2|CE2': 2,\n 'TRP|CE3|CZ3': 2,\n 'TRP|CH2|CZ2': 2,\n 'ASN|CG|OD1': 2,\n 'GLN|CD|OE1': 2,\n 'TYR|CD1|CG': 2,\n 'TYR|CD2|CE2': 2,\n 'TYR|CE1|CZ': 2,\n 'ASP|CG|OD1': 2,\n 'GLU|CD|OE1': 2,\n\n 'G|C8|N7': 2,\n 'G|C4|C5': 2,\n 'G|C2|N3': 2,\n 'G|C6|O6': 2,\n 'C|C4|N3': 2,\n 'C|C5|C6': 2,\n 'C|C2|O2': 2,\n 'A|C2|N3': 2,\n 'A|C6|N1': 2,\n 'A|C4|C5': 2,\n 'A|C8|N7': 2,\n 'U|C5|C6': 2,\n 'U|C2|O2': 2,\n 'U|C4|O4': 2,\n\n 'DG|C8|N7': 2,\n 'DG|C4|C5': 2,\n 'DG|C2|N3': 2,\n 'DG|C6|O6': 2,\n 'DC|C4|N3': 2,\n 'DC|C5|C6': 2,\n 'DC|C2|O2': 2,\n 'DA|C2|N3': 2,\n 'DA|C6|N1': 2,\n 'DA|C4|C5': 2,\n 'DA|C8|N7': 2,\n 'DT|C5|C6': 2,\n 'DT|C2|O2': 2,\n 'DT|C4|O4': 2\n}\nfunction getBondOrderFromTable (resname: string, atomname1: string, atomname2: string) {\n [ atomname1, atomname2 ] = atomname1 < atomname2 ? [ atomname1, atomname2 ] : [ atomname2, atomname1 ]\n if (AA3.includes(resname) && atomname1 === 'C' && atomname2 === 'O') return 2\n if (Bases.includes(resname) && atomname1 === 'OP1' && atomname2 === 'P') return 2\n return BondOrderTable[ `${resname}|${atomname1}|${atomname2}` ] || 1\n}\n\nexport function calculateResidueBonds (r: ResidueProxy) {\n const structure = r.structure\n const a1 = structure.getAtomProxy()\n const a2 = structure.getAtomProxy()\n\n const count = r.atomCount\n const offset = r.atomOffset\n const end = offset + count\n const end1 = end - 1\n\n const atomIndices1 = []\n const atomIndices2 = []\n const bondOrders = []\n\n if (count > 500) {\n if (Debug) Log.warn('more than 500 atoms, skip residue for auto-bonding', r.qualifiedName())\n } else {\n if (count > 50) {\n const kdtree = new Kdtree(r, true)\n const radius = r.isCg() ? 1.2 : 2.3\n\n for (let i = offset; i < end1; ++i) {\n a1.index = i\n const maxd = a1.covalent + radius + 0.3\n const nearestAtoms = kdtree.nearest(a1 as any, Infinity, maxd * maxd) // TODO\n const m = nearestAtoms.length\n for (let j = 0; j < m; ++j) {\n a2.index = nearestAtoms[ j ].index\n if (a1.index < a2.index) {\n if (a1.connectedTo(a2)) {\n atomIndices1.push(a1.index - offset)\n atomIndices2.push(a2.index - offset)\n bondOrders.push(getBondOrderFromTable(a1.resname, a1.atomname, a2.atomname))\n }\n }\n }\n }\n } else {\n for (let i = offset; i < end1; ++i) {\n a1.index = i\n for (let j = i + 1; j <= end1; ++j) {\n a2.index = j\n if (a1.connectedTo(a2)) {\n atomIndices1.push(i - offset)\n atomIndices2.push(j - offset)\n bondOrders.push(getBondOrderFromTable(a1.resname, a1.atomname, a2.atomname))\n }\n }\n }\n }\n }\n\n return {\n atomIndices1: atomIndices1,\n atomIndices2: atomIndices2,\n bondOrders: bondOrders\n }\n}\n\nexport function calculateAtomBondMap (structure: Structure) {\n if (Debug) Log.time('calculateAtomBondMap')\n\n var atomBondMap: number[][] = []\n\n structure.eachBond(function (bp) {\n var ai1 = bp.atomIndex1\n var ai2 = bp.atomIndex2\n if (atomBondMap[ ai1 ] === undefined) atomBondMap[ ai1 ] = []\n atomBondMap[ ai1 ][ ai2 ] = bp.index\n })\n\n if (Debug) Log.timeEnd('calculateAtomBondMap')\n\n return atomBondMap\n}\n\nexport function calculateBondsWithin (structure: Structure, onlyAddRung = false, inferBonds: InferBondsOptions='all') {\n if (Debug) Log.time('calculateBondsWithin')\n\n const bondStore = structure.bondStore\n const rungBondStore = structure.rungBondStore\n const rungAtomSet = structure.getAtomSet(false)\n const a1 = structure.getAtomProxy()\n const a2 = structure.getAtomProxy()\n const bp = structure.getBondProxy()\n const atomBondMap = onlyAddRung ? null : calculateAtomBondMap(structure)\n\n let bondedAtoms: Set\n if (!onlyAddRung && inferBonds === 'auto') {\n bondedAtoms = new Set()\n atomBondMap!.forEach((a, i) => {\n bondedAtoms.add(i)\n a.forEach(j => {bondedAtoms.add(j)})\n })\n }\n\n structure.eachResidue(function (r) {\n if (!onlyAddRung && atomBondMap) {\n const count = r.atomCount\n const offset = r.atomOffset\n\n if (count > 500) {\n Log.warn('more than 500 atoms, skip residue for auto-bonding', r.qualifiedName())\n return\n }\n\n if (inferBonds === 'auto' && r.hetero) {\n // Are bonds present on this residue?\n for (let rai=r.atomOffset; rai {\n ncsMatrixList.forEach(nm => {\n ncsUnitcellMatrixList.push(sm.clone().multiply(nm))\n })\n })\n unitcellAssembly.addPart(ncsUnitcellMatrixList)\n } else {\n unitcellAssembly.addPart(unitcellMatrixList)\n }\n\n const vec = new Vector3()\n const supercellAssembly = new Assembly('SUPERCELL')\n const supercellMatrixList = Array.prototype.concat.call(\n getMatrixList(vec.set(1, 0, 0)), // 655\n getMatrixList(vec.set(0, 1, 0)), // 565\n getMatrixList(vec.set(0, 0, 1)), // 556\n\n getMatrixList(vec.set(-1, 0, 0)), // 455\n getMatrixList(vec.set(0, -1, 0)), // 545\n getMatrixList(vec.set(0, 0, -1)), // 554\n\n getMatrixList(vec.set(1, 1, 0)), // 665\n getMatrixList(vec.set(1, 0, 1)), // 656\n getMatrixList(vec.set(0, 1, 1)), // 566\n\n getMatrixList(vec.set(-1, -1, 0)), // 445\n getMatrixList(vec.set(-1, 0, -1)), // 454\n getMatrixList(vec.set(0, -1, -1)), // 544\n\n getMatrixList(vec.set(1, -1, -1)), // 644\n getMatrixList(vec.set(1, 1, -1)), // 664\n getMatrixList(vec.set(1, -1, 1)), // 646\n getMatrixList(vec.set(-1, 1, 1)), // 466\n getMatrixList(vec.set(-1, -1, 1)), // 446\n getMatrixList(vec.set(-1, 1, -1)), // 464\n\n getMatrixList(vec.set(0, 1, -1)), // 564\n getMatrixList(vec.set(0, -1, 1)), // 546\n getMatrixList(vec.set(1, 0, -1)), // 654\n getMatrixList(vec.set(-1, 0, 1)), // 456\n getMatrixList(vec.set(1, -1, 0)), // 645\n getMatrixList(vec.set(-1, 1, 0)), // 465\n\n getMatrixList(), // 555\n getMatrixList(vec.set(1, 1, 1)), // 666\n getMatrixList(vec.set(-1, -1, -1)) // 444\n )\n if (structure.biomolDict.NCS) {\n const ncsSupercellMatrixList: Matrix4[] = []\n supercellMatrixList.forEach(function (sm: Matrix4) {\n ncsMatrixList.forEach(function (nm) {\n ncsSupercellMatrixList.push(sm.clone().multiply(nm))\n })\n })\n supercellAssembly.addPart(ncsSupercellMatrixList)\n } else {\n supercellAssembly.addPart(supercellMatrixList)\n }\n\n structure.biomolDict.UNITCELL = unitcellAssembly\n structure.biomolDict.SUPERCELL = supercellAssembly\n\n if (Debug) Log.timeEnd('buildUnitcellAssembly')\n}\n\nconst elm1 = [ 'H', 'C', 'O', 'N', 'S', 'P' ]\nconst elm2 = [ 'NA', 'CL', 'FE' ]\n\nexport function guessElement (atomName: string) {\n // Retain first group of letters in atomName\n let at = atomName.toUpperCase()\n let begin = 0, end = 0\n for (let i = 0; i < at.length ; i++) {\n if (at.charCodeAt(i) < 65) {\n if (end > 0) break\n ++begin\n }\n else end = i + 1\n }\n if (begin > 0 || end < at.length) at = at.substring(begin, end)\n \n const n = at.length\n\n if (n === 0) return ''\n if (n === 1) return at\n if (n === 2) {\n if (elm2.indexOf(at) !== -1) return at\n if (elm1.indexOf(at[0]) !== -1) return at[0]\n if (at in AtomicNumbers) return at\n }\n if (n >= 3) {\n if (elm1.indexOf(at[0]) !== -1) return at[0]\n }\n return ''\n}\n\n/**\n * Assigns ResidueType bonds.\n * @param {Structure} structure - the structure object\n * @return {undefined}\n */\nexport function assignResidueTypeBonds (structure: Structure) {\n // if( Debug ) Log.time( \"assignResidueTypeBonds\" )\n\n const bondHash = structure.bondHash! // TODO\n const countArray = bondHash.countArray\n const offsetArray = bondHash.offsetArray\n const indexArray = bondHash.indexArray\n const bp = structure.getBondProxy()\n\n structure.eachResidue(function (rp) {\n const residueType = rp.residueType\n if (residueType.bonds !== undefined) return\n\n var atomOffset = rp.atomOffset\n var atomIndices1: number[] = []\n var atomIndices2: number[] = []\n var bondOrders: number[] = []\n var bondDict: { [k: string]: boolean } = {}\n\n const nextAtomOffset = atomOffset + rp.atomCount\n\n rp.eachAtom(function (ap) {\n const index = ap.index\n const offset = offsetArray[ index ]\n const count = countArray[ index ]\n for (let i = 0, il = count; i < il; ++i) {\n bp.index = indexArray[ offset + i ]\n let idx1 = bp.atomIndex1\n if (idx1 < atomOffset || idx1 >= nextAtomOffset) {\n // Don't add bonds outside of this resiude\n continue\n }\n let idx2 = bp.atomIndex2\n if (idx2 < atomOffset || idx2 >= nextAtomOffset) {\n continue\n }\n\n if (idx1 > idx2) {\n const tmp = idx2\n idx2 = idx1\n idx1 = tmp\n }\n const hash = idx1 + '|' + idx2\n if (bondDict[ hash ] === undefined) {\n bondDict[ hash ] = true\n atomIndices1.push(idx1 - atomOffset)\n atomIndices2.push(idx2 - atomOffset)\n bondOrders.push(bp.bondOrder)\n }\n }\n })\n\n residueType.bonds = {\n atomIndices1: atomIndices1,\n atomIndices2: atomIndices2,\n bondOrders: bondOrders\n }\n })\n\n // if( Debug ) Log.timeEnd( \"assignResidueTypeBonds\" )\n}\n\nexport function concatStructures (name: string, ...structures: Structure[]) {\n if( Debug ) Log.time( \"concatStructures\" )\n\n const s = new Structure(name, '')\n const sb = new StructureBuilder(s)\n\n const atomStore = s.atomStore as any\n const atomMap = s.atomMap\n atomStore.addField('formalCharge', 1, 'int8')\n atomStore.addField('partialCharge', 1, 'float32')\n\n const atomIndexDict: { [k: number]: number } = {}\n\n let idx = 0\n let atomCount = 0\n let modelCount = 0\n structures.forEach(structure => {\n structure.eachAtom(a => {\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(a.atomname, a.element)\n\n atomStore.x[ idx ] = a.x\n atomStore.y[ idx ] = a.y\n atomStore.z[ idx ] = a.z\n atomStore.serial[ idx ] = a.serial\n atomStore.formalCharge[ idx ] = a.formalCharge\n atomStore.partialCharge[ idx ] = a.partialCharge\n atomStore.altloc[ idx ] = a.altloc\n atomStore.occupancy[ idx ] = a.occupancy\n atomStore.bfactor[ idx ] = a.bfactor\n\n sb.addAtom(\n a.modelIndex + modelCount,\n a.chainname,\n a.chainid,\n a.resname,\n a.resno,\n a.hetero === 1,\n a.sstruc,\n a.inscode\n )\n\n atomIndexDict[a.index + atomCount] = idx\n idx += 1\n })\n atomCount += structure.atomStore.count\n modelCount += structure.modelStore.count\n })\n\n const bondStore = s.bondStore\n const a1 = s.getAtomProxy()\n const a2 = s.getAtomProxy()\n\n atomCount = 0\n structures.forEach(structure => {\n structure.eachBond(b => {\n a1.index = atomIndexDict[ b.atomIndex1 + atomCount ]\n a2.index = atomIndexDict[ b.atomIndex2 + atomCount ]\n bondStore.addBond(a1, a2, b.bondOrder)\n })\n atomCount += structure.atomStore.count\n })\n\n sb.finalize()\n\n calculateBondsBetween(s, true) // calculate backbone bonds\n calculateBondsWithin(s, true) // calculate rung bonds\n\n s.finalizeAtoms()\n s.finalizeBonds()\n assignResidueTypeBonds(s)\n\n if( Debug ) Log.timeEnd( \"concatStructures\" )\n\n return s\n}\n","/**\n * @file Atom Type\n * @author Alexander Rose \n * @private\n */\n\nimport { guessElement } from '../structure/structure-utils'\nimport {\n AtomicNumbers, DefaultAtomicNumber,\n VdwRadii, DefaultVdwRadius,\n CovalentRadii, DefaultCovalentRadius,\n Valences, DefaultValence,\n OuterShellElectronCounts, DefaultOuterShellElectronCount\n} from '../structure/structure-constants'\nimport Structure from '../structure/structure'\n\n// Li, Na, K, Rb, Cs Fr\nconst AlkaliMetals = [ 3, 11, 19, 37, 55, 87 ]\n\n// Be, Mg, Ca, Sr, Ba, Ra\nconst AlkalineEarthMetals = [ 4, 12, 20, 38, 56, 88 ]\n\n// C, P, S, Se\nconst PolyatomicNonmetals = [ 6, 15, 16, 34, ]\n\n// H, N, O, F, Cl, Br, I\nconst DiatomicNonmetals = [ 1, 7, 8, 9, 17, 35, 53 ]\n\n// He, Ne, Ar, Kr, Xe, Rn\nconst NobleGases = [ 2, 10, 18, 36, 54, 86 ]\n\n// Zn, Ga, Cd, In, Sn, Hg, Ti, Pb, Bi, Po, Cn\nconst PostTransitionMetals = [ 13, 30, 31, 48, 49, 50, 80, 81, 82, 83, 84, 85, 112 ]\n\n// B, Si, Ge, As, Sb, Te, At\nconst Metalloids = [ 5, 14, 32, 33, 51, 52, 85 ]\n\n// F, Cl, Br, I, At\nconst Halogens = [ 9, 17, 35, 53, 85 ]\n\n/**\n * Atom type\n */\nclass AtomType {\n element: string\n number: number\n vdw: number\n covalent: number\n\n /**\n * @param {Structure} structure - the structure object\n * @param {String} atomname - the name of the atom\n * @param {String} element - the chemical element\n */\n constructor (readonly structure: Structure, readonly atomname: string, element?: string) {\n element = element || guessElement(atomname)\n\n this.element = element\n this.number = AtomicNumbers[ element ] || DefaultAtomicNumber\n this.vdw = VdwRadii[ this.number ] || DefaultVdwRadius\n this.covalent = CovalentRadii[ this.number ] || DefaultCovalentRadius\n }\n\n getDefaultValence() {\n const vl = Valences[ this.number ]\n return vl ? vl[ 0 ] : DefaultValence\n }\n\n getValenceList () {\n return Valences[ this.number ] || []\n }\n\n getOuterShellElectronCount () {\n return OuterShellElectronCounts[ this.number ] || DefaultOuterShellElectronCount\n }\n\n isMetal () {\n return (\n this.isAlkaliMetal() ||\n this.isAlkalineEarthMetal() ||\n this.isLanthanide() ||\n this.isActinide() ||\n this.isTransitionMetal() ||\n this.isPostTransitionMetal()\n )\n }\n\n isNonmetal () {\n return (\n this.isDiatomicNonmetal() ||\n this.isPolyatomicNonmetal() ||\n this.isNobleGas()\n )\n }\n\n isMetalloid () {\n return Metalloids.includes(this.number)\n }\n\n isHalogen () {\n return Halogens.includes(this.number)\n }\n\n isDiatomicNonmetal () {\n return DiatomicNonmetals.includes(this.number)\n }\n\n isPolyatomicNonmetal () {\n return PolyatomicNonmetals.includes(this.number)\n }\n\n isAlkaliMetal () {\n return AlkaliMetals.includes(this.number)\n }\n\n isAlkalineEarthMetal () {\n return AlkalineEarthMetals.includes(this.number)\n }\n\n isNobleGas () {\n return NobleGases.includes(this.number)\n }\n\n isTransitionMetal () {\n const no = this.number\n return (\n (no >= 21 && no <= 29) ||\n (no >= 39 && no <= 47) ||\n (no >= 72 && no <= 79) ||\n (no >= 104 && no <= 108)\n )\n }\n\n isPostTransitionMetal () {\n return PostTransitionMetals.includes(this.number)\n }\n\n isLanthanide () {\n return this.number >= 57 && this.number <= 71\n }\n\n isActinide () {\n return this.number >= 89 && this.number <= 103\n }\n\n}\n\nexport default AtomType","/**\n * @file Atom Map\n * @author Alexander Rose \n * @private\n */\n\nimport AtomType from './atom-type'\nimport { guessElement } from '../structure/structure-utils'\nimport Structure from '../structure/structure'\n\nfunction getHash (atomname: string, element: string) {\n return atomname + '|' + element\n}\n\nclass AtomMap {\n dict: { [k: string]: number } = {}\n list: AtomType[] = []\n\n constructor (readonly structure: Structure) {\n this.structure = structure\n }\n\n add (atomname: string, element?: string) {\n atomname = atomname.toUpperCase()\n if (!element) {\n element = guessElement(atomname)\n } else {\n element = element.toUpperCase()\n }\n const hash = getHash(atomname, element)\n let id = this.dict[ hash ]\n if (id === undefined) {\n const atomType = new AtomType(this.structure, atomname, element)\n id = this.list.length\n this.dict[ hash ] = id\n this.list.push(atomType)\n }\n return id\n }\n\n get (id: number) {\n return this.list[ id ]\n }\n}\n\nexport default AtomMap\n","/**\n * @file Residue Type\n * @author Alexander Rose \n * @author Fred Ludlow\n * @private\n */\n\nimport { defaults } from '../utils'\nimport PrincipalAxes from '../math/principal-axes'\nimport { Matrix } from '../math/matrix-utils'\nimport { calculateResidueBonds, ResidueBonds } from '../structure/structure-utils'\nimport {\n Elements,\n ProteinType, RnaType, DnaType, WaterType, IonType, SaccharideType, UnknownType,\n ProteinBackboneType, RnaBackboneType, DnaBackboneType, UnknownBackboneType,\n CgProteinBackboneType, CgRnaBackboneType, CgDnaBackboneType,\n ChemCompProtein, ChemCompRna, ChemCompDna, ChemCompSaccharide,\n AA3, PurinBases, RnaBases, DnaBases, Bases, IonNames, WaterNames, SaccharideNames,\n ProteinBackboneAtoms, NucleicBackboneAtoms, ResidueTypeAtoms\n} from '../structure/structure-constants'\nimport Structure from '../structure/structure'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\n\nexport interface BondGraph {\n [k: number]: number[]\n}\n\nexport interface RingData {\n atomRings: number[][] // sparse array:\n // atomRings[atomIdx] -> array of ring indices\n rings: number[][] // rings as arrays of indices\n}\n\n/**\n * Residue type\n */\nexport default class ResidueType {\n resname: string\n atomTypeIdList: number[]\n hetero: number\n chemCompType: string\n bonds?: ResidueBonds\n rings?: RingData\n bondGraph?: BondGraph\n aromaticAtoms?: Uint8Array\n aromaticRings?: number[][]\n\n atomCount: number\n\n moleculeType: number\n backboneType: number\n backboneEndType: number\n backboneStartType: number\n backboneIndexList: number[]\n\n traceAtomIndex: number\n direction1AtomIndex: number\n direction2AtomIndex: number\n backboneStartAtomIndex: number\n backboneEndAtomIndex: number\n rungEndAtomIndex: number\n\n // Sparse array containing the reference atom index for each bond.\n bondReferenceAtomIndices: number[] = []\n\n /**\n * @param {Structure} structure - the structure object\n * @param {String} resname - name of the residue\n * @param {Array} atomTypeIdList - list of IDs of {@link AtomType}s corresponding\n * to the atoms of the residue\n * @param {Boolean} hetero - hetero flag\n * @param {String} chemCompType - chemical component type\n * @param {Object} [bonds] - TODO\n */\n constructor (readonly structure: Structure, resname: string, atomTypeIdList: number[], hetero: boolean, chemCompType: string, bonds?: ResidueBonds) {\n this.resname = resname\n this.atomTypeIdList = atomTypeIdList\n this.hetero = hetero ? 1 : 0\n this.chemCompType = chemCompType\n this.bonds = bonds\n this.atomCount = atomTypeIdList.length\n\n this.moleculeType = this.getMoleculeType()\n this.backboneType = this.getBackboneType(0)\n this.backboneEndType = this.getBackboneType(-1)\n this.backboneStartType = this.getBackboneType(1)\n this.backboneIndexList = this.getBackboneIndexList()\n\n const atomnames = ResidueTypeAtoms[ this.backboneType ]\n const atomnamesStart = ResidueTypeAtoms[ this.backboneStartType ]\n const atomnamesEnd = ResidueTypeAtoms[ this.backboneEndType ]\n\n const traceIndex = this.getAtomIndexByName(atomnames.trace)\n this.traceAtomIndex = defaults(traceIndex, -1)\n\n const dir1Index = this.getAtomIndexByName(atomnames.direction1)\n this.direction1AtomIndex = defaults(dir1Index, -1)\n\n const dir2Index = this.getAtomIndexByName(atomnames.direction2)\n this.direction2AtomIndex = defaults(dir2Index, -1)\n\n const bbStartIndex = this.getAtomIndexByName(atomnamesStart.backboneStart)\n this.backboneStartAtomIndex = defaults(bbStartIndex, -1)\n\n const bbEndIndex = this.getAtomIndexByName(atomnamesEnd.backboneEnd)\n this.backboneEndAtomIndex = defaults(bbEndIndex, -1)\n\n let rungEndIndex\n if (PurinBases.includes(resname)) {\n rungEndIndex = this.getAtomIndexByName('N1')\n } else {\n rungEndIndex = this.getAtomIndexByName('N3')\n }\n this.rungEndAtomIndex = defaults(rungEndIndex, -1)\n }\n\n getBackboneIndexList () {\n const backboneIndexList: number[] = []\n let atomnameList\n switch (this.moleculeType) {\n case ProteinType:\n atomnameList = ProteinBackboneAtoms\n break\n case RnaType:\n case DnaType:\n atomnameList = NucleicBackboneAtoms\n break\n default:\n return backboneIndexList\n }\n const atomMap = this.structure.atomMap\n const atomTypeIdList = this.atomTypeIdList\n for (let i = 0, il = this.atomCount; i < il; ++i) {\n const atomType = atomMap.get(atomTypeIdList[ i ])\n if (atomnameList.includes(atomType.atomname)) {\n backboneIndexList.push(i)\n }\n }\n return backboneIndexList\n }\n\n getMoleculeType () {\n if (this.isProtein()) {\n return ProteinType\n } else if (this.isRna()) {\n return RnaType\n } else if (this.isDna()) {\n return DnaType\n } else if (this.isWater()) {\n return WaterType\n } else if (this.isIon()) {\n return IonType\n } else if (this.isSaccharide()) {\n return SaccharideType\n } else {\n return UnknownType\n }\n }\n\n getBackboneType (position: number) {\n if (this.hasProteinBackbone(position)) {\n return ProteinBackboneType\n } else if (this.hasRnaBackbone(position)) {\n return RnaBackboneType\n } else if (this.hasDnaBackbone(position)) {\n return DnaBackboneType\n } else if (this.hasCgProteinBackbone(position)) {\n return CgProteinBackboneType\n } else if (this.hasCgRnaBackbone(position)) {\n return CgRnaBackboneType\n } else if (this.hasCgDnaBackbone(position)) {\n return CgDnaBackboneType\n } else {\n return UnknownBackboneType\n }\n }\n\n isProtein () {\n if (this.chemCompType) {\n return ChemCompProtein.includes(this.chemCompType)\n } else {\n return (\n this.hasAtomWithName('CA', 'C', 'N') ||\n AA3.includes(this.resname)\n )\n }\n }\n\n isCg () {\n const backboneType = this.backboneType\n return (\n backboneType === CgProteinBackboneType ||\n backboneType === CgRnaBackboneType ||\n backboneType === CgDnaBackboneType\n )\n }\n\n isNucleic () {\n return this.isRna() || this.isDna()\n }\n\n isRna () {\n if (this.chemCompType) {\n return ChemCompRna.includes(this.chemCompType)\n } else if (this.hetero === 1) {\n return false\n } else {\n return (\n this.hasAtomWithName(\n [ 'P', \"O3'\", 'O3*' ], [ \"C4'\", 'C4*' ], [ \"O2'\", 'O2*', \"F2'\", 'F2*' ]\n ) ||\n (RnaBases.includes(this.resname) &&\n (this.hasAtomWithName([ \"O2'\", 'O2*', \"F2'\", 'F2*' ])))\n )\n }\n }\n\n isDna () {\n if (this.chemCompType) {\n return ChemCompDna.includes(this.chemCompType)\n } else if (this.hetero === 1) {\n return false\n } else {\n return (\n (this.hasAtomWithName([ 'P', \"O3'\", 'O3*' ], [ \"C3'\", 'C3*' ]) &&\n !this.hasAtomWithName([ \"O2'\", 'O2*', \"F2'\", 'F2*' ])) ||\n DnaBases.includes(this.resname)\n )\n }\n }\n\n isHetero () {\n return this.hetero === 1\n }\n\n isIon () {\n return IonNames.includes(this.resname)\n }\n\n isWater () {\n return WaterNames.includes(this.resname)\n }\n\n isSaccharide () {\n if (this.chemCompType) {\n return ChemCompSaccharide.includes(this.chemCompType)\n } else {\n return SaccharideNames.includes(this.resname)\n }\n }\n\n isStandardAminoacid () {\n return AA3.includes(this.resname)\n }\n\n isStandardBase () {\n return Bases.includes(this.resname)\n }\n\n hasBackboneAtoms (position: number, type: number) {\n const atomnames = ResidueTypeAtoms[ type ]\n if (position === -1) {\n return this.hasAtomWithName(\n atomnames.trace,\n atomnames.backboneEnd,\n atomnames.direction1,\n atomnames.direction2\n )\n } else if (position === 0) {\n return this.hasAtomWithName(\n atomnames.trace,\n atomnames.direction1,\n atomnames.direction2\n )\n } else if (position === 1) {\n return this.hasAtomWithName(\n atomnames.trace,\n atomnames.backboneStart,\n atomnames.direction1,\n atomnames.direction2\n )\n } else {\n return this.hasAtomWithName(\n atomnames.trace,\n atomnames.backboneStart,\n atomnames.backboneEnd,\n atomnames.direction1,\n atomnames.direction2\n )\n }\n }\n\n hasProteinBackbone (position: number) {\n return (\n this.isProtein() &&\n this.hasBackboneAtoms(position, ProteinBackboneType)\n )\n }\n\n hasRnaBackbone (position: number) {\n return (\n this.isRna() &&\n this.hasBackboneAtoms(position, RnaBackboneType)\n )\n }\n\n hasDnaBackbone (position: number) {\n return (\n this.isDna() &&\n this.hasBackboneAtoms(position, DnaBackboneType)\n )\n }\n\n hasCgProteinBackbone (position: number) {\n return (\n this.atomCount < 7 &&\n this.isProtein() &&\n this.hasBackboneAtoms(position, CgProteinBackboneType)\n )\n }\n\n hasCgRnaBackbone (position: number) {\n return (\n this.atomCount < 11 &&\n this.isRna() &&\n this.hasBackboneAtoms(position, CgRnaBackboneType)\n )\n }\n\n hasCgDnaBackbone (position: number) {\n return (\n this.atomCount < 11 &&\n this.isDna() &&\n this.hasBackboneAtoms(position, CgDnaBackboneType)\n )\n }\n\n hasBackbone (position: number) {\n return (\n this.hasProteinBackbone(position) ||\n this.hasRnaBackbone(position) ||\n this.hasDnaBackbone(position) ||\n this.hasCgProteinBackbone(position) ||\n this.hasCgRnaBackbone(position) ||\n this.hasCgDnaBackbone(position)\n )\n }\n\n getAtomIndexByName (atomname: string|string[]) {\n const n = this.atomCount\n const atomMap = this.structure.atomMap\n const atomTypeIdList = this.atomTypeIdList\n if (Array.isArray(atomname)) {\n for (let i = 0; i < n; ++i) {\n const index = atomTypeIdList[ i ]\n if (atomname.includes(atomMap.get(index).atomname)) {\n return i\n }\n }\n } else {\n for (let i = 0; i < n; ++i) {\n const index = atomTypeIdList[ i ]\n if (atomname === atomMap.get(index).atomname) {\n return i\n }\n }\n }\n return undefined\n }\n\n hasAtomWithName (...atomnames: (string|string[])[]) {\n const n = atomnames.length\n for (let i = 0; i < n; ++i) {\n if (atomnames[ i ] === undefined) continue\n if (this.getAtomIndexByName(atomnames[ i ]) === undefined) {\n return false\n }\n }\n return true\n }\n\n getBonds (r?: ResidueProxy) {\n if (this.bonds === undefined) {\n this.bonds = calculateResidueBonds(r!) // TODO\n }\n return this.bonds\n }\n\n getRings () {\n if (this.rings === undefined) {\n this.calculateRings()\n }\n return this.rings\n }\n\n getBondGraph () {\n if (this.bondGraph === undefined) {\n this.calculateBondGraph()\n }\n return this.bondGraph\n }\n\n getAromatic (a?: AtomProxy) {\n if (this.aromaticAtoms === undefined) {\n this.calculateAromatic(this.structure.getResidueProxy((a!).residueIndex)) // TODO\n }\n return this.aromaticAtoms\n }\n\n getAromaticRings (r?: ResidueProxy) {\n if (this.aromaticRings === undefined) {\n this.calculateAromatic(r!) // TODO\n }\n return this.aromaticRings\n }\n\n /**\n * @return {Object} bondGraph - represents the bonding in this\n * residue: { ai1: [ ai2, ai3, ...], ...}\n */\n calculateBondGraph () {\n const bondGraph: BondGraph = this.bondGraph = {}\n const bonds = this.getBonds()\n const nb = bonds.atomIndices1.length\n const atomIndices1 = bonds.atomIndices1\n const atomIndices2 = bonds.atomIndices2\n\n for (let i = 0; i < nb; ++i) {\n const ai1 = atomIndices1[i]\n const ai2 = atomIndices2[i]\n\n const a1 = bondGraph[ ai1 ] = bondGraph[ ai1 ] || []\n a1.push(ai2)\n\n const a2 = bondGraph[ ai2 ] = bondGraph[ ai2 ] || []\n a2.push(ai1)\n }\n }\n\n /**\n * Find all rings up to 2 * RingFinderMaxDepth\n */\n calculateRings () {\n const bondGraph = this.getBondGraph()! // TODO\n const state = RingFinderState(bondGraph, this.atomCount)\n\n for (let i = 0; i < state.count; i++) {\n if (state.visited[i] >= 0) continue\n findRings(state, i)\n }\n\n this.rings = { atomRings: state.atomRings, rings: state.rings }\n }\n\n isAromatic (atom: AtomProxy) {\n this.aromaticAtoms = this.getAromatic(atom)! // TODO\n return this.aromaticAtoms[atom.index - atom.residueAtomOffset] === 1\n }\n\n calculateAromatic (r: ResidueProxy) {\n const aromaticAtoms = this.aromaticAtoms = new Uint8Array(this.atomCount)\n const rings = this.getRings()!.rings\n\n const aromaticRingFlags = rings.map(ring => {\n return isRingAromatic(ring.map(idx => {\n return this.structure.getAtomProxy(idx + r.atomOffset)\n }))\n })\n\n const aromaticRings: number[][] = this.aromaticRings = []\n rings.forEach((ring, i) => {\n if (aromaticRingFlags[i]) {\n aromaticRings.push(ring)\n ring.forEach(idx => aromaticAtoms[idx] = 1)\n }\n })\n }\n\n /**\n * For bonds with order > 1, pick a reference atom\n * @return {undefined}\n */\n assignBondReferenceAtomIndices () {\n const bondGraph = this.getBondGraph()! // TODO\n const rings = this.getRings()! // TODO\n const atomRings = rings.atomRings\n const ringData = rings.rings\n\n const bonds = this.bonds! // TODO\n const atomIndices1 = bonds.atomIndices1\n const atomIndices2 = bonds.atomIndices2\n const bondOrders = bonds.bondOrders\n const bondReferenceAtomIndices = this.bondReferenceAtomIndices\n\n const nb = bonds.atomIndices1.length\n\n bondReferenceAtomIndices.length = 0 // reset array\n\n for (let i = 0; i < nb; ++i) {\n // Not required for single bonds\n if (bondOrders[i] <= 1) continue\n\n let refRing\n\n const ai1 = atomIndices1[i]\n const ai2 = atomIndices2[i]\n\n const rings1 = atomRings[ ai1 ]\n const rings2 = atomRings[ ai2 ]\n // Are both atoms in a ring?\n if (rings1 && rings2) {\n // Are they in the same ring? (If not, ignore ring info)\n for (let ri1 = 0; ri1 < rings1.length; ri1++){\n if (rings2.indexOf(rings1[ ri1 ]) !== -1) {\n refRing = ringData[ rings1[ ri1 ] ]\n break\n }\n }\n }\n\n // Find the first neighbour.\n if (bondGraph[ ai1 ].length > 1) {\n for (let j = 0; j < bondGraph[ ai1 ].length; ++j) {\n const ai3 = bondGraph[ ai1 ][ j ]\n if (ai3 !== ai2) {\n if (refRing === undefined || refRing.indexOf(ai3) !== -1){\n bondReferenceAtomIndices[i] = ai3\n break\n }\n }\n }\n } else if (bondGraph[ ai2 ].length > 1) {\n for (let j = 0; j < bondGraph[ ai2 ].length; ++j) {\n const ai3 = bondGraph[ ai2 ][ j ]\n if (ai3 !== ai1) {\n if (refRing === undefined || refRing.indexOf(ai3) !== -1){\n bondReferenceAtomIndices[i] = ai3\n break\n }\n }\n }\n } // No reference atom could be found (e.g. diatomic molecule/fragment)\n }\n }\n\n getBondIndex (atomIndex1: number, atomIndex2: number) {\n const bonds = this.bonds! // TODO\n const atomIndices1 = bonds.atomIndices1\n const atomIndices2 = bonds.atomIndices2\n let idx1 = atomIndices1.indexOf(atomIndex1)\n let idx2 = atomIndices2.indexOf(atomIndex2)\n const _idx2 = idx2\n while (idx1 !== -1) {\n while (idx2 !== -1) {\n if (idx1 === idx2) return idx1\n idx2 = atomIndices2.indexOf(atomIndex2, idx2 + 1)\n }\n idx1 = atomIndices1.indexOf(atomIndex1, idx1 + 1)\n idx2 = _idx2\n }\n // returns undefined when no bond is found\n }\n\n getBondReferenceAtomIndex (atomIndex1: number, atomIndex2: number) {\n const bondIndex = this.getBondIndex(atomIndex1, atomIndex2)\n if (bondIndex === undefined) return undefined\n if (this.bondReferenceAtomIndices.length === 0) {\n this.assignBondReferenceAtomIndices()\n }\n return this.bondReferenceAtomIndices[ bondIndex ]\n }\n}\n\n//\n\nconst AromaticRingElements = [\n Elements.B, Elements.C, Elements.N, Elements.O,\n Elements.SI, Elements.P, Elements.S,\n Elements.GE, Elements.AS,\n Elements.SN, Elements.SB,\n Elements.BI\n]\nconst AromaticRingPlanarityThreshold = 0.05\n\nfunction isRingAromatic (ring: AtomProxy[]) {\n if (ring.some(a => !AromaticRingElements.includes(a.number))) return false\n\n let i = 0\n const coords = new Matrix(3, ring.length)\n const cd = coords.data\n\n ring.forEach(a => {\n cd[ i + 0 ] = a.x\n cd[ i + 1 ] = a.y\n cd[ i + 2 ] = a.z\n i += 3\n })\n\n const pa = new PrincipalAxes(coords)\n\n return pa.vecC.length() < AromaticRingPlanarityThreshold\n}\n\n//\n\n/**\n * Ring finding code below adapted from MolQL\n * Copyright (c) 2017 MolQL contributors, licensed under MIT\n * @author David Sehnal \n */\n\nfunction addRing(state: RingFinderState, a: number, b: number) {\n // only \"monotonous\" rings\n if (b < a) return\n\n const { pred, color, left, right } = state\n const nc = ++state.currentColor\n\n let current = a\n\n for (let t = 0; t < RingFinderMaxDepth; t++) {\n color[current] = nc\n current = pred[current]\n if (current < 0) break\n }\n\n let leftOffset = 0\n let rightOffset = 0\n\n let found = false\n let target = 0\n current = b\n for (let t = 0; t < RingFinderMaxDepth; t++) {\n if (color[current] === nc) {\n target = current\n found = true\n break\n }\n right[rightOffset++] = current\n current = pred[current]\n if (current < 0) break\n }\n if (!found) return\n\n current = a\n for (let t = 0; t < RingFinderMaxDepth; t++) {\n left[leftOffset++] = current\n if (target === current) break\n current = pred[current]\n if (current < 0) break\n }\n\n const rn = leftOffset + rightOffset\n const ring: number[] = new Array(rn)\n let ringOffset = 0;\n for (let t = 0; t < leftOffset; t++) {\n ring[ringOffset++] = left[t]\n }\n for (let t = rightOffset - 1; t >= 0; t--) {\n ring[ringOffset++] = right[t]\n }\n\n const ri = state.rings.length\n // set atomRing indices:\n for (let i = 0; i < rn; ++i) {\n const ai = ring[i]\n if (state.atomRings[ai]) {\n state.atomRings[ai].push(ri)\n } else {\n state.atomRings[ai] = [ri]\n }\n }\n\n state.rings.push(ring)\n}\n\nfunction findRings(state: RingFinderState, from: number) {\n const { bonds, visited, queue, pred } = state\n\n visited[from] = 1\n queue[0] = from\n\n let head = 0\n let size = 1\n\n while (head < size) {\n const top = queue[head++]\n const start = 0\n if (bonds[top] === undefined) {\n continue\n }\n const end = bonds[top].length\n\n for (let i = start; i < end; i++) {\n const other = bonds[top][i]\n\n if (visited[other] > 0) {\n if (pred[other] !== top && pred[top] !== other) {\n addRing(state, top, other)\n }\n continue\n }\n\n visited[other] = 1\n queue[size++] = other\n pred[other] = top\n }\n }\n}\n\nconst RingFinderMaxDepth = 4\n\ninterface RingFinderState {\n count: number,\n visited: Int32Array,\n queue: Int32Array,\n color: Int32Array,\n pred: Int32Array,\n\n left: Int32Array,\n right: Int32Array,\n\n currentColor: number,\n\n rings: number[][],\n atomRings: number[][],\n\n bonds: BondGraph\n}\n\nfunction RingFinderState(bonds: BondGraph, capacity: number): RingFinderState {\n const state = {\n count: capacity,\n visited: new Int32Array(capacity),\n queue: new Int32Array(capacity),\n pred: new Int32Array(capacity),\n left: new Int32Array(RingFinderMaxDepth),\n right: new Int32Array(RingFinderMaxDepth),\n color: new Int32Array(capacity),\n currentColor: 0,\n rings: [],\n atomRings: [],\n bonds\n }\n for (let i = 0; i < capacity; i++) {\n state.visited[i] = -1\n state.pred[i] = -1\n }\n return state\n}\n","/**\n * @file Residue Map\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport { ResidueBonds } from '../structure/structure-utils'\nimport ResidueType from './residue-type'\n\nfunction getHash (resname: string, atomTypeIdList: number[], hetero: boolean, chemCompType = '') {\n return (\n resname + '|' +\n atomTypeIdList.join(',') + '|' +\n (hetero ? 1 : 0) + '|' +\n chemCompType\n )\n}\n\nclass ResidueMap {\n dict: { [k: string]: number } = {}\n list: ResidueType[] = []\n\n constructor (readonly structure: Structure) {}\n\n add (resname: string, atomTypeIdList: number[], hetero: boolean, chemCompType = '', bonds?: ResidueBonds) {\n resname = resname.toUpperCase()\n const hash = getHash(resname, atomTypeIdList, hetero, chemCompType)\n let id = this.dict[ hash ]\n if (id === undefined) {\n const residueType = new ResidueType(\n this.structure, resname, atomTypeIdList, hetero, chemCompType, bonds\n )\n id = this.list.length\n this.dict[ hash ] = id\n this.list.push(residueType)\n }\n return id\n }\n\n get (id: number) {\n return this.list[ id ]\n }\n}\n\nexport default ResidueMap\n","/**\n * @file Bond Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport Structure from '../structure/structure'\nimport BondStore from '../store/bond-store'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Bond proxy\n */\nclass BondProxy {\n index: number\n\n bondStore: BondStore\n\n private _v12: Vector3\n private _v13: Vector3\n private _ap1: AtomProxy\n private _ap2: AtomProxy\n private _ap3: AtomProxy\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.bondStore = structure.bondStore\n\n this._v12 = new Vector3()\n this._v13 = new Vector3()\n this._ap1 = this.structure.getAtomProxy()\n this._ap2 = this.structure.getAtomProxy()\n this._ap3 = this.structure.getAtomProxy()\n }\n\n /**\n * @type {AtomProxy}\n */\n get atom1 () {\n return this.structure.getAtomProxy(this.atomIndex1)\n }\n\n /**\n * @type {AtomProxy}\n */\n get atom2 () {\n return this.structure.getAtomProxy(this.atomIndex2)\n }\n\n /**\n * @type {Integer}\n */\n get atomIndex1 () {\n return this.bondStore.atomIndex1[ this.index ]\n }\n set atomIndex1 (value) {\n this.bondStore.atomIndex1[ this.index ] = value\n }\n\n /**\n * @type {Integer}\n */\n get atomIndex2 () {\n return this.bondStore.atomIndex2[ this.index ]\n }\n set atomIndex2 (value) {\n this.bondStore.atomIndex2[ this.index ] = value\n }\n\n /**\n * @type {Integer}\n */\n get bondOrder () {\n return this.bondStore.bondOrder[ this.index ]\n }\n set bondOrder (value) {\n this.bondStore.bondOrder[ this.index ] = value\n }\n\n getOtherAtomIndex (atomIndex: number) {\n return atomIndex === this.atomIndex1 ? this.atomIndex2 : this.atomIndex1\n }\n\n getOtherAtom (atom: AtomProxy) {\n return this.structure.getAtomProxy(this.getOtherAtomIndex(atom.index))\n }\n\n /**\n * Get reference atom index for the bond\n * @return {Integer|undefined} atom index, or `undefined` if unavailable\n */\n getReferenceAtomIndex () {\n const ap1 = this._ap1\n const ap2 = this._ap2\n ap1.index = this.atomIndex1\n ap2.index = this.atomIndex2\n if (ap1.residueIndex !== ap2.residueIndex) {\n return undefined // Bond between residues, for now ignore (could detect)\n }\n const typeAtomIndex1 = ap1.index - ap1.residueAtomOffset\n const typeAtomIndex2 = ap2.index - ap2.residueAtomOffset\n const residueType = ap1.residueType\n const ix = residueType.getBondReferenceAtomIndex(typeAtomIndex1, typeAtomIndex2)\n if (ix !== undefined) {\n return ix + ap1.residueAtomOffset\n } else {\n console.warn('No reference atom found', ap1.index, ap2.index)\n }\n }\n\n /**\n * calculate shift direction for displaying double/triple bonds\n * @param {Vector3} [v] pre-allocated output vector\n * @return {Vector3} the shift direction vector\n */\n calculateShiftDir (v = new Vector3()) {\n const ap1 = this._ap1\n const ap2 = this._ap2\n const ap3 = this._ap3\n const v12 = this._v12\n const v13 = this._v13\n\n ap1.index = this.atomIndex1\n ap2.index = this.atomIndex2\n const ai3 = this.getReferenceAtomIndex()\n\n v12.subVectors(ap1 as any, ap2 as any).normalize() // TODO\n if (ai3 !== undefined) {\n ap3.index = ai3\n v13.subVectors(ap1 as any, ap3 as any) // TODO\n } else {\n v13.copy(ap1 as any) // no reference point, use origin // TODO\n }\n v13.normalize()\n\n // make sure v13 and v12 are not colinear\n let dp = v12.dot(v13)\n if (1 - Math.abs(dp) < 1e-5) {\n v13.set(1, 0, 0)\n dp = v12.dot(v13)\n if (1 - Math.abs(dp) < 1e-5) {\n v13.set(0, 1, 0)\n dp = v12.dot(v13)\n }\n }\n\n return v.copy(v13.sub(v12.multiplyScalar(dp))).normalize()\n }\n\n qualifiedName () {\n return this.atomIndex1 + '=' + this.atomIndex2\n }\n\n /**\n * Clone object\n * @return {BondProxy} cloned bond\n */\n clone () {\n return new BondProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n atomIndex1: this.atomIndex1,\n atomIndex2: this.atomIndex2,\n bondOrder: this.bondOrder\n }\n }\n}\n\nexport default BondProxy\n","/**\n * @file Residue Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { NumberArray } from '../types'\nimport { defaults } from '../utils'\nimport {\n SecStrucHelix, SecStrucSheet, SecStrucTurn,\n ProteinType, RnaType, DnaType, WaterType, IonType, SaccharideType,\n CgProteinBackboneType, CgRnaBackboneType, CgDnaBackboneType,\n AA1\n} from '../structure/structure-constants'\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\n\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\nimport AtomStore from '../store/atom-store'\n\nimport AtomMap from '../store/atom-map'\nimport ResidueMap from '../store/residue-map'\n\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueType, { RingData } from '../store/residue-type';\nimport { ResidueBonds } from '../structure/structure-utils';\nimport AtomType from '../store/atom-type';\nimport ChainProxy from './chain-proxy';\nimport Entity from '../structure/entity';\n\n/**\n * Residue proxy\n */\nclass ResidueProxy {\n index: number\n\n chainStore: ChainStore\n residueStore: ResidueStore\n atomStore: AtomStore\n\n residueMap: ResidueMap\n atomMap: AtomMap\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n this.atomStore = structure.atomStore\n this.residueMap = structure.residueMap\n this.atomMap = structure.atomMap\n }\n\n /**\n * Entity\n * @type {Entity}\n */\n get entity (): Entity {\n return this.structure.entityList[ this.entityIndex ]\n }\n get entityIndex () {\n return this.chainStore.entityIndex[ this.chainIndex ]\n }\n /**\n * Chain\n * @type {ChainProxy}\n */\n get chain (): ChainProxy {\n return this.structure.getChainProxy(this.chainIndex)\n }\n\n get chainIndex () {\n return this.residueStore.chainIndex[ this.index ]\n }\n set chainIndex (value) {\n this.residueStore.chainIndex[ this.index ] = value\n }\n\n get atomOffset () {\n return this.residueStore.atomOffset[ this.index ]\n }\n set atomOffset (value) {\n this.residueStore.atomOffset[ this.index ] = value\n }\n\n /**\n * Atom count\n * @type {Integer}\n */\n get atomCount () {\n return this.residueStore.atomCount[ this.index ]\n }\n set atomCount (value) {\n this.residueStore.atomCount[ this.index ] = value\n }\n\n get atomEnd () {\n return this.atomOffset + this.atomCount - 1\n }\n\n //\n\n get modelIndex () {\n return this.chainStore.modelIndex[ this.chainIndex ]\n }\n /**\n * Chain name\n * @type {String}\n */\n get chainname () {\n return this.chainStore.getChainname(this.chainIndex)\n }\n /**\n * Chain id\n * @type {String}\n */\n get chainid () {\n return this.chainStore.getChainid(this.chainIndex)\n }\n\n //\n\n /**\n * Residue number/label\n * @type {Integer}\n */\n get resno () {\n return this.residueStore.resno[ this.index ]\n }\n set resno (value) {\n this.residueStore.resno[ this.index ] = value\n }\n\n /**\n * Secondary structure code\n * @type {String}\n */\n get sstruc () {\n return this.residueStore.getSstruc(this.index)\n }\n set sstruc (value) {\n this.residueStore.setSstruc(this.index, value)\n }\n\n /**\n * Insertion code\n * @type {String}\n */\n get inscode () {\n return this.residueStore.getInscode(this.index)\n }\n set inscode (value) {\n this.residueStore.setInscode(this.index, value)\n }\n\n //\n\n get residueType (): ResidueType {\n return this.residueMap.get(this.residueStore.residueTypeId[ this.index ])\n }\n\n /**\n * Residue name\n * @type {String}\n */\n get resname () {\n return this.residueType.resname\n }\n /**\n * Hetero flag\n * @type {Boolean}\n */\n get hetero () {\n return this.residueType.hetero\n }\n get moleculeType () {\n return this.residueType.moleculeType\n }\n get backboneType () {\n return this.residueType.backboneType\n }\n get backboneStartType () {\n return this.residueType.backboneStartType\n }\n get backboneEndType () {\n return this.residueType.backboneEndType\n }\n get traceAtomIndex () {\n return this.residueType.traceAtomIndex + this.atomOffset\n }\n get direction1AtomIndex () {\n return this.residueType.direction1AtomIndex + this.atomOffset\n }\n get direction2AtomIndex () {\n return this.residueType.direction2AtomIndex + this.atomOffset\n }\n get backboneStartAtomIndex () {\n return this.residueType.backboneStartAtomIndex + this.atomOffset\n }\n get backboneEndAtomIndex () {\n return this.residueType.backboneEndAtomIndex + this.atomOffset\n }\n get rungEndAtomIndex () {\n return this.residueType.rungEndAtomIndex + this.atomOffset\n }\n\n //\n\n get x () {\n let x = 0\n for (let i = this.atomOffset; i <= this.atomEnd; ++i) {\n x += this.atomStore.x[ i ]\n }\n return x / this.atomCount\n }\n\n get y () {\n let y = 0\n for (let i = this.atomOffset; i <= this.atomEnd; ++i) {\n y += this.atomStore.y[ i ]\n }\n return y / this.atomCount\n }\n\n get z () {\n let z = 0\n for (let i = this.atomOffset; i <= this.atomEnd; ++i) {\n z += this.atomStore.z[ i ]\n }\n return z / this.atomCount\n }\n\n //\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (ap: AtomProxy) => void, selection?: Selection) {\n const count = this.atomCount\n const offset = this.atomOffset\n const ap = this.structure._ap\n const end = offset + count\n\n if (selection && selection.atomOnlyTest) {\n const atomOnlyTest = selection.atomOnlyTest\n for (let i = offset; i < end; ++i) {\n ap.index = i\n if (atomOnlyTest(ap)) callback(ap)\n }\n } else {\n for (let i = offset; i < end; ++i) {\n ap.index = i\n callback(ap)\n }\n }\n }\n\n //\n\n /**\n * Write residue center position to array\n * @param {Array|TypedArray} [array] - target array\n * @param {Integer} [offset] - the offset\n * @return {Array|TypedArray} target array\n */\n positionToArray (array: NumberArray = [], offset = 0) {\n array[ offset + 0 ] = this.x\n array[ offset + 1 ] = this.y\n array[ offset + 2 ] = this.z\n\n return array\n }\n\n //\n\n /**\n * If residue is from a protein\n * @return {Boolean} flag\n */\n isProtein () {\n return this.residueType.moleculeType === ProteinType\n }\n\n /**\n * If residue is nucleic\n * @return {Boolean} flag\n */\n isNucleic () {\n const moleculeType = this.residueType.moleculeType\n return moleculeType === RnaType || moleculeType === DnaType\n }\n\n /**\n * If residue is rna\n * @return {Boolean} flag\n */\n isRna () {\n return this.residueType.moleculeType === RnaType\n }\n\n /**\n * If residue is dna\n * @return {Boolean} flag\n */\n isDna () {\n return this.residueType.moleculeType === DnaType\n }\n\n /**\n * If residue is coarse-grain\n * @return {Boolean} flag\n */\n isCg () {\n const backboneType = this.residueType.backboneType\n return (\n backboneType === CgProteinBackboneType ||\n backboneType === CgRnaBackboneType ||\n backboneType === CgDnaBackboneType\n )\n }\n\n /**\n * If residue is from a polymer\n * @return {Boolean} flag\n */\n isPolymer () {\n if (this.structure.entityList.length > 0) {\n return this.entity.isPolymer()\n } else {\n const moleculeType = this.residueType.moleculeType\n return (\n moleculeType === ProteinType ||\n moleculeType === RnaType ||\n moleculeType === DnaType\n )\n }\n }\n\n /**\n * If residue is hetero\n * @return {Boolean} flag\n */\n isHetero () {\n return this.residueType.hetero === 1\n }\n\n /**\n * If residue is a water molecule\n * @return {Boolean} flag\n */\n isWater () {\n return this.residueType.moleculeType === WaterType\n }\n\n /**\n * If residue is an ion\n * @return {Boolean} flag\n */\n isIon () {\n return this.residueType.moleculeType === IonType\n }\n\n /**\n * If residue is a saccharide\n * @return {Boolean} flag\n */\n isSaccharide () {\n return this.residueType.moleculeType === SaccharideType\n }\n\n isStandardAminoacid () {\n return this.residueType.isStandardAminoacid()\n }\n\n isStandardBase () {\n return this.residueType.isStandardBase()\n }\n\n /**\n * If residue is part of a helix\n * @return {Boolean} flag\n */\n isHelix () {\n return SecStrucHelix.includes(this.sstruc)\n }\n\n /**\n * If residue is part of a sheet\n * @return {Boolean} flag\n */\n isSheet () {\n return SecStrucSheet.includes(this.sstruc)\n }\n\n /**\n * If residue is part of a turn\n * @return {Boolean} flag\n */\n isTurn () {\n return SecStrucTurn.includes(this.sstruc) && this.isProtein()\n }\n\n getAtomType (index: number): AtomType {\n return this.atomMap.get(this.atomStore.atomTypeId[ index ])\n }\n\n getResname1 () {\n // FIXME nucleic support\n return AA1[ this.resname.toUpperCase() ] || 'X'\n }\n\n getBackboneType (position: number) {\n switch (position) {\n case -1:\n return this.residueType.backboneStartType\n case 1:\n return this.residueType.backboneEndType\n default:\n return this.residueType.backboneType\n }\n }\n\n getAtomIndexByName (atomname: string) {\n let index = this.residueType.getAtomIndexByName(atomname)\n if (index !== undefined) {\n index += this.atomOffset\n }\n return index\n }\n\n hasAtomWithName (atomname: string) {\n return this.residueType.hasAtomWithName(atomname)\n }\n\n getAtomnameList () {\n console.warn('getAtomnameList - might be expensive')\n\n const n = this.atomCount\n const offset = this.atomOffset\n const list = new Array(n)\n for (let i = 0; i < n; ++i) {\n list[ i ] = this.getAtomType(offset + i).atomname\n }\n return list\n }\n\n /**\n * If residue is connected to another\n * @param {ResidueProxy} rNext - the other residue\n * @return {Boolean} - flag\n */\n connectedTo (rNext: ResidueProxy) {\n const bbAtomEnd = this.structure.getAtomProxy(this.backboneEndAtomIndex)\n const bbAtomStart = this.structure.getAtomProxy(rNext.backboneStartAtomIndex)\n if (bbAtomEnd && bbAtomStart) {\n return bbAtomEnd.connectedTo(bbAtomStart)\n } else {\n return false\n }\n }\n\n getNextConnectedResidue () {\n const rOffset = this.chainStore.residueOffset[ this.chainIndex ]\n const rCount = this.chainStore.residueCount[ this.chainIndex ]\n const nextIndex = this.index + 1\n if (nextIndex < rOffset + rCount) {\n const rpNext = this.structure.getResidueProxy(nextIndex)\n if (this.connectedTo(rpNext)) {\n return rpNext\n }\n } else if (nextIndex === rOffset + rCount) { // cyclic\n const rpFirst = this.structure.getResidueProxy(rOffset)\n if (this.connectedTo(rpFirst)) {\n return rpFirst\n }\n }\n return undefined\n }\n\n getPreviousConnectedResidue (residueProxy?: ResidueProxy) {\n const rOffset = this.chainStore.residueOffset[ this.chainIndex ]\n const prevIndex = this.index - 1\n if (prevIndex >= rOffset) {\n const rpPrev = defaults(residueProxy, this.structure.getResidueProxy())\n rpPrev.index = prevIndex\n if (rpPrev.connectedTo(this)) {\n return rpPrev\n }\n } else if (prevIndex === rOffset - 1) { // cyclic\n const rCount = this.chainStore.residueCount[ this.chainIndex ]\n const rpLast = defaults(residueProxy, this.structure.getResidueProxy())\n rpLast.index = rOffset + rCount - 1\n if (rpLast.connectedTo(this)) {\n return rpLast\n }\n }\n return undefined\n }\n\n getBonds (): ResidueBonds {\n return this.residueType.getBonds(this)\n }\n\n getRings (): RingData|undefined {\n return this.residueType.getRings()\n }\n\n getAromaticRings () {\n return this.residueType.getAromaticRings(this)\n }\n\n qualifiedName (noResname = false) {\n let name = ''\n if (this.resname && !noResname) name += '[' + this.resname + ']'\n if (this.resno !== undefined) name += this.resno\n if (this.inscode) name += '^' + this.inscode\n if (this.chain) name += ':' + this.chainname\n name += '/' + this.modelIndex\n return name\n }\n\n /**\n * Clone object\n * @return {ResidueProxy} cloned residue\n */\n clone () {\n return new ResidueProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n index: this.index,\n chainIndex: this.chainIndex,\n atomOffset: this.atomOffset,\n atomCount: this.atomCount,\n\n resno: this.resno,\n resname: this.resname,\n sstruc: this.sstruc\n }\n }\n}\n\nexport default ResidueProxy\n","/**\n * @file Polymer\n * @author Alexander Rose \n * @private\n */\n\n// import { Log } from '../globals'\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\n\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\nimport AtomStore from '../store/atom-store'\n\nimport ResidueProxy from '../proxy/residue-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Polymer\n */\nclass Polymer {\n chainStore: ChainStore\n residueStore: ResidueStore\n atomStore: AtomStore\n\n residueCount: number\n\n isPrevConnected: boolean\n isNextConnected: boolean\n isNextNextConnected: boolean\n isCyclic: boolean\n\n private __residueProxy: ResidueProxy\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} residueIndexStart - the index of the first residue\n * @param {Integer} residueIndexEnd - the index of the last residue\n */\n constructor (readonly structure: Structure, readonly residueIndexStart: number, readonly residueIndexEnd: number) {\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n this.atomStore = structure.atomStore\n\n /**\n * @type {Integer}\n */\n this.residueCount = residueIndexEnd - residueIndexStart + 1\n\n const rpStart = this.structure.getResidueProxy(this.residueIndexStart)\n const rpEnd = this.structure.getResidueProxy(this.residueIndexEnd)\n this.isPrevConnected = rpStart.getPreviousConnectedResidue() !== undefined\n const rpNext = rpEnd.getNextConnectedResidue()\n this.isNextConnected = rpNext !== undefined\n this.isNextNextConnected = rpNext !== undefined && rpNext.getNextConnectedResidue() !== undefined\n this.isCyclic = rpEnd.connectedTo(rpStart)\n\n this.__residueProxy = this.structure.getResidueProxy()\n\n // console.log( this.qualifiedName(), this );\n }\n\n get chainIndex () {\n return this.residueStore.chainIndex[ this.residueIndexStart ]\n }\n get modelIndex () {\n return this.chainStore.modelIndex[ this.chainIndex ]\n }\n\n /**\n * @type {String}\n */\n get chainname () {\n return this.chainStore.getChainname(this.chainIndex)\n }\n\n //\n\n /**\n * If first residue is from aprotein\n * @return {Boolean} flag\n */\n isProtein () {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.isProtein()\n }\n\n /**\n * If atom is part of a coarse-grain group\n * @return {Boolean} flag\n */\n isCg () {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.isCg()\n }\n\n /**\n * If atom is part of a nucleic molecule\n * @return {Boolean} flag\n */\n isNucleic () {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.isNucleic()\n }\n\n getMoleculeType () {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.moleculeType\n }\n\n getBackboneType (position: number) {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.getBackboneType(position)\n }\n\n getAtomIndexByType (index: number, type: string) {\n // TODO pre-calculate, add to residueStore???\n\n if (this.isCyclic) {\n if (index === -1) {\n index = this.residueCount - 1\n } else if (index === this.residueCount) {\n index = 0\n }\n } else {\n if (index === -1 && !this.isPrevConnected) index += 1\n if (index === this.residueCount && !this.isNextNextConnected) index -= 1\n // if( index === this.residueCount - 1 && !this.isNextConnected ) index -= 1;\n }\n\n const rp = this.__residueProxy\n rp.index = this.residueIndexStart + index\n let aIndex\n\n switch (type) {\n case 'trace':\n aIndex = rp.traceAtomIndex\n break\n case 'direction1':\n aIndex = rp.direction1AtomIndex\n break\n case 'direction2':\n aIndex = rp.direction2AtomIndex\n break\n default:\n aIndex = rp.getAtomIndexByName(type)\n }\n\n // if (!ap){\n // console.log(this, type, rp.residueType)\n // // console.log(rp.qualifiedName(), rp.index, index, this.residueCount - 1)\n // // rp.index = this.residueIndexStart;\n // // console.log(rp.qualifiedName(), this.residueIndexStart)\n // // rp.index = this.residueIndexEnd;\n // // console.log(rp.qualifiedName(), this.residueIndexEnd)\n // }\n\n return aIndex\n }\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (ap: AtomProxy) => void, selection?: Selection) {\n this.eachResidue(function (rp) {\n rp.eachAtom(callback, selection)\n })\n }\n\n eachAtomN (n: number, callback: (...apArray: AtomProxy[]) => void, type: string) {\n const m = this.residueCount\n const array: AtomProxy[] = new Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = this.structure.getAtomProxy(this.getAtomIndexByType(i, type))\n }\n callback.apply(this, array)\n\n for (var j = n; j < m; ++j) {\n for (let i = 1; i < n; ++i) {\n array[ i - 1 ].index = array[ i ].index\n }\n array[ n - 1 ].index = this.getAtomIndexByType(j, type)! // TODO\n callback.apply(this, array)\n }\n }\n\n /**\n * Residue iterator\n * @param {function(residue: ResidueProxy)} callback - the callback\n * @return {undefined}\n */\n eachResidue (callback: (rp: ResidueProxy) => void) {\n const rp = this.structure.getResidueProxy()\n const n = this.residueCount\n const rStartIndex = this.residueIndexStart\n\n for (let i = 0; i < n; ++i) {\n rp.index = rStartIndex + i\n callback(rp)\n }\n }\n\n qualifiedName () {\n const rpStart = this.structure.getResidueProxy(this.residueIndexStart)\n const rpEnd = this.structure.getResidueProxy(this.residueIndexEnd)\n return rpStart.qualifiedName() + ' - ' + rpEnd.qualifiedName()\n }\n}\n\nexport default Polymer\n","/**\n * @file Chain Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { UnknownBackboneType } from '../structure/structure-constants'\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\n\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\n\nimport Polymer from '../proxy/polymer'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ModelProxy from './model-proxy';\nimport Entity from '../structure/entity';\n\n/**\n * Chain proxy\n */\nclass ChainProxy {\n index: number\n\n chainStore: ChainStore\n residueStore: ResidueStore\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n }\n\n /**\n * Entity\n * @type {Entity}\n */\n get entity (): Entity {\n return this.structure.entityList[ this.entityIndex ]\n }\n /**\n * Model\n * @type {ModelProxy}\n */\n get model (): ModelProxy {\n return this.structure.getModelProxy(this.modelIndex)\n }\n\n get entityIndex () {\n return this.chainStore.entityIndex[ this.index ]\n }\n set entityIndex (value) {\n this.chainStore.entityIndex[ this.index ] = value\n }\n\n get modelIndex () {\n return this.chainStore.modelIndex[ this.index ]\n }\n set modelIndex (value) {\n this.chainStore.modelIndex[ this.index ] = value\n }\n\n get residueOffset () {\n return this.chainStore.residueOffset[ this.index ]\n }\n set residueOffset (value) {\n this.chainStore.residueOffset[ this.index ] = value\n }\n\n /**\n * Residue count\n * @type {Integer}\n */\n get residueCount () {\n return this.chainStore.residueCount[ this.index ]\n }\n set residueCount (value) {\n this.chainStore.residueCount[ this.index ] = value\n }\n\n get residueEnd () {\n return this.residueOffset + this.residueCount - 1\n }\n\n get atomOffset () {\n return this.residueStore.atomOffset[ this.residueOffset ]\n }\n get atomEnd () {\n return (\n this.residueStore.atomOffset[ this.residueEnd ] +\n this.residueStore.atomCount[ this.residueEnd ] - 1\n )\n }\n /**\n * Atom count\n * @type {Integer}\n */\n get atomCount () {\n if (this.residueCount === 0) {\n return 0\n } else {\n return this.atomEnd - this.atomOffset + 1\n }\n }\n\n //\n\n /**\n * Chain name\n * @type {String}\n */\n get chainname () {\n return this.chainStore.getChainname(this.index)\n }\n set chainname (value) {\n this.chainStore.setChainname(this.index, value)\n }\n\n /**\n * Chain id\n * @type {String}\n */\n get chainid () {\n return this.chainStore.getChainid(this.index)\n }\n set chainid (value) {\n this.chainStore.setChainid(this.index, value)\n }\n\n //\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (ap: AtomProxy) => void, selection?: Selection) {\n this.eachResidue(function (rp) {\n rp.eachAtom(callback, selection)\n }, selection)\n }\n\n /**\n * Residue iterator\n * @param {function(residue: ResidueProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachResidue (callback: (rp: ResidueProxy) => void, selection?: Selection) {\n const count = this.residueCount\n const offset = this.residueOffset\n const rp = this.structure._rp\n const end = offset + count\n\n if (selection && selection.test) {\n const residueOnlyTest = selection.residueOnlyTest\n if (residueOnlyTest) {\n for (let i = offset; i < end; ++i) {\n rp.index = i\n if (residueOnlyTest(rp)) {\n callback(rp)\n }\n }\n } else {\n for (let i = offset; i < end; ++i) {\n rp.index = i\n callback(rp)\n }\n }\n } else {\n for (let i = offset; i < end; ++i) {\n rp.index = i\n callback(rp)\n }\n }\n }\n\n /**\n * Multi-residue iterator\n * @param {Integer} n - window size\n * @param {function(residueList: ResidueProxy[])} callback - the callback\n * @return {undefined}\n */\n eachResidueN (n: number, callback: (...rpArray: ResidueProxy[]) => void) {\n const count = this.residueCount\n const offset = this.residueOffset\n const end = offset + count\n if (count < n) return\n const array: ResidueProxy[] = new Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = this.structure.getResidueProxy(offset + i)\n }\n callback.apply(this, array)\n\n for (let j = offset + n; j < end; ++j) {\n for (let i = 0; i < n; ++i) {\n array[ i ].index += 1\n }\n callback.apply(this, array)\n }\n }\n\n /**\n * Polymer iterator\n * @param {function(polymer: Polymer)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachPolymer (callback: (p: Polymer) => void, selection?: Selection) {\n let rStartIndex = 0\n let rNextIndex = 0\n const test = selection ? selection.residueOnlyTest : undefined\n const structure = this.model.structure\n\n const count = this.residueCount\n const offset = this.residueOffset\n const end = offset + count\n\n const rp1 = this.structure.getResidueProxy()\n const rp2 = this.structure.getResidueProxy(offset)\n\n const ap1 = this.structure.getAtomProxy()\n const ap2 = this.structure.getAtomProxy()\n\n let first = true\n\n for (let i = offset + 1; i < end; ++i) {\n rp1.index = rp2.index\n rp2.index = i\n\n const bbType1 = first ? rp1.backboneEndType : rp1.backboneType\n const bbType2 = rp2.backboneType\n\n if (first) {\n rStartIndex = rp1.index\n first = false\n }\n rNextIndex = rp2.index\n\n if (bbType1 !== UnknownBackboneType && bbType1 === bbType2) {\n ap1.index = rp1.backboneEndAtomIndex\n ap2.index = rp2.backboneStartAtomIndex\n } else {\n if (bbType1 !== UnknownBackboneType) {\n if (rp1.index - rStartIndex > 1) {\n // console.log(\"FOO1\",rStartIndex, rp1.index)\n callback(new Polymer(structure, rStartIndex, rp1.index))\n }\n }\n rStartIndex = rNextIndex\n\n continue\n }\n\n if (!ap1 || !ap2 || !ap1.connectedTo(ap2) ||\n (test && (!test(rp1) || !test(rp2)))\n ) {\n if (rp1.index - rStartIndex > 1) {\n // console.log(\"FOO2\",rStartIndex, rp1.index)\n callback(new Polymer(structure, rStartIndex, rp1.index))\n }\n rStartIndex = rNextIndex\n }\n }\n\n if (rNextIndex - rStartIndex > 1) {\n if (this.structure.getResidueProxy(rStartIndex).backboneEndType) {\n // console.log(\"FOO3\",rStartIndex, rNextIndex)\n callback(new Polymer(structure, rStartIndex, rNextIndex))\n }\n }\n }\n\n //\n\n qualifiedName () {\n var name = ':' + this.chainname + '/' + this.modelIndex\n return name\n }\n\n /**\n * Clone object\n * @return {ChainProxy} cloned chain\n */\n clone () {\n return new ChainProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n index: this.index,\n residueOffset: this.residueOffset,\n residueCount: this.residueCount,\n\n chainname: this.chainname\n }\n }\n}\n\nexport default ChainProxy\n","/**\n * @file Model Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\n\nimport ModelStore from '../store/model-store'\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\n\nimport ChainProxy from '../proxy/chain-proxy'\nimport Polymer from '../proxy/polymer'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Model proxy\n */\nclass ModelProxy {\n index: number\n\n modelStore: ModelStore\n chainStore: ChainStore\n residueStore: ResidueStore\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.modelStore = structure.modelStore\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n }\n\n get chainOffset () {\n return this.modelStore.chainOffset[ this.index ]\n }\n set chainOffset (value) {\n this.modelStore.chainOffset[ this.index ] = value\n }\n\n get chainCount () {\n return this.modelStore.chainCount[ this.index ]\n }\n set chainCount (value) {\n this.modelStore.chainCount[ this.index ] = value\n }\n\n get residueOffset () {\n return this.chainStore.residueOffset[ this.chainOffset ]\n }\n get atomOffset () {\n return this.residueStore.atomOffset[ this.residueOffset ]\n }\n\n get chainEnd () {\n return this.chainOffset + this.chainCount - 1\n }\n get residueEnd () {\n return (\n this.chainStore.residueOffset[ this.chainEnd ] +\n this.chainStore.residueCount[ this.chainEnd ] - 1\n )\n }\n get atomEnd () {\n return (\n this.residueStore.atomOffset[ this.residueEnd ] +\n this.residueStore.atomCount[ this.residueEnd ] - 1\n )\n }\n\n /**\n * Residue count\n * @type {Integer}\n */\n get residueCount () {\n if (this.chainCount === 0) {\n return 0\n } else {\n return this.residueEnd - this.residueOffset + 1\n }\n }\n\n /**\n * Atom count\n * @type {Integer}\n */\n get atomCount () {\n if (this.residueCount === 0) {\n return 0\n } else {\n return this.atomEnd - this.atomOffset + 1\n }\n }\n\n //\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (ap: AtomProxy) => void, selection?: Selection) {\n this.eachChain(function (cp) {\n cp.eachAtom(callback, selection)\n }, selection)\n }\n\n /**\n * Residue iterator\n * @param {function(residue: ResidueProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachResidue (callback: (rp: ResidueProxy) => void, selection?: Selection) {\n this.eachChain(function (cp) {\n cp.eachResidue(callback, selection)\n }, selection)\n }\n\n /**\n * Polymer iterator\n * @param {function(polymer: Polymer)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachPolymer (callback: (p: Polymer) => void, selection?: Selection) {\n if (selection && selection.chainOnlyTest) {\n const chainOnlyTest = selection.chainOnlyTest\n\n this.eachChain(function (cp) {\n if (chainOnlyTest(cp)) {\n cp.eachPolymer(callback, selection)\n }\n })\n } else {\n this.eachChain(function (cp) {\n cp.eachPolymer(callback, selection)\n })\n }\n }\n\n /**\n * Chain iterator\n * @param {function(chain: ChainProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachChain (callback: (cp: ChainProxy) => void, selection?: Selection) {\n const count = this.chainCount\n const offset = this.chainOffset\n const cp = this.structure._cp\n const end = offset + count\n\n if (selection && selection.test) {\n const chainOnlyTest = selection.chainOnlyTest\n if (chainOnlyTest) {\n for (let i = offset; i < end; ++i) {\n cp.index = i\n if (chainOnlyTest(cp)) {\n callback(cp)\n }\n }\n } else {\n for (let i = offset; i < end; ++i) {\n cp.index = i\n callback(cp)\n }\n }\n } else {\n for (let i = offset; i < end; ++i) {\n cp.index = i\n callback(cp)\n }\n }\n }\n\n //\n\n qualifiedName () {\n const name = '/' + this.index\n return name\n }\n\n /**\n * Clone object\n * @return {ModelProxy} cloned model\n */\n clone () {\n return new ModelProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n index: this.index,\n chainOffset: this.chainOffset,\n chainCount: this.chainCount\n }\n }\n}\n\nexport default ModelProxy\n","/**\n * @file Structure\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3 } from 'three'\nimport { Signal } from 'signals'\n\nimport { Debug, Log, ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { AtomPicker, BondPicker } from '../utils/picker'\nimport { copyWithin, arrayMin, arrayMax } from '../math/array-utils'\nimport BitArray from '../utils/bitarray'\nimport RadiusFactory, { RadiusParams } from '../utils/radius-factory'\nimport { Matrix } from '../math/matrix-utils'\nimport PrincipalAxes from '../math/principal-axes'\nimport SpatialHash from '../geometry/spatial-hash'\nimport FilteredVolume from '../surface/filtered-volume'\nimport StructureView from './structure-view'\nimport { AtomDataParams, AtomData, BondDataParams, BondData } from './structure-data'\nimport { Data, createData } from './data'\n\nimport Entity from './entity'\nimport Unitcell from '../symmetry/unitcell'\nimport Validation from './validation'\nimport Selection from '../selection/selection'\nimport Assembly from '../symmetry/assembly'\nimport Volume from '../surface/volume'\nimport Polymer from '../proxy/polymer'\n\nimport BondHash from '../store/bond-hash'\nimport BondStore from '../store/bond-store'\nimport AtomStore from '../store/atom-store'\nimport ResidueStore from '../store/residue-store'\nimport ChainStore from '../store/chain-store'\nimport ModelStore from '../store/model-store'\n\nimport AtomMap from '../store/atom-map'\nimport ResidueMap from '../store/residue-map'\n\nimport BondProxy from '../proxy/bond-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\ninterface Structure {\n signals: StructureSignals\n\n name: string\n path: string\n title: string\n id: string\n\n data: Data\n\n atomCount: number\n bondCount: number\n\n header: StructureHeader\n extraData: StructureExtraData\n\n atomSetCache: { [k: string]: BitArray }\n atomSetDict: { [k: string]: BitArray }\n biomolDict: { [k: string]: Assembly }\n\n entityList: Entity[]\n unitcell?: Unitcell\n\n frames: Float32Array[]\n boxes: Float32Array[]\n\n validation?: Validation\n\n bondStore: BondStore\n backboneBondStore: BondStore\n rungBondStore: BondStore\n atomStore: AtomStore\n residueStore: ResidueStore\n chainStore: ChainStore\n modelStore: ModelStore\n\n atomMap: AtomMap\n residueMap: ResidueMap\n\n bondHash?: BondHash\n spatialHash?: SpatialHash\n\n atomSet?: BitArray\n bondSet?: BitArray\n\n center: Vector3\n boundingBox: Box3\n\n trajectory?: {\n name: string\n frame: number\n }\n\n getView(selection: Selection): StructureView\n\n _hasCoords?: boolean\n\n _bp: BondProxy\n _ap: AtomProxy\n _rp: ResidueProxy\n _cp: ChainProxy\n}\n\nexport type StructureHeader = {\n releaseDate?: string\n depositionDate?: string\n resolution?: number\n rFree?: number\n rWork?: number\n experimentalMethods?: string[]\n}\n\nexport type StructureExtraData = {\n cif?: object\n sdf?: object[]\n}\n\nexport type StructureSignals = {\n refreshed: Signal\n}\n\n/**\n * Structure\n */\nclass Structure implements Structure{\n signals: StructureSignals = {\n refreshed: new Signal()\n }\n\n /**\n * @param {String} name - structure name\n * @param {String} path - source path\n */\n constructor (name = '', path = '') {\n this.init(name, path)\n }\n\n init (name: string, path: string) {\n this.name = name\n this.path = path\n this.title = ''\n this.id = ''\n\n this.data = createData(this)\n\n this.header = {}\n this.extraData = {}\n\n this.atomSetCache = {}\n this.atomSetDict = {}\n this.biomolDict = {}\n\n this.entityList = []\n this.unitcell = undefined\n\n this.frames = []\n this.boxes = []\n\n this.validation = undefined\n\n this.bondStore = new BondStore(0)\n this.backboneBondStore = new BondStore(0)\n this.rungBondStore = new BondStore(0)\n this.atomStore = new AtomStore(0)\n this.residueStore = new ResidueStore(0)\n this.chainStore = new ChainStore(0)\n this.modelStore = new ModelStore(0)\n\n this.atomMap = new AtomMap(this)\n this.residueMap = new ResidueMap(this)\n\n this.bondHash = undefined\n this.spatialHash = undefined\n\n this.atomSet = undefined\n this.bondSet = undefined\n\n this.center = new Vector3()\n this.boundingBox = new Box3()\n\n this._bp = this.getBondProxy()\n this._ap = this.getAtomProxy()\n this._rp = this.getResidueProxy()\n this._cp = this.getChainProxy()\n }\n\n get type () { return 'Structure' }\n\n finalizeAtoms () {\n this.atomSet = this.getAtomSet()\n this.atomCount = this.atomStore.count\n this.boundingBox = this.getBoundingBox(undefined, this.boundingBox)\n this.center = this.boundingBox.getCenter(new Vector3())\n this.spatialHash = new SpatialHash(this.atomStore, this.boundingBox)\n }\n\n finalizeBonds () {\n this.bondSet = this.getBondSet()\n this.bondCount = this.bondStore.count\n this.bondHash = new BondHash(this.bondStore, this.atomStore.count)\n\n this.atomSetCache = {}\n if (!this.atomSetDict.rung) {\n this.atomSetDict.rung = this.getAtomSet(false)\n }\n\n for (let name in this.atomSetDict) {\n this.atomSetCache[ '__' + name ] = this.atomSetDict[ name ].clone()\n }\n }\n\n //\n\n getBondProxy (index?: number) {\n return new BondProxy(this, index)\n }\n\n getAtomProxy (index?: number) {\n return new AtomProxy(this, index)\n }\n\n getResidueProxy (index?: number) {\n return new ResidueProxy(this, index)\n }\n\n getChainProxy (index?: number) {\n return new ChainProxy(this, index)\n }\n\n getModelProxy (index?: number) {\n return new ModelProxy(this, index)\n }\n\n //\n\n getBondSet (/* selection */) {\n // TODO implement selection parameter\n\n const n = this.bondStore.count\n const bondSet = new BitArray(n)\n const atomSet = this.atomSet\n\n if (atomSet) {\n if (atomSet.isAllSet()) {\n bondSet.setAll()\n } else if (atomSet.isAllClear()) {\n bondSet.clearAll()\n } else {\n const bp = this.getBondProxy()\n\n for (let i = 0; i < n; ++i) {\n bp.index = i\n if (atomSet.isSet(bp.atomIndex1, bp.atomIndex2)) {\n bondSet.set(bp.index)\n }\n }\n }\n } else {\n bondSet.setAll()\n }\n\n return bondSet\n }\n\n getBackboneBondSet (/* selection */) {\n // TODO implement selection parameter\n\n const n = this.backboneBondStore.count\n const backboneBondSet = new BitArray(n)\n const backboneAtomSet = this.atomSetCache.__backbone\n\n if (backboneAtomSet) {\n const bp = this.getBondProxy()\n bp.bondStore = this.backboneBondStore\n\n for (let i = 0; i < n; ++i) {\n bp.index = i\n if (backboneAtomSet.isSet(bp.atomIndex1, bp.atomIndex2)) {\n backboneBondSet.set(bp.index)\n }\n }\n } else {\n backboneBondSet.setAll()\n }\n\n return backboneBondSet\n }\n\n getRungBondSet (/* selection */) {\n // TODO implement selection parameter\n\n const n = this.rungBondStore.count\n const rungBondSet = new BitArray(n)\n const rungAtomSet = this.atomSetCache.__rung\n\n if (rungAtomSet) {\n const bp = this.getBondProxy()\n bp.bondStore = this.rungBondStore\n\n for (let i = 0; i < n; ++i) {\n bp.index = i\n if (rungAtomSet.isSet(bp.atomIndex1, bp.atomIndex2)) {\n rungBondSet.set(bp.index)\n }\n }\n } else {\n rungBondSet.setAll()\n }\n\n return rungBondSet\n }\n\n /**\n * Get a set of atoms\n * @param {Boolean|Selection|BitArray} selection - object defining how to\n * initialize the atom set.\n * Boolean: init with value;\n * Selection: init with selection;\n * BitArray: return bit array\n * @return {BitArray} set of atoms\n */\n getAtomSet (selection?: boolean|Selection|BitArray) {\n const n = this.atomStore.count\n\n if (selection === undefined) {\n return new BitArray(n, true)\n } else if (selection instanceof BitArray) {\n return selection\n } else if (selection === true) {\n return new BitArray(n, true)\n } else if (selection && selection.test) {\n const seleString = selection.string\n if (seleString in this.atomSetCache) {\n return this.atomSetCache[ seleString ]\n } else {\n if (seleString === '') {\n return new BitArray(n, true)\n } else {\n const atomSet = new BitArray(n)\n this.eachAtom(function (ap: AtomProxy) {\n atomSet.set(ap.index)\n }, selection)\n this.atomSetCache[ seleString ] = atomSet\n return atomSet\n }\n }\n } else if (selection === false) {\n return new BitArray(n)\n }\n\n return new BitArray(n, true)\n }\n\n /**\n * Get set of atoms around a set of atoms from a selection\n * @param {Selection} selection - the selection object\n * @param {Number} radius - radius to select within\n * @return {BitArray} set of atoms\n */\n getAtomSetWithinSelection (selection: boolean|Selection|BitArray, radius: number) {\n const spatialHash = this.spatialHash\n const atomSet = this.getAtomSet(false)\n const ap = this.getAtomProxy()\n\n if (!spatialHash) return atomSet\n\n this.getAtomSet(selection).forEach(function (idx: number) {\n ap.index = idx\n spatialHash.within(ap.x, ap.y, ap.z, radius).forEach(function (idx2: number) {\n atomSet.set(idx2)\n })\n })\n\n return atomSet\n }\n\n /**\n * Get set of atoms around a point\n * @param {Vector3|AtomProxy} point - the point\n * @param {Number} radius - radius to select within\n * @return {BitArray} set of atoms\n */\n getAtomSetWithinPoint (point: Vector3|AtomProxy, radius: number) {\n const p = point\n const atomSet = this.getAtomSet(false)\n\n if (!this.spatialHash) return atomSet\n\n this.spatialHash.within(p.x, p.y, p.z, radius).forEach(function (idx: number) {\n atomSet.set(idx)\n })\n\n return atomSet\n }\n\n /**\n * Get set of atoms within a volume\n * @param {Volume} volume - the volume\n * @param {Number} radius - radius to select within\n * @param {[type]} minValue - minimum value to be considered as within the volume\n * @param {[type]} maxValue - maximum value to be considered as within the volume\n * @param {[type]} outside - use only values falling outside of the min/max values\n * @return {BitArray} set of atoms\n */\n getAtomSetWithinVolume (volume: Volume, radius: number, minValue: number, maxValue: number, outside: boolean) {\n const fv = new FilteredVolume(volume, minValue, maxValue, outside) as any // TODO\n\n const dp = fv.getDataPosition()\n const n = dp.length\n const r = fv.matrix.getMaxScaleOnAxis()\n const atomSet = this.getAtomSet(false)\n\n if (!this.spatialHash) return atomSet\n\n for (let i = 0; i < n; i += 3) {\n this.spatialHash.within(dp[ i ], dp[ i + 1 ], dp[ i + 2 ], r).forEach(function (idx) {\n atomSet.set(idx)\n })\n }\n\n return atomSet\n }\n\n /**\n * Get set of all atoms within the groups of a selection\n * @param {Selection} selection - the selection object\n * @return {BitArray} set of atoms\n */\n getAtomSetWithinGroup (selection: boolean|Selection|BitArray) {\n const atomResidueIndex = this.atomStore.residueIndex\n const atomSet = this.getAtomSet(false)\n const rp = this.getResidueProxy()\n\n this.getAtomSet(selection).forEach(function (idx) {\n rp.index = atomResidueIndex[ idx ]\n for (let idx2 = rp.atomOffset; idx2 <= rp.atomEnd; ++idx2) {\n atomSet.set(idx2)\n }\n })\n\n return atomSet\n }\n\n //\n\n getSelection (): undefined|Selection {\n return\n }\n\n getStructure (): Structure|StructureView {\n return this\n }\n\n /**\n * Entity iterator\n * @param {function(entity: Entity)} callback - the callback\n * @param {EntityType} type - entity type\n * @return {undefined}\n */\n eachEntity (callback: (entity: Entity) => void, type: number) {\n this.entityList.forEach(function (entity) {\n if (type === undefined || entity.getEntityType() === type) {\n callback(entity)\n }\n })\n }\n\n /**\n * Bond iterator\n * @param {function(bond: BondProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachBond (callback: (entity: BondProxy) => void, selection?: Selection) {\n const bp = this.getBondProxy()\n let bondSet\n\n if (selection && selection.test) {\n bondSet = this.getBondSet(/*selection*/)\n if (this.bondSet) {\n bondSet.intersection(this.bondSet)\n }\n }\n\n if (bondSet) {\n bondSet.forEach(function (index) {\n bp.index = index\n callback(bp)\n })\n } else {\n const n = this.bondStore.count\n for (let i = 0; i < n; ++i) {\n bp.index = i\n callback(bp)\n }\n }\n }\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (entity: AtomProxy) => void, selection?: Selection) {\n if (selection && selection.test) {\n this.eachModel(function (mp) {\n mp.eachAtom(callback, selection)\n }, selection)\n } else {\n const an = this.atomStore.count\n const ap = this.getAtomProxy()\n for (let i = 0; i < an; ++i) {\n ap.index = i\n callback(ap)\n }\n }\n }\n\n /**\n * Residue iterator\n * @param {function(residue: ResidueProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachResidue (callback: (entity: ResidueProxy) => void, selection?: Selection) {\n if (selection && selection.test) {\n const mn = this.modelStore.count\n const mp = this.getModelProxy()\n const modelOnlyTest = selection.modelOnlyTest\n if (modelOnlyTest) {\n for (let i = 0; i < mn; ++i) {\n mp.index = i\n if (modelOnlyTest(mp)) {\n mp.eachResidue(callback, selection)\n }\n }\n } else {\n for (let i = 0; i < mn; ++i) {\n mp.index = i\n mp.eachResidue(callback, selection)\n }\n }\n } else {\n const rn = this.residueStore.count\n const rp = this.getResidueProxy()\n for (let i = 0; i < rn; ++i) {\n rp.index = i\n callback(rp)\n }\n }\n }\n\n /**\n * Multi-residue iterator\n * @param {Integer} n - window size\n * @param {function(residueList: ResidueProxy[])} callback - the callback\n * @return {undefined}\n */\n eachResidueN (n: number, callback: (...entityArray: ResidueProxy[]) => void) {\n const rn = this.residueStore.count\n if (rn < n) return\n const array: ResidueProxy[] = new Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = this.getResidueProxy(i)\n }\n callback.apply(this, array)\n\n for (let j = n; j < rn; ++j) {\n for (let i = 0; i < n; ++i) {\n array[ i ].index += 1\n }\n callback.apply(this, array)\n }\n }\n\n /**\n * Polymer iterator\n * @param {function(polymer: Polymer)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachPolymer (callback: (entity: Polymer) => void, selection?: Selection) {\n if (selection && selection.modelOnlyTest) {\n const modelOnlyTest = selection.modelOnlyTest\n\n this.eachModel(function (mp) {\n if (modelOnlyTest(mp)) {\n mp.eachPolymer(callback, selection)\n }\n })\n } else {\n this.eachModel(function (mp) {\n mp.eachPolymer(callback, selection)\n })\n }\n }\n\n /**\n * Chain iterator\n * @param {function(chain: ChainProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachChain (callback: (entity: ChainProxy) => void, selection?: Selection) {\n if (selection && selection.test) {\n this.eachModel(function (mp) {\n mp.eachChain(callback, selection)\n })\n } else {\n const cn = this.chainStore.count\n const cp = this.getChainProxy()\n for (let i = 0; i < cn; ++i) {\n cp.index = i\n callback(cp)\n }\n }\n }\n\n /**\n * Model iterator\n * @param {function(model: ModelProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachModel (callback: (entity: ModelProxy) => void, selection?: Selection) {\n const n = this.modelStore.count\n const mp = this.getModelProxy()\n\n if (selection && selection.test) {\n const modelOnlyTest = selection.modelOnlyTest\n if (modelOnlyTest) {\n for (let i = 0; i < n; ++i) {\n mp.index = i\n if (modelOnlyTest(mp)) {\n callback(mp)\n }\n }\n } else {\n for (let i = 0; i < n; ++i) {\n mp.index = i\n callback(mp)\n }\n }\n } else {\n for (let i = 0; i < n; ++i) {\n mp.index = i\n callback(mp)\n }\n }\n }\n\n //\n\n getAtomData (params: AtomDataParams) {\n const p = Object.assign({}, params)\n if (p.colorParams) p.colorParams.structure = this.getStructure()\n\n const what = p.what\n const atomSet = defaults(p.atomSet, this.atomSet)\n\n let radiusFactory: any // TODO\n let colormaker: any // TODO\n\n const atomData: AtomData = {}\n const ap = this.getAtomProxy()\n const atomCount = atomSet.getSize()\n\n if (!what || what.position) {\n atomData.position = new Float32Array(atomCount * 3)\n }\n if ((!what || what.color) && p.colorParams) {\n atomData.color = new Float32Array(atomCount * 3)\n colormaker = ColormakerRegistry.getScheme(p.colorParams)\n }\n if (!what || what.picking) {\n atomData.picking = new AtomPicker(new Float32Array(atomCount), this.getStructure())\n }\n if (!what || what.radius) {\n atomData.radius = new Float32Array(atomCount)\n radiusFactory = new RadiusFactory(p.radiusParams as RadiusParams)\n }\n if (!what || what.index) {\n atomData.index = new Uint32Array(atomCount)\n }\n\n const {position, color, picking, radius, index} = atomData\n\n atomSet.forEach((idx: number, i: number) => {\n const i3 = i * 3\n ap.index = idx\n if (position) {\n ap.positionToArray(position, i3)\n }\n if (color) {\n colormaker.atomColorToArray(ap, color, i3)\n }\n if (picking) {\n picking.array![ i ] = idx\n }\n if (radius) {\n radius[ i ] = radiusFactory.atomRadius(ap)\n }\n if (index) {\n index[ i ] = idx\n }\n })\n return atomData\n }\n\n getBondData (params: BondDataParams) {\n const p = Object.assign({}, params)\n if (p.colorParams) p.colorParams.structure = this.getStructure()\n\n const what = p.what\n const bondSet = defaults(p.bondSet, this.bondSet)\n const multipleBond = defaults(p.multipleBond, 'off')\n const isMulti = multipleBond !== 'off'\n const isOffset = multipleBond === 'offset'\n const bondScale = defaults(p.bondScale, 0.4)\n const bondSpacing = defaults(p.bondSpacing, 1.0)\n\n let radiusFactory: any // TODO\n let colormaker: any // TODO\n\n const bondData: BondData = {}\n const bp = this.getBondProxy()\n if (p.bondStore) bp.bondStore = p.bondStore\n const ap1 = this.getAtomProxy()\n const ap2 = this.getAtomProxy()\n\n let bondCount: number\n if (isMulti) {\n const storeBondOrder = bp.bondStore.bondOrder\n bondCount = 0\n bondSet.forEach(function (index: number) {\n bondCount += storeBondOrder[ index ]\n })\n } else {\n bondCount = bondSet.getSize()\n }\n\n if (!what || what.position) {\n bondData.position1 = new Float32Array(bondCount * 3)\n bondData.position2 = new Float32Array(bondCount * 3)\n }\n if ((!what || what.color) && p.colorParams) {\n bondData.color = new Float32Array(bondCount * 3)\n bondData.color2 = new Float32Array(bondCount * 3)\n colormaker = ColormakerRegistry.getScheme(p.colorParams)\n }\n if (!what || what.picking) {\n bondData.picking = new BondPicker(new Float32Array(bondCount), this.getStructure(), p.bondStore)\n }\n if (!what || what.radius || (isMulti && what.position)) {\n radiusFactory = new RadiusFactory(p.radiusParams as RadiusParams)\n }\n if (!what || what.radius) {\n bondData.radius = new Float32Array(bondCount)\n if (p.radius2) {\n bondData.radius2 = new Float32Array(bondCount)\n }\n }\n\n const {position1, position2, color, color2, picking, radius, radius2} = bondData\n\n let i = 0\n let j, i3, k, bondOrder, absOffset\n let multiRadius\n\n const vt = new Vector3()\n const vShortening = new Vector3()\n const vShift = new Vector3()\n\n bondSet.forEach((index: number) => {\n i3 = i * 3\n bp.index = index\n ap1.index = bp.atomIndex1\n ap2.index = bp.atomIndex2\n bondOrder = bp.bondOrder\n if (position1) {\n if (isMulti && bondOrder > 1) {\n const atomRadius = radiusFactory.atomRadius(ap1)\n multiRadius = atomRadius * bondScale / (0.5 * bondOrder)\n\n bp.calculateShiftDir(vShift)\n\n if (isOffset) {\n absOffset = 2 * bondSpacing * atomRadius\n vShift.multiplyScalar(absOffset)\n vShift.negate()\n\n // Shortening is calculated so that neighbouring double\n // bonds on tetrahedral geometry (e.g. sulphonamide)\n // are not quite touching (arccos(1.9 / 2) ~ 109deg)\n // but don't shorten beyond 10% each end or it looks odd\n vShortening.subVectors(ap2 as any, ap1 as any).multiplyScalar( // TODO\n Math.max(0.1, absOffset / 1.88)\n )\n ap1.positionToArray(position1, i3)\n ap2.positionToArray(position2, i3)\n\n if (bondOrder >= 2) {\n vt.addVectors(ap1 as any, vShift).add(vShortening).toArray(position1 as any, i3 + 3) // TODO\n vt.addVectors(ap2 as any, vShift).sub(vShortening).toArray(position2 as any, i3 + 3) // TODO\n\n if (bondOrder >= 3) {\n vt.subVectors(ap1 as any, vShift).add(vShortening).toArray(position1 as any, i3 + 6) // TODO\n vt.subVectors(ap2 as any, vShift).sub(vShortening).toArray(position2 as any, i3 + 6) // TODO\n }\n }\n } else {\n absOffset = (bondSpacing - bondScale) * atomRadius\n vShift.multiplyScalar(absOffset)\n\n if (bondOrder === 2) {\n vt.addVectors(ap1 as any, vShift).toArray(position1 as any, i3) // TODO\n vt.subVectors(ap1 as any, vShift).toArray(position1 as any, i3 + 3) // TODO\n vt.addVectors(ap2 as any, vShift).toArray(position2 as any, i3) // TODO\n vt.subVectors(ap2 as any, vShift).toArray(position2 as any, i3 + 3) // TODO\n } else if (bondOrder === 3) {\n ap1.positionToArray(position1, i3)\n vt.addVectors(ap1 as any, vShift).toArray(position1 as any, i3 + 3) // TODO\n vt.subVectors(ap1 as any, vShift).toArray(position1 as any, i3 + 6) // TODO\n ap2.positionToArray(position2, i3)\n vt.addVectors(ap2 as any, vShift).toArray(position2 as any, i3 + 3) // TODO\n vt.subVectors(ap2 as any, vShift).toArray(position2 as any, i3 + 6) // TODO\n } else {\n // todo, better fallback\n ap1.positionToArray(position1, i3)\n ap2.positionToArray(position2, i3)\n }\n }\n } else {\n ap1.positionToArray(position1, i3)\n ap2.positionToArray(position2, i3)\n }\n }\n if (color && color2) {\n colormaker.bondColorToArray(bp, 1, color, i3)\n colormaker.bondColorToArray(bp, 0, color2, i3)\n if (isMulti && bondOrder > 1) {\n for (j = 1; j < bondOrder; ++j) {\n k = j * 3 + i3\n copyWithin(color, i3, k, 3)\n copyWithin(color2, i3, k, 3)\n }\n }\n }\n if (picking && picking.array) {\n picking.array[ i ] = index\n if (isMulti && bondOrder > 1) {\n for (j = 1; j < bondOrder; ++j) {\n picking.array[ i + j ] = index\n }\n }\n }\n if (radius) {\n radius[ i ] = radiusFactory.atomRadius(ap1)\n if (isMulti && bondOrder > 1) {\n multiRadius = radius[ i ] * bondScale / (isOffset ? 1 : (0.5 * bondOrder))\n for (j = isOffset ? 1 : 0; j < bondOrder; ++j) {\n radius[ i + j ] = multiRadius\n }\n }\n }\n if (radius2) {\n radius2[ i ] = radiusFactory.atomRadius(ap2)\n if (isMulti && bondOrder > 1) {\n multiRadius = radius2[ i ] * bondScale / (isOffset ? 1 : (0.5 * bondOrder))\n for (j = isOffset ? 1 : 0; j < bondOrder; ++j) {\n radius2[ i + j ] = multiRadius\n }\n }\n }\n i += isMulti ? bondOrder : 1\n })\n\n return bondData\n }\n\n getBackboneAtomData (params: AtomDataParams) {\n params = Object.assign({\n atomSet: this.atomSetCache.__backbone\n }, params)\n\n return this.getAtomData(params)\n }\n\n getBackboneBondData (params: BondDataParams) {\n params = Object.assign({\n bondSet: this.getBackboneBondSet(),\n bondStore: this.backboneBondStore\n }, params)\n\n return this.getBondData(params)\n }\n\n getRungAtomData (params: AtomDataParams) {\n params = Object.assign({\n atomSet: this.atomSetCache.__rung\n }, params)\n\n return this.getAtomData(params)\n }\n\n getRungBondData (params: BondDataParams) {\n params = Object.assign({\n bondSet: this.getRungBondSet(),\n bondStore: this.rungBondStore\n }, params)\n\n return this.getBondData(params)\n }\n\n //\n\n /**\n * Gets the bounding box of the (selected) structure atoms\n * @param {Selection} [selection] - the selection\n * @param {Box3} [box] - optional target\n * @return {Vector3} the box\n */\n getBoundingBox (selection?: Selection, box?: Box3) {\n if (Debug) Log.time('getBoundingBox')\n\n box = box || new Box3()\n\n let minX = +Infinity\n let minY = +Infinity\n let minZ = +Infinity\n\n let maxX = -Infinity\n let maxY = -Infinity\n let maxZ = -Infinity\n\n this.eachAtom(ap => {\n const x = ap.x\n const y = ap.y\n const z = ap.z\n\n if (x < minX) minX = x\n if (y < minY) minY = y\n if (z < minZ) minZ = z\n\n if (x > maxX) maxX = x\n if (y > maxY) maxY = y\n if (z > maxZ) maxZ = z\n }, selection)\n\n box.min.set(minX, minY, minZ)\n box.max.set(maxX, maxY, maxZ)\n\n if (Debug) Log.timeEnd('getBoundingBox')\n\n return box\n }\n\n /**\n * Gets the principal axes of the (selected) structure atoms\n * @param {Selection} [selection] - the selection\n * @return {PrincipalAxes} the principal axes\n */\n getPrincipalAxes (selection?: Selection) {\n if (Debug) Log.time('getPrincipalAxes')\n\n let i = 0\n const coords = new Matrix(3, this.atomCount)\n const cd = coords.data\n\n this.eachAtom(a => {\n cd[ i + 0 ] = a.x\n cd[ i + 1 ] = a.y\n cd[ i + 2 ] = a.z\n i += 3\n }, selection)\n\n if (Debug) Log.timeEnd('getPrincipalAxes')\n\n return new PrincipalAxes(coords)\n }\n\n /**\n * Gets the center of the (selected) structure atoms\n * @param {Selection} [selection] - the selection\n * @return {Vector3} the center\n */\n atomCenter (selection?: Selection) {\n if (selection) {\n return this.getBoundingBox(selection).getCenter(new Vector3())\n } else {\n return this.center.clone()\n }\n }\n\n hasCoords () {\n if (this._hasCoords === undefined) {\n const atomStore = this.atomStore\n this._hasCoords = (\n arrayMin(atomStore.x) !== 0 || arrayMax(atomStore.x) !== 0 ||\n arrayMin(atomStore.y) !== 0 || arrayMax(atomStore.y) !== 0 ||\n arrayMin(atomStore.z) !== 0 || arrayMax(atomStore.z) !== 0\n ) || (\n // allow models with a single atom at the origin\n atomStore.count / this.modelStore.count === 1\n )\n }\n return this._hasCoords;\n }\n\n getSequence (selection?: Selection) {\n const seq: string[] = []\n const rp = this.getResidueProxy()\n\n this.eachAtom(function (ap: AtomProxy) {\n rp.index = ap.residueIndex\n if (ap.index === rp.traceAtomIndex) {\n seq.push(rp.getResname1())\n }\n }, selection)\n\n return seq\n }\n\n getAtomIndices (selection?: Selection) {\n if (selection && selection.string) {\n const indices: number[] = []\n this.eachAtom(function (ap: AtomProxy) {\n indices.push(ap.index)\n }, selection)\n return new Uint32Array(indices)\n } else {\n const p = { what: { index: true } }\n return this.getAtomData(p).index\n }\n }\n\n /**\n * Get number of unique chainnames\n * @param {Selection} selection - limit count to selection\n * @return {Integer} count\n */\n getChainnameCount (selection?: Selection) {\n const chainnames = new Set()\n this.eachChain(function (cp: ChainProxy) {\n if (cp.residueCount) {\n chainnames.add(cp.chainname)\n }\n }, selection)\n\n return chainnames.size\n }\n\n /**\n * Update atomic positions\n * @param position - Array to copy positions from\n * @param refresh - Whether or not to issue a full refresh (automatically\n * triggers re-calculation of bounding boxes, spatial hash,\n * representations etc etc). This provides compatibility with\n * the old behaviour\n */\n updatePosition (position: Float32Array|number[], refresh: boolean = true) {\n let i = 0\n\n this.eachAtom(function (ap: AtomProxy) {\n ap.positionFromArray(position, i)\n i += 3\n }, undefined)\n\n this._hasCoords = undefined // to trigger recalculation (of the _hasCoords value)\n\n if (refresh) { \n this.refreshPosition() // Recalculate bounds - structure-component listener will \n // trigger representation rebuild\n }\n\n }\n\n refreshPosition () {\n this.getBoundingBox(undefined, this.boundingBox)\n this.boundingBox.getCenter(this.center)\n this.spatialHash = new SpatialHash(this.atomStore, this.boundingBox)\n\n this.signals.refreshed.dispatch(this)\n }\n\n /**\n * Calls dispose() method of property objects.\n * Unsets properties to help garbage collection.\n * @return {undefined}\n */\n dispose () {\n if (this.frames) this.frames.length = 0\n if (this.boxes) this.boxes.length = 0\n\n this.bondStore.dispose()\n this.backboneBondStore.dispose()\n this.rungBondStore.dispose()\n this.atomStore.dispose()\n this.residueStore.dispose()\n this.chainStore.dispose()\n this.modelStore.dispose()\n\n // can't delete non-optional properties as of TS 4\n // and since we've already disposed them, don't need to.\n\n delete this.bondSet\n delete this.atomSet\n }\n}\n\nexport default Structure\n","/**\n * @file Shape\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Matrix4 required for declaration only\nimport { Box3, Vector3, Color, Matrix4 } from 'three'\n\nimport { createParams, ensureFloat32Array, getUintArray } from '../utils'\nimport {\n ArrowPrimitive, BoxPrimitive, ConePrimitive, CylinderPrimitive, EllipsoidPrimitive,\n OctahedronPrimitive, SpherePrimitive, TetrahedronPrimitive, TextPrimitive,\n TorusPrimitive, PointPrimitive, WidelinePrimitive\n} from './primitive'\nimport { MeshPicker } from '../utils/picker'\nimport Buffer from '../buffer/buffer'\nimport MeshBuffer from '../buffer/mesh-buffer'\nimport { TextBufferParameters } from '../buffer/text-buffer'\n\nconst tmpBox = new Box3()\n\nconst Primitives = [\n ArrowPrimitive, BoxPrimitive, ConePrimitive, CylinderPrimitive,\n EllipsoidPrimitive, OctahedronPrimitive, SpherePrimitive, TetrahedronPrimitive,\n TextPrimitive, TorusPrimitive, PointPrimitive, WidelinePrimitive\n]\n\nexport const ShapeDefaultParameters = {\n aspectRatio: 1.5,\n sphereDetail: 2,\n radialSegments: 50,\n disableImpostor: false,\n openEnded: false,\n dashedCylinder: false,\n labelParams: {} as Partial,\n pointSize: 2,\n sizeAttenuation: false,\n useTexture: true,\n linewidth: 2\n}\nexport type ShapeParameters = typeof ShapeDefaultParameters\n\n/**\n * Class for building custom shapes.\n *\n * @example\n * var shape = new NGL.Shape('shape', { disableImpostor: true });\n * shape.addSphere([ 0, 0, 9 ], [ 1, 0, 0 ], 1.5 );\n * shape.addEllipsoid([ 6, 0, 0 ], [ 1, 0, 0 ], 1.5, [ 3, 0, 0 ], [ 0, 2, 0 ]);\n * shape.addCylinder([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ], 0.5);\n * shape.addCone([ 0, 2, 7 ], [ 0, 3, 3 ], [ 1, 1, 0 ], 1.5);\n * shape.addArrow([ 1, 2, 7 ], [ 30, 3, 3 ], [ 1, 0, 1 ], 1.0);\n * shape.addBox([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);\n * var shapeComp = stage.addComponentFromObject(shape);\n * geoComp.addRepresentation('buffer');\n */\nclass Shape {\n name: string\n parameters: ShapeParameters\n\n boundingBox = new Box3()\n bufferList: Buffer[] = []\n meshCount = 0\n\n _center?: Vector3\n _primitiveData: { [k: string]: any } = {}\n\n /**\n * @param {String} name - name\n * @param {Object} params - parameter object\n * @param {Integer} params.aspectRatio - arrow aspect ratio, used for cylinder radius and cone length\n * @param {Integer} params.sphereDetail - sphere quality (icosahedron subdivisions)\n * @param {Integer} params.radialSegments - cylinder quality (number of segments)\n * @param {Boolean} params.disableImpostor - disable use of raycasted impostors for rendering\n * @param {Boolean} params.openEnded - capped or not\n * @param {TextBufferParameters} params.labelParams - label parameters\n */\n constructor (name = 'shape', params: Partial = {}) {\n this.name = name\n\n this.parameters = createParams(params, ShapeDefaultParameters)\n\n Primitives.forEach(P => {\n Object.keys(P.fields).forEach(name => {\n this._primitiveData[ P.getShapeKey(name) ] = []\n })\n this._primitiveData[ P.getShapeKey('name') ] = []\n })\n }\n\n /**\n * Add a buffer\n * @param {Buffer} buffer - buffer object\n * @return {Shape} this object\n */\n addBuffer (buffer: Buffer) {\n this.bufferList.push(buffer)\n\n const geometry = (buffer as any).geometry // TODO\n if (!geometry.boundingBox) {\n geometry.computeBoundingBox()\n }\n this.boundingBox.union(geometry.boundingBox)\n\n return this\n }\n\n /**\n * Add a mesh\n * @example\n * shape.addMesh(\n * [ 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1 ],\n * [ 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0 ]\n * );\n *\n * @param {Float32Array|Array} position - positions\n * @param {Float32Array|Array} color - colors\n * @param {Uint32Array|Uint16Array|Array} [index] - indices\n * @param {Float32Array|Array} [normal] - normals\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addMesh (position: Float32Array|number[], color:Float32Array|number[], index: Uint32Array|Uint16Array|number[], normal?: Float32Array|number[], name?: string) {\n position = ensureFloat32Array(position)\n color = ensureFloat32Array(color)\n\n if (Array.isArray(index)) {\n index = getUintArray(index, position.length)\n }\n if (normal) {\n normal = ensureFloat32Array(normal)\n }\n\n let data\n if (normal === undefined || normal.length == 0 ) {\n data = { position, color, index }\n } else {\n data = { position, color, index, normal }\n }\n //const data = { position, color, index, normal }\n const picking = new MeshPicker(\n this, Object.assign({ serial: this.meshCount, name }, data)\n )\n const meshBuffer = new MeshBuffer(\n Object.assign({ picking }, data) as any\n )\n this.bufferList.push(meshBuffer)\n\n tmpBox.setFromArray(position)\n this.boundingBox.union(tmpBox)\n this.meshCount += 1\n\n return this\n }\n\n /**\n * Add a sphere\n * @example\n * shape.addSphere([ 0, 0, 9 ], [ 1, 0, 0 ], 1.5);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addSphere (position: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, name: string) {\n SpherePrimitive.objectToShape(\n this, { position, color, radius, name }\n )\n return this\n }\n\n /**\n * Add an ellipsoid\n * @example\n * shape.addEllipsoid([ 6, 0, 0 ], [ 1, 0, 0 ], 1.5, [ 3, 0, 0 ], [ 0, 2, 0 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {Vector3|Array} majorAxis - major axis vector or array\n * @param {Vector3|Array} minorAxis - minor axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addEllipsoid (position: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, majorAxis: Vector3|[number, number, number], minorAxis: Vector3|[number, number, number], name: string) {\n EllipsoidPrimitive.objectToShape(\n this, { position, color, radius, majorAxis, minorAxis, name }\n )\n return this\n }\n\n /**\n * Add a torus\n * @example\n * shape.addTorus([ 6, 0, 0 ], [ 1, 0, 0 ], 1.5, [ 3, 0, 0 ], [ 0, 2, 0 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {Vector3|Array} majorAxis - major axis vector or array\n * @param {Vector3|Array} minorAxis - minor axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addTorus (position: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, majorAxis: Vector3|[number, number, number], minorAxis: Vector3|[number, number, number], name: string) {\n TorusPrimitive.objectToShape(\n this, { position, color, radius, majorAxis, minorAxis, name }\n )\n return this\n }\n\n /**\n * Add a cylinder\n * @example\n * shape.addCylinder([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ], 0.5);\n *\n * @param {Vector3|Array} position1 - from position vector or array\n * @param {Vector3|Array} position2 - to position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addCylinder (position1: Vector3|[number, number, number], position2: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, name: string) {\n CylinderPrimitive.objectToShape(\n this, { position1, position2, color, radius, name }\n )\n return this\n }\n\n /**\n * Add a cone\n * @example\n * shape.addCone([ 0, 2, 7 ], [ 0, 3, 3 ], [ 1, 1, 0 ], 1.5);\n *\n * @param {Vector3|Array} position1 - from position vector or array\n * @param {Vector3|Array} position2 - to position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addCone (position1: Vector3|[number, number, number], position2: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, name: string) {\n ConePrimitive.objectToShape(\n this, { position1, position2, color, radius, name }\n )\n return this\n }\n\n /**\n * Add an arrow\n * @example\n * shape.addArrow([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ], 0.5);\n *\n * @param {Vector3|Array} position1 - from position vector or array\n * @param {Vector3|Array} position2 - to position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addArrow (position1: Vector3|[number, number, number], position2: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, name: string) {\n ArrowPrimitive.objectToShape(\n this, { position1, position2, color, radius, name }\n )\n return this\n }\n\n /**\n * Add a box\n * @example\n * shape.addBox([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} size - size value\n * @param {Vector3|Array} heightAxis - height axis vector or array\n * @param {Vector3|Array} depthAxis - depth axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addBox (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, heightAxis: Vector3|[number, number, number], depthAxis: Vector3|[number, number, number], name: string) {\n BoxPrimitive.objectToShape(\n this, { position, color, size, heightAxis, depthAxis, name }\n )\n return this\n }\n\n /**\n * Add an octahedron\n * @example\n * shape.addOctahedron([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} size - size value\n * @param {Vector3|Array} heightAxis - height axis vector or array\n * @param {Vector3|Array} depthAxis - depth axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addOctahedron (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, heightAxis: Vector3|[number, number, number], depthAxis: Vector3|[number, number, number], name: string) {\n OctahedronPrimitive.objectToShape(\n this, { position, color, size, heightAxis, depthAxis, name }\n )\n return this\n }\n\n /**\n * Add a tetrahedron\n * @example\n * shape.addTetrahedron([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} size - size value\n * @param {Vector3|Array} heightAxis - height axis vector or array\n * @param {Vector3|Array} depthAxis - depth axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addTetrahedron (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, heightAxis: Vector3|[number, number, number], depthAxis: Vector3|[number, number, number], name: string) {\n TetrahedronPrimitive.objectToShape(\n this, { position, color, size, heightAxis, depthAxis, name }\n )\n return this\n }\n\n /**\n * Add text\n * @example\n * shape.addText([ 10, -2, 4 ], [ 0.2, 0.5, 0.8 ], 0.5, \"Hello\");\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} size - size value\n * @param {String} text - text value\n * @return {Shape} this object\n */\n addText (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, text: string) {\n TextPrimitive.objectToShape(\n this, { position, color, size, text }\n )\n return this\n }\n\n /**\n * Add point\n * @example\n * shape.addPoint([ 10, -2, 4 ], [ 0.2, 0.5, 0.8 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addPoint (position: Vector3|[number, number, number], color: Color|[number, number, number], name: string) {\n PointPrimitive.objectToShape(\n this, { position, color, name }\n )\n return this\n }\n\n /**\n * Add a wideline\n * @example\n * shape.addWideline([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ]);\n *\n * @param {Vector3|Array} position1 - from position vector or array\n * @param {Vector3|Array} position2 - to position vector or array\n * @param {Color|Array} color - color object or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addWideline (position1: Vector3|[number, number, number], position2: Vector3|[number, number, number], color: Color|[number, number, number], linewidth: number, name: string) {\n this.parameters.linewidth = linewidth\n WidelinePrimitive.objectToShape(\n this, { position1, position2, color, name }\n )\n return this\n }\n\n /**\n * Deprecated, use `.addText`\n */\n addLabel (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, text: string) {\n console.warn('Shape.addLabel is deprecated, use .addText instead')\n return this.addText(position, color, size, text)\n }\n\n getBufferList () {\n const buffers: Buffer[] = []\n\n Primitives.forEach(P => {\n if (this._primitiveData[ P.getShapeKey('color') ].length) {\n buffers.push(P.bufferFromShape(this, this.parameters))\n }\n })\n\n return this.bufferList.concat(buffers)\n }\n\n dispose () {\n this.bufferList.forEach(function (buffer) {\n buffer.dispose()\n })\n this.bufferList.length = 0\n\n Primitives.forEach(P => {\n Object.keys(P.fields).forEach(name => {\n this._primitiveData[ P.getShapeKey(name) ].length = 0\n })\n this._primitiveData[ P.getShapeKey('name') ].length = 0\n })\n }\n\n get center () {\n if (!this._center) {\n this._center = this.boundingBox.getCenter(new Vector3())\n }\n return this._center\n }\n\n get type () { return 'Shape' }\n}\n\nexport default Shape\n","/**\n * @file Buffer Representation\n * @author Alexander Rose \n * @private\n */\n\nimport Representation, { RepresentationParameters } from './representation'\nimport Viewer from '../viewer/viewer';\n\n/**\n * Representation for showing buffer objects. Good for efficiently showing\n * large amounts of geometric primitives e.g. spheres via {@link SphereBuffer}.\n * Smaller numbers of geometric primitives are more easily shown with help\n * from the {@link Shape} class.\n *\n * __Name:__ _buffer_\n *\n * @example\n * // add a single red sphere from a buffer to a shape instance\n * var shape = new NGL.Shape( \"shape\" );\n * var sphereBuffer = new NGL.SphereBuffer( {\n * position: new Float32Array( [ 0, 0, 0 ] ),\n * color: new Float32Array( [ 1, 0, 0 ] ),\n * radius: new Float32Array( [ 1 ] )\n * } );\n * shape.addBuffer( sphereBuffer );\n * var shapeComp = stage.addComponentFromObject( shape );\n * shapeComp.addRepresentation( \"buffer\" );\n *\n * @example\n * // add a single red sphere from a buffer to a structure component instance\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * var sphereBuffer = new NGL.SphereBuffer( {\n * position: new Float32Array( [ 0, 0, 0 ] ),\n * color: new Float32Array( [ 1, 0, 0 ] ),\n * radius: new Float32Array( [ 1 ] )\n * } );\n * o.addBufferRepresentation( sphereBuffer, { opacity: 0.5 } );\n * } );\n */\nclass BufferRepresentation extends Representation {\n buffer: Buffer[]\n /**\n * Create Buffer representation\n * @param {Buffer} buffer - a buffer object\n * @param {Viewer} viewer - a viewer object\n * @param {RepresentationParameters} params - representation parameters\n */\n constructor (buffer: Buffer|Buffer[], viewer: Viewer, params: Partial) {\n if (!Array.isArray(buffer)) {\n buffer = [ buffer ]\n }\n\n super(buffer, viewer, params)\n\n this.type = 'buffer'\n\n this.parameters = Object.assign({\n\n }, this.parameters, {\n\n colorScheme: null,\n colorScale: null,\n colorValue: null,\n colorDomain: null,\n colorMode: null\n\n })\n\n this.buffer = buffer\n\n this.init(params)\n }\n\n init (params: Partial) {\n super.init(params)\n\n this.build()\n }\n\n create () {\n this.bufferList.push.apply(this.bufferList, this.buffer)\n }\n\n attach (callback: ()=> void) {\n this.bufferList.forEach(buffer => {\n this.viewer.add(buffer)\n buffer.setParameters(this.getBufferParams())\n })\n this.setVisibility(this.visible)\n\n callback()\n }\n}\n\nexport default BufferRepresentation\n","/**\n * @file Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3 required for declaration only\n import { Vector3, Matrix4, Matrix3, BufferGeometry } from 'three'\n\nimport { getUintArray } from '../utils'\nimport { serialBlockArray } from '../math/array-utils'\nimport { applyMatrix3toVector3array, applyMatrix4toVector3array } from '../math/vector-utils'\nimport MeshBuffer from './mesh-buffer'\nimport { BufferParameters, BufferData } from './buffer'\nimport {Log} from \"../globals\";\n\nconst matrix = new Matrix4()\nconst normalMatrix = new Matrix3()\n\nfunction getData(data: BufferData, geo: BufferGeometry){\n const geoPosition = (geo.attributes as any).position.array\n const geoIndex = geo.index ? geo.index.array : undefined\n\n const n = data.position!.length / 3\n const m = geoPosition.length / 3\n\n const size = n * m\n\n const meshPosition = new Float32Array(size * 3)\n const meshNormal = new Float32Array(size * 3)\n const meshColor = new Float32Array(size * 3)\n\n let meshIndex\n if (geoIndex) {\n meshIndex = getUintArray(n * geoIndex.length, size)\n }\n\n return {\n position: meshPosition,\n color: meshColor,\n index: meshIndex,\n normal: meshNormal,\n primitiveId: data.primitiveId || serialBlockArray(n, m) as Float32Array,\n picking: data.picking\n }\n}\n\n/**\n * Geometry buffer. Base class for geometry-based buffers. Used to draw\n * geometry primitives given a mesh.\n * @interface\n */\nabstract class GeometryBuffer extends MeshBuffer {\n updateNormals = false\n\n geoPosition: Float32Array\n geoNormal: Float32Array\n geoIndex?: Uint32Array|Uint16Array\n\n positionCount: number\n geoPositionCount: number\n\n transformedGeoPosition: Float32Array\n transformedGeoNormal: Float32Array\n\n meshPosition: Float32Array\n meshColor: Float32Array\n meshIndex: Uint32Array|Uint16Array\n meshNormal: Float32Array\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n * @param {BufferGeometry} geo - geometry object\n */\n constructor (data: BufferData, params: Partial = {}, geo: BufferGeometry) {\n super(getData(data, geo), params)\n\n const geoPosition = (geo.attributes as any).position.array\n const geoNormal = (geo.attributes as any).normal.array\n const geoIndex = geo.index ? (geo.index.array as Uint32Array|Uint16Array) : undefined\n\n this.geoPosition = geoPosition\n this.geoNormal = geoNormal\n this.geoIndex = geoIndex\n\n this.positionCount = data.position!.length / 3\n this.geoPositionCount = geoPosition.length / 3\n\n this.transformedGeoPosition = new Float32Array(this.geoPositionCount * 3)\n this.transformedGeoNormal = new Float32Array(this.geoPositionCount * 3)\n\n const attributes = this.geometry.attributes as any // TODO\n this.meshPosition = attributes.position.array\n this.meshColor = attributes.color.array\n this.meshNormal = attributes.normal.array\n\n this.setAttributes(data)\n\n if (geoIndex) {\n const index = this.geometry.getIndex()\n if (!index) { Log.error('Index is null'); return; }\n this.meshIndex = index.array as Uint32Array|Uint16Array\n this.makeIndex()\n }\n }\n\n abstract applyPositionTransform (matrix: Matrix4, i: number, i3?: number): void\n\n setAttributes (data: Partial = {}, initNormals = false) {\n const attributes = this.geometry.attributes as any // TODO\n\n let position, color\n let geoPosition, geoNormal\n let transformedGeoPosition, transformedGeoNormal\n let meshPosition, meshColor, meshNormal\n\n const updateNormals = this.updateNormals\n\n if (data.position) {\n position = data.position\n geoPosition = this.geoPosition\n meshPosition = this.meshPosition\n transformedGeoPosition = this.transformedGeoPosition\n attributes.position.needsUpdate = true\n if (updateNormals || initNormals) {\n geoNormal = this.geoNormal\n meshNormal = this.meshNormal\n transformedGeoNormal = this.transformedGeoNormal\n attributes.normal.needsUpdate = true\n }\n }\n\n if (data.color) {\n color = data.color\n meshColor = this.meshColor\n attributes.color.needsUpdate = true\n }\n\n const n = this.positionCount\n const m = this.geoPositionCount\n\n for (let i = 0; i < n; ++i) {\n let j, l\n const k = i * m * 3\n const i3 = i * 3\n\n if (position && transformedGeoPosition && meshPosition && meshNormal && geoPosition && geoNormal) {\n transformedGeoPosition.set(geoPosition)\n matrix.makeTranslation(\n position[ i3 ], position[ i3 + 1 ], position[ i3 + 2 ]\n )\n this.applyPositionTransform(matrix, i, i3)\n applyMatrix4toVector3array(matrix.elements as unknown as Float32Array,\n transformedGeoPosition)\n\n meshPosition.set(transformedGeoPosition, k)\n\n if (updateNormals && transformedGeoNormal) {\n transformedGeoNormal.set(geoNormal)\n normalMatrix.getNormalMatrix(matrix)\n applyMatrix3toVector3array(normalMatrix.elements as unknown as Float32Array,\n transformedGeoNormal)\n\n meshNormal.set(transformedGeoNormal, k)\n } else if (initNormals) {\n meshNormal.set(geoNormal, k)\n }\n }\n\n if (color && meshColor) {\n for (j = 0; j < m; ++j) {\n l = k + 3 * j\n\n meshColor[ l ] = color[ i3 ]\n meshColor[ l + 1 ] = color[ i3 + 1 ]\n meshColor[ l + 2 ] = color[ i3 + 2 ]\n }\n }\n }\n }\n\n makeIndex () {\n const geoIndex = this.geoIndex\n const meshIndex = this.meshIndex\n\n if (!geoIndex) return\n\n const n = this.positionCount\n const m = this.geoPositionCount\n const o = geoIndex.length / 3\n\n const o3 = o * 3\n\n for (let i = 0; i < n; ++i) {\n const j = i * o3\n const q = j + o3\n\n meshIndex.set(geoIndex, j)\n for (let p = j; p < q; ++p) meshIndex[ p ] += i * m\n }\n }\n}\n\nexport default GeometryBuffer\n","/**\n * @file Sphere Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { IcosahedronBufferGeometry, Vector3, Matrix4 } from 'three'\nimport { defaults } from '../utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { SphereBufferData } from './sphere-buffer'\nimport { BufferDefaultParameters, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\n\nexport const SphereGeometryBufferDefaultParameters = Object.assign({\n sphereDetail: 1\n}, BufferDefaultParameters)\nexport type SphereGeometryBufferParameters = BufferParameters & { sphereDetail: number }\n\n/**\n * Sphere geometry buffer.\n *\n * @example\n * var sphereGeometryBuffer = new SphereGeometryBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass SphereGeometryBuffer extends GeometryBuffer {\n get defaultParameters() { return SphereGeometryBufferDefaultParameters }\n parameters: SphereGeometryBufferParameters\n\n private _radius: Float32Array\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: SphereBufferData, params: Partial = {}) {\n super(data, params, new IcosahedronBufferGeometry(1, defaults(params.sphereDetail, 1)))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number) {\n const r = this._radius[ i ]\n scale.set(r, r, r)\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.radius) this._radius = data.radius\n\n super.setAttributes(data, initNormals)\n }\n}\n\nexport default SphereGeometryBuffer\n","/**\n * @file Mapped Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { getUintArray } from '../utils'\nimport { calculateCenterArray, serialArray } from '../math/array-utils'\nimport Buffer, { BufferParameters, BufferData } from './buffer'\n\nexport type MappingType = 'v2'|'v3'\n\n/**\n * Mapped buffer. Sends mapping attribute to the GPU and repeats data in\n * others attributes. Used to render imposters.\n * @interface\n */\nabstract class MappedBuffer extends Buffer {\n index: Uint32Array|Uint16Array\n\n constructor (mappingType: MappingType, data: BufferData, params: Partial = {}) {\n super(data, params)\n\n this.index = getUintArray(this.indexSize, this.attributeSize)\n this.makeIndex()\n this.initIndex(this.index)\n\n this.addAttributes({\n 'mapping': { type: mappingType, value: null }\n })\n\n this.setAttributes({ primitiveId: serialArray(this.size) })\n }\n\n abstract get mapping (): Float32Array\n abstract get mappingIndices (): Uint32Array|Uint16Array\n abstract get mappingIndicesSize (): number\n abstract get mappingSize (): number\n abstract get mappingItemSize (): number\n\n get attributeSize () {\n return this.size * this.mappingSize\n }\n\n get indexSize () {\n return this.size * this.mappingIndicesSize\n }\n\n addAttributes (attributes: any) {\n const nullValueAttributes: any = {}\n for (const name in attributes) {\n const a = attributes[ name ]\n nullValueAttributes[ name ] = {\n type: a.type,\n value: null\n }\n }\n\n super.addAttributes(nullValueAttributes)\n }\n\n getAttributeIndex (dataIndex: number) {\n return dataIndex * 3 * this.mappingSize\n }\n\n setAttributes (data: any) { // TODO\n if (data && !data.position && data.position1 && data.position2) {\n data.position = calculateCenterArray(data.position1, data.position2)\n }\n\n const size = this.size\n const mappingSize = this.mappingSize\n const attributes = this.geometry.attributes as any // TODO\n\n let a, d, itemSize, array, n, i, j\n\n for (const name in data) {\n if (name === 'index' || name === 'picking') continue\n\n d = data[ name ]\n a = attributes[ name ]\n itemSize = a.itemSize\n array = a.array\n\n for (let k = 0; k < size; ++k) {\n n = k * itemSize\n i = n * mappingSize\n\n for (let l = 0; l < mappingSize; ++l) {\n j = i + (itemSize * l)\n\n for (let m = 0; m < itemSize; ++m) {\n array[ j + m ] = d[ n + m ]\n }\n }\n }\n\n a.needsUpdate = true\n }\n }\n\n makeMapping () {\n const size = this.size\n const mapping = this.mapping\n const mappingSize = this.mappingSize\n const mappingItemSize = this.mappingItemSize\n\n const attributes = this.geometry.attributes as any // TODO\n const aMapping = attributes.mapping.array\n\n for (let v = 0; v < size; v++) {\n aMapping.set(mapping, v * mappingItemSize * mappingSize)\n }\n }\n\n makeIndex () {\n const size = this.size\n const mappingSize = this.mappingSize\n const mappingIndices = this.mappingIndices\n const mappingIndicesSize = this.mappingIndicesSize\n\n const index = this.index\n\n for (let v = 0; v < size; v++) {\n const ix = v * mappingIndicesSize\n const it = v * mappingSize\n\n index.set(mappingIndices, ix)\n\n for (let s = 0; s < mappingIndicesSize; ++s) {\n index[ ix + s ] += it\n }\n }\n }\n}\n\nexport default MappedBuffer\n","/**\n * @file Mapped Quad Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { BufferParameters, BufferData } from './buffer'\nimport MappedBuffer from './mapped-buffer'\n\nconst mapping = new Float32Array([\n -1.0, 1.0,\n -1.0, -1.0,\n 1.0, 1.0,\n 1.0, -1.0\n])\n\nconst mappingIndices = new Uint16Array([\n 0, 1, 2,\n 1, 3, 2\n])\n\n/**\n * Mapped Quad buffer. Draws screen-aligned quads. Used to render impostors.\n * @interface\n */\nclass MappedQuadBuffer extends MappedBuffer {\n constructor(data: BufferData, params: Partial = {}) {\n super('v2', data, params)\n }\n get mapping () { return mapping }\n get mappingIndices () { return mappingIndices }\n get mappingIndicesSize () { return 6 }\n get mappingSize () { return 4 }\n get mappingItemSize () { return 2 }\n}\n\nexport default MappedQuadBuffer\n","/**\n * @file Sphere Impostor Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport '../shader/SphereImpostor.vert'\nimport '../shader/SphereImpostor.frag'\n\nimport MappedQuadBuffer from './mappedquad-buffer'\nimport { SphereBufferData } from './sphere-buffer'\nimport { BufferParameters } from './buffer'\n\n/**\n * Sphere impostor buffer.\n *\n * @example\n * var sphereImpostorBuffer = new SphereImpostorBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass SphereImpostorBuffer extends MappedQuadBuffer {\n isImpostor = true\n vertexShader = 'SphereImpostor.vert'\n fragmentShader = 'SphereImpostor.frag'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: SphereBufferData, params: Partial = {}) {\n super(data, params)\n\n this.addUniforms({\n 'projectionMatrixInverse': { value: new Matrix4() },\n 'ortho': { value: 0.0 }\n })\n\n this.addAttributes({\n 'radius': { type: 'f', value: null }\n })\n\n this.setAttributes(data)\n this.makeMapping()\n }\n}\n\nexport default SphereImpostorBuffer\n","/**\n * @file Sphere Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only \nimport { Vector3, Matrix4 } from 'three'\nimport { BufferRegistry, ExtensionFragDepth } from '../globals'\nimport SphereGeometryBuffer, { SphereGeometryBufferDefaultParameters, SphereGeometryBufferParameters } from './spheregeometry-buffer'\nimport SphereImpostorBuffer from './sphereimpostor-buffer'\nimport { BufferData } from './buffer'\n\nexport interface SphereBufferData extends BufferData {\n radius: Float32Array\n}\n\nexport const SphereBufferDefaultParameters = Object.assign({\n disableImpostor: false\n}, SphereGeometryBufferDefaultParameters)\nexport type SphereBufferParameters = SphereGeometryBufferParameters & { disableImpostor: boolean }\n\nclass SphereBufferImpl {\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} params - parameters object\n * @return {SphereGeometryBuffer|SphereImpostorBuffer} the buffer object\n */\n constructor (data: SphereBufferData, params: SphereBufferParameters) {\n if (!ExtensionFragDepth || (params && params.disableImpostor)) {\n return new SphereGeometryBuffer(data, params)\n } else {\n return new SphereImpostorBuffer(data, params)\n }\n }\n}\n\n/**\n * Sphere buffer. Depending on the value {@link ExtensionFragDepth} and\n * `params.disableImpostor` the constructor returns either a\n * {@link SphereGeometryBuffer} or a {@link SphereImpostorBuffer}\n * @implements {Buffer}\n *\n * @example\n * var sphereBuffer = new SphereBuffer( {\n * position: new Float32Array( [ 0, 0, 0 ] ),\n * color: new Float32Array( [ 1, 0, 0 ] ),\n * radius: new Float32Array( [ 1 ] )\n * } );\n */\n//@ts-expect-error Incompatible constructor signatures\nconst SphereBuffer: {\n new(data: SphereBufferData, params: SphereBufferParameters): SphereGeometryBuffer | SphereImpostorBuffer;\n} = SphereBufferImpl;\n\ntype SphereBuffer = SphereGeometryBuffer | SphereImpostorBuffer;\n\nBufferRegistry.add('sphere', SphereBuffer)\n\nexport default SphereBuffer\n","/**\n * @file Point Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { DataTexture, Vector3, Matrix4 } from 'three'\n\nimport '../shader/Point.vert'\nimport '../shader/Point.frag'\n\nimport { BufferRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { smoothstep } from '../math/math-utils'\nimport Buffer, { BufferDefaultParameters, BufferParameterTypes, BufferData, BufferTypes, BufferParameters } from './buffer'\n\nfunction distance (x0: number, y0: number, x1: number, y1: number) {\n const dx = x1 - x0\n const dy = y1 - y0\n return Math.sqrt(dx * dx + dy * dy)\n}\n\ninterface PointTextureParams {\n width?: number\n height?: number\n delta?: number\n}\n\nfunction makePointTexture (params: PointTextureParams) {\n const p = params || {}\n\n const width = defaults(p.width, 256)\n const height = defaults(p.height, 256)\n const center = [ width / 2, height / 2 ]\n const radius = Math.min(width / 2, height / 2)\n const delta = defaults(p.delta, 1 / (radius + 1)) * radius\n\n let x = 0\n let y = 0\n const data = new Uint8Array(width * height * 4)\n\n for (let i = 0, il = data.length; i < il; i += 4) {\n const dist = distance(x, y, center[ 0 ], center[ 1 ])\n const value = 1 - smoothstep(radius - delta, radius, dist)\n\n data[ i ] = value * 255\n data[ i + 1 ] = value * 255\n data[ i + 2 ] = value * 255\n data[ i + 3 ] = value * 255\n\n if (++x === width) {\n x = 0\n y++\n }\n }\n\n const tex = new DataTexture(data, width, height)\n tex.needsUpdate = true\n\n return tex\n}\n\nexport const PointBufferDefaultParameters = Object.assign({\n pointSize: 1,\n sizeAttenuation: true,\n sortParticles: false,\n alphaTest: 0.5,\n useTexture: false,\n forceTransparent: false,\n edgeBleach: 0.0\n}, BufferDefaultParameters)\nexport type PointBufferParameters = BufferParameters & {\n pointSize: number,\n sizeAttenuation: boolean,\n sortParticles: boolean,\n alphaTest: number,\n useTexture: boolean,\n forceTransparent: boolean,\n edgeBleach: number\n}\n\nconst PointBufferParameterTypes = Object.assign({\n pointSize: { uniform: 'size' },\n sizeAttenuation: { updateShader: true },\n sortParticles: {},\n alphaTest: { updateShader: true },\n useTexture: { updateShader: true },\n forceTransparent: {},\n edgeBleach: { uniform: true }\n}, BufferParameterTypes)\n\n/**\n * Point buffer. Draws points. Optionally textured.\n *\n * @example\n * var pointBuffer = new PointBuffer( {\n * position: new Float32Array( [ 0, 0, 0 ] ),\n * color: new Float32Array( [ 1, 0, 0 ] )\n * } );\n */\nclass PointBuffer extends Buffer {\n parameterTypes = PointBufferParameterTypes\n get defaultParameters() { return PointBufferDefaultParameters }\n parameters: PointBufferParameters\n\n vertexShader = 'Point.vert'\n fragmentShader ='Point.frag'\n\n isPoint = true\n tex: DataTexture\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: BufferData, params: Partial = {}) {\n super(data, params)\n\n this.addUniforms({\n 'size': { value: this.parameters.pointSize },\n 'canvasHeight': { value: 1.0 },\n 'pixelRatio': { value: 1.0 },\n 'map': { value: null }\n })\n }\n\n makeMaterial () {\n super.makeMaterial()\n\n this.makeTexture()\n\n const m = this.material\n const wm = this.wireframeMaterial\n const pm = this.pickingMaterial\n\n m.uniforms.map.value = this.tex\n m.needsUpdate = true\n\n wm.uniforms.map.value = this.tex\n wm.needsUpdate = true\n\n pm.uniforms.map.value = this.tex\n pm.needsUpdate = true\n }\n\n makeTexture () {\n if (this.tex) this.tex.dispose()\n this.tex = makePointTexture({ delta: this.parameters.edgeBleach })\n }\n\n getDefines (type?: BufferTypes) {\n const defines = super.getDefines(type)\n\n if (this.parameters.sizeAttenuation) {\n defines.USE_SIZEATTENUATION = 1\n }\n\n if (this.parameters.useTexture) {\n defines.USE_MAP = 1\n }\n\n if (this.parameters.alphaTest > 0 && this.parameters.alphaTest <= 1) {\n defines.ALPHATEST = this.parameters.alphaTest.toPrecision(2)\n }\n\n return defines\n }\n\n setUniforms (data: any) {\n if (data && data.edgeBleach !== undefined) {\n this.makeTexture()\n data.map = this.tex\n }\n\n super.setUniforms(data)\n }\n\n dispose () {\n super.dispose()\n\n if (this.tex) this.tex.dispose()\n }\n}\n\nBufferRegistry.add('point', PointBuffer)\n\nexport default PointBuffer\n","/**\n * @file Dot Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { ExtensionFragDepth } from '../globals'\nimport { defaults } from '../utils'\nimport Representation, { RepresentationParameters } from './representation'\nimport Volume from '../surface/volume'\nimport FilteredVolume from '../surface/filtered-volume'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport PointBuffer from '../buffer/point-buffer'\nimport Surface from '../surface/surface';\nimport Viewer from '../viewer/viewer';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\n\nexport interface DotDataFields {\n color?: boolean,\n radius?: boolean,\n scale?: boolean\n}\n\n/**\n * Dot representation parameter object. Extends {@link RepresentationParameters}\n *\n * @typedef {Object} DotRepresentationParameters - dot representation parameters\n *\n * @property {String} thresholdType - Meaning of the threshold values. Either *value* for the literal value or *sigma* as a factor of the sigma of the data. For volume data only.\n * @property {Number} thresholdMin - Minimum value to be displayed. For volume data only.\n * @property {Number} thresholdMax - Maximum value to be displayed. For volume data only.\n * @property {Number} thresholdOut - Show only values falling outside of the treshold minumum and maximum. For volume data only.\n */\nexport interface DotRepresentationParameters extends RepresentationParameters {\n thresholdType: 'value'|'value'|'sigma'|'sigma'\n thresholdMin: number\n thresholdMax: number\n thresholdOut: boolean\n dotType: ''|'sphere'|'point'\n radiusType: ''|'value'|'abs-value'|'value-min'|'deviation'|'size'|'radius' //TODO had to add 'radius' because of test in line 333\n radius: number\n scale: number\n sphereDetail: number\n disableImpostor: boolean\n pointSize: number\n sizeAttenuation: boolean\n sortParticles: boolean\n useTexture: boolean\n alphaTest: number\n forceTransparent: boolean\n edgeBleach: number\n}\n/**\n * Dot representation\n */\nclass DotRepresentation extends Representation {\n protected thresholdType: 'value'|'value'|'sigma'|'sigma'\n protected thresholdMin: number\n protected thresholdMax: number\n protected thresholdOut: boolean\n protected dotType: ''|'sphere'|'point'\n protected radiusType: ''|'value'|'abs-value'|'value-min'|'deviation'|'size'|'radius' //TODO had to add 'radius' because of test in line 333\n protected radius: number\n protected scale: number\n protected sphereDetail: number\n protected disableImpostor: boolean\n protected pointSize: number\n protected sizeAttenuation: boolean\n protected sortParticles: boolean\n protected useTexture: boolean\n protected alphaTest: number\n protected forceTransparent: boolean\n protected edgeBleach: number\n\n protected surface: Surface|undefined\n protected volume: FilteredVolume|undefined\n protected dotBuffer: SphereBuffer|PointBuffer\n /**\n * Create Dot representation object\n * @param {Surface|Volume} surface - the surface or volume to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {DotRepresentationParameters} params - dot representation parameters\n */\n constructor (surface: Surface, viewer: Viewer, params: Partial) {\n super(surface, viewer, params)\n\n this.type = 'dot'\n\n this.parameters = Object.assign({\n\n thresholdType: {\n type: 'select',\n rebuild: true,\n options: {\n 'value': 'value', 'sigma': 'sigma'\n }\n },\n thresholdMin: {\n type: 'number', precision: 3, max: Infinity, min: -Infinity, rebuild: true\n },\n thresholdMax: {\n type: 'number', precision: 3, max: Infinity, min: -Infinity, rebuild: true\n },\n thresholdOut: {\n type: 'boolean', rebuild: true\n },\n dotType: {\n type: 'select',\n rebuild: true,\n options: {\n '': '',\n 'sphere': 'sphere',\n 'point': 'point'\n }\n },\n radiusType: {\n type: 'select',\n options: {\n '': '',\n 'value': 'value',\n 'abs-value': 'abs-value',\n 'value-min': 'value-min',\n 'deviation': 'deviation',\n 'size': 'size'\n }\n },\n radius: {\n type: 'number', precision: 3, max: 10.0, min: 0.001, property: 'size'\n },\n scale: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n sphereDetail: true,\n disableImpostor: true,\n\n pointSize: {\n type: 'number', precision: 1, max: 100, min: 0, buffer: true\n },\n sizeAttenuation: {\n type: 'boolean', buffer: true\n },\n sortParticles: {\n type: 'boolean', rebuild: true\n },\n useTexture: {\n type: 'boolean', buffer: true\n },\n alphaTest: {\n type: 'range', step: 0.001, max: 1, min: 0, buffer: true\n },\n forceTransparent: {\n type: 'boolean', buffer: true\n },\n edgeBleach: {\n type: 'range', step: 0.001, max: 1, min: 0, buffer: true\n }\n\n }, this.parameters, {\n\n colorScheme: {\n type: 'select',\n update: 'color',\n options: {\n '': '',\n 'value': 'value',\n 'uniform': 'uniform',\n 'random': 'random'\n }\n }\n\n })\n\n if (surface instanceof Volume) {\n this.surface = undefined\n this.volume = new FilteredVolume(surface)\n } else {\n this.surface = surface\n this.volume = undefined\n }\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'uniform')\n p.colorValue = defaults(p.colorValue, 0xDDDDDD)\n\n this.thresholdType = defaults(p.thresholdType, 'sigma')\n this.thresholdMin = defaults(p.thresholdMin, 2.0)\n this.thresholdMax = defaults(p.thresholdMax, Infinity)\n this.thresholdOut = defaults(p.thresholdOut, false)\n this.dotType = defaults(p.dotType, 'point')\n this.radius = defaults(p.radius, 0.1)\n this.scale = defaults(p.scale, 1.0)\n\n this.pointSize = defaults(p.pointSize, 1)\n this.sizeAttenuation = defaults(p.sizeAttenuation, true)\n this.sortParticles = defaults(p.sortParticles, false)\n this.useTexture = defaults(p.useTexture, false)\n this.alphaTest = defaults(p.alphaTest, 0.5)\n this.forceTransparent = defaults(p.forceTransparent, false)\n this.edgeBleach = defaults(p.edgeBleach, 0.0)\n\n super.init(p)\n\n this.build()\n }\n\n attach (callback: () => void) {\n this.bufferList.forEach(buffer => {\n this.viewer.add(buffer)\n })\n this.setVisibility(this.visible)\n\n callback()\n }\n\n create () {\n var dotData: SphereBufferData|{} = {}\n\n if (this.volume) {\n var volume = this.volume\n var thresholdMin, thresholdMax\n\n if (this.thresholdType === 'sigma') {\n thresholdMin = volume.getValueForSigma(this.thresholdMin)\n thresholdMax = volume.getValueForSigma(this.thresholdMax)\n } else {\n thresholdMin = this.thresholdMin\n thresholdMax = this.thresholdMax\n }\n volume.setFilter(thresholdMin, thresholdMax, this.thresholdOut)\n\n Object.assign(dotData, {\n position: volume.getDataPosition(),\n color: volume.getDataColor(this.getColorParams())\n })\n if (this.dotType === 'sphere') {\n Object.assign(dotData, {\n radius: volume.getDataSize(this.radius, this.scale),\n picking: volume.getDataPicking()\n })\n }\n } else {\n var surface = this.surface\n Object.assign(dotData, {\n position: (surface as Surface).getPosition(),\n color: (surface as Surface).getColor(this.getColorParams())\n })\n if (this.dotType === 'sphere') {\n Object.assign(dotData, {\n radius: (surface as Surface).getSize(this.radius, this.scale),\n picking: (surface as Surface).getPicking()\n })\n }\n }\n\n if (this.dotType === 'sphere') {\n this.dotBuffer = new SphereBuffer(\n dotData as SphereBufferData,\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: false\n }) as SphereBufferParameters\n ) as SphereGeometryBuffer\n } else {\n this.dotBuffer = new PointBuffer(\n dotData,\n this.getBufferParams({\n pointSize: this.pointSize,\n sizeAttenuation: this.sizeAttenuation,\n sortParticles: this.sortParticles,\n useTexture: this.useTexture,\n alphaTest: this.alphaTest,\n forceTransparent: this.forceTransparent,\n edgeBleach: this.edgeBleach\n })\n )\n }\n\n this.bufferList.push(this.dotBuffer as SphereGeometryBuffer)\n }\n\n update (what: DotDataFields = {}) {\n if (this.bufferList.length === 0) return\n\n const dotData: SphereBufferData|{} = {}\n\n if (what.color) {\n if (this.volume) {\n Object.assign(dotData, {\n color: this.volume.getDataColor(\n this.getColorParams()\n )\n })\n } else {\n Object.assign(dotData, {\n color: (this.surface as Surface).getColor(\n this.getColorParams()\n )\n })\n }\n }\n\n if (this.dotType === 'sphere' && (what.radius || what.scale)) {\n if (this.volume) {\n Object.assign(dotData, {\n radius: this.volume.getDataSize(\n this.radius, this.scale\n )\n })\n } else {\n Object.assign(dotData, {\n radius: (this.surface as Surface).getSize(\n this.radius, this.scale\n )\n })\n }\n }\n\n (this.dotBuffer as SphereGeometryBuffer).setAttributes(dotData)\n }\n\n setParameters (params: Partial, what: DotDataFields = {}, rebuild: boolean) {\n \n if (params && params.thresholdType !== undefined &&\n this.volume instanceof Volume\n ) {\n if (this.thresholdType === 'value' &&\n params.thresholdType === 'sigma'\n ) {\n this.thresholdMin = this.volume.getSigmaForValue(\n this.thresholdMin\n )\n this.thresholdMax = this.volume.getSigmaForValue(\n this.thresholdMax\n )\n } else if (this.thresholdType === 'sigma' &&\n params.thresholdType === 'value'\n ) {\n this.thresholdMin = this.volume.getValueForSigma(\n this.thresholdMin\n )\n this.thresholdMax = this.volume.getValueForSigma(\n this.thresholdMax\n )\n }\n\n this.thresholdType = params.thresholdType\n }\n\n if (params && params.radiusType !== undefined) {\n if (params.radiusType === 'radius') {\n this.radius = 0.1\n } else {\n this.radius = parseFloat(params.radiusType)\n }\n what.radius = true\n if (this.dotType === 'sphere' &&\n (!ExtensionFragDepth || this.disableImpostor)\n ) {\n rebuild = true\n }\n }\n\n if (params && params.radius !== undefined) {\n what.radius = true\n if (this.dotType === 'sphere' &&\n (!ExtensionFragDepth || this.disableImpostor)\n ) {\n rebuild = true\n }\n }\n\n if (params && params.scale !== undefined) {\n what.scale = true\n if (this.dotType === 'sphere' &&\n (!ExtensionFragDepth || this.disableImpostor)\n ) {\n rebuild = true\n }\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nexport default DotRepresentation\n","/**\n * @file Image Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport {\n // @ts-ignore: unused import Vector3, Matrix4 required for declaration only\n Vector2, Vector3, Matrix4, BufferAttribute, DataTexture,\n NormalBlending, NearestFilter, LinearFilter\n} from 'three'\n\nimport '../shader/Image.vert'\nimport '../shader/Image.frag'\n\nimport { Picker } from '../utils/picker'\nimport Buffer, { BufferDefaultParameters, BufferParameterTypes, BufferTypes } from './buffer'\n\n\nconst quadIndices = new Uint16Array([\n 0, 1, 2,\n 1, 3, 2\n])\n\nconst quadUvs = new Float32Array([\n 0, 1,\n 0, 0,\n 1, 1,\n 1, 0\n])\n\ntype ImageFilterTypes = 'nearest'|'linear'|'cubic-bspline'|'cubic-catmulrom'|'cubic-mitchell'\n\nexport interface ImageBufferData {\n position: Float32Array\n imageData: Uint8Array\n width: number\n height: number\n\n picking?: Picker\n}\n\nexport const ImageBufferDefaultParameters = Object.assign({\n filter: 'nearest' as ImageFilterTypes,\n forceTransparent: true\n}, BufferDefaultParameters)\nexport type ImageBufferParameters = typeof ImageBufferDefaultParameters\n\nexport const ImageBufferParameterTypes = Object.assign({\n filter: { updateShader: true, uniform: true }\n}, BufferParameterTypes)\n\n/**\n * Image buffer. Draw a single image. Optionally interpolate.\n */\nclass ImageBuffer extends Buffer {\n parameterTypes = ImageBufferParameterTypes\n get defaultParameters() { return ImageBufferDefaultParameters }\n parameters: ImageBufferParameters\n\n alwaysTransparent = true\n hasWireframe = false\n vertexShader = 'Image.vert'\n fragmentShader = 'Image.frag'\n\n tex: DataTexture\n pickingTex: DataTexture\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position - image position\n * @param {Float32Array} data.imageData - image data, rgba channels\n * @param {Float32Array} data.width - image width\n * @param {Float32Array} data.height - image height\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n */\n constructor (data: ImageBufferData, params: ImageBufferParameters) {\n super({\n position: data.position,\n index: quadIndices,\n picking: data.picking\n }, params)\n\n const {imageData, width, height} = data\n\n const tex = new DataTexture(imageData, width, height)\n tex.flipY = true\n this.tex = tex\n\n const n = imageData.length\n const pickingData = new Uint8Array(n)\n for (let i = 0; i < n; i += 4) {\n const j = i / 4\n pickingData[ i ] = j >> 16 & 255\n pickingData[ i + 1 ] = j >> 8 & 255\n pickingData[ i + 2 ] = j & 255\n }\n\n const pickingTex = new DataTexture(pickingData, width, height)\n pickingTex.flipY = true\n pickingTex.minFilter = NearestFilter\n pickingTex.magFilter = NearestFilter\n this.pickingTex = pickingTex\n\n this.addUniforms({\n 'map': { value: tex },\n 'pickingMap': { value: pickingTex },\n 'mapSize': { value: new Vector2(width, height) }\n })\n\n this.geometry.setAttribute('uv', new BufferAttribute(quadUvs, 2))\n }\n\n getDefines (type: BufferTypes) {\n const defines = super.getDefines(type)\n const filter = this.parameters.filter\n\n if (filter.startsWith('cubic')) {\n defines.CUBIC_INTERPOLATION = 1\n if (filter.endsWith('bspline')) {\n defines.BSPLINE_FILTER = 1\n } else if (filter.endsWith('catmulrom')) {\n defines.CATMULROM_FILTER = 1\n } else if (filter.endsWith('mitchell')) {\n defines.MITCHELL_FILTER = 1\n }\n }\n\n return defines\n }\n\n updateTexture () {\n const tex = this.tex\n const filter = this.parameters.filter\n\n if (filter.startsWith('cubic')) {\n tex.minFilter = NearestFilter\n tex.magFilter = NearestFilter\n } else if (filter === 'linear') {\n tex.minFilter = LinearFilter\n tex.magFilter = LinearFilter\n } else { // filter === \"nearest\"\n tex.minFilter = NearestFilter\n tex.magFilter = NearestFilter\n }\n\n tex.needsUpdate = true\n this.pickingTex.needsUpdate = true\n }\n\n makeMaterial () {\n super.makeMaterial()\n this.updateTexture()\n\n const m = this.material\n m.uniforms.map.value = this.tex\n m.blending = NormalBlending\n m.needsUpdate = true\n\n const wm = this.wireframeMaterial\n wm.uniforms.map.value = this.tex\n wm.blending = NormalBlending\n wm.needsUpdate = true\n\n const pm = this.pickingMaterial\n pm.uniforms.map.value = this.tex\n pm.uniforms.pickingMap.value = this.pickingTex\n pm.blending = NormalBlending\n pm.needsUpdate = true\n }\n\n setUniforms (data: any) { // TODO\n if (data && data.filter !== undefined) {\n this.updateTexture()\n data.map = this.tex\n }\n\n super.setUniforms(data)\n }\n}\n\nexport default ImageBuffer\n","/**\n * @file Volume Slice\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { SlicePicker } from '../utils/picker'\nimport { Volume } from '../ngl';\nimport { SliceRepresentationParameters } from '../representation/slice-representation';\n\nclass VolumeSlice {\n dimension: 'x'|'y'|'z'\n positionType: 'percent'|'coordinate'\n position: number\n thresholdType: 'sigma'|'value'\n thresholdMin: number\n thresholdMax: number\n normalize: boolean\n volume: Volume\n\n constructor (volume: Volume, params: Partial) {\n const p = params || {}\n\n this.dimension = defaults(p.dimension, 'x')\n this.positionType = defaults(p.positionType, 'percent')\n this.position = defaults(p.position, 30)\n this.thresholdType = defaults(p.thresholdType, 'sigma')\n this.thresholdMin = defaults(p.thresholdMin, -Infinity)\n this.thresholdMax = defaults(p.thresholdMax, Infinity)\n this.normalize = defaults(p.normalize, false)\n\n this.volume = volume\n }\n\n getPositionFromCoordinate (coord: number) {\n const dim = this.dimension\n const v = this.volume\n const m = v.matrix\n\n const mp = new Vector3().setFromMatrixPosition(m)[ dim ]\n const ms = new Vector3().setFromMatrixScale(m)[ dim ]\n\n let vn\n if (dim === 'x') {\n vn = v.nx\n } else if (dim === 'y') {\n vn = v.ny\n } else {\n vn = v.nz\n }\n\n return Math.round((((coord - mp) / (vn / 100)) + 1) / ms)\n }\n\n getData (params: any) {\n params = params || {}\n\n const v = this.volume\n const d = v.data\n const m = v.matrix\n\n let p: number\n if (this.positionType === 'coordinate') {\n p = this.getPositionFromCoordinate(this.position)\n } else {\n p = this.position\n }\n\n function pos (dimLen: number) {\n return Math.round((dimLen / 100) * (p - 1))\n }\n\n function index (x: number, y: number, z: number, i: number) {\n return (z * v.ny * v.nx + y * v.nx + x) * 3 + i\n }\n\n const position = new Float32Array(4 * 3)\n const vec = new Vector3()\n\n let width, height\n let x\n let y\n let z\n let x0 = 0\n let y0 = 0\n let z0 = 0\n let nx = v.nx\n let ny = v.ny\n let nz = v.nz\n\n function setVec (x: number, y: number, z: number, offset: number) {\n vec.set(x, y, z).applyMatrix4(m).toArray(position as any, offset)\n }\n\n if (this.dimension === 'x') {\n x = pos(v.nx)\n y = v.ny - 1\n z = v.nz - 1\n\n width = v.nz\n height = v.ny\n\n x0 = x\n nx = x0 + 1\n\n setVec(x, 0, 0, 0)\n setVec(x, y, 0, 3)\n setVec(x, 0, z, 6)\n setVec(x, y, z, 9)\n } else if (this.dimension === 'y') {\n x = v.nx - 1\n y = pos(v.ny)\n z = v.nz - 1\n\n width = v.nz\n height = v.nx\n\n y0 = y\n ny = y0 + 1\n\n setVec(0, y, 0, 0)\n setVec(x, y, 0, 3)\n setVec(0, y, z, 6)\n setVec(x, y, z, 9)\n } else if (this.dimension === 'z') {\n x = v.nx - 1\n y = v.ny - 1\n z = pos(v.nz)\n\n width = v.nx\n height = v.ny\n\n z0 = z\n nz = z0 + 1\n\n setVec(0, 0, z, 0)\n setVec(0, y, z, 3)\n setVec(x, 0, z, 6)\n setVec(x, y, z, 9)\n }\n\n let i = 0\n let j = 0\n const imageData = new Uint8Array(width * height * 4)\n const pickingArray = new Float32Array(width * height)\n\n let tMin, tMax\n if (this.thresholdType === 'sigma') {\n tMin = v.getValueForSigma(this.thresholdMin)\n tMax = v.getValueForSigma(this.thresholdMax)\n } else {\n tMin = this.thresholdMin\n tMax = this.thresholdMax\n }\n\n const cp = Object.assign({}, params.colorParams, { volume: v })\n if (this.normalize) {\n cp.domain = [ 0, 1 ]\n }\n const colormaker = ColormakerRegistry.getScheme(cp)\n const tmp = new Float32Array(3)\n const scale = colormaker.getScale()\n\n let min = 0, max, diff = 0\n if (this.normalize) {\n min = +Infinity\n max = -Infinity\n for (let iy = y0; iy < ny; ++iy) {\n for (let ix = x0; ix < nx; ++ix) {\n for (let iz = z0; iz < nz; ++iz) {\n const idx = index(ix, iy, iz, 0) / 3\n const val = d[ idx ]\n if (val < min) min = val\n if (val > max) max = val\n }\n }\n }\n diff = max - min\n }\n\n for (let iy = y0; iy < ny; ++iy) {\n for (let ix = x0; ix < nx; ++ix) {\n for (let iz = z0; iz < nz; ++iz) {\n const idx = index(ix, iy, iz, 0) / 3\n let val = d[ idx ]\n if (this.normalize) {\n val = (val - min) / diff\n }\n\n colormaker.colorToArray(scale(val), tmp)\n imageData[ i ] = Math.round(tmp[ 0 ] * 255)\n imageData[ i + 1 ] = Math.round(tmp[ 1 ] * 255)\n imageData[ i + 2 ] = Math.round(tmp[ 2 ] * 255)\n imageData[ i + 3 ] = (val > tMin && val < tMax) ? 255 : 0\n\n pickingArray[ j ] = idx\n\n ++j\n i += 4\n }\n }\n }\n\n const picking = new SlicePicker(pickingArray, v)\n\n return { position, imageData, width, height, picking }\n }\n}\n\nexport default VolumeSlice\n","/**\n * @file Slice Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport Representation, { RepresentationParameters } from './representation'\nimport ImageBuffer, { ImageBufferParameters, ImageBufferData } from '../buffer/image-buffer'\nimport VolumeSlice from '../surface/volume-slice'\nimport Viewer from '../viewer/viewer';\nimport { Volume } from '../ngl';\n\n/**\n * Slice representation parameter object. Extends {@link RepresentationParameters}\n *\n * @typedef {Object} SliceRepresentationParameters - slice representation parameters\n *\n * @property {String} filter - filter applied to map the volume data on the slice, one of \"nearest\", \"linear\", \"cubic-bspline\", \"cubic-catmulrom\", \"cubic-mitchell\".\n * @property {String} positionType - Meaning of the position value. Either \"percent\" od \"coordinate\".\n * @property {Number} position - position of the slice.\n * @property {String} dimension - one of \"x\", \"y\" or \"z\"\n * @property {String} thresholdType - Meaning of the threshold values. Either *value* for the literal value or *sigma* as a factor of the sigma of the data. For volume data only.\n * @property {Number} thresholdMin - Minimum value to be displayed. For volume data only.\n * @property {Number} thresholdMax - Maximum value to be displayed. For volume data only.\n * @property {Boolean} normalize - Flag indicating wheather to normalize the data in a slice when coloring.\n */\nexport interface SliceRepresentationParameters extends RepresentationParameters {\n filter: 'nearest'|'linear'|'cubic-bspline'|'cubic-catmulrom'|'cubic-mitchell'\n positionType: 'percent'|'coordinate'\n position: number\n dimension: 'x'|'y'|'z'\n thresholdType: 'value'|'sigma'\n thresholdMin: number\n thresholdMax: number\n normalize: boolean\n}\n/**\n * Slice representation\n */\nclass SliceRepresentation extends Representation {\n protected filter: 'nearest'|'linear'|'cubic-bspline'|'cubic-catmulrom'|'cubic-mitchell'\n protected positionType: 'percent'|'coordinate'\n protected position: number\n protected dimension: 'x'|'y'|'z'\n protected thresholdType: 'value'|'sigma'\n protected thresholdMin: number\n protected thresholdMax: number\n protected normalize: boolean\n protected volume: Volume\n /**\n * Create Slice representation object\n * @param {Volume} surface - the volume to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {SliceRepresentationParameters} params - slice representation parameters\n */\n constructor (volume: Volume, viewer: Viewer, params: Partial) {\n super(volume, viewer, params)\n\n this.type = 'slice'\n\n this.parameters = Object.assign({\n\n filter: {\n type: 'select',\n buffer: true,\n options: {\n 'nearest': 'nearest',\n 'linear': 'linear',\n 'cubic-bspline': 'cubic-bspline',\n 'cubic-catmulrom': 'cubic-catmulrom',\n 'cubic-mitchell': 'cubic-mitchell'\n }\n },\n positionType: {\n type: 'select',\n rebuild: true,\n options: {\n 'percent': 'percent', 'coordinate': 'coordinate'\n }\n },\n position: {\n type: 'range',\n step: 0.1,\n max: 100,\n min: 1,\n rebuild: true\n },\n dimension: {\n type: 'select',\n rebuild: true,\n options: {\n 'x': 'x', 'y': 'y', 'z': 'z'\n }\n },\n thresholdType: {\n type: 'select',\n rebuild: true,\n options: {\n 'value': 'value', 'sigma': 'sigma'\n }\n },\n thresholdMin: {\n type: 'number', precision: 3, max: Infinity, min: -Infinity, rebuild: true\n },\n thresholdMax: {\n type: 'number', precision: 3, max: Infinity, min: -Infinity, rebuild: true\n },\n normalize: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n\n flatShaded: null,\n side: null,\n wireframe: null,\n linewidth: null,\n colorScheme: null,\n\n roughness: null,\n metalness: null,\n diffuse: null\n\n })\n\n this.volume = volume\n\n this.init(params)\n }\n\n init (params: Partial) {\n const v = this.volume\n const p = params || {}\n p.colorDomain = defaults(p.colorDomain, [ v.min, v.max ])\n p.colorScheme = defaults(p.colorScheme, 'value')\n p.colorScale = defaults(p.colorScale, 'Spectral')\n\n this.colorScheme = 'value'\n this.dimension = defaults(p.dimension, 'x')\n this.filter = defaults(p.filter, 'cubic-bspline')\n this.positionType = defaults(p.positionType, 'percent')\n this.position = defaults(p.position, 30)\n this.thresholdType = defaults(p.thresholdType, 'sigma')\n this.thresholdMin = defaults(p.thresholdMin, -Infinity)\n this.thresholdMax = defaults(p.thresholdMax, Infinity)\n this.normalize = defaults(p.normalize, false)\n\n super.init(p)\n\n this.build()\n }\n\n attach (callback: () => void) {\n this.bufferList.forEach(buffer => {\n this.viewer.add(buffer)\n })\n this.setVisibility(this.visible)\n\n callback()\n }\n\n create () {\n const volumeSlice = new VolumeSlice(this.volume, {\n positionType: this.positionType,\n position: this.position,\n dimension: this.dimension,\n thresholdType: this.thresholdType,\n thresholdMin: this.thresholdMin,\n thresholdMax: this.thresholdMax,\n normalize: this.normalize\n })\n\n const sliceBuffer = new ImageBuffer(\n volumeSlice.getData({ colorParams: this.getColorParams() }) as ImageBufferData,\n this.getBufferParams({\n filter: this.filter\n }) as ImageBufferParameters\n )\n\n this.bufferList.push(sliceBuffer)\n }\n}\n\nexport default SliceRepresentation\n","/**\n * @file Representation Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, RepresentationRegistry } from '../globals'\n\nimport Viewer from '../viewer/viewer'\nimport Structure from '../structure/structure'\nimport Surface from '../surface/surface'\nimport Volume from '../surface/volume'\nimport Shape from '../geometry/shape'\n\nimport BufferRepresentation from './buffer-representation'\nimport SurfaceRepresentation from './surface-representation'\nimport DotRepresentation from './dot-representation'\nimport SliceRepresentation from './slice-representation'\n\nfunction logReprUnknown (type: string) {\n Log.error(`makeRepresentation: representation type ${type} unknown`)\n}\n\nexport function makeRepresentation (type: string, object: any, viewer: Viewer, params: any) { // TODO\n if (Debug) Log.time('makeRepresentation ' + type)\n\n var ReprClass\n\n if (object instanceof Structure) {\n ReprClass = RepresentationRegistry.get(type)\n\n if (!ReprClass) {\n logReprUnknown(type)\n return\n }\n } else if (object instanceof Surface) {\n if (type === 'surface') {\n ReprClass = SurfaceRepresentation\n } else if (type === 'dot') {\n ReprClass = DotRepresentation\n } else {\n logReprUnknown(type)\n return\n }\n } else if (object instanceof Volume) {\n if (type === 'surface') {\n ReprClass = SurfaceRepresentation\n } else if (type === 'dot') {\n ReprClass = DotRepresentation\n } else if (type === 'slice') {\n ReprClass = SliceRepresentation\n } else {\n logReprUnknown(type)\n return\n }\n } else if (object instanceof Shape) {\n ReprClass = BufferRepresentation\n object = object.getBufferList()\n } else if (type === 'buffer') {\n ReprClass = BufferRepresentation\n } else {\n Log.error('makeRepresentation: object ' + object + ' unknown')\n return\n }\n\n const repr = new ReprClass(object, viewer, params)\n\n if (Debug) Log.timeEnd('makeRepresentation ' + type)\n\n return repr\n}\n","/**\n * @file Element\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { createParams } from '../utils'\nimport { generateUUID } from '../math/math-utils'\nimport Stage from '../stage/stage'\n\nexport const ElementDefaultParameters = {\n name: 'some element',\n status: ''\n}\nexport type ElementParameters = typeof ElementDefaultParameters\n\nexport interface ElementSignals {\n statusChanged: Signal // on status change\n nameChanged: Signal // on name change\n disposed: Signal // on dispose\n}\n\n/**\n * Element base class\n */\nabstract class Element {\n /**\n * Events emitted by the element\n */\n signals: ElementSignals = {\n statusChanged: new Signal(),\n nameChanged: new Signal(),\n disposed: new Signal()\n }\n readonly parameters: ElementParameters\n readonly uuid: string\n\n get defaultParameters() { return ElementDefaultParameters }\n\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {ElementParameters} params - component parameters\n */\n constructor (readonly stage: Stage, params: Partial = {}) {\n this.parameters = createParams(params, this.defaultParameters)\n this.uuid = generateUUID()\n }\n\n abstract get type (): string\n\n get name () { return this.parameters.name }\n\n setStatus (value: string) {\n this.parameters.status = value\n this.signals.statusChanged.dispatch(value)\n\n return this\n }\n\n setName (value: string) {\n this.parameters.name = value\n this.signals.nameChanged.dispatch(value)\n\n return this\n }\n\n dispose () {\n this.signals.disposed.dispatch()\n }\n}\n\nexport default Element\n","/**\n * @file Representation Element\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\nimport { Color } from 'three'\n\nimport Stage from '../stage/stage'\nimport Representation, { RepresentationParameters } from '../representation/representation'\nimport Component from './component'\nimport Element, { ElementDefaultParameters, ElementSignals } from './element'\n\nexport const RepresentationElementDefaultParameters = Object.assign({\n visible: true\n}, ElementDefaultParameters)\nexport type RepresentationElementParameters = typeof RepresentationElementDefaultParameters\n\nexport interface RepresentationElementSignals extends ElementSignals {\n visibilityChanged: Signal // on visibility change\n parametersChanged: Signal // on parameters change\n}\n\n/**\n * Element wrapping a {@link Representation} object\n */\nclass RepresentationElement extends Element {\n signals: RepresentationElementSignals\n parameters: RepresentationElementParameters\n get defaultParameters() { return RepresentationElementDefaultParameters }\n\n repr: Representation\n\n /**\n * Create representation component\n * @param {Stage} stage - stage object the component belongs to\n * @param {Representation} repr - representation object to wrap\n * @param {RepresentationParameters} [params] - component parameters\n * @param {Component} [parent] - parent component\n */\n constructor (stage: Stage, repr: Representation, params: Partial = {}, readonly parent: Component) {\n super(stage, Object.assign({ name: repr.type }, params))\n\n this.signals = Object.assign({\n visibilityChanged: new Signal(),\n parametersChanged: new Signal()\n }, this.signals)\n\n this.setRepresentation(repr)\n }\n\n get visible () { return this.parameters.visible }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'representation' }\n\n getType () {\n return this.repr.type\n }\n\n setRepresentation (repr: Representation) {\n this._disposeRepresentation()\n this.repr = repr\n // this.name = repr.type;\n this.stage.tasks.listen(this.repr.tasks)\n this.updateVisibility()\n }\n\n _disposeRepresentation () {\n if (this.repr) {\n this.stage.tasks.unlisten(this.repr.tasks)\n this.repr.dispose()\n }\n }\n\n dispose () {\n if (this.parent && this.parent.hasRepresentation(this)) {\n this.parent.removeRepresentation(this)\n } else {\n this._disposeRepresentation()\n this.signals.disposed.dispatch()\n }\n }\n\n /**\n * Set the visibility of the component, takes parent visibility into account\n * @param {Boolean} value - visibility flag\n * @return {RepresentationElement} this object\n */\n setVisibility (value: boolean) {\n this.parameters.visible = value\n this.updateVisibility()\n this.signals.visibilityChanged.dispatch(this.parameters.visible)\n\n return this\n }\n\n getVisibility () {\n if (this.parent) {\n return this.parent.parameters.visible && this.parameters.visible\n } else {\n return this.parameters.visible\n }\n }\n\n /**\n * Toggle visibility of the component, takes parent visibility into account\n * @return {RepresentationElement} this object\n */\n toggleVisibility () {\n return this.setVisibility(!this.parameters.visible)\n }\n\n updateVisibility () {\n this.repr.setVisibility(this.getVisibility())\n }\n\n /**\n * Set selection\n * @param {Object} what - flags indicating what attributes to update\n * @param {Boolean} what.position - update position attribute\n * @param {Boolean} what.color - update color attribute\n * @param {Boolean} what.radius - update radius attribute\n * @return {RepresentationElement} this object\n */\n update (what: any) { // TODO\n (this.repr as any).update(what) // TODO\n\n return this\n }\n\n build (params?: any) { // TODO\n this.repr.build(params)\n\n return this\n }\n\n /**\n * Set selection\n * @param {String} string - selection string\n * @return {RepresentationElement} this object\n */\n setSelection (string: string) {\n const repr: any = this.repr // TODO\n\n if (repr.setSelection) {\n repr.setSelection(string)\n }\n\n return this\n }\n\n /**\n * Set representation parameters\n * @param {RepresentationParameters} params - parameter object\n * @return {RepresentationElement} this object\n */\n setParameters (params: any) { // TODO\n this.repr.setParameters(params)\n this.signals.parametersChanged.dispatch(\n this.repr.getParameters()\n )\n\n return this\n }\n\n /**\n * Get representation parameters\n * @return {RepresentationParameters} parameter object\n */\n getParameters (): Partial {\n return this.repr.getParameters()\n }\n\n /**\n * Set color\n * @param {String|Color|Hex} value - color value\n * @return {RepresentationElement} this object\n */\n setColor (value: string|number|Color) {\n this.repr.setColor(value)\n\n return this\n }\n}\n\nexport default RepresentationElement\n","\n/**\n * @file Component\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Quaternion, Matrix4, Euler, Box3 } from 'three'\nimport { Signal } from 'signals'\n\nimport { defaults, createParams } from '../utils'\nimport { generateUUID } from '../math/math-utils'\nimport Annotation, { AnnotationParams } from '../component/annotation'\nimport ComponentControls from '../controls/component-controls'\nimport { makeRepresentation } from '../representation/representation-utils'\nimport RepresentationElement from './representation-element'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\n\nconst _m = new Matrix4()\nconst _v = new Vector3()\n\nexport const ComponentDefaultParameters = {\n name: '',\n status: '',\n visible: true\n}\nexport type ComponentParameters = typeof ComponentDefaultParameters\n\n\nexport interface ComponentSignals {\n representationAdded: Signal // when a representation is added\n representationRemoved: Signal // when a representation is removed\n visibilityChanged: Signal // on visibility change\n matrixChanged: Signal // on matrix change\n statusChanged: Signal // on status change\n nameChanged: Signal // on name change\n disposed: Signal // on dispose\n}\n\n/**\n * Base class for components\n */\nabstract class Component {\n /**\n * Events emitted by the component\n */\n readonly signals: ComponentSignals = {\n representationAdded: new Signal(),\n representationRemoved: new Signal(),\n visibilityChanged: new Signal(),\n matrixChanged: new Signal(),\n statusChanged: new Signal(),\n nameChanged: new Signal(),\n disposed: new Signal()\n }\n\n readonly parameters: ComponentParameters\n get defaultParameters () { return ComponentDefaultParameters }\n\n readonly uuid: string\n readonly viewer: Viewer\n\n reprList: RepresentationElement[] = []\n annotationList: Annotation[] = []\n\n matrix = new Matrix4()\n position = new Vector3()\n quaternion = new Quaternion()\n scale = new Vector3(1, 1, 1)\n transform = new Matrix4()\n\n controls: ComponentControls\n\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {ComponentParameters} params - parameter object\n */\n constructor (readonly stage: Stage, readonly object: any, params: Partial = {}) {\n this.parameters = createParams(params, this.defaultParameters)\n this.uuid = generateUUID()\n this.viewer = stage.viewer\n\n this.controls = new ComponentControls(this)\n }\n\n abstract get type (): string\n\n get name () { return this.parameters.name }\n get status () { return this.parameters.status }\n get visible () { return this.parameters.visible }\n\n /**\n * Set position transform\n *\n * @example\n * // translate by 25 angstrom along x axis\n * component.setPosition([ 25, 0, 0 ]);\n *\n * @param {Vector3|Array} p - the coordinates\n * @return {Component} this object\n */\n setPosition (p: [number, number, number]|Vector3) {\n if (Array.isArray(p)) {\n this.position.fromArray(p)\n } else {\n this.position.copy(p)\n }\n this.updateMatrix()\n\n return this\n }\n\n /**\n * Set local rotation transform\n * (for global rotation use setTransform)\n *\n * @example\n * // rotate by 2 degree radians on x axis\n * component.setRotation( [ 2, 0, 0 ] );\n *\n * @param {Quaternion|Euler|Array} r - the rotation\n * @return {Component} this object\n */\n setRotation (r: [number, number, number]|Euler|Quaternion) {\n if (Array.isArray(r)) {\n if (r.length === 3) {\n const e = new Euler().fromArray(r)\n this.quaternion.setFromEuler(e)\n } else {\n this.quaternion.fromArray(r)\n }\n } else if (r instanceof Euler) {\n this.quaternion.setFromEuler(r)\n } else {\n this.quaternion.copy(r)\n }\n this.updateMatrix()\n\n return this\n }\n\n /**\n * Set scale transform\n *\n * @example\n * // scale by factor of two\n * component.setScale( 2 );\n *\n * @param {Number} s - the scale\n * @return {Component} this object\n */\n setScale (s: number) {\n this.scale.set(s, s, s)\n this.updateMatrix()\n\n return this\n }\n\n /**\n * Set general transform. Is applied before and in addition\n * to the position, rotation and scale transformations\n *\n * @example\n * component.setTransform( matrix );\n *\n * @param {Matrix4} m - the matrix\n * @return {Component} this object\n */\n setTransform (m: Matrix4) {\n this.transform.copy(m)\n this.updateMatrix()\n\n return this\n }\n\n updateMatrix () {\n const c = this.getCenterUntransformed(_v)\n this.matrix.makeTranslation(-c.x, -c.y, -c.z)\n\n _m.makeRotationFromQuaternion(this.quaternion)\n this.matrix.premultiply(_m)\n\n _m.makeScale(this.scale.x, this.scale.y, this.scale.z)\n this.matrix.premultiply(_m)\n\n const p = this.position\n _m.makeTranslation(p.x + c.x, p.y + c.y, p.z + c.z)\n this.matrix.premultiply(_m)\n\n this.matrix.premultiply(this.transform)\n\n this.updateRepresentationMatrices()\n\n this.stage.viewer.updateBoundingBox()\n\n this.signals.matrixChanged.dispatch(this.matrix)\n }\n\n /**\n * Propogates our matrix to each representation\n */\n updateRepresentationMatrices () {\n this.reprList.forEach(repr => {\n repr.setParameters({ matrix: this.matrix })\n })\n }\n\n /**\n * Add an anotation object\n * @param {Vector3} position - the 3d position\n * @param {String|Element} content - the HTML content\n * @param {Object} [params] - parameters\n * @param {Integer} params.offsetX - 2d offset in x direction\n * @param {Integer} params.offsetY - 2d offset in y direction\n * @return {Annotation} the added annotation object\n */\n addAnnotation (position: Vector3, content: string|HTMLElement, params: AnnotationParams) {\n const annotation = new Annotation(this, position, content, params)\n this.annotationList.push(annotation)\n\n return annotation\n }\n\n /**\n * Iterator over each annotation and executing the callback\n * @param {Function} callback - function to execute\n * @return {undefined}\n */\n eachAnnotation (callback: (a: Annotation) => void) {\n this.annotationList.slice().forEach(callback)\n }\n\n /**\n * Remove the give annotation from the component\n * @param {Annotation} annotation - the annotation to remove\n * @return {undefined}\n */\n removeAnnotation (annotation: Annotation) {\n const idx = this.annotationList.indexOf(annotation)\n if (idx !== -1) {\n this.annotationList.splice(idx, 1)\n annotation.dispose()\n }\n }\n\n /**\n * Remove all annotations from the component\n * @return {undefined}\n */\n removeAllAnnotations () {\n this.eachAnnotation(annotation => annotation.dispose())\n this.annotationList.length = 0\n }\n\n /**\n * Add a new representation to the component\n * @param {String} type - the name of the representation\n * @param {Object} object - the object on which the representation should be based\n * @param {RepresentationParameters} [params] - representation parameters\n * @return {RepresentationElement} the created representation wrapped into\n * a representation element object\n */\n protected _addRepresentation (type: string, object: any, params: any, hidden = false) { // TODO\n const p = params || {}\n const sp = this.stage.getParameters() as any // TODO\n p.matrix = this.matrix.clone()\n p.quality = p.quality || sp.quality\n p.disableImpostor = defaults(p.disableImpostor, !sp.impostor)\n p.useWorker = defaults(p.useWorker, sp.workerDefault)\n p.visible = defaults(p.visible, true)\n\n const p2 = Object.assign({}, p, { visible: this.parameters.visible && p.visible })\n const repr = makeRepresentation(type, object, this.viewer, p2)\n const reprElem = new RepresentationElement(this.stage, repr, p, this)\n\n if (!hidden) {\n this.reprList.push(reprElem)\n this.signals.representationAdded.dispatch(reprElem)\n }\n return reprElem\n }\n\n abstract addRepresentation (type: any, params: any): any\n\n addBufferRepresentation (buffer: any, params: any) { // TODO\n return this._addRepresentation.call(this, 'buffer', buffer, params)\n }\n\n hasRepresentation (repr: RepresentationElement) {\n return this.reprList.indexOf(repr) !== -1\n }\n\n /**\n * Iterator over each representation and executing the callback\n * @param {Function} callback - function to execute\n * @return {undefined}\n */\n eachRepresentation (callback: (repr: RepresentationElement) => void) {\n this.reprList.slice().forEach(callback)\n }\n\n /**\n * Removes a representation component\n * @param {RepresentationElement} repr - the representation element\n * @return {undefined}\n */\n removeRepresentation (repr: RepresentationElement) {\n const idx = this.reprList.indexOf(repr)\n if (idx !== -1) {\n this.reprList.splice(idx, 1)\n repr.dispose()\n this.signals.representationRemoved.dispatch(repr)\n }\n }\n\n updateRepresentations (what: any) { // TODO\n this.reprList.forEach(repr => repr.update(what))\n this.stage.viewer.requestRender()\n }\n\n /**\n * Removes all representation components\n * @return {undefined}\n */\n removeAllRepresentations () {\n this.eachRepresentation(repr => repr.dispose())\n }\n\n dispose () {\n this.removeAllAnnotations()\n this.removeAllRepresentations()\n\n this.reprList.length = 0\n\n this.signals.disposed.dispatch()\n }\n\n /**\n * Set the visibility of the component, including added representations\n * @param {Boolean} value - visibility flag\n * @return {Component} this object\n */\n setVisibility (value: boolean) {\n this.parameters.visible = value\n\n this.eachRepresentation((repr: RepresentationElement) => repr.updateVisibility())\n this.eachAnnotation((annotation: Annotation) => annotation.updateVisibility())\n\n this.signals.visibilityChanged.dispatch(value)\n\n return this\n }\n\n setStatus (value: string) {\n this.parameters.status = value\n this.signals.statusChanged.dispatch(value)\n\n return this\n }\n\n setName (value: string) {\n this.parameters.name = value\n this.signals.nameChanged.dispatch(value)\n\n return this\n }\n\n /**\n * @return {Box3} the component's bounding box\n */\n getBox (...args: any[]) {\n return this.getBoxUntransformed(...args)\n .clone().applyMatrix4(this.matrix)\n }\n\n /**\n * @return {Vector3} the component's center position\n */\n getCenter (...args: any[]) {\n return this.getCenterUntransformed(...args)\n .clone().applyMatrix4(this.matrix)\n }\n\n getZoom (...args: any[]) {\n return this.stage.getZoomForBox(this.getBox(...args))\n }\n\n /**\n * @abstract\n * @return {Box3} the untransformed component's bounding box\n */\n getBoxUntransformed (...args: any[]): Box3 {\n return new Box3()\n }\n\n getCenterUntransformed (...args: any[]) {\n return this.getBoxUntransformed().getCenter(new Vector3())\n }\n\n /**\n * Automatically center and zoom the component\n * @param {Integer} [duration] - duration of the animation, defaults to 0\n * @return {undefined}\n */\n autoView (duration?: number) {\n this.stage.animationControls.zoomMove(\n this.getCenter(),\n this.getZoom(),\n defaults(duration, 0)\n )\n }\n}\n\nexport default Component\n","/**\n * @file Collection\n * @author Alexander Rose \n * @private\n */\n\nimport Component from './component'\nimport Element from './element'\n\nclass Collection {\n constructor (readonly list: T[] = []) {\n // remove elements from list when they get disposed\n const n = list.length\n\n for (let i = 0; i < n; ++i) {\n const elm = list[ i ]\n elm.signals.disposed.add(this._remove, this)\n }\n }\n\n _remove (elm: T) {\n const idx = this.list.indexOf(elm)\n\n if (idx !== -1) {\n this.list.splice(idx, 1)\n }\n }\n\n get first () {\n return this.list.length > 0 ? this.list[0] : undefined\n }\n\n forEach (fn: (x: T) => any) {\n this.list.forEach(fn)\n\n return this\n }\n\n dispose () {\n return this.forEach((elm) => elm.dispose())\n }\n}\n\nexport default Collection\n","/**\n * @file Component Collection\n * @author Alexander Rose \n * @private\n */\n\nimport RepresentationElement from './representation-element'\nimport Collection from './collection'\nimport { GenericColor } from '../types'\n\nclass RepresentationCollection extends Collection {\n setParameters (params: any) {\n return this.forEach((repr) => repr.setParameters(params))\n }\n\n setVisibility (value: boolean) {\n return this.forEach((repr) => repr.setVisibility(value))\n }\n\n setSelection (string: string) {\n return this.forEach((repr) => repr.setSelection(string))\n }\n\n setColor (color: GenericColor) {\n return this.forEach((repr) => repr.setColor(color))\n }\n\n update (what: any) {\n return this.forEach((repr) => repr.update(what))\n }\n\n build (params?: any) {\n return this.forEach((repr) => repr.build(params))\n }\n\n dispose (params?: any) {\n return this.forEach((repr) => repr.dispose())\n }\n}\n\nexport default RepresentationCollection\n","/**\n * @file Trajectory Component\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport Element, { ElementSignals, ElementDefaultParameters } from './element'\nimport Stage from '../stage/stage'\nimport Trajectory, { TrajectoryParameters } from '../trajectory/trajectory'\nimport TrajectoryPlayer, {\n TrajectoryPlayerDirection, TrajectoryPlayerMode, TrajectoryPlayerInterpolateType\n} from '../trajectory/trajectory-player'\n\n/**\n * Trajectory component parameter object.\n * @typedef {Object} TrajectoryComponentParameters - component parameters\n *\n * @property {String} name - component name\n * @property {Integer} initialFrame - initial frame the trajectory is set to\n * @property {Integer} defaultStep - default step size to be used by trajectory players\n * @property {Integer} defaultTimeout - default timeout to be used by trajectory players\n * @property {String} defaultInterpolateType - one of \"\" (empty string), \"linear\" or \"spline\"\n * @property {Integer} defaultInterpolateStep - window size used for interpolation\n * @property {String} defaultMode - either \"loop\" or \"once\"\n * @property {String} defaultDirection - either \"forward\" or \"backward\"\n */\n\nexport const TrajectoryElementDefaultParameters = Object.assign({\n defaultStep: 1,\n defaultTimeout: 50,\n defaultInterpolateType: '' as TrajectoryPlayerInterpolateType,\n defaultInterpolateStep: 5,\n defaultMode: 'loop' as TrajectoryPlayerMode,\n defaultDirection: 'forward' as TrajectoryPlayerDirection,\n initialFrame: 0\n}, ElementDefaultParameters)\nexport type TrajectoryElementParameters = typeof TrajectoryElementDefaultParameters\n\nexport interface TrajectoryElementSignals extends ElementSignals {\n frameChanged: Signal // on frame change\n playerChanged: Signal // on player change\n countChanged: Signal // when frame count is available\n parametersChanged: Signal // on parameters change\n}\n\n/**\n * Component wrapping a {@link Trajectory} object\n */\nclass TrajectoryElement extends Element {\n signals: TrajectoryElementSignals\n parameters: TrajectoryElementParameters\n get defaultParameters () { return TrajectoryElementDefaultParameters }\n\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {Trajectory} trajectory - the trajectory object\n * @param {TrajectoryComponentParameters} params - component parameters\n * @param {StructureComponent} parent - the parent structure\n */\n constructor (stage: Stage, readonly trajectory: Trajectory, params: Partial = {}) {\n super(stage, Object.assign({ name: trajectory.name }, params))\n\n this.signals = Object.assign(this.signals, {\n frameChanged: new Signal(),\n playerChanged: new Signal(),\n countChanged: new Signal(),\n parametersChanged: new Signal()\n })\n\n // signals\n\n trajectory.signals.frameChanged.add((i: number) => {\n this.signals.frameChanged.dispatch(i)\n })\n\n trajectory.signals.playerChanged.add((player: TrajectoryPlayer) => {\n this.signals.playerChanged.dispatch(player)\n })\n\n trajectory.signals.countChanged.add((n: number) => {\n this.signals.countChanged.dispatch(n)\n })\n\n //\n\n if (params.initialFrame !== undefined) {\n this.setFrame(params.initialFrame)\n }\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'trajectory' }\n\n /**\n * Set the frame of the trajectory\n * @param {Integer} i - frame number\n * @return {undefined}\n */\n setFrame (i: number) {\n this.trajectory.setFrame(i)\n }\n\n /**\n * Set trajectory parameters\n * @param {TrajectoryParameters} params - trajectory parameters\n * @return {undefined}\n */\n setParameters (params: Partial = {}) {\n this.trajectory.setParameters(params)\n this.signals.parametersChanged.dispatch(params)\n }\n\n dispose () {\n this.trajectory.dispose()\n super.dispose()\n }\n}\n\nexport default TrajectoryElement\n","/**\n * @file Frames\n * @author Alexander Rose \n * @private\n */\n\nexport default class Frames {\n coordinates = []\n boxes = []\n times = []\n\n timeOffset = 0\n deltaTime = 1\n\n constructor (readonly name: string, readonly path: string) {}\n\n get type () { return 'Frames' }\n}\n","/**\n * @file Superposition\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\nimport { Debug, Log } from '../globals'\nimport {\n Matrix, svd, meanRows, subRows, transpose,\n multiplyABt, invert3x3, multiply3x3, mat3x3determinant, multiply\n} from '../math/matrix-utils'\nimport Structure from '../structure/structure'\n\nclass Superposition {\n coords1t: Matrix\n coords2t: Matrix\n\n transformationMatrix: Matrix4\n\n mean1: number[]\n mean2: number[]\n\n A = new Matrix(3, 3)\n W = new Matrix(1, 3)\n U = new Matrix(3, 3)\n V = new Matrix(3, 3)\n VH = new Matrix(3, 3)\n R = new Matrix(3, 3)\n\n private tmp = new Matrix(3, 3)\n private c = new Matrix(3, 3)\n\n constructor (atoms1: Structure|Float32Array, atoms2: Structure|Float32Array) {\n // allocate & init data structures\n\n let n1\n if (atoms1 instanceof Structure) {\n n1 = atoms1.atomCount\n } else if (atoms1 instanceof Float32Array) {\n n1 = atoms1.length / 3\n } else {\n return\n }\n\n let n2\n if (atoms2 instanceof Structure) {\n n2 = atoms2.atomCount\n } else if (atoms2 instanceof Float32Array) {\n n2 = atoms2.length / 3\n } else {\n return\n }\n\n const n = Math.min(n1, n2)\n\n const coords1 = new Matrix(3, n)\n const coords2 = new Matrix(3, n)\n\n this.coords1t = new Matrix(n, 3)\n this.coords2t = new Matrix(n, 3)\n\n this.transformationMatrix = new Matrix4()\n\n this.c.data.set([ 1, 0, 0, 0, 1, 0, 0, 0, -1 ])\n\n // prep coords\n\n this.prepCoords(atoms1, coords1, n, false)\n this.prepCoords(atoms2, coords2, n, false)\n\n // superpose\n\n this._superpose(coords1, coords2)\n }\n\n _superpose (coords1: Matrix, coords2: Matrix) {\n this.mean1 = meanRows(coords1)\n this.mean2 = meanRows(coords2)\n\n subRows(coords1, this.mean1)\n subRows(coords2, this.mean2)\n\n transpose(this.coords1t, coords1)\n transpose(this.coords2t, coords2)\n\n multiplyABt(this.A, this.coords2t, this.coords1t)\n\n svd(this.A, this.W, this.U, this.V)\n\n invert3x3(this.V, this.VH)\n multiply3x3(this.R, this.U, this.VH)\n\n if (mat3x3determinant(this.R) < 0.0) {\n if (Debug) Log.log('R not a right handed system')\n\n multiply3x3(this.tmp, this.c, this.VH)\n multiply3x3(this.R, this.U, this.tmp)\n }\n\n //get the transformation matrix\n\n const transformMat_ = new Matrix(4,4)\n const tmp_1 = new Matrix(4,4)\n const tmp_2 = new Matrix(4,4)\n\n const sub = new Matrix(4,4)\n const mult = new Matrix(4,4)\n const add = new Matrix(4,4)\n\n const R = this.R.data\n const M1 = this.mean1\n const M2 = this.mean2\n\n sub.data.set([ 1, 0, 0, -M1[0],\n 0, 1, 0, -M1[1],\n 0, 0, 1, -M1[2],\n 0, 0, 0, 1 ])\n\n mult.data.set([ R[0], R[1], R[2], 0,\n R[3], R[4], R[5], 0,\n R[6], R[7], R[8], 0,\n 0, 0, 0, 1 ])\n\n add.data.set([ 1, 0, 0, M2[0],\n 0, 1, 0, M2[1],\n 0, 0, 1, M2[2],\n 0, 0, 0, 1 ])\n\n transpose(tmp_1,sub)\n multiplyABt(transformMat_,mult,tmp_1)\n transpose(tmp_2,transformMat_)\n multiplyABt(tmp_1,add,tmp_2)\n\n transpose(transformMat_,tmp_1)\n this.transformationMatrix.elements = transformMat_.data as unknown as number[]\n\n }\n\n prepCoords (atoms: Structure|Float32Array, coords: Matrix, n: number, is4X4: boolean) {\n let i = 0\n const cd = coords.data\n\n let c = 3\n let d = n * 3\n\n if (is4X4) {\n d = n * 4\n c = 4\n }\n if (atoms instanceof Structure) {\n atoms.eachAtom(function (a) {\n if (i < d) {\n cd[ i + 0 ] = a.x\n cd[ i + 1 ] = a.y\n cd[ i + 2 ] = a.z\n if (is4X4) cd[ i + 3 ] = 1\n\n i += c\n }\n })\n } else if (atoms instanceof Float32Array) {\n for (; i < d; i += c){\n if (i < d) {\n cd[ i ] = atoms[ i ]\n cd[ i + 1 ] = atoms[ i + 1 ]\n cd[ i + 2 ] = atoms[ i + 2 ]\n if (is4X4) cd[ i + 3 ] = 1\n }\n }\n } else {\n Log.warn('prepCoords: input type unknown')\n }\n }\n\n transform (atoms: Structure|Float32Array) {\n // allocate data structures\n\n let n\n if (atoms instanceof Structure) {\n n = atoms.atomCount\n } else if (atoms instanceof Float32Array) {\n n = atoms.length / 3\n } else {\n return\n }\n\n const coords = new Matrix(4, n)\n const tCoords = new Matrix(n,4)\n\n // prep coords\n\n this.prepCoords(atoms, coords, n, true)\n\n // check for transformation matrix correctness\n\n const transform = this.transformationMatrix\n const det = transform.determinant()\n if (!det){\n return det\n }\n\n // do transform\n\n const mult = new Matrix(4,4)\n mult.data = transform.elements as unknown as Float32Array\n multiply(tCoords,coords,mult)\n\n let i = 0\n const cd = tCoords.data\n if (atoms instanceof Structure) {\n atoms.eachAtom(function (a) {\n a.x = cd[ i ]\n a.y = cd[ i + 1 ]\n a.z = cd[ i + 2 ]\n i += 4\n })\n\n //update transformation matrices for each assembly\n\n const invertTrasform = new Matrix4()\n invertTrasform.getInverse(transform)\n\n const biomolDict = atoms.biomolDict\n\n for (let key in biomolDict) {\n\n if (biomolDict.hasOwnProperty(key)) {\n let assembly = biomolDict[key]\n\n assembly.partList.forEach(function(part){\n\n part.matrixList.forEach(function(mat){\n\n mat.premultiply(transform)\n mat.multiply(invertTrasform)\n\n })\n })\n }\n }\n } else if (atoms instanceof Float32Array) {\n\n const n4 = n * 4\n for (; i < n4; i += 4){\n\n atoms[ i ] = cd[ i ]\n atoms[ i + 1 ] = cd[ i + 1 ]\n atoms[ i + 2 ] = cd[ i + 2 ]\n\n }\n } else {\n Log.warn('transform: input type unknown')\n }\n\n return this.transformationMatrix\n }\n}\nexport default Superposition\n","/**\n * @file Trajectory Player\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { defaults, createParams, updateParams } from '../utils'\nimport Trajectory from './trajectory'\n\nexport type TrajectoryPlayerInterpolateType = ''|'linear'|'spline'\nexport type TrajectoryPlayerMode = 'loop'|'once'\nexport type TrajectoryPlayerDirection = 'forward'|'backward'|'bounce'\n\nexport const TrajectoryPlayerDefaultParameters = {\n step: 1, // how many frames to advance when playing\n timeout: 50, // how many milliseconds to wait between playing frames\n start: 0, // first frame to play\n end: 0, // last frame to play\n interpolateType: '' as TrajectoryPlayerInterpolateType,\n interpolateStep: 5, // window size used for interpolation\n mode: 'loop' as TrajectoryPlayerMode,\n direction: 'forward' as TrajectoryPlayerDirection\n}\nexport type TrajectoryPlayerParameters = typeof TrajectoryPlayerDefaultParameters\n\nexport interface TrajectoryPlayerSignals {\n startedRunning: Signal\n haltedRunning: Signal\n}\n\n/**\n * Trajectory player for animating coordinate frames\n * @example\n * var player = new TrajectoryPlayer(trajectory, {step: 1, timeout: 50});\n * player.play();\n */\nclass TrajectoryPlayer {\n signals: TrajectoryPlayerSignals = {\n startedRunning: new Signal(),\n haltedRunning: new Signal()\n }\n\n parameters: TrajectoryPlayerParameters\n traj: Trajectory\n\n private _run = false\n private _previousTime = 0\n private _currentTime = 0\n private _currentStep = 1\n private _currentFrame: number|[number, number, number, number]\n private _direction: TrajectoryPlayerDirection\n\n /**\n * make trajectory player\n * @param {Trajectory} traj - the trajectory\n * @param {TrajectoryPlayerParameters} [params] - parameter object\n */\n constructor (traj: Trajectory, params: Partial = {}) {\n traj.signals.playerChanged.add((player: TrajectoryPlayer) => {\n if (player !== this) {\n this.pause()\n }\n }, this)\n\n const n = defaults(traj.frameCount, 1)\n\n this.traj = traj\n this.parameters = createParams(params, TrajectoryPlayerDefaultParameters)\n this.parameters.end = Math.min(defaults(params.end, n - 1), n - 1)\n this.parameters.step = defaults(params.step, Math.ceil((n + 1) / 100))\n\n this._currentFrame = this.parameters.start\n this._direction = this.parameters.direction === 'bounce' ? 'forward' : this.parameters.direction\n\n traj.signals.countChanged.add((n: number) => {\n this.parameters.end = Math.min(defaults(this.parameters.end, n - 1), n - 1)\n }, this)\n\n this._animate = this._animate.bind(this)\n }\n\n get isRunning () { return this._run }\n\n /**\n * set player parameters\n * @param {TrajectoryPlayerParameters} [params] - parameter object\n */\n setParameters (params: Partial = {}) {\n updateParams(this.parameters, params)\n\n if (params.direction !== undefined && this.parameters.direction !== 'bounce') {\n this._direction = this.parameters.direction\n }\n }\n\n _animate () {\n if (!this._run) return\n\n this._currentTime = window.performance.now()\n const dt = this._currentTime - this._previousTime\n const step = this.parameters.interpolateType ? this.parameters.interpolateStep : 1\n const timeout = this.parameters.timeout / step\n const traj = this.traj\n\n if (traj && traj.frameCount && !traj.inProgress && dt >= timeout) {\n if (this.parameters.interpolateType) {\n if (this._currentStep > this.parameters.interpolateStep) {\n this._currentStep = 1\n }\n if (this._currentStep === 1) {\n this._currentFrame = this._nextInterpolated()\n }\n if (traj.hasFrame(this._currentFrame)) {\n this._currentStep += 1\n const t = this._currentStep / (this.parameters.interpolateStep + 1)\n const [i, ip, ipp, ippp] = this._currentFrame as [number, number, number, number]\n traj.setFrameInterpolated(\n i, ip, ipp, ippp, t, this.parameters.interpolateType\n )\n this._previousTime = this._currentTime\n } else {\n traj.loadFrame(this._currentFrame)\n }\n } else {\n const i = this._next()\n if (traj.hasFrame(i)) {\n traj.setFrame(i)\n this._previousTime = this._currentTime\n } else {\n traj.loadFrame(i)\n }\n }\n }\n\n window.requestAnimationFrame(this._animate)\n }\n\n _next () {\n const p = this.parameters\n let i\n\n if (this._direction === 'forward') {\n i = this.traj.currentFrame + p.step\n } else {\n i = this.traj.currentFrame - p.step\n }\n\n if (i > p.end || i < p.start) {\n if (p.direction === 'bounce') {\n if (this._direction === 'forward') {\n this._direction = 'backward'\n } else {\n this._direction = 'forward'\n }\n }\n\n if (p.mode === 'once') {\n this.pause()\n\n if (p.direction === 'forward') {\n i = p.end\n } else if (p.direction === 'backward') {\n i = p.start\n } else {\n if (this._direction === 'forward') {\n i = p.start\n } else {\n i = p.end\n }\n }\n } else {\n if (this._direction === 'forward') {\n i = p.start\n if (p.interpolateType) {\n i = Math.min(p.end, i + p.step)\n }\n } else {\n i = p.end\n if (p.interpolateType) {\n i = Math.max(p.start, i - p.step)\n }\n }\n }\n }\n\n return i\n }\n\n _nextInterpolated () {\n const p = this.parameters\n const i = this._next()\n let ip, ipp, ippp\n\n if (this._direction === 'forward') {\n ip = Math.max(p.start, i - p.step)\n ipp = Math.max(p.start, i - 2 * p.step)\n ippp = Math.max(p.start, i - 3 * p.step)\n } else {\n ip = Math.min(p.end, i + p.step)\n ipp = Math.min(p.end, i + 2 * p.step)\n ippp = Math.min(p.end, i + 3 * p.step)\n }\n\n return [i, ip, ipp, ippp] as [number, number, number, number]\n }\n\n /**\n * toggle between playing and pausing the animation\n * @return {undefined}\n */\n toggle () {\n if (this._run) {\n this.pause()\n } else {\n this.play()\n }\n }\n\n /**\n * start the animation\n * @return {undefined}\n */\n play () {\n if (!this._run) {\n if (this.traj.player !== this) {\n this.traj.setPlayer(this)\n }\n this._currentStep = 1\n\n const p = this.parameters\n const frame = this.traj.currentFrame\n\n // snap to the grid implied by this.step division and multiplication\n // thus minimizing cache misses\n let i = Math.ceil(frame / p.step) * p.step\n // wrap when restarting from the limit (i.e. end or start)\n if (p.direction === 'forward' && frame >= p.end) {\n i = p.start\n } else if (p.direction === 'backward' && frame <= p.start) {\n i = p.end\n }\n\n this.traj.setFrame(i)\n\n this._run = true\n this._animate()\n this.signals.startedRunning.dispatch()\n }\n }\n\n /**\n * pause the animation\n * @return {undefined}\n */\n pause () {\n this._run = false\n this.signals.haltedRunning.dispatch()\n }\n\n /**\n * stop the animation (pause and go to start-frame)\n * @return {undefined}\n */\n stop () {\n this.pause()\n this.traj.setFrame(this.parameters.start)\n }\n}\n\nexport default TrajectoryPlayer\n","/**\n * @file Trajectory\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { Log } from '../globals'\nimport { defaults } from '../utils'\nimport { NumberArray } from '../types'\nimport { circularMean, arrayMean } from '../math/array-utils'\nimport { lerp, spline } from '../math/math-utils'\nimport Selection from '../selection/selection'\nimport Superposition from '../align/superposition'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\nimport TrajectoryPlayer, { TrajectoryPlayerInterpolateType } from './trajectory-player'\n\n\nfunction centerPbc (coords: NumberArray, mean: number[], box: ArrayLike) {\n if (box[ 0 ] === 0 || box[ 8 ] === 0 || box[ 4 ] === 0) {\n return\n }\n\n const n = coords.length\n\n const bx = box[ 0 ]\n const by = box[ 1 ]\n const bz = box[ 2 ]\n const mx = mean[ 0 ]\n const my = mean[ 1 ]\n const mz = mean[ 2 ]\n\n const fx = -mx + bx + bx / 2\n const fy = -my + by + by / 2\n const fz = -mz + bz + bz / 2\n\n for (let i = 0; i < n; i += 3) {\n coords[ i + 0 ] = (coords[ i + 0 ] + fx) % bx\n coords[ i + 1 ] = (coords[ i + 1 ] + fy) % by\n coords[ i + 2 ] = (coords[ i + 2 ] + fz) % bz\n }\n}\n\nfunction removePbc (x: NumberArray, box: ArrayLike) {\n if (box[ 0 ] === 0 || box[ 8 ] === 0 || box[ 4 ] === 0) {\n return\n }\n\n // ported from GROMACS src/gmxlib/rmpbc.c:rm_gropbc()\n // in-place\n\n const n = x.length\n\n for (let i = 3; i < n; i += 3) {\n for (let j = 0; j < 3; ++j) {\n const dist = x[ i + j ] - x[ i - 3 + j ]\n\n if (Math.abs(dist) > 0.9 * box[ j * 3 + j ]) {\n if (dist > 0) {\n for (let d = 0; d < 3; ++d) {\n x[ i + d ] -= box[ j * 3 + d ]\n }\n } else {\n for (let d = 0; d < 3; ++d) {\n x[ i + d ] += box[ j * 3 + d ]\n }\n }\n }\n }\n }\n\n return x\n}\n\nfunction removePeriodicity (x: NumberArray, box: ArrayLike, mean: number[]) {\n if (box[ 0 ] === 0 || box[ 8 ] === 0 || box[ 4 ] === 0) {\n return\n }\n\n const n = x.length\n for (let i = 3; i < n; i += 3) {\n for (let j = 0; j < 3; ++j) {\n const f = (x[ i + j ] - mean[ j ]) / box[ j * 3 + j ]\n if (Math.abs(f) > 0.5) {\n x[ i + j ] -= box[ j * 3 + j ] * Math.round(f)\n }\n }\n }\n\n return x\n}\n\nfunction circularMean3 (indices: NumberArray, coords: NumberArray, box: ArrayLike) {\n return [\n circularMean(coords, box[ 0 ], 3, 0, indices),\n circularMean(coords, box[ 1 ], 3, 1, indices),\n circularMean(coords, box[ 2 ], 3, 2, indices)\n ]\n}\n\nfunction arrayMean3 (coords: NumberArray) {\n return [\n arrayMean(coords, 3, 0),\n arrayMean(coords, 3, 1),\n arrayMean(coords, 3, 2)\n ]\n}\n\nfunction interpolateSpline (c: NumberArray, cp: NumberArray, cpp: NumberArray, cppp: NumberArray, t: number) {\n const m = c.length\n const coords = new Float32Array(m)\n\n for (let j0 = 0; j0 < m; j0 += 3) {\n const j1 = j0 + 1\n const j2 = j0 + 2\n coords[ j0 ] = spline(cppp[ j0 ], cpp[ j0 ], cp[ j0 ], c[ j0 ], t, 1)\n coords[ j1 ] = spline(cppp[ j1 ], cpp[ j1 ], cp[ j1 ], c[ j1 ], t, 1)\n coords[ j2 ] = spline(cppp[ j2 ], cpp[ j2 ], cp[ j2 ], c[ j2 ], t, 1)\n }\n\n return coords\n}\n\nfunction interpolateLerp (c: NumberArray, cp: NumberArray, t: number) {\n const m = c.length\n const coords = new Float32Array(m)\n\n for (let j0 = 0; j0 < m; j0 += 3) {\n const j1 = j0 + 1\n const j2 = j0 + 2\n coords[ j0 ] = lerp(cp[ j0 ], c[ j0 ], t)\n coords[ j1 ] = lerp(cp[ j1 ], c[ j1 ], t)\n coords[ j2 ] = lerp(cp[ j2 ], c[ j2 ], t)\n }\n\n return coords\n}\n\n/**\n * Trajectory parameter object.\n * @typedef {Object} TrajectoryParameters - parameters\n *\n * @property {Number} deltaTime - timestep between frames in picoseconds\n * @property {Number} timeOffset - starting time of frames in picoseconds\n * @property {String} sele - to restrict atoms used for superposition\n * @property {Boolean} centerPbc - center on initial frame\n * @property {Boolean} removePeriodicity - move atoms into the origin box\n * @property {Boolean} remo - try fixing periodic boundary discontinuities\n * @property {Boolean} superpose - superpose on initial frame\n */\n\n/**\n * @example\n * trajectory.signals.frameChanged.add( function(i){ ... } );\n *\n * @typedef {Object} TrajectorySignals\n * @property {Signal} countChanged - when the frame count is changed\n * @property {Signal} frameChanged - when the set frame is changed\n * @property {Signal} playerChanged - when the player is changed\n */\n\nexport interface TrajectoryParameters {\n deltaTime: number // timestep between frames in picoseconds\n timeOffset: number // starting time of frames in picoseconds\n sele: string // to restrict atoms used for superposition\n centerPbc: boolean // center on initial frame\n removePbc: boolean // move atoms into the origin box\n removePeriodicity: boolean // try fixing periodic boundary discontinuities\n superpose: boolean // superpose on initial frame\n}\n\nexport interface TrajectorySignals {\n countChanged: Signal\n frameChanged: Signal\n playerChanged: Signal\n}\n\n/**\n * Base class for trajectories, tying structures and coordinates together\n * @interface\n */\nclass Trajectory {\n signals: TrajectorySignals = {\n countChanged: new Signal(),\n frameChanged: new Signal(),\n playerChanged: new Signal()\n }\n\n deltaTime: number\n timeOffset: number\n sele: string\n centerPbc: boolean\n removePbc: boolean\n removePeriodicity: boolean\n superpose: boolean\n\n name: string\n frame: number\n trajPath: string\n\n initialCoords: Float32Array\n structureCoords: Float32Array\n selectionIndices: NumberArray\n backboneIndices: NumberArray\n\n coords1: Float32Array\n coords2: Float32Array\n\n frameCache: { [k: number]: Float32Array } = {}\n loadQueue: { [k: number]: boolean } = {}\n boxCache: { [k: number]: ArrayLike } = {}\n pathCache = {}\n frameCacheSize = 0\n\n atomCount: number\n inProgress: boolean\n\n selection: Selection // selection to restrict atoms used for superposition\n structure: Structure\n player: TrajectoryPlayer\n\n private _frameCount = 0\n private _currentFrame = -1\n private _disposed = false\n\n /**\n * @param {String} trajPath - trajectory source\n * @param {Structure} structure - the structure object\n * @param {TrajectoryParameters} params - trajectory parameters\n */\n constructor (trajPath: string, structure: Structure, params: Partial = {}) {\n this.deltaTime = defaults(params.deltaTime, 0)\n this.timeOffset = defaults(params.timeOffset, 0)\n this.centerPbc = defaults(params.centerPbc, false)\n this.removePbc = defaults(params.removePbc, false)\n this.removePeriodicity = defaults(params.removePeriodicity, false)\n this.superpose = defaults(params.superpose, false)\n\n this.name = trajPath.replace(/^.*[\\\\/]/, '')\n this.trajPath = trajPath\n\n this.selection = new Selection(\n defaults(params.sele, 'backbone and not hydrogen')\n )\n\n this.selection.signals.stringChanged.add(() => {\n this.selectionIndices = this.structure.getAtomIndices(this.selection)!\n this._resetCache()\n this._saveInitialCoords()\n this.setFrame(this._currentFrame)\n })\n }\n\n /**\n * Number of frames in the trajectory\n */\n get frameCount () {\n return this._frameCount\n }\n\n /**\n * Currently set frame of the trajectory\n */\n get currentFrame () {\n return this._currentFrame\n }\n\n _init (structure: Structure) {\n this.setStructure(structure)\n this._loadFrameCount()\n this.setPlayer(new TrajectoryPlayer(this))\n }\n\n _loadFrameCount () {}\n\n setStructure (structure: Structure) {\n this.structure = structure\n this.atomCount = structure.atomCount\n\n this.backboneIndices = this._getIndices(\n new Selection('backbone and not hydrogen')\n )\n this._makeAtomIndices()\n this._saveStructureCoords()\n\n this.selectionIndices = this._getIndices(this.selection)\n this._resetCache()\n this._saveInitialCoords()\n this.setFrame(this._currentFrame)\n }\n\n _saveInitialCoords () {\n if (this.structure.hasCoords()) {\n this.initialCoords = new Float32Array(this.structureCoords)\n this._makeSuperposeCoords()\n } else if (this.frameCache[0]) {\n this.initialCoords = new Float32Array(this.frameCache[0])\n this._makeSuperposeCoords()\n } else {\n this.loadFrame(0, () => this._saveInitialCoords())\n }\n }\n\n _saveStructureCoords () {\n const p = { what: { position: true } }\n this.structureCoords = this.structure.getAtomData(p).position!\n }\n\n setSelection (string: string) {\n this.selection.setString(string)\n return this\n }\n\n _getIndices (selection: Selection) {\n let i = 0\n const test = selection.test\n const indices: number[] = []\n\n if (test) {\n this.structure.eachAtom((ap: AtomProxy) => {\n if (test(ap)) indices.push(i)\n i += 1\n })\n }\n\n return indices\n }\n\n _makeSuperposeCoords () {\n const n = this.selectionIndices.length * 3\n\n this.coords1 = new Float32Array(n)\n this.coords2 = new Float32Array(n)\n\n const y = this.initialCoords\n const coords2 = this.coords2\n\n for (let i = 0; i < n; i += 3) {\n const j = this.selectionIndices[ i / 3 ] * 3\n\n coords2[ i + 0 ] = y[ j + 0 ]\n coords2[ i + 1 ] = y[ j + 1 ]\n coords2[ i + 2 ] = y[ j + 2 ]\n }\n }\n\n _makeAtomIndices () {\n Log.error('Trajectory._makeAtomIndices not implemented')\n }\n\n _resetCache () {\n this.frameCache = {}\n this.loadQueue = {}\n this.boxCache = {}\n this.pathCache = {}\n this.frameCacheSize = 0\n this.initialCoords = new Float32Array(0)\n }\n\n setParameters (params: Partial = {}) {\n let resetCache = false\n\n if (params.centerPbc !== undefined && params.centerPbc !== this.centerPbc) {\n this.centerPbc = params.centerPbc\n resetCache = true\n }\n\n if (params.removePeriodicity !== undefined && params.removePeriodicity !== this.removePeriodicity) {\n this.removePeriodicity = params.removePeriodicity\n resetCache = true\n }\n\n if (params.removePbc !== undefined && params.removePbc !== this.removePbc) {\n this.removePbc = params.removePbc\n resetCache = true\n }\n\n if (params.superpose !== undefined && params.superpose !== this.superpose) {\n this.superpose = params.superpose\n resetCache = true\n }\n\n this.deltaTime = defaults(params.deltaTime, this.deltaTime)\n this.timeOffset = defaults(params.timeOffset, this.timeOffset)\n\n if (resetCache) {\n this._resetCache()\n this.setFrame(this._currentFrame)\n }\n }\n\n /**\n * Check if a frame is available\n * @param {Integer|Integer[]} i - the frame index\n * @return {Boolean} frame availability\n */\n hasFrame (i: number|number[]) {\n if (Array.isArray(i)) {\n return i.every(j => !!this.frameCache[j])\n } else {\n return !!this.frameCache[i]\n }\n }\n\n /**\n * Set trajectory to a frame index\n * @param {Integer} i - the frame index\n * @param {Function} [callback] - fired when the frame has been set\n */\n setFrame (i: number, callback?: Function) {\n if (i === undefined) return this\n\n this.inProgress = true\n\n // i = parseInt(i) // TODO\n\n if (i === -1 || this.frameCache[ i ]) {\n this._updateStructure(i)\n if (callback) callback()\n } else {\n this.loadFrame(i, () => {\n this._updateStructure(i)\n if (callback) callback()\n })\n }\n\n return this\n }\n\n _interpolate (i: number, ip: number, ipp: number, ippp: number, t: number, type: TrajectoryPlayerInterpolateType) {\n const fc = this.frameCache\n\n let coords\n if (type === 'spline') {\n coords = interpolateSpline(fc[ i ], fc[ ip ], fc[ ipp ], fc[ ippp ], t)\n } else {\n coords = interpolateLerp(fc[ i ], fc[ ip ], t)\n }\n\n this.structure.updatePosition(coords)\n this._currentFrame = i\n this.signals.frameChanged.dispatch(i)\n }\n\n /**\n * Interpolated and set trajectory to frame indices\n * @param {Integer} i - the frame index\n * @param {Integer} ip - one before frame index\n * @param {Integer} ipp - two before frame index\n * @param {Integer} ippp - three before frame index\n * @param {Number} t - interpolation step [0,1]\n * @param {String} type - interpolation type, '', 'spline' or 'linear'\n * @param {Function} callback - fired when the frame has been set\n */\n setFrameInterpolated (i: number, ip: number, ipp: number, ippp: number, t: number, type: TrajectoryPlayerInterpolateType, callback?: Function) {\n if (i === undefined) return this\n\n const fc = this.frameCache\n const iList: number[] = []\n\n if (!fc[ ippp ]) iList.push(ippp)\n if (!fc[ ipp ]) iList.push(ipp)\n if (!fc[ ip ]) iList.push(ip)\n if (!fc[ i ]) iList.push(i)\n\n if (iList.length) {\n this.loadFrame(iList, () => {\n this._interpolate(i, ip, ipp, ippp, t, type)\n if (callback) callback()\n })\n } else {\n this._interpolate(i, ip, ipp, ippp, t, type)\n if (callback) callback()\n }\n\n return this\n }\n\n /**\n * Load frame index\n * @param {Integer|Integer[]} i - the frame index\n * @param {Function} callback - fired when the frame has been loaded\n */\n loadFrame (i: number|number[], callback?: Function) {\n if (Array.isArray(i)) {\n i.forEach(j => {\n if (!this.loadQueue[j] && !this.frameCache[j]) {\n this.loadQueue[j] = true\n this._loadFrame(j, () => {\n delete this.loadQueue[j]\n })\n }\n })\n } else {\n if (!this.loadQueue[i] && !this.frameCache[i]) {\n this.loadQueue[i] = true\n this._loadFrame(i, () => {\n delete this.loadQueue[i]\n if (callback) callback()\n })\n }\n }\n }\n\n /**\n * Load frame index\n * @abstract\n * @param {Integer} i - the frame index\n * @param {Function} callback - fired when the frame has been loaded\n */\n _loadFrame (i: number, callback?: Function) {\n Log.error('Trajectory._loadFrame not implemented', i, callback)\n }\n\n _updateStructure (i: number) {\n if (this._disposed) {\n console.error('updateStructure: traj disposed')\n return\n }\n\n if (i === -1) {\n if (this.structureCoords) {\n this.structure.updatePosition(this.structureCoords)\n }\n } else {\n this.structure.updatePosition(this.frameCache[ i ])\n }\n\n this.structure.trajectory = {\n name: this.trajPath,\n frame: i\n }\n\n this._currentFrame = i\n this.inProgress = false\n this.signals.frameChanged.dispatch(i)\n }\n\n _doSuperpose (x: Float32Array) {\n const n = this.selectionIndices.length * 3\n\n const coords1 = this.coords1\n const coords2 = this.coords2\n\n for (let i = 0; i < n; i += 3) {\n const j = this.selectionIndices[ i / 3 ] * 3\n\n coords1[ i + 0 ] = x[ j + 0 ]\n coords1[ i + 1 ] = x[ j + 1 ]\n coords1[ i + 2 ] = x[ j + 2 ]\n }\n\n // TODO re-use superposition object\n const sp = new Superposition(coords1, coords2)\n sp.transform(x)\n }\n\n _process (i: number, box: ArrayLike, coords: Float32Array, frameCount: number) {\n this._setFrameCount(frameCount)\n\n if (box) {\n if (this.backboneIndices.length > 0 && this.centerPbc) {\n const box2 = [ box[ 0 ], box[ 4 ], box[ 8 ] ]\n const circMean = circularMean3(this.backboneIndices, coords, box2)\n centerPbc(coords, circMean, box2)\n }\n\n if (this.removePeriodicity) {\n const mean = arrayMean3(coords)\n removePeriodicity(coords, box, mean)\n }\n\n if (this.removePbc) {\n removePbc(coords, box)\n }\n }\n\n if (this.selectionIndices.length > 0 && this.coords1 && this.superpose) {\n this._doSuperpose(coords)\n }\n\n this.frameCache[ i ] = coords\n this.boxCache[ i ] = box\n this.frameCacheSize += 1\n }\n\n _setFrameCount (n: number) {\n if (n !== this._frameCount) {\n this._frameCount = n\n this.signals.countChanged.dispatch(n)\n }\n }\n\n /**\n * Dispose of the trajectory object\n * @return {undefined}\n */\n dispose () {\n this._resetCache() // aid GC\n this._disposed = true\n if (this.player) this.player.stop()\n }\n\n /**\n * Set player for this trajectory\n * @param {TrajectoryPlayer} player - the player\n */\n setPlayer (player: TrajectoryPlayer) {\n this.player = player\n this.signals.playerChanged.dispatch(player)\n }\n\n /**\n * Get time for frame\n * @param {Integer} i - frame index\n * @return {Number} time in picoseconds\n */\n getFrameTime (i: number) {\n return this.timeOffset + i * this.deltaTime\n }\n}\n\nexport default Trajectory\n","/**\n * @file Frames Trajectory\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport Structure from '../structure/structure'\nimport Frames from './frames'\nimport Trajectory, { TrajectoryParameters } from './trajectory'\n\n/**\n * Frames trajectory class. Gets data from a frames object.\n */\nclass FramesTrajectory extends Trajectory {\n path: string\n\n frames: ArrayLike[]\n boxes: ArrayLike[]\n\n atomIndices?: ArrayLike\n\n constructor (frames: Frames, structure: Structure, params: TrajectoryParameters) {\n const p = params || {}\n p.timeOffset = defaults(p.timeOffset, frames.timeOffset)\n p.deltaTime = defaults(p.deltaTime, frames.deltaTime)\n\n super('', structure, p)\n\n this.name = frames.name\n this.path = frames.path\n\n this.frames = frames.coordinates\n this.boxes = frames.boxes\n\n this._init(structure)\n }\n\n get type () { return 'frames' }\n\n _makeAtomIndices () {\n if (this.structure.type === 'StructureView') {\n this.atomIndices = this.structure.getAtomIndices()\n } else {\n this.atomIndices = undefined\n }\n }\n\n _loadFrame (i: number, callback?: Function) {\n let coords\n const frame = this.frames[ i ]\n\n if (this.atomIndices) {\n const indices = this.atomIndices\n const m = indices.length\n\n coords = new Float32Array(m * 3)\n\n for (let j = 0; j < m; ++j) {\n const j3 = j * 3\n const idx3 = indices[ j ] * 3\n\n coords[ j3 + 0 ] = frame[ idx3 + 0 ]\n coords[ j3 + 1 ] = frame[ idx3 + 1 ]\n coords[ j3 + 2 ] = frame[ idx3 + 2 ]\n }\n } else {\n coords = new Float32Array(frame)\n }\n\n const box = this.boxes[ i ]\n const frameCount = this.frames.length\n\n this._process(i, box, coords, frameCount)\n\n if (typeof callback === 'function') {\n callback()\n }\n }\n\n _loadFrameCount () {\n if (this.frames) {\n this._setFrameCount(this.frames.length)\n }\n }\n}\n\nexport default FramesTrajectory\n","/**\n * @file Structure Trajectory\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Trajectory, { TrajectoryParameters } from './trajectory'\n\n/**\n * Structure trajectory class. Gets data from a structure object.\n */\nclass StructureTrajectory extends Trajectory {\n atomIndices?: ArrayLike\n\n constructor (trajPath: string, structure: Structure, params: TrajectoryParameters) {\n super('', structure, params)\n this._init(structure)\n }\n\n get type () { return 'structure' }\n\n _makeAtomIndices () {\n if (this.structure.atomSet && this.structure.atomSet.getSize() < this.structure.atomStore.count) {\n this.atomIndices = this.structure.getAtomIndices()\n } else {\n this.atomIndices = undefined\n }\n }\n\n _loadFrame (i: number, callback?: Function) {\n let coords\n const structure = this.structure\n const frame = structure.frames[ i ]\n\n if (this.atomIndices) {\n const indices = this.atomIndices\n const m = indices.length\n\n coords = new Float32Array(m * 3)\n\n for (let j = 0; j < m; ++j) {\n const j3 = j * 3\n const idx3 = indices[ j ] * 3\n\n coords[ j3 + 0 ] = frame[ idx3 + 0 ]\n coords[ j3 + 1 ] = frame[ idx3 + 1 ]\n coords[ j3 + 2 ] = frame[ idx3 + 2 ]\n }\n } else {\n coords = new Float32Array(frame)\n }\n\n const box = structure.boxes[ i ]\n const frameCount = structure.frames.length\n\n this._process(i, box, coords, frameCount)\n\n if (typeof callback === 'function') {\n callback()\n }\n }\n\n _loadFrameCount () {\n this._setFrameCount(this.structure.frames.length)\n }\n}\n\nexport default StructureTrajectory\n","/**\n * @file Remote Trajectory\n * @author Alexander Rose \n * @private\n */\n\nimport { Log, TrajectoryDatasource } from '../globals'\nimport Structure from '../structure/structure'\nimport Trajectory, { TrajectoryParameters } from './trajectory'\n\n/**\n * Remote trajectory class. Gets data from an MDsrv instance.\n */\nclass RemoteTrajectory extends Trajectory {\n atomIndices: number[][]\n\n constructor (trajPath: string, structure: Structure, params: TrajectoryParameters) {\n super(trajPath, structure, params)\n this._init(structure)\n }\n\n get type () { return 'remote' }\n\n _makeAtomIndices () {\n const atomIndices = []\n\n if (this.structure.type === 'StructureView') {\n const indices = this.structure.getAtomIndices()! // TODO\n const n = indices.length\n\n let p = indices[ 0 ]\n let q = indices[ 0 ]\n\n for (let i = 1; i < n; ++i) {\n const r = indices[ i ]\n\n if (q + 1 < r) {\n atomIndices.push([ p, q + 1 ])\n p = r\n }\n\n q = r\n }\n\n atomIndices.push([ p, q + 1 ])\n } else {\n atomIndices.push([ 0, this.atomCount ])\n }\n\n this.atomIndices = atomIndices\n }\n\n _loadFrame (i: number, callback?: Function) {\n // TODO implement max frameCache size, re-use arrays\n\n const request = new XMLHttpRequest()\n\n const url = TrajectoryDatasource.getFrameUrl(this.trajPath, i)\n const params = TrajectoryDatasource.getFrameParams(this.trajPath, this.atomIndices)\n\n request.open('POST', url, true)\n request.responseType = 'arraybuffer'\n request.setRequestHeader(\n 'Content-type', 'application/x-www-form-urlencoded'\n )\n\n request.addEventListener('load', () => {\n const arrayBuffer = request.response\n if (!arrayBuffer) {\n Log.error(`empty arrayBuffer for '${url}'`)\n return\n }\n\n const frameCount = new Int32Array(arrayBuffer, 0, 1)[ 0 ]\n // const time = new Float32Array( arrayBuffer, 1 * 4, 1 )[ 0 ];\n const box = new Float32Array(arrayBuffer, 2 * 4, 9)\n const coords = new Float32Array(arrayBuffer, 11 * 4)\n\n this._process(i, box, coords, frameCount)\n if (typeof callback === 'function') {\n callback()\n }\n }, false)\n\n request.send(params)\n }\n\n _loadFrameCount () {\n const request = new XMLHttpRequest()\n\n const url = TrajectoryDatasource.getCountUrl(this.trajPath)\n\n request.open('GET', url, true)\n request.addEventListener('load', () => {\n this._setFrameCount(parseInt(request.response))\n }, false)\n request.send()\n }\n}\n\nexport default RemoteTrajectory\n","/**\n * @file Callback Trajectory\n * @author Tarn W. Burton \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Trajectory, { TrajectoryParameters } from './trajectory'\n\ntype RequestCallback = (responseCallback: Function, i?: number, atomIndices?: number[][]) => void\n\n/**\n * Callback trajectory class. Gets data from an JavaScript function.\n */\nclass CallbackTrajectory extends Trajectory {\n atomIndices: number[][]\n requestCallback: RequestCallback\n\n constructor (requestCallback: RequestCallback, structure: Structure, params: TrajectoryParameters) {\n super('', structure, params)\n this.requestCallback = requestCallback;\n this._init(structure)\n }\n\n get type () { return 'callback' }\n\n _makeAtomIndices () {\n const atomIndices = []\n\n if (this.structure.type === 'StructureView') {\n const indices = this.structure.getAtomIndices()! // TODO\n const n = indices.length\n\n let p = indices[ 0 ]\n let q = indices[ 0 ]\n\n for (let i = 1; i < n; ++i) {\n const r = indices[ i ]\n\n if (q + 1 < r) {\n atomIndices.push([ p, q + 1 ])\n p = r\n }\n\n q = r\n }\n\n atomIndices.push([ p, q + 1 ])\n } else {\n atomIndices.push([ 0, this.atomCount ])\n }\n\n this.atomIndices = atomIndices\n }\n\n _loadFrame (i: number, callback?: Function) {\n this.requestCallback(\n (i: number, box: ArrayLike, coords: Float32Array, frameCount: number) => {\n this._process(i, box, coords, frameCount)\n if (typeof callback === 'function') {\n callback()\n }\n }, i, this.atomIndices)\n }\n\n _loadFrameCount () {\n this.requestCallback((count: number) => this._setFrameCount(count))\n }\n}\n\nexport default CallbackTrajectory\n\n","/**\n * @file Structure View\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3 } from 'three'\n\nimport { Debug, Log } from '../globals'\nimport Structure from './structure'\nimport Selection from '../selection/selection'\nimport BitArray from '../utils/bitarray'\n\nimport BondProxy from '../proxy/bond-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\nimport SpatialHash from '../geometry/spatial-hash';\nimport BondHash from '../store/bond-hash';\nimport ResidueMap from '../store/residue-map';\nimport AtomMap from '../store/atom-map';\nimport ModelStore from '../store/model-store';\nimport ChainStore from '../store/chain-store';\nimport ResidueStore from '../store/residue-store';\nimport AtomStore from '../store/atom-store';\nimport BondStore from '../store/bond-store';\nimport Validation from './validation';\nimport Unitcell from '../symmetry/unitcell';\nimport Entity from './entity';\nimport Assembly from '../symmetry/assembly';\nimport { Data } from './data';\n\n/**\n * Get view on structure restricted to the selection\n * @param {Selection} selection - the selection\n * @return {StructureView} the view on the structure\n */\nStructure.prototype.getView = function (this: Structure, selection: Selection) {\n // added here to avoid cyclic import dependency\n return new StructureView(this, selection)\n}\n\n/**\n * View on the structure, restricted to the selection\n */\nclass StructureView extends Structure {\n structure: Structure\n selection: Selection\n\n /**\n * @param {Structure} structure - the structure\n * @param {Selection} selection - the selection\n */\n constructor (structure: Structure, selection: Selection) {\n super()\n\n this.structure = structure\n this.selection = selection\n\n this.center = new Vector3()\n this.boundingBox = new Box3()\n\n this._bp = this.getBondProxy()\n this._ap = this.getAtomProxy()\n this._rp = this.getResidueProxy()\n this._cp = this.getChainProxy()\n\n if (this.selection) {\n this.selection.signals.stringChanged.add(this.refresh, this)\n }\n\n this.structure.signals.refreshed.add(this.refresh, this)\n\n this.refresh()\n }\n\n init () {}\n\n get type () { return 'StructureView' }\n\n get name () { return this.structure.name }\n get path () { return this.structure.path }\n get title () { return this.structure.title }\n get id () { return this.structure.id }\n get data (): Data { return this.structure.data }\n get atomSetDict () { return this.structure.atomSetDict }\n get biomolDict (): {[k: string]: Assembly} { return this.structure.biomolDict }\n get entityList (): Entity[] { return this.structure.entityList }\n get unitcell (): Unitcell|undefined { return this.structure.unitcell }\n get frames () { return this.structure.frames }\n get boxes () { return this.structure.boxes }\n get validation (): Validation|undefined { return this.structure.validation }\n get bondStore () { return this.structure.bondStore }\n get backboneBondStore () { return this.structure.backboneBondStore }\n get rungBondStore (): BondStore { return this.structure.rungBondStore }\n get atomStore (): AtomStore { return this.structure.atomStore }\n get residueStore (): ResidueStore { return this.structure.residueStore }\n get chainStore (): ChainStore { return this.structure.chainStore }\n get modelStore (): ModelStore { return this.structure.modelStore }\n get atomMap (): AtomMap { return this.structure.atomMap }\n get residueMap (): ResidueMap { return this.structure.residueMap }\n get bondHash (): BondHash|undefined { return this.structure.bondHash }\n get spatialHash (): SpatialHash|undefined { return this.structure.spatialHash }\n\n get _hasCoords () { return this.structure._hasCoords }\n set _hasCoords (value) { this.structure._hasCoords = value }\n\n /**\n * Updates atomSet, bondSet, atomSetCache, atomCount, bondCount, boundingBox, center.\n * @emits {Structure.signals.refreshed} when refreshed\n * @return {undefined}\n */\n refresh () {\n if (Debug) Log.time('StructureView.refresh')\n\n this.atomSetCache = {}\n const structure = this.structure\n\n if (this.selection.isAllSelection() &&\n structure !== this && structure.atomSet && structure.bondSet\n ) {\n this.atomSet = structure.atomSet.clone()\n this.bondSet = structure.bondSet.clone()\n\n for (let name in this.atomSetDict) {\n const atomSet = this.atomSetDict[ name ]\n this.atomSetCache[ '__' + name ] = atomSet.clone()\n }\n\n this.atomCount = structure.atomCount\n this.bondCount = structure.bondCount\n\n this.boundingBox.copy(structure.boundingBox)\n this.center.copy(structure.center)\n } else if (this.selection.isNoneSelection() &&\n structure !== this && structure.atomSet && structure.bondSet\n ) {\n this.atomSet = new BitArray(structure.atomCount)\n this.bondSet = new BitArray(structure.bondCount)\n\n for (let name in this.atomSetDict) {\n this.atomSetCache[ '__' + name ] = new BitArray(structure.atomCount)\n }\n\n this.atomCount = 0\n this.bondCount = 0\n\n this.boundingBox.makeEmpty()\n this.center.set(0, 0, 0)\n } else {\n this.atomSet = this.getAtomSet(this.selection, true)\n if (structure.atomSet) {\n this.atomSet = this.atomSet.intersection(structure.atomSet)\n }\n\n this.bondSet = this.getBondSet()\n\n for (let name in this.atomSetDict) {\n const atomSet = this.atomSetDict[ name ]\n this.atomSetCache[ '__' + name ] = atomSet.makeIntersection(this.atomSet)\n }\n\n this.atomCount = this.atomSet.getSize()\n this.bondCount = this.bondSet.getSize()\n\n this.boundingBox = this.getBoundingBox()\n this.center = this.boundingBox.getCenter(new Vector3())\n }\n\n if (Debug) Log.timeEnd('StructureView.refresh')\n\n this.signals.refreshed.dispatch()\n }\n\n //\n\n setSelection (selection: Selection) {\n this.selection = selection\n\n this.refresh()\n }\n\n getSelection (selection?: Selection) {\n const seleList: string[] = []\n\n if (selection && selection.string) {\n seleList.push(selection.string)\n }\n\n const parentSelection = this.structure.getSelection()\n if (parentSelection && parentSelection.string) {\n seleList.push(parentSelection.string)\n }\n\n if (this.selection && this.selection.string) {\n seleList.push(this.selection.string)\n }\n\n let sele = ''\n if (seleList.length > 0) {\n sele = `( ${seleList.join(' ) AND ( ')} )`\n }\n\n return new Selection(sele)\n }\n\n getStructure () {\n return this.structure.getStructure()\n }\n\n //\n\n eachBond (callback: (entity: BondProxy) => any, selection?: Selection) {\n this.structure.eachBond(callback, this.getSelection(selection))\n }\n\n eachAtom (callback: (entity: AtomProxy) => any, selection?: Selection) {\n const ap = this.getAtomProxy()\n const atomSet = this.getAtomSet(selection)\n const n = this.atomStore.count\n\n if (atomSet.getSize() < n) {\n atomSet.forEach(function (index) {\n ap.index = index\n callback(ap)\n })\n } else {\n for (let i = 0; i < n; ++i) {\n ap.index = i\n callback(ap)\n }\n }\n }\n\n eachResidue (callback: (entity: ResidueProxy) => any, selection?: Selection) {\n this.structure.eachResidue(callback, this.getSelection(selection))\n }\n\n /**\n * Not implemented\n * @alias StructureView#eachResidueN\n * @return {undefined}\n */\n eachResidueN (n: number, callback: (entity: ResidueProxy) => any) {\n console.error('StructureView.eachResidueN() not implemented')\n }\n\n eachChain (callback: (entity: ChainProxy) => any, selection?: Selection) {\n this.structure.eachChain(callback, this.getSelection(selection))\n }\n\n eachModel (callback: (entity: ModelProxy) => any, selection?: Selection) {\n this.structure.eachModel(callback, this.getSelection(selection))\n }\n\n //\n\n getAtomSet (selection?: boolean|Selection|BitArray, ignoreView = false) {\n let atomSet = this.structure.getAtomSet(selection)\n if (!ignoreView && this.atomSet) {\n atomSet = atomSet.makeIntersection(this.atomSet)\n }\n\n return atomSet\n }\n\n //\n\n getAtomIndices (selection?: Selection) {\n return this.structure.getAtomIndices(this.getSelection(selection))\n }\n\n refreshPosition () {\n return this.structure.refreshPosition()\n }\n\n //\n\n dispose () {\n if (this.selection) {\n this.selection.signals.stringChanged.remove(this.refresh, this)\n }\n\n this.structure.signals.refreshed.remove(this.refresh, this)\n\n this.structure = new Structure() // delete old data\n\n delete this.atomSet\n delete this.bondSet\n\n }\n}\n\nexport default StructureView\n","/**\n * @file Alignment\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log } from '../globals'\n\n// const nucleotides = 'ACTG';\nconst aminoacidsX = 'ACDEFGHIKLMNPQRSTVWY'\nconst aminoacids = 'ARNDCQEGHILKMFPSTWYVBZ?'\n\nconst blosum62x = [\n [4, 0, -2, -1, -2, 0, -2, -1, -1, -1, -1, -2, -1, -1, -1, 1, 0, 0, -3, -2], // A\n [0, 9, -3, -4, -2, -3, -3, -1, -3, -1, -1, -3, -3, -3, -3, -1, -1, -1, -2, -2], // C\n [-2, -3, 6, 2, -3, -1, -1, -3, -1, -4, -3, 1, -1, 0, -2, 0, -1, -3, -4, -3], // D\n [-1, -4, 2, 5, -3, -2, 0, -3, 1, -3, -2, 0, -1, 2, 0, 0, -1, -2, -3, -2], // E\n [-2, -2, -3, -3, 6, -3, -1, 0, -3, 0, 0, -3, -4, -3, -3, -2, -2, -1, 1, 3], // F\n [0, -3, -1, -2, -3, 6, -2, -4, -2, -4, -3, 0, -2, -2, -2, 0, -2, -3, -2, -3], // G\n [-2, -3, -1, 0, -1, -2, 8, -3, -1, -3, -2, 1, -2, 0, 0, -1, -2, -3, -2, 2], // H\n [-1, -1, -3, -3, 0, -4, -3, 4, -3, 2, 1, -3, -3, -3, -3, -2, -1, 3, -3, -1], // I\n [-1, -3, -1, 1, -3, -2, -1, -3, 5, -2, -1, 0, -1, 1, 2, 0, -1, -2, -3, -2], // K\n [-1, -1, -4, -3, 0, -4, -3, 2, -2, 4, 2, -3, -3, -2, -2, -2, -1, 1, -2, -1], // L\n [-1, -1, -3, -2, 0, -3, -2, 1, -1, 2, 5, -2, -2, 0, -1, -1, -1, 1, -1, -1], // M\n [-2, -3, 1, 0, -3, 0, 1, -3, 0, -3, -2, 6, -2, 0, 0, 1, 0, -3, -4, -2], // N\n [-1, -3, -1, -1, -4, -2, -2, -3, -1, -3, -2, -2, 7, -1, -2, -1, -1, -2, -4, -3], // P\n [-1, -3, 0, 2, -3, -2, 0, -3, 1, -2, 0, 0, -1, 5, 1, 0, -1, -2, -2, -1], // Q\n [-1, -3, -2, 0, -3, -2, 0, -3, 2, -2, -1, 0, -2, 1, 5, -1, -1, -3, -3, -2], // R\n [1, -1, 0, 0, -2, 0, -1, -2, 0, -2, -1, 1, -1, 0, -1, 4, 1, -2, -3, -2], // S\n [0, -1, -1, -1, -2, -2, -2, -1, -1, -1, -1, 0, -1, -1, -1, 1, 5, 0, -2, -2], // T\n [0, -1, -3, -2, -1, -3, -3, 3, -2, 1, 1, -3, -2, -2, -3, -2, 0, 4, -3, -1], // V\n [-3, -2, -4, -3, 1, -2, -2, -3, -3, -2, -1, -4, -4, -2, -3, -3, -2, -3, 11, 2], // W\n [-2, -2, -3, -2, 3, -3, 2, -1, -2, -1, -1, -2, -3, -1, -2, -2, -2, -1, 2, 7] // Y\n]\n\nconst blosum62 = [\n // A R N D C Q E G H I L K M F P S T W Y V B Z X\n [4, -1, -2, -2, 0, -1, -1, 0, -2, -1, -1, -1, -1, -2, -1, 1, 0, -3, -2, 0, -2, -1, 0], // A\n [-1, 5, 0, -2, -3, 1, 0, -2, 0, -3, -2, 2, -1, -3, -2, -1, -1, -3, -2, -3, -1, 0, -1], // R\n [-2, 0, 6, 1, -3, 0, 0, 0, 1, -3, -3, 0, -2, -3, -2, 1, 0, -4, -2, -3, 3, 0, -1], // N\n [-2, -2, 1, 6, -3, 0, 2, -1, -1, -3, -4, -1, -3, -3, -1, 0, -1, -4, -3, -3, 4, 1, -1], // D\n [0, -3, -3, -3, 9, -3, -4, -3, -3, -1, -1, -3, -1, -2, -3, -1, -1, -2, -2, -1, -3, -3, -2], // C\n [-1, 1, 0, 0, -3, 5, 2, -2, 0, -3, -2, 1, 0, -3, -1, 0, -1, -2, -1, -2, 0, 3, -1], // Q\n [-1, 0, 0, 2, -4, 2, 5, -2, 0, -3, -3, 1, -2, -3, -1, 0, -1, -3, -2, -2, 1, 4, -1], // E\n [0, -2, 0, -1, -3, -2, -2, 6, -2, -4, -4, -2, -3, -3, -2, 0, -2, -2, -3, -3, -1, -2, -1], // G\n [-2, 0, 1, -1, -3, 0, 0, -2, 8, -3, -3, -1, -2, -1, -2, -1, -2, -2, 2, -3, 0, 0, -1], // H\n [-1, -3, -3, -3, -1, -3, -3, -4, -3, 4, 2, -3, 1, 0, -3, -2, -1, -3, -1, 3, -3, -3, -1], // I\n [-1, -2, -3, -4, -1, -2, -3, -4, -3, 2, 4, -2, 2, 0, -3, -2, -1, -2, -1, 1, -4, -3, -1], // L\n [-1, 2, 0, -1, -3, 1, 1, -2, -1, -3, -2, 5, -1, -3, -1, 0, -1, -3, -2, -2, 0, 1, -1], // K\n [-1, -1, -2, -3, -1, 0, -2, -3, -2, 1, 2, -1, 5, 0, -2, -1, -1, -1, -1, 1, -3, -1, -1], // M\n [-2, -3, -3, -3, -2, -3, -3, -3, -1, 0, 0, -3, 0, 6, -4, -2, -2, 1, 3, -1, -3, -3, -1], // F\n [-1, -2, -2, -1, -3, -1, -1, -2, -2, -3, -3, -1, -2, -4, 7, -1, -1, -4, -3, -2, -2, -1, -2], // P\n [1, -1, 1, 0, -1, 0, 0, 0, -1, -2, -2, 0, -1, -2, -1, 4, 1, -3, -2, -2, 0, 0, 0], // S\n [0, -1, 0, -1, -1, -1, -1, -2, -2, -1, -1, -1, -1, -2, -1, 1, 5, -2, -2, 0, -1, -1, 0], // T\n [-3, -3, -4, -4, -2, -2, -3, -2, -2, -3, -2, -3, -1, 1, -4, -3, -2, 11, 2, -3, -4, -3, -2], // W\n [-2, -2, -2, -3, -2, -1, -2, -3, 2, -1, -1, -2, -1, 3, -3, -2, -2, 2, 7, -1, -3, -2, -1], // Y\n [0, -3, -3, -3, -1, -2, -2, -3, -3, 3, 1, -2, 1, -1, -2, -2, 0, -3, -1, 4, -3, -2, -1], // V\n [-2, -1, 3, 4, -3, 0, 1, -1, 0, -3, -4, 0, -3, -3, -2, 0, -1, -4, -3, -3, 4, 1, -1], // B\n [-1, 0, 0, 1, -3, 3, 4, -2, 0, -3, -3, 1, -1, -3, -1, 0, -1, -3, -2, -2, 1, 4, -1], // Z\n [0, -1, -1, -1, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, 0, 0, -2, -1, -1, -1, -1, -1] // X\n]\n\nfunction prepareMatrix (cellNames: string, mat: number[][]) {\n let j: number\n let i = 0\n const matDict: { [k: string]: { [k: string]: number } } = {}\n mat.forEach(function (row) {\n j = 0\n const rowDict: { [k: string]: number } = {}\n row.forEach(function (elm) {\n rowDict[ cellNames[ j++ ] ] = elm\n })\n matDict[ cellNames[ i++ ] ] = rowDict\n })\n return matDict\n}\n\nconst SubstitutionMatrices = (function () {\n return {\n blosum62: prepareMatrix(aminoacids, blosum62),\n blosum62x: prepareMatrix(aminoacidsX, blosum62x)\n }\n}())\nexport type SubstitutionMatrix = ''|'blosum62'|'blosum62x'\n\nclass Alignment {\n substMatrix: { [k: string]: { [k: string]: number } }\n\n n: number\n m: number\n score?: number\n ali: string\n\n S: number[][]\n V: number[][]\n H: number[][]\n\n ali1: string\n ali2: string\n\n constructor (readonly seq1: string, readonly seq2: string, readonly gapPenalty = -10, readonly gapExtensionPenalty = -1, substMatrix: SubstitutionMatrix = 'blosum62') {\n // TODO try encoding seqs as integers and use array subst matrix, maybe faster\n\n if (substMatrix) {\n this.substMatrix = SubstitutionMatrices[ substMatrix ]\n }\n }\n\n initMatrices () {\n this.n = this.seq1.length\n this.m = this.seq2.length\n\n // Log.log(this.n, this.m);\n\n this.score = undefined\n this.ali = ''\n\n this.S = []\n this.V = []\n this.H = []\n\n for (let i = 0; i <= this.n; ++i) {\n this.S[ i ] = []\n this.V[ i ] = []\n this.H[ i ] = []\n\n for (let j = 0; j <= this.m; ++j) {\n this.S[ i ][ j ] = 0\n this.V[ i ][ j ] = 0\n this.H[ i ][ j ] = 0\n }\n }\n\n for (let i = 0; i <= this.n; ++i) {\n this.S[ i ][ 0 ] = this.gap(0)\n this.H[ i ][ 0 ] = -Infinity\n }\n\n for (let j = 0; j <= this.m; ++j) {\n this.S[ 0 ][ j ] = this.gap(0)\n this.V[ 0 ][ j ] = -Infinity\n }\n\n this.S[ 0 ][ 0 ] = 0\n\n // Log.log(this.S, this.V, this.H);\n }\n\n gap (len: number) {\n return this.gapPenalty + len * this.gapExtensionPenalty\n }\n\n makeScoreFn () {\n const seq1 = this.seq1\n const seq2 = this.seq2\n\n const substMatrix = this.substMatrix\n\n if (substMatrix) {\n return function score (i: number, j: number) {\n const c1 = seq1[ i ]\n const c2 = seq2[ j ]\n\n try {\n return substMatrix[ c1 ][ c2 ]\n } catch (e) {\n return -4\n }\n }\n } else {\n Log.warn('Alignment: no subst matrix')\n\n return function scoreNoSubstMat (i: number, j: number) {\n const c1 = seq1[ i ]\n const c2 = seq2[ j ]\n\n return c1 === c2 ? 5 : -3\n }\n }\n }\n\n calc () {\n if (Debug) Log.time('Alignment.calc')\n\n this.initMatrices()\n\n const gap0 = this.gap(0)\n const scoreFn = this.makeScoreFn()\n const gapExtensionPenalty = this.gapExtensionPenalty\n\n const V = this.V\n const H = this.H\n const S = this.S\n\n const n = this.n\n const m = this.m\n\n let Vi1, Si1, Vi, Hi, Si\n\n for (let i = 1; i <= n; ++i) {\n Si1 = S[ i - 1 ]\n Vi1 = V[ i - 1 ]\n\n Vi = V[ i ]\n Hi = H[ i ]\n Si = S[ i ]\n\n for (let j = 1; j <= m; ++j) {\n Vi[j] = Math.max(\n Si1[ j ] + gap0,\n Vi1[ j ] + gapExtensionPenalty\n )\n\n Hi[j] = Math.max(\n Si[ j - 1 ] + gap0,\n Hi[ j - 1 ] + gapExtensionPenalty\n )\n\n Si[j] = Math.max(\n Si1[ j - 1 ] + scoreFn(i - 1, j - 1), // match\n Vi[ j ], // del\n Hi[ j ] // ins\n )\n }\n }\n\n if (Debug) Log.timeEnd('Alignment.calc')\n\n if (Debug) Log.log(this.S, this.V, this.H)\n }\n\n trace () {\n if (Debug) Log.time('Alignment.trace')\n\n this.ali1 = ''\n this.ali2 = ''\n\n const scoreFn = this.makeScoreFn()\n\n let i = this.n\n let j = this.m\n let mat\n\n if (this.S[i][j] >= this.V[i][j]) {\n mat = 'S'\n this.score = this.S[i][j]\n } else if (this.V[i][j] >= this.H[i][j]) {\n mat = 'V'\n this.score = this.V[i][j]\n } else {\n mat = 'H'\n this.score = this.H[i][j]\n }\n\n if (Debug) Log.log('Alignment: SCORE', this.score)\n if (Debug) Log.log('Alignment: S, V, H', this.S[i][j], this.V[i][j], this.H[i][j])\n\n while (i > 0 && j > 0) {\n if (mat === 'S') {\n if (this.S[i][j] === this.S[i - 1][j - 1] + scoreFn(i - 1, j - 1)) {\n this.ali1 = this.seq1[i - 1] + this.ali1\n this.ali2 = this.seq2[j - 1] + this.ali2\n --i\n --j\n mat = 'S'\n } else if (this.S[i][j] === this.V[i][j]) {\n mat = 'V'\n } else if (this.S[i][j] === this.H[i][j]) {\n mat = 'H'\n } else {\n // Log.debug('Alignment: S');\n --i\n --j\n }\n } else if (mat === 'V') {\n if (this.V[i][j] === this.V[i - 1][j] + this.gapExtensionPenalty) {\n this.ali1 = this.seq1[i - 1] + this.ali1\n this.ali2 = '-' + this.ali2\n --i\n mat = 'V'\n } else if (this.V[i][j] === this.S[i - 1][j] + this.gap(0)) {\n this.ali1 = this.seq1[i - 1] + this.ali1\n this.ali2 = '-' + this.ali2\n --i\n mat = 'S'\n } else {\n // Log.debug('Alignment: V');\n --i\n }\n } else if (mat === 'H') {\n if (this.H[i][j] === this.H[i][j - 1] + this.gapExtensionPenalty) {\n this.ali1 = '-' + this.ali1\n this.ali2 = this.seq2[j - 1] + this.ali2\n --j\n mat = 'H'\n } else if (this.H[i][j] === this.S[i][j - 1] + this.gap(0)) {\n this.ali1 = '-' + this.ali1\n this.ali2 = this.seq2[j - 1] + this.ali2\n --j\n mat = 'S'\n } else {\n // Log.debug('Alignment: H');\n --j\n }\n } else {\n Log.error('Alignment: no matrix')\n }\n }\n\n while (i > 0) {\n this.ali1 = this.seq1[ i - 1 ] + this.ali1\n this.ali2 = '-' + this.ali2\n --i\n }\n\n while (j > 0) {\n this.ali1 = '-' + this.ali1\n this.ali2 = this.seq2[ j - 1 ] + this.ali2\n --j\n }\n\n if (Debug) Log.timeEnd('Alignment.trace')\n\n if (Debug) Log.log([this.ali1, this.ali2])\n }\n}\n\nexport default Alignment\n","/**\n * @file Align Utils\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\nimport Alignment from './alignment'\nimport Superposition from './superposition'\n\n/**\n * Perform structural superposition of two structures,\n * optionally guided by a sequence alignment\n * @param {Structure|StructureView} s1 - structure 1 which is superposed onto structure 2\n * @param {Structure|StructureView} s2 - structure 2 onto which structure 1 is superposed\n * @param {Boolean} [align] - guide the superposition by a sequence alignment\n * @param {String} [sele1] - selection string for structure 1\n * @param {String} [sele2] - selection string for structure 2\n * @return {undefined}\n */\nfunction superpose (s1: Structure, s2: Structure, align = false, sele1 = '', sele2 = '') {\n let i: number\n let j: number\n let n: number\n let atoms1\n let atoms2\n\n if (align) {\n let _s1 = s1\n let _s2 = s2\n\n if (sele1 && sele2) {\n _s1 = s1.getView(new Selection(sele1))\n _s2 = s2.getView(new Selection(sele2))\n }\n\n const seq1 = _s1.getSequence()\n const seq2 = _s2.getSequence()\n\n // Log.log( seq1.join(\"\") );\n // Log.log( seq2.join(\"\") );\n\n const ali = new Alignment(seq1.join(''), seq2.join(''))\n\n ali.calc()\n ali.trace()\n\n // Log.log( \"superpose alignment score\", ali.score );\n\n // Log.log( ali.ali1 );\n // Log.log( ali.ali2 );\n\n let _i, _j\n i = 0\n j = 0\n n = ali.ali1.length\n const aliIdx1: boolean[] = []\n const aliIdx2: boolean[] = []\n\n for (let l = 0; l < n; ++l) {\n const x = ali.ali1[ l ]\n const y = ali.ali2[ l ]\n\n _i = 0\n _j = 0\n\n if (x === '-') {\n aliIdx2[ j ] = false\n } else {\n aliIdx2[ j ] = true\n _i = 1\n }\n\n if (y === '-') {\n aliIdx1[ i ] = false\n } else {\n aliIdx1[ i ] = true\n _j = 1\n }\n\n i += _i\n j += _j\n }\n\n // Log.log( i, j );\n\n // Log.log( aliIdx1 );\n // Log.log( aliIdx2 );\n\n const _atoms1: number[] = []\n const _atoms2: number[] = []\n const ap1 = _s1.getAtomProxy()\n const ap2 = _s2.getAtomProxy()\n\n i = 0\n _s1.eachResidue(function (r) {\n if (r.traceAtomIndex === undefined ||\n r.traceAtomIndex !== r.getAtomIndexByName('CA')) return\n\n if (aliIdx1[ i ]) {\n ap1.index = r.getAtomIndexByName('CA')! // TODO\n _atoms1.push(ap1.x, ap1.y, ap1.z)\n }\n i += 1\n })\n\n i = 0\n _s2.eachResidue(function (r) {\n if (r.traceAtomIndex === undefined ||\n r.traceAtomIndex !== r.getAtomIndexByName('CA')) return\n\n if (aliIdx2[ i ]) {\n ap2.index = r.getAtomIndexByName('CA')! // TODO\n _atoms2.push(ap2.x, ap2.y, ap2.z)\n }\n i += 1\n })\n\n atoms1 = new Float32Array(_atoms1)\n atoms2 = new Float32Array(_atoms2)\n } else {\n const sviewCa1 = s1.getView(new Selection(`${sele1} and .CA`))\n const sviewCa2 = s2.getView(new Selection(`${sele2} and .CA`))\n\n atoms1 = sviewCa1\n atoms2 = sviewCa2\n }\n\n const superpose = new Superposition(atoms1, atoms2)\n const result = superpose.transform(s1)\n s1.refreshPosition()\n return result\n}\n\nexport {\n superpose\n}\n","/**\n * @file Sturucture Component\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { ComponentRegistry, MeasurementDefaultParams } from '../globals'\nimport {\n defaults, /*deepEqual, */createRingBuffer, RingBuffer, createSimpleDict, SimpleDict\n} from '../utils'\nimport { smoothstep } from '../math/math-utils'\nimport Component, { ComponentSignals, ComponentDefaultParameters } from './component'\nimport RepresentationCollection from './representation-collection'\nimport TrajectoryElement from './trajectory-element'\nimport RepresentationElement from './representation-element'\nimport { makeTrajectory } from '../trajectory/trajectory-utils'\nimport { TrajectoryParameters } from '../trajectory/trajectory'\nimport Selection from '../selection/selection'\nimport Structure from '../structure/structure'\nimport StructureView from '../structure/structure-view'\nimport { superpose } from '../align/align-utils'\nimport Stage from '../stage/stage'\nimport StructureRepresentation, { StructureRepresentationParameters } from '../representation/structure-representation'\nimport AtomProxy from '../proxy/atom-proxy'\nimport { Vector3, Box3 } from 'three';\nimport { AngleRepresentationParameters } from '../representation/angle-representation';\nimport { AxesRepresentationParameters } from '../representation/axes-representation';\nimport { BallAndStickRepresentationParameters } from '../representation/ballandstick-representation';\nimport { CartoonRepresentationParameters } from '../representation/cartoon-representation';\nimport { ContactRepresentationParameters } from '../representation/contact-representation';\nimport { DihedralRepresentationParameters } from '../representation/dihedral-representation';\nimport { DihedralHistogramRepresentationParameters } from '../representation/dihedral-histogram-representation';\nimport { DistanceRepresentationParameters } from '../representation/distance-representation';\nimport { HyperballRepresentationParameters } from '../representation/hyperball-representation';\nimport { LabelRepresentationParameters } from '../representation/label-representation';\nimport { LineRepresentationParameters } from '../representation/line-representation';\nimport { PointRepresentationParameters } from '../representation/point-representation';\nimport { SurfaceRepresentationParameters } from '../representation/surface-representation';\nimport { RibbonRepresentationParameters } from '../representation/ribbon-representation';\nimport { RocketRepresentationParameters } from '../representation/rocket-representation';\nimport { TraceRepresentationParameters } from '../representation/trace-representation';\nimport { UnitcellRepresentationParameters } from '../representation/unitcell-representation';\nimport { SliceRepresentationParameters } from '../representation/slice-representation'\nimport { MolecularSurfaceRepresentationParameters } from '../representation/molecularsurface-representation'\nimport { DotRepresentationParameters } from '../representation/dot-representation'\n\nexport type StructureRepresentationType = keyof StructureRepresentationParametersMap\n\ninterface StructureRepresentationParametersMap {\n 'angle': AngleRepresentationParameters,\n 'axes' : AxesRepresentationParameters,\n 'backbone': BallAndStickRepresentationParameters,\n 'ball+stick': BallAndStickRepresentationParameters,\n 'base': BallAndStickRepresentationParameters,\n 'cartoon': CartoonRepresentationParameters,\n 'contact': ContactRepresentationParameters,\n 'dihedral': DihedralRepresentationParameters,\n 'dihedral-histogram': DihedralHistogramRepresentationParameters,\n 'distance': DistanceRepresentationParameters,\n 'dot': DotRepresentationParameters,\n 'helixorient': StructureRepresentationParameters,\n 'hyperball': HyperballRepresentationParameters,\n 'label': LabelRepresentationParameters,\n 'licorice': BallAndStickRepresentationParameters,\n 'line': LineRepresentationParameters,\n 'molecularsurface': MolecularSurfaceRepresentationParameters,\n 'point': PointRepresentationParameters,\n 'ribbon': RibbonRepresentationParameters,\n 'rocket': RocketRepresentationParameters,\n 'rope': CartoonRepresentationParameters,\n 'slice': SliceRepresentationParameters,\n 'spacefill': BallAndStickRepresentationParameters,\n 'surface': SurfaceRepresentationParameters,\n 'trace': TraceRepresentationParameters,\n 'tube': CartoonRepresentationParameters,\n 'unitcell': UnitcellRepresentationParameters,\n 'validation': StructureRepresentationParameters\n}\n\nexport const StructureComponentDefaultParameters = Object.assign({\n sele: '',\n defaultAssembly: ''\n}, ComponentDefaultParameters)\nexport type StructureComponentParameters = typeof StructureComponentDefaultParameters\n\nexport interface StructureComponentSignals extends ComponentSignals {\n trajectoryAdded: Signal // when a trajectory is added\n trajectoryRemoved: Signal // when a trajectory is removed\n defaultAssemblyChanged: Signal // on default assembly change\n}\n\n/**\n * Component wrapping a {@link Structure} object\n *\n * @example\n * // get a structure component by loading a structure file into the stage\n * stage.loadFile( \"rcsb://4opj\" ).then( function( structureComponent ){\n * structureComponent.addRepresentation( \"cartoon\" );\n * structureComponent.autoView();\n * } );\n */\nclass StructureComponent extends Component {\n readonly signals: StructureComponentSignals\n readonly parameters: StructureComponentParameters\n get defaultParameters () { return StructureComponentDefaultParameters }\n\n selection: Selection\n structureView: StructureView\n readonly trajList: TrajectoryElement[] = []\n\n pickBuffer: RingBuffer\n pickDict: SimpleDict\n lastPick?: number\n\n spacefillRepresentation: RepresentationElement\n distanceRepresentation: RepresentationElement\n angleRepresentation: RepresentationElement\n dihedralRepresentation: RepresentationElement\n\n measureRepresentations: RepresentationCollection\n\n constructor (stage: Stage, readonly structure: Structure, params: Partial = {}) {\n super(stage, structure, Object.assign({ name: structure.name }, params))\n\n this.signals = Object.assign(this.signals, {\n trajectoryAdded: new Signal(),\n trajectoryRemoved: new Signal(),\n defaultAssemblyChanged: new Signal()\n })\n\n this.initSelection(this.parameters.sele)\n\n //\n\n this.pickBuffer = createRingBuffer(4)\n this.pickDict = createSimpleDict()\n\n this.spacefillRepresentation = this.addRepresentation('spacefill', {\n sele: 'none',\n opacity: MeasurementDefaultParams.opacity,\n color: MeasurementDefaultParams.color,\n disablePicking: true,\n radiusType: 'data'\n }, true)\n\n this.distanceRepresentation = this.addRepresentation(\n 'distance', MeasurementDefaultParams, true\n )\n this.angleRepresentation = this.addRepresentation(\n 'angle', MeasurementDefaultParams, true\n )\n this.dihedralRepresentation = this.addRepresentation(\n 'dihedral', MeasurementDefaultParams, true\n )\n\n this.measureRepresentations = new RepresentationCollection([\n this.spacefillRepresentation,\n this.distanceRepresentation,\n this.angleRepresentation,\n this.dihedralRepresentation\n ])\n\n //\n\n this.setDefaultAssembly(this.parameters.defaultAssembly)\n\n this.structure.signals.refreshed.add(() => {\n this.updateRepresentations({ position: true })\n })\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'structure' }\n\n /**\n * Initialize selection\n * @private\n * @param {String} sele - selection string\n * @return {undefined}\n */\n initSelection (sele: string) {\n /**\n * Selection for {@link StructureComponent#structureView}\n * @private\n * @type {Selection}\n */\n this.selection = new Selection(sele)\n\n /**\n * View on {@link StructureComponent#structure}.\n * Change its selection via {@link StructureComponent#setSelection}.\n * @type {StructureView}\n */\n this.structureView = new StructureView(\n this.structure, this.selection\n )\n\n this.selection.signals.stringChanged.add(() => {\n this.structureView.setSelection(this.selection)\n\n this.rebuildRepresentations()\n this.rebuildTrajectories()\n })\n }\n\n /**\n * Set selection of {@link StructureComponent#structureView}\n * @param {String} string - selection string\n * @return {StructureComponent} this object\n */\n setSelection (string: string) {\n this.parameters.sele = string\n this.selection.setString(string)\n return this\n }\n\n /**\n * Set the default assembly\n * @param {String} value - assembly name\n * @return {undefined}\n */\n setDefaultAssembly (value:string) {\n // filter out non-exsisting assemblies\n if (this.structure.biomolDict[value] === undefined) value = ''\n // only set default assembly when changed\n if (this.parameters.defaultAssembly !== value) {\n const reprParams = { defaultAssembly: value }\n this.reprList.forEach(repr => repr.setParameters(reprParams))\n this.measureRepresentations.setParameters(reprParams)\n this.parameters.defaultAssembly = value\n this.signals.defaultAssemblyChanged.dispatch(value)\n }\n return this\n }\n\n /**\n * Rebuild all representations\n * @return {undefined}\n */\n rebuildRepresentations () {\n this.reprList.forEach((repr: RepresentationElement) => {\n repr.build()\n })\n this.measureRepresentations.build()\n }\n\n /**\n * Rebuild all trajectories\n * @return {undefined}\n */\n rebuildTrajectories () {\n this.trajList.forEach(trajComp => {\n trajComp.trajectory.setStructure(this.structureView)\n })\n }\n\n updateRepresentations (what: any) {\n super.updateRepresentations(what)\n this.measureRepresentations.update(what)\n }\n\n /**\n * Overrides {@link Component.updateRepresentationMatrices} \n * to also update matrix for measureRepresentations \n */\n updateRepresentationMatrices () {\n super.updateRepresentationMatrices()\n this.measureRepresentations.setParameters({ matrix: this.matrix })\n }\n\n addRepresentation (\n type: K,\n params: Partial|{defaultAssembly: string} = {},\n hidden = false\n ) {\n params.defaultAssembly = this.parameters.defaultAssembly\n\n const reprComp = this._addRepresentation(type, this.structureView, params, hidden)\n if (!hidden) {\n reprComp.signals.parametersChanged.add(() => this.measureUpdate())\n }\n return reprComp\n }\n\n /**\n * Add a new trajectory component to the structure\n */\n addTrajectory (trajPath = '', params: { [k: string]: any } = {}) {\n const traj = makeTrajectory(trajPath, this.structureView, params as TrajectoryParameters)\n\n const trajComp = new TrajectoryElement(this.stage, traj, params)\n this.trajList.push(trajComp)\n this.signals.trajectoryAdded.dispatch(trajComp)\n\n return trajComp\n }\n\n removeTrajectory (traj: TrajectoryElement) {\n const idx = this.trajList.indexOf(traj)\n if (idx !== -1) {\n this.trajList.splice(idx, 1)\n }\n\n traj.dispose()\n\n this.signals.trajectoryRemoved.dispatch(traj)\n }\n\n dispose () {\n // copy via .slice because side effects may change trajList\n this.trajList.slice().forEach(traj => traj.dispose())\n\n this.trajList.length = 0\n this.structure.dispose()\n this.measureRepresentations.dispose()\n\n super.dispose()\n }\n\n /**\n * Automatically center and zoom the component\n * @param {String|Integer} [sele] - selection string or duration if integer\n * @param {Integer} [duration] - duration of the animation, defaults to 0\n * @return {undefined}\n */\n autoView (sele?: string|number, duration?: number) {\n if (typeof sele === 'number') {\n duration = sele\n sele = ''\n }\n\n this.stage.animationControls.zoomMove(\n this.getCenter(sele),\n this.getZoom(sele),\n defaults(duration, 0)\n )\n }\n\n getBoxUntransformed (sele: string): Box3 {\n let bb\n\n if (sele) {\n bb = this.structureView.getBoundingBox(new Selection(sele))\n } else {\n bb = this.structureView.boundingBox\n }\n\n return bb\n }\n\n getCenterUntransformed (sele: string): Vector3 {\n if (sele && typeof sele === 'string') {\n return this.structure.atomCenter(new Selection(sele))\n } else {\n return this.structure.center\n }\n }\n\n superpose (component: StructureComponent, align: boolean, sele1: string, sele2: string) {\n superpose(\n this.structureView, component.structureView, align, sele1, sele2\n )\n\n this.updateRepresentations({ 'position': true })\n\n return this\n }\n\n getMaxRepresentationRadius (atomIndex: number) {\n let maxRadius = 0\n const atom = this.structure.getAtomProxy(atomIndex)\n this.eachRepresentation(reprElem => {\n if (reprElem.getVisibility()) {\n const repr: StructureRepresentation = reprElem.repr as any // TODO\n maxRadius = Math.max(repr.getAtomRadius(atom), maxRadius)\n }\n })\n return maxRadius\n }\n\n measurePick (atom: AtomProxy) {\n const pickCount = this.pickBuffer.count\n\n if (this.lastPick === atom.index && pickCount >= 1) {\n if (pickCount > 1) {\n const atomList = this.pickBuffer.data\n const atomListSorted = this.pickBuffer.data.sort()\n if (this.pickDict.has(atomListSorted)) {\n this.pickDict.del(atomListSorted)\n } else {\n this.pickDict.add(atomListSorted, atomList)\n }\n if (pickCount === 2) {\n this.distanceRepresentation.setParameters({\n atomPair: this.pickDict.values.filter(l => l.length === 2)\n })\n } else if (pickCount === 3) {\n this.angleRepresentation.setParameters({\n atomTriple: this.pickDict.values.filter(l => l.length === 3)\n })\n } else if (pickCount === 4) {\n this.dihedralRepresentation.setParameters({\n atomQuad: this.pickDict.values.filter(l => l.length === 4)\n })\n }\n }\n this.pickBuffer.clear()\n this.lastPick = undefined\n } else {\n if (!this.pickBuffer.has(atom.index)) {\n this.pickBuffer.push(atom.index)\n }\n this.lastPick = atom.index\n }\n\n this.measureUpdate()\n }\n\n measureClear () {\n this.pickBuffer.clear()\n this.lastPick = undefined\n this.spacefillRepresentation.setSelection('none')\n }\n\n measureBuild () {\n const md = this.measureData()\n this.distanceRepresentation.setParameters({ atomPair: md.distance })\n this.angleRepresentation.setParameters({ atomTriple: md.angle })\n this.dihedralRepresentation.setParameters({ atomQuad: md.dihedral })\n }\n\n measureUpdate () {\n const pickData = this.pickBuffer.data\n const radiusData: { [k: number]: number } = {}\n pickData.forEach(ai => {\n const r = Math.max(0.1, this.getMaxRepresentationRadius(ai))\n radiusData[ ai ] = r * (2.3 - smoothstep(0.1, 2, r))\n })\n this.spacefillRepresentation.setSelection(\n pickData.length ? ( '@' + pickData.join(',') ) : 'none'\n )\n if (pickData.length)\n this.spacefillRepresentation.setParameters({ radiusData })\n }\n\n measureData () {\n const pv = this.pickDict.values\n return {\n distance: pv.filter(l => l.length === 2),\n angle: pv.filter(l => l.length === 3),\n dihedral: pv.filter(l => l.length === 4)\n }\n }\n\n /**\n * Remove all measurements, optionally limit to distance, angle or dihedral\n */\n removeAllMeasurements (type?: MeasurementFlags) {\n const pd = this.pickDict\n const pv = pd.values\n const remove = function (len: number) {\n pv.filter(l => l.length === len).forEach(l => pd.del(l.slice().sort()))\n }\n if (!type || type & MeasurementFlags.Distance) remove(2)\n if (!type || type & MeasurementFlags.Angle) remove(3)\n if (!type || type & MeasurementFlags.Dihedral) remove(4)\n this.measureBuild()\n }\n\n /**\n * Remove a measurement given as a pair, triple, quad of atom indices\n */\n removeMeasurement (atomList: number[]) {\n this.pickDict.del(atomList.slice().sort())\n this.measureBuild()\n }\n\n /**\n * Add a measurement given as a pair, triple, quad of atom indices\n */\n addMeasurement (atomList: number[]) {\n if (atomList.length < 2 || atomList.length > 4) return\n const atomListSorted = atomList.slice().sort()\n if (!this.pickDict.has(atomListSorted)) {\n this.pickDict.add(atomListSorted, atomList)\n }\n this.measureBuild()\n }\n}\n\nexport const enum MeasurementFlags {\n Distance = 0x1,\n Angle = 0x2,\n Dihedral = 0x4\n}\n\nComponentRegistry.add('structure', StructureComponent)\nComponentRegistry.add('structureview', StructureComponent)\n\nexport default StructureComponent\n","/**\n * @file Trajectory Utils\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Frames from './frames'\nimport { TrajectoryParameters } from './trajectory'\nimport FramesTrajectory from './frames-trajectory'\nimport StructureTrajectory from './structure-trajectory'\nimport RemoteTrajectory from './remote-trajectory'\nimport CallbackTrajectory from './callback-trajectory'\n\nexport function makeTrajectory (trajSrc: string|Frames, structure: Structure, params: TrajectoryParameters) {\n let traj\n\n if (trajSrc && trajSrc instanceof Frames) {\n traj = new FramesTrajectory(trajSrc, structure, params)\n } else if (!trajSrc && structure.frames) {\n traj = new StructureTrajectory(trajSrc, structure, params)\n } else if (trajSrc && typeof trajSrc === 'function') {\n traj = new CallbackTrajectory(trajSrc, structure, params)\n } else {\n traj = new RemoteTrajectory(trajSrc, structure, params)\n }\n\n return traj\n}\n\n","/**\n * @file Surface Component\n * @author Alexander Rose \n * @private\n */\n\nimport { ComponentRegistry } from '../globals'\nimport Component, { ComponentParameters } from './component'\nimport Stage from '../stage/stage'\nimport Surface from '../surface/surface'\nimport { Vector3, Box3 } from 'three';\nimport RepresentationElement from './representation-element';\n\nexport type SurfaceRepresentationType = 'surface'|'dot'\n\n/**\n * Component wrapping a {@link Surface} object\n *\n * @example\n * // get a surface component by loading a surface file into the stage\n * stage.loadFile( \"url/for/surface\" ).then( function( surfaceComponent ){\n * surfaceComponent.addRepresentation( \"surface\" );\n * surfaceComponent.autoView();\n * } );\n */\nclass SurfaceComponent extends Component {\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {Surface} surface - surface object to wrap\n * @param {ComponentParameters} params - component parameters\n */\n constructor (stage: Stage, readonly surface: Surface, params: Partial = {}) {\n super(stage, surface, Object.assign({ name: surface.name }, params))\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'surface' }\n\n /**\n * Add a new surface representation to the component\n * @param {String} type - the name of the representation, one of:\n * surface, dot.\n * @param {SurfaceRepresentationParameters} params - representation parameters\n * @return {RepresentationComponent} the created representation wrapped into\n * a representation component object\n */\n addRepresentation (type: SurfaceRepresentationType, params: { [k: string]: any } = {}): RepresentationElement {\n return this._addRepresentation(type, this.surface, params)\n }\n\n getBoxUntransformed (): Box3 {\n return this.surface.boundingBox\n }\n\n getCenterUntransformed (): Vector3 {\n return this.surface.center\n }\n\n dispose () {\n this.surface.dispose()\n super.dispose()\n }\n}\n\nComponentRegistry.add('surface', SurfaceComponent)\n\nexport default SurfaceComponent\n","/**\n * @file Volume Component\n * @author Alexander Rose \n * @private\n */\n\nimport { ComponentRegistry } from '../globals'\nimport Component, { ComponentParameters } from './component'\nimport Stage from '../stage/stage'\nimport Volume from '../surface/volume'\nimport { Box3, Vector3 } from 'three';\nimport RepresentationElement from './representation-element';\n\nexport type VolumeRepresentationType = 'surface'|'slice'|'dot'\n\n/**\n * Component wrapping a {@link Volume} object\n *\n * @example\n * // get a volume component by loading a volume file into the stage\n * stage.loadFile( \"url/for/volume\" ).then(function(volumeComponent){\n * volumeComponent.addRepresentation('surface');\n * volumeComponent.autoView();\n * });\n */\nclass VolumeComponent extends Component {\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {Volume} volume - volume object to wrap\n * @param {ComponentParameters} params - component parameters\n */\n constructor (stage: Stage, readonly volume: Volume, params: Partial = {}) {\n super(stage, volume, Object.assign({ name: volume.name }, params))\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'volume' }\n\n /**\n * Add a new volume representation to the component\n */\n addRepresentation (type: VolumeRepresentationType, params: { [k: string]: any } = {}): RepresentationElement {\n return this._addRepresentation(type, this.volume, params)\n }\n\n getBoxUntransformed (): Box3 {\n return this.volume.boundingBox\n }\n\n getCenterUntransformed (): Vector3 {\n return this.volume.center\n }\n\n dispose () {\n this.volume.dispose()\n\n super.dispose()\n }\n}\n\nComponentRegistry.add('volume', VolumeComponent)\n\nexport default VolumeComponent\n","/**\n * @file Component Collection\n * @author Alexander Rose \n * @private\n */\n\nimport Component from './component'\nimport Collection from './collection'\n\nclass ComponentCollection extends Collection {\n addRepresentation (name: string, params: any) {\n \treturn this.forEach((comp) => comp.addRepresentation(name, params))\n }\n\n autoView (duration: number) {\n return this.forEach((comp) => comp.autoView(duration))\n }\n}\n\nexport default ComponentCollection\n","/**\n * @file Stage\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3 } from 'three'\nimport { Signal } from 'signals'\n\nimport {\n Debug, Log, Mobile, ComponentRegistry, ParserRegistry\n} from '../globals'\nimport { defaults, createParams, updateParams } from '../utils'\nimport { degToRad, clamp, pclamp } from '../math/math-utils'\nimport Counter from '../utils/counter'\nimport Viewer from '../viewer/viewer'\nimport { ImageParameters } from '../viewer/viewer-utils'\nimport MouseObserver from './mouse-observer'\n\nimport TrackballControls from '../controls/trackball-controls'\nimport PickingControls from '../controls/picking-controls'\nimport ViewerControls from '../controls/viewer-controls'\nimport AnimationControls from '../controls/animation-controls'\nimport MouseControls, { MouseControlPreset } from '../controls/mouse-controls'\nimport KeyControls from '../controls/key-controls'\n\nimport PickingBehavior from './picking-behavior'\nimport MouseBehavior from './mouse-behavior'\nimport AnimationBehavior from './animation-behavior'\nimport KeyBehavior from './key-behavior'\n\nimport Component, { ComponentParameters } from '../component/component'\nimport RepresentationElement from '../component/representation-element'\nimport StructureComponent from '../component/structure-component'\nimport SurfaceComponent from '../component/surface-component'\nimport VolumeComponent from '../component/volume-component'\nimport ComponentCollection from '../component/component-collection'\nimport RepresentationCollection from '../component/representation-collection'\nimport { autoLoad, getFileInfo, LoaderParameters } from '../loader/loader-utils'\nimport { ParserParams } from '../loader/parser-loader'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Animation from '../animation/animation'\nimport Selection from '../selection/selection'\n\nimport Structure from '../structure/structure'\nimport Surface from '../surface/surface'\nimport Volume from '../surface/volume'\nimport Shape from '../geometry/shape'\nimport Script from '../script'\n\nfunction matchName (name: string|RegExp, object: { name: string }) {\n if (name instanceof RegExp) {\n return object.name.match(name) !== null\n } else {\n return object.name === name\n }\n}\n\nconst tmpZoomVector = new Vector3()\n\ndeclare global {\n interface Document {\n mozFullScreen: boolean\n mozFullScreenEnabled: boolean\n mozFullScreenElement: Element\n mozCancelFullScreen(): void\n\n msFullscreenEnabled: boolean\n msFullscreenElement: Element\n msExitFullscreen(): void\n }\n\n interface Element {\n mozRequestFullScreen(): void\n msRequestFullscreen(): void\n }\n}\n\n/**\n * Stage parameter object.\n * @typedef {Object} StageParameters - stage parameters\n * @property {Color} backgroundColor - background color\n * @property {Integer} sampleLevel - sampling level for antialiasing, between -1 and 5;\n * -1: no sampling, 0: only sampling when not moving\n * @property {Boolean} workerDefault - default value for useWorker parameter of representations\n * @property {Float} rotateSpeed - camera-controls rotation speed, between 0 and 10\n * @property {Float} zoomSpeed - camera-controls zoom speed, between 0 and 10\n * @property {Float} panSpeed - camera-controls pan speed, between 0 and 10\n * @property {Float} clipNear - position of camera near/front clipping plane\n * in percent of scene bounding box\n * @property {Float} clipFar - position of camera far/back clipping plane\n * in percent of scene bounding box\n * @property {Float} clipDist - camera clipping distance in Angstrom\n * @property {String} clipMode - how to interpret clipNear/Far and fogNear/Far values: \"scene\" for scene-relative, \"camera\" for camera-relative\n * @property {String} clipScale - \"relative\" or \"absolute\": interpret clipNear/Far and fogNear/Far as percentage of bounding box or absolute Angstroms (ignored when clipMode==camera)\n * @property {Float} fogNear - position of the start of the fog effect\n * in percent of scene bounding box\n * @property {Float} fogFar - position where the fog is in full effect\n * in percent of scene bounding box\n * @property {String} cameraType - type of camera, either 'persepective' or 'orthographic'\n * @property {Float} cameraFov - perspective camera field of view in degree, between 15 and 120\n * @property {Float} cameraEyeSep - stereo camera eye seperation\n * @property {Color} lightColor - point light color\n * @property {Float} lightIntensity - point light intensity\n * @property {Color} ambientColor - ambient light color\n * @property {Float} ambientIntensity - ambient light intensity\n * @property {Integer} hoverTimeout - timeout for hovering\n */\n\nexport interface StageSignals {\n parametersChanged: Signal\n fullscreenChanged: Signal\n componentAdded: Signal\n componentRemoved: Signal\n clicked: Signal\n hovered: Signal\n}\n\nexport type RenderQualityType = 'auto'|'low'|'medium'|'high'\n\nexport const StageDefaultParameters = {\n impostor: true,\n quality: 'medium' as RenderQualityType,\n workerDefault: true,\n sampleLevel: 0,\n backgroundColor: 'black' as string|number,\n rotateSpeed: 2.0,\n zoomSpeed: 1.2,\n panSpeed: 1.0,\n clipNear: 0,\n clipFar: 100,\n clipDist: 10,\n clipMode: 'scene',\n clipScale: 'relative',\n fogNear: 50,\n fogFar: 100,\n cameraFov: 40,\n cameraEyeSep: 0.3,\n cameraType: 'perspective' as 'perspective'|'orthographic'|'stereo',\n lightColor: 0xdddddd as string|number,\n lightIntensity: 1.0,\n ambientColor: 0xdddddd as string|number,\n ambientIntensity: 0.2,\n hoverTimeout: 0,\n tooltip: true,\n mousePreset: 'default' as MouseControlPreset\n}\nexport type StageParameters = typeof StageDefaultParameters\n\nexport interface StageLoadFileParams extends LoaderParameters {\n defaultRepresentation: boolean,\n assembly: string\n}\n\n/**\n * Stage class, central for creating molecular scenes with NGL.\n *\n * @example\n * var stage = new Stage( \"elementId\", { backgroundColor: \"white\" } );\n */\nclass Stage {\n signals: StageSignals = {\n parametersChanged: new Signal(),\n fullscreenChanged: new Signal(),\n componentAdded: new Signal(),\n componentRemoved: new Signal(),\n clicked: new Signal(),\n hovered: new Signal()\n }\n parameters: StageParameters\n\n /**\n * Counter that keeps track of various potentially long-running tasks,\n * including file loading and surface calculation.\n */\n tasks = new Counter()\n compList: Component[] = []\n defaultFileParams = {}\n logList: string[] = []\n\n transformComponent?: Component\n transformAtom?: AtomProxy\n\n viewer: Viewer\n tooltip: HTMLElement\n lastFullscreenElement: HTMLElement\n\n mouseObserver: MouseObserver\n viewerControls: ViewerControls\n trackballControls: TrackballControls\n pickingControls: PickingControls\n animationControls: AnimationControls\n mouseControls: MouseControls\n keyControls: KeyControls\n\n pickingBehavior: PickingBehavior\n mouseBehavior: MouseBehavior\n animationBehavior: AnimationBehavior\n keyBehavior: KeyBehavior\n\n spinAnimation: Animation\n rockAnimation: Animation\n\n constructor (idOrElement: string|HTMLElement, params: Partial = {}) {\n this.viewer = new Viewer(idOrElement)\n if (!this.viewer.renderer) return\n\n this.tooltip = document.createElement('div')\n Object.assign(this.tooltip.style, {\n display: 'none',\n position: 'fixed',\n zIndex: '1000000',\n pointerEvents: 'none',\n backgroundColor: 'rgba( 0, 0, 0, 0.6 )',\n color: 'lightgrey',\n padding: '8px',\n fontFamily: 'sans-serif'\n })\n this.viewer.container.appendChild(this.tooltip)\n\n this.mouseObserver = new MouseObserver(this.viewer.renderer.domElement)\n this.viewerControls = new ViewerControls(this)\n this.trackballControls = new TrackballControls(this)\n this.pickingControls = new PickingControls(this)\n this.animationControls = new AnimationControls(this)\n this.mouseControls = new MouseControls(this)\n this.keyControls = new KeyControls(this)\n\n this.pickingBehavior = new PickingBehavior(this)\n this.mouseBehavior = new MouseBehavior(this)\n this.animationBehavior = new AnimationBehavior(this)\n this.keyBehavior = new KeyBehavior(this)\n\n this.spinAnimation = this.animationControls.spin([ 0, 1, 0 ], 0.005)\n this.spinAnimation.pause(true)\n this.rockAnimation = this.animationControls.rock([ 0, 1, 0 ], 0.005)\n this.rockAnimation.pause(true)\n\n // must come after the viewer has been instantiated\n this.parameters = createParams(params, StageDefaultParameters)\n this.setParameters(this.parameters)\n\n this.viewer.animate()\n }\n\n /**\n * Set stage parameters\n */\n setParameters (params: Partial = {}) {\n updateParams(this.parameters, params)\n\n const p = params\n const tp = this.parameters\n\n const viewer = this.viewer\n const controls = this.trackballControls\n\n // apply parameters\n if (p.quality !== undefined) this.setQuality(tp.quality)\n if (p.impostor !== undefined) this.setImpostor(tp.impostor)\n if (p.rotateSpeed !== undefined) controls.rotateSpeed = tp.rotateSpeed\n if (p.zoomSpeed !== undefined) controls.zoomSpeed = tp.zoomSpeed\n if (p.panSpeed !== undefined) controls.panSpeed = tp.panSpeed\n if (p.mousePreset !== undefined) this.mouseControls.preset(tp.mousePreset)\n this.mouseObserver.setParameters({ hoverTimeout: tp.hoverTimeout })\n viewer.setClip(tp.clipNear, tp.clipFar, tp.clipDist, tp.clipMode, tp.clipScale)\n viewer.setFog(undefined, tp.fogNear, tp.fogFar)\n viewer.setCamera(tp.cameraType, tp.cameraFov, tp.cameraEyeSep)\n viewer.setSampling(tp.sampleLevel)\n viewer.setBackground(tp.backgroundColor)\n viewer.setLight(tp.lightColor, tp.lightIntensity, tp.ambientColor, tp.ambientIntensity)\n\n this.signals.parametersChanged.dispatch(this.getParameters())\n\n return this\n }\n\n log (msg: string) {\n console.log('STAGE LOG', msg)\n this.logList.push(msg)\n }\n\n /**\n * Get stage parameters\n */\n getParameters () {\n return Object.assign({}, this.parameters)\n }\n\n /**\n * Create default representations for the given component\n * @param {StructureComponent|SurfaceComponent} object - component to create the representations for\n * @return {undefined}\n */\n defaultFileRepresentation (component: Component) {\n if (component instanceof StructureComponent) {\n component.setSelection('/0')\n\n let atomCount, residueCount, instanceCount\n const structure = component.structure\n\n if (structure.biomolDict.BU1) {\n const assembly = structure.biomolDict.BU1\n atomCount = assembly.getAtomCount(structure)\n residueCount = assembly.getResidueCount(structure)\n instanceCount = assembly.getInstanceCount()\n component.setDefaultAssembly('BU1')\n } else {\n atomCount = structure.getModelProxy(0).atomCount\n residueCount = structure.getModelProxy(0).residueCount\n instanceCount = 1\n }\n\n let sizeScore = atomCount\n\n if (Mobile) {\n sizeScore *= 4\n }\n\n const backboneOnly = structure.atomStore.count / structure.residueStore.count < 2\n if (backboneOnly) {\n sizeScore *= 10\n }\n\n let colorScheme = 'chainname'\n let colorScale = 'RdYlBu'\n let colorReverse = false\n if (structure.getChainnameCount(new Selection('polymer and /0')) === 1) {\n colorScheme = 'residueindex'\n colorScale = 'Spectral'\n colorReverse = true\n }\n\n if (Debug) console.log(sizeScore, atomCount, instanceCount, backboneOnly)\n\n if (residueCount / instanceCount < 4) {\n component.addRepresentation('ball+stick', {\n colorScheme: 'element',\n radiusScale: 2.0,\n aspectRatio: 1.5,\n bondScale: 0.3,\n bondSpacing: 0.75,\n quality: 'auto'\n })\n } else if ((instanceCount > 5 && sizeScore > 15000) || sizeScore > 700000) {\n let scaleFactor = (\n Math.min(\n 2.0,\n Math.max(\n 0.1,\n 6000 / (sizeScore / instanceCount)\n )\n )\n )\n if (backboneOnly) scaleFactor = Math.min(scaleFactor, 0.5)\n\n component.addRepresentation('surface', {\n colorScheme, colorScale, colorReverse,\n sele: 'polymer',\n surfaceType: 'av',\n probeRadius: 1.4,\n scaleFactor: scaleFactor,\n useWorker: false\n })\n } else if (sizeScore > 250000) {\n component.addRepresentation('backbone', {\n colorScheme, colorScale, colorReverse,\n lineOnly: true\n })\n } else if (sizeScore > 100000) {\n component.addRepresentation('backbone', {\n colorScheme, colorScale, colorReverse,\n quality: 'low',\n disableImpostor: true,\n radiusScale: 2.0\n })\n } else if (sizeScore > 80000) {\n component.addRepresentation('backbone', {\n colorScheme, colorScale, colorReverse,\n radiusScale: 2.0\n })\n } else {\n component.addRepresentation('cartoon', {\n colorScheme, colorScale, colorReverse,\n radiusScale: 0.7,\n aspectRatio: 5,\n quality: 'auto'\n })\n if (sizeScore < 50000) {\n component.addRepresentation('base', {\n colorScheme, colorScale, colorReverse,\n quality: 'auto'\n })\n }\n component.addRepresentation('ball+stick', {\n sele: 'ligand',\n colorScheme: 'element',\n radiusScale: 2.0,\n aspectRatio: 1.5,\n bondScale: 0.3,\n bondSpacing: 0.75,\n quality: 'auto'\n })\n }\n\n // add frames as trajectory\n if (component.structure.frames.length) {\n component.addTrajectory()\n }\n } else if (component instanceof SurfaceComponent) {\n component.addRepresentation('surface')\n } else if (component instanceof VolumeComponent) {\n component.addRepresentation('surface')\n }\n\n this.tasks.onZeroOnce(this.autoView, this)\n }\n\n /**\n * Load a file onto the stage\n *\n * @example\n * // load from URL\n * stage.loadFile( \"http://files.rcsb.org/download/5IOS.cif\" );\n *\n * @example\n * // load binary data in CCP4 format via a Blob\n * var binaryBlob = new Blob( [ ccp4Data ], { type: 'application/octet-binary'} );\n * stage.loadFile( binaryBlob, { ext: \"ccp4\" } );\n *\n * @example\n * // load string data in PDB format via a Blob\n * var stringBlob = new Blob( [ pdbData ], { type: 'text/plain'} );\n * stage.loadFile( stringBlob, { ext: \"pdb\" } );\n *\n * @example\n * // load a File object\n * stage.loadFile( file );\n *\n * @example\n * // load from URL and add a 'ball+stick' representation with double/triple bonds\n * stage.loadFile( \"http://files.rcsb.org/download/1crn.cif\" ).then( function( comp ){\n * comp.addRepresentation( \"ball+stick\", { multipleBond: true } );\n * } );\n *\n * @param {String|File|Blob} path - either a URL or an object containing the file data\n * @param {LoaderParameters} params - loading parameters\n * @param {Boolean} params.asTrajectory - load multi-model structures as a trajectory\n * @return {Promise} A Promise object that resolves to a {@link StructureComponent},\n * a {@link SurfaceComponent} or a {@link ScriptComponent} object,\n * depending on the type of the loaded file.\n */\n loadFile (path: string|File|Blob, params: Partial = {}) {\n const p = Object.assign({}, this.defaultFileParams, params)\n const name = getFileInfo(path).name\n\n this.tasks.increment()\n this.log(`loading file '${name}'`)\n\n const onLoadFn = (object: Structure|Surface|Volume) => {\n this.log(`loaded '${name}'`)\n\n const component = this.addComponentFromObject(object, p)\n if (p.defaultRepresentation) {\n this.defaultFileRepresentation(component as Component)\n }\n this.tasks.decrement()\n\n return component\n }\n\n const onErrorFn = (e: Error|string) => {\n this.tasks.decrement()\n const errorMsg = `error loading file: '${e}'`\n this.log(errorMsg)\n throw errorMsg // throw so it can be catched\n }\n\n const ext = defaults(p.ext, getFileInfo(path).ext)\n let promise: Promise\n\n if (ParserRegistry.isTrajectory(ext)) {\n promise = Promise.reject(\n new Error(`loadFile: ext '${ext}' is a trajectory and must be loaded into a structure component`)\n )\n } else {\n promise = autoLoad(path, p)\n }\n\n return promise.then(onLoadFn, onErrorFn)\n }\n\n loadScript (path: string|File|Blob) {\n const name = getFileInfo(path).name\n\n this.log(`loading script '${name}'`)\n\n return autoLoad(path).then(\n (script: Script) => {\n this.tasks.increment()\n this.log(`running script '${name}'`)\n script.run(this).then(() => {\n this.tasks.decrement()\n this.log(`finished script '${name}'`)\n })\n this.log(`called script '${name}'`)\n },\n (error: Error|string) => {\n this.tasks.decrement()\n const errorMsg = `errored script '${name}' \"${error}\"`\n this.log(errorMsg)\n throw errorMsg // throw so it can be catched\n }\n )\n }\n\n /**\n * Add the given component to the stage\n * @param {Component} component - the component to add\n * @return {undefined}\n */\n addComponent (component: Component) {\n if (!component) {\n Log.warn('Stage.addComponent: no component given')\n return\n }\n\n this.compList.push(component)\n this.signals.componentAdded.dispatch(component)\n }\n\n /**\n * Create a component from the given object and add to the stage\n */\n addComponentFromObject (object: Structure|Surface|Volume|Shape, params: Partial = {}): void|Component {\n const CompClass = ComponentRegistry.get(object.type)\n\n if (CompClass) {\n const component = new CompClass(this, object, params)\n this.addComponent(component)\n return component\n }\n\n Log.warn('no component for object type', object.type)\n }\n\n /**\n * Remove the given component\n * @param {Component} component - the component to remove\n * @return {undefined}\n */\n removeComponent (component: Component) {\n const idx = this.compList.indexOf(component)\n if (idx !== -1) {\n this.compList.splice(idx, 1)\n component.dispose()\n this.signals.componentRemoved.dispatch(component)\n }\n }\n\n /**\n * Remove all components from the stage\n */\n removeAllComponents () {\n this.compList.slice().forEach(o => this.removeComponent(o))\n }\n\n /**\n * Handle any size-changes of the container element\n * @return {undefined}\n */\n handleResize () {\n this.viewer.handleResize()\n }\n\n /**\n * Set width and height\n * @param {String} width - CSS width value\n * @param {String} height - CSS height value\n * @return {undefined}\n */\n setSize (width: string, height: string) {\n const container = this.viewer.container\n\n if (container !== document.body) {\n if (width !== undefined) container.style.width = width\n if (height !== undefined) container.style.height = height\n this.handleResize()\n }\n }\n\n /**\n * Toggle fullscreen\n * @param {Element} [element] - document element to put into fullscreen,\n * defaults to the viewer container\n * @return {undefined}\n */\n toggleFullscreen (element: HTMLElement) {\n if (!document.fullscreenEnabled && !document.mozFullScreenEnabled &&\n !(document as any).webkitFullscreenEnabled && !document.msFullscreenEnabled\n ) {\n Log.log('fullscreen mode (currently) not possible')\n return\n }\n\n const self = this\n element = element || this.viewer.container\n this.lastFullscreenElement = element\n\n //\n\n function getFullscreenElement () {\n return document.fullscreenElement || document.mozFullScreenElement ||\n (document as any).webkitFullscreenElement || document.msFullscreenElement\n }\n\n function resizeElement () {\n if (!getFullscreenElement() && self.lastFullscreenElement) {\n const element = self.lastFullscreenElement\n element.style.width = element.dataset.normalWidth || ''\n element.style.height = element.dataset.normalHeight || ''\n\n document.removeEventListener('fullscreenchange', resizeElement)\n document.removeEventListener('mozfullscreenchange', resizeElement)\n document.removeEventListener('webkitfullscreenchange', resizeElement)\n document.removeEventListener('MSFullscreenChange', resizeElement)\n\n self.handleResize()\n self.signals.fullscreenChanged.dispatch(false)\n }\n }\n\n //\n\n if (!getFullscreenElement()) {\n element.dataset.normalWidth = element.style.width || ''\n element.dataset.normalHeight = element.style.height || ''\n element.style.width = window.screen.width + 'px'\n element.style.height = window.screen.height + 'px'\n\n if (element.requestFullscreen) {\n element.requestFullscreen()\n } else if (element.msRequestFullscreen) {\n element.msRequestFullscreen()\n } else if (element.mozRequestFullScreen) {\n element.mozRequestFullScreen()\n } else if ((element as any).webkitRequestFullscreen) {\n (element as any).webkitRequestFullscreen()\n }\n\n document.addEventListener('fullscreenchange', resizeElement)\n document.addEventListener('mozfullscreenchange', resizeElement)\n document.addEventListener('webkitfullscreenchange', resizeElement)\n document.addEventListener('MSFullscreenChange', resizeElement)\n\n this.handleResize()\n this.signals.fullscreenChanged.dispatch(true)\n\n // workaround for Safari\n setTimeout(function () { self.handleResize() }, 100)\n } else {\n if (document.exitFullscreen) {\n document.exitFullscreen()\n } else if (document.msExitFullscreen) {\n document.msExitFullscreen()\n } else if (document.mozCancelFullScreen) {\n document.mozCancelFullScreen()\n } else if ((document as any).webkitExitFullscreen) {\n (document as any).webkitExitFullscreen()\n }\n }\n }\n\n /**\n * Set spin\n * @param {Boolean} flag - if true start rocking and stop spinning\n * @return {undefined}\n */\n setSpin (flag: boolean) {\n if (flag) {\n this.spinAnimation.resume(true)\n this.rockAnimation.pause(true)\n } else {\n this.spinAnimation.pause(true)\n }\n }\n\n /**\n * Set rock\n * @param {Boolean} flag - if true start rocking and stop spinning\n * @return {undefined}\n */\n setRock (flag: boolean) {\n if (flag) {\n this.rockAnimation.resume(true)\n this.spinAnimation.pause(true)\n } else {\n this.rockAnimation.pause(true)\n }\n }\n\n /**\n * Toggle spin\n * @return {undefined}\n */\n toggleSpin () {\n this.setSpin(this.spinAnimation.paused)\n }\n\n /**\n * Toggle rock\n * @return {undefined}\n */\n toggleRock () {\n this.setRock(this.rockAnimation.paused)\n }\n\n /**\n * Get the current focus from the current clipNear value expressed\n * as 0 (full view) to 100 (completely clipped)\n * Negative values may be returned in some cases.\n *\n * In 'camera' clipMode focus isn't applicable, this method returns 0.0\n *\n * @return {number} focus\n */\n getFocus () : number {\n const p = this.parameters\n if (p.clipMode !== 'scene') return 0.0\n\n let clipNear = p.clipNear\n if (p.clipScale === 'absolute') {\n clipNear = this.viewer.absoluteToRelative(clipNear)\n }\n return clipNear * 2\n }\n\n\n /**\n * Set the focus, a value of 0 sets clipping planes to show full scene,\n * while a value of 100 will compltely clip the scene.\n *\n * @param {number} value focus\n */\n setFocus (value: number) {\n if (this.parameters.clipMode !== 'scene') return\n\n let clipNear\n let clipFar\n let fogNear\n let fogFar\n\n if (this.parameters.clipScale === 'relative') {\n clipNear = clamp(value / 2.0, 0.0, 49.9)\n clipFar = 100 - clipNear\n fogNear = 50\n fogFar = pclamp(2 * clipFar - 50)\n\n } else {\n clipNear = this.viewer.relativeToAbsolute(value / 2.0)\n clipFar = clipNear\n fogNear = 0\n fogFar = 2 * clipFar\n }\n\n this.setParameters({ clipNear, clipFar, fogNear, fogFar })\n }\n\n getZoomForBox (boundingBox: Box3) {\n const bbSize = boundingBox.getSize(tmpZoomVector)\n const maxSize = Math.max(bbSize.x, bbSize.y, bbSize.z)\n const minSize = Math.min(bbSize.x, bbSize.y, bbSize.z)\n let distance = maxSize + Math.sqrt(minSize)\n\n const fov = degToRad(this.viewer.perspectiveCamera.fov)\n const width = this.viewer.width\n const height = this.viewer.height\n const aspect = width / height\n const aspectFactor = (height < width ? 1 : aspect)\n\n distance = Math.abs(\n ((distance * 0.5) / aspectFactor) / Math.sin(fov / 2)\n )\n distance += this.parameters.clipDist\n return -distance\n }\n\n getBox () {\n return this.viewer.boundingBox\n }\n\n getZoom () {\n return this.getZoomForBox(this.getBox())\n }\n\n getCenter (optionalTarget?: Vector3) {\n return this.getBox().getCenter(optionalTarget || new Vector3())\n }\n\n /**\n * Add a zoom and a move animation with automatic targets\n * @param {Integer} duration - animation time in milliseconds\n * @return {undefined}\n */\n autoView (duration?: number) {\n this.animationControls.zoomMove(\n this.getCenter(),\n this.getZoom(),\n defaults(duration, 0)\n )\n }\n\n /**\n * Make image from what is shown in a viewer canvas\n */\n makeImage (params: Partial = {}) {\n return new Promise((resolve, reject) => {\n this.tasks.onZeroOnce(() => {\n this.tasks.increment()\n this.viewer.makeImage(params).then(blob => {\n this.tasks.decrement()\n resolve(blob)\n }).catch(e => {\n this.tasks.decrement()\n reject(e)\n })\n })\n })\n }\n\n setImpostor (value: boolean) {\n this.parameters.impostor = value\n\n const types = [\n 'spacefill', 'ball+stick', 'licorice', 'hyperball',\n 'backbone', 'rocket', 'helixorient', 'contact', 'distance',\n 'dot'\n ]\n\n this.eachRepresentation(function (reprElem) {\n if (!types.includes(reprElem.getType())) return\n\n const p = reprElem.getParameters() as any // TODO\n p.disableImpostor = !value\n reprElem.build(p)\n })\n }\n\n setQuality (value: RenderQualityType) {\n this.parameters.quality = value\n\n const types = [\n 'tube', 'cartoon', 'ribbon', 'trace', 'rope'\n ]\n\n const impostorTypes = [\n 'spacefill', 'ball+stick', 'licorice', 'hyperball',\n 'backbone', 'rocket', 'helixorient', 'contact', 'distance',\n 'dot'\n ]\n\n this.eachRepresentation(function (repr) {\n const p = repr.getParameters() as any // TODO\n\n if (!types.includes(repr.getType())) {\n if (!impostorTypes.includes(repr.getType())) return\n\n if (!p.disableImpostor) {\n (repr.repr as any).quality = value // TODO\n return\n }\n }\n\n p.quality = value\n repr.build(p)\n })\n }\n\n /**\n * Iterator over each component and executing the callback\n */\n eachComponent (callback: (comp: Component) => void, type?: string) {\n this.compList.slice().forEach(comp => {\n if (type === undefined || type === comp.type) callback(comp)\n })\n }\n\n /**\n * Iterator over each representation and executing the callback\n */\n eachRepresentation (callback: (reprElem: RepresentationElement, comp: Component) => void, type?: string) {\n this.eachComponent(comp => {\n comp.reprList.slice().forEach(reprElem => {\n if (type === undefined || type === reprElem.getType()) callback(reprElem, comp)\n })\n })\n }\n\n /**\n * Get collection of components by name\n */\n getComponentsByName (name: string|RegExp) {\n const compList: Component[] = []\n\n this.eachComponent(comp => {\n if (name === undefined || matchName(name, comp)) compList.push(comp)\n })\n\n return new ComponentCollection(compList)\n }\n\n /**\n * Get collection of components by object\n */\n getComponentsByObject (object: Structure|Surface|Volume|Shape) {\n const compList: Component[] = []\n\n this.eachComponent(comp => {\n if (comp.object === object) compList.push(comp)\n })\n\n return new ComponentCollection(compList)\n }\n\n /**\n * Get collection of representations by name\n */\n getRepresentationsByName (name: string|RegExp) {\n const reprList: RepresentationElement[] = []\n\n this.eachRepresentation((repr, comp) => {\n if (name === undefined || matchName(name, repr)) reprList.push(repr)\n })\n\n return new RepresentationCollection(reprList)\n }\n\n measureClear () {\n this.eachComponent((sc: StructureComponent) => sc.measureClear(), 'structure')\n }\n\n measureUpdate () {\n this.eachComponent((sc: StructureComponent) => sc.measureUpdate(), 'structure')\n }\n\n /**\n * Cleanup when disposing of a stage object\n */\n dispose () {\n this.tasks.dispose()\n this.viewer.dispose()\n this.mouseObserver.dispose()\n }\n}\n\nexport default Stage\n","/**\n * @file Shape Component\n * @author Alexander Rose \n * @private\n */\n\nimport { ComponentRegistry } from '../globals'\nimport Component, { ComponentParameters } from './component'\nimport Stage from '../stage/stage'\nimport Shape from '../geometry/shape'\nimport { Vector3, Box3 } from 'three';\nimport RepresentationElement from './representation-element';\n\nexport type ShapeRepresentationType = 'buffer'\n\n/**\n * Component wrapping a {@link Shape} object\n *\n * @example\n * // get a shape component by adding a shape object to the stage\n * var shape = new NGL.Shape( \"shape\" );\n * shape.addSphere( [ 0, 0, 0 ], [ 1, 0, 0 ], 1.5 );\n * var shapeComponent = stage.addComponentFromObject( shape );\n * shapeComponent.addRepresentation( \"buffer\" );\n */\nclass ShapeComponent extends Component {\n constructor (stage: Stage, readonly shape: Shape, params: Partial = {}) {\n super(stage, shape, Object.assign({ name: shape.name }, params))\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'shape' }\n\n /**\n * Add a new shape representation to the component\n * @param {String} type - the name of the representation, one of:\n * buffer.\n * @param {BufferRepresentationParameters} params - representation parameters\n * @return {RepresentationComponent} the created representation wrapped into\n * a representation component object\n */\n addRepresentation (type: ShapeRepresentationType, params: { [k: string]: any } = {}): RepresentationElement {\n return this._addRepresentation(type, this.shape, params)\n }\n\n getBoxUntransformed (): Box3 {\n return this.shape.boundingBox\n }\n\n getCenterUntransformed (): Vector3 {\n return this.shape.center\n }\n\n dispose () {\n this.shape.dispose()\n super.dispose()\n }\n}\n\nComponentRegistry.add('shape', ShapeComponent)\n\nexport default ShapeComponent\n","/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n}\r\n","/**\n * @file Atomindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\n/**\n * Color by atom index. The {@link AtomProxy.index} property is used for coloring.\n * Each {@link ModelProxy} of a {@link Structure} is colored seperately. The\n * `params.domain` parameter is ignored.\n *\n * __Name:__ _atomindex_\n *\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"ball+stick\", { colorScheme: \"atomindex\" } );\n * o.autoView();\n * } );\n */\nclass AtomindexColormaker extends Colormaker {\n scalePerModel: { [k: number]: ColormakerScale }\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rainbow'\n this.parameters.reverse = defaults(params.reverse, true)\n }\n\n this.scalePerModel = {}\n\n params.structure.eachModel((mp: ModelProxy) => {\n this.parameters.domain = [ mp.atomOffset, mp.atomEnd ]\n this.scalePerModel[ mp.index ] = this.getScale() // TODO\n })\n }\n\n /**\n * get color for an atom\n * @param {AtomProxy} atom - atom to get color for\n * @return {Integer} hex atom color\n */\n @manageColor\n atomColor (atom: AtomProxy) {\n return this.scalePerModel[ atom.modelIndex ](atom.index)\n }\n}\n\nColormakerRegistry.add('atomindex', AtomindexColormaker)\n\nexport default AtomindexColormaker\n","/**\n * @file Bfactor Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Selection from '../selection/selection'\n\n/**\n * Color by b-factor. The {@link AtomProxy.bfactor} property is used for coloring.\n * By default the min and max b-factor values are used for the scale`s domain.\n *\n * __Name:__ _bfactor_\n *\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"ball+stick\", { colorScheme: \"bfactor\" } );\n * o.autoView();\n * } );\n */\nclass BfactorColormaker extends Colormaker {\n bfactorScale: ColormakerScale\n\n constructor (params: { sele?: string } & StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'OrRd'\n }\n\n if (!params.domain) {\n let selection\n let min = Infinity\n let max = -Infinity\n\n if (params.sele) {\n selection = new Selection(params.sele)\n }\n\n params.structure.eachAtom(function (a) {\n const bfactor = a.bfactor\n min = Math.min(min, bfactor)\n max = Math.max(max, bfactor)\n }, selection)\n\n this.parameters.domain = [ min, max ]\n }\n\n this.bfactorScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.bfactorScale(a.bfactor)\n }\n}\n\nColormakerRegistry.add('bfactor', BfactorColormaker)\n\nexport default BfactorColormaker\n","/**\n * @file Chainid Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\nexport type ChainidDict = { [k: string]: number }\n\n/**\n * Color by chain id\n */\nclass ChainidColormaker extends Colormaker {\n chainidDictPerModel: { [k: number]: ChainidDict } = {}\n scalePerModel: { [k: number]: ColormakerScale } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'Spectral'\n }\n\n params.structure.eachModel((mp: ModelProxy) => {\n let i = 0\n const chainidDict: ChainidDict = {}\n mp.eachChain(function (cp: ChainProxy) {\n if (chainidDict[ cp.chainid ] === undefined) {\n chainidDict[ cp.chainid ] = i\n i += 1\n }\n })\n this.parameters.domain = [ 0, i - 1 ]\n this.chainidDictPerModel[ mp.index ] = chainidDict\n this.scalePerModel[ mp.index ] = this.getScale()\n })\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n const chainidDict = this.chainidDictPerModel[ a.modelIndex ]\n return this.scalePerModel[ a.modelIndex ](chainidDict[ a.chainid ])\n }\n}\n\nColormakerRegistry.add('chainid', ChainidColormaker)\n\nexport default ChainidColormaker\n","/**\n * @file Chainindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\n/**\n * Color by chain index\n */\nclass ChainindexColormaker extends Colormaker {\n scalePerModel: { [k: number]: ColormakerScale } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'Spectral'\n }\n\n params.structure.eachModel((mp: ModelProxy) => {\n this.parameters.domain = [ mp.chainOffset, mp.chainEnd ]\n this.scalePerModel[ mp.index ] = this.getScale()\n })\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.scalePerModel[ a.modelIndex ](a.chainIndex)\n }\n}\n\nColormakerRegistry.add('chainindex', ChainindexColormaker)\n\nexport default ChainindexColormaker\n","/**\n * @file Chainname Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\nexport type ChainnameDict = { [k: string]: number }\n\n/**\n * Color by chain name\n */\nclass ChainnameColormaker extends Colormaker {\n chainnameDictPerModel: { [k: number]: ChainnameDict } = {}\n scalePerModel: { [k: number]: ColormakerScale } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'Spectral'\n }\n\n params.structure.eachModel((mp: ModelProxy) => {\n let i = 0\n const chainnameDict: ChainnameDict = {}\n mp.eachChain(function (cp: ChainProxy) {\n if (chainnameDict[ cp.chainname ] === undefined) {\n chainnameDict[ cp.chainname ] = i\n i += 1\n }\n })\n this.parameters.domain = [ 0, i - 1 ]\n this.chainnameDictPerModel[ mp.index ] = chainnameDict\n this.scalePerModel[ mp.index ] = this.getScale()\n })\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n const chainnameDict = this.chainnameDictPerModel[ a.modelIndex ]\n return this.scalePerModel[ a.modelIndex ](chainnameDict[ a.chainname ])\n }\n}\n\nColormakerRegistry.add('chainname', ChainnameColormaker)\n\nexport default ChainnameColormaker\n","/**\n * @file Densityfit Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by validation density fit\n */\nclass DensityfitColormaker extends Colormaker {\n rsrzScale: ColormakerScale\n rsccScale: ColormakerScale\n\n rsrzDict: { [k: string]: number|undefined } = {}\n rsccDict: { [k: string]: number|undefined } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'RdYlBu'\n }\n\n this.rsrzScale = this.getScale({ domain: [ 2, 0 ] })\n this.rsccScale = this.getScale({ domain: [ 0.678, 1.0 ] })\n\n const val = params.structure.validation\n if (val) {\n this.rsrzDict = val.rsrzDict\n this.rsccDict = val.rsccDict\n }\n\n }\n\n @manageColor\n atomColor (atom: AtomProxy) {\n let sele = atom.resno + ''\n if (atom.inscode) sele += '^' + atom.inscode\n if (atom.chainname) sele += ':' + atom.chainname\n sele += '/' + atom.modelIndex\n\n const rsrz = this.rsrzDict[ sele ]\n if (rsrz !== undefined) {\n return this.rsrzScale(rsrz)\n }\n\n const rscc = this.rsccDict[ sele ]\n if (rscc !== undefined) {\n return this.rsccScale(rscc)\n }\n\n return 0x909090\n }\n}\n\nColormakerRegistry.add('densityfit', DensityfitColormaker)\n\nexport default DensityfitColormaker\n","/**\n * @file Atomindex Colormaker\n * @author Fred Ludlow \n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport SpatialHash from '../geometry/spatial-hash'\n\n// from CHARMM\nconst partialCharges: { [k: string]: { [k: string]: number } } = {\n 'ARG': {\n 'CD': 0.1,\n 'CZ': 0.5,\n 'NE': -0.1\n },\n 'ASN': {\n 'CG': 0.55,\n 'OD1': -0.55\n },\n 'ASP': {\n 'CB': -0.16,\n 'CG': 0.36,\n 'OD1': -0.6,\n 'OD2': -0.6\n },\n 'CYS': {\n 'CB': 0.19,\n 'SG': -0.19\n },\n 'GLN': {\n 'CD': 0.55,\n 'OE1': -0.55\n },\n 'GLU': {\n 'CD': 0.36,\n 'CG': -0.16,\n 'OE1': -0.6,\n 'OE2': -0.6\n },\n 'HIS': {\n 'CB': 0.1,\n 'CD2': 0.2,\n 'CE1': 0.45,\n 'CG': 0.15,\n 'ND1': 0.05,\n 'NE2': 0.05\n },\n 'LYS': {\n 'CE': 0.25,\n 'NZ': 0.75\n },\n 'MET': {\n 'CE': 0.06,\n 'CG': 0.06,\n 'SD': -0.12\n },\n 'PTR': {\n 'C': 0.55,\n 'CA': 0.1,\n 'CZ': 0.25,\n 'N': -0.35,\n 'O': -0.55,\n 'O1P': -0.85,\n 'O2P': -0.85,\n 'O3P': -0.85,\n 'OG1': -1.1,\n 'P': 1.4\n },\n 'SEP': {\n 'C': 0.55,\n 'CA': 0.1,\n 'CB': 0.25,\n 'N': -0.35,\n 'O': -0.55,\n 'O1P': -0.85,\n 'O2P': -0.85,\n 'O3P': -0.85,\n 'OG1': -1.1,\n 'P': 1.4\n },\n 'SER': {\n 'CB': 0.25,\n 'OG': -0.25\n },\n 'THR': {\n 'CB': 0.25,\n 'OG1': -0.25\n },\n 'TPO': {\n 'C': 0.55,\n 'CA': 0.1,\n 'CB': 0.25,\n 'N': -0.35,\n 'O': -0.55,\n 'OG1': -1.1,\n 'O1P': -0.85,\n 'O2P': -0.85,\n 'O3P': -0.85,\n 'P': 1.4\n },\n 'TRP': {\n 'CD1': 0.06,\n 'CD2': 0.1,\n 'CE2': -0.04,\n 'CE3': -0.03,\n 'CG': -0.03,\n 'NE1': -0.06\n },\n 'TYR': {\n 'CZ': 0.25,\n 'OH': -0.25\n },\n 'backbone': {\n 'C': 0.55,\n 'O': -0.55,\n 'N': -0.35,\n 'CA': 0.1\n }\n}\n\nconst maxRadius = 12.0\nconst nHBondDistance = 1.04\nconst nHCharge = 0.25\n\n/**\n * Populates position vector with location of implicit or explicit H\n * Returns position or undefined if not able to locate H\n *\n * @param {AtomProxy} ap - the nitrogen atom\n * @param {Vector3} [position] - optional target\n * @return {Vectors|undefined} the hydrogen atom position\n */\nfunction backboneNHPosition (ap: AtomProxy, position = new Vector3()) {\n let h = false\n let ca = false\n let c = false\n position.set(2 * ap.x, 2 * ap.y, 2 * ap.z)\n\n ap.eachBondedAtom(function (a2: AtomProxy) {\n // Any time we detect H, reset position and skip\n // future tests\n if (h) return\n if (a2.atomname === 'H') {\n position.set(a2.x, a2.y, a2.z)\n h = true\n return\n }\n if (!ca && a2.atomname === 'CA') {\n position.sub(a2 as any) // TODO\n ca = true\n } else if (!c && a2.atomname === 'C') {\n c = true\n position.sub(a2 as any) // TODO\n }\n })\n\n if (h) { return position }\n\n if (ca && c) {\n position.normalize()\n position.multiplyScalar(nHBondDistance)\n position.add(ap as any)\n return position\n }\n}\n\n/**\n * Takes an array of Vector3 objects and\n * converts to an object that looks like an AtomStore\n *\n * @param {Vector3[]} positions - array of positions\n * @return {Object} AtomStore-like object\n */\nfunction buildStoreLike (positions: Vector3[]) {\n const n = positions.length\n const x = new Float32Array(n)\n const y = new Float32Array(n)\n const z = new Float32Array(n)\n\n for (let i = 0; i < positions.length; i++) {\n const v = positions[ i ]\n x[ i ] = v.x\n y[ i ] = v.y\n z[ i ] = v.z\n }\n\n return { x: x, y: y, z: z, count: n }\n}\n\nfunction chargeForAtom (a: AtomProxy): number {\n if (a.partialCharge !== null) return a.partialCharge\n if (!a.isProtein()) { return 0.0 }\n return (\n (partialCharges[ a.resname ] &&\n partialCharges[ a.resname ][ a.atomname ]) ||\n partialCharges[ 'backbone' ][ a.atomname ] || 0.0\n )\n}\n\n/**\n * Color a surface by electrostatic charge. This is a highly approximate\n * calculation! The partial charges are CHARMM with hydrogens added to heavy\n * atoms and hydrogen positions generated for amides.\n *\n * __Name:__ _electrostatic_\n *\n * @example\n * stage.loadFile( \"rcsb://3dqb\" ).then( function( o ){\n * o.addRepresentation( \"surface\", { colorScheme: \"electrostatic\" } );\n * o.autoView();\n * } );\n */\nclass ElectrostaticColormaker extends Colormaker {\n scale: ColormakerScale\n hHash: SpatialHash\n hash: SpatialHash\n charges: Float32Array\n hStore: { x: Float32Array, y: Float32Array, z: Float32Array, count: number }\n atomProxy: AtomProxy\n\n delta = new Vector3()\n hCharges: number[] = []\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rwb'\n }\n if (!params.domain) {\n this.parameters.domain = [ -50, 50 ]\n }\n\n this.scale = this.getScale()\n\n this.charges = new Float32Array(params.structure.atomCount)\n const hPositions: Vector3[] = []\n\n params.structure.eachAtom((ap: AtomProxy) => {\n this.charges[ ap.index ] = chargeForAtom(ap) * ap.occupancy\n if (ap.atomname === 'N') {\n\n // In the specific case where N forms two bonds to\n // CA and C, try and place a dummy hydrogen\n\n if (ap.bondCount >= 3) return; // Skip if 3 bonds already (e.g. PRO)\n\n if (ap.bondToElementCount(1)) return; // Skip if any H specificed\n\n const hPos = backboneNHPosition(ap)\n if (hPos !== undefined) {\n hPositions.push(hPos)\n this.hCharges.push(nHCharge * ap.occupancy)\n }\n }\n })\n\n const bbox = params.structure.getBoundingBox()\n bbox.expandByScalar(nHBondDistance) // Worst case\n\n // SpatialHash requires x,y,z and count\n this.hStore = buildStoreLike(hPositions)\n this.hHash = new SpatialHash(this.hStore as any, bbox) // TODO\n this.hash = new SpatialHash(params.structure.atomStore, bbox)\n }\n\n @manageColor\n positionColor (v: Vector3) {\n\n const charges = this.charges\n const hCharges = this.hCharges\n\n let p = 0.0\n this.hash.eachWithin(v.x, v.y, v.z, maxRadius, (atomIndex, dSq) => {\n const charge = charges[atomIndex]\n if (charge === 0.0) return\n p += charge / dSq\n })\n\n this.hHash.eachWithin(v.x, v.y, v.z, maxRadius, (atomIndex, dSq) => {\n const charge = hCharges[atomIndex]\n if (charge === 0.0) return\n p += charge / dSq\n })\n\n return this.scale(p * 332) // 332 to convert to kcal/mol\n }\n}\n\nColormakerRegistry.add('electrostatic', ElectrostaticColormaker)\n\nexport default ElectrostaticColormaker\n","/**\n * @file Element Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Colormaker, { ColormakerParameters, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n// from Jmol http://jmol.sourceforge.net/jscolors/ (or 0xFFFFFF)\nconst ElementColors: { [k: string]: number } = {\n 'H': 0xFFFFFF,\n 'HE': 0xD9FFFF,\n 'LI': 0xCC80FF,\n 'BE': 0xC2FF00,\n 'B': 0xFFB5B5,\n 'C': 0x909090,\n 'N': 0x3050F8,\n 'O': 0xFF0D0D,\n 'F': 0x90E050,\n 'NE': 0xB3E3F5,\n 'NA': 0xAB5CF2,\n 'MG': 0x8AFF00,\n 'AL': 0xBFA6A6,\n 'SI': 0xF0C8A0,\n 'P': 0xFF8000,\n 'S': 0xFFFF30,\n 'CL': 0x1FF01F,\n 'AR': 0x80D1E3,\n 'K': 0x8F40D4,\n 'CA': 0x3DFF00,\n 'SC': 0xE6E6E6,\n 'TI': 0xBFC2C7,\n 'V': 0xA6A6AB,\n 'CR': 0x8A99C7,\n 'MN': 0x9C7AC7,\n 'FE': 0xE06633,\n 'CO': 0xF090A0,\n 'NI': 0x50D050,\n 'CU': 0xC88033,\n 'ZN': 0x7D80B0,\n 'GA': 0xC28F8F,\n 'GE': 0x668F8F,\n 'AS': 0xBD80E3,\n 'SE': 0xFFA100,\n 'BR': 0xA62929,\n 'KR': 0x5CB8D1,\n 'RB': 0x702EB0,\n 'SR': 0x00FF00,\n 'Y': 0x94FFFF,\n 'ZR': 0x94E0E0,\n 'NB': 0x73C2C9,\n 'MO': 0x54B5B5,\n 'TC': 0x3B9E9E,\n 'RU': 0x248F8F,\n 'RH': 0x0A7D8C,\n 'PD': 0x006985,\n 'AG': 0xC0C0C0,\n 'CD': 0xFFD98F,\n 'IN': 0xA67573,\n 'SN': 0x668080,\n 'SB': 0x9E63B5,\n 'TE': 0xD47A00,\n 'I': 0x940094,\n 'XE': 0x940094,\n 'CS': 0x57178F,\n 'BA': 0x00C900,\n 'LA': 0x70D4FF,\n 'CE': 0xFFFFC7,\n 'PR': 0xD9FFC7,\n 'ND': 0xC7FFC7,\n 'PM': 0xA3FFC7,\n 'SM': 0x8FFFC7,\n 'EU': 0x61FFC7,\n 'GD': 0x45FFC7,\n 'TB': 0x30FFC7,\n 'DY': 0x1FFFC7,\n 'HO': 0x00FF9C,\n 'ER': 0x00E675,\n 'TM': 0x00D452,\n 'YB': 0x00BF38,\n 'LU': 0x00AB24,\n 'HF': 0x4DC2FF,\n 'TA': 0x4DA6FF,\n 'W': 0x2194D6,\n 'RE': 0x267DAB,\n 'OS': 0x266696,\n 'IR': 0x175487,\n 'PT': 0xD0D0E0,\n 'AU': 0xFFD123,\n 'HG': 0xB8B8D0,\n 'TL': 0xA6544D,\n 'PB': 0x575961,\n 'BI': 0x9E4FB5,\n 'PO': 0xAB5C00,\n 'AT': 0x754F45,\n 'RN': 0x428296,\n 'FR': 0x420066,\n 'RA': 0x007D00,\n 'AC': 0x70ABFA,\n 'TH': 0x00BAFF,\n 'PA': 0x00A1FF,\n 'U': 0x008FFF,\n 'NP': 0x0080FF,\n 'PU': 0x006BFF,\n 'AM': 0x545CF2,\n 'CM': 0x785CE3,\n 'BK': 0x8A4FE3,\n 'CF': 0xA136D4,\n 'ES': 0xB31FD4,\n 'FM': 0xB31FBA,\n 'MD': 0xB30DA6,\n 'NO': 0xBD0D87,\n 'LR': 0xC70066,\n 'RF': 0xCC0059,\n 'DB': 0xD1004F,\n 'SG': 0xD90045,\n 'BH': 0xE00038,\n 'HS': 0xE6002E,\n 'MT': 0xEB0026,\n 'DS': 0xFFFFFF,\n 'RG': 0xFFFFFF,\n 'CN': 0xFFFFFF,\n 'UUT': 0xFFFFFF,\n 'FL': 0xFFFFFF,\n 'UUP': 0xFFFFFF,\n 'LV': 0xFFFFFF,\n 'UUH': 0xFFFFFF,\n\n 'D': 0xFFFFC0,\n 'T': 0xFFFFA0\n}\nconst DefaultElementColor = 0xFFFFFF\n\n/**\n * Color by element\n */\nclass ElementColormaker extends Colormaker {\n constructor (params: ColormakerParameters) {\n params.value = defaults(params.value, ElementColors.C)\n\n super(params)\n }\n\n\n @manageColor\n atomColor (a: AtomProxy) {\n const element = a.element\n\n if (element === 'C') {\n return this.parameters.value\n } else {\n return ElementColors[ element ] || DefaultElementColor\n }\n }\n}\n\nColormakerRegistry.add('element', ElementColormaker)\n\nexport default ElementColormaker\n","/**\n * @file Entityindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by entity index\n */\nclass EntityindexColormaker extends Colormaker {\n entityindexScale: ColormakerScale\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'Spectral'\n }\n if (!params.domain) {\n this.parameters.domain = [ 0, params.structure.entityList.length - 1 ]\n }\n\n this.entityindexScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.entityindexScale(a.entityIndex)\n }\n}\n\nColormakerRegistry.add('entityindex', EntityindexColormaker)\n\nexport default EntityindexColormaker\n","/**\n * @file Entitytype Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\nimport {\n PolymerEntity, NonPolymerEntity, MacrolideEntity, WaterEntity\n} from '../structure/structure-constants'\n\n/**\n * Color by entity type\n */\nclass EntitytypeColormaker extends Colormaker {\n @manageColor\n atomColor (a: AtomProxy) {\n const e = a.entity\n const et = e ? e.entityType : undefined\n switch (et) {\n case PolymerEntity:\n return 0x7fc97f\n case NonPolymerEntity:\n return 0xfdc086\n case MacrolideEntity:\n return 0xbeaed4\n case WaterEntity:\n return 0x386cb0\n default:\n return 0xffff99\n }\n }\n}\n\nColormakerRegistry.add('entitytype', EntitytypeColormaker)\n\nexport default EntitytypeColormaker\n","/**\n * @file Geoquality Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport { countSetBits } from '../math/math-utils'\n\n/**\n * Color by validation gometry quality\n */\nclass GeoqualityColormaker extends Colormaker {\n geoAtomDict: { [k: string]: { [k: string]: number } } = {}\n geoDict: { [k: string]: number|undefined } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n const val = params.structure.validation\n if (val) {\n this.geoAtomDict = val.geoAtomDict\n this.geoDict = val.geoDict\n }\n }\n\n @manageColor\n atomColor (atom: AtomProxy) {\n let sele = atom.resno + ''\n if (atom.inscode) sele += '^' + atom.inscode\n if (atom.chainname) sele += ':' + atom.chainname\n sele += '/' + atom.modelIndex\n\n let geoProblemCount\n const geoAtom = this.geoAtomDict[ sele ]\n if (geoAtom !== undefined) {\n const atomProblems: number = geoAtom[ atom.atomname ] || 0\n geoProblemCount = countSetBits(atomProblems)\n } else {\n geoProblemCount = this.geoDict[ sele ] || 0\n }\n\n if (geoProblemCount === 0) {\n return 0x2166ac\n } else if (geoProblemCount === 1) {\n return 0xfee08b\n } else if (geoProblemCount === 2) {\n return 0xf46d43\n } else if (geoProblemCount >= 3) {\n return 0xa50026\n }\n return 0x909090\n }\n}\n\nColormakerRegistry.add('geoquality', GeoqualityColormaker)\n\nexport default GeoqualityColormaker\n","/**\n * @file Hydrophobicity Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { ColormakerParameters, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\nimport {\n ResidueHydrophobicity, DefaultResidueHydrophobicity\n} from '../structure/structure-constants'\n\n/**\n * Color by hydrophobicity\n */\nclass HydrophobicityColormaker extends Colormaker {\n hfScale: ColormakerScale\n resHF: { [k: string]: number } = {}\n defaultResidueHydrophobicity: number\n\n constructor (params: ColormakerParameters) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'RdYlGn'\n }\n\n const idx = 0 // 0: DGwif, 1: DGwoct, 2: Oct-IF\n\n for (const name in ResidueHydrophobicity) {\n this.resHF[ name ] = ResidueHydrophobicity[ name ][ idx ]\n }\n this.defaultResidueHydrophobicity = DefaultResidueHydrophobicity[idx]\n\n if (!params.domain) {\n let min = Infinity\n let max = -Infinity\n\n for (const name in this.resHF) {\n const val = this.resHF[ name ]\n min = Math.min(min, val)\n max = Math.max(max, val)\n }\n\n this.parameters.domain = [ min, 0, max ]\n }\n\n this.hfScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.hfScale(this.resHF[ a.resname ] || this.defaultResidueHydrophobicity)\n }\n}\n\nColormakerRegistry.add('hydrophobicity', HydrophobicityColormaker)\n\nexport default HydrophobicityColormaker\n","/**\n * @file Modelindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by model index\n */\nclass ModelindexColormaker extends Colormaker {\n modelindexScale: ColormakerScale\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rainbow'\n }\n if (!params.domain) {\n this.parameters.domain = [ 0, params.structure.modelStore.count ]\n }\n\n this.modelindexScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.modelindexScale(a.modelIndex)\n }\n}\n\nColormakerRegistry.add('modelindex', ModelindexColormaker)\n\nexport default ModelindexColormaker\n","/**\n * @file Moleculetype Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\nimport {\n WaterType, IonType, ProteinType, RnaType, DnaType, SaccharideType\n} from '../structure/structure-constants'\n\n/**\n * Color by molecule type\n */\nclass MoleculetypeColormaker extends Colormaker {\n @manageColor\n atomColor (a: AtomProxy) {\n switch (a.residueType.moleculeType) {\n case WaterType:\n return 0x386cb0\n case IonType:\n return 0xf0027f\n case ProteinType:\n return 0xbeaed4\n case RnaType:\n return 0xfdc086\n case DnaType:\n return 0xbf5b17\n case SaccharideType:\n return 0x7fc97f\n default:\n return 0xffff99\n }\n }\n}\n\nColormakerRegistry.add('moleculetype', MoleculetypeColormaker)\n\nexport default MoleculetypeColormaker\n","/**\n * @file Occupancy Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { ColormakerParameters, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by occupancy\n */\nclass OccupancyColormaker extends Colormaker {\n occupancyScale: ColormakerScale\n\n constructor (params: ColormakerParameters) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'PuBu'\n }\n\n if (!params.domain) {\n this.parameters.domain = [ 0.0, 1.0 ]\n }\n\n this.occupancyScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.occupancyScale(a.occupancy)\n }\n}\n\nColormakerRegistry.add('occupancy', OccupancyColormaker)\n\nexport default OccupancyColormaker\n","/**\n * @file Partialcharge Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { ColormakerParameters, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by partial charge. The {@link AtomProxy.partialCharge} property is used for coloring.\n * The default domain is [-1, 1].\n *\n * __Name:__ _partialCharge_\n *\n * @example\n * stage.loadFile(\"rcsb://1crn\").then(function (o) {\n * o.addRepresentation(\"ball+stick\", {colorScheme: \"partialCharge\"});\n * o.autoView();\n * });\n */\nclass PartialchargeColormaker extends Colormaker {\n partialchargeScale: ColormakerScale\n\n constructor (params: ColormakerParameters) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rwb'\n }\n\n if (!params.domain) {\n this.parameters.domain = [-1, 1]\n }\n\n this.partialchargeScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.partialchargeScale(a.partialCharge || 0)\n }\n}\n\nColormakerRegistry.add('partialcharge', PartialchargeColormaker)\n\nexport default PartialchargeColormaker\n","/**\n * @file Random Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\n\nfunction randomColor () {\n return Math.random() * 0xFFFFFF\n}\n\n/**\n * Class by random color\n */\nclass RandomColormaker extends Colormaker {\n /**\n * get color for an atom\n * @return {Integer} random hex color\n */\n @manageColor\n atomColor () {\n return randomColor()\n }\n\n /**\n * get color for volume cell\n * @return {Integer} random hex color\n */\n @manageColor\n volumeColor () {\n return randomColor()\n }\n\n /**\n * get color for coordinates in space\n * @return {Integer} random hex color\n */\n @manageColor\n positionColor () {\n return randomColor()\n }\n}\n\nColormakerRegistry.add('random', RandomColormaker)\n\nexport default RandomColormaker\n","/**\n * @file Randomcoilindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by random coil index\n */\nclass RandomcoilindexColormaker extends Colormaker {\n rciScale: ColormakerScale\n rciDict: { [k: string]: number|undefined } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'RdYlBu'\n }\n\n this.rciScale = this.getScale({ domain: [ 0.6, 0 ] })\n\n const val = params.structure.validation\n if (val) this.rciDict = val.rciDict\n\n }\n\n @manageColor\n atomColor (atom: AtomProxy) {\n let sele = `[${atom.resname}]${atom.resno}`\n if (atom.chainname) sele += ':' + atom.chainname\n\n const rci = this.rciDict[ sele ]\n return rci !== undefined ? this.rciScale(rci) : 0x909090\n }\n}\n\nColormakerRegistry.add('randomcoilindex', RandomcoilindexColormaker)\n\nexport default RandomcoilindexColormaker\n","/**\n * @file Residueindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\n\n/**\n * Color by residue index\n */\nclass ResidueindexColormaker extends Colormaker {\n scalePerChain: { [k: number]: ColormakerScale } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rainbow'\n this.parameters.reverse = defaults(params.reverse, true)\n }\n\n params.structure.eachChain((cp: ChainProxy) => {\n this.parameters.domain = [ cp.residueOffset, cp.residueEnd ]\n this.scalePerChain[ cp.index ] = this.getScale()\n })\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.scalePerChain[ a.chainIndex ](a.residueIndex)\n }\n}\n\nColormakerRegistry.add('residueindex', ResidueindexColormaker)\n\nexport default ResidueindexColormaker\n","/**\n * @file Resname Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n// protein colors from Jmol http://jmol.sourceforge.net/jscolors/\nconst ResidueColors: { [k: string]: number } = {\n 'ALA': 0x8CFF8C,\n 'ARG': 0x00007C,\n 'ASN': 0xFF7C70,\n 'ASP': 0xA00042,\n 'CYS': 0xFFFF70,\n 'GLN': 0xFF4C4C,\n 'GLU': 0x660000,\n 'GLY': 0xFFFFFF,\n 'HIS': 0x7070FF,\n 'ILE': 0x004C00,\n 'LEU': 0x455E45,\n 'LYS': 0x4747B8,\n 'MET': 0xB8A042,\n 'PHE': 0x534C52,\n 'PRO': 0x525252,\n 'SER': 0xFF7042,\n 'THR': 0xB84C00,\n 'TRP': 0x4F4600,\n 'TYR': 0x8C704C,\n 'VAL': 0xFF8CFF,\n\n 'ASX': 0xFF00FF,\n 'GLX': 0xFF00FF,\n 'ASH': 0xFF00FF,\n 'GLH': 0xFF00FF,\n\n 'A': 0xDC143C, // Crimson Red\n 'G': 0x32CD32, // Lime Green\n 'I': 0x9ACD32, // Yellow Green\n 'X': 0x7CFC00, // Lawn Green\n 'C': 0xFFD700, // Gold Yellow\n 'T': 0x4169E1, // Royal Blue\n 'U': 0x40E0D0, // Turquoise Cyan\n 'D': 0x008B8B, // Dark Cyan\n\n 'DA': 0xDC143C,\n 'DG': 0x32CD32,\n 'DI': 0x9ACD32,\n 'DX': 0x7CFC00,\n 'DC': 0xFFD700,\n 'DT': 0x4169E1,\n 'DU': 0x40E0D0,\n 'DD': 0x008B8B\n}\nconst DefaultResidueColor = 0xFF00FF\n\n/**\n * Color by residue name\n */\nclass ResnameColormaker extends Colormaker {\n @manageColor\n atomColor (a: AtomProxy) {\n return ResidueColors[ a.resname ] || DefaultResidueColor\n }\n}\n\nColormakerRegistry.add('resname', ResnameColormaker)\n\nexport default ResnameColormaker\n","/**\n * @file Sstruc Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\n\n// from Jmol http://jmol.sourceforge.net/jscolors/ (shapely)\nconst StructureColors = {\n 'alphaHelix': 0xFF0080,\n 'threeTenHelix': 0xA00080,\n 'piHelix': 0x600080,\n 'betaStrand': 0xFFC800,\n 'betaTurn': 0x6080FF,\n 'coil': 0xFFFFFF,\n\n 'dna': 0xAE00FE,\n 'rna': 0xFD0162,\n\n 'carbohydrate': 0xA6A6FA\n}\nconst DefaultStructureColor = 0x808080\n\n/**\n * Color by secondary structure\n */\nclass SstrucColormaker extends Colormaker {\n residueProxy: ResidueProxy\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n this.residueProxy = params.structure.getResidueProxy()\n }\n\n @manageColor\n atomColor (ap: AtomProxy) {\n const sstruc = ap.sstruc\n const rp = this.residueProxy\n\n if (sstruc === 'h') {\n return StructureColors.alphaHelix\n } else if (sstruc === 'g') {\n return StructureColors.threeTenHelix\n } else if (sstruc === 'i') {\n return StructureColors.piHelix\n } else if (sstruc === 'e' || sstruc === 'b') {\n return StructureColors.betaStrand\n } else if (sstruc === 't') {\n return StructureColors.betaTurn\n } else {\n rp.index = ap.residueIndex\n if (rp.isDna()) {\n return StructureColors.dna\n } else if (rp.isRna()) {\n return StructureColors.rna\n } else if (rp.isSaccharide()) {\n return StructureColors.carbohydrate\n } else if (rp.isProtein() || sstruc === 's' || sstruc === 'l') {\n return StructureColors.coil\n } else {\n return DefaultStructureColor\n }\n }\n }\n}\n\nColormakerRegistry.add('sstruc', SstrucColormaker)\n\nexport default SstrucColormaker\n","/**\n * @file Colordata Colormaker\n * @author Fred Ludlow \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { ColorData, ColormakerScale, manageColor, StuctureColormakerParams } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport BondProxy from '../proxy/bond-proxy'\n\n\nclass StructuredataColormaker extends Colormaker {\n atomData?: ColorData['atomData']\n bondData?: ColorData['bondData']\n scale: ColormakerScale\n\n constructor(params: StuctureColormakerParams) {\n super(params)\n if (!params.scale) {\n this.parameters.scale = 'rwb'\n }\n this.atomData = this.parameters.data?.atomData\n this.bondData = this.parameters.data?.bondData\n this.scale = this.getScale(this.parameters)\n }\n\n @manageColor\n atomColor(a: AtomProxy) {\n const val = this.atomData?.[a.index]\n return (val !== undefined) ? this.scale(val) : this.parameters.value\n }\n\n @manageColor\n bondColor(bond: BondProxy, fromTo: boolean) {\n const val = this.bondData?.[bond.index]\n \n // Explicit bond data?\n if (val !== undefined) return this.scale(val)\n \n \n if (this.atomProxy) {\n this.atomProxy.index = fromTo ? bond.atomIndex1 : bond.atomIndex2\n return this.atomColor(this.atomProxy)\n } \n \n // Fallback\n return this.parameters.value\n }\n}\n\nColormakerRegistry.add('structuredata', StructuredataColormaker)\n\nexport default StructuredataColormaker","/**\n * @file Uniform Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\n\n/**\n * Color by uniform color\n */\nclass UniformColormaker extends Colormaker {\n @manageColor\n atomColor () {\n return this.parameters.value\n }\n\n @manageColor\n bondColor () {\n return this.parameters.value\n }\n\n @manageColor\n valueColor () {\n return this.parameters.value\n }\n\n @manageColor\n volumeColor () {\n return this.parameters.value\n }\n}\n\nColormakerRegistry.add('uniform', UniformColormaker)\n\nexport default UniformColormaker\n","/**\n * @file Value Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { VolumeColormakerParams, ColormakerScale, manageColor } from './colormaker'\n\n/**\n * Color by volume value\n */\nclass ValueColormaker extends Colormaker {\n valueScale: ColormakerScale\n\n constructor (params: VolumeColormakerParams) {\n super(params)\n this.valueScale = this.getScale()\n }\n\n /**\n * return the color for a volume cell\n * @param {Integer} index - volume cell index\n * @return {Integer} hex cell color\n */\n @manageColor\n volumeColor (index: number) {\n return this.valueScale((this.parameters.volume! as any).data[ index ]) // TODO\n }\n}\n\nColormakerRegistry.add('value', ValueColormaker)\n\nexport default ValueColormaker\n","/**\n * @file Volume Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\nimport { lerp } from '../math/math-utils'\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { VolumeColormakerParams, ColormakerScale, manageColor } from './colormaker'\n\n/**\n * Color by volume position\n */\nclass VolumeColormaker extends Colormaker {\n valueScale: ColormakerScale\n vec = new Vector3()\n\n constructor (params: VolumeColormakerParams) {\n super(params)\n this.valueScale = this.getScale()\n }\n\n /**\n * return the color for coordinates in space\n * @param {Vector3} coords - xyz coordinates\n * @return {Integer} hex coords color\n */\n @manageColor\n positionColor (coords: Vector3) {\n const volume = this.parameters.volume as any // TODO\n\n if (!volume || !volume.inverseMatrix) {\n return this.parameters.value\n }\n\n const vec = this.vec\n const data = volume.data\n const nx = volume.nx\n const ny = volume.ny\n const nxy = nx * ny\n\n vec.copy(coords)\n vec.applyMatrix4(volume.inverseMatrix)\n\n // position of grid cell\n const x0 = Math.floor(vec.x)\n const y0 = Math.floor(vec.y)\n const z0 = Math.floor(vec.z)\n\n // Indices\n const i = ((((z0 * ny) + y0) * nx) + x0)\n const i1 = i + 1\n const iy = i + nx\n const iz = i + nxy\n const i1y = iy + 1\n const i1z = iz + 1\n const iyz = iy + nxy\n const i1yz = iyz + 1\n\n // Values\n const v = data[ i ]\n const v1 = data[ i1 ]\n const vy = data[ iy ]\n const vz = data[ iz ]\n const v1y = data[ i1y ]\n const v1z = data[ i1z ]\n const vyz = data[ iyz ]\n const v1yz = data[ i1yz ]\n\n // Position of point in fraction of grid\n const xd = vec.x - x0\n const yd = vec.y - y0\n const zd = vec.z - z0\n\n // 1st Dimension\n const c00 = lerp(v, v1, xd)\n const c01 = lerp(vz, v1z, xd)\n const c10 = lerp(vy, v1y, xd)\n const c11 = lerp(vyz, v1yz, xd)\n\n // 2nd Dimension\n const c0 = lerp(c00, c10, yd)\n const c1 = lerp(c01, c11, yd)\n\n // 3rd Dimension\n const c = lerp(c0, c1, zd)\n\n return this.valueScale(c)\n }\n}\n\nColormakerRegistry.add('volume', VolumeColormaker)\n\nexport default VolumeColormaker\n","/**\n * @file Structure Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { ExtensionFragDepth, Mobile } from '../globals'\nimport { defaults } from '../utils'\nimport { RepresentationParameters, default as Representation } from './representation'\nimport Selection from '../selection/selection'\nimport RadiusFactory, { RadiusFactoryTypes, RadiusType } from '../utils/radius-factory'\nimport Structure from '../structure/structure'\nimport Viewer from '../viewer/viewer'\n// @ts-ignore: unused import Volume required for declaration only\nimport { Assembly, Volume } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport AtomProxy from '../proxy/atom-proxy';\nimport Polymer from '../proxy/polymer';\nimport Buffer from '../buffer/buffer';\nimport { AtomDataFields, BondDataFields, AtomDataParams, BondDataParams } from '../structure/structure-data';\n// @ts-ignore: unused import Surface required for declaration only\nimport Surface from '../surface/surface'\n\n/**\n * Structure representation parameter object.\n * @typedef {Object} StructureRepresentationParameters - structure representation parameters\n * @mixes RepresentationParameters\n *\n * @property {String} radiusType - A list of possible sources of the radius used for rendering the representation. The radius can be based on the *vdW radius*, the *covalent radius* or the *B-factor* value of the corresponding atom. Additionally the radius can be based on the *secondary structure*. Alternatively, when set to *size*, the value from the *radius* parameter is used for all atoms.\n * @property {Float} radius - A number providing a fixed radius used for rendering the representation.\n * @property {Float} scale - A number that scales the value defined by the *radius* or the *radiusType* parameter.\n * @property {String} assembly - name of an assembly object. Included are the asymmetric unit (*AU*) corresponding to the coordinates given in the structure file, biological assemblies from *PDB*, *mmCIF* or *MMTF* files (*BU1*, *BU2*, ...), a filled (crystallographic) unitcell of a given space group (*UNITCELL*), a supercell consisting of a center unitcell and its 26 direct neighbors (*SUPERCELL*). Set to *default* to use the default asemmbly of the structure object.\n */\nexport interface StructureRepresentationParameters extends RepresentationParameters {\n radiusType: string\n radius: number\n scale: number\n assembly: string\n}\nexport interface StructureRepresentationData {\n bufferList: Buffer[]\n polymerList?: Polymer[]\n sview?: StructureView | Structure\n [k: string]: any\n}\n/**\n * Structure representation\n * @interface\n */\nabstract class StructureRepresentation extends Representation {\n\n protected selection: Selection\n protected dataList: StructureRepresentationData[]\n structure: Structure\n structureView: StructureView\n\n protected radiusType: RadiusType\n protected radiusData: {[k: number]: number}\n protected radiusSize: number\n protected radiusScale: number\n protected assembly: string\n protected defaultAssembly: string\n protected needsBuild: boolean\n\n /**\n * Create Structure representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {StructureRepresentationParameters} params - structure representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n const p = params || {}\n\n super(structure, viewer, p)\n\n this.type = 'structure'\n\n this.parameters = Object.assign({\n radiusType: {\n type: 'select', options: RadiusFactory.types\n },\n radiusData: {\n type: 'hidden'\n },\n radiusSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n radiusScale: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n assembly: null,\n defaultAssembly: {\n type: 'hidden'\n }\n }, this.parameters)\n\n /**\n * @type {Selection}\n * @private\n */\n this.selection = new Selection(p.sele)\n\n /**\n * @type {Array}\n * @private\n */\n this.dataList = []\n\n /**\n * @type {Structure}\n */\n this.structure = structure\n\n /**\n * @type {StructureView}\n */\n this.structureView = this.structure.getView(this.selection)\n\n if (structure.biomolDict) {\n const biomolOptions:{[key: string]: string} = {\n 'default': 'default',\n '': (structure.unitcell ? 'AU' : 'FULL')\n }\n Object.keys(structure.biomolDict).forEach(function (k) {\n biomolOptions[ k ] = k\n })\n this.parameters.assembly = {\n type: 'select',\n options: biomolOptions,\n rebuild: true\n }\n } else {\n this.parameters.assembly = null\n }\n }\n\n get defaultScale () {\n return {\n 'vdw': 1.0,\n 'covalent': 1.0,\n 'bfactor': 0.01,\n 'sstruc': 1.0\n }\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'element')\n\n this.setRadius(p.radius, p)\n\n this.radiusType = defaults(p.radiusType, 'vdw')\n this.radiusData = defaults(p.radiusData, {})\n this.radiusSize = defaults(p.radiusSize, 1.0)\n this.radiusScale = defaults(p.radiusScale, 1.0)\n this.assembly = defaults(p.assembly, 'default')\n this.defaultAssembly = defaults(p.defaultAssembly, '')\n\n if (p.quality === 'auto') {\n p.quality = this.getQuality()\n }\n\n super.init(p)\n\n this.selection.signals.stringChanged.add((/* sele */) => {\n this.build()\n })\n\n this.build()\n }\n\n setRadius (value: string | number | undefined, p: Partial) {\n const types = Object.keys(RadiusFactoryTypes)\n\n if (typeof value === 'string' && types.includes(value.toLowerCase())) {\n p.radiusType = value\n } else if (value !== undefined) {\n p.radiusType = 'size'\n p.radiusSize = value\n }\n\n return this\n }\n\n getAssembly (): Assembly {\n const name = this.assembly === 'default' ? this.defaultAssembly : this.assembly\n return this.structure.biomolDict[ name ]\n }\n\n getQuality () {\n let atomCount\n const s = this.structureView\n const assembly = this.getAssembly()\n if (assembly) {\n atomCount = assembly.getAtomCount(s)\n } else {\n atomCount = s.atomCount\n }\n if (Mobile) {\n atomCount *= 4\n }\n const backboneOnly = s.atomStore.count / s.residueStore.count < 2\n if (backboneOnly) {\n atomCount *= 10\n }\n\n if (atomCount < 15000) {\n return 'high'\n } else if (atomCount < 80000) {\n return 'medium'\n } else {\n return 'low'\n }\n }\n\n create () {\n if (this.structureView.atomCount === 0) return\n\n if (!this.structureView.hasCoords()) {\n this.needsBuild = true\n return\n } else {\n this.needsBuild = false\n }\n\n const assembly = this.getAssembly()\n\n if (assembly) {\n assembly.partList.forEach((part, i) => {\n const sview = part.getView(this.structureView)\n if (sview.atomCount === 0) return\n const data = this.createData(sview, i)\n if (data) {\n data.sview = sview\n data.instanceList = part.getInstanceList()\n this.dataList.push(data)\n }\n })\n } else {\n const data = this.createData(this.structureView, 0)\n if (data) {\n data.sview = this.structureView\n this.dataList.push(data)\n }\n }\n }\n\n abstract createData (sview: StructureView, k?: number): StructureRepresentationData|undefined\n\n update (what: AtomDataFields|BondDataFields) {\n if (this.lazy && !this.visible) {\n Object.assign(this.lazyProps.what, what)\n return\n }\n\n if (this.needsBuild) {\n this.build()\n return\n }\n\n this.dataList.forEach((data) => {\n if (data.bufferList.length > 0) {\n this.updateData(what, data)\n }\n }, this)\n }\n\n updateData (what?: AtomDataFields|BondDataFields, data?: any) {\n this.build()\n }\n\n getColorParams () {\n return {\n ...super.getColorParams(),\n structure: this.structure\n }\n }\n\n getRadiusParams (param?: any) {\n return {\n type: this.radiusType,\n scale: this.radiusScale,\n size: this.radiusSize,\n data: this.radiusData\n }\n }\n\n getAtomParams (what?: AtomDataFields, params?: AtomDataParams) {\n return Object.assign({\n what: what,\n colorParams: this.getColorParams(),\n radiusParams: this.getRadiusParams()\n }, params)\n }\n\n getBondParams (what?: BondDataFields, params?: BondDataParams) {\n return Object.assign({\n what: what,\n colorParams: this.getColorParams(),\n radiusParams: this.getRadiusParams()\n }, params)\n }\n\n getAtomRadius (atom: AtomProxy) {\n if (this.structureView.atomSet!.isSet(atom.index)) {\n const radiusFactory = new RadiusFactory(this.getRadiusParams())\n return radiusFactory.atomRadius(atom)\n }\n return 0\n }\n\n /**\n * Set representation parameters\n * @alias StructureRepresentation#setSelection\n * @param {String} string - selection string, see {@tutorial selection-language}\n * @param {Boolean} [silent] - don't trigger a change event in the selection\n * @return {StructureRepresentation} this object\n */\n setSelection (string: string, silent?: boolean) {\n this.selection.setString(string, silent)\n\n return this\n }\n\n /**\n * Set representation parameters\n * @alias StructureRepresentation#setParameters\n * @param {StructureRepresentationParameters} params - structure parameter object\n * @param {Object} [what] - buffer data attributes to be updated,\n * note that this needs to be implemented in the\n * derived classes. Generally it allows more\n * fine-grained control over updating than\n * forcing a rebuild.\n * @param {Boolean} what.position - update position data\n * @param {Boolean} what.color - update color data\n * @param {Boolean} [rebuild] - whether or not to rebuild the representation\n * @return {StructureRepresentation} this object\n */\n setParameters (params: Partial, what: AtomDataFields = {}, rebuild = false) {\n const p = params || {}\n\n this.setRadius(p.radius, p)\n\n if (p.radiusType !== undefined || p.radiusData !== undefined || p.radiusSize !== undefined || p.radiusScale !== undefined) {\n what.radius = true\n if (!ExtensionFragDepth || this.disableImpostor) {\n rebuild = true\n }\n }\n\n if (p.defaultAssembly !== undefined &&\n p.defaultAssembly !== this.defaultAssembly &&\n ((this.assembly === 'default' && p.assembly === undefined) ||\n p.assembly === 'default')\n ) {\n rebuild = true\n }\n\n super.setParameters(p, what, rebuild)\n\n return this\n }\n\n getParameters () {\n const params = Object.assign(\n super.getParameters(),\n {\n sele: this.selection ? this.selection.string : undefined,\n defaultAssembly: this.defaultAssembly\n }\n )\n\n return params\n }\n\n attach (callback: ()=> void) {\n const viewer = this.viewer\n const bufferList = this.bufferList\n\n this.dataList.forEach(function (data) {\n data.bufferList.forEach(function (buffer) {\n bufferList.push(buffer)\n viewer.add(buffer, data.instanceList)\n })\n })\n\n this.setVisibility(this.visible)\n callback()\n }\n\n clear () {\n this.dataList.length = 0\n\n super.clear()\n }\n\n dispose () {\n this.structureView.dispose()\n\n super.dispose()\n }\n}\n\nexport default StructureRepresentation\n","/**\n * @file Measurement Representation\n * @author Fred Ludlow \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { Color, Vector3, Matrix4 } from 'three'\n\nimport Selection from '../selection/selection'\nimport { Browser } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport { uniformArray, uniformArray3 } from '../math/array-utils'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { LabelRepresentationParameters } from './label-representation';\nimport TextBuffer, { TextBufferData } from '../buffer/text-buffer';\nimport { GenericColor } from '../types'\n\nexport interface LabelDataField {\n position?: boolean\n labelColor?: boolean\n labelSize?: boolean\n radius?: boolean\n labelText?: boolean\n}\n\n/**\n * Measurement representation parameter object.\n * @typedef {Object} MeasurementRepresentationParameters - measurement representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n *\n * @property {Float} labelSize - size of the distance label\n * @property {Color} labelColor - color of the distance label\n * @property {Boolean} labelVisible - visibility of the distance label\n * @property {Float} labelZOffset - offset in z-direction (i.e. in camera direction)\n */\nexport interface MeasurementRepresentationParameters extends StructureRepresentationParameters {\n labelVisible: boolean\n labelSize: number\n labelColor: GenericColor\n labelType: 'atomname'|'atomindex'|'occupancy'|'bfactor'|'serial'|'element'|'atom'|'resname'|'resno'|'res'|'text'|'qualified'\n labelText: string\n labelFormat: string\n labelGrouping: 'atom'|'residue'\n labelFontFamily: 'sans-serif'|'monospace'|'serif'\n labelFontStyle: 'normal'|'italic'\n labelFontWeight: 'normal'|'bold'\n labelsdf: boolean\n labelXOffset: number\n labelYOffset: number\n labelZOffset: number\n labelAttachment: 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n labelBorder: boolean\n labelBorderColor: GenericColor\n labelBorderWidth: number\n labelBackground: boolean\n labelBackgroundColor: GenericColor\n labelBackgroundMargin: number\n labelBackgroundOpacity: number\n labelFixedSize: boolean\n lineOpacity: number\n linewidth: number\n}\n\n/**\n * Measurement representation\n * @interface\n */\nabstract class MeasurementRepresentation extends StructureRepresentation {\n protected n: number\n protected labelVisible: boolean\n protected labelSize: number\n protected labelColor: GenericColor\n protected labelType: 'atomname'|'atomindex'|'occupancy'|'bfactor'|'serial'|'element'|'atom'|'resname'|'resno'|'res'|'text'|'qualified'\n protected labelText: string\n protected labelFormat: string\n protected labelGrouping: 'atom'|'residue'\n protected labelFontFamily: 'sans-serif'|'monospace'|'serif'\n protected labelFontStyle: 'normal'|'italic'\n protected labelFontWeight: 'normal'|'bold'\n protected labelsdf: boolean\n protected labelXOffset: number\n protected labelYOffset: number\n protected labelZOffset: number\n protected labelAttachment: 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n protected labelBorder: boolean\n protected labelBorderColor: GenericColor\n protected labelBorderWidth: number\n protected labelBackground: boolean\n protected labelBackgroundColor: GenericColor\n protected labelBackgroundMargin: number\n protected labelBackgroundOpacity: number\n protected labelFixedSize: boolean\n protected lineOpacity: number\n protected linewidth: number\n protected lineVisible: boolean\n\n protected textBuffer: TextBuffer\n /**\n * Handles common label settings and position logic for\n * distance, angle and dihedral representations\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.n = 0 // Subclass create sets value\n this.parameters = Object.assign({\n labelVisible: {\n type: 'boolean'\n },\n labelSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n labelColor: {\n type: 'color'\n },\n labelFontFamily: {\n type: 'select',\n options: {\n 'sans-serif': 'sans-serif',\n 'monospace': 'monospace',\n 'serif': 'serif'\n },\n buffer: 'fontFamily'\n },\n labelFontStyle: {\n type: 'select',\n options: {\n 'normal': 'normal',\n 'italic': 'italic'\n },\n buffer: 'fontStyle'\n },\n labelFontWeight: {\n type: 'select',\n options: {\n 'normal': 'normal',\n 'bold': 'bold'\n },\n buffer: 'fontWeight'\n },\n labelsdf: {\n type: 'boolean', buffer: 'sdf'\n },\n labelXOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: 'xOffset'\n },\n labelYOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: 'yOffset'\n },\n labelZOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: 'zOffset'\n },\n labelAttachment: {\n type: 'select',\n options: {\n 'bottom-left': 'bottom-left',\n 'bottom-center': 'bottom-center',\n 'bottom-right': 'bottom-right',\n 'middle-left': 'middle-left',\n 'middle-center': 'middle-center',\n 'middle-right': 'middle-right',\n 'top-left': 'top-left',\n 'top-center': 'top-center',\n 'top-right': 'top-right'\n },\n rebuild: true\n },\n labelBorder: {\n type: 'boolean', buffer: 'showBorder'\n },\n labelBorderColor: {\n type: 'color', buffer: 'borderColor'\n },\n labelBorderWidth: {\n type: 'number', precision: 2, max: 0.3, min: 0, buffer: 'borderWidth'\n },\n labelBackground: {\n type: 'boolean', rebuild: true\n },\n labelBackgroundColor: {\n type: 'color', buffer: 'backgroundColor'\n },\n labelBackgroundMargin: {\n type: 'number', precision: 2, max: 2, min: 0, rebuild: true\n },\n labelBackgroundOpacity: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: 'backgroundOpacity'\n },\n labelFixedSize: {\n type: 'boolean', buffer: 'fixedSize'\n },\n lineOpacity: {\n type: 'range', min: 0.0, max: 1.0, step: 0.01\n },\n linewidth: {\n type: 'integer', max: 50, min: 1, buffer: true\n }\n }, this.parameters, {\n flatShaded: null\n })\n }\n\n init (params: Partial) {\n const p = params || {}\n this.labelVisible = defaults(p.labelVisible, true)\n this.labelSize = defaults(p.labelSize, 2.0)\n this.labelColor = defaults(p.labelColor, 0xFFFFFF)\n this.labelFontFamily = defaults(p.labelFontFamily, 'sans-serif')\n this.labelFontStyle = defaults(p.labelFontstyle, 'normal')\n this.labelFontWeight = defaults(p.labelFontWeight, 'bold')\n this.labelsdf = defaults(p.labelsdf, Browser === 'Chrome')\n this.labelXOffset = defaults(p.labelXOffset, 0.0)\n this.labelYOffset = defaults(p.labelYOffset, 0.0)\n this.labelZOffset = defaults(p.labelZOffset, 0.5)\n this.labelAttachment = defaults(p.labelAttachment, 'bottom-left')\n this.labelBorder = defaults(p.labelBorder, false)\n this.labelBorderColor = defaults(p.labelBorderColor, 'lightgrey')\n this.labelBorderWidth = defaults(p.labelBorderWidth, 0.15)\n this.labelBackground = defaults(p.labelBackground, false)\n this.labelBackgroundColor = defaults(p.labelBackgroundColor, 'lightgrey')\n this.labelBackgroundMargin = defaults(p.labelBackgroundMargin, 0.5)\n this.labelBackgroundOpacity = defaults(p.labelBackgroundOpacity, 1.0)\n this.labelFixedSize = defaults(p.labelFixedSize, false)\n this.lineOpacity = defaults(p.lineOpacity, 1.0)\n this.linewidth = defaults(p.linewidth, 2)\n\n super.init(p)\n }\n\n // All measurements need to rebuild on position change\n update (what: LabelDataField) {\n if (what.position) {\n this.build()\n } else {\n super.update(what)\n }\n }\n\n updateData (what: LabelDataField & {[k: string]: any}, data: any) {\n const textData: TextBufferData | {} = {}\n if (!what || what.labelSize) {\n Object.assign(textData, {size: uniformArray(this.n, this.labelSize)})\n }\n\n if (!what || what.labelColor) {\n const c = new Color(this.labelColor)\n Object.assign(textData, {color: uniformArray3(this.n, c.r, c.g, c.b)})\n }\n\n this.textBuffer.setAttributes(textData as TextBufferData)\n }\n\n setParameters (params: Partial, what: LabelDataField = {}, rebuild = false) {\n if (params && params.labelSize) {\n what.labelSize = true\n }\n\n if (params && (params.labelColor || params.labelColor === 0x000000)) {\n what.labelColor = true\n rebuild = true\n }\n\n super.setParameters(params, what, rebuild)\n\n if (params && params.opacity !== undefined) {\n this.textBuffer.setParameters({ opacity: 1.0 }) // only opaque labels\n }\n\n if (params && params.labelVisible !== undefined) {\n this.setVisibility(this.visible)\n }\n\n return this\n }\n\n setVisibility (value: boolean, noRenderRequest?: boolean) {\n super.setVisibility(value, true)\n if (this.textBuffer) {\n this.textBuffer.setVisibility(\n this.labelVisible && this.visible\n )\n }\n\n if (!noRenderRequest) this.viewer.requestRender()\n\n return this\n }\n\n getLabelBufferParams (params: Partial = {}) {\n return super.getBufferParams(Object.assign({\n fontFamily: this.labelFontFamily,\n fontStyle: this.labelFontStyle,\n fontWeight: this.labelFontWeight,\n sdf: this.labelsdf,\n xOffset: this.labelXOffset,\n yOffset: this.labelYOffset,\n zOffset: this.labelZOffset,\n attachment: this.labelAttachment,\n showBorder: this.labelBorder,\n borderColor: this.labelBorderColor,\n borderWidth: this.labelBorderWidth,\n showBackground: this.labelBackground,\n backgroundColor: this.labelBackgroundColor,\n backgroundMargin: this.labelBackgroundMargin,\n backgroundOpacity: this.labelBackgroundOpacity,\n fixedSize: this.labelFixedSize,\n disablePicking: true,\n visible: this.labelVisible\n }, params, {\n opacity: 1.0 // only opaque labels\n }))\n }\n\n getAtomRadius () {\n return 0\n }\n}\n\n/**\n * MeasurementRepresentations take atom[Pair|Triple|Quad] parameters.\n *\n * Parses nested array of either integer atom indices or selection\n * expressions into a flat array of coordinates.\n *\n * @param {Structure} sview The structure to which the atoms refer\n * @param {Array} atoms Nested array of atom pairs|triples|quads as\n * Integer indices or selection expressions\n * @return {Float32Array} Flattened array of position coordinates\n */\nfunction parseNestedAtoms (sview: StructureView, atoms: (number|string)[][]) {\n const ap = sview.getAtomProxy()\n const sele = new Selection()\n\n const nSets = atoms.length\n if (nSets === 0) return new Float32Array(0)\n\n // Peek-ahead at first item to determine order and parse mode\n const order = atoms[ 0 ].length\n const selected = sview.getAtomSet()\n\n const a = new Float32Array(nSets * order * 3)\n\n let p = 0\n atoms.forEach(function (group) {\n let _break = false\n for (let j = 0; j < order; j++) {\n const value = group[ j ]\n if (typeof (value) === 'number' && Number.isInteger(value)) {\n if (selected.get(value)) {\n ap.index = value\n } else {\n _break = true\n break\n }\n } else {\n sele.setString(value as string)\n const atomIndices = sview.getAtomIndices(sele)\n if (atomIndices!.length) {\n ap.index = atomIndices![ 0 ]\n } else {\n _break = true\n break\n }\n }\n\n let offset = p + j * 3\n a[ offset++ ] = ap.x\n a[ offset++ ] = ap.y\n a[ offset++ ] = ap.z\n }\n if (!_break) p += 3 * order\n })\n\n return a.subarray(0, p)\n}\n\n/* out = v1 * cos(angle) + v2 * sin(angle) */\nfunction calcArcPoint (out: Float32Array, center: Float32Array, v1: Float32Array, v2: Float32Array, angle: number) {\n const x = Math.cos(angle)\n const y = Math.sin(angle)\n out[ 0 ] = center[ 0 ] + v1[ 0 ] * x + v2[ 0 ] * y\n out[ 1 ] = center[ 1 ] + v1[ 1 ] * x + v2[ 1 ] * y\n out[ 2 ] = center[ 2 ] + v1[ 2 ] * x + v2[ 2 ] * y\n}\n\nexport {\n MeasurementRepresentation as default,\n calcArcPoint,\n parseNestedAtoms\n}\n","/**\n * @file Edt\n * @author Alexander Rose \n * @private\n */\n\nimport { NumberArray } from '../types'\n\n// 2D Euclidean distance transform by Felzenszwalb & Huttenlocher https://cs.brown.edu/~pff/papers/dt-final.pdf\nexport function edt(data: NumberArray, width: number, height: number, f: NumberArray, d: NumberArray, v: NumberArray, z: NumberArray) {\n for (let x = 0; x < width; x++) {\n for (let y = 0; y < height; y++) {\n f[y] = data[y * width + x]\n }\n edt1d(f, d, v, z, height)\n for (let y = 0; y < height; y++) {\n data[y * width + x] = d[y]\n }\n }\n for (let y = 0; y < height; y++) {\n for (let x = 0; x < width; x++) {\n f[x] = data[y * width + x]\n }\n edt1d(f, d, v, z, width)\n for (let x = 0; x < width; x++) {\n data[y * width + x] = Math.sqrt(d[x])\n }\n }\n}\n\n// 1D squared distance transform\nfunction edt1d(f: NumberArray, d: NumberArray, v: NumberArray, z: NumberArray, n: number) {\n v[0] = 0\n z[0] = Number.MIN_SAFE_INTEGER\n z[1] = Number.MAX_SAFE_INTEGER\n\n for (let q = 1, k = 0; q < n; q++) {\n let s = ((f[q] + q * q) - (f[v[k]] + v[k] * v[k])) / (2 * q - 2 * v[k])\n while (s <= z[k]) {\n k--\n s = ((f[q] + q * q) - (f[v[k]] + v[k] * v[k])) / (2 * q - 2 * v[k])\n }\n k++\n v[k] = q\n z[k] = s\n z[k + 1] = Number.MAX_SAFE_INTEGER\n }\n\n for (let q = 0, k = 0; q < n; q++) {\n while (z[k + 1] < q) k++\n d[q] = (q - v[k]) * (q - v[k]) + f[v[k]]\n }\n}\n","/**\n * @file Text Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { Color, CanvasTexture, Vector3, Matrix4 } from 'three'\n\nimport '../shader/SDFFont.vert'\nimport '../shader/SDFFont.frag'\n\nimport { BufferRegistry } from '../globals'\nimport { createParams } from '../utils'\nimport MappedQuadBuffer from './mappedquad-buffer'\nimport { IgnorePicker } from '../utils/picker'\nimport { edt } from '../utils/edt'\nimport { BufferDefaultParameters, BufferParameterTypes, BufferData, BufferTypes, BufferParameters } from './buffer'\nimport { GenericColor } from '../types'\n\nconst TextAtlasCache: { [k: string]: TextAtlas } = {}\n\nfunction getTextAtlas (params: Partial) {\n const hash = JSON.stringify(params)\n if (TextAtlasCache[ hash ] === undefined) {\n TextAtlasCache[ hash ] = new TextAtlas(params)\n }\n return TextAtlasCache[ hash ]\n}\n\ntype TextFonts = 'sans-serif'|'monospace'|'serif'\ntype TextStyles = 'normal'|'italic'\ntype TextVariants = 'normal'\ntype TextWeights = 'normal'|'bold'\n\nexport const TextAtlasDefaultParams = {\n font: 'sans-serif' as TextFonts,\n size: 36,\n style: 'normal' as TextStyles,\n variant: 'normal' as TextVariants,\n weight: 'normal' as TextWeights,\n outline: 3,\n width: 1024,\n height: 1024\n}\nexport type TextAtlasParams = typeof TextAtlasDefaultParams\n\nexport type TextAtlasMap = { x: number, y: number, w: number, h: number }\n\nexport class TextAtlas {\n parameters: TextAtlasParams\n\n gamma = 1\n mapped: { [k: string]: TextAtlasMap } = {}\n scratchW = 0\n scratchH = 0\n currentX = 0\n currentY = 0\n\n cutoff = 0.25\n padding: number\n radius: number\n\n gridOuter: Float64Array\n gridInner: Float64Array\n f: Float64Array\n d: Float64Array\n z: Float64Array\n v: Int16Array\n\n paddedSize: number\n middle: number\n\n texture: CanvasTexture\n canvas: HTMLCanvasElement\n context: CanvasRenderingContext2D\n\n lineHeight: number\n maxWidth: number\n colors: string[]\n scratch: Uint8Array\n canvas2: HTMLCanvasElement\n context2: CanvasRenderingContext2D\n data: Uint8Array\n\n placeholder: TextAtlasMap\n\n constructor (params: Partial = {}) {\n this.parameters = createParams(params, TextAtlasDefaultParams)\n const p = this.parameters\n\n this.radius = p.size / 8\n this.padding = p.size / 3\n\n // Prepare line-height with room for outline and descenders/ascenders\n const lineHeight = this.lineHeight = p.size + 2 * p.outline + Math.round(p.size / 4)\n const maxWidth = this.maxWidth = p.width / 4\n\n // Prepare scratch canvas\n const canvas = this.canvas = document.createElement('canvas')\n canvas.width = maxWidth\n canvas.height = lineHeight\n\n const ctx = this.context = this.canvas.getContext('2d')!\n ctx.font = `${p.style} ${p.variant} ${p.weight} ${p.size}px ${p.font}`\n ctx.fillStyle = 'black'\n ctx.textAlign = 'left'\n ctx.textBaseline = 'bottom'\n ctx.lineJoin = 'round'\n\n // temporary arrays for the distance transform\n this.gridOuter = new Float64Array(lineHeight * maxWidth)\n this.gridInner = new Float64Array(lineHeight * maxWidth)\n this.f = new Float64Array(Math.max(lineHeight, maxWidth))\n this.d = new Float64Array(Math.max(lineHeight, maxWidth))\n this.z = new Float64Array(Math.max(lineHeight, maxWidth) + 1)\n this.v = new Int16Array(Math.max(lineHeight, maxWidth))\n\n //\n this.data = new Uint8Array(p.width * p.height * 4)\n this.canvas2 = document.createElement('canvas')\n this.canvas2.width = p.width\n this.canvas2.height = p.height\n this.context2 = this.canvas2.getContext('2d')!\n\n // Replacement Character\n this.placeholder = this.map(String.fromCharCode(0xFFFD))\n\n // Basic Latin (subset)\n for (let i = 0x0020; i <= 0x007E; ++i) {\n this.map(String.fromCharCode(i))\n }\n\n // TODO: to slow to always prepare them\n // // Latin-1 Supplement (subset)\n // for (let i = 0x00A1; i <= 0x00FF; ++i) {\n // this.map(String.fromCharCode(i))\n // }\n\n // Degree sign\n this.map(String.fromCharCode(0x00B0))\n\n // // Greek and Coptic (subset)\n // for (let i = 0x0391; i <= 0x03C9; ++i) {\n // this.map(String.fromCharCode(i))\n // }\n\n // // Cyrillic (subset)\n // for (let i = 0x0400; i <= 0x044F; ++i) {\n // this.map(String.fromCharCode(i))\n // }\n\n // Angstrom Sign\n this.map(String.fromCharCode(0x212B))\n\n this.texture = new CanvasTexture(this.canvas2)\n this.texture.flipY = false\n this.texture.needsUpdate = true\n }\n\n map (text: string) {\n const p = this.parameters\n\n if (this.mapped[ text ] === undefined) {\n this.draw(text)\n\n if (this.currentX + this.scratchW > p.width) {\n this.currentX = 0\n this.currentY += this.scratchH\n }\n if (this.currentY + this.scratchH > p.height) {\n console.warn('canvas to small')\n }\n\n this.mapped[ text ] = {\n x: this.currentX,\n y: this.currentY,\n w: this.scratchW,\n h: this.scratchH\n }\n\n this.context2.drawImage(\n this.canvas,\n 0, 0,\n this.scratchW, this.scratchH,\n this.currentX, this.currentY,\n this.scratchW, this.scratchH\n )\n\n this.currentX += this.scratchW\n }\n\n return this.mapped[ text ]\n }\n\n get (text: string) {\n return this.mapped[ text ] || this.placeholder\n }\n\n draw (text: string) {\n const p = this.parameters\n\n const h = this.lineHeight\n const o = p.outline\n const ctx = this.context\n // const dst = this.scratch\n const max = this.maxWidth\n // const colors = this.colors\n\n // Bottom aligned, take outline into account\n const x = o\n const y = h - p.outline\n\n // Measure text\n const m = ctx.measureText(text)\n const w = Math.min(max, Math.ceil(m.width + 2 * x + 1))\n\n const n = w * h\n\n // Clear scratch area\n ctx.clearRect(0, 0, w, h)\n\n // Draw text\n ctx.fillText(text, x, y)\n\n const imageData = ctx.getImageData(0, 0, w, h)\n const data = imageData.data\n\n for (let i = 0; i < n; i++) {\n const a = imageData.data[i * 4 + 3] / 255; // alpha value\n this.gridOuter[i] = a === 1 ? 0 : a === 0 ? Number.MAX_SAFE_INTEGER : Math.pow(Math.max(0, 0.5 - a), 2);\n this.gridInner[i] = a === 1 ? Number.MAX_SAFE_INTEGER : a === 0 ? 0 : Math.pow(Math.max(0, a - 0.5), 2);\n }\n\n edt(this.gridOuter, w, h, this.f, this.d, this.v, this.z);\n edt(this.gridInner, w, h, this.f, this.d, this.v, this.z);\n\n for (let i = 0; i < n; i++) {\n const d = this.gridOuter[i] - this.gridInner[i];\n data[i * 4 + 3] = Math.max(0, Math.min(255, Math.round(255 - 255 * (d / this.radius + this.cutoff))));\n }\n\n ctx.putImageData(imageData, 0, 0)\n this.scratchW = w\n this.scratchH = h\n }\n}\n\n/**\n * Text buffer parameter object.\n * @typedef {Object} TextBufferParameters - text buffer parameters\n *\n * @property {Float} opacity - translucency: 1 is fully opaque, 0 is fully transparent\n * @property {Integer} clipNear - position of camera near/front clipping plane\n * in percent of scene bounding box\n * @property {String} labelType - type of the label, one of:\n * \"atomname\", \"atomindex\", \"occupancy\", \"bfactor\",\n * \"serial\", \"element\", \"atom\", \"resname\", \"resno\",\n * \"res\", \"text\", \"qualified\". When set to \"text\", the\n * `labelText` list is used.\n * @property {String[]} labelText - list of label strings, must set `labelType` to \"text\"\n * to take effect\n * @property {String} fontFamily - font family, one of: \"sans-serif\", \"monospace\", \"serif\"\n * @property {String} fontStyle - font style, \"normal\" or \"italic\"\n * @property {String} fontWeight - font weight, \"normal\" or \"bold\"\n * @property {Float} xOffset - offset in x-direction\n * @property {Float} yOffset - offset in y-direction\n * @property {Float} zOffset - offset in z-direction (i.e. in camera direction)\n * @property {String} attachment - attachment of the label, one of:\n * \"bottom-left\", \"bottom-center\", \"bottom-right\",\n * \"middle-left\", \"middle-center\", \"middle-right\",\n * \"top-left\", \"top-center\", \"top-right\"\n * @property {Boolean} showBorder - show border/outline\n * @property {Color} borderColor - color of the border/outline\n * @property {Float} borderWidth - width of the border/outline\n * @property {Boolean} showBackground - show background rectangle\n * @property {Color} backgroundColor - color of the background\n * @property {Float} backgroundMargin - width of the background\n * @property {Float} backgroundOpacity - opacity of the background\n * @property {Boolean} fixedSize - show text with a fixed pixel size\n */\n\nexport interface TextBufferData extends BufferData {\n size: Float32Array\n text: string[]\n}\n\ntype TextAttachments = 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n\nexport const TextBufferDefaultParameters = Object.assign({\n fontFamily: 'sans-serif' as TextFonts,\n fontStyle: 'normal' as TextStyles,\n fontWeight: 'bold' as TextWeights,\n fontSize: 36,\n xOffset: 0.0,\n yOffset: 0.0,\n zOffset: 0.5,\n attachment: 'bottom-left' as TextAttachments,\n showBorder: false,\n borderColor: 'lightgrey' as number|string,\n borderWidth: 0.15,\n showBackground: false,\n backgroundColor: 'lightgrey' as number|string,\n backgroundMargin: 0.5,\n backgroundOpacity: 1.0,\n forceTransparent: true,\n fixedSize: false\n}, BufferDefaultParameters)\nexport type TextBufferParameters = BufferParameters & {\n fontFamily: TextFonts,\n fontStyle: TextStyles,\n fontWeight: TextWeights,\n fontSize: number,\n xOffset: number,\n yOffset: number,\n zOffset: number,\n attachment: TextAttachments,\n showBorder: boolean,\n borderColor: GenericColor,\n borderWidth: number,\n showBackground: boolean,\n backgroundColor: GenericColor,\n backgroundMargin: number,\n backgroundOpacity: number,\n forceTransparent: boolean,\n fixedSize: boolean\n}\n\nconst TextBufferParameterTypes = Object.assign({\n fontFamily: { uniform: true },\n fontStyle: { uniform: true },\n fontWeight: { uniform: true },\n fontSize: { uniform: true },\n xOffset: { uniform: true },\n yOffset: { uniform: true },\n zOffset: { uniform: true },\n showBorder: { uniform: true },\n borderColor: { uniform: true },\n borderWidth: { uniform: true },\n backgroundColor: { uniform: true },\n backgroundOpacity: { uniform: true },\n fixedSize: { updateShader: true }\n}, BufferParameterTypes)\n\nfunction getCharCount (data: TextBufferData, params: Partial) {\n const n = data.position!.length / 3\n let charCount = 0\n for (let i = 0; i < n; ++i) {\n charCount += data.text[ i ].length\n }\n if (params.showBackground) charCount += n\n\n return charCount\n}\n\n/**\n * Text buffer. Renders screen-aligned text strings.\n *\n * @example\n * var textBuffer = new TextBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * size: new Float32Array([ 2 ]),\n * text: [ \"Hello\" ]\n * });\n */\nclass TextBuffer extends MappedQuadBuffer {\n parameterTypes = TextBufferParameterTypes\n get defaultParameters() { return TextBufferDefaultParameters }\n parameters: TextBufferParameters\n\n alwaysTransparent = true\n hasWireframe = false\n isText = true\n vertexShader = 'SDFFont.vert'\n fragmentShader = 'SDFFont.frag'\n\n text: string[]\n positionCount: number\n texture: CanvasTexture\n textAtlas: TextAtlas\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.size - sizes\n * @param {String[]} data.text - text strings\n * @param {TextBufferParameters} params - parameters object\n */\n constructor (data: TextBufferData, params: Partial = {}) {\n super({\n position: new Float32Array(getCharCount(data, params) * 3),\n color: new Float32Array(getCharCount(data, params) * 3),\n picking: new IgnorePicker()\n }, params)\n\n this.text = data.text\n this.positionCount = data.position!.length / 3\n\n this.addUniforms({\n 'fontTexture': { value: null },\n 'xOffset': { value: this.parameters.xOffset },\n 'yOffset': { value: this.parameters.yOffset },\n 'zOffset': { value: this.parameters.zOffset },\n 'ortho': { value: false },\n 'showBorder': { value: this.parameters.showBorder },\n 'borderColor': { value: new Color(this.parameters.borderColor as number) },\n 'borderWidth': { value: this.parameters.borderWidth },\n 'backgroundColor': { value: new Color(this.parameters.backgroundColor as number) },\n 'backgroundOpacity': { value: this.parameters.backgroundOpacity },\n 'canvasHeight': { value: 1.0 },\n 'pixelRatio': { value: 1.0 }\n })\n\n this.addAttributes({\n 'inputTexCoord': { type: 'v2', value: null },\n 'inputSize': { type: 'f', value: null }\n })\n\n this.setAttributes(data)\n\n this.makeTexture()\n this.makeMapping()\n }\n\n makeMaterial () {\n super.makeMaterial()\n\n const tex = this.texture\n\n const m = this.material\n m.transparent = true\n m.extensions.derivatives = true\n m.lights = false\n m.uniforms.fontTexture.value = tex\n m.needsUpdate = true\n\n const wm = this.wireframeMaterial\n wm.transparent = true\n wm.extensions.derivatives = true\n wm.lights = false\n wm.uniforms.fontTexture.value = tex\n wm.needsUpdate = true\n\n const pm = this.pickingMaterial\n pm.extensions.derivatives = true\n pm.lights = false\n pm.uniforms.fontTexture.value = tex\n pm.needsUpdate = true\n }\n\n setAttributes (data: Partial = {}) {\n let position, size, color\n let aPosition, inputSize, aColor\n\n const text = this.text\n const attributes = this.geometry.attributes as any // TODO\n\n if (data.position) {\n position = data.position\n aPosition = attributes.position.array\n attributes.position.needsUpdate = true\n }\n\n if (data.size) {\n size = data.size\n inputSize = attributes.inputSize.array\n attributes.inputSize.needsUpdate = true\n }\n\n if (data.color) {\n color = data.color\n aColor = attributes.color.array\n attributes.color.needsUpdate = true\n }\n\n const n = this.positionCount\n\n let j, o\n let iCharAll = 0\n let txt, iChar, nChar\n\n for (let v = 0; v < n; ++v) {\n o = 3 * v\n txt = text[ v ]\n nChar = txt.length\n if (this.parameters.showBackground) nChar += 1\n\n for (iChar = 0; iChar < nChar; ++iChar, ++iCharAll) {\n for (let m = 0; m < 4; m++) {\n j = iCharAll * 4 * 3 + (3 * m)\n\n if (position) {\n aPosition[ j ] = position[ o ]\n aPosition[ j + 1 ] = position[ o + 1 ]\n aPosition[ j + 2 ] = position[ o + 2 ]\n }\n\n if (size) {\n inputSize[ (iCharAll * 4) + m ] = size[ v ]\n }\n\n if (color) {\n aColor[ j ] = color[ o ]\n aColor[ j + 1 ] = color[ o + 1 ]\n aColor[ j + 2 ] = color[ o + 2 ]\n }\n }\n }\n }\n }\n\n makeTexture () {\n this.textAtlas = getTextAtlas({\n font: this.parameters.fontFamily,\n style: this.parameters.fontStyle,\n weight: this.parameters.fontWeight,\n size: this.parameters.fontSize\n })\n\n this.texture = this.textAtlas.texture\n }\n\n makeMapping () {\n const ta = this.textAtlas\n const text = this.text\n const attachment = this.parameters.attachment\n const margin = (ta.lineHeight * this.parameters.backgroundMargin * 0.1) - 10\n\n const attribs = this.geometry.attributes as any // TODO\n const inputTexCoord = attribs.inputTexCoord.array\n const inputMapping = attribs.mapping.array\n\n const n = this.positionCount\n let iCharAll = 0\n let c, i, txt, xadvance, iChar, nChar, xShift, yShift\n\n for (let v = 0; v < n; ++v) {\n txt = text[ v ]\n xadvance = 0\n nChar = txt.length\n\n // calculate width\n for (iChar = 0; iChar < nChar; ++iChar) {\n c = ta.get(txt[ iChar ])\n xadvance += c.w - 2 * ta.parameters.outline\n }\n\n // attachment\n if (attachment.startsWith('top')) {\n yShift = ta.lineHeight / 1.25\n } else if (attachment.startsWith('middle')) {\n yShift = ta.lineHeight / 2.5\n } else {\n yShift = 0 // \"bottom\"\n }\n if (attachment.endsWith('right')) {\n xShift = xadvance\n } else if (attachment.endsWith('center')) {\n xShift = xadvance / 2\n } else {\n xShift = 0 // \"left\"\n }\n xShift += ta.parameters.outline\n yShift += ta.parameters.outline\n\n // background\n if (this.parameters.showBackground) {\n i = iCharAll * 2 * 4\n inputMapping[ i + 0 ] = -ta.lineHeight / 6 - xShift - margin // top left\n inputMapping[ i + 1 ] = ta.lineHeight - yShift + margin\n inputMapping[ i + 2 ] = -ta.lineHeight / 6 - xShift - margin // bottom left\n inputMapping[ i + 3 ] = 0 - yShift - margin\n inputMapping[ i + 4 ] = xadvance + ta.lineHeight / 6 - xShift + 2 * ta.parameters.outline + margin // top right\n inputMapping[ i + 5 ] = ta.lineHeight - yShift + margin\n inputMapping[ i + 6 ] = xadvance + ta.lineHeight / 6 - xShift + 2 * ta.parameters.outline + margin // bottom right\n inputMapping[ i + 7 ] = 0 - yShift - margin\n inputTexCoord[ i + 0 ] = 10\n inputTexCoord[ i + 2 ] = 10\n inputTexCoord[ i + 4 ] = 10\n inputTexCoord[ i + 6 ] = 10\n iCharAll += 1\n }\n\n xadvance = 0\n\n for (iChar = 0; iChar < nChar; ++iChar, ++iCharAll) {\n c = ta.get(txt[ iChar ])\n i = iCharAll * 2 * 4\n\n inputMapping[ i + 0 ] = xadvance - xShift // top left\n inputMapping[ i + 1 ] = c.h - yShift\n inputMapping[ i + 2 ] = xadvance - xShift // bottom left\n inputMapping[ i + 3 ] = 0 - yShift\n inputMapping[ i + 4 ] = xadvance + c.w - xShift // top right\n inputMapping[ i + 5 ] = c.h - yShift\n inputMapping[ i + 6 ] = xadvance + c.w - xShift // bottom right\n inputMapping[ i + 7 ] = 0 - yShift\n\n const texWidth = ta.parameters.width\n const texHeight = ta.parameters.height\n\n const texCoords = [\n c.x / texWidth, c.y / texHeight, // top left\n c.x / texWidth, (c.y + c.h) / texHeight, // bottom left\n (c.x + c.w) / texWidth, c.y / texHeight, // top right\n (c.x + c.w) / texWidth, (c.y + c.h) / texHeight // bottom right\n ]\n inputTexCoord.set(texCoords, i)\n\n xadvance += c.w - 2 * ta.parameters.outline\n }\n }\n\n attribs.inputTexCoord.needsUpdate = true\n attribs.mapping.needsUpdate = true\n }\n\n getDefines (type: BufferTypes) {\n const defines = super.getDefines(type)\n\n if (this.parameters.fixedSize) {\n defines.FIXED_SIZE = 1\n }\n\n return defines\n }\n\n setUniforms (data: any) { // TODO\n if (data && (\n data.fontFamily !== undefined ||\n data.fontStyle !== undefined ||\n data.fontWeight !== undefined ||\n data.fontSize !== undefined\n )) {\n this.makeTexture()\n this.makeMapping()\n this.texture.needsUpdate = true\n data.fontTexture = this.texture\n }\n\n super.setUniforms(data)\n }\n}\n\nBufferRegistry.add('text', TextBuffer)\n\nexport default TextBuffer\n","/**\n * @file Wide Line Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3 required for declaration only\nimport { Vector2, Vector3, Matrix4 } from 'three'\n\nimport '../shader/WideLine.vert'\nimport '../shader/WideLine.frag'\n\nimport { BufferRegistry } from '../globals'\nimport MappedQuadBuffer from './mappedquad-buffer'\nimport { BufferDefaultParameters, BufferParameterTypes, BufferData, BufferParameters } from './buffer'\n\nexport interface WideLineBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n color2: Float32Array\n}\n\nexport const WideLineBufferDefaultParameters = Object.assign({\n linewidth: 2\n}, BufferDefaultParameters)\nexport type WideLineBufferParameters = BufferParameters & { linewidth: number }\n\nconst WideLineBufferParameterTypes = Object.assign({\n linewidth: { uniform: true }\n}, BufferParameterTypes)\n\n/**\n * Wide Line buffer. Draws lines with a fixed width in pixels.\n *\n * @example\n * var lineBuffer = new WideLineBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ])\n * });\n */\nclass WideLineBuffer extends MappedQuadBuffer {\n parameterTypes = WideLineBufferParameterTypes\n get defaultParameters() { return WideLineBufferDefaultParameters }\n parameters: WideLineBufferParameters\n\n vertexShader = 'WideLine.vert'\n fragmentShader ='WideLine.frag'\n\n constructor (data: Partial, params: Partial = {}) {\n super(data, params)\n\n if (!data.color2 && data.color) data.color2 = data.color\n\n this.addUniforms({\n 'linewidth': { value: this.parameters.linewidth },\n 'resolution': { value: new Vector2() },\n 'projectionMatrixInverse': { value: new Matrix4() }\n })\n\n this.addAttributes({\n 'position1': { type: 'v3', value: null },\n 'position2': { type: 'v3', value: null },\n 'color2': { type: 'c', value: null }\n })\n\n this.setAttributes(data)\n this.makeMapping()\n }\n\n setParameters (params: Partial) {\n super.setParameters(params)\n }\n}\n\nBufferRegistry.add('wideline', WideLineBuffer)\n\nexport default WideLineBuffer\n","/**\n * @file Angle Representation\n * @author Fred Ludlow \n * @private\n */\nimport { Color } from 'three'\n\nimport { RepresentationRegistry } from '../globals'\nimport MeasurementRepresentation, { parseNestedAtoms, calcArcPoint, MeasurementRepresentationParameters, LabelDataField } from './measurement-representation'\nimport { defaults } from '../utils'\n\nimport MeshBuffer from '../buffer/mesh-buffer'\nimport TextBuffer, { TextBufferData, TextBufferParameters } from '../buffer/text-buffer'\nimport WideLineBuffer, { WideLineBufferData } from '../buffer/wideline-buffer'\n\nimport { v3add, v3cross, v3dot, v3fromArray, v3length, v3new,\n v3normalize, v3sub, v3toArray } from '../math/vector-utils'\nimport { copyArray, uniformArray, uniformArray3 } from '../math/array-utils'\nimport { RAD2DEG } from '../math/math-constants'\nimport { getFixedLengthWrappedDashData } from '../geometry/dash'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { BufferData } from '../buffer/buffer';\nimport { StructureRepresentationData, StructureRepresentationParameters } from './structure-representation';\n\n/**\n * @typedef {Object} AngleRepresentationParameters - angle representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n * @mixes MeasurementRepresentationParameters\n *\n * @property {String} atomTriple - list of triplets of selection strings\n * or atom indices\n * @property {Boolean} vectorVisible - Indicate the 3 points for each angle by drawing lines 1-2-3\n * @property {Boolean} arcVisible - Show the arc outline for each angle\n * @property {Number} lineOpacity - opacity for the line part of the representation\n * @property {Number} linewidth - width for line part of representation\n * @property {Boolean} sectorVisible - Show the filled arc for each angle\n */\n\nexport interface AngleRepresentationParameters extends MeasurementRepresentationParameters {\n atomTriple: (number|string)[][]\n vectorVisible: boolean\n arcVisible: boolean\n lineOpacity: number\n lineWidth: number\n sectorVisible: boolean\n}\n\n/**\n * Angle representation object\n *\n * Reperesentation consists of four parts, visibility can be set for each\n * label - the text label with the angle size\n * vectors - lines joining the three points\n * sector - triangles representing the angle\n * arc - line bordering the sector\n *\n * @param {Structure} structure - the structure to measure angles in\n * @param {Viewer} viewer - a viewer object\n * @param {AngleRepresentationParameters} params - angle representation parameters\n */\nclass AngleRepresentation extends MeasurementRepresentation {\n protected atomTriple: (number|string)[][]\n protected vectorVisible: boolean\n protected arcVisible: boolean\n protected lineOpacity: number\n protected lineWidth: number\n protected sectorVisible: boolean\n protected vectorBuffer: WideLineBuffer\n arcLength: number\n sectorLength: number\n arcBuffer: WideLineBuffer\n sectorBuffer: MeshBuffer\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'angle'\n\n this.parameters = Object.assign({\n atomTriple: {\n type: 'hidden', rebuild: true\n },\n vectorVisible: {\n type: 'boolean', default: true\n },\n arcVisible: {\n type: 'boolean', default: true\n },\n sectorVisible: {\n type: 'boolean', default: true\n }\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.side = defaults(p.side, 'double')\n p.opacity = defaults(p.opacity, 0.5)\n\n this.atomTriple = defaults(p.atomTriple, [])\n this.arcVisible = defaults(p.arcVisible, true)\n this.sectorVisible = defaults(p.sectorVisible, true)\n this.vectorVisible = defaults(p.vectorVisible, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n if (!sview.atomCount || !this.atomTriple.length) return\n\n const atomPosition = atomTriplePositions(sview, this.atomTriple)\n const angleData = getAngleData(atomPosition)\n const n = this.n = angleData.labelPosition.length / 3\n\n const labelColor = new Color(this.labelColor)\n\n // Create buffers\n this.textBuffer = new TextBuffer({\n position: angleData.labelPosition,\n size: uniformArray(n, this.labelSize),\n color: uniformArray3(n, labelColor.r, labelColor.g, labelColor.b),\n text: angleData.labelText\n } as TextBufferData, this.getLabelBufferParams() as TextBufferParameters)\n\n const c = new Color(this.colorValue)\n\n this.vectorBuffer = new WideLineBuffer(\n getFixedLengthWrappedDashData({\n position1: angleData.vectorPosition1,\n position2: angleData.vectorPosition2,\n color: uniformArray3(2 * n, c.r, c.g, c.b),\n color2: uniformArray3(2 * n, c.r, c.g, c.b)\n } as WideLineBufferData),\n this.getBufferParams({\n linewidth: this.linewidth,\n visible: this.vectorVisible,\n opacity: this.lineOpacity\n })\n )\n\n this.arcLength = angleData.arcPosition1.length / 3\n\n this.arcBuffer = new WideLineBuffer(\n getFixedLengthWrappedDashData({\n position1: angleData.arcPosition1,\n position2: angleData.arcPosition2,\n color: uniformArray3(this.arcLength, c.r, c.g, c.b),\n color2: uniformArray3(this.arcLength, c.r, c.g, c.b)\n } as WideLineBufferData), this.getBufferParams({\n linewidth: this.linewidth,\n visible: this.arcVisible,\n opacity: this.lineOpacity\n }))\n\n this.sectorLength = angleData.sectorPosition.length / 3\n\n this.sectorBuffer = new MeshBuffer({\n position: angleData.sectorPosition,\n color: uniformArray3(this.sectorLength, c.r, c.g, c.b)\n } as BufferData, this.getBufferParams({\n visible: this.sectorVisible\n }))\n\n return {\n bufferList: [\n this.textBuffer,\n this.vectorBuffer,\n this.arcBuffer,\n this.sectorBuffer\n ]\n }\n }\n\n updateData (what: LabelDataField & {color?: boolean}, data: StructureRepresentationData) {\n super.updateData(what, data)\n const vectorData = {}\n const arcData = {}\n const sectorData = {}\n\n if (what.color) {\n const c = new Color(this.colorValue)\n Object.assign(vectorData, {\n color: uniformArray3(this.n * 2, c.r, c.g, c.b),\n color2: uniformArray3(this.n * 2, c.r, c.g, c.b)\n })\n Object.assign(arcData, {\n color: uniformArray3(this.arcLength, c.r, c.g, c.b),\n color2: uniformArray3(this.arcLength, c.r, c.g, c.b)\n })\n Object.assign(sectorData, {\n color: uniformArray3(this.sectorLength, c.r, c.g, c.b)\n })\n }\n\n // if (what.sectorOpacity) {\n // this.sectorBuffer.opacity = what.sectorOpacity\n // }\n\n this.vectorBuffer.setAttributes(vectorData)\n this.arcBuffer.setAttributes(arcData)\n this.sectorBuffer.setAttributes(sectorData)\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n super.setParameters(params, what, rebuild)\n\n if (params && (\n params.vectorVisible !== undefined ||\n params.arcVisible !== undefined ||\n params.sectorVisible !== undefined)) {\n this.setVisibility(this.visible)\n }\n\n if (params && params.lineOpacity) {\n this.vectorBuffer.setParameters({ opacity: params.lineOpacity })\n this.arcBuffer.setParameters({ opacity: params.lineOpacity })\n }\n\n if (params && params.opacity !== undefined) {\n this.vectorBuffer.setParameters({ opacity: this.lineOpacity })\n this.arcBuffer.setParameters({ opacity: this.lineOpacity })\n }\n\n if (params && params.linewidth) {\n this.vectorBuffer.setParameters({ linewidth: params.linewidth })\n this.arcBuffer.setParameters({ linewidth: params.linewidth })\n }\n\n return this\n }\n\n setVisibility (value: boolean, noRenderRequest?: boolean) {\n super.setVisibility(value, true)\n\n if (this.vectorBuffer) {\n this.vectorBuffer.setVisibility(this.vectorVisible && this.visible)\n }\n\n if (this.arcBuffer) {\n this.arcBuffer.setVisibility(this.arcVisible && this.visible)\n }\n\n if (this.sectorBuffer) {\n this.sectorBuffer.setVisibility(this.sectorVisible && this.visible)\n }\n\n if (!noRenderRequest) this.viewer.requestRender()\n\n return this\n }\n}\n\n/**\n * Ensure mid point does not coincide with first or second\n * @param {Float32Array} position 9*nAngle array of coordinates\n * @return {Float32Array} Filtered position array, may be shorter\n */\nfunction validatePositions (position: Float32Array) {\n const include = []\n const n = position.length / 9\n for (let i = 0; i < n; i++) {\n // Check that first point not same as second and that second not same as third\n let okay = true\n for (let j = i; j < i + 3; j += 3) {\n if (position[j] === position[j + 3] &&\n position[j + 1] === position[j + 4] &&\n position[j + 2] === position[j + 5]) {\n okay = false\n }\n }\n if (okay) include.push(i)\n }\n const outPosition = new Float32Array(include.length * 9)\n let outIdx = 0\n include.forEach(function (i) {\n copyArray(position, outPosition, i * 9, outIdx * 9, 9)\n outIdx++\n })\n return outPosition\n}\n\nfunction atomTriplePositions (sview: StructureView, atomTriple: (number|string)[][]) {\n return validatePositions(parseNestedAtoms(sview, atomTriple))\n}\n\n/**\n * Converts triple positions into data required to build various buffers.\n */\nfunction getAngleData (position: Float32Array, params: Partial = {}) {\n const angleStep = defaults(params.angleStep, Math.PI / 90)\n const n = position.length / 9\n const angles = new Float32Array(n)\n const labelPosition = new Float32Array(n * 3)\n const labelText = new Array(n)\n\n const vectorPosition1 = new Float32Array(n * 6) // Two lines per angle\n const vectorPosition2 = new Float32Array(n * 6)\n\n const arcPositionTmp1 = new Array(n) // Start points for arc lines\n const arcPositionTmp2 = new Array(n) // End points for arc lines\n const sectorPositionTmp = new Array(n) // Triangle points\n\n let totalSegments = 0\n\n // Re-used vectors etc\n const p1 = v3new() // Positions of points for each angel\n const p2 = v3new()\n const p3 = v3new()\n const v21 = v3new() // Vectors\n const v23 = v3new()\n const cross = v3new() // Cross product v21xv23\n const cross2 = v3new() // In-plane cross product v21 x (v21 x v23)\n const labelTmp = v3new()\n const arcPoint = v3new()\n\n for (var i = 0; i < n; i++) {\n let p = 9 * i\n v3fromArray(p1, position, p)\n v3fromArray(p2, position, p + 3)\n v3fromArray(p3, position, p + 6)\n\n let v = 6 * i\n v3toArray(p1, vectorPosition1, v)\n v3toArray(p2, vectorPosition2, v)\n v3toArray(p2, vectorPosition1, v + 3)\n v3toArray(p3, vectorPosition2, v + 3)\n\n v3sub(v21, p1, p2)\n v3sub(v23, p3, p2)\n\n v3normalize(v21, v21) // validatePositions ensures valid\n v3normalize(v23, v23)\n\n v3cross(cross, v21, v23)\n const crossLength = v3length(cross)\n const dot = v3dot(v21, v23)\n\n const angle = angles[i] = Math.atan2(crossLength, dot)\n labelText[i] = (RAD2DEG * angle).toFixed(1) + String.fromCharCode(0x00B0)\n\n if (v3length(cross) === 0.0) {\n // Angle exactly 0/180, pick an arbitrary direction\n cross[ 0 ] = 1.0\n cross[ 1 ] = 0.0\n cross[ 2 ] = 0.0\n }\n v3cross(cross2, cross, v21)\n v3normalize(cross2, cross2)\n\n calcArcPoint(labelTmp, p2, v21, cross2, angle / 2.0)\n // TODO: Scale label position?\n v3toArray(labelTmp, labelPosition, 3 * i)\n\n // Build the arc and sector\n\n const nSegments = Math.ceil(angle / angleStep)\n const sectorVertices = new Float32Array(nSegments * 9)\n sectorPositionTmp[ i ] = sectorVertices\n const arcVertices1 = new Float32Array(nSegments * 3)\n const arcVertices2 = new Float32Array(nSegments * 3)\n arcPositionTmp1[ i ] = arcVertices1\n arcPositionTmp2[ i ] = arcVertices2\n\n v3add(arcPoint, p2, v21) // Our initial arc point\n\n const appendArcSection = function (a: number, j: number) {\n const si = j * 9\n const ai = j * 3\n v3toArray(p2, sectorVertices, si)\n v3toArray(arcPoint, sectorVertices, si + 3)\n v3toArray(arcPoint, arcVertices1, ai)\n\n calcArcPoint(arcPoint, p2, v21, cross2, a)\n\n v3toArray(arcPoint, sectorVertices, si + 6)\n v3toArray(arcPoint, arcVertices2, ai)\n }\n\n let j = 0\n for (let a = angleStep; a < angle; a += angleStep) {\n appendArcSection(a, j)\n j++\n }\n appendArcSection(angle, j)\n totalSegments += nSegments\n }\n\n // Flatten nested arrays of arc/segment points\n const arcSize = totalSegments * 3\n const sectorSize = totalSegments * 9\n const arcPosition1 = new Float32Array(arcSize)\n const arcPosition2 = new Float32Array(arcSize)\n const sectorPosition = new Float32Array(sectorSize)\n\n let sectorOffset = 0\n let arcOffset = 0\n for (let i = 0; i < n; i++) {\n const ap1 = arcPositionTmp1[ i ]\n const ap2 = arcPositionTmp2[ i ]\n copyArray(ap1, arcPosition1, 0, arcOffset, ap1.length)\n copyArray(ap2, arcPosition2, 0, arcOffset, ap2.length)\n arcOffset += ap1.length // === ap2.length\n\n const sp = sectorPositionTmp[ i ]\n copyArray(sp, sectorPosition, 0, sectorOffset, sp.length)\n sectorOffset += sp.length\n }\n\n return {\n labelPosition,\n labelText,\n vectorPosition1,\n vectorPosition2,\n arcPosition1,\n arcPosition2,\n sectorPosition\n }\n}\n\nRepresentationRegistry.add('angle', AngleRepresentation)\n\nexport default AngleRepresentation\n","/**\n * @file Cylinder Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3, CylinderBufferGeometry } from 'three'\n\nimport { defaults } from '../utils'\nimport { calculateCenterArray, serialBlockArray } from '../math/array-utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { CylinderBufferData } from './cylinder-buffer'\nimport { BufferDefaultParameters, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\nconst eye = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3(0, 1, 0)\n\nexport const CylinderGeometryBufferDefaultParameters = Object.assign({\n radialSegments: 1,\n openEnded: true\n}, BufferDefaultParameters)\nexport type CylinderGeometryBufferParameters = BufferParameters & {radialSegments: number, openEnded: boolean}\n\nfunction getData (data: CylinderBufferData, params: Partial = {}) {\n const geo = getGeo(params)\n\n const n = data.position1.length\n\n const geoLength = (geo.attributes as any).position.array.length / 3\n const count = n / 3\n const primitiveId = new Float32Array(count * 2 * geoLength)\n serialBlockArray(count, geoLength, 0, primitiveId)\n serialBlockArray(count, geoLength, count * geoLength, primitiveId)\n\n const position = new Float32Array(n * 2)\n const color = new Float32Array(n * 2)\n\n return {\n position, color, primitiveId, picking: data.picking\n }\n}\n\nfunction getGeo (params: Partial = {}) {\n const radialSegments = defaults(params.radialSegments, 10)\n const openEnded = defaults(params.openEnded, true)\n const matrix = new Matrix4().makeRotationX(Math.PI / 2)\n\n const geo = new CylinderBufferGeometry(\n 1, // radiusTop,\n 1, // radiusBottom,\n 1, // height,\n radialSegments, // radialSegments,\n 1, // heightSegments,\n openEnded // openEnded\n )\n geo.applyMatrix4(matrix)\n\n return geo\n}\n\n/**\n * Cylinder geometry buffer.\n *\n * @example\n * var cylinderGeometryBuffer = new CylinderGeometryBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass CylinderGeometryBuffer extends GeometryBuffer {\n updateNormals = true\n\n get defaultParameters() { return CylinderGeometryBufferDefaultParameters }\n parameters: CylinderGeometryBufferParameters\n\n __center: Float32Array\n _position: Float32Array\n _color: Float32Array\n _from: Float32Array\n _to: Float32Array\n _radius: Float32Array\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - from colors\n * @param {Float32Array} data.color2 - to colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n */\n constructor (data: CylinderBufferData, params: Partial = {}) {\n super(getData(data, params), params, getGeo(params))\n\n const n = data.position1.length\n const m = data.radius.length\n\n this.__center = new Float32Array(n)\n this._position = new Float32Array(n * 2)\n this._color = new Float32Array(n * 2)\n this._from = new Float32Array(n * 2)\n this._to = new Float32Array(n * 2)\n this._radius = new Float32Array(m * 2)\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n eye.fromArray(this._from as any, i3)\n target.fromArray(this._to as any, i3)\n matrix.lookAt(eye, target, up)\n\n const r = this._radius[ i ]\n scale.set(r, r, eye.distanceTo(target))\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n const meshData: Partial = {}\n\n if (data.position1 && data.position2) {\n calculateCenterArray(\n data.position1, data.position2, this.__center\n )\n calculateCenterArray(\n data.position1, this.__center, this._position\n )\n calculateCenterArray(\n this.__center, data.position2, this._position, data.position1.length\n )\n this._from.set(data.position1)\n this._from.set(this.__center, data.position1.length)\n this._to.set(this.__center)\n this._to.set(data.position2, this.__center.length)\n meshData.position = this._position\n }\n\n if (data.color && data.color2) {\n this._color.set(data.color)\n this._color.set(data.color2, data.color.length)\n meshData.color = this._color\n }\n\n if (data.radius) {\n this._radius.set(data.radius)\n this._radius.set(data.radius, data.radius.length)\n meshData.radius = this._radius\n }\n\n super.setAttributes(meshData, initNormals)\n }\n}\n\nexport default CylinderGeometryBuffer\n","/**\n * @file Mapped Aligned Box Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { BufferParameters, BufferData } from './buffer'\nimport MappedBuffer from './mapped-buffer'\n\n// +Y /\n// 0**********2\n// * | / **\n// * |/ * *\n// -----------3---- +X\n// * /| * *\n// * / | * *\n// 1/**|******4\n// / | * *\n// / | ** \n// +Z | 5 \nconst mapping = new Float32Array([\n -1.0, 1.0, -1.0,\n -1.0, -1.0, -1.0,\n 1.0, 1.0, -1.0,\n 1.0, 1.0, 1.0,\n 1.0, -1.0, -1.0,\n 1.0, -1.0, 1.0\n])\n\nconst mappingIndices = new Uint16Array([\n 0, 1, 2,\n 1, 4, 2,\n 2, 4, 3,\n 4, 5, 3\n])\n\n/**\n * Mapped Aligned box buffer. Draws boxes where one side is always screen-space aligned.\n * Used to render cylinder imposters.\n * @interface\n */\nclass MappedAlignedBoxBuffer extends MappedBuffer {\n constructor(data: BufferData, params: Partial = {}) {\n super('v3', data, params)\n }\n get mapping () { return mapping }\n get mappingIndices () { return mappingIndices }\n get mappingIndicesSize () { return 12 }\n get mappingSize () { return 6 }\n get mappingItemSize () { return 3 }\n}\n\nexport default MappedAlignedBoxBuffer\n","/**\n * @file Cylinder Impostor Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3 required for declaration only\nimport { Matrix4, Vector3 } from 'three'\n\nimport '../shader/CylinderImpostor.vert'\nimport '../shader/CylinderImpostor.frag'\n\nimport MappedAlignedBoxBuffer from './mappedalignedbox-buffer'\nimport { BufferDefaultParameters, BufferParameters, BufferParameterTypes, BufferTypes } from './buffer'\nimport { CylinderBufferData } from './cylinder-buffer'\n\nexport const CylinderImpostorBufferDefaultParameters = Object.assign({\n openEnded: false\n}, BufferDefaultParameters)\nexport type CylinderImpostorBufferParameters = BufferParameters & { openEnded: boolean }\n\nconst CylinderImpostorBufferParameterTypes = Object.assign({\n openEnded: { updateShader: true }\n}, BufferParameterTypes)\n\n/**\n * Cylinder impostor buffer.\n *\n * @example\n * var cylinderimpostorBuffer = new CylinderImpostorBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass CylinderImpostorBuffer extends MappedAlignedBoxBuffer {\n parameterTypes = CylinderImpostorBufferParameterTypes\n get defaultParameters() { return CylinderImpostorBufferDefaultParameters }\n parameters: CylinderImpostorBufferParameters\n\n isImpostor = true\n vertexShader = 'CylinderImpostor.vert'\n fragmentShader = 'CylinderImpostor.frag'\n\n /**\n * make cylinder impostor buffer\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - from colors\n * @param {Float32Array} data.color2 - to colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} data.picking - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: CylinderBufferData, params: Partial = {}) {\n super(data, params)\n\n this.addUniforms({\n 'modelViewMatrixInverse': { value: new Matrix4() },\n 'ortho': { value: 0.0 }\n })\n\n this.addAttributes({\n 'position1': { type: 'v3', value: null },\n 'position2': { type: 'v3', value: null },\n 'color2': { type: 'c', value: null },\n 'radius': { type: 'f', value: null }\n })\n\n this.setAttributes(data)\n this.makeMapping()\n }\n\n getDefines (type?: BufferTypes) {\n const defines = MappedAlignedBoxBuffer.prototype.getDefines.call(this, type)\n\n if (!this.parameters.openEnded) {\n defines.CAP = 1\n }\n\n return defines\n }\n}\n\nexport default CylinderImpostorBuffer\n","/**\n * @file Cylinder Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import required for declaration only\nimport { Vector3, Matrix4 } from 'three'\nimport { BufferRegistry, ExtensionFragDepth } from '../globals'\nimport CylinderGeometryBuffer, { CylinderGeometryBufferDefaultParameters, CylinderGeometryBufferParameters } from './cylindergeometry-buffer'\nimport CylinderImpostorBuffer, { CylinderImpostorBufferDefaultParameters, CylinderImpostorBufferParameters } from './cylinderimpostor-buffer'\nimport { BufferData } from './buffer'\n\nexport interface CylinderBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n color2: Float32Array\n radius: Float32Array\n}\n\nexport const CylinderBufferDefaultParameters = Object.assign({\n disableImpostor: false\n}, CylinderGeometryBufferDefaultParameters, CylinderImpostorBufferDefaultParameters)\nexport type CylinderBufferParameters = (CylinderGeometryBufferParameters & {disableImpostor: boolean}) | (CylinderImpostorBufferParameters & {disableImpostor: boolean})\n\nclass CylinderBufferImpl {\n constructor (data: CylinderBufferData, params: Partial = {}) {\n if (!data.color2 && data.color) data.color2 = data.color\n if (!ExtensionFragDepth || (params && params.disableImpostor)) {\n return new CylinderGeometryBuffer(data, params)\n } else {\n return new CylinderImpostorBuffer(data, params)\n }\n }\n}\n\n/**\n * Cylinder buffer. Depending on the value {@link ExtensionFragDepth} and\n * `params.disableImpostor` the constructor returns either a\n * {@link CylinderGeometryBuffer} or a {@link CylinderImpostorBuffer}\n * @implements {Buffer}\n *\n * @example\n * var cylinderBuffer = new CylinderBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\n//@ts-expect-error Incompatible constructor signatures\nconst CylinderBuffer: {\n new(data: CylinderBufferData, params: Partial): CylinderGeometryBuffer | CylinderImpostorBuffer;\n} = CylinderBufferImpl;\n\ntype CylinderBuffer = CylinderGeometryBuffer | CylinderImpostorBuffer;\n\nBufferRegistry.add('cylinder', CylinderBuffer)\n\nexport default CylinderBuffer\n","/**\n * @file Axes Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { Color, Vector3 } from 'three'\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { AxesPicker } from '../utils/picker'\nimport { uniformArray, uniformArray3 } from '../math/array-utils'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport CylinderBuffer, { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport StructureView from '../structure/structure-view';\nimport Viewer from '../viewer/viewer';\nimport { Structure } from '../ngl';\nimport { AtomDataFields } from '../structure/structure-data';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport PrincipalAxes from '../math/principal-axes';\n\nexport interface AxesRepresentationParameters extends StructureRepresentationParameters {\n showAxes: boolean\n showBox: boolean\n}\n\n/**\n * Axes representation. Show principal axes and/or a box aligned with them\n * that fits the structure or selection.\n *\n * __Name:__ _axes_\n *\n * @example\n * stage.loadFile( \"rcsb://3pqr\", {\n * assembly: \"BU1\"\n * } ).then( function( o ){\n * o.addRepresentation( \"cartoon\" );\n * o.addRepresentation( \"axes\", {\n * sele: \"RET\", showAxes: false, showBox: true, radius: 0.2\n * } );\n * o.addRepresentation( \"ball+stick\", { sele: \"RET\" } );\n * o.addRepresentation( \"axes\", {\n * sele: \":B and backbone\", showAxes: false, showBox: true, radius: 0.2\n * } );\n * stage.autoView();\n * var pa = o.structure.getPrincipalAxes();\n * stage.animationControls.rotate( pa.getRotationQuaternion(), 1500 );\n * } );\n */\nclass AxesRepresentation extends StructureRepresentation {\n \n protected showAxes: boolean\n protected showBox: boolean\n protected sphereBuffer: SphereBuffer\n protected cylinderBuffer: CylinderBuffer\n /**\n * @param {Structure} structure - the structure object\n * @param {Viewer} viewer - the viewer object\n * @param {StructureRepresentationParameters} params - parameters object\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'axes'\n\n this.parameters = Object.assign({\n\n radiusSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n sphereDetail: true,\n radialSegments: true,\n disableImpostor: true,\n showAxes: {\n type: 'boolean', rebuild: true\n },\n showBox: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n assembly: null\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.radiusSize = defaults(p.radiusSize, 0.5)\n p.colorValue = defaults(p.colorValue, 'lightgreen')\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.showAxes = defaults(p.showAxes, true)\n this.showBox = defaults(p.showBox, false)\n\n super.init(p)\n }\n\n getPrincipalAxes (): PrincipalAxes {\n let selection\n const assembly = this.getAssembly()\n\n if (assembly) {\n selection = assembly.partList[ 0 ].getSelection()\n }\n\n return this.structureView.getPrincipalAxes(selection)\n }\n\n getAxesData (sview: StructureView) {\n const pa = this.getPrincipalAxes()\n const c = new Color(this.colorValue)\n\n let vn = 0\n let en = 0\n\n if (this.showAxes) {\n vn += 6\n en += 3\n }\n\n if (this.showBox) {\n vn += 8\n en += 12\n }\n\n const vertexPosition = new Float32Array(3 * vn)\n const vertexColor = uniformArray3(vn, c.r, c.g, c.b)\n const vertexRadius = uniformArray(vn, this.radiusSize)\n\n const edgePosition1 = new Float32Array(3 * en)\n const edgePosition2 = new Float32Array(3 * en)\n const edgeColor = uniformArray3(en, c.r, c.g, c.b)\n const edgeRadius = uniformArray(en, this.radiusSize)\n\n let offset = 0\n\n if (this.showAxes) {\n const addAxis = function (v1: Vector3, v2: Vector3) {\n v1.toArray(vertexPosition as any, offset * 2)\n v2.toArray(vertexPosition as any, offset * 2 + 3)\n v1.toArray(edgePosition1 as any, offset)\n v2.toArray(edgePosition2 as any, offset)\n offset += 3\n }\n\n addAxis(pa.begA, pa.endA)\n addAxis(pa.begB, pa.endB)\n addAxis(pa.begC, pa.endC)\n }\n\n if (this.showBox) {\n const v = new Vector3()\n const { d1a, d2a, d3a, d1b, d2b, d3b } = pa.getProjectedScaleForAtoms(sview)\n\n // console.log(d1a, d2a, d3a, d1b, d2b, d3b)\n\n let offset2 = offset * 2\n const addCorner = function (d1: number, d2: number, d3: number) {\n v.copy(pa.center)\n .addScaledVector(pa.normVecA, d1)\n .addScaledVector(pa.normVecB, d2)\n .addScaledVector(pa.normVecC, d3)\n v.toArray(vertexPosition as any, offset2)\n offset2 += 3\n }\n addCorner(d1a, d2a, d3a)\n addCorner(d1a, d2a, d3b)\n addCorner(d1a, d2b, d3b)\n addCorner(d1a, d2b, d3a)\n addCorner(d1b, d2b, d3b)\n addCorner(d1b, d2b, d3a)\n addCorner(d1b, d2a, d3a)\n addCorner(d1b, d2a, d3b)\n\n let edgeOffset = offset\n const addEdge = function (a: number, b: number) {\n v.fromArray(vertexPosition as any, offset * 2 + a * 3)\n .toArray(edgePosition1 as any, edgeOffset)\n v.fromArray(vertexPosition as any, offset * 2 + b * 3)\n .toArray(edgePosition2 as any, edgeOffset)\n edgeOffset += 3\n }\n addEdge(0, 1)\n addEdge(0, 3)\n addEdge(0, 6)\n addEdge(1, 2)\n addEdge(1, 7)\n addEdge(2, 3)\n addEdge(2, 4)\n addEdge(3, 5)\n addEdge(4, 5)\n addEdge(4, 7)\n addEdge(5, 6)\n addEdge(6, 7)\n }\n\n const picker = new AxesPicker(pa)\n\n return {\n vertex: {\n position: vertexPosition,\n color: vertexColor,\n radius: vertexRadius,\n picking: picker\n },\n edge: {\n position1: edgePosition1,\n position2: edgePosition2,\n color: edgeColor,\n color2: edgeColor,\n radius: edgeRadius,\n picking: picker\n }\n }\n }\n\n create () {\n const axesData = this.getAxesData(this.structureView)\n\n this.sphereBuffer = new SphereBuffer(\n axesData.vertex as SphereBufferData,\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters\n )\n\n this.cylinderBuffer = new CylinderBuffer(\n axesData.edge as CylinderBufferData,\n this.getBufferParams({\n openEnded: true,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n this.dataList.push({\n sview: this.structureView,\n bufferList: [ this.sphereBuffer as SphereGeometryBuffer, this.cylinderBuffer as CylinderGeometryBuffer]\n })\n }\n\n createData (sview: StructureView): undefined {\n return\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n const axesData = this.getAxesData(data.sview as StructureView)\n const sphereData = {}\n const cylinderData = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {\n position: axesData.vertex.position\n })\n Object.assign(cylinderData, {\n position1: axesData.edge.position1,\n position2: axesData.edge.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {\n color: axesData.vertex.color as Float32Array\n })\n Object.assign(cylinderData, {\n color: axesData.edge.color as Float32Array,\n color2: axesData.edge.color as Float32Array\n })\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {\n radius: axesData.vertex.radius as Float32Array\n })\n Object.assign(cylinderData, {\n radius: axesData.edge.radius as Float32Array\n })\n }\n\n (this.sphereBuffer as SphereGeometryBuffer).setAttributes(sphereData);\n (this.cylinderBuffer as CylinderGeometryBuffer).setAttributes(cylinderData)\n }\n}\n\nRepresentationRegistry.add('axes', AxesRepresentation)\n\nexport default AxesRepresentation\n","/**\n * @file Ball And Stick Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { ExtensionFragDepth, RepresentationRegistry } from '../globals'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport CylinderBuffer, { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport WideLineBuffer from '../buffer/wideline-buffer'\nimport Viewer from '../viewer/viewer';\n// @ts-ignore: unused import Volume required for declaration only\nimport { Structure, Volume } from '../ngl';\nimport AtomProxy from '../proxy/atom-proxy';\nimport { AtomDataParams, BondDataParams, BondDataFields, AtomDataFields, BondData, AtomData } from '../structure/structure-data';\nimport StructureView from '../structure/structure-view';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\n// @ts-ignore: unused import Surface required for declaration only\nimport Surface from '../surface/surface';\n\nexport interface BallAndStickRepresentationParameters extends StructureRepresentationParameters {\n sphereDetail: number\n radialSegments: number\n openEnded: boolean\n disableImpostor: boolean\n aspectRatio: number\n lineOnly: boolean\n lineWidth: number\n cylinderOnly: boolean\n multipleBond: 'off' | 'symmetric' | 'offset'\n bondSpacing: number\n bondScale: number\n linewidth: number\n}\n\n/**\n * Ball And Stick representation parameter object. Extends {@link RepresentationParameters} and\n * {@link StructureRepresentationParameters}.\n *\n * @typedef {Object} BallAndStickRepresentationParameters - ball and stick representation parameters\n *\n * @property {Integer} sphereDetail - sphere quality (icosahedron subdivisions)\n * @property {Integer} radialSegments - cylinder quality (number of segments)\n * @property {Boolean} openEnded - capped or not\n * @property {Boolean} disableImpostor - disable use of raycasted impostors for rendering\n * @property {Float} aspectRatio - size difference between atom and bond radii\n * @property {Boolean} lineOnly - render only bonds, and only as lines\n * @property {Integer} linewidth - width of lines\n * @property {Boolean} cylinderOnly - render only bonds (no atoms)\n * @property {String} multipleBond - one off \"off\", \"symmetric\", \"offset\"\n * @property {Float} bondSpacing - spacing for multiple bond rendering\n * @property {Float} bondScale - scale/radius for multiple bond rendering\n */\n\n/**\n * Ball And Stick representation. Show atoms as spheres and bonds as cylinders.\n *\n * __Name:__ _ball+stick_\n *\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"ball+stick\" );\n * o.autoView();\n * } );\n */\nclass BallAndStickRepresentation extends StructureRepresentation {\n protected sphereDetail: number\n protected radialSegments: number\n protected openEnded: boolean\n protected disableImpostor: boolean\n protected aspectRatio: number\n protected lineOnly: boolean\n protected lineWidth: number\n protected cylinderOnly: boolean\n protected multipleBond: 'off' | 'symmetric' | 'offset'\n protected bondSpacing: number\n protected bondScale: number\n protected linewidth: number\n\n protected lineBuffer: WideLineBuffer\n /**\n * Create Ball And Stick representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {BallAndStickRepresentationParameters} params - ball and stick representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'ball+stick'\n\n this.parameters = Object.assign({\n\n sphereDetail: true,\n radialSegments: true,\n openEnded: true,\n disableImpostor: true,\n aspectRatio: {\n type: 'number', precision: 1, max: 10.0, min: 1.0\n },\n lineOnly: {\n type: 'boolean', rebuild: true\n },\n cylinderOnly: {\n type: 'boolean', rebuild: true\n },\n multipleBond: {\n type: 'select',\n rebuild: true,\n options: {\n 'off': 'off',\n 'symmetric': 'symmetric',\n 'offset': 'offset'\n }\n },\n bondScale: {\n type: 'number', precision: 2, max: 1.0, min: 0.01\n },\n bondSpacing: {\n type: 'number', precision: 2, max: 2.0, min: 0.5\n },\n linewidth: {\n type: 'integer', max: 50, min: 1, buffer: true\n }\n\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.radiusType = defaults(p.radiusType, 'size')\n p.radiusSize = defaults(p.radiusSize, 0.15)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.aspectRatio = defaults(p.aspectRatio, 2.0)\n this.lineOnly = defaults(p.lineOnly, false)\n this.cylinderOnly = defaults(p.cylinderOnly, false)\n this.multipleBond = defaults(p.multipleBond, 'off')\n this.bondSpacing = defaults(p.bondSpacing, 1.0)\n this.bondScale = defaults(p.bondScale, 0.4)\n this.linewidth = defaults(p.linewidth, 2)\n\n super.init(p)\n }\n\n getAtomRadius (atom: AtomProxy) {\n return this.aspectRatio * super.getAtomRadius(atom)\n }\n\n getAtomParams (what?: AtomDataFields, params?: Partial) {\n var p = super.getAtomParams(what, params)\n p.radiusParams.scale *= this.aspectRatio\n\n return p\n }\n\n getAtomData (sview: StructureView, what?: AtomDataFields, params?: Partial): AtomData {\n return sview.getAtomData(this.getAtomParams(what, params))\n }\n\n getBondParams (what?: BondDataFields, params?: Partial) {\n params = Object.assign({\n multipleBond: this.multipleBond,\n bondSpacing: this.bondSpacing,\n bondScale: this.bondScale\n }, params)\n\n return super.getBondParams(what, params)\n }\n\n getBondData (sview: StructureView, what?: BondDataFields, params?: Partial): BondData {\n return sview.getBondData(this.getBondParams(what, params))\n }\n\n createData (sview: StructureView) {\n const bufferList: any[] = []\n\n if (this.lineOnly) {\n this.lineBuffer = new WideLineBuffer(\n this.getBondData(sview, { position: true, color: true, picking: true }),\n this.getBufferParams({ linewidth: this.linewidth })\n )\n\n bufferList.push(this.lineBuffer)\n } else {\n const cylinderBuffer = new CylinderBuffer(\n (this.getBondData(sview) as CylinderBufferData),\n this.getBufferParams({\n openEnded: this.openEnded,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n bufferList.push(cylinderBuffer as CylinderGeometryBuffer)\n\n if (!this.cylinderOnly) {\n const sphereBuffer = new SphereBuffer(\n (this.getAtomData(sview) as SphereBufferData),\n (this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters)\n )\n\n bufferList.push(sphereBuffer as SphereGeometryBuffer)\n }\n }\n\n return {\n bufferList: bufferList\n }\n }\n\n updateData (what: BondDataFields | AtomDataFields, data: StructureRepresentationData) {\n if (this.multipleBond !== 'off' && what && what.radius) {\n what.position = true\n }\n\n const bondData = this.getBondData(data.sview as StructureView, what)\n\n if (this.lineOnly) {\n const lineData:Partial = {}\n\n if (!what || what.position) {\n Object.assign(lineData, {\n position1: bondData.position1,\n position2: bondData.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(lineData, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n data.bufferList[ 0 ].setAttributes(lineData)\n } else {\n var cylinderData: Partial = {}\n\n if (!what || what.position) {\n Object.assign(cylinderData, {\n position1: bondData.position1,\n position2: bondData.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(cylinderData, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n if (!what || what.radius) {\n Object.assign(cylinderData, {\n radius: bondData.radius\n })\n }\n\n data.bufferList[ 0 ].setAttributes(cylinderData)\n\n if (!this.cylinderOnly) {\n var atomData = this.getAtomData(data.sview as StructureView, what)\n\n var sphereData: Partial = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {\n position: atomData.position\n })\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {\n color: atomData.color\n })\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {\n radius: atomData.radius\n })\n }\n\n data.bufferList[ 1 ].setAttributes(sphereData)\n }\n }\n }\n\n setParameters (params: Partial = {}) {\n let rebuild = false\n const what: AtomDataFields = {}\n\n if (params.aspectRatio || params.bondSpacing || params.bondScale) {\n Object.assign(what, {radius: true})\n if (!ExtensionFragDepth || this.disableImpostor) {\n rebuild = true\n }\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('ball+stick', BallAndStickRepresentation)\n\nexport default BallAndStickRepresentation\n","/**\n * @file Backbone Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport BallAndStickRepresentation, { BallAndStickRepresentationParameters } from './ballandstick-representation'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport StructureView from '../structure/structure-view';\nimport { AtomDataFields, AtomDataParams, BondDataFields, BondDataParams, BondData, AtomData } from '../structure/structure-data';\n\n/**\n * Backbone representation. Show cylinders (or lines) connecting .CA (protein)\n * or .C4'/.C3' (RNA/DNA) of polymers.\n *\n * __Name:__ _backbone_\n *\n * @example\n * stage.loadFile( \"rcsb://1sfi\" ).then( function( o ){\n * o.addRepresentation( \"backbone\" );\n * o.autoView();\n * } );\n */\nclass BackboneRepresentation extends BallAndStickRepresentation {\n /**\n * @param {Structure} structure - the structure object\n * @param {Viewer} viewer - the viewer object\n * @param {BallAndStickRepresentationParameters} params - parameters object\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'backbone'\n\n this.parameters = Object.assign({\n\n }, this.parameters, {\n\n multipleBond: null,\n bondSpacing: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.aspectRatio = defaults(p.aspectRatio, 1.0)\n p.radiusSize = defaults(p.radiusSize, 0.25)\n\n super.init(p)\n }\n\n getAtomRadius (atom: AtomProxy) {\n return atom.isTrace() ? super.getAtomRadius(atom) : 0\n }\n\n getAtomData (sview: StructureView, what?: AtomDataFields, params?: Partial): AtomData {\n return sview.getBackboneAtomData(this.getAtomParams(what, params))\n }\n\n getBondData (sview: StructureView, what?: BondDataFields, params?: Partial): BondData {\n return sview.getBackboneBondData(this.getBondParams(what, params))\n }\n}\n\nRepresentationRegistry.add('backbone', BackboneRepresentation)\n\nexport default BackboneRepresentation\n","/**\n * @file Base Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport BallAndStickRepresentation, { BallAndStickRepresentationParameters } from './ballandstick-representation'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { AtomDataFields, AtomDataParams, BondDataFields, BondDataParams, BondData, AtomData } from '../structure/structure-data';\n\n/**\n * Base representation. Show cylinders for RNA/DNA ladders.\n *\n * __Name:__ _base_\n *\n * @example\n * stage.loadFile( \"rcsb://1d66\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\", { sele: \"nucleic\" } );\n * o.addRepresentation( \"base\", { color: \"resname\" } );\n * o.autoView( \"nucleic\" );\n * } );\n */\nclass BaseRepresentation extends BallAndStickRepresentation {\n /**\n * @param {Structure} structure - the structure object\n * @param {Viewer} viewer - the viewer object\n * @param {BallAndStickRepresentationParameters} params - parameters object\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'base'\n\n this.parameters = Object.assign({\n\n }, this.parameters, {\n\n multipleBond: null,\n bondSpacing: null\n\n })\n }\n\n init (params: Partial) {\n let p = params || {}\n p.aspectRatio = defaults(p.aspectRatio, 1.0)\n p.radiusSize = defaults(p.radiusSize, 0.3)\n\n super.init(p)\n }\n\n getAtomData (sview: StructureView, what?: AtomDataFields, params?: AtomDataParams): AtomData {\n return sview.getRungAtomData(this.getAtomParams(what, params))\n }\n\n getBondData (sview: StructureView, what?: BondDataFields, params?: BondDataParams): BondData {\n let p = this.getBondParams(what, params)\n Object.assign(p.colorParams, {rung: true})\n\n return sview.getRungBondData(p)\n }\n}\n\nRepresentationRegistry.add('base', BaseRepresentation)\n\nexport default BaseRepresentation\n","/**\n * @file Spline\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport { AtomPicker } from '../utils/picker'\nimport RadiusFactory, { RadiusParams } from '../utils/radius-factory'\nimport { copyArray } from '../math/array-utils'\nimport { spline } from '../math/math-utils'\nimport Polymer from '../proxy/polymer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport { ColormakerParameters } from '../color/colormaker';\nimport { NumberArray } from '../types';\n\nexport class Interpolator {\n \n m: number\n tension: number\n dt: number\n delta: number\n vec1: Vector3\n vec2: Vector3\n vDir: Vector3 \n vTan: Vector3\n vNorm: Vector3\n vBin: Vector3\n m2: number\n\n constructor (m: number, tension: number) {\n this.m = m\n this.tension = tension\n this.dt = 1.0 / this.m\n this.delta = 0.0001\n\n this.vec1 = new Vector3()\n this.vec2 = new Vector3()\n\n this.vDir = new Vector3()\n this.vTan = new Vector3()\n this.vNorm = new Vector3()\n this.vBin = new Vector3()\n \n this.m2 = Math.ceil(this.m / 2)\n }\n\n private interpolateToArr (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, t: number, arr: Float32Array, offset: number) {\n arr[ offset + 0 ] = spline(v0.x, v1.x, v2.x, v3.x, t, this.tension)\n arr[ offset + 1 ] = spline(v0.y, v1.y, v2.y, v3.y, t, this.tension)\n arr[ offset + 2 ] = spline(v0.z, v1.z, v2.z, v3.z, t, this.tension)\n }\n\n private interpolateToVec (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, t: number, vec: Vector3) {\n vec.x = spline(v0.x, v1.x, v2.x, v3.x, t, this.tension)\n vec.y = spline(v0.y, v1.y, v2.y, v3.y, t, this.tension)\n vec.z = spline(v0.z, v1.z, v2.z, v3.z, t, this.tension)\n }\n\n private interpolatePosition (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, pos: Float32Array, offset: number) {\n for (var j = 0; j < this.m; ++j) {\n var l = offset + j * 3\n var d = this.dt * j\n this.interpolateToArr(v0, v1, v2, v3, d, pos, l)\n }\n }\n\n private interpolateTangent (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, tan: Float32Array, offset: number) {\n for (var j = 0; j < this.m; ++j) {\n var d = this.dt * j\n var d1 = d - this.delta\n var d2 = d + this.delta\n var l = offset + j * 3\n // capping as a precaution\n if (d1 < 0) d1 = 0\n if (d2 > 1) d2 = 1\n //\n this.interpolateToVec(v0, v1, v2, v3, d1, this.vec1)\n this.interpolateToVec(v0, v1, v2, v3, d2, this.vec2)\n //\n this.vec2.sub(this.vec1).normalize()\n this.vec2.toArray(tan as any, l)\n }\n }\n\n private vectorSubdivide (interpolationFn: (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, array: Float32Array, offset: number) => void,\n iterator: AtomIterator, array: Float32Array, offset: number, isCyclic: boolean) {\n let v0: Vector3\n let v1 = iterator.next()\n let v2 = iterator.next()\n let v3 = iterator.next()\n //\n const n = iterator.size\n const n1 = n - 1\n let k = offset || 0\n for (let i = 0; i < n1; ++i) {\n v0 = v1\n v1 = v2\n v2 = v3\n v3 = iterator.next()\n interpolationFn.apply(this, [v0, v1, v2, v3, array, k])\n k += 3 * this.m\n }\n if (isCyclic) {\n v0 = iterator.get(n - 2)\n v1 = iterator.get(n - 1)\n v2 = iterator.get(0)\n v3 = iterator.get(1)\n interpolationFn.apply(this, [v0, v1, v2, v3, array, k])\n k += 3 * this.m\n }\n }\n\n //\n\n public getPosition (iterator: AtomIterator, array: Float32Array, offset: number, isCyclic: boolean) {\n iterator.reset()\n this.vectorSubdivide(this.interpolatePosition, iterator, array, offset, isCyclic)\n var n1 = iterator.size - 1\n var k = n1 * this.m * 3\n if (isCyclic) k += this.m * 3\n var v = iterator.get(isCyclic ? 0 : n1)\n array[ k ] = v.x\n array[ k + 1 ] = v.y\n array[ k + 2 ] = v.z\n }\n\n public getTangent (iterator: AtomIterator, array: Float32Array, offset: number, isCyclic: boolean) {\n iterator.reset()\n this.vectorSubdivide(this.interpolateTangent, iterator, array, offset, isCyclic)\n const n1 = iterator.size - 1\n let k = n1 * this.m * 3\n if (isCyclic) k += this.m * 3\n copyArray(array, array, k - 3, k, 3)\n }\n\n private interpolateNormalDir (u0: Vector3, u1: Vector3, u2: Vector3, u3: Vector3,\n v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3,\n tan: Float32Array, norm: Float32Array, bin: Float32Array,\n offset: number, shift: boolean) {\n for (let j = 0; j < this.m; ++j) {\n let l = offset + j * 3\n if (shift) l += this.m2 * 3\n const d = this.dt * j\n this.interpolateToVec(u0, u1, u2, u3, d, this.vec1)\n this.interpolateToVec(v0, v1, v2, v3, d, this.vec2)\n this.vDir.subVectors(this.vec2, this.vec1).normalize()\n this.vTan.fromArray(tan as any, l)\n this.vBin.crossVectors(this.vDir, this.vTan).normalize()\n this.vBin.toArray(bin as any, l)\n this.vNorm.crossVectors(this.vTan, this.vBin).normalize()\n this.vNorm.toArray(norm as any, l)\n }\n }\n\n private interpolateNormal (vDir: Vector3, tan: Float32Array, norm: Float32Array, bin: Float32Array, offset: number) {\n for (var j = 0; j < this.m; ++j) {\n var l = offset + j * 3\n vDir.copy(this.vNorm)\n this.vTan.fromArray(tan as any, l)\n this.vBin.crossVectors(vDir, this.vTan).normalize()\n this.vBin.toArray(bin as any, l)\n this.vNorm.crossVectors(this.vTan, this.vBin).normalize()\n this.vNorm.toArray(norm as any, l)\n }\n }\n\n public getNormal (size: number, tan: Float32Array, norm: Float32Array, bin: Float32Array, offset: number, isCyclic: boolean) {\n this.vNorm.set(0, 0, 1)\n const n = size\n const n1 = n - 1\n let k = offset || 0\n for (var i = 0; i < n1; ++i) {\n this.interpolateNormal(this.vDir, tan, norm, bin, k)\n k += 3 * this.m\n }\n if (isCyclic) {\n this.interpolateNormal(this.vDir, tan, norm, bin, k)\n k += 3 * this.m\n }\n this.vBin.toArray(bin as any, k)\n this.vNorm.toArray(norm as any, k)\n }\n\n public getNormalDir (iterDir1: AtomIterator, iterDir2: AtomIterator, tan: Float32Array, norm: Float32Array, bin: Float32Array, offset: number, isCyclic: boolean, shift: boolean) {\n iterDir1.reset()\n iterDir2.reset()\n //\n const vSub1 = new Vector3()\n const vSub2 = new Vector3()\n const vSub3 = new Vector3()\n const vSub4 = new Vector3()\n //\n const d1v1 = new Vector3()\n const d1v2 = new Vector3().copy(iterDir1.next())\n const d1v3 = new Vector3().copy(iterDir1.next())\n const d1v4 = new Vector3().copy(iterDir1.next())\n const d2v1 = new Vector3()\n const d2v2 = new Vector3().copy(iterDir2.next())\n const d2v3 = new Vector3().copy(iterDir2.next())\n const d2v4 = new Vector3().copy(iterDir2.next())\n //\n this.vNorm.set(0, 0, 1)\n let n = iterDir1.size\n let n1 = n - 1\n let k = offset || 0\n for (var i = 0; i < n1; ++i) {\n d1v1.copy(d1v2)\n d1v2.copy(d1v3)\n d1v3.copy(d1v4)\n d1v4.copy(iterDir1.next())\n d2v1.copy(d2v2)\n d2v2.copy(d2v3)\n d2v3.copy(d2v4)\n d2v4.copy(iterDir2.next())\n //\n if (i === 0) {\n vSub1.subVectors(d2v1, d1v1)\n vSub2.subVectors(d2v2, d1v2)\n if (vSub1.dot(vSub2) < 0) {\n vSub2.multiplyScalar(-1)\n d2v2.addVectors(d1v2, vSub2)\n }\n vSub3.subVectors(d2v3, d1v3)\n if (vSub2.dot(vSub3) < 0) {\n vSub3.multiplyScalar(-1)\n d2v3.addVectors(d1v3, vSub3)\n }\n } else {\n vSub3.copy(vSub4)\n }\n vSub4.subVectors(d2v4, d1v4)\n if (vSub3.dot(vSub4) < 0) {\n vSub4.multiplyScalar(-1)\n d2v4.addVectors(d1v4, vSub4)\n }\n this.interpolateNormalDir(\n d1v1, d1v2, d1v3, d1v4,\n d2v1, d2v2, d2v3, d2v4,\n tan, norm, bin, k, shift\n )\n k += 3 * this.m\n }\n if (isCyclic) {\n d1v1.copy(iterDir1.get(n - 2))\n d1v2.copy(iterDir1.get(n - 1))\n d1v3.copy(iterDir1.get(0))\n d1v4.copy(iterDir1.get(1))\n d2v1.copy(iterDir2.get(n - 2))\n d2v2.copy(iterDir2.get(n - 1))\n d2v3.copy(iterDir2.get(0))\n d2v4.copy(iterDir2.get(1))\n //\n vSub3.copy(vSub4)\n vSub4.subVectors(d2v4, d1v4)\n if (vSub3.dot(vSub4) < 0) {\n vSub4.multiplyScalar(-1)\n d2v4.addVectors(d1v4, vSub4)\n }\n this.interpolateNormalDir(\n d1v1, d1v2, d1v3, d1v4,\n d2v1, d2v2, d2v3, d2v4,\n tan, norm, bin, k, shift\n )\n k += 3 * this.m\n }\n if (shift) {\n // FIXME shift requires data from one this.more preceeding residue\n this.vBin.fromArray(bin as any, this.m2 * 3)\n this.vNorm.fromArray(norm as any, this.m2 * 3)\n for (var j = 0; j < this.m2; ++j) {\n this.vBin.toArray(bin as any, j * 3)\n this.vNorm.toArray(norm as any, j * 3)\n }\n } else {\n this.vBin.toArray(bin as any, k)\n this.vNorm.toArray(norm as any, k)\n }\n }\n\n //\n\n private interpolateColor (item1: AtomProxy, item2: AtomProxy, colFn: (...arg: any[]) => void, col: any, offset: number) {\n var j, l\n for (j = 0; j < this.m2; ++j) {\n l = offset + j * 3\n colFn.apply(this, [item1, col, l]) // itemColorToArray\n }\n for (j = this.m2; j < this.m; ++j) {\n l = offset + j * 3\n colFn.apply(this, [item2, col, l]) // itemColorToArray\n }\n }\n\n public getColor (iterator: AtomIterator, colFn: (...arg: any[]) => void, col: any, offset: number, isCyclic: boolean) {\n iterator.reset()\n iterator.next() // first element not needed\n let i0: AtomProxy\n let i1 = iterator.next()\n //\n var n = iterator.size\n var n1 = n - 1\n var k = offset || 0\n for (var i = 0; i < n1; ++i) {\n i0 = i1\n i1 = iterator.next()\n this.interpolateColor(i0, i1, colFn, col, k)\n k += 3 * this.m\n }\n if (isCyclic) {\n i0 = iterator.get(n - 1)\n i1 = iterator.get(0)\n this.interpolateColor(i0, i1, colFn, col, k)\n k += 3 * this.m\n }\n //\n col[ k ] = col[ k - 3 ]\n col[ k + 1 ] = col[ k - 2 ]\n col[ k + 2 ] = col[ k - 1 ]\n }\n\n //\n\n private interpolatePicking (item1: AtomProxy, item2: AtomProxy, pickFn: (item: AtomProxy) => number, pick: Float32Array, offset: number) {\n var j\n for (j = 0; j < this.m2; ++j) {\n pick[ offset + j ] = pickFn.apply(this, [item1])\n }\n for (j = this.m2; j < this.m; ++j) {\n pick[ offset + j ] = pickFn.apply(this, [item2])\n }\n }\n\n public getPicking (iterator: AtomIterator, pickFn: (item: AtomProxy) => number, pick: Float32Array, offset: number, isCyclic: boolean) {\n iterator.reset()\n iterator.next() // first element not needed\n let i0: AtomProxy\n let i1 = iterator.next()\n //\n const n = iterator.size\n const n1 = n - 1\n let k = offset || 0\n for (var i = 0; i < n1; ++i) {\n i0 = i1\n i1 = iterator.next()\n this.interpolatePicking(i0, i1, pickFn, pick, k)\n k += this.m\n }\n if (isCyclic) {\n i0 = iterator.get(n - 1)\n i1 = iterator.get(0)\n this.interpolatePicking(i0, i1, pickFn, pick, k)\n k += this.m\n }\n //\n pick[ k ] = pick[ k - 1 ]\n }\n\n //\n\n private interpolateSize (item1: AtomProxy, item2: AtomProxy, sizeFn: (item: AtomProxy) => number, size: Float32Array, offset: number) {\n const s1: number = sizeFn.apply(this, [item1])\n const s2: number = sizeFn.apply(this, [item2])\n for (let j = 0; j < this.m; ++j) {\n // linear interpolation\n let t = j / this.m\n size[ offset + j ] = (1 - t) * s1 + t * s2\n }\n }\n\n public getSize (iterator: AtomIterator, sizeFn: (item: AtomProxy) => number, size: Float32Array, offset: number, isCyclic: boolean) {\n iterator.reset()\n iterator.next() // first element not needed\n let i0: AtomProxy\n let i1: AtomProxy = iterator.next()\n //\n const n = iterator.size\n const n1 = n - 1\n let k = offset || 0\n for (var i = 0; i < n1; ++i) {\n i0 = i1\n i1 = iterator.next()\n this.interpolateSize(i0, i1, sizeFn, size, k)\n k += this.m\n }\n if (isCyclic) {\n i0 = iterator.get(n - 1)\n i1 = iterator.get(0)\n this.interpolateSize(i0, i1, sizeFn, size, k)\n k += this.m\n }\n //\n size[ k ] = size[ k - 1 ]\n }\n}\n\nexport interface SplineParameters {\n directional?: boolean\n positionIterator?: boolean\n subdiv?: number\n smoothSheet?: boolean\n tension?: number\n}\nexport interface AtomIterator {\n size: number,\n next: () => AtomProxy | Vector3,\n get: (idx: number) => AtomProxy | Vector3,\n reset: () => void\n}\nclass Spline {\n\n polymer: Polymer\n size: number\n directional: boolean\n positionIterator: any\n subdiv: number\n smoothSheet: boolean\n tension: number\n interpolator: Interpolator\n\n constructor (polymer: Polymer, params?: SplineParameters) {\n this.polymer = polymer\n this.size = polymer.residueCount\n\n var p = params || {}\n this.directional = p.directional || false\n this.positionIterator = p.positionIterator || false\n this.subdiv = p.subdiv || 1\n this.smoothSheet = p.smoothSheet || false\n\n if (!p.tension) {\n this.tension = this.polymer.isNucleic() ? 0.5 : 0.9\n } else {\n this.tension = p.tension\n }\n\n this.interpolator = new Interpolator(this.subdiv, this.tension)\n }\n\n getAtomIterator (type: string, smooth?: boolean): AtomIterator {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n\n let i = 0\n let j = -1\n\n const cache = [\n structure.getAtomProxy(),\n structure.getAtomProxy(),\n structure.getAtomProxy(),\n structure.getAtomProxy()\n ]\n\n const cache2 = [\n new Vector3(),\n new Vector3(),\n new Vector3(),\n new Vector3()\n ]\n\n function next () {\n var atomProxy = get(j)\n j += 1\n return atomProxy\n }\n\n var apPrev = structure.getAtomProxy()\n var apNext = structure.getAtomProxy()\n\n function get (idx: number) {\n var atomProxy = cache[ i % 4 ]\n atomProxy.index = polymer.getAtomIndexByType(idx, type) as number\n if (smooth && idx > 0 && idx < n && atomProxy.sstruc === 'e') {\n var vec = cache2[ i % 4 ]\n apPrev.index = polymer.getAtomIndexByType(idx + 1, type) as number\n apNext.index = polymer.getAtomIndexByType(idx - 1, type) as number\n vec.addVectors(apPrev as any, apNext as any)\n .add(atomProxy as any).add(atomProxy as any)\n .multiplyScalar(0.25)\n i += 1\n return vec\n }\n i += 1\n return atomProxy\n }\n\n function reset () {\n i = 0\n j = -1\n }\n\n return {\n size: n,\n next: next,\n get: get,\n reset: reset\n }\n }\n\n getSubdividedColor (params: {scheme: string, [k: string]: any } & ColormakerParameters) {\n var m = this.subdiv\n var polymer = this.polymer\n var n = polymer.residueCount\n var n1 = n - 1\n var nCol = n1 * m * 3 + 3\n if (polymer.isCyclic) nCol += m * 3\n\n var col = new Float32Array(nCol)\n var iterator = this.getAtomIterator('trace')\n\n var p = params || {}\n p.structure = polymer.structure\n\n var colormaker = ColormakerRegistry.getScheme(p)\n\n function colFn (item: AtomProxy, array: NumberArray, offset: number) {\n colormaker.atomColorToArray(item, array, offset)\n }\n\n this.interpolator.getColor(\n iterator, colFn, col, 0, polymer.isCyclic\n )\n\n return {\n 'color': col\n }\n }\n \n getSubdividedPicking () {\n var m = this.subdiv\n var polymer = this.polymer\n var n = polymer.residueCount\n var n1 = n - 1\n var nCol = n1 * m + 1\n if (polymer.isCyclic) nCol += m\n\n var structure = polymer.structure\n var iterator = this.getAtomIterator('trace')\n var pick = new Float32Array(nCol)\n\n function pickFn (item: AtomProxy) {\n return item.index\n }\n\n this.interpolator.getPicking(\n iterator, pickFn, pick, 0, polymer.isCyclic\n )\n\n return {\n 'picking': new AtomPicker(pick, structure)\n }\n }\n\n getSubdividedPosition () {\n var pos = this.getPosition()\n\n return {\n 'position': pos\n }\n }\n \n getSubdividedOrientation () {\n const tan = this.getTangent()\n const normals = this.getNormals(tan)\n\n return {\n 'tangent': tan,\n 'normal': normals.normal,\n 'binormal': normals.binormal\n }\n }\n\n getSubdividedSize (params: RadiusParams) {\n var m = this.subdiv\n var polymer = this.polymer\n var n = polymer.residueCount\n var n1 = n - 1\n var nSize = n1 * m + 1\n if (polymer.isCyclic) nSize += m\n\n var size = new Float32Array(nSize)\n var iterator = this.getAtomIterator('trace')\n\n var radiusFactory = new RadiusFactory(params)\n\n function sizeFn (item: AtomProxy) {\n return radiusFactory.atomRadius(item)\n }\n\n this.interpolator.getSize(\n iterator, sizeFn, size, 0, polymer.isCyclic\n )\n\n return {\n 'size': size\n }\n }\n\n getPosition () {\n const m = this.subdiv\n const polymer = this.polymer\n const n = polymer.residueCount\n const n1 = n - 1\n let nPos = n1 * m * 3 + 3\n if (polymer.isCyclic) nPos += m * 3\n\n const pos = new Float32Array(nPos)\n const iterator = this.positionIterator || this.getAtomIterator('trace', this.smoothSheet)\n\n this.interpolator.getPosition(iterator, pos, 0, polymer.isCyclic)\n\n return pos\n }\n\n getTangent () {\n const m = this.subdiv\n const polymer = this.polymer\n const n = this.size\n const n1 = n - 1\n let nTan = n1 * m * 3 + 3\n if (polymer.isCyclic) nTan += m * 3\n\n const tan = new Float32Array(nTan)\n const iterator = this.positionIterator || this.getAtomIterator('trace', this.smoothSheet)\n\n this.interpolator.getTangent(iterator, tan, 0, polymer.isCyclic)\n\n return tan\n }\n\n getNormals (tan: Float32Array) {\n const m = this.subdiv\n const polymer = this.polymer\n const isProtein = polymer.isProtein()\n const n = this.size\n const n1 = n - 1\n let nNorm = n1 * m * 3 + 3\n if (polymer.isCyclic) nNorm += m * 3\n\n const norm = new Float32Array(nNorm)\n const bin = new Float32Array(nNorm)\n\n if (this.directional && !this.polymer.isCg()) {\n const iterDir1 = this.getAtomIterator('direction1')\n const iterDir2 = this.getAtomIterator('direction2')\n this.interpolator.getNormalDir(\n iterDir1, iterDir2, tan, norm, bin, 0, polymer.isCyclic, isProtein\n )\n } else {\n this.interpolator.getNormal(\n n, tan, norm, bin, 0, polymer.isCyclic\n )\n }\n\n return {\n 'normal': norm,\n 'binormal': bin\n }\n }\n\n}\n\nexport default Spline\n","/**\n * @file Tube Mesh Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Matrix4 required for declaration only\nimport { Vector3, Matrix4 } from 'three'\n\nimport { defaults, getUintArray } from '../utils'\nimport { serialArray } from '../math/array-utils'\nimport MeshBuffer from './mesh-buffer'\nimport { BufferDefaultParameters, BufferData, BufferParameters } from './buffer'\nimport {Log} from \"../globals\";\n\nconst vTangent = new Vector3()\nconst vMeshNormal = new Vector3()\n\nexport interface TubeMeshBufferData extends BufferData {\n binormal: Float32Array\n tangent: Float32Array\n size: Float32Array\n}\n\nexport const TubeMeshBufferDefaultParameters = Object.assign({\n radialSegments: 4,\n capped: false,\n aspectRatio: 1.0\n}, BufferDefaultParameters)\nexport type TubeMeshBufferParameters = BufferParameters & {\n radialSegments: number,\n capped: boolean,\n aspectRatio: number\n}\n\nfunction getData (data: TubeMeshBufferData, params: Partial = {}) {\n const radialSegments = defaults(params.radialSegments, 4)\n const capped = defaults(params.capped, false)\n\n const capVertices = capped ? radialSegments : 0\n const capTriangles = capped ? radialSegments - 2 : 0\n\n const n = data.position!.length / 3\n const n1 = n - 1\n const x = n * radialSegments * 3 + 2 * capVertices * 3\n const xi = n1 * 2 * radialSegments * 3 + 2 * capTriangles * 3\n\n return {\n position: new Float32Array(x),\n color: new Float32Array(x),\n index: getUintArray(xi, x / 3),\n normal: new Float32Array(x),\n picking: data.picking\n }\n}\n\n/**\n * Tube mesh buffer. Draws a tube.\n */\nclass TubeMeshBuffer extends MeshBuffer {\n get defaultParameters() { return TubeMeshBufferDefaultParameters }\n parameters: TubeMeshBufferParameters\n\n capVertices: number\n capTriangles: number\n size2: number\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.normal - normals\n * @param {Float32Array} data.binormal - binormals\n * @param {Float32Array} data.tangent - tangents\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.size - sizes\n * @param {Picker} data.picking - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: TubeMeshBufferData, params: Partial = {}) {\n super(getData(data, params), params)\n\n this.capVertices = this.parameters.capped ? this.parameters.radialSegments : 0\n this.capTriangles = this.parameters.capped ? this.parameters.radialSegments - 2 : 0\n\n this.size2 = data.position!.length / 3\n data.primitiveId = serialArray(this.size2)\n\n this.setAttributes(data)\n this.makeIndex()\n }\n\n setAttributes (data: Partial = {}) {\n const aspectRatio = this.parameters.aspectRatio\n\n const n = this.size2\n const n1 = n - 1\n const radialSegments = this.parameters.radialSegments\n\n const attributes = this.geometry.attributes as any\n\n let position, normal, binormal, tangent, color, size, primitiveId\n let meshPosition, meshColor, meshNormal, meshPrimitiveId\n\n if (data.position) {\n position = data.position\n normal = data.normal\n binormal = data.binormal\n tangent = data.tangent\n size = data.size\n\n meshPosition = attributes.position.array\n meshNormal = attributes.normal.array\n\n attributes.position.needsUpdate = true\n attributes.normal.needsUpdate = true\n }\n\n if (data.color) {\n color = data.color\n meshColor = attributes.color.array\n attributes.color.needsUpdate = true\n }\n\n if (data.primitiveId) {\n primitiveId = data.primitiveId\n meshPrimitiveId = attributes.primitiveId.array\n attributes.primitiveId.needsUpdate = true\n }\n\n let k, l\n let radius = 0\n\n let normX = 0\n let normY = 0\n let normZ = 0\n let biX = 0\n let biY = 0\n let biZ = 0\n let posX = 0\n let posY = 0\n let posZ = 0\n\n const cxArr = []\n const cyArr = []\n const cx1Arr = []\n const cy1Arr = []\n const cx2Arr = []\n const cy2Arr = []\n\n if (position) {\n for (let j = 0; j < radialSegments; ++j) {\n const v = (j / radialSegments) * 2 * Math.PI\n\n cxArr[ j ] = aspectRatio * Math.cos(v)\n cyArr[ j ] = Math.sin(v)\n\n cx1Arr[ j ] = aspectRatio * Math.cos(v - 0.01)\n cy1Arr[ j ] = Math.sin(v - 0.01)\n cx2Arr[ j ] = aspectRatio * Math.cos(v + 0.01)\n cy2Arr[ j ] = Math.sin(v + 0.01)\n }\n }\n\n for (let i = 0; i < n; ++i) {\n k = i * 3\n l = k * radialSegments\n\n if (position && tangent && normal && binormal && size) {\n vTangent.set(\n tangent[ k ], tangent[ k + 1 ], tangent[ k + 2 ]\n )\n\n normX = normal[ k ]\n normY = normal[ k + 1 ]\n normZ = normal[ k + 2 ]\n\n biX = binormal[ k ]\n biY = binormal[ k + 1 ]\n biZ = binormal[ k + 2 ]\n\n posX = position[ k ]\n posY = position[ k + 1 ]\n posZ = position[ k + 2 ]\n\n radius = size[ i ]\n }\n\n for (let j = 0; j < radialSegments; ++j) {\n const s = l + j * 3\n\n if (position) {\n const cx = -radius * cxArr[ j ] // TODO: Hack: Negating it so it faces outside.\n const cy = radius * cyArr[ j ]\n\n const cx1 = -radius * cx1Arr[ j ]\n const cy1 = radius * cy1Arr[ j ]\n const cx2 = -radius * cx2Arr[ j ]\n const cy2 = radius * cy2Arr[ j ]\n\n meshPosition[ s ] = posX + cx * normX + cy * biX\n meshPosition[ s + 1 ] = posY + cx * normY + cy * biY\n meshPosition[ s + 2 ] = posZ + cx * normZ + cy * biZ\n\n // TODO half of these are symmetric\n vMeshNormal.set(\n // ellipse tangent approximated as vector from/to adjacent points\n (cx2 * normX + cy2 * biX) - (cx1 * normX + cy1 * biX),\n (cx2 * normY + cy2 * biY) - (cx1 * normY + cy1 * biY),\n (cx2 * normZ + cy2 * biZ) - (cx1 * normZ + cy1 * biZ)\n ).cross(vTangent)\n\n meshNormal[ s ] = vMeshNormal.x\n meshNormal[ s + 1 ] = vMeshNormal.y\n meshNormal[ s + 2 ] = vMeshNormal.z\n }\n\n if (color) {\n meshColor[ s ] = color[ k ]\n meshColor[ s + 1 ] = color[ k + 1 ]\n meshColor[ s + 2 ] = color[ k + 2 ]\n }\n\n if (primitiveId) {\n meshPrimitiveId[ i * radialSegments + j ] = primitiveId[ i ]\n }\n }\n }\n\n // front cap\n\n k = 0\n l = n * 3 * radialSegments\n\n for (let j = 0; j < radialSegments; ++j) {\n const s = k + j * 3\n const t = l + j * 3\n\n if (position && tangent) {\n meshPosition[ t ] = meshPosition[ s ]\n meshPosition[ t + 1 ] = meshPosition[ s + 1 ]\n meshPosition[ t + 2 ] = meshPosition[ s + 2 ]\n\n meshNormal[ t ] = tangent[ k ]\n meshNormal[ t + 1 ] = tangent[ k + 1 ]\n meshNormal[ t + 2 ] = tangent[ k + 2 ]\n }\n\n if (color) {\n meshColor[ t ] = meshColor[ s ]\n meshColor[ t + 1 ] = meshColor[ s + 1 ]\n meshColor[ t + 2 ] = meshColor[ s + 2 ]\n }\n\n if (primitiveId) {\n meshPrimitiveId[ n * radialSegments + j ] = meshPrimitiveId[ 0 + j ]\n }\n }\n\n // back cap\n\n k = (n - 1) * 3 * radialSegments\n l = (n + 1) * 3 * radialSegments\n\n for (let j = 0; j < radialSegments; ++j) {\n const s = k + j * 3\n const t = l + j * 3\n\n if (position && tangent) {\n meshPosition[ t ] = meshPosition[ s ]\n meshPosition[ t + 1 ] = meshPosition[ s + 1 ]\n meshPosition[ t + 2 ] = meshPosition[ s + 2 ]\n\n meshNormal[ t ] = tangent[ n1 * 3 ]\n meshNormal[ t + 1 ] = tangent[ n1 * 3 + 1 ]\n meshNormal[ t + 2 ] = tangent[ n1 * 3 + 2 ]\n }\n\n if (color) {\n meshColor[ t ] = meshColor[ s ]\n meshColor[ t + 1 ] = meshColor[ s + 1 ]\n meshColor[ t + 2 ] = meshColor[ s + 2 ]\n }\n\n if (primitiveId) {\n meshPrimitiveId[ (n + 1) * radialSegments + j ] = meshPrimitiveId[ (n - 1) * radialSegments + j ]\n }\n }\n }\n\n makeIndex () {\n const index = this.geometry.getIndex()\n if (!index) { Log.error('Index is null'); return; }\n const meshIndex = index.array as Uint32Array|Uint16Array\n\n const n = this.size2\n const n1 = n - 1\n const capTriangles = this.capTriangles\n const radialSegments = this.parameters.radialSegments\n const radialSegments1 = this.parameters.radialSegments + 1\n\n let k, l\n\n for (let i = 0; i < n1; ++i) {\n const k = i * radialSegments * 3 * 2\n\n const irs = i * radialSegments\n const irs1 = (i + 1) * radialSegments\n\n for (let j = 0; j < radialSegments; ++j) {\n l = k + j * 3 * 2\n\n // meshIndex[ l + 0 ] = irs + ( ( j + 0 ) % radialSegments );\n meshIndex[ l ] = irs + j\n meshIndex[ l + 1 ] = irs + ((j + 1) % radialSegments)\n // meshIndex[ l + 2 ] = irs1 + ( ( j + 0 ) % radialSegments );\n meshIndex[ l + 2 ] = irs1 + j\n\n // meshIndex[ l + 3 ] = irs1 + ( ( j + 0 ) % radialSegments );\n meshIndex[ l + 3 ] = irs1 + j\n meshIndex[ l + 4 ] = irs + ((j + 1) % radialSegments)\n meshIndex[ l + 5 ] = irs1 + ((j + 1) % radialSegments)\n }\n }\n\n // capping\n\n const strip = [ 0 ]\n\n for (let j = 1; j < radialSegments1 / 2; ++j) {\n strip.push(j)\n if (radialSegments - j !== j) {\n strip.push(radialSegments - j)\n }\n }\n\n // front cap\n\n l = n1 * radialSegments * 3 * 2\n k = n * radialSegments\n\n for (let j = 0; j < strip.length - 2; ++j) {\n if (j % 2 === 0) {\n meshIndex[ l + j * 3 + 0 ] = k + strip[ j + 0 ]\n meshIndex[ l + j * 3 + 1 ] = k + strip[ j + 1 ]\n meshIndex[ l + j * 3 + 2 ] = k + strip[ j + 2 ]\n } else {\n meshIndex[ l + j * 3 + 0 ] = k + strip[ j + 2 ]\n meshIndex[ l + j * 3 + 1 ] = k + strip[ j + 1 ]\n meshIndex[ l + j * 3 + 2 ] = k + strip[ j + 0 ]\n }\n }\n\n // back cap\n\n l = n1 * radialSegments * 3 * 2 + 3 * capTriangles\n k = n * radialSegments + radialSegments\n\n for (let j = 0; j < strip.length - 2; ++j) {\n if (j % 2 === 0) {\n meshIndex[ l + j * 3 + 0 ] = k + strip[ j + 0 ]\n meshIndex[ l + j * 3 + 1 ] = k + strip[ j + 1 ]\n meshIndex[ l + j * 3 + 2 ] = k + strip[ j + 2 ]\n } else {\n meshIndex[ l + j * 3 + 0 ] = k + strip[ j + 2 ]\n meshIndex[ l + j * 3 + 1 ] = k + strip[ j + 1 ]\n meshIndex[ l + j * 3 + 2 ] = k + strip[ j + 0 ]\n }\n }\n }\n}\n\nexport default TubeMeshBuffer\n","/**\n * @file Cartoon Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { Debug, Log, RepresentationRegistry } from '../globals'\nimport Spline from '../geometry/spline'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport TubeMeshBuffer from '../buffer/tubemesh-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport Polymer from '../proxy/polymer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport StructureView from '../structure/structure-view';\nimport Buffer from '../buffer/buffer';\n\nexport interface CartoonRepresentationParameters extends StructureRepresentationParameters {\n aspectRatio: number\n subdiv: number\n radialSegments: number\n tension: number\n capped: boolean\n smoothSheet: boolean\n}\n\n/**\n * Cartoon representation. Show a thick ribbon that\n * smoothly connecting backbone atoms in polymers.\n *\n * __Name:__ _cartoon_\n *\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\" );\n * o.autoView();\n * } );\n */\nclass CartoonRepresentation extends StructureRepresentation {\n protected aspectRatio: number\n protected tension: number\n protected capped: boolean\n protected smoothSheet: boolean\n protected subdiv: number\n \n /**\n * Create Cartoon representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {StructureRepresentationParameters} params - representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'cartoon'\n\n this.parameters = Object.assign({\n\n aspectRatio: {\n type: 'number', precision: 1, max: 10.0, min: 1.0, rebuild: true\n },\n subdiv: {\n type: 'integer', max: 50, min: 1, rebuild: true\n },\n radialSegments: {\n type: 'integer', max: 50, min: 1, rebuild: true\n },\n tension: {\n type: 'number', precision: 1, max: 1.0, min: 0.1\n },\n capped: {\n type: 'boolean', rebuild: true\n },\n smoothSheet: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'chainname')\n p.colorScale = defaults(p.colorScale, 'RdYlBu')\n p.radiusType = defaults(p.radiusType, 'sstruc')\n p.radiusScale = defaults(p.radiusScale, 0.7)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.aspectRatio = defaults(p.aspectRatio, 5.0)\n this.tension = defaults(p.tension, NaN)\n this.capped = defaults(p.capped, true)\n this.smoothSheet = defaults(p.smoothSheet, false)\n\n if (p.quality === 'low') {\n this.subdiv = 3\n this.radialSegments = 6\n } else if (p.quality === 'medium') {\n this.subdiv = 6\n } else if (p.quality === 'high') {\n this.subdiv = 12\n } else {\n this.subdiv = defaults(p.subdiv, 6)\n }\n\n super.init(p)\n }\n\n getSplineParams (params?: Partial) {\n return Object.assign({\n subdiv: this.subdiv,\n tension: this.tension,\n directional: this.aspectRatio !== 1.0,\n smoothSheet: this.smoothSheet\n }, params)\n }\n\n getSpline (polymer: Polymer): Spline {\n return new Spline(polymer, this.getSplineParams())\n }\n\n getAspectRatio (polymer: Polymer): number {\n return polymer.isCg() ? 1.0 : this.aspectRatio\n }\n\n getAtomRadius (atom: AtomProxy): number {\n return atom.isTrace() ? super.getAtomRadius(atom) : 0\n }\n\n createData (sview: StructureView) {\n let bufferList: Buffer[] = []\n let polymerList: Polymer[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4) return\n polymerList.push(polymer)\n\n const spline = this.getSpline(polymer)\n const aspectRatio = this.getAspectRatio(polymer)\n\n const subPos = spline.getSubdividedPosition()\n const subOri = spline.getSubdividedOrientation()\n const subCol = spline.getSubdividedColor(this.getColorParams())\n const subPick = spline.getSubdividedPicking()\n const subSize = spline.getSubdividedSize(this.getRadiusParams())\n\n bufferList.push(\n new TubeMeshBuffer(\n Object.assign({}, subPos, subOri, subCol, subPick, subSize),\n this.getBufferParams({\n radialSegments: this.radialSegments,\n aspectRatio: aspectRatio,\n capped: this.capped\n })\n )\n )\n }, sview.getSelection())\n\n return {\n bufferList: bufferList,\n polymerList: polymerList\n }\n }\n\n updateData (what: any, data: StructureRepresentationData) {\n if (Debug) Log.time(this.type + ' repr update')\n\n what = what || {}\n\n for (var i = 0, il = data.polymerList!.length; i < il; ++i) {\n var bufferData: {[key: string]: any} = {}\n var polymer = data.polymerList![ i ]\n var spline = this.getSpline(polymer)\n var aspectRatio = this.getAspectRatio(polymer)\n\n Object.assign(data.bufferList[ i ], {aspectRatio: aspectRatio})\n\n if (what.position || what.radius) {\n var subPos = spline.getSubdividedPosition()\n var subOri = spline.getSubdividedOrientation()\n var subSize = spline.getSubdividedSize(this.getRadiusParams(aspectRatio))\n\n bufferData.position = subPos.position\n bufferData.normal = subOri.normal\n bufferData.binormal = subOri.binormal\n bufferData.tangent = subOri.tangent\n bufferData.size = subSize.size\n }\n\n if (what.color) {\n var subCol = spline.getSubdividedColor(this.getColorParams())\n bufferData.color = subCol.color\n }\n\n if (what.picking) {\n var subPick = spline.getSubdividedPicking()\n bufferData.picking = subPick.picking\n }\n\n data.bufferList[ i ].setAttributes(bufferData)\n }\n\n if (Debug) Log.timeEnd(this.type + ' repr update')\n }\n\n setParameters (params: Partial) {\n const rebuild = false\n var what: {[k: string]: any} = {}\n\n if (params && params.aspectRatio) {\n what.radius = true\n }\n\n if (params && params.tension) {\n what.position = true\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('cartoon', CartoonRepresentation)\n\nexport default CartoonRepresentation\n","/**\n * @file Contact Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { RepresentationRegistry } from '../globals'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport { calculateContacts, getContactData, getLabelData } from '../chemistry/interactions/contact'\nimport CylinderBuffer from '../buffer/cylinder-buffer'\nimport TextBuffer from '../buffer/text-buffer'\nimport { getFixedCountDashData } from '../geometry/dash'\nimport Viewer from '../viewer/viewer';\nimport { Structure } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport CylinderImpostorBuffer from '../buffer/cylinderimpostor-buffer';\n// @ts-ignore: unused import ContactPicker required for declaration only\nimport { ContactPicker } from '../utils/picker';\n\nexport interface ContactRepresentationParameters extends StructureRepresentationParameters {\n hydrogenBond: boolean\n weakHydrogenBond: boolean\n waterHydrogenBond: boolean\n backboneHydrogenBond: boolean\n hydrophobic: boolean\n halogenBond: boolean\n ionicInteraction: boolean\n metalCoordination: boolean\n cationPi: boolean\n piStacking: boolean\n filterSele: string|[string, string]\n maxHydrophobicDist: number\n maxHbondDist: number\n maxHbondSulfurDist: number\n maxHbondAccAngle: number\n maxHbondDonAngle: number\n maxHbondAccPlaneAngle: number\n maxHbondDonPlaneAngle: number\n maxPiStackingDist: number\n maxPiStackingOffset: number\n maxPiStackingAngle: number\n maxCationPiDist: number\n maxCationPiOffset: number\n maxIonicDist: number\n maxHalogenBondDist: number\n maxHalogenBondAngle: number\n maxMetalDist: number\n refineSaltBridges: boolean\n masterModelIndex: number\n lineOfSightDistFactor: number\n}\n\n/**\n * Contact representation.\n */\nclass ContactRepresentation extends StructureRepresentation {\n protected hydrogenBond: boolean\n protected weakHydrogenBond: boolean\n protected waterHydrogenBond: boolean\n protected backboneHydrogenBond: boolean\n protected hydrophobic: boolean\n protected halogenBond: boolean\n protected ionicInteraction: boolean\n protected metalCoordination: boolean\n protected cationPi: boolean\n protected piStacking: boolean\n protected filterSele: string|[string, string]\n protected maxHydrophobicDist: number\n protected maxHbondDist: number\n protected maxHbondSulfurDist: number\n protected maxHbondAccAngle: number\n protected maxHbondDonAngle: number\n protected maxHbondAccPlaneAngle: number\n protected maxHbondDonPlaneAngle: number\n protected maxPiStackingDist: number\n protected maxPiStackingOffset: number\n protected maxPiStackingAngle: number\n protected maxCationPiDist: number\n protected maxCationPiOffset: number\n protected maxIonicDist: number\n protected maxHalogenBondDist: number\n protected maxHalogenBondAngle: number\n protected maxMetalDist: number\n protected refineSaltBridges: boolean\n protected masterModelIndex: number\n protected lineOfSightDistFactor: number\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'contact'\n\n this.parameters = Object.assign({\n hydrogenBond: {\n type: 'boolean', rebuild: true\n },\n weakHydrogenBond: {\n type: 'boolean', rebuild: true\n },\n waterHydrogenBond: {\n type: 'boolean', rebuild: true\n },\n backboneHydrogenBond: {\n type: 'boolean', rebuild: true\n },\n hydrophobic: {\n type: 'boolean', rebuild: true\n },\n halogenBond: {\n type: 'boolean', rebuild: true\n },\n ionicInteraction: {\n type: 'boolean', rebuild: true\n },\n metalCoordination: {\n type: 'boolean', rebuild: true\n },\n cationPi: {\n type: 'boolean', rebuild: true\n },\n piStacking: {\n type: 'boolean', rebuild: true\n },\n\n filterSele: {\n type: 'text', rebuild: true\n },\n\n labelVisible: {\n type: 'boolean', rebuild: true\n },\n\n labelFixedSize: {\n type: 'boolean', buffer: 'fixedSize'\n },\n\n labelSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001, rebuild: true\n },\n\n labelUnit: {\n type: 'select',\n rebuild: true,\n options: { '': '', angstrom: 'angstrom', nm: 'nm' }\n },\n\n maxHydrophobicDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHbondDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHbondSulfurDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHbondAccAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n maxHbondDonAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n maxHbondAccPlaneAngle: {\n type: 'integer', max: 90, min: 0, rebuild: true\n },\n maxHbondDonPlaneAngle: {\n type: 'integer', max: 90, min: 0, rebuild: true\n },\n maxPiStackingDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxPiStackingOffset: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxPiStackingAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n maxCationPiDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxCationPiOffset: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxIonicDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHalogenBondDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHalogenBondAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n maxMetalDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n refineSaltBridges: {\n type: 'boolean', rebuild: true\n },\n masterModelIndex: {\n type: 'integer', max: 1000, min: -1, rebuild: true\n },\n lineOfSightDistFactor: {\n type: 'number', precision: 1, max: 10, min: 0.0, rebuild: true\n },\n\n radialSegments: true,\n disableImpostor: true\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.radiusSize = defaults(p.radiusSize, 0.05)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.hydrogenBond = defaults(p.hydrogenBond, true)\n this.weakHydrogenBond = defaults(p.weakHydrogenBond, false)\n this.waterHydrogenBond = defaults(p.waterHydrogenBond, false)\n this.backboneHydrogenBond = defaults(p.backboneHydrogenBond, false)\n this.hydrophobic = defaults(p.hydrophobic, false)\n this.halogenBond = defaults(p.halogenBond, true)\n this.ionicInteraction = defaults(p.ionicInteraction, true)\n this.metalCoordination = defaults(p.metalCoordination, true)\n this.cationPi = defaults(p.cationPi, true)\n this.piStacking = defaults(p.piStacking, true)\n\n this.filterSele = defaults(p.filterSele, '')\n this.labelVisible = defaults(p.labelVisible, false)\n this.labelFixedSize = defaults(p.labelFixedSize, false)\n this.labelSize = defaults(p.labelSize, 2.0)\n this.labelUnit = defaults(p.labelUnit, '')\n\n this.maxHydrophobicDist = defaults(p.maxHydrophobicDist, 4.0)\n this.maxHbondDist = defaults(p.maxHbondDist, 3.5)\n this.maxHbondSulfurDist = defaults(p.maxHbondSulfurDist, 4.1)\n this.maxHbondAccAngle = defaults(p.maxHbondAccAngle, 45)\n this.maxHbondDonAngle = defaults(p.maxHbondDonAngle, 45)\n this.maxHbondAccPlaneAngle = defaults(p.maxHbondAccPlaneAngle, 90)\n this.maxHbondDonPlaneAngle = defaults(p.maxHbondDonPlaneAngle, 30)\n this.maxPiStackingDist = defaults(p.maxPiStackingDist, 5.5)\n this.maxPiStackingOffset = defaults(p.maxPiStackingOffset, 2.0)\n this.maxPiStackingAngle = defaults(p.maxPiStackingAngle, 30)\n this.maxCationPiDist = defaults(p.maxCationPiDist, 6.0)\n this.maxCationPiOffset = defaults(p.maxCationPiOffset, 2.0)\n this.maxIonicDist = defaults(p.maxIonicDist, 5.0)\n this.maxHalogenBondDist = defaults(p.maxHalogenBondDist, 3.5)\n this.maxHalogenBondAngle = defaults(p.maxHalogenBondAngle, 30)\n this.maxMetalDist = defaults(p.maxMetalDist, 3.0)\n this.refineSaltBridges = defaults(p.refineSaltBridges, true)\n this.masterModelIndex = defaults(p.masterModelIndex, -1)\n this.lineOfSightDistFactor = defaults(p.lineOfSightDistFactor, 1.0)\n\n super.init(p)\n }\n\n getAtomRadius () {\n return 0\n }\n\n getContactData (sview: StructureView) {\n const params = {\n maxHydrophobicDist: this.maxHydrophobicDist,\n maxHbondDist: this.maxHbondDist,\n maxHbondSulfurDist: this.maxHbondSulfurDist,\n maxHbondAccAngle: this.maxHbondAccAngle,\n maxHbondDonAngle: this.maxHbondDonAngle,\n maxHbondAccPlaneAngle: this.maxHbondAccPlaneAngle,\n maxHbondDonPlaneAngle: this.maxHbondDonPlaneAngle,\n maxPiStackingDist: this.maxPiStackingDist,\n maxPiStackingOffset: this.maxPiStackingOffset,\n maxPiStackingAngle: this.maxPiStackingAngle,\n maxCationPiDist: this.maxCationPiDist,\n maxCationPiOffset: this.maxCationPiOffset,\n maxIonicDist: this.maxIonicDist,\n maxHalogenBondDist: this.maxHalogenBondDist,\n maxHalogenBondAngle: this.maxHalogenBondAngle,\n maxMetalDist: this.maxMetalDist,\n refineSaltBridges: this.refineSaltBridges,\n masterModelIndex: this.masterModelIndex,\n lineOfSightDistFactor: this.lineOfSightDistFactor\n }\n\n const dataParams = {\n hydrogenBond: this.hydrogenBond,\n weakHydrogenBond: this.weakHydrogenBond,\n waterHydrogenBond: this.waterHydrogenBond,\n backboneHydrogenBond: this.backboneHydrogenBond,\n hydrophobic: this.hydrophobic,\n halogenBond: this.halogenBond,\n ionicInteraction: this.ionicInteraction,\n metalCoordination: this.metalCoordination,\n cationPi: this.cationPi,\n piStacking: this.piStacking,\n radius: this.radiusSize * this.radiusScale,\n filterSele: this.filterSele\n }\n\n const contacts = calculateContacts(sview, params)\n return getContactData(contacts, sview, dataParams)\n }\n\n createData (sview: StructureView) {\n const contactData = this.getContactData(sview)\n\n const bufferList = [\n new CylinderBuffer(\n getFixedCountDashData(contactData),\n this.getBufferParams({\n sphereDetail: 1,\n dullInterior: true,\n disableImpostor: this.disableImpostor\n })\n ) as (CylinderGeometryBuffer | CylinderImpostorBuffer | TextBuffer)\n ]\n\n if (this.labelVisible) {\n const labelParams = {\n size: this.labelSize,\n unit: this.labelUnit\n }\n bufferList.push(new TextBuffer(\n getLabelData(contactData, labelParams),\n this.getBufferParams({fixedSize: this.labelFixedSize})\n ))\n }\n\n return { bufferList }\n }\n}\n\nRepresentationRegistry.add('contact', ContactRepresentation)\n\nexport default ContactRepresentation\n","/**\n * @file Dihedral Representation\n * @author Fred Ludlow \n * @private\n */\nimport { Color } from 'three'\n\nimport { RepresentationRegistry } from '../globals'\nimport MeasurementRepresentation, { calcArcPoint, parseNestedAtoms, MeasurementRepresentationParameters, LabelDataField } from './measurement-representation'\nimport { defaults } from '../utils'\n\nimport MeshBuffer from '../buffer/mesh-buffer'\nimport TextBuffer, { TextBufferData } from '../buffer/text-buffer'\nimport WideLineBuffer from '../buffer/wideline-buffer'\n\nimport { copyArray, uniformArray, uniformArray3 } from '../math/array-utils'\nimport { v3add, v3angle, v3cross, v3dot, v3multiplyScalar, v3fromArray, v3length,\n v3negate, v3new, v3normalize, v3sub, v3toArray } from '../math/vector-utils'\nimport { RAD2DEG } from '../math/math-constants'\nimport { getFixedLengthWrappedDashData } from '../geometry/dash'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { CylinderBufferData } from '../buffer/cylinder-buffer';\nimport { BufferData } from '../buffer/buffer';\nimport { StructureRepresentationData } from './structure-representation';\n\n/**\n * @typedef {Object} DihedralRepresentationParameters - dihedral representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n * @mixes MeasurementRepresentationParameters\n *\n * @property {String} atomQuad - list of quadruplets of selection strings\n * or atom indices\n * @property {Boolean} extendLine - Extend lines in planes\n * @property {Number} lineOpacity - Opacity for the line part of the representation\n * @property {Boolean} lineVisible - Display the line part of the representation\n * @property {Number} linewidth - width for line part of representation\n * @property {Boolean} planeVisible - Display the two planes corresponding to dihedral\n * @property {Boolean} sectorVisible - Display the filled arc for each angle\n */\n\nexport interface DihedralRepresentationParameters extends MeasurementRepresentationParameters {\n atomQuad: (number|string)[][]\n extendLine: boolean\n lineOpacity: number\n lineVisible: boolean\n linewidth: number\n planeVisible: boolean\n sectorVisible: boolean\n}\n\n/**\n * Dihedral representation object\n *\n * Reperesentation consists of three parts, visibility can be set for each\n * label - text label indicating dihedral angle\n * line - line indicating four positions that define the dihedral\n * sector - filled arc section\n *\n * @param {Structure} structure - the structure to measure angles in\n * @param {Viewer} viewer - a viewer object\n * @param {AngleRepresentationParameters} params - angle representation parameters\n */\nclass DihedralRepresentation extends MeasurementRepresentation {\n protected atomQuad: (number|string)[][]\n protected extendLine: boolean\n protected lineOpacity: number\n protected lineVisible: boolean\n protected linewidth: number\n protected planeVisible: boolean\n protected sectorVisible: boolean\n\n protected lineLength: number\n protected planeLength: number\n protected sectorLength: number\n\n protected lineBuffer: WideLineBuffer\n protected planeBuffer: MeshBuffer\n protected sectorBuffer: MeshBuffer\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'dihedral'\n\n this.parameters = Object.assign({\n atomQuad: {\n type: 'hidden', rebuild: true\n },\n extendLine: {\n type: 'boolean', rebuild: true, default: true\n },\n lineVisible: {\n type: 'boolean', default: true\n },\n planeVisible: {\n type: 'boolean', default: true\n },\n sectorVisible: {\n type: 'boolean', default: true\n }\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.side = defaults(p.side, 'double')\n p.opacity = defaults(p.opacity, 0.5)\n\n this.atomQuad = defaults(p.atomQuad, [])\n this.extendLine = defaults(p.extendLine, true)\n this.lineVisible = defaults(p.lineVisible, true)\n this.planeVisible = defaults(p.planeVisible, true)\n this.sectorVisible = defaults(p.sectorVisible, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n if (!sview.atomCount || !this.atomQuad.length) return\n\n const atomPosition = parseNestedAtoms(sview, this.atomQuad)\n const dihedralData = getDihedralData(\n atomPosition, {\n extendLine: this.extendLine\n }\n )\n\n const n = this.n = dihedralData.labelText.length\n const labelColor = new Color(this.labelColor)\n\n this.textBuffer = new TextBuffer({\n position: dihedralData.labelPosition,\n size: uniformArray(n, this.labelSize),\n color: uniformArray3(n, labelColor.r, labelColor.g, labelColor.b),\n text: dihedralData.labelText\n } as TextBufferData, this.getLabelBufferParams())\n\n const c = new Color(this.colorValue)\n this.lineLength = dihedralData.linePosition1.length / 3\n const lineColor = uniformArray3(this.lineLength, c.r, c.g, c.b)\n\n this.lineBuffer = new WideLineBuffer(\n getFixedLengthWrappedDashData({\n position1: dihedralData.linePosition1,\n position2: dihedralData.linePosition2,\n color: lineColor,\n color2: lineColor\n } as CylinderBufferData) ,\n this.getBufferParams({\n linewidth: this.linewidth,\n visible: this.lineVisible,\n opacity: this.lineOpacity\n })\n )\n\n this.planeLength = dihedralData.planePosition.length / 3\n this.planeBuffer = new MeshBuffer({\n position: dihedralData.planePosition,\n color: uniformArray3(this.planeLength, c.r, c.g, c.b)\n } as BufferData, this.getBufferParams({\n visible: this.planeVisible\n }))\n\n this.sectorLength = dihedralData.sectorPosition.length / 3\n this.sectorBuffer = new MeshBuffer({\n position: dihedralData.sectorPosition,\n color: uniformArray3(this.sectorLength, c.r, c.g, c.b)\n } as BufferData, this.getBufferParams({\n visible: this.sectorVisible\n }))\n\n return {\n bufferList: [\n this.textBuffer,\n this.lineBuffer,\n this.planeBuffer,\n this.sectorBuffer\n ]\n }\n }\n\n updateData (what: LabelDataField & {color?: boolean}, data: StructureRepresentationData) {\n super.updateData(what, data)\n const lineData = {}\n const planeData = {}\n const sectorData = {}\n\n if (what.color) {\n const c = new Color(this.colorValue)\n Object.assign(lineData, {\n color: uniformArray3(this.lineLength, c.r, c.g, c.b),\n color2: uniformArray3(this.lineLength, c.r, c.g, c.b)\n })\n Object.assign(planeData, {\n color: uniformArray3(this.planeLength, c.r, c.g, c.b)\n })\n Object.assign(sectorData, {\n color: uniformArray3(this.sectorLength, c.r, c.g, c.b)\n })\n }\n\n this.lineBuffer.setAttributes(lineData)\n this.planeBuffer.setAttributes(planeData)\n this.sectorBuffer.setAttributes(sectorData)\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n super.setParameters(params, what, rebuild)\n\n if (params && (\n params.lineVisible !== undefined ||\n params.sectorVisible !== undefined ||\n params.planeVisible !== undefined)) {\n this.setVisibility(this.visible)\n }\n\n if (params && params.lineOpacity) {\n this.lineBuffer.setParameters({ opacity: params.lineOpacity })\n }\n\n if (params && params.opacity !== undefined) {\n this.lineBuffer.setParameters({ opacity: this.lineOpacity })\n }\n\n if (params && params.linewidth) {\n this.lineBuffer.setParameters({ linewidth: params.linewidth })\n }\n\n return this\n }\n\n setVisibility (value: boolean, noRenderRequest?: boolean) {\n super.setVisibility(value, true)\n\n if (this.lineBuffer) {\n this.lineBuffer.setVisibility(this.lineVisible && this.visible)\n }\n\n if (this.planeBuffer) {\n this.planeBuffer.setVisibility(this.planeVisible && this.visible)\n }\n\n if (this.sectorBuffer) {\n this.sectorBuffer.setVisibility(this.sectorVisible && this.visible)\n }\n\n if (!noRenderRequest) this.viewer.requestRender()\n\n return this\n }\n}\n\n/**\n * Build the data required to create {Buffer} objects, given positions\n * @param {Float32Array} atomPosition 3*4*nDihedral array of coordinates\n * @return {Object} Arrays for building buffers\n */\nfunction getDihedralData (position: Float32Array, params: Partial = {}) {\n const angleStep = defaults(params.angleStep, Math.PI / 90)\n const nPos = position.length\n const n = position.length / 12\n const angles = new Float32Array(n)\n const labelPosition = new Float32Array(n * 3)\n const labelText = new Array(n)\n\n // Temporary arrays as don't know output length yet\n const lineTmp1 = new Array(n)\n const lineTmp2 = new Array(n)\n const sectorTmp = new Array(n)\n const planeTmp = new Array(n)\n\n // Eventual sizes of output arrays\n let totalLines = 0\n let totalSegments = 0\n let totalPlanes = 0\n\n const p1 = v3new()\n const p2 = v3new()\n const p3 = v3new()\n const p4 = v3new()\n\n const v21 = v3new()\n const v23 = v3new()\n const v34 = v3new()\n\n const tmp = v3new()\n const mid = v3new()\n const inPlane1 = v3new()\n const inPlane2 = v3new()\n const start = v3new()\n const end = v3new()\n\n const cross = v3new()\n const arcPoint = v3new()\n\n let i = 0 // Actual output index (after skipping inappropriate)\n\n for (var p = 0; p < nPos; p += 12) {\n // Set Positions\n v3fromArray(p1, position, p)\n v3fromArray(p2, position, p + 3)\n v3fromArray(p3, position, p + 6)\n v3fromArray(p4, position, p + 9)\n\n // Vectors between points\n v3sub(v21, p1, p2)\n v3sub(v23, p3, p2)\n if (v3length(v23) === 0.0) {\n continue // Can't define axis\n }\n\n v3sub(v34, p4, p3)\n\n v3multiplyScalar(tmp, v23, 0.5)\n v3add(mid, p2, tmp)\n\n v3normalize(v21, v21)\n v3normalize(v23, v23)\n v3normalize(v34, v34)\n\n // Which side of plane are p1, p4 (are we measuring something that\n // looks more like an improper? e.g. C, CA, CB, N)\n v3sub(tmp, p1, mid)\n const improperStart = v3dot(tmp, v23) > 0.0\n v3sub(tmp, p4, mid)\n const improperEnd = v3dot(tmp, v23) < 0.0\n\n // Calculate vectors perp to v23 (lying in plane (1,2,3) and (2,3,4))\n v3multiplyScalar(tmp, v23, v3dot(v23, v21))\n v3sub(inPlane1, v21, tmp)\n\n v3multiplyScalar(tmp, v23, v3dot(v23, v34))\n v3sub(inPlane2, v34, tmp)\n\n if (v3length(inPlane1) === 0.0 || v3length(inPlane2) === 0.0) {\n continue // Indeterminate angle\n }\n\n v3normalize(inPlane1, inPlane1)\n v3normalize(inPlane2, inPlane2)\n\n const angle = angles[ i ] = v3angle(inPlane1, inPlane2)\n labelText[ i ] = (RAD2DEG * angle).toFixed(1) + String.fromCharCode(0x00B0)\n\n v3cross(cross, inPlane1, v23)\n v3normalize(cross, cross)\n if (v3dot(cross, inPlane2) < 0.0) {\n v3negate(cross, cross) // Ensure cp faces correct way\n }\n\n calcArcPoint(tmp, mid, inPlane1, cross, angle / 2.0)\n v3toArray(tmp, labelPosition, 3 * i)\n\n const nSegments = Math.ceil(angle / angleStep)\n // For extended display mode, 4 straight lines plus arc/segment edge\n // For non-extended, 2 straight lines plus segment edge\n const nLines = nSegments + ((params.extendLine) ? 4 : 2)\n\n // Don't draw planes if not extending lines\n const nPlanes = params.extendLine ? 36 : 0\n\n const line1 = new Float32Array(nLines * 3)\n const line2 = new Float32Array(nLines * 3)\n const sector = new Float32Array(nSegments * 9)\n // 2 planes, 2 triangles each per dihedral (2*2*9)\n const plane = new Float32Array(nPlanes)\n\n lineTmp1[ i ] = line1\n lineTmp2[ i ] = line2\n sectorTmp[ i ] = sector\n planeTmp[ i ] = plane\n\n // Start points for lines/planes, only required\n // if extending lines\n if (params.extendLine) {\n if (improperStart) { // We'll start on the v3->1 line (tmp)\n v3sub(tmp, p1, p3)\n v3normalize(tmp, tmp)\n v3multiplyScalar(start, tmp, 1.0 / v3dot(inPlane1, tmp))\n v3add(start, start, p3)\n } else { // start on the 2->1 line\n v3multiplyScalar(start, v21, 1.0 / v3dot(inPlane1, v21))\n v3add(start, start, p2)\n }\n\n if (improperEnd) { // Finish on 2->4 line\n v3sub(tmp, p4, p2)\n v3normalize(tmp, tmp)\n v3multiplyScalar(end, tmp, 1.0 / v3dot(inPlane2, tmp))\n v3add(end, end, p2)\n } else { // end on the 3->4 line\n v3multiplyScalar(end, v34, 1.0 / v3dot(inPlane2, v34))\n v3add(end, end, p3)\n }\n }\n\n v3add(arcPoint, mid, inPlane1)\n\n // index into line1, line2\n let li = 0\n // If extending lines, there's a bit of stuff to do here\n // figuring out start and end positions\n if (params.extendLine) {\n v3toArray(p1, line1, li)\n v3toArray(start, line2, li)\n li += 3\n v3toArray(start, line1, li)\n v3toArray(arcPoint, line2, li)\n li += 3\n\n // Construct plane at start, if not extening lines\n // this is skipped\n v3toArray(start, plane, 0)\n v3toArray(arcPoint, plane, 3)\n v3toArray(improperStart ? p3 : p2, plane, 6)\n v3toArray(improperStart ? p3 : p2, plane, 9)\n v3toArray(arcPoint, plane, 12)\n v3toArray(mid, plane, 15)\n } else {\n // Not extending lines\n v3toArray(mid, line1, li)\n v3toArray(arcPoint, line2, li)\n li += 3\n }\n\n const appendArcSection = function (a: number, j: number) {\n const si = j * 9\n\n v3toArray(mid, sector, si)\n v3toArray(arcPoint, sector, si + 3)\n v3toArray(arcPoint, line1, li)\n\n calcArcPoint(arcPoint, mid, inPlane1, cross, a)\n\n v3toArray(arcPoint, sector, si + 6)\n v3toArray(arcPoint, line2, li)\n li += 3\n }\n\n let j = 0\n for (let a = angleStep; a < angle; a += angleStep) {\n appendArcSection(a, j++)\n }\n appendArcSection(angle, j++)\n\n if (params.extendLine) {\n v3toArray(arcPoint, line1, (nLines - 2) * 3)\n v3toArray(end, line2, (nLines - 2) * 3)\n v3toArray(end, line1, (nLines - 1) * 3)\n v3toArray(p4, line2, (nLines - 1) * 3)\n\n // Construct plane at end\n v3toArray(end, plane, 18)\n v3toArray(arcPoint, plane, 21)\n v3toArray(improperEnd ? p2 : p3, plane, 24)\n v3toArray(improperEnd ? p2 : p3, plane, 27)\n v3toArray(arcPoint, plane, 30)\n v3toArray(mid, plane, 33)\n } else {\n v3toArray(arcPoint, line1, li)\n v3toArray(mid, line2, li)\n li += 3\n }\n\n totalLines += nLines * 3\n totalSegments += nSegments * 9\n totalPlanes += nPlanes\n i += 1\n }\n\n const nSuccess = i\n\n const linePosition1 = new Float32Array(totalLines)\n const linePosition2 = new Float32Array(totalLines)\n const sectorPosition = new Float32Array(totalSegments)\n const planePosition = new Float32Array(totalPlanes)\n\n let lineOffset = 0\n let sectorOffset = 0\n let planeOffset = 0\n\n for (let i = 0; i < nSuccess; i++) {\n const lp1 = lineTmp1[ i ]\n const lp2 = lineTmp2[ i ]\n const sp = sectorTmp[ i ]\n const pp = planeTmp[ i ]\n\n copyArray(lp1, linePosition1, 0, lineOffset, lp1.length)\n copyArray(lp2, linePosition2, 0, lineOffset, lp2.length)\n copyArray(sp, sectorPosition, 0, sectorOffset, sp.length)\n copyArray(pp, planePosition, 0, planeOffset, pp.length)\n\n lineOffset += lp1.length\n sectorOffset += sp.length\n planeOffset += pp.length\n }\n\n return {\n labelPosition: labelPosition.subarray(0, nSuccess * 3),\n labelText: labelText.slice(0, nSuccess),\n linePosition1,\n linePosition2,\n planePosition,\n sectorPosition\n }\n}\n\nRepresentationRegistry.add('dihedral', DihedralRepresentation)\n\nexport default DihedralRepresentation\n","/**\n * @file Dihedral Histogram Representation\n * @author Rudolfs Petrovs \n * @private\n */\nimport { Color } from 'three'\n\nimport { calcArcPoint, parseNestedAtoms } from './measurement-representation'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\n\nimport { RepresentationRegistry } from '../globals'\nimport { Structure } from '../ngl'\nimport { defaults } from '../utils'\n\nimport { BufferData } from '../buffer/buffer'\nimport MeshBuffer from '../buffer/mesh-buffer'\nimport WideLineBuffer, { WideLineBufferData } from '../buffer/wideline-buffer'\n\nimport { copyArray, uniformArray3, arraySum } from '../math/array-utils'\nimport {\n v3add, v3cross, v3dot, v3multiplyScalar, v3fromArray,\n v3negate, v3new, v3normalize, v3sub, v3toArray, v3length\n} from '../math/vector-utils'\n\nimport StructureView from '../structure/structure-view'\n\nimport Viewer from '../viewer/viewer'\n\n\nconst pointLength = 3 // One Point Length (number of coordinates of one point in 3D)\nconst pointsInTriangle = 3\n\ntype ColorDefinition = Color | string | number | undefined\n\ninterface HistogramColorParameters {\n histogramBinBorderColor: ColorDefinition\n adjacentBondArrowColor: ColorDefinition\n distantBondArrowColor: ColorDefinition\n frontHistogramColor: ColorDefinition\n backHistogramColor: ColorDefinition\n opaqueMiddleDiscColor: ColorDefinition\n}\n\ninterface HistogramInputData extends Partial {\n atomQuad: (number | string)[]\n histogram360: number[]\n}\n\ninterface HistogramData extends HistogramInputData {\n atomPositions: Float32Array\n histogram360Scaled: number[]\n}\n\ninterface WideLineData {\n startPoints: Float32Array\n endPoints: Float32Array\n startColors: Float32Array\n endColors: Float32Array\n}\n\ninterface MeshData {\n triangles: Float32Array\n triangleColors: Float32Array\n}\n\nfunction createUpdatedObject(o: Object, updateSource: Object) {\n function hasKey(obj: O, key: keyof any): key is keyof O {\n return key in obj\n }\n\n const result = { ...o } // Shallow copy\n for (const key in result) {\n if (hasKey(result, key) && hasKey(updateSource, key)) {\n result[key] = defaults(updateSource[key], result[key])\n }\n }\n return result\n}\n\nfunction createColorArray(color: ColorDefinition, arrayLength: number) {\n const colorValue = new Color(color)\n const targetArray = new Float32Array(arrayLength * 3)\n uniformArray3(arrayLength, colorValue.r, colorValue.g, colorValue.b, targetArray)\n return targetArray\n}\n\n/**\n * @typedef {Object} DihedralHistogramRepresentationParameters - dihedral representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n *\n * @property {HistogramInputData[]} histogramsData\n * List of HistogramInputData objects, which properties specifies each particular\n * histogram, and can contain particular histogram-specific parameters.\n * Obligatory properties are:\n * atomQuad - Quadruplet of selection strings or atom indices\n * histogram360 - List of values, representing histogram from 0 to 360 degrees.\n * @property {Boolean} histogramBinBorderVisible - Display the lines that separate circular histogram bins\n * @property {Boolean} scaleBinToSectorArea - Should sector-based histogram bins'\n * area be proportional to the bins' value\n */\n\nexport interface DihedralHistogramRepresentationParameters extends StructureRepresentationParameters {\n histogramsData: HistogramInputData[]\n\n histogramBinBorderVisible: boolean\n scaleBinToSectorArea: boolean\n}\n\n/**\n * Dihedral Histogram representation object\n *\n * Reperesentation consists of several parts:\n * opaqueMiddleDisc - opaque disc in the middle of the dihedral between front and back histograms\n * frontHistogram - circular histogram from the adjacent bond viewpoint\n * backHistogram - circular histogram from the distant bond viewpoint\n * histogramBinBorder - lines, which separate histogram bins\n * bondArrows - lines, which show the actual angle on the histogram disc\n *\n * @param {Structure} structure - the structure to measure angles in\n * @param {Viewer} viewer - a viewer object\n * @param {DihedralHistogramRepresentationParameters} params - Dihedral histogram representation parameters\n */\nclass DihedralHistogramRepresentation extends StructureRepresentation {\n protected histogramsData: HistogramData[]\n\n protected histogramBinBorderVisible: boolean\n protected histogramBinBorderWidth: number\n protected histogramBinBorderColor: ColorDefinition\n protected histogramBinBorderOpacity: number\n\n protected bondArrowVisible: boolean\n protected bondArrowWidth: number\n protected bondArrowOpacity: number\n\n protected adjacentBondArrowColor: ColorDefinition\n protected distantBondArrowColor: ColorDefinition\n\n protected histogramOpacity: number\n protected frontHistogramColor: ColorDefinition\n protected backHistogramColor: ColorDefinition\n\n protected opaqueMiddleDiscVisible: boolean\n protected opaqueMiddleDiscColor: ColorDefinition\n protected opaqueMiddleDiscOpacity: number\n\n protected scaleBinToSectorArea: boolean\n\n constructor(structure: Structure, viewer: Viewer, params: DihedralHistogramRepresentationParameters) {\n super(structure, viewer, params)\n\n this.type = 'dihedral-histogram'\n\n this.parameters = Object.assign({\n histogramsData: {\n type: 'hidden', rebuild: true\n },\n histogramBinBorderVisible: {\n type: 'boolean', default: true\n },\n scaleBinToSectorArea: {\n type: 'boolean',\n rebuild: true,\n default: false\n }\n }, this.parameters)\n\n this.init(params)\n }\n\n init(params: Partial) {\n const p = params || {}\n\n const defaultColorData = {\n histogramBinBorderColor: 'grey',\n adjacentBondArrowColor: 'black',\n distantBondArrowColor: 'magenta',\n frontHistogramColor: 'green',\n backHistogramColor: 'blue',\n opaqueMiddleDiscColor: 'white'\n }\n\n const colorData = createUpdatedObject(defaultColorData, p)\n Object.assign(this, colorData)\n\n const defaultParameters = {\n histogramsData: [],\n histogramOpacity: 1.0,\n\n opaqueMiddleDiscVisible: true,\n opaqueMiddleDiscOpacity: 1.0,\n\n histogramBinBorderVisible: true,\n histogramBinBorderWidth: 1,\n histogramBinBorderOpacity: 0.5,\n\n bondArrowVisible: true,\n bondArrowWidth: 2,\n bondArrowOpacity: 1.0,\n\n scaleBinToSectorArea: false,\n }\n const parameters = createUpdatedObject(defaultParameters, p)\n Object.assign(this, parameters)\n\n this.histogramsData.forEach(x => {\n const specificColorData = createUpdatedObject(colorData, x)\n Object.assign(x, specificColorData)\n })\n\n p.side = defaults(p.side, 'double')\n p.opacity = defaults(p.opacity, 0.5)\n p.radiusType = defaults(p.radiusType, 'size')\n p.radiusSize = defaults(p.radiusSize, 0.15)\n\n super.init(p)\n }\n\n getHistogramBinBorderBufferParameters() {\n return this.getBufferParams({\n linewidth: this.histogramBinBorderWidth,\n visible: this.histogramBinBorderVisible,\n opacity: this.histogramBinBorderOpacity,\n })\n }\n\n getBondArrowsBufferParameters() {\n return this.getBufferParams({\n linewidth: this.bondArrowWidth,\n visible: this.bondArrowVisible,\n opacity: this.bondArrowOpacity,\n })\n }\n\n getOpaqueMiddleDiscBufferParameters() {\n return this.getBufferParams({\n visible: this.opaqueMiddleDiscVisible,\n opacity: this.opaqueMiddleDiscOpacity\n })\n }\n\n getHistogramBufferParameters() {\n return this.getBufferParams({\n visible: true,\n opacity: this.histogramOpacity,\n side: \"double\"\n })\n }\n\n createData(sview: StructureView) {\n if (!sview.atomCount || !this.histogramsData.length) return\n this.histogramsData.forEach(x => x.atomPositions = parseNestedAtoms(sview, [x.atomQuad]))\n const scaleData = this.scaleBinToSectorArea ? function (y: number) { return Math.sqrt(y) } : function (y: number) { return y }\n this.histogramsData.forEach(x => x.histogram360Scaled = x.histogram360.map(scaleData))\n function Float32Concat(arrays: Float32Array[]) {\n const lengths = arrays.map(x => x.length)\n const result = new Float32Array(arraySum(lengths))\n let accumulatedOffset = 0\n for (let i = 0; i < arrays.length; i++) {\n result.set(arrays[i], accumulatedOffset)\n accumulatedOffset += arrays[i].length\n }\n return result\n }\n\n function createWideLineBuffer(linesList: WideLineData[], params: {}) {\n return new WideLineBuffer(\n {\n position1: Float32Concat(linesList.map(x => x.startPoints)),\n position2: Float32Concat(linesList.map(x => x.endPoints)),\n color: Float32Concat(linesList.map(x => x.startColors)),\n color2: Float32Concat(linesList.map(x => x.endColors)),\n } as WideLineBufferData,\n params)\n }\n\n function createMeshBuffer(mesh: MeshData[], params: {}) {\n return new MeshBuffer(\n {\n position: Float32Concat(mesh.map(x => x.triangles)),\n color: Float32Concat(mesh.map(x => x.triangleColors))\n } as BufferData,\n params)\n }\n\n const dihedralDataArray = []\n\n for (let i = 0; i < this.histogramsData.length; i++) {\n let dihedralData = undefined\n let currentHistogramData = this.histogramsData[i]\n let currentHistogram360 = currentHistogramData.histogram360\n if (currentHistogram360.length >= 3) {\n dihedralData = calculateDihedralHistogram(currentHistogramData)\n }\n if (typeof dihedralData === \"undefined\") continue\n dihedralDataArray.push(dihedralData)\n }\n\n this.frontHistogramBinBordersBuffer = createWideLineBuffer(\n dihedralDataArray.map(x => x.frontHistogramBinBorders),\n this.getHistogramBinBorderBufferParameters()\n )\n\n this.backHistogramBinBordersBuffer = createWideLineBuffer(\n dihedralDataArray.map(x => x.backHistogramBinBorders),\n this.getHistogramBinBorderBufferParameters()\n )\n\n this.adjacentBondArrowsBuffer = createWideLineBuffer(\n dihedralDataArray.map(x => x.adjacentBondArrows),\n this.getBondArrowsBufferParameters()\n )\n\n this.distantBondArrowsBuffer = createWideLineBuffer(\n dihedralDataArray.map(x => x.distantBondArrows),\n this.getBondArrowsBufferParameters()\n )\n\n this.opaqueMiddleDiscBuffer = createMeshBuffer(\n dihedralDataArray.map(x => x.opaqueMiddleDisc),\n this.getOpaqueMiddleDiscBufferParameters()\n )\n\n this.frontHistogramBuffer = createMeshBuffer(\n dihedralDataArray.map(x => x.frontHistogram),\n this.getHistogramBufferParameters()\n )\n\n this.backHistogramBuffer = createMeshBuffer(\n dihedralDataArray.map(x => x.backHistogram),\n this.getHistogramBufferParameters()\n )\n\n return {\n bufferList: [].concat(\n this.frontHistogramBinBordersBuffer,\n this.backHistogramBinBordersBuffer,\n this.adjacentBondArrowsBuffer,\n this.distantBondArrowsBuffer,\n this.opaqueMiddleDiscBuffer,\n this.frontHistogramBuffer,\n this.backHistogramBuffer\n )\n }\n }\n\n setParameters(params: Partial) {\n const rebuild = false\n const what = {}\n super.setParameters(params, what, rebuild)\n\n if (params && (params.histogramBinBorderVisible !== undefined)) {\n this.setVisibility(this.visible)\n }\n return this\n }\n\n setVisibility(value: boolean, noRenderRequest?: boolean) {\n super.setVisibility(value, true)\n if (this.frontHistogramBinBordersBuffer) {\n this.frontHistogramBinBordersBuffer.setVisibility(this.histogramBinBorderVisible)\n }\n if (this.backHistogramBinBordersBuffer) {\n this.backHistogramBinBordersBuffer.setVisibility(this.histogramBinBorderVisible)\n }\n if (!noRenderRequest) this.viewer.requestRender()\n return this\n }\n}\n\n/**\n * Calculates the data required to create {Buffer} objects for one histogram, given positions\n * @param Float32Array positionOfDihedralAtoms 3*4 array of coordinates\n * @param NumberArray histogram array of coordinates\n * @return Arrays for building buffers\n */\nfunction calculateDihedralHistogram(histogramData: HistogramData) {\n const positionOfDihedralAtoms = histogramData.atomPositions\n const histogram = histogramData.histogram360Scaled;\n const totalSectorTrianglesInOpaqueMiddleDisc = histogram.length <= 180 ? 360 : histogram.length * 2\n const frontAndBack = 2\n\n const opaqueMiddleDisc = {\n triangles: new Float32Array(totalSectorTrianglesInOpaqueMiddleDisc * pointsInTriangle * pointLength),\n triangleColors: createColorArray(histogramData.opaqueMiddleDiscColor, totalSectorTrianglesInOpaqueMiddleDisc * pointsInTriangle)\n }\n\n const frontHistogram = {\n triangles: new Float32Array(histogram.length * pointsInTriangle * pointLength),\n triangleColors: createColorArray(histogramData.frontHistogramColor, histogram.length * pointsInTriangle)\n }\n\n const backHistogram = {\n triangles: new Float32Array(histogram.length * pointsInTriangle * pointLength),\n triangleColors: createColorArray(histogramData.backHistogramColor, histogram.length * pointsInTriangle)\n }\n\n const frontHistogramBinBorders = {\n startPoints: new Float32Array(histogram.length * pointLength),\n endPoints: new Float32Array(histogram.length * pointLength),\n startColors: createColorArray(histogramData.histogramBinBorderColor, histogram.length),\n endColors: createColorArray(histogramData.histogramBinBorderColor, histogram.length)\n }\n\n const backHistogramBinBorders = {\n startPoints: new Float32Array(histogram.length * pointLength),\n endPoints: new Float32Array(histogram.length * pointLength),\n startColors: createColorArray(histogramData.histogramBinBorderColor, histogram.length),\n endColors: createColorArray(histogramData.histogramBinBorderColor, histogram.length)\n }\n\n const adjacentBondArrows = {\n startPoints: new Float32Array(frontAndBack * pointLength),\n endPoints: new Float32Array(frontAndBack * pointLength),\n startColors: createColorArray(histogramData.adjacentBondArrowColor, histogram.length),\n endColors: createColorArray(histogramData.adjacentBondArrowColor, histogram.length)\n }\n const distantBondArrows = {\n startPoints: new Float32Array(frontAndBack * pointLength),\n endPoints: new Float32Array(frontAndBack * pointLength),\n startColors: createColorArray(histogramData.distantBondArrowColor, histogram.length),\n endColors: createColorArray(histogramData.distantBondArrowColor, histogram.length)\n }\n\n const p1 = v3new()\n const p2 = v3new()\n const p3 = v3new()\n const p4 = v3new()\n\n const v21 = v3new()\n const v23 = v3new()\n const v32 = v3new()\n const v34 = v3new()\n\n const mid = v3new()\n const inPlane1 = v3new()\n const inPlane2 = v3new()\n\n const cross1 = v3new()\n const cross2 = v3new()\n\n const arcPoint = v3new()\n const tmp = v3new()\n const tmp2 = v3new()\n\n // Set Atom Coordinates\n const dihedralAtomVectors = [p1, p2, p3, p4]\n\n for (let i = 0; i < dihedralAtomVectors.length; i++) {\n v3fromArray(dihedralAtomVectors[i], positionOfDihedralAtoms, i * pointLength)\n }\n\n // Vectors between points\n v3sub(v21, p1, p2)\n v3sub(v23, p3, p2)\n v3sub(v34, p4, p3)\n if (v3length(v23) === 0.0) {\n return // Can't define axis\n }\n\n v3multiplyScalar(tmp, v23, 0.5)\n v3add(mid, p2, tmp)\n\n v3normalize(v21, v21)\n v3normalize(v23, v23)\n v3normalize(v34, v34)\n\n v3negate(v32, v23)\n // Calculate vectors perp to v23 (lying in plane (1,2,3) and (2,3,4))\n v3multiplyScalar(tmp, v32, v3dot(v32, v21))\n v3sub(inPlane1, v21, tmp)\n\n v3multiplyScalar(tmp, v23, v3dot(v23, v34))\n v3sub(inPlane2, v34, tmp)\n\n if (v3length(inPlane1) === 0.0 || v3length(inPlane2) === 0.0) {\n return // Indeterminate angle\n }\n\n v3normalize(inPlane1, inPlane1)\n v3normalize(inPlane2, inPlane2)\n\n // Can use acos as normalized and non-zero\n const absAngle = Math.acos(v3dot(inPlane1, inPlane2))\n\n v3cross(cross1, v32, inPlane1)\n v3cross(cross2, v23, inPlane2)\n v3normalize(cross1, cross1)\n v3normalize(cross2, cross2)\n\n let angle = absAngle\n if (v3dot(cross1, inPlane2) < 0.0) {\n angle = -absAngle\n }\n\n v3add(arcPoint, mid, inPlane1)\n\n // Calculate necessary constants\n const maxHist = Math.max.apply(null, histogram)\n const histBinAngleStep = (Math.PI * 2) / histogram.length\n\n function setHistogramBinCoordinates(out: Float32Array, ind: number, zeroDegreeVector: Float32Array, crossVector: Float32Array, histBinAngleStep: number) {\n const startOffset = ind * pointsInTriangle * pointLength\n v3toArray(mid, out, startOffset)\n const scalingFactor = Number(histogram[ind]) / maxHist\n v3multiplyScalar(tmp, zeroDegreeVector, scalingFactor)\n v3multiplyScalar(tmp2, crossVector, scalingFactor)\n calcArcPoint(arcPoint, mid, tmp, tmp2, ind * histBinAngleStep)\n v3toArray(arcPoint, out, startOffset + 1 * pointLength)\n calcArcPoint(arcPoint, mid, tmp, tmp2, (ind + 1) * histBinAngleStep)\n v3toArray(arcPoint, out, startOffset + 2 * pointLength)\n }\n\n function setOneSideHistogram(discHistogram: MeshData, binBorders: { startPoints: Float32Array, endPoints: Float32Array }, ind: number, zeroDegreeVector: Float32Array, crossVector: Float32Array) {\n // Set Bond Arrows\n\n copyArray(mid, adjacentBondArrows.startPoints, 0, ind * pointLength, mid.length)\n calcArcPoint(tmp, mid, zeroDegreeVector, crossVector, 0 + histBinAngleStep * 0)\n copyArray(tmp, adjacentBondArrows.endPoints, 0, ind * pointLength, mid.length)\n\n copyArray(mid, distantBondArrows.startPoints, 0, ind * pointLength, mid.length)\n calcArcPoint(tmp, mid, zeroDegreeVector, crossVector, angle)\n copyArray(tmp, distantBondArrows.endPoints, 0, ind * pointLength, mid.length)\n\n // Set Histogram Bin Borders\n\n for (let i = 0; i < histogram.length; i++) {\n copyArray(mid, binBorders.startPoints, 0, i * 3, mid.length)\n calcArcPoint(tmp, mid, zeroDegreeVector, crossVector, 0 + histBinAngleStep * i)\n copyArray(tmp, binBorders.endPoints, 0, i * 3, tmp.length)\n }\n\n // Set Histogram Bins\n\n for (let sectionIndex = 0; sectionIndex < histogram.length; sectionIndex++) {\n setHistogramBinCoordinates(discHistogram.triangles, sectionIndex, zeroDegreeVector, crossVector, histBinAngleStep)\n }\n }\n\n // Opaque disc\n const opaqueCircleSectorAngleStep = Math.PI * 2 / totalSectorTrianglesInOpaqueMiddleDisc\n\n for (let sectionIndex = 0; sectionIndex < totalSectorTrianglesInOpaqueMiddleDisc; sectionIndex++) {\n const startOffset = sectionIndex * pointsInTriangle * pointLength\n v3toArray(mid, opaqueMiddleDisc.triangles, startOffset)\n calcArcPoint(arcPoint, mid, inPlane1, cross1, sectionIndex * opaqueCircleSectorAngleStep)\n v3toArray(arcPoint, opaqueMiddleDisc.triangles, startOffset + 1 * pointLength)\n calcArcPoint(arcPoint, mid, inPlane1, cross1, (sectionIndex + 1) * opaqueCircleSectorAngleStep)\n v3toArray(arcPoint, opaqueMiddleDisc.triangles, startOffset + 2 * pointLength)\n }\n\n // Front Histogram\n const distanceToOpaqueDisc = 0.01\n v3multiplyScalar(tmp, v23, -distanceToOpaqueDisc) // Get a vector to move \"mid\" just a bit from opaque disc\n v3add(mid, mid, tmp)\n setOneSideHistogram(frontHistogram, frontHistogramBinBorders, 0, inPlane1, cross1)\n\n // Back Histogram\n v3multiplyScalar(tmp, v23, 2 * distanceToOpaqueDisc) // Get a vector to move \"mid\" back and plus just a bit from opaque disc the other way\n v3add(mid, mid, tmp)\n setOneSideHistogram(backHistogram, backHistogramBinBorders, 1, inPlane2, cross2)\n\n return {\n opaqueMiddleDisc,\n frontHistogram,\n backHistogram,\n frontHistogramBinBorders,\n backHistogramBinBorders,\n adjacentBondArrows,\n distantBondArrows\n }\n}\n\nRepresentationRegistry.add('dihedral-histogram', DihedralHistogramRepresentation)\n\nexport default DihedralHistogramRepresentation\n","/**\n * @file Distance Representation\n * @author Alexander Rose \n * @author Fred Ludlow \n * @private\n */\n\nimport { Color } from 'three'\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { DistancePicker } from '../utils/picker'\nimport { uniformArray, uniformArray3 } from '../math/array-utils'\nimport BitArray from '../utils/bitarray'\nimport MeasurementRepresentation, { MeasurementRepresentationParameters } from './measurement-representation'\nimport Selection from '../selection/selection'\nimport BondStore from '../store/bond-store'\nimport TextBuffer, { TextBufferData, TextBufferParameters } from '../buffer/text-buffer'\nimport WideLineBuffer from '../buffer/wideline-buffer'\nimport CylinderBuffer, { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport { getFixedLengthDashData } from '../geometry/dash'\nimport Viewer from '../viewer/viewer';\nimport { Structure } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport { BondDataFields, BondDataParams, BondData } from '../structure/structure-data';\nimport { StructureRepresentationData } from './structure-representation';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\n\n/**\n * Distance representation parameter object.\n * @typedef {Object} DistanceRepresentationParameters - distance representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n * @mixes MeasurementRepresentationParameters\n *\n * @property {String} labelUnit - distance unit (e.g. \"angstrom\" or \"nm\"). If set, a distance\n * symbol is appended to the label (i.e. 'nm' or '\\u00C5'). In case of 'nm', the\n * distance value is computed in nanometers instead of Angstroms.\n * @property {Array[]} atomPair - list of pairs of selection strings (see {@link Selection})\n * or pairs of atom indices. Using atom indices is much more\n * efficient when the representation is updated often, e.g. by\n * changing the selection or the atom positions, as there\n * are no selection strings to be evaluated.\n */\nexport interface DistanceRepresentationParameters extends MeasurementRepresentationParameters {\n labelUnit: string\n atomPair: AtomPair\n useCylinder: boolean\n}\nexport type AtomPair = (number|string)[][]\n/**\n * Distance representation\n */\nclass DistanceRepresentation extends MeasurementRepresentation {\n protected labelUnit: string\n protected atomPair: AtomPair\n protected useCylinder: boolean\n protected distanceBuffer: WideLineBuffer|CylinderGeometryBuffer\n /**\n * Create Distance representation object\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\" );\n * // either give selections (uses first selected atom) ...\n * var atomPair = [ [ \"1.CA\", \"4.CA\" ], [ \"7.CA\", \"13.CA\" ] ];\n * // or atom indices\n * var atomPair = [ [ 8, 28 ], [ 173, 121 ] ];\n * o.addRepresentation( \"distance\", { atomPair: atomPair } );\n * stage.autoView();\n * } );\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {DistanceRepresentationParameters} params - distance representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'distance'\n\n this.parameters = Object.assign({\n radialSegments: true,\n openEnded: true,\n disableImpostor: true,\n labelUnit: {\n type: 'select',\n rebuild: true,\n options: { '': '', angstrom: 'angstrom', nm: 'nm' }\n },\n useCylinder: {\n type: 'boolean', rebuild: true\n },\n atomPair: {\n type: 'hidden', rebuild: true\n }\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.linewidth = defaults(p.linewidth, 5.0)\n p.radiusType = defaults(p.radiusType, 'size')\n p.radiusSize = defaults(p.radiusSize, 0.2)\n\n this.labelUnit = defaults(p.labelUnit, '')\n this.useCylinder = defaults(p.useCylinder, false)\n this.atomPair = defaults(p.atomPair, [])\n\n super.init(p)\n }\n\n getDistanceData (sview: StructureView, atomPair: AtomPair) {\n let n = atomPair.length\n const text = new Array(n)\n let position = new Float32Array(n * 3)\n const sele1 = new Selection()\n const sele2 = new Selection()\n\n const bondStore = new BondStore()\n\n const ap1 = sview.getAtomProxy()\n const ap2 = sview.getAtomProxy()\n\n let j = 0 // Skipped pairs\n const selected = sview.getAtomSet()\n\n atomPair.forEach((pair, i) => {\n let v1 = pair[ 0 ]\n let v2 = pair[ 1 ]\n\n if (typeof(v1) === 'number' && Number.isInteger(v1) && typeof(v2) === 'number' && Number.isInteger(v2)) {\n if (selected.get(v1) && selected.get(v2)) {\n ap1.index = v1\n ap2.index = v2\n } else {\n j += 1\n return\n }\n } else {\n sele1.setString(v1 as string)\n sele2.setString(v2 as string)\n\n var atomIndices1 = sview.getAtomIndices(sele1)\n var atomIndices2 = sview.getAtomIndices(sele2)\n\n if (atomIndices1!.length && atomIndices2!.length) {\n ap1.index = atomIndices1![ 0 ]\n ap2.index = atomIndices2![ 0 ]\n } else {\n j += 1\n return\n }\n }\n\n bondStore.addBond(ap1, ap2, 1)\n\n i -= j\n var d = ap1.distanceTo(ap2)\n switch (this.labelUnit) {\n case 'angstrom':\n text[ i ] = d.toFixed(2) + ' ' + String.fromCharCode(0x212B)\n break\n case 'nm':\n text[ i ] = (d / 10).toFixed(2) + ' nm'\n break\n default:\n text[ i ] = d.toFixed(2)\n break\n }\n\n var i3 = i * 3\n position[ i3 + 0 ] = (ap1.x + ap2.x) / 2\n position[ i3 + 1 ] = (ap1.y + ap2.y) / 2\n position[ i3 + 2 ] = (ap1.z + ap2.z) / 2\n })\n\n if (j > 0) {\n n -= j\n position = position.subarray(0, n * 3)\n }\n\n var bondSet = new BitArray(bondStore.count, true)\n\n return {\n text: text,\n position: position,\n bondSet: bondSet,\n bondStore: bondStore\n }\n }\n\n getBondData (sview: StructureView, what: BondDataFields, params: BondDataParams): BondData {\n const bondData = sview.getBondData(this.getBondParams(what, params))\n if (bondData.picking) {\n bondData.picking = new DistancePicker(\n bondData.picking.array,\n bondData.picking.structure,\n params.bondStore!\n ) as any\n }\n return bondData\n }\n\n createData (sview: StructureView) {\n if (!sview.atomCount || !this.atomPair.length) return\n\n const n = this.atomPair.length\n const c = new Color(this.labelColor)\n const distanceData = this.getDistanceData(sview, this.atomPair)\n\n this.textBuffer = new TextBuffer({\n position: distanceData.position,\n size: uniformArray(n, this.labelSize),\n color: uniformArray3(n, c.r, c.g, c.b),\n text: distanceData.text\n } as TextBufferData, this.getLabelBufferParams() as TextBufferParameters)\n\n const bondParams = {\n bondSet: distanceData.bondSet,\n bondStore: distanceData.bondStore\n }\n\n const bondData = this.getBondData(\n sview,\n { position: true, color: true, picking: true, radius: this.useCylinder },\n bondParams\n )\n\n if (this.useCylinder) {\n this.distanceBuffer = new CylinderBuffer(\n bondData as CylinderBufferData,\n this.getBufferParams({\n openEnded: this.openEnded,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) \n ) as CylinderGeometryBuffer\n } else {\n this.distanceBuffer = new WideLineBuffer(\n getFixedLengthDashData(bondData as CylinderBufferData),\n this.getBufferParams({\n linewidth: this.linewidth,\n visible: this.lineVisible,\n opacity: this.lineOpacity\n })\n )\n }\n\n return {\n bondSet: distanceData.bondSet,\n bondStore: distanceData.bondStore,\n position: distanceData.position,\n bufferList: [ this.textBuffer, this.distanceBuffer ]\n }\n }\n\n updateData (what: BondDataFields, data: StructureRepresentationData) {\n super.updateData(what, data)\n\n const bondParams = {\n bondSet: data.bondSet,\n bondStore: data.bondStore\n }\n\n const bondData = this.getBondData(data.sview as StructureView, what, bondParams)\n const distanceData = {}\n\n if (!what || what.color) {\n Object.assign( distanceData, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n if (!what || what.radius) {\n Object.assign( distanceData, {radius: bondData.radius})\n }\n\n (this.distanceBuffer as CylinderGeometryBuffer).setAttributes(distanceData)\n }\n\n setParameters (params: Partial) {\n let rebuild = false\n const what = {}\n\n super.setParameters(params, what, rebuild)\n\n if (!this.useCylinder) {\n if (params && params.lineOpacity) {\n (this.distanceBuffer as WideLineBuffer).setParameters({ opacity: params.lineOpacity })\n }\n if (params && params.opacity !== undefined) {\n (this.distanceBuffer as WideLineBuffer).setParameters({ opacity: this.lineOpacity })\n }\n if (params && params.linewidth) {\n (this.distanceBuffer as WideLineBuffer).setParameters({ linewidth: params.linewidth })\n }\n }\n\n return this\n }\n}\n\nRepresentationRegistry.add('distance', DistanceRepresentation)\n\nexport default DistanceRepresentation\n","/**\n * @file Vector Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { Color, Matrix4, Vector3 } from 'three'\n\nimport '../shader/Line.vert'\nimport '../shader/Line.frag'\n\nimport { uniformArray3 } from '../math/array-utils'\nimport Buffer, { BufferDefaultParameters, BufferData, BufferParameters } from './buffer'\nimport { GenericColor } from '../types'\n\nfunction getSize(data: BufferData){\n const n = data.position!.length / 3\n return n * 2 * 3\n}\n\nexport interface VectorBufferData extends BufferData {\n vector: Float32Array\n}\n\nexport const VectorBufferDefaultParameters = Object.assign({\n scale: 1,\n color: 'grey'\n}, BufferDefaultParameters)\nexport type VectorBufferParameters = BufferParameters & { scale: number, color: GenericColor }\n\n/**\n * Vector buffer. Draws vectors as lines.\n */\nclass VectorBuffer extends Buffer {\n get defaultParameters() { return VectorBufferDefaultParameters }\n parameters: VectorBufferParameters\n\n isLine = true\n vertexShader = 'Line.vert'\n fragmentShader = 'Line.frag'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.vector - vectors\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: VectorBufferData, params: Partial = {}) {\n super({\n position: new Float32Array(getSize(data)),\n color: new Float32Array(getSize(data))\n }, params)\n\n const color = new Color(this.parameters.color)\n const attributes = this.geometry.attributes as any // TODO\n uniformArray3(getSize(data) / 3, color.r, color.g, color.b, attributes.color.array)\n\n this.setAttributes(data)\n }\n\n setAttributes (data: Partial = {}) {\n const attributes = this.geometry.attributes as any // TODO\n\n let position, vector\n let aPosition\n\n if (data.position && data.vector) {\n position = data.position\n vector = data.vector\n aPosition = attributes.position.array\n attributes.position.needsUpdate = true\n }\n\n const n = this.size / 2\n const scale = this.parameters.scale\n\n if (position && vector) {\n for (let v = 0; v < n; v++) {\n const i = v * 2 * 3\n const j = v * 3\n\n aPosition[ i + 0 ] = position[ j + 0 ]\n aPosition[ i + 1 ] = position[ j + 1 ]\n aPosition[ i + 2 ] = position[ j + 2 ]\n aPosition[ i + 3 ] = position[ j + 0 ] + vector[ j + 0 ] * scale\n aPosition[ i + 4 ] = position[ j + 1 ] + vector[ j + 1 ] * scale\n aPosition[ i + 5 ] = position[ j + 2 ] + vector[ j + 2 ] * scale\n }\n }\n }\n}\n\nexport default VectorBuffer\n","/**\n * @file Helixorient Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Helixorient from '../geometry/helixorient'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferParameters } from '../buffer/sphere-buffer'\nimport VectorBuffer from '../buffer/vector-buffer'\nimport Viewer from '../viewer/viewer';\nimport { Structure } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport Polymer from '../proxy/polymer';\nimport { AtomDataFields } from '../structure/structure-data';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\nimport SphereImpostorBuffer from '../buffer/sphereimpostor-buffer';\nimport { BufferData } from '../buffer/buffer';\n\n/**\n * Helixorient Representation\n */\nclass HelixorientRepresentation extends StructureRepresentation {\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'helixorient'\n\n this.parameters = Object.assign({\n sphereDetail: true,\n disableImpostor: true\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'sstruc')\n p.radiusType = defaults(p.radiusType, 'size')\n p.radiusSize = defaults(p.radiusSize, 0.15)\n p.radiusScale = defaults(p.radiusScale, 1.0)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n const bufferList: (SphereBuffer|VectorBuffer)[] = []\n const polymerList: Polymer[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4) return\n polymerList.push(polymer)\n\n const helixorient = new Helixorient(polymer)\n const position = helixorient.getPosition()\n const color = helixorient.getColor(this.getColorParams())\n const size = helixorient.getSize(this.getRadiusParams())\n const picking = helixorient.getPicking()\n\n bufferList.push(\n new SphereBuffer(\n {\n position: position.center,\n color: color.color,\n radius: size.size,\n picking: picking.picking\n },\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters\n ),\n new VectorBuffer(\n {\n position: position.center,\n vector: position.axis\n },\n this.getBufferParams({\n color: 'skyblue',\n scale: 1\n })\n ),\n new VectorBuffer(\n {\n position: position.center,\n vector: position.resdir\n },\n this.getBufferParams({\n color: 'lightgreen',\n scale: 1\n })\n )\n )\n }, sview.getSelection())\n\n return {\n bufferList: bufferList as (SphereGeometryBuffer|SphereImpostorBuffer|VectorBuffer)[],\n polymerList: polymerList\n }\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n if (Debug) Log.time(this.type + ' repr update')\n\n what = what || {}\n\n for (let i = 0, il = data.polymerList!.length; i < il; ++i) {\n const j = i * 3\n\n const bufferData: Partial = {}\n const polymer = data.polymerList![ i ]\n const helixorient = new Helixorient(polymer)\n\n if (what.position) {\n const position = helixorient.getPosition()\n\n Object.assign(bufferData, {position: position.center})\n\n data.bufferList[ j + 1 ].setAttributes({\n 'position': position.center,\n 'vector': position.axis\n })\n data.bufferList[ j + 2 ].setAttributes({\n 'position': position.center,\n 'vector': position.resdir\n })\n }\n\n data.bufferList[ j ].setAttributes(bufferData)\n }\n\n if (Debug) Log.timeEnd(this.type + ' repr update')\n }\n}\n\nRepresentationRegistry.add('helixorient', HelixorientRepresentation)\n\nexport default HelixorientRepresentation\n","/**\n * @file Licorice Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport BallAndStickRepresentation, { BallAndStickRepresentationParameters } from './ballandstick-representation'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\n\n/**\n * Licorice representation object ({@link BallAndStickRepresentation} with `aspectRatio` fixed at 1.0)\n */\nclass LicoriceRepresentation extends BallAndStickRepresentation {\n /**\n * Create Licorice representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {BallAndStickRepresentationParameters} params - ball and stick representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'licorice'\n\n this.parameters = Object.assign(\n {}, this.parameters, { aspectRatio: null }\n )\n }\n\n init (params: Partial) {\n var p = params || {}\n p.aspectRatio = 1.0\n\n super.init(p)\n }\n}\n\nRepresentationRegistry.add('licorice', LicoriceRepresentation)\n\nexport default LicoriceRepresentation\n","/**\n * @file Mapped Box Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { BufferParameters, BufferData } from './buffer'\nimport MappedBuffer from './mapped-buffer'\n\nconst mapping = new Float32Array([\n -1.0, -1.0, -1.0,\n 1.0, -1.0, -1.0,\n 1.0, -1.0, 1.0,\n -1.0, -1.0, 1.0,\n -1.0, 1.0, -1.0,\n 1.0, 1.0, -1.0,\n 1.0, 1.0, 1.0,\n -1.0, 1.0, 1.0\n])\n\nconst mappingIndices = new Uint16Array([\n 0, 1, 2,\n 0, 2, 3,\n 1, 5, 6,\n 1, 6, 2,\n 4, 6, 5,\n 4, 7, 6,\n 0, 7, 4,\n 0, 3, 7,\n 0, 5, 1,\n 0, 4, 5,\n 3, 2, 6,\n 3, 6, 7\n])\n\n/**\n * Mapped Box buffer. Draws boxes. Used to render general imposters.\n * @interface\n */\nclass MappedBoxBuffer extends MappedBuffer {\n constructor(data: BufferData, params: Partial = {}) {\n super('v3', data, params)\n }\n get mapping () { return mapping }\n get mappingIndices () { return mappingIndices }\n get mappingIndicesSize () { return 36 }\n get mappingSize () { return 8 }\n get mappingItemSize () { return 3 }\n}\n\nexport default MappedBoxBuffer\n","/**\n * @file Hyperball Stick Impostor Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3 required for declaration only\nimport { Matrix4, Vector3 } from 'three'\n\nimport '../shader/HyperballStickImpostor.vert'\nimport '../shader/HyperballStickImpostor.frag'\n\nimport MappedBoxBuffer from './mappedbox-buffer'\nimport { BufferDefaultParameters, BufferParameterTypes, BufferData, BufferParameters } from './buffer'\n\nexport interface HyperballStickImpostorBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n color2: Float32Array\n radius: Float32Array\n radius2: Float32Array\n}\n\nexport const HyperballStickImpostorBufferDefaultParameters = Object.assign({\n shrink: 0.14\n}, BufferDefaultParameters)\nexport type HyperballStickImpostorBufferParameters = BufferParameters & { shrink: number }\n\nconst HyperballStickImpostorBufferParameterTypes = Object.assign({\n shrink: { uniform: true }\n}, BufferParameterTypes)\n\n/**\n * Hyperball stick impostor buffer.\n *\n * @example\n * var hyperballStickImpostorBuffer = new HyperballStickImpostorBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 2, 2, 2 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ]),\n * radius2: new Float32Array([ 2 ])\n * });\n */\nclass HyperballStickImpostorBuffer extends MappedBoxBuffer {\n parameterTypes = HyperballStickImpostorBufferParameterTypes\n get defaultParameters() { return HyperballStickImpostorBufferDefaultParameters }\n parameters: HyperballStickImpostorBufferParameters\n\n isImpostor = true\n vertexShader = 'HyperballStickImpostor.vert'\n fragmentShader = 'HyperballStickImpostor.frag'\n\n constructor (data: HyperballStickImpostorBufferData, params: Partial = {}) {\n super(data, params)\n\n this.addUniforms({\n 'modelViewProjectionMatrix': { value: new Matrix4() },\n 'modelViewProjectionMatrixInverse': { value: new Matrix4() },\n 'modelViewMatrixInverseTranspose': { value: new Matrix4() },\n 'shrink': { value: this.parameters.shrink }\n })\n\n this.addAttributes({\n 'position1': { type: 'v3', value: null },\n 'position2': { type: 'v3', value: null },\n 'color2': { type: 'c', value: null },\n 'radius': { type: 'f', value: null },\n 'radius2': { type: 'f', value: null }\n })\n\n this.setAttributes(data)\n this.makeMapping()\n }\n}\n\nexport default HyperballStickImpostorBuffer\n","/**\n * @file Hyperball Stick Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import required for declaration only\nimport { Vector3, Matrix4 } from 'three'\nimport { ExtensionFragDepth } from '../globals'\nimport { calculateMinArray } from '../math/array-utils'\nimport CylinderGeometryBuffer, { CylinderGeometryBufferDefaultParameters, CylinderGeometryBufferParameters } from './cylindergeometry-buffer'\nimport HyperballStickImpostorBuffer, { HyperballStickImpostorBufferDefaultParameters, HyperballStickImpostorBufferParameters } from './hyperballstickimpostor-buffer'\nimport { BufferData } from './buffer'\n\nexport interface HyperballStickBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n color2: Float32Array\n radius: Float32Array\n radius2: Float32Array\n}\n\nexport const HyperballStickBufferDefaultParameters = Object.assign({\n disableImpostor: false\n}, CylinderGeometryBufferDefaultParameters, HyperballStickImpostorBufferDefaultParameters)\nexport type HyperballStickBufferParameters = HyperballStickImpostorBufferParameters & CylinderGeometryBufferParameters & { disableImpostor: boolean }\n\nclass HyperballStickBufferImpl {\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - from colors\n * @param {Float32Array} data.color2 - to colors\n * @param {Float32Array} data.radius - from radii\n * @param {Float32Array} data.radius2 - to radii\n * @param {Float32Array} data.picking - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: HyperballStickBufferData, params: Partial = {}) {\n if (!ExtensionFragDepth || (params && params.disableImpostor)) {\n data.radius = calculateMinArray(data.radius, data.radius2)\n return new CylinderGeometryBuffer(data, params)\n } else {\n return new HyperballStickImpostorBuffer(data, params)\n }\n }\n}\n\n/**\n * Hyperball stick buffer. Depending on the value {@link ExtensionFragDepth} and\n * `params.disableImpostor` the constructor returns either a\n * {@link CylinderGeometryBuffer} or a {@link HyperballStickImpostorBuffer}\n * @implements {Buffer}\n *\n * @example\n * var hyperballStickBuffer = new HyperballStickBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 2, 2, 2 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ]),\n * radius2: new Float32Array([ 2 ])\n * });\n */\n//@ts-expect-error Incompatible constructor signatures\nconst HyperballStickBuffer: {\n new(data: HyperballStickBufferData, params: Partial): CylinderGeometryBuffer | HyperballStickImpostorBuffer;\n} = HyperballStickBufferImpl;\n\ntype HyperballStickBuffer = CylinderGeometryBuffer | HyperballStickImpostorBuffer;\n\nexport default HyperballStickBuffer\n","/**\n * @file Hyperball Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { calculateCenterArray } from '../math/array-utils'\nimport LicoriceRepresentation from './licorice-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport HyperballStickBuffer, { HyperballStickBufferData } from '../buffer/hyperballstick-buffer'\nimport { BallAndStickRepresentationParameters } from './ballandstick-representation';\n// @ts-ignore: unused import Volume required for declaration only\nimport { Structure, Volume } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport { BondDataParams, BondDataFields, AtomDataFields } from '../structure/structure-data';\nimport StructureView from '../structure/structure-view';\nimport { StructureRepresentationData } from './structure-representation';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\n// @ts-ignore: unused import Surface required for declaration only\nimport Surface from '../surface/surface';\n\nexport interface HyperballRepresentationParameters extends BallAndStickRepresentationParameters {\n shrink: number\n}\n\n/**\n * Hyperball Representation\n */\nclass HyperballRepresentation extends LicoriceRepresentation {\n protected shrink: number\n protected __center: Float32Array\n \n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'hyperball'\n\n this.parameters = Object.assign({\n\n shrink: {\n type: 'number', precision: 3, max: 1.0, min: 0.001, buffer: true\n }\n\n }, this.parameters, {\n\n multipleBond: null,\n bondSpacing: null\n\n })\n }\n\n init (params: Partial) {\n var p = params || {}\n p.radiusScale = defaults(p.radiusScale, 0.2)\n p.radiusType = defaults(p.radiusType, 'vdw')\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.shrink = defaults(p.shrink, 0.12)\n\n super.init(p)\n }\n\n getBondParams (what?: BondDataFields, params?: BondDataParams) {\n if (!what || what.radius) {\n params = Object.assign({ radius2: true }, params)\n }\n\n return super.getBondParams(what, params)\n }\n\n createData (sview: StructureView) {\n var sphereBuffer = new SphereBuffer(\n (sview.getAtomData(this.getAtomParams()) as SphereBufferData),\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters\n ) as SphereGeometryBuffer\n\n this.__center = new Float32Array(sview.bondCount * 3)\n\n var stickBuffer = new HyperballStickBuffer(\n sview.getBondData(this.getBondParams()) as HyperballStickBufferData,\n this.getBufferParams({\n shrink: this.shrink,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n return {\n bufferList: [ sphereBuffer, stickBuffer ]\n }\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n var atomData = data.sview!.getAtomData(this.getAtomParams())\n var bondData = data.sview!.getBondData(this.getBondParams())\n var sphereData = {}\n var stickData = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {position: atomData.position})\n var from = bondData.position1\n var to = bondData.position2\n Object.assign(stickData, {\n position: calculateCenterArray(from!, to!, this.__center),\n position1: from,\n position2: to\n })\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {color: atomData.color})\n Object.assign(stickData, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {radius: atomData.radius})\n Object.assign(stickData, {\n radius: bondData.radius,\n radius2: bondData.radius2\n })\n }\n\n data.bufferList[ 0 ].setAttributes(sphereData)\n data.bufferList[ 1 ].setAttributes(stickData)\n }\n}\n\nRepresentationRegistry.add('hyperball', HyperballRepresentation)\n\nexport default HyperballRepresentation\n","/**\n * @file Label Factory\n * @author Alexander Rose \n * @private\n */\n\nimport { AA1 } from '../structure/structure-constants'\nimport AtomProxy from '../proxy/atom-proxy'\nimport { sprintf } from 'sprintf-js'\n\nexport const LabelFactoryTypes = {\n '': '',\n 'atomname': 'atom name',\n 'atomindex': 'atom index',\n 'occupancy': 'occupancy',\n 'bfactor': 'b-factor',\n 'serial': 'serial',\n 'element': 'element',\n 'atom': 'atom name + index',\n 'resname': 'residue name',\n 'resno': 'residue no',\n 'res': 'one letter code + no',\n 'residue': '[residue name] + no + inscode',\n 'text': 'text',\n 'format': 'format',\n 'qualified': 'qualified name'\n}\nexport type LabelType = keyof typeof LabelFactoryTypes\n\nclass LabelFactory {\n\n static types = LabelFactoryTypes\n errorLogged: boolean = false\n\n constructor(readonly type: LabelType, readonly text: { [k: number]: string } = {},\n readonly format: string = '') {}\n\n atomLabel (a: AtomProxy) {\n const type = this.type\n\n let l\n\n switch (type) {\n case 'atomname':\n l = a.atomname\n break\n\n case 'atomindex':\n l = `${a.index}`\n break\n\n case 'occupancy':\n l = a.occupancy.toFixed(2)\n break\n\n case 'bfactor':\n l = a.bfactor.toFixed(2)\n break\n\n case 'serial':\n l = `${a.serial}`\n break\n\n case 'element':\n l = a.element\n break\n\n case 'atom':\n l = `${a.atomname}|${a.index}`\n break\n\n case 'resname':\n l = a.resname\n break\n\n case 'resno':\n l = `${a.resno}`\n break\n\n case 'res':\n l = `${(AA1[ a.resname.toUpperCase() ] || a.resname)}${a.resno}`\n break\n\n case 'residue':\n const aa1 = AA1[ a.resname.toUpperCase() ]\n if (aa1 && !a.inscode) {\n l = `${aa1}${a.resno}`\n } else {\n l = `[${a.resname}]${a.resno}${a.inscode}`\n }\n break\n\n case 'text':\n l = this.text[ a.index ]\n break\n\n case 'format':\n try {\n l = sprintf(this.format, a)\n } catch (e) {\n if (!this.errorLogged) {\n this.errorLogged = true\n console.log(e.message)\n }\n }\n break\n\n // case \"qualified\":\n default:\n l = a.qualifiedName()\n break\n }\n\n return l === undefined ? '' : l\n }\n}\n\nexport default LabelFactory\n","/**\n * @file Label Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry, ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport LabelFactory, { LabelType } from '../utils/label-factory'\nimport RadiusFactory from '../utils/radius-factory'\nimport StructureRepresentation, { StructureRepresentationData } from './structure-representation'\nimport TextBuffer, { TextBufferData } from '../buffer/text-buffer'\nimport { RepresentationParameters } from './representation';\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { GenericColor } from '../types'\n\nexport interface TextDataField {\n position?: boolean\n color?: boolean\n radius?: boolean\n text?: boolean\n}\n\n/**\n * Label representation parameter object. Extends {@link RepresentationParameters} and\n * {@link StructureRepresentationParameters}.\n *\n * @typedef {Object} LabelRepresentationParameters - label representation parameters\n *\n * @property {Integer} clipNear - position of camera near/front clipping plane\n * in percent of scene bounding box\n * @property {Float} opacity - translucency: 1 is fully opaque, 0 is fully transparent\n * @property {String} labelType - type of the label, one of:\n * \"atomname\", \"atomindex\", \"occupancy\", \"bfactor\",\n * \"serial\", \"element\", \"atom\", \"resname\", \"resno\",\n * \"res\", \"text\", \"qualified\". When set to \"text\", the\n * `labelText` list is used.\n * @property {String[]} labelText - list of label strings, must set `labelType` to \"text\"\n * to take effect\n * @property {String} labelFormat - sprintf-js format string, any attribute of\n * {@link AtomProxy} can be used\n * @property {String} labelGrouping - grouping of the label, one of:\n * \"atom\", \"residue\".\n * @property {String} fontFamily - font family, one of: \"sans-serif\", \"monospace\", \"serif\"\n * @property {String} fontStyle - font style, \"normal\" or \"italic\"\n * @property {String} fontWeight - font weight, \"normal\" or \"bold\"\n * @property {Float} xOffset - offset in x-direction\n * @property {Float} yOffset - offset in y-direction\n * @property {Float} zOffset - offset in z-direction (i.e. in camera direction)\n * @property {String} attachment - attachment of the label, one of:\n * \"bottom-left\", \"bottom-center\", \"bottom-right\",\n * \"middle-left\", \"middle-center\", \"middle-right\",\n * \"top-left\", \"top-center\", \"top-right\"\n * @property {Boolean} showBorder - show border/outline\n * @property {Color} borderColor - color of the border/outline\n * @property {Float} borderWidth - width of the border/outline\n * @property {Boolean} showBackground - show background rectangle\n * @property {Color} backgroundColor - color of the background\n * @property {Float} backgroundMargin - width of the background\n * @property {Float} backgroundOpacity - opacity of the background\n * @property {Boolean} fixedSize - show text with a fixed pixel size\n */\nexport interface LabelRepresentationParameters extends RepresentationParameters {\n labelType: LabelType\n labelText: string[]\n labelFormat: string\n labelGrouping: 'atom'|'residue'\n fontFamily: 'sans-serif'|'monospace'|'serif'\n fontStyle: 'normal'|'italic'\n fontWeight: 'normal'|'bold'\n xOffset: number\n yOffset: number\n zOffset: number\n attachment: 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n showBorder: boolean\n borderColor: GenericColor\n borderWidth: number\n showBackground: boolean\n backgroundColor: GenericColor\n backgroundMargin: number\n backgroundOpacity: number\n fixedSize: boolean\n}\n/**\n * Label representation\n */\nclass LabelRepresentation extends StructureRepresentation {\n\n protected labelType: LabelType\n protected labelText: string[]\n protected labelFormat: string\n protected labelGrouping: 'atom'|'residue'\n protected fontFamily: 'sans-serif'|'monospace'|'serif'\n protected fontStyle: 'normal'|'italic'\n protected fontWeight: 'normal'|'bold'\n protected xOffset: number\n protected yOffset: number\n protected zOffset: number\n protected attachment: 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n protected showBorder: boolean\n protected borderColor: GenericColor\n protected borderWidth: number\n protected showBackground: boolean\n protected backgroundColor: GenericColor\n protected backgroundMargin: number\n protected backgroundOpacity: number\n protected fixedSize: boolean\n\n /**\n * Create Label representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {LabelRepresentationParameters} params - label representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'label'\n\n this.parameters = Object.assign({\n\n labelType: {\n type: 'select', options: LabelFactory.types, rebuild: true\n },\n labelText: {\n type: 'hidden', rebuild: true\n },\n labelFormat: {\n type: 'text', rebuild: true\n },\n labelGrouping: {\n type: 'select',\n options: {\n 'atom': 'atom',\n 'residue': 'residue'\n },\n rebuild: true\n },\n fontFamily: {\n type: 'select',\n options: {\n 'sans-serif': 'sans-serif',\n 'monospace': 'monospace',\n 'serif': 'serif'\n },\n buffer: true\n },\n fontStyle: {\n type: 'select',\n options: {\n 'normal': 'normal',\n 'italic': 'italic'\n },\n buffer: true\n },\n fontWeight: {\n type: 'select',\n options: {\n 'normal': 'normal',\n 'bold': 'bold'\n },\n buffer: true\n },\n xOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: true\n },\n yOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: true\n },\n zOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: true\n },\n attachment: {\n type: 'select',\n options: {\n 'bottom-left': 'bottom-left',\n 'bottom-center': 'bottom-center',\n 'bottom-right': 'bottom-right',\n 'middle-left': 'middle-left',\n 'middle-center': 'middle-center',\n 'middle-right': 'middle-right',\n 'top-left': 'top-left',\n 'top-center': 'top-center',\n 'top-right': 'top-right'\n },\n rebuild: true\n },\n showBorder: {\n type: 'boolean', buffer: true\n },\n borderColor: {\n type: 'color', buffer: true\n },\n borderWidth: {\n type: 'number', precision: 2, max: 0.3, min: 0, buffer: true\n },\n showBackground: {\n type: 'boolean', rebuild: true\n },\n backgroundColor: {\n type: 'color', buffer: true\n },\n backgroundMargin: {\n type: 'number', precision: 2, max: 2, min: 0, rebuild: true\n },\n backgroundOpacity: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n fixedSize: {\n type: 'boolean', buffer: true\n }\n\n }, this.parameters, {\n\n side: null,\n flatShaded: null,\n wireframe: null,\n linewidth: null,\n\n roughness: null,\n metalness: null,\n diffuse: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n\n this.labelType = defaults(p.labelType, 'res')\n this.labelText = defaults(p.labelText, {})\n this.labelFormat = defaults(p.labelFormat, '')\n this.labelGrouping = defaults(p.labelGrouping, 'atom')\n this.fontFamily = defaults(p.fontFamily, 'sans-serif')\n this.fontStyle = defaults(p.fontStyle, 'normal')\n this.fontWeight = defaults(p.fontWeight, 'bold')\n this.xOffset = defaults(p.xOffset, 0.0)\n this.yOffset = defaults(p.yOffset, 0.0)\n this.zOffset = defaults(p.zOffset, 0.5)\n this.attachment = defaults(p.attachment, 'bottom-left')\n this.showBorder = defaults(p.showBorder, false)\n this.borderColor = defaults(p.borderColor, 'lightgrey')\n this.borderWidth = defaults(p.borderWidth, 0.15)\n this.showBackground = defaults(p.showBackground, false)\n this.backgroundColor = defaults(p.backgroundColor, 'lightgrey')\n this.backgroundMargin = defaults(p.backgroundMargin, 0.5)\n this.backgroundOpacity = defaults(p.backgroundOpacity, 1.0)\n this.fixedSize = defaults(p.fixedSize, false)\n\n super.init(p)\n }\n\n getTextData (sview: StructureView, what?: TextDataField) {\n const p = this.getAtomParams(what)\n const labelFactory = new LabelFactory(this.labelType, this.labelText, this.labelFormat)\n let position: Float32Array, size: Float32Array, color: Float32Array, text: string[],\n positionN: number[], sizeN: number[], colorN: number[]\n if (this.labelGrouping === 'atom') {\n const atomData = sview.getAtomData(p)\n position = atomData.position as Float32Array\n size = atomData.radius as Float32Array\n color = atomData.color as Float32Array\n if (!what || what.text) {\n text = []\n sview.eachAtom(ap => text.push(labelFactory.atomLabel(ap)))\n }\n } else if (this.labelGrouping === 'residue') {\n if (!what || what.position) positionN = []\n if (!what || what.color) colorN = []\n if (!what || what.radius) sizeN = []\n if (!what || what.text) text = []\n if (p.colorParams) p.colorParams.structure = sview.getStructure()\n const colormaker = ColormakerRegistry.getScheme(p.colorParams)\n const radiusFactory = new RadiusFactory(p.radiusParams)\n const ap1 = sview.getAtomProxy()\n\n let i = 0\n sview.eachResidue(rp => {\n const i3 = i * 3\n if (rp.isProtein() || rp.isNucleic()) {\n ap1.index = rp.traceAtomIndex\n if (!what || what.position) {\n ap1.positionToArray(positionN, i3)\n }\n } else {\n ap1.index = rp.atomOffset\n if (!what || what.position) {\n rp.positionToArray(positionN, i3)\n }\n }\n if (!what || what.color) {\n colormaker.atomColorToArray(ap1, colorN, i3)\n }\n if (!what || what.radius) {\n sizeN[ i ] = radiusFactory.atomRadius(ap1)\n }\n if (!what || what.text) {\n text.push(labelFactory.atomLabel(ap1))\n }\n ++i\n })\n\n if (!what || what.position) position = new Float32Array(positionN!)\n if (!what || what.color) color = new Float32Array(colorN!)\n if (!what || what.radius) size = new Float32Array(sizeN!)\n }\n\n return { position: position!, size: size!, color: color!, text: text! }\n }\n\n createData (sview: StructureView) {\n const what: TextDataField = { position: true, color: true, radius: true, text: true }\n\n const textBuffer = new TextBuffer(\n this.getTextData(sview, what) as TextBufferData,\n this.getBufferParams({\n fontFamily: this.fontFamily,\n fontStyle: this.fontStyle,\n fontWeight: this.fontWeight,\n xOffset: this.xOffset,\n yOffset: this.yOffset,\n zOffset: this.zOffset,\n attachment: this.attachment,\n showBorder: this.showBorder,\n borderColor: this.borderColor,\n borderWidth: this.borderWidth,\n showBackground: this.showBackground,\n backgroundColor: this.backgroundColor,\n backgroundMargin: this.backgroundMargin,\n backgroundOpacity: this.backgroundOpacity,\n fixedSize: this.fixedSize\n })\n )\n\n return { bufferList: [ textBuffer ] }\n }\n\n updateData (what: TextDataField, data: StructureRepresentationData) {\n data.bufferList[ 0 ].setAttributes(this.getTextData(data.sview as StructureView, what))\n }\n\n getAtomRadius () {\n return 0\n }\n}\n\nRepresentationRegistry.add('label', LabelRepresentation)\n\nexport default LabelRepresentation\n","/**\n * @file Line Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { RepresentationRegistry } from '../globals'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport WideLineBuffer from '../buffer/wideline-buffer'\nimport { AtomPicker } from '../utils/picker'\n// @ts-ignore: unused import Volume required for declaration only\nimport { Structure, Volume } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport Viewer from '../viewer/viewer';\nimport AtomProxy from '../proxy/atom-proxy';\n// @ts-ignore: unused import Surface required for declaration only\nimport Surface from '../surface/surface';\n// @ts-ignore: unused import BondDataFields, BondDataParams required for declaration only\nimport { BondDataFields, BondDataParams } from '../structure/structure-data';\n\n/**\n * Determine which atoms in a Structure[View] form no bonds to any other atoms\n * in that Structure.\n *\n * This differs from setting the selection to \"nonbonded\" as it finds atoms\n * that have no bonds within the current selection.\n * @param {Structure} structure - The Structure or StructureView object\n * @return {AtomSet} AtomSet of lone atoms\n */\nfunction getLoneAtomSet (structure: Structure | StructureView) {\n const atomSet = structure.getAtomSet()\n const bondSet = structure.getBondSet()\n const bp = structure.getBondProxy()\n bondSet.forEach(function (idx) {\n bp.index = idx\n atomSet.clear(bp.atomIndex1)\n atomSet.clear(bp.atomIndex2)\n })\n return atomSet\n}\n\nexport interface LineRepresentationParameters extends StructureRepresentationParameters {\n multipleBond: 'off' | 'symmetric' | 'offset'\n bondSpacing: number\n linewidth: number\n lines: boolean\n crosses: 'off' | 'all' | 'lone'\n crossSize: number\n}\n\nexport interface CrossData {\n position1?: Float32Array\n position2?: Float32Array\n color?: Float32Array\n color2?: Float32Array\n picking?: AtomPicker\n}\n\n/**\n * Line representation\n */\nclass LineRepresentation extends StructureRepresentation {\n protected multipleBond: 'off' | 'symmetric' | 'offset'\n protected bondSpacing: number\n protected linewidth: number\n protected lines: boolean\n protected crosses: 'off' | 'all' | 'lone'\n protected crossSize: number\n /**\n * Create Line representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {RepresentationParameters} params - representation parameters, plus the properties listed below\n * @property {String} multipleBond - one off \"off\", \"symmetric\", \"offset\"\n * @param {Float} params.bondSpacing - spacing for multiple bond rendering\n * @param {Integer} params.linewidth - width of lines\n * @param {Boolean} params.lines - render bonds as lines\n * @param {String} params.crosses - render atoms as crosses: \"off\", \"all\" or \"lone\" (default)\n * @param {Float} params.crossSize - size of cross\n * @param {null} params.flatShaded - not available\n * @param {null} params.side - not available\n * @param {null} params.wireframe - not available\n * @param {null} params.roughness - not available\n * @param {null} params.metalness - not available\n * @param {null} params.diffuse - not available\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'line'\n\n this.parameters = Object.assign({\n\n multipleBond: {\n type: 'select',\n rebuild: true,\n options: {\n 'off': 'off',\n 'symmetric': 'symmetric',\n 'offset': 'offset'\n }\n },\n bondSpacing: {\n type: 'number', precision: 2, max: 2.0, min: 0.5\n },\n linewidth: {\n type: 'integer', max: 50, min: 1, buffer: true\n },\n lines: {\n type: 'boolean', rebuild: true\n },\n crosses: {\n type: 'select',\n rebuild: true,\n options: {\n 'off': 'off',\n 'lone': 'lone',\n 'all': 'all'\n }\n },\n crossSize: {\n type: 'number', precision: 2, max: 2.0, min: 0.1\n }\n\n }, this.parameters, {\n\n flatShaded: null,\n side: null,\n wireframe: null,\n\n roughness: null,\n metalness: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n\n this.multipleBond = defaults(p.multipleBond, 'off')\n this.bondSpacing = defaults(p.bondSpacing, 1.0)\n this.linewidth = defaults(p.linewidth, 2)\n this.lines = defaults(p.lines, true)\n this.crosses = defaults(p.crosses, 'lone')\n this.crossSize = defaults(p.crossSize, 0.4)\n\n super.init(p)\n }\n\n getAtomRadius (atom:AtomProxy) {\n return 0.1\n }\n\n getBondParams (what: any, params?: Partial) {\n params = Object.assign({\n multipleBond: this.multipleBond,\n bondSpacing: this.bondSpacing,\n radiusParams: { 'type': 'size', 'size': 0.1, 'scale': 1 }\n }, params)\n\n return super.getBondParams(what, params)\n }\n\n _crossData (what: any, sview: StructureView) {\n if (what) {\n if (!what.position && !what.color) return\n }\n\n const p = {}\n if (this.crosses === 'lone') {\n Object.assign(p, {atomSet : getLoneAtomSet(sview)})\n }\n\n const atomData = sview.getAtomData(this.getAtomParams(what, p))\n const crossData: CrossData = {}\n const position = atomData.position\n const color = atomData.color\n const picking = atomData.picking\n\n const size = (position! || color).length\n const attrSize = size * 3\n\n let cPosition1 = new Float32Array(0)\n let cPosition2 = new Float32Array(0)\n let cColor = new Float32Array(0)\n let cColor2 = new Float32Array(0)\n let cOffset: number = 0\n\n let pickingArray = new Float32Array(0)\n\n if (!what || what.position) {\n cPosition1 = crossData.position1 = new Float32Array(attrSize)\n cPosition2 = crossData.position2 = new Float32Array(attrSize)\n cOffset = this.crossSize / 2\n }\n if (!what || what.color) {\n cColor = crossData.color = new Float32Array(attrSize)\n cColor2 = crossData.color2 = new Float32Array(attrSize)\n }\n if (!what || what.picking) {\n pickingArray = new Float32Array(atomData.picking!.array!.length * 3) // Needs padding??\n }\n\n for (let v = 0; v < size; v++) {\n const j = v * 3\n const i = j * 3\n\n if (!what || what.position) {\n const x = position![ j ]\n const y = position![ j + 1 ]\n const z = position![ j + 2 ]\n\n cPosition1[ i ] = x - cOffset!\n cPosition1[ i + 1 ] = y\n cPosition1[ i + 2 ] = z\n cPosition2[ i ] = x + cOffset\n cPosition2[ i + 1 ] = y\n cPosition2[ i + 2 ] = z\n\n cPosition1[ i + 3 ] = x\n cPosition1[ i + 4 ] = y - cOffset\n cPosition1[ i + 5 ] = z\n cPosition2[ i + 3 ] = x\n cPosition2[ i + 4 ] = y + cOffset\n cPosition2[ i + 5 ] = z\n\n cPosition1[ i + 6 ] = x\n cPosition1[ i + 7 ] = y\n cPosition1[ i + 8 ] = z - cOffset\n cPosition2[ i + 6 ] = x\n cPosition2[ i + 7 ] = y\n cPosition2[ i + 8 ] = z + cOffset\n }\n\n if (!what || what.color) {\n const cimax = i + 9\n for (let ci = i; ci < cimax; ci += 3) {\n cColor[ ci ] = cColor2[ ci ] = color![ j ]\n cColor[ ci + 1 ] = cColor2[ ci + 1 ] = color![ j + 1 ]\n cColor[ ci + 2 ] = cColor2[ ci + 2 ] = color![ j + 2 ]\n }\n }\n\n if (!what || what.picking) {\n pickingArray[ j ] =\n pickingArray[ j + 1 ] =\n pickingArray[ j + 2 ] = picking!.array![ v ]\n }\n }\n\n if (!what || what.picking) {\n crossData.picking = new AtomPicker(\n pickingArray, picking!.structure\n )\n }\n\n return crossData\n }\n\n createData (sview: StructureView) {\n const what = { position: true, color: true, picking: true }\n\n const bufferList = []\n\n if (this.lines) {\n const bondData = sview.getBondData(this.getBondParams(what))\n\n const lineBuffer = new WideLineBuffer(\n bondData, this.getBufferParams({ linewidth: this.linewidth })\n )\n\n bufferList.push(lineBuffer)\n }\n\n if (this.crosses !== 'off') {\n const crossBuffer = new WideLineBuffer(\n (this._crossData(what, sview) as CrossData),\n this.getBufferParams({linewidth: this.linewidth})\n )\n bufferList.push(crossBuffer)\n }\n\n return {\n bufferList: bufferList\n }\n }\n\n updateData (what: any, data: StructureRepresentationData) {\n let bufferIdx = 0\n\n if (this.lines) {\n const bondData = data.sview!.getBondData(this.getBondParams(what))\n const lineAttributes = {}\n\n if (!what || what.position) {\n Object.assign(lineAttributes, {\n position1: bondData.position1,\n position2: bondData.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(lineAttributes, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n data.bufferList[ bufferIdx++ ].setAttributes(lineAttributes)\n }\n\n if (this.crosses !== 'off') {\n const crossData = this._crossData(what, (data.sview as StructureView))\n const crossAttributes = {}\n\n if (!what || what.position) {\n Object.assign(crossAttributes, {\n position1: crossData!.position1,\n position2: crossData!.position2\n })\n }\n if (!what || what.color) {\n Object.assign(crossAttributes, {\n color: crossData!.color,\n color2: crossData!.color2\n })\n }\n\n data.bufferList[ bufferIdx++ ].setAttributes(crossAttributes)\n }\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n if (params && (params.bondSpacing || params.crossSize)) {\n Object.assign(what, { position: true })\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('line', LineRepresentation)\n\nexport default LineRepresentation\n","import { NumberArray, TypedArray } from \"../types\";\n\n/**\n * @file Grid\n * @author Alexander Rose \n * @private\n */\nexport interface iGrid {\n data: TypedArray\n index: (x: number, y: number, z: number) => number\n set: (x: number, y: number, z: number, ...arg: number[]) => void\n toArray: (x: number, y: number, z: number, array?: NumberArray, offset?: number) => void\n fromArray: (x: number, y: number, z: number, array: NumberArray, offset?: number) => void\n copy: (grid: iGrid) => void\n // clone: () => iGrid\n}\n\nfunction makeGrid (length: number, width: number, height: number, DataCtor: any, elemSize: number) : iGrid {\n DataCtor = DataCtor || Int32Array\n elemSize = elemSize || 1\n\n const data = new DataCtor(length * width * height * elemSize)\n\n function index (x: number, y: number, z: number) {\n return ((((x * width) + y) * height) + z) * elemSize\n }\n\n function set (x: number, y: number, z: number, ...args: number[]) {\n const i = index(x, y, z)\n\n for (let j = 0; j < elemSize; ++j) {\n data[ i + j ] = args[ j ]\n }\n }\n\n function toArray (x: number, y: number, z: number, array: NumberArray = [], offset: number = 0) {\n const i = index(x, y, z)\n\n for (let j = 0; j < elemSize; ++j) {\n array[ offset + j ] = data[ i + j ]\n }\n }\n\n function fromArray(x: number, y: number, z: number, array: NumberArray, offset: number = 0) {\n const i = index(x, y, z)\n\n for (let j = 0; j < elemSize; ++j) {\n data[ i + j ] = array[ offset + j ]\n }\n }\n\n function copy(grid: iGrid) {\n data.set(grid.data)\n }\n\n // function clone() {\n // return makeGrid(\n // length, width, height, DataCtor, elemSize\n // ).copy(this)\n // }\n return { data, index, set, toArray, fromArray, copy }\n}\n\nexport { makeGrid }","/**\n * @file EDT Surface\n * @author Alexander Rose \n * @private\n */\n\nimport { VolumeSurface } from './volume'\nimport { iGrid, makeGrid } from '../geometry/grid'\nimport { computeBoundingBox } from '../math/vector-utils'\nimport { getRadiusDict, getSurfaceGrid } from './surface-utils'\nimport { TypedArray } from '../types';\n\ninterface EDTSurface {\n getVolume: (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean) => {\n data: TypedArray\n nx: number\n ny: number\n nz: number\n atomindex: TypedArray\n }\n getSurface: (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean, smooth: number, contour: boolean) => any\n}\n\nfunction EDTSurface (this: EDTSurface, coordList: Float32Array, radiusList: Float32Array, indexList: Uint16Array|Uint32Array) {\n // based on D. Xu, Y. Zhang (2009) Generating Triangulated Macromolecular\n // Surfaces by Euclidean Distance Transform. PLoS ONE 4(12): e8140.\n //\n // Permission to use, copy, modify, and distribute this program for\n // any purpose, with or without fee, is hereby granted, provided that\n // the notices on the head, the reference information, and this\n // copyright notice appear in all copies or substantial portions of\n // the Software. It is provided \"as is\" without express or implied\n // warranty.\n //\n // ported to JavaScript by biochem_fan (http://webglmol.sourceforge.jp/)\n // refactored by dkoes (https://github.com/dkoes)\n //\n // adapted to NGL by Alexander Rose\n\n var radiusDict = getRadiusDict(radiusList as any)\n var bbox = computeBoundingBox(coordList)\n if (coordList.length === 0) {\n bbox[ 0 ].set([ 0, 0, 0 ])\n bbox[ 1 ].set([ 0, 0, 0 ])\n }\n var min = bbox[ 0 ]\n var max = bbox[ 1 ]\n\n var probeRadius: number, scaleFactor: number, cutoff: number\n var pLength: number, pWidth: number, pHeight: number\n var matrix: Float32Array, ptran: Float32Array\n var depty: {[k: string]: TypedArray}, widxz: {[k: string]: number}\n var cutRadius: number\n var setAtomID: boolean\n var vpBits: TypedArray, vpDistance: TypedArray, vpAtomID: TypedArray\n\n function init (btype: boolean, _probeRadius: number, _scaleFactor: number, _cutoff: number, _setAtomID: boolean) {\n probeRadius = _probeRadius || 1.4\n scaleFactor = _scaleFactor || 2.0\n setAtomID = _setAtomID || true\n\n var maxRadius = 0\n for (var radius in radiusDict) {\n maxRadius = Math.max(maxRadius, radius as any)\n }\n\n var grid = getSurfaceGrid(\n min, max, maxRadius, scaleFactor, btype ? probeRadius : 0\n )\n\n pLength = grid.dim[0]\n pWidth = grid.dim[1]\n pHeight = grid.dim[2]\n\n matrix = grid.matrix\n ptran = grid.tran\n scaleFactor = grid.scaleFactor\n\n // boundingatom caches\n depty = {}\n widxz = {}\n boundingatom(btype)\n\n cutRadius = probeRadius * scaleFactor\n\n if (_cutoff) {\n cutoff = _cutoff\n } else {\n // cutoff = Math.max( 0.1, -1.2 + scaleFactor * probeRadius );\n cutoff = probeRadius / scaleFactor\n }\n\n vpBits = new Uint8Array(pLength * pWidth * pHeight)\n if (btype) {\n vpDistance = new Float64Array(pLength * pWidth * pHeight)\n }\n if (setAtomID) {\n vpAtomID = new Int32Array(pLength * pWidth * pHeight)\n }\n }\n\n // constants for vpBits bitmasks\n var INOUT = 1\n var ISDONE = 2\n var ISBOUND = 4\n\n var nb = [\n new Int32Array([ 1, 0, 0 ]), new Int32Array([ -1, 0, 0 ]),\n new Int32Array([ 0, 1, 0 ]), new Int32Array([ 0, -1, 0 ]),\n new Int32Array([ 0, 0, 1 ]), new Int32Array([ 0, 0, -1 ]),\n new Int32Array([ 1, 1, 0 ]), new Int32Array([ 1, -1, 0 ]),\n new Int32Array([ -1, 1, 0 ]), new Int32Array([ -1, -1, 0 ]),\n new Int32Array([ 1, 0, 1 ]), new Int32Array([ 1, 0, -1 ]),\n new Int32Array([ -1, 0, 1 ]), new Int32Array([ -1, 0, -1 ]),\n new Int32Array([ 0, 1, 1 ]), new Int32Array([ 0, 1, -1 ]),\n new Int32Array([ 0, -1, 1 ]), new Int32Array([ 0, -1, -1 ]),\n new Int32Array([ 1, 1, 1 ]), new Int32Array([ 1, 1, -1 ]),\n new Int32Array([ 1, -1, 1 ]), new Int32Array([ -1, 1, 1 ]),\n new Int32Array([ 1, -1, -1 ]), new Int32Array([ -1, -1, 1 ]),\n new Int32Array([ -1, 1, -1 ]), new Int32Array([ -1, -1, -1 ])\n ]\n\n //\n\n this.getVolume = function (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean) {\n console.time('EDTSurface.getVolume')\n\n var btype = type !== 'vws'\n\n init(btype, probeRadius, scaleFactor, cutoff, setAtomID)\n\n fillvoxels(btype)\n buildboundary()\n\n if (type === 'ms' || type === 'ses') {\n fastdistancemap()\n }\n\n if (type === 'ses') {\n boundingatom(false)\n fillvoxelswaals()\n }\n\n marchingcubeinit(type)\n\n // set atomindex in the volume data\n for (var i = 0, il = vpAtomID.length; i < il; ++i) {\n vpAtomID[ i ] = indexList[ vpAtomID[ i ] ]\n }\n\n console.timeEnd('EDTSurface.getVolume')\n\n return {\n data: vpBits,\n nx: pHeight,\n ny: pWidth,\n nz: pLength,\n atomindex: vpAtomID\n }\n }\n\n this.getSurface = function (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean, smooth: number, contour: boolean) {\n var vd = this.getVolume(\n type, probeRadius, scaleFactor, cutoff, setAtomID\n )\n\n var volsurf = new (VolumeSurface as any)(\n vd.data, vd.nx, vd.ny, vd.nz, vd.atomindex\n ) as VolumeSurface\n\n return (volsurf!.getSurface as any)(1, smooth, undefined, matrix, contour)\n }\n\n function boundingatom (btype: boolean) {\n var r\n var j\n var k\n var txz\n var tdept\n var sradius\n var tradius\n var widxzR\n var deptyName\n var indx\n\n for (var name in radiusDict) {\n r = parseFloat(name)\n\n if (depty[ name ]) continue\n\n if (!btype) {\n tradius = r * scaleFactor + 0.5\n } else {\n tradius = (r + probeRadius) * scaleFactor + 0.5\n }\n\n sradius = tradius * tradius\n widxzR = Math.floor(tradius) + 1\n deptyName = new Int32Array(widxzR * widxzR)\n indx = 0\n\n for (j = 0; j < widxzR; ++j) {\n for (k = 0; k < widxzR; ++k) {\n txz = j * j + k * k\n\n if (txz > sradius) {\n deptyName[ indx ] = -1\n } else {\n tdept = Math.sqrt(sradius - txz)\n deptyName[ indx ] = Math.floor(tdept)\n }\n\n ++indx\n }\n }\n\n widxz[ name ] = widxzR\n depty[ name ] = deptyName\n }\n }\n\n function fillatom (idx: number) {\n var ci = idx * 3\n var ri = idx\n\n var cx, cy, cz, ox, oy, oz, mi, mj, mk, i, j, k, si, sj, sk\n var ii, jj, kk\n\n cx = Math.floor(0.5 + scaleFactor * (coordList[ ci ] + ptran[0]))\n cy = Math.floor(0.5 + scaleFactor * (coordList[ ci + 1 ] + ptran[1]))\n cz = Math.floor(0.5 + scaleFactor * (coordList[ ci + 2 ] + ptran[2]))\n\n var at = radiusList[ ri ]\n var deptyAt = depty[ at ]\n var nind = 0\n var pWH = pWidth * pHeight\n var n = widxz[ at ]\n\n var deptyAtNind\n\n for (i = 0; i < n; ++i) {\n for (j = 0; j < n; ++j) {\n deptyAtNind = deptyAt[ nind ]\n\n if (deptyAtNind !== -1) {\n for (ii = -1; ii < 2; ++ii) {\n for (jj = -1; jj < 2; ++jj) {\n for (kk = -1; kk < 2; ++kk) {\n if (ii !== 0 && jj !== 0 && kk !== 0) {\n mi = ii * i\n mk = kk * j\n\n for (k = 0; k <= deptyAtNind; ++k) {\n mj = k * jj\n si = cx + mi\n sj = cy + mj\n sk = cz + mk\n\n if (si < 0 || sj < 0 || sk < 0 ||\n si >= pLength || sj >= pWidth || sk >= pHeight\n ) {\n continue\n }\n\n var index = si * pWH + sj * pHeight + sk\n\n if (!setAtomID) {\n vpBits[ index ] |= INOUT\n } else {\n if (!(vpBits[ index ] & INOUT)) {\n vpBits[ index ] |= INOUT\n vpAtomID[ index ] = idx\n } else if (vpBits[ index ] & INOUT) {\n var ci2 = vpAtomID[ index ]\n\n if (ci2 !== ci) {\n ox = cx + mi - Math.floor(0.5 + scaleFactor * (coordList[ci2] + ptran[0]))\n oy = cy + mj - Math.floor(0.5 + scaleFactor * (coordList[ci2 + 1] + ptran[1]))\n oz = cz + mk - Math.floor(0.5 + scaleFactor * (coordList[ci2 + 2] + ptran[2]))\n\n if (mi * mi + mj * mj + mk * mk < ox * ox + oy * oy + oz * oz) {\n vpAtomID[ index ] = idx\n }\n }\n }\n }\n } // k\n } // if\n } // kk\n } // jj\n } // ii\n } // if\n\n nind++\n } // j\n } // i\n }\n\n function fillvoxels (btype: boolean) {\n console.time('EDTSurface fillvoxels')\n\n var i, il\n\n for (i = 0, il = vpBits.length; i < il; ++i) {\n vpBits[ i ] = 0\n if (btype) vpDistance[ i ] = -1.0\n if (setAtomID) vpAtomID[ i ] = -1\n }\n\n for (i = 0, il = coordList.length / 3; i < il; ++i) {\n fillatom(i)\n }\n\n for (i = 0, il = vpBits.length; i < il; ++i) {\n if (vpBits[ i ] & INOUT) {\n vpBits[ i ] |= ISDONE\n }\n }\n\n console.timeEnd('EDTSurface fillvoxels')\n }\n\n function fillAtomWaals (idx: number) {\n var ci = idx * 3\n var ri = idx\n\n var cx\n var cy\n var cz\n var ox\n var oy\n var oz\n var nind = 0\n\n var mi\n var mj\n var mk\n var si\n var sj\n var sk\n var i\n var j\n var k\n var ii\n var jj\n var kk\n var n\n\n cx = Math.floor(0.5 + scaleFactor * (coordList[ ci ] + ptran[0]))\n cy = Math.floor(0.5 + scaleFactor * (coordList[ ci + 1 ] + ptran[1]))\n cz = Math.floor(0.5 + scaleFactor * (coordList[ ci + 2 ] + ptran[2]))\n\n var at = radiusList[ ri ]\n var pWH = pWidth * pHeight\n\n for (i = 0, n = widxz[at]; i < n; ++i) {\n for (j = 0; j < n; ++j) {\n if (depty[ at ][ nind ] !== -1) {\n for (ii = -1; ii < 2; ++ii) {\n for (jj = -1; jj < 2; ++jj) {\n for (kk = -1; kk < 2; ++kk) {\n if (ii !== 0 && jj !== 0 && kk !== 0) {\n mi = ii * i\n mk = kk * j\n\n for (k = 0; k <= depty[ at ][ nind ]; ++k) {\n mj = k * jj\n si = cx + mi\n sj = cy + mj\n sk = cz + mk\n\n if (si < 0 || sj < 0 || sk < 0 ||\n si >= pLength || sj >= pWidth || sk >= pHeight\n ) {\n continue\n }\n\n var index = si * pWH + sj * pHeight + sk\n\n if (!(vpBits[ index ] & ISDONE)) {\n vpBits[ index ] |= ISDONE\n if (setAtomID) vpAtomID[ index ] = idx\n } else if (setAtomID) {\n var ci2 = vpAtomID[ index ]\n\n ox = Math.floor(0.5 + scaleFactor * (coordList[ ci2 ] + ptran[0]))\n oy = Math.floor(0.5 + scaleFactor * (coordList[ ci2 + 1 ] + ptran[1]))\n oz = Math.floor(0.5 + scaleFactor * (coordList[ ci2 + 2 ] + ptran[2]))\n\n if (mi * mi + mj * mj + mk * mk < ox * ox + oy * oy + oz * oz) {\n vpAtomID[ index ] = idx\n }\n }\n } // k\n } // if\n } // kk\n } // jj\n } // ii\n } // if\n\n nind++\n } // j\n } // i\n }\n\n function fillvoxelswaals () {\n var i, il\n\n for (i = 0, il = vpBits.length; i < il; ++i) {\n vpBits[ i ] &= ~ISDONE // not isdone\n }\n\n for (i = 0, il = coordList.length / 3; i < il; ++i) {\n fillAtomWaals(i)\n }\n }\n\n function buildboundary () {\n var i, j, k\n var pWH = pWidth * pHeight\n\n for (i = 0; i < pLength; ++i) {\n for (j = 0; j < pHeight; ++j) {\n for (k = 0; k < pWidth; ++k) {\n var index = i * pWH + k * pHeight + j\n\n if (vpBits[ index ] & INOUT) {\n // var flagbound = false;\n var ii = 0\n\n // while( !flagbound && ii < 26 ){\n while (ii < 26) {\n var ti = i + nb[ ii ][ 0 ]\n var tj = j + nb[ ii ][ 2 ]\n var tk = k + nb[ ii ][ 1 ]\n\n if (ti > -1 && ti < pLength &&\n tk > -1 && tk < pWidth &&\n tj > -1 && tj < pHeight &&\n !(vpBits[ ti * pWH + tk * pHeight + tj ] & INOUT)\n ) {\n vpBits[ index ] |= ISBOUND\n // flagbound = true;\n break\n } else {\n ii++\n }\n }\n }\n } // k\n } // j\n } // i\n }\n\n function fastdistancemap () {\n console.time('EDTSurface fastdistancemap')\n\n var i, j, k, n\n\n var boundPoint = makeGrid(\n pLength, pWidth, pHeight, Uint16Array, 3\n )\n var pWH = pWidth * pHeight\n var cutRSq = cutRadius * cutRadius\n\n var totalsurfacevox = 0\n // var totalinnervox = 0;\n\n var index\n\n for (i = 0; i < pLength; ++i) {\n for (j = 0; j < pWidth; ++j) {\n for (k = 0; k < pHeight; ++k) {\n index = i * pWH + j * pHeight + k\n\n vpBits[ index ] &= ~ISDONE\n\n if (vpBits[ index ] & INOUT) {\n if (vpBits[ index ] & ISBOUND) {\n boundPoint.set(\n i, j, k,\n i, j, k\n )\n\n vpDistance[ index ] = 0\n vpBits[ index ] |= ISDONE\n\n totalsurfacevox += 1\n }/* else{\n totalinnervox += 1;\n } */\n }\n }\n }\n }\n\n var inarray = new Int32Array(3 * totalsurfacevox)\n var positin = 0\n var outarray = new Int32Array(3 * totalsurfacevox)\n var positout = 0\n\n for (i = 0; i < pLength; ++i) {\n for (j = 0; j < pWidth; ++j) {\n for (k = 0; k < pHeight; ++k) {\n index = i * pWH + j * pHeight + k\n\n if (vpBits[ index ] & ISBOUND) {\n inarray[ positin ] = i\n inarray[ positin + 1 ] = j\n inarray[ positin + 2 ] = k\n positin += 3\n\n vpBits[ index ] &= ~ISBOUND\n }\n }\n }\n }\n\n do {\n positout = fastoneshell(inarray, boundPoint, positin, outarray)\n positin = 0\n\n for (i = 0, n = positout; i < n; i += 3) {\n index = pWH * outarray[ i ] + pHeight * outarray[ i + 1 ] + outarray[ i + 2 ]\n vpBits[ index ] &= ~ISBOUND\n\n if (vpDistance[ index ] <= 1.0404 * cutRSq) {\n // if( vpDistance[ index ] <= 1.02 * cutRadius ){\n\n inarray[ positin ] = outarray[ i ]\n inarray[ positin + 1 ] = outarray[ i + 1 ]\n inarray[ positin + 2 ] = outarray[ i + 2 ]\n positin += 3\n }\n }\n } while (positin > 0)\n\n // var cutsf = Math.max( 0, scaleFactor - 0.5 );\n // cutoff = cutRadius - 0.5 / ( 0.1 + cutsf );\n var cutoffSq = cutoff * cutoff\n\n var index2\n var bp = new Uint16Array(3)\n\n for (i = 0; i < pLength; ++i) {\n for (j = 0; j < pWidth; ++j) {\n for (k = 0; k < pHeight; ++k) {\n index = i * pWH + j * pHeight + k\n vpBits[ index ] &= ~ISBOUND\n\n // ses solid\n\n if (vpBits[ index ] & INOUT) {\n if (!(vpBits[ index ] & ISDONE) ||\n ((vpBits[ index ] & ISDONE) && vpDistance[ index ] >= cutoffSq)\n ) {\n vpBits[ index ] |= ISBOUND\n\n if (setAtomID && (vpBits[ index ] & ISDONE)) {\n boundPoint.toArray(i, j, k, bp)\n index2 = bp[ 0 ] * pWH + bp[ 1 ] * pHeight + bp[ 2 ]\n\n vpAtomID[ index ] = vpAtomID[ index2 ]\n }\n }\n }\n }\n }\n }\n\n console.timeEnd('EDTSurface fastdistancemap')\n }\n\n function fastoneshell (inarray: Int32Array, boundPoint: iGrid, positin: number, outarray: Int32Array) {\n // *allocout,voxel2\n // ***boundPoint, int*\n // outnum, int *elimi)\n var tx, ty, tz\n var dx, dy, dz\n var i, j, n\n var square\n var index\n var nbj\n var bp = new Uint16Array(3)\n var positout = 0\n\n if (positin === 0) {\n return positout\n }\n\n var tnvix = -1\n var tnviy = -1\n var tnviz = -1\n\n var pWH = pWidth * pHeight\n\n for (i = 0, n = positin; i < n; i += 3) {\n tx = inarray[ i ]\n ty = inarray[ i + 1 ]\n tz = inarray[ i + 2 ]\n boundPoint.toArray(tx, ty, tz, bp)\n\n for (j = 0; j < 6; ++j) {\n nbj = nb[ j ]\n tnvix = tx + nbj[ 0 ]\n tnviy = ty + nbj[ 1 ]\n tnviz = tz + nbj[ 2 ]\n\n if (tnvix < pLength && tnvix > -1 &&\n tnviy < pWidth && tnviy > -1 &&\n tnviz < pHeight && tnviz > -1\n ) {\n index = tnvix * pWH + pHeight * tnviy + tnviz\n\n if ((vpBits[ index ] & INOUT) && !(vpBits[ index ] & ISDONE)) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n vpDistance[ index ] = square\n vpBits[ index ] |= ISDONE\n vpBits[ index ] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n } else if ((vpBits[ index ] & INOUT) && (vpBits[ index ] & ISDONE)) {\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n if (square < vpDistance[ index ]) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n vpDistance[ index ] = square\n\n if (!(vpBits[ index ] & ISBOUND)) {\n vpBits[ index ] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n }\n }\n }\n }\n }\n }\n\n for (i = 0, n = positin; i < n; i += 3) {\n tx = inarray[ i ]\n ty = inarray[ i + 1 ]\n tz = inarray[ i + 2 ]\n boundPoint.toArray(tx, ty, tz, bp)\n\n for (j = 6; j < 18; j++) {\n nbj = nb[ j ]\n tnvix = tx + nbj[ 0 ]\n tnviy = ty + nbj[ 1 ]\n tnviz = tz + nbj[ 2 ]\n\n if (tnvix < pLength && tnvix > -1 &&\n tnviy < pWidth && tnviy > -1 &&\n tnviz < pHeight && tnviz > -1\n ) {\n index = tnvix * pWH + pHeight * tnviy + tnviz\n\n if ((vpBits[index] & INOUT) && !(vpBits[index] & ISDONE)) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n vpDistance[index] = square\n vpBits[index] |= ISDONE\n vpBits[index] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n } else if ((vpBits[index] & INOUT) && (vpBits[index] & ISDONE)) {\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n if (square < vpDistance[index]) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n vpDistance[index] = square\n\n if (!(vpBits[index] & ISBOUND)) {\n vpBits[index] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n }\n }\n }\n }\n }\n }\n\n for (i = 0, n = positin; i < n; i += 3) {\n tx = inarray[ i ]\n ty = inarray[ i + 1 ]\n tz = inarray[ i + 2 ]\n boundPoint.toArray(tx, ty, tz, bp)\n\n for (j = 18; j < 26; j++) {\n nbj = nb[ j ]\n tnvix = tx + nbj[ 0 ]\n tnviy = ty + nbj[ 1 ]\n tnviz = tz + nbj[ 2 ]\n\n if (tnvix < pLength && tnvix > -1 &&\n tnviy < pWidth && tnviy > -1 &&\n tnviz < pHeight && tnviz > -1\n ) {\n index = tnvix * pWH + pHeight * tnviy + tnviz\n\n if ((vpBits[index] & INOUT) && !(vpBits[index] & ISDONE)) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n vpDistance[index] = square\n vpBits[index] |= ISDONE\n vpBits[index] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n } else if ((vpBits[index] & INOUT) && (vpBits[index] & ISDONE)) {\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n if (square < vpDistance[index]) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n vpDistance[index] = square\n\n if (!(vpBits[index] & ISBOUND)) {\n vpBits[index] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n }\n }\n }\n }\n }\n }\n\n return positout\n }\n\n function marchingcubeinit (stype: string) {\n var i\n var n = vpBits.length\n\n if (stype === 'vws') {\n for (i = 0; i < n; ++i) {\n vpBits[ i ] &= ~ISBOUND\n vpBits[ i ] = (vpBits[ i ] & ISDONE) ? 1 : 0\n }\n } else if (stype === 'ms') { // ses without vdw => ms\n for (i = 0; i < n; ++i) {\n vpBits[ i ] &= ~ISDONE\n if (vpBits[ i ] & ISBOUND) {\n vpBits[ i ] |= ISDONE\n }\n vpBits[ i ] &= ~ISBOUND\n vpBits[ i ] = (vpBits[ i ] & ISDONE) ? 1 : 0\n }\n } else if (stype === 'ses') {\n for (i = 0; i < n; ++i) {\n if ((vpBits[ i ] & ISBOUND) && (vpBits[ i ] & ISDONE)) {\n vpBits[ i ] &= ~ISBOUND\n } else if ((vpBits[ i ] & ISBOUND) && !(vpBits[ i ] & ISDONE)) {\n vpBits[ i ] |= ISDONE\n }\n vpBits[ i ] = (vpBits[ i ] & ISDONE) ? 1 : 0\n }\n } else if (stype === 'sas') {\n for (i = 0; i < n; ++i) {\n vpBits[ i ] &= ~ISBOUND\n vpBits[ i ] = (vpBits[ i ] & ISDONE) ? 1 : 0\n }\n }\n }\n}\nObject.assign(EDTSurface, {__deps: [\n getSurfaceGrid, getRadiusDict, VolumeSurface, computeBoundingBox, makeGrid\n]})\n\nexport default EDTSurface\n","/**\n * @file AV Surface\n * @author Fred Ludlow \n * @private\n */\n\nimport { getSurfaceGrid } from './surface-utils'\nimport { VolumeSurface } from './volume'\nimport { uniformArray } from '../math/array-utils'\nimport {\n computeBoundingBox, v3multiplyScalar, v3cross, v3normalize\n} from '../math/vector-utils'\nimport { defaults } from '../utils'\nimport { NumberArray } from '../types';\n\n\n/**\n * Modifed from SpatialHash\n *\n * Main differences are:\n * - Optimized grid size to ensure we only ever need to look +/-1 cell\n * - Aware of atomic radii and will only output atoms within rAtom + rExtra\n * (see withinRadii method)\n *\n * (Uses rounding rather than bitshifting as consequence of arbitrary grid size)\n * @class\n * @param {Float32Array} atomsX - x coordinates\n * @param {Float32Array} atomsY - y coordinates\n * @param {Float32Array} atomsZ - z coordinates\n * @param {Float32Array} atomsR - atom radii\n * @param {Float32Array} min - xyz min coordinates\n * @param {Float32Array} max - xyz max coordinates\n * @param {Float} maxDistance - max distance\n */\nexport interface iAVHash {\n neighbourListLength: number\n withinRadii: (x: number, y: number, z: number, rExtra: number, out: Int32Array) => void\n}\n\n\nfunction makeAVHash (atomsX: Float32Array, atomsY: Float32Array, atomsZ: Float32Array, atomsR: Float32Array, min: Float32Array, max: Float32Array, maxDistance: number): iAVHash {\n maxDistance = Math.max(0.1, maxDistance) // Avoid maxDistance of zero, see #802\n var nAtoms = atomsX.length\n\n var minX = min[ 0 ]\n var minY = min[ 1 ]\n var minZ = min[ 2 ]\n\n var maxX = max[ 0 ]\n var maxY = max[ 1 ]\n var maxZ = max[ 2 ]\n\n function hashFunc (w: number, minW: number) {\n return Math.floor((w - minW) / maxDistance)\n }\n\n var iDim = hashFunc(maxX, minX) + 1\n var jDim = hashFunc(maxY, minY) + 1\n var kDim = hashFunc(maxZ, minZ) + 1\n\n var nCells = iDim * jDim * kDim\n\n var jkDim = jDim * kDim\n\n /* Get cellID for cartesian x,y,z */\n var cellID = function (x: number, y: number, z: number) {\n return (((hashFunc(x, minX) * jDim) + hashFunc(y, minY)) * kDim) + hashFunc(z, minZ)\n }\n\n /* Initial building, could probably be optimized further */\n var preHash = [] // preHash[ cellID ] = [ atomId1, atomId2 ];\n\n for (var i = 0; i < nAtoms; i++) {\n var cid = cellID(atomsX[ i ], atomsY[ i ], atomsZ[ i ])\n\n if (preHash[ cid ] === undefined) {\n preHash[ cid ] = [ i ]\n } else {\n preHash[ cid ].push(i)\n }\n }\n\n var cellOffsets = new Uint32Array(nCells)\n var cellLengths = new Uint16Array(nCells)\n var data = new Uint32Array(nAtoms)\n\n var offset = 0\n var maxCellLength = 0\n\n for (i = 0; i < nCells; i++) {\n var start = cellOffsets[ i ] = offset\n\n var subArray = preHash[ i ]\n\n if (subArray !== undefined) {\n for (var j = 0; j < subArray.length; j++) {\n data[ offset ] = subArray[ j ]\n offset++\n }\n }\n\n var cellLength = offset - start\n cellLengths[ i ] = cellLength\n\n if (cellLength > maxCellLength) { maxCellLength = cellLength }\n }\n\n // Maximum number of neighbours we could ever produce (27 adjacent cells of equal population)\n const neighbourListLength = (27 * maxCellLength) + 1\n\n /**\n * Populate the supplied out array with atom indices that are within rAtom + rExtra\n * of x,y,z\n *\n * -1 in out array indicates the end of the list\n *\n * @param {Float} x - x coordinate\n * @param {Float} y - y coordinate\n * @param {Float} z - z coordinate\n * @param {Float} rExtra - additional radius\n * @param {Float32Array} out - pre-allocated output array\n * @return {undefined}\n */\n const withinRadii = function (x: number, y: number, z: number, rExtra: number, out: Int32Array) {\n var outIdx = 0\n\n var nearI = hashFunc(x, minX)\n var nearJ = hashFunc(y, minY)\n var nearK = hashFunc(z, minZ)\n\n var loI = Math.max(0, nearI - 1)\n var loJ = Math.max(0, nearJ - 1)\n var loK = Math.max(0, nearK - 1)\n\n var hiI = Math.min(iDim, nearI + 2)\n var hiJ = Math.min(jDim, nearJ + 2)\n var hiK = Math.min(kDim, nearK + 2)\n\n for (var i = loI; i < hiI; ++i) {\n var iOffset = i * jkDim\n\n for (var j = loJ; j < hiJ; ++j) {\n var jOffset = j * kDim\n\n for (var k = loK; k < hiK; ++k) {\n var cid = iOffset + jOffset + k\n\n var cellStart = cellOffsets[ cid ]\n var cellEnd = cellStart + cellLengths[ cid ]\n\n for (var dataIndex = cellStart; dataIndex < cellEnd; dataIndex++) {\n var atomIndex = data[ dataIndex ]\n var dx = atomsX[ atomIndex ] - x\n var dy = atomsY[ atomIndex ] - y\n var dz = atomsZ[ atomIndex ] - z\n var rSum = atomsR[ atomIndex ] + rExtra\n\n if ((dx * dx + dy * dy + dz * dz) <= (rSum * rSum)) {\n out[ outIdx++ ] = data[ dataIndex ]\n }\n }\n }\n }\n }\n // Add terminator\n out[ outIdx ] = -1\n }\n return {\n neighbourListLength: neighbourListLength,\n withinRadii: withinRadii\n }\n}\n\ninterface AVSurface {\n getSurface: (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean, smooth: number, contour: boolean) => any\n}\nfunction AVSurface (this: AVSurface, coordList: Float32Array, radiusList: Float32Array, indexList: Uint16Array|Uint32Array) {\n // Field generation method adapted from AstexViewer (Mike Hartshorn)\n // by Fred Ludlow.\n // Other parts based heavily on NGL (Alexander Rose) EDT Surface class\n //\n // Should work as a drop-in alternative to EDTSurface (though some of\n // the EDT paramters are not relevant in this method).\n\n const nAtoms = radiusList.length\n\n const x = new Float32Array(nAtoms)\n const y = new Float32Array(nAtoms)\n const z = new Float32Array(nAtoms)\n\n for (let i = 0; i < nAtoms; i++) {\n const ci = 3 * i\n x[ i ] = coordList[ ci ]\n y[ i ] = coordList[ ci + 1 ]\n z[ i ] = coordList[ ci + 2 ]\n }\n\n let bbox = computeBoundingBox(coordList)\n if (coordList.length === 0) {\n bbox[ 0 ].set([ 0, 0, 0 ])\n bbox[ 1 ].set([ 0, 0, 0 ])\n }\n const min = bbox[0]\n const max = bbox[1]\n\n let r: Float32Array, r2: Float32Array // Atom positions, expanded radii (squared)\n let maxRadius: number\n\n // Parameters\n let probeRadius: number, scaleFactor: number, setAtomID: boolean, probePositions: number\n\n // Cache last value for obscured test\n let lastClip = -1\n\n // Grid params\n let dim: Float32Array, matrix: Float32Array, grid: NumberArray, atomIndex: Int32Array\n\n // grid indices -> xyz coords\n let gridx: Float32Array, gridy: Float32Array, gridz: Float32Array\n\n // Lookup tables:\n let sinTable: Float32Array, cosTable: Float32Array\n\n // Spatial Hash\n let hash: iAVHash\n\n // Neighbour array to be filled by hash\n let neighbours: Int32Array\n\n // Vectors for Torus Projection\n const atob = new Float32Array([ 0.0, 0.0, 0.0 ])\n const mid = new Float32Array([ 0.0, 0.0, 0.0 ])\n const n1 = new Float32Array([ 0.0, 0.0, 0.0 ])\n const n2 = new Float32Array([ 0.0, 0.0, 0.0 ])\n\n let ngTorus: number\n\n function init (_probeRadius?: number, _scaleFactor?: number, _setAtomID?: boolean, _probePositions?: number) {\n probeRadius = defaults(_probeRadius, 1.4)\n scaleFactor = defaults(_scaleFactor, 2.0)\n setAtomID = defaults(_setAtomID, true)\n probePositions = defaults(_probePositions, 30)\n\n r = new Float32Array(nAtoms)\n r2 = new Float32Array(nAtoms)\n\n for (let i = 0; i < r.length; ++i) {\n var rExt = radiusList[ i ] + probeRadius\n r[ i ] = rExt\n r2[ i ] = rExt * rExt\n }\n\n maxRadius = 0\n for (let j = 0; j < r.length; ++j) {\n if (r[ j ] > maxRadius) maxRadius = r[ j ]\n }\n\n initializeGrid()\n initializeAngleTables()\n initializeHash()\n\n lastClip = -1\n }\n\n function fillGridDim (a: Float32Array, start: number, step: number) {\n for (let i = 0; i < a.length; i++) {\n a[i] = start + (step * i)\n }\n }\n\n function initializeGrid () {\n const surfGrid = getSurfaceGrid(\n min, max, maxRadius, scaleFactor, 0.0\n )\n\n scaleFactor = surfGrid.scaleFactor\n dim = surfGrid.dim\n matrix = surfGrid.matrix\n\n ngTorus = Math.max(5, 2 + Math.floor(probeRadius * scaleFactor))\n\n grid = uniformArray(dim[0] * dim[1] * dim[2], -1001.0)\n\n atomIndex = new Int32Array(grid.length)\n\n gridx = new Float32Array(dim[0])\n gridy = new Float32Array(dim[1])\n gridz = new Float32Array(dim[2])\n\n fillGridDim(gridx, min[0], 1 / scaleFactor)\n fillGridDim(gridy, min[1], 1 / scaleFactor)\n fillGridDim(gridz, min[2], 1 / scaleFactor)\n }\n\n function initializeAngleTables () {\n var theta = 0.0\n var step = 2 * Math.PI / probePositions\n\n cosTable = new Float32Array(probePositions)\n sinTable = new Float32Array(probePositions)\n for (var i = 0; i < probePositions; i++) {\n cosTable[ i ] = Math.cos(theta)\n sinTable[ i ] = Math.sin(theta)\n theta += step\n }\n }\n\n function initializeHash () {\n hash = makeAVHash(x, y, z, r, min, max, 2.01 * maxRadius)\n neighbours = new Int32Array(hash.neighbourListLength)\n }\n\n function obscured (x: number, y: number, z: number, a: number, b: number) {\n // Is the point at x,y,z obscured by any of the atoms\n // specifeid by indices in neighbours. Ignore indices\n // a and b (these are the relevant atoms in projectPoints/Torii)\n\n // Cache the last clipped atom (as very often the same one in\n // subsequent calls)\n let ai: number\n\n if (lastClip !== -1) {\n ai = lastClip\n if (ai !== a && ai !== b && singleAtomObscures(ai, x, y, z)) {\n return ai\n } else {\n lastClip = -1\n }\n }\n\n var ni = 0\n ai = neighbours[ ni ]\n while (ai >= 0) {\n if (ai !== a && ai !== b && singleAtomObscures(ai, x, y, z)) {\n lastClip = ai\n return ai\n }\n ai = neighbours[ ++ni ]\n }\n\n lastClip = -1\n\n return -1\n }\n\n function singleAtomObscures (ai: number, x: number, y: number, z: number) {\n var ci = 3 * ai\n var ra2 = r2[ ai ]\n var dx = coordList[ ci ] - x\n var dy = coordList[ ci + 1 ] - y\n var dz = coordList[ ci + 2 ] - z\n var d2 = dx * dx + dy * dy + dz * dz\n\n return d2 < ra2\n }\n\n function projectPoints () {\n // For each atom:\n // Iterate over a subsection of the grid, for each point:\n // If current value < 0.0, unvisited, set positive\n //\n // In any case: Project this point onto surface of the atomic sphere\n // If this projected point is not obscured by any other atom\n // Calcualte delta distance and set grid value to minimum of\n // itself and delta\n\n // Should we alias frequently accessed closure variables??\n // Assume JS engine capable of optimizing this\n // anyway...\n\n for (var i = 0; i < nAtoms; i++) {\n var ax = x[ i ]\n var ay = y[ i ]\n var az = z[ i ]\n var ar = r[ i ]\n var ar2 = r2[ i ]\n\n hash.withinRadii(ax, ay, az, ar, neighbours)\n\n // Number of grid points, round this up...\n var ng = Math.ceil(ar * scaleFactor)\n\n // Center of the atom, mapped to grid points (take floor)\n var iax = Math.floor(scaleFactor * (ax - min[ 0 ]))\n var iay = Math.floor(scaleFactor * (ay - min[ 1 ]))\n var iaz = Math.floor(scaleFactor * (az - min[ 2 ]))\n\n // Extents of grid to consider for this atom\n var minx = Math.max(0, iax - ng)\n var miny = Math.max(0, iay - ng)\n var minz = Math.max(0, iaz - ng)\n\n // Add two to these points:\n // - iax are floor'd values so this ensures coverage\n // - these are loop limits (exclusive)\n var maxx = Math.min(dim[ 0 ], iax + ng + 2)\n var maxy = Math.min(dim[ 1 ], iay + ng + 2)\n var maxz = Math.min(dim[ 2 ], iaz + ng + 2)\n\n for (var ix = minx; ix < maxx; ix++) {\n var dx = gridx[ ix ] - ax\n var xoffset = dim[ 1 ] * dim[ 2 ] * ix\n\n for (var iy = miny; iy < maxy; iy++) {\n var dy = gridy[ iy ] - ay\n var dxy2 = dx * dx + dy * dy\n var xyoffset = xoffset + dim[ 2 ] * iy\n\n for (var iz = minz; iz < maxz; iz++) {\n var dz = gridz[ iz ] - az\n var d2 = dxy2 + dz * dz\n\n if (d2 < ar2) {\n var idx = iz + xyoffset\n\n if (grid[idx] < 0.0) {\n // Unvisited, make positive\n grid[ idx ] = -grid[ idx ]\n }\n // Project on to the surface of the sphere\n // sp is the projected point ( dx, dy, dz ) * ( ra / d )\n var d = Math.sqrt(d2)\n var ap = ar / d\n var spx = dx * ap\n var spy = dy * ap\n var spz = dz * ap\n\n spx += ax\n spy += ay\n spz += az\n\n if (obscured(spx, spy, spz, i, -1) === -1) {\n var dd = ar - d\n if (dd < grid[ idx ]) {\n grid[ idx ] = dd\n if (setAtomID) atomIndex[ idx ] = i\n }\n }\n }\n }\n }\n }\n }\n }\n\n function projectTorii () {\n for (var i = 0; i < nAtoms; i++) {\n hash.withinRadii(x[ i ], y[ i ], z[ i ], r[ i ], neighbours)\n var ia = 0\n var ni = neighbours[ ia ]\n while (ni >= 0) {\n if (i < ni) {\n projectTorus(i, ni)\n }\n ni = neighbours[ ++ia ]\n }\n }\n }\n\n function projectTorus (a: number, b: number) {\n var r1 = r[ a ]\n var r2 = r[ b ]\n var dx = atob[ 0 ] = x[ b ] - x[ a ]\n var dy = atob[ 1 ] = y[ b ] - y[ a ]\n var dz = atob[ 2 ] = z[ b ] - z[ a ]\n var d2 = dx * dx + dy * dy + dz * dz\n\n // This check now redundant as already done in AVHash.withinRadii\n // if( d2 > (( r1 + r2 ) * ( r1 + r2 )) ){ return; }\n\n var d = Math.sqrt(d2)\n\n // Find angle between a->b vector and the circle\n // of their intersection by cosine rule\n var cosA = (r1 * r1 + d * d - r2 * r2) / (2.0 * r1 * d)\n\n // distance along a->b at intersection\n var dmp = r1 * cosA\n\n v3normalize(atob, atob)\n\n // Create normal to line\n normalToLine(n1 as any, atob)\n v3normalize(n1, n1)\n\n // Cross together for second normal vector\n v3cross(n2, atob, n1)\n v3normalize(n2, n2)\n\n // r is radius of circle of intersection\n var rInt = Math.sqrt(r1 * r1 - dmp * dmp)\n\n v3multiplyScalar(n1, n1, rInt)\n v3multiplyScalar(n2, n2, rInt)\n v3multiplyScalar(atob, atob, dmp)\n\n mid[ 0 ] = atob[ 0 ] + x[ a ]\n mid[ 1 ] = atob[ 1 ] + y[ a ]\n mid[ 2 ] = atob[ 2 ] + z[ a ]\n\n lastClip = -1\n\n var ng = ngTorus\n\n for (var i = 0; i < probePositions; i++) {\n var cost = cosTable[ i ]\n var sint = sinTable[ i ]\n\n var px = mid[ 0 ] + cost * n1[ 0 ] + sint * n2[ 0 ]\n var py = mid[ 1 ] + cost * n1[ 1 ] + sint * n2[ 1 ]\n var pz = mid[ 2 ] + cost * n1[ 2 ] + sint * n2[ 2 ]\n\n if (obscured(px, py, pz, a, b) === -1) {\n // As above, iterate over our grid...\n // px, py, pz in grid coords\n var iax = Math.floor(scaleFactor * (px - min[ 0 ]))\n var iay = Math.floor(scaleFactor * (py - min[ 1 ]))\n var iaz = Math.floor(scaleFactor * (pz - min[ 2 ]))\n\n var minx = Math.max(0, iax - ng)\n var miny = Math.max(0, iay - ng)\n var minz = Math.max(0, iaz - ng)\n\n var maxx = Math.min(dim[ 0 ], iax + ng + 2)\n var maxy = Math.min(dim[ 1 ], iay + ng + 2)\n var maxz = Math.min(dim[ 2 ], iaz + ng + 2)\n\n for (var ix = minx; ix < maxx; ix++) {\n dx = px - gridx[ ix ]\n var xoffset = dim[ 1 ] * dim[ 2 ] * ix\n\n for (var iy = miny; iy < maxy; iy++) {\n dy = py - gridy[ iy ]\n var dxy2 = dx * dx + dy * dy\n var xyoffset = xoffset + dim[ 2 ] * iy\n\n for (var iz = minz; iz < maxz; iz++) {\n dz = pz - gridz[ iz ]\n d2 = dxy2 + dz * dz\n var idx = iz + xyoffset\n var current = grid[ idx ]\n\n if (current > 0.0 && d2 < (current * current)) {\n grid[ idx ] = Math.sqrt(d2)\n if (setAtomID) {\n // Is this grid point closer to a or b?\n // Take dot product of atob and gridpoint->p (dx, dy, dz)\n const dp = dx * atob[ 0 ] + dy * atob [ 1 ] + dz * atob[ 2 ]\n atomIndex[ idx ] = dp < 0.0 ? b : a\n }\n }\n }\n }\n }\n }\n }\n }\n\n function normalToLine (out: Int32Array, p: Float32Array) {\n out[ 0 ] = out[ 1 ] = out[ 2 ] = 1.0\n if (p[ 0 ] !== 0) {\n out[ 0 ] = (p[ 1 ] + p[ 2 ]) / -p[ 0 ]\n } else if (p[ 1 ] !== 0) {\n out[ 1 ] = (p[ 0 ] + p[ 2 ]) / -p[ 1 ]\n } else if (p[ 2 ] !== 0) {\n out[ 2 ] = (p[ 0 ] + p[ 1 ]) / -p[ 2 ]\n }\n return out\n }\n\n function fixNegatives () {\n for (var i = 0; i < grid.length; i++) {\n if (grid[ i ] < 0) grid[ i ] = 0\n }\n }\n\n function fixAtomIDs () {\n for (var i = 0; i < atomIndex.length; i++) {\n atomIndex[ i ] = indexList[ atomIndex[ i ] ]\n }\n }\n\n function getVolume (probeRadius: number, scaleFactor: number, setAtomID: boolean) {\n // Basic steps are:\n // 1) Initialize\n // 2) Project points\n // 3) Project torii\n\n console.time('AVSurface.getVolume')\n\n console.time('AVSurface.init')\n init(probeRadius, scaleFactor, setAtomID)\n console.timeEnd('AVSurface.init')\n\n console.time('AVSurface.projectPoints')\n projectPoints()\n console.timeEnd('AVSurface.projectPoints')\n\n console.time('AVSurface.projectTorii')\n projectTorii()\n console.timeEnd('AVSurface.projectTorii')\n fixNegatives()\n fixAtomIDs()\n\n console.timeEnd('AVSurface.getVolume')\n }\n\n this.getSurface = function (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean, smooth: number, contour: boolean) {\n // type and cutoff left in for compatibility with EDTSurface.getSurface\n // function signature\n\n getVolume(probeRadius, scaleFactor, setAtomID)\n\n var volsurf = new (VolumeSurface as any)(\n grid, dim[ 2 ], dim[ 1 ], dim[ 0 ], atomIndex\n ) as VolumeSurface\n\n return volsurf.getSurface!(probeRadius, false, undefined, matrix, contour)\n }\n}\nObject.assign(AVSurface, {__deps: [\n getSurfaceGrid, VolumeSurface, uniformArray, computeBoundingBox,\n v3multiplyScalar, v3cross, v3normalize,\n makeAVHash,\n defaults\n]})\n\nexport { AVSurface, makeAVHash }\n","/**\n * @file Molecular Surface\n * @author Alexander Rose \n * @private\n */\n\nimport { WorkerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Worker from '../worker/worker'\nimport EDTSurface from './edt-surface'\nimport { AVSurface } from './av-surface'\nimport Surface, { SurfaceData } from './surface'\nimport { Structure } from '../ngl';\nimport { AtomData, RadiusParams } from '../structure/structure-data';\n\nWorkerRegistry.add('molsurf', function func (e: any, callback: (data: any, buffers: any[])=> void) {\n const a = e.data.args\n const p = e.data.params\n if (a && p) {\n const SurfClass = (p.type === 'av') ? AVSurface : EDTSurface\n const surf = new (SurfClass as any)(a.coordList, a.radiusList, a.indexList) as AVSurface|EDTSurface\n const sd = surf.getSurface(\n p.type, p.probeRadius, p.scaleFactor, p.cutoff, true, p.smooth, p.contour\n ) as SurfaceData\n const transferList = [ sd.position.buffer, sd.index!.buffer ]\n if (sd.normal) transferList.push(sd.normal.buffer)\n if (sd.atomindex) transferList.push(sd.atomindex.buffer)\n const data = {\n sd: sd,\n p: p\n }\n callback(data, transferList)\n }\n}, [ EDTSurface, AVSurface ])\n\n/**\n * Molecular surface parameter object.\n * @typedef {Object} MolecularSurfaceParameters - stage parameters\n * @property {String} type - \"av\" or \"edt\"\n * @property {Number} probeRadius - probe radius\n * @property {Number} scaleFactor - higher for better quality\n * @property {Integer} smooth - number of smoothing cycles to apply\n * @property {String} name - name for created surface\n */\nexport interface MolecularSurfaceParameters {\n type: 'av'|'edt'\n probeRadius: number\n scaleFactor: number\n smooth: number\n name: string\n cutoff: number\n contour: boolean,\n radiusParams: RadiusParams\n}\n/**\n * Create Molecular surfaces\n */\nclass MolecularSurface {\n structure: Structure\n worker: Worker|undefined\n\n constructor (structure: Structure) {\n this.structure = structure\n }\n\n _getAtomData (params: Partial): AtomData {\n return this.structure.getAtomData({\n what: { position: true, radius: true, index: true },\n radiusParams: defaults(params.radiusParams, {\n type: 'vdw', scale: 1.0\n })\n })\n }\n\n _makeSurface (sd: SurfaceData, p: Partial) {\n var surface = new Surface(p.name!, '', sd)\n\n surface.info.type = p.type\n surface.info.probeRadius = p.probeRadius\n surface.info.scaleFactor = p.scaleFactor\n surface.info.smooth = p.smooth\n surface.info.cutoff = p.cutoff\n\n return surface\n }\n\n /**\n * Get molecular surface\n * @param {MolecularSurfaceParameters} params - parameters for surface creation\n * @return {Surface} the surface\n */\n getSurface (params: Partial) {\n const p = params || {}\n\n const atomData = this._getAtomData(params)\n const coordList = atomData.position\n const radiusList = atomData.radius\n const indexList = atomData.index\n\n const SurfClass = (p.type === 'av') ? AVSurface : EDTSurface\n const surf = new (SurfClass as any)(coordList, radiusList, indexList) as AVSurface|EDTSurface\n const sd = surf.getSurface(\n p.type!, p.probeRadius!, p.scaleFactor!, p.cutoff!, true, p.smooth!, p.contour!\n )\n\n return this._makeSurface(sd, p)\n }\n\n /**\n * Get molecular surface asynchronous\n * @param {MolecularSurfaceParameters} params - parameters for surface creation\n * @param {function(surface: Surface)} callback - function to be called after surface is created\n * @return {undefined}\n */\n getSurfaceWorker (params: MolecularSurfaceParameters, callback: (s: Surface) => void) {\n const p = Object.assign({}, params)\n\n if (window.hasOwnProperty('Worker')) {\n if (this.worker === undefined) {\n this.worker = new Worker('molsurf')\n }\n\n const atomData = this._getAtomData(params)\n const coordList = atomData.position\n const radiusList = atomData.radius\n const indexList = atomData.index\n\n const msg = {\n args: {\n coordList: coordList,\n radiusList: radiusList,\n indexList: indexList\n },\n params: p\n }\n\n const transferList = [\n coordList!.buffer, radiusList!.buffer, indexList!.buffer\n ]\n\n this.worker.post(msg, transferList,\n\n (e: any) => {\n callback(this._makeSurface(e.data.sd, p))\n },\n\n (e: string) => {\n console.warn(\n 'MolecularSurface.getSurfaceWorker error - trying without worker', e\n )\n this.worker!.terminate()\n this.worker = undefined\n const surface = this.getSurface(p)\n callback(surface)\n }\n\n )\n } else {\n const surface = this.getSurface(p)\n callback(surface)\n }\n }\n\n /**\n * Cleanup\n * @return {undefined}\n */\n dispose () {\n if (this.worker) this.worker.terminate()\n }\n}\n\nexport default MolecularSurface\n","/**\n * @file Molecular Surface Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport MolecularSurface, { MolecularSurfaceParameters } from '../surface/molecular-surface'\nimport SurfaceBuffer from '../buffer/surface-buffer'\nimport ContourBuffer from '../buffer/contour-buffer'\nimport DoubleSidedBuffer from '../buffer/doublesided-buffer'\nimport Selection from '../selection/selection'\nimport Viewer from '../viewer/viewer';\n// @ts-ignore: unused import Volume required for declaration only\nimport { Structure, Vector3, Volume } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport { SurfaceDataFields } from './surface-representation';\nimport Surface, {SurfaceData} from '../surface/surface';\n\nexport interface MolecularSurfaceRepresentationParameters extends StructureRepresentationParameters {\n surfaceType: 'vws'|'sas'|'ms'|'ses'|'av'\n probeRadius: number\n smooth: number\n scaleFactor: number\n cutoff: number\n contour: boolean\n background: boolean\n opaqueBack: boolean\n filterSele: string\n colorVolume: any\n useWorker: boolean\n}\n\nexport interface MolecularSurfaceInfo {\n molsurf?: MolecularSurface\n sele?: string\n surface?: Surface\n}\n\n/**\n * Molecular Surface Representation\n */\nclass MolecularSurfaceRepresentation extends StructureRepresentation {\n protected surfaceType: 'vws'|'sas'|'ms'|'ses'|'av'\n protected probeRadius: number\n protected smooth: number\n protected scaleFactor: number\n protected cutoff: number\n protected contour: boolean\n protected background: boolean\n protected opaqueBack: boolean\n protected filterSele: string\n protected colorVolume: any\n protected useWorker: boolean\n\n protected __infoList: MolecularSurfaceInfo[]\n protected __forceNewMolsurf: boolean\n protected __sele: string\n protected __surfaceParams: string\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'surface'\n\n this.parameters = Object.assign({\n\n surfaceType: {\n type: 'select',\n rebuild: true,\n options: {\n 'vws': 'vws',\n 'sas': 'sas',\n 'ms': 'ms',\n 'ses': 'ses',\n 'av': 'av'\n }\n },\n probeRadius: {\n type: 'number',\n precision: 1,\n max: 20,\n min: 0,\n rebuild: true\n },\n smooth: {\n type: 'integer',\n precision: 1,\n max: 10,\n min: 0,\n rebuild: true\n },\n scaleFactor: {\n type: 'number',\n precision: 1,\n max: 5,\n min: 0,\n rebuild: true\n },\n cutoff: {\n type: 'number',\n precision: 2,\n max: 50,\n min: 0,\n rebuild: true\n },\n contour: {\n type: 'boolean', rebuild: true\n },\n background: {\n type: 'boolean', rebuild: true // FIXME\n },\n opaqueBack: {\n type: 'boolean', buffer: true\n },\n filterSele: {\n type: 'text', rebuild: true\n },\n colorVolume: {\n type: 'hidden'\n },\n useWorker: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n\n radius: null,\n scale: null\n\n })\n\n this.__infoList = []\n\n // TODO find a more direct way\n this.structure.signals.refreshed.add(() => {\n this.__forceNewMolsurf = true\n })\n\n this.toBePrepared = true\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'uniform')\n p.colorValue = defaults(p.colorValue, 0xDDDDDD)\n p.disablePicking = defaults(p.disablePicking, true)\n\n this.surfaceType = defaults(p.surfaceType, 'ms')\n this.probeRadius = defaults(p.probeRadius, 1.4)\n this.smooth = defaults(p.smooth, 2)\n this.scaleFactor = defaults(p.scaleFactor, 2.0)\n this.cutoff = defaults(p.cutoff, 0.0)\n this.contour = defaults(p.contour, false)\n this.background = defaults(p.background, false)\n this.opaqueBack = defaults(p.opaqueBack, true)\n this.filterSele = defaults(p.filterSele, '')\n this.colorVolume = defaults(p.colorVolume, undefined)\n this.useWorker = defaults(p.useWorker, true)\n\n super.init(params)\n }\n\n prepareData (sview: StructureView, i: number, callback: (i: number) => void) {\n let info: MolecularSurfaceInfo = this.__infoList[ i ]\n if (!info) {\n info = {}\n this.__infoList[ i ] = info\n }\n\n if (!info.molsurf || info.sele !== sview.selection.string) {\n if (this.filterSele) {\n const sviewFilter = sview.structure.getView(new Selection(this.filterSele))\n const bbSize = sviewFilter.boundingBox.getSize(new Vector3())\n const maxDim = Math.max(bbSize.x, bbSize.y, bbSize.z)\n const asWithin = sview.getAtomSetWithinPoint(sviewFilter.center, (maxDim / 2) + 6.0)\n sview = sview.getView(\n new Selection(sview.getAtomSetWithinSelection(asWithin, 3).toSeleString())\n )\n if (sview.atomCount === 0) {\n callback(i)\n return\n }\n }\n\n info.sele = sview.selection.string\n info.molsurf = new MolecularSurface(sview)\n\n const p = this.getSurfaceParams()\n const onSurfaceFinish = (surface: Surface) => {\n info.surface = surface\n callback(i)\n }\n\n if (this.useWorker) {\n info.molsurf.getSurfaceWorker(p as MolecularSurfaceParameters, onSurfaceFinish)\n } else {\n onSurfaceFinish(info.molsurf.getSurface(p as {name: string, type: 'av'|'edt' } & MolecularSurfaceRepresentationParameters))\n }\n } else {\n callback(i)\n }\n }\n\n prepare (callback: () => void) {\n if (this.__forceNewMolsurf || this.__sele !== this.selection.string ||\n this.__surfaceParams !== JSON.stringify(this.getSurfaceParams())) {\n this.__infoList.forEach((info: MolecularSurfaceInfo) => {\n if (info && info.molsurf) {\n info.molsurf.dispose()\n }\n })\n this.__infoList.length = 0\n }\n\n if (this.structureView.atomCount === 0) {\n callback()\n return\n }\n\n const after = () => {\n this.__sele = this.selection.string\n this.__surfaceParams = JSON.stringify(this.getSurfaceParams())\n this.__forceNewMolsurf = false\n callback()\n }\n\n const name = this.assembly === 'default' ? this.defaultAssembly : this.assembly\n const assembly = this.structure.biomolDict[ name ]\n\n if (assembly) {\n assembly.partList.forEach((part, i) => {\n const sview = part.getView(this.structureView)\n this.prepareData(sview as StructureView, i, (_i) => {\n if (_i === assembly.partList.length - 1) after()\n })\n })\n } else {\n this.prepareData(this.structureView, 0, after)\n }\n }\n\n createData (sview: StructureView, i: number) {\n const info = this.__infoList[ i ]\n const surface = info.surface\n\n if (!surface) {\n // Surface creation bailed (no surface generated for this sview)\n return\n }\n\n const surfaceData = {\n position: surface!.getPosition(),\n color: surface!.getColor(this.getColorParams()),\n index: surface!.getFilteredIndex(this.filterSele, sview)\n }\n\n const bufferList = []\n\n if (surface.contour) {\n const contourBuffer = new ContourBuffer(\n surfaceData,\n this.getBufferParams({\n wireframe: false\n })\n )\n\n bufferList.push(contourBuffer)\n } else {\n Object.assign(surfaceData, {\n normal: surface.getNormal(),\n picking: surface.getPicking(sview.getStructure())\n })\n\n const surfaceBuffer = new SurfaceBuffer(\n surfaceData,\n this.getBufferParams({\n background: this.background,\n opaqueBack: this.opaqueBack,\n dullInterior: false\n })\n )\n\n if (this.getBufferParams().side == 'double') {\n const doubleSidedBuffer = new DoubleSidedBuffer(surfaceBuffer)\n bufferList.push(doubleSidedBuffer)\n }\n else {\n bufferList.push(surfaceBuffer)\n }\n }\n\n return { bufferList, info } as StructureRepresentationData\n }\n\n updateData (what: SurfaceDataFields, data: StructureRepresentationData) {\n const surfaceData: Partial = {}\n\n if (what.position || what.radius) {\n this.__forceNewMolsurf = true\n this.build()\n return\n }\n\n if (what.color) {\n surfaceData.color = data.info.surface.getColor(this.getColorParams())\n }\n\n if (what.index) {\n surfaceData.index = data.info.surface.getFilteredIndex(this.filterSele, data.sview)\n }\n\n data.bufferList[ 0 ].setAttributes(surfaceData)\n }\n\n setParameters (params: Partial, what: Partial = {}, rebuild?: boolean) {\n if (params && params.filterSele) {\n what.index = true\n }\n\n if (params && params.colorVolume !== undefined) {\n what.color = true\n }\n\n // forbid setting wireframe to true when contour is true\n if (params && params.wireframe && (\n params.contour || (params.contour === undefined && this.contour)\n )\n ) {\n params.wireframe = false\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n\n getSurfaceParams (params: Partial = {}) {\n const p = Object.assign({\n type: this.surfaceType as string,\n probeRadius: this.probeRadius as number,\n scaleFactor: this.scaleFactor as number,\n smooth: this.smooth && !this.contour,\n cutoff: this.cutoff as number,\n contour: this.contour as boolean,\n useWorker: this.useWorker as boolean,\n radiusParams: this.getRadiusParams()\n }, params)\n\n return p\n }\n\n getColorParams () {\n const p = super.getColorParams()\n\n p.volume = this.colorVolume\n\n return p\n }\n\n getAtomRadius () {\n return 0\n }\n\n clear () {\n super.clear()\n }\n\n dispose () {\n this.__infoList.forEach((info: MolecularSurfaceInfo) => {\n if (info && info.molsurf) {\n info.molsurf.dispose()\n }\n })\n this.__infoList.length = 0\n\n super.dispose()\n }\n}\n\nRepresentationRegistry.add('surface', MolecularSurfaceRepresentation)\n\nexport default MolecularSurfaceRepresentation\n","/**\n * @file Point Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport PointBuffer from '../buffer/point-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { AtomDataFields } from '../structure/structure-data';\n\nexport interface PointRepresentationParameters extends StructureRepresentationParameters {\n pointSize: number\n sizeAttenuation: boolean\n sortParticles: boolean\n useTexture: boolean\n alphaTest: number\n forceTransparent: boolean\n edgeBleach: number\n}\n\n/**\n * Point Representation\n */\nclass PointRepresentation extends StructureRepresentation {\n protected pointSize: number\n protected sizeAttenuation: boolean\n protected sortParticles: boolean\n protected useTexture: boolean\n protected alphaTest: number\n protected forceTransparent: boolean\n protected edgeBleach: number\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'point'\n\n this.parameters = Object.assign({\n\n pointSize: {\n type: 'number', precision: 1, max: 100, min: 0, buffer: true\n },\n sizeAttenuation: {\n type: 'boolean', buffer: true\n },\n sortParticles: {\n type: 'boolean', rebuild: true\n },\n useTexture: {\n type: 'boolean', buffer: true\n },\n alphaTest: {\n type: 'range', step: 0.001, max: 1, min: 0, buffer: true\n },\n forceTransparent: {\n type: 'boolean', buffer: true\n },\n edgeBleach: {\n type: 'range', step: 0.001, max: 1, min: 0, buffer: true\n }\n\n }, this.parameters, {\n\n flatShaded: null,\n wireframe: null,\n linewidth: null,\n side: null,\n\n roughness: null,\n metalness: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n\n this.pointSize = defaults(p.pointSize, 1)\n this.sizeAttenuation = defaults(p.sizeAttenuation, true)\n this.sortParticles = defaults(p.sortParticles, false)\n this.useTexture = defaults(p.useTexture, false)\n this.alphaTest = defaults(p.alphaTest, 0.5)\n this.forceTransparent = defaults(p.forceTransparent, false)\n this.edgeBleach = defaults(p.edgeBleach, 0.0)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n var what = { position: true, color: true, picking: true }\n var atomData = sview.getAtomData(this.getAtomParams(what))\n\n var pointBuffer = new PointBuffer(\n atomData,\n this.getBufferParams({\n pointSize: this.pointSize,\n sizeAttenuation: this.sizeAttenuation,\n sortParticles: this.sortParticles,\n useTexture: this.useTexture,\n alphaTest: this.alphaTest,\n forceTransparent: this.forceTransparent,\n edgeBleach: this.edgeBleach\n })\n )\n\n return {\n bufferList: [ pointBuffer ]\n }\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n var atomData = data.sview!.getAtomData(this.getAtomParams(what))\n var pointData = {}\n\n if (!what || what.position) {\n Object.assign(pointData, {position: atomData.position})\n }\n\n if (!what || what.color) {\n Object.assign(pointData, {color: atomData.color})\n }\n\n data.bufferList[ 0 ].setAttributes(pointData)\n }\n\n getAtomRadius () {\n return 0.1\n }\n}\n\nRepresentationRegistry.add('point', PointRepresentation)\n\nexport default PointRepresentation\n","/**\n * @file Ribbon Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport '../shader/Ribbon.vert'\n\nimport { getUintArray } from '../utils'\nimport { serialArray } from '../math/array-utils'\nimport MeshBuffer from './mesh-buffer'\nimport { BufferParameters, BufferData } from './buffer'\nimport {Log} from \"../globals\";\n\nconst quadIndices = new Uint16Array([\n 0, 1, 2,\n 1, 3, 2\n])\n\nexport interface RibbonBufferData extends BufferData {\n normal: Float32Array\n dir: Float32Array\n size: Float32Array\n}\n\nfunction getSize(data: RibbonBufferData){\n const n = (data.position!.length / 3) - 1\n const n4 = n * 4\n const x = n4 * 3\n return x\n}\n\n/**\n * Ribbon buffer. Draws a thin ribbon.\n */\nclass RibbonBuffer extends MeshBuffer {\n vertexShader = 'Ribbon.vert'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.normal - normals\n * @param {Float32Array} data.dir - binormals\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.size - sizes\n * @param {Picker} data.picking - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: RibbonBufferData, params: Partial = {}) {\n super({\n position: new Float32Array(getSize(data)),\n color: new Float32Array(getSize(data)),\n index: getUintArray(getSize(data), getSize(data) / 3),\n normal: new Float32Array(getSize(data)),\n picking: data.picking\n }, params)\n\n const n = (data.position!.length / 3) - 1\n const n4 = n * 4\n const x = n4 * 3\n\n this.addAttributes({\n 'dir': { type: 'v3', value: new Float32Array(x) }\n })\n this.addAttributes({\n 'size': { type: 'f', value: new Float32Array(n4) }\n })\n\n data.primitiveId = serialArray(n)\n this.setAttributes(data)\n\n this.makeIndex()\n }\n\n setAttributes (data: Partial = {}) {\n const n4 = this.size\n const n = n4 / 4\n\n const attributes = this.geometry.attributes as any // TODO\n\n let position, normal, size, dir, color, primitiveId\n let aPosition, aNormal, aSize, aDir, aColor, aPrimitiveId\n\n if (data.position) {\n position = data.position\n aPosition = attributes.position.array\n attributes.position.needsUpdate = true\n }\n\n if (data.normal) {\n normal = data.normal\n aNormal = attributes.normal.array\n attributes.normal.needsUpdate = true\n }\n\n if (data.size) {\n size = data.size\n aSize = attributes.size.array\n attributes.size.needsUpdate = true\n }\n\n if (data.dir) {\n dir = data.dir\n aDir = attributes.dir.array\n attributes.dir.needsUpdate = true\n }\n\n if (data.color) {\n color = data.color\n aColor = attributes.color.array\n attributes.color.needsUpdate = true\n }\n\n if (data.primitiveId) {\n primitiveId = data.primitiveId\n aPrimitiveId = attributes.primitiveId.array\n attributes.primitiveId.needsUpdate = true\n }\n\n let v, i, k, p, l, v3\n let currSize\n let prevSize = size ? size[ 0 ] : null\n\n for (v = 0; v < n; ++v) {\n v3 = v * 3\n k = v * 3 * 4\n l = v * 4\n\n if (position) {\n aPosition[ k ] = aPosition[ k + 3 ] = position[ v3 ]\n aPosition[ k + 1 ] = aPosition[ k + 4 ] = position[ v3 + 1 ]\n aPosition[ k + 2 ] = aPosition[ k + 5 ] = position[ v3 + 2 ]\n\n aPosition[ k + 6 ] = aPosition[ k + 9 ] = position[ v3 + 3 ]\n aPosition[ k + 7 ] = aPosition[ k + 10 ] = position[ v3 + 4 ]\n aPosition[ k + 8 ] = aPosition[ k + 11 ] = position[ v3 + 5 ]\n }\n\n if (normal) {\n aNormal[ k ] = aNormal[ k + 3 ] = -normal[ v3 ]\n aNormal[ k + 1 ] = aNormal[ k + 4 ] = -normal[ v3 + 1 ]\n aNormal[ k + 2 ] = aNormal[ k + 5 ] = -normal[ v3 + 2 ]\n\n aNormal[ k + 6 ] = aNormal[ k + 9 ] = -normal[ v3 + 3 ]\n aNormal[ k + 7 ] = aNormal[ k + 10 ] = -normal[ v3 + 4 ]\n aNormal[ k + 8 ] = aNormal[ k + 11 ] = -normal[ v3 + 5 ]\n }\n\n for (i = 0; i < 4; ++i) {\n p = k + 3 * i\n\n if (color) {\n aColor[ p ] = color[ v3 ]\n aColor[ p + 1 ] = color[ v3 + 1 ]\n aColor[ p + 2 ] = color[ v3 + 2 ]\n }\n\n if (primitiveId) {\n aPrimitiveId[ l + i ] = primitiveId[ v ]\n }\n }\n\n if (size) {\n currSize = size[ v ]\n\n if (prevSize !== size[ v ]) {\n aSize[ l ] = prevSize\n aSize[ l + 1 ] = prevSize\n aSize[ l + 2 ] = currSize\n aSize[ l + 3 ] = currSize\n } else {\n aSize[ l ] = currSize\n aSize[ l + 1 ] = currSize\n aSize[ l + 2 ] = currSize\n aSize[ l + 3 ] = currSize\n }\n\n prevSize = currSize\n }\n\n if (dir) {\n aDir[ k ] = dir[ v3 ]\n aDir[ k + 1 ] = dir[ v3 + 1 ]\n aDir[ k + 2 ] = dir[ v3 + 2 ]\n\n aDir[ k + 3 ] = -dir[ v3 ]\n aDir[ k + 4 ] = -dir[ v3 + 1 ]\n aDir[ k + 5 ] = -dir[ v3 + 2 ]\n\n aDir[ k + 6 ] = dir[ v3 + 3 ]\n aDir[ k + 7 ] = dir[ v3 + 4 ]\n aDir[ k + 8 ] = dir[ v3 + 5 ]\n\n aDir[ k + 9 ] = -dir[ v3 + 3 ]\n aDir[ k + 10 ] = -dir[ v3 + 4 ]\n aDir[ k + 11 ] = -dir[ v3 + 5 ]\n }\n }\n }\n\n makeIndex () {\n const index = this.geometry.getIndex()\n if (!index) { Log.error('Index is null'); return; }\n const meshIndex = index.array as Uint32Array|Uint16Array\n const n = meshIndex.length / 4 / 3\n\n for (let v = 0; v < n; ++v) {\n const ix = v * 6\n const it = v * 4\n\n meshIndex.set(quadIndices, ix)\n for (let s = 0; s < 6; ++s) {\n meshIndex[ ix + s ] += it\n }\n }\n }\n}\n\nexport default RibbonBuffer\n","/**\n * @file Ribbon Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Spline, { SplineParameters } from '../geometry/spline'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport RibbonBuffer from '../buffer/ribbon-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport StructureView from '../structure/structure-view';\nimport Polymer from '../proxy/polymer';\n\nexport interface RibbonRepresentationParameters extends StructureRepresentationParameters {\n subdiv: number\n tension: number\n smoothSheet: boolean\n}\n\n/**\n * Ribbon Representation\n */\nclass RibbonRepresentation extends StructureRepresentation {\n protected subdiv: number\n protected tension: number\n protected smoothSheet: boolean\n \n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'ribbon'\n\n this.parameters = Object.assign({\n\n subdiv: {\n type: 'integer', max: 50, min: 1, rebuild: true\n },\n tension: {\n type: 'number', precision: 1, max: 1.0, min: 0.1\n },\n smoothSheet: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n\n side: null,\n wireframe: null,\n linewidth: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'chainname')\n p.colorScale = defaults(p.colorScale, 'RdYlBu')\n p.radiusType = defaults(p.radiusType, 'sstruc')\n p.radiusScale = defaults(p.radiusScale, 4.0)\n\n if (p.quality === 'low') {\n this.subdiv = 3\n } else if (p.quality === 'medium') {\n this.subdiv = 6\n } else if (p.quality === 'high') {\n this.subdiv = 12\n } else {\n this.subdiv = defaults(p.subdiv, 6)\n }\n\n this.tension = defaults(p.tension, NaN)\n this.smoothSheet = defaults(p.smoothSheet, false)\n\n super.init(p)\n }\n\n getSplineParams (params?: Partial) {\n return Object.assign({\n subdiv: this.subdiv,\n tension: this.tension,\n directional: true,\n smoothSheet: this.smoothSheet\n }, params)\n }\n\n getAtomRadius (atom: AtomProxy) {\n return atom.isTrace() ? super.getAtomRadius(atom) : 0\n }\n\n createData (sview: StructureView) {\n var bufferList: RibbonBuffer[] = []\n var polymerList: Polymer[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4) return\n polymerList.push(polymer)\n\n var spline = new Spline(polymer, this.getSplineParams())\n var subPos = spline.getSubdividedPosition()\n var subOri = spline.getSubdividedOrientation()\n var subCol = spline.getSubdividedColor(this.getColorParams())\n var subPick = spline.getSubdividedPicking()\n var subSize = spline.getSubdividedSize(this.getRadiusParams())\n\n bufferList.push(\n new RibbonBuffer(\n ({\n position: subPos.position,\n normal: subOri.binormal,\n dir: subOri.normal,\n color: subCol.color,\n size: subSize.size,\n picking: subPick.picking\n }),\n this.getBufferParams()\n )\n )\n }, sview.getSelection())\n\n return {\n bufferList: bufferList,\n polymerList: polymerList\n }\n }\n\n updateData (what: {position?: boolean, radius?: boolean, scale?: boolean, color?: boolean}, data: {polymerList: Polymer[], bufferList: RibbonBuffer[]}) {\n what = what || {}\n\n var i = 0\n var n = data.polymerList.length\n\n for (i = 0; i < n; ++i) {\n var bufferData = {}\n var spline = new Spline(data.polymerList[ i ], this.getSplineParams())\n\n if (what.position) {\n var subPos = spline.getSubdividedPosition()\n var subOri = spline.getSubdividedOrientation()\n Object.assign(bufferData, {\n position: subPos.position,\n normal: subOri.binormal,\n dir: subOri.normal\n })\n }\n\n if (what.radius || what.scale) {\n var subSize = spline.getSubdividedSize(this.getRadiusParams())\n Object.assign(bufferData, {size: subSize.size})\n }\n\n if (what.color) {\n var subCol = spline.getSubdividedColor(this.getColorParams())\n Object.assign(bufferData, {color: subCol.color})\n }\n\n data.bufferList[ i ].setAttributes(bufferData)\n }\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n if (params && params.tension) {\n Object.assign(what, {position: true})\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('ribbon', RibbonRepresentation)\n\nexport default RibbonRepresentation\n","/**\n * @file Rocket Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { AtomPicker } from '../utils/picker'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport Helixbundle, { Axis } from '../geometry/helixbundle'\nimport CylinderBuffer from '../buffer/cylinder-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport CylinderImpostorBuffer from '../buffer/cylinderimpostor-buffer';\n\nexport interface RocketRepresentationParameters extends StructureRepresentationParameters {\n localAngle: number\n centerDist: number\n ssBorder: boolean\n radialSegments: number\n openEnded: boolean\n disableImpostor: boolean\n}\n\nexport interface AxisData {\n begin: Float32Array\n end: Float32Array\n size: Float32Array\n color: Float32Array\n picking: AtomPicker\n}\n\n/**\n * Rocket Representation\n */\nclass RocketRepresentation extends StructureRepresentation {\n\n protected localAngle: number\n protected centerDist: number\n protected ssBorder: boolean\n protected radialSegments: number\n protected openEnded: boolean\n protected disableImpostor: boolean\n // protected helixbundleList: Helixbundle[]\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'rocket'\n\n this.parameters = Object.assign({\n\n localAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n centerDist: {\n type: 'number', precision: 1, max: 10, min: 0, rebuild: true\n },\n ssBorder: {\n type: 'boolean', rebuild: true\n },\n radialSegments: true,\n openEnded: true,\n disableImpostor: true\n\n }, this.parameters)\n\n // this.helixbundleList = []\n\n this.init(params)\n }\n\n init (params: Partial) {\n let p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'sstruc')\n p.radiusSize = defaults(p.radiusSize, 1.5)\n p.radiusScale = defaults(p.radiusScale, 1.0)\n p.openEnded = defaults(p.openEnded, false)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.localAngle = defaults(p.localAngle, 30)\n this.centerDist = defaults(p.centerDist, 2.5)\n this.ssBorder = defaults(p.ssBorder, false)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n let length = 0\n const axisList:Axis[] = []\n const helixbundleList:Helixbundle[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4 || polymer.isNucleic()) return\n\n const helixbundle = new Helixbundle(polymer)\n const axis = helixbundle.getAxis(\n this.localAngle, this.centerDist, this.ssBorder,\n this.getColorParams(), this.getRadiusParams()\n )\n\n length += axis.size.length\n axisList.push(axis)\n helixbundleList.push(helixbundle)\n }, sview.getSelection())\n\n const axisData = {\n begin: new Float32Array(length * 3),\n end: new Float32Array(length * 3),\n size: new Float32Array(length),\n color: new Float32Array(length * 3),\n picking: {}\n }\n\n let picking = new Float32Array(length)\n\n let offset = 0\n\n axisList.forEach(function (axis) {\n axisData.begin.set(axis.begin, offset * 3)\n axisData.end.set(axis.end, offset * 3)\n axisData.size.set(axis.size, offset)\n axisData.color.set(axis.color, offset * 3)\n picking.set(axis.picking.array!, offset)\n offset += axis.size.length\n })\n\n if (length) {\n axisData.picking = new AtomPicker(\n picking, sview.getStructure()\n )\n }\n\n const cylinderBuffer = new CylinderBuffer(\n {\n position1: axisData.begin,\n position2: axisData.end,\n color: axisData.color,\n color2: axisData.color,\n radius: axisData.size,\n picking: axisData.picking\n },\n this.getBufferParams({\n openEnded: this.openEnded,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n return {\n bufferList: [ cylinderBuffer as CylinderGeometryBuffer|CylinderImpostorBuffer ],\n axisList: axisList,\n helixbundleList: helixbundleList,\n axisData: axisData\n }\n }\n\n \n updateData (what: any, data: {bufferList: CylinderBuffer[], helixbundleList: Helixbundle[], axisList: Axis[], axisData: AxisData}) {\n what = what || {}\n\n if (what.position) {\n this.build()\n return\n }\n\n var cylinderData = {}\n\n if (what.color || what.radius) {\n var offset = 0\n\n data.helixbundleList.forEach((helixbundle) => {\n var axis = helixbundle.getAxis(\n this.localAngle, this.centerDist, this.ssBorder,\n this.getColorParams(), this.getRadiusParams()\n )\n if (what.color) {\n data.axisData.color.set(axis.color, offset * 3)\n }\n if (what.radius || what.scale) {\n data.axisData.size.set(axis.size, offset)\n }\n offset += axis.size.length\n })\n\n if (what.color) {\n Object.assign(cylinderData, {\n color: data.axisData.color,\n color2: data.axisData.color\n })\n }\n\n if (what.radius || what.scale) {\n Object.assign(cylinderData, {\n radius: data.axisData.size\n })\n }\n }\n\n (data.bufferList[ 0 ] as CylinderGeometryBuffer).setAttributes(cylinderData)\n }\n}\n\nRepresentationRegistry.add('rocket', RocketRepresentation)\n\nexport default RocketRepresentation\n","/**\n * @file Rope Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport CartoonRepresentation, { CartoonRepresentationParameters } from './cartoon-representation'\nimport Helixorient from '../geometry/helixorient'\nimport Spline from '../geometry/spline'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport Polymer from '../proxy/polymer';\n\n/**\n * Rope Representation\n */\nclass RopeRepresentation extends CartoonRepresentation {\n protected smooth: number\n \n constructor (structure: Structure, viewer: Viewer, params: Partial&{smooth: number}) {\n super(structure, viewer, params)\n\n this.type = 'rope'\n\n this.parameters = Object.assign({\n\n smooth: {\n type: 'integer', max: 15, min: 0, rebuild: true\n }\n\n }, this.parameters, {\n aspectRatio: null,\n smoothSheet: null\n })\n }\n\n init (params: Partial) {\n var p = params || {}\n p.aspectRatio = 1.0\n p.tension = defaults(p.tension, 0.5)\n p.radiusScale = defaults(p.radiusScale, 5.0)\n p.smoothSheet = false\n\n this.smooth = defaults(p.smooth, 2)\n\n super.init(p)\n }\n\n getSpline (polymer: Polymer) {\n var helixorient = new Helixorient(polymer)\n\n return new Spline(polymer, this.getSplineParams({\n directional: false,\n positionIterator: helixorient.getCenterIterator(this.smooth)\n }))\n }\n}\n\nRepresentationRegistry.add('rope', RopeRepresentation)\n\nexport default RopeRepresentation\n","/**\n * @file Spacefill Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { RepresentationRegistry } from '../globals'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\nimport { AtomDataFields } from '../structure/structure-data';\nimport SphereImpostorBuffer from '../buffer/sphereimpostor-buffer';\n\n/**\n * Spacefill Representation\n */\nclass SpacefillRepresentation extends StructureRepresentation {\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'spacefill'\n\n this.parameters = Object.assign({\n sphereDetail: true,\n disableImpostor: true\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n var sphereBuffer = new SphereBuffer(\n (sview.getAtomData(this.getAtomParams()) as SphereBufferData),\n (this.getBufferParams({\n sphereDetail: this.sphereDetail,\n dullInterior: true,\n disableImpostor: this.disableImpostor\n }) as SphereBufferParameters)\n )\n\n return {\n bufferList: [ sphereBuffer as SphereGeometryBuffer|SphereImpostorBuffer ]\n }\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n var atomData = data.sview!.getAtomData(this.getAtomParams(what))\n var sphereData: Partial = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {position: atomData.position})\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {color: atomData.color})\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {radius: atomData.radius})\n }\n\n data.bufferList[ 0 ].setAttributes(sphereData)\n }\n}\n\nRepresentationRegistry.add('spacefill', SpacefillRepresentation)\n\nexport default SpacefillRepresentation\n","/**\n * @file Trace Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport '../shader/Line.vert'\nimport '../shader/Line.frag'\n\nimport { Log } from '../globals'\nimport Buffer, { BufferParameters, BufferData } from './buffer'\n\nfunction getSize(data: BufferData){\n const n = data.position!.length / 3\n const n1 = n - 1\n return n1 * 3 * 2\n}\n\n/**\n * Trace buffer. Draws a series of lines.\n */\nclass TraceBuffer extends Buffer {\n isLine = true\n vertexShader = 'Line.vert'\n fragmentShader = 'Line.frag'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: BufferData, params: Partial = {}) {\n super({\n position: new Float32Array(getSize(data)),\n color: new Float32Array(getSize(data))\n }, params)\n\n this.setAttributes(data)\n }\n\n setAttributes (data: Partial) {\n let position, color\n let linePosition, lineColor\n\n const attributes = this.geometry.attributes as any // TODO\n\n if (data.position) {\n position = data.position\n linePosition = attributes.position.array\n attributes.position.needsUpdate = true\n }\n\n if (data.color) {\n color = data.color\n lineColor = attributes.color.array\n attributes.color.needsUpdate = true\n }\n\n if (!position && !color) {\n Log.warn('TraceBuffer.prototype.setAttributes no data')\n return\n }\n\n let v, v2\n const n = this.size\n const n1 = n - 1\n\n for (let i = 0; i < n1; ++i) {\n v = 3 * i\n v2 = 3 * i * 2\n\n if (position) {\n linePosition[ v2 ] = position[ v ]\n linePosition[ v2 + 1 ] = position[ v + 1 ]\n linePosition[ v2 + 2 ] = position[ v + 2 ]\n\n linePosition[ v2 + 3 ] = position[ v + 3 ]\n linePosition[ v2 + 4 ] = position[ v + 4 ]\n linePosition[ v2 + 5 ] = position[ v + 5 ]\n }\n\n if (color) {\n lineColor[ v2 ] = color[ v ]\n lineColor[ v2 + 1 ] = color[ v + 1 ]\n lineColor[ v2 + 2 ] = color[ v + 2 ]\n\n lineColor[ v2 + 3 ] = color[ v + 3 ]\n lineColor[ v2 + 4 ] = color[ v + 4 ]\n lineColor[ v2 + 5 ] = color[ v + 5 ]\n }\n }\n }\n}\n\nexport default TraceBuffer\n","/**\n * @file Trace Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Spline from '../geometry/spline'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport TraceBuffer from '../buffer/trace-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport StructureView from '../structure/structure-view';\nimport Polymer from '../proxy/polymer';\n\nexport interface TraceRepresentationParameters extends StructureRepresentationParameters {\n subdiv: number\n tension: number\n smoothSheet: boolean\n}\n/**\n * Trace Representation\n */\nclass TraceRepresentation extends StructureRepresentation {\n protected subdiv: number\n protected tension: number\n protected smoothSheet: boolean\n \n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'trace'\n\n this.parameters = Object.assign({\n\n subdiv: {\n type: 'integer', max: 50, min: 1, rebuild: true\n },\n tension: {\n type: 'number', precision: 1, max: 1.0, min: 0.1\n },\n smoothSheet: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n\n flatShaded: null,\n side: null,\n wireframe: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'chainname')\n p.colorScale = defaults(p.colorScale, 'RdYlBu')\n\n if (p.quality === 'low') {\n this.subdiv = 3\n } else if (p.quality === 'medium') {\n this.subdiv = 6\n } else if (p.quality === 'high') {\n this.subdiv = 12\n } else {\n this.subdiv = defaults(p.subdiv, 6)\n }\n\n this.tension = defaults(p.tension, NaN)\n this.smoothSheet = defaults(p.smoothSheet, false)\n\n super.init(p)\n }\n\n getSplineParams (params?: {[k:string]: any}) {\n return Object.assign({\n subdiv: this.subdiv,\n tension: this.tension,\n directional: false,\n smoothSheet: this.smoothSheet\n }, params)\n }\n\n getAtomRadius (atom: AtomProxy) {\n return atom.isTrace() ? 0.1 : 0\n }\n\n createData (sview: StructureView) {\n var bufferList: TraceBuffer[] = []\n var polymerList: Polymer[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4) return\n polymerList.push(polymer)\n\n var spline = new Spline(polymer, this.getSplineParams())\n var subPos = spline.getSubdividedPosition()\n var subCol = spline.getSubdividedColor(this.getColorParams())\n\n bufferList.push(\n new TraceBuffer(\n Object.assign({}, subPos, subCol),\n this.getBufferParams()\n )\n )\n }, sview.getSelection())\n\n return {\n bufferList: bufferList,\n polymerList: polymerList\n }\n }\n\n updateData (what: any, data: StructureRepresentationData) {\n what = what || {}\n\n var i = 0\n var n = data.polymerList!.length\n\n for (i = 0; i < n; ++i) {\n var bufferData = {}\n var spline = new Spline(data.polymerList![ i ], this.getSplineParams())\n\n if (what.position) {\n var subPos = spline.getSubdividedPosition()\n Object.assign(bufferData, { position: subPos.position })\n }\n\n if (what.color) {\n var subCol = spline.getSubdividedColor(this.getColorParams())\n Object.assign(bufferData, { color: subCol.color })\n }\n\n data.bufferList[ i ].setAttributes(bufferData)\n }\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n if (params && params.tension) {\n Object.assign(what, {position: true})\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('trace', TraceRepresentation)\n\nexport default TraceRepresentation\n","/**\n * @file Tube Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport CartoonRepresentation, {CartoonRepresentationParameters} from './cartoon-representation'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\n\n/**\n * Tube Representation\n */\nclass TubeRepresentation extends CartoonRepresentation {\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'tube'\n\n this.parameters = Object.assign(\n {}, this.parameters, { aspectRatio: null }\n )\n }\n\n init (params: Partial) {\n var p = params || {}\n p.aspectRatio = 1.0\n p.radiusScale = defaults(p.radiusScale, 2.0)\n\n if (p.quality === 'low') {\n this.radialSegments = 5\n }\n\n super.init(p)\n }\n\n getSplineParams (/* params */) {\n return super.getSplineParams({\n directional: false\n })\n }\n}\n\nRepresentationRegistry.add('tube', TubeRepresentation)\n\nexport default TubeRepresentation\n","/**\n * @file Unitcell Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport CylinderBuffer, { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport { AtomDataFields } from '../structure/structure-data';\nimport StructureView from '../structure/structure-view';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\n// @ts-ignore: unused import UnitcellPicker required for declaration only\nimport { UnitcellPicker } from '../utils/picker';\n\nexport interface UnitcellRepresentationParameters extends StructureRepresentationParameters {\n radiusSize: number\n sphereDetail: number\n radialSegments: number\n disableImpostor: boolean\n}\n\n/**\n * Unitcell Representation\n */\nclass UnitcellRepresentation extends StructureRepresentation {\n sphereBuffer: SphereBuffer\n cylinderBuffer: CylinderBuffer\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'unitcell'\n\n this.parameters = Object.assign({\n\n radiusSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n sphereDetail: true,\n radialSegments: true,\n disableImpostor: true\n\n }, this.parameters, {\n assembly: null\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n\n let defaultRadius = 0.5\n if (this.structure.unitcell) {\n defaultRadius = Math.cbrt(this.structure.unitcell.volume) / 200\n }\n\n p.radiusSize = defaults(p.radiusSize, defaultRadius)\n p.colorValue = defaults(p.colorValue, 'orange')\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n super.init(p)\n }\n\n getUnitcellData (structure: Structure) {\n return structure.unitcell!.getData(structure)\n }\n\n create () {\n const structure = this.structureView.getStructure()\n if (!structure.unitcell) return\n const unitcellData = this.getUnitcellData(structure)\n\n this.sphereBuffer = new SphereBuffer(\n unitcellData.vertex as SphereBufferData,\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters\n )\n\n this.cylinderBuffer = new CylinderBuffer(\n unitcellData.edge as CylinderBufferData,\n this.getBufferParams({\n openEnded: true,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n this.dataList.push({\n sview: this.structureView,\n bufferList: [ this.sphereBuffer as SphereGeometryBuffer, this.cylinderBuffer as CylinderGeometryBuffer ]\n })\n }\n\n createData (sview: StructureView): undefined {\n return\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n const structure = data.sview!.getStructure()\n if (!structure.unitcell) return\n const unitcellData = this.getUnitcellData(structure)\n const sphereData: Partial = {}\n const cylinderData: Partial = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {position: unitcellData.vertex.position})\n Object.assign(cylinderData, {\n position1: unitcellData.edge.position1,\n position2: unitcellData.edge.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {color: unitcellData.vertex.color})\n Object.assign(cylinderData, {\n color: unitcellData.edge.color,\n color2: unitcellData.edge.color2\n })\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {radius: unitcellData.vertex.radius})\n Object.assign(cylinderData, {radius: unitcellData.edge.radius})\n }\n\n (this.sphereBuffer as SphereGeometryBuffer).setAttributes(sphereData);\n (this.cylinderBuffer as CylinderGeometryBuffer).setAttributes(cylinderData)\n }\n}\n\nRepresentationRegistry.add('unitcell', UnitcellRepresentation)\n\nexport default UnitcellRepresentation\n","/**\n * @file Validation Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport CylinderBuffer from '../buffer/cylinder-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport CylinderImpostorBuffer from '../buffer/cylinderimpostor-buffer';\n\n/**\n * Validation representation\n */\nclass ValidationRepresentation extends StructureRepresentation {\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'validation'\n\n this.parameters = Object.assign({\n\n }, this.parameters, {\n radiusType: null,\n radiusSize: null,\n radiusScale: null\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorValue = defaults(p.colorValue, '#f0027f')\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n if (!sview.validation) return\n\n const clashData = sview.validation.getClashData({\n structure: sview,\n color: this.colorValue\n })\n\n const cylinderBuffer = new CylinderBuffer(\n clashData, this.getBufferParams({ openEnded: false })\n )\n\n return {\n bufferList: [ cylinderBuffer as CylinderGeometryBuffer|CylinderImpostorBuffer ]\n }\n }\n}\n\nRepresentationRegistry.add('validation', ValidationRepresentation)\n\nexport default ValidationRepresentation\n","/**\n * @file Cone Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3, ConeBufferGeometry } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { calculateCenterArray } from '../math/array-utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferDefaultParameters } from './buffer'\n\nconst scale = new Vector3()\nconst eye = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3(0, 1, 0)\n\nfunction getGeo (params: Partial = {}) {\n const geo = new ConeBufferGeometry(\n 1, // radius\n 1, // height\n defaults(params.radialSegments, 60), // radialSegments\n 1, // heightSegments\n defaults(params.openEnded, false) // openEnded\n )\n geo.applyMatrix4(new Matrix4().makeRotationX(-Math.PI / 2))\n\n return geo\n}\n\nexport interface ConeBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n radius: Float32Array\n}\n\nexport const ConeBufferDefaultParameters = Object.assign({\n radialSegments: 60,\n openEnded: false\n}, BufferDefaultParameters)\nexport type ConeBufferParameters = typeof ConeBufferDefaultParameters\n\n\n/**\n * Cone geometry buffer.\n *\n * @example\n * var coneBuffer = new ConeBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass ConeBuffer extends GeometryBuffer {\n updateNormals = true\n\n get defaultParameters() { return ConeBufferDefaultParameters }\n parameters: ConeBufferParameters\n\n _position: Float32Array\n _position1: Float32Array\n _position2: Float32Array\n _radius: Float32Array\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n */\n constructor (data: ConeBufferData, params: Partial = {}) {\n super({\n position: new Float32Array(data.position1.length),\n color: data.color,\n picking: data.picking\n }, params, getGeo(params))\n\n this._position = new Float32Array(data.position1.length)\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n eye.fromArray(this._position1 as any, i3)\n target.fromArray(this._position2 as any, i3)\n matrix.lookAt(eye, target, up)\n\n const r = this._radius[ i ]\n scale.set(r, r, eye.distanceTo(target))\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.position1 && data.position2) {\n calculateCenterArray(data.position1, data.position2, this._position)\n this._position1 = data.position1\n this._position2 = data.position2\n data.position = this._position\n }\n if (data.radius) this._radius = data.radius\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('cone', ConeBuffer)\n\nexport default ConeBuffer\n","/**\n * @file Geometry Group\n * @author Alexander Rose \n * @private\n */\n\nimport { Box3, BufferGeometry } from 'three'\n\nclass GeometryGroup {\n geometryList: BufferGeometry[]\n boundingBox: Box3\n\n constructor (geometryList: BufferGeometry[] = []) {\n this.geometryList = geometryList\n }\n\n computeBoundingBox () {\n if (!this.boundingBox) {\n this.boundingBox = new Box3()\n } else {\n this.boundingBox.empty()\n }\n\n this.geometryList.forEach(geo => {\n if (!geo.boundingBox) geo.computeBoundingBox()\n this.boundingBox.union(geo.boundingBox as Box3)\n })\n }\n}\n\nexport default GeometryGroup\n","/**\n * @file Arrow Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3, Group } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport { createParams, defaults } from '../utils'\nimport { Picker } from '../utils/picker'\nimport Buffer from './buffer'\nimport CylinderBuffer, { CylinderBufferData } from './cylinder-buffer'\nimport CylinderGeometryBuffer from './cylindergeometry-buffer'\nimport ConeBuffer, { ConeBufferData } from './cone-buffer'\nimport GeometryGroup from '../viewer/geometry-group'\nimport { BufferData, BufferDefaultParameters } from './buffer'\n\nexport interface ArrowBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n radius: Float32Array\n}\n\nexport const ArrowBufferDefaultParameters = Object.assign({\n aspectRatio: 1.5,\n radialSegments: 50,\n openEnded: false,\n disableImpostor: false\n}, BufferDefaultParameters)\nexport type ArrowBufferParameters = typeof ArrowBufferDefaultParameters\n\n/**\n * Arrow buffer. Draws arrows made from a cylinder and a cone.\n * @implements {Buffer}\n *\n * @example\n * var arrowBuffer = new ArrowBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 10, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass ArrowBuffer {\n parameters: ArrowBufferParameters\n get defaultParameters() { return ArrowBufferDefaultParameters }\n\n cylinderBuffer: CylinderGeometryBuffer\n coneBuffer: ConeBuffer\n\n splitPosition: Float32Array\n cylinderRadius: Float32Array\n\n geometry: GeometryGroup\n picking?: Picker\n\n group = new Group()\n wireframeGroup = new Group()\n pickingGroup = new Group()\n\n visible = true\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n */\n constructor (data: ArrowBufferData, params: Partial = {}) {\n this.parameters = createParams(params, this.defaultParameters)\n\n this.splitPosition = new Float32Array(data.position1.length)\n this.cylinderRadius = new Float32Array(data.radius.length)\n\n const attr = this.makeAttributes(data)\n const bufferParams = {\n radialSegments: this.parameters.radialSegments,\n openEnded: this.parameters.openEnded,\n disableImpostor: this.parameters.disableImpostor\n }\n\n this.cylinderBuffer = new CylinderBuffer(\n attr.cylinder as CylinderBufferData, bufferParams\n ) as CylinderGeometryBuffer\n this.coneBuffer = new ConeBuffer(\n attr.cone as ConeBufferData, bufferParams\n )\n\n this.geometry = new GeometryGroup([\n this.cylinderBuffer.geometry,\n this.coneBuffer.geometry\n ])\n\n // requires Group objects to be present\n this.matrix = defaults(params.matrix, new Matrix4())\n\n this.picking = data.picking\n }\n\n set matrix (m) {\n Buffer.prototype.setMatrix.call(this, m)\n }\n get matrix () {\n return this.group.matrix.clone()\n }\n\n get pickable () {\n return !!this.picking\n }\n\n makeAttributes (data: Partial = {}) {\n const splitPosition = this.splitPosition\n const cylinderRadius = this.cylinderRadius\n\n const aspectRatio = this.parameters.aspectRatio\n\n let i, il\n const cylinder: Partial = {}\n const cone: Partial = {}\n\n if (data.radius) {\n for (i = 0, il = cylinderRadius.length; i < il; ++i) {\n cylinderRadius[ i ] = data.radius[ i ] / aspectRatio\n }\n cylinder.radius = cylinderRadius\n cone.radius = data.radius\n }\n\n if (data.position1 && data.position2) {\n const vFrom = new Vector3()\n const vTo = new Vector3()\n const vDir = new Vector3()\n const vSplit = new Vector3()\n for (i = 0, il = splitPosition.length; i < il; i += 3) {\n vFrom.fromArray(data.position1 as any, i)\n vTo.fromArray(data.position2 as any, i)\n vDir.subVectors(vFrom, vTo)\n const fullLength = vDir.length()\n const coneLength = cylinderRadius[ i / 3 ] * aspectRatio * 2\n const length = Math.min(fullLength, coneLength)\n vDir.setLength(length)\n vSplit.copy(vTo).add(vDir)\n vSplit.toArray(splitPosition as any, i)\n }\n cylinder.position1 = data.position1\n cylinder.position2 = splitPosition\n cone.position1 = splitPosition\n cone.position2 = data.position2\n }\n\n if (data.color) {\n cylinder.color = data.color\n cylinder.color2 = data.color\n cone.color = data.color\n }\n\n return {\n cylinder: cylinder,\n cone: cone\n }\n }\n\n getMesh () {\n return new Group().add(\n this.cylinderBuffer.getMesh(),\n this.coneBuffer.getMesh()\n )\n }\n\n getWireframeMesh () {\n return new Group().add(\n this.cylinderBuffer.getWireframeMesh(),\n this.coneBuffer.getWireframeMesh()\n )\n }\n\n getPickingMesh () {\n return new Group().add(\n this.cylinderBuffer.getPickingMesh(),\n this.coneBuffer.getPickingMesh()\n )\n }\n\n setAttributes (data: Partial = {}) {\n const attr = this.makeAttributes(data)\n\n this.cylinderBuffer.setAttributes(attr.cylinder)\n this.coneBuffer.setAttributes(attr.cone)\n }\n\n /**\n * Set buffer parameters\n * @param {BufferParameters} params - buffer parameters object\n * @return {undefined}\n */\n setParameters (params: Partial = {}) {\n params = Object.assign({}, params)\n\n if (params && params.matrix !== undefined) {\n this.matrix = params.matrix\n }\n delete params.matrix\n\n if (params && params.wireframe !== undefined) {\n this.parameters.wireframe = params.wireframe\n this.setVisibility(this.visible)\n }\n\n this.cylinderBuffer.setParameters(params)\n this.coneBuffer.setParameters(params)\n }\n\n setVisibility (value: boolean) {\n Buffer.prototype.setVisibility.call(this, value)\n }\n\n dispose () {\n this.cylinderBuffer.dispose()\n this.coneBuffer.dispose()\n }\n}\n\nBufferRegistry.add('arrow', ArrowBuffer)\n\nexport default ArrowBuffer\n","/**\n * @file Box Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { BoxBufferGeometry, Vector3, Matrix4 } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface BoxBufferData extends BufferData {\n heightAxis: Float32Array\n depthAxis: Float32Array\n size: Float32Array\n}\n\n/**\n * Box buffer. Draws boxes.\n *\n * @example\n * var boxBuffer = new BoxBuffer({\n * position: new Float32Array([ 0, 3, 0, -2, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 1, 0, 1, 0 ]),\n * size: new Float32Array([ 2, 1.5 ]),\n * heightAxis: new Float32Array([ 0, 1, 1, 0, 2, 0 ]),\n * depthAxis: new Float32Array([ 1, 0, 1, 0, 0, 2 ])\n * })\n */\nclass BoxBuffer extends GeometryBuffer {\n updateNormals = true\n\n _heightAxis: Float32Array\n _depthAxis: Float32Array\n _size: Float32Array\n\n constructor (data: BoxBufferData, params: Partial = {}) {\n super(data, params, new BoxBufferGeometry(1, 1, 1))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._heightAxis as any, i3)\n up.fromArray(this._depthAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n scale.set(this._size[ i ], up.length(), target.length())\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.size) this._size = data.size\n if (data.heightAxis) this._heightAxis = data.heightAxis\n if (data.depthAxis) this._depthAxis = data.depthAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('box', BoxBuffer)\n\nexport default BoxBuffer\n","/**\n * @file Ellipsoid Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { IcosahedronBufferGeometry, Vector3, Matrix4 } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferDefaultParameters } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface EllipsoidBufferData extends BufferData {\n majorAxis: Float32Array\n minorAxis: Float32Array\n radius: Float32Array\n}\n\nexport const EllipsoidBufferDefaultParameters = Object.assign({\n sphereDetail: 2,\n}, BufferDefaultParameters)\nexport type EllipsoidBufferParameters = typeof EllipsoidBufferDefaultParameters\n\n/**\n * Ellipsoid buffer. Draws ellipsoids.\n *\n * @example\n * var ellipsoidBuffer = new EllipsoidBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ]),\n * majorAxis: new Float32Array([ 1, 1, 0 ]),\n * minorAxis: new Float32Array([ 0.5, 0, 0.5 ]),\n * });\n */\nclass EllipsoidBuffer extends GeometryBuffer {\n updateNormals = true\n\n get defaultParameters() { return EllipsoidBufferDefaultParameters }\n parameters: EllipsoidBufferParameters\n\n _majorAxis: Float32Array\n _minorAxis: Float32Array\n _radius: Float32Array\n\n constructor (data: EllipsoidBufferData, params: Partial = {}) {\n super(data, params, new IcosahedronBufferGeometry(1, defaults(params.sphereDetail, 2)))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._majorAxis as any, i3)\n up.fromArray(this._minorAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n scale.set(this._radius[ i ], up.length(), target.length())\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.radius) this._radius = data.radius\n if (data.majorAxis) this._majorAxis = data.majorAxis\n if (data.minorAxis) this._minorAxis = data.minorAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('ellipsoid', EllipsoidBuffer)\n\nexport default EllipsoidBuffer\n","/**\n * @file Octahedron Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { OctahedronBufferGeometry, Vector3, Matrix4 } from 'three'\nimport { BufferRegistry } from '../globals'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface OctahedronBufferData extends BufferData {\n heightAxis: Float32Array\n depthAxis: Float32Array\n size: Float32Array\n}\n\n/**\n * Octahedron buffer. Draws octahedrons.\n *\n * @example\n * var octahedronBuffer = new OctahedronBuffer({\n * position: new Float32Array([ 0, 3, 0, -2, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 1, 0, 1, 0 ]),\n * size: new Float32Array([ 2, 1.5 ]),\n * heightAxis: new Float32Array([ 0, 1, 1, 0, 2, 0 ]),\n * depthAxis: new Float32Array([ 1, 0, 1, 0, 0, 2 ])\n * })\n */\nclass OctahedronBuffer extends GeometryBuffer {\n updateNormals = true\n\n _heightAxis: Float32Array\n _depthAxis: Float32Array\n _size: Float32Array\n\n constructor (data: OctahedronBufferData, params: Partial = {}) {\n super(data, params, new OctahedronBufferGeometry(1, 0))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._heightAxis as any, i3)\n up.fromArray(this._depthAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n scale.set(this._size[ i ], up.length(), target.length())\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.size) this._size = data.size\n if (data.heightAxis) this._heightAxis = data.heightAxis\n if (data.depthAxis) this._depthAxis = data.depthAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('octahedron', OctahedronBuffer)\n\nexport default OctahedronBuffer\n","/**\n * @file Tetrahedron Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { TetrahedronBufferGeometry, Vector3, Matrix4 } from 'three'\nimport { BufferRegistry } from '../globals'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface TetrahedronBufferData extends BufferData {\n heightAxis: Float32Array\n depthAxis: Float32Array\n size: Float32Array\n}\n\n/**\n * Tetrahedron buffer. Draws tetrahedrons.\n *\n * @example\n * var tetrahedronBuffer = new TetrahedronBuffer({\n * position: new Float32Array([ 0, 3, 0, -2, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 1, 0, 1, 0 ]),\n * size: new Float32Array([ 2, 1.5 ]),\n * heightAxis: new Float32Array([ 0, 1, 1, 0, 2, 0 ]),\n * depthAxis: new Float32Array([ 1, 0, 1, 0, 0, 2 ])\n * })\n */\nclass TetrahedronBuffer extends GeometryBuffer {\n updateNormals = true\n\n _heightAxis: Float32Array\n _depthAxis: Float32Array\n _size: Float32Array\n\n constructor (data: TetrahedronBufferData, params: Partial = {}) {\n super(data, params, new TetrahedronBufferGeometry(1, 0))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._heightAxis as any, i3)\n up.fromArray(this._depthAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n scale.set(this._size[ i ], up.length(), target.length())\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.size) this._size = data.size\n if (data.heightAxis) this._heightAxis = data.heightAxis\n if (data.depthAxis) this._depthAxis = data.depthAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('tetrahedron', TetrahedronBuffer)\n\nexport default TetrahedronBuffer\n","/**\n * @file Tetrahedron Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { TorusBufferGeometry, Vector3, Matrix4 } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferDefaultParameters, BufferData } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface TorusBufferData extends BufferData {\n majorAxis: Float32Array\n minorAxis: Float32Array\n radius: Float32Array\n}\n\nexport const TorusBufferDefaultParameters = Object.assign({\n radiusRatio: 0.2,\n radialSegments: 16,\n tubularSegments: 32\n}, BufferDefaultParameters)\nexport type TorusBufferParameters = typeof TorusBufferDefaultParameters\n\n/**\n * Torus geometry buffer. Draws torii.\n *\n * @example\n * var torusBuffer = new TorusBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ]),\n * majorAxis: new Float32Array([ 1, 1, 0 ]),\n * minorAxis: new Float32Array([ 0.5, 0, 0.5 ]),\n * });\n */\nclass TorusBuffer extends GeometryBuffer {\n updateNormals = true\n\n get defaultParameters() { return TorusBufferDefaultParameters }\n parameters: TorusBufferParameters\n\n _majorAxis: Float32Array\n _minorAxis: Float32Array\n _radius: Float32Array\n\n constructor (data: TorusBufferData, params: Partial = {}) {\n super(data, params, new TorusBufferGeometry(\n 1,\n defaults(params.radiusRatio, 0.2),\n defaults(params.radialSegments, 16),\n defaults(params.tubularSegments, 32)\n ))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._majorAxis as any, i3)\n up.fromArray(this._minorAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n const r = this._radius[ i ]\n scale.set(r, r, r)\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.radius) this._radius = data.radius\n if (data.majorAxis) this._majorAxis = data.majorAxis\n if (data.minorAxis) this._minorAxis = data.minorAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('torus', TorusBuffer)\n\nexport default TorusBuffer\n","/**\n * @file Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log } from '../globals'\nimport { defaults } from '../utils'\nimport Streamer from '../streamer/streamer';\n\nexport interface ParserParameters {\n name: string\n path: string\n}\n\nclass Parser {\n streamer: Streamer\n name: string\n path: string\n [k: string]: any\n \n constructor (streamer: Streamer, params?: Partial) {\n var p = params || {}\n\n this.streamer = streamer\n\n this.name = defaults(p.name, '')\n this.path = defaults(p.path, '')\n }\n\n get type () { return '' }\n get __objName () { return '' }\n get isBinary () { return false }\n get isJson () { return false }\n get isXml () { return false }\n\n parse () {\n return this.streamer.read().then(() => {\n this._beforeParse()\n this._parse()\n this._afterParse()\n return this[ this.__objName ]\n })\n }\n\n _parse () {}\n\n _beforeParse () {}\n\n _afterParse () {\n if (Debug) Log.log(this[ this.__objName ])\n }\n}\n\nexport default Parser\n","/**\n * @file Structure Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport Parser, { ParserParameters } from './parser'\nimport Structure from '../structure/structure'\nimport StructureBuilder from '../structure/structure-builder'\nimport Streamer from '../streamer/streamer';\n\nexport interface StructureParserParameters extends ParserParameters {\n firstModelOnly: boolean\n asTrajectory: boolean\n cAlphaOnly: boolean\n}\nclass StructureParser extends Parser {\n\n structureBuilder: StructureBuilder\n\n constructor (streamer: Streamer, params?: Partial) {\n var p = params || {}\n\n super(streamer, p)\n\n this.firstModelOnly = defaults(p.firstModelOnly, false)\n this.asTrajectory = defaults(p.asTrajectory, false)\n this.cAlphaOnly = defaults(p.cAlphaOnly, false)\n\n this.structure = new Structure(this.name, this.path)\n this.structureBuilder = new StructureBuilder(this.structure)\n }\n\n get type () { return 'structure' }\n get __objName () { return 'structure' }\n}\n\nexport default StructureParser\n","/**\n * @file Entity\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from './structure'\nimport {\n UnknownEntity, PolymerEntity, NonPolymerEntity, MacrolideEntity, WaterEntity\n} from './structure-constants'\nimport ChainProxy from '../proxy/chain-proxy'\n\nfunction entityTypeFromString (string: string) {\n string = string.toLowerCase()\n switch (string) {\n case 'polymer':\n return PolymerEntity\n case 'non-polymer':\n return NonPolymerEntity\n case 'macrolide':\n return MacrolideEntity\n case 'water':\n return WaterEntity\n default:\n return UnknownEntity\n }\n}\n\nfunction entityFromType (type: number) {\n switch (type) {\n case PolymerEntity:\n return 'polymer'\n case NonPolymerEntity:\n return 'non-polymer'\n case MacrolideEntity:\n return 'macrolide'\n case WaterEntity:\n return 'water'\n default:\n return undefined\n }\n}\n\nexport const EntityTypeString = {\n 'polymer': PolymerEntity,\n 'non-polymer': NonPolymerEntity,\n 'macrolide': MacrolideEntity,\n 'water': WaterEntity,\n}\nexport type EntityTypeString = keyof typeof EntityTypeString\n\n/**\n * Entity of a {@link Structure}\n */\nexport default class Entity {\n structure: Structure\n index: number\n description: string\n entityType: number\n chainIndexList: number[]\n\n /**\n * @param {Structure} structure - structure the entity belongs to\n * @param {Integer} index - index within structure.entityList\n * @param {String} description - entity description\n * @param {String} type - entity type\n * @param {Array} chainIndexList - entity chainIndexList\n */\n constructor (structure: Structure, index: number, description = '', type?: EntityTypeString, chainIndexList: number[] = []) {\n this.structure = structure\n this.index = index\n this.description = description\n this.entityType = entityTypeFromString(type || '')\n this.chainIndexList = chainIndexList\n\n chainIndexList.forEach(function (ci: number) {\n structure.chainStore.entityIndex[ ci ] = index\n })\n }\n\n get type () { return entityFromType(this.entityType) }\n\n getEntityType () {\n return this.entityType\n }\n\n isPolymer () {\n return this.entityType === PolymerEntity\n }\n\n isNonPolymer () {\n return this.entityType === NonPolymerEntity\n }\n\n isMacrolide () {\n return this.entityType === MacrolideEntity\n }\n\n isWater () {\n return this.entityType === WaterEntity\n }\n\n eachChain (callback: (cp: ChainProxy) => any) {\n const cp = this.structure.getChainProxy()\n\n this.chainIndexList.forEach(function (index) {\n cp.index = index\n callback(cp)\n })\n }\n}","/**\n * @file Unitcell\n * @author Alexander Rose \n * @private\n */\n\nimport { Color, Vector3, Matrix4 } from 'three'\n\nimport { defaults } from '../utils'\nimport { degToRad } from '../math/math-utils'\nimport {\n uniformArray, uniformArray3, centerArray3\n} from '../math/array-utils'\nimport { UnitcellPicker } from '../utils/picker'\nimport Structure from '../structure/structure'\n\nexport interface UnitcellParams {\n a: number\n b: number\n c: number\n alpha: number\n beta: number\n gamma: number\n spacegroup: string\n cartToFrac?: Matrix4\n}\n\nconst DefaultBoxParams = {\n a: 1,\n b: 1,\n c: 1,\n alpha: 90,\n beta: 90,\n gamma: 90,\n spacegroup: 'P 1'\n}\n\nexport interface UnitcellDataParams {\n colorValue?: string|number,\n radius?: number\n}\n\n/**\n * Unitcell class\n */\nclass Unitcell {\n a: number\n b: number\n c: number\n alpha: number\n beta: number\n gamma: number\n\n spacegroup: string\n\n cartToFrac = new Matrix4()\n fracToCart = new Matrix4()\n\n volume: number\n\n /**\n * @param {Object} params - unitcell parameters\n * @param {Number} params.a - length a\n * @param {Number} params.b - length b\n * @param {Number} params.c - length c\n * @param {Number} params.alpha - angle alpha\n * @param {Number} params.beta - angle beta\n * @param {Number} params.gamma - angle gamma\n * @param {String} params.spacegroup - spacegroup\n * @param {Matrix4} [params.cartToFrac] - transformation matrix from\n * cartesian to fractional coordinates\n * @param {Matrix4} [params.scale] - alias for `params.cartToFrac`\n */\n constructor (params: UnitcellParams = DefaultBoxParams) {\n this.a = params.a\n this.b = params.b\n this.c = params.c\n this.alpha = params.alpha\n this.beta = params.beta\n this.gamma = params.gamma\n this.spacegroup = params.spacegroup\n\n const alphaRad = degToRad(this.alpha)\n const betaRad = degToRad(this.beta)\n const gammaRad = degToRad(this.gamma)\n const cosAlpha = Math.cos(alphaRad)\n const cosBeta = Math.cos(betaRad)\n const cosGamma = Math.cos(gammaRad)\n const sinBeta = Math.sin(betaRad)\n const sinGamma = Math.sin(gammaRad)\n\n this.volume = (\n this.a * this.b * this.c *\n Math.sqrt(\n 1 - cosAlpha * cosAlpha - cosBeta * cosBeta - cosGamma * cosGamma +\n 2.0 * cosAlpha * cosBeta * cosGamma\n )\n )\n\n if (params.cartToFrac === undefined) {\n // https://github.com/biojava/biojava/blob/master/biojava-structure/src/main/java/org/biojava/nbio/structure/xtal/CrystalCell.java\n\n const cStar = (this.a * this.b * sinGamma) / this.volume\n const cosAlphaStar = (\n (cosBeta * cosGamma - cosAlpha) / (sinBeta * sinGamma)\n )\n\n this.fracToCart.set(\n this.a, 0, 0, 0,\n this.b * cosGamma, this.b * sinGamma, 0, 0,\n this.c * cosBeta, -this.c * sinBeta * cosAlphaStar, 1.0 / cStar, 0,\n 0, 0, 0, 1\n ).transpose()\n this.cartToFrac.getInverse(this.fracToCart)\n } else {\n this.cartToFrac.copy(params.cartToFrac)\n this.fracToCart.getInverse(this.cartToFrac)\n }\n }\n\n getPosition (structure: Structure): Float32Array {\n const vertexPosition = new Float32Array(3 * 8)\n\n if (structure.unitcell) {\n const uc = structure.unitcell\n const centerFrac = structure.center.clone().applyMatrix4(uc.cartToFrac).floor()\n const v = new Vector3()\n\n let cornerOffset = 0\n const addCorner = function (x: number, y: number, z: number) {\n v.set(x, y, z)\n .add(centerFrac)\n .applyMatrix4(uc.fracToCart)\n .toArray(vertexPosition as any, cornerOffset)\n cornerOffset += 3\n }\n addCorner(0, 0, 0)\n addCorner(1, 0, 0)\n addCorner(0, 1, 0)\n addCorner(0, 0, 1)\n addCorner(1, 1, 0)\n addCorner(1, 0, 1)\n addCorner(0, 1, 1)\n addCorner(1, 1, 1)\n }\n\n return vertexPosition\n }\n\n getCenter (structure: Structure) {\n return centerArray3(this.getPosition(structure))\n }\n\n getData (structure: Structure, params: UnitcellDataParams = {}) {\n const colorValue = defaults(params.colorValue, 'orange')\n const radius = defaults(params.radius, Math.cbrt(this.volume) / 200)\n\n const c = new Color(colorValue)\n const v = new Vector3()\n\n const vertexPosition = this.getPosition(structure)\n const vertexColor = uniformArray3(8, c.r, c.g, c.b)\n const vertexRadius = uniformArray(8, radius)\n\n const edgePosition1 = new Float32Array(3 * 12)\n const edgePosition2 = new Float32Array(3 * 12)\n const edgeColor = uniformArray3(12, c.r, c.g, c.b)\n const edgeRadius = uniformArray(12, radius)\n\n let edgeOffset = 0\n function addEdge (a: number, b: number) {\n v.fromArray(vertexPosition as any, a * 3)\n .toArray(edgePosition1 as any, edgeOffset)\n v.fromArray(vertexPosition as any, b * 3)\n .toArray(edgePosition2 as any, edgeOffset)\n edgeOffset += 3\n }\n addEdge(0, 1)\n addEdge(0, 2)\n addEdge(0, 3)\n addEdge(1, 4)\n addEdge(1, 5)\n addEdge(2, 6)\n addEdge(3, 5)\n addEdge(4, 7)\n addEdge(5, 7)\n addEdge(2, 4)\n addEdge(7, 6)\n addEdge(3, 6)\n\n const picker = new UnitcellPicker(this, structure)\n\n return {\n vertex: {\n position: vertexPosition,\n color: vertexColor,\n radius: vertexRadius,\n picking: picker\n },\n edge: {\n position1: edgePosition1,\n position2: edgePosition2,\n color: edgeColor,\n color2: edgeColor,\n radius: edgeRadius,\n picking: picker\n }\n }\n }\n}\n\nexport default Unitcell\n","/**\n * @file Pdb Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureParser from './structure-parser'\nimport Entity, { EntityTypeString } from '../structure/entity'\nimport Unitcell, { UnitcellParams } from '../symmetry/unitcell'\nimport Assembly, { AssemblyPart } from '../symmetry/assembly'\nimport { PDBQTSpecialElements, WaterNames } from '../structure/structure-constants'\nimport {\n assignSecondaryStructure, InferBondsOptions, buildUnitcellAssembly,\n calculateBonds, calculateChainnames, calculateSecondaryStructure\n} from '../structure/structure-utils'\nimport Streamer from '../streamer/streamer';\nimport { ParserParameters } from './parser';\nimport { NumberArray } from '../types';\nimport { Structure } from '../ngl';\n\n// PDB helix record encoding\nconst HelixTypes: {[k: number]: string} = {\n 1: 'h', // Right-handed alpha (default)\n 2: 'h', // Right-handed omega\n 3: 'i', // Right-handed pi\n 4: 'h', // Right-handed gamma\n 5: 'g', // Right-handed 310\n 6: 'h', // Left-handed alpha\n 7: 'h', // Left-handed omega\n 8: 'h', // Left-handed gamma\n 9: 'h', // 27 ribbon/helix\n 10: 'h', // Polyproline\n 0: 'h' //Used to be ''\n}\n\nconst dAminoAcids = [\n 'DAL', // D-ALANINE\n 'DAR', // D-ARGININE\n 'DSG', // D-ASPARAGINE\n 'DAS', // D-ASPARTIC ACID\n 'DCY', // D-CYSTEINE\n 'DGL', // D-GLUTAMIC ACID\n 'DGN', // D-GLUTAMINE\n 'DHI', // D-HISTIDINE\n 'DIL', // D-ISOLEUCINE\n 'DLE', // D-LEUCINE\n 'DLY', // D-LYSINE\n 'MED', // D-METHIONINE\n 'DPN', // D-PHENYLALANINE\n 'DPR', // D-PROLINE\n 'DSN', // D-SERINE\n 'DTH', // D-THREONINE\n 'DTR', // D-TRYPTOPHAN\n 'DTY', // D-TYROSINE\n 'DVA', // D-VALINE\n\n 'DNE' // D-NORLEUCINE\n\n // ??? // D-SELENOCYSTEINE\n]\n\nconst entityKeyList = [\n 'MOL_ID', 'MOLECULE', 'CHAIN', 'FRAGMENT', 'SYNONYM',\n 'EC', 'ENGINEERED', 'MUTATION', 'OTHER_DETAILS'\n]\n\nconst reWhitespace = /\\s+/\n\nfunction getModresId (resno: number, chainname?: string, inscode?: string) {\n let id = `${resno}`\n if (chainname) id += `:${chainname}`\n if (inscode) id += `^${inscode}`\n return id\n}\n\nexport interface PdbParserParameters extends ParserParameters {\n hex: boolean\n inferBonds: InferBondsOptions\n}\n\nclass PdbParser extends StructureParser {\n\n hex: boolean\n inferBonds: InferBondsOptions\n\n /**\n * Create a pdb parser\n * @param {Streamer} streamer - streamer object\n * @param {Object} params - params object\n * @param {Boolean} params.hex - hexadecimal parsing of\n * atom numbers >99.999 and\n * residue numbers >9.999\n * @param {InferBondsOptions} params.inferBonds: 'all': use explicit bonds and detect by distance\n * 'auto': If a hetgroup residue has explicit bonds, don't auto-detect\n * 'none': Don't add any bonds automatically\n * @return {undefined}\n */\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.hex = defaults(p.hex, false)\n this.inferBonds = defaults(p.inferBonds, 'all')\n }\n\n get type () { return 'pdb' }\n\n _parse () {\n // http://www.wwpdb.org/documentation/file-format.php\n\n if (Debug) Log.time('PdbParser._parse ' + this.name)\n\n let isLegacy = false\n const headerLine = this.streamer.peekLines(1)[ 0 ]\n const headerId = headerLine.substr(62, 4)\n const legacyId = headerLine.substr(72, 4)\n if (headerId === legacyId && legacyId.trim()) {\n isLegacy = true\n }\n\n const isPqr = this.type === 'pqr'\n const isPdbqt = this.type === 'pdbqt'\n\n const s: Structure = this.structure\n const sb = this.structureBuilder\n\n const hex = this.hex\n let serialRadix = 10\n let resnoRadix = 10\n\n const firstModelOnly = this.firstModelOnly\n const asTrajectory = this.asTrajectory\n const cAlphaOnly = this.cAlphaOnly\n\n const frames = s.frames\n const boxes = s.boxes\n let doFrames = false\n let currentFrame: NumberArray, currentCoord: number\n\n const biomolDict = s.biomolDict\n let currentBiomol: Assembly\n let currentPart: AssemblyPart\n let currentMatrix: Matrix4\n\n let line, recordName\n let serial, chainname: string, resno: number, resname: string, occupancy: number\n let inscode: string, atomname, hetero: boolean, bfactor: number, altloc\n let formalCharge: number\n\n let startChain, startResi, startIcode\n let endChain, endResi, endIcode\n\n let serialDict: {[k: number]: number} = {}\n const unitcellDict: Partial<{\n origx: Matrix4\n scale: Matrix4\n a: number\n b: number\n c: number\n alpha: number\n beta: number\n gamma: number\n spacegroup: string\n }> = {}\n const bondDict: {[k: string]: boolean} = {}\n\n const entityDataList: {chainList: string[], name: string}[] = []\n let currentEntityData: {chainList: string[], name: string}\n let currentEntityKey: 'MOL_ID'|'MOLECULE'|'CHAIN'|'FRAGMENT'|'SYNONYM'|'EC'|'ENGINEERED'|'MUTATION'|'OTHER_DETAILS'\n // MOL_ID Numbers each component; also used in SOURCE to associate\n // the information.\n // MOLECULE Name of the macromolecule.\n // CHAIN Comma-separated list of chain identifier(s).\n // FRAGMENT Specifies a domain or region of the molecule.\n // SYNONYM Comma-separated list of synonyms for the MOLECULE.\n // EC The Enzyme Commission number associated with the molecule.\n // If there is more than one EC number, they are presented\n // as a comma-separated list.\n // ENGINEERED Indicates that the molecule was produced using\n // recombinant technology or by purely chemical synthesis.\n // MUTATION Indicates if there is a mutation.\n // OTHER_DETAILS Additional comments.\n\n const hetnameDict: {[k: string]: string} = {}\n const modresDict: {[k: string]: any} = {}\n\n const chainDict: {[k: string]: number} = {}\n let chainIdx: number, chainid: string, newChain: boolean\n let currentChainname: string, currentResno: number, currentResname: string, currentInscode: string\n\n const seqresDict: {[k: string]: string[]} = {}\n let currentSeqresChainname: string\n\n const secStruct = {\n helices: [] as any[],\n sheets: [] as any[]\n }\n const helices = secStruct.helices\n const sheets = secStruct.sheets\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.resize(Math.round(this.streamer.data.length / 80))\n if (isPqr || isPdbqt) atomStore.addField('partialCharge', 1, 'float32')\n if (isPqr) atomStore.addField('radius', 1, 'float32')\n\n const ap1 = s.getAtomProxy()\n const ap2 = s.getAtomProxy()\n\n let idx = 0\n let modelIdx = 0\n let pendingStart = true\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n line = lines[ i ]\n recordName = line.substr(0, 6)\n\n if (recordName === 'ATOM ' || recordName === 'HETATM') {\n // http://www.wwpdb.org/documentation/file-format-content/format33/sect9.html#ATOM\n // PQR: Field_name Atom_number Atom_name Residue_name Chain_ID Residue_number X Y Z Charge Radius\n\n if (pendingStart) {\n if (asTrajectory) {\n if (doFrames) {\n currentFrame = new Float32Array(atomStore.count * 3)\n frames.push(currentFrame)\n } else {\n currentFrame = []\n }\n currentCoord = 0\n } else {\n if (!firstModelOnly) serialDict = {}\n }\n\n chainIdx = 1\n chainid = chainIdx.toString()\n newChain = true\n\n pendingStart = false\n }\n\n if (firstModelOnly && modelIdx > 0) continue\n\n let x, y, z, ls: string[], dd = 0\n\n if (isPqr) {\n ls = line.split(reWhitespace)\n dd = ls.length === 10 ? 1 : 0\n\n atomname = ls[ 2 ]\n if (cAlphaOnly && atomname !== 'CA') continue\n\n x = parseFloat(ls[ 6 - dd ])\n y = parseFloat(ls[ 7 - dd ])\n z = parseFloat(ls[ 8 - dd ])\n } else {\n atomname = line.substr(12, 4).trim()\n if (cAlphaOnly && atomname !== 'CA') continue\n\n x = parseFloat(line.substr(30, 8))\n y = parseFloat(line.substr(38, 8))\n z = parseFloat(line.substr(46, 8))\n }\n\n if (asTrajectory) {\n const j = currentCoord * 3\n\n currentFrame[ j + 0 ] = x\n currentFrame[ j + 1 ] = y\n currentFrame[ j + 2 ] = z\n\n currentCoord += 1\n\n if (doFrames) continue\n }\n\n let element\n\n if (isPqr) {\n serial = parseInt(ls![ 1 ])\n element = ''\n hetero = (line[ 0 ] === 'H')\n chainname = dd ? '' : ls![ 4 ]\n resno = parseInt(ls![ 5 - dd! ])\n inscode = ''\n resname = ls![ 3 ]\n altloc = ''\n occupancy = 1.0\n } else {\n serial = parseInt(line.substr(6, 5), serialRadix)\n if (hex && serial === 99999) {\n serialRadix = 16\n }\n hetero = (line[ 0 ] === 'H')\n chainname = line[ 21 ].trim()\n resno = parseInt(line.substr(22, 4), resnoRadix)\n if (hex && resno === 9999) {\n resnoRadix = 16\n }\n inscode = line[ 26 ].trim()\n resname = line.substr(17, 4).trim() || 'MOL'\n bfactor = parseFloat(line.substr(60, 6))\n altloc = line[ 16 ].trim()\n occupancy = parseFloat(line.substr(54, 6))\n\n if (!isLegacy) {\n if (isPdbqt) {\n element = line.substr(76, 3).trim()\n // @ts-expect-error TS limitation on narrowing indexes types with `in`\n if (element in PDBQTSpecialElements) element = PDBQTSpecialElements[element]\n } else {\n element = line.substr(76, 2).trim()\n if (!chainname) {\n chainname = line.substr(72, 4).trim() // segid\n }\n }\n // Where specified, formalCharge is of form \"2-\" or \"1+\"\n formalCharge = parseInt((line.substr(79,1) + line.substr(78, 1)).trim())\n }\n }\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname, element)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = serial\n atomStore.altloc[ idx ] = altloc.charCodeAt(0)\n atomStore.occupancy[ idx ] = isNaN(occupancy) ? 0 : occupancy\n\n if (isPqr) {\n atomStore.partialCharge![ idx ] = parseFloat(ls![ 9 - dd! ])\n atomStore.radius[ idx ] = parseFloat(ls![ 10 - dd! ])\n } else {\n atomStore.bfactor[ idx ] = isNaN(bfactor) ? 0 : bfactor\n if (isPdbqt) {\n atomStore.partialCharge![ idx ] = parseFloat(line.substr(70, 6))\n }\n // isFinite check will reject undefined (in legacy case) and NaN values\n if (isFinite(formalCharge)) {\n if (!atomStore.formalCharge) {\n atomStore.addField('formalCharge', 1, 'int8')\n }\n atomStore.formalCharge![ idx ] = formalCharge\n }\n }\n\n const modresId = getModresId(resno, chainname, inscode)\n\n // TODO instead of looking at MODRES look at SEQRES and\n // missing residues in REMARK 465\n if (hetero && !modresDict[modresId] && !dAminoAcids.includes(resname)) {\n if (currentChainname !== chainname || currentResname !== resname ||\n (!WaterNames.includes(resname) &&\n (currentResno !== resno || currentInscode !== inscode))\n ) {\n chainIdx += 1\n chainid = chainIdx.toString()\n\n currentResno = resno\n currentResname = resname\n currentInscode = inscode\n }\n } else if (!newChain && currentChainname !== chainname) {\n chainIdx += 1\n chainid = chainIdx.toString()\n }\n\n sb.addAtom(modelIdx, chainname, chainid, resname, resno, hetero, undefined, inscode)\n\n serialDict[ serial ] = idx\n idx += 1\n newChain = false\n currentChainname = chainname\n } else if (recordName === 'CONECT') {\n const fromIdx = serialDict[ parseInt(line.substr(6, 5)) ]\n const pos = [ 11, 16, 21, 26 ]\n const bondIndex: {[k: number]: number} = {}\n\n if (fromIdx === undefined) {\n // Log.log( \"missing CONNECT serial\" );\n continue\n }\n\n for (let j = 0; j < 4; ++j) {\n let toIdx = parseInt(line.substr(pos[ j ], 5))\n if (Number.isNaN(toIdx)) continue\n toIdx = serialDict[ toIdx ]\n if (toIdx === undefined) {\n // Log.log( \"missing CONNECT serial\" );\n continue\n }/* else if( toIdx < fromIdx ){\n // likely a duplicate in standard PDB format\n // but not necessarily, so better remove duplicates\n // in a pass after parsing (and auto bonding)\n continue;\n } */\n\n if (fromIdx < toIdx) {\n ap1.index = fromIdx\n ap2.index = toIdx\n } else {\n ap1.index = toIdx\n ap2.index = fromIdx\n }\n\n // interpret records where a 'toIdx' atom is given multiple times\n // as double/triple bonds, e.g. CONECT 1529 1528 1528 is a double bond\n if (bondIndex[ toIdx ] !== undefined) {\n s.bondStore.bondOrder[ bondIndex[ toIdx ] ] += 1\n } else {\n const hash = ap1.index + '|' + ap2.index\n if (bondDict[ hash ] === undefined) {\n bondDict[ hash ] = true\n bondIndex[ toIdx ] = s.bondStore.count\n s.bondStore.addBond(ap1, ap2, 1) // start/assume with single bond\n }\n }\n }\n } else if (recordName === 'HELIX ') {\n startChain = line[ 19 ].trim()\n startResi = parseInt(line.substr(21, 4))\n startIcode = line[ 25 ].trim()\n endChain = line[ 31 ].trim()\n endResi = parseInt(line.substr(33, 4))\n endIcode = line[ 37 ].trim()\n let helixType = parseInt(line.substr(39, 1))\n helixType = (HelixTypes[ helixType ] || HelixTypes[0]).charCodeAt(0)\n helices.push([\n startChain, startResi, startIcode,\n endChain, endResi, endIcode,\n helixType\n ])\n } else if (recordName === 'SHEET ') {\n startChain = line[ 21 ].trim()\n startResi = parseInt(line.substr(22, 4))\n startIcode = line[ 26 ].trim()\n endChain = line[ 32 ].trim()\n endResi = parseInt(line.substr(33, 4))\n endIcode = line[ 37 ].trim()\n sheets.push([\n startChain, startResi, startIcode,\n endChain, endResi, endIcode\n ])\n } else if (recordName === 'HETNAM') {\n hetnameDict[ line.substr(11, 3) ] = line.substr(15).trim()\n } else if (recordName === 'SEQRES') {\n const seqresChainname = line[11].trim()\n if (seqresChainname !== currentSeqresChainname) {\n seqresDict[ seqresChainname ] = []\n currentSeqresChainname = seqresChainname\n }\n seqresDict[ seqresChainname ].push(\n ...line.substr(19).trim().split(reWhitespace)\n )\n } else if (recordName === 'MODRES') {\n // MODRES 2SRC PTR A 527 TYR O-PHOSPHOTYROSINE\n const resname = line.substr(12, 3).trim()\n const chainname = line[16].trim()\n const inscode = line[22].trim()\n const resno = parseInt(line.substr(18, 4).trim())\n const id = getModresId(resno, chainname, inscode)\n modresDict[ id ] = { resname, chainname, inscode, resno }\n } else if (recordName === 'COMPND') {\n const comp = line.substr(10, 70).trim()\n const keyEnd = comp.indexOf(':')\n const key = comp.substring(0, keyEnd)\n let value\n\n if (entityKeyList.includes(key)) {\n currentEntityKey = key as 'MOL_ID'|'MOLECULE'|'CHAIN'|'FRAGMENT'|'SYNONYM'|'EC'|'ENGINEERED'|'MUTATION'|'OTHER_DETAILS'\n value = comp.substring(keyEnd + 2)\n } else {\n value = comp\n }\n value = value.replace(/;$/, '')\n\n if (currentEntityKey === 'MOL_ID') {\n currentEntityData = {\n chainList: [],\n name: ''\n }\n entityDataList.push(currentEntityData)\n } else if (currentEntityKey === 'MOLECULE') {\n if (currentEntityData.name) currentEntityData.name += ' '\n currentEntityData.name += value\n } else if (currentEntityKey === 'CHAIN') {\n Array.prototype.push.apply(\n currentEntityData.chainList,\n value.split(/\\s*,\\s*/)\n )\n }\n } else if (line.startsWith('TER')) {\n const cp = s.getChainProxy(s.chainStore.count - 1)\n chainDict[ cp.chainname ] = cp.index\n chainIdx += 1\n chainid = chainIdx.toString()\n newChain = true\n } else if (recordName === 'REMARK' && line.substr(7, 3) === '350') {\n if (line.substr(11, 12) === 'BIOMOLECULE:') {\n let name = line.substr(23).trim()\n if (/^(0|[1-9][0-9]*)$/.test(name)) name = 'BU' + name\n\n currentBiomol = new Assembly(name)\n biomolDict[ name ] = currentBiomol\n } else if (line.substr(13, 5) === 'BIOMT') {\n const biomt = line.split(/\\s+/)\n const row = parseInt(line[ 18 ]) - 1\n\n if (row === 0) {\n currentMatrix = new Matrix4()\n currentPart.matrixList.push(currentMatrix)\n }\n\n const biomtElms = currentMatrix.elements\n\n biomtElms[ 4 * 0 + row ] = parseFloat(biomt[ 4 ])\n biomtElms[ 4 * 1 + row ] = parseFloat(biomt[ 5 ])\n biomtElms[ 4 * 2 + row ] = parseFloat(biomt[ 6 ])\n biomtElms[ 4 * 3 + row ] = parseFloat(biomt[ 7 ])\n } else if (\n line.substr(11, 30) === 'APPLY THE FOLLOWING TO CHAINS:' ||\n line.substr(11, 30) === ' AND CHAINS:'\n ) {\n if (line.substr(11, 5) === 'APPLY') {\n currentPart = currentBiomol.addPart()\n }\n\n const chainList = line.substr(41, 30).split(',')\n for (let j = 0, jl = chainList.length; j < jl; ++j) {\n const c = chainList[ j ].trim()\n if (c) currentPart.chainList.push(c)\n }\n }\n } else if (recordName === 'HEADER') {\n s.id = line.substr(62, 4)\n } else if (recordName === 'TITLE ') {\n s.title += (s.title ? ' ' : '') + line.substr(10, 70).trim()\n } else if (recordName === 'MODEL ') {\n pendingStart = true\n } else if (recordName === 'ENDMDL' || line.trim() === 'END') {\n if (pendingStart) continue\n\n if (asTrajectory && !doFrames) {\n frames.push(new Float32Array(currentFrame))\n doFrames = true\n }\n\n modelIdx += 1\n pendingStart = true\n } else if (line.substr(0, 5) === 'MTRIX') {\n // ignore 'given' operators\n if (line[ 59 ] === '1') continue\n\n if (!currentBiomol || currentBiomol.name !== 'NCS') {\n const ncsName = 'NCS'\n currentBiomol = new Assembly(ncsName)\n biomolDict[ ncsName ] = currentBiomol\n currentPart = currentBiomol.addPart()\n }\n\n const ncs = line.split(/\\s+/)\n const ncsRow = parseInt(line[ 5 ]) - 1\n\n if (ncsRow === 0) {\n currentMatrix = new Matrix4()\n currentPart.matrixList.push(currentMatrix)\n }\n\n const ncsElms = currentMatrix.elements\n\n ncsElms[ 4 * 0 + ncsRow ] = parseFloat(ncs[ 2 ])\n ncsElms[ 4 * 1 + ncsRow ] = parseFloat(ncs[ 3 ])\n ncsElms[ 4 * 2 + ncsRow ] = parseFloat(ncs[ 4 ])\n ncsElms[ 4 * 3 + ncsRow ] = parseFloat(ncs[ 5 ])\n } else if (line.substr(0, 5) === 'ORIGX') {\n if (!unitcellDict.origx) {\n unitcellDict.origx = new Matrix4()\n }\n\n const orgix = line.split(/\\s+/)\n const origxRow = parseInt(line[ 5 ]) - 1\n const origxElms = unitcellDict.origx.elements\n\n origxElms[ 4 * 0 + origxRow ] = parseFloat(orgix[ 1 ])\n origxElms[ 4 * 1 + origxRow ] = parseFloat(orgix[ 2 ])\n origxElms[ 4 * 2 + origxRow ] = parseFloat(orgix[ 3 ])\n origxElms[ 4 * 3 + origxRow ] = parseFloat(orgix[ 4 ])\n } else if (line.substr(0, 5) === 'SCALE') {\n if (!unitcellDict.scale) {\n unitcellDict.scale = new Matrix4()\n }\n\n const scale = line.split(/\\s+/)\n const scaleRow = parseInt(line[ 5 ]) - 1\n const scaleElms = unitcellDict.scale.elements\n\n scaleElms[ 4 * 0 + scaleRow ] = parseFloat(scale[ 1 ])\n scaleElms[ 4 * 1 + scaleRow ] = parseFloat(scale[ 2 ])\n scaleElms[ 4 * 2 + scaleRow ] = parseFloat(scale[ 3 ])\n scaleElms[ 4 * 3 + scaleRow ] = parseFloat(scale[ 4 ])\n } else if (recordName === 'CRYST1') {\n // CRYST1 55.989 55.989 55.989 90.00 90.00 90.00 P 1 1\n // 7 - 15 Real(9.3) a (Angstroms)\n // 16 - 24 Real(9.3) b (Angstroms)\n // 25 - 33 Real(9.3) c (Angstroms)\n // 34 - 40 Real(7.2) alpha alpha (degrees).\n // 41 - 47 Real(7.2) beta beta (degrees).\n // 48 - 54 Real(7.2) gamma gamma (degrees).\n // 56 - 66 LString sGroup Space group.\n // 67 - 70 Integer z Z value.\n\n const aLength = parseFloat(line.substr(6, 9))\n const bLength = parseFloat(line.substr(15, 9))\n const cLength = parseFloat(line.substr(24, 9))\n\n const alpha = parseFloat(line.substr(33, 7))\n const beta = parseFloat(line.substr(40, 7))\n const gamma = parseFloat(line.substr(47, 7))\n\n const sGroup = line.substr(55, 11).trim()\n // const zValue = parseInt( line.substr( 66, 4 ) );\n\n const box = new Float32Array(9)\n box[ 0 ] = aLength\n box[ 4 ] = bLength\n box[ 8 ] = cLength\n boxes.push(box)\n\n if (modelIdx === 0) {\n unitcellDict.a = aLength\n unitcellDict.b = bLength\n unitcellDict.c = cLength\n unitcellDict.alpha = alpha\n unitcellDict.beta = beta\n unitcellDict.gamma = gamma\n unitcellDict.spacegroup = sGroup\n }\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n\n // finalize ensures resname will be defined for all rp.resname\n // (required in entity handling below)\n sb.finalize()\n\n //\n\n const en = entityDataList.length\n\n if (en) {\n s.eachChain(function (cp) {\n cp.entityIndex = en\n })\n\n entityDataList.forEach(function (e, i) {\n const chainIndexList = e.chainList.map(function (chainname) {\n return chainDict[ chainname ]\n })\n s.entityList.push(new Entity(\n s, i, e.name, 'polymer', chainIndexList\n ))\n })\n\n let ei = entityDataList.length\n const rp = s.getResidueProxy()\n const residueDict: {[k: string]: number[]} = {}\n\n s.eachChain(function (cp) {\n if (cp.entityIndex === en) {\n rp.index = cp.residueOffset\n if (!residueDict[ rp.resname ]) {\n residueDict[ rp.resname ] = []\n }\n residueDict[ rp.resname ].push(cp.index)\n }\n })\n\n Object.keys(residueDict).forEach(function (resname) {\n const chainList = residueDict[ resname ]\n let type: EntityTypeString = 'non-polymer'\n let name = hetnameDict[ resname ] || resname\n if (WaterNames.includes(resname)) {\n name = 'water'\n type = 'water'\n }\n s.entityList.push(new Entity(\n s, ei, name, type, chainList\n ))\n ei += 1\n })\n }\n\n //\n\n if (unitcellDict.a !== undefined) {\n s.unitcell = new Unitcell(unitcellDict as UnitcellParams)\n } else {\n s.unitcell = undefined\n }\n\n if (helices.length || sheets.length) {\n assignSecondaryStructure(s, secStruct)\n }\n\n s.finalizeAtoms()\n if (!isLegacy) calculateChainnames(s)\n calculateBonds(s, this.inferBonds)\n s.finalizeBonds()\n\n if (!helices.length && !sheets.length) {\n calculateSecondaryStructure(s)\n }\n buildUnitcellAssembly(s)\n\n if (Debug) Log.timeEnd('PdbParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('pdb', PdbParser)\nParserRegistry.add('pdb1', PdbParser)\nParserRegistry.add('ent', PdbParser)\n\nexport default PdbParser\n\nexport {\n HelixTypes\n}\n","/**\n * @file Cif Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport { HelixTypes } from './pdb-parser'\nimport Entity from '../structure/entity'\nimport Unitcell, { UnitcellParams } from '../symmetry/unitcell'\nimport Assembly from '../symmetry/assembly'\nimport Selection from '../selection/selection'\nimport {\n assignResidueTypeBonds, assignSecondaryStructure, buildUnitcellAssembly,\n calculateBonds, calculateSecondaryStructure\n} from '../structure/structure-utils'\nimport { Structure } from '../ngl';\nimport StructureBuilder from '../structure/structure-builder';\nimport { NumberArray } from '../types';\n\nconst reWhitespace = /\\s+/\nconst reQuotedWhitespace = /'((?:(?!'\\s).)*)'|\"((?:(?!\"\\s).)*)\"|(\\S+)/g\nconst reDoubleQuote = /\"/g\nconst reTrimQuotes = /^['\"]+|['\"]+$/g\nconst reAtomSymbol = /^\\D{1,2}/ // atom symbol in atom_site_label\n\ninterface Cif {[k: string]: any}\n\nfunction trimQuotes (str: string) {\n if (str && str[0] === str[ str.length - 1 ] && (str[0] === \"'\" || str[0] === '\"')) {\n return str.substring(1, str.length - 1)\n } else {\n return str\n }\n}\n\nfunction ensureArray (dict: {[k: string]: any[]}, field: string) {\n if (!Array.isArray(dict[ field ])) {\n Object.keys(dict).forEach(function (key) {\n dict[ key ] = [ dict[ key ] ]\n })\n }\n}\n\nfunction hasValue (d: string) {\n return d !== '?'\n}\n\nfunction cifDefaults (value: string, defaultValue: string) {\n return hasValue(value) ? value : defaultValue\n}\n\nfunction getBondOrder (valueOrder: string) {\n switch (valueOrder.toLowerCase()) {\n case '?': // assume single bond\n case 'sing':\n return 1\n case 'doub':\n return 2\n case 'trip':\n return 3\n case 'quad':\n return 4\n }\n return 0\n}\n\nfunction parseChemComp (cif: Cif, structure: Structure, structureBuilder: StructureBuilder) {\n const atomStore = structure.atomStore\n const atomMap = structure.atomMap\n\n let i, n\n const cc = cif.chem_comp\n const cca = cif.chem_comp_atom\n const ccb = cif.chem_comp_bond\n\n if (cc) {\n if (cc.name) {\n structure.title = cc.name.trim().replace(reTrimQuotes, '')\n }\n if (cc.id) {\n structure.id = cc.id.trim().replace(reTrimQuotes, '')\n }\n }\n\n var atomnameDict: {[k: string]: number} = {}\n\n if (cca) {\n ensureArray(cca, 'comp_id')\n\n var atomname, element, resname, resno\n n = cca.comp_id.length\n\n for (i = 0; i < n; ++i) {\n atomStore.growIfFull()\n\n atomname = cca.atom_id[ i ].replace(reDoubleQuote, '')\n element = cca.type_symbol[ i ]\n\n atomnameDict[ atomname ] = i\n atomStore.atomTypeId[ i ] = atomMap.add(atomname, element)\n\n atomStore.x[ i ] = cca.model_Cartn_x[ i ]\n atomStore.y[ i ] = cca.model_Cartn_y[ i ]\n atomStore.z[ i ] = cca.model_Cartn_z[ i ]\n atomStore.serial[ i ] = i\n\n resname = cca.pdbx_component_comp_id[ i ]\n resno = cca.pdbx_residue_numbering ? cca.pdbx_residue_numbering[ i ] : 1\n\n structureBuilder.addAtom(0, '', '', resname, resno, true)\n }\n\n for (i = 0; i < n; ++i) {\n var j = i + n\n\n atomStore.growIfFull()\n\n atomname = cca.atom_id[ i ].replace(reDoubleQuote, '')\n element = cca.type_symbol[ i ]\n\n atomStore.atomTypeId[ j ] = atomMap.add(atomname, element)\n\n atomStore.x[ j ] = cca.pdbx_model_Cartn_x_ideal[ i ]\n atomStore.y[ j ] = cca.pdbx_model_Cartn_y_ideal[ i ]\n atomStore.z[ j ] = cca.pdbx_model_Cartn_z_ideal[ i ]\n atomStore.serial[ j ] = j\n\n resname = cca.pdbx_component_comp_id[ i ]\n resno = cca.pdbx_residue_numbering ? cca.pdbx_residue_numbering[ i ] : 1\n\n structureBuilder.addAtom(1, '', '', resname, resno, true)\n }\n }\n\n if (cca && ccb) {\n ensureArray(ccb, 'comp_id')\n\n var atomname1, atomname2, bondOrder\n n = ccb.comp_id.length\n var na = cca.comp_id.length\n\n var ap1 = structure.getAtomProxy()\n var ap2 = structure.getAtomProxy()\n\n for (i = 0; i < n; ++i) {\n atomname1 = ccb.atom_id_1[ i ].replace(reDoubleQuote, '')\n atomname2 = ccb.atom_id_2[ i ].replace(reDoubleQuote, '')\n bondOrder = getBondOrder(ccb.value_order[ i ])\n\n ap1.index = atomnameDict[ atomname1 ]\n ap2.index = atomnameDict[ atomname2 ]\n structure.bondStore.growIfFull()\n structure.bondStore.addBond(ap1, ap2, bondOrder)\n\n ap1.index += na\n ap2.index += na\n structure.bondStore.growIfFull()\n structure.bondStore.addBond(ap1, ap2, bondOrder)\n }\n }\n}\n\nfunction parseCore (cif: Cif, structure: Structure, structureBuilder: StructureBuilder) {\n var atomStore = structure.atomStore\n var atomMap = structure.atomMap\n\n if (cif.data) {\n structure.id = cif.data\n structure.name = cif.data\n }\n\n structure.unitcell = new Unitcell({\n a: parseFloat(cif.cell_length_a),\n b: parseFloat(cif.cell_length_b),\n c: parseFloat(cif.cell_length_c),\n alpha: parseFloat(cif.cell_angle_alpha),\n beta: parseFloat(cif.cell_angle_beta),\n gamma: parseFloat(cif.cell_angle_gamma),\n spacegroup: trimQuotes(cif['symmetry_space_group_name_H-M'])\n })\n\n const v = new Vector3()\n const c = new Vector3()\n const n = cif.atom_site_type_symbol.length\n\n const typeSymbolMap: Record = {}\n\n for (let i = 0; i < n; ++i) {\n atomStore.growIfFull()\n\n const atomname = cif.atom_site_label[ i ]\n const typeSymbol = cif.atom_site_type_symbol[ i ]\n\n // typeSymbol can be like `Al2.5+`. Retain element symbol only.\n let element = typeSymbolMap[typeSymbol]\n if (!element) {\n const match = typeSymbol.match(reAtomSymbol)\n typeSymbolMap[typeSymbol] = element = match?.[0] ?? typeSymbol\n }\n\n atomStore.atomTypeId[ i ] = atomMap.add(atomname, element)\n\n v.set(\n cif.atom_site_fract_x[ i ],\n cif.atom_site_fract_y[ i ],\n cif.atom_site_fract_z[ i ]\n )\n v.applyMatrix4(structure.unitcell.fracToCart)\n c.add(v)\n\n atomStore.x[ i ] = v.x\n atomStore.y[ i ] = v.y\n atomStore.z[ i ] = v.z\n if (cif.atom_site_occupancy) {\n atomStore.occupancy[ i ] = parseFloat(cif.atom_site_occupancy[ i ])\n }\n atomStore.serial[ i ] = i\n\n structureBuilder.addAtom(0, '', '', 'HET', 1, true)\n }\n\n c.divideScalar(n)\n structure.center = c\n buildUnitcellAssembly(structure)\n\n const v2 = new Vector3()\n const v3 = new Vector3()\n const ml = structure.biomolDict.SUPERCELL.partList[ 0 ].matrixList\n\n let k = n\n\n function covalent (idx: number) {\n return atomMap.get(atomStore.atomTypeId[ idx ]).covalent\n }\n const identityMatrix = new Matrix4()\n\n for (let i = 0; i < n; ++i) {\n const covalentI = covalent(i)\n\n v.set(\n atomStore.x[ i ],\n atomStore.y[ i ],\n atomStore.z[ i ]\n )\n\n ml.forEach(function (m) {\n if (identityMatrix.equals(m)) return\n\n v2.copy(v)\n v2.applyMatrix4(m)\n\n for (let j = 0; j < n; ++j) {\n v3.set(\n atomStore.x[ j ],\n atomStore.y[ j ],\n atomStore.z[ j ]\n )\n\n const distSquared = v2.distanceToSquared(v3)\n const d = covalent(j) + covalentI\n const d1 = d + 0.3\n const d2 = d - 0.5\n\n if (distSquared < (d1 * d1) && distSquared > (d2 * d2)) {\n atomStore.growIfFull()\n\n atomStore.atomTypeId[ k ] = atomStore.atomTypeId[ i ]\n atomStore.x[ k ] = v2.x\n atomStore.y[ k ] = v2.y\n atomStore.z[ k ] = v2.z\n atomStore.occupancy[ k ] = atomStore.occupancy[ i ]\n atomStore.serial[ k ] = k\n atomStore.altloc[ k ] = 'A'.charCodeAt(0)\n\n structureBuilder.addAtom(0, '', '', 'HET', 1, true)\n\n k += 1\n return\n }\n }\n })\n }\n}\n\nfunction processSecondaryStructure (cif: Cif, structure: Structure, asymIdDict: {[k: string]: string}) {\n var helices: [string, number, string, string, number, string, number][] = []\n var sheets: [string, number, string, string, number, string][] = []\n\n var i, il, begIcode, endIcode\n\n // get helices\n var sc = cif.struct_conf\n\n if (sc?.pdbx_PDB_helix_class) {\n ensureArray(sc, 'id')\n\n for (i = 0, il = sc.beg_auth_seq_id.length; i < il; ++i) {\n var helixType = parseInt(sc.pdbx_PDB_helix_class[ i ])\n if (!Number.isNaN(helixType)) {\n begIcode = sc.pdbx_beg_PDB_ins_code[ i ]\n endIcode = sc.pdbx_end_PDB_ins_code[ i ]\n helices.push([\n asymIdDict[ sc.beg_label_asym_id[ i ] ],\n parseInt(sc.beg_auth_seq_id[ i ]),\n cifDefaults(begIcode, ''),\n asymIdDict[ sc.end_label_asym_id[ i ] ],\n parseInt(sc.end_auth_seq_id[ i ]),\n cifDefaults(endIcode, ''),\n (HelixTypes[ helixType ] || HelixTypes[0]).charCodeAt(0)\n ])\n }\n }\n }\n\n // get sheets\n var ssr = cif.struct_sheet_range\n\n if (ssr) {\n ensureArray(ssr, 'id')\n\n for (i = 0, il = ssr.beg_auth_seq_id.length; i < il; ++i) {\n begIcode = ssr.pdbx_beg_PDB_ins_code[ i ]\n endIcode = ssr.pdbx_end_PDB_ins_code[ i ]\n sheets.push([\n asymIdDict[ ssr.beg_label_asym_id[ i ] ],\n parseInt(ssr.beg_auth_seq_id[ i ]),\n cifDefaults(begIcode, ''),\n asymIdDict[ ssr.end_label_asym_id[ i ] ],\n parseInt(ssr.end_auth_seq_id[ i ]),\n cifDefaults(endIcode, '')\n ])\n }\n }\n\n if (sc || ssr) {\n return {\n helices: helices,\n sheets: sheets\n }\n } else {\n return false\n }\n}\n\nfunction processSymmetry (cif: Cif, structure: Structure, asymIdDict: {[k: string]: string}) {\n // biomol & ncs processing\n var operDict: {[k: string]: Matrix4} = {}\n var biomolDict = structure.biomolDict\n\n if (cif.pdbx_struct_oper_list) {\n var biomolOp = cif.pdbx_struct_oper_list\n ensureArray(biomolOp, 'id')\n\n biomolOp.id.forEach(function (id: number, i: number) {\n var m = new Matrix4()\n var elms = m.elements\n\n elms[ 0 ] = parseFloat(biomolOp[ 'matrix[1][1]' ][ i ])\n elms[ 1 ] = parseFloat(biomolOp[ 'matrix[1][2]' ][ i ])\n elms[ 2 ] = parseFloat(biomolOp[ 'matrix[1][3]' ][ i ])\n\n elms[ 4 ] = parseFloat(biomolOp[ 'matrix[2][1]' ][ i ])\n elms[ 5 ] = parseFloat(biomolOp[ 'matrix[2][2]' ][ i ])\n elms[ 6 ] = parseFloat(biomolOp[ 'matrix[2][3]' ][ i ])\n\n elms[ 8 ] = parseFloat(biomolOp[ 'matrix[3][1]' ][ i ])\n elms[ 9 ] = parseFloat(biomolOp[ 'matrix[3][2]' ][ i ])\n elms[ 10 ] = parseFloat(biomolOp[ 'matrix[3][3]' ][ i ])\n\n elms[ 3 ] = parseFloat(biomolOp[ 'vector[1]' ][ i ])\n elms[ 7 ] = parseFloat(biomolOp[ 'vector[2]' ][ i ])\n elms[ 11 ] = parseFloat(biomolOp[ 'vector[3]' ][ i ])\n\n m.transpose()\n\n operDict[ id ] = m\n })\n }\n\n if (cif.pdbx_struct_assembly_gen) {\n var gen = cif.pdbx_struct_assembly_gen\n ensureArray(gen, 'assembly_id')\n\n var getMatrixDict = function (expr: string) {\n var matDict: {[k: string]: Matrix4} = {}\n\n var l = expr.replace(/[()']/g, '').split(',')\n\n l.forEach(function (e) {\n if (e.includes('-')) {\n var es = e.split('-')\n\n var j = parseInt(es[ 0 ])\n var m = parseInt(es[ 1 ])\n\n for (; j <= m; ++j) {\n matDict[ j ] = operDict[ j ]\n }\n } else {\n matDict[ e ] = operDict[ e ]\n }\n })\n\n return matDict\n }\n\n gen.assembly_id.forEach(function (id: string, i: number) {\n var md:{[k: string]: Matrix4} = {}\n var oe = gen.oper_expression[ i ].replace(/['\"]\\(|['\"]/g, '')\n\n if (oe.includes(')(') || oe.indexOf('(') > 0) {\n oe = oe.split('(')\n\n var md1 = getMatrixDict(oe[ 0 ])\n var md2 = getMatrixDict(oe[ 1 ])\n\n Object.keys(md1).forEach(function (k1) {\n Object.keys(md2).forEach(function (k2) {\n var mat = new Matrix4()\n\n mat.multiplyMatrices(md1[ k1 ], md2[ k2 ])\n md[ k1 + 'x' + k2 ] = mat\n })\n })\n } else {\n md = getMatrixDict(oe)\n }\n\n var matrixList = []\n for (var k in md) {\n matrixList.push(md[ k ])\n }\n\n var name = id\n if (/^(0|[1-9][0-9]*)$/.test(name)) name = 'BU' + name\n\n var chainList = gen.asym_id_list[ i ].split(',')\n for (var j = 0, jl = chainList.length; j < jl; ++j) {\n chainList[ j ] = asymIdDict[ chainList[ j ] ]\n }\n\n if (biomolDict[ name ] === undefined) {\n biomolDict[ name ] = new Assembly(name)\n }\n biomolDict[ name ].addPart(matrixList, chainList)\n })\n }\n\n // non-crystallographic symmetry operations\n if (cif.struct_ncs_oper) {\n var ncsOp = cif.struct_ncs_oper\n ensureArray(ncsOp, 'id')\n\n var ncsName = 'NCS'\n biomolDict[ ncsName ] = new Assembly(ncsName)\n var ncsPart = biomolDict[ ncsName ].addPart()\n\n ncsOp.id.forEach(function (id: string, i: number) {\n // ignore 'given' operators\n if (ncsOp.code[ i ] === 'given') return\n\n var m = new Matrix4()\n var elms = m.elements\n\n elms[ 0 ] = parseFloat(ncsOp[ 'matrix[1][1]' ][ i ])\n elms[ 1 ] = parseFloat(ncsOp[ 'matrix[1][2]' ][ i ])\n elms[ 2 ] = parseFloat(ncsOp[ 'matrix[1][3]' ][ i ])\n\n elms[ 4 ] = parseFloat(ncsOp[ 'matrix[2][1]' ][ i ])\n elms[ 5 ] = parseFloat(ncsOp[ 'matrix[2][2]' ][ i ])\n elms[ 6 ] = parseFloat(ncsOp[ 'matrix[2][3]' ][ i ])\n\n elms[ 8 ] = parseFloat(ncsOp[ 'matrix[3][1]' ][ i ])\n elms[ 9 ] = parseFloat(ncsOp[ 'matrix[3][2]' ][ i ])\n elms[ 10 ] = parseFloat(ncsOp[ 'matrix[3][3]' ][ i ])\n\n elms[ 3 ] = parseFloat(ncsOp[ 'vector[1]' ][ i ])\n elms[ 7 ] = parseFloat(ncsOp[ 'vector[2]' ][ i ])\n elms[ 11 ] = parseFloat(ncsOp[ 'vector[3]' ][ i ])\n\n m.transpose()\n\n ncsPart.matrixList.push(m)\n })\n\n if (ncsPart.matrixList.length === 0) {\n delete biomolDict[ ncsName ]\n }\n }\n\n // cell & symmetry\n const unitcellDict: {\n a?: number\n b?: number\n c?: number\n alpha?: number\n beta?: number\n gamma?: number\n spacegroup?: string\n origx?: Matrix4\n scale?: Matrix4\n } = {}\n\n if (cif.cell) {\n const cell = cif.cell\n\n const a = parseFloat(cell.length_a)\n const b = parseFloat(cell.length_b)\n const c = parseFloat(cell.length_c)\n\n const box = new Float32Array(9)\n box[ 0 ] = a\n box[ 4 ] = b\n box[ 8 ] = c\n structure.boxes.push(box)\n\n unitcellDict.a = a\n unitcellDict.b = b\n unitcellDict.c = c\n unitcellDict.alpha = parseFloat(cell.angle_alpha)\n unitcellDict.beta = parseFloat(cell.angle_beta)\n unitcellDict.gamma = parseFloat(cell.angle_gamma)\n }\n\n if (cif.symmetry) {\n unitcellDict.spacegroup = trimQuotes(\n cif.symmetry[ 'space_group_name_H-M' ]\n )\n }\n\n // origx\n var origx = new Matrix4()\n\n if (cif.database_PDB_matrix) {\n var origxMat = cif.database_PDB_matrix\n var origxElms = origx.elements\n\n origxElms[ 0 ] = parseFloat(origxMat[ 'origx[1][1]' ])\n origxElms[ 1 ] = parseFloat(origxMat[ 'origx[1][2]' ])\n origxElms[ 2 ] = parseFloat(origxMat[ 'origx[1][3]' ])\n\n origxElms[ 4 ] = parseFloat(origxMat[ 'origx[2][1]' ])\n origxElms[ 5 ] = parseFloat(origxMat[ 'origx[2][2]' ])\n origxElms[ 6 ] = parseFloat(origxMat[ 'origx[2][3]' ])\n\n origxElms[ 8 ] = parseFloat(origxMat[ 'origx[3][1]' ])\n origxElms[ 9 ] = parseFloat(origxMat[ 'origx[3][2]' ])\n origxElms[ 10 ] = parseFloat(origxMat[ 'origx[3][3]' ])\n\n origxElms[ 3 ] = parseFloat(origxMat[ 'origx_vector[1]' ])\n origxElms[ 7 ] = parseFloat(origxMat[ 'origx_vector[2]' ])\n origxElms[ 11 ] = parseFloat(origxMat[ 'origx_vector[3]' ])\n\n origx.transpose()\n\n unitcellDict.origx = origx\n }\n\n // scale\n var scale = new Matrix4()\n\n if (cif.atom_sites) {\n var scaleMat = cif.atom_sites\n var scaleElms = scale.elements\n\n scaleElms[ 0 ] = parseFloat(scaleMat[ 'fract_transf_matrix[1][1]' ])\n scaleElms[ 1 ] = parseFloat(scaleMat[ 'fract_transf_matrix[1][2]' ])\n scaleElms[ 2 ] = parseFloat(scaleMat[ 'fract_transf_matrix[1][3]' ])\n\n scaleElms[ 4 ] = parseFloat(scaleMat[ 'fract_transf_matrix[2][1]' ])\n scaleElms[ 5 ] = parseFloat(scaleMat[ 'fract_transf_matrix[2][2]' ])\n scaleElms[ 6 ] = parseFloat(scaleMat[ 'fract_transf_matrix[2][3]' ])\n\n scaleElms[ 8 ] = parseFloat(scaleMat[ 'fract_transf_matrix[3][1]' ])\n scaleElms[ 9 ] = parseFloat(scaleMat[ 'fract_transf_matrix[3][2]' ])\n scaleElms[ 10 ] = parseFloat(scaleMat[ 'fract_transf_matrix[3][3]' ])\n\n scaleElms[ 3 ] = parseFloat(scaleMat[ 'fract_transf_vector[1]' ])\n scaleElms[ 7 ] = parseFloat(scaleMat[ 'fract_transf_vector[2]' ])\n scaleElms[ 11 ] = parseFloat(scaleMat[ 'fract_transf_vector[3]' ])\n\n scale.transpose()\n\n unitcellDict.scale = scale\n }\n\n if (unitcellDict.a !== undefined) {\n structure.unitcell = new Unitcell(unitcellDict as UnitcellParams)\n } else {\n structure.unitcell = undefined\n }\n}\n\nfunction processConnections (cif: Cif, structure: Structure, asymIdDict: {[k: string]: string}) {\n // add connections\n var sc = cif.struct_conn\n\n if (sc) {\n ensureArray(sc, 'id')\n\n var reDoubleQuote = /\"/g\n var ap1 = structure.getAtomProxy()\n var ap2 = structure.getAtomProxy()\n var atomIndicesCache: {[k: string]: Uint32Array|undefined} = {}\n\n for (var i = 0, il = sc.id.length; i < il; ++i) {\n // ignore:\n // hydrog - hydrogen bond\n // mismat - mismatched base pairs\n // saltbr - ionic interaction\n\n var connTypeId = sc.conn_type_id[ i ]\n if (connTypeId === 'hydrog' ||\n connTypeId === 'mismat' ||\n connTypeId === 'saltbr') continue\n\n // ignore bonds between symmetry mates\n if (sc.ptnr1_symmetry[ i ] !== '1_555' ||\n sc.ptnr2_symmetry[ i ] !== '1_555') continue\n\n // process:\n // covale - covalent bond\n // covale_base -\n // covalent modification of a nucleotide base\n // covale_phosphate -\n // covalent modification of a nucleotide phosphate\n // covale_sugar -\n // covalent modification of a nucleotide sugar\n // disulf - disulfide bridge\n // metalc - metal coordination\n // modres - covalent residue modification\n\n var inscode1 = sc.pdbx_ptnr1_PDB_ins_code[ i ]\n var altloc1 = sc.pdbx_ptnr1_label_alt_id[ i ]\n var sele1 = (\n sc.ptnr1_auth_seq_id[ i ] +\n (hasValue(inscode1) ? ('^' + inscode1) : '') +\n ':' + asymIdDict[ sc.ptnr1_label_asym_id[ i ] ] +\n '.' + sc.ptnr1_label_atom_id[ i ].replace(reDoubleQuote, '') +\n (hasValue(altloc1) ? ('%' + altloc1) : '')\n )\n var atomIndices1 = atomIndicesCache[ sele1 ]\n if (!atomIndices1) {\n var selection1 = new Selection(sele1)\n if (selection1.selection.error) {\n if (Debug) Log.warn('invalid selection for connection', sele1)\n continue\n }\n atomIndices1 = structure.getAtomIndices(selection1)\n atomIndicesCache[ sele1 ] = atomIndices1\n }\n\n var inscode2 = sc.pdbx_ptnr2_PDB_ins_code[ i ]\n var altloc2 = sc.pdbx_ptnr2_label_alt_id[ i ]\n var sele2 = (\n sc.ptnr2_auth_seq_id[ i ] +\n (hasValue(inscode2) ? ('^' + inscode2) : '') +\n ':' + asymIdDict[ sc.ptnr2_label_asym_id[ i ] ] +\n '.' + sc.ptnr2_label_atom_id[ i ].replace(reDoubleQuote, '') +\n (hasValue(altloc2) ? ('%' + altloc2) : '')\n )\n var atomIndices2 = atomIndicesCache[ sele2 ]\n if (!atomIndices2) {\n var selection2 = new Selection(sele2)\n if (selection2.selection.error) {\n if (Debug) Log.warn('invalid selection for connection', sele2)\n continue\n }\n atomIndices2 = structure.getAtomIndices(selection2)\n atomIndicesCache[ sele2 ] = atomIndices2\n }\n\n // cases with more than one atom per selection\n // - #altloc1 to #altloc2\n // - #model to #model\n // - #altloc1 * #model to #altloc2 * #model\n\n var k = atomIndices1!.length\n var l = atomIndices2!.length\n\n if (k > l) {\n var tmpA = k\n k = l\n l = tmpA\n var tmpB = atomIndices1\n atomIndices1 = atomIndices2\n atomIndices2 = tmpB\n }\n\n // console.log( k, l );\n\n if (k === 0 || l === 0) {\n if (Debug) Log.warn('no atoms found for', sele1, sele2)\n continue\n }\n\n for (var j = 0; j < l; ++j) {\n ap1.index = atomIndices1![ j % k ]\n ap2.index = atomIndices2![ j ]\n\n if (ap1 && ap2) {\n structure.bondStore.addBond(\n ap1, ap2, getBondOrder(sc.pdbx_value_order[ i ])\n )\n } else {\n Log.log('atoms for connection not found')\n }\n }\n }\n }\n}\n\nfunction processEntities (cif: Cif, structure: Structure, chainIndexDict: {[k: string]: Set}) {\n if (cif.entity) {\n ensureArray(cif.entity, 'id')\n var e = cif.entity\n var n = e.id.length\n for (var i = 0; i < n; ++i) {\n var description = e.pdbx_description[ i ]\n var type = e.type[ i ]\n var chainIndexList: number[] = Array.from(chainIndexDict[ e.id[ i ] ])\n structure.entityList[ i ] = new Entity(\n structure, i, description, type, chainIndexList\n )\n }\n }\n}\n\n//\n\nclass CifParser extends StructureParser {\n get type () { return 'cif' }\n\n _parse () {\n // http://mmcif.wwpdb.org/\n\n Log.time('CifParser._parse ' + this.name)\n\n var s = this.structure\n var sb = this.structureBuilder\n\n var firstModelOnly = this.firstModelOnly\n var asTrajectory = this.asTrajectory\n var cAlphaOnly = this.cAlphaOnly\n\n var frames = s.frames\n var currentFrame: NumberArray, currentCoord: number\n\n var rawline, line\n\n //\n\n var cif: Cif = {}\n var asymIdDict: {[k: string]: string} = {}\n var chainIndexDict:{[k: string]: Set} = {}\n\n var pendingString = false\n var currentString: string|null = null\n var pendingValue = false\n var pendingLoop = false\n var pendingName = false\n var loopPointers: string[][] = []\n var currentLoopIndex: number|null = null\n var currentCategory: string|null = null\n var currentName: string|boolean|null = null\n var first: boolean|null = null\n var pointerNames: string[] = []\n\n var authAsymId: number, authSeqId: number, labelSeqId: number,\n labelAtomId: number, labelCompId: number, labelAsymId: number, labelEntityId: number, labelAltId: number,\n groupPDB: number, id: number, typeSymbol: number, pdbxPDBmodelNum: number, pdbxPDBinsCode: number,\n CartnX: number, CartnY: number, CartnZ: number, bIsoOrEquiv: number, occupancy: number\n\n //\n\n var atomMap = s.atomMap\n var atomStore = s.atomStore\n atomStore.resize(this.streamer.data.length / 100)\n\n var idx = 0\n var modelIdx = 0\n var modelNum: number\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (var i = _i; i < _n; ++i) {\n rawline = lines[i]\n line = rawline.trim()\n\n if ((!line && !pendingString && !pendingLoop) || line[0] === '#') {\n // Log.log( \"NEW BLOCK\" );\n\n pendingString = false\n pendingLoop = false\n pendingValue = false\n loopPointers.length = 0\n currentLoopIndex = null\n currentCategory = null\n currentName = null\n first = null\n pointerNames.length = 0\n } else if (line.substring(0, 5) === 'data_') {\n cif.data = line.substring(5).trim()\n\n // Log.log( \"DATA\", data );\n } else if (line[0] === ';') {\n if (pendingString) {\n // Log.log( \"STRING END\", currentString );\n\n if (pendingLoop) {\n if (currentLoopIndex === loopPointers.length) {\n currentLoopIndex = 0\n }\n loopPointers[ currentLoopIndex as number ].push(currentString as string);\n (currentLoopIndex as number) += 1\n } else {\n if (currentName === false) {\n cif[ currentCategory as string ] = currentString\n } else {\n cif[ currentCategory as string ][ currentName as string ] = currentString //TODO currentname can equals null\n }\n }\n\n pendingString = false\n currentString = null\n } else {\n // Log.log( \"STRING START\" );\n\n pendingString = true\n currentString = line.substring(1)\n }\n } else if (line === 'loop_') {\n // Log.log( \"LOOP START\" );\n\n pendingLoop = true\n pendingName = true\n loopPointers.length = 0\n pointerNames.length = 0\n currentLoopIndex = 0\n } else if (line[0] === '_') {\n var keyParts, category, name\n\n if (pendingLoop && !pendingName) {\n pendingLoop = false\n }\n\n if (pendingLoop) {\n // Log.log( \"LOOP KEY\", line );\n\n keyParts = line.split('.')\n category = keyParts[ 0 ].substring(1)\n name = keyParts[ 1 ]\n\n if (keyParts.length === 1) {\n name = false\n if (!cif[ category ]) cif[ category ] = []\n loopPointers.push(cif[ category ])\n } else {\n if (!cif[ category ]) cif[ category ] = {}\n if (cif[ category ][ name ]) {\n if (Debug) Log.warn(category, name, 'already exists')\n } else {\n cif[ category ][ name ] = []\n loopPointers.push(cif[ category ][ name ])\n pointerNames.push(name)\n }\n }\n\n currentCategory = category\n currentName = name\n first = true\n } else {\n var keyValuePair = line.match(reQuotedWhitespace)\n var key = keyValuePair![ 0 ]\n var value = keyValuePair![ 1 ]\n keyParts = key.split('.')\n category = keyParts[ 0 ].substring(1)\n name = keyParts[ 1 ]\n\n if (keyParts.length === 1) {\n name = false\n cif[ category ] = value\n } else {\n if (!cif[ category ]) cif[ category ] = {}\n\n if (cif[ category ][ name ]) {\n if (Debug) Log.warn(category, name, 'already exists')\n } else {\n cif[ category ][ name ] = value\n }\n }\n\n if (!value) pendingValue = true\n\n currentCategory = category\n currentName = name\n }\n } else {\n if (pendingString) {\n // Log.log( \"STRING VALUE\", line );\n\n currentString += rawline\n } else if (pendingLoop) {\n // Log.log( \"LOOP VALUE\", line );\n\n if (!line) {\n continue\n } else if (currentCategory === 'atom_site') {\n const ls = line.split(reWhitespace)\n\n if (first) {\n authAsymId = pointerNames.indexOf('auth_asym_id')\n authSeqId = pointerNames.indexOf('auth_seq_id')\n labelSeqId = pointerNames.indexOf('label_seq_id')\n labelAtomId = pointerNames.indexOf('label_atom_id')\n labelCompId = pointerNames.indexOf('label_comp_id')\n labelAsymId = pointerNames.indexOf('label_asym_id')\n labelEntityId = pointerNames.indexOf('label_entity_id')\n labelAltId = pointerNames.indexOf('label_alt_id')\n CartnX = pointerNames.indexOf('Cartn_x')\n CartnY = pointerNames.indexOf('Cartn_y')\n CartnZ = pointerNames.indexOf('Cartn_z')\n id = pointerNames.indexOf('id')\n typeSymbol = pointerNames.indexOf('type_symbol')\n groupPDB = pointerNames.indexOf('group_PDB')\n bIsoOrEquiv = pointerNames.indexOf('B_iso_or_equiv')\n pdbxPDBmodelNum = pointerNames.indexOf('pdbx_PDB_model_num')\n\n pdbxPDBinsCode = pointerNames.indexOf('pdbx_PDB_ins_code')\n occupancy = pointerNames.indexOf('occupancy')\n\n first = false\n\n modelNum = parseInt(ls[ pdbxPDBmodelNum ])\n\n if (asTrajectory) {\n currentFrame = []\n currentCoord = 0\n }\n }\n\n //\n\n const _modelNum = parseInt(ls[ pdbxPDBmodelNum ])\n\n if (modelNum !== _modelNum) {\n if (asTrajectory) {\n if (modelIdx === 0) {\n frames.push(new Float32Array(currentFrame))\n }\n\n currentFrame = new Float32Array(atomStore.count * 3)\n frames.push(currentFrame)\n currentCoord = 0\n }\n\n modelIdx += 1\n }\n\n modelNum = _modelNum\n\n if (firstModelOnly && modelIdx > 0) continue\n\n //\n\n const atomname = ls[ labelAtomId ].replace(reDoubleQuote, '')\n if (cAlphaOnly && atomname !== 'CA') continue\n\n const x = parseFloat(ls[ CartnX ])\n const y = parseFloat(ls[ CartnY ])\n const z = parseFloat(ls[ CartnZ ])\n\n if (asTrajectory) {\n const frameOffset = currentCoord * 3\n\n currentFrame[ frameOffset + 0 ] = x\n currentFrame[ frameOffset + 1 ] = y\n currentFrame[ frameOffset + 2 ] = z\n\n currentCoord += 1\n\n if (modelIdx > 0) continue\n }\n\n //\n\n const resname = ls[ labelCompId ]\n const resno = parseInt(ls[ authSeqId !== -1 ? authSeqId : labelSeqId ])\n let inscode = ls[ pdbxPDBinsCode ]\n inscode = (inscode === '?') ? '' : inscode\n const chainname = ls[ authAsymId ]\n const chainid = ls[ labelAsymId ]\n const hetero = (ls[ groupPDB ][ 0 ] === 'H')\n\n //\n\n const element = ls[ typeSymbol ]\n const bfactor = parseFloat(ls[ bIsoOrEquiv ])\n const occ = parseFloat(ls[ occupancy ])\n let altloc = ls[ labelAltId ]\n altloc = (altloc === '.') ? '' : altloc\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname, element)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = parseInt(ls[ id ])\n atomStore.bfactor[ idx ] = isNaN(bfactor) ? 0 : bfactor\n atomStore.occupancy[ idx ] = isNaN(occ) ? 0 : occ\n atomStore.altloc[ idx ] = altloc.charCodeAt(0)\n\n sb.addAtom(modelIdx, chainname, chainid, resname, resno, hetero, undefined, inscode)\n\n if (Debug) {\n // check if one-to-many (chainname-asymId) relationship is\n // actually a many-to-many mapping\n const assignedChainname = asymIdDict[ chainid ]\n if (assignedChainname !== undefined && assignedChainname !== chainname) {\n if (Debug) Log.warn(assignedChainname, chainname)\n }\n }\n // chainname mapping: label_asym_id -> auth_asym_id\n asymIdDict[ chainid ] = chainname\n\n // entity mapping: chainIndex -> label_entity_id\n const entityId = ls[ labelEntityId ]\n if (!chainIndexDict[ entityId ]) {\n chainIndexDict[ entityId ] = new Set()\n }\n chainIndexDict[ entityId ].add(s.chainStore.count - 1)\n\n idx += 1\n } else {\n const ls = line.match(reQuotedWhitespace)\n const nn = ls!.length\n\n if (currentLoopIndex === loopPointers.length) {\n currentLoopIndex = 0\n }/* else if( currentLoopIndex + nn > loopPointers.length ){\n Log.warn( \"cif parsing error, wrong number of loop data entries\", nn, loopPointers.length );\n } */\n\n for (let j = 0; j < nn; ++j) {\n loopPointers[ currentLoopIndex + j ].push(ls![ j ])\n }\n\n (currentLoopIndex) += nn\n }\n\n pendingName = false\n } else if (line[0] === \"'\" && line[line.length - 1] === \"'\") {\n // Log.log( \"NEWLINE STRING\", line );\n\n const str = line.substring(1, line.length - 1)\n\n if (currentName === false) {\n cif[ currentCategory as string ] = str\n } else {\n cif[ currentCategory as string ][ currentName as string ] = str\n }\n } else if (pendingValue) {\n // Log.log( \"NEWLINE VALUE\", line );\n\n if (currentName === false) {\n cif[ currentCategory as string ] = line\n } else {\n cif[ currentCategory as string ][ currentName as string ] = line\n }\n } else {\n if (Debug) Log.log('CifParser._parse: unknown state', line)\n }\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n if (cif.chem_comp && cif.chem_comp_atom && !cif.struct) {\n parseChemComp(cif, s, sb)\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n assignResidueTypeBonds(s)\n } else if (cif.atom_site_type_symbol && cif.atom_site_label && cif.atom_site_fract_x) {\n parseCore(cif, s, sb)\n sb.finalize()\n s.finalizeAtoms()\n calculateBonds(s)\n s.finalizeBonds()\n // assignResidueTypeBonds( s );\n } else {\n var secStruct = processSecondaryStructure(cif, s, asymIdDict)\n processSymmetry(cif, s, asymIdDict)\n processConnections(cif, s, asymIdDict)\n processEntities(cif, s, chainIndexDict)\n\n if (cif.struct && cif.struct.title) {\n s.title = cif.struct.title.trim().replace(reTrimQuotes, '')\n }\n if (cif.entry && cif.entry.id) {\n s.id = cif.entry.id.trim().replace(reTrimQuotes, '')\n }\n\n // structure header (mimicking biojava)\n if (cif.pdbx_audit_revision_history) {\n if (cif.pdbx_audit_revision_history.revision_date) {\n ensureArray(cif.pdbx_audit_revision_history, 'revision_date')\n const dates = cif.pdbx_audit_revision_history.revision_date.filter(hasValue)\n if (dates.length) {\n s.header.releaseDate = dates[ 0 ]\n }\n }\n if (cif.pdbx_database_status.recvd_initial_deposition_date) {\n ensureArray(cif.pdbx_database_status, 'recvd_initial_deposition_date')\n const depDates = cif.pdbx_database_status.recvd_initial_deposition_date.filter(hasValue)\n if (depDates.length) {\n s.header.depositionDate = depDates[ 0 ]\n }\n }\n } else if (cif.database_PDB_rev) {\n if (cif.database_PDB_rev.date) {\n ensureArray(cif.database_PDB_rev, 'date')\n const dates = cif.database_PDB_rev.date.filter(hasValue)\n if (dates.length) {\n s.header.releaseDate = dates[ 0 ]\n }\n }\n if (cif.database_PDB_rev.date_original) {\n ensureArray(cif.database_PDB_rev, 'date_original')\n const depDates = cif.database_PDB_rev.date_original.filter(hasValue)\n if (depDates.length) {\n s.header.depositionDate = depDates[ 0 ]\n }\n }\n }\n if (cif.reflns && cif.reflns.d_resolution_high) {\n if (hasValue(cif.reflns.d_resolution_high)) {\n s.header.resolution = parseFloat(cif.reflns.d_resolution_high)\n }\n } else if (cif.refine && cif.refine.ls_d_res_high) {\n if (hasValue(cif.refine.ls_d_res_high)) {\n s.header.resolution = parseFloat(cif.refine.ls_d_res_high)\n }\n }\n if (cif.refine && cif.refine.ls_R_factor_R_free) {\n if (hasValue(cif.refine.ls_R_factor_R_free)) {\n s.header.rFree = parseFloat(cif.refine.ls_R_factor_R_free)\n }\n }\n if (cif.refine && cif.refine.ls_R_factor_R_work) {\n if (hasValue(cif.refine.ls_R_factor_R_work)) {\n s.header.rWork = parseFloat(cif.refine.ls_R_factor_R_work)\n }\n }\n if (cif.exptl && cif.exptl.method) {\n ensureArray(cif.exptl, 'method')\n s.header.experimentalMethods = cif.exptl.method.map(function (m: string) {\n return m.replace(reTrimQuotes, '')\n })\n }\n\n sb.finalize()\n s.finalizeAtoms()\n calculateBonds(s)\n s.finalizeBonds()\n\n if (!secStruct) {\n calculateSecondaryStructure(s)\n } else {\n assignSecondaryStructure(s, secStruct)\n }\n buildUnitcellAssembly(s)\n\n s.extraData.cif = cif\n }\n\n if (Debug) Log.timeEnd('CifParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('cif', CifParser)\nParserRegistry.add('mcif', CifParser)\nParserRegistry.add('mmcif', CifParser)\n\nexport default CifParser\n","/**\n * @file Gro Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport {\n calculateBonds, calculateChainnames, calculateSecondaryStructure\n} from '../structure/structure-utils'\n\nclass GroParser extends StructureParser {\n get type () { return 'gro' }\n\n _parse () {\n // http://manual.gromacs.org/current/online/gro.html\n\n if (Debug) Log.time('GroParser._parse ' + this.name)\n\n var s = this.structure\n var sb = this.structureBuilder\n\n var firstModelOnly = this.firstModelOnly\n var asTrajectory = this.asTrajectory\n var cAlphaOnly = this.cAlphaOnly\n\n var frames = s.frames\n var boxes = s.boxes\n var currentFrame: Float32Array, currentCoord: number\n\n var firstLines = this.streamer.peekLines(3)\n\n s.title = firstLines[ 0 ].trim()\n\n // determine number of decimal places\n var ndec = firstLines[ 2 ].length - firstLines[ 2 ].lastIndexOf('.') - 1\n var lpos = 5 + ndec\n var xpos = 20\n var ypos = 20 + lpos\n var zpos = 20 + 2 * lpos\n\n //\n\n var atomname, resname, resno, serial\n\n var atomCount = parseInt(firstLines[ 1 ])\n var modelLineCount = atomCount + 3\n\n var atomMap = s.atomMap\n var atomStore = s.atomStore\n atomStore.resize(atomCount)\n\n var idx = 0\n var modelIdx = 0\n var lineNo = 0\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (var i = _i; i < _n; ++i) {\n ++lineNo\n var l = lineNo - 1\n\n var line = lines[ i ]\n\n if (!line) continue\n\n if (l % modelLineCount === 0) {\n // Log.log( \"title\", line )\n\n if (asTrajectory) {\n currentFrame = new Float32Array(atomCount * 3)\n frames.push(currentFrame)\n currentCoord = 0\n }\n } else if (l % modelLineCount === 1) {\n\n // Log.log( \"atomCount\", line )\n\n } else if (l % modelLineCount === modelLineCount - 1) {\n var str = line.trim().split(/\\s+/)\n var box = new Float32Array(9)\n box[ 0 ] = parseFloat(str[ 0 ]) * 10\n box[ 4 ] = parseFloat(str[ 1 ]) * 10\n box[ 8 ] = parseFloat(str[ 2 ]) * 10\n boxes.push(box)\n\n if (firstModelOnly) {\n return true\n }\n\n modelIdx += 1\n } else {\n atomname = line.substr(10, 5).trim()\n if (cAlphaOnly && atomname !== 'CA') continue\n\n var x = parseFloat(line.substr(xpos, lpos)) * 10\n var y = parseFloat(line.substr(ypos, lpos)) * 10\n var z = parseFloat(line.substr(zpos, lpos)) * 10\n\n if (asTrajectory) {\n var j = currentCoord * 3\n\n currentFrame[ j + 0 ] = x\n currentFrame[ j + 1 ] = y\n currentFrame[ j + 2 ] = z\n\n currentCoord += 1\n\n if (l > modelLineCount) continue\n }\n\n resname = line.substr(5, 5).trim()\n resno = parseInt(line.substr(0, 5))\n serial = parseInt(line.substr(15, 5))\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = serial\n\n sb.addAtom(modelIdx, '', '', resname, resno, false, 'l')\n\n idx += 1\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n sb.finalize()\n s.finalizeAtoms()\n calculateChainnames(s)\n calculateBonds(s)\n s.finalizeBonds()\n\n calculateSecondaryStructure(s)\n\n if (Debug) Log.timeEnd('GroParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('gro', GroParser)\n\nexport default GroParser\n","/**\n * @file utf8-utils\n * @private\n * @author Alexander Rose \n * mostly copied from https://github.com/creationix/msgpack-js-browser\n * by Tim Caswell , MIT License, Copyright (c) 2013\n */\n\n\n// Encode string as utf8 into dataview at offset\nfunction utf8Write(view, offset, string) {\n var byteLength = view.byteLength;\n for(var i = 0, l = string.length; i < l; i++) {\n var codePoint = string.charCodeAt(i);\n\n // One byte of UTF-8\n if (codePoint < 0x80) {\n view.setUint8(offset++, codePoint >>> 0 & 0x7f | 0x00);\n continue;\n }\n\n // Two bytes of UTF-8\n if (codePoint < 0x800) {\n view.setUint8(offset++, codePoint >>> 6 & 0x1f | 0xc0);\n view.setUint8(offset++, codePoint >>> 0 & 0x3f | 0x80);\n continue;\n }\n\n // Three bytes of UTF-8.\n if (codePoint < 0x10000) {\n view.setUint8(offset++, codePoint >>> 12 & 0x0f | 0xe0);\n view.setUint8(offset++, codePoint >>> 6 & 0x3f | 0x80);\n view.setUint8(offset++, codePoint >>> 0 & 0x3f | 0x80);\n continue;\n }\n\n // Four bytes of UTF-8\n if (codePoint < 0x110000) {\n view.setUint8(offset++, codePoint >>> 18 & 0x07 | 0xf0);\n view.setUint8(offset++, codePoint >>> 12 & 0x3f | 0x80);\n view.setUint8(offset++, codePoint >>> 6 & 0x3f | 0x80);\n view.setUint8(offset++, codePoint >>> 0 & 0x3f | 0x80);\n continue;\n }\n throw new Error(\"bad codepoint \" + codePoint);\n }\n}\n\nfunction utf8ByteCount(string) {\n var count = 0;\n for(var i = 0, l = string.length; i < l; i++) {\n var codePoint = string.charCodeAt(i);\n if (codePoint < 0x80) {\n count += 1;\n continue;\n }\n if (codePoint < 0x800) {\n count += 2;\n continue;\n }\n if (codePoint < 0x10000) {\n count += 3;\n continue;\n }\n if (codePoint < 0x110000) {\n count += 4;\n continue;\n }\n throw new Error(\"bad codepoint \" + codePoint);\n }\n return count;\n}\n\n/**\n * encode data value (recursively) into binary encoded MessagePack v5 (http://msgpack.org/)\n * @param {Object|Array|String|Number|Boolean|null} value [description]\n * @param {DataView} view [description]\n * @param {Integer} offset [description]\n * @return {Integer} number of bytes written into view\n */\nfunction encode$1(value, view, offset) {\n var type = typeof value;\n\n // Strings Bytes\n if (type === \"string\") {\n var length = utf8ByteCount(value);\n // fix str\n if (length < 0x20) {\n view.setUint8(offset, length | 0xa0);\n utf8Write(view, offset + 1, value);\n return 1 + length;\n }\n // str 8\n if (length < 0x100) {\n view.setUint8(offset, 0xd9);\n view.setUint8(offset + 1, length);\n utf8Write(view, offset + 2, value);\n return 2 + length;\n }\n // str 16\n if (length < 0x10000) {\n view.setUint8(offset, 0xda);\n view.setUint16(offset + 1, length);\n utf8Write(view, offset + 3, value);\n return 3 + length;\n }\n // str 32\n if (length < 0x100000000) {\n view.setUint8(offset, 0xdb);\n view.setUint32(offset + 1, length);\n utf8Write(view, offset + 5, value);\n return 5 + length;\n }\n }\n\n if (value instanceof Uint8Array) {\n var length = value.byteLength;\n var bytes = new Uint8Array(view.buffer);\n // bin 8\n if (length < 0x100) {\n view.setUint8(offset, 0xc4);\n view.setUint8(offset + 1, length);\n bytes.set(value, offset + 2);\n return 2 + length;\n }\n // bin 16\n if (length < 0x10000) {\n view.setUint8(offset, 0xc5);\n view.setUint16(offset + 1, length);\n bytes.set(value, offset + 3);\n return 3 + length;\n }\n // bin 32\n if (length < 0x100000000) {\n view.setUint8(offset, 0xc6);\n view.setUint32(offset + 1, length);\n bytes.set(value, offset + 5);\n return 5 + length;\n }\n }\n\n if (type === \"number\") {\n if (!isFinite(value)) {\n throw new Error(\"Number not finite: \" + value);\n }\n\n // Floating point\n if (Math.floor(value) !== value) {\n view.setUint8(offset, 0xcb);\n view.setFloat64(offset + 1, value);\n return 9;\n }\n\n // Integers\n if (value >=0) {\n // positive fixnum\n if (value < 0x80) {\n view.setUint8(offset, value);\n return 1;\n }\n // uint 8\n if (value < 0x100) {\n view.setUint8(offset, 0xcc);\n view.setUint8(offset + 1, value);\n return 2;\n }\n // uint 16\n if (value < 0x10000) {\n view.setUint8(offset, 0xcd);\n view.setUint16(offset + 1, value);\n return 3;\n }\n // uint 32\n if (value < 0x100000000) {\n view.setUint8(offset, 0xce);\n view.setUint32(offset + 1, value);\n return 5;\n }\n throw new Error(\"Number too big 0x\" + value.toString(16));\n }\n // negative fixnum\n if (value >= -0x20) {\n view.setInt8(offset, value);\n return 1;\n }\n // int 8\n if (value >= -0x80) {\n view.setUint8(offset, 0xd0);\n view.setInt8(offset + 1, value);\n return 2;\n }\n // int 16\n if (value >= -0x8000) {\n view.setUint8(offset, 0xd1);\n view.setInt16(offset + 1, value);\n return 3;\n }\n // int 32\n if (value >= -0x80000000) {\n view.setUint8(offset, 0xd2);\n view.setInt32(offset + 1, value);\n return 5;\n }\n throw new Error(\"Number too small -0x\" + (-value).toString(16).substr(1));\n }\n\n // null\n if (value === null) {\n view.setUint8(offset, 0xc0);\n return 1;\n }\n\n // Boolean\n if (type === \"boolean\") {\n view.setUint8(offset, value ? 0xc3 : 0xc2);\n return 1;\n }\n\n // Container Types\n if (type === \"object\") {\n var length, size = 0;\n var isArray = Array.isArray(value);\n\n if (isArray) {\n length = value.length;\n }\n else {\n var keys = Object.keys(value);\n length = keys.length;\n }\n\n var size;\n if (length < 0x10) {\n view.setUint8(offset, length | (isArray ? 0x90 : 0x80));\n size = 1;\n }\n else if (length < 0x10000) {\n view.setUint8(offset, isArray ? 0xdc : 0xde);\n view.setUint16(offset + 1, length);\n size = 3;\n }\n else if (length < 0x100000000) {\n view.setUint8(offset, isArray ? 0xdd : 0xdf);\n view.setUint32(offset + 1, length);\n size = 5;\n }\n\n if (isArray) {\n for (var i = 0; i < length; i++) {\n size += encode$1(value[i], view, offset + size);\n }\n }\n else {\n for (var i = 0; i < length; i++) {\n var key = keys[i];\n size += encode$1(key, view, offset + size);\n size += encode$1(value[key], view, offset + size);\n }\n }\n\n return size;\n }\n throw new Error(\"Unknown type \" + type);\n}\n\nfunction encodedSize(value) {\n var type = typeof value;\n\n // Raw Bytes\n if (type === \"string\") {\n var length = utf8ByteCount(value);\n if (length < 0x20) {\n return 1 + length;\n }\n if (length < 0x100) {\n return 2 + length;\n }\n if (length < 0x10000) {\n return 3 + length;\n }\n if (length < 0x100000000) {\n return 5 + length;\n }\n }\n\n if (value instanceof Uint8Array) {\n var length = value.byteLength;\n if (length < 0x100) {\n return 2 + length;\n }\n if (length < 0x10000) {\n return 3 + length;\n }\n if (length < 0x100000000) {\n return 5 + length;\n }\n }\n\n if (type === \"number\") {\n // Floating Point\n // double\n if (Math.floor(value) !== value) return 9;\n\n // Integers\n if (value >=0) {\n // positive fixnum\n if (value < 0x80) return 1;\n // uint 8\n if (value < 0x100) return 2;\n // uint 16\n if (value < 0x10000) return 3;\n // uint 32\n if (value < 0x100000000) return 5;\n throw new Error(\"Number too big 0x\" + value.toString(16));\n }\n // negative fixnum\n if (value >= -0x20) return 1;\n // int 8\n if (value >= -0x80) return 2;\n // int 16\n if (value >= -0x8000) return 3;\n // int 32\n if (value >= -0x80000000) return 5;\n throw new Error(\"Number too small -0x\" + value.toString(16).substr(1));\n }\n\n // Boolean, null\n if (type === \"boolean\" || value === null) return 1;\n\n // Container Types\n if (type === \"object\") {\n var length, size = 0;\n if (Array.isArray(value)) {\n length = value.length;\n for (var i = 0; i < length; i++) {\n size += encodedSize(value[i]);\n }\n }\n else {\n var keys = Object.keys(value);\n length = keys.length;\n for (var i = 0; i < length; i++) {\n var key = keys[i];\n size += encodedSize(key) + encodedSize(value[key]);\n }\n }\n if (length < 0x10) {\n return 1 + size;\n }\n if (length < 0x10000) {\n return 3 + size;\n }\n if (length < 0x100000000) {\n return 5 + size;\n }\n throw new Error(\"Array or object too long 0x\" + length.toString(16));\n }\n throw new Error(\"Unknown type \" + type);\n}\n\nfunction encodeMsgpack(value) {\n var buffer = new ArrayBuffer(encodedSize(value));\n var view = new DataView(buffer);\n encode$1(value, view, 0);\n return new Uint8Array(buffer);\n}\n\n/**\n * @file mmtf-constants\n * @private\n * @author Alexander Rose \n */\n\n\nvar PassThroughFields = [\n \"mmtfVersion\", \"mmtfProducer\",\n \"unitCell\", \"spaceGroup\", \"structureId\", \"title\",\n \"depositionDate\", \"releaseDate\",\n \"experimentalMethods\", \"resolution\", \"rFree\", \"rWork\",\n \"bioAssemblyList\", \"ncsOperatorList\", \"entityList\", \"groupList\",\n \"numBonds\", \"numAtoms\", \"numGroups\", \"numChains\", \"numModels\",\n \"groupsPerChain\", \"chainsPerModel\",\n];\n\nvar EncodedFields = [\n\t// required\n \"xCoordList\", \"yCoordList\", \"zCoordList\",\n \"groupIdList\", \"groupTypeList\",\n \"chainIdList\",\n // optional\n \"bFactorList\", \"atomIdList\", \"altLocList\", \"occupancyList\",\n \"secStructList\", \"insCodeList\", \"sequenceIndexList\",\n \"chainNameList\",\n \"bondAtomList\", \"bondOrderList\"\n];\n\nvar AllFields = PassThroughFields.concat( EncodedFields );\n\n/**\n * @file mmtf-utils\n * @private\n * @author Alexander Rose \n */\n\n/**\n * mmtf utils module.\n * @module MmtfUtils\n */\n\n\nfunction getView( ctor, typedArray, elemSize ){\n return typedArray ? new ctor(\n typedArray.buffer,\n typedArray.byteOffset,\n typedArray.byteLength / ( elemSize || 1 )\n ) : undefined;\n}\n\nfunction getDataView( typedArray ){\n return getView( DataView, typedArray );\n}\n\n/**\n * get an Uint8Array view on the input array memory\n * @static\n * @param {TypedArray} dataArray - input array\n * @return {Uint8Array} new view on the input array memory\n */\nfunction getUint8View( typedArray ){\n return getView( Uint8Array, typedArray );\n}\n\n/**\n * get an Int8Array view on the input array memory\n * @static\n * @param {TypedArray} dataArray - input array\n * @return {Int8Array} new view on the input array memory\n */\nfunction getInt8View( typedArray ){\n return getView( Int8Array, typedArray );\n}\n\n/**\n * get an Int32Array view on the input array memory\n * @static\n * @param {TypedArray} dataArray - input array\n * @return {Int32Array} new view on the input array memory\n */\nfunction getInt32View( typedArray ){\n return getView( Int32Array, typedArray, 4 );\n}\n\nfunction getFloat32View( typedArray ){\n return getView( Float32Array, typedArray, 4 );\n}\n\n\n/**\n * get an Int16Array copy of the the input array data\n * @static\n * @param {TypedArray} view - input data in big endian format\n * @param {Int16Array} [dataArray] - pre-allocated output array\n * @return {Int16Array} copy of the input array data\n */\nfunction decodeInt16( bytes, output ){\n var n = bytes.length / 2;\n if( !output ) output = new Int16Array( n );\n for( var i = 0, i2 = 0; i < n; ++i, i2 += 2 ){\n output[ i ] = bytes[ i2 ] << 8 ^ bytes[ i2 + 1 ] << 0;\n }\n return output;\n}\n\n/**\n * make big endian buffer of an int16 array\n * @static\n * @param {Array|TypedArray} array - array of int16 values\n * @return {ArrayBuffer} big endian buffer\n */\nfunction encodeInt16( array, output ){\n var n = array.length;\n if( !output ) output = new Uint8Array( 2 * n );\n var dv = getDataView( output );\n for( var i = 0; i < n; ++i ){\n dv.setInt16( 2 * i, array[ i ] );\n }\n return getUint8View( output );\n}\n\n/**\n * get an Int32Array copy of the the input array data\n * @static\n * @param {TypedArray} view - input data in big endian format\n * @param {Int32Array} [dataArray] - pre-allocated output array\n * @return {Int32Array} copy of the input array data\n */\nfunction decodeInt32( bytes, output ){\n var n = bytes.length / 4;\n if( !output ) output = new Int32Array( n );\n for( var i = 0, i4 = 0; i < n; ++i, i4 += 4 ){\n output[ i ] = (\n bytes[ i4 ] << 24 ^ bytes[ i4 + 1 ] << 16 ^\n bytes[ i4 + 2 ] << 8 ^ bytes[ i4 + 3 ] << 0\n );\n }\n return output;\n}\n\n/**\n * make big endian buffer of an int32 array\n * @static\n * @param {Array|TypedArray} array - array of int32 values\n * @return {ArrayBuffer} big endian buffer\n */\nfunction encodeInt32( array, output ){\n var n = array.length;\n if( !output ) output = new Uint8Array( 4 * n );\n var dv = getDataView( output );\n for( var i = 0; i < n; ++i ){\n dv.setInt32( 4 * i, array[ i ] );\n }\n return getUint8View( output );\n}\n\nfunction decodeFloat32( bytes, output ){\n var n = bytes.length;\n if( !output ) output = new Float32Array( n / 4 );\n var dvOut = getDataView( output );\n var dvIn = getDataView( bytes );\n for( var i = 0, i4 = 0, il = n / 4; i < il; ++i, i4 += 4 ){\n dvOut.setFloat32( i4, dvIn.getFloat32( i4 ), true );\n }\n return output;\n}\n\n/**\n * decode integers into floats using given divisor\n * example:\n * intArray: [ 12, 34, 543, 687, 2, 0, 4689 ]\n * divisor: 100\n * return: [ 0.12, 0.34, 5.43, 6.87, 0.02, 0.00, 46.89 ]\n * @static\n * @param {TypedArray|Array} intArray - input array containing integers\n * @param {Number} divisor - number to devide the integers to obtain floats\n * @param {Float32Array} [dataArray] - pre-allocated output array\n * @return {Float32Array} decoded array\n */\nfunction decodeInteger( intArray, divisor, output ){\n var n = intArray.length;\n var invDiv = 1/divisor;\n if( !output ) output = new Float32Array( n );\n for( var i = 0; i < n; ++i ){\n // multiply by inverse of the divisor which is faster then division\n output[ i ] = intArray[ i ] * invDiv;\n }\n return output;\n}\n\nfunction encodeInteger( floatArray, factor, output ){\n var n = floatArray.length;\n if( !output ) output = new Int32Array( n );\n for( var i = 0; i < n; ++i ){\n output[ i ] = Math.round( floatArray[ i ] * factor );\n }\n return output;\n}\n\n\n\n/**\n * perform run-length decoding of input array\n * example:\n * array: [ 0, 2, 3, 5 ] // pairs of values and length of a run\n * return: [ 0, 0, 3, 3, 3, 3, 3 ]\n * @static\n * @param {TypedArray|Array} array - run-length encoded input array\n * @param {TypedArray|Array} [dataArray] - pre-allocated output array\n * @return {TypedArray|Array} decoded array\n */\nfunction decodeRun( array, output ){\n var i, il;\n if( !output ){\n // calculate the length the decoded array will have\n var fullLength = 0;\n for( i = 0, il = array.length; i < il; i+=2 ){\n fullLength += array[ i + 1 ];\n }\n // create a new array of the same type of the input array\n output = new array.constructor( fullLength );\n }\n var dataOffset = 0;\n for( i = 0, il = array.length; i < il; i+=2 ){\n var value = array[ i ]; // value to be repeated\n var length = array[ i + 1 ]; // number of repeats\n for( var j = 0; j < length; ++j ){\n output[ dataOffset ] = value;\n ++dataOffset;\n }\n }\n return output;\n}\n\nfunction encodeRun( array ){\n if( array.length === 0 ) return new Int32Array();\n var i, il;\n // calculate output size\n var fullLength = 2;\n for( i = 1, il = array.length; i < il; ++i ){\n if( array[ i - 1 ] !== array[ i ] ){\n fullLength += 2;\n }\n }\n var output = new Int32Array( fullLength );\n var offset = 0;\n var runLength = 1;\n for( i = 1, il = array.length; i < il; ++i ){\n if( array[ i - 1 ] !== array[ i ] ){\n output[ offset ] = array[ i - 1 ];\n output[ offset + 1 ] = runLength;\n runLength = 1;\n offset += 2;\n }else{\n ++runLength;\n }\n }\n output[ offset ] = array[ array.length - 1 ];\n output[ offset + 1 ] = runLength;\n return output;\n}\n\n\n\n/**\n * perform delta decoding of the input array\n * by iterativly adding the ith element's value to the i+1th\n * example:\n * dataArray: [ 0, 2, 1, 2, 1, 1, -4, -2, 9 ]\n * return: [ 0, 2, 3, 5, 6, 7, 3, 1, 10 ]\n * @static\n * @param {TypedArray|Array} dataArray - delta encoded input array\n * @return {TypedArray|Array} decoded array\n */\nfunction decodeDelta( array, output ){\n var n = array.length;\n if( !output ) output = new array.constructor( n );\n if( n ) output[ 0 ] = array[ 0 ];\n for( var i = 1; i < n; ++i ){\n output[ i ] = array[ i ] + output[ i - 1 ];\n }\n return output;\n}\n\nfunction encodeDelta( array, output ){\n var n = array.length;\n if( !output ) output = new array.constructor( n );\n output[ 0 ] = array[ 0 ];\n for( var i = 1; i < n; ++i ){\n output[ i ] = array[ i ] - array[ i - 1 ];\n }\n return output;\n}\n\n\n\n/**\n * [decodePacking description]\n * @param {Int16Array|Int8Array} int16or8 [description]\n * @param {Int32Array} output [description]\n * @return {Int32Array} [description]\n */\nfunction decodePacking( int16or8, output ){\n var upperLimit = int16or8 instanceof Int8Array ? 0x7F : 0x7FFF;\n var lowerLimit = -upperLimit - 1;\n var n = int16or8.length;\n var i, j;\n if( !output ){\n var fullLength = 0;\n for( i = 0; i < n; ++i ){\n if( int16or8[ i ] < upperLimit && int16or8[ i ] > lowerLimit ){\n ++fullLength;\n }\n }\n output = new Int32Array( fullLength );\n }\n i = 0;\n j = 0;\n while( i < n ){\n var value = 0;\n while( int16or8[ i ] === upperLimit || int16or8[ i ] === lowerLimit ){\n value += int16or8[ i ];\n ++i;\n }\n value += int16or8[ i ];\n ++i;\n output[ j ] = value;\n ++j;\n }\n return output;\n}\n\n/**\n * integer packing using recursive indexing\n * @param {Array|TyepedArray} intArray [description]\n * @param {Boolean} useInt8 [description]\n * @return {Int16Array|Int8Array} [description]\n */\nfunction encodePacking( intArray, useInt8 ){\n var upperLimit = useInt8 ? 0x7F : 0x7FFF;\n var lowerLimit = -upperLimit - 1;\n var i;\n var n = intArray.length;\n var size = 0;\n for( i = 0; i < n; ++i ){\n var value = intArray[ i ];\n if( value === 0 ){\n ++size;\n }else if( value === upperLimit || value === lowerLimit ){\n size += 2;\n }else if( value > 0) {\n size += Math.ceil( value / upperLimit );\n }else {\n size += Math.ceil( value / lowerLimit );\n }\n }\n var output = useInt8 ? new Int8Array( size ) : new Int16Array( size );\n var j = 0;\n for( i = 0; i < n; ++i ){\n var value = intArray[ i ];\n if( value >= 0) {\n while( value >= upperLimit ){\n output[ j ] = upperLimit;\n ++j;\n value -= upperLimit;\n }\n }else{\n while( value <= lowerLimit ){\n output[ j ] = lowerLimit;\n ++j;\n value -= lowerLimit;\n }\n }\n output[ j ] = value;\n ++j;\n }\n return output;\n}\n\n\n\nfunction decodeDeltaRun( array, output ){\n return decodeDelta( decodeRun( array ), output );\n}\n\nfunction encodeDeltaRun( array ){\n return encodeRun( encodeDelta( array ) );\n}\n\n\n\n/**\n * perform run-length decoding followed (@see decodeRunLength)\n * by decoding integers into floats using given divisor (@see decodeIntegerToFloat)\n * example:\n * array: [ 320, 3, 100, 2 ]\n * divisor: 100\n * return: [ 3.20, 3.20, 3.20, 1.00, 1.00 ]\n * @static\n * @param {Uint8Array} array - run-length encoded int32 array as bytes in big endian format\n * @param {Integer} divisor - number to devide the integers to obtain floats\n * @param {Float32Array} dataArray - pre-allocated output array\n * @return {Float32Array} decoded array\n */\nfunction decodeIntegerRun( intArray, divisor, output ){\n return decodeInteger(\n decodeRun( intArray, getInt32View( output ) ), divisor, output\n );\n}\n\nfunction encodeIntegerRun( floatArray, factor ){\n return encodeRun( encodeInteger( floatArray, factor ) );\n}\n\n\n\nfunction decodeIntegerDelta( intArray, divisor, output ){\n return decodeInteger(\n decodeDelta( intArray, getInt32View( output ) ), divisor, output\n );\n}\n\nfunction encodeIntegerDelta( floatArray, factor, output ){\n return encodeDelta( encodeInteger( floatArray, factor ), output );\n}\n\n\n\nfunction decodeIntegerPacking( int16or8, divisor, output ){\n return decodeInteger(\n decodePacking( int16or8, getInt32View( output ) ), divisor, output\n );\n}\n\nfunction decodeIntegerDeltaPacking( int16or8, divisor, output ){\n var unpacked = decodePacking( int16or8, getInt32View( output ) );\n return decodeIntegerDelta( unpacked, divisor, getFloat32View( unpacked ) );\n}\n\nfunction encodeIntegerDeltaPacking( floatArray, factor, useInt8 ){\n return encodePacking( encodeIntegerDelta( floatArray, factor ), useInt8 );\n}\n\n\n\nfunction decodeBytes( bytes ){\n var dv = getDataView( bytes );\n var type = dv.getInt32( 0 );\n var size = dv.getInt32( 4 );\n var param = bytes.subarray( 8, 12 );\n var bytes = bytes.subarray( 12 );\n return [ type, bytes, size, param ];\n}\n\nfunction encodeBytes( type, size, param, bytes ){\n var buffer = new ArrayBuffer( 12 + bytes.byteLength );\n var out = new Uint8Array( buffer );\n var dv = new DataView( buffer );\n dv.setInt32( 0, type );\n dv.setInt32( 4, size );\n if( param ) out.set( param, 8 );\n out.set( bytes, 12 );\n return out;\n}\n\nfunction passInt8( int8 ){\n var size = int8.length;\n var bytes = getUint8View( int8 );\n return encodeBytes( 2, size, undefined, bytes );\n}\n\nfunction passInt32( int32 ){\n var size = int32.length;\n var bytes = encodeInt32( int32 );\n return encodeBytes( 4, size, undefined, bytes );\n}\n\nfunction passString( stringBytes, length ){\n var size = stringBytes.length / length;\n var param = encodeInt32([ length ]);\n var bytes = getUint8View( stringBytes );\n return encodeBytes( 5, size, param, bytes );\n}\n\nfunction runChar( charBytes ){\n var size = charBytes.length;\n var bytes = encodeInt32( encodeRun( charBytes ) );\n return encodeBytes( 6, size, undefined, bytes );\n}\n\nfunction deltaRun( int32 ){\n var size = int32.length;\n var bytes = encodeInt32( encodeDeltaRun( int32 ) );\n return encodeBytes( 8, size, undefined, bytes );\n}\n\nfunction integerRun( float32, factor ){\n var size = float32.length;\n var param = encodeInt32([ factor ]);\n var bytes = encodeInt32( encodeIntegerRun( float32, factor ) );\n return encodeBytes( 9, size, param, bytes );\n}\n\nfunction integerDeltaPacking16( float32, factor ){\n var size = float32.length;\n var param = encodeInt32([ factor ]);\n var bytes = encodeInt16( encodeIntegerDeltaPacking( float32, factor ) );\n return encodeBytes( 10, size, param, bytes );\n}\n\nfunction encodeMmtf( inputDict ){\n\n var outputDict = {};\n\n // copy some fields over from the input dict\n PassThroughFields.forEach( function( name ){\n if( inputDict[ name ] !== undefined ){\n outputDict[ name ] = inputDict[ name ];\n }\n } );\n\n //////////////\n // bond data\n\n // encode inter group bond atom indices, i.e. get bytes in big endian order\n if( inputDict.bondAtomList ){\n outputDict.bondAtomList = passInt32( inputDict.bondAtomList );\n }\n\n // encode inter group bond orders, i.e. get bytes\n if( inputDict.bondOrderList ){\n outputDict.bondOrderList = passInt8( inputDict.bondOrderList );\n }\n\n //////////////\n // atom data\n\n // split-list delta & integer encode x, y, z atom coords\n outputDict.xCoordList = integerDeltaPacking16( inputDict.xCoordList, 1000 );\n outputDict.yCoordList = integerDeltaPacking16( inputDict.yCoordList, 1000 );\n outputDict.zCoordList = integerDeltaPacking16( inputDict.zCoordList, 1000 );\n\n // split-list delta & integer encode b-factors\n if( inputDict.bFactorList ){\n outputDict.bFactorList = integerDeltaPacking16( inputDict.bFactorList, 100 );\n }\n\n // delta & run-length encode atom ids\n if( inputDict.atomIdList ){\n outputDict.atomIdList = deltaRun( inputDict.atomIdList );\n }\n\n // run-length encode alternate labels\n if( inputDict.altLocList ){\n outputDict.altLocList = runChar( inputDict.altLocList );\n }\n\n // run-length & integer encode occupancies\n if( inputDict.occupancyList ){\n outputDict.occupancyList = integerRun( inputDict.occupancyList, 100 );\n }\n\n ///////////////\n // group data\n\n // run-length & delta encode group numbers\n outputDict.groupIdList = deltaRun( inputDict.groupIdList );\n\n // encode group types, i.e. get int32 array\n outputDict.groupTypeList = passInt32( inputDict.groupTypeList );\n\n // encode secondary structure, i.e. get bytes\n if( inputDict.secStructList ){\n outputDict.secStructList = passInt8( inputDict.secStructList, 1 );\n }\n\n // run-length encode insertion codes\n if( inputDict.insCodeList ){\n outputDict.insCodeList = runChar( inputDict.insCodeList );\n }\n\n // run-length & delta encode sequence indices\n if( inputDict.sequenceIndexList ){\n outputDict.sequenceIndexList = deltaRun( inputDict.sequenceIndexList );\n }\n\n ///////////////\n // chain data\n\n // encode chain ids, i.e. get bytes\n outputDict.chainIdList = passString( inputDict.chainIdList, 4 );\n\n // encode chain names, i.e. get bytes\n if( inputDict.chainNameList ){\n outputDict.chainNameList = passString( inputDict.chainNameList, 4 );\n }\n\n return outputDict;\n\n}\n\n/**\n * @file msgpack-decode\n * @private\n * @author Alexander Rose \n */\n\n/**\n * msgpack decode module.\n * @module MsgpackDecode\n */\n\n/**\n * decode binary encoded MessagePack v5 (http://msgpack.org/) data\n * @static\n * @param {Uint8Array} buffer - binary encoded MessagePack data\n * @return {Object|Array|String|Number|Boolean|null} decoded Messagepack data\n */\nfunction decodeMsgpack(buffer) {\n // Loosely based on\n // The MIT License (MIT)\n // Copyright (c) 2013 Tim Caswell \n // https://github.com/creationix/msgpack-js\n var offset = 0;\n var dataView = new DataView(buffer.buffer);\n\n /**\n * decode all key-value pairs of a map into an object\n * @param {Integer} length - number of key-value pairs\n * @return {Object} decoded map\n */\n function map(length) {\n var value = {};\n for (var i = 0; i < length; i++) {\n var key = parse();\n value[key] = parse();\n }\n return value;\n }\n\n /**\n * decode binary array\n * @param {Integer} length - number of elements in the array\n * @return {Uint8Array} decoded array\n */\n function bin(length) {\n var value = buffer.subarray(offset, offset + length);\n offset += length;\n return value;\n }\n\n /**\n * decode string\n * @param {Integer} length - number string characters\n * @return {String} decoded string\n */\n function str(length) {\n var array = buffer.subarray(offset, offset + length);\n offset += length;\n // limit number of arguments to String.fromCharCode to something\n // browsers can handle, see http://stackoverflow.com/a/22747272\n var chunkSize = 0xffff;\n if(length > chunkSize){\n var c = [];\n for(var i = 0; i < array.length; i += chunkSize) {\n c.push(String.fromCharCode.apply(\n null, array.subarray(i, i + chunkSize)\n ));\n }\n return c.join(\"\");\n }else{\n return String.fromCharCode.apply(null, array);\n }\n }\n\n /**\n * decode array\n * @param {Integer} length - number of array elements\n * @return {Array} decoded array\n */\n function array(length) {\n var value = new Array(length);\n for (var i = 0; i < length; i++) {\n value[i] = parse();\n }\n return value;\n }\n\n /**\n * recursively parse the MessagePack data\n * @return {Object|Array|String|Number|Boolean|null} decoded MessagePack data\n */\n function parse() {\n var type = buffer[offset];\n var value, length, extType;\n // Positive FixInt\n if ((type & 0x80) === 0x00) {\n offset++;\n return type;\n }\n // FixMap\n if ((type & 0xf0) === 0x80) {\n length = type & 0x0f;\n offset++;\n return map(length);\n }\n // FixArray\n if ((type & 0xf0) === 0x90) {\n length = type & 0x0f;\n offset++;\n return array(length);\n }\n // FixStr\n if ((type & 0xe0) === 0xa0) {\n length = type & 0x1f;\n offset++;\n return str(length);\n }\n // Negative FixInt\n if ((type & 0xe0) === 0xe0) {\n value = dataView.getInt8(offset);\n offset++;\n return value;\n }\n switch (type) {\n // nil\n case 0xc0:\n offset++;\n return null;\n // 0xc1: (never used, could be employed for padding)\n // false\n case 0xc2:\n offset++;\n return false;\n // true\n case 0xc3:\n offset++;\n return true;\n // bin 8\n case 0xc4:\n length = dataView.getUint8(offset + 1);\n offset += 2;\n return bin(length);\n // bin 16\n case 0xc5:\n length = dataView.getUint16(offset + 1);\n offset += 3;\n return bin(length);\n // bin 32\n case 0xc6:\n length = dataView.getUint32(offset + 1);\n offset += 5;\n return bin(length);\n // // ext 8\n // case 0xc7:\n // length = dataView.getUint8(offset + 1);\n // extType = dataView.getUint8(offset + 2);\n // offset += 3;\n // return [extType, bin(length)];\n // // ext 16\n // case 0xc8:\n // length = dataView.getUint16(offset + 1);\n // extType = dataView.getUint8(offset + 3);\n // offset += 4;\n // return [extType, bin(length)];\n // // ext 32\n // case 0xc9:\n // length = dataView.getUint32(offset + 1);\n // extType = dataView.getUint8(offset + 5);\n // offset += 6;\n // return [extType, bin(length)];\n // float 32\n case 0xca:\n value = dataView.getFloat32(offset + 1);\n offset += 5;\n return value;\n // float 64\n case 0xcb:\n value = dataView.getFloat64(offset + 1);\n offset += 9;\n return value;\n // uint8\n case 0xcc:\n value = buffer[offset + 1];\n offset += 2;\n return value;\n // uint 16\n case 0xcd:\n value = dataView.getUint16(offset + 1);\n offset += 3;\n return value;\n // uint 32\n case 0xce:\n value = dataView.getUint32(offset + 1);\n offset += 5;\n return value;\n // // uint64\n // case 0xcf:\n // // FIXME not available/representable in JS\n // // largest possible int in JS is 2^53\n // // value = dataView.getUint64(offset + 1);\n // offset += 9;\n // return 0;\n // int 8\n case 0xd0:\n value = dataView.getInt8(offset + 1);\n offset += 2;\n return value;\n // int 16\n case 0xd1:\n value = dataView.getInt16(offset + 1);\n offset += 3;\n return value;\n // int 32\n case 0xd2:\n value = dataView.getInt32(offset + 1);\n offset += 5;\n return value;\n // // int 64\n // case 0xd3:\n // // FIXME not available/representable in JS\n // // largest possible int in JS is 2^53\n // // value = dataView.getInt64(offset + 1);\n // offset += 9;\n // return 0;\n\n // // fixext 1\n // case 0xd4:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(1)];\n // // fixext 2\n // case 0xd5:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(2)];\n // // fixext 4\n // case 0xd6:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(4)];\n // // fixext 8\n // case 0xd7:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(8)];\n // // fixext 16\n // case 0xd8:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(16)];\n // str 8\n case 0xd9:\n length = dataView.getUint8(offset + 1);\n offset += 2;\n return str(length);\n // str 16\n case 0xda:\n length = dataView.getUint16(offset + 1);\n offset += 3;\n return str(length);\n // str 32\n case 0xdb:\n length = dataView.getUint32(offset + 1);\n offset += 5;\n return str(length);\n // array 16\n case 0xdc:\n length = dataView.getUint16(offset + 1);\n offset += 3;\n return array(length);\n // array 32\n case 0xdd:\n length = dataView.getUint32(offset + 1);\n offset += 5;\n return array(length);\n // map 16:\n case 0xde:\n length = dataView.getUint16(offset + 1);\n offset += 3;\n return map(length);\n // map 32\n case 0xdf:\n length = dataView.getUint32(offset + 1);\n offset += 5;\n return map(length);\n }\n\n throw new Error(\"Unknown type 0x\" + type.toString(16));\n }\n\n // start the recursive parsing\n return parse();\n}\n\n/**\n * Fields shared in encoded and decoded mmtf data objects.\n * @typedef {Object} module:MmtfDecode.SharedMmtfData\n * @property {String} mmtfVersion - MMTF specification version\n * @property {String} mmtfProducer - Program that created the file\n * @property {Float[]} [unitCell] - Crystallographic unit cell\n * @property {Float} unitCell.0 - x length\n * @property {Float} unitCell.1 - y length\n * @property {Float} unitCell.2 - z length\n * @property {Float} unitCell.3 - alpha angle\n * @property {Float} unitCell.4 - beta angle\n * @property {Float} unitCell.5 - gamma angle\n * @property {String} [spaceGroup] - Hermann-Mauguin symbol\n * @property {String} [structureId] - Some reference, e.g. a PDB ID\n * @property {String} [title] - Short description\n * @property {String} [depositionDate] - Deposition date in YYYY-MM-DD format\n * @property {String} [releaseDate] - Release date in YYYY-MM-DD format\n * @property {String[]} [experimentalMethods] - Structure determination methods\n * @property {Float} [resolution] - Resolution in Å\n * @property {Float} [rFree] - R-free value\n * @property {Float} [rWork] - R-work value\n * @property {Integer} numBonds - Number of bonds\n * @property {Integer} numAtoms - Number of atoms\n * @property {Integer} numGroups - Number of groups (residues)\n * @property {Integer} numChains - Number of chains\n * @property {Integer} numModels - Number of models\n * @property {Integer[]} chainsPerModel - List of number of chains in each model\n * @property {Integer[]} groupsPerChain - List of number of groups in each chain\n * @property {Entity[]} [entityList] - List of entity objects\n * @property {Integer[]} entityList.chainIndexList - Pointers into chain data fields\n * @property {String} entityList.description - Description of the entity\n * @property {String} entityList.type - Name of the entity type\n * @property {String} entityList.sequence - One letter code sequence\n * @property {Assembly[]} [bioAssemblyList] - List of assembly objects\n * @property {Transform[]} bioAssemblyList.transformList - List of transform objects\n * @property {Integer[]} bioAssemblyList.transformList.chainIndexList - Pointers into chain data fields\n * @property {Float[]} bioAssemblyList.transformList.matrix - 4x4 transformation matrix\n * @property {Array[]} [ncsOperatorList] - List of ncs operator matrices\n * @property {Float[]} ncsOperatorList. - 4x4 transformation matrix\n * @property {GroupType[]} groupList - List of groupType objects\n * @property {Integer[]} groupList.formalChargeList - List of atom formal charges\n * @property {String[]} groupList.elementList - List of elements\n * @property {String[]} groupList.atomNameList - List of atom names\n * @property {Integer[]} groupList.bondAtomList - List of bonded atom indices\n * @property {Integer[]} groupList.bondOrderList - List of bond orders\n * @property {String} groupList.groupName - The name of the group\n * @property {String} groupList.singleLetterCode - The single letter code\n * @property {String} groupList.chemCompType - The chemical component type\n */\n\n/**\n * Encoded mmtf data object. Also includes the fields from {@link module:MmtfDecode.SharedMmtfData}. See MMTF specification on how they are encoded.\n * @typedef {Object} module:MmtfDecode.EncodedMmtfData\n * @mixes module:MmtfDecode.SharedMmtfData\n * @property {Uint8Array} [bondAtomList] - Encoded bonded atom indices\n * @property {Uint8Array} [bondOrderList] - Encoded bond orders\n * @property {Uint8Array} xCoordBig - Encoded x coordinates in Å, part 1\n * @property {Uint8Array} xCoordSmall - Encoded x coordinates in Å, part 2\n * @property {Uint8Array} yCoordBig - Encoded y coordinates in Å, part 1\n * @property {Uint8Array} yCoordSmall - Encoded y coordinates in Å, part 2\n * @property {Uint8Array} yCoordBig - Encoded y coordinates in Å, part 1\n * @property {Uint8Array} yCoordSmall - Encoded y coordinates in Å, part 2\n * @property {Uint8Array} [bFactorBig] - Encoded B-factors in Å^2, part 1\n * @property {Uint8Array} [bFactorSmall] - Encoded B-factors in Å^2, part 2\n * @property {Uint8Array} [atomIdList] - Encoded atom ids\n * @property {Uint8Array} [altLocList] - Encoded alternate location labels\n * @property {Uint8Array} [occupancyList] - Encoded occupancies\n * @property {Uint8Array} groupIdList - Encoded group ids\n * @property {Uint8Array} groupTypeList - Encoded group types\n * @property {Uint8Array} [secStructList] - Encoded secondary structure codes\n * @property {Uint8Array} [insCodeList] - Encoded insertion codes\n * @property {Uint8Array} [seuenceIdList] - Encoded sequence ids\n * @property {Uint8Array} chainIdList - Encoded chain ids\n * @property {Uint8Array} [chainNameList] - Encoded chain names\n */\n\n/**\n * Decoded mmtf data object. Also includes fields the from {@link module:MmtfDecode.SharedMmtfData}.\n * @typedef {Object} module:MmtfDecode.MmtfData\n * @mixes module:MmtfDecode.SharedMmtfData\n * @property {Int32Array} [bondAtomList] - List of bonded atom indices\n * @property {Uint8Array} [bondOrderList] - List of bond orders\n * @property {Float32Array} xCoordList - List of x coordinates in Å\n * @property {Float32Array} yCoordList - List of y coordinates in Å\n * @property {Float32Array} zCoordList - List of z coordinates in Å\n * @property {Float32Array} [bFactorList] - List of B-factors in Å^2\n * @property {Int32Array} [atomIdList] - List of atom ids\n * @property {Uint8Array} [altLocList] - List of alternate location labels\n * @property {Float32Array} [occupancyList] - List of occupancies\n * @property {Int32Array} groupIdList - List of group ids\n * @property {Int32Array} groupTypeList - List of group types\n * @property {Int8Array} [secStructList] - List of secondary structure codes, encoding\n * 0: pi helix, 1: bend, 2: alpha helix, 3: extended,\n * 4: 3-10 helix, 5: bridge, 6: turn, 7: coil, -1: undefined\n * @property {Uint8Array} [insCodeList] - List of insertion codes\n * @property {Int32Array} [seuenceIdList] - List of sequence ids\n * @property {Uint8Array} chainIdList - List of chain ids\n * @property {Uint8Array} [chainNameList] - List of chain names\n */\n\n\n/**\n * [performDecoding description]\n * @param {Integer} bytes [description]\n * @param {Integer} size [description]\n * @param {Uint8Array} param [description]\n * @return {TypedArray} [description]\n */\nfunction performDecoding( type, bytes, size, param ){\n\n switch( type ){\n case 1:\n return decodeFloat32( bytes );\n case 2:\n return getInt8View( bytes );\n case 3:\n return decodeInt16( bytes );\n case 4:\n return decodeInt32( bytes );\n case 5:\n // var length = decodeInt32( param )[ 0 ];\n return getUint8View( bytes ); // interpret as string array\n case 6:\n // interpret as char array\n return decodeRun( decodeInt32( bytes ), new Uint8Array( size ) );\n case 7:\n return decodeRun( decodeInt32( bytes ) )\n case 8:\n return decodeDeltaRun( decodeInt32( bytes ) );\n case 9:\n return decodeIntegerRun( decodeInt32( bytes ), decodeInt32( param )[ 0 ] );\n case 10:\n return decodeIntegerDeltaPacking( decodeInt16( bytes ), decodeInt32( param )[ 0 ] );\n case 11:\n return decodeInteger( decodeInt16( bytes ), decodeInt32( param )[ 0 ] );\n case 12:\n return decodeIntegerPacking( decodeInt16( bytes ), decodeInt32( param )[ 0 ] );\n case 13:\n return decodeIntegerPacking( getInt8View( bytes ), decodeInt32( param )[ 0 ] );\n case 14:\n return decodePacking( decodeInt16( bytes ) );\n case 15:\n return decodePacking( getInt8View( bytes ) );\n }\n\n};\n\n\n/**\n * Decode MMTF fields\n * @static\n * @param {Object} inputDict - encoded MMTF data\n * @param {Object} [params] - decoding parameters\n * @param {String[]} params.ignoreFields - names of optional fields not to decode\n * @return {module:MmtfDecode.MmtfData} mmtfData\n */\nfunction decodeMmtf( inputDict, params ){\n\n params = params || {};\n var ignoreFields = params.ignoreFields;\n var outputDict = {};\n\n AllFields.forEach( function( name ){\n var ignore = ignoreFields ? ignoreFields.indexOf( name ) !== -1 : false;\n var data = inputDict[ name ];\n if( !ignore && data !== undefined ){\n if( data instanceof Uint8Array ){\n outputDict[ name ] = performDecoding.apply( null, decodeBytes( data ) );\n }else{\n outputDict[ name ] = data;\n }\n }\n } );\n\n return outputDict;\n\n}\n\n/**\n * @file mmtf-traverse\n * @private\n * @author Alexander Rose \n */\n\n/**\n * mmtf traverse module.\n * @module MmtfTraverse\n */\n\n/**\n * Converts an array of ASCII codes trimming '\\0' bytes\n * @private\n * @param {Array} charCodeArray - array of ASCII char codes\n * @return {String} '\\0' trimmed string\n */\nfunction fromCharCode( charCodeArray ){\n return String.fromCharCode.apply( null, charCodeArray ).replace(/\\0/g, '');\n}\n\n\n/**\n * @callback module:MmtfTraverse.onModel\n * @param {Object} modelData\n * @param {Integer} modelData.chainCount - number of chains in the model\n * @param {Integer} modelData.modelIndex - index of the model\n */\n\n/**\n * @callback module:MmtfTraverse.onChain\n * @param {Object} chainData\n * @param {Integer} chainData.groupCount - number of groups in the chain\n * @param {Integer} chainData.chainIndex - index of the chain\n * @param {Integer} chainData.modelIndex - index of the parent model\n * @param {String} chainData.chainId - chain id\n * @param {?String} chainData.chainName - additional chain name\n */\n\n/**\n * @callback module:MmtfTraverse.onGroup\n * @param {Object} groupData\n * @param {Integer} groupData.atomCount - number of atoms in the group\n * @param {Integer} groupData.groupIndex - index of the group\n * @param {Integer} groupData.chainIndex - index of the parent chain\n * @param {Integer} groupData.modelIndex - index of the parent model\n * @param {Integer} groupData.groupId - group id (residue number)\n * @param {Integer} groupData.groupType - index to an entry in {@link module:MmtfDecode.MmtfData}#groupList\n * @param {String} groupData.groupName - name of the group, 0 to 5 characters\n * @param {Char} groupData.singleLetterCode - IUPAC single letter code, otherwise 'X', 1 character\n * @param {String} groupData.chemCompType - chemical component type from the mmCIF dictionary\n * @param {?Integer} groupData.secStruct - sencoded secondary structure |\n * 0: pi helix, 1: bend, 2: alpha helix, 3: extended,\n * 4: 3-10 helix, 5: bridge, 6: turn, 7: coil, -1: undefined\n * @param {?Char} groupData.insCode - insertion code\n * @param {?Integer} groupData.sequenceIndex - index to the `sequence` property of\n * the corresponding entity, -1 when the entity has no sequence\n */\n\n/**\n * @callback module:MmtfTraverse.onAtom\n * @param {Object} atomData\n * @param {Integer} atomData.atomIndex - index of the atom\n * @param {Integer} atomData.groupIndex - index of the parent group\n * @param {Integer} atomData.chainIndex - index of the parent chain\n * @param {Integer} atomData.modelIndex - index of the parent model\n * @param {?Integer} atomData.atomId - atom id\n * @param {String} atomData.element - IUPAC element name, 0 to 3 characters\n * @param {String} atomData.atomName - name of the atom, 0 to 5 characters\n * @param {Integer} atomData.formalCharge - formal charge of the atom\n * @param {Float} atomData.xCoord - x coordinate in Å\n * @param {Float} atomData.yCoord - y coordinate in Å\n * @param {Float} atomData.zCoord - z coordinate in Å\n * @param {?Float} atomData.bFactor - B-factor in in Å^2\n * @param {?Char} atomData.altLoc - alternate location identifier\n * @param {?Float} atomData.occupancy - occupancy of the atom\n */\n\n/**\n * @callback module:MmtfTraverse.onBond\n * @param {Object} bondData\n * @param {Integer} bondData.atomIndex1 - index of the first atom\n * @param {Integer} bondData.atomIndex2 - index of the secound atom\n * @param {Integer} bondData.bondOrder - bond order, allowed values are 1 to 3\n */\n\n\n/**\n * Traverse the MMTF structure data.\n * @static\n * @param {module:MmtfDecode.MmtfData} mmtfData - decoded mmtf data\n * @param {Object} eventCallbacks\n * @param {module:MmtfTraverse.onModel} [eventCallbacks.onModel] - called for each model\n * @param {module:MmtfTraverse.onChain} [eventCallbacks.onChain] - called for each chain\n * @param {module:MmtfTraverse.onGroup} [eventCallbacks.onGroup] - called for each group\n * @param {module:MmtfTraverse.onAtom} [eventCallbacks.onAtom] - called for each atom\n * @param {module:MmtfTraverse.onBond} [eventCallbacks.onBond] - called for each bond\n * @param {Object} [params] - traversal parameters\n * @param {Boolean} [params.firstModelOnly] - traverse only the first model\n */\nfunction traverseMmtf( mmtfData, eventCallbacks, params ){\n\n params = params || {};\n\n var firstModelOnly = params.firstModelOnly;\n\n // setup callbacks\n var onModel = eventCallbacks.onModel;\n var onChain = eventCallbacks.onChain;\n var onGroup = eventCallbacks.onGroup;\n var onAtom = eventCallbacks.onAtom;\n var onBond = eventCallbacks.onBond;\n\n // setup index counters\n var modelIndex = 0;\n var chainIndex = 0;\n var groupIndex = 0;\n var atomIndex = 0;\n\n var modelFirstAtomIndex = 0;\n var modelLastAtomIndex = -1;\n\n // setup optional fields\n var chainNameList = mmtfData.chainNameList;\n var secStructList = mmtfData.secStructList;\n var insCodeList = mmtfData.insCodeList;\n var sequenceIndexList = mmtfData.sequenceIndexList;\n var atomIdList = mmtfData.atomIdList;\n var bFactorList = mmtfData.bFactorList;\n var altLocList = mmtfData.altLocList;\n var occupancyList = mmtfData.occupancyList;\n var bondAtomList = mmtfData.bondAtomList;\n var bondOrderList = mmtfData.bondOrderList;\n\n // hoisted loop variables\n var o, ol, i, j, k, kl;\n\n // loop over all models\n for( o = 0, ol = mmtfData.chainsPerModel.length; o < ol; ++o ){\n\n if( firstModelOnly && modelIndex > 0 ) break;\n\n var modelChainCount = mmtfData.chainsPerModel[ modelIndex ];\n\n if( onModel ){\n onModel({\n chainCount: modelChainCount,\n modelIndex: modelIndex\n });\n }\n\n for( i = 0; i < modelChainCount; ++i ){\n\n var chainGroupCount = mmtfData.groupsPerChain[ chainIndex ];\n if( onChain ){\n var chainId = fromCharCode(\n mmtfData.chainIdList.subarray( chainIndex * 4, chainIndex * 4 + 4 )\n );\n var chainName = null;\n if( chainNameList ){\n chainName = fromCharCode(\n chainNameList.subarray( chainIndex * 4, chainIndex * 4 + 4 )\n );\n }\n onChain({\n groupCount: chainGroupCount,\n chainIndex: chainIndex,\n modelIndex: modelIndex,\n chainId: chainId,\n chainName: chainName\n });\n }\n\n for( j = 0; j < chainGroupCount; ++j ){\n\n var groupData = mmtfData.groupList[ mmtfData.groupTypeList[ groupIndex ] ];\n var groupAtomCount = groupData.atomNameList.length;\n if( onGroup ){\n var secStruct = null;\n if( secStructList ){\n secStruct = secStructList[ groupIndex ];\n }\n var insCode = null;\n if( mmtfData.insCodeList ){\n insCode = String.fromCharCode( insCodeList[ groupIndex ] );\n }\n var sequenceIndex = null;\n if( sequenceIndexList ){\n sequenceIndex = sequenceIndexList[ groupIndex ];\n }\n onGroup({\n atomCount: groupAtomCount,\n groupIndex: groupIndex,\n chainIndex: chainIndex,\n modelIndex: modelIndex,\n groupId: mmtfData.groupIdList[ groupIndex ],\n groupType: mmtfData.groupTypeList[ groupIndex ],\n groupName: groupData.groupName,\n singleLetterCode: groupData.singleLetterCode,\n chemCompType: groupData.chemCompType,\n secStruct: secStruct,\n insCode: insCode,\n sequenceIndex: sequenceIndex\n });\n }\n\n for( k = 0; k < groupAtomCount; ++k ){\n\n if( onAtom ){\n var atomId = null;\n if( atomIdList ){\n atomId = atomIdList[ atomIndex ];\n }\n var bFactor = null;\n if( bFactorList ){\n bFactor = bFactorList[ atomIndex ];\n }\n var altLoc = null;\n if( altLocList ){\n altLoc = String.fromCharCode( altLocList[ atomIndex ] );\n }\n var occupancy = null;\n if( occupancyList ){\n occupancy = occupancyList[ atomIndex ];\n }\n onAtom({\n atomIndex: atomIndex,\n groupIndex: groupIndex,\n chainIndex: chainIndex,\n modelIndex: modelIndex,\n atomId: atomId,\n element: groupData.elementList[ k ],\n atomName: groupData.atomNameList[ k ],\n formalCharge: groupData.formalChargeList[ k ],\n xCoord: mmtfData.xCoordList[ atomIndex ],\n yCoord: mmtfData.yCoordList[ atomIndex ],\n zCoord: mmtfData.zCoordList[ atomIndex ],\n bFactor: bFactor,\n altLoc: altLoc,\n occupancy: occupancy\n });\n }\n\n atomIndex += 1;\n }\n\n if( onBond ){\n // intra group bonds\n var groupBondAtomList = groupData.bondAtomList;\n for( k = 0, kl = groupData.bondOrderList.length; k < kl; ++k ){\n onBond({\n atomIndex1: atomIndex - groupAtomCount + groupBondAtomList[ k * 2 ],\n atomIndex2: atomIndex - groupAtomCount + groupBondAtomList[ k * 2 + 1 ],\n bondOrder: groupData.bondOrderList[ k ]\n });\n }\n }\n\n groupIndex += 1;\n }\n\n chainIndex += 1;\n }\n\n modelFirstAtomIndex = modelLastAtomIndex + 1;\n modelLastAtomIndex = atomIndex - 1; // subtract one as it already has been incremented\n\n if( onBond ){\n // inter group bonds\n if( bondAtomList ){\n for( k = 0, kl = bondAtomList.length; k < kl; k += 2 ){\n var atomIndex1 = bondAtomList[ k ];\n var atomIndex2 = bondAtomList[ k + 1 ];\n if( ( atomIndex1 >= modelFirstAtomIndex && atomIndex1 <= modelLastAtomIndex ) ||\n ( atomIndex2 >= modelFirstAtomIndex && atomIndex2 <= modelLastAtomIndex )\n ){\n onBond({\n atomIndex1: atomIndex1,\n atomIndex2: atomIndex2,\n bondOrder: bondOrderList ? bondOrderList[ k / 2 ] : null\n });\n }\n }\n }\n }\n\n modelIndex += 1;\n }\n\n}\n\n/**\n * Version name\n * @static\n * @type {String}\n */\nvar version = \"v1.1.0dev\";\n\n/**\n * Version name\n * @private\n * @type {String}\n */\nvar baseUrl = \"//mmtf.rcsb.org/v1.0/\";\n\n/**\n * URL of the RCSB webservice to obtain MMTF files\n * @static\n * @type {String}\n */\nvar fetchUrl = baseUrl + \"full/\";\n\n/**\n * URL of the RCSB webservice to obtain reduced MMTF files\n * @static\n * @type {String}\n */\nvar fetchReducedUrl = baseUrl + \"reduced/\";\n\n/**\n * Encode MMTF fields\n * @static\n * @param {module:MmtfDecode.MmtfData} mmtfData - mmtf data\n * @return {Uint8Array} encoded MMTF fields\n */\nfunction encode( mmtfData ){\n return encodeMsgpack( encodeMmtf( mmtfData ) );\n}\n\n/**\n * Decode MMTF fields\n * @static\n * @example\n * // bin is Uint8Array containing the mmtf msgpack\n * var mmtfData = MMTF.decode( bin );\n * console.log( mmtfData.numAtoms );\n *\n * @param {Uint8Array|ArrayBuffer|module:MmtfDecode.EncodedMmtfData} binOrDict - binary MessagePack or encoded MMTF data\n * @param {Object} [params] - decoding parameters\n * @param {String[]} params.ignoreFields - names of optional fields not to decode\n * @return {module:MmtfDecode.MmtfData} mmtfData\n */\nfunction decode( binOrDict, params ){\n\t// make sure binOrDict is not a plain Arraybuffer\n if( binOrDict instanceof ArrayBuffer ){\n binOrDict = new Uint8Array( binOrDict );\n }\n\n var inputDict;\n if( binOrDict instanceof Uint8Array ){\n // get dict from msgpack\n inputDict = decodeMsgpack( binOrDict );\n }else{\n // already a dict\n inputDict = binOrDict;\n }\n\n return decodeMmtf( inputDict, params );\n}\n\n/**\n * @callback module:MMTF.onLoad\n * @param {module:MmtfDecode.MmtfData} mmtfData - decoded mmtf data object\n */\n\n/**\n * helper method to fetch binary files from an URL\n * @private\n * @param {String} pdbid - PDB ID to fetch\n * @param {String} baseUrl - URL to fetch from\n * @param {module:MMTF.onLoad} onLoad - callback( mmtfData )\n * @param {Function} onError - callback( error )\n * @return {undefined}\n */\nfunction _fetch( pdbid, baseUrl, onLoad, onError ){\n var xhr = new XMLHttpRequest();\n function _onLoad(){\n try{\n var mmtfData = decode( xhr.response );\n onLoad( mmtfData );\n }catch( error ){\n onError( error );\n }\n }\n xhr.addEventListener( \"load\", _onLoad, true );\n xhr.addEventListener( \"error\", onError, true );\n xhr.responseType = \"arraybuffer\";\n xhr.open( \"GET\", baseUrl + pdbid.toUpperCase() );\n xhr.send();\n}\n\n/**\n * Fetch MMTF file from RCSB webservice which contains\n * @static\n * @example\n * MMTF.fetch(\n * \"3PQR\",\n * // onLoad callback\n * function( mmtfData ){ console.log( mmtfData ) },\n * // onError callback\n * function( error ){ console.error( error ) }\n * );\n *\n * @param {String} pdbid - PDB ID to fetch\n * @param {module:MMTF.onLoad} onLoad - callback( mmtfData )\n * @param {Function} onError - callback( error )\n * @return {undefined}\n */\nfunction fetch( pdbid, onLoad, onError ){\n _fetch( pdbid, fetchUrl, onLoad, onError );\n}\n\n/**\n * Fetch reduced MMTF file from RCSB webservice which contains\n * protein C-alpha, nucleotide phosphate and ligand atoms\n * @static\n * @example\n * MMTF.fetchReduced(\n * \"3PQR\",\n * // onLoad callback\n * function( mmtfData ){ console.log( mmtfData ) },\n * // onError callback\n * function( error ){ console.error( error ) }\n * );\n *\n * @param {String} pdbid - PDB ID to fetch\n * @param {module:MMTF.onLoad} onLoad - callback( mmtfData )\n * @param {Function} onError - callback( error )\n * @return {undefined}\n */\nfunction fetchReduced( pdbid, onLoad, onError ){\n _fetch( pdbid, fetchReducedUrl, onLoad, onError );\n}\n\nexport { encode, decode, traverseMmtf as traverse, fetch, fetchReduced, version, fetchUrl, fetchReducedUrl, encodeMsgpack, encodeMmtf, decodeMsgpack, decodeMmtf };","/**\n * @file Mmtf Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport {\n buildUnitcellAssembly, calculateBondsBetween, calculateBondsWithin\n} from '../structure/structure-utils'\nimport { ChemCompHetero } from '../structure/structure-constants'\nimport Entity from '../structure/entity'\nimport Unitcell from '../symmetry/unitcell'\nimport Assembly, { AssemblyPart } from '../symmetry/assembly'\n\nimport { decodeMsgpack, decodeMmtf } from '../../lib/mmtf.es6'\n\nconst SstrucMap: {[k: string]: number} = {\n '0': 'i'.charCodeAt(0), // pi helix\n '1': 's'.charCodeAt(0), // bend\n '2': 'h'.charCodeAt(0), // alpha helix\n '3': 'e'.charCodeAt(0), // extended\n '4': 'g'.charCodeAt(0), // 3-10 helix\n '5': 'b'.charCodeAt(0), // bridge\n '6': 't'.charCodeAt(0), // turn\n '7': 'l'.charCodeAt(0), // coil\n '-1': ''.charCodeAt(0) // NA\n}\n\nclass MmtfParser extends StructureParser {\n get type () { return 'mmtf' }\n get isBinary () { return true }\n\n _parse () {\n // https://github.com/rcsb/mmtf\n\n if (Debug) Log.time('MmtfParser._parse ' + this.name)\n\n let i, il, j, jl, groupData\n\n const s = this.structure\n const sd: {[k: string]: any} = decodeMmtf(decodeMsgpack(this.streamer.data))\n\n // structure header\n const headerFields = [\n 'depositionDate', 'releaseDate', 'resolution',\n 'rFree', 'rWork', 'experimentalMethods'\n ]\n headerFields.forEach(function (name) {\n if (sd[ name ] !== undefined) {\n s.header[ name ] = sd[ name ]\n }\n })\n\n let numBonds, numAtoms, numGroups, numChains, numModels\n let chainsPerModel\n\n s.id = sd.structureId\n s.title = sd.title\n\n s.atomStore.addField('formalCharge', 1, 'int8')\n\n if (this.firstModelOnly || this.asTrajectory) {\n numModels = 1\n numChains = sd.chainsPerModel[ 0 ]\n\n numGroups = 0\n for (i = 0, il = numChains; i < il; ++i) {\n numGroups += sd.groupsPerChain[ i ]\n }\n\n numAtoms = 0\n for (i = 0, il = numGroups; i < il; ++i) {\n groupData = sd.groupList[ sd.groupTypeList[ i ] ]\n numAtoms += groupData.atomNameList.length\n }\n\n numBonds = sd.numBonds\n\n chainsPerModel = [ numChains ]\n } else {\n numBonds = sd.numBonds\n numAtoms = sd.numAtoms\n numGroups = sd.numGroups\n numChains = sd.numChains\n numModels = sd.numModels\n\n chainsPerModel = sd.chainsPerModel\n }\n\n numBonds += numGroups // add numGroups to have space for polymer bonds\n\n //\n\n if (this.asTrajectory) {\n for (i = 0, il = sd.numModels; i < il; ++i) {\n const frame = new Float32Array(numAtoms * 3)\n const frameAtomOffset = numAtoms * i\n\n for (j = 0; j < numAtoms; ++j) {\n const j3 = j * 3\n const offset = j + frameAtomOffset\n frame[ j3 ] = sd.xCoordList[ offset ]\n frame[ j3 + 1 ] = sd.yCoordList[ offset ]\n frame[ j3 + 2 ] = sd.zCoordList[ offset ]\n }\n\n s.frames.push(frame)\n }\n }\n\n // bondStore\n const bAtomIndex1 = new Uint32Array(numBonds)\n const bAtomIndex2 = new Uint32Array(numBonds)\n const bBondOrder = new Uint8Array(numBonds)\n\n const aGroupIndex = new Uint32Array(numAtoms)\n const aFormalCharge = new Int8Array(numAtoms)\n\n const gChainIndex = new Uint32Array(numGroups)\n const gAtomOffset = new Uint32Array(numGroups)\n const gAtomCount = new Uint16Array(numGroups)\n\n const cModelIndex = new Uint16Array(numChains)\n const cGroupOffset = new Uint32Array(numChains)\n const cGroupCount = new Uint32Array(numChains)\n\n const mChainOffset = new Uint32Array(numModels)\n const mChainCount = new Uint32Array(numModels)\n\n // set-up model-chain relations\n let chainOffset = 0\n for (i = 0, il = numModels; i < il; ++i) {\n const modelChainCount = chainsPerModel[ i ]\n mChainOffset[ i ] = chainOffset\n mChainCount[ i ] = modelChainCount\n for (j = 0; j < modelChainCount; ++j) {\n cModelIndex[ j + chainOffset ] = i\n }\n chainOffset += modelChainCount\n }\n\n // set-up chain-residue relations\n const groupsPerChain = sd.groupsPerChain\n let groupOffset = 0\n for (i = 0, il = numChains; i < il; ++i) {\n const chainGroupCount = groupsPerChain[ i ]\n cGroupOffset[ i ] = groupOffset\n cGroupCount[ i ] = chainGroupCount\n for (j = 0; j < chainGroupCount; ++j) {\n gChainIndex[ j + groupOffset ] = i\n }\n groupOffset += chainGroupCount\n }\n\n /// ///\n // get data from group map\n\n let atomOffset = 0\n let bondOffset = 0\n\n for (i = 0, il = numGroups; i < il; ++i) {\n groupData = sd.groupList[ sd.groupTypeList[ i ] ]\n const groupAtomCount = groupData.atomNameList.length\n const groupFormalChargeList = groupData.formalChargeList\n\n const groupBondAtomList = groupData.bondAtomList\n const groupBondOrderList = groupData.bondOrderList\n\n for (j = 0, jl = groupBondOrderList.length; j < jl; ++j) {\n bAtomIndex1[ bondOffset ] = atomOffset + groupBondAtomList[ j * 2 ]\n bAtomIndex2[ bondOffset ] = atomOffset + groupBondAtomList[ j * 2 + 1 ]\n bBondOrder[ bondOffset ] = groupBondOrderList[ j ]\n bondOffset += 1\n }\n\n //\n\n gAtomOffset[ i ] = atomOffset\n gAtomCount[ i ] = groupAtomCount\n\n for (j = 0; j < groupAtomCount; ++j) {\n aGroupIndex[ atomOffset ] = i\n aFormalCharge[ atomOffset ] = groupFormalChargeList[ j ]\n atomOffset += 1\n }\n }\n\n // extra bonds\n\n const bondAtomList = sd.bondAtomList\n if (bondAtomList) {\n if (sd.bondOrderList) {\n bBondOrder.set(sd.bondOrderList, bondOffset)\n }\n\n for (i = 0, il = bondAtomList.length; i < il; i += 2) {\n const atomIndex1 = bondAtomList[ i ]\n const atomIndex2 = bondAtomList[ i + 1 ]\n if (atomIndex1 < numAtoms && atomIndex2 < numAtoms) {\n bAtomIndex1[ bondOffset ] = atomIndex1\n bAtomIndex2[ bondOffset ] = atomIndex2\n bondOffset += 1\n }\n }\n }\n\n //\n\n s.bondStore.length = bBondOrder.length\n s.bondStore.count = bondOffset\n s.bondStore.atomIndex1 = bAtomIndex1\n s.bondStore.atomIndex2 = bAtomIndex2\n s.bondStore.bondOrder = bBondOrder\n\n s.atomStore.length = numAtoms\n s.atomStore.count = numAtoms\n s.atomStore.residueIndex = aGroupIndex\n s.atomStore.atomTypeId = new Uint16Array(numAtoms)\n s.atomStore.x = sd.xCoordList.subarray(0, numAtoms)\n s.atomStore.y = sd.yCoordList.subarray(0, numAtoms)\n s.atomStore.z = sd.zCoordList.subarray(0, numAtoms)\n s.atomStore.serial = sd.atomIdList.subarray(0, numAtoms)\n s.atomStore.bfactor = sd.bFactorList.subarray(0, numAtoms)\n s.atomStore.altloc = sd.altLocList.subarray(0, numAtoms)\n s.atomStore.occupancy = sd.occupancyList.subarray(0, numAtoms)\n s.atomStore.formalCharge = aFormalCharge\n\n s.residueStore.length = numGroups\n s.residueStore.count = numGroups\n s.residueStore.chainIndex = gChainIndex\n s.residueStore.residueTypeId = sd.groupTypeList\n s.residueStore.atomOffset = gAtomOffset\n s.residueStore.atomCount = gAtomCount\n s.residueStore.resno = sd.groupIdList.subarray(0, numGroups)\n s.residueStore.sstruc = sd.secStructList.subarray(0, numGroups)\n s.residueStore.inscode = sd.insCodeList.subarray(0, numGroups)\n\n s.chainStore.length = numChains\n s.chainStore.count = numChains\n s.chainStore.entityIndex = new Uint16Array(numChains)\n s.chainStore.modelIndex = cModelIndex\n s.chainStore.residueOffset = cGroupOffset\n s.chainStore.residueCount = cGroupCount\n s.chainStore.chainname = sd.chainNameList.subarray(0, numChains * 4)\n s.chainStore.chainid = sd.chainIdList.subarray(0, numChains * 4)\n\n s.modelStore.length = numModels\n s.modelStore.count = numModels\n s.modelStore.chainOffset = mChainOffset\n s.modelStore.chainCount = mChainCount\n\n //\n\n let groupTypeDict: {[k: number]: any} = {}\n for (i = 0, il = sd.groupList.length; i < il; ++i) {\n const groupType = sd.groupList[ i ]\n const atomTypeIdList: number[] = []\n for (j = 0, jl = groupType.atomNameList.length; j < jl; ++j) {\n const element = groupType.elementList[ j ].toUpperCase()\n const atomname = groupType.atomNameList[ j ]\n atomTypeIdList.push(s.atomMap.add(atomname, element))\n }\n const chemCompType = groupType.chemCompType.toUpperCase()\n const hetFlag = ChemCompHetero.includes(chemCompType)\n\n const numGroupBonds = groupType.bondOrderList.length\n const atomIndices1 = new Array(numGroupBonds)\n const atomIndices2 = new Array(numGroupBonds)\n for (j = 0; j < numGroupBonds; ++j) {\n atomIndices1[ j ] = groupType.bondAtomList[ j * 2 ]\n atomIndices2[ j ] = groupType.bondAtomList[ j * 2 + 1 ]\n }\n const bonds = {\n atomIndices1: atomIndices1,\n atomIndices2: atomIndices2,\n bondOrders: groupType.bondOrderList\n }\n\n groupTypeDict[ i ] = s.residueMap.add(\n groupType.groupName, atomTypeIdList, hetFlag, chemCompType, bonds\n )\n }\n\n for (i = 0, il = numGroups; i < il; ++i) {\n s.residueStore.residueTypeId[ i ] = groupTypeDict[ s.residueStore.residueTypeId[ i ] ]\n }\n\n for (i = 0, il = s.atomStore.count; i < il; ++i) {\n const residueIndex = s.atomStore.residueIndex[ i ]\n const residueType = s.residueMap.list[ s.residueStore.residueTypeId[ residueIndex ] ]\n const resAtomOffset = s.residueStore.atomOffset[ residueIndex ]\n s.atomStore.atomTypeId[ i ] = residueType.atomTypeIdList[ i - resAtomOffset ]\n }\n\n if (sd.secStructList) {\n const secStructLength: number = sd.secStructList.length\n for (i = 0, il = s.residueStore.count; i < il; ++i) {\n // with ( i % secStructLength ) secStruct entries are reused\n const sstruc = SstrucMap[ s.residueStore.sstruc[ i % secStructLength ] ]\n if (sstruc !== undefined) s.residueStore.sstruc[ i ] = sstruc\n }\n }\n\n //\n\n if (sd.entityList) {\n sd.entityList.forEach(function (e: Entity, i: number) {\n s.entityList[ i ] = new Entity(\n s, i, e.description, e.type, e.chainIndexList\n )\n })\n }\n\n if (sd.bioAssemblyList) {\n sd.bioAssemblyList.forEach(function (_assembly: any, k: number) {\n const id = k + 1\n const assembly = new Assembly('' + id)\n s.biomolDict[ 'BU' + id ] = assembly\n let chainToPart: {[k: string]: AssemblyPart} = {}\n _assembly.transformList.forEach(function (_transform: any) {\n const matrix = new Matrix4().fromArray(_transform.matrix).transpose()\n const chainList: string[] = _transform.chainIndexList.map(function (chainIndex: number) {\n let chainname = ''\n for (let k = 0; k < 4; ++k) {\n const code = sd.chainNameList[ chainIndex * 4 + k ]\n if (code) {\n chainname += String.fromCharCode(code)\n } else {\n break\n }\n }\n return chainname\n })\n const part = chainToPart[ chainList.toString() ]\n if (part) {\n part.matrixList.push(matrix)\n } else {\n chainToPart[ chainList.toString() ] = assembly.addPart([ matrix ], chainList)\n }\n })\n })\n }\n\n if (sd.ncsOperatorList) {\n const ncsName = 'NCS'\n const ncsAssembly = new Assembly(ncsName)\n const ncsPart = ncsAssembly.addPart()\n sd.ncsOperatorList.forEach(function (_operator: number[]) {\n const matrix = new Matrix4().fromArray(_operator).transpose()\n ncsPart.matrixList.push(matrix)\n })\n if (ncsPart.matrixList.length > 0) {\n s.biomolDict[ ncsName ] = ncsAssembly\n }\n }\n\n const uc = sd.unitCell\n if (uc && Array.isArray(uc) && uc[ 0 ]) {\n s.unitcell = new Unitcell({\n a: uc[ 0 ],\n b: uc[ 1 ],\n c: uc[ 2 ],\n alpha: uc[ 3 ],\n beta: uc[ 4 ],\n gamma: uc[ 5 ],\n spacegroup: sd.spaceGroup\n })\n } else {\n s.unitcell = undefined\n }\n\n // calculate backbone bonds\n calculateBondsBetween(s, true)\n\n // calculate rung bonds\n calculateBondsWithin(s, true)\n\n s.finalizeAtoms()\n s.finalizeBonds()\n\n buildUnitcellAssembly(s)\n\n if (Debug) Log.timeEnd('MmtfParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('mmtf', MmtfParser)\n\nexport default MmtfParser\n","/**\n * @file Mol2 Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport {\n assignResidueTypeBonds,\n calculateChainnames, calculateSecondaryStructure,\n calculateBondsBetween, calculateBondsWithin\n} from '../structure/structure-utils'\nimport StructureParser from './structure-parser'\n\nconst reWhitespace = /\\s+/\nconst bondTypes: {[k: string]: number} = {\n '1': 1,\n '2': 2,\n '3': 3,\n 'am': 1, // amide\n 'ar': 1, // aromatic\n 'du': 1, // dummy\n 'un': 1, // unknown\n 'nc': 0 // not connected\n}\n\nclass Mol2Parser extends StructureParser {\n get type () { return 'mol2' }\n\n _parse () {\n // http://paulbourke.net/dataformats/mol2/\n\n if (Debug) Log.time('Mol2Parser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n const firstModelOnly = this.firstModelOnly\n const asTrajectory = this.asTrajectory\n\n const frames = s.frames\n let doFrames = false\n let currentFrame: Float32Array, currentCoord: number\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.resize(Math.round(this.streamer.data.length / 60))\n atomStore.addField('partialCharge', 1, 'float32')\n\n let idx = 0\n let moleculeLineNo = 0\n let modelAtomIdxStart = 0\n let modelIdx = -1\n let numAtoms = 0\n\n let currentRecordType = 0\n let moleculeRecordType = 1\n let atomRecordType = 2\n let bondRecordType = 3\n\n const ap1 = s.getAtomProxy()\n const ap2 = s.getAtomProxy()\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ].trim()\n\n if (line === '' || line[ 0 ] === '#') continue\n\n if (line[ 0 ] === '@') {\n if (line === '@MOLECULE') {\n currentRecordType = moleculeRecordType\n moleculeLineNo = 0\n\n ++modelIdx\n } else if (line === '@ATOM') {\n currentRecordType = atomRecordType\n modelAtomIdxStart = atomStore.count\n\n if (asTrajectory) {\n currentCoord = 0\n currentFrame = new Float32Array(numAtoms * 3)\n frames.push(currentFrame)\n\n if (modelIdx > 0) doFrames = true\n }\n } else if (line === '@BOND') {\n currentRecordType = bondRecordType\n } else {\n currentRecordType = 0\n }\n } else if (currentRecordType === moleculeRecordType) {\n if (moleculeLineNo === 0) {\n s.title = line\n s.id = line\n } else if (moleculeLineNo === 1) {\n const ls = line.split(reWhitespace)\n numAtoms = parseInt(ls[ 0 ])\n // num_atoms [num_bonds [num_subst [num_feat [num_sets]]]]\n } else if (moleculeLineNo === 2) {\n\n // const molType = line;\n // SMALL, BIOPOLYMER, PROTEIN, NUCLEIC_ACID, SACCHARIDE\n\n } else if (moleculeLineNo === 3) {\n\n // const chargeType = line;\n // NO_CHARGES, DEL_RE, GASTEIGER, GAST_HUCK, HUCKEL,\n // PULLMAN, GAUSS80_CHARGES, AMPAC_CHARGES,\n // MULLIKEN_CHARGES, DICT_ CHARGES, MMFF94_CHARGES,\n // USER_CHARGES\n\n } else if (moleculeLineNo === 4) {\n\n // const statusBits = line;\n\n } else if (moleculeLineNo === 5) {\n\n // const molComment = line;\n\n }\n\n ++moleculeLineNo\n } else if (currentRecordType === atomRecordType) {\n const ls = line.split(reWhitespace)\n\n if (firstModelOnly && modelIdx > 0) continue\n\n const x = parseFloat(ls[ 2 ])\n const y = parseFloat(ls[ 3 ])\n const z = parseFloat(ls[ 4 ])\n\n if (asTrajectory) {\n const j = currentCoord * 3\n\n currentFrame[ j + 0 ] = x\n currentFrame[ j + 1 ] = y\n currentFrame[ j + 2 ] = z\n\n currentCoord += 1\n\n if (doFrames) continue\n }\n\n const serial = ls[ 0 ]\n const atomname = ls[ 1 ]\n const element = ls[ 5 ].split('.')[ 0 ]\n const resno = ls[ 6 ] ? parseInt(ls[ 6 ]) : 1\n const resname = ls[ 7 ] ? ls[ 7 ] : ''\n const partialCharge = ls[ 8 ] ? parseFloat(ls[ 8 ]) : 0.0\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname, element)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = serial\n atomStore.partialCharge[ idx ] = partialCharge\n\n sb.addAtom(modelIdx, '', '', resname, resno, true)\n\n idx += 1\n } else if (currentRecordType === bondRecordType) {\n if (firstModelOnly && modelIdx > 0) continue\n if (asTrajectory && modelIdx > 0) continue\n\n const ls = line.split(reWhitespace)\n\n // ls[ 0 ] is bond id\n ap1.index = parseInt(ls[ 1 ]) - 1 + modelAtomIdxStart\n ap2.index = parseInt(ls[ 2 ]) - 1 + modelAtomIdxStart\n const order = bondTypes[ ls[ 3 ] ]\n\n s.bondStore.addBond(ap1, ap2, order)\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n sb.finalize()\n s.finalizeAtoms()\n calculateChainnames(s)\n calculateBondsWithin(s, true)\n calculateBondsBetween(s, true)\n s.finalizeBonds()\n assignResidueTypeBonds(s)\n calculateSecondaryStructure(s)\n\n if (Debug) Log.timeEnd('Mol2Parser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('mol2', Mol2Parser)\n\nexport default Mol2Parser\n","/**\n * @file Pdbqt Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport PdbParser from './pdb-parser'\n\n// autodock variant of PDB format with\n// - atom partial charges (empty column in pdb format)\n// - atom types (bfactor column in pdb format)\n// http://autodock.scripps.edu/faqs-help/faq/what-is-the-format-of-a-pdbqt-file\n\nclass PdbqtParser extends PdbParser {\n get type () { return 'pdbqt' }\n}\n\nParserRegistry.add('pdbqt', PdbqtParser)\n\nexport default PdbqtParser\n","/**\n * @file Pqr Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport PdbParser from './pdb-parser'\n\n// http://www.poissonboltzmann.org/docs/file-format-info/\n\nclass PqrParser extends PdbParser {\n get type () { return 'pqr' }\n}\n\nParserRegistry.add('pqr', PqrParser)\n\nexport default PqrParser\n","/**\n * @file Sdf Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { assignResidueTypeBonds } from '../structure/structure-utils'\nimport StructureParser from './structure-parser'\n\nconst reItem = /> +<(.+)>/\n\nclass SdfParser extends StructureParser {\n get type () { return 'sdf' }\n\n _parse () {\n // https://en.wikipedia.org/wiki/Chemical_table_file#SDF\n // http://download.accelrys.com/freeware/ctfile-formats/ctfile-formats.zip\n\n if (Debug) Log.time('SdfParser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n const firstModelOnly = this.firstModelOnly\n const asTrajectory = this.asTrajectory\n\n const headerLines = this.streamer.peekLines(2)\n\n s.id = headerLines[ 0 ].trim()\n s.title = headerLines[ 1 ].trim()\n\n const frames = s.frames\n let doFrames = false\n let currentFrame: Float32Array, currentCoord: number\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.resize(Math.round(this.streamer.data.length / 50))\n atomStore.addField('formalCharge', 1, 'int8')\n\n const ap1 = s.getAtomProxy()\n const ap2 = s.getAtomProxy()\n\n let idx = 0\n let lineNo = 0 // for V2000: current line number in currently parsed Mol file\n let modelIdx = 0\n let modelAtomIdxStart = 0\n\n const sdfData: {[k: string]: string[]}[] = []\n let currentItem: string|boolean = false\n let currentData: {[k: string]: string[]} = {}\n let mItem: RegExpMatchArray | null\n s.extraData.sdf = sdfData\n\n let atomCount, bondCount, atomStart: number, atomEnd: number, bondStart: number, bondEnd: number, x: number, y: number, z: number, atomname: string, element: string, atomindex: number, order: number\n let isV3000 = false, isAtomBlock = false, isBondBlock = false\n let tokens: string[] = [], acc: string[] = []\n const atomindexToStoreindex = new Map()\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n\n if (isV3000 && line) {\n tokens = line.substring(7).split(' ')\n\n // Entity properties may extend over multiple lines (hanging line finishes with '-')\n // Tokens are accumulated to be processed at the same time for a given entity\n if (acc.length) {\n tokens = [...acc, ...tokens]\n acc = []\n }\n if (tokens[tokens.length - 1] === '-') {\n tokens.pop();\n acc = tokens;\n continue;\n }\n }\n\n if (line.substr(0, 4) === '$$$$') {\n lineNo = -1\n ++modelIdx\n modelAtomIdxStart = atomStore.count\n sdfData.push(currentData)\n currentData = {}\n currentItem = false\n isV3000 = false\n } else if (lineNo === 3) {\n isV3000 = line.indexOf(' V3000') > -1\n\n if (isV3000) {\n atomindexToStoreindex.clear()\n } else {\n\n atomCount = parseInt(line.substr(0, 3))\n bondCount = parseInt(line.substr(3, 3))\n\n atomStart = 4\n atomEnd = atomStart + atomCount\n bondStart = atomEnd\n bondEnd = bondStart + bondCount\n\n if (asTrajectory) {\n currentCoord = 0\n currentFrame = new Float32Array(atomCount * 3)\n frames.push(currentFrame)\n\n if (modelIdx > 0) doFrames = true\n }\n }\n } else if (isV3000 && tokens[0] === 'COUNTS') {\n atomCount = parseInt(tokens[1]);\n\n if (asTrajectory) {\n currentCoord = 0\n currentFrame = new Float32Array(atomCount * 3)\n frames.push(currentFrame)\n\n if (modelIdx > 0) doFrames = true\n }\n } else if (isV3000 && tokens.length == 2) {\n if (tokens[1] === 'ATOM') {\n if (tokens[0] === 'BEGIN') isAtomBlock = true\n else if (tokens[0] === 'END') isAtomBlock = false\n } else if (tokens[1] === 'BOND') {\n if (tokens[0] === 'BEGIN') isBondBlock = true\n else if (tokens[0] === 'END') isBondBlock = false\n }\n } else if (\n isAtomBlock \n || (!isV3000 && lineNo >= atomStart && lineNo < atomEnd)\n ) {\n if (firstModelOnly && modelIdx > 0) continue\n\n let charge = 0\n if (isV3000) {\n x = parseFloat(tokens[2])\n y = parseFloat(tokens[3])\n z = parseFloat(tokens[4])\n\n element = tokens[1]\n atomindex = parseInt(tokens[0])\n atomindexToStoreindex.set(atomindex, idx)\n atomname = element + atomindex\n\n if (tokens.length > 6) {\n let chgTok = tokens.slice(6).find(t => t.indexOf('CHG=') === 0);\n if (chgTok) {\n charge = parseInt(chgTok.substring(4))\n }\n }\n } else {\n x = parseFloat(line.substr(0, 10))\n y = parseFloat(line.substr(10, 10))\n z = parseFloat(line.substr(20, 10))\n\n element = line.substr(31, 3).trim()\n atomname = element + (idx - modelAtomIdxStart + 1)\n }\n\n if (asTrajectory) {\n const j = currentCoord * 3\n\n currentFrame[ j + 0 ] = x\n currentFrame[ j + 1 ] = y\n currentFrame[ j + 2 ] = z\n\n currentCoord += 1\n\n if (doFrames) continue\n }\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname, element)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = isV3000 ? atomindex : idx\n atomStore.formalCharge[ idx ] = charge\n\n sb.addAtom(modelIdx, '', '', 'HET', 1, true)\n\n idx += 1\n } else if (\n isBondBlock \n || (!isV3000 && lineNo >= bondStart && lineNo < bondEnd)\n ) {\n if (firstModelOnly && modelIdx > 0) continue\n if (asTrajectory && modelIdx > 0) continue\n\n if (isV3000) {\n ap1.index = atomindexToStoreindex.get(parseInt(tokens[2]))\n ap2.index = atomindexToStoreindex.get(parseInt(tokens[3]))\n order = parseInt(tokens[1])\n } else {\n ap1.index = parseInt(line.substr(0, 3)) - 1 + modelAtomIdxStart\n ap2.index = parseInt(line.substr(3, 3)) - 1 + modelAtomIdxStart\n order = parseInt(line.substr(6, 3))\n }\n\n s.bondStore.addBond(ap1, ap2, order)\n } else if (line.substr(0, 6) === 'M CHG') {\n const chargeCount = parseInt(line.substr(6, 3))\n for (let ci = 0, coffset = 10; ci < chargeCount; ++ci, coffset += 8) {\n const aToken = parseInt(line.substr(coffset, 3))\n const atomIdx = aToken - 1 + modelAtomIdxStart\n const cToken = parseInt(line.substr(coffset + 4, 3))\n atomStore.formalCharge[ atomIdx ] = cToken\n }\n // eslint-disable-next-line no-cond-assign\n } else if (line.charAt(0) === '>' && (mItem = line.match(reItem))) {\n currentItem = mItem[ 1 ]\n currentData[ currentItem ] = []\n } else if (currentItem !== false && line) {\n currentData[ currentItem ].push(line)\n }\n\n ++lineNo\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n assignResidueTypeBonds(s)\n\n if (Debug) Log.timeEnd('SdfParser._parse ' + this.name)\n }\n\n _postProcess () {\n assignResidueTypeBonds(this.structure)\n }\n}\n\nParserRegistry.add('sdf', SdfParser)\nParserRegistry.add('sd', SdfParser)\nParserRegistry.add('mol', SdfParser)\n\nexport default SdfParser\n","/**\n * @file Prmtop Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport {\n assignResidueTypeBonds, calculateBondsBetween,\n calculateBondsWithin, calculateChainnames\n} from '../structure/structure-utils'\n\nconst amberChargeUnitFactor = 18.2223\n\nconst enum Mode {\n Title,\n Pointers,\n AtomName,\n Charge,\n Mass,\n ResidueLabel,\n ResiduePointer,\n BondsIncHydrogen,\n BondsWithoutHydrogen,\n Radii\n}\n\nfunction parseIntSubstr (line: string, start: number, length: number) {\n return parseInt(line.substr(start, length).trim())\n}\n\nclass PrmtopParser extends StructureParser {\n get type () { return 'prmtop' }\n\n _parse () {\n // http://ambermd.org/prmtop.pdf\n // http://ambermd.org/formats.html#topology\n\n if (Debug) Log.time('PrmtopParser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n //\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.addField('partialCharge', 1, 'float32')\n atomStore.addField('radius', 1, 'float32')\n\n const title: string[] = []\n const pointersDict: {[k: string]: number} = {}\n const pointers = [\n 'NATOM', 'NTYPES', 'NBONH', 'MBONA', 'NTHETH', 'MTHETA',\n 'NPHIH', 'MPHIA', 'NHPARM', 'NPARM', 'NNB', 'NRES',\n 'NBONA', 'NTHETA', 'NPHIA', 'NUMBND', 'NUMANG', 'NPTRA',\n 'NATYP', 'NPHB', 'IFPERT', 'NBPER', 'NGPER', 'NDPER',\n 'MBPER', 'MGPER', 'MDPER', 'IFBOX', 'NMXRS', 'IFCAP',\n 'NUMEXTRA', 'NCOPY'\n ]\n pointers.forEach(name => { pointersDict[ name ] = 0 })\n\n let atomNames: string[]\n let charges: Float32Array\n let radii: Float32Array\n let bAtomIndex1: Uint32Array\n let bAtomIndex2: Uint32Array\n let bBondOrder: Uint8Array = new Uint8Array(0)\n let residueLabels: string[]\n let residuePointers: Uint32Array\n\n let mode: number|undefined\n // let currentFormat\n let curIdx: number\n let bondIdx: number\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n const lt = line.trim()\n\n if (!lt) {\n continue\n } else if (line.startsWith('%FORMAT')) {\n // currentFormat = lt.substring(8, lt.length - 1)\n } else if (line.startsWith('%FLAG')) {\n const flag = line.substr(5).trim()\n curIdx = 0\n\n if (flag === 'TITLE') {\n mode = Mode.Title\n } else if (flag === 'POINTERS') {\n mode = Mode.Pointers\n } else if (flag === 'ATOM_NAME') {\n mode = Mode.AtomName\n } else if (flag === 'CHARGE') {\n mode = Mode.Charge\n } else if (flag === 'MASS') {\n mode = Mode.Mass\n } else if (flag === 'RESIDUE_LABEL') {\n mode = Mode.ResidueLabel\n } else if (flag === 'RESIDUE_POINTER') {\n mode = Mode.ResiduePointer\n } else if (flag === 'BONDS_INC_HYDROGEN') {\n bondIdx = 0\n mode = Mode.BondsIncHydrogen\n } else if (flag === 'BONDS_WITHOUT_HYDROGEN') {\n bondIdx = pointersDict['NBONH']\n mode = Mode.BondsWithoutHydrogen\n } else if (flag === 'RADII') {\n mode = Mode.Radii\n } else {\n mode = undefined\n }\n } else if (mode === Mode.Title) {\n title.push(lt)\n } else if (mode === Mode.Pointers) {\n const n = Math.min(curIdx + 10, 32)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n pointersDict[pointers[curIdx]] = parseInt(\n line.substr(i * 8, 8).trim()\n )\n }\n atomNames = new Array(pointersDict.NATOM)\n charges = new Float32Array(pointersDict.NATOM)\n radii = new Float32Array(pointersDict.NATOM)\n atomStore.resize(pointersDict.NATOM)\n const bondCount = pointersDict.NBONH + pointersDict.MBONA\n bAtomIndex1 = new Uint32Array(bondCount)\n bAtomIndex2 = new Uint32Array(bondCount)\n bBondOrder = new Uint8Array(bondCount)\n residueLabels = new Array(pointersDict.NRES)\n residuePointers = new Uint32Array(pointersDict.NRES)\n } else if (mode === Mode.AtomName) {\n const n = Math.min(curIdx + 20, pointersDict.NATOM)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n atomNames[curIdx] = line.substr(i * 4, 4).trim()\n }\n } else if (mode === Mode.Charge) {\n const n = Math.min(curIdx + 5, pointersDict.NATOM)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n charges[curIdx] = parseFloat(line.substr(i * 16, 16)) / amberChargeUnitFactor\n }\n } else if (mode === Mode.Mass) {\n\n // not currently used\n\n } else if (mode === Mode.ResidueLabel) {\n const n = Math.min(curIdx + 20, pointersDict.NRES)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n residueLabels[curIdx] = line.substr(i * 4, 4).trim()\n }\n } else if (mode === Mode.ResiduePointer) {\n const n = Math.min(curIdx + 10, pointersDict.NRES)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n residuePointers[curIdx] = parseIntSubstr(line, i * 8, 8)\n }\n } else if (mode === Mode.BondsIncHydrogen) {\n const n = Math.min(curIdx + 10, pointersDict.NBONH * 3)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n const r = curIdx % 3\n if (r === 0) {\n bAtomIndex1[bondIdx] = parseIntSubstr(line, i * 8, 8) / 3\n } if (r === 1) {\n bAtomIndex2[bondIdx] = parseIntSubstr(line, i * 8, 8) / 3\n bBondOrder[bondIdx] = 1\n ++bondIdx\n }\n }\n } else if (mode === Mode.BondsWithoutHydrogen) {\n const n = Math.min(curIdx + 10, pointersDict.MBONA * 3)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n const r = curIdx % 3\n if (r === 0) {\n bAtomIndex1[bondIdx] = parseIntSubstr(line, i * 8, 8) / 3\n } if (r === 1) {\n bAtomIndex2[bondIdx] = parseIntSubstr(line, i * 8, 8) / 3\n bBondOrder[bondIdx] = 1\n ++bondIdx\n }\n }\n } else if (mode === Mode.Radii) {\n const n = Math.min(curIdx + 5, pointersDict.NATOM)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n radii[curIdx] = parseFloat(line.substr(i * 16, 16))\n }\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n s.title = title.join(' ')\n\n const atomCount = pointersDict.NATOM\n let curResIdx = 0\n let curResname = residueLabels![0]\n let curResno = 1\n for (let i = 0; i < atomCount; ++i) {\n if (i + 1 === residuePointers![curResIdx + 1]) {\n ++curResIdx\n curResname = residueLabels![curResIdx]\n curResno = curResIdx + 1\n }\n atomStore.atomTypeId[i] = atomMap.add(atomNames![i])\n atomStore.serial[i] = i + 1\n sb.addAtom(0, '', '', curResname, curResno, false)\n }\n\n atomStore.partialCharge.set(charges!)\n atomStore.radius.set(radii!)\n\n s.bondStore.length = bBondOrder!.length\n s.bondStore.count = bBondOrder!.length\n s.bondStore.atomIndex1 = bAtomIndex1!\n s.bondStore.atomIndex2 = bAtomIndex2!\n s.bondStore.bondOrder = bBondOrder\n\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n calculateBondsWithin(s, true)\n calculateBondsBetween(s, true, true)\n calculateChainnames(s, true)\n assignResidueTypeBonds(s)\n\n if (Debug) Log.timeEnd('PrmtopParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('prmtop', PrmtopParser)\nParserRegistry.add('parm7', PrmtopParser)\n\nexport default PrmtopParser\n","/**\n * @file Psf Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport {\n assignResidueTypeBonds, calculateBondsBetween,\n calculateBondsWithin, getChainname\n} from '../structure/structure-utils'\n\nconst TitleMode = 1\nconst AtomMode = 2\nconst BondMode = 3\nconst AngleMode = 4\nconst DihedralMode = 5\nconst ImproperMode = 6\n\nconst reWhitespace = /\\s+/\nconst reTitle = /(^\\*|REMARK)*/\n\nclass PsfParser extends StructureParser {\n get type () { return 'psf' }\n\n _parse () {\n // http://www.ks.uiuc.edu/Training/Tutorials/namd/namd-tutorial-unix-html/node23.html\n\n if (Debug) Log.time('PsfParser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n //\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.addField('partialCharge', 1, 'float32')\n\n const title: string[] = []\n\n let mode: number|undefined\n let chainid: string\n let lastSegid: string\n let idx = 0\n let chainIdx = 0\n let bondIdx = 0\n let bAtomIndex1: Uint32Array, bAtomIndex2: Uint32Array, bBondOrder: Uint8Array\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ].trim()\n\n if (!line) {\n mode = undefined\n continue\n }\n\n if (mode === AtomMode) {\n const ls = line.split(reWhitespace)\n\n const serial = parseInt(ls[ 0 ])\n const segid = ls[ 1 ]\n const resno = parseInt(ls[ 2 ])\n const resname = ls[ 3 ]\n const atomname = ls[ 4 ]\n const charge = parseFloat(ls[ 6 ])\n\n if (segid !== lastSegid) {\n chainid = getChainname(chainIdx)\n ++chainIdx\n }\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname)\n\n atomStore.serial[ idx ] = serial\n atomStore.partialCharge[ idx ] = charge\n\n sb.addAtom(0, chainid, chainid, resname, resno, false)\n\n idx += 1\n lastSegid = segid\n } else if (mode === BondMode) {\n const ls = line.split(reWhitespace)\n\n for (let j = 0, m = ls.length; j < m; j += 2) {\n bAtomIndex1[ bondIdx ] = parseInt(ls[ j ]) - 1\n bAtomIndex2[ bondIdx ] = parseInt(ls[ j + 1 ]) - 1\n bBondOrder[ bondIdx ] = 1\n bondIdx += 1\n }\n } else if (mode === TitleMode) {\n title.push(line.replace(reTitle, '').trim())\n } else if (mode === AngleMode) {\n\n // currently not used\n\n } else if (mode === DihedralMode) {\n\n // currently not used\n\n } else if (mode === ImproperMode) {\n\n // currently not used\n\n } else if (line.includes('!NATOM')) {\n mode = AtomMode\n\n const numAtoms = parseInt(line.split(reWhitespace)[ 0 ])\n atomStore.resize(numAtoms)\n } else if (line.includes('!NBOND')) {\n mode = BondMode\n\n const numBonds = parseInt(line.split(reWhitespace)[ 0 ])\n bAtomIndex1 = new Uint32Array(numBonds)\n bAtomIndex2 = new Uint32Array(numBonds)\n bBondOrder = new Uint8Array(numBonds)\n } else if (line.includes('!NTITLE')) {\n mode = TitleMode\n } else if (line.includes('!NTHETA')) {\n mode = AngleMode\n } else if (line.includes('!NPHI')) {\n mode = DihedralMode\n } else if (line.includes('!NIMPHI')) {\n mode = ImproperMode\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n s.title = title.join(' ')\n\n s.bondStore.length = bBondOrder!.length\n s.bondStore.count = bondIdx\n s.bondStore.atomIndex1 = bAtomIndex1!\n s.bondStore.atomIndex2 = bAtomIndex2!\n s.bondStore.bondOrder = bBondOrder!\n\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n calculateBondsWithin(s, true)\n calculateBondsBetween(s, true, true)\n assignResidueTypeBonds(s)\n\n if (Debug) Log.timeEnd('PsfParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('psf', PsfParser)\n\nexport default PsfParser\n","/**\n * @file Top Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport { WaterNames } from '../structure/structure-constants'\nimport {\n assignResidueTypeBonds, calculateBondsBetween,\n calculateBondsWithin, getChainname\n} from '../structure/structure-utils'\n\nconst enum Mode {\n System,\n Molecules,\n Moleculetype,\n Atoms,\n Bonds\n}\n\nconst reField = /\\[ (.+) \\]/\nconst reWhitespace = /\\s+/\n\nclass TopParser extends StructureParser {\n get type () { return 'top' }\n\n _parse () {\n // http://manual.gromacs.org/online/top.html\n\n if (Debug) Log.time('TopParser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n //\n\n const atomMap = s.atomMap\n const bondStore = s.bondStore\n\n const atomStore = s.atomStore\n atomStore.addField('partialCharge', 1, 'float32')\n\n const molecules: [string, number][] = []\n const moleculetypeDict: {[k: string]: {atoms: any[], bonds: any[] }} = {}\n\n let currentMoleculetype: {\n atoms: [number, string, string, number][],\n bonds: [number, number][]\n }\n let mode: number|undefined\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n let lt = line.trim()\n\n if (!lt || lt[0] === '*' || lt[0] === ';') {\n continue\n }\n\n if (lt.startsWith('#include')) {\n throw new Error('TopParser: #include statements not allowed')\n }\n\n const fieldMatch = line.match(reField)\n if (fieldMatch !== null) {\n const name = fieldMatch[1]\n if (name === 'moleculetype') {\n mode = Mode.Moleculetype\n currentMoleculetype = {\n atoms: [],\n bonds: []\n }\n } else if (name === 'atoms') {\n mode = Mode.Atoms\n } else if (name === 'bonds') {\n mode = Mode.Bonds\n } else if (name === 'system') {\n mode = Mode.System\n } else if (name === 'molecules') {\n mode = Mode.Molecules\n } else {\n mode = undefined\n }\n continue\n }\n\n const cIdx = lt.indexOf(';')\n if (cIdx !== -1) {\n lt = lt.substring(0, cIdx).trim()\n }\n if (mode === Mode.Moleculetype) {\n const molName = lt.split(reWhitespace)[0]\n moleculetypeDict[molName] = currentMoleculetype\n } else if (mode === Mode.Atoms) {\n const ls = lt.split(reWhitespace)\n currentMoleculetype.atoms.push([\n parseInt(ls[2]), // resnr\n ls[3], // residue\n ls[4], // atom\n parseFloat(ls[6]) // charge\n ])\n } else if (mode === Mode.Bonds) {\n const ls = lt.split(reWhitespace)\n currentMoleculetype.bonds.push([\n parseInt(ls[0]), // ai\n parseInt(ls[1]) // aj\n ])\n } else if (mode === Mode.System) {\n s.title = lt\n } else if (mode === Mode.Molecules) {\n const ls = lt.split(reWhitespace)\n molecules.push([\n ls[0], // name\n parseInt(ls[1]) // count\n ])\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n let atomCount = 0\n let bondCount = 0\n molecules.forEach(function (val) {\n const [name, molCount] = val\n const molType = moleculetypeDict[name]\n atomCount += molCount * molType.atoms.length\n bondCount += molCount * molType.bonds.length\n })\n\n atomStore.resize(atomCount)\n bondStore.resize(bondCount)\n\n let atomIdx = 0\n let resIdx = 0\n let chainidIdx = 0\n let chainnameIdx = 0\n let bondIdx = 0\n let atomOffset = 0\n let lastResno: number\n\n molecules.forEach(function (val) {\n const [name, molCount] = val\n const molType = moleculetypeDict[name]\n const chainname = getChainname(chainnameIdx)\n for (let i = 0; i < molCount; ++i) {\n lastResno = -1\n const chainid = WaterNames.includes(name) ? chainname : getChainname(chainidIdx)\n molType.atoms.forEach(function (atomData) {\n const [resno, resname, atomname, charge] = atomData\n if (resno !== lastResno) {\n ++resIdx\n }\n atomStore.atomTypeId[atomIdx] = atomMap.add(atomname)\n atomStore.serial[atomIdx] = atomIdx + 1\n atomStore.partialCharge[atomIdx] = charge\n sb.addAtom(0, chainname, chainid, resname, resIdx + 1, false)\n ++atomIdx\n lastResno = resno\n })\n molType.bonds.forEach(function (bondData) {\n bondStore.atomIndex1[bondIdx] = atomOffset + bondData[0] - 1\n bondStore.atomIndex2[bondIdx] = atomOffset + bondData[1] - 1\n ++bondIdx\n })\n ++chainidIdx\n atomOffset += molType.atoms.length\n }\n ++chainnameIdx\n })\n\n bondStore.count = bondCount\n\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n calculateBondsWithin(s, true)\n calculateBondsBetween(s, true, true)\n assignResidueTypeBonds(s)\n\n if (Debug) Log.timeEnd('TopParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('top', TopParser)\n\nexport default TopParser\n","/**\n * @file Trajectory Parser\n * @author Alexander Rose \n * @private\n */\n\nimport Parser, { ParserParameters } from './parser'\nimport Frames from '../trajectory/frames'\nimport Streamer from '../streamer/streamer';\n\nclass TrajectoryParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n super(streamer, params)\n\n this.frames = new Frames(this.name, this.path)\n }\n\n get type () { return 'trajectory' }\n get __objName () { return 'frames' }\n}\n\nexport default TrajectoryParser\n","/**\n * @file Netcdf Reader\n * @author Alexander Rose \n * @private\n *\n * Adapted from https://github.com/cheminfo-js/netcdfjs\n * MIT License, Copyright (c) 2016 cheminfo\n */\n\nimport IOBuffer from './io-buffer'\n\nexport interface NetCDFRecordDimension {\n length: number,\n id?: number,\n name?: string,\n recordStep?: number\n}\n\nexport interface NetCDFHeader {\n recordDimension: NetCDFRecordDimension,\n version: number,\n dimensions: any[],\n globalAttributes: any[],\n variables: any[]\n}\n\nexport interface NetCDFDimension {\n name: string,\n size: number\n}\n\n/**\n * Throws a non-valid NetCDF exception if the statement it's true\n * @ignore\n * @param {boolean} statement - Throws if true\n * @param {string} reason - Reason to throw\n */\nfunction notNetcdf (statement: boolean, reason: string) {\n if (statement) {\n throw new TypeError('Not a valid NetCDF v3.x file: ' + reason)\n }\n}\n\n/**\n * Moves 1, 2, or 3 bytes to next 4-byte boundary\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n */\nfunction padding (buffer: IOBuffer) {\n if ((buffer.offset % 4) !== 0) {\n buffer.skip(4 - (buffer.offset % 4))\n }\n}\n\n/**\n * Reads the name\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @return {string} - Name\n */\nfunction readName (buffer: IOBuffer) {\n // Read name\n const nameLength = buffer.readUint32()\n const name = buffer.readChars(nameLength)\n\n // validate name\n // TODO\n\n // Apply padding\n padding(buffer)\n return name\n}\n\nconst types = {\n BYTE: 1,\n CHAR: 2,\n SHORT: 3,\n INT: 4,\n FLOAT: 5,\n DOUBLE: 6\n}\n\n/**\n * Parse a number into their respective type\n * @ignore\n * @param {number} type - integer that represents the type\n * @return {string} - parsed value of the type\n */\nfunction num2str (type: number) {\n switch (Number(type)) {\n case types.BYTE:\n return 'byte'\n case types.CHAR:\n return 'char'\n case types.SHORT:\n return 'short'\n case types.INT:\n return 'int'\n case types.FLOAT:\n return 'float'\n case types.DOUBLE:\n return 'double'\n default:\n return 'undefined'\n }\n}\n\n/**\n * Parse a number type identifier to his size in bytes\n * @ignore\n * @param {number} type - integer that represents the type\n * @return {number} -size of the type\n */\nfunction num2bytes (type: number) {\n switch (Number(type)) {\n case types.BYTE:\n return 1\n case types.CHAR:\n return 1\n case types.SHORT:\n return 2\n case types.INT:\n return 4\n case types.FLOAT:\n return 4\n case types.DOUBLE:\n return 8\n default:\n return -1\n }\n}\n\n/**\n * Reverse search of num2str\n * @ignore\n * @param {string} type - string that represents the type\n * @return {number} - parsed value of the type\n */\nfunction str2num (type: string) {\n switch (String(type)) {\n case 'byte':\n return types.BYTE\n case 'char':\n return types.CHAR\n case 'short':\n return types.SHORT\n case 'int':\n return types.INT\n case 'float':\n return types.FLOAT\n case 'double':\n return types.DOUBLE\n default:\n return -1\n }\n}\n\n/**\n * Auxiliary function to read numeric data\n * @ignore\n * @param {number} size - Size of the element to read\n * @param {function} bufferReader - Function to read next value\n * @return {Array|number}\n */\nfunction readNumber (size: number, bufferReader: Function) {\n if (size !== 1) {\n const numbers = new Array(size)\n for (let i = 0; i < size; i++) {\n numbers[i] = bufferReader()\n }\n return numbers\n } else {\n return bufferReader()\n }\n}\n\n/**\n * Given a type and a size reads the next element\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {number} type - Type of the data to read\n * @param {number} size - Size of the element to read\n * @return {string|Array|number}\n */\nfunction readType (buffer: IOBuffer, type: number, size: number) {\n switch (type) {\n case types.BYTE:\n return buffer.readBytes(size)\n case types.CHAR:\n return trimNull(buffer.readChars(size))\n case types.SHORT:\n return readNumber(size, buffer.readInt16.bind(buffer))\n case types.INT:\n return readNumber(size, buffer.readInt32.bind(buffer))\n case types.FLOAT:\n return readNumber(size, buffer.readFloat32.bind(buffer))\n case types.DOUBLE:\n return readNumber(size, buffer.readFloat64.bind(buffer))\n default:\n notNetcdf(true, 'non valid type ' + type)\n return undefined\n }\n}\n\n/**\n * Removes null terminate value\n * @ignore\n * @param {string} value - String to trim\n * @return {string} - Trimmed string\n */\nfunction trimNull (value: string) {\n if (value.charCodeAt(value.length - 1) === 0) {\n return value.substring(0, value.length - 1)\n }\n return value\n}\n\n// const STREAMING = 4294967295;\n\n/**\n * Read data for the given non-record variable\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {object} variable - Variable metadata\n * @return {Array} - Data of the element\n */\nfunction nonRecord (buffer: IOBuffer, variable: {type: string, size: number}) {\n // variable type\n const type = str2num(variable.type)\n\n // size of the data\n const size = variable.size / num2bytes(type)\n\n // iterates over the data\n const data = new Array(size)\n for (let i = 0; i < size; i++) {\n data[i] = readType(buffer, type, 1)\n }\n\n return data\n}\n\n/**\n * Read data for the given record variable\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {object} variable - Variable metadata\n * @param {object} recordDimension - Record dimension metadata\n * @return {Array} - Data of the element\n */\nfunction record (buffer:IOBuffer, variable: {type: string, size: number}, recordDimension: NetCDFRecordDimension) {\n // variable type\n const type = str2num(variable.type)\n const width = variable.size ? variable.size / num2bytes(type) : 1\n\n // size of the data\n // TODO streaming data\n const size = recordDimension.length\n\n // iterates over the data\n const data = new Array(size)\n const step = recordDimension.recordStep\n\n for (let i = 0; i < size; i++) {\n const currentOffset = buffer.offset\n data[i] = readType(buffer, type, width)\n buffer.seek(currentOffset + step!)\n }\n\n return data\n}\n\n// Grammar constants\nconst ZERO = 0\nconst NC_DIMENSION = 10\nconst NC_VARIABLE = 11\nconst NC_ATTRIBUTE = 12\n\n/**\n * Read the header of the file\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {number} version - Version of the file\n * @return {object} - Object with the fields:\n * * `recordDimension`: Number with the length of record dimension\n * * `dimensions`: List of dimensions\n * * `globalAttributes`: List of global attributes\n * * `variables`: List of variables\n */\nfunction header (buffer: IOBuffer, version: number) {\n // Length of record dimension\n // sum of the varSize's of all the record variables.\n const header: Partial = {recordDimension: {length: buffer.readUint32()}}\n\n // Version\n header.version = version\n\n // List of dimensions\n const dimList = dimensionsList(buffer) as {dimensions: NetCDFDimension[], recordId: number, recordName: string}\n header.recordDimension!.id = dimList.recordId\n header.recordDimension!.name = dimList.recordName\n header.dimensions = dimList.dimensions\n\n // List of global attributes\n header.globalAttributes = attributesList(buffer)\n\n // List of variables\n const variables = variablesList(buffer, dimList.recordId, version) as {variables: any[], recordStep: number}\n header.variables = variables.variables\n header.recordDimension!.recordStep = variables.recordStep\n\n return header\n}\n\n/**\n * List of dimensions\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @return {object} - List of dimensions and record dimension with:\n * * `name`: String with the name of the dimension\n * * `size`: Number with the size of the dimension\n */\nfunction dimensionsList (buffer: IOBuffer) {\n let dimensions: NetCDFDimension[], recordId, recordName\n const dimList = buffer.readUint32()\n if (dimList === ZERO) {\n notNetcdf((buffer.readUint32() !== ZERO), 'wrong empty tag for list of dimensions')\n return []\n } else {\n notNetcdf((dimList !== NC_DIMENSION), 'wrong tag for list of dimensions')\n\n // Length of dimensions\n const dimensionSize = buffer.readUint32()\n dimensions = new Array(dimensionSize)\n for (let dim = 0; dim < dimensionSize; dim++) {\n // Read name\n const name = readName(buffer)\n\n // Read dimension size\n const size = buffer.readUint32()\n if (size === 0) {\n recordId = dim\n recordName = name\n }\n\n dimensions[dim] = {\n name: name,\n size: size\n }\n }\n return {\n dimensions: dimensions,\n recordId: recordId,\n recordName: recordName\n }\n }\n}\n\n/**\n * List of attributes\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @return {Array} - List of attributes with:\n * * `name`: String with the name of the attribute\n * * `type`: String with the type of the attribute\n * * `value`: A number or string with the value of the attribute\n */\nfunction attributesList (buffer: IOBuffer) {\n let attributes\n const gAttList = buffer.readUint32()\n if (gAttList === ZERO) {\n notNetcdf((buffer.readUint32() !== ZERO), 'wrong empty tag for list of attributes')\n return []\n } else {\n notNetcdf((gAttList !== NC_ATTRIBUTE), 'wrong tag for list of attributes')\n\n // Length of attributes\n const attributeSize = buffer.readUint32()\n attributes = new Array(attributeSize)\n for (let gAtt = 0; gAtt < attributeSize; gAtt++) {\n // Read name\n const name = readName(buffer)\n\n // Read type\n const type = buffer.readUint32()\n notNetcdf(((type < 1) || (type > 6)), 'non valid type ' + type)\n\n // Read attribute\n const size = buffer.readUint32()\n const value = readType(buffer, type, size)\n\n // Apply padding\n padding(buffer)\n\n attributes[gAtt] = {\n name: name,\n type: num2str(type),\n value: value\n }\n }\n }\n return attributes\n}\n\n/**\n * List of variables\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {number} recordId - Id if the record dimension\n * @param {number} version - Version of the file\n * @return {object} - Number of recordStep and list of variables with:\n * * `name`: String with the name of the variable\n * * `dimensions`: Array with the dimension IDs of the variable\n * * `attributes`: Array with the attributes of the variable\n * * `type`: String with the type of the variable\n * * `size`: Number with the size of the variable\n * * `offset`: Number with the offset where of the variable begins\n * * `record`: True if is a record variable, false otherwise\n */\nfunction variablesList (buffer: IOBuffer, recordId: number, version: number) {\n const varList = buffer.readUint32()\n let recordStep = 0\n let variables\n if (varList === ZERO) {\n notNetcdf(\n (buffer.readUint32() !== ZERO),\n 'wrong empty tag for list of variables'\n )\n return []\n } else {\n notNetcdf((varList !== NC_VARIABLE), 'wrong tag for list of variables')\n\n // Length of variables\n const variableSize = buffer.readUint32()\n variables = new Array(variableSize)\n for (let v = 0; v < variableSize; v++) {\n // Read name\n const name = readName(buffer)\n\n // Read dimensionality of the variable\n const dimensionality = buffer.readUint32()\n\n // Index into the list of dimensions\n const dimensionsIds = new Array(dimensionality)\n for (let dim = 0; dim < dimensionality; dim++) {\n dimensionsIds[dim] = buffer.readUint32()\n }\n\n // Read variables size\n const attributes = attributesList(buffer)\n\n // Read type\n const type = buffer.readUint32()\n notNetcdf(((type < 1) && (type > 6)), 'non valid type ' + type)\n\n // Read variable size\n // The 32-bit varSize field is not large enough to contain the\n // size of variables that require more than 2^32 - 4 bytes,\n // so 2^32 - 1 is used in the varSize field for such variables.\n const varSize = buffer.readUint32()\n\n // Read offset\n let offset = buffer.readUint32()\n if (version === 2) {\n notNetcdf((offset > 0), 'offsets larger than 4GB not supported')\n offset = buffer.readUint32()\n }\n\n // Count amount of record variables\n if (dimensionsIds[0] === recordId) {\n recordStep += varSize\n }\n\n variables[v] = {\n name: name,\n dimensions: dimensionsIds,\n attributes: attributes,\n type: num2str(type),\n size: varSize,\n offset: offset,\n record: (dimensionsIds[0] === recordId)\n }\n }\n }\n\n return {\n variables: variables,\n recordStep: recordStep\n }\n}\n\n/**\n * Reads a NetCDF v3.x file\n * https://www.unidata.ucar.edu/software/netcdf/docs/file_format_specifications.html\n */\nclass NetcdfReader {\n header: Partial\n buffer: IOBuffer\n /**\n * @param {ArrayBuffer} data - ArrayBuffer or any Typed Array with the data\n */\n constructor (data: ArrayBuffer) {\n const buffer = new IOBuffer(data)\n buffer.setBigEndian()\n\n // Validate that it's a NetCDF file\n notNetcdf((buffer.readChars(3) !== 'CDF'), 'should start with CDF')\n\n // Check the NetCDF format\n const version = buffer.readByte()\n notNetcdf((version > 2), 'unknown version')\n\n // Read the header\n this.header = header(buffer, version)\n this.buffer = buffer\n }\n\n /**\n * @return {string} - Version for the NetCDF format\n */\n get version () {\n if (this.header.version === 1) {\n return 'classic format'\n } else {\n return '64-bit offset format'\n }\n }\n\n /**\n * @return {object} - Metadata for the record dimension\n * * `length`: Number of elements in the record dimension\n * * `id`: Id number in the list of dimensions for the record dimension\n * * `name`: String with the name of the record dimension\n * * `recordStep`: Number with the record variables step size\n */\n get recordDimension () {\n return this.header.recordDimension\n }\n\n /**\n * @return {Array} - List of dimensions with:\n * * `name`: String with the name of the dimension\n * * `size`: Number with the size of the dimension\n */\n get dimensions () {\n return this.header.dimensions\n }\n\n /**\n * @return {Array} - List of global attributes with:\n * * `name`: String with the name of the attribute\n * * `type`: String with the type of the attribute\n * * `value`: A number or string with the value of the attribute\n */\n get globalAttributes () {\n return this.header.globalAttributes\n }\n\n /**\n * @return {Array} - List of variables with:\n * * `name`: String with the name of the variable\n * * `dimensions`: Array with the dimension IDs of the variable\n * * `attributes`: Array with the attributes of the variable\n * * `type`: String with the type of the variable\n * * `size`: Number with the size of the variable\n * * `offset`: Number with the offset where of the variable begins\n * * `record`: True if is a record variable, false otherwise\n */\n get variables () {\n return this.header.variables\n }\n\n /**\n * Checks if a variable is available\n * @param {string|object} variableName - Name of the variable to check\n * @return {Boolean} - Variable existence\n */\n hasDataVariable (variableName: string) {\n return this.header.variables!.findIndex(function (val) {\n return val.name === variableName\n }) !== -1\n }\n\n /**\n * Retrieves the data for a given variable\n * @param {string|object} variableName - Name of the variable to search or variable object\n * @return {Array} - List with the variable values\n */\n getDataVariable (variableName: string|{}) {\n let variable\n if (typeof variableName === 'string') {\n // search the variable\n variable = this.header.variables!.find(function (val) {\n return val.name === variableName\n })\n } else {\n variable = variableName\n }\n\n // throws if variable not found\n notNetcdf((variable === undefined), 'variable not found')\n\n // go to the offset position\n this.buffer.seek(variable.offset)\n\n if (variable.record) {\n // record variable case\n return record(this.buffer, variable, this.header.recordDimension!)\n } else {\n // non-record variable case\n return nonRecord(this.buffer, variable)\n }\n }\n}\n\nexport default NetcdfReader\n","/**\n * @file Dcd Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { uint8ToString, ensureBuffer } from '../utils'\nimport TrajectoryParser from './trajectory-parser'\n\nconst charmmTimeUnitFactor = 20.45482949774598\n\ninterface DcdHeader {\n NSET: number,\n ISTART: number,\n NSAVC: number,\n NAMNF: number,\n DELTA: number,\n TITLE: string,\n NATOM: number\n}\n\nclass DcdParser extends TrajectoryParser {\n get type () { return 'dcd' }\n get isBinary () { return true }\n\n _parse () {\n // http://www.ks.uiuc.edu/Research/vmd/plugins/molfile/dcdplugin.html\n\n // The DCD format is structured as follows\n // (FORTRAN UNFORMATTED, with Fortran data type descriptions):\n // HDR NSET ISTRT NSAVC 5-ZEROS NATOM-NFREAT DELTA 9-ZEROS\n // `CORD' #files step 1 step zeroes (zero) timestep (zeroes)\n // interval\n // C*4 INT INT INT 5INT INT DOUBLE 9INT\n // ==========================================================================\n // NTITLE TITLE\n // INT (=2) C*MAXTITL\n // (=32)\n // ==========================================================================\n // NATOM\n // #atoms\n // INT\n // ==========================================================================\n // X(I), I=1,NATOM (DOUBLE)\n // Y(I), I=1,NATOM\n // Z(I), I=1,NATOM\n // ==========================================================================\n\n if (Debug) Log.time('DcdParser._parse ' + this.name)\n\n const bin = ensureBuffer(this.streamer.data)\n const dv = new DataView(bin)\n\n const f = this.frames\n const coordinates = f.coordinates\n const boxes = f.boxes\n const header: Partial = {}\n\n let nextPos = 0\n\n // header block\n\n const intView = new Int32Array(bin, 0, 23)\n const ef = intView[ 0 ] !== dv.getInt32(0) // endianess flag\n // swap byte order when big endian (84 indicates little endian)\n if (intView[ 0 ] !== 84) {\n const n = bin.byteLength\n for (let i = 0; i < n; i += 4) {\n dv.setFloat32(i, dv.getFloat32(i), true)\n }\n }\n if (intView[ 0 ] !== 84) {\n Log.error('dcd bad format, header block start')\n }\n // format indicator, should read 'CORD'\n const formatString = String.fromCharCode(\n dv.getUint8(4), dv.getUint8(5),\n dv.getUint8(6), dv.getUint8(7)\n )\n if (formatString !== 'CORD') {\n Log.error('dcd bad format, format string')\n }\n let isCharmm = false\n let extraBlock = false\n let fourDims = false\n // version field in charmm, unused in X-PLOR\n if (intView[ 22 ] !== 0) {\n isCharmm = true\n if (intView[ 12 ] !== 0) extraBlock = true\n if (intView[ 13 ] === 1) fourDims = true\n }\n header.NSET = intView[ 2 ]\n header.ISTART = intView[ 3 ]\n header.NSAVC = intView[ 4 ]\n header.NAMNF = intView[ 10 ]\n if (isCharmm) {\n header.DELTA = dv.getFloat32(44, ef)\n } else {\n header.DELTA = dv.getFloat64(44, ef)\n }\n if (intView[ 22 ] !== 84) {\n Log.error('dcd bad format, header block end')\n }\n nextPos = nextPos + 21 * 4 + 8\n\n // title block\n\n const titleLength = dv.getInt32(nextPos, ef)\n const titlePos = nextPos + 1\n if ((titleLength - 4) % 80 !== 0) {\n Log.error('dcd bad format, title block start')\n }\n header.TITLE = uint8ToString(\n new Uint8Array(bin, titlePos, titleLength)\n )\n if (dv.getInt32(titlePos + titleLength + 4 - 1, ef) !== titleLength) {\n Log.error('dcd bad format, title block end')\n }\n nextPos = nextPos + titleLength + 8\n\n // natom block\n\n if (dv.getInt32(nextPos, ef) !== 4) {\n Log.error('dcd bad format, natom block start')\n }\n header.NATOM = dv.getInt32(nextPos + 4, ef)\n if (dv.getInt32(nextPos + 8, ef) !== 4) {\n Log.error('dcd bad format, natom block end')\n }\n nextPos = nextPos + 4 + 8\n\n // fixed atoms block\n\n if (header.NAMNF > 0) {\n // TODO read coordinates and indices of fixed atoms\n Log.error('dcd format with fixed atoms unsupported, aborting')\n return\n }\n\n // frames\n\n const natom = header.NATOM\n const natom4 = natom * 4\n\n for (let i = 0, n = header.NSET; i < n; ++i) {\n if (extraBlock) {\n nextPos += 4 // block start\n // unitcell: A, alpha, B, beta, gamma, C (doubles)\n const box = new Float32Array(9)\n box[ 0 ] = dv.getFloat64(nextPos, ef)\n box[ 4 ] = dv.getFloat64(nextPos + 2 * 8, ef)\n box[ 8 ] = dv.getFloat64(nextPos + 5 * 8, ef)\n boxes.push(box)\n nextPos += 48\n nextPos += 4 // block end\n }\n\n // xyz coordinates\n const coord = new Float32Array(natom * 3)\n for (let j = 0; j < 3; ++j) {\n if (dv.getInt32(nextPos, ef) !== natom4) {\n Log.error('dcd bad format, coord block start', i, j)\n }\n nextPos += 4 // block start\n const c = new Float32Array(bin, nextPos, natom)\n for (let k = 0; k < natom; ++k) {\n coord[ 3 * k + j ] = c[ k ]\n }\n nextPos += natom4\n if (dv.getInt32(nextPos, ef) !== natom4) {\n Log.error('dcd bad format, coord block end', i, j)\n }\n nextPos += 4 // block end\n }\n coordinates.push(coord)\n\n if (fourDims) {\n const bytes = dv.getInt32(nextPos, ef)\n nextPos += 4 + bytes + 4 // block start + skip + block end\n }\n }\n\n if (header.DELTA) {\n f.deltaTime = header.DELTA * charmmTimeUnitFactor\n }\n if (header.ISTART >= 1) {\n f.timeOffset = (header.ISTART - 1) * f.deltaTime\n }\n\n // console.log(header)\n // console.log(header.TITLE)\n // console.log('isCharmm', isCharmm, 'extraBlock', extraBlock, 'fourDims, fourDims)\n\n if (Debug) Log.timeEnd('DcdParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('dcd', DcdParser)\n\nexport default DcdParser\n","/**\n * @file Nctraj Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport TrajectoryParser from './trajectory-parser'\nimport NetcdfReader from '../utils/netcdf-reader'\n\nclass NctrajParser extends TrajectoryParser {\n get type () { return 'nctraj' }\n get isBinary () { return true }\n\n _parse () {\n // http://ambermd.org/netcdf/nctraj.xhtml\n\n if (Debug) Log.time('NctrajParser._parse ' + this.name)\n\n const netcdfReader = new NetcdfReader(this.streamer.data)\n\n const f = this.frames\n const coordinates = f.coordinates\n const boxes = f.boxes\n const times = f.times\n\n netcdfReader.getDataVariable('coordinates').forEach(function (c) {\n coordinates.push(new Float32Array(c))\n })\n\n if (netcdfReader.hasDataVariable('cell_lengths')) {\n netcdfReader.getDataVariable('cell_lengths').forEach(function (b) {\n boxes.push(new Float32Array(b))\n })\n }\n\n if (netcdfReader.hasDataVariable('time')) {\n netcdfReader.getDataVariable('time').forEach(function (t) {\n times.push(t)\n })\n }\n\n if (times.length >= 1) {\n f.timeOffset = times[0]\n }\n if (times.length >= 2) {\n f.deltaTime = times[1] - times[0]\n }\n\n if (Debug) Log.timeEnd('NctrajParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('nctraj', NctrajParser)\nParserRegistry.add('ncdf', NctrajParser)\nParserRegistry.add('nc', NctrajParser)\n\nexport default NctrajParser\n","/**\n * @file Trr Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { ensureBuffer } from '../utils'\nimport TrajectoryParser from './trajectory-parser'\n\nclass TrrParser extends TrajectoryParser {\n get type () { return 'trr' }\n get isBinary () { return true }\n\n _parse () {\n // https://github.com/gromacs/gromacs/blob/master/src/gromacs/fileio/trrio.cpp\n\n if (Debug) Log.time('TrrParser._parse ' + this.name)\n\n const bin = ensureBuffer(this.streamer.data)\n const dv = new DataView(bin)\n\n const f = this.frames\n const coordinates = f.coordinates\n const boxes = f.boxes\n const times = f.times\n\n let offset = 0\n\n while (true) {\n // const magicnum = dv.getInt32(offset)\n // const i1 = dv.getFloat32(offset + 4)\n offset += 8\n\n const versionSize = dv.getInt32(offset)\n offset += 4\n offset += versionSize\n\n // const irSize = dv.getInt32(offset)\n // const eSize = dv.getInt32(offset + 4)\n const boxSize = dv.getInt32(offset + 8)\n const virSize = dv.getInt32(offset + 12)\n const presSize = dv.getInt32(offset + 16)\n // const topSize = dv.getInt32(offset + 20)\n // const symSize = dv.getInt32(offset + 24)\n const coordSize = dv.getInt32(offset + 28)\n const velocitySize = dv.getInt32(offset + 32)\n const forceSize = dv.getInt32(offset + 36)\n const natoms = dv.getInt32(offset + 40)\n // const step = dv.getInt32(offset + 44)\n // const nre = dv.getInt32(offset + 48)\n offset += 52\n\n const floatSize = boxSize / 9\n const natoms3 = natoms * 3\n\n // let lambda\n if (floatSize === 8) {\n times.push(dv.getFloat64(offset))\n // lambda = dv.getFloat64(offset + 8)\n } else {\n times.push(dv.getFloat32(offset))\n // lambda = dv.getFloat32(offset + 4)\n }\n offset += 2 * floatSize\n\n if (boxSize) {\n const box = new Float32Array(9)\n if (floatSize === 8) {\n for (let i = 0; i < 9; ++i) {\n box[i] = dv.getFloat64(offset) * 10\n offset += 8\n }\n } else {\n for (let i = 0; i < 9; ++i) {\n box[i] = dv.getFloat32(offset) * 10\n offset += 4\n }\n }\n boxes.push(box)\n }\n\n // ignore, unused\n offset += virSize\n\n // ignore, unused\n offset += presSize\n\n if (coordSize) {\n let frameCoords\n if (floatSize === 8) {\n frameCoords = new Float32Array(natoms3)\n for (let i = 0; i < natoms3; ++i) {\n frameCoords[i] = dv.getFloat64(offset) * 10\n offset += 8\n }\n } else {\n const tmp = new Uint32Array(bin, offset, natoms3)\n for (let i = 0; i < natoms3; ++i) {\n const value = tmp[i]\n tmp[i] = (\n ((value & 0xFF) << 24) | ((value & 0xFF00) << 8) |\n ((value >> 8) & 0xFF00) | ((value >> 24) & 0xFF)\n )\n }\n frameCoords = new Float32Array(bin, offset, natoms3)\n for (let i = 0; i < natoms3; ++i) {\n frameCoords[i] *= 10\n offset += 4\n }\n }\n coordinates.push(frameCoords)\n }\n\n // ignore, unused\n offset += velocitySize\n\n // ignore, unused\n offset += forceSize\n\n if (offset >= bin.byteLength) break\n }\n\n if (times.length >= 1) {\n f.timeOffset = times[0]\n }\n if (times.length >= 2) {\n f.deltaTime = times[1] - times[0]\n }\n\n if (Debug) Log.timeEnd('TrrParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('trr', TrrParser)\n\nexport default TrrParser\n","/**\n * @file Xtc Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { ensureBuffer } from '../utils'\nimport TrajectoryParser from './trajectory-parser'\nimport { NumberArray } from '../types';\n\nconst MagicInts = new Uint32Array([\n 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 10, 12, 16, 20, 25, 32, 40, 50, 64,\n 80, 101, 128, 161, 203, 256, 322, 406, 512, 645, 812, 1024, 1290,\n 1625, 2048, 2580, 3250, 4096, 5060, 6501, 8192, 10321, 13003,\n 16384, 20642, 26007, 32768, 41285, 52015, 65536, 82570, 104031,\n 131072, 165140, 208063, 262144, 330280, 416127, 524287, 660561,\n 832255, 1048576, 1321122, 1664510, 2097152, 2642245, 3329021,\n 4194304, 5284491, 6658042, 8388607, 10568983, 13316085, 16777216\n])\nconst FirstIdx = 9\n// const LastIdx = MagicInts.length\n\nfunction sizeOfInt (size: number) {\n let num = 1\n let numOfBits = 0\n while (size >= num && numOfBits < 32) {\n numOfBits++\n num <<= 1\n }\n return numOfBits\n}\n\nconst _tmpBytes = new Uint8Array(32)\n\nfunction sizeOfInts (numOfInts: number, sizes: Int32Array) {\n let numOfBytes = 1\n let numOfBits = 0\n _tmpBytes[0] = 1\n for (let i = 0; i < numOfInts; i++) {\n let bytecnt\n let tmp = 0\n for (bytecnt = 0; bytecnt < numOfBytes; bytecnt++) {\n tmp += _tmpBytes[bytecnt] * sizes[i]\n _tmpBytes[bytecnt] = tmp & 0xff\n tmp >>= 8\n }\n while (tmp !== 0) {\n _tmpBytes[bytecnt++] = tmp & 0xff\n tmp >>= 8\n }\n numOfBytes = bytecnt\n }\n let num = 1\n numOfBytes--\n while (_tmpBytes[numOfBytes] >= num) {\n numOfBits++\n num *= 2\n }\n return numOfBits + numOfBytes * 8\n}\n\nfunction decodeBits (buf: Int32Array, cbuf: Uint8Array, numOfBits: number, buf2: Uint32Array) {\n const mask = (1 << numOfBits) - 1\n let lastBB0 = buf2[1]\n let lastBB1 = buf2[2]\n let cnt = buf[0]\n let num = 0\n\n while (numOfBits >= 8) {\n lastBB1 = (lastBB1 << 8) | cbuf[cnt++]\n num |= (lastBB1 >> lastBB0) << (numOfBits - 8)\n numOfBits -= 8\n }\n\n if (numOfBits > 0) {\n if (lastBB0 < numOfBits) {\n lastBB0 += 8\n lastBB1 = (lastBB1 << 8) | cbuf[cnt++]\n }\n lastBB0 -= numOfBits\n num |= (lastBB1 >> lastBB0) & ((1 << numOfBits) - 1)\n }\n\n num &= mask\n buf[0] = cnt\n buf[1] = lastBB0\n buf[2] = lastBB1\n\n return num\n}\n\nconst _tmpIntBytes = new Int32Array(32)\n\nfunction decodeInts (buf: Int32Array, cbuf: Uint8Array, numOfInts: number, numOfBits: number, sizes: NumberArray, nums: Float32Array, buf2: Uint32Array) {\n let numOfBytes = 0\n _tmpIntBytes[1] = 0\n _tmpIntBytes[2] = 0\n _tmpIntBytes[3] = 0\n\n while (numOfBits > 8) {\n // this is inversed??? why??? because of the endiannness???\n _tmpIntBytes[numOfBytes++] = decodeBits(buf, cbuf, 8, buf2)\n numOfBits -= 8\n }\n\n if (numOfBits > 0) {\n _tmpIntBytes[numOfBytes++] = decodeBits(buf, cbuf, numOfBits, buf2)\n }\n\n for (let i = numOfInts - 1; i > 0; i--) {\n let num = 0\n for (let j = numOfBytes - 1; j >= 0; j--) {\n num = (num << 8) | _tmpIntBytes[j]\n const p = (num / sizes[i]) | 0\n _tmpIntBytes[j] = p\n num = num - p * sizes[i]\n }\n nums[i] = num\n }\n nums[0] = (\n _tmpIntBytes[0] |\n (_tmpIntBytes[1] << 8) |\n (_tmpIntBytes[2] << 16) |\n (_tmpIntBytes[3] << 24)\n )\n}\n\nclass XtcParser extends TrajectoryParser {\n get type () { return 'xtc' }\n get isBinary () { return true }\n\n _parse () {\n // https://github.com/gromacs/gromacs/blob/master/src/gromacs/fileio/xtcio.cpp\n // https://github.com/gromacs/gromacs/blob/master/src/gromacs/fileio/libxdrf.cpp\n\n if (Debug) Log.time('XtcParser._parse ' + this.name)\n\n const bin = ensureBuffer(this.streamer.data)\n const dv = new DataView(bin)\n\n const f = this.frames\n const coordinates = f.coordinates\n const boxes = f.boxes\n const times = f.times\n\n const minMaxInt = new Int32Array(6)\n const sizeint = new Int32Array(3)\n const bitsizeint = new Int32Array(3)\n const sizesmall = new Uint32Array(3)\n const thiscoord = new Float32Array(3)\n const prevcoord = new Float32Array(3)\n\n let offset = 0\n const buf = new Int32Array(3)\n const buf2 = new Uint32Array(buf.buffer)\n\n while (true) {\n let frameCoords: NumberArray\n\n // const magicnum = dv.getInt32(offset)\n const natoms = dv.getInt32(offset + 4)\n // const step = dv.getInt32(offset + 8)\n offset += 12\n\n const natoms3 = natoms * 3\n\n times.push(dv.getFloat32(offset))\n offset += 4\n\n const box = new Float32Array(9)\n for (let i = 0; i < 9; ++i) {\n box[i] = dv.getFloat32(offset) * 10\n offset += 4\n }\n boxes.push(box)\n\n if (natoms <= 9) { // no compression\n frameCoords = new Float32Array(natoms)\n for (let i = 0; i < natoms; ++i) {\n frameCoords[i] = dv.getFloat32(offset)\n offset += 4\n }\n } else {\n buf[0] = buf[1] = buf[2] = 0.0\n sizeint[0] = sizeint[1] = sizeint[2] = 0\n sizesmall[0] = sizesmall[1] = sizesmall[2] = 0\n bitsizeint[0] = bitsizeint[1] = bitsizeint[2] = 0\n thiscoord[0] = thiscoord[1] = thiscoord[2] = 0\n prevcoord[0] = prevcoord[1] = prevcoord[2] = 0\n\n frameCoords = new Float32Array(natoms3)\n let lfp = 0\n\n const lsize = dv.getInt32(offset)\n offset += 4\n const precision = dv.getFloat32(offset)\n offset += 4\n\n minMaxInt[0] = dv.getInt32(offset)\n minMaxInt[1] = dv.getInt32(offset + 4)\n minMaxInt[2] = dv.getInt32(offset + 8)\n minMaxInt[3] = dv.getInt32(offset + 12)\n minMaxInt[4] = dv.getInt32(offset + 16)\n minMaxInt[5] = dv.getInt32(offset + 20)\n sizeint[0] = minMaxInt[3] - minMaxInt[0] + 1\n sizeint[1] = minMaxInt[4] - minMaxInt[1] + 1\n sizeint[2] = minMaxInt[5] - minMaxInt[2] + 1\n offset += 24\n\n let bitsize\n if ((sizeint[0] | sizeint[1] | sizeint[2]) > 0xffffff) {\n bitsizeint[0] = sizeOfInt(sizeint[0])\n bitsizeint[1] = sizeOfInt(sizeint[1])\n bitsizeint[2] = sizeOfInt(sizeint[2])\n bitsize = 0 // flag the use of large sizes\n } else {\n bitsize = sizeOfInts(3, sizeint)\n }\n\n let smallidx = dv.getInt32(offset)\n offset += 4\n // if (smallidx == 0) {alert(\"Undocumented error 1\"); return;}\n\n // let tmpIdx = smallidx + 8\n // const maxidx = (LastIdx < tmpIdx) ? LastIdx : tmpIdx\n // const minidx = maxidx - 8 // often this equal smallidx\n let tmpIdx = smallidx - 1\n tmpIdx = (FirstIdx > tmpIdx) ? FirstIdx : tmpIdx\n let smaller = (MagicInts[tmpIdx] / 2) | 0\n let smallnum = (MagicInts[smallidx] / 2) | 0\n\n sizesmall[0] = sizesmall[1] = sizesmall[2] = MagicInts[smallidx]\n // larger = MagicInts[maxidx]\n\n let adz = Math.ceil(dv.getInt32(offset) / 4) * 4\n offset += 4\n // if (tmpIdx == 0) {alert(\"Undocumented error 2\"); return;}\n\n // buf = new Int32Array(bin, offset);\n // buf8 = new Uint8Array(bin, offset);\n\n // tmpIdx += 3; rndup = tmpIdx%4;\n // for (i=tmpIdx+rndup-1; i>=tmpIdx; i--) buf8[i] = 0;\n\n // now unpack buf2...\n\n const invPrecision = 1.0 / precision\n let run = 0\n let i = 0\n\n const buf8 = new Uint8Array(bin, offset) // 229...\n\n thiscoord[0] = thiscoord[1] = thiscoord[2] = 0\n\n while (i < lsize) {\n if (bitsize === 0) {\n thiscoord[0] = decodeBits(buf, buf8, bitsizeint[0], buf2)\n thiscoord[1] = decodeBits(buf, buf8, bitsizeint[1], buf2)\n thiscoord[2] = decodeBits(buf, buf8, bitsizeint[2], buf2)\n } else {\n decodeInts(buf, buf8, 3, bitsize, sizeint, thiscoord, buf2)\n }\n\n i++\n\n thiscoord[0] += minMaxInt[0]\n thiscoord[1] += minMaxInt[1]\n thiscoord[2] += minMaxInt[2]\n\n prevcoord[0] = thiscoord[0]\n prevcoord[1] = thiscoord[1]\n prevcoord[2] = thiscoord[2]\n\n const flag = decodeBits(buf, buf8, 1, buf2)\n let isSmaller = 0\n\n if (flag === 1) {\n run = decodeBits(buf, buf8, 5, buf2)\n isSmaller = run % 3\n run -= isSmaller\n isSmaller--\n }\n\n // if ((lfp-ptrstart)+run > size3){\n // fprintf(stderr, \"(xdrfile error) Buffer overrun during decompression.\\n\");\n // return 0;\n // }\n\n if (run > 0) {\n thiscoord[0] = thiscoord[1] = thiscoord[2] = 0\n\n for (let k = 0; k < run; k += 3) {\n decodeInts(buf, buf8, 3, smallidx, sizesmall, thiscoord, buf2)\n i++\n\n thiscoord[0] += prevcoord[0] - smallnum\n thiscoord[1] += prevcoord[1] - smallnum\n thiscoord[2] += prevcoord[2] - smallnum\n\n if (k === 0) {\n // interchange first with second atom for\n // better compression of water molecules\n let tmpSwap = thiscoord[0]\n thiscoord[0] = prevcoord[0]\n prevcoord[0] = tmpSwap\n\n tmpSwap = thiscoord[1]\n thiscoord[1] = prevcoord[1]\n prevcoord[1] = tmpSwap\n\n tmpSwap = thiscoord[2]\n thiscoord[2] = prevcoord[2]\n prevcoord[2] = tmpSwap\n\n frameCoords[lfp++] = prevcoord[0] * invPrecision\n frameCoords[lfp++] = prevcoord[1] * invPrecision\n frameCoords[lfp++] = prevcoord[2] * invPrecision\n } else {\n prevcoord[0] = thiscoord[0]\n prevcoord[1] = thiscoord[1]\n prevcoord[2] = thiscoord[2]\n }\n frameCoords[lfp++] = thiscoord[0] * invPrecision\n frameCoords[lfp++] = thiscoord[1] * invPrecision\n frameCoords[lfp++] = thiscoord[2] * invPrecision\n }\n } else {\n frameCoords[lfp++] = thiscoord[0] * invPrecision\n frameCoords[lfp++] = thiscoord[1] * invPrecision\n frameCoords[lfp++] = thiscoord[2] * invPrecision\n }\n\n smallidx += isSmaller\n\n if (isSmaller < 0) {\n smallnum = smaller\n if (smallidx > FirstIdx) {\n smaller = (MagicInts[smallidx - 1] / 2) | 0\n } else {\n smaller = 0\n }\n } else if (isSmaller > 0) {\n smaller = smallnum\n smallnum = (MagicInts[smallidx] / 2) | 0\n }\n sizesmall[0] = sizesmall[1] = sizesmall[2] = MagicInts[smallidx]\n\n if (sizesmall[0] === 0 || sizesmall[1] === 0 || sizesmall[2] === 0) {\n console.error('(xdrfile error) Undefined error.')\n return\n }\n }\n offset += adz\n }\n\n for (let c = 0; c < natoms3; c++) {\n frameCoords[c] *= 10\n }\n\n coordinates.push(frameCoords)\n\n if (offset >= bin.byteLength) break\n }\n\n if (times.length >= 1) {\n f.timeOffset = times[0]\n }\n if (times.length >= 2) {\n f.deltaTime = times[1] - times[0]\n }\n\n if (Debug) Log.timeEnd('XtcParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('xtc', XtcParser)\n\nexport default XtcParser\n","/**\n * @file Volume Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { defaults } from '../utils'\nimport Parser, { ParserParameters } from './parser'\nimport Volume from '../surface/volume'\nimport Streamer from '../streamer/streamer';\n\nexport interface VolumeParserParameters extends ParserParameters {\n voxelSize: number\n}\n\nclass VolumeParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.volume = new Volume(this.name, this.path)\n this.voxelSize = defaults(p.voxelSize, 1)\n }\n\n get type () { return 'volume' }\n get __objName () { return 'volume' }\n\n _afterParse () {\n this.volume.setMatrix(this.getMatrix())\n super._afterParse()\n }\n\n getMatrix () {\n return new Matrix4()\n }\n}\n\nexport default VolumeParser\n","/**\n * @file Cube Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport VolumeParser from './volume-parser'\n\n// @author Johanna Tiemann \n// @author Alexander Rose \n\nconst reWhitespace = /\\s+/\nconst reScientificNotation = /-?\\d+(?:\\.\\d*)?(?:[eE][+-]?\\d+)?/g\nconst bohrToAngstromFactor = 0.529177210859\ninterface Header {\n atomCount: number,\n originX: number,\n originY: number,\n originZ: number,\n NVX: number,\n NVY: number,\n NVZ: number,\n basisX: Vector3,\n basisY: Vector3,\n basisZ: Vector3\n}\n\nclass CubeParser extends VolumeParser {\n get type () { return 'cube' }\n\n _parse () {\n // http://paulbourke.net/dataformats/cube/\n\n if (Debug) Log.time('CubeParser._parse ' + this.name)\n\n const v = this.volume\n const headerLines = this.streamer.peekLines(6)\n const header: Partial
= {}\n\n const scaleFactor = bohrToAngstromFactor * this.voxelSize\n\n function h (k: number, l: number) {\n var field = headerLines[ k ].trim().split(reWhitespace)[ l ]\n return parseFloat(field)\n }\n\n header.atomCount = Math.abs(h(2, 0)) // Number of atoms\n header.originX = h(2, 1) * bohrToAngstromFactor // Position of origin of volumetric data\n header.originY = h(2, 2) * bohrToAngstromFactor\n header.originZ = h(2, 3) * bohrToAngstromFactor\n header.NVX = h(3, 0) // Number of voxels\n header.NVY = h(4, 0)\n header.NVZ = h(5, 0)\n\n header.basisX = new Vector3(h(3, 1), h(3, 2), h(3, 3))\n .multiplyScalar(scaleFactor)\n header.basisY = new Vector3(h(4, 1), h(4, 2), h(4, 3))\n .multiplyScalar(scaleFactor)\n header.basisZ = new Vector3(h(5, 1), h(5, 2), h(5, 3))\n .multiplyScalar(scaleFactor)\n\n const data = new Float32Array(header.NVX * header.NVY * header.NVZ)\n let count = 0\n let lineNo = 0\n const oribitalFlag = h(2, 0) > 0 ? 0 : 1\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ].trim()\n\n if (line !== '' && lineNo >= header.atomCount! + 6 + oribitalFlag) {\n const m = line.match(reScientificNotation) as RegExpMatchArray\n for (let j = 0, lj = m.length; j < lj; ++j) {\n data[ count ] = parseFloat(m[ j ])\n ++count\n }\n }\n\n ++lineNo\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n v.header = header\n v.setData(data, header.NVZ, header.NVY, header.NVX)\n\n if (Debug) Log.timeEnd('CubeParser._parse ' + this.name)\n }\n\n getMatrix () {\n const h = this.volume.header\n const matrix = new Matrix4()\n\n matrix.multiply(\n new Matrix4().makeTranslation(\n h.originX, h.originY, h.originZ\n )\n )\n\n matrix.multiply(\n new Matrix4().makeBasis(\n h.basisZ, h.basisY, h.basisX\n )\n )\n\n return matrix\n }\n}\n\nParserRegistry.add('cub', CubeParser)\nParserRegistry.add('cube', CubeParser)\n\nexport default CubeParser\n","/**\n * @file Dsn6 Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { ensureBuffer } from '../utils'\nimport { degToRad } from '../math/math-utils'\nimport VolumeParser from './volume-parser'\n\ninterface Dsn6Header {\n xStart: number,\n yStart: number,\n zStart: number,\n xExtent: number,\n yExtent: number,\n zExtent: number,\n xRate: number,\n yRate: number,\n zRate: number,\n xlen: number,\n ylen: number,\n zlen: number,\n alpha: number,\n beta: number,\n gamma: number,\n sigma: number\n}\n\nclass Dsn6Parser extends VolumeParser {\n get type () { return 'dsn6' }\n get isBinary () { return true }\n\n _parse () {\n // DSN6 http://www.uoxray.uoregon.edu/tnt/manual/node104.html\n // BRIX http://svn.cgl.ucsf.edu/svn/chimera/trunk/libs/VolumeData/dsn6/brix-1.html\n\n if (Debug) Log.time('Dsn6Parser._parse ' + this.name)\n\n const v = this.volume\n const header: Partial = {}\n let divisor, summand\n\n const bin = ensureBuffer(this.streamer.data)\n const intView = new Int16Array(bin)\n const byteView = new Uint8Array(bin)\n const brixStr = String.fromCharCode.apply(null, byteView.subarray(0, 512))\n\n if (brixStr.startsWith(':-)')) {\n header.xStart = parseInt(brixStr.substr(10, 5)) // NXSTART\n header.yStart = parseInt(brixStr.substr(15, 5))\n header.zStart = parseInt(brixStr.substr(20, 5))\n\n header.xExtent = parseInt(brixStr.substr(32, 5)) // NX\n header.yExtent = parseInt(brixStr.substr(38, 5))\n header.zExtent = parseInt(brixStr.substr(42, 5))\n\n header.xRate = parseInt(brixStr.substr(52, 5)) // MX\n header.yRate = parseInt(brixStr.substr(58, 5))\n header.zRate = parseInt(brixStr.substr(62, 5))\n\n header.xlen = parseFloat(brixStr.substr(73, 10)) * this.voxelSize\n header.ylen = parseFloat(brixStr.substr(83, 10)) * this.voxelSize\n header.zlen = parseFloat(brixStr.substr(93, 10)) * this.voxelSize\n\n header.alpha = parseFloat(brixStr.substr(103, 10))\n header.beta = parseFloat(brixStr.substr(113, 10))\n header.gamma = parseFloat(brixStr.substr(123, 10))\n\n divisor = parseFloat(brixStr.substr(138, 12)) / 100\n summand = parseInt(brixStr.substr(155, 8))\n\n header.sigma = parseFloat(brixStr.substr(170, 12)) * 100\n } else {\n // swap byte order when big endian\n if (intView[ 18 ] !== 100) {\n for (let i = 0, n = intView.length; i < n; ++i) {\n const val = intView[ i ]\n intView[ i ] = ((val & 0xff) << 8) | ((val >> 8) & 0xff)\n }\n }\n\n header.xStart = intView[ 0 ] // NXSTART\n header.yStart = intView[ 1 ]\n header.zStart = intView[ 2 ]\n\n header.xExtent = intView[ 3 ] // NX\n header.yExtent = intView[ 4 ]\n header.zExtent = intView[ 5 ]\n\n header.xRate = intView[ 6 ] // MX\n header.yRate = intView[ 7 ]\n header.zRate = intView[ 8 ]\n\n const factor = 1 / intView[ 17 ]\n const scalingFactor = factor * this.voxelSize\n\n header.xlen = intView[ 9 ] * scalingFactor\n header.ylen = intView[ 10 ] * scalingFactor\n header.zlen = intView[ 11 ] * scalingFactor\n\n header.alpha = intView[ 12 ] * factor\n header.beta = intView[ 13 ] * factor\n header.gamma = intView[ 14 ] * factor\n\n divisor = intView[ 15 ] / 100\n summand = intView[ 16 ]\n header.gamma = intView[ 14 ] * factor\n }\n\n v.header = header\n\n if (Debug) Log.log(header, divisor, summand)\n\n const data = new Float32Array(\n header.xExtent * header.yExtent * header.zExtent\n )\n\n let offset = 512\n const xBlocks = Math.ceil(header.xExtent / 8)\n const yBlocks = Math.ceil(header.yExtent / 8)\n const zBlocks = Math.ceil(header.zExtent / 8)\n\n // loop over blocks\n for (var zz = 0; zz < zBlocks; ++zz) {\n for (var yy = 0; yy < yBlocks; ++yy) {\n for (var xx = 0; xx < xBlocks; ++xx) {\n // loop inside block\n for (var k = 0; k < 8; ++k) {\n var z = 8 * zz + k\n for (var j = 0; j < 8; ++j) {\n var y = 8 * yy + j\n for (var i = 0; i < 8; ++i) {\n var x = 8 * xx + i\n\n // check if remaining slice-part contains data\n if (x < header.xExtent && y < header.yExtent && z < header.zExtent) {\n var idx = ((((x * header.yExtent) + y) * header.zExtent) + z)\n data[ idx ] = (byteView[ offset ] - summand) / divisor\n ++offset\n } else {\n offset += 8 - i\n break\n }\n }\n }\n }\n }\n }\n }\n\n v.setData(data, header.zExtent, header.yExtent, header.xExtent)\n if (header.sigma) {\n v.setStats(undefined, undefined, undefined, header.sigma)\n }\n\n if (Debug) Log.timeEnd('Dsn6Parser._parse ' + this.name)\n }\n\n getMatrix () {\n const h: Dsn6Header = this.volume.header\n\n const basisX = [\n h.xlen as number,\n 0,\n 0\n ]\n\n const basisY = [\n h.ylen * Math.cos(Math.PI / 180.0 * h.gamma),\n h.ylen * Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n\n const basisZ = [\n h.zlen * Math.cos(Math.PI / 180.0 * h.beta),\n h.zlen * (\n Math.cos(Math.PI / 180.0 * h.alpha) -\n Math.cos(Math.PI / 180.0 * h.gamma) *\n Math.cos(Math.PI / 180.0 * h.beta)\n ) / Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n basisZ[ 2 ] = Math.sqrt(\n h.zlen * h.zlen * Math.sin(Math.PI / 180.0 * h.beta) *\n Math.sin(Math.PI / 180.0 * h.beta) - basisZ[ 1 ] * basisZ[ 1 ]\n )\n\n const basis = [ [], basisX, basisY, basisZ ]\n const nxyz = [ 0, h.xRate, h.yRate, h.zRate ]\n const mapcrs = [ 0, 1, 2, 3 ]\n\n const matrix = new Matrix4()\n\n matrix.set(\n basis[ mapcrs[1] ][0] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][0] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][0] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][1] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][1] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][1] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][2] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][2] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][2] / nxyz[ mapcrs[3] ],\n 0,\n 0, 0, 0, 1\n )\n\n matrix.multiply(\n new Matrix4().makeRotationY(degToRad(90))\n )\n\n matrix.multiply(new Matrix4().makeTranslation(\n -h.zStart, h.yStart, h.xStart\n ))\n\n matrix.multiply(new Matrix4().makeScale(\n -1, 1, 1\n ))\n\n return matrix\n }\n}\n\nParserRegistry.add('dsn6', Dsn6Parser)\nParserRegistry.add('brix', Dsn6Parser)\n\nexport default Dsn6Parser\n","/**\n * @file Dx Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { degToRad } from '../math/math-utils'\nimport VolumeParser from './volume-parser'\n\nconst reWhitespace = /\\s+/\n\ninterface DxHeader {\n nx: number,\n ny: number,\n nz: number,\n xmin: number,\n ymin: number,\n zmin: number,\n hx: number,\n hy: number,\n hz: number\n}\n\nclass DxParser extends VolumeParser {\n get type () { return 'dx' }\n\n _parse () {\n // http://apbs.readthedocs.io/en/latest/formats/opendx.html\n\n if (Debug) Log.time('DxParser._parse ' + this.name)\n\n const v = this.volume\n const headerLines = this.streamer.peekLines(30)\n const headerInfo = this.parseHeaderLines(headerLines)\n const header = this.volume.header\n const dataLineStart = headerInfo.dataLineStart\n\n const size = header.nx * header.ny * header.nz\n const data = new Float32Array(size)\n let count = 0\n let lineNo = 0\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string []) {\n for (let i = _i; i < _n; ++i) {\n if (count < size && lineNo > dataLineStart) {\n const line = lines[ i ].trim()\n\n if (line !== '') {\n const ls = line.split(reWhitespace)\n\n for (let j = 0, lj = ls.length; j < lj; ++j) {\n data[ count ] = parseFloat(ls[ j ])\n ++count\n }\n }\n }\n\n ++lineNo\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n v.setData(data, header.nz, header.ny, header.nx)\n\n if (Debug) Log.timeEnd('DxParser._parse ' + this.name)\n }\n\n parseHeaderLines (headerLines: string []) {\n const header: Partial = {}\n const n = headerLines.length\n\n let dataLineStart = 0\n let headerByteCount = 0\n let deltaLineCount = 0\n\n for (let i = 0; i < n; ++i) {\n let ls\n const line = headerLines[ i ]\n\n if (line.startsWith('object 1')) {\n ls = line.split(reWhitespace)\n\n header.nx = parseInt(ls[ 5 ])\n header.ny = parseInt(ls[ 6 ])\n header.nz = parseInt(ls[ 7 ])\n } else if (line.startsWith('origin')) {\n ls = line.split(reWhitespace)\n\n header.xmin = parseFloat(ls[ 1 ])\n header.ymin = parseFloat(ls[ 2 ])\n header.zmin = parseFloat(ls[ 3 ])\n } else if (line.startsWith('delta')) {\n ls = line.split(reWhitespace)\n\n if (deltaLineCount === 0) {\n header.hx = parseFloat(ls[ 1 ]) * this.voxelSize\n } else if (deltaLineCount === 1) {\n header.hy = parseFloat(ls[ 2 ]) * this.voxelSize\n } else if (deltaLineCount === 2) {\n header.hz = parseFloat(ls[ 3 ]) * this.voxelSize\n }\n\n deltaLineCount += 1\n } else if (line.startsWith('object 3')) {\n dataLineStart = i\n headerByteCount += line.length + 1\n break\n }\n\n headerByteCount += line.length + 1\n }\n\n this.volume.header = header\n\n return {\n dataLineStart: dataLineStart,\n headerByteCount: headerByteCount\n }\n }\n\n getMatrix () {\n const h = this.volume.header\n const matrix = new Matrix4()\n\n matrix.multiply(\n new Matrix4().makeRotationY(degToRad(90))\n )\n\n matrix.multiply(\n new Matrix4().makeTranslation(\n -h.zmin, h.ymin, h.xmin\n )\n )\n\n matrix.multiply(\n new Matrix4().makeScale(\n -h.hz, h.hy, h.hx\n )\n )\n\n return matrix\n }\n}\n\nParserRegistry.add('dx', DxParser)\n\nexport default DxParser\n","/**\n * @file Dxbin Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { uint8ToLines, ensureBuffer } from '../utils'\nimport DxParser from './dx-parser'\n\nclass DxbinParser extends DxParser {\n get type () { return 'dxbin' }\n get isBinary () { return true }\n\n _parse () {\n // https://github.com/Electrostatics/apbs-pdb2pqr/issues/216\n\n if (Debug) Log.time('DxbinParser._parse ' + this.name)\n\n const bin = ensureBuffer(this.streamer.data)\n const headerLines = uint8ToLines(new Uint8Array(bin, 0, 1000))\n const headerInfo = this.parseHeaderLines(headerLines)\n const header = this.volume.header\n const headerByteCount = headerInfo.headerByteCount\n\n const size = header.nx * header.ny * header.nz\n const dv = new DataView(bin)\n const data = new Float32Array(size)\n\n for (let i = 0; i < size; ++i) {\n data[ i ] = dv.getFloat64(i * 8 + headerByteCount, true)\n }\n\n this.volume.setData(data, header.nz, header.ny, header.nx)\n\n if (Debug) Log.timeEnd('DxbinParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('dxbin', DxbinParser)\n\nexport default DxbinParser\n","/**\n * @file Mrc Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { ensureBuffer } from '../utils'\nimport VolumeParser from './volume-parser'\n\ninterface MrcHeader {\n MAP: string,\n MACHST: number [],\n NX: number,\n NY: number,\n NZ: number,\n MODE: number,\n NXSTART: number,\n NYSTART: number,\n NZSTART: number,\n MX: number,\n MY: number,\n MZ: number,\n xlen: number,\n ylen: number,\n zlen: number,\n alpha: number,\n beta: number,\n gamma: number,\n MAPC: number,\n MAPR: number,\n MAPS: number,\n DMIN: number,\n DMAX: number,\n DMEAN: number,\n ISPG: number,\n NSYMBT: number,\n LSKFLG: number,\n originX: number,\n originY: number,\n originZ: number,\n ARMS: number\n}\n\nclass MrcParser extends VolumeParser {\n get type () { return 'mrc' }\n get isBinary () { return true }\n\n _parse () {\n // MRC\n // http://ami.scripps.edu/software/mrctools/mrc_specification.php\n // http://www2.mrc-lmb.cam.ac.uk/research/locally-developed-software/image-processing-software/#image\n // http://bio3d.colorado.edu/imod/doc/mrc_format.txt\n\n // CCP4 (MAP)\n // http://www.ccp4.ac.uk/html/maplib.html\n\n // MRC format does not use the skew transformation header records (words 25-37)\n // CCP4 format does not use the ORIGIN header records (words 50-52)\n\n if (Debug) Log.time('MrcParser._parse ' + this.name)\n\n const v = this.volume\n const header: Partial = {}\n\n const bin = ensureBuffer(this.streamer.data)\n const intView = new Int32Array(bin, 0, 56)\n const floatView = new Float32Array(bin, 0, 56)\n const dv = new DataView(bin)\n\n // 53 MAP Character string 'MAP ' to identify file type\n header.MAP = String.fromCharCode(\n dv.getUint8(52 * 4), dv.getUint8(52 * 4 + 1),\n dv.getUint8(52 * 4 + 2), dv.getUint8(52 * 4 + 3)\n )\n\n // 54 MACHST Machine stamp indicating machine type which wrote file\n // 17 and 17 for big-endian or 68 and 65 for little-endian\n header.MACHST = [ dv.getUint8(53 * 4), dv.getUint8(53 * 4 + 1) ]\n\n // swap byte order when big endian\n if (header.MACHST[ 0 ] === 17 && header.MACHST[ 1 ] === 17) {\n const n = bin.byteLength\n for (let i = 0; i < n; i += 4) {\n dv.setFloat32(i, dv.getFloat32(i), true)\n }\n }\n\n header.NX = intView[ 0 ] // NC - columns (fastest changing)\n header.NY = intView[ 1 ] // NR - rows\n header.NZ = intView[ 2 ] // NS - sections (slowest changing)\n\n // mode\n // 0 image : signed 8-bit bytes range -128 to 127\n // 1 image : 16-bit halfwords\n // 2 image : 32-bit reals\n // 3 transform : complex 16-bit integers\n // 4 transform : complex 32-bit reals\n // 6 image : unsigned 16-bit range 0 to 65535\n // 16 image: unsigned char * 3 (for rgb data, non-standard)\n //\n // Note: Mode 2 is the normal mode used in the CCP4 programs.\n // Other modes than 2 and 0 may NOT WORK\n header.MODE = intView[ 3 ]\n\n // start\n header.NXSTART = intView[ 4 ] // NCSTART - first column\n header.NYSTART = intView[ 5 ] // NRSTART - first row\n header.NZSTART = intView[ 6 ] // NSSTART - first section\n\n // intervals\n header.MX = intView[ 7 ] // intervals along x\n header.MY = intView[ 8 ] // intervals along y\n header.MZ = intView[ 9 ] // intervals along z\n\n // cell length (Angstroms in CCP4)\n header.xlen = floatView[ 10 ] * this.voxelSize\n header.ylen = floatView[ 11 ] * this.voxelSize\n header.zlen = floatView[ 12 ] * this.voxelSize\n\n // cell angle (Degrees)\n header.alpha = floatView[ 13 ]\n header.beta = floatView[ 14 ]\n header.gamma = floatView[ 15 ]\n\n // axis correspondence (1,2,3 for X,Y,Z)\n header.MAPC = intView[ 16 ] // column\n header.MAPR = intView[ 17 ] // row\n header.MAPS = intView[ 18 ] // section\n\n // density statistics\n header.DMIN = floatView[ 19 ]\n header.DMAX = floatView[ 20 ]\n header.DMEAN = floatView[ 21 ]\n\n // space group number 0 or 1 (default=0)\n header.ISPG = intView[ 22 ]\n\n // number of bytes used for symmetry data (0 or 80)\n header.NSYMBT = intView[ 23 ]\n\n // Flag for skew transformation, =0 none, =1 if foll\n header.LSKFLG = intView[ 24 ]\n\n // 26-34 SKWMAT Skew matrix S (in order S11, S12, S13, S21 etc) if\n // LSKFLG .ne. 0.\n // 35-37 SKWTRN Skew translation t if LSKFLG != 0.\n // Skew transformation is from standard orthogonal\n // coordinate frame (as used for atoms) to orthogonal\n // map frame, as Xo(map) = S * (Xo(atoms) - t)\n\n // 38 future use (some of these are used by the MSUBSX routines\n // . \" in MAPBRICK, MAPCONT and FRODO)\n // . \" (all set to zero by default)\n // . \"\n // 52 \"\n\n // 50-52 origin in X,Y,Z used for transforms\n header.originX = floatView[ 49 ]\n header.originY = floatView[ 50 ]\n header.originZ = floatView[ 51 ]\n\n // 53 MAP Character string 'MAP ' to identify file type\n // => see top of this parser\n\n // 54 MACHST Machine stamp indicating machine type which wrote file\n // => see top of this parser\n\n // Rms deviation of map from mean density\n header.ARMS = floatView[ 54 ]\n\n // 56 NLABL Number of labels being used\n // 57-256 LABEL(20,10) 10 80 character text labels (ie. A4 format)\n\n v.header = header\n\n // Log.log( header );\n\n let data\n if (header.MODE === 2) {\n data = new Float32Array(\n bin, 256 * 4 + header.NSYMBT,\n header.NX * header.NY * header.NZ\n )\n } else if (header.MODE === 0) {\n data = new Float32Array(new Int8Array(\n bin, 256 * 4 + header.NSYMBT,\n header.NX * header.NY * header.NZ\n ))\n\n // based on uglymol (https://github.com/uglymol/uglymol) by Marcin Wojdyr (wojdyr)\n // if the file was converted by mapmode2to0 - scale the data\n if (intView[ 39 ] === -128 && intView[ 40 ] === 127) {\n // scaling f(x)=b1*x+b0 such that f(-128)=min and f(127)=max\n const b1 = (header.DMAX - header.DMIN) / 255.0\n const b0 = 0.5 * (header.DMIN + header.DMAX + b1)\n for (let j = 0, jl = data.length; j < jl; ++j) {\n data[ j ] = b1 * data[ j ] + b0\n }\n }\n } else {\n Log.error('MrcParser unknown mode', header.MODE)\n }\n\n v.setData(data, header.NX, header.NY, header.NZ)\n if (header.ARMS !== 0) {\n v.setStats(header.DMIN, header.DMAX, header.DMEAN, header.ARMS)\n }\n\n if (Debug) Log.timeEnd('MrcParser._parse ' + this.name)\n }\n\n getMatrix () {\n const h = this.volume.header\n\n const basisX = [\n h.xlen,\n 0,\n 0\n ]\n\n const basisY = [\n h.ylen * Math.cos(Math.PI / 180.0 * h.gamma),\n h.ylen * Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n\n const basisZ = [\n h.zlen * Math.cos(Math.PI / 180.0 * h.beta),\n h.zlen * (\n Math.cos(Math.PI / 180.0 * h.alpha) -\n Math.cos(Math.PI / 180.0 * h.gamma) *\n Math.cos(Math.PI / 180.0 * h.beta)\n ) / Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n basisZ[ 2 ] = Math.sqrt(\n h.zlen * h.zlen * Math.sin(Math.PI / 180.0 * h.beta) *\n Math.sin(Math.PI / 180.0 * h.beta) - basisZ[ 1 ] * basisZ[ 1 ]\n )\n\n const basis = [ [], basisX, basisY, basisZ ]\n const nxyz = [ 0, h.MX, h.MY, h.MZ ]\n const mapcrs = [ 0, h.MAPC, h.MAPR, h.MAPS ]\n\n const matrix = new Matrix4()\n\n matrix.set(\n basis[ mapcrs[1] ][0] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][0] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][0] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][1] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][1] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][1] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][2] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][2] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][2] / nxyz[ mapcrs[3] ],\n 0,\n 0, 0, 0, 1\n )\n\n matrix.setPosition(new Vector3(\n h.originX, h.originY, h.originZ\n ))\n\n matrix.multiply(new Matrix4().makeTranslation(\n h.NXSTART, h.NYSTART, h.NZSTART\n ))\n\n return matrix\n }\n}\n\nParserRegistry.add('mrc', MrcParser)\nParserRegistry.add('ccp4', MrcParser)\nParserRegistry.add('map', MrcParser)\n\nexport default MrcParser\n","/**\n * @file Xplor Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport VolumeParser from './volume-parser'\n\nconst reWhitespace = /\\s+/\n\nfunction parseNumberLine (line: string) {\n return line.trim().split(reWhitespace).map(parseFloat)\n}\n\ninterface XplorHeader {\n NA: number,\n AMIN: number,\n AMAX: number,\n NB: number,\n BMIN: number,\n BMAX: number,\n NC: number,\n CMIN: number,\n CMAX: number,\n a: number,\n b: number,\n c: number,\n alpha: number,\n beta: number,\n gamma: number,\n RAVE: number,\n RSIGMA: number\n}\n\nclass XplorParser extends VolumeParser {\n get type () { return 'xplor' }\n\n _parse () {\n // http://hincklab.uthscsa.edu/html/soft_packs/msi_docs/insight980/xplor/formats.html\n // http://www.mrc-lmb.cam.ac.uk/public/xtal/doc/cns/cns_1.3/tutorial/formats/maps/text.html\n\n if (Debug) Log.time('XplorParser._parse ' + this.name)\n\n const v = this.volume\n const headerLines = this.streamer.peekLines(8)\n const header: Partial = {}\n\n let infoStart\n if (headerLines[ 2 ].startsWith('REMARKS')) {\n infoStart = parseInt(headerLines[ 1 ].substring(0, 8)) + 2\n } else {\n infoStart = 5\n }\n const dataStart = infoStart + 3\n\n const gridInfo = parseNumberLine(headerLines[ infoStart ])\n header.NA = gridInfo[ 0 ]\n header.AMIN = gridInfo[ 1 ]\n header.AMAX = gridInfo[ 2 ]\n header.NB = gridInfo[ 3 ]\n header.BMIN = gridInfo[ 4 ]\n header.BMAX = gridInfo[ 5 ]\n header.NC = gridInfo[ 6 ]\n header.CMIN = gridInfo[ 7 ]\n header.CMAX = gridInfo[ 8 ]\n\n const cellInfo = parseNumberLine(headerLines[ infoStart + 1 ])\n header.a = cellInfo[ 0 ] * this.voxelSize\n header.b = cellInfo[ 1 ] * this.voxelSize\n header.c = cellInfo[ 2 ] * this.voxelSize\n header.alpha = cellInfo[ 3 ]\n header.beta = cellInfo[ 4 ]\n header.gamma = cellInfo[ 5 ]\n\n const na = header.AMAX - header.AMIN + 1\n const nb = header.BMAX - header.BMIN + 1\n const nc = header.CMAX - header.CMIN + 1\n const n = na * nb * nc\n\n const data = new Float32Array(n)\n const lineSection = Math.ceil(1 + (na * nb) / 6)\n let count = 0\n let lineNo = 0\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n\n if (lineNo >= dataStart && (lineNo - dataStart) % lineSection !== 0 && count < n) {\n for (let j = 0, lj = 6; j < lj; ++j) {\n const value = parseFloat(line.substr(12 * j, 12))\n if (isNaN(value)) { break } // Last line of map section\n data[count++] = value\n }\n } else if (count === n) {\n const lt = line.trim()\n if (lt && lt !== '-9999') {\n const ls = parseNumberLine(line)\n header.RAVE = ls[0]\n header.RSIGMA = ls[1]\n }\n }\n\n ++lineNo\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n v.header = header\n v.setData(data, na, nb, nc)\n if (header.RAVE !== 0 && header.RSIGMA !== 1) {\n v.setStats(undefined, undefined, header.RAVE, header.RSIGMA)\n }\n\n if (Debug) Log.timeEnd('XplorParser._parse ' + this.name)\n }\n\n getMatrix () {\n const h = this.volume.header\n\n const basisX = [\n h.a,\n 0,\n 0\n ]\n\n const basisY = [\n h.b * Math.cos(Math.PI / 180.0 * h.gamma),\n h.b * Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n\n const basisZ = [\n h.c * Math.cos(Math.PI / 180.0 * h.beta),\n h.c * (\n Math.cos(Math.PI / 180.0 * h.alpha) -\n Math.cos(Math.PI / 180.0 * h.gamma) *\n Math.cos(Math.PI / 180.0 * h.beta)\n ) / Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n basisZ[ 2 ] = Math.sqrt(\n h.c * h.c * Math.sin(Math.PI / 180.0 * h.beta) *\n Math.sin(Math.PI / 180.0 * h.beta) - basisZ[ 1 ] * basisZ[ 1 ]\n )\n\n const basis = [ [], basisX, basisY, basisZ ]\n const nxyz = [ 0, h.NA, h.NB, h.NC ]\n const mapcrs = [ 0, 1, 2, 3 ]\n\n const matrix = new Matrix4()\n\n matrix.set(\n basis[ mapcrs[1] ][0] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][0] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][0] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][1] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][1] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][1] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][2] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][2] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][2] / nxyz[ mapcrs[3] ],\n 0,\n 0, 0, 0, 1\n )\n\n matrix.multiply(new Matrix4().makeTranslation(\n h.AMIN, h.BMIN, h.CMIN\n ))\n\n return matrix\n }\n}\n\nParserRegistry.add('xplor', XplorParser)\nParserRegistry.add('cns', XplorParser)\n\nexport default XplorParser\n","/**\n * @file Kin Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { Vector3 } from 'three'\nimport Parser from './parser'\n\nfunction hsvToRgb (h: number, s: number, v: number) {\n h /= 360\n s /= 100\n v /= 100\n let r, g, b\n const i = Math.floor(h * 6)\n const f = h * 6 - i\n const p = v * (1 - s)\n const q = v * (1 - f * s)\n const t = v * (1 - (1 - f) * s)\n switch (i % 6) {\n case 0: r = v; g = t; b = p; break\n case 1: r = q; g = v; b = p; break\n case 2: r = p; g = v; b = t; break\n case 3: r = p; g = q; b = v; break\n case 4: r = t; g = p; b = v; break\n case 5: r = v; g = p; b = q; break\n }\n return [ r, g, b ] as number []\n}\n\nconst ColorDict: {[k: string]: number[]} = {\n red: hsvToRgb(0, 100, 100),\n orange: hsvToRgb(20, 100, 100),\n gold: hsvToRgb(40, 100, 100),\n yellow: hsvToRgb(60, 100, 100),\n lime: hsvToRgb(80, 100, 100),\n green: hsvToRgb(120, 80, 100),\n sea: hsvToRgb(150, 100, 100),\n cyan: hsvToRgb(180, 100, 85),\n sky: hsvToRgb(210, 75, 95),\n blue: hsvToRgb(240, 70, 100),\n purple: hsvToRgb(275, 75, 100),\n magenta: hsvToRgb(300, 95, 100),\n hotpink: hsvToRgb(335, 100, 100),\n pink: hsvToRgb(350, 55, 100),\n peach: hsvToRgb(25, 75, 100),\n lilac: hsvToRgb(275, 55, 100),\n pinktint: hsvToRgb(340, 30, 100),\n peachtint: hsvToRgb(25, 50, 100),\n yellowtint: hsvToRgb(60, 50, 100),\n greentint: hsvToRgb(135, 40, 100),\n bluetint: hsvToRgb(220, 40, 100),\n lilactint: hsvToRgb(275, 35, 100),\n white: hsvToRgb(0, 0, 100),\n gray: hsvToRgb(0, 0, 50),\n brown: hsvToRgb(20, 45, 75),\n deadwhite: [ 1, 1, 1 ],\n deadblack: [ 0, 0, 0 ],\n invisible: [ 0, 0, 0 ]\n}\n\nconst reWhitespaceComma = /[\\s,]+/\nconst reCurlyWhitespace = /[^{}\\s]*{[^{}]+}|[^{}\\s]+/g\nconst reTrimCurly = /^{+|}+$/g\nconst reTrimQuotes = /^['\"]+|['\"]+$/g\nconst reCollapseEqual = /\\s*=\\s*/g\n\nfunction parseListDef (line: string) {\n let name\n let defaultColor\n let master = []\n let width\n\n line = line.replace(reCollapseEqual, '=')\n\n const lm = line.match(reCurlyWhitespace) as RegExpMatchArray\n for (let j = 1; j < lm.length; ++j) {\n const e = lm[ j ]\n if (e[ 0 ] === '{') {\n name = e.substring(1, e.length - 1)\n } else {\n const es = e.split('=')\n if (es.length === 2) {\n if (es[ 0 ] === 'color') {\n defaultColor = ColorDict[ es[ 1 ] ]\n } else if (es[ 0 ] === 'width') {\n width = parseInt(es[ 1 ])\n } else if (es[ 0 ] === 'master') {\n master.push(es[ 1 ].replace(reTrimCurly, ''))\n }\n }\n }\n }\n\n return {\n listName: name,\n listColor: defaultColor,\n listMasters: master,\n listWidth: width\n }\n}\n\nfunction parseListElm (line: string) {\n line = line.trim()\n\n const idx1 = line.indexOf('{')\n const idx2 = line.indexOf('}')\n const ls = line.substr(idx2 + 1).split(reWhitespaceComma)\n\n const label = line.substr(idx1 + 1, idx2 - 1)\n const position = [\n parseFloat(ls[ ls.length - 3 ]),\n parseFloat(ls[ ls.length - 2 ]),\n parseFloat(ls[ ls.length - 1 ])\n ]\n let color, width, radius\n let lineBreak = false\n let triangleBreak = false\n for (let lsindex = 4; lsindex <= ls.length; lsindex++) {\n const literal = ls[ ls.length - lsindex ]\n if (literal in ColorDict) {\n color = ColorDict[ ls[ ls.length - lsindex ] ]\n }\n if (literal.startsWith('width')) {\n width = parseInt(literal.substring(5))\n }\n if (literal.startsWith('r=')) {\n radius = parseFloat(literal.split('=')[1])\n }\n if (literal.startsWith('P')) {\n lineBreak = true\n }\n if (literal.startsWith('X')) {\n triangleBreak = true\n }\n }\n // const color = line[ idx2 + 1 ] === ' ' ? undefined : ColorDict[ ls[ 0 ] ]\n\n return {\n label: label,\n position: position,\n color: color,\n radius: radius,\n width: width,\n isLineBreak: lineBreak,\n isTriangleBreak: triangleBreak\n }\n}\n\nfunction parseStr (line: string) {\n const start = line.indexOf('{')\n const end = line.indexOf('}')\n return line.substring(\n start !== -1 ? start + 1 : 0,\n end !== -1 ? end : undefined\n ).trim()\n}\n\nfunction parseFlag (line: string) {\n const end = line.indexOf('}')\n return end === -1 ? undefined : line.substr(end + 1).trim()\n}\n\nfunction parseGroup (line: string) {\n let name:string = ''\n let master:string[] = []\n let flags: {[k: string]: string|boolean} = {}\n\n line = line.replace(reCollapseEqual, '=')\n\n const lm = line.match(reCurlyWhitespace) as RegExpMatchArray\n for (let j = 1; j < lm.length; ++j) {\n const e = lm[ j ]\n if (e[ 0 ] === '{') {\n name = e.substring(1, e.length - 1)\n } else {\n const es = e.split('=')\n if (es.length === 2) {\n if (es[ 0 ] === 'master') {\n master.push(es[ 1 ].replace(reTrimCurly, ''))\n } else {\n flags[ es[ 0 ] ] = es[ 1 ].replace(reTrimCurly, '')\n }\n } else {\n flags[ es[ 0 ] ] = true\n }\n }\n }\n\n return { groupName: name,\n groupFlags: flags,\n groupMasters: master\n }\n}\ninterface RibbonObject {\n labelArray: string[],\n positionArray: number[],\n breakArray: boolean[],\n colorArray: number[],\n name?: string,\n masterArray: any[]\n}\nfunction convertKinTriangleArrays (ribbonObject: RibbonObject) {\n // have to convert ribbons/triangle lists from stripdrawmode to normal drawmode\n // index [ 0 1 2 3 4 5 6 7 8 91011 ]\n // label [ 0 1 2 3 4 5 ] to [ 0 1 2 1 2 3 2 3 4 3 4 5 ]\n // convertedindex [ 0 1 2 3 4 5 6 7 8 91011121314151617181920212223242526 ]\n // index [ 0 1 2 3 4 5 6 7 8 91011121314 ] [ 0 1 2 3 4 5 6 7 8 3 4 5 6 7 8 91011 6 7 8 91011121314 ]\n // position/color [ 0 0 0 1 1 1 2 2 2 3 3 3 4 4 4 ] to [ 0 0 0 1 1 1 2 2 2 1 1 1 2 2 2 3 3 3 2 2 2 3 3 3 4 4 4 ]\n let { labelArray, positionArray, colorArray, breakArray } = ribbonObject\n let convertedLabels = []\n for (let i = 0; i < (labelArray.length - 2) * 3; ++i) {\n convertedLabels[i] = labelArray[i - Math.floor(i / 3) * 2]\n }\n let convertedBreaks = []\n for (let i = 0; i < (breakArray.length - 2) * 3; ++i) {\n convertedBreaks[i] = breakArray[i - Math.floor(i / 3) * 2]\n }\n let convertedPositions = []\n for (let i = 0; i < (positionArray.length / 3 - 2) * 9; ++i) {\n convertedPositions[i] = positionArray[i - Math.floor(i / 9) * 6]\n }\n let convertedColors = []\n for (let i = 0; i < (colorArray.length / 3 - 2) * 9; ++i) {\n convertedColors[i] = colorArray[i - Math.floor(i / 9) * 6]\n }\n let vector3Positions = []\n for (let i = 0; i < (convertedPositions.length) / 3; ++i) {\n vector3Positions.push(new Vector3(convertedPositions[i * 3], convertedPositions[i * 3] + 1, convertedPositions[i * 3] + 2))\n }\n //let normals = []\n //for (let i = 0; i < vector3Positions.length - 1; ++i) {\n // let normalVec3 = vector3Positions[i].cross(vector3Positions[i + 1])\n // normals.push(normalVec3.x)\n // normals.push(normalVec3.y)\n // normals.push(normalVec3.z)\n //}\n return {\n name: ribbonObject.name,\n masterArray: ribbonObject.masterArray,\n labelArray: convertedLabels,\n positionArray: convertedPositions,\n breakArray: convertedBreaks,\n colorArray: convertedColors\n }\n}\n\nfunction removePointBreaksTriangleArrays (convertedRibbonObject: RibbonObject) {\n // after converting ribbon/triangle arrys to drawmode, removed point break triangles\n // label [ 0 1 2 3 4 5 ] to [ 0 1 2 1 2 3 2 3 4 3 4 5 ]\n // position/color [ 0 0 0 1 1 1 2 2 2 3 3 3 4 4 4 ] to [ 0 0 0 1 1 1 2 2 2 1 1 1 2 2 2 3 3 3 2 2 2 3 3 3 4 4 4 ]\n let { labelArray, positionArray, colorArray, breakArray } = convertedRibbonObject\n let editedLabels = []\n let editedPositions = []\n let editedColors = []\n let editedBreaks = []\n for (let i = 0; i < breakArray.length / 3; i++) {\n let breakPointer = i * 3\n let positionPointer = i * 9\n if (!breakArray[breakPointer+1]&&!breakArray[breakPointer+2]) {\n editedLabels.push(labelArray[breakPointer])\n editedLabels.push(labelArray[breakPointer+1])\n editedLabels.push(labelArray[breakPointer+2])\n editedBreaks.push(breakArray[breakPointer])\n editedBreaks.push(breakArray[breakPointer+1])\n editedBreaks.push(breakArray[breakPointer+2])\n editedPositions.push(positionArray[positionPointer])\n editedPositions.push(positionArray[positionPointer+1])\n editedPositions.push(positionArray[positionPointer+2])\n editedPositions.push(positionArray[positionPointer+3])\n editedPositions.push(positionArray[positionPointer+4])\n editedPositions.push(positionArray[positionPointer+5])\n editedPositions.push(positionArray[positionPointer+6])\n editedPositions.push(positionArray[positionPointer+7])\n editedPositions.push(positionArray[positionPointer+8])\n editedColors.push(colorArray[positionPointer])\n editedColors.push(colorArray[positionPointer+1])\n editedColors.push(colorArray[positionPointer+2])\n editedColors.push(colorArray[positionPointer+3])\n editedColors.push(colorArray[positionPointer+4])\n editedColors.push(colorArray[positionPointer+5])\n editedColors.push(colorArray[positionPointer+6])\n editedColors.push(colorArray[positionPointer+7])\n editedColors.push(colorArray[positionPointer+8])\n } else {\n //console.log('X triangle break found')\n //console.log('skipping: '+positionArray[positionPointer]+','+positionArray[positionPointer+1]+','+positionArray[positionPointer+2]+','\n // +positionArray[positionPointer+3]+','+positionArray[positionPointer+4]+','+positionArray[positionPointer+5]+','\n // +positionArray[positionPointer+6]+','+positionArray[positionPointer+7]+','+positionArray[positionPointer+8])\n }\n }\n return {\n name: convertedRibbonObject.name,\n masterArray: convertedRibbonObject.masterArray,\n labelArray: editedLabels,\n positionArray: editedPositions,\n breakArray: editedBreaks,\n colorArray: editedColors\n }\n}\n\ninterface Kinemage {\n kinemage?: number,\n onewidth?: any,\n '1viewid'?: string,\n pdbfile?: string,\n text: string,\n texts: string[],\n captions: string[],\n caption: string,\n groupDict: {[k:string]: {[k:string]: boolean}},\n subgroupDict: {[k: string]: any},\n masterDict: {[k:string]: {indent: boolean, visible: boolean}},\n pointmasterDict: {[k: string]: any},\n dotLists: DotList[],\n vectorLists: VectorList[],\n ballLists: any[],\n ribbonLists: RibbonObject[]\n}\n\ninterface DotList {\n name?: string,\n masterArray: any[],\n labelArray: any[],\n positionArray: any[],\n colorArray: any[]\n}\n\ninterface VectorList {\n name?: string,\n masterArray: any[],\n label1Array: string[],\n label2Array: string[],\n position1Array: number[],\n position2Array: number[],\n color1Array: number[],\n color2Array: number[],\n width: number[]\n}\n\nclass KinParser extends Parser {\n kinemage: Kinemage\n get type () { return 'kin' }\n get __objName () { return 'kinemage' }\n\n _parse () {\n // http://kinemage.biochem.duke.edu/software/king.php\n\n if (Debug) Log.time(`KinParser._parse ${this.name}`)\n\n const kinemage: Kinemage = {\n kinemage: undefined,\n onewidth: undefined,\n '1viewid': undefined,\n pdbfile: undefined,\n texts: [],\n text: '',\n captions: [],\n caption: '',\n groupDict: {},\n subgroupDict: {},\n masterDict: {},\n pointmasterDict: {},\n dotLists: [],\n vectorLists: [],\n ballLists: [],\n ribbonLists: []\n }\n this.kinemage = kinemage\n\n let currentGroupMasters: string[]\n let currentSubgroupMasters: string[]\n\n let isDotList = false\n let prevDotLabel = ''\n let dotDefaultColor: number[]\n let dotLabel: string[], dotPosition: number[], dotColor: number[]\n\n let isVectorList = false\n let prevVecLabel = ''\n let prevVecPosition: number[]|null = null\n let prevVecColor: number[]|null = null\n let vecDefaultColor: number[], vecDefaultWidth: number[]\n let vecLabel1: string[], vecLabel2: string[], vecPosition1: number[], vecPosition2: number[], vecColor1: number[], vecColor2: number[]\n\n let isBallList = false\n let prevBallLabel = ''\n let ballRadius: number[], ballDefaultColor: number[]\n let ballLabel: string[], ballPosition: number[], ballColor: number[]\n\n let isRibbonList = false\n let prevRibbonPointLabel = ''\n\n let ribbonListDefaultColor: number[]\n let ribbonPointLabelArray: string[], ribbonPointPositionArray: number[], ribbonPointBreakArray: boolean[], ribbonPointColorArray: number[]\n\n let isText = false\n let isCaption = false\n\n // @vectorlist {mc} color= white master= {mainchain}\n // { n thr A 1 B13.79 1crnFH} P 17.047, 14.099, 3.625 { n thr A 1 B13.79 1crnFH} L 17.047, 14.099, 3.625\n\n // @dotlist {x} color=white master={vdw contact} master={dots}\n // { CB THR 1 A}sky 'P' 18.915,14.199,5.024\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n\n if (line[ 0 ] === '@') {\n isDotList = false\n isVectorList = false\n isBallList = false\n isRibbonList = false\n isText = false\n isCaption = false\n }\n\n if (!line) {\n isDotList = false\n isVectorList = false\n isBallList = false\n isRibbonList = false\n } else if (line.startsWith('@dotlist')) {\n // @dotlist {x} color=white master={vdw contact} master={dots}\n\n let { listColor, listName, listMasters } = parseListDef(line)\n\n isDotList = true\n prevDotLabel = ''\n dotLabel = []\n dotPosition = []\n dotColor = []\n dotDefaultColor = listColor as number[]\n\n if (currentGroupMasters) {\n listMasters = listMasters.concat(currentGroupMasters)\n }\n if (currentSubgroupMasters) {\n listMasters = listMasters.concat(currentSubgroupMasters)\n }\n\n kinemage.dotLists.push({\n name: listName,\n masterArray: listMasters,\n labelArray: dotLabel,\n positionArray: dotPosition,\n colorArray: dotColor\n })\n } else if (line.startsWith('@vectorlist')) {\n // @vectorlist {x} color=white master={small overlap} master={dots}\n\n let { listMasters, listName, listWidth, listColor } = parseListDef(line)\n\n if (listMasters) {\n listMasters.forEach(function (name: string) {\n if (!kinemage.masterDict[ name ]) {\n kinemage.masterDict[ name ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n\n isVectorList = true\n prevVecLabel = ''\n prevVecPosition = null\n prevVecColor = null\n vecLabel1 = []\n vecLabel2 = []\n vecPosition1 = []\n vecPosition2 = []\n vecColor1 = []\n vecColor2 = []\n vecDefaultColor = listColor as number[]\n vecDefaultWidth = []\n if (listWidth) {\n vecDefaultWidth.push(listWidth)\n }\n\n if (currentGroupMasters) {\n listMasters = listMasters.concat(currentGroupMasters)\n }\n if (currentSubgroupMasters) {\n listMasters = listMasters.concat(currentSubgroupMasters)\n }\n\n kinemage.vectorLists.push({\n name: listName,\n masterArray: listMasters,\n label1Array: vecLabel1,\n label2Array: vecLabel2,\n position1Array: vecPosition1,\n position2Array: vecPosition2,\n color1Array: vecColor1,\n color2Array: vecColor2,\n width: vecDefaultWidth\n })\n } else if (line.startsWith('@balllist')) {\n let { listName, listColor, listMasters } = parseListDef(line)\n\n if (listMasters) {\n listMasters.forEach(function (name: string) {\n if (!kinemage.masterDict[ name ]) {\n kinemage.masterDict[ name ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n\n isBallList = true\n\n prevBallLabel = ''\n ballLabel = []\n ballRadius = []\n ballPosition = []\n ballColor = []\n ballDefaultColor = listColor as number[]\n\n if (currentGroupMasters) {\n listMasters = listMasters.concat(currentGroupMasters)\n }\n if (currentSubgroupMasters) {\n listMasters = listMasters.concat(currentSubgroupMasters)\n }\n\n kinemage.ballLists.push({\n name: listName,\n masterArray: listMasters,\n labelArray: ballLabel,\n radiusArray: ballRadius,\n positionArray: ballPosition,\n colorArray: ballColor\n })\n } else if (line.startsWith('@ribbonlist')||line.startsWith('@trianglelist')) {\n let { listMasters, listName, listColor } = parseListDef(line)\n\n if (listMasters) {\n listMasters.forEach(function (name: string) {\n if (!kinemage.masterDict[ name ]) {\n kinemage.masterDict[ name ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n isRibbonList = true\n prevRibbonPointLabel = ''\n ribbonPointLabelArray = []\n ribbonPointPositionArray = []\n ribbonPointBreakArray = []\n ribbonPointColorArray = []\n ribbonListDefaultColor = listColor as number[]\n\n if (currentGroupMasters) {\n listMasters = listMasters.concat(currentGroupMasters)\n }\n if (currentSubgroupMasters) {\n listMasters = listMasters.concat(currentSubgroupMasters)\n }\n\n kinemage.ribbonLists.push({\n name: listName,\n masterArray: listMasters,\n labelArray: ribbonPointLabelArray,\n positionArray: ribbonPointPositionArray,\n breakArray: ribbonPointBreakArray,\n colorArray: ribbonPointColorArray\n })\n } else if (line.startsWith('@text')) {\n isText = true\n kinemage.texts.push(line.substr(5))\n } else if (line.startsWith('@caption')) {\n isCaption = true\n kinemage.captions.push(line.substr(8))\n } else if (isDotList) {\n // { CB THR 1 A}sky 'P' 18.915,14.199,5.024\n\n let { label, color, position } = parseListElm(line)\n\n if (label === '\"') {\n label = prevDotLabel\n } else {\n prevDotLabel = label\n }\n\n if (color === undefined) {\n color = dotDefaultColor\n }\n\n dotLabel.push(label)\n dotPosition.push(...position)\n dotColor.push(...color)\n } else if (isVectorList) {\n // { n thr A 1 B13.79 1crnFH} P 17.047, 14.099, 3.625 { n thr A 1 B13.79 1crnFH} L 17.047, 14.099, 3.625\n\n let doubleLine = line.replace(/(?!^){/g, '\\n{')\n let splitLine = doubleLine.split(/\\n/)\n\n for (var i2 = 0; i2 < splitLine.length; i2++) {\n let singlePointLine = splitLine[i2]\n let { label, color, width, position, isLineBreak } = parseListElm(singlePointLine)\n\n if (label === '\"') {\n label = prevVecLabel\n } else {\n prevVecLabel = label\n }\n\n if (color === undefined) {\n color = vecDefaultColor\n }\n\n if (!isLineBreak) {\n if (prevVecPosition !== null) {\n if (width) {\n vecDefaultWidth.push(width)\n }\n\n vecLabel1.push(prevVecLabel)\n vecPosition1.push(...prevVecPosition)\n vecColor1.push(...prevVecColor as number[])\n\n vecLabel2.push(label)\n vecPosition2.push(...position)\n vecColor2.push(...color)\n\n }\n }\n\n prevVecLabel = label\n prevVecPosition = position\n prevVecColor = color\n }\n } else if (isBallList) {\n // {cb arg A 1 1.431 -106.80} r=1.431 39.085, 8.083, 22.182\n\n let { label, radius, color, position } = parseListElm(line)\n\n if (label === '\"') {\n label = prevBallLabel\n } else {\n prevBallLabel = label\n }\n\n if (radius === undefined) {\n radius = 1 // temporary default radius\n }\n\n if (color === undefined) {\n color = ballDefaultColor\n }\n\n ballLabel.push(label)\n ballRadius.push(radius)\n ballPosition.push(...position)\n ballColor.push(...color)\n } else if (isRibbonList) {\n let { label, color, position, isTriangleBreak } = parseListElm(line)\n\n if (label === '\"') {\n label = prevRibbonPointLabel\n } else {\n prevRibbonPointLabel = label\n }\n\n if (color === undefined) {\n color = ribbonListDefaultColor\n }\n\n ribbonPointLabelArray.push(label)\n ribbonPointPositionArray.push(...position)\n ribbonPointBreakArray.push(isTriangleBreak)\n ribbonPointColorArray.push(...color)\n } else if (isText) {\n kinemage.texts.push(line)\n } else if (isCaption) {\n kinemage.captions.push(line)\n } else if (line.startsWith('@kinemage')) {\n kinemage.kinemage = parseInt(line.substr(9).trim())\n } else if (line.startsWith('@onewidth')) {\n kinemage.onewidth = true\n } else if (line.startsWith('@1viewid')) {\n kinemage[ '1viewid' ] = parseStr(line)\n } else if (line.startsWith('@pdbfile')) {\n kinemage.pdbfile = parseStr(line)\n } else if (line.startsWith('@group')) {\n let { groupName, groupFlags, groupMasters } = parseGroup(line)\n if (!kinemage.groupDict[ groupName as string ]) {\n kinemage.groupDict[ groupName as string ] = {\n dominant: false,\n animate: false\n }\n currentGroupMasters = groupMasters\n }\n\n if (currentGroupMasters) {\n currentGroupMasters.forEach(function (master) {\n if (!kinemage.masterDict[ master ]) {\n kinemage.masterDict[ master ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n\n for (let key in groupFlags as {[k: string]: boolean}) {\n kinemage.groupDict[ groupName as string ][ key ] = (groupFlags as {[k: string]: boolean})[ key ]\n }\n } else if (line.startsWith('@subgroup')) {\n const { groupName, groupFlags, groupMasters } = parseGroup(line)\n\n if (!kinemage.subgroupDict[ groupName as string ]) {\n kinemage.subgroupDict[ groupName as string ] = {\n dominant: false,\n animate: false\n }\n currentSubgroupMasters = groupMasters\n }\n\n if (currentSubgroupMasters) {\n currentSubgroupMasters.forEach(function (master) {\n if (!kinemage.masterDict[ master ]) {\n kinemage.masterDict[ master ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n\n for (let key in groupFlags as {[k: string]: boolean}) {\n kinemage.subgroupDict[ groupName as string ][ key ] = (groupFlags as {[k: string]: boolean})[ key ]\n }\n } else if (line.startsWith('@master')) {\n const name = parseStr(line)\n const flag = parseFlag(line)\n\n if (!kinemage.masterDict[ name ]) {\n kinemage.masterDict[ name ] = {\n indent: false,\n visible: false\n }\n }\n\n if (flag === 'on') {\n kinemage.masterDict[ name ].visible = true\n } else if (flag === 'off') {\n kinemage.masterDict[ name ].visible = false\n } else if (flag === 'indent') {\n kinemage.masterDict[ name ].indent = true\n } else if (!flag) {\n // nothing to do\n }\n } else if (line.startsWith('@pointmaster')) {\n const { groupName, groupFlags } = parseGroup(line)\n\n kinemage.pointmasterDict[ groupName as string] = {\n id: Object.keys(groupFlags as {[k: string]: boolean})[ 0 ].replace(reTrimQuotes, '')\n }\n } else {\n console.log(line)\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n kinemage.text = kinemage.texts.join('\\n').trim()\n kinemage.caption = kinemage.captions.join('\\n').trim()\n if (kinemage.ribbonLists) {\n let convertedLists: RibbonObject[] = []\n kinemage.ribbonLists.forEach(function (listObject) {\n convertedLists.push(removePointBreaksTriangleArrays(convertKinTriangleArrays(listObject)))\n })\n kinemage.ribbonLists = convertedLists\n }\n\n if (Debug) Log.timeEnd(`KinParser._parse ${this.name}`)\n }\n}\n\nParserRegistry.add('kin', KinParser)\n\nexport default KinParser\n","/**\n * @file Surface Parser\n * @author Alexander Rose \n * @private\n */\n\nimport Parser, { ParserParameters } from './parser'\nimport Surface from '../surface/surface'\nimport Streamer from '../streamer/streamer';\n\nclass SurfaceParser extends Parser {\n constructor (streamer: Streamer, params?:Partial) {\n super(streamer, params)\n\n this.loader = this.getLoader()\n this.surface = new Surface(this.name, this.path)\n }\n\n get type () { return 'surface' }\n get __objName () { return 'surface' }\n\n _parse () {\n var geometry = this.loader.parse(this.streamer.asText())\n\n this.surface.fromGeometry(geometry)\n }\n}\n\nexport default SurfaceParser\n","/**\n * @file Obj Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { BufferGeometry, BufferAttribute } from 'three'\n\nimport { ParserRegistry } from '../globals'\nimport SurfaceParser from './surface-parser'\n\nexport interface _OBJLoader {\n regexp: {[k: string]: RegExp}\n}\n\ninterface _OBJLoaderConstructor {\n (this: _OBJLoader): void\n new(): _OBJLoader\n}\n\ninterface ObjectType {\n name: string,\n fromDeclaration: boolean,\n geometry: {\n vertices: number[],\n normals: number[],\n type?: string\n }\n}\n/**\n * OBJLoader\n * @class\n * @private\n * @author mrdoob / http://mrdoob.com/\n */\nconst OBJLoader = (function OBJLoader (this: _OBJLoader) {\n this.regexp = {\n // v float float float\n vertex_pattern: /^v\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)/,\n // vn float float float\n normal_pattern: /^vn\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)/,\n // vt float float\n uv_pattern: /^vt\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)/,\n // f vertex vertex vertex\n face_vertex: /^f\\s+(-?\\d+)\\s+(-?\\d+)\\s+(-?\\d+)(?:\\s+(-?\\d+))?/,\n // f vertex/uv vertex/uv vertex/uv\n face_vertex_uv: /^f\\s+(-?\\d+)\\/(-?\\d+)\\s+(-?\\d+)\\/(-?\\d+)\\s+(-?\\d+)\\/(-?\\d+)(?:\\s+(-?\\d+)\\/(-?\\d+))?/,\n // f vertex/uv/normal vertex/uv/normal vertex/uv/normal\n face_vertex_uv_normal: /^f\\s+(-?\\d+)\\/(-?\\d+)\\/(-?\\d+)\\s+(-?\\d+)\\/(-?\\d+)\\/(-?\\d+)\\s+(-?\\d+)\\/(-?\\d+)\\/(-?\\d+)(?:\\s+(-?\\d+)\\/(-?\\d+)\\/(-?\\d+))?/,\n // f vertex//normal vertex//normal vertex//normal\n face_vertex_normal: /^f\\s+(-?\\d+)\\/\\/(-?\\d+)\\s+(-?\\d+)\\/\\/(-?\\d+)\\s+(-?\\d+)\\/\\/(-?\\d+)(?:\\s+(-?\\d+)\\/\\/(-?\\d+))?/,\n // o object_name | g group_name\n object_pattern: /^[og]\\s*(.+)?/,\n // s boolean\n smoothing_pattern: /^s\\s+(\\d+|on|off)/,\n // mtllib file_reference\n material_library_pattern: /^mtllib /,\n // usemtl material_name\n material_use_pattern: /^usemtl /\n }\n}) as _OBJLoaderConstructor\n\nOBJLoader.prototype = {\n\n constructor: OBJLoader,\n\n setPath: function (value: string) {\n this.path = value\n },\n\n _createParserState: function () {\n var state = {\n objects: [] as ObjectType[],\n object: {} as ObjectType,\n\n vertices: [],\n normals: [],\n\n startObject: function (name: string, fromDeclaration: boolean) {\n // If the current object (initial from reset) is not from a g/o declaration in the parsed\n // file. We need to use it for the first parsed g/o to keep things in sync.\n if (this.object && this.object.fromDeclaration === false) {\n this.object.name = name\n this.object.fromDeclaration = (fromDeclaration !== false)\n return\n }\n\n this.object = {\n name: name || '',\n geometry: {\n vertices: [],\n normals: []\n },\n fromDeclaration: (fromDeclaration !== false)\n }\n\n this.objects.push(this.object)\n },\n\n parseVertexIndex: function (value: string, len: number) {\n var index = parseInt(value, 10)\n return (index >= 0 ? index - 1 : index + len / 3) * 3\n },\n\n parseNormalIndex: function (value: string, len: number) {\n var index = parseInt(value, 10)\n return (index >= 0 ? index - 1 : index + len / 3) * 3\n },\n\n addVertex: function (a: number, b: number, c: number) {\n var src = this.vertices\n var dst = this.object.geometry.vertices\n\n dst.push(src[ a + 0 ])\n dst.push(src[ a + 1 ])\n dst.push(src[ a + 2 ])\n dst.push(src[ b + 0 ])\n dst.push(src[ b + 1 ])\n dst.push(src[ b + 2 ])\n dst.push(src[ c + 0 ])\n dst.push(src[ c + 1 ])\n dst.push(src[ c + 2 ])\n },\n\n addVertexLine: function (a: number) {\n var src = this.vertices\n var dst = this.object.geometry.vertices\n\n dst.push(src[ a + 0 ])\n dst.push(src[ a + 1 ])\n dst.push(src[ a + 2 ])\n },\n\n addNormal: function (a: number, b: number, c: number) {\n var src = this.normals\n var dst = this.object.geometry.normals\n\n dst.push(src[ a + 0 ])\n dst.push(src[ a + 1 ])\n dst.push(src[ a + 2 ])\n dst.push(src[ b + 0 ])\n dst.push(src[ b + 1 ])\n dst.push(src[ b + 2 ])\n dst.push(src[ c + 0 ])\n dst.push(src[ c + 1 ])\n dst.push(src[ c + 2 ])\n },\n\n addFace: function (a: string, b: string, c: string, d?: string, na?: string, nb?: string, nc?: string, nd?: string) {\n var vLen = this.vertices.length\n\n var ia = this.parseVertexIndex(a, vLen)\n var ib = this.parseVertexIndex(b, vLen)\n var ic = this.parseVertexIndex(c, vLen)\n var id\n\n if (d === undefined) {\n this.addVertex(ia, ib, ic)\n } else {\n id = this.parseVertexIndex(d, vLen)\n\n this.addVertex(ia, ib, id)\n this.addVertex(ib, ic, id)\n }\n\n if (na !== undefined) {\n // Normals are many times the same. If so, skip function call and parseInt.\n var nLen = this.normals.length\n ia = this.parseNormalIndex(na, nLen)\n\n ib = na === nb ? ia : this.parseNormalIndex(nb!, nLen)\n ic = na === nc ? ia : this.parseNormalIndex(nc!, nLen)\n\n if (d === undefined) {\n this.addNormal(ia, ib, ic)\n } else {\n id = this.parseNormalIndex(nd!, nLen)\n\n this.addNormal(ia, ib, id)\n this.addNormal(ib, ic, id)\n }\n }\n },\n\n addLineGeometry: function (vertices: string[]) {\n this.object.geometry.type = 'Line'\n\n var vLen = this.vertices.length\n\n for (var vi = 0, l = vertices.length; vi < l; vi++) {\n this.addVertexLine(this.parseVertexIndex(vertices[ vi ], vLen))\n }\n }\n\n }\n\n state.startObject('', false)\n\n return state\n },\n\n parse: function (text: string) {\n var state = this._createParserState()\n\n if (text.indexOf('\\r\\n') !== -1) {\n // This is faster than String.split with regex that splits on both\n text = text.replace(/\\r\\n/g, '\\n')\n }\n\n if (text.indexOf('\\\\\\n') !== -1) {\n // join lines separated by a line continuation character (\\)\n text = text.replace(/\\\\\\n/g, '')\n }\n\n var i, l\n var lines = text.split('\\n')\n var line = ''\n var lineFirstChar = ''\n var lineSecondChar = ''\n var lineLength = 0\n var result = []\n\n // Faster to just trim left side of the line. Use if available.\n var trimLeft = (typeof ''.trimLeft === 'function')\n\n for (i = 0, l = lines.length; i < l; i++) {\n line = lines[ i ]\n\n line = trimLeft ? line.trimLeft() : line.trim()\n\n lineLength = line.length\n\n if (lineLength === 0) continue\n\n lineFirstChar = line.charAt(0)\n\n // @todo invoke passed in handler if any\n if (lineFirstChar === '#') continue\n\n if (lineFirstChar === 'v') {\n lineSecondChar = line.charAt(1)\n\n if (lineSecondChar === ' ' && (result = this.regexp.vertex_pattern.exec(line)) !== null) {\n // 0 1 2 3\n // [\"v 1.0 2.0 3.0\", \"1.0\", \"2.0\", \"3.0\"]\n\n state.vertices.push(\n parseFloat(result[ 1 ]),\n parseFloat(result[ 2 ]),\n parseFloat(result[ 3 ])\n )\n } else if (lineSecondChar === 'n' && (result = this.regexp.normal_pattern.exec(line)) !== null) {\n // 0 1 2 3\n // [\"vn 1.0 2.0 3.0\", \"1.0\", \"2.0\", \"3.0\"]\n\n state.normals.push(\n parseFloat(result[ 1 ]),\n parseFloat(result[ 2 ]),\n parseFloat(result[ 3 ])\n )\n } else if (lineSecondChar === 't' && this.regexp.uv_pattern.exec(line) !== null) {\n\n // ignore uv line\n\n } else {\n throw new Error(\"Unexpected vertex/normal/uv line: '\" + line + \"'\")\n }\n } else if (lineFirstChar === 'f') {\n if ((result = this.regexp.face_vertex_uv_normal.exec(line)) !== null) {\n // f vertex/uv/normal vertex/uv/normal vertex/uv/normal\n // 0 1 2 3 4 5 6 7 8 9 10 11 12\n // [\"f 1/1/1 2/2/2 3/3/3\", \"1\", \"1\", \"1\", \"2\", \"2\", \"2\", \"3\", \"3\", \"3\", undefined, undefined, undefined]\n\n state.addFace(\n result[ 1 ], result[ 4 ], result[ 7 ], result[ 10 ],\n // result[ 2 ], result[ 5 ], result[ 8 ], result[ 11 ], // ignore uv part\n result[ 3 ], result[ 6 ], result[ 9 ], result[ 12 ]\n )\n } else if (this.regexp.face_vertex_uv.exec(line) !== null) {\n\n // ignore uv line\n\n } else if ((result = this.regexp.face_vertex_normal.exec(line)) !== null) {\n // f vertex//normal vertex//normal vertex//normal\n // 0 1 2 3 4 5 6 7 8\n // [\"f 1//1 2//2 3//3\", \"1\", \"1\", \"2\", \"2\", \"3\", \"3\", undefined, undefined]\n\n state.addFace(\n result[ 1 ], result[ 3 ], result[ 5 ], result[ 7 ],\n result[ 2 ], result[ 4 ], result[ 6 ], result[ 8 ]\n )\n } else if ((result = this.regexp.face_vertex.exec(line)) !== null) {\n // f vertex vertex vertex\n // 0 1 2 3 4\n // [\"f 1 2 3\", \"1\", \"2\", \"3\", undefined]\n\n state.addFace(\n result[ 1 ], result[ 2 ], result[ 3 ], result[ 4 ]\n )\n } else {\n throw new Error(\"Unexpected face line: '\" + line + \"'\")\n }\n } else if (lineFirstChar === 'l') {\n var lineParts = line.substring(1).trim().split(' ')\n var lineVertices = []\n var lineUVs = []\n\n if (line.indexOf('/') === -1) {\n lineVertices = lineParts\n } else {\n for (var li = 0, llen = lineParts.length; li < llen; li++) {\n var parts = lineParts[ li ].split('/')\n\n if (parts[ 0 ] !== '') lineVertices.push(parts[ 0 ])\n if (parts[ 1 ] !== '') lineUVs.push(parts[ 1 ])\n }\n }\n state.addLineGeometry(lineVertices, lineUVs)\n } else if ((result = this.regexp.object_pattern.exec(line)) !== null) {\n // o object_name\n // or\n // g group_name\n\n var name = result[ 0 ].substr(1).trim()\n state.startObject(name)\n\n // ignore material related lines\n // eslint-disable-next-line no-empty\n } else if (this.regexp.material_use_pattern.test(line)) {\n // eslint-disable-next-line no-empty\n } else if (this.regexp.material_library_pattern.test(line)) {\n // eslint-disable-next-line no-empty\n } else if (this.regexp.smoothing_pattern.exec(line) !== null) {\n } else {\n // Handle null terminated files without exception\n if (line === '\\0') continue\n\n throw new Error(\"Unexpected line: '\" + line + \"'\")\n }\n }\n\n var container = []\n\n for (i = 0, l = state.objects.length; i < l; i++) {\n var object = state.objects[ i ]\n var geometry = object.geometry\n\n // Skip o/g line declarations that did not follow with any faces\n if (geometry.vertices.length === 0) continue\n\n var buffergeometry = new BufferGeometry()\n\n buffergeometry.setAttribute('position', new BufferAttribute(new Float32Array(geometry.vertices), 3))\n\n if (geometry.normals.length > 0) {\n buffergeometry.setAttribute('normal', new BufferAttribute(new Float32Array(geometry.normals), 3))\n } else {\n buffergeometry.computeVertexNormals()\n }\n\n container.push(buffergeometry)\n }\n\n return container\n }\n\n}\n\nclass ObjParser extends SurfaceParser {\n get type () { return 'obj' }\n\n getLoader () {\n return new OBJLoader()\n }\n}\n\nParserRegistry.add('obj', ObjParser)\n\nexport default ObjParser\n","/**\n * @file Ply Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Geometry, Vector3, Face3, Color } from 'three'\n\nimport { ParserRegistry } from '../globals'\nimport SurfaceParser from './surface-parser'\n\n/**\n * PLYLoader\n * @class\n * @private\n * @author Wei Meng / http://about.me/menway\n *\n * @description\n * A THREE loader for PLY ASCII files (known as the Polygon File Format or the Stanford Triangle Format).\n *\n * Limitations: ASCII decoding assumes file is UTF-8.\n *\n * @example\n * var loader = new THREE.PLYLoader();\n * loader.load('./models/ply/ascii/dolphins.ply', function (geometry) {\n * scene.add( new THREE.Mesh( geometry ) );\n * } );\n *\n * // If the PLY file uses non standard property names, they can be mapped while\n * // loading. For example, the following maps the properties\n * // “diffuse_(red|green|blue)” in the file to standard color names.\n *\n * loader.setPropertyNameMapping( {\n * diffuse_red: 'red',\n * diffuse_green: 'green',\n * diffuse_blue: 'blue'\n * } );\n *\n */\n\nexport interface _PLYLoader {\n propertyNameMapping: {[k: string]: string}\n}\n\ninterface _PLYLoaderConstructor {\n (this: _PLYLoader): void\n new(): _PLYLoader\n}\n\ninterface PLYProperty {\n type: string,\n name: string,\n countType: string,\n itemType: string\n}\n\ninterface PLYElement {\n name: string,\n count: number,\n properties: PLYProperty[],\n x: number,\n y: number,\n z: number,\n red: number,\n green: number,\n blue: number,\n [k:string]: any\n}\n\ninterface PLYHeader {\n format: string,\n version: string,\n comments: string[],\n elements: PLYElement[],\n headerLength: number\n}\n\ninterface GeometryPLY extends Geometry {\n useColor: boolean\n}\n\nconst PLYLoader = (function PLYLoader (this: _PLYLoader) {\n this.propertyNameMapping = {}\n}) as _PLYLoaderConstructor\n\nPLYLoader.prototype = {\n\n constructor: PLYLoader,\n\n setPropertyNameMapping: function (mapping: {[k: string]: string}) {\n this.propertyNameMapping = mapping\n },\n\n bin2str: function (buf: ArrayBuffer) {\n var arrayBuffer = new Uint8Array(buf)\n var str = ''\n for (var i = 0; i < buf.byteLength; i++) {\n str += String.fromCharCode(arrayBuffer[ i ]) // implicitly assumes little-endian\n }\n\n return str\n },\n\n isASCII: function (data: ArrayBuffer) {\n var header = this.parseHeader(this.bin2str(data))\n\n return header.format === 'ascii'\n },\n\n parse: function (data: string|ArrayBuffer) {\n if (data instanceof ArrayBuffer) {\n return (\n this.isASCII(data)\n ? this.parseASCII(this.bin2str(data))\n : this.parseBinary(data)\n )\n } else {\n return this.parseASCII(data)\n }\n },\n\n parseHeader: function (data: string) {\n var patternHeader = /ply([\\s\\S]*)end_header\\s/\n var headerText = ''\n var headerLength = 0\n var result = patternHeader.exec(data)\n if (result !== null) {\n headerText = result[ 1 ]\n headerLength = result[ 0 ].length\n }\n\n var header: Partial = {\n comments: [],\n elements: [],\n headerLength: headerLength\n }\n\n var lines = headerText.split('\\n')\n var currentElement: PLYElement|undefined, lineType, lineValues\n\n function makePlyElementProperty (propertValues: string[], propertyNameMapping: {[k: string]: string}) {\n var property = {\n type: propertValues[ 0 ]\n } as PLYProperty\n\n if (property.type === 'list') {\n property.name = propertValues[ 3 ]\n property.countType = propertValues[ 1 ]\n property.itemType = propertValues[ 2 ]\n } else {\n property.name = propertValues[ 1 ]\n }\n\n if (property.name in propertyNameMapping) {\n property.name = propertyNameMapping[ property.name ]\n }\n\n return property\n }\n\n for (var i = 0; i < lines.length; i++) {\n var line = lines[ i ]\n line = line.trim()\n if (line === '') {\n continue\n }\n lineValues = line.split(/\\s+/)\n lineType = lineValues.shift()\n line = lineValues.join(' ')\n\n switch (lineType) {\n case 'format':\n\n header.format = lineValues[ 0 ]\n header.version = lineValues[ 1 ]\n\n break\n\n case 'comment':\n\n header.comments!.push(line)\n\n break\n\n case 'element':\n\n if (currentElement !== undefined) {\n header.elements!.push(currentElement as PLYElement)\n }\n\n currentElement = {} as PLYElement\n currentElement.name = lineValues[ 0 ]\n currentElement.count = parseInt(lineValues[ 1 ])\n currentElement.properties = []\n\n break\n\n case 'property':\n\n currentElement!.properties.push(makePlyElementProperty(lineValues, this.propertyNameMapping))\n\n break\n\n default:\n\n console.log('unhandled', lineType, lineValues)\n }\n }\n\n if (currentElement !== undefined) {\n header.elements!.push(currentElement)\n }\n\n return header\n },\n\n parseASCIINumber: function (n: string, type: string) {\n switch (type) {\n case 'char': case 'uchar': case 'short': case 'ushort': case 'int': case 'uint':\n case 'int8': case 'uint8': case 'int16': case 'uint16': case 'int32': case 'uint32':\n\n return parseInt(n)\n\n case 'float': case 'double': case 'float32': case 'float64':\n\n return parseFloat(n)\n }\n },\n\n parseASCIIElement: function (properties: PLYProperty[], line: string) {\n var values = line.split(/\\s+/)\n\n var element = {} as PLYElement\n\n for (var i = 0; i < properties.length; i++) {\n if (properties[ i ].type === 'list') {\n var list = []\n var n = this.parseASCIINumber(values.shift(), properties[ i ].countType)\n\n for (var j = 0; j < n; j++) {\n list.push(this.parseASCIINumber(values.shift(), properties[ i ].itemType))\n }\n\n element[ properties[ i ].name ] = list\n } else {\n element[ properties[ i ].name ] = this.parseASCIINumber(values.shift(), properties[ i ].type)\n }\n }\n\n return element\n },\n\n parseASCII: function (data: string) {\n // PLY ascii format specification, as per http://en.wikipedia.org/wiki/PLY_(file_format)\n\n var geometry = new Geometry() as GeometryPLY\n\n var result\n\n var header = this.parseHeader(data)\n\n var patternBody = /end_header\\s([\\s\\S]*)$/\n var body = ''\n if ((result = patternBody.exec(data)) !== null) {\n body = result[ 1 ]\n }\n\n var lines = body.split('\\n')\n var currentElement = 0\n var currentElementCount = 0\n geometry.useColor = false\n\n for (var i = 0; i < lines.length; i++) {\n var line = lines[ i ]\n line = line.trim()\n if (line === '') {\n continue\n }\n\n if (currentElementCount >= header.elements[ currentElement ].count) {\n currentElement++\n currentElementCount = 0\n }\n\n var element = this.parseASCIIElement(header.elements[ currentElement ].properties, line)\n\n this.handleElement(geometry, header.elements[ currentElement ].name, element)\n\n currentElementCount++\n }\n\n return this.postProcess(geometry)\n },\n\n postProcess: function (geometry: GeometryPLY) {\n if (geometry.useColor) {\n for (var i = 0; i < geometry.faces.length; i++) {\n geometry.faces[ i ].vertexColors = [\n geometry.colors[ geometry.faces[ i ].a ],\n geometry.colors[ geometry.faces[ i ].b ],\n geometry.colors[ geometry.faces[ i ].c ]\n ]\n }\n\n geometry.elementsNeedUpdate = true\n }\n\n geometry.computeBoundingSphere()\n\n return geometry\n },\n\n handleElement: function (geometry: GeometryPLY, elementName: string, element: PLYElement) {\n if (elementName === 'vertex') {\n geometry.vertices.push(\n new Vector3(element.x, element.y, element.z)\n )\n\n if ('red' in element && 'green' in element && 'blue' in element) {\n geometry.useColor = true\n\n var color = new Color()\n color.setRGB(element.red / 255.0, element.green / 255.0, element.blue / 255.0)\n geometry.colors.push(color)\n }\n } else if (elementName === 'face') {\n var vertexIndices = element.vertex_indices\n\n if (vertexIndices.length === 3) {\n geometry.faces.push(\n new Face3(vertexIndices[ 0 ], vertexIndices[ 1 ], vertexIndices[ 2 ])\n )\n } else if (vertexIndices.length === 4) {\n geometry.faces.push(\n new Face3(vertexIndices[ 0 ], vertexIndices[ 1 ], vertexIndices[ 3 ]),\n new Face3(vertexIndices[ 1 ], vertexIndices[ 2 ], vertexIndices[ 3 ])\n )\n }\n }\n },\n\n binaryRead: function (dataview: DataView, at: number, type: string, littleEndian: boolean) {\n switch (type) {\n // corespondences for non-specific length types here match rply:\n case 'int8': case 'char': return [ dataview.getInt8(at), 1 ]\n\n case 'uint8': case 'uchar': return [ dataview.getUint8(at), 1 ]\n\n case 'int16': case 'short': return [ dataview.getInt16(at, littleEndian), 2 ]\n\n case 'uint16': case 'ushort': return [ dataview.getUint16(at, littleEndian), 2 ]\n\n case 'int32': case 'int': return [ dataview.getInt32(at, littleEndian), 4 ]\n\n case 'uint32': case 'uint': return [ dataview.getUint32(at, littleEndian), 4 ]\n\n case 'float32': case 'float': return [ dataview.getFloat32(at, littleEndian), 4 ]\n\n case 'float64': case 'double': return [ dataview.getFloat64(at, littleEndian), 8 ]\n }\n },\n\n binaryReadElement: function (dataview: DataView, at: number, properties: PLYProperty[], littleEndian: boolean) {\n var element = {} as PLYElement\n var result\n var read = 0\n\n for (var i = 0; i < properties.length; i++) {\n if (properties[ i ].type === 'list') {\n var list = []\n\n result = this.binaryRead(dataview, at + read, properties[ i ].countType, littleEndian)\n var n = result[ 0 ]\n read += result[ 1 ]\n\n for (var j = 0; j < n; j++) {\n result = this.binaryRead(dataview, at + read, properties[ i ].itemType, littleEndian)\n list.push(result[ 0 ])\n read += result[ 1 ]\n }\n\n element[ properties[ i ].name ] = list\n } else {\n result = this.binaryRead(dataview, at + read, properties[ i ].type, littleEndian)\n element[ properties[ i ].name ] = result[ 0 ]\n read += result[ 1 ]\n }\n }\n\n return [ element, read ]\n },\n\n parseBinary: function (data: ArrayBuffer) {\n var geometry = new Geometry()\n\n var header = this.parseHeader(this.bin2str(data))\n var littleEndian = (header.format === 'binary_little_endian')\n var body = new DataView(data, header.headerLength)\n var result\n var loc = 0\n\n for (var currentElement = 0; currentElement < header.elements.length; currentElement++) {\n for (var currentElementCount = 0; currentElementCount < header.elements[ currentElement ].count; currentElementCount++) {\n result = this.binaryReadElement(body, loc, header.elements[ currentElement ].properties, littleEndian)\n loc += result[ 1 ]\n var element = result[ 0 ]\n\n this.handleElement(geometry, header.elements[ currentElement ].name, element)\n }\n }\n\n return this.postProcess(geometry)\n }\n\n}\n\nclass PlyParser extends SurfaceParser {\n get type () { return 'ply' }\n\n getLoader () {\n return new PLYLoader()\n }\n}\n\nParserRegistry.add('ply', PlyParser)\n\nexport default PlyParser\n","/**\n * @file Csv Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { ParserRegistry } from '../globals'\nimport Parser, { ParserParameters } from './parser'\nimport Streamer from '../streamer/streamer';\n\nexport interface CsvParserParameters extends ParserParameters {\n delimiter: string\n comment: string\n columnNames: boolean\n}\n/**\n * CSV parser\n */\nclass CsvParser extends Parser {\n /**\n * [constructor description]\n * @param {Streamer} streamer - the streamer object\n * @param {Object} params - parameter object\n * @param {Char} params.delimiter - delimiter character\n * @param {Char} params.comment - comment character\n * @param {Boolean} params.columnNames - use first data line as column names\n */\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.delimiter = defaults(p.delimiter, ',')\n this.comment = defaults(p.comment, '#')\n this.columnNames = defaults(p.columnNames, false)\n\n this.table = {\n name: this.name,\n path: this.path,\n columnNames: [],\n data: []\n }\n }\n\n get type () { return 'csv' }\n get __objName () { return 'table' }\n\n _parse () {\n const data = this.table.data\n const reDelimiter = new RegExp('\\\\s*' + this.delimiter + '\\\\s*')\n\n let j = 0\n\n this.streamer.eachChunkOfLines(chunk => {\n const n = chunk.length\n\n for (let i = 0; i < n; ++i) {\n const line = chunk[ i ].trim()\n if (line.startsWith(this.comment)) continue\n const values = line.split(reDelimiter)\n\n if (j === 0) {\n this.table.columnNames = values\n } else if (line) {\n data.push(values)\n }\n ++j\n }\n })\n }\n}\n\nParserRegistry.add('csv', CsvParser)\n\nexport default CsvParser\n","/**\n * @file Json Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Parser, { ParserParameters } from './parser'\nimport Streamer from '../streamer/streamer';\n\nexport interface JsonParserParameters extends ParserParameters {\n string: boolean\n}\n\nclass JsonParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.string = defaults(p.string, false)\n\n this.json = {\n name: this.name,\n path: this.path,\n data: {}\n }\n }\n\n get type () { return 'json' }\n get __objName () { return 'json' }\n get isJson () { return true }\n\n _parse () {\n if (this.streamer.isBinary() || this.string) {\n this.json.data = JSON.parse(this.streamer.asText())\n } else {\n this.json.data = this.streamer.data\n }\n }\n}\n\nParserRegistry.add('json', JsonParser)\n\nexport default JsonParser\n","/**\n * @file Msgpack Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport Parser, { ParserParameters } from './parser'\n\nimport { decodeMsgpack } from '../../lib/mmtf.es6'\nimport Streamer from '../streamer/streamer';\n\nclass MsgpackParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.msgpack = {\n name: this.name,\n path: this.path,\n data: undefined\n }\n }\n\n get type () { return 'msgpack' }\n get __objName () { return 'msgpack' }\n get isBinary () { return true }\n\n _parse () {\n if (Debug) Log.time('MsgpackParser._parse ' + this.name)\n\n this.msgpack.data = decodeMsgpack(this.streamer.data)\n\n if (Debug) Log.timeEnd('MsgpackParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('msgpack', MsgpackParser)\n\nexport default MsgpackParser\n","/**\n * @file Netcdf Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport Parser, { ParserParameters } from './parser'\nimport NetcdfReader from '../utils/netcdf-reader'\nimport Streamer from '../streamer/streamer';\n\nclass NetcdfParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.netcdf = {\n name: this.name,\n path: this.path,\n data: undefined\n }\n }\n\n get type () { return 'netcdf' }\n get __objName () { return 'netcdf' }\n get isBinary () { return true }\n\n _parse () {\n if (Debug) Log.time('NetcdfParser._parse ' + this.name)\n\n this.netcdf.data = new NetcdfReader(this.streamer.data)\n\n if (Debug) Log.timeEnd('NetcdfParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('netcdf', NetcdfParser)\n\nexport default NetcdfParser\n","/**\n * @file Text Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport Parser, { ParserParameters } from './parser'\nimport Streamer from '../streamer/streamer';\n\nclass TextParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n super(streamer, params)\n\n this.text = {\n\n name: this.name,\n path: this.path,\n data: ''\n\n }\n }\n\n get type () { return 'text' }\n get __objName () { return 'text' }\n\n _parse () {\n this.text.data = this.streamer.asText()\n }\n}\n\nParserRegistry.add('txt', TextParser)\nParserRegistry.add('text', TextParser)\n\nexport default TextParser\n","/**\n * @file Parse Xml\n * @author Alexander Rose \n * @private\n */\n\n// https://github.com/segmentio/xml-parser\n// MIT license\n\nexport type XMLNodeAttributes = { [k: string]: any }\nexport interface XMLNode {\n name?: string\n content?: string\n attributes: XMLNodeAttributes\n children?: XMLNode[]\n}\n\nconst reStrip = /^['\"]|['\"]$/g\nconst reTag = /^<([\\w-:.]+)\\s*/\nconst reContent = /^([^<]*)/\nconst reAttr = /([\\w:-]+)\\s*=\\s*(\"[^\"]*\"|'[^']*'|\\w+)\\s*/\n\nfunction strip (val: string) {\n return val.replace(reStrip, '')\n}\n\nexport function parseXml (xml: string) {\n // trim and strip comments\n xml = xml.trim().replace(//g, '')\n\n return document()\n\n function document () {\n return {\n declaration: declaration(),\n root: tag()\n }\n }\n\n function declaration () {\n const m = match(/^<\\?xml\\s*/)\n if (!m) return\n\n // tag\n const node: XMLNode = {\n attributes: {}\n }\n\n // attributes\n while (!(eos() || is('?>'))) {\n const attr = attribute()\n if (!attr) return node\n node.attributes[attr.name] = attr.value\n }\n match(/\\?>\\s*/)\n return node\n }\n\n function tag () {\n const m = match(reTag)\n if (!m) return\n\n // name\n const node: XMLNode = {\n name: m[1],\n attributes: {},\n children: []\n }\n\n // attributes\n while (!(eos() || is('>') || is('?>') || is('/>'))) {\n const attr = attribute()\n if (!attr) return node\n node.attributes[attr.name] = attr.value\n }\n\n // self closing tag\n if (match(/^\\s*\\/>\\s*/)) {\n return node\n }\n match(/\\??>\\s*/)\n\n // content\n node.content = content()\n\n // children\n let child\n while ((child = tag())) {\n node.children!.push(child)\n }\n\n // closing\n match(/^<\\/[\\w-:.]+>\\s*/)\n return node\n }\n\n function content () {\n const m = match(reContent)\n if (m) return m[1]\n return ''\n }\n\n function attribute () {\n const m = match(reAttr)\n if (!m) return\n return { name: m[1], value: strip(m[2]) }\n }\n\n function match (re: RegExp) {\n const m = xml.match(re)\n if (!m) return\n xml = xml.slice(m[0].length)\n return m\n }\n\n function eos () {\n return xml.length === 0\n }\n\n function is (prefix: string) {\n return xml.indexOf(prefix) === 0\n }\n}\n","/**\n * @file Xml Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { defaults } from '../utils'\n// @ts-ignore: unused import XMLNode required for declaration only\nimport { parseXml, XMLNode } from '../utils/parse-xml'\nimport Parser, { ParserParameters } from './parser'\nimport Streamer from '../streamer/streamer';\n\nexport interface XmlParserParameters extends ParserParameters {\n useDomParser: boolean\n}\n\nclass XmlParser extends Parser {\n xml: {\n name: string\n path: string\n data: any\n }\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.useDomParser = defaults(p.useDomParser, false)\n\n this.xml = {\n name: this.name,\n path: this.path,\n data: {}\n }\n }\n\n get type () { return 'xml' }\n get __objName () { return 'xml' }\n get isXml () { return true }\n\n __xmlParser (xml: string) {\n return parseXml(xml)\n }\n\n __domParser (xml: string) {\n const domParser = new (window as any).DOMParser() as DOMParser\n return domParser.parseFromString(xml, 'text/xml')\n }\n\n _parse () {\n if (Debug) Log.time('XmlParser._parse ' + this.name)\n\n if (this.useDomParser) {\n if (this.streamer.data instanceof Document) { //TS conversion: stripped the window prefix from window.Document\n this.xml.data = this.streamer.data\n } else {\n this.xml.data = this.__domParser(this.streamer.asText())\n }\n } else {\n this.xml.data = this.__xmlParser(this.streamer.asText())\n }\n\n if (Debug) Log.timeEnd('XmlParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('xml', XmlParser)\n\nexport default XmlParser\n","/**\n * @file Validation\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Color } from 'three'\n\nimport { Debug, Log } from '../globals'\nimport { defaults } from '../utils'\nimport { ClashPicker } from '../utils/picker'\nimport { uniformArray3 } from '../math/array-utils'\nimport { guessElement } from '../structure/structure-utils'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Structure from '../structure/structure'\n\nfunction getNamedItem(a: NamedNodeMap, name: string) {\n const item = a.getNamedItem(name)\n return item !== null ? item.value : ''\n}\n\nfunction getSele (a: NamedNodeMap, atomname?: string, useAltcode = false) {\n const icode = getNamedItem(a, 'icode').trim()\n const chain = getNamedItem(a, 'chain').trim()\n const altcode = getNamedItem(a, 'altcode')\n let sele = getNamedItem(a, 'resnum')\n if (icode) sele += '^' + icode\n if (chain) sele += ':' + chain\n if (atomname) sele += '.' + atomname\n if (useAltcode && altcode.trim()) sele += '%' + altcode\n sele += '/' + (parseInt(getNamedItem(a, 'model')) - 1)\n return sele\n}\n\nfunction getResSele (a: NamedNodeMap) {\n const chain = getNamedItem(a, 'chain').trim()\n const rescode = getNamedItem(a, 'rescode')\n const resnum = getNamedItem(a, 'resnum')\n let sele = `[${rescode}]${resnum}`\n if (chain) sele += `:${chain}`\n return sele\n}\n\nfunction setBitDict (dict: { [k: string]: number }, key: string, bit: number) {\n if (dict[ key ] === undefined) {\n dict[ key ] = bit\n } else {\n dict[ key ] |= bit\n }\n}\n\nfunction hasAttrValue (attr: Attr|null, value: string) {\n return attr !== null && attr.value === value\n}\n\nfunction getAtomSele (ap: AtomProxy) {\n const icode = ap.inscode\n const chain = ap.chainname\n const atomname = ap.atomname\n const altcode = ap.altloc\n let sele = ap.resno + ''\n if (icode) sele += '^' + icode\n if (chain) sele += ':' + chain\n if (atomname) sele += '.' + atomname\n if (altcode) sele += '%' + altcode\n sele += '/' + ap.modelIndex\n return sele\n}\n\nfunction getProblemCount (clashDict: { [k: string]: { [k: string]: string } }, g: Element, ga: NamedNodeMap) {\n let geoProblemCount = 0\n\n const clashes = g.getElementsByTagName('clash')\n for (let j = 0, jl = clashes.length; j < jl; ++j) {\n if (clashDict[ getNamedItem(clashes[ j ].attributes, 'cid') ]) {\n geoProblemCount += 1\n break\n }\n }\n\n const angleOutliers = g.getElementsByTagName('angle-outlier')\n if (angleOutliers.length > 0) {\n geoProblemCount += 1\n }\n\n const bondOutliers = g.getElementsByTagName('bond-outlier')\n if (bondOutliers.length > 0) {\n geoProblemCount += 1\n }\n\n const planeOutliers = g.getElementsByTagName('plane-outlier')\n if (planeOutliers.length > 0) {\n geoProblemCount += 1\n }\n\n if (hasAttrValue(ga.getNamedItem('rota'), 'OUTLIER')) {\n geoProblemCount += 1\n }\n\n if (hasAttrValue(ga.getNamedItem('rama'), 'OUTLIER')) {\n geoProblemCount += 1\n }\n\n if (hasAttrValue(ga.getNamedItem('RNApucker'), 'outlier')) {\n geoProblemCount += 1\n }\n\n return geoProblemCount\n}\n\nclass Validation {\n rsrzDict: { [k: string]: number } = {}\n rsccDict: { [k: string]: number } = {}\n /**\n * Random Coil Index (RCI) - evaluates the proximity of residue structural\n * and dynamic properties to the properties of flexible random coil regions\n * from NMR chemical shifts.\n *\n * Mark V. Berjanskii and David S. Wishart (2005)\n * A Simple Method To Predict Protein Flexibility Using Secondary Chemical Shifts\n * J. Am. Chem. Soc., 2005, 127 (43), pp 14970–14971\n * http://pubs.acs.org/doi/abs/10.1021/ja054842f\n *\n * Mark V. Berjanskii and David S. Wishart (2008)\n * Application of the random coil index to studying protein flexibility.\n * J Biomol NMR. 2008 Jan;40(1):31-48. Epub 2007 Nov 6.\n * http://www.springerlink.com/content/2966482w10306126/\n */\n rciDict: { [k: string]: number } = {}\n clashDict: { [k: string]: { [k: string]: string } } = {}\n clashArray: { [k: string]: string }[] = []\n geoDict: { [k: string]: number } = {}\n geoAtomDict: { [k: string]: { [k: string]: number } } = {}\n atomDict: { [k: string]: boolean|number } = {}\n clashSele = 'NONE'\n\n constructor (readonly name: string, readonly path: string) {}\n\n get type () { return 'validation' }\n\n fromXml (xml: XMLDocument) {\n if (Debug) Log.time('Validation.fromXml')\n\n const rsrzDict = this.rsrzDict\n const rsccDict = this.rsccDict\n const rciDict = this.rciDict\n const clashDict = this.clashDict\n const clashArray = this.clashArray\n const geoDict = this.geoDict\n const geoAtomDict = this.geoAtomDict\n const atomDict = this.atomDict\n\n const entries = xml.getElementsByTagName('Entry')\n if (entries.length === 1) {\n const chemicalShiftLists = entries[0].getElementsByTagName('chemical_shift_list')\n if (chemicalShiftLists.length === 1) {\n const randomCoilIndices = chemicalShiftLists[0].getElementsByTagName('random_coil_index')\n for (let j = 0, jl = randomCoilIndices.length; j < jl; ++j) {\n const rcia = randomCoilIndices[ j ].attributes\n const sele = getResSele(rcia)\n rciDict[ sele ] = parseFloat(getNamedItem(rcia, 'value'))\n }\n }\n }\n\n const groups = xml.getElementsByTagName('ModelledSubgroup')\n\n const _clashDict: { [k: string]: { [k: string]: string } } = {}\n const clashList: string[] = []\n\n if (Debug) Log.time('Validation.fromXml#clashDict')\n\n for (let i = 0, il = groups.length; i < il; ++i) {\n const g = groups[ i ]\n const ga = g.attributes\n\n const sele = getSele(ga)\n if (ga.getNamedItem('rsrz') !== null) {\n rsrzDict[ sele ] = parseFloat(getNamedItem(ga, 'rsrz'))\n }\n if (ga.getNamedItem('rscc') !== null) {\n rsccDict[ sele ] = parseFloat(getNamedItem(ga, 'rscc'))\n }\n const seleAttr = xml.createAttribute('sele')\n seleAttr.value = sele\n ga.setNamedItem(seleAttr)\n\n const clashes = g.getElementsByTagName('clash')\n\n for (let j = 0, jl = clashes.length; j < jl; ++j) {\n const ca = clashes[ j ].attributes\n const atom = getNamedItem(ca, 'atom')\n\n if (guessElement(atom) !== 'H') {\n const cid = getNamedItem(ca, 'cid')\n const atomSele = getSele(ga, atom, true)\n atomDict[ atomSele ] = true\n\n if (_clashDict[ cid ] === undefined) {\n _clashDict[ cid ] = {\n sele1: atomSele,\n res1: sele\n }\n } else {\n const c = _clashDict[ cid ]\n if (c.res1 !== sele) {\n c.sele2 = atomSele\n c.res2 = sele\n clashList.push(c.res1, sele)\n clashDict[ cid ] = c\n clashArray.push(c)\n }\n }\n }\n }\n }\n\n if (Debug) Log.timeEnd('Validation.fromXml#clashDict')\n\n for (let i = 0, il = groups.length; i < il; ++i) {\n const g = groups[ i ]\n const ga = g.attributes\n\n const sele = getNamedItem(ga, 'sele')\n const isPolymer = getNamedItem(ga, 'seq') !== '.'\n\n if (isPolymer) {\n const geoProblemCount = getProblemCount(clashDict, g, ga)\n if (geoProblemCount > 0) {\n geoDict[ sele ] = geoProblemCount\n }\n } else {\n const clashes = g.getElementsByTagName('clash')\n const mogBondOutliers = g.getElementsByTagName('mog-bond-outlier')\n const mogAngleOutliers = g.getElementsByTagName('mog-angle-outlier')\n\n if (mogBondOutliers.length > 0 || mogAngleOutliers.length > 0 || clashes.length > 0) {\n const atomDict = {}\n geoAtomDict[ sele ] = atomDict\n\n for (let j = 0, jl = clashes.length; j < jl; ++j) {\n const ca = clashes[ j ].attributes\n if (clashDict[ getNamedItem(ca, 'cid') ]) {\n setBitDict(atomDict, getNamedItem(ca, 'atom'), 1)\n }\n }\n\n for (let j = 0, jl = mogBondOutliers.length; j < jl; ++j) {\n const mbo = mogBondOutliers[ j ].attributes\n getNamedItem(mbo, 'atoms').split(',').forEach(function (atomname) {\n setBitDict(atomDict, atomname, 2)\n })\n }\n\n for (let j = 0, jl = mogAngleOutliers.length; j < jl; ++j) {\n const mao = mogAngleOutliers[ j ].attributes\n getNamedItem(mao, 'atoms').split(',').forEach(function (atomname) {\n setBitDict(atomDict, atomname, 4)\n })\n }\n }\n }\n }\n\n this.clashSele = clashList.length ? clashList.join(' OR ') : 'NONE'\n\n if (Debug) Log.timeEnd('Validation.fromXml')\n }\n\n getClashData (params: { color: number|string|Color, structure: Structure }) {\n if (Debug) Log.time('Validation.getClashData')\n\n const p = params || {}\n\n const s = p.structure\n const atomSet = s.atomSet! // TODO\n const c = new Color(defaults(p.color, '#f0027f'))\n\n const ap1 = s.getAtomProxy()\n const ap2 = s.getAtomProxy()\n const vDir = new Vector3()\n const vPos1 = new Vector3()\n const vPos2 = new Vector3()\n\n const clashArray = this.clashArray\n const n = clashArray.length\n\n const position1 = new Float32Array(n * 3)\n const position2 = new Float32Array(n * 3)\n const color = uniformArray3(n, c.r, c.g, c.b) as Float32Array\n const radius = new Float32Array(n)\n const picking = new Float32Array(n)\n\n if (Debug) Log.time('Validation.getClashData#atomDict')\n\n const atomDict = this.atomDict\n\n s.eachAtom(function (ap) {\n const sele = getAtomSele(ap)\n if (atomDict[ sele ] === true) {\n atomDict[ sele ] = ap.index\n }\n })\n\n if (Debug) Log.timeEnd('Validation.getClashData#atomDict')\n\n let i = 0\n\n clashArray.forEach(function (c, idx) {\n ap1.index = atomDict[ c.sele1 ] as number // TODO\n ap2.index = atomDict[ c.sele2 ] as number // TODO\n\n if (ap1.index === undefined || ap2.index === undefined ||\n !atomSet.isSet(ap1.index, ap2.index)) return\n\n vDir.subVectors(ap2 as any, ap1 as any).setLength(ap1.vdw) // TODO\n vPos1.copy(ap1 as any).add(vDir) // TODO\n\n vDir.subVectors(ap1 as any, ap2 as any).setLength(ap2.vdw) // TODO\n vPos2.copy(ap2 as any).add(vDir) // TODO\n\n const dHalf = ap1.distanceTo(ap2) / 2\n const r1 = Math.sqrt(ap1.vdw * ap1.vdw - dHalf * dHalf)\n const r2 = Math.sqrt(ap2.vdw * ap2.vdw - dHalf * dHalf)\n\n vPos1.toArray(position1 as any, i * 3) // TODO\n vPos2.toArray(position2 as any, i * 3)\n radius[ i ] = (r1 + r2) / 2\n picking[ i ] = idx\n\n ++i\n })\n\n if (Debug) Log.timeEnd('Validation.getClashData')\n\n return {\n position1: position1.subarray(0, i * 3),\n position2: position2.subarray(0, i * 3),\n color: color.subarray(0, i * 3),\n color2: color.subarray(0, i * 3),\n radius: radius.subarray(0, i),\n picking: new ClashPicker(picking.subarray(0, i), this, s)\n }\n }\n}\n\nexport default Validation\n","\n// https://github.com/nodeca/pako\n// MIT License, Copyright (c) 2014 by Vitaly Puzrin\n\n\n// 'use strict';\n\n\n// var TYPED_OK = (typeof Uint8Array !== 'undefined') &&\n// (typeof Uint16Array !== 'undefined') &&\n// (typeof Int32Array !== 'undefined');\n\n\nfunction assign(obj /*from1, from2, from3, ...*/) {\n var sources = Array.prototype.slice.call(arguments, 1);\n while (sources.length) {\n var source = sources.shift();\n if (!source) { continue; }\n\n if (typeof source !== 'object') {\n throw new TypeError(source + 'must be non-object');\n }\n\n for (var p in source) {\n if (source.hasOwnProperty(p)) {\n obj[p] = source[p];\n }\n }\n }\n\n return obj;\n}\n\n\n// reduce buffer size, avoiding mem copy\nfunction shrinkBuf(buf, size) {\n if (buf.length === size) { return buf; }\n if (buf.subarray) { return buf.subarray(0, size); }\n buf.length = size;\n return buf;\n}\n\n\nfunction arraySet(dest, src, src_offs, len, dest_offs) {\n if (src.subarray && dest.subarray) {\n dest.set(src.subarray(src_offs, src_offs + len), dest_offs);\n return;\n }\n // Fallback to ordinary array\n for (var i = 0; i < len; i++) {\n dest[dest_offs + i] = src[src_offs + i];\n }\n}\n\n// Join array of chunks to single array.\nfunction flattenChunks(chunks) {\n var i, l, len, pos, chunk, result;\n\n // calculate data length\n len = 0;\n for (i = 0, l = chunks.length; i < l; i++) {\n len += chunks[i].length;\n }\n\n // join chunks\n result = new Uint8Array(len);\n pos = 0;\n for (i = 0, l = chunks.length; i < l; i++) {\n chunk = chunks[i];\n result.set(chunk, pos);\n pos += chunk.length;\n }\n\n return result;\n}\n\n// 'use strict';\n\n// Note: adler32 takes 12% for level 0 and 2% for level 6.\n// It doesn't worth to make additional optimizationa as in original.\n// Small size is preferable.\n\nfunction adler32(adler, buf, len, pos) {\n var s1 = (adler & 0xffff) |0,\n s2 = ((adler >>> 16) & 0xffff) |0,\n n = 0;\n\n while (len !== 0) {\n // Set limit ~ twice less than 5552, to keep\n // s2 in 31-bits, because we force signed ints.\n // in other case %= will fail.\n n = len > 2000 ? 2000 : len;\n len -= n;\n\n do {\n s1 = (s1 + buf[pos++]) |0;\n s2 = (s2 + s1) |0;\n } while (--n);\n\n s1 %= 65521;\n s2 %= 65521;\n }\n\n return (s1 | (s2 << 16)) |0;\n}\n\n// 'use strict';\n\n// Note: we can't get significant speed boost here.\n// So write code to minimize size - no pregenerated tables\n// and array tools dependencies.\n\n\n// Use ordinary array, since untyped makes no boost here\nfunction makeTable() {\n var c, table = [];\n\n for (var n = 0; n < 256; n++) {\n c = n;\n for (var k = 0; k < 8; k++) {\n c = ((c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));\n }\n table[n] = c;\n }\n\n return table;\n}\n\n// Create table on load. Just 255 signed longs. Not a problem.\nvar crcTable = makeTable();\n\n\nfunction crc32(crc, buf, len, pos) {\n var t = crcTable,\n end = pos + len;\n\n crc ^= -1;\n\n for (var i = pos; i < end; i++) {\n crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF];\n }\n\n return (crc ^ (-1)); // >>> 0;\n}\n\n// 'use strict';\n\n// See state defs from inflate.js\nvar BAD$1 = 30; /* got a data error -- remain here until reset */\nvar TYPE$1 = 12; /* i: waiting for type bits, including last-flag bit */\n\n/*\n Decode literal, length, and distance codes and write out the resulting\n literal and match bytes until either not enough input or output is\n available, an end-of-block is encountered, or a data error is encountered.\n When large enough input and output buffers are supplied to inflate(), for\n example, a 16K input buffer and a 64K output buffer, more than 95% of the\n inflate execution time is spent in this routine.\n\n Entry assumptions:\n\n state.mode === LEN\n strm.avail_in >= 6\n strm.avail_out >= 258\n start >= strm.avail_out\n state.bits < 8\n\n On return, state.mode is one of:\n\n LEN -- ran out of enough output space or enough available input\n TYPE -- reached end of block code, inflate() to interpret next block\n BAD -- error in block data\n\n Notes:\n\n - The maximum input bits used by a length/distance pair is 15 bits for the\n length code, 5 bits for the length extra, 15 bits for the distance code,\n and 13 bits for the distance extra. This totals 48 bits, or six bytes.\n Therefore if strm.avail_in >= 6, then there is enough input to avoid\n checking for available input while decoding.\n\n - The maximum bytes that a single length/distance pair can output is 258\n bytes, which is the maximum length that can be coded. inflate_fast()\n requires strm.avail_out >= 258 for each loop to avoid checking for\n output space.\n */\n// module.exports =\nfunction inflate_fast(strm, start) {\n var state;\n var _in; /* local strm.input */\n var last; /* have enough input while in < last */\n var _out; /* local strm.output */\n var beg; /* inflate()'s initial strm.output */\n var end; /* while out < end, enough space available */\n//#ifdef INFLATE_STRICT\n var dmax; /* maximum distance from zlib header */\n//#endif\n var wsize; /* window size or zero if not using window */\n var whave; /* valid bytes in the window */\n var wnext; /* window write index */\n // Use `s_window` instead `window`, avoid conflict with instrumentation tools\n var s_window; /* allocated sliding window, if wsize != 0 */\n var hold; /* local strm.hold */\n var bits; /* local strm.bits */\n var lcode; /* local strm.lencode */\n var dcode; /* local strm.distcode */\n var lmask; /* mask for first level of length codes */\n var dmask; /* mask for first level of distance codes */\n var here; /* retrieved table entry */\n var op; /* code bits, operation, extra bits, or */\n /* window position, window bytes to copy */\n var len; /* match length, unused bytes */\n var dist; /* match distance */\n var from; /* where to copy match from */\n var from_source;\n\n\n var input, output; // JS specific, because we have no pointers\n\n /* copy state to local variables */\n state = strm.state;\n //here = state.here;\n _in = strm.next_in;\n input = strm.input;\n last = _in + (strm.avail_in - 5);\n _out = strm.next_out;\n output = strm.output;\n beg = _out - (start - strm.avail_out);\n end = _out + (strm.avail_out - 257);\n//#ifdef INFLATE_STRICT\n dmax = state.dmax;\n//#endif\n wsize = state.wsize;\n whave = state.whave;\n wnext = state.wnext;\n s_window = state.window;\n hold = state.hold;\n bits = state.bits;\n lcode = state.lencode;\n dcode = state.distcode;\n lmask = (1 << state.lenbits) - 1;\n dmask = (1 << state.distbits) - 1;\n\n\n /* decode literals and length/distances until end-of-block or not enough\n input data or output space */\n\n top:\n do {\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n\n here = lcode[hold & lmask];\n\n dolen:\n for (;;) { // Goto emulation\n op = here >>> 24/*here.bits*/;\n hold >>>= op;\n bits -= op;\n op = (here >>> 16) & 0xff/*here.op*/;\n if (op === 0) { /* literal */\n //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n // \"inflate: literal '%c'\\n\" :\n // \"inflate: literal 0x%02x\\n\", here.val));\n output[_out++] = here & 0xffff/*here.val*/;\n }\n else if (op & 16) { /* length base */\n len = here & 0xffff/*here.val*/;\n op &= 15; /* number of extra bits */\n if (op) {\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n len += hold & ((1 << op) - 1);\n hold >>>= op;\n bits -= op;\n }\n //Tracevv((stderr, \"inflate: length %u\\n\", len));\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n here = dcode[hold & dmask];\n\n dodist:\n for (;;) { // goto emulation\n op = here >>> 24/*here.bits*/;\n hold >>>= op;\n bits -= op;\n op = (here >>> 16) & 0xff/*here.op*/;\n\n if (op & 16) { /* distance base */\n dist = here & 0xffff/*here.val*/;\n op &= 15; /* number of extra bits */\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n }\n dist += hold & ((1 << op) - 1);\n//#ifdef INFLATE_STRICT\n if (dist > dmax) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD$1;\n break top;\n }\n//#endif\n hold >>>= op;\n bits -= op;\n //Tracevv((stderr, \"inflate: distance %u\\n\", dist));\n op = _out - beg; /* max distance in output */\n if (dist > op) { /* see if copy from window */\n op = dist - op; /* distance back in window */\n if (op > whave) {\n if (state.sane) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD$1;\n break top;\n }\n\n// (!) This block is disabled in zlib defailts,\n// don't enable it for binary compatibility\n//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n// if (len <= op - whave) {\n// do {\n// output[_out++] = 0;\n// } while (--len);\n// continue top;\n// }\n// len -= op - whave;\n// do {\n// output[_out++] = 0;\n// } while (--op > whave);\n// if (op === 0) {\n// from = _out - dist;\n// do {\n// output[_out++] = output[from++];\n// } while (--len);\n// continue top;\n// }\n//#endif\n }\n from = 0; // window index\n from_source = s_window;\n if (wnext === 0) { /* very common case */\n from += wsize - op;\n if (op < len) { /* some from window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n else if (wnext < op) { /* wrap around window */\n from += wsize + wnext - op;\n op -= wnext;\n if (op < len) { /* some from end of window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = 0;\n if (wnext < len) { /* some from start of window */\n op = wnext;\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n }\n else { /* contiguous in window */\n from += wnext - op;\n if (op < len) { /* some from window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n while (len > 2) {\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n len -= 3;\n }\n if (len) {\n output[_out++] = from_source[from++];\n if (len > 1) {\n output[_out++] = from_source[from++];\n }\n }\n }\n else {\n from = _out - dist; /* copy direct from output */\n do { /* minimum length is three */\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n len -= 3;\n } while (len > 2);\n if (len) {\n output[_out++] = output[from++];\n if (len > 1) {\n output[_out++] = output[from++];\n }\n }\n }\n }\n else if ((op & 64) === 0) { /* 2nd level distance code */\n here = dcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n continue dodist;\n }\n else {\n strm.msg = 'invalid distance code';\n state.mode = BAD$1;\n break top;\n }\n\n break; // need to emulate goto via \"continue\"\n }\n }\n else if ((op & 64) === 0) { /* 2nd level length code */\n here = lcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n continue dolen;\n }\n else if (op & 32) { /* end-of-block */\n //Tracevv((stderr, \"inflate: end of block\\n\"));\n state.mode = TYPE$1;\n break top;\n }\n else {\n strm.msg = 'invalid literal/length code';\n state.mode = BAD$1;\n break top;\n }\n\n break; // need to emulate goto via \"continue\"\n }\n } while (_in < last && _out < end);\n\n /* return unused bytes (on entry, bits < 8, so in won't go too far back) */\n len = bits >> 3;\n _in -= len;\n bits -= len << 3;\n hold &= (1 << bits) - 1;\n\n /* update state and return */\n strm.next_in = _in;\n strm.next_out = _out;\n strm.avail_in = (_in < last ? 5 + (last - _in) : 5 - (_in - last));\n strm.avail_out = (_out < end ? 257 + (end - _out) : 257 - (_out - end));\n state.hold = hold;\n state.bits = bits;\n return;\n};\n\n// 'use strict';\n\n\n// var utils = require('../utils/common');\n\nvar MAXBITS = 15;\nvar ENOUGH_LENS$1 = 852;\nvar ENOUGH_DISTS$1 = 592;\n//var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);\n\nvar CODES$1 = 0;\nvar LENS$1 = 1;\nvar DISTS$1 = 2;\n\nvar lbase = [ /* Length codes 257..285 base */\n 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,\n 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0\n];\n\nvar lext = [ /* Length codes 257..285 extra */\n 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,\n 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78\n];\n\nvar dbase = [ /* Distance codes 0..29 base */\n 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,\n 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,\n 8193, 12289, 16385, 24577, 0, 0\n];\n\nvar dext = [ /* Distance codes 0..29 extra */\n 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,\n 23, 23, 24, 24, 25, 25, 26, 26, 27, 27,\n 28, 28, 29, 29, 64, 64\n];\n\n// module.exports =\nfunction inflate_table(type, lens, lens_index, codes, table, table_index, work, opts)\n{\n var bits = opts.bits;\n //here = opts.here; /* table entry for duplication */\n\n var len = 0; /* a code's length in bits */\n var sym = 0; /* index of code symbols */\n var min = 0, max = 0; /* minimum and maximum code lengths */\n var root = 0; /* number of index bits for root table */\n var curr = 0; /* number of index bits for current table */\n var drop = 0; /* code bits to drop for sub-table */\n var left = 0; /* number of prefix codes available */\n var used = 0; /* code entries in table used */\n var huff = 0; /* Huffman code */\n var incr; /* for incrementing code, index */\n var fill; /* index for replicating entries */\n var low; /* low bits for current root entry */\n var mask; /* mask for low root bits */\n var next; /* next available space in table */\n var base = null; /* base value table to use */\n var base_index = 0;\n// var shoextra; /* extra bits table to use */\n var end; /* use base and extra for symbol > end */\n var count = new Uint16Array(MAXBITS + 1); //[MAXBITS+1]; /* number of codes of each length */\n var offs = new Uint16Array(MAXBITS + 1); //[MAXBITS+1]; /* offsets in table for each length */\n var extra = null;\n var extra_index = 0;\n\n var here_bits, here_op, here_val;\n\n /*\n Process a set of code lengths to create a canonical Huffman code. The\n code lengths are lens[0..codes-1]. Each length corresponds to the\n symbols 0..codes-1. The Huffman code is generated by first sorting the\n symbols by length from short to long, and retaining the symbol order\n for codes with equal lengths. Then the code starts with all zero bits\n for the first code of the shortest length, and the codes are integer\n increments for the same length, and zeros are appended as the length\n increases. For the deflate format, these bits are stored backwards\n from their more natural integer increment ordering, and so when the\n decoding tables are built in the large loop below, the integer codes\n are incremented backwards.\n\n This routine assumes, but does not check, that all of the entries in\n lens[] are in the range 0..MAXBITS. The caller must assure this.\n 1..MAXBITS is interpreted as that code length. zero means that that\n symbol does not occur in this code.\n\n The codes are sorted by computing a count of codes for each length,\n creating from that a table of starting indices for each length in the\n sorted table, and then entering the symbols in order in the sorted\n table. The sorted table is work[], with that space being provided by\n the caller.\n\n The length counts are used for other purposes as well, i.e. finding\n the minimum and maximum length codes, determining if there are any\n codes at all, checking for a valid set of lengths, and looking ahead\n at length counts to determine sub-table sizes when building the\n decoding tables.\n */\n\n /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */\n for (len = 0; len <= MAXBITS; len++) {\n count[len] = 0;\n }\n for (sym = 0; sym < codes; sym++) {\n count[lens[lens_index + sym]]++;\n }\n\n /* bound code lengths, force root to be within code lengths */\n root = bits;\n for (max = MAXBITS; max >= 1; max--) {\n if (count[max] !== 0) { break; }\n }\n if (root > max) {\n root = max;\n }\n if (max === 0) { /* no symbols to code at all */\n //table.op[opts.table_index] = 64; //here.op = (var char)64; /* invalid code marker */\n //table.bits[opts.table_index] = 1; //here.bits = (var char)1;\n //table.val[opts.table_index++] = 0; //here.val = (var short)0;\n table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n\n //table.op[opts.table_index] = 64;\n //table.bits[opts.table_index] = 1;\n //table.val[opts.table_index++] = 0;\n table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n opts.bits = 1;\n return 0; /* no symbols, but wait for decoding to report error */\n }\n for (min = 1; min < max; min++) {\n if (count[min] !== 0) { break; }\n }\n if (root < min) {\n root = min;\n }\n\n /* check for an over-subscribed or incomplete set of lengths */\n left = 1;\n for (len = 1; len <= MAXBITS; len++) {\n left <<= 1;\n left -= count[len];\n if (left < 0) {\n return -1;\n } /* over-subscribed */\n }\n if (left > 0 && (type === CODES$1 || max !== 1)) {\n return -1; /* incomplete set */\n }\n\n /* generate offsets into symbol table for each length for sorting */\n offs[1] = 0;\n for (len = 1; len < MAXBITS; len++) {\n offs[len + 1] = offs[len] + count[len];\n }\n\n /* sort symbols by length, by symbol order within each length */\n for (sym = 0; sym < codes; sym++) {\n if (lens[lens_index + sym] !== 0) {\n work[offs[lens[lens_index + sym]]++] = sym;\n }\n }\n\n /*\n Create and fill in decoding tables. In this loop, the table being\n filled is at next and has curr index bits. The code being used is huff\n with length len. That code is converted to an index by dropping drop\n bits off of the bottom. For codes where len is less than drop + curr,\n those top drop + curr - len bits are incremented through all values to\n fill the table with replicated entries.\n\n root is the number of index bits for the root table. When len exceeds\n root, sub-tables are created pointed to by the root entry with an index\n of the low root bits of huff. This is saved in low to check for when a\n new sub-table should be started. drop is zero when the root table is\n being filled, and drop is root when sub-tables are being filled.\n\n When a new sub-table is needed, it is necessary to look ahead in the\n code lengths to determine what size sub-table is needed. The length\n counts are used for this, and so count[] is decremented as codes are\n entered in the tables.\n\n used keeps track of how many table entries have been allocated from the\n provided *table space. It is checked for LENS and DIST tables against\n the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in\n the initial root table size constants. See the comments in inftrees.h\n for more information.\n\n sym increments through all symbols, and the loop terminates when\n all codes of length max, i.e. all codes, have been processed. This\n routine permits incomplete codes, so another loop after this one fills\n in the rest of the decoding tables with invalid code markers.\n */\n\n /* set up for code type */\n // poor man optimization - use if-else instead of switch,\n // to avoid deopts in old v8\n if (type === CODES$1) {\n base = extra = work; /* dummy value--not used */\n end = 19;\n\n } else if (type === LENS$1) {\n base = lbase;\n base_index -= 257;\n extra = lext;\n extra_index -= 257;\n end = 256;\n\n } else { /* DISTS */\n base = dbase;\n extra = dext;\n end = -1;\n }\n\n /* initialize opts for loop */\n huff = 0; /* starting code */\n sym = 0; /* starting code symbol */\n len = min; /* starting code length */\n next = table_index; /* current table to fill in */\n curr = root; /* current table index bits */\n drop = 0; /* current bits to drop from code for index */\n low = -1; /* trigger new sub-table when len > root */\n used = 1 << root; /* use root table entries */\n mask = used - 1; /* mask for comparing low */\n\n /* check available table space */\n if ((type === LENS$1 && used > ENOUGH_LENS$1) ||\n (type === DISTS$1 && used > ENOUGH_DISTS$1)) {\n return 1;\n }\n\n var i = 0;\n /* process all codes and make table entries */\n for (;;) {\n i++;\n /* create table entry */\n here_bits = len - drop;\n if (work[sym] < end) {\n here_op = 0;\n here_val = work[sym];\n }\n else if (work[sym] > end) {\n here_op = extra[extra_index + work[sym]];\n here_val = base[base_index + work[sym]];\n }\n else {\n here_op = 32 + 64; /* end of block */\n here_val = 0;\n }\n\n /* replicate for those indices with low len bits equal to huff */\n incr = 1 << (len - drop);\n fill = 1 << curr;\n min = fill; /* save offset to next table */\n do {\n fill -= incr;\n table[next + (huff >> drop) + fill] = (here_bits << 24) | (here_op << 16) | here_val |0;\n } while (fill !== 0);\n\n /* backwards increment the len-bit code huff */\n incr = 1 << (len - 1);\n while (huff & incr) {\n incr >>= 1;\n }\n if (incr !== 0) {\n huff &= incr - 1;\n huff += incr;\n } else {\n huff = 0;\n }\n\n /* go to next symbol, update count, len */\n sym++;\n if (--count[len] === 0) {\n if (len === max) { break; }\n len = lens[lens_index + work[sym]];\n }\n\n /* create new sub-table if needed */\n if (len > root && (huff & mask) !== low) {\n /* if first time, transition to sub-tables */\n if (drop === 0) {\n drop = root;\n }\n\n /* increment past last table */\n next += min; /* here min is 1 << curr */\n\n /* determine length of next table */\n curr = len - drop;\n left = 1 << curr;\n while (curr + drop < max) {\n left -= count[curr + drop];\n if (left <= 0) { break; }\n curr++;\n left <<= 1;\n }\n\n /* check for enough space */\n used += 1 << curr;\n if ((type === LENS$1 && used > ENOUGH_LENS$1) ||\n (type === DISTS$1 && used > ENOUGH_DISTS$1)) {\n return 1;\n }\n\n /* point entry in root table to sub-table */\n low = huff & mask;\n /*table.op[low] = curr;\n table.bits[low] = root;\n table.val[low] = next - opts.table_index;*/\n table[low] = (root << 24) | (curr << 16) | (next - table_index) |0;\n }\n }\n\n /* fill in remaining table entry if code is incomplete (guaranteed to have\n at most one remaining entry, since if the code is incomplete, the\n maximum code length that was allowed to get this far is one bit) */\n if (huff !== 0) {\n //table.op[next + huff] = 64; /* invalid code marker */\n //table.bits[next + huff] = len - drop;\n //table.val[next + huff] = 0;\n table[next + huff] = ((len - drop) << 24) | (64 << 16) |0;\n }\n\n /* set return parameters */\n //opts.table_index += used;\n opts.bits = root;\n return 0;\n};\n\n// 'use strict';\n\n\n// var utils = require('../utils/common');\n// var adler32 = require('./adler32');\n// var crc32 = require('./crc32');\n// var inflate_fast = require('./inffast');\n// var inflate_table = require('./inftrees');\n\nvar CODES = 0;\nvar LENS = 1;\nvar DISTS = 2;\n\n/* Public constants ==========================================================*/\n/* ===========================================================================*/\n\n\n/* Allowed flush values; see deflate() and inflate() below for details */\n//var Z_NO_FLUSH = 0;\n//var Z_PARTIAL_FLUSH = 1;\n//var Z_SYNC_FLUSH = 2;\n//var Z_FULL_FLUSH = 3;\nvar Z_FINISH = 4;\nvar Z_BLOCK = 5;\nvar Z_TREES = 6;\n\n\n/* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\nvar Z_OK = 0;\nvar Z_STREAM_END = 1;\nvar Z_NEED_DICT = 2;\n//var Z_ERRNO = -1;\nvar Z_STREAM_ERROR = -2;\nvar Z_DATA_ERROR = -3;\nvar Z_MEM_ERROR = -4;\nvar Z_BUF_ERROR = -5;\n//var Z_VERSION_ERROR = -6;\n\n/* The deflate compression method */\nvar Z_DEFLATED = 8;\n\n\n/* STATES ====================================================================*/\n/* ===========================================================================*/\n\n\nvar HEAD = 1; /* i: waiting for magic header */\nvar FLAGS = 2; /* i: waiting for method and flags (gzip) */\nvar TIME = 3; /* i: waiting for modification time (gzip) */\nvar OS = 4; /* i: waiting for extra flags and operating system (gzip) */\nvar EXLEN = 5; /* i: waiting for extra length (gzip) */\nvar EXTRA = 6; /* i: waiting for extra bytes (gzip) */\nvar NAME = 7; /* i: waiting for end of file name (gzip) */\nvar COMMENT = 8; /* i: waiting for end of comment (gzip) */\nvar HCRC = 9; /* i: waiting for header crc (gzip) */\nvar DICTID = 10; /* i: waiting for dictionary check value */\nvar DICT = 11; /* waiting for inflateSetDictionary() call */\nvar TYPE = 12; /* i: waiting for type bits, including last-flag bit */\nvar TYPEDO = 13; /* i: same, but skip check to exit inflate on new block */\nvar STORED = 14; /* i: waiting for stored size (length and complement) */\nvar COPY_ = 15; /* i/o: same as COPY below, but only first time in */\nvar COPY = 16; /* i/o: waiting for input or output to copy stored block */\nvar TABLE = 17; /* i: waiting for dynamic block table lengths */\nvar LENLENS = 18; /* i: waiting for code length code lengths */\nvar CODELENS = 19; /* i: waiting for length/lit and distance code lengths */\nvar LEN_ = 20; /* i: same as LEN below, but only first time in */\nvar LEN = 21; /* i: waiting for length/lit/eob code */\nvar LENEXT = 22; /* i: waiting for length extra bits */\nvar DIST = 23; /* i: waiting for distance code */\nvar DISTEXT = 24; /* i: waiting for distance extra bits */\nvar MATCH = 25; /* o: waiting for output space to copy string */\nvar LIT = 26; /* o: waiting for output space to write literal */\nvar CHECK = 27; /* i: waiting for 32-bit check value */\nvar LENGTH = 28; /* i: waiting for 32-bit length (gzip) */\nvar DONE = 29; /* finished check, done -- remain here until reset */\nvar BAD = 30; /* got a data error -- remain here until reset */\nvar MEM = 31; /* got an inflate() memory error -- remain here until reset */\nvar SYNC = 32; /* looking for synchronization bytes to restart inflate() */\n\n/* ===========================================================================*/\n\n\n\nvar ENOUGH_LENS = 852;\nvar ENOUGH_DISTS = 592;\nfunction zswap32(q) {\n return (((q >>> 24) & 0xff) +\n ((q >>> 8) & 0xff00) +\n ((q & 0xff00) << 8) +\n ((q & 0xff) << 24));\n}\n\n\nfunction InflateState() {\n this.mode = 0; /* current inflate mode */\n this.last = false; /* true if processing last block */\n this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip */\n this.havedict = false; /* true if dictionary provided */\n this.flags = 0; /* gzip header method and flags (0 if zlib) */\n this.dmax = 0; /* zlib header max distance (INFLATE_STRICT) */\n this.check = 0; /* protected copy of check value */\n this.total = 0; /* protected copy of output count */\n // TODO: may be {}\n this.head = null; /* where to save gzip header information */\n\n /* sliding window */\n this.wbits = 0; /* log base 2 of requested window size */\n this.wsize = 0; /* window size or zero if not using window */\n this.whave = 0; /* valid bytes in the window */\n this.wnext = 0; /* window write index */\n this.window = null; /* allocated sliding window, if needed */\n\n /* bit accumulator */\n this.hold = 0; /* input bit accumulator */\n this.bits = 0; /* number of bits in \"in\" */\n\n /* for string and stored block copying */\n this.length = 0; /* literal or length of data to copy */\n this.offset = 0; /* distance back to copy string from */\n\n /* for table and code decoding */\n this.extra = 0; /* extra bits needed */\n\n /* fixed and dynamic code tables */\n this.lencode = null; /* starting table for length/literal codes */\n this.distcode = null; /* starting table for distance codes */\n this.lenbits = 0; /* index bits for lencode */\n this.distbits = 0; /* index bits for distcode */\n\n /* dynamic table building */\n this.ncode = 0; /* number of code length code lengths */\n this.nlen = 0; /* number of length code lengths */\n this.ndist = 0; /* number of distance code lengths */\n this.have = 0; /* number of code lengths in lens[] */\n this.next = null; /* next available space in codes[] */\n\n this.lens = new Uint16Array(320); /* temporary storage for code lengths */\n this.work = new Uint16Array(288); /* work area for code table building */\n\n /*\n because we don't have pointers in js, we use lencode and distcode directly\n as buffers so we don't need codes\n */\n //this.codes = new Buf32(ENOUGH); /* space for code tables */\n this.lendyn = null; /* dynamic table for length/literal codes (JS specific) */\n this.distdyn = null; /* dynamic table for distance codes (JS specific) */\n this.sane = 0; /* if false, allow invalid distance too far */\n this.back = 0; /* bits back of last unprocessed length/lit */\n this.was = 0; /* initial length of match */\n}\n\nfunction inflateResetKeep(strm) {\n var state;\n\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n strm.total_in = strm.total_out = state.total = 0;\n strm.msg = ''; /*Z_NULL*/\n if (state.wrap) { /* to support ill-conceived Java test suite */\n strm.adler = state.wrap & 1;\n }\n state.mode = HEAD;\n state.last = 0;\n state.havedict = 0;\n state.dmax = 32768;\n state.head = null/*Z_NULL*/;\n state.hold = 0;\n state.bits = 0;\n //state.lencode = state.distcode = state.next = state.codes;\n state.lencode = state.lendyn = new Int32Array(ENOUGH_LENS);\n state.distcode = state.distdyn = new Int32Array(ENOUGH_DISTS);\n\n state.sane = 1;\n state.back = -1;\n //Tracev((stderr, \"inflate: reset\\n\"));\n return Z_OK;\n}\n\nfunction inflateReset(strm) {\n var state;\n\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n state.wsize = 0;\n state.whave = 0;\n state.wnext = 0;\n return inflateResetKeep(strm);\n\n}\n\nfunction inflateReset2(strm, windowBits) {\n var wrap;\n var state;\n\n /* get the state */\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n\n /* extract wrap request from windowBits parameter */\n if (windowBits < 0) {\n wrap = 0;\n windowBits = -windowBits;\n }\n else {\n wrap = (windowBits >> 4) + 1;\n if (windowBits < 48) {\n windowBits &= 15;\n }\n }\n\n /* set number of window bits, free window if different */\n if (windowBits && (windowBits < 8 || windowBits > 15)) {\n return Z_STREAM_ERROR;\n }\n if (state.window !== null && state.wbits !== windowBits) {\n state.window = null;\n }\n\n /* update state and reset the rest of it */\n state.wrap = wrap;\n state.wbits = windowBits;\n return inflateReset(strm);\n}\n\nfunction inflateInit2(strm, windowBits) {\n var ret;\n var state;\n\n if (!strm) { return Z_STREAM_ERROR; }\n //strm.msg = Z_NULL; /* in case we return an error */\n\n state = new InflateState();\n\n //if (state === Z_NULL) return Z_MEM_ERROR;\n //Tracev((stderr, \"inflate: allocated\\n\"));\n strm.state = state;\n state.window = null/*Z_NULL*/;\n ret = inflateReset2(strm, windowBits);\n if (ret !== Z_OK) {\n strm.state = null/*Z_NULL*/;\n }\n return ret;\n}\n\n/*\n Return state with length and distance decoding tables and index sizes set to\n fixed code decoding. Normally this returns fixed tables from inffixed.h.\n If BUILDFIXED is defined, then instead this routine builds the tables the\n first time it's called, and returns those tables the first time and\n thereafter. This reduces the size of the code by about 2K bytes, in\n exchange for a little execution time. However, BUILDFIXED should not be\n used for threaded applications, since the rewriting of the tables and virgin\n may not be thread-safe.\n */\nvar virgin = true;\n\nvar lenfix;\nvar distfix;\n// We have no pointers in JS, so keep tables separate\n\nfunction fixedtables(state) {\n /* build fixed huffman tables if first call (may not be thread safe) */\n if (virgin) {\n var sym;\n\n lenfix = new Int32Array(512);\n distfix = new Int32Array(32);\n\n /* literal/length table */\n sym = 0;\n while (sym < 144) { state.lens[sym++] = 8; }\n while (sym < 256) { state.lens[sym++] = 9; }\n while (sym < 280) { state.lens[sym++] = 7; }\n while (sym < 288) { state.lens[sym++] = 8; }\n\n inflate_table(LENS, state.lens, 0, 288, lenfix, 0, state.work, { bits: 9 });\n\n /* distance table */\n sym = 0;\n while (sym < 32) { state.lens[sym++] = 5; }\n\n inflate_table(DISTS, state.lens, 0, 32, distfix, 0, state.work, { bits: 5 });\n\n /* do this just once */\n virgin = false;\n }\n\n state.lencode = lenfix;\n state.lenbits = 9;\n state.distcode = distfix;\n state.distbits = 5;\n}\n\n\n/*\n Update the window with the last wsize (normally 32K) bytes written before\n returning. If window does not exist yet, create it. This is only called\n when a window is already in use, or when output has been written during this\n inflate call, but the end of the deflate stream has not been reached yet.\n It is also called to create a window for dictionary data when a dictionary\n is loaded.\n\n Providing output buffers larger than 32K to inflate() should provide a speed\n advantage, since only the last 32K of output is copied to the sliding window\n upon return from inflate(), and since all distances after the first 32K of\n output will fall in the output data, making match copies simpler and faster.\n The advantage may be dependent on the size of the processor's data caches.\n */\nfunction updatewindow(strm, src, end, copy) {\n var dist;\n var state = strm.state;\n\n /* if it hasn't been done already, allocate space for the window */\n if (state.window === null) {\n state.wsize = 1 << state.wbits;\n state.wnext = 0;\n state.whave = 0;\n\n state.window = new Uint8Array(state.wsize);\n }\n\n /* copy state->wsize or less output bytes into the circular window */\n if (copy >= state.wsize) {\n arraySet(state.window, src, end - state.wsize, state.wsize, 0);\n state.wnext = 0;\n state.whave = state.wsize;\n }\n else {\n dist = state.wsize - state.wnext;\n if (dist > copy) {\n dist = copy;\n }\n //zmemcpy(state->window + state->wnext, end - copy, dist);\n arraySet(state.window, src, end - copy, dist, state.wnext);\n copy -= dist;\n if (copy) {\n //zmemcpy(state->window, end - copy, copy);\n arraySet(state.window, src, end - copy, copy, 0);\n state.wnext = copy;\n state.whave = state.wsize;\n }\n else {\n state.wnext += dist;\n if (state.wnext === state.wsize) { state.wnext = 0; }\n if (state.whave < state.wsize) { state.whave += dist; }\n }\n }\n return 0;\n}\n\nfunction inflate(strm, flush) {\n var state;\n var input, output; // input/output buffers\n var next; /* next input INDEX */\n var put; /* next output INDEX */\n var have, left; /* available input and output */\n var hold; /* bit buffer */\n var bits; /* bits in bit buffer */\n var _in, _out; /* save starting available input and output */\n var copy; /* number of stored or match bytes to copy */\n var from; /* where to copy match bytes from */\n var from_source;\n var here = 0; /* current decoding table entry */\n var here_bits, here_op, here_val; // paked \"here\" denormalized (JS specific)\n //var last; /* parent table entry */\n var last_bits, last_op, last_val; // paked \"last\" denormalized (JS specific)\n var len; /* length to copy for repeats, bits to drop */\n var ret; /* return code */\n var hbuf = new Uint8Array(4); /* buffer for gzip header crc calculation */\n var opts;\n\n var n; // temporary var for NEED_BITS\n\n var order = /* permutation of code lengths */\n [ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ];\n\n\n if (!strm || !strm.state || !strm.output ||\n (!strm.input && strm.avail_in !== 0)) {\n return Z_STREAM_ERROR;\n }\n\n state = strm.state;\n if (state.mode === TYPE) { state.mode = TYPEDO; } /* skip check */\n\n\n //--- LOAD() ---\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n //---\n\n _in = have;\n _out = left;\n ret = Z_OK;\n\n inf_leave: // goto emulation\n for (;;) {\n switch (state.mode) {\n case HEAD:\n if (state.wrap === 0) {\n state.mode = TYPEDO;\n break;\n }\n //=== NEEDBITS(16);\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if ((state.wrap & 2) && hold === 0x8b1f) { /* gzip header */\n state.check = 0/*crc32(0L, Z_NULL, 0)*/;\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = FLAGS;\n break;\n }\n state.flags = 0; /* expect zlib header */\n if (state.head) {\n state.head.done = false;\n }\n if (!(state.wrap & 1) || /* check if zlib header allowed */\n (((hold & 0xff)/*BITS(8)*/ << 8) + (hold >> 8)) % 31) {\n strm.msg = 'incorrect header check';\n state.mode = BAD;\n break;\n }\n if ((hold & 0x0f)/*BITS(4)*/ !== Z_DEFLATED) {\n strm.msg = 'unknown compression method';\n state.mode = BAD;\n break;\n }\n //--- DROPBITS(4) ---//\n hold >>>= 4;\n bits -= 4;\n //---//\n len = (hold & 0x0f)/*BITS(4)*/ + 8;\n if (state.wbits === 0) {\n state.wbits = len;\n }\n else if (len > state.wbits) {\n strm.msg = 'invalid window size';\n state.mode = BAD;\n break;\n }\n state.dmax = 1 << len;\n //Tracev((stderr, \"inflate: zlib header ok\\n\"));\n strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n state.mode = hold & 0x200 ? DICTID : TYPE;\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n break;\n case FLAGS:\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.flags = hold;\n if ((state.flags & 0xff) !== Z_DEFLATED) {\n strm.msg = 'unknown compression method';\n state.mode = BAD;\n break;\n }\n if (state.flags & 0xe000) {\n strm.msg = 'unknown header flags set';\n state.mode = BAD;\n break;\n }\n if (state.head) {\n state.head.text = ((hold >> 8) & 1);\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = TIME;\n /* falls through */\n case TIME:\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (state.head) {\n state.head.time = hold;\n }\n if (state.flags & 0x0200) {\n //=== CRC4(state.check, hold)\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n hbuf[2] = (hold >>> 16) & 0xff;\n hbuf[3] = (hold >>> 24) & 0xff;\n state.check = crc32(state.check, hbuf, 4, 0);\n //===\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = OS;\n /* falls through */\n case OS:\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (state.head) {\n state.head.xflags = (hold & 0xff);\n state.head.os = (hold >> 8);\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = EXLEN;\n /* falls through */\n case EXLEN:\n if (state.flags & 0x0400) {\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.length = hold;\n if (state.head) {\n state.head.extra_len = hold;\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n }\n else if (state.head) {\n state.head.extra = null/*Z_NULL*/;\n }\n state.mode = EXTRA;\n /* falls through */\n case EXTRA:\n if (state.flags & 0x0400) {\n copy = state.length;\n if (copy > have) { copy = have; }\n if (copy) {\n if (state.head) {\n len = state.head.extra_len - state.length;\n if (!state.head.extra) {\n // Use untyped array for more conveniend processing later\n state.head.extra = new Array(state.head.extra_len);\n }\n arraySet(\n state.head.extra,\n input,\n next,\n // extra field is limited to 65536 bytes\n // - no need for additional size check\n copy,\n /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/\n len\n );\n //zmemcpy(state.head.extra + len, next,\n // len + copy > state.head.extra_max ?\n // state.head.extra_max - len : copy);\n }\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n state.length -= copy;\n }\n if (state.length) { break inf_leave; }\n }\n state.length = 0;\n state.mode = NAME;\n /* falls through */\n case NAME:\n if (state.flags & 0x0800) {\n if (have === 0) { break inf_leave; }\n copy = 0;\n do {\n // TODO: 2 or 1 bytes?\n len = input[next + copy++];\n /* use constant limit because in js we should not preallocate memory */\n if (state.head && len &&\n (state.length < 65536 /*state.head.name_max*/)) {\n state.head.name += String.fromCharCode(len);\n }\n } while (len && copy < have);\n\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) { break inf_leave; }\n }\n else if (state.head) {\n state.head.name = null;\n }\n state.length = 0;\n state.mode = COMMENT;\n /* falls through */\n case COMMENT:\n if (state.flags & 0x1000) {\n if (have === 0) { break inf_leave; }\n copy = 0;\n do {\n len = input[next + copy++];\n /* use constant limit because in js we should not preallocate memory */\n if (state.head && len &&\n (state.length < 65536 /*state.head.comm_max*/)) {\n state.head.comment += String.fromCharCode(len);\n }\n } while (len && copy < have);\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) { break inf_leave; }\n }\n else if (state.head) {\n state.head.comment = null;\n }\n state.mode = HCRC;\n /* falls through */\n case HCRC:\n if (state.flags & 0x0200) {\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (hold !== (state.check & 0xffff)) {\n strm.msg = 'header crc mismatch';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n }\n if (state.head) {\n state.head.hcrc = ((state.flags >> 9) & 1);\n state.head.done = true;\n }\n strm.adler = state.check = 0;\n state.mode = TYPE;\n break;\n case DICTID:\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n strm.adler = state.check = zswap32(hold);\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = DICT;\n /* falls through */\n case DICT:\n if (state.havedict === 0) {\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n return Z_NEED_DICT;\n }\n strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n state.mode = TYPE;\n /* falls through */\n case TYPE:\n if (flush === Z_BLOCK || flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case TYPEDO:\n if (state.last) {\n //--- BYTEBITS() ---//\n hold >>>= bits & 7;\n bits -= bits & 7;\n //---//\n state.mode = CHECK;\n break;\n }\n //=== NEEDBITS(3); */\n while (bits < 3) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.last = (hold & 0x01)/*BITS(1)*/;\n //--- DROPBITS(1) ---//\n hold >>>= 1;\n bits -= 1;\n //---//\n\n switch ((hold & 0x03)/*BITS(2)*/) {\n case 0: /* stored block */\n //Tracev((stderr, \"inflate: stored block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = STORED;\n break;\n case 1: /* fixed block */\n fixedtables(state);\n //Tracev((stderr, \"inflate: fixed codes block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = LEN_; /* decode codes */\n if (flush === Z_TREES) {\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n break inf_leave;\n }\n break;\n case 2: /* dynamic block */\n //Tracev((stderr, \"inflate: dynamic codes block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = TABLE;\n break;\n case 3:\n strm.msg = 'invalid block type';\n state.mode = BAD;\n }\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n break;\n case STORED:\n //--- BYTEBITS() ---// /* go to byte boundary */\n hold >>>= bits & 7;\n bits -= bits & 7;\n //---//\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if ((hold & 0xffff) !== ((hold >>> 16) ^ 0xffff)) {\n strm.msg = 'invalid stored block lengths';\n state.mode = BAD;\n break;\n }\n state.length = hold & 0xffff;\n //Tracev((stderr, \"inflate: stored length %u\\n\",\n // state.length));\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = COPY_;\n if (flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case COPY_:\n state.mode = COPY;\n /* falls through */\n case COPY:\n copy = state.length;\n if (copy) {\n if (copy > have) { copy = have; }\n if (copy > left) { copy = left; }\n if (copy === 0) { break inf_leave; }\n //--- zmemcpy(put, next, copy); ---\n arraySet(output, input, next, copy, put);\n //---//\n have -= copy;\n next += copy;\n left -= copy;\n put += copy;\n state.length -= copy;\n break;\n }\n //Tracev((stderr, \"inflate: stored end\\n\"));\n state.mode = TYPE;\n break;\n case TABLE:\n //=== NEEDBITS(14); */\n while (bits < 14) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.nlen = (hold & 0x1f)/*BITS(5)*/ + 257;\n //--- DROPBITS(5) ---//\n hold >>>= 5;\n bits -= 5;\n //---//\n state.ndist = (hold & 0x1f)/*BITS(5)*/ + 1;\n //--- DROPBITS(5) ---//\n hold >>>= 5;\n bits -= 5;\n //---//\n state.ncode = (hold & 0x0f)/*BITS(4)*/ + 4;\n //--- DROPBITS(4) ---//\n hold >>>= 4;\n bits -= 4;\n //---//\n//#ifndef PKZIP_BUG_WORKAROUND\n if (state.nlen > 286 || state.ndist > 30) {\n strm.msg = 'too many length or distance symbols';\n state.mode = BAD;\n break;\n }\n//#endif\n //Tracev((stderr, \"inflate: table sizes ok\\n\"));\n state.have = 0;\n state.mode = LENLENS;\n /* falls through */\n case LENLENS:\n while (state.have < state.ncode) {\n //=== NEEDBITS(3);\n while (bits < 3) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.lens[order[state.have++]] = (hold & 0x07);//BITS(3);\n //--- DROPBITS(3) ---//\n hold >>>= 3;\n bits -= 3;\n //---//\n }\n while (state.have < 19) {\n state.lens[order[state.have++]] = 0;\n }\n // We have separate tables & no pointers. 2 commented lines below not needed.\n //state.next = state.codes;\n //state.lencode = state.next;\n // Switch to use dynamic table\n state.lencode = state.lendyn;\n state.lenbits = 7;\n\n opts = { bits: state.lenbits };\n ret = inflate_table(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts);\n state.lenbits = opts.bits;\n\n if (ret) {\n strm.msg = 'invalid code lengths set';\n state.mode = BAD;\n break;\n }\n //Tracev((stderr, \"inflate: code lengths ok\\n\"));\n state.have = 0;\n state.mode = CODELENS;\n /* falls through */\n case CODELENS:\n while (state.have < state.nlen + state.ndist) {\n for (;;) {\n here = state.lencode[hold & ((1 << state.lenbits) - 1)];/*BITS(state.lenbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if (here_val < 16) {\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.lens[state.have++] = here_val;\n }\n else {\n if (here_val === 16) {\n //=== NEEDBITS(here.bits + 2);\n n = here_bits + 2;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n if (state.have === 0) {\n strm.msg = 'invalid bit length repeat';\n state.mode = BAD;\n break;\n }\n len = state.lens[state.have - 1];\n copy = 3 + (hold & 0x03);//BITS(2);\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n }\n else if (here_val === 17) {\n //=== NEEDBITS(here.bits + 3);\n n = here_bits + 3;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n len = 0;\n copy = 3 + (hold & 0x07);//BITS(3);\n //--- DROPBITS(3) ---//\n hold >>>= 3;\n bits -= 3;\n //---//\n }\n else {\n //=== NEEDBITS(here.bits + 7);\n n = here_bits + 7;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n len = 0;\n copy = 11 + (hold & 0x7f);//BITS(7);\n //--- DROPBITS(7) ---//\n hold >>>= 7;\n bits -= 7;\n //---//\n }\n if (state.have + copy > state.nlen + state.ndist) {\n strm.msg = 'invalid bit length repeat';\n state.mode = BAD;\n break;\n }\n while (copy--) {\n state.lens[state.have++] = len;\n }\n }\n }\n\n /* handle error breaks in while */\n if (state.mode === BAD) { break; }\n\n /* check for end-of-block code (better have one) */\n if (state.lens[256] === 0) {\n strm.msg = 'invalid code -- missing end-of-block';\n state.mode = BAD;\n break;\n }\n\n /* build code tables -- note: do not change the lenbits or distbits\n values here (9 and 6) without reading the comments in inftrees.h\n concerning the ENOUGH constants, which depend on those values */\n state.lenbits = 9;\n\n opts = { bits: state.lenbits };\n ret = inflate_table(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts);\n // We have separate tables & no pointers. 2 commented lines below not needed.\n // state.next_index = opts.table_index;\n state.lenbits = opts.bits;\n // state.lencode = state.next;\n\n if (ret) {\n strm.msg = 'invalid literal/lengths set';\n state.mode = BAD;\n break;\n }\n\n state.distbits = 6;\n //state.distcode.copy(state.codes);\n // Switch to use dynamic table\n state.distcode = state.distdyn;\n opts = { bits: state.distbits };\n ret = inflate_table(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts);\n // We have separate tables & no pointers. 2 commented lines below not needed.\n // state.next_index = opts.table_index;\n state.distbits = opts.bits;\n // state.distcode = state.next;\n\n if (ret) {\n strm.msg = 'invalid distances set';\n state.mode = BAD;\n break;\n }\n //Tracev((stderr, 'inflate: codes ok\\n'));\n state.mode = LEN_;\n if (flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case LEN_:\n state.mode = LEN;\n /* falls through */\n case LEN:\n if (have >= 6 && left >= 258) {\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n inflate_fast(strm, _out);\n //--- LOAD() ---\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n //---\n\n if (state.mode === TYPE) {\n state.back = -1;\n }\n break;\n }\n state.back = 0;\n for (;;) {\n here = state.lencode[hold & ((1 << state.lenbits) - 1)]; /*BITS(state.lenbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if (here_bits <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if (here_op && (here_op & 0xf0) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (;;) {\n here = state.lencode[last_val +\n ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((last_bits + here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n //--- DROPBITS(last.bits) ---//\n hold >>>= last_bits;\n bits -= last_bits;\n //---//\n state.back += last_bits;\n }\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.back += here_bits;\n state.length = here_val;\n if (here_op === 0) {\n //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n // \"inflate: literal '%c'\\n\" :\n // \"inflate: literal 0x%02x\\n\", here.val));\n state.mode = LIT;\n break;\n }\n if (here_op & 32) {\n //Tracevv((stderr, \"inflate: end of block\\n\"));\n state.back = -1;\n state.mode = TYPE;\n break;\n }\n if (here_op & 64) {\n strm.msg = 'invalid literal/length code';\n state.mode = BAD;\n break;\n }\n state.extra = here_op & 15;\n state.mode = LENEXT;\n /* falls through */\n case LENEXT:\n if (state.extra) {\n //=== NEEDBITS(state.extra);\n n = state.extra;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.length += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n //--- DROPBITS(state.extra) ---//\n hold >>>= state.extra;\n bits -= state.extra;\n //---//\n state.back += state.extra;\n }\n //Tracevv((stderr, \"inflate: length %u\\n\", state.length));\n state.was = state.length;\n state.mode = DIST;\n /* falls through */\n case DIST:\n for (;;) {\n here = state.distcode[hold & ((1 << state.distbits) - 1)];/*BITS(state.distbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if ((here_op & 0xf0) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (;;) {\n here = state.distcode[last_val +\n ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((last_bits + here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n //--- DROPBITS(last.bits) ---//\n hold >>>= last_bits;\n bits -= last_bits;\n //---//\n state.back += last_bits;\n }\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.back += here_bits;\n if (here_op & 64) {\n strm.msg = 'invalid distance code';\n state.mode = BAD;\n break;\n }\n state.offset = here_val;\n state.extra = (here_op) & 15;\n state.mode = DISTEXT;\n /* falls through */\n case DISTEXT:\n if (state.extra) {\n //=== NEEDBITS(state.extra);\n n = state.extra;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.offset += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n //--- DROPBITS(state.extra) ---//\n hold >>>= state.extra;\n bits -= state.extra;\n //---//\n state.back += state.extra;\n }\n//#ifdef INFLATE_STRICT\n if (state.offset > state.dmax) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break;\n }\n//#endif\n //Tracevv((stderr, \"inflate: distance %u\\n\", state.offset));\n state.mode = MATCH;\n /* falls through */\n case MATCH:\n if (left === 0) { break inf_leave; }\n copy = _out - left;\n if (state.offset > copy) { /* copy from window */\n copy = state.offset - copy;\n if (copy > state.whave) {\n if (state.sane) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break;\n }\n// (!) This block is disabled in zlib defailts,\n// don't enable it for binary compatibility\n//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n// Trace((stderr, \"inflate.c too far\\n\"));\n// copy -= state.whave;\n// if (copy > state.length) { copy = state.length; }\n// if (copy > left) { copy = left; }\n// left -= copy;\n// state.length -= copy;\n// do {\n// output[put++] = 0;\n// } while (--copy);\n// if (state.length === 0) { state.mode = LEN; }\n// break;\n//#endif\n }\n if (copy > state.wnext) {\n copy -= state.wnext;\n from = state.wsize - copy;\n }\n else {\n from = state.wnext - copy;\n }\n if (copy > state.length) { copy = state.length; }\n from_source = state.window;\n }\n else { /* copy from output */\n from_source = output;\n from = put - state.offset;\n copy = state.length;\n }\n if (copy > left) { copy = left; }\n left -= copy;\n state.length -= copy;\n do {\n output[put++] = from_source[from++];\n } while (--copy);\n if (state.length === 0) { state.mode = LEN; }\n break;\n case LIT:\n if (left === 0) { break inf_leave; }\n output[put++] = state.length;\n left--;\n state.mode = LEN;\n break;\n case CHECK:\n if (state.wrap) {\n //=== NEEDBITS(32);\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n // Use '|' insdead of '+' to make sure that result is signed\n hold |= input[next++] << bits;\n bits += 8;\n }\n //===//\n _out -= left;\n strm.total_out += _out;\n state.total += _out;\n if (_out) {\n strm.adler = state.check =\n /*UPDATE(state.check, put - _out, _out);*/\n (state.flags ? crc32(state.check, output, _out, put - _out) : adler32(state.check, output, _out, put - _out));\n\n }\n _out = left;\n // NB: crc32 stored as signed 32-bit int, zswap32 returns signed too\n if ((state.flags ? hold : zswap32(hold)) !== state.check) {\n strm.msg = 'incorrect data check';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n //Tracev((stderr, \"inflate: check matches trailer\\n\"));\n }\n state.mode = LENGTH;\n /* falls through */\n case LENGTH:\n if (state.wrap && state.flags) {\n //=== NEEDBITS(32);\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (hold !== (state.total & 0xffffffff)) {\n strm.msg = 'incorrect length check';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n //Tracev((stderr, \"inflate: length matches trailer\\n\"));\n }\n state.mode = DONE;\n /* falls through */\n case DONE:\n ret = Z_STREAM_END;\n break inf_leave;\n case BAD:\n ret = Z_DATA_ERROR;\n break inf_leave;\n case MEM:\n return Z_MEM_ERROR;\n case SYNC:\n /* falls through */\n default:\n return Z_STREAM_ERROR;\n }\n }\n\n // inf_leave <- here is real place for \"goto inf_leave\", emulated via \"break inf_leave\"\n\n /*\n Return from inflate(), updating the total counts and the check value.\n If there was no progress during the inflate() call, return a buffer\n error. Call updatewindow() to create and/or update the window state.\n Note: a memory error from inflate() is non-recoverable.\n */\n\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n\n if (state.wsize || (_out !== strm.avail_out && state.mode < BAD &&\n (state.mode < CHECK || flush !== Z_FINISH))) {\n if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) {\n state.mode = MEM;\n return Z_MEM_ERROR;\n }\n }\n _in -= strm.avail_in;\n _out -= strm.avail_out;\n strm.total_in += _in;\n strm.total_out += _out;\n state.total += _out;\n if (state.wrap && _out) {\n strm.adler = state.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/\n (state.flags ? crc32(state.check, output, _out, strm.next_out - _out) : adler32(state.check, output, _out, strm.next_out - _out));\n }\n strm.data_type = state.bits + (state.last ? 64 : 0) +\n (state.mode === TYPE ? 128 : 0) +\n (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);\n if (((_in === 0 && _out === 0) || flush === Z_FINISH) && ret === Z_OK) {\n ret = Z_BUF_ERROR;\n }\n return ret;\n}\n\nfunction inflateEnd(strm) {\n\n if (!strm || !strm.state /*|| strm->zfree == (free_func)0*/) {\n return Z_STREAM_ERROR;\n }\n\n var state = strm.state;\n if (state.window) {\n state.window = null;\n }\n strm.state = null;\n return Z_OK;\n}\n\nfunction inflateGetHeader(strm, head) {\n var state;\n\n /* check state */\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n if ((state.wrap & 2) === 0) { return Z_STREAM_ERROR; }\n\n /* save header structure */\n state.head = head;\n head.done = false;\n return Z_OK;\n}\n\nfunction inflateSetDictionary(strm, dictionary) {\n var dictLength = dictionary.length;\n\n var state;\n var dictid;\n var ret;\n\n /* check state */\n if (!strm /* == Z_NULL */ || !strm.state /* == Z_NULL */) { return Z_STREAM_ERROR; }\n state = strm.state;\n\n if (state.wrap !== 0 && state.mode !== DICT) {\n return Z_STREAM_ERROR;\n }\n\n /* check for correct dictionary identifier */\n if (state.mode === DICT) {\n dictid = 1; /* adler32(0, null, 0)*/\n /* dictid = adler32(dictid, dictionary, dictLength); */\n dictid = adler32(dictid, dictionary, dictLength, 0);\n if (dictid !== state.check) {\n return Z_DATA_ERROR;\n }\n }\n /* copy dictionary to window using updatewindow(), which will amend the\n existing dictionary if appropriate */\n ret = updatewindow(strm, dictionary, dictLength, dictLength);\n if (ret) {\n state.mode = MEM;\n return Z_MEM_ERROR;\n }\n state.havedict = 1;\n // Tracev((stderr, \"inflate: dictionary set\\n\"));\n return Z_OK;\n}\n\n// String encode/decode helpers\n// 'use strict';\n\n\n// var utils = require('./common');\n\n\n// Quick check if we can use fast array to bin string conversion\n//\n// - apply(Array) can fail on Android 2.2\n// - apply(Uint8Array) can fail on iOS 5.1 Safary\n//\nvar STR_APPLY_OK = true;\nvar STR_APPLY_UIA_OK = true;\n\ntry { String.fromCharCode.apply(null, [ 0 ]); } catch (__) { STR_APPLY_OK = false; }\ntry { String.fromCharCode.apply(null, new Uint8Array(1)); } catch (__) { STR_APPLY_UIA_OK = false; }\n\n\n// Table with utf8 lengths (calculated by first byte of sequence)\n// Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS,\n// because max possible codepoint is 0x10ffff\nvar _utf8len = new Uint8Array(256);\nfor (var q = 0; q < 256; q++) {\n _utf8len[q] = (q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1);\n}\n_utf8len[254] = _utf8len[254] = 1; // Invalid sequence start\n\n\n// convert string to array (typed, when possible)\nfunction string2buf(str) {\n var buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;\n\n // count binary size\n for (m_pos = 0; m_pos < str_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n m_pos++;\n }\n }\n buf_len += c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4;\n }\n\n // allocate buffer\n buf = new Uint8Array(buf_len);\n\n // convert\n for (i = 0, m_pos = 0; i < buf_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n m_pos++;\n }\n }\n if (c < 0x80) {\n /* one byte */\n buf[i++] = c;\n } else if (c < 0x800) {\n /* two bytes */\n buf[i++] = 0xC0 | (c >>> 6);\n buf[i++] = 0x80 | (c & 0x3f);\n } else if (c < 0x10000) {\n /* three bytes */\n buf[i++] = 0xE0 | (c >>> 12);\n buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n buf[i++] = 0x80 | (c & 0x3f);\n } else {\n /* four bytes */\n buf[i++] = 0xf0 | (c >>> 18);\n buf[i++] = 0x80 | (c >>> 12 & 0x3f);\n buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n buf[i++] = 0x80 | (c & 0x3f);\n }\n }\n\n return buf;\n}\n\n// Helper (used in 2 places)\nfunction _buf2binstring(buf, len) {\n // use fallback for big arrays to avoid stack overflow\n if (len < 65537) {\n if ((buf.subarray && STR_APPLY_UIA_OK) || (!buf.subarray && STR_APPLY_OK)) {\n return String.fromCharCode.apply(null, shrinkBuf(buf, len));\n }\n }\n\n var result = '';\n for (var i = 0; i < len; i++) {\n result += String.fromCharCode(buf[i]);\n }\n return result;\n}\n\n\n// Convert binary string (typed, when possible)\nfunction binstring2buf(str) {\n var buf = new Uint8Array(str.length);\n for (var i = 0, len = buf.length; i < len; i++) {\n buf[i] = str.charCodeAt(i);\n }\n return buf;\n}\n\n\n// convert array to string\nfunction buf2string(buf, max) {\n var i, out, c, c_len;\n var len = max || buf.length;\n\n // Reserve max possible length (2 words per char)\n // NB: by unknown reasons, Array is significantly faster for\n // String.fromCharCode.apply than Uint16Array.\n var utf16buf = new Array(len * 2);\n\n for (out = 0, i = 0; i < len;) {\n c = buf[i++];\n // quick process ascii\n if (c < 0x80) { utf16buf[out++] = c; continue; }\n\n c_len = _utf8len[c];\n // skip 5 & 6 byte codes\n if (c_len > 4) { utf16buf[out++] = 0xfffd; i += c_len - 1; continue; }\n\n // apply mask on first byte\n c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07;\n // join the rest\n while (c_len > 1 && i < len) {\n c = (c << 6) | (buf[i++] & 0x3f);\n c_len--;\n }\n\n // terminated by end of string?\n if (c_len > 1) { utf16buf[out++] = 0xfffd; continue; }\n\n if (c < 0x10000) {\n utf16buf[out++] = c;\n } else {\n c -= 0x10000;\n utf16buf[out++] = 0xd800 | ((c >> 10) & 0x3ff);\n utf16buf[out++] = 0xdc00 | (c & 0x3ff);\n }\n }\n\n return _buf2binstring(utf16buf, out);\n}\n\n\n// Calculate max possible position in utf8 buffer,\n// that will not break sequence. If that's not possible\n// - (very small limits) return max size as is.\n//\n// buf[] - utf8 bytes array\n// max - length limit (mandatory);\nfunction utf8border(buf, max) {\n var pos;\n\n max = max || buf.length;\n if (max > buf.length) { max = buf.length; }\n\n // go back from last position, until start of sequence found\n pos = max - 1;\n while (pos >= 0 && (buf[pos] & 0xC0) === 0x80) { pos--; }\n\n // Fuckup - very small and broken sequence,\n // return max, because we should return something anyway.\n if (pos < 0) { return max; }\n\n // If we came to start of buffer - that means vuffer is too small,\n // return max too.\n if (pos === 0) { return max; }\n\n return (pos + _utf8len[buf[pos]] > max) ? pos : max;\n}\n\n/* Allowed flush values; see deflate() and inflate() below for details */\nvar Z_NO_FLUSH = 0;\nvar Z_SYNC_FLUSH = 2;\nvar Z_FINISH$1 = 4;\n/* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\nvar Z_OK$1 = 0;\nvar Z_STREAM_END$1 = 1;\nvar Z_NEED_DICT$1 = 2;\n//export var Z_MEM_ERROR = -4;\nvar Z_BUF_ERROR$1 = -5;\n\n// 'use strict';\n\nvar messages = {\n 2: 'need dictionary', /* Z_NEED_DICT 2 */\n 1: 'stream end', /* Z_STREAM_END 1 */\n 0: '', /* Z_OK 0 */\n '-1': 'file error', /* Z_ERRNO (-1) */\n '-2': 'stream error', /* Z_STREAM_ERROR (-2) */\n '-3': 'data error', /* Z_DATA_ERROR (-3) */\n '-4': 'insufficient memory', /* Z_MEM_ERROR (-4) */\n '-5': 'buffer error', /* Z_BUF_ERROR (-5) */\n '-6': 'incompatible version' /* Z_VERSION_ERROR (-6) */\n};\n\n// 'use strict';\n\n\nfunction ZStream() {\n /* next input byte */\n this.input = null; // JS specific, because we have no pointers\n this.next_in = 0;\n /* number of bytes available at input */\n this.avail_in = 0;\n /* total number of input bytes read so far */\n this.total_in = 0;\n /* next output byte should be put there */\n this.output = null; // JS specific, because we have no pointers\n this.next_out = 0;\n /* remaining free space at output */\n this.avail_out = 0;\n /* total number of bytes output so far */\n this.total_out = 0;\n /* last error message, NULL if no error */\n this.msg = ''/*Z_NULL*/;\n /* not visible by applications */\n this.state = null;\n /* best guess about the data type: binary or text */\n this.data_type = 2/*Z_UNKNOWN*/;\n /* adler32 value of the uncompressed data */\n this.adler = 0;\n}\n\n// 'use strict';\n\n\nfunction GZheader() {\n /* true if compressed data believed to be text */\n this.text = 0;\n /* modification time */\n this.time = 0;\n /* extra flags (not used when writing a gzip file) */\n this.xflags = 0;\n /* operating system */\n this.os = 0;\n /* pointer to extra field or Z_NULL if none */\n this.extra = null;\n /* extra field length (valid if extra != Z_NULL) */\n this.extra_len = 0; // Actually, we don't need it in JS,\n // but leave for few code modifications\n\n //\n // Setup limits is not necessary because in js we should not preallocate memory\n // for inflate use constant limit in 65536 bytes\n //\n\n /* space at extra (only when reading header) */\n // this.extra_max = 0;\n /* pointer to zero-terminated file name or Z_NULL */\n this.name = '';\n /* space at name (only when reading header) */\n // this.name_max = 0;\n /* pointer to zero-terminated comment or Z_NULL */\n this.comment = '';\n /* space at comment (only when reading header) */\n // this.comm_max = 0;\n /* true if there was or will be a header crc */\n this.hcrc = 0;\n /* true when done reading gzip header (not used when writing a gzip file) */\n this.done = false;\n}\n\n// 'use strict';\n\n\n// var zlib_inflate = require('./zlib/inflate');\n// var utils = require('./utils/common');\n// var strings = require('./utils/strings');\n// var c = require('./zlib/constants');\n// var msg = require('./zlib/messages');\n// var ZStream = require('./zlib/zstream');\n// var GZheader = require('./zlib/gzheader');\n\nvar toString = Object.prototype.toString;\n\n/**\n * class Inflate\n *\n * Generic JS-style wrapper for zlib calls. If you don't need\n * streaming behaviour - use more simple functions: [[inflate]]\n * and [[inflateRaw]].\n **/\n\n/* internal\n * inflate.chunks -> Array\n *\n * Chunks of output data, if [[Inflate#onData]] not overriden.\n **/\n\n/**\n * Inflate.result -> Uint8Array|Array|String\n *\n * Uncompressed result, generated by default [[Inflate#onData]]\n * and [[Inflate#onEnd]] handlers. Filled after you push last chunk\n * (call [[Inflate#push]] with `Z_FINISH` / `true` param) or if you\n * push a chunk with explicit flush (call [[Inflate#push]] with\n * `Z_SYNC_FLUSH` param).\n **/\n\n/**\n * Inflate.err -> Number\n *\n * Error code after inflate finished. 0 (Z_OK) on success.\n * Should be checked if broken data possible.\n **/\n\n/**\n * Inflate.msg -> String\n *\n * Error message, if [[Inflate.err]] != 0\n **/\n\n\n/**\n * new Inflate(options)\n * - options (Object): zlib inflate options.\n *\n * Creates new inflator instance with specified params. Throws exception\n * on bad params. Supported options:\n *\n * - `windowBits`\n * - `dictionary`\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information on these.\n *\n * Additional options, for internal needs:\n *\n * - `chunkSize` - size of generated data chunks (16K by default)\n * - `raw` (Boolean) - do raw inflate\n * - `to` (String) - if equal to 'string', then result will be converted\n * from utf8 to utf16 (javascript) string. When string output requested,\n * chunk length can differ from `chunkSize`, depending on content.\n *\n * By default, when no options set, autodetect deflate/gzip data format via\n * wrapper header.\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , chunk1 = Uint8Array([1,2,3,4,5,6,7,8,9])\n * , chunk2 = Uint8Array([10,11,12,13,14,15,16,17,18,19]);\n *\n * var inflate = new pako.Inflate({ level: 3});\n *\n * inflate.push(chunk1, false);\n * inflate.push(chunk2, true); // true -> last chunk\n *\n * if (inflate.err) { throw new Error(inflate.err); }\n *\n * console.log(inflate.result);\n * ```\n **/\nfunction Inflate(options) {\n if (!(this instanceof Inflate)) return new Inflate(options);\n\n this.options = assign({\n chunkSize: 16384,\n windowBits: 0,\n to: ''\n }, options || {});\n\n var opt = this.options;\n\n // Force window size for `raw` data, if not set directly,\n // because we have no header for autodetect.\n if (opt.raw && (opt.windowBits >= 0) && (opt.windowBits < 16)) {\n opt.windowBits = -opt.windowBits;\n if (opt.windowBits === 0) { opt.windowBits = -15; }\n }\n\n // If `windowBits` not defined (and mode not raw) - set autodetect flag for gzip/deflate\n if ((opt.windowBits >= 0) && (opt.windowBits < 16) &&\n !(options && options.windowBits)) {\n opt.windowBits += 32;\n }\n\n // Gzip header has no info about windows size, we can do autodetect only\n // for deflate. So, if window size not set, force it to max when gzip possible\n if ((opt.windowBits > 15) && (opt.windowBits < 48)) {\n // bit 3 (16) -> gzipped data\n // bit 4 (32) -> autodetect gzip/deflate\n if ((opt.windowBits & 15) === 0) {\n opt.windowBits |= 15;\n }\n }\n\n this.err = 0; // error code, if happens (0 = Z_OK)\n this.msg = ''; // error message\n this.ended = false; // used to avoid multiple onEnd() calls\n this.chunks = []; // chunks of compressed data\n\n this.strm = new ZStream();\n this.strm.avail_out = 0;\n\n var status = inflateInit2(\n this.strm,\n opt.windowBits\n );\n\n if (status !== Z_OK$1) {\n throw new Error(messages[status]);\n }\n\n this.header = new GZheader();\n\n inflateGetHeader(this.strm, this.header);\n}\n\n/**\n * Inflate#push(data[, mode]) -> Boolean\n * - data (Uint8Array|Array|ArrayBuffer|String): input data\n * - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.\n * See constants. Skipped or `false` means Z_NO_FLUSH, `true` meansh Z_FINISH.\n *\n * Sends input data to inflate pipe, generating [[Inflate#onData]] calls with\n * new output chunks. Returns `true` on success. The last data block must have\n * mode Z_FINISH (or `true`). That will flush internal pending buffers and call\n * [[Inflate#onEnd]]. For interim explicit flushes (without ending the stream) you\n * can use mode Z_SYNC_FLUSH, keeping the decompression context.\n *\n * On fail call [[Inflate#onEnd]] with error code and return false.\n *\n * We strongly recommend to use `Uint8Array` on input for best speed (output\n * format is detected automatically). Also, don't skip last param and always\n * use the same type in your code (boolean or number). That will improve JS speed.\n *\n * For regular `Array`-s make sure all elements are [0..255].\n *\n * ##### Example\n *\n * ```javascript\n * push(chunk, false); // push one of data chunks\n * ...\n * push(chunk, true); // push last chunk\n * ```\n **/\nInflate.prototype.push = function (data, mode) {\n var strm = this.strm;\n var chunkSize = this.options.chunkSize;\n var dictionary = this.options.dictionary;\n var status, _mode;\n var next_out_utf8, tail, utf8str;\n var dict;\n\n // Flag to properly process Z_BUF_ERROR on testing inflate call\n // when we check that all output data was flushed.\n var allowBufError = false;\n\n if (this.ended) { return false; }\n _mode = (mode === ~~mode) ? mode : ((mode === true) ? Z_FINISH$1 : Z_NO_FLUSH);\n\n // Convert data if needed\n if (typeof data === 'string') {\n // Only binary strings can be decompressed on practice\n strm.input = binstring2buf(data);\n } else if (toString.call(data) === '[object ArrayBuffer]') {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\n\n do {\n if (strm.avail_out === 0) {\n strm.output = new Uint8Array(chunkSize);\n strm.next_out = 0;\n strm.avail_out = chunkSize;\n }\n\n status = inflate(strm, Z_NO_FLUSH); /* no bad return value */\n\n if (status === Z_NEED_DICT$1 && dictionary) {\n // Convert data if needed\n if (typeof dictionary === 'string') {\n dict = string2buf(dictionary);\n } else if (toString.call(dictionary) === '[object ArrayBuffer]') {\n dict = new Uint8Array(dictionary);\n } else {\n dict = dictionary;\n }\n\n status = inflateSetDictionary(this.strm, dict);\n\n }\n\n if (status === Z_BUF_ERROR$1 && allowBufError === true) {\n status = Z_OK$1;\n allowBufError = false;\n }\n\n if (status !== Z_STREAM_END$1 && status !== Z_OK$1) {\n this.onEnd(status);\n this.ended = true;\n return false;\n }\n\n if (strm.next_out) {\n if (strm.avail_out === 0 || status === Z_STREAM_END$1 || (strm.avail_in === 0 && (_mode === Z_FINISH$1 || _mode === Z_SYNC_FLUSH))) {\n\n if (this.options.to === 'string') {\n\n next_out_utf8 = utf8border(strm.output, strm.next_out);\n\n tail = strm.next_out - next_out_utf8;\n utf8str = buf2string(strm.output, next_out_utf8);\n\n // move tail\n strm.next_out = tail;\n strm.avail_out = chunkSize - tail;\n if (tail) { arraySet(strm.output, strm.output, next_out_utf8, tail, 0); }\n\n this.onData(utf8str);\n\n } else {\n this.onData(shrinkBuf(strm.output, strm.next_out));\n }\n }\n }\n\n // When no more input data, we should check that internal inflate buffers\n // are flushed. The only way to do it when avail_out = 0 - run one more\n // inflate pass. But if output data not exists, inflate return Z_BUF_ERROR.\n // Here we set flag to process this error properly.\n //\n // NOTE. Deflate does not return error in this case and does not needs such\n // logic.\n if (strm.avail_in === 0 && strm.avail_out === 0) {\n allowBufError = true;\n }\n\n } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== Z_STREAM_END$1);\n\n if (status === Z_STREAM_END$1) {\n _mode = Z_FINISH$1;\n }\n\n // Finalize on the last chunk.\n if (_mode === Z_FINISH$1) {\n status = inflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return status === Z_OK$1;\n }\n\n // callback interim results if Z_SYNC_FLUSH.\n if (_mode === Z_SYNC_FLUSH) {\n this.onEnd(Z_OK$1);\n strm.avail_out = 0;\n return true;\n }\n\n return true;\n};\n\n\n/**\n * Inflate#onData(chunk) -> Void\n * - chunk (Uint8Array|Array|String): ouput data. Type of array depends\n * on js engine support. When string output requested, each chunk\n * will be string.\n *\n * By default, stores data blocks in `chunks[]` property and glue\n * those in `onEnd`. Override this handler, if you need another behaviour.\n **/\nInflate.prototype.onData = function (chunk) {\n this.chunks.push(chunk);\n};\n\n\n/**\n * Inflate#onEnd(status) -> Void\n * - status (Number): inflate status. 0 (Z_OK) on success,\n * other if not.\n *\n * Called either after you tell inflate that the input stream is\n * complete (Z_FINISH) or should be flushed (Z_SYNC_FLUSH)\n * or if an error happened. By default - join collected chunks,\n * free memory and fill `results` / `err` properties.\n **/\nInflate.prototype.onEnd = function (status) {\n // On success - join\n if (status === Z_OK$1) {\n if (this.options.to === 'string') {\n // Glue & convert here, until we teach pako to send\n // utf8 alligned strings to onData\n this.result = this.chunks.join('');\n } else {\n this.result = flattenChunks(this.chunks);\n }\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n};\n\n\n/**\n * inflate(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * Decompress `data` with inflate/ungzip and `options`. Autodetect\n * format via wrapper header by default. That's why we don't provide\n * separate `ungzip` method.\n *\n * Supported options are:\n *\n * - windowBits\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information.\n *\n * Sugar (options):\n *\n * - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify\n * negative windowBits implicitly.\n * - `to` (String) - if equal to 'string', then result will be converted\n * from utf8 to utf16 (javascript) string. When string output requested,\n * chunk length can differ from `chunkSize`, depending on content.\n *\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , input = pako.deflate([1,2,3,4,5,6,7,8,9])\n * , output;\n *\n * try {\n * output = pako.inflate(input);\n * } catch (err)\n * console.log(err);\n * }\n * ```\n **/\nfunction doInflate(input, options) {\n var inflator = new Inflate(options);\n\n inflator.push(input, true);\n\n // That will never happens, if you don't cheat with options :)\n if (inflator.err) { throw inflator.msg; }\n\n return inflator.result;\n}\n\nexport { doInflate as ungzip };","/**\n * @file Validation Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport XmlParser, { XmlParserParameters } from './xml-parser'\nimport Validation from '../structure/validation'\nimport Streamer from '../streamer/streamer';\n\nclass ValidationParser extends XmlParser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.useDomParser = true\n this.validation = new Validation(this.name, this.path)\n }\n\n get __objName () { return 'validation' }\n get isXml () { return true }\n\n _parse () {\n super._parse()\n\n if (Debug) Log.time('ValidationParser._parse ' + this.name)\n\n this.validation.fromXml(this.xml.data)\n\n if (Debug) Log.timeEnd('ValidationParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('validation', ValidationParser)\n\nexport default ValidationParser\n","/**\n * @file Gzip Decompressor\n * @author Alexander Rose \n * @private\n */\n\nimport { ungzip } from '../../lib/pako_inflate.es6'\n\nimport { DecompressorRegistry } from '../globals'\n\nfunction gzipDecompress (data: ArrayBuffer|Uint8Array) {\n let decompressedData\n\n if (data instanceof ArrayBuffer) {\n data = new Uint8Array(data)\n }\n\n try {\n decompressedData = ungzip(data as Uint8Array)\n } catch (e) {\n decompressedData = data // assume it is already uncompressed\n }\n\n return decompressedData\n}\n\nDecompressorRegistry.add('gz', gzipDecompress)\n","/**\n * @file Datasource\n * @author Alexander Rose \n * @private\n */\n\n/**\n * Datasource base class\n * @interface\n */\nabstract class Datasource {\n /**\n * Get full url\n * @abstract\n * @param {String} path - datasource string\n * @return {String} - url\n */\n abstract getUrl (path: string): string\n\n /**\n * Get file extension\n * @abstract\n * @param {String} path - datasource string\n * @return {String} - extension\n */\n abstract getExt (path: string): string\n}\n\nexport default Datasource\n","/**\n * @file RCSB Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { Log, DatasourceRegistry } from '../globals'\nimport { getProtocol } from '../utils'\nimport { getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nconst baseUrl = '//files.rcsb.org/download/'\nconst mmtfBaseUrl = '//mmtf.rcsb.org/v1.0/'\nconst mmtfFullUrl = mmtfBaseUrl + 'full/'\nconst mmtfReducedUrl = mmtfBaseUrl + 'reduced/'\n\nclass RcsbDatasource extends Datasource {\n getUrl (src: string) {\n // valid path are\n // XXXX.pdb, XXXX.pdb.gz, XXXX.cif, XXXX.cif.gz, XXXX.mmtf, XXXX.bb.mmtf\n // XXXX defaults to XXXX.cif\n const info = getFileInfo(src)\n const pdbid = info.name.substr(0, 4)\n let url\n if ([ 'pdb', 'cif' ].includes(info.ext) &&\n (info.compressed === false || info.compressed === 'gz')\n ) {\n url = baseUrl + info.path\n } else if (info.ext === 'mmtf') {\n if (info.base.endsWith('.bb')) {\n url = mmtfReducedUrl + pdbid\n } else {\n url = mmtfFullUrl + pdbid\n }\n } else if (!info.ext) {\n url = mmtfFullUrl + pdbid\n } else {\n Log.warn('unsupported ext', info.ext)\n url = mmtfFullUrl + pdbid\n }\n return getProtocol() + url\n }\n\n getExt (src: string) {\n const ext = getFileInfo(src).ext\n return ext ? ext : 'mmtf'\n }\n}\n\nDatasourceRegistry.add('rcsb', new RcsbDatasource())\n\nexport default RcsbDatasource\n","/**\n * @file PubChem Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { Log, DatasourceRegistry } from '../globals'\nimport { getProtocol } from '../utils'\nimport { getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nconst baseUrl = '//pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/'\nconst suffixUrl = '/SDF?record_type=3d'\n\nclass PubchemDatasource extends Datasource {\n getUrl (src: string) {\n const info = getFileInfo(src)\n const cid = info.name\n let url\n if (!info.ext || info.ext === 'sdf') {\n url = baseUrl + cid + suffixUrl\n } else {\n Log.warn('unsupported ext', info.ext)\n url = baseUrl + cid + suffixUrl\n }\n return getProtocol() + url\n }\n\n getExt (src: string) {\n const ext = getFileInfo(src).ext\n return ext ? ext : 'sdf'\n }\n}\n\nDatasourceRegistry.add('pubchem', new PubchemDatasource())\n\nexport default PubchemDatasource\n","/**\n * @file Pass Through Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { DatasourceRegistry } from '../globals'\nimport { getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nclass PassThroughDatasource extends Datasource {\n getUrl (path: string) {\n return path\n }\n\n getExt (path: string) {\n return getFileInfo(path).ext\n }\n}\n\nDatasourceRegistry.add('ftp', new PassThroughDatasource())\nDatasourceRegistry.add('http', new PassThroughDatasource())\nDatasourceRegistry.add('https', new PassThroughDatasource())\n\nexport default PassThroughDatasource\n","/**\r\n * @file Alphafold Datasource\r\n * @author Fredric Johansson \r\n * @private\r\n */\r\n\r\nimport { Log, DatasourceRegistry } from '../globals'\r\nimport { getProtocol } from '../utils'\r\nimport { getFileInfo } from '../loader/loader-utils'\r\nimport Datasource from './datasource'\r\n\r\nconst baseUrl = '//alphafold.ebi.ac.uk/files/AF-'\r\nconst suffixURL = '-F1-model_v2.pdb'\r\n\r\nclass AlphafoldDatasource extends Datasource {\r\n getUrl (src: string) {\r\n const info = getFileInfo(src)\r\n const uniprotid = info.name\r\n let url\r\n if (!info.ext || info.ext === 'pdb') {\r\n url = baseUrl + uniprotid + suffixURL\r\n } else {\r\n Log.warn('unsupported AF ext', info.ext)\r\n url = baseUrl + uniprotid + suffixURL\r\n }\r\n return getProtocol() + url\r\n }\r\n\r\n getExt (src: string) {\r\n const ext = getFileInfo(src).ext\r\n return ext ? ext : 'pdb'\r\n }\r\n}\r\n\r\nDatasourceRegistry.add('alphafold', new AlphafoldDatasource())\r\n\r\nexport default AlphafoldDatasource\r\n","/**\n * @file Static Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { getAbsolutePath } from '../utils'\nimport { getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nconst reProtocol = /^((http|https|ftp):)*\\/\\//\n\nclass StaticDatasource extends Datasource {\n baseUrl: string\n\n constructor (baseUrl: string = '') {\n super()\n this.baseUrl = baseUrl\n }\n\n getUrl (src: string) {\n const info = getFileInfo(src)\n let url = this.baseUrl + info.path\n if (!reProtocol.test(this.baseUrl)) {\n url = getAbsolutePath(url)\n }\n return url\n }\n\n getExt (src: string) {\n return getFileInfo(src).ext\n }\n}\n\nexport default StaticDatasource\n","/**\n * @file MDsrv Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { autoLoad, getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nclass MdsrvDatasource extends Datasource {\n baseUrl: string\n\n constructor (baseUrl: string = '') {\n super()\n this.baseUrl = baseUrl\n }\n\n getListing (path: string = '') {\n let url = `${this.baseUrl}dir/${path}`\n if (url[url.length - 1] !== '/') url += '/'\n return autoLoad(url, {\n ext: 'json'\n }).then((jsonData: any) => ({\n path: path,\n data: jsonData.data\n }))\n }\n\n getUrl (src: string) {\n const info = getFileInfo(src)\n return `${this.baseUrl}file/${info.path}${info.query}`\n }\n\n getCountUrl (src: string) {\n const info = getFileInfo(src)\n return `${this.baseUrl}traj/numframes/${info.path}${info.query}`\n }\n\n getFrameUrl (src: string, frameIndex: number|string) {\n const info = getFileInfo(src)\n return `${this.baseUrl}traj/frame/${frameIndex}/${info.path}${info.query}`\n }\n\n getFrameParams (src: string, atomIndices: (number|string)[]) {\n return `atomIndices=${atomIndices.join(';')}`\n }\n\n getPathUrl (src: string, atomIndex: number|string) {\n const info = getFileInfo(src)\n return `${this.baseUrl}traj/path/${atomIndex}/${info.path}${info.query}`\n }\n\n getExt (src: string) {\n return getFileInfo(src).ext\n }\n}\n\nexport default MdsrvDatasource\n","/**\n * @file UI Parameters\n * @author Alexander Rose \n */\n\nimport { StageParameters } from '../stage/stage'\nimport { MouseActionPresets } from '../controls/mouse-actions'\n\nexport type BooleanParam = { type: 'boolean' }\nfunction BooleanParam () { return { type: 'boolean' } as BooleanParam }\n\nexport type ColorParam = { type: 'color' }\nfunction ColorParam () { return { type: 'color' } as ColorParam }\n\nexport type IntegerParam = { type: 'integer', max: number, min: number }\nfunction IntegerParam (max: number, min: number) {\n return { type: 'integer', max, min } as IntegerParam\n}\n\nexport type NumberParam = { type: 'number', precision: number, max: number, min: number }\nfunction NumberParam (precision: number, max: number, min: number) {\n return { type: 'number', precision, max, min } as NumberParam\n}\n\nexport type RangeParam = { type: 'range', step: number, max: number, min: number }\nfunction RangeParam (step: number, max: number, min: number) {\n return { type: 'range', step, max, min } as RangeParam\n}\n\nexport type SelectParam = { type: 'select', options: { [k: string]: string } }\nfunction SelectParam (...options: string[]) {\n return { type: 'select', options: options.reduce((o, k) => ({ ...o, [k]: k}), {}) } as SelectParam\n}\n\nexport type ParamType = BooleanParam|ColorParam|IntegerParam|NumberParam|RangeParam|SelectParam\n\nexport const UIStageParameters: { [k in keyof StageParameters]: ParamType } = {\n backgroundColor: ColorParam(),\n quality: SelectParam('auto', 'low', 'medium', 'high'),\n sampleLevel: RangeParam(1, 5, -1),\n impostor: BooleanParam(),\n workerDefault: BooleanParam(),\n rotateSpeed: NumberParam(1, 10, 0),\n zoomSpeed: NumberParam(1, 10, 0),\n panSpeed: NumberParam(1, 10, 0),\n clipNear: RangeParam(1, 100, 0),\n clipFar: RangeParam(1, 100, 0),\n clipDist: IntegerParam(200, 0),\n clipMode: SelectParam('scene', 'camera'),\n clipScale: SelectParam('relative', 'absolute'),\n fogNear: RangeParam(1, 100, 0),\n fogFar: RangeParam(1, 100, 0),\n cameraType: SelectParam('perspective', 'orthographic', 'stereo'),\n cameraEyeSep: NumberParam(3, 1.0, 0.01),\n cameraFov: RangeParam(1, 120, 15),\n lightColor: ColorParam(),\n lightIntensity: NumberParam(2, 10, 0),\n ambientColor: ColorParam(),\n ambientIntensity: NumberParam(2, 10, 0),\n hoverTimeout: IntegerParam(10000, -1),\n tooltip: BooleanParam(),\n mousePreset: SelectParam(...Object.keys(MouseActionPresets))\n}\n","/**\n * @file Version\n * @private\n * @author Alexander Rose \n */\n\nimport * as data from '../package.json'\n\n/**\n * Version name\n * @type {String}\n */\nconst Version = (data as any).version as string\n\nexport default Version\n"],"names":["getQuery","id","window","m","RegExp","exec","location","search","decodeURIComponent","defaults","value","defaultValue","undefined","createParams","params","defaultParams","o","Object","assign","k","updateParams","newParams","flatten","array","ret","i","length","Array","isArray","push","getProtocol","protocol","match","getBrowser","ua","navigator","userAgent","test","openUrl","url","open","href","download","data","downloadName","isSafari","isChromeIos","a","document","createElement","str","replace","msSaveOrOpenBlob","FileReader","Blob","reader","onloadend","result","readAsDataURL","objectUrlCreated","URL","createObjectURL","style","display","body","appendChild","target","click","removeChild","revokeObjectURL","throttle","func","wait","options","context","args","timeout","previous","later","leading","Date","now","apply","remaining","this","arguments","clearTimeout","trailing","setTimeout","lexicographicCompare","elm1","elm2","binarySearchIndexOf","element","compareFunction","low","high","mid","cmp","rangeInSortedArray","min","max","indexLeft","leftRange","binarySearchForLeftRange","indexRight","rightRange","binarySearchForRightRange","uniqueArray","sort","filter","index","sorted","uint8ToString","u8a","chunkSize","c","String","fromCharCode","subarray","join","getTypedArray","arrayType","arraySize","Int8Array","Int16Array","Int32Array","Uint8Array","Uint16Array","Uint32Array","Float32Array","Error","getUintArray","sizeOrArray","maxUint","ensureBuffer","buffer","ArrayBuffer","_ensureClassFromArray","constructor","fromArray","ensureVector3","v","Vector3","ensureMatrix4","Matrix4","ensureQuaternion","q","Quaternion","ensureFloat32Array","arg","toLowerCaseString","toString","toLowerCase","Registry","name","_dict","add","key","get","names","keys","degToRad","deg","chars","split","uuid","generateUUID","r","rnd","Math","random","clamp","lerp","start","stop","alpha","spline","p0","p1","p2","p3","t","tension","v0","v1","t2","smoothstep","x","normalize","colorSpace","ScaleDefaultParameters","scale","mode","domain","reverse","tmpColor","Color","manageColor","_target","_name","descriptor","originalMethod","fromTo","bind","set","convertSRGBToLinear","getHex","Colormaker","parameters","structure","atomProxy","getAtomProxy","getScale","p","slice","chroma","out","colorToArray","color","offset","atomColorToArray","atom","atomColor","bondColor","bond","atomIndex1","atomIndex2","bondColorToArray","volumeColorToArray","volumeColor","positionColorToArray","coords","positionColor","kwd","SelectAllKeyword","SelectNoneKeyword","AtomOnlyKeywords","BACKBONE","SIDECHAIN","BONDED","RING","AROMATICRING","METAL","POLARH","ChainKeywords","POLYMER","WATER","SmallResname","NucleophilicResname","HydrophobicResname","AromaticResname","AmideResname","AcidicResname","BasicResname","ChargedResname","PolarResname","NonpolarResname","CyclicResname","AliphaticResname","atomTestFn","s","atomname","altloc","atomindex","keyword","inscode","resname","sstruc","resno","chainname","model","isBackbone","isSidechain","isBonded","isRing","isAromatic","HETERO","isHetero","PROTEIN","isProtein","NUCLEIC","isNucleic","RNA","isRna","DNA","isDna","isPolymer","isWater","HELIX","isHelix","SHEET","isSheet","TURN","isTurn","ION","isIon","SACCHARIDE","isSaccharide","isMetal","isPolarHydrogen","includes","modelIndex","residueTestFn","atomOffset","atomEnd","chainTestFn","entity","modelTestFn","makeTest","selection","fn","error","rules","n","negate","f","subTests","hasOwnProperty","and","operator","na","ALL","NONE","filtered","fs","makeAtomTest","atomOnly","filteredSelection","makeResidueTest","residueOnly","makeChainTest","chainOnly","makeModelTest","modelOnly","Selection","string","signals","stringChanged","Signal","setString","type","silent","retSelection","newSelection","oldSelection","selectionStack","trim","charAt","substr","chunks","createNewContext","getPrevContext","pop","pushRule","rule","not","cu","toUpperCase","lastRule","indexOf","indexList","map","parseInt","b","console","resnameList","isNaN","sele","substring","chain","negate2","resi","resiSingle","resiRange","parseSele","e","message","residueTest","chainTest","modelTest","atomOnlyTest","residueOnlyTest","chainOnlyTest","modelOnlyTest","dispatch","isAllSelection","isNoneSelection","SelectionColormaker","super","colormakerList","selectionList","dataList","forEach","scheme","ColormakerRegistry","hasScheme","getScheme","ColormakerScales","OrRd","PuBu","BuPu","Oranges","BuGn","YlOrBr","YlGn","Reds","RdPu","Greens","YlGnBu","Purples","GnBu","Greys","YlOrRd","PuRd","Blues","PuBuGn","Viridis","Spectral","RdYlGn","RdBu","PiYG","PRGn","RdYlBu","BrBG","RdGy","PuOr","Set1","Set2","Set3","Dark2","Paired","Pastel1","Pastel2","Accent","rainbow","rwb","ColormakerModes","rgb","hsv","hsl","hsi","lab","hcl","getWorkerDeps","vars","deps","sym","__deps","prototype","makeWorkerString","onmessage","__name","postId","__postId","self","callback","aMessage","transferList","postMessage","makeWorkerBlob","Browser","SupportsPassiveEventHandler","opts","defineProperty","addEventListener","Mobile","orientation","SupportsReadPixelsFloat","setSupportsReadPixelsFloat","ExtensionFragDepth","setExtensionFragDepth","Log","log","Function","call","info","warn","time","timeEnd","MeasurementDefaultParams","labelColor","labelAttachment","labelSize","labelZOffset","labelYOffset","labelBorder","labelBorderColor","labelBorderWidth","lineOpacity","linewidth","opacity","labelUnit","arcVisible","planeVisible","setMeasurementDefaultParams","Debug","setDebug","ScriptExtensions","WorkerRegistry","activeWorkerCount","_funcDict","_depsDict","_blobDict","schemes","userSchemes","SchemeClass","getSchemes","types","getScales","getModes","addScheme","label","_createScheme","_addUserScheme","removeScheme","_Colormaker","addSelectionScheme","DatasourceRegistry","RepresentationRegistry","ParserRegistry","__hasObjName","objName","parser","__objName","isTrajectory","isStructure","isVolume","isSurface","isBinary","isXml","isJson","getTrajectoryExtensions","getStructureExtensions","getVolumeExtensions","getSurfaceExtensions","ShaderRegistry","DecompressorRegistry","ComponentRegistry","BufferRegistry","PickerRegistry","ListingDatasource","TrajectoryDatasource","setListingDatasource","setTrajectoryDatasource","Streamer","src","newline","__pointer","__partialLine","compressed","binary","json","xml","read","_read","then","decompressFn","_chunk","end","chunk","peekLines","charCodeAt","count","chunkToLines","lines","chunkCount","floor","asText","partialLine","isLast","idx","lastIndexOf","str2","concat","nextChunk","nextChunkOfLines","d","eachChunk","round","eachChunkOfLines","chunkNo","dispose","FileStreamer","Promise","resolve","reject","file","onload","event","onerror","readAsArrayBuffer","readAsText","NetworkStreamer","xhr","XMLHttpRequest","status","response","statusText","responseType","send","Loader","ext","dir","path","streamerParams","File","streamer","ParserLoader","parserParams","voxelSize","firstModelOnly","asTrajectory","cAlphaOnly","delimiter","comment","columnNames","inferBonds","load","parse","Script","functionBody","elementAdded","elementRemoved","nameChanged","run","stage","ScriptLoader","getFileInfo","compressedExtList","queryIndex","query","base","nameSplit","protocolMatch","getDataInfo","datasource","getUrl","getExt","autoLoad","loader","Writer","getBlob","getData","mimeType","defaultName","defaultExt","PdbWriter","renumberSerial","remarks","ensureArray","_records","_writeRecords","_writeTitle","_writeRemarks","_writeAtoms","sprintf","trajectory","frame","ia","im","charge","chargeSign","hasModels","modelStore","eachModel","eachAtom","formatString","hetero","serial","formalCharge","abs","toPrecision","y","z","occupancy","bfactor","getSelection","getString","SdfWriter","idString","titleString","title","countsString","atomCount","bondCount","chargeLines","pairs","ap","nCharges","j","formatAtom","line","formatBond","bp","bondOrder","_writeHeader","_writeCTab","_writeFooter","eachBond","charArray","IOBuffer","_mark","_marks","littleEndian","dataIsGiven","byteLength","dvOffset","byteOffset","_lastWrittenByte","_data","DataView","available","isLittleEndian","setLittleEndian","isBigEndian","setBigEndian","skip","seek","mark","reset","pushMark","popMark","rewind","ensureAvailable","newLength","newArray","readBoolean","readUint8","readInt8","getInt8","getUint8","readByte","readBytes","bytes","readInt16","getInt16","readUint16","getUint16","readInt32","getInt32","readUint32","getUint32","readFloat32","getFloat32","readFloat64","getFloat64","readChar","readChars","writeBoolean","writeUint8","writeInt8","setInt8","_updateLastWrittenByte","setUint8","writeByte","writeBytes","writeInt16","setInt16","writeUint16","setUint16","writeInt32","setInt32","writeUint32","setUint32","writeFloat32","setFloat32","writeFloat64","setFloat64","writeChar","writeChars","toArray","StlWriter","surface","triangles","output","vector","vectorNorm1","vectorNorm2","vectorNorm3","indices","normal","addVectors","position","Counter","countChanged","signalsWrapper","clear","change","delta","increment","decrement","listen","counter","unlisten","has","remove","onZeroOnce","Stats","updated","maxDuration","Infinity","minDuration","avgDuration","lastDuration","prevFpsTime","lastFps","lastFrames","frames","begin","update","startTime","currentTime","performance","reInclude","shaderCache","getShader","defines","hash","definesText","getDefines","shaderText","ShaderChunk","WebGLRenderingContext","wrcp","_getShaderParameter","getShaderParameter","_getShaderInfoLog","getShaderInfoLog","_getProgramParameter","getProgramParameter","program","pname","LINK_STATUS","_getProgramInfoLog","getProgramInfoLog","JitterVectors","offsetList","TiledRenderer","renderer","camera","viewer","canvas","_viewer","_factor","factor","_antialias","antialias","_onProgress","onProgress","_onFinish","onFinish","_n","_width","width","_height","height","_ctx","getContext","_viewerSampleLevel","sampleLevel","setSampling","_renderTile","offsetX","offsetY","setViewOffset","render","w","h","drawImage","domElement","ceil","_finalize","view","renderAsync","TwoPI","PI","RAD2DEG","circularMean","stride","cosMean","sinMean","angle","cos","sin","atan2","calculateCenterArray","array1","array2","center","calculateDirectionArray","direction","uniformArray","optionalTarget","uniformArray3","serialArray","serialBlockArray","replicateArrayEntries","repArr","copyArray","dst","srcOffset","dstOffset","copyWithin","arrayMax","il","arrayMin","arraySum","sum","arrayMean","ImageDefaultParameters","transparent","makeImage","originalClearAlpha","getClearAlpha","backgroundColor","getClearColor","setLineWidthAndPixelSize","invert","scene","traverse","material","uniforms","size","__seen","trimCanvas","bg","g","canvasHeight","canvasWidth","pixels","getImageData","doBreak","off","topY","topX","bottomY","bottomX","trimedCanvas","_trimCanvas","finished","tiledRenderer","toBlob","blob","setClearAlpha","requestRender","vertex","matrix","modelViewProjectionMatrix","resolution","Vector2","projectionMatrixInverse","projectionMatrixTranspose","updateCameraUniforms","group","getInverse","projectionMatrix","copy","transpose","u","loadShader","gl","shaderSource","shaderType","shader","createShader","compileShader","COMPILE_STATUS","deleteShader","getExtension","TextureTestTexCoords","testTextureSupport","vertShader","VERTEX_SHADER","fragShader","FRAGMENT_SHADER","shaders","attribs","locations","createProgram","attachShader","attrib","bindAttribLocation","linkProgram","deleteProgram","useProgram","positionLocation","getAttribLocation","colorLoc","getUniformLocation","positionBuffer","createBuffer","bindBuffer","ARRAY_BUFFER","bufferData","STATIC_DRAW","enableVertexAttribArray","vertexAttribPointer","FLOAT","whiteTex","createTexture","whiteData","bindTexture","TEXTURE_2D","texImage2D","RGBA","UNSIGNED_BYTE","tex","texParameteri","TEXTURE_MIN_FILTER","NEAREST","TEXTURE_MAG_FILTER","fb","createFramebuffer","bindFramebuffer","FRAMEBUFFER","framebufferTexture2D","COLOR_ATTACHMENT0","checkFramebufferStatus","FRAMEBUFFER_COMPLETE","uniform4fv","drawArrays","TRIANGLES","clearColor","COLOR_BUFFER_BIT","pixel","readPixels","floatPixel","getError","NO_ERROR","INVALID_ENUM","INVALID_VALUE","INVALID_OPERATION","INVALID_FRAMEBUFFER_OPERATION","OUT_OF_MEMORY","CONTEXT_LOST_WEBGL","getErrorDescription","pixelBufferFloat","pixelBufferUint","pixelOrder","tmpMatrix","onBeforeRender","geometry","updateList","objectId","modelViewMatrixInverse","modelViewMatrixInverseTranspose","modelViewProjectionMatrixInverse","modelViewMatrix","multiplyMatrices","matrixWorldInverse","matrixWorld","materialProperties","properties","pu","getUniforms","setValue","Viewer","idOrElement","boundingBox","Box3","boundingBoxSize","boundingBoxLength","memory","programs","geometries","textures","calls","vertices","faces","points","distVector","ticked","rendered","elm","getElementById","container","HTMLElement","innerWidth","innerHeight","box","getBoundingClientRect","overflow","wrapper","_initParams","_initStats","_initCamera","_initScene","_initRenderer","_initHelper","setBackground","setFog","animate","fogColor","fogNear","fogFar","cameraType","cameraFov","cameraEyeSep","cameraZ","clipNear","clipFar","clipDist","clipMode","clipScale","lightColor","lightIntensity","ambientColor","ambientIntensity","rendererEncoding","LinearEncoding","lookAt","perspectiveCamera","PerspectiveCamera","orthographicCamera","OrthographicCamera","stereoCamera","StereoCamera","aspect","eyeSep","updateProjectionMatrix","stats","Scene","rotationGroup","Group","translationGroup","modelGroup","pickingGroup","backgroundGroup","helperGroup","fog","Fog","spotLight","SpotLight","ambientLight","AmbientLight","dpr","devicePixelRatio","WebGLRenderer","preserveDrawingBuffer","innerHTML","setPixelRatio","setSize","autoClear","sortObjects","outputEncoding","capabilities","isWebGL2","extensions","supportsHalfFloat","dprWidth","dprHeight","JSON","stringify","OES_texture_float","OES_texture_half_float","WEBGL_color_buffer_float","pickingTarget","WebGLRenderTarget","minFilter","NearestFilter","magFilter","stencilBuffer","format","RGBAFormat","FloatType","UnsignedByteType","texture","generateMipmaps","encoding","setRenderTarget","sampleTarget","LinearFilter","holdTarget","compositeUniforms","tForeground","Uniform","compositeMaterial","ShaderMaterial","vertexShader","fragmentShader","premultipliedAlpha","blending","AdditiveBlending","depthTest","depthWrite","compositeCamera","compositeScene","Mesh","PlaneGeometry","positions","bbGeometry","BufferGeometry","setIndex","BufferAttribute","setAttribute","bbMaterial","uColor","boundingBoxMesh","LineSegments","updateHelper","attributes","needsUpdate","isEmpty","computeBoundingSphere","cameraDistance","instanceList","instance","addBuffer","wireframeGroup","background","pickable","setUserData","object","children","userData","mesh","getMesh","applyMatrix4","wireframeMesh","getWireframeMesh","quaternion","pickingMesh","getPickingMesh","_updateBoundingBox","updateBoundingBox","instanceMatrix","updateGeometry","computeBoundingBox","geoBoundingBox","clone","equals","expandByScalar","union","updateNode","node","makeEmpty","getSize","getPickingPixels","imgBuffer","readRenderTargetPixels","getImage","picking","imgBuffer2","ctx","imgData","putImageData","setLight","intensity","near","far","setClearColor","getStyle","level","setOutputEncoding","setColorWorkflow","sRGBEncoding","setCamera","fov","up","updateZoom","setClip","dist","left","right","top","bottom","handleResize","updateInfo","rInfo","rMemory","rRender","isStill","currentSampleLevel","renderPending","frameRequest","requestAnimationFrame","pick","pid","picker","pixelBuffer","oid","getObjectById","tan","zoom","absoluteToRelative","bRadius","relativeToAbsolute","__updateClipping","isFinite","getWorldPosition","cDist","nearFactor","farFactor","fogNearFactor","fogFarFactor","__updateCamera","updateMatrix","updateMatrixWorld","pixelRatio","getPixelRatio","ortho","nearClip","updateMaterialUniforms","traverseVisible","Points","sortParticles","sortData","sortArray","zArray","cmpFn","indexSrc","indexDst","tmpTab","__zArray","__sortArray","__cmpFn","ai","bi","arr","stack","tmp","sp","swap","tmp2","quicksortCmp","attr","itemSize","sortProjectedPosition","__setVisibility","helper","visible","__updateLights","setLength","__renderPickingGroup","__renderModelGroup","renderTarget","__renderSuperSample","baseSampleWeight","sampleWeight","clearViewOffset","__renderStereo","_renderTarget","setScissorTest","setScissor","setViewport","cameraL","__render","cameraR","lastRenderedPicking","rendering","cancelAnimationFrame","LeftMouseButton","MiddleMouseButton","RightMouseButton","getTouchDistance","dx","touches","pageX","dy","pageY","sqrt","MouseObserver","moved","scrolled","dragged","dropped","clicked","hovered","doubleClicked","prevPosition","down","canvasPosition","prevClickCP","moving","hovering","lastMoved","which","buttons","pressed","altKey","ctrlKey","metaKey","shiftKey","touchAction","hoverTimeout","handleScroll","doubleClickSpeed","_listen","_onMousewheel","_onMousemove","_onMousedown","_onMouseup","_onContextmenu","_onTouchstart","_onTouchend","_onTouchmove","opt","passive","setParameters","cp","doubleClickPending","lastClicked","overElement","preventDefault","_setKeys","deltaY","deltaMode","WheelEvent","DOM_DELTA_PIXEL","DOM_DELTA_LINE","wheelDelta","wheelDeltaY","detail","clientX","clientY","_setCanvasPosition","button","getMouseButtons","_distance","distanceTo","lastTouchDistance","touchDistance","removeEventListener","tmpRotateXMatrix","tmpRotateYMatrix","tmpRotateZMatrix","tmpRotateMatrix","tmpRotateCameraMatrix","tmpRotateVector","tmpRotateQuaternion","tmpRotateQuaternion2","tmpPanMatrix","tmpPanVector","tmpAtomVector","TrackballControls","rotateSpeed","zoomSpeed","panSpeed","mouse","mouseObserver","controls","viewerControls","component","transformComponent","transformAtom","_setPanVector","scaleFactor","getCanvasScaleFactor","multiplyScalar","_getRotateXY","_getCameraRotation","extractRotation","multiply","makeRotationY","_transformPanVector","transform","premultiply","pan","translate","panComponent","panAtom","positionToVector3","positionAdd","updateRepresentations","rotate","setFromAxisAngle","makeRotationFromQuaternion","applyMatrix","zRotate","dz","makeRotationZ","rotateComponent","makeRotationAxis","setFromRotationMatrix","tmpVec","PickingProxy","pickingData","getComponentsByObject","list","getObject","getPosition","closestBondAtom","atom1","v2","atom2","acp1","getPositionOnCanvas","acp2","closeAtom","ca","acp","radius","getMaxRepresentationRadius","arrow","_objectIfType","axes","cone","clash","contact","cylinder","distance","ellipsoid","octahedron","point","sphere","tetrahedron","torus","unitcell","unknown","volume","wideline","getLabel","msg","qualifiedName","sele1","sele2","shape","spacegroup","PickingControls","pickerArray","tmpQ","tmpP","tmpS","tmpCanvasVector","tmpScaleVector","tmpAlignMatrix","ViewerControls","changed","rotation","project","getCameraDistance","getOrientation","setPosition","orient","decompose","setRotationFromQuaternion","spin","axis","rotateOnAxis","align","basis","setRotationFromMatrix","Animation","duration","pausedTime","elapsedDuration","pausedDuration","ignoreGlobalToggle","_paused","_resolveList","_init","done","paused","tick","_tick","pause","hold","_hold","resume","releaseHold","toggle","SpinAnimation","RockAnimation","angleSum","angleStep","angleEnd","MoveAnimation","moveFrom","moveTo","lerpVectors","ZoomAnimation","zoomFrom","zoomTo","RotateAnimation","_currentRotation","rotateFrom","rotateTo","slerp","ValueAnimation","valueFrom","valueTo","TimeoutAnimation","AnimationList","_list","every","animation","AnimationControls","animationList","finishedList","splice","rock","move","zoomMove","orientTo","spinComponent","rockComponent","moveComponent","Queue","argList","queue","pending","next","shift","kill","Representation","lazy","step","clipRadius","precision","clipCenter","flatShaded","side","front","back","double","wireframe","colorData","colorScheme","colorScale","colorReverse","colorValue","colorDomain","colorMode","roughness","metalness","diffuse","diffuseInterior","useInteriorColor","interiorColor","interiorDarkening","disablePicking","rebuild","tasks","make","bufferList","toBePrepared","init","setColor","quality","lazyProps","build","bufferParams","what","tp","sphereDetail","radialSegments","openEnded","disableImpostor","getColorParams","getBufferParams","val","prepare","cb","create","updateWhat","_make","manualAttach","disposed","attach","setVisibility","noRenderRequest","updateParameters","int","float","parseFloat","getParameters","_Worker","postCount","onmessageDict","onerrorDict","blobUrl","worker","Worker","post","__debug","terminate","WorkerPool","maxCount","pool","getNextWorker","nextWorker","minPending","calculateMeanVector3","projectPointOnVector","origin","sub","projectOnVector","minX","minY","minZ","maxX","maxY","maxZ","l","v3new","applyMatrix4toVector3array","applyMatrix3toVector3array","normalizeVector3array","len2","v3cross","ax","ay","az","bx","by","bz","v3dot","v3sub","v3add","v3fromArray","v3toArray","input","v3length2","v3length","v3divideScalar","v3multiplyScalar","v3normalize","length2","v3subScalar","v3addScalar","v3floor","v3ceil","v3negate","v3angle","cx","cy","cz","getFixedCountDashData","segmentCount","position1","sn3","position2","i3","j3","f1","f2","replicateArray3Entries","color2","primitiveId","getFixedLengthDashData","segmentLength","pos1","pos2","col","rad","getFixedLengthWrappedDashData","drawing","k3","kprev","vl","inv","Primitive","Picker","Buffer","static","_primitiveData","getShapeKey","fields","valueToShape","expandBoundingBox","valueFromShape","arrayFromShape","dataFromShape","SpherePrimitive","expandByPoint","BoxPrimitive","heightAxis","depthAxis","OctahedronPrimitive","TetrahedronPrimitive","CylinderPrimitive","dashedCylinder","ArrowPrimitive","ConePrimitive","EllipsoidPrimitive","majorAxis","minorAxis","TorusPrimitive","TextPrimitive","text","PointPrimitive","WidelinePrimitive","SpatialHash","exp","bb","createBoundingBox","boundX","boundY","boundZ","an","xArray","yArray","grid","bucketIndex","bucketCount","bucketOffset","bucketFill","bucketArray","bucketIdx","within","eachWithin","atomIndex","rSq","loX","loY","loZ","hiX","hiY","hiZ","ix","iy","iz","dSq","Store","_fields","_defaultFields","_initField","addField","resize","tmpArray","growIfFull","copyFrom","other","thisOffset","otherOffset","thisField","otherField","thisIndex","otherIndex","offsetTarget","offsetSource","targetIndex","sourceIndex","thisStore","tmpStore","quicksort","pivot","leftNew","rightNew","index1","index2","ContactStore","addContact","hammingWeight","BitArray","setAll","_words","flip","_assignRange","words","wordValue","wordStart","wordEnd","startWord","endWord","setRange","clearRange","setBits","clearBits","clearAll","flipAll","bs","_isRangeValue","isRangeSet","isRangeClear","isAllSet","isAllClear","isSet","isClear","isEqualTo","otherBitarray","words1","words2","difference","intersection","intersects","getIntersectionSize","makeIntersection","wordsA","answer","pos","toSeleString","createAdjacencyList","edges","edgeCount","nodeCount","nodeArray1","nodeArray2","countArray","offsetArray","bondCount2","indexArray","idx1","idx2","j1","j2","createFeatureState","atomSet","addAtom","state","addFeature","features","groups","centers","atomSets","UnknownBackboneType","ChemCompProtein","ChemCompRna","ChemCompDna","ChemCompSaccharide","ChemCompHetero","SecStrucHelix","SecStrucSheet","SecStrucTurn","AtomicNumbers","H","D","T","HE","LI","BE","B","C","N","O","F","NE","NA","MG","AL","SI","P","S","CL","AR","K","CA","SC","TI","V","CR","MN","FE","CO","NI","CU","ZN","GA","GE","AS","SE","BR","KR","RB","SR","Y","ZR","NB","MO","TC","RU","RH","PD","AG","CD","IN","SN","SB","TE","I","XE","CS","BA","LA","CE","PR","ND","PM","SM","EU","GD","TB","DY","HO","ER","TM","YB","LU","HF","TA","W","RE","OS","IR","PT","AU","HG","TL","PB","BI","PO","AT","RN","FR","RA","AC","TH","PA","U","NP","PU","AM","CM","BK","CF","ES","FM","MD","NO","LR","RF","DB","SG","BH","HS","MT","DS","RG","CN","NH","FL","MC","LV","TS","OG","VdwRadii","CovalentRadii","Valences","OuterShellElectronCounts","ResidueHydrophobicity","ALA","ARG","ASN","ASP","ASH","CYS","GLN","GLU","GLH","GLY","HIS","ILE","LEU","LYS","MET","PHE","PRO","SER","THR","TRP","TYR","VAL","DefaultResidueHydrophobicity","AA1","SEC","PYL","AA3","RnaBases","DnaBases","PurinBases","Bases","WaterNames","IonNames","SaccharideNames","ProteinBackboneAtoms","NucleicBackboneAtoms","ResidueTypeAtoms","trace","direction1","direction2","backboneStart","backboneEnd","PDBQTSpecialElements","HD","A","NS","OA","SA","G0","G1","G2","G3","CG0","CG1","CG2","CG3","assignGeometry","totalCoordination","Angles","Map","calcAngles","ap1","ap2","angles","d1","d2","subVectors","eachBondedAtom","number","angleTo","calcPlaneAngle","x1","v12","neighbours","ni","cross","ValenceModel","implicitH","totalH","idealGeometry","chg","implH","totH","geom","hydrogenCount","bondToElementCount","assignCharge","assignH","degree","valence","explicitValence","conjugated","_bp","getBondProxy","atomicNumber","flag","a2","getOtherAtom","b2","atomicNumber2","isConjugated","multiBond","implicitHCount","ba","oa","calculateHydrogensCharge","valenceModel","isPhosphate","PositvelyCharged","NegativelyCharged","isIonicInteraction","ti","tj","isPiStacking","isCationPi","isHistidineNitrogen","isHydrogenBond","isWeakHydrogenBond","IonicTypeMetals","isMetalComplex","halBondElements","X","OptimalHalogenAngle","OptimalAcceptorAngle","invalidAtomContact","masterIdx","isMasterContact","ContactDefaultParams","maxHydrophobicDist","maxHbondDist","maxHbondSulfurDist","maxHbondAccAngle","maxHbondDonAngle","maxHbondAccPlaneAngle","maxHbondDonPlaneAngle","maxPiStackingDist","maxPiStackingOffset","maxPiStackingAngle","maxCationPiDist","maxCationPiOffset","maxIonicDist","maxHalogenBondDist","maxHalogenBondAngle","maxMetalDist","refineSaltBridges","masterModelIndex","lineOfSightDistFactor","residueIndex","calculateFeatures","atomInGroupDict","eachResidue","addGroup","terminalNitrogenCount","isGuanidine","isAcetamidine","addPositiveCharges","isSulfonicAcid","isSulfate","terminalOxygenCount","isCarboxylate","addNegativeCharges","rings","getAromaticRings","ring","addAromaticRings","totalBonds","ig","addHydrogenAcceptors","addHydrogenDonors","ringData","residueType","getRings","hasElement","some","residueAtomOffset","atomTypeId","atomTypeIdList","atomMap","inAromaticRingWithElectronNegativeElement","addWeakHydrogenDonors","dative","ionic","isStandardAminoacid","isStandardBase","isHalogen","addMetalBinding","isTransitionMetal","addMetals","addHydrophobic","addHalogenAcceptors","addHalogenDonors","calculateContacts","contacts","spatialHash","contactStore","featureSet","createContacts","maxDistance","maxPiStackingDistSq","maxCationPiDistSq","atomStore","areAtomSetsWithinDist","atomSet1","atomSet2","maxDist","sn","sm","si","sj","v3","n1","n2","getNormal","atoms","crossVectors","getOffset","projectOnPlane","ct","addChargedContacts","maxHbondDistSq","donor","acceptor","isWeak","connectedTo","donorAngles","idealDonorAngle","donorAngle","outOfPlane","acceptorAngles","idealAcceptorAngle","acceptorAngle","bondType","isWaterHydrogenBond","isBackboneHydrogenBond","addHydrogenBonds","m1","m2","addMetalComplexation","addHydrophobicContacts","halogen","halogenAngles","addHalogenBonds","frozenContacts","adjacencyList","contactSet","createFrozenContacts","ac1","ac2","aw","c1","c2","lineOfSightDist","lineOfSightDistFactorSq","as1","as2","vdw","distanceToSquared","refineLineOfSight","residueContactDict","handleResidueContact","minDist","minIndex","refineHydrophobicContacts","ionicInteractionDict","isHydrogenBondType","iil1","iil2","piStackingDict","pil1","pil2","refinePiStacking","refineMetalCoordination","contactTypeName","ContactDataDefaultParams","hydrogenBond","hydrophobic","halogenBond","ionicInteraction","metalCoordination","cationPi","piStacking","weakHydrogenBond","waterHydrogenBond","backboneHydrogenBond","filterSele","getContactData","filterSet","getAtomSet","setHex","contactColor","ContactPicker","getIndex","_applyTransformations","_getPosition","ShapePicker","primitive","objectFromShape","positionFromShape","AtomPicker","AxesPicker","BondPicker","bondStore","center1","center2","ClashPicker","validation","clashArray","_getAtomProxyFromSele","getAtomIndices","DistancePicker","IgnorePicker","MeshPicker","__position","SurfacePicker","UnitcellPicker","getCenter","VolumePicker","vol","dp","SlicePicker","getEdgeTable","getTriTable","MarchingCubes","field","nx","ny","nz","normalCache","vertexIndex","icount","mx","my","mz","allowedContours","isolevel","noNormals","contour","wrap","isNegativeIso","normalFactor","yd","zd","ilist","positionArray","normalArray","atomindexArray","edgeTable","triTable","VIntX","valp1","valp2","_q","mu","nc","q3","VIntY","q6","VIntZ","compNorm","polygonize","fx","fy","fz","edgeFilter","q1","qy","qz","q1y","q1z","qyz","q1yz","cubeindex","field0","field1","field2","field3","field4","field5","field6","field7","bits","fx2","fy2","fz2","e1","e2","e3","triIndex","triangulate","xBeg","yBeg","zBeg","xEnd","yEnd","zEnd","yOffset","zOffset","xBeg2","yBeg2","zBeg2","xEnd2","yEnd2","zEnd2","__break","__xBeg","__yBeg","__zBeg","__xEnd","__yEnd","__zEnd","_isolevel","_noNormals","_box","_contour","_wrap","vIndexLength","Matrix","cols","rows","copyTo","At","nrows","ncols","Ai","Ati","pAt","ad","atd","multiplyABt","Ap","pA","pB","Cp","mrows","bd","cd","multiply3x3","Cd","Ad","Bd","m10","m11","m12","m13","m14","m15","m16","m17","m18","m20","m21","m22","m23","m24","m25","m26","m27","m28","meanRows","mean","subRows","row","i0","i1","hypot","EPSILON","FLT_MIN","svd","at","_m","amt","wmt","vmt","astep","_W","Vt","vstep","eps","minval","iter","maxIter","Aj","Vi","Vj","t0","t1","sd","beta","gamma","seed","val0","asum","Float64Array","JacobiSVDImpl","m4new","m4set","n11","n12","n13","n14","n21","n22","n23","n24","n31","n32","n33","n34","n41","n42","n43","n44","m4multiply","a11","a12","a13","a14","a21","a22","a23","a24","a31","a32","a33","a34","a41","a42","a43","a44","b11","b12","b13","b14","b21","b22","b23","b24","b31","b32","b33","b34","b41","b42","b43","b44","m4makeScale","m4makeTranslation","m4makeRotationY","theta","m3new","m3makeNormal","m4","r0","r1","r2","laplacianSmooth","verts","numiter","inflate","nv","nf","norms","tps","vertdeg","jl","flagvert","ao","bo","co","vi3","vdi","wtvi","wt2vi","wt2","outwt","computeVertexNormals","nv3","ab","ci","getRadiusDict","radiusList","radiusDict","getSurfaceGrid","maxRadius","extraMargin","margin","dim","maxSize","pow","tmpSize","tran","mroty","mscale","mtrans","Surface","Geometry","fromGeometry","setFromArray","geo","getColor","colormaker","tc","getPicking","getFilteredIndex","filteredIndex","elementSize","include","getAtomindex","VolumeSurface","mc","getSurface","smooth","normalMatrix","volsurf","Volume","Matrix3","inverseMatrix","setData","setAtomindex","_position","_min","_max","_mean","_rms","setStats","rms","setMatrix","me","elements","ne","getBox","_getBox","__box","_makeSurface","getValueForSigma","getSurfaceWorker","workerPool","sigma","getSigmaForValue","getDataAtomindex","getDataPosition","getDataColor","getDataPicking","getDataSize","_sum","sumSq","di","arrayRms","header","getThreeSide","FrontSide","BackSide","DoubleSide","setObjectMatrix","matrixWorldNeedsUpdate","BufferDefaultParameters","opaqueBack","forceTransparent","BufferParameterTypes","updateShader","property","uniform","updateVisibility","parameterTypes","indexVersion","wireframeIndexVersion","isImpostor","isText","isPoint","isLine","dynamic","wireframeIndexCount","defaultParameters","UniformsUtils","merge","UniformsLib","common","emissive","lights","pickingUniforms","_positionDataSize","addAttributes","initIndex","makeWireframeGeometry","attributeSize","nindex","setUsage","DYNAMIC_DRAW","makeMaterial","vertexColors","derivatives","fragDepth","wm","pm","NoBlending","wireframeMaterial","pickingMaterial","makeWireframeIndex","wireframeIndex","wireframeGeometry","setDrawRange","checkEdge","drawRange","updateWireframeIndex","updateRange","getRenderOrder","renderOrder","_getMesh","materialName","frustumCulled","getVertexShader","getFragmentShader","NEAR_CLIP","RADIUS_CLIP","PICKING","NOLIGHT","FLAT_SHADED","OPAQUE_BACK","DIFFUSE_INTERIOR","USE_INTERIOR_COLOR","addUniforms","buf","updateRenderOrder","setRenderOrder","pt","pv","propertyData","uniformData","doShaderUpdate","doVisibilityUpdate","setProperties","setUniforms","setAttributes","attribute","wu","isVector3","toJSON","MeshBuffer","SurfaceBuffer","setVisibilityTrue","setVisibilityFalse","DoubleSidedBuffer","frontMeshes","backMeshes","frontBuffer","backBuffer","ContourBuffer","SurfaceRepresentation","isolevelType","negateIsolevel","isolevelScroll","boxSize","colorVolume","useWorker","boxCenter","__boxCenter","setBox","__isolevel","__smooth","__contour","__wrap","__boxSize","onSurfaceFinish","surfaceBuffer","dullInterior","surfaceData","MouseActions","trackballControls","focus","getFocus","sign","almostIdentity","setFocus","eachRepresentation","reprElem","comp","repr","pickingProxy","animationControls","tt","tooltip","mp","innerText","measurePick","measureClear","MouseActionPresets","default","zoomScroll","focusScroll","zoomFocusScroll","rotateDrag","panDrag","zRotateDrag","zoomDrag","zoomFocusDrag","panComponentDrag","rotateComponentDrag","movePick","tooltipPick","pymol","coot","astexviewer","triggerFromString","tokens","MouseControls","actionList","disabled","preset","triggerStr","wildcard","action","KeyActions","autoView","toggleRock","toggleSpin","KeyActionPresets","toggleAnimations","toggleAntialiasing","KeyControls","char","PickingBehavior","mouseControls","_onClick","_onHover","pickingControls","MouseBehavior","_onMove","_onScroll","_onDrag","_onDblclick","AnimationBehavior","_onTick","KeyBehavior","keyControls","outline","_focusDomElement","_onKeydown","_onKeyup","_onKeypress","pressedKey","KeyboardEvent","keyCode","Annotation","content","_viewerPosition","_updateViewerPosition","_canvasPosition","_cameraPosition","pointerEvents","whiteSpace","setContent","_update","matrixChanged","displayValue","padding","fontFamily","_clientRect","getVisibility","vp","cr","depth","zIndex","ComponentControls","RadiusFactoryTypes","covalent","explicit","RadiusFactory","atomRadius","negateVector","PrincipalAxes","n3","pointsT","vm","van","vbn","vcn","va","vb","vc","begA","endA","begB","endB","begC","endC","vecA","vecB","vecC","normVecA","normVecB","normVecC","getBasisMatrix","makeBasis","determinant","getRotationQuaternion","inverse","getProjectedScaleForAtoms","d1a","d1b","d2a","d2b","d3a","d3b","ax1","ax2","ax3","dp1","dot","dt1","dp2","dt2","dp3","dt3","FilteredVolume","minValue","maxValue","outside","setFilter","_getFilterHash","DMEAN","ARMS","filterHash","_filterHash","_dataBuffer","_positionBuffer","_atomindexBuffer","filteredData","filteredPosition","filteredAtomindex","BondHash","al","BondStore","addBond","ai1","ai2","addBondIfConnected","AtomStore","setAltloc","getAltloc","code","ResidueStore","setSstruc","getSstruc","setInscode","getInscode","ChainStore","setChainname","getChainname","setChainid","chainid","getChainid","ModelStore","Helixorient","polymer","residueCount","getCenterIterator","cache","idx3","residueIndexStart","rp","getResidueProxy","traceAtomIndex","radiusFactory","diff","rise","twist","resdir","r12","r23","r34","diff13","diff24","vt","_axis","_prevAxis","_resdir","_center","a1","getAtomIndexByType","a3","a4","acos","diff13Length","diff24Length","resRadius","resTwist","resRise","resBending","resAxis","bending","Helixbundle","helixorient","getAxis","localAngle","centerDist","ssBorder","colorParams","radiusParams","beg","residueOffset","tmpAxis","tmpCenter","_beg","_end","rp1","rp2","BinaryHeap","scoreFunction","bubbleUp","sinkDown","peek","len","parentN","parent","elemScore","child1Score","child2Score","child2N","child1N","child1","child2","Kdtree","metric","maxDepth","currentNode","nodes","rootIndex","buildTree","arrBegin","arrEnd","plength","nodeIndex","arrMedian","currentDim","pivotIndex","pivotValue","storeIndex","getNodeDepth","parentIndex","nearest","maxNodes","bestNodes","nearestSearch","bestChild","otherChild","dimension","pointIndex","ownPoint","ownDistance","saveNode","leftIndex","rightIndex","linearPoint","linearDistance","verify","AtomProxy","chainStore","residueStore","residueMap","bondHash","entityList","entityIndex","chainIndex","residue","residueTypeId","atomType","partialCharge","aromatic","_ap","hasBondTo","bap","hasBondToElement","backboneIndexList","moleculeType","isCg","backboneType","isTrace","atomRings","isNonmetal","isMetalloid","isDiatomicNonmetal","isPolyatomicNonmetal","isAlkaliMetal","isAlkalineEarthMetal","isNobleGas","isPostTransitionMetal","isLanthanide","isActinide","getDefaultValence","getValenceList","getOuterShellElectronCount","taa","aaa","distSquared","ta","aa","positionFromArray","positionToArray","positionFromVector3","positionSub","getResidueBonds","firstOnly","relativeIndex","bonds","getBonds","atomIndices1","atomIndices2","connectedAtomIndex","connectedAtomIndices","noResname","toObject","euclideanDistSq","euclideanDist","pointArray","useSquaredDist","atomIndices","kdtree","_Kdtree","nodeList","resultList","SymOpCode","$","E","G","J","L","M","Q","R","Z","_","EncodedSymOp","reInteger","selectionFromChains","chainList","Assembly","partList","addPart","matrixList","part","AssemblyPart","getAtomCount","reduce","getResidueCount","getInstanceCount","instanceCount","isIdentity","structureChainList","eachChain","getBoundingBox","partBox","_getCount","propertyName","instanceBox","structureBox","getView","getInstanceList","StructureBuilder","currentModelindex","currentChainid","currentResname","currentResno","currentInscode","currentHetero","previousResname","previousHetero","ri","mi","addResidueType","modelindex","addModel","addChain","addResidue","chainOffset","chainCount","finalize","assignSecondaryStructure","secStruct","chainnames","chainnamesSorted","chainnamesIndex","helices","h1","h2","helix","helixRun","chainChange","sheets","s1","s2","strandCharCode","sheet","sheetRun","calculateSecondaryStructure","zhangSkolnickSS","distances","isHelical","eachPolymer","cgPolymer","proteinPolymer","prevSstruc","sstrucCount","ChainnameAlphabet","calculateChainnames","useExistingBonds","doAutoChainName","mIndex","rOffset","rCount","rStart","rEnd","chainData","eachResidueN","newChain","bbType1","bbType2","bbTypeUnk","backboneEndAtomIndex","backboneStartAtomIndex","fill","calculateBonds","calculateBondsWithin","calculateBondsBetween","BondOrderTable","getBondOrderFromTable","atomname1","atomname2","onlyAddRung","rungBondStore","rungAtomSet","atomBondMap","calculateAtomBondMap","bondedAtoms","Set","rai","bondOrders","nn","rai1","rai2","getBondIndex","rungEndAtomIndex","atomSetDict","rung","onlyAddBackbone","backboneBondStore","backboneAtomSet","needsBond","needsBackbone","backbone","buildUnitcellAssembly","uc","structureCenterFrac","cartToFrac","centerFrac","symopDict","encodedSymopList","matrixDict","symopList","symop","denominator","integer","getSymmetryOperations","centerFracSymop","positionFracSymop","getMatrixList","setFromMatrixPosition","fracToCart","unitcellAssembly","unitcellMatrixList","ncsMatrixList","biomolDict","NCS","ncsUnitcellMatrixList","nm","vec","supercellAssembly","supercellMatrixList","ncsSupercellMatrixList","UNITCELL","SUPERCELL","guessElement","atomName","assignResidueTypeBonds","bondDict","nextAtomOffset","concatStructures","structures","Structure","sb","atomIndexDict","modelCount","finalizeAtoms","finalizeBonds","AlkaliMetals","AlkalineEarthMetals","PolyatomicNonmetals","DiatomicNonmetals","NobleGases","PostTransitionMetals","Metalloids","Halogens","AtomType","no","AtomMap","dict","getHash","ResidueType","chemCompType","bondReferenceAtomIndices","getMoleculeType","getBackboneType","backboneEndType","backboneStartType","getBackboneIndexList","atomnames","atomnamesStart","atomnamesEnd","traceIndex","getAtomIndexByName","dir1Index","direction1AtomIndex","dir2Index","direction2AtomIndex","bbStartIndex","bbEndIndex","rungEndIndex","atomnameList","hasProteinBackbone","hasRnaBackbone","hasDnaBackbone","hasCgProteinBackbone","hasCgRnaBackbone","hasCgDnaBackbone","hasAtomWithName","hasBackboneAtoms","hasBackbone","end1","maxd","nearestAtoms","calculateResidueBonds","calculateRings","getBondGraph","bondGraph","calculateBondGraph","getAromatic","aromaticAtoms","calculateAromatic","aromaticRings","nb","capacity","visited","pred","RingFinderMaxDepth","currentColor","RingFinderState","findRings","aromaticRingFlags","AromaticRingElements","AromaticRingPlanarityThreshold","isRingAromatic","assignBondReferenceAtomIndices","refRing","rings1","rings2","ri1","ai3","_idx2","getBondReferenceAtomIndex","bondIndex","addRing","current","leftOffset","rightOffset","found","rn","ringOffset","from","head","ResidueMap","BondProxy","_v12","_v13","_ap1","_ap2","_ap3","getOtherAtomIndex","getReferenceAtomIndex","typeAtomIndex1","typeAtomIndex2","calculateShiftDir","ap3","v13","ResidueProxy","getChainProxy","getAtomType","getResname1","getAtomnameList","rNext","bbAtomEnd","bbAtomStart","getNextConnectedResidue","nextIndex","rpNext","rpFirst","getPreviousConnectedResidue","residueProxy","prevIndex","rpPrev","rpLast","Polymer","residueIndexEnd","rpStart","rpEnd","isPrevConnected","isNextConnected","isNextNextConnected","isCyclic","__residueProxy","aIndex","eachAtomN","rStartIndex","ChainProxy","getModelProxy","residueEnd","_rp","rNextIndex","first","ModelProxy","chainEnd","_cp","refreshed","extraData","atomSetCache","boxes","bondSet","getBondSet","getBackboneBondSet","backboneBondSet","__backbone","getRungBondSet","rungBondSet","__rung","seleString","getAtomSetWithinSelection","getAtomSetWithinPoint","getAtomSetWithinVolume","fv","getMaxScaleOnAxis","getAtomSetWithinGroup","atomResidueIndex","getStructure","eachEntity","getEntityType","mn","cn","getAtomData","atomData","getBondData","multipleBond","isMulti","isOffset","bondScale","bondSpacing","bondData","storeBondOrder","radius2","absOffset","multiRadius","vShortening","vShift","getBackboneAtomData","getBackboneBondData","getRungAtomData","getRungBondData","getPrincipalAxes","atomCenter","hasCoords","_hasCoords","getSequence","seq","getChainnameCount","updatePosition","refresh","refreshPosition","tmpBox","Primitives","ShapeDefaultParameters","aspectRatio","labelParams","pointSize","sizeAttenuation","useTexture","Shape","meshCount","addMesh","meshBuffer","addSphere","objectToShape","addEllipsoid","addTorus","addCylinder","addCone","addArrow","addBox","addOctahedron","addTetrahedron","addText","addPoint","addWideline","addLabel","getBufferList","buffers","bufferFromShape","BufferRepresentation","GeometryBuffer","geoPosition","geoIndex","meshPosition","meshNormal","meshColor","meshIndex","updateNormals","geoNormal","positionCount","geoPositionCount","transformedGeoPosition","transformedGeoNormal","makeIndex","initNormals","makeTranslation","applyPositionTransform","getNormalMatrix","o3","SphereGeometryBufferDefaultParameters","SphereGeometryBuffer","IcosahedronBufferGeometry","_radius","MappedBuffer","mappingType","indexSize","mapping","mappingSize","mappingIndicesSize","nullValueAttributes","getAttributeIndex","dataIndex","makeMapping","mappingItemSize","aMapping","mappingIndices","it","MappedQuadBuffer","SphereImpostorBuffer","SphereBuffer","x0","y0","y1","PointBufferDefaultParameters","alphaTest","edgeBleach","PointBufferParameterTypes","PointBuffer","makeTexture","DataTexture","makePointTexture","USE_SIZEATTENUATION","USE_MAP","ALPHATEST","DotRepresentation","thresholdType","thresholdMin","thresholdMax","thresholdOut","dotType","radiusType","deviation","dotData","dotBuffer","quadIndices","quadUvs","ImageBufferDefaultParameters","ImageBufferParameterTypes","ImageBuffer","alwaysTransparent","hasWireframe","imageData","flipY","pickingTex","pickingMap","mapSize","startsWith","CUBIC_INTERPOLATION","endsWith","BSPLINE_FILTER","CATMULROM_FILTER","MITCHELL_FILTER","updateTexture","NormalBlending","VolumeSlice","positionType","getPositionFromCoordinate","coord","ms","setFromMatrixScale","vn","dimLen","z0","setVec","pickingArray","tMin","tMax","SliceRepresentation","linear","percent","coordinate","volumeSlice","sliceBuffer","logReprUnknown","ElementDefaultParameters","Element","statusChanged","setStatus","setName","RepresentationElementDefaultParameters","RepresentationElement","visibilityChanged","parametersChanged","setRepresentation","getType","_disposeRepresentation","hasRepresentation","removeRepresentation","toggleVisibility","setSelection","_v","ComponentDefaultParameters","Component","representationAdded","representationRemoved","reprList","annotationList","setRotation","Euler","setFromEuler","setScale","setTransform","getCenterUntransformed","makeScale","updateRepresentationMatrices","addAnnotation","annotation","eachAnnotation","removeAnnotation","removeAllAnnotations","_addRepresentation","hidden","impostor","workerDefault","ReprClass","makeRepresentation","addBufferRepresentation","removeAllRepresentations","getBoxUntransformed","getZoom","getZoomForBox","Collection","_remove","RepresentationCollection","TrajectoryElementDefaultParameters","defaultStep","defaultTimeout","defaultInterpolateType","defaultInterpolateStep","defaultMode","defaultDirection","initialFrame","TrajectoryElement","frameChanged","playerChanged","player","setFrame","Frames","coordinates","times","timeOffset","deltaTime","Superposition","atoms1","atoms2","VH","coords1","coords2","coords1t","coords2t","transformationMatrix","prepCoords","_superpose","mean1","mean2","to","invA","t4","t5","t8","t9","t11","t13","t14","t15","t17","t18","t20","t21","t23","t26","invert3x3","md","mat3x3determinant","transformMat_","tmp_1","tmp_2","mult","M1","M2","is4X4","tCoords","det","_pB","mcols","invertTrasform","mat","n4","TrajectoryPlayerDefaultParameters","interpolateType","interpolateStep","TrajectoryPlayer","traj","startedRunning","haltedRunning","_run","_previousTime","_currentTime","_currentStep","frameCount","_currentFrame","_direction","_animate","isRunning","dt","inProgress","_nextInterpolated","hasFrame","ip","ipp","ippp","setFrameInterpolated","loadFrame","_next","currentFrame","play","setPlayer","Trajectory","trajPath","frameCache","loadQueue","boxCache","pathCache","frameCacheSize","_frameCount","_disposed","centerPbc","removePbc","removePeriodicity","superpose","selectionIndices","_resetCache","_saveInitialCoords","setStructure","_loadFrameCount","backboneIndices","_getIndices","_makeAtomIndices","_saveStructureCoords","initialCoords","structureCoords","_makeSuperposeCoords","resetCache","_updateStructure","_interpolate","fc","cpp","cppp","j0","interpolateSpline","interpolateLerp","iList","_loadFrame","_doSuperpose","_process","_setFrameCount","box2","circMean","circularMean3","arrayMean3","getFrameTime","FramesTrajectory","StructureTrajectory","RemoteTrajectory","request","getFrameUrl","getFrameParams","setRequestHeader","arrayBuffer","getCountUrl","CallbackTrajectory","requestCallback","StructureView","seleList","parentSelection","ignoreView","blosum62x","prepareMatrix","cellNames","matDict","rowDict","SubstitutionMatrices","blosum62","Alignment","seq1","seq2","gapPenalty","gapExtensionPenalty","substMatrix","initMatrices","score","ali","gap","makeScoreFn","calc","gap0","scoreFn","Vi1","Si1","Hi","Si","ali1","ali2","_s1","_s2","_i","_j","aliIdx1","aliIdx2","_atoms1","_atoms2","StructureComponentDefaultParameters","defaultAssembly","StructureComponent","trajList","trajectoryAdded","trajectoryRemoved","defaultAssemblyChanged","initSelection","pickBuffer","pointer","item","createRingBuffer","pickDict","del","values","createSimpleDict","spacefillRepresentation","addRepresentation","distanceRepresentation","angleRepresentation","dihedralRepresentation","measureRepresentations","setDefaultAssembly","structureView","rebuildRepresentations","rebuildTrajectories","reprParams","trajComp","reprComp","measureUpdate","addTrajectory","trajSrc","makeTrajectory","removeTrajectory","getAtomRadius","pickCount","lastPick","atomList","atomListSorted","atomPair","atomTriple","atomQuad","measureBuild","measureData","dihedral","pickData","radiusData","removeAllMeasurements","pd","removeMeasurement","addMeasurement","SurfaceComponent","VolumeComponent","ComponentCollection","matchName","tmpZoomVector","StageDefaultParameters","mousePreset","Stage","fullscreenChanged","componentAdded","componentRemoved","compList","defaultFileParams","logList","pickingBehavior","mouseBehavior","animationBehavior","keyBehavior","spinAnimation","rockAnimation","setQuality","setImpostor","defaultFileRepresentation","BU1","assembly","sizeScore","backboneOnly","radiusScale","surfaceType","probeRadius","lineOnly","loadFile","promise","addComponentFromObject","defaultRepresentation","errorMsg","loadScript","script","addComponent","CompClass","removeComponent","removeAllComponents","toggleFullscreen","fullscreenEnabled","mozFullScreenEnabled","webkitFullscreenEnabled","msFullscreenEnabled","getFullscreenElement","fullscreenElement","mozFullScreenElement","webkitFullscreenElement","msFullscreenElement","resizeElement","lastFullscreenElement","dataset","normalWidth","normalHeight","exitFullscreen","msExitFullscreen","mozCancelFullScreen","webkitExitFullscreen","screen","requestFullscreen","msRequestFullscreen","mozRequestFullScreen","webkitRequestFullscreen","setSpin","setRock","pclamp","bbSize","minSize","aspectFactor","catch","impostorTypes","eachComponent","getComponentsByName","getRepresentationsByName","sc","ShapeComponent","__decorate","decorators","desc","getOwnPropertyDescriptor","Reflect","decorate","AtomindexColormaker","scalePerModel","BfactorColormaker","bfactorScale","ChainidColormaker","chainidDictPerModel","chainidDict","ChainindexColormaker","ChainnameColormaker","chainnameDictPerModel","chainnameDict","DensityfitColormaker","rsrzDict","rsccDict","rsrzScale","rsccScale","rsrz","rscc","partialCharges","CZ","CG","OD1","CB","OD2","OE1","OE2","CD2","CE1","ND1","NE2","NZ","SD","PTR","O1P","O2P","O3P","OG1","SEP","TPO","CD1","CE2","CE3","NE1","OH","ElectrostaticColormaker","hCharges","charges","hPositions","hPos","backboneNHPosition","bbox","hStore","buildStoreLike","hHash","ElementColors","UUT","UUP","UUH","ElementColormaker","EntityindexColormaker","entityindexScale","EntitytypeColormaker","entityType","GeoqualityColormaker","geoAtomDict","geoDict","geoProblemCount","geoAtom","atomProblems","HydrophobicityColormaker","resHF","defaultResidueHydrophobicity","hfScale","ModelindexColormaker","modelindexScale","MoleculetypeColormaker","OccupancyColormaker","occupancyScale","PartialchargeColormaker","partialchargeScale","randomColor","RandomColormaker","RandomcoilindexColormaker","rciDict","rciScale","rci","ResidueindexColormaker","scalePerChain","ResidueColors","ASX","GLX","DA","DG","DI","DX","DC","DT","DU","DD","ResnameColormaker","StructureColors","SstrucColormaker","StructuredataColormaker","_a","_b","UniformColormaker","valueColor","ValueColormaker","valueScale","VolumeColormaker","nxy","i1y","i1z","iyz","i1yz","vy","vz","v1y","v1z","vyz","v1yz","xd","c00","c01","c10","c11","c0","StructureRepresentation","radiusSize","biomolOptions","defaultScale","setRadius","getQuality","getAssembly","needsBuild","sview","createData","updateData","getRadiusParams","param","getAtomParams","getBondParams","MeasurementRepresentation","labelVisible","labelFontFamily","monospace","serif","labelFontStyle","italic","labelFontWeight","bold","labelsdf","labelXOffset","labelBackground","labelBackgroundColor","labelBackgroundMargin","labelBackgroundOpacity","labelFixedSize","labelFontstyle","textData","textBuffer","getLabelBufferParams","fontStyle","fontWeight","sdf","xOffset","attachment","showBorder","borderColor","borderWidth","showBackground","backgroundMargin","backgroundOpacity","fixedSize","parseNestedAtoms","nSets","order","selected","_break","Number","isInteger","calcArcPoint","edt","edt1d","MIN_SAFE_INTEGER","MAX_SAFE_INTEGER","TextAtlasCache","TextAtlasDefaultParams","font","variant","weight","TextAtlas","mapped","scratchW","scratchH","currentX","currentY","cutoff","lineHeight","maxWidth","fillStyle","textAlign","textBaseline","lineJoin","gridOuter","gridInner","canvas2","context2","placeholder","CanvasTexture","draw","measureText","clearRect","fillText","TextBufferDefaultParameters","fontSize","TextBufferParameterTypes","getCharCount","charCount","TextBuffer","fontTexture","inputTexCoord","inputSize","aPosition","aColor","txt","iChar","nChar","iCharAll","textAtlas","getTextAtlas","inputMapping","xadvance","xShift","yShift","texWidth","texHeight","texCoords","FIXED_SIZE","WideLineBufferDefaultParameters","WideLineBufferParameterTypes","WideLineBuffer","AngleRepresentation","vectorVisible","sectorVisible","atomPosition","okay","outPosition","outIdx","validatePositions","atomTriplePositions","angleData","labelPosition","labelText","vectorPosition1","vectorPosition2","arcPositionTmp1","arcPositionTmp2","sectorPositionTmp","totalSegments","v21","v23","cross2","labelTmp","arcPoint","crossLength","toFixed","nSegments","sectorVertices","arcVertices1","arcVertices2","appendArcSection","arcSize","sectorSize","arcPosition1","arcPosition2","sectorPosition","sectorOffset","arcOffset","getAngleData","vectorBuffer","arcLength","arcBuffer","sectorLength","sectorBuffer","vectorData","arcData","sectorData","eye","CylinderGeometryBufferDefaultParameters","getGeo","makeRotationX","CylinderBufferGeometry","CylinderGeometryBuffer","geoLength","__center","_color","_from","_to","meshData","MappedAlignedBoxBuffer","CylinderImpostorBufferDefaultParameters","CylinderImpostorBufferParameterTypes","CylinderImpostorBuffer","CAP","CylinderBuffer","AxesRepresentation","showAxes","showBox","getAxesData","pa","en","vertexPosition","vertexColor","vertexRadius","edgePosition1","edgePosition2","edgeColor","edgeRadius","addAxis","offset2","addCorner","d3","addScaledVector","edgeOffset","addEdge","edge","axesData","sphereBuffer","cylinderBuffer","sphereData","cylinderData","BallAndStickRepresentation","cylinderOnly","symmetric","lineBuffer","lineData","BackboneRepresentation","BaseRepresentation","Interpolator","vec1","vec2","vDir","vTan","vNorm","vBin","interpolateToArr","interpolateToVec","interpolatePosition","interpolateTangent","vectorSubdivide","interpolationFn","iterator","getTangent","interpolateNormalDir","u0","u1","u2","u3","norm","bin","interpolateNormal","getNormalDir","iterDir1","iterDir2","vSub1","vSub2","vSub3","vSub4","d1v1","d1v2","d1v3","d1v4","d2v1","d2v2","d2v3","d2v4","interpolateColor","item1","item2","colFn","interpolatePicking","pickFn","interpolateSize","sizeFn","Spline","directional","positionIterator","subdiv","smoothSheet","interpolator","getAtomIterator","cache2","apPrev","apNext","getSubdividedColor","nCol","getSubdividedPicking","getSubdividedPosition","getSubdividedOrientation","normals","getNormals","tangent","binormal","getSubdividedSize","nSize","nPos","nTan","nNorm","vTangent","vMeshNormal","TubeMeshBufferDefaultParameters","capped","TubeMeshBuffer","capVertices","capTriangles","xi","size2","meshPrimitiveId","normX","normY","normZ","biX","biY","biZ","posX","posY","posZ","cxArr","cyArr","cx1Arr","cy1Arr","cx2Arr","cy2Arr","cx1","cy1","cx2","cy2","radialSegments1","irs","irs1","strip","CartoonRepresentation","NaN","getSplineParams","getSpline","getAspectRatio","polymerList","subPos","subOri","subCol","subPick","subSize","ContactRepresentation","angstrom","dataParams","contactData","unit","getLabelData","DihedralRepresentation","extendLine","lineVisible","dihedralData","lineTmp1","lineTmp2","sectorTmp","planeTmp","totalLines","totalPlanes","p4","v34","inPlane1","inPlane2","improperStart","improperEnd","nLines","nPlanes","line1","line2","sector","plane","li","nSuccess","linePosition1","linePosition2","planePosition","lineOffset","planeOffset","lp1","lp2","pp","getDihedralData","lineLength","lineColor","planeLength","planeBuffer","planeData","createUpdatedObject","updateSource","hasKey","obj","createColorArray","arrayLength","targetArray","DihedralHistogramRepresentation","histogramsData","histogramBinBorderVisible","scaleBinToSectorArea","histogramBinBorderColor","adjacentBondArrowColor","distantBondArrowColor","frontHistogramColor","backHistogramColor","opaqueMiddleDiscColor","histogramOpacity","opaqueMiddleDiscVisible","opaqueMiddleDiscOpacity","histogramBinBorderWidth","histogramBinBorderOpacity","bondArrowVisible","bondArrowWidth","bondArrowOpacity","specificColorData","getHistogramBinBorderBufferParameters","getBondArrowsBufferParameters","getOpaqueMiddleDiscBufferParameters","getHistogramBufferParameters","atomPositions","scaleData","Float32Concat","arrays","lengths","accumulatedOffset","createWideLineBuffer","linesList","startPoints","endPoints","startColors","endColors","createMeshBuffer","triangleColors","histogram360Scaled","histogram360","dihedralDataArray","currentHistogramData","calculateDihedralHistogram","frontHistogramBinBordersBuffer","frontHistogramBinBorders","backHistogramBinBordersBuffer","backHistogramBinBorders","adjacentBondArrowsBuffer","adjacentBondArrows","distantBondArrowsBuffer","distantBondArrows","opaqueMiddleDiscBuffer","opaqueMiddleDisc","frontHistogramBuffer","frontHistogram","backHistogramBuffer","backHistogram","histogramData","positionOfDihedralAtoms","histogram","totalSectorTrianglesInOpaqueMiddleDisc","frontAndBack","v32","cross1","dihedralAtomVectors","absAngle","maxHist","histBinAngleStep","setHistogramBinCoordinates","ind","zeroDegreeVector","crossVector","startOffset","scalingFactor","setOneSideHistogram","discHistogram","binBorders","sectionIndex","opaqueCircleSectorAngleStep","DistanceRepresentation","useCylinder","getDistanceData","pair","distanceData","bondParams","distanceBuffer","VectorBufferDefaultParameters","VectorBuffer","HelixorientRepresentation","LicoriceRepresentation","MappedBoxBuffer","HyperballStickImpostorBufferDefaultParameters","shrink","HyperballStickImpostorBufferParameterTypes","HyperballStickImpostorBuffer","HyperballStickBuffer","calculateMinArray","HyperballRepresentation","stickData","LabelFactory","errorLogged","atomLabel","aa1","res","qualified","LabelRepresentation","labelType","labelFormat","labelGrouping","getTextData","labelFactory","positionN","sizeN","colorN","getLoneAtomSet","LineRepresentation","crosses","lone","all","crossSize","_crossData","crossData","attrSize","cPosition1","cPosition2","cColor","cColor2","cOffset","cimax","crossBuffer","bufferIdx","lineAttributes","crossAttributes","makeGrid","DataCtor","elemSize","EDTSurface","coordList","pLength","pWidth","pHeight","ptran","depty","widxz","cutRadius","setAtomID","vpBits","vpDistance","vpAtomID","btype","_probeRadius","_scaleFactor","_cutoff","_setAtomID","boundingatom","INOUT","ISDONE","ISBOUND","txz","tdept","sradius","tradius","widxzR","deptyName","indx","fillatom","ox","oy","oz","mj","mk","sk","ii","jj","kk","deptyAtNind","deptyAt","nind","pWH","ci2","fillvoxels","fillAtomWaals","fastdistancemap","boundPoint","cutRSq","totalsurfacevox","inarray","positin","outarray","positout","fastoneshell","cutoffSq","tx","ty","tz","square","nbj","tnvix","tnviy","tnviz","getVolume","tk","buildboundary","fillvoxelswaals","stype","marchingcubeinit","vd","makeAVHash","atomsX","atomsY","atomsZ","atomsR","nAtoms","hashFunc","minW","iDim","jDim","kDim","nCells","jkDim","preHash","cid","cellOffsets","cellLengths","maxCellLength","subArray","cellLength","neighbourListLength","withinRadii","rExtra","nearI","nearJ","nearK","loI","loJ","loK","hiI","hiJ","hiK","iOffset","jOffset","cellStart","cellEnd","rSum","AVSurface","probePositions","gridx","gridy","gridz","sinTable","cosTable","lastClip","atob","ngTorus","_probePositions","rExt","surfGrid","fillGridDim","initializeGrid","initializeAngleTables","obscured","singleAtomObscures","ra2","projectPoints","ar","ar2","ng","iax","iay","iaz","minx","miny","minz","maxx","maxy","maxz","xoffset","dxy2","xyoffset","spx","spy","spz","dd","projectTorus","dmp","normalToLine","rInt","cost","sint","px","py","pz","projectTorii","fixNegatives","fixAtomIDs","MolecularSurface","_getAtomData","MolecularSurfaceRepresentation","vws","sas","ses","av","__infoList","__forceNewMolsurf","prepareData","molsurf","sviewFilter","maxDim","asWithin","getSurfaceParams","__sele","__surfaceParams","after","contourBuffer","doubleSidedBuffer","PointRepresentation","pointData","RibbonBuffer","aNormal","aSize","aDir","aPrimitiveId","currSize","prevSize","RibbonRepresentation","RocketRepresentation","axisList","helixbundleList","helixbundle","axisData","RopeRepresentation","SpacefillRepresentation","TraceBuffer","linePosition","TraceRepresentation","TubeRepresentation","UnitcellRepresentation","defaultRadius","cbrt","getUnitcellData","unitcellData","ValidationRepresentation","clashData","getClashData","ConeBufferDefaultParameters","ConeBuffer","ConeBufferGeometry","_position1","_position2","GeometryGroup","geometryList","empty","ArrowBufferDefaultParameters","ArrowBuffer","splitPosition","cylinderRadius","makeAttributes","coneBuffer","vFrom","vTo","vSplit","fullLength","coneLength","BoxBuffer","BoxBufferGeometry","_heightAxis","_depthAxis","_size","EllipsoidBufferDefaultParameters","EllipsoidBuffer","_majorAxis","_minorAxis","OctahedronBuffer","OctahedronBufferGeometry","TetrahedronBuffer","TetrahedronBufferGeometry","TorusBufferDefaultParameters","radiusRatio","tubularSegments","TorusBuffer","TorusBufferGeometry","Parser","_beforeParse","_parse","_afterParse","StructureParser","structureBuilder","Entity","description","chainIndexList","entityTypeFromString","entityFromType","isNonPolymer","isMacrolide","DefaultBoxParams","Unitcell","alphaRad","betaRad","gammaRad","cosAlpha","cosBeta","cosGamma","sinBeta","sinGamma","cStar","cosAlphaStar","cornerOffset","divideScalar","centerArray3","HelixTypes","dAminoAcids","entityKeyList","reWhitespace","getModresId","PdbParser","hex","isLegacy","headerLine","headerId","legacyId","isPqr","isPdbqt","serialRadix","resnoRadix","currentCoord","doFrames","currentBiomol","currentPart","currentMatrix","recordName","startChain","startResi","startIcode","endChain","endResi","endIcode","serialDict","unitcellDict","entityDataList","currentEntityData","currentEntityKey","hetnameDict","modresDict","chainDict","chainIdx","currentChainname","seqresDict","currentSeqresChainname","modelIdx","pendingStart","ls","modresId","fromIdx","toIdx","helixType","seqresChainname","keyEnd","biomt","biomtElms","ncsName","ncs","ncsRow","ncsElms","origx","orgix","origxRow","origxElms","scaleRow","scaleElms","aLength","bLength","cLength","sGroup","_parseChunkOfLines","ei","residueDict","reQuotedWhitespace","reDoubleQuote","reTrimQuotes","reAtomSymbol","trimQuotes","hasValue","cifDefaults","getBondOrder","valueOrder","CifParser","rawline","authAsymId","authSeqId","labelSeqId","labelAtomId","labelCompId","labelAsymId","labelEntityId","labelAltId","groupPDB","typeSymbol","pdbxPDBmodelNum","pdbxPDBinsCode","CartnX","CartnY","CartnZ","bIsoOrEquiv","cif","asymIdDict","chainIndexDict","pendingString","currentString","pendingValue","pendingLoop","pendingName","loopPointers","currentLoopIndex","currentCategory","currentName","pointerNames","modelNum","keyParts","category","keyValuePair","_modelNum","frameOffset","occ","assignedChainname","entityId","chem_comp","chem_comp_atom","struct","cc","cca","ccb","chem_comp_bond","atomnameDict","comp_id","atom_id","type_symbol","model_Cartn_x","model_Cartn_y","model_Cartn_z","pdbx_component_comp_id","pdbx_residue_numbering","pdbx_model_Cartn_x_ideal","pdbx_model_Cartn_y_ideal","pdbx_model_Cartn_z_ideal","atom_id_1","atom_id_2","value_order","parseChemComp","atom_site_type_symbol","atom_site_label","atom_site_fract_x","cell_length_a","cell_length_b","cell_length_c","cell_angle_alpha","cell_angle_beta","cell_angle_gamma","typeSymbolMap","atom_site_fract_y","atom_site_fract_z","atom_site_occupancy","ml","identityMatrix","covalentI","parseCore","begIcode","struct_conf","pdbx_PDB_helix_class","beg_auth_seq_id","pdbx_beg_PDB_ins_code","pdbx_end_PDB_ins_code","beg_label_asym_id","end_label_asym_id","end_auth_seq_id","ssr","struct_sheet_range","processSecondaryStructure","operDict","pdbx_struct_oper_list","biomolOp","elms","pdbx_struct_assembly_gen","gen","getMatrixDict","expr","es","assembly_id","oe","oper_expression","md1","md2","k1","k2","asym_id_list","struct_ncs_oper","ncsOp","ncsPart","cell","length_a","length_b","length_c","angle_alpha","angle_beta","angle_gamma","symmetry","database_PDB_matrix","origxMat","atom_sites","scaleMat","processSymmetry","struct_conn","atomIndicesCache","connTypeId","conn_type_id","ptnr1_symmetry","ptnr2_symmetry","inscode1","pdbx_ptnr1_PDB_ins_code","altloc1","pdbx_ptnr1_label_alt_id","ptnr1_auth_seq_id","ptnr1_label_asym_id","ptnr1_label_atom_id","selection1","inscode2","pdbx_ptnr2_PDB_ins_code","altloc2","pdbx_ptnr2_label_alt_id","ptnr2_auth_seq_id","ptnr2_label_asym_id","ptnr2_label_atom_id","selection2","tmpA","tmpB","pdbx_value_order","processConnections","pdbx_description","processEntities","entry","pdbx_audit_revision_history","revision_date","dates","releaseDate","pdbx_database_status","recvd_initial_deposition_date","depDates","depositionDate","database_PDB_rev","date","date_original","reflns","d_resolution_high","refine","ls_d_res_high","ls_R_factor_R_free","rFree","ls_R_factor_R_work","rWork","exptl","method","experimentalMethods","firstLines","lpos","ypos","zpos","modelLineCount","lineNo","AllFields","ctor","typedArray","getDataView","getInt8View","getInt32View","decodeInt16","i2","decodeInt32","i4","decodeInteger","intArray","divisor","invDiv","decodeRun","dataOffset","decodeDelta","decodePacking","int16or8","upperLimit","lowerLimit","decodeIntegerPacking","decodeIntegerDeltaPacking","unpacked","decodeIntegerDelta","decodeMsgpack","dataView","performDecoding","dvOut","dvIn","decodeFloat32","decodeIntegerRun","decodeMmtf","inputDict","ignoreFields","outputDict","dv","ignore","SstrucMap","groupData","numBonds","numAtoms","numGroups","numChains","numModels","chainsPerModel","structureId","groupsPerChain","groupList","groupTypeList","atomNameList","frameAtomOffset","xCoordList","yCoordList","zCoordList","bAtomIndex1","bAtomIndex2","bBondOrder","aGroupIndex","aFormalCharge","gChainIndex","gAtomOffset","gAtomCount","cModelIndex","cGroupOffset","cGroupCount","mChainOffset","mChainCount","modelChainCount","groupOffset","chainGroupCount","bondOffset","groupAtomCount","groupFormalChargeList","formalChargeList","groupBondAtomList","bondAtomList","groupBondOrderList","bondOrderList","atomIdList","bFactorList","altLocList","occupancyList","groupIdList","secStructList","insCodeList","chainNameList","chainIdList","groupTypeDict","groupType","elementList","hetFlag","numGroupBonds","groupName","resAtomOffset","secStructLength","bioAssemblyList","_assembly","chainToPart","transformList","_transform","ncsOperatorList","ncsAssembly","_operator","unitCell","spaceGroup","bondTypes","am","du","un","moleculeLineNo","modelAtomIdxStart","currentRecordType","reItem","SdfParser","headerLines","sdfData","mItem","atomStart","bondStart","bondEnd","currentItem","currentData","isV3000","isAtomBlock","isBondBlock","acc","atomindexToStoreindex","chgTok","find","chargeCount","coffset","atomIdx","cToken","_postProcess","parseIntSubstr","PrmtopParser","pointersDict","pointers","atomNames","radii","residueLabels","residuePointers","curIdx","bondIdx","lt","NATOM","NBONH","MBONA","NRES","curResIdx","curResname","curResno","reTitle","lastSegid","segid","reField","molecules","moleculetypeDict","currentMoleculetype","fieldMatch","cIdx","molName","molCount","molType","lastResno","resIdx","chainidIdx","chainnameIdx","TrajectoryParser","notNetcdf","statement","reason","TypeError","readName","nameLength","nextPos","intView","ef","isCharmm","extraBlock","fourDims","NSET","ISTART","NSAVC","NAMNF","DELTA","titleLength","titlePos","TITLE","natom","natom4","BYTE","CHAR","SHORT","INT","DOUBLE","num2str","num2bytes","str2num","readNumber","bufferReader","numbers","readType","trimNull","ZERO","NC_DIMENSION","NC_VARIABLE","NC_ATTRIBUTE","version","recordDimension","dimList","dimensions","recordId","dimensionSize","dimensionsList","globalAttributes","attributesList","variables","varList","recordStep","variableSize","dimensionality","dimensionsIds","varSize","record","variablesList","gAttList","gAtt","NetcdfReader","hasDataVariable","variableName","findIndex","getDataVariable","variable","currentOffset","nonRecord","NctrajParser","netcdfReader","versionSize","virSize","presSize","coordSize","velocitySize","forceSize","natoms","floatSize","natoms3","frameCoords","MagicInts","sizeOfInt","num","numOfBits","_tmpBytes","sizeOfInts","numOfInts","sizes","numOfBytes","bytecnt","decodeBits","cbuf","buf2","mask","lastBB0","lastBB1","cnt","_tmpIntBytes","decodeInts","nums","minMaxInt","sizeint","bitsizeint","sizesmall","thiscoord","prevcoord","lfp","lsize","bitsize","smallidx","tmpIdx","smaller","smallnum","adz","invPrecision","buf8","isSmaller","tmpSwap","VolumeParser","getMatrix","reScientificNotation","bohrToAngstromFactor","CubeParser","originX","originY","originZ","NVX","NVY","NVZ","basisX","basisY","basisZ","oribitalFlag","lj","Dsn6Parser","summand","byteView","brixStr","xStart","yStart","zStart","xExtent","yExtent","zExtent","xRate","yRate","zRate","xlen","ylen","zlen","xBlocks","yBlocks","zBlocks","zz","yy","xx","nxyz","mapcrs","DxParser","headerInfo","parseHeaderLines","dataLineStart","headerByteCount","deltaLineCount","xmin","ymin","zmin","hx","hy","hz","uint8ToLines","MrcParser","floatView","MAP","MACHST","NX","NY","MODE","NXSTART","NYSTART","NZSTART","MX","MY","MZ","MAPC","MAPR","MAPS","DMIN","DMAX","ISPG","NSYMBT","LSKFLG","b1","b0","parseNumberLine","XplorParser","infoStart","dataStart","gridInfo","AMIN","AMAX","BMIN","BMAX","NC","CMIN","CMAX","cellInfo","lineSection","RAVE","RSIGMA","hsvToRgb","ColorDict","red","orange","gold","yellow","lime","green","sea","cyan","sky","blue","purple","magenta","hotpink","pink","peach","lilac","pinktint","peachtint","yellowtint","greentint","bluetint","lilactint","white","gray","brown","deadwhite","deadblack","invisible","reWhitespaceComma","reCurlyWhitespace","reTrimCurly","reCollapseEqual","parseListDef","defaultColor","master","lm","listName","listColor","listMasters","listWidth","parseListElm","lineBreak","triangleBreak","lsindex","literal","isLineBreak","isTriangleBreak","parseStr","parseFlag","parseGroup","flags","groupFlags","groupMasters","kinemage","onewidth","pdbfile","texts","captions","caption","groupDict","subgroupDict","masterDict","pointmasterDict","dotLists","vectorLists","ballLists","ribbonLists","currentGroupMasters","currentSubgroupMasters","dotDefaultColor","dotLabel","dotPosition","dotColor","vecDefaultColor","vecDefaultWidth","vecLabel1","vecLabel2","vecPosition1","vecPosition2","vecColor1","vecColor2","ballRadius","ballDefaultColor","ballLabel","ballPosition","ballColor","ribbonListDefaultColor","ribbonPointLabelArray","ribbonPointPositionArray","ribbonPointBreakArray","ribbonPointColorArray","isDotList","prevDotLabel","isVectorList","prevVecLabel","prevVecPosition","prevVecColor","isBallList","prevBallLabel","isRibbonList","prevRibbonPointLabel","isCaption","masterArray","labelArray","colorArray","indent","label1Array","label2Array","position1Array","position2Array","color1Array","color2Array","radiusArray","breakArray","splitLine","singlePointLine","dominant","convertedLists","listObject","convertedRibbonObject","editedLabels","editedPositions","editedColors","editedBreaks","breakPointer","positionPointer","removePointBreaksTriangleArrays","ribbonObject","convertedLabels","convertedBreaks","convertedPositions","convertedColors","vector3Positions","convertKinTriangleArrays","SurfaceParser","getLoader","OBJLoader","regexp","vertex_pattern","normal_pattern","uv_pattern","face_vertex","face_vertex_uv","face_vertex_uv_normal","face_vertex_normal","object_pattern","smoothing_pattern","material_library_pattern","material_use_pattern","setPath","_createParserState","objects","startObject","fromDeclaration","parseVertexIndex","parseNormalIndex","addVertex","addVertexLine","addNormal","addFace","nd","vLen","ib","ic","nLen","addLineGeometry","vi","lineFirstChar","lineSecondChar","trimLeft","lineParts","lineVertices","lineUVs","llen","parts","buffergeometry","PLYLoader","propertyNameMapping","setPropertyNameMapping","bin2str","isASCII","parseHeader","parseASCII","parseBinary","headerText","headerLength","currentElement","lineType","lineValues","propertValues","comments","countType","itemType","parseASCIINumber","parseASCIIElement","currentElementCount","useColor","handleElement","postProcess","colors","elementsNeedUpdate","elementName","setRGB","vertexIndices","vertex_indices","Face3","binaryRead","dataview","binaryReadElement","loc","table","reDelimiter","msgpack","netcdf","TextParser","reStrip","reTag","reContent","reAttr","parseXml","declaration","root","tag","eos","is","child","re","prefix","XmlParser","useDomParser","__xmlParser","__domParser","DOMParser","parseFromString","Document","getNamedItem","getSele","useAltcode","icode","altcode","getResSele","setBitDict","bit","hasAttrValue","getProblemCount","clashDict","ga","clashes","getElementsByTagName","Validation","atomDict","clashSele","fromXml","entries","chemicalShiftLists","randomCoilIndices","rcia","_clashDict","clashList","seleAttr","createAttribute","setNamedItem","atomSele","res1","res2","mogBondOutliers","mogAngleOutliers","vPos1","vPos2","getAtomSele","dHalf","shrinkBuf","arraySet","dest","src_offs","dest_offs","adler32","adler","crcTable","makeTable","crc32","crc","BAD$1","TYPE$1","inflate_fast","strm","_in","last","_out","dmax","wsize","whave","wnext","s_window","lcode","dcode","lmask","dmask","here","op","from_source","next_in","avail_in","next_out","avail_out","lencode","distcode","lenbits","distbits","dolen","dodist","sane","MAXBITS","ENOUGH_LENS$1","ENOUGH_DISTS$1","CODES$1","LENS$1","DISTS$1","lbase","lext","dbase","dext","inflate_table","lens","lens_index","codes","table_index","work","incr","here_bits","here_op","here_val","curr","drop","used","huff","base_index","offs","extra","extra_index","LENS","DISTS","Z_OK","Z_STREAM_ERROR","HEAD","TYPE","BAD","ENOUGH_LENS","ENOUGH_DISTS","zswap32","InflateState","havedict","check","total","wbits","ncode","nlen","ndist","have","lendyn","distdyn","was","inflateReset","total_in","total_out","inflateResetKeep","inflateInit2","windowBits","inflateReset2","lenfix","distfix","virgin","fixedtables","updatewindow","flush","put","last_bits","last_op","last_val","hbuf","inf_leave","xflags","os","extra_len","hcrc","data_type","inflateSetDictionary","dictionary","dictLength","STR_APPLY_OK","STR_APPLY_UIA_OK","__","_utf8len","string2buf","m_pos","str_len","buf_len","buf2string","c_len","utf16buf","_buf2binstring","utf8border","Z_OK$1","messages","ZStream","GZheader","Inflate","sources","source","raw","err","ended","_mode","next_out_utf8","tail","utf8str","allowBufError","binstring2buf","onEnd","onData","inflateEnd","flattenChunks","decompressedData","inflator","ungzip","Datasource","mmtfBaseUrl","mmtfFullUrl","mmtfReducedUrl","pdbid","baseUrl","suffixUrl","PassThroughDatasource","suffixURL","uniprotid","reProtocol","StaticDatasource","relativePath","pn","pathname","basePath","getAbsolutePath","MdsrvDatasource","getListing","jsonData","frameIndex","getPathUrl","IntegerParam","NumberParam","RangeParam","SelectParam","UIStageParameters","Version"],"mappings":"grCAQM,SAAUA,GAAUC,GACxB,GAAsB,oBAAXC,OAAwB,OAEnC,MACMC,EADI,IAAIC,OAAO,GAAGH,eACZI,KAAKH,OAAOI,SAASC,QAEjC,OAAIJ,EACKK,mBAAmBL,EAAE,SAE5B,CAEJ,CAcgB,SAAAM,GAAUC,EAAYC,GACpC,YAAiBC,IAAVF,EAAsBA,EAAQC,CACvC,CAEgB,SAAAE,GAAiBC,EAAgCC,GAC/D,MAAMC,EAASC,OAAOC,OAAO,CAAE,EAAEJ,GACjC,IAAK,MAAMK,KAAKJ,EAAe,MAEfH,IADAE,EAAOK,KACIH,EAAEG,GAAKJ,EAAcI,GAC/C,CACD,OAAOH,CACT,CAEgB,SAAAI,GAAiBN,EAAWO,GAC1C,IAAK,MAAMF,KAAKE,EAAW,CACzB,MAAMX,EAAQW,EAAUF,QACVP,IAAVF,IAAqBI,EAAOK,GAAKT,EACtC,CACD,OAAOI,CACT,CAUgB,SAAAQ,GAASC,EAAcC,GACrCA,EAAMf,GAASe,EAAK,IACpB,IAAK,IAAIC,EAAI,EAAGA,EAAIF,EAAMG,OAAQD,IAC5BE,MAAMC,QAAQL,EAAME,IACtBH,GAAQC,EAAME,GAAID,GAElBA,EAAIK,KAAKN,EAAME,IAGnB,OAAOD,CACT,UAEgBM,KACd,MAAMC,EAAW7B,OAAOI,SAASyB,SACjC,OAAyC,OAAlCA,EAASC,MAAM,eAA0B,QAAUD,CAC5D,UAEgBE,KACd,GAAsB,oBAAX/B,OAAwB,OAAO,EAE1C,MAAMgC,EAAKhC,OAAOiC,UAAUC,UAE5B,MAAI,YAAYC,KAAKH,GACZ,QACE,UAAUG,KAAKH,G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AAI,GACrCtiJ,aAAcqiJ,GAAa,KAAQ,GACnCzoG,QAnDgC,CAAEh7E,KAAM,WAoDxC4hH,YAAagiE,MAAeh4L,OAAOgJ,KAAKymF,MCjD1C,MAAMyoG"} \ No newline at end of file diff --git a/dist/ngl.js b/dist/ngl.js index f3e97f86..8762ec3a 100644 --- a/dist/ngl.js +++ b/dist/ngl.js @@ -84,5 +84,5 @@ _.brewer=x={OrRd:["#fff7ec","#fee8c8","#fdd49e","#fdbb84","#fc8d59","#ef6548","# * * @param {Float32Array} points - points * @param {Function} metric - metric - */class Gm{constructor(e,t){this.points=e,this.metric=t,this.maxDepth=0,this.currentNode=0;const i=e.length/3,n=new Uint32Array(i);for(let e=0;ethis.maxDepth&&(this.maxDepth=e);const r=n-i;if(0===r)return-1;const s=4*this.currentNode,o=this.nodes;if(this.currentNode+=1,1===r)return o[s]=i,o[s+1]=-1,o[s+2]=-1,o[s+3]=t,s;const a=this.indices,c=this.points,l=i+Math.floor(r/2),h=e%3;let u,d,f,m,p,g=i,v=n-1;for(;v>g;){for(f=g+v>>1,m=c[3*a[f]+h],d=a[f],a[f]=a[v],a[v]=d,p=g,u=g;u-e[1])),r=this.nodes,s=this.points,o=this.indices,a=c=>{let l,h;const u=this.getNodeDepth(c)%3,d=3*o[r[c]],f=[s[d+0],s[d+1],s[d+2]],m=this.metric(e,f);function p(e,i){n.push([e,i]),n.size()>t&&n.pop()}const g=r[c+1],v=r[c+2];if(-1===v&&-1===g)return void((n.size()s[3*o[r[e]]+n])throw new Error("left child is > parent!");i+=this.verify(a,t+1)}if(-1!==c){if(s[3*o[r[c]]+n]0}isBackbone(){const e=this.residueType.backboneIndexList;return e.length>0&&e.includes(this.index-this.residueAtomOffset)}isPolymer(){if(this.structure.entityList.length>0)return this.entity.isPolymer();{const e=this.residueType.moleculeType;return 3===e||4===e||5===e}}isSidechain(){return this.isPolymer()&&!this.isBackbone()}isCg(){const e=this.residueType.backboneType;return 4===e||5===e||6===e}isTrace(){return this.index===this.residueType.traceAtomIndex+this.residueAtomOffset}isHetero(){return 1===this.residueType.hetero}isProtein(){return 3===this.residueType.moleculeType}isNucleic(){const e=this.residueType.moleculeType;return 4===e||5===e}isRna(){return 4===this.residueType.moleculeType}isDna(){return 5===this.residueType.moleculeType}isWater(){return 1===this.residueType.moleculeType}isIon(){return 2===this.residueType.moleculeType}isSaccharide(){return 6===this.residueType.moleculeType}isHelix(){return od.includes(this.sstruc)}isSheet(){return ad.includes(this.sstruc)}isTurn(){return cd.includes(this.sstruc)&&this.isProtein()}isBonded(){return 0!==this.bondHash.countArray[this.index]}isRing(){return void 0!==this.residueType.getRings().atomRings[this.index-this.residueAtomOffset]}isAromatic(){return 1===this.aromatic}isPolarHydrogen(){let e=!1;return 1!==this.number||(e=!this.hasBondToElement(6)),e}isMetal(){return this.atomType.isMetal()}isNonmetal(){return this.atomType.isNonmetal()}isMetalloid(){return this.atomType.isMetalloid()}isHalogen(){return this.atomType.isHalogen()}isDiatomicNonmetal(){return this.atomType.isDiatomicNonmetal()}isPolyatomicNonmetal(){return this.atomType.isPolyatomicNonmetal()}isAlkaliMetal(){return this.atomType.isAlkaliMetal()}isAlkalineEarthMetal(){return this.atomType.isAlkalineEarthMetal()}isNobleGas(){return this.atomType.isNobleGas()}isTransitionMetal(){return this.atomType.isTransitionMetal()}isPostTransitionMetal(){return this.atomType.isPostTransitionMetal()}isLanthanide(){return this.atomType.isLanthanide()}isActinide(){return this.atomType.isActinide()}getDefaultValence(){return this.atomType.getDefaultValence()}getValenceList(){return this.atomType.getValenceList()}getOuterShellElectronCount(){return this.atomType.getOuterShellElectronCount()}distanceTo(e){const t=this.atomStore,i=e.atomStore,n=this.index,r=e.index,s=t.x[n]-i.x[r],o=t.y[n]-i.y[r],a=t.z[n]-i.z[r],c=s*s+o*o+a*a;return Math.sqrt(c)}connectedTo(e){const t=this.atomStore,i=e.atomStore,n=this.index,r=e.index;if(t.altloc&&i.altloc){const e=t.altloc[n],s=i.altloc[r];if(0!==e&&0!==s&&32!==e&&32!==s&&e!==s)return!1}const s=t.x[n]-i.x[r],o=t.y[n]-i.y[r],a=t.z[n]-i.z[r],c=s*s+o*o+a*a;if(c<48&&this.isCg())return!0;if(isNaN(c))return!1;const l=this.covalent+e.covalent,h=l+.3,u=l-.5;return cu*u}positionFromArray(e,t=0){return this.x=e[t+0],this.y=e[t+1],this.z=e[t+2],this}positionToArray(e=[],t=0){const i=this.index,n=this.atomStore;return e[t+0]=n.x[i],e[t+1]=n.y[i],e[t+2]=n.z[i],e}positionToVector3(e){return void 0===e&&(e=new Zt),e.x=this.x,e.y=this.y,e.z=this.z,e}positionFromVector3(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}positionAdd(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}positionSub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}getResidueBonds(e=!1){const t=this.residueAtomOffset,i=this.index-this.residueAtomOffset,n=this.residueType.getBonds(),r=n.atomIndices1,s=n.atomIndices2;let o,a,c,l;for(e||(l=[]),o=r.indexOf(i);-1!==o;){if(c=s[o]+t,!l)return c;l.push(c),o=r.indexOf(i,o+1)}for(a=s.indexOf(i);-1!==a;){if(c=r[a]+t,!l)return c;l.push(c),a=s.indexOf(i,a+1)}return l}qualifiedName(e=!1){var t="";return this.resname&&!e&&(t+="["+this.resname+"]"),void 0!==this.resno&&(t+=this.resno),this.inscode&&(t+="^"+this.inscode),this.chainname&&(t+=":"+this.chainname),this.atomname&&(t+="."+this.atomname),this.altloc&&(t+="%"+this.altloc),this.structure.modelStore.count>1&&(t+="/"+this.modelIndex),t}clone(){return new Vm(this.structure,this.index)}toObject(){return{index:this.index,residueIndex:this.residueIndex,resname:this.resname,x:this.x,y:this.y,z:this.z,element:this.element,chainname:this.chainname,resno:this.resno,serial:this.serial,vdw:this.vdw,covalent:this.covalent,hetero:this.hetero,bfactor:this.bfactor,altloc:this.altloc,atomname:this.atomname,modelIndex:this.modelIndex}}}function Hm(e,t){const i=e[0]-t[0],n=e[1]-t[1],r=e[2]-t[2];return i*i+n*n+r*r}function jm(e,t){return Math.sqrt(Hm(e,t))}const Wm=new Float32Array(3);class qm{constructor(t,i=!1){e.Debug&&il.time("Kdtree build");const n=i?Hm:jm,r=new Float32Array(3*t.atomCount),s=new Uint32Array(t.atomCount);let o=0;t.eachAtom((function(e){r[o+0]=e.x,r[o+1]=e.y,r[o+2]=e.z,s[o/3]=e.index,o+=3})),this.atomIndices=s,this.points=r,this.kdtree=new Gm(r,n),e.Debug&&il.timeEnd("Kdtree build")}nearest(e,t,i){e instanceof Zt?e.toArray(Wm):e instanceof Vm&&e.positionToArray(Wm);const n=this.kdtree.nearest(Wm,t,i),r=this.kdtree.indices,s=this.kdtree.nodes,o=this.atomIndices,a=[];for(let e=0,t=n.length;e":"3/4-Z","?":"X-Y","@":"Y-X",A:"Z+1/3",B:"Z+2/3",C:"X+2/3",D:"Y+1/3",E:"-Y+2/3",F:"X-Y+1/3",G:"Y-X+2/3",H:"-X+1/3",I:"X+1/3",J:"Y+2/3",K:"-Y+1/3",L:"X-Y+2/3",M:"Y-X+1/3",N:"-X+2/3",O:"2/3+X",P:"1/3+Y",Q:"1/3+Z",R:"2/3-Y",S:"1/3+X-Y",T:"2/3+Y-X",U:"1/3-X",V:"2/3-X",W:"1/3-Y",X:"1/3-Z",Y:"2/3+Y",Z:"1/3+Y-X","[":"2/3+X-Y","]":"1/3+X","^":"2/3+Z",_:"2/3-Z","`":"5/6+Z",a:"1/6+Z",b:"5/6-Z",c:"1/6-Z",d:"Z+5/6",e:"Z+1/6",f:"Z+1/4",g:"+Y"},Ym={"P 1":" !#","P -1":" !#$%&","P 1 2 1":" !#$!&","P 1 21 1":" !#$'&","C 1 2 1":" !#$!&()#*)&","P 1 m 1":" !# %#","P 1 c 1":" !# %+","C 1 m 1":" !# %#()#(,#","C 1 c 1":" !# %+()#(,+","P 1 2/m 1":" !# %#$!&$%&","P 1 21/m 1":" !#$)&$%& ,#","C 1 2/m 1":" !# %#$!&$%&()#(,#*)&*,&","P 1 2/c 1":" !#$!-$%& %+","P 1 21/c 1":" !#$%&$)- ,+","C 1 2/c 1":" !#$!-$%& %+()#*)-*,&(,+","P 2 2 2":" !#$%#$!& %&","P 2 2 21":" !#$%+$!- %&","P 21 21 2":" !#$%#*)&(,&","P 21 21 21":" !#*%+$)-(,&","C 2 2 21":" !#$%+$!- %&()#*,+*)-(,&","C 2 2 2":" !#$%#$!& %&()#*,#*)&(,&","F 2 2 2":" !#$%#$!& %& )+$,+$)- ,-(!+*%+*!-(%-()#*,#*)&(,&","I 2 2 2":" !#$%# %&$!&.'/01/.120'2","I 21 21 21":" !#*%+$)-(,&()+$,#*!& %-","P m m 2":" !#$%# %#$!#","P m c 21":" !#$%+ %+$!#","P c c 2":" !#$%# %+$!+","P m a 2":" !#$%#(%#*!#","P c a 21":" !#$%+(%#*!+","P n c 2":" !#$%# ,+$)+","P m n 21":" !#*%+(%+$!#","P b a 2":" !#$%#(,#*)#","P n a 21":" !#$%+(,#*)+","P n n 2":" !#$%#(,+*)+","C m m 2":" !#$%# %#$!#()#*,#(,#*)#","C m c 21":" !#$%+ %+$!#()#*,+(,+*)#","C c c 2":" !#$%# %+$!+()#*,#(,+*)+","A m m 2":" !#$%# %#$!# )+$,+ ,+$)+","A b m 2":" !#$%# ,#$)# )+$,+ %+$!+","A m a 2":" !#$%#(%#*!# )+$,+(,+*)+","A b a 2":" !#$%#(,#*)# )+$,+(%+*!+","F m m 2":" !#$%# %#$!# )+$,+ ,+$)+(!+*%+(%+*!+()#*,#(,#*)#","F d d 2":" !#$%#345675 )+$,+3896:9(!+*%+;49<79()#*,#;85<:5","I m m 2":" !#$%# %#$!#()+*,+(,+*)+","I b a 2":" !#$%#(,#*)#()+*,+ %+$!+","I m a 2":" !#$%#(%#*!#()+*,+ ,+$)+","P 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!#","P 2/n 2/n 2/n":" !#$%#$!& %&*,-()-(,+*)+","P 2/c 2/c 2/m":" !#$%#$!- %-$%& !& %+$!+","P 2/b 2/a 2/n":" !#$%#$!& %&*,&()&(,#*)#","P 21/m 2/m 2/a":" !#*%#$!&(%&$%&(!& %#*!#","P 2/n 21/n 2/a":" !#*%#*)- ,-$%&(!&(,+$)+","P 2/m 2/n 21/a":" !#*%+*!- %&$%&(!-(%+$!#","P 21/c 2/c 2/a":" !#*%#$!-(%-$%&(!& %+*!+","P 21/b 21/a 2/m":" !#$%#*)&(,&$%& !&(,#*)#","P 21/c 21/c 2/n":" !#*,#$)-(%-$%&()& ,+*!+","P 2/b 21/c 21/m":" !#$%+$)- ,&$%& !- ,+$)#","P 21/n 21/n 2/m":" !#$%#*)-(,-$%& !&(,+*)+","P 21/m 21/m 2/n":" !#$%#*'&.,&*,&.'& %#$!#","P 21/b 2/c 21/n":" !#*,+$!-(,&$%&()- %+*)#","P 21/b 21/c 21/a":" !#*%+$)-(,&$%&(!- ,+*)#","P 21/n 21/m 21/a":" !#0%/$'&.12$%&.!2 1#0'/","C 2/m 2/c 21/m":" !#$%+$!- %&$%& !- %+$!#()#*,+*)-(,&*,&()-(,+*)#","C 2/m 2/c 21/a":" !#$,+$)- %&$%& )- ,+$!#()#*%+*!-(,&*,&(!-(%+*)#","C 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!#()#*,#*)&(,&*,&()&(,#*)#","C 2/c 2/c 2/m":" !#$%#$!- %-$%& !& %+$!+()#*,#*)-(,-*,&()&(,+*)+","C 2/m 2/m 2/a":" !#$,#$)& %&$%& )& ,#$!#()#*%#*!&(,&*,&(!&(%#*)#","C 2/c 2/c 2/a":" !#*,#$!&(,&$,-(!- ,+*!+()#$%#*)& %&*%- )-(%+$)+","F 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!# )+$,+$)- ,-$,- )- ,+$)+(!+*%+*!-(%-*%-(!-(%+*!+()#*,#*)&(,&*,&()&(,#*)#","F 2/d 2/d 2/d":" !#$%#$!& %&64=37=345675 )+$,+$)- ,-68>3:>3896:9(!+*%+*!-(%-<4>;7>;49<79()#*,#*)&(,&<8=;:=;85<:5","I 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!#()+*,+*)-(,-*,-()-(,+*)+","I 2/b 2/a 2/m":" !#$%#*)&(,&$%& !&(,#*)#()+*,+$!- %-*,-()- %+$!+","I 21/b 21/c 21/a":" !#*%+$)-(,&$%&(!- ,+*)#()+$,#*!& %-*,- )&(%#$!+","I 21/m 21/m 21/a":" !#$,#$)& %&$%& )& ,#$!#()+*%+*!-(,-*,-(!-(%+*)+","P 4":" !#$%#% #!$#","P 41":" !#$%+% 5!$9","P 42":" !#$%#% +!$+","P 43":" !#$%+% 9!$5","I 4":" !#$%#% #!$#()+*,+,(+)*+","I 41":" !#*,+%(5)$9()+$%#, 9!*5","P -4":" !#$%#!$&% &","I -4":" !#$%#!$&% &()+*,+)*-,(-","P 4/m":" !#$%#% #!$#$%& !&!$&% &","P 42/m":" !#$%#% +!$+$%& !&!$-% -","P 4/n":" !#$%#,(#)*#*,&()&!$&% &","P 42/n":" !#$%#,(+)*+*,-()-!$&% &","I 4/m":" !#$%#% #!$#$%& !&!$&% &()+*,+,(+)*+*,-()-)*-,(-","I 41/a":" !#*,+%(5)$9$,=(!>!$&,(-()+$%#, 9!*5*%> )=)*-% &","P 4 2 2":" !#$%#% #!$#$!& %&! &%$&","P 4 21 2":" !#$%#,(#)*#*)&(,&! &%$&","P 41 2 2":" !#$%+% 5!$9$!& %-! >%$=","P 41 21 2":" !#$%+,(5)*9*)=(,>! &%$-","P 42 2 2":" !#$%#% +!$+$!& %&! -%$-","P 42 21 2":" !#$%#,(+)*+*)-(,-! &%$&","P 43 2 2":" !#$%+% 9!$5$!& %-! =%$>","P 43 21 2":" !#$%+,(9)*5*)>(,=! &%$-","I 4 2 2":" !#$%#% #!$#$!& %&! &%$&()+*,+,(+)*+*)-(,-)(-,*-","I 41 2 2":" !#*,+%(5)$9*!> ,=)(-%$&()+$%#, 9!*5$)=(%>! &,*-","P 4 m m":" !#$%#% #!$# %#$!#%$#! #","P 4 b m":" !#$%#% #!$#(,#*)#,*#)(#","P 42 c m":" !#$%#% +!$+ %+$!+%$#! #","P 42 n m":" !#$%#,(+)*+(,+*)+%$#! #","P 4 c c":" !#$%#% #!$# %+$!+%$+! +","P 4 n c":" !#$%#% #!$#(,+*)+,*+)(+","P 42 m c":" !#$%#% +!$+ %#$!#%$+! +","P 42 b c":" !#$%#% +!$+(,#*)#,*+)(+","I 4 m m":" !#$%#% #!$# %#$!#%$#! #()+*,+,(+)*+(,+*)+,*+)(+","I 4 c m":" !#$%#% #!$# %+$!+%$+! +()+*,+,(+)*+(,#*)#,*#)(#","I 41 m d":" !#*,+%(5)$9 %#*)+%*5) 9()+$%#, 9!*5(,+$!#,$9!(5","I 41 c d":" !#*,+%(5)$9 %+*)#%*9) 5()+$%#, 9!*5(,#$!+,$5!(9","P -4 2 m":" !#$%#% &!$&$!& %&%$#! #","P -4 2 c":" !#$%#% &!$&$!- %-%$+! +","P -4 21 m":" !#$%#% &!$&*)&(,&,*#)(#","P -4 21 c":" !#$%#% &!$&*)-(,-,*+)(+","P -4 m 2":" !#$%#!$&% & %#$!#! &%$&","P -4 c 2":" !#$%#% &!$& %+$!+! -%$-","P -4 b 2":" !#$%#% &!$&(,#*)#)(&,*&","P -4 n 2":" !#$%#% &!$&(,+*)+)(-,*-","I -4 m 2":" !#$%#% &!$& %#$!#! &%$&()+*,+,(-)*-(,+*)+)(-,*-","I -4 c 2":" !#$%#% &!$& %+$!+! -%$-()+*,+,(-)*-(,#*)#)(&,*&","I -4 2 m":" !#$%#% &!$&$!& %&%$#! #()+*,+,(-)*-*)-(,-,*+)(+","I -4 2 d":" !#$%#% &!$&*!>(%>,$9) 9()+*,+,(-)*-$)= ,=%*5!(5","P 4/m 2/m 2/m":" !#$%#% #!$#$!& %&! &%$&$%& !&!$&% & %#$!#%$#! #","P 4/m 2/c 2/c":" !#$%#% #!$#$!- %-! -%$-$%& !&!$&% & %+$!+%$+! +","P 4/n 2/b 2/m":" !#$%#% #!$#$!& %&! &%$&*,&()&)*&,(&(,#*)#,*#)(#","P 4/n 2/n 2/c":" !#$%#% #!$#$!& %&! &%$&*,-()-)*-,(-(,+*)+,*+)(+","P 4/m 21/b 2/m":" !#$%#% #!$#*)&(,&)(&,*&$%& !&!$&% &(,#*)#,*#)(#","P 4/m 21/n 2/c":" !#$%#% #!$#*)-(,-)(-,*-$%& !&!$&% &(,+*)+,*+)(+","P 4/n 21/m 2/m":" !#$%#,(#)*#*)&(,&! &%$&*,&()&!$&% & %#$!#,*#)(#","P 4/n 2/c 2/c":" !#$%#,(#)*#*)-(,-! -%$-*,&()&!$&% & %+$!+,*+)(+","P 42/m 2/m 2/c":" !#$%#% +!$+$!& %&! -%$-$%& !&!$-% - %#$!#%$+! +","P 42/m 2/c 2/m":" !#$%#% +!$+$!- %-! &%$&$%& !&!$-% - %+$!+%$#! #","P 42/n 2/b 2/c":" !#$%#,(+)*+$!- %-)(&,*&*,-()-!$&% &(,#*)#%$+! +","P 42/n 2/n 2/m":" !#$%#,(+)*+$!& %&)(-,*-*,-()-!$&% &(,+*)+%$#! #","P 42/m 21/b 2/c":" !#$%#% +!$+*)&(,&)(-,*-$%& !&!$-% -(,#*)#,*+)(+","P 42/m 21/n 2/m":" !#$%#,./'*/*'-.,-! &%$&$%& !&'*-,.-.,/*'/%$#! #","P 42/n 21/m 2/c":" !#$%#,(+)*+*)-(,-! &%$&*,-()-!$&% & %#$!#,*+)(+","P 42/n 21/c 2/m":" !#$%#,(+)*+*)&(,&! -%$-*,-()-!$&% & %+$!+,*#)(#","I 4/m 2/m 2/m":" !#$%#% #!$#$!& %&! &%$&$%& !&!$&% & %#$!#%$#! #()+*,+,(+)*+*)-(,-)(-,*-*,-()-)*-,(-(,+*)+,*+)(+","I 4/m 2/c 2/m":" !#$%#% #!$#$!- %-! -%$-$%& !&!$&% & %+$!+%$+! +()+*,+,(+)*+*)&(,&)(&,*&*,-()-)*-,(-(,#*)#,*#)(#","I 41/a 2/m 2/d":" !#*,+%(5)$9*!> ,=)(-%$&$,=(!>!$&,(-(,+$!#,$9!(5()+$%#, 9!*5$)=(%>! &,*-*%> )=)*-% & %#*)+%*5) 9","I 41/a 2/c 2/d":" !#*,+%(5)$9*!= ,>)(&%$-$,=(!>!$&,(-(,#$!+,$5!(9()+$%#, 9!*5$)>(%=! -,*&*%> )=)*-% & %+*)#%*9) 5","P 3":" !#%?#@$#","P 31":" !#%?A@$B","P 32":" !#%?B@$A","H 3":" !#%?#@$#CDAEFAGHAIJBKLBMNB","R 3":" !## !!# ","P -3":" !#%?#@$#$%&!@&? &","H -3":" !#%?#@$#$%&!@&? &OPQRSQTUQVWXYZX[]X]Y^W[^ZV^UR_PT_SO_","R -3":" !## !!# $%&&$%%&$","P 3 1 2":" !#%?#@$#%$&@!& ?&","P 3 2 1":" !#%?#@$#! &?%&$@&","P 31 1 2":" !#%?Q@$^%$_@!X ?&","P 31 2 1":" !#%?A@$B! &?%_$@X","P 32 1 2":" !#%?^@$Q%$X@!_ ?&","P 32 2 1":" !#%?B@$A! &?%X$@_","H 3 2":" !#%?#@$#! &?%&$@&OPQRSQTUQY]X[WXVZX]Y^W[^ZV^PO_SR_UT_","R 3 2":" !## !!# %$&$&%&%$","P 3 m 1":" !#%?#@$#%$#@!# ?#","P 3 1 m":" !#%?#@$#! #?%#$@#","P 3 c 1":" !#%?#@$#%$+@!+ ?+","P 3 1 c":" !#%?#@$#! +?%+$@+","H 3 m":" !#%?#@$#%$#@!# ?#OPQRSQTUQRUQTPQOSQ]Y^W[^ZV^WV^ZY^][^","R 3 m":" !## !!# ! # #!#! ","H 3 c":" !#%?#@$#%$+@!+ ?+OPQRSQTUQRU`TP`OS`]Y^W[^ZV^WVaZYa][a","R 3 c":" !## !!# '././'/'.","P -3 1 2/m":" !#%?#@$#%$&@!& ?&$%&!@&? &! #?%#$@#","P -3 1 2/c":" !#%?#@$#%$-@!- ?-$%&!@&? &! +?%+$@+","P -3 2/m 1":" !#%?#@$#! &?%&$@&$%&!@&? &%$#@!# ?#","P -3 2/c 1":" !#%?#@$#! -?%-$@-$%&!@&? &%$+@!+ ?+","H -3 2/m":" !#%?#@$#! &?%&$@&$%&!@&? &%$#@!# ?#OPQRSQTUQY]X[WXVZXVWXYZX[]XRUQTPQOSQ]Y^W[^ZV^PO_SR_UT_UR_PT_SO_WV^ZY^][^","R -3 2/m":" !## !!# %$&$&%&%$$%&&$%%&$! # #!#! ","H -3 2/c":" !#%?#@$#! -?%-$@-$%&!@&? &%$+@!+ ?+OPQRSQTUQY]b[WbVZbVWXYZX[]XRU`TP`OS`]Y^W[^ZV^POcSRcUTcUR_PT_SO_WVaZYa][a","R -3 2/c":" !## !!# 102021210$%&&$%%&$'././'/'.","P 6":" !#%?#@$#$%#!@#? #","P 61":" !#%?A@$B$%/!@d? e","P 65":" !#%?B@$A$%/!@e? d","P 62":" !#%?^@$Q$%#!@^? Q","P 64":" !#%?Q@$^$%#!@Q? ^","P 63":" !#%?#@$#$%+!@+? +","P -6":" !#%?#@$# !&%?&@$&","P 6/m":" !#%?#@$#$%#!@#? #$%&!@&? & !&%?&@$&","P 63/m":" !#%?#@$#$%+!@+? +$%&!@&? & !-%?-@$-","P 6 2 2":" !#%?#@$#$%#!@#? #! &?%&$@&%$&@!& ?&","P 61 2 2":" !#%?Q@$^$%+!@`? a! X?%&$@_%$b@!- ?c","P 65 2 2":" !#%?^@$Q$%+!@a? `! _?%&$@X%$c@!- ?b","P 62 2 2":" !#%?^@$Q$%#!@^? Q! _?%&$@X%$_@!& ?X","P 64 2 2":" !#%?Q@$^$%#!@Q? ^! X?%&$@_%$X@!& ?_","P 63 2 2":" !#%?#@$#$%+!@+? +! &?%&$@&%$-@!- ?-","P 6 m m":" !#%?#@$#$%#!@#? #%$#@!# ?#! #?%#$@#","P 6 c c":" !#%?#@$#$%#!@#? #%$+@!+ ?+! +?%+$@+","P 63 c m":" !#%?#@$#$%+!@+? +%$+@!+ ?+! #?%#$@#","P 63 m c":" !#%?#@$#$%+!@+? +%$#@!# ?#! +?%+$@+","P -6 m 2":" !#%?#@$# !&%?&@$&%$#@!# ?#%$&@!& ?&","P -6 c 2":" !#%?#@$# !-%?-@$-%$+@!+ ?+%$&@!& ?&","P -6 2 m":" !#%?#@$# !&%?&@$&! &?%&$@&! #?%#$@#","P -6 2 c":" !#%?#@$# !-%?-@$-! &?%&$@&! +?%+$@+","P 6/m 2/m 2/m":" !#%?#@$#$%#!@#? #! &?%&$@&%$&@!& ?&$%&!@&? & !&@$&%?&%$#@!# ?#! #?%#$@#","P 6/m 2/c 2/c":" !#%?#@$#$%#!@#? #! -?%-$@-%$-@!- ?-$%&!@&? & !&@$&%?&%$+@!+ ?+! +?%+$@+","P 63/m 2/c 2/m":" !#%?#@$#$%+!@+? +! -?%-$@-%$&@!& ?&$%&!@&? & !-@$-%?-%$+@!+ ?+! #?%#$@#","P 63/m 2/m 2/c":" !#%?#@$#$%+!@+? +! &?%&$@&%$-@!- ?-$%&!@&? & !-@$-%?-%$#@!# ?#! +?%+$@+","P 2 3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ","F 2 3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ","I 2 3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-(","P 21 3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(","I 21 3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- ","P 2/m -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$","P 2/n -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& *,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*","F 2/m -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$ )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-($,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(*%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- *,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$","F 2/d -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& 64=37=345675=64=375345674=67=3453756 )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(68>3:>3896:9=<8=;:5;85<:4><7>;49;79<(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(<4>;7>;49<79>68>3:93896:8=<:=;85;:5<()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- <8=;:=;8f<:f><4>;79;49<78>6:>3893:96","I 2/m -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-(*,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*","P 21/a -3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&($%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*","I 21/a -3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&($%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*()+$,#*g& %-+()#$,&*!- %)+(,#$!&*%- *,- )&(%#$!+-*,& )#(%+$!,-*)& %#(!+$","P 4 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$","P 42 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*","F 4 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$ )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(-%*-!*+%(+ +,$+)$-, -)#)*#,(&)(&,*(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() -,$-)$+, +(#,*#)*&,(&)+!*+%(-!(-%*()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(&,*&)*#,(#(+%*+!*-%(-!+)$+, -) -,$","F 41 3 2":" !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=46 )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<(!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>86","I 4 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*","P 43 3 2":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(7;>46=:<5839398<5:6=4;>75:<983>7;=46","P 41 3 2":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<","I 41 3 2":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- 7;>46=:<5839398<5:6=4;>75:<983>7;=46","P -4 3 m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% ","F -4 3 m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(+%*+!*-%(- +)$+,$-) -,#)(#,*&)*&,((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() +,$+)$-, -(#)*#,*&)(&,+!(+%*-!*-%(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(#,*#)*&,(&(+!*+%*-!(-%+) +,$-)$-, ","I -4 3 m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,(","P -4 3 n":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,(","F -4 3 c":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,( )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-() #,$#)$&, &(#!*#%*&!(&%+! +%$-!$-% (!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(!(#%*#!*&%(& +!$+%$-! -%#) #,$&)$&, ()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ! +%$+!$-% - #)$#,$&) &,#!(#%*&!*&%(","I -4 3 d":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(7354<9:6>8;=357<946>:;=857394<>:6=8;()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- :;98657<=43>;9:658<=73>49:;586=7<>43","P 4/m -3 2/m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ","P 4/n -3 2/n":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$*,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(","P 42/m -3 2/n":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(","P 42/n -3 2/m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,**,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ","F 4/m -3 2/m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(-%*-!*+%(+ +,$+)$-, -)#)*#,(&)(&,*$,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*%*+!(+%(-!*-$-) -, +)$+,&,(&)*#,*#)((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() -,$-)$+, +(#,*#)*&,(&)+!*+%(-!(-%**%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*,$+) +, -)$-*&)(&,(#)*#,-%(-!*+%*+!(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(&,*&)*#,(#(+%*+!*-%(-!+)$+, -) -,$*,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$,*#)(#,(&)*&*-!(-%(+!*+%-, -)$+,$+) ","F 4/m -3 2/c":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)( )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-() &,$&)$#, #(#%*#!*&%(&!+!$+% -! -%$$,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*,$#) #, &)$&*&!(&%(#!*#%-% -!$+%$+! (!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(!(&%*&!*#%(# +%$+!$-% -!#)$#, &) &,$*%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*%*#!(#%(&!*&$-! -% +!$+%&, &)$#,$#) ()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ! -%$-!$+% + #,$#)$&, &)#!*#%(&!(&%**,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$%$+! +% -!$-$&) &, #)$#,&%(&!*#%*#!(","F 41/d -3 2/m":" !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=4664=3:>;85<79=64>3:5;89<74=6:>385;79<,$+! #%(-)*&*&)(-% #!$+,-%(&)*+,$#! )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<68>37=;49<:5=<8>;753496:4><:=;893756,*#!(+% &)$-*-!(&, +)$#%-, &!$+%*#)((!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<<4>;:=389675>68=379;45<:8=<7>;453:96%$#) +,(&!*-$&! -,(#)*+%&% -)$#,*+!(()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>86<8=;7>3456:9><4=;:9385678>67=349;:5<%*+)(#, -!$&$-) &%(+!*#,&,(-!*#%$+) ","F 41/d -3 2/c":" !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=46<8>;7=3496:5><8=;793456:8><7=;493:56%*#)(+, &!$-$-! &,(+)*#%&, -!$#%*+)( )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<<4=;:>385679>64=3:9;85<78=67>345;:9<%$+) #,(-!*&$&) -%(#!*+,&%(-)*#,$+! (!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<68=37>;45<:9=<4>;:5389674>6:=389;75<,*+!(#% -)$&*-)(&% +!$#,-,(&!*+%$#) ()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>8664>3:=;89<75=68>375;49<:4=<:>;853796,$#! +%(&)*-*&!(-, #)$+%-% &)$+,*#!(","I 4/m -3 2/m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,**,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(","I 41/a -3 2/d":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<$%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*4<97358;=:6>6>:;=8357<94=8;>:694<573()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- 7;>46=:<5839398<5:6=4;>75:<983>7;=46*,- )&(%#$!+-*,& )#(%+$!,-*)& %#(!+$865:;943>7<=<=73>4;9:658>43=7<5869:;","P 1 1 2":" !#$%#","P 1 1 21":" !#$%+","B 1 1 2":" !#$%#(g+*%+","A 1 2 1":" !#$!& )+$)-","C 1 21 1":" !#$)&()#*!&","I 1 2 1":" !#$!&.'/0'2","I 1 21 1":" !#$)&.'/0!-","P 1 1 m":" !# !&","P 1 1 b":" !# )&","B 1 1 m":" !# !&(!+(!-","B 1 1 b":" !# )&(!+()-","P 1 1 2/m":" !# !&$%#$%&","P 1 1 21/m":" !#$%+$%& !-","B 1 1 2/m":" !# !&$%#$%&(!+(!-*%+*%-","P 1 1 2/b":" !#$,#$%& )&","P 1 1 21/b":" !#$%&$,+ )-","B 1 1 2/b":" !#$,#$%& )&(!+*,+*%-()-","P 21 2 2":" !#$!&(%&*%#","P 2 21 2":" !# ,&$)&$%#","P 21 21 2 (a)":" !#*,#.%&$'&","P 21 2 21":" !#$!&(%-*%+","P 2 21 21":" !# %&$)-$,+","C 2 2 21a)":" !#*%+(,&$)-()#$,+ %&*!-","C 2 2 2a":" !#*,#.%&$'&()#$%# ,&*!&","F 2 2 2a":" !#*,#.%&$'& '/*%/.12$!2.!/$,/ %20'2.'#$%# 1&0!&","I 2 2 2a":" !#*,#.%&$'&()+$%+*!- ,-","P 21/m 21/m 2/n a":" !#*,#$)&(%&$%&.'& ,#*!#","P 42 21 2a":" !#*,#%.+'$+$'&.%&! -,*-","I 2 3a":" !#*,#.%&$'&!# ,- '&$%/$# !-*!/$%&.%()+$%+ ,-*!-)+(%&(!-*,#*+()&$)#*,- ,"},Zm=/^[1-9]$/;function Km(e){let t="";return e.length>0&&(t=":"+za(e).join(" OR :")),new $c(t)}class Qm{constructor(e=""){this.name=e,this.partList=[]}get type(){return"Assembly"}addPart(e,t){const i=new Jm(e,t);return this.partList.push(i),i}getAtomCount(e){return this.partList.reduce(((t,i)=>t+i.getAtomCount(e)),0)}getResidueCount(e){return this.partList.reduce(((t,i)=>t+i.getResidueCount(e)),0)}getInstanceCount(){let e=0;return this.partList.forEach((function(t){e+=t.matrixList.length})),e}isIdentity(e){if(1!==this.partList.length)return!1;const t=this.partList[0];if(1!==t.matrixList.length)return!1;if(!(new ri).equals(t.matrixList[0]))return!1;let i=[];return e.eachChain((function(e){i.push(e.chainname)})),i=za(i),t.chainList.length===i.length}getBoundingBox(e){const t=new Ni;return this.partList.forEach((function(i){const n=i.getBoundingBox(e);t.expandByPoint(n.min),t.expandByPoint(n.max)})),t}getCenter(e){return this.getBoundingBox(e).getCenter(new Zt)}getSelection(){let e=[];return this.partList.forEach((function(t){e=e.concat(t.chainList)})),Km(e)}}class Jm{constructor(e=[],t=[]){this.matrixList=e,this.chainList=t}get type(){return"AssemblyPart"}_getCount(e,t){let i=0;return e.eachChain((e=>{(0===this.chainList.length||this.chainList.includes(e.chainname))&&(i+=e[t])})),this.matrixList.length*i}getAtomCount(e){return this._getCount(e,"atomCount")}getResidueCount(e){return this._getCount(e,"residueCount")}getBoundingBox(e){const t=new Ni,i=new Ni,n=this.getSelection(),r=e.getBoundingBox(n);return this.matrixList.forEach((function(e){i.copy(r).applyMatrix4(e),t.expandByPoint(i.min),t.expandByPoint(i.max)})),t}getSelection(){return Km(this.chainList)}getView(e){const t=this.getSelection();return t?e.getView(t):e}getInstanceList(){const e=[];for(let t=0,i=this.matrixList.length;t0&&this.addResidueType(this.ri-1),l.growIfFull(),l.resno[this.ri]=r,void 0!==o&&(l.sstruc[this.ri]=o.charCodeAt(0)),void 0!==a&&(l.inscode[this.ri]=a.charCodeAt(0)),l.atomOffset[this.ri]=this.ai,l.atomCount[this.ri]=0,l.count+=1,l.chainIndex[this.ri]=this.ci,h.residueCount[this.ci]+=1),c.count+=1,c.residueIndex[this.ai]=this.ri,l.atomCount[this.ri]+=1,this.currentModelindex=e,this.currentChainid=i,this.currentResname=n,this.currentResno=r,this.currentInscode=a,this.currentHetero=s}finalize(){this.previousResname=this.currentResname,this.previousHetero=this.currentHetero,this.ri>-1&&this.addResidueType(this.ri)}}function tp(t,i){if(!i)return;e.Debug&&il.time("assignSecondaryStructure");const n=[];t.eachModel((function(e){e.eachChain((function(e){n.push(e.chainname)}))}));const r=n.slice().sort(),s=[];r.forEach((function(e){s.push(n.indexOf(e))}));const o=i.helices.filter((function(e){return Na(r,e[0])>=0}));o.sort((function(e,t){const i=e[0],n=t[0],o=e[1],a=t[1];if(i===n)return o===a?0:o=0}));c.sort((function(e,t){const i=e[0],n=t[0];if(i===n)return 0;const o=Na(r,i),a=Na(r,n);return s[o]=e.residueCount)continue;o.index=s+r,a.index=s+r+t,c.index=o.traceAtomIndex,l.index=a.traceAtomIndex;const h=c.distanceTo(l);if(Math.abs(h-i[t-2])>n)return!1}return!0},i=function(e,i){return t(e,i,[5.45,5.18,6.37],2.1)},n=function(e,i){return t(e,i,[6.1,10.4,13],1.42)};return function(t){e.Debug&&il.time("calculateSecondaryStructure"),t.eachPolymer((function(e){if(e.residueCount<4)return;if(e.isCg())!function(e){const t=e.residueStore,i=e.residueIndexStart,n=new Um(e).position,r=new Zt,s=new Zt;for(let o=0,a=e.residueCount;o1&&n.bending[o]<20&&(t.sstruc[i+o]="h".charCodeAt(0),t.sstruc[i+o+1]="h".charCodeAt(0))}}(e);else{if(!e.isProtein())return;!function(e){const t=e.residueStore,r=e.residueIndexStart;for(let s=0,o=e.residueCount;s=t;)i=Math.floor(i/t),r+=np[i%t],n+=1;return n>=5&&il.warn("chainname overflow"),r}function sp(t,i=!1){e.Debug&&il.time("calculateChainnames");let n=!0;if(t.eachChain((function(e){e.chainname&&(n=!1)})),n){const e=t.modelStore,n=t.chainStore,r=t.residueStore,s=function(t,i,s,o){const a=n.count;for(let e=0;e{u.add(t),e.forEach((e=>{u.add(e)}))}))),t.eachResidue((function(e){if(!i&&h){const t=e.atomCount,i=e.atomOffset;if(t>500)return void il.warn("more than 500 atoms, skip residue for auto-bonding",e.qualifiedName());if("auto"===n&&e.hetero)for(let t=e.atomOffset;t{u.forEach((i=>{e.push(t.clone().multiply(i))}))})),l.addPart(e)}else l.addPart(h);const d=new Zt,f=new Qm("SUPERCELL"),m=Array.prototype.concat.call(c(d.set(1,0,0)),c(d.set(0,1,0)),c(d.set(0,0,1)),c(d.set(-1,0,0)),c(d.set(0,-1,0)),c(d.set(0,0,-1)),c(d.set(1,1,0)),c(d.set(1,0,1)),c(d.set(0,1,1)),c(d.set(-1,-1,0)),c(d.set(-1,0,-1)),c(d.set(0,-1,-1)),c(d.set(1,-1,-1)),c(d.set(1,1,-1)),c(d.set(1,-1,1)),c(d.set(-1,1,1)),c(d.set(-1,-1,1)),c(d.set(-1,1,-1)),c(d.set(0,1,-1)),c(d.set(0,-1,1)),c(d.set(1,0,-1)),c(d.set(-1,0,1)),c(d.set(1,-1,0)),c(d.set(-1,1,0)),c(),c(d.set(1,1,1)),c(d.set(-1,-1,-1)));if(t.biomolDict.NCS){const e=[];m.forEach((function(t){u.forEach((function(i){e.push(t.clone().multiply(i))}))})),f.addPart(e)}else f.addPart(m);t.biomolDict.UNITCELL=l,t.biomolDict.SUPERCELL=f,e.Debug&&il.timeEnd("buildUnitcellAssembly")}const dp=["H","C","O","N","S","P"],fp=["NA","CL","FE"];function mp(e){let t=e.toUpperCase(),i=0,n=0;for(let e=0;e0)break;++i}else n=e+1;(i>0||n=3&&-1!==dp.indexOf(t[0])?t[0]:""}function pp(e){const t=e.bondHash,i=t.countArray,n=t.offsetArray,r=t.indexArray,s=e.getBondProxy();e.eachResidue((function(e){const t=e.residueType;if(void 0!==t.bonds)return;var o=e.atomOffset,a=[],c=[],l=[],h={};const u=o+e.atomCount;e.eachAtom((function(e){const t=e.index,d=n[t];for(let e=0,n=i[t];e=u)continue;let i=s.atomIndex2;if(i=u)continue;if(t>i){const e=i;i=t,t=e}const n=t+"|"+i;void 0===h[n]&&(h[n]=!0,a.push(t-o),c.push(i-o),l.push(s.bondOrder))}})),t.bonds={atomIndices1:a,atomIndices2:c,bondOrders:l}}))}const gp=[3,11,19,37,55,87],vp=[4,12,20,38,56,88],yp=[6,15,16,34],xp=[1,7,8,9,17,35,53],bp=[2,10,18,36,54,86],_p=[13,30,31,48,49,50,80,81,82,83,84,85,112],wp=[5,14,32,33,51,52,85],Sp=[9,17,35,53,85];class Ap{constructor(e,t,i){this.structure=e,this.atomname=t,i=i||mp(t),this.element=i,this.number=ld[i]||0,this.vdw=hd[this.number]||2,this.covalent=ud[this.number]||1.6}getDefaultValence(){const e=dd[this.number];return e?e[0]:-1}getValenceList(){return dd[this.number]||[]}getOuterShellElectronCount(){return fd[this.number]||2}isMetal(){return this.isAlkaliMetal()||this.isAlkalineEarthMetal()||this.isLanthanide()||this.isActinide()||this.isTransitionMetal()||this.isPostTransitionMetal()}isNonmetal(){return this.isDiatomicNonmetal()||this.isPolyatomicNonmetal()||this.isNobleGas()}isMetalloid(){return wp.includes(this.number)}isHalogen(){return Sp.includes(this.number)}isDiatomicNonmetal(){return xp.includes(this.number)}isPolyatomicNonmetal(){return yp.includes(this.number)}isAlkaliMetal(){return gp.includes(this.number)}isAlkalineEarthMetal(){return vp.includes(this.number)}isNobleGas(){return bp.includes(this.number)}isTransitionMetal(){const e=this.number;return e>=21&&e<=29||e>=39&&e<=47||e>=72&&e<=79||e>=104&&e<=108}isPostTransitionMetal(){return _p.includes(this.number)}isLanthanide(){return this.number>=57&&this.number<=71}isActinide(){return this.number>=89&&this.number<=103}}class Mp{constructor(e){this.structure=e,this.dict={},this.list=[],this.structure=e}add(e,t){const i=function(e,t){return e+"|"+t}(e=e.toUpperCase(),t=t?t.toUpperCase():mp(e));let n=this.dict[i];if(void 0===n){const r=new Ap(this.structure,e,t);n=this.list.length,this.dict[i]=n,this.list.push(r)}return n}get(e){return this.list[e]}}class Cp{constructor(e,t,i,n,r,s){this.structure=e,this.bondReferenceAtomIndices=[],this.resname=t,this.atomTypeIdList=i,this.hetero=n?1:0,this.chemCompType=r,this.bonds=s,this.atomCount=i.length,this.moleculeType=this.getMoleculeType(),this.backboneType=this.getBackboneType(0),this.backboneEndType=this.getBackboneType(-1),this.backboneStartType=this.getBackboneType(1),this.backboneIndexList=this.getBackboneIndexList();const o=Pd[this.backboneType],a=Pd[this.backboneStartType],c=Pd[this.backboneEndType],l=this.getAtomIndexByName(o.trace);this.traceAtomIndex=Ia(l,-1);const h=this.getAtomIndexByName(o.direction1);this.direction1AtomIndex=Ia(h,-1);const u=this.getAtomIndexByName(o.direction2);this.direction2AtomIndex=Ia(u,-1);const d=this.getAtomIndexByName(a.backboneStart);this.backboneStartAtomIndex=Ia(d,-1);const f=this.getAtomIndexByName(c.backboneEnd);let m;this.backboneEndAtomIndex=Ia(f,-1),m=bd.includes(t)?this.getAtomIndexByName("N1"):this.getAtomIndexByName("N3"),this.rungEndAtomIndex=Ia(m,-1)}getBackboneIndexList(){const e=[];let t;switch(this.moleculeType){case 3:t=Md;break;case 4:case 5:t=Cd;break;default:return e}const i=this.structure.atomMap,n=this.atomTypeIdList;for(let r=0,s=this.atomCount;r500)e.Debug&&il.warn("more than 500 atoms, skip residue for auto-bonding",t.qualifiedName());else if(s>50){const e=new qm(t,!0),i=t.isCg()?1.2:2.3;for(let t=o;t=0||Ep(e,t);this.rings={atomRings:e.atomRings,rings:e.rings}}isAromatic(e){return this.aromaticAtoms=this.getAromatic(e),1===this.aromaticAtoms[e.index-e.residueAtomOffset]}calculateAromatic(e){const t=this.aromaticAtoms=new Uint8Array(this.atomCount),i=this.getRings().rings,n=i.map((t=>function(e){if(e.some((e=>!Pp.includes(e.number))))return!1;let t=0;const i=new Mf(3,e.length),n=i.data;e.forEach((e=>{n[t+0]=e.x,n[t+1]=e.y,n[t+2]=e.z,t+=3}));return new Dm(i).vecC.length()this.structure.getAtomProxy(t+e.atomOffset)))))),r=this.aromaticRings=[];i.forEach(((e,i)=>{n[i]&&(r.push(e),e.forEach((e=>t[e]=1)))}))}assignBondReferenceAtomIndices(){const e=this.getBondGraph(),t=this.getRings(),i=t.atomRings,n=t.rings,r=this.bonds,s=r.atomIndices1,o=r.atomIndices2,a=r.bondOrders,c=this.bondReferenceAtomIndices,l=r.atomIndices1.length;c.length=0;for(let t=0;t1)for(let i=0;i1)for(let i=0;i=0;e--)m[p++]=o[e];const g=e.rings.length;for(let t=0;t0?s[c]!==t&&s[t]!==c&&Ip(e,t,c):(n[c]=1,r[a++]=c,s[c]=t)}}}const Dp=4;class Lp{constructor(e){this.structure=e,this.dict={},this.list=[]}add(e,t,i,n="",r){const s=function(e,t,i,n=""){return e+"|"+t.join(",")+"|"+(i?1:0)+"|"+n}(e=e.toUpperCase(),t,i,n);let o=this.dict[s];if(void 0===o){const a=new Cp(this.structure,e,t,i,n,r);o=this.list.length,this.dict[s]=o,this.list.push(a)}return o}get(e){return this.list[e]}}class Rp{constructor(e,t=0){this.structure=e,this.index=t,this.bondStore=e.bondStore,this._v12=new Zt,this._v13=new Zt,this._ap1=this.structure.getAtomProxy(),this._ap2=this.structure.getAtomProxy(),this._ap3=this.structure.getAtomProxy()}get atom1(){return this.structure.getAtomProxy(this.atomIndex1)}get atom2(){return this.structure.getAtomProxy(this.atomIndex2)}get atomIndex1(){return this.bondStore.atomIndex1[this.index]}set atomIndex1(e){this.bondStore.atomIndex1[this.index]=e}get atomIndex2(){return this.bondStore.atomIndex2[this.index]}set atomIndex2(e){this.bondStore.atomIndex2[this.index]=e}get bondOrder(){return this.bondStore.bondOrder[this.index]}set bondOrder(e){this.bondStore.bondOrder[this.index]=e}getOtherAtomIndex(e){return e===this.atomIndex1?this.atomIndex2:this.atomIndex1}getOtherAtom(e){return this.structure.getAtomProxy(this.getOtherAtomIndex(e.index))}getReferenceAtomIndex(){const e=this._ap1,t=this._ap2;if(e.index=this.atomIndex1,t.index=this.atomIndex2,e.residueIndex!==t.residueIndex)return;const i=e.index-e.residueAtomOffset,n=t.index-t.residueAtomOffset,r=e.residueType.getBondReferenceAtomIndex(i,n);if(void 0!==r)return r+e.residueAtomOffset;console.warn("No reference atom found",e.index,t.index)}calculateShiftDir(e=new Zt){const t=this._ap1,i=this._ap2,n=this._ap3,r=this._v12,s=this._v13;t.index=this.atomIndex1,i.index=this.atomIndex2;const o=this.getReferenceAtomIndex();r.subVectors(t,i).normalize(),void 0!==o?(n.index=o,s.subVectors(t,n)):s.copy(t),s.normalize();let a=r.dot(s);return 1-Math.abs(a)<1e-5&&(s.set(1,0,0),a=r.dot(s),1-Math.abs(a)<1e-5&&(s.set(0,1,0),a=r.dot(s))),e.copy(s.sub(r.multiplyScalar(a))).normalize()}qualifiedName(){return this.atomIndex1+"="+this.atomIndex2}clone(){return new Rp(this.structure,this.index)}toObject(){return{atomIndex1:this.atomIndex1,atomIndex2:this.atomIndex2,bondOrder:this.bondOrder}}}class kp{constructor(e,t=0){this.structure=e,this.index=t,this.chainStore=e.chainStore,this.residueStore=e.residueStore,this.atomStore=e.atomStore,this.residueMap=e.residueMap,this.atomMap=e.atomMap}get entity(){return this.structure.entityList[this.entityIndex]}get entityIndex(){return this.chainStore.entityIndex[this.chainIndex]}get chain(){return this.structure.getChainProxy(this.chainIndex)}get chainIndex(){return this.residueStore.chainIndex[this.index]}set chainIndex(e){this.residueStore.chainIndex[this.index]=e}get atomOffset(){return this.residueStore.atomOffset[this.index]}set atomOffset(e){this.residueStore.atomOffset[this.index]=e}get atomCount(){return this.residueStore.atomCount[this.index]}set atomCount(e){this.residueStore.atomCount[this.index]=e}get atomEnd(){return this.atomOffset+this.atomCount-1}get modelIndex(){return this.chainStore.modelIndex[this.chainIndex]}get chainname(){return this.chainStore.getChainname(this.chainIndex)}get chainid(){return this.chainStore.getChainid(this.chainIndex)}get resno(){return this.residueStore.resno[this.index]}set resno(e){this.residueStore.resno[this.index]=e}get sstruc(){return this.residueStore.getSstruc(this.index)}set sstruc(e){this.residueStore.setSstruc(this.index,e)}get inscode(){return this.residueStore.getInscode(this.index)}set inscode(e){this.residueStore.setInscode(this.index,e)}get residueType(){return this.residueMap.get(this.residueStore.residueTypeId[this.index])}get resname(){return this.residueType.resname}get hetero(){return this.residueType.hetero}get moleculeType(){return this.residueType.moleculeType}get backboneType(){return this.residueType.backboneType}get backboneStartType(){return this.residueType.backboneStartType}get backboneEndType(){return this.residueType.backboneEndType}get traceAtomIndex(){return this.residueType.traceAtomIndex+this.atomOffset}get direction1AtomIndex(){return this.residueType.direction1AtomIndex+this.atomOffset}get direction2AtomIndex(){return this.residueType.direction2AtomIndex+this.atomOffset}get backboneStartAtomIndex(){return this.residueType.backboneStartAtomIndex+this.atomOffset}get backboneEndAtomIndex(){return this.residueType.backboneEndAtomIndex+this.atomOffset}get rungEndAtomIndex(){return this.residueType.rungEndAtomIndex+this.atomOffset}get x(){let e=0;for(let t=this.atomOffset;t<=this.atomEnd;++t)e+=this.atomStore.x[t];return e/this.atomCount}get y(){let e=0;for(let t=this.atomOffset;t<=this.atomEnd;++t)e+=this.atomStore.y[t];return e/this.atomCount}get z(){let e=0;for(let t=this.atomOffset;t<=this.atomEnd;++t)e+=this.atomStore.z[t];return e/this.atomCount}eachAtom(e,t){const i=this.atomCount,n=this.atomOffset,r=this.structure._ap,s=n+i;if(t&&t.atomOnlyTest){const i=t.atomOnlyTest;for(let t=n;t0)return this.entity.isPolymer();{const e=this.residueType.moleculeType;return 3===e||4===e||5===e}}isHetero(){return 1===this.residueType.hetero}isWater(){return 1===this.residueType.moleculeType}isIon(){return 2===this.residueType.moleculeType}isSaccharide(){return 6===this.residueType.moleculeType}isStandardAminoacid(){return this.residueType.isStandardAminoacid()}isStandardBase(){return this.residueType.isStandardBase()}isHelix(){return od.includes(this.sstruc)}isSheet(){return ad.includes(this.sstruc)}isTurn(){return cd.includes(this.sstruc)&&this.isProtein()}getAtomType(e){return this.atomMap.get(this.atomStore.atomTypeId[e])}getResname1(){return gd[this.resname.toUpperCase()]||"X"}getBackboneType(e){switch(e){case-1:return this.residueType.backboneStartType;case 1:return this.residueType.backboneEndType;default:return this.residueType.backboneType}}getAtomIndexByName(e){let t=this.residueType.getAtomIndexByName(e);return void 0!==t&&(t+=this.atomOffset),t}hasAtomWithName(e){return this.residueType.hasAtomWithName(e)}getAtomnameList(){console.warn("getAtomnameList - might be expensive");const e=this.atomCount,t=this.atomOffset,i=new Array(e);for(let n=0;n=t){const t=Ia(e,this.structure.getResidueProxy());if(t.index=i,t.connectedTo(this))return t}else if(i===t-1){const i=this.chainStore.residueCount[this.chainIndex],n=Ia(e,this.structure.getResidueProxy());if(n.index=t+i-1,n.connectedTo(this))return n}}getBonds(){return this.residueType.getBonds(this)}getRings(){return this.residueType.getRings()}getAromaticRings(){return this.residueType.getAromaticRings(this)}qualifiedName(e=!1){let t="";return this.resname&&!e&&(t+="["+this.resname+"]"),void 0!==this.resno&&(t+=this.resno),this.inscode&&(t+="^"+this.inscode),this.chain&&(t+=":"+this.chainname),t+="/"+this.modelIndex,t}clone(){return new kp(this.structure,this.index)}toObject(){return{index:this.index,chainIndex:this.chainIndex,atomOffset:this.atomOffset,atomCount:this.atomCount,resno:this.resno,resname:this.resname,sstruc:this.sstruc}}}class Op{constructor(e,t,i){this.structure=e,this.residueIndexStart=t,this.residueIndexEnd=i,this.chainStore=e.chainStore,this.residueStore=e.residueStore,this.atomStore=e.atomStore,this.residueCount=i-t+1;const n=this.structure.getResidueProxy(this.residueIndexStart),r=this.structure.getResidueProxy(this.residueIndexEnd);this.isPrevConnected=void 0!==n.getPreviousConnectedResidue();const s=r.getNextConnectedResidue();this.isNextConnected=void 0!==s,this.isNextNextConnected=void 0!==s&&void 0!==s.getNextConnectedResidue(),this.isCyclic=r.connectedTo(n),this.__residueProxy=this.structure.getResidueProxy()}get chainIndex(){return this.residueStore.chainIndex[this.residueIndexStart]}get modelIndex(){return this.chainStore.modelIndex[this.chainIndex]}get chainname(){return this.chainStore.getChainname(this.chainIndex)}isProtein(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isProtein()}isCg(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isCg()}isNucleic(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isNucleic()}getMoleculeType(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.moleculeType}getBackboneType(e){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.getBackboneType(e)}getAtomIndexByType(e,t){this.isCyclic?-1===e?e=this.residueCount-1:e===this.residueCount&&(e=0):(-1!==e||this.isPrevConnected||(e+=1),e!==this.residueCount||this.isNextNextConnected||(e-=1));const i=this.__residueProxy;let n;switch(i.index=this.residueIndexStart+e,t){case"trace":n=i.traceAtomIndex;break;case"direction1":n=i.direction1AtomIndex;break;case"direction2":n=i.direction2AtomIndex;break;default:n=i.getAtomIndexByName(t)}return n}eachAtom(e,t){this.eachResidue((function(i){i.eachAtom(e,t)}))}eachAtomN(e,t,i){const n=this.residueCount,r=new Array(e);for(let t=0;t1&&e(new Op(s,i,l.index)),i=n)):(o!==ed&&l.index-i>1&&e(new Op(s,i,l.index)),i=n)}n-i>1&&this.structure.getResidueProxy(i).backboneEndType&&e(new Op(s,i,n))}qualifiedName(){return":"+this.chainname+"/"+this.modelIndex}clone(){return new Bp(this.structure,this.index)}toObject(){return{index:this.index,residueOffset:this.residueOffset,residueCount:this.residueCount,chainname:this.chainname}}}class Np{constructor(e,t=0){this.structure=e,this.index=t,this.modelStore=e.modelStore,this.chainStore=e.chainStore,this.residueStore=e.residueStore}get chainOffset(){return this.modelStore.chainOffset[this.index]}set chainOffset(e){this.modelStore.chainOffset[this.index]=e}get chainCount(){return this.modelStore.chainCount[this.index]}set chainCount(e){this.modelStore.chainCount[this.index]=e}get residueOffset(){return this.chainStore.residueOffset[this.chainOffset]}get atomOffset(){return this.residueStore.atomOffset[this.residueOffset]}get chainEnd(){return this.chainOffset+this.chainCount-1}get residueEnd(){return this.chainStore.residueOffset[this.chainEnd]+this.chainStore.residueCount[this.chainEnd]-1}get atomEnd(){return this.residueStore.atomOffset[this.residueEnd]+this.residueStore.atomCount[this.residueEnd]-1}get residueCount(){return 0===this.chainCount?0:this.residueEnd-this.residueOffset+1}get atomCount(){return 0===this.residueCount?0:this.atomEnd-this.atomOffset+1}eachAtom(e,t){this.eachChain((function(i){i.eachAtom(e,t)}),t)}eachResidue(e,t){this.eachChain((function(i){i.eachResidue(e,t)}),t)}eachPolymer(e,t){if(t&&t.chainOnlyTest){const i=t.chainOnlyTest;this.eachChain((function(n){i(n)&&n.eachPolymer(e,t)}))}else this.eachChain((function(i){i.eachPolymer(e,t)}))}eachChain(e,t){const i=this.chainCount,n=this.chainOffset,r=this.structure._cp,s=n+i;if(t&&t.test){const i=t.chainOnlyTest;if(i)for(let t=n;t{const i=3*t;a.index=e,l&&a.positionToArray(l,i),h&&s.atomColorToArray(a,h,i),u&&(u.array[t]=e),d&&(d[t]=r.atomRadius(a)),f&&(f[t]=e)})),o}getBondData(e){const t=Object.assign({},e);t.colorParams&&(t.colorParams.structure=this.getStructure());const i=t.what,n=Ia(t.bondSet,this.bondSet),r=Ia(t.multipleBond,"off"),s="off"!==r,o="offset"===r,a=Ia(t.bondScale,.4),c=Ia(t.bondSpacing,1);let l,h;const u={},d=this.getBondProxy();t.bondStore&&(d.bondStore=t.bondStore);const f=this.getAtomProxy(),m=this.getAtomProxy();let p;if(s){const e=d.bondStore.bondOrder;p=0,n.forEach((function(t){p+=e[t]}))}else p=n.getSize();i&&!i.position||(u.position1=new Float32Array(3*p),u.position2=new Float32Array(3*p)),i&&!i.color||!t.colorParams||(u.color=new Float32Array(3*p),u.color2=new Float32Array(3*p),h=al.getScheme(t.colorParams)),i&&!i.picking||(u.picking=new df(new Float32Array(p),this.getStructure(),t.bondStore)),(!i||i.radius||s&&i.position)&&(l=new Tm(t.radiusParams)),i&&!i.radius||(u.radius=new Float32Array(p),t.radius2&&(u.radius2=new Float32Array(p)));const{position1:g,position2:v,color:y,color2:x,picking:b,radius:_,radius2:w}=u;let S,A,M,C,P,T,I=0;const E=new Zt,D=new Zt,L=new Zt;return n.forEach((e=>{if(A=3*I,d.index=e,f.index=d.atomIndex1,m.index=d.atomIndex2,C=d.bondOrder,g)if(s&&C>1){const e=l.atomRadius(f);T=e*a/(.5*C),d.calculateShiftDir(L),o?(P=2*c*e,L.multiplyScalar(P),L.negate(),D.subVectors(m,f).multiplyScalar(Math.max(.1,P/1.88)),f.positionToArray(g,A),m.positionToArray(v,A),C>=2&&(E.addVectors(f,L).add(D).toArray(g,A+3),E.addVectors(m,L).sub(D).toArray(v,A+3),C>=3&&(E.subVectors(f,L).add(D).toArray(g,A+6),E.subVectors(m,L).sub(D).toArray(v,A+6)))):(P=(c-a)*e,L.multiplyScalar(P),2===C?(E.addVectors(f,L).toArray(g,A),E.subVectors(f,L).toArray(g,A+3),E.addVectors(m,L).toArray(v,A),E.subVectors(m,L).toArray(v,A+3)):3===C?(f.positionToArray(g,A),E.addVectors(f,L).toArray(g,A+3),E.subVectors(f,L).toArray(g,A+6),m.positionToArray(v,A),E.addVectors(m,L).toArray(v,A+3),E.subVectors(m,L).toArray(v,A+6)):(f.positionToArray(g,A),m.positionToArray(v,A)))}else f.positionToArray(g,A),m.positionToArray(v,A);if(y&&x&&(h.bondColorToArray(d,1,y,A),h.bondColorToArray(d,0,x,A),s&&C>1))for(S=1;S1))for(S=1;S1))for(T=_[I]*a/(o?1:.5*C),S=o?1:0;S1))for(T=w[I]*a/(o?1:.5*C),S=o?1:0;S{const t=e.x,i=e.y,l=e.z;to&&(o=t),i>a&&(a=i),l>c&&(c=l)}),t),i.min.set(n,r,s),i.max.set(o,a,c),e.Debug&&il.timeEnd("getBoundingBox"),i}getPrincipalAxes(t){e.Debug&&il.time("getPrincipalAxes");let i=0;const n=new Mf(3,this.atomCount),r=n.data;return this.eachAtom((e=>{r[i+0]=e.x,r[i+1]=e.y,r[i+2]=e.z,i+=3}),t),e.Debug&&il.timeEnd("getPrincipalAxes"),new Dm(n)}atomCenter(e){return e?this.getBoundingBox(e).getCenter(new Zt):this.center.clone()}hasCoords(){if(void 0===this._hasCoords){const e=this.atomStore;this._hasCoords=0!==Zl(e.x)||0!==Yl(e.x)||0!==Zl(e.y)||0!==Yl(e.y)||0!==Zl(e.z)||0!==Yl(e.z)||e.count/this.modelStore.count==1}return this._hasCoords}getSequence(e){const t=[],i=this.getResidueProxy();return this.eachAtom((function(e){i.index=e.residueIndex,e.index===i.traceAtomIndex&&t.push(i.getResname1())}),e),t}getAtomIndices(e){if(e&&e.string){const t=[];return this.eachAtom((function(e){t.push(e.index)}),e),new Uint32Array(t)}{const e={what:{index:!0}};return this.getAtomData(e).index}}getChainnameCount(e){const t=new Set;return this.eachChain((function(e){e.residueCount&&t.add(e.chainname)}),e),t.size}updatePosition(e,t=!0){let i=0;this.eachAtom((function(t){t.positionFromArray(e,i),i+=3}),void 0),this._hasCoords=void 0,t&&this.refreshPosition()}refreshPosition(){this.getBoundingBox(void 0,this.boundingBox),this.boundingBox.getCenter(this.center),this.spatialHash=new ju(this.atomStore,this.boundingBox),this.signals.refreshed.dispatch(this)}dispose(){this.frames&&(this.frames.length=0),this.boxes&&(this.boxes.length=0),this.bondStore.dispose(),this.backboneBondStore.dispose(),this.rungBondStore.dispose(),this.atomStore.dispose(),this.residueStore.dispose(),this.chainStore.dispose(),this.modelStore.dispose(),delete this.bondSet,delete this.atomSet}}const zp=new Ni,Up=[Fu,ku,zu,Nu,Uu,Ou,Ru,Bu,Gu,$u,Vu,Hu],$p={aspectRatio:1.5,sphereDetail:2,radialSegments:50,disableImpostor:!1,openEnded:!1,dashedCylinder:!1,labelParams:{},pointSize:2,sizeAttenuation:!1,useTexture:!0,linewidth:2};class Gp{constructor(e="shape",t={}){this.boundingBox=new Ni,this.bufferList=[],this.meshCount=0,this._primitiveData={},this.name=e,this.parameters=Ea(t,$p),Up.forEach((e=>{Object.keys(e.fields).forEach((t=>{this._primitiveData[e.getShapeKey(t)]=[]})),this._primitiveData[e.getShapeKey("name")]=[]}))}addBuffer(e){this.bufferList.push(e);const t=e.geometry;return t.boundingBox||t.computeBoundingBox(),this.boundingBox.union(t.boundingBox),this}addMesh(e,t,i,n,r){let s;e=Xa(e),t=Xa(t),Array.isArray(i)&&(i=Ga(i,e.length)),n&&(n=Xa(n)),s=void 0===n||0==n.length?{position:e,color:t,index:i}:{position:e,color:t,index:i,normal:n};const o=new vf(this,Object.assign({serial:this.meshCount,name:r},s)),a=new nm(Object.assign({picking:o},s));return this.bufferList.push(a),zp.setFromArray(e),this.boundingBox.union(zp),this.meshCount+=1,this}addSphere(e,t,i,n){return Ru.objectToShape(this,{position:e,color:t,radius:i,name:n}),this}addEllipsoid(e,t,i,n,r,s){return Uu.objectToShape(this,{position:e,color:t,radius:i,majorAxis:n,minorAxis:r,name:s}),this}addTorus(e,t,i,n,r,s){return $u.objectToShape(this,{position:e,color:t,radius:i,majorAxis:n,minorAxis:r,name:s}),this}addCylinder(e,t,i,n,r){return Nu.objectToShape(this,{position1:e,position2:t,color:i,radius:n,name:r}),this}addCone(e,t,i,n,r){return zu.objectToShape(this,{position1:e,position2:t,color:i,radius:n,name:r}),this}addArrow(e,t,i,n,r){return Fu.objectToShape(this,{position1:e,position2:t,color:i,radius:n,name:r}),this}addBox(e,t,i,n,r,s){return ku.objectToShape(this,{position:e,color:t,size:i,heightAxis:n,depthAxis:r,name:s}),this}addOctahedron(e,t,i,n,r,s){return Ou.objectToShape(this,{position:e,color:t,size:i,heightAxis:n,depthAxis:r,name:s}),this}addTetrahedron(e,t,i,n,r,s){return Bu.objectToShape(this,{position:e,color:t,size:i,heightAxis:n,depthAxis:r,name:s}),this}addText(e,t,i,n){return Gu.objectToShape(this,{position:e,color:t,size:i,text:n}),this}addPoint(e,t,i){return Vu.objectToShape(this,{position:e,color:t,name:i}),this}addWideline(e,t,i,n,r){return this.parameters.linewidth=n,Hu.objectToShape(this,{position1:e,position2:t,color:i,name:r}),this}addLabel(e,t,i,n){return console.warn("Shape.addLabel is deprecated, use .addText instead"),this.addText(e,t,i,n)}getBufferList(){const e=[];return Up.forEach((t=>{this._primitiveData[t.getShapeKey("color")].length&&e.push(t.bufferFromShape(this,this.parameters))})),this.bufferList.concat(e)}dispose(){this.bufferList.forEach((function(e){e.dispose()})),this.bufferList.length=0,Up.forEach((e=>{Object.keys(e.fields).forEach((t=>{this._primitiveData[e.getShapeKey(t)].length=0})),this._primitiveData[e.getShapeKey("name")].length=0}))}get center(){return this._center||(this._center=this.boundingBox.getCenter(new Zt)),this._center}get type(){return"Shape"}}class Vp extends tu{constructor(e,t,i){Array.isArray(e)||(e=[e]),super(e,t,i),this.type="buffer",this.parameters=Object.assign({},this.parameters,{colorScheme:null,colorScale:null,colorValue:null,colorDomain:null,colorMode:null}),this.buffer=e,this.init(i)}init(e){super.init(e),this.build()}create(){this.bufferList.push.apply(this.bufferList,this.buffer)}attach(e){this.bufferList.forEach((e=>{this.viewer.add(e),e.setParameters(this.getBufferParams())})),this.setVisibility(this.visible),e()}}const Hp=new ri,jp=new Ut;class Wp extends nm{constructor(e,t={},i){super(function(e,t){const i=t.attributes.position.array,n=t.index?t.index.array:void 0,r=e.position.length/3,s=i.length/3,o=r*s,a=new Float32Array(3*o),c=new Float32Array(3*o),l=new Float32Array(3*o);let h;return n&&(h=Ga(r*n.length,o)),{position:a,color:l,index:h,normal:c,primitiveId:e.primitiveId||jl(r,s),picking:e.picking}}(e,i),t),this.updateNormals=!1;const n=i.attributes.position.array,r=i.attributes.normal.array,s=i.index?i.index.array:void 0;this.geoPosition=n,this.geoNormal=r,this.geoIndex=s,this.positionCount=e.position.length/3,this.geoPositionCount=n.length/3,this.transformedGeoPosition=new Float32Array(3*this.geoPositionCount),this.transformedGeoNormal=new Float32Array(3*this.geoPositionCount);const o=this.geometry.attributes;if(this.meshPosition=o.position.array,this.meshColor=o.color.array,this.meshNormal=o.normal.array,this.setAttributes(e),s){const e=this.geometry.getIndex();if(!e)return void il.error("Index is null");this.meshIndex=e.array,this.makeIndex()}}setAttributes(e={},t=!1){const i=this.geometry.attributes;let n,r,s,o,a,c,l,h,u;const d=this.updateNormals;e.position&&(n=e.position,s=this.geoPosition,l=this.meshPosition,a=this.transformedGeoPosition,i.position.needsUpdate=!0,(d||t)&&(o=this.geoNormal,u=this.meshNormal,c=this.transformedGeoNormal,i.normal.needsUpdate=!0)),e.color&&(r=e.color,h=this.meshColor,i.color.needsUpdate=!0);const f=this.positionCount,m=this.geoPositionCount;for(let e=0;e 0.0 ){\ncameraPos = rayDirection * posT + rayOrigin;\ninterior = true;\nflag2 = true;\n}\n#else\nif( calcDepth( cameraPos ) <= 0.0 ){\ncameraPos = rayDirection * posT + rayOrigin;\ninterior = true;\n}\n#endif\ncameraNormal = normalize( cameraPos - cameraSpherePos );\ncameraNormal *= float(!interior) * 2.0 - 1.0;\nreturn !interior;\n}\nvoid main(void){\nbool flag = Impostor( cameraPos, cameraNormal );\n#ifdef NEAR_CLIP\nif( calcClip( cameraPos ) > 0.0 )\ndiscard;\n#endif\ngl_FragDepthEXT = calcDepth( cameraPos );\nif( !flag ){\n#ifdef NEAR_CLIP\nif( flag2 ){\ngl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( clipNear - 0.5 ) ) ) + ( 0.0000001 / vRadius ) );\n}else if( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n#else\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n#endif\n}\nif (gl_FragDepthEXT < 0.0)\ndiscard;\nif (gl_FragDepthEXT > 1.0)\ndiscard;\n#ifdef PICKING\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 vNormal = cameraNormal;\nvec3 vViewPosition = -cameraPos;\nvec4 diffuseColor = vec4( diffuse, opacity );\nReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\nvec3 totalEmissiveLight = emissive;\n#include color_fragment\n#include roughnessmap_fragment\n#include metalnessmap_fragment\n#include normal_fragment_begin\n#include lights_physical_fragment\n#include lights_fragment_begin\n#include lights_fragment_end\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\nif( interior ){\n#ifdef USE_INTERIOR_COLOR\noutgoingLight.xyz = interiorColor;\n#else\n#ifdef DIFFUSE_INTERIOR\noutgoingLight.xyz = vColor;\n#endif\n#endif\noutgoingLight.xyz *= 1.0 - interiorDarkening;\n}\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");class Zp extends im{constructor(e,t,i={}){super(t,i),this.index=Ga(this.indexSize,this.attributeSize),this.makeIndex(),this.initIndex(this.index),this.addAttributes({mapping:{type:e,value:null}}),this.setAttributes({primitiveId:Hl(this.size)})}get attributeSize(){return this.size*this.mappingSize}get indexSize(){return this.size*this.mappingIndicesSize}addAttributes(e){const t={};for(const i in e){const n=e[i];t[i]={type:n.type,value:null}}super.addAttributes(t)}getAttributeIndex(e){return 3*e*this.mappingSize}setAttributes(e){e&&!e.position&&e.position1&&e.position2&&(e.position=Ul(e.position1,e.position2));const t=this.size,i=this.mappingSize,n=this.geometry.attributes;let r,s,o,a,c,l,h;for(const u in e)if("index"!==u&&"picking"!==u){s=e[u],r=n[u],o=r.itemSize,a=r.array;for(let e=0;e0&&this.parameters.alphaTest<=1&&(t.ALPHATEST=this.parameters.alphaTest.toPrecision(2)),t}setUniforms(e){e&&void 0!==e.edgeBleach&&(this.makeTexture(),e.map=this.tex),super.setUniforms(e)}dispose(){super.dispose(),this.tex&&this.tex.dispose()}}ml.add("point",sg);class og extends tu{constructor(e,t,i){super(e,t,i),this.type="dot",this.parameters=Object.assign({thresholdType:{type:"select",rebuild:!0,options:{value:"value",sigma:"sigma"}},thresholdMin:{type:"number",precision:3,max:1/0,min:-1/0,rebuild:!0},thresholdMax:{type:"number",precision:3,max:1/0,min:-1/0,rebuild:!0},thresholdOut:{type:"boolean",rebuild:!0},dotType:{type:"select",rebuild:!0,options:{"":"",sphere:"sphere",point:"point"}},radiusType:{type:"select",options:{"":"",value:"value","abs-value":"abs-value","value-min":"value-min",deviation:"deviation",size:"size"}},radius:{type:"number",precision:3,max:10,min:.001,property:"size"},scale:{type:"number",precision:3,max:10,min:.001},sphereDetail:!0,disableImpostor:!0,pointSize:{type:"number",precision:1,max:100,min:0,buffer:!0},sizeAttenuation:{type:"boolean",buffer:!0},sortParticles:{type:"boolean",rebuild:!0},useTexture:{type:"boolean",buffer:!0},alphaTest:{type:"range",step:.001,max:1,min:0,buffer:!0},forceTransparent:{type:"boolean",buffer:!0},edgeBleach:{type:"range",step:.001,max:1,min:0,buffer:!0}},this.parameters,{colorScheme:{type:"select",update:"color",options:{"":"",value:"value",uniform:"uniform",random:"random"}}}),e instanceof Zf?(this.surface=void 0,this.volume=new Lm(e)):(this.surface=e,this.volume=void 0),this.init(i)}init(e){var t=e||{};t.colorScheme=Ia(t.colorScheme,"uniform"),t.colorValue=Ia(t.colorValue,14540253),this.thresholdType=Ia(t.thresholdType,"sigma"),this.thresholdMin=Ia(t.thresholdMin,2),this.thresholdMax=Ia(t.thresholdMax,1/0),this.thresholdOut=Ia(t.thresholdOut,!1),this.dotType=Ia(t.dotType,"point"),this.radius=Ia(t.radius,.1),this.scale=Ia(t.scale,1),this.pointSize=Ia(t.pointSize,1),this.sizeAttenuation=Ia(t.sizeAttenuation,!0),this.sortParticles=Ia(t.sortParticles,!1),this.useTexture=Ia(t.useTexture,!1),this.alphaTest=Ia(t.alphaTest,.5),this.forceTransparent=Ia(t.forceTransparent,!1),this.edgeBleach=Ia(t.edgeBleach,0),super.init(t),this.build()}attach(e){this.bufferList.forEach((e=>{this.viewer.add(e)})),this.setVisibility(this.visible),e()}create(){var e={};if(this.volume){var t,i,n=this.volume;"sigma"===this.thresholdType?(t=n.getValueForSigma(this.thresholdMin),i=n.getValueForSigma(this.thresholdMax)):(t=this.thresholdMin,i=this.thresholdMax),n.setFilter(t,i,this.thresholdOut),Object.assign(e,{position:n.getDataPosition(),color:n.getDataColor(this.getColorParams())}),"sphere"===this.dotType&&Object.assign(e,{radius:n.getDataSize(this.radius,this.scale),picking:n.getDataPicking()})}else{var r=this.surface;Object.assign(e,{position:r.getPosition(),color:r.getColor(this.getColorParams())}),"sphere"===this.dotType&&Object.assign(e,{radius:r.getSize(this.radius,this.scale),picking:r.getPicking()})}"sphere"===this.dotType?this.dotBuffer=new tg(e,this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!1})):this.dotBuffer=new sg(e,this.getBufferParams({pointSize:this.pointSize,sizeAttenuation:this.sizeAttenuation,sortParticles:this.sortParticles,useTexture:this.useTexture,alphaTest:this.alphaTest,forceTransparent:this.forceTransparent,edgeBleach:this.edgeBleach})),this.bufferList.push(this.dotBuffer)}update(e={}){if(0===this.bufferList.length)return;const t={};e.color&&(this.volume?Object.assign(t,{color:this.volume.getDataColor(this.getColorParams())}):Object.assign(t,{color:this.surface.getColor(this.getColorParams())})),"sphere"===this.dotType&&(e.radius||e.scale)&&(this.volume?Object.assign(t,{radius:this.volume.getDataSize(this.radius,this.scale)}):Object.assign(t,{radius:this.surface.getSize(this.radius,this.scale)})),this.dotBuffer.setAttributes(t)}setParameters(e,t={},i){return e&&void 0!==e.thresholdType&&this.volume instanceof Zf&&("value"===this.thresholdType&&"sigma"===e.thresholdType?(this.thresholdMin=this.volume.getSigmaForValue(this.thresholdMin),this.thresholdMax=this.volume.getSigmaForValue(this.thresholdMax)):"sigma"===this.thresholdType&&"value"===e.thresholdType&&(this.thresholdMin=this.volume.getValueForSigma(this.thresholdMin),this.thresholdMax=this.volume.getValueForSigma(this.thresholdMax)),this.thresholdType=e.thresholdType),e&&void 0!==e.radiusType&&("radius"===e.radiusType?this.radius=.1:this.radius=parseFloat(e.radiusType),t.radius=!0,"sphere"!==this.dotType||el&&!this.disableImpostor||(i=!0)),e&&void 0!==e.radius&&(t.radius=!0,"sphere"!==this.dotType||el&&!this.disableImpostor||(i=!0)),e&&void 0!==e.scale&&(t.scale=!0,"sphere"!==this.dotType||el&&!this.disableImpostor||(i=!0)),super.setParameters(e,t,i),this}}ul.add("shader/Image.vert","uniform float clipRadius;\nuniform vec3 clipCenter;\nvarying vec2 vUv;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvarying vec3 vViewPosition;\n#endif\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\nvoid main() {\n#include begin_vertex\n#include project_vertex\nvUv = uv;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvViewPosition = -mvPosition.xyz;\n#endif\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n}"),ul.add("shader/Image.frag","uniform sampler2D map;\nuniform float opacity;\nuniform vec2 mapSize;\nuniform float clipNear;\nuniform float clipRadius;\nvarying vec2 vUv;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvarying vec3 vViewPosition;\n#endif\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#if defined( PICKING )\nuniform sampler2D pickingMap;\nuniform float objectId;\n#else\n#include fog_pars_fragment\n#endif\n#if defined( CUBIC_INTERPOLATION )\n#if defined( CATMULROM_FILTER ) || defined( MITCHELL_FILTER )\n#if defined( CATMULROM_FILTER )\nconst float B = 0.0;\nconst float C = 0.5;\n#elif defined( MITCHELL_FILTER )\nconst float B = 0.333;\nconst float C = 0.333;\n#endif\nfloat filter( float x ){\nfloat f = x;\nif( f < 0.0 ){\nf = -f;\n}\nif( f < 1.0 ){\nreturn ( ( 12.0 - 9.0 * B - 6.0 * C ) * ( f * f * f ) +\n( -18.0 + 12.0 * B + 6.0 *C ) * ( f * f ) +\n( 6.0 - 2.0 * B ) ) / 6.0;\n}else if( f >= 1.0 && f < 2.0 ){\nreturn ( ( -B - 6.0 * C ) * ( f * f * f )\n+ ( 6.0 * B + 30.0 * C ) * ( f *f ) +\n( - ( 12.0 * B ) - 48.0 * C ) * f +\n8.0 * B + 24.0 * C ) / 6.0;\n}else{\nreturn 0.0;\n}\n}\n#elif defined( BSPLINE_FILTER )\nfloat filter( float x ){\nfloat f = x;\nif( f < 0.0 ){\nf = -f;\n}\nif( f >= 0.0 && f <= 1.0 ){\nreturn ( 2.0 / 3.0 ) + ( 0.5 ) * ( f * f * f ) - ( f * f );\n}else if( f > 1.0 && f <= 2.0 ){\nreturn 1.0 / 6.0 * pow( ( 2.0 - f ), 3.0 );\n}\nreturn 1.0;\n}\n#else\nfloat filter( float x ){\nreturn 1.0;\n}\n#endif\nvec4 biCubic( sampler2D tex, vec2 texCoord ){\nvec2 texelSize = 1.0 / mapSize;\ntexCoord -= texelSize / 2.0;\nvec4 nSum = vec4( 0.0 );\nfloat nDenom = 0.0;\nvec2 cell = fract( texCoord * mapSize );\nfor( float m = -1.0; m <= 2.0; ++m ){\nfor( float n = -1.0; n <= 2.0; ++n ){\nvec4 vecData = texture2D(\ntex, texCoord + texelSize * vec2( m, n )\n);\nfloat c = filter( m - cell.x ) * filter( -n + cell.y );\nnSum += vecData * c;\nnDenom += c;\n}\n}\nreturn nSum / nDenom;\n}\n#endif\nvoid main(){\n#include nearclip_fragment\n#include radiusclip_fragment\n#if defined( CUBIC_INTERPOLATION )\ngl_FragColor = biCubic( map, vUv );\n#else\ngl_FragColor = texture2D( map, vUv );\n#endif\n#if defined( PICKING )\nif( gl_FragColor.a < 0.3 )\ndiscard;\ngl_FragColor = vec4( texture2D( pickingMap, vUv ).xyz, objectId );\n#else\nif( gl_FragColor.a < 0.01 )\ndiscard;\ngl_FragColor.a *= opacity;\n#include fog_fragment\n#endif\n}");const ag=new Uint16Array([0,1,2,1,3,2]),cg=new Float32Array([0,1,0,0,1,1,1,0]),lg=Object.assign({filter:"nearest",forceTransparent:!0},em),hg=Object.assign({filter:{updateShader:!0,uniform:!0}},tm);class ug extends im{constructor(e,t){super({position:e.position,index:ag,picking:e.picking},t),this.parameterTypes=hg,this.alwaysTransparent=!0,this.hasWireframe=!1,this.vertexShader="Image.vert",this.fragmentShader="Image.frag";const{imageData:i,width:n,height:r}=e,s=new Ar(i,n,r);s.flipY=!0,this.tex=s;const o=i.length,a=new Uint8Array(o);for(let e=0;e>16&255,a[e+1]=t>>8&255,a[e+2]=255&t}const c=new Ar(a,n,r);c.flipY=!0,c.minFilter=re,c.magFilter=re,this.pickingTex=c,this.addUniforms({map:{value:s},pickingMap:{value:c},mapSize:{value:new zt(n,r)}}),this.geometry.setAttribute("uv",new An(cg,2))}get defaultParameters(){return lg}getDefines(e){const t=super.getDefines(e),i=this.parameters.filter;return i.startsWith("cubic")&&(t.CUBIC_INTERPOLATION=1,i.endsWith("bspline")?t.BSPLINE_FILTER=1:i.endsWith("catmulrom")?t.CATMULROM_FILTER=1:i.endsWith("mitchell")&&(t.MITCHELL_FILTER=1)),t}updateTexture(){const e=this.tex,t=this.parameters.filter;t.startsWith("cubic")?(e.minFilter=re,e.magFilter=re):"linear"===t?(e.minFilter=ae,e.magFilter=ae):(e.minFilter=re,e.magFilter=re),e.needsUpdate=!0,this.pickingTex.needsUpdate=!0}makeMaterial(){super.makeMaterial(),this.updateTexture();const e=this.material;e.uniforms.map.value=this.tex,e.blending=u,e.needsUpdate=!0;const t=this.wireframeMaterial;t.uniforms.map.value=this.tex,t.blending=u,t.needsUpdate=!0;const i=this.pickingMaterial;i.uniforms.map.value=this.tex,i.uniforms.pickingMap.value=this.pickingTex,i.blending=u,i.needsUpdate=!0}setUniforms(e){e&&void 0!==e.filter&&(this.updateTexture(),e.map=this.tex),super.setUniforms(e)}}class dg{constructor(e,t){const i=t||{};this.dimension=Ia(i.dimension,"x"),this.positionType=Ia(i.positionType,"percent"),this.position=Ia(i.position,30),this.thresholdType=Ia(i.thresholdType,"sigma"),this.thresholdMin=Ia(i.thresholdMin,-1/0),this.thresholdMax=Ia(i.thresholdMax,1/0),this.normalize=Ia(i.normalize,!1),this.volume=e}getPositionFromCoordinate(e){const t=this.dimension,i=this.volume,n=i.matrix,r=(new Zt).setFromMatrixPosition(n)[t],s=(new Zt).setFromMatrixScale(n)[t];let o;return o="x"===t?i.nx:"y"===t?i.ny:i.nz,Math.round(((e-r)/(o/100)+1)/s)}getData(e){e=e||{};const t=this.volume,i=t.data,n=t.matrix;let r;function s(e){return Math.round(e/100*(r-1))}function o(e,i,n,r){return 3*(n*t.ny*t.nx+i*t.nx+e)+r}r="coordinate"===this.positionType?this.getPositionFromCoordinate(this.position):this.position;const a=new Float32Array(12),c=new Zt;let l,h,u,d,f,m=0,p=0,g=0,v=t.nx,y=t.ny,x=t.nz;function b(e,t,i,r){c.set(e,t,i).applyMatrix4(n).toArray(a,r)}"x"===this.dimension?(u=s(t.nx),d=t.ny-1,f=t.nz-1,l=t.nz,h=t.ny,m=u,v=m+1,b(u,0,0,0),b(u,d,0,3),b(u,0,f,6),b(u,d,f,9)):"y"===this.dimension?(u=t.nx-1,d=s(t.ny),f=t.nz-1,l=t.nz,h=t.nx,p=d,y=p+1,b(0,d,0,0),b(u,d,0,3),b(0,d,f,6),b(u,d,f,9)):"z"===this.dimension&&(u=t.nx-1,d=t.ny-1,f=s(t.nz),l=t.nx,h=t.ny,g=f,x=g+1,b(0,0,f,0),b(0,d,f,3),b(u,0,f,6),b(u,d,f,9));let _=0,w=0;const S=new Uint8Array(l*h*4),A=new Float32Array(l*h);let M,C;"sigma"===this.thresholdType?(M=t.getValueForSigma(this.thresholdMin),C=t.getValueForSigma(this.thresholdMax)):(M=this.thresholdMin,C=this.thresholdMax);const P=Object.assign({},e.colorParams,{volume:t});this.normalize&&(P.domain=[0,1]);const T=al.getScheme(P),I=new Float32Array(3),E=T.getScale();let D,L=0,R=0;if(this.normalize){L=1/0,D=-1/0;for(let e=p;eD&&(D=r)}R=D-L}for(let e=p;eM&&s{this.viewer.add(e)})),this.setVisibility(this.visible),e()}create(){const e=new dg(this.volume,{positionType:this.positionType,position:this.position,dimension:this.dimension,thresholdType:this.thresholdType,thresholdMin:this.thresholdMin,thresholdMax:this.thresholdMax,normalize:this.normalize}),t=new ug(e.getData({colorParams:this.getColorParams()}),this.getBufferParams({filter:this.filter}));this.bufferList.push(t)}}function mg(e){il.error(`makeRepresentation: representation type ${e} unknown`)}const pg={name:"some element",status:""};class gg{constructor(e,t={}){this.stage=e,this.signals={statusChanged:new mc.Signal,nameChanged:new mc.Signal,disposed:new mc.Signal},this.parameters=Ea(t,this.defaultParameters),this.uuid=ec()}get defaultParameters(){return pg}get name(){return this.parameters.name}setStatus(e){return this.parameters.status=e,this.signals.statusChanged.dispatch(e),this}setName(e){return this.parameters.name=e,this.signals.nameChanged.dispatch(e),this}dispose(){this.signals.disposed.dispatch()}}const vg=Object.assign({visible:!0},pg);class yg extends gg{constructor(e,t,i={},n){super(e,Object.assign({name:t.type},i)),this.parent=n,this.signals=Object.assign({visibilityChanged:new mc.Signal,parametersChanged:new mc.Signal},this.signals),this.setRepresentation(t)}get defaultParameters(){return vg}get visible(){return this.parameters.visible}get type(){return"representation"}getType(){return this.repr.type}setRepresentation(e){this._disposeRepresentation(),this.repr=e,this.stage.tasks.listen(this.repr.tasks),this.updateVisibility()}_disposeRepresentation(){this.repr&&(this.stage.tasks.unlisten(this.repr.tasks),this.repr.dispose())}dispose(){this.parent&&this.parent.hasRepresentation(this)?this.parent.removeRepresentation(this):(this._disposeRepresentation(),this.signals.disposed.dispatch())}setVisibility(e){return this.parameters.visible=e,this.updateVisibility(),this.signals.visibilityChanged.dispatch(this.parameters.visible),this}getVisibility(){return this.parent?this.parent.parameters.visible&&this.parameters.visible:this.parameters.visible}toggleVisibility(){return this.setVisibility(!this.parameters.visible)}updateVisibility(){this.repr.setVisibility(this.getVisibility())}update(e){return this.repr.update(e),this}build(e){return this.repr.build(e),this}setSelection(e){const t=this.repr;return t.setSelection&&t.setSelection(e),this}setParameters(e){return this.repr.setParameters(e),this.signals.parametersChanged.dispatch(this.repr.getParameters()),this}getParameters(){return this.repr.getParameters()}setColor(e){return this.repr.setColor(e),this}}const xg=new ri,bg=new Zt,_g={name:"",status:"",visible:!0};class wg{constructor(e,t,i={}){this.stage=e,this.object=t,this.signals={representationAdded:new mc.Signal,representationRemoved:new mc.Signal,visibilityChanged:new mc.Signal,matrixChanged:new mc.Signal,statusChanged:new mc.Signal,nameChanged:new mc.Signal,disposed:new mc.Signal},this.reprList=[],this.annotationList=[],this.matrix=new ri,this.position=new Zt,this.quaternion=new qt,this.scale=new Zt(1,1,1),this.transform=new ri,this.parameters=Ea(i,this.defaultParameters),this.uuid=ec(),this.viewer=e.viewer,this.controls=new Cm(this)}get defaultParameters(){return _g}get name(){return this.parameters.name}get status(){return this.parameters.status}get visible(){return this.parameters.visible}setPosition(e){return Array.isArray(e)?this.position.fromArray(e):this.position.copy(e),this.updateMatrix(),this}setRotation(e){if(Array.isArray(e))if(3===e.length){const t=(new ai).fromArray(e);this.quaternion.setFromEuler(t)}else this.quaternion.fromArray(e);else e instanceof ai?this.quaternion.setFromEuler(e):this.quaternion.copy(e);return this.updateMatrix(),this}setScale(e){return this.scale.set(e,e,e),this.updateMatrix(),this}setTransform(e){return this.transform.copy(e),this.updateMatrix(),this}updateMatrix(){const e=this.getCenterUntransformed(bg);this.matrix.makeTranslation(-e.x,-e.y,-e.z),xg.makeRotationFromQuaternion(this.quaternion),this.matrix.premultiply(xg),xg.makeScale(this.scale.x,this.scale.y,this.scale.z),this.matrix.premultiply(xg);const t=this.position;xg.makeTranslation(t.x+e.x,t.y+e.y,t.z+e.z),this.matrix.premultiply(xg),this.matrix.premultiply(this.transform),this.updateRepresentationMatrices(),this.stage.viewer.updateBoundingBox(),this.signals.matrixChanged.dispatch(this.matrix)}updateRepresentationMatrices(){this.reprList.forEach((e=>{e.setParameters({matrix:this.matrix})}))}addAnnotation(e,t,i){const n=new wm(this,e,t,i);return this.annotationList.push(n),n}eachAnnotation(e){this.annotationList.slice().forEach(e)}removeAnnotation(e){const t=this.annotationList.indexOf(e);-1!==t&&(this.annotationList.splice(t,1),e.dispose())}removeAllAnnotations(){this.eachAnnotation((e=>e.dispose())),this.annotationList.length=0}_addRepresentation(t,i,n,r=!1){const s=n||{},o=this.stage.getParameters();s.matrix=this.matrix.clone(),s.quality=s.quality||o.quality,s.disableImpostor=Ia(s.disableImpostor,!o.impostor),s.useWorker=Ia(s.useWorker,o.workerDefault),s.visible=Ia(s.visible,!0);const a=Object.assign({},s,{visible:this.parameters.visible&&s.visible}),c=function(t,i,n,r){var s;if(e.Debug&&il.time("makeRepresentation "+t),i instanceof Fp){if(!(s=ll.get(t)))return void mg(t)}else if(i instanceof Xf)if("surface"===t)s=lm;else{if("dot"!==t)return void mg(t);s=og}else if(i instanceof Zf)if("surface"===t)s=lm;else if("dot"===t)s=og;else{if("slice"!==t)return void mg(t);s=fg}else if(i instanceof Gp)s=Vp,i=i.getBufferList();else{if("buffer"!==t)return void il.error("makeRepresentation: object "+i+" unknown");s=Vp}const o=new s(i,n,r);return e.Debug&&il.timeEnd("makeRepresentation "+t),o}(t,i,this.viewer,a),l=new yg(this.stage,c,s,this);return r||(this.reprList.push(l),this.signals.representationAdded.dispatch(l)),l}addBufferRepresentation(e,t){return this._addRepresentation.call(this,"buffer",e,t)}hasRepresentation(e){return-1!==this.reprList.indexOf(e)}eachRepresentation(e){this.reprList.slice().forEach(e)}removeRepresentation(e){const t=this.reprList.indexOf(e);-1!==t&&(this.reprList.splice(t,1),e.dispose(),this.signals.representationRemoved.dispatch(e))}updateRepresentations(e){this.reprList.forEach((t=>t.update(e))),this.stage.viewer.requestRender()}removeAllRepresentations(){this.eachRepresentation((e=>e.dispose()))}dispose(){this.removeAllAnnotations(),this.removeAllRepresentations(),this.reprList.length=0,this.signals.disposed.dispatch()}setVisibility(e){return this.parameters.visible=e,this.eachRepresentation((e=>e.updateVisibility())),this.eachAnnotation((e=>e.updateVisibility())),this.signals.visibilityChanged.dispatch(e),this}setStatus(e){return this.parameters.status=e,this.signals.statusChanged.dispatch(e),this}setName(e){return this.parameters.name=e,this.signals.nameChanged.dispatch(e),this}getBox(...e){return this.getBoxUntransformed(...e).clone().applyMatrix4(this.matrix)}getCenter(...e){return this.getCenterUntransformed(...e).clone().applyMatrix4(this.matrix)}getZoom(...e){return this.stage.getZoomForBox(this.getBox(...e))}getBoxUntransformed(...e){return new Ni}getCenterUntransformed(...e){return this.getBoxUntransformed().getCenter(new Zt)}autoView(e){this.stage.animationControls.zoomMove(this.getCenter(),this.getZoom(),Ia(e,0))}}class Sg{constructor(e=[]){this.list=e;const t=e.length;for(let i=0;i0?this.list[0]:void 0}forEach(e){return this.list.forEach(e),this}dispose(){return this.forEach((e=>e.dispose()))}}class Ag extends Sg{setParameters(e){return this.forEach((t=>t.setParameters(e)))}setVisibility(e){return this.forEach((t=>t.setVisibility(e)))}setSelection(e){return this.forEach((t=>t.setSelection(e)))}setColor(e){return this.forEach((t=>t.setColor(e)))}update(e){return this.forEach((t=>t.update(e)))}build(e){return this.forEach((t=>t.build(e)))}dispose(e){return this.forEach((e=>e.dispose()))}}const Mg=Object.assign({defaultStep:1,defaultTimeout:50,defaultInterpolateType:"",defaultInterpolateStep:5,defaultMode:"loop",defaultDirection:"forward",initialFrame:0},pg);class Cg extends gg{constructor(e,t,i={}){super(e,Object.assign({name:t.name},i)),this.trajectory=t,this.signals=Object.assign(this.signals,{frameChanged:new mc.Signal,playerChanged:new mc.Signal,countChanged:new mc.Signal,parametersChanged:new mc.Signal}),t.signals.frameChanged.add((e=>{this.signals.frameChanged.dispatch(e)})),t.signals.playerChanged.add((e=>{this.signals.playerChanged.dispatch(e)})),t.signals.countChanged.add((e=>{this.signals.countChanged.dispatch(e)})),void 0!==i.initialFrame&&this.setFrame(i.initialFrame)}get defaultParameters(){return Mg}get type(){return"trajectory"}setFrame(e){this.trajectory.setFrame(e)}setParameters(e={}){this.trajectory.setParameters(e),this.signals.parametersChanged.dispatch(e)}dispose(){this.trajectory.dispose(),super.dispose()}}class Pg{constructor(e,t){this.name=e,this.path=t,this.coordinates=[],this.boxes=[],this.times=[],this.timeOffset=0,this.deltaTime=1}get type(){return"Frames"}}class Tg{constructor(e,t){let i,n;if(this.A=new Mf(3,3),this.W=new Mf(1,3),this.U=new Mf(3,3),this.V=new Mf(3,3),this.VH=new Mf(3,3),this.R=new Mf(3,3),this.tmp=new Mf(3,3),this.c=new Mf(3,3),e instanceof Fp)i=e.atomCount;else{if(!(e instanceof Float32Array))return;i=e.length/3}if(t instanceof Fp)n=t.atomCount;else{if(!(t instanceof Float32Array))return;n=t.length/3}const r=Math.min(i,n),s=new Mf(3,r),o=new Mf(3,r);this.coords1t=new Mf(r,3),this.coords2t=new Mf(r,3),this.transformationMatrix=new ri,this.c.data.set([1,0,0,0,1,0,0,0,-1]),this.prepCoords(e,s,r,!1),this.prepCoords(t,o,r,!1),this._superpose(s,o)}_superpose(t,i){this.mean1=If(t),this.mean2=If(i),Ef(t,this.mean1),Ef(i,this.mean2),Cf(this.coords1t,t),Cf(this.coords2t,i),Pf(this.A,this.coords2t,this.coords1t),Of(this.A,this.W,this.U,this.V),function(e,t){const i=e.data,n=t.data,r=i[4],s=i[8],o=i[5],a=i[7],c=i[0],l=c*r,h=c*o,u=i[3],d=i[1],f=u*d,m=i[2],p=u*m,g=i[6],v=g*d,y=g*m,x=1/(l*s-h*a-f*s+p*a+v*o-y*r);n[0]=(r*s-o*a)*x,n[1]=-(d*s-m*a)*x,n[2]=-(-d*o+m*r)*x,n[3]=-(u*s-o*g)*x,n[4]=(c*s-y)*x,n[5]=-(h-p)*x,n[6]=-(-u*a+r*g)*x,n[7]=-(c*a-v)*x,n[8]=(l-f)*x}(this.V,this.VH),Tf(this.R,this.U,this.VH),function(e){const t=e.data;return t[0]*t[4]*t[8]-t[0]*t[5]*t[7]-t[3]*t[1]*t[8]+t[3]*t[2]*t[7]+t[6]*t[1]*t[5]-t[6]*t[2]*t[4]}(this.R)<0&&(e.Debug&&il.log("R not a right handed system"),Tf(this.tmp,this.c,this.VH),Tf(this.R,this.U,this.tmp));const n=new Mf(4,4),r=new Mf(4,4),s=new Mf(4,4),o=new Mf(4,4),a=new Mf(4,4),c=new Mf(4,4),l=this.R.data,h=this.mean1,u=this.mean2;o.data.set([1,0,0,-h[0],0,1,0,-h[1],0,0,1,-h[2],0,0,0,1]),a.data.set([l[0],l[1],l[2],0,l[3],l[4],l[5],0,l[6],l[7],l[8],0,0,0,0,1]),c.data.set([1,0,0,u[0],0,1,0,u[1],0,0,1,u[2],0,0,0,1]),Cf(r,o),Pf(n,a,r),Cf(s,n),Pf(r,c,s),Cf(n,r),this.transformationMatrix.elements=n.data}prepCoords(e,t,i,n){let r=0;const s=t.data;let o=3,a=3*i;if(n&&(a=4*i,o=4),e instanceof Fp)e.eachAtom((function(e){r{e!==this&&this.pause()}),this);const i=Ia(e.frameCount,1);this.traj=e,this.parameters=Ea(t,Ig),this.parameters.end=Math.min(Ia(t.end,i-1),i-1),this.parameters.step=Ia(t.step,Math.ceil((i+1)/100)),this._currentFrame=this.parameters.start,this._direction="bounce"===this.parameters.direction?"forward":this.parameters.direction,e.signals.countChanged.add((e=>{this.parameters.end=Math.min(Ia(this.parameters.end,e-1),e-1)}),this),this._animate=this._animate.bind(this)}get isRunning(){return this._run}setParameters(e={}){Da(this.parameters,e),void 0!==e.direction&&"bounce"!==this.parameters.direction&&(this._direction=this.parameters.direction)}_animate(){if(!this._run)return;this._currentTime=window.performance.now();const e=this._currentTime-this._previousTime,t=this.parameters.interpolateType?this.parameters.interpolateStep:1,i=this.parameters.timeout/t,n=this.traj;if(n&&n.frameCount&&!n.inProgress&&e>=i)if(this.parameters.interpolateType)if(this._currentStep>this.parameters.interpolateStep&&(this._currentStep=1),1===this._currentStep&&(this._currentFrame=this._nextInterpolated()),n.hasFrame(this._currentFrame)){this._currentStep+=1;const e=this._currentStep/(this.parameters.interpolateStep+1),[t,i,r,s]=this._currentFrame;n.setFrameInterpolated(t,i,r,s,e,this.parameters.interpolateType),this._previousTime=this._currentTime}else n.loadFrame(this._currentFrame);else{const e=this._next();n.hasFrame(e)?(n.setFrame(e),this._previousTime=this._currentTime):n.loadFrame(e)}window.requestAnimationFrame(this._animate)}_next(){const e=this.parameters;let t;return t="forward"===this._direction?this.traj.currentFrame+e.step:this.traj.currentFrame-e.step,(t>e.end||t=e.end?i=e.start:"backward"===e.direction&&t<=e.start&&(i=e.end),this.traj.setFrame(i),this._run=!0,this._animate(),this.signals.startedRunning.dispatch()}}pause(){this._run=!1,this.signals.haltedRunning.dispatch()}stop(){this.pause(),this.traj.setFrame(this.parameters.start)}}class Dg{constructor(e,t,i={}){this.signals={countChanged:new mc.Signal,frameChanged:new mc.Signal,playerChanged:new mc.Signal},this.frameCache={},this.loadQueue={},this.boxCache={},this.pathCache={},this.frameCacheSize=0,this._frameCount=0,this._currentFrame=-1,this._disposed=!1,this.deltaTime=Ia(i.deltaTime,0),this.timeOffset=Ia(i.timeOffset,0),this.centerPbc=Ia(i.centerPbc,!1),this.removePbc=Ia(i.removePbc,!1),this.removePeriodicity=Ia(i.removePeriodicity,!1),this.superpose=Ia(i.superpose,!1),this.name=e.replace(/^.*[\\/]/,""),this.trajPath=e,this.selection=new $c(Ia(i.sele,"backbone and not hydrogen")),this.selection.signals.stringChanged.add((()=>{this.selectionIndices=this.structure.getAtomIndices(this.selection),this._resetCache(),this._saveInitialCoords(),this.setFrame(this._currentFrame)}))}get frameCount(){return this._frameCount}get currentFrame(){return this._currentFrame}_init(e){this.setStructure(e),this._loadFrameCount(),this.setPlayer(new Eg(this))}_loadFrameCount(){}setStructure(e){this.structure=e,this.atomCount=e.atomCount,this.backboneIndices=this._getIndices(new $c("backbone and not hydrogen")),this._makeAtomIndices(),this._saveStructureCoords(),this.selectionIndices=this._getIndices(this.selection),this._resetCache(),this._saveInitialCoords(),this.setFrame(this._currentFrame)}_saveInitialCoords(){this.structure.hasCoords()?(this.initialCoords=new Float32Array(this.structureCoords),this._makeSuperposeCoords()):this.frameCache[0]?(this.initialCoords=new Float32Array(this.frameCache[0]),this._makeSuperposeCoords()):this.loadFrame(0,(()=>this._saveInitialCoords()))}_saveStructureCoords(){this.structureCoords=this.structure.getAtomData({what:{position:!0}}).position}setSelection(e){return this.selection.setString(e),this}_getIndices(e){let t=0;const i=e.test,n=[];return i&&this.structure.eachAtom((e=>{i(e)&&n.push(t),t+=1})),n}_makeSuperposeCoords(){const e=3*this.selectionIndices.length;this.coords1=new Float32Array(e),this.coords2=new Float32Array(e);const t=this.initialCoords,i=this.coords2;for(let n=0;n!!this.frameCache[e])):!!this.frameCache[e]}setFrame(e,t){return void 0===e||(this.inProgress=!0,-1===e||this.frameCache[e]?(this._updateStructure(e),t&&t()):this.loadFrame(e,(()=>{this._updateStructure(e),t&&t()}))),this}_interpolate(e,t,i,n,r,s){const o=this.frameCache;let a;a="spline"===s?function(e,t,i,n,r){const s=e.length,o=new Float32Array(s);for(let a=0;a{this._interpolate(e,t,i,n,r,s),o&&o()})):(this._interpolate(e,t,i,n,r,s),o&&o()),this}loadFrame(e,t){Array.isArray(e)?e.forEach((e=>{this.loadQueue[e]||this.frameCache[e]||(this.loadQueue[e]=!0,this._loadFrame(e,(()=>{delete this.loadQueue[e]})))})):this.loadQueue[e]||this.frameCache[e]||(this.loadQueue[e]=!0,this._loadFrame(e,(()=>{delete this.loadQueue[e],t&&t()})))}_loadFrame(e,t){il.error("Trajectory._loadFrame not implemented",e,t)}_updateStructure(e){this._disposed?console.error("updateStructure: traj disposed"):(-1===e?this.structureCoords&&this.structure.updatePosition(this.structureCoords):this.structure.updatePosition(this.frameCache[e]),this.structure.trajectory={name:this.trajPath,frame:e},this._currentFrame=e,this.inProgress=!1,this.signals.frameChanged.dispatch(e))}_doSuperpose(e){const t=3*this.selectionIndices.length,i=this.coords1,n=this.coords2;for(let n=0;n0&&this.centerPbc){const e=[t[0],t[4],t[8]],n=function(e,t,i){return[zl(t,i[0],3,0,e),zl(t,i[1],3,1,e),zl(t,i[2],3,2,e)]}(this.backboneIndices,i,e);!function(e,t,i){if(0===i[0]||0===i[8]||0===i[4])return;const n=e.length,r=i[0],s=i[1],o=i[2],a=-t[0]+r+r/2,c=-t[1]+s+s/2,l=-t[2]+o+o/2;for(let t=0;t.5&&(e[r+n]-=t[3*n+n]*Math.round(s))}}(i,t,e)}this.removePbc&&function(e,t){if(0===t[0]||0===t[8]||0===t[4])return;const i=e.length;for(let n=3;n.9*t[3*i+i])if(r>0)for(let r=0;r<3;++r)e[n+r]-=t[3*i+r];else for(let r=0;r<3;++r)e[n+r]+=t[3*i+r]}}(i,t)}this.selectionIndices.length>0&&this.coords1&&this.superpose&&this._doSuperpose(i),this.frameCache[e]=i,this.boxCache[e]=t,this.frameCacheSize+=1}_setFrameCount(e){e!==this._frameCount&&(this._frameCount=e,this.signals.countChanged.dispatch(e))}dispose(){this._resetCache(),this._disposed=!0,this.player&&this.player.stop()}setPlayer(e){this.player=e,this.signals.playerChanged.dispatch(e)}getFrameTime(e){return this.timeOffset+e*this.deltaTime}}class Lg extends Dg{constructor(e,t,i){const n=i||{};n.timeOffset=Ia(n.timeOffset,e.timeOffset),n.deltaTime=Ia(n.deltaTime,e.deltaTime),super("",t,n),this.name=e.name,this.path=e.path,this.frames=e.coordinates,this.boxes=e.boxes,this._init(t)}get type(){return"frames"}_makeAtomIndices(){"StructureView"===this.structure.type?this.atomIndices=this.structure.getAtomIndices():this.atomIndices=void 0}_loadFrame(e,t){let i;const n=this.frames[e];if(this.atomIndices){const e=this.atomIndices,t=e.length;i=new Float32Array(3*t);for(let r=0;r{const e=n.response;if(!e)return void il.error(`empty arrayBuffer for '${r}'`);const s=new Int32Array(e,0,1)[0],o=new Float32Array(e,8,9),a=new Float32Array(e,44);this._process(t,o,a,s),"function"==typeof i&&i()}),!1),n.send(s)}_loadFrameCount(){const t=new XMLHttpRequest,i=e.TrajectoryDatasource.getCountUrl(this.trajPath);t.open("GET",i,!0),t.addEventListener("load",(()=>{this._setFrameCount(parseInt(t.response))}),!1),t.send()}}class Og extends Dg{constructor(e,t,i){super("",t,i),this.requestCallback=e,this._init(t)}get type(){return"callback"}_makeAtomIndices(){const e=[];if("StructureView"===this.structure.type){const t=this.structure.getAtomIndices(),i=t.length;let n=t[0],r=t[0];for(let s=1;s{this._process(e,i,n,r),"function"==typeof t&&t()}),e,this.atomIndices)}_loadFrameCount(){this.requestCallback((e=>this._setFrameCount(e)))}}Fp.prototype.getView=function(e){return new Bg(this,e)};class Bg extends Fp{constructor(e,t){super(),this.structure=e,this.selection=t,this.center=new Zt,this.boundingBox=new Ni,this._bp=this.getBondProxy(),this._ap=this.getAtomProxy(),this._rp=this.getResidueProxy(),this._cp=this.getChainProxy(),this.selection&&this.selection.signals.stringChanged.add(this.refresh,this),this.structure.signals.refreshed.add(this.refresh,this),this.refresh()}init(){}get type(){return"StructureView"}get name(){return this.structure.name}get path(){return this.structure.path}get title(){return this.structure.title}get id(){return this.structure.id}get data(){return this.structure.data}get atomSetDict(){return this.structure.atomSetDict}get biomolDict(){return this.structure.biomolDict}get entityList(){return this.structure.entityList}get unitcell(){return this.structure.unitcell}get frames(){return this.structure.frames}get boxes(){return this.structure.boxes}get validation(){return this.structure.validation}get bondStore(){return this.structure.bondStore}get backboneBondStore(){return this.structure.backboneBondStore}get rungBondStore(){return this.structure.rungBondStore}get atomStore(){return this.structure.atomStore}get residueStore(){return this.structure.residueStore}get chainStore(){return this.structure.chainStore}get modelStore(){return this.structure.modelStore}get atomMap(){return this.structure.atomMap}get residueMap(){return this.structure.residueMap}get bondHash(){return this.structure.bondHash}get spatialHash(){return this.structure.spatialHash}get _hasCoords(){return this.structure._hasCoords}set _hasCoords(e){this.structure._hasCoords=e}refresh(){e.Debug&&il.time("StructureView.refresh"),this.atomSetCache={};const t=this.structure;if(this.selection.isAllSelection()&&t!==this&&t.atomSet&&t.bondSet){this.atomSet=t.atomSet.clone(),this.bondSet=t.bondSet.clone();for(let e in this.atomSetDict){const t=this.atomSetDict[e];this.atomSetCache["__"+e]=t.clone()}this.atomCount=t.atomCount,this.bondCount=t.bondCount,this.boundingBox.copy(t.boundingBox),this.center.copy(t.center)}else if(this.selection.isNoneSelection()&&t!==this&&t.atomSet&&t.bondSet){this.atomSet=new Yu(t.atomCount),this.bondSet=new Yu(t.bondCount);for(let e in this.atomSetDict)this.atomSetCache["__"+e]=new Yu(t.atomCount);this.atomCount=0,this.bondCount=0,this.boundingBox.makeEmpty(),this.center.set(0,0,0)}else{this.atomSet=this.getAtomSet(this.selection,!0),t.atomSet&&(this.atomSet=this.atomSet.intersection(t.atomSet)),this.bondSet=this.getBondSet();for(let e in this.atomSetDict){const t=this.atomSetDict[e];this.atomSetCache["__"+e]=t.makeIntersection(this.atomSet)}this.atomCount=this.atomSet.getSize(),this.bondCount=this.bondSet.getSize(),this.boundingBox=this.getBoundingBox(),this.center=this.boundingBox.getCenter(new Zt)}e.Debug&&il.timeEnd("StructureView.refresh"),this.signals.refreshed.dispatch()}setSelection(e){this.selection=e,this.refresh()}getSelection(e){const t=[];e&&e.string&&t.push(e.string);const i=this.structure.getSelection();i&&i.string&&t.push(i.string),this.selection&&this.selection.string&&t.push(this.selection.string);let n="";return t.length>0&&(n=`( ${t.join(" ) AND ( ")} )`),new $c(n)}getStructure(){return this.structure.getStructure()}eachBond(e,t){this.structure.eachBond(e,this.getSelection(t))}eachAtom(e,t){const i=this.getAtomProxy(),n=this.getAtomSet(t),r=this.atomStore.count;if(n.getSize()=this.V[n][r]?(i="S",this.score=this.S[n][r]):this.V[n][r]>=this.H[n][r]?(i="V",this.score=this.V[n][r]):(i="H",this.score=this.H[n][r]),e.Debug&&il.log("Alignment: SCORE",this.score),e.Debug&&il.log("Alignment: S, V, H",this.S[n][r],this.V[n][r],this.H[n][r]);n>0&&r>0;)"S"===i?this.S[n][r]===this.S[n-1][r-1]+t(n-1,r-1)?(this.ali1=this.seq1[n-1]+this.ali1,this.ali2=this.seq2[r-1]+this.ali2,--n,--r,i="S"):this.S[n][r]===this.V[n][r]?i="V":this.S[n][r]===this.H[n][r]?i="H":(--n,--r):"V"===i?this.V[n][r]===this.V[n-1][r]+this.gapExtensionPenalty?(this.ali1=this.seq1[n-1]+this.ali1,this.ali2="-"+this.ali2,--n,i="V"):this.V[n][r]===this.S[n-1][r]+this.gap(0)?(this.ali1=this.seq1[n-1]+this.ali1,this.ali2="-"+this.ali2,--n,i="S"):--n:"H"===i?this.H[n][r]===this.H[n][r-1]+this.gapExtensionPenalty?(this.ali1="-"+this.ali1,this.ali2=this.seq2[r-1]+this.ali2,--r,i="H"):this.H[n][r]===this.S[n][r-1]+this.gap(0)?(this.ali1="-"+this.ali1,this.ali2=this.seq2[r-1]+this.ali2,--r,i="S"):--r:il.error("Alignment: no matrix");for(;n>0;)this.ali1=this.seq1[n-1]+this.ali1,this.ali2="-"+this.ali2,--n;for(;r>0;)this.ali1="-"+this.ali1,this.ali2=this.seq2[r-1]+this.ali2,--r;e.Debug&&il.timeEnd("Alignment.trace"),e.Debug&&il.log([this.ali1,this.ali2])}}function $g(e,t,i=!1,n="",r=""){let s,o,a,c,l;if(i){let i=e,h=t;n&&r&&(i=e.getView(new $c(n)),h=t.getView(new $c(r)));const u=i.getSequence(),d=h.getSequence(),f=new Ug(u.join(""),d.join(""));let m,p;f.calc(),f.trace(),s=0,o=0,a=f.ali1.length;const g=[],v=[];for(let e=0;ee[t]))}}}(),this.spacefillRepresentation=this.addRepresentation("spacefill",{sele:"none",opacity:nl.opacity,color:nl.color,disablePicking:!0,radiusType:"data"},!0),this.distanceRepresentation=this.addRepresentation("distance",nl,!0),this.angleRepresentation=this.addRepresentation("angle",nl,!0),this.dihedralRepresentation=this.addRepresentation("dihedral",nl,!0),this.measureRepresentations=new Ag([this.spacefillRepresentation,this.distanceRepresentation,this.angleRepresentation,this.dihedralRepresentation]),this.setDefaultAssembly(this.parameters.defaultAssembly),this.structure.signals.refreshed.add((()=>{this.updateRepresentations({position:!0})}))}get defaultParameters(){return Gg}get type(){return"structure"}initSelection(e){this.selection=new $c(e),this.structureView=new Bg(this.structure,this.selection),this.selection.signals.stringChanged.add((()=>{this.structureView.setSelection(this.selection),this.rebuildRepresentations(),this.rebuildTrajectories()}))}setSelection(e){return this.parameters.sele=e,this.selection.setString(e),this}setDefaultAssembly(e){if(void 0===this.structure.biomolDict[e]&&(e=""),this.parameters.defaultAssembly!==e){const t={defaultAssembly:e};this.reprList.forEach((e=>e.setParameters(t))),this.measureRepresentations.setParameters(t),this.parameters.defaultAssembly=e,this.signals.defaultAssemblyChanged.dispatch(e)}return this}rebuildRepresentations(){this.reprList.forEach((e=>{e.build()})),this.measureRepresentations.build()}rebuildTrajectories(){this.trajList.forEach((e=>{e.trajectory.setStructure(this.structureView)}))}updateRepresentations(e){super.updateRepresentations(e),this.measureRepresentations.update(e)}updateRepresentationMatrices(){super.updateRepresentationMatrices(),this.measureRepresentations.setParameters({matrix:this.matrix})}addRepresentation(e,t={},i=!1){t.defaultAssembly=this.parameters.defaultAssembly;const n=this._addRepresentation(e,this.structureView,t,i);return i||n.signals.parametersChanged.add((()=>this.measureUpdate())),n}addTrajectory(e="",t={}){const i=function(e,t,i){let n;return n=e&&e instanceof Pg?new Lg(e,t,i):!e&&t.frames?new Rg(e,t,i):e&&"function"==typeof e?new Og(e,t,i):new kg(e,t,i),n}(e,this.structureView,t),n=new Cg(this.stage,i,t);return this.trajList.push(n),this.signals.trajectoryAdded.dispatch(n),n}removeTrajectory(e){const t=this.trajList.indexOf(e);-1!==t&&this.trajList.splice(t,1),e.dispose(),this.signals.trajectoryRemoved.dispatch(e)}dispose(){this.trajList.slice().forEach((e=>e.dispose())),this.trajList.length=0,this.structure.dispose(),this.measureRepresentations.dispose(),super.dispose()}autoView(e,t){"number"==typeof e&&(t=e,e=""),this.stage.animationControls.zoomMove(this.getCenter(e),this.getZoom(e),Ia(t,0))}getBoxUntransformed(e){let t;return t=e?this.structureView.getBoundingBox(new $c(e)):this.structureView.boundingBox,t}getCenterUntransformed(e){return e&&"string"==typeof e?this.structure.atomCenter(new $c(e)):this.structure.center}superpose(e,t,i,n){return $g(this.structureView,e.structureView,t,i,n),this.updateRepresentations({position:!0}),this}getMaxRepresentationRadius(e){let t=0;const i=this.structure.getAtomProxy(e);return this.eachRepresentation((e=>{if(e.getVisibility()){const n=e.repr;t=Math.max(n.getAtomRadius(i),t)}})),t}measurePick(e){const t=this.pickBuffer.count;if(this.lastPick===e.index&&t>=1){if(t>1){const e=this.pickBuffer.data,i=this.pickBuffer.data.sort();this.pickDict.has(i)?this.pickDict.del(i):this.pickDict.add(i,e),2===t?this.distanceRepresentation.setParameters({atomPair:this.pickDict.values.filter((e=>2===e.length))}):3===t?this.angleRepresentation.setParameters({atomTriple:this.pickDict.values.filter((e=>3===e.length))}):4===t&&this.dihedralRepresentation.setParameters({atomQuad:this.pickDict.values.filter((e=>4===e.length))})}this.pickBuffer.clear(),this.lastPick=void 0}else this.pickBuffer.has(e.index)||this.pickBuffer.push(e.index),this.lastPick=e.index;this.measureUpdate()}measureClear(){this.pickBuffer.clear(),this.lastPick=void 0,this.spacefillRepresentation.setSelection("none")}measureBuild(){const e=this.measureData();this.distanceRepresentation.setParameters({atomPair:e.distance}),this.angleRepresentation.setParameters({atomTriple:e.angle}),this.dihedralRepresentation.setParameters({atomQuad:e.dihedral})}measureUpdate(){const e=this.pickBuffer.data,t={};e.forEach((e=>{const i=Math.max(.1,this.getMaxRepresentationRadius(e));t[e]=i*(2.3-rc(.1,2,i))})),this.spacefillRepresentation.setSelection(e.length?"@"+e.join(","):"none"),e.length&&this.spacefillRepresentation.setParameters({radiusData:t})}measureData(){const e=this.pickDict.values;return{distance:e.filter((e=>2===e.length)),angle:e.filter((e=>3===e.length)),dihedral:e.filter((e=>4===e.length))}}removeAllMeasurements(e){const t=this.pickDict,i=t.values,n=function(e){i.filter((t=>t.length===e)).forEach((e=>t.del(e.slice().sort())))};(!e||1&e)&&n(2),(!e||2&e)&&n(3),(!e||4&e)&&n(4),this.measureBuild()}removeMeasurement(e){this.pickDict.del(e.slice().sort()),this.measureBuild()}addMeasurement(e){if(e.length<2||e.length>4)return;const t=e.slice().sort();this.pickDict.has(t)||this.pickDict.add(t,e),this.measureBuild()}}fl.add("structure",Vg),fl.add("structureview",Vg);class Hg extends wg{constructor(e,t,i={}){super(e,t,Object.assign({name:t.name},i)),this.surface=t}get type(){return"surface"}addRepresentation(e,t={}){return this._addRepresentation(e,this.surface,t)}getBoxUntransformed(){return this.surface.boundingBox}getCenterUntransformed(){return this.surface.center}dispose(){this.surface.dispose(),super.dispose()}}fl.add("surface",Hg);class jg extends wg{constructor(e,t,i={}){super(e,t,Object.assign({name:t.name},i)),this.volume=t}get type(){return"volume"}addRepresentation(e,t={}){return this._addRepresentation(e,this.volume,t)}getBoxUntransformed(){return this.volume.boundingBox}getCenterUntransformed(){return this.volume.center}dispose(){this.volume.dispose(),super.dispose()}}fl.add("volume",jg);class Wg extends Sg{addRepresentation(e,t){return this.forEach((i=>i.addRepresentation(e,t)))}autoView(e){return this.forEach((t=>t.autoView(e)))}}function qg(e,t){return e instanceof RegExp?null!==t.name.match(e):t.name===e}const Xg=new Zt,Yg={impostor:!0,quality:"medium",workerDefault:!0,sampleLevel:0,backgroundColor:"black",rotateSpeed:2,zoomSpeed:1.2,panSpeed:1,clipNear:0,clipFar:100,clipDist:10,clipMode:"scene",clipScale:"relative",fogNear:50,fogFar:100,cameraFov:40,cameraEyeSep:.3,cameraType:"perspective",lightColor:14540253,lightIntensity:1,ambientColor:14540253,ambientIntensity:.2,hoverTimeout:0,tooltip:!0,mousePreset:"default"};class Zg extends wg{constructor(e,t,i={}){super(e,t,Object.assign({name:t.name},i)),this.shape=t}get type(){return"shape"}addRepresentation(e,t={}){return this._addRepresentation(e,this.shape,t)}getBoxUntransformed(){return this.shape.boundingBox}getCenterUntransformed(){return this.shape.center}dispose(){this.shape.dispose(),super.dispose()}}function Kg(e,t,i,n){var r,s=arguments.length,o=s<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,n);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(o=(s<3?r(o):s>3?r(t,i,o):r(t,i))||o);return s>3&&o&&Object.defineProperty(t,i,o),o}fl.add("shape",Zg);class Qg extends dc{constructor(e){super(e),e.scale||(this.parameters.scale="rainbow",this.parameters.reverse=Ia(e.reverse,!0)),this.scalePerModel={},e.structure.eachModel((e=>{this.parameters.domain=[e.atomOffset,e.atomEnd],this.scalePerModel[e.index]=this.getScale()}))}atomColor(e){return this.scalePerModel[e.modelIndex](e.index)}}Kg([uc],Qg.prototype,"atomColor",null),al.add("atomindex",Qg);class Jg extends dc{constructor(e){if(super(e),e.scale||(this.parameters.scale="OrRd"),!e.domain){let t,i=1/0,n=-1/0;e.sele&&(t=new $c(e.sele)),e.structure.eachAtom((function(e){const t=e.bfactor;i=Math.min(i,t),n=Math.max(n,t)}),t),this.parameters.domain=[i,n]}this.bfactorScale=this.getScale()}atomColor(e){return this.bfactorScale(e.bfactor)}}Kg([uc],Jg.prototype,"atomColor",null),al.add("bfactor",Jg);class ev extends dc{constructor(e){super(e),this.chainidDictPerModel={},this.scalePerModel={},e.scale||(this.parameters.scale="Spectral"),e.structure.eachModel((e=>{let t=0;const i={};e.eachChain((function(e){void 0===i[e.chainid]&&(i[e.chainid]=t,t+=1)})),this.parameters.domain=[0,t-1],this.chainidDictPerModel[e.index]=i,this.scalePerModel[e.index]=this.getScale()}))}atomColor(e){const t=this.chainidDictPerModel[e.modelIndex];return this.scalePerModel[e.modelIndex](t[e.chainid])}}Kg([uc],ev.prototype,"atomColor",null),al.add("chainid",ev);class tv extends dc{constructor(e){super(e),this.scalePerModel={},e.scale||(this.parameters.scale="Spectral"),e.structure.eachModel((e=>{this.parameters.domain=[e.chainOffset,e.chainEnd],this.scalePerModel[e.index]=this.getScale()}))}atomColor(e){return this.scalePerModel[e.modelIndex](e.chainIndex)}}Kg([uc],tv.prototype,"atomColor",null),al.add("chainindex",tv);class iv extends dc{constructor(e){super(e),this.chainnameDictPerModel={},this.scalePerModel={},e.scale||(this.parameters.scale="Spectral"),e.structure.eachModel((e=>{let t=0;const i={};e.eachChain((function(e){void 0===i[e.chainname]&&(i[e.chainname]=t,t+=1)})),this.parameters.domain=[0,t-1],this.chainnameDictPerModel[e.index]=i,this.scalePerModel[e.index]=this.getScale()}))}atomColor(e){const t=this.chainnameDictPerModel[e.modelIndex];return this.scalePerModel[e.modelIndex](t[e.chainname])}}Kg([uc],iv.prototype,"atomColor",null),al.add("chainname",iv);class nv extends dc{constructor(e){super(e),this.rsrzDict={},this.rsccDict={},e.scale||(this.parameters.scale="RdYlBu"),this.rsrzScale=this.getScale({domain:[2,0]}),this.rsccScale=this.getScale({domain:[.678,1]});const t=e.structure.validation;t&&(this.rsrzDict=t.rsrzDict,this.rsccDict=t.rsccDict)}atomColor(e){let t=e.resno+"";e.inscode&&(t+="^"+e.inscode),e.chainname&&(t+=":"+e.chainname),t+="/"+e.modelIndex;const i=this.rsrzDict[t];if(void 0!==i)return this.rsrzScale(i);const n=this.rsccDict[t];return void 0!==n?this.rsccScale(n):9474192}}Kg([uc],nv.prototype,"atomColor",null),al.add("densityfit",nv);const rv={ARG:{CD:.1,CZ:.5,NE:-.1},ASN:{CG:.55,OD1:-.55},ASP:{CB:-.16,CG:.36,OD1:-.6,OD2:-.6},CYS:{CB:.19,SG:-.19},GLN:{CD:.55,OE1:-.55},GLU:{CD:.36,CG:-.16,OE1:-.6,OE2:-.6},HIS:{CB:.1,CD2:.2,CE1:.45,CG:.15,ND1:.05,NE2:.05},LYS:{CE:.25,NZ:.75},MET:{CE:.06,CG:.06,SD:-.12},PTR:{C:.55,CA:.1,CZ:.25,N:-.35,O:-.55,O1P:-.85,O2P:-.85,O3P:-.85,OG1:-1.1,P:1.4},SEP:{C:.55,CA:.1,CB:.25,N:-.35,O:-.55,O1P:-.85,O2P:-.85,O3P:-.85,OG1:-1.1,P:1.4},SER:{CB:.25,OG:-.25},THR:{CB:.25,OG1:-.25},TPO:{C:.55,CA:.1,CB:.25,N:-.35,O:-.55,OG1:-1.1,O1P:-.85,O2P:-.85,O3P:-.85,P:1.4},TRP:{CD1:.06,CD2:.1,CE2:-.04,CE3:-.03,CG:-.03,NE1:-.06},TYR:{CZ:.25,OH:-.25},backbone:{C:.55,O:-.55,N:-.35,CA:.1}};class sv extends dc{constructor(e){super(e),this.delta=new Zt,this.hCharges=[],e.scale||(this.parameters.scale="rwb"),e.domain||(this.parameters.domain=[-50,50]),this.scale=this.getScale(),this.charges=new Float32Array(e.structure.atomCount);const t=[];e.structure.eachAtom((e=>{var i;if(this.charges[e.index]=(null!==(i=e).partialCharge?i.partialCharge:i.isProtein()&&(rv[i.resname]&&rv[i.resname][i.atomname]||rv.backbone[i.atomname])||0)*e.occupancy,"N"===e.atomname){if(e.bondCount>=3)return;if(e.bondToElementCount(1))return;const i=function(e,t=new Zt){let i=!1,n=!1,r=!1;return t.set(2*e.x,2*e.y,2*e.z),e.eachBondedAtom((function(e){if(!i)return"H"===e.atomname?(t.set(e.x,e.y,e.z),void(i=!0)):void(n||"CA"!==e.atomname?r||"C"!==e.atomname||(r=!0,t.sub(e)):(t.sub(e),n=!0))})),i?t:n&&r?(t.normalize(),t.multiplyScalar(1.04),t.add(e),t):void 0}(e);void 0!==i&&(t.push(i),this.hCharges.push(.25*e.occupancy))}}));const i=e.structure.getBoundingBox();i.expandByScalar(1.04),this.hStore=function(e){const t=e.length,i=new Float32Array(t),n=new Float32Array(t),r=new Float32Array(t);for(let t=0;t{const r=t[e];0!==r&&(n+=r/i)})),this.hHash.eachWithin(e.x,e.y,e.z,12,((e,t)=>{const r=i[e];0!==r&&(n+=r/t)})),this.scale(332*n)}}Kg([uc],sv.prototype,"positionColor",null),al.add("electrostatic",sv);const ov={H:16777215,HE:14286847,LI:13402367,BE:12779264,B:16758197,C:9474192,N:3166456,O:16715021,F:9494608,NE:11789301,NA:11230450,MG:9109248,AL:12560038,SI:1578e4,P:16744448,S:16777008,CL:2093087,AR:8442339,K:9388244,CA:4062976,SC:15132390,TI:12567239,V:10921643,CR:9083335,MN:10255047,FE:14706227,CO:15765664,NI:5296208,CU:13140019,ZN:8224944,GA:12750735,GE:6721423,AS:12419299,SE:16752896,BR:10889513,KR:6076625,RB:7351984,SR:65280,Y:9764863,ZR:9756896,NB:7586505,MO:5551541,TC:3907230,RU:2396047,RH:687500,PD:27013,AG:12632256,CD:16767375,IN:10909043,SN:6717568,SB:10380213,TE:13924864,I:9699476,XE:9699476,CS:5707663,BA:51456,LA:7394559,CE:16777159,PR:14286791,ND:13107143,PM:10747847,SM:9437127,EU:6422471,GD:4587463,TB:3211207,DY:2097095,HO:65436,ER:58997,TM:54354,YB:48952,LU:43812,HF:5096191,TA:5089023,W:2200790,RE:2522539,OS:2516630,IR:1528967,PT:13684960,AU:16765219,HG:12105936,TL:10900557,PB:5724513,BI:10375093,PO:11230208,AT:7688005,RN:4358806,FR:4325478,RA:32e3,AC:7384058,TH:47871,PA:41471,U:36863,NP:33023,PU:27647,AM:5528818,CM:7888099,BK:9064419,CF:10565332,ES:11739092,FM:11739066,MD:11734438,NO:12389767,LR:13041766,RF:13369433,DB:13697103,SG:14221381,BH:14680120,HS:15073326,MT:15400998,DS:16777215,RG:16777215,CN:16777215,UUT:16777215,FL:16777215,UUP:16777215,LV:16777215,UUH:16777215,D:16777152,T:16777120};class av extends dc{constructor(e){e.value=Ia(e.value,ov.C),super(e)}atomColor(e){const t=e.element;return"C"===t?this.parameters.value:ov[t]||16777215}}Kg([uc],av.prototype,"atomColor",null),al.add("element",av);class cv extends dc{constructor(e){super(e),e.scale||(this.parameters.scale="Spectral"),e.domain||(this.parameters.domain=[0,e.structure.entityList.length-1]),this.entityindexScale=this.getScale()}atomColor(e){return this.entityindexScale(e.entityIndex)}}Kg([uc],cv.prototype,"atomColor",null),al.add("entityindex",cv);class lv extends dc{atomColor(e){const t=e.entity;switch(t?t.entityType:void 0){case 1:return 8374655;case 2:return 16629894;case 3:return 12496596;case 4:return 3697840;default:return 16777113}}}Kg([uc],lv.prototype,"atomColor",null),al.add("entitytype",lv);class hv extends dc{constructor(e){super(e),this.geoAtomDict={},this.geoDict={};const t=e.structure.validation;t&&(this.geoAtomDict=t.geoAtomDict,this.geoDict=t.geoDict)}atomColor(e){let t,i=e.resno+"";e.inscode&&(i+="^"+e.inscode),e.chainname&&(i+=":"+e.chainname),i+="/"+e.modelIndex;const n=this.geoAtomDict[i];if(void 0!==n){const i=n[e.atomname]||0;r=i,t=16843009*((r=(858993459&(r-=r>>1&1431655765))+(r>>2&858993459))+(r>>4)&252645135)>>24}else t=this.geoDict[i]||0;var r;return 0===t?2188972:1===t?16703627:2===t?16018755:t>=3?10813478:9474192}}Kg([uc],hv.prototype,"atomColor",null),al.add("geoquality",hv);class uv extends dc{constructor(e){super(e),this.resHF={},e.scale||(this.parameters.scale="RdYlGn");for(const e in md)this.resHF[e]=md[e][0];if(this.defaultResidueHydrophobicity=pd[0],!e.domain){let e=1/0,t=-1/0;for(const i in this.resHF){const n=this.resHF[i];e=Math.min(e,n),t=Math.max(t,n)}this.parameters.domain=[e,0,t]}this.hfScale=this.getScale()}atomColor(e){return this.hfScale(this.resHF[e.resname]||this.defaultResidueHydrophobicity)}}Kg([uc],uv.prototype,"atomColor",null),al.add("hydrophobicity",uv);class dv extends dc{constructor(e){super(e),e.scale||(this.parameters.scale="rainbow"),e.domain||(this.parameters.domain=[0,e.structure.modelStore.count]),this.modelindexScale=this.getScale()}atomColor(e){return this.modelindexScale(e.modelIndex)}}Kg([uc],dv.prototype,"atomColor",null),al.add("modelindex",dv);class fv extends dc{atomColor(e){switch(e.residueType.moleculeType){case 1:return 3697840;case 2:return 15729279;case 3:return 12496596;case 4:return 16629894;case 5:return 12540695;case 6:return 8374655;default:return 16777113}}}Kg([uc],fv.prototype,"atomColor",null),al.add("moleculetype",fv);class mv extends dc{constructor(e){super(e),e.scale||(this.parameters.scale="PuBu"),e.domain||(this.parameters.domain=[0,1]),this.occupancyScale=this.getScale()}atomColor(e){return this.occupancyScale(e.occupancy)}}Kg([uc],mv.prototype,"atomColor",null),al.add("occupancy",mv);class pv extends dc{constructor(e){super(e),e.scale||(this.parameters.scale="rwb"),e.domain||(this.parameters.domain=[-1,1]),this.partialchargeScale=this.getScale()}atomColor(e){return this.partialchargeScale(e.partialCharge||0)}}function gv(){return 16777215*Math.random()}Kg([uc],pv.prototype,"atomColor",null),al.add("partialcharge",pv);class vv extends dc{atomColor(){return gv()}volumeColor(){return gv()}positionColor(){return gv()}}Kg([uc],vv.prototype,"atomColor",null),Kg([uc],vv.prototype,"volumeColor",null),Kg([uc],vv.prototype,"positionColor",null),al.add("random",vv);class yv extends dc{constructor(e){super(e),this.rciDict={},e.scale||(this.parameters.scale="RdYlBu"),this.rciScale=this.getScale({domain:[.6,0]});const t=e.structure.validation;t&&(this.rciDict=t.rciDict)}atomColor(e){let t=`[${e.resname}]${e.resno}`;e.chainname&&(t+=":"+e.chainname);const i=this.rciDict[t];return void 0!==i?this.rciScale(i):9474192}}Kg([uc],yv.prototype,"atomColor",null),al.add("randomcoilindex",yv);class xv extends dc{constructor(e){super(e),this.scalePerChain={},e.scale||(this.parameters.scale="rainbow",this.parameters.reverse=Ia(e.reverse,!0)),e.structure.eachChain((e=>{this.parameters.domain=[e.residueOffset,e.residueEnd],this.scalePerChain[e.index]=this.getScale()}))}atomColor(e){return this.scalePerChain[e.chainIndex](e.residueIndex)}}Kg([uc],xv.prototype,"atomColor",null),al.add("residueindex",xv);const bv={ALA:9240460,ARG:124,ASN:16743536,ASP:10485826,CYS:16777072,GLN:16731212,GLU:6684672,GLY:16777215,HIS:7368959,ILE:19456,LEU:4546117,LYS:4671416,MET:12099650,PHE:5459026,PRO:5395026,SER:16740418,THR:12078080,TRP:5195264,TYR:9203788,VAL:16747775,ASX:16711935,GLX:16711935,ASH:16711935,GLH:16711935,A:14423100,G:3329330,I:10145074,X:8190976,C:16766720,T:4286945,U:4251856,D:35723,DA:14423100,DG:3329330,DI:10145074,DX:8190976,DC:16766720,DT:4286945,DU:4251856,DD:35723};class _v extends dc{atomColor(e){return bv[e.resname]||16711935}}Kg([uc],_v.prototype,"atomColor",null),al.add("resname",_v);const wv=16711808,Sv=10485888,Av=6291584,Mv=16762880,Cv=6324479,Pv=16777215,Tv=11403518,Iv=16580962,Ev=10921722;class Dv extends dc{constructor(e){super(e),this.residueProxy=e.structure.getResidueProxy()}atomColor(e){const t=e.sstruc,i=this.residueProxy;return"h"===t?wv:"g"===t?Sv:"i"===t?Av:"e"===t||"b"===t?Mv:"t"===t?Cv:(i.index=e.residueIndex,i.isDna()?Tv:i.isRna()?Iv:i.isSaccharide()?Ev:i.isProtein()||"s"===t||"l"===t?Pv:8421504)}}Kg([uc],Dv.prototype,"atomColor",null),al.add("sstruc",Dv);class Lv extends dc{constructor(e){var t,i;super(e),e.scale||(this.parameters.scale="rwb"),this.atomData=null===(t=this.parameters.data)||void 0===t?void 0:t.atomData,this.bondData=null===(i=this.parameters.data)||void 0===i?void 0:i.bondData,this.scale=this.getScale(this.parameters)}atomColor(e){var t;const i=null===(t=this.atomData)||void 0===t?void 0:t[e.index];return void 0!==i?this.scale(i):this.parameters.value}bondColor(e,t){var i;const n=null===(i=this.bondData)||void 0===i?void 0:i[e.index];return void 0!==n?this.scale(n):this.atomProxy?(this.atomProxy.index=t?e.atomIndex1:e.atomIndex2,this.atomColor(this.atomProxy)):this.parameters.value}}Kg([uc],Lv.prototype,"atomColor",null),Kg([uc],Lv.prototype,"bondColor",null),al.add("structuredata",Lv);class Rv extends dc{atomColor(){return this.parameters.value}bondColor(){return this.parameters.value}valueColor(){return this.parameters.value}volumeColor(){return this.parameters.value}}Kg([uc],Rv.prototype,"atomColor",null),Kg([uc],Rv.prototype,"bondColor",null),Kg([uc],Rv.prototype,"valueColor",null),Kg([uc],Rv.prototype,"volumeColor",null),al.add("uniform",Rv);class kv extends dc{constructor(e){super(e),this.valueScale=this.getScale()}volumeColor(e){return this.valueScale(this.parameters.volume.data[e])}}Kg([uc],kv.prototype,"volumeColor",null),al.add("value",kv);class Ov extends dc{constructor(e){super(e),this.vec=new Zt,this.valueScale=this.getScale()}positionColor(e){const t=this.parameters.volume;if(!t||!t.inverseMatrix)return this.parameters.value;const i=this.vec,n=t.data,r=t.nx,s=t.ny,o=r*s;i.copy(e),i.applyMatrix4(t.inverseMatrix);const a=Math.floor(i.x),c=Math.floor(i.y),l=Math.floor(i.z),h=(l*s+c)*r+a,u=h+1,d=h+r,f=h+o,m=d+1,p=f+1,g=d+o,v=g+1,y=n[h],x=n[u],b=n[d],_=n[f],w=n[m],S=n[p],A=n[g],M=n[v],C=i.x-a,P=i.y-c,T=i.z-l,I=ic(y,x,C),E=ic(_,S,C),D=ic(b,w,C),L=ic(A,M,C),R=ic(I,D,P),k=ic(E,L,P),O=ic(R,k,T);return this.valueScale(O)}}Kg([uc],Ov.prototype,"positionColor",null),al.add("volume",Ov);class Bv extends tu{constructor(e,t,i){const n=i||{};if(super(e,t,n),this.type="structure",this.parameters=Object.assign({radiusType:{type:"select",options:Tm.types},radiusData:{type:"hidden"},radiusSize:{type:"number",precision:3,max:10,min:.001},radiusScale:{type:"number",precision:3,max:10,min:.001},assembly:null,defaultAssembly:{type:"hidden"}},this.parameters),this.selection=new $c(n.sele),this.dataList=[],this.structure=e,this.structureView=this.structure.getView(this.selection),e.biomolDict){const t={default:"default","":e.unitcell?"AU":"FULL"};Object.keys(e.biomolDict).forEach((function(e){t[e]=e})),this.parameters.assembly={type:"select",options:t,rebuild:!0}}else this.parameters.assembly=null}get defaultScale(){return{vdw:1,covalent:1,bfactor:.01,sstruc:1}}init(e){const t=e||{};t.colorScheme=Ia(t.colorScheme,"element"),this.setRadius(t.radius,t),this.radiusType=Ia(t.radiusType,"vdw"),this.radiusData=Ia(t.radiusData,{}),this.radiusSize=Ia(t.radiusSize,1),this.radiusScale=Ia(t.radiusScale,1),this.assembly=Ia(t.assembly,"default"),this.defaultAssembly=Ia(t.defaultAssembly,""),"auto"===t.quality&&(t.quality=this.getQuality()),super.init(t),this.selection.signals.stringChanged.add((()=>{this.build()})),this.build()}setRadius(e,t){const i=Object.keys(Pm);return"string"==typeof e&&i.includes(e.toLowerCase())?t.radiusType=e:void 0!==e&&(t.radiusType="size",t.radiusSize=e),this}getAssembly(){const e="default"===this.assembly?this.defaultAssembly:this.assembly;return this.structure.biomolDict[e]}getQuality(){let e;const t=this.structureView,i=this.getAssembly();e=i?i.getAtomCount(t):t.atomCount,Kc&&(e*=4);return t.atomStore.count/t.residueStore.count<2&&(e*=10),e<15e3?"high":e<8e4?"medium":"low"}create(){if(0===this.structureView.atomCount)return;if(!this.structureView.hasCoords())return void(this.needsBuild=!0);this.needsBuild=!1;const e=this.getAssembly();if(e)e.partList.forEach(((e,t)=>{const i=e.getView(this.structureView);if(0===i.atomCount)return;const n=this.createData(i,t);n&&(n.sview=i,n.instanceList=e.getInstanceList(),this.dataList.push(n))}));else{const e=this.createData(this.structureView,0);e&&(e.sview=this.structureView,this.dataList.push(e))}}update(e){!this.lazy||this.visible?this.needsBuild?this.build():this.dataList.forEach((t=>{t.bufferList.length>0&&this.updateData(e,t)}),this):Object.assign(this.lazyProps.what,e)}updateData(e,t){this.build()}getColorParams(){return Object.assign(Object.assign({},super.getColorParams()),{structure:this.structure})}getRadiusParams(e){return{type:this.radiusType,scale:this.radiusScale,size:this.radiusSize,data:this.radiusData}}getAtomParams(e,t){return Object.assign({what:e,colorParams:this.getColorParams(),radiusParams:this.getRadiusParams()},t)}getBondParams(e,t){return Object.assign({what:e,colorParams:this.getColorParams(),radiusParams:this.getRadiusParams()},t)}getAtomRadius(e){if(this.structureView.atomSet.isSet(e.index)){return new Tm(this.getRadiusParams()).atomRadius(e)}return 0}setSelection(e,t){return this.selection.setString(e,t),this}setParameters(e,t={},i=!1){const n=e||{};return this.setRadius(n.radius,n),void 0===n.radiusType&&void 0===n.radiusData&&void 0===n.radiusSize&&void 0===n.radiusScale||(t.radius=!0,el&&!this.disableImpostor||(i=!0)),void 0!==n.defaultAssembly&&n.defaultAssembly!==this.defaultAssembly&&("default"===this.assembly&&void 0===n.assembly||"default"===n.assembly)&&(i=!0),super.setParameters(n,t,i),this}getParameters(){return Object.assign(super.getParameters(),{sele:this.selection?this.selection.string:void 0,defaultAssembly:this.defaultAssembly})}attach(e){const t=this.viewer,i=this.bufferList;this.dataList.forEach((function(e){e.bufferList.forEach((function(n){i.push(n),t.add(n,e.instanceList)}))})),this.setVisibility(this.visible),e()}clear(){this.dataList.length=0,super.clear()}dispose(){this.structureView.dispose(),super.dispose()}}class Nv extends Bv{constructor(e,t,i){super(e,t,i),this.n=0,this.parameters=Object.assign({labelVisible:{type:"boolean"},labelSize:{type:"number",precision:3,max:10,min:.001},labelColor:{type:"color"},labelFontFamily:{type:"select",options:{"sans-serif":"sans-serif",monospace:"monospace",serif:"serif"},buffer:"fontFamily"},labelFontStyle:{type:"select",options:{normal:"normal",italic:"italic"},buffer:"fontStyle"},labelFontWeight:{type:"select",options:{normal:"normal",bold:"bold"},buffer:"fontWeight"},labelsdf:{type:"boolean",buffer:"sdf"},labelXOffset:{type:"number",precision:1,max:20,min:-20,buffer:"xOffset"},labelYOffset:{type:"number",precision:1,max:20,min:-20,buffer:"yOffset"},labelZOffset:{type:"number",precision:1,max:20,min:-20,buffer:"zOffset"},labelAttachment:{type:"select",options:{"bottom-left":"bottom-left","bottom-center":"bottom-center","bottom-right":"bottom-right","middle-left":"middle-left","middle-center":"middle-center","middle-right":"middle-right","top-left":"top-left","top-center":"top-center","top-right":"top-right"},rebuild:!0},labelBorder:{type:"boolean",buffer:"showBorder"},labelBorderColor:{type:"color",buffer:"borderColor"},labelBorderWidth:{type:"number",precision:2,max:.3,min:0,buffer:"borderWidth"},labelBackground:{type:"boolean",rebuild:!0},labelBackgroundColor:{type:"color",buffer:"backgroundColor"},labelBackgroundMargin:{type:"number",precision:2,max:2,min:0,rebuild:!0},labelBackgroundOpacity:{type:"range",step:.01,max:1,min:0,buffer:"backgroundOpacity"},labelFixedSize:{type:"boolean",buffer:"fixedSize"},lineOpacity:{type:"range",min:0,max:1,step:.01},linewidth:{type:"integer",max:50,min:1,buffer:!0}},this.parameters,{flatShaded:null})}init(e){const t=e||{};this.labelVisible=Ia(t.labelVisible,!0),this.labelSize=Ia(t.labelSize,2),this.labelColor=Ia(t.labelColor,16777215),this.labelFontFamily=Ia(t.labelFontFamily,"sans-serif"),this.labelFontStyle=Ia(t.labelFontstyle,"normal"),this.labelFontWeight=Ia(t.labelFontWeight,"bold"),this.labelsdf=Ia(t.labelsdf,"Chrome"===Yc),this.labelXOffset=Ia(t.labelXOffset,0),this.labelYOffset=Ia(t.labelYOffset,0),this.labelZOffset=Ia(t.labelZOffset,.5),this.labelAttachment=Ia(t.labelAttachment,"bottom-left"),this.labelBorder=Ia(t.labelBorder,!1),this.labelBorderColor=Ia(t.labelBorderColor,"lightgrey"),this.labelBorderWidth=Ia(t.labelBorderWidth,.15),this.labelBackground=Ia(t.labelBackground,!1),this.labelBackgroundColor=Ia(t.labelBackgroundColor,"lightgrey"),this.labelBackgroundMargin=Ia(t.labelBackgroundMargin,.5),this.labelBackgroundOpacity=Ia(t.labelBackgroundOpacity,1),this.labelFixedSize=Ia(t.labelFixedSize,!1),this.lineOpacity=Ia(t.lineOpacity,1),this.linewidth=Ia(t.linewidth,2),super.init(t)}update(e){e.position?this.build():super.update(e)}updateData(e,t){const i={};if(e&&!e.labelSize||Object.assign(i,{size:Gl(this.n,this.labelSize)}),!e||e.labelColor){const e=new mn(this.labelColor);Object.assign(i,{color:Vl(this.n,e.r,e.g,e.b)})}this.textBuffer.setAttributes(i)}setParameters(e,t={},i=!1){return e&&e.labelSize&&(t.labelSize=!0),e&&(e.labelColor||0===e.labelColor)&&(t.labelColor=!0,i=!0),super.setParameters(e,t,i),e&&void 0!==e.opacity&&this.textBuffer.setParameters({opacity:1}),e&&void 0!==e.labelVisible&&this.setVisibility(this.visible),this}setVisibility(e,t){return super.setVisibility(e,!0),this.textBuffer&&this.textBuffer.setVisibility(this.labelVisible&&this.visible),t||this.viewer.requestRender(),this}getLabelBufferParams(e={}){return super.getBufferParams(Object.assign({fontFamily:this.labelFontFamily,fontStyle:this.labelFontStyle,fontWeight:this.labelFontWeight,sdf:this.labelsdf,xOffset:this.labelXOffset,yOffset:this.labelYOffset,zOffset:this.labelZOffset,attachment:this.labelAttachment,showBorder:this.labelBorder,borderColor:this.labelBorderColor,borderWidth:this.labelBorderWidth,showBackground:this.labelBackground,backgroundColor:this.labelBackgroundColor,backgroundMargin:this.labelBackgroundMargin,backgroundOpacity:this.labelBackgroundOpacity,fixedSize:this.labelFixedSize,disablePicking:!0,visible:this.labelVisible},e,{opacity:1}))}getAtomRadius(){return 0}}function Fv(e,t){const i=e.getAtomProxy(),n=new $c,r=t.length;if(0===r)return new Float32Array(0);const s=t[0].length,o=e.getAtomSet(),a=new Float32Array(r*s*3);let c=0;return t.forEach((function(t){let r=!1;for(let l=0;l 1.0 ){\ngl_FragColor = vec4( backgroundColor, backgroundOpacity );\n}else{\nfloat sdf = texture2D( fontTexture, texCoord ).a;\nif( showBorder ) sdf += borderWidth;\nfloat a = smoothstep(padding - gamma, padding + gamma, sdf);\nif( a < 0.2 ) discard;\na *= opacity;\nvec3 outgoingLight = vColor;\nif( showBorder && sdf < ( padding + borderWidth ) ){\noutgoingLight = borderColor;\n}\ngl_FragColor = vec4( outgoingLight, a );\n}\n#if defined( PICKING )\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");const Gv={};const Vv={font:"sans-serif",size:36,style:"normal",variant:"normal",weight:"normal",outline:3,width:1024,height:1024};class Hv{constructor(e={}){this.gamma=1,this.mapped={},this.scratchW=0,this.scratchH=0,this.currentX=0,this.currentY=0,this.cutoff=.25,this.parameters=Ea(e,Vv);const t=this.parameters;this.radius=t.size/8,this.padding=t.size/3;const i=this.lineHeight=t.size+2*t.outline+Math.round(t.size/4),n=this.maxWidth=t.width/4,r=this.canvas=document.createElement("canvas");r.width=n,r.height=i;const s=this.context=this.canvas.getContext("2d");s.font=`${t.style} ${t.variant} ${t.weight} ${t.size}px ${t.font}`,s.fillStyle="black",s.textAlign="left",s.textBaseline="bottom",s.lineJoin="round",this.gridOuter=new Float64Array(i*n),this.gridInner=new Float64Array(i*n),this.f=new Float64Array(Math.max(i,n)),this.d=new Float64Array(Math.max(i,n)),this.z=new Float64Array(Math.max(i,n)+1),this.v=new Int16Array(Math.max(i,n)),this.data=new Uint8Array(t.width*t.height*4),this.canvas2=document.createElement("canvas"),this.canvas2.width=t.width,this.canvas2.height=t.height,this.context2=this.canvas2.getContext("2d"),this.placeholder=this.map(String.fromCharCode(65533));for(let e=32;e<=126;++e)this.map(String.fromCharCode(e));this.map(String.fromCharCode(176)),this.map(String.fromCharCode(8491)),this.texture=new na(this.canvas2),this.texture.flipY=!1,this.texture.needsUpdate=!0}map(e){const t=this.parameters;return void 0===this.mapped[e]&&(this.draw(e),this.currentX+this.scratchW>t.width&&(this.currentX=0,this.currentY+=this.scratchH),this.currentY+this.scratchH>t.height&&console.warn("canvas to small"),this.mapped[e]={x:this.currentX,y:this.currentY,w:this.scratchW,h:this.scratchH},this.context2.drawImage(this.canvas,0,0,this.scratchW,this.scratchH,this.currentX,this.currentY,this.scratchW,this.scratchH),this.currentX+=this.scratchW),this.mapped[e]}get(e){return this.mapped[e]||this.placeholder}draw(e){const t=this.parameters,i=this.lineHeight,n=t.outline,r=this.context,s=this.maxWidth,o=n,a=i-t.outline,c=r.measureText(e),l=Math.min(s,Math.ceil(c.width+2*o+1)),h=l*i;r.clearRect(0,0,l,i),r.fillText(e,o,a);const u=r.getImageData(0,0,l,i),d=u.data;for(let e=0;e= 0.0 ) {\ntrimSegment( start, end );\n} else if ( end.z < 0.0 && start.z >= 0.0 ) {\ntrimSegment( end, start );\n}\n}\nvec4 clipStart = projectionMatrix * start;\nvec4 clipEnd = projectionMatrix * end;\nvec2 ndcStart = clipStart.xy / clipStart.w;\nvec2 ndcEnd = clipEnd.xy / clipEnd.w;\nvec2 dir = ndcEnd - ndcStart;\ndir.x *= aspect;\ndir = normalize( dir );\nvec2 offset = vec2( dir.y, - dir.x );\ndir.x /= aspect;\noffset.x /= aspect;\nif ( mapping.x < 0.0 ) offset *= - 1.0;\noffset *= linewidth;\noffset /= resolution.y;\nvec4 clip = ( mapping.y < 0.5 ) ? clipStart : clipEnd;\noffset *= clip.w;\nclip.xy += offset;\ngl_Position = clip;\n#ifndef PICKING\nvViewPosition = ( projectionMatrixInverse * clip ).xyz;\n#endif\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n#include nearclip_vertex\n}"),ul.add("shader/WideLine.frag","uniform vec3 diffuse;\nuniform float opacity;\nuniform float clipNear;\nuniform float clipRadius;\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#ifdef PICKING\nuniform float objectId;\nvarying vec3 vPickingColor;\n#else\n#include common\n#include fog_pars_fragment\nvarying vec3 vViewPosition;\nvarying vec3 vColor;\nvarying vec3 vColor2;\nvarying float flag;\n#endif\nvoid main() {\n#include nearclip_fragment\n#include radiusclip_fragment\n#if defined( PICKING )\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 outgoingLight = vec3( 0.0 );\nvec4 diffuseColor = vec4( diffuse, 1.0 );\nif ( flag < 0.0 ) {\ndiffuseColor.rgb *= vColor;\n} else {\ndiffuseColor.rgb *= vColor2;\n}\n#include alphatest_fragment\noutgoingLight = diffuseColor.rgb;\ngl_FragColor = vec4( outgoingLight, diffuseColor.a * opacity );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");const Yv=Object.assign({linewidth:2},em),Zv=Object.assign({linewidth:{uniform:!0}},tm);class Kv extends Jp{constructor(e,t={}){super(e,t),this.parameterTypes=Zv,this.vertexShader="WideLine.vert",this.fragmentShader="WideLine.frag",!e.color2&&e.color&&(e.color2=e.color),this.addUniforms({linewidth:{value:this.parameters.linewidth},resolution:{value:new zt},projectionMatrixInverse:{value:new ri}}),this.addAttributes({position1:{type:"v3",value:null},position2:{type:"v3",value:null},color2:{type:"c",value:null}}),this.setAttributes(e),this.makeMapping()}get defaultParameters(){return Yv}setParameters(e){super.setParameters(e)}}ml.add("wideline",Kv);class Qv extends Nv{constructor(e,t,i){super(e,t,i),this.type="angle",this.parameters=Object.assign({atomTriple:{type:"hidden",rebuild:!0},vectorVisible:{type:"boolean",default:!0},arcVisible:{type:"boolean",default:!0},sectorVisible:{type:"boolean",default:!0}},this.parameters),this.init(i)}init(e){const t=e||{};t.side=Ia(t.side,"double"),t.opacity=Ia(t.opacity,.5),this.atomTriple=Ia(t.atomTriple,[]),this.arcVisible=Ia(t.arcVisible,!0),this.sectorVisible=Ia(t.sectorVisible,!0),this.vectorVisible=Ia(t.vectorVisible,!0),super.init(t)}createData(e){if(!e.atomCount||!this.atomTriple.length)return;const t=function(e,t){return function(e){const t=[],i=e.length/9;for(let n=0;n radius2) {\ndiscard;\n}\n#ifdef CAP\nsurface_point = front_point;\n_normal = axis;\n#else\nsurface_point = ray_target + ( (-a1 - sqrt(d)) / a2 ) * ray_direction;\ndNV = dot(-axis, ray_direction);\nnear = dot(axis, end) / dNV;\nnew_point2 = ray_direction * near + ray_origin;\nif (dot(new_point2 - end, new_point2-base) < radius2) {\ndiscard;\n}\ninterior = true;\n#endif\n}\nif( end_cap_test > 0.0 )\n{\nfloat dNV;\nfloat near;\nvec3 end_point;\nif ( ortho == 1.0 ) {\nend_point = ray_target;\n} else {\ndNV = dot(axis, ray_direction);\nif (dNV < 0.0) {\ndiscard;\n}\nnear = dot(axis, end) / dNV;\nend_point = ray_direction * near + ray_origin;\n}\n\nif( dot(end_point - end, end_point-base) > radius2 ) {\ndiscard;\n}\n#ifdef CAP\nsurface_point = end_point;\n_normal = axis;\n#else\nsurface_point = ray_target + ( (-a1 - sqrt(d)) / a2 ) * ray_direction;\ndNV = dot(-axis, ray_direction);\nnear = dot(-axis, (base)) / dNV;\nnew_point2 = ray_direction * near + ray_origin;\nif (dot(new_point2 - base, new_point2-base) < radius2) {\ndiscard;\n}\ninterior = true;\n#endif\n}\ngl_FragDepthEXT = calcDepth( surface_point );\n\n#ifdef NEAR_CLIP\nif( calcClip( surface_point ) > 0.0 ){\ndist = (-a1 - sqrt(d)) / a2;\nsurface_point = ray_target + dist * ray_direction;\nif( calcClip( surface_point ) > 0.0 ) {\ndiscard;\n}\ninterior = true;\ngl_FragDepthEXT = calcDepth( surface_point );\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( clipNear - 0.5 ) ) ) + ( 0.0000001 / vRadius ) );\n}\n}else if( gl_FragDepthEXT <= 0.0 ){\ndist = (-a1 - sqrt(d)) / a2;\nsurface_point = ray_target + dist * ray_direction;\ninterior = true;\ngl_FragDepthEXT = calcDepth( surface_point );\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n}\n#else\nif( gl_FragDepthEXT <= 0.0 ){\ndist = (-a1 - sqrt(d)) / a2;\nsurface_point = ray_target + dist * ray_direction;\ninterior = true;\ngl_FragDepthEXT = calcDepth( surface_point );\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n}\n#endif\nif (gl_FragDepthEXT < 0.0) {\ndiscard;\n}\nif (gl_FragDepthEXT > 1.0) {\ndiscard;\n}\n#ifdef PICKING\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 vViewPosition = -surface_point;\nvec3 vNormal = _normal;\nvec3 vColor;\nif( distSq3( surface_point, end ) < distSq3( surface_point, base ) ){\nif( b < 0.0 ){\nvColor = vColor1;\n}else{\nvColor = vColor2;\n}\n}else{\nif( b > 0.0 ){\nvColor = vColor1;\n}else{\nvColor = vColor2;\n}\n}\nvec4 diffuseColor = vec4( diffuse, opacity );\nReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\nvec3 totalEmissiveLight = emissive;\n#include color_fragment\n#include roughnessmap_fragment\n#include metalnessmap_fragment\nvec3 normal = normalize( vNormal );\nvec3 geometryNormal = normal;\n#include lights_physical_fragment\n#include lights_fragment_begin\n#include lights_fragment_end\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\nif( interior ){\n#ifdef USE_INTERIOR_COLOR\noutgoingLight.xyz = interiorColor;\n#else\n#ifdef DIFFUSE_INTERIOR\noutgoingLight.xyz = vColor;\n#endif\n#endif\noutgoingLight.xyz *= 1.0 - interiorDarkening;\n}\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");const oy=new Float32Array([-1,1,-1,-1,-1,-1,1,1,-1,1,1,1,1,-1,-1,1,-1,1]),ay=new Uint16Array([0,1,2,1,4,2,2,4,3,4,5,3]);class cy extends Zp{constructor(e,t={}){super("v3",e,t)}get mapping(){return oy}get mappingIndices(){return ay}get mappingIndicesSize(){return 12}get mappingSize(){return 6}get mappingItemSize(){return 3}}const ly=Object.assign({openEnded:!1},em),hy=Object.assign({openEnded:{updateShader:!0}},tm);class uy extends cy{constructor(e,t={}){super(e,t),this.parameterTypes=hy,this.isImpostor=!0,this.vertexShader="CylinderImpostor.vert",this.fragmentShader="CylinderImpostor.frag",this.addUniforms({modelViewMatrixInverse:{value:new ri},ortho:{value:0}}),this.addAttributes({position1:{type:"v3",value:null},position2:{type:"v3",value:null},color2:{type:"c",value:null},radius:{type:"f",value:null}}),this.setAttributes(e),this.makeMapping()}get defaultParameters(){return ly}getDefines(e){const t=cy.prototype.getDefines.call(this,e);return this.parameters.openEnded||(t.CAP=1),t}}Object.assign({disableImpostor:!1},ny,ly);const dy=class{constructor(e,t={}){return!e.color2&&e.color&&(e.color2=e.color),!el||t&&t.disableImpostor?new sy(e,t):new uy(e,t)}};ml.add("cylinder",dy);class fy extends Bv{constructor(e,t,i){super(e,t,i),this.type="axes",this.parameters=Object.assign({radiusSize:{type:"number",precision:3,max:10,min:.001},sphereDetail:!0,radialSegments:!0,disableImpostor:!0,showAxes:{type:"boolean",rebuild:!0},showBox:{type:"boolean",rebuild:!0}},this.parameters,{assembly:null}),this.init(i)}init(e){const t=e||{};t.radiusSize=Ia(t.radiusSize,.5),t.colorValue=Ia(t.colorValue,"lightgreen"),t.useInteriorColor=Ia(t.useInteriorColor,!0),this.showAxes=Ia(t.showAxes,!0),this.showBox=Ia(t.showBox,!1),super.init(t)}getPrincipalAxes(){let e;const t=this.getAssembly();return t&&(e=t.partList[0].getSelection()),this.structureView.getPrincipalAxes(e)}getAxesData(e){const t=this.getPrincipalAxes(),i=new mn(this.colorValue);let n=0,r=0;this.showAxes&&(n+=6,r+=3),this.showBox&&(n+=8,r+=12);const s=new Float32Array(3*n),o=Vl(n,i.r,i.g,i.b),a=Gl(n,this.radiusSize),c=new Float32Array(3*r),l=new Float32Array(3*r),h=Vl(r,i.r,i.g,i.b),u=Gl(r,this.radiusSize);let d=0;if(this.showAxes){const e=function(e,t){e.toArray(s,2*d),t.toArray(s,2*d+3),e.toArray(c,d),t.toArray(l,d),d+=3};e(t.begA,t.endA),e(t.begB,t.endB),e(t.begC,t.endC)}if(this.showBox){const i=new Zt,{d1a:n,d2a:r,d3a:o,d1b:a,d2b:h,d3b:u}=t.getProjectedScaleForAtoms(e);let f=2*d;const m=function(e,n,r){i.copy(t.center).addScaledVector(t.normVecA,e).addScaledVector(t.normVecB,n).addScaledVector(t.normVecC,r),i.toArray(s,f),f+=3};m(n,r,o),m(n,r,u),m(n,h,u),m(n,h,o),m(a,h,u),m(a,h,o),m(a,r,o),m(a,r,u);let p=d;const g=function(e,t){i.fromArray(s,2*d+3*e).toArray(c,p),i.fromArray(s,2*d+3*t).toArray(l,p),p+=3};g(0,1),g(0,3),g(0,6),g(1,2),g(1,7),g(2,3),g(2,4),g(3,5),g(4,5),g(4,7),g(5,6),g(6,7)}const f=new uf(t);return{vertex:{position:s,color:o,radius:a,picking:f},edge:{position1:c,position2:l,color:h,color2:h,radius:u,picking:f}}}create(){const e=this.getAxesData(this.structureView);this.sphereBuffer=new tg(e.vertex,this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0})),this.cylinderBuffer=new dy(e.edge,this.getBufferParams({openEnded:!0,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0})),this.dataList.push({sview:this.structureView,bufferList:[this.sphereBuffer,this.cylinderBuffer]})}createData(e){}updateData(e,t){const i=this.getAxesData(t.sview),n={},r={};e&&!e.position||(Object.assign(n,{position:i.vertex.position}),Object.assign(r,{position1:i.edge.position1,position2:i.edge.position2})),e&&!e.color||(Object.assign(n,{color:i.vertex.color}),Object.assign(r,{color:i.edge.color,color2:i.edge.color})),e&&!e.radius||(Object.assign(n,{radius:i.vertex.radius}),Object.assign(r,{radius:i.edge.radius})),this.sphereBuffer.setAttributes(n),this.cylinderBuffer.setAttributes(r)}}ll.add("axes",fy);class my extends Bv{constructor(e,t,i){super(e,t,i),this.type="ball+stick",this.parameters=Object.assign({sphereDetail:!0,radialSegments:!0,openEnded:!0,disableImpostor:!0,aspectRatio:{type:"number",precision:1,max:10,min:1},lineOnly:{type:"boolean",rebuild:!0},cylinderOnly:{type:"boolean",rebuild:!0},multipleBond:{type:"select",rebuild:!0,options:{off:"off",symmetric:"symmetric",offset:"offset"}},bondScale:{type:"number",precision:2,max:1,min:.01},bondSpacing:{type:"number",precision:2,max:2,min:.5},linewidth:{type:"integer",max:50,min:1,buffer:!0}},this.parameters),this.init(i)}init(e){var t=e||{};t.radiusType=Ia(t.radiusType,"size"),t.radiusSize=Ia(t.radiusSize,.15),t.useInteriorColor=Ia(t.useInteriorColor,!0),this.aspectRatio=Ia(t.aspectRatio,2),this.lineOnly=Ia(t.lineOnly,!1),this.cylinderOnly=Ia(t.cylinderOnly,!1),this.multipleBond=Ia(t.multipleBond,"off"),this.bondSpacing=Ia(t.bondSpacing,1),this.bondScale=Ia(t.bondScale,.4),this.linewidth=Ia(t.linewidth,2),super.init(t)}getAtomRadius(e){return this.aspectRatio*super.getAtomRadius(e)}getAtomParams(e,t){var i=super.getAtomParams(e,t);return i.radiusParams.scale*=this.aspectRatio,i}getAtomData(e,t,i){return e.getAtomData(this.getAtomParams(t,i))}getBondParams(e,t){return t=Object.assign({multipleBond:this.multipleBond,bondSpacing:this.bondSpacing,bondScale:this.bondScale},t),super.getBondParams(e,t)}getBondData(e,t,i){return e.getBondData(this.getBondParams(t,i))}createData(e){const t=[];if(this.lineOnly)this.lineBuffer=new Kv(this.getBondData(e,{position:!0,color:!0,picking:!0}),this.getBufferParams({linewidth:this.linewidth})),t.push(this.lineBuffer);else{const i=new dy(this.getBondData(e),this.getBufferParams({openEnded:this.openEnded,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0}));if(t.push(i),!this.cylinderOnly){const i=new tg(this.getAtomData(e),this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0}));t.push(i)}}return{bufferList:t}}updateData(e,t){"off"!==this.multipleBond&&e&&e.radius&&(e.position=!0);const i=this.getBondData(t.sview,e);if(this.lineOnly){const n={};e&&!e.position||Object.assign(n,{position1:i.position1,position2:i.position2}),e&&!e.color||Object.assign(n,{color:i.color,color2:i.color2}),t.bufferList[0].setAttributes(n)}else{var n={};if(e&&!e.position||Object.assign(n,{position1:i.position1,position2:i.position2}),e&&!e.color||Object.assign(n,{color:i.color,color2:i.color2}),e&&!e.radius||Object.assign(n,{radius:i.radius}),t.bufferList[0].setAttributes(n),!this.cylinderOnly){var r=this.getAtomData(t.sview,e),s={};e&&!e.position||Object.assign(s,{position:r.position}),e&&!e.color||Object.assign(s,{color:r.color}),e&&!e.radius||Object.assign(s,{radius:r.radius}),t.bufferList[1].setAttributes(s)}}}setParameters(e={}){let t=!1;const i={};return(e.aspectRatio||e.bondSpacing||e.bondScale)&&(Object.assign(i,{radius:!0}),el&&!this.disableImpostor||(t=!0)),super.setParameters(e,i,t),this}}ll.add("ball+stick",my);class py extends my{constructor(e,t,i){super(e,t,i),this.type="backbone",this.parameters=Object.assign({},this.parameters,{multipleBond:null,bondSpacing:null}),this.init(i)}init(e){var t=e||{};t.aspectRatio=Ia(t.aspectRatio,1),t.radiusSize=Ia(t.radiusSize,.25),super.init(t)}getAtomRadius(e){return e.isTrace()?super.getAtomRadius(e):0}getAtomData(e,t,i){return e.getBackboneAtomData(this.getAtomParams(t,i))}getBondData(e,t,i){return e.getBackboneBondData(this.getBondParams(t,i))}}ll.add("backbone",py);class gy extends my{constructor(e,t,i){super(e,t,i),this.type="base",this.parameters=Object.assign({},this.parameters,{multipleBond:null,bondSpacing:null})}init(e){let t=e||{};t.aspectRatio=Ia(t.aspectRatio,1),t.radiusSize=Ia(t.radiusSize,.3),super.init(t)}getAtomData(e,t,i){return e.getRungAtomData(this.getAtomParams(t,i))}getBondData(e,t,i){let n=this.getBondParams(t,i);return Object.assign(n.colorParams,{rung:!0}),e.getRungBondData(n)}}ll.add("base",gy);class vy{constructor(e,t){this.m=e,this.tension=t,this.dt=1/this.m,this.delta=1e-4,this.vec1=new Zt,this.vec2=new Zt,this.vDir=new Zt,this.vTan=new Zt,this.vNorm=new Zt,this.vBin=new Zt,this.m2=Math.ceil(this.m/2)}interpolateToArr(e,t,i,n,r,s,o){s[o+0]=nc(e.x,t.x,i.x,n.x,r,this.tension),s[o+1]=nc(e.y,t.y,i.y,n.y,r,this.tension),s[o+2]=nc(e.z,t.z,i.z,n.z,r,this.tension)}interpolateToVec(e,t,i,n,r,s){s.x=nc(e.x,t.x,i.x,n.x,r,this.tension),s.y=nc(e.y,t.y,i.y,n.y,r,this.tension),s.z=nc(e.z,t.z,i.z,n.z,r,this.tension)}interpolatePosition(e,t,i,n,r,s){for(var o=0;o1&&(l=1),this.interpolateToVec(e,t,i,n,c,this.vec1),this.interpolateToVec(e,t,i,n,l,this.vec2),this.vec2.sub(this.vec1).normalize(),this.vec2.toArray(r,h)}}vectorSubdivide(e,t,i,n,r){let s,o=t.next(),a=t.next(),c=t.next();const l=t.size,h=l-1;let u=n||0;for(let n=0;n0&&n{if(e.residueCount<4)return;i.push(e);const n=this.getSpline(e),r=this.getAspectRatio(e),s=n.getSubdividedPosition(),o=n.getSubdividedOrientation(),a=n.getSubdividedColor(this.getColorParams()),c=n.getSubdividedPicking(),l=n.getSubdividedSize(this.getRadiusParams());t.push(new wy(Object.assign({},s,o,a,c,l),this.getBufferParams({radialSegments:this.radialSegments,aspectRatio:r,capped:this.capped})))}),e.getSelection()),{bufferList:t,polymerList:i}}updateData(t,i){e.Debug&&il.time(this.type+" repr update"),t=t||{};for(var n=0,r=i.polymerList.length;n0;fu(w,y,S);const r=du(w,b)<0;if(bu(w,b,du(b,x)),fu(A,x,w),bu(w,b,du(b,_)),fu(M,_,w),0===yu(A)||0===yu(M))continue;_u(A,A),_u(M,M);const L=s[E]=Pu(A,M);a[E]=(Fl*L).toFixed(1)+String.fromCharCode(176),uu(T,A,b),_u(T,T),du(T,M)<0&&Cu(T,T),zv(w,S,A,T,L/2),gu(w,o,3*E);const R=Math.ceil(L/i),k=R+(t.extendLine?4:2),O=t.extendLine?36:0,B=new Float32Array(3*k),N=new Float32Array(3*k),F=new Float32Array(9*R),z=new Float32Array(O);c[E]=B,l[E]=N,h[E]=F,u[E]=z,t.extendLine&&(n?(fu(w,p,v),_u(w,w),bu(C,w,1/du(A,w)),mu(C,C,v)):(bu(C,x,1/du(A,x)),mu(C,C,g)),r?(fu(w,y,g),_u(w,w),bu(P,w,1/du(M,w)),mu(P,P,g)):(bu(P,_,1/du(M,_)),mu(P,P,v))),mu(I,S,A);let U=0;t.extendLine?(gu(p,B,U),gu(C,N,U),U+=3,gu(C,B,U),gu(I,N,U),U+=3,gu(C,z,0),gu(I,z,3),gu(n?v:g,z,6),gu(n?v:g,z,9),gu(I,z,12),gu(S,z,15)):(gu(S,B,U),gu(I,N,U),U+=3);const $=function(e,t){const i=9*t;gu(S,F,i),gu(I,F,i+3),gu(I,B,U),zv(I,S,A,T,e),gu(I,F,i+6),gu(I,N,U),U+=3};let G=0;for(let e=i;e{const t=Cy(i,e);Object.assign(e,t)})),t.side=Ia(t.side,"double"),t.opacity=Ia(t.opacity,.5),t.radiusType=Ia(t.radiusType,"size"),t.radiusSize=Ia(t.radiusSize,.15),super.init(t)}getHistogramBinBorderBufferParameters(){return this.getBufferParams({linewidth:this.histogramBinBorderWidth,visible:this.histogramBinBorderVisible,opacity:this.histogramBinBorderOpacity})}getBondArrowsBufferParameters(){return this.getBufferParams({linewidth:this.bondArrowWidth,visible:this.bondArrowVisible,opacity:this.bondArrowOpacity})}getOpaqueMiddleDiscBufferParameters(){return this.getBufferParams({visible:this.opaqueMiddleDiscVisible,opacity:this.opaqueMiddleDiscOpacity})}getHistogramBufferParameters(){return this.getBufferParams({visible:!0,opacity:this.histogramOpacity,side:"double"})}createData(e){if(!e.atomCount||!this.histogramsData.length)return;this.histogramsData.forEach((t=>t.atomPositions=Fv(e,[t.atomQuad])));const t=this.scaleBinToSectorArea?function(e){return Math.sqrt(e)}:function(e){return e};function i(e){const t=e.map((e=>e.length)),i=new Float32Array(Kl(t));let n=0;for(let t=0;te.startPoints))),position2:i(e.map((e=>e.endPoints))),color:i(e.map((e=>e.startColors))),color2:i(e.map((e=>e.endColors)))},t)}function r(e,t){return new nm({position:i(e.map((e=>e.triangles))),color:i(e.map((e=>e.triangleColors)))},t)}this.histogramsData.forEach((e=>e.histogram360Scaled=e.histogram360.map(t)));const s=[];for(let e=0;e=3&&(t=Iy(i)),void 0!==t&&s.push(t)}return this.frontHistogramBinBordersBuffer=n(s.map((e=>e.frontHistogramBinBorders)),this.getHistogramBinBorderBufferParameters()),this.backHistogramBinBordersBuffer=n(s.map((e=>e.backHistogramBinBorders)),this.getHistogramBinBorderBufferParameters()),this.adjacentBondArrowsBuffer=n(s.map((e=>e.adjacentBondArrows)),this.getBondArrowsBufferParameters()),this.distantBondArrowsBuffer=n(s.map((e=>e.distantBondArrows)),this.getBondArrowsBufferParameters()),this.opaqueMiddleDiscBuffer=r(s.map((e=>e.opaqueMiddleDisc)),this.getOpaqueMiddleDiscBufferParameters()),this.frontHistogramBuffer=r(s.map((e=>e.frontHistogram)),this.getHistogramBufferParameters()),this.backHistogramBuffer=r(s.map((e=>e.backHistogram)),this.getHistogramBufferParameters()),{bufferList:[].concat(this.frontHistogramBinBordersBuffer,this.backHistogramBinBordersBuffer,this.adjacentBondArrowsBuffer,this.distantBondArrowsBuffer,this.opaqueMiddleDiscBuffer,this.frontHistogramBuffer,this.backHistogramBuffer)}}setParameters(e){return super.setParameters(e,{},!1),e&&void 0!==e.histogramBinBorderVisible&&this.setVisibility(this.visible),this}setVisibility(e,t){return super.setVisibility(e,!0),this.frontHistogramBinBordersBuffer&&this.frontHistogramBinBordersBuffer.setVisibility(this.histogramBinBorderVisible),this.backHistogramBinBordersBuffer&&this.backHistogramBinBordersBuffer.setVisibility(this.histogramBinBorderVisible),t||this.viewer.requestRender(),this}}function Iy(e){const t=e.atomPositions,i=e.histogram360Scaled,n=i.length<=180?360:2*i.length,r={triangles:new Float32Array(3*n*3),triangleColors:Py(e.opaqueMiddleDiscColor,3*n)},s={triangles:new Float32Array(3*i.length*3),triangleColors:Py(e.frontHistogramColor,3*i.length)},o={triangles:new Float32Array(3*i.length*3),triangleColors:Py(e.backHistogramColor,3*i.length)},a={startPoints:new Float32Array(3*i.length),endPoints:new Float32Array(3*i.length),startColors:Py(e.histogramBinBorderColor,i.length),endColors:Py(e.histogramBinBorderColor,i.length)},c={startPoints:new Float32Array(3*i.length),endPoints:new Float32Array(3*i.length),startColors:Py(e.histogramBinBorderColor,i.length),endColors:Py(e.histogramBinBorderColor,i.length)},l={startPoints:new Float32Array(6),endPoints:new Float32Array(6),startColors:Py(e.adjacentBondArrowColor,i.length),endColors:Py(e.adjacentBondArrowColor,i.length)},h={startPoints:new Float32Array(6),endPoints:new Float32Array(6),startColors:Py(e.distantBondArrowColor,i.length),endColors:Py(e.distantBondArrowColor,i.length)},u=hu(),d=hu(),f=hu(),m=hu(),p=hu(),g=hu(),v=hu(),y=hu(),x=hu(),b=hu(),_=hu(),w=hu(),S=hu(),A=hu(),M=hu(),C=hu(),P=[u,d,f,m];for(let e=0;e{let d=t[0],f=t[1];if("number"==typeof d&&Number.isInteger(d)&&"number"==typeof f&&Number.isInteger(f)){if(!u.get(d)||!u.get(f))return void(h+=1);c.index=d,l.index=f}else{s.setString(d),o.setString(f);var m=e.getAtomIndices(s),p=e.getAtomIndices(o);if(!m.length||!p.length)return void(h+=1);c.index=m[0],l.index=p[0]}a.addBond(c,l,1),i-=h;var g=c.distanceTo(l);switch(this.labelUnit){case"angstrom":n[i]=g.toFixed(2)+" "+String.fromCharCode(8491);break;case"nm":n[i]=(g/10).toFixed(2)+" nm";break;default:n[i]=g.toFixed(2)}var v=3*i;r[v+0]=(c.x+l.x)/2,r[v+1]=(c.y+l.y)/2,r[v+2]=(c.z+l.z)/2})),h>0&&(i-=h,r=r.subarray(0,3*i));var d=new Yu(a.count,!0);return{text:n,position:r,bondSet:d,bondStore:a}}getBondData(e,t,i){const n=e.getBondData(this.getBondParams(t,i));return n.picking&&(n.picking=new pf(n.picking.array,n.picking.structure,i.bondStore)),n}createData(e){if(!e.atomCount||!this.atomPair.length)return;const t=this.atomPair.length,i=new mn(this.labelColor),n=this.getDistanceData(e,this.atomPair);this.textBuffer=new Xv({position:n.position,size:Gl(t,this.labelSize),color:Vl(t,i.r,i.g,i.b),text:n.text},this.getLabelBufferParams());const r={bondSet:n.bondSet,bondStore:n.bondStore},s=this.getBondData(e,{position:!0,color:!0,picking:!0,radius:this.useCylinder},r);return this.useCylinder?this.distanceBuffer=new dy(s,this.getBufferParams({openEnded:this.openEnded,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0})):this.distanceBuffer=new Kv(Iu(s),this.getBufferParams({linewidth:this.linewidth,visible:this.lineVisible,opacity:this.lineOpacity})),{bondSet:n.bondSet,bondStore:n.bondStore,position:n.position,bufferList:[this.textBuffer,this.distanceBuffer]}}updateData(e,t){super.updateData(e,t);const i={bondSet:t.bondSet,bondStore:t.bondStore},n=this.getBondData(t.sview,e,i),r={};e&&!e.color||Object.assign(r,{color:n.color,color2:n.color2}),e&&!e.radius||Object.assign(r,{radius:n.radius}),this.distanceBuffer.setAttributes(r)}setParameters(e){return super.setParameters(e,{},!1),this.useCylinder||(e&&e.lineOpacity&&this.distanceBuffer.setParameters({opacity:e.lineOpacity}),e&&void 0!==e.opacity&&this.distanceBuffer.setParameters({opacity:this.lineOpacity}),e&&e.linewidth&&this.distanceBuffer.setParameters({linewidth:e.linewidth})),this}}function Dy(e){return 2*(e.position.length/3)*3}ll.add("distance",Ey);const Ly=Object.assign({scale:1,color:"grey"},em);class Ry extends im{constructor(e,t={}){super({position:new Float32Array(Dy(e)),color:new Float32Array(Dy(e))},t),this.isLine=!0,this.vertexShader="Line.vert",this.fragmentShader="Line.frag";const i=new mn(this.parameters.color),n=this.geometry.attributes;Vl(Dy(e)/3,i.r,i.g,i.b,n.color.array),this.setAttributes(e)}get defaultParameters(){return Ly}setAttributes(e={}){const t=this.geometry.attributes;let i,n,r;e.position&&e.vector&&(i=e.position,n=e.vector,r=t.position.array,t.position.needsUpdate=!0);const s=this.size/2,o=this.parameters.scale;if(i&&n)for(let e=0;e{if(e.residueCount<4)return;i.push(e);const n=new zm(e),r=n.getPosition(),s=n.getColor(this.getColorParams()),o=n.getSize(this.getRadiusParams()),a=n.getPicking();t.push(new tg({position:r.center,color:s.color,radius:o.size,picking:a.picking},this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0})),new Ry({position:r.center,vector:r.axis},this.getBufferParams({color:"skyblue",scale:1})),new Ry({position:r.center,vector:r.resdir},this.getBufferParams({color:"lightgreen",scale:1})))}),e.getSelection()),{bufferList:t,polymerList:i}}updateData(t,i){e.Debug&&il.time(this.type+" repr update"),t=t||{};for(let e=0,n=i.polymerList.length;e radius2) {\nspaceposition.y = mapping.y * 1.5 * radius1;\nspaceposition.x = mapping.x * 1.5 * radius1;\n} else {\nspaceposition.y = mapping.y * 1.5 * radius2;\nspaceposition.x = mapping.x * 1.5 * radius2;\n}\nspaceposition.w = 1.0;\nvec4 e3 = vec4( 1.0 );\nvec3 e1, e1_temp, e2, e2_temp;\ne3.xyz = normalize(position_atom1-position_atom2);\nif (e3.z == 0.0) { e3.z = 0.0000000000001;}\nif ( (position_atom1.x - position_atom2.x) == 0.0) { position_atom1.x += 0.001;}\nif ( (position_atom1.y - position_atom2.y) == 0.0) { position_atom1.y += 0.001;}\nif ( (position_atom1.z - position_atom2.z) == 0.0) { position_atom1.z += 0.001;}\nvec4 focus = vec4( 1.0 );\nfocus.x = ( position_atom1.x*position_atom1.x - position_atom2.x*position_atom2.x +\n( radius2*radius2 - radius1*radius1 )*e3.x*e3.x/shrink )/(2.0*(position_atom1.x - position_atom2.x));\nfocus.y = ( position_atom1.y*position_atom1.y - position_atom2.y*position_atom2.y +\n( radius2*radius2 - radius1*radius1 )*e3.y*e3.y/shrink )/(2.0*(position_atom1.y - position_atom2.y));\nfocus.z = ( position_atom1.z*position_atom1.z - position_atom2.z*position_atom2.z +\n( radius2*radius2 - radius1*radius1 )*e3.z*e3.z/shrink )/(2.0*(position_atom1.z - position_atom2.z));\ne1.x = 1.0;\ne1.y = 1.0;\ne1.z = ( (e3.x*focus.x + e3.y*focus.y + e3.z*focus.z) - e1.x*e3.x - e1.y*e3.y)/e3.z;\ne1_temp = e1 - focus.xyz;\ne1 = normalize(e1_temp);\ne2_temp = e1.yzx * e3.zxy - e1.zxy * e3.yzx;\ne2 = normalize(e2_temp);\nmat3 R= mat3( e1.xyz, e2.xyz, e3.xyz );\nvertex_position.xyz = R * spaceposition.xyz;\nvertex_position.w = 1.0;\nvertex_position.x += (position_atom1.x+position_atom2.x) / 2.0;\nvertex_position.y += (position_atom1.y+position_atom2.y) / 2.0;\nvertex_position.z += (position_atom1.z+position_atom2.z) / 2.0;\ngl_Position = modelViewProjectionMatrix * vertex_position;\nvec4 i_near, i_far;\nvec4 near = gl_Position;\nnear.z = 0.0 ;\nnear = modelViewProjectionMatrixInverse * near;\ni_near = near;\nvec4 far = gl_Position;\nfar.z = far.w ;\ni_far = modelViewProjectionMatrixInverse * far;\nprime1 = vec4( position_atom1 - (position_atom1 - focus.xyz)*shrink, 1.0 );\nprime2 = vec4( position_atom2 - (position_atom2 - focus.xyz)*shrink, 1.0 );\nfloat Rsquare = (radius1*radius1/shrink) - (\n(position_atom1.x - focus.x)*(position_atom1.x - focus.x) +\n(position_atom1.y - focus.y)*(position_atom1.y - focus.y) +\n(position_atom1.z - focus.z)*(position_atom1.z - focus.z)\n);\nfocus.w = Rsquare;\nmatrix_near = mat4( i_near, i_far, focus, e3 );\ngl_Position.z = 1.0;\n}"),ul.add("shader/HyperballStickImpostor.frag","#define STANDARD\n#define IMPOSTOR\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 interiorColor;\nuniform float interiorDarkening;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\nuniform float clipNear;\nuniform float shrink;\nuniform mat4 modelViewMatrix;\nuniform mat4 modelViewProjectionMatrix;\nuniform mat4 modelViewMatrixInverseTranspose;\nuniform mat4 projectionMatrix;\nvarying mat4 matrix_near;\nvarying vec4 prime1;\nvarying vec4 prime2;\nvarying float vRadius;\nvarying float vRadius2;\n#ifdef PICKING\nuniform float objectId;\nvarying vec3 vPickingColor;\n#else\nvarying vec3 vColor1;\nvarying vec3 vColor2;\n#include common\n#include fog_pars_fragment\n#include bsdfs\n#include lights_pars_begin\n#include lights_physical_pars_fragment\n#endif\nbool interior = false;\nfloat calcClip( vec4 cameraPos ){\nreturn dot( cameraPos, vec4( 0.0, 0.0, 1.0, clipNear - 0.5 ) );\n}\nfloat calcClip( vec3 cameraPos ){\nreturn calcClip( vec4( cameraPos, 1.0 ) );\n}\nfloat calcDepth( in vec3 cameraPos ){\nvec2 clipZW = cameraPos.z * projectionMatrix[2].zw + projectionMatrix[3].zw;\nreturn 0.5 + 0.5 * clipZW.x / clipZW.y;\n}\nstruct Ray {\nvec3 origin ;\nvec3 direction ;\n};\nbool cutoff_plane (vec3 M, vec3 cutoff, vec3 x3){\nfloat a = x3.x;\nfloat b = x3.y;\nfloat c = x3.z;\nfloat d = -x3.x*cutoff.x-x3.y*cutoff.y-x3.z*cutoff.z;\nfloat l = a*M.x+b*M.y+c*M.z+d;\nif (l<0.0) {return true;}\nelse{return false;}\n}\nvec3 isect_surf(Ray r, mat4 matrix_coef){\nvec4 direction = vec4(r.direction, 0.0);\nvec4 origin = vec4(r.origin, 1.0);\nfloat a = dot(direction,(matrix_coef*direction));\nfloat b = dot(origin,(matrix_coef*direction));\nfloat c = dot(origin,(matrix_coef*origin));\nfloat delta =b*b-a*c;\ngl_FragColor.a = 1.0;\nif (delta<0.0){\ndiscard;\n}\nfloat t1 =(-b-sqrt(delta))/a;\nreturn r.origin+t1*r.direction;\n}\nvec3 isect_surf2(Ray r, mat4 matrix_coef){\nvec4 direction = vec4(r.direction, 0.0);\nvec4 origin = vec4(r.origin, 1.0);\nfloat a = dot(direction,(matrix_coef*direction));\nfloat b = dot(origin,(matrix_coef*direction));\nfloat c = dot(origin,(matrix_coef*origin));\nfloat delta =b*b-a*c;\ngl_FragColor.a = 1.0;\nif (delta<0.0){\ndiscard;\n}\nfloat t2 =(-b+sqrt(delta))/a;\nreturn r.origin+t2*r.direction;\n}\nRay primary_ray(vec4 near1, vec4 far1){\nvec3 near=near1.xyz/near1.w;\nvec3 far=far1.xyz/far1.w;\nreturn Ray(near,far-near);\n}\nfloat update_z_buffer(vec3 M, mat4 ModelViewP){\nfloat depth1;\nvec4 Ms=(ModelViewP*vec4(M,1.0));\nreturn depth1=(1.0+Ms.z/Ms.w)/2.0;\n}\nvoid main(){\nfloat radius = max( vRadius, vRadius2 );\nvec4 i_near, i_far, focus;\nvec3 e3, e1, e1_temp, e2;\ni_near = vec4(matrix_near[0][0],matrix_near[0][1],matrix_near[0][2],matrix_near[0][3]);\ni_far = vec4(matrix_near[1][0],matrix_near[1][1],matrix_near[1][2],matrix_near[1][3]);\nfocus = vec4(matrix_near[2][0],matrix_near[2][1],matrix_near[2][2],matrix_near[2][3]);\ne3 = vec3(matrix_near[3][0],matrix_near[3][1],matrix_near[3][2]);\ne1.x = 1.0;\ne1.y = 1.0;\ne1.z = ( (e3.x*focus.x + e3.y*focus.y + e3.z*focus.z) - e1.x*e3.x - e1.y*e3.y)/e3.z;\ne1_temp = e1 - focus.xyz;\ne1 = normalize(e1_temp);\ne2 = normalize(cross(e1,e3));\nvec4 equation = focus;\nfloat shrinkfactor = shrink;\nfloat t1 = -1.0/(1.0-shrinkfactor);\nfloat t2 = 1.0/(shrinkfactor);\nvec4 colonne1, colonne2, colonne3, colonne4;\nmat4 mat;\nvec3 equation1 = vec3(t2,t2,t1);\nfloat A1 = - e1.x*equation.x - e1.y*equation.y - e1.z*equation.z;\nfloat A2 = - e2.x*equation.x - e2.y*equation.y - e2.z*equation.z;\nfloat A3 = - e3.x*equation.x - e3.y*equation.y - e3.z*equation.z;\nfloat A11 = equation1.x*e1.x*e1.x + equation1.y*e2.x*e2.x + equation1.z*e3.x*e3.x;\nfloat A21 = equation1.x*e1.x*e1.y + equation1.y*e2.x*e2.y + equation1.z*e3.x*e3.y;\nfloat A31 = equation1.x*e1.x*e1.z + equation1.y*e2.x*e2.z + equation1.z*e3.x*e3.z;\nfloat A41 = equation1.x*e1.x*A1 + equation1.y*e2.x*A2 + equation1.z*e3.x*A3;\nfloat A22 = equation1.x*e1.y*e1.y + equation1.y*e2.y*e2.y + equation1.z*e3.y*e3.y;\nfloat A32 = equation1.x*e1.y*e1.z + equation1.y*e2.y*e2.z + equation1.z*e3.y*e3.z;\nfloat A42 = equation1.x*e1.y*A1 + equation1.y*e2.y*A2 + equation1.z*e3.y*A3;\nfloat A33 = equation1.x*e1.z*e1.z + equation1.y*e2.z*e2.z + equation1.z*e3.z*e3.z;\nfloat A43 = equation1.x*e1.z*A1 + equation1.y*e2.z*A2 + equation1.z*e3.z*A3;\nfloat A44 = equation1.x*A1*A1 + equation1.y*A2*A2 + equation1.z*A3*A3 - equation.w;\ncolonne1 = vec4(A11,A21,A31,A41);\ncolonne2 = vec4(A21,A22,A32,A42);\ncolonne3 = vec4(A31,A32,A33,A43);\ncolonne4 = vec4(A41,A42,A43,A44);\nmat = mat4(colonne1,colonne2,colonne3,colonne4);\nRay ray = primary_ray(i_near,i_far) ;\nvec3 M;\nM = isect_surf(ray, mat);\nif (cutoff_plane(M, prime1.xyz, -e3) || cutoff_plane(M, prime2.xyz, e3)){ discard; }\nvec4 M1 = vec4(M,1.0);\nvec4 M2 = mat*M1;\nvec3 _normal = ( modelViewMatrixInverseTranspose * M2 ).xyz;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix) ;\n#ifdef NEAR_CLIP\nif( calcClip( modelViewMatrix * vec4( M, 1.0 ) ) > 0.0 ){\nM = isect_surf2(ray, mat);\nif( calcClip( modelViewMatrix * vec4( M, 1.0 ) ) > 0.0 )\ndiscard;\ninterior = true;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix) ;\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( clipNear - 0.5 ) ) ) + ( 0.0000001 / radius ) );\n}\n}else if( gl_FragDepthEXT <= 0.0 ){\nM = isect_surf2(ray, mat);\ninterior = true;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix);\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / radius );\n}\n}\n#else\nif( gl_FragDepthEXT <= 0.0 ){\nM = isect_surf2(ray, mat);\ninterior = true;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix) ;\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / radius );\n}\n}\n#endif\nif (cutoff_plane(M, prime1.xyz, -e3) || cutoff_plane(M, prime2.xyz, e3)){ discard; }\nif (gl_FragDepthEXT < 0.0)\ndiscard;\nif (gl_FragDepthEXT > 1.0)\ndiscard;\nfloat distance_ratio = ((M.x-prime2.x)*e3.x + (M.y-prime2.y)*e3.y +(M.z-prime2.z)*e3.z) /\ndistance(prime2.xyz,prime1.xyz);\n#ifdef PICKING\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 vViewPosition = -( modelViewMatrix * vec4( M, 1.0 ) ).xyz;\nvec3 vNormal = _normal;\nvec3 vColor;\nif( distance_ratio>0.5 ){\nvColor = vColor1;\n}else{\nvColor = vColor2;\n}\nvec4 diffuseColor = vec4( diffuse, opacity );\nReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\nvec3 totalEmissiveLight = emissive;\n#include color_fragment\n#include roughnessmap_fragment\n#include metalnessmap_fragment\nvec3 normal = normalize( vNormal );\nvec3 geometryNormal = normal;\n#include lights_physical_fragment\n#include lights_fragment_begin\n#include lights_fragment_end\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\nif( interior ){\n#ifdef USE_INTERIOR_COLOR\noutgoingLight.xyz = interiorColor;\n#else\n#ifdef DIFFUSE_INTERIOR\noutgoingLight.xyz = vColor;\n#endif\n#endif\noutgoingLight.xyz *= 1.0 - interiorDarkening;\n}\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");const By=new Float32Array([-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,-1,1,-1,1,1,-1,1,1,1,-1,1,1]),Ny=new Uint16Array([0,1,2,0,2,3,1,5,6,1,6,2,4,6,5,4,7,6,0,7,4,0,3,7,0,5,1,0,4,5,3,2,6,3,6,7]);class Fy extends Zp{constructor(e,t={}){super("v3",e,t)}get mapping(){return By}get mappingIndices(){return Ny}get mappingIndicesSize(){return 36}get mappingSize(){return 8}get mappingItemSize(){return 3}}const zy=Object.assign({shrink:.14},em),Uy=Object.assign({shrink:{uniform:!0}},tm);class $y extends Fy{constructor(e,t={}){super(e,t),this.parameterTypes=Uy,this.isImpostor=!0,this.vertexShader="HyperballStickImpostor.vert",this.fragmentShader="HyperballStickImpostor.frag",this.addUniforms({modelViewProjectionMatrix:{value:new ri},modelViewProjectionMatrixInverse:{value:new ri},modelViewMatrixInverseTranspose:{value:new ri},shrink:{value:this.parameters.shrink}}),this.addAttributes({position1:{type:"v3",value:null},position2:{type:"v3",value:null},color2:{type:"c",value:null},radius:{type:"f",value:null},radius2:{type:"f",value:null}}),this.setAttributes(e),this.makeMapping()}get defaultParameters(){return zy}}Object.assign({disableImpostor:!1},ny,zy);const Gy=class{constructor(e,t={}){return!el||t&&t.disableImpostor?(e.radius=function(e,t){const i=e.length,n=new Float32Array(i);for(let r=0;ra.push(n.atomLabel(e)))))}else if("residue"===this.labelGrouping){t&&!t.position||(c=[]),t&&!t.color||(h=[]),t&&!t.radius||(l=[]),t&&!t.text||(a=[]),i.colorParams&&(i.colorParams.structure=e.getStructure());const u=al.getScheme(i.colorParams),d=new Tm(i.radiusParams),f=e.getAtomProxy();let m=0;e.eachResidue((e=>{const i=3*m;e.isProtein()||e.isNucleic()?(f.index=e.traceAtomIndex,t&&!t.position||f.positionToArray(c,i)):(f.index=e.atomOffset,t&&!t.position||e.positionToArray(c,i)),t&&!t.color||u.atomColorToArray(f,h,i),t&&!t.radius||(l[m]=d.atomRadius(f)),t&&!t.text||a.push(n.atomLabel(f)),++m})),t&&!t.position||(r=new Float32Array(c)),t&&!t.color||(o=new Float32Array(h)),t&&!t.radius||(s=new Float32Array(l))}return{position:r,size:s,color:o,text:a}}createData(e){return{bufferList:[new Xv(this.getTextData(e,{position:!0,color:!0,radius:!0,text:!0}),this.getBufferParams({fontFamily:this.fontFamily,fontStyle:this.fontStyle,fontWeight:this.fontWeight,xOffset:this.xOffset,yOffset:this.yOffset,zOffset:this.zOffset,attachment:this.attachment,showBorder:this.showBorder,borderColor:this.borderColor,borderWidth:this.borderWidth,showBackground:this.showBackground,backgroundColor:this.backgroundColor,backgroundMargin:this.backgroundMargin,backgroundOpacity:this.backgroundOpacity,fixedSize:this.fixedSize}))]}}updateData(e,t){t.bufferList[0].setAttributes(this.getTextData(t.sview,e))}getAtomRadius(){return 0}}function Wy(e){const t=e.getAtomSet(),i=e.getBondSet(),n=e.getBondProxy();return i.forEach((function(e){n.index=e,t.clear(n.atomIndex1),t.clear(n.atomIndex2)})),t}ll.add("label",jy);class qy extends Bv{constructor(e,t,i){super(e,t,i),this.type="line",this.parameters=Object.assign({multipleBond:{type:"select",rebuild:!0,options:{off:"off",symmetric:"symmetric",offset:"offset"}},bondSpacing:{type:"number",precision:2,max:2,min:.5},linewidth:{type:"integer",max:50,min:1,buffer:!0},lines:{type:"boolean",rebuild:!0},crosses:{type:"select",rebuild:!0,options:{off:"off",lone:"lone",all:"all"}},crossSize:{type:"number",precision:2,max:2,min:.1}},this.parameters,{flatShaded:null,side:null,wireframe:null,roughness:null,metalness:null}),this.init(i)}init(e){var t=e||{};this.multipleBond=Ia(t.multipleBond,"off"),this.bondSpacing=Ia(t.bondSpacing,1),this.linewidth=Ia(t.linewidth,2),this.lines=Ia(t.lines,!0),this.crosses=Ia(t.crosses,"lone"),this.crossSize=Ia(t.crossSize,.4),super.init(t)}getAtomRadius(e){return.1}getBondParams(e,t){return t=Object.assign({multipleBond:this.multipleBond,bondSpacing:this.bondSpacing,radiusParams:{type:"size",size:.1,scale:1}},t),super.getBondParams(e,t)}_crossData(e,t){if(e&&!e.position&&!e.color)return;const i={};"lone"===this.crosses&&Object.assign(i,{atomSet:Wy(t)});const n=t.getAtomData(this.getAtomParams(e,i)),r={},s=n.position,o=n.color,a=n.picking,c=(s||o).length,l=3*c;let h=new Float32Array(0),u=new Float32Array(0),d=new Float32Array(0),f=new Float32Array(0),m=0,p=new Float32Array(0);e&&!e.position||(h=r.position1=new Float32Array(l),u=r.position2=new Float32Array(l),m=this.crossSize/2),e&&!e.color||(d=r.color=new Float32Array(l),f=r.color2=new Float32Array(l)),e&&!e.picking||(p=new Float32Array(3*n.picking.array.length));for(let t=0;tl?d[p]=-1:(c=Math.sqrt(l-a),d[p]=Math.floor(c)),++p;m[g]=u,f[g]=d}}function T(i){var n,r,s,a,u,p,y,b,_,w,A,M,C,P,T,I,E,D,L=3*i,R=i;n=Math.floor(.5+o*(e[L]+d[0])),r=Math.floor(.5+o*(e[L+1]+d[1])),s=Math.floor(.5+o*(e[L+2]+d[2]));var k,O=t[R],B=f[O],N=0,F=l*h,z=m[O];for(w=0;w=c||P>=l||T>=h)){var U=C*F+P*h+T;if(g)if(v[U]&S){if(v[U]&S){var $=x[U];$!==L&&y*y+b*b+_*_<(a=n+y-Math.floor(.5+o*(e[$]+d[0])))*a+(u=r+b-Math.floor(.5+o*(e[$+1]+d[1])))*u+(p=s+_-Math.floor(.5+o*(e[$+2]+d[2])))*p&&(x[U]=i)}}else v[U]|=S,x[U]=i;else v[U]|=S}N++}}function I(t){var i,n;for(console.time("EDTSurface fillvoxels"),i=0,n=v.length;i=c||S>=l||M>=h)){var F=w*N+S*h+M;if(v[F]&A){if(g){var z=x[F];y*y+b*b+_*_<(a=Math.floor(.5+o*(e[z]+d[0])))*a+(u=Math.floor(.5+o*(e[z+1]+d[1])))*u+(p=Math.floor(.5+o*(e[z+2]+d[2])))*p&&(x[F]=i)}}else v[F]|=A,g&&(x[F]=i)}O++}}function D(){var e,t,i,n;console.time("EDTSurface fastdistancemap");var r,s=Xy(c,l,h,Uint16Array,3),o=l*h,u=p*p,d=0;for(e=0;e0);var w,C=a*a,P=new Uint16Array(3);for(e=0;e=C)||(v[r]|=M,g&&v[r]&A&&(s.toArray(e,t,i,P),w=P[0]*o+P[1]*h+P[2],x[r]=x[w])));console.timeEnd("EDTSurface fastdistancemap")}function L(e,t,i,n){var r,s,o,a,u,d,f,m,p,g,x,b,_=new Uint16Array(3),w=0;if(0===i)return w;var P=-1,T=-1,I=-1,E=l*h;for(f=0,p=i;f-1&&T-1&&I-1&&(v[x=P*E+h*T+I]&S&&!(v[x]&A)?(t.fromArray(P,T,I,_),g=(a=P-_[0])*a+(u=T-_[1])*u+(d=I-_[2])*d,y[x]=g,v[x]|=A,v[x]|=M,n[w]=P,n[w+1]=T,n[w+2]=I,w+=3):v[x]&S&&v[x]&A&&(g=(a=P-_[0])*a+(u=T-_[1])*u+(d=I-_[2])*d)-1&&T-1&&I-1&&(v[x=P*E+h*T+I]&S&&!(v[x]&A)?(t.fromArray(P,T,I,_),g=(a=P-_[0])*a+(u=T-_[1])*u+(d=I-_[2])*d,y[x]=g,v[x]|=A,v[x]|=M,n[w]=P,n[w+1]=T,n[w+2]=I,w+=3):v[x]&S&&v[x]&A&&(g=(a=P-_[0])*a+(u=T-_[1])*u+(d=I-_[2])*d)-1&&T-1&&I-1&&(v[x=P*E+h*T+I]&S&&!(v[x]&A)?(t.fromArray(P,T,I,_),g=(a=P-_[0])*a+(u=T-_[1])*u+(d=I-_[2])*d,y[x]=g,v[x]|=A,v[x]|=M,n[w]=P,n[w+1]=T,n[w+2]=I,w+=3):v[x]&S&&v[x]&A&&(g=(a=P-_[0])*a+(u=T-_[1])*u+(d=I-_[2])*d)-1&&o-1&&u-1&&aE&&(E=k)}return{neighbourListLength:27*E+1,withinRadii:function(r,s,o,a,u){for(var d=0,f=m(r,c),p=m(s,l),g=m(o,h),v=Math.max(0,f-1),_=Math.max(0,p-1),S=Math.max(0,g-1),A=Math.min(y,f+2),M=Math.min(x,p+2),I=Math.min(b,g+2),E=v;Ed&&(d=h[e]);!function(){const e=qf(c,l,d,m,0);m=e.scaleFactor,v=e.dim,y=e.matrix,R=Math.max(5,2+Math.floor(f*m)),x=Gl(v[0]*v[1]*v[2],-1001),b=new Int32Array(x.length),_=new Float32Array(v[0]),w=new Float32Array(v[1]),S=new Float32Array(v[2]),O(_,c[0],1/m),O(w,c[1],1/m),O(S,c[2],1/m)}(),function(){var e=0,t=2*Math.PI/g;M=new Float32Array(g),A=new Float32Array(g);for(var i=0;i=0;){if(s!==n&&s!==r&&N(s,e,t,i))return T=s,s;s=P[++o]}return T=-1,-1}function N(t,i,n,r){var s=3*t,o=u[t],a=e[s]-i,c=e[s+1]-n,l=e[s+2]-r;return a*a+c*c+l*l0&&d=0;)e{t(this._makeSurface(e.data.sd,i))}),(e=>{console.warn("MolecularSurface.getSurfaceWorker error - trying without worker",e),this.worker.terminate(),this.worker=void 0;const n=this.getSurface(i);t(n)}))}else{const e=this.getSurface(i);t(e)}}dispose(){this.worker&&this.worker.terminate()}}class Jy extends Bv{constructor(e,t,i){super(e,t,i),this.type="surface",this.parameters=Object.assign({surfaceType:{type:"select",rebuild:!0,options:{vws:"vws",sas:"sas",ms:"ms",ses:"ses",av:"av"}},probeRadius:{type:"number",precision:1,max:20,min:0,rebuild:!0},smooth:{type:"integer",precision:1,max:10,min:0,rebuild:!0},scaleFactor:{type:"number",precision:1,max:5,min:0,rebuild:!0},cutoff:{type:"number",precision:2,max:50,min:0,rebuild:!0},contour:{type:"boolean",rebuild:!0},background:{type:"boolean",rebuild:!0},opaqueBack:{type:"boolean",buffer:!0},filterSele:{type:"text",rebuild:!0},colorVolume:{type:"hidden"},useWorker:{type:"boolean",rebuild:!0}},this.parameters,{radius:null,scale:null}),this.__infoList=[],this.structure.signals.refreshed.add((()=>{this.__forceNewMolsurf=!0})),this.toBePrepared=!0,this.init(i)}init(e){const t=e||{};t.colorScheme=Ia(t.colorScheme,"uniform"),t.colorValue=Ia(t.colorValue,14540253),t.disablePicking=Ia(t.disablePicking,!0),this.surfaceType=Ia(t.surfaceType,"ms"),this.probeRadius=Ia(t.probeRadius,1.4),this.smooth=Ia(t.smooth,2),this.scaleFactor=Ia(t.scaleFactor,2),this.cutoff=Ia(t.cutoff,0),this.contour=Ia(t.contour,!1),this.background=Ia(t.background,!1),this.opaqueBack=Ia(t.opaqueBack,!0),this.filterSele=Ia(t.filterSele,""),this.colorVolume=Ia(t.colorVolume,void 0),this.useWorker=Ia(t.useWorker,!0),super.init(e)}prepareData(e,t,i){let n=this.__infoList[t];if(n||(n={},this.__infoList[t]=n),n.molsurf&&n.sele===e.selection.string)i(t);else{if(this.filterSele){const n=e.structure.getView(new $c(this.filterSele)),r=n.boundingBox.getSize(new Zt),s=Math.max(r.x,r.y,r.z),o=e.getAtomSetWithinPoint(n.center,s/2+6);if(0===(e=e.getView(new $c(e.getAtomSetWithinSelection(o,3).toSeleString()))).atomCount)return void i(t)}n.sele=e.selection.string,n.molsurf=new Qy(e);const r=this.getSurfaceParams(),s=e=>{n.surface=e,i(t)};this.useWorker?n.molsurf.getSurfaceWorker(r,s):s(n.molsurf.getSurface(r))}}prepare(e){if((this.__forceNewMolsurf||this.__sele!==this.selection.string||this.__surfaceParams!==JSON.stringify(this.getSurfaceParams()))&&(this.__infoList.forEach((e=>{e&&e.molsurf&&e.molsurf.dispose()})),this.__infoList.length=0),0===this.structureView.atomCount)return void e();const t=()=>{this.__sele=this.selection.string,this.__surfaceParams=JSON.stringify(this.getSurfaceParams()),this.__forceNewMolsurf=!1,e()},i="default"===this.assembly?this.defaultAssembly:this.assembly,n=this.structure.biomolDict[i];n?n.partList.forEach(((e,i)=>{const r=e.getView(this.structureView);this.prepareData(r,i,(e=>{e===n.partList.length-1&&t()}))})):this.prepareData(this.structureView,0,t)}createData(e,t){const i=this.__infoList[t],n=i.surface;if(!n)return;const r={position:n.getPosition(),color:n.getColor(this.getColorParams()),index:n.getFilteredIndex(this.filterSele,e)},s=[];if(n.contour){const e=new cm(r,this.getBufferParams({wireframe:!1}));s.push(e)}else{Object.assign(r,{normal:n.getNormal(),picking:n.getPicking(e.getStructure())});const t=new rm(r,this.getBufferParams({background:this.background,opaqueBack:this.opaqueBack,dullInterior:!1}));if("double"==this.getBufferParams().side){const e=new am(t);s.push(e)}else s.push(t)}return{bufferList:s,info:i}}updateData(e,t){const i={};if(e.position||e.radius)return this.__forceNewMolsurf=!0,void this.build();e.color&&(i.color=t.info.surface.getColor(this.getColorParams())),e.index&&(i.index=t.info.surface.getFilteredIndex(this.filterSele,t.sview)),t.bufferList[0].setAttributes(i)}setParameters(e,t={},i){return e&&e.filterSele&&(t.index=!0),e&&void 0!==e.colorVolume&&(t.color=!0),e&&e.wireframe&&(e.contour||void 0===e.contour&&this.contour)&&(e.wireframe=!1),super.setParameters(e,t,i),this}getSurfaceParams(e={}){return Object.assign({type:this.surfaceType,probeRadius:this.probeRadius,scaleFactor:this.scaleFactor,smooth:this.smooth&&!this.contour,cutoff:this.cutoff,contour:this.contour,useWorker:this.useWorker,radiusParams:this.getRadiusParams()},e)}getColorParams(){const e=super.getColorParams();return e.volume=this.colorVolume,e}getAtomRadius(){return 0}clear(){super.clear()}dispose(){this.__infoList.forEach((e=>{e&&e.molsurf&&e.molsurf.dispose()})),this.__infoList.length=0,super.dispose()}}ll.add("surface",Jy);class ex extends Bv{constructor(e,t,i){super(e,t,i),this.type="point",this.parameters=Object.assign({pointSize:{type:"number",precision:1,max:100,min:0,buffer:!0},sizeAttenuation:{type:"boolean",buffer:!0},sortParticles:{type:"boolean",rebuild:!0},useTexture:{type:"boolean",buffer:!0},alphaTest:{type:"range",step:.001,max:1,min:0,buffer:!0},forceTransparent:{type:"boolean",buffer:!0},edgeBleach:{type:"range",step:.001,max:1,min:0,buffer:!0}},this.parameters,{flatShaded:null,wireframe:null,linewidth:null,side:null,roughness:null,metalness:null}),this.init(i)}init(e){var t=e||{};this.pointSize=Ia(t.pointSize,1),this.sizeAttenuation=Ia(t.sizeAttenuation,!0),this.sortParticles=Ia(t.sortParticles,!1),this.useTexture=Ia(t.useTexture,!1),this.alphaTest=Ia(t.alphaTest,.5),this.forceTransparent=Ia(t.forceTransparent,!1),this.edgeBleach=Ia(t.edgeBleach,0),super.init(t)}createData(e){var t=e.getAtomData(this.getAtomParams({position:!0,color:!0,picking:!0}));return{bufferList:[new sg(t,this.getBufferParams({pointSize:this.pointSize,sizeAttenuation:this.sizeAttenuation,sortParticles:this.sortParticles,useTexture:this.useTexture,alphaTest:this.alphaTest,forceTransparent:this.forceTransparent,edgeBleach:this.edgeBleach}))]}}updateData(e,t){var i=t.sview.getAtomData(this.getAtomParams(e)),n={};e&&!e.position||Object.assign(n,{position:i.position}),e&&!e.color||Object.assign(n,{color:i.color}),t.bufferList[0].setAttributes(n)}getAtomRadius(){return.1}}ll.add("point",ex),ul.add("shader/Ribbon.vert","#define STANDARD\nuniform float clipNear;\nuniform vec3 clipCenter;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvarying vec3 vViewPosition;\n#endif\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\nattribute vec3 dir;\nattribute float size;\n#ifdef PICKING\n#include unpack_color\nattribute float primitiveId;\nvarying vec3 vPickingColor;\n#else\n#include color_pars_vertex\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\n#endif\n#include common\nvoid main(void){\n#ifdef PICKING\nvPickingColor = unpackColor( primitiveId );\n#else\n#include color_vertex\n#include beginnormal_vertex\n#include defaultnormal_vertex\n#ifndef FLAT_SHADED\nvNormal = normalize( transformedNormal );\n#endif\n#endif\n#include begin_vertex\ntransformed += normalize( dir ) * size;\n#include project_vertex\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvViewPosition = -mvPosition.xyz;\n#endif\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n#include nearclip_vertex\n}");const tx=new Uint16Array([0,1,2,1,3,2]);function ix(e){return 3*(4*(e.position.length/3-1))}class nx extends nm{constructor(e,t={}){super({position:new Float32Array(ix(e)),color:new Float32Array(ix(e)),index:Ga(ix(e),ix(e)/3),normal:new Float32Array(ix(e)),picking:e.picking},t),this.vertexShader="Ribbon.vert";const i=e.position.length/3-1,n=4*i,r=3*n;this.addAttributes({dir:{type:"v3",value:new Float32Array(r)}}),this.addAttributes({size:{type:"f",value:new Float32Array(n)}}),e.primitiveId=Hl(i),this.setAttributes(e),this.makeIndex()}setAttributes(e={}){const t=this.size/4,i=this.geometry.attributes;let n,r,s,o,a,c,l,h,u,d,f,m,p,g,v,y,x,b,_;e.position&&(n=e.position,l=i.position.array,i.position.needsUpdate=!0),e.normal&&(r=e.normal,h=i.normal.array,i.normal.needsUpdate=!0),e.size&&(s=e.size,u=i.size.array,i.size.needsUpdate=!0),e.dir&&(o=e.dir,d=i.dir.array,i.dir.needsUpdate=!0),e.color&&(a=e.color,f=i.color.array,i.color.needsUpdate=!0),e.primitiveId&&(c=e.primitiveId,m=i.primitiveId.array,i.primitiveId.needsUpdate=!0);let w=s?s[0]:null;for(p=0;p{if(!(e.residueCount<4)){i.push(e);var n=new yy(e,this.getSplineParams()),r=n.getSubdividedPosition(),s=n.getSubdividedOrientation(),o=n.getSubdividedColor(this.getColorParams()),a=n.getSubdividedPicking(),c=n.getSubdividedSize(this.getRadiusParams());t.push(new nx({position:r.position,normal:s.binormal,dir:s.normal,color:o.color,size:c.size,picking:a.picking},this.getBufferParams()))}}),e.getSelection()),{bufferList:t,polymerList:i}}updateData(e,t){e=e||{};var i=0,n=t.polymerList.length;for(i=0;i{if(e.residueCount<4||e.isNucleic())return;const r=new Um(e),s=r.getAxis(this.localAngle,this.centerDist,this.ssBorder,this.getColorParams(),this.getRadiusParams());t+=s.size.length,i.push(s),n.push(r)}),e.getSelection());const r={begin:new Float32Array(3*t),end:new Float32Array(3*t),size:new Float32Array(t),color:new Float32Array(3*t),picking:{}};let s=new Float32Array(t),o=0;i.forEach((function(e){r.begin.set(e.begin,3*o),r.end.set(e.end,3*o),r.size.set(e.size,o),r.color.set(e.color,3*o),s.set(e.picking.array,o),o+=e.size.length})),t&&(r.picking=new hf(s,e.getStructure()));return{bufferList:[new dy({position1:r.begin,position2:r.end,color:r.color,color2:r.color,radius:r.size,picking:r.picking},this.getBufferParams({openEnded:this.openEnded,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0}))],axisList:i,helixbundleList:n,axisData:r}}updateData(e,t){if((e=e||{}).position)this.build();else{var i={};if(e.color||e.radius){var n=0;t.helixbundleList.forEach((i=>{var r=i.getAxis(this.localAngle,this.centerDist,this.ssBorder,this.getColorParams(),this.getRadiusParams());e.color&&t.axisData.color.set(r.color,3*n),(e.radius||e.scale)&&t.axisData.size.set(r.size,n),n+=r.size.length})),e.color&&Object.assign(i,{color:t.axisData.color,color2:t.axisData.color}),(e.radius||e.scale)&&Object.assign(i,{radius:t.axisData.size})}t.bufferList[0].setAttributes(i)}}}ll.add("rocket",sx);class ox extends Sy{constructor(e,t,i){super(e,t,i),this.type="rope",this.parameters=Object.assign({smooth:{type:"integer",max:15,min:0,rebuild:!0}},this.parameters,{aspectRatio:null,smoothSheet:null})}init(e){var t=e||{};t.aspectRatio=1,t.tension=Ia(t.tension,.5),t.radiusScale=Ia(t.radiusScale,5),t.smoothSheet=!1,this.smooth=Ia(t.smooth,2),super.init(t)}getSpline(e){var t=new zm(e);return new yy(e,this.getSplineParams({directional:!1,positionIterator:t.getCenterIterator(this.smooth)}))}}ll.add("rope",ox);class ax extends Bv{constructor(e,t,i){super(e,t,i),this.type="spacefill",this.parameters=Object.assign({sphereDetail:!0,disableImpostor:!0},this.parameters),this.init(i)}init(e){var t=e||{};t.useInteriorColor=Ia(t.useInteriorColor,!0),super.init(t)}createData(e){return{bufferList:[new tg(e.getAtomData(this.getAtomParams()),this.getBufferParams({sphereDetail:this.sphereDetail,dullInterior:!0,disableImpostor:this.disableImpostor}))]}}updateData(e,t){var i=t.sview.getAtomData(this.getAtomParams(e)),n={};e&&!e.position||Object.assign(n,{position:i.position}),e&&!e.color||Object.assign(n,{color:i.color}),e&&!e.radius||Object.assign(n,{radius:i.radius}),t.bufferList[0].setAttributes(n)}}function cx(e){return 3*(e.position.length/3-1)*2}ll.add("spacefill",ax);class lx extends im{constructor(e,t={}){super({position:new Float32Array(cx(e)),color:new Float32Array(cx(e))},t),this.isLine=!0,this.vertexShader="Line.vert",this.fragmentShader="Line.frag",this.setAttributes(e)}setAttributes(e){let t,i,n,r;const s=this.geometry.attributes;if(e.position&&(t=e.position,n=s.position.array,s.position.needsUpdate=!0),e.color&&(i=e.color,r=s.color.array,s.color.needsUpdate=!0),!t&&!i)return void il.warn("TraceBuffer.prototype.setAttributes no data");let o,a;const c=this.size-1;for(let e=0;e{if(!(e.residueCount<4)){i.push(e);var n=new yy(e,this.getSplineParams()),r=n.getSubdividedPosition(),s=n.getSubdividedColor(this.getColorParams());t.push(new lx(Object.assign({},r,s),this.getBufferParams()))}}),e.getSelection()),{bufferList:t,polymerList:i}}updateData(e,t){e=e||{};var i=0,n=t.polymerList.length;for(i=0;i{e.boundingBox||e.computeBoundingBox(),this.boundingBox.union(e.boundingBox)}))}}const _x=Object.assign({aspectRatio:1.5,radialSegments:50,openEnded:!1,disableImpostor:!1},em);class wx{constructor(e,t={}){this.group=new ko,this.wireframeGroup=new ko,this.pickingGroup=new ko,this.visible=!0,this.parameters=Ea(t,this.defaultParameters),this.splitPosition=new Float32Array(e.position1.length),this.cylinderRadius=new Float32Array(e.radius.length);const i=this.makeAttributes(e),n={radialSegments:this.parameters.radialSegments,openEnded:this.parameters.openEnded,disableImpostor:this.parameters.disableImpostor};this.cylinderBuffer=new dy(i.cylinder,n),this.coneBuffer=new xx(i.cone,n),this.geometry=new bx([this.cylinderBuffer.geometry,this.coneBuffer.geometry]),this.matrix=Ia(t.matrix,new ri),this.picking=e.picking}get defaultParameters(){return _x}set matrix(e){im.prototype.setMatrix.call(this,e)}get matrix(){return this.group.matrix.clone()}get pickable(){return!!this.picking}makeAttributes(e={}){const t=this.splitPosition,i=this.cylinderRadius,n=this.parameters.aspectRatio;let r,s;const o={},a={};if(e.radius){for(r=0,s=i.length;r(this._beforeParse(),this._parse(),this._afterParse(),this[this.__objName])))}_parse(){}_beforeParse(){}_afterParse(){e.Debug&&il.log(this[this.__objName])}}class Kx extends Zx{constructor(e,t){var i=t||{};super(e,i),this.firstModelOnly=Ia(i.firstModelOnly,!1),this.asTrajectory=Ia(i.asTrajectory,!1),this.cAlphaOnly=Ia(i.cAlphaOnly,!1),this.structure=new Fp(this.name,this.path),this.structureBuilder=new ep(this.structure)}get type(){return"structure"}get __objName(){return"structure"}}class Qx{constructor(e,t,i="",n,r=[]){this.structure=e,this.index=t,this.description=i,this.entityType=function(e){switch(e=e.toLowerCase()){case"polymer":return 1;case"non-polymer":return 2;case"macrolide":return 3;case"water":return 4;default:return 0}}(n||""),this.chainIndexList=r,r.forEach((function(i){e.chainStore.entityIndex[i]=t}))}get type(){return function(e){switch(e){case 1:return"polymer";case 2:return"non-polymer";case 3:return"macrolide";case 4:return"water";default:return}}(this.entityType)}getEntityType(){return this.entityType}isPolymer(){return 1===this.entityType}isNonPolymer(){return 2===this.entityType}isMacrolide(){return 3===this.entityType}isWater(){return 4===this.entityType}eachChain(e){const t=this.structure.getChainProxy();this.chainIndexList.forEach((function(i){t.index=i,e(t)}))}}const Jx={a:1,b:1,c:1,alpha:90,beta:90,gamma:90,spacegroup:"P 1"};class eb{constructor(e=Jx){this.cartToFrac=new ri,this.fracToCart=new ri,this.a=e.a,this.b=e.b,this.c=e.c,this.alpha=e.alpha,this.beta=e.beta,this.gamma=e.gamma,this.spacegroup=e.spacegroup;const t=Ka(this.alpha),i=Ka(this.beta),n=Ka(this.gamma),r=Math.cos(t),s=Math.cos(i),o=Math.cos(n),a=Math.sin(i),c=Math.sin(n);if(this.volume=this.a*this.b*this.c*Math.sqrt(1-r*r-s*s-o*o+2*r*s*o),void 0===e.cartToFrac){const e=this.a*this.b*c/this.volume,t=(s*o-r)/(a*c);this.fracToCart.set(this.a,0,0,0,this.b*o,this.b*c,0,0,this.c*s,-this.c*a*t,1/e,0,0,0,0,1).transpose(),this.cartToFrac.getInverse(this.fracToCart)}else this.cartToFrac.copy(e.cartToFrac),this.fracToCart.getInverse(this.cartToFrac)}getPosition(e){const t=new Float32Array(24);if(e.unitcell){const i=e.unitcell,n=e.center.clone().applyMatrix4(i.cartToFrac).floor(),r=new Zt;let s=0;const o=function(e,o,a){r.set(e,o,a).add(n).applyMatrix4(i.fracToCart).toArray(t,s),s+=3};o(0,0,0),o(1,0,0),o(0,1,0),o(0,0,1),o(1,1,0),o(1,0,1),o(0,1,1),o(1,1,1)}return t}getCenter(e){return function(e,t=new Zt){const i=e.length;for(let n=0;n0)continue;let e,i,n,r,a,g=0;if(s){if(r=A.split(rb),g=10===r.length?1:0,L=r[2],m&&"CA"!==L)continue;e=parseFloat(r[6-g]),i=parseFloat(r[7-g]),n=parseFloat(r[8-g])}else{if(L=A.substr(12,4).trim(),m&&"CA"!==L)continue;e=parseFloat(A.substr(30,8)),i=parseFloat(A.substr(38,8)),n=parseFloat(A.substr(46,8))}if(f){const t=3*y;if(v[t+0]=e,v[t+1]=i,v[t+2]=n,y+=1,x)continue}s?(C=parseInt(r[1]),a="",R="H"===A[0],P=g?"":r[4],T=parseInt(r[5-g]),D="",I=r[3],O="",E=1):(C=parseInt(A.substr(6,5),h),l&&99999===C&&(h=16),R="H"===A[0],P=A[21].trim(),T=parseInt(A.substr(22,4),u),l&&9999===T&&(u=16),D=A[26].trim(),I=A.substr(17,4).trim()||"MOL",k=parseFloat(A.substr(60,6)),O=A[16].trim(),E=parseFloat(A.substr(54,6)),t||(o?(a=A.substr(76,3).trim(),a in Td&&(a=Td[a])):(a=A.substr(76,2).trim(),P||(P=A.substr(72,4).trim())),B=parseInt((A.substr(79,1)+A.substr(78,1)).trim()))),ue.growIfFull(),ue.atomTypeId[me]=he.add(L,a),ue.x[me]=e,ue.y[me]=i,ue.z[me]=n,ue.serial[me]=C,ue.altloc[me]=O.charCodeAt(0),ue.occupancy[me]=isNaN(E)?0:E,s?(ue.partialCharge[me]=parseFloat(r[9-g]),ue.radius[me]=parseFloat(r[10-g])):(ue.bfactor[me]=isNaN(k)?0:k,o&&(ue.partialCharge[me]=parseFloat(A.substr(70,6))),isFinite(B)&&(ue.formalCharge||ue.addField("formalCharge",1,"int8"),ue.formalCharge[me]=B));const b=sb(T,P,D);!R||Z[b]||ib.includes(I)?ee||te===P||(Q+=1,J=Q.toString()):te===P&&ne===I&&(wd.includes(I)||ie===T&&re===D)||(Q+=1,J=Q.toString(),ie=T,ne=I,re=D),c.addAtom(pe,P,J,I,T,R,void 0,D),V[C]=me,me+=1,ee=!1,te=P}else if("CONECT"===M){const e=V[parseInt(A.substr(6,5))],t=[11,16,21,26],i={};if(void 0===e)continue;for(let n=0;n<4;++n){let r=parseInt(A.substr(t[n],5));if(!Number.isNaN(r)&&(r=V[r],void 0!==r))if(e0)continue;const L=n[c].replace(lb,"");if(P&&"CA"!==L)continue;const R=parseFloat(n[y]),k=parseFloat(n[x]),O=parseFloat(n[b]);if(C){const e=3*i;if(t[e+0]=R,t[e+1]=k,t[e+2]=O,i+=1,q>0)continue}const B=n[l],N=parseInt(n[-1!==o?o:a]);let F=n[v];F="?"===F?"":F;const z=n[s],U=n[h],X="H"===n[f][0],Y=n[p],Z=parseFloat(n[_]),K=parseFloat(n[w]);let Q=n[d];if(Q="."===Q?"":Q,H.growIfFull(),H.atomTypeId[W]=V.add(L,Y),H.x[W]=R,H.y[W]=k,H.z[W]=O,H.serial[W]=parseInt(n[m]),H.bfactor[W]=isNaN(Z)?0:Z,H.occupancy[W]=isNaN(K)?0:K,H.altloc[W]=Q.charCodeAt(0),A.addAtom(q,z,U,B,N,X,void 0,F),e.Debug){const t=E[U];void 0!==t&&t!==z&&e.Debug&&il.warn(t,z)}E[U]=z;const J=n[u];D[J]||(D[J]=new Set),D[J].add(S.chainStore.count-1),W+=1}else{const e=r.match(cb),t=e.length;F===N.length&&(F=0);for(let i=0;ih*h)return n.growIfFull(),n.atomTypeId[u]=n.atomTypeId[e],n.x[u]=c.x,n.y[u]=c.y,n.z[u]=c.z,n.occupancy[u]=n.occupancy[e],n.serial[u]=u,n.altloc[u]="A".charCodeAt(0),i.addAtom(0,"","","HET",1,!0),void(u+=1)}}}))}}(I,S,A),A.finalize(),S.finalizeAtoms(),op(S),S.finalizeBonds();else{var X=function(e,t,i){var n,r,s,o,a=[],c=[],l=e.struct_conf;if(null==l?void 0:l.pdbx_PDB_helix_class)for(db(l,"id"),n=0,r=l.beg_auth_seq_id.length;n0){s=s.split("(");var c=a(s[0]),l=a(s[1]);Object.keys(c).forEach((function(e){Object.keys(l).forEach((function(t){var i=new ri;i.multiplyMatrices(c[e],l[t]),n[e+"x"+t]=i}))}))}else n=a(s);var h=[];for(var u in n)h.push(n[u]);var d=e;/^(0|[1-9][0-9]*)$/.test(d)&&(d="BU"+d);for(var f=o.asym_id_list[t].split(","),m=0,p=f.length;mS){var A=w;w=S,S=A;var M=p;p=b,b=M}if(0!==w&&0!==S)for(var C=0;Cx)continue}d=P.substr(5,5).trim(),f=parseInt(P.substr(0,5)),m=parseInt(P.substr(15,5)),_.growIfFull(),_.atomTypeId[w]=b.add(u),_.x[w]=E,_.y[w]=D,_.z[w]=L,_.serial[w]=m,r.addAtom(S,"","",d,f,!1,"l"),w+=1}}}(0,e.length,e)})),r.finalize(),n.finalizeAtoms(),sp(n),op(n),n.finalizeBonds(),ip(n),e.Debug&&il.timeEnd("GroParser._parse "+this.name)}});var vb=["mmtfVersion","mmtfProducer","unitCell","spaceGroup","structureId","title","depositionDate","releaseDate","experimentalMethods","resolution","rFree","rWork","bioAssemblyList","ncsOperatorList","entityList","groupList","numBonds","numAtoms","numGroups","numChains","numModels","groupsPerChain","chainsPerModel"].concat(["xCoordList","yCoordList","zCoordList","groupIdList","groupTypeList","chainIdList","bFactorList","atomIdList","altLocList","occupancyList","secStructList","insCodeList","sequenceIndexList","chainNameList","bondAtomList","bondOrderList"]);function yb(e,t,i){return t?new e(t.buffer,t.byteOffset,t.byteLength/(i||1)):void 0}function xb(e){return yb(DataView,e)}function bb(e){return yb(Int8Array,e)}function _b(e){return yb(Int32Array,e,4)}function wb(e,t){var i=e.length/2;t||(t=new Int16Array(i));for(var n=0,r=0;ns&&++a;t=new Int32Array(a)}for(i=0,n=0;ir){for(var s=[],o=0;o0&&(o.biomolDict[e]=t)}const k=a.unitCell;k&&Array.isArray(k)&&k[0]?o.unitcell=new eb({a:k[0],b:k[1],c:k[2],alpha:k[3],beta:k[4],gamma:k[5],spacegroup:a.spaceGroup}):o.unitcell=void 0,hp(o,!0),lp(o,!0),o.finalizeAtoms(),o.finalizeBonds(),up(o),e.Debug&&il.timeEnd("MmtfParser._parse "+this.name)}});const kb=/\s+/,Ob={1:1,2:2,3:3,am:1,ar:1,du:1,un:1,nc:0};hl.add("mol2",class extends Kx{get type(){return"mol2"}_parse(){e.Debug&&il.time("Mol2Parser._parse "+this.name);const t=this.structure,i=this.structureBuilder,n=this.firstModelOnly,r=this.asTrajectory,s=t.frames;let o,a,c=!1;const l=t.atomMap,h=t.atomStore;h.resize(Math.round(this.streamer.data.length/60)),h.addField("partialCharge",1,"float32");let u=0,d=0,f=0,m=-1,p=0,g=0;const v=t.getAtomProxy(),y=t.getAtomProxy();this.streamer.eachChunkOfLines((function(e){!function(e,x,b){for(let _=e;_MOLECULE"===e?(g=1,d=0,++m):"@ATOM"===e?(g=2,f=h.count,r&&(a=0,o=new Float32Array(3*p),s.push(o),m>0&&(c=!0))):g="@BOND"===e?3:0;else if(1===g){if(0===d)t.title=e,t.id=e;else if(1===d){const t=e.split(kb);p=parseInt(t[0])}++d}else if(2===g){const t=e.split(kb);if(n&&m>0)continue;const s=parseFloat(t[2]),d=parseFloat(t[3]),f=parseFloat(t[4]);if(r){const e=3*a;if(o[e+0]=s,o[e+1]=d,o[e+2]=f,a+=1,c)continue}const p=t[0],g=t[1],v=t[5].split(".")[0],y=t[6]?parseInt(t[6]):1,x=t[7]?t[7]:"",b=t[8]?parseFloat(t[8]):0;h.growIfFull(),h.atomTypeId[u]=l.add(g,v),h.x[u]=s,h.y[u]=d,h.z[u]=f,h.serial[u]=p,h.partialCharge[u]=b,i.addAtom(m,"","",x,y,!0),u+=1}else if(3===g){if(n&&m>0)continue;if(r&&m>0)continue;const i=e.split(kb);v.index=parseInt(i[1])-1+f,y.index=parseInt(i[2])-1+f;const s=Ob[i[3]];t.bondStore.addBond(v,y,s)}}}(0,e.length,e)})),i.finalize(),t.finalizeAtoms(),sp(t),lp(t,!0),hp(t,!0),t.finalizeBonds(),pp(t),ip(t),e.Debug&&il.timeEnd("Mol2Parser._parse "+this.name)}});hl.add("pdbqt",class extends ob{get type(){return"pdbqt"}});hl.add("pqr",class extends ob{get type(){return"pqr"}});const Bb=/> +<(.+)>/;class Nb extends Kx{get type(){return"sdf"}_parse(){e.Debug&&il.time("SdfParser._parse "+this.name);const t=this.structure,i=this.structureBuilder,n=this.firstModelOnly,r=this.asTrajectory,s=this.streamer.peekLines(2);t.id=s[0].trim(),t.title=s[1].trim();const o=t.frames;let a,c,l=!1;const h=t.atomMap,u=t.atomStore;u.resize(Math.round(this.streamer.data.length/50)),u.addField("formalCharge",1,"int8");const d=t.getAtomProxy(),f=t.getAtomProxy();let m=0,p=0,g=0,v=0;const y=[];let x,b,_,w,S,A,M,C,P,T,I,E,D,L,R=!1,k={};t.extraData.sdf=y;let O=!1,B=!1,N=!1,F=[],z=[];const U=new Map;this.streamer.eachChunkOfLines((function(e){!function(e,s,$){for(let G=e;G-1,O?U.clear():(b=parseInt(e.substr(0,3)),_=parseInt(e.substr(3,3)),w=4,S=w+b,A=S,M=A+_,r&&(c=0,a=new Float32Array(3*b),o.push(a),g>0&&(l=!0)));else if(O&&"COUNTS"===F[0])b=parseInt(F[1]),r&&(c=0,a=new Float32Array(3*b),o.push(a),g>0&&(l=!0));else if(O&&2==F.length)"ATOM"===F[1]?"BEGIN"===F[0]?B=!0:"END"===F[0]&&(B=!1):"BOND"===F[1]&&("BEGIN"===F[0]?N=!0:"END"===F[0]&&(N=!1));else if(B||!O&&p>=w&&p0)continue;let t=0;if(O){if(C=parseFloat(F[2]),P=parseFloat(F[3]),T=parseFloat(F[4]),E=F[1],D=parseInt(F[0]),U.set(D,m),I=E+D,F.length>6){let e=F.slice(6).find((e=>0===e.indexOf("CHG=")));e&&(t=parseInt(e.substring(4)))}}else C=parseFloat(e.substr(0,10)),P=parseFloat(e.substr(10,10)),T=parseFloat(e.substr(20,10)),E=e.substr(31,3).trim(),I=E+(m-v+1);if(r){const e=3*c;if(a[e+0]=C,a[e+1]=P,a[e+2]=T,c+=1,l)continue}u.growIfFull(),u.atomTypeId[m]=h.add(I,E),u.x[m]=C,u.y[m]=P,u.z[m]=T,u.serial[m]=O?D:m,u.formalCharge[m]=t,i.addAtom(g,"","","HET",1,!0),m+=1}else if(N||!O&&p>=A&&p0)continue;if(r&&g>0)continue;O?(d.index=U.get(parseInt(F[2])),f.index=U.get(parseInt(F[3])),L=parseInt(F[1])):(d.index=parseInt(e.substr(0,3))-1+v,f.index=parseInt(e.substr(3,3))-1+v,L=parseInt(e.substr(6,3))),t.bondStore.addBond(d,f,L)}else if("M CHG"===e.substr(0,6)){const t=parseInt(e.substr(6,3));for(let i=0,n=10;i"===e.charAt(0)&&(x=e.match(Bb))?(R=x[1],k[R]=[]):!1!==R&&e&&k[R].push(e);++p}}}(0,e.length,e)})),i.finalize(),t.finalizeAtoms(),t.finalizeBonds(),pp(t),e.Debug&&il.timeEnd("SdfParser._parse "+this.name)}_postProcess(){pp(this.structure)}}hl.add("sdf",Nb),hl.add("sd",Nb),hl.add("mol",Nb);function Fb(e,t,i){return parseInt(e.substr(t,i).trim())}class zb extends Kx{get type(){return"prmtop"}_parse(){e.Debug&&il.time("PrmtopParser._parse "+this.name);const t=this.structure,i=this.structureBuilder,n=t.atomMap,r=t.atomStore;r.addField("partialCharge",1,"float32"),r.addField("radius",1,"float32");const s=[],o={},a=["NATOM","NTYPES","NBONH","MBONA","NTHETH","MTHETA","NPHIH","MPHIA","NHPARM","NPARM","NNB","NRES","NBONA","NTHETA","NPHIA","NUMBND","NUMANG","NPTRA","NATYP","NPHB","IFPERT","NBPER","NGPER","NDPER","MBPER","MGPER","MDPER","IFBOX","NMXRS","IFCAP","NUMEXTRA","NCOPY"];let c,l,h,u,d;a.forEach((e=>{o[e]=0}));let f,m,p,g,v,y=new Uint8Array(0);this.streamer.eachChunkOfLines((function(e){!function(e,t,i){for(let n=e;n0)return void il.error("dcd format with fixed atoms unsupported, aborting");const p=o.NATOM,g=4*p;for(let e=0,n=o.NSET;e=1&&(n.timeOffset=(o.ISTART-1)*n.deltaTime),e.Debug&&il.timeEnd("DcdParser._parse "+this.name)}});const Xb={BYTE:1,CHAR:2,SHORT:3,INT:4,FLOAT:5,DOUBLE:6};function Yb(e){switch(Number(e)){case Xb.BYTE:return"byte";case Xb.CHAR:return"char";case Xb.SHORT:return"short";case Xb.INT:return"int";case Xb.FLOAT:return"float";case Xb.DOUBLE:return"double";default:return"undefined"}}function Zb(e){switch(Number(e)){case Xb.BYTE:case Xb.CHAR:return 1;case Xb.SHORT:return 2;case Xb.INT:case Xb.FLOAT:return 4;case Xb.DOUBLE:return 8;default:return-1}}function Kb(e){switch(String(e)){case"byte":return Xb.BYTE;case"char":return Xb.CHAR;case"short":return Xb.SHORT;case"int":return Xb.INT;case"float":return Xb.FLOAT;case"double":return Xb.DOUBLE;default:return-1}}function Qb(e,t){if(1!==e){const i=new Array(e);for(let n=0;n6,"non valid type "+h);const u=e.readUint32();let d=e.readUint32();2===i&&(jb(d>0,"offsets larger than 4GB not supported"),d=e.readUint32()),c[0]===t&&(s+=u),r[n]={name:o,dimensions:c,attributes:l,type:Yb(h),size:u,offset:d,record:c[0]===t}}}return{variables:r,recordStep:s}}(e,n.recordId,t);return i.variables=r.variables,i.recordDimension.recordStep=r.recordStep,i}function s_(e){let t;const i=e.readUint32();if(i===e_)return jb(e.readUint32()!==e_,"wrong empty tag for list of attributes"),[];{jb(i!==n_,"wrong tag for list of attributes");const n=e.readUint32();t=new Array(n);for(let i=0;i6,"non valid type "+r);const s=e.readUint32(),o=Jb(e,r,s);Wb(e),t[i]={name:n,type:Yb(r),value:o}}}return t}class o_{constructor(e){const t=new Il(e);t.setBigEndian(),jb("CDF"!==t.readChars(3),"should start with CDF");const i=t.readByte();jb(i>2,"unknown version"),this.header=r_(t,i),this.buffer=t}get version(){return 1===this.header.version?"classic format":"64-bit offset format"}get recordDimension(){return this.header.recordDimension}get dimensions(){return this.header.dimensions}get globalAttributes(){return this.header.globalAttributes}get variables(){return this.header.variables}hasDataVariable(e){return-1!==this.header.variables.findIndex((function(t){return t.name===e}))}getDataVariable(e){let t;return t="string"==typeof e?this.header.variables.find((function(t){return t.name===e})):e,jb(void 0===t,"variable not found"),this.buffer.seek(t.offset),t.record?function(e,t,i){const n=Kb(t.type),r=t.size?t.size/Zb(n):1,s=i.length,o=new Array(s),a=i.recordStep;for(let t=0;t=1&&(i.timeOffset=s[0]),s.length>=2&&(i.deltaTime=s[1]-s[0]),e.Debug&&il.timeEnd("NctrajParser._parse "+this.name)}}hl.add("nctraj",a_),hl.add("ncdf",a_),hl.add("nc",a_);hl.add("trr",class extends Hb{get type(){return"trr"}get isBinary(){return!0}_parse(){e.Debug&&il.time("TrrParser._parse "+this.name);const t=Va(this.streamer.data),i=new DataView(t),n=this.frames,r=n.coordinates,s=n.boxes,o=n.times;let a=0;for(;;){a+=8;const e=i.getInt32(a);a+=4,a+=e;const n=i.getInt32(a+8),c=i.getInt32(a+12),l=i.getInt32(a+16),h=i.getInt32(a+28),u=i.getInt32(a+32),d=i.getInt32(a+36),f=i.getInt32(a+40);a+=52;const m=n/9,p=3*f;if(8===m?o.push(i.getFloat64(a)):o.push(i.getFloat32(a)),a+=2*m,n){const e=new Float32Array(9);if(8===m)for(let t=0;t<9;++t)e[t]=10*i.getFloat64(a),a+=8;else for(let t=0;t<9;++t)e[t]=10*i.getFloat32(a),a+=4;s.push(e)}if(a+=c,a+=l,h){let e;if(8===m){e=new Float32Array(p);for(let t=0;t>8&65280|t>>24&255}e=new Float32Array(t,a,p);for(let t=0;t=t.byteLength)break}o.length>=1&&(n.timeOffset=o[0]),o.length>=2&&(n.deltaTime=o[1]-o[0]),e.Debug&&il.timeEnd("TrrParser._parse "+this.name)}});const c_=new Uint32Array([0,0,0,0,0,0,0,0,0,8,10,12,16,20,25,32,40,50,64,80,101,128,161,203,256,322,406,512,645,812,1024,1290,1625,2048,2580,3250,4096,5060,6501,8192,10321,13003,16384,20642,26007,32768,41285,52015,65536,82570,104031,131072,165140,208063,262144,330280,416127,524287,660561,832255,1048576,1321122,1664510,2097152,2642245,3329021,4194304,5284491,6658042,8388607,10568983,13316085,16777216]);function l_(e){let t=1,i=0;for(;e>=t&&i<32;)i++,t<<=1;return i}const h_=new Uint8Array(32);function u_(e,t){let i=1,n=0;h_[0]=1;for(let n=0;n>=8;for(;0!==r;)h_[e++]=255&r,r>>=8;i=e}let r=1;for(i--;h_[i]>=r;)n++,r*=2;return n+8*i}function d_(e,t,i,n){const r=(1<=8;)o=o<<8|t[a++],c|=o>>s<0&&(s>s&(1<8;)f_[a++]=d_(e,t,8,o),n-=8;n>0&&(f_[a++]=d_(e,t,n,o));for(let e=i-1;e>0;e--){let t=0;for(let i=a-1;i>=0;i--){t=t<<8|f_[i];const n=t/r[e]|0;f_[i]=n,t-=n*r[e]}s[e]=t}s[0]=f_[0]|f_[1]<<8|f_[2]<<16|f_[3]<<24}hl.add("xtc",class extends Hb{get type(){return"xtc"}get isBinary(){return!0}_parse(){e.Debug&&il.time("XtcParser._parse "+this.name);const t=Va(this.streamer.data),i=new DataView(t),n=this.frames,r=n.coordinates,s=n.boxes,o=n.times,a=new Int32Array(6),c=new Int32Array(3),l=new Int32Array(3),h=new Uint32Array(3),u=new Float32Array(3),d=new Float32Array(3);let f=0;const m=new Int32Array(3),p=new Uint32Array(m.buffer);for(;;){let e;const n=i.getInt32(f+4);f+=12;const g=3*n;o.push(i.getFloat32(f)),f+=4;const v=new Float32Array(9);for(let e=0;e<9;++e)v[e]=10*i.getFloat32(f),f+=4;if(s.push(v),n<=9){e=new Float32Array(n);for(let t=0;t16777215?(l[0]=l_(c[0]),l[1]=l_(c[1]),l[2]=l_(c[2]),o=0):o=u_(3,c);let v=i.getInt32(f);f+=4;let y=v-1;y=9>y?9:y;let x=c_[y]/2|0,b=c_[v]/2|0;h[0]=h[1]=h[2]=c_[v];let _=4*Math.ceil(i.getInt32(f)/4);f+=4;const w=1/s;let S=0,A=0;const M=new Uint8Array(t,f);for(u[0]=u[1]=u[2]=0;A0){u[0]=u[1]=u[2]=0;for(let t=0;t9?c_[v-1]/2|0:0):t>0&&(x=b,b=c_[v]/2|0),h[0]=h[1]=h[2]=c_[v],0===h[0]||0===h[1]||0===h[2])return void console.error("(xdrfile error) Undefined error.")}f+=_}for(let t=0;t=t.byteLength)break}o.length>=1&&(n.timeOffset=o[0]),o.length>=2&&(n.deltaTime=o[1]-o[0]),e.Debug&&il.timeEnd("XtcParser._parse "+this.name)}});class p_ extends Zx{constructor(e,t){const i=t||{};super(e,i),this.volume=new Zf(this.name,this.path),this.voxelSize=Ia(i.voxelSize,1)}get type(){return"volume"}get __objName(){return"volume"}_afterParse(){this.volume.setMatrix(this.getMatrix()),super._afterParse()}getMatrix(){return new ri}}const g_=/\s+/,v_=/-?\d+(?:\.\d*)?(?:[eE][+-]?\d+)?/g,y_=.529177210859;class x_ extends p_{get type(){return"cube"}_parse(){e.Debug&&il.time("CubeParser._parse "+this.name);const t=this.volume,i=this.streamer.peekLines(6),n={},r=y_*this.voxelSize;function s(e,t){var n=i[e].trim().split(g_)[t];return parseFloat(n)}n.atomCount=Math.abs(s(2,0)),n.originX=s(2,1)*y_,n.originY=s(2,2)*y_,n.originZ=s(2,3)*y_,n.NVX=s(3,0),n.NVY=s(4,0),n.NVZ=s(5,0),n.basisX=new Zt(s(3,1),s(3,2),s(3,3)).multiplyScalar(r),n.basisY=new Zt(s(4,1),s(4,2),s(4,3)).multiplyScalar(r),n.basisZ=new Zt(s(5,1),s(5,2),s(5,3)).multiplyScalar(r);const o=new Float32Array(n.NVX*n.NVY*n.NVZ);let a=0,c=0;const l=s(2,0)>0?0:1;this.streamer.eachChunkOfLines((function(e){!function(e,t,i){for(let r=e;r=n.atomCount+6+l){const t=e.match(v_);for(let e=0,i=t.length;e>8&255}i.xStart=o[0],i.yStart=o[1],i.zStart=o[2],i.xExtent=o[3],i.yExtent=o[4],i.zExtent=o[5],i.xRate=o[6],i.yRate=o[7],i.zRate=o[8];const e=1/o[17],t=e*this.voxelSize;i.xlen=o[9]*t,i.ylen=o[10]*t,i.zlen=o[11]*t,i.alpha=o[12]*e,i.beta=o[13]*e,i.gamma=o[14]*e,n=o[15]/100,r=o[16],i.gamma=o[14]*e}t.header=i,e.Debug&&il.log(i,n,r);const l=new Float32Array(i.xExtent*i.yExtent*i.zExtent);let h=512;const u=Math.ceil(i.xExtent/8),d=Math.ceil(i.yExtent/8),f=Math.ceil(i.zExtent/8);for(var m=0;ms){const e=i[n].trim();if(""!==e){const t=e.split(__);for(let e=0,i=t.length;e=s&&(p-s)%f!=0&&m=0?i-1:i+t/3)},parseNormalIndex:function(e,t){var i=parseInt(e,10);return 3*(i>=0?i-1:i+t/3)},addVertex:function(e,t,i){var n=this.vertices,r=this.object.geometry.vertices;r.push(n[e+0]),r.push(n[e+1]),r.push(n[e+2]),r.push(n[t+0]),r.push(n[t+1]),r.push(n[t+2]),r.push(n[i+0]),r.push(n[i+1]),r.push(n[i+2])},addVertexLine:function(e){var t=this.vertices,i=this.object.geometry.vertices;i.push(t[e+0]),i.push(t[e+1]),i.push(t[e+2])},addNormal:function(e,t,i){var n=this.normals,r=this.object.geometry.normals;r.push(n[e+0]),r.push(n[e+1]),r.push(n[e+2]),r.push(n[t+0]),r.push(n[t+1]),r.push(n[t+2]),r.push(n[i+0]),r.push(n[i+1]),r.push(n[i+2])},addFace:function(e,t,i,n,r,s,o,a){var c,l=this.vertices.length,h=this.parseVertexIndex(e,l),u=this.parseVertexIndex(t,l),d=this.parseVertexIndex(i,l);if(void 0===n?this.addVertex(h,u,d):(c=this.parseVertexIndex(n,l),this.addVertex(h,u,c),this.addVertex(u,d,c)),void 0!==r){var f=this.normals.length;h=this.parseNormalIndex(r,f),u=r===s?h:this.parseNormalIndex(s,f),d=r===o?h:this.parseNormalIndex(o,f),void 0===n?this.addNormal(h,u,d):(c=this.parseNormalIndex(a,f),this.addNormal(h,u,c),this.addNormal(u,d,c))}},addLineGeometry:function(e){this.object.geometry.type="Line";for(var t=this.vertices.length,i=0,n=e.length;i0?x.setAttribute("normal",new An(new Float32Array(y.normals),3)):x.computeVertexNormals(),v.push(x)}}return v}};hl.add("obj",class extends z_{get type(){return"obj"}getLoader(){return new U_}});const $_=function(){this.propertyNameMapping={}};$_.prototype={constructor:$_,setPropertyNameMapping:function(e){this.propertyNameMapping=e},bin2str:function(e){for(var t=new Uint8Array(e),i="",n=0;n=n.elements[o].count&&(o++,a=0);var h=this.parseASCIIElement(n.elements[o].properties,l);this.handleElement(i,n.elements[o].name,h),a++}}return this.postProcess(i)},postProcess:function(e){if(e.useColor){for(var t=0;t{const r=n.length;for(let s=0;s/g,""),{declaration:t(),root:i()};function t(){if(!r(/^<\?xml\s*/))return;const e={attributes:{}};for(;!s()&&!o("?>");){const t=n();if(!t)return e;e.attributes[t.name]=t.value}return r(/\?>\s*/),e}function i(){const e=r(H_);if(!e)return;const t={name:e[1],attributes:{},children:[]};for(;!(s()||o(">")||o("?>")||o("/>"));){const e=n();if(!e)return t;t.attributes[e.name]=e.value}if(r(/^\s*\/>\s*/))return t;let a;for(r(/\??>\s*/),t.content=function(){const e=r(j_);return e?e[1]:""}();a=i();)t.children.push(a);return r(/^<\/[\w-:.]+>\s*/),t}function n(){const e=r(W_);var t;if(e)return{name:e[1],value:(t=e[2],t.replace(V_,""))}}function r(t){const i=e.match(t);if(i)return e=e.slice(i[0].length),i}function s(){return 0===e.length}function o(t){return 0===e.indexOf(t)}}class X_ extends Zx{constructor(e,t){const i=t||{};super(e,i),this.useDomParser=Ia(i.useDomParser,!1),this.xml={name:this.name,path:this.path,data:{}}}get type(){return"xml"}get __objName(){return"xml"}get isXml(){return!0}__xmlParser(e){return q_(e)}__domParser(e){return(new window.DOMParser).parseFromString(e,"text/xml")}_parse(){e.Debug&&il.time("XmlParser._parse "+this.name),this.useDomParser?this.streamer.data instanceof Document?this.xml.data=this.streamer.data:this.xml.data=this.__domParser(this.streamer.asText()):this.xml.data=this.__xmlParser(this.streamer.asText()),e.Debug&&il.timeEnd("XmlParser._parse "+this.name)}}function Y_(e,t){const i=e.getNamedItem(t);return null!==i?i.value:""}function Z_(e,t,i=!1){const n=Y_(e,"icode").trim(),r=Y_(e,"chain").trim(),s=Y_(e,"altcode");let o=Y_(e,"resnum");return n&&(o+="^"+n),r&&(o+=":"+r),t&&(o+="."+t),i&&s.trim()&&(o+="%"+s),o+="/"+(parseInt(Y_(e,"model"))-1),o}function K_(e){const t=Y_(e,"chain").trim();let i=`[${Y_(e,"rescode")}]${Y_(e,"resnum")}`;return t&&(i+=`:${t}`),i}function Q_(e,t,i){void 0===e[t]?e[t]=i:e[t]|=i}function J_(e,t){return null!==e&&e.value===t}function ew(e,t,i){let n=0;const r=t.getElementsByTagName("clash");for(let t=0,i=r.length;t0&&(n+=1);t.getElementsByTagName("bond-outlier").length>0&&(n+=1);return t.getElementsByTagName("plane-outlier").length>0&&(n+=1),J_(i.getNamedItem("rota"),"OUTLIER")&&(n+=1),J_(i.getNamedItem("rama"),"OUTLIER")&&(n+=1),J_(i.getNamedItem("RNApucker"),"outlier")&&(n+=1),n}hl.add("xml",X_);class tw{constructor(e,t){this.name=e,this.path=t,this.rsrzDict={},this.rsccDict={},this.rciDict={},this.clashDict={},this.clashArray=[],this.geoDict={},this.geoAtomDict={},this.atomDict={},this.clashSele="NONE"}get type(){return"validation"}fromXml(t){e.Debug&&il.time("Validation.fromXml");const i=this.rsrzDict,n=this.rsccDict,r=this.rciDict,s=this.clashDict,o=this.clashArray,a=this.geoDict,c=this.geoAtomDict,l=this.atomDict,h=t.getElementsByTagName("Entry");if(1===h.length){const e=h[0].getElementsByTagName("chemical_shift_list");if(1===e.length){const t=e[0].getElementsByTagName("random_coil_index");for(let e=0,i=t.length;e0&&(a[n]=e)}else{const e=t.getElementsByTagName("clash"),i=t.getElementsByTagName("mog-bond-outlier"),r=t.getElementsByTagName("mog-angle-outlier");if(i.length>0||r.length>0||e.length>0){const t={};c[n]=t;for(let i=0,n=e.length;i>>16&65535|0,o=0;0!==i;){i-=o=i>2e3?2e3:i;do{s=s+(r=r+t[n++]|0)|0}while(--o);r%=65521,s%=65521}return r|s<<16|0}hl.add("validation",class extends X_{constructor(e,t){super(e,t||{}),this.useDomParser=!0,this.validation=new tw(this.name,this.path)}get __objName(){return"validation"}get isXml(){return!0}_parse(){super._parse(),e.Debug&&il.time("ValidationParser._parse "+this.name),this.validation.fromXml(this.xml.data),e.Debug&&il.timeEnd("ValidationParser._parse "+this.name)}});var sw=function(){for(var e,t=[],i=0;i<256;i++){e=i;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[i]=e}return t}();function ow(e,t,i,n){var r=sw,s=n+i;e^=-1;for(var o=n;o>>8^r[255&(e^t[o])];return-1^e}var aw=30,cw=12;function lw(e,t){var i,n,r,s,o,a,c,l,h,u,d,f,m,p,g,v,y,x,b,_,w,S,A,M,C;i=e.state,n=e.next_in,M=e.input,r=n+(e.avail_in-5),s=e.next_out,C=e.output,o=s-(t-e.avail_out),a=s+(e.avail_out-257),c=i.dmax,l=i.wsize,h=i.whave,u=i.wnext,d=i.window,f=i.hold,m=i.bits,p=i.lencode,g=i.distcode,v=(1<>>=b=x>>>24,m-=b,0===(b=x>>>16&255))C[s++]=65535&x;else{if(!(16&b)){if(0==(64&b)){x=p[(65535&x)+(f&(1<>>=b,m-=b),m<15&&(f+=M[n++]<>>=b=x>>>24,m-=b,!(16&(b=x>>>16&255))){if(0==(64&b)){x=g[(65535&x)+(f&(1<c){e.msg="invalid distance too far back",i.mode=aw;break e}if(f>>>=b,m-=b,w>(b=s-o)){if((b=w-b)>h&&i.sane){e.msg="invalid distance too far back",i.mode=aw;break e}if(S=0,A=d,0===u){if(S+=l-b,b<_){_-=b;do{C[s++]=d[S++]}while(--b);S=s-w,A=C}}else if(u2;)C[s++]=A[S++],C[s++]=A[S++],C[s++]=A[S++],_-=3;_&&(C[s++]=A[S++],_>1&&(C[s++]=A[S++]))}else{S=s-w;do{C[s++]=C[S++],C[s++]=C[S++],C[s++]=C[S++],_-=3}while(_>2);_&&(C[s++]=C[S++],_>1&&(C[s++]=C[S++]))}break}}break}}while(n>3,f&=(1<<(m-=_<<3))-1,e.next_in=n,e.next_out=s,e.avail_in=n=1&&0===E[_];_--);if(w>_&&(w=_),0===_)return r[s++]=20971520,r[s++]=20971520,a.bits=1,0;for(b=1;b<_&&0===E[b];b++);for(w0&&(e===fw||1!==_))return-1;for(D[1]=0,y=1;yuw||e===pw&&C>dw)return 1;for(;;){m=y-A,o[x]f?(p=L[R+o[x]],g=T[I+o[x]]):(p=96,g=0),c=1<>A)+(l-=c)]=m<<24|p<<16|g|0}while(0!==l);for(c=1<>=1;if(0!==c?(P&=c-1,P+=c):P=0,x++,0==--E[y]){if(y===_)break;y=t[i+o[x]]}if(y>w&&(P&u)!==h){for(0===A&&(A=w),d+=b,M=1<<(S=y-A);S+A<_&&!((M-=E[S+A])<=0);)S++,M<<=1;if(C+=1<uw||e===pw&&C>dw)return 1;r[h=P&u]=w<<24|S<<16|d-s|0}}return 0!==P&&(r[d+P]=y-A<<24|64<<16|0),a.bits=w,0}var _w=1,ww=2,Sw=0,Aw=-2,Mw=1,Cw=12,Pw=30,Tw=852,Iw=592;function Ew(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function Dw(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function Lw(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,function(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=Mw,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(Tw),t.distcode=t.distdyn=new Int32Array(Iw),t.sane=1,t.back=-1,Sw):Aw}(e)):Aw}function Rw(e,t){var i,n;return e?(n=new Dw,e.state=n,n.window=null,i=function(e,t){var i,n;return e&&e.state?(n=e.state,t<0?(i=0,t=-t):(i=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?Aw:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=i,n.wbits=t,Lw(e))):Aw}(e,t),i!==Sw&&(e.state=null),i):Aw}var kw,Ow,Bw=!0;function Nw(e){if(Bw){var t;for(kw=new Int32Array(512),Ow=new Int32Array(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(bw(_w,e.lens,0,288,kw,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;bw(ww,e.lens,0,32,Ow,0,e.work,{bits:5}),Bw=!1}e.lencode=kw,e.lenbits=9,e.distcode=Ow,e.distbits=5}function Fw(e,t,i,n){var r,s=e.state;return null===s.window&&(s.wsize=1<=s.wsize?(nw(s.window,t,i-s.wsize,s.wsize,0),s.wnext=0,s.whave=s.wsize):((r=s.wsize-s.wnext)>n&&(r=n),nw(s.window,t,i-n,r,s.wnext),(n-=r)?(nw(s.window,t,i-n,n,0),s.wnext=n,s.whave=s.wsize):(s.wnext+=r,s.wnext===s.wsize&&(s.wnext=0),s.whave>>8&255,i.check=ow(i.check,P,2,0),l=0,h=0,i.mode=2;break}if(i.flags=0,i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&l)<<8)+(l>>8))%31){e.msg="incorrect header check",i.mode=Pw;break}if(8!=(15&l)){e.msg="unknown compression method",i.mode=Pw;break}if(h-=4,w=8+(15&(l>>>=4)),0===i.wbits)i.wbits=w;else if(w>i.wbits){e.msg="invalid window size",i.mode=Pw;break}i.dmax=1<>8&1),512&i.flags&&(P[0]=255&l,P[1]=l>>>8&255,i.check=ow(i.check,P,2,0)),l=0,h=0,i.mode=3;case 3:for(;h<32;){if(0===a)break e;a--,l+=n[s++]<>>8&255,P[2]=l>>>16&255,P[3]=l>>>24&255,i.check=ow(i.check,P,4,0)),l=0,h=0,i.mode=4;case 4:for(;h<16;){if(0===a)break e;a--,l+=n[s++]<>8),512&i.flags&&(P[0]=255&l,P[1]=l>>>8&255,i.check=ow(i.check,P,2,0)),l=0,h=0,i.mode=5;case 5:if(1024&i.flags){for(;h<16;){if(0===a)break e;a--,l+=n[s++]<>>8&255,i.check=ow(i.check,P,2,0)),l=0,h=0}else i.head&&(i.head.extra=null);i.mode=6;case 6:if(1024&i.flags&&((f=i.length)>a&&(f=a),f&&(i.head&&(w=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Array(i.head.extra_len)),nw(i.head.extra,n,s,f,w)),512&i.flags&&(i.check=ow(i.check,n,f,s)),a-=f,s+=f,i.length-=f),i.length))break e;i.length=0,i.mode=7;case 7:if(2048&i.flags){if(0===a)break e;f=0;do{w=n[s+f++],i.head&&w&&i.length<65536&&(i.head.name+=String.fromCharCode(w))}while(w&&f>9&1,i.head.done=!0),e.adler=i.check=0,i.mode=Cw;break;case 10:for(;h<32;){if(0===a)break e;a--,l+=n[s++]<>>=7&h,h-=7&h,i.mode=27;break}for(;h<3;){if(0===a)break e;a--,l+=n[s++]<>>=1)){case 0:i.mode=14;break;case 1:if(Nw(i),i.mode=20,6===t){l>>>=2,h-=2;break e}break;case 2:i.mode=17;break;case 3:e.msg="invalid block type",i.mode=Pw}l>>>=2,h-=2;break;case 14:for(l>>>=7&h,h-=7&h;h<32;){if(0===a)break e;a--,l+=n[s++]<>>16^65535)){e.msg="invalid stored block lengths",i.mode=Pw;break}if(i.length=65535&l,l=0,h=0,i.mode=15,6===t)break e;case 15:i.mode=16;case 16:if(f=i.length){if(f>a&&(f=a),f>c&&(f=c),0===f)break e;nw(r,n,s,f,o),a-=f,s+=f,c-=f,o+=f,i.length-=f;break}i.mode=Cw;break;case 17:for(;h<14;){if(0===a)break e;a--,l+=n[s++]<>>=5,h-=5,i.ndist=1+(31&l),l>>>=5,h-=5,i.ncode=4+(15&l),l>>>=4,h-=4,i.nlen>286||i.ndist>30){e.msg="too many length or distance symbols",i.mode=Pw;break}i.have=0,i.mode=18;case 18:for(;i.have>>=3,h-=3}for(;i.have<19;)i.lens[T[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,A={bits:i.lenbits},S=bw(0,i.lens,0,19,i.lencode,0,i.work,A),i.lenbits=A.bits,S){e.msg="invalid code lengths set",i.mode=Pw;break}i.have=0,i.mode=19;case 19:for(;i.have>>16&255,y=65535&C,!((g=C>>>24)<=h);){if(0===a)break e;a--,l+=n[s++]<>>=g,h-=g,i.lens[i.have++]=y;else{if(16===y){for(M=g+2;h>>=g,h-=g,0===i.have){e.msg="invalid bit length repeat",i.mode=Pw;break}w=i.lens[i.have-1],f=3+(3&l),l>>>=2,h-=2}else if(17===y){for(M=g+3;h>>=g)),l>>>=3,h-=3}else{for(M=g+7;h>>=g)),l>>>=7,h-=7}if(i.have+f>i.nlen+i.ndist){e.msg="invalid bit length repeat",i.mode=Pw;break}for(;f--;)i.lens[i.have++]=w}}if(i.mode===Pw)break;if(0===i.lens[256]){e.msg="invalid code -- missing end-of-block",i.mode=Pw;break}if(i.lenbits=9,A={bits:i.lenbits},S=bw(_w,i.lens,0,i.nlen,i.lencode,0,i.work,A),i.lenbits=A.bits,S){e.msg="invalid literal/lengths set",i.mode=Pw;break}if(i.distbits=6,i.distcode=i.distdyn,A={bits:i.distbits},S=bw(ww,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,A),i.distbits=A.bits,S){e.msg="invalid distances set",i.mode=Pw;break}if(i.mode=20,6===t)break e;case 20:i.mode=21;case 21:if(a>=6&&c>=258){e.next_out=o,e.avail_out=c,e.next_in=s,e.avail_in=a,i.hold=l,i.bits=h,lw(e,d),o=e.next_out,r=e.output,c=e.avail_out,s=e.next_in,n=e.input,a=e.avail_in,l=i.hold,h=i.bits,i.mode===Cw&&(i.back=-1);break}for(i.back=0;v=(C=i.lencode[l&(1<>>16&255,y=65535&C,!((g=C>>>24)<=h);){if(0===a)break e;a--,l+=n[s++]<>x)])>>>16&255,y=65535&C,!(x+(g=C>>>24)<=h);){if(0===a)break e;a--,l+=n[s++]<>>=x,h-=x,i.back+=x}if(l>>>=g,h-=g,i.back+=g,i.length=y,0===v){i.mode=26;break}if(32&v){i.back=-1,i.mode=Cw;break}if(64&v){e.msg="invalid literal/length code",i.mode=Pw;break}i.extra=15&v,i.mode=22;case 22:if(i.extra){for(M=i.extra;h>>=i.extra,h-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=23;case 23:for(;v=(C=i.distcode[l&(1<>>16&255,y=65535&C,!((g=C>>>24)<=h);){if(0===a)break e;a--,l+=n[s++]<>x)])>>>16&255,y=65535&C,!(x+(g=C>>>24)<=h);){if(0===a)break e;a--,l+=n[s++]<>>=x,h-=x,i.back+=x}if(l>>>=g,h-=g,i.back+=g,64&v){e.msg="invalid distance code",i.mode=Pw;break}i.offset=y,i.extra=15&v,i.mode=24;case 24:if(i.extra){for(M=i.extra;h>>=i.extra,h-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){e.msg="invalid distance too far back",i.mode=Pw;break}i.mode=25;case 25:if(0===c)break e;if(f=d-c,i.offset>f){if((f=i.offset-f)>i.whave&&i.sane){e.msg="invalid distance too far back",i.mode=Pw;break}f>i.wnext?(f-=i.wnext,m=i.wsize-f):m=i.wnext-f,f>i.length&&(f=i.length),p=i.window}else p=r,m=o-i.offset,f=i.length;f>c&&(f=c),c-=f,i.length-=f;do{r[o++]=p[m++]}while(--f);0===i.length&&(i.mode=21);break;case 26:if(0===c)break e;r[o++]=i.length,c--,i.mode=21;break;case 27:if(i.wrap){for(;h<32;){if(0===a)break e;a--,l|=n[s++]<=252?6:Hw>=248?5:Hw>=240?4:Hw>=224?3:Hw>=192?2:1;function jw(e){var t,i,n,r,s,o=e.length,a=0;for(r=0;r>>6,t[s++]=128|63&i):i<65536?(t[s++]=224|i>>>12,t[s++]=128|i>>>6&63,t[s++]=128|63&i):(t[s++]=240|i>>>18,t[s++]=128|i>>>12&63,t[s++]=128|i>>>6&63,t[s++]=128|63&i);return t}function Ww(e,t){var i,n,r,s,o=t||e.length,a=new Array(2*o);for(n=0,i=0;i4)a[n++]=65533,i+=s-1;else{for(r&=2===s?31:3===s?15:7;s>1&&i1?a[n++]=65533:r<65536?a[n++]=r:(r-=65536,a[n++]=55296|r>>10&1023,a[n++]=56320|1023&r)}return function(e,t){if(t<65537&&(e.subarray&&Gw||!e.subarray&&$w))return String.fromCharCode.apply(null,iw(e,t));for(var i="",n=0;ne.length&&(t=e.length),i=t-1;i>=0&&128==(192&e[i]);)i--;return i<0||0===i?t:i+Vw[e[i]]>t?i:t}Vw[254]=Vw[254]=1;var Xw=0,Yw={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"};function Zw(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}function Kw(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var Qw=Object.prototype.toString;function Jw(e){if(!(this instanceof Jw))return new Jw(e);this.options=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var i=t.shift();if(i){if("object"!=typeof i)throw new TypeError(i+"must be non-object");for(var n in i)i.hasOwnProperty(n)&&(e[n]=i[n])}}return e}({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Zw,this.strm.avail_out=0;var i,n,r,s=Rw(this.strm,t.windowBits);if(s!==Xw)throw new Error(Yw[s]);this.header=new Kw,i=this.strm,n=this.header,i&&i.state&&(0==(2&(r=i.state).wrap)||(r.head=n,n.done=!1))}Jw.prototype.push=function(e,t){var i,n,r,s,o,a,c=this.strm,l=this.options.chunkSize,h=this.options.dictionary,u=!1;if(this.ended)return!1;n=t===~~t?t:!0===t?4:0,"string"==typeof e?c.input=function(e){for(var t=new Uint8Array(e.length),i=0,n=t.length;i0||0===c.avail_out)&&1!==i);return 1===i&&(n=4),4===n?(i=function(e){if(!e||!e.state)return Aw;var t=e.state;return t.window&&(t.window=null),e.state=null,Sw}(this.strm),this.onEnd(i),this.ended=!0,i===Xw):2!==n||(this.onEnd(Xw),c.avail_out=0,!0)},Jw.prototype.onData=function(e){this.chunks.push(e)},Jw.prototype.onEnd=function(e){e===Xw&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=function(e){var t,i,n,r,s,o;for(n=0,t=0,i=e.length;tObject.assign(Object.assign({},e),{[t]:t})),{})}}const mS={backgroundColor:{type:"color"},quality:fS("auto","low","medium","high"),sampleLevel:dS(1,5,-1),impostor:{type:"boolean"},workerDefault:{type:"boolean"},rotateSpeed:uS(1,10,0),zoomSpeed:uS(1,10,0),panSpeed:uS(1,10,0),clipNear:dS(1,100,0),clipFar:dS(1,100,0),clipDist:hS(200,0),clipMode:fS("scene","camera"),clipScale:fS("relative","absolute"),fogNear:dS(1,100,0),fogFar:dS(1,100,0),cameraType:fS("perspective","orthographic","stereo"),cameraEyeSep:uS(3,1,.01),cameraFov:dS(1,120,15),lightColor:{type:"color"},lightIntensity:uS(2,10,0),ambientColor:{type:"color"},ambientIntensity:uS(2,10,0),hoverTimeout:hS(1e4,-1),tooltip:{type:"boolean"},mousePreset:fS(...Object.keys(um))};e.AngleRepresentation=Qv,e.ArrowBuffer=wx,e.Assembly=Qm,e.AxesRepresentation=fy,e.BackboneRepresentation=py,e.BallAndStickRepresentation=my,e.BaseRepresentation=gy,e.Box3=Ni,e.BoxBuffer=Px,e.BufferRepresentation=Vp,e.CartoonRepresentation=Sy,e.Collection=Sg,e.Color=mn,e.Colormaker=dc,e.ColormakerRegistry=al,e.Component=wg,e.ComponentCollection=Wg,e.ConeBuffer=xx,e.ContactRepresentation=Ay,e.Counter=El,e.CylinderBuffer=dy,e.DatasourceRegistry=cl,e.DecompressorRegistry=dl,e.DihedralHistogramRepresentation=Ty,e.DihedralRepresentation=My,e.DistanceRepresentation=Ey,e.EllipsoidBuffer=Rx,e.Euler=ai,e.Frames=Pg,e.HelixorientRepresentation=ky,e.HyperballRepresentation=Vy,e.Kdtree=qm,e.KeyActions=mm,e.LabelRepresentation=jy,e.LeftMouseButton=1,e.LicoriceRepresentation=Oy,e.LineRepresentation=qy,e.Matrix3=Ut,e.Matrix4=ri,e.MdsrvDatasource=class extends eS{constructor(e=""){super(),this.baseUrl=e}getListing(e=""){let t=`${this.baseUrl}dir/${e}`;return"/"!==t[t.length-1]&&(t+="/"),Ml(t,{ext:"json"}).then((t=>({path:e,data:t.data})))}getUrl(e){const t=Sl(e);return`${this.baseUrl}file/${t.path}${t.query}`}getCountUrl(e){const t=Sl(e);return`${this.baseUrl}traj/numframes/${t.path}${t.query}`}getFrameUrl(e,t){const i=Sl(e);return`${this.baseUrl}traj/frame/${t}/${i.path}${i.query}`}getFrameParams(e,t){return`atomIndices=${t.join(";")}`}getPathUrl(e,t){const i=Sl(e);return`${this.baseUrl}traj/path/${t}/${i.path}${i.query}`}getExt(e){return Sl(e).ext}},e.MeasurementDefaultParams=nl,e.MeshBuffer=nm,e.MiddleMouseButton=2,e.MolecularSurface=Qy,e.MolecularSurfaceRepresentation=Jy,e.MouseActions=hm,e.OctahedronBuffer=Fx,e.ParserRegistry=hl,e.PdbWriter=class extends Pl{constructor(e,t){super(),this.mimeType="text/plain",this.defaultName="structure",this.defaultExt="pdb";const i=Object.assign({},t);this.renumberSerial=Ia(i.renumberSerial,!0),this.remarks=function(e){return Array.isArray(e)?e:[e]}(Ia(i.remarks,[])),this.structure=e,this._records=[]}_writeRecords(){this._records.length=0,this._writeTitle(),this._writeRemarks(),this._writeAtoms()}_writeTitle(){this._records.push(Cl.sprintf("TITLE %-74s",this.structure.name))}_writeRemarks(){this.remarks.forEach((e=>{this._records.push(Cl.sprintf("REMARK %-73s",e))})),this.structure.trajectory&&(this._records.push(Cl.sprintf("REMARK %-73s","Trajectory '"+this.structure.trajectory.name+"'")),this._records.push(Cl.sprintf("REMARK %-73s",`Frame ${this.structure.trajectory.frame}`)))}_writeAtoms(){let e=1,t=1,i=" ",n=" ";const r=this.structure.modelStore.count>1;this.structure.eachModel((s=>{r&&this._records.push(Cl.sprintf("MODEL %4d%-66s",t++,"")),s.eachAtom((t=>{const r=t.hetero?"HETATM%5d %-4s %3s %1s%4d %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%1s%1s":"ATOM %5d %-4s %3s %1s%4d %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%1s%1s",s=this.renumberSerial?e:t.serial;let o=t.atomname;(1===o.length||o.length<4&&1===t.element.length&&o[0]===t.element)&&(o=" "+o),t.formalCharge?(i=Math.abs(t.formalCharge).toPrecision(1),n=t.formalCharge>0?"+":"-"):(i=" ",n=" "),this._records.push(Cl.sprintf(r,s,o,t.resname,Ia(t.chainname," "),t.resno,t.x,t.y,t.z,Ia(t.occupancy,1),Ia(t.bfactor,0),"",Ia(t.element,""),i,n)),e+=1}),this.structure.getSelection()),r&&this._records.push(Cl.sprintf("%-80s","ENDMDL"))})),this._records.push(Cl.sprintf("%-80s","END"))}getString(){return console.warn("PdbWriter.getString() is deprecated, use .getData instead"),this.getData()}getData(){return this._writeRecords(),this._records.join("\n")}},e.PickingProxy=Rh,e.Plane=Qi,e.PointBuffer=sg,e.PointRepresentation=ex,e.Quaternion=qt,e.Queue=eu,e.RepresentationCollection=Ag,e.RepresentationElement=yg,e.RepresentationRegistry=ll,e.RibbonRepresentation=rx,e.RightMouseButton=3,e.RocketRepresentation=sx,e.RopeRepresentation=ox,e.ScriptExtensions=sl,e.SdfWriter=class extends Pl{constructor(e){super(),this.mimeType="text/plain",this.defaultName="structure",this.defaultExt="sdf",this.structure=e,this._records=[]}get idString(){return this.structure.id}get titleString(){return" "+this.structure.title}get countsString(){return Cl.sprintf("%3i%3i 0 0 0 0 0 0 0 0999 V2000",this.structure.atomCount,this.structure.bondCount)}get chargeLines(){const e=[];this.structure.eachAtom((t=>{null!=t.formalCharge&&0!==t.formalCharge&&e.push([t.index,t.formalCharge])}));const t=[];for(let i=0;i{this._records.push(this.formatAtom(e))})),this.structure.eachBond((e=>{this._records.push(this.formatBond(e))})),this.chargeLines.forEach((e=>{this._records.push(e)})),this._records.push("M END")}_writeFooter(){this._records.push("$$$$")}getData(){return this._writeRecords(),this._records.join("\n")}},e.Selection=$c,e.Shape=Gp,e.ShapeComponent=Zg,e.Signal=mc.Signal,e.SpacefillRepresentation=ax,e.SpatialHash=ju,e.SphereBuffer=tg,e.Stage=class{constructor(e,t={}){this.signals={parametersChanged:new mc.Signal,fullscreenChanged:new mc.Signal,componentAdded:new mc.Signal,componentRemoved:new mc.Signal,clicked:new mc.Signal,hovered:new mc.Signal},this.tasks=new El,this.compList=[],this.defaultFileParams={},this.logList=[],this.viewer=new vh(e),this.viewer.renderer&&(this.tooltip=document.createElement("div"),Object.assign(this.tooltip.style,{display:"none",position:"fixed",zIndex:"1000000",pointerEvents:"none",backgroundColor:"rgba( 0, 0, 0, 0.6 )",color:"lightgrey",padding:"8px",fontFamily:"sans-serif"}),this.viewer.container.appendChild(this.tooltip),this.mouseObserver=new xh(this.viewer.renderer.domElement),this.viewerControls=new Vh(this),this.trackballControls=new Dh(this),this.pickingControls=new kh(this),this.animationControls=new Jh(this),this.mouseControls=new fm(this),this.keyControls=new gm(this),this.pickingBehavior=new vm(this),this.mouseBehavior=new ym(this),this.animationBehavior=new xm(this),this.keyBehavior=new _m(this),this.spinAnimation=this.animationControls.spin([0,1,0],.005),this.spinAnimation.pause(!0),this.rockAnimation=this.animationControls.rock([0,1,0],.005),this.rockAnimation.pause(!0),this.parameters=Ea(t,Yg),this.setParameters(this.parameters),this.viewer.animate())}setParameters(e={}){Da(this.parameters,e);const t=e,i=this.parameters,n=this.viewer,r=this.trackballControls;return void 0!==t.quality&&this.setQuality(i.quality),void 0!==t.impostor&&this.setImpostor(i.impostor),void 0!==t.rotateSpeed&&(r.rotateSpeed=i.rotateSpeed),void 0!==t.zoomSpeed&&(r.zoomSpeed=i.zoomSpeed),void 0!==t.panSpeed&&(r.panSpeed=i.panSpeed),void 0!==t.mousePreset&&this.mouseControls.preset(i.mousePreset),this.mouseObserver.setParameters({hoverTimeout:i.hoverTimeout}),n.setClip(i.clipNear,i.clipFar,i.clipDist,i.clipMode,i.clipScale),n.setFog(void 0,i.fogNear,i.fogFar),n.setCamera(i.cameraType,i.cameraFov,i.cameraEyeSep),n.setSampling(i.sampleLevel),n.setBackground(i.backgroundColor),n.setLight(i.lightColor,i.lightIntensity,i.ambientColor,i.ambientIntensity),this.signals.parametersChanged.dispatch(this.getParameters()),this}log(e){console.log("STAGE LOG",e),this.logList.push(e)}getParameters(){return Object.assign({},this.parameters)}defaultFileRepresentation(t){if(t instanceof Vg){let i,n,r;t.setSelection("/0");const s=t.structure;if(s.biomolDict.BU1){const e=s.biomolDict.BU1;i=e.getAtomCount(s),n=e.getResidueCount(s),r=e.getInstanceCount(),t.setDefaultAssembly("BU1")}else i=s.getModelProxy(0).atomCount,n=s.getModelProxy(0).residueCount,r=1;let o=i;Kc&&(o*=4);const a=s.atomStore.count/s.residueStore.count<2;a&&(o*=10);let c="chainname",l="RdYlBu",h=!1;if(1===s.getChainnameCount(new $c("polymer and /0"))&&(c="residueindex",l="Spectral",h=!0),e.Debug&&console.log(o,i,r,a),n/r<4)t.addRepresentation("ball+stick",{colorScheme:"element",radiusScale:2,aspectRatio:1.5,bondScale:.3,bondSpacing:.75,quality:"auto"});else if(r>5&&o>15e3||o>7e5){let e=Math.min(2,Math.max(.1,6e3/(o/r)));a&&(e=Math.min(e,.5)),t.addRepresentation("surface",{colorScheme:c,colorScale:l,colorReverse:h,sele:"polymer",surfaceType:"av",probeRadius:1.4,scaleFactor:e,useWorker:!1})}else o>25e4?t.addRepresentation("backbone",{colorScheme:c,colorScale:l,colorReverse:h,lineOnly:!0}):o>1e5?t.addRepresentation("backbone",{colorScheme:c,colorScale:l,colorReverse:h,quality:"low",disableImpostor:!0,radiusScale:2}):o>8e4?t.addRepresentation("backbone",{colorScheme:c,colorScale:l,colorReverse:h,radiusScale:2}):(t.addRepresentation("cartoon",{colorScheme:c,colorScale:l,colorReverse:h,radiusScale:.7,aspectRatio:5,quality:"auto"}),o<5e4&&t.addRepresentation("base",{colorScheme:c,colorScale:l,colorReverse:h,quality:"auto"}),t.addRepresentation("ball+stick",{sele:"ligand",colorScheme:"element",radiusScale:2,aspectRatio:1.5,bondScale:.3,bondSpacing:.75,quality:"auto"}));t.structure.frames.length&&t.addTrajectory()}else(t instanceof Hg||t instanceof jg)&&t.addRepresentation("surface");this.tasks.onZeroOnce(this.autoView,this)}loadFile(e,t={}){const i=Object.assign({},this.defaultFileParams,t),n=Sl(e).name;this.tasks.increment(),this.log(`loading file '${n}'`);const r=Ia(i.ext,Sl(e).ext);let s;return s=hl.isTrajectory(r)?Promise.reject(new Error(`loadFile: ext '${r}' is a trajectory and must be loaded into a structure component`)):Ml(e,i),s.then((e=>{this.log(`loaded '${n}'`);const t=this.addComponentFromObject(e,i);return i.defaultRepresentation&&this.defaultFileRepresentation(t),this.tasks.decrement(),t}),(e=>{this.tasks.decrement();const t=`error loading file: '${e}'`;throw this.log(t),t}))}loadScript(e){const t=Sl(e).name;return this.log(`loading script '${t}'`),Ml(e).then((e=>{this.tasks.increment(),this.log(`running script '${t}'`),e.run(this).then((()=>{this.tasks.decrement(),this.log(`finished script '${t}'`)})),this.log(`called script '${t}'`)}),(e=>{this.tasks.decrement();const i=`errored script '${t}' "${e}"`;throw this.log(i),i}))}addComponent(e){e?(this.compList.push(e),this.signals.componentAdded.dispatch(e)):il.warn("Stage.addComponent: no component given")}addComponentFromObject(e,t={}){const i=fl.get(e.type);if(i){const n=new i(this,e,t);return this.addComponent(n),n}il.warn("no component for object type",e.type)}removeComponent(e){const t=this.compList.indexOf(e);-1!==t&&(this.compList.splice(t,1),e.dispose(),this.signals.componentRemoved.dispatch(e))}removeAllComponents(){this.compList.slice().forEach((e=>this.removeComponent(e)))}handleResize(){this.viewer.handleResize()}setSize(e,t){const i=this.viewer.container;i!==document.body&&(void 0!==e&&(i.style.width=e),void 0!==t&&(i.style.height=t),this.handleResize())}toggleFullscreen(e){if(!(document.fullscreenEnabled||document.mozFullScreenEnabled||document.webkitFullscreenEnabled||document.msFullscreenEnabled))return void il.log("fullscreen mode (currently) not possible");const t=this;function i(){return document.fullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement||document.msFullscreenElement}function n(){if(!i()&&t.lastFullscreenElement){const e=t.lastFullscreenElement;e.style.width=e.dataset.normalWidth||"",e.style.height=e.dataset.normalHeight||"",document.removeEventListener("fullscreenchange",n),document.removeEventListener("mozfullscreenchange",n),document.removeEventListener("webkitfullscreenchange",n),document.removeEventListener("MSFullscreenChange",n),t.handleResize(),t.signals.fullscreenChanged.dispatch(!1)}}e=e||this.viewer.container,this.lastFullscreenElement=e,i()?document.exitFullscreen?document.exitFullscreen():document.msExitFullscreen?document.msExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen&&document.webkitExitFullscreen():(e.dataset.normalWidth=e.style.width||"",e.dataset.normalHeight=e.style.height||"",e.style.width=window.screen.width+"px",e.style.height=window.screen.height+"px",e.requestFullscreen?e.requestFullscreen():e.msRequestFullscreen?e.msRequestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.webkitRequestFullscreen&&e.webkitRequestFullscreen(),document.addEventListener("fullscreenchange",n),document.addEventListener("mozfullscreenchange",n),document.addEventListener("webkitfullscreenchange",n),document.addEventListener("MSFullscreenChange",n),this.handleResize(),this.signals.fullscreenChanged.dispatch(!0),setTimeout((function(){t.handleResize()}),100))}setSpin(e){e?(this.spinAnimation.resume(!0),this.rockAnimation.pause(!0)):this.spinAnimation.pause(!0)}setRock(e){e?(this.rockAnimation.resume(!0),this.spinAnimation.pause(!0)):this.rockAnimation.pause(!0)}toggleSpin(){this.setSpin(this.spinAnimation.paused)}toggleRock(){this.setRock(this.rockAnimation.paused)}getFocus(){const e=this.parameters;if("scene"!==e.clipMode)return 0;let t=e.clipNear;return"absolute"===e.clipScale&&(t=this.viewer.absoluteToRelative(t)),2*t}setFocus(e){if("scene"!==this.parameters.clipMode)return;let t,i,n,r;"relative"===this.parameters.clipScale?(t=tc(e/2,0,49.9),i=100-t,n=50,r=function(e){return tc(e,0,100)}(2*i-50)):(t=this.viewer.relativeToAbsolute(e/2),i=t,n=0,r=2*i),this.setParameters({clipNear:t,clipFar:i,fogNear:n,fogFar:r})}getZoomForBox(e){const t=e.getSize(Xg),i=Math.max(t.x,t.y,t.z),n=Math.min(t.x,t.y,t.z);let r=i+Math.sqrt(n);const s=Ka(this.viewer.perspectiveCamera.fov),o=this.viewer.width,a=this.viewer.height,c=a{this.tasks.onZeroOnce((()=>{this.tasks.increment(),this.viewer.makeImage(e).then((e=>{this.tasks.decrement(),t(e)})).catch((e=>{this.tasks.decrement(),i(e)}))}))}))}setImpostor(e){this.parameters.impostor=e;const t=["spacefill","ball+stick","licorice","hyperball","backbone","rocket","helixorient","contact","distance","dot"];this.eachRepresentation((function(i){if(!t.includes(i.getType()))return;const n=i.getParameters();n.disableImpostor=!e,i.build(n)}))}setQuality(e){this.parameters.quality=e;const t=["tube","cartoon","ribbon","trace","rope"],i=["spacefill","ball+stick","licorice","hyperball","backbone","rocket","helixorient","contact","distance","dot"];this.eachRepresentation((function(n){const r=n.getParameters();if(!t.includes(n.getType())){if(!i.includes(n.getType()))return;if(!r.disableImpostor)return void(n.repr.quality=e)}r.quality=e,n.build(r)}))}eachComponent(e,t){this.compList.slice().forEach((i=>{void 0!==t&&t!==i.type||e(i)}))}eachRepresentation(e,t){this.eachComponent((i=>{i.reprList.slice().forEach((n=>{void 0!==t&&t!==n.getType()||e(n,i)}))}))}getComponentsByName(e){const t=[];return this.eachComponent((i=>{(void 0===e||qg(e,i))&&t.push(i)})),new Wg(t)}getComponentsByObject(e){const t=[];return this.eachComponent((i=>{i.object===e&&t.push(i)})),new Wg(t)}getRepresentationsByName(e){const t=[];return this.eachRepresentation(((i,n)=>{(void 0===e||qg(e,i))&&t.push(i)})),new Ag(t)}measureClear(){this.eachComponent((e=>e.measureClear()),"structure")}measureUpdate(){this.eachComponent((e=>e.measureUpdate()),"structure")}dispose(){this.tasks.dispose(),this.viewer.dispose(),this.mouseObserver.dispose()}},e.StaticDatasource=class extends eS{constructor(e=""){super(),this.baseUrl=e}getUrl(e){const t=Sl(e);let i=this.baseUrl+t.path;return lS.test(this.baseUrl)||(i=function(e){const t=window.location,i=t.pathname,n=i.substring(0,i.lastIndexOf("/")+1);return t.origin+n+e}(i)),i}getExt(e){return Sl(e).ext}},e.StlWriter=class extends Pl{constructor(e){super(),this.mimeType="application/vnd.ms-pki.stl",this.defaultName="surface",this.defaultExt="stl",this.surface=e}getData(){const e=this.surface.index.length/3,t=new Il(2*e+3*e*4*4+80+4);t.skip(80),t.writeUint32(e);const i=new Zt,n=new Zt,r=new Zt,s=new Zt;for(let o=0;o{e.eachAtom((e=>{s.growIfFull(),s.atomTypeId[c]=o.add(e.atomname,e.element),s.x[c]=e.x,s.y[c]=e.y,s.z[c]=e.z,s.serial[c]=e.serial,s.formalCharge[c]=e.formalCharge,s.partialCharge[c]=e.partialCharge,s.altloc[c]=e.altloc,s.occupancy[c]=e.occupancy,s.bfactor[c]=e.bfactor,r.addAtom(e.modelIndex+h,e.chainname,e.chainid,e.resname,e.resno,1===e.hetero,e.sstruc,e.inscode),a[e.index+l]=c,c+=1})),l+=e.atomStore.count,h+=e.modelStore.count}));const u=n.bondStore,d=n.getAtomProxy(),f=n.getAtomProxy();return l=0,i.forEach((e=>{e.eachBond((e=>{d.index=a[e.atomIndex1+l],f.index=a[e.atomIndex2+l],u.addBond(d,f,e.bondOrder)})),l+=e.atomStore.count})),r.finalize(),hp(n,!0),lp(n,!0),n.finalizeAtoms(),n.finalizeBonds(),pp(n),e.Debug&&il.timeEnd("concatStructures"),n},e.download=Oa,e.flatten=function e(t,i){i=Ia(i,[]);for(let n=0;nt?(o&&(clearTimeout(o),o=null),a=l,s=e.apply(n,r),o||(n=r=null)):o||!1===i.trailing||(o=setTimeout(c,h)),s}},e.uniqueArray=za,Object.defineProperty(e,"__esModule",{value:!0})})); + */class Gm{constructor(e,t){this.points=e,this.metric=t,this.maxDepth=0,this.currentNode=0;const i=e.length/3,n=new Uint32Array(i);for(let e=0;ethis.maxDepth&&(this.maxDepth=e);const r=n-i;if(0===r)return-1;const s=4*this.currentNode,o=this.nodes;if(this.currentNode+=1,1===r)return o[s]=i,o[s+1]=-1,o[s+2]=-1,o[s+3]=t,s;const a=this.indices,c=this.points,l=i+Math.floor(r/2),h=e%3;let u,d,f,m,p,g=i,v=n-1;for(;v>g;){for(f=g+v>>1,m=c[3*a[f]+h],d=a[f],a[f]=a[v],a[v]=d,p=g,u=g;u-e[1])),r=this.nodes,s=this.points,o=this.indices,a=c=>{let l,h;const u=this.getNodeDepth(c)%3,d=3*o[r[c]],f=[s[d+0],s[d+1],s[d+2]],m=this.metric(e,f);function p(e,i){n.push([e,i]),n.size()>t&&n.pop()}const g=r[c+1],v=r[c+2];if(-1===v&&-1===g)return void((n.size()s[3*o[r[e]]+n])throw new Error("left child is > parent!");i+=this.verify(a,t+1)}if(-1!==c){if(s[3*o[r[c]]+n]0}isBackbone(){const e=this.residueType.backboneIndexList;return e.length>0&&e.includes(this.index-this.residueAtomOffset)}isPolymer(){if(this.structure.entityList.length>0)return this.entity.isPolymer();{const e=this.residueType.moleculeType;return 3===e||4===e||5===e}}isSidechain(){return this.isPolymer()&&!this.isBackbone()}isCg(){const e=this.residueType.backboneType;return 4===e||5===e||6===e}isTrace(){return this.index===this.residueType.traceAtomIndex+this.residueAtomOffset}isHetero(){return 1===this.residueType.hetero}isProtein(){return 3===this.residueType.moleculeType}isNucleic(){const e=this.residueType.moleculeType;return 4===e||5===e}isRna(){return 4===this.residueType.moleculeType}isDna(){return 5===this.residueType.moleculeType}isWater(){return 1===this.residueType.moleculeType}isIon(){return 2===this.residueType.moleculeType}isSaccharide(){return 6===this.residueType.moleculeType}isHelix(){return od.includes(this.sstruc)}isSheet(){return ad.includes(this.sstruc)}isTurn(){return cd.includes(this.sstruc)&&this.isProtein()}isBonded(){return 0!==this.bondHash.countArray[this.index]}isRing(){return void 0!==this.residueType.getRings().atomRings[this.index-this.residueAtomOffset]}isAromatic(){return 1===this.aromatic}isPolarHydrogen(){let e=!1;return 1!==this.number||(e=!this.hasBondToElement(6)),e}isMetal(){return this.atomType.isMetal()}isNonmetal(){return this.atomType.isNonmetal()}isMetalloid(){return this.atomType.isMetalloid()}isHalogen(){return this.atomType.isHalogen()}isDiatomicNonmetal(){return this.atomType.isDiatomicNonmetal()}isPolyatomicNonmetal(){return this.atomType.isPolyatomicNonmetal()}isAlkaliMetal(){return this.atomType.isAlkaliMetal()}isAlkalineEarthMetal(){return this.atomType.isAlkalineEarthMetal()}isNobleGas(){return this.atomType.isNobleGas()}isTransitionMetal(){return this.atomType.isTransitionMetal()}isPostTransitionMetal(){return this.atomType.isPostTransitionMetal()}isLanthanide(){return this.atomType.isLanthanide()}isActinide(){return this.atomType.isActinide()}getDefaultValence(){return this.atomType.getDefaultValence()}getValenceList(){return this.atomType.getValenceList()}getOuterShellElectronCount(){return this.atomType.getOuterShellElectronCount()}distanceTo(e){const t=this.atomStore,i=e.atomStore,n=this.index,r=e.index,s=t.x[n]-i.x[r],o=t.y[n]-i.y[r],a=t.z[n]-i.z[r],c=s*s+o*o+a*a;return Math.sqrt(c)}connectedTo(e){const t=this.atomStore,i=e.atomStore,n=this.index,r=e.index;if(t.altloc&&i.altloc){const e=t.altloc[n],s=i.altloc[r];if(0!==e&&0!==s&&32!==e&&32!==s&&e!==s)return!1}const s=t.x[n]-i.x[r],o=t.y[n]-i.y[r],a=t.z[n]-i.z[r],c=s*s+o*o+a*a;if(c<48&&this.isCg())return!0;if(isNaN(c))return!1;const l=this.covalent+e.covalent,h=l+.3,u=l-.5;return cu*u}positionFromArray(e,t=0){return this.x=e[t+0],this.y=e[t+1],this.z=e[t+2],this}positionToArray(e=[],t=0){const i=this.index,n=this.atomStore;return e[t+0]=n.x[i],e[t+1]=n.y[i],e[t+2]=n.z[i],e}positionToVector3(e){return void 0===e&&(e=new Zt),e.x=this.x,e.y=this.y,e.z=this.z,e}positionFromVector3(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}positionAdd(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}positionSub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}getResidueBonds(e=!1){const t=this.residueAtomOffset,i=this.index-this.residueAtomOffset,n=this.residueType.getBonds(),r=n.atomIndices1,s=n.atomIndices2;let o,a,c,l;for(e||(l=[]),o=r.indexOf(i);-1!==o;){if(c=s[o]+t,!l)return c;l.push(c),o=r.indexOf(i,o+1)}for(a=s.indexOf(i);-1!==a;){if(c=r[a]+t,!l)return c;l.push(c),a=s.indexOf(i,a+1)}return l}qualifiedName(e=!1){var t="";return this.resname&&!e&&(t+="["+this.resname+"]"),void 0!==this.resno&&(t+=this.resno),this.inscode&&(t+="^"+this.inscode),this.chainname&&(t+=":"+this.chainname),this.atomname&&(t+="."+this.atomname),this.altloc&&(t+="%"+this.altloc),this.structure.modelStore.count>1&&(t+="/"+this.modelIndex),t}clone(){return new Vm(this.structure,this.index)}toObject(){return{index:this.index,residueIndex:this.residueIndex,resname:this.resname,x:this.x,y:this.y,z:this.z,element:this.element,chainname:this.chainname,resno:this.resno,serial:this.serial,vdw:this.vdw,covalent:this.covalent,hetero:this.hetero,bfactor:this.bfactor,altloc:this.altloc,atomname:this.atomname,modelIndex:this.modelIndex}}}function Hm(e,t){const i=e[0]-t[0],n=e[1]-t[1],r=e[2]-t[2];return i*i+n*n+r*r}function jm(e,t){return Math.sqrt(Hm(e,t))}const Wm=new Float32Array(3);class qm{constructor(t,i=!1){e.Debug&&il.time("Kdtree build");const n=i?Hm:jm,r=new Float32Array(3*t.atomCount),s=new Uint32Array(t.atomCount);let o=0;t.eachAtom((function(e){r[o+0]=e.x,r[o+1]=e.y,r[o+2]=e.z,s[o/3]=e.index,o+=3})),this.atomIndices=s,this.points=r,this.kdtree=new Gm(r,n),e.Debug&&il.timeEnd("Kdtree build")}nearest(e,t,i){e instanceof Zt?e.toArray(Wm):e instanceof Vm&&e.positionToArray(Wm);const n=this.kdtree.nearest(Wm,t,i),r=this.kdtree.indices,s=this.kdtree.nodes,o=this.atomIndices,a=[];for(let e=0,t=n.length;e":"3/4-Z","?":"X-Y","@":"Y-X",A:"Z+1/3",B:"Z+2/3",C:"X+2/3",D:"Y+1/3",E:"-Y+2/3",F:"X-Y+1/3",G:"Y-X+2/3",H:"-X+1/3",I:"X+1/3",J:"Y+2/3",K:"-Y+1/3",L:"X-Y+2/3",M:"Y-X+1/3",N:"-X+2/3",O:"2/3+X",P:"1/3+Y",Q:"1/3+Z",R:"2/3-Y",S:"1/3+X-Y",T:"2/3+Y-X",U:"1/3-X",V:"2/3-X",W:"1/3-Y",X:"1/3-Z",Y:"2/3+Y",Z:"1/3+Y-X","[":"2/3+X-Y","]":"1/3+X","^":"2/3+Z",_:"2/3-Z","`":"5/6+Z",a:"1/6+Z",b:"5/6-Z",c:"1/6-Z",d:"Z+5/6",e:"Z+1/6",f:"Z+1/4",g:"+Y"},Ym={"P 1":" !#","P -1":" !#$%&","P 1 2 1":" !#$!&","P 1 21 1":" !#$'&","C 1 2 1":" !#$!&()#*)&","P 1 m 1":" !# %#","P 1 c 1":" !# %+","C 1 m 1":" !# %#()#(,#","C 1 c 1":" !# %+()#(,+","P 1 2/m 1":" !# %#$!&$%&","P 1 21/m 1":" !#$)&$%& ,#","C 1 2/m 1":" !# %#$!&$%&()#(,#*)&*,&","P 1 2/c 1":" !#$!-$%& %+","P 1 21/c 1":" !#$%&$)- ,+","C 1 2/c 1":" !#$!-$%& %+()#*)-*,&(,+","P 2 2 2":" !#$%#$!& %&","P 2 2 21":" !#$%+$!- %&","P 21 21 2":" !#$%#*)&(,&","P 21 21 21":" !#*%+$)-(,&","C 2 2 21":" !#$%+$!- %&()#*,+*)-(,&","C 2 2 2":" !#$%#$!& %&()#*,#*)&(,&","F 2 2 2":" !#$%#$!& %& )+$,+$)- ,-(!+*%+*!-(%-()#*,#*)&(,&","I 2 2 2":" !#$%# %&$!&.'/01/.120'2","I 21 21 21":" !#*%+$)-(,&()+$,#*!& %-","P m m 2":" !#$%# %#$!#","P m c 21":" !#$%+ %+$!#","P c c 2":" !#$%# %+$!+","P m a 2":" !#$%#(%#*!#","P c a 21":" !#$%+(%#*!+","P n c 2":" !#$%# ,+$)+","P m n 21":" !#*%+(%+$!#","P b a 2":" !#$%#(,#*)#","P n a 21":" !#$%+(,#*)+","P n n 2":" !#$%#(,+*)+","C m m 2":" !#$%# %#$!#()#*,#(,#*)#","C m c 21":" !#$%+ %+$!#()#*,+(,+*)#","C c c 2":" !#$%# %+$!+()#*,#(,+*)+","A m m 2":" !#$%# %#$!# )+$,+ ,+$)+","A b m 2":" !#$%# ,#$)# )+$,+ %+$!+","A m a 2":" !#$%#(%#*!# )+$,+(,+*)+","A b a 2":" !#$%#(,#*)# )+$,+(%+*!+","F m m 2":" !#$%# %#$!# )+$,+ ,+$)+(!+*%+(%+*!+()#*,#(,#*)#","F d d 2":" !#$%#345675 )+$,+3896:9(!+*%+;49<79()#*,#;85<:5","I m m 2":" !#$%# %#$!#()+*,+(,+*)+","I b a 2":" !#$%#(,#*)#()+*,+ %+$!+","I m a 2":" !#$%#(%#*!#()+*,+ ,+$)+","P 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!#","P 2/n 2/n 2/n":" !#$%#$!& %&*,-()-(,+*)+","P 2/c 2/c 2/m":" !#$%#$!- %-$%& !& %+$!+","P 2/b 2/a 2/n":" !#$%#$!& %&*,&()&(,#*)#","P 21/m 2/m 2/a":" !#*%#$!&(%&$%&(!& %#*!#","P 2/n 21/n 2/a":" !#*%#*)- ,-$%&(!&(,+$)+","P 2/m 2/n 21/a":" !#*%+*!- %&$%&(!-(%+$!#","P 21/c 2/c 2/a":" !#*%#$!-(%-$%&(!& %+*!+","P 21/b 21/a 2/m":" !#$%#*)&(,&$%& !&(,#*)#","P 21/c 21/c 2/n":" !#*,#$)-(%-$%&()& ,+*!+","P 2/b 21/c 21/m":" !#$%+$)- ,&$%& !- ,+$)#","P 21/n 21/n 2/m":" !#$%#*)-(,-$%& !&(,+*)+","P 21/m 21/m 2/n":" !#$%#*'&.,&*,&.'& %#$!#","P 21/b 2/c 21/n":" !#*,+$!-(,&$%&()- %+*)#","P 21/b 21/c 21/a":" !#*%+$)-(,&$%&(!- ,+*)#","P 21/n 21/m 21/a":" !#0%/$'&.12$%&.!2 1#0'/","C 2/m 2/c 21/m":" !#$%+$!- %&$%& !- %+$!#()#*,+*)-(,&*,&()-(,+*)#","C 2/m 2/c 21/a":" !#$,+$)- %&$%& )- ,+$!#()#*%+*!-(,&*,&(!-(%+*)#","C 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!#()#*,#*)&(,&*,&()&(,#*)#","C 2/c 2/c 2/m":" !#$%#$!- %-$%& !& %+$!+()#*,#*)-(,-*,&()&(,+*)+","C 2/m 2/m 2/a":" !#$,#$)& %&$%& )& ,#$!#()#*%#*!&(,&*,&(!&(%#*)#","C 2/c 2/c 2/a":" !#*,#$!&(,&$,-(!- ,+*!+()#$%#*)& %&*%- )-(%+$)+","F 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!# )+$,+$)- ,-$,- )- ,+$)+(!+*%+*!-(%-*%-(!-(%+*!+()#*,#*)&(,&*,&()&(,#*)#","F 2/d 2/d 2/d":" !#$%#$!& %&64=37=345675 )+$,+$)- ,-68>3:>3896:9(!+*%+*!-(%-<4>;7>;49<79()#*,#*)&(,&<8=;:=;85<:5","I 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!#()+*,+*)-(,-*,-()-(,+*)+","I 2/b 2/a 2/m":" !#$%#*)&(,&$%& !&(,#*)#()+*,+$!- %-*,-()- %+$!+","I 21/b 21/c 21/a":" !#*%+$)-(,&$%&(!- ,+*)#()+$,#*!& %-*,- )&(%#$!+","I 21/m 21/m 21/a":" !#$,#$)& %&$%& )& ,#$!#()+*%+*!-(,-*,-(!-(%+*)+","P 4":" !#$%#% #!$#","P 41":" !#$%+% 5!$9","P 42":" !#$%#% +!$+","P 43":" !#$%+% 9!$5","I 4":" !#$%#% #!$#()+*,+,(+)*+","I 41":" !#*,+%(5)$9()+$%#, 9!*5","P -4":" !#$%#!$&% &","I -4":" !#$%#!$&% &()+*,+)*-,(-","P 4/m":" !#$%#% #!$#$%& !&!$&% &","P 42/m":" !#$%#% +!$+$%& !&!$-% -","P 4/n":" !#$%#,(#)*#*,&()&!$&% &","P 42/n":" !#$%#,(+)*+*,-()-!$&% &","I 4/m":" !#$%#% #!$#$%& !&!$&% &()+*,+,(+)*+*,-()-)*-,(-","I 41/a":" !#*,+%(5)$9$,=(!>!$&,(-()+$%#, 9!*5*%> )=)*-% &","P 4 2 2":" !#$%#% #!$#$!& %&! &%$&","P 4 21 2":" !#$%#,(#)*#*)&(,&! &%$&","P 41 2 2":" !#$%+% 5!$9$!& %-! >%$=","P 41 21 2":" !#$%+,(5)*9*)=(,>! &%$-","P 42 2 2":" !#$%#% +!$+$!& %&! -%$-","P 42 21 2":" !#$%#,(+)*+*)-(,-! &%$&","P 43 2 2":" !#$%+% 9!$5$!& %-! =%$>","P 43 21 2":" !#$%+,(9)*5*)>(,=! &%$-","I 4 2 2":" !#$%#% #!$#$!& %&! &%$&()+*,+,(+)*+*)-(,-)(-,*-","I 41 2 2":" !#*,+%(5)$9*!> ,=)(-%$&()+$%#, 9!*5$)=(%>! &,*-","P 4 m m":" !#$%#% #!$# %#$!#%$#! #","P 4 b m":" !#$%#% #!$#(,#*)#,*#)(#","P 42 c m":" !#$%#% +!$+ %+$!+%$#! #","P 42 n m":" !#$%#,(+)*+(,+*)+%$#! #","P 4 c c":" !#$%#% #!$# %+$!+%$+! +","P 4 n c":" !#$%#% #!$#(,+*)+,*+)(+","P 42 m c":" !#$%#% +!$+ %#$!#%$+! +","P 42 b c":" !#$%#% +!$+(,#*)#,*+)(+","I 4 m m":" !#$%#% #!$# %#$!#%$#! #()+*,+,(+)*+(,+*)+,*+)(+","I 4 c m":" !#$%#% #!$# %+$!+%$+! +()+*,+,(+)*+(,#*)#,*#)(#","I 41 m d":" !#*,+%(5)$9 %#*)+%*5) 9()+$%#, 9!*5(,+$!#,$9!(5","I 41 c d":" !#*,+%(5)$9 %+*)#%*9) 5()+$%#, 9!*5(,#$!+,$5!(9","P -4 2 m":" !#$%#% &!$&$!& %&%$#! #","P -4 2 c":" !#$%#% &!$&$!- %-%$+! +","P -4 21 m":" !#$%#% &!$&*)&(,&,*#)(#","P -4 21 c":" !#$%#% &!$&*)-(,-,*+)(+","P -4 m 2":" !#$%#!$&% & %#$!#! &%$&","P -4 c 2":" !#$%#% &!$& %+$!+! -%$-","P -4 b 2":" !#$%#% &!$&(,#*)#)(&,*&","P -4 n 2":" !#$%#% &!$&(,+*)+)(-,*-","I -4 m 2":" !#$%#% &!$& %#$!#! &%$&()+*,+,(-)*-(,+*)+)(-,*-","I -4 c 2":" !#$%#% &!$& %+$!+! -%$-()+*,+,(-)*-(,#*)#)(&,*&","I -4 2 m":" !#$%#% &!$&$!& %&%$#! #()+*,+,(-)*-*)-(,-,*+)(+","I -4 2 d":" !#$%#% &!$&*!>(%>,$9) 9()+*,+,(-)*-$)= ,=%*5!(5","P 4/m 2/m 2/m":" !#$%#% #!$#$!& %&! &%$&$%& !&!$&% & %#$!#%$#! #","P 4/m 2/c 2/c":" !#$%#% #!$#$!- %-! -%$-$%& !&!$&% & %+$!+%$+! +","P 4/n 2/b 2/m":" !#$%#% #!$#$!& %&! &%$&*,&()&)*&,(&(,#*)#,*#)(#","P 4/n 2/n 2/c":" !#$%#% #!$#$!& %&! &%$&*,-()-)*-,(-(,+*)+,*+)(+","P 4/m 21/b 2/m":" !#$%#% #!$#*)&(,&)(&,*&$%& !&!$&% &(,#*)#,*#)(#","P 4/m 21/n 2/c":" !#$%#% #!$#*)-(,-)(-,*-$%& !&!$&% &(,+*)+,*+)(+","P 4/n 21/m 2/m":" !#$%#,(#)*#*)&(,&! &%$&*,&()&!$&% & %#$!#,*#)(#","P 4/n 2/c 2/c":" !#$%#,(#)*#*)-(,-! -%$-*,&()&!$&% & %+$!+,*+)(+","P 42/m 2/m 2/c":" !#$%#% +!$+$!& %&! -%$-$%& !&!$-% - %#$!#%$+! +","P 42/m 2/c 2/m":" !#$%#% +!$+$!- %-! &%$&$%& !&!$-% - %+$!+%$#! #","P 42/n 2/b 2/c":" !#$%#,(+)*+$!- %-)(&,*&*,-()-!$&% &(,#*)#%$+! +","P 42/n 2/n 2/m":" !#$%#,(+)*+$!& %&)(-,*-*,-()-!$&% &(,+*)+%$#! #","P 42/m 21/b 2/c":" !#$%#% +!$+*)&(,&)(-,*-$%& !&!$-% -(,#*)#,*+)(+","P 42/m 21/n 2/m":" !#$%#,./'*/*'-.,-! &%$&$%& !&'*-,.-.,/*'/%$#! #","P 42/n 21/m 2/c":" !#$%#,(+)*+*)-(,-! &%$&*,-()-!$&% & %#$!#,*+)(+","P 42/n 21/c 2/m":" !#$%#,(+)*+*)&(,&! -%$-*,-()-!$&% & %+$!+,*#)(#","I 4/m 2/m 2/m":" !#$%#% #!$#$!& %&! &%$&$%& !&!$&% & %#$!#%$#! #()+*,+,(+)*+*)-(,-)(-,*-*,-()-)*-,(-(,+*)+,*+)(+","I 4/m 2/c 2/m":" !#$%#% #!$#$!- %-! -%$-$%& !&!$&% & %+$!+%$+! +()+*,+,(+)*+*)&(,&)(&,*&*,-()-)*-,(-(,#*)#,*#)(#","I 41/a 2/m 2/d":" !#*,+%(5)$9*!> ,=)(-%$&$,=(!>!$&,(-(,+$!#,$9!(5()+$%#, 9!*5$)=(%>! &,*-*%> )=)*-% & %#*)+%*5) 9","I 41/a 2/c 2/d":" !#*,+%(5)$9*!= ,>)(&%$-$,=(!>!$&,(-(,#$!+,$5!(9()+$%#, 9!*5$)>(%=! -,*&*%> )=)*-% & %+*)#%*9) 5","P 3":" !#%?#@$#","P 31":" !#%?A@$B","P 32":" !#%?B@$A","H 3":" !#%?#@$#CDAEFAGHAIJBKLBMNB","R 3":" !## !!# ","P -3":" !#%?#@$#$%&!@&? &","H -3":" !#%?#@$#$%&!@&? &OPQRSQTUQVWXYZX[]X]Y^W[^ZV^UR_PT_SO_","R -3":" !## !!# $%&&$%%&$","P 3 1 2":" !#%?#@$#%$&@!& ?&","P 3 2 1":" !#%?#@$#! &?%&$@&","P 31 1 2":" !#%?Q@$^%$_@!X ?&","P 31 2 1":" !#%?A@$B! &?%_$@X","P 32 1 2":" !#%?^@$Q%$X@!_ ?&","P 32 2 1":" !#%?B@$A! &?%X$@_","H 3 2":" !#%?#@$#! &?%&$@&OPQRSQTUQY]X[WXVZX]Y^W[^ZV^PO_SR_UT_","R 3 2":" !## !!# %$&$&%&%$","P 3 m 1":" !#%?#@$#%$#@!# ?#","P 3 1 m":" !#%?#@$#! #?%#$@#","P 3 c 1":" !#%?#@$#%$+@!+ ?+","P 3 1 c":" !#%?#@$#! +?%+$@+","H 3 m":" !#%?#@$#%$#@!# ?#OPQRSQTUQRUQTPQOSQ]Y^W[^ZV^WV^ZY^][^","R 3 m":" !## !!# ! # #!#! ","H 3 c":" !#%?#@$#%$+@!+ ?+OPQRSQTUQRU`TP`OS`]Y^W[^ZV^WVaZYa][a","R 3 c":" !## !!# '././'/'.","P -3 1 2/m":" !#%?#@$#%$&@!& ?&$%&!@&? &! #?%#$@#","P -3 1 2/c":" !#%?#@$#%$-@!- ?-$%&!@&? &! +?%+$@+","P -3 2/m 1":" !#%?#@$#! &?%&$@&$%&!@&? &%$#@!# ?#","P -3 2/c 1":" !#%?#@$#! -?%-$@-$%&!@&? &%$+@!+ ?+","H -3 2/m":" !#%?#@$#! &?%&$@&$%&!@&? &%$#@!# ?#OPQRSQTUQY]X[WXVZXVWXYZX[]XRUQTPQOSQ]Y^W[^ZV^PO_SR_UT_UR_PT_SO_WV^ZY^][^","R -3 2/m":" !## !!# %$&$&%&%$$%&&$%%&$! # #!#! ","H -3 2/c":" !#%?#@$#! -?%-$@-$%&!@&? &%$+@!+ ?+OPQRSQTUQY]b[WbVZbVWXYZX[]XRU`TP`OS`]Y^W[^ZV^POcSRcUTcUR_PT_SO_WVaZYa][a","R -3 2/c":" !## !!# 102021210$%&&$%%&$'././'/'.","P 6":" !#%?#@$#$%#!@#? #","P 61":" !#%?A@$B$%/!@d? e","P 65":" !#%?B@$A$%/!@e? d","P 62":" !#%?^@$Q$%#!@^? Q","P 64":" !#%?Q@$^$%#!@Q? ^","P 63":" !#%?#@$#$%+!@+? +","P -6":" !#%?#@$# !&%?&@$&","P 6/m":" !#%?#@$#$%#!@#? #$%&!@&? & !&%?&@$&","P 63/m":" !#%?#@$#$%+!@+? +$%&!@&? & !-%?-@$-","P 6 2 2":" !#%?#@$#$%#!@#? #! &?%&$@&%$&@!& ?&","P 61 2 2":" !#%?Q@$^$%+!@`? a! X?%&$@_%$b@!- ?c","P 65 2 2":" !#%?^@$Q$%+!@a? `! _?%&$@X%$c@!- ?b","P 62 2 2":" !#%?^@$Q$%#!@^? Q! _?%&$@X%$_@!& ?X","P 64 2 2":" !#%?Q@$^$%#!@Q? ^! X?%&$@_%$X@!& ?_","P 63 2 2":" !#%?#@$#$%+!@+? +! &?%&$@&%$-@!- ?-","P 6 m m":" !#%?#@$#$%#!@#? #%$#@!# ?#! #?%#$@#","P 6 c c":" !#%?#@$#$%#!@#? #%$+@!+ ?+! +?%+$@+","P 63 c m":" !#%?#@$#$%+!@+? +%$+@!+ ?+! #?%#$@#","P 63 m c":" !#%?#@$#$%+!@+? +%$#@!# ?#! +?%+$@+","P -6 m 2":" !#%?#@$# !&%?&@$&%$#@!# ?#%$&@!& ?&","P -6 c 2":" !#%?#@$# !-%?-@$-%$+@!+ ?+%$&@!& ?&","P -6 2 m":" !#%?#@$# !&%?&@$&! &?%&$@&! #?%#$@#","P -6 2 c":" !#%?#@$# !-%?-@$-! &?%&$@&! +?%+$@+","P 6/m 2/m 2/m":" !#%?#@$#$%#!@#? #! &?%&$@&%$&@!& ?&$%&!@&? & !&@$&%?&%$#@!# ?#! #?%#$@#","P 6/m 2/c 2/c":" !#%?#@$#$%#!@#? #! -?%-$@-%$-@!- ?-$%&!@&? & !&@$&%?&%$+@!+ ?+! +?%+$@+","P 63/m 2/c 2/m":" !#%?#@$#$%+!@+? +! -?%-$@-%$&@!& ?&$%&!@&? & !-@$-%?-%$+@!+ ?+! #?%#$@#","P 63/m 2/m 2/c":" !#%?#@$#$%+!@+? +! &?%&$@&%$-@!- ?-$%&!@&? & !-@$-%?-%$#@!# ?#! +?%+$@+","P 2 3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ","F 2 3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ","I 2 3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-(","P 21 3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(","I 21 3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- ","P 2/m -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$","P 2/n -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& *,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*","F 2/m -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$ )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-($,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(*%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- *,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$","F 2/d -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& 64=37=345675=64=375345674=67=3453756 )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(68>3:>3896:9=<8=;:5;85<:4><7>;49;79<(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(<4>;7>;49<79>68>3:93896:8=<:=;85;:5<()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- <8=;:=;8f<:f><4>;79;49<78>6:>3893:96","I 2/m -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-(*,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*","P 21/a -3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&($%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*","I 21/a -3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&($%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*()+$,#*g& %-+()#$,&*!- %)+(,#$!&*%- *,- )&(%#$!+-*,& )#(%+$!,-*)& %#(!+$","P 4 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$","P 42 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*","F 4 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$ )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(-%*-!*+%(+ +,$+)$-, -)#)*#,(&)(&,*(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() -,$-)$+, +(#,*#)*&,(&)+!*+%(-!(-%*()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(&,*&)*#,(#(+%*+!*-%(-!+)$+, -) -,$","F 41 3 2":" !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=46 )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<(!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>86","I 4 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*","P 43 3 2":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(7;>46=:<5839398<5:6=4;>75:<983>7;=46","P 41 3 2":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<","I 41 3 2":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- 7;>46=:<5839398<5:6=4;>75:<983>7;=46","P -4 3 m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% ","F -4 3 m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(+%*+!*-%(- +)$+,$-) -,#)(#,*&)*&,((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() +,$+)$-, -(#)*#,*&)(&,+!(+%*-!*-%(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(#,*#)*&,(&(+!*+%*-!(-%+) +,$-)$-, ","I -4 3 m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,(","P -4 3 n":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,(","F -4 3 c":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,( )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-() #,$#)$&, &(#!*#%*&!(&%+! +%$-!$-% (!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(!(#%*#!*&%(& +!$+%$-! -%#) #,$&)$&, ()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ! +%$+!$-% - #)$#,$&) &,#!(#%*&!*&%(","I -4 3 d":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(7354<9:6>8;=357<946>:;=857394<>:6=8;()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- :;98657<=43>;9:658<=73>49:;586=7<>43","P 4/m -3 2/m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ","P 4/n -3 2/n":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$*,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(","P 42/m -3 2/n":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(","P 42/n -3 2/m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,**,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*%$#! #%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!$+% + #,$#)$&, &)#!*#%(&!(&%**,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$%$+! +% -!$-$&) &, #)$#,&%(&!*#%*#!(","F 41/d -3 2/m":" !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=4664=3:>;85<79=64>3:5;89<74=6:>385;79<,$+! #%(-)*&*&)(-% #!$+,-%(&)*+,$#! )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<68>37=;49<:5=<8>;753496:4><:=;893756,*#!(+% &)$-*-!(&, +)$#%-, &!$+%*#)((!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<<4>;:=389675>68=379;45<:8=<7>;453:96%$#) +,(&!*-$&! -,(#)*+%&% -)$#,*+!(()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>86<8=;7>3456:9><4=;:9385678>67=349;:5<%*+)(#, -!$&$-) &%(+!*#,&,(-!*#%$+) ","F 41/d -3 2/c":" !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=46<8>;7=3496:5><8=;793456:8><7=;493:56%*#)(+, &!$-$-! &,(+)*#%&, -!$#%*+)( )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<<4=;:>385679>64=3:9;85<78=67>345;:9<%$+) #,(-!*&$&) -%(#!*+,&%(-)*#,$+! (!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<68=37>;45<:9=<4>;:5389674>6:=389;75<,*+!(#% -)$&*-)(&% +!$#,-,(&!*+%$#) ()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>8664>3:=;89<75=68>375;49<:4=<:>;853796,$#! +%(&)*-*&!(-, #)$+%-% &)$+,*#!(","I 4/m -3 2/m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,**,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(","I 41/a -3 2/d":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<$%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*4<97358;=:6>6>:;=8357<94=8;>:694<573()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- 7;>46=:<5839398<5:6=4;>75:<983>7;=46*,- )&(%#$!+-*,& )#(%+$!,-*)& %#(!+$865:;943>7<=<=73>4;9:658>43=7<5869:;","P 1 1 2":" !#$%#","P 1 1 21":" !#$%+","B 1 1 2":" !#$%#(g+*%+","A 1 2 1":" !#$!& )+$)-","C 1 21 1":" !#$)&()#*!&","I 1 2 1":" !#$!&.'/0'2","I 1 21 1":" !#$)&.'/0!-","P 1 1 m":" !# !&","P 1 1 b":" !# )&","B 1 1 m":" !# !&(!+(!-","B 1 1 b":" !# )&(!+()-","P 1 1 2/m":" !# !&$%#$%&","P 1 1 21/m":" !#$%+$%& !-","B 1 1 2/m":" !# !&$%#$%&(!+(!-*%+*%-","P 1 1 2/b":" !#$,#$%& )&","P 1 1 21/b":" !#$%&$,+ )-","B 1 1 2/b":" !#$,#$%& )&(!+*,+*%-()-","P 21 2 2":" !#$!&(%&*%#","P 2 21 2":" !# ,&$)&$%#","P 21 21 2 (a)":" !#*,#.%&$'&","P 21 2 21":" !#$!&(%-*%+","P 2 21 21":" !# %&$)-$,+","C 2 2 21a)":" !#*%+(,&$)-()#$,+ %&*!-","C 2 2 2a":" !#*,#.%&$'&()#$%# ,&*!&","F 2 2 2a":" !#*,#.%&$'& '/*%/.12$!2.!/$,/ %20'2.'#$%# 1&0!&","I 2 2 2a":" !#*,#.%&$'&()+$%+*!- ,-","P 21/m 21/m 2/n a":" !#*,#$)&(%&$%&.'& ,#*!#","P 42 21 2a":" !#*,#%.+'$+$'&.%&! -,*-","I 2 3a":" !#*,#.%&$'&!# ,- '&$%/$# !-*!/$%&.%()+$%+ ,-*!-)+(%&(!-*,#*+()&$)#*,- ,"},Zm=/^[1-9]$/;function Km(e){let t="";return e.length>0&&(t=":"+za(e).join(" OR :")),new $c(t)}class Qm{constructor(e=""){this.name=e,this.partList=[]}get type(){return"Assembly"}addPart(e,t){const i=new Jm(e,t);return this.partList.push(i),i}getAtomCount(e){return this.partList.reduce(((t,i)=>t+i.getAtomCount(e)),0)}getResidueCount(e){return this.partList.reduce(((t,i)=>t+i.getResidueCount(e)),0)}getInstanceCount(){let e=0;return this.partList.forEach((function(t){e+=t.matrixList.length})),e}isIdentity(e){if(1!==this.partList.length)return!1;const t=this.partList[0];if(1!==t.matrixList.length)return!1;if(!(new ri).equals(t.matrixList[0]))return!1;let i=[];return e.eachChain((function(e){i.push(e.chainname)})),i=za(i),t.chainList.length===i.length}getBoundingBox(e){const t=new Ni;return this.partList.forEach((function(i){const n=i.getBoundingBox(e);t.expandByPoint(n.min),t.expandByPoint(n.max)})),t}getCenter(e){return this.getBoundingBox(e).getCenter(new Zt)}getSelection(){let e=[];return this.partList.forEach((function(t){e=e.concat(t.chainList)})),Km(e)}}class Jm{constructor(e=[],t=[]){this.matrixList=e,this.chainList=t}get type(){return"AssemblyPart"}_getCount(e,t){let i=0;return e.eachChain((e=>{(0===this.chainList.length||this.chainList.includes(e.chainname))&&(i+=e[t])})),this.matrixList.length*i}getAtomCount(e){return this._getCount(e,"atomCount")}getResidueCount(e){return this._getCount(e,"residueCount")}getBoundingBox(e){const t=new Ni,i=new Ni,n=this.getSelection(),r=e.getBoundingBox(n);return this.matrixList.forEach((function(e){i.copy(r).applyMatrix4(e),t.expandByPoint(i.min),t.expandByPoint(i.max)})),t}getSelection(){return Km(this.chainList)}getView(e){const t=this.getSelection();return t?e.getView(t):e}getInstanceList(){const e=[];for(let t=0,i=this.matrixList.length;t0&&this.addResidueType(this.ri-1),l.growIfFull(),l.resno[this.ri]=r,void 0!==o&&(l.sstruc[this.ri]=o.charCodeAt(0)),void 0!==a&&(l.inscode[this.ri]=a.charCodeAt(0)),l.atomOffset[this.ri]=this.ai,l.atomCount[this.ri]=0,l.count+=1,l.chainIndex[this.ri]=this.ci,h.residueCount[this.ci]+=1),c.count+=1,c.residueIndex[this.ai]=this.ri,l.atomCount[this.ri]+=1,this.currentModelindex=e,this.currentChainid=i,this.currentResname=n,this.currentResno=r,this.currentInscode=a,this.currentHetero=s}finalize(){this.previousResname=this.currentResname,this.previousHetero=this.currentHetero,this.ri>-1&&this.addResidueType(this.ri)}}function tp(t,i){if(!i)return;e.Debug&&il.time("assignSecondaryStructure");const n=[];t.eachModel((function(e){e.eachChain((function(e){n.push(e.chainname)}))}));const r=n.slice().sort(),s=[];r.forEach((function(e){s.push(n.indexOf(e))}));const o=i.helices.filter((function(e){return Na(r,e[0])>=0}));o.sort((function(e,t){const i=e[0],n=t[0],o=e[1],a=t[1];if(i===n)return o===a?0:o=0}));c.sort((function(e,t){const i=e[0],n=t[0];if(i===n)return 0;const o=Na(r,i),a=Na(r,n);return s[o]=e.residueCount)continue;o.index=s+r,a.index=s+r+t,c.index=o.traceAtomIndex,l.index=a.traceAtomIndex;const h=c.distanceTo(l);if(Math.abs(h-i[t-2])>n)return!1}return!0},i=function(e,i){return t(e,i,[5.45,5.18,6.37],2.1)},n=function(e,i){return t(e,i,[6.1,10.4,13],1.42)};return function(t){e.Debug&&il.time("calculateSecondaryStructure"),t.eachPolymer((function(e){if(e.residueCount<4)return;if(e.isCg())!function(e){const t=e.residueStore,i=e.residueIndexStart,n=new Um(e).position,r=new Zt,s=new Zt;for(let o=0,a=e.residueCount;o1&&n.bending[o]<20&&(t.sstruc[i+o]="h".charCodeAt(0),t.sstruc[i+o+1]="h".charCodeAt(0))}}(e);else{if(!e.isProtein())return;!function(e){const t=e.residueStore,r=e.residueIndexStart;for(let s=0,o=e.residueCount;s=t;)i=Math.floor(i/t),r+=np[i%t],n+=1;return n>=5&&il.warn("chainname overflow"),r}function sp(t,i=!1){e.Debug&&il.time("calculateChainnames");let n=!0;if(t.eachChain((function(e){e.chainname&&(n=!1)})),n){const e=t.modelStore,n=t.chainStore,r=t.residueStore,s=function(t,i,s,o){const a=n.count;for(let e=0;e{u.add(t),e.forEach((e=>{u.add(e)}))}))),t.eachResidue((function(e){if(!i&&h){const t=e.atomCount,i=e.atomOffset;if(t>500)return void il.warn("more than 500 atoms, skip residue for auto-bonding",e.qualifiedName());if("auto"===n&&e.hetero)for(let t=e.atomOffset;t{u.forEach((i=>{e.push(t.clone().multiply(i))}))})),l.addPart(e)}else l.addPart(h);const d=new Zt,f=new Qm("SUPERCELL"),m=Array.prototype.concat.call(c(d.set(1,0,0)),c(d.set(0,1,0)),c(d.set(0,0,1)),c(d.set(-1,0,0)),c(d.set(0,-1,0)),c(d.set(0,0,-1)),c(d.set(1,1,0)),c(d.set(1,0,1)),c(d.set(0,1,1)),c(d.set(-1,-1,0)),c(d.set(-1,0,-1)),c(d.set(0,-1,-1)),c(d.set(1,-1,-1)),c(d.set(1,1,-1)),c(d.set(1,-1,1)),c(d.set(-1,1,1)),c(d.set(-1,-1,1)),c(d.set(-1,1,-1)),c(d.set(0,1,-1)),c(d.set(0,-1,1)),c(d.set(1,0,-1)),c(d.set(-1,0,1)),c(d.set(1,-1,0)),c(d.set(-1,1,0)),c(),c(d.set(1,1,1)),c(d.set(-1,-1,-1)));if(t.biomolDict.NCS){const e=[];m.forEach((function(t){u.forEach((function(i){e.push(t.clone().multiply(i))}))})),f.addPart(e)}else f.addPart(m);t.biomolDict.UNITCELL=l,t.biomolDict.SUPERCELL=f,e.Debug&&il.timeEnd("buildUnitcellAssembly")}const dp=["H","C","O","N","S","P"],fp=["NA","CL","FE"];function mp(e){let t=e.toUpperCase(),i=0,n=0;for(let e=0;e0)break;++i}else n=e+1;(i>0||n=3&&-1!==dp.indexOf(t[0])?t[0]:""}function pp(e){const t=e.bondHash,i=t.countArray,n=t.offsetArray,r=t.indexArray,s=e.getBondProxy();e.eachResidue((function(e){const t=e.residueType;if(void 0!==t.bonds)return;var o=e.atomOffset,a=[],c=[],l=[],h={};const u=o+e.atomCount;e.eachAtom((function(e){const t=e.index,d=n[t];for(let e=0,n=i[t];e=u)continue;let i=s.atomIndex2;if(i=u)continue;if(t>i){const e=i;i=t,t=e}const n=t+"|"+i;void 0===h[n]&&(h[n]=!0,a.push(t-o),c.push(i-o),l.push(s.bondOrder))}})),t.bonds={atomIndices1:a,atomIndices2:c,bondOrders:l}}))}const gp=[3,11,19,37,55,87],vp=[4,12,20,38,56,88],yp=[6,15,16,34],xp=[1,7,8,9,17,35,53],bp=[2,10,18,36,54,86],_p=[13,30,31,48,49,50,80,81,82,83,84,85,112],wp=[5,14,32,33,51,52,85],Sp=[9,17,35,53,85];class Ap{constructor(e,t,i){this.structure=e,this.atomname=t,i=i||mp(t),this.element=i,this.number=ld[i]||0,this.vdw=hd[this.number]||2,this.covalent=ud[this.number]||1.6}getDefaultValence(){const e=dd[this.number];return e?e[0]:-1}getValenceList(){return dd[this.number]||[]}getOuterShellElectronCount(){return fd[this.number]||2}isMetal(){return this.isAlkaliMetal()||this.isAlkalineEarthMetal()||this.isLanthanide()||this.isActinide()||this.isTransitionMetal()||this.isPostTransitionMetal()}isNonmetal(){return this.isDiatomicNonmetal()||this.isPolyatomicNonmetal()||this.isNobleGas()}isMetalloid(){return wp.includes(this.number)}isHalogen(){return Sp.includes(this.number)}isDiatomicNonmetal(){return xp.includes(this.number)}isPolyatomicNonmetal(){return yp.includes(this.number)}isAlkaliMetal(){return gp.includes(this.number)}isAlkalineEarthMetal(){return vp.includes(this.number)}isNobleGas(){return bp.includes(this.number)}isTransitionMetal(){const e=this.number;return e>=21&&e<=29||e>=39&&e<=47||e>=72&&e<=79||e>=104&&e<=108}isPostTransitionMetal(){return _p.includes(this.number)}isLanthanide(){return this.number>=57&&this.number<=71}isActinide(){return this.number>=89&&this.number<=103}}class Mp{constructor(e){this.structure=e,this.dict={},this.list=[],this.structure=e}add(e,t){const i=function(e,t){return e+"|"+t}(e=e.toUpperCase(),t=t?t.toUpperCase():mp(e));let n=this.dict[i];if(void 0===n){const r=new Ap(this.structure,e,t);n=this.list.length,this.dict[i]=n,this.list.push(r)}return n}get(e){return this.list[e]}}class Cp{constructor(e,t,i,n,r,s){this.structure=e,this.bondReferenceAtomIndices=[],this.resname=t,this.atomTypeIdList=i,this.hetero=n?1:0,this.chemCompType=r,this.bonds=s,this.atomCount=i.length,this.moleculeType=this.getMoleculeType(),this.backboneType=this.getBackboneType(0),this.backboneEndType=this.getBackboneType(-1),this.backboneStartType=this.getBackboneType(1),this.backboneIndexList=this.getBackboneIndexList();const o=Pd[this.backboneType],a=Pd[this.backboneStartType],c=Pd[this.backboneEndType],l=this.getAtomIndexByName(o.trace);this.traceAtomIndex=Ia(l,-1);const h=this.getAtomIndexByName(o.direction1);this.direction1AtomIndex=Ia(h,-1);const u=this.getAtomIndexByName(o.direction2);this.direction2AtomIndex=Ia(u,-1);const d=this.getAtomIndexByName(a.backboneStart);this.backboneStartAtomIndex=Ia(d,-1);const f=this.getAtomIndexByName(c.backboneEnd);let m;this.backboneEndAtomIndex=Ia(f,-1),m=bd.includes(t)?this.getAtomIndexByName("N1"):this.getAtomIndexByName("N3"),this.rungEndAtomIndex=Ia(m,-1)}getBackboneIndexList(){const e=[];let t;switch(this.moleculeType){case 3:t=Md;break;case 4:case 5:t=Cd;break;default:return e}const i=this.structure.atomMap,n=this.atomTypeIdList;for(let r=0,s=this.atomCount;r500)e.Debug&&il.warn("more than 500 atoms, skip residue for auto-bonding",t.qualifiedName());else if(s>50){const e=new qm(t,!0),i=t.isCg()?1.2:2.3;for(let t=o;t=0||Ep(e,t);this.rings={atomRings:e.atomRings,rings:e.rings}}isAromatic(e){return this.aromaticAtoms=this.getAromatic(e),1===this.aromaticAtoms[e.index-e.residueAtomOffset]}calculateAromatic(e){const t=this.aromaticAtoms=new Uint8Array(this.atomCount),i=this.getRings().rings,n=i.map((t=>function(e){if(e.some((e=>!Pp.includes(e.number))))return!1;let t=0;const i=new Mf(3,e.length),n=i.data;e.forEach((e=>{n[t+0]=e.x,n[t+1]=e.y,n[t+2]=e.z,t+=3}));return new Dm(i).vecC.length()this.structure.getAtomProxy(t+e.atomOffset)))))),r=this.aromaticRings=[];i.forEach(((e,i)=>{n[i]&&(r.push(e),e.forEach((e=>t[e]=1)))}))}assignBondReferenceAtomIndices(){const e=this.getBondGraph(),t=this.getRings(),i=t.atomRings,n=t.rings,r=this.bonds,s=r.atomIndices1,o=r.atomIndices2,a=r.bondOrders,c=this.bondReferenceAtomIndices,l=r.atomIndices1.length;c.length=0;for(let t=0;t1)for(let i=0;i1)for(let i=0;i=0;e--)m[p++]=o[e];const g=e.rings.length;for(let t=0;t0?s[c]!==t&&s[t]!==c&&Ip(e,t,c):(n[c]=1,r[a++]=c,s[c]=t)}}}const Dp=4;class Lp{constructor(e){this.structure=e,this.dict={},this.list=[]}add(e,t,i,n="",r){const s=function(e,t,i,n=""){return e+"|"+t.join(",")+"|"+(i?1:0)+"|"+n}(e=e.toUpperCase(),t,i,n);let o=this.dict[s];if(void 0===o){const a=new Cp(this.structure,e,t,i,n,r);o=this.list.length,this.dict[s]=o,this.list.push(a)}return o}get(e){return this.list[e]}}class Rp{constructor(e,t=0){this.structure=e,this.index=t,this.bondStore=e.bondStore,this._v12=new Zt,this._v13=new Zt,this._ap1=this.structure.getAtomProxy(),this._ap2=this.structure.getAtomProxy(),this._ap3=this.structure.getAtomProxy()}get atom1(){return this.structure.getAtomProxy(this.atomIndex1)}get atom2(){return this.structure.getAtomProxy(this.atomIndex2)}get atomIndex1(){return this.bondStore.atomIndex1[this.index]}set atomIndex1(e){this.bondStore.atomIndex1[this.index]=e}get atomIndex2(){return this.bondStore.atomIndex2[this.index]}set atomIndex2(e){this.bondStore.atomIndex2[this.index]=e}get bondOrder(){return this.bondStore.bondOrder[this.index]}set bondOrder(e){this.bondStore.bondOrder[this.index]=e}getOtherAtomIndex(e){return e===this.atomIndex1?this.atomIndex2:this.atomIndex1}getOtherAtom(e){return this.structure.getAtomProxy(this.getOtherAtomIndex(e.index))}getReferenceAtomIndex(){const e=this._ap1,t=this._ap2;if(e.index=this.atomIndex1,t.index=this.atomIndex2,e.residueIndex!==t.residueIndex)return;const i=e.index-e.residueAtomOffset,n=t.index-t.residueAtomOffset,r=e.residueType.getBondReferenceAtomIndex(i,n);if(void 0!==r)return r+e.residueAtomOffset;console.warn("No reference atom found",e.index,t.index)}calculateShiftDir(e=new Zt){const t=this._ap1,i=this._ap2,n=this._ap3,r=this._v12,s=this._v13;t.index=this.atomIndex1,i.index=this.atomIndex2;const o=this.getReferenceAtomIndex();r.subVectors(t,i).normalize(),void 0!==o?(n.index=o,s.subVectors(t,n)):s.copy(t),s.normalize();let a=r.dot(s);return 1-Math.abs(a)<1e-5&&(s.set(1,0,0),a=r.dot(s),1-Math.abs(a)<1e-5&&(s.set(0,1,0),a=r.dot(s))),e.copy(s.sub(r.multiplyScalar(a))).normalize()}qualifiedName(){return this.atomIndex1+"="+this.atomIndex2}clone(){return new Rp(this.structure,this.index)}toObject(){return{atomIndex1:this.atomIndex1,atomIndex2:this.atomIndex2,bondOrder:this.bondOrder}}}class kp{constructor(e,t=0){this.structure=e,this.index=t,this.chainStore=e.chainStore,this.residueStore=e.residueStore,this.atomStore=e.atomStore,this.residueMap=e.residueMap,this.atomMap=e.atomMap}get entity(){return this.structure.entityList[this.entityIndex]}get entityIndex(){return this.chainStore.entityIndex[this.chainIndex]}get chain(){return this.structure.getChainProxy(this.chainIndex)}get chainIndex(){return this.residueStore.chainIndex[this.index]}set chainIndex(e){this.residueStore.chainIndex[this.index]=e}get atomOffset(){return this.residueStore.atomOffset[this.index]}set atomOffset(e){this.residueStore.atomOffset[this.index]=e}get atomCount(){return this.residueStore.atomCount[this.index]}set atomCount(e){this.residueStore.atomCount[this.index]=e}get atomEnd(){return this.atomOffset+this.atomCount-1}get modelIndex(){return this.chainStore.modelIndex[this.chainIndex]}get chainname(){return this.chainStore.getChainname(this.chainIndex)}get chainid(){return this.chainStore.getChainid(this.chainIndex)}get resno(){return this.residueStore.resno[this.index]}set resno(e){this.residueStore.resno[this.index]=e}get sstruc(){return this.residueStore.getSstruc(this.index)}set sstruc(e){this.residueStore.setSstruc(this.index,e)}get inscode(){return this.residueStore.getInscode(this.index)}set inscode(e){this.residueStore.setInscode(this.index,e)}get residueType(){return this.residueMap.get(this.residueStore.residueTypeId[this.index])}get resname(){return this.residueType.resname}get hetero(){return this.residueType.hetero}get moleculeType(){return this.residueType.moleculeType}get backboneType(){return this.residueType.backboneType}get backboneStartType(){return this.residueType.backboneStartType}get backboneEndType(){return this.residueType.backboneEndType}get traceAtomIndex(){return this.residueType.traceAtomIndex+this.atomOffset}get direction1AtomIndex(){return this.residueType.direction1AtomIndex+this.atomOffset}get direction2AtomIndex(){return this.residueType.direction2AtomIndex+this.atomOffset}get backboneStartAtomIndex(){return this.residueType.backboneStartAtomIndex+this.atomOffset}get backboneEndAtomIndex(){return this.residueType.backboneEndAtomIndex+this.atomOffset}get rungEndAtomIndex(){return this.residueType.rungEndAtomIndex+this.atomOffset}get x(){let e=0;for(let t=this.atomOffset;t<=this.atomEnd;++t)e+=this.atomStore.x[t];return e/this.atomCount}get y(){let e=0;for(let t=this.atomOffset;t<=this.atomEnd;++t)e+=this.atomStore.y[t];return e/this.atomCount}get z(){let e=0;for(let t=this.atomOffset;t<=this.atomEnd;++t)e+=this.atomStore.z[t];return e/this.atomCount}eachAtom(e,t){const i=this.atomCount,n=this.atomOffset,r=this.structure._ap,s=n+i;if(t&&t.atomOnlyTest){const i=t.atomOnlyTest;for(let t=n;t0)return this.entity.isPolymer();{const e=this.residueType.moleculeType;return 3===e||4===e||5===e}}isHetero(){return 1===this.residueType.hetero}isWater(){return 1===this.residueType.moleculeType}isIon(){return 2===this.residueType.moleculeType}isSaccharide(){return 6===this.residueType.moleculeType}isStandardAminoacid(){return this.residueType.isStandardAminoacid()}isStandardBase(){return this.residueType.isStandardBase()}isHelix(){return od.includes(this.sstruc)}isSheet(){return ad.includes(this.sstruc)}isTurn(){return cd.includes(this.sstruc)&&this.isProtein()}getAtomType(e){return this.atomMap.get(this.atomStore.atomTypeId[e])}getResname1(){return gd[this.resname.toUpperCase()]||"X"}getBackboneType(e){switch(e){case-1:return this.residueType.backboneStartType;case 1:return this.residueType.backboneEndType;default:return this.residueType.backboneType}}getAtomIndexByName(e){let t=this.residueType.getAtomIndexByName(e);return void 0!==t&&(t+=this.atomOffset),t}hasAtomWithName(e){return this.residueType.hasAtomWithName(e)}getAtomnameList(){console.warn("getAtomnameList - might be expensive");const e=this.atomCount,t=this.atomOffset,i=new Array(e);for(let n=0;n=t){const t=Ia(e,this.structure.getResidueProxy());if(t.index=i,t.connectedTo(this))return t}else if(i===t-1){const i=this.chainStore.residueCount[this.chainIndex],n=Ia(e,this.structure.getResidueProxy());if(n.index=t+i-1,n.connectedTo(this))return n}}getBonds(){return this.residueType.getBonds(this)}getRings(){return this.residueType.getRings()}getAromaticRings(){return this.residueType.getAromaticRings(this)}qualifiedName(e=!1){let t="";return this.resname&&!e&&(t+="["+this.resname+"]"),void 0!==this.resno&&(t+=this.resno),this.inscode&&(t+="^"+this.inscode),this.chain&&(t+=":"+this.chainname),t+="/"+this.modelIndex,t}clone(){return new kp(this.structure,this.index)}toObject(){return{index:this.index,chainIndex:this.chainIndex,atomOffset:this.atomOffset,atomCount:this.atomCount,resno:this.resno,resname:this.resname,sstruc:this.sstruc}}}class Op{constructor(e,t,i){this.structure=e,this.residueIndexStart=t,this.residueIndexEnd=i,this.chainStore=e.chainStore,this.residueStore=e.residueStore,this.atomStore=e.atomStore,this.residueCount=i-t+1;const n=this.structure.getResidueProxy(this.residueIndexStart),r=this.structure.getResidueProxy(this.residueIndexEnd);this.isPrevConnected=void 0!==n.getPreviousConnectedResidue();const s=r.getNextConnectedResidue();this.isNextConnected=void 0!==s,this.isNextNextConnected=void 0!==s&&void 0!==s.getNextConnectedResidue(),this.isCyclic=r.connectedTo(n),this.__residueProxy=this.structure.getResidueProxy()}get chainIndex(){return this.residueStore.chainIndex[this.residueIndexStart]}get modelIndex(){return this.chainStore.modelIndex[this.chainIndex]}get chainname(){return this.chainStore.getChainname(this.chainIndex)}isProtein(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isProtein()}isCg(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isCg()}isNucleic(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isNucleic()}getMoleculeType(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.moleculeType}getBackboneType(e){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.getBackboneType(e)}getAtomIndexByType(e,t){this.isCyclic?-1===e?e=this.residueCount-1:e===this.residueCount&&(e=0):(-1!==e||this.isPrevConnected||(e+=1),e!==this.residueCount||this.isNextNextConnected||(e-=1));const i=this.__residueProxy;let n;switch(i.index=this.residueIndexStart+e,t){case"trace":n=i.traceAtomIndex;break;case"direction1":n=i.direction1AtomIndex;break;case"direction2":n=i.direction2AtomIndex;break;default:n=i.getAtomIndexByName(t)}return n}eachAtom(e,t){this.eachResidue((function(i){i.eachAtom(e,t)}))}eachAtomN(e,t,i){const n=this.residueCount,r=new Array(e);for(let t=0;t1&&e(new Op(s,i,l.index)),i=n)):(o!==ed&&l.index-i>1&&e(new Op(s,i,l.index)),i=n)}n-i>1&&this.structure.getResidueProxy(i).backboneEndType&&e(new Op(s,i,n))}qualifiedName(){return":"+this.chainname+"/"+this.modelIndex}clone(){return new Bp(this.structure,this.index)}toObject(){return{index:this.index,residueOffset:this.residueOffset,residueCount:this.residueCount,chainname:this.chainname}}}class Np{constructor(e,t=0){this.structure=e,this.index=t,this.modelStore=e.modelStore,this.chainStore=e.chainStore,this.residueStore=e.residueStore}get chainOffset(){return this.modelStore.chainOffset[this.index]}set chainOffset(e){this.modelStore.chainOffset[this.index]=e}get chainCount(){return this.modelStore.chainCount[this.index]}set chainCount(e){this.modelStore.chainCount[this.index]=e}get residueOffset(){return this.chainStore.residueOffset[this.chainOffset]}get atomOffset(){return this.residueStore.atomOffset[this.residueOffset]}get chainEnd(){return this.chainOffset+this.chainCount-1}get residueEnd(){return this.chainStore.residueOffset[this.chainEnd]+this.chainStore.residueCount[this.chainEnd]-1}get atomEnd(){return this.residueStore.atomOffset[this.residueEnd]+this.residueStore.atomCount[this.residueEnd]-1}get residueCount(){return 0===this.chainCount?0:this.residueEnd-this.residueOffset+1}get atomCount(){return 0===this.residueCount?0:this.atomEnd-this.atomOffset+1}eachAtom(e,t){this.eachChain((function(i){i.eachAtom(e,t)}),t)}eachResidue(e,t){this.eachChain((function(i){i.eachResidue(e,t)}),t)}eachPolymer(e,t){if(t&&t.chainOnlyTest){const i=t.chainOnlyTest;this.eachChain((function(n){i(n)&&n.eachPolymer(e,t)}))}else this.eachChain((function(i){i.eachPolymer(e,t)}))}eachChain(e,t){const i=this.chainCount,n=this.chainOffset,r=this.structure._cp,s=n+i;if(t&&t.test){const i=t.chainOnlyTest;if(i)for(let t=n;t{const i=3*t;a.index=e,l&&a.positionToArray(l,i),h&&s.atomColorToArray(a,h,i),u&&(u.array[t]=e),d&&(d[t]=r.atomRadius(a)),f&&(f[t]=e)})),o}getBondData(e){const t=Object.assign({},e);t.colorParams&&(t.colorParams.structure=this.getStructure());const i=t.what,n=Ia(t.bondSet,this.bondSet),r=Ia(t.multipleBond,"off"),s="off"!==r,o="offset"===r,a=Ia(t.bondScale,.4),c=Ia(t.bondSpacing,1);let l,h;const u={},d=this.getBondProxy();t.bondStore&&(d.bondStore=t.bondStore);const f=this.getAtomProxy(),m=this.getAtomProxy();let p;if(s){const e=d.bondStore.bondOrder;p=0,n.forEach((function(t){p+=e[t]}))}else p=n.getSize();i&&!i.position||(u.position1=new Float32Array(3*p),u.position2=new Float32Array(3*p)),i&&!i.color||!t.colorParams||(u.color=new Float32Array(3*p),u.color2=new Float32Array(3*p),h=al.getScheme(t.colorParams)),i&&!i.picking||(u.picking=new df(new Float32Array(p),this.getStructure(),t.bondStore)),(!i||i.radius||s&&i.position)&&(l=new Tm(t.radiusParams)),i&&!i.radius||(u.radius=new Float32Array(p),t.radius2&&(u.radius2=new Float32Array(p)));const{position1:g,position2:v,color:y,color2:x,picking:b,radius:_,radius2:w}=u;let S,A,M,C,P,T,I=0;const E=new Zt,D=new Zt,L=new Zt;return n.forEach((e=>{if(A=3*I,d.index=e,f.index=d.atomIndex1,m.index=d.atomIndex2,C=d.bondOrder,g)if(s&&C>1){const e=l.atomRadius(f);T=e*a/(.5*C),d.calculateShiftDir(L),o?(P=2*c*e,L.multiplyScalar(P),L.negate(),D.subVectors(m,f).multiplyScalar(Math.max(.1,P/1.88)),f.positionToArray(g,A),m.positionToArray(v,A),C>=2&&(E.addVectors(f,L).add(D).toArray(g,A+3),E.addVectors(m,L).sub(D).toArray(v,A+3),C>=3&&(E.subVectors(f,L).add(D).toArray(g,A+6),E.subVectors(m,L).sub(D).toArray(v,A+6)))):(P=(c-a)*e,L.multiplyScalar(P),2===C?(E.addVectors(f,L).toArray(g,A),E.subVectors(f,L).toArray(g,A+3),E.addVectors(m,L).toArray(v,A),E.subVectors(m,L).toArray(v,A+3)):3===C?(f.positionToArray(g,A),E.addVectors(f,L).toArray(g,A+3),E.subVectors(f,L).toArray(g,A+6),m.positionToArray(v,A),E.addVectors(m,L).toArray(v,A+3),E.subVectors(m,L).toArray(v,A+6)):(f.positionToArray(g,A),m.positionToArray(v,A)))}else f.positionToArray(g,A),m.positionToArray(v,A);if(y&&x&&(h.bondColorToArray(d,1,y,A),h.bondColorToArray(d,0,x,A),s&&C>1))for(S=1;S1))for(S=1;S1))for(T=_[I]*a/(o?1:.5*C),S=o?1:0;S1))for(T=w[I]*a/(o?1:.5*C),S=o?1:0;S{const t=e.x,i=e.y,l=e.z;to&&(o=t),i>a&&(a=i),l>c&&(c=l)}),t),i.min.set(n,r,s),i.max.set(o,a,c),e.Debug&&il.timeEnd("getBoundingBox"),i}getPrincipalAxes(t){e.Debug&&il.time("getPrincipalAxes");let i=0;const n=new Mf(3,this.atomCount),r=n.data;return this.eachAtom((e=>{r[i+0]=e.x,r[i+1]=e.y,r[i+2]=e.z,i+=3}),t),e.Debug&&il.timeEnd("getPrincipalAxes"),new Dm(n)}atomCenter(e){return e?this.getBoundingBox(e).getCenter(new Zt):this.center.clone()}hasCoords(){if(void 0===this._hasCoords){const e=this.atomStore;this._hasCoords=0!==Zl(e.x)||0!==Yl(e.x)||0!==Zl(e.y)||0!==Yl(e.y)||0!==Zl(e.z)||0!==Yl(e.z)||e.count/this.modelStore.count==1}return this._hasCoords}getSequence(e){const t=[],i=this.getResidueProxy();return this.eachAtom((function(e){i.index=e.residueIndex,e.index===i.traceAtomIndex&&t.push(i.getResname1())}),e),t}getAtomIndices(e){if(e&&e.string){const t=[];return this.eachAtom((function(e){t.push(e.index)}),e),new Uint32Array(t)}{const e={what:{index:!0}};return this.getAtomData(e).index}}getChainnameCount(e){const t=new Set;return this.eachChain((function(e){e.residueCount&&t.add(e.chainname)}),e),t.size}updatePosition(e,t=!0){let i=0;this.eachAtom((function(t){t.positionFromArray(e,i),i+=3}),void 0),this._hasCoords=void 0,t&&this.refreshPosition()}refreshPosition(){this.getBoundingBox(void 0,this.boundingBox),this.boundingBox.getCenter(this.center),this.spatialHash=new ju(this.atomStore,this.boundingBox),this.signals.refreshed.dispatch(this)}dispose(){this.frames&&(this.frames.length=0),this.boxes&&(this.boxes.length=0),this.bondStore.dispose(),this.backboneBondStore.dispose(),this.rungBondStore.dispose(),this.atomStore.dispose(),this.residueStore.dispose(),this.chainStore.dispose(),this.modelStore.dispose(),delete this.bondSet,delete this.atomSet}}const zp=new Ni,Up=[Fu,ku,zu,Nu,Uu,Ou,Ru,Bu,Gu,$u,Vu,Hu],$p={aspectRatio:1.5,sphereDetail:2,radialSegments:50,disableImpostor:!1,openEnded:!1,dashedCylinder:!1,labelParams:{},pointSize:2,sizeAttenuation:!1,useTexture:!0,linewidth:2};class Gp{constructor(e="shape",t={}){this.boundingBox=new Ni,this.bufferList=[],this.meshCount=0,this._primitiveData={},this.name=e,this.parameters=Ea(t,$p),Up.forEach((e=>{Object.keys(e.fields).forEach((t=>{this._primitiveData[e.getShapeKey(t)]=[]})),this._primitiveData[e.getShapeKey("name")]=[]}))}addBuffer(e){this.bufferList.push(e);const t=e.geometry;return t.boundingBox||t.computeBoundingBox(),this.boundingBox.union(t.boundingBox),this}addMesh(e,t,i,n,r){let s;e=Xa(e),t=Xa(t),Array.isArray(i)&&(i=Ga(i,e.length)),n&&(n=Xa(n)),s=void 0===n||0==n.length?{position:e,color:t,index:i}:{position:e,color:t,index:i,normal:n};const o=new vf(this,Object.assign({serial:this.meshCount,name:r},s)),a=new nm(Object.assign({picking:o},s));return this.bufferList.push(a),zp.setFromArray(e),this.boundingBox.union(zp),this.meshCount+=1,this}addSphere(e,t,i,n){return Ru.objectToShape(this,{position:e,color:t,radius:i,name:n}),this}addEllipsoid(e,t,i,n,r,s){return Uu.objectToShape(this,{position:e,color:t,radius:i,majorAxis:n,minorAxis:r,name:s}),this}addTorus(e,t,i,n,r,s){return $u.objectToShape(this,{position:e,color:t,radius:i,majorAxis:n,minorAxis:r,name:s}),this}addCylinder(e,t,i,n,r){return Nu.objectToShape(this,{position1:e,position2:t,color:i,radius:n,name:r}),this}addCone(e,t,i,n,r){return zu.objectToShape(this,{position1:e,position2:t,color:i,radius:n,name:r}),this}addArrow(e,t,i,n,r){return Fu.objectToShape(this,{position1:e,position2:t,color:i,radius:n,name:r}),this}addBox(e,t,i,n,r,s){return ku.objectToShape(this,{position:e,color:t,size:i,heightAxis:n,depthAxis:r,name:s}),this}addOctahedron(e,t,i,n,r,s){return Ou.objectToShape(this,{position:e,color:t,size:i,heightAxis:n,depthAxis:r,name:s}),this}addTetrahedron(e,t,i,n,r,s){return Bu.objectToShape(this,{position:e,color:t,size:i,heightAxis:n,depthAxis:r,name:s}),this}addText(e,t,i,n){return Gu.objectToShape(this,{position:e,color:t,size:i,text:n}),this}addPoint(e,t,i){return Vu.objectToShape(this,{position:e,color:t,name:i}),this}addWideline(e,t,i,n,r){return this.parameters.linewidth=n,Hu.objectToShape(this,{position1:e,position2:t,color:i,name:r}),this}addLabel(e,t,i,n){return console.warn("Shape.addLabel is deprecated, use .addText instead"),this.addText(e,t,i,n)}getBufferList(){const e=[];return Up.forEach((t=>{this._primitiveData[t.getShapeKey("color")].length&&e.push(t.bufferFromShape(this,this.parameters))})),this.bufferList.concat(e)}dispose(){this.bufferList.forEach((function(e){e.dispose()})),this.bufferList.length=0,Up.forEach((e=>{Object.keys(e.fields).forEach((t=>{this._primitiveData[e.getShapeKey(t)].length=0})),this._primitiveData[e.getShapeKey("name")].length=0}))}get center(){return this._center||(this._center=this.boundingBox.getCenter(new Zt)),this._center}get type(){return"Shape"}}class Vp extends tu{constructor(e,t,i){Array.isArray(e)||(e=[e]),super(e,t,i),this.type="buffer",this.parameters=Object.assign({},this.parameters,{colorScheme:null,colorScale:null,colorValue:null,colorDomain:null,colorMode:null}),this.buffer=e,this.init(i)}init(e){super.init(e),this.build()}create(){this.bufferList.push.apply(this.bufferList,this.buffer)}attach(e){this.bufferList.forEach((e=>{this.viewer.add(e),e.setParameters(this.getBufferParams())})),this.setVisibility(this.visible),e()}}const Hp=new ri,jp=new Ut;class Wp extends nm{constructor(e,t={},i){super(function(e,t){const i=t.attributes.position.array,n=t.index?t.index.array:void 0,r=e.position.length/3,s=i.length/3,o=r*s,a=new Float32Array(3*o),c=new Float32Array(3*o),l=new Float32Array(3*o);let h;return n&&(h=Ga(r*n.length,o)),{position:a,color:l,index:h,normal:c,primitiveId:e.primitiveId||jl(r,s),picking:e.picking}}(e,i),t),this.updateNormals=!1;const n=i.attributes.position.array,r=i.attributes.normal.array,s=i.index?i.index.array:void 0;this.geoPosition=n,this.geoNormal=r,this.geoIndex=s,this.positionCount=e.position.length/3,this.geoPositionCount=n.length/3,this.transformedGeoPosition=new Float32Array(3*this.geoPositionCount),this.transformedGeoNormal=new Float32Array(3*this.geoPositionCount);const o=this.geometry.attributes;if(this.meshPosition=o.position.array,this.meshColor=o.color.array,this.meshNormal=o.normal.array,this.setAttributes(e),s){const e=this.geometry.getIndex();if(!e)return void il.error("Index is null");this.meshIndex=e.array,this.makeIndex()}}setAttributes(e={},t=!1){const i=this.geometry.attributes;let n,r,s,o,a,c,l,h,u;const d=this.updateNormals;e.position&&(n=e.position,s=this.geoPosition,l=this.meshPosition,a=this.transformedGeoPosition,i.position.needsUpdate=!0,(d||t)&&(o=this.geoNormal,u=this.meshNormal,c=this.transformedGeoNormal,i.normal.needsUpdate=!0)),e.color&&(r=e.color,h=this.meshColor,i.color.needsUpdate=!0);const f=this.positionCount,m=this.geoPositionCount;for(let e=0;e 0.0 ){\ncameraPos = rayDirection * posT + rayOrigin;\ninterior = true;\nflag2 = true;\n}\n#else\nif( calcDepth( cameraPos ) <= 0.0 ){\ncameraPos = rayDirection * posT + rayOrigin;\ninterior = true;\n}\n#endif\ncameraNormal = normalize( cameraPos - cameraSpherePos );\ncameraNormal *= float(!interior) * 2.0 - 1.0;\nreturn !interior;\n}\nvoid main(void){\nbool flag = Impostor( cameraPos, cameraNormal );\n#ifdef NEAR_CLIP\nif( calcClip( cameraPos ) > 0.0 )\ndiscard;\n#endif\ngl_FragDepthEXT = calcDepth( cameraPos );\nif( !flag ){\n#ifdef NEAR_CLIP\nif( flag2 ){\ngl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( clipNear - 0.5 ) ) ) + ( 0.0000001 / vRadius ) );\n}else if( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n#else\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n#endif\n}\nif (gl_FragDepthEXT < 0.0)\ndiscard;\nif (gl_FragDepthEXT > 1.0)\ndiscard;\n#ifdef PICKING\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 vNormal = cameraNormal;\nvec3 vViewPosition = -cameraPos;\nvec4 diffuseColor = vec4( diffuse, opacity );\nReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\nvec3 totalEmissiveLight = emissive;\n#include color_fragment\n#include roughnessmap_fragment\n#include metalnessmap_fragment\n#include normal_fragment_begin\n#include lights_physical_fragment\n#include lights_fragment_begin\n#include lights_fragment_end\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\nif( interior ){\n#ifdef USE_INTERIOR_COLOR\noutgoingLight.xyz = interiorColor;\n#else\n#ifdef DIFFUSE_INTERIOR\noutgoingLight.xyz = vColor;\n#endif\n#endif\noutgoingLight.xyz *= 1.0 - interiorDarkening;\n}\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");class Zp extends im{constructor(e,t,i={}){super(t,i),this.index=Ga(this.indexSize,this.attributeSize),this.makeIndex(),this.initIndex(this.index),this.addAttributes({mapping:{type:e,value:null}}),this.setAttributes({primitiveId:Hl(this.size)})}get attributeSize(){return this.size*this.mappingSize}get indexSize(){return this.size*this.mappingIndicesSize}addAttributes(e){const t={};for(const i in e){const n=e[i];t[i]={type:n.type,value:null}}super.addAttributes(t)}getAttributeIndex(e){return 3*e*this.mappingSize}setAttributes(e){e&&!e.position&&e.position1&&e.position2&&(e.position=Ul(e.position1,e.position2));const t=this.size,i=this.mappingSize,n=this.geometry.attributes;let r,s,o,a,c,l,h;for(const u in e)if("index"!==u&&"picking"!==u){s=e[u],r=n[u],o=r.itemSize,a=r.array;for(let e=0;e0&&this.parameters.alphaTest<=1&&(t.ALPHATEST=this.parameters.alphaTest.toPrecision(2)),t}setUniforms(e){e&&void 0!==e.edgeBleach&&(this.makeTexture(),e.map=this.tex),super.setUniforms(e)}dispose(){super.dispose(),this.tex&&this.tex.dispose()}}ml.add("point",sg);class og extends tu{constructor(e,t,i){super(e,t,i),this.type="dot",this.parameters=Object.assign({thresholdType:{type:"select",rebuild:!0,options:{value:"value",sigma:"sigma"}},thresholdMin:{type:"number",precision:3,max:1/0,min:-1/0,rebuild:!0},thresholdMax:{type:"number",precision:3,max:1/0,min:-1/0,rebuild:!0},thresholdOut:{type:"boolean",rebuild:!0},dotType:{type:"select",rebuild:!0,options:{"":"",sphere:"sphere",point:"point"}},radiusType:{type:"select",options:{"":"",value:"value","abs-value":"abs-value","value-min":"value-min",deviation:"deviation",size:"size"}},radius:{type:"number",precision:3,max:10,min:.001,property:"size"},scale:{type:"number",precision:3,max:10,min:.001},sphereDetail:!0,disableImpostor:!0,pointSize:{type:"number",precision:1,max:100,min:0,buffer:!0},sizeAttenuation:{type:"boolean",buffer:!0},sortParticles:{type:"boolean",rebuild:!0},useTexture:{type:"boolean",buffer:!0},alphaTest:{type:"range",step:.001,max:1,min:0,buffer:!0},forceTransparent:{type:"boolean",buffer:!0},edgeBleach:{type:"range",step:.001,max:1,min:0,buffer:!0}},this.parameters,{colorScheme:{type:"select",update:"color",options:{"":"",value:"value",uniform:"uniform",random:"random"}}}),e instanceof Zf?(this.surface=void 0,this.volume=new Lm(e)):(this.surface=e,this.volume=void 0),this.init(i)}init(e){var t=e||{};t.colorScheme=Ia(t.colorScheme,"uniform"),t.colorValue=Ia(t.colorValue,14540253),this.thresholdType=Ia(t.thresholdType,"sigma"),this.thresholdMin=Ia(t.thresholdMin,2),this.thresholdMax=Ia(t.thresholdMax,1/0),this.thresholdOut=Ia(t.thresholdOut,!1),this.dotType=Ia(t.dotType,"point"),this.radius=Ia(t.radius,.1),this.scale=Ia(t.scale,1),this.pointSize=Ia(t.pointSize,1),this.sizeAttenuation=Ia(t.sizeAttenuation,!0),this.sortParticles=Ia(t.sortParticles,!1),this.useTexture=Ia(t.useTexture,!1),this.alphaTest=Ia(t.alphaTest,.5),this.forceTransparent=Ia(t.forceTransparent,!1),this.edgeBleach=Ia(t.edgeBleach,0),super.init(t),this.build()}attach(e){this.bufferList.forEach((e=>{this.viewer.add(e)})),this.setVisibility(this.visible),e()}create(){var e={};if(this.volume){var t,i,n=this.volume;"sigma"===this.thresholdType?(t=n.getValueForSigma(this.thresholdMin),i=n.getValueForSigma(this.thresholdMax)):(t=this.thresholdMin,i=this.thresholdMax),n.setFilter(t,i,this.thresholdOut),Object.assign(e,{position:n.getDataPosition(),color:n.getDataColor(this.getColorParams())}),"sphere"===this.dotType&&Object.assign(e,{radius:n.getDataSize(this.radius,this.scale),picking:n.getDataPicking()})}else{var r=this.surface;Object.assign(e,{position:r.getPosition(),color:r.getColor(this.getColorParams())}),"sphere"===this.dotType&&Object.assign(e,{radius:r.getSize(this.radius,this.scale),picking:r.getPicking()})}"sphere"===this.dotType?this.dotBuffer=new tg(e,this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!1})):this.dotBuffer=new sg(e,this.getBufferParams({pointSize:this.pointSize,sizeAttenuation:this.sizeAttenuation,sortParticles:this.sortParticles,useTexture:this.useTexture,alphaTest:this.alphaTest,forceTransparent:this.forceTransparent,edgeBleach:this.edgeBleach})),this.bufferList.push(this.dotBuffer)}update(e={}){if(0===this.bufferList.length)return;const t={};e.color&&(this.volume?Object.assign(t,{color:this.volume.getDataColor(this.getColorParams())}):Object.assign(t,{color:this.surface.getColor(this.getColorParams())})),"sphere"===this.dotType&&(e.radius||e.scale)&&(this.volume?Object.assign(t,{radius:this.volume.getDataSize(this.radius,this.scale)}):Object.assign(t,{radius:this.surface.getSize(this.radius,this.scale)})),this.dotBuffer.setAttributes(t)}setParameters(e,t={},i){return e&&void 0!==e.thresholdType&&this.volume instanceof Zf&&("value"===this.thresholdType&&"sigma"===e.thresholdType?(this.thresholdMin=this.volume.getSigmaForValue(this.thresholdMin),this.thresholdMax=this.volume.getSigmaForValue(this.thresholdMax)):"sigma"===this.thresholdType&&"value"===e.thresholdType&&(this.thresholdMin=this.volume.getValueForSigma(this.thresholdMin),this.thresholdMax=this.volume.getValueForSigma(this.thresholdMax)),this.thresholdType=e.thresholdType),e&&void 0!==e.radiusType&&("radius"===e.radiusType?this.radius=.1:this.radius=parseFloat(e.radiusType),t.radius=!0,"sphere"!==this.dotType||el&&!this.disableImpostor||(i=!0)),e&&void 0!==e.radius&&(t.radius=!0,"sphere"!==this.dotType||el&&!this.disableImpostor||(i=!0)),e&&void 0!==e.scale&&(t.scale=!0,"sphere"!==this.dotType||el&&!this.disableImpostor||(i=!0)),super.setParameters(e,t,i),this}}ul.add("shader/Image.vert","uniform float clipRadius;\nuniform vec3 clipCenter;\nvarying vec2 vUv;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvarying vec3 vViewPosition;\n#endif\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\nvoid main() {\n#include begin_vertex\n#include project_vertex\nvUv = uv;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvViewPosition = -mvPosition.xyz;\n#endif\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n}"),ul.add("shader/Image.frag","uniform sampler2D map;\nuniform float opacity;\nuniform vec2 mapSize;\nuniform float clipNear;\nuniform float clipRadius;\nvarying vec2 vUv;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvarying vec3 vViewPosition;\n#endif\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#if defined( PICKING )\nuniform sampler2D pickingMap;\nuniform float objectId;\n#else\n#include fog_pars_fragment\n#endif\n#if defined( CUBIC_INTERPOLATION )\n#if defined( CATMULROM_FILTER ) || defined( MITCHELL_FILTER )\n#if defined( CATMULROM_FILTER )\nconst float B = 0.0;\nconst float C = 0.5;\n#elif defined( MITCHELL_FILTER )\nconst float B = 0.333;\nconst float C = 0.333;\n#endif\nfloat filter( float x ){\nfloat f = x;\nif( f < 0.0 ){\nf = -f;\n}\nif( f < 1.0 ){\nreturn ( ( 12.0 - 9.0 * B - 6.0 * C ) * ( f * f * f ) +\n( -18.0 + 12.0 * B + 6.0 *C ) * ( f * f ) +\n( 6.0 - 2.0 * B ) ) / 6.0;\n}else if( f >= 1.0 && f < 2.0 ){\nreturn ( ( -B - 6.0 * C ) * ( f * f * f )\n+ ( 6.0 * B + 30.0 * C ) * ( f *f ) +\n( - ( 12.0 * B ) - 48.0 * C ) * f +\n8.0 * B + 24.0 * C ) / 6.0;\n}else{\nreturn 0.0;\n}\n}\n#elif defined( BSPLINE_FILTER )\nfloat filter( float x ){\nfloat f = x;\nif( f < 0.0 ){\nf = -f;\n}\nif( f >= 0.0 && f <= 1.0 ){\nreturn ( 2.0 / 3.0 ) + ( 0.5 ) * ( f * f * f ) - ( f * f );\n}else if( f > 1.0 && f <= 2.0 ){\nreturn 1.0 / 6.0 * pow( ( 2.0 - f ), 3.0 );\n}\nreturn 1.0;\n}\n#else\nfloat filter( float x ){\nreturn 1.0;\n}\n#endif\nvec4 biCubic( sampler2D tex, vec2 texCoord ){\nvec2 texelSize = 1.0 / mapSize;\ntexCoord -= texelSize / 2.0;\nvec4 nSum = vec4( 0.0 );\nfloat nDenom = 0.0;\nvec2 cell = fract( texCoord * mapSize );\nfor( float m = -1.0; m <= 2.0; ++m ){\nfor( float n = -1.0; n <= 2.0; ++n ){\nvec4 vecData = texture2D(\ntex, texCoord + texelSize * vec2( m, n )\n);\nfloat c = filter( m - cell.x ) * filter( -n + cell.y );\nnSum += vecData * c;\nnDenom += c;\n}\n}\nreturn nSum / nDenom;\n}\n#endif\nvoid main(){\n#include nearclip_fragment\n#include radiusclip_fragment\n#if defined( CUBIC_INTERPOLATION )\ngl_FragColor = biCubic( map, vUv );\n#else\ngl_FragColor = texture2D( map, vUv );\n#endif\n#if defined( PICKING )\nif( gl_FragColor.a < 0.3 )\ndiscard;\ngl_FragColor = vec4( texture2D( pickingMap, vUv ).xyz, objectId );\n#else\nif( gl_FragColor.a < 0.01 )\ndiscard;\ngl_FragColor.a *= opacity;\n#include fog_fragment\n#endif\n}");const ag=new Uint16Array([0,1,2,1,3,2]),cg=new Float32Array([0,1,0,0,1,1,1,0]),lg=Object.assign({filter:"nearest",forceTransparent:!0},em),hg=Object.assign({filter:{updateShader:!0,uniform:!0}},tm);class ug extends im{constructor(e,t){super({position:e.position,index:ag,picking:e.picking},t),this.parameterTypes=hg,this.alwaysTransparent=!0,this.hasWireframe=!1,this.vertexShader="Image.vert",this.fragmentShader="Image.frag";const{imageData:i,width:n,height:r}=e,s=new Ar(i,n,r);s.flipY=!0,this.tex=s;const o=i.length,a=new Uint8Array(o);for(let e=0;e>16&255,a[e+1]=t>>8&255,a[e+2]=255&t}const c=new Ar(a,n,r);c.flipY=!0,c.minFilter=re,c.magFilter=re,this.pickingTex=c,this.addUniforms({map:{value:s},pickingMap:{value:c},mapSize:{value:new zt(n,r)}}),this.geometry.setAttribute("uv",new An(cg,2))}get defaultParameters(){return lg}getDefines(e){const t=super.getDefines(e),i=this.parameters.filter;return i.startsWith("cubic")&&(t.CUBIC_INTERPOLATION=1,i.endsWith("bspline")?t.BSPLINE_FILTER=1:i.endsWith("catmulrom")?t.CATMULROM_FILTER=1:i.endsWith("mitchell")&&(t.MITCHELL_FILTER=1)),t}updateTexture(){const e=this.tex,t=this.parameters.filter;t.startsWith("cubic")?(e.minFilter=re,e.magFilter=re):"linear"===t?(e.minFilter=ae,e.magFilter=ae):(e.minFilter=re,e.magFilter=re),e.needsUpdate=!0,this.pickingTex.needsUpdate=!0}makeMaterial(){super.makeMaterial(),this.updateTexture();const e=this.material;e.uniforms.map.value=this.tex,e.blending=u,e.needsUpdate=!0;const t=this.wireframeMaterial;t.uniforms.map.value=this.tex,t.blending=u,t.needsUpdate=!0;const i=this.pickingMaterial;i.uniforms.map.value=this.tex,i.uniforms.pickingMap.value=this.pickingTex,i.blending=u,i.needsUpdate=!0}setUniforms(e){e&&void 0!==e.filter&&(this.updateTexture(),e.map=this.tex),super.setUniforms(e)}}class dg{constructor(e,t){const i=t||{};this.dimension=Ia(i.dimension,"x"),this.positionType=Ia(i.positionType,"percent"),this.position=Ia(i.position,30),this.thresholdType=Ia(i.thresholdType,"sigma"),this.thresholdMin=Ia(i.thresholdMin,-1/0),this.thresholdMax=Ia(i.thresholdMax,1/0),this.normalize=Ia(i.normalize,!1),this.volume=e}getPositionFromCoordinate(e){const t=this.dimension,i=this.volume,n=i.matrix,r=(new Zt).setFromMatrixPosition(n)[t],s=(new Zt).setFromMatrixScale(n)[t];let o;return o="x"===t?i.nx:"y"===t?i.ny:i.nz,Math.round(((e-r)/(o/100)+1)/s)}getData(e){e=e||{};const t=this.volume,i=t.data,n=t.matrix;let r;function s(e){return Math.round(e/100*(r-1))}function o(e,i,n,r){return 3*(n*t.ny*t.nx+i*t.nx+e)+r}r="coordinate"===this.positionType?this.getPositionFromCoordinate(this.position):this.position;const a=new Float32Array(12),c=new Zt;let l,h,u,d,f,m=0,p=0,g=0,v=t.nx,y=t.ny,x=t.nz;function b(e,t,i,r){c.set(e,t,i).applyMatrix4(n).toArray(a,r)}"x"===this.dimension?(u=s(t.nx),d=t.ny-1,f=t.nz-1,l=t.nz,h=t.ny,m=u,v=m+1,b(u,0,0,0),b(u,d,0,3),b(u,0,f,6),b(u,d,f,9)):"y"===this.dimension?(u=t.nx-1,d=s(t.ny),f=t.nz-1,l=t.nz,h=t.nx,p=d,y=p+1,b(0,d,0,0),b(u,d,0,3),b(0,d,f,6),b(u,d,f,9)):"z"===this.dimension&&(u=t.nx-1,d=t.ny-1,f=s(t.nz),l=t.nx,h=t.ny,g=f,x=g+1,b(0,0,f,0),b(0,d,f,3),b(u,0,f,6),b(u,d,f,9));let _=0,w=0;const S=new Uint8Array(l*h*4),A=new Float32Array(l*h);let M,C;"sigma"===this.thresholdType?(M=t.getValueForSigma(this.thresholdMin),C=t.getValueForSigma(this.thresholdMax)):(M=this.thresholdMin,C=this.thresholdMax);const P=Object.assign({},e.colorParams,{volume:t});this.normalize&&(P.domain=[0,1]);const T=al.getScheme(P),I=new Float32Array(3),E=T.getScale();let D,L=0,R=0;if(this.normalize){L=1/0,D=-1/0;for(let e=p;eD&&(D=r)}R=D-L}for(let e=p;eM&&s{this.viewer.add(e)})),this.setVisibility(this.visible),e()}create(){const e=new dg(this.volume,{positionType:this.positionType,position:this.position,dimension:this.dimension,thresholdType:this.thresholdType,thresholdMin:this.thresholdMin,thresholdMax:this.thresholdMax,normalize:this.normalize}),t=new ug(e.getData({colorParams:this.getColorParams()}),this.getBufferParams({filter:this.filter}));this.bufferList.push(t)}}function mg(e){il.error(`makeRepresentation: representation type ${e} unknown`)}const pg={name:"some element",status:""};class gg{constructor(e,t={}){this.stage=e,this.signals={statusChanged:new mc.Signal,nameChanged:new mc.Signal,disposed:new mc.Signal},this.parameters=Ea(t,this.defaultParameters),this.uuid=ec()}get defaultParameters(){return pg}get name(){return this.parameters.name}setStatus(e){return this.parameters.status=e,this.signals.statusChanged.dispatch(e),this}setName(e){return this.parameters.name=e,this.signals.nameChanged.dispatch(e),this}dispose(){this.signals.disposed.dispatch()}}const vg=Object.assign({visible:!0},pg);class yg extends gg{constructor(e,t,i={},n){super(e,Object.assign({name:t.type},i)),this.parent=n,this.signals=Object.assign({visibilityChanged:new mc.Signal,parametersChanged:new mc.Signal},this.signals),this.setRepresentation(t)}get defaultParameters(){return vg}get visible(){return this.parameters.visible}get type(){return"representation"}getType(){return this.repr.type}setRepresentation(e){this._disposeRepresentation(),this.repr=e,this.stage.tasks.listen(this.repr.tasks),this.updateVisibility()}_disposeRepresentation(){this.repr&&(this.stage.tasks.unlisten(this.repr.tasks),this.repr.dispose())}dispose(){this.parent&&this.parent.hasRepresentation(this)?this.parent.removeRepresentation(this):(this._disposeRepresentation(),this.signals.disposed.dispatch())}setVisibility(e){return this.parameters.visible=e,this.updateVisibility(),this.signals.visibilityChanged.dispatch(this.parameters.visible),this}getVisibility(){return this.parent?this.parent.parameters.visible&&this.parameters.visible:this.parameters.visible}toggleVisibility(){return this.setVisibility(!this.parameters.visible)}updateVisibility(){this.repr.setVisibility(this.getVisibility())}update(e){return this.repr.update(e),this}build(e){return this.repr.build(e),this}setSelection(e){const t=this.repr;return t.setSelection&&t.setSelection(e),this}setParameters(e){return this.repr.setParameters(e),this.signals.parametersChanged.dispatch(this.repr.getParameters()),this}getParameters(){return this.repr.getParameters()}setColor(e){return this.repr.setColor(e),this}}const xg=new ri,bg=new Zt,_g={name:"",status:"",visible:!0};class wg{constructor(e,t,i={}){this.stage=e,this.object=t,this.signals={representationAdded:new mc.Signal,representationRemoved:new mc.Signal,visibilityChanged:new mc.Signal,matrixChanged:new mc.Signal,statusChanged:new mc.Signal,nameChanged:new mc.Signal,disposed:new mc.Signal},this.reprList=[],this.annotationList=[],this.matrix=new ri,this.position=new Zt,this.quaternion=new qt,this.scale=new Zt(1,1,1),this.transform=new ri,this.parameters=Ea(i,this.defaultParameters),this.uuid=ec(),this.viewer=e.viewer,this.controls=new Cm(this)}get defaultParameters(){return _g}get name(){return this.parameters.name}get status(){return this.parameters.status}get visible(){return this.parameters.visible}setPosition(e){return Array.isArray(e)?this.position.fromArray(e):this.position.copy(e),this.updateMatrix(),this}setRotation(e){if(Array.isArray(e))if(3===e.length){const t=(new ai).fromArray(e);this.quaternion.setFromEuler(t)}else this.quaternion.fromArray(e);else e instanceof ai?this.quaternion.setFromEuler(e):this.quaternion.copy(e);return this.updateMatrix(),this}setScale(e){return this.scale.set(e,e,e),this.updateMatrix(),this}setTransform(e){return this.transform.copy(e),this.updateMatrix(),this}updateMatrix(){const e=this.getCenterUntransformed(bg);this.matrix.makeTranslation(-e.x,-e.y,-e.z),xg.makeRotationFromQuaternion(this.quaternion),this.matrix.premultiply(xg),xg.makeScale(this.scale.x,this.scale.y,this.scale.z),this.matrix.premultiply(xg);const t=this.position;xg.makeTranslation(t.x+e.x,t.y+e.y,t.z+e.z),this.matrix.premultiply(xg),this.matrix.premultiply(this.transform),this.updateRepresentationMatrices(),this.stage.viewer.updateBoundingBox(),this.signals.matrixChanged.dispatch(this.matrix)}updateRepresentationMatrices(){this.reprList.forEach((e=>{e.setParameters({matrix:this.matrix})}))}addAnnotation(e,t,i){const n=new wm(this,e,t,i);return this.annotationList.push(n),n}eachAnnotation(e){this.annotationList.slice().forEach(e)}removeAnnotation(e){const t=this.annotationList.indexOf(e);-1!==t&&(this.annotationList.splice(t,1),e.dispose())}removeAllAnnotations(){this.eachAnnotation((e=>e.dispose())),this.annotationList.length=0}_addRepresentation(t,i,n,r=!1){const s=n||{},o=this.stage.getParameters();s.matrix=this.matrix.clone(),s.quality=s.quality||o.quality,s.disableImpostor=Ia(s.disableImpostor,!o.impostor),s.useWorker=Ia(s.useWorker,o.workerDefault),s.visible=Ia(s.visible,!0);const a=Object.assign({},s,{visible:this.parameters.visible&&s.visible}),c=function(t,i,n,r){var s;if(e.Debug&&il.time("makeRepresentation "+t),i instanceof Fp){if(!(s=ll.get(t)))return void mg(t)}else if(i instanceof Xf)if("surface"===t)s=lm;else{if("dot"!==t)return void mg(t);s=og}else if(i instanceof Zf)if("surface"===t)s=lm;else if("dot"===t)s=og;else{if("slice"!==t)return void mg(t);s=fg}else if(i instanceof Gp)s=Vp,i=i.getBufferList();else{if("buffer"!==t)return void il.error("makeRepresentation: object "+i+" unknown");s=Vp}const o=new s(i,n,r);return e.Debug&&il.timeEnd("makeRepresentation "+t),o}(t,i,this.viewer,a),l=new yg(this.stage,c,s,this);return r||(this.reprList.push(l),this.signals.representationAdded.dispatch(l)),l}addBufferRepresentation(e,t){return this._addRepresentation.call(this,"buffer",e,t)}hasRepresentation(e){return-1!==this.reprList.indexOf(e)}eachRepresentation(e){this.reprList.slice().forEach(e)}removeRepresentation(e){const t=this.reprList.indexOf(e);-1!==t&&(this.reprList.splice(t,1),e.dispose(),this.signals.representationRemoved.dispatch(e))}updateRepresentations(e){this.reprList.forEach((t=>t.update(e))),this.stage.viewer.requestRender()}removeAllRepresentations(){this.eachRepresentation((e=>e.dispose()))}dispose(){this.removeAllAnnotations(),this.removeAllRepresentations(),this.reprList.length=0,this.signals.disposed.dispatch()}setVisibility(e){return this.parameters.visible=e,this.eachRepresentation((e=>e.updateVisibility())),this.eachAnnotation((e=>e.updateVisibility())),this.signals.visibilityChanged.dispatch(e),this}setStatus(e){return this.parameters.status=e,this.signals.statusChanged.dispatch(e),this}setName(e){return this.parameters.name=e,this.signals.nameChanged.dispatch(e),this}getBox(...e){return this.getBoxUntransformed(...e).clone().applyMatrix4(this.matrix)}getCenter(...e){return this.getCenterUntransformed(...e).clone().applyMatrix4(this.matrix)}getZoom(...e){return this.stage.getZoomForBox(this.getBox(...e))}getBoxUntransformed(...e){return new Ni}getCenterUntransformed(...e){return this.getBoxUntransformed().getCenter(new Zt)}autoView(e){this.stage.animationControls.zoomMove(this.getCenter(),this.getZoom(),Ia(e,0))}}class Sg{constructor(e=[]){this.list=e;const t=e.length;for(let i=0;i0?this.list[0]:void 0}forEach(e){return this.list.forEach(e),this}dispose(){return this.forEach((e=>e.dispose()))}}class Ag extends Sg{setParameters(e){return this.forEach((t=>t.setParameters(e)))}setVisibility(e){return this.forEach((t=>t.setVisibility(e)))}setSelection(e){return this.forEach((t=>t.setSelection(e)))}setColor(e){return this.forEach((t=>t.setColor(e)))}update(e){return this.forEach((t=>t.update(e)))}build(e){return this.forEach((t=>t.build(e)))}dispose(e){return this.forEach((e=>e.dispose()))}}const Mg=Object.assign({defaultStep:1,defaultTimeout:50,defaultInterpolateType:"",defaultInterpolateStep:5,defaultMode:"loop",defaultDirection:"forward",initialFrame:0},pg);class Cg extends gg{constructor(e,t,i={}){super(e,Object.assign({name:t.name},i)),this.trajectory=t,this.signals=Object.assign(this.signals,{frameChanged:new mc.Signal,playerChanged:new mc.Signal,countChanged:new mc.Signal,parametersChanged:new mc.Signal}),t.signals.frameChanged.add((e=>{this.signals.frameChanged.dispatch(e)})),t.signals.playerChanged.add((e=>{this.signals.playerChanged.dispatch(e)})),t.signals.countChanged.add((e=>{this.signals.countChanged.dispatch(e)})),void 0!==i.initialFrame&&this.setFrame(i.initialFrame)}get defaultParameters(){return Mg}get type(){return"trajectory"}setFrame(e){this.trajectory.setFrame(e)}setParameters(e={}){this.trajectory.setParameters(e),this.signals.parametersChanged.dispatch(e)}dispose(){this.trajectory.dispose(),super.dispose()}}class Pg{constructor(e,t){this.name=e,this.path=t,this.coordinates=[],this.boxes=[],this.times=[],this.timeOffset=0,this.deltaTime=1}get type(){return"Frames"}}class Tg{constructor(e,t){let i,n;if(this.A=new Mf(3,3),this.W=new Mf(1,3),this.U=new Mf(3,3),this.V=new Mf(3,3),this.VH=new Mf(3,3),this.R=new Mf(3,3),this.tmp=new Mf(3,3),this.c=new Mf(3,3),e instanceof Fp)i=e.atomCount;else{if(!(e instanceof Float32Array))return;i=e.length/3}if(t instanceof Fp)n=t.atomCount;else{if(!(t instanceof Float32Array))return;n=t.length/3}const r=Math.min(i,n),s=new Mf(3,r),o=new Mf(3,r);this.coords1t=new Mf(r,3),this.coords2t=new Mf(r,3),this.transformationMatrix=new ri,this.c.data.set([1,0,0,0,1,0,0,0,-1]),this.prepCoords(e,s,r,!1),this.prepCoords(t,o,r,!1),this._superpose(s,o)}_superpose(t,i){this.mean1=If(t),this.mean2=If(i),Ef(t,this.mean1),Ef(i,this.mean2),Cf(this.coords1t,t),Cf(this.coords2t,i),Pf(this.A,this.coords2t,this.coords1t),Of(this.A,this.W,this.U,this.V),function(e,t){const i=e.data,n=t.data,r=i[4],s=i[8],o=i[5],a=i[7],c=i[0],l=c*r,h=c*o,u=i[3],d=i[1],f=u*d,m=i[2],p=u*m,g=i[6],v=g*d,y=g*m,x=1/(l*s-h*a-f*s+p*a+v*o-y*r);n[0]=(r*s-o*a)*x,n[1]=-(d*s-m*a)*x,n[2]=-(-d*o+m*r)*x,n[3]=-(u*s-o*g)*x,n[4]=(c*s-y)*x,n[5]=-(h-p)*x,n[6]=-(-u*a+r*g)*x,n[7]=-(c*a-v)*x,n[8]=(l-f)*x}(this.V,this.VH),Tf(this.R,this.U,this.VH),function(e){const t=e.data;return t[0]*t[4]*t[8]-t[0]*t[5]*t[7]-t[3]*t[1]*t[8]+t[3]*t[2]*t[7]+t[6]*t[1]*t[5]-t[6]*t[2]*t[4]}(this.R)<0&&(e.Debug&&il.log("R not a right handed system"),Tf(this.tmp,this.c,this.VH),Tf(this.R,this.U,this.tmp));const n=new Mf(4,4),r=new Mf(4,4),s=new Mf(4,4),o=new Mf(4,4),a=new Mf(4,4),c=new Mf(4,4),l=this.R.data,h=this.mean1,u=this.mean2;o.data.set([1,0,0,-h[0],0,1,0,-h[1],0,0,1,-h[2],0,0,0,1]),a.data.set([l[0],l[1],l[2],0,l[3],l[4],l[5],0,l[6],l[7],l[8],0,0,0,0,1]),c.data.set([1,0,0,u[0],0,1,0,u[1],0,0,1,u[2],0,0,0,1]),Cf(r,o),Pf(n,a,r),Cf(s,n),Pf(r,c,s),Cf(n,r),this.transformationMatrix.elements=n.data}prepCoords(e,t,i,n){let r=0;const s=t.data;let o=3,a=3*i;if(n&&(a=4*i,o=4),e instanceof Fp)e.eachAtom((function(e){r{e!==this&&this.pause()}),this);const i=Ia(e.frameCount,1);this.traj=e,this.parameters=Ea(t,Ig),this.parameters.end=Math.min(Ia(t.end,i-1),i-1),this.parameters.step=Ia(t.step,Math.ceil((i+1)/100)),this._currentFrame=this.parameters.start,this._direction="bounce"===this.parameters.direction?"forward":this.parameters.direction,e.signals.countChanged.add((e=>{this.parameters.end=Math.min(Ia(this.parameters.end,e-1),e-1)}),this),this._animate=this._animate.bind(this)}get isRunning(){return this._run}setParameters(e={}){Da(this.parameters,e),void 0!==e.direction&&"bounce"!==this.parameters.direction&&(this._direction=this.parameters.direction)}_animate(){if(!this._run)return;this._currentTime=window.performance.now();const e=this._currentTime-this._previousTime,t=this.parameters.interpolateType?this.parameters.interpolateStep:1,i=this.parameters.timeout/t,n=this.traj;if(n&&n.frameCount&&!n.inProgress&&e>=i)if(this.parameters.interpolateType)if(this._currentStep>this.parameters.interpolateStep&&(this._currentStep=1),1===this._currentStep&&(this._currentFrame=this._nextInterpolated()),n.hasFrame(this._currentFrame)){this._currentStep+=1;const e=this._currentStep/(this.parameters.interpolateStep+1),[t,i,r,s]=this._currentFrame;n.setFrameInterpolated(t,i,r,s,e,this.parameters.interpolateType),this._previousTime=this._currentTime}else n.loadFrame(this._currentFrame);else{const e=this._next();n.hasFrame(e)?(n.setFrame(e),this._previousTime=this._currentTime):n.loadFrame(e)}window.requestAnimationFrame(this._animate)}_next(){const e=this.parameters;let t;return t="forward"===this._direction?this.traj.currentFrame+e.step:this.traj.currentFrame-e.step,(t>e.end||t=e.end?i=e.start:"backward"===e.direction&&t<=e.start&&(i=e.end),this.traj.setFrame(i),this._run=!0,this._animate(),this.signals.startedRunning.dispatch()}}pause(){this._run=!1,this.signals.haltedRunning.dispatch()}stop(){this.pause(),this.traj.setFrame(this.parameters.start)}}class Dg{constructor(e,t,i={}){this.signals={countChanged:new mc.Signal,frameChanged:new mc.Signal,playerChanged:new mc.Signal},this.frameCache={},this.loadQueue={},this.boxCache={},this.pathCache={},this.frameCacheSize=0,this._frameCount=0,this._currentFrame=-1,this._disposed=!1,this.deltaTime=Ia(i.deltaTime,0),this.timeOffset=Ia(i.timeOffset,0),this.centerPbc=Ia(i.centerPbc,!1),this.removePbc=Ia(i.removePbc,!1),this.removePeriodicity=Ia(i.removePeriodicity,!1),this.superpose=Ia(i.superpose,!1),this.name=e.replace(/^.*[\\/]/,""),this.trajPath=e,this.selection=new $c(Ia(i.sele,"backbone and not hydrogen")),this.selection.signals.stringChanged.add((()=>{this.selectionIndices=this.structure.getAtomIndices(this.selection),this._resetCache(),this._saveInitialCoords(),this.setFrame(this._currentFrame)}))}get frameCount(){return this._frameCount}get currentFrame(){return this._currentFrame}_init(e){this.setStructure(e),this._loadFrameCount(),this.setPlayer(new Eg(this))}_loadFrameCount(){}setStructure(e){this.structure=e,this.atomCount=e.atomCount,this.backboneIndices=this._getIndices(new $c("backbone and not hydrogen")),this._makeAtomIndices(),this._saveStructureCoords(),this.selectionIndices=this._getIndices(this.selection),this._resetCache(),this._saveInitialCoords(),this.setFrame(this._currentFrame)}_saveInitialCoords(){this.structure.hasCoords()?(this.initialCoords=new Float32Array(this.structureCoords),this._makeSuperposeCoords()):this.frameCache[0]?(this.initialCoords=new Float32Array(this.frameCache[0]),this._makeSuperposeCoords()):this.loadFrame(0,(()=>this._saveInitialCoords()))}_saveStructureCoords(){this.structureCoords=this.structure.getAtomData({what:{position:!0}}).position}setSelection(e){return this.selection.setString(e),this}_getIndices(e){let t=0;const i=e.test,n=[];return i&&this.structure.eachAtom((e=>{i(e)&&n.push(t),t+=1})),n}_makeSuperposeCoords(){const e=3*this.selectionIndices.length;this.coords1=new Float32Array(e),this.coords2=new Float32Array(e);const t=this.initialCoords,i=this.coords2;for(let n=0;n!!this.frameCache[e])):!!this.frameCache[e]}setFrame(e,t){return void 0===e||(this.inProgress=!0,-1===e||this.frameCache[e]?(this._updateStructure(e),t&&t()):this.loadFrame(e,(()=>{this._updateStructure(e),t&&t()}))),this}_interpolate(e,t,i,n,r,s){const o=this.frameCache;let a;a="spline"===s?function(e,t,i,n,r){const s=e.length,o=new Float32Array(s);for(let a=0;a{this._interpolate(e,t,i,n,r,s),o&&o()})):(this._interpolate(e,t,i,n,r,s),o&&o()),this}loadFrame(e,t){Array.isArray(e)?e.forEach((e=>{this.loadQueue[e]||this.frameCache[e]||(this.loadQueue[e]=!0,this._loadFrame(e,(()=>{delete this.loadQueue[e]})))})):this.loadQueue[e]||this.frameCache[e]||(this.loadQueue[e]=!0,this._loadFrame(e,(()=>{delete this.loadQueue[e],t&&t()})))}_loadFrame(e,t){il.error("Trajectory._loadFrame not implemented",e,t)}_updateStructure(e){this._disposed?console.error("updateStructure: traj disposed"):(-1===e?this.structureCoords&&this.structure.updatePosition(this.structureCoords):this.structure.updatePosition(this.frameCache[e]),this.structure.trajectory={name:this.trajPath,frame:e},this._currentFrame=e,this.inProgress=!1,this.signals.frameChanged.dispatch(e))}_doSuperpose(e){const t=3*this.selectionIndices.length,i=this.coords1,n=this.coords2;for(let n=0;n0&&this.centerPbc){const e=[t[0],t[4],t[8]],n=function(e,t,i){return[zl(t,i[0],3,0,e),zl(t,i[1],3,1,e),zl(t,i[2],3,2,e)]}(this.backboneIndices,i,e);!function(e,t,i){if(0===i[0]||0===i[8]||0===i[4])return;const n=e.length,r=i[0],s=i[1],o=i[2],a=-t[0]+r+r/2,c=-t[1]+s+s/2,l=-t[2]+o+o/2;for(let t=0;t.5&&(e[r+n]-=t[3*n+n]*Math.round(s))}}(i,t,e)}this.removePbc&&function(e,t){if(0===t[0]||0===t[8]||0===t[4])return;const i=e.length;for(let n=3;n.9*t[3*i+i])if(r>0)for(let r=0;r<3;++r)e[n+r]-=t[3*i+r];else for(let r=0;r<3;++r)e[n+r]+=t[3*i+r]}}(i,t)}this.selectionIndices.length>0&&this.coords1&&this.superpose&&this._doSuperpose(i),this.frameCache[e]=i,this.boxCache[e]=t,this.frameCacheSize+=1}_setFrameCount(e){e!==this._frameCount&&(this._frameCount=e,this.signals.countChanged.dispatch(e))}dispose(){this._resetCache(),this._disposed=!0,this.player&&this.player.stop()}setPlayer(e){this.player=e,this.signals.playerChanged.dispatch(e)}getFrameTime(e){return this.timeOffset+e*this.deltaTime}}class Lg extends Dg{constructor(e,t,i){const n=i||{};n.timeOffset=Ia(n.timeOffset,e.timeOffset),n.deltaTime=Ia(n.deltaTime,e.deltaTime),super("",t,n),this.name=e.name,this.path=e.path,this.frames=e.coordinates,this.boxes=e.boxes,this._init(t)}get type(){return"frames"}_makeAtomIndices(){"StructureView"===this.structure.type?this.atomIndices=this.structure.getAtomIndices():this.atomIndices=void 0}_loadFrame(e,t){let i;const n=this.frames[e];if(this.atomIndices){const e=this.atomIndices,t=e.length;i=new Float32Array(3*t);for(let r=0;r{const e=n.response;if(!e)return void il.error(`empty arrayBuffer for '${r}'`);const s=new Int32Array(e,0,1)[0],o=new Float32Array(e,8,9),a=new Float32Array(e,44);this._process(t,o,a,s),"function"==typeof i&&i()}),!1),n.send(s)}_loadFrameCount(){const t=new XMLHttpRequest,i=e.TrajectoryDatasource.getCountUrl(this.trajPath);t.open("GET",i,!0),t.addEventListener("load",(()=>{this._setFrameCount(parseInt(t.response))}),!1),t.send()}}class Og extends Dg{constructor(e,t,i){super("",t,i),this.requestCallback=e,this._init(t)}get type(){return"callback"}_makeAtomIndices(){const e=[];if("StructureView"===this.structure.type){const t=this.structure.getAtomIndices(),i=t.length;let n=t[0],r=t[0];for(let s=1;s{this._process(e,i,n,r),"function"==typeof t&&t()}),e,this.atomIndices)}_loadFrameCount(){this.requestCallback((e=>this._setFrameCount(e)))}}Fp.prototype.getView=function(e){return new Bg(this,e)};class Bg extends Fp{constructor(e,t){super(),this.structure=e,this.selection=t,this.center=new Zt,this.boundingBox=new Ni,this._bp=this.getBondProxy(),this._ap=this.getAtomProxy(),this._rp=this.getResidueProxy(),this._cp=this.getChainProxy(),this.selection&&this.selection.signals.stringChanged.add(this.refresh,this),this.structure.signals.refreshed.add(this.refresh,this),this.refresh()}init(){}get type(){return"StructureView"}get name(){return this.structure.name}get path(){return this.structure.path}get title(){return this.structure.title}get id(){return this.structure.id}get data(){return this.structure.data}get atomSetDict(){return this.structure.atomSetDict}get biomolDict(){return this.structure.biomolDict}get entityList(){return this.structure.entityList}get unitcell(){return this.structure.unitcell}get frames(){return this.structure.frames}get boxes(){return this.structure.boxes}get validation(){return this.structure.validation}get bondStore(){return this.structure.bondStore}get backboneBondStore(){return this.structure.backboneBondStore}get rungBondStore(){return this.structure.rungBondStore}get atomStore(){return this.structure.atomStore}get residueStore(){return this.structure.residueStore}get chainStore(){return this.structure.chainStore}get modelStore(){return this.structure.modelStore}get atomMap(){return this.structure.atomMap}get residueMap(){return this.structure.residueMap}get bondHash(){return this.structure.bondHash}get spatialHash(){return this.structure.spatialHash}get _hasCoords(){return this.structure._hasCoords}set _hasCoords(e){this.structure._hasCoords=e}refresh(){e.Debug&&il.time("StructureView.refresh"),this.atomSetCache={};const t=this.structure;if(this.selection.isAllSelection()&&t!==this&&t.atomSet&&t.bondSet){this.atomSet=t.atomSet.clone(),this.bondSet=t.bondSet.clone();for(let e in this.atomSetDict){const t=this.atomSetDict[e];this.atomSetCache["__"+e]=t.clone()}this.atomCount=t.atomCount,this.bondCount=t.bondCount,this.boundingBox.copy(t.boundingBox),this.center.copy(t.center)}else if(this.selection.isNoneSelection()&&t!==this&&t.atomSet&&t.bondSet){this.atomSet=new Yu(t.atomCount),this.bondSet=new Yu(t.bondCount);for(let e in this.atomSetDict)this.atomSetCache["__"+e]=new Yu(t.atomCount);this.atomCount=0,this.bondCount=0,this.boundingBox.makeEmpty(),this.center.set(0,0,0)}else{this.atomSet=this.getAtomSet(this.selection,!0),t.atomSet&&(this.atomSet=this.atomSet.intersection(t.atomSet)),this.bondSet=this.getBondSet();for(let e in this.atomSetDict){const t=this.atomSetDict[e];this.atomSetCache["__"+e]=t.makeIntersection(this.atomSet)}this.atomCount=this.atomSet.getSize(),this.bondCount=this.bondSet.getSize(),this.boundingBox=this.getBoundingBox(),this.center=this.boundingBox.getCenter(new Zt)}e.Debug&&il.timeEnd("StructureView.refresh"),this.signals.refreshed.dispatch()}setSelection(e){this.selection=e,this.refresh()}getSelection(e){const t=[];e&&e.string&&t.push(e.string);const i=this.structure.getSelection();i&&i.string&&t.push(i.string),this.selection&&this.selection.string&&t.push(this.selection.string);let n="";return t.length>0&&(n=`( ${t.join(" ) AND ( ")} )`),new $c(n)}getStructure(){return this.structure.getStructure()}eachBond(e,t){this.structure.eachBond(e,this.getSelection(t))}eachAtom(e,t){const i=this.getAtomProxy(),n=this.getAtomSet(t),r=this.atomStore.count;if(n.getSize()=this.V[n][r]?(i="S",this.score=this.S[n][r]):this.V[n][r]>=this.H[n][r]?(i="V",this.score=this.V[n][r]):(i="H",this.score=this.H[n][r]),e.Debug&&il.log("Alignment: SCORE",this.score),e.Debug&&il.log("Alignment: S, V, H",this.S[n][r],this.V[n][r],this.H[n][r]);n>0&&r>0;)"S"===i?this.S[n][r]===this.S[n-1][r-1]+t(n-1,r-1)?(this.ali1=this.seq1[n-1]+this.ali1,this.ali2=this.seq2[r-1]+this.ali2,--n,--r,i="S"):this.S[n][r]===this.V[n][r]?i="V":this.S[n][r]===this.H[n][r]?i="H":(--n,--r):"V"===i?this.V[n][r]===this.V[n-1][r]+this.gapExtensionPenalty?(this.ali1=this.seq1[n-1]+this.ali1,this.ali2="-"+this.ali2,--n,i="V"):this.V[n][r]===this.S[n-1][r]+this.gap(0)?(this.ali1=this.seq1[n-1]+this.ali1,this.ali2="-"+this.ali2,--n,i="S"):--n:"H"===i?this.H[n][r]===this.H[n][r-1]+this.gapExtensionPenalty?(this.ali1="-"+this.ali1,this.ali2=this.seq2[r-1]+this.ali2,--r,i="H"):this.H[n][r]===this.S[n][r-1]+this.gap(0)?(this.ali1="-"+this.ali1,this.ali2=this.seq2[r-1]+this.ali2,--r,i="S"):--r:il.error("Alignment: no matrix");for(;n>0;)this.ali1=this.seq1[n-1]+this.ali1,this.ali2="-"+this.ali2,--n;for(;r>0;)this.ali1="-"+this.ali1,this.ali2=this.seq2[r-1]+this.ali2,--r;e.Debug&&il.timeEnd("Alignment.trace"),e.Debug&&il.log([this.ali1,this.ali2])}}function $g(e,t,i=!1,n="",r=""){let s,o,a,c,l;if(i){let i=e,h=t;n&&r&&(i=e.getView(new $c(n)),h=t.getView(new $c(r)));const u=i.getSequence(),d=h.getSequence(),f=new Ug(u.join(""),d.join(""));let m,p;f.calc(),f.trace(),s=0,o=0,a=f.ali1.length;const g=[],v=[];for(let e=0;ee[t]))}}}(),this.spacefillRepresentation=this.addRepresentation("spacefill",{sele:"none",opacity:nl.opacity,color:nl.color,disablePicking:!0,radiusType:"data"},!0),this.distanceRepresentation=this.addRepresentation("distance",nl,!0),this.angleRepresentation=this.addRepresentation("angle",nl,!0),this.dihedralRepresentation=this.addRepresentation("dihedral",nl,!0),this.measureRepresentations=new Ag([this.spacefillRepresentation,this.distanceRepresentation,this.angleRepresentation,this.dihedralRepresentation]),this.setDefaultAssembly(this.parameters.defaultAssembly),this.structure.signals.refreshed.add((()=>{this.updateRepresentations({position:!0})}))}get defaultParameters(){return Gg}get type(){return"structure"}initSelection(e){this.selection=new $c(e),this.structureView=new Bg(this.structure,this.selection),this.selection.signals.stringChanged.add((()=>{this.structureView.setSelection(this.selection),this.rebuildRepresentations(),this.rebuildTrajectories()}))}setSelection(e){return this.parameters.sele=e,this.selection.setString(e),this}setDefaultAssembly(e){if(void 0===this.structure.biomolDict[e]&&(e=""),this.parameters.defaultAssembly!==e){const t={defaultAssembly:e};this.reprList.forEach((e=>e.setParameters(t))),this.measureRepresentations.setParameters(t),this.parameters.defaultAssembly=e,this.signals.defaultAssemblyChanged.dispatch(e)}return this}rebuildRepresentations(){this.reprList.forEach((e=>{e.build()})),this.measureRepresentations.build()}rebuildTrajectories(){this.trajList.forEach((e=>{e.trajectory.setStructure(this.structureView)}))}updateRepresentations(e){super.updateRepresentations(e),this.measureRepresentations.update(e)}updateRepresentationMatrices(){super.updateRepresentationMatrices(),this.measureRepresentations.setParameters({matrix:this.matrix})}addRepresentation(e,t={},i=!1){t.defaultAssembly=this.parameters.defaultAssembly;const n=this._addRepresentation(e,this.structureView,t,i);return i||n.signals.parametersChanged.add((()=>this.measureUpdate())),n}addTrajectory(e="",t={}){const i=function(e,t,i){let n;return n=e&&e instanceof Pg?new Lg(e,t,i):!e&&t.frames?new Rg(e,t,i):e&&"function"==typeof e?new Og(e,t,i):new kg(e,t,i),n}(e,this.structureView,t),n=new Cg(this.stage,i,t);return this.trajList.push(n),this.signals.trajectoryAdded.dispatch(n),n}removeTrajectory(e){const t=this.trajList.indexOf(e);-1!==t&&this.trajList.splice(t,1),e.dispose(),this.signals.trajectoryRemoved.dispatch(e)}dispose(){this.trajList.slice().forEach((e=>e.dispose())),this.trajList.length=0,this.structure.dispose(),this.measureRepresentations.dispose(),super.dispose()}autoView(e,t){"number"==typeof e&&(t=e,e=""),this.stage.animationControls.zoomMove(this.getCenter(e),this.getZoom(e),Ia(t,0))}getBoxUntransformed(e){let t;return t=e?this.structureView.getBoundingBox(new $c(e)):this.structureView.boundingBox,t}getCenterUntransformed(e){return e&&"string"==typeof e?this.structure.atomCenter(new $c(e)):this.structure.center}superpose(e,t,i,n){return $g(this.structureView,e.structureView,t,i,n),this.updateRepresentations({position:!0}),this}getMaxRepresentationRadius(e){let t=0;const i=this.structure.getAtomProxy(e);return this.eachRepresentation((e=>{if(e.getVisibility()){const n=e.repr;t=Math.max(n.getAtomRadius(i),t)}})),t}measurePick(e){const t=this.pickBuffer.count;if(this.lastPick===e.index&&t>=1){if(t>1){const e=this.pickBuffer.data,i=this.pickBuffer.data.sort();this.pickDict.has(i)?this.pickDict.del(i):this.pickDict.add(i,e),2===t?this.distanceRepresentation.setParameters({atomPair:this.pickDict.values.filter((e=>2===e.length))}):3===t?this.angleRepresentation.setParameters({atomTriple:this.pickDict.values.filter((e=>3===e.length))}):4===t&&this.dihedralRepresentation.setParameters({atomQuad:this.pickDict.values.filter((e=>4===e.length))})}this.pickBuffer.clear(),this.lastPick=void 0}else this.pickBuffer.has(e.index)||this.pickBuffer.push(e.index),this.lastPick=e.index;this.measureUpdate()}measureClear(){this.pickBuffer.clear(),this.lastPick=void 0,this.spacefillRepresentation.setSelection("none")}measureBuild(){const e=this.measureData();this.distanceRepresentation.setParameters({atomPair:e.distance}),this.angleRepresentation.setParameters({atomTriple:e.angle}),this.dihedralRepresentation.setParameters({atomQuad:e.dihedral})}measureUpdate(){const e=this.pickBuffer.data,t={};e.forEach((e=>{const i=Math.max(.1,this.getMaxRepresentationRadius(e));t[e]=i*(2.3-rc(.1,2,i))})),this.spacefillRepresentation.setSelection(e.length?"@"+e.join(","):"none"),e.length&&this.spacefillRepresentation.setParameters({radiusData:t})}measureData(){const e=this.pickDict.values;return{distance:e.filter((e=>2===e.length)),angle:e.filter((e=>3===e.length)),dihedral:e.filter((e=>4===e.length))}}removeAllMeasurements(e){const t=this.pickDict,i=t.values,n=function(e){i.filter((t=>t.length===e)).forEach((e=>t.del(e.slice().sort())))};(!e||1&e)&&n(2),(!e||2&e)&&n(3),(!e||4&e)&&n(4),this.measureBuild()}removeMeasurement(e){this.pickDict.del(e.slice().sort()),this.measureBuild()}addMeasurement(e){if(e.length<2||e.length>4)return;const t=e.slice().sort();this.pickDict.has(t)||this.pickDict.add(t,e),this.measureBuild()}}fl.add("structure",Vg),fl.add("structureview",Vg);class Hg extends wg{constructor(e,t,i={}){super(e,t,Object.assign({name:t.name},i)),this.surface=t}get type(){return"surface"}addRepresentation(e,t={}){return this._addRepresentation(e,this.surface,t)}getBoxUntransformed(){return this.surface.boundingBox}getCenterUntransformed(){return this.surface.center}dispose(){this.surface.dispose(),super.dispose()}}fl.add("surface",Hg);class jg extends wg{constructor(e,t,i={}){super(e,t,Object.assign({name:t.name},i)),this.volume=t}get type(){return"volume"}addRepresentation(e,t={}){return this._addRepresentation(e,this.volume,t)}getBoxUntransformed(){return this.volume.boundingBox}getCenterUntransformed(){return this.volume.center}dispose(){this.volume.dispose(),super.dispose()}}fl.add("volume",jg);class Wg extends Sg{addRepresentation(e,t){return this.forEach((i=>i.addRepresentation(e,t)))}autoView(e){return this.forEach((t=>t.autoView(e)))}}function qg(e,t){return e instanceof RegExp?null!==t.name.match(e):t.name===e}const Xg=new Zt,Yg={impostor:!0,quality:"medium",workerDefault:!0,sampleLevel:0,backgroundColor:"black",rotateSpeed:2,zoomSpeed:1.2,panSpeed:1,clipNear:0,clipFar:100,clipDist:10,clipMode:"scene",clipScale:"relative",fogNear:50,fogFar:100,cameraFov:40,cameraEyeSep:.3,cameraType:"perspective",lightColor:14540253,lightIntensity:1,ambientColor:14540253,ambientIntensity:.2,hoverTimeout:0,tooltip:!0,mousePreset:"default"};class Zg extends wg{constructor(e,t,i={}){super(e,t,Object.assign({name:t.name},i)),this.shape=t}get type(){return"shape"}addRepresentation(e,t={}){return this._addRepresentation(e,this.shape,t)}getBoxUntransformed(){return this.shape.boundingBox}getCenterUntransformed(){return this.shape.center}dispose(){this.shape.dispose(),super.dispose()}}function Kg(e,t,i,n){var r,s=arguments.length,o=s<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,n);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(o=(s<3?r(o):s>3?r(t,i,o):r(t,i))||o);return s>3&&o&&Object.defineProperty(t,i,o),o}fl.add("shape",Zg);class Qg extends dc{constructor(e){super(e),e.scale||(this.parameters.scale="rainbow",this.parameters.reverse=Ia(e.reverse,!0)),this.scalePerModel={},e.structure.eachModel((e=>{this.parameters.domain=[e.atomOffset,e.atomEnd],this.scalePerModel[e.index]=this.getScale()}))}atomColor(e){return this.scalePerModel[e.modelIndex](e.index)}}Kg([uc],Qg.prototype,"atomColor",null),al.add("atomindex",Qg);class Jg extends dc{constructor(e){if(super(e),e.scale||(this.parameters.scale="OrRd"),!e.domain){let t,i=1/0,n=-1/0;e.sele&&(t=new $c(e.sele)),e.structure.eachAtom((function(e){const t=e.bfactor;i=Math.min(i,t),n=Math.max(n,t)}),t),this.parameters.domain=[i,n]}this.bfactorScale=this.getScale()}atomColor(e){return this.bfactorScale(e.bfactor)}}Kg([uc],Jg.prototype,"atomColor",null),al.add("bfactor",Jg);class ev extends dc{constructor(e){super(e),this.chainidDictPerModel={},this.scalePerModel={},e.scale||(this.parameters.scale="Spectral"),e.structure.eachModel((e=>{let t=0;const i={};e.eachChain((function(e){void 0===i[e.chainid]&&(i[e.chainid]=t,t+=1)})),this.parameters.domain=[0,t-1],this.chainidDictPerModel[e.index]=i,this.scalePerModel[e.index]=this.getScale()}))}atomColor(e){const t=this.chainidDictPerModel[e.modelIndex];return this.scalePerModel[e.modelIndex](t[e.chainid])}}Kg([uc],ev.prototype,"atomColor",null),al.add("chainid",ev);class tv extends dc{constructor(e){super(e),this.scalePerModel={},e.scale||(this.parameters.scale="Spectral"),e.structure.eachModel((e=>{this.parameters.domain=[e.chainOffset,e.chainEnd],this.scalePerModel[e.index]=this.getScale()}))}atomColor(e){return this.scalePerModel[e.modelIndex](e.chainIndex)}}Kg([uc],tv.prototype,"atomColor",null),al.add("chainindex",tv);class iv extends dc{constructor(e){super(e),this.chainnameDictPerModel={},this.scalePerModel={},e.scale||(this.parameters.scale="Spectral"),e.structure.eachModel((e=>{let t=0;const i={};e.eachChain((function(e){void 0===i[e.chainname]&&(i[e.chainname]=t,t+=1)})),this.parameters.domain=[0,t-1],this.chainnameDictPerModel[e.index]=i,this.scalePerModel[e.index]=this.getScale()}))}atomColor(e){const t=this.chainnameDictPerModel[e.modelIndex];return this.scalePerModel[e.modelIndex](t[e.chainname])}}Kg([uc],iv.prototype,"atomColor",null),al.add("chainname",iv);class nv extends dc{constructor(e){super(e),this.rsrzDict={},this.rsccDict={},e.scale||(this.parameters.scale="RdYlBu"),this.rsrzScale=this.getScale({domain:[2,0]}),this.rsccScale=this.getScale({domain:[.678,1]});const t=e.structure.validation;t&&(this.rsrzDict=t.rsrzDict,this.rsccDict=t.rsccDict)}atomColor(e){let t=e.resno+"";e.inscode&&(t+="^"+e.inscode),e.chainname&&(t+=":"+e.chainname),t+="/"+e.modelIndex;const i=this.rsrzDict[t];if(void 0!==i)return this.rsrzScale(i);const n=this.rsccDict[t];return void 0!==n?this.rsccScale(n):9474192}}Kg([uc],nv.prototype,"atomColor",null),al.add("densityfit",nv);const rv={ARG:{CD:.1,CZ:.5,NE:-.1},ASN:{CG:.55,OD1:-.55},ASP:{CB:-.16,CG:.36,OD1:-.6,OD2:-.6},CYS:{CB:.19,SG:-.19},GLN:{CD:.55,OE1:-.55},GLU:{CD:.36,CG:-.16,OE1:-.6,OE2:-.6},HIS:{CB:.1,CD2:.2,CE1:.45,CG:.15,ND1:.05,NE2:.05},LYS:{CE:.25,NZ:.75},MET:{CE:.06,CG:.06,SD:-.12},PTR:{C:.55,CA:.1,CZ:.25,N:-.35,O:-.55,O1P:-.85,O2P:-.85,O3P:-.85,OG1:-1.1,P:1.4},SEP:{C:.55,CA:.1,CB:.25,N:-.35,O:-.55,O1P:-.85,O2P:-.85,O3P:-.85,OG1:-1.1,P:1.4},SER:{CB:.25,OG:-.25},THR:{CB:.25,OG1:-.25},TPO:{C:.55,CA:.1,CB:.25,N:-.35,O:-.55,OG1:-1.1,O1P:-.85,O2P:-.85,O3P:-.85,P:1.4},TRP:{CD1:.06,CD2:.1,CE2:-.04,CE3:-.03,CG:-.03,NE1:-.06},TYR:{CZ:.25,OH:-.25},backbone:{C:.55,O:-.55,N:-.35,CA:.1}};class sv extends dc{constructor(e){super(e),this.delta=new Zt,this.hCharges=[],e.scale||(this.parameters.scale="rwb"),e.domain||(this.parameters.domain=[-50,50]),this.scale=this.getScale(),this.charges=new Float32Array(e.structure.atomCount);const t=[];e.structure.eachAtom((e=>{var i;if(this.charges[e.index]=(null!==(i=e).partialCharge?i.partialCharge:i.isProtein()&&(rv[i.resname]&&rv[i.resname][i.atomname]||rv.backbone[i.atomname])||0)*e.occupancy,"N"===e.atomname){if(e.bondCount>=3)return;if(e.bondToElementCount(1))return;const i=function(e,t=new Zt){let i=!1,n=!1,r=!1;return t.set(2*e.x,2*e.y,2*e.z),e.eachBondedAtom((function(e){if(!i)return"H"===e.atomname?(t.set(e.x,e.y,e.z),void(i=!0)):void(n||"CA"!==e.atomname?r||"C"!==e.atomname||(r=!0,t.sub(e)):(t.sub(e),n=!0))})),i?t:n&&r?(t.normalize(),t.multiplyScalar(1.04),t.add(e),t):void 0}(e);void 0!==i&&(t.push(i),this.hCharges.push(.25*e.occupancy))}}));const i=e.structure.getBoundingBox();i.expandByScalar(1.04),this.hStore=function(e){const t=e.length,i=new Float32Array(t),n=new Float32Array(t),r=new Float32Array(t);for(let t=0;t{const r=t[e];0!==r&&(n+=r/i)})),this.hHash.eachWithin(e.x,e.y,e.z,12,((e,t)=>{const r=i[e];0!==r&&(n+=r/t)})),this.scale(332*n)}}Kg([uc],sv.prototype,"positionColor",null),al.add("electrostatic",sv);const ov={H:16777215,HE:14286847,LI:13402367,BE:12779264,B:16758197,C:9474192,N:3166456,O:16715021,F:9494608,NE:11789301,NA:11230450,MG:9109248,AL:12560038,SI:1578e4,P:16744448,S:16777008,CL:2093087,AR:8442339,K:9388244,CA:4062976,SC:15132390,TI:12567239,V:10921643,CR:9083335,MN:10255047,FE:14706227,CO:15765664,NI:5296208,CU:13140019,ZN:8224944,GA:12750735,GE:6721423,AS:12419299,SE:16752896,BR:10889513,KR:6076625,RB:7351984,SR:65280,Y:9764863,ZR:9756896,NB:7586505,MO:5551541,TC:3907230,RU:2396047,RH:687500,PD:27013,AG:12632256,CD:16767375,IN:10909043,SN:6717568,SB:10380213,TE:13924864,I:9699476,XE:9699476,CS:5707663,BA:51456,LA:7394559,CE:16777159,PR:14286791,ND:13107143,PM:10747847,SM:9437127,EU:6422471,GD:4587463,TB:3211207,DY:2097095,HO:65436,ER:58997,TM:54354,YB:48952,LU:43812,HF:5096191,TA:5089023,W:2200790,RE:2522539,OS:2516630,IR:1528967,PT:13684960,AU:16765219,HG:12105936,TL:10900557,PB:5724513,BI:10375093,PO:11230208,AT:7688005,RN:4358806,FR:4325478,RA:32e3,AC:7384058,TH:47871,PA:41471,U:36863,NP:33023,PU:27647,AM:5528818,CM:7888099,BK:9064419,CF:10565332,ES:11739092,FM:11739066,MD:11734438,NO:12389767,LR:13041766,RF:13369433,DB:13697103,SG:14221381,BH:14680120,HS:15073326,MT:15400998,DS:16777215,RG:16777215,CN:16777215,UUT:16777215,FL:16777215,UUP:16777215,LV:16777215,UUH:16777215,D:16777152,T:16777120};class av extends dc{constructor(e){e.value=Ia(e.value,ov.C),super(e)}atomColor(e){const t=e.element;return"C"===t?this.parameters.value:ov[t]||16777215}}Kg([uc],av.prototype,"atomColor",null),al.add("element",av);class cv extends dc{constructor(e){super(e),e.scale||(this.parameters.scale="Spectral"),e.domain||(this.parameters.domain=[0,e.structure.entityList.length-1]),this.entityindexScale=this.getScale()}atomColor(e){return this.entityindexScale(e.entityIndex)}}Kg([uc],cv.prototype,"atomColor",null),al.add("entityindex",cv);class lv extends dc{atomColor(e){const t=e.entity;switch(t?t.entityType:void 0){case 1:return 8374655;case 2:return 16629894;case 3:return 12496596;case 4:return 3697840;default:return 16777113}}}Kg([uc],lv.prototype,"atomColor",null),al.add("entitytype",lv);class hv extends dc{constructor(e){super(e),this.geoAtomDict={},this.geoDict={};const t=e.structure.validation;t&&(this.geoAtomDict=t.geoAtomDict,this.geoDict=t.geoDict)}atomColor(e){let t,i=e.resno+"";e.inscode&&(i+="^"+e.inscode),e.chainname&&(i+=":"+e.chainname),i+="/"+e.modelIndex;const n=this.geoAtomDict[i];if(void 0!==n){const i=n[e.atomname]||0;r=i,t=16843009*((r=(858993459&(r-=r>>1&1431655765))+(r>>2&858993459))+(r>>4)&252645135)>>24}else t=this.geoDict[i]||0;var r;return 0===t?2188972:1===t?16703627:2===t?16018755:t>=3?10813478:9474192}}Kg([uc],hv.prototype,"atomColor",null),al.add("geoquality",hv);class uv extends dc{constructor(e){super(e),this.resHF={},e.scale||(this.parameters.scale="RdYlGn");for(const e in md)this.resHF[e]=md[e][0];if(this.defaultResidueHydrophobicity=pd[0],!e.domain){let e=1/0,t=-1/0;for(const i in this.resHF){const n=this.resHF[i];e=Math.min(e,n),t=Math.max(t,n)}this.parameters.domain=[e,0,t]}this.hfScale=this.getScale()}atomColor(e){return this.hfScale(this.resHF[e.resname]||this.defaultResidueHydrophobicity)}}Kg([uc],uv.prototype,"atomColor",null),al.add("hydrophobicity",uv);class dv extends dc{constructor(e){super(e),e.scale||(this.parameters.scale="rainbow"),e.domain||(this.parameters.domain=[0,e.structure.modelStore.count]),this.modelindexScale=this.getScale()}atomColor(e){return this.modelindexScale(e.modelIndex)}}Kg([uc],dv.prototype,"atomColor",null),al.add("modelindex",dv);class fv extends dc{atomColor(e){switch(e.residueType.moleculeType){case 1:return 3697840;case 2:return 15729279;case 3:return 12496596;case 4:return 16629894;case 5:return 12540695;case 6:return 8374655;default:return 16777113}}}Kg([uc],fv.prototype,"atomColor",null),al.add("moleculetype",fv);class mv extends dc{constructor(e){super(e),e.scale||(this.parameters.scale="PuBu"),e.domain||(this.parameters.domain=[0,1]),this.occupancyScale=this.getScale()}atomColor(e){return this.occupancyScale(e.occupancy)}}Kg([uc],mv.prototype,"atomColor",null),al.add("occupancy",mv);class pv extends dc{constructor(e){super(e),e.scale||(this.parameters.scale="rwb"),e.domain||(this.parameters.domain=[-1,1]),this.partialchargeScale=this.getScale()}atomColor(e){return this.partialchargeScale(e.partialCharge||0)}}function gv(){return 16777215*Math.random()}Kg([uc],pv.prototype,"atomColor",null),al.add("partialcharge",pv);class vv extends dc{atomColor(){return gv()}volumeColor(){return gv()}positionColor(){return gv()}}Kg([uc],vv.prototype,"atomColor",null),Kg([uc],vv.prototype,"volumeColor",null),Kg([uc],vv.prototype,"positionColor",null),al.add("random",vv);class yv extends dc{constructor(e){super(e),this.rciDict={},e.scale||(this.parameters.scale="RdYlBu"),this.rciScale=this.getScale({domain:[.6,0]});const t=e.structure.validation;t&&(this.rciDict=t.rciDict)}atomColor(e){let t=`[${e.resname}]${e.resno}`;e.chainname&&(t+=":"+e.chainname);const i=this.rciDict[t];return void 0!==i?this.rciScale(i):9474192}}Kg([uc],yv.prototype,"atomColor",null),al.add("randomcoilindex",yv);class xv extends dc{constructor(e){super(e),this.scalePerChain={},e.scale||(this.parameters.scale="rainbow",this.parameters.reverse=Ia(e.reverse,!0)),e.structure.eachChain((e=>{this.parameters.domain=[e.residueOffset,e.residueEnd],this.scalePerChain[e.index]=this.getScale()}))}atomColor(e){return this.scalePerChain[e.chainIndex](e.residueIndex)}}Kg([uc],xv.prototype,"atomColor",null),al.add("residueindex",xv);const bv={ALA:9240460,ARG:124,ASN:16743536,ASP:10485826,CYS:16777072,GLN:16731212,GLU:6684672,GLY:16777215,HIS:7368959,ILE:19456,LEU:4546117,LYS:4671416,MET:12099650,PHE:5459026,PRO:5395026,SER:16740418,THR:12078080,TRP:5195264,TYR:9203788,VAL:16747775,ASX:16711935,GLX:16711935,ASH:16711935,GLH:16711935,A:14423100,G:3329330,I:10145074,X:8190976,C:16766720,T:4286945,U:4251856,D:35723,DA:14423100,DG:3329330,DI:10145074,DX:8190976,DC:16766720,DT:4286945,DU:4251856,DD:35723};class _v extends dc{atomColor(e){return bv[e.resname]||16711935}}Kg([uc],_v.prototype,"atomColor",null),al.add("resname",_v);const wv=16711808,Sv=10485888,Av=6291584,Mv=16762880,Cv=6324479,Pv=16777215,Tv=11403518,Iv=16580962,Ev=10921722;class Dv extends dc{constructor(e){super(e),this.residueProxy=e.structure.getResidueProxy()}atomColor(e){const t=e.sstruc,i=this.residueProxy;return"h"===t?wv:"g"===t?Sv:"i"===t?Av:"e"===t||"b"===t?Mv:"t"===t?Cv:(i.index=e.residueIndex,i.isDna()?Tv:i.isRna()?Iv:i.isSaccharide()?Ev:i.isProtein()||"s"===t||"l"===t?Pv:8421504)}}Kg([uc],Dv.prototype,"atomColor",null),al.add("sstruc",Dv);class Lv extends dc{constructor(e){var t,i;super(e),e.scale||(this.parameters.scale="rwb"),this.atomData=null===(t=this.parameters.data)||void 0===t?void 0:t.atomData,this.bondData=null===(i=this.parameters.data)||void 0===i?void 0:i.bondData,this.scale=this.getScale(this.parameters)}atomColor(e){var t;const i=null===(t=this.atomData)||void 0===t?void 0:t[e.index];return void 0!==i?this.scale(i):this.parameters.value}bondColor(e,t){var i;const n=null===(i=this.bondData)||void 0===i?void 0:i[e.index];return void 0!==n?this.scale(n):this.atomProxy?(this.atomProxy.index=t?e.atomIndex1:e.atomIndex2,this.atomColor(this.atomProxy)):this.parameters.value}}Kg([uc],Lv.prototype,"atomColor",null),Kg([uc],Lv.prototype,"bondColor",null),al.add("structuredata",Lv);class Rv extends dc{atomColor(){return this.parameters.value}bondColor(){return this.parameters.value}valueColor(){return this.parameters.value}volumeColor(){return this.parameters.value}}Kg([uc],Rv.prototype,"atomColor",null),Kg([uc],Rv.prototype,"bondColor",null),Kg([uc],Rv.prototype,"valueColor",null),Kg([uc],Rv.prototype,"volumeColor",null),al.add("uniform",Rv);class kv extends dc{constructor(e){super(e),this.valueScale=this.getScale()}volumeColor(e){return this.valueScale(this.parameters.volume.data[e])}}Kg([uc],kv.prototype,"volumeColor",null),al.add("value",kv);class Ov extends dc{constructor(e){super(e),this.vec=new Zt,this.valueScale=this.getScale()}positionColor(e){const t=this.parameters.volume;if(!t||!t.inverseMatrix)return this.parameters.value;const i=this.vec,n=t.data,r=t.nx,s=t.ny,o=r*s;i.copy(e),i.applyMatrix4(t.inverseMatrix);const a=Math.floor(i.x),c=Math.floor(i.y),l=Math.floor(i.z),h=(l*s+c)*r+a,u=h+1,d=h+r,f=h+o,m=d+1,p=f+1,g=d+o,v=g+1,y=n[h],x=n[u],b=n[d],_=n[f],w=n[m],S=n[p],A=n[g],M=n[v],C=i.x-a,P=i.y-c,T=i.z-l,I=ic(y,x,C),E=ic(_,S,C),D=ic(b,w,C),L=ic(A,M,C),R=ic(I,D,P),k=ic(E,L,P),O=ic(R,k,T);return this.valueScale(O)}}Kg([uc],Ov.prototype,"positionColor",null),al.add("volume",Ov);class Bv extends tu{constructor(e,t,i){const n=i||{};if(super(e,t,n),this.type="structure",this.parameters=Object.assign({radiusType:{type:"select",options:Tm.types},radiusData:{type:"hidden"},radiusSize:{type:"number",precision:3,max:10,min:.001},radiusScale:{type:"number",precision:3,max:10,min:.001},assembly:null,defaultAssembly:{type:"hidden"}},this.parameters),this.selection=new $c(n.sele),this.dataList=[],this.structure=e,this.structureView=this.structure.getView(this.selection),e.biomolDict){const t={default:"default","":e.unitcell?"AU":"FULL"};Object.keys(e.biomolDict).forEach((function(e){t[e]=e})),this.parameters.assembly={type:"select",options:t,rebuild:!0}}else this.parameters.assembly=null}get defaultScale(){return{vdw:1,covalent:1,bfactor:.01,sstruc:1}}init(e){const t=e||{};t.colorScheme=Ia(t.colorScheme,"element"),this.setRadius(t.radius,t),this.radiusType=Ia(t.radiusType,"vdw"),this.radiusData=Ia(t.radiusData,{}),this.radiusSize=Ia(t.radiusSize,1),this.radiusScale=Ia(t.radiusScale,1),this.assembly=Ia(t.assembly,"default"),this.defaultAssembly=Ia(t.defaultAssembly,""),"auto"===t.quality&&(t.quality=this.getQuality()),super.init(t),this.selection.signals.stringChanged.add((()=>{this.build()})),this.build()}setRadius(e,t){const i=Object.keys(Pm);return"string"==typeof e&&i.includes(e.toLowerCase())?t.radiusType=e:void 0!==e&&(t.radiusType="size",t.radiusSize=e),this}getAssembly(){const e="default"===this.assembly?this.defaultAssembly:this.assembly;return this.structure.biomolDict[e]}getQuality(){let e;const t=this.structureView,i=this.getAssembly();e=i?i.getAtomCount(t):t.atomCount,Kc&&(e*=4);return t.atomStore.count/t.residueStore.count<2&&(e*=10),e<15e3?"high":e<8e4?"medium":"low"}create(){if(0===this.structureView.atomCount)return;if(!this.structureView.hasCoords())return void(this.needsBuild=!0);this.needsBuild=!1;const e=this.getAssembly();if(e)e.partList.forEach(((e,t)=>{const i=e.getView(this.structureView);if(0===i.atomCount)return;const n=this.createData(i,t);n&&(n.sview=i,n.instanceList=e.getInstanceList(),this.dataList.push(n))}));else{const e=this.createData(this.structureView,0);e&&(e.sview=this.structureView,this.dataList.push(e))}}update(e){!this.lazy||this.visible?this.needsBuild?this.build():this.dataList.forEach((t=>{t.bufferList.length>0&&this.updateData(e,t)}),this):Object.assign(this.lazyProps.what,e)}updateData(e,t){this.build()}getColorParams(){return Object.assign(Object.assign({},super.getColorParams()),{structure:this.structure})}getRadiusParams(e){return{type:this.radiusType,scale:this.radiusScale,size:this.radiusSize,data:this.radiusData}}getAtomParams(e,t){return Object.assign({what:e,colorParams:this.getColorParams(),radiusParams:this.getRadiusParams()},t)}getBondParams(e,t){return Object.assign({what:e,colorParams:this.getColorParams(),radiusParams:this.getRadiusParams()},t)}getAtomRadius(e){if(this.structureView.atomSet.isSet(e.index)){return new Tm(this.getRadiusParams()).atomRadius(e)}return 0}setSelection(e,t){return this.selection.setString(e,t),this}setParameters(e,t={},i=!1){const n=e||{};return this.setRadius(n.radius,n),void 0===n.radiusType&&void 0===n.radiusData&&void 0===n.radiusSize&&void 0===n.radiusScale||(t.radius=!0,el&&!this.disableImpostor||(i=!0)),void 0!==n.defaultAssembly&&n.defaultAssembly!==this.defaultAssembly&&("default"===this.assembly&&void 0===n.assembly||"default"===n.assembly)&&(i=!0),super.setParameters(n,t,i),this}getParameters(){return Object.assign(super.getParameters(),{sele:this.selection?this.selection.string:void 0,defaultAssembly:this.defaultAssembly})}attach(e){const t=this.viewer,i=this.bufferList;this.dataList.forEach((function(e){e.bufferList.forEach((function(n){i.push(n),t.add(n,e.instanceList)}))})),this.setVisibility(this.visible),e()}clear(){this.dataList.length=0,super.clear()}dispose(){this.structureView.dispose(),super.dispose()}}class Nv extends Bv{constructor(e,t,i){super(e,t,i),this.n=0,this.parameters=Object.assign({labelVisible:{type:"boolean"},labelSize:{type:"number",precision:3,max:10,min:.001},labelColor:{type:"color"},labelFontFamily:{type:"select",options:{"sans-serif":"sans-serif",monospace:"monospace",serif:"serif"},buffer:"fontFamily"},labelFontStyle:{type:"select",options:{normal:"normal",italic:"italic"},buffer:"fontStyle"},labelFontWeight:{type:"select",options:{normal:"normal",bold:"bold"},buffer:"fontWeight"},labelsdf:{type:"boolean",buffer:"sdf"},labelXOffset:{type:"number",precision:1,max:20,min:-20,buffer:"xOffset"},labelYOffset:{type:"number",precision:1,max:20,min:-20,buffer:"yOffset"},labelZOffset:{type:"number",precision:1,max:20,min:-20,buffer:"zOffset"},labelAttachment:{type:"select",options:{"bottom-left":"bottom-left","bottom-center":"bottom-center","bottom-right":"bottom-right","middle-left":"middle-left","middle-center":"middle-center","middle-right":"middle-right","top-left":"top-left","top-center":"top-center","top-right":"top-right"},rebuild:!0},labelBorder:{type:"boolean",buffer:"showBorder"},labelBorderColor:{type:"color",buffer:"borderColor"},labelBorderWidth:{type:"number",precision:2,max:.3,min:0,buffer:"borderWidth"},labelBackground:{type:"boolean",rebuild:!0},labelBackgroundColor:{type:"color",buffer:"backgroundColor"},labelBackgroundMargin:{type:"number",precision:2,max:2,min:0,rebuild:!0},labelBackgroundOpacity:{type:"range",step:.01,max:1,min:0,buffer:"backgroundOpacity"},labelFixedSize:{type:"boolean",buffer:"fixedSize"},lineOpacity:{type:"range",min:0,max:1,step:.01},linewidth:{type:"integer",max:50,min:1,buffer:!0}},this.parameters,{flatShaded:null})}init(e){const t=e||{};this.labelVisible=Ia(t.labelVisible,!0),this.labelSize=Ia(t.labelSize,2),this.labelColor=Ia(t.labelColor,16777215),this.labelFontFamily=Ia(t.labelFontFamily,"sans-serif"),this.labelFontStyle=Ia(t.labelFontstyle,"normal"),this.labelFontWeight=Ia(t.labelFontWeight,"bold"),this.labelsdf=Ia(t.labelsdf,"Chrome"===Yc),this.labelXOffset=Ia(t.labelXOffset,0),this.labelYOffset=Ia(t.labelYOffset,0),this.labelZOffset=Ia(t.labelZOffset,.5),this.labelAttachment=Ia(t.labelAttachment,"bottom-left"),this.labelBorder=Ia(t.labelBorder,!1),this.labelBorderColor=Ia(t.labelBorderColor,"lightgrey"),this.labelBorderWidth=Ia(t.labelBorderWidth,.15),this.labelBackground=Ia(t.labelBackground,!1),this.labelBackgroundColor=Ia(t.labelBackgroundColor,"lightgrey"),this.labelBackgroundMargin=Ia(t.labelBackgroundMargin,.5),this.labelBackgroundOpacity=Ia(t.labelBackgroundOpacity,1),this.labelFixedSize=Ia(t.labelFixedSize,!1),this.lineOpacity=Ia(t.lineOpacity,1),this.linewidth=Ia(t.linewidth,2),super.init(t)}update(e){e.position?this.build():super.update(e)}updateData(e,t){const i={};if(e&&!e.labelSize||Object.assign(i,{size:Gl(this.n,this.labelSize)}),!e||e.labelColor){const e=new mn(this.labelColor);Object.assign(i,{color:Vl(this.n,e.r,e.g,e.b)})}this.textBuffer.setAttributes(i)}setParameters(e,t={},i=!1){return e&&e.labelSize&&(t.labelSize=!0),e&&(e.labelColor||0===e.labelColor)&&(t.labelColor=!0,i=!0),super.setParameters(e,t,i),e&&void 0!==e.opacity&&this.textBuffer.setParameters({opacity:1}),e&&void 0!==e.labelVisible&&this.setVisibility(this.visible),this}setVisibility(e,t){return super.setVisibility(e,!0),this.textBuffer&&this.textBuffer.setVisibility(this.labelVisible&&this.visible),t||this.viewer.requestRender(),this}getLabelBufferParams(e={}){return super.getBufferParams(Object.assign({fontFamily:this.labelFontFamily,fontStyle:this.labelFontStyle,fontWeight:this.labelFontWeight,sdf:this.labelsdf,xOffset:this.labelXOffset,yOffset:this.labelYOffset,zOffset:this.labelZOffset,attachment:this.labelAttachment,showBorder:this.labelBorder,borderColor:this.labelBorderColor,borderWidth:this.labelBorderWidth,showBackground:this.labelBackground,backgroundColor:this.labelBackgroundColor,backgroundMargin:this.labelBackgroundMargin,backgroundOpacity:this.labelBackgroundOpacity,fixedSize:this.labelFixedSize,disablePicking:!0,visible:this.labelVisible},e,{opacity:1}))}getAtomRadius(){return 0}}function Fv(e,t){const i=e.getAtomProxy(),n=new $c,r=t.length;if(0===r)return new Float32Array(0);const s=t[0].length,o=e.getAtomSet(),a=new Float32Array(r*s*3);let c=0;return t.forEach((function(t){let r=!1;for(let l=0;l 1.0 ){\ngl_FragColor = vec4( backgroundColor, backgroundOpacity );\n}else{\nfloat sdf = texture2D( fontTexture, texCoord ).a;\nif( showBorder ) sdf += borderWidth;\nfloat a = smoothstep(padding - gamma, padding + gamma, sdf);\nif( a < 0.2 ) discard;\na *= opacity;\nvec3 outgoingLight = vColor;\nif( showBorder && sdf < ( padding + borderWidth ) ){\noutgoingLight = borderColor;\n}\ngl_FragColor = vec4( outgoingLight, a );\n}\n#if defined( PICKING )\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");const Gv={};const Vv={font:"sans-serif",size:36,style:"normal",variant:"normal",weight:"normal",outline:3,width:1024,height:1024};class Hv{constructor(e={}){this.gamma=1,this.mapped={},this.scratchW=0,this.scratchH=0,this.currentX=0,this.currentY=0,this.cutoff=.25,this.parameters=Ea(e,Vv);const t=this.parameters;this.radius=t.size/8,this.padding=t.size/3;const i=this.lineHeight=t.size+2*t.outline+Math.round(t.size/4),n=this.maxWidth=t.width/4,r=this.canvas=document.createElement("canvas");r.width=n,r.height=i;const s=this.context=this.canvas.getContext("2d");s.font=`${t.style} ${t.variant} ${t.weight} ${t.size}px ${t.font}`,s.fillStyle="black",s.textAlign="left",s.textBaseline="bottom",s.lineJoin="round",this.gridOuter=new Float64Array(i*n),this.gridInner=new Float64Array(i*n),this.f=new Float64Array(Math.max(i,n)),this.d=new Float64Array(Math.max(i,n)),this.z=new Float64Array(Math.max(i,n)+1),this.v=new Int16Array(Math.max(i,n)),this.data=new Uint8Array(t.width*t.height*4),this.canvas2=document.createElement("canvas"),this.canvas2.width=t.width,this.canvas2.height=t.height,this.context2=this.canvas2.getContext("2d"),this.placeholder=this.map(String.fromCharCode(65533));for(let e=32;e<=126;++e)this.map(String.fromCharCode(e));this.map(String.fromCharCode(176)),this.map(String.fromCharCode(8491)),this.texture=new na(this.canvas2),this.texture.flipY=!1,this.texture.needsUpdate=!0}map(e){const t=this.parameters;return void 0===this.mapped[e]&&(this.draw(e),this.currentX+this.scratchW>t.width&&(this.currentX=0,this.currentY+=this.scratchH),this.currentY+this.scratchH>t.height&&console.warn("canvas to small"),this.mapped[e]={x:this.currentX,y:this.currentY,w:this.scratchW,h:this.scratchH},this.context2.drawImage(this.canvas,0,0,this.scratchW,this.scratchH,this.currentX,this.currentY,this.scratchW,this.scratchH),this.currentX+=this.scratchW),this.mapped[e]}get(e){return this.mapped[e]||this.placeholder}draw(e){const t=this.parameters,i=this.lineHeight,n=t.outline,r=this.context,s=this.maxWidth,o=n,a=i-t.outline,c=r.measureText(e),l=Math.min(s,Math.ceil(c.width+2*o+1)),h=l*i;r.clearRect(0,0,l,i),r.fillText(e,o,a);const u=r.getImageData(0,0,l,i),d=u.data;for(let e=0;e= 0.0 ) {\ntrimSegment( start, end );\n} else if ( end.z < 0.0 && start.z >= 0.0 ) {\ntrimSegment( end, start );\n}\n}\nvec4 clipStart = projectionMatrix * start;\nvec4 clipEnd = projectionMatrix * end;\nvec2 ndcStart = clipStart.xy / clipStart.w;\nvec2 ndcEnd = clipEnd.xy / clipEnd.w;\nvec2 dir = ndcEnd - ndcStart;\ndir.x *= aspect;\ndir = normalize( dir );\nvec2 offset = vec2( dir.y, - dir.x );\ndir.x /= aspect;\noffset.x /= aspect;\nif ( mapping.x < 0.0 ) offset *= - 1.0;\noffset *= linewidth;\noffset /= resolution.y;\nvec4 clip = ( mapping.y < 0.5 ) ? clipStart : clipEnd;\noffset *= clip.w;\nclip.xy += offset;\ngl_Position = clip;\n#ifndef PICKING\nvViewPosition = ( projectionMatrixInverse * clip ).xyz;\n#endif\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n#include nearclip_vertex\n}"),ul.add("shader/WideLine.frag","uniform vec3 diffuse;\nuniform float opacity;\nuniform float clipNear;\nuniform float clipRadius;\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#ifdef PICKING\nuniform float objectId;\nvarying vec3 vPickingColor;\n#else\n#include common\n#include fog_pars_fragment\nvarying vec3 vViewPosition;\nvarying vec3 vColor;\nvarying vec3 vColor2;\nvarying float flag;\n#endif\nvoid main() {\n#include nearclip_fragment\n#include radiusclip_fragment\n#if defined( PICKING )\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 outgoingLight = vec3( 0.0 );\nvec4 diffuseColor = vec4( diffuse, 1.0 );\nif ( flag < 0.0 ) {\ndiffuseColor.rgb *= vColor;\n} else {\ndiffuseColor.rgb *= vColor2;\n}\n#include alphatest_fragment\noutgoingLight = diffuseColor.rgb;\ngl_FragColor = vec4( outgoingLight, diffuseColor.a * opacity );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");const Yv=Object.assign({linewidth:2},em),Zv=Object.assign({linewidth:{uniform:!0}},tm);class Kv extends Jp{constructor(e,t={}){super(e,t),this.parameterTypes=Zv,this.vertexShader="WideLine.vert",this.fragmentShader="WideLine.frag",!e.color2&&e.color&&(e.color2=e.color),this.addUniforms({linewidth:{value:this.parameters.linewidth},resolution:{value:new zt},projectionMatrixInverse:{value:new ri}}),this.addAttributes({position1:{type:"v3",value:null},position2:{type:"v3",value:null},color2:{type:"c",value:null}}),this.setAttributes(e),this.makeMapping()}get defaultParameters(){return Yv}setParameters(e){super.setParameters(e)}}ml.add("wideline",Kv);class Qv extends Nv{constructor(e,t,i){super(e,t,i),this.type="angle",this.parameters=Object.assign({atomTriple:{type:"hidden",rebuild:!0},vectorVisible:{type:"boolean",default:!0},arcVisible:{type:"boolean",default:!0},sectorVisible:{type:"boolean",default:!0}},this.parameters),this.init(i)}init(e){const t=e||{};t.side=Ia(t.side,"double"),t.opacity=Ia(t.opacity,.5),this.atomTriple=Ia(t.atomTriple,[]),this.arcVisible=Ia(t.arcVisible,!0),this.sectorVisible=Ia(t.sectorVisible,!0),this.vectorVisible=Ia(t.vectorVisible,!0),super.init(t)}createData(e){if(!e.atomCount||!this.atomTriple.length)return;const t=function(e,t){return function(e){const t=[],i=e.length/9;for(let n=0;n radius2) {\ndiscard;\n}\n#ifdef CAP\nsurface_point = front_point;\n_normal = axis;\n#else\nsurface_point = ray_target + ( (-a1 - sqrt(d)) / a2 ) * ray_direction;\ndNV = dot(-axis, ray_direction);\nnear = dot(axis, end) / dNV;\nnew_point2 = ray_direction * near + ray_origin;\nif (dot(new_point2 - end, new_point2-base) < radius2) {\ndiscard;\n}\ninterior = true;\n#endif\n}\nif( end_cap_test > 0.0 )\n{\nfloat dNV;\nfloat near;\nvec3 end_point;\nif ( ortho == 1.0 ) {\nend_point = ray_target;\n} else {\ndNV = dot(axis, ray_direction);\nif (dNV < 0.0) {\ndiscard;\n}\nnear = dot(axis, end) / dNV;\nend_point = ray_direction * near + ray_origin;\n}\n\nif( dot(end_point - end, end_point-base) > radius2 ) {\ndiscard;\n}\n#ifdef CAP\nsurface_point = end_point;\n_normal = axis;\n#else\nsurface_point = ray_target + ( (-a1 - sqrt(d)) / a2 ) * ray_direction;\ndNV = dot(-axis, ray_direction);\nnear = dot(-axis, (base)) / dNV;\nnew_point2 = ray_direction * near + ray_origin;\nif (dot(new_point2 - base, new_point2-base) < radius2) {\ndiscard;\n}\ninterior = true;\n#endif\n}\ngl_FragDepthEXT = calcDepth( surface_point );\n\n#ifdef NEAR_CLIP\nif( calcClip( surface_point ) > 0.0 ){\ndist = (-a1 - sqrt(d)) / a2;\nsurface_point = ray_target + dist * ray_direction;\nif( calcClip( surface_point ) > 0.0 ) {\ndiscard;\n}\ninterior = true;\ngl_FragDepthEXT = calcDepth( surface_point );\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( clipNear - 0.5 ) ) ) + ( 0.0000001 / vRadius ) );\n}\n}else if( gl_FragDepthEXT <= 0.0 ){\ndist = (-a1 - sqrt(d)) / a2;\nsurface_point = ray_target + dist * ray_direction;\ninterior = true;\ngl_FragDepthEXT = calcDepth( surface_point );\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n}\n#else\nif( gl_FragDepthEXT <= 0.0 ){\ndist = (-a1 - sqrt(d)) / a2;\nsurface_point = ray_target + dist * ray_direction;\ninterior = true;\ngl_FragDepthEXT = calcDepth( surface_point );\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n}\n#endif\nif (gl_FragDepthEXT < 0.0) {\ndiscard;\n}\nif (gl_FragDepthEXT > 1.0) {\ndiscard;\n}\n#ifdef PICKING\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 vViewPosition = -surface_point;\nvec3 vNormal = _normal;\nvec3 vColor;\nif( distSq3( surface_point, end ) < distSq3( surface_point, base ) ){\nif( b < 0.0 ){\nvColor = vColor1;\n}else{\nvColor = vColor2;\n}\n}else{\nif( b > 0.0 ){\nvColor = vColor1;\n}else{\nvColor = vColor2;\n}\n}\nvec4 diffuseColor = vec4( diffuse, opacity );\nReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\nvec3 totalEmissiveLight = emissive;\n#include color_fragment\n#include roughnessmap_fragment\n#include metalnessmap_fragment\nvec3 normal = normalize( vNormal );\nvec3 geometryNormal = normal;\n#include lights_physical_fragment\n#include lights_fragment_begin\n#include lights_fragment_end\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\nif( interior ){\n#ifdef USE_INTERIOR_COLOR\noutgoingLight.xyz = interiorColor;\n#else\n#ifdef DIFFUSE_INTERIOR\noutgoingLight.xyz = vColor;\n#endif\n#endif\noutgoingLight.xyz *= 1.0 - interiorDarkening;\n}\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");const oy=new Float32Array([-1,1,-1,-1,-1,-1,1,1,-1,1,1,1,1,-1,-1,1,-1,1]),ay=new Uint16Array([0,1,2,1,4,2,2,4,3,4,5,3]);class cy extends Zp{constructor(e,t={}){super("v3",e,t)}get mapping(){return oy}get mappingIndices(){return ay}get mappingIndicesSize(){return 12}get mappingSize(){return 6}get mappingItemSize(){return 3}}const ly=Object.assign({openEnded:!1},em),hy=Object.assign({openEnded:{updateShader:!0}},tm);class uy extends cy{constructor(e,t={}){super(e,t),this.parameterTypes=hy,this.isImpostor=!0,this.vertexShader="CylinderImpostor.vert",this.fragmentShader="CylinderImpostor.frag",this.addUniforms({modelViewMatrixInverse:{value:new ri},ortho:{value:0}}),this.addAttributes({position1:{type:"v3",value:null},position2:{type:"v3",value:null},color2:{type:"c",value:null},radius:{type:"f",value:null}}),this.setAttributes(e),this.makeMapping()}get defaultParameters(){return ly}getDefines(e){const t=cy.prototype.getDefines.call(this,e);return this.parameters.openEnded||(t.CAP=1),t}}Object.assign({disableImpostor:!1},ny,ly);const dy=class{constructor(e,t={}){return!e.color2&&e.color&&(e.color2=e.color),!el||t&&t.disableImpostor?new sy(e,t):new uy(e,t)}};ml.add("cylinder",dy);class fy extends Bv{constructor(e,t,i){super(e,t,i),this.type="axes",this.parameters=Object.assign({radiusSize:{type:"number",precision:3,max:10,min:.001},sphereDetail:!0,radialSegments:!0,disableImpostor:!0,showAxes:{type:"boolean",rebuild:!0},showBox:{type:"boolean",rebuild:!0}},this.parameters,{assembly:null}),this.init(i)}init(e){const t=e||{};t.radiusSize=Ia(t.radiusSize,.5),t.colorValue=Ia(t.colorValue,"lightgreen"),t.useInteriorColor=Ia(t.useInteriorColor,!0),this.showAxes=Ia(t.showAxes,!0),this.showBox=Ia(t.showBox,!1),super.init(t)}getPrincipalAxes(){let e;const t=this.getAssembly();return t&&(e=t.partList[0].getSelection()),this.structureView.getPrincipalAxes(e)}getAxesData(e){const t=this.getPrincipalAxes(),i=new mn(this.colorValue);let n=0,r=0;this.showAxes&&(n+=6,r+=3),this.showBox&&(n+=8,r+=12);const s=new Float32Array(3*n),o=Vl(n,i.r,i.g,i.b),a=Gl(n,this.radiusSize),c=new Float32Array(3*r),l=new Float32Array(3*r),h=Vl(r,i.r,i.g,i.b),u=Gl(r,this.radiusSize);let d=0;if(this.showAxes){const e=function(e,t){e.toArray(s,2*d),t.toArray(s,2*d+3),e.toArray(c,d),t.toArray(l,d),d+=3};e(t.begA,t.endA),e(t.begB,t.endB),e(t.begC,t.endC)}if(this.showBox){const i=new Zt,{d1a:n,d2a:r,d3a:o,d1b:a,d2b:h,d3b:u}=t.getProjectedScaleForAtoms(e);let f=2*d;const m=function(e,n,r){i.copy(t.center).addScaledVector(t.normVecA,e).addScaledVector(t.normVecB,n).addScaledVector(t.normVecC,r),i.toArray(s,f),f+=3};m(n,r,o),m(n,r,u),m(n,h,u),m(n,h,o),m(a,h,u),m(a,h,o),m(a,r,o),m(a,r,u);let p=d;const g=function(e,t){i.fromArray(s,2*d+3*e).toArray(c,p),i.fromArray(s,2*d+3*t).toArray(l,p),p+=3};g(0,1),g(0,3),g(0,6),g(1,2),g(1,7),g(2,3),g(2,4),g(3,5),g(4,5),g(4,7),g(5,6),g(6,7)}const f=new uf(t);return{vertex:{position:s,color:o,radius:a,picking:f},edge:{position1:c,position2:l,color:h,color2:h,radius:u,picking:f}}}create(){const e=this.getAxesData(this.structureView);this.sphereBuffer=new tg(e.vertex,this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0})),this.cylinderBuffer=new dy(e.edge,this.getBufferParams({openEnded:!0,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0})),this.dataList.push({sview:this.structureView,bufferList:[this.sphereBuffer,this.cylinderBuffer]})}createData(e){}updateData(e,t){const i=this.getAxesData(t.sview),n={},r={};e&&!e.position||(Object.assign(n,{position:i.vertex.position}),Object.assign(r,{position1:i.edge.position1,position2:i.edge.position2})),e&&!e.color||(Object.assign(n,{color:i.vertex.color}),Object.assign(r,{color:i.edge.color,color2:i.edge.color})),e&&!e.radius||(Object.assign(n,{radius:i.vertex.radius}),Object.assign(r,{radius:i.edge.radius})),this.sphereBuffer.setAttributes(n),this.cylinderBuffer.setAttributes(r)}}ll.add("axes",fy);class my extends Bv{constructor(e,t,i){super(e,t,i),this.type="ball+stick",this.parameters=Object.assign({sphereDetail:!0,radialSegments:!0,openEnded:!0,disableImpostor:!0,aspectRatio:{type:"number",precision:1,max:10,min:1},lineOnly:{type:"boolean",rebuild:!0},cylinderOnly:{type:"boolean",rebuild:!0},multipleBond:{type:"select",rebuild:!0,options:{off:"off",symmetric:"symmetric",offset:"offset"}},bondScale:{type:"number",precision:2,max:1,min:.01},bondSpacing:{type:"number",precision:2,max:2,min:.5},linewidth:{type:"integer",max:50,min:1,buffer:!0}},this.parameters),this.init(i)}init(e){var t=e||{};t.radiusType=Ia(t.radiusType,"size"),t.radiusSize=Ia(t.radiusSize,.15),t.useInteriorColor=Ia(t.useInteriorColor,!0),this.aspectRatio=Ia(t.aspectRatio,2),this.lineOnly=Ia(t.lineOnly,!1),this.cylinderOnly=Ia(t.cylinderOnly,!1),this.multipleBond=Ia(t.multipleBond,"off"),this.bondSpacing=Ia(t.bondSpacing,1),this.bondScale=Ia(t.bondScale,.4),this.linewidth=Ia(t.linewidth,2),super.init(t)}getAtomRadius(e){return this.aspectRatio*super.getAtomRadius(e)}getAtomParams(e,t){var i=super.getAtomParams(e,t);return i.radiusParams.scale*=this.aspectRatio,i}getAtomData(e,t,i){return e.getAtomData(this.getAtomParams(t,i))}getBondParams(e,t){return t=Object.assign({multipleBond:this.multipleBond,bondSpacing:this.bondSpacing,bondScale:this.bondScale},t),super.getBondParams(e,t)}getBondData(e,t,i){return e.getBondData(this.getBondParams(t,i))}createData(e){const t=[];if(this.lineOnly)this.lineBuffer=new Kv(this.getBondData(e,{position:!0,color:!0,picking:!0}),this.getBufferParams({linewidth:this.linewidth})),t.push(this.lineBuffer);else{const i=new dy(this.getBondData(e),this.getBufferParams({openEnded:this.openEnded,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0}));if(t.push(i),!this.cylinderOnly){const i=new tg(this.getAtomData(e),this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0}));t.push(i)}}return{bufferList:t}}updateData(e,t){"off"!==this.multipleBond&&e&&e.radius&&(e.position=!0);const i=this.getBondData(t.sview,e);if(this.lineOnly){const n={};e&&!e.position||Object.assign(n,{position1:i.position1,position2:i.position2}),e&&!e.color||Object.assign(n,{color:i.color,color2:i.color2}),t.bufferList[0].setAttributes(n)}else{var n={};if(e&&!e.position||Object.assign(n,{position1:i.position1,position2:i.position2}),e&&!e.color||Object.assign(n,{color:i.color,color2:i.color2}),e&&!e.radius||Object.assign(n,{radius:i.radius}),t.bufferList[0].setAttributes(n),!this.cylinderOnly){var r=this.getAtomData(t.sview,e),s={};e&&!e.position||Object.assign(s,{position:r.position}),e&&!e.color||Object.assign(s,{color:r.color}),e&&!e.radius||Object.assign(s,{radius:r.radius}),t.bufferList[1].setAttributes(s)}}}setParameters(e={}){let t=!1;const i={};return(e.aspectRatio||e.bondSpacing||e.bondScale)&&(Object.assign(i,{radius:!0}),el&&!this.disableImpostor||(t=!0)),super.setParameters(e,i,t),this}}ll.add("ball+stick",my);class py extends my{constructor(e,t,i){super(e,t,i),this.type="backbone",this.parameters=Object.assign({},this.parameters,{multipleBond:null,bondSpacing:null}),this.init(i)}init(e){var t=e||{};t.aspectRatio=Ia(t.aspectRatio,1),t.radiusSize=Ia(t.radiusSize,.25),super.init(t)}getAtomRadius(e){return e.isTrace()?super.getAtomRadius(e):0}getAtomData(e,t,i){return e.getBackboneAtomData(this.getAtomParams(t,i))}getBondData(e,t,i){return e.getBackboneBondData(this.getBondParams(t,i))}}ll.add("backbone",py);class gy extends my{constructor(e,t,i){super(e,t,i),this.type="base",this.parameters=Object.assign({},this.parameters,{multipleBond:null,bondSpacing:null})}init(e){let t=e||{};t.aspectRatio=Ia(t.aspectRatio,1),t.radiusSize=Ia(t.radiusSize,.3),super.init(t)}getAtomData(e,t,i){return e.getRungAtomData(this.getAtomParams(t,i))}getBondData(e,t,i){let n=this.getBondParams(t,i);return Object.assign(n.colorParams,{rung:!0}),e.getRungBondData(n)}}ll.add("base",gy);class vy{constructor(e,t){this.m=e,this.tension=t,this.dt=1/this.m,this.delta=1e-4,this.vec1=new Zt,this.vec2=new Zt,this.vDir=new Zt,this.vTan=new Zt,this.vNorm=new Zt,this.vBin=new Zt,this.m2=Math.ceil(this.m/2)}interpolateToArr(e,t,i,n,r,s,o){s[o+0]=nc(e.x,t.x,i.x,n.x,r,this.tension),s[o+1]=nc(e.y,t.y,i.y,n.y,r,this.tension),s[o+2]=nc(e.z,t.z,i.z,n.z,r,this.tension)}interpolateToVec(e,t,i,n,r,s){s.x=nc(e.x,t.x,i.x,n.x,r,this.tension),s.y=nc(e.y,t.y,i.y,n.y,r,this.tension),s.z=nc(e.z,t.z,i.z,n.z,r,this.tension)}interpolatePosition(e,t,i,n,r,s){for(var o=0;o1&&(l=1),this.interpolateToVec(e,t,i,n,c,this.vec1),this.interpolateToVec(e,t,i,n,l,this.vec2),this.vec2.sub(this.vec1).normalize(),this.vec2.toArray(r,h)}}vectorSubdivide(e,t,i,n,r){let s,o=t.next(),a=t.next(),c=t.next();const l=t.size,h=l-1;let u=n||0;for(let n=0;n0&&n{if(e.residueCount<4)return;i.push(e);const n=this.getSpline(e),r=this.getAspectRatio(e),s=n.getSubdividedPosition(),o=n.getSubdividedOrientation(),a=n.getSubdividedColor(this.getColorParams()),c=n.getSubdividedPicking(),l=n.getSubdividedSize(this.getRadiusParams());t.push(new wy(Object.assign({},s,o,a,c,l),this.getBufferParams({radialSegments:this.radialSegments,aspectRatio:r,capped:this.capped})))}),e.getSelection()),{bufferList:t,polymerList:i}}updateData(t,i){e.Debug&&il.time(this.type+" repr update"),t=t||{};for(var n=0,r=i.polymerList.length;n0;fu(w,y,S);const r=du(w,b)<0;if(bu(w,b,du(b,x)),fu(A,x,w),bu(w,b,du(b,_)),fu(M,_,w),0===yu(A)||0===yu(M))continue;_u(A,A),_u(M,M);const L=s[E]=Pu(A,M);a[E]=(Fl*L).toFixed(1)+String.fromCharCode(176),uu(T,A,b),_u(T,T),du(T,M)<0&&Cu(T,T),zv(w,S,A,T,L/2),gu(w,o,3*E);const R=Math.ceil(L/i),k=R+(t.extendLine?4:2),O=t.extendLine?36:0,B=new Float32Array(3*k),N=new Float32Array(3*k),F=new Float32Array(9*R),z=new Float32Array(O);c[E]=B,l[E]=N,h[E]=F,u[E]=z,t.extendLine&&(n?(fu(w,p,v),_u(w,w),bu(C,w,1/du(A,w)),mu(C,C,v)):(bu(C,x,1/du(A,x)),mu(C,C,g)),r?(fu(w,y,g),_u(w,w),bu(P,w,1/du(M,w)),mu(P,P,g)):(bu(P,_,1/du(M,_)),mu(P,P,v))),mu(I,S,A);let U=0;t.extendLine?(gu(p,B,U),gu(C,N,U),U+=3,gu(C,B,U),gu(I,N,U),U+=3,gu(C,z,0),gu(I,z,3),gu(n?v:g,z,6),gu(n?v:g,z,9),gu(I,z,12),gu(S,z,15)):(gu(S,B,U),gu(I,N,U),U+=3);const $=function(e,t){const i=9*t;gu(S,F,i),gu(I,F,i+3),gu(I,B,U),zv(I,S,A,T,e),gu(I,F,i+6),gu(I,N,U),U+=3};let G=0;for(let e=i;e{const t=Cy(i,e);Object.assign(e,t)})),t.side=Ia(t.side,"double"),t.opacity=Ia(t.opacity,.5),t.radiusType=Ia(t.radiusType,"size"),t.radiusSize=Ia(t.radiusSize,.15),super.init(t)}getHistogramBinBorderBufferParameters(){return this.getBufferParams({linewidth:this.histogramBinBorderWidth,visible:this.histogramBinBorderVisible,opacity:this.histogramBinBorderOpacity})}getBondArrowsBufferParameters(){return this.getBufferParams({linewidth:this.bondArrowWidth,visible:this.bondArrowVisible,opacity:this.bondArrowOpacity})}getOpaqueMiddleDiscBufferParameters(){return this.getBufferParams({visible:this.opaqueMiddleDiscVisible,opacity:this.opaqueMiddleDiscOpacity})}getHistogramBufferParameters(){return this.getBufferParams({visible:!0,opacity:this.histogramOpacity,side:"double"})}createData(e){if(!e.atomCount||!this.histogramsData.length)return;this.histogramsData.forEach((t=>t.atomPositions=Fv(e,[t.atomQuad])));const t=this.scaleBinToSectorArea?function(e){return Math.sqrt(e)}:function(e){return e};function i(e){const t=e.map((e=>e.length)),i=new Float32Array(Kl(t));let n=0;for(let t=0;te.startPoints))),position2:i(e.map((e=>e.endPoints))),color:i(e.map((e=>e.startColors))),color2:i(e.map((e=>e.endColors)))},t)}function r(e,t){return new nm({position:i(e.map((e=>e.triangles))),color:i(e.map((e=>e.triangleColors)))},t)}this.histogramsData.forEach((e=>e.histogram360Scaled=e.histogram360.map(t)));const s=[];for(let e=0;e=3&&(t=Iy(i)),void 0!==t&&s.push(t)}return this.frontHistogramBinBordersBuffer=n(s.map((e=>e.frontHistogramBinBorders)),this.getHistogramBinBorderBufferParameters()),this.backHistogramBinBordersBuffer=n(s.map((e=>e.backHistogramBinBorders)),this.getHistogramBinBorderBufferParameters()),this.adjacentBondArrowsBuffer=n(s.map((e=>e.adjacentBondArrows)),this.getBondArrowsBufferParameters()),this.distantBondArrowsBuffer=n(s.map((e=>e.distantBondArrows)),this.getBondArrowsBufferParameters()),this.opaqueMiddleDiscBuffer=r(s.map((e=>e.opaqueMiddleDisc)),this.getOpaqueMiddleDiscBufferParameters()),this.frontHistogramBuffer=r(s.map((e=>e.frontHistogram)),this.getHistogramBufferParameters()),this.backHistogramBuffer=r(s.map((e=>e.backHistogram)),this.getHistogramBufferParameters()),{bufferList:[].concat(this.frontHistogramBinBordersBuffer,this.backHistogramBinBordersBuffer,this.adjacentBondArrowsBuffer,this.distantBondArrowsBuffer,this.opaqueMiddleDiscBuffer,this.frontHistogramBuffer,this.backHistogramBuffer)}}setParameters(e){return super.setParameters(e,{},!1),e&&void 0!==e.histogramBinBorderVisible&&this.setVisibility(this.visible),this}setVisibility(e,t){return super.setVisibility(e,!0),this.frontHistogramBinBordersBuffer&&this.frontHistogramBinBordersBuffer.setVisibility(this.histogramBinBorderVisible),this.backHistogramBinBordersBuffer&&this.backHistogramBinBordersBuffer.setVisibility(this.histogramBinBorderVisible),t||this.viewer.requestRender(),this}}function Iy(e){const t=e.atomPositions,i=e.histogram360Scaled,n=i.length<=180?360:2*i.length,r={triangles:new Float32Array(3*n*3),triangleColors:Py(e.opaqueMiddleDiscColor,3*n)},s={triangles:new Float32Array(3*i.length*3),triangleColors:Py(e.frontHistogramColor,3*i.length)},o={triangles:new Float32Array(3*i.length*3),triangleColors:Py(e.backHistogramColor,3*i.length)},a={startPoints:new Float32Array(3*i.length),endPoints:new Float32Array(3*i.length),startColors:Py(e.histogramBinBorderColor,i.length),endColors:Py(e.histogramBinBorderColor,i.length)},c={startPoints:new Float32Array(3*i.length),endPoints:new Float32Array(3*i.length),startColors:Py(e.histogramBinBorderColor,i.length),endColors:Py(e.histogramBinBorderColor,i.length)},l={startPoints:new Float32Array(6),endPoints:new Float32Array(6),startColors:Py(e.adjacentBondArrowColor,i.length),endColors:Py(e.adjacentBondArrowColor,i.length)},h={startPoints:new Float32Array(6),endPoints:new Float32Array(6),startColors:Py(e.distantBondArrowColor,i.length),endColors:Py(e.distantBondArrowColor,i.length)},u=hu(),d=hu(),f=hu(),m=hu(),p=hu(),g=hu(),v=hu(),y=hu(),x=hu(),b=hu(),_=hu(),w=hu(),S=hu(),A=hu(),M=hu(),C=hu(),P=[u,d,f,m];for(let e=0;e{let d=t[0],f=t[1];if("number"==typeof d&&Number.isInteger(d)&&"number"==typeof f&&Number.isInteger(f)){if(!u.get(d)||!u.get(f))return void(h+=1);c.index=d,l.index=f}else{s.setString(d),o.setString(f);var m=e.getAtomIndices(s),p=e.getAtomIndices(o);if(!m.length||!p.length)return void(h+=1);c.index=m[0],l.index=p[0]}a.addBond(c,l,1),i-=h;var g=c.distanceTo(l);switch(this.labelUnit){case"angstrom":n[i]=g.toFixed(2)+" "+String.fromCharCode(8491);break;case"nm":n[i]=(g/10).toFixed(2)+" nm";break;default:n[i]=g.toFixed(2)}var v=3*i;r[v+0]=(c.x+l.x)/2,r[v+1]=(c.y+l.y)/2,r[v+2]=(c.z+l.z)/2})),h>0&&(i-=h,r=r.subarray(0,3*i));var d=new Yu(a.count,!0);return{text:n,position:r,bondSet:d,bondStore:a}}getBondData(e,t,i){const n=e.getBondData(this.getBondParams(t,i));return n.picking&&(n.picking=new pf(n.picking.array,n.picking.structure,i.bondStore)),n}createData(e){if(!e.atomCount||!this.atomPair.length)return;const t=this.atomPair.length,i=new mn(this.labelColor),n=this.getDistanceData(e,this.atomPair);this.textBuffer=new Xv({position:n.position,size:Gl(t,this.labelSize),color:Vl(t,i.r,i.g,i.b),text:n.text},this.getLabelBufferParams());const r={bondSet:n.bondSet,bondStore:n.bondStore},s=this.getBondData(e,{position:!0,color:!0,picking:!0,radius:this.useCylinder},r);return this.useCylinder?this.distanceBuffer=new dy(s,this.getBufferParams({openEnded:this.openEnded,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0})):this.distanceBuffer=new Kv(Iu(s),this.getBufferParams({linewidth:this.linewidth,visible:this.lineVisible,opacity:this.lineOpacity})),{bondSet:n.bondSet,bondStore:n.bondStore,position:n.position,bufferList:[this.textBuffer,this.distanceBuffer]}}updateData(e,t){super.updateData(e,t);const i={bondSet:t.bondSet,bondStore:t.bondStore},n=this.getBondData(t.sview,e,i),r={};e&&!e.color||Object.assign(r,{color:n.color,color2:n.color2}),e&&!e.radius||Object.assign(r,{radius:n.radius}),this.distanceBuffer.setAttributes(r)}setParameters(e){return super.setParameters(e,{},!1),this.useCylinder||(e&&e.lineOpacity&&this.distanceBuffer.setParameters({opacity:e.lineOpacity}),e&&void 0!==e.opacity&&this.distanceBuffer.setParameters({opacity:this.lineOpacity}),e&&e.linewidth&&this.distanceBuffer.setParameters({linewidth:e.linewidth})),this}}function Dy(e){return 2*(e.position.length/3)*3}ll.add("distance",Ey);const Ly=Object.assign({scale:1,color:"grey"},em);class Ry extends im{constructor(e,t={}){super({position:new Float32Array(Dy(e)),color:new Float32Array(Dy(e))},t),this.isLine=!0,this.vertexShader="Line.vert",this.fragmentShader="Line.frag";const i=new mn(this.parameters.color),n=this.geometry.attributes;Vl(Dy(e)/3,i.r,i.g,i.b,n.color.array),this.setAttributes(e)}get defaultParameters(){return Ly}setAttributes(e={}){const t=this.geometry.attributes;let i,n,r;e.position&&e.vector&&(i=e.position,n=e.vector,r=t.position.array,t.position.needsUpdate=!0);const s=this.size/2,o=this.parameters.scale;if(i&&n)for(let e=0;e{if(e.residueCount<4)return;i.push(e);const n=new zm(e),r=n.getPosition(),s=n.getColor(this.getColorParams()),o=n.getSize(this.getRadiusParams()),a=n.getPicking();t.push(new tg({position:r.center,color:s.color,radius:o.size,picking:a.picking},this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0})),new Ry({position:r.center,vector:r.axis},this.getBufferParams({color:"skyblue",scale:1})),new Ry({position:r.center,vector:r.resdir},this.getBufferParams({color:"lightgreen",scale:1})))}),e.getSelection()),{bufferList:t,polymerList:i}}updateData(t,i){e.Debug&&il.time(this.type+" repr update"),t=t||{};for(let e=0,n=i.polymerList.length;e radius2) {\nspaceposition.y = mapping.y * 1.5 * radius1;\nspaceposition.x = mapping.x * 1.5 * radius1;\n} else {\nspaceposition.y = mapping.y * 1.5 * radius2;\nspaceposition.x = mapping.x * 1.5 * radius2;\n}\nspaceposition.w = 1.0;\nvec4 e3 = vec4( 1.0 );\nvec3 e1, e1_temp, e2, e2_temp;\ne3.xyz = normalize(position_atom1-position_atom2);\nif (e3.z == 0.0) { e3.z = 0.0000000000001;}\nif ( (position_atom1.x - position_atom2.x) == 0.0) { position_atom1.x += 0.001;}\nif ( (position_atom1.y - position_atom2.y) == 0.0) { position_atom1.y += 0.001;}\nif ( (position_atom1.z - position_atom2.z) == 0.0) { position_atom1.z += 0.001;}\nvec4 focus = vec4( 1.0 );\nfocus.x = ( position_atom1.x*position_atom1.x - position_atom2.x*position_atom2.x +\n( radius2*radius2 - radius1*radius1 )*e3.x*e3.x/shrink )/(2.0*(position_atom1.x - position_atom2.x));\nfocus.y = ( position_atom1.y*position_atom1.y - position_atom2.y*position_atom2.y +\n( radius2*radius2 - radius1*radius1 )*e3.y*e3.y/shrink )/(2.0*(position_atom1.y - position_atom2.y));\nfocus.z = ( position_atom1.z*position_atom1.z - position_atom2.z*position_atom2.z +\n( radius2*radius2 - radius1*radius1 )*e3.z*e3.z/shrink )/(2.0*(position_atom1.z - position_atom2.z));\ne1.x = 1.0;\ne1.y = 1.0;\ne1.z = ( (e3.x*focus.x + e3.y*focus.y + e3.z*focus.z) - e1.x*e3.x - e1.y*e3.y)/e3.z;\ne1_temp = e1 - focus.xyz;\ne1 = normalize(e1_temp);\ne2_temp = e1.yzx * e3.zxy - e1.zxy * e3.yzx;\ne2 = normalize(e2_temp);\nmat3 R= mat3( e1.xyz, e2.xyz, e3.xyz );\nvertex_position.xyz = R * spaceposition.xyz;\nvertex_position.w = 1.0;\nvertex_position.x += (position_atom1.x+position_atom2.x) / 2.0;\nvertex_position.y += (position_atom1.y+position_atom2.y) / 2.0;\nvertex_position.z += (position_atom1.z+position_atom2.z) / 2.0;\ngl_Position = modelViewProjectionMatrix * vertex_position;\nvec4 i_near, i_far;\nvec4 near = gl_Position;\nnear.z = 0.0 ;\nnear = modelViewProjectionMatrixInverse * near;\ni_near = near;\nvec4 far = gl_Position;\nfar.z = far.w ;\ni_far = modelViewProjectionMatrixInverse * far;\nprime1 = vec4( position_atom1 - (position_atom1 - focus.xyz)*shrink, 1.0 );\nprime2 = vec4( position_atom2 - (position_atom2 - focus.xyz)*shrink, 1.0 );\nfloat Rsquare = (radius1*radius1/shrink) - (\n(position_atom1.x - focus.x)*(position_atom1.x - focus.x) +\n(position_atom1.y - focus.y)*(position_atom1.y - focus.y) +\n(position_atom1.z - focus.z)*(position_atom1.z - focus.z)\n);\nfocus.w = Rsquare;\nmatrix_near = mat4( i_near, i_far, focus, e3 );\ngl_Position.z = 1.0;\n}"),ul.add("shader/HyperballStickImpostor.frag","#define STANDARD\n#define IMPOSTOR\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 interiorColor;\nuniform float interiorDarkening;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\nuniform float clipNear;\nuniform float shrink;\nuniform mat4 modelViewMatrix;\nuniform mat4 modelViewProjectionMatrix;\nuniform mat4 modelViewMatrixInverseTranspose;\nuniform mat4 projectionMatrix;\nvarying mat4 matrix_near;\nvarying vec4 prime1;\nvarying vec4 prime2;\nvarying float vRadius;\nvarying float vRadius2;\n#ifdef PICKING\nuniform float objectId;\nvarying vec3 vPickingColor;\n#else\nvarying vec3 vColor1;\nvarying vec3 vColor2;\n#include common\n#include fog_pars_fragment\n#include bsdfs\n#include lights_pars_begin\n#include lights_physical_pars_fragment\n#endif\nbool interior = false;\nfloat calcClip( vec4 cameraPos ){\nreturn dot( cameraPos, vec4( 0.0, 0.0, 1.0, clipNear - 0.5 ) );\n}\nfloat calcClip( vec3 cameraPos ){\nreturn calcClip( vec4( cameraPos, 1.0 ) );\n}\nfloat calcDepth( in vec3 cameraPos ){\nvec2 clipZW = cameraPos.z * projectionMatrix[2].zw + projectionMatrix[3].zw;\nreturn 0.5 + 0.5 * clipZW.x / clipZW.y;\n}\nstruct Ray {\nvec3 origin ;\nvec3 direction ;\n};\nbool cutoff_plane (vec3 M, vec3 cutoff, vec3 x3){\nfloat a = x3.x;\nfloat b = x3.y;\nfloat c = x3.z;\nfloat d = -x3.x*cutoff.x-x3.y*cutoff.y-x3.z*cutoff.z;\nfloat l = a*M.x+b*M.y+c*M.z+d;\nif (l<0.0) {return true;}\nelse{return false;}\n}\nvec3 isect_surf(Ray r, mat4 matrix_coef){\nvec4 direction = vec4(r.direction, 0.0);\nvec4 origin = vec4(r.origin, 1.0);\nfloat a = dot(direction,(matrix_coef*direction));\nfloat b = dot(origin,(matrix_coef*direction));\nfloat c = dot(origin,(matrix_coef*origin));\nfloat delta =b*b-a*c;\ngl_FragColor.a = 1.0;\nif (delta<0.0){\ndiscard;\n}\nfloat t1 =(-b-sqrt(delta))/a;\nreturn r.origin+t1*r.direction;\n}\nvec3 isect_surf2(Ray r, mat4 matrix_coef){\nvec4 direction = vec4(r.direction, 0.0);\nvec4 origin = vec4(r.origin, 1.0);\nfloat a = dot(direction,(matrix_coef*direction));\nfloat b = dot(origin,(matrix_coef*direction));\nfloat c = dot(origin,(matrix_coef*origin));\nfloat delta =b*b-a*c;\ngl_FragColor.a = 1.0;\nif (delta<0.0){\ndiscard;\n}\nfloat t2 =(-b+sqrt(delta))/a;\nreturn r.origin+t2*r.direction;\n}\nRay primary_ray(vec4 near1, vec4 far1){\nvec3 near=near1.xyz/near1.w;\nvec3 far=far1.xyz/far1.w;\nreturn Ray(near,far-near);\n}\nfloat update_z_buffer(vec3 M, mat4 ModelViewP){\nfloat depth1;\nvec4 Ms=(ModelViewP*vec4(M,1.0));\nreturn depth1=(1.0+Ms.z/Ms.w)/2.0;\n}\nvoid main(){\nfloat radius = max( vRadius, vRadius2 );\nvec4 i_near, i_far, focus;\nvec3 e3, e1, e1_temp, e2;\ni_near = vec4(matrix_near[0][0],matrix_near[0][1],matrix_near[0][2],matrix_near[0][3]);\ni_far = vec4(matrix_near[1][0],matrix_near[1][1],matrix_near[1][2],matrix_near[1][3]);\nfocus = vec4(matrix_near[2][0],matrix_near[2][1],matrix_near[2][2],matrix_near[2][3]);\ne3 = vec3(matrix_near[3][0],matrix_near[3][1],matrix_near[3][2]);\ne1.x = 1.0;\ne1.y = 1.0;\ne1.z = ( (e3.x*focus.x + e3.y*focus.y + e3.z*focus.z) - e1.x*e3.x - e1.y*e3.y)/e3.z;\ne1_temp = e1 - focus.xyz;\ne1 = normalize(e1_temp);\ne2 = normalize(cross(e1,e3));\nvec4 equation = focus;\nfloat shrinkfactor = shrink;\nfloat t1 = -1.0/(1.0-shrinkfactor);\nfloat t2 = 1.0/(shrinkfactor);\nvec4 colonne1, colonne2, colonne3, colonne4;\nmat4 mat;\nvec3 equation1 = vec3(t2,t2,t1);\nfloat A1 = - e1.x*equation.x - e1.y*equation.y - e1.z*equation.z;\nfloat A2 = - e2.x*equation.x - e2.y*equation.y - e2.z*equation.z;\nfloat A3 = - e3.x*equation.x - e3.y*equation.y - e3.z*equation.z;\nfloat A11 = equation1.x*e1.x*e1.x + equation1.y*e2.x*e2.x + equation1.z*e3.x*e3.x;\nfloat A21 = equation1.x*e1.x*e1.y + equation1.y*e2.x*e2.y + equation1.z*e3.x*e3.y;\nfloat A31 = equation1.x*e1.x*e1.z + equation1.y*e2.x*e2.z + equation1.z*e3.x*e3.z;\nfloat A41 = equation1.x*e1.x*A1 + equation1.y*e2.x*A2 + equation1.z*e3.x*A3;\nfloat A22 = equation1.x*e1.y*e1.y + equation1.y*e2.y*e2.y + equation1.z*e3.y*e3.y;\nfloat A32 = equation1.x*e1.y*e1.z + equation1.y*e2.y*e2.z + equation1.z*e3.y*e3.z;\nfloat A42 = equation1.x*e1.y*A1 + equation1.y*e2.y*A2 + equation1.z*e3.y*A3;\nfloat A33 = equation1.x*e1.z*e1.z + equation1.y*e2.z*e2.z + equation1.z*e3.z*e3.z;\nfloat A43 = equation1.x*e1.z*A1 + equation1.y*e2.z*A2 + equation1.z*e3.z*A3;\nfloat A44 = equation1.x*A1*A1 + equation1.y*A2*A2 + equation1.z*A3*A3 - equation.w;\ncolonne1 = vec4(A11,A21,A31,A41);\ncolonne2 = vec4(A21,A22,A32,A42);\ncolonne3 = vec4(A31,A32,A33,A43);\ncolonne4 = vec4(A41,A42,A43,A44);\nmat = mat4(colonne1,colonne2,colonne3,colonne4);\nRay ray = primary_ray(i_near,i_far) ;\nvec3 M;\nM = isect_surf(ray, mat);\nif (cutoff_plane(M, prime1.xyz, -e3) || cutoff_plane(M, prime2.xyz, e3)){ discard; }\nvec4 M1 = vec4(M,1.0);\nvec4 M2 = mat*M1;\nvec3 _normal = ( modelViewMatrixInverseTranspose * M2 ).xyz;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix) ;\n#ifdef NEAR_CLIP\nif( calcClip( modelViewMatrix * vec4( M, 1.0 ) ) > 0.0 ){\nM = isect_surf2(ray, mat);\nif( calcClip( modelViewMatrix * vec4( M, 1.0 ) ) > 0.0 )\ndiscard;\ninterior = true;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix) ;\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( clipNear - 0.5 ) ) ) + ( 0.0000001 / radius ) );\n}\n}else if( gl_FragDepthEXT <= 0.0 ){\nM = isect_surf2(ray, mat);\ninterior = true;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix);\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / radius );\n}\n}\n#else\nif( gl_FragDepthEXT <= 0.0 ){\nM = isect_surf2(ray, mat);\ninterior = true;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix) ;\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / radius );\n}\n}\n#endif\nif (cutoff_plane(M, prime1.xyz, -e3) || cutoff_plane(M, prime2.xyz, e3)){ discard; }\nif (gl_FragDepthEXT < 0.0)\ndiscard;\nif (gl_FragDepthEXT > 1.0)\ndiscard;\nfloat distance_ratio = ((M.x-prime2.x)*e3.x + (M.y-prime2.y)*e3.y +(M.z-prime2.z)*e3.z) /\ndistance(prime2.xyz,prime1.xyz);\n#ifdef PICKING\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 vViewPosition = -( modelViewMatrix * vec4( M, 1.0 ) ).xyz;\nvec3 vNormal = _normal;\nvec3 vColor;\nif( distance_ratio>0.5 ){\nvColor = vColor1;\n}else{\nvColor = vColor2;\n}\nvec4 diffuseColor = vec4( diffuse, opacity );\nReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\nvec3 totalEmissiveLight = emissive;\n#include color_fragment\n#include roughnessmap_fragment\n#include metalnessmap_fragment\nvec3 normal = normalize( vNormal );\nvec3 geometryNormal = normal;\n#include lights_physical_fragment\n#include lights_fragment_begin\n#include lights_fragment_end\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\nif( interior ){\n#ifdef USE_INTERIOR_COLOR\noutgoingLight.xyz = interiorColor;\n#else\n#ifdef DIFFUSE_INTERIOR\noutgoingLight.xyz = vColor;\n#endif\n#endif\noutgoingLight.xyz *= 1.0 - interiorDarkening;\n}\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");const By=new Float32Array([-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,-1,1,-1,1,1,-1,1,1,1,-1,1,1]),Ny=new Uint16Array([0,1,2,0,2,3,1,5,6,1,6,2,4,6,5,4,7,6,0,7,4,0,3,7,0,5,1,0,4,5,3,2,6,3,6,7]);class Fy extends Zp{constructor(e,t={}){super("v3",e,t)}get mapping(){return By}get mappingIndices(){return Ny}get mappingIndicesSize(){return 36}get mappingSize(){return 8}get mappingItemSize(){return 3}}const zy=Object.assign({shrink:.14},em),Uy=Object.assign({shrink:{uniform:!0}},tm);class $y extends Fy{constructor(e,t={}){super(e,t),this.parameterTypes=Uy,this.isImpostor=!0,this.vertexShader="HyperballStickImpostor.vert",this.fragmentShader="HyperballStickImpostor.frag",this.addUniforms({modelViewProjectionMatrix:{value:new ri},modelViewProjectionMatrixInverse:{value:new ri},modelViewMatrixInverseTranspose:{value:new ri},shrink:{value:this.parameters.shrink}}),this.addAttributes({position1:{type:"v3",value:null},position2:{type:"v3",value:null},color2:{type:"c",value:null},radius:{type:"f",value:null},radius2:{type:"f",value:null}}),this.setAttributes(e),this.makeMapping()}get defaultParameters(){return zy}}Object.assign({disableImpostor:!1},ny,zy);const Gy=class{constructor(e,t={}){return!el||t&&t.disableImpostor?(e.radius=function(e,t){const i=e.length,n=new Float32Array(i);for(let r=0;ra.push(n.atomLabel(e)))))}else if("residue"===this.labelGrouping){t&&!t.position||(c=[]),t&&!t.color||(h=[]),t&&!t.radius||(l=[]),t&&!t.text||(a=[]),i.colorParams&&(i.colorParams.structure=e.getStructure());const u=al.getScheme(i.colorParams),d=new Tm(i.radiusParams),f=e.getAtomProxy();let m=0;e.eachResidue((e=>{const i=3*m;e.isProtein()||e.isNucleic()?(f.index=e.traceAtomIndex,t&&!t.position||f.positionToArray(c,i)):(f.index=e.atomOffset,t&&!t.position||e.positionToArray(c,i)),t&&!t.color||u.atomColorToArray(f,h,i),t&&!t.radius||(l[m]=d.atomRadius(f)),t&&!t.text||a.push(n.atomLabel(f)),++m})),t&&!t.position||(r=new Float32Array(c)),t&&!t.color||(o=new Float32Array(h)),t&&!t.radius||(s=new Float32Array(l))}return{position:r,size:s,color:o,text:a}}createData(e){return{bufferList:[new Xv(this.getTextData(e,{position:!0,color:!0,radius:!0,text:!0}),this.getBufferParams({fontFamily:this.fontFamily,fontStyle:this.fontStyle,fontWeight:this.fontWeight,xOffset:this.xOffset,yOffset:this.yOffset,zOffset:this.zOffset,attachment:this.attachment,showBorder:this.showBorder,borderColor:this.borderColor,borderWidth:this.borderWidth,showBackground:this.showBackground,backgroundColor:this.backgroundColor,backgroundMargin:this.backgroundMargin,backgroundOpacity:this.backgroundOpacity,fixedSize:this.fixedSize}))]}}updateData(e,t){t.bufferList[0].setAttributes(this.getTextData(t.sview,e))}getAtomRadius(){return 0}}function Wy(e){const t=e.getAtomSet(),i=e.getBondSet(),n=e.getBondProxy();return i.forEach((function(e){n.index=e,t.clear(n.atomIndex1),t.clear(n.atomIndex2)})),t}ll.add("label",jy);class qy extends Bv{constructor(e,t,i){super(e,t,i),this.type="line",this.parameters=Object.assign({multipleBond:{type:"select",rebuild:!0,options:{off:"off",symmetric:"symmetric",offset:"offset"}},bondSpacing:{type:"number",precision:2,max:2,min:.5},linewidth:{type:"integer",max:50,min:1,buffer:!0},lines:{type:"boolean",rebuild:!0},crosses:{type:"select",rebuild:!0,options:{off:"off",lone:"lone",all:"all"}},crossSize:{type:"number",precision:2,max:2,min:.1}},this.parameters,{flatShaded:null,side:null,wireframe:null,roughness:null,metalness:null}),this.init(i)}init(e){var t=e||{};this.multipleBond=Ia(t.multipleBond,"off"),this.bondSpacing=Ia(t.bondSpacing,1),this.linewidth=Ia(t.linewidth,2),this.lines=Ia(t.lines,!0),this.crosses=Ia(t.crosses,"lone"),this.crossSize=Ia(t.crossSize,.4),super.init(t)}getAtomRadius(e){return.1}getBondParams(e,t){return t=Object.assign({multipleBond:this.multipleBond,bondSpacing:this.bondSpacing,radiusParams:{type:"size",size:.1,scale:1}},t),super.getBondParams(e,t)}_crossData(e,t){if(e&&!e.position&&!e.color)return;const i={};"lone"===this.crosses&&Object.assign(i,{atomSet:Wy(t)});const n=t.getAtomData(this.getAtomParams(e,i)),r={},s=n.position,o=n.color,a=n.picking,c=(s||o).length,l=3*c;let h=new Float32Array(0),u=new Float32Array(0),d=new Float32Array(0),f=new Float32Array(0),m=0,p=new Float32Array(0);e&&!e.position||(h=r.position1=new Float32Array(l),u=r.position2=new Float32Array(l),m=this.crossSize/2),e&&!e.color||(d=r.color=new Float32Array(l),f=r.color2=new Float32Array(l)),e&&!e.picking||(p=new Float32Array(3*n.picking.array.length));for(let t=0;tl?d[p]=-1:(c=Math.sqrt(l-a),d[p]=Math.floor(c)),++p;m[g]=u,f[g]=d}}function T(i){var n,r,s,a,u,p,y,b,_,w,A,M,C,P,T,I,E,D,L=3*i,R=i;n=Math.floor(.5+o*(e[L]+d[0])),r=Math.floor(.5+o*(e[L+1]+d[1])),s=Math.floor(.5+o*(e[L+2]+d[2]));var k,O=t[R],B=f[O],N=0,F=l*h,z=m[O];for(w=0;w=c||P>=l||T>=h)){var U=C*F+P*h+T;if(g)if(v[U]&S){if(v[U]&S){var $=x[U];$!==L&&y*y+b*b+_*_<(a=n+y-Math.floor(.5+o*(e[$]+d[0])))*a+(u=r+b-Math.floor(.5+o*(e[$+1]+d[1])))*u+(p=s+_-Math.floor(.5+o*(e[$+2]+d[2])))*p&&(x[U]=i)}}else v[U]|=S,x[U]=i;else v[U]|=S}N++}}function I(t){var i,n;for(console.time("EDTSurface fillvoxels"),i=0,n=v.length;i=c||S>=l||M>=h)){var F=w*N+S*h+M;if(v[F]&A){if(g){var z=x[F];y*y+b*b+_*_<(a=Math.floor(.5+o*(e[z]+d[0])))*a+(u=Math.floor(.5+o*(e[z+1]+d[1])))*u+(p=Math.floor(.5+o*(e[z+2]+d[2])))*p&&(x[F]=i)}}else v[F]|=A,g&&(x[F]=i)}O++}}function D(){var e,t,i,n;console.time("EDTSurface fastdistancemap");var r,s=Xy(c,l,h,Uint16Array,3),o=l*h,u=p*p,d=0;for(e=0;e0);var w,C=a*a,P=new Uint16Array(3);for(e=0;e=C)||(v[r]|=M,g&&v[r]&A&&(s.toArray(e,t,i,P),w=P[0]*o+P[1]*h+P[2],x[r]=x[w])));console.timeEnd("EDTSurface fastdistancemap")}function L(e,t,i,n){var r,s,o,a,u,d,f,m,p,g,x,b,_=new Uint16Array(3),w=0;if(0===i)return w;var P=-1,T=-1,I=-1,E=l*h;for(f=0,p=i;f-1&&T-1&&I-1&&(v[x=P*E+h*T+I]&S&&!(v[x]&A)?(t.fromArray(P,T,I,_),g=(a=P-_[0])*a+(u=T-_[1])*u+(d=I-_[2])*d,y[x]=g,v[x]|=A,v[x]|=M,n[w]=P,n[w+1]=T,n[w+2]=I,w+=3):v[x]&S&&v[x]&A&&(g=(a=P-_[0])*a+(u=T-_[1])*u+(d=I-_[2])*d)-1&&T-1&&I-1&&(v[x=P*E+h*T+I]&S&&!(v[x]&A)?(t.fromArray(P,T,I,_),g=(a=P-_[0])*a+(u=T-_[1])*u+(d=I-_[2])*d,y[x]=g,v[x]|=A,v[x]|=M,n[w]=P,n[w+1]=T,n[w+2]=I,w+=3):v[x]&S&&v[x]&A&&(g=(a=P-_[0])*a+(u=T-_[1])*u+(d=I-_[2])*d)-1&&T-1&&I-1&&(v[x=P*E+h*T+I]&S&&!(v[x]&A)?(t.fromArray(P,T,I,_),g=(a=P-_[0])*a+(u=T-_[1])*u+(d=I-_[2])*d,y[x]=g,v[x]|=A,v[x]|=M,n[w]=P,n[w+1]=T,n[w+2]=I,w+=3):v[x]&S&&v[x]&A&&(g=(a=P-_[0])*a+(u=T-_[1])*u+(d=I-_[2])*d)-1&&o-1&&u-1&&aE&&(E=k)}return{neighbourListLength:27*E+1,withinRadii:function(r,s,o,a,u){for(var d=0,f=m(r,c),p=m(s,l),g=m(o,h),v=Math.max(0,f-1),_=Math.max(0,p-1),S=Math.max(0,g-1),A=Math.min(y,f+2),M=Math.min(x,p+2),I=Math.min(b,g+2),E=v;Ed&&(d=h[e]);!function(){const e=qf(c,l,d,m,0);m=e.scaleFactor,v=e.dim,y=e.matrix,R=Math.max(5,2+Math.floor(f*m)),x=Gl(v[0]*v[1]*v[2],-1001),b=new Int32Array(x.length),_=new Float32Array(v[0]),w=new Float32Array(v[1]),S=new Float32Array(v[2]),O(_,c[0],1/m),O(w,c[1],1/m),O(S,c[2],1/m)}(),function(){var e=0,t=2*Math.PI/g;M=new Float32Array(g),A=new Float32Array(g);for(var i=0;i=0;){if(s!==n&&s!==r&&N(s,e,t,i))return T=s,s;s=P[++o]}return T=-1,-1}function N(t,i,n,r){var s=3*t,o=u[t],a=e[s]-i,c=e[s+1]-n,l=e[s+2]-r;return a*a+c*c+l*l0&&d=0;)e{t(this._makeSurface(e.data.sd,i))}),(e=>{console.warn("MolecularSurface.getSurfaceWorker error - trying without worker",e),this.worker.terminate(),this.worker=void 0;const n=this.getSurface(i);t(n)}))}else{const e=this.getSurface(i);t(e)}}dispose(){this.worker&&this.worker.terminate()}}class Jy extends Bv{constructor(e,t,i){super(e,t,i),this.type="surface",this.parameters=Object.assign({surfaceType:{type:"select",rebuild:!0,options:{vws:"vws",sas:"sas",ms:"ms",ses:"ses",av:"av"}},probeRadius:{type:"number",precision:1,max:20,min:0,rebuild:!0},smooth:{type:"integer",precision:1,max:10,min:0,rebuild:!0},scaleFactor:{type:"number",precision:1,max:5,min:0,rebuild:!0},cutoff:{type:"number",precision:2,max:50,min:0,rebuild:!0},contour:{type:"boolean",rebuild:!0},background:{type:"boolean",rebuild:!0},opaqueBack:{type:"boolean",buffer:!0},filterSele:{type:"text",rebuild:!0},colorVolume:{type:"hidden"},useWorker:{type:"boolean",rebuild:!0}},this.parameters,{radius:null,scale:null}),this.__infoList=[],this.structure.signals.refreshed.add((()=>{this.__forceNewMolsurf=!0})),this.toBePrepared=!0,this.init(i)}init(e){const t=e||{};t.colorScheme=Ia(t.colorScheme,"uniform"),t.colorValue=Ia(t.colorValue,14540253),t.disablePicking=Ia(t.disablePicking,!0),this.surfaceType=Ia(t.surfaceType,"ms"),this.probeRadius=Ia(t.probeRadius,1.4),this.smooth=Ia(t.smooth,2),this.scaleFactor=Ia(t.scaleFactor,2),this.cutoff=Ia(t.cutoff,0),this.contour=Ia(t.contour,!1),this.background=Ia(t.background,!1),this.opaqueBack=Ia(t.opaqueBack,!0),this.filterSele=Ia(t.filterSele,""),this.colorVolume=Ia(t.colorVolume,void 0),this.useWorker=Ia(t.useWorker,!0),super.init(e)}prepareData(e,t,i){let n=this.__infoList[t];if(n||(n={},this.__infoList[t]=n),n.molsurf&&n.sele===e.selection.string)i(t);else{if(this.filterSele){const n=e.structure.getView(new $c(this.filterSele)),r=n.boundingBox.getSize(new Zt),s=Math.max(r.x,r.y,r.z),o=e.getAtomSetWithinPoint(n.center,s/2+6);if(0===(e=e.getView(new $c(e.getAtomSetWithinSelection(o,3).toSeleString()))).atomCount)return void i(t)}n.sele=e.selection.string,n.molsurf=new Qy(e);const r=this.getSurfaceParams(),s=e=>{n.surface=e,i(t)};this.useWorker?n.molsurf.getSurfaceWorker(r,s):s(n.molsurf.getSurface(r))}}prepare(e){if((this.__forceNewMolsurf||this.__sele!==this.selection.string||this.__surfaceParams!==JSON.stringify(this.getSurfaceParams()))&&(this.__infoList.forEach((e=>{e&&e.molsurf&&e.molsurf.dispose()})),this.__infoList.length=0),0===this.structureView.atomCount)return void e();const t=()=>{this.__sele=this.selection.string,this.__surfaceParams=JSON.stringify(this.getSurfaceParams()),this.__forceNewMolsurf=!1,e()},i="default"===this.assembly?this.defaultAssembly:this.assembly,n=this.structure.biomolDict[i];n?n.partList.forEach(((e,i)=>{const r=e.getView(this.structureView);this.prepareData(r,i,(e=>{e===n.partList.length-1&&t()}))})):this.prepareData(this.structureView,0,t)}createData(e,t){const i=this.__infoList[t],n=i.surface;if(!n)return;const r={position:n.getPosition(),color:n.getColor(this.getColorParams()),index:n.getFilteredIndex(this.filterSele,e)},s=[];if(n.contour){const e=new cm(r,this.getBufferParams({wireframe:!1}));s.push(e)}else{Object.assign(r,{normal:n.getNormal(),picking:n.getPicking(e.getStructure())});const t=new rm(r,this.getBufferParams({background:this.background,opaqueBack:this.opaqueBack,dullInterior:!1}));if("double"==this.getBufferParams().side){const e=new am(t);s.push(e)}else s.push(t)}return{bufferList:s,info:i}}updateData(e,t){const i={};if(e.position||e.radius)return this.__forceNewMolsurf=!0,void this.build();e.color&&(i.color=t.info.surface.getColor(this.getColorParams())),e.index&&(i.index=t.info.surface.getFilteredIndex(this.filterSele,t.sview)),t.bufferList[0].setAttributes(i)}setParameters(e,t={},i){return e&&e.filterSele&&(t.index=!0),e&&void 0!==e.colorVolume&&(t.color=!0),e&&e.wireframe&&(e.contour||void 0===e.contour&&this.contour)&&(e.wireframe=!1),super.setParameters(e,t,i),this}getSurfaceParams(e={}){return Object.assign({type:this.surfaceType,probeRadius:this.probeRadius,scaleFactor:this.scaleFactor,smooth:this.smooth&&!this.contour,cutoff:this.cutoff,contour:this.contour,useWorker:this.useWorker,radiusParams:this.getRadiusParams()},e)}getColorParams(){const e=super.getColorParams();return e.volume=this.colorVolume,e}getAtomRadius(){return 0}clear(){super.clear()}dispose(){this.__infoList.forEach((e=>{e&&e.molsurf&&e.molsurf.dispose()})),this.__infoList.length=0,super.dispose()}}ll.add("surface",Jy);class ex extends Bv{constructor(e,t,i){super(e,t,i),this.type="point",this.parameters=Object.assign({pointSize:{type:"number",precision:1,max:100,min:0,buffer:!0},sizeAttenuation:{type:"boolean",buffer:!0},sortParticles:{type:"boolean",rebuild:!0},useTexture:{type:"boolean",buffer:!0},alphaTest:{type:"range",step:.001,max:1,min:0,buffer:!0},forceTransparent:{type:"boolean",buffer:!0},edgeBleach:{type:"range",step:.001,max:1,min:0,buffer:!0}},this.parameters,{flatShaded:null,wireframe:null,linewidth:null,side:null,roughness:null,metalness:null}),this.init(i)}init(e){var t=e||{};this.pointSize=Ia(t.pointSize,1),this.sizeAttenuation=Ia(t.sizeAttenuation,!0),this.sortParticles=Ia(t.sortParticles,!1),this.useTexture=Ia(t.useTexture,!1),this.alphaTest=Ia(t.alphaTest,.5),this.forceTransparent=Ia(t.forceTransparent,!1),this.edgeBleach=Ia(t.edgeBleach,0),super.init(t)}createData(e){var t=e.getAtomData(this.getAtomParams({position:!0,color:!0,picking:!0}));return{bufferList:[new sg(t,this.getBufferParams({pointSize:this.pointSize,sizeAttenuation:this.sizeAttenuation,sortParticles:this.sortParticles,useTexture:this.useTexture,alphaTest:this.alphaTest,forceTransparent:this.forceTransparent,edgeBleach:this.edgeBleach}))]}}updateData(e,t){var i=t.sview.getAtomData(this.getAtomParams(e)),n={};e&&!e.position||Object.assign(n,{position:i.position}),e&&!e.color||Object.assign(n,{color:i.color}),t.bufferList[0].setAttributes(n)}getAtomRadius(){return.1}}ll.add("point",ex),ul.add("shader/Ribbon.vert","#define STANDARD\nuniform float clipNear;\nuniform vec3 clipCenter;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvarying vec3 vViewPosition;\n#endif\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\nattribute vec3 dir;\nattribute float size;\n#ifdef PICKING\n#include unpack_color\nattribute float primitiveId;\nvarying vec3 vPickingColor;\n#else\n#include color_pars_vertex\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\n#endif\n#include common\nvoid main(void){\n#ifdef PICKING\nvPickingColor = unpackColor( primitiveId );\n#else\n#include color_vertex\n#include beginnormal_vertex\n#include defaultnormal_vertex\n#ifndef FLAT_SHADED\nvNormal = normalize( transformedNormal );\n#endif\n#endif\n#include begin_vertex\ntransformed += normalize( dir ) * size;\n#include project_vertex\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvViewPosition = -mvPosition.xyz;\n#endif\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n#include nearclip_vertex\n}");const tx=new Uint16Array([0,1,2,1,3,2]);function ix(e){return 3*(4*(e.position.length/3-1))}class nx extends nm{constructor(e,t={}){super({position:new Float32Array(ix(e)),color:new Float32Array(ix(e)),index:Ga(ix(e),ix(e)/3),normal:new Float32Array(ix(e)),picking:e.picking},t),this.vertexShader="Ribbon.vert";const i=e.position.length/3-1,n=4*i,r=3*n;this.addAttributes({dir:{type:"v3",value:new Float32Array(r)}}),this.addAttributes({size:{type:"f",value:new Float32Array(n)}}),e.primitiveId=Hl(i),this.setAttributes(e),this.makeIndex()}setAttributes(e={}){const t=this.size/4,i=this.geometry.attributes;let n,r,s,o,a,c,l,h,u,d,f,m,p,g,v,y,x,b,_;e.position&&(n=e.position,l=i.position.array,i.position.needsUpdate=!0),e.normal&&(r=e.normal,h=i.normal.array,i.normal.needsUpdate=!0),e.size&&(s=e.size,u=i.size.array,i.size.needsUpdate=!0),e.dir&&(o=e.dir,d=i.dir.array,i.dir.needsUpdate=!0),e.color&&(a=e.color,f=i.color.array,i.color.needsUpdate=!0),e.primitiveId&&(c=e.primitiveId,m=i.primitiveId.array,i.primitiveId.needsUpdate=!0);let w=s?s[0]:null;for(p=0;p{if(!(e.residueCount<4)){i.push(e);var n=new yy(e,this.getSplineParams()),r=n.getSubdividedPosition(),s=n.getSubdividedOrientation(),o=n.getSubdividedColor(this.getColorParams()),a=n.getSubdividedPicking(),c=n.getSubdividedSize(this.getRadiusParams());t.push(new nx({position:r.position,normal:s.binormal,dir:s.normal,color:o.color,size:c.size,picking:a.picking},this.getBufferParams()))}}),e.getSelection()),{bufferList:t,polymerList:i}}updateData(e,t){e=e||{};var i=0,n=t.polymerList.length;for(i=0;i{if(e.residueCount<4||e.isNucleic())return;const r=new Um(e),s=r.getAxis(this.localAngle,this.centerDist,this.ssBorder,this.getColorParams(),this.getRadiusParams());t+=s.size.length,i.push(s),n.push(r)}),e.getSelection());const r={begin:new Float32Array(3*t),end:new Float32Array(3*t),size:new Float32Array(t),color:new Float32Array(3*t),picking:{}};let s=new Float32Array(t),o=0;i.forEach((function(e){r.begin.set(e.begin,3*o),r.end.set(e.end,3*o),r.size.set(e.size,o),r.color.set(e.color,3*o),s.set(e.picking.array,o),o+=e.size.length})),t&&(r.picking=new hf(s,e.getStructure()));return{bufferList:[new dy({position1:r.begin,position2:r.end,color:r.color,color2:r.color,radius:r.size,picking:r.picking},this.getBufferParams({openEnded:this.openEnded,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0}))],axisList:i,helixbundleList:n,axisData:r}}updateData(e,t){if((e=e||{}).position)this.build();else{var i={};if(e.color||e.radius){var n=0;t.helixbundleList.forEach((i=>{var r=i.getAxis(this.localAngle,this.centerDist,this.ssBorder,this.getColorParams(),this.getRadiusParams());e.color&&t.axisData.color.set(r.color,3*n),(e.radius||e.scale)&&t.axisData.size.set(r.size,n),n+=r.size.length})),e.color&&Object.assign(i,{color:t.axisData.color,color2:t.axisData.color}),(e.radius||e.scale)&&Object.assign(i,{radius:t.axisData.size})}t.bufferList[0].setAttributes(i)}}}ll.add("rocket",sx);class ox extends Sy{constructor(e,t,i){super(e,t,i),this.type="rope",this.parameters=Object.assign({smooth:{type:"integer",max:15,min:0,rebuild:!0}},this.parameters,{aspectRatio:null,smoothSheet:null})}init(e){var t=e||{};t.aspectRatio=1,t.tension=Ia(t.tension,.5),t.radiusScale=Ia(t.radiusScale,5),t.smoothSheet=!1,this.smooth=Ia(t.smooth,2),super.init(t)}getSpline(e){var t=new zm(e);return new yy(e,this.getSplineParams({directional:!1,positionIterator:t.getCenterIterator(this.smooth)}))}}ll.add("rope",ox);class ax extends Bv{constructor(e,t,i){super(e,t,i),this.type="spacefill",this.parameters=Object.assign({sphereDetail:!0,disableImpostor:!0},this.parameters),this.init(i)}init(e){var t=e||{};t.useInteriorColor=Ia(t.useInteriorColor,!0),super.init(t)}createData(e){return{bufferList:[new tg(e.getAtomData(this.getAtomParams()),this.getBufferParams({sphereDetail:this.sphereDetail,dullInterior:!0,disableImpostor:this.disableImpostor}))]}}updateData(e,t){var i=t.sview.getAtomData(this.getAtomParams(e)),n={};e&&!e.position||Object.assign(n,{position:i.position}),e&&!e.color||Object.assign(n,{color:i.color}),e&&!e.radius||Object.assign(n,{radius:i.radius}),t.bufferList[0].setAttributes(n)}}function cx(e){return 3*(e.position.length/3-1)*2}ll.add("spacefill",ax);class lx extends im{constructor(e,t={}){super({position:new Float32Array(cx(e)),color:new Float32Array(cx(e))},t),this.isLine=!0,this.vertexShader="Line.vert",this.fragmentShader="Line.frag",this.setAttributes(e)}setAttributes(e){let t,i,n,r;const s=this.geometry.attributes;if(e.position&&(t=e.position,n=s.position.array,s.position.needsUpdate=!0),e.color&&(i=e.color,r=s.color.array,s.color.needsUpdate=!0),!t&&!i)return void il.warn("TraceBuffer.prototype.setAttributes no data");let o,a;const c=this.size-1;for(let e=0;e{if(!(e.residueCount<4)){i.push(e);var n=new yy(e,this.getSplineParams()),r=n.getSubdividedPosition(),s=n.getSubdividedColor(this.getColorParams());t.push(new lx(Object.assign({},r,s),this.getBufferParams()))}}),e.getSelection()),{bufferList:t,polymerList:i}}updateData(e,t){e=e||{};var i=0,n=t.polymerList.length;for(i=0;i{e.boundingBox||e.computeBoundingBox(),this.boundingBox.union(e.boundingBox)}))}}const _x=Object.assign({aspectRatio:1.5,radialSegments:50,openEnded:!1,disableImpostor:!1},em);class wx{constructor(e,t={}){this.group=new ko,this.wireframeGroup=new ko,this.pickingGroup=new ko,this.visible=!0,this.parameters=Ea(t,this.defaultParameters),this.splitPosition=new Float32Array(e.position1.length),this.cylinderRadius=new Float32Array(e.radius.length);const i=this.makeAttributes(e),n={radialSegments:this.parameters.radialSegments,openEnded:this.parameters.openEnded,disableImpostor:this.parameters.disableImpostor};this.cylinderBuffer=new dy(i.cylinder,n),this.coneBuffer=new xx(i.cone,n),this.geometry=new bx([this.cylinderBuffer.geometry,this.coneBuffer.geometry]),this.matrix=Ia(t.matrix,new ri),this.picking=e.picking}get defaultParameters(){return _x}set matrix(e){im.prototype.setMatrix.call(this,e)}get matrix(){return this.group.matrix.clone()}get pickable(){return!!this.picking}makeAttributes(e={}){const t=this.splitPosition,i=this.cylinderRadius,n=this.parameters.aspectRatio;let r,s;const o={},a={};if(e.radius){for(r=0,s=i.length;r(this._beforeParse(),this._parse(),this._afterParse(),this[this.__objName])))}_parse(){}_beforeParse(){}_afterParse(){e.Debug&&il.log(this[this.__objName])}}class Kx extends Zx{constructor(e,t){var i=t||{};super(e,i),this.firstModelOnly=Ia(i.firstModelOnly,!1),this.asTrajectory=Ia(i.asTrajectory,!1),this.cAlphaOnly=Ia(i.cAlphaOnly,!1),this.structure=new Fp(this.name,this.path),this.structureBuilder=new ep(this.structure)}get type(){return"structure"}get __objName(){return"structure"}}class Qx{constructor(e,t,i="",n,r=[]){this.structure=e,this.index=t,this.description=i,this.entityType=function(e){switch(e=e.toLowerCase()){case"polymer":return 1;case"non-polymer":return 2;case"macrolide":return 3;case"water":return 4;default:return 0}}(n||""),this.chainIndexList=r,r.forEach((function(i){e.chainStore.entityIndex[i]=t}))}get type(){return function(e){switch(e){case 1:return"polymer";case 2:return"non-polymer";case 3:return"macrolide";case 4:return"water";default:return}}(this.entityType)}getEntityType(){return this.entityType}isPolymer(){return 1===this.entityType}isNonPolymer(){return 2===this.entityType}isMacrolide(){return 3===this.entityType}isWater(){return 4===this.entityType}eachChain(e){const t=this.structure.getChainProxy();this.chainIndexList.forEach((function(i){t.index=i,e(t)}))}}const Jx={a:1,b:1,c:1,alpha:90,beta:90,gamma:90,spacegroup:"P 1"};class eb{constructor(e=Jx){this.cartToFrac=new ri,this.fracToCart=new ri,this.a=e.a,this.b=e.b,this.c=e.c,this.alpha=e.alpha,this.beta=e.beta,this.gamma=e.gamma,this.spacegroup=e.spacegroup;const t=Ka(this.alpha),i=Ka(this.beta),n=Ka(this.gamma),r=Math.cos(t),s=Math.cos(i),o=Math.cos(n),a=Math.sin(i),c=Math.sin(n);if(this.volume=this.a*this.b*this.c*Math.sqrt(1-r*r-s*s-o*o+2*r*s*o),void 0===e.cartToFrac){const e=this.a*this.b*c/this.volume,t=(s*o-r)/(a*c);this.fracToCart.set(this.a,0,0,0,this.b*o,this.b*c,0,0,this.c*s,-this.c*a*t,1/e,0,0,0,0,1).transpose(),this.cartToFrac.getInverse(this.fracToCart)}else this.cartToFrac.copy(e.cartToFrac),this.fracToCart.getInverse(this.cartToFrac)}getPosition(e){const t=new Float32Array(24);if(e.unitcell){const i=e.unitcell,n=e.center.clone().applyMatrix4(i.cartToFrac).floor(),r=new Zt;let s=0;const o=function(e,o,a){r.set(e,o,a).add(n).applyMatrix4(i.fracToCart).toArray(t,s),s+=3};o(0,0,0),o(1,0,0),o(0,1,0),o(0,0,1),o(1,1,0),o(1,0,1),o(0,1,1),o(1,1,1)}return t}getCenter(e){return function(e,t=new Zt){const i=e.length;for(let n=0;n0)continue;let e,i,n,r,a,g=0;if(s){if(r=A.split(rb),g=10===r.length?1:0,L=r[2],m&&"CA"!==L)continue;e=parseFloat(r[6-g]),i=parseFloat(r[7-g]),n=parseFloat(r[8-g])}else{if(L=A.substr(12,4).trim(),m&&"CA"!==L)continue;e=parseFloat(A.substr(30,8)),i=parseFloat(A.substr(38,8)),n=parseFloat(A.substr(46,8))}if(f){const t=3*y;if(v[t+0]=e,v[t+1]=i,v[t+2]=n,y+=1,x)continue}s?(C=parseInt(r[1]),a="",R="H"===A[0],P=g?"":r[4],T=parseInt(r[5-g]),D="",I=r[3],O="",E=1):(C=parseInt(A.substr(6,5),h),l&&99999===C&&(h=16),R="H"===A[0],P=A[21].trim(),T=parseInt(A.substr(22,4),u),l&&9999===T&&(u=16),D=A[26].trim(),I=A.substr(17,4).trim()||"MOL",k=parseFloat(A.substr(60,6)),O=A[16].trim(),E=parseFloat(A.substr(54,6)),t||(o?(a=A.substr(76,3).trim(),a in Td&&(a=Td[a])):(a=A.substr(76,2).trim(),P||(P=A.substr(72,4).trim())),B=parseInt((A.substr(79,1)+A.substr(78,1)).trim()))),ue.growIfFull(),ue.atomTypeId[me]=he.add(L,a),ue.x[me]=e,ue.y[me]=i,ue.z[me]=n,ue.serial[me]=C,ue.altloc[me]=O.charCodeAt(0),ue.occupancy[me]=isNaN(E)?0:E,s?(ue.partialCharge[me]=parseFloat(r[9-g]),ue.radius[me]=parseFloat(r[10-g])):(ue.bfactor[me]=isNaN(k)?0:k,o&&(ue.partialCharge[me]=parseFloat(A.substr(70,6))),isFinite(B)&&(ue.formalCharge||ue.addField("formalCharge",1,"int8"),ue.formalCharge[me]=B));const b=sb(T,P,D);!R||Z[b]||ib.includes(I)?ee||te===P||(Q+=1,J=Q.toString()):te===P&&ne===I&&(wd.includes(I)||ie===T&&re===D)||(Q+=1,J=Q.toString(),ie=T,ne=I,re=D),c.addAtom(pe,P,J,I,T,R,void 0,D),V[C]=me,me+=1,ee=!1,te=P}else if("CONECT"===M){const e=V[parseInt(A.substr(6,5))],t=[11,16,21,26],i={};if(void 0===e)continue;for(let n=0;n<4;++n){let r=parseInt(A.substr(t[n],5));if(!Number.isNaN(r)&&(r=V[r],void 0!==r))if(e0)continue;const L=n[c].replace(lb,"");if(P&&"CA"!==L)continue;const R=parseFloat(n[y]),k=parseFloat(n[x]),O=parseFloat(n[b]);if(C){const e=3*i;if(t[e+0]=R,t[e+1]=k,t[e+2]=O,i+=1,q>0)continue}const B=n[l],N=parseInt(n[-1!==o?o:a]);let F=n[v];F="?"===F?"":F;const z=n[s],U=n[h],X="H"===n[f][0],Y=n[p],Z=parseFloat(n[_]),K=parseFloat(n[w]);let Q=n[d];if(Q="."===Q?"":Q,H.growIfFull(),H.atomTypeId[W]=V.add(L,Y),H.x[W]=R,H.y[W]=k,H.z[W]=O,H.serial[W]=parseInt(n[m]),H.bfactor[W]=isNaN(Z)?0:Z,H.occupancy[W]=isNaN(K)?0:K,H.altloc[W]=Q.charCodeAt(0),A.addAtom(q,z,U,B,N,X,void 0,F),e.Debug){const t=E[U];void 0!==t&&t!==z&&e.Debug&&il.warn(t,z)}E[U]=z;const J=n[u];D[J]||(D[J]=new Set),D[J].add(S.chainStore.count-1),W+=1}else{const e=r.match(cb),t=e.length;F===N.length&&(F=0);for(let i=0;ic*c)return r.growIfFull(),r.atomTypeId[f]=r.atomTypeId[e],r.x[f]=h.x,r.y[f]=h.y,r.z[f]=h.z,r.occupancy[f]=r.occupancy[e],r.serial[f]=f,r.altloc[f]="A".charCodeAt(0),i.addAtom(0,"","","HET",1,!0),void(f+=1)}}}))}}(I,S,A),A.finalize(),S.finalizeAtoms(),op(S),S.finalizeBonds();else{var X=function(e,t,i){var n,r,s,o,a=[],c=[],l=e.struct_conf;if(null==l?void 0:l.pdbx_PDB_helix_class)for(fb(l,"id"),n=0,r=l.beg_auth_seq_id.length;n0){s=s.split("(");var c=a(s[0]),l=a(s[1]);Object.keys(c).forEach((function(e){Object.keys(l).forEach((function(t){var i=new ri;i.multiplyMatrices(c[e],l[t]),n[e+"x"+t]=i}))}))}else n=a(s);var h=[];for(var u in n)h.push(n[u]);var d=e;/^(0|[1-9][0-9]*)$/.test(d)&&(d="BU"+d);for(var f=o.asym_id_list[t].split(","),m=0,p=f.length;mS){var A=w;w=S,S=A;var M=p;p=b,b=M}if(0!==w&&0!==S)for(var C=0;Cx)continue}d=P.substr(5,5).trim(),f=parseInt(P.substr(0,5)),m=parseInt(P.substr(15,5)),_.growIfFull(),_.atomTypeId[w]=b.add(u),_.x[w]=E,_.y[w]=D,_.z[w]=L,_.serial[w]=m,r.addAtom(S,"","",d,f,!1,"l"),w+=1}}}(0,e.length,e)})),r.finalize(),n.finalizeAtoms(),sp(n),op(n),n.finalizeBonds(),ip(n),e.Debug&&il.timeEnd("GroParser._parse "+this.name)}});var yb=["mmtfVersion","mmtfProducer","unitCell","spaceGroup","structureId","title","depositionDate","releaseDate","experimentalMethods","resolution","rFree","rWork","bioAssemblyList","ncsOperatorList","entityList","groupList","numBonds","numAtoms","numGroups","numChains","numModels","groupsPerChain","chainsPerModel"].concat(["xCoordList","yCoordList","zCoordList","groupIdList","groupTypeList","chainIdList","bFactorList","atomIdList","altLocList","occupancyList","secStructList","insCodeList","sequenceIndexList","chainNameList","bondAtomList","bondOrderList"]);function xb(e,t,i){return t?new e(t.buffer,t.byteOffset,t.byteLength/(i||1)):void 0}function bb(e){return xb(DataView,e)}function _b(e){return xb(Int8Array,e)}function wb(e){return xb(Int32Array,e,4)}function Sb(e,t){var i=e.length/2;t||(t=new Int16Array(i));for(var n=0,r=0;ns&&++a;t=new Int32Array(a)}for(i=0,n=0;ir){for(var s=[],o=0;o0&&(o.biomolDict[e]=t)}const k=a.unitCell;k&&Array.isArray(k)&&k[0]?o.unitcell=new eb({a:k[0],b:k[1],c:k[2],alpha:k[3],beta:k[4],gamma:k[5],spacegroup:a.spaceGroup}):o.unitcell=void 0,hp(o,!0),lp(o,!0),o.finalizeAtoms(),o.finalizeBonds(),up(o),e.Debug&&il.timeEnd("MmtfParser._parse "+this.name)}});const Ob=/\s+/,Bb={1:1,2:2,3:3,am:1,ar:1,du:1,un:1,nc:0};hl.add("mol2",class extends Kx{get type(){return"mol2"}_parse(){e.Debug&&il.time("Mol2Parser._parse "+this.name);const t=this.structure,i=this.structureBuilder,n=this.firstModelOnly,r=this.asTrajectory,s=t.frames;let o,a,c=!1;const l=t.atomMap,h=t.atomStore;h.resize(Math.round(this.streamer.data.length/60)),h.addField("partialCharge",1,"float32");let u=0,d=0,f=0,m=-1,p=0,g=0;const v=t.getAtomProxy(),y=t.getAtomProxy();this.streamer.eachChunkOfLines((function(e){!function(e,x,b){for(let _=e;_MOLECULE"===e?(g=1,d=0,++m):"@ATOM"===e?(g=2,f=h.count,r&&(a=0,o=new Float32Array(3*p),s.push(o),m>0&&(c=!0))):g="@BOND"===e?3:0;else if(1===g){if(0===d)t.title=e,t.id=e;else if(1===d){const t=e.split(Ob);p=parseInt(t[0])}++d}else if(2===g){const t=e.split(Ob);if(n&&m>0)continue;const s=parseFloat(t[2]),d=parseFloat(t[3]),f=parseFloat(t[4]);if(r){const e=3*a;if(o[e+0]=s,o[e+1]=d,o[e+2]=f,a+=1,c)continue}const p=t[0],g=t[1],v=t[5].split(".")[0],y=t[6]?parseInt(t[6]):1,x=t[7]?t[7]:"",b=t[8]?parseFloat(t[8]):0;h.growIfFull(),h.atomTypeId[u]=l.add(g,v),h.x[u]=s,h.y[u]=d,h.z[u]=f,h.serial[u]=p,h.partialCharge[u]=b,i.addAtom(m,"","",x,y,!0),u+=1}else if(3===g){if(n&&m>0)continue;if(r&&m>0)continue;const i=e.split(Ob);v.index=parseInt(i[1])-1+f,y.index=parseInt(i[2])-1+f;const s=Bb[i[3]];t.bondStore.addBond(v,y,s)}}}(0,e.length,e)})),i.finalize(),t.finalizeAtoms(),sp(t),lp(t,!0),hp(t,!0),t.finalizeBonds(),pp(t),ip(t),e.Debug&&il.timeEnd("Mol2Parser._parse "+this.name)}});hl.add("pdbqt",class extends ob{get type(){return"pdbqt"}});hl.add("pqr",class extends ob{get type(){return"pqr"}});const Nb=/> +<(.+)>/;class Fb extends Kx{get type(){return"sdf"}_parse(){e.Debug&&il.time("SdfParser._parse "+this.name);const t=this.structure,i=this.structureBuilder,n=this.firstModelOnly,r=this.asTrajectory,s=this.streamer.peekLines(2);t.id=s[0].trim(),t.title=s[1].trim();const o=t.frames;let a,c,l=!1;const h=t.atomMap,u=t.atomStore;u.resize(Math.round(this.streamer.data.length/50)),u.addField("formalCharge",1,"int8");const d=t.getAtomProxy(),f=t.getAtomProxy();let m=0,p=0,g=0,v=0;const y=[];let x,b,_,w,S,A,M,C,P,T,I,E,D,L,R=!1,k={};t.extraData.sdf=y;let O=!1,B=!1,N=!1,F=[],z=[];const U=new Map;this.streamer.eachChunkOfLines((function(e){!function(e,s,$){for(let G=e;G-1,O?U.clear():(b=parseInt(e.substr(0,3)),_=parseInt(e.substr(3,3)),w=4,S=w+b,A=S,M=A+_,r&&(c=0,a=new Float32Array(3*b),o.push(a),g>0&&(l=!0)));else if(O&&"COUNTS"===F[0])b=parseInt(F[1]),r&&(c=0,a=new Float32Array(3*b),o.push(a),g>0&&(l=!0));else if(O&&2==F.length)"ATOM"===F[1]?"BEGIN"===F[0]?B=!0:"END"===F[0]&&(B=!1):"BOND"===F[1]&&("BEGIN"===F[0]?N=!0:"END"===F[0]&&(N=!1));else if(B||!O&&p>=w&&p0)continue;let t=0;if(O){if(C=parseFloat(F[2]),P=parseFloat(F[3]),T=parseFloat(F[4]),E=F[1],D=parseInt(F[0]),U.set(D,m),I=E+D,F.length>6){let e=F.slice(6).find((e=>0===e.indexOf("CHG=")));e&&(t=parseInt(e.substring(4)))}}else C=parseFloat(e.substr(0,10)),P=parseFloat(e.substr(10,10)),T=parseFloat(e.substr(20,10)),E=e.substr(31,3).trim(),I=E+(m-v+1);if(r){const e=3*c;if(a[e+0]=C,a[e+1]=P,a[e+2]=T,c+=1,l)continue}u.growIfFull(),u.atomTypeId[m]=h.add(I,E),u.x[m]=C,u.y[m]=P,u.z[m]=T,u.serial[m]=O?D:m,u.formalCharge[m]=t,i.addAtom(g,"","","HET",1,!0),m+=1}else if(N||!O&&p>=A&&p0)continue;if(r&&g>0)continue;O?(d.index=U.get(parseInt(F[2])),f.index=U.get(parseInt(F[3])),L=parseInt(F[1])):(d.index=parseInt(e.substr(0,3))-1+v,f.index=parseInt(e.substr(3,3))-1+v,L=parseInt(e.substr(6,3))),t.bondStore.addBond(d,f,L)}else if("M CHG"===e.substr(0,6)){const t=parseInt(e.substr(6,3));for(let i=0,n=10;i"===e.charAt(0)&&(x=e.match(Nb))?(R=x[1],k[R]=[]):!1!==R&&e&&k[R].push(e);++p}}}(0,e.length,e)})),i.finalize(),t.finalizeAtoms(),t.finalizeBonds(),pp(t),e.Debug&&il.timeEnd("SdfParser._parse "+this.name)}_postProcess(){pp(this.structure)}}hl.add("sdf",Fb),hl.add("sd",Fb),hl.add("mol",Fb);function zb(e,t,i){return parseInt(e.substr(t,i).trim())}class Ub extends Kx{get type(){return"prmtop"}_parse(){e.Debug&&il.time("PrmtopParser._parse "+this.name);const t=this.structure,i=this.structureBuilder,n=t.atomMap,r=t.atomStore;r.addField("partialCharge",1,"float32"),r.addField("radius",1,"float32");const s=[],o={},a=["NATOM","NTYPES","NBONH","MBONA","NTHETH","MTHETA","NPHIH","MPHIA","NHPARM","NPARM","NNB","NRES","NBONA","NTHETA","NPHIA","NUMBND","NUMANG","NPTRA","NATYP","NPHB","IFPERT","NBPER","NGPER","NDPER","MBPER","MGPER","MDPER","IFBOX","NMXRS","IFCAP","NUMEXTRA","NCOPY"];let c,l,h,u,d;a.forEach((e=>{o[e]=0}));let f,m,p,g,v,y=new Uint8Array(0);this.streamer.eachChunkOfLines((function(e){!function(e,t,i){for(let n=e;n0)return void il.error("dcd format with fixed atoms unsupported, aborting");const p=o.NATOM,g=4*p;for(let e=0,n=o.NSET;e=1&&(n.timeOffset=(o.ISTART-1)*n.deltaTime),e.Debug&&il.timeEnd("DcdParser._parse "+this.name)}});const Yb={BYTE:1,CHAR:2,SHORT:3,INT:4,FLOAT:5,DOUBLE:6};function Zb(e){switch(Number(e)){case Yb.BYTE:return"byte";case Yb.CHAR:return"char";case Yb.SHORT:return"short";case Yb.INT:return"int";case Yb.FLOAT:return"float";case Yb.DOUBLE:return"double";default:return"undefined"}}function Kb(e){switch(Number(e)){case Yb.BYTE:case Yb.CHAR:return 1;case Yb.SHORT:return 2;case Yb.INT:case Yb.FLOAT:return 4;case Yb.DOUBLE:return 8;default:return-1}}function Qb(e){switch(String(e)){case"byte":return Yb.BYTE;case"char":return Yb.CHAR;case"short":return Yb.SHORT;case"int":return Yb.INT;case"float":return Yb.FLOAT;case"double":return Yb.DOUBLE;default:return-1}}function Jb(e,t){if(1!==e){const i=new Array(e);for(let n=0;n6,"non valid type "+h);const u=e.readUint32();let d=e.readUint32();2===i&&(Wb(d>0,"offsets larger than 4GB not supported"),d=e.readUint32()),c[0]===t&&(s+=u),r[n]={name:o,dimensions:c,attributes:l,type:Zb(h),size:u,offset:d,record:c[0]===t}}}return{variables:r,recordStep:s}}(e,n.recordId,t);return i.variables=r.variables,i.recordDimension.recordStep=r.recordStep,i}function o_(e){let t;const i=e.readUint32();if(i===t_)return Wb(e.readUint32()!==t_,"wrong empty tag for list of attributes"),[];{Wb(i!==r_,"wrong tag for list of attributes");const n=e.readUint32();t=new Array(n);for(let i=0;i6,"non valid type "+r);const s=e.readUint32(),o=e_(e,r,s);qb(e),t[i]={name:n,type:Zb(r),value:o}}}return t}class a_{constructor(e){const t=new Il(e);t.setBigEndian(),Wb("CDF"!==t.readChars(3),"should start with CDF");const i=t.readByte();Wb(i>2,"unknown version"),this.header=s_(t,i),this.buffer=t}get version(){return 1===this.header.version?"classic format":"64-bit offset format"}get recordDimension(){return this.header.recordDimension}get dimensions(){return this.header.dimensions}get globalAttributes(){return this.header.globalAttributes}get variables(){return this.header.variables}hasDataVariable(e){return-1!==this.header.variables.findIndex((function(t){return t.name===e}))}getDataVariable(e){let t;return t="string"==typeof e?this.header.variables.find((function(t){return t.name===e})):e,Wb(void 0===t,"variable not found"),this.buffer.seek(t.offset),t.record?function(e,t,i){const n=Qb(t.type),r=t.size?t.size/Kb(n):1,s=i.length,o=new Array(s),a=i.recordStep;for(let t=0;t=1&&(i.timeOffset=s[0]),s.length>=2&&(i.deltaTime=s[1]-s[0]),e.Debug&&il.timeEnd("NctrajParser._parse "+this.name)}}hl.add("nctraj",c_),hl.add("ncdf",c_),hl.add("nc",c_);hl.add("trr",class extends jb{get type(){return"trr"}get isBinary(){return!0}_parse(){e.Debug&&il.time("TrrParser._parse "+this.name);const t=Va(this.streamer.data),i=new DataView(t),n=this.frames,r=n.coordinates,s=n.boxes,o=n.times;let a=0;for(;;){a+=8;const e=i.getInt32(a);a+=4,a+=e;const n=i.getInt32(a+8),c=i.getInt32(a+12),l=i.getInt32(a+16),h=i.getInt32(a+28),u=i.getInt32(a+32),d=i.getInt32(a+36),f=i.getInt32(a+40);a+=52;const m=n/9,p=3*f;if(8===m?o.push(i.getFloat64(a)):o.push(i.getFloat32(a)),a+=2*m,n){const e=new Float32Array(9);if(8===m)for(let t=0;t<9;++t)e[t]=10*i.getFloat64(a),a+=8;else for(let t=0;t<9;++t)e[t]=10*i.getFloat32(a),a+=4;s.push(e)}if(a+=c,a+=l,h){let e;if(8===m){e=new Float32Array(p);for(let t=0;t>8&65280|t>>24&255}e=new Float32Array(t,a,p);for(let t=0;t=t.byteLength)break}o.length>=1&&(n.timeOffset=o[0]),o.length>=2&&(n.deltaTime=o[1]-o[0]),e.Debug&&il.timeEnd("TrrParser._parse "+this.name)}});const l_=new Uint32Array([0,0,0,0,0,0,0,0,0,8,10,12,16,20,25,32,40,50,64,80,101,128,161,203,256,322,406,512,645,812,1024,1290,1625,2048,2580,3250,4096,5060,6501,8192,10321,13003,16384,20642,26007,32768,41285,52015,65536,82570,104031,131072,165140,208063,262144,330280,416127,524287,660561,832255,1048576,1321122,1664510,2097152,2642245,3329021,4194304,5284491,6658042,8388607,10568983,13316085,16777216]);function h_(e){let t=1,i=0;for(;e>=t&&i<32;)i++,t<<=1;return i}const u_=new Uint8Array(32);function d_(e,t){let i=1,n=0;u_[0]=1;for(let n=0;n>=8;for(;0!==r;)u_[e++]=255&r,r>>=8;i=e}let r=1;for(i--;u_[i]>=r;)n++,r*=2;return n+8*i}function f_(e,t,i,n){const r=(1<=8;)o=o<<8|t[a++],c|=o>>s<0&&(s>s&(1<8;)m_[a++]=f_(e,t,8,o),n-=8;n>0&&(m_[a++]=f_(e,t,n,o));for(let e=i-1;e>0;e--){let t=0;for(let i=a-1;i>=0;i--){t=t<<8|m_[i];const n=t/r[e]|0;m_[i]=n,t-=n*r[e]}s[e]=t}s[0]=m_[0]|m_[1]<<8|m_[2]<<16|m_[3]<<24}hl.add("xtc",class extends jb{get type(){return"xtc"}get isBinary(){return!0}_parse(){e.Debug&&il.time("XtcParser._parse "+this.name);const t=Va(this.streamer.data),i=new DataView(t),n=this.frames,r=n.coordinates,s=n.boxes,o=n.times,a=new Int32Array(6),c=new Int32Array(3),l=new Int32Array(3),h=new Uint32Array(3),u=new Float32Array(3),d=new Float32Array(3);let f=0;const m=new Int32Array(3),p=new Uint32Array(m.buffer);for(;;){let e;const n=i.getInt32(f+4);f+=12;const g=3*n;o.push(i.getFloat32(f)),f+=4;const v=new Float32Array(9);for(let e=0;e<9;++e)v[e]=10*i.getFloat32(f),f+=4;if(s.push(v),n<=9){e=new Float32Array(n);for(let t=0;t16777215?(l[0]=h_(c[0]),l[1]=h_(c[1]),l[2]=h_(c[2]),o=0):o=d_(3,c);let v=i.getInt32(f);f+=4;let y=v-1;y=9>y?9:y;let x=l_[y]/2|0,b=l_[v]/2|0;h[0]=h[1]=h[2]=l_[v];let _=4*Math.ceil(i.getInt32(f)/4);f+=4;const w=1/s;let S=0,A=0;const M=new Uint8Array(t,f);for(u[0]=u[1]=u[2]=0;A0){u[0]=u[1]=u[2]=0;for(let t=0;t9?l_[v-1]/2|0:0):t>0&&(x=b,b=l_[v]/2|0),h[0]=h[1]=h[2]=l_[v],0===h[0]||0===h[1]||0===h[2])return void console.error("(xdrfile error) Undefined error.")}f+=_}for(let t=0;t=t.byteLength)break}o.length>=1&&(n.timeOffset=o[0]),o.length>=2&&(n.deltaTime=o[1]-o[0]),e.Debug&&il.timeEnd("XtcParser._parse "+this.name)}});class g_ extends Zx{constructor(e,t){const i=t||{};super(e,i),this.volume=new Zf(this.name,this.path),this.voxelSize=Ia(i.voxelSize,1)}get type(){return"volume"}get __objName(){return"volume"}_afterParse(){this.volume.setMatrix(this.getMatrix()),super._afterParse()}getMatrix(){return new ri}}const v_=/\s+/,y_=/-?\d+(?:\.\d*)?(?:[eE][+-]?\d+)?/g,x_=.529177210859;class b_ extends g_{get type(){return"cube"}_parse(){e.Debug&&il.time("CubeParser._parse "+this.name);const t=this.volume,i=this.streamer.peekLines(6),n={},r=x_*this.voxelSize;function s(e,t){var n=i[e].trim().split(v_)[t];return parseFloat(n)}n.atomCount=Math.abs(s(2,0)),n.originX=s(2,1)*x_,n.originY=s(2,2)*x_,n.originZ=s(2,3)*x_,n.NVX=s(3,0),n.NVY=s(4,0),n.NVZ=s(5,0),n.basisX=new Zt(s(3,1),s(3,2),s(3,3)).multiplyScalar(r),n.basisY=new Zt(s(4,1),s(4,2),s(4,3)).multiplyScalar(r),n.basisZ=new Zt(s(5,1),s(5,2),s(5,3)).multiplyScalar(r);const o=new Float32Array(n.NVX*n.NVY*n.NVZ);let a=0,c=0;const l=s(2,0)>0?0:1;this.streamer.eachChunkOfLines((function(e){!function(e,t,i){for(let r=e;r=n.atomCount+6+l){const t=e.match(y_);for(let e=0,i=t.length;e>8&255}i.xStart=o[0],i.yStart=o[1],i.zStart=o[2],i.xExtent=o[3],i.yExtent=o[4],i.zExtent=o[5],i.xRate=o[6],i.yRate=o[7],i.zRate=o[8];const e=1/o[17],t=e*this.voxelSize;i.xlen=o[9]*t,i.ylen=o[10]*t,i.zlen=o[11]*t,i.alpha=o[12]*e,i.beta=o[13]*e,i.gamma=o[14]*e,n=o[15]/100,r=o[16],i.gamma=o[14]*e}t.header=i,e.Debug&&il.log(i,n,r);const l=new Float32Array(i.xExtent*i.yExtent*i.zExtent);let h=512;const u=Math.ceil(i.xExtent/8),d=Math.ceil(i.yExtent/8),f=Math.ceil(i.zExtent/8);for(var m=0;ms){const e=i[n].trim();if(""!==e){const t=e.split(w_);for(let e=0,i=t.length;e=s&&(p-s)%f!=0&&m=0?i-1:i+t/3)},parseNormalIndex:function(e,t){var i=parseInt(e,10);return 3*(i>=0?i-1:i+t/3)},addVertex:function(e,t,i){var n=this.vertices,r=this.object.geometry.vertices;r.push(n[e+0]),r.push(n[e+1]),r.push(n[e+2]),r.push(n[t+0]),r.push(n[t+1]),r.push(n[t+2]),r.push(n[i+0]),r.push(n[i+1]),r.push(n[i+2])},addVertexLine:function(e){var t=this.vertices,i=this.object.geometry.vertices;i.push(t[e+0]),i.push(t[e+1]),i.push(t[e+2])},addNormal:function(e,t,i){var n=this.normals,r=this.object.geometry.normals;r.push(n[e+0]),r.push(n[e+1]),r.push(n[e+2]),r.push(n[t+0]),r.push(n[t+1]),r.push(n[t+2]),r.push(n[i+0]),r.push(n[i+1]),r.push(n[i+2])},addFace:function(e,t,i,n,r,s,o,a){var c,l=this.vertices.length,h=this.parseVertexIndex(e,l),u=this.parseVertexIndex(t,l),d=this.parseVertexIndex(i,l);if(void 0===n?this.addVertex(h,u,d):(c=this.parseVertexIndex(n,l),this.addVertex(h,u,c),this.addVertex(u,d,c)),void 0!==r){var f=this.normals.length;h=this.parseNormalIndex(r,f),u=r===s?h:this.parseNormalIndex(s,f),d=r===o?h:this.parseNormalIndex(o,f),void 0===n?this.addNormal(h,u,d):(c=this.parseNormalIndex(a,f),this.addNormal(h,u,c),this.addNormal(u,d,c))}},addLineGeometry:function(e){this.object.geometry.type="Line";for(var t=this.vertices.length,i=0,n=e.length;i0?x.setAttribute("normal",new An(new Float32Array(y.normals),3)):x.computeVertexNormals(),v.push(x)}}return v}};hl.add("obj",class extends U_{get type(){return"obj"}getLoader(){return new $_}});const G_=function(){this.propertyNameMapping={}};G_.prototype={constructor:G_,setPropertyNameMapping:function(e){this.propertyNameMapping=e},bin2str:function(e){for(var t=new Uint8Array(e),i="",n=0;n=n.elements[o].count&&(o++,a=0);var h=this.parseASCIIElement(n.elements[o].properties,l);this.handleElement(i,n.elements[o].name,h),a++}}return this.postProcess(i)},postProcess:function(e){if(e.useColor){for(var t=0;t{const r=n.length;for(let s=0;s/g,""),{declaration:t(),root:i()};function t(){if(!r(/^<\?xml\s*/))return;const e={attributes:{}};for(;!s()&&!o("?>");){const t=n();if(!t)return e;e.attributes[t.name]=t.value}return r(/\?>\s*/),e}function i(){const e=r(j_);if(!e)return;const t={name:e[1],attributes:{},children:[]};for(;!(s()||o(">")||o("?>")||o("/>"));){const e=n();if(!e)return t;t.attributes[e.name]=e.value}if(r(/^\s*\/>\s*/))return t;let a;for(r(/\??>\s*/),t.content=function(){const e=r(W_);return e?e[1]:""}();a=i();)t.children.push(a);return r(/^<\/[\w-:.]+>\s*/),t}function n(){const e=r(q_);var t;if(e)return{name:e[1],value:(t=e[2],t.replace(H_,""))}}function r(t){const i=e.match(t);if(i)return e=e.slice(i[0].length),i}function s(){return 0===e.length}function o(t){return 0===e.indexOf(t)}}class Y_ extends Zx{constructor(e,t){const i=t||{};super(e,i),this.useDomParser=Ia(i.useDomParser,!1),this.xml={name:this.name,path:this.path,data:{}}}get type(){return"xml"}get __objName(){return"xml"}get isXml(){return!0}__xmlParser(e){return X_(e)}__domParser(e){return(new window.DOMParser).parseFromString(e,"text/xml")}_parse(){e.Debug&&il.time("XmlParser._parse "+this.name),this.useDomParser?this.streamer.data instanceof Document?this.xml.data=this.streamer.data:this.xml.data=this.__domParser(this.streamer.asText()):this.xml.data=this.__xmlParser(this.streamer.asText()),e.Debug&&il.timeEnd("XmlParser._parse "+this.name)}}function Z_(e,t){const i=e.getNamedItem(t);return null!==i?i.value:""}function K_(e,t,i=!1){const n=Z_(e,"icode").trim(),r=Z_(e,"chain").trim(),s=Z_(e,"altcode");let o=Z_(e,"resnum");return n&&(o+="^"+n),r&&(o+=":"+r),t&&(o+="."+t),i&&s.trim()&&(o+="%"+s),o+="/"+(parseInt(Z_(e,"model"))-1),o}function Q_(e){const t=Z_(e,"chain").trim();let i=`[${Z_(e,"rescode")}]${Z_(e,"resnum")}`;return t&&(i+=`:${t}`),i}function J_(e,t,i){void 0===e[t]?e[t]=i:e[t]|=i}function ew(e,t){return null!==e&&e.value===t}function tw(e,t,i){let n=0;const r=t.getElementsByTagName("clash");for(let t=0,i=r.length;t0&&(n+=1);t.getElementsByTagName("bond-outlier").length>0&&(n+=1);return t.getElementsByTagName("plane-outlier").length>0&&(n+=1),ew(i.getNamedItem("rota"),"OUTLIER")&&(n+=1),ew(i.getNamedItem("rama"),"OUTLIER")&&(n+=1),ew(i.getNamedItem("RNApucker"),"outlier")&&(n+=1),n}hl.add("xml",Y_);class iw{constructor(e,t){this.name=e,this.path=t,this.rsrzDict={},this.rsccDict={},this.rciDict={},this.clashDict={},this.clashArray=[],this.geoDict={},this.geoAtomDict={},this.atomDict={},this.clashSele="NONE"}get type(){return"validation"}fromXml(t){e.Debug&&il.time("Validation.fromXml");const i=this.rsrzDict,n=this.rsccDict,r=this.rciDict,s=this.clashDict,o=this.clashArray,a=this.geoDict,c=this.geoAtomDict,l=this.atomDict,h=t.getElementsByTagName("Entry");if(1===h.length){const e=h[0].getElementsByTagName("chemical_shift_list");if(1===e.length){const t=e[0].getElementsByTagName("random_coil_index");for(let e=0,i=t.length;e0&&(a[n]=e)}else{const e=t.getElementsByTagName("clash"),i=t.getElementsByTagName("mog-bond-outlier"),r=t.getElementsByTagName("mog-angle-outlier");if(i.length>0||r.length>0||e.length>0){const t={};c[n]=t;for(let i=0,n=e.length;i>>16&65535|0,o=0;0!==i;){i-=o=i>2e3?2e3:i;do{s=s+(r=r+t[n++]|0)|0}while(--o);r%=65521,s%=65521}return r|s<<16|0}hl.add("validation",class extends Y_{constructor(e,t){super(e,t||{}),this.useDomParser=!0,this.validation=new iw(this.name,this.path)}get __objName(){return"validation"}get isXml(){return!0}_parse(){super._parse(),e.Debug&&il.time("ValidationParser._parse "+this.name),this.validation.fromXml(this.xml.data),e.Debug&&il.timeEnd("ValidationParser._parse "+this.name)}});var ow=function(){for(var e,t=[],i=0;i<256;i++){e=i;for(var n=0;n<8;n++)e=1&e?3988292384^e>>>1:e>>>1;t[i]=e}return t}();function aw(e,t,i,n){var r=ow,s=n+i;e^=-1;for(var o=n;o>>8^r[255&(e^t[o])];return-1^e}var cw=30,lw=12;function hw(e,t){var i,n,r,s,o,a,c,l,h,u,d,f,m,p,g,v,y,x,b,_,w,S,A,M,C;i=e.state,n=e.next_in,M=e.input,r=n+(e.avail_in-5),s=e.next_out,C=e.output,o=s-(t-e.avail_out),a=s+(e.avail_out-257),c=i.dmax,l=i.wsize,h=i.whave,u=i.wnext,d=i.window,f=i.hold,m=i.bits,p=i.lencode,g=i.distcode,v=(1<>>=b=x>>>24,m-=b,0===(b=x>>>16&255))C[s++]=65535&x;else{if(!(16&b)){if(0==(64&b)){x=p[(65535&x)+(f&(1<>>=b,m-=b),m<15&&(f+=M[n++]<>>=b=x>>>24,m-=b,!(16&(b=x>>>16&255))){if(0==(64&b)){x=g[(65535&x)+(f&(1<c){e.msg="invalid distance too far back",i.mode=cw;break e}if(f>>>=b,m-=b,w>(b=s-o)){if((b=w-b)>h&&i.sane){e.msg="invalid distance too far back",i.mode=cw;break e}if(S=0,A=d,0===u){if(S+=l-b,b<_){_-=b;do{C[s++]=d[S++]}while(--b);S=s-w,A=C}}else if(u2;)C[s++]=A[S++],C[s++]=A[S++],C[s++]=A[S++],_-=3;_&&(C[s++]=A[S++],_>1&&(C[s++]=A[S++]))}else{S=s-w;do{C[s++]=C[S++],C[s++]=C[S++],C[s++]=C[S++],_-=3}while(_>2);_&&(C[s++]=C[S++],_>1&&(C[s++]=C[S++]))}break}}break}}while(n>3,f&=(1<<(m-=_<<3))-1,e.next_in=n,e.next_out=s,e.avail_in=n=1&&0===E[_];_--);if(w>_&&(w=_),0===_)return r[s++]=20971520,r[s++]=20971520,a.bits=1,0;for(b=1;b<_&&0===E[b];b++);for(w0&&(e===mw||1!==_))return-1;for(D[1]=0,y=1;ydw||e===gw&&C>fw)return 1;for(;;){m=y-A,o[x]f?(p=L[R+o[x]],g=T[I+o[x]]):(p=96,g=0),c=1<>A)+(l-=c)]=m<<24|p<<16|g|0}while(0!==l);for(c=1<>=1;if(0!==c?(P&=c-1,P+=c):P=0,x++,0==--E[y]){if(y===_)break;y=t[i+o[x]]}if(y>w&&(P&u)!==h){for(0===A&&(A=w),d+=b,M=1<<(S=y-A);S+A<_&&!((M-=E[S+A])<=0);)S++,M<<=1;if(C+=1<dw||e===gw&&C>fw)return 1;r[h=P&u]=w<<24|S<<16|d-s|0}}return 0!==P&&(r[d+P]=y-A<<24|64<<16|0),a.bits=w,0}var ww=1,Sw=2,Aw=0,Mw=-2,Cw=1,Pw=12,Tw=30,Iw=852,Ew=592;function Dw(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function Lw(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function Rw(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,function(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=Cw,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(Iw),t.distcode=t.distdyn=new Int32Array(Ew),t.sane=1,t.back=-1,Aw):Mw}(e)):Mw}function kw(e,t){var i,n;return e?(n=new Lw,e.state=n,n.window=null,i=function(e,t){var i,n;return e&&e.state?(n=e.state,t<0?(i=0,t=-t):(i=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?Mw:(null!==n.window&&n.wbits!==t&&(n.window=null),n.wrap=i,n.wbits=t,Rw(e))):Mw}(e,t),i!==Aw&&(e.state=null),i):Mw}var Ow,Bw,Nw=!0;function Fw(e){if(Nw){var t;for(Ow=new Int32Array(512),Bw=new Int32Array(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(_w(ww,e.lens,0,288,Ow,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;_w(Sw,e.lens,0,32,Bw,0,e.work,{bits:5}),Nw=!1}e.lencode=Ow,e.lenbits=9,e.distcode=Bw,e.distbits=5}function zw(e,t,i,n){var r,s=e.state;return null===s.window&&(s.wsize=1<=s.wsize?(rw(s.window,t,i-s.wsize,s.wsize,0),s.wnext=0,s.whave=s.wsize):((r=s.wsize-s.wnext)>n&&(r=n),rw(s.window,t,i-n,r,s.wnext),(n-=r)?(rw(s.window,t,i-n,n,0),s.wnext=n,s.whave=s.wsize):(s.wnext+=r,s.wnext===s.wsize&&(s.wnext=0),s.whave>>8&255,i.check=aw(i.check,P,2,0),l=0,h=0,i.mode=2;break}if(i.flags=0,i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&l)<<8)+(l>>8))%31){e.msg="incorrect header check",i.mode=Tw;break}if(8!=(15&l)){e.msg="unknown compression method",i.mode=Tw;break}if(h-=4,w=8+(15&(l>>>=4)),0===i.wbits)i.wbits=w;else if(w>i.wbits){e.msg="invalid window size",i.mode=Tw;break}i.dmax=1<>8&1),512&i.flags&&(P[0]=255&l,P[1]=l>>>8&255,i.check=aw(i.check,P,2,0)),l=0,h=0,i.mode=3;case 3:for(;h<32;){if(0===a)break e;a--,l+=n[s++]<>>8&255,P[2]=l>>>16&255,P[3]=l>>>24&255,i.check=aw(i.check,P,4,0)),l=0,h=0,i.mode=4;case 4:for(;h<16;){if(0===a)break e;a--,l+=n[s++]<>8),512&i.flags&&(P[0]=255&l,P[1]=l>>>8&255,i.check=aw(i.check,P,2,0)),l=0,h=0,i.mode=5;case 5:if(1024&i.flags){for(;h<16;){if(0===a)break e;a--,l+=n[s++]<>>8&255,i.check=aw(i.check,P,2,0)),l=0,h=0}else i.head&&(i.head.extra=null);i.mode=6;case 6:if(1024&i.flags&&((f=i.length)>a&&(f=a),f&&(i.head&&(w=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Array(i.head.extra_len)),rw(i.head.extra,n,s,f,w)),512&i.flags&&(i.check=aw(i.check,n,f,s)),a-=f,s+=f,i.length-=f),i.length))break e;i.length=0,i.mode=7;case 7:if(2048&i.flags){if(0===a)break e;f=0;do{w=n[s+f++],i.head&&w&&i.length<65536&&(i.head.name+=String.fromCharCode(w))}while(w&&f>9&1,i.head.done=!0),e.adler=i.check=0,i.mode=Pw;break;case 10:for(;h<32;){if(0===a)break e;a--,l+=n[s++]<>>=7&h,h-=7&h,i.mode=27;break}for(;h<3;){if(0===a)break e;a--,l+=n[s++]<>>=1)){case 0:i.mode=14;break;case 1:if(Fw(i),i.mode=20,6===t){l>>>=2,h-=2;break e}break;case 2:i.mode=17;break;case 3:e.msg="invalid block type",i.mode=Tw}l>>>=2,h-=2;break;case 14:for(l>>>=7&h,h-=7&h;h<32;){if(0===a)break e;a--,l+=n[s++]<>>16^65535)){e.msg="invalid stored block lengths",i.mode=Tw;break}if(i.length=65535&l,l=0,h=0,i.mode=15,6===t)break e;case 15:i.mode=16;case 16:if(f=i.length){if(f>a&&(f=a),f>c&&(f=c),0===f)break e;rw(r,n,s,f,o),a-=f,s+=f,c-=f,o+=f,i.length-=f;break}i.mode=Pw;break;case 17:for(;h<14;){if(0===a)break e;a--,l+=n[s++]<>>=5,h-=5,i.ndist=1+(31&l),l>>>=5,h-=5,i.ncode=4+(15&l),l>>>=4,h-=4,i.nlen>286||i.ndist>30){e.msg="too many length or distance symbols",i.mode=Tw;break}i.have=0,i.mode=18;case 18:for(;i.have>>=3,h-=3}for(;i.have<19;)i.lens[T[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,A={bits:i.lenbits},S=_w(0,i.lens,0,19,i.lencode,0,i.work,A),i.lenbits=A.bits,S){e.msg="invalid code lengths set",i.mode=Tw;break}i.have=0,i.mode=19;case 19:for(;i.have>>16&255,y=65535&C,!((g=C>>>24)<=h);){if(0===a)break e;a--,l+=n[s++]<>>=g,h-=g,i.lens[i.have++]=y;else{if(16===y){for(M=g+2;h>>=g,h-=g,0===i.have){e.msg="invalid bit length repeat",i.mode=Tw;break}w=i.lens[i.have-1],f=3+(3&l),l>>>=2,h-=2}else if(17===y){for(M=g+3;h>>=g)),l>>>=3,h-=3}else{for(M=g+7;h>>=g)),l>>>=7,h-=7}if(i.have+f>i.nlen+i.ndist){e.msg="invalid bit length repeat",i.mode=Tw;break}for(;f--;)i.lens[i.have++]=w}}if(i.mode===Tw)break;if(0===i.lens[256]){e.msg="invalid code -- missing end-of-block",i.mode=Tw;break}if(i.lenbits=9,A={bits:i.lenbits},S=_w(ww,i.lens,0,i.nlen,i.lencode,0,i.work,A),i.lenbits=A.bits,S){e.msg="invalid literal/lengths set",i.mode=Tw;break}if(i.distbits=6,i.distcode=i.distdyn,A={bits:i.distbits},S=_w(Sw,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,A),i.distbits=A.bits,S){e.msg="invalid distances set",i.mode=Tw;break}if(i.mode=20,6===t)break e;case 20:i.mode=21;case 21:if(a>=6&&c>=258){e.next_out=o,e.avail_out=c,e.next_in=s,e.avail_in=a,i.hold=l,i.bits=h,hw(e,d),o=e.next_out,r=e.output,c=e.avail_out,s=e.next_in,n=e.input,a=e.avail_in,l=i.hold,h=i.bits,i.mode===Pw&&(i.back=-1);break}for(i.back=0;v=(C=i.lencode[l&(1<>>16&255,y=65535&C,!((g=C>>>24)<=h);){if(0===a)break e;a--,l+=n[s++]<>x)])>>>16&255,y=65535&C,!(x+(g=C>>>24)<=h);){if(0===a)break e;a--,l+=n[s++]<>>=x,h-=x,i.back+=x}if(l>>>=g,h-=g,i.back+=g,i.length=y,0===v){i.mode=26;break}if(32&v){i.back=-1,i.mode=Pw;break}if(64&v){e.msg="invalid literal/length code",i.mode=Tw;break}i.extra=15&v,i.mode=22;case 22:if(i.extra){for(M=i.extra;h>>=i.extra,h-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=23;case 23:for(;v=(C=i.distcode[l&(1<>>16&255,y=65535&C,!((g=C>>>24)<=h);){if(0===a)break e;a--,l+=n[s++]<>x)])>>>16&255,y=65535&C,!(x+(g=C>>>24)<=h);){if(0===a)break e;a--,l+=n[s++]<>>=x,h-=x,i.back+=x}if(l>>>=g,h-=g,i.back+=g,64&v){e.msg="invalid distance code",i.mode=Tw;break}i.offset=y,i.extra=15&v,i.mode=24;case 24:if(i.extra){for(M=i.extra;h>>=i.extra,h-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){e.msg="invalid distance too far back",i.mode=Tw;break}i.mode=25;case 25:if(0===c)break e;if(f=d-c,i.offset>f){if((f=i.offset-f)>i.whave&&i.sane){e.msg="invalid distance too far back",i.mode=Tw;break}f>i.wnext?(f-=i.wnext,m=i.wsize-f):m=i.wnext-f,f>i.length&&(f=i.length),p=i.window}else p=r,m=o-i.offset,f=i.length;f>c&&(f=c),c-=f,i.length-=f;do{r[o++]=p[m++]}while(--f);0===i.length&&(i.mode=21);break;case 26:if(0===c)break e;r[o++]=i.length,c--,i.mode=21;break;case 27:if(i.wrap){for(;h<32;){if(0===a)break e;a--,l|=n[s++]<=252?6:jw>=248?5:jw>=240?4:jw>=224?3:jw>=192?2:1;function Ww(e){var t,i,n,r,s,o=e.length,a=0;for(r=0;r>>6,t[s++]=128|63&i):i<65536?(t[s++]=224|i>>>12,t[s++]=128|i>>>6&63,t[s++]=128|63&i):(t[s++]=240|i>>>18,t[s++]=128|i>>>12&63,t[s++]=128|i>>>6&63,t[s++]=128|63&i);return t}function qw(e,t){var i,n,r,s,o=t||e.length,a=new Array(2*o);for(n=0,i=0;i4)a[n++]=65533,i+=s-1;else{for(r&=2===s?31:3===s?15:7;s>1&&i1?a[n++]=65533:r<65536?a[n++]=r:(r-=65536,a[n++]=55296|r>>10&1023,a[n++]=56320|1023&r)}return function(e,t){if(t<65537&&(e.subarray&&Vw||!e.subarray&&Gw))return String.fromCharCode.apply(null,nw(e,t));for(var i="",n=0;ne.length&&(t=e.length),i=t-1;i>=0&&128==(192&e[i]);)i--;return i<0||0===i?t:i+Hw[e[i]]>t?i:t}Hw[254]=Hw[254]=1;var Yw=0,Zw={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"};function Kw(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}function Qw(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var Jw=Object.prototype.toString;function eS(e){if(!(this instanceof eS))return new eS(e);this.options=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var i=t.shift();if(i){if("object"!=typeof i)throw new TypeError(i+"must be non-object");for(var n in i)i.hasOwnProperty(n)&&(e[n]=i[n])}}return e}({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Kw,this.strm.avail_out=0;var i,n,r,s=kw(this.strm,t.windowBits);if(s!==Yw)throw new Error(Zw[s]);this.header=new Qw,i=this.strm,n=this.header,i&&i.state&&(0==(2&(r=i.state).wrap)||(r.head=n,n.done=!1))}eS.prototype.push=function(e,t){var i,n,r,s,o,a,c=this.strm,l=this.options.chunkSize,h=this.options.dictionary,u=!1;if(this.ended)return!1;n=t===~~t?t:!0===t?4:0,"string"==typeof e?c.input=function(e){for(var t=new Uint8Array(e.length),i=0,n=t.length;i0||0===c.avail_out)&&1!==i);return 1===i&&(n=4),4===n?(i=function(e){if(!e||!e.state)return Mw;var t=e.state;return t.window&&(t.window=null),e.state=null,Aw}(this.strm),this.onEnd(i),this.ended=!0,i===Yw):2!==n||(this.onEnd(Yw),c.avail_out=0,!0)},eS.prototype.onData=function(e){this.chunks.push(e)},eS.prototype.onEnd=function(e){e===Yw&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=function(e){var t,i,n,r,s,o;for(n=0,t=0,i=e.length;tObject.assign(Object.assign({},e),{[t]:t})),{})}}const pS={backgroundColor:{type:"color"},quality:mS("auto","low","medium","high"),sampleLevel:fS(1,5,-1),impostor:{type:"boolean"},workerDefault:{type:"boolean"},rotateSpeed:dS(1,10,0),zoomSpeed:dS(1,10,0),panSpeed:dS(1,10,0),clipNear:fS(1,100,0),clipFar:fS(1,100,0),clipDist:uS(200,0),clipMode:mS("scene","camera"),clipScale:mS("relative","absolute"),fogNear:fS(1,100,0),fogFar:fS(1,100,0),cameraType:mS("perspective","orthographic","stereo"),cameraEyeSep:dS(3,1,.01),cameraFov:fS(1,120,15),lightColor:{type:"color"},lightIntensity:dS(2,10,0),ambientColor:{type:"color"},ambientIntensity:dS(2,10,0),hoverTimeout:uS(1e4,-1),tooltip:{type:"boolean"},mousePreset:mS(...Object.keys(um))};e.AngleRepresentation=Qv,e.ArrowBuffer=wx,e.Assembly=Qm,e.AxesRepresentation=fy,e.BackboneRepresentation=py,e.BallAndStickRepresentation=my,e.BaseRepresentation=gy,e.Box3=Ni,e.BoxBuffer=Px,e.BufferRepresentation=Vp,e.CartoonRepresentation=Sy,e.Collection=Sg,e.Color=mn,e.Colormaker=dc,e.ColormakerRegistry=al,e.Component=wg,e.ComponentCollection=Wg,e.ConeBuffer=xx,e.ContactRepresentation=Ay,e.Counter=El,e.CylinderBuffer=dy,e.DatasourceRegistry=cl,e.DecompressorRegistry=dl,e.DihedralHistogramRepresentation=Ty,e.DihedralRepresentation=My,e.DistanceRepresentation=Ey,e.EllipsoidBuffer=Rx,e.Euler=ai,e.Frames=Pg,e.HelixorientRepresentation=ky,e.HyperballRepresentation=Vy,e.Kdtree=qm,e.KeyActions=mm,e.LabelRepresentation=jy,e.LeftMouseButton=1,e.LicoriceRepresentation=Oy,e.LineRepresentation=qy,e.Matrix3=Ut,e.Matrix4=ri,e.MdsrvDatasource=class extends tS{constructor(e=""){super(),this.baseUrl=e}getListing(e=""){let t=`${this.baseUrl}dir/${e}`;return"/"!==t[t.length-1]&&(t+="/"),Ml(t,{ext:"json"}).then((t=>({path:e,data:t.data})))}getUrl(e){const t=Sl(e);return`${this.baseUrl}file/${t.path}${t.query}`}getCountUrl(e){const t=Sl(e);return`${this.baseUrl}traj/numframes/${t.path}${t.query}`}getFrameUrl(e,t){const i=Sl(e);return`${this.baseUrl}traj/frame/${t}/${i.path}${i.query}`}getFrameParams(e,t){return`atomIndices=${t.join(";")}`}getPathUrl(e,t){const i=Sl(e);return`${this.baseUrl}traj/path/${t}/${i.path}${i.query}`}getExt(e){return Sl(e).ext}},e.MeasurementDefaultParams=nl,e.MeshBuffer=nm,e.MiddleMouseButton=2,e.MolecularSurface=Qy,e.MolecularSurfaceRepresentation=Jy,e.MouseActions=hm,e.OctahedronBuffer=Fx,e.ParserRegistry=hl,e.PdbWriter=class extends Pl{constructor(e,t){super(),this.mimeType="text/plain",this.defaultName="structure",this.defaultExt="pdb";const i=Object.assign({},t);this.renumberSerial=Ia(i.renumberSerial,!0),this.remarks=function(e){return Array.isArray(e)?e:[e]}(Ia(i.remarks,[])),this.structure=e,this._records=[]}_writeRecords(){this._records.length=0,this._writeTitle(),this._writeRemarks(),this._writeAtoms()}_writeTitle(){this._records.push(Cl.sprintf("TITLE %-74s",this.structure.name))}_writeRemarks(){this.remarks.forEach((e=>{this._records.push(Cl.sprintf("REMARK %-73s",e))})),this.structure.trajectory&&(this._records.push(Cl.sprintf("REMARK %-73s","Trajectory '"+this.structure.trajectory.name+"'")),this._records.push(Cl.sprintf("REMARK %-73s",`Frame ${this.structure.trajectory.frame}`)))}_writeAtoms(){let e=1,t=1,i=" ",n=" ";const r=this.structure.modelStore.count>1;this.structure.eachModel((s=>{r&&this._records.push(Cl.sprintf("MODEL %4d%-66s",t++,"")),s.eachAtom((t=>{const r=t.hetero?"HETATM%5d %-4s %3s %1s%4d %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%1s%1s":"ATOM %5d %-4s %3s %1s%4d %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%1s%1s",s=this.renumberSerial?e:t.serial;let o=t.atomname;(1===o.length||o.length<4&&1===t.element.length&&o[0]===t.element)&&(o=" "+o),t.formalCharge?(i=Math.abs(t.formalCharge).toPrecision(1),n=t.formalCharge>0?"+":"-"):(i=" ",n=" "),this._records.push(Cl.sprintf(r,s,o,t.resname,Ia(t.chainname," "),t.resno,t.x,t.y,t.z,Ia(t.occupancy,1),Ia(t.bfactor,0),"",Ia(t.element,""),i,n)),e+=1}),this.structure.getSelection()),r&&this._records.push(Cl.sprintf("%-80s","ENDMDL"))})),this._records.push(Cl.sprintf("%-80s","END"))}getString(){return console.warn("PdbWriter.getString() is deprecated, use .getData instead"),this.getData()}getData(){return this._writeRecords(),this._records.join("\n")}},e.PickingProxy=Rh,e.Plane=Qi,e.PointBuffer=sg,e.PointRepresentation=ex,e.Quaternion=qt,e.Queue=eu,e.RepresentationCollection=Ag,e.RepresentationElement=yg,e.RepresentationRegistry=ll,e.RibbonRepresentation=rx,e.RightMouseButton=3,e.RocketRepresentation=sx,e.RopeRepresentation=ox,e.ScriptExtensions=sl,e.SdfWriter=class extends Pl{constructor(e){super(),this.mimeType="text/plain",this.defaultName="structure",this.defaultExt="sdf",this.structure=e,this._records=[]}get idString(){return this.structure.id}get titleString(){return" "+this.structure.title}get countsString(){return Cl.sprintf("%3i%3i 0 0 0 0 0 0 0 0999 V2000",this.structure.atomCount,this.structure.bondCount)}get chargeLines(){const e=[];this.structure.eachAtom((t=>{null!=t.formalCharge&&0!==t.formalCharge&&e.push([t.index,t.formalCharge])}));const t=[];for(let i=0;i{this._records.push(this.formatAtom(e))})),this.structure.eachBond((e=>{this._records.push(this.formatBond(e))})),this.chargeLines.forEach((e=>{this._records.push(e)})),this._records.push("M END")}_writeFooter(){this._records.push("$$$$")}getData(){return this._writeRecords(),this._records.join("\n")}},e.Selection=$c,e.Shape=Gp,e.ShapeComponent=Zg,e.Signal=mc.Signal,e.SpacefillRepresentation=ax,e.SpatialHash=ju,e.SphereBuffer=tg,e.Stage=class{constructor(e,t={}){this.signals={parametersChanged:new mc.Signal,fullscreenChanged:new mc.Signal,componentAdded:new mc.Signal,componentRemoved:new mc.Signal,clicked:new mc.Signal,hovered:new mc.Signal},this.tasks=new El,this.compList=[],this.defaultFileParams={},this.logList=[],this.viewer=new vh(e),this.viewer.renderer&&(this.tooltip=document.createElement("div"),Object.assign(this.tooltip.style,{display:"none",position:"fixed",zIndex:"1000000",pointerEvents:"none",backgroundColor:"rgba( 0, 0, 0, 0.6 )",color:"lightgrey",padding:"8px",fontFamily:"sans-serif"}),this.viewer.container.appendChild(this.tooltip),this.mouseObserver=new xh(this.viewer.renderer.domElement),this.viewerControls=new Vh(this),this.trackballControls=new Dh(this),this.pickingControls=new kh(this),this.animationControls=new Jh(this),this.mouseControls=new fm(this),this.keyControls=new gm(this),this.pickingBehavior=new vm(this),this.mouseBehavior=new ym(this),this.animationBehavior=new xm(this),this.keyBehavior=new _m(this),this.spinAnimation=this.animationControls.spin([0,1,0],.005),this.spinAnimation.pause(!0),this.rockAnimation=this.animationControls.rock([0,1,0],.005),this.rockAnimation.pause(!0),this.parameters=Ea(t,Yg),this.setParameters(this.parameters),this.viewer.animate())}setParameters(e={}){Da(this.parameters,e);const t=e,i=this.parameters,n=this.viewer,r=this.trackballControls;return void 0!==t.quality&&this.setQuality(i.quality),void 0!==t.impostor&&this.setImpostor(i.impostor),void 0!==t.rotateSpeed&&(r.rotateSpeed=i.rotateSpeed),void 0!==t.zoomSpeed&&(r.zoomSpeed=i.zoomSpeed),void 0!==t.panSpeed&&(r.panSpeed=i.panSpeed),void 0!==t.mousePreset&&this.mouseControls.preset(i.mousePreset),this.mouseObserver.setParameters({hoverTimeout:i.hoverTimeout}),n.setClip(i.clipNear,i.clipFar,i.clipDist,i.clipMode,i.clipScale),n.setFog(void 0,i.fogNear,i.fogFar),n.setCamera(i.cameraType,i.cameraFov,i.cameraEyeSep),n.setSampling(i.sampleLevel),n.setBackground(i.backgroundColor),n.setLight(i.lightColor,i.lightIntensity,i.ambientColor,i.ambientIntensity),this.signals.parametersChanged.dispatch(this.getParameters()),this}log(e){console.log("STAGE LOG",e),this.logList.push(e)}getParameters(){return Object.assign({},this.parameters)}defaultFileRepresentation(t){if(t instanceof Vg){let i,n,r;t.setSelection("/0");const s=t.structure;if(s.biomolDict.BU1){const e=s.biomolDict.BU1;i=e.getAtomCount(s),n=e.getResidueCount(s),r=e.getInstanceCount(),t.setDefaultAssembly("BU1")}else i=s.getModelProxy(0).atomCount,n=s.getModelProxy(0).residueCount,r=1;let o=i;Kc&&(o*=4);const a=s.atomStore.count/s.residueStore.count<2;a&&(o*=10);let c="chainname",l="RdYlBu",h=!1;if(1===s.getChainnameCount(new $c("polymer and /0"))&&(c="residueindex",l="Spectral",h=!0),e.Debug&&console.log(o,i,r,a),n/r<4)t.addRepresentation("ball+stick",{colorScheme:"element",radiusScale:2,aspectRatio:1.5,bondScale:.3,bondSpacing:.75,quality:"auto"});else if(r>5&&o>15e3||o>7e5){let e=Math.min(2,Math.max(.1,6e3/(o/r)));a&&(e=Math.min(e,.5)),t.addRepresentation("surface",{colorScheme:c,colorScale:l,colorReverse:h,sele:"polymer",surfaceType:"av",probeRadius:1.4,scaleFactor:e,useWorker:!1})}else o>25e4?t.addRepresentation("backbone",{colorScheme:c,colorScale:l,colorReverse:h,lineOnly:!0}):o>1e5?t.addRepresentation("backbone",{colorScheme:c,colorScale:l,colorReverse:h,quality:"low",disableImpostor:!0,radiusScale:2}):o>8e4?t.addRepresentation("backbone",{colorScheme:c,colorScale:l,colorReverse:h,radiusScale:2}):(t.addRepresentation("cartoon",{colorScheme:c,colorScale:l,colorReverse:h,radiusScale:.7,aspectRatio:5,quality:"auto"}),o<5e4&&t.addRepresentation("base",{colorScheme:c,colorScale:l,colorReverse:h,quality:"auto"}),t.addRepresentation("ball+stick",{sele:"ligand",colorScheme:"element",radiusScale:2,aspectRatio:1.5,bondScale:.3,bondSpacing:.75,quality:"auto"}));t.structure.frames.length&&t.addTrajectory()}else(t instanceof Hg||t instanceof jg)&&t.addRepresentation("surface");this.tasks.onZeroOnce(this.autoView,this)}loadFile(e,t={}){const i=Object.assign({},this.defaultFileParams,t),n=Sl(e).name;this.tasks.increment(),this.log(`loading file '${n}'`);const r=Ia(i.ext,Sl(e).ext);let s;return s=hl.isTrajectory(r)?Promise.reject(new Error(`loadFile: ext '${r}' is a trajectory and must be loaded into a structure component`)):Ml(e,i),s.then((e=>{this.log(`loaded '${n}'`);const t=this.addComponentFromObject(e,i);return i.defaultRepresentation&&this.defaultFileRepresentation(t),this.tasks.decrement(),t}),(e=>{this.tasks.decrement();const t=`error loading file: '${e}'`;throw this.log(t),t}))}loadScript(e){const t=Sl(e).name;return this.log(`loading script '${t}'`),Ml(e).then((e=>{this.tasks.increment(),this.log(`running script '${t}'`),e.run(this).then((()=>{this.tasks.decrement(),this.log(`finished script '${t}'`)})),this.log(`called script '${t}'`)}),(e=>{this.tasks.decrement();const i=`errored script '${t}' "${e}"`;throw this.log(i),i}))}addComponent(e){e?(this.compList.push(e),this.signals.componentAdded.dispatch(e)):il.warn("Stage.addComponent: no component given")}addComponentFromObject(e,t={}){const i=fl.get(e.type);if(i){const n=new i(this,e,t);return this.addComponent(n),n}il.warn("no component for object type",e.type)}removeComponent(e){const t=this.compList.indexOf(e);-1!==t&&(this.compList.splice(t,1),e.dispose(),this.signals.componentRemoved.dispatch(e))}removeAllComponents(){this.compList.slice().forEach((e=>this.removeComponent(e)))}handleResize(){this.viewer.handleResize()}setSize(e,t){const i=this.viewer.container;i!==document.body&&(void 0!==e&&(i.style.width=e),void 0!==t&&(i.style.height=t),this.handleResize())}toggleFullscreen(e){if(!(document.fullscreenEnabled||document.mozFullScreenEnabled||document.webkitFullscreenEnabled||document.msFullscreenEnabled))return void il.log("fullscreen mode (currently) not possible");const t=this;function i(){return document.fullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement||document.msFullscreenElement}function n(){if(!i()&&t.lastFullscreenElement){const e=t.lastFullscreenElement;e.style.width=e.dataset.normalWidth||"",e.style.height=e.dataset.normalHeight||"",document.removeEventListener("fullscreenchange",n),document.removeEventListener("mozfullscreenchange",n),document.removeEventListener("webkitfullscreenchange",n),document.removeEventListener("MSFullscreenChange",n),t.handleResize(),t.signals.fullscreenChanged.dispatch(!1)}}e=e||this.viewer.container,this.lastFullscreenElement=e,i()?document.exitFullscreen?document.exitFullscreen():document.msExitFullscreen?document.msExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen&&document.webkitExitFullscreen():(e.dataset.normalWidth=e.style.width||"",e.dataset.normalHeight=e.style.height||"",e.style.width=window.screen.width+"px",e.style.height=window.screen.height+"px",e.requestFullscreen?e.requestFullscreen():e.msRequestFullscreen?e.msRequestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.webkitRequestFullscreen&&e.webkitRequestFullscreen(),document.addEventListener("fullscreenchange",n),document.addEventListener("mozfullscreenchange",n),document.addEventListener("webkitfullscreenchange",n),document.addEventListener("MSFullscreenChange",n),this.handleResize(),this.signals.fullscreenChanged.dispatch(!0),setTimeout((function(){t.handleResize()}),100))}setSpin(e){e?(this.spinAnimation.resume(!0),this.rockAnimation.pause(!0)):this.spinAnimation.pause(!0)}setRock(e){e?(this.rockAnimation.resume(!0),this.spinAnimation.pause(!0)):this.rockAnimation.pause(!0)}toggleSpin(){this.setSpin(this.spinAnimation.paused)}toggleRock(){this.setRock(this.rockAnimation.paused)}getFocus(){const e=this.parameters;if("scene"!==e.clipMode)return 0;let t=e.clipNear;return"absolute"===e.clipScale&&(t=this.viewer.absoluteToRelative(t)),2*t}setFocus(e){if("scene"!==this.parameters.clipMode)return;let t,i,n,r;"relative"===this.parameters.clipScale?(t=tc(e/2,0,49.9),i=100-t,n=50,r=function(e){return tc(e,0,100)}(2*i-50)):(t=this.viewer.relativeToAbsolute(e/2),i=t,n=0,r=2*i),this.setParameters({clipNear:t,clipFar:i,fogNear:n,fogFar:r})}getZoomForBox(e){const t=e.getSize(Xg),i=Math.max(t.x,t.y,t.z),n=Math.min(t.x,t.y,t.z);let r=i+Math.sqrt(n);const s=Ka(this.viewer.perspectiveCamera.fov),o=this.viewer.width,a=this.viewer.height,c=a{this.tasks.onZeroOnce((()=>{this.tasks.increment(),this.viewer.makeImage(e).then((e=>{this.tasks.decrement(),t(e)})).catch((e=>{this.tasks.decrement(),i(e)}))}))}))}setImpostor(e){this.parameters.impostor=e;const t=["spacefill","ball+stick","licorice","hyperball","backbone","rocket","helixorient","contact","distance","dot"];this.eachRepresentation((function(i){if(!t.includes(i.getType()))return;const n=i.getParameters();n.disableImpostor=!e,i.build(n)}))}setQuality(e){this.parameters.quality=e;const t=["tube","cartoon","ribbon","trace","rope"],i=["spacefill","ball+stick","licorice","hyperball","backbone","rocket","helixorient","contact","distance","dot"];this.eachRepresentation((function(n){const r=n.getParameters();if(!t.includes(n.getType())){if(!i.includes(n.getType()))return;if(!r.disableImpostor)return void(n.repr.quality=e)}r.quality=e,n.build(r)}))}eachComponent(e,t){this.compList.slice().forEach((i=>{void 0!==t&&t!==i.type||e(i)}))}eachRepresentation(e,t){this.eachComponent((i=>{i.reprList.slice().forEach((n=>{void 0!==t&&t!==n.getType()||e(n,i)}))}))}getComponentsByName(e){const t=[];return this.eachComponent((i=>{(void 0===e||qg(e,i))&&t.push(i)})),new Wg(t)}getComponentsByObject(e){const t=[];return this.eachComponent((i=>{i.object===e&&t.push(i)})),new Wg(t)}getRepresentationsByName(e){const t=[];return this.eachRepresentation(((i,n)=>{(void 0===e||qg(e,i))&&t.push(i)})),new Ag(t)}measureClear(){this.eachComponent((e=>e.measureClear()),"structure")}measureUpdate(){this.eachComponent((e=>e.measureUpdate()),"structure")}dispose(){this.tasks.dispose(),this.viewer.dispose(),this.mouseObserver.dispose()}},e.StaticDatasource=class extends tS{constructor(e=""){super(),this.baseUrl=e}getUrl(e){const t=Sl(e);let i=this.baseUrl+t.path;return hS.test(this.baseUrl)||(i=function(e){const t=window.location,i=t.pathname,n=i.substring(0,i.lastIndexOf("/")+1);return t.origin+n+e}(i)),i}getExt(e){return Sl(e).ext}},e.StlWriter=class extends Pl{constructor(e){super(),this.mimeType="application/vnd.ms-pki.stl",this.defaultName="surface",this.defaultExt="stl",this.surface=e}getData(){const e=this.surface.index.length/3,t=new Il(2*e+3*e*4*4+80+4);t.skip(80),t.writeUint32(e);const i=new Zt,n=new Zt,r=new Zt,s=new Zt;for(let o=0;o{e.eachAtom((e=>{s.growIfFull(),s.atomTypeId[c]=o.add(e.atomname,e.element),s.x[c]=e.x,s.y[c]=e.y,s.z[c]=e.z,s.serial[c]=e.serial,s.formalCharge[c]=e.formalCharge,s.partialCharge[c]=e.partialCharge,s.altloc[c]=e.altloc,s.occupancy[c]=e.occupancy,s.bfactor[c]=e.bfactor,r.addAtom(e.modelIndex+h,e.chainname,e.chainid,e.resname,e.resno,1===e.hetero,e.sstruc,e.inscode),a[e.index+l]=c,c+=1})),l+=e.atomStore.count,h+=e.modelStore.count}));const u=n.bondStore,d=n.getAtomProxy(),f=n.getAtomProxy();return l=0,i.forEach((e=>{e.eachBond((e=>{d.index=a[e.atomIndex1+l],f.index=a[e.atomIndex2+l],u.addBond(d,f,e.bondOrder)})),l+=e.atomStore.count})),r.finalize(),hp(n,!0),lp(n,!0),n.finalizeAtoms(),n.finalizeBonds(),pp(n),e.Debug&&il.timeEnd("concatStructures"),n},e.download=Oa,e.flatten=function e(t,i){i=Ia(i,[]);for(let n=0;nt?(o&&(clearTimeout(o),o=null),a=l,s=e.apply(n,r),o||(n=r=null)):o||!1===i.trailing||(o=setTimeout(c,h)),s}},e.uniqueArray=za,Object.defineProperty(e,"__esModule",{value:!0})})); //# sourceMappingURL=ngl.js.map diff --git a/dist/ngl.js.map b/dist/ngl.js.map index 644c1464..273470b9 100644 --- a/dist/ngl.js.map +++ b/dist/ngl.js.map @@ -1 +1 @@ -{"version":3,"file":"ngl.js","sources":["../node_modules/three/src/constants.js","../node_modules/three/src/core/EventDispatcher.js","../node_modules/three/src/math/MathUtils.js","../node_modules/three/src/math/Vector2.js","../node_modules/three/src/math/Matrix3.js","../node_modules/three/src/extras/ImageUtils.js","../node_modules/three/src/textures/Texture.js","../node_modules/three/src/math/Vector4.js","../node_modules/three/src/renderers/WebGLRenderTarget.js","../node_modules/three/src/math/Quaternion.js","../node_modules/three/src/math/Vector3.js","../node_modules/three/src/math/Matrix4.js","../node_modules/three/src/math/Euler.js","../node_modules/three/src/core/Layers.js","../node_modules/three/src/core/Object3D.js","../node_modules/three/src/scenes/Scene.js","../node_modules/three/src/math/Box3.js","../node_modules/three/src/math/Sphere.js","../node_modules/three/src/math/Ray.js","../node_modules/three/src/math/Plane.js","../node_modules/three/src/math/Triangle.js","../node_modules/three/src/math/Color.js","../node_modules/three/src/core/Face3.js","../node_modules/three/src/materials/Material.js","../node_modules/three/src/materials/MeshBasicMaterial.js","../node_modules/three/src/core/BufferAttribute.js","../node_modules/three/src/core/DirectGeometry.js","../node_modules/three/src/utils.js","../node_modules/three/src/core/BufferGeometry.js","../node_modules/three/src/objects/Mesh.js","../node_modules/three/src/core/Geometry.js","../node_modules/three/src/geometries/BoxGeometry.js","../node_modules/three/src/renderers/shaders/UniformsUtils.js","../node_modules/three/src/renderers/shaders/ShaderChunk/default_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/default_fragment.glsl.js","../node_modules/three/src/materials/ShaderMaterial.js","../node_modules/three/src/cameras/Camera.js","../node_modules/three/src/cameras/PerspectiveCamera.js","../node_modules/three/src/textures/DataTexture.js","../node_modules/three/src/math/Frustum.js","../node_modules/three/src/renderers/shaders/UniformsLib.js","../node_modules/three/src/renderers/webgl/WebGLAnimation.js","../node_modules/three/src/renderers/webgl/WebGLAttributes.js","../node_modules/three/src/geometries/PlaneGeometry.js","../node_modules/three/src/renderers/shaders/ShaderChunk.js","../node_modules/three/src/renderers/shaders/ShaderChunk/alphamap_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/alphamap_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/alphatest_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/aomap_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/begin_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/beginnormal_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/bsdfs.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/clipping_planes_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/clipping_planes_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/clipping_planes_pars_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/clipping_planes_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/color_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/color_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/common.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/displacementmap_pars_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/displacementmap_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/emissivemap_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/encodings_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/encodings_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/envmap_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/envmap_pars_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/envmap_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/fog_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/fog_pars_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/fog_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/fog_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/gradientmap_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/lightmap_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/lightmap_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/lights_lambert_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/lights_toon_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/lights_toon_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/lights_phong_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/map_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/map_particle_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/map_particle_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/metalnessmap_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/metalnessmap_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/morphnormal_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/morphtarget_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/normal_fragment_maps.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/normalmap_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_begin.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_maps.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/clearcoat_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/packing.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/premultiplied_alpha_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/project_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/dithering_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/dithering_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/roughnessmap_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/roughnessmap_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/skinbase_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/skinning_pars_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/skinning_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/skinnormal_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/specularmap_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/specularmap_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/tonemapping_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/uv_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/uv_pars_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/uv_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/uv2_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/uv2_pars_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/uv2_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/worldpos_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/background_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/background_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/cube_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/cube_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/depth_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/depth_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/distanceRGBA_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/distanceRGBA_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/equirect_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/equirect_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/linedashed_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/linedashed_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/meshbasic_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/meshbasic_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/meshlambert_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/meshlambert_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/meshmatcap_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/meshmatcap_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/meshtoon_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/meshtoon_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/meshphong_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/meshphong_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/meshphysical_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/meshphysical_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/normal_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/normal_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/points_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/points_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/shadow_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/shadow_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/sprite_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/sprite_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib.js","../node_modules/three/src/renderers/webgl/WebGLBackground.js","../node_modules/three/src/renderers/webgl/WebGLBindingStates.js","../node_modules/three/src/renderers/webgl/WebGLBufferRenderer.js","../node_modules/three/src/renderers/webgl/WebGLCapabilities.js","../node_modules/three/src/renderers/webgl/WebGLClipping.js","../node_modules/three/src/renderers/webgl/WebGLExtensions.js","../node_modules/three/src/renderers/webgl/WebGLGeometries.js","../node_modules/three/src/renderers/webgl/WebGLIndexedBufferRenderer.js","../node_modules/three/src/renderers/webgl/WebGLInfo.js","../node_modules/three/src/renderers/webgl/WebGLMorphtargets.js","../node_modules/three/src/renderers/webgl/WebGLObjects.js","../node_modules/three/src/textures/CubeTexture.js","../node_modules/three/src/textures/DataTexture2DArray.js","../node_modules/three/src/textures/DataTexture3D.js","../node_modules/three/src/renderers/webgl/WebGLUniforms.js","../node_modules/three/src/renderers/webgl/WebGLShader.js","../node_modules/three/src/renderers/webgl/WebGLProgram.js","../node_modules/three/src/renderers/webgl/WebGLPrograms.js","../node_modules/three/src/renderers/webgl/WebGLProperties.js","../node_modules/three/src/renderers/webgl/WebGLRenderLists.js","../node_modules/three/src/renderers/webgl/WebGLLights.js","../node_modules/three/src/renderers/webgl/WebGLRenderStates.js","../node_modules/three/src/materials/MeshDepthMaterial.js","../node_modules/three/src/materials/MeshDistanceMaterial.js","../node_modules/three/src/renderers/shaders/ShaderLib/vsm_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/vsm_vert.glsl.js","../node_modules/three/src/renderers/webgl/WebGLShadowMap.js","../node_modules/three/src/renderers/webgl/WebGLState.js","../node_modules/three/src/renderers/webgl/WebGLTextures.js","../node_modules/three/src/renderers/webgl/WebGLUtils.js","../node_modules/three/src/cameras/ArrayCamera.js","../node_modules/three/src/objects/Group.js","../node_modules/three/src/renderers/webxr/WebXRController.js","../node_modules/three/src/renderers/webxr/WebXRManager.js","../node_modules/three/src/renderers/webgl/WebGLMaterials.js","../node_modules/three/src/renderers/WebGLRenderer.js","../node_modules/three/src/scenes/Fog.js","../node_modules/three/src/materials/LineBasicMaterial.js","../node_modules/three/src/objects/Line.js","../node_modules/three/src/objects/LineSegments.js","../node_modules/three/src/materials/PointsMaterial.js","../node_modules/three/src/objects/Points.js","../node_modules/three/src/textures/CanvasTexture.js","../node_modules/three/src/geometries/PolyhedronGeometry.js","../node_modules/three/src/geometries/TetrahedronGeometry.js","../node_modules/three/src/geometries/OctahedronGeometry.js","../node_modules/three/src/geometries/IcosahedronGeometry.js","../node_modules/three/src/geometries/TorusGeometry.js","../node_modules/three/src/geometries/CylinderGeometry.js","../node_modules/three/src/geometries/ConeGeometry.js","../node_modules/three/src/lights/Light.js","../node_modules/three/src/lights/LightShadow.js","../node_modules/three/src/lights/SpotLightShadow.js","../node_modules/three/src/lights/SpotLight.js","../node_modules/three/src/cameras/OrthographicCamera.js","../node_modules/three/src/lights/AmbientLight.js","../node_modules/three/src/cameras/StereoCamera.js","../node_modules/three/src/core/Uniform.js","../src/utils.ts","../src/utils/registry.ts","../src/math/math-utils.ts","../node_modules/chroma-js/chroma.js","../src/color/colormaker.ts","../src/selection/selection-constants.ts","../node_modules/signals/dist/signals.js","../src/selection/selection-test.ts","../src/selection/selection.ts","../src/selection/selection-parser.ts","../src/color/selection-colormaker.ts","../src/color/colormaker-registry.ts","../src/worker/worker-utils.ts","../src/globals.ts","../src/worker/worker-registry.ts","../src/parser/parser-registry.ts","../src/streamer/streamer.ts","../src/streamer/file-streamer.ts","../src/streamer/network-streamer.ts","../src/loader/loader.ts","../src/loader/parser-loader.ts","../src/script.ts","../src/loader/script-loader.ts","../src/loader/loader-utils.ts","../node_modules/sprintf-js/src/sprintf.js","../src/writer/writer.ts","../src/utils/io-buffer.ts","../src/utils/counter.ts","../src/viewer/stats.ts","../src/shader/shader-utils.ts","../src/viewer/viewer-constants.ts","../src/viewer/tiled-renderer.ts","../src/math/math-constants.ts","../src/math/array-utils.ts","../src/viewer/viewer-utils.ts","../src/viewer/gl-utils.ts","../src/viewer/viewer.ts","../src/stage/mouse-observer.ts","../src/constants.ts","../src/controls/trackball-controls.ts","../src/controls/picking-proxy.ts","../src/controls/picking-controls.ts","../src/controls/viewer-controls.ts","../src/animation/animation.ts","../src/controls/animation-controls.ts","../src/utils/queue.ts","../src/representation/representation.ts","../src/worker/worker.ts","../src/worker/worker-pool.ts","../src/math/vector-utils.ts","../src/geometry/dash.ts","../src/geometry/primitive.ts","../src/geometry/spatial-hash.ts","../src/store/store.ts","../src/store/contact-store.ts","../src/utils/bitarray.ts","../src/utils/adjacency-list.ts","../src/chemistry/interactions/features.ts","../src/structure/structure-constants.ts","../src/chemistry/geometry.ts","../src/chemistry/valence-model.ts","../src/structure/data.ts","../src/chemistry/functional-groups.ts","../src/chemistry/interactions/charged.ts","../src/chemistry/interactions/hydrogen-bonds.ts","../src/chemistry/interactions/metal-binding.ts","../src/chemistry/interactions/halogen-bonds.ts","../src/chemistry/interactions/refine-contacts.ts","../src/chemistry/interactions/contact.ts","../src/chemistry/interactions/hydrophobic.ts","../src/utils/picker.ts","../src/surface/marching-cubes.ts","../src/math/matrix-utils.ts","../src/surface/surface-utils.ts","../src/surface/surface.ts","../src/surface/volume.ts","../src/buffer/buffer.ts","../src/buffer/mesh-buffer.ts","../src/buffer/surface-buffer.ts","../src/buffer/doublesided-buffer.ts","../src/buffer/contour-buffer.ts","../src/representation/surface-representation.ts","../src/controls/mouse-actions.ts","../src/controls/mouse-controls.ts","../src/controls/key-actions.ts","../src/controls/key-controls.ts","../src/stage/picking-behavior.ts","../src/stage/mouse-behavior.ts","../src/stage/animation-behavior.ts","../src/stage/key-behavior.ts","../src/component/annotation.ts","../src/controls/component-controls.ts","../src/utils/radius-factory.ts","../src/math/principal-axes.ts","../src/surface/filtered-volume.ts","../src/store/bond-hash.ts","../src/store/bond-store.ts","../src/store/atom-store.ts","../src/store/residue-store.ts","../src/store/chain-store.ts","../src/store/model-store.ts","../src/geometry/helixorient.ts","../src/geometry/helixbundle.ts","../src/utils/binary-heap.ts","../src/utils/kdtree.ts","../src/proxy/atom-proxy.ts","../src/geometry/kdtree.ts","../src/symmetry/symmetry-constants.ts","../src/symmetry/symmetry-utils.ts","../src/symmetry/assembly.ts","../src/structure/structure-builder.ts","../src/structure/structure-utils.ts","../src/store/atom-type.ts","../src/store/atom-map.ts","../src/store/residue-type.ts","../src/store/residue-map.ts","../src/proxy/bond-proxy.ts","../src/proxy/residue-proxy.ts","../src/proxy/polymer.ts","../src/proxy/chain-proxy.ts","../src/proxy/model-proxy.ts","../src/structure/structure.ts","../src/geometry/shape.ts","../src/representation/buffer-representation.ts","../src/buffer/geometry-buffer.ts","../src/buffer/spheregeometry-buffer.ts","../src/buffer/mapped-buffer.ts","../src/buffer/mappedquad-buffer.ts","../src/buffer/sphereimpostor-buffer.ts","../src/buffer/sphere-buffer.ts","../src/buffer/point-buffer.ts","../src/representation/dot-representation.ts","../src/buffer/image-buffer.ts","../src/surface/volume-slice.ts","../src/representation/slice-representation.ts","../src/representation/representation-utils.ts","../src/component/element.ts","../src/component/representation-element.ts","../src/component/component.ts","../src/component/collection.ts","../src/component/representation-collection.ts","../src/component/trajectory-element.ts","../src/trajectory/frames.ts","../src/align/superposition.ts","../src/trajectory/trajectory-player.ts","../src/trajectory/trajectory.ts","../src/trajectory/frames-trajectory.ts","../src/trajectory/structure-trajectory.ts","../src/trajectory/remote-trajectory.ts","../src/trajectory/callback-trajectory.ts","../src/structure/structure-view.ts","../src/align/alignment.ts","../src/align/align-utils.ts","../src/component/structure-component.ts","../src/trajectory/trajectory-utils.ts","../src/component/surface-component.ts","../src/component/volume-component.ts","../src/component/component-collection.ts","../src/stage/stage.ts","../src/component/shape-component.ts","../node_modules/tslib/tslib.es6.js","../src/color/atomindex-colormaker.ts","../src/color/bfactor-colormaker.ts","../src/color/chainid-colormaker.ts","../src/color/chainindex-colormaker.ts","../src/color/chainname-colormaker.ts","../src/color/densityfit-colormaker.ts","../src/color/electrostatic-colormaker.ts","../src/color/element-colormaker.ts","../src/color/entityindex-colormaker.ts","../src/color/entitytype-colormaker.ts","../src/color/geoquality-colormaker.ts","../src/color/hydrophobicity-colormaker.ts","../src/color/modelindex-colormaker.ts","../src/color/moleculetype-colormaker.ts","../src/color/occupancy-colormaker.ts","../src/color/partialcharge-colormaker.ts","../src/color/random-colormaker.ts","../src/color/randomcoilindex-colormaker.ts","../src/color/residueindex-colormaker.ts","../src/color/resname-colormaker.ts","../src/color/sstruc-colormaker.ts","../src/color/structuredata-colormaker.ts","../src/color/uniform-colormaker.ts","../src/color/value-colormaker.ts","../src/color/volume-colormaker.ts","../src/representation/structure-representation.ts","../src/representation/measurement-representation.ts","../src/utils/edt.ts","../src/buffer/text-buffer.ts","../src/buffer/wideline-buffer.ts","../src/representation/angle-representation.ts","../src/buffer/cylindergeometry-buffer.ts","../src/buffer/mappedalignedbox-buffer.ts","../src/buffer/cylinderimpostor-buffer.ts","../src/buffer/cylinder-buffer.ts","../src/representation/axes-representation.ts","../src/representation/ballandstick-representation.ts","../src/representation/backbone-representation.ts","../src/representation/base-representation.ts","../src/geometry/spline.ts","../src/buffer/tubemesh-buffer.ts","../src/representation/cartoon-representation.ts","../src/representation/contact-representation.ts","../src/representation/dihedral-representation.ts","../src/representation/dihedral-histogram-representation.ts","../src/representation/distance-representation.ts","../src/buffer/vector-buffer.ts","../src/representation/helixorient-representation.ts","../src/representation/licorice-representation.ts","../src/buffer/mappedbox-buffer.ts","../src/buffer/hyperballstickimpostor-buffer.ts","../src/buffer/hyperballstick-buffer.ts","../src/representation/hyperball-representation.ts","../src/utils/label-factory.ts","../src/representation/label-representation.ts","../src/representation/line-representation.ts","../src/geometry/grid.ts","../src/surface/edt-surface.ts","../src/surface/av-surface.ts","../src/surface/molecular-surface.ts","../src/representation/molecularsurface-representation.ts","../src/representation/point-representation.ts","../src/buffer/ribbon-buffer.ts","../src/representation/ribbon-representation.ts","../src/representation/rocket-representation.ts","../src/representation/rope-representation.ts","../src/representation/spacefill-representation.ts","../src/buffer/trace-buffer.ts","../src/representation/trace-representation.ts","../src/representation/tube-representation.ts","../src/representation/unitcell-representation.ts","../src/representation/validation-representation.ts","../src/buffer/cone-buffer.ts","../src/viewer/geometry-group.ts","../src/buffer/arrow-buffer.ts","../src/buffer/box-buffer.ts","../src/buffer/ellipsoid-buffer.ts","../src/buffer/octahedron-buffer.ts","../src/buffer/tetrahedron-buffer.ts","../src/buffer/torus-buffer.ts","../src/parser/parser.ts","../src/parser/structure-parser.ts","../src/structure/entity.ts","../src/symmetry/unitcell.ts","../src/parser/pdb-parser.ts","../src/parser/cif-parser.ts","../src/parser/gro-parser.ts","../lib/mmtf.es6.js","../src/parser/mmtf-parser.ts","../src/parser/mol2-parser.ts","../src/parser/pdbqt-parser.ts","../src/parser/pqr-parser.ts","../src/parser/sdf-parser.ts","../src/parser/prmtop-parser.ts","../src/parser/psf-parser.ts","../src/parser/top-parser.ts","../src/parser/trajectory-parser.ts","../src/utils/netcdf-reader.ts","../src/parser/dcd-parser.ts","../src/parser/nctraj-parser.ts","../src/parser/trr-parser.ts","../src/parser/xtc-parser.ts","../src/parser/volume-parser.ts","../src/parser/cube-parser.ts","../src/parser/dsn6-parser.ts","../src/parser/dx-parser.ts","../src/parser/dxbin-parser.ts","../src/parser/mrc-parser.ts","../src/parser/xplor-parser.ts","../src/parser/kin-parser.ts","../src/parser/surface-parser.ts","../src/parser/obj-parser.ts","../src/parser/ply-parser.ts","../src/parser/csv-parser.ts","../src/parser/json-parser.ts","../src/parser/msgpack-parser.ts","../src/parser/netcdf-parser.ts","../src/parser/text-parser.ts","../src/utils/parse-xml.ts","../src/parser/xml-parser.ts","../src/structure/validation.ts","../lib/pako_inflate.es6.js","../src/parser/validation-parser.ts","../src/utils/gzip-decompressor.ts","../src/datasource/datasource.ts","../src/datasource/rcsb-datasource.ts","../src/datasource/pubchem-datasource.ts","../src/datasource/passthrough-datasource.ts","../src/datasource/alphafold-datasource.ts","../src/datasource/static-datasource.ts","../src/ui/parameters.ts","../src/datasource/mdsrv-datasource.ts","../src/writer/pdb-writer.ts","../src/writer/sdf-writer.ts","../src/writer/stl-writer.ts"],"sourcesContent":["export const REVISION = '118';\nexport const MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 };\nexport const TOUCH = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 };\nexport const CullFaceNone = 0;\nexport const CullFaceBack = 1;\nexport const CullFaceFront = 2;\nexport const CullFaceFrontBack = 3;\nexport const FrontFaceDirectionCW = 0;\nexport const FrontFaceDirectionCCW = 1;\nexport const BasicShadowMap = 0;\nexport const PCFShadowMap = 1;\nexport const PCFSoftShadowMap = 2;\nexport const VSMShadowMap = 3;\nexport const FrontSide = 0;\nexport const BackSide = 1;\nexport const DoubleSide = 2;\nexport const FlatShading = 1;\nexport const SmoothShading = 2;\nexport const NoBlending = 0;\nexport const NormalBlending = 1;\nexport const AdditiveBlending = 2;\nexport const SubtractiveBlending = 3;\nexport const MultiplyBlending = 4;\nexport const CustomBlending = 5;\nexport const AddEquation = 100;\nexport const SubtractEquation = 101;\nexport const ReverseSubtractEquation = 102;\nexport const MinEquation = 103;\nexport const MaxEquation = 104;\nexport const ZeroFactor = 200;\nexport const OneFactor = 201;\nexport const SrcColorFactor = 202;\nexport const OneMinusSrcColorFactor = 203;\nexport const SrcAlphaFactor = 204;\nexport const OneMinusSrcAlphaFactor = 205;\nexport const DstAlphaFactor = 206;\nexport const OneMinusDstAlphaFactor = 207;\nexport const DstColorFactor = 208;\nexport const OneMinusDstColorFactor = 209;\nexport const SrcAlphaSaturateFactor = 210;\nexport const NeverDepth = 0;\nexport const AlwaysDepth = 1;\nexport const LessDepth = 2;\nexport const LessEqualDepth = 3;\nexport const EqualDepth = 4;\nexport const GreaterEqualDepth = 5;\nexport const GreaterDepth = 6;\nexport const NotEqualDepth = 7;\nexport const MultiplyOperation = 0;\nexport const MixOperation = 1;\nexport const AddOperation = 2;\nexport const NoToneMapping = 0;\nexport const LinearToneMapping = 1;\nexport const ReinhardToneMapping = 2;\nexport const CineonToneMapping = 3;\nexport const ACESFilmicToneMapping = 4;\nexport const CustomToneMapping = 5;\n\nexport const UVMapping = 300;\nexport const CubeReflectionMapping = 301;\nexport const CubeRefractionMapping = 302;\nexport const EquirectangularReflectionMapping = 303;\nexport const EquirectangularRefractionMapping = 304;\nexport const CubeUVReflectionMapping = 306;\nexport const CubeUVRefractionMapping = 307;\nexport const RepeatWrapping = 1000;\nexport const ClampToEdgeWrapping = 1001;\nexport const MirroredRepeatWrapping = 1002;\nexport const NearestFilter = 1003;\nexport const NearestMipmapNearestFilter = 1004;\nexport const NearestMipMapNearestFilter = 1004;\nexport const NearestMipmapLinearFilter = 1005;\nexport const NearestMipMapLinearFilter = 1005;\nexport const LinearFilter = 1006;\nexport const LinearMipmapNearestFilter = 1007;\nexport const LinearMipMapNearestFilter = 1007;\nexport const LinearMipmapLinearFilter = 1008;\nexport const LinearMipMapLinearFilter = 1008;\nexport const UnsignedByteType = 1009;\nexport const ByteType = 1010;\nexport const ShortType = 1011;\nexport const UnsignedShortType = 1012;\nexport const IntType = 1013;\nexport const UnsignedIntType = 1014;\nexport const FloatType = 1015;\nexport const HalfFloatType = 1016;\nexport const UnsignedShort4444Type = 1017;\nexport const UnsignedShort5551Type = 1018;\nexport const UnsignedShort565Type = 1019;\nexport const UnsignedInt248Type = 1020;\nexport const AlphaFormat = 1021;\nexport const RGBFormat = 1022;\nexport const RGBAFormat = 1023;\nexport const LuminanceFormat = 1024;\nexport const LuminanceAlphaFormat = 1025;\nexport const RGBEFormat = RGBAFormat;\nexport const DepthFormat = 1026;\nexport const DepthStencilFormat = 1027;\nexport const RedFormat = 1028;\nexport const RedIntegerFormat = 1029;\nexport const RGFormat = 1030;\nexport const RGIntegerFormat = 1031;\nexport const RGBIntegerFormat = 1032;\nexport const RGBAIntegerFormat = 1033;\n\nexport const RGB_S3TC_DXT1_Format = 33776;\nexport const RGBA_S3TC_DXT1_Format = 33777;\nexport const RGBA_S3TC_DXT3_Format = 33778;\nexport const RGBA_S3TC_DXT5_Format = 33779;\nexport const RGB_PVRTC_4BPPV1_Format = 35840;\nexport const RGB_PVRTC_2BPPV1_Format = 35841;\nexport const RGBA_PVRTC_4BPPV1_Format = 35842;\nexport const RGBA_PVRTC_2BPPV1_Format = 35843;\nexport const RGB_ETC1_Format = 36196;\nexport const RGB_ETC2_Format = 37492;\nexport const RGBA_ETC2_EAC_Format = 37496;\nexport const RGBA_ASTC_4x4_Format = 37808;\nexport const RGBA_ASTC_5x4_Format = 37809;\nexport const RGBA_ASTC_5x5_Format = 37810;\nexport const RGBA_ASTC_6x5_Format = 37811;\nexport const RGBA_ASTC_6x6_Format = 37812;\nexport const RGBA_ASTC_8x5_Format = 37813;\nexport const RGBA_ASTC_8x6_Format = 37814;\nexport const RGBA_ASTC_8x8_Format = 37815;\nexport const RGBA_ASTC_10x5_Format = 37816;\nexport const RGBA_ASTC_10x6_Format = 37817;\nexport const RGBA_ASTC_10x8_Format = 37818;\nexport const RGBA_ASTC_10x10_Format = 37819;\nexport const RGBA_ASTC_12x10_Format = 37820;\nexport const RGBA_ASTC_12x12_Format = 37821;\nexport const RGBA_BPTC_Format = 36492;\nexport const SRGB8_ALPHA8_ASTC_4x4_Format = 37840;\nexport const SRGB8_ALPHA8_ASTC_5x4_Format = 37841;\nexport const SRGB8_ALPHA8_ASTC_5x5_Format = 37842;\nexport const SRGB8_ALPHA8_ASTC_6x5_Format = 37843;\nexport const SRGB8_ALPHA8_ASTC_6x6_Format = 37844;\nexport const SRGB8_ALPHA8_ASTC_8x5_Format = 37845;\nexport const SRGB8_ALPHA8_ASTC_8x6_Format = 37846;\nexport const SRGB8_ALPHA8_ASTC_8x8_Format = 37847;\nexport const SRGB8_ALPHA8_ASTC_10x5_Format = 37848;\nexport const SRGB8_ALPHA8_ASTC_10x6_Format = 37849;\nexport const SRGB8_ALPHA8_ASTC_10x8_Format = 37850;\nexport const SRGB8_ALPHA8_ASTC_10x10_Format = 37851;\nexport const SRGB8_ALPHA8_ASTC_12x10_Format = 37852;\nexport const SRGB8_ALPHA8_ASTC_12x12_Format = 37853;\nexport const LoopOnce = 2200;\nexport const LoopRepeat = 2201;\nexport const LoopPingPong = 2202;\nexport const InterpolateDiscrete = 2300;\nexport const InterpolateLinear = 2301;\nexport const InterpolateSmooth = 2302;\nexport const ZeroCurvatureEnding = 2400;\nexport const ZeroSlopeEnding = 2401;\nexport const WrapAroundEnding = 2402;\nexport const NormalAnimationBlendMode = 2500;\nexport const AdditiveAnimationBlendMode = 2501;\nexport const TrianglesDrawMode = 0;\nexport const TriangleStripDrawMode = 1;\nexport const TriangleFanDrawMode = 2;\nexport const LinearEncoding = 3000;\nexport const sRGBEncoding = 3001;\nexport const GammaEncoding = 3007;\nexport const RGBEEncoding = 3002;\nexport const LogLuvEncoding = 3003;\nexport const RGBM7Encoding = 3004;\nexport const RGBM16Encoding = 3005;\nexport const RGBDEncoding = 3006;\nexport const BasicDepthPacking = 3200;\nexport const RGBADepthPacking = 3201;\nexport const TangentSpaceNormalMap = 0;\nexport const ObjectSpaceNormalMap = 1;\n\nexport const ZeroStencilOp = 0;\nexport const KeepStencilOp = 7680;\nexport const ReplaceStencilOp = 7681;\nexport const IncrementStencilOp = 7682;\nexport const DecrementStencilOp = 7683;\nexport const IncrementWrapStencilOp = 34055;\nexport const DecrementWrapStencilOp = 34056;\nexport const InvertStencilOp = 5386;\n\nexport const NeverStencilFunc = 512;\nexport const LessStencilFunc = 513;\nexport const EqualStencilFunc = 514;\nexport const LessEqualStencilFunc = 515;\nexport const GreaterStencilFunc = 516;\nexport const NotEqualStencilFunc = 517;\nexport const GreaterEqualStencilFunc = 518;\nexport const AlwaysStencilFunc = 519;\n\nexport const StaticDrawUsage = 35044;\nexport const DynamicDrawUsage = 35048;\nexport const StreamDrawUsage = 35040;\nexport const StaticReadUsage = 35045;\nexport const DynamicReadUsage = 35049;\nexport const StreamReadUsage = 35041;\nexport const StaticCopyUsage = 35046;\nexport const DynamicCopyUsage = 35050;\nexport const StreamCopyUsage = 35042;\n","/**\n * https://github.com/mrdoob/eventdispatcher.js/\n */\n\nfunction EventDispatcher() {}\n\nObject.assign( EventDispatcher.prototype, {\n\n\taddEventListener: function ( type, listener ) {\n\n\t\tif ( this._listeners === undefined ) this._listeners = {};\n\n\t\tconst listeners = this._listeners;\n\n\t\tif ( listeners[ type ] === undefined ) {\n\n\t\t\tlisteners[ type ] = [];\n\n\t\t}\n\n\t\tif ( listeners[ type ].indexOf( listener ) === - 1 ) {\n\n\t\t\tlisteners[ type ].push( listener );\n\n\t\t}\n\n\t},\n\n\thasEventListener: function ( type, listener ) {\n\n\t\tif ( this._listeners === undefined ) return false;\n\n\t\tconst listeners = this._listeners;\n\n\t\treturn listeners[ type ] !== undefined && listeners[ type ].indexOf( listener ) !== - 1;\n\n\t},\n\n\tremoveEventListener: function ( type, listener ) {\n\n\t\tif ( this._listeners === undefined ) return;\n\n\t\tconst listeners = this._listeners;\n\t\tconst listenerArray = listeners[ type ];\n\n\t\tif ( listenerArray !== undefined ) {\n\n\t\t\tconst index = listenerArray.indexOf( listener );\n\n\t\t\tif ( index !== - 1 ) {\n\n\t\t\t\tlistenerArray.splice( index, 1 );\n\n\t\t\t}\n\n\t\t}\n\n\t},\n\n\tdispatchEvent: function ( event ) {\n\n\t\tif ( this._listeners === undefined ) return;\n\n\t\tconst listeners = this._listeners;\n\t\tconst listenerArray = listeners[ event.type ];\n\n\t\tif ( listenerArray !== undefined ) {\n\n\t\t\tevent.target = this;\n\n\t\t\t// Make a copy, in case listeners are removed while iterating.\n\t\t\tconst array = listenerArray.slice( 0 );\n\n\t\t\tfor ( let i = 0, l = array.length; i < l; i ++ ) {\n\n\t\t\t\tarray[ i ].call( this, event );\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n} );\n\n\nexport { EventDispatcher };\n","/**\n * @author alteredq / http://alteredqualia.com/\n * @author mrdoob / http://mrdoob.com/\n * @author WestLangley / http://github.com/WestLangley\n * @author thezwap\n */\n\nconst _lut = [];\n\nfor ( let i = 0; i < 256; i ++ ) {\n\n\t_lut[ i ] = ( i < 16 ? '0' : '' ) + ( i ).toString( 16 );\n\n}\n\nconst MathUtils = {\n\n\tDEG2RAD: Math.PI / 180,\n\tRAD2DEG: 180 / Math.PI,\n\n\tgenerateUUID: function () {\n\n\t\t// http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/21963136#21963136\n\n\t\tconst d0 = Math.random() * 0xffffffff | 0;\n\t\tconst d1 = Math.random() * 0xffffffff | 0;\n\t\tconst d2 = Math.random() * 0xffffffff | 0;\n\t\tconst d3 = Math.random() * 0xffffffff | 0;\n\t\tconst uuid = _lut[ d0 & 0xff ] + _lut[ d0 >> 8 & 0xff ] + _lut[ d0 >> 16 & 0xff ] + _lut[ d0 >> 24 & 0xff ] + '-' +\n\t\t\t_lut[ d1 & 0xff ] + _lut[ d1 >> 8 & 0xff ] + '-' + _lut[ d1 >> 16 & 0x0f | 0x40 ] + _lut[ d1 >> 24 & 0xff ] + '-' +\n\t\t\t_lut[ d2 & 0x3f | 0x80 ] + _lut[ d2 >> 8 & 0xff ] + '-' + _lut[ d2 >> 16 & 0xff ] + _lut[ d2 >> 24 & 0xff ] +\n\t\t\t_lut[ d3 & 0xff ] + _lut[ d3 >> 8 & 0xff ] + _lut[ d3 >> 16 & 0xff ] + _lut[ d3 >> 24 & 0xff ];\n\n\t\t// .toUpperCase() here flattens concatenated strings to save heap memory space.\n\t\treturn uuid.toUpperCase();\n\n\t},\n\n\tclamp: function ( value, min, max ) {\n\n\t\treturn Math.max( min, Math.min( max, value ) );\n\n\t},\n\n\t// compute euclidian modulo of m % n\n\t// https://en.wikipedia.org/wiki/Modulo_operation\n\n\teuclideanModulo: function ( n, m ) {\n\n\t\treturn ( ( n % m ) + m ) % m;\n\n\t},\n\n\t// Linear mapping from range to range \n\n\tmapLinear: function ( x, a1, a2, b1, b2 ) {\n\n\t\treturn b1 + ( x - a1 ) * ( b2 - b1 ) / ( a2 - a1 );\n\n\t},\n\n\t// https://en.wikipedia.org/wiki/Linear_interpolation\n\n\tlerp: function ( x, y, t ) {\n\n\t\treturn ( 1 - t ) * x + t * y;\n\n\t},\n\n\t// http://en.wikipedia.org/wiki/Smoothstep\n\n\tsmoothstep: function ( x, min, max ) {\n\n\t\tif ( x <= min ) return 0;\n\t\tif ( x >= max ) return 1;\n\n\t\tx = ( x - min ) / ( max - min );\n\n\t\treturn x * x * ( 3 - 2 * x );\n\n\t},\n\n\tsmootherstep: function ( x, min, max ) {\n\n\t\tif ( x <= min ) return 0;\n\t\tif ( x >= max ) return 1;\n\n\t\tx = ( x - min ) / ( max - min );\n\n\t\treturn x * x * x * ( x * ( x * 6 - 15 ) + 10 );\n\n\t},\n\n\t// Random integer from interval\n\n\trandInt: function ( low, high ) {\n\n\t\treturn low + Math.floor( Math.random() * ( high - low + 1 ) );\n\n\t},\n\n\t// Random float from interval\n\n\trandFloat: function ( low, high ) {\n\n\t\treturn low + Math.random() * ( high - low );\n\n\t},\n\n\t// Random float from <-range/2, range/2> interval\n\n\trandFloatSpread: function ( range ) {\n\n\t\treturn range * ( 0.5 - Math.random() );\n\n\t},\n\n\tdegToRad: function ( degrees ) {\n\n\t\treturn degrees * MathUtils.DEG2RAD;\n\n\t},\n\n\tradToDeg: function ( radians ) {\n\n\t\treturn radians * MathUtils.RAD2DEG;\n\n\t},\n\n\tisPowerOfTwo: function ( value ) {\n\n\t\treturn ( value & ( value - 1 ) ) === 0 && value !== 0;\n\n\t},\n\n\tceilPowerOfTwo: function ( value ) {\n\n\t\treturn Math.pow( 2, Math.ceil( Math.log( value ) / Math.LN2 ) );\n\n\t},\n\n\tfloorPowerOfTwo: function ( value ) {\n\n\t\treturn Math.pow( 2, Math.floor( Math.log( value ) / Math.LN2 ) );\n\n\t},\n\n\tsetQuaternionFromProperEuler: function ( q, a, b, c, order ) {\n\n\t\t// Intrinsic Proper Euler Angles - see https://en.wikipedia.org/wiki/Euler_angles\n\n\t\t// rotations are applied to the axes in the order specified by 'order'\n\t\t// rotation by angle 'a' is applied first, then by angle 'b', then by angle 'c'\n\t\t// angles are in radians\n\n\t\tconst cos = Math.cos;\n\t\tconst sin = Math.sin;\n\n\t\tconst c2 = cos( b / 2 );\n\t\tconst s2 = sin( b / 2 );\n\n\t\tconst c13 = cos( ( a + c ) / 2 );\n\t\tconst s13 = sin( ( a + c ) / 2 );\n\n\t\tconst c1_3 = cos( ( a - c ) / 2 );\n\t\tconst s1_3 = sin( ( a - c ) / 2 );\n\n\t\tconst c3_1 = cos( ( c - a ) / 2 );\n\t\tconst s3_1 = sin( ( c - a ) / 2 );\n\n\t\tswitch ( order ) {\n\n\t\t\tcase 'XYX':\n\t\t\t\tq.set( c2 * s13, s2 * c1_3, s2 * s1_3, c2 * c13 );\n\t\t\t\tbreak;\n\n\t\t\tcase 'YZY':\n\t\t\t\tq.set( s2 * s1_3, c2 * s13, s2 * c1_3, c2 * c13 );\n\t\t\t\tbreak;\n\n\t\t\tcase 'ZXZ':\n\t\t\t\tq.set( s2 * c1_3, s2 * s1_3, c2 * s13, c2 * c13 );\n\t\t\t\tbreak;\n\n\t\t\tcase 'XZX':\n\t\t\t\tq.set( c2 * s13, s2 * s3_1, s2 * c3_1, c2 * c13 );\n\t\t\t\tbreak;\n\n\t\t\tcase 'YXY':\n\t\t\t\tq.set( s2 * c3_1, c2 * s13, s2 * s3_1, c2 * c13 );\n\t\t\t\tbreak;\n\n\t\t\tcase 'ZYZ':\n\t\t\t\tq.set( s2 * s3_1, s2 * c3_1, c2 * s13, c2 * c13 );\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tconsole.warn( 'THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: ' + order );\n\n\t\t}\n\n\t}\n\n};\n\n\nexport { MathUtils };\n","/**\n * @author mrdoob / http://mrdoob.com/\n * @author philogb / http://blog.thejit.org/\n * @author egraether / http://egraether.com/\n * @author zz85 / http://www.lab4games.net/zz85/blog\n */\n\nfunction Vector2( x = 0, y = 0 ) {\n\n\tthis.x = x;\n\tthis.y = y;\n\n}\n\nObject.defineProperties( Vector2.prototype, {\n\n\t\"width\": {\n\n\t\tget: function () {\n\n\t\t\treturn this.x;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tthis.x = value;\n\n\t\t}\n\n\t},\n\n\t\"height\": {\n\n\t\tget: function () {\n\n\t\t\treturn this.y;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tthis.y = value;\n\n\t\t}\n\n\t}\n\n} );\n\nObject.assign( Vector2.prototype, {\n\n\tisVector2: true,\n\n\tset: function ( x, y ) {\n\n\t\tthis.x = x;\n\t\tthis.y = y;\n\n\t\treturn this;\n\n\t},\n\n\tsetScalar: function ( scalar ) {\n\n\t\tthis.x = scalar;\n\t\tthis.y = scalar;\n\n\t\treturn this;\n\n\t},\n\n\tsetX: function ( x ) {\n\n\t\tthis.x = x;\n\n\t\treturn this;\n\n\t},\n\n\tsetY: function ( y ) {\n\n\t\tthis.y = y;\n\n\t\treturn this;\n\n\t},\n\n\tsetComponent: function ( index, value ) {\n\n\t\tswitch ( index ) {\n\n\t\t\tcase 0: this.x = value; break;\n\t\t\tcase 1: this.y = value; break;\n\t\t\tdefault: throw new Error( 'index is out of range: ' + index );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tgetComponent: function ( index ) {\n\n\t\tswitch ( index ) {\n\n\t\t\tcase 0: return this.x;\n\t\t\tcase 1: return this.y;\n\t\t\tdefault: throw new Error( 'index is out of range: ' + index );\n\n\t\t}\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor( this.x, this.y );\n\n\t},\n\n\tcopy: function ( v ) {\n\n\t\tthis.x = v.x;\n\t\tthis.y = v.y;\n\n\t\treturn this;\n\n\t},\n\n\tadd: function ( v, w ) {\n\n\t\tif ( w !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead.' );\n\t\t\treturn this.addVectors( v, w );\n\n\t\t}\n\n\t\tthis.x += v.x;\n\t\tthis.y += v.y;\n\n\t\treturn this;\n\n\t},\n\n\taddScalar: function ( s ) {\n\n\t\tthis.x += s;\n\t\tthis.y += s;\n\n\t\treturn this;\n\n\t},\n\n\taddVectors: function ( a, b ) {\n\n\t\tthis.x = a.x + b.x;\n\t\tthis.y = a.y + b.y;\n\n\t\treturn this;\n\n\t},\n\n\taddScaledVector: function ( v, s ) {\n\n\t\tthis.x += v.x * s;\n\t\tthis.y += v.y * s;\n\n\t\treturn this;\n\n\t},\n\n\tsub: function ( v, w ) {\n\n\t\tif ( w !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.' );\n\t\t\treturn this.subVectors( v, w );\n\n\t\t}\n\n\t\tthis.x -= v.x;\n\t\tthis.y -= v.y;\n\n\t\treturn this;\n\n\t},\n\n\tsubScalar: function ( s ) {\n\n\t\tthis.x -= s;\n\t\tthis.y -= s;\n\n\t\treturn this;\n\n\t},\n\n\tsubVectors: function ( a, b ) {\n\n\t\tthis.x = a.x - b.x;\n\t\tthis.y = a.y - b.y;\n\n\t\treturn this;\n\n\t},\n\n\tmultiply: function ( v ) {\n\n\t\tthis.x *= v.x;\n\t\tthis.y *= v.y;\n\n\t\treturn this;\n\n\t},\n\n\tmultiplyScalar: function ( scalar ) {\n\n\t\tthis.x *= scalar;\n\t\tthis.y *= scalar;\n\n\t\treturn this;\n\n\t},\n\n\tdivide: function ( v ) {\n\n\t\tthis.x /= v.x;\n\t\tthis.y /= v.y;\n\n\t\treturn this;\n\n\t},\n\n\tdivideScalar: function ( scalar ) {\n\n\t\treturn this.multiplyScalar( 1 / scalar );\n\n\t},\n\n\tapplyMatrix3: function ( m ) {\n\n\t\tconst x = this.x, y = this.y;\n\t\tconst e = m.elements;\n\n\t\tthis.x = e[ 0 ] * x + e[ 3 ] * y + e[ 6 ];\n\t\tthis.y = e[ 1 ] * x + e[ 4 ] * y + e[ 7 ];\n\n\t\treturn this;\n\n\t},\n\n\tmin: function ( v ) {\n\n\t\tthis.x = Math.min( this.x, v.x );\n\t\tthis.y = Math.min( this.y, v.y );\n\n\t\treturn this;\n\n\t},\n\n\tmax: function ( v ) {\n\n\t\tthis.x = Math.max( this.x, v.x );\n\t\tthis.y = Math.max( this.y, v.y );\n\n\t\treturn this;\n\n\t},\n\n\tclamp: function ( min, max ) {\n\n\t\t// assumes min < max, componentwise\n\n\t\tthis.x = Math.max( min.x, Math.min( max.x, this.x ) );\n\t\tthis.y = Math.max( min.y, Math.min( max.y, this.y ) );\n\n\t\treturn this;\n\n\t},\n\n\tclampScalar: function ( minVal, maxVal ) {\n\n\t\tthis.x = Math.max( minVal, Math.min( maxVal, this.x ) );\n\t\tthis.y = Math.max( minVal, Math.min( maxVal, this.y ) );\n\n\t\treturn this;\n\n\t},\n\n\tclampLength: function ( min, max ) {\n\n\t\tconst length = this.length();\n\n\t\treturn this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) );\n\n\t},\n\n\tfloor: function () {\n\n\t\tthis.x = Math.floor( this.x );\n\t\tthis.y = Math.floor( this.y );\n\n\t\treturn this;\n\n\t},\n\n\tceil: function () {\n\n\t\tthis.x = Math.ceil( this.x );\n\t\tthis.y = Math.ceil( this.y );\n\n\t\treturn this;\n\n\t},\n\n\tround: function () {\n\n\t\tthis.x = Math.round( this.x );\n\t\tthis.y = Math.round( this.y );\n\n\t\treturn this;\n\n\t},\n\n\troundToZero: function () {\n\n\t\tthis.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x );\n\t\tthis.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y );\n\n\t\treturn this;\n\n\t},\n\n\tnegate: function () {\n\n\t\tthis.x = - this.x;\n\t\tthis.y = - this.y;\n\n\t\treturn this;\n\n\t},\n\n\tdot: function ( v ) {\n\n\t\treturn this.x * v.x + this.y * v.y;\n\n\t},\n\n\tcross: function ( v ) {\n\n\t\treturn this.x * v.y - this.y * v.x;\n\n\t},\n\n\tlengthSq: function () {\n\n\t\treturn this.x * this.x + this.y * this.y;\n\n\t},\n\n\tlength: function () {\n\n\t\treturn Math.sqrt( this.x * this.x + this.y * this.y );\n\n\t},\n\n\tmanhattanLength: function () {\n\n\t\treturn Math.abs( this.x ) + Math.abs( this.y );\n\n\t},\n\n\tnormalize: function () {\n\n\t\treturn this.divideScalar( this.length() || 1 );\n\n\t},\n\n\tangle: function () {\n\n\t\t// computes the angle in radians with respect to the positive x-axis\n\n\t\tconst angle = Math.atan2( - this.y, - this.x ) + Math.PI;\n\n\t\treturn angle;\n\n\t},\n\n\tdistanceTo: function ( v ) {\n\n\t\treturn Math.sqrt( this.distanceToSquared( v ) );\n\n\t},\n\n\tdistanceToSquared: function ( v ) {\n\n\t\tconst dx = this.x - v.x, dy = this.y - v.y;\n\t\treturn dx * dx + dy * dy;\n\n\t},\n\n\tmanhattanDistanceTo: function ( v ) {\n\n\t\treturn Math.abs( this.x - v.x ) + Math.abs( this.y - v.y );\n\n\t},\n\n\tsetLength: function ( length ) {\n\n\t\treturn this.normalize().multiplyScalar( length );\n\n\t},\n\n\tlerp: function ( v, alpha ) {\n\n\t\tthis.x += ( v.x - this.x ) * alpha;\n\t\tthis.y += ( v.y - this.y ) * alpha;\n\n\t\treturn this;\n\n\t},\n\n\tlerpVectors: function ( v1, v2, alpha ) {\n\n\t\tthis.x = v1.x + ( v2.x - v1.x ) * alpha;\n\t\tthis.y = v1.y + ( v2.y - v1.y ) * alpha;\n\n\t\treturn this;\n\n\t},\n\n\tequals: function ( v ) {\n\n\t\treturn ( ( v.x === this.x ) && ( v.y === this.y ) );\n\n\t},\n\n\tfromArray: function ( array, offset ) {\n\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tthis.x = array[ offset ];\n\t\tthis.y = array[ offset + 1 ];\n\n\t\treturn this;\n\n\t},\n\n\ttoArray: function ( array, offset ) {\n\n\t\tif ( array === undefined ) array = [];\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tarray[ offset ] = this.x;\n\t\tarray[ offset + 1 ] = this.y;\n\n\t\treturn array;\n\n\t},\n\n\tfromBufferAttribute: function ( attribute, index, offset ) {\n\n\t\tif ( offset !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Vector2: offset has been removed from .fromBufferAttribute().' );\n\n\t\t}\n\n\t\tthis.x = attribute.getX( index );\n\t\tthis.y = attribute.getY( index );\n\n\t\treturn this;\n\n\t},\n\n\trotateAround: function ( center, angle ) {\n\n\t\tconst c = Math.cos( angle ), s = Math.sin( angle );\n\n\t\tconst x = this.x - center.x;\n\t\tconst y = this.y - center.y;\n\n\t\tthis.x = x * c - y * s + center.x;\n\t\tthis.y = x * s + y * c + center.y;\n\n\t\treturn this;\n\n\t},\n\n\trandom: function () {\n\n\t\tthis.x = Math.random();\n\t\tthis.y = Math.random();\n\n\t\treturn this;\n\n\t}\n\n} );\n\n\nexport { Vector2 };\n","/**\n * @author alteredq / http://alteredqualia.com/\n * @author WestLangley / http://github.com/WestLangley\n * @author bhouston / http://clara.io\n * @author tschw\n */\n\nfunction Matrix3() {\n\n\tthis.elements = [\n\n\t\t1, 0, 0,\n\t\t0, 1, 0,\n\t\t0, 0, 1\n\n\t];\n\n\tif ( arguments.length > 0 ) {\n\n\t\tconsole.error( 'THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.' );\n\n\t}\n\n}\n\nObject.assign( Matrix3.prototype, {\n\n\tisMatrix3: true,\n\n\tset: function ( n11, n12, n13, n21, n22, n23, n31, n32, n33 ) {\n\n\t\tconst te = this.elements;\n\n\t\tte[ 0 ] = n11; te[ 1 ] = n21; te[ 2 ] = n31;\n\t\tte[ 3 ] = n12; te[ 4 ] = n22; te[ 5 ] = n32;\n\t\tte[ 6 ] = n13; te[ 7 ] = n23; te[ 8 ] = n33;\n\n\t\treturn this;\n\n\t},\n\n\tidentity: function () {\n\n\t\tthis.set(\n\n\t\t\t1, 0, 0,\n\t\t\t0, 1, 0,\n\t\t\t0, 0, 1\n\n\t\t);\n\n\t\treturn this;\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor().fromArray( this.elements );\n\n\t},\n\n\tcopy: function ( m ) {\n\n\t\tconst te = this.elements;\n\t\tconst me = m.elements;\n\n\t\tte[ 0 ] = me[ 0 ]; te[ 1 ] = me[ 1 ]; te[ 2 ] = me[ 2 ];\n\t\tte[ 3 ] = me[ 3 ]; te[ 4 ] = me[ 4 ]; te[ 5 ] = me[ 5 ];\n\t\tte[ 6 ] = me[ 6 ]; te[ 7 ] = me[ 7 ]; te[ 8 ] = me[ 8 ];\n\n\t\treturn this;\n\n\t},\n\n\textractBasis: function ( xAxis, yAxis, zAxis ) {\n\n\t\txAxis.setFromMatrix3Column( this, 0 );\n\t\tyAxis.setFromMatrix3Column( this, 1 );\n\t\tzAxis.setFromMatrix3Column( this, 2 );\n\n\t\treturn this;\n\n\t},\n\n\tsetFromMatrix4: function ( m ) {\n\n\t\tconst me = m.elements;\n\n\t\tthis.set(\n\n\t\t\tme[ 0 ], me[ 4 ], me[ 8 ],\n\t\t\tme[ 1 ], me[ 5 ], me[ 9 ],\n\t\t\tme[ 2 ], me[ 6 ], me[ 10 ]\n\n\t\t);\n\n\t\treturn this;\n\n\t},\n\n\tmultiply: function ( m ) {\n\n\t\treturn this.multiplyMatrices( this, m );\n\n\t},\n\n\tpremultiply: function ( m ) {\n\n\t\treturn this.multiplyMatrices( m, this );\n\n\t},\n\n\tmultiplyMatrices: function ( a, b ) {\n\n\t\tconst ae = a.elements;\n\t\tconst be = b.elements;\n\t\tconst te = this.elements;\n\n\t\tconst a11 = ae[ 0 ], a12 = ae[ 3 ], a13 = ae[ 6 ];\n\t\tconst a21 = ae[ 1 ], a22 = ae[ 4 ], a23 = ae[ 7 ];\n\t\tconst a31 = ae[ 2 ], a32 = ae[ 5 ], a33 = ae[ 8 ];\n\n\t\tconst b11 = be[ 0 ], b12 = be[ 3 ], b13 = be[ 6 ];\n\t\tconst b21 = be[ 1 ], b22 = be[ 4 ], b23 = be[ 7 ];\n\t\tconst b31 = be[ 2 ], b32 = be[ 5 ], b33 = be[ 8 ];\n\n\t\tte[ 0 ] = a11 * b11 + a12 * b21 + a13 * b31;\n\t\tte[ 3 ] = a11 * b12 + a12 * b22 + a13 * b32;\n\t\tte[ 6 ] = a11 * b13 + a12 * b23 + a13 * b33;\n\n\t\tte[ 1 ] = a21 * b11 + a22 * b21 + a23 * b31;\n\t\tte[ 4 ] = a21 * b12 + a22 * b22 + a23 * b32;\n\t\tte[ 7 ] = a21 * b13 + a22 * b23 + a23 * b33;\n\n\t\tte[ 2 ] = a31 * b11 + a32 * b21 + a33 * b31;\n\t\tte[ 5 ] = a31 * b12 + a32 * b22 + a33 * b32;\n\t\tte[ 8 ] = a31 * b13 + a32 * b23 + a33 * b33;\n\n\t\treturn this;\n\n\t},\n\n\tmultiplyScalar: function ( s ) {\n\n\t\tconst te = this.elements;\n\n\t\tte[ 0 ] *= s; te[ 3 ] *= s; te[ 6 ] *= s;\n\t\tte[ 1 ] *= s; te[ 4 ] *= s; te[ 7 ] *= s;\n\t\tte[ 2 ] *= s; te[ 5 ] *= s; te[ 8 ] *= s;\n\n\t\treturn this;\n\n\t},\n\n\tdeterminant: function () {\n\n\t\tconst te = this.elements;\n\n\t\tconst a = te[ 0 ], b = te[ 1 ], c = te[ 2 ],\n\t\t\td = te[ 3 ], e = te[ 4 ], f = te[ 5 ],\n\t\t\tg = te[ 6 ], h = te[ 7 ], i = te[ 8 ];\n\n\t\treturn a * e * i - a * f * h - b * d * i + b * f * g + c * d * h - c * e * g;\n\n\t},\n\n\tgetInverse: function ( matrix, throwOnDegenerate ) {\n\n\t\tif ( throwOnDegenerate !== undefined ) {\n\n\t\t\tconsole.warn( \"THREE.Matrix3: .getInverse() can no longer be configured to throw on degenerate.\" );\n\n\t\t}\n\n\t\tconst me = matrix.elements,\n\t\t\tte = this.elements,\n\n\t\t\tn11 = me[ 0 ], n21 = me[ 1 ], n31 = me[ 2 ],\n\t\t\tn12 = me[ 3 ], n22 = me[ 4 ], n32 = me[ 5 ],\n\t\t\tn13 = me[ 6 ], n23 = me[ 7 ], n33 = me[ 8 ],\n\n\t\t\tt11 = n33 * n22 - n32 * n23,\n\t\t\tt12 = n32 * n13 - n33 * n12,\n\t\t\tt13 = n23 * n12 - n22 * n13,\n\n\t\t\tdet = n11 * t11 + n21 * t12 + n31 * t13;\n\n\t\tif ( det === 0 ) return this.set( 0, 0, 0, 0, 0, 0, 0, 0, 0 );\n\n\t\tconst detInv = 1 / det;\n\n\t\tte[ 0 ] = t11 * detInv;\n\t\tte[ 1 ] = ( n31 * n23 - n33 * n21 ) * detInv;\n\t\tte[ 2 ] = ( n32 * n21 - n31 * n22 ) * detInv;\n\n\t\tte[ 3 ] = t12 * detInv;\n\t\tte[ 4 ] = ( n33 * n11 - n31 * n13 ) * detInv;\n\t\tte[ 5 ] = ( n31 * n12 - n32 * n11 ) * detInv;\n\n\t\tte[ 6 ] = t13 * detInv;\n\t\tte[ 7 ] = ( n21 * n13 - n23 * n11 ) * detInv;\n\t\tte[ 8 ] = ( n22 * n11 - n21 * n12 ) * detInv;\n\n\t\treturn this;\n\n\t},\n\n\ttranspose: function () {\n\n\t\tlet tmp;\n\t\tconst m = this.elements;\n\n\t\ttmp = m[ 1 ]; m[ 1 ] = m[ 3 ]; m[ 3 ] = tmp;\n\t\ttmp = m[ 2 ]; m[ 2 ] = m[ 6 ]; m[ 6 ] = tmp;\n\t\ttmp = m[ 5 ]; m[ 5 ] = m[ 7 ]; m[ 7 ] = tmp;\n\n\t\treturn this;\n\n\t},\n\n\tgetNormalMatrix: function ( matrix4 ) {\n\n\t\treturn this.setFromMatrix4( matrix4 ).getInverse( this ).transpose();\n\n\t},\n\n\ttransposeIntoArray: function ( r ) {\n\n\t\tconst m = this.elements;\n\n\t\tr[ 0 ] = m[ 0 ];\n\t\tr[ 1 ] = m[ 3 ];\n\t\tr[ 2 ] = m[ 6 ];\n\t\tr[ 3 ] = m[ 1 ];\n\t\tr[ 4 ] = m[ 4 ];\n\t\tr[ 5 ] = m[ 7 ];\n\t\tr[ 6 ] = m[ 2 ];\n\t\tr[ 7 ] = m[ 5 ];\n\t\tr[ 8 ] = m[ 8 ];\n\n\t\treturn this;\n\n\t},\n\n\tsetUvTransform: function ( tx, ty, sx, sy, rotation, cx, cy ) {\n\n\t\tconst c = Math.cos( rotation );\n\t\tconst s = Math.sin( rotation );\n\n\t\tthis.set(\n\t\t\tsx * c, sx * s, - sx * ( c * cx + s * cy ) + cx + tx,\n\t\t\t- sy * s, sy * c, - sy * ( - s * cx + c * cy ) + cy + ty,\n\t\t\t0, 0, 1\n\t\t);\n\n\t},\n\n\tscale: function ( sx, sy ) {\n\n\t\tconst te = this.elements;\n\n\t\tte[ 0 ] *= sx; te[ 3 ] *= sx; te[ 6 ] *= sx;\n\t\tte[ 1 ] *= sy; te[ 4 ] *= sy; te[ 7 ] *= sy;\n\n\t\treturn this;\n\n\t},\n\n\trotate: function ( theta ) {\n\n\t\tconst c = Math.cos( theta );\n\t\tconst s = Math.sin( theta );\n\n\t\tconst te = this.elements;\n\n\t\tconst a11 = te[ 0 ], a12 = te[ 3 ], a13 = te[ 6 ];\n\t\tconst a21 = te[ 1 ], a22 = te[ 4 ], a23 = te[ 7 ];\n\n\t\tte[ 0 ] = c * a11 + s * a21;\n\t\tte[ 3 ] = c * a12 + s * a22;\n\t\tte[ 6 ] = c * a13 + s * a23;\n\n\t\tte[ 1 ] = - s * a11 + c * a21;\n\t\tte[ 4 ] = - s * a12 + c * a22;\n\t\tte[ 7 ] = - s * a13 + c * a23;\n\n\t\treturn this;\n\n\t},\n\n\ttranslate: function ( tx, ty ) {\n\n\t\tconst te = this.elements;\n\n\t\tte[ 0 ] += tx * te[ 2 ]; te[ 3 ] += tx * te[ 5 ]; te[ 6 ] += tx * te[ 8 ];\n\t\tte[ 1 ] += ty * te[ 2 ]; te[ 4 ] += ty * te[ 5 ]; te[ 7 ] += ty * te[ 8 ];\n\n\t\treturn this;\n\n\t},\n\n\tequals: function ( matrix ) {\n\n\t\tconst te = this.elements;\n\t\tconst me = matrix.elements;\n\n\t\tfor ( let i = 0; i < 9; i ++ ) {\n\n\t\t\tif ( te[ i ] !== me[ i ] ) return false;\n\n\t\t}\n\n\t\treturn true;\n\n\t},\n\n\tfromArray: function ( array, offset ) {\n\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tfor ( let i = 0; i < 9; i ++ ) {\n\n\t\t\tthis.elements[ i ] = array[ i + offset ];\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\ttoArray: function ( array, offset ) {\n\n\t\tif ( array === undefined ) array = [];\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tconst te = this.elements;\n\n\t\tarray[ offset ] = te[ 0 ];\n\t\tarray[ offset + 1 ] = te[ 1 ];\n\t\tarray[ offset + 2 ] = te[ 2 ];\n\n\t\tarray[ offset + 3 ] = te[ 3 ];\n\t\tarray[ offset + 4 ] = te[ 4 ];\n\t\tarray[ offset + 5 ] = te[ 5 ];\n\n\t\tarray[ offset + 6 ] = te[ 6 ];\n\t\tarray[ offset + 7 ] = te[ 7 ];\n\t\tarray[ offset + 8 ] = te[ 8 ];\n\n\t\treturn array;\n\n\t}\n\n} );\n\n\nexport { Matrix3 };\n","/**\n * @author mrdoob / http://mrdoob.com/\n * @author alteredq / http://alteredqualia.com/\n * @author szimek / https://github.com/szimek/\n */\n\nlet _canvas;\n\nconst ImageUtils = {\n\n\tgetDataURL: function ( image ) {\n\n\t\tif ( /^data:/i.test( image.src ) ) {\n\n\t\t\treturn image.src;\n\n\t\t}\n\n\t\tif ( typeof HTMLCanvasElement == 'undefined' ) {\n\n\t\t\treturn image.src;\n\n\t\t}\n\n\t\tlet canvas;\n\n\t\tif ( image instanceof HTMLCanvasElement ) {\n\n\t\t\tcanvas = image;\n\n\t\t} else {\n\n\t\t\tif ( _canvas === undefined ) _canvas = document.createElementNS( 'http://www.w3.org/1999/xhtml', 'canvas' );\n\n\t\t\t_canvas.width = image.width;\n\t\t\t_canvas.height = image.height;\n\n\t\t\tconst context = _canvas.getContext( '2d' );\n\n\t\t\tif ( image instanceof ImageData ) {\n\n\t\t\t\tcontext.putImageData( image, 0, 0 );\n\n\t\t\t} else {\n\n\t\t\t\tcontext.drawImage( image, 0, 0, image.width, image.height );\n\n\t\t\t}\n\n\t\t\tcanvas = _canvas;\n\n\t\t}\n\n\t\tif ( canvas.width > 2048 || canvas.height > 2048 ) {\n\n\t\t\treturn canvas.toDataURL( 'image/jpeg', 0.6 );\n\n\t\t} else {\n\n\t\t\treturn canvas.toDataURL( 'image/png' );\n\n\t\t}\n\n\t}\n\n};\n\nexport { ImageUtils };\n","/**\n * @author mrdoob / http://mrdoob.com/\n * @author alteredq / http://alteredqualia.com/\n * @author szimek / https://github.com/szimek/\n */\n\nimport { EventDispatcher } from '../core/EventDispatcher.js';\nimport {\n\tMirroredRepeatWrapping,\n\tClampToEdgeWrapping,\n\tRepeatWrapping,\n\tLinearEncoding,\n\tUnsignedByteType,\n\tRGBAFormat,\n\tLinearMipmapLinearFilter,\n\tLinearFilter,\n\tUVMapping\n} from '../constants.js';\nimport { MathUtils } from '../math/MathUtils.js';\nimport { Vector2 } from '../math/Vector2.js';\nimport { Matrix3 } from '../math/Matrix3.js';\nimport { ImageUtils } from '../extras/ImageUtils.js';\n\nlet textureId = 0;\n\nfunction Texture( image, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ) {\n\n\tObject.defineProperty( this, 'id', { value: textureId ++ } );\n\n\tthis.uuid = MathUtils.generateUUID();\n\n\tthis.name = '';\n\n\tthis.image = image !== undefined ? image : Texture.DEFAULT_IMAGE;\n\tthis.mipmaps = [];\n\n\tthis.mapping = mapping !== undefined ? mapping : Texture.DEFAULT_MAPPING;\n\n\tthis.wrapS = wrapS !== undefined ? wrapS : ClampToEdgeWrapping;\n\tthis.wrapT = wrapT !== undefined ? wrapT : ClampToEdgeWrapping;\n\n\tthis.magFilter = magFilter !== undefined ? magFilter : LinearFilter;\n\tthis.minFilter = minFilter !== undefined ? minFilter : LinearMipmapLinearFilter;\n\n\tthis.anisotropy = anisotropy !== undefined ? anisotropy : 1;\n\n\tthis.format = format !== undefined ? format : RGBAFormat;\n\tthis.internalFormat = null;\n\tthis.type = type !== undefined ? type : UnsignedByteType;\n\n\tthis.offset = new Vector2( 0, 0 );\n\tthis.repeat = new Vector2( 1, 1 );\n\tthis.center = new Vector2( 0, 0 );\n\tthis.rotation = 0;\n\n\tthis.matrixAutoUpdate = true;\n\tthis.matrix = new Matrix3();\n\n\tthis.generateMipmaps = true;\n\tthis.premultiplyAlpha = false;\n\tthis.flipY = true;\n\tthis.unpackAlignment = 4;\t// valid values: 1, 2, 4, 8 (see http://www.khronos.org/opengles/sdk/docs/man/xhtml/glPixelStorei.xml)\n\n\t// Values of encoding !== THREE.LinearEncoding only supported on map, envMap and emissiveMap.\n\t//\n\t// Also changing the encoding after already used by a Material will not automatically make the Material\n\t// update. You need to explicitly call Material.needsUpdate to trigger it to recompile.\n\tthis.encoding = encoding !== undefined ? encoding : LinearEncoding;\n\n\tthis.version = 0;\n\tthis.onUpdate = null;\n\n}\n\nTexture.DEFAULT_IMAGE = undefined;\nTexture.DEFAULT_MAPPING = UVMapping;\n\nTexture.prototype = Object.assign( Object.create( EventDispatcher.prototype ), {\n\n\tconstructor: Texture,\n\n\tisTexture: true,\n\n\tupdateMatrix: function () {\n\n\t\tthis.matrix.setUvTransform( this.offset.x, this.offset.y, this.repeat.x, this.repeat.y, this.rotation, this.center.x, this.center.y );\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor().copy( this );\n\n\t},\n\n\tcopy: function ( source ) {\n\n\t\tthis.name = source.name;\n\n\t\tthis.image = source.image;\n\t\tthis.mipmaps = source.mipmaps.slice( 0 );\n\n\t\tthis.mapping = source.mapping;\n\n\t\tthis.wrapS = source.wrapS;\n\t\tthis.wrapT = source.wrapT;\n\n\t\tthis.magFilter = source.magFilter;\n\t\tthis.minFilter = source.minFilter;\n\n\t\tthis.anisotropy = source.anisotropy;\n\n\t\tthis.format = source.format;\n\t\tthis.internalFormat = source.internalFormat;\n\t\tthis.type = source.type;\n\n\t\tthis.offset.copy( source.offset );\n\t\tthis.repeat.copy( source.repeat );\n\t\tthis.center.copy( source.center );\n\t\tthis.rotation = source.rotation;\n\n\t\tthis.matrixAutoUpdate = source.matrixAutoUpdate;\n\t\tthis.matrix.copy( source.matrix );\n\n\t\tthis.generateMipmaps = source.generateMipmaps;\n\t\tthis.premultiplyAlpha = source.premultiplyAlpha;\n\t\tthis.flipY = source.flipY;\n\t\tthis.unpackAlignment = source.unpackAlignment;\n\t\tthis.encoding = source.encoding;\n\n\t\treturn this;\n\n\t},\n\n\ttoJSON: function ( meta ) {\n\n\t\tconst isRootObject = ( meta === undefined || typeof meta === 'string' );\n\n\t\tif ( ! isRootObject && meta.textures[ this.uuid ] !== undefined ) {\n\n\t\t\treturn meta.textures[ this.uuid ];\n\n\t\t}\n\n\t\tconst output = {\n\n\t\t\tmetadata: {\n\t\t\t\tversion: 4.5,\n\t\t\t\ttype: 'Texture',\n\t\t\t\tgenerator: 'Texture.toJSON'\n\t\t\t},\n\n\t\t\tuuid: this.uuid,\n\t\t\tname: this.name,\n\n\t\t\tmapping: this.mapping,\n\n\t\t\trepeat: [ this.repeat.x, this.repeat.y ],\n\t\t\toffset: [ this.offset.x, this.offset.y ],\n\t\t\tcenter: [ this.center.x, this.center.y ],\n\t\t\trotation: this.rotation,\n\n\t\t\twrap: [ this.wrapS, this.wrapT ],\n\n\t\t\tformat: this.format,\n\t\t\ttype: this.type,\n\t\t\tencoding: this.encoding,\n\n\t\t\tminFilter: this.minFilter,\n\t\t\tmagFilter: this.magFilter,\n\t\t\tanisotropy: this.anisotropy,\n\n\t\t\tflipY: this.flipY,\n\n\t\t\tpremultiplyAlpha: this.premultiplyAlpha,\n\t\t\tunpackAlignment: this.unpackAlignment\n\n\t\t};\n\n\t\tif ( this.image !== undefined ) {\n\n\t\t\t// TODO: Move to THREE.Image\n\n\t\t\tconst image = this.image;\n\n\t\t\tif ( image.uuid === undefined ) {\n\n\t\t\t\timage.uuid = MathUtils.generateUUID(); // UGH\n\n\t\t\t}\n\n\t\t\tif ( ! isRootObject && meta.images[ image.uuid ] === undefined ) {\n\n\t\t\t\tlet url;\n\n\t\t\t\tif ( Array.isArray( image ) ) {\n\n\t\t\t\t\t// process array of images e.g. CubeTexture\n\n\t\t\t\t\turl = [];\n\n\t\t\t\t\tfor ( let i = 0, l = image.length; i < l; i ++ ) {\n\n\t\t\t\t\t\turl.push( ImageUtils.getDataURL( image[ i ] ) );\n\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\n\t\t\t\t\t// process single image\n\n\t\t\t\t\turl = ImageUtils.getDataURL( image );\n\n\t\t\t\t}\n\n\t\t\t\tmeta.images[ image.uuid ] = {\n\t\t\t\t\tuuid: image.uuid,\n\t\t\t\t\turl: url\n\t\t\t\t};\n\n\t\t\t}\n\n\t\t\toutput.image = image.uuid;\n\n\t\t}\n\n\t\tif ( ! isRootObject ) {\n\n\t\t\tmeta.textures[ this.uuid ] = output;\n\n\t\t}\n\n\t\treturn output;\n\n\t},\n\n\tdispose: function () {\n\n\t\tthis.dispatchEvent( { type: 'dispose' } );\n\n\t},\n\n\ttransformUv: function ( uv ) {\n\n\t\tif ( this.mapping !== UVMapping ) return uv;\n\n\t\tuv.applyMatrix3( this.matrix );\n\n\t\tif ( uv.x < 0 || uv.x > 1 ) {\n\n\t\t\tswitch ( this.wrapS ) {\n\n\t\t\t\tcase RepeatWrapping:\n\n\t\t\t\t\tuv.x = uv.x - Math.floor( uv.x );\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase ClampToEdgeWrapping:\n\n\t\t\t\t\tuv.x = uv.x < 0 ? 0 : 1;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase MirroredRepeatWrapping:\n\n\t\t\t\t\tif ( Math.abs( Math.floor( uv.x ) % 2 ) === 1 ) {\n\n\t\t\t\t\t\tuv.x = Math.ceil( uv.x ) - uv.x;\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tuv.x = uv.x - Math.floor( uv.x );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( uv.y < 0 || uv.y > 1 ) {\n\n\t\t\tswitch ( this.wrapT ) {\n\n\t\t\t\tcase RepeatWrapping:\n\n\t\t\t\t\tuv.y = uv.y - Math.floor( uv.y );\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase ClampToEdgeWrapping:\n\n\t\t\t\t\tuv.y = uv.y < 0 ? 0 : 1;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase MirroredRepeatWrapping:\n\n\t\t\t\t\tif ( Math.abs( Math.floor( uv.y ) % 2 ) === 1 ) {\n\n\t\t\t\t\t\tuv.y = Math.ceil( uv.y ) - uv.y;\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tuv.y = uv.y - Math.floor( uv.y );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( this.flipY ) {\n\n\t\t\tuv.y = 1 - uv.y;\n\n\t\t}\n\n\t\treturn uv;\n\n\t}\n\n} );\n\nObject.defineProperty( Texture.prototype, \"needsUpdate\", {\n\n\tset: function ( value ) {\n\n\t\tif ( value === true ) this.version ++;\n\n\t}\n\n} );\n\n\nexport { Texture };\n","/**\n * @author supereggbert / http://www.paulbrunt.co.uk/\n * @author philogb / http://blog.thejit.org/\n * @author mikael emtinger / http://gomo.se/\n * @author egraether / http://egraether.com/\n * @author WestLangley / http://github.com/WestLangley\n */\n\nfunction Vector4( x = 0, y = 0, z = 0, w = 1 ) {\n\n\tthis.x = x;\n\tthis.y = y;\n\tthis.z = z;\n\tthis.w = w;\n\n}\n\nObject.defineProperties( Vector4.prototype, {\n\n\t\"width\": {\n\n\t\tget: function () {\n\n\t\t\treturn this.z;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tthis.z = value;\n\n\t\t}\n\n\t},\n\n\t\"height\": {\n\n\t\tget: function () {\n\n\t\t\treturn this.w;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tthis.w = value;\n\n\t\t}\n\n\t}\n\n} );\n\nObject.assign( Vector4.prototype, {\n\n\tisVector4: true,\n\n\tset: function ( x, y, z, w ) {\n\n\t\tthis.x = x;\n\t\tthis.y = y;\n\t\tthis.z = z;\n\t\tthis.w = w;\n\n\t\treturn this;\n\n\t},\n\n\tsetScalar: function ( scalar ) {\n\n\t\tthis.x = scalar;\n\t\tthis.y = scalar;\n\t\tthis.z = scalar;\n\t\tthis.w = scalar;\n\n\t\treturn this;\n\n\t},\n\n\tsetX: function ( x ) {\n\n\t\tthis.x = x;\n\n\t\treturn this;\n\n\t},\n\n\tsetY: function ( y ) {\n\n\t\tthis.y = y;\n\n\t\treturn this;\n\n\t},\n\n\tsetZ: function ( z ) {\n\n\t\tthis.z = z;\n\n\t\treturn this;\n\n\t},\n\n\tsetW: function ( w ) {\n\n\t\tthis.w = w;\n\n\t\treturn this;\n\n\t},\n\n\tsetComponent: function ( index, value ) {\n\n\t\tswitch ( index ) {\n\n\t\t\tcase 0: this.x = value; break;\n\t\t\tcase 1: this.y = value; break;\n\t\t\tcase 2: this.z = value; break;\n\t\t\tcase 3: this.w = value; break;\n\t\t\tdefault: throw new Error( 'index is out of range: ' + index );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tgetComponent: function ( index ) {\n\n\t\tswitch ( index ) {\n\n\t\t\tcase 0: return this.x;\n\t\t\tcase 1: return this.y;\n\t\t\tcase 2: return this.z;\n\t\t\tcase 3: return this.w;\n\t\t\tdefault: throw new Error( 'index is out of range: ' + index );\n\n\t\t}\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor( this.x, this.y, this.z, this.w );\n\n\t},\n\n\tcopy: function ( v ) {\n\n\t\tthis.x = v.x;\n\t\tthis.y = v.y;\n\t\tthis.z = v.z;\n\t\tthis.w = ( v.w !== undefined ) ? v.w : 1;\n\n\t\treturn this;\n\n\t},\n\n\tadd: function ( v, w ) {\n\n\t\tif ( w !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead.' );\n\t\t\treturn this.addVectors( v, w );\n\n\t\t}\n\n\t\tthis.x += v.x;\n\t\tthis.y += v.y;\n\t\tthis.z += v.z;\n\t\tthis.w += v.w;\n\n\t\treturn this;\n\n\t},\n\n\taddScalar: function ( s ) {\n\n\t\tthis.x += s;\n\t\tthis.y += s;\n\t\tthis.z += s;\n\t\tthis.w += s;\n\n\t\treturn this;\n\n\t},\n\n\taddVectors: function ( a, b ) {\n\n\t\tthis.x = a.x + b.x;\n\t\tthis.y = a.y + b.y;\n\t\tthis.z = a.z + b.z;\n\t\tthis.w = a.w + b.w;\n\n\t\treturn this;\n\n\t},\n\n\taddScaledVector: function ( v, s ) {\n\n\t\tthis.x += v.x * s;\n\t\tthis.y += v.y * s;\n\t\tthis.z += v.z * s;\n\t\tthis.w += v.w * s;\n\n\t\treturn this;\n\n\t},\n\n\tsub: function ( v, w ) {\n\n\t\tif ( w !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.' );\n\t\t\treturn this.subVectors( v, w );\n\n\t\t}\n\n\t\tthis.x -= v.x;\n\t\tthis.y -= v.y;\n\t\tthis.z -= v.z;\n\t\tthis.w -= v.w;\n\n\t\treturn this;\n\n\t},\n\n\tsubScalar: function ( s ) {\n\n\t\tthis.x -= s;\n\t\tthis.y -= s;\n\t\tthis.z -= s;\n\t\tthis.w -= s;\n\n\t\treturn this;\n\n\t},\n\n\tsubVectors: function ( a, b ) {\n\n\t\tthis.x = a.x - b.x;\n\t\tthis.y = a.y - b.y;\n\t\tthis.z = a.z - b.z;\n\t\tthis.w = a.w - b.w;\n\n\t\treturn this;\n\n\t},\n\n\tmultiplyScalar: function ( scalar ) {\n\n\t\tthis.x *= scalar;\n\t\tthis.y *= scalar;\n\t\tthis.z *= scalar;\n\t\tthis.w *= scalar;\n\n\t\treturn this;\n\n\t},\n\n\tapplyMatrix4: function ( m ) {\n\n\t\tconst x = this.x, y = this.y, z = this.z, w = this.w;\n\t\tconst e = m.elements;\n\n\t\tthis.x = e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z + e[ 12 ] * w;\n\t\tthis.y = e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z + e[ 13 ] * w;\n\t\tthis.z = e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z + e[ 14 ] * w;\n\t\tthis.w = e[ 3 ] * x + e[ 7 ] * y + e[ 11 ] * z + e[ 15 ] * w;\n\n\t\treturn this;\n\n\t},\n\n\tdivideScalar: function ( scalar ) {\n\n\t\treturn this.multiplyScalar( 1 / scalar );\n\n\t},\n\n\tsetAxisAngleFromQuaternion: function ( q ) {\n\n\t\t// http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToAngle/index.htm\n\n\t\t// q is assumed to be normalized\n\n\t\tthis.w = 2 * Math.acos( q.w );\n\n\t\tconst s = Math.sqrt( 1 - q.w * q.w );\n\n\t\tif ( s < 0.0001 ) {\n\n\t\t\tthis.x = 1;\n\t\t\tthis.y = 0;\n\t\t\tthis.z = 0;\n\n\t\t} else {\n\n\t\t\tthis.x = q.x / s;\n\t\t\tthis.y = q.y / s;\n\t\t\tthis.z = q.z / s;\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tsetAxisAngleFromRotationMatrix: function ( m ) {\n\n\t\t// http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToAngle/index.htm\n\n\t\t// assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)\n\n\t\tlet angle, x, y, z; // variables for result\n\t\tconst epsilon = 0.01,\t\t// margin to allow for rounding errors\n\t\t\tepsilon2 = 0.1,\t\t// margin to distinguish between 0 and 180 degrees\n\n\t\t\tte = m.elements,\n\n\t\t\tm11 = te[ 0 ], m12 = te[ 4 ], m13 = te[ 8 ],\n\t\t\tm21 = te[ 1 ], m22 = te[ 5 ], m23 = te[ 9 ],\n\t\t\tm31 = te[ 2 ], m32 = te[ 6 ], m33 = te[ 10 ];\n\n\t\tif ( ( Math.abs( m12 - m21 ) < epsilon ) &&\n\t\t ( Math.abs( m13 - m31 ) < epsilon ) &&\n\t\t ( Math.abs( m23 - m32 ) < epsilon ) ) {\n\n\t\t\t// singularity found\n\t\t\t// first check for identity matrix which must have +1 for all terms\n\t\t\t// in leading diagonal and zero in other terms\n\n\t\t\tif ( ( Math.abs( m12 + m21 ) < epsilon2 ) &&\n\t\t\t ( Math.abs( m13 + m31 ) < epsilon2 ) &&\n\t\t\t ( Math.abs( m23 + m32 ) < epsilon2 ) &&\n\t\t\t ( Math.abs( m11 + m22 + m33 - 3 ) < epsilon2 ) ) {\n\n\t\t\t\t// this singularity is identity matrix so angle = 0\n\n\t\t\t\tthis.set( 1, 0, 0, 0 );\n\n\t\t\t\treturn this; // zero angle, arbitrary axis\n\n\t\t\t}\n\n\t\t\t// otherwise this singularity is angle = 180\n\n\t\t\tangle = Math.PI;\n\n\t\t\tconst xx = ( m11 + 1 ) / 2;\n\t\t\tconst yy = ( m22 + 1 ) / 2;\n\t\t\tconst zz = ( m33 + 1 ) / 2;\n\t\t\tconst xy = ( m12 + m21 ) / 4;\n\t\t\tconst xz = ( m13 + m31 ) / 4;\n\t\t\tconst yz = ( m23 + m32 ) / 4;\n\n\t\t\tif ( ( xx > yy ) && ( xx > zz ) ) {\n\n\t\t\t\t// m11 is the largest diagonal term\n\n\t\t\t\tif ( xx < epsilon ) {\n\n\t\t\t\t\tx = 0;\n\t\t\t\t\ty = 0.707106781;\n\t\t\t\t\tz = 0.707106781;\n\n\t\t\t\t} else {\n\n\t\t\t\t\tx = Math.sqrt( xx );\n\t\t\t\t\ty = xy / x;\n\t\t\t\t\tz = xz / x;\n\n\t\t\t\t}\n\n\t\t\t} else if ( yy > zz ) {\n\n\t\t\t\t// m22 is the largest diagonal term\n\n\t\t\t\tif ( yy < epsilon ) {\n\n\t\t\t\t\tx = 0.707106781;\n\t\t\t\t\ty = 0;\n\t\t\t\t\tz = 0.707106781;\n\n\t\t\t\t} else {\n\n\t\t\t\t\ty = Math.sqrt( yy );\n\t\t\t\t\tx = xy / y;\n\t\t\t\t\tz = yz / y;\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\t// m33 is the largest diagonal term so base result on this\n\n\t\t\t\tif ( zz < epsilon ) {\n\n\t\t\t\t\tx = 0.707106781;\n\t\t\t\t\ty = 0.707106781;\n\t\t\t\t\tz = 0;\n\n\t\t\t\t} else {\n\n\t\t\t\t\tz = Math.sqrt( zz );\n\t\t\t\t\tx = xz / z;\n\t\t\t\t\ty = yz / z;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tthis.set( x, y, z, angle );\n\n\t\t\treturn this; // return 180 deg rotation\n\n\t\t}\n\n\t\t// as we have reached here there are no singularities so we can handle normally\n\n\t\tlet s = Math.sqrt( ( m32 - m23 ) * ( m32 - m23 ) +\n\t\t\t( m13 - m31 ) * ( m13 - m31 ) +\n\t\t\t( m21 - m12 ) * ( m21 - m12 ) ); // used to normalize\n\n\t\tif ( Math.abs( s ) < 0.001 ) s = 1;\n\n\t\t// prevent divide by zero, should not happen if matrix is orthogonal and should be\n\t\t// caught by singularity test above, but I've left it in just in case\n\n\t\tthis.x = ( m32 - m23 ) / s;\n\t\tthis.y = ( m13 - m31 ) / s;\n\t\tthis.z = ( m21 - m12 ) / s;\n\t\tthis.w = Math.acos( ( m11 + m22 + m33 - 1 ) / 2 );\n\n\t\treturn this;\n\n\t},\n\n\tmin: function ( v ) {\n\n\t\tthis.x = Math.min( this.x, v.x );\n\t\tthis.y = Math.min( this.y, v.y );\n\t\tthis.z = Math.min( this.z, v.z );\n\t\tthis.w = Math.min( this.w, v.w );\n\n\t\treturn this;\n\n\t},\n\n\tmax: function ( v ) {\n\n\t\tthis.x = Math.max( this.x, v.x );\n\t\tthis.y = Math.max( this.y, v.y );\n\t\tthis.z = Math.max( this.z, v.z );\n\t\tthis.w = Math.max( this.w, v.w );\n\n\t\treturn this;\n\n\t},\n\n\tclamp: function ( min, max ) {\n\n\t\t// assumes min < max, componentwise\n\n\t\tthis.x = Math.max( min.x, Math.min( max.x, this.x ) );\n\t\tthis.y = Math.max( min.y, Math.min( max.y, this.y ) );\n\t\tthis.z = Math.max( min.z, Math.min( max.z, this.z ) );\n\t\tthis.w = Math.max( min.w, Math.min( max.w, this.w ) );\n\n\t\treturn this;\n\n\t},\n\n\tclampScalar: function ( minVal, maxVal ) {\n\n\t\tthis.x = Math.max( minVal, Math.min( maxVal, this.x ) );\n\t\tthis.y = Math.max( minVal, Math.min( maxVal, this.y ) );\n\t\tthis.z = Math.max( minVal, Math.min( maxVal, this.z ) );\n\t\tthis.w = Math.max( minVal, Math.min( maxVal, this.w ) );\n\n\t\treturn this;\n\n\t},\n\n\tclampLength: function ( min, max ) {\n\n\t\tconst length = this.length();\n\n\t\treturn this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) );\n\n\t},\n\n\tfloor: function () {\n\n\t\tthis.x = Math.floor( this.x );\n\t\tthis.y = Math.floor( this.y );\n\t\tthis.z = Math.floor( this.z );\n\t\tthis.w = Math.floor( this.w );\n\n\t\treturn this;\n\n\t},\n\n\tceil: function () {\n\n\t\tthis.x = Math.ceil( this.x );\n\t\tthis.y = Math.ceil( this.y );\n\t\tthis.z = Math.ceil( this.z );\n\t\tthis.w = Math.ceil( this.w );\n\n\t\treturn this;\n\n\t},\n\n\tround: function () {\n\n\t\tthis.x = Math.round( this.x );\n\t\tthis.y = Math.round( this.y );\n\t\tthis.z = Math.round( this.z );\n\t\tthis.w = Math.round( this.w );\n\n\t\treturn this;\n\n\t},\n\n\troundToZero: function () {\n\n\t\tthis.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x );\n\t\tthis.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y );\n\t\tthis.z = ( this.z < 0 ) ? Math.ceil( this.z ) : Math.floor( this.z );\n\t\tthis.w = ( this.w < 0 ) ? Math.ceil( this.w ) : Math.floor( this.w );\n\n\t\treturn this;\n\n\t},\n\n\tnegate: function () {\n\n\t\tthis.x = - this.x;\n\t\tthis.y = - this.y;\n\t\tthis.z = - this.z;\n\t\tthis.w = - this.w;\n\n\t\treturn this;\n\n\t},\n\n\tdot: function ( v ) {\n\n\t\treturn this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w;\n\n\t},\n\n\tlengthSq: function () {\n\n\t\treturn this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w;\n\n\t},\n\n\tlength: function () {\n\n\t\treturn Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w );\n\n\t},\n\n\tmanhattanLength: function () {\n\n\t\treturn Math.abs( this.x ) + Math.abs( this.y ) + Math.abs( this.z ) + Math.abs( this.w );\n\n\t},\n\n\tnormalize: function () {\n\n\t\treturn this.divideScalar( this.length() || 1 );\n\n\t},\n\n\tsetLength: function ( length ) {\n\n\t\treturn this.normalize().multiplyScalar( length );\n\n\t},\n\n\tlerp: function ( v, alpha ) {\n\n\t\tthis.x += ( v.x - this.x ) * alpha;\n\t\tthis.y += ( v.y - this.y ) * alpha;\n\t\tthis.z += ( v.z - this.z ) * alpha;\n\t\tthis.w += ( v.w - this.w ) * alpha;\n\n\t\treturn this;\n\n\t},\n\n\tlerpVectors: function ( v1, v2, alpha ) {\n\n\t\tthis.x = v1.x + ( v2.x - v1.x ) * alpha;\n\t\tthis.y = v1.y + ( v2.y - v1.y ) * alpha;\n\t\tthis.z = v1.z + ( v2.z - v1.z ) * alpha;\n\t\tthis.w = v1.w + ( v2.w - v1.w ) * alpha;\n\n\t\treturn this;\n\n\t},\n\n\tequals: function ( v ) {\n\n\t\treturn ( ( v.x === this.x ) && ( v.y === this.y ) && ( v.z === this.z ) && ( v.w === this.w ) );\n\n\t},\n\n\tfromArray: function ( array, offset ) {\n\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tthis.x = array[ offset ];\n\t\tthis.y = array[ offset + 1 ];\n\t\tthis.z = array[ offset + 2 ];\n\t\tthis.w = array[ offset + 3 ];\n\n\t\treturn this;\n\n\t},\n\n\ttoArray: function ( array, offset ) {\n\n\t\tif ( array === undefined ) array = [];\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tarray[ offset ] = this.x;\n\t\tarray[ offset + 1 ] = this.y;\n\t\tarray[ offset + 2 ] = this.z;\n\t\tarray[ offset + 3 ] = this.w;\n\n\t\treturn array;\n\n\t},\n\n\tfromBufferAttribute: function ( attribute, index, offset ) {\n\n\t\tif ( offset !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Vector4: offset has been removed from .fromBufferAttribute().' );\n\n\t\t}\n\n\t\tthis.x = attribute.getX( index );\n\t\tthis.y = attribute.getY( index );\n\t\tthis.z = attribute.getZ( index );\n\t\tthis.w = attribute.getW( index );\n\n\t\treturn this;\n\n\t},\n\n\trandom: function () {\n\n\t\tthis.x = Math.random();\n\t\tthis.y = Math.random();\n\t\tthis.z = Math.random();\n\t\tthis.w = Math.random();\n\n\t\treturn this;\n\n\t}\n\n} );\n\n\nexport { Vector4 };\n","import { EventDispatcher } from '../core/EventDispatcher.js';\nimport { Texture } from '../textures/Texture.js';\nimport { LinearFilter } from '../constants.js';\nimport { Vector4 } from '../math/Vector4.js';\n\n/**\n * @author szimek / https://github.com/szimek/\n * @author alteredq / http://alteredqualia.com/\n * @author Marius Kintel / https://github.com/kintel\n */\n\n/*\n In options, we can specify:\n * Texture parameters for an auto-generated target texture\n * depthBuffer/stencilBuffer: Booleans to indicate if we should generate these buffers\n*/\nfunction WebGLRenderTarget( width, height, options ) {\n\n\tthis.width = width;\n\tthis.height = height;\n\n\tthis.scissor = new Vector4( 0, 0, width, height );\n\tthis.scissorTest = false;\n\n\tthis.viewport = new Vector4( 0, 0, width, height );\n\n\toptions = options || {};\n\n\tthis.texture = new Texture( undefined, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.encoding );\n\n\tthis.texture.image = {};\n\tthis.texture.image.width = width;\n\tthis.texture.image.height = height;\n\n\tthis.texture.generateMipmaps = options.generateMipmaps !== undefined ? options.generateMipmaps : false;\n\tthis.texture.minFilter = options.minFilter !== undefined ? options.minFilter : LinearFilter;\n\n\tthis.depthBuffer = options.depthBuffer !== undefined ? options.depthBuffer : true;\n\tthis.stencilBuffer = options.stencilBuffer !== undefined ? options.stencilBuffer : true;\n\tthis.depthTexture = options.depthTexture !== undefined ? options.depthTexture : null;\n\n}\n\nWebGLRenderTarget.prototype = Object.assign( Object.create( EventDispatcher.prototype ), {\n\n\tconstructor: WebGLRenderTarget,\n\n\tisWebGLRenderTarget: true,\n\n\tsetSize: function ( width, height ) {\n\n\t\tif ( this.width !== width || this.height !== height ) {\n\n\t\t\tthis.width = width;\n\t\t\tthis.height = height;\n\n\t\t\tthis.texture.image.width = width;\n\t\t\tthis.texture.image.height = height;\n\n\t\t\tthis.dispose();\n\n\t\t}\n\n\t\tthis.viewport.set( 0, 0, width, height );\n\t\tthis.scissor.set( 0, 0, width, height );\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor().copy( this );\n\n\t},\n\n\tcopy: function ( source ) {\n\n\t\tthis.width = source.width;\n\t\tthis.height = source.height;\n\n\t\tthis.viewport.copy( source.viewport );\n\n\t\tthis.texture = source.texture.clone();\n\n\t\tthis.depthBuffer = source.depthBuffer;\n\t\tthis.stencilBuffer = source.stencilBuffer;\n\t\tthis.depthTexture = source.depthTexture;\n\n\t\treturn this;\n\n\t},\n\n\tdispose: function () {\n\n\t\tthis.dispatchEvent( { type: 'dispose' } );\n\n\t}\n\n} );\n\n\nexport { WebGLRenderTarget };\n","/**\n * @author mikael emtinger / http://gomo.se/\n * @author alteredq / http://alteredqualia.com/\n * @author WestLangley / http://github.com/WestLangley\n * @author bhouston / http://clara.io\n */\n\nimport { MathUtils } from './MathUtils.js';\n\nfunction Quaternion( x = 0, y = 0, z = 0, w = 1 ) {\n\n\tthis._x = x;\n\tthis._y = y;\n\tthis._z = z;\n\tthis._w = w;\n\n}\n\nObject.assign( Quaternion, {\n\n\tslerp: function ( qa, qb, qm, t ) {\n\n\t\treturn qm.copy( qa ).slerp( qb, t );\n\n\t},\n\n\tslerpFlat: function ( dst, dstOffset, src0, srcOffset0, src1, srcOffset1, t ) {\n\n\t\t// fuzz-free, array-based Quaternion SLERP operation\n\n\t\tlet x0 = src0[ srcOffset0 + 0 ],\n\t\t\ty0 = src0[ srcOffset0 + 1 ],\n\t\t\tz0 = src0[ srcOffset0 + 2 ],\n\t\t\tw0 = src0[ srcOffset0 + 3 ];\n\n\t\tconst x1 = src1[ srcOffset1 + 0 ],\n\t\t\ty1 = src1[ srcOffset1 + 1 ],\n\t\t\tz1 = src1[ srcOffset1 + 2 ],\n\t\t\tw1 = src1[ srcOffset1 + 3 ];\n\n\t\tif ( w0 !== w1 || x0 !== x1 || y0 !== y1 || z0 !== z1 ) {\n\n\t\t\tlet s = 1 - t,\n\n\t\t\t\tcos = x0 * x1 + y0 * y1 + z0 * z1 + w0 * w1,\n\n\t\t\t\tdir = ( cos >= 0 ? 1 : - 1 ),\n\t\t\t\tsqrSin = 1 - cos * cos;\n\n\t\t\t// Skip the Slerp for tiny steps to avoid numeric problems:\n\t\t\tif ( sqrSin > Number.EPSILON ) {\n\n\t\t\t\tconst sin = Math.sqrt( sqrSin ),\n\t\t\t\t\tlen = Math.atan2( sin, cos * dir );\n\n\t\t\t\ts = Math.sin( s * len ) / sin;\n\t\t\t\tt = Math.sin( t * len ) / sin;\n\n\t\t\t}\n\n\t\t\tconst tDir = t * dir;\n\n\t\t\tx0 = x0 * s + x1 * tDir;\n\t\t\ty0 = y0 * s + y1 * tDir;\n\t\t\tz0 = z0 * s + z1 * tDir;\n\t\t\tw0 = w0 * s + w1 * tDir;\n\n\t\t\t// Normalize in case we just did a lerp:\n\t\t\tif ( s === 1 - t ) {\n\n\t\t\t\tconst f = 1 / Math.sqrt( x0 * x0 + y0 * y0 + z0 * z0 + w0 * w0 );\n\n\t\t\t\tx0 *= f;\n\t\t\t\ty0 *= f;\n\t\t\t\tz0 *= f;\n\t\t\t\tw0 *= f;\n\n\t\t\t}\n\n\t\t}\n\n\t\tdst[ dstOffset ] = x0;\n\t\tdst[ dstOffset + 1 ] = y0;\n\t\tdst[ dstOffset + 2 ] = z0;\n\t\tdst[ dstOffset + 3 ] = w0;\n\n\t},\n\n\tmultiplyQuaternionsFlat: function ( dst, dstOffset, src0, srcOffset0, src1, srcOffset1 ) {\n\n\t\tconst x0 = src0[ srcOffset0 ];\n\t\tconst y0 = src0[ srcOffset0 + 1 ];\n\t\tconst z0 = src0[ srcOffset0 + 2 ];\n\t\tconst w0 = src0[ srcOffset0 + 3 ];\n\n\t\tconst x1 = src1[ srcOffset1 ];\n\t\tconst y1 = src1[ srcOffset1 + 1 ];\n\t\tconst z1 = src1[ srcOffset1 + 2 ];\n\t\tconst w1 = src1[ srcOffset1 + 3 ];\n\n\t\tdst[ dstOffset ] = x0 * w1 + w0 * x1 + y0 * z1 - z0 * y1;\n\t\tdst[ dstOffset + 1 ] = y0 * w1 + w0 * y1 + z0 * x1 - x0 * z1;\n\t\tdst[ dstOffset + 2 ] = z0 * w1 + w0 * z1 + x0 * y1 - y0 * x1;\n\t\tdst[ dstOffset + 3 ] = w0 * w1 - x0 * x1 - y0 * y1 - z0 * z1;\n\n\t\treturn dst;\n\n\t}\n\n} );\n\nObject.defineProperties( Quaternion.prototype, {\n\n\tx: {\n\n\t\tget: function () {\n\n\t\t\treturn this._x;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tthis._x = value;\n\t\t\tthis._onChangeCallback();\n\n\t\t}\n\n\t},\n\n\ty: {\n\n\t\tget: function () {\n\n\t\t\treturn this._y;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tthis._y = value;\n\t\t\tthis._onChangeCallback();\n\n\t\t}\n\n\t},\n\n\tz: {\n\n\t\tget: function () {\n\n\t\t\treturn this._z;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tthis._z = value;\n\t\t\tthis._onChangeCallback();\n\n\t\t}\n\n\t},\n\n\tw: {\n\n\t\tget: function () {\n\n\t\t\treturn this._w;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tthis._w = value;\n\t\t\tthis._onChangeCallback();\n\n\t\t}\n\n\t}\n\n} );\n\nObject.assign( Quaternion.prototype, {\n\n\tisQuaternion: true,\n\n\tset: function ( x, y, z, w ) {\n\n\t\tthis._x = x;\n\t\tthis._y = y;\n\t\tthis._z = z;\n\t\tthis._w = w;\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor( this._x, this._y, this._z, this._w );\n\n\t},\n\n\tcopy: function ( quaternion ) {\n\n\t\tthis._x = quaternion.x;\n\t\tthis._y = quaternion.y;\n\t\tthis._z = quaternion.z;\n\t\tthis._w = quaternion.w;\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\tsetFromEuler: function ( euler, update ) {\n\n\t\tif ( ! ( euler && euler.isEuler ) ) {\n\n\t\t\tthrow new Error( 'THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.' );\n\n\t\t}\n\n\t\tconst x = euler._x, y = euler._y, z = euler._z, order = euler.order;\n\n\t\t// http://www.mathworks.com/matlabcentral/fileexchange/\n\t\t// \t20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors/\n\t\t//\tcontent/SpinCalc.m\n\n\t\tconst cos = Math.cos;\n\t\tconst sin = Math.sin;\n\n\t\tconst c1 = cos( x / 2 );\n\t\tconst c2 = cos( y / 2 );\n\t\tconst c3 = cos( z / 2 );\n\n\t\tconst s1 = sin( x / 2 );\n\t\tconst s2 = sin( y / 2 );\n\t\tconst s3 = sin( z / 2 );\n\n\t\tswitch ( order ) {\n\n\t\t\tcase 'XYZ':\n\t\t\t\tthis._x = s1 * c2 * c3 + c1 * s2 * s3;\n\t\t\t\tthis._y = c1 * s2 * c3 - s1 * c2 * s3;\n\t\t\t\tthis._z = c1 * c2 * s3 + s1 * s2 * c3;\n\t\t\t\tthis._w = c1 * c2 * c3 - s1 * s2 * s3;\n\t\t\t\tbreak;\n\n\t\t\tcase 'YXZ':\n\t\t\t\tthis._x = s1 * c2 * c3 + c1 * s2 * s3;\n\t\t\t\tthis._y = c1 * s2 * c3 - s1 * c2 * s3;\n\t\t\t\tthis._z = c1 * c2 * s3 - s1 * s2 * c3;\n\t\t\t\tthis._w = c1 * c2 * c3 + s1 * s2 * s3;\n\t\t\t\tbreak;\n\n\t\t\tcase 'ZXY':\n\t\t\t\tthis._x = s1 * c2 * c3 - c1 * s2 * s3;\n\t\t\t\tthis._y = c1 * s2 * c3 + s1 * c2 * s3;\n\t\t\t\tthis._z = c1 * c2 * s3 + s1 * s2 * c3;\n\t\t\t\tthis._w = c1 * c2 * c3 - s1 * s2 * s3;\n\t\t\t\tbreak;\n\n\t\t\tcase 'ZYX':\n\t\t\t\tthis._x = s1 * c2 * c3 - c1 * s2 * s3;\n\t\t\t\tthis._y = c1 * s2 * c3 + s1 * c2 * s3;\n\t\t\t\tthis._z = c1 * c2 * s3 - s1 * s2 * c3;\n\t\t\t\tthis._w = c1 * c2 * c3 + s1 * s2 * s3;\n\t\t\t\tbreak;\n\n\t\t\tcase 'YZX':\n\t\t\t\tthis._x = s1 * c2 * c3 + c1 * s2 * s3;\n\t\t\t\tthis._y = c1 * s2 * c3 + s1 * c2 * s3;\n\t\t\t\tthis._z = c1 * c2 * s3 - s1 * s2 * c3;\n\t\t\t\tthis._w = c1 * c2 * c3 - s1 * s2 * s3;\n\t\t\t\tbreak;\n\n\t\t\tcase 'XZY':\n\t\t\t\tthis._x = s1 * c2 * c3 - c1 * s2 * s3;\n\t\t\t\tthis._y = c1 * s2 * c3 - s1 * c2 * s3;\n\t\t\t\tthis._z = c1 * c2 * s3 + s1 * s2 * c3;\n\t\t\t\tthis._w = c1 * c2 * c3 + s1 * s2 * s3;\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tconsole.warn( 'THREE.Quaternion: .setFromEuler() encountered an unknown order: ' + order );\n\n\t\t}\n\n\t\tif ( update !== false ) this._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\tsetFromAxisAngle: function ( axis, angle ) {\n\n\t\t// http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm\n\n\t\t// assumes axis is normalized\n\n\t\tconst halfAngle = angle / 2, s = Math.sin( halfAngle );\n\n\t\tthis._x = axis.x * s;\n\t\tthis._y = axis.y * s;\n\t\tthis._z = axis.z * s;\n\t\tthis._w = Math.cos( halfAngle );\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\tsetFromRotationMatrix: function ( m ) {\n\n\t\t// http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm\n\n\t\t// assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)\n\n\t\tconst te = m.elements,\n\n\t\t\tm11 = te[ 0 ], m12 = te[ 4 ], m13 = te[ 8 ],\n\t\t\tm21 = te[ 1 ], m22 = te[ 5 ], m23 = te[ 9 ],\n\t\t\tm31 = te[ 2 ], m32 = te[ 6 ], m33 = te[ 10 ],\n\n\t\t\ttrace = m11 + m22 + m33;\n\n\t\tif ( trace > 0 ) {\n\n\t\t\tconst s = 0.5 / Math.sqrt( trace + 1.0 );\n\n\t\t\tthis._w = 0.25 / s;\n\t\t\tthis._x = ( m32 - m23 ) * s;\n\t\t\tthis._y = ( m13 - m31 ) * s;\n\t\t\tthis._z = ( m21 - m12 ) * s;\n\n\t\t} else if ( m11 > m22 && m11 > m33 ) {\n\n\t\t\tconst s = 2.0 * Math.sqrt( 1.0 + m11 - m22 - m33 );\n\n\t\t\tthis._w = ( m32 - m23 ) / s;\n\t\t\tthis._x = 0.25 * s;\n\t\t\tthis._y = ( m12 + m21 ) / s;\n\t\t\tthis._z = ( m13 + m31 ) / s;\n\n\t\t} else if ( m22 > m33 ) {\n\n\t\t\tconst s = 2.0 * Math.sqrt( 1.0 + m22 - m11 - m33 );\n\n\t\t\tthis._w = ( m13 - m31 ) / s;\n\t\t\tthis._x = ( m12 + m21 ) / s;\n\t\t\tthis._y = 0.25 * s;\n\t\t\tthis._z = ( m23 + m32 ) / s;\n\n\t\t} else {\n\n\t\t\tconst s = 2.0 * Math.sqrt( 1.0 + m33 - m11 - m22 );\n\n\t\t\tthis._w = ( m21 - m12 ) / s;\n\t\t\tthis._x = ( m13 + m31 ) / s;\n\t\t\tthis._y = ( m23 + m32 ) / s;\n\t\t\tthis._z = 0.25 * s;\n\n\t\t}\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\tsetFromUnitVectors: function ( vFrom, vTo ) {\n\n\t\t// assumes direction vectors vFrom and vTo are normalized\n\n\t\tconst EPS = 0.000001;\n\n\t\tlet r = vFrom.dot( vTo ) + 1;\n\n\t\tif ( r < EPS ) {\n\n\t\t\tr = 0;\n\n\t\t\tif ( Math.abs( vFrom.x ) > Math.abs( vFrom.z ) ) {\n\n\t\t\t\tthis._x = - vFrom.y;\n\t\t\t\tthis._y = vFrom.x;\n\t\t\t\tthis._z = 0;\n\t\t\t\tthis._w = r;\n\n\t\t\t} else {\n\n\t\t\t\tthis._x = 0;\n\t\t\t\tthis._y = - vFrom.z;\n\t\t\t\tthis._z = vFrom.y;\n\t\t\t\tthis._w = r;\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\t// crossVectors( vFrom, vTo ); // inlined to avoid cyclic dependency on Vector3\n\n\t\t\tthis._x = vFrom.y * vTo.z - vFrom.z * vTo.y;\n\t\t\tthis._y = vFrom.z * vTo.x - vFrom.x * vTo.z;\n\t\t\tthis._z = vFrom.x * vTo.y - vFrom.y * vTo.x;\n\t\t\tthis._w = r;\n\n\t\t}\n\n\t\treturn this.normalize();\n\n\t},\n\n\tangleTo: function ( q ) {\n\n\t\treturn 2 * Math.acos( Math.abs( MathUtils.clamp( this.dot( q ), - 1, 1 ) ) );\n\n\t},\n\n\trotateTowards: function ( q, step ) {\n\n\t\tconst angle = this.angleTo( q );\n\n\t\tif ( angle === 0 ) return this;\n\n\t\tconst t = Math.min( 1, step / angle );\n\n\t\tthis.slerp( q, t );\n\n\t\treturn this;\n\n\t},\n\n\tinverse: function () {\n\n\t\t// quaternion is assumed to have unit length\n\n\t\treturn this.conjugate();\n\n\t},\n\n\tconjugate: function () {\n\n\t\tthis._x *= - 1;\n\t\tthis._y *= - 1;\n\t\tthis._z *= - 1;\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\tdot: function ( v ) {\n\n\t\treturn this._x * v._x + this._y * v._y + this._z * v._z + this._w * v._w;\n\n\t},\n\n\tlengthSq: function () {\n\n\t\treturn this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w;\n\n\t},\n\n\tlength: function () {\n\n\t\treturn Math.sqrt( this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w );\n\n\t},\n\n\tnormalize: function () {\n\n\t\tlet l = this.length();\n\n\t\tif ( l === 0 ) {\n\n\t\t\tthis._x = 0;\n\t\t\tthis._y = 0;\n\t\t\tthis._z = 0;\n\t\t\tthis._w = 1;\n\n\t\t} else {\n\n\t\t\tl = 1 / l;\n\n\t\t\tthis._x = this._x * l;\n\t\t\tthis._y = this._y * l;\n\t\t\tthis._z = this._z * l;\n\t\t\tthis._w = this._w * l;\n\n\t\t}\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\tmultiply: function ( q, p ) {\n\n\t\tif ( p !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead.' );\n\t\t\treturn this.multiplyQuaternions( q, p );\n\n\t\t}\n\n\t\treturn this.multiplyQuaternions( this, q );\n\n\t},\n\n\tpremultiply: function ( q ) {\n\n\t\treturn this.multiplyQuaternions( q, this );\n\n\t},\n\n\tmultiplyQuaternions: function ( a, b ) {\n\n\t\t// from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm\n\n\t\tconst qax = a._x, qay = a._y, qaz = a._z, qaw = a._w;\n\t\tconst qbx = b._x, qby = b._y, qbz = b._z, qbw = b._w;\n\n\t\tthis._x = qax * qbw + qaw * qbx + qay * qbz - qaz * qby;\n\t\tthis._y = qay * qbw + qaw * qby + qaz * qbx - qax * qbz;\n\t\tthis._z = qaz * qbw + qaw * qbz + qax * qby - qay * qbx;\n\t\tthis._w = qaw * qbw - qax * qbx - qay * qby - qaz * qbz;\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\tslerp: function ( qb, t ) {\n\n\t\tif ( t === 0 ) return this;\n\t\tif ( t === 1 ) return this.copy( qb );\n\n\t\tconst x = this._x, y = this._y, z = this._z, w = this._w;\n\n\t\t// http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/\n\n\t\tlet cosHalfTheta = w * qb._w + x * qb._x + y * qb._y + z * qb._z;\n\n\t\tif ( cosHalfTheta < 0 ) {\n\n\t\t\tthis._w = - qb._w;\n\t\t\tthis._x = - qb._x;\n\t\t\tthis._y = - qb._y;\n\t\t\tthis._z = - qb._z;\n\n\t\t\tcosHalfTheta = - cosHalfTheta;\n\n\t\t} else {\n\n\t\t\tthis.copy( qb );\n\n\t\t}\n\n\t\tif ( cosHalfTheta >= 1.0 ) {\n\n\t\t\tthis._w = w;\n\t\t\tthis._x = x;\n\t\t\tthis._y = y;\n\t\t\tthis._z = z;\n\n\t\t\treturn this;\n\n\t\t}\n\n\t\tconst sqrSinHalfTheta = 1.0 - cosHalfTheta * cosHalfTheta;\n\n\t\tif ( sqrSinHalfTheta <= Number.EPSILON ) {\n\n\t\t\tconst s = 1 - t;\n\t\t\tthis._w = s * w + t * this._w;\n\t\t\tthis._x = s * x + t * this._x;\n\t\t\tthis._y = s * y + t * this._y;\n\t\t\tthis._z = s * z + t * this._z;\n\n\t\t\tthis.normalize();\n\t\t\tthis._onChangeCallback();\n\n\t\t\treturn this;\n\n\t\t}\n\n\t\tconst sinHalfTheta = Math.sqrt( sqrSinHalfTheta );\n\t\tconst halfTheta = Math.atan2( sinHalfTheta, cosHalfTheta );\n\t\tconst ratioA = Math.sin( ( 1 - t ) * halfTheta ) / sinHalfTheta,\n\t\t\tratioB = Math.sin( t * halfTheta ) / sinHalfTheta;\n\n\t\tthis._w = ( w * ratioA + this._w * ratioB );\n\t\tthis._x = ( x * ratioA + this._x * ratioB );\n\t\tthis._y = ( y * ratioA + this._y * ratioB );\n\t\tthis._z = ( z * ratioA + this._z * ratioB );\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\tequals: function ( quaternion ) {\n\n\t\treturn ( quaternion._x === this._x ) && ( quaternion._y === this._y ) && ( quaternion._z === this._z ) && ( quaternion._w === this._w );\n\n\t},\n\n\tfromArray: function ( array, offset ) {\n\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tthis._x = array[ offset ];\n\t\tthis._y = array[ offset + 1 ];\n\t\tthis._z = array[ offset + 2 ];\n\t\tthis._w = array[ offset + 3 ];\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\ttoArray: function ( array, offset ) {\n\n\t\tif ( array === undefined ) array = [];\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tarray[ offset ] = this._x;\n\t\tarray[ offset + 1 ] = this._y;\n\t\tarray[ offset + 2 ] = this._z;\n\t\tarray[ offset + 3 ] = this._w;\n\n\t\treturn array;\n\n\t},\n\n\tfromBufferAttribute: function ( attribute, index ) {\n\n\t\tthis._x = attribute.getX( index );\n\t\tthis._y = attribute.getY( index );\n\t\tthis._z = attribute.getZ( index );\n\t\tthis._w = attribute.getW( index );\n\n\t\treturn this;\n\n\t},\n\n\t_onChange: function ( callback ) {\n\n\t\tthis._onChangeCallback = callback;\n\n\t\treturn this;\n\n\t},\n\n\t_onChangeCallback: function () {}\n\n} );\n\n\nexport { Quaternion };\n","import { MathUtils } from './MathUtils.js';\nimport { Quaternion } from './Quaternion.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author kile / http://kile.stravaganza.org/\n * @author philogb / http://blog.thejit.org/\n * @author mikael emtinger / http://gomo.se/\n * @author egraether / http://egraether.com/\n * @author WestLangley / http://github.com/WestLangley\n */\n\nconst _vector = new Vector3();\nconst _quaternion = new Quaternion();\n\nfunction Vector3( x = 0, y = 0, z = 0 ) {\n\n\tthis.x = x;\n\tthis.y = y;\n\tthis.z = z;\n\n}\n\nObject.assign( Vector3.prototype, {\n\n\tisVector3: true,\n\n\tset: function ( x, y, z ) {\n\n\t\tthis.x = x;\n\t\tthis.y = y;\n\t\tthis.z = z;\n\n\t\treturn this;\n\n\t},\n\n\tsetScalar: function ( scalar ) {\n\n\t\tthis.x = scalar;\n\t\tthis.y = scalar;\n\t\tthis.z = scalar;\n\n\t\treturn this;\n\n\t},\n\n\tsetX: function ( x ) {\n\n\t\tthis.x = x;\n\n\t\treturn this;\n\n\t},\n\n\tsetY: function ( y ) {\n\n\t\tthis.y = y;\n\n\t\treturn this;\n\n\t},\n\n\tsetZ: function ( z ) {\n\n\t\tthis.z = z;\n\n\t\treturn this;\n\n\t},\n\n\tsetComponent: function ( index, value ) {\n\n\t\tswitch ( index ) {\n\n\t\t\tcase 0: this.x = value; break;\n\t\t\tcase 1: this.y = value; break;\n\t\t\tcase 2: this.z = value; break;\n\t\t\tdefault: throw new Error( 'index is out of range: ' + index );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tgetComponent: function ( index ) {\n\n\t\tswitch ( index ) {\n\n\t\t\tcase 0: return this.x;\n\t\t\tcase 1: return this.y;\n\t\t\tcase 2: return this.z;\n\t\t\tdefault: throw new Error( 'index is out of range: ' + index );\n\n\t\t}\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor( this.x, this.y, this.z );\n\n\t},\n\n\tcopy: function ( v ) {\n\n\t\tthis.x = v.x;\n\t\tthis.y = v.y;\n\t\tthis.z = v.z;\n\n\t\treturn this;\n\n\t},\n\n\tadd: function ( v, w ) {\n\n\t\tif ( w !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead.' );\n\t\t\treturn this.addVectors( v, w );\n\n\t\t}\n\n\t\tthis.x += v.x;\n\t\tthis.y += v.y;\n\t\tthis.z += v.z;\n\n\t\treturn this;\n\n\t},\n\n\taddScalar: function ( s ) {\n\n\t\tthis.x += s;\n\t\tthis.y += s;\n\t\tthis.z += s;\n\n\t\treturn this;\n\n\t},\n\n\taddVectors: function ( a, b ) {\n\n\t\tthis.x = a.x + b.x;\n\t\tthis.y = a.y + b.y;\n\t\tthis.z = a.z + b.z;\n\n\t\treturn this;\n\n\t},\n\n\taddScaledVector: function ( v, s ) {\n\n\t\tthis.x += v.x * s;\n\t\tthis.y += v.y * s;\n\t\tthis.z += v.z * s;\n\n\t\treturn this;\n\n\t},\n\n\tsub: function ( v, w ) {\n\n\t\tif ( w !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.' );\n\t\t\treturn this.subVectors( v, w );\n\n\t\t}\n\n\t\tthis.x -= v.x;\n\t\tthis.y -= v.y;\n\t\tthis.z -= v.z;\n\n\t\treturn this;\n\n\t},\n\n\tsubScalar: function ( s ) {\n\n\t\tthis.x -= s;\n\t\tthis.y -= s;\n\t\tthis.z -= s;\n\n\t\treturn this;\n\n\t},\n\n\tsubVectors: function ( a, b ) {\n\n\t\tthis.x = a.x - b.x;\n\t\tthis.y = a.y - b.y;\n\t\tthis.z = a.z - b.z;\n\n\t\treturn this;\n\n\t},\n\n\tmultiply: function ( v, w ) {\n\n\t\tif ( w !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead.' );\n\t\t\treturn this.multiplyVectors( v, w );\n\n\t\t}\n\n\t\tthis.x *= v.x;\n\t\tthis.y *= v.y;\n\t\tthis.z *= v.z;\n\n\t\treturn this;\n\n\t},\n\n\tmultiplyScalar: function ( scalar ) {\n\n\t\tthis.x *= scalar;\n\t\tthis.y *= scalar;\n\t\tthis.z *= scalar;\n\n\t\treturn this;\n\n\t},\n\n\tmultiplyVectors: function ( a, b ) {\n\n\t\tthis.x = a.x * b.x;\n\t\tthis.y = a.y * b.y;\n\t\tthis.z = a.z * b.z;\n\n\t\treturn this;\n\n\t},\n\n\tapplyEuler: function ( euler ) {\n\n\t\tif ( ! ( euler && euler.isEuler ) ) {\n\n\t\t\tconsole.error( 'THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.' );\n\n\t\t}\n\n\t\treturn this.applyQuaternion( _quaternion.setFromEuler( euler ) );\n\n\t},\n\n\tapplyAxisAngle: function ( axis, angle ) {\n\n\t\treturn this.applyQuaternion( _quaternion.setFromAxisAngle( axis, angle ) );\n\n\t},\n\n\tapplyMatrix3: function ( m ) {\n\n\t\tconst x = this.x, y = this.y, z = this.z;\n\t\tconst e = m.elements;\n\n\t\tthis.x = e[ 0 ] * x + e[ 3 ] * y + e[ 6 ] * z;\n\t\tthis.y = e[ 1 ] * x + e[ 4 ] * y + e[ 7 ] * z;\n\t\tthis.z = e[ 2 ] * x + e[ 5 ] * y + e[ 8 ] * z;\n\n\t\treturn this;\n\n\t},\n\n\tapplyNormalMatrix: function ( m ) {\n\n\t\treturn this.applyMatrix3( m ).normalize();\n\n\t},\n\n\tapplyMatrix4: function ( m ) {\n\n\t\tconst x = this.x, y = this.y, z = this.z;\n\t\tconst e = m.elements;\n\n\t\tconst w = 1 / ( e[ 3 ] * x + e[ 7 ] * y + e[ 11 ] * z + e[ 15 ] );\n\n\t\tthis.x = ( e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z + e[ 12 ] ) * w;\n\t\tthis.y = ( e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z + e[ 13 ] ) * w;\n\t\tthis.z = ( e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z + e[ 14 ] ) * w;\n\n\t\treturn this;\n\n\t},\n\n\tapplyQuaternion: function ( q ) {\n\n\t\tconst x = this.x, y = this.y, z = this.z;\n\t\tconst qx = q.x, qy = q.y, qz = q.z, qw = q.w;\n\n\t\t// calculate quat * vector\n\n\t\tconst ix = qw * x + qy * z - qz * y;\n\t\tconst iy = qw * y + qz * x - qx * z;\n\t\tconst iz = qw * z + qx * y - qy * x;\n\t\tconst iw = - qx * x - qy * y - qz * z;\n\n\t\t// calculate result * inverse quat\n\n\t\tthis.x = ix * qw + iw * - qx + iy * - qz - iz * - qy;\n\t\tthis.y = iy * qw + iw * - qy + iz * - qx - ix * - qz;\n\t\tthis.z = iz * qw + iw * - qz + ix * - qy - iy * - qx;\n\n\t\treturn this;\n\n\t},\n\n\tproject: function ( camera ) {\n\n\t\treturn this.applyMatrix4( camera.matrixWorldInverse ).applyMatrix4( camera.projectionMatrix );\n\n\t},\n\n\tunproject: function ( camera ) {\n\n\t\treturn this.applyMatrix4( camera.projectionMatrixInverse ).applyMatrix4( camera.matrixWorld );\n\n\t},\n\n\ttransformDirection: function ( m ) {\n\n\t\t// input: THREE.Matrix4 affine matrix\n\t\t// vector interpreted as a direction\n\n\t\tconst x = this.x, y = this.y, z = this.z;\n\t\tconst e = m.elements;\n\n\t\tthis.x = e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z;\n\t\tthis.y = e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z;\n\t\tthis.z = e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z;\n\n\t\treturn this.normalize();\n\n\t},\n\n\tdivide: function ( v ) {\n\n\t\tthis.x /= v.x;\n\t\tthis.y /= v.y;\n\t\tthis.z /= v.z;\n\n\t\treturn this;\n\n\t},\n\n\tdivideScalar: function ( scalar ) {\n\n\t\treturn this.multiplyScalar( 1 / scalar );\n\n\t},\n\n\tmin: function ( v ) {\n\n\t\tthis.x = Math.min( this.x, v.x );\n\t\tthis.y = Math.min( this.y, v.y );\n\t\tthis.z = Math.min( this.z, v.z );\n\n\t\treturn this;\n\n\t},\n\n\tmax: function ( v ) {\n\n\t\tthis.x = Math.max( this.x, v.x );\n\t\tthis.y = Math.max( this.y, v.y );\n\t\tthis.z = Math.max( this.z, v.z );\n\n\t\treturn this;\n\n\t},\n\n\tclamp: function ( min, max ) {\n\n\t\t// assumes min < max, componentwise\n\n\t\tthis.x = Math.max( min.x, Math.min( max.x, this.x ) );\n\t\tthis.y = Math.max( min.y, Math.min( max.y, this.y ) );\n\t\tthis.z = Math.max( min.z, Math.min( max.z, this.z ) );\n\n\t\treturn this;\n\n\t},\n\n\tclampScalar: function ( minVal, maxVal ) {\n\n\t\tthis.x = Math.max( minVal, Math.min( maxVal, this.x ) );\n\t\tthis.y = Math.max( minVal, Math.min( maxVal, this.y ) );\n\t\tthis.z = Math.max( minVal, Math.min( maxVal, this.z ) );\n\n\t\treturn this;\n\n\t},\n\n\tclampLength: function ( min, max ) {\n\n\t\tconst length = this.length();\n\n\t\treturn this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) );\n\n\t},\n\n\tfloor: function () {\n\n\t\tthis.x = Math.floor( this.x );\n\t\tthis.y = Math.floor( this.y );\n\t\tthis.z = Math.floor( this.z );\n\n\t\treturn this;\n\n\t},\n\n\tceil: function () {\n\n\t\tthis.x = Math.ceil( this.x );\n\t\tthis.y = Math.ceil( this.y );\n\t\tthis.z = Math.ceil( this.z );\n\n\t\treturn this;\n\n\t},\n\n\tround: function () {\n\n\t\tthis.x = Math.round( this.x );\n\t\tthis.y = Math.round( this.y );\n\t\tthis.z = Math.round( this.z );\n\n\t\treturn this;\n\n\t},\n\n\troundToZero: function () {\n\n\t\tthis.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x );\n\t\tthis.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y );\n\t\tthis.z = ( this.z < 0 ) ? Math.ceil( this.z ) : Math.floor( this.z );\n\n\t\treturn this;\n\n\t},\n\n\tnegate: function () {\n\n\t\tthis.x = - this.x;\n\t\tthis.y = - this.y;\n\t\tthis.z = - this.z;\n\n\t\treturn this;\n\n\t},\n\n\tdot: function ( v ) {\n\n\t\treturn this.x * v.x + this.y * v.y + this.z * v.z;\n\n\t},\n\n\t// TODO lengthSquared?\n\n\tlengthSq: function () {\n\n\t\treturn this.x * this.x + this.y * this.y + this.z * this.z;\n\n\t},\n\n\tlength: function () {\n\n\t\treturn Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z );\n\n\t},\n\n\tmanhattanLength: function () {\n\n\t\treturn Math.abs( this.x ) + Math.abs( this.y ) + Math.abs( this.z );\n\n\t},\n\n\tnormalize: function () {\n\n\t\treturn this.divideScalar( this.length() || 1 );\n\n\t},\n\n\tsetLength: function ( length ) {\n\n\t\treturn this.normalize().multiplyScalar( length );\n\n\t},\n\n\tlerp: function ( v, alpha ) {\n\n\t\tthis.x += ( v.x - this.x ) * alpha;\n\t\tthis.y += ( v.y - this.y ) * alpha;\n\t\tthis.z += ( v.z - this.z ) * alpha;\n\n\t\treturn this;\n\n\t},\n\n\tlerpVectors: function ( v1, v2, alpha ) {\n\n\t\tthis.x = v1.x + ( v2.x - v1.x ) * alpha;\n\t\tthis.y = v1.y + ( v2.y - v1.y ) * alpha;\n\t\tthis.z = v1.z + ( v2.z - v1.z ) * alpha;\n\n\t\treturn this;\n\n\t},\n\n\tcross: function ( v, w ) {\n\n\t\tif ( w !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead.' );\n\t\t\treturn this.crossVectors( v, w );\n\n\t\t}\n\n\t\treturn this.crossVectors( this, v );\n\n\t},\n\n\tcrossVectors: function ( a, b ) {\n\n\t\tconst ax = a.x, ay = a.y, az = a.z;\n\t\tconst bx = b.x, by = b.y, bz = b.z;\n\n\t\tthis.x = ay * bz - az * by;\n\t\tthis.y = az * bx - ax * bz;\n\t\tthis.z = ax * by - ay * bx;\n\n\t\treturn this;\n\n\t},\n\n\tprojectOnVector: function ( v ) {\n\n\t\tconst denominator = v.lengthSq();\n\n\t\tif ( denominator === 0 ) return this.set( 0, 0, 0 );\n\n\t\tconst scalar = v.dot( this ) / denominator;\n\n\t\treturn this.copy( v ).multiplyScalar( scalar );\n\n\t},\n\n\tprojectOnPlane: function ( planeNormal ) {\n\n\t\t_vector.copy( this ).projectOnVector( planeNormal );\n\n\t\treturn this.sub( _vector );\n\n\t},\n\n\treflect: function ( normal ) {\n\n\t\t// reflect incident vector off plane orthogonal to normal\n\t\t// normal is assumed to have unit length\n\n\t\treturn this.sub( _vector.copy( normal ).multiplyScalar( 2 * this.dot( normal ) ) );\n\n\t},\n\n\tangleTo: function ( v ) {\n\n\t\tconst denominator = Math.sqrt( this.lengthSq() * v.lengthSq() );\n\n\t\tif ( denominator === 0 ) return Math.PI / 2;\n\n\t\tconst theta = this.dot( v ) / denominator;\n\n\t\t// clamp, to handle numerical problems\n\n\t\treturn Math.acos( MathUtils.clamp( theta, - 1, 1 ) );\n\n\t},\n\n\tdistanceTo: function ( v ) {\n\n\t\treturn Math.sqrt( this.distanceToSquared( v ) );\n\n\t},\n\n\tdistanceToSquared: function ( v ) {\n\n\t\tconst dx = this.x - v.x, dy = this.y - v.y, dz = this.z - v.z;\n\n\t\treturn dx * dx + dy * dy + dz * dz;\n\n\t},\n\n\tmanhattanDistanceTo: function ( v ) {\n\n\t\treturn Math.abs( this.x - v.x ) + Math.abs( this.y - v.y ) + Math.abs( this.z - v.z );\n\n\t},\n\n\tsetFromSpherical: function ( s ) {\n\n\t\treturn this.setFromSphericalCoords( s.radius, s.phi, s.theta );\n\n\t},\n\n\tsetFromSphericalCoords: function ( radius, phi, theta ) {\n\n\t\tconst sinPhiRadius = Math.sin( phi ) * radius;\n\n\t\tthis.x = sinPhiRadius * Math.sin( theta );\n\t\tthis.y = Math.cos( phi ) * radius;\n\t\tthis.z = sinPhiRadius * Math.cos( theta );\n\n\t\treturn this;\n\n\t},\n\n\tsetFromCylindrical: function ( c ) {\n\n\t\treturn this.setFromCylindricalCoords( c.radius, c.theta, c.y );\n\n\t},\n\n\tsetFromCylindricalCoords: function ( radius, theta, y ) {\n\n\t\tthis.x = radius * Math.sin( theta );\n\t\tthis.y = y;\n\t\tthis.z = radius * Math.cos( theta );\n\n\t\treturn this;\n\n\t},\n\n\tsetFromMatrixPosition: function ( m ) {\n\n\t\tconst e = m.elements;\n\n\t\tthis.x = e[ 12 ];\n\t\tthis.y = e[ 13 ];\n\t\tthis.z = e[ 14 ];\n\n\t\treturn this;\n\n\t},\n\n\tsetFromMatrixScale: function ( m ) {\n\n\t\tconst sx = this.setFromMatrixColumn( m, 0 ).length();\n\t\tconst sy = this.setFromMatrixColumn( m, 1 ).length();\n\t\tconst sz = this.setFromMatrixColumn( m, 2 ).length();\n\n\t\tthis.x = sx;\n\t\tthis.y = sy;\n\t\tthis.z = sz;\n\n\t\treturn this;\n\n\t},\n\n\tsetFromMatrixColumn: function ( m, index ) {\n\n\t\treturn this.fromArray( m.elements, index * 4 );\n\n\t},\n\n\tsetFromMatrix3Column: function ( m, index ) {\n\n\t\treturn this.fromArray( m.elements, index * 3 );\n\n\t},\n\n\tequals: function ( v ) {\n\n\t\treturn ( ( v.x === this.x ) && ( v.y === this.y ) && ( v.z === this.z ) );\n\n\t},\n\n\tfromArray: function ( array, offset ) {\n\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tthis.x = array[ offset ];\n\t\tthis.y = array[ offset + 1 ];\n\t\tthis.z = array[ offset + 2 ];\n\n\t\treturn this;\n\n\t},\n\n\ttoArray: function ( array, offset ) {\n\n\t\tif ( array === undefined ) array = [];\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tarray[ offset ] = this.x;\n\t\tarray[ offset + 1 ] = this.y;\n\t\tarray[ offset + 2 ] = this.z;\n\n\t\treturn array;\n\n\t},\n\n\tfromBufferAttribute: function ( attribute, index, offset ) {\n\n\t\tif ( offset !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Vector3: offset has been removed from .fromBufferAttribute().' );\n\n\t\t}\n\n\t\tthis.x = attribute.getX( index );\n\t\tthis.y = attribute.getY( index );\n\t\tthis.z = attribute.getZ( index );\n\n\t\treturn this;\n\n\t},\n\n\trandom: function () {\n\n\t\tthis.x = Math.random();\n\t\tthis.y = Math.random();\n\t\tthis.z = Math.random();\n\n\t\treturn this;\n\n\t}\n\n} );\n\n\nexport { Vector3 };\n","import { Vector3 } from './Vector3.js';\n\nconst _v1 = new Vector3();\nconst _m1 = new Matrix4();\nconst _zero = new Vector3( 0, 0, 0 );\nconst _one = new Vector3( 1, 1, 1 );\nconst _x = new Vector3();\nconst _y = new Vector3();\nconst _z = new Vector3();\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author supereggbert / http://www.paulbrunt.co.uk/\n * @author philogb / http://blog.thejit.org/\n * @author jordi_ros / http://plattsoft.com\n * @author D1plo1d / http://github.com/D1plo1d\n * @author alteredq / http://alteredqualia.com/\n * @author mikael emtinger / http://gomo.se/\n * @author timknip / http://www.floorplanner.com/\n * @author bhouston / http://clara.io\n * @author WestLangley / http://github.com/WestLangley\n */\n\nfunction Matrix4() {\n\n\tthis.elements = [\n\n\t\t1, 0, 0, 0,\n\t\t0, 1, 0, 0,\n\t\t0, 0, 1, 0,\n\t\t0, 0, 0, 1\n\n\t];\n\n\tif ( arguments.length > 0 ) {\n\n\t\tconsole.error( 'THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.' );\n\n\t}\n\n}\n\nObject.assign( Matrix4.prototype, {\n\n\tisMatrix4: true,\n\n\tset: function ( n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44 ) {\n\n\t\tconst te = this.elements;\n\n\t\tte[ 0 ] = n11; te[ 4 ] = n12; te[ 8 ] = n13; te[ 12 ] = n14;\n\t\tte[ 1 ] = n21; te[ 5 ] = n22; te[ 9 ] = n23; te[ 13 ] = n24;\n\t\tte[ 2 ] = n31; te[ 6 ] = n32; te[ 10 ] = n33; te[ 14 ] = n34;\n\t\tte[ 3 ] = n41; te[ 7 ] = n42; te[ 11 ] = n43; te[ 15 ] = n44;\n\n\t\treturn this;\n\n\t},\n\n\tidentity: function () {\n\n\t\tthis.set(\n\n\t\t\t1, 0, 0, 0,\n\t\t\t0, 1, 0, 0,\n\t\t\t0, 0, 1, 0,\n\t\t\t0, 0, 0, 1\n\n\t\t);\n\n\t\treturn this;\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new Matrix4().fromArray( this.elements );\n\n\t},\n\n\tcopy: function ( m ) {\n\n\t\tconst te = this.elements;\n\t\tconst me = m.elements;\n\n\t\tte[ 0 ] = me[ 0 ]; te[ 1 ] = me[ 1 ]; te[ 2 ] = me[ 2 ]; te[ 3 ] = me[ 3 ];\n\t\tte[ 4 ] = me[ 4 ]; te[ 5 ] = me[ 5 ]; te[ 6 ] = me[ 6 ]; te[ 7 ] = me[ 7 ];\n\t\tte[ 8 ] = me[ 8 ]; te[ 9 ] = me[ 9 ]; te[ 10 ] = me[ 10 ]; te[ 11 ] = me[ 11 ];\n\t\tte[ 12 ] = me[ 12 ]; te[ 13 ] = me[ 13 ]; te[ 14 ] = me[ 14 ]; te[ 15 ] = me[ 15 ];\n\n\t\treturn this;\n\n\t},\n\n\tcopyPosition: function ( m ) {\n\n\t\tconst te = this.elements, me = m.elements;\n\n\t\tte[ 12 ] = me[ 12 ];\n\t\tte[ 13 ] = me[ 13 ];\n\t\tte[ 14 ] = me[ 14 ];\n\n\t\treturn this;\n\n\t},\n\n\textractBasis: function ( xAxis, yAxis, zAxis ) {\n\n\t\txAxis.setFromMatrixColumn( this, 0 );\n\t\tyAxis.setFromMatrixColumn( this, 1 );\n\t\tzAxis.setFromMatrixColumn( this, 2 );\n\n\t\treturn this;\n\n\t},\n\n\tmakeBasis: function ( xAxis, yAxis, zAxis ) {\n\n\t\tthis.set(\n\t\t\txAxis.x, yAxis.x, zAxis.x, 0,\n\t\t\txAxis.y, yAxis.y, zAxis.y, 0,\n\t\t\txAxis.z, yAxis.z, zAxis.z, 0,\n\t\t\t0, 0, 0, 1\n\t\t);\n\n\t\treturn this;\n\n\t},\n\n\textractRotation: function ( m ) {\n\n\t\t// this method does not support reflection matrices\n\n\t\tconst te = this.elements;\n\t\tconst me = m.elements;\n\n\t\tconst scaleX = 1 / _v1.setFromMatrixColumn( m, 0 ).length();\n\t\tconst scaleY = 1 / _v1.setFromMatrixColumn( m, 1 ).length();\n\t\tconst scaleZ = 1 / _v1.setFromMatrixColumn( m, 2 ).length();\n\n\t\tte[ 0 ] = me[ 0 ] * scaleX;\n\t\tte[ 1 ] = me[ 1 ] * scaleX;\n\t\tte[ 2 ] = me[ 2 ] * scaleX;\n\t\tte[ 3 ] = 0;\n\n\t\tte[ 4 ] = me[ 4 ] * scaleY;\n\t\tte[ 5 ] = me[ 5 ] * scaleY;\n\t\tte[ 6 ] = me[ 6 ] * scaleY;\n\t\tte[ 7 ] = 0;\n\n\t\tte[ 8 ] = me[ 8 ] * scaleZ;\n\t\tte[ 9 ] = me[ 9 ] * scaleZ;\n\t\tte[ 10 ] = me[ 10 ] * scaleZ;\n\t\tte[ 11 ] = 0;\n\n\t\tte[ 12 ] = 0;\n\t\tte[ 13 ] = 0;\n\t\tte[ 14 ] = 0;\n\t\tte[ 15 ] = 1;\n\n\t\treturn this;\n\n\t},\n\n\tmakeRotationFromEuler: function ( euler ) {\n\n\t\tif ( ! ( euler && euler.isEuler ) ) {\n\n\t\t\tconsole.error( 'THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.' );\n\n\t\t}\n\n\t\tconst te = this.elements;\n\n\t\tconst x = euler.x, y = euler.y, z = euler.z;\n\t\tconst a = Math.cos( x ), b = Math.sin( x );\n\t\tconst c = Math.cos( y ), d = Math.sin( y );\n\t\tconst e = Math.cos( z ), f = Math.sin( z );\n\n\t\tif ( euler.order === 'XYZ' ) {\n\n\t\t\tconst ae = a * e, af = a * f, be = b * e, bf = b * f;\n\n\t\t\tte[ 0 ] = c * e;\n\t\t\tte[ 4 ] = - c * f;\n\t\t\tte[ 8 ] = d;\n\n\t\t\tte[ 1 ] = af + be * d;\n\t\t\tte[ 5 ] = ae - bf * d;\n\t\t\tte[ 9 ] = - b * c;\n\n\t\t\tte[ 2 ] = bf - ae * d;\n\t\t\tte[ 6 ] = be + af * d;\n\t\t\tte[ 10 ] = a * c;\n\n\t\t} else if ( euler.order === 'YXZ' ) {\n\n\t\t\tconst ce = c * e, cf = c * f, de = d * e, df = d * f;\n\n\t\t\tte[ 0 ] = ce + df * b;\n\t\t\tte[ 4 ] = de * b - cf;\n\t\t\tte[ 8 ] = a * d;\n\n\t\t\tte[ 1 ] = a * f;\n\t\t\tte[ 5 ] = a * e;\n\t\t\tte[ 9 ] = - b;\n\n\t\t\tte[ 2 ] = cf * b - de;\n\t\t\tte[ 6 ] = df + ce * b;\n\t\t\tte[ 10 ] = a * c;\n\n\t\t} else if ( euler.order === 'ZXY' ) {\n\n\t\t\tconst ce = c * e, cf = c * f, de = d * e, df = d * f;\n\n\t\t\tte[ 0 ] = ce - df * b;\n\t\t\tte[ 4 ] = - a * f;\n\t\t\tte[ 8 ] = de + cf * b;\n\n\t\t\tte[ 1 ] = cf + de * b;\n\t\t\tte[ 5 ] = a * e;\n\t\t\tte[ 9 ] = df - ce * b;\n\n\t\t\tte[ 2 ] = - a * d;\n\t\t\tte[ 6 ] = b;\n\t\t\tte[ 10 ] = a * c;\n\n\t\t} else if ( euler.order === 'ZYX' ) {\n\n\t\t\tconst ae = a * e, af = a * f, be = b * e, bf = b * f;\n\n\t\t\tte[ 0 ] = c * e;\n\t\t\tte[ 4 ] = be * d - af;\n\t\t\tte[ 8 ] = ae * d + bf;\n\n\t\t\tte[ 1 ] = c * f;\n\t\t\tte[ 5 ] = bf * d + ae;\n\t\t\tte[ 9 ] = af * d - be;\n\n\t\t\tte[ 2 ] = - d;\n\t\t\tte[ 6 ] = b * c;\n\t\t\tte[ 10 ] = a * c;\n\n\t\t} else if ( euler.order === 'YZX' ) {\n\n\t\t\tconst ac = a * c, ad = a * d, bc = b * c, bd = b * d;\n\n\t\t\tte[ 0 ] = c * e;\n\t\t\tte[ 4 ] = bd - ac * f;\n\t\t\tte[ 8 ] = bc * f + ad;\n\n\t\t\tte[ 1 ] = f;\n\t\t\tte[ 5 ] = a * e;\n\t\t\tte[ 9 ] = - b * e;\n\n\t\t\tte[ 2 ] = - d * e;\n\t\t\tte[ 6 ] = ad * f + bc;\n\t\t\tte[ 10 ] = ac - bd * f;\n\n\t\t} else if ( euler.order === 'XZY' ) {\n\n\t\t\tconst ac = a * c, ad = a * d, bc = b * c, bd = b * d;\n\n\t\t\tte[ 0 ] = c * e;\n\t\t\tte[ 4 ] = - f;\n\t\t\tte[ 8 ] = d * e;\n\n\t\t\tte[ 1 ] = ac * f + bd;\n\t\t\tte[ 5 ] = a * e;\n\t\t\tte[ 9 ] = ad * f - bc;\n\n\t\t\tte[ 2 ] = bc * f - ad;\n\t\t\tte[ 6 ] = b * e;\n\t\t\tte[ 10 ] = bd * f + ac;\n\n\t\t}\n\n\t\t// bottom row\n\t\tte[ 3 ] = 0;\n\t\tte[ 7 ] = 0;\n\t\tte[ 11 ] = 0;\n\n\t\t// last column\n\t\tte[ 12 ] = 0;\n\t\tte[ 13 ] = 0;\n\t\tte[ 14 ] = 0;\n\t\tte[ 15 ] = 1;\n\n\t\treturn this;\n\n\t},\n\n\tmakeRotationFromQuaternion: function ( q ) {\n\n\t\treturn this.compose( _zero, q, _one );\n\n\t},\n\n\tlookAt: function ( eye, target, up ) {\n\n\t\tconst te = this.elements;\n\n\t\t_z.subVectors( eye, target );\n\n\t\tif ( _z.lengthSq() === 0 ) {\n\n\t\t\t// eye and target are in the same position\n\n\t\t\t_z.z = 1;\n\n\t\t}\n\n\t\t_z.normalize();\n\t\t_x.crossVectors( up, _z );\n\n\t\tif ( _x.lengthSq() === 0 ) {\n\n\t\t\t// up and z are parallel\n\n\t\t\tif ( Math.abs( up.z ) === 1 ) {\n\n\t\t\t\t_z.x += 0.0001;\n\n\t\t\t} else {\n\n\t\t\t\t_z.z += 0.0001;\n\n\t\t\t}\n\n\t\t\t_z.normalize();\n\t\t\t_x.crossVectors( up, _z );\n\n\t\t}\n\n\t\t_x.normalize();\n\t\t_y.crossVectors( _z, _x );\n\n\t\tte[ 0 ] = _x.x; te[ 4 ] = _y.x; te[ 8 ] = _z.x;\n\t\tte[ 1 ] = _x.y; te[ 5 ] = _y.y; te[ 9 ] = _z.y;\n\t\tte[ 2 ] = _x.z; te[ 6 ] = _y.z; te[ 10 ] = _z.z;\n\n\t\treturn this;\n\n\t},\n\n\tmultiply: function ( m, n ) {\n\n\t\tif ( n !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead.' );\n\t\t\treturn this.multiplyMatrices( m, n );\n\n\t\t}\n\n\t\treturn this.multiplyMatrices( this, m );\n\n\t},\n\n\tpremultiply: function ( m ) {\n\n\t\treturn this.multiplyMatrices( m, this );\n\n\t},\n\n\tmultiplyMatrices: function ( a, b ) {\n\n\t\tconst ae = a.elements;\n\t\tconst be = b.elements;\n\t\tconst te = this.elements;\n\n\t\tconst a11 = ae[ 0 ], a12 = ae[ 4 ], a13 = ae[ 8 ], a14 = ae[ 12 ];\n\t\tconst a21 = ae[ 1 ], a22 = ae[ 5 ], a23 = ae[ 9 ], a24 = ae[ 13 ];\n\t\tconst a31 = ae[ 2 ], a32 = ae[ 6 ], a33 = ae[ 10 ], a34 = ae[ 14 ];\n\t\tconst a41 = ae[ 3 ], a42 = ae[ 7 ], a43 = ae[ 11 ], a44 = ae[ 15 ];\n\n\t\tconst b11 = be[ 0 ], b12 = be[ 4 ], b13 = be[ 8 ], b14 = be[ 12 ];\n\t\tconst b21 = be[ 1 ], b22 = be[ 5 ], b23 = be[ 9 ], b24 = be[ 13 ];\n\t\tconst b31 = be[ 2 ], b32 = be[ 6 ], b33 = be[ 10 ], b34 = be[ 14 ];\n\t\tconst b41 = be[ 3 ], b42 = be[ 7 ], b43 = be[ 11 ], b44 = be[ 15 ];\n\n\t\tte[ 0 ] = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41;\n\t\tte[ 4 ] = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42;\n\t\tte[ 8 ] = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43;\n\t\tte[ 12 ] = a11 * b14 + a12 * b24 + a13 * b34 + a14 * b44;\n\n\t\tte[ 1 ] = a21 * b11 + a22 * b21 + a23 * b31 + a24 * b41;\n\t\tte[ 5 ] = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42;\n\t\tte[ 9 ] = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43;\n\t\tte[ 13 ] = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44;\n\n\t\tte[ 2 ] = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41;\n\t\tte[ 6 ] = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42;\n\t\tte[ 10 ] = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43;\n\t\tte[ 14 ] = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44;\n\n\t\tte[ 3 ] = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41;\n\t\tte[ 7 ] = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42;\n\t\tte[ 11 ] = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43;\n\t\tte[ 15 ] = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44;\n\n\t\treturn this;\n\n\t},\n\n\tmultiplyScalar: function ( s ) {\n\n\t\tconst te = this.elements;\n\n\t\tte[ 0 ] *= s; te[ 4 ] *= s; te[ 8 ] *= s; te[ 12 ] *= s;\n\t\tte[ 1 ] *= s; te[ 5 ] *= s; te[ 9 ] *= s; te[ 13 ] *= s;\n\t\tte[ 2 ] *= s; te[ 6 ] *= s; te[ 10 ] *= s; te[ 14 ] *= s;\n\t\tte[ 3 ] *= s; te[ 7 ] *= s; te[ 11 ] *= s; te[ 15 ] *= s;\n\n\t\treturn this;\n\n\t},\n\n\tdeterminant: function () {\n\n\t\tconst te = this.elements;\n\n\t\tconst n11 = te[ 0 ], n12 = te[ 4 ], n13 = te[ 8 ], n14 = te[ 12 ];\n\t\tconst n21 = te[ 1 ], n22 = te[ 5 ], n23 = te[ 9 ], n24 = te[ 13 ];\n\t\tconst n31 = te[ 2 ], n32 = te[ 6 ], n33 = te[ 10 ], n34 = te[ 14 ];\n\t\tconst n41 = te[ 3 ], n42 = te[ 7 ], n43 = te[ 11 ], n44 = te[ 15 ];\n\n\t\t//TODO: make this more efficient\n\t\t//( based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm )\n\n\t\treturn (\n\t\t\tn41 * (\n\t\t\t\t+ n14 * n23 * n32\n\t\t\t\t - n13 * n24 * n32\n\t\t\t\t - n14 * n22 * n33\n\t\t\t\t + n12 * n24 * n33\n\t\t\t\t + n13 * n22 * n34\n\t\t\t\t - n12 * n23 * n34\n\t\t\t) +\n\t\t\tn42 * (\n\t\t\t\t+ n11 * n23 * n34\n\t\t\t\t - n11 * n24 * n33\n\t\t\t\t + n14 * n21 * n33\n\t\t\t\t - n13 * n21 * n34\n\t\t\t\t + n13 * n24 * n31\n\t\t\t\t - n14 * n23 * n31\n\t\t\t) +\n\t\t\tn43 * (\n\t\t\t\t+ n11 * n24 * n32\n\t\t\t\t - n11 * n22 * n34\n\t\t\t\t - n14 * n21 * n32\n\t\t\t\t + n12 * n21 * n34\n\t\t\t\t + n14 * n22 * n31\n\t\t\t\t - n12 * n24 * n31\n\t\t\t) +\n\t\t\tn44 * (\n\t\t\t\t- n13 * n22 * n31\n\t\t\t\t - n11 * n23 * n32\n\t\t\t\t + n11 * n22 * n33\n\t\t\t\t + n13 * n21 * n32\n\t\t\t\t - n12 * n21 * n33\n\t\t\t\t + n12 * n23 * n31\n\t\t\t)\n\n\t\t);\n\n\t},\n\n\ttranspose: function () {\n\n\t\tconst te = this.elements;\n\t\tlet tmp;\n\n\t\ttmp = te[ 1 ]; te[ 1 ] = te[ 4 ]; te[ 4 ] = tmp;\n\t\ttmp = te[ 2 ]; te[ 2 ] = te[ 8 ]; te[ 8 ] = tmp;\n\t\ttmp = te[ 6 ]; te[ 6 ] = te[ 9 ]; te[ 9 ] = tmp;\n\n\t\ttmp = te[ 3 ]; te[ 3 ] = te[ 12 ]; te[ 12 ] = tmp;\n\t\ttmp = te[ 7 ]; te[ 7 ] = te[ 13 ]; te[ 13 ] = tmp;\n\t\ttmp = te[ 11 ]; te[ 11 ] = te[ 14 ]; te[ 14 ] = tmp;\n\n\t\treturn this;\n\n\t},\n\n\tsetPosition: function ( x, y, z ) {\n\n\t\tconst te = this.elements;\n\n\t\tif ( x.isVector3 ) {\n\n\t\t\tte[ 12 ] = x.x;\n\t\t\tte[ 13 ] = x.y;\n\t\t\tte[ 14 ] = x.z;\n\n\t\t} else {\n\n\t\t\tte[ 12 ] = x;\n\t\t\tte[ 13 ] = y;\n\t\t\tte[ 14 ] = z;\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tgetInverse: function ( m, throwOnDegenerate ) {\n\n\t\tif ( throwOnDegenerate !== undefined ) {\n\n\t\t\tconsole.warn( \"THREE.Matrix4: .getInverse() can no longer be configured to throw on degenerate.\" );\n\n\t\t}\n\n\t\t// based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm\n\t\tconst te = this.elements,\n\t\t\tme = m.elements,\n\n\t\t\tn11 = me[ 0 ], n21 = me[ 1 ], n31 = me[ 2 ], n41 = me[ 3 ],\n\t\t\tn12 = me[ 4 ], n22 = me[ 5 ], n32 = me[ 6 ], n42 = me[ 7 ],\n\t\t\tn13 = me[ 8 ], n23 = me[ 9 ], n33 = me[ 10 ], n43 = me[ 11 ],\n\t\t\tn14 = me[ 12 ], n24 = me[ 13 ], n34 = me[ 14 ], n44 = me[ 15 ],\n\n\t\t\tt11 = n23 * n34 * n42 - n24 * n33 * n42 + n24 * n32 * n43 - n22 * n34 * n43 - n23 * n32 * n44 + n22 * n33 * n44,\n\t\t\tt12 = n14 * n33 * n42 - n13 * n34 * n42 - n14 * n32 * n43 + n12 * n34 * n43 + n13 * n32 * n44 - n12 * n33 * n44,\n\t\t\tt13 = n13 * n24 * n42 - n14 * n23 * n42 + n14 * n22 * n43 - n12 * n24 * n43 - n13 * n22 * n44 + n12 * n23 * n44,\n\t\t\tt14 = n14 * n23 * n32 - n13 * n24 * n32 - n14 * n22 * n33 + n12 * n24 * n33 + n13 * n22 * n34 - n12 * n23 * n34;\n\n\t\tconst det = n11 * t11 + n21 * t12 + n31 * t13 + n41 * t14;\n\n\t\tif ( det === 0 ) return this.set( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );\n\n\t\tconst detInv = 1 / det;\n\n\t\tte[ 0 ] = t11 * detInv;\n\t\tte[ 1 ] = ( n24 * n33 * n41 - n23 * n34 * n41 - n24 * n31 * n43 + n21 * n34 * n43 + n23 * n31 * n44 - n21 * n33 * n44 ) * detInv;\n\t\tte[ 2 ] = ( n22 * n34 * n41 - n24 * n32 * n41 + n24 * n31 * n42 - n21 * n34 * n42 - n22 * n31 * n44 + n21 * n32 * n44 ) * detInv;\n\t\tte[ 3 ] = ( n23 * n32 * n41 - n22 * n33 * n41 - n23 * n31 * n42 + n21 * n33 * n42 + n22 * n31 * n43 - n21 * n32 * n43 ) * detInv;\n\n\t\tte[ 4 ] = t12 * detInv;\n\t\tte[ 5 ] = ( n13 * n34 * n41 - n14 * n33 * n41 + n14 * n31 * n43 - n11 * n34 * n43 - n13 * n31 * n44 + n11 * n33 * n44 ) * detInv;\n\t\tte[ 6 ] = ( n14 * n32 * n41 - n12 * n34 * n41 - n14 * n31 * n42 + n11 * n34 * n42 + n12 * n31 * n44 - n11 * n32 * n44 ) * detInv;\n\t\tte[ 7 ] = ( n12 * n33 * n41 - n13 * n32 * n41 + n13 * n31 * n42 - n11 * n33 * n42 - n12 * n31 * n43 + n11 * n32 * n43 ) * detInv;\n\n\t\tte[ 8 ] = t13 * detInv;\n\t\tte[ 9 ] = ( n14 * n23 * n41 - n13 * n24 * n41 - n14 * n21 * n43 + n11 * n24 * n43 + n13 * n21 * n44 - n11 * n23 * n44 ) * detInv;\n\t\tte[ 10 ] = ( n12 * n24 * n41 - n14 * n22 * n41 + n14 * n21 * n42 - n11 * n24 * n42 - n12 * n21 * n44 + n11 * n22 * n44 ) * detInv;\n\t\tte[ 11 ] = ( n13 * n22 * n41 - n12 * n23 * n41 - n13 * n21 * n42 + n11 * n23 * n42 + n12 * n21 * n43 - n11 * n22 * n43 ) * detInv;\n\n\t\tte[ 12 ] = t14 * detInv;\n\t\tte[ 13 ] = ( n13 * n24 * n31 - n14 * n23 * n31 + n14 * n21 * n33 - n11 * n24 * n33 - n13 * n21 * n34 + n11 * n23 * n34 ) * detInv;\n\t\tte[ 14 ] = ( n14 * n22 * n31 - n12 * n24 * n31 - n14 * n21 * n32 + n11 * n24 * n32 + n12 * n21 * n34 - n11 * n22 * n34 ) * detInv;\n\t\tte[ 15 ] = ( n12 * n23 * n31 - n13 * n22 * n31 + n13 * n21 * n32 - n11 * n23 * n32 - n12 * n21 * n33 + n11 * n22 * n33 ) * detInv;\n\n\t\treturn this;\n\n\t},\n\n\tscale: function ( v ) {\n\n\t\tconst te = this.elements;\n\t\tconst x = v.x, y = v.y, z = v.z;\n\n\t\tte[ 0 ] *= x; te[ 4 ] *= y; te[ 8 ] *= z;\n\t\tte[ 1 ] *= x; te[ 5 ] *= y; te[ 9 ] *= z;\n\t\tte[ 2 ] *= x; te[ 6 ] *= y; te[ 10 ] *= z;\n\t\tte[ 3 ] *= x; te[ 7 ] *= y; te[ 11 ] *= z;\n\n\t\treturn this;\n\n\t},\n\n\tgetMaxScaleOnAxis: function () {\n\n\t\tconst te = this.elements;\n\n\t\tconst scaleXSq = te[ 0 ] * te[ 0 ] + te[ 1 ] * te[ 1 ] + te[ 2 ] * te[ 2 ];\n\t\tconst scaleYSq = te[ 4 ] * te[ 4 ] + te[ 5 ] * te[ 5 ] + te[ 6 ] * te[ 6 ];\n\t\tconst scaleZSq = te[ 8 ] * te[ 8 ] + te[ 9 ] * te[ 9 ] + te[ 10 ] * te[ 10 ];\n\n\t\treturn Math.sqrt( Math.max( scaleXSq, scaleYSq, scaleZSq ) );\n\n\t},\n\n\tmakeTranslation: function ( x, y, z ) {\n\n\t\tthis.set(\n\n\t\t\t1, 0, 0, x,\n\t\t\t0, 1, 0, y,\n\t\t\t0, 0, 1, z,\n\t\t\t0, 0, 0, 1\n\n\t\t);\n\n\t\treturn this;\n\n\t},\n\n\tmakeRotationX: function ( theta ) {\n\n\t\tconst c = Math.cos( theta ), s = Math.sin( theta );\n\n\t\tthis.set(\n\n\t\t\t1, 0, 0, 0,\n\t\t\t0, c, - s, 0,\n\t\t\t0, s, c, 0,\n\t\t\t0, 0, 0, 1\n\n\t\t);\n\n\t\treturn this;\n\n\t},\n\n\tmakeRotationY: function ( theta ) {\n\n\t\tconst c = Math.cos( theta ), s = Math.sin( theta );\n\n\t\tthis.set(\n\n\t\t\t c, 0, s, 0,\n\t\t\t 0, 1, 0, 0,\n\t\t\t- s, 0, c, 0,\n\t\t\t 0, 0, 0, 1\n\n\t\t);\n\n\t\treturn this;\n\n\t},\n\n\tmakeRotationZ: function ( theta ) {\n\n\t\tconst c = Math.cos( theta ), s = Math.sin( theta );\n\n\t\tthis.set(\n\n\t\t\tc, - s, 0, 0,\n\t\t\ts, c, 0, 0,\n\t\t\t0, 0, 1, 0,\n\t\t\t0, 0, 0, 1\n\n\t\t);\n\n\t\treturn this;\n\n\t},\n\n\tmakeRotationAxis: function ( axis, angle ) {\n\n\t\t// Based on http://www.gamedev.net/reference/articles/article1199.asp\n\n\t\tconst c = Math.cos( angle );\n\t\tconst s = Math.sin( angle );\n\t\tconst t = 1 - c;\n\t\tconst x = axis.x, y = axis.y, z = axis.z;\n\t\tconst tx = t * x, ty = t * y;\n\n\t\tthis.set(\n\n\t\t\ttx * x + c, tx * y - s * z, tx * z + s * y, 0,\n\t\t\ttx * y + s * z, ty * y + c, ty * z - s * x, 0,\n\t\t\ttx * z - s * y, ty * z + s * x, t * z * z + c, 0,\n\t\t\t0, 0, 0, 1\n\n\t\t);\n\n\t\t return this;\n\n\t},\n\n\tmakeScale: function ( x, y, z ) {\n\n\t\tthis.set(\n\n\t\t\tx, 0, 0, 0,\n\t\t\t0, y, 0, 0,\n\t\t\t0, 0, z, 0,\n\t\t\t0, 0, 0, 1\n\n\t\t);\n\n\t\treturn this;\n\n\t},\n\n\tmakeShear: function ( x, y, z ) {\n\n\t\tthis.set(\n\n\t\t\t1, y, z, 0,\n\t\t\tx, 1, z, 0,\n\t\t\tx, y, 1, 0,\n\t\t\t0, 0, 0, 1\n\n\t\t);\n\n\t\treturn this;\n\n\t},\n\n\tcompose: function ( position, quaternion, scale ) {\n\n\t\tconst te = this.elements;\n\n\t\tconst x = quaternion._x, y = quaternion._y, z = quaternion._z, w = quaternion._w;\n\t\tconst x2 = x + x,\ty2 = y + y, z2 = z + z;\n\t\tconst xx = x * x2, xy = x * y2, xz = x * z2;\n\t\tconst yy = y * y2, yz = y * z2, zz = z * z2;\n\t\tconst wx = w * x2, wy = w * y2, wz = w * z2;\n\n\t\tconst sx = scale.x, sy = scale.y, sz = scale.z;\n\n\t\tte[ 0 ] = ( 1 - ( yy + zz ) ) * sx;\n\t\tte[ 1 ] = ( xy + wz ) * sx;\n\t\tte[ 2 ] = ( xz - wy ) * sx;\n\t\tte[ 3 ] = 0;\n\n\t\tte[ 4 ] = ( xy - wz ) * sy;\n\t\tte[ 5 ] = ( 1 - ( xx + zz ) ) * sy;\n\t\tte[ 6 ] = ( yz + wx ) * sy;\n\t\tte[ 7 ] = 0;\n\n\t\tte[ 8 ] = ( xz + wy ) * sz;\n\t\tte[ 9 ] = ( yz - wx ) * sz;\n\t\tte[ 10 ] = ( 1 - ( xx + yy ) ) * sz;\n\t\tte[ 11 ] = 0;\n\n\t\tte[ 12 ] = position.x;\n\t\tte[ 13 ] = position.y;\n\t\tte[ 14 ] = position.z;\n\t\tte[ 15 ] = 1;\n\n\t\treturn this;\n\n\t},\n\n\tdecompose: function ( position, quaternion, scale ) {\n\n\t\tconst te = this.elements;\n\n\t\tlet sx = _v1.set( te[ 0 ], te[ 1 ], te[ 2 ] ).length();\n\t\tlet sy = _v1.set( te[ 4 ], te[ 5 ], te[ 6 ] ).length();\n\t\tlet sz = _v1.set( te[ 8 ], te[ 9 ], te[ 10 ] ).length();\n\n\t\t// if determine is negative, we need to invert one scale\n\t\tconst det = this.determinant();\n\t\tif ( det < 0 ) sx = - sx;\n\n\t\tposition.x = te[ 12 ];\n\t\tposition.y = te[ 13 ];\n\t\tposition.z = te[ 14 ];\n\n\t\t// scale the rotation part\n\t\t_m1.copy( this );\n\n\t\tconst invSX = 1 / sx;\n\t\tconst invSY = 1 / sy;\n\t\tconst invSZ = 1 / sz;\n\n\t\t_m1.elements[ 0 ] *= invSX;\n\t\t_m1.elements[ 1 ] *= invSX;\n\t\t_m1.elements[ 2 ] *= invSX;\n\n\t\t_m1.elements[ 4 ] *= invSY;\n\t\t_m1.elements[ 5 ] *= invSY;\n\t\t_m1.elements[ 6 ] *= invSY;\n\n\t\t_m1.elements[ 8 ] *= invSZ;\n\t\t_m1.elements[ 9 ] *= invSZ;\n\t\t_m1.elements[ 10 ] *= invSZ;\n\n\t\tquaternion.setFromRotationMatrix( _m1 );\n\n\t\tscale.x = sx;\n\t\tscale.y = sy;\n\t\tscale.z = sz;\n\n\t\treturn this;\n\n\t},\n\n\tmakePerspective: function ( left, right, top, bottom, near, far ) {\n\n\t\tif ( far === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.' );\n\n\t\t}\n\n\t\tconst te = this.elements;\n\t\tconst x = 2 * near / ( right - left );\n\t\tconst y = 2 * near / ( top - bottom );\n\n\t\tconst a = ( right + left ) / ( right - left );\n\t\tconst b = ( top + bottom ) / ( top - bottom );\n\t\tconst c = - ( far + near ) / ( far - near );\n\t\tconst d = - 2 * far * near / ( far - near );\n\n\t\tte[ 0 ] = x;\tte[ 4 ] = 0;\tte[ 8 ] = a;\tte[ 12 ] = 0;\n\t\tte[ 1 ] = 0;\tte[ 5 ] = y;\tte[ 9 ] = b;\tte[ 13 ] = 0;\n\t\tte[ 2 ] = 0;\tte[ 6 ] = 0;\tte[ 10 ] = c;\tte[ 14 ] = d;\n\t\tte[ 3 ] = 0;\tte[ 7 ] = 0;\tte[ 11 ] = - 1;\tte[ 15 ] = 0;\n\n\t\treturn this;\n\n\t},\n\n\tmakeOrthographic: function ( left, right, top, bottom, near, far ) {\n\n\t\tconst te = this.elements;\n\t\tconst w = 1.0 / ( right - left );\n\t\tconst h = 1.0 / ( top - bottom );\n\t\tconst p = 1.0 / ( far - near );\n\n\t\tconst x = ( right + left ) * w;\n\t\tconst y = ( top + bottom ) * h;\n\t\tconst z = ( far + near ) * p;\n\n\t\tte[ 0 ] = 2 * w;\tte[ 4 ] = 0;\tte[ 8 ] = 0;\tte[ 12 ] = - x;\n\t\tte[ 1 ] = 0;\tte[ 5 ] = 2 * h;\tte[ 9 ] = 0;\tte[ 13 ] = - y;\n\t\tte[ 2 ] = 0;\tte[ 6 ] = 0;\tte[ 10 ] = - 2 * p;\tte[ 14 ] = - z;\n\t\tte[ 3 ] = 0;\tte[ 7 ] = 0;\tte[ 11 ] = 0;\tte[ 15 ] = 1;\n\n\t\treturn this;\n\n\t},\n\n\tequals: function ( matrix ) {\n\n\t\tconst te = this.elements;\n\t\tconst me = matrix.elements;\n\n\t\tfor ( let i = 0; i < 16; i ++ ) {\n\n\t\t\tif ( te[ i ] !== me[ i ] ) return false;\n\n\t\t}\n\n\t\treturn true;\n\n\t},\n\n\tfromArray: function ( array, offset ) {\n\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tfor ( let i = 0; i < 16; i ++ ) {\n\n\t\t\tthis.elements[ i ] = array[ i + offset ];\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\ttoArray: function ( array, offset ) {\n\n\t\tif ( array === undefined ) array = [];\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tconst te = this.elements;\n\n\t\tarray[ offset ] = te[ 0 ];\n\t\tarray[ offset + 1 ] = te[ 1 ];\n\t\tarray[ offset + 2 ] = te[ 2 ];\n\t\tarray[ offset + 3 ] = te[ 3 ];\n\n\t\tarray[ offset + 4 ] = te[ 4 ];\n\t\tarray[ offset + 5 ] = te[ 5 ];\n\t\tarray[ offset + 6 ] = te[ 6 ];\n\t\tarray[ offset + 7 ] = te[ 7 ];\n\n\t\tarray[ offset + 8 ] = te[ 8 ];\n\t\tarray[ offset + 9 ] = te[ 9 ];\n\t\tarray[ offset + 10 ] = te[ 10 ];\n\t\tarray[ offset + 11 ] = te[ 11 ];\n\n\t\tarray[ offset + 12 ] = te[ 12 ];\n\t\tarray[ offset + 13 ] = te[ 13 ];\n\t\tarray[ offset + 14 ] = te[ 14 ];\n\t\tarray[ offset + 15 ] = te[ 15 ];\n\n\t\treturn array;\n\n\t}\n\n} );\n\n\nexport { Matrix4 };\n","import { Quaternion } from './Quaternion.js';\nimport { Vector3 } from './Vector3.js';\nimport { Matrix4 } from './Matrix4.js';\nimport { MathUtils } from './MathUtils.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author WestLangley / http://github.com/WestLangley\n * @author bhouston / http://clara.io\n */\n\nconst _matrix = new Matrix4();\nconst _quaternion = new Quaternion();\n\nfunction Euler( x = 0, y = 0, z = 0, order = Euler.DefaultOrder ) {\n\n\tthis._x = x;\n\tthis._y = y;\n\tthis._z = z;\n\tthis._order = order;\n\n}\n\nEuler.RotationOrders = [ 'XYZ', 'YZX', 'ZXY', 'XZY', 'YXZ', 'ZYX' ];\n\nEuler.DefaultOrder = 'XYZ';\n\nObject.defineProperties( Euler.prototype, {\n\n\tx: {\n\n\t\tget: function () {\n\n\t\t\treturn this._x;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tthis._x = value;\n\t\t\tthis._onChangeCallback();\n\n\t\t}\n\n\t},\n\n\ty: {\n\n\t\tget: function () {\n\n\t\t\treturn this._y;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tthis._y = value;\n\t\t\tthis._onChangeCallback();\n\n\t\t}\n\n\t},\n\n\tz: {\n\n\t\tget: function () {\n\n\t\t\treturn this._z;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tthis._z = value;\n\t\t\tthis._onChangeCallback();\n\n\t\t}\n\n\t},\n\n\torder: {\n\n\t\tget: function () {\n\n\t\t\treturn this._order;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tthis._order = value;\n\t\t\tthis._onChangeCallback();\n\n\t\t}\n\n\t}\n\n} );\n\nObject.assign( Euler.prototype, {\n\n\tisEuler: true,\n\n\tset: function ( x, y, z, order ) {\n\n\t\tthis._x = x;\n\t\tthis._y = y;\n\t\tthis._z = z;\n\t\tthis._order = order || this._order;\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor( this._x, this._y, this._z, this._order );\n\n\t},\n\n\tcopy: function ( euler ) {\n\n\t\tthis._x = euler._x;\n\t\tthis._y = euler._y;\n\t\tthis._z = euler._z;\n\t\tthis._order = euler._order;\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\tsetFromRotationMatrix: function ( m, order, update ) {\n\n\t\tconst clamp = MathUtils.clamp;\n\n\t\t// assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)\n\n\t\tconst te = m.elements;\n\t\tconst m11 = te[ 0 ], m12 = te[ 4 ], m13 = te[ 8 ];\n\t\tconst m21 = te[ 1 ], m22 = te[ 5 ], m23 = te[ 9 ];\n\t\tconst m31 = te[ 2 ], m32 = te[ 6 ], m33 = te[ 10 ];\n\n\t\torder = order || this._order;\n\n\t\tswitch ( order ) {\n\n\t\t\tcase 'XYZ':\n\n\t\t\t\tthis._y = Math.asin( clamp( m13, - 1, 1 ) );\n\n\t\t\t\tif ( Math.abs( m13 ) < 0.9999999 ) {\n\n\t\t\t\t\tthis._x = Math.atan2( - m23, m33 );\n\t\t\t\t\tthis._z = Math.atan2( - m12, m11 );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tthis._x = Math.atan2( m32, m22 );\n\t\t\t\t\tthis._z = 0;\n\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\n\t\t\tcase 'YXZ':\n\n\t\t\t\tthis._x = Math.asin( - clamp( m23, - 1, 1 ) );\n\n\t\t\t\tif ( Math.abs( m23 ) < 0.9999999 ) {\n\n\t\t\t\t\tthis._y = Math.atan2( m13, m33 );\n\t\t\t\t\tthis._z = Math.atan2( m21, m22 );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tthis._y = Math.atan2( - m31, m11 );\n\t\t\t\t\tthis._z = 0;\n\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\n\t\t\tcase 'ZXY':\n\n\t\t\t\tthis._x = Math.asin( clamp( m32, - 1, 1 ) );\n\n\t\t\t\tif ( Math.abs( m32 ) < 0.9999999 ) {\n\n\t\t\t\t\tthis._y = Math.atan2( - m31, m33 );\n\t\t\t\t\tthis._z = Math.atan2( - m12, m22 );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tthis._y = 0;\n\t\t\t\t\tthis._z = Math.atan2( m21, m11 );\n\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\n\t\t\tcase 'ZYX':\n\n\t\t\t\tthis._y = Math.asin( - clamp( m31, - 1, 1 ) );\n\n\t\t\t\tif ( Math.abs( m31 ) < 0.9999999 ) {\n\n\t\t\t\t\tthis._x = Math.atan2( m32, m33 );\n\t\t\t\t\tthis._z = Math.atan2( m21, m11 );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tthis._x = 0;\n\t\t\t\t\tthis._z = Math.atan2( - m12, m22 );\n\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\n\t\t\tcase 'YZX':\n\n\t\t\t\tthis._z = Math.asin( clamp( m21, - 1, 1 ) );\n\n\t\t\t\tif ( Math.abs( m21 ) < 0.9999999 ) {\n\n\t\t\t\t\tthis._x = Math.atan2( - m23, m22 );\n\t\t\t\t\tthis._y = Math.atan2( - m31, m11 );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tthis._x = 0;\n\t\t\t\t\tthis._y = Math.atan2( m13, m33 );\n\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\n\t\t\tcase 'XZY':\n\n\t\t\t\tthis._z = Math.asin( - clamp( m12, - 1, 1 ) );\n\n\t\t\t\tif ( Math.abs( m12 ) < 0.9999999 ) {\n\n\t\t\t\t\tthis._x = Math.atan2( m32, m22 );\n\t\t\t\t\tthis._y = Math.atan2( m13, m11 );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tthis._x = Math.atan2( - m23, m33 );\n\t\t\t\t\tthis._y = 0;\n\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\n\t\t\t\tconsole.warn( 'THREE.Euler: .setFromRotationMatrix() encountered an unknown order: ' + order );\n\n\t\t}\n\n\t\tthis._order = order;\n\n\t\tif ( update !== false ) this._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\tsetFromQuaternion: function ( q, order, update ) {\n\n\t\t_matrix.makeRotationFromQuaternion( q );\n\n\t\treturn this.setFromRotationMatrix( _matrix, order, update );\n\n\t},\n\n\tsetFromVector3: function ( v, order ) {\n\n\t\treturn this.set( v.x, v.y, v.z, order || this._order );\n\n\t},\n\n\treorder: function ( newOrder ) {\n\n\t\t// WARNING: this discards revolution information -bhouston\n\n\t\t_quaternion.setFromEuler( this );\n\n\t\treturn this.setFromQuaternion( _quaternion, newOrder );\n\n\t},\n\n\tequals: function ( euler ) {\n\n\t\treturn ( euler._x === this._x ) && ( euler._y === this._y ) && ( euler._z === this._z ) && ( euler._order === this._order );\n\n\t},\n\n\tfromArray: function ( array ) {\n\n\t\tthis._x = array[ 0 ];\n\t\tthis._y = array[ 1 ];\n\t\tthis._z = array[ 2 ];\n\t\tif ( array[ 3 ] !== undefined ) this._order = array[ 3 ];\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\ttoArray: function ( array, offset ) {\n\n\t\tif ( array === undefined ) array = [];\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tarray[ offset ] = this._x;\n\t\tarray[ offset + 1 ] = this._y;\n\t\tarray[ offset + 2 ] = this._z;\n\t\tarray[ offset + 3 ] = this._order;\n\n\t\treturn array;\n\n\t},\n\n\ttoVector3: function ( optionalResult ) {\n\n\t\tif ( optionalResult ) {\n\n\t\t\treturn optionalResult.set( this._x, this._y, this._z );\n\n\t\t} else {\n\n\t\t\treturn new Vector3( this._x, this._y, this._z );\n\n\t\t}\n\n\t},\n\n\t_onChange: function ( callback ) {\n\n\t\tthis._onChangeCallback = callback;\n\n\t\treturn this;\n\n\t},\n\n\t_onChangeCallback: function () {}\n\n} );\n\n\nexport { Euler };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction Layers() {\n\n\tthis.mask = 1 | 0;\n\n}\n\nObject.assign( Layers.prototype, {\n\n\tset: function ( channel ) {\n\n\t\tthis.mask = 1 << channel | 0;\n\n\t},\n\n\tenable: function ( channel ) {\n\n\t\tthis.mask |= 1 << channel | 0;\n\n\t},\n\n\tenableAll: function () {\n\n\t\tthis.mask = 0xffffffff | 0;\n\n\t},\n\n\ttoggle: function ( channel ) {\n\n\t\tthis.mask ^= 1 << channel | 0;\n\n\t},\n\n\tdisable: function ( channel ) {\n\n\t\tthis.mask &= ~ ( 1 << channel | 0 );\n\n\t},\n\n\tdisableAll: function () {\n\n\t\tthis.mask = 0;\n\n\t},\n\n\ttest: function ( layers ) {\n\n\t\treturn ( this.mask & layers.mask ) !== 0;\n\n\t}\n\n} );\n\n\nexport { Layers };\n","import { Quaternion } from '../math/Quaternion.js';\nimport { Vector3 } from '../math/Vector3.js';\nimport { Matrix4 } from '../math/Matrix4.js';\nimport { EventDispatcher } from './EventDispatcher.js';\nimport { Euler } from '../math/Euler.js';\nimport { Layers } from './Layers.js';\nimport { Matrix3 } from '../math/Matrix3.js';\nimport { MathUtils } from '../math/MathUtils.js';\n\nlet _object3DId = 0;\n\nconst _v1 = new Vector3();\nconst _q1 = new Quaternion();\nconst _m1 = new Matrix4();\nconst _target = new Vector3();\n\nconst _position = new Vector3();\nconst _scale = new Vector3();\nconst _quaternion = new Quaternion();\n\nconst _xAxis = new Vector3( 1, 0, 0 );\nconst _yAxis = new Vector3( 0, 1, 0 );\nconst _zAxis = new Vector3( 0, 0, 1 );\n\nconst _addedEvent = { type: 'added' };\nconst _removedEvent = { type: 'removed' };\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author mikael emtinger / http://gomo.se/\n * @author alteredq / http://alteredqualia.com/\n * @author WestLangley / http://github.com/WestLangley\n * @author elephantatwork / www.elephantatwork.ch\n */\n\nfunction Object3D() {\n\n\tObject.defineProperty( this, 'id', { value: _object3DId ++ } );\n\n\tthis.uuid = MathUtils.generateUUID();\n\n\tthis.name = '';\n\tthis.type = 'Object3D';\n\n\tthis.parent = null;\n\tthis.children = [];\n\n\tthis.up = Object3D.DefaultUp.clone();\n\n\tconst position = new Vector3();\n\tconst rotation = new Euler();\n\tconst quaternion = new Quaternion();\n\tconst scale = new Vector3( 1, 1, 1 );\n\n\tfunction onRotationChange() {\n\n\t\tquaternion.setFromEuler( rotation, false );\n\n\t}\n\n\tfunction onQuaternionChange() {\n\n\t\trotation.setFromQuaternion( quaternion, undefined, false );\n\n\t}\n\n\trotation._onChange( onRotationChange );\n\tquaternion._onChange( onQuaternionChange );\n\n\tObject.defineProperties( this, {\n\t\tposition: {\n\t\t\tconfigurable: true,\n\t\t\tenumerable: true,\n\t\t\tvalue: position\n\t\t},\n\t\trotation: {\n\t\t\tconfigurable: true,\n\t\t\tenumerable: true,\n\t\t\tvalue: rotation\n\t\t},\n\t\tquaternion: {\n\t\t\tconfigurable: true,\n\t\t\tenumerable: true,\n\t\t\tvalue: quaternion\n\t\t},\n\t\tscale: {\n\t\t\tconfigurable: true,\n\t\t\tenumerable: true,\n\t\t\tvalue: scale\n\t\t},\n\t\tmodelViewMatrix: {\n\t\t\tvalue: new Matrix4()\n\t\t},\n\t\tnormalMatrix: {\n\t\t\tvalue: new Matrix3()\n\t\t}\n\t} );\n\n\tthis.matrix = new Matrix4();\n\tthis.matrixWorld = new Matrix4();\n\n\tthis.matrixAutoUpdate = Object3D.DefaultMatrixAutoUpdate;\n\tthis.matrixWorldNeedsUpdate = false;\n\n\tthis.layers = new Layers();\n\tthis.visible = true;\n\n\tthis.castShadow = false;\n\tthis.receiveShadow = false;\n\n\tthis.frustumCulled = true;\n\tthis.renderOrder = 0;\n\n\tthis.userData = {};\n\n}\n\nObject3D.DefaultUp = new Vector3( 0, 1, 0 );\nObject3D.DefaultMatrixAutoUpdate = true;\n\nObject3D.prototype = Object.assign( Object.create( EventDispatcher.prototype ), {\n\n\tconstructor: Object3D,\n\n\tisObject3D: true,\n\n\tonBeforeRender: function () {},\n\tonAfterRender: function () {},\n\n\tapplyMatrix4: function ( matrix ) {\n\n\t\tif ( this.matrixAutoUpdate ) this.updateMatrix();\n\n\t\tthis.matrix.premultiply( matrix );\n\n\t\tthis.matrix.decompose( this.position, this.quaternion, this.scale );\n\n\t},\n\n\tapplyQuaternion: function ( q ) {\n\n\t\tthis.quaternion.premultiply( q );\n\n\t\treturn this;\n\n\t},\n\n\tsetRotationFromAxisAngle: function ( axis, angle ) {\n\n\t\t// assumes axis is normalized\n\n\t\tthis.quaternion.setFromAxisAngle( axis, angle );\n\n\t},\n\n\tsetRotationFromEuler: function ( euler ) {\n\n\t\tthis.quaternion.setFromEuler( euler, true );\n\n\t},\n\n\tsetRotationFromMatrix: function ( m ) {\n\n\t\t// assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)\n\n\t\tthis.quaternion.setFromRotationMatrix( m );\n\n\t},\n\n\tsetRotationFromQuaternion: function ( q ) {\n\n\t\t// assumes q is normalized\n\n\t\tthis.quaternion.copy( q );\n\n\t},\n\n\trotateOnAxis: function ( axis, angle ) {\n\n\t\t// rotate object on axis in object space\n\t\t// axis is assumed to be normalized\n\n\t\t_q1.setFromAxisAngle( axis, angle );\n\n\t\tthis.quaternion.multiply( _q1 );\n\n\t\treturn this;\n\n\t},\n\n\trotateOnWorldAxis: function ( axis, angle ) {\n\n\t\t// rotate object on axis in world space\n\t\t// axis is assumed to be normalized\n\t\t// method assumes no rotated parent\n\n\t\t_q1.setFromAxisAngle( axis, angle );\n\n\t\tthis.quaternion.premultiply( _q1 );\n\n\t\treturn this;\n\n\t},\n\n\trotateX: function ( angle ) {\n\n\t\treturn this.rotateOnAxis( _xAxis, angle );\n\n\t},\n\n\trotateY: function ( angle ) {\n\n\t\treturn this.rotateOnAxis( _yAxis, angle );\n\n\t},\n\n\trotateZ: function ( angle ) {\n\n\t\treturn this.rotateOnAxis( _zAxis, angle );\n\n\t},\n\n\ttranslateOnAxis: function ( axis, distance ) {\n\n\t\t// translate object by distance along axis in object space\n\t\t// axis is assumed to be normalized\n\n\t\t_v1.copy( axis ).applyQuaternion( this.quaternion );\n\n\t\tthis.position.add( _v1.multiplyScalar( distance ) );\n\n\t\treturn this;\n\n\t},\n\n\ttranslateX: function ( distance ) {\n\n\t\treturn this.translateOnAxis( _xAxis, distance );\n\n\t},\n\n\ttranslateY: function ( distance ) {\n\n\t\treturn this.translateOnAxis( _yAxis, distance );\n\n\t},\n\n\ttranslateZ: function ( distance ) {\n\n\t\treturn this.translateOnAxis( _zAxis, distance );\n\n\t},\n\n\tlocalToWorld: function ( vector ) {\n\n\t\treturn vector.applyMatrix4( this.matrixWorld );\n\n\t},\n\n\tworldToLocal: function ( vector ) {\n\n\t\treturn vector.applyMatrix4( _m1.getInverse( this.matrixWorld ) );\n\n\t},\n\n\tlookAt: function ( x, y, z ) {\n\n\t\t// This method does not support objects having non-uniformly-scaled parent(s)\n\n\t\tif ( x.isVector3 ) {\n\n\t\t\t_target.copy( x );\n\n\t\t} else {\n\n\t\t\t_target.set( x, y, z );\n\n\t\t}\n\n\t\tconst parent = this.parent;\n\n\t\tthis.updateWorldMatrix( true, false );\n\n\t\t_position.setFromMatrixPosition( this.matrixWorld );\n\n\t\tif ( this.isCamera || this.isLight ) {\n\n\t\t\t_m1.lookAt( _position, _target, this.up );\n\n\t\t} else {\n\n\t\t\t_m1.lookAt( _target, _position, this.up );\n\n\t\t}\n\n\t\tthis.quaternion.setFromRotationMatrix( _m1 );\n\n\t\tif ( parent ) {\n\n\t\t\t_m1.extractRotation( parent.matrixWorld );\n\t\t\t_q1.setFromRotationMatrix( _m1 );\n\t\t\tthis.quaternion.premultiply( _q1.inverse() );\n\n\t\t}\n\n\t},\n\n\tadd: function ( object ) {\n\n\t\tif ( arguments.length > 1 ) {\n\n\t\t\tfor ( let i = 0; i < arguments.length; i ++ ) {\n\n\t\t\t\tthis.add( arguments[ i ] );\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t}\n\n\t\tif ( object === this ) {\n\n\t\t\tconsole.error( \"THREE.Object3D.add: object can't be added as a child of itself.\", object );\n\t\t\treturn this;\n\n\t\t}\n\n\t\tif ( ( object && object.isObject3D ) ) {\n\n\t\t\tif ( object.parent !== null ) {\n\n\t\t\t\tobject.parent.remove( object );\n\n\t\t\t}\n\n\t\t\tobject.parent = this;\n\t\t\tthis.children.push( object );\n\n\t\t\tobject.dispatchEvent( _addedEvent );\n\n\t\t} else {\n\n\t\t\tconsole.error( \"THREE.Object3D.add: object not an instance of THREE.Object3D.\", object );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tremove: function ( object ) {\n\n\t\tif ( arguments.length > 1 ) {\n\n\t\t\tfor ( let i = 0; i < arguments.length; i ++ ) {\n\n\t\t\t\tthis.remove( arguments[ i ] );\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t}\n\n\t\tconst index = this.children.indexOf( object );\n\n\t\tif ( index !== - 1 ) {\n\n\t\t\tobject.parent = null;\n\t\t\tthis.children.splice( index, 1 );\n\n\t\t\tobject.dispatchEvent( _removedEvent );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tattach: function ( object ) {\n\n\t\t// adds object as a child of this, while maintaining the object's world transform\n\n\t\tthis.updateWorldMatrix( true, false );\n\n\t\t_m1.getInverse( this.matrixWorld );\n\n\t\tif ( object.parent !== null ) {\n\n\t\t\tobject.parent.updateWorldMatrix( true, false );\n\n\t\t\t_m1.multiply( object.parent.matrixWorld );\n\n\t\t}\n\n\t\tobject.applyMatrix4( _m1 );\n\n\t\tobject.updateWorldMatrix( false, false );\n\n\t\tthis.add( object );\n\n\t\treturn this;\n\n\t},\n\n\tgetObjectById: function ( id ) {\n\n\t\treturn this.getObjectByProperty( 'id', id );\n\n\t},\n\n\tgetObjectByName: function ( name ) {\n\n\t\treturn this.getObjectByProperty( 'name', name );\n\n\t},\n\n\tgetObjectByProperty: function ( name, value ) {\n\n\t\tif ( this[ name ] === value ) return this;\n\n\t\tfor ( let i = 0, l = this.children.length; i < l; i ++ ) {\n\n\t\t\tconst child = this.children[ i ];\n\t\t\tconst object = child.getObjectByProperty( name, value );\n\n\t\t\tif ( object !== undefined ) {\n\n\t\t\t\treturn object;\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn undefined;\n\n\t},\n\n\tgetWorldPosition: function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Object3D: .getWorldPosition() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\tthis.updateMatrixWorld( true );\n\n\t\treturn target.setFromMatrixPosition( this.matrixWorld );\n\n\t},\n\n\tgetWorldQuaternion: function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Object3D: .getWorldQuaternion() target is now required' );\n\t\t\ttarget = new Quaternion();\n\n\t\t}\n\n\t\tthis.updateMatrixWorld( true );\n\n\t\tthis.matrixWorld.decompose( _position, target, _scale );\n\n\t\treturn target;\n\n\t},\n\n\tgetWorldScale: function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Object3D: .getWorldScale() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\tthis.updateMatrixWorld( true );\n\n\t\tthis.matrixWorld.decompose( _position, _quaternion, target );\n\n\t\treturn target;\n\n\t},\n\n\tgetWorldDirection: function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Object3D: .getWorldDirection() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\tthis.updateMatrixWorld( true );\n\n\t\tconst e = this.matrixWorld.elements;\n\n\t\treturn target.set( e[ 8 ], e[ 9 ], e[ 10 ] ).normalize();\n\n\t},\n\n\traycast: function () {},\n\n\ttraverse: function ( callback ) {\n\n\t\tcallback( this );\n\n\t\tconst children = this.children;\n\n\t\tfor ( let i = 0, l = children.length; i < l; i ++ ) {\n\n\t\t\tchildren[ i ].traverse( callback );\n\n\t\t}\n\n\t},\n\n\ttraverseVisible: function ( callback ) {\n\n\t\tif ( this.visible === false ) return;\n\n\t\tcallback( this );\n\n\t\tconst children = this.children;\n\n\t\tfor ( let i = 0, l = children.length; i < l; i ++ ) {\n\n\t\t\tchildren[ i ].traverseVisible( callback );\n\n\t\t}\n\n\t},\n\n\ttraverseAncestors: function ( callback ) {\n\n\t\tconst parent = this.parent;\n\n\t\tif ( parent !== null ) {\n\n\t\t\tcallback( parent );\n\n\t\t\tparent.traverseAncestors( callback );\n\n\t\t}\n\n\t},\n\n\tupdateMatrix: function () {\n\n\t\tthis.matrix.compose( this.position, this.quaternion, this.scale );\n\n\t\tthis.matrixWorldNeedsUpdate = true;\n\n\t},\n\n\tupdateMatrixWorld: function ( force ) {\n\n\t\tif ( this.matrixAutoUpdate ) this.updateMatrix();\n\n\t\tif ( this.matrixWorldNeedsUpdate || force ) {\n\n\t\t\tif ( this.parent === null ) {\n\n\t\t\t\tthis.matrixWorld.copy( this.matrix );\n\n\t\t\t} else {\n\n\t\t\t\tthis.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix );\n\n\t\t\t}\n\n\t\t\tthis.matrixWorldNeedsUpdate = false;\n\n\t\t\tforce = true;\n\n\t\t}\n\n\t\t// update children\n\n\t\tconst children = this.children;\n\n\t\tfor ( let i = 0, l = children.length; i < l; i ++ ) {\n\n\t\t\tchildren[ i ].updateMatrixWorld( force );\n\n\t\t}\n\n\t},\n\n\tupdateWorldMatrix: function ( updateParents, updateChildren ) {\n\n\t\tconst parent = this.parent;\n\n\t\tif ( updateParents === true && parent !== null ) {\n\n\t\t\tparent.updateWorldMatrix( true, false );\n\n\t\t}\n\n\t\tif ( this.matrixAutoUpdate ) this.updateMatrix();\n\n\t\tif ( this.parent === null ) {\n\n\t\t\tthis.matrixWorld.copy( this.matrix );\n\n\t\t} else {\n\n\t\t\tthis.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix );\n\n\t\t}\n\n\t\t// update children\n\n\t\tif ( updateChildren === true ) {\n\n\t\t\tconst children = this.children;\n\n\t\t\tfor ( let i = 0, l = children.length; i < l; i ++ ) {\n\n\t\t\t\tchildren[ i ].updateWorldMatrix( false, true );\n\n\t\t\t}\n\n\t\t}\n\n\t},\n\n\ttoJSON: function ( meta ) {\n\n\t\t// meta is a string when called from JSON.stringify\n\t\tconst isRootObject = ( meta === undefined || typeof meta === 'string' );\n\n\t\tconst output = {};\n\n\t\t// meta is a hash used to collect geometries, materials.\n\t\t// not providing it implies that this is the root object\n\t\t// being serialized.\n\t\tif ( isRootObject ) {\n\n\t\t\t// initialize meta obj\n\t\t\tmeta = {\n\t\t\t\tgeometries: {},\n\t\t\t\tmaterials: {},\n\t\t\t\ttextures: {},\n\t\t\t\timages: {},\n\t\t\t\tshapes: {}\n\t\t\t};\n\n\t\t\toutput.metadata = {\n\t\t\t\tversion: 4.5,\n\t\t\t\ttype: 'Object',\n\t\t\t\tgenerator: 'Object3D.toJSON'\n\t\t\t};\n\n\t\t}\n\n\t\t// standard Object3D serialization\n\n\t\tconst object = {};\n\n\t\tobject.uuid = this.uuid;\n\t\tobject.type = this.type;\n\n\t\tif ( this.name !== '' ) object.name = this.name;\n\t\tif ( this.castShadow === true ) object.castShadow = true;\n\t\tif ( this.receiveShadow === true ) object.receiveShadow = true;\n\t\tif ( this.visible === false ) object.visible = false;\n\t\tif ( this.frustumCulled === false ) object.frustumCulled = false;\n\t\tif ( this.renderOrder !== 0 ) object.renderOrder = this.renderOrder;\n\t\tif ( JSON.stringify( this.userData ) !== '{}' ) object.userData = this.userData;\n\n\t\tobject.layers = this.layers.mask;\n\t\tobject.matrix = this.matrix.toArray();\n\n\t\tif ( this.matrixAutoUpdate === false ) object.matrixAutoUpdate = false;\n\n\t\t// object specific properties\n\n\t\tif ( this.isInstancedMesh ) {\n\n\t\t\tobject.type = 'InstancedMesh';\n\t\t\tobject.count = this.count;\n\t\t\tobject.instanceMatrix = this.instanceMatrix.toJSON();\n\n\t\t}\n\n\t\t//\n\n\t\tfunction serialize( library, element ) {\n\n\t\t\tif ( library[ element.uuid ] === undefined ) {\n\n\t\t\t\tlibrary[ element.uuid ] = element.toJSON( meta );\n\n\t\t\t}\n\n\t\t\treturn element.uuid;\n\n\t\t}\n\n\t\tif ( this.isMesh || this.isLine || this.isPoints ) {\n\n\t\t\tobject.geometry = serialize( meta.geometries, this.geometry );\n\n\t\t\tconst parameters = this.geometry.parameters;\n\n\t\t\tif ( parameters !== undefined && parameters.shapes !== undefined ) {\n\n\t\t\t\tconst shapes = parameters.shapes;\n\n\t\t\t\tif ( Array.isArray( shapes ) ) {\n\n\t\t\t\t\tfor ( let i = 0, l = shapes.length; i < l; i ++ ) {\n\n\t\t\t\t\t\tconst shape = shapes[ i ];\n\n\t\t\t\t\t\tserialize( meta.shapes, shape );\n\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\n\t\t\t\t\tserialize( meta.shapes, shapes );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( this.material !== undefined ) {\n\n\t\t\tif ( Array.isArray( this.material ) ) {\n\n\t\t\t\tconst uuids = [];\n\n\t\t\t\tfor ( let i = 0, l = this.material.length; i < l; i ++ ) {\n\n\t\t\t\t\tuuids.push( serialize( meta.materials, this.material[ i ] ) );\n\n\t\t\t\t}\n\n\t\t\t\tobject.material = uuids;\n\n\t\t\t} else {\n\n\t\t\t\tobject.material = serialize( meta.materials, this.material );\n\n\t\t\t}\n\n\t\t}\n\n\t\t//\n\n\t\tif ( this.children.length > 0 ) {\n\n\t\t\tobject.children = [];\n\n\t\t\tfor ( let i = 0; i < this.children.length; i ++ ) {\n\n\t\t\t\tobject.children.push( this.children[ i ].toJSON( meta ).object );\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( isRootObject ) {\n\n\t\t\tconst geometries = extractFromCache( meta.geometries );\n\t\t\tconst materials = extractFromCache( meta.materials );\n\t\t\tconst textures = extractFromCache( meta.textures );\n\t\t\tconst images = extractFromCache( meta.images );\n\t\t\tconst shapes = extractFromCache( meta.shapes );\n\n\t\t\tif ( geometries.length > 0 ) output.geometries = geometries;\n\t\t\tif ( materials.length > 0 ) output.materials = materials;\n\t\t\tif ( textures.length > 0 ) output.textures = textures;\n\t\t\tif ( images.length > 0 ) output.images = images;\n\t\t\tif ( shapes.length > 0 ) output.shapes = shapes;\n\n\t\t}\n\n\t\toutput.object = object;\n\n\t\treturn output;\n\n\t\t// extract data from the cache hash\n\t\t// remove metadata on each item\n\t\t// and return as array\n\t\tfunction extractFromCache( cache ) {\n\n\t\t\tconst values = [];\n\t\t\tfor ( const key in cache ) {\n\n\t\t\t\tconst data = cache[ key ];\n\t\t\t\tdelete data.metadata;\n\t\t\t\tvalues.push( data );\n\n\t\t\t}\n\n\t\t\treturn values;\n\n\t\t}\n\n\t},\n\n\tclone: function ( recursive ) {\n\n\t\treturn new this.constructor().copy( this, recursive );\n\n\t},\n\n\tcopy: function ( source, recursive ) {\n\n\t\tif ( recursive === undefined ) recursive = true;\n\n\t\tthis.name = source.name;\n\n\t\tthis.up.copy( source.up );\n\n\t\tthis.position.copy( source.position );\n\t\tthis.quaternion.copy( source.quaternion );\n\t\tthis.scale.copy( source.scale );\n\n\t\tthis.matrix.copy( source.matrix );\n\t\tthis.matrixWorld.copy( source.matrixWorld );\n\n\t\tthis.matrixAutoUpdate = source.matrixAutoUpdate;\n\t\tthis.matrixWorldNeedsUpdate = source.matrixWorldNeedsUpdate;\n\n\t\tthis.layers.mask = source.layers.mask;\n\t\tthis.visible = source.visible;\n\n\t\tthis.castShadow = source.castShadow;\n\t\tthis.receiveShadow = source.receiveShadow;\n\n\t\tthis.frustumCulled = source.frustumCulled;\n\t\tthis.renderOrder = source.renderOrder;\n\n\t\tthis.userData = JSON.parse( JSON.stringify( source.userData ) );\n\n\t\tif ( recursive === true ) {\n\n\t\t\tfor ( let i = 0; i < source.children.length; i ++ ) {\n\n\t\t\t\tconst child = source.children[ i ];\n\t\t\t\tthis.add( child.clone() );\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn this;\n\n\t}\n\n} );\n\n\nexport { Object3D };\n","import { Object3D } from '../core/Object3D.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction Scene() {\n\n\tObject3D.call( this );\n\n\tthis.type = 'Scene';\n\n\tthis.background = null;\n\tthis.environment = null;\n\tthis.fog = null;\n\n\tthis.overrideMaterial = null;\n\n\tthis.autoUpdate = true; // checked by the renderer\n\n\tif ( typeof __THREE_DEVTOOLS__ !== 'undefined' ) {\n\n\t\t__THREE_DEVTOOLS__.dispatchEvent( new CustomEvent( 'observe', { detail: this } ) ); // eslint-disable-line no-undef\n\n\t}\n\n}\n\nScene.prototype = Object.assign( Object.create( Object3D.prototype ), {\n\n\tconstructor: Scene,\n\n\tisScene: true,\n\n\tcopy: function ( source, recursive ) {\n\n\t\tObject3D.prototype.copy.call( this, source, recursive );\n\n\t\tif ( source.background !== null ) this.background = source.background.clone();\n\t\tif ( source.environment !== null ) this.environment = source.environment.clone();\n\t\tif ( source.fog !== null ) this.fog = source.fog.clone();\n\n\t\tif ( source.overrideMaterial !== null ) this.overrideMaterial = source.overrideMaterial.clone();\n\n\t\tthis.autoUpdate = source.autoUpdate;\n\t\tthis.matrixAutoUpdate = source.matrixAutoUpdate;\n\n\t\treturn this;\n\n\t},\n\n\ttoJSON: function ( meta ) {\n\n\t\tconst data = Object3D.prototype.toJSON.call( this, meta );\n\n\t\tif ( this.background !== null ) data.object.background = this.background.toJSON( meta );\n\t\tif ( this.environment !== null ) data.object.environment = this.environment.toJSON( meta );\n\t\tif ( this.fog !== null ) data.object.fog = this.fog.toJSON();\n\n\t\treturn data;\n\n\t},\n\n\tdispose: function () {\n\n\t\tthis.dispatchEvent( { type: 'dispose' } );\n\n\t}\n\n} );\n\n\n\nexport { Scene };\n","import { Vector3 } from './Vector3.js';\n\nconst _points = [\n\tnew Vector3(),\n\tnew Vector3(),\n\tnew Vector3(),\n\tnew Vector3(),\n\tnew Vector3(),\n\tnew Vector3(),\n\tnew Vector3(),\n\tnew Vector3()\n];\n\nconst _vector = new Vector3();\n\nconst _box = new Box3();\n\n// triangle centered vertices\n\nconst _v0 = new Vector3();\nconst _v1 = new Vector3();\nconst _v2 = new Vector3();\n\n// triangle edge vectors\n\nconst _f0 = new Vector3();\nconst _f1 = new Vector3();\nconst _f2 = new Vector3();\n\nconst _center = new Vector3();\nconst _extents = new Vector3();\nconst _triangleNormal = new Vector3();\nconst _testAxis = new Vector3();\n\n/**\n * @author bhouston / http://clara.io\n * @author WestLangley / http://github.com/WestLangley\n */\n\nfunction Box3( min, max ) {\n\n\tthis.min = ( min !== undefined ) ? min : new Vector3( + Infinity, + Infinity, + Infinity );\n\tthis.max = ( max !== undefined ) ? max : new Vector3( - Infinity, - Infinity, - Infinity );\n\n}\n\n\nObject.assign( Box3.prototype, {\n\n\tisBox3: true,\n\n\tset: function ( min, max ) {\n\n\t\tthis.min.copy( min );\n\t\tthis.max.copy( max );\n\n\t\treturn this;\n\n\t},\n\n\tsetFromArray: function ( array ) {\n\n\t\tlet minX = + Infinity;\n\t\tlet minY = + Infinity;\n\t\tlet minZ = + Infinity;\n\n\t\tlet maxX = - Infinity;\n\t\tlet maxY = - Infinity;\n\t\tlet maxZ = - Infinity;\n\n\t\tfor ( let i = 0, l = array.length; i < l; i += 3 ) {\n\n\t\t\tconst x = array[ i ];\n\t\t\tconst y = array[ i + 1 ];\n\t\t\tconst z = array[ i + 2 ];\n\n\t\t\tif ( x < minX ) minX = x;\n\t\t\tif ( y < minY ) minY = y;\n\t\t\tif ( z < minZ ) minZ = z;\n\n\t\t\tif ( x > maxX ) maxX = x;\n\t\t\tif ( y > maxY ) maxY = y;\n\t\t\tif ( z > maxZ ) maxZ = z;\n\n\t\t}\n\n\t\tthis.min.set( minX, minY, minZ );\n\t\tthis.max.set( maxX, maxY, maxZ );\n\n\t\treturn this;\n\n\t},\n\n\tsetFromBufferAttribute: function ( attribute ) {\n\n\t\tlet minX = + Infinity;\n\t\tlet minY = + Infinity;\n\t\tlet minZ = + Infinity;\n\n\t\tlet maxX = - Infinity;\n\t\tlet maxY = - Infinity;\n\t\tlet maxZ = - Infinity;\n\n\t\tfor ( let i = 0, l = attribute.count; i < l; i ++ ) {\n\n\t\t\tconst x = attribute.getX( i );\n\t\t\tconst y = attribute.getY( i );\n\t\t\tconst z = attribute.getZ( i );\n\n\t\t\tif ( x < minX ) minX = x;\n\t\t\tif ( y < minY ) minY = y;\n\t\t\tif ( z < minZ ) minZ = z;\n\n\t\t\tif ( x > maxX ) maxX = x;\n\t\t\tif ( y > maxY ) maxY = y;\n\t\t\tif ( z > maxZ ) maxZ = z;\n\n\t\t}\n\n\t\tthis.min.set( minX, minY, minZ );\n\t\tthis.max.set( maxX, maxY, maxZ );\n\n\t\treturn this;\n\n\t},\n\n\tsetFromPoints: function ( points ) {\n\n\t\tthis.makeEmpty();\n\n\t\tfor ( let i = 0, il = points.length; i < il; i ++ ) {\n\n\t\t\tthis.expandByPoint( points[ i ] );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tsetFromCenterAndSize: function ( center, size ) {\n\n\t\tconst halfSize = _vector.copy( size ).multiplyScalar( 0.5 );\n\n\t\tthis.min.copy( center ).sub( halfSize );\n\t\tthis.max.copy( center ).add( halfSize );\n\n\t\treturn this;\n\n\t},\n\n\tsetFromObject: function ( object ) {\n\n\t\tthis.makeEmpty();\n\n\t\treturn this.expandByObject( object );\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor().copy( this );\n\n\t},\n\n\tcopy: function ( box ) {\n\n\t\tthis.min.copy( box.min );\n\t\tthis.max.copy( box.max );\n\n\t\treturn this;\n\n\t},\n\n\tmakeEmpty: function () {\n\n\t\tthis.min.x = this.min.y = this.min.z = + Infinity;\n\t\tthis.max.x = this.max.y = this.max.z = - Infinity;\n\n\t\treturn this;\n\n\t},\n\n\tisEmpty: function () {\n\n\t\t// this is a more robust check for empty than ( volume <= 0 ) because volume can get positive with two negative axes\n\n\t\treturn ( this.max.x < this.min.x ) || ( this.max.y < this.min.y ) || ( this.max.z < this.min.z );\n\n\t},\n\n\tgetCenter: function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Box3: .getCenter() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\treturn this.isEmpty() ? target.set( 0, 0, 0 ) : target.addVectors( this.min, this.max ).multiplyScalar( 0.5 );\n\n\t},\n\n\tgetSize: function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Box3: .getSize() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\treturn this.isEmpty() ? target.set( 0, 0, 0 ) : target.subVectors( this.max, this.min );\n\n\t},\n\n\texpandByPoint: function ( point ) {\n\n\t\tthis.min.min( point );\n\t\tthis.max.max( point );\n\n\t\treturn this;\n\n\t},\n\n\texpandByVector: function ( vector ) {\n\n\t\tthis.min.sub( vector );\n\t\tthis.max.add( vector );\n\n\t\treturn this;\n\n\t},\n\n\texpandByScalar: function ( scalar ) {\n\n\t\tthis.min.addScalar( - scalar );\n\t\tthis.max.addScalar( scalar );\n\n\t\treturn this;\n\n\t},\n\n\texpandByObject: function ( object ) {\n\n\t\t// Computes the world-axis-aligned bounding box of an object (including its children),\n\t\t// accounting for both the object's, and children's, world transforms\n\n\t\tobject.updateWorldMatrix( false, false );\n\n\t\tconst geometry = object.geometry;\n\n\t\tif ( geometry !== undefined ) {\n\n\t\t\tif ( geometry.boundingBox === null ) {\n\n\t\t\t\tgeometry.computeBoundingBox();\n\n\t\t\t}\n\n\t\t\t_box.copy( geometry.boundingBox );\n\t\t\t_box.applyMatrix4( object.matrixWorld );\n\n\t\t\tthis.union( _box );\n\n\t\t}\n\n\t\tconst children = object.children;\n\n\t\tfor ( let i = 0, l = children.length; i < l; i ++ ) {\n\n\t\t\tthis.expandByObject( children[ i ] );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tcontainsPoint: function ( point ) {\n\n\t\treturn point.x < this.min.x || point.x > this.max.x ||\n\t\t\tpoint.y < this.min.y || point.y > this.max.y ||\n\t\t\tpoint.z < this.min.z || point.z > this.max.z ? false : true;\n\n\t},\n\n\tcontainsBox: function ( box ) {\n\n\t\treturn this.min.x <= box.min.x && box.max.x <= this.max.x &&\n\t\t\tthis.min.y <= box.min.y && box.max.y <= this.max.y &&\n\t\t\tthis.min.z <= box.min.z && box.max.z <= this.max.z;\n\n\t},\n\n\tgetParameter: function ( point, target ) {\n\n\t\t// This can potentially have a divide by zero if the box\n\t\t// has a size dimension of 0.\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Box3: .getParameter() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\treturn target.set(\n\t\t\t( point.x - this.min.x ) / ( this.max.x - this.min.x ),\n\t\t\t( point.y - this.min.y ) / ( this.max.y - this.min.y ),\n\t\t\t( point.z - this.min.z ) / ( this.max.z - this.min.z )\n\t\t);\n\n\t},\n\n\tintersectsBox: function ( box ) {\n\n\t\t// using 6 splitting planes to rule out intersections.\n\t\treturn box.max.x < this.min.x || box.min.x > this.max.x ||\n\t\t\tbox.max.y < this.min.y || box.min.y > this.max.y ||\n\t\t\tbox.max.z < this.min.z || box.min.z > this.max.z ? false : true;\n\n\t},\n\n\tintersectsSphere: function ( sphere ) {\n\n\t\t// Find the point on the AABB closest to the sphere center.\n\t\tthis.clampPoint( sphere.center, _vector );\n\n\t\t// If that point is inside the sphere, the AABB and sphere intersect.\n\t\treturn _vector.distanceToSquared( sphere.center ) <= ( sphere.radius * sphere.radius );\n\n\t},\n\n\tintersectsPlane: function ( plane ) {\n\n\t\t// We compute the minimum and maximum dot product values. If those values\n\t\t// are on the same side (back or front) of the plane, then there is no intersection.\n\n\t\tlet min, max;\n\n\t\tif ( plane.normal.x > 0 ) {\n\n\t\t\tmin = plane.normal.x * this.min.x;\n\t\t\tmax = plane.normal.x * this.max.x;\n\n\t\t} else {\n\n\t\t\tmin = plane.normal.x * this.max.x;\n\t\t\tmax = plane.normal.x * this.min.x;\n\n\t\t}\n\n\t\tif ( plane.normal.y > 0 ) {\n\n\t\t\tmin += plane.normal.y * this.min.y;\n\t\t\tmax += plane.normal.y * this.max.y;\n\n\t\t} else {\n\n\t\t\tmin += plane.normal.y * this.max.y;\n\t\t\tmax += plane.normal.y * this.min.y;\n\n\t\t}\n\n\t\tif ( plane.normal.z > 0 ) {\n\n\t\t\tmin += plane.normal.z * this.min.z;\n\t\t\tmax += plane.normal.z * this.max.z;\n\n\t\t} else {\n\n\t\t\tmin += plane.normal.z * this.max.z;\n\t\t\tmax += plane.normal.z * this.min.z;\n\n\t\t}\n\n\t\treturn ( min <= - plane.constant && max >= - plane.constant );\n\n\t},\n\n\tintersectsTriangle: function ( triangle ) {\n\n\t\tif ( this.isEmpty() ) {\n\n\t\t\treturn false;\n\n\t\t}\n\n\t\t// compute box center and extents\n\t\tthis.getCenter( _center );\n\t\t_extents.subVectors( this.max, _center );\n\n\t\t// translate triangle to aabb origin\n\t\t_v0.subVectors( triangle.a, _center );\n\t\t_v1.subVectors( triangle.b, _center );\n\t\t_v2.subVectors( triangle.c, _center );\n\n\t\t// compute edge vectors for triangle\n\t\t_f0.subVectors( _v1, _v0 );\n\t\t_f1.subVectors( _v2, _v1 );\n\t\t_f2.subVectors( _v0, _v2 );\n\n\t\t// test against axes that are given by cross product combinations of the edges of the triangle and the edges of the aabb\n\t\t// make an axis testing of each of the 3 sides of the aabb against each of the 3 sides of the triangle = 9 axis of separation\n\t\t// axis_ij = u_i x f_j (u0, u1, u2 = face normals of aabb = x,y,z axes vectors since aabb is axis aligned)\n\t\tlet axes = [\n\t\t\t0, - _f0.z, _f0.y, 0, - _f1.z, _f1.y, 0, - _f2.z, _f2.y,\n\t\t\t_f0.z, 0, - _f0.x, _f1.z, 0, - _f1.x, _f2.z, 0, - _f2.x,\n\t\t\t- _f0.y, _f0.x, 0, - _f1.y, _f1.x, 0, - _f2.y, _f2.x, 0\n\t\t];\n\t\tif ( ! satForAxes( axes, _v0, _v1, _v2, _extents ) ) {\n\n\t\t\treturn false;\n\n\t\t}\n\n\t\t// test 3 face normals from the aabb\n\t\taxes = [ 1, 0, 0, 0, 1, 0, 0, 0, 1 ];\n\t\tif ( ! satForAxes( axes, _v0, _v1, _v2, _extents ) ) {\n\n\t\t\treturn false;\n\n\t\t}\n\n\t\t// finally testing the face normal of the triangle\n\t\t// use already existing triangle edge vectors here\n\t\t_triangleNormal.crossVectors( _f0, _f1 );\n\t\taxes = [ _triangleNormal.x, _triangleNormal.y, _triangleNormal.z ];\n\n\t\treturn satForAxes( axes, _v0, _v1, _v2, _extents );\n\n\t},\n\n\tclampPoint: function ( point, target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Box3: .clampPoint() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\treturn target.copy( point ).clamp( this.min, this.max );\n\n\t},\n\n\tdistanceToPoint: function ( point ) {\n\n\t\tconst clampedPoint = _vector.copy( point ).clamp( this.min, this.max );\n\n\t\treturn clampedPoint.sub( point ).length();\n\n\t},\n\n\tgetBoundingSphere: function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.error( 'THREE.Box3: .getBoundingSphere() target is now required' );\n\t\t\t//target = new Sphere(); // removed to avoid cyclic dependency\n\n\t\t}\n\n\t\tthis.getCenter( target.center );\n\n\t\ttarget.radius = this.getSize( _vector ).length() * 0.5;\n\n\t\treturn target;\n\n\t},\n\n\tintersect: function ( box ) {\n\n\t\tthis.min.max( box.min );\n\t\tthis.max.min( box.max );\n\n\t\t// ensure that if there is no overlap, the result is fully empty, not slightly empty with non-inf/+inf values that will cause subsequence intersects to erroneously return valid values.\n\t\tif ( this.isEmpty() ) this.makeEmpty();\n\n\t\treturn this;\n\n\t},\n\n\tunion: function ( box ) {\n\n\t\tthis.min.min( box.min );\n\t\tthis.max.max( box.max );\n\n\t\treturn this;\n\n\t},\n\n\tapplyMatrix4: function ( matrix ) {\n\n\t\t// transform of empty box is an empty box.\n\t\tif ( this.isEmpty() ) return this;\n\n\t\t// NOTE: I am using a binary pattern to specify all 2^3 combinations below\n\t\t_points[ 0 ].set( this.min.x, this.min.y, this.min.z ).applyMatrix4( matrix ); // 000\n\t\t_points[ 1 ].set( this.min.x, this.min.y, this.max.z ).applyMatrix4( matrix ); // 001\n\t\t_points[ 2 ].set( this.min.x, this.max.y, this.min.z ).applyMatrix4( matrix ); // 010\n\t\t_points[ 3 ].set( this.min.x, this.max.y, this.max.z ).applyMatrix4( matrix ); // 011\n\t\t_points[ 4 ].set( this.max.x, this.min.y, this.min.z ).applyMatrix4( matrix ); // 100\n\t\t_points[ 5 ].set( this.max.x, this.min.y, this.max.z ).applyMatrix4( matrix ); // 101\n\t\t_points[ 6 ].set( this.max.x, this.max.y, this.min.z ).applyMatrix4( matrix ); // 110\n\t\t_points[ 7 ].set( this.max.x, this.max.y, this.max.z ).applyMatrix4( matrix ); // 111\n\n\t\tthis.setFromPoints( _points );\n\n\t\treturn this;\n\n\t},\n\n\ttranslate: function ( offset ) {\n\n\t\tthis.min.add( offset );\n\t\tthis.max.add( offset );\n\n\t\treturn this;\n\n\t},\n\n\tequals: function ( box ) {\n\n\t\treturn box.min.equals( this.min ) && box.max.equals( this.max );\n\n\t}\n\n} );\n\nfunction satForAxes( axes, v0, v1, v2, extents ) {\n\n\tfor ( let i = 0, j = axes.length - 3; i <= j; i += 3 ) {\n\n\t\t_testAxis.fromArray( axes, i );\n\t\t// project the aabb onto the seperating axis\n\t\tconst r = extents.x * Math.abs( _testAxis.x ) + extents.y * Math.abs( _testAxis.y ) + extents.z * Math.abs( _testAxis.z );\n\t\t// project all 3 vertices of the triangle onto the seperating axis\n\t\tconst p0 = v0.dot( _testAxis );\n\t\tconst p1 = v1.dot( _testAxis );\n\t\tconst p2 = v2.dot( _testAxis );\n\t\t// actual test, basically see if either of the most extreme of the triangle points intersects r\n\t\tif ( Math.max( - Math.max( p0, p1, p2 ), Math.min( p0, p1, p2 ) ) > r ) {\n\n\t\t\t// points of the projected triangle are outside the projected half-length of the aabb\n\t\t\t// the axis is seperating and we can exit\n\t\t\treturn false;\n\n\t\t}\n\n\t}\n\n\treturn true;\n\n}\n\nexport { Box3 };\n","import { Box3 } from './Box3.js';\nimport { Vector3 } from './Vector3.js';\n\nconst _box = new Box3();\n\n/**\n * @author bhouston / http://clara.io\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction Sphere( center, radius ) {\n\n\tthis.center = ( center !== undefined ) ? center : new Vector3();\n\tthis.radius = ( radius !== undefined ) ? radius : - 1;\n\n}\n\nObject.assign( Sphere.prototype, {\n\n\tset: function ( center, radius ) {\n\n\t\tthis.center.copy( center );\n\t\tthis.radius = radius;\n\n\t\treturn this;\n\n\t},\n\n\tsetFromPoints: function ( points, optionalCenter ) {\n\n\t\tconst center = this.center;\n\n\t\tif ( optionalCenter !== undefined ) {\n\n\t\t\tcenter.copy( optionalCenter );\n\n\t\t} else {\n\n\t\t\t_box.setFromPoints( points ).getCenter( center );\n\n\t\t}\n\n\t\tlet maxRadiusSq = 0;\n\n\t\tfor ( let i = 0, il = points.length; i < il; i ++ ) {\n\n\t\t\tmaxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( points[ i ] ) );\n\n\t\t}\n\n\t\tthis.radius = Math.sqrt( maxRadiusSq );\n\n\t\treturn this;\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor().copy( this );\n\n\t},\n\n\tcopy: function ( sphere ) {\n\n\t\tthis.center.copy( sphere.center );\n\t\tthis.radius = sphere.radius;\n\n\t\treturn this;\n\n\t},\n\n\tisEmpty: function () {\n\n\t\treturn ( this.radius < 0 );\n\n\t},\n\n\tmakeEmpty: function () {\n\n\t\tthis.center.set( 0, 0, 0 );\n\t\tthis.radius = - 1;\n\n\t\treturn this;\n\n\t},\n\n\tcontainsPoint: function ( point ) {\n\n\t\treturn ( point.distanceToSquared( this.center ) <= ( this.radius * this.radius ) );\n\n\t},\n\n\tdistanceToPoint: function ( point ) {\n\n\t\treturn ( point.distanceTo( this.center ) - this.radius );\n\n\t},\n\n\tintersectsSphere: function ( sphere ) {\n\n\t\tconst radiusSum = this.radius + sphere.radius;\n\n\t\treturn sphere.center.distanceToSquared( this.center ) <= ( radiusSum * radiusSum );\n\n\t},\n\n\tintersectsBox: function ( box ) {\n\n\t\treturn box.intersectsSphere( this );\n\n\t},\n\n\tintersectsPlane: function ( plane ) {\n\n\t\treturn Math.abs( plane.distanceToPoint( this.center ) ) <= this.radius;\n\n\t},\n\n\tclampPoint: function ( point, target ) {\n\n\t\tconst deltaLengthSq = this.center.distanceToSquared( point );\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Sphere: .clampPoint() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\ttarget.copy( point );\n\n\t\tif ( deltaLengthSq > ( this.radius * this.radius ) ) {\n\n\t\t\ttarget.sub( this.center ).normalize();\n\t\t\ttarget.multiplyScalar( this.radius ).add( this.center );\n\n\t\t}\n\n\t\treturn target;\n\n\t},\n\n\tgetBoundingBox: function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Sphere: .getBoundingBox() target is now required' );\n\t\t\ttarget = new Box3();\n\n\t\t}\n\n\t\tif ( this.isEmpty() ) {\n\n\t\t\t// Empty sphere produces empty bounding box\n\t\t\ttarget.makeEmpty();\n\t\t\treturn target;\n\n\t\t}\n\n\t\ttarget.set( this.center, this.center );\n\t\ttarget.expandByScalar( this.radius );\n\n\t\treturn target;\n\n\t},\n\n\tapplyMatrix4: function ( matrix ) {\n\n\t\tthis.center.applyMatrix4( matrix );\n\t\tthis.radius = this.radius * matrix.getMaxScaleOnAxis();\n\n\t\treturn this;\n\n\t},\n\n\ttranslate: function ( offset ) {\n\n\t\tthis.center.add( offset );\n\n\t\treturn this;\n\n\t},\n\n\tequals: function ( sphere ) {\n\n\t\treturn sphere.center.equals( this.center ) && ( sphere.radius === this.radius );\n\n\t}\n\n} );\n\n\nexport { Sphere };\n","import { Vector3 } from './Vector3.js';\n\nconst _vector = new Vector3();\nconst _segCenter = new Vector3();\nconst _segDir = new Vector3();\nconst _diff = new Vector3();\n\nconst _edge1 = new Vector3();\nconst _edge2 = new Vector3();\nconst _normal = new Vector3();\n\n/**\n * @author bhouston / http://clara.io\n */\n\nfunction Ray( origin, direction ) {\n\n\tthis.origin = ( origin !== undefined ) ? origin : new Vector3();\n\tthis.direction = ( direction !== undefined ) ? direction : new Vector3( 0, 0, - 1 );\n\n}\n\nObject.assign( Ray.prototype, {\n\n\tset: function ( origin, direction ) {\n\n\t\tthis.origin.copy( origin );\n\t\tthis.direction.copy( direction );\n\n\t\treturn this;\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor().copy( this );\n\n\t},\n\n\tcopy: function ( ray ) {\n\n\t\tthis.origin.copy( ray.origin );\n\t\tthis.direction.copy( ray.direction );\n\n\t\treturn this;\n\n\t},\n\n\tat: function ( t, target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Ray: .at() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\treturn target.copy( this.direction ).multiplyScalar( t ).add( this.origin );\n\n\t},\n\n\tlookAt: function ( v ) {\n\n\t\tthis.direction.copy( v ).sub( this.origin ).normalize();\n\n\t\treturn this;\n\n\t},\n\n\trecast: function ( t ) {\n\n\t\tthis.origin.copy( this.at( t, _vector ) );\n\n\t\treturn this;\n\n\t},\n\n\tclosestPointToPoint: function ( point, target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Ray: .closestPointToPoint() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\ttarget.subVectors( point, this.origin );\n\n\t\tconst directionDistance = target.dot( this.direction );\n\n\t\tif ( directionDistance < 0 ) {\n\n\t\t\treturn target.copy( this.origin );\n\n\t\t}\n\n\t\treturn target.copy( this.direction ).multiplyScalar( directionDistance ).add( this.origin );\n\n\t},\n\n\tdistanceToPoint: function ( point ) {\n\n\t\treturn Math.sqrt( this.distanceSqToPoint( point ) );\n\n\t},\n\n\tdistanceSqToPoint: function ( point ) {\n\n\t\tconst directionDistance = _vector.subVectors( point, this.origin ).dot( this.direction );\n\n\t\t// point behind the ray\n\n\t\tif ( directionDistance < 0 ) {\n\n\t\t\treturn this.origin.distanceToSquared( point );\n\n\t\t}\n\n\t\t_vector.copy( this.direction ).multiplyScalar( directionDistance ).add( this.origin );\n\n\t\treturn _vector.distanceToSquared( point );\n\n\t},\n\n\tdistanceSqToSegment: function ( v0, v1, optionalPointOnRay, optionalPointOnSegment ) {\n\n\t\t// from http://www.geometrictools.com/GTEngine/Include/Mathematics/GteDistRaySegment.h\n\t\t// It returns the min distance between the ray and the segment\n\t\t// defined by v0 and v1\n\t\t// It can also set two optional targets :\n\t\t// - The closest point on the ray\n\t\t// - The closest point on the segment\n\n\t\t_segCenter.copy( v0 ).add( v1 ).multiplyScalar( 0.5 );\n\t\t_segDir.copy( v1 ).sub( v0 ).normalize();\n\t\t_diff.copy( this.origin ).sub( _segCenter );\n\n\t\tconst segExtent = v0.distanceTo( v1 ) * 0.5;\n\t\tconst a01 = - this.direction.dot( _segDir );\n\t\tconst b0 = _diff.dot( this.direction );\n\t\tconst b1 = - _diff.dot( _segDir );\n\t\tconst c = _diff.lengthSq();\n\t\tconst det = Math.abs( 1 - a01 * a01 );\n\t\tlet s0, s1, sqrDist, extDet;\n\n\t\tif ( det > 0 ) {\n\n\t\t\t// The ray and segment are not parallel.\n\n\t\t\ts0 = a01 * b1 - b0;\n\t\t\ts1 = a01 * b0 - b1;\n\t\t\textDet = segExtent * det;\n\n\t\t\tif ( s0 >= 0 ) {\n\n\t\t\t\tif ( s1 >= - extDet ) {\n\n\t\t\t\t\tif ( s1 <= extDet ) {\n\n\t\t\t\t\t\t// region 0\n\t\t\t\t\t\t// Minimum at interior points of ray and segment.\n\n\t\t\t\t\t\tconst invDet = 1 / det;\n\t\t\t\t\t\ts0 *= invDet;\n\t\t\t\t\t\ts1 *= invDet;\n\t\t\t\t\t\tsqrDist = s0 * ( s0 + a01 * s1 + 2 * b0 ) + s1 * ( a01 * s0 + s1 + 2 * b1 ) + c;\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\t// region 1\n\n\t\t\t\t\t\ts1 = segExtent;\n\t\t\t\t\t\ts0 = Math.max( 0, - ( a01 * s1 + b0 ) );\n\t\t\t\t\t\tsqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;\n\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\n\t\t\t\t\t// region 5\n\n\t\t\t\t\ts1 = - segExtent;\n\t\t\t\t\ts0 = Math.max( 0, - ( a01 * s1 + b0 ) );\n\t\t\t\t\tsqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\tif ( s1 <= - extDet ) {\n\n\t\t\t\t\t// region 4\n\n\t\t\t\t\ts0 = Math.max( 0, - ( - a01 * segExtent + b0 ) );\n\t\t\t\t\ts1 = ( s0 > 0 ) ? - segExtent : Math.min( Math.max( - segExtent, - b1 ), segExtent );\n\t\t\t\t\tsqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;\n\n\t\t\t\t} else if ( s1 <= extDet ) {\n\n\t\t\t\t\t// region 3\n\n\t\t\t\t\ts0 = 0;\n\t\t\t\t\ts1 = Math.min( Math.max( - segExtent, - b1 ), segExtent );\n\t\t\t\t\tsqrDist = s1 * ( s1 + 2 * b1 ) + c;\n\n\t\t\t\t} else {\n\n\t\t\t\t\t// region 2\n\n\t\t\t\t\ts0 = Math.max( 0, - ( a01 * segExtent + b0 ) );\n\t\t\t\t\ts1 = ( s0 > 0 ) ? segExtent : Math.min( Math.max( - segExtent, - b1 ), segExtent );\n\t\t\t\t\tsqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\t// Ray and segment are parallel.\n\n\t\t\ts1 = ( a01 > 0 ) ? - segExtent : segExtent;\n\t\t\ts0 = Math.max( 0, - ( a01 * s1 + b0 ) );\n\t\t\tsqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;\n\n\t\t}\n\n\t\tif ( optionalPointOnRay ) {\n\n\t\t\toptionalPointOnRay.copy( this.direction ).multiplyScalar( s0 ).add( this.origin );\n\n\t\t}\n\n\t\tif ( optionalPointOnSegment ) {\n\n\t\t\toptionalPointOnSegment.copy( _segDir ).multiplyScalar( s1 ).add( _segCenter );\n\n\t\t}\n\n\t\treturn sqrDist;\n\n\t},\n\n\tintersectSphere: function ( sphere, target ) {\n\n\t\t_vector.subVectors( sphere.center, this.origin );\n\t\tconst tca = _vector.dot( this.direction );\n\t\tconst d2 = _vector.dot( _vector ) - tca * tca;\n\t\tconst radius2 = sphere.radius * sphere.radius;\n\n\t\tif ( d2 > radius2 ) return null;\n\n\t\tconst thc = Math.sqrt( radius2 - d2 );\n\n\t\t// t0 = first intersect point - entrance on front of sphere\n\t\tconst t0 = tca - thc;\n\n\t\t// t1 = second intersect point - exit point on back of sphere\n\t\tconst t1 = tca + thc;\n\n\t\t// test to see if both t0 and t1 are behind the ray - if so, return null\n\t\tif ( t0 < 0 && t1 < 0 ) return null;\n\n\t\t// test to see if t0 is behind the ray:\n\t\t// if it is, the ray is inside the sphere, so return the second exit point scaled by t1,\n\t\t// in order to always return an intersect point that is in front of the ray.\n\t\tif ( t0 < 0 ) return this.at( t1, target );\n\n\t\t// else t0 is in front of the ray, so return the first collision point scaled by t0\n\t\treturn this.at( t0, target );\n\n\t},\n\n\tintersectsSphere: function ( sphere ) {\n\n\t\treturn this.distanceSqToPoint( sphere.center ) <= ( sphere.radius * sphere.radius );\n\n\t},\n\n\tdistanceToPlane: function ( plane ) {\n\n\t\tconst denominator = plane.normal.dot( this.direction );\n\n\t\tif ( denominator === 0 ) {\n\n\t\t\t// line is coplanar, return origin\n\t\t\tif ( plane.distanceToPoint( this.origin ) === 0 ) {\n\n\t\t\t\treturn 0;\n\n\t\t\t}\n\n\t\t\t// Null is preferable to undefined since undefined means.... it is undefined\n\n\t\t\treturn null;\n\n\t\t}\n\n\t\tconst t = - ( this.origin.dot( plane.normal ) + plane.constant ) / denominator;\n\n\t\t// Return if the ray never intersects the plane\n\n\t\treturn t >= 0 ? t : null;\n\n\t},\n\n\tintersectPlane: function ( plane, target ) {\n\n\t\tconst t = this.distanceToPlane( plane );\n\n\t\tif ( t === null ) {\n\n\t\t\treturn null;\n\n\t\t}\n\n\t\treturn this.at( t, target );\n\n\t},\n\n\tintersectsPlane: function ( plane ) {\n\n\t\t// check if the ray lies on the plane first\n\n\t\tconst distToPoint = plane.distanceToPoint( this.origin );\n\n\t\tif ( distToPoint === 0 ) {\n\n\t\t\treturn true;\n\n\t\t}\n\n\t\tconst denominator = plane.normal.dot( this.direction );\n\n\t\tif ( denominator * distToPoint < 0 ) {\n\n\t\t\treturn true;\n\n\t\t}\n\n\t\t// ray origin is behind the plane (and is pointing behind it)\n\n\t\treturn false;\n\n\t},\n\n\tintersectBox: function ( box, target ) {\n\n\t\tlet tmin, tmax, tymin, tymax, tzmin, tzmax;\n\n\t\tconst invdirx = 1 / this.direction.x,\n\t\t\tinvdiry = 1 / this.direction.y,\n\t\t\tinvdirz = 1 / this.direction.z;\n\n\t\tconst origin = this.origin;\n\n\t\tif ( invdirx >= 0 ) {\n\n\t\t\ttmin = ( box.min.x - origin.x ) * invdirx;\n\t\t\ttmax = ( box.max.x - origin.x ) * invdirx;\n\n\t\t} else {\n\n\t\t\ttmin = ( box.max.x - origin.x ) * invdirx;\n\t\t\ttmax = ( box.min.x - origin.x ) * invdirx;\n\n\t\t}\n\n\t\tif ( invdiry >= 0 ) {\n\n\t\t\ttymin = ( box.min.y - origin.y ) * invdiry;\n\t\t\ttymax = ( box.max.y - origin.y ) * invdiry;\n\n\t\t} else {\n\n\t\t\ttymin = ( box.max.y - origin.y ) * invdiry;\n\t\t\ttymax = ( box.min.y - origin.y ) * invdiry;\n\n\t\t}\n\n\t\tif ( ( tmin > tymax ) || ( tymin > tmax ) ) return null;\n\n\t\t// These lines also handle the case where tmin or tmax is NaN\n\t\t// (result of 0 * Infinity). x !== x returns true if x is NaN\n\n\t\tif ( tymin > tmin || tmin !== tmin ) tmin = tymin;\n\n\t\tif ( tymax < tmax || tmax !== tmax ) tmax = tymax;\n\n\t\tif ( invdirz >= 0 ) {\n\n\t\t\ttzmin = ( box.min.z - origin.z ) * invdirz;\n\t\t\ttzmax = ( box.max.z - origin.z ) * invdirz;\n\n\t\t} else {\n\n\t\t\ttzmin = ( box.max.z - origin.z ) * invdirz;\n\t\t\ttzmax = ( box.min.z - origin.z ) * invdirz;\n\n\t\t}\n\n\t\tif ( ( tmin > tzmax ) || ( tzmin > tmax ) ) return null;\n\n\t\tif ( tzmin > tmin || tmin !== tmin ) tmin = tzmin;\n\n\t\tif ( tzmax < tmax || tmax !== tmax ) tmax = tzmax;\n\n\t\t//return point closest to the ray (positive side)\n\n\t\tif ( tmax < 0 ) return null;\n\n\t\treturn this.at( tmin >= 0 ? tmin : tmax, target );\n\n\t},\n\n\tintersectsBox: function ( box ) {\n\n\t\treturn this.intersectBox( box, _vector ) !== null;\n\n\t},\n\n\tintersectTriangle: function ( a, b, c, backfaceCulling, target ) {\n\n\t\t// Compute the offset origin, edges, and normal.\n\n\t\t// from http://www.geometrictools.com/GTEngine/Include/Mathematics/GteIntrRay3Triangle3.h\n\n\t\t_edge1.subVectors( b, a );\n\t\t_edge2.subVectors( c, a );\n\t\t_normal.crossVectors( _edge1, _edge2 );\n\n\t\t// Solve Q + t*D = b1*E1 + b2*E2 (Q = kDiff, D = ray direction,\n\t\t// E1 = kEdge1, E2 = kEdge2, N = Cross(E1,E2)) by\n\t\t// |Dot(D,N)|*b1 = sign(Dot(D,N))*Dot(D,Cross(Q,E2))\n\t\t// |Dot(D,N)|*b2 = sign(Dot(D,N))*Dot(D,Cross(E1,Q))\n\t\t// |Dot(D,N)|*t = -sign(Dot(D,N))*Dot(Q,N)\n\t\tlet DdN = this.direction.dot( _normal );\n\t\tlet sign;\n\n\t\tif ( DdN > 0 ) {\n\n\t\t\tif ( backfaceCulling ) return null;\n\t\t\tsign = 1;\n\n\t\t} else if ( DdN < 0 ) {\n\n\t\t\tsign = - 1;\n\t\t\tDdN = - DdN;\n\n\t\t} else {\n\n\t\t\treturn null;\n\n\t\t}\n\n\t\t_diff.subVectors( this.origin, a );\n\t\tconst DdQxE2 = sign * this.direction.dot( _edge2.crossVectors( _diff, _edge2 ) );\n\n\t\t// b1 < 0, no intersection\n\t\tif ( DdQxE2 < 0 ) {\n\n\t\t\treturn null;\n\n\t\t}\n\n\t\tconst DdE1xQ = sign * this.direction.dot( _edge1.cross( _diff ) );\n\n\t\t// b2 < 0, no intersection\n\t\tif ( DdE1xQ < 0 ) {\n\n\t\t\treturn null;\n\n\t\t}\n\n\t\t// b1+b2 > 1, no intersection\n\t\tif ( DdQxE2 + DdE1xQ > DdN ) {\n\n\t\t\treturn null;\n\n\t\t}\n\n\t\t// Line intersects triangle, check if ray does.\n\t\tconst QdN = - sign * _diff.dot( _normal );\n\n\t\t// t < 0, no intersection\n\t\tif ( QdN < 0 ) {\n\n\t\t\treturn null;\n\n\t\t}\n\n\t\t// Ray intersects triangle.\n\t\treturn this.at( QdN / DdN, target );\n\n\t},\n\n\tapplyMatrix4: function ( matrix4 ) {\n\n\t\tthis.origin.applyMatrix4( matrix4 );\n\t\tthis.direction.transformDirection( matrix4 );\n\n\t\treturn this;\n\n\t},\n\n\tequals: function ( ray ) {\n\n\t\treturn ray.origin.equals( this.origin ) && ray.direction.equals( this.direction );\n\n\t}\n\n} );\n\n\nexport { Ray };\n","import { Matrix3 } from './Matrix3.js';\nimport { Vector3 } from './Vector3.js';\n\n/**\n * @author bhouston / http://clara.io\n */\n\nconst _vector1 = new Vector3();\nconst _vector2 = new Vector3();\nconst _normalMatrix = new Matrix3();\n\nfunction Plane( normal, constant ) {\n\n\t// normal is assumed to be normalized\n\n\tthis.normal = ( normal !== undefined ) ? normal : new Vector3( 1, 0, 0 );\n\tthis.constant = ( constant !== undefined ) ? constant : 0;\n\n}\n\nObject.assign( Plane.prototype, {\n\n\tisPlane: true,\n\n\tset: function ( normal, constant ) {\n\n\t\tthis.normal.copy( normal );\n\t\tthis.constant = constant;\n\n\t\treturn this;\n\n\t},\n\n\tsetComponents: function ( x, y, z, w ) {\n\n\t\tthis.normal.set( x, y, z );\n\t\tthis.constant = w;\n\n\t\treturn this;\n\n\t},\n\n\tsetFromNormalAndCoplanarPoint: function ( normal, point ) {\n\n\t\tthis.normal.copy( normal );\n\t\tthis.constant = - point.dot( this.normal );\n\n\t\treturn this;\n\n\t},\n\n\tsetFromCoplanarPoints: function ( a, b, c ) {\n\n\t\tconst normal = _vector1.subVectors( c, b ).cross( _vector2.subVectors( a, b ) ).normalize();\n\n\t\t// Q: should an error be thrown if normal is zero (e.g. degenerate plane)?\n\n\t\tthis.setFromNormalAndCoplanarPoint( normal, a );\n\n\t\treturn this;\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor().copy( this );\n\n\t},\n\n\tcopy: function ( plane ) {\n\n\t\tthis.normal.copy( plane.normal );\n\t\tthis.constant = plane.constant;\n\n\t\treturn this;\n\n\t},\n\n\tnormalize: function () {\n\n\t\t// Note: will lead to a divide by zero if the plane is invalid.\n\n\t\tconst inverseNormalLength = 1.0 / this.normal.length();\n\t\tthis.normal.multiplyScalar( inverseNormalLength );\n\t\tthis.constant *= inverseNormalLength;\n\n\t\treturn this;\n\n\t},\n\n\tnegate: function () {\n\n\t\tthis.constant *= - 1;\n\t\tthis.normal.negate();\n\n\t\treturn this;\n\n\t},\n\n\tdistanceToPoint: function ( point ) {\n\n\t\treturn this.normal.dot( point ) + this.constant;\n\n\t},\n\n\tdistanceToSphere: function ( sphere ) {\n\n\t\treturn this.distanceToPoint( sphere.center ) - sphere.radius;\n\n\t},\n\n\tprojectPoint: function ( point, target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Plane: .projectPoint() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\treturn target.copy( this.normal ).multiplyScalar( - this.distanceToPoint( point ) ).add( point );\n\n\t},\n\n\tintersectLine: function ( line, target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Plane: .intersectLine() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\tconst direction = line.delta( _vector1 );\n\n\t\tconst denominator = this.normal.dot( direction );\n\n\t\tif ( denominator === 0 ) {\n\n\t\t\t// line is coplanar, return origin\n\t\t\tif ( this.distanceToPoint( line.start ) === 0 ) {\n\n\t\t\t\treturn target.copy( line.start );\n\n\t\t\t}\n\n\t\t\t// Unsure if this is the correct method to handle this case.\n\t\t\treturn undefined;\n\n\t\t}\n\n\t\tconst t = - ( line.start.dot( this.normal ) + this.constant ) / denominator;\n\n\t\tif ( t < 0 || t > 1 ) {\n\n\t\t\treturn undefined;\n\n\t\t}\n\n\t\treturn target.copy( direction ).multiplyScalar( t ).add( line.start );\n\n\t},\n\n\tintersectsLine: function ( line ) {\n\n\t\t// Note: this tests if a line intersects the plane, not whether it (or its end-points) are coplanar with it.\n\n\t\tconst startSign = this.distanceToPoint( line.start );\n\t\tconst endSign = this.distanceToPoint( line.end );\n\n\t\treturn ( startSign < 0 && endSign > 0 ) || ( endSign < 0 && startSign > 0 );\n\n\t},\n\n\tintersectsBox: function ( box ) {\n\n\t\treturn box.intersectsPlane( this );\n\n\t},\n\n\tintersectsSphere: function ( sphere ) {\n\n\t\treturn sphere.intersectsPlane( this );\n\n\t},\n\n\tcoplanarPoint: function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Plane: .coplanarPoint() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\treturn target.copy( this.normal ).multiplyScalar( - this.constant );\n\n\t},\n\n\tapplyMatrix4: function ( matrix, optionalNormalMatrix ) {\n\n\t\tconst normalMatrix = optionalNormalMatrix || _normalMatrix.getNormalMatrix( matrix );\n\n\t\tconst referencePoint = this.coplanarPoint( _vector1 ).applyMatrix4( matrix );\n\n\t\tconst normal = this.normal.applyMatrix3( normalMatrix ).normalize();\n\n\t\tthis.constant = - referencePoint.dot( normal );\n\n\t\treturn this;\n\n\t},\n\n\ttranslate: function ( offset ) {\n\n\t\tthis.constant -= offset.dot( this.normal );\n\n\t\treturn this;\n\n\t},\n\n\tequals: function ( plane ) {\n\n\t\treturn plane.normal.equals( this.normal ) && ( plane.constant === this.constant );\n\n\t}\n\n} );\n\n\nexport { Plane };\n","import { Vector3 } from './Vector3.js';\nimport { Plane } from './Plane.js';\n\n/**\n * @author bhouston / http://clara.io\n * @author mrdoob / http://mrdoob.com/\n */\n\nconst _v0 = new Vector3();\nconst _v1 = new Vector3();\nconst _v2 = new Vector3();\nconst _v3 = new Vector3();\n\nconst _vab = new Vector3();\nconst _vac = new Vector3();\nconst _vbc = new Vector3();\nconst _vap = new Vector3();\nconst _vbp = new Vector3();\nconst _vcp = new Vector3();\n\nfunction Triangle( a, b, c ) {\n\n\tthis.a = ( a !== undefined ) ? a : new Vector3();\n\tthis.b = ( b !== undefined ) ? b : new Vector3();\n\tthis.c = ( c !== undefined ) ? c : new Vector3();\n\n}\n\nObject.assign( Triangle, {\n\n\tgetNormal: function ( a, b, c, target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Triangle: .getNormal() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\ttarget.subVectors( c, b );\n\t\t_v0.subVectors( a, b );\n\t\ttarget.cross( _v0 );\n\n\t\tconst targetLengthSq = target.lengthSq();\n\t\tif ( targetLengthSq > 0 ) {\n\n\t\t\treturn target.multiplyScalar( 1 / Math.sqrt( targetLengthSq ) );\n\n\t\t}\n\n\t\treturn target.set( 0, 0, 0 );\n\n\t},\n\n\t// static/instance method to calculate barycentric coordinates\n\t// based on: http://www.blackpawn.com/texts/pointinpoly/default.html\n\tgetBarycoord: function ( point, a, b, c, target ) {\n\n\t\t_v0.subVectors( c, a );\n\t\t_v1.subVectors( b, a );\n\t\t_v2.subVectors( point, a );\n\n\t\tconst dot00 = _v0.dot( _v0 );\n\t\tconst dot01 = _v0.dot( _v1 );\n\t\tconst dot02 = _v0.dot( _v2 );\n\t\tconst dot11 = _v1.dot( _v1 );\n\t\tconst dot12 = _v1.dot( _v2 );\n\n\t\tconst denom = ( dot00 * dot11 - dot01 * dot01 );\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Triangle: .getBarycoord() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\t// collinear or singular triangle\n\t\tif ( denom === 0 ) {\n\n\t\t\t// arbitrary location outside of triangle?\n\t\t\t// not sure if this is the best idea, maybe should be returning undefined\n\t\t\treturn target.set( - 2, - 1, - 1 );\n\n\t\t}\n\n\t\tconst invDenom = 1 / denom;\n\t\tconst u = ( dot11 * dot02 - dot01 * dot12 ) * invDenom;\n\t\tconst v = ( dot00 * dot12 - dot01 * dot02 ) * invDenom;\n\n\t\t// barycentric coordinates must always sum to 1\n\t\treturn target.set( 1 - u - v, v, u );\n\n\t},\n\n\tcontainsPoint: function ( point, a, b, c ) {\n\n\t\tTriangle.getBarycoord( point, a, b, c, _v3 );\n\n\t\treturn ( _v3.x >= 0 ) && ( _v3.y >= 0 ) && ( ( _v3.x + _v3.y ) <= 1 );\n\n\t},\n\n\tgetUV: function ( point, p1, p2, p3, uv1, uv2, uv3, target ) {\n\n\t\tthis.getBarycoord( point, p1, p2, p3, _v3 );\n\n\t\ttarget.set( 0, 0 );\n\t\ttarget.addScaledVector( uv1, _v3.x );\n\t\ttarget.addScaledVector( uv2, _v3.y );\n\t\ttarget.addScaledVector( uv3, _v3.z );\n\n\t\treturn target;\n\n\t},\n\n\tisFrontFacing: function ( a, b, c, direction ) {\n\n\t\t_v0.subVectors( c, b );\n\t\t_v1.subVectors( a, b );\n\n\t\t// strictly front facing\n\t\treturn ( _v0.cross( _v1 ).dot( direction ) < 0 ) ? true : false;\n\n\t}\n\n} );\n\nObject.assign( Triangle.prototype, {\n\n\tset: function ( a, b, c ) {\n\n\t\tthis.a.copy( a );\n\t\tthis.b.copy( b );\n\t\tthis.c.copy( c );\n\n\t\treturn this;\n\n\t},\n\n\tsetFromPointsAndIndices: function ( points, i0, i1, i2 ) {\n\n\t\tthis.a.copy( points[ i0 ] );\n\t\tthis.b.copy( points[ i1 ] );\n\t\tthis.c.copy( points[ i2 ] );\n\n\t\treturn this;\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor().copy( this );\n\n\t},\n\n\tcopy: function ( triangle ) {\n\n\t\tthis.a.copy( triangle.a );\n\t\tthis.b.copy( triangle.b );\n\t\tthis.c.copy( triangle.c );\n\n\t\treturn this;\n\n\t},\n\n\tgetArea: function () {\n\n\t\t_v0.subVectors( this.c, this.b );\n\t\t_v1.subVectors( this.a, this.b );\n\n\t\treturn _v0.cross( _v1 ).length() * 0.5;\n\n\t},\n\n\tgetMidpoint: function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Triangle: .getMidpoint() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\treturn target.addVectors( this.a, this.b ).add( this.c ).multiplyScalar( 1 / 3 );\n\n\t},\n\n\tgetNormal: function ( target ) {\n\n\t\treturn Triangle.getNormal( this.a, this.b, this.c, target );\n\n\t},\n\n\tgetPlane: function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Triangle: .getPlane() target is now required' );\n\t\t\ttarget = new Plane();\n\n\t\t}\n\n\t\treturn target.setFromCoplanarPoints( this.a, this.b, this.c );\n\n\t},\n\n\tgetBarycoord: function ( point, target ) {\n\n\t\treturn Triangle.getBarycoord( point, this.a, this.b, this.c, target );\n\n\t},\n\n\tgetUV: function ( point, uv1, uv2, uv3, target ) {\n\n\t\treturn Triangle.getUV( point, this.a, this.b, this.c, uv1, uv2, uv3, target );\n\n\t},\n\n\tcontainsPoint: function ( point ) {\n\n\t\treturn Triangle.containsPoint( point, this.a, this.b, this.c );\n\n\t},\n\n\tisFrontFacing: function ( direction ) {\n\n\t\treturn Triangle.isFrontFacing( this.a, this.b, this.c, direction );\n\n\t},\n\n\tintersectsBox: function ( box ) {\n\n\t\treturn box.intersectsTriangle( this );\n\n\t},\n\n\tclosestPointToPoint: function ( p, target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Triangle: .closestPointToPoint() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\tconst a = this.a, b = this.b, c = this.c;\n\t\tlet v, w;\n\n\t\t// algorithm thanks to Real-Time Collision Detection by Christer Ericson,\n\t\t// published by Morgan Kaufmann Publishers, (c) 2005 Elsevier Inc.,\n\t\t// under the accompanying license; see chapter 5.1.5 for detailed explanation.\n\t\t// basically, we're distinguishing which of the voronoi regions of the triangle\n\t\t// the point lies in with the minimum amount of redundant computation.\n\n\t\t_vab.subVectors( b, a );\n\t\t_vac.subVectors( c, a );\n\t\t_vap.subVectors( p, a );\n\t\tconst d1 = _vab.dot( _vap );\n\t\tconst d2 = _vac.dot( _vap );\n\t\tif ( d1 <= 0 && d2 <= 0 ) {\n\n\t\t\t// vertex region of A; barycentric coords (1, 0, 0)\n\t\t\treturn target.copy( a );\n\n\t\t}\n\n\t\t_vbp.subVectors( p, b );\n\t\tconst d3 = _vab.dot( _vbp );\n\t\tconst d4 = _vac.dot( _vbp );\n\t\tif ( d3 >= 0 && d4 <= d3 ) {\n\n\t\t\t// vertex region of B; barycentric coords (0, 1, 0)\n\t\t\treturn target.copy( b );\n\n\t\t}\n\n\t\tconst vc = d1 * d4 - d3 * d2;\n\t\tif ( vc <= 0 && d1 >= 0 && d3 <= 0 ) {\n\n\t\t\tv = d1 / ( d1 - d3 );\n\t\t\t// edge region of AB; barycentric coords (1-v, v, 0)\n\t\t\treturn target.copy( a ).addScaledVector( _vab, v );\n\n\t\t}\n\n\t\t_vcp.subVectors( p, c );\n\t\tconst d5 = _vab.dot( _vcp );\n\t\tconst d6 = _vac.dot( _vcp );\n\t\tif ( d6 >= 0 && d5 <= d6 ) {\n\n\t\t\t// vertex region of C; barycentric coords (0, 0, 1)\n\t\t\treturn target.copy( c );\n\n\t\t}\n\n\t\tconst vb = d5 * d2 - d1 * d6;\n\t\tif ( vb <= 0 && d2 >= 0 && d6 <= 0 ) {\n\n\t\t\tw = d2 / ( d2 - d6 );\n\t\t\t// edge region of AC; barycentric coords (1-w, 0, w)\n\t\t\treturn target.copy( a ).addScaledVector( _vac, w );\n\n\t\t}\n\n\t\tconst va = d3 * d6 - d5 * d4;\n\t\tif ( va <= 0 && ( d4 - d3 ) >= 0 && ( d5 - d6 ) >= 0 ) {\n\n\t\t\t_vbc.subVectors( c, b );\n\t\t\tw = ( d4 - d3 ) / ( ( d4 - d3 ) + ( d5 - d6 ) );\n\t\t\t// edge region of BC; barycentric coords (0, 1-w, w)\n\t\t\treturn target.copy( b ).addScaledVector( _vbc, w ); // edge region of BC\n\n\t\t}\n\n\t\t// face region\n\t\tconst denom = 1 / ( va + vb + vc );\n\t\t// u = va * denom\n\t\tv = vb * denom;\n\t\tw = vc * denom;\n\n\t\treturn target.copy( a ).addScaledVector( _vab, v ).addScaledVector( _vac, w );\n\n\t},\n\n\tequals: function ( triangle ) {\n\n\t\treturn triangle.a.equals( this.a ) && triangle.b.equals( this.b ) && triangle.c.equals( this.c );\n\n\t}\n\n} );\n\n\nexport { Triangle };\n","import { MathUtils } from './MathUtils.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nconst _colorKeywords = { 'aliceblue': 0xF0F8FF, 'antiquewhite': 0xFAEBD7, 'aqua': 0x00FFFF, 'aquamarine': 0x7FFFD4, 'azure': 0xF0FFFF,\n\t'beige': 0xF5F5DC, 'bisque': 0xFFE4C4, 'black': 0x000000, 'blanchedalmond': 0xFFEBCD, 'blue': 0x0000FF, 'blueviolet': 0x8A2BE2,\n\t'brown': 0xA52A2A, 'burlywood': 0xDEB887, 'cadetblue': 0x5F9EA0, 'chartreuse': 0x7FFF00, 'chocolate': 0xD2691E, 'coral': 0xFF7F50,\n\t'cornflowerblue': 0x6495ED, 'cornsilk': 0xFFF8DC, 'crimson': 0xDC143C, 'cyan': 0x00FFFF, 'darkblue': 0x00008B, 'darkcyan': 0x008B8B,\n\t'darkgoldenrod': 0xB8860B, 'darkgray': 0xA9A9A9, 'darkgreen': 0x006400, 'darkgrey': 0xA9A9A9, 'darkkhaki': 0xBDB76B, 'darkmagenta': 0x8B008B,\n\t'darkolivegreen': 0x556B2F, 'darkorange': 0xFF8C00, 'darkorchid': 0x9932CC, 'darkred': 0x8B0000, 'darksalmon': 0xE9967A, 'darkseagreen': 0x8FBC8F,\n\t'darkslateblue': 0x483D8B, 'darkslategray': 0x2F4F4F, 'darkslategrey': 0x2F4F4F, 'darkturquoise': 0x00CED1, 'darkviolet': 0x9400D3,\n\t'deeppink': 0xFF1493, 'deepskyblue': 0x00BFFF, 'dimgray': 0x696969, 'dimgrey': 0x696969, 'dodgerblue': 0x1E90FF, 'firebrick': 0xB22222,\n\t'floralwhite': 0xFFFAF0, 'forestgreen': 0x228B22, 'fuchsia': 0xFF00FF, 'gainsboro': 0xDCDCDC, 'ghostwhite': 0xF8F8FF, 'gold': 0xFFD700,\n\t'goldenrod': 0xDAA520, 'gray': 0x808080, 'green': 0x008000, 'greenyellow': 0xADFF2F, 'grey': 0x808080, 'honeydew': 0xF0FFF0, 'hotpink': 0xFF69B4,\n\t'indianred': 0xCD5C5C, 'indigo': 0x4B0082, 'ivory': 0xFFFFF0, 'khaki': 0xF0E68C, 'lavender': 0xE6E6FA, 'lavenderblush': 0xFFF0F5, 'lawngreen': 0x7CFC00,\n\t'lemonchiffon': 0xFFFACD, 'lightblue': 0xADD8E6, 'lightcoral': 0xF08080, 'lightcyan': 0xE0FFFF, 'lightgoldenrodyellow': 0xFAFAD2, 'lightgray': 0xD3D3D3,\n\t'lightgreen': 0x90EE90, 'lightgrey': 0xD3D3D3, 'lightpink': 0xFFB6C1, 'lightsalmon': 0xFFA07A, 'lightseagreen': 0x20B2AA, 'lightskyblue': 0x87CEFA,\n\t'lightslategray': 0x778899, 'lightslategrey': 0x778899, 'lightsteelblue': 0xB0C4DE, 'lightyellow': 0xFFFFE0, 'lime': 0x00FF00, 'limegreen': 0x32CD32,\n\t'linen': 0xFAF0E6, 'magenta': 0xFF00FF, 'maroon': 0x800000, 'mediumaquamarine': 0x66CDAA, 'mediumblue': 0x0000CD, 'mediumorchid': 0xBA55D3,\n\t'mediumpurple': 0x9370DB, 'mediumseagreen': 0x3CB371, 'mediumslateblue': 0x7B68EE, 'mediumspringgreen': 0x00FA9A, 'mediumturquoise': 0x48D1CC,\n\t'mediumvioletred': 0xC71585, 'midnightblue': 0x191970, 'mintcream': 0xF5FFFA, 'mistyrose': 0xFFE4E1, 'moccasin': 0xFFE4B5, 'navajowhite': 0xFFDEAD,\n\t'navy': 0x000080, 'oldlace': 0xFDF5E6, 'olive': 0x808000, 'olivedrab': 0x6B8E23, 'orange': 0xFFA500, 'orangered': 0xFF4500, 'orchid': 0xDA70D6,\n\t'palegoldenrod': 0xEEE8AA, 'palegreen': 0x98FB98, 'paleturquoise': 0xAFEEEE, 'palevioletred': 0xDB7093, 'papayawhip': 0xFFEFD5, 'peachpuff': 0xFFDAB9,\n\t'peru': 0xCD853F, 'pink': 0xFFC0CB, 'plum': 0xDDA0DD, 'powderblue': 0xB0E0E6, 'purple': 0x800080, 'rebeccapurple': 0x663399, 'red': 0xFF0000, 'rosybrown': 0xBC8F8F,\n\t'royalblue': 0x4169E1, 'saddlebrown': 0x8B4513, 'salmon': 0xFA8072, 'sandybrown': 0xF4A460, 'seagreen': 0x2E8B57, 'seashell': 0xFFF5EE,\n\t'sienna': 0xA0522D, 'silver': 0xC0C0C0, 'skyblue': 0x87CEEB, 'slateblue': 0x6A5ACD, 'slategray': 0x708090, 'slategrey': 0x708090, 'snow': 0xFFFAFA,\n\t'springgreen': 0x00FF7F, 'steelblue': 0x4682B4, 'tan': 0xD2B48C, 'teal': 0x008080, 'thistle': 0xD8BFD8, 'tomato': 0xFF6347, 'turquoise': 0x40E0D0,\n\t'violet': 0xEE82EE, 'wheat': 0xF5DEB3, 'white': 0xFFFFFF, 'whitesmoke': 0xF5F5F5, 'yellow': 0xFFFF00, 'yellowgreen': 0x9ACD32 };\n\nconst _hslA = { h: 0, s: 0, l: 0 };\nconst _hslB = { h: 0, s: 0, l: 0 };\n\nfunction Color( r, g, b ) {\n\n\tif ( g === undefined && b === undefined ) {\n\n\t\t// r is THREE.Color, hex or string\n\t\treturn this.set( r );\n\n\t}\n\n\treturn this.setRGB( r, g, b );\n\n}\n\nfunction hue2rgb( p, q, t ) {\n\n\tif ( t < 0 ) t += 1;\n\tif ( t > 1 ) t -= 1;\n\tif ( t < 1 / 6 ) return p + ( q - p ) * 6 * t;\n\tif ( t < 1 / 2 ) return q;\n\tif ( t < 2 / 3 ) return p + ( q - p ) * 6 * ( 2 / 3 - t );\n\treturn p;\n\n}\n\nfunction SRGBToLinear( c ) {\n\n\treturn ( c < 0.04045 ) ? c * 0.0773993808 : Math.pow( c * 0.9478672986 + 0.0521327014, 2.4 );\n\n}\n\nfunction LinearToSRGB( c ) {\n\n\treturn ( c < 0.0031308 ) ? c * 12.92 : 1.055 * ( Math.pow( c, 0.41666 ) ) - 0.055;\n\n}\n\nObject.assign( Color.prototype, {\n\n\tisColor: true,\n\n\tr: 1, g: 1, b: 1,\n\n\tset: function ( value ) {\n\n\t\tif ( value && value.isColor ) {\n\n\t\t\tthis.copy( value );\n\n\t\t} else if ( typeof value === 'number' ) {\n\n\t\t\tthis.setHex( value );\n\n\t\t} else if ( typeof value === 'string' ) {\n\n\t\t\tthis.setStyle( value );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tsetScalar: function ( scalar ) {\n\n\t\tthis.r = scalar;\n\t\tthis.g = scalar;\n\t\tthis.b = scalar;\n\n\t\treturn this;\n\n\t},\n\n\tsetHex: function ( hex ) {\n\n\t\thex = Math.floor( hex );\n\n\t\tthis.r = ( hex >> 16 & 255 ) / 255;\n\t\tthis.g = ( hex >> 8 & 255 ) / 255;\n\t\tthis.b = ( hex & 255 ) / 255;\n\n\t\treturn this;\n\n\t},\n\n\tsetRGB: function ( r, g, b ) {\n\n\t\tthis.r = r;\n\t\tthis.g = g;\n\t\tthis.b = b;\n\n\t\treturn this;\n\n\t},\n\n\tsetHSL: function ( h, s, l ) {\n\n\t\t// h,s,l ranges are in 0.0 - 1.0\n\t\th = MathUtils.euclideanModulo( h, 1 );\n\t\ts = MathUtils.clamp( s, 0, 1 );\n\t\tl = MathUtils.clamp( l, 0, 1 );\n\n\t\tif ( s === 0 ) {\n\n\t\t\tthis.r = this.g = this.b = l;\n\n\t\t} else {\n\n\t\t\tconst p = l <= 0.5 ? l * ( 1 + s ) : l + s - ( l * s );\n\t\t\tconst q = ( 2 * l ) - p;\n\n\t\t\tthis.r = hue2rgb( q, p, h + 1 / 3 );\n\t\t\tthis.g = hue2rgb( q, p, h );\n\t\t\tthis.b = hue2rgb( q, p, h - 1 / 3 );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tsetStyle: function ( style ) {\n\n\t\tfunction handleAlpha( string ) {\n\n\t\t\tif ( string === undefined ) return;\n\n\t\t\tif ( parseFloat( string ) < 1 ) {\n\n\t\t\t\tconsole.warn( 'THREE.Color: Alpha component of ' + style + ' will be ignored.' );\n\n\t\t\t}\n\n\t\t}\n\n\n\t\tlet m;\n\n\t\tif ( m = /^((?:rgb|hsl)a?)\\(\\s*([^\\)]*)\\)/.exec( style ) ) {\n\n\t\t\t// rgb / hsl\n\n\t\t\tlet color;\n\t\t\tconst name = m[ 1 ];\n\t\t\tconst components = m[ 2 ];\n\n\t\t\tswitch ( name ) {\n\n\t\t\t\tcase 'rgb':\n\t\t\t\tcase 'rgba':\n\n\t\t\t\t\tif ( color = /^(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*(,\\s*([0-9]*\\.?[0-9]+)\\s*)?$/.exec( components ) ) {\n\n\t\t\t\t\t\t// rgb(255,0,0) rgba(255,0,0,0.5)\n\t\t\t\t\t\tthis.r = Math.min( 255, parseInt( color[ 1 ], 10 ) ) / 255;\n\t\t\t\t\t\tthis.g = Math.min( 255, parseInt( color[ 2 ], 10 ) ) / 255;\n\t\t\t\t\t\tthis.b = Math.min( 255, parseInt( color[ 3 ], 10 ) ) / 255;\n\n\t\t\t\t\t\thandleAlpha( color[ 5 ] );\n\n\t\t\t\t\t\treturn this;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( color = /^(\\d+)\\%\\s*,\\s*(\\d+)\\%\\s*,\\s*(\\d+)\\%\\s*(,\\s*([0-9]*\\.?[0-9]+)\\s*)?$/.exec( components ) ) {\n\n\t\t\t\t\t\t// rgb(100%,0%,0%) rgba(100%,0%,0%,0.5)\n\t\t\t\t\t\tthis.r = Math.min( 100, parseInt( color[ 1 ], 10 ) ) / 100;\n\t\t\t\t\t\tthis.g = Math.min( 100, parseInt( color[ 2 ], 10 ) ) / 100;\n\t\t\t\t\t\tthis.b = Math.min( 100, parseInt( color[ 3 ], 10 ) ) / 100;\n\n\t\t\t\t\t\thandleAlpha( color[ 5 ] );\n\n\t\t\t\t\t\treturn this;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'hsl':\n\t\t\t\tcase 'hsla':\n\n\t\t\t\t\tif ( color = /^([0-9]*\\.?[0-9]+)\\s*,\\s*(\\d+)\\%\\s*,\\s*(\\d+)\\%\\s*(,\\s*([0-9]*\\.?[0-9]+)\\s*)?$/.exec( components ) ) {\n\n\t\t\t\t\t\t// hsl(120,50%,50%) hsla(120,50%,50%,0.5)\n\t\t\t\t\t\tconst h = parseFloat( color[ 1 ] ) / 360;\n\t\t\t\t\t\tconst s = parseInt( color[ 2 ], 10 ) / 100;\n\t\t\t\t\t\tconst l = parseInt( color[ 3 ], 10 ) / 100;\n\n\t\t\t\t\t\thandleAlpha( color[ 5 ] );\n\n\t\t\t\t\t\treturn this.setHSL( h, s, l );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\n\t\t\t}\n\n\t\t} else if ( m = /^\\#([A-Fa-f0-9]+)$/.exec( style ) ) {\n\n\t\t\t// hex color\n\n\t\t\tconst hex = m[ 1 ];\n\t\t\tconst size = hex.length;\n\n\t\t\tif ( size === 3 ) {\n\n\t\t\t\t// #ff0\n\t\t\t\tthis.r = parseInt( hex.charAt( 0 ) + hex.charAt( 0 ), 16 ) / 255;\n\t\t\t\tthis.g = parseInt( hex.charAt( 1 ) + hex.charAt( 1 ), 16 ) / 255;\n\t\t\t\tthis.b = parseInt( hex.charAt( 2 ) + hex.charAt( 2 ), 16 ) / 255;\n\n\t\t\t\treturn this;\n\n\t\t\t} else if ( size === 6 ) {\n\n\t\t\t\t// #ff0000\n\t\t\t\tthis.r = parseInt( hex.charAt( 0 ) + hex.charAt( 1 ), 16 ) / 255;\n\t\t\t\tthis.g = parseInt( hex.charAt( 2 ) + hex.charAt( 3 ), 16 ) / 255;\n\t\t\t\tthis.b = parseInt( hex.charAt( 4 ) + hex.charAt( 5 ), 16 ) / 255;\n\n\t\t\t\treturn this;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( style && style.length > 0 ) {\n\n\t\t\treturn this.setColorName( style );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tsetColorName: function ( style ) {\n\n\t\t// color keywords\n\t\tconst hex = _colorKeywords[ style ];\n\n\t\tif ( hex !== undefined ) {\n\n\t\t\t// red\n\t\t\tthis.setHex( hex );\n\n\t\t} else {\n\n\t\t\t// unknown color\n\t\t\tconsole.warn( 'THREE.Color: Unknown color ' + style );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor( this.r, this.g, this.b );\n\n\t},\n\n\tcopy: function ( color ) {\n\n\t\tthis.r = color.r;\n\t\tthis.g = color.g;\n\t\tthis.b = color.b;\n\n\t\treturn this;\n\n\t},\n\n\tcopyGammaToLinear: function ( color, gammaFactor ) {\n\n\t\tif ( gammaFactor === undefined ) gammaFactor = 2.0;\n\n\t\tthis.r = Math.pow( color.r, gammaFactor );\n\t\tthis.g = Math.pow( color.g, gammaFactor );\n\t\tthis.b = Math.pow( color.b, gammaFactor );\n\n\t\treturn this;\n\n\t},\n\n\tcopyLinearToGamma: function ( color, gammaFactor ) {\n\n\t\tif ( gammaFactor === undefined ) gammaFactor = 2.0;\n\n\t\tconst safeInverse = ( gammaFactor > 0 ) ? ( 1.0 / gammaFactor ) : 1.0;\n\n\t\tthis.r = Math.pow( color.r, safeInverse );\n\t\tthis.g = Math.pow( color.g, safeInverse );\n\t\tthis.b = Math.pow( color.b, safeInverse );\n\n\t\treturn this;\n\n\t},\n\n\tconvertGammaToLinear: function ( gammaFactor ) {\n\n\t\tthis.copyGammaToLinear( this, gammaFactor );\n\n\t\treturn this;\n\n\t},\n\n\tconvertLinearToGamma: function ( gammaFactor ) {\n\n\t\tthis.copyLinearToGamma( this, gammaFactor );\n\n\t\treturn this;\n\n\t},\n\n\tcopySRGBToLinear: function ( color ) {\n\n\t\tthis.r = SRGBToLinear( color.r );\n\t\tthis.g = SRGBToLinear( color.g );\n\t\tthis.b = SRGBToLinear( color.b );\n\n\t\treturn this;\n\n\t},\n\n\tcopyLinearToSRGB: function ( color ) {\n\n\t\tthis.r = LinearToSRGB( color.r );\n\t\tthis.g = LinearToSRGB( color.g );\n\t\tthis.b = LinearToSRGB( color.b );\n\n\t\treturn this;\n\n\t},\n\n\tconvertSRGBToLinear: function () {\n\n\t\tthis.copySRGBToLinear( this );\n\n\t\treturn this;\n\n\t},\n\n\tconvertLinearToSRGB: function () {\n\n\t\tthis.copyLinearToSRGB( this );\n\n\t\treturn this;\n\n\t},\n\n\tgetHex: function () {\n\n\t\treturn ( this.r * 255 ) << 16 ^ ( this.g * 255 ) << 8 ^ ( this.b * 255 ) << 0;\n\n\t},\n\n\tgetHexString: function () {\n\n\t\treturn ( '000000' + this.getHex().toString( 16 ) ).slice( - 6 );\n\n\t},\n\n\tgetHSL: function ( target ) {\n\n\t\t// h,s,l ranges are in 0.0 - 1.0\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Color: .getHSL() target is now required' );\n\t\t\ttarget = { h: 0, s: 0, l: 0 };\n\n\t\t}\n\n\t\tconst r = this.r, g = this.g, b = this.b;\n\n\t\tconst max = Math.max( r, g, b );\n\t\tconst min = Math.min( r, g, b );\n\n\t\tlet hue, saturation;\n\t\tconst lightness = ( min + max ) / 2.0;\n\n\t\tif ( min === max ) {\n\n\t\t\thue = 0;\n\t\t\tsaturation = 0;\n\n\t\t} else {\n\n\t\t\tconst delta = max - min;\n\n\t\t\tsaturation = lightness <= 0.5 ? delta / ( max + min ) : delta / ( 2 - max - min );\n\n\t\t\tswitch ( max ) {\n\n\t\t\t\tcase r: hue = ( g - b ) / delta + ( g < b ? 6 : 0 ); break;\n\t\t\t\tcase g: hue = ( b - r ) / delta + 2; break;\n\t\t\t\tcase b: hue = ( r - g ) / delta + 4; break;\n\n\t\t\t}\n\n\t\t\thue /= 6;\n\n\t\t}\n\n\t\ttarget.h = hue;\n\t\ttarget.s = saturation;\n\t\ttarget.l = lightness;\n\n\t\treturn target;\n\n\t},\n\n\tgetStyle: function () {\n\n\t\treturn 'rgb(' + ( ( this.r * 255 ) | 0 ) + ',' + ( ( this.g * 255 ) | 0 ) + ',' + ( ( this.b * 255 ) | 0 ) + ')';\n\n\t},\n\n\toffsetHSL: function ( h, s, l ) {\n\n\t\tthis.getHSL( _hslA );\n\n\t\t_hslA.h += h; _hslA.s += s; _hslA.l += l;\n\n\t\tthis.setHSL( _hslA.h, _hslA.s, _hslA.l );\n\n\t\treturn this;\n\n\t},\n\n\tadd: function ( color ) {\n\n\t\tthis.r += color.r;\n\t\tthis.g += color.g;\n\t\tthis.b += color.b;\n\n\t\treturn this;\n\n\t},\n\n\taddColors: function ( color1, color2 ) {\n\n\t\tthis.r = color1.r + color2.r;\n\t\tthis.g = color1.g + color2.g;\n\t\tthis.b = color1.b + color2.b;\n\n\t\treturn this;\n\n\t},\n\n\taddScalar: function ( s ) {\n\n\t\tthis.r += s;\n\t\tthis.g += s;\n\t\tthis.b += s;\n\n\t\treturn this;\n\n\t},\n\n\tsub: function ( color ) {\n\n\t\tthis.r = Math.max( 0, this.r - color.r );\n\t\tthis.g = Math.max( 0, this.g - color.g );\n\t\tthis.b = Math.max( 0, this.b - color.b );\n\n\t\treturn this;\n\n\t},\n\n\tmultiply: function ( color ) {\n\n\t\tthis.r *= color.r;\n\t\tthis.g *= color.g;\n\t\tthis.b *= color.b;\n\n\t\treturn this;\n\n\t},\n\n\tmultiplyScalar: function ( s ) {\n\n\t\tthis.r *= s;\n\t\tthis.g *= s;\n\t\tthis.b *= s;\n\n\t\treturn this;\n\n\t},\n\n\tlerp: function ( color, alpha ) {\n\n\t\tthis.r += ( color.r - this.r ) * alpha;\n\t\tthis.g += ( color.g - this.g ) * alpha;\n\t\tthis.b += ( color.b - this.b ) * alpha;\n\n\t\treturn this;\n\n\t},\n\n\tlerpHSL: function ( color, alpha ) {\n\n\t\tthis.getHSL( _hslA );\n\t\tcolor.getHSL( _hslB );\n\n\t\tconst h = MathUtils.lerp( _hslA.h, _hslB.h, alpha );\n\t\tconst s = MathUtils.lerp( _hslA.s, _hslB.s, alpha );\n\t\tconst l = MathUtils.lerp( _hslA.l, _hslB.l, alpha );\n\n\t\tthis.setHSL( h, s, l );\n\n\t\treturn this;\n\n\t},\n\n\tequals: function ( c ) {\n\n\t\treturn ( c.r === this.r ) && ( c.g === this.g ) && ( c.b === this.b );\n\n\t},\n\n\tfromArray: function ( array, offset ) {\n\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tthis.r = array[ offset ];\n\t\tthis.g = array[ offset + 1 ];\n\t\tthis.b = array[ offset + 2 ];\n\n\t\treturn this;\n\n\t},\n\n\ttoArray: function ( array, offset ) {\n\n\t\tif ( array === undefined ) array = [];\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tarray[ offset ] = this.r;\n\t\tarray[ offset + 1 ] = this.g;\n\t\tarray[ offset + 2 ] = this.b;\n\n\t\treturn array;\n\n\t},\n\n\tfromBufferAttribute: function ( attribute, index ) {\n\n\t\tthis.r = attribute.getX( index );\n\t\tthis.g = attribute.getY( index );\n\t\tthis.b = attribute.getZ( index );\n\n\t\tif ( attribute.normalized === true ) {\n\n\t\t\t// assuming Uint8Array\n\n\t\t\tthis.r /= 255;\n\t\t\tthis.g /= 255;\n\t\t\tthis.b /= 255;\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\ttoJSON: function () {\n\n\t\treturn this.getHex();\n\n\t}\n\n} );\n\nColor.NAMES = _colorKeywords;\n\nexport { Color };\n","import { Color } from '../math/Color.js';\nimport { Vector3 } from '../math/Vector3.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author alteredq / http://alteredqualia.com/\n */\n\nfunction Face3( a, b, c, normal, color, materialIndex ) {\n\n\tthis.a = a;\n\tthis.b = b;\n\tthis.c = c;\n\n\tthis.normal = ( normal && normal.isVector3 ) ? normal : new Vector3();\n\tthis.vertexNormals = Array.isArray( normal ) ? normal : [];\n\n\tthis.color = ( color && color.isColor ) ? color : new Color();\n\tthis.vertexColors = Array.isArray( color ) ? color : [];\n\n\tthis.materialIndex = materialIndex !== undefined ? materialIndex : 0;\n\n}\n\nObject.assign( Face3.prototype, {\n\n\tclone: function () {\n\n\t\treturn new this.constructor().copy( this );\n\n\t},\n\n\tcopy: function ( source ) {\n\n\t\tthis.a = source.a;\n\t\tthis.b = source.b;\n\t\tthis.c = source.c;\n\n\t\tthis.normal.copy( source.normal );\n\t\tthis.color.copy( source.color );\n\n\t\tthis.materialIndex = source.materialIndex;\n\n\t\tfor ( let i = 0, il = source.vertexNormals.length; i < il; i ++ ) {\n\n\t\t\tthis.vertexNormals[ i ] = source.vertexNormals[ i ].clone();\n\n\t\t}\n\n\t\tfor ( let i = 0, il = source.vertexColors.length; i < il; i ++ ) {\n\n\t\t\tthis.vertexColors[ i ] = source.vertexColors[ i ].clone();\n\n\t\t}\n\n\t\treturn this;\n\n\t}\n\n} );\n\n\nexport { Face3 };\n","import { EventDispatcher } from '../core/EventDispatcher.js';\nimport { FrontSide, FlatShading, NormalBlending, LessEqualDepth, AddEquation, OneMinusSrcAlphaFactor, SrcAlphaFactor, AlwaysStencilFunc, KeepStencilOp } from '../constants.js';\nimport { MathUtils } from '../math/MathUtils.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author alteredq / http://alteredqualia.com/\n */\n\nlet materialId = 0;\n\nfunction Material() {\n\n\tObject.defineProperty( this, 'id', { value: materialId ++ } );\n\n\tthis.uuid = MathUtils.generateUUID();\n\n\tthis.name = '';\n\tthis.type = 'Material';\n\n\tthis.fog = true;\n\n\tthis.blending = NormalBlending;\n\tthis.side = FrontSide;\n\tthis.flatShading = false;\n\tthis.vertexColors = false;\n\n\tthis.opacity = 1;\n\tthis.transparent = false;\n\n\tthis.blendSrc = SrcAlphaFactor;\n\tthis.blendDst = OneMinusSrcAlphaFactor;\n\tthis.blendEquation = AddEquation;\n\tthis.blendSrcAlpha = null;\n\tthis.blendDstAlpha = null;\n\tthis.blendEquationAlpha = null;\n\n\tthis.depthFunc = LessEqualDepth;\n\tthis.depthTest = true;\n\tthis.depthWrite = true;\n\n\tthis.stencilWriteMask = 0xff;\n\tthis.stencilFunc = AlwaysStencilFunc;\n\tthis.stencilRef = 0;\n\tthis.stencilFuncMask = 0xff;\n\tthis.stencilFail = KeepStencilOp;\n\tthis.stencilZFail = KeepStencilOp;\n\tthis.stencilZPass = KeepStencilOp;\n\tthis.stencilWrite = false;\n\n\tthis.clippingPlanes = null;\n\tthis.clipIntersection = false;\n\tthis.clipShadows = false;\n\n\tthis.shadowSide = null;\n\n\tthis.colorWrite = true;\n\n\tthis.precision = null; // override the renderer's default precision for this material\n\n\tthis.polygonOffset = false;\n\tthis.polygonOffsetFactor = 0;\n\tthis.polygonOffsetUnits = 0;\n\n\tthis.dithering = false;\n\n\tthis.alphaTest = 0;\n\tthis.premultipliedAlpha = false;\n\n\tthis.visible = true;\n\n\tthis.toneMapped = true;\n\n\tthis.userData = {};\n\n\tthis.version = 0;\n\n}\n\nMaterial.prototype = Object.assign( Object.create( EventDispatcher.prototype ), {\n\n\tconstructor: Material,\n\n\tisMaterial: true,\n\n\tonBeforeCompile: function ( /* shaderobject, renderer */ ) {},\n\n\tcustomProgramCacheKey: function () {\n\n\t\treturn this.onBeforeCompile.toString();\n\n\t},\n\n\tsetValues: function ( values ) {\n\n\t\tif ( values === undefined ) return;\n\n\t\tfor ( const key in values ) {\n\n\t\t\tconst newValue = values[ key ];\n\n\t\t\tif ( newValue === undefined ) {\n\n\t\t\t\tconsole.warn( \"THREE.Material: '\" + key + \"' parameter is undefined.\" );\n\t\t\t\tcontinue;\n\n\t\t\t}\n\n\t\t\t// for backward compatability if shading is set in the constructor\n\t\t\tif ( key === 'shading' ) {\n\n\t\t\t\tconsole.warn( 'THREE.' + this.type + ': .shading has been removed. Use the boolean .flatShading instead.' );\n\t\t\t\tthis.flatShading = ( newValue === FlatShading ) ? true : false;\n\t\t\t\tcontinue;\n\n\t\t\t}\n\n\t\t\tconst currentValue = this[ key ];\n\n\t\t\tif ( currentValue === undefined ) {\n\n\t\t\t\tconsole.warn( \"THREE.\" + this.type + \": '\" + key + \"' is not a property of this material.\" );\n\t\t\t\tcontinue;\n\n\t\t\t}\n\n\t\t\tif ( currentValue && currentValue.isColor ) {\n\n\t\t\t\tcurrentValue.set( newValue );\n\n\t\t\t} else if ( ( currentValue && currentValue.isVector3 ) && ( newValue && newValue.isVector3 ) ) {\n\n\t\t\t\tcurrentValue.copy( newValue );\n\n\t\t\t} else {\n\n\t\t\t\tthis[ key ] = newValue;\n\n\t\t\t}\n\n\t\t}\n\n\t},\n\n\ttoJSON: function ( meta ) {\n\n\t\tconst isRoot = ( meta === undefined || typeof meta === 'string' );\n\n\t\tif ( isRoot ) {\n\n\t\t\tmeta = {\n\t\t\t\ttextures: {},\n\t\t\t\timages: {}\n\t\t\t};\n\n\t\t}\n\n\t\tconst data = {\n\t\t\tmetadata: {\n\t\t\t\tversion: 4.5,\n\t\t\t\ttype: 'Material',\n\t\t\t\tgenerator: 'Material.toJSON'\n\t\t\t}\n\t\t};\n\n\t\t// standard Material serialization\n\t\tdata.uuid = this.uuid;\n\t\tdata.type = this.type;\n\n\t\tif ( this.name !== '' ) data.name = this.name;\n\n\t\tif ( this.color && this.color.isColor ) data.color = this.color.getHex();\n\n\t\tif ( this.roughness !== undefined ) data.roughness = this.roughness;\n\t\tif ( this.metalness !== undefined ) data.metalness = this.metalness;\n\n\t\tif ( this.sheen && this.sheen.isColor ) data.sheen = this.sheen.getHex();\n\t\tif ( this.emissive && this.emissive.isColor ) data.emissive = this.emissive.getHex();\n\t\tif ( this.emissiveIntensity && this.emissiveIntensity !== 1 ) data.emissiveIntensity = this.emissiveIntensity;\n\n\t\tif ( this.specular && this.specular.isColor ) data.specular = this.specular.getHex();\n\t\tif ( this.shininess !== undefined ) data.shininess = this.shininess;\n\t\tif ( this.clearcoat !== undefined ) data.clearcoat = this.clearcoat;\n\t\tif ( this.clearcoatRoughness !== undefined ) data.clearcoatRoughness = this.clearcoatRoughness;\n\n\t\tif ( this.clearcoatMap && this.clearcoatMap.isTexture ) {\n\n\t\t\tdata.clearcoatMap = this.clearcoatMap.toJSON( meta ).uuid;\n\n\t\t}\n\n\t\tif ( this.clearcoatRoughnessMap && this.clearcoatRoughnessMap.isTexture ) {\n\n\t\t\tdata.clearcoatRoughnessMap = this.clearcoatRoughnessMap.toJSON( meta ).uuid;\n\n\t\t}\n\n\t\tif ( this.clearcoatNormalMap && this.clearcoatNormalMap.isTexture ) {\n\n\t\t\tdata.clearcoatNormalMap = this.clearcoatNormalMap.toJSON( meta ).uuid;\n\t\t\tdata.clearcoatNormalScale = this.clearcoatNormalScale.toArray();\n\n\t\t}\n\n\t\tif ( this.map && this.map.isTexture ) data.map = this.map.toJSON( meta ).uuid;\n\t\tif ( this.matcap && this.matcap.isTexture ) data.matcap = this.matcap.toJSON( meta ).uuid;\n\t\tif ( this.alphaMap && this.alphaMap.isTexture ) data.alphaMap = this.alphaMap.toJSON( meta ).uuid;\n\t\tif ( this.lightMap && this.lightMap.isTexture ) data.lightMap = this.lightMap.toJSON( meta ).uuid;\n\n\t\tif ( this.aoMap && this.aoMap.isTexture ) {\n\n\t\t\tdata.aoMap = this.aoMap.toJSON( meta ).uuid;\n\t\t\tdata.aoMapIntensity = this.aoMapIntensity;\n\n\t\t}\n\n\t\tif ( this.bumpMap && this.bumpMap.isTexture ) {\n\n\t\t\tdata.bumpMap = this.bumpMap.toJSON( meta ).uuid;\n\t\t\tdata.bumpScale = this.bumpScale;\n\n\t\t}\n\n\t\tif ( this.normalMap && this.normalMap.isTexture ) {\n\n\t\t\tdata.normalMap = this.normalMap.toJSON( meta ).uuid;\n\t\t\tdata.normalMapType = this.normalMapType;\n\t\t\tdata.normalScale = this.normalScale.toArray();\n\n\t\t}\n\n\t\tif ( this.displacementMap && this.displacementMap.isTexture ) {\n\n\t\t\tdata.displacementMap = this.displacementMap.toJSON( meta ).uuid;\n\t\t\tdata.displacementScale = this.displacementScale;\n\t\t\tdata.displacementBias = this.displacementBias;\n\n\t\t}\n\n\t\tif ( this.roughnessMap && this.roughnessMap.isTexture ) data.roughnessMap = this.roughnessMap.toJSON( meta ).uuid;\n\t\tif ( this.metalnessMap && this.metalnessMap.isTexture ) data.metalnessMap = this.metalnessMap.toJSON( meta ).uuid;\n\n\t\tif ( this.emissiveMap && this.emissiveMap.isTexture ) data.emissiveMap = this.emissiveMap.toJSON( meta ).uuid;\n\t\tif ( this.specularMap && this.specularMap.isTexture ) data.specularMap = this.specularMap.toJSON( meta ).uuid;\n\n\t\tif ( this.envMap && this.envMap.isTexture ) {\n\n\t\t\tdata.envMap = this.envMap.toJSON( meta ).uuid;\n\t\t\tdata.reflectivity = this.reflectivity; // Scale behind envMap\n\t\t\tdata.refractionRatio = this.refractionRatio;\n\n\t\t\tif ( this.combine !== undefined ) data.combine = this.combine;\n\t\t\tif ( this.envMapIntensity !== undefined ) data.envMapIntensity = this.envMapIntensity;\n\n\t\t}\n\n\t\tif ( this.gradientMap && this.gradientMap.isTexture ) {\n\n\t\t\tdata.gradientMap = this.gradientMap.toJSON( meta ).uuid;\n\n\t\t}\n\n\t\tif ( this.size !== undefined ) data.size = this.size;\n\t\tif ( this.sizeAttenuation !== undefined ) data.sizeAttenuation = this.sizeAttenuation;\n\n\t\tif ( this.blending !== NormalBlending ) data.blending = this.blending;\n\t\tif ( this.flatShading === true ) data.flatShading = this.flatShading;\n\t\tif ( this.side !== FrontSide ) data.side = this.side;\n\t\tif ( this.vertexColors ) data.vertexColors = true;\n\n\t\tif ( this.opacity < 1 ) data.opacity = this.opacity;\n\t\tif ( this.transparent === true ) data.transparent = this.transparent;\n\n\t\tdata.depthFunc = this.depthFunc;\n\t\tdata.depthTest = this.depthTest;\n\t\tdata.depthWrite = this.depthWrite;\n\n\t\tdata.stencilWrite = this.stencilWrite;\n\t\tdata.stencilWriteMask = this.stencilWriteMask;\n\t\tdata.stencilFunc = this.stencilFunc;\n\t\tdata.stencilRef = this.stencilRef;\n\t\tdata.stencilFuncMask = this.stencilFuncMask;\n\t\tdata.stencilFail = this.stencilFail;\n\t\tdata.stencilZFail = this.stencilZFail;\n\t\tdata.stencilZPass = this.stencilZPass;\n\n\t\t// rotation (SpriteMaterial)\n\t\tif ( this.rotation && this.rotation !== 0 ) data.rotation = this.rotation;\n\n\t\tif ( this.polygonOffset === true ) data.polygonOffset = true;\n\t\tif ( this.polygonOffsetFactor !== 0 ) data.polygonOffsetFactor = this.polygonOffsetFactor;\n\t\tif ( this.polygonOffsetUnits !== 0 ) data.polygonOffsetUnits = this.polygonOffsetUnits;\n\n\t\tif ( this.linewidth && this.linewidth !== 1 ) data.linewidth = this.linewidth;\n\t\tif ( this.dashSize !== undefined ) data.dashSize = this.dashSize;\n\t\tif ( this.gapSize !== undefined ) data.gapSize = this.gapSize;\n\t\tif ( this.scale !== undefined ) data.scale = this.scale;\n\n\t\tif ( this.dithering === true ) data.dithering = true;\n\n\t\tif ( this.alphaTest > 0 ) data.alphaTest = this.alphaTest;\n\t\tif ( this.premultipliedAlpha === true ) data.premultipliedAlpha = this.premultipliedAlpha;\n\n\t\tif ( this.wireframe === true ) data.wireframe = this.wireframe;\n\t\tif ( this.wireframeLinewidth > 1 ) data.wireframeLinewidth = this.wireframeLinewidth;\n\t\tif ( this.wireframeLinecap !== 'round' ) data.wireframeLinecap = this.wireframeLinecap;\n\t\tif ( this.wireframeLinejoin !== 'round' ) data.wireframeLinejoin = this.wireframeLinejoin;\n\n\t\tif ( this.morphTargets === true ) data.morphTargets = true;\n\t\tif ( this.morphNormals === true ) data.morphNormals = true;\n\t\tif ( this.skinning === true ) data.skinning = true;\n\n\t\tif ( this.visible === false ) data.visible = false;\n\n\t\tif ( this.toneMapped === false ) data.toneMapped = false;\n\n\t\tif ( JSON.stringify( this.userData ) !== '{}' ) data.userData = this.userData;\n\n\t\t// TODO: Copied from Object3D.toJSON\n\n\t\tfunction extractFromCache( cache ) {\n\n\t\t\tconst values = [];\n\n\t\t\tfor ( const key in cache ) {\n\n\t\t\t\tconst data = cache[ key ];\n\t\t\t\tdelete data.metadata;\n\t\t\t\tvalues.push( data );\n\n\t\t\t}\n\n\t\t\treturn values;\n\n\t\t}\n\n\t\tif ( isRoot ) {\n\n\t\t\tconst textures = extractFromCache( meta.textures );\n\t\t\tconst images = extractFromCache( meta.images );\n\n\t\t\tif ( textures.length > 0 ) data.textures = textures;\n\t\t\tif ( images.length > 0 ) data.images = images;\n\n\t\t}\n\n\t\treturn data;\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor().copy( this );\n\n\t},\n\n\tcopy: function ( source ) {\n\n\t\tthis.name = source.name;\n\n\t\tthis.fog = source.fog;\n\n\t\tthis.blending = source.blending;\n\t\tthis.side = source.side;\n\t\tthis.flatShading = source.flatShading;\n\t\tthis.vertexColors = source.vertexColors;\n\n\t\tthis.opacity = source.opacity;\n\t\tthis.transparent = source.transparent;\n\n\t\tthis.blendSrc = source.blendSrc;\n\t\tthis.blendDst = source.blendDst;\n\t\tthis.blendEquation = source.blendEquation;\n\t\tthis.blendSrcAlpha = source.blendSrcAlpha;\n\t\tthis.blendDstAlpha = source.blendDstAlpha;\n\t\tthis.blendEquationAlpha = source.blendEquationAlpha;\n\n\t\tthis.depthFunc = source.depthFunc;\n\t\tthis.depthTest = source.depthTest;\n\t\tthis.depthWrite = source.depthWrite;\n\n\t\tthis.stencilWriteMask = source.stencilWriteMask;\n\t\tthis.stencilFunc = source.stencilFunc;\n\t\tthis.stencilRef = source.stencilRef;\n\t\tthis.stencilFuncMask = source.stencilFuncMask;\n\t\tthis.stencilFail = source.stencilFail;\n\t\tthis.stencilZFail = source.stencilZFail;\n\t\tthis.stencilZPass = source.stencilZPass;\n\t\tthis.stencilWrite = source.stencilWrite;\n\n\t\tconst srcPlanes = source.clippingPlanes;\n\t\tlet dstPlanes = null;\n\n\t\tif ( srcPlanes !== null ) {\n\n\t\t\tconst n = srcPlanes.length;\n\t\t\tdstPlanes = new Array( n );\n\n\t\t\tfor ( let i = 0; i !== n; ++ i ) {\n\n\t\t\t\tdstPlanes[ i ] = srcPlanes[ i ].clone();\n\n\t\t\t}\n\n\t\t}\n\n\t\tthis.clippingPlanes = dstPlanes;\n\t\tthis.clipIntersection = source.clipIntersection;\n\t\tthis.clipShadows = source.clipShadows;\n\n\t\tthis.shadowSide = source.shadowSide;\n\n\t\tthis.colorWrite = source.colorWrite;\n\n\t\tthis.precision = source.precision;\n\n\t\tthis.polygonOffset = source.polygonOffset;\n\t\tthis.polygonOffsetFactor = source.polygonOffsetFactor;\n\t\tthis.polygonOffsetUnits = source.polygonOffsetUnits;\n\n\t\tthis.dithering = source.dithering;\n\n\t\tthis.alphaTest = source.alphaTest;\n\t\tthis.premultipliedAlpha = source.premultipliedAlpha;\n\n\t\tthis.visible = source.visible;\n\n\t\tthis.toneMapped = source.toneMapped;\n\n\t\tthis.userData = JSON.parse( JSON.stringify( source.userData ) );\n\n\t\treturn this;\n\n\t},\n\n\tdispose: function () {\n\n\t\tthis.dispatchEvent( { type: 'dispose' } );\n\n\t}\n\n} );\n\nObject.defineProperty( Material.prototype, 'needsUpdate', {\n\n\tset: function ( value ) {\n\n\t\tif ( value === true ) this.version ++;\n\n\t}\n\n} );\n\nexport { Material };\n","import { Material } from './Material.js';\nimport { MultiplyOperation } from '../constants.js';\nimport { Color } from '../math/Color.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author alteredq / http://alteredqualia.com/\n *\n * parameters = {\n * color: ,\n * opacity: ,\n * map: new THREE.Texture( ),\n *\n * lightMap: new THREE.Texture( ),\n * lightMapIntensity: \n *\n * aoMap: new THREE.Texture( ),\n * aoMapIntensity: \n *\n * specularMap: new THREE.Texture( ),\n *\n * alphaMap: new THREE.Texture( ),\n *\n * envMap: new THREE.CubeTexture( [posx, negx, posy, negy, posz, negz] ),\n * combine: THREE.Multiply,\n * reflectivity: ,\n * refractionRatio: ,\n *\n * depthTest: ,\n * depthWrite: ,\n *\n * wireframe: ,\n * wireframeLinewidth: ,\n *\n * skinning: ,\n * morphTargets: \n * }\n */\n\nfunction MeshBasicMaterial( parameters ) {\n\n\tMaterial.call( this );\n\n\tthis.type = 'MeshBasicMaterial';\n\n\tthis.color = new Color( 0xffffff ); // emissive\n\n\tthis.map = null;\n\n\tthis.lightMap = null;\n\tthis.lightMapIntensity = 1.0;\n\n\tthis.aoMap = null;\n\tthis.aoMapIntensity = 1.0;\n\n\tthis.specularMap = null;\n\n\tthis.alphaMap = null;\n\n\tthis.envMap = null;\n\tthis.combine = MultiplyOperation;\n\tthis.reflectivity = 1;\n\tthis.refractionRatio = 0.98;\n\n\tthis.wireframe = false;\n\tthis.wireframeLinewidth = 1;\n\tthis.wireframeLinecap = 'round';\n\tthis.wireframeLinejoin = 'round';\n\n\tthis.skinning = false;\n\tthis.morphTargets = false;\n\n\tthis.setValues( parameters );\n\n}\n\nMeshBasicMaterial.prototype = Object.create( Material.prototype );\nMeshBasicMaterial.prototype.constructor = MeshBasicMaterial;\n\nMeshBasicMaterial.prototype.isMeshBasicMaterial = true;\n\nMeshBasicMaterial.prototype.copy = function ( source ) {\n\n\tMaterial.prototype.copy.call( this, source );\n\n\tthis.color.copy( source.color );\n\n\tthis.map = source.map;\n\n\tthis.lightMap = source.lightMap;\n\tthis.lightMapIntensity = source.lightMapIntensity;\n\n\tthis.aoMap = source.aoMap;\n\tthis.aoMapIntensity = source.aoMapIntensity;\n\n\tthis.specularMap = source.specularMap;\n\n\tthis.alphaMap = source.alphaMap;\n\n\tthis.envMap = source.envMap;\n\tthis.combine = source.combine;\n\tthis.reflectivity = source.reflectivity;\n\tthis.refractionRatio = source.refractionRatio;\n\n\tthis.wireframe = source.wireframe;\n\tthis.wireframeLinewidth = source.wireframeLinewidth;\n\tthis.wireframeLinecap = source.wireframeLinecap;\n\tthis.wireframeLinejoin = source.wireframeLinejoin;\n\n\tthis.skinning = source.skinning;\n\tthis.morphTargets = source.morphTargets;\n\n\treturn this;\n\n};\n\n\nexport { MeshBasicMaterial };\n","import { Vector4 } from '../math/Vector4.js';\nimport { Vector3 } from '../math/Vector3.js';\nimport { Vector2 } from '../math/Vector2.js';\nimport { Color } from '../math/Color.js';\nimport { StaticDrawUsage } from '../constants.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nconst _vector = new Vector3();\nconst _vector2 = new Vector2();\n\nfunction BufferAttribute( array, itemSize, normalized ) {\n\n\tif ( Array.isArray( array ) ) {\n\n\t\tthrow new TypeError( 'THREE.BufferAttribute: array should be a Typed Array.' );\n\n\t}\n\n\tthis.name = '';\n\n\tthis.array = array;\n\tthis.itemSize = itemSize;\n\tthis.count = array !== undefined ? array.length / itemSize : 0;\n\tthis.normalized = normalized === true;\n\n\tthis.usage = StaticDrawUsage;\n\tthis.updateRange = { offset: 0, count: - 1 };\n\n\tthis.version = 0;\n\n}\n\nObject.defineProperty( BufferAttribute.prototype, 'needsUpdate', {\n\n\tset: function ( value ) {\n\n\t\tif ( value === true ) this.version ++;\n\n\t}\n\n} );\n\nObject.assign( BufferAttribute.prototype, {\n\n\tisBufferAttribute: true,\n\n\tonUploadCallback: function () {},\n\n\tsetUsage: function ( value ) {\n\n\t\tthis.usage = value;\n\n\t\treturn this;\n\n\t},\n\n\tcopy: function ( source ) {\n\n\t\tthis.name = source.name;\n\t\tthis.array = new source.array.constructor( source.array );\n\t\tthis.itemSize = source.itemSize;\n\t\tthis.count = source.count;\n\t\tthis.normalized = source.normalized;\n\n\t\tthis.usage = source.usage;\n\n\t\treturn this;\n\n\t},\n\n\tcopyAt: function ( index1, attribute, index2 ) {\n\n\t\tindex1 *= this.itemSize;\n\t\tindex2 *= attribute.itemSize;\n\n\t\tfor ( let i = 0, l = this.itemSize; i < l; i ++ ) {\n\n\t\t\tthis.array[ index1 + i ] = attribute.array[ index2 + i ];\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tcopyArray: function ( array ) {\n\n\t\tthis.array.set( array );\n\n\t\treturn this;\n\n\t},\n\n\tcopyColorsArray: function ( colors ) {\n\n\t\tconst array = this.array;\n\t\tlet offset = 0;\n\n\t\tfor ( let i = 0, l = colors.length; i < l; i ++ ) {\n\n\t\t\tlet color = colors[ i ];\n\n\t\t\tif ( color === undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.BufferAttribute.copyColorsArray(): color is undefined', i );\n\t\t\t\tcolor = new Color();\n\n\t\t\t}\n\n\t\t\tarray[ offset ++ ] = color.r;\n\t\t\tarray[ offset ++ ] = color.g;\n\t\t\tarray[ offset ++ ] = color.b;\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tcopyVector2sArray: function ( vectors ) {\n\n\t\tconst array = this.array;\n\t\tlet offset = 0;\n\n\t\tfor ( let i = 0, l = vectors.length; i < l; i ++ ) {\n\n\t\t\tlet vector = vectors[ i ];\n\n\t\t\tif ( vector === undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.BufferAttribute.copyVector2sArray(): vector is undefined', i );\n\t\t\t\tvector = new Vector2();\n\n\t\t\t}\n\n\t\t\tarray[ offset ++ ] = vector.x;\n\t\t\tarray[ offset ++ ] = vector.y;\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tcopyVector3sArray: function ( vectors ) {\n\n\t\tconst array = this.array;\n\t\tlet offset = 0;\n\n\t\tfor ( let i = 0, l = vectors.length; i < l; i ++ ) {\n\n\t\t\tlet vector = vectors[ i ];\n\n\t\t\tif ( vector === undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.BufferAttribute.copyVector3sArray(): vector is undefined', i );\n\t\t\t\tvector = new Vector3();\n\n\t\t\t}\n\n\t\t\tarray[ offset ++ ] = vector.x;\n\t\t\tarray[ offset ++ ] = vector.y;\n\t\t\tarray[ offset ++ ] = vector.z;\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tcopyVector4sArray: function ( vectors ) {\n\n\t\tconst array = this.array;\n\t\tlet offset = 0;\n\n\t\tfor ( let i = 0, l = vectors.length; i < l; i ++ ) {\n\n\t\t\tlet vector = vectors[ i ];\n\n\t\t\tif ( vector === undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.BufferAttribute.copyVector4sArray(): vector is undefined', i );\n\t\t\t\tvector = new Vector4();\n\n\t\t\t}\n\n\t\t\tarray[ offset ++ ] = vector.x;\n\t\t\tarray[ offset ++ ] = vector.y;\n\t\t\tarray[ offset ++ ] = vector.z;\n\t\t\tarray[ offset ++ ] = vector.w;\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tapplyMatrix3: function ( m ) {\n\n\t\tif ( this.itemSize === 2 ) {\n\n\t\t\tfor ( let i = 0, l = this.count; i < l; i ++ ) {\n\n\t\t\t\t_vector2.fromBufferAttribute( this, i );\n\t\t\t\t_vector2.applyMatrix3( m );\n\n\t\t\t\tthis.setXY( i, _vector2.x, _vector2.y, );\n\n\t\t\t}\n\n\t\t} else if ( this.itemSize === 3 ) {\n\n\t\t\tfor ( let i = 0, l = this.count; i < l; i ++ ) {\n\n\t\t\t\t_vector.fromBufferAttribute( this, i );\n\t\t\t\t_vector.applyMatrix3( m );\n\n\t\t\t\tthis.setXYZ( i, _vector.x, _vector.y, _vector.z );\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tapplyMatrix4: function ( m ) {\n\n\t\tfor ( let i = 0, l = this.count; i < l; i ++ ) {\n\n\t\t\t_vector.x = this.getX( i );\n\t\t\t_vector.y = this.getY( i );\n\t\t\t_vector.z = this.getZ( i );\n\n\t\t\t_vector.applyMatrix4( m );\n\n\t\t\tthis.setXYZ( i, _vector.x, _vector.y, _vector.z );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tapplyNormalMatrix: function ( m ) {\n\n\t\tfor ( let i = 0, l = this.count; i < l; i ++ ) {\n\n\t\t\t_vector.x = this.getX( i );\n\t\t\t_vector.y = this.getY( i );\n\t\t\t_vector.z = this.getZ( i );\n\n\t\t\t_vector.applyNormalMatrix( m );\n\n\t\t\tthis.setXYZ( i, _vector.x, _vector.y, _vector.z );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\ttransformDirection: function ( m ) {\n\n\t\tfor ( let i = 0, l = this.count; i < l; i ++ ) {\n\n\t\t\t_vector.x = this.getX( i );\n\t\t\t_vector.y = this.getY( i );\n\t\t\t_vector.z = this.getZ( i );\n\n\t\t\t_vector.transformDirection( m );\n\n\t\t\tthis.setXYZ( i, _vector.x, _vector.y, _vector.z );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tset: function ( value, offset ) {\n\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tthis.array.set( value, offset );\n\n\t\treturn this;\n\n\t},\n\n\tgetX: function ( index ) {\n\n\t\treturn this.array[ index * this.itemSize ];\n\n\t},\n\n\tsetX: function ( index, x ) {\n\n\t\tthis.array[ index * this.itemSize ] = x;\n\n\t\treturn this;\n\n\t},\n\n\tgetY: function ( index ) {\n\n\t\treturn this.array[ index * this.itemSize + 1 ];\n\n\t},\n\n\tsetY: function ( index, y ) {\n\n\t\tthis.array[ index * this.itemSize + 1 ] = y;\n\n\t\treturn this;\n\n\t},\n\n\tgetZ: function ( index ) {\n\n\t\treturn this.array[ index * this.itemSize + 2 ];\n\n\t},\n\n\tsetZ: function ( index, z ) {\n\n\t\tthis.array[ index * this.itemSize + 2 ] = z;\n\n\t\treturn this;\n\n\t},\n\n\tgetW: function ( index ) {\n\n\t\treturn this.array[ index * this.itemSize + 3 ];\n\n\t},\n\n\tsetW: function ( index, w ) {\n\n\t\tthis.array[ index * this.itemSize + 3 ] = w;\n\n\t\treturn this;\n\n\t},\n\n\tsetXY: function ( index, x, y ) {\n\n\t\tindex *= this.itemSize;\n\n\t\tthis.array[ index + 0 ] = x;\n\t\tthis.array[ index + 1 ] = y;\n\n\t\treturn this;\n\n\t},\n\n\tsetXYZ: function ( index, x, y, z ) {\n\n\t\tindex *= this.itemSize;\n\n\t\tthis.array[ index + 0 ] = x;\n\t\tthis.array[ index + 1 ] = y;\n\t\tthis.array[ index + 2 ] = z;\n\n\t\treturn this;\n\n\t},\n\n\tsetXYZW: function ( index, x, y, z, w ) {\n\n\t\tindex *= this.itemSize;\n\n\t\tthis.array[ index + 0 ] = x;\n\t\tthis.array[ index + 1 ] = y;\n\t\tthis.array[ index + 2 ] = z;\n\t\tthis.array[ index + 3 ] = w;\n\n\t\treturn this;\n\n\t},\n\n\tonUpload: function ( callback ) {\n\n\t\tthis.onUploadCallback = callback;\n\n\t\treturn this;\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor( this.array, this.itemSize ).copy( this );\n\n\t},\n\n\ttoJSON: function () {\n\n\t\treturn {\n\t\t\titemSize: this.itemSize,\n\t\t\ttype: this.array.constructor.name,\n\t\t\tarray: Array.prototype.slice.call( this.array ),\n\t\t\tnormalized: this.normalized\n\t\t};\n\n\t}\n\n} );\n\n//\n\nfunction Int8BufferAttribute( array, itemSize, normalized ) {\n\n\tBufferAttribute.call( this, new Int8Array( array ), itemSize, normalized );\n\n}\n\nInt8BufferAttribute.prototype = Object.create( BufferAttribute.prototype );\nInt8BufferAttribute.prototype.constructor = Int8BufferAttribute;\n\n\nfunction Uint8BufferAttribute( array, itemSize, normalized ) {\n\n\tBufferAttribute.call( this, new Uint8Array( array ), itemSize, normalized );\n\n}\n\nUint8BufferAttribute.prototype = Object.create( BufferAttribute.prototype );\nUint8BufferAttribute.prototype.constructor = Uint8BufferAttribute;\n\n\nfunction Uint8ClampedBufferAttribute( array, itemSize, normalized ) {\n\n\tBufferAttribute.call( this, new Uint8ClampedArray( array ), itemSize, normalized );\n\n}\n\nUint8ClampedBufferAttribute.prototype = Object.create( BufferAttribute.prototype );\nUint8ClampedBufferAttribute.prototype.constructor = Uint8ClampedBufferAttribute;\n\n\nfunction Int16BufferAttribute( array, itemSize, normalized ) {\n\n\tBufferAttribute.call( this, new Int16Array( array ), itemSize, normalized );\n\n}\n\nInt16BufferAttribute.prototype = Object.create( BufferAttribute.prototype );\nInt16BufferAttribute.prototype.constructor = Int16BufferAttribute;\n\n\nfunction Uint16BufferAttribute( array, itemSize, normalized ) {\n\n\tBufferAttribute.call( this, new Uint16Array( array ), itemSize, normalized );\n\n}\n\nUint16BufferAttribute.prototype = Object.create( BufferAttribute.prototype );\nUint16BufferAttribute.prototype.constructor = Uint16BufferAttribute;\n\n\nfunction Int32BufferAttribute( array, itemSize, normalized ) {\n\n\tBufferAttribute.call( this, new Int32Array( array ), itemSize, normalized );\n\n}\n\nInt32BufferAttribute.prototype = Object.create( BufferAttribute.prototype );\nInt32BufferAttribute.prototype.constructor = Int32BufferAttribute;\n\n\nfunction Uint32BufferAttribute( array, itemSize, normalized ) {\n\n\tBufferAttribute.call( this, new Uint32Array( array ), itemSize, normalized );\n\n}\n\nUint32BufferAttribute.prototype = Object.create( BufferAttribute.prototype );\nUint32BufferAttribute.prototype.constructor = Uint32BufferAttribute;\n\n\nfunction Float32BufferAttribute( array, itemSize, normalized ) {\n\n\tBufferAttribute.call( this, new Float32Array( array ), itemSize, normalized );\n\n}\n\nFloat32BufferAttribute.prototype = Object.create( BufferAttribute.prototype );\nFloat32BufferAttribute.prototype.constructor = Float32BufferAttribute;\n\n\nfunction Float64BufferAttribute( array, itemSize, normalized ) {\n\n\tBufferAttribute.call( this, new Float64Array( array ), itemSize, normalized );\n\n}\n\nFloat64BufferAttribute.prototype = Object.create( BufferAttribute.prototype );\nFloat64BufferAttribute.prototype.constructor = Float64BufferAttribute;\n\n//\n\nexport {\n\tFloat64BufferAttribute,\n\tFloat32BufferAttribute,\n\tUint32BufferAttribute,\n\tInt32BufferAttribute,\n\tUint16BufferAttribute,\n\tInt16BufferAttribute,\n\tUint8ClampedBufferAttribute,\n\tUint8BufferAttribute,\n\tInt8BufferAttribute,\n\tBufferAttribute\n};\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { Vector2 } from '../math/Vector2.js';\n\nfunction DirectGeometry() {\n\n\tthis.vertices = [];\n\tthis.normals = [];\n\tthis.colors = [];\n\tthis.uvs = [];\n\tthis.uvs2 = [];\n\n\tthis.groups = [];\n\n\tthis.morphTargets = {};\n\n\tthis.skinWeights = [];\n\tthis.skinIndices = [];\n\n\t// this.lineDistances = [];\n\n\tthis.boundingBox = null;\n\tthis.boundingSphere = null;\n\n\t// update flags\n\n\tthis.verticesNeedUpdate = false;\n\tthis.normalsNeedUpdate = false;\n\tthis.colorsNeedUpdate = false;\n\tthis.uvsNeedUpdate = false;\n\tthis.groupsNeedUpdate = false;\n\n}\n\nObject.assign( DirectGeometry.prototype, {\n\n\tcomputeGroups: function ( geometry ) {\n\n\t\tconst groups = [];\n\n\t\tlet group, i;\n\t\tlet materialIndex = undefined;\n\n\t\tconst faces = geometry.faces;\n\n\t\tfor ( i = 0; i < faces.length; i ++ ) {\n\n\t\t\tconst face = faces[ i ];\n\n\t\t\t// materials\n\n\t\t\tif ( face.materialIndex !== materialIndex ) {\n\n\t\t\t\tmaterialIndex = face.materialIndex;\n\n\t\t\t\tif ( group !== undefined ) {\n\n\t\t\t\t\tgroup.count = ( i * 3 ) - group.start;\n\t\t\t\t\tgroups.push( group );\n\n\t\t\t\t}\n\n\t\t\t\tgroup = {\n\t\t\t\t\tstart: i * 3,\n\t\t\t\t\tmaterialIndex: materialIndex\n\t\t\t\t};\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( group !== undefined ) {\n\n\t\t\tgroup.count = ( i * 3 ) - group.start;\n\t\t\tgroups.push( group );\n\n\t\t}\n\n\t\tthis.groups = groups;\n\n\t},\n\n\tfromGeometry: function ( geometry ) {\n\n\t\tconst faces = geometry.faces;\n\t\tconst vertices = geometry.vertices;\n\t\tconst faceVertexUvs = geometry.faceVertexUvs;\n\n\t\tconst hasFaceVertexUv = faceVertexUvs[ 0 ] && faceVertexUvs[ 0 ].length > 0;\n\t\tconst hasFaceVertexUv2 = faceVertexUvs[ 1 ] && faceVertexUvs[ 1 ].length > 0;\n\n\t\t// morphs\n\n\t\tconst morphTargets = geometry.morphTargets;\n\t\tconst morphTargetsLength = morphTargets.length;\n\n\t\tlet morphTargetsPosition;\n\n\t\tif ( morphTargetsLength > 0 ) {\n\n\t\t\tmorphTargetsPosition = [];\n\n\t\t\tfor ( let i = 0; i < morphTargetsLength; i ++ ) {\n\n\t\t\t\tmorphTargetsPosition[ i ] = {\n\t\t\t\t\tname: morphTargets[ i ].name,\n\t\t\t\t \tdata: []\n\t\t\t\t};\n\n\t\t\t}\n\n\t\t\tthis.morphTargets.position = morphTargetsPosition;\n\n\t\t}\n\n\t\tconst morphNormals = geometry.morphNormals;\n\t\tconst morphNormalsLength = morphNormals.length;\n\n\t\tlet morphTargetsNormal;\n\n\t\tif ( morphNormalsLength > 0 ) {\n\n\t\t\tmorphTargetsNormal = [];\n\n\t\t\tfor ( let i = 0; i < morphNormalsLength; i ++ ) {\n\n\t\t\t\tmorphTargetsNormal[ i ] = {\n\t\t\t\t\tname: morphNormals[ i ].name,\n\t\t\t\t \tdata: []\n\t\t\t\t};\n\n\t\t\t}\n\n\t\t\tthis.morphTargets.normal = morphTargetsNormal;\n\n\t\t}\n\n\t\t// skins\n\n\t\tconst skinIndices = geometry.skinIndices;\n\t\tconst skinWeights = geometry.skinWeights;\n\n\t\tconst hasSkinIndices = skinIndices.length === vertices.length;\n\t\tconst hasSkinWeights = skinWeights.length === vertices.length;\n\n\t\t//\n\n\t\tif ( vertices.length > 0 && faces.length === 0 ) {\n\n\t\t\tconsole.error( 'THREE.DirectGeometry: Faceless geometries are not supported.' );\n\n\t\t}\n\n\t\tfor ( let i = 0; i < faces.length; i ++ ) {\n\n\t\t\tconst face = faces[ i ];\n\n\t\t\tthis.vertices.push( vertices[ face.a ], vertices[ face.b ], vertices[ face.c ] );\n\n\t\t\tconst vertexNormals = face.vertexNormals;\n\n\t\t\tif ( vertexNormals.length === 3 ) {\n\n\t\t\t\tthis.normals.push( vertexNormals[ 0 ], vertexNormals[ 1 ], vertexNormals[ 2 ] );\n\n\t\t\t} else {\n\n\t\t\t\tconst normal = face.normal;\n\n\t\t\t\tthis.normals.push( normal, normal, normal );\n\n\t\t\t}\n\n\t\t\tconst vertexColors = face.vertexColors;\n\n\t\t\tif ( vertexColors.length === 3 ) {\n\n\t\t\t\tthis.colors.push( vertexColors[ 0 ], vertexColors[ 1 ], vertexColors[ 2 ] );\n\n\t\t\t} else {\n\n\t\t\t\tconst color = face.color;\n\n\t\t\t\tthis.colors.push( color, color, color );\n\n\t\t\t}\n\n\t\t\tif ( hasFaceVertexUv === true ) {\n\n\t\t\t\tconst vertexUvs = faceVertexUvs[ 0 ][ i ];\n\n\t\t\t\tif ( vertexUvs !== undefined ) {\n\n\t\t\t\t\tthis.uvs.push( vertexUvs[ 0 ], vertexUvs[ 1 ], vertexUvs[ 2 ] );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tconsole.warn( 'THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ', i );\n\n\t\t\t\t\tthis.uvs.push( new Vector2(), new Vector2(), new Vector2() );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif ( hasFaceVertexUv2 === true ) {\n\n\t\t\t\tconst vertexUvs = faceVertexUvs[ 1 ][ i ];\n\n\t\t\t\tif ( vertexUvs !== undefined ) {\n\n\t\t\t\t\tthis.uvs2.push( vertexUvs[ 0 ], vertexUvs[ 1 ], vertexUvs[ 2 ] );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tconsole.warn( 'THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ', i );\n\n\t\t\t\t\tthis.uvs2.push( new Vector2(), new Vector2(), new Vector2() );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// morphs\n\n\t\t\tfor ( let j = 0; j < morphTargetsLength; j ++ ) {\n\n\t\t\t\tconst morphTarget = morphTargets[ j ].vertices;\n\n\t\t\t\tmorphTargetsPosition[ j ].data.push( morphTarget[ face.a ], morphTarget[ face.b ], morphTarget[ face.c ] );\n\n\t\t\t}\n\n\t\t\tfor ( let j = 0; j < morphNormalsLength; j ++ ) {\n\n\t\t\t\tconst morphNormal = morphNormals[ j ].vertexNormals[ i ];\n\n\t\t\t\tmorphTargetsNormal[ j ].data.push( morphNormal.a, morphNormal.b, morphNormal.c );\n\n\t\t\t}\n\n\t\t\t// skins\n\n\t\t\tif ( hasSkinIndices ) {\n\n\t\t\t\tthis.skinIndices.push( skinIndices[ face.a ], skinIndices[ face.b ], skinIndices[ face.c ] );\n\n\t\t\t}\n\n\t\t\tif ( hasSkinWeights ) {\n\n\t\t\t\tthis.skinWeights.push( skinWeights[ face.a ], skinWeights[ face.b ], skinWeights[ face.c ] );\n\n\t\t\t}\n\n\t\t}\n\n\t\tthis.computeGroups( geometry );\n\n\t\tthis.verticesNeedUpdate = geometry.verticesNeedUpdate;\n\t\tthis.normalsNeedUpdate = geometry.normalsNeedUpdate;\n\t\tthis.colorsNeedUpdate = geometry.colorsNeedUpdate;\n\t\tthis.uvsNeedUpdate = geometry.uvsNeedUpdate;\n\t\tthis.groupsNeedUpdate = geometry.groupsNeedUpdate;\n\n\t\tif ( geometry.boundingSphere !== null ) {\n\n\t\t\tthis.boundingSphere = geometry.boundingSphere.clone();\n\n\t\t}\n\n\t\tif ( geometry.boundingBox !== null ) {\n\n\t\t\tthis.boundingBox = geometry.boundingBox.clone();\n\n\t\t}\n\n\t\treturn this;\n\n\t}\n\n} );\n\n\nexport { DirectGeometry };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction arrayMin( array ) {\n\n\tif ( array.length === 0 ) return Infinity;\n\n\tlet min = array[ 0 ];\n\n\tfor ( let i = 1, l = array.length; i < l; ++ i ) {\n\n\t\tif ( array[ i ] < min ) min = array[ i ];\n\n\t}\n\n\treturn min;\n\n}\n\nfunction arrayMax( array ) {\n\n\tif ( array.length === 0 ) return - Infinity;\n\n\tlet max = array[ 0 ];\n\n\tfor ( let i = 1, l = array.length; i < l; ++ i ) {\n\n\t\tif ( array[ i ] > max ) max = array[ i ];\n\n\t}\n\n\treturn max;\n\n}\n\nexport { arrayMin, arrayMax };\n","import { Vector3 } from '../math/Vector3.js';\nimport { Box3 } from '../math/Box3.js';\nimport { EventDispatcher } from './EventDispatcher.js';\nimport { BufferAttribute, Float32BufferAttribute, Uint16BufferAttribute, Uint32BufferAttribute } from './BufferAttribute.js';\nimport { Sphere } from '../math/Sphere.js';\nimport { DirectGeometry } from './DirectGeometry.js';\nimport { Object3D } from './Object3D.js';\nimport { Matrix4 } from '../math/Matrix4.js';\nimport { Matrix3 } from '../math/Matrix3.js';\nimport { MathUtils } from '../math/MathUtils.js';\nimport { arrayMax } from '../utils.js';\n\n/**\n * @author alteredq / http://alteredqualia.com/\n * @author mrdoob / http://mrdoob.com/\n */\n\nlet _bufferGeometryId = 1; // BufferGeometry uses odd numbers as Id\n\nconst _m1 = new Matrix4();\nconst _obj = new Object3D();\nconst _offset = new Vector3();\nconst _box = new Box3();\nconst _boxMorphTargets = new Box3();\nconst _vector = new Vector3();\n\nfunction BufferGeometry() {\n\n\tObject.defineProperty( this, 'id', { value: _bufferGeometryId += 2 } );\n\n\tthis.uuid = MathUtils.generateUUID();\n\n\tthis.name = '';\n\tthis.type = 'BufferGeometry';\n\n\tthis.index = null;\n\tthis.attributes = {};\n\n\tthis.morphAttributes = {};\n\tthis.morphTargetsRelative = false;\n\n\tthis.groups = [];\n\n\tthis.boundingBox = null;\n\tthis.boundingSphere = null;\n\n\tthis.drawRange = { start: 0, count: Infinity };\n\n\tthis.userData = {};\n\n}\n\nBufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ), {\n\n\tconstructor: BufferGeometry,\n\n\tisBufferGeometry: true,\n\n\tgetIndex: function () {\n\n\t\treturn this.index;\n\n\t},\n\n\tsetIndex: function ( index ) {\n\n\t\tif ( Array.isArray( index ) ) {\n\n\t\t\tthis.index = new ( arrayMax( index ) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute )( index, 1 );\n\n\t\t} else {\n\n\t\t\tthis.index = index;\n\n\t\t}\n\n\t},\n\n\tgetAttribute: function ( name ) {\n\n\t\treturn this.attributes[ name ];\n\n\t},\n\n\tsetAttribute: function ( name, attribute ) {\n\n\t\tthis.attributes[ name ] = attribute;\n\n\t\treturn this;\n\n\t},\n\n\tdeleteAttribute: function ( name ) {\n\n\t\tdelete this.attributes[ name ];\n\n\t\treturn this;\n\n\t},\n\n\taddGroup: function ( start, count, materialIndex ) {\n\n\t\tthis.groups.push( {\n\n\t\t\tstart: start,\n\t\t\tcount: count,\n\t\t\tmaterialIndex: materialIndex !== undefined ? materialIndex : 0\n\n\t\t} );\n\n\t},\n\n\tclearGroups: function () {\n\n\t\tthis.groups = [];\n\n\t},\n\n\tsetDrawRange: function ( start, count ) {\n\n\t\tthis.drawRange.start = start;\n\t\tthis.drawRange.count = count;\n\n\t},\n\n\tapplyMatrix4: function ( matrix ) {\n\n\t\tconst position = this.attributes.position;\n\n\t\tif ( position !== undefined ) {\n\n\t\t\tposition.applyMatrix4( matrix );\n\n\t\t\tposition.needsUpdate = true;\n\n\t\t}\n\n\t\tconst normal = this.attributes.normal;\n\n\t\tif ( normal !== undefined ) {\n\n\t\t\tconst normalMatrix = new Matrix3().getNormalMatrix( matrix );\n\n\t\t\tnormal.applyNormalMatrix( normalMatrix );\n\n\t\t\tnormal.needsUpdate = true;\n\n\t\t}\n\n\t\tconst tangent = this.attributes.tangent;\n\n\t\tif ( tangent !== undefined ) {\n\n\t\t\ttangent.transformDirection( matrix );\n\n\t\t\ttangent.needsUpdate = true;\n\n\t\t}\n\n\t\tif ( this.boundingBox !== null ) {\n\n\t\t\tthis.computeBoundingBox();\n\n\t\t}\n\n\t\tif ( this.boundingSphere !== null ) {\n\n\t\t\tthis.computeBoundingSphere();\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\trotateX: function ( angle ) {\n\n\t\t// rotate geometry around world x-axis\n\n\t\t_m1.makeRotationX( angle );\n\n\t\tthis.applyMatrix4( _m1 );\n\n\t\treturn this;\n\n\t},\n\n\trotateY: function ( angle ) {\n\n\t\t// rotate geometry around world y-axis\n\n\t\t_m1.makeRotationY( angle );\n\n\t\tthis.applyMatrix4( _m1 );\n\n\t\treturn this;\n\n\t},\n\n\trotateZ: function ( angle ) {\n\n\t\t// rotate geometry around world z-axis\n\n\t\t_m1.makeRotationZ( angle );\n\n\t\tthis.applyMatrix4( _m1 );\n\n\t\treturn this;\n\n\t},\n\n\ttranslate: function ( x, y, z ) {\n\n\t\t// translate geometry\n\n\t\t_m1.makeTranslation( x, y, z );\n\n\t\tthis.applyMatrix4( _m1 );\n\n\t\treturn this;\n\n\t},\n\n\tscale: function ( x, y, z ) {\n\n\t\t// scale geometry\n\n\t\t_m1.makeScale( x, y, z );\n\n\t\tthis.applyMatrix4( _m1 );\n\n\t\treturn this;\n\n\t},\n\n\tlookAt: function ( vector ) {\n\n\t\t_obj.lookAt( vector );\n\n\t\t_obj.updateMatrix();\n\n\t\tthis.applyMatrix4( _obj.matrix );\n\n\t\treturn this;\n\n\t},\n\n\tcenter: function () {\n\n\t\tthis.computeBoundingBox();\n\n\t\tthis.boundingBox.getCenter( _offset ).negate();\n\n\t\tthis.translate( _offset.x, _offset.y, _offset.z );\n\n\t\treturn this;\n\n\t},\n\n\tsetFromObject: function ( object ) {\n\n\t\t// console.log( 'THREE.BufferGeometry.setFromObject(). Converting', object, this );\n\n\t\tconst geometry = object.geometry;\n\n\t\tif ( object.isPoints || object.isLine ) {\n\n\t\t\tconst positions = new Float32BufferAttribute( geometry.vertices.length * 3, 3 );\n\t\t\tconst colors = new Float32BufferAttribute( geometry.colors.length * 3, 3 );\n\n\t\t\tthis.setAttribute( 'position', positions.copyVector3sArray( geometry.vertices ) );\n\t\t\tthis.setAttribute( 'color', colors.copyColorsArray( geometry.colors ) );\n\n\t\t\tif ( geometry.lineDistances && geometry.lineDistances.length === geometry.vertices.length ) {\n\n\t\t\t\tconst lineDistances = new Float32BufferAttribute( geometry.lineDistances.length, 1 );\n\n\t\t\t\tthis.setAttribute( 'lineDistance', lineDistances.copyArray( geometry.lineDistances ) );\n\n\t\t\t}\n\n\t\t\tif ( geometry.boundingSphere !== null ) {\n\n\t\t\t\tthis.boundingSphere = geometry.boundingSphere.clone();\n\n\t\t\t}\n\n\t\t\tif ( geometry.boundingBox !== null ) {\n\n\t\t\t\tthis.boundingBox = geometry.boundingBox.clone();\n\n\t\t\t}\n\n\t\t} else if ( object.isMesh ) {\n\n\t\t\tif ( geometry && geometry.isGeometry ) {\n\n\t\t\t\tthis.fromGeometry( geometry );\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tsetFromPoints: function ( points ) {\n\n\t\tconst position = [];\n\n\t\tfor ( let i = 0, l = points.length; i < l; i ++ ) {\n\n\t\t\tconst point = points[ i ];\n\t\t\tposition.push( point.x, point.y, point.z || 0 );\n\n\t\t}\n\n\t\tthis.setAttribute( 'position', new Float32BufferAttribute( position, 3 ) );\n\n\t\treturn this;\n\n\t},\n\n\tupdateFromObject: function ( object ) {\n\n\t\tlet geometry = object.geometry;\n\n\t\tif ( object.isMesh ) {\n\n\t\t\tlet direct = geometry.__directGeometry;\n\n\t\t\tif ( geometry.elementsNeedUpdate === true ) {\n\n\t\t\t\tdirect = undefined;\n\t\t\t\tgeometry.elementsNeedUpdate = false;\n\n\t\t\t}\n\n\t\t\tif ( direct === undefined ) {\n\n\t\t\t\treturn this.fromGeometry( geometry );\n\n\t\t\t}\n\n\t\t\tdirect.verticesNeedUpdate = geometry.verticesNeedUpdate;\n\t\t\tdirect.normalsNeedUpdate = geometry.normalsNeedUpdate;\n\t\t\tdirect.colorsNeedUpdate = geometry.colorsNeedUpdate;\n\t\t\tdirect.uvsNeedUpdate = geometry.uvsNeedUpdate;\n\t\t\tdirect.groupsNeedUpdate = geometry.groupsNeedUpdate;\n\n\t\t\tgeometry.verticesNeedUpdate = false;\n\t\t\tgeometry.normalsNeedUpdate = false;\n\t\t\tgeometry.colorsNeedUpdate = false;\n\t\t\tgeometry.uvsNeedUpdate = false;\n\t\t\tgeometry.groupsNeedUpdate = false;\n\n\t\t\tgeometry = direct;\n\n\t\t}\n\n\t\tif ( geometry.verticesNeedUpdate === true ) {\n\n\t\t\tconst attribute = this.attributes.position;\n\n\t\t\tif ( attribute !== undefined ) {\n\n\t\t\t\tattribute.copyVector3sArray( geometry.vertices );\n\t\t\t\tattribute.needsUpdate = true;\n\n\t\t\t}\n\n\t\t\tgeometry.verticesNeedUpdate = false;\n\n\t\t}\n\n\t\tif ( geometry.normalsNeedUpdate === true ) {\n\n\t\t\tconst attribute = this.attributes.normal;\n\n\t\t\tif ( attribute !== undefined ) {\n\n\t\t\t\tattribute.copyVector3sArray( geometry.normals );\n\t\t\t\tattribute.needsUpdate = true;\n\n\t\t\t}\n\n\t\t\tgeometry.normalsNeedUpdate = false;\n\n\t\t}\n\n\t\tif ( geometry.colorsNeedUpdate === true ) {\n\n\t\t\tconst attribute = this.attributes.color;\n\n\t\t\tif ( attribute !== undefined ) {\n\n\t\t\t\tattribute.copyColorsArray( geometry.colors );\n\t\t\t\tattribute.needsUpdate = true;\n\n\t\t\t}\n\n\t\t\tgeometry.colorsNeedUpdate = false;\n\n\t\t}\n\n\t\tif ( geometry.uvsNeedUpdate ) {\n\n\t\t\tconst attribute = this.attributes.uv;\n\n\t\t\tif ( attribute !== undefined ) {\n\n\t\t\t\tattribute.copyVector2sArray( geometry.uvs );\n\t\t\t\tattribute.needsUpdate = true;\n\n\t\t\t}\n\n\t\t\tgeometry.uvsNeedUpdate = false;\n\n\t\t}\n\n\t\tif ( geometry.lineDistancesNeedUpdate ) {\n\n\t\t\tconst attribute = this.attributes.lineDistance;\n\n\t\t\tif ( attribute !== undefined ) {\n\n\t\t\t\tattribute.copyArray( geometry.lineDistances );\n\t\t\t\tattribute.needsUpdate = true;\n\n\t\t\t}\n\n\t\t\tgeometry.lineDistancesNeedUpdate = false;\n\n\t\t}\n\n\t\tif ( geometry.groupsNeedUpdate ) {\n\n\t\t\tgeometry.computeGroups( object.geometry );\n\t\t\tthis.groups = geometry.groups;\n\n\t\t\tgeometry.groupsNeedUpdate = false;\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tfromGeometry: function ( geometry ) {\n\n\t\tgeometry.__directGeometry = new DirectGeometry().fromGeometry( geometry );\n\n\t\treturn this.fromDirectGeometry( geometry.__directGeometry );\n\n\t},\n\n\tfromDirectGeometry: function ( geometry ) {\n\n\t\tconst positions = new Float32Array( geometry.vertices.length * 3 );\n\t\tthis.setAttribute( 'position', new BufferAttribute( positions, 3 ).copyVector3sArray( geometry.vertices ) );\n\n\t\tif ( geometry.normals.length > 0 ) {\n\n\t\t\tconst normals = new Float32Array( geometry.normals.length * 3 );\n\t\t\tthis.setAttribute( 'normal', new BufferAttribute( normals, 3 ).copyVector3sArray( geometry.normals ) );\n\n\t\t}\n\n\t\tif ( geometry.colors.length > 0 ) {\n\n\t\t\tconst colors = new Float32Array( geometry.colors.length * 3 );\n\t\t\tthis.setAttribute( 'color', new BufferAttribute( colors, 3 ).copyColorsArray( geometry.colors ) );\n\n\t\t}\n\n\t\tif ( geometry.uvs.length > 0 ) {\n\n\t\t\tconst uvs = new Float32Array( geometry.uvs.length * 2 );\n\t\t\tthis.setAttribute( 'uv', new BufferAttribute( uvs, 2 ).copyVector2sArray( geometry.uvs ) );\n\n\t\t}\n\n\t\tif ( geometry.uvs2.length > 0 ) {\n\n\t\t\tconst uvs2 = new Float32Array( geometry.uvs2.length * 2 );\n\t\t\tthis.setAttribute( 'uv2', new BufferAttribute( uvs2, 2 ).copyVector2sArray( geometry.uvs2 ) );\n\n\t\t}\n\n\t\t// groups\n\n\t\tthis.groups = geometry.groups;\n\n\t\t// morphs\n\n\t\tfor ( const name in geometry.morphTargets ) {\n\n\t\t\tconst array = [];\n\t\t\tconst morphTargets = geometry.morphTargets[ name ];\n\n\t\t\tfor ( let i = 0, l = morphTargets.length; i < l; i ++ ) {\n\n\t\t\t\tconst morphTarget = morphTargets[ i ];\n\n\t\t\t\tconst attribute = new Float32BufferAttribute( morphTarget.data.length * 3, 3 );\n\t\t\t\tattribute.name = morphTarget.name;\n\n\t\t\t\tarray.push( attribute.copyVector3sArray( morphTarget.data ) );\n\n\t\t\t}\n\n\t\t\tthis.morphAttributes[ name ] = array;\n\n\t\t}\n\n\t\t// skinning\n\n\t\tif ( geometry.skinIndices.length > 0 ) {\n\n\t\t\tconst skinIndices = new Float32BufferAttribute( geometry.skinIndices.length * 4, 4 );\n\t\t\tthis.setAttribute( 'skinIndex', skinIndices.copyVector4sArray( geometry.skinIndices ) );\n\n\t\t}\n\n\t\tif ( geometry.skinWeights.length > 0 ) {\n\n\t\t\tconst skinWeights = new Float32BufferAttribute( geometry.skinWeights.length * 4, 4 );\n\t\t\tthis.setAttribute( 'skinWeight', skinWeights.copyVector4sArray( geometry.skinWeights ) );\n\n\t\t}\n\n\t\t//\n\n\t\tif ( geometry.boundingSphere !== null ) {\n\n\t\t\tthis.boundingSphere = geometry.boundingSphere.clone();\n\n\t\t}\n\n\t\tif ( geometry.boundingBox !== null ) {\n\n\t\t\tthis.boundingBox = geometry.boundingBox.clone();\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tcomputeBoundingBox: function () {\n\n\t\tif ( this.boundingBox === null ) {\n\n\t\t\tthis.boundingBox = new Box3();\n\n\t\t}\n\n\t\tconst position = this.attributes.position;\n\t\tconst morphAttributesPosition = this.morphAttributes.position;\n\n\t\tif ( position !== undefined ) {\n\n\t\t\tthis.boundingBox.setFromBufferAttribute( position );\n\n\t\t\t// process morph attributes if present\n\n\t\t\tif ( morphAttributesPosition ) {\n\n\t\t\t\tfor ( let i = 0, il = morphAttributesPosition.length; i < il; i ++ ) {\n\n\t\t\t\t\tconst morphAttribute = morphAttributesPosition[ i ];\n\t\t\t\t\t_box.setFromBufferAttribute( morphAttribute );\n\n\t\t\t\t\tif ( this.morphTargetsRelative ) {\n\n\t\t\t\t\t\t_vector.addVectors( this.boundingBox.min, _box.min );\n\t\t\t\t\t\tthis.boundingBox.expandByPoint( _vector );\n\n\t\t\t\t\t\t_vector.addVectors( this.boundingBox.max, _box.max );\n\t\t\t\t\t\tthis.boundingBox.expandByPoint( _vector );\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tthis.boundingBox.expandByPoint( _box.min );\n\t\t\t\t\t\tthis.boundingBox.expandByPoint( _box.max );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tthis.boundingBox.makeEmpty();\n\n\t\t}\n\n\t\tif ( isNaN( this.boundingBox.min.x ) || isNaN( this.boundingBox.min.y ) || isNaN( this.boundingBox.min.z ) ) {\n\n\t\t\tconsole.error( 'THREE.BufferGeometry.computeBoundingBox: Computed min/max have NaN values. The \"position\" attribute is likely to have NaN values.', this );\n\n\t\t}\n\n\t},\n\n\tcomputeBoundingSphere: function () {\n\n\t\tif ( this.boundingSphere === null ) {\n\n\t\t\tthis.boundingSphere = new Sphere();\n\n\t\t}\n\n\t\tconst position = this.attributes.position;\n\t\tconst morphAttributesPosition = this.morphAttributes.position;\n\n\t\tif ( position ) {\n\n\t\t\t// first, find the center of the bounding sphere\n\n\t\t\tconst center = this.boundingSphere.center;\n\n\t\t\t_box.setFromBufferAttribute( position );\n\n\t\t\t// process morph attributes if present\n\n\t\t\tif ( morphAttributesPosition ) {\n\n\t\t\t\tfor ( let i = 0, il = morphAttributesPosition.length; i < il; i ++ ) {\n\n\t\t\t\t\tconst morphAttribute = morphAttributesPosition[ i ];\n\t\t\t\t\t_boxMorphTargets.setFromBufferAttribute( morphAttribute );\n\n\t\t\t\t\tif ( this.morphTargetsRelative ) {\n\n\t\t\t\t\t\t_vector.addVectors( _box.min, _boxMorphTargets.min );\n\t\t\t\t\t\t_box.expandByPoint( _vector );\n\n\t\t\t\t\t\t_vector.addVectors( _box.max, _boxMorphTargets.max );\n\t\t\t\t\t\t_box.expandByPoint( _vector );\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\t_box.expandByPoint( _boxMorphTargets.min );\n\t\t\t\t\t\t_box.expandByPoint( _boxMorphTargets.max );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t_box.getCenter( center );\n\n\t\t\t// second, try to find a boundingSphere with a radius smaller than the\n\t\t\t// boundingSphere of the boundingBox: sqrt(3) smaller in the best case\n\n\t\t\tlet maxRadiusSq = 0;\n\n\t\t\tfor ( let i = 0, il = position.count; i < il; i ++ ) {\n\n\t\t\t\t_vector.fromBufferAttribute( position, i );\n\n\t\t\t\tmaxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector ) );\n\n\t\t\t}\n\n\t\t\t// process morph attributes if present\n\n\t\t\tif ( morphAttributesPosition ) {\n\n\t\t\t\tfor ( let i = 0, il = morphAttributesPosition.length; i < il; i ++ ) {\n\n\t\t\t\t\tconst morphAttribute = morphAttributesPosition[ i ];\n\t\t\t\t\tconst morphTargetsRelative = this.morphTargetsRelative;\n\n\t\t\t\t\tfor ( let j = 0, jl = morphAttribute.count; j < jl; j ++ ) {\n\n\t\t\t\t\t\t_vector.fromBufferAttribute( morphAttribute, j );\n\n\t\t\t\t\t\tif ( morphTargetsRelative ) {\n\n\t\t\t\t\t\t\t_offset.fromBufferAttribute( position, j );\n\t\t\t\t\t\t\t_vector.add( _offset );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tmaxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector ) );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tthis.boundingSphere.radius = Math.sqrt( maxRadiusSq );\n\n\t\t\tif ( isNaN( this.boundingSphere.radius ) ) {\n\n\t\t\t\tconsole.error( 'THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The \"position\" attribute is likely to have NaN values.', this );\n\n\t\t\t}\n\n\t\t}\n\n\t},\n\n\tcomputeFaceNormals: function () {\n\n\t\t// backwards compatibility\n\n\t},\n\n\tcomputeVertexNormals: function () {\n\n\t\tconst index = this.index;\n\t\tconst positionAttribute = this.getAttribute( 'position' );\n\n\t\tif ( positionAttribute !== undefined ) {\n\n\t\t\tlet normalAttribute = this.getAttribute( 'normal' );\n\n\t\t\tif ( normalAttribute === undefined ) {\n\n\t\t\t\tnormalAttribute = new BufferAttribute( new Float32Array( positionAttribute.count * 3 ), 3 );\n\t\t\t\tthis.setAttribute( 'normal', normalAttribute );\n\n\t\t\t} else {\n\n\t\t\t\t// reset existing normals to zero\n\n\t\t\t\tfor ( let i = 0, il = normalAttribute.count; i < il; i ++ ) {\n\n\t\t\t\t\tnormalAttribute.setXYZ( i, 0, 0, 0 );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tconst pA = new Vector3(), pB = new Vector3(), pC = new Vector3();\n\t\t\tconst nA = new Vector3(), nB = new Vector3(), nC = new Vector3();\n\t\t\tconst cb = new Vector3(), ab = new Vector3();\n\n\t\t\t// indexed elements\n\n\t\t\tif ( index ) {\n\n\t\t\t\tfor ( let i = 0, il = index.count; i < il; i += 3 ) {\n\n\t\t\t\t\tconst vA = index.getX( i + 0 );\n\t\t\t\t\tconst vB = index.getX( i + 1 );\n\t\t\t\t\tconst vC = index.getX( i + 2 );\n\n\t\t\t\t\tpA.fromBufferAttribute( positionAttribute, vA );\n\t\t\t\t\tpB.fromBufferAttribute( positionAttribute, vB );\n\t\t\t\t\tpC.fromBufferAttribute( positionAttribute, vC );\n\n\t\t\t\t\tcb.subVectors( pC, pB );\n\t\t\t\t\tab.subVectors( pA, pB );\n\t\t\t\t\tcb.cross( ab );\n\n\t\t\t\t\tnA.fromBufferAttribute( normalAttribute, vA );\n\t\t\t\t\tnB.fromBufferAttribute( normalAttribute, vB );\n\t\t\t\t\tnC.fromBufferAttribute( normalAttribute, vC );\n\n\t\t\t\t\tnA.add( cb );\n\t\t\t\t\tnB.add( cb );\n\t\t\t\t\tnC.add( cb );\n\n\t\t\t\t\tnormalAttribute.setXYZ( vA, nA.x, nA.y, nA.z );\n\t\t\t\t\tnormalAttribute.setXYZ( vB, nB.x, nB.y, nB.z );\n\t\t\t\t\tnormalAttribute.setXYZ( vC, nC.x, nC.y, nC.z );\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\t// non-indexed elements (unconnected triangle soup)\n\n\t\t\t\tfor ( let i = 0, il = positionAttribute.count; i < il; i += 3 ) {\n\n\t\t\t\t\tpA.fromBufferAttribute( positionAttribute, i + 0 );\n\t\t\t\t\tpB.fromBufferAttribute( positionAttribute, i + 1 );\n\t\t\t\t\tpC.fromBufferAttribute( positionAttribute, i + 2 );\n\n\t\t\t\t\tcb.subVectors( pC, pB );\n\t\t\t\t\tab.subVectors( pA, pB );\n\t\t\t\t\tcb.cross( ab );\n\n\t\t\t\t\tnormalAttribute.setXYZ( i + 0, cb.x, cb.y, cb.z );\n\t\t\t\t\tnormalAttribute.setXYZ( i + 1, cb.x, cb.y, cb.z );\n\t\t\t\t\tnormalAttribute.setXYZ( i + 2, cb.x, cb.y, cb.z );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tthis.normalizeNormals();\n\n\t\t\tnormalAttribute.needsUpdate = true;\n\n\t\t}\n\n\t},\n\n\tmerge: function ( geometry, offset ) {\n\n\t\tif ( ! ( geometry && geometry.isBufferGeometry ) ) {\n\n\t\t\tconsole.error( 'THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.', geometry );\n\t\t\treturn;\n\n\t\t}\n\n\t\tif ( offset === undefined ) {\n\n\t\t\toffset = 0;\n\n\t\t\tconsole.warn(\n\t\t\t\t'THREE.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. '\n\t\t\t\t+ 'Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge.'\n\t\t\t);\n\n\t\t}\n\n\t\tconst attributes = this.attributes;\n\n\t\tfor ( const key in attributes ) {\n\n\t\t\tif ( geometry.attributes[ key ] === undefined ) continue;\n\n\t\t\tconst attribute1 = attributes[ key ];\n\t\t\tconst attributeArray1 = attribute1.array;\n\n\t\t\tconst attribute2 = geometry.attributes[ key ];\n\t\t\tconst attributeArray2 = attribute2.array;\n\n\t\t\tconst attributeOffset = attribute2.itemSize * offset;\n\t\t\tconst length = Math.min( attributeArray2.length, attributeArray1.length - attributeOffset );\n\n\t\t\tfor ( let i = 0, j = attributeOffset; i < length; i ++, j ++ ) {\n\n\t\t\t\tattributeArray1[ j ] = attributeArray2[ i ];\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tnormalizeNormals: function () {\n\n\t\tconst normals = this.attributes.normal;\n\n\t\tfor ( let i = 0, il = normals.count; i < il; i ++ ) {\n\n\t\t\t_vector.fromBufferAttribute( normals, i );\n\n\t\t\t_vector.normalize();\n\n\t\t\tnormals.setXYZ( i, _vector.x, _vector.y, _vector.z );\n\n\t\t}\n\n\t},\n\n\ttoNonIndexed: function () {\n\n\t\tfunction convertBufferAttribute( attribute, indices ) {\n\n\t\t\tconst array = attribute.array;\n\t\t\tconst itemSize = attribute.itemSize;\n\t\t\tconst normalized = attribute.normalized;\n\n\t\t\tconst array2 = new array.constructor( indices.length * itemSize );\n\n\t\t\tlet index = 0, index2 = 0;\n\n\t\t\tfor ( let i = 0, l = indices.length; i < l; i ++ ) {\n\n\t\t\t\tindex = indices[ i ] * itemSize;\n\n\t\t\t\tfor ( let j = 0; j < itemSize; j ++ ) {\n\n\t\t\t\t\tarray2[ index2 ++ ] = array[ index ++ ];\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\treturn new BufferAttribute( array2, itemSize, normalized );\n\n\t\t}\n\n\t\t//\n\n\t\tif ( this.index === null ) {\n\n\t\t\tconsole.warn( 'THREE.BufferGeometry.toNonIndexed(): Geometry is already non-indexed.' );\n\t\t\treturn this;\n\n\t\t}\n\n\t\tconst geometry2 = new BufferGeometry();\n\n\t\tconst indices = this.index.array;\n\t\tconst attributes = this.attributes;\n\n\t\t// attributes\n\n\t\tfor ( const name in attributes ) {\n\n\t\t\tconst attribute = attributes[ name ];\n\n\t\t\tconst newAttribute = convertBufferAttribute( attribute, indices );\n\n\t\t\tgeometry2.setAttribute( name, newAttribute );\n\n\t\t}\n\n\t\t// morph attributes\n\n\t\tconst morphAttributes = this.morphAttributes;\n\n\t\tfor ( const name in morphAttributes ) {\n\n\t\t\tconst morphArray = [];\n\t\t\tconst morphAttribute = morphAttributes[ name ]; // morphAttribute: array of Float32BufferAttributes\n\n\t\t\tfor ( let i = 0, il = morphAttribute.length; i < il; i ++ ) {\n\n\t\t\t\tconst attribute = morphAttribute[ i ];\n\n\t\t\t\tconst newAttribute = convertBufferAttribute( attribute, indices );\n\n\t\t\t\tmorphArray.push( newAttribute );\n\n\t\t\t}\n\n\t\t\tgeometry2.morphAttributes[ name ] = morphArray;\n\n\t\t}\n\n\t\tgeometry2.morphTargetsRelative = this.morphTargetsRelative;\n\n\t\t// groups\n\n\t\tconst groups = this.groups;\n\n\t\tfor ( let i = 0, l = groups.length; i < l; i ++ ) {\n\n\t\t\tconst group = groups[ i ];\n\t\t\tgeometry2.addGroup( group.start, group.count, group.materialIndex );\n\n\t\t}\n\n\t\treturn geometry2;\n\n\t},\n\n\ttoJSON: function () {\n\n\t\tconst data = {\n\t\t\tmetadata: {\n\t\t\t\tversion: 4.5,\n\t\t\t\ttype: 'BufferGeometry',\n\t\t\t\tgenerator: 'BufferGeometry.toJSON'\n\t\t\t}\n\t\t};\n\n\t\t// standard BufferGeometry serialization\n\n\t\tdata.uuid = this.uuid;\n\t\tdata.type = this.type;\n\t\tif ( this.name !== '' ) data.name = this.name;\n\t\tif ( Object.keys( this.userData ).length > 0 ) data.userData = this.userData;\n\n\t\tif ( this.parameters !== undefined ) {\n\n\t\t\tconst parameters = this.parameters;\n\n\t\t\tfor ( const key in parameters ) {\n\n\t\t\t\tif ( parameters[ key ] !== undefined ) data[ key ] = parameters[ key ];\n\n\t\t\t}\n\n\t\t\treturn data;\n\n\t\t}\n\n\t\tdata.data = { attributes: {} };\n\n\t\tconst index = this.index;\n\n\t\tif ( index !== null ) {\n\n\t\t\tdata.data.index = {\n\t\t\t\ttype: index.array.constructor.name,\n\t\t\t\tarray: Array.prototype.slice.call( index.array )\n\t\t\t};\n\n\t\t}\n\n\t\tconst attributes = this.attributes;\n\n\t\tfor ( const key in attributes ) {\n\n\t\t\tconst attribute = attributes[ key ];\n\n\t\t\tconst attributeData = attribute.toJSON( data.data );\n\n\t\t\tif ( attribute.name !== '' ) attributeData.name = attribute.name;\n\n\t\t\tdata.data.attributes[ key ] = attributeData;\n\n\t\t}\n\n\t\tconst morphAttributes = {};\n\t\tlet hasMorphAttributes = false;\n\n\t\tfor ( const key in this.morphAttributes ) {\n\n\t\t\tconst attributeArray = this.morphAttributes[ key ];\n\n\t\t\tconst array = [];\n\n\t\t\tfor ( let i = 0, il = attributeArray.length; i < il; i ++ ) {\n\n\t\t\t\tconst attribute = attributeArray[ i ];\n\n\t\t\t\tconst attributeData = attribute.toJSON( data.data );\n\n\t\t\t\tif ( attribute.name !== '' ) attributeData.name = attribute.name;\n\n\t\t\t\tarray.push( attributeData );\n\n\t\t\t}\n\n\t\t\tif ( array.length > 0 ) {\n\n\t\t\t\tmorphAttributes[ key ] = array;\n\n\t\t\t\thasMorphAttributes = true;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( hasMorphAttributes ) {\n\n\t\t\tdata.data.morphAttributes = morphAttributes;\n\t\t\tdata.data.morphTargetsRelative = this.morphTargetsRelative;\n\n\t\t}\n\n\t\tconst groups = this.groups;\n\n\t\tif ( groups.length > 0 ) {\n\n\t\t\tdata.data.groups = JSON.parse( JSON.stringify( groups ) );\n\n\t\t}\n\n\t\tconst boundingSphere = this.boundingSphere;\n\n\t\tif ( boundingSphere !== null ) {\n\n\t\t\tdata.data.boundingSphere = {\n\t\t\t\tcenter: boundingSphere.center.toArray(),\n\t\t\t\tradius: boundingSphere.radius\n\t\t\t};\n\n\t\t}\n\n\t\treturn data;\n\n\t},\n\n\tclone: function () {\n\n\t\t/*\n\t\t // Handle primitives\n\n\t\t const parameters = this.parameters;\n\n\t\t if ( parameters !== undefined ) {\n\n\t\t const values = [];\n\n\t\t for ( const key in parameters ) {\n\n\t\t values.push( parameters[ key ] );\n\n\t\t }\n\n\t\t const geometry = Object.create( this.constructor.prototype );\n\t\t this.constructor.apply( geometry, values );\n\t\t return geometry;\n\n\t\t }\n\n\t\t return new this.constructor().copy( this );\n\t\t */\n\n\t\treturn new BufferGeometry().copy( this );\n\n\t},\n\n\tcopy: function ( source ) {\n\n\t\t// reset\n\n\t\tthis.index = null;\n\t\tthis.attributes = {};\n\t\tthis.morphAttributes = {};\n\t\tthis.groups = [];\n\t\tthis.boundingBox = null;\n\t\tthis.boundingSphere = null;\n\n\t\t// used for storing cloned, shared data\n\n\t\tconst data = {};\n\n\t\t// name\n\n\t\tthis.name = source.name;\n\n\t\t// index\n\n\t\tconst index = source.index;\n\n\t\tif ( index !== null ) {\n\n\t\t\tthis.setIndex( index.clone( data ) );\n\n\t\t}\n\n\t\t// attributes\n\n\t\tconst attributes = source.attributes;\n\n\t\tfor ( const name in attributes ) {\n\n\t\t\tconst attribute = attributes[ name ];\n\t\t\tthis.setAttribute( name, attribute.clone( data ) );\n\n\t\t}\n\n\t\t// morph attributes\n\n\t\tconst morphAttributes = source.morphAttributes;\n\n\t\tfor ( const name in morphAttributes ) {\n\n\t\t\tconst array = [];\n\t\t\tconst morphAttribute = morphAttributes[ name ]; // morphAttribute: array of Float32BufferAttributes\n\n\t\t\tfor ( let i = 0, l = morphAttribute.length; i < l; i ++ ) {\n\n\t\t\t\tarray.push( morphAttribute[ i ].clone( data ) );\n\n\t\t\t}\n\n\t\t\tthis.morphAttributes[ name ] = array;\n\n\t\t}\n\n\t\tthis.morphTargetsRelative = source.morphTargetsRelative;\n\n\t\t// groups\n\n\t\tconst groups = source.groups;\n\n\t\tfor ( let i = 0, l = groups.length; i < l; i ++ ) {\n\n\t\t\tconst group = groups[ i ];\n\t\t\tthis.addGroup( group.start, group.count, group.materialIndex );\n\n\t\t}\n\n\t\t// bounding box\n\n\t\tconst boundingBox = source.boundingBox;\n\n\t\tif ( boundingBox !== null ) {\n\n\t\t\tthis.boundingBox = boundingBox.clone();\n\n\t\t}\n\n\t\t// bounding sphere\n\n\t\tconst boundingSphere = source.boundingSphere;\n\n\t\tif ( boundingSphere !== null ) {\n\n\t\t\tthis.boundingSphere = boundingSphere.clone();\n\n\t\t}\n\n\t\t// draw range\n\n\t\tthis.drawRange.start = source.drawRange.start;\n\t\tthis.drawRange.count = source.drawRange.count;\n\n\t\t// user data\n\n\t\tthis.userData = source.userData;\n\n\t\treturn this;\n\n\t},\n\n\tdispose: function () {\n\n\t\tthis.dispatchEvent( { type: 'dispose' } );\n\n\t}\n\n} );\n\n\nexport { BufferGeometry };\n","import { Vector3 } from '../math/Vector3.js';\nimport { Vector2 } from '../math/Vector2.js';\nimport { Sphere } from '../math/Sphere.js';\nimport { Ray } from '../math/Ray.js';\nimport { Matrix4 } from '../math/Matrix4.js';\nimport { Object3D } from '../core/Object3D.js';\nimport { Triangle } from '../math/Triangle.js';\nimport { Face3 } from '../core/Face3.js';\nimport { DoubleSide, BackSide } from '../constants.js';\nimport { MeshBasicMaterial } from '../materials/MeshBasicMaterial.js';\nimport { BufferGeometry } from '../core/BufferGeometry.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author alteredq / http://alteredqualia.com/\n * @author mikael emtinger / http://gomo.se/\n * @author jonobr1 / http://jonobr1.com/\n */\n\nconst _inverseMatrix = new Matrix4();\nconst _ray = new Ray();\nconst _sphere = new Sphere();\n\nconst _vA = new Vector3();\nconst _vB = new Vector3();\nconst _vC = new Vector3();\n\nconst _tempA = new Vector3();\nconst _tempB = new Vector3();\nconst _tempC = new Vector3();\n\nconst _morphA = new Vector3();\nconst _morphB = new Vector3();\nconst _morphC = new Vector3();\n\nconst _uvA = new Vector2();\nconst _uvB = new Vector2();\nconst _uvC = new Vector2();\n\nconst _intersectionPoint = new Vector3();\nconst _intersectionPointWorld = new Vector3();\n\nfunction Mesh( geometry, material ) {\n\n\tObject3D.call( this );\n\n\tthis.type = 'Mesh';\n\n\tthis.geometry = geometry !== undefined ? geometry : new BufferGeometry();\n\tthis.material = material !== undefined ? material : new MeshBasicMaterial();\n\n\tthis.updateMorphTargets();\n\n}\n\nMesh.prototype = Object.assign( Object.create( Object3D.prototype ), {\n\n\tconstructor: Mesh,\n\n\tisMesh: true,\n\n\tcopy: function ( source ) {\n\n\t\tObject3D.prototype.copy.call( this, source );\n\n\t\tif ( source.morphTargetInfluences !== undefined ) {\n\n\t\t\tthis.morphTargetInfluences = source.morphTargetInfluences.slice();\n\n\t\t}\n\n\t\tif ( source.morphTargetDictionary !== undefined ) {\n\n\t\t\tthis.morphTargetDictionary = Object.assign( {}, source.morphTargetDictionary );\n\n\t\t}\n\n\t\tthis.material = source.material;\n\t\tthis.geometry = source.geometry;\n\n\t\treturn this;\n\n\t},\n\n\tupdateMorphTargets: function () {\n\n\t\tconst geometry = this.geometry;\n\n\t\tif ( geometry.isBufferGeometry ) {\n\n\t\t\tconst morphAttributes = geometry.morphAttributes;\n\t\t\tconst keys = Object.keys( morphAttributes );\n\n\t\t\tif ( keys.length > 0 ) {\n\n\t\t\t\tconst morphAttribute = morphAttributes[ keys[ 0 ] ];\n\n\t\t\t\tif ( morphAttribute !== undefined ) {\n\n\t\t\t\t\tthis.morphTargetInfluences = [];\n\t\t\t\t\tthis.morphTargetDictionary = {};\n\n\t\t\t\t\tfor ( let m = 0, ml = morphAttribute.length; m < ml; m ++ ) {\n\n\t\t\t\t\t\tconst name = morphAttribute[ m ].name || String( m );\n\n\t\t\t\t\t\tthis.morphTargetInfluences.push( 0 );\n\t\t\t\t\t\tthis.morphTargetDictionary[ name ] = m;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tconst morphTargets = geometry.morphTargets;\n\n\t\t\tif ( morphTargets !== undefined && morphTargets.length > 0 ) {\n\n\t\t\t\tconsole.error( 'THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.' );\n\n\t\t\t}\n\n\t\t}\n\n\t},\n\n\traycast: function ( raycaster, intersects ) {\n\n\t\tconst geometry = this.geometry;\n\t\tconst material = this.material;\n\t\tconst matrixWorld = this.matrixWorld;\n\n\t\tif ( material === undefined ) return;\n\n\t\t// Checking boundingSphere distance to ray\n\n\t\tif ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();\n\n\t\t_sphere.copy( geometry.boundingSphere );\n\t\t_sphere.applyMatrix4( matrixWorld );\n\n\t\tif ( raycaster.ray.intersectsSphere( _sphere ) === false ) return;\n\n\t\t//\n\n\t\t_inverseMatrix.getInverse( matrixWorld );\n\t\t_ray.copy( raycaster.ray ).applyMatrix4( _inverseMatrix );\n\n\t\t// Check boundingBox before continuing\n\n\t\tif ( geometry.boundingBox !== null ) {\n\n\t\t\tif ( _ray.intersectsBox( geometry.boundingBox ) === false ) return;\n\n\t\t}\n\n\t\tlet intersection;\n\n\t\tif ( geometry.isBufferGeometry ) {\n\n\t\t\tconst index = geometry.index;\n\t\t\tconst position = geometry.attributes.position;\n\t\t\tconst morphPosition = geometry.morphAttributes.position;\n\t\t\tconst morphTargetsRelative = geometry.morphTargetsRelative;\n\t\t\tconst uv = geometry.attributes.uv;\n\t\t\tconst uv2 = geometry.attributes.uv2;\n\t\t\tconst groups = geometry.groups;\n\t\t\tconst drawRange = geometry.drawRange;\n\n\t\t\tif ( index !== null ) {\n\n\t\t\t\t// indexed buffer geometry\n\n\t\t\t\tif ( Array.isArray( material ) ) {\n\n\t\t\t\t\tfor ( let i = 0, il = groups.length; i < il; i ++ ) {\n\n\t\t\t\t\t\tconst group = groups[ i ];\n\t\t\t\t\t\tconst groupMaterial = material[ group.materialIndex ];\n\n\t\t\t\t\t\tconst start = Math.max( group.start, drawRange.start );\n\t\t\t\t\t\tconst end = Math.min( ( group.start + group.count ), ( drawRange.start + drawRange.count ) );\n\n\t\t\t\t\t\tfor ( let j = start, jl = end; j < jl; j += 3 ) {\n\n\t\t\t\t\t\t\tconst a = index.getX( j );\n\t\t\t\t\t\t\tconst b = index.getX( j + 1 );\n\t\t\t\t\t\t\tconst c = index.getX( j + 2 );\n\n\t\t\t\t\t\t\tintersection = checkBufferGeometryIntersection( this, groupMaterial, raycaster, _ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c );\n\n\t\t\t\t\t\t\tif ( intersection ) {\n\n\t\t\t\t\t\t\t\tintersection.faceIndex = Math.floor( j / 3 ); // triangle number in indexed buffer semantics\n\t\t\t\t\t\t\t\tintersection.face.materialIndex = group.materialIndex;\n\t\t\t\t\t\t\t\tintersects.push( intersection );\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\n\t\t\t\t\tconst start = Math.max( 0, drawRange.start );\n\t\t\t\t\tconst end = Math.min( index.count, ( drawRange.start + drawRange.count ) );\n\n\t\t\t\t\tfor ( let i = start, il = end; i < il; i += 3 ) {\n\n\t\t\t\t\t\tconst a = index.getX( i );\n\t\t\t\t\t\tconst b = index.getX( i + 1 );\n\t\t\t\t\t\tconst c = index.getX( i + 2 );\n\n\t\t\t\t\t\tintersection = checkBufferGeometryIntersection( this, material, raycaster, _ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c );\n\n\t\t\t\t\t\tif ( intersection ) {\n\n\t\t\t\t\t\t\tintersection.faceIndex = Math.floor( i / 3 ); // triangle number in indexed buffer semantics\n\t\t\t\t\t\t\tintersects.push( intersection );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t} else if ( position !== undefined ) {\n\n\t\t\t\t// non-indexed buffer geometry\n\n\t\t\t\tif ( Array.isArray( material ) ) {\n\n\t\t\t\t\tfor ( let i = 0, il = groups.length; i < il; i ++ ) {\n\n\t\t\t\t\t\tconst group = groups[ i ];\n\t\t\t\t\t\tconst groupMaterial = material[ group.materialIndex ];\n\n\t\t\t\t\t\tconst start = Math.max( group.start, drawRange.start );\n\t\t\t\t\t\tconst end = Math.min( ( group.start + group.count ), ( drawRange.start + drawRange.count ) );\n\n\t\t\t\t\t\tfor ( let j = start, jl = end; j < jl; j += 3 ) {\n\n\t\t\t\t\t\t\tconst a = j;\n\t\t\t\t\t\t\tconst b = j + 1;\n\t\t\t\t\t\t\tconst c = j + 2;\n\n\t\t\t\t\t\t\tintersection = checkBufferGeometryIntersection( this, groupMaterial, raycaster, _ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c );\n\n\t\t\t\t\t\t\tif ( intersection ) {\n\n\t\t\t\t\t\t\t\tintersection.faceIndex = Math.floor( j / 3 ); // triangle number in non-indexed buffer semantics\n\t\t\t\t\t\t\t\tintersection.face.materialIndex = group.materialIndex;\n\t\t\t\t\t\t\t\tintersects.push( intersection );\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\n\t\t\t\t\tconst start = Math.max( 0, drawRange.start );\n\t\t\t\t\tconst end = Math.min( position.count, ( drawRange.start + drawRange.count ) );\n\n\t\t\t\t\tfor ( let i = start, il = end; i < il; i += 3 ) {\n\n\t\t\t\t\t\tconst a = i;\n\t\t\t\t\t\tconst b = i + 1;\n\t\t\t\t\t\tconst c = i + 2;\n\n\t\t\t\t\t\tintersection = checkBufferGeometryIntersection( this, material, raycaster, _ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c );\n\n\t\t\t\t\t\tif ( intersection ) {\n\n\t\t\t\t\t\t\tintersection.faceIndex = Math.floor( i / 3 ); // triangle number in non-indexed buffer semantics\n\t\t\t\t\t\t\tintersects.push( intersection );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} else if ( geometry.isGeometry ) {\n\n\t\t\tconst isMultiMaterial = Array.isArray( material );\n\n\t\t\tconst vertices = geometry.vertices;\n\t\t\tconst faces = geometry.faces;\n\t\t\tlet uvs;\n\n\t\t\tconst faceVertexUvs = geometry.faceVertexUvs[ 0 ];\n\t\t\tif ( faceVertexUvs.length > 0 ) uvs = faceVertexUvs;\n\n\t\t\tfor ( let f = 0, fl = faces.length; f < fl; f ++ ) {\n\n\t\t\t\tconst face = faces[ f ];\n\t\t\t\tconst faceMaterial = isMultiMaterial ? material[ face.materialIndex ] : material;\n\n\t\t\t\tif ( faceMaterial === undefined ) continue;\n\n\t\t\t\tconst fvA = vertices[ face.a ];\n\t\t\t\tconst fvB = vertices[ face.b ];\n\t\t\t\tconst fvC = vertices[ face.c ];\n\n\t\t\t\tintersection = checkIntersection( this, faceMaterial, raycaster, _ray, fvA, fvB, fvC, _intersectionPoint );\n\n\t\t\t\tif ( intersection ) {\n\n\t\t\t\t\tif ( uvs && uvs[ f ] ) {\n\n\t\t\t\t\t\tconst uvs_f = uvs[ f ];\n\t\t\t\t\t\t_uvA.copy( uvs_f[ 0 ] );\n\t\t\t\t\t\t_uvB.copy( uvs_f[ 1 ] );\n\t\t\t\t\t\t_uvC.copy( uvs_f[ 2 ] );\n\n\t\t\t\t\t\tintersection.uv = Triangle.getUV( _intersectionPoint, fvA, fvB, fvC, _uvA, _uvB, _uvC, new Vector2() );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tintersection.face = face;\n\t\t\t\t\tintersection.faceIndex = f;\n\t\t\t\t\tintersects.push( intersection );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n} );\n\nfunction checkIntersection( object, material, raycaster, ray, pA, pB, pC, point ) {\n\n\tlet intersect;\n\n\tif ( material.side === BackSide ) {\n\n\t\tintersect = ray.intersectTriangle( pC, pB, pA, true, point );\n\n\t} else {\n\n\t\tintersect = ray.intersectTriangle( pA, pB, pC, material.side !== DoubleSide, point );\n\n\t}\n\n\tif ( intersect === null ) return null;\n\n\t_intersectionPointWorld.copy( point );\n\t_intersectionPointWorld.applyMatrix4( object.matrixWorld );\n\n\tconst distance = raycaster.ray.origin.distanceTo( _intersectionPointWorld );\n\n\tif ( distance < raycaster.near || distance > raycaster.far ) return null;\n\n\treturn {\n\t\tdistance: distance,\n\t\tpoint: _intersectionPointWorld.clone(),\n\t\tobject: object\n\t};\n\n}\n\nfunction checkBufferGeometryIntersection( object, material, raycaster, ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c ) {\n\n\t_vA.fromBufferAttribute( position, a );\n\t_vB.fromBufferAttribute( position, b );\n\t_vC.fromBufferAttribute( position, c );\n\n\tconst morphInfluences = object.morphTargetInfluences;\n\n\tif ( material.morphTargets && morphPosition && morphInfluences ) {\n\n\t\t_morphA.set( 0, 0, 0 );\n\t\t_morphB.set( 0, 0, 0 );\n\t\t_morphC.set( 0, 0, 0 );\n\n\t\tfor ( let i = 0, il = morphPosition.length; i < il; i ++ ) {\n\n\t\t\tconst influence = morphInfluences[ i ];\n\t\t\tconst morphAttribute = morphPosition[ i ];\n\n\t\t\tif ( influence === 0 ) continue;\n\n\t\t\t_tempA.fromBufferAttribute( morphAttribute, a );\n\t\t\t_tempB.fromBufferAttribute( morphAttribute, b );\n\t\t\t_tempC.fromBufferAttribute( morphAttribute, c );\n\n\t\t\tif ( morphTargetsRelative ) {\n\n\t\t\t\t_morphA.addScaledVector( _tempA, influence );\n\t\t\t\t_morphB.addScaledVector( _tempB, influence );\n\t\t\t\t_morphC.addScaledVector( _tempC, influence );\n\n\t\t\t} else {\n\n\t\t\t\t_morphA.addScaledVector( _tempA.sub( _vA ), influence );\n\t\t\t\t_morphB.addScaledVector( _tempB.sub( _vB ), influence );\n\t\t\t\t_morphC.addScaledVector( _tempC.sub( _vC ), influence );\n\n\t\t\t}\n\n\t\t}\n\n\t\t_vA.add( _morphA );\n\t\t_vB.add( _morphB );\n\t\t_vC.add( _morphC );\n\n\t}\n\n\tif ( object.isSkinnedMesh ) {\n\n\t\tobject.boneTransform( a, _vA );\n\t\tobject.boneTransform( b, _vB );\n\t\tobject.boneTransform( c, _vC );\n\n\t}\n\n\tconst intersection = checkIntersection( object, material, raycaster, ray, _vA, _vB, _vC, _intersectionPoint );\n\n\tif ( intersection ) {\n\n\t\tif ( uv ) {\n\n\t\t\t_uvA.fromBufferAttribute( uv, a );\n\t\t\t_uvB.fromBufferAttribute( uv, b );\n\t\t\t_uvC.fromBufferAttribute( uv, c );\n\n\t\t\tintersection.uv = Triangle.getUV( _intersectionPoint, _vA, _vB, _vC, _uvA, _uvB, _uvC, new Vector2() );\n\n\t\t}\n\n\t\tif ( uv2 ) {\n\n\t\t\t_uvA.fromBufferAttribute( uv2, a );\n\t\t\t_uvB.fromBufferAttribute( uv2, b );\n\t\t\t_uvC.fromBufferAttribute( uv2, c );\n\n\t\t\tintersection.uv2 = Triangle.getUV( _intersectionPoint, _vA, _vB, _vC, _uvA, _uvB, _uvC, new Vector2() );\n\n\t\t}\n\n\t\tconst face = new Face3( a, b, c );\n\t\tTriangle.getNormal( _vA, _vB, _vC, face.normal );\n\n\t\tintersection.face = face;\n\n\t}\n\n\treturn intersection;\n\n}\n\nexport { Mesh };\n","import { EventDispatcher } from './EventDispatcher.js';\nimport { Face3 } from './Face3.js';\nimport { Matrix3 } from '../math/Matrix3.js';\nimport { Sphere } from '../math/Sphere.js';\nimport { Box3 } from '../math/Box3.js';\nimport { Vector3 } from '../math/Vector3.js';\nimport { Matrix4 } from '../math/Matrix4.js';\nimport { Vector2 } from '../math/Vector2.js';\nimport { Color } from '../math/Color.js';\nimport { Object3D } from './Object3D.js';\nimport { MathUtils } from '../math/MathUtils.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author kile / http://kile.stravaganza.org/\n * @author alteredq / http://alteredqualia.com/\n * @author mikael emtinger / http://gomo.se/\n * @author zz85 / http://www.lab4games.net/zz85/blog\n * @author bhouston / http://clara.io\n */\n\nlet _geometryId = 0; // Geometry uses even numbers as Id\nconst _m1 = new Matrix4();\nconst _obj = new Object3D();\nconst _offset = new Vector3();\n\nfunction Geometry() {\n\n\tObject.defineProperty( this, 'id', { value: _geometryId += 2 } );\n\n\tthis.uuid = MathUtils.generateUUID();\n\n\tthis.name = '';\n\tthis.type = 'Geometry';\n\n\tthis.vertices = [];\n\tthis.colors = [];\n\tthis.faces = [];\n\tthis.faceVertexUvs = [[]];\n\n\tthis.morphTargets = [];\n\tthis.morphNormals = [];\n\n\tthis.skinWeights = [];\n\tthis.skinIndices = [];\n\n\tthis.lineDistances = [];\n\n\tthis.boundingBox = null;\n\tthis.boundingSphere = null;\n\n\t// update flags\n\n\tthis.elementsNeedUpdate = false;\n\tthis.verticesNeedUpdate = false;\n\tthis.uvsNeedUpdate = false;\n\tthis.normalsNeedUpdate = false;\n\tthis.colorsNeedUpdate = false;\n\tthis.lineDistancesNeedUpdate = false;\n\tthis.groupsNeedUpdate = false;\n\n}\n\nGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ), {\n\n\tconstructor: Geometry,\n\n\tisGeometry: true,\n\n\tapplyMatrix4: function ( matrix ) {\n\n\t\tconst normalMatrix = new Matrix3().getNormalMatrix( matrix );\n\n\t\tfor ( let i = 0, il = this.vertices.length; i < il; i ++ ) {\n\n\t\t\tconst vertex = this.vertices[ i ];\n\t\t\tvertex.applyMatrix4( matrix );\n\n\t\t}\n\n\t\tfor ( let i = 0, il = this.faces.length; i < il; i ++ ) {\n\n\t\t\tconst face = this.faces[ i ];\n\t\t\tface.normal.applyMatrix3( normalMatrix ).normalize();\n\n\t\t\tfor ( let j = 0, jl = face.vertexNormals.length; j < jl; j ++ ) {\n\n\t\t\t\tface.vertexNormals[ j ].applyMatrix3( normalMatrix ).normalize();\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( this.boundingBox !== null ) {\n\n\t\t\tthis.computeBoundingBox();\n\n\t\t}\n\n\t\tif ( this.boundingSphere !== null ) {\n\n\t\t\tthis.computeBoundingSphere();\n\n\t\t}\n\n\t\tthis.verticesNeedUpdate = true;\n\t\tthis.normalsNeedUpdate = true;\n\n\t\treturn this;\n\n\t},\n\n\trotateX: function ( angle ) {\n\n\t\t// rotate geometry around world x-axis\n\n\t\t_m1.makeRotationX( angle );\n\n\t\tthis.applyMatrix4( _m1 );\n\n\t\treturn this;\n\n\t},\n\n\trotateY: function ( angle ) {\n\n\t\t// rotate geometry around world y-axis\n\n\t\t_m1.makeRotationY( angle );\n\n\t\tthis.applyMatrix4( _m1 );\n\n\t\treturn this;\n\n\t},\n\n\trotateZ: function ( angle ) {\n\n\t\t// rotate geometry around world z-axis\n\n\t\t_m1.makeRotationZ( angle );\n\n\t\tthis.applyMatrix4( _m1 );\n\n\t\treturn this;\n\n\t},\n\n\ttranslate: function ( x, y, z ) {\n\n\t\t// translate geometry\n\n\t\t_m1.makeTranslation( x, y, z );\n\n\t\tthis.applyMatrix4( _m1 );\n\n\t\treturn this;\n\n\t},\n\n\tscale: function ( x, y, z ) {\n\n\t\t// scale geometry\n\n\t\t_m1.makeScale( x, y, z );\n\n\t\tthis.applyMatrix4( _m1 );\n\n\t\treturn this;\n\n\t},\n\n\tlookAt: function ( vector ) {\n\n\t\t_obj.lookAt( vector );\n\n\t\t_obj.updateMatrix();\n\n\t\tthis.applyMatrix4( _obj.matrix );\n\n\t\treturn this;\n\n\t},\n\n\tfromBufferGeometry: function ( geometry ) {\n\n\t\tconst scope = this;\n\n\t\tconst index = geometry.index !== null ? geometry.index : undefined;\n\t\tconst attributes = geometry.attributes;\n\n\t\tif ( attributes.position === undefined ) {\n\n\t\t\tconsole.error( 'THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion.' );\n\t\t\treturn this;\n\n\t\t}\n\n\t\tconst position = attributes.position;\n\t\tconst normal = attributes.normal;\n\t\tconst color = attributes.color;\n\t\tconst uv = attributes.uv;\n\t\tconst uv2 = attributes.uv2;\n\n\t\tif ( uv2 !== undefined ) this.faceVertexUvs[ 1 ] = [];\n\n\t\tfor ( let i = 0; i < position.count; i ++ ) {\n\n\t\t\tscope.vertices.push( new Vector3().fromBufferAttribute( position, i ) );\n\n\t\t\tif ( color !== undefined ) {\n\n\t\t\t\tscope.colors.push( new Color().fromBufferAttribute( color, i ) );\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction addFace( a, b, c, materialIndex ) {\n\n\t\t\tconst vertexColors = ( color === undefined ) ? [] : [\n\t\t\t\tscope.colors[ a ].clone(),\n\t\t\t\tscope.colors[ b ].clone(),\n\t\t\t\tscope.colors[ c ].clone()\n\t\t\t];\n\n\t\t\tconst vertexNormals = ( normal === undefined ) ? [] : [\n\t\t\t\tnew Vector3().fromBufferAttribute( normal, a ),\n\t\t\t\tnew Vector3().fromBufferAttribute( normal, b ),\n\t\t\t\tnew Vector3().fromBufferAttribute( normal, c )\n\t\t\t];\n\n\t\t\tconst face = new Face3( a, b, c, vertexNormals, vertexColors, materialIndex );\n\n\t\t\tscope.faces.push( face );\n\n\t\t\tif ( uv !== undefined ) {\n\n\t\t\t\tscope.faceVertexUvs[ 0 ].push( [\n\t\t\t\t\tnew Vector2().fromBufferAttribute( uv, a ),\n\t\t\t\t\tnew Vector2().fromBufferAttribute( uv, b ),\n\t\t\t\t\tnew Vector2().fromBufferAttribute( uv, c )\n\t\t\t\t] );\n\n\t\t\t}\n\n\t\t\tif ( uv2 !== undefined ) {\n\n\t\t\t\tscope.faceVertexUvs[ 1 ].push( [\n\t\t\t\t\tnew Vector2().fromBufferAttribute( uv2, a ),\n\t\t\t\t\tnew Vector2().fromBufferAttribute( uv2, b ),\n\t\t\t\t\tnew Vector2().fromBufferAttribute( uv2, c )\n\t\t\t\t] );\n\n\t\t\t}\n\n\t\t}\n\n\t\tconst groups = geometry.groups;\n\n\t\tif ( groups.length > 0 ) {\n\n\t\t\tfor ( let i = 0; i < groups.length; i ++ ) {\n\n\t\t\t\tconst group = groups[ i ];\n\n\t\t\t\tconst start = group.start;\n\t\t\t\tconst count = group.count;\n\n\t\t\t\tfor ( let j = start, jl = start + count; j < jl; j += 3 ) {\n\n\t\t\t\t\tif ( index !== undefined ) {\n\n\t\t\t\t\t\taddFace( index.getX( j ), index.getX( j + 1 ), index.getX( j + 2 ), group.materialIndex );\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\taddFace( j, j + 1, j + 2, group.materialIndex );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tif ( index !== undefined ) {\n\n\t\t\t\tfor ( let i = 0; i < index.count; i += 3 ) {\n\n\t\t\t\t\taddFace( index.getX( i ), index.getX( i + 1 ), index.getX( i + 2 ) );\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\tfor ( let i = 0; i < position.count; i += 3 ) {\n\n\t\t\t\t\taddFace( i, i + 1, i + 2 );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tthis.computeFaceNormals();\n\n\t\tif ( geometry.boundingBox !== null ) {\n\n\t\t\tthis.boundingBox = geometry.boundingBox.clone();\n\n\t\t}\n\n\t\tif ( geometry.boundingSphere !== null ) {\n\n\t\t\tthis.boundingSphere = geometry.boundingSphere.clone();\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tcenter: function () {\n\n\t\tthis.computeBoundingBox();\n\n\t\tthis.boundingBox.getCenter( _offset ).negate();\n\n\t\tthis.translate( _offset.x, _offset.y, _offset.z );\n\n\t\treturn this;\n\n\t},\n\n\tnormalize: function () {\n\n\t\tthis.computeBoundingSphere();\n\n\t\tconst center = this.boundingSphere.center;\n\t\tconst radius = this.boundingSphere.radius;\n\n\t\tconst s = radius === 0 ? 1 : 1.0 / radius;\n\n\t\tconst matrix = new Matrix4();\n\t\tmatrix.set(\n\t\t\ts, 0, 0, - s * center.x,\n\t\t\t0, s, 0, - s * center.y,\n\t\t\t0, 0, s, - s * center.z,\n\t\t\t0, 0, 0, 1\n\t\t);\n\n\t\tthis.applyMatrix4( matrix );\n\n\t\treturn this;\n\n\t},\n\n\tcomputeFaceNormals: function () {\n\n\t\tconst cb = new Vector3(), ab = new Vector3();\n\n\t\tfor ( let f = 0, fl = this.faces.length; f < fl; f ++ ) {\n\n\t\t\tconst face = this.faces[ f ];\n\n\t\t\tconst vA = this.vertices[ face.a ];\n\t\t\tconst vB = this.vertices[ face.b ];\n\t\t\tconst vC = this.vertices[ face.c ];\n\n\t\t\tcb.subVectors( vC, vB );\n\t\t\tab.subVectors( vA, vB );\n\t\t\tcb.cross( ab );\n\n\t\t\tcb.normalize();\n\n\t\t\tface.normal.copy( cb );\n\n\t\t}\n\n\t},\n\n\tcomputeVertexNormals: function ( areaWeighted ) {\n\n\t\tif ( areaWeighted === undefined ) areaWeighted = true;\n\n\t\tconst vertices = new Array( this.vertices.length );\n\n\t\tfor ( let v = 0, vl = this.vertices.length; v < vl; v ++ ) {\n\n\t\t\tvertices[ v ] = new Vector3();\n\n\t\t}\n\n\t\tif ( areaWeighted ) {\n\n\t\t\t// vertex normals weighted by triangle areas\n\t\t\t// http://www.iquilezles.org/www/articles/normals/normals.htm\n\n\t\t\tconst cb = new Vector3(), ab = new Vector3();\n\n\t\t\tfor ( let f = 0, fl = this.faces.length; f < fl; f ++ ) {\n\n\t\t\t\tconst face = this.faces[ f ];\n\n\t\t\t\tconst vA = this.vertices[ face.a ];\n\t\t\t\tconst vB = this.vertices[ face.b ];\n\t\t\t\tconst vC = this.vertices[ face.c ];\n\n\t\t\t\tcb.subVectors( vC, vB );\n\t\t\t\tab.subVectors( vA, vB );\n\t\t\t\tcb.cross( ab );\n\n\t\t\t\tvertices[ face.a ].add( cb );\n\t\t\t\tvertices[ face.b ].add( cb );\n\t\t\t\tvertices[ face.c ].add( cb );\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tthis.computeFaceNormals();\n\n\t\t\tfor ( let f = 0, fl = this.faces.length; f < fl; f ++ ) {\n\n\t\t\t\tconst face = this.faces[ f ];\n\n\t\t\t\tvertices[ face.a ].add( face.normal );\n\t\t\t\tvertices[ face.b ].add( face.normal );\n\t\t\t\tvertices[ face.c ].add( face.normal );\n\n\t\t\t}\n\n\t\t}\n\n\t\tfor ( let v = 0, vl = this.vertices.length; v < vl; v ++ ) {\n\n\t\t\tvertices[ v ].normalize();\n\n\t\t}\n\n\t\tfor ( let f = 0, fl = this.faces.length; f < fl; f ++ ) {\n\n\t\t\tconst face = this.faces[ f ];\n\n\t\t\tconst vertexNormals = face.vertexNormals;\n\n\t\t\tif ( vertexNormals.length === 3 ) {\n\n\t\t\t\tvertexNormals[ 0 ].copy( vertices[ face.a ] );\n\t\t\t\tvertexNormals[ 1 ].copy( vertices[ face.b ] );\n\t\t\t\tvertexNormals[ 2 ].copy( vertices[ face.c ] );\n\n\t\t\t} else {\n\n\t\t\t\tvertexNormals[ 0 ] = vertices[ face.a ].clone();\n\t\t\t\tvertexNormals[ 1 ] = vertices[ face.b ].clone();\n\t\t\t\tvertexNormals[ 2 ] = vertices[ face.c ].clone();\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( this.faces.length > 0 ) {\n\n\t\t\tthis.normalsNeedUpdate = true;\n\n\t\t}\n\n\t},\n\n\tcomputeFlatVertexNormals: function () {\n\n\t\tthis.computeFaceNormals();\n\n\t\tfor ( let f = 0, fl = this.faces.length; f < fl; f ++ ) {\n\n\t\t\tconst face = this.faces[ f ];\n\n\t\t\tconst vertexNormals = face.vertexNormals;\n\n\t\t\tif ( vertexNormals.length === 3 ) {\n\n\t\t\t\tvertexNormals[ 0 ].copy( face.normal );\n\t\t\t\tvertexNormals[ 1 ].copy( face.normal );\n\t\t\t\tvertexNormals[ 2 ].copy( face.normal );\n\n\t\t\t} else {\n\n\t\t\t\tvertexNormals[ 0 ] = face.normal.clone();\n\t\t\t\tvertexNormals[ 1 ] = face.normal.clone();\n\t\t\t\tvertexNormals[ 2 ] = face.normal.clone();\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( this.faces.length > 0 ) {\n\n\t\t\tthis.normalsNeedUpdate = true;\n\n\t\t}\n\n\t},\n\n\tcomputeMorphNormals: function () {\n\n\t\t// save original normals\n\t\t// - create temp variables on first access\n\t\t// otherwise just copy (for faster repeated calls)\n\n\t\tfor ( let f = 0, fl = this.faces.length; f < fl; f ++ ) {\n\n\t\t\tconst face = this.faces[ f ];\n\n\t\t\tif ( ! face.__originalFaceNormal ) {\n\n\t\t\t\tface.__originalFaceNormal = face.normal.clone();\n\n\t\t\t} else {\n\n\t\t\t\tface.__originalFaceNormal.copy( face.normal );\n\n\t\t\t}\n\n\t\t\tif ( ! face.__originalVertexNormals ) face.__originalVertexNormals = [];\n\n\t\t\tfor ( let i = 0, il = face.vertexNormals.length; i < il; i ++ ) {\n\n\t\t\t\tif ( ! face.__originalVertexNormals[ i ] ) {\n\n\t\t\t\t\tface.__originalVertexNormals[ i ] = face.vertexNormals[ i ].clone();\n\n\t\t\t\t} else {\n\n\t\t\t\t\tface.__originalVertexNormals[ i ].copy( face.vertexNormals[ i ] );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\t// use temp geometry to compute face and vertex normals for each morph\n\n\t\tconst tmpGeo = new Geometry();\n\t\ttmpGeo.faces = this.faces;\n\n\t\tfor ( let i = 0, il = this.morphTargets.length; i < il; i ++ ) {\n\n\t\t\t// create on first access\n\n\t\t\tif ( ! this.morphNormals[ i ] ) {\n\n\t\t\t\tthis.morphNormals[ i ] = {};\n\t\t\t\tthis.morphNormals[ i ].faceNormals = [];\n\t\t\t\tthis.morphNormals[ i ].vertexNormals = [];\n\n\t\t\t\tconst dstNormalsFace = this.morphNormals[ i ].faceNormals;\n\t\t\t\tconst dstNormalsVertex = this.morphNormals[ i ].vertexNormals;\n\n\t\t\t\tfor ( let f = 0, fl = this.faces.length; f < fl; f ++ ) {\n\n\t\t\t\t\tconst faceNormal = new Vector3();\n\t\t\t\t\tconst vertexNormals = { a: new Vector3(), b: new Vector3(), c: new Vector3() };\n\n\t\t\t\t\tdstNormalsFace.push( faceNormal );\n\t\t\t\t\tdstNormalsVertex.push( vertexNormals );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tconst morphNormals = this.morphNormals[ i ];\n\n\t\t\t// set vertices to morph target\n\n\t\t\ttmpGeo.vertices = this.morphTargets[ i ].vertices;\n\n\t\t\t// compute morph normals\n\n\t\t\ttmpGeo.computeFaceNormals();\n\t\t\ttmpGeo.computeVertexNormals();\n\n\t\t\t// store morph normals\n\n\t\t\tfor ( let f = 0, fl = this.faces.length; f < fl; f ++ ) {\n\n\t\t\t\tconst face = this.faces[ f ];\n\n\t\t\t\tconst faceNormal = morphNormals.faceNormals[ f ];\n\t\t\t\tconst vertexNormals = morphNormals.vertexNormals[ f ];\n\n\t\t\t\tfaceNormal.copy( face.normal );\n\n\t\t\t\tvertexNormals.a.copy( face.vertexNormals[ 0 ] );\n\t\t\t\tvertexNormals.b.copy( face.vertexNormals[ 1 ] );\n\t\t\t\tvertexNormals.c.copy( face.vertexNormals[ 2 ] );\n\n\t\t\t}\n\n\t\t}\n\n\t\t// restore original normals\n\n\t\tfor ( let f = 0, fl = this.faces.length; f < fl; f ++ ) {\n\n\t\t\tconst face = this.faces[ f ];\n\n\t\t\tface.normal = face.__originalFaceNormal;\n\t\t\tface.vertexNormals = face.__originalVertexNormals;\n\n\t\t}\n\n\t},\n\n\tcomputeBoundingBox: function () {\n\n\t\tif ( this.boundingBox === null ) {\n\n\t\t\tthis.boundingBox = new Box3();\n\n\t\t}\n\n\t\tthis.boundingBox.setFromPoints( this.vertices );\n\n\t},\n\n\tcomputeBoundingSphere: function () {\n\n\t\tif ( this.boundingSphere === null ) {\n\n\t\t\tthis.boundingSphere = new Sphere();\n\n\t\t}\n\n\t\tthis.boundingSphere.setFromPoints( this.vertices );\n\n\t},\n\n\tmerge: function ( geometry, matrix, materialIndexOffset ) {\n\n\t\tif ( ! ( geometry && geometry.isGeometry ) ) {\n\n\t\t\tconsole.error( 'THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.', geometry );\n\t\t\treturn;\n\n\t\t}\n\n\t\tlet normalMatrix,\n\t\t\tvertexOffset = this.vertices.length,\n\t\t\tvertices1 = this.vertices,\n\t\t\tvertices2 = geometry.vertices,\n\t\t\tfaces1 = this.faces,\n\t\t\tfaces2 = geometry.faces,\n\t\t\tcolors1 = this.colors,\n\t\t\tcolors2 = geometry.colors;\n\n\t\tif ( materialIndexOffset === undefined ) materialIndexOffset = 0;\n\n\t\tif ( matrix !== undefined ) {\n\n\t\t\tnormalMatrix = new Matrix3().getNormalMatrix( matrix );\n\n\t\t}\n\n\t\t// vertices\n\n\t\tfor ( let i = 0, il = vertices2.length; i < il; i ++ ) {\n\n\t\t\tconst vertex = vertices2[ i ];\n\n\t\t\tconst vertexCopy = vertex.clone();\n\n\t\t\tif ( matrix !== undefined ) vertexCopy.applyMatrix4( matrix );\n\n\t\t\tvertices1.push( vertexCopy );\n\n\t\t}\n\n\t\t// colors\n\n\t\tfor ( let i = 0, il = colors2.length; i < il; i ++ ) {\n\n\t\t\tcolors1.push( colors2[ i ].clone() );\n\n\t\t}\n\n\t\t// faces\n\n\t\tfor ( let i = 0, il = faces2.length; i < il; i ++ ) {\n\n\t\t\tlet face = faces2[ i ], faceCopy, normal, color,\n\t\t\t\tfaceVertexNormals = face.vertexNormals,\n\t\t\t\tfaceVertexColors = face.vertexColors;\n\n\t\t\tfaceCopy = new Face3( face.a + vertexOffset, face.b + vertexOffset, face.c + vertexOffset );\n\t\t\tfaceCopy.normal.copy( face.normal );\n\n\t\t\tif ( normalMatrix !== undefined ) {\n\n\t\t\t\tfaceCopy.normal.applyMatrix3( normalMatrix ).normalize();\n\n\t\t\t}\n\n\t\t\tfor ( let j = 0, jl = faceVertexNormals.length; j < jl; j ++ ) {\n\n\t\t\t\tnormal = faceVertexNormals[ j ].clone();\n\n\t\t\t\tif ( normalMatrix !== undefined ) {\n\n\t\t\t\t\tnormal.applyMatrix3( normalMatrix ).normalize();\n\n\t\t\t\t}\n\n\t\t\t\tfaceCopy.vertexNormals.push( normal );\n\n\t\t\t}\n\n\t\t\tfaceCopy.color.copy( face.color );\n\n\t\t\tfor ( let j = 0, jl = faceVertexColors.length; j < jl; j ++ ) {\n\n\t\t\t\tcolor = faceVertexColors[ j ];\n\t\t\t\tfaceCopy.vertexColors.push( color.clone() );\n\n\t\t\t}\n\n\t\t\tfaceCopy.materialIndex = face.materialIndex + materialIndexOffset;\n\n\t\t\tfaces1.push( faceCopy );\n\n\t\t}\n\n\t\t// uvs\n\n\t\tfor ( let i = 0, il = geometry.faceVertexUvs.length; i < il; i ++ ) {\n\n\t\t\tconst faceVertexUvs2 = geometry.faceVertexUvs[ i ];\n\n\t\t\tif ( this.faceVertexUvs[ i ] === undefined ) this.faceVertexUvs[ i ] = [];\n\n\t\t\tfor ( let j = 0, jl = faceVertexUvs2.length; j < jl; j ++ ) {\n\n\t\t\t\tconst uvs2 = faceVertexUvs2[ j ], uvsCopy = [];\n\n\t\t\t\tfor ( let k = 0, kl = uvs2.length; k < kl; k ++ ) {\n\n\t\t\t\t\tuvsCopy.push( uvs2[ k ].clone() );\n\n\t\t\t\t}\n\n\t\t\t\tthis.faceVertexUvs[ i ].push( uvsCopy );\n\n\t\t\t}\n\n\t\t}\n\n\t},\n\n\tmergeMesh: function ( mesh ) {\n\n\t\tif ( ! ( mesh && mesh.isMesh ) ) {\n\n\t\t\tconsole.error( 'THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.', mesh );\n\t\t\treturn;\n\n\t\t}\n\n\t\tif ( mesh.matrixAutoUpdate ) mesh.updateMatrix();\n\n\t\tthis.merge( mesh.geometry, mesh.matrix );\n\n\t},\n\n\t/*\n\t * Checks for duplicate vertices with hashmap.\n\t * Duplicated vertices are removed\n\t * and faces' vertices are updated.\n\t */\n\n\tmergeVertices: function () {\n\n\t\tconst verticesMap = {}; // Hashmap for looking up vertices by position coordinates (and making sure they are unique)\n\t\tconst unique = [], changes = [];\n\n\t\tconst precisionPoints = 4; // number of decimal points, e.g. 4 for epsilon of 0.0001\n\t\tconst precision = Math.pow( 10, precisionPoints );\n\n\t\tfor ( let i = 0, il = this.vertices.length; i < il; i ++ ) {\n\n\t\t\tconst v = this.vertices[ i ];\n\t\t\tconst key = Math.round( v.x * precision ) + '_' + Math.round( v.y * precision ) + '_' + Math.round( v.z * precision );\n\n\t\t\tif ( verticesMap[ key ] === undefined ) {\n\n\t\t\t\tverticesMap[ key ] = i;\n\t\t\t\tunique.push( this.vertices[ i ] );\n\t\t\t\tchanges[ i ] = unique.length - 1;\n\n\t\t\t} else {\n\n\t\t\t\t//console.log('Duplicate vertex found. ', i, ' could be using ', verticesMap[key]);\n\t\t\t\tchanges[ i ] = changes[ verticesMap[ key ] ];\n\n\t\t\t}\n\n\t\t}\n\n\n\t\t// if faces are completely degenerate after merging vertices, we\n\t\t// have to remove them from the geometry.\n\t\tconst faceIndicesToRemove = [];\n\n\t\tfor ( let i = 0, il = this.faces.length; i < il; i ++ ) {\n\n\t\t\tconst face = this.faces[ i ];\n\n\t\t\tface.a = changes[ face.a ];\n\t\t\tface.b = changes[ face.b ];\n\t\t\tface.c = changes[ face.c ];\n\n\t\t\tconst indices = [ face.a, face.b, face.c ];\n\n\t\t\t// if any duplicate vertices are found in a Face3\n\t\t\t// we have to remove the face as nothing can be saved\n\t\t\tfor ( let n = 0; n < 3; n ++ ) {\n\n\t\t\t\tif ( indices[ n ] === indices[ ( n + 1 ) % 3 ] ) {\n\n\t\t\t\t\tfaceIndicesToRemove.push( i );\n\t\t\t\t\tbreak;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tfor ( let i = faceIndicesToRemove.length - 1; i >= 0; i -- ) {\n\n\t\t\tconst idx = faceIndicesToRemove[ i ];\n\n\t\t\tthis.faces.splice( idx, 1 );\n\n\t\t\tfor ( let j = 0, jl = this.faceVertexUvs.length; j < jl; j ++ ) {\n\n\t\t\t\tthis.faceVertexUvs[ j ].splice( idx, 1 );\n\n\t\t\t}\n\n\t\t}\n\n\t\t// Use unique set of vertices\n\n\t\tconst diff = this.vertices.length - unique.length;\n\t\tthis.vertices = unique;\n\t\treturn diff;\n\n\t},\n\n\tsetFromPoints: function ( points ) {\n\n\t\tthis.vertices = [];\n\n\t\tfor ( let i = 0, l = points.length; i < l; i ++ ) {\n\n\t\t\tconst point = points[ i ];\n\t\t\tthis.vertices.push( new Vector3( point.x, point.y, point.z || 0 ) );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tsortFacesByMaterialIndex: function () {\n\n\t\tconst faces = this.faces;\n\t\tconst length = faces.length;\n\n\t\t// tag faces\n\n\t\tfor ( let i = 0; i < length; i ++ ) {\n\n\t\t\tfaces[ i ]._id = i;\n\n\t\t}\n\n\t\t// sort faces\n\n\t\tfunction materialIndexSort( a, b ) {\n\n\t\t\treturn a.materialIndex - b.materialIndex;\n\n\t\t}\n\n\t\tfaces.sort( materialIndexSort );\n\n\t\t// sort uvs\n\n\t\tconst uvs1 = this.faceVertexUvs[ 0 ];\n\t\tconst uvs2 = this.faceVertexUvs[ 1 ];\n\n\t\tlet newUvs1, newUvs2;\n\n\t\tif ( uvs1 && uvs1.length === length ) newUvs1 = [];\n\t\tif ( uvs2 && uvs2.length === length ) newUvs2 = [];\n\n\t\tfor ( let i = 0; i < length; i ++ ) {\n\n\t\t\tconst id = faces[ i ]._id;\n\n\t\t\tif ( newUvs1 ) newUvs1.push( uvs1[ id ] );\n\t\t\tif ( newUvs2 ) newUvs2.push( uvs2[ id ] );\n\n\t\t}\n\n\t\tif ( newUvs1 ) this.faceVertexUvs[ 0 ] = newUvs1;\n\t\tif ( newUvs2 ) this.faceVertexUvs[ 1 ] = newUvs2;\n\n\t},\n\n\ttoJSON: function () {\n\n\t\tconst data = {\n\t\t\tmetadata: {\n\t\t\t\tversion: 4.5,\n\t\t\t\ttype: 'Geometry',\n\t\t\t\tgenerator: 'Geometry.toJSON'\n\t\t\t}\n\t\t};\n\n\t\t// standard Geometry serialization\n\n\t\tdata.uuid = this.uuid;\n\t\tdata.type = this.type;\n\t\tif ( this.name !== '' ) data.name = this.name;\n\n\t\tif ( this.parameters !== undefined ) {\n\n\t\t\tconst parameters = this.parameters;\n\n\t\t\tfor ( const key in parameters ) {\n\n\t\t\t\tif ( parameters[ key ] !== undefined ) data[ key ] = parameters[ key ];\n\n\t\t\t}\n\n\t\t\treturn data;\n\n\t\t}\n\n\t\tconst vertices = [];\n\n\t\tfor ( let i = 0; i < this.vertices.length; i ++ ) {\n\n\t\t\tconst vertex = this.vertices[ i ];\n\t\t\tvertices.push( vertex.x, vertex.y, vertex.z );\n\n\t\t}\n\n\t\tconst faces = [];\n\t\tconst normals = [];\n\t\tconst normalsHash = {};\n\t\tconst colors = [];\n\t\tconst colorsHash = {};\n\t\tconst uvs = [];\n\t\tconst uvsHash = {};\n\n\t\tfor ( let i = 0; i < this.faces.length; i ++ ) {\n\n\t\t\tconst face = this.faces[ i ];\n\n\t\t\tconst hasMaterial = true;\n\t\t\tconst hasFaceUv = false; // deprecated\n\t\t\tconst hasFaceVertexUv = this.faceVertexUvs[ 0 ][ i ] !== undefined;\n\t\t\tconst hasFaceNormal = face.normal.length() > 0;\n\t\t\tconst hasFaceVertexNormal = face.vertexNormals.length > 0;\n\t\t\tconst hasFaceColor = face.color.r !== 1 || face.color.g !== 1 || face.color.b !== 1;\n\t\t\tconst hasFaceVertexColor = face.vertexColors.length > 0;\n\n\t\t\tlet faceType = 0;\n\n\t\t\tfaceType = setBit( faceType, 0, 0 ); // isQuad\n\t\t\tfaceType = setBit( faceType, 1, hasMaterial );\n\t\t\tfaceType = setBit( faceType, 2, hasFaceUv );\n\t\t\tfaceType = setBit( faceType, 3, hasFaceVertexUv );\n\t\t\tfaceType = setBit( faceType, 4, hasFaceNormal );\n\t\t\tfaceType = setBit( faceType, 5, hasFaceVertexNormal );\n\t\t\tfaceType = setBit( faceType, 6, hasFaceColor );\n\t\t\tfaceType = setBit( faceType, 7, hasFaceVertexColor );\n\n\t\t\tfaces.push( faceType );\n\t\t\tfaces.push( face.a, face.b, face.c );\n\t\t\tfaces.push( face.materialIndex );\n\n\t\t\tif ( hasFaceVertexUv ) {\n\n\t\t\t\tconst faceVertexUvs = this.faceVertexUvs[ 0 ][ i ];\n\n\t\t\t\tfaces.push(\n\t\t\t\t\tgetUvIndex( faceVertexUvs[ 0 ] ),\n\t\t\t\t\tgetUvIndex( faceVertexUvs[ 1 ] ),\n\t\t\t\t\tgetUvIndex( faceVertexUvs[ 2 ] )\n\t\t\t\t);\n\n\t\t\t}\n\n\t\t\tif ( hasFaceNormal ) {\n\n\t\t\t\tfaces.push( getNormalIndex( face.normal ) );\n\n\t\t\t}\n\n\t\t\tif ( hasFaceVertexNormal ) {\n\n\t\t\t\tconst vertexNormals = face.vertexNormals;\n\n\t\t\t\tfaces.push(\n\t\t\t\t\tgetNormalIndex( vertexNormals[ 0 ] ),\n\t\t\t\t\tgetNormalIndex( vertexNormals[ 1 ] ),\n\t\t\t\t\tgetNormalIndex( vertexNormals[ 2 ] )\n\t\t\t\t);\n\n\t\t\t}\n\n\t\t\tif ( hasFaceColor ) {\n\n\t\t\t\tfaces.push( getColorIndex( face.color ) );\n\n\t\t\t}\n\n\t\t\tif ( hasFaceVertexColor ) {\n\n\t\t\t\tconst vertexColors = face.vertexColors;\n\n\t\t\t\tfaces.push(\n\t\t\t\t\tgetColorIndex( vertexColors[ 0 ] ),\n\t\t\t\t\tgetColorIndex( vertexColors[ 1 ] ),\n\t\t\t\t\tgetColorIndex( vertexColors[ 2 ] )\n\t\t\t\t);\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction setBit( value, position, enabled ) {\n\n\t\t\treturn enabled ? value | ( 1 << position ) : value & ( ~ ( 1 << position ) );\n\n\t\t}\n\n\t\tfunction getNormalIndex( normal ) {\n\n\t\t\tconst hash = normal.x.toString() + normal.y.toString() + normal.z.toString();\n\n\t\t\tif ( normalsHash[ hash ] !== undefined ) {\n\n\t\t\t\treturn normalsHash[ hash ];\n\n\t\t\t}\n\n\t\t\tnormalsHash[ hash ] = normals.length / 3;\n\t\t\tnormals.push( normal.x, normal.y, normal.z );\n\n\t\t\treturn normalsHash[ hash ];\n\n\t\t}\n\n\t\tfunction getColorIndex( color ) {\n\n\t\t\tconst hash = color.r.toString() + color.g.toString() + color.b.toString();\n\n\t\t\tif ( colorsHash[ hash ] !== undefined ) {\n\n\t\t\t\treturn colorsHash[ hash ];\n\n\t\t\t}\n\n\t\t\tcolorsHash[ hash ] = colors.length;\n\t\t\tcolors.push( color.getHex() );\n\n\t\t\treturn colorsHash[ hash ];\n\n\t\t}\n\n\t\tfunction getUvIndex( uv ) {\n\n\t\t\tconst hash = uv.x.toString() + uv.y.toString();\n\n\t\t\tif ( uvsHash[ hash ] !== undefined ) {\n\n\t\t\t\treturn uvsHash[ hash ];\n\n\t\t\t}\n\n\t\t\tuvsHash[ hash ] = uvs.length / 2;\n\t\t\tuvs.push( uv.x, uv.y );\n\n\t\t\treturn uvsHash[ hash ];\n\n\t\t}\n\n\t\tdata.data = {};\n\n\t\tdata.data.vertices = vertices;\n\t\tdata.data.normals = normals;\n\t\tif ( colors.length > 0 ) data.data.colors = colors;\n\t\tif ( uvs.length > 0 ) data.data.uvs = [ uvs ]; // temporal backward compatibility\n\t\tdata.data.faces = faces;\n\n\t\treturn data;\n\n\t},\n\n\tclone: function () {\n\n\t\t/*\n\t\t // Handle primitives\n\n\t\t const parameters = this.parameters;\n\n\t\t if ( parameters !== undefined ) {\n\n\t\t const values = [];\n\n\t\t for ( const key in parameters ) {\n\n\t\t values.push( parameters[ key ] );\n\n\t\t }\n\n\t\t const geometry = Object.create( this.constructor.prototype );\n\t\t this.constructor.apply( geometry, values );\n\t\t return geometry;\n\n\t\t }\n\n\t\t return new this.constructor().copy( this );\n\t\t */\n\n\t\treturn new Geometry().copy( this );\n\n\t},\n\n\tcopy: function ( source ) {\n\n\t\t// reset\n\n\t\tthis.vertices = [];\n\t\tthis.colors = [];\n\t\tthis.faces = [];\n\t\tthis.faceVertexUvs = [[]];\n\t\tthis.morphTargets = [];\n\t\tthis.morphNormals = [];\n\t\tthis.skinWeights = [];\n\t\tthis.skinIndices = [];\n\t\tthis.lineDistances = [];\n\t\tthis.boundingBox = null;\n\t\tthis.boundingSphere = null;\n\n\t\t// name\n\n\t\tthis.name = source.name;\n\n\t\t// vertices\n\n\t\tconst vertices = source.vertices;\n\n\t\tfor ( let i = 0, il = vertices.length; i < il; i ++ ) {\n\n\t\t\tthis.vertices.push( vertices[ i ].clone() );\n\n\t\t}\n\n\t\t// colors\n\n\t\tconst colors = source.colors;\n\n\t\tfor ( let i = 0, il = colors.length; i < il; i ++ ) {\n\n\t\t\tthis.colors.push( colors[ i ].clone() );\n\n\t\t}\n\n\t\t// faces\n\n\t\tconst faces = source.faces;\n\n\t\tfor ( let i = 0, il = faces.length; i < il; i ++ ) {\n\n\t\t\tthis.faces.push( faces[ i ].clone() );\n\n\t\t}\n\n\t\t// face vertex uvs\n\n\t\tfor ( let i = 0, il = source.faceVertexUvs.length; i < il; i ++ ) {\n\n\t\t\tconst faceVertexUvs = source.faceVertexUvs[ i ];\n\n\t\t\tif ( this.faceVertexUvs[ i ] === undefined ) {\n\n\t\t\t\tthis.faceVertexUvs[ i ] = [];\n\n\t\t\t}\n\n\t\t\tfor ( let j = 0, jl = faceVertexUvs.length; j < jl; j ++ ) {\n\n\t\t\t\tconst uvs = faceVertexUvs[ j ], uvsCopy = [];\n\n\t\t\t\tfor ( let k = 0, kl = uvs.length; k < kl; k ++ ) {\n\n\t\t\t\t\tconst uv = uvs[ k ];\n\n\t\t\t\t\tuvsCopy.push( uv.clone() );\n\n\t\t\t\t}\n\n\t\t\t\tthis.faceVertexUvs[ i ].push( uvsCopy );\n\n\t\t\t}\n\n\t\t}\n\n\t\t// morph targets\n\n\t\tconst morphTargets = source.morphTargets;\n\n\t\tfor ( let i = 0, il = morphTargets.length; i < il; i ++ ) {\n\n\t\t\tconst morphTarget = {};\n\t\t\tmorphTarget.name = morphTargets[ i ].name;\n\n\t\t\t// vertices\n\n\t\t\tif ( morphTargets[ i ].vertices !== undefined ) {\n\n\t\t\t\tmorphTarget.vertices = [];\n\n\t\t\t\tfor ( let j = 0, jl = morphTargets[ i ].vertices.length; j < jl; j ++ ) {\n\n\t\t\t\t\tmorphTarget.vertices.push( morphTargets[ i ].vertices[ j ].clone() );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// normals\n\n\t\t\tif ( morphTargets[ i ].normals !== undefined ) {\n\n\t\t\t\tmorphTarget.normals = [];\n\n\t\t\t\tfor ( let j = 0, jl = morphTargets[ i ].normals.length; j < jl; j ++ ) {\n\n\t\t\t\t\tmorphTarget.normals.push( morphTargets[ i ].normals[ j ].clone() );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tthis.morphTargets.push( morphTarget );\n\n\t\t}\n\n\t\t// morph normals\n\n\t\tconst morphNormals = source.morphNormals;\n\n\t\tfor ( let i = 0, il = morphNormals.length; i < il; i ++ ) {\n\n\t\t\tconst morphNormal = {};\n\n\t\t\t// vertex normals\n\n\t\t\tif ( morphNormals[ i ].vertexNormals !== undefined ) {\n\n\t\t\t\tmorphNormal.vertexNormals = [];\n\n\t\t\t\tfor ( let j = 0, jl = morphNormals[ i ].vertexNormals.length; j < jl; j ++ ) {\n\n\t\t\t\t\tconst srcVertexNormal = morphNormals[ i ].vertexNormals[ j ];\n\t\t\t\t\tconst destVertexNormal = {};\n\n\t\t\t\t\tdestVertexNormal.a = srcVertexNormal.a.clone();\n\t\t\t\t\tdestVertexNormal.b = srcVertexNormal.b.clone();\n\t\t\t\t\tdestVertexNormal.c = srcVertexNormal.c.clone();\n\n\t\t\t\t\tmorphNormal.vertexNormals.push( destVertexNormal );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// face normals\n\n\t\t\tif ( morphNormals[ i ].faceNormals !== undefined ) {\n\n\t\t\t\tmorphNormal.faceNormals = [];\n\n\t\t\t\tfor ( let j = 0, jl = morphNormals[ i ].faceNormals.length; j < jl; j ++ ) {\n\n\t\t\t\t\tmorphNormal.faceNormals.push( morphNormals[ i ].faceNormals[ j ].clone() );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tthis.morphNormals.push( morphNormal );\n\n\t\t}\n\n\t\t// skin weights\n\n\t\tconst skinWeights = source.skinWeights;\n\n\t\tfor ( let i = 0, il = skinWeights.length; i < il; i ++ ) {\n\n\t\t\tthis.skinWeights.push( skinWeights[ i ].clone() );\n\n\t\t}\n\n\t\t// skin indices\n\n\t\tconst skinIndices = source.skinIndices;\n\n\t\tfor ( let i = 0, il = skinIndices.length; i < il; i ++ ) {\n\n\t\t\tthis.skinIndices.push( skinIndices[ i ].clone() );\n\n\t\t}\n\n\t\t// line distances\n\n\t\tconst lineDistances = source.lineDistances;\n\n\t\tfor ( let i = 0, il = lineDistances.length; i < il; i ++ ) {\n\n\t\t\tthis.lineDistances.push( lineDistances[ i ] );\n\n\t\t}\n\n\t\t// bounding box\n\n\t\tconst boundingBox = source.boundingBox;\n\n\t\tif ( boundingBox !== null ) {\n\n\t\t\tthis.boundingBox = boundingBox.clone();\n\n\t\t}\n\n\t\t// bounding sphere\n\n\t\tconst boundingSphere = source.boundingSphere;\n\n\t\tif ( boundingSphere !== null ) {\n\n\t\t\tthis.boundingSphere = boundingSphere.clone();\n\n\t\t}\n\n\t\t// update flags\n\n\t\tthis.elementsNeedUpdate = source.elementsNeedUpdate;\n\t\tthis.verticesNeedUpdate = source.verticesNeedUpdate;\n\t\tthis.uvsNeedUpdate = source.uvsNeedUpdate;\n\t\tthis.normalsNeedUpdate = source.normalsNeedUpdate;\n\t\tthis.colorsNeedUpdate = source.colorsNeedUpdate;\n\t\tthis.lineDistancesNeedUpdate = source.lineDistancesNeedUpdate;\n\t\tthis.groupsNeedUpdate = source.groupsNeedUpdate;\n\n\t\treturn this;\n\n\t},\n\n\tdispose: function () {\n\n\t\tthis.dispatchEvent( { type: 'dispose' } );\n\n\t}\n\n} );\n\n\nexport { Geometry };\n","/**\n * @author mrdoob / http://mrdoob.com/\n * @author Mugen87 / https://github.com/Mugen87\n */\n\nimport { Geometry } from '../core/Geometry.js';\nimport { BufferGeometry } from '../core/BufferGeometry.js';\nimport { Float32BufferAttribute } from '../core/BufferAttribute.js';\nimport { Vector3 } from '../math/Vector3.js';\n\n// BoxGeometry\n\nclass BoxGeometry extends Geometry {\n\n\tconstructor( width, height, depth, widthSegments, heightSegments, depthSegments ) {\n\n\t\tsuper();\n\n\t\tthis.type = 'BoxGeometry';\n\n\t\tthis.parameters = {\n\t\t\twidth: width,\n\t\t\theight: height,\n\t\t\tdepth: depth,\n\t\t\twidthSegments: widthSegments,\n\t\t\theightSegments: heightSegments,\n\t\t\tdepthSegments: depthSegments\n\t\t};\n\n\t\tthis.fromBufferGeometry( new BoxBufferGeometry( width, height, depth, widthSegments, heightSegments, depthSegments ) );\n\t\tthis.mergeVertices();\n\n\t}\n\n}\n\n// BoxBufferGeometry\n\nclass BoxBufferGeometry extends BufferGeometry {\n\n\tconstructor( width, height, depth, widthSegments, heightSegments, depthSegments ) {\n\n\t\tsuper();\n\n\t\tthis.type = 'BoxBufferGeometry';\n\n\t\tthis.parameters = {\n\t\t\twidth: width,\n\t\t\theight: height,\n\t\t\tdepth: depth,\n\t\t\twidthSegments: widthSegments,\n\t\t\theightSegments: heightSegments,\n\t\t\tdepthSegments: depthSegments\n\t\t};\n\n\t\tconst scope = this;\n\n\t\twidth = width || 1;\n\t\theight = height || 1;\n\t\tdepth = depth || 1;\n\n\t\t// segments\n\n\t\twidthSegments = Math.floor( widthSegments ) || 1;\n\t\theightSegments = Math.floor( heightSegments ) || 1;\n\t\tdepthSegments = Math.floor( depthSegments ) || 1;\n\n\t\t// buffers\n\n\t\tconst indices = [];\n\t\tconst vertices = [];\n\t\tconst normals = [];\n\t\tconst uvs = [];\n\n\t\t// helper variables\n\n\t\tlet numberOfVertices = 0;\n\t\tlet groupStart = 0;\n\n\t\t// build each side of the box geometry\n\n\t\tbuildPlane( 'z', 'y', 'x', - 1, - 1, depth, height, width, depthSegments, heightSegments, 0 ); // px\n\t\tbuildPlane( 'z', 'y', 'x', 1, - 1, depth, height, - width, depthSegments, heightSegments, 1 ); // nx\n\t\tbuildPlane( 'x', 'z', 'y', 1, 1, width, depth, height, widthSegments, depthSegments, 2 ); // py\n\t\tbuildPlane( 'x', 'z', 'y', 1, - 1, width, depth, - height, widthSegments, depthSegments, 3 ); // ny\n\t\tbuildPlane( 'x', 'y', 'z', 1, - 1, width, height, depth, widthSegments, heightSegments, 4 ); // pz\n\t\tbuildPlane( 'x', 'y', 'z', - 1, - 1, width, height, - depth, widthSegments, heightSegments, 5 ); // nz\n\n\t\t// build geometry\n\n\t\tthis.setIndex( indices );\n\t\tthis.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );\n\t\tthis.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );\n\t\tthis.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );\n\n\t\tfunction buildPlane( u, v, w, udir, vdir, width, height, depth, gridX, gridY, materialIndex ) {\n\n\t\t\tconst segmentWidth = width / gridX;\n\t\t\tconst segmentHeight = height / gridY;\n\n\t\t\tconst widthHalf = width / 2;\n\t\t\tconst heightHalf = height / 2;\n\t\t\tconst depthHalf = depth / 2;\n\n\t\t\tconst gridX1 = gridX + 1;\n\t\t\tconst gridY1 = gridY + 1;\n\n\t\t\tlet vertexCounter = 0;\n\t\t\tlet groupCount = 0;\n\n\t\t\tconst vector = new Vector3();\n\n\t\t\t// generate vertices, normals and uvs\n\n\t\t\tfor ( let iy = 0; iy < gridY1; iy ++ ) {\n\n\t\t\t\tconst y = iy * segmentHeight - heightHalf;\n\n\t\t\t\tfor ( let ix = 0; ix < gridX1; ix ++ ) {\n\n\t\t\t\t\tconst x = ix * segmentWidth - widthHalf;\n\n\t\t\t\t\t// set values to correct vector component\n\n\t\t\t\t\tvector[ u ] = x * udir;\n\t\t\t\t\tvector[ v ] = y * vdir;\n\t\t\t\t\tvector[ w ] = depthHalf;\n\n\t\t\t\t\t// now apply vector to vertex buffer\n\n\t\t\t\t\tvertices.push( vector.x, vector.y, vector.z );\n\n\t\t\t\t\t// set values to correct vector component\n\n\t\t\t\t\tvector[ u ] = 0;\n\t\t\t\t\tvector[ v ] = 0;\n\t\t\t\t\tvector[ w ] = depth > 0 ? 1 : - 1;\n\n\t\t\t\t\t// now apply vector to normal buffer\n\n\t\t\t\t\tnormals.push( vector.x, vector.y, vector.z );\n\n\t\t\t\t\t// uvs\n\n\t\t\t\t\tuvs.push( ix / gridX );\n\t\t\t\t\tuvs.push( 1 - ( iy / gridY ) );\n\n\t\t\t\t\t// counters\n\n\t\t\t\t\tvertexCounter += 1;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// indices\n\n\t\t\t// 1. you need three indices to draw a single face\n\t\t\t// 2. a single segment consists of two faces\n\t\t\t// 3. so we need to generate six (2*3) indices per segment\n\n\t\t\tfor ( let iy = 0; iy < gridY; iy ++ ) {\n\n\t\t\t\tfor ( let ix = 0; ix < gridX; ix ++ ) {\n\n\t\t\t\t\tconst a = numberOfVertices + ix + gridX1 * iy;\n\t\t\t\t\tconst b = numberOfVertices + ix + gridX1 * ( iy + 1 );\n\t\t\t\t\tconst c = numberOfVertices + ( ix + 1 ) + gridX1 * ( iy + 1 );\n\t\t\t\t\tconst d = numberOfVertices + ( ix + 1 ) + gridX1 * iy;\n\n\t\t\t\t\t// faces\n\n\t\t\t\t\tindices.push( a, b, d );\n\t\t\t\t\tindices.push( b, c, d );\n\n\t\t\t\t\t// increase counter\n\n\t\t\t\t\tgroupCount += 6;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// add a group to the geometry. this will ensure multi material support\n\n\t\t\tscope.addGroup( groupStart, groupCount, materialIndex );\n\n\t\t\t// calculate new start value for groups\n\n\t\t\tgroupStart += groupCount;\n\n\t\t\t// update total number of vertices\n\n\t\t\tnumberOfVertices += vertexCounter;\n\n\t\t}\n\n\t}\n\n}\n\nexport { BoxGeometry, BoxBufferGeometry };\n","/**\n * Uniform Utilities\n */\n\nexport function cloneUniforms( src ) {\n\n\tconst dst = {};\n\n\tfor ( const u in src ) {\n\n\t\tdst[ u ] = {};\n\n\t\tfor ( const p in src[ u ] ) {\n\n\t\t\tconst property = src[ u ][ p ];\n\n\t\t\tif ( property && ( property.isColor ||\n\t\t\t\tproperty.isMatrix3 || property.isMatrix4 ||\n\t\t\t\tproperty.isVector2 || property.isVector3 || property.isVector4 ||\n\t\t\t\tproperty.isTexture ) ) {\n\n\t\t\t\tdst[ u ][ p ] = property.clone();\n\n\t\t\t} else if ( Array.isArray( property ) ) {\n\n\t\t\t\tdst[ u ][ p ] = property.slice();\n\n\t\t\t} else {\n\n\t\t\t\tdst[ u ][ p ] = property;\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\treturn dst;\n\n}\n\nexport function mergeUniforms( uniforms ) {\n\n\tconst merged = {};\n\n\tfor ( let u = 0; u < uniforms.length; u ++ ) {\n\n\t\tconst tmp = cloneUniforms( uniforms[ u ] );\n\n\t\tfor ( const p in tmp ) {\n\n\t\t\tmerged[ p ] = tmp[ p ];\n\n\t\t}\n\n\t}\n\n\treturn merged;\n\n}\n\n// Legacy\n\nconst UniformsUtils = { clone: cloneUniforms, merge: mergeUniforms };\n\nexport { UniformsUtils };\n","export default /* glsl */`\nvoid main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}\n`;\n","export default /* glsl */`\nvoid main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}\n`;\n","/**\n * @author alteredq / http://alteredqualia.com/\n *\n * parameters = {\n * defines: { \"label\" : \"value\" },\n * uniforms: { \"parameter1\": { value: 1.0 }, \"parameter2\": { value2: 2 } },\n *\n * fragmentShader: ,\n * vertexShader: ,\n *\n * wireframe: ,\n * wireframeLinewidth: ,\n *\n * lights: ,\n *\n * skinning: ,\n * morphTargets: ,\n * morphNormals: \n * }\n */\n\nimport { Material } from './Material.js';\nimport { cloneUniforms } from '../renderers/shaders/UniformsUtils.js';\n\nimport default_vertex from '../renderers/shaders/ShaderChunk/default_vertex.glsl.js';\nimport default_fragment from '../renderers/shaders/ShaderChunk/default_fragment.glsl.js';\n\nfunction ShaderMaterial( parameters ) {\n\n\tMaterial.call( this );\n\n\tthis.type = 'ShaderMaterial';\n\n\tthis.defines = {};\n\tthis.uniforms = {};\n\n\tthis.vertexShader = default_vertex;\n\tthis.fragmentShader = default_fragment;\n\n\tthis.linewidth = 1;\n\n\tthis.wireframe = false;\n\tthis.wireframeLinewidth = 1;\n\n\tthis.fog = false; // set to use scene fog\n\tthis.lights = false; // set to use scene lights\n\tthis.clipping = false; // set to use user-defined clipping planes\n\n\tthis.skinning = false; // set to use skinning attribute streams\n\tthis.morphTargets = false; // set to use morph targets\n\tthis.morphNormals = false; // set to use morph normals\n\n\tthis.extensions = {\n\t\tderivatives: false, // set to use derivatives\n\t\tfragDepth: false, // set to use fragment depth values\n\t\tdrawBuffers: false, // set to use draw buffers\n\t\tshaderTextureLOD: false // set to use shader texture LOD\n\t};\n\n\t// When rendered geometry doesn't include these attributes but the material does,\n\t// use these default values in WebGL. This avoids errors when buffer data is missing.\n\tthis.defaultAttributeValues = {\n\t\t'color': [ 1, 1, 1 ],\n\t\t'uv': [ 0, 0 ],\n\t\t'uv2': [ 0, 0 ]\n\t};\n\n\tthis.index0AttributeName = undefined;\n\tthis.uniformsNeedUpdate = false;\n\n\tif ( parameters !== undefined ) {\n\n\t\tif ( parameters.attributes !== undefined ) {\n\n\t\t\tconsole.error( 'THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead.' );\n\n\t\t}\n\n\t\tthis.setValues( parameters );\n\n\t}\n\n}\n\nShaderMaterial.prototype = Object.create( Material.prototype );\nShaderMaterial.prototype.constructor = ShaderMaterial;\n\nShaderMaterial.prototype.isShaderMaterial = true;\n\nShaderMaterial.prototype.copy = function ( source ) {\n\n\tMaterial.prototype.copy.call( this, source );\n\n\tthis.fragmentShader = source.fragmentShader;\n\tthis.vertexShader = source.vertexShader;\n\n\tthis.uniforms = cloneUniforms( source.uniforms );\n\n\tthis.defines = Object.assign( {}, source.defines );\n\n\tthis.wireframe = source.wireframe;\n\tthis.wireframeLinewidth = source.wireframeLinewidth;\n\n\tthis.lights = source.lights;\n\tthis.clipping = source.clipping;\n\n\tthis.skinning = source.skinning;\n\n\tthis.morphTargets = source.morphTargets;\n\tthis.morphNormals = source.morphNormals;\n\n\tthis.extensions = Object.assign( {}, source.extensions );\n\n\treturn this;\n\n};\n\nShaderMaterial.prototype.toJSON = function ( meta ) {\n\n\tconst data = Material.prototype.toJSON.call( this, meta );\n\n\tdata.uniforms = {};\n\n\tfor ( const name in this.uniforms ) {\n\n\t\tconst uniform = this.uniforms[ name ];\n\t\tconst value = uniform.value;\n\n\t\tif ( value && value.isTexture ) {\n\n\t\t\tdata.uniforms[ name ] = {\n\t\t\t\ttype: 't',\n\t\t\t\tvalue: value.toJSON( meta ).uuid\n\t\t\t};\n\n\t\t} else if ( value && value.isColor ) {\n\n\t\t\tdata.uniforms[ name ] = {\n\t\t\t\ttype: 'c',\n\t\t\t\tvalue: value.getHex()\n\t\t\t};\n\n\t\t} else if ( value && value.isVector2 ) {\n\n\t\t\tdata.uniforms[ name ] = {\n\t\t\t\ttype: 'v2',\n\t\t\t\tvalue: value.toArray()\n\t\t\t};\n\n\t\t} else if ( value && value.isVector3 ) {\n\n\t\t\tdata.uniforms[ name ] = {\n\t\t\t\ttype: 'v3',\n\t\t\t\tvalue: value.toArray()\n\t\t\t};\n\n\t\t} else if ( value && value.isVector4 ) {\n\n\t\t\tdata.uniforms[ name ] = {\n\t\t\t\ttype: 'v4',\n\t\t\t\tvalue: value.toArray()\n\t\t\t};\n\n\t\t} else if ( value && value.isMatrix3 ) {\n\n\t\t\tdata.uniforms[ name ] = {\n\t\t\t\ttype: 'm3',\n\t\t\t\tvalue: value.toArray()\n\t\t\t};\n\n\t\t} else if ( value && value.isMatrix4 ) {\n\n\t\t\tdata.uniforms[ name ] = {\n\t\t\t\ttype: 'm4',\n\t\t\t\tvalue: value.toArray()\n\t\t\t};\n\n\t\t} else {\n\n\t\t\tdata.uniforms[ name ] = {\n\t\t\t\tvalue: value\n\t\t\t};\n\n\t\t\t// note: the array variants v2v, v3v, v4v, m4v and tv are not supported so far\n\n\t\t}\n\n\t}\n\n\tif ( Object.keys( this.defines ).length > 0 ) data.defines = this.defines;\n\n\tdata.vertexShader = this.vertexShader;\n\tdata.fragmentShader = this.fragmentShader;\n\n\tconst extensions = {};\n\n\tfor ( const key in this.extensions ) {\n\n\t\tif ( this.extensions[ key ] === true ) extensions[ key ] = true;\n\n\t}\n\n\tif ( Object.keys( extensions ).length > 0 ) data.extensions = extensions;\n\n\treturn data;\n\n};\n\n\nexport { ShaderMaterial };\n","/**\n * @author mrdoob / http://mrdoob.com/\n * @author mikael emtinger / http://gomo.se/\n * @author WestLangley / http://github.com/WestLangley\n*/\n\nimport { Matrix4 } from '../math/Matrix4.js';\nimport { Object3D } from '../core/Object3D.js';\nimport { Vector3 } from '../math/Vector3.js';\n\nfunction Camera() {\n\n\tObject3D.call( this );\n\n\tthis.type = 'Camera';\n\n\tthis.matrixWorldInverse = new Matrix4();\n\n\tthis.projectionMatrix = new Matrix4();\n\tthis.projectionMatrixInverse = new Matrix4();\n\n}\n\nCamera.prototype = Object.assign( Object.create( Object3D.prototype ), {\n\n\tconstructor: Camera,\n\n\tisCamera: true,\n\n\tcopy: function ( source, recursive ) {\n\n\t\tObject3D.prototype.copy.call( this, source, recursive );\n\n\t\tthis.matrixWorldInverse.copy( source.matrixWorldInverse );\n\n\t\tthis.projectionMatrix.copy( source.projectionMatrix );\n\t\tthis.projectionMatrixInverse.copy( source.projectionMatrixInverse );\n\n\t\treturn this;\n\n\t},\n\n\tgetWorldDirection: function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Camera: .getWorldDirection() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\tthis.updateMatrixWorld( true );\n\n\t\tconst e = this.matrixWorld.elements;\n\n\t\treturn target.set( - e[ 8 ], - e[ 9 ], - e[ 10 ] ).normalize();\n\n\t},\n\n\tupdateMatrixWorld: function ( force ) {\n\n\t\tObject3D.prototype.updateMatrixWorld.call( this, force );\n\n\t\tthis.matrixWorldInverse.getInverse( this.matrixWorld );\n\n\t},\n\n\tupdateWorldMatrix: function ( updateParents, updateChildren ) {\n\n\t\tObject3D.prototype.updateWorldMatrix.call( this, updateParents, updateChildren );\n\n\t\tthis.matrixWorldInverse.getInverse( this.matrixWorld );\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor().copy( this );\n\n\t}\n\n} );\n\nexport { Camera };\n","import { Camera } from './Camera.js';\nimport { Object3D } from '../core/Object3D.js';\nimport { MathUtils } from '../math/MathUtils.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author greggman / http://games.greggman.com/\n * @author zz85 / http://www.lab4games.net/zz85/blog\n * @author tschw\n */\n\nfunction PerspectiveCamera( fov, aspect, near, far ) {\n\n\tCamera.call( this );\n\n\tthis.type = 'PerspectiveCamera';\n\n\tthis.fov = fov !== undefined ? fov : 50;\n\tthis.zoom = 1;\n\n\tthis.near = near !== undefined ? near : 0.1;\n\tthis.far = far !== undefined ? far : 2000;\n\tthis.focus = 10;\n\n\tthis.aspect = aspect !== undefined ? aspect : 1;\n\tthis.view = null;\n\n\tthis.filmGauge = 35;\t// width of the film (default in millimeters)\n\tthis.filmOffset = 0;\t// horizontal film offset (same unit as gauge)\n\n\tthis.updateProjectionMatrix();\n\n}\n\nPerspectiveCamera.prototype = Object.assign( Object.create( Camera.prototype ), {\n\n\tconstructor: PerspectiveCamera,\n\n\tisPerspectiveCamera: true,\n\n\tcopy: function ( source, recursive ) {\n\n\t\tCamera.prototype.copy.call( this, source, recursive );\n\n\t\tthis.fov = source.fov;\n\t\tthis.zoom = source.zoom;\n\n\t\tthis.near = source.near;\n\t\tthis.far = source.far;\n\t\tthis.focus = source.focus;\n\n\t\tthis.aspect = source.aspect;\n\t\tthis.view = source.view === null ? null : Object.assign( {}, source.view );\n\n\t\tthis.filmGauge = source.filmGauge;\n\t\tthis.filmOffset = source.filmOffset;\n\n\t\treturn this;\n\n\t},\n\n\t/**\n\t * Sets the FOV by focal length in respect to the current .filmGauge.\n\t *\n\t * The default film gauge is 35, so that the focal length can be specified for\n\t * a 35mm (full frame) camera.\n\t *\n\t * Values for focal length and film gauge must have the same unit.\n\t */\n\tsetFocalLength: function ( focalLength ) {\n\n\t\t// see http://www.bobatkins.com/photography/technical/field_of_view.html\n\t\tconst vExtentSlope = 0.5 * this.getFilmHeight() / focalLength;\n\n\t\tthis.fov = MathUtils.RAD2DEG * 2 * Math.atan( vExtentSlope );\n\t\tthis.updateProjectionMatrix();\n\n\t},\n\n\t/**\n\t * Calculates the focal length from the current .fov and .filmGauge.\n\t */\n\tgetFocalLength: function () {\n\n\t\tconst vExtentSlope = Math.tan( MathUtils.DEG2RAD * 0.5 * this.fov );\n\n\t\treturn 0.5 * this.getFilmHeight() / vExtentSlope;\n\n\t},\n\n\tgetEffectiveFOV: function () {\n\n\t\treturn MathUtils.RAD2DEG * 2 * Math.atan(\n\t\t\tMath.tan( MathUtils.DEG2RAD * 0.5 * this.fov ) / this.zoom );\n\n\t},\n\n\tgetFilmWidth: function () {\n\n\t\t// film not completely covered in portrait format (aspect < 1)\n\t\treturn this.filmGauge * Math.min( this.aspect, 1 );\n\n\t},\n\n\tgetFilmHeight: function () {\n\n\t\t// film not completely covered in landscape format (aspect > 1)\n\t\treturn this.filmGauge / Math.max( this.aspect, 1 );\n\n\t},\n\n\t/**\n\t * Sets an offset in a larger frustum. This is useful for multi-window or\n\t * multi-monitor/multi-machine setups.\n\t *\n\t * For example, if you have 3x2 monitors and each monitor is 1920x1080 and\n\t * the monitors are in grid like this\n\t *\n\t * +---+---+---+\n\t * | A | B | C |\n\t * +---+---+---+\n\t * | D | E | F |\n\t * +---+---+---+\n\t *\n\t * then for each monitor you would call it like this\n\t *\n\t * const w = 1920;\n\t * const h = 1080;\n\t * const fullWidth = w * 3;\n\t * const fullHeight = h * 2;\n\t *\n\t * --A--\n\t * camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 0, w, h );\n\t * --B--\n\t * camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 0, w, h );\n\t * --C--\n\t * camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 0, w, h );\n\t * --D--\n\t * camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 1, w, h );\n\t * --E--\n\t * camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 1, w, h );\n\t * --F--\n\t * camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 1, w, h );\n\t *\n\t * Note there is no reason monitors have to be the same size or in a grid.\n\t */\n\tsetViewOffset: function ( fullWidth, fullHeight, x, y, width, height ) {\n\n\t\tthis.aspect = fullWidth / fullHeight;\n\n\t\tif ( this.view === null ) {\n\n\t\t\tthis.view = {\n\t\t\t\tenabled: true,\n\t\t\t\tfullWidth: 1,\n\t\t\t\tfullHeight: 1,\n\t\t\t\toffsetX: 0,\n\t\t\t\toffsetY: 0,\n\t\t\t\twidth: 1,\n\t\t\t\theight: 1\n\t\t\t};\n\n\t\t}\n\n\t\tthis.view.enabled = true;\n\t\tthis.view.fullWidth = fullWidth;\n\t\tthis.view.fullHeight = fullHeight;\n\t\tthis.view.offsetX = x;\n\t\tthis.view.offsetY = y;\n\t\tthis.view.width = width;\n\t\tthis.view.height = height;\n\n\t\tthis.updateProjectionMatrix();\n\n\t},\n\n\tclearViewOffset: function () {\n\n\t\tif ( this.view !== null ) {\n\n\t\t\tthis.view.enabled = false;\n\n\t\t}\n\n\t\tthis.updateProjectionMatrix();\n\n\t},\n\n\tupdateProjectionMatrix: function () {\n\n\t\tlet near = this.near,\n\t\t\ttop = near * Math.tan( MathUtils.DEG2RAD * 0.5 * this.fov ) / this.zoom,\n\t\t\theight = 2 * top,\n\t\t\twidth = this.aspect * height,\n\t\t\tleft = - 0.5 * width,\n\t\t\tview = this.view;\n\n\t\tif ( this.view !== null && this.view.enabled ) {\n\n\t\t\tconst fullWidth = view.fullWidth,\n\t\t\t\tfullHeight = view.fullHeight;\n\n\t\t\tleft += view.offsetX * width / fullWidth;\n\t\t\ttop -= view.offsetY * height / fullHeight;\n\t\t\twidth *= view.width / fullWidth;\n\t\t\theight *= view.height / fullHeight;\n\n\t\t}\n\n\t\tconst skew = this.filmOffset;\n\t\tif ( skew !== 0 ) left += near * skew / this.getFilmWidth();\n\n\t\tthis.projectionMatrix.makePerspective( left, left + width, top, top - height, near, this.far );\n\n\t\tthis.projectionMatrixInverse.getInverse( this.projectionMatrix );\n\n\t},\n\n\ttoJSON: function ( meta ) {\n\n\t\tconst data = Object3D.prototype.toJSON.call( this, meta );\n\n\t\tdata.object.fov = this.fov;\n\t\tdata.object.zoom = this.zoom;\n\n\t\tdata.object.near = this.near;\n\t\tdata.object.far = this.far;\n\t\tdata.object.focus = this.focus;\n\n\t\tdata.object.aspect = this.aspect;\n\n\t\tif ( this.view !== null ) data.object.view = Object.assign( {}, this.view );\n\n\t\tdata.object.filmGauge = this.filmGauge;\n\t\tdata.object.filmOffset = this.filmOffset;\n\n\t\treturn data;\n\n\t}\n\n} );\n\n\nexport { PerspectiveCamera };\n","/**\n * @author alteredq / http://alteredqualia.com/\n */\n\nimport { Texture } from './Texture.js';\nimport { NearestFilter } from '../constants.js';\n\nfunction DataTexture( data, width, height, format, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, encoding ) {\n\n\tTexture.call( this, null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding );\n\n\tthis.image = { data: data || null, width: width || 1, height: height || 1 };\n\n\tthis.magFilter = magFilter !== undefined ? magFilter : NearestFilter;\n\tthis.minFilter = minFilter !== undefined ? minFilter : NearestFilter;\n\n\tthis.generateMipmaps = false;\n\tthis.flipY = false;\n\tthis.unpackAlignment = 1;\n\n\tthis.needsUpdate = true;\n\n}\n\nDataTexture.prototype = Object.create( Texture.prototype );\nDataTexture.prototype.constructor = DataTexture;\n\nDataTexture.prototype.isDataTexture = true;\n\n\nexport { DataTexture };\n","import { Vector3 } from './Vector3.js';\nimport { Sphere } from './Sphere.js';\nimport { Plane } from './Plane.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author alteredq / http://alteredqualia.com/\n * @author bhouston / http://clara.io\n */\n\nconst _sphere = new Sphere();\nconst _vector = new Vector3();\n\nfunction Frustum( p0, p1, p2, p3, p4, p5 ) {\n\n\tthis.planes = [\n\n\t\t( p0 !== undefined ) ? p0 : new Plane(),\n\t\t( p1 !== undefined ) ? p1 : new Plane(),\n\t\t( p2 !== undefined ) ? p2 : new Plane(),\n\t\t( p3 !== undefined ) ? p3 : new Plane(),\n\t\t( p4 !== undefined ) ? p4 : new Plane(),\n\t\t( p5 !== undefined ) ? p5 : new Plane()\n\n\t];\n\n}\n\nObject.assign( Frustum.prototype, {\n\n\tset: function ( p0, p1, p2, p3, p4, p5 ) {\n\n\t\tconst planes = this.planes;\n\n\t\tplanes[ 0 ].copy( p0 );\n\t\tplanes[ 1 ].copy( p1 );\n\t\tplanes[ 2 ].copy( p2 );\n\t\tplanes[ 3 ].copy( p3 );\n\t\tplanes[ 4 ].copy( p4 );\n\t\tplanes[ 5 ].copy( p5 );\n\n\t\treturn this;\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor().copy( this );\n\n\t},\n\n\tcopy: function ( frustum ) {\n\n\t\tconst planes = this.planes;\n\n\t\tfor ( let i = 0; i < 6; i ++ ) {\n\n\t\t\tplanes[ i ].copy( frustum.planes[ i ] );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tsetFromProjectionMatrix: function ( m ) {\n\n\t\tconst planes = this.planes;\n\t\tconst me = m.elements;\n\t\tconst me0 = me[ 0 ], me1 = me[ 1 ], me2 = me[ 2 ], me3 = me[ 3 ];\n\t\tconst me4 = me[ 4 ], me5 = me[ 5 ], me6 = me[ 6 ], me7 = me[ 7 ];\n\t\tconst me8 = me[ 8 ], me9 = me[ 9 ], me10 = me[ 10 ], me11 = me[ 11 ];\n\t\tconst me12 = me[ 12 ], me13 = me[ 13 ], me14 = me[ 14 ], me15 = me[ 15 ];\n\n\t\tplanes[ 0 ].setComponents( me3 - me0, me7 - me4, me11 - me8, me15 - me12 ).normalize();\n\t\tplanes[ 1 ].setComponents( me3 + me0, me7 + me4, me11 + me8, me15 + me12 ).normalize();\n\t\tplanes[ 2 ].setComponents( me3 + me1, me7 + me5, me11 + me9, me15 + me13 ).normalize();\n\t\tplanes[ 3 ].setComponents( me3 - me1, me7 - me5, me11 - me9, me15 - me13 ).normalize();\n\t\tplanes[ 4 ].setComponents( me3 - me2, me7 - me6, me11 - me10, me15 - me14 ).normalize();\n\t\tplanes[ 5 ].setComponents( me3 + me2, me7 + me6, me11 + me10, me15 + me14 ).normalize();\n\n\t\treturn this;\n\n\t},\n\n\tintersectsObject: function ( object ) {\n\n\t\tconst geometry = object.geometry;\n\n\t\tif ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();\n\n\t\t_sphere.copy( geometry.boundingSphere ).applyMatrix4( object.matrixWorld );\n\n\t\treturn this.intersectsSphere( _sphere );\n\n\t},\n\n\tintersectsSprite: function ( sprite ) {\n\n\t\t_sphere.center.set( 0, 0, 0 );\n\t\t_sphere.radius = 0.7071067811865476;\n\t\t_sphere.applyMatrix4( sprite.matrixWorld );\n\n\t\treturn this.intersectsSphere( _sphere );\n\n\t},\n\n\tintersectsSphere: function ( sphere ) {\n\n\t\tconst planes = this.planes;\n\t\tconst center = sphere.center;\n\t\tconst negRadius = - sphere.radius;\n\n\t\tfor ( let i = 0; i < 6; i ++ ) {\n\n\t\t\tconst distance = planes[ i ].distanceToPoint( center );\n\n\t\t\tif ( distance < negRadius ) {\n\n\t\t\t\treturn false;\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn true;\n\n\t},\n\n\tintersectsBox: function ( box ) {\n\n\t\tconst planes = this.planes;\n\n\t\tfor ( let i = 0; i < 6; i ++ ) {\n\n\t\t\tconst plane = planes[ i ];\n\n\t\t\t// corner at max distance\n\n\t\t\t_vector.x = plane.normal.x > 0 ? box.max.x : box.min.x;\n\t\t\t_vector.y = plane.normal.y > 0 ? box.max.y : box.min.y;\n\t\t\t_vector.z = plane.normal.z > 0 ? box.max.z : box.min.z;\n\n\t\t\tif ( plane.distanceToPoint( _vector ) < 0 ) {\n\n\t\t\t\treturn false;\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn true;\n\n\t},\n\n\tcontainsPoint: function ( point ) {\n\n\t\tconst planes = this.planes;\n\n\t\tfor ( let i = 0; i < 6; i ++ ) {\n\n\t\t\tif ( planes[ i ].distanceToPoint( point ) < 0 ) {\n\n\t\t\t\treturn false;\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn true;\n\n\t}\n\n} );\n\n\nexport { Frustum };\n","import { Color } from '../../math/Color.js';\nimport { Vector2 } from '../../math/Vector2.js';\nimport { Matrix3 } from '../../math/Matrix3.js';\n\n/**\n * Uniforms library for shared webgl shaders\n */\n\nconst UniformsLib = {\n\n\tcommon: {\n\n\t\tdiffuse: { value: new Color( 0xeeeeee ) },\n\t\topacity: { value: 1.0 },\n\n\t\tmap: { value: null },\n\t\tuvTransform: { value: new Matrix3() },\n\t\tuv2Transform: { value: new Matrix3() },\n\n\t\talphaMap: { value: null },\n\n\t},\n\n\tspecularmap: {\n\n\t\tspecularMap: { value: null },\n\n\t},\n\n\tenvmap: {\n\n\t\tenvMap: { value: null },\n\t\tflipEnvMap: { value: - 1 },\n\t\treflectivity: { value: 1.0 },\n\t\trefractionRatio: { value: 0.98 },\n\t\tmaxMipLevel: { value: 0 }\n\n\t},\n\n\taomap: {\n\n\t\taoMap: { value: null },\n\t\taoMapIntensity: { value: 1 }\n\n\t},\n\n\tlightmap: {\n\n\t\tlightMap: { value: null },\n\t\tlightMapIntensity: { value: 1 }\n\n\t},\n\n\temissivemap: {\n\n\t\temissiveMap: { value: null }\n\n\t},\n\n\tbumpmap: {\n\n\t\tbumpMap: { value: null },\n\t\tbumpScale: { value: 1 }\n\n\t},\n\n\tnormalmap: {\n\n\t\tnormalMap: { value: null },\n\t\tnormalScale: { value: new Vector2( 1, 1 ) }\n\n\t},\n\n\tdisplacementmap: {\n\n\t\tdisplacementMap: { value: null },\n\t\tdisplacementScale: { value: 1 },\n\t\tdisplacementBias: { value: 0 }\n\n\t},\n\n\troughnessmap: {\n\n\t\troughnessMap: { value: null }\n\n\t},\n\n\tmetalnessmap: {\n\n\t\tmetalnessMap: { value: null }\n\n\t},\n\n\tgradientmap: {\n\n\t\tgradientMap: { value: null }\n\n\t},\n\n\tfog: {\n\n\t\tfogDensity: { value: 0.00025 },\n\t\tfogNear: { value: 1 },\n\t\tfogFar: { value: 2000 },\n\t\tfogColor: { value: new Color( 0xffffff ) }\n\n\t},\n\n\tlights: {\n\n\t\tambientLightColor: { value: [] },\n\n\t\tlightProbe: { value: [] },\n\n\t\tdirectionalLights: { value: [], properties: {\n\t\t\tdirection: {},\n\t\t\tcolor: {}\n\t\t} },\n\n\t\tdirectionalLightShadows: { value: [], properties: {\n\t\t\tshadowBias: {},\n\t\t\tshadowNormalBias: {},\n\t\t\tshadowRadius: {},\n\t\t\tshadowMapSize: {}\n\t\t} },\n\n\t\tdirectionalShadowMap: { value: [] },\n\t\tdirectionalShadowMatrix: { value: [] },\n\n\t\tspotLights: { value: [], properties: {\n\t\t\tcolor: {},\n\t\t\tposition: {},\n\t\t\tdirection: {},\n\t\t\tdistance: {},\n\t\t\tconeCos: {},\n\t\t\tpenumbraCos: {},\n\t\t\tdecay: {}\n\t\t} },\n\n\t\tspotLightShadows: { value: [], properties: {\n\t\t\tshadowBias: {},\n\t\t\tshadowNormalBias: {},\n\t\t\tshadowRadius: {},\n\t\t\tshadowMapSize: {}\n\t\t} },\n\n\t\tspotShadowMap: { value: [] },\n\t\tspotShadowMatrix: { value: [] },\n\n\t\tpointLights: { value: [], properties: {\n\t\t\tcolor: {},\n\t\t\tposition: {},\n\t\t\tdecay: {},\n\t\t\tdistance: {}\n\t\t} },\n\n\t\tpointLightShadows: { value: [], properties: {\n\t\t\tshadowBias: {},\n\t\t\tshadowNormalBias: {},\n\t\t\tshadowRadius: {},\n\t\t\tshadowMapSize: {},\n\t\t\tshadowCameraNear: {},\n\t\t\tshadowCameraFar: {}\n\t\t} },\n\n\t\tpointShadowMap: { value: [] },\n\t\tpointShadowMatrix: { value: [] },\n\n\t\themisphereLights: { value: [], properties: {\n\t\t\tdirection: {},\n\t\t\tskyColor: {},\n\t\t\tgroundColor: {}\n\t\t} },\n\n\t\t// TODO (abelnation): RectAreaLight BRDF data needs to be moved from example to main src\n\t\trectAreaLights: { value: [], properties: {\n\t\t\tcolor: {},\n\t\t\tposition: {},\n\t\t\twidth: {},\n\t\t\theight: {}\n\t\t} }\n\n\t},\n\n\tpoints: {\n\n\t\tdiffuse: { value: new Color( 0xeeeeee ) },\n\t\topacity: { value: 1.0 },\n\t\tsize: { value: 1.0 },\n\t\tscale: { value: 1.0 },\n\t\tmap: { value: null },\n\t\talphaMap: { value: null },\n\t\tuvTransform: { value: new Matrix3() }\n\n\t},\n\n\tsprite: {\n\n\t\tdiffuse: { value: new Color( 0xeeeeee ) },\n\t\topacity: { value: 1.0 },\n\t\tcenter: { value: new Vector2( 0.5, 0.5 ) },\n\t\trotation: { value: 0.0 },\n\t\tmap: { value: null },\n\t\talphaMap: { value: null },\n\t\tuvTransform: { value: new Matrix3() }\n\n\t}\n\n};\n\nexport { UniformsLib };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction WebGLAnimation() {\n\n\tlet context = null;\n\tlet isAnimating = false;\n\tlet animationLoop = null;\n\tlet requestId = null;\n\n\tfunction onAnimationFrame( time, frame ) {\n\n\t\tanimationLoop( time, frame );\n\n\t\trequestId = context.requestAnimationFrame( onAnimationFrame );\n\n\t}\n\n\treturn {\n\n\t\tstart: function () {\n\n\t\t\tif ( isAnimating === true ) return;\n\t\t\tif ( animationLoop === null ) return;\n\n\t\t\trequestId = context.requestAnimationFrame( onAnimationFrame );\n\n\t\t\tisAnimating = true;\n\n\t\t},\n\n\t\tstop: function () {\n\n\t\t\tcontext.cancelAnimationFrame( requestId );\n\n\t\t\tisAnimating = false;\n\n\t\t},\n\n\t\tsetAnimationLoop: function ( callback ) {\n\n\t\t\tanimationLoop = callback;\n\n\t\t},\n\n\t\tsetContext: function ( value ) {\n\n\t\t\tcontext = value;\n\n\t\t}\n\n\t};\n\n}\n\nexport { WebGLAnimation };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction WebGLAttributes( gl, capabilities ) {\n\n\tconst isWebGL2 = capabilities.isWebGL2;\n\n\tconst buffers = new WeakMap();\n\n\tfunction createBuffer( attribute, bufferType ) {\n\n\t\tconst array = attribute.array;\n\t\tconst usage = attribute.usage;\n\n\t\tconst buffer = gl.createBuffer();\n\n\t\tgl.bindBuffer( bufferType, buffer );\n\t\tgl.bufferData( bufferType, array, usage );\n\n\t\tattribute.onUploadCallback();\n\n\t\tlet type = gl.FLOAT;\n\n\t\tif ( array instanceof Float32Array ) {\n\n\t\t\ttype = gl.FLOAT;\n\n\t\t} else if ( array instanceof Float64Array ) {\n\n\t\t\tconsole.warn( 'THREE.WebGLAttributes: Unsupported data buffer format: Float64Array.' );\n\n\t\t} else if ( array instanceof Uint16Array ) {\n\n\t\t\ttype = gl.UNSIGNED_SHORT;\n\n\t\t} else if ( array instanceof Int16Array ) {\n\n\t\t\ttype = gl.SHORT;\n\n\t\t} else if ( array instanceof Uint32Array ) {\n\n\t\t\ttype = gl.UNSIGNED_INT;\n\n\t\t} else if ( array instanceof Int32Array ) {\n\n\t\t\ttype = gl.INT;\n\n\t\t} else if ( array instanceof Int8Array ) {\n\n\t\t\ttype = gl.BYTE;\n\n\t\t} else if ( array instanceof Uint8Array ) {\n\n\t\t\ttype = gl.UNSIGNED_BYTE;\n\n\t\t}\n\n\t\treturn {\n\t\t\tbuffer: buffer,\n\t\t\ttype: type,\n\t\t\tbytesPerElement: array.BYTES_PER_ELEMENT,\n\t\t\tversion: attribute.version\n\t\t};\n\n\t}\n\n\tfunction updateBuffer( buffer, attribute, bufferType ) {\n\n\t\tconst array = attribute.array;\n\t\tconst updateRange = attribute.updateRange;\n\n\t\tgl.bindBuffer( bufferType, buffer );\n\n\t\tif ( updateRange.count === - 1 ) {\n\n\t\t\t// Not using update ranges\n\n\t\t\tgl.bufferSubData( bufferType, 0, array );\n\n\t\t} else {\n\n\t\t\tif ( isWebGL2 ) {\n\n\t\t\t\tgl.bufferSubData( bufferType, updateRange.offset * array.BYTES_PER_ELEMENT,\n\t\t\t\t\tarray, updateRange.offset, updateRange.count );\n\n\t\t\t} else {\n\n\t\t\t\tgl.bufferSubData( bufferType, updateRange.offset * array.BYTES_PER_ELEMENT,\n\t\t\t\t\tarray.subarray( updateRange.offset, updateRange.offset + updateRange.count ) );\n\n\t\t\t}\n\n\t\t\tupdateRange.count = - 1; // reset range\n\n\t\t}\n\n\t}\n\n\t//\n\n\tfunction get( attribute ) {\n\n\t\tif ( attribute.isInterleavedBufferAttribute ) attribute = attribute.data;\n\n\t\treturn buffers.get( attribute );\n\n\t}\n\n\tfunction remove( attribute ) {\n\n\t\tif ( attribute.isInterleavedBufferAttribute ) attribute = attribute.data;\n\n\t\tconst data = buffers.get( attribute );\n\n\t\tif ( data ) {\n\n\t\t\tgl.deleteBuffer( data.buffer );\n\n\t\t\tbuffers.delete( attribute );\n\n\t\t}\n\n\t}\n\n\tfunction update( attribute, bufferType ) {\n\n\t\tif ( attribute.isInterleavedBufferAttribute ) attribute = attribute.data;\n\n\t\tconst data = buffers.get( attribute );\n\n\t\tif ( data === undefined ) {\n\n\t\t\tbuffers.set( attribute, createBuffer( attribute, bufferType ) );\n\n\t\t} else if ( data.version < attribute.version ) {\n\n\t\t\tupdateBuffer( data.buffer, attribute, bufferType );\n\n\t\t\tdata.version = attribute.version;\n\n\t\t}\n\n\t}\n\n\treturn {\n\n\t\tget: get,\n\t\tremove: remove,\n\t\tupdate: update\n\n\t};\n\n}\n\n\nexport { WebGLAttributes };\n","/**\n * @author mrdoob / http://mrdoob.com/\n * @author Mugen87 / https://github.com/Mugen87\n */\n\nimport { Geometry } from '../core/Geometry.js';\nimport { BufferGeometry } from '../core/BufferGeometry.js';\nimport { Float32BufferAttribute } from '../core/BufferAttribute.js';\n\n// PlaneGeometry\n\nfunction PlaneGeometry( width, height, widthSegments, heightSegments ) {\n\n\tGeometry.call( this );\n\n\tthis.type = 'PlaneGeometry';\n\n\tthis.parameters = {\n\t\twidth: width,\n\t\theight: height,\n\t\twidthSegments: widthSegments,\n\t\theightSegments: heightSegments\n\t};\n\n\tthis.fromBufferGeometry( new PlaneBufferGeometry( width, height, widthSegments, heightSegments ) );\n\tthis.mergeVertices();\n\n}\n\nPlaneGeometry.prototype = Object.create( Geometry.prototype );\nPlaneGeometry.prototype.constructor = PlaneGeometry;\n\n// PlaneBufferGeometry\n\nfunction PlaneBufferGeometry( width, height, widthSegments, heightSegments ) {\n\n\tBufferGeometry.call( this );\n\n\tthis.type = 'PlaneBufferGeometry';\n\n\tthis.parameters = {\n\t\twidth: width,\n\t\theight: height,\n\t\twidthSegments: widthSegments,\n\t\theightSegments: heightSegments\n\t};\n\n\twidth = width || 1;\n\theight = height || 1;\n\n\tconst width_half = width / 2;\n\tconst height_half = height / 2;\n\n\tconst gridX = Math.floor( widthSegments ) || 1;\n\tconst gridY = Math.floor( heightSegments ) || 1;\n\n\tconst gridX1 = gridX + 1;\n\tconst gridY1 = gridY + 1;\n\n\tconst segment_width = width / gridX;\n\tconst segment_height = height / gridY;\n\n\t// buffers\n\n\tconst indices = [];\n\tconst vertices = [];\n\tconst normals = [];\n\tconst uvs = [];\n\n\t// generate vertices, normals and uvs\n\n\tfor ( let iy = 0; iy < gridY1; iy ++ ) {\n\n\t\tconst y = iy * segment_height - height_half;\n\n\t\tfor ( let ix = 0; ix < gridX1; ix ++ ) {\n\n\t\t\tconst x = ix * segment_width - width_half;\n\n\t\t\tvertices.push( x, - y, 0 );\n\n\t\t\tnormals.push( 0, 0, 1 );\n\n\t\t\tuvs.push( ix / gridX );\n\t\t\tuvs.push( 1 - ( iy / gridY ) );\n\n\t\t}\n\n\t}\n\n\t// indices\n\n\tfor ( let iy = 0; iy < gridY; iy ++ ) {\n\n\t\tfor ( let ix = 0; ix < gridX; ix ++ ) {\n\n\t\t\tconst a = ix + gridX1 * iy;\n\t\t\tconst b = ix + gridX1 * ( iy + 1 );\n\t\t\tconst c = ( ix + 1 ) + gridX1 * ( iy + 1 );\n\t\t\tconst d = ( ix + 1 ) + gridX1 * iy;\n\n\t\t\t// faces\n\n\t\t\tindices.push( a, b, d );\n\t\t\tindices.push( b, c, d );\n\n\t\t}\n\n\t}\n\n\t// build geometry\n\n\tthis.setIndex( indices );\n\tthis.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );\n\tthis.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );\n\tthis.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );\n\n}\n\nPlaneBufferGeometry.prototype = Object.create( BufferGeometry.prototype );\nPlaneBufferGeometry.prototype.constructor = PlaneBufferGeometry;\n\n\nexport { PlaneGeometry, PlaneBufferGeometry };\n","import alphamap_fragment from './ShaderChunk/alphamap_fragment.glsl.js';\nimport alphamap_pars_fragment from './ShaderChunk/alphamap_pars_fragment.glsl.js';\nimport alphatest_fragment from './ShaderChunk/alphatest_fragment.glsl.js';\nimport aomap_fragment from './ShaderChunk/aomap_fragment.glsl.js';\nimport aomap_pars_fragment from './ShaderChunk/aomap_pars_fragment.glsl.js';\nimport begin_vertex from './ShaderChunk/begin_vertex.glsl.js';\nimport beginnormal_vertex from './ShaderChunk/beginnormal_vertex.glsl.js';\nimport bsdfs from './ShaderChunk/bsdfs.glsl.js';\nimport bumpmap_pars_fragment from './ShaderChunk/bumpmap_pars_fragment.glsl.js';\nimport clipping_planes_fragment from './ShaderChunk/clipping_planes_fragment.glsl.js';\nimport clipping_planes_pars_fragment from './ShaderChunk/clipping_planes_pars_fragment.glsl.js';\nimport clipping_planes_pars_vertex from './ShaderChunk/clipping_planes_pars_vertex.glsl.js';\nimport clipping_planes_vertex from './ShaderChunk/clipping_planes_vertex.glsl.js';\nimport color_fragment from './ShaderChunk/color_fragment.glsl.js';\nimport color_pars_fragment from './ShaderChunk/color_pars_fragment.glsl.js';\nimport color_pars_vertex from './ShaderChunk/color_pars_vertex.glsl.js';\nimport color_vertex from './ShaderChunk/color_vertex.glsl.js';\nimport common from './ShaderChunk/common.glsl.js';\nimport cube_uv_reflection_fragment from './ShaderChunk/cube_uv_reflection_fragment.glsl.js';\nimport defaultnormal_vertex from './ShaderChunk/defaultnormal_vertex.glsl.js';\nimport displacementmap_pars_vertex from './ShaderChunk/displacementmap_pars_vertex.glsl.js';\nimport displacementmap_vertex from './ShaderChunk/displacementmap_vertex.glsl.js';\nimport emissivemap_fragment from './ShaderChunk/emissivemap_fragment.glsl.js';\nimport emissivemap_pars_fragment from './ShaderChunk/emissivemap_pars_fragment.glsl.js';\nimport encodings_fragment from './ShaderChunk/encodings_fragment.glsl.js';\nimport encodings_pars_fragment from './ShaderChunk/encodings_pars_fragment.glsl.js';\nimport envmap_fragment from './ShaderChunk/envmap_fragment.glsl.js';\nimport envmap_common_pars_fragment from './ShaderChunk/envmap_common_pars_fragment.glsl.js';\nimport envmap_pars_fragment from './ShaderChunk/envmap_pars_fragment.glsl.js';\nimport envmap_pars_vertex from './ShaderChunk/envmap_pars_vertex.glsl.js';\nimport envmap_vertex from './ShaderChunk/envmap_vertex.glsl.js';\nimport fog_vertex from './ShaderChunk/fog_vertex.glsl.js';\nimport fog_pars_vertex from './ShaderChunk/fog_pars_vertex.glsl.js';\nimport fog_fragment from './ShaderChunk/fog_fragment.glsl.js';\nimport fog_pars_fragment from './ShaderChunk/fog_pars_fragment.glsl.js';\nimport gradientmap_pars_fragment from './ShaderChunk/gradientmap_pars_fragment.glsl.js';\nimport lightmap_fragment from './ShaderChunk/lightmap_fragment.glsl.js';\nimport lightmap_pars_fragment from './ShaderChunk/lightmap_pars_fragment.glsl.js';\nimport lights_lambert_vertex from './ShaderChunk/lights_lambert_vertex.glsl.js';\nimport lights_pars_begin from './ShaderChunk/lights_pars_begin.glsl.js';\nimport envmap_physical_pars_fragment from './ShaderChunk/envmap_physical_pars_fragment.glsl.js';\nimport lights_toon_fragment from './ShaderChunk/lights_toon_fragment.glsl.js';\nimport lights_toon_pars_fragment from './ShaderChunk/lights_toon_pars_fragment.glsl.js';\nimport lights_phong_fragment from './ShaderChunk/lights_phong_fragment.glsl.js';\nimport lights_phong_pars_fragment from './ShaderChunk/lights_phong_pars_fragment.glsl.js';\nimport lights_physical_fragment from './ShaderChunk/lights_physical_fragment.glsl.js';\nimport lights_physical_pars_fragment from './ShaderChunk/lights_physical_pars_fragment.glsl.js';\nimport lights_fragment_begin from './ShaderChunk/lights_fragment_begin.glsl.js';\nimport lights_fragment_maps from './ShaderChunk/lights_fragment_maps.glsl.js';\nimport lights_fragment_end from './ShaderChunk/lights_fragment_end.glsl.js';\nimport logdepthbuf_fragment from './ShaderChunk/logdepthbuf_fragment.glsl.js';\nimport logdepthbuf_pars_fragment from './ShaderChunk/logdepthbuf_pars_fragment.glsl.js';\nimport logdepthbuf_pars_vertex from './ShaderChunk/logdepthbuf_pars_vertex.glsl.js';\nimport logdepthbuf_vertex from './ShaderChunk/logdepthbuf_vertex.glsl.js';\nimport map_fragment from './ShaderChunk/map_fragment.glsl.js';\nimport map_pars_fragment from './ShaderChunk/map_pars_fragment.glsl.js';\nimport map_particle_fragment from './ShaderChunk/map_particle_fragment.glsl.js';\nimport map_particle_pars_fragment from './ShaderChunk/map_particle_pars_fragment.glsl.js';\nimport metalnessmap_fragment from './ShaderChunk/metalnessmap_fragment.glsl.js';\nimport metalnessmap_pars_fragment from './ShaderChunk/metalnessmap_pars_fragment.glsl.js';\nimport morphnormal_vertex from './ShaderChunk/morphnormal_vertex.glsl.js';\nimport morphtarget_pars_vertex from './ShaderChunk/morphtarget_pars_vertex.glsl.js';\nimport morphtarget_vertex from './ShaderChunk/morphtarget_vertex.glsl.js';\nimport normal_fragment_begin from './ShaderChunk/normal_fragment_begin.glsl.js';\nimport normal_fragment_maps from './ShaderChunk/normal_fragment_maps.glsl.js';\nimport normalmap_pars_fragment from './ShaderChunk/normalmap_pars_fragment.glsl.js';\nimport clearcoat_normal_fragment_begin from './ShaderChunk/clearcoat_normal_fragment_begin.glsl.js';\nimport clearcoat_normal_fragment_maps from './ShaderChunk/clearcoat_normal_fragment_maps.glsl.js';\nimport clearcoat_pars_fragment from './ShaderChunk/clearcoat_pars_fragment.glsl.js';\nimport packing from './ShaderChunk/packing.glsl.js';\nimport premultiplied_alpha_fragment from './ShaderChunk/premultiplied_alpha_fragment.glsl.js';\nimport project_vertex from './ShaderChunk/project_vertex.glsl.js';\nimport dithering_fragment from './ShaderChunk/dithering_fragment.glsl.js';\nimport dithering_pars_fragment from './ShaderChunk/dithering_pars_fragment.glsl.js';\nimport roughnessmap_fragment from './ShaderChunk/roughnessmap_fragment.glsl.js';\nimport roughnessmap_pars_fragment from './ShaderChunk/roughnessmap_pars_fragment.glsl.js';\nimport shadowmap_pars_fragment from './ShaderChunk/shadowmap_pars_fragment.glsl.js';\nimport shadowmap_pars_vertex from './ShaderChunk/shadowmap_pars_vertex.glsl.js';\nimport shadowmap_vertex from './ShaderChunk/shadowmap_vertex.glsl.js';\nimport shadowmask_pars_fragment from './ShaderChunk/shadowmask_pars_fragment.glsl.js';\nimport skinbase_vertex from './ShaderChunk/skinbase_vertex.glsl.js';\nimport skinning_pars_vertex from './ShaderChunk/skinning_pars_vertex.glsl.js';\nimport skinning_vertex from './ShaderChunk/skinning_vertex.glsl.js';\nimport skinnormal_vertex from './ShaderChunk/skinnormal_vertex.glsl.js';\nimport specularmap_fragment from './ShaderChunk/specularmap_fragment.glsl.js';\nimport specularmap_pars_fragment from './ShaderChunk/specularmap_pars_fragment.glsl.js';\nimport tonemapping_fragment from './ShaderChunk/tonemapping_fragment.glsl.js';\nimport tonemapping_pars_fragment from './ShaderChunk/tonemapping_pars_fragment.glsl.js';\nimport uv_pars_fragment from './ShaderChunk/uv_pars_fragment.glsl.js';\nimport uv_pars_vertex from './ShaderChunk/uv_pars_vertex.glsl.js';\nimport uv_vertex from './ShaderChunk/uv_vertex.glsl.js';\nimport uv2_pars_fragment from './ShaderChunk/uv2_pars_fragment.glsl.js';\nimport uv2_pars_vertex from './ShaderChunk/uv2_pars_vertex.glsl.js';\nimport uv2_vertex from './ShaderChunk/uv2_vertex.glsl.js';\nimport worldpos_vertex from './ShaderChunk/worldpos_vertex.glsl.js';\n\nimport background_frag from './ShaderLib/background_frag.glsl.js';\nimport background_vert from './ShaderLib/background_vert.glsl.js';\nimport cube_frag from './ShaderLib/cube_frag.glsl.js';\nimport cube_vert from './ShaderLib/cube_vert.glsl.js';\nimport depth_frag from './ShaderLib/depth_frag.glsl.js';\nimport depth_vert from './ShaderLib/depth_vert.glsl.js';\nimport distanceRGBA_frag from './ShaderLib/distanceRGBA_frag.glsl.js';\nimport distanceRGBA_vert from './ShaderLib/distanceRGBA_vert.glsl.js';\nimport equirect_frag from './ShaderLib/equirect_frag.glsl.js';\nimport equirect_vert from './ShaderLib/equirect_vert.glsl.js';\nimport linedashed_frag from './ShaderLib/linedashed_frag.glsl.js';\nimport linedashed_vert from './ShaderLib/linedashed_vert.glsl.js';\nimport meshbasic_frag from './ShaderLib/meshbasic_frag.glsl.js';\nimport meshbasic_vert from './ShaderLib/meshbasic_vert.glsl.js';\nimport meshlambert_frag from './ShaderLib/meshlambert_frag.glsl.js';\nimport meshlambert_vert from './ShaderLib/meshlambert_vert.glsl.js';\nimport meshmatcap_frag from './ShaderLib/meshmatcap_frag.glsl.js';\nimport meshmatcap_vert from './ShaderLib/meshmatcap_vert.glsl.js';\nimport meshtoon_frag from './ShaderLib/meshtoon_frag.glsl.js';\nimport meshtoon_vert from './ShaderLib/meshtoon_vert.glsl.js';\nimport meshphong_frag from './ShaderLib/meshphong_frag.glsl.js';\nimport meshphong_vert from './ShaderLib/meshphong_vert.glsl.js';\nimport meshphysical_frag from './ShaderLib/meshphysical_frag.glsl.js';\nimport meshphysical_vert from './ShaderLib/meshphysical_vert.glsl.js';\nimport normal_frag from './ShaderLib/normal_frag.glsl.js';\nimport normal_vert from './ShaderLib/normal_vert.glsl.js';\nimport points_frag from './ShaderLib/points_frag.glsl.js';\nimport points_vert from './ShaderLib/points_vert.glsl.js';\nimport shadow_frag from './ShaderLib/shadow_frag.glsl.js';\nimport shadow_vert from './ShaderLib/shadow_vert.glsl.js';\nimport sprite_frag from './ShaderLib/sprite_frag.glsl.js';\nimport sprite_vert from './ShaderLib/sprite_vert.glsl.js';\n\nexport const ShaderChunk = {\n\talphamap_fragment: alphamap_fragment,\n\talphamap_pars_fragment: alphamap_pars_fragment,\n\talphatest_fragment: alphatest_fragment,\n\taomap_fragment: aomap_fragment,\n\taomap_pars_fragment: aomap_pars_fragment,\n\tbegin_vertex: begin_vertex,\n\tbeginnormal_vertex: beginnormal_vertex,\n\tbsdfs: bsdfs,\n\tbumpmap_pars_fragment: bumpmap_pars_fragment,\n\tclipping_planes_fragment: clipping_planes_fragment,\n\tclipping_planes_pars_fragment: clipping_planes_pars_fragment,\n\tclipping_planes_pars_vertex: clipping_planes_pars_vertex,\n\tclipping_planes_vertex: clipping_planes_vertex,\n\tcolor_fragment: color_fragment,\n\tcolor_pars_fragment: color_pars_fragment,\n\tcolor_pars_vertex: color_pars_vertex,\n\tcolor_vertex: color_vertex,\n\tcommon: common,\n\tcube_uv_reflection_fragment: cube_uv_reflection_fragment,\n\tdefaultnormal_vertex: defaultnormal_vertex,\n\tdisplacementmap_pars_vertex: displacementmap_pars_vertex,\n\tdisplacementmap_vertex: displacementmap_vertex,\n\temissivemap_fragment: emissivemap_fragment,\n\temissivemap_pars_fragment: emissivemap_pars_fragment,\n\tencodings_fragment: encodings_fragment,\n\tencodings_pars_fragment: encodings_pars_fragment,\n\tenvmap_fragment: envmap_fragment,\n\tenvmap_common_pars_fragment: envmap_common_pars_fragment,\n\tenvmap_pars_fragment: envmap_pars_fragment,\n\tenvmap_pars_vertex: envmap_pars_vertex,\n\tenvmap_physical_pars_fragment: envmap_physical_pars_fragment,\n\tenvmap_vertex: envmap_vertex,\n\tfog_vertex: fog_vertex,\n\tfog_pars_vertex: fog_pars_vertex,\n\tfog_fragment: fog_fragment,\n\tfog_pars_fragment: fog_pars_fragment,\n\tgradientmap_pars_fragment: gradientmap_pars_fragment,\n\tlightmap_fragment: lightmap_fragment,\n\tlightmap_pars_fragment: lightmap_pars_fragment,\n\tlights_lambert_vertex: lights_lambert_vertex,\n\tlights_pars_begin: lights_pars_begin,\n\tlights_toon_fragment: lights_toon_fragment,\n\tlights_toon_pars_fragment: lights_toon_pars_fragment,\n\tlights_phong_fragment: lights_phong_fragment,\n\tlights_phong_pars_fragment: lights_phong_pars_fragment,\n\tlights_physical_fragment: lights_physical_fragment,\n\tlights_physical_pars_fragment: lights_physical_pars_fragment,\n\tlights_fragment_begin: lights_fragment_begin,\n\tlights_fragment_maps: lights_fragment_maps,\n\tlights_fragment_end: lights_fragment_end,\n\tlogdepthbuf_fragment: logdepthbuf_fragment,\n\tlogdepthbuf_pars_fragment: logdepthbuf_pars_fragment,\n\tlogdepthbuf_pars_vertex: logdepthbuf_pars_vertex,\n\tlogdepthbuf_vertex: logdepthbuf_vertex,\n\tmap_fragment: map_fragment,\n\tmap_pars_fragment: map_pars_fragment,\n\tmap_particle_fragment: map_particle_fragment,\n\tmap_particle_pars_fragment: map_particle_pars_fragment,\n\tmetalnessmap_fragment: metalnessmap_fragment,\n\tmetalnessmap_pars_fragment: metalnessmap_pars_fragment,\n\tmorphnormal_vertex: morphnormal_vertex,\n\tmorphtarget_pars_vertex: morphtarget_pars_vertex,\n\tmorphtarget_vertex: morphtarget_vertex,\n\tnormal_fragment_begin: normal_fragment_begin,\n\tnormal_fragment_maps: normal_fragment_maps,\n\tnormalmap_pars_fragment: normalmap_pars_fragment,\n\tclearcoat_normal_fragment_begin: clearcoat_normal_fragment_begin,\n\tclearcoat_normal_fragment_maps: clearcoat_normal_fragment_maps,\n\tclearcoat_pars_fragment: clearcoat_pars_fragment,\n\tpacking: packing,\n\tpremultiplied_alpha_fragment: premultiplied_alpha_fragment,\n\tproject_vertex: project_vertex,\n\tdithering_fragment: dithering_fragment,\n\tdithering_pars_fragment: dithering_pars_fragment,\n\troughnessmap_fragment: roughnessmap_fragment,\n\troughnessmap_pars_fragment: roughnessmap_pars_fragment,\n\tshadowmap_pars_fragment: shadowmap_pars_fragment,\n\tshadowmap_pars_vertex: shadowmap_pars_vertex,\n\tshadowmap_vertex: shadowmap_vertex,\n\tshadowmask_pars_fragment: shadowmask_pars_fragment,\n\tskinbase_vertex: skinbase_vertex,\n\tskinning_pars_vertex: skinning_pars_vertex,\n\tskinning_vertex: skinning_vertex,\n\tskinnormal_vertex: skinnormal_vertex,\n\tspecularmap_fragment: specularmap_fragment,\n\tspecularmap_pars_fragment: specularmap_pars_fragment,\n\ttonemapping_fragment: tonemapping_fragment,\n\ttonemapping_pars_fragment: tonemapping_pars_fragment,\n\tuv_pars_fragment: uv_pars_fragment,\n\tuv_pars_vertex: uv_pars_vertex,\n\tuv_vertex: uv_vertex,\n\tuv2_pars_fragment: uv2_pars_fragment,\n\tuv2_pars_vertex: uv2_pars_vertex,\n\tuv2_vertex: uv2_vertex,\n\tworldpos_vertex: worldpos_vertex,\n\n\tbackground_frag: background_frag,\n\tbackground_vert: background_vert,\n\tcube_frag: cube_frag,\n\tcube_vert: cube_vert,\n\tdepth_frag: depth_frag,\n\tdepth_vert: depth_vert,\n\tdistanceRGBA_frag: distanceRGBA_frag,\n\tdistanceRGBA_vert: distanceRGBA_vert,\n\tequirect_frag: equirect_frag,\n\tequirect_vert: equirect_vert,\n\tlinedashed_frag: linedashed_frag,\n\tlinedashed_vert: linedashed_vert,\n\tmeshbasic_frag: meshbasic_frag,\n\tmeshbasic_vert: meshbasic_vert,\n\tmeshlambert_frag: meshlambert_frag,\n\tmeshlambert_vert: meshlambert_vert,\n\tmeshmatcap_frag: meshmatcap_frag,\n\tmeshmatcap_vert: meshmatcap_vert,\n\tmeshtoon_frag: meshtoon_frag,\n\tmeshtoon_vert: meshtoon_vert,\n\tmeshphong_frag: meshphong_frag,\n\tmeshphong_vert: meshphong_vert,\n\tmeshphysical_frag: meshphysical_frag,\n\tmeshphysical_vert: meshphysical_vert,\n\tnormal_frag: normal_frag,\n\tnormal_vert: normal_vert,\n\tpoints_frag: points_frag,\n\tpoints_vert: points_vert,\n\tshadow_frag: shadow_frag,\n\tshadow_vert: shadow_vert,\n\tsprite_frag: sprite_frag,\n\tsprite_vert: sprite_vert\n};\n","export default /* glsl */`\n#ifdef USE_ALPHAMAP\n\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_ALPHAMAP\n\n\tuniform sampler2D alphaMap;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef ALPHATEST\n\n\tif ( diffuseColor.a < ALPHATEST ) discard;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_AOMAP\n\n\t// reads channel R, compatible with a combined OcclusionRoughnessMetallic (RGB) texture\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_AOMAP\n\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n\n#endif\n`;\n","export default /* glsl */`\nvec3 transformed = vec3( position );\n`;\n","export default /* glsl */`\nvec3 objectNormal = vec3( normal );\n\n#ifdef USE_TANGENT\n\n\tvec3 objectTangent = vec3( tangent.xyz );\n\n#endif\n`;\n","export default /* glsl */`\n\n// Analytical approximation of the DFG LUT, one half of the\n// split-sum approximation used in indirect specular lighting.\n// via 'environmentBRDF' from \"Physically Based Shading on Mobile\"\n// https://www.unrealengine.com/blog/physically-based-shading-on-mobile - environmentBRDF for GGX on mobile\nvec2 integrateSpecularBRDF( const in float dotNV, const in float roughness ) {\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\n\tvec4 r = roughness * c0 + c1;\n\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\n\treturn vec2( -1.04, 1.04 ) * a004 + r.zw;\n\n}\n\nfloat punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\n\t// based upon Frostbite 3 Moving to Physically-based Rendering\n\t// page 32, equation 26: E[window1]\n\t// https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf\n\t// this is intended to be used on spot and point lights who are represented as luminous intensity\n\t// but who must be converted to luminous irradiance for surface lighting calculation\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\n\tif( cutoffDistance > 0.0 ) {\n\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\n\t}\n\n\treturn distanceFalloff;\n\n#else\n\n\tif( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\n\t}\n\n\treturn 1.0;\n\n#endif\n\n}\n\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\n\treturn RECIPROCAL_PI * diffuseColor;\n\n} // validated\n\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\n\t// Original approximation by Christophe Schlick '94\n\t// float fresnel = pow( 1.0 - dotLH, 5.0 );\n\n\t// Optimized variant (presented by Epic at SIGGRAPH '13)\n\t// https://cdn2.unrealengine.com/Resources/files/2013SiggraphPresentationsNotes-26915738.pdf\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n\n} // validated\n\nvec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {\n\n\t// See F_Schlick\n\tfloat fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );\n\tvec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;\n\n\treturn Fr * fresnel + F0;\n\n}\n\n\n// Microfacet Models for Refraction through Rough Surfaces - equation (34)\n// http://graphicrants.blogspot.com/2013/08/specular-brdf-reference.html\n// alpha is \"roughness squared\" in Disney’s reparameterization\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\n\t// geometry term (normalized) = G(l)⋅G(v) / 4(n⋅l)(n⋅v)\n\t// also see #12151\n\n\tfloat a2 = pow2( alpha );\n\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\n\treturn 1.0 / ( gl * gv );\n\n} // validated\n\n// Moving Frostbite to Physically Based Rendering 3.0 - page 12, listing 2\n// https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\n\tfloat a2 = pow2( alpha );\n\n\t// dotNL and dotNV are explicitly swapped. This is not a mistake.\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\n\treturn 0.5 / max( gv + gl, EPSILON );\n\n}\n\n// Microfacet Models for Refraction through Rough Surfaces - equation (33)\n// http://graphicrants.blogspot.com/2013/08/specular-brdf-reference.html\n// alpha is \"roughness squared\" in Disney’s reparameterization\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\n\tfloat a2 = pow2( alpha );\n\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; // avoid alpha = 0 with dotNH = 1\n\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n\n}\n\n// GGX Distribution, Schlick Fresnel, GGX-Smith Visibility\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\n\tfloat alpha = pow2( roughness ); // UE4's roughness\n\n\tvec3 halfDir = normalize( incidentLight.direction + viewDir );\n\n\tfloat dotNL = saturate( dot( normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\n\tfloat D = D_GGX( alpha, dotNH );\n\n\treturn F * ( G * D );\n\n} // validated\n\n// Rect Area Light\n\n// Real-Time Polygonal-Light Shading with Linearly Transformed Cosines\n// by Eric Heitz, Jonathan Dupuy, Stephen Hill and David Neubelt\n// code: https://github.com/selfshadow/ltc_code/\n\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\n\tfloat dotNV = saturate( dot( N, V ) );\n\n\t// texture parameterized by sqrt( GGX alpha ) and sqrt( 1 - cos( theta ) )\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\n\treturn uv;\n\n}\n\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\n\t// Real-Time Area Lighting: a Journey from Research to Production (p.102)\n\t// An approximation of the form factor of a horizon-clipped rectangle.\n\n\tfloat l = length( f );\n\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n\n}\n\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\n\tfloat x = dot( v1, v2 );\n\n\tfloat y = abs( x );\n\n\t// rational polynomial approximation to theta / sin( theta ) / 2PI\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\n\treturn cross( v1, v2 ) * theta_sintheta;\n\n}\n\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\n\t// bail if point is on back side of plane of light\n\t// assumes ccw winding order of light vertices\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\n\t// construct orthonormal basis around N\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 ); // negated from paper; possibly due to a different handedness of world coordinate system\n\n\t// compute transform\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\n\t// transform rect\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\n\t// project rect onto sphere\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\n\t// calculate vector form factor\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\n\t// adjust for horizon clipping\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\n/*\n\t// alternate method of adjusting for horizon clipping (see referece)\n\t// refactoring required\n\tfloat len = length( vectorFormFactor );\n\tfloat z = vectorFormFactor.z / len;\n\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\n\t// tabulated horizon-clipped sphere, apparently...\n\tvec2 uv = vec2( z * 0.5 + 0.5, len );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\n\tfloat scale = texture2D( ltc_2, uv ).w;\n\n\tfloat result = len * scale;\n*/\n\n\treturn vec3( result );\n\n}\n\n// End Rect Area Light\n\n// ref: https://www.unrealengine.com/blog/physically-based-shading-on-mobile - environmentBRDF for GGX on mobile\nvec3 BRDF_Specular_GGX_Environment( const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\n\treturn specularColor * brdf.x + brdf.y;\n\n} // validated\n\n// Fdez-Agüera's \"Multiple-Scattering Microfacet Model for Real-Time Image Based Lighting\"\n// Approximates multiscattering in order to preserve energy.\n// http://www.jcgt.org/published/0008/01/03/\nvoid BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\n\tvec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\tvec3 FssEss = F * brdf.x + brdf.y;\n\n\tfloat Ess = brdf.x + brdf.y;\n\tfloat Ems = 1.0 - Ess;\n\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619; // 1/21\n\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n\n}\n\nfloat G_BlinnPhong_Implicit( /* const in float dotNL, const in float dotNV */ ) {\n\n\t// geometry term is (n dot l)(n dot v) / 4(n dot l)(n dot v)\n\treturn 0.25;\n\n}\n\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n\n}\n\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\n\t//float dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\n\t//float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\n\tfloat G = G_BlinnPhong_Implicit( /* dotNL, dotNV */ );\n\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\n\treturn F * ( G * D );\n\n} // validated\n\n// source: http://simonstechblog.blogspot.ca/2011/12/microfacet-brdf.html\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\n\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n\n#if defined( USE_SHEEN )\n\n// https://github.com/google/filament/blob/master/shaders/src/brdf.fs#L94\nfloat D_Charlie(float roughness, float NoH) {\n\t// Estevez and Kulla 2017, \"Production Friendly Microfacet Sheen BRDF\"\n\tfloat invAlpha = 1.0 / roughness;\n\tfloat cos2h = NoH * NoH;\n\tfloat sin2h = max(1.0 - cos2h, 0.0078125); // 2^(-14/2), so sin2h^2 > 0 in fp16\n\treturn (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);\n}\n\n// https://github.com/google/filament/blob/master/shaders/src/brdf.fs#L136\nfloat V_Neubelt(float NoV, float NoL) {\n\t// Neubelt and Pettineo 2013, \"Crafting a Next-gen Material Pipeline for The Order: 1886\"\n\treturn saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));\n}\n\nvec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {\n\n\tvec3 N = geometry.normal;\n\tvec3 V = geometry.viewDir;\n\n\tvec3 H = normalize( V + L );\n\tfloat dotNH = saturate( dot( N, H ) );\n\n\treturn specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );\n\n}\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_BUMPMAP\n\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\n\t// Bump Mapping Unparametrized Surfaces on the GPU by Morten S. Mikkelsen\n\t// http://api.unrealengine.com/attachments/Engine/Rendering/LightingAndShadows/BumpMappingWithoutTangentSpace/mm_sfgrad_bump.pdf\n\n\t// Evaluate the derivative of the height w.r.t. screen-space using forward differencing (listing 2)\n\n\tvec2 dHdxy_fwd() {\n\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\n\t\treturn vec2( dBx, dBy );\n\n\t}\n\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\n\t\t// Workaround for Adreno 3XX dFd*( vec3 ) bug. See #9988\n\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\t\t// normalized\n\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\n\t\tfDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\n\t}\n\n#endif\n`;\n","export default /* glsl */`\n#if NUM_CLIPPING_PLANES > 0\n\n\tvec4 plane;\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\n\t}\n\t#pragma unroll_loop_end\n\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\n\t\tbool clipped = true;\n\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\n\t\t}\n\t\t#pragma unroll_loop_end\n\n\t\tif ( clipped ) discard;\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n#if NUM_CLIPPING_PLANES > 0\n\n\tvarying vec3 vClipPosition;\n\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n\n#endif\n`;\n","export default /* glsl */`\n#if NUM_CLIPPING_PLANES > 0\n\n\tvarying vec3 vClipPosition;\n\n#endif\n`;\n","export default /* glsl */`\n#if NUM_CLIPPING_PLANES > 0\n\n\tvClipPosition = - mvPosition.xyz;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_COLOR\n\n\tdiffuseColor.rgb *= vColor;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_COLOR\n\n\tvarying vec3 vColor;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_COLOR\n\n\tvarying vec3 vColor;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_COLOR\n\n\tvColor.xyz = color.xyz;\n\n#endif\n`;\n","export default /* glsl */`\n#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n\n#ifndef saturate\n// may have defined saturate() already\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement(a) ( 1.0 - saturate( a ) )\n\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\n// expects values in the range of [0,1]x[0,1], returns values in the [0,1] range.\n// do not collapse into a single function per: http://byteblacksmith.com/improvements-to-the-canonical-one-liner-glsl-rand-for-opengl-es-2-0/\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\n\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat max3( vec3 v ) { return max( max( v.x, v.y ), v.z ); }\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\n\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\n\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\n\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\n\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n}\n\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t// dir can be either a direction vector or a normal vector\n\t// upper-left 3x3 of matrix is assumed to be orthogonal\n\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n\n}\n\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\n\treturn - distance * planeNormal + point;\n\n}\n\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n\n}\n\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n\n}\n\nmat3 transposeMat3( const in mat3 m ) {\n\n\tmat3 tmp;\n\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\n\treturn tmp;\n\n}\n\n// https://en.wikipedia.org/wiki/Relative_luminance\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\n\treturn dot( weights, color.rgb );\n\n}\n\nbool isPerspectiveMatrix( mat4 m ) {\n\n return m[ 2 ][ 3 ] == - 1.0;\n\n}\n\nvec2 equirectUv( in vec3 dir ) {\n\n\t// dir is assumed to be unit length\n\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\n\treturn vec2( u, v );\n\n}\n`;\n","export default /* glsl */`\n#ifdef ENVMAP_TYPE_CUBE_UV\n\n#define cubeUV_maxMipLevel 8.0\n#define cubeUV_minMipLevel 4.0\n#define cubeUV_maxTileSize 256.0\n#define cubeUV_minTileSize 16.0\n\n// These shader functions convert between the UV coordinates of a single face of\n// a cubemap, the 0-5 integer index of a cube face, and the direction vector for\n// sampling a textureCube (not generally normalized).\n\nfloat getFace(vec3 direction) {\n vec3 absDirection = abs(direction);\n float face = -1.0;\n if (absDirection.x > absDirection.z) {\n if (absDirection.x > absDirection.y)\n face = direction.x > 0.0 ? 0.0 : 3.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n } else {\n if (absDirection.z > absDirection.y)\n face = direction.z > 0.0 ? 2.0 : 5.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n }\n return face;\n}\n\n// RH coordinate system; PMREM face-indexing convention\nvec2 getUV(vec3 direction, float face) {\n vec2 uv;\n if (face == 0.0) {\n uv = vec2(direction.z, direction.y) / abs(direction.x); // pos x\n } else if (face == 1.0) {\n uv = vec2(-direction.x, -direction.z) / abs(direction.y); // pos y\n } else if (face == 2.0) {\n uv = vec2(-direction.x, direction.y) / abs(direction.z); // pos z\n } else if (face == 3.0) {\n uv = vec2(-direction.z, direction.y) / abs(direction.x); // neg x\n } else if (face == 4.0) {\n uv = vec2(-direction.x, direction.z) / abs(direction.y); // neg y\n } else {\n uv = vec2(direction.x, direction.y) / abs(direction.z); // neg z\n }\n return 0.5 * (uv + 1.0);\n}\n\nvec3 bilinearCubeUV(sampler2D envMap, vec3 direction, float mipInt) {\n float face = getFace(direction);\n float filterInt = max(cubeUV_minMipLevel - mipInt, 0.0);\n mipInt = max(mipInt, cubeUV_minMipLevel);\n float faceSize = exp2(mipInt);\n\n float texelSize = 1.0 / (3.0 * cubeUV_maxTileSize);\n\n vec2 uv = getUV(direction, face) * (faceSize - 1.0);\n vec2 f = fract(uv);\n uv += 0.5 - f;\n if (face > 2.0) {\n uv.y += faceSize;\n face -= 3.0;\n }\n uv.x += face * faceSize;\n if(mipInt < cubeUV_maxMipLevel){\n uv.y += 2.0 * cubeUV_maxTileSize;\n }\n uv.y += filterInt * 2.0 * cubeUV_minTileSize;\n uv.x += 3.0 * max(0.0, cubeUV_maxTileSize - 2.0 * faceSize);\n uv *= texelSize;\n\n vec3 tl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.x += texelSize;\n vec3 tr = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.y += texelSize;\n vec3 br = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.x -= texelSize;\n vec3 bl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n vec3 tm = mix(tl, tr, f.x);\n vec3 bm = mix(bl, br, f.x);\n return mix(tm, bm, f.y);\n}\n\n// These defines must match with PMREMGenerator\n\n#define r0 1.0\n#define v0 0.339\n#define m0 -2.0\n#define r1 0.8\n#define v1 0.276\n#define m1 -1.0\n#define r4 0.4\n#define v4 0.046\n#define m4 2.0\n#define r5 0.305\n#define v5 0.016\n#define m5 3.0\n#define r6 0.21\n#define v6 0.0038\n#define m6 4.0\n\nfloat roughnessToMip(float roughness) {\n float mip = 0.0;\n if (roughness >= r1) {\n mip = (r0 - roughness) * (m1 - m0) / (r0 - r1) + m0;\n } else if (roughness >= r4) {\n mip = (r1 - roughness) * (m4 - m1) / (r1 - r4) + m1;\n } else if (roughness >= r5) {\n mip = (r4 - roughness) * (m5 - m4) / (r4 - r5) + m4;\n } else if (roughness >= r6) {\n mip = (r5 - roughness) * (m6 - m5) / (r5 - r6) + m5;\n } else {\n mip = -2.0 * log2(1.16 * roughness);// 1.16 = 1.79^0.25\n }\n return mip;\n}\n\nvec4 textureCubeUV(sampler2D envMap, vec3 sampleDir, float roughness) {\n float mip = clamp(roughnessToMip(roughness), m0, cubeUV_maxMipLevel);\n float mipF = fract(mip);\n float mipInt = floor(mip);\n\n vec3 color0 = bilinearCubeUV(envMap, sampleDir, mipInt);\n if (mipF == 0.0) {\n return vec4(color0, 1.0);\n } else {\n vec3 color1 = bilinearCubeUV(envMap, sampleDir, mipInt + 1.0);\n return vec4(mix(color0, color1, mipF), 1.0);\n }\n}\n#endif\n`;\n","export default /* glsl */`\nvec3 transformedNormal = objectNormal;\n\n#ifdef USE_INSTANCING\n\n\t// this is in lieu of a per-instance normal-matrix\n\t// shear transforms in the instance matrix are not supported\n\n\tmat3 m = mat3( instanceMatrix );\n\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\n\ttransformedNormal = m * transformedNormal;\n\n#endif\n\ntransformedNormal = normalMatrix * transformedNormal;\n\n#ifdef FLIP_SIDED\n\n\ttransformedNormal = - transformedNormal;\n\n#endif\n\n#ifdef USE_TANGENT\n\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\n\t#ifdef FLIP_SIDED\n\n\t\ttransformedTangent = - transformedTangent;\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_DISPLACEMENTMAP\n\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_DISPLACEMENTMAP\n\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_EMISSIVEMAP\n\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_EMISSIVEMAP\n\n\tuniform sampler2D emissiveMap;\n\n#endif\n`;\n","export default /* glsl */`\ngl_FragColor = linearToOutputTexel( gl_FragColor );\n`;\n","export default /* glsl */`\n// For a discussion of what this is, please read this: http://lousodrome.net/blog/light/2013/05/26/gamma-correct-and-hdr-rendering-in-a-32-bits-buffer/\n\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\n\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\n\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\n\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\n\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\n\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\n\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n// return vec4( value.brg, ( 3.0 + 128.0 ) / 256.0 );\n}\n\n// reference: http://iwasbeingirony.blogspot.ca/2010/06/difference-between-rgbm-and-rgbd.html\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\n\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\n\n// reference: http://iwasbeingirony.blogspot.ca/2010/06/difference-between-rgbm-and-rgbd.html\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\n\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\t// NOTE: The implementation with min causes the shader to not compile on\n\t// a common Alcatel A502DL in Chrome 78/Android 8.1. Some research suggests \n\t// that the chipset is Mediatek MT6739 w/ IMG PowerVR GE8100 GPU.\n\t// D = min( floor( D ) / 255.0, 1.0 );\n\tD = clamp( floor( D ) / 255.0, 0.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\n\n// LogLuv reference: http://graphicrants.blogspot.ca/2009/04/rgbm-color-encoding.html\n\n// M matrix, for encoding\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = cLogLuvM * value.rgb;\n\tXp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract( Le );\n\tvResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n\treturn vResult;\n}\n\n// Inverse M matrix, for decoding\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}\n`;\n","export default /* glsl */`\n#ifdef USE_ENVMAP\n\n\t#ifdef ENV_WORLDPOS\n\n\t\tvec3 cameraToFrag;\n\t\t\n\t\tif ( isOrthographic ) {\n\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\n\t\t} else {\n\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\n\t\t}\n\n\t\t// Transforming Normal Vectors with the Inverse Transformation\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\n\t\t#else\n\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\n\t\t#endif\n\n\t#else\n\n\t\tvec3 reflectVec = vReflect;\n\n\t#endif\n\n\t#ifdef ENVMAP_TYPE_CUBE\n\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\n\t\tvec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );\n\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\n\t\treflectVec = normalize( reflectVec );\n\n\t\tvec2 sampleUV = equirectUv( reflectVec );\n\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\n\t#else\n\n\t\tvec4 envColor = vec4( 0.0 );\n\n\t#endif\n\n\t#ifndef ENVMAP_TYPE_CUBE_UV\n\n\t\tenvColor = envMapTexelToLinear( envColor );\n\n\t#endif\n\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_ENVMAP\n\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_ENVMAP\n\n\tuniform float reflectivity;\n\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\n\t\t#define ENV_WORLDPOS\n\n\t#endif\n\n\t#ifdef ENV_WORLDPOS\n\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_ENVMAP\n\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )\n\n\t\t#define ENV_WORLDPOS\n\n\t#endif\n\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\n\t#else\n\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n#if defined( USE_ENVMAP )\n\n\t#ifdef ENVMAP_MODE_REFRACTION\n\t\tuniform float refractionRatio;\n\t#endif\n\n\tvec3 getLightProbeIndirectIrradiance( /*const in SpecularLightProbe specularLightProbe,*/ const in GeometricContext geometry, const in int maxMIPLevel ) {\n\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\n\t\t\t// TODO: replace with properly filtered cubemaps and access the irradiance LOD level, be it the last LOD level\n\t\t\t// of a specular cubemap, or just the default level of a specially created irradiance cubemap.\n\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\n\t\t\t#else\n\n\t\t\t\t// force the bias high to get the last LOD level as it is the most blurred.\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\n\t\t\t#endif\n\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\n\t\t#else\n\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\n\t\t#endif\n\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\n\t}\n\n\t// Trowbridge-Reitz distribution to Mip level, following the logic of http://casual-effects.blogspot.ca/2011/08/plausible-environment-lighting-in-two.html\n\tfloat getSpecularMIPLevel( const in float roughness, const in int maxMIPLevel ) {\n\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\n\t\tfloat sigma = PI * roughness * roughness / ( 1.0 + roughness );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + log2( sigma );\n\n\t\t// clamp to allowable LOD ranges.\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\n\t}\n\n\tvec3 getLightProbeIndirectRadiance( /*const in SpecularLightProbe specularLightProbe,*/ const in vec3 viewDir, const in vec3 normal, const in float roughness, const in int maxMIPLevel ) {\n\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\n\t\t vec3 reflectVec = reflect( -viewDir, normal );\n\n\t\t // Mixing the reflection with the normal is more accurate and keeps rough objects from gathering light from behind their tangent plane.\n\t\t reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\n\t\t#else\n\n\t\t vec3 reflectVec = refract( -viewDir, normal, refractionRatio );\n\n\t\t#endif\n\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( roughness, maxMIPLevel );\n\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\n\t\t\t#else\n\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\n\t\t\t#endif\n\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\n\t\t\tvec2 sampleUV = equirectUv( reflectVec );\n\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\n\t\t\t#else\n\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\n\t\t\t#endif\n\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\n\t\t#endif\n\n\t\treturn envMapColor.rgb * envMapIntensity;\n\n\t}\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_ENVMAP\n\n\t#ifdef ENV_WORLDPOS\n\n\t\tvWorldPosition = worldPosition.xyz;\n\n\t#else\n\n\t\tvec3 cameraToVertex;\n\n\t\tif ( isOrthographic ) { \n\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\n\t\t} else {\n\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\n\t\t}\n\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\n\t\t#else\n\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\n\t\t#endif\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_FOG\n\n\tfogDepth = -mvPosition.z;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_FOG\n\n\tvarying float fogDepth;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_FOG\n\n\t#ifdef FOG_EXP2\n\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );\n\n\t#else\n\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\n\t#endif\n\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_FOG\n\n\tuniform vec3 fogColor;\n\tvarying float fogDepth;\n\n\t#ifdef FOG_EXP2\n\n\t\tuniform float fogDensity;\n\n\t#else\n\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n\n#ifdef USE_GRADIENTMAP\n\n\tuniform sampler2D gradientMap;\n\n#endif\n\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\n\t// dotNL will be from -1.0 to 1.0\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\n\t#ifdef USE_GRADIENTMAP\n\n\t\treturn texture2D( gradientMap, coord ).rgb;\n\n\t#else\n\n\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\n\t#endif\n\n}\n\n`;\n","export default /* glsl */`\n#ifdef USE_LIGHTMAP\n\n\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\treflectedLight.indirectDiffuse += PI * lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity; // factor of PI should not be present; included here to prevent breakage\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_LIGHTMAP\n\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n\n#endif\n`;\n","export default /* glsl */`\nvec3 diffuse = vec3( 1.0 );\n\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\n\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\n\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n\tvIndirectBack = vec3( 0.0 );\n#endif\n\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n\nvIndirectFront += getAmbientLightIrradiance( ambientLightColor );\n\nvIndirectFront += getLightProbeIrradiance( lightProbe, geometry );\n\n#ifdef DOUBLE_SIDED\n\n\tvIndirectBack += getAmbientLightIrradiance( ambientLightColor );\n\n\tvIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry );\n\n#endif\n\n#if NUM_POINT_LIGHTS > 0\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\n\t\t#ifdef DOUBLE_SIDED\n\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\n\t\t#endif\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if NUM_SPOT_LIGHTS > 0\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\n\t\t#ifdef DOUBLE_SIDED\n\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n/*\n#if NUM_RECT_AREA_LIGHTS > 0\n\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\n\t\t// TODO (abelnation): implement\n\n\t}\n\n#endif\n*/\n\n#if NUM_DIR_LIGHTS > 0\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\n\t\t#ifdef DOUBLE_SIDED\n\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\n\t\t#endif\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if NUM_HEMI_LIGHTS > 0\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\n\t\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\n\t\t#ifdef DOUBLE_SIDED\n\n\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\n\t\t#endif\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n`;\n","export default /* glsl */`\nuniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\n\n// get the irradiance (radiance convolved with cosine lobe) at the point 'normal' on the unit sphere\n// source: https://graphics.stanford.edu/papers/envmap/envmap.pdf\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\n\t// normal is assumed to have unit length\n\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\n\t// band 0\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\n\t// band 1\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\n\t// band 2\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\n\treturn result;\n\n}\n\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in GeometricContext geometry ) {\n\n\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\n\treturn irradiance;\n\n}\n\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\n\tvec3 irradiance = ambientLightColor;\n\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\n\t\tirradiance *= PI;\n\n\t#endif\n\n\treturn irradiance;\n\n}\n\n#if NUM_DIR_LIGHTS > 0\n\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\n\t}\n\n#endif\n\n\n#if NUM_POINT_LIGHTS > 0\n\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\n\t// directLight is an out parameter as having it as a return value caused compiler errors on some devices\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\n\t\tfloat lightDistance = length( lVector );\n\n\t\tdirectLight.color = pointLight.color;\n\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\tdirectLight.visible = ( directLight.color != vec3( 0.0 ) );\n\n\t}\n\n#endif\n\n\n#if NUM_SPOT_LIGHTS > 0\n\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\n\t// directLight is an out parameter as having it as a return value caused compiler errors on some devices\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\n\t\tif ( angleCos > spotLight.coneCos ) {\n\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\n\t\t} else {\n\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\n\t\t}\n\t}\n\n#endif\n\n\n#if NUM_RECT_AREA_LIGHTS > 0\n\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\n\t// Pre-computed values of LinearTransformedCosine approximation of BRDF\n\t// BRDF approximation Texture is 64x64\n\tuniform sampler2D ltc_1; // RGBA Float\n\tuniform sampler2D ltc_2; // RGBA Float\n\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n\n#endif\n\n\n#if NUM_HEMI_LIGHTS > 0\n\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\n\t\t\tirradiance *= PI;\n\n\t\t#endif\n\n\t\treturn irradiance;\n\n\t}\n\n#endif\n`;\n","export default /* glsl */`\nToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\n`;\n","export default /* glsl */`\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n#endif\n\n\nstruct ToonMaterial {\n\n\tvec3\tdiffuseColor;\n\n};\n\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\n\t\tirradiance *= PI; // punctual light\n\n\t#endif\n\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\n}\n\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\n}\n\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon\n\n#define Material_LightProbeLOD( material )\t(0)\n`;\n","export default /* glsl */`\nBlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;\n`;\n","export default /* glsl */`\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n#endif\n\n\nstruct BlinnPhongMaterial {\n\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n\n};\n\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\n\t\tirradiance *= PI; // punctual light\n\n\t#endif\n\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n\n}\n\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\n}\n\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n\n#define Material_LightProbeLOD( material )\t(0)\n`;\n","export default /* glsl */`\nPhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\n\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\n\nmaterial.specularRoughness = max( roughnessFactor, 0.0525 );// 0.0525 corresponds to the base mip of a 256 cubemap.\nmaterial.specularRoughness += geometryRoughness;\nmaterial.specularRoughness = min( material.specularRoughness, 1.0 );\n\n#ifdef REFLECTIVITY\n\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n\n#else\n\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n\n#endif\n\n#ifdef CLEARCOAT\n\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\n\t#ifdef USE_CLEARCOATMAP\n\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vUv ).x;\n\n\t#endif\n\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;\n\n\t#endif\n\n\tmaterial.clearcoat = saturate( material.clearcoat ); // Burley clearcoat model\n\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n\n#endif\n\n#ifdef USE_SHEEN\n\n\tmaterial.sheenColor = sheen;\n\n#endif\n`;\n","export default /* glsl */`\nstruct PhysicalMaterial {\n\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n\n#ifdef CLEARCOAT\n\tfloat clearcoat;\n\tfloat clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tvec3 sheenColor;\n#endif\n\n};\n\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\n\n// Clear coat directional hemishperical reflectance (this approximation should be improved)\nfloat clearcoatDHRApprox( const in float roughness, const in float dotNL ) {\n\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n\n}\n\n#if NUM_RECT_AREA_LIGHTS > 0\n\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight; // counterclockwise; light shines in local neg z direction\n\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\n\t\t// LTC Fresnel Approximation by Stephen Hill\n\t\t// http://blog.selfshadow.com/publications/s2016-advances/s2016_ltc_fresnel.pdf\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\n\t}\n\n#endif\n\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\n\tvec3 irradiance = dotNL * directLight.color;\n\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\n\t\tirradiance *= PI; // punctual light\n\n\t#endif\n\n\t#ifdef CLEARCOAT\n\n\t\tfloat ccDotNL = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\n\t\tvec3 ccIrradiance = ccDotNL * directLight.color;\n\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\n\t\t\tccIrradiance *= PI; // punctual light\n\n\t\t#endif\n\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\n\t\treflectedLight.directSpecular += ccIrradiance * material.clearcoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\n\t#else\n\n\t\tfloat clearcoatDHR = 0.0;\n\n\t#endif\n\n\t#ifdef USE_SHEEN\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_Sheen(\n\t\t\tmaterial.specularRoughness,\n\t\t\tdirectLight.direction,\n\t\t\tgeometry,\n\t\t\tmaterial.sheenColor\n\t\t);\n\t#else\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness);\n\t#endif\n\n\treflectedLight.directDiffuse += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\n}\n\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\n\t#ifdef CLEARCOAT\n\n\t\tfloat ccDotNV = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\n\t\treflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\n\t\tfloat ccDotNL = ccDotNV;\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\n\t#else\n\n\t\tfloat clearcoatDHR = 0.0;\n\n\t#endif\n\n\tfloat clearcoatInv = 1.0 - clearcoatDHR;\n\n\t// Both indirect specular and indirect diffuse light accumulate here\n\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\n\tBRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );\n\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\n\treflectedLight.indirectSpecular += clearcoatInv * radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n\n}\n\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\n\n// ref: https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n\n}\n`;\n","export default /* glsl */`\n/**\n * This is a template that can be used to light a material, it uses pluggable\n * RenderEquations (RE)for specific lighting scenarios.\n *\n * Instructions for use:\n * - Ensure that both RE_Direct, RE_IndirectDiffuse and RE_IndirectSpecular are defined\n * - If you have defined an RE_IndirectSpecular, you need to also provide a Material_LightProbeLOD. <---- ???\n * - Create a material parameter that is to be passed as the third parameter to your lighting functions.\n *\n * TODO:\n * - Add area light support.\n * - Add sphere light support.\n * - Add diffuse light probe (irradiance cubemap) support.\n */\n\nGeometricContext geometry;\n\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n\n#ifdef CLEARCOAT\n\n\tgeometry.clearcoatNormal = clearcoatNormal;\n\n#endif\n\nIncidentLight directLight;\n\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\n\t\tpointLight = pointLights[ i ];\n\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\n\tSpotLight spotLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\n\t\tspotLight = spotLights[ i ];\n\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\n\t\tdirectionalLight = directionalLights[ i ];\n\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\n\tRectAreaLight rectAreaLight;\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if defined( RE_IndirectDiffuse )\n\n\tvec3 iblIrradiance = vec3( 0.0 );\n\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry );\n\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\n\t\t}\n\t\t#pragma unroll_loop_end\n\n\t#endif\n\n#endif\n\n#if defined( RE_IndirectSpecular )\n\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n\n#endif\n`;\n","export default /* glsl */`\n#if defined( RE_IndirectDiffuse )\n\n\t#ifdef USE_LIGHTMAP\n\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\tvec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\n\t\t\tlightMapIrradiance *= PI; // factor of PI should not be present; included here to prevent breakage\n\n\t\t#endif\n\n\t\tirradiance += lightMapIrradiance;\n\n\t#endif\n\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\n\t\tiblIrradiance += getLightProbeIndirectIrradiance( /*lightProbe,*/ geometry, maxMipLevel );\n\n\t#endif\n\n#endif\n\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\n\tradiance += getLightProbeIndirectRadiance( /*specularLightProbe,*/ geometry.viewDir, geometry.normal, material.specularRoughness, maxMipLevel );\n\n\t#ifdef CLEARCOAT\n\n\t\tclearcoatRadiance += getLightProbeIndirectRadiance( /*specularLightProbe,*/ geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness, maxMipLevel );\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n#if defined( RE_IndirectDiffuse )\n\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n\n#endif\n\n#if defined( RE_IndirectSpecular )\n\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n\n#endif\n`;\n","export default /* glsl */`\n#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\n\t// Doing a strict comparison with == 1.0 can cause noise artifacts\n\t// on some platforms. See issue #17623.\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n\n#endif\n`;\n","export default /* glsl */`\n#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_LOGDEPTHBUF\n\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\n\t#else\n\n\t\tuniform float logDepthBufFC;\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_LOGDEPTHBUF\n\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\n\t#else\n\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\n\t\t\tgl_Position.z *= gl_Position.w;\n\n\t\t}\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_MAP\n\n\tvec4 texelColor = texture2D( map, vUv );\n\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_MAP\n\n\tuniform sampler2D map;\n\n#endif\n`;\n","export default /* glsl */`\n#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\n#endif\n\n#ifdef USE_MAP\n\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n\n#endif\n\n#ifdef USE_ALPHAMAP\n\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n\n#endif\n`;\n","export default /* glsl */`\n#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\n\tuniform mat3 uvTransform;\n\n#endif\n\n#ifdef USE_MAP\n\n\tuniform sampler2D map;\n\n#endif\n\n#ifdef USE_ALPHAMAP\n\n\tuniform sampler2D alphaMap;\n\n#endif\n`;\n","export default /* glsl */`\nfloat metalnessFactor = metalness;\n\n#ifdef USE_METALNESSMAP\n\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\n\t// reads channel B, compatible with a combined OcclusionRoughnessMetallic (RGB) texture\n\tmetalnessFactor *= texelMetalness.b;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_METALNESSMAP\n\n\tuniform sampler2D metalnessMap;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_MORPHNORMALS\n\n\t// morphTargetBaseInfluence is set based on BufferGeometry.morphTargetsRelative value:\n\t// When morphTargetsRelative is false, this is set to 1 - sum(influences); this results in normal = sum((target - base) * influence)\n\t// When morphTargetsRelative is true, this is set to 1; as a result, all morph targets are simply added to the base after weighting\n\tobjectNormal *= morphTargetBaseInfluence;\n\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_MORPHTARGETS\n\n\tuniform float morphTargetBaseInfluence;\n\n\t#ifndef USE_MORPHNORMALS\n\n\tuniform float morphTargetInfluences[ 8 ];\n\n\t#else\n\n\tuniform float morphTargetInfluences[ 4 ];\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_MORPHTARGETS\n\n\t// morphTargetBaseInfluence is set based on BufferGeometry.morphTargetsRelative value:\n\t// When morphTargetsRelative is false, this is set to 1 - sum(influences); this results in position = sum((target - base) * influence)\n\t// When morphTargetsRelative is true, this is set to 1; as a result, all morph targets are simply added to the base after weighting\n\ttransformed *= morphTargetBaseInfluence;\n\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\n\t#ifndef USE_MORPHNORMALS\n\n\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef FLAT_SHADED\n\n\t// Workaround for Adreno/Nexus5 not able able to do dFdx( vViewPosition ) ...\n\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n\n#else\n\n\tvec3 normal = normalize( vNormal );\n\n\t#ifdef DOUBLE_SIDED\n\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\n\t#endif\n\n\t#ifdef USE_TANGENT\n\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\n\t\t#ifdef DOUBLE_SIDED\n\n\t\t\ttangent = tangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t\tbitangent = bitangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\n\t\t#endif\n\n\t\t#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )\n\n\t\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\n\t\t#endif\n\n\t#endif\n\n#endif\n\n// non perturbed normal for clearcoat among others\n\nvec3 geometryNormal = normal;\n\n`;\n","export default /* glsl */`\n\n#ifdef OBJECTSPACE_NORMALMAP\n\n\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0; // overrides both flatShading and attribute normals\n\n\t#ifdef FLIP_SIDED\n\n\t\tnormal = - normal;\n\n\t#endif\n\n\t#ifdef DOUBLE_SIDED\n\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\n\t#endif\n\n\tnormal = normalize( normalMatrix * normal );\n\n#elif defined( TANGENTSPACE_NORMALMAP )\n\n\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\n\t#ifdef USE_TANGENT\n\n\t\tnormal = normalize( vTBN * mapN );\n\n\t#else\n\n\t\tnormal = perturbNormal2Arb( -vViewPosition, normal, mapN );\n\n\t#endif\n\n#elif defined( USE_BUMPMAP )\n\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_NORMALMAP\n\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n\n#endif\n\n#ifdef OBJECTSPACE_NORMALMAP\n\n\tuniform mat3 normalMatrix;\n\n#endif\n\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\n\t// Per-Pixel Tangent Space Normal Mapping\n\t// http://hacksoflife.blogspot.ch/2009/11/per-pixel-tangent-space-normal-mapping.html\n\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN ) {\n\n\t\t// Workaround for Adreno 3XX dFd*( vec3 ) bug. See #9988\n\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\n\t\tfloat scale = sign( st1.t * st0.s - st0.t * st1.s ); // we do not care about the magnitude\n\n\t\tvec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\n\t\tvec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );\n\t\tvec3 N = normalize( surf_norm );\n\n\t\tmat3 tsn = mat3( S, T, N );\n\n\t\tmapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\n\t\treturn normalize( tsn * mapN );\n\n\t}\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef CLEARCOAT\n\n\tvec3 clearcoatNormal = geometryNormal;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_CLEARCOAT_NORMALMAP\n\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\n\t#ifdef USE_TANGENT\n\n\t\tclearcoatNormal = normalize( vTBN * clearcoatMapN );\n\n\t#else\n\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN );\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n\n#ifdef USE_CLEARCOATMAP\n\n\tuniform sampler2D clearcoatMap;\n\n#endif\n\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\n\tuniform sampler2D clearcoatRoughnessMap;\n\n#endif\n\n#ifdef USE_CLEARCOAT_NORMALMAP\n\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n\n#endif\n`;\n","export default /* glsl */`\nvec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\n\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\n\nconst float PackUpscale = 256. / 255.; // fraction -> 0..1 (including 1)\nconst float UnpackDownscale = 255. / 256.; // 0..1 -> fraction (excluding 1)\n\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\n\nconst float ShiftRight8 = 1. / 256.;\n\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8; // tidy overflow\n\treturn r * PackUpscale;\n}\n\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\n\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ));\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w);\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\n\n// NOTE: viewZ/eyeZ is < 0 when in front of the camera per OpenGL conventions\n\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\n\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}\n`;\n","export default /* glsl */`\n#ifdef PREMULTIPLIED_ALPHA\n\n\t// Get get normal blending with premultipled, use with CustomBlending, OneFactor, OneMinusSrcAlphaFactor, AddEquation.\n\tgl_FragColor.rgb *= gl_FragColor.a;\n\n#endif\n`;\n","export default /* glsl */`\nvec4 mvPosition = vec4( transformed, 1.0 );\n\n#ifdef USE_INSTANCING\n\n\tmvPosition = instanceMatrix * mvPosition;\n\n#endif\n\nmvPosition = modelViewMatrix * mvPosition;\n\ngl_Position = projectionMatrix * mvPosition;\n`;\n","export default /* glsl */`\n#ifdef DITHERING\n\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef DITHERING\n\n\t// based on https://www.shadertoy.com/view/MslGR8\n\tvec3 dithering( vec3 color ) {\n\t\t//Calculate grid position\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\n\t\t//Shift the individual colors differently, thus making it even harder to see the dithering pattern\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\n\t\t//modify shift acording to grid position.\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\n\t\t//shift the color by dither_shift\n\t\treturn color + dither_shift_RGB;\n\t}\n\n#endif\n`;\n","export default /* glsl */`\nfloat roughnessFactor = roughness;\n\n#ifdef USE_ROUGHNESSMAP\n\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\n\t// reads channel G, compatible with a combined OcclusionRoughnessMetallic (RGB) texture\n\troughnessFactor *= texelRoughness.g;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_ROUGHNESSMAP\n\n\tuniform sampler2D roughnessMap;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_SHADOWMAP\n\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\n\t#endif\n\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\n\t#endif\n\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\n\t#endif\n\n\t/*\n\t#if NUM_RECT_AREA_LIGHTS > 0\n\n\t\t// TODO (abelnation): create uniforms for area light shadows\n\n\t#endif\n\t*/\n\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\n\t}\n\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\n\t}\n\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\n\t\tfloat occlusion = 1.0;\n\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\n\t\tfloat hard_shadow = step( compare , distribution.x ); // Hard Shadow\n\n\t\tif (hard_shadow != 1.0 ) {\n\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance ); // Chebeyshevs inequality\n\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); // 0.3 reduces light bleed\n\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\n\t\t}\n\t\treturn occlusion;\n\n\t}\n\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\n\t\tfloat shadow = 1.0;\n\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\n\t\t// if ( something && something ) breaks ATI OpenGL shader compiler\n\t\t// if ( all( something, something ) ) using this instead\n\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\n\t\tbool frustumTest = all( frustumTestVec );\n\n\t\tif ( frustumTest ) {\n\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), \n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\n\t\t#else // no percentage-closer filtering:\n\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\n\t\t#endif\n\n\t\t}\n\n\t\treturn shadow;\n\n\t}\n\n\t// cubeToUV() maps a 3D direction vector suitable for cube texture mapping to a 2D\n\t// vector suitable for 2D texture mapping. This code uses the following layout for the\n\t// 2D texture:\n\t//\n\t// xzXZ\n\t// y Y\n\t//\n\t// Y - Positive y direction\n\t// y - Negative y direction\n\t// X - Positive x direction\n\t// x - Negative x direction\n\t// Z - Positive z direction\n\t// z - Negative z direction\n\t//\n\t// Source and test bed:\n\t// https://gist.github.com/tschw/da10c43c467ce8afd0c4\n\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\n\t\t// Number of texels to avoid at the edge of each square\n\n\t\tvec3 absV = abs( v );\n\n\t\t// Intersect unit cube\n\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\n\t\t// Apply scale to avoid seams\n\n\t\t// two texels less per square (one texel will do for NEAREST)\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\n\t\t// Unwrap\n\n\t\t// space: -1 ... 1 range for each square\n\t\t//\n\t\t// #X##\t\tdim := ( 4 , 2 )\n\t\t// # #\t\tcenter := ( 1 , 1 )\n\n\t\tvec2 planar = v.xy;\n\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\n\t\tif ( absV.z >= almostOne ) {\n\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\n\t\t} else if ( absV.x >= almostOne ) {\n\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\n\t\t} else if ( absV.y >= almostOne ) {\n\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\n\t\t}\n\n\t\t// Transform to UV space\n\n\t\t// scale := 0.5 / dim\n\t\t// translate := ( center + 0.5 ) / dim\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\n\t}\n\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\n\t\t// for point lights, the uniform @vShadowCoord is re-purposed to hold\n\t\t// the vector from the light to the world-space position of the fragment.\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\n\t\t// dp = normalized distance from light to fragment position\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); // need to clamp?\n\t\tdp += shadowBias;\n\n\t\t// bd3D = base direction 3D\n\t\tvec3 bd3D = normalize( lightToPosition );\n\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\n\t\t#else // no percentage-closer filtering\n\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\n\t\t#endif\n\n\t}\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_SHADOWMAP\n\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\n\t#endif\n\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\n\t#endif\n\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\n\t#endif\n\n\t/*\n\t#if NUM_RECT_AREA_LIGHTS > 0\n\n\t\t// TODO (abelnation): uniforms for area light shadows\n\n\t#endif\n\t*/\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_SHADOWMAP\n\n\t#if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0\n\n\t\t// Offsetting the position used for querying occlusion along the world normal can be used to reduce shadow acne.\n\t\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\tvec4 shadowWorldPosition;\n\n\t#endif\n\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\n\t}\n\t#pragma unroll_loop_end\n\n\t#endif\n\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * shadowWorldPosition;\n\n\t}\n\t#pragma unroll_loop_end\n\n\t#endif\n\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\n\t}\n\t#pragma unroll_loop_end\n\n\t#endif\n\n\t/*\n\t#if NUM_RECT_AREA_LIGHTS > 0\n\n\t\t// TODO (abelnation): update vAreaShadowCoord with area light info\n\n\t#endif\n\t*/\n\n#endif\n`;\n","export default /* glsl */`\nfloat getShadowMask() {\n\n\tfloat shadow = 1.0;\n\n\t#ifdef USE_SHADOWMAP\n\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\n\tDirectionalLightShadow directionalLight;\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\n\t}\n\t#pragma unroll_loop_end\n\n\t#endif\n\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\n\tSpotLightShadow spotLight;\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\n\t}\n\t#pragma unroll_loop_end\n\n\t#endif\n\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\n\tPointLightShadow pointLight;\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\n\t}\n\t#pragma unroll_loop_end\n\n\t#endif\n\n\t/*\n\t#if NUM_RECT_AREA_LIGHTS > 0\n\n\t\t// TODO (abelnation): update shadow for Area light\n\n\t#endif\n\t*/\n\n\t#endif\n\n\treturn shadow;\n\n}\n`;\n","export default /* glsl */`\n#ifdef USE_SKINNING\n\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_SKINNING\n\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\n\t#ifdef BONE_TEXTURE\n\n\t\tuniform highp sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\n\t\tmat4 getBoneMatrix( const in float i ) {\n\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\n\t\t\ty = dy * ( y + 0.5 );\n\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\n\t\t\treturn bone;\n\n\t\t}\n\n\t#else\n\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\n\t\tmat4 getBoneMatrix( const in float i ) {\n\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\n\t\t}\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_SKINNING\n\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_SKINNING\n\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\n\t#ifdef USE_TANGENT\n\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\nfloat specularStrength;\n\n#ifdef USE_SPECULARMAP\n\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n\n#else\n\n\tspecularStrength = 1.0;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_SPECULARMAP\n\n\tuniform sampler2D specularMap;\n\n#endif\n`;\n","export default /* glsl */`\n#if defined( TONE_MAPPING )\n\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n\n#endif\n`;\n","export default /* glsl */`\n#ifndef saturate\n// may have defined saturate() already\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\n\nuniform float toneMappingExposure;\n\n// exposure only\nvec3 LinearToneMapping( vec3 color ) {\n\n\treturn toneMappingExposure * color;\n\n}\n\n// source: https://www.cs.utah.edu/~reinhard/cdrom/\nvec3 ReinhardToneMapping( vec3 color ) {\n\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n\n}\n\n// source: http://filmicworlds.com/blog/filmic-tonemapping-operators/\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\n\t// optimized filmic operator by Jim Hejl and Richard Burgess-Dawson\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n\n}\n\n// source: https://github.com/selfshadow/ltc_code/blob/master/webgl/shaders/ltc/ltc_blit.fs\nvec3 RRTAndODTFit( vec3 v ) {\n\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n\n}\n\n// this implementation of ACES is modified to accommodate a brighter viewing environment.\n// the scale factor of 1/0.6 is subjective. see discussion in #19621.\n\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\n\t// sRGB => XYZ => D65_2_D60 => AP1 => RRT_SAT\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ), // transposed from source\n\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\n\t// ODT_SAT => XYZ => D60_2_D65 => sRGB\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ), // transposed from source\n\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\n\tcolor *= toneMappingExposure / 0.6;\n\n\tcolor = ACESInputMat * color;\n\n\t// Apply RRT and ODT\n\tcolor = RRTAndODTFit( color );\n\n\tcolor = ACESOutputMat * color;\n\n\t// Clamp to [0, 1]\n\treturn saturate( color );\n\n}\n\nvec3 CustomToneMapping( vec3 color ) { return color; }\n`;\n","export default /* glsl */`\n#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\n\tvarying vec2 vUv;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_UV\n\n\t#ifdef UVS_VERTEX_ONLY\n\n\t\tvec2 vUv;\n\n\t#else\n\n\t\tvarying vec2 vUv;\n\n\t#endif\n\n\tuniform mat3 uvTransform;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_UV\n\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\n#endif\n`;\n","export default /* glsl */`\n#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\n\tvarying vec2 vUv2;\n\n#endif\n`;\n","export default /* glsl */`\n#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n\n\tuniform mat3 uv2Transform;\n\n#endif\n`;\n","export default /* glsl */`\n#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\n\tvUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;\n\n#endif\n`;\n","export default /* glsl */`\n#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\n\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\n\t#ifdef USE_INSTANCING\n\n\t\tworldPosition = instanceMatrix * worldPosition;\n\n\t#endif\n\n\tworldPosition = modelMatrix * worldPosition;\n\n#endif\n`;\n","export default /* glsl */`\nuniform sampler2D t2D;\n\nvarying vec2 vUv;\n\nvoid main() {\n\n\tvec4 texColor = texture2D( t2D, vUv );\n\n\tgl_FragColor = mapTexelToLinear( texColor );\n\n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\nvarying vec2 vUv;\nuniform mat3 uvTransform;\n\nvoid main() {\n\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n\n}\n`;\n","export default /* glsl */`\n#include \nuniform float opacity;\n\nvarying vec3 vWorldDirection;\n\n#include \n\nvoid main() {\n\n\tvec3 vReflect = vWorldDirection;\n\t#include \n\n\tgl_FragColor = envColor;\n\tgl_FragColor.a *= opacity;\n\n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\nvarying vec3 vWorldDirection;\n\n#include \n\nvoid main() {\n\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t#include \n\t#include \n\n\tgl_Position.z = gl_Position.w; // set z to camera.far\n\n}\n`;\n","export default /* glsl */`\n#if DEPTH_PACKING == 3200\n\n\tuniform float opacity;\n\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvarying vec2 vHighPrecisionZW;\n\nvoid main() {\n\n\t#include \n\n\tvec4 diffuseColor = vec4( 1.0 );\n\n\t#if DEPTH_PACKING == 3200\n\n\t\tdiffuseColor.a = opacity;\n\n\t#endif\n\n\t#include \n\t#include \n\t#include \n\n\t#include \n\n\t// Higher precision equivalent of gl_FragCoord.z. This assumes depthRange has been left to its default values.\n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\n\t#if DEPTH_PACKING == 3200\n\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\n\t#elif DEPTH_PACKING == 3201\n\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\n\t#endif\n\n}\n`;\n","export default /* glsl */`\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n// This is used for computing an equivalent of gl_FragCoord.z that is as high precision as possible.\n// Some platforms compute gl_FragCoord at a lower precision which makes the manually computed value better for\n// depth-based postprocessing effects. Reproduced on iPad with A10 processor / iPadOS 13.3.1.\nvarying vec2 vHighPrecisionZW;\n\nvoid main() {\n\n\t#include \n\n\t#include \n\n\t#ifdef USE_DISPLACEMENTMAP\n\n\t\t#include \n\t\t#include \n\t\t#include \n\n\t#endif\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\tvHighPrecisionZW = gl_Position.zw;\n\n}\n`;\n","export default /* glsl */`\n#define DISTANCE\n\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n\n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main () {\n\n\t#include \n\n\tvec4 diffuseColor = vec4( 1.0 );\n\n\t#include \n\t#include \n\t#include \n\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist ); // clamp to [ 0, 1 ]\n\n\tgl_FragColor = packDepthToRGBA( dist );\n\n}\n`;\n","export default /* glsl */`\n#define DISTANCE\n\nvarying vec3 vWorldPosition;\n\n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\t#include \n\n\t#ifdef USE_DISPLACEMENTMAP\n\n\t\t#include \n\t\t#include \n\t\t#include \n\n\t#endif\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\tvWorldPosition = worldPosition.xyz;\n\n}\n`;\n","export default /* glsl */`\nuniform sampler2D tEquirect;\n\nvarying vec3 vWorldDirection;\n\n#include \n\nvoid main() {\n\n\tvec3 direction = normalize( vWorldDirection );\n\n\tvec2 sampleUV = equirectUv( direction );\n\n\tvec4 texColor = texture2D( tEquirect, sampleUV );\n\n\tgl_FragColor = mapTexelToLinear( texColor );\n\n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\nvarying vec3 vWorldDirection;\n\n#include \n\nvoid main() {\n\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\nuniform vec3 diffuse;\nuniform float opacity;\n\nuniform float dashSize;\nuniform float totalSize;\n\nvarying float vLineDistance;\n\n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\n\t\tdiscard;\n\n\t}\n\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\n\t#include \n\t#include \n\n\toutgoingLight = diffuseColor.rgb; // simple shader\n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\nuniform float scale;\nattribute float lineDistance;\n\nvarying float vLineDistance;\n\n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\tvLineDistance = scale * lineDistance;\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\nuniform vec3 diffuse;\nuniform float opacity;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\n\t// accumulation (baked indirect lighting only)\n\t#ifdef USE_LIGHTMAP\n\t\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\treflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\n\t#else\n\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\n\t#endif\n\n\t// modulation\n\t#include \n\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\n\t#include \n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\t#include \n\t#include \n\t#include \n\n\t#ifdef USE_ENVMAP\n\n\t#include \n\t#include \n\t#include \n\t#include \n\n\t#endif\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t// accumulation\n\n\t#ifdef DOUBLE_SIDED\n\n\t\treflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n\n\t#else\n\n\t\treflectedLight.indirectDiffuse += vIndirectFront;\n\n\t#endif\n\n\t#include \n\n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\n\t#ifdef DOUBLE_SIDED\n\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\n\t#else\n\n\t\treflectedLight.directDiffuse = vLightFront;\n\n\t#endif\n\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\n\t// modulation\n\n\t#include \n\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\n\t#include \n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n`;\n","export default /* glsl */`\n#define LAMBERT\n\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n`;\n","export default /* glsl */`\n#define MATCAP\n\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\n\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; // 0.495 to remove artifacts caused by undersized matcap disks\n\n\t#ifdef USE_MATCAP\n\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t\tmatcapColor = matcapTexelToLinear( matcapColor );\n\n\t#else\n\n\t\tvec4 matcapColor = vec4( 1.0 );\n\n\t#endif\n\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\n#define MATCAP\n\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#include \n#include \n\nvoid main() {\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED\n\n\t\tvNormal = normalize( transformedNormal );\n\n\t#endif\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\t#include \n\n\tvViewPosition = - mvPosition.xyz;\n\n}\n`;\n","export default /* glsl */`\n#define TOON\n\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t// accumulation\n\t#include \n\t#include \n\t#include \n\t#include \n\n\t// modulation\n\t#include \n\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\n#define TOON\n\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED\n\n\tvNormal = normalize( transformedNormal );\n\n#endif\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\tvViewPosition = - mvPosition.xyz;\n\n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\n#define PHONG\n\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t// accumulation\n\t#include \n\t#include \n\t#include \n\t#include \n\n\t// modulation\n\t#include \n\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\n\t#include \n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\n#define PHONG\n\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED\n\n\tvNormal = normalize( transformedNormal );\n\n#endif\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\tvViewPosition = - mvPosition.xyz;\n\n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\n#define STANDARD\n\n#ifdef PHYSICAL\n\t#define REFLECTIVITY\n\t#define CLEARCOAT\n\t#define TRANSPARENCY\n#endif\n\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n\n#ifdef TRANSPARENCY\n\tuniform float transparency;\n#endif\n\n#ifdef REFLECTIVITY\n\tuniform float reflectivity;\n#endif\n\n#ifdef CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n\n#ifdef USE_SHEEN\n\tuniform vec3 sheen;\n#endif\n\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n\t#ifdef USE_TANGENT\n\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\n\t#endif\n\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t// accumulation\n\t#include \n\t#include \n\t#include \n\t#include \n\n\t// modulation\n\t#include \n\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\n\t// this is a stub for the transparency model\n\t#ifdef TRANSPARENCY\n\t\tdiffuseColor.a *= saturate( 1. - transparency + linearToRelativeLuminance( reflectedLight.directSpecular + reflectedLight.indirectSpecular ) );\n\t#endif\n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\n#define STANDARD\n\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n\t#ifdef USE_TANGENT\n\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\n\t#endif\n\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED\n\n\tvNormal = normalize( transformedNormal );\n\n\t#ifdef USE_TANGENT\n\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\n\t#endif\n\n#endif\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\tvViewPosition = - mvPosition.xyz;\n\n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\n#define NORMAL\n\nuniform float opacity;\n\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\n\tvarying vec3 vViewPosition;\n\n#endif\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n\t#ifdef USE_TANGENT\n\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\n\t#endif\n\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\t#include \n\t#include \n\t#include \n\n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n\n}\n`;\n","export default /* glsl */`\n#define NORMAL\n\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\n\tvarying vec3 vViewPosition;\n\n#endif\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n\t#ifdef USE_TANGENT\n\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\n\t#endif\n\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED\n\n\tvNormal = normalize( transformedNormal );\n\n\t#ifdef USE_TANGENT\n\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\n\t#endif\n\n#endif\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\n\tvViewPosition = - mvPosition.xyz;\n\n#endif\n\n}\n`;\n","export default /* glsl */`\nuniform vec3 diffuse;\nuniform float opacity;\n\n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\n\toutgoingLight = diffuseColor.rgb;\n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\nuniform float size;\nuniform float scale;\n\n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\t#include \n\t#include \n\t#include \n\n\tgl_PointSize = size;\n\n\t#ifdef USE_SIZEATTENUATION\n\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\n\t#endif\n\n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\nuniform vec3 color;\nuniform float opacity;\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\nuniform vec3 diffuse;\nuniform float opacity;\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\n\toutgoingLight = diffuseColor.rgb;\n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\nuniform float rotation;\nuniform vec2 center;\n\n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\n\t#ifndef USE_SIZEATTENUATION\n\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\n\t#endif\n\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\n\tmvPosition.xy += rotatedPosition;\n\n\tgl_Position = projectionMatrix * mvPosition;\n\n\t#include \n\t#include \n\t#include \n\n}\n`;\n","import { ShaderChunk } from './ShaderChunk.js';\nimport { mergeUniforms } from './UniformsUtils.js';\nimport { Vector2 } from '../../math/Vector2.js';\nimport { Vector3 } from '../../math/Vector3.js';\nimport { UniformsLib } from './UniformsLib.js';\nimport { Color } from '../../math/Color.js';\nimport { Matrix3 } from '../../math/Matrix3.js';\n\n/**\n * @author alteredq / http://alteredqualia.com/\n * @author mrdoob / http://mrdoob.com/\n * @author mikael emtinger / http://gomo.se/\n */\n\nconst ShaderLib = {\n\n\tbasic: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.common,\n\t\t\tUniformsLib.specularmap,\n\t\t\tUniformsLib.envmap,\n\t\t\tUniformsLib.aomap,\n\t\t\tUniformsLib.lightmap,\n\t\t\tUniformsLib.fog\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.meshbasic_vert,\n\t\tfragmentShader: ShaderChunk.meshbasic_frag\n\n\t},\n\n\tlambert: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.common,\n\t\t\tUniformsLib.specularmap,\n\t\t\tUniformsLib.envmap,\n\t\t\tUniformsLib.aomap,\n\t\t\tUniformsLib.lightmap,\n\t\t\tUniformsLib.emissivemap,\n\t\t\tUniformsLib.fog,\n\t\t\tUniformsLib.lights,\n\t\t\t{\n\t\t\t\temissive: { value: new Color( 0x000000 ) }\n\t\t\t}\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.meshlambert_vert,\n\t\tfragmentShader: ShaderChunk.meshlambert_frag\n\n\t},\n\n\tphong: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.common,\n\t\t\tUniformsLib.specularmap,\n\t\t\tUniformsLib.envmap,\n\t\t\tUniformsLib.aomap,\n\t\t\tUniformsLib.lightmap,\n\t\t\tUniformsLib.emissivemap,\n\t\t\tUniformsLib.bumpmap,\n\t\t\tUniformsLib.normalmap,\n\t\t\tUniformsLib.displacementmap,\n\t\t\tUniformsLib.fog,\n\t\t\tUniformsLib.lights,\n\t\t\t{\n\t\t\t\temissive: { value: new Color( 0x000000 ) },\n\t\t\t\tspecular: { value: new Color( 0x111111 ) },\n\t\t\t\tshininess: { value: 30 }\n\t\t\t}\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.meshphong_vert,\n\t\tfragmentShader: ShaderChunk.meshphong_frag\n\n\t},\n\n\tstandard: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.common,\n\t\t\tUniformsLib.envmap,\n\t\t\tUniformsLib.aomap,\n\t\t\tUniformsLib.lightmap,\n\t\t\tUniformsLib.emissivemap,\n\t\t\tUniformsLib.bumpmap,\n\t\t\tUniformsLib.normalmap,\n\t\t\tUniformsLib.displacementmap,\n\t\t\tUniformsLib.roughnessmap,\n\t\t\tUniformsLib.metalnessmap,\n\t\t\tUniformsLib.fog,\n\t\t\tUniformsLib.lights,\n\t\t\t{\n\t\t\t\temissive: { value: new Color( 0x000000 ) },\n\t\t\t\troughness: { value: 1.0 },\n\t\t\t\tmetalness: { value: 0.0 },\n\t\t\t\tenvMapIntensity: { value: 1 } // temporary\n\t\t\t}\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.meshphysical_vert,\n\t\tfragmentShader: ShaderChunk.meshphysical_frag\n\n\t},\n\n\ttoon: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.common,\n\t\t\tUniformsLib.aomap,\n\t\t\tUniformsLib.lightmap,\n\t\t\tUniformsLib.emissivemap,\n\t\t\tUniformsLib.bumpmap,\n\t\t\tUniformsLib.normalmap,\n\t\t\tUniformsLib.displacementmap,\n\t\t\tUniformsLib.gradientmap,\n\t\t\tUniformsLib.fog,\n\t\t\tUniformsLib.lights,\n\t\t\t{\n\t\t\t\temissive: { value: new Color( 0x000000 ) }\n\t\t\t}\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.meshtoon_vert,\n\t\tfragmentShader: ShaderChunk.meshtoon_frag\n\n\t},\n\n\tmatcap: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.common,\n\t\t\tUniformsLib.bumpmap,\n\t\t\tUniformsLib.normalmap,\n\t\t\tUniformsLib.displacementmap,\n\t\t\tUniformsLib.fog,\n\t\t\t{\n\t\t\t\tmatcap: { value: null }\n\t\t\t}\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.meshmatcap_vert,\n\t\tfragmentShader: ShaderChunk.meshmatcap_frag\n\n\t},\n\n\tpoints: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.points,\n\t\t\tUniformsLib.fog\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.points_vert,\n\t\tfragmentShader: ShaderChunk.points_frag\n\n\t},\n\n\tdashed: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.common,\n\t\t\tUniformsLib.fog,\n\t\t\t{\n\t\t\t\tscale: { value: 1 },\n\t\t\t\tdashSize: { value: 1 },\n\t\t\t\ttotalSize: { value: 2 }\n\t\t\t}\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.linedashed_vert,\n\t\tfragmentShader: ShaderChunk.linedashed_frag\n\n\t},\n\n\tdepth: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.common,\n\t\t\tUniformsLib.displacementmap\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.depth_vert,\n\t\tfragmentShader: ShaderChunk.depth_frag\n\n\t},\n\n\tnormal: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.common,\n\t\t\tUniformsLib.bumpmap,\n\t\t\tUniformsLib.normalmap,\n\t\t\tUniformsLib.displacementmap,\n\t\t\t{\n\t\t\t\topacity: { value: 1.0 }\n\t\t\t}\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.normal_vert,\n\t\tfragmentShader: ShaderChunk.normal_frag\n\n\t},\n\n\tsprite: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.sprite,\n\t\t\tUniformsLib.fog\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.sprite_vert,\n\t\tfragmentShader: ShaderChunk.sprite_frag\n\n\t},\n\n\tbackground: {\n\n\t\tuniforms: {\n\t\t\tuvTransform: { value: new Matrix3() },\n\t\t\tt2D: { value: null },\n\t\t},\n\n\t\tvertexShader: ShaderChunk.background_vert,\n\t\tfragmentShader: ShaderChunk.background_frag\n\n\t},\n\t/* -------------------------------------------------------------------------\n\t//\tCube map shader\n\t ------------------------------------------------------------------------- */\n\n\tcube: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.envmap,\n\t\t\t{\n\t\t\t\topacity: { value: 1.0 }\n\t\t\t}\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.cube_vert,\n\t\tfragmentShader: ShaderChunk.cube_frag\n\n\t},\n\n\tequirect: {\n\n\t\tuniforms: {\n\t\t\ttEquirect: { value: null },\n\t\t},\n\n\t\tvertexShader: ShaderChunk.equirect_vert,\n\t\tfragmentShader: ShaderChunk.equirect_frag\n\n\t},\n\n\tdistanceRGBA: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.common,\n\t\t\tUniformsLib.displacementmap,\n\t\t\t{\n\t\t\t\treferencePosition: { value: new Vector3() },\n\t\t\t\tnearDistance: { value: 1 },\n\t\t\t\tfarDistance: { value: 1000 }\n\t\t\t}\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.distanceRGBA_vert,\n\t\tfragmentShader: ShaderChunk.distanceRGBA_frag\n\n\t},\n\n\tshadow: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.lights,\n\t\t\tUniformsLib.fog,\n\t\t\t{\n\t\t\t\tcolor: { value: new Color( 0x00000 ) },\n\t\t\t\topacity: { value: 1.0 }\n\t\t\t},\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.shadow_vert,\n\t\tfragmentShader: ShaderChunk.shadow_frag\n\n\t}\n\n};\n\nShaderLib.physical = {\n\n\tuniforms: mergeUniforms( [\n\t\tShaderLib.standard.uniforms,\n\t\t{\n\t\t\tclearcoat: { value: 0 },\n\t\t\tclearcoatMap: { value: null },\n\t\t\tclearcoatRoughness: { value: 0 },\n\t\t\tclearcoatRoughnessMap: { value: null },\n\t\t\tclearcoatNormalScale: { value: new Vector2( 1, 1 ) },\n\t\t\tclearcoatNormalMap: { value: null },\n\t\t\tsheen: { value: new Color( 0x000000 ) },\n\t\t\ttransparency: { value: 0 },\n\t\t}\n\t] ),\n\n\tvertexShader: ShaderChunk.meshphysical_vert,\n\tfragmentShader: ShaderChunk.meshphysical_frag\n\n};\n\n\nexport { ShaderLib };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { BackSide, FrontSide, CubeUVReflectionMapping } from '../../constants.js';\nimport { BoxBufferGeometry } from '../../geometries/BoxGeometry.js';\nimport { PlaneBufferGeometry } from '../../geometries/PlaneGeometry.js';\nimport { ShaderMaterial } from '../../materials/ShaderMaterial.js';\nimport { Color } from '../../math/Color.js';\nimport { Mesh } from '../../objects/Mesh.js';\nimport { ShaderLib } from '../shaders/ShaderLib.js';\nimport { cloneUniforms } from '../shaders/UniformsUtils.js';\n\nfunction WebGLBackground( renderer, state, objects, premultipliedAlpha ) {\n\n\tconst clearColor = new Color( 0x000000 );\n\tlet clearAlpha = 0;\n\n\tlet planeMesh;\n\tlet boxMesh;\n\n\tlet currentBackground = null;\n\tlet currentBackgroundVersion = 0;\n\tlet currentTonemapping = null;\n\n\tfunction render( renderList, scene, camera, forceClear ) {\n\n\t\tlet background = scene.isScene === true ? scene.background : null;\n\n\t\t// Ignore background in AR\n\t\t// TODO: Reconsider this.\n\n\t\tconst xr = renderer.xr;\n\t\tconst session = xr.getSession && xr.getSession();\n\n\t\tif ( session && session.environmentBlendMode === 'additive' ) {\n\n\t\t\tbackground = null;\n\n\t\t}\n\n\t\tif ( background === null ) {\n\n\t\t\tsetClear( clearColor, clearAlpha );\n\n\t\t} else if ( background && background.isColor ) {\n\n\t\t\tsetClear( background, 1 );\n\t\t\tforceClear = true;\n\n\t\t}\n\n\t\tif ( renderer.autoClear || forceClear ) {\n\n\t\t\trenderer.clear( renderer.autoClearColor, renderer.autoClearDepth, renderer.autoClearStencil );\n\n\t\t}\n\n\t\tif ( background && ( background.isCubeTexture || background.isWebGLCubeRenderTarget || background.mapping === CubeUVReflectionMapping ) ) {\n\n\t\t\tif ( boxMesh === undefined ) {\n\n\t\t\t\tboxMesh = new Mesh(\n\t\t\t\t\tnew BoxBufferGeometry( 1, 1, 1 ),\n\t\t\t\t\tnew ShaderMaterial( {\n\t\t\t\t\t\tname: 'BackgroundCubeMaterial',\n\t\t\t\t\t\tuniforms: cloneUniforms( ShaderLib.cube.uniforms ),\n\t\t\t\t\t\tvertexShader: ShaderLib.cube.vertexShader,\n\t\t\t\t\t\tfragmentShader: ShaderLib.cube.fragmentShader,\n\t\t\t\t\t\tside: BackSide,\n\t\t\t\t\t\tdepthTest: false,\n\t\t\t\t\t\tdepthWrite: false,\n\t\t\t\t\t\tfog: false\n\t\t\t\t\t} )\n\t\t\t\t);\n\n\t\t\t\tboxMesh.geometry.deleteAttribute( 'normal' );\n\t\t\t\tboxMesh.geometry.deleteAttribute( 'uv' );\n\n\t\t\t\tboxMesh.onBeforeRender = function ( renderer, scene, camera ) {\n\n\t\t\t\t\tthis.matrixWorld.copyPosition( camera.matrixWorld );\n\n\t\t\t\t};\n\n\t\t\t\t// enable code injection for non-built-in material\n\t\t\t\tObject.defineProperty( boxMesh.material, 'envMap', {\n\n\t\t\t\t\tget: function () {\n\n\t\t\t\t\t\treturn this.uniforms.envMap.value;\n\n\t\t\t\t\t}\n\n\t\t\t\t} );\n\n\t\t\t\tobjects.update( boxMesh );\n\n\t\t\t}\n\n\t\t\tconst texture = background.isWebGLCubeRenderTarget ? background.texture : background;\n\n\t\t\tboxMesh.material.uniforms.envMap.value = texture;\n\t\t\tboxMesh.material.uniforms.flipEnvMap.value = texture.isCubeTexture ? - 1 : 1;\n\n\t\t\tif ( currentBackground !== background ||\n\t\t\t\tcurrentBackgroundVersion !== texture.version ||\n\t\t\t\tcurrentTonemapping !== renderer.toneMapping ) {\n\n\t\t\t\tboxMesh.material.needsUpdate = true;\n\n\t\t\t\tcurrentBackground = background;\n\t\t\t\tcurrentBackgroundVersion = texture.version;\n\t\t\t\tcurrentTonemapping = renderer.toneMapping;\n\n\t\t\t}\n\n\t\t\t// push to the pre-sorted opaque render list\n\t\t\trenderList.unshift( boxMesh, boxMesh.geometry, boxMesh.material, 0, 0, null );\n\n\t\t} else if ( background && background.isTexture ) {\n\n\t\t\tif ( planeMesh === undefined ) {\n\n\t\t\t\tplaneMesh = new Mesh(\n\t\t\t\t\tnew PlaneBufferGeometry( 2, 2 ),\n\t\t\t\t\tnew ShaderMaterial( {\n\t\t\t\t\t\tname: 'BackgroundMaterial',\n\t\t\t\t\t\tuniforms: cloneUniforms( ShaderLib.background.uniforms ),\n\t\t\t\t\t\tvertexShader: ShaderLib.background.vertexShader,\n\t\t\t\t\t\tfragmentShader: ShaderLib.background.fragmentShader,\n\t\t\t\t\t\tside: FrontSide,\n\t\t\t\t\t\tdepthTest: false,\n\t\t\t\t\t\tdepthWrite: false,\n\t\t\t\t\t\tfog: false\n\t\t\t\t\t} )\n\t\t\t\t);\n\n\t\t\t\tplaneMesh.geometry.deleteAttribute( 'normal' );\n\n\t\t\t\t// enable code injection for non-built-in material\n\t\t\t\tObject.defineProperty( planeMesh.material, 'map', {\n\n\t\t\t\t\tget: function () {\n\n\t\t\t\t\t\treturn this.uniforms.t2D.value;\n\n\t\t\t\t\t}\n\n\t\t\t\t} );\n\n\t\t\t\tobjects.update( planeMesh );\n\n\t\t\t}\n\n\t\t\tplaneMesh.material.uniforms.t2D.value = background;\n\n\t\t\tif ( background.matrixAutoUpdate === true ) {\n\n\t\t\t\tbackground.updateMatrix();\n\n\t\t\t}\n\n\t\t\tplaneMesh.material.uniforms.uvTransform.value.copy( background.matrix );\n\n\t\t\tif ( currentBackground !== background ||\n\t\t\t\tcurrentBackgroundVersion !== background.version ||\n\t\t\t\tcurrentTonemapping !== renderer.toneMapping ) {\n\n\t\t\t\tplaneMesh.material.needsUpdate = true;\n\n\t\t\t\tcurrentBackground = background;\n\t\t\t\tcurrentBackgroundVersion = background.version;\n\t\t\t\tcurrentTonemapping = renderer.toneMapping;\n\n\t\t\t}\n\n\n\t\t\t// push to the pre-sorted opaque render list\n\t\t\trenderList.unshift( planeMesh, planeMesh.geometry, planeMesh.material, 0, 0, null );\n\n\t\t}\n\n\t}\n\n\tfunction setClear( color, alpha ) {\n\n\t\tstate.buffers.color.setClear( color.r, color.g, color.b, alpha, premultipliedAlpha );\n\n\t}\n\n\treturn {\n\n\t\tgetClearColor: function () {\n\n\t\t\treturn clearColor;\n\n\t\t},\n\t\tsetClearColor: function ( color, alpha ) {\n\n\t\t\tclearColor.set( color );\n\t\t\tclearAlpha = alpha !== undefined ? alpha : 1;\n\t\t\tsetClear( clearColor, clearAlpha );\n\n\t\t},\n\t\tgetClearAlpha: function () {\n\n\t\t\treturn clearAlpha;\n\n\t\t},\n\t\tsetClearAlpha: function ( alpha ) {\n\n\t\t\tclearAlpha = alpha;\n\t\t\tsetClear( clearColor, clearAlpha );\n\n\t\t},\n\t\trender: render\n\n\t};\n\n}\n\n\nexport { WebGLBackground };\n","/**\n * @author Mugen87 / https://github.com/Mugen87\n * @author Takahiro / https://github.com/takahirox\n */\n\nfunction WebGLBindingStates( gl, extensions, attributes, capabilities ) {\n\n\tconst maxVertexAttributes = gl.getParameter( gl.MAX_VERTEX_ATTRIBS );\n\n\tconst extension = capabilities.isWebGL2 ? null : extensions.get( 'OES_vertex_array_object' );\n\tconst vaoAvailable = capabilities.isWebGL2 || extension !== null;\n\n\tconst bindingStates = {};\n\n\tconst defaultState = createBindingState( null );\n\tlet currentState = defaultState;\n\n\tfunction setup( object, material, program, geometry, index ) {\n\n\t\tlet updateBuffers = false;\n\n\t\tif ( vaoAvailable ) {\n\n\t\t\tconst state = getBindingState( geometry, program, material );\n\n\t\t\tif ( currentState !== state ) {\n\n\t\t\t\tcurrentState = state;\n\t\t\t\tbindVertexArrayObject( currentState.object );\n\n\t\t\t}\n\n\t\t\tupdateBuffers = needsUpdate( geometry );\n\n\t\t\tif ( updateBuffers ) saveCache( geometry );\n\n\t\t} else {\n\n\t\t\tconst wireframe = ( material.wireframe === true );\n\n\t\t\tif ( currentState.geometry !== geometry.id ||\n\t\t\t\tcurrentState.program !== program.id ||\n\t\t\t\tcurrentState.wireframe !== wireframe ) {\n\n\t\t\t\tcurrentState.geometry = geometry.id;\n\t\t\t\tcurrentState.program = program.id;\n\t\t\t\tcurrentState.wireframe = wireframe;\n\n\t\t\t\tupdateBuffers = true;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( object.isInstancedMesh === true ) {\n\n\t\t\tupdateBuffers = true;\n\n\t\t}\n\n\t\tif ( index !== null ) {\n\n\t\t\tattributes.update( index, gl.ELEMENT_ARRAY_BUFFER );\n\n\t\t}\n\n\t\tif ( updateBuffers ) {\n\n\t\t\tsetupVertexAttributes( object, material, program, geometry );\n\n\t\t\tif ( index !== null ) {\n\n\t\t\t\tgl.bindBuffer( gl.ELEMENT_ARRAY_BUFFER, attributes.get( index ).buffer );\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tfunction createVertexArrayObject() {\n\n\t\tif ( capabilities.isWebGL2 ) return gl.createVertexArray();\n\n\t\treturn extension.createVertexArrayOES();\n\n\t}\n\n\tfunction bindVertexArrayObject( vao ) {\n\n\t\tif ( capabilities.isWebGL2 ) return gl.bindVertexArray( vao );\n\n\t\treturn extension.bindVertexArrayOES( vao );\n\n\t}\n\n\tfunction deleteVertexArrayObject( vao ) {\n\n\t\tif ( capabilities.isWebGL2 ) return gl.deleteVertexArray( vao );\n\n\t\treturn extension.deleteVertexArrayOES( vao );\n\n\t}\n\n\tfunction getBindingState( geometry, program, material ) {\n\n\t\tconst wireframe = ( material.wireframe === true );\n\n\t\tlet programMap = bindingStates[ geometry.id ];\n\n\t\tif ( programMap === undefined ) {\n\n\t\t\tprogramMap = {};\n\t\t\tbindingStates[ geometry.id ] = programMap;\n\n\t\t}\n\n\t\tlet stateMap = programMap[ program.id ];\n\n\t\tif ( stateMap === undefined ) {\n\n\t\t\tstateMap = {};\n\t\t\tprogramMap[ program.id ] = stateMap;\n\n\t\t}\n\n\t\tlet state = stateMap[ wireframe ];\n\n\t\tif ( state === undefined ) {\n\n\t\t\tstate = createBindingState( createVertexArrayObject() );\n\t\t\tstateMap[ wireframe ] = state;\n\n\t\t}\n\n\t\treturn state;\n\n\t}\n\n\tfunction createBindingState( vao ) {\n\n\t\tconst newAttributes = [];\n\t\tconst enabledAttributes = [];\n\t\tconst attributeDivisors = [];\n\n\t\tfor ( let i = 0; i < maxVertexAttributes; i ++ ) {\n\n\t\t\tnewAttributes[ i ] = 0;\n\t\t\tenabledAttributes[ i ] = 0;\n\t\t\tattributeDivisors[ i ] = 0;\n\n\t\t}\n\n\t\treturn {\n\n\t\t\t// for backward compatibility on non-VAO support browser\n\t\t\tgeometry: null,\n\t\t\tprogram: null,\n\t\t\twireframe: false,\n\n\t\t\tnewAttributes: newAttributes,\n\t\t\tenabledAttributes: enabledAttributes,\n\t\t\tattributeDivisors: attributeDivisors,\n\t\t\tobject: vao,\n\t\t\tattributes: {}\n\n\t\t};\n\n\t}\n\n\tfunction needsUpdate( geometry ) {\n\n\t\tconst cachedAttributes = currentState.attributes;\n\t\tconst geometryAttributes = geometry.attributes;\n\n\t\tif ( Object.keys( cachedAttributes ).length !== Object.keys( geometryAttributes ).length ) return true;\n\n\t\tfor ( const key in geometryAttributes ) {\n\n\t\t\tconst cachedAttribute = cachedAttributes[ key ];\n\t\t\tconst geometryAttribute = geometryAttributes[ key ];\n\n\t\t\tif ( cachedAttribute.attribute !== geometryAttribute ) return true;\n\n\t\t\tif ( cachedAttribute.data !== geometryAttribute.data ) return true;\n\n\t\t}\n\n\t\treturn false;\n\n\t}\n\n\tfunction saveCache( geometry ) {\n\n\t\tconst cache = {};\n\t\tconst attributes = geometry.attributes;\n\n\t\tfor ( const key in attributes ) {\n\n\t\t\tconst attribute = attributes[ key ];\n\n\t\t\tconst data = {};\n\t\t\tdata.attribute = attribute;\n\n\t\t\tif ( attribute.data ) {\n\n\t\t\t\tdata.data = attribute.data;\n\n\t\t\t}\n\n\t\t\tcache[ key ] = data;\n\n\t\t}\n\n\t\tcurrentState.attributes = cache;\n\n\t}\n\n\tfunction initAttributes() {\n\n\t\tconst newAttributes = currentState.newAttributes;\n\n\t\tfor ( let i = 0, il = newAttributes.length; i < il; i ++ ) {\n\n\t\t\tnewAttributes[ i ] = 0;\n\n\t\t}\n\n\t}\n\n\tfunction enableAttribute( attribute ) {\n\n\t\tenableAttributeAndDivisor( attribute, 0 );\n\n\t}\n\n\tfunction enableAttributeAndDivisor( attribute, meshPerAttribute ) {\n\n\t\tconst newAttributes = currentState.newAttributes;\n\t\tconst enabledAttributes = currentState.enabledAttributes;\n\t\tconst attributeDivisors = currentState.attributeDivisors;\n\n\t\tnewAttributes[ attribute ] = 1;\n\n\t\tif ( enabledAttributes[ attribute ] === 0 ) {\n\n\t\t\tgl.enableVertexAttribArray( attribute );\n\t\t\tenabledAttributes[ attribute ] = 1;\n\n\t\t}\n\n\t\tif ( attributeDivisors[ attribute ] !== meshPerAttribute ) {\n\n\t\t\tconst extension = capabilities.isWebGL2 ? gl : extensions.get( 'ANGLE_instanced_arrays' );\n\n\t\t\textension[ capabilities.isWebGL2 ? 'vertexAttribDivisor' : 'vertexAttribDivisorANGLE' ]( attribute, meshPerAttribute );\n\t\t\tattributeDivisors[ attribute ] = meshPerAttribute;\n\n\t\t}\n\n\t}\n\n\tfunction disableUnusedAttributes() {\n\n\t\tconst newAttributes = currentState.newAttributes;\n\t\tconst enabledAttributes = currentState.enabledAttributes;\n\n\t\tfor ( let i = 0, il = enabledAttributes.length; i < il; i ++ ) {\n\n\t\t\tif ( enabledAttributes[ i ] !== newAttributes[ i ] ) {\n\n\t\t\t\tgl.disableVertexAttribArray( i );\n\t\t\t\tenabledAttributes[ i ] = 0;\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tfunction vertexAttribPointer( index, size, type, normalized, stride, offset ) {\n\n\t\tif ( capabilities.isWebGL2 === true && ( type === gl.INT || type === gl.UNSIGNED_INT ) ) {\n\n\t\t\tgl.vertexAttribIPointer( index, size, type, normalized, stride, offset );\n\n\t\t} else {\n\n\t\t\tgl.vertexAttribPointer( index, size, type, normalized, stride, offset );\n\n\t\t}\n\n\t}\n\n\tfunction setupVertexAttributes( object, material, program, geometry ) {\n\n\t\tif ( capabilities.isWebGL2 === false && ( object.isInstancedMesh || geometry.isInstancedBufferGeometry ) ) {\n\n\t\t\tif ( extensions.get( 'ANGLE_instanced_arrays' ) === null ) return;\n\n\t\t}\n\n\t\tinitAttributes();\n\n\t\tconst geometryAttributes = geometry.attributes;\n\n\t\tconst programAttributes = program.getAttributes();\n\n\t\tconst materialDefaultAttributeValues = material.defaultAttributeValues;\n\n\t\tfor ( const name in programAttributes ) {\n\n\t\t\tconst programAttribute = programAttributes[ name ];\n\n\t\t\tif ( programAttribute >= 0 ) {\n\n\t\t\t\tconst geometryAttribute = geometryAttributes[ name ];\n\n\t\t\t\tif ( geometryAttribute !== undefined ) {\n\n\t\t\t\t\tconst normalized = geometryAttribute.normalized;\n\t\t\t\t\tconst size = geometryAttribute.itemSize;\n\n\t\t\t\t\tconst attribute = attributes.get( geometryAttribute );\n\n\t\t\t\t\t// TODO Attribute may not be available on context restore\n\n\t\t\t\t\tif ( attribute === undefined ) continue;\n\n\t\t\t\t\tconst buffer = attribute.buffer;\n\t\t\t\t\tconst type = attribute.type;\n\t\t\t\t\tconst bytesPerElement = attribute.bytesPerElement;\n\n\t\t\t\t\tif ( geometryAttribute.isInterleavedBufferAttribute ) {\n\n\t\t\t\t\t\tconst data = geometryAttribute.data;\n\t\t\t\t\t\tconst stride = data.stride;\n\t\t\t\t\t\tconst offset = geometryAttribute.offset;\n\n\t\t\t\t\t\tif ( data && data.isInstancedInterleavedBuffer ) {\n\n\t\t\t\t\t\t\tenableAttributeAndDivisor( programAttribute, data.meshPerAttribute );\n\n\t\t\t\t\t\t\tif ( geometry._maxInstanceCount === undefined ) {\n\n\t\t\t\t\t\t\t\tgeometry._maxInstanceCount = data.meshPerAttribute * data.count;\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\tenableAttribute( programAttribute );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tgl.bindBuffer( gl.ARRAY_BUFFER, buffer );\n\t\t\t\t\t\tvertexAttribPointer( programAttribute, size, type, normalized, stride * bytesPerElement, offset * bytesPerElement );\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tif ( geometryAttribute.isInstancedBufferAttribute ) {\n\n\t\t\t\t\t\t\tenableAttributeAndDivisor( programAttribute, geometryAttribute.meshPerAttribute );\n\n\t\t\t\t\t\t\tif ( geometry._maxInstanceCount === undefined ) {\n\n\t\t\t\t\t\t\t\tgeometry._maxInstanceCount = geometryAttribute.meshPerAttribute * geometryAttribute.count;\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\tenableAttribute( programAttribute );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tgl.bindBuffer( gl.ARRAY_BUFFER, buffer );\n\t\t\t\t\t\tvertexAttribPointer( programAttribute, size, type, normalized, 0, 0 );\n\n\t\t\t\t\t}\n\n\t\t\t\t} else if ( name === 'instanceMatrix' ) {\n\n\t\t\t\t\tconst attribute = attributes.get( object.instanceMatrix );\n\n\t\t\t\t\t// TODO Attribute may not be available on context restore\n\n\t\t\t\t\tif ( attribute === undefined ) continue;\n\n\t\t\t\t\tconst buffer = attribute.buffer;\n\t\t\t\t\tconst type = attribute.type;\n\n\t\t\t\t\tenableAttributeAndDivisor( programAttribute + 0, 1 );\n\t\t\t\t\tenableAttributeAndDivisor( programAttribute + 1, 1 );\n\t\t\t\t\tenableAttributeAndDivisor( programAttribute + 2, 1 );\n\t\t\t\t\tenableAttributeAndDivisor( programAttribute + 3, 1 );\n\n\t\t\t\t\tgl.bindBuffer( gl.ARRAY_BUFFER, buffer );\n\n\t\t\t\t\tgl.vertexAttribPointer( programAttribute + 0, 4, type, false, 64, 0 );\n\t\t\t\t\tgl.vertexAttribPointer( programAttribute + 1, 4, type, false, 64, 16 );\n\t\t\t\t\tgl.vertexAttribPointer( programAttribute + 2, 4, type, false, 64, 32 );\n\t\t\t\t\tgl.vertexAttribPointer( programAttribute + 3, 4, type, false, 64, 48 );\n\n\t\t\t\t} else if ( materialDefaultAttributeValues !== undefined ) {\n\n\t\t\t\t\tconst value = materialDefaultAttributeValues[ name ];\n\n\t\t\t\t\tif ( value !== undefined ) {\n\n\t\t\t\t\t\tswitch ( value.length ) {\n\n\t\t\t\t\t\t\tcase 2:\n\t\t\t\t\t\t\t\tgl.vertexAttrib2fv( programAttribute, value );\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase 3:\n\t\t\t\t\t\t\t\tgl.vertexAttrib3fv( programAttribute, value );\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase 4:\n\t\t\t\t\t\t\t\tgl.vertexAttrib4fv( programAttribute, value );\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\tgl.vertexAttrib1fv( programAttribute, value );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tdisableUnusedAttributes();\n\n\t}\n\n\tfunction dispose() {\n\n\t\treset();\n\n\t\tfor ( const geometryId in bindingStates ) {\n\n\t\t\tconst programMap = bindingStates[ geometryId ];\n\n\t\t\tfor ( const programId in programMap ) {\n\n\t\t\t\tconst stateMap = programMap[ programId ];\n\n\t\t\t\tfor ( const wireframe in stateMap ) {\n\n\t\t\t\t\tdeleteVertexArrayObject( stateMap[ wireframe ].object );\n\n\t\t\t\t\tdelete stateMap[ wireframe ];\n\n\t\t\t\t}\n\n\t\t\t\tdelete programMap[ programId ];\n\n\t\t\t}\n\n\t\t\tdelete bindingStates[ geometryId ];\n\n\t\t}\n\n\t}\n\n\tfunction releaseStatesOfGeometry( geometry ) {\n\n\t\tif ( bindingStates[ geometry.id ] === undefined ) return;\n\n\t\tconst programMap = bindingStates[ geometry.id ];\n\n\t\tfor ( const programId in programMap ) {\n\n\t\t\tconst stateMap = programMap[ programId ];\n\n\t\t\tfor ( const wireframe in stateMap ) {\n\n\t\t\t\tdeleteVertexArrayObject( stateMap[ wireframe ].object );\n\n\t\t\t\tdelete stateMap[ wireframe ];\n\n\t\t\t}\n\n\t\t\tdelete programMap[ programId ];\n\n\t\t}\n\n\t\tdelete bindingStates[ geometry.id ];\n\n\t}\n\n\tfunction releaseStatesOfProgram( program ) {\n\n\t\tfor ( const geometryId in bindingStates ) {\n\n\t\t\tconst programMap = bindingStates[ geometryId ];\n\n\t\t\tif ( programMap[ program.id ] === undefined ) continue;\n\n\t\t\tconst stateMap = programMap[ program.id ];\n\n\t\t\tfor ( const wireframe in stateMap ) {\n\n\t\t\t\tdeleteVertexArrayObject( stateMap[ wireframe ].object );\n\n\t\t\t\tdelete stateMap[ wireframe ];\n\n\t\t\t}\n\n\t\t\tdelete programMap[ program.id ];\n\n\t\t}\n\n\t}\n\n\tfunction reset() {\n\n\t\tresetDefaultState();\n\n\t\tif ( currentState === defaultState ) return;\n\n\t\tcurrentState = defaultState;\n\t\tbindVertexArrayObject( currentState.object );\n\n\t}\n\n\t// for backward-compatilibity\n\n\tfunction resetDefaultState() {\n\n\t\tdefaultState.geometry = null;\n\t\tdefaultState.program = null;\n\t\tdefaultState.wireframe = false;\n\n\t}\n\n\treturn {\n\n\t\tsetup: setup,\n\t\treset: reset,\n\t\tresetDefaultState: resetDefaultState,\n\t\tdispose: dispose,\n\t\treleaseStatesOfGeometry: releaseStatesOfGeometry,\n\t\treleaseStatesOfProgram: releaseStatesOfProgram,\n\n\t\tinitAttributes: initAttributes,\n\t\tenableAttribute: enableAttribute,\n\t\tdisableUnusedAttributes: disableUnusedAttributes\n\n\t};\n\n}\n\n\nexport { WebGLBindingStates };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction WebGLBufferRenderer( gl, extensions, info, capabilities ) {\n\n\tconst isWebGL2 = capabilities.isWebGL2;\n\n\tlet mode;\n\n\tfunction setMode( value ) {\n\n\t\tmode = value;\n\n\t}\n\n\tfunction render( start, count ) {\n\n\t\tgl.drawArrays( mode, start, count );\n\n\t\tinfo.update( count, mode );\n\n\t}\n\n\tfunction renderInstances( geometry, start, count, primcount ) {\n\n\t\tif ( primcount === 0 ) return;\n\n\t\tlet extension, methodName;\n\n\t\tif ( isWebGL2 ) {\n\n\t\t\textension = gl;\n\t\t\tmethodName = 'drawArraysInstanced';\n\n\t\t} else {\n\n\t\t\textension = extensions.get( 'ANGLE_instanced_arrays' );\n\t\t\tmethodName = 'drawArraysInstancedANGLE';\n\n\t\t\tif ( extension === null ) {\n\n\t\t\t\tconsole.error( 'THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.' );\n\t\t\t\treturn;\n\n\t\t\t}\n\n\t\t}\n\n\t\textension[ methodName ]( mode, start, count, primcount );\n\n\t\tinfo.update( count, mode, primcount );\n\n\t}\n\n\t//\n\n\tthis.setMode = setMode;\n\tthis.render = render;\n\tthis.renderInstances = renderInstances;\n\n}\n\n\nexport { WebGLBufferRenderer };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction WebGLCapabilities( gl, extensions, parameters ) {\n\n\tlet maxAnisotropy;\n\n\tfunction getMaxAnisotropy() {\n\n\t\tif ( maxAnisotropy !== undefined ) return maxAnisotropy;\n\n\t\tconst extension = extensions.get( 'EXT_texture_filter_anisotropic' );\n\n\t\tif ( extension !== null ) {\n\n\t\t\tmaxAnisotropy = gl.getParameter( extension.MAX_TEXTURE_MAX_ANISOTROPY_EXT );\n\n\t\t} else {\n\n\t\t\tmaxAnisotropy = 0;\n\n\t\t}\n\n\t\treturn maxAnisotropy;\n\n\t}\n\n\tfunction getMaxPrecision( precision ) {\n\n\t\tif ( precision === 'highp' ) {\n\n\t\t\tif ( gl.getShaderPrecisionFormat( gl.VERTEX_SHADER, gl.HIGH_FLOAT ).precision > 0 &&\n\t\t\t\tgl.getShaderPrecisionFormat( gl.FRAGMENT_SHADER, gl.HIGH_FLOAT ).precision > 0 ) {\n\n\t\t\t\treturn 'highp';\n\n\t\t\t}\n\n\t\t\tprecision = 'mediump';\n\n\t\t}\n\n\t\tif ( precision === 'mediump' ) {\n\n\t\t\tif ( gl.getShaderPrecisionFormat( gl.VERTEX_SHADER, gl.MEDIUM_FLOAT ).precision > 0 &&\n\t\t\t\tgl.getShaderPrecisionFormat( gl.FRAGMENT_SHADER, gl.MEDIUM_FLOAT ).precision > 0 ) {\n\n\t\t\t\treturn 'mediump';\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn 'lowp';\n\n\t}\n\n\t/* eslint-disable no-undef */\n\tconst isWebGL2 = ( typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext ) ||\n\t\t( typeof WebGL2ComputeRenderingContext !== 'undefined' && gl instanceof WebGL2ComputeRenderingContext );\n\t/* eslint-enable no-undef */\n\n\tlet precision = parameters.precision !== undefined ? parameters.precision : 'highp';\n\tconst maxPrecision = getMaxPrecision( precision );\n\n\tif ( maxPrecision !== precision ) {\n\n\t\tconsole.warn( 'THREE.WebGLRenderer:', precision, 'not supported, using', maxPrecision, 'instead.' );\n\t\tprecision = maxPrecision;\n\n\t}\n\n\tconst logarithmicDepthBuffer = parameters.logarithmicDepthBuffer === true;\n\n\tconst maxTextures = gl.getParameter( gl.MAX_TEXTURE_IMAGE_UNITS );\n\tconst maxVertexTextures = gl.getParameter( gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS );\n\tconst maxTextureSize = gl.getParameter( gl.MAX_TEXTURE_SIZE );\n\tconst maxCubemapSize = gl.getParameter( gl.MAX_CUBE_MAP_TEXTURE_SIZE );\n\n\tconst maxAttributes = gl.getParameter( gl.MAX_VERTEX_ATTRIBS );\n\tconst maxVertexUniforms = gl.getParameter( gl.MAX_VERTEX_UNIFORM_VECTORS );\n\tconst maxVaryings = gl.getParameter( gl.MAX_VARYING_VECTORS );\n\tconst maxFragmentUniforms = gl.getParameter( gl.MAX_FRAGMENT_UNIFORM_VECTORS );\n\n\tconst vertexTextures = maxVertexTextures > 0;\n\tconst floatFragmentTextures = isWebGL2 || !! extensions.get( 'OES_texture_float' );\n\tconst floatVertexTextures = vertexTextures && floatFragmentTextures;\n\n\tconst maxSamples = isWebGL2 ? gl.getParameter( gl.MAX_SAMPLES ) : 0;\n\n\treturn {\n\n\t\tisWebGL2: isWebGL2,\n\n\t\tgetMaxAnisotropy: getMaxAnisotropy,\n\t\tgetMaxPrecision: getMaxPrecision,\n\n\t\tprecision: precision,\n\t\tlogarithmicDepthBuffer: logarithmicDepthBuffer,\n\n\t\tmaxTextures: maxTextures,\n\t\tmaxVertexTextures: maxVertexTextures,\n\t\tmaxTextureSize: maxTextureSize,\n\t\tmaxCubemapSize: maxCubemapSize,\n\n\t\tmaxAttributes: maxAttributes,\n\t\tmaxVertexUniforms: maxVertexUniforms,\n\t\tmaxVaryings: maxVaryings,\n\t\tmaxFragmentUniforms: maxFragmentUniforms,\n\n\t\tvertexTextures: vertexTextures,\n\t\tfloatFragmentTextures: floatFragmentTextures,\n\t\tfloatVertexTextures: floatVertexTextures,\n\n\t\tmaxSamples: maxSamples\n\n\t};\n\n}\n\n\nexport { WebGLCapabilities };\n","/**\n * @author tschw\n */\n\nimport { Matrix3 } from '../../math/Matrix3.js';\nimport { Plane } from '../../math/Plane.js';\n\nfunction WebGLClipping() {\n\n\tconst scope = this;\n\n\tlet globalState = null,\n\t\tnumGlobalPlanes = 0,\n\t\tlocalClippingEnabled = false,\n\t\trenderingShadows = false;\n\n\tconst plane = new Plane(),\n\t\tviewNormalMatrix = new Matrix3(),\n\n\t\tuniform = { value: null, needsUpdate: false };\n\n\tthis.uniform = uniform;\n\tthis.numPlanes = 0;\n\tthis.numIntersection = 0;\n\n\tthis.init = function ( planes, enableLocalClipping, camera ) {\n\n\t\tconst enabled =\n\t\t\tplanes.length !== 0 ||\n\t\t\tenableLocalClipping ||\n\t\t\t// enable state of previous frame - the clipping code has to\n\t\t\t// run another frame in order to reset the state:\n\t\t\tnumGlobalPlanes !== 0 ||\n\t\t\tlocalClippingEnabled;\n\n\t\tlocalClippingEnabled = enableLocalClipping;\n\n\t\tglobalState = projectPlanes( planes, camera, 0 );\n\t\tnumGlobalPlanes = planes.length;\n\n\t\treturn enabled;\n\n\t};\n\n\tthis.beginShadows = function () {\n\n\t\trenderingShadows = true;\n\t\tprojectPlanes( null );\n\n\t};\n\n\tthis.endShadows = function () {\n\n\t\trenderingShadows = false;\n\t\tresetGlobalState();\n\n\t};\n\n\tthis.setState = function ( planes, clipIntersection, clipShadows, camera, cache, fromCache ) {\n\n\t\tif ( ! localClippingEnabled || planes === null || planes.length === 0 || renderingShadows && ! clipShadows ) {\n\n\t\t\t// there's no local clipping\n\n\t\t\tif ( renderingShadows ) {\n\n\t\t\t\t// there's no global clipping\n\n\t\t\t\tprojectPlanes( null );\n\n\t\t\t} else {\n\n\t\t\t\tresetGlobalState();\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tconst nGlobal = renderingShadows ? 0 : numGlobalPlanes,\n\t\t\t\tlGlobal = nGlobal * 4;\n\n\t\t\tlet dstArray = cache.clippingState || null;\n\n\t\t\tuniform.value = dstArray; // ensure unique state\n\n\t\t\tdstArray = projectPlanes( planes, camera, lGlobal, fromCache );\n\n\t\t\tfor ( let i = 0; i !== lGlobal; ++ i ) {\n\n\t\t\t\tdstArray[ i ] = globalState[ i ];\n\n\t\t\t}\n\n\t\t\tcache.clippingState = dstArray;\n\t\t\tthis.numIntersection = clipIntersection ? this.numPlanes : 0;\n\t\t\tthis.numPlanes += nGlobal;\n\n\t\t}\n\n\n\t};\n\n\tfunction resetGlobalState() {\n\n\t\tif ( uniform.value !== globalState ) {\n\n\t\t\tuniform.value = globalState;\n\t\t\tuniform.needsUpdate = numGlobalPlanes > 0;\n\n\t\t}\n\n\t\tscope.numPlanes = numGlobalPlanes;\n\t\tscope.numIntersection = 0;\n\n\t}\n\n\tfunction projectPlanes( planes, camera, dstOffset, skipTransform ) {\n\n\t\tlet nPlanes = planes !== null ? planes.length : 0,\n\t\t\tdstArray = null;\n\n\t\tif ( nPlanes !== 0 ) {\n\n\t\t\tdstArray = uniform.value;\n\n\t\t\tif ( skipTransform !== true || dstArray === null ) {\n\n\t\t\t\tconst flatSize = dstOffset + nPlanes * 4,\n\t\t\t\t\tviewMatrix = camera.matrixWorldInverse;\n\n\t\t\t\tviewNormalMatrix.getNormalMatrix( viewMatrix );\n\n\t\t\t\tif ( dstArray === null || dstArray.length < flatSize ) {\n\n\t\t\t\t\tdstArray = new Float32Array( flatSize );\n\n\t\t\t\t}\n\n\t\t\t\tfor ( let i = 0, i4 = dstOffset; i !== nPlanes; ++ i, i4 += 4 ) {\n\n\t\t\t\t\tplane.copy( planes[ i ] ).applyMatrix4( viewMatrix, viewNormalMatrix );\n\n\t\t\t\t\tplane.normal.toArray( dstArray, i4 );\n\t\t\t\t\tdstArray[ i4 + 3 ] = plane.constant;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tuniform.value = dstArray;\n\t\t\tuniform.needsUpdate = true;\n\n\t\t}\n\n\t\tscope.numPlanes = nPlanes;\n\t\tscope.numIntersection = 0;\n\n\t\treturn dstArray;\n\n\t}\n\n}\n\n\nexport { WebGLClipping };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction WebGLExtensions( gl ) {\n\n\tconst extensions = {};\n\n\treturn {\n\n\t\tget: function ( name ) {\n\n\t\t\tif ( extensions[ name ] !== undefined ) {\n\n\t\t\t\treturn extensions[ name ];\n\n\t\t\t}\n\n\t\t\tlet extension;\n\n\t\t\tswitch ( name ) {\n\n\t\t\t\tcase 'WEBGL_depth_texture':\n\t\t\t\t\textension = gl.getExtension( 'WEBGL_depth_texture' ) || gl.getExtension( 'MOZ_WEBGL_depth_texture' ) || gl.getExtension( 'WEBKIT_WEBGL_depth_texture' );\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'EXT_texture_filter_anisotropic':\n\t\t\t\t\textension = gl.getExtension( 'EXT_texture_filter_anisotropic' ) || gl.getExtension( 'MOZ_EXT_texture_filter_anisotropic' ) || gl.getExtension( 'WEBKIT_EXT_texture_filter_anisotropic' );\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'WEBGL_compressed_texture_s3tc':\n\t\t\t\t\textension = gl.getExtension( 'WEBGL_compressed_texture_s3tc' ) || gl.getExtension( 'MOZ_WEBGL_compressed_texture_s3tc' ) || gl.getExtension( 'WEBKIT_WEBGL_compressed_texture_s3tc' );\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'WEBGL_compressed_texture_pvrtc':\n\t\t\t\t\textension = gl.getExtension( 'WEBGL_compressed_texture_pvrtc' ) || gl.getExtension( 'WEBKIT_WEBGL_compressed_texture_pvrtc' );\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\t\t\t\t\textension = gl.getExtension( name );\n\n\t\t\t}\n\n\t\t\tif ( extension === null ) {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: ' + name + ' extension not supported.' );\n\n\t\t\t}\n\n\t\t\textensions[ name ] = extension;\n\n\t\t\treturn extension;\n\n\t\t}\n\n\t};\n\n}\n\n\nexport { WebGLExtensions };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { Uint16BufferAttribute, Uint32BufferAttribute } from '../../core/BufferAttribute.js';\nimport { BufferGeometry } from '../../core/BufferGeometry.js';\nimport { arrayMax } from '../../utils.js';\n\nfunction WebGLGeometries( gl, attributes, info, bindingStates ) {\n\n\tconst geometries = new WeakMap();\n\tconst wireframeAttributes = new WeakMap();\n\n\tfunction onGeometryDispose( event ) {\n\n\t\tconst geometry = event.target;\n\t\tconst buffergeometry = geometries.get( geometry );\n\n\t\tif ( buffergeometry.index !== null ) {\n\n\t\t\tattributes.remove( buffergeometry.index );\n\n\t\t}\n\n\t\tfor ( const name in buffergeometry.attributes ) {\n\n\t\t\tattributes.remove( buffergeometry.attributes[ name ] );\n\n\t\t}\n\n\t\tgeometry.removeEventListener( 'dispose', onGeometryDispose );\n\n\t\tgeometries.delete( geometry );\n\n\t\tconst attribute = wireframeAttributes.get( buffergeometry );\n\n\t\tif ( attribute ) {\n\n\t\t\tattributes.remove( attribute );\n\t\t\twireframeAttributes.delete( buffergeometry );\n\n\t\t}\n\n\t\tbindingStates.releaseStatesOfGeometry( geometry );\n\n\t\tif ( geometry.isInstancedBufferGeometry === true ) {\n\n\t\t\tdelete geometry._maxInstanceCount;\n\n\t\t}\n\n\t\t//\n\n\t\tinfo.memory.geometries --;\n\n\t}\n\n\tfunction get( object, geometry ) {\n\n\t\tlet buffergeometry = geometries.get( geometry );\n\n\t\tif ( buffergeometry ) return buffergeometry;\n\n\t\tgeometry.addEventListener( 'dispose', onGeometryDispose );\n\n\t\tif ( geometry.isBufferGeometry ) {\n\n\t\t\tbuffergeometry = geometry;\n\n\t\t} else if ( geometry.isGeometry ) {\n\n\t\t\tif ( geometry._bufferGeometry === undefined ) {\n\n\t\t\t\tgeometry._bufferGeometry = new BufferGeometry().setFromObject( object );\n\n\t\t\t}\n\n\t\t\tbuffergeometry = geometry._bufferGeometry;\n\n\t\t}\n\n\t\tgeometries.set( geometry, buffergeometry );\n\n\t\tinfo.memory.geometries ++;\n\n\t\treturn buffergeometry;\n\n\t}\n\n\tfunction update( geometry ) {\n\n\t\tconst geometryAttributes = geometry.attributes;\n\n\t\t// Updating index buffer in VAO now. See WebGLBindingStates.\n\n\t\tfor ( const name in geometryAttributes ) {\n\n\t\t\tattributes.update( geometryAttributes[ name ], gl.ARRAY_BUFFER );\n\n\t\t}\n\n\t\t// morph targets\n\n\t\tconst morphAttributes = geometry.morphAttributes;\n\n\t\tfor ( const name in morphAttributes ) {\n\n\t\t\tconst array = morphAttributes[ name ];\n\n\t\t\tfor ( let i = 0, l = array.length; i < l; i ++ ) {\n\n\t\t\t\tattributes.update( array[ i ], gl.ARRAY_BUFFER );\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tfunction updateWireframeAttribute( geometry ) {\n\n\t\tconst indices = [];\n\n\t\tconst geometryIndex = geometry.index;\n\t\tconst geometryPosition = geometry.attributes.position;\n\t\tlet version = 0;\n\n\t\tif ( geometryIndex !== null ) {\n\n\t\t\tconst array = geometryIndex.array;\n\t\t\tversion = geometryIndex.version;\n\n\t\t\tfor ( let i = 0, l = array.length; i < l; i += 3 ) {\n\n\t\t\t\tconst a = array[ i + 0 ];\n\t\t\t\tconst b = array[ i + 1 ];\n\t\t\t\tconst c = array[ i + 2 ];\n\n\t\t\t\tindices.push( a, b, b, c, c, a );\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tconst array = geometryPosition.array;\n\t\t\tversion = geometryPosition.version;\n\n\t\t\tfor ( let i = 0, l = ( array.length / 3 ) - 1; i < l; i += 3 ) {\n\n\t\t\t\tconst a = i + 0;\n\t\t\t\tconst b = i + 1;\n\t\t\t\tconst c = i + 2;\n\n\t\t\t\tindices.push( a, b, b, c, c, a );\n\n\t\t\t}\n\n\t\t}\n\n\t\tconst attribute = new ( arrayMax( indices ) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute )( indices, 1 );\n\t\tattribute.version = version;\n\n\t\t// Updating index buffer in VAO now. See WebGLBindingStates\n\n\t\t//\n\n\t\tconst previousAttribute = wireframeAttributes.get( geometry );\n\n\t\tif ( previousAttribute ) attributes.remove( previousAttribute );\n\n\t\t//\n\n\t\twireframeAttributes.set( geometry, attribute );\n\n\t}\n\n\tfunction getWireframeAttribute( geometry ) {\n\n\t\tconst currentAttribute = wireframeAttributes.get( geometry );\n\n\t\tif ( currentAttribute ) {\n\n\t\t\tconst geometryIndex = geometry.index;\n\n\t\t\tif ( geometryIndex !== null ) {\n\n\t\t\t\t// if the attribute is obsolete, create a new one\n\n\t\t\t\tif ( currentAttribute.version < geometryIndex.version ) {\n\n\t\t\t\t\tupdateWireframeAttribute( geometry );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tupdateWireframeAttribute( geometry );\n\n\t\t}\n\n\t\treturn wireframeAttributes.get( geometry );\n\n\t}\n\n\treturn {\n\n\t\tget: get,\n\t\tupdate: update,\n\n\t\tgetWireframeAttribute: getWireframeAttribute\n\n\t};\n\n}\n\n\nexport { WebGLGeometries };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction WebGLIndexedBufferRenderer( gl, extensions, info, capabilities ) {\n\n\tconst isWebGL2 = capabilities.isWebGL2;\n\n\tlet mode;\n\n\tfunction setMode( value ) {\n\n\t\tmode = value;\n\n\t}\n\n\tlet type, bytesPerElement;\n\n\tfunction setIndex( value ) {\n\n\t\ttype = value.type;\n\t\tbytesPerElement = value.bytesPerElement;\n\n\t}\n\n\tfunction render( start, count ) {\n\n\t\tgl.drawElements( mode, count, type, start * bytesPerElement );\n\n\t\tinfo.update( count, mode );\n\n\t}\n\n\tfunction renderInstances( geometry, start, count, primcount ) {\n\n\t\tif ( primcount === 0 ) return;\n\n\t\tlet extension, methodName;\n\n\t\tif ( isWebGL2 ) {\n\n\t\t\textension = gl;\n\t\t\tmethodName = 'drawElementsInstanced';\n\n\t\t} else {\n\n\t\t\textension = extensions.get( 'ANGLE_instanced_arrays' );\n\t\t\tmethodName = 'drawElementsInstancedANGLE';\n\n\t\t\tif ( extension === null ) {\n\n\t\t\t\tconsole.error( 'THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.' );\n\t\t\t\treturn;\n\n\t\t\t}\n\n\t\t}\n\n\t\textension[ methodName ]( mode, count, type, start * bytesPerElement, primcount );\n\n\t\tinfo.update( count, mode, primcount );\n\n\t}\n\n\t//\n\n\tthis.setMode = setMode;\n\tthis.setIndex = setIndex;\n\tthis.render = render;\n\tthis.renderInstances = renderInstances;\n\n}\n\n\nexport { WebGLIndexedBufferRenderer };\n","/**\n * @author Mugen87 / https://github.com/Mugen87\n */\n\nfunction WebGLInfo( gl ) {\n\n\tconst memory = {\n\t\tgeometries: 0,\n\t\ttextures: 0\n\t};\n\n\tconst render = {\n\t\tframe: 0,\n\t\tcalls: 0,\n\t\ttriangles: 0,\n\t\tpoints: 0,\n\t\tlines: 0\n\t};\n\n\tfunction update( count, mode, instanceCount ) {\n\n\t\tinstanceCount = instanceCount || 1;\n\n\t\trender.calls ++;\n\n\t\tswitch ( mode ) {\n\n\t\t\tcase gl.TRIANGLES:\n\t\t\t\trender.triangles += instanceCount * ( count / 3 );\n\t\t\t\tbreak;\n\n\t\t\tcase gl.LINES:\n\t\t\t\trender.lines += instanceCount * ( count / 2 );\n\t\t\t\tbreak;\n\n\t\t\tcase gl.LINE_STRIP:\n\t\t\t\trender.lines += instanceCount * ( count - 1 );\n\t\t\t\tbreak;\n\n\t\t\tcase gl.LINE_LOOP:\n\t\t\t\trender.lines += instanceCount * count;\n\t\t\t\tbreak;\n\n\t\t\tcase gl.POINTS:\n\t\t\t\trender.points += instanceCount * count;\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tconsole.error( 'THREE.WebGLInfo: Unknown draw mode:', mode );\n\t\t\t\tbreak;\n\n\t\t}\n\n\t}\n\n\tfunction reset() {\n\n\t\trender.frame ++;\n\t\trender.calls = 0;\n\t\trender.triangles = 0;\n\t\trender.points = 0;\n\t\trender.lines = 0;\n\n\t}\n\n\treturn {\n\t\tmemory: memory,\n\t\trender: render,\n\t\tprograms: null,\n\t\tautoReset: true,\n\t\treset: reset,\n\t\tupdate: update\n\t};\n\n}\n\n\nexport { WebGLInfo };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction numericalSort( a, b ) {\n\n\treturn a[ 0 ] - b[ 0 ];\n\n}\n\nfunction absNumericalSort( a, b ) {\n\n\treturn Math.abs( b[ 1 ] ) - Math.abs( a[ 1 ] );\n\n}\n\nfunction WebGLMorphtargets( gl ) {\n\n\tconst influencesList = {};\n\tconst morphInfluences = new Float32Array( 8 );\n\n\tconst workInfluences = [];\n\n\tfor ( let i = 0; i < 8; i ++ ) {\n\n\t\tworkInfluences[ i ] = [ i, 0 ];\n\n\t}\n\n\tfunction update( object, geometry, material, program ) {\n\n\t\tconst objectInfluences = object.morphTargetInfluences;\n\n\t\t// When object doesn't have morph target influences defined, we treat it as a 0-length array\n\t\t// This is important to make sure we set up morphTargetBaseInfluence / morphTargetInfluences\n\n\t\tconst length = objectInfluences === undefined ? 0 : objectInfluences.length;\n\n\t\tlet influences = influencesList[ geometry.id ];\n\n\t\tif ( influences === undefined ) {\n\n\t\t\t// initialise list\n\n\t\t\tinfluences = [];\n\n\t\t\tfor ( let i = 0; i < length; i ++ ) {\n\n\t\t\t\tinfluences[ i ] = [ i, 0 ];\n\n\t\t\t}\n\n\t\t\tinfluencesList[ geometry.id ] = influences;\n\n\t\t}\n\n\t\t// Collect influences\n\n\t\tfor ( let i = 0; i < length; i ++ ) {\n\n\t\t\tconst influence = influences[ i ];\n\n\t\t\tinfluence[ 0 ] = i;\n\t\t\tinfluence[ 1 ] = objectInfluences[ i ];\n\n\t\t}\n\n\t\tinfluences.sort( absNumericalSort );\n\n\t\tfor ( let i = 0; i < 8; i ++ ) {\n\n\t\t\tif ( i < length && influences[ i ][ 1 ] ) {\n\n\t\t\t\tworkInfluences[ i ][ 0 ] = influences[ i ][ 0 ];\n\t\t\t\tworkInfluences[ i ][ 1 ] = influences[ i ][ 1 ];\n\n\t\t\t} else {\n\n\t\t\t\tworkInfluences[ i ][ 0 ] = Number.MAX_SAFE_INTEGER;\n\t\t\t\tworkInfluences[ i ][ 1 ] = 0;\n\n\t\t\t}\n\n\t\t}\n\n\t\tworkInfluences.sort( numericalSort );\n\n\t\tconst morphTargets = material.morphTargets && geometry.morphAttributes.position;\n\t\tconst morphNormals = material.morphNormals && geometry.morphAttributes.normal;\n\n\t\tlet morphInfluencesSum = 0;\n\n\t\tfor ( let i = 0; i < 8; i ++ ) {\n\n\t\t\tconst influence = workInfluences[ i ];\n\t\t\tconst index = influence[ 0 ];\n\t\t\tconst value = influence[ 1 ];\n\n\t\t\tif ( index !== Number.MAX_SAFE_INTEGER && value ) {\n\n\t\t\t\tif ( morphTargets && geometry.getAttribute( 'morphTarget' + i ) !== morphTargets[ index ] ) {\n\n\t\t\t\t\tgeometry.setAttribute( 'morphTarget' + i, morphTargets[ index ] );\n\n\t\t\t\t}\n\n\t\t\t\tif ( morphNormals && geometry.getAttribute( 'morphNormal' + i ) !== morphNormals[ index ] ) {\n\n\t\t\t\t\tgeometry.setAttribute( 'morphNormal' + i, morphNormals[ index ] );\n\n\t\t\t\t}\n\n\t\t\t\tmorphInfluences[ i ] = value;\n\t\t\t\tmorphInfluencesSum += value;\n\n\t\t\t} else {\n\n\t\t\t\tif ( morphTargets && geometry.getAttribute( 'morphTarget' + i ) !== undefined ) {\n\n\t\t\t\t\tgeometry.deleteAttribute( 'morphTarget' + i );\n\n\t\t\t\t}\n\n\t\t\t\tif ( morphNormals && geometry.getAttribute( 'morphNormal' + i ) !== undefined ) {\n\n\t\t\t\t\tgeometry.deleteAttribute( 'morphNormal' + i );\n\n\t\t\t\t}\n\n\t\t\t\tmorphInfluences[ i ] = 0;\n\n\t\t\t}\n\n\t\t}\n\n\t\t// GLSL shader uses formula baseinfluence * base + sum(target * influence)\n\t\t// This allows us to switch between absolute morphs and relative morphs without changing shader code\n\t\t// When baseinfluence = 1 - sum(influence), the above is equivalent to sum((target - base) * influence)\n\t\tconst morphBaseInfluence = geometry.morphTargetsRelative ? 1 : 1 - morphInfluencesSum;\n\n\t\tprogram.getUniforms().setValue( gl, 'morphTargetBaseInfluence', morphBaseInfluence );\n\t\tprogram.getUniforms().setValue( gl, 'morphTargetInfluences', morphInfluences );\n\n\t}\n\n\treturn {\n\n\t\tupdate: update\n\n\t};\n\n}\n\n\nexport { WebGLMorphtargets };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction WebGLObjects( gl, geometries, attributes, info ) {\n\n\tlet updateMap = new WeakMap();\n\n\tfunction update( object ) {\n\n\t\tconst frame = info.render.frame;\n\n\t\tconst geometry = object.geometry;\n\t\tconst buffergeometry = geometries.get( object, geometry );\n\n\t\t// Update once per frame\n\n\t\tif ( updateMap.get( buffergeometry ) !== frame ) {\n\n\t\t\tif ( geometry.isGeometry ) {\n\n\t\t\t\tbuffergeometry.updateFromObject( object );\n\n\t\t\t}\n\n\t\t\tgeometries.update( buffergeometry );\n\n\t\t\tupdateMap.set( buffergeometry, frame );\n\n\t\t}\n\n\t\tif ( object.isInstancedMesh ) {\n\n\t\t\tattributes.update( object.instanceMatrix, gl.ARRAY_BUFFER );\n\n\t\t}\n\n\t\treturn buffergeometry;\n\n\t}\n\n\tfunction dispose() {\n\n\t\tupdateMap = new WeakMap();\n\n\t}\n\n\treturn {\n\n\t\tupdate: update,\n\t\tdispose: dispose\n\n\t};\n\n}\n\n\nexport { WebGLObjects };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { Texture } from './Texture.js';\nimport { CubeReflectionMapping, RGBFormat } from '../constants.js';\n\nfunction CubeTexture( images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ) {\n\n\timages = images !== undefined ? images : [];\n\tmapping = mapping !== undefined ? mapping : CubeReflectionMapping;\n\tformat = format !== undefined ? format : RGBFormat;\n\n\tTexture.call( this, images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding );\n\n\tthis.flipY = false;\n\n}\n\nCubeTexture.prototype = Object.create( Texture.prototype );\nCubeTexture.prototype.constructor = CubeTexture;\n\nCubeTexture.prototype.isCubeTexture = true;\n\nObject.defineProperty( CubeTexture.prototype, 'images', {\n\n\tget: function () {\n\n\t\treturn this.image;\n\n\t},\n\n\tset: function ( value ) {\n\n\t\tthis.image = value;\n\n\t}\n\n} );\n\n\nexport { CubeTexture };\n","/**\n * @author Takahiro https://github.com/takahirox\n */\n\nimport { Texture } from './Texture.js';\nimport { ClampToEdgeWrapping, NearestFilter } from '../constants.js';\n\nfunction DataTexture2DArray( data, width, height, depth ) {\n\n\tTexture.call( this, null );\n\n\tthis.image = { data: data || null, width: width || 1, height: height || 1, depth: depth || 1 };\n\n\tthis.magFilter = NearestFilter;\n\tthis.minFilter = NearestFilter;\n\n\tthis.wrapR = ClampToEdgeWrapping;\n\n\tthis.generateMipmaps = false;\n\tthis.flipY = false;\n\n\tthis.needsUpdate = true;\n\n}\n\nDataTexture2DArray.prototype = Object.create( Texture.prototype );\nDataTexture2DArray.prototype.constructor = DataTexture2DArray;\nDataTexture2DArray.prototype.isDataTexture2DArray = true;\n\nexport { DataTexture2DArray };\n","/**\n * @author Artur Trzesiok\n */\n\nimport { Texture } from './Texture.js';\nimport { ClampToEdgeWrapping, NearestFilter } from '../constants.js';\n\nfunction DataTexture3D( data, width, height, depth ) {\n\n\t// We're going to add .setXXX() methods for setting properties later.\n\t// Users can still set in DataTexture3D directly.\n\t//\n\t//\tconst texture = new THREE.DataTexture3D( data, width, height, depth );\n\t// \ttexture.anisotropy = 16;\n\t//\n\t// See #14839\n\n\tTexture.call( this, null );\n\n\tthis.image = { data: data || null, width: width || 1, height: height || 1, depth: depth || 1 };\n\n\tthis.magFilter = NearestFilter;\n\tthis.minFilter = NearestFilter;\n\n\tthis.wrapR = ClampToEdgeWrapping;\n\n\tthis.generateMipmaps = false;\n\tthis.flipY = false;\n\n\tthis.needsUpdate = true;\n\n\n}\n\nDataTexture3D.prototype = Object.create( Texture.prototype );\nDataTexture3D.prototype.constructor = DataTexture3D;\nDataTexture3D.prototype.isDataTexture3D = true;\n\nexport { DataTexture3D };\n","/**\n * @author tschw\n * @author Mugen87 / https://github.com/Mugen87\n * @author mrdoob / http://mrdoob.com/\n *\n * Uniforms of a program.\n * Those form a tree structure with a special top-level container for the root,\n * which you get by calling 'new WebGLUniforms( gl, program )'.\n *\n *\n * Properties of inner nodes including the top-level container:\n *\n * .seq - array of nested uniforms\n * .map - nested uniforms by name\n *\n *\n * Methods of all nodes except the top-level container:\n *\n * .setValue( gl, value, [textures] )\n *\n * \t\tuploads a uniform value(s)\n * \tthe 'textures' parameter is needed for sampler uniforms\n *\n *\n * Static methods of the top-level container (textures factorizations):\n *\n * .upload( gl, seq, values, textures )\n *\n * \t\tsets uniforms in 'seq' to 'values[id].value'\n *\n * .seqWithValue( seq, values ) : filteredSeq\n *\n * \t\tfilters 'seq' entries with corresponding entry in values\n *\n *\n * Methods of the top-level container (textures factorizations):\n *\n * .setValue( gl, name, value, textures )\n *\n * \t\tsets uniform with name 'name' to 'value'\n *\n * .setOptional( gl, obj, prop )\n *\n * \t\tlike .set for an optional property of the object\n *\n */\n\nimport { CubeTexture } from '../../textures/CubeTexture.js';\nimport { Texture } from '../../textures/Texture.js';\nimport { DataTexture2DArray } from '../../textures/DataTexture2DArray.js';\nimport { DataTexture3D } from '../../textures/DataTexture3D.js';\n\nconst emptyTexture = new Texture();\nconst emptyTexture2dArray = new DataTexture2DArray();\nconst emptyTexture3d = new DataTexture3D();\nconst emptyCubeTexture = new CubeTexture();\n\n// --- Utilities ---\n\n// Array Caches (provide typed arrays for temporary by size)\n\nconst arrayCacheF32 = [];\nconst arrayCacheI32 = [];\n\n// Float32Array caches used for uploading Matrix uniforms\n\nconst mat4array = new Float32Array( 16 );\nconst mat3array = new Float32Array( 9 );\nconst mat2array = new Float32Array( 4 );\n\n// Flattening for arrays of vectors and matrices\n\nfunction flatten( array, nBlocks, blockSize ) {\n\n\tconst firstElem = array[ 0 ];\n\n\tif ( firstElem <= 0 || firstElem > 0 ) return array;\n\t// unoptimized: ! isNaN( firstElem )\n\t// see http://jacksondunstan.com/articles/983\n\n\tlet n = nBlocks * blockSize,\n\t\tr = arrayCacheF32[ n ];\n\n\tif ( r === undefined ) {\n\n\t\tr = new Float32Array( n );\n\t\tarrayCacheF32[ n ] = r;\n\n\t}\n\n\tif ( nBlocks !== 0 ) {\n\n\t\tfirstElem.toArray( r, 0 );\n\n\t\tfor ( let i = 1, offset = 0; i !== nBlocks; ++ i ) {\n\n\t\t\toffset += blockSize;\n\t\t\tarray[ i ].toArray( r, offset );\n\n\t\t}\n\n\t}\n\n\treturn r;\n\n}\n\nfunction arraysEqual( a, b ) {\n\n\tif ( a.length !== b.length ) return false;\n\n\tfor ( let i = 0, l = a.length; i < l; i ++ ) {\n\n\t\tif ( a[ i ] !== b[ i ] ) return false;\n\n\t}\n\n\treturn true;\n\n}\n\nfunction copyArray( a, b ) {\n\n\tfor ( let i = 0, l = b.length; i < l; i ++ ) {\n\n\t\ta[ i ] = b[ i ];\n\n\t}\n\n}\n\n// Texture unit allocation\n\nfunction allocTexUnits( textures, n ) {\n\n\tlet r = arrayCacheI32[ n ];\n\n\tif ( r === undefined ) {\n\n\t\tr = new Int32Array( n );\n\t\tarrayCacheI32[ n ] = r;\n\n\t}\n\n\tfor ( let i = 0; i !== n; ++ i ) {\n\n\t\tr[ i ] = textures.allocateTextureUnit();\n\n\t}\n\n\treturn r;\n\n}\n\n// --- Setters ---\n\n// Note: Defining these methods externally, because they come in a bunch\n// and this way their names minify.\n\n// Single scalar\n\nfunction setValueV1f( gl, v ) {\n\n\tconst cache = this.cache;\n\n\tif ( cache[ 0 ] === v ) return;\n\n\tgl.uniform1f( this.addr, v );\n\n\tcache[ 0 ] = v;\n\n}\n\n// Single float vector (from flat array or THREE.VectorN)\n\nfunction setValueV2f( gl, v ) {\n\n\tconst cache = this.cache;\n\n\tif ( v.x !== undefined ) {\n\n\t\tif ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y ) {\n\n\t\t\tgl.uniform2f( this.addr, v.x, v.y );\n\n\t\t\tcache[ 0 ] = v.x;\n\t\t\tcache[ 1 ] = v.y;\n\n\t\t}\n\n\t} else {\n\n\t\tif ( arraysEqual( cache, v ) ) return;\n\n\t\tgl.uniform2fv( this.addr, v );\n\n\t\tcopyArray( cache, v );\n\n\t}\n\n}\n\nfunction setValueV3f( gl, v ) {\n\n\tconst cache = this.cache;\n\n\tif ( v.x !== undefined ) {\n\n\t\tif ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y || cache[ 2 ] !== v.z ) {\n\n\t\t\tgl.uniform3f( this.addr, v.x, v.y, v.z );\n\n\t\t\tcache[ 0 ] = v.x;\n\t\t\tcache[ 1 ] = v.y;\n\t\t\tcache[ 2 ] = v.z;\n\n\t\t}\n\n\t} else if ( v.r !== undefined ) {\n\n\t\tif ( cache[ 0 ] !== v.r || cache[ 1 ] !== v.g || cache[ 2 ] !== v.b ) {\n\n\t\t\tgl.uniform3f( this.addr, v.r, v.g, v.b );\n\n\t\t\tcache[ 0 ] = v.r;\n\t\t\tcache[ 1 ] = v.g;\n\t\t\tcache[ 2 ] = v.b;\n\n\t\t}\n\n\t} else {\n\n\t\tif ( arraysEqual( cache, v ) ) return;\n\n\t\tgl.uniform3fv( this.addr, v );\n\n\t\tcopyArray( cache, v );\n\n\t}\n\n}\n\nfunction setValueV4f( gl, v ) {\n\n\tconst cache = this.cache;\n\n\tif ( v.x !== undefined ) {\n\n\t\tif ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y || cache[ 2 ] !== v.z || cache[ 3 ] !== v.w ) {\n\n\t\t\tgl.uniform4f( this.addr, v.x, v.y, v.z, v.w );\n\n\t\t\tcache[ 0 ] = v.x;\n\t\t\tcache[ 1 ] = v.y;\n\t\t\tcache[ 2 ] = v.z;\n\t\t\tcache[ 3 ] = v.w;\n\n\t\t}\n\n\t} else {\n\n\t\tif ( arraysEqual( cache, v ) ) return;\n\n\t\tgl.uniform4fv( this.addr, v );\n\n\t\tcopyArray( cache, v );\n\n\t}\n\n}\n\n// Single matrix (from flat array or MatrixN)\n\nfunction setValueM2( gl, v ) {\n\n\tconst cache = this.cache;\n\tconst elements = v.elements;\n\n\tif ( elements === undefined ) {\n\n\t\tif ( arraysEqual( cache, v ) ) return;\n\n\t\tgl.uniformMatrix2fv( this.addr, false, v );\n\n\t\tcopyArray( cache, v );\n\n\t} else {\n\n\t\tif ( arraysEqual( cache, elements ) ) return;\n\n\t\tmat2array.set( elements );\n\n\t\tgl.uniformMatrix2fv( this.addr, false, mat2array );\n\n\t\tcopyArray( cache, elements );\n\n\t}\n\n}\n\nfunction setValueM3( gl, v ) {\n\n\tconst cache = this.cache;\n\tconst elements = v.elements;\n\n\tif ( elements === undefined ) {\n\n\t\tif ( arraysEqual( cache, v ) ) return;\n\n\t\tgl.uniformMatrix3fv( this.addr, false, v );\n\n\t\tcopyArray( cache, v );\n\n\t} else {\n\n\t\tif ( arraysEqual( cache, elements ) ) return;\n\n\t\tmat3array.set( elements );\n\n\t\tgl.uniformMatrix3fv( this.addr, false, mat3array );\n\n\t\tcopyArray( cache, elements );\n\n\t}\n\n}\n\nfunction setValueM4( gl, v ) {\n\n\tconst cache = this.cache;\n\tconst elements = v.elements;\n\n\tif ( elements === undefined ) {\n\n\t\tif ( arraysEqual( cache, v ) ) return;\n\n\t\tgl.uniformMatrix4fv( this.addr, false, v );\n\n\t\tcopyArray( cache, v );\n\n\t} else {\n\n\t\tif ( arraysEqual( cache, elements ) ) return;\n\n\t\tmat4array.set( elements );\n\n\t\tgl.uniformMatrix4fv( this.addr, false, mat4array );\n\n\t\tcopyArray( cache, elements );\n\n\t}\n\n}\n\n// Single texture (2D / Cube)\n\nfunction setValueT1( gl, v, textures ) {\n\n\tconst cache = this.cache;\n\tconst unit = textures.allocateTextureUnit();\n\n\tif ( cache[ 0 ] !== unit ) {\n\n\t\tgl.uniform1i( this.addr, unit );\n\t\tcache[ 0 ] = unit;\n\n\t}\n\n\ttextures.safeSetTexture2D( v || emptyTexture, unit );\n\n}\n\nfunction setValueT2DArray1( gl, v, textures ) {\n\n\tconst cache = this.cache;\n\tconst unit = textures.allocateTextureUnit();\n\n\tif ( cache[ 0 ] !== unit ) {\n\n\t\tgl.uniform1i( this.addr, unit );\n\t\tcache[ 0 ] = unit;\n\n\t}\n\n\ttextures.setTexture2DArray( v || emptyTexture2dArray, unit );\n\n}\n\nfunction setValueT3D1( gl, v, textures ) {\n\n\tconst cache = this.cache;\n\tconst unit = textures.allocateTextureUnit();\n\n\tif ( cache[ 0 ] !== unit ) {\n\n\t\tgl.uniform1i( this.addr, unit );\n\t\tcache[ 0 ] = unit;\n\n\t}\n\n\ttextures.setTexture3D( v || emptyTexture3d, unit );\n\n}\n\nfunction setValueT6( gl, v, textures ) {\n\n\tconst cache = this.cache;\n\tconst unit = textures.allocateTextureUnit();\n\n\tif ( cache[ 0 ] !== unit ) {\n\n\t\tgl.uniform1i( this.addr, unit );\n\t\tcache[ 0 ] = unit;\n\n\t}\n\n\ttextures.safeSetTextureCube( v || emptyCubeTexture, unit );\n\n}\n\n// Integer / Boolean vectors or arrays thereof (always flat arrays)\n\nfunction setValueV1i( gl, v ) {\n\n\tconst cache = this.cache;\n\n\tif ( cache[ 0 ] === v ) return;\n\n\tgl.uniform1i( this.addr, v );\n\n\tcache[ 0 ] = v;\n\n}\n\nfunction setValueV2i( gl, v ) {\n\n\tconst cache = this.cache;\n\n\tif ( arraysEqual( cache, v ) ) return;\n\n\tgl.uniform2iv( this.addr, v );\n\n\tcopyArray( cache, v );\n\n}\n\nfunction setValueV3i( gl, v ) {\n\n\tconst cache = this.cache;\n\n\tif ( arraysEqual( cache, v ) ) return;\n\n\tgl.uniform3iv( this.addr, v );\n\n\tcopyArray( cache, v );\n\n}\n\nfunction setValueV4i( gl, v ) {\n\n\tconst cache = this.cache;\n\n\tif ( arraysEqual( cache, v ) ) return;\n\n\tgl.uniform4iv( this.addr, v );\n\n\tcopyArray( cache, v );\n\n}\n\n// uint\n\nfunction setValueV1ui( gl, v ) {\n\n\tconst cache = this.cache;\n\n\tif ( cache[ 0 ] === v ) return;\n\n\tgl.uniform1ui( this.addr, v );\n\n\tcache[ 0 ] = v;\n\n}\n\n// Helper to pick the right setter for the singular case\n\nfunction getSingularSetter( type ) {\n\n\tswitch ( type ) {\n\n\t\tcase 0x1406: return setValueV1f; // FLOAT\n\t\tcase 0x8b50: return setValueV2f; // _VEC2\n\t\tcase 0x8b51: return setValueV3f; // _VEC3\n\t\tcase 0x8b52: return setValueV4f; // _VEC4\n\n\t\tcase 0x8b5a: return setValueM2; // _MAT2\n\t\tcase 0x8b5b: return setValueM3; // _MAT3\n\t\tcase 0x8b5c: return setValueM4; // _MAT4\n\n\t\tcase 0x1404: case 0x8b56: return setValueV1i; // INT, BOOL\n\t\tcase 0x8b53: case 0x8b57: return setValueV2i; // _VEC2\n\t\tcase 0x8b54: case 0x8b58: return setValueV3i; // _VEC3\n\t\tcase 0x8b55: case 0x8b59: return setValueV4i; // _VEC4\n\n\t\tcase 0x1405: return setValueV1ui; // UINT\n\n\t\tcase 0x8b5e: // SAMPLER_2D\n\t\tcase 0x8d66: // SAMPLER_EXTERNAL_OES\n\t\tcase 0x8dca: // INT_SAMPLER_2D\n\t\tcase 0x8dd2: // UNSIGNED_INT_SAMPLER_2D\n\t\tcase 0x8b62: // SAMPLER_2D_SHADOW\n\t\t\treturn setValueT1;\n\n\t\tcase 0x8b5f: // SAMPLER_3D\n\t\tcase 0x8dcb: // INT_SAMPLER_3D\n\t\tcase 0x8dd3: // UNSIGNED_INT_SAMPLER_3D\n\t\t\treturn setValueT3D1;\n\n\t\tcase 0x8b60: // SAMPLER_CUBE\n\t\tcase 0x8dcc: // INT_SAMPLER_CUBE\n\t\tcase 0x8dd4: // UNSIGNED_INT_SAMPLER_CUBE\n\t\tcase 0x8dc5: // SAMPLER_CUBE_SHADOW\n\t\t\treturn setValueT6;\n\n\t\tcase 0x8dc1: // SAMPLER_2D_ARRAY\n\t\tcase 0x8dcf: // INT_SAMPLER_2D_ARRAY\n\t\tcase 0x8dd7: // UNSIGNED_INT_SAMPLER_2D_ARRAY\n\t\tcase 0x8dc4: // SAMPLER_2D_ARRAY_SHADOW\n\t\t\treturn setValueT2DArray1;\n\n\t}\n\n}\n\n// Array of scalars\nfunction setValueV1fArray( gl, v ) {\n\n\tgl.uniform1fv( this.addr, v );\n\n}\n\n// Integer / Boolean vectors or arrays thereof (always flat arrays)\nfunction setValueV1iArray( gl, v ) {\n\n\tgl.uniform1iv( this.addr, v );\n\n}\n\nfunction setValueV2iArray( gl, v ) {\n\n\tgl.uniform2iv( this.addr, v );\n\n}\n\nfunction setValueV3iArray( gl, v ) {\n\n\tgl.uniform3iv( this.addr, v );\n\n}\n\nfunction setValueV4iArray( gl, v ) {\n\n\tgl.uniform4iv( this.addr, v );\n\n}\n\n\n// Array of vectors (flat or from THREE classes)\n\nfunction setValueV2fArray( gl, v ) {\n\n\tconst data = flatten( v, this.size, 2 );\n\n\tgl.uniform2fv( this.addr, data );\n\n}\n\nfunction setValueV3fArray( gl, v ) {\n\n\tconst data = flatten( v, this.size, 3 );\n\n\tgl.uniform3fv( this.addr, data );\n\n}\n\nfunction setValueV4fArray( gl, v ) {\n\n\tconst data = flatten( v, this.size, 4 );\n\n\tgl.uniform4fv( this.addr, data );\n\n}\n\n// Array of matrices (flat or from THREE clases)\n\nfunction setValueM2Array( gl, v ) {\n\n\tconst data = flatten( v, this.size, 4 );\n\n\tgl.uniformMatrix2fv( this.addr, false, data );\n\n}\n\nfunction setValueM3Array( gl, v ) {\n\n\tconst data = flatten( v, this.size, 9 );\n\n\tgl.uniformMatrix3fv( this.addr, false, data );\n\n}\n\nfunction setValueM4Array( gl, v ) {\n\n\tconst data = flatten( v, this.size, 16 );\n\n\tgl.uniformMatrix4fv( this.addr, false, data );\n\n}\n\n// Array of textures (2D / Cube)\n\nfunction setValueT1Array( gl, v, textures ) {\n\n\tconst n = v.length;\n\n\tconst units = allocTexUnits( textures, n );\n\n\tgl.uniform1iv( this.addr, units );\n\n\tfor ( let i = 0; i !== n; ++ i ) {\n\n\t\ttextures.safeSetTexture2D( v[ i ] || emptyTexture, units[ i ] );\n\n\t}\n\n}\n\nfunction setValueT6Array( gl, v, textures ) {\n\n\tconst n = v.length;\n\n\tconst units = allocTexUnits( textures, n );\n\n\tgl.uniform1iv( this.addr, units );\n\n\tfor ( let i = 0; i !== n; ++ i ) {\n\n\t\ttextures.safeSetTextureCube( v[ i ] || emptyCubeTexture, units[ i ] );\n\n\t}\n\n}\n\n// Helper to pick the right setter for a pure (bottom-level) array\n\nfunction getPureArraySetter( type ) {\n\n\tswitch ( type ) {\n\n\t\tcase 0x1406: return setValueV1fArray; // FLOAT\n\t\tcase 0x8b50: return setValueV2fArray; // _VEC2\n\t\tcase 0x8b51: return setValueV3fArray; // _VEC3\n\t\tcase 0x8b52: return setValueV4fArray; // _VEC4\n\n\t\tcase 0x8b5a: return setValueM2Array; // _MAT2\n\t\tcase 0x8b5b: return setValueM3Array; // _MAT3\n\t\tcase 0x8b5c: return setValueM4Array; // _MAT4\n\n\t\tcase 0x1404: case 0x8b56: return setValueV1iArray; // INT, BOOL\n\t\tcase 0x8b53: case 0x8b57: return setValueV2iArray; // _VEC2\n\t\tcase 0x8b54: case 0x8b58: return setValueV3iArray; // _VEC3\n\t\tcase 0x8b55: case 0x8b59: return setValueV4iArray; // _VEC4\n\n\t\tcase 0x8b5e: // SAMPLER_2D\n\t\tcase 0x8d66: // SAMPLER_EXTERNAL_OES\n\t\tcase 0x8dca: // INT_SAMPLER_2D\n\t\tcase 0x8dd2: // UNSIGNED_INT_SAMPLER_2D\n\t\tcase 0x8b62: // SAMPLER_2D_SHADOW\n\t\t\treturn setValueT1Array;\n\n\t\tcase 0x8b60: // SAMPLER_CUBE\n\t\tcase 0x8dcc: // INT_SAMPLER_CUBE\n\t\tcase 0x8dd4: // UNSIGNED_INT_SAMPLER_CUBE\n\t\tcase 0x8dc5: // SAMPLER_CUBE_SHADOW\n\t\t\treturn setValueT6Array;\n\n\t}\n\n}\n\n// --- Uniform Classes ---\n\nfunction SingleUniform( id, activeInfo, addr ) {\n\n\tthis.id = id;\n\tthis.addr = addr;\n\tthis.cache = [];\n\tthis.setValue = getSingularSetter( activeInfo.type );\n\n\t// this.path = activeInfo.name; // DEBUG\n\n}\n\nfunction PureArrayUniform( id, activeInfo, addr ) {\n\n\tthis.id = id;\n\tthis.addr = addr;\n\tthis.cache = [];\n\tthis.size = activeInfo.size;\n\tthis.setValue = getPureArraySetter( activeInfo.type );\n\n\t// this.path = activeInfo.name; // DEBUG\n\n}\n\nPureArrayUniform.prototype.updateCache = function ( data ) {\n\n\tlet cache = this.cache;\n\n\tif ( data instanceof Float32Array && cache.length !== data.length ) {\n\n\t\tthis.cache = new Float32Array( data.length );\n\n\t}\n\n\tcopyArray( cache, data );\n\n};\n\nfunction StructuredUniform( id ) {\n\n\tthis.id = id;\n\n\tthis.seq = [];\n\tthis.map = {};\n\n}\n\nStructuredUniform.prototype.setValue = function ( gl, value, textures ) {\n\n\tconst seq = this.seq;\n\n\tfor ( let i = 0, n = seq.length; i !== n; ++ i ) {\n\n\t\tconst u = seq[ i ];\n\t\tu.setValue( gl, value[ u.id ], textures );\n\n\t}\n\n};\n\n// --- Top-level ---\n\n// Parser - builds up the property tree from the path strings\n\nconst RePathPart = /([\\w\\d_]+)(\\])?(\\[|\\.)?/g;\n\n// extracts\n// \t- the identifier (member name or array index)\n// - followed by an optional right bracket (found when array index)\n// - followed by an optional left bracket or dot (type of subscript)\n//\n// Note: These portions can be read in a non-overlapping fashion and\n// allow straightforward parsing of the hierarchy that WebGL encodes\n// in the uniform names.\n\nfunction addUniform( container, uniformObject ) {\n\n\tcontainer.seq.push( uniformObject );\n\tcontainer.map[ uniformObject.id ] = uniformObject;\n\n}\n\nfunction parseUniform( activeInfo, addr, container ) {\n\n\tconst path = activeInfo.name,\n\t\tpathLength = path.length;\n\n\t// reset RegExp object, because of the early exit of a previous run\n\tRePathPart.lastIndex = 0;\n\n\twhile ( true ) {\n\n\t\tconst match = RePathPart.exec( path ),\n\t\t\tmatchEnd = RePathPart.lastIndex;\n\n\t\tlet id = match[ 1 ],\n\t\t\tidIsIndex = match[ 2 ] === ']',\n\t\t\tsubscript = match[ 3 ];\n\n\t\tif ( idIsIndex ) id = id | 0; // convert to integer\n\n\t\tif ( subscript === undefined || subscript === '[' && matchEnd + 2 === pathLength ) {\n\n\t\t\t// bare name or \"pure\" bottom-level array \"[0]\" suffix\n\n\t\t\taddUniform( container, subscript === undefined ?\n\t\t\t\tnew SingleUniform( id, activeInfo, addr ) :\n\t\t\t\tnew PureArrayUniform( id, activeInfo, addr ) );\n\n\t\t\tbreak;\n\n\t\t} else {\n\n\t\t\t// step into inner node / create it in case it doesn't exist\n\n\t\t\tconst map = container.map;\n\t\t\tlet next = map[ id ];\n\n\t\t\tif ( next === undefined ) {\n\n\t\t\t\tnext = new StructuredUniform( id );\n\t\t\t\taddUniform( container, next );\n\n\t\t\t}\n\n\t\t\tcontainer = next;\n\n\t\t}\n\n\t}\n\n}\n\n// Root Container\n\nfunction WebGLUniforms( gl, program ) {\n\n\tthis.seq = [];\n\tthis.map = {};\n\n\tconst n = gl.getProgramParameter( program, gl.ACTIVE_UNIFORMS );\n\n\tfor ( let i = 0; i < n; ++ i ) {\n\n\t\tconst info = gl.getActiveUniform( program, i ),\n\t\t\taddr = gl.getUniformLocation( program, info.name );\n\n\t\tparseUniform( info, addr, this );\n\n\t}\n\n}\n\nWebGLUniforms.prototype.setValue = function ( gl, name, value, textures ) {\n\n\tconst u = this.map[ name ];\n\n\tif ( u !== undefined ) u.setValue( gl, value, textures );\n\n};\n\nWebGLUniforms.prototype.setOptional = function ( gl, object, name ) {\n\n\tconst v = object[ name ];\n\n\tif ( v !== undefined ) this.setValue( gl, name, v );\n\n};\n\n\n// Static interface\n\nWebGLUniforms.upload = function ( gl, seq, values, textures ) {\n\n\tfor ( let i = 0, n = seq.length; i !== n; ++ i ) {\n\n\t\tconst u = seq[ i ],\n\t\t\tv = values[ u.id ];\n\n\t\tif ( v.needsUpdate !== false ) {\n\n\t\t\t// note: always updating when .needsUpdate is undefined\n\t\t\tu.setValue( gl, v.value, textures );\n\n\t\t}\n\n\t}\n\n};\n\nWebGLUniforms.seqWithValue = function ( seq, values ) {\n\n\tconst r = [];\n\n\tfor ( let i = 0, n = seq.length; i !== n; ++ i ) {\n\n\t\tconst u = seq[ i ];\n\t\tif ( u.id in values ) r.push( u );\n\n\t}\n\n\treturn r;\n\n};\n\nexport { WebGLUniforms };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction WebGLShader( gl, type, string ) {\n\n\tconst shader = gl.createShader( type );\n\n\tgl.shaderSource( shader, string );\n\tgl.compileShader( shader );\n\n\treturn shader;\n\n}\n\nexport { WebGLShader };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { WebGLUniforms } from './WebGLUniforms.js';\nimport { WebGLShader } from './WebGLShader.js';\nimport { ShaderChunk } from '../shaders/ShaderChunk.js';\nimport { NoToneMapping, AddOperation, MixOperation, MultiplyOperation, EquirectangularRefractionMapping, CubeRefractionMapping, EquirectangularReflectionMapping, CubeUVRefractionMapping, CubeUVReflectionMapping, CubeReflectionMapping, PCFSoftShadowMap, PCFShadowMap, VSMShadowMap, ACESFilmicToneMapping, CineonToneMapping, CustomToneMapping, ReinhardToneMapping, LinearToneMapping, GammaEncoding, RGBDEncoding, RGBM16Encoding, RGBM7Encoding, RGBEEncoding, sRGBEncoding, LinearEncoding, LogLuvEncoding } from '../../constants.js';\n\nlet programIdCount = 0;\n\nfunction addLineNumbers( string ) {\n\n\tconst lines = string.split( '\\n' );\n\n\tfor ( let i = 0; i < lines.length; i ++ ) {\n\n\t\tlines[ i ] = ( i + 1 ) + ': ' + lines[ i ];\n\n\t}\n\n\treturn lines.join( '\\n' );\n\n}\n\nfunction getEncodingComponents( encoding ) {\n\n\tswitch ( encoding ) {\n\n\t\tcase LinearEncoding:\n\t\t\treturn [ 'Linear', '( value )' ];\n\t\tcase sRGBEncoding:\n\t\t\treturn [ 'sRGB', '( value )' ];\n\t\tcase RGBEEncoding:\n\t\t\treturn [ 'RGBE', '( value )' ];\n\t\tcase RGBM7Encoding:\n\t\t\treturn [ 'RGBM', '( value, 7.0 )' ];\n\t\tcase RGBM16Encoding:\n\t\t\treturn [ 'RGBM', '( value, 16.0 )' ];\n\t\tcase RGBDEncoding:\n\t\t\treturn [ 'RGBD', '( value, 256.0 )' ];\n\t\tcase GammaEncoding:\n\t\t\treturn [ 'Gamma', '( value, float( GAMMA_FACTOR ) )' ];\n\t\tcase LogLuvEncoding:\n\t\t\treturn [ 'LogLuv', '( value )' ];\n\t\tdefault:\n\t\t\tconsole.warn( 'THREE.WebGLProgram: Unsupported encoding:', encoding );\n\t\t\treturn [ 'Linear', '( value )' ];\n\n\t}\n\n}\n\nfunction getShaderErrors( gl, shader, type ) {\n\n\tconst status = gl.getShaderParameter( shader, gl.COMPILE_STATUS );\n\tconst log = gl.getShaderInfoLog( shader ).trim();\n\n\tif ( status && log === '' ) return '';\n\n\t// --enable-privileged-webgl-extension\n\t// console.log( '**' + type + '**', gl.getExtension( 'WEBGL_debug_shaders' ).getTranslatedShaderSource( shader ) );\n\n\tconst source = gl.getShaderSource( shader );\n\n\treturn 'THREE.WebGLShader: gl.getShaderInfoLog() ' + type + '\\n' + log + addLineNumbers( source );\n\n}\n\nfunction getTexelDecodingFunction( functionName, encoding ) {\n\n\tconst components = getEncodingComponents( encoding );\n\treturn 'vec4 ' + functionName + '( vec4 value ) { return ' + components[ 0 ] + 'ToLinear' + components[ 1 ] + '; }';\n\n}\n\nfunction getTexelEncodingFunction( functionName, encoding ) {\n\n\tconst components = getEncodingComponents( encoding );\n\treturn 'vec4 ' + functionName + '( vec4 value ) { return LinearTo' + components[ 0 ] + components[ 1 ] + '; }';\n\n}\n\nfunction getToneMappingFunction( functionName, toneMapping ) {\n\n\tlet toneMappingName;\n\n\tswitch ( toneMapping ) {\n\n\t\tcase LinearToneMapping:\n\t\t\ttoneMappingName = 'Linear';\n\t\t\tbreak;\n\n\t\tcase ReinhardToneMapping:\n\t\t\ttoneMappingName = 'Reinhard';\n\t\t\tbreak;\n\n\t\tcase CineonToneMapping:\n\t\t\ttoneMappingName = 'OptimizedCineon';\n\t\t\tbreak;\n\n\t\tcase ACESFilmicToneMapping:\n\t\t\ttoneMappingName = 'ACESFilmic';\n\t\t\tbreak;\n\n\t\tcase CustomToneMapping:\n\t\t\ttoneMappingName = 'Custom';\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\tconsole.warn( 'THREE.WebGLProgram: Unsupported toneMapping:', toneMapping );\n\t\t\ttoneMappingName = 'Linear';\n\n\t}\n\n\treturn 'vec3 ' + functionName + '( vec3 color ) { return ' + toneMappingName + 'ToneMapping( color ); }';\n\n}\n\nfunction generateExtensions( parameters ) {\n\n\tconst chunks = [\n\t\t( parameters.extensionDerivatives || parameters.envMapCubeUV || parameters.bumpMap || parameters.tangentSpaceNormalMap || parameters.clearcoatNormalMap || parameters.flatShading || parameters.shaderID === 'physical' ) ? '#extension GL_OES_standard_derivatives : enable' : '',\n\t\t( parameters.extensionFragDepth || parameters.logarithmicDepthBuffer ) && parameters.rendererExtensionFragDepth ? '#extension GL_EXT_frag_depth : enable' : '',\n\t\t( parameters.extensionDrawBuffers && parameters.rendererExtensionDrawBuffers ) ? '#extension GL_EXT_draw_buffers : require' : '',\n\t\t( parameters.extensionShaderTextureLOD || parameters.envMap ) && parameters.rendererExtensionShaderTextureLod ? '#extension GL_EXT_shader_texture_lod : enable' : ''\n\t];\n\n\treturn chunks.filter( filterEmptyLine ).join( '\\n' );\n\n}\n\nfunction generateDefines( defines ) {\n\n\tconst chunks = [];\n\n\tfor ( const name in defines ) {\n\n\t\tconst value = defines[ name ];\n\n\t\tif ( value === false ) continue;\n\n\t\tchunks.push( '#define ' + name + ' ' + value );\n\n\t}\n\n\treturn chunks.join( '\\n' );\n\n}\n\nfunction fetchAttributeLocations( gl, program ) {\n\n\tconst attributes = {};\n\n\tconst n = gl.getProgramParameter( program, gl.ACTIVE_ATTRIBUTES );\n\n\tfor ( let i = 0; i < n; i ++ ) {\n\n\t\tconst info = gl.getActiveAttrib( program, i );\n\t\tconst name = info.name;\n\n\t\t// console.log( 'THREE.WebGLProgram: ACTIVE VERTEX ATTRIBUTE:', name, i );\n\n\t\tattributes[ name ] = gl.getAttribLocation( program, name );\n\n\t}\n\n\treturn attributes;\n\n}\n\nfunction filterEmptyLine( string ) {\n\n\treturn string !== '';\n\n}\n\nfunction replaceLightNums( string, parameters ) {\n\n\treturn string\n\t\t.replace( /NUM_DIR_LIGHTS/g, parameters.numDirLights )\n\t\t.replace( /NUM_SPOT_LIGHTS/g, parameters.numSpotLights )\n\t\t.replace( /NUM_RECT_AREA_LIGHTS/g, parameters.numRectAreaLights )\n\t\t.replace( /NUM_POINT_LIGHTS/g, parameters.numPointLights )\n\t\t.replace( /NUM_HEMI_LIGHTS/g, parameters.numHemiLights )\n\t\t.replace( /NUM_DIR_LIGHT_SHADOWS/g, parameters.numDirLightShadows )\n\t\t.replace( /NUM_SPOT_LIGHT_SHADOWS/g, parameters.numSpotLightShadows )\n\t\t.replace( /NUM_POINT_LIGHT_SHADOWS/g, parameters.numPointLightShadows );\n\n}\n\nfunction replaceClippingPlaneNums( string, parameters ) {\n\n\treturn string\n\t\t.replace( /NUM_CLIPPING_PLANES/g, parameters.numClippingPlanes )\n\t\t.replace( /UNION_CLIPPING_PLANES/g, ( parameters.numClippingPlanes - parameters.numClipIntersection ) );\n\n}\n\n// Resolve Includes\n\nconst includePattern = /^[ \\t]*#include +<([\\w\\d./]+)>/gm;\n\nfunction resolveIncludes( string ) {\n\n\treturn string.replace( includePattern, includeReplacer );\n\n}\n\nfunction includeReplacer( match, include ) {\n\n\tconst string = ShaderChunk[ include ];\n\n\tif ( string === undefined ) {\n\n\t\tthrow new Error( 'Can not resolve #include <' + include + '>' );\n\n\t}\n\n\treturn resolveIncludes( string );\n\n}\n\n// Unroll Loops\n\nconst deprecatedUnrollLoopPattern = /#pragma unroll_loop[\\s]+?for \\( int i \\= (\\d+)\\; i < (\\d+)\\; i \\+\\+ \\) \\{([\\s\\S]+?)(?=\\})\\}/g;\nconst unrollLoopPattern = /#pragma unroll_loop_start[\\s]+?for \\( int i \\= (\\d+)\\; i < (\\d+)\\; i \\+\\+ \\) \\{([\\s\\S]+?)(?=\\})\\}[\\s]+?#pragma unroll_loop_end/g;\n\nfunction unrollLoops( string ) {\n\n\treturn string\n\t\t.replace( unrollLoopPattern, loopReplacer )\n\t\t.replace( deprecatedUnrollLoopPattern, deprecatedLoopReplacer );\n\n}\n\nfunction deprecatedLoopReplacer( match, start, end, snippet ) {\n\n\tconsole.warn( 'WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead.' );\n\treturn loopReplacer( match, start, end, snippet );\n\n}\n\nfunction loopReplacer( match, start, end, snippet ) {\n\n\tlet string = '';\n\n\tfor ( let i = parseInt( start ); i < parseInt( end ); i ++ ) {\n\n\t\tstring += snippet\n\t\t\t.replace( /\\[ i \\]/g, '[ ' + i + ' ]' )\n\t\t\t.replace( /UNROLLED_LOOP_INDEX/g, i );\n\n\t}\n\n\treturn string;\n\n}\n\n//\n\nfunction generatePrecision( parameters ) {\n\n\tlet precisionstring = \"precision \" + parameters.precision + \" float;\\nprecision \" + parameters.precision + \" int;\";\n\n\tif ( parameters.precision === \"highp\" ) {\n\n\t\tprecisionstring += \"\\n#define HIGH_PRECISION\";\n\n\t} else if ( parameters.precision === \"mediump\" ) {\n\n\t\tprecisionstring += \"\\n#define MEDIUM_PRECISION\";\n\n\t} else if ( parameters.precision === \"lowp\" ) {\n\n\t\tprecisionstring += \"\\n#define LOW_PRECISION\";\n\n\t}\n\n\treturn precisionstring;\n\n}\n\nfunction generateShadowMapTypeDefine( parameters ) {\n\n\tlet shadowMapTypeDefine = 'SHADOWMAP_TYPE_BASIC';\n\n\tif ( parameters.shadowMapType === PCFShadowMap ) {\n\n\t\tshadowMapTypeDefine = 'SHADOWMAP_TYPE_PCF';\n\n\t} else if ( parameters.shadowMapType === PCFSoftShadowMap ) {\n\n\t\tshadowMapTypeDefine = 'SHADOWMAP_TYPE_PCF_SOFT';\n\n\t} else if ( parameters.shadowMapType === VSMShadowMap ) {\n\n\t\tshadowMapTypeDefine = 'SHADOWMAP_TYPE_VSM';\n\n\t}\n\n\treturn shadowMapTypeDefine;\n\n}\n\nfunction generateEnvMapTypeDefine( parameters ) {\n\n\tlet envMapTypeDefine = 'ENVMAP_TYPE_CUBE';\n\n\tif ( parameters.envMap ) {\n\n\t\tswitch ( parameters.envMapMode ) {\n\n\t\t\tcase CubeReflectionMapping:\n\t\t\tcase CubeRefractionMapping:\n\t\t\t\tenvMapTypeDefine = 'ENVMAP_TYPE_CUBE';\n\t\t\t\tbreak;\n\n\t\t\tcase CubeUVReflectionMapping:\n\t\t\tcase CubeUVRefractionMapping:\n\t\t\t\tenvMapTypeDefine = 'ENVMAP_TYPE_CUBE_UV';\n\t\t\t\tbreak;\n\n\t\t\tcase EquirectangularReflectionMapping:\n\t\t\tcase EquirectangularRefractionMapping:\n\t\t\t\tenvMapTypeDefine = 'ENVMAP_TYPE_EQUIREC';\n\t\t\t\tbreak;\n\n\t\t}\n\n\t}\n\n\treturn envMapTypeDefine;\n\n}\n\nfunction generateEnvMapModeDefine( parameters ) {\n\n\tlet envMapModeDefine = 'ENVMAP_MODE_REFLECTION';\n\n\tif ( parameters.envMap ) {\n\n\t\tswitch ( parameters.envMapMode ) {\n\n\t\t\tcase CubeRefractionMapping:\n\t\t\tcase EquirectangularRefractionMapping:\n\t\t\t\tenvMapModeDefine = 'ENVMAP_MODE_REFRACTION';\n\t\t\t\tbreak;\n\n\t\t}\n\n\t}\n\n\treturn envMapModeDefine;\n\n}\n\nfunction generateEnvMapBlendingDefine( parameters ) {\n\n\tlet envMapBlendingDefine = 'ENVMAP_BLENDING_NONE';\n\n\tif ( parameters.envMap ) {\n\n\t\tswitch ( parameters.combine ) {\n\n\t\t\tcase MultiplyOperation:\n\t\t\t\tenvMapBlendingDefine = 'ENVMAP_BLENDING_MULTIPLY';\n\t\t\t\tbreak;\n\n\t\t\tcase MixOperation:\n\t\t\t\tenvMapBlendingDefine = 'ENVMAP_BLENDING_MIX';\n\t\t\t\tbreak;\n\n\t\t\tcase AddOperation:\n\t\t\t\tenvMapBlendingDefine = 'ENVMAP_BLENDING_ADD';\n\t\t\t\tbreak;\n\n\t\t}\n\n\t}\n\n\treturn envMapBlendingDefine;\n\n}\n\nfunction WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {\n\n\tconst gl = renderer.getContext();\n\n\tconst defines = parameters.defines;\n\n\tlet vertexShader = parameters.vertexShader;\n\tlet fragmentShader = parameters.fragmentShader;\n\n\tconst shadowMapTypeDefine = generateShadowMapTypeDefine( parameters );\n\tconst envMapTypeDefine = generateEnvMapTypeDefine( parameters );\n\tconst envMapModeDefine = generateEnvMapModeDefine( parameters );\n\tconst envMapBlendingDefine = generateEnvMapBlendingDefine( parameters );\n\n\n\tconst gammaFactorDefine = ( renderer.gammaFactor > 0 ) ? renderer.gammaFactor : 1.0;\n\n\tconst customExtensions = parameters.isWebGL2 ? '' : generateExtensions( parameters );\n\n\tconst customDefines = generateDefines( defines );\n\n\tconst program = gl.createProgram();\n\n\tlet prefixVertex, prefixFragment;\n\n\tif ( parameters.isRawShaderMaterial ) {\n\n\t\tprefixVertex = [\n\n\t\t\tcustomDefines\n\n\t\t].filter( filterEmptyLine ).join( '\\n' );\n\n\t\tif ( prefixVertex.length > 0 ) {\n\n\t\t\tprefixVertex += '\\n';\n\n\t\t}\n\n\t\tprefixFragment = [\n\n\t\t\tcustomExtensions,\n\t\t\tcustomDefines\n\n\t\t].filter( filterEmptyLine ).join( '\\n' );\n\n\t\tif ( prefixFragment.length > 0 ) {\n\n\t\t\tprefixFragment += '\\n';\n\n\t\t}\n\n\t} else {\n\n\t\tprefixVertex = [\n\n\t\t\tgeneratePrecision( parameters ),\n\n\t\t\t'#define SHADER_NAME ' + parameters.shaderName,\n\n\t\t\tcustomDefines,\n\n\t\t\tparameters.instancing ? '#define USE_INSTANCING' : '',\n\t\t\tparameters.supportsVertexTextures ? '#define VERTEX_TEXTURES' : '',\n\n\t\t\t'#define GAMMA_FACTOR ' + gammaFactorDefine,\n\n\t\t\t'#define MAX_BONES ' + parameters.maxBones,\n\t\t\t( parameters.useFog && parameters.fog ) ? '#define USE_FOG' : '',\n\t\t\t( parameters.useFog && parameters.fogExp2 ) ? '#define FOG_EXP2' : '',\n\n\t\t\tparameters.map ? '#define USE_MAP' : '',\n\t\t\tparameters.envMap ? '#define USE_ENVMAP' : '',\n\t\t\tparameters.envMap ? '#define ' + envMapModeDefine : '',\n\t\t\tparameters.lightMap ? '#define USE_LIGHTMAP' : '',\n\t\t\tparameters.aoMap ? '#define USE_AOMAP' : '',\n\t\t\tparameters.emissiveMap ? '#define USE_EMISSIVEMAP' : '',\n\t\t\tparameters.bumpMap ? '#define USE_BUMPMAP' : '',\n\t\t\tparameters.normalMap ? '#define USE_NORMALMAP' : '',\n\t\t\t( parameters.normalMap && parameters.objectSpaceNormalMap ) ? '#define OBJECTSPACE_NORMALMAP' : '',\n\t\t\t( parameters.normalMap && parameters.tangentSpaceNormalMap ) ? '#define TANGENTSPACE_NORMALMAP' : '',\n\n\t\t\tparameters.clearcoatMap ? '#define USE_CLEARCOATMAP' : '',\n\t\t\tparameters.clearcoatRoughnessMap ? '#define USE_CLEARCOAT_ROUGHNESSMAP' : '',\n\t\t\tparameters.clearcoatNormalMap ? '#define USE_CLEARCOAT_NORMALMAP' : '',\n\t\t\tparameters.displacementMap && parameters.supportsVertexTextures ? '#define USE_DISPLACEMENTMAP' : '',\n\t\t\tparameters.specularMap ? '#define USE_SPECULARMAP' : '',\n\t\t\tparameters.roughnessMap ? '#define USE_ROUGHNESSMAP' : '',\n\t\t\tparameters.metalnessMap ? '#define USE_METALNESSMAP' : '',\n\t\t\tparameters.alphaMap ? '#define USE_ALPHAMAP' : '',\n\n\t\t\tparameters.vertexTangents ? '#define USE_TANGENT' : '',\n\t\t\tparameters.vertexColors ? '#define USE_COLOR' : '',\n\t\t\tparameters.vertexUvs ? '#define USE_UV' : '',\n\t\t\tparameters.uvsVertexOnly ? '#define UVS_VERTEX_ONLY' : '',\n\n\t\t\tparameters.flatShading ? '#define FLAT_SHADED' : '',\n\n\t\t\tparameters.skinning ? '#define USE_SKINNING' : '',\n\t\t\tparameters.useVertexTexture ? '#define BONE_TEXTURE' : '',\n\n\t\t\tparameters.morphTargets ? '#define USE_MORPHTARGETS' : '',\n\t\t\tparameters.morphNormals && parameters.flatShading === false ? '#define USE_MORPHNORMALS' : '',\n\t\t\tparameters.doubleSided ? '#define DOUBLE_SIDED' : '',\n\t\t\tparameters.flipSided ? '#define FLIP_SIDED' : '',\n\n\t\t\tparameters.shadowMapEnabled ? '#define USE_SHADOWMAP' : '',\n\t\t\tparameters.shadowMapEnabled ? '#define ' + shadowMapTypeDefine : '',\n\n\t\t\tparameters.sizeAttenuation ? '#define USE_SIZEATTENUATION' : '',\n\n\t\t\tparameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',\n\t\t\t( parameters.logarithmicDepthBuffer && parameters.rendererExtensionFragDepth ) ? '#define USE_LOGDEPTHBUF_EXT' : '',\n\n\t\t\t'uniform mat4 modelMatrix;',\n\t\t\t'uniform mat4 modelViewMatrix;',\n\t\t\t'uniform mat4 projectionMatrix;',\n\t\t\t'uniform mat4 viewMatrix;',\n\t\t\t'uniform mat3 normalMatrix;',\n\t\t\t'uniform vec3 cameraPosition;',\n\t\t\t'uniform bool isOrthographic;',\n\n\t\t\t'#ifdef USE_INSTANCING',\n\n\t\t\t' attribute mat4 instanceMatrix;',\n\n\t\t\t'#endif',\n\n\t\t\t'attribute vec3 position;',\n\t\t\t'attribute vec3 normal;',\n\t\t\t'attribute vec2 uv;',\n\n\t\t\t'#ifdef USE_TANGENT',\n\n\t\t\t'\tattribute vec4 tangent;',\n\n\t\t\t'#endif',\n\n\t\t\t'#ifdef USE_COLOR',\n\n\t\t\t'\tattribute vec3 color;',\n\n\t\t\t'#endif',\n\n\t\t\t'#ifdef USE_MORPHTARGETS',\n\n\t\t\t'\tattribute vec3 morphTarget0;',\n\t\t\t'\tattribute vec3 morphTarget1;',\n\t\t\t'\tattribute vec3 morphTarget2;',\n\t\t\t'\tattribute vec3 morphTarget3;',\n\n\t\t\t'\t#ifdef USE_MORPHNORMALS',\n\n\t\t\t'\t\tattribute vec3 morphNormal0;',\n\t\t\t'\t\tattribute vec3 morphNormal1;',\n\t\t\t'\t\tattribute vec3 morphNormal2;',\n\t\t\t'\t\tattribute vec3 morphNormal3;',\n\n\t\t\t'\t#else',\n\n\t\t\t'\t\tattribute vec3 morphTarget4;',\n\t\t\t'\t\tattribute vec3 morphTarget5;',\n\t\t\t'\t\tattribute vec3 morphTarget6;',\n\t\t\t'\t\tattribute vec3 morphTarget7;',\n\n\t\t\t'\t#endif',\n\n\t\t\t'#endif',\n\n\t\t\t'#ifdef USE_SKINNING',\n\n\t\t\t'\tattribute vec4 skinIndex;',\n\t\t\t'\tattribute vec4 skinWeight;',\n\n\t\t\t'#endif',\n\n\t\t\t'\\n'\n\n\t\t].filter( filterEmptyLine ).join( '\\n' );\n\n\t\tprefixFragment = [\n\n\t\t\tcustomExtensions,\n\n\t\t\tgeneratePrecision( parameters ),\n\n\t\t\t'#define SHADER_NAME ' + parameters.shaderName,\n\n\t\t\tcustomDefines,\n\n\t\t\tparameters.alphaTest ? '#define ALPHATEST ' + parameters.alphaTest + ( parameters.alphaTest % 1 ? '' : '.0' ) : '', // add '.0' if integer\n\n\t\t\t'#define GAMMA_FACTOR ' + gammaFactorDefine,\n\n\t\t\t( parameters.useFog && parameters.fog ) ? '#define USE_FOG' : '',\n\t\t\t( parameters.useFog && parameters.fogExp2 ) ? '#define FOG_EXP2' : '',\n\n\t\t\tparameters.map ? '#define USE_MAP' : '',\n\t\t\tparameters.matcap ? '#define USE_MATCAP' : '',\n\t\t\tparameters.envMap ? '#define USE_ENVMAP' : '',\n\t\t\tparameters.envMap ? '#define ' + envMapTypeDefine : '',\n\t\t\tparameters.envMap ? '#define ' + envMapModeDefine : '',\n\t\t\tparameters.envMap ? '#define ' + envMapBlendingDefine : '',\n\t\t\tparameters.lightMap ? '#define USE_LIGHTMAP' : '',\n\t\t\tparameters.aoMap ? '#define USE_AOMAP' : '',\n\t\t\tparameters.emissiveMap ? '#define USE_EMISSIVEMAP' : '',\n\t\t\tparameters.bumpMap ? '#define USE_BUMPMAP' : '',\n\t\t\tparameters.normalMap ? '#define USE_NORMALMAP' : '',\n\t\t\t( parameters.normalMap && parameters.objectSpaceNormalMap ) ? '#define OBJECTSPACE_NORMALMAP' : '',\n\t\t\t( parameters.normalMap && parameters.tangentSpaceNormalMap ) ? '#define TANGENTSPACE_NORMALMAP' : '',\n\t\t\tparameters.clearcoatMap ? '#define USE_CLEARCOATMAP' : '',\n\t\t\tparameters.clearcoatRoughnessMap ? '#define USE_CLEARCOAT_ROUGHNESSMAP' : '',\n\t\t\tparameters.clearcoatNormalMap ? '#define USE_CLEARCOAT_NORMALMAP' : '',\n\t\t\tparameters.specularMap ? '#define USE_SPECULARMAP' : '',\n\t\t\tparameters.roughnessMap ? '#define USE_ROUGHNESSMAP' : '',\n\t\t\tparameters.metalnessMap ? '#define USE_METALNESSMAP' : '',\n\t\t\tparameters.alphaMap ? '#define USE_ALPHAMAP' : '',\n\n\t\t\tparameters.sheen ? '#define USE_SHEEN' : '',\n\n\t\t\tparameters.vertexTangents ? '#define USE_TANGENT' : '',\n\t\t\tparameters.vertexColors ? '#define USE_COLOR' : '',\n\t\t\tparameters.vertexUvs ? '#define USE_UV' : '',\n\t\t\tparameters.uvsVertexOnly ? '#define UVS_VERTEX_ONLY' : '',\n\n\t\t\tparameters.gradientMap ? '#define USE_GRADIENTMAP' : '',\n\n\t\t\tparameters.flatShading ? '#define FLAT_SHADED' : '',\n\n\t\t\tparameters.doubleSided ? '#define DOUBLE_SIDED' : '',\n\t\t\tparameters.flipSided ? '#define FLIP_SIDED' : '',\n\n\t\t\tparameters.shadowMapEnabled ? '#define USE_SHADOWMAP' : '',\n\t\t\tparameters.shadowMapEnabled ? '#define ' + shadowMapTypeDefine : '',\n\n\t\t\tparameters.premultipliedAlpha ? '#define PREMULTIPLIED_ALPHA' : '',\n\n\t\t\tparameters.physicallyCorrectLights ? '#define PHYSICALLY_CORRECT_LIGHTS' : '',\n\n\t\t\tparameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',\n\t\t\t( parameters.logarithmicDepthBuffer && parameters.rendererExtensionFragDepth ) ? '#define USE_LOGDEPTHBUF_EXT' : '',\n\n\t\t\t( ( parameters.extensionShaderTextureLOD || parameters.envMap ) && parameters.rendererExtensionShaderTextureLod ) ? '#define TEXTURE_LOD_EXT' : '',\n\n\t\t\t'uniform mat4 viewMatrix;',\n\t\t\t'uniform vec3 cameraPosition;',\n\t\t\t'uniform bool isOrthographic;',\n\n\t\t\t( parameters.toneMapping !== NoToneMapping ) ? '#define TONE_MAPPING' : '',\n\t\t\t( parameters.toneMapping !== NoToneMapping ) ? ShaderChunk[ 'tonemapping_pars_fragment' ] : '', // this code is required here because it is used by the toneMapping() function defined below\n\t\t\t( parameters.toneMapping !== NoToneMapping ) ? getToneMappingFunction( 'toneMapping', parameters.toneMapping ) : '',\n\n\t\t\tparameters.dithering ? '#define DITHERING' : '',\n\n\t\t\tShaderChunk[ 'encodings_pars_fragment' ], // this code is required here because it is used by the various encoding/decoding function defined below\n\t\t\tparameters.map ? getTexelDecodingFunction( 'mapTexelToLinear', parameters.mapEncoding ) : '',\n\t\t\tparameters.matcap ? getTexelDecodingFunction( 'matcapTexelToLinear', parameters.matcapEncoding ) : '',\n\t\t\tparameters.envMap ? getTexelDecodingFunction( 'envMapTexelToLinear', parameters.envMapEncoding ) : '',\n\t\t\tparameters.emissiveMap ? getTexelDecodingFunction( 'emissiveMapTexelToLinear', parameters.emissiveMapEncoding ) : '',\n\t\t\tparameters.lightMap ? getTexelDecodingFunction( 'lightMapTexelToLinear', parameters.lightMapEncoding ) : '',\n\t\t\tgetTexelEncodingFunction( 'linearToOutputTexel', parameters.outputEncoding ),\n\n\t\t\tparameters.depthPacking ? '#define DEPTH_PACKING ' + parameters.depthPacking : '',\n\n\t\t\t'\\n'\n\n\t\t].filter( filterEmptyLine ).join( '\\n' );\n\n\t}\n\n\tvertexShader = resolveIncludes( vertexShader );\n\tvertexShader = replaceLightNums( vertexShader, parameters );\n\tvertexShader = replaceClippingPlaneNums( vertexShader, parameters );\n\n\tfragmentShader = resolveIncludes( fragmentShader );\n\tfragmentShader = replaceLightNums( fragmentShader, parameters );\n\tfragmentShader = replaceClippingPlaneNums( fragmentShader, parameters );\n\n\tvertexShader = unrollLoops( vertexShader );\n\tfragmentShader = unrollLoops( fragmentShader );\n\n\tif ( parameters.isWebGL2 && ! parameters.isRawShaderMaterial ) {\n\n\t\tlet isGLSL3ShaderMaterial = false;\n\n\t\tconst versionRegex = /^\\s*#version\\s+300\\s+es\\s*\\n/;\n\n\t\tif ( parameters.isShaderMaterial &&\n\t\t\tvertexShader.match( versionRegex ) !== null &&\n\t\t\tfragmentShader.match( versionRegex ) !== null ) {\n\n\t\t\tisGLSL3ShaderMaterial = true;\n\n\t\t\tvertexShader = vertexShader.replace( versionRegex, '' );\n\t\t\tfragmentShader = fragmentShader.replace( versionRegex, '' );\n\n\t\t}\n\n\t\t// GLSL 3.0 conversion\n\n\t\tprefixVertex = [\n\t\t\t'#version 300 es\\n',\n\t\t\t'#define attribute in',\n\t\t\t'#define varying out',\n\t\t\t'#define texture2D texture'\n\t\t].join( '\\n' ) + '\\n' + prefixVertex;\n\n\t\tprefixFragment = [\n\t\t\t'#version 300 es\\n',\n\t\t\t'#define varying in',\n\t\t\tisGLSL3ShaderMaterial ? '' : 'out highp vec4 pc_fragColor;',\n\t\t\tisGLSL3ShaderMaterial ? '' : '#define gl_FragColor pc_fragColor',\n\t\t\t'#define gl_FragDepthEXT gl_FragDepth',\n\t\t\t'#define texture2D texture',\n\t\t\t'#define textureCube texture',\n\t\t\t'#define texture2DProj textureProj',\n\t\t\t'#define texture2DLodEXT textureLod',\n\t\t\t'#define texture2DProjLodEXT textureProjLod',\n\t\t\t'#define textureCubeLodEXT textureLod',\n\t\t\t'#define texture2DGradEXT textureGrad',\n\t\t\t'#define texture2DProjGradEXT textureProjGrad',\n\t\t\t'#define textureCubeGradEXT textureGrad'\n\t\t].join( '\\n' ) + '\\n' + prefixFragment;\n\n\t}\n\n\tconst vertexGlsl = prefixVertex + vertexShader;\n\tconst fragmentGlsl = prefixFragment + fragmentShader;\n\n\t// console.log( '*VERTEX*', vertexGlsl );\n\t// console.log( '*FRAGMENT*', fragmentGlsl );\n\n\tconst glVertexShader = WebGLShader( gl, gl.VERTEX_SHADER, vertexGlsl );\n\tconst glFragmentShader = WebGLShader( gl, gl.FRAGMENT_SHADER, fragmentGlsl );\n\n\tgl.attachShader( program, glVertexShader );\n\tgl.attachShader( program, glFragmentShader );\n\n\t// Force a particular attribute to index 0.\n\n\tif ( parameters.index0AttributeName !== undefined ) {\n\n\t\tgl.bindAttribLocation( program, 0, parameters.index0AttributeName );\n\n\t} else if ( parameters.morphTargets === true ) {\n\n\t\t// programs with morphTargets displace position out of attribute 0\n\t\tgl.bindAttribLocation( program, 0, 'position' );\n\n\t}\n\n\tgl.linkProgram( program );\n\n\t// check for link errors\n\tif ( renderer.debug.checkShaderErrors ) {\n\n\t\tconst programLog = gl.getProgramInfoLog( program ).trim();\n\t\tconst vertexLog = gl.getShaderInfoLog( glVertexShader ).trim();\n\t\tconst fragmentLog = gl.getShaderInfoLog( glFragmentShader ).trim();\n\n\t\tlet runnable = true;\n\t\tlet haveDiagnostics = true;\n\n\t\tif ( gl.getProgramParameter( program, gl.LINK_STATUS ) === false ) {\n\n\t\t\trunnable = false;\n\n\t\t\tconst vertexErrors = getShaderErrors( gl, glVertexShader, 'vertex' );\n\t\t\tconst fragmentErrors = getShaderErrors( gl, glFragmentShader, 'fragment' );\n\n\t\t\tconsole.error( 'THREE.WebGLProgram: shader error: ', gl.getError(), 'gl.VALIDATE_STATUS', gl.getProgramParameter( program, gl.VALIDATE_STATUS ), 'gl.getProgramInfoLog', programLog, vertexErrors, fragmentErrors );\n\n\t\t} else if ( programLog !== '' ) {\n\n\t\t\tconsole.warn( 'THREE.WebGLProgram: gl.getProgramInfoLog()', programLog );\n\n\t\t} else if ( vertexLog === '' || fragmentLog === '' ) {\n\n\t\t\thaveDiagnostics = false;\n\n\t\t}\n\n\t\tif ( haveDiagnostics ) {\n\n\t\t\tthis.diagnostics = {\n\n\t\t\t\trunnable: runnable,\n\n\t\t\t\tprogramLog: programLog,\n\n\t\t\t\tvertexShader: {\n\n\t\t\t\t\tlog: vertexLog,\n\t\t\t\t\tprefix: prefixVertex\n\n\t\t\t\t},\n\n\t\t\t\tfragmentShader: {\n\n\t\t\t\t\tlog: fragmentLog,\n\t\t\t\t\tprefix: prefixFragment\n\n\t\t\t\t}\n\n\t\t\t};\n\n\t\t}\n\n\t}\n\n\t// Clean up\n\n\t// Crashes in iOS9 and iOS10. #18402\n\t// gl.detachShader( program, glVertexShader );\n\t// gl.detachShader( program, glFragmentShader );\n\n\tgl.deleteShader( glVertexShader );\n\tgl.deleteShader( glFragmentShader );\n\n\t// set up caching for uniform locations\n\n\tlet cachedUniforms;\n\n\tthis.getUniforms = function () {\n\n\t\tif ( cachedUniforms === undefined ) {\n\n\t\t\tcachedUniforms = new WebGLUniforms( gl, program );\n\n\t\t}\n\n\t\treturn cachedUniforms;\n\n\t};\n\n\t// set up caching for attribute locations\n\n\tlet cachedAttributes;\n\n\tthis.getAttributes = function () {\n\n\t\tif ( cachedAttributes === undefined ) {\n\n\t\t\tcachedAttributes = fetchAttributeLocations( gl, program );\n\n\t\t}\n\n\t\treturn cachedAttributes;\n\n\t};\n\n\t// free resource\n\n\tthis.destroy = function () {\n\n\t\tbindingStates.releaseStatesOfProgram( this );\n\n\t\tgl.deleteProgram( program );\n\t\tthis.program = undefined;\n\n\t};\n\n\t//\n\n\tthis.name = parameters.shaderName;\n\tthis.id = programIdCount ++;\n\tthis.cacheKey = cacheKey;\n\tthis.usedTimes = 1;\n\tthis.program = program;\n\tthis.vertexShader = glVertexShader;\n\tthis.fragmentShader = glFragmentShader;\n\n\treturn this;\n\n}\n\nexport { WebGLProgram };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { BackSide, DoubleSide, CubeUVRefractionMapping, CubeUVReflectionMapping, LinearEncoding, ObjectSpaceNormalMap, TangentSpaceNormalMap, NoToneMapping } from '../../constants.js';\nimport { WebGLProgram } from './WebGLProgram.js';\nimport { ShaderLib } from '../shaders/ShaderLib.js';\nimport { UniformsUtils } from '../shaders/UniformsUtils.js';\n\nfunction WebGLPrograms( renderer, extensions, capabilities, bindingStates ) {\n\n\tconst programs = [];\n\n\tconst isWebGL2 = capabilities.isWebGL2;\n\tconst logarithmicDepthBuffer = capabilities.logarithmicDepthBuffer;\n\tconst floatVertexTextures = capabilities.floatVertexTextures;\n\tconst maxVertexUniforms = capabilities.maxVertexUniforms;\n\tconst vertexTextures = capabilities.vertexTextures;\n\n\tlet precision = capabilities.precision;\n\n\tconst shaderIDs = {\n\t\tMeshDepthMaterial: 'depth',\n\t\tMeshDistanceMaterial: 'distanceRGBA',\n\t\tMeshNormalMaterial: 'normal',\n\t\tMeshBasicMaterial: 'basic',\n\t\tMeshLambertMaterial: 'lambert',\n\t\tMeshPhongMaterial: 'phong',\n\t\tMeshToonMaterial: 'toon',\n\t\tMeshStandardMaterial: 'physical',\n\t\tMeshPhysicalMaterial: 'physical',\n\t\tMeshMatcapMaterial: 'matcap',\n\t\tLineBasicMaterial: 'basic',\n\t\tLineDashedMaterial: 'dashed',\n\t\tPointsMaterial: 'points',\n\t\tShadowMaterial: 'shadow',\n\t\tSpriteMaterial: 'sprite'\n\t};\n\n\tconst parameterNames = [\n\t\t\"precision\", \"isWebGL2\", \"supportsVertexTextures\", \"outputEncoding\", \"instancing\",\n\t\t\"map\", \"mapEncoding\", \"matcap\", \"matcapEncoding\", \"envMap\", \"envMapMode\", \"envMapEncoding\", \"envMapCubeUV\",\n\t\t\"lightMap\", \"lightMapEncoding\", \"aoMap\", \"emissiveMap\", \"emissiveMapEncoding\", \"bumpMap\", \"normalMap\", \"objectSpaceNormalMap\", \"tangentSpaceNormalMap\", \"clearcoatMap\", \"clearcoatRoughnessMap\", \"clearcoatNormalMap\", \"displacementMap\", \"specularMap\",\n\t\t\"roughnessMap\", \"metalnessMap\", \"gradientMap\",\n\t\t\"alphaMap\", \"combine\", \"vertexColors\", \"vertexTangents\", \"vertexUvs\", \"uvsVertexOnly\", \"fog\", \"useFog\", \"fogExp2\",\n\t\t\"flatShading\", \"sizeAttenuation\", \"logarithmicDepthBuffer\", \"skinning\",\n\t\t\"maxBones\", \"useVertexTexture\", \"morphTargets\", \"morphNormals\",\n\t\t\"maxMorphTargets\", \"maxMorphNormals\", \"premultipliedAlpha\",\n\t\t\"numDirLights\", \"numPointLights\", \"numSpotLights\", \"numHemiLights\", \"numRectAreaLights\",\n\t\t\"numDirLightShadows\", \"numPointLightShadows\", \"numSpotLightShadows\",\n\t\t\"shadowMapEnabled\", \"shadowMapType\", \"toneMapping\", 'physicallyCorrectLights',\n\t\t\"alphaTest\", \"doubleSided\", \"flipSided\", \"numClippingPlanes\", \"numClipIntersection\", \"depthPacking\", \"dithering\",\n\t\t\"sheen\"\n\t];\n\n\tfunction getShaderObject( material, shaderID ) {\n\n\t\tlet shaderobject;\n\n\t\tif ( shaderID ) {\n\n\t\t\tconst shader = ShaderLib[ shaderID ];\n\n\t\t\tshaderobject = {\n\t\t\t\tname: material.name || material.type,\n\t\t\t\tuniforms: UniformsUtils.clone( shader.uniforms ),\n\t\t\t\tvertexShader: shader.vertexShader,\n\t\t\t\tfragmentShader: shader.fragmentShader\n\t\t\t};\n\n\t\t} else {\n\n\t\t\tshaderobject = {\n\t\t\t\tname: material.name || material.type,\n\t\t\t\tuniforms: material.uniforms,\n\t\t\t\tvertexShader: material.vertexShader,\n\t\t\t\tfragmentShader: material.fragmentShader\n\t\t\t};\n\n\t\t}\n\n\t\treturn shaderobject;\n\n\t}\n\n\tfunction allocateBones( object ) {\n\n\t\tconst skeleton = object.skeleton;\n\t\tconst bones = skeleton.bones;\n\n\t\tif ( floatVertexTextures ) {\n\n\t\t\treturn 1024;\n\n\t\t} else {\n\n\t\t\t// default for when object is not specified\n\t\t\t// ( for example when prebuilding shader to be used with multiple objects )\n\t\t\t//\n\t\t\t// - leave some extra space for other uniforms\n\t\t\t// - limit here is ANGLE's 254 max uniform vectors\n\t\t\t// (up to 54 should be safe)\n\n\t\t\tconst nVertexUniforms = maxVertexUniforms;\n\t\t\tconst nVertexMatrices = Math.floor( ( nVertexUniforms - 20 ) / 4 );\n\n\t\t\tconst maxBones = Math.min( nVertexMatrices, bones.length );\n\n\t\t\tif ( maxBones < bones.length ) {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Skeleton has ' + bones.length + ' bones. This GPU supports ' + maxBones + '.' );\n\t\t\t\treturn 0;\n\n\t\t\t}\n\n\t\t\treturn maxBones;\n\n\t\t}\n\n\t}\n\n\tfunction getTextureEncodingFromMap( map ) {\n\n\t\tlet encoding;\n\n\t\tif ( ! map ) {\n\n\t\t\tencoding = LinearEncoding;\n\n\t\t} else if ( map.isTexture ) {\n\n\t\t\tencoding = map.encoding;\n\n\t\t} else if ( map.isWebGLRenderTarget ) {\n\n\t\t\tconsole.warn( \"THREE.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead.\" );\n\t\t\tencoding = map.texture.encoding;\n\n\t\t}\n\n\t\treturn encoding;\n\n\t}\n\n\tfunction getParameters( material, lights, shadows, scene, nClipPlanes, nClipIntersection, object ) {\n\n\t\tconst fog = scene.fog;\n\t\tconst environment = material.isMeshStandardMaterial ? scene.environment : null;\n\n\t\tconst envMap = material.envMap || environment;\n\n\t\tconst shaderID = shaderIDs[ material.type ];\n\n\t\t// heuristics to create shader parameters according to lights in the scene\n\t\t// (not to blow over maxLights budget)\n\n\t\tconst maxBones = object.isSkinnedMesh ? allocateBones( object ) : 0;\n\n\t\tif ( material.precision !== null ) {\n\n\t\t\tprecision = capabilities.getMaxPrecision( material.precision );\n\n\t\t\tif ( precision !== material.precision ) {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLProgram.getParameters:', material.precision, 'not supported, using', precision, 'instead.' );\n\n\t\t\t}\n\n\t\t}\n\n\t\tconst shaderobject = getShaderObject( material, shaderID );\n\t\tmaterial.onBeforeCompile( shaderobject, renderer );\n\n\t\tconst currentRenderTarget = renderer.getRenderTarget();\n\n\t\tconst parameters = {\n\n\t\t\tisWebGL2: isWebGL2,\n\n\t\t\tshaderID: shaderID,\n\t\t\tshaderName: shaderobject.name,\n\n\t\t\tuniforms: shaderobject.uniforms,\n\t\t\tvertexShader: shaderobject.vertexShader,\n\t\t\tfragmentShader: shaderobject.fragmentShader,\n\t\t\tdefines: material.defines,\n\n\t\t\tisRawShaderMaterial: material.isRawShaderMaterial,\n\t\t\tisShaderMaterial: material.isShaderMaterial,\n\n\t\t\tprecision: precision,\n\n\t\t\tinstancing: object.isInstancedMesh === true,\n\n\t\t\tsupportsVertexTextures: vertexTextures,\n\t\t\toutputEncoding: ( currentRenderTarget !== null ) ? getTextureEncodingFromMap( currentRenderTarget.texture ) : renderer.outputEncoding,\n\t\t\tmap: !! material.map,\n\t\t\tmapEncoding: getTextureEncodingFromMap( material.map ),\n\t\t\tmatcap: !! material.matcap,\n\t\t\tmatcapEncoding: getTextureEncodingFromMap( material.matcap ),\n\t\t\tenvMap: !! envMap,\n\t\t\tenvMapMode: envMap && envMap.mapping,\n\t\t\tenvMapEncoding: getTextureEncodingFromMap( envMap ),\n\t\t\tenvMapCubeUV: ( !! envMap ) && ( ( envMap.mapping === CubeUVReflectionMapping ) || ( envMap.mapping === CubeUVRefractionMapping ) ),\n\t\t\tlightMap: !! material.lightMap,\n\t\t\tlightMapEncoding: getTextureEncodingFromMap( material.lightMap ),\n\t\t\taoMap: !! material.aoMap,\n\t\t\temissiveMap: !! material.emissiveMap,\n\t\t\temissiveMapEncoding: getTextureEncodingFromMap( material.emissiveMap ),\n\t\t\tbumpMap: !! material.bumpMap,\n\t\t\tnormalMap: !! material.normalMap,\n\t\t\tobjectSpaceNormalMap: material.normalMapType === ObjectSpaceNormalMap,\n\t\t\ttangentSpaceNormalMap: material.normalMapType === TangentSpaceNormalMap,\n\t\t\tclearcoatMap: !! material.clearcoatMap,\n\t\t\tclearcoatRoughnessMap: !! material.clearcoatRoughnessMap,\n\t\t\tclearcoatNormalMap: !! material.clearcoatNormalMap,\n\t\t\tdisplacementMap: !! material.displacementMap,\n\t\t\troughnessMap: !! material.roughnessMap,\n\t\t\tmetalnessMap: !! material.metalnessMap,\n\t\t\tspecularMap: !! material.specularMap,\n\t\t\talphaMap: !! material.alphaMap,\n\n\t\t\tgradientMap: !! material.gradientMap,\n\n\t\t\tsheen: !! material.sheen,\n\n\t\t\tcombine: material.combine,\n\n\t\t\tvertexTangents: ( material.normalMap && material.vertexTangents ),\n\t\t\tvertexColors: material.vertexColors,\n\t\t\tvertexUvs: !! material.map || !! material.bumpMap || !! material.normalMap || !! material.specularMap || !! material.alphaMap || !! material.emissiveMap || !! material.roughnessMap || !! material.metalnessMap || !! material.clearcoatMap || !! material.clearcoatRoughnessMap || !! material.clearcoatNormalMap || !! material.displacementMap,\n\t\t\tuvsVertexOnly: ! ( !! material.map || !! material.bumpMap || !! material.normalMap || !! material.specularMap || !! material.alphaMap || !! material.emissiveMap || !! material.roughnessMap || !! material.metalnessMap || !! material.clearcoatNormalMap ) && !! material.displacementMap,\n\n\t\t\tfog: !! fog,\n\t\t\tuseFog: material.fog,\n\t\t\tfogExp2: ( fog && fog.isFogExp2 ),\n\n\t\t\tflatShading: material.flatShading,\n\n\t\t\tsizeAttenuation: material.sizeAttenuation,\n\t\t\tlogarithmicDepthBuffer: logarithmicDepthBuffer,\n\n\t\t\tskinning: material.skinning && maxBones > 0,\n\t\t\tmaxBones: maxBones,\n\t\t\tuseVertexTexture: floatVertexTextures,\n\n\t\t\tmorphTargets: material.morphTargets,\n\t\t\tmorphNormals: material.morphNormals,\n\t\t\tmaxMorphTargets: renderer.maxMorphTargets,\n\t\t\tmaxMorphNormals: renderer.maxMorphNormals,\n\n\t\t\tnumDirLights: lights.directional.length,\n\t\t\tnumPointLights: lights.point.length,\n\t\t\tnumSpotLights: lights.spot.length,\n\t\t\tnumRectAreaLights: lights.rectArea.length,\n\t\t\tnumHemiLights: lights.hemi.length,\n\n\t\t\tnumDirLightShadows: lights.directionalShadowMap.length,\n\t\t\tnumPointLightShadows: lights.pointShadowMap.length,\n\t\t\tnumSpotLightShadows: lights.spotShadowMap.length,\n\n\t\t\tnumClippingPlanes: nClipPlanes,\n\t\t\tnumClipIntersection: nClipIntersection,\n\n\t\t\tdithering: material.dithering,\n\n\t\t\tshadowMapEnabled: renderer.shadowMap.enabled && shadows.length > 0,\n\t\t\tshadowMapType: renderer.shadowMap.type,\n\n\t\t\ttoneMapping: material.toneMapped ? renderer.toneMapping : NoToneMapping,\n\t\t\tphysicallyCorrectLights: renderer.physicallyCorrectLights,\n\n\t\t\tpremultipliedAlpha: material.premultipliedAlpha,\n\n\t\t\talphaTest: material.alphaTest,\n\t\t\tdoubleSided: material.side === DoubleSide,\n\t\t\tflipSided: material.side === BackSide,\n\n\t\t\tdepthPacking: ( material.depthPacking !== undefined ) ? material.depthPacking : false,\n\n\t\t\tindex0AttributeName: material.index0AttributeName,\n\n\t\t\textensionDerivatives: material.extensions && material.extensions.derivatives,\n\t\t\textensionFragDepth: material.extensions && material.extensions.fragDepth,\n\t\t\textensionDrawBuffers: material.extensions && material.extensions.drawBuffers,\n\t\t\textensionShaderTextureLOD: material.extensions && material.extensions.shaderTextureLOD,\n\n\t\t\trendererExtensionFragDepth: isWebGL2 || extensions.get( 'EXT_frag_depth' ) !== null,\n\t\t\trendererExtensionDrawBuffers: isWebGL2 || extensions.get( 'WEBGL_draw_buffers' ) !== null,\n\t\t\trendererExtensionShaderTextureLod: isWebGL2 || extensions.get( 'EXT_shader_texture_lod' ) !== null,\n\n\t\t\tcustomProgramCacheKey: material.customProgramCacheKey()\n\n\t\t};\n\n\t\treturn parameters;\n\n\t}\n\n\tfunction getProgramCacheKey( parameters ) {\n\n\t\tconst array = [];\n\n\t\tif ( parameters.shaderID ) {\n\n\t\t\tarray.push( parameters.shaderID );\n\n\t\t} else {\n\n\t\t\tarray.push( parameters.fragmentShader );\n\t\t\tarray.push( parameters.vertexShader );\n\n\t\t}\n\n\t\tif ( parameters.defines !== undefined ) {\n\n\t\t\tfor ( const name in parameters.defines ) {\n\n\t\t\t\tarray.push( name );\n\t\t\t\tarray.push( parameters.defines[ name ] );\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( parameters.isRawShaderMaterial === undefined ) {\n\n\t\t\tfor ( let i = 0; i < parameterNames.length; i ++ ) {\n\n\t\t\t\tarray.push( parameters[ parameterNames[ i ] ] );\n\n\t\t\t}\n\n\t\t\tarray.push( renderer.outputEncoding );\n\t\t\tarray.push( renderer.gammaFactor );\n\n\t\t}\n\n\t\tarray.push( parameters.customProgramCacheKey );\n\n\t\treturn array.join();\n\n\t}\n\n\tfunction acquireProgram( parameters, cacheKey ) {\n\n\t\tlet program;\n\n\t\t// Check if code has been already compiled\n\t\tfor ( let p = 0, pl = programs.length; p < pl; p ++ ) {\n\n\t\t\tconst preexistingProgram = programs[ p ];\n\n\t\t\tif ( preexistingProgram.cacheKey === cacheKey ) {\n\n\t\t\t\tprogram = preexistingProgram;\n\t\t\t\t++ program.usedTimes;\n\n\t\t\t\tbreak;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( program === undefined ) {\n\n\t\t\tprogram = new WebGLProgram( renderer, cacheKey, parameters, bindingStates );\n\t\t\tprograms.push( program );\n\n\t\t}\n\n\t\treturn program;\n\n\t}\n\n\tfunction releaseProgram( program ) {\n\n\t\tif ( -- program.usedTimes === 0 ) {\n\n\t\t\t// Remove from unordered set\n\t\t\tconst i = programs.indexOf( program );\n\t\t\tprograms[ i ] = programs[ programs.length - 1 ];\n\t\t\tprograms.pop();\n\n\t\t\t// Free WebGL resources\n\t\t\tprogram.destroy();\n\n\t\t}\n\n\t}\n\n\treturn {\n\t\tgetParameters: getParameters,\n\t\tgetProgramCacheKey: getProgramCacheKey,\n\t\tacquireProgram: acquireProgram,\n\t\treleaseProgram: releaseProgram,\n\t\t// Exposed for resource monitoring & error feedback via renderer.info:\n\t\tprograms: programs\n\t};\n\n}\n\n\nexport { WebGLPrograms };\n","/**\n * @author fordacious / fordacious.github.io\n */\n\nfunction WebGLProperties() {\n\n\tlet properties = new WeakMap();\n\n\tfunction get( object ) {\n\n\t\tlet map = properties.get( object );\n\n\t\tif ( map === undefined ) {\n\n\t\t\tmap = {};\n\t\t\tproperties.set( object, map );\n\n\t\t}\n\n\t\treturn map;\n\n\t}\n\n\tfunction remove( object ) {\n\n\t\tproperties.delete( object );\n\n\t}\n\n\tfunction update( object, key, value ) {\n\n\t\tproperties.get( object )[ key ] = value;\n\n\t}\n\n\tfunction dispose() {\n\n\t\tproperties = new WeakMap();\n\n\t}\n\n\treturn {\n\t\tget: get,\n\t\tremove: remove,\n\t\tupdate: update,\n\t\tdispose: dispose\n\t};\n\n}\n\n\nexport { WebGLProperties };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction painterSortStable( a, b ) {\n\n\tif ( a.groupOrder !== b.groupOrder ) {\n\n\t\treturn a.groupOrder - b.groupOrder;\n\n\t} else if ( a.renderOrder !== b.renderOrder ) {\n\n\t\treturn a.renderOrder - b.renderOrder;\n\n\t} else if ( a.program !== b.program ) {\n\n\t\treturn a.program.id - b.program.id;\n\n\t} else if ( a.material.id !== b.material.id ) {\n\n\t\treturn a.material.id - b.material.id;\n\n\t} else if ( a.z !== b.z ) {\n\n\t\treturn a.z - b.z;\n\n\t} else {\n\n\t\treturn a.id - b.id;\n\n\t}\n\n}\n\nfunction reversePainterSortStable( a, b ) {\n\n\tif ( a.groupOrder !== b.groupOrder ) {\n\n\t\treturn a.groupOrder - b.groupOrder;\n\n\t} else if ( a.renderOrder !== b.renderOrder ) {\n\n\t\treturn a.renderOrder - b.renderOrder;\n\n\t} else if ( a.z !== b.z ) {\n\n\t\treturn b.z - a.z;\n\n\t} else {\n\n\t\treturn a.id - b.id;\n\n\t}\n\n}\n\n\nfunction WebGLRenderList() {\n\n\tconst renderItems = [];\n\tlet renderItemsIndex = 0;\n\n\tconst opaque = [];\n\tconst transparent = [];\n\n\tconst defaultProgram = { id: - 1 };\n\n\tfunction init() {\n\n\t\trenderItemsIndex = 0;\n\n\t\topaque.length = 0;\n\t\ttransparent.length = 0;\n\n\t}\n\n\tfunction getNextRenderItem( object, geometry, material, groupOrder, z, group ) {\n\n\t\tlet renderItem = renderItems[ renderItemsIndex ];\n\n\t\tif ( renderItem === undefined ) {\n\n\t\t\trenderItem = {\n\t\t\t\tid: object.id,\n\t\t\t\tobject: object,\n\t\t\t\tgeometry: geometry,\n\t\t\t\tmaterial: material,\n\t\t\t\tprogram: material.program || defaultProgram,\n\t\t\t\tgroupOrder: groupOrder,\n\t\t\t\trenderOrder: object.renderOrder,\n\t\t\t\tz: z,\n\t\t\t\tgroup: group\n\t\t\t};\n\n\t\t\trenderItems[ renderItemsIndex ] = renderItem;\n\n\t\t} else {\n\n\t\t\trenderItem.id = object.id;\n\t\t\trenderItem.object = object;\n\t\t\trenderItem.geometry = geometry;\n\t\t\trenderItem.material = material;\n\t\t\trenderItem.program = material.program || defaultProgram;\n\t\t\trenderItem.groupOrder = groupOrder;\n\t\t\trenderItem.renderOrder = object.renderOrder;\n\t\t\trenderItem.z = z;\n\t\t\trenderItem.group = group;\n\n\t\t}\n\n\t\trenderItemsIndex ++;\n\n\t\treturn renderItem;\n\n\t}\n\n\tfunction push( object, geometry, material, groupOrder, z, group ) {\n\n\t\tconst renderItem = getNextRenderItem( object, geometry, material, groupOrder, z, group );\n\n\t\t( material.transparent === true ? transparent : opaque ).push( renderItem );\n\n\t}\n\n\tfunction unshift( object, geometry, material, groupOrder, z, group ) {\n\n\t\tconst renderItem = getNextRenderItem( object, geometry, material, groupOrder, z, group );\n\n\t\t( material.transparent === true ? transparent : opaque ).unshift( renderItem );\n\n\t}\n\n\tfunction sort( customOpaqueSort, customTransparentSort ) {\n\n\t\tif ( opaque.length > 1 ) opaque.sort( customOpaqueSort || painterSortStable );\n\t\tif ( transparent.length > 1 ) transparent.sort( customTransparentSort || reversePainterSortStable );\n\n\t}\n\n\tfunction finish() {\n\n\t\t// Clear references from inactive renderItems in the list\n\n\t\tfor ( let i = renderItemsIndex, il = renderItems.length; i < il; i ++ ) {\n\n\t\t\tconst renderItem = renderItems[ i ];\n\n\t\t\tif ( renderItem.id === null ) break;\n\n\t\t\trenderItem.id = null;\n\t\t\trenderItem.object = null;\n\t\t\trenderItem.geometry = null;\n\t\t\trenderItem.material = null;\n\t\t\trenderItem.program = null;\n\t\t\trenderItem.group = null;\n\n\t\t}\n\n\t}\n\n\treturn {\n\t\topaque: opaque,\n\t\ttransparent: transparent,\n\n\t\tinit: init,\n\t\tpush: push,\n\t\tunshift: unshift,\n\t\tfinish: finish,\n\n\t\tsort: sort\n\t};\n\n}\n\nfunction WebGLRenderLists() {\n\n\tlet lists = new WeakMap();\n\n\tfunction onSceneDispose( event ) {\n\n\t\tconst scene = event.target;\n\n\t\tscene.removeEventListener( 'dispose', onSceneDispose );\n\n\t\tlists.delete( scene );\n\n\t}\n\n\tfunction get( scene, camera ) {\n\n\t\tconst cameras = lists.get( scene );\n\t\tlet list;\n\n\t\tif ( cameras === undefined ) {\n\n\t\t\tlist = new WebGLRenderList();\n\t\t\tlists.set( scene, new WeakMap() );\n\t\t\tlists.get( scene ).set( camera, list );\n\n\t\t\tscene.addEventListener( 'dispose', onSceneDispose );\n\n\t\t} else {\n\n\t\t\tlist = cameras.get( camera );\n\t\t\tif ( list === undefined ) {\n\n\t\t\t\tlist = new WebGLRenderList();\n\t\t\t\tcameras.set( camera, list );\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn list;\n\n\t}\n\n\tfunction dispose() {\n\n\t\tlists = new WeakMap();\n\n\t}\n\n\treturn {\n\t\tget: get,\n\t\tdispose: dispose\n\t};\n\n}\n\n\nexport { WebGLRenderLists };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { Color } from '../../math/Color.js';\nimport { Matrix4 } from '../../math/Matrix4.js';\nimport { Vector2 } from '../../math/Vector2.js';\nimport { Vector3 } from '../../math/Vector3.js';\n\nfunction UniformsCache() {\n\n\tconst lights = {};\n\n\treturn {\n\n\t\tget: function ( light ) {\n\n\t\t\tif ( lights[ light.id ] !== undefined ) {\n\n\t\t\t\treturn lights[ light.id ];\n\n\t\t\t}\n\n\t\t\tlet uniforms;\n\n\t\t\tswitch ( light.type ) {\n\n\t\t\t\tcase 'DirectionalLight':\n\t\t\t\t\tuniforms = {\n\t\t\t\t\t\tdirection: new Vector3(),\n\t\t\t\t\t\tcolor: new Color()\n\t\t\t\t\t};\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'SpotLight':\n\t\t\t\t\tuniforms = {\n\t\t\t\t\t\tposition: new Vector3(),\n\t\t\t\t\t\tdirection: new Vector3(),\n\t\t\t\t\t\tcolor: new Color(),\n\t\t\t\t\t\tdistance: 0,\n\t\t\t\t\t\tconeCos: 0,\n\t\t\t\t\t\tpenumbraCos: 0,\n\t\t\t\t\t\tdecay: 0\n\t\t\t\t\t};\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'PointLight':\n\t\t\t\t\tuniforms = {\n\t\t\t\t\t\tposition: new Vector3(),\n\t\t\t\t\t\tcolor: new Color(),\n\t\t\t\t\t\tdistance: 0,\n\t\t\t\t\t\tdecay: 0\n\t\t\t\t\t};\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'HemisphereLight':\n\t\t\t\t\tuniforms = {\n\t\t\t\t\t\tdirection: new Vector3(),\n\t\t\t\t\t\tskyColor: new Color(),\n\t\t\t\t\t\tgroundColor: new Color()\n\t\t\t\t\t};\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'RectAreaLight':\n\t\t\t\t\tuniforms = {\n\t\t\t\t\t\tcolor: new Color(),\n\t\t\t\t\t\tposition: new Vector3(),\n\t\t\t\t\t\thalfWidth: new Vector3(),\n\t\t\t\t\t\thalfHeight: new Vector3()\n\t\t\t\t\t};\n\t\t\t\t\tbreak;\n\n\t\t\t}\n\n\t\t\tlights[ light.id ] = uniforms;\n\n\t\t\treturn uniforms;\n\n\t\t}\n\n\t};\n\n}\n\nfunction ShadowUniformsCache() {\n\n\tconst lights = {};\n\n\treturn {\n\n\t\tget: function ( light ) {\n\n\t\t\tif ( lights[ light.id ] !== undefined ) {\n\n\t\t\t\treturn lights[ light.id ];\n\n\t\t\t}\n\n\t\t\tlet uniforms;\n\n\t\t\tswitch ( light.type ) {\n\n\t\t\t\tcase 'DirectionalLight':\n\t\t\t\t\tuniforms = {\n\t\t\t\t\t\tshadowBias: 0,\n\t\t\t\t\t\tshadowNormalBias: 0,\n\t\t\t\t\t\tshadowRadius: 1,\n\t\t\t\t\t\tshadowMapSize: new Vector2()\n\t\t\t\t\t};\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'SpotLight':\n\t\t\t\t\tuniforms = {\n\t\t\t\t\t\tshadowBias: 0,\n\t\t\t\t\t\tshadowNormalBias: 0,\n\t\t\t\t\t\tshadowRadius: 1,\n\t\t\t\t\t\tshadowMapSize: new Vector2()\n\t\t\t\t\t};\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'PointLight':\n\t\t\t\t\tuniforms = {\n\t\t\t\t\t\tshadowBias: 0,\n\t\t\t\t\t\tshadowNormalBias: 0,\n\t\t\t\t\t\tshadowRadius: 1,\n\t\t\t\t\t\tshadowMapSize: new Vector2(),\n\t\t\t\t\t\tshadowCameraNear: 1,\n\t\t\t\t\t\tshadowCameraFar: 1000\n\t\t\t\t\t};\n\t\t\t\t\tbreak;\n\n\t\t\t\t// TODO (abelnation): set RectAreaLight shadow uniforms\n\n\t\t\t}\n\n\t\t\tlights[ light.id ] = uniforms;\n\n\t\t\treturn uniforms;\n\n\t\t}\n\n\t};\n\n}\n\n\n\nlet nextVersion = 0;\n\nfunction shadowCastingLightsFirst( lightA, lightB ) {\n\n\treturn ( lightB.castShadow ? 1 : 0 ) - ( lightA.castShadow ? 1 : 0 );\n\n}\n\nfunction WebGLLights() {\n\n\tconst cache = new UniformsCache();\n\n\tconst shadowCache = ShadowUniformsCache();\n\n\tconst state = {\n\n\t\tversion: 0,\n\n\t\thash: {\n\t\t\tdirectionalLength: - 1,\n\t\t\tpointLength: - 1,\n\t\t\tspotLength: - 1,\n\t\t\trectAreaLength: - 1,\n\t\t\themiLength: - 1,\n\n\t\t\tnumDirectionalShadows: - 1,\n\t\t\tnumPointShadows: - 1,\n\t\t\tnumSpotShadows: - 1\n\t\t},\n\n\t\tambient: [ 0, 0, 0 ],\n\t\tprobe: [],\n\t\tdirectional: [],\n\t\tdirectionalShadow: [],\n\t\tdirectionalShadowMap: [],\n\t\tdirectionalShadowMatrix: [],\n\t\tspot: [],\n\t\tspotShadow: [],\n\t\tspotShadowMap: [],\n\t\tspotShadowMatrix: [],\n\t\trectArea: [],\n\t\tpoint: [],\n\t\tpointShadow: [],\n\t\tpointShadowMap: [],\n\t\tpointShadowMatrix: [],\n\t\themi: []\n\n\t};\n\n\tfor ( let i = 0; i < 9; i ++ ) state.probe.push( new Vector3() );\n\n\tconst vector3 = new Vector3();\n\tconst matrix4 = new Matrix4();\n\tconst matrix42 = new Matrix4();\n\n\tfunction setup( lights, shadows, camera ) {\n\n\t\tlet r = 0, g = 0, b = 0;\n\n\t\tfor ( let i = 0; i < 9; i ++ ) state.probe[ i ].set( 0, 0, 0 );\n\n\t\tlet directionalLength = 0;\n\t\tlet pointLength = 0;\n\t\tlet spotLength = 0;\n\t\tlet rectAreaLength = 0;\n\t\tlet hemiLength = 0;\n\n\t\tlet numDirectionalShadows = 0;\n\t\tlet numPointShadows = 0;\n\t\tlet numSpotShadows = 0;\n\n\t\tconst viewMatrix = camera.matrixWorldInverse;\n\n\t\tlights.sort( shadowCastingLightsFirst );\n\n\t\tfor ( let i = 0, l = lights.length; i < l; i ++ ) {\n\n\t\t\tconst light = lights[ i ];\n\n\t\t\tconst color = light.color;\n\t\t\tconst intensity = light.intensity;\n\t\t\tconst distance = light.distance;\n\n\t\t\tconst shadowMap = ( light.shadow && light.shadow.map ) ? light.shadow.map.texture : null;\n\n\t\t\tif ( light.isAmbientLight ) {\n\n\t\t\t\tr += color.r * intensity;\n\t\t\t\tg += color.g * intensity;\n\t\t\t\tb += color.b * intensity;\n\n\t\t\t} else if ( light.isLightProbe ) {\n\n\t\t\t\tfor ( let j = 0; j < 9; j ++ ) {\n\n\t\t\t\t\tstate.probe[ j ].addScaledVector( light.sh.coefficients[ j ], intensity );\n\n\t\t\t\t}\n\n\t\t\t} else if ( light.isDirectionalLight ) {\n\n\t\t\t\tconst uniforms = cache.get( light );\n\n\t\t\t\tuniforms.color.copy( light.color ).multiplyScalar( light.intensity );\n\t\t\t\tuniforms.direction.setFromMatrixPosition( light.matrixWorld );\n\t\t\t\tvector3.setFromMatrixPosition( light.target.matrixWorld );\n\t\t\t\tuniforms.direction.sub( vector3 );\n\t\t\t\tuniforms.direction.transformDirection( viewMatrix );\n\n\t\t\t\tif ( light.castShadow ) {\n\n\t\t\t\t\tconst shadow = light.shadow;\n\n\t\t\t\t\tconst shadowUniforms = shadowCache.get( light );\n\n\t\t\t\t\tshadowUniforms.shadowBias = shadow.bias;\n\t\t\t\t\tshadowUniforms.shadowNormalBias = shadow.normalBias;\n\t\t\t\t\tshadowUniforms.shadowRadius = shadow.radius;\n\t\t\t\t\tshadowUniforms.shadowMapSize = shadow.mapSize;\n\n\t\t\t\t\tstate.directionalShadow[ directionalLength ] = shadowUniforms;\n\t\t\t\t\tstate.directionalShadowMap[ directionalLength ] = shadowMap;\n\t\t\t\t\tstate.directionalShadowMatrix[ directionalLength ] = light.shadow.matrix;\n\n\t\t\t\t\tnumDirectionalShadows ++;\n\n\t\t\t\t}\n\n\t\t\t\tstate.directional[ directionalLength ] = uniforms;\n\n\t\t\t\tdirectionalLength ++;\n\n\t\t\t} else if ( light.isSpotLight ) {\n\n\t\t\t\tconst uniforms = cache.get( light );\n\n\t\t\t\tuniforms.position.setFromMatrixPosition( light.matrixWorld );\n\t\t\t\tuniforms.position.applyMatrix4( viewMatrix );\n\n\t\t\t\tuniforms.color.copy( color ).multiplyScalar( intensity );\n\t\t\t\tuniforms.distance = distance;\n\n\t\t\t\tuniforms.direction.setFromMatrixPosition( light.matrixWorld );\n\t\t\t\tvector3.setFromMatrixPosition( light.target.matrixWorld );\n\t\t\t\tuniforms.direction.sub( vector3 );\n\t\t\t\tuniforms.direction.transformDirection( viewMatrix );\n\n\t\t\t\tuniforms.coneCos = Math.cos( light.angle );\n\t\t\t\tuniforms.penumbraCos = Math.cos( light.angle * ( 1 - light.penumbra ) );\n\t\t\t\tuniforms.decay = light.decay;\n\n\t\t\t\tif ( light.castShadow ) {\n\n\t\t\t\t\tconst shadow = light.shadow;\n\n\t\t\t\t\tconst shadowUniforms = shadowCache.get( light );\n\n\t\t\t\t\tshadowUniforms.shadowBias = shadow.bias;\n\t\t\t\t\tshadowUniforms.shadowNormalBias = shadow.normalBias;\n\t\t\t\t\tshadowUniforms.shadowRadius = shadow.radius;\n\t\t\t\t\tshadowUniforms.shadowMapSize = shadow.mapSize;\n\n\t\t\t\t\tstate.spotShadow[ spotLength ] = shadowUniforms;\n\t\t\t\t\tstate.spotShadowMap[ spotLength ] = shadowMap;\n\t\t\t\t\tstate.spotShadowMatrix[ spotLength ] = light.shadow.matrix;\n\n\t\t\t\t\tnumSpotShadows ++;\n\n\t\t\t\t}\n\n\t\t\t\tstate.spot[ spotLength ] = uniforms;\n\n\t\t\t\tspotLength ++;\n\n\t\t\t} else if ( light.isRectAreaLight ) {\n\n\t\t\t\tconst uniforms = cache.get( light );\n\n\t\t\t\t// (a) intensity is the total visible light emitted\n\t\t\t\t//uniforms.color.copy( color ).multiplyScalar( intensity / ( light.width * light.height * Math.PI ) );\n\n\t\t\t\t// (b) intensity is the brightness of the light\n\t\t\t\tuniforms.color.copy( color ).multiplyScalar( intensity );\n\n\t\t\t\tuniforms.position.setFromMatrixPosition( light.matrixWorld );\n\t\t\t\tuniforms.position.applyMatrix4( viewMatrix );\n\n\t\t\t\t// extract local rotation of light to derive width/height half vectors\n\t\t\t\tmatrix42.identity();\n\t\t\t\tmatrix4.copy( light.matrixWorld );\n\t\t\t\tmatrix4.premultiply( viewMatrix );\n\t\t\t\tmatrix42.extractRotation( matrix4 );\n\n\t\t\t\tuniforms.halfWidth.set( light.width * 0.5, 0.0, 0.0 );\n\t\t\t\tuniforms.halfHeight.set( 0.0, light.height * 0.5, 0.0 );\n\n\t\t\t\tuniforms.halfWidth.applyMatrix4( matrix42 );\n\t\t\t\tuniforms.halfHeight.applyMatrix4( matrix42 );\n\n\t\t\t\t// TODO (abelnation): RectAreaLight distance?\n\t\t\t\t// uniforms.distance = distance;\n\n\t\t\t\tstate.rectArea[ rectAreaLength ] = uniforms;\n\n\t\t\t\trectAreaLength ++;\n\n\t\t\t} else if ( light.isPointLight ) {\n\n\t\t\t\tconst uniforms = cache.get( light );\n\n\t\t\t\tuniforms.position.setFromMatrixPosition( light.matrixWorld );\n\t\t\t\tuniforms.position.applyMatrix4( viewMatrix );\n\n\t\t\t\tuniforms.color.copy( light.color ).multiplyScalar( light.intensity );\n\t\t\t\tuniforms.distance = light.distance;\n\t\t\t\tuniforms.decay = light.decay;\n\n\t\t\t\tif ( light.castShadow ) {\n\n\t\t\t\t\tconst shadow = light.shadow;\n\n\t\t\t\t\tconst shadowUniforms = shadowCache.get( light );\n\n\t\t\t\t\tshadowUniforms.shadowBias = shadow.bias;\n\t\t\t\t\tshadowUniforms.shadowNormalBias = shadow.normalBias;\n\t\t\t\t\tshadowUniforms.shadowRadius = shadow.radius;\n\t\t\t\t\tshadowUniforms.shadowMapSize = shadow.mapSize;\n\t\t\t\t\tshadowUniforms.shadowCameraNear = shadow.camera.near;\n\t\t\t\t\tshadowUniforms.shadowCameraFar = shadow.camera.far;\n\n\t\t\t\t\tstate.pointShadow[ pointLength ] = shadowUniforms;\n\t\t\t\t\tstate.pointShadowMap[ pointLength ] = shadowMap;\n\t\t\t\t\tstate.pointShadowMatrix[ pointLength ] = light.shadow.matrix;\n\n\t\t\t\t\tnumPointShadows ++;\n\n\t\t\t\t}\n\n\t\t\t\tstate.point[ pointLength ] = uniforms;\n\n\t\t\t\tpointLength ++;\n\n\t\t\t} else if ( light.isHemisphereLight ) {\n\n\t\t\t\tconst uniforms = cache.get( light );\n\n\t\t\t\tuniforms.direction.setFromMatrixPosition( light.matrixWorld );\n\t\t\t\tuniforms.direction.transformDirection( viewMatrix );\n\t\t\t\tuniforms.direction.normalize();\n\n\t\t\t\tuniforms.skyColor.copy( light.color ).multiplyScalar( intensity );\n\t\t\t\tuniforms.groundColor.copy( light.groundColor ).multiplyScalar( intensity );\n\n\t\t\t\tstate.hemi[ hemiLength ] = uniforms;\n\n\t\t\t\themiLength ++;\n\n\t\t\t}\n\n\t\t}\n\n\t\tstate.ambient[ 0 ] = r;\n\t\tstate.ambient[ 1 ] = g;\n\t\tstate.ambient[ 2 ] = b;\n\n\t\tconst hash = state.hash;\n\n\t\tif ( hash.directionalLength !== directionalLength ||\n\t\t\thash.pointLength !== pointLength ||\n\t\t\thash.spotLength !== spotLength ||\n\t\t\thash.rectAreaLength !== rectAreaLength ||\n\t\t\thash.hemiLength !== hemiLength ||\n\t\t\thash.numDirectionalShadows !== numDirectionalShadows ||\n\t\t\thash.numPointShadows !== numPointShadows ||\n\t\t\thash.numSpotShadows !== numSpotShadows ) {\n\n\t\t\tstate.directional.length = directionalLength;\n\t\t\tstate.spot.length = spotLength;\n\t\t\tstate.rectArea.length = rectAreaLength;\n\t\t\tstate.point.length = pointLength;\n\t\t\tstate.hemi.length = hemiLength;\n\n\t\t\tstate.directionalShadow.length = numDirectionalShadows;\n\t\t\tstate.directionalShadowMap.length = numDirectionalShadows;\n\t\t\tstate.pointShadow.length = numPointShadows;\n\t\t\tstate.pointShadowMap.length = numPointShadows;\n\t\t\tstate.spotShadow.length = numSpotShadows;\n\t\t\tstate.spotShadowMap.length = numSpotShadows;\n\t\t\tstate.directionalShadowMatrix.length = numDirectionalShadows;\n\t\t\tstate.pointShadowMatrix.length = numPointShadows;\n\t\t\tstate.spotShadowMatrix.length = numSpotShadows;\n\n\t\t\thash.directionalLength = directionalLength;\n\t\t\thash.pointLength = pointLength;\n\t\t\thash.spotLength = spotLength;\n\t\t\thash.rectAreaLength = rectAreaLength;\n\t\t\thash.hemiLength = hemiLength;\n\n\t\t\thash.numDirectionalShadows = numDirectionalShadows;\n\t\t\thash.numPointShadows = numPointShadows;\n\t\t\thash.numSpotShadows = numSpotShadows;\n\n\t\t\tstate.version = nextVersion ++;\n\n\t\t}\n\n\t}\n\n\treturn {\n\t\tsetup: setup,\n\t\tstate: state\n\t};\n\n}\n\n\nexport { WebGLLights };\n","/**\n * @author Mugen87 / https://github.com/Mugen87\n */\n\nimport { WebGLLights } from './WebGLLights.js';\n\nfunction WebGLRenderState() {\n\n\tconst lights = new WebGLLights();\n\n\tconst lightsArray = [];\n\tconst shadowsArray = [];\n\n\tfunction init() {\n\n\t\tlightsArray.length = 0;\n\t\tshadowsArray.length = 0;\n\n\t}\n\n\tfunction pushLight( light ) {\n\n\t\tlightsArray.push( light );\n\n\t}\n\n\tfunction pushShadow( shadowLight ) {\n\n\t\tshadowsArray.push( shadowLight );\n\n\t}\n\n\tfunction setupLights( camera ) {\n\n\t\tlights.setup( lightsArray, shadowsArray, camera );\n\n\t}\n\n\tconst state = {\n\t\tlightsArray: lightsArray,\n\t\tshadowsArray: shadowsArray,\n\n\t\tlights: lights\n\t};\n\n\treturn {\n\t\tinit: init,\n\t\tstate: state,\n\t\tsetupLights: setupLights,\n\n\t\tpushLight: pushLight,\n\t\tpushShadow: pushShadow\n\t};\n\n}\n\nfunction WebGLRenderStates() {\n\n\tlet renderStates = new WeakMap();\n\n\tfunction onSceneDispose( event ) {\n\n\t\tconst scene = event.target;\n\n\t\tscene.removeEventListener( 'dispose', onSceneDispose );\n\n\t\trenderStates.delete( scene );\n\n\t}\n\n\tfunction get( scene, camera ) {\n\n\t\tlet renderState;\n\n\t\tif ( renderStates.has( scene ) === false ) {\n\n\t\t\trenderState = new WebGLRenderState();\n\t\t\trenderStates.set( scene, new WeakMap() );\n\t\t\trenderStates.get( scene ).set( camera, renderState );\n\n\t\t\tscene.addEventListener( 'dispose', onSceneDispose );\n\n\t\t} else {\n\n\t\t\tif ( renderStates.get( scene ).has( camera ) === false ) {\n\n\t\t\t\trenderState = new WebGLRenderState();\n\t\t\t\trenderStates.get( scene ).set( camera, renderState );\n\n\t\t\t} else {\n\n\t\t\t\trenderState = renderStates.get( scene ).get( camera );\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn renderState;\n\n\t}\n\n\tfunction dispose() {\n\n\t\trenderStates = new WeakMap();\n\n\t}\n\n\treturn {\n\t\tget: get,\n\t\tdispose: dispose\n\t};\n\n}\n\n\nexport { WebGLRenderStates };\n","import { Material } from './Material.js';\nimport { BasicDepthPacking } from '../constants.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author alteredq / http://alteredqualia.com/\n * @author bhouston / https://clara.io\n * @author WestLangley / http://github.com/WestLangley\n *\n * parameters = {\n *\n * opacity: ,\n *\n * map: new THREE.Texture( ),\n *\n * alphaMap: new THREE.Texture( ),\n *\n * displacementMap: new THREE.Texture( ),\n * displacementScale: ,\n * displacementBias: ,\n *\n * wireframe: ,\n * wireframeLinewidth: \n * }\n */\n\nfunction MeshDepthMaterial( parameters ) {\n\n\tMaterial.call( this );\n\n\tthis.type = 'MeshDepthMaterial';\n\n\tthis.depthPacking = BasicDepthPacking;\n\n\tthis.skinning = false;\n\tthis.morphTargets = false;\n\n\tthis.map = null;\n\n\tthis.alphaMap = null;\n\n\tthis.displacementMap = null;\n\tthis.displacementScale = 1;\n\tthis.displacementBias = 0;\n\n\tthis.wireframe = false;\n\tthis.wireframeLinewidth = 1;\n\n\tthis.fog = false;\n\n\tthis.setValues( parameters );\n\n}\n\nMeshDepthMaterial.prototype = Object.create( Material.prototype );\nMeshDepthMaterial.prototype.constructor = MeshDepthMaterial;\n\nMeshDepthMaterial.prototype.isMeshDepthMaterial = true;\n\nMeshDepthMaterial.prototype.copy = function ( source ) {\n\n\tMaterial.prototype.copy.call( this, source );\n\n\tthis.depthPacking = source.depthPacking;\n\n\tthis.skinning = source.skinning;\n\tthis.morphTargets = source.morphTargets;\n\n\tthis.map = source.map;\n\n\tthis.alphaMap = source.alphaMap;\n\n\tthis.displacementMap = source.displacementMap;\n\tthis.displacementScale = source.displacementScale;\n\tthis.displacementBias = source.displacementBias;\n\n\tthis.wireframe = source.wireframe;\n\tthis.wireframeLinewidth = source.wireframeLinewidth;\n\n\treturn this;\n\n};\n\n\nexport { MeshDepthMaterial };\n","import { Material } from './Material.js';\nimport { Vector3 } from '../math/Vector3.js';\n\n/**\n * @author WestLangley / http://github.com/WestLangley\n *\n * parameters = {\n *\n * referencePosition: ,\n * nearDistance: ,\n * farDistance: ,\n *\n * skinning: ,\n * morphTargets: ,\n *\n * map: new THREE.Texture( ),\n *\n * alphaMap: new THREE.Texture( ),\n *\n * displacementMap: new THREE.Texture( ),\n * displacementScale: ,\n * displacementBias: \n *\n * }\n */\n\nfunction MeshDistanceMaterial( parameters ) {\n\n\tMaterial.call( this );\n\n\tthis.type = 'MeshDistanceMaterial';\n\n\tthis.referencePosition = new Vector3();\n\tthis.nearDistance = 1;\n\tthis.farDistance = 1000;\n\n\tthis.skinning = false;\n\tthis.morphTargets = false;\n\n\tthis.map = null;\n\n\tthis.alphaMap = null;\n\n\tthis.displacementMap = null;\n\tthis.displacementScale = 1;\n\tthis.displacementBias = 0;\n\n\tthis.fog = false;\n\n\tthis.setValues( parameters );\n\n}\n\nMeshDistanceMaterial.prototype = Object.create( Material.prototype );\nMeshDistanceMaterial.prototype.constructor = MeshDistanceMaterial;\n\nMeshDistanceMaterial.prototype.isMeshDistanceMaterial = true;\n\nMeshDistanceMaterial.prototype.copy = function ( source ) {\n\n\tMaterial.prototype.copy.call( this, source );\n\n\tthis.referencePosition.copy( source.referencePosition );\n\tthis.nearDistance = source.nearDistance;\n\tthis.farDistance = source.farDistance;\n\n\tthis.skinning = source.skinning;\n\tthis.morphTargets = source.morphTargets;\n\n\tthis.map = source.map;\n\n\tthis.alphaMap = source.alphaMap;\n\n\tthis.displacementMap = source.displacementMap;\n\tthis.displacementScale = source.displacementScale;\n\tthis.displacementBias = source.displacementBias;\n\n\treturn this;\n\n};\n\n\nexport { MeshDistanceMaterial };\n","export default /* glsl */`\nuniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n\n#include \n\nvoid main() {\n\n float mean = 0.0;\n float squared_mean = 0.0;\n\n\t// This seems totally useless but it's a crazy work around for a Adreno compiler bug\n\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy ) / resolution ) );\n\n for ( float i = -1.0; i < 1.0 ; i += SAMPLE_RATE) {\n\n #ifdef HORIZONAL_PASS\n\n vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( i, 0.0 ) * radius ) / resolution ) );\n mean += distribution.x;\n squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\n #else\n\n float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, i ) * radius ) / resolution ) );\n mean += depth;\n squared_mean += depth * depth;\n\n #endif\n\n }\n\n mean = mean * HALF_SAMPLE_RATE;\n squared_mean = squared_mean * HALF_SAMPLE_RATE;\n\n float std_dev = sqrt( squared_mean - mean * mean );\n\n gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n\n}\n`;\n","export default /* glsl */`\nvoid main() {\n\n\tgl_Position = vec4( position, 1.0 );\n\n}\n`;\n","/**\n * @author alteredq / http://alteredqualia.com/\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { FrontSide, BackSide, DoubleSide, RGBAFormat, NearestFilter, LinearFilter, PCFShadowMap, VSMShadowMap, RGBADepthPacking, NoBlending } from '../../constants.js';\nimport { WebGLRenderTarget } from '../WebGLRenderTarget.js';\nimport { MeshDepthMaterial } from '../../materials/MeshDepthMaterial.js';\nimport { MeshDistanceMaterial } from '../../materials/MeshDistanceMaterial.js';\nimport { ShaderMaterial } from '../../materials/ShaderMaterial.js';\nimport { BufferAttribute } from '../../core/BufferAttribute.js';\nimport { BufferGeometry } from '../../core/BufferGeometry.js';\nimport { Mesh } from '../../objects/Mesh.js';\nimport { Vector4 } from '../../math/Vector4.js';\nimport { Vector2 } from '../../math/Vector2.js';\nimport { Frustum } from '../../math/Frustum.js';\n\nimport vsm_frag from '../shaders/ShaderLib/vsm_frag.glsl.js';\nimport vsm_vert from '../shaders/ShaderLib/vsm_vert.glsl.js';\n\nfunction WebGLShadowMap( _renderer, _objects, maxTextureSize ) {\n\n\tlet _frustum = new Frustum();\n\n\tconst _shadowMapSize = new Vector2(),\n\t\t_viewportSize = new Vector2(),\n\n\t\t_viewport = new Vector4(),\n\n\t\t_depthMaterials = [],\n\t\t_distanceMaterials = [],\n\n\t\t_materialCache = {};\n\n\tconst shadowSide = { 0: BackSide, 1: FrontSide, 2: DoubleSide };\n\n\tconst shadowMaterialVertical = new ShaderMaterial( {\n\n\t\tdefines: {\n\t\t\tSAMPLE_RATE: 2.0 / 8.0,\n\t\t\tHALF_SAMPLE_RATE: 1.0 / 8.0\n\t\t},\n\n\t\tuniforms: {\n\t\t\tshadow_pass: { value: null },\n\t\t\tresolution: { value: new Vector2() },\n\t\t\tradius: { value: 4.0 }\n\t\t},\n\n\t\tvertexShader: vsm_vert,\n\n\t\tfragmentShader: vsm_frag\n\n\t} );\n\n\tconst shadowMaterialHorizonal = shadowMaterialVertical.clone();\n\tshadowMaterialHorizonal.defines.HORIZONAL_PASS = 1;\n\n\tconst fullScreenTri = new BufferGeometry();\n\tfullScreenTri.setAttribute(\n\t\t\"position\",\n\t\tnew BufferAttribute(\n\t\t\tnew Float32Array( [ - 1, - 1, 0.5, 3, - 1, 0.5, - 1, 3, 0.5 ] ),\n\t\t\t3\n\t\t)\n\t);\n\n\tconst fullScreenMesh = new Mesh( fullScreenTri, shadowMaterialVertical );\n\n\tconst scope = this;\n\n\tthis.enabled = false;\n\n\tthis.autoUpdate = true;\n\tthis.needsUpdate = false;\n\n\tthis.type = PCFShadowMap;\n\n\tthis.render = function ( lights, scene, camera ) {\n\n\t\tif ( scope.enabled === false ) return;\n\t\tif ( scope.autoUpdate === false && scope.needsUpdate === false ) return;\n\n\t\tif ( lights.length === 0 ) return;\n\n\t\tconst currentRenderTarget = _renderer.getRenderTarget();\n\t\tconst activeCubeFace = _renderer.getActiveCubeFace();\n\t\tconst activeMipmapLevel = _renderer.getActiveMipmapLevel();\n\n\t\tconst _state = _renderer.state;\n\n\t\t// Set GL state for depth map.\n\t\t_state.setBlending( NoBlending );\n\t\t_state.buffers.color.setClear( 1, 1, 1, 1 );\n\t\t_state.buffers.depth.setTest( true );\n\t\t_state.setScissorTest( false );\n\n\t\t// render depth map\n\n\t\tfor ( let i = 0, il = lights.length; i < il; i ++ ) {\n\n\t\t\tconst light = lights[ i ];\n\t\t\tconst shadow = light.shadow;\n\n\t\t\tif ( shadow.autoUpdate === false && shadow.needsUpdate === false ) continue;\n\n\t\t\tif ( shadow === undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLShadowMap:', light, 'has no shadow.' );\n\t\t\t\tcontinue;\n\n\t\t\t}\n\n\t\t\t_shadowMapSize.copy( shadow.mapSize );\n\n\t\t\tconst shadowFrameExtents = shadow.getFrameExtents();\n\n\t\t\t_shadowMapSize.multiply( shadowFrameExtents );\n\n\t\t\t_viewportSize.copy( shadow.mapSize );\n\n\t\t\tif ( _shadowMapSize.x > maxTextureSize || _shadowMapSize.y > maxTextureSize ) {\n\n\t\t\t\tif ( _shadowMapSize.x > maxTextureSize ) {\n\n\t\t\t\t\t_viewportSize.x = Math.floor( maxTextureSize / shadowFrameExtents.x );\n\t\t\t\t\t_shadowMapSize.x = _viewportSize.x * shadowFrameExtents.x;\n\t\t\t\t\tshadow.mapSize.x = _viewportSize.x;\n\n\t\t\t\t}\n\n\t\t\t\tif ( _shadowMapSize.y > maxTextureSize ) {\n\n\t\t\t\t\t_viewportSize.y = Math.floor( maxTextureSize / shadowFrameExtents.y );\n\t\t\t\t\t_shadowMapSize.y = _viewportSize.y * shadowFrameExtents.y;\n\t\t\t\t\tshadow.mapSize.y = _viewportSize.y;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif ( shadow.map === null && ! shadow.isPointLightShadow && this.type === VSMShadowMap ) {\n\n\t\t\t\tconst pars = { minFilter: LinearFilter, magFilter: LinearFilter, format: RGBAFormat };\n\n\t\t\t\tshadow.map = new WebGLRenderTarget( _shadowMapSize.x, _shadowMapSize.y, pars );\n\t\t\t\tshadow.map.texture.name = light.name + \".shadowMap\";\n\n\t\t\t\tshadow.mapPass = new WebGLRenderTarget( _shadowMapSize.x, _shadowMapSize.y, pars );\n\n\t\t\t\tshadow.camera.updateProjectionMatrix();\n\n\t\t\t}\n\n\t\t\tif ( shadow.map === null ) {\n\n\t\t\t\tconst pars = { minFilter: NearestFilter, magFilter: NearestFilter, format: RGBAFormat };\n\n\t\t\t\tshadow.map = new WebGLRenderTarget( _shadowMapSize.x, _shadowMapSize.y, pars );\n\t\t\t\tshadow.map.texture.name = light.name + \".shadowMap\";\n\n\t\t\t\tshadow.camera.updateProjectionMatrix();\n\n\t\t\t}\n\n\t\t\t_renderer.setRenderTarget( shadow.map );\n\t\t\t_renderer.clear();\n\n\t\t\tconst viewportCount = shadow.getViewportCount();\n\n\t\t\tfor ( let vp = 0; vp < viewportCount; vp ++ ) {\n\n\t\t\t\tconst viewport = shadow.getViewport( vp );\n\n\t\t\t\t_viewport.set(\n\t\t\t\t\t_viewportSize.x * viewport.x,\n\t\t\t\t\t_viewportSize.y * viewport.y,\n\t\t\t\t\t_viewportSize.x * viewport.z,\n\t\t\t\t\t_viewportSize.y * viewport.w\n\t\t\t\t);\n\n\t\t\t\t_state.viewport( _viewport );\n\n\t\t\t\tshadow.updateMatrices( light, vp );\n\n\t\t\t\t_frustum = shadow.getFrustum();\n\n\t\t\t\trenderObject( scene, camera, shadow.camera, light, this.type );\n\n\t\t\t}\n\n\t\t\t// do blur pass for VSM\n\n\t\t\tif ( ! shadow.isPointLightShadow && this.type === VSMShadowMap ) {\n\n\t\t\t\tVSMPass( shadow, camera );\n\n\t\t\t}\n\n\t\t\tshadow.needsUpdate = false;\n\n\t\t}\n\n\t\tscope.needsUpdate = false;\n\n\t\t_renderer.setRenderTarget( currentRenderTarget, activeCubeFace, activeMipmapLevel );\n\n\t};\n\n\tfunction VSMPass( shadow, camera ) {\n\n\t\tconst geometry = _objects.update( fullScreenMesh );\n\n\t\t// vertical pass\n\n\t\tshadowMaterialVertical.uniforms.shadow_pass.value = shadow.map.texture;\n\t\tshadowMaterialVertical.uniforms.resolution.value = shadow.mapSize;\n\t\tshadowMaterialVertical.uniforms.radius.value = shadow.radius;\n\t\t_renderer.setRenderTarget( shadow.mapPass );\n\t\t_renderer.clear();\n\t\t_renderer.renderBufferDirect( camera, null, geometry, shadowMaterialVertical, fullScreenMesh, null );\n\n\t\t// horizonal pass\n\n\t\tshadowMaterialHorizonal.uniforms.shadow_pass.value = shadow.mapPass.texture;\n\t\tshadowMaterialHorizonal.uniforms.resolution.value = shadow.mapSize;\n\t\tshadowMaterialHorizonal.uniforms.radius.value = shadow.radius;\n\t\t_renderer.setRenderTarget( shadow.map );\n\t\t_renderer.clear();\n\t\t_renderer.renderBufferDirect( camera, null, geometry, shadowMaterialHorizonal, fullScreenMesh, null );\n\n\t}\n\n\tfunction getDepthMaterialVariant( useMorphing, useSkinning, useInstancing ) {\n\n\t\tconst index = useMorphing << 0 | useSkinning << 1 | useInstancing << 2;\n\n\t\tlet material = _depthMaterials[ index ];\n\n\t\tif ( material === undefined ) {\n\n\t\t\tmaterial = new MeshDepthMaterial( {\n\n\t\t\t\tdepthPacking: RGBADepthPacking,\n\n\t\t\t\tmorphTargets: useMorphing,\n\t\t\t\tskinning: useSkinning\n\n\t\t\t} );\n\n\t\t\t_depthMaterials[ index ] = material;\n\n\t\t}\n\n\t\treturn material;\n\n\t}\n\n\tfunction getDistanceMaterialVariant( useMorphing, useSkinning, useInstancing ) {\n\n\t\tconst index = useMorphing << 0 | useSkinning << 1 | useInstancing << 2;\n\n\t\tlet material = _distanceMaterials[ index ];\n\n\t\tif ( material === undefined ) {\n\n\t\t\tmaterial = new MeshDistanceMaterial( {\n\n\t\t\t\tmorphTargets: useMorphing,\n\t\t\t\tskinning: useSkinning\n\n\t\t\t} );\n\n\t\t\t_distanceMaterials[ index ] = material;\n\n\t\t}\n\n\t\treturn material;\n\n\t}\n\n\tfunction getDepthMaterial( object, geometry, material, light, shadowCameraNear, shadowCameraFar, type ) {\n\n\t\tlet result = null;\n\n\t\tlet getMaterialVariant = getDepthMaterialVariant;\n\t\tlet customMaterial = object.customDepthMaterial;\n\n\t\tif ( light.isPointLight === true ) {\n\n\t\t\tgetMaterialVariant = getDistanceMaterialVariant;\n\t\t\tcustomMaterial = object.customDistanceMaterial;\n\n\t\t}\n\n\t\tif ( customMaterial === undefined ) {\n\n\t\t\tlet useMorphing = false;\n\n\t\t\tif ( material.morphTargets === true ) {\n\n\t\t\t\tuseMorphing = geometry.morphAttributes && geometry.morphAttributes.position && geometry.morphAttributes.position.length > 0;\n\n\t\t\t}\n\n\t\t\tlet useSkinning = false;\n\n\t\t\tif ( object.isSkinnedMesh === true ) {\n\n\t\t\t\tif ( material.skinning === true ) {\n\n\t\t\t\t\tuseSkinning = true;\n\n\t\t\t\t} else {\n\n\t\t\t\t\tconsole.warn( 'THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:', object );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tconst useInstancing = object.isInstancedMesh === true;\n\n\t\t\tresult = getMaterialVariant( useMorphing, useSkinning, useInstancing );\n\n\t\t} else {\n\n\t\t\tresult = customMaterial;\n\n\t\t}\n\n\t\tif ( _renderer.localClippingEnabled &&\n\t\t\t\tmaterial.clipShadows === true &&\n\t\t\t\tmaterial.clippingPlanes.length !== 0 ) {\n\n\t\t\t// in this case we need a unique material instance reflecting the\n\t\t\t// appropriate state\n\n\t\t\tconst keyA = result.uuid, keyB = material.uuid;\n\n\t\t\tlet materialsForVariant = _materialCache[ keyA ];\n\n\t\t\tif ( materialsForVariant === undefined ) {\n\n\t\t\t\tmaterialsForVariant = {};\n\t\t\t\t_materialCache[ keyA ] = materialsForVariant;\n\n\t\t\t}\n\n\t\t\tlet cachedMaterial = materialsForVariant[ keyB ];\n\n\t\t\tif ( cachedMaterial === undefined ) {\n\n\t\t\t\tcachedMaterial = result.clone();\n\t\t\t\tmaterialsForVariant[ keyB ] = cachedMaterial;\n\n\t\t\t}\n\n\t\t\tresult = cachedMaterial;\n\n\t\t}\n\n\t\tresult.visible = material.visible;\n\t\tresult.wireframe = material.wireframe;\n\n\t\tif ( type === VSMShadowMap ) {\n\n\t\t\tresult.side = ( material.shadowSide !== null ) ? material.shadowSide : material.side;\n\n\t\t} else {\n\n\t\t\tresult.side = ( material.shadowSide !== null ) ? material.shadowSide : shadowSide[ material.side ];\n\n\t\t}\n\n\t\tresult.clipShadows = material.clipShadows;\n\t\tresult.clippingPlanes = material.clippingPlanes;\n\t\tresult.clipIntersection = material.clipIntersection;\n\n\t\tresult.wireframeLinewidth = material.wireframeLinewidth;\n\t\tresult.linewidth = material.linewidth;\n\n\t\tif ( light.isPointLight === true && result.isMeshDistanceMaterial === true ) {\n\n\t\t\tresult.referencePosition.setFromMatrixPosition( light.matrixWorld );\n\t\t\tresult.nearDistance = shadowCameraNear;\n\t\t\tresult.farDistance = shadowCameraFar;\n\n\t\t}\n\n\t\treturn result;\n\n\t}\n\n\tfunction renderObject( object, camera, shadowCamera, light, type ) {\n\n\t\tif ( object.visible === false ) return;\n\n\t\tconst visible = object.layers.test( camera.layers );\n\n\t\tif ( visible && ( object.isMesh || object.isLine || object.isPoints ) ) {\n\n\t\t\tif ( ( object.castShadow || ( object.receiveShadow && type === VSMShadowMap ) ) && ( ! object.frustumCulled || _frustum.intersectsObject( object ) ) ) {\n\n\t\t\t\tobject.modelViewMatrix.multiplyMatrices( shadowCamera.matrixWorldInverse, object.matrixWorld );\n\n\t\t\t\tconst geometry = _objects.update( object );\n\t\t\t\tconst material = object.material;\n\n\t\t\t\tif ( Array.isArray( material ) ) {\n\n\t\t\t\t\tconst groups = geometry.groups;\n\n\t\t\t\t\tfor ( let k = 0, kl = groups.length; k < kl; k ++ ) {\n\n\t\t\t\t\t\tconst group = groups[ k ];\n\t\t\t\t\t\tconst groupMaterial = material[ group.materialIndex ];\n\n\t\t\t\t\t\tif ( groupMaterial && groupMaterial.visible ) {\n\n\t\t\t\t\t\t\tconst depthMaterial = getDepthMaterial( object, geometry, groupMaterial, light, shadowCamera.near, shadowCamera.far, type );\n\n\t\t\t\t\t\t\t_renderer.renderBufferDirect( shadowCamera, null, geometry, depthMaterial, object, group );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t} else if ( material.visible ) {\n\n\t\t\t\t\tconst depthMaterial = getDepthMaterial( object, geometry, material, light, shadowCamera.near, shadowCamera.far, type );\n\n\t\t\t\t\t_renderer.renderBufferDirect( shadowCamera, null, geometry, depthMaterial, object, null );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tconst children = object.children;\n\n\t\tfor ( let i = 0, l = children.length; i < l; i ++ ) {\n\n\t\t\trenderObject( children[ i ], camera, shadowCamera, light, type );\n\n\t\t}\n\n\t}\n\n}\n\n\nexport { WebGLShadowMap };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { NotEqualDepth, GreaterDepth, GreaterEqualDepth, EqualDepth, LessEqualDepth, LessDepth, AlwaysDepth, NeverDepth, CullFaceFront, CullFaceBack, CullFaceNone, DoubleSide, BackSide, CustomBlending, MultiplyBlending, SubtractiveBlending, AdditiveBlending, NoBlending, NormalBlending, AddEquation, SubtractEquation, ReverseSubtractEquation, MinEquation, MaxEquation, ZeroFactor, OneFactor, SrcColorFactor, SrcAlphaFactor, SrcAlphaSaturateFactor, DstColorFactor, DstAlphaFactor, OneMinusSrcColorFactor, OneMinusSrcAlphaFactor, OneMinusDstColorFactor, OneMinusDstAlphaFactor } from '../../constants.js';\nimport { Vector4 } from '../../math/Vector4.js';\n\nfunction WebGLState( gl, extensions, capabilities ) {\n\n\tconst isWebGL2 = capabilities.isWebGL2;\n\n\tfunction ColorBuffer() {\n\n\t\tlet locked = false;\n\n\t\tconst color = new Vector4();\n\t\tlet currentColorMask = null;\n\t\tconst currentColorClear = new Vector4( 0, 0, 0, 0 );\n\n\t\treturn {\n\n\t\t\tsetMask: function ( colorMask ) {\n\n\t\t\t\tif ( currentColorMask !== colorMask && ! locked ) {\n\n\t\t\t\t\tgl.colorMask( colorMask, colorMask, colorMask, colorMask );\n\t\t\t\t\tcurrentColorMask = colorMask;\n\n\t\t\t\t}\n\n\t\t\t},\n\n\t\t\tsetLocked: function ( lock ) {\n\n\t\t\t\tlocked = lock;\n\n\t\t\t},\n\n\t\t\tsetClear: function ( r, g, b, a, premultipliedAlpha ) {\n\n\t\t\t\tif ( premultipliedAlpha === true ) {\n\n\t\t\t\t\tr *= a; g *= a; b *= a;\n\n\t\t\t\t}\n\n\t\t\t\tcolor.set( r, g, b, a );\n\n\t\t\t\tif ( currentColorClear.equals( color ) === false ) {\n\n\t\t\t\t\tgl.clearColor( r, g, b, a );\n\t\t\t\t\tcurrentColorClear.copy( color );\n\n\t\t\t\t}\n\n\t\t\t},\n\n\t\t\treset: function () {\n\n\t\t\t\tlocked = false;\n\n\t\t\t\tcurrentColorMask = null;\n\t\t\t\tcurrentColorClear.set( - 1, 0, 0, 0 ); // set to invalid state\n\n\t\t\t}\n\n\t\t};\n\n\t}\n\n\tfunction DepthBuffer() {\n\n\t\tlet locked = false;\n\n\t\tlet currentDepthMask = null;\n\t\tlet currentDepthFunc = null;\n\t\tlet currentDepthClear = null;\n\n\t\treturn {\n\n\t\t\tsetTest: function ( depthTest ) {\n\n\t\t\t\tif ( depthTest ) {\n\n\t\t\t\t\tenable( gl.DEPTH_TEST );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tdisable( gl.DEPTH_TEST );\n\n\t\t\t\t}\n\n\t\t\t},\n\n\t\t\tsetMask: function ( depthMask ) {\n\n\t\t\t\tif ( currentDepthMask !== depthMask && ! locked ) {\n\n\t\t\t\t\tgl.depthMask( depthMask );\n\t\t\t\t\tcurrentDepthMask = depthMask;\n\n\t\t\t\t}\n\n\t\t\t},\n\n\t\t\tsetFunc: function ( depthFunc ) {\n\n\t\t\t\tif ( currentDepthFunc !== depthFunc ) {\n\n\t\t\t\t\tif ( depthFunc ) {\n\n\t\t\t\t\t\tswitch ( depthFunc ) {\n\n\t\t\t\t\t\t\tcase NeverDepth:\n\n\t\t\t\t\t\t\t\tgl.depthFunc( gl.NEVER );\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase AlwaysDepth:\n\n\t\t\t\t\t\t\t\tgl.depthFunc( gl.ALWAYS );\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase LessDepth:\n\n\t\t\t\t\t\t\t\tgl.depthFunc( gl.LESS );\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase LessEqualDepth:\n\n\t\t\t\t\t\t\t\tgl.depthFunc( gl.LEQUAL );\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase EqualDepth:\n\n\t\t\t\t\t\t\t\tgl.depthFunc( gl.EQUAL );\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase GreaterEqualDepth:\n\n\t\t\t\t\t\t\t\tgl.depthFunc( gl.GEQUAL );\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase GreaterDepth:\n\n\t\t\t\t\t\t\t\tgl.depthFunc( gl.GREATER );\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase NotEqualDepth:\n\n\t\t\t\t\t\t\t\tgl.depthFunc( gl.NOTEQUAL );\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tdefault:\n\n\t\t\t\t\t\t\t\tgl.depthFunc( gl.LEQUAL );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tgl.depthFunc( gl.LEQUAL );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tcurrentDepthFunc = depthFunc;\n\n\t\t\t\t}\n\n\t\t\t},\n\n\t\t\tsetLocked: function ( lock ) {\n\n\t\t\t\tlocked = lock;\n\n\t\t\t},\n\n\t\t\tsetClear: function ( depth ) {\n\n\t\t\t\tif ( currentDepthClear !== depth ) {\n\n\t\t\t\t\tgl.clearDepth( depth );\n\t\t\t\t\tcurrentDepthClear = depth;\n\n\t\t\t\t}\n\n\t\t\t},\n\n\t\t\treset: function () {\n\n\t\t\t\tlocked = false;\n\n\t\t\t\tcurrentDepthMask = null;\n\t\t\t\tcurrentDepthFunc = null;\n\t\t\t\tcurrentDepthClear = null;\n\n\t\t\t}\n\n\t\t};\n\n\t}\n\n\tfunction StencilBuffer() {\n\n\t\tlet locked = false;\n\n\t\tlet currentStencilMask = null;\n\t\tlet currentStencilFunc = null;\n\t\tlet currentStencilRef = null;\n\t\tlet currentStencilFuncMask = null;\n\t\tlet currentStencilFail = null;\n\t\tlet currentStencilZFail = null;\n\t\tlet currentStencilZPass = null;\n\t\tlet currentStencilClear = null;\n\n\t\treturn {\n\n\t\t\tsetTest: function ( stencilTest ) {\n\n\t\t\t\tif ( ! locked ) {\n\n\t\t\t\t\tif ( stencilTest ) {\n\n\t\t\t\t\t\tenable( gl.STENCIL_TEST );\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tdisable( gl.STENCIL_TEST );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t},\n\n\t\t\tsetMask: function ( stencilMask ) {\n\n\t\t\t\tif ( currentStencilMask !== stencilMask && ! locked ) {\n\n\t\t\t\t\tgl.stencilMask( stencilMask );\n\t\t\t\t\tcurrentStencilMask = stencilMask;\n\n\t\t\t\t}\n\n\t\t\t},\n\n\t\t\tsetFunc: function ( stencilFunc, stencilRef, stencilMask ) {\n\n\t\t\t\tif ( currentStencilFunc !== stencilFunc ||\n\t\t\t\t currentStencilRef \t!== stencilRef \t||\n\t\t\t\t currentStencilFuncMask !== stencilMask ) {\n\n\t\t\t\t\tgl.stencilFunc( stencilFunc, stencilRef, stencilMask );\n\n\t\t\t\t\tcurrentStencilFunc = stencilFunc;\n\t\t\t\t\tcurrentStencilRef = stencilRef;\n\t\t\t\t\tcurrentStencilFuncMask = stencilMask;\n\n\t\t\t\t}\n\n\t\t\t},\n\n\t\t\tsetOp: function ( stencilFail, stencilZFail, stencilZPass ) {\n\n\t\t\t\tif ( currentStencilFail\t !== stencilFail \t||\n\t\t\t\t currentStencilZFail !== stencilZFail ||\n\t\t\t\t currentStencilZPass !== stencilZPass ) {\n\n\t\t\t\t\tgl.stencilOp( stencilFail, stencilZFail, stencilZPass );\n\n\t\t\t\t\tcurrentStencilFail = stencilFail;\n\t\t\t\t\tcurrentStencilZFail = stencilZFail;\n\t\t\t\t\tcurrentStencilZPass = stencilZPass;\n\n\t\t\t\t}\n\n\t\t\t},\n\n\t\t\tsetLocked: function ( lock ) {\n\n\t\t\t\tlocked = lock;\n\n\t\t\t},\n\n\t\t\tsetClear: function ( stencil ) {\n\n\t\t\t\tif ( currentStencilClear !== stencil ) {\n\n\t\t\t\t\tgl.clearStencil( stencil );\n\t\t\t\t\tcurrentStencilClear = stencil;\n\n\t\t\t\t}\n\n\t\t\t},\n\n\t\t\treset: function () {\n\n\t\t\t\tlocked = false;\n\n\t\t\t\tcurrentStencilMask = null;\n\t\t\t\tcurrentStencilFunc = null;\n\t\t\t\tcurrentStencilRef = null;\n\t\t\t\tcurrentStencilFuncMask = null;\n\t\t\t\tcurrentStencilFail = null;\n\t\t\t\tcurrentStencilZFail = null;\n\t\t\t\tcurrentStencilZPass = null;\n\t\t\t\tcurrentStencilClear = null;\n\n\t\t\t}\n\n\t\t};\n\n\t}\n\n\t//\n\n\tconst colorBuffer = new ColorBuffer();\n\tconst depthBuffer = new DepthBuffer();\n\tconst stencilBuffer = new StencilBuffer();\n\n\tlet enabledCapabilities = {};\n\n\tlet currentProgram = null;\n\n\tlet currentBlendingEnabled = null;\n\tlet currentBlending = null;\n\tlet currentBlendEquation = null;\n\tlet currentBlendSrc = null;\n\tlet currentBlendDst = null;\n\tlet currentBlendEquationAlpha = null;\n\tlet currentBlendSrcAlpha = null;\n\tlet currentBlendDstAlpha = null;\n\tlet currentPremultipledAlpha = false;\n\n\tlet currentFlipSided = null;\n\tlet currentCullFace = null;\n\n\tlet currentLineWidth = null;\n\n\tlet currentPolygonOffsetFactor = null;\n\tlet currentPolygonOffsetUnits = null;\n\n\tconst maxTextures = gl.getParameter( gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS );\n\n\tlet lineWidthAvailable = false;\n\tlet version = 0;\n\tconst glVersion = gl.getParameter( gl.VERSION );\n\n\tif ( glVersion.indexOf( 'WebGL' ) !== - 1 ) {\n\n\t\tversion = parseFloat( /^WebGL\\ ([0-9])/.exec( glVersion )[ 1 ] );\n\t\tlineWidthAvailable = ( version >= 1.0 );\n\n\t} else if ( glVersion.indexOf( 'OpenGL ES' ) !== - 1 ) {\n\n\t\tversion = parseFloat( /^OpenGL\\ ES\\ ([0-9])/.exec( glVersion )[ 1 ] );\n\t\tlineWidthAvailable = ( version >= 2.0 );\n\n\t}\n\n\tlet currentTextureSlot = null;\n\tlet currentBoundTextures = {};\n\n\tconst currentScissor = new Vector4();\n\tconst currentViewport = new Vector4();\n\n\tfunction createTexture( type, target, count ) {\n\n\t\tconst data = new Uint8Array( 4 ); // 4 is required to match default unpack alignment of 4.\n\t\tconst texture = gl.createTexture();\n\n\t\tgl.bindTexture( type, texture );\n\t\tgl.texParameteri( type, gl.TEXTURE_MIN_FILTER, gl.NEAREST );\n\t\tgl.texParameteri( type, gl.TEXTURE_MAG_FILTER, gl.NEAREST );\n\n\t\tfor ( let i = 0; i < count; i ++ ) {\n\n\t\t\tgl.texImage2D( target + i, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, data );\n\n\t\t}\n\n\t\treturn texture;\n\n\t}\n\n\tconst emptyTextures = {};\n\temptyTextures[ gl.TEXTURE_2D ] = createTexture( gl.TEXTURE_2D, gl.TEXTURE_2D, 1 );\n\temptyTextures[ gl.TEXTURE_CUBE_MAP ] = createTexture( gl.TEXTURE_CUBE_MAP, gl.TEXTURE_CUBE_MAP_POSITIVE_X, 6 );\n\n\t// init\n\n\tcolorBuffer.setClear( 0, 0, 0, 1 );\n\tdepthBuffer.setClear( 1 );\n\tstencilBuffer.setClear( 0 );\n\n\tenable( gl.DEPTH_TEST );\n\tdepthBuffer.setFunc( LessEqualDepth );\n\n\tsetFlipSided( false );\n\tsetCullFace( CullFaceBack );\n\tenable( gl.CULL_FACE );\n\n\tsetBlending( NoBlending );\n\n\t//\n\n\tfunction enable( id ) {\n\n\t\tif ( enabledCapabilities[ id ] !== true ) {\n\n\t\t\tgl.enable( id );\n\t\t\tenabledCapabilities[ id ] = true;\n\n\t\t}\n\n\t}\n\n\tfunction disable( id ) {\n\n\t\tif ( enabledCapabilities[ id ] !== false ) {\n\n\t\t\tgl.disable( id );\n\t\t\tenabledCapabilities[ id ] = false;\n\n\t\t}\n\n\t}\n\n\tfunction useProgram( program ) {\n\n\t\tif ( currentProgram !== program ) {\n\n\t\t\tgl.useProgram( program );\n\n\t\t\tcurrentProgram = program;\n\n\t\t\treturn true;\n\n\t\t}\n\n\t\treturn false;\n\n\t}\n\n\tconst equationToGL = {\n\t\t[ AddEquation ]: gl.FUNC_ADD,\n\t\t[ SubtractEquation ]: gl.FUNC_SUBTRACT,\n\t\t[ ReverseSubtractEquation ]: gl.FUNC_REVERSE_SUBTRACT\n\t};\n\n\tif ( isWebGL2 ) {\n\n\t\tequationToGL[ MinEquation ] = gl.MIN;\n\t\tequationToGL[ MaxEquation ] = gl.MAX;\n\n\t} else {\n\n\t\tconst extension = extensions.get( 'EXT_blend_minmax' );\n\n\t\tif ( extension !== null ) {\n\n\t\t\tequationToGL[ MinEquation ] = extension.MIN_EXT;\n\t\t\tequationToGL[ MaxEquation ] = extension.MAX_EXT;\n\n\t\t}\n\n\t}\n\n\tconst factorToGL = {\n\t\t[ ZeroFactor ]: gl.ZERO,\n\t\t[ OneFactor ]: gl.ONE,\n\t\t[ SrcColorFactor ]: gl.SRC_COLOR,\n\t\t[ SrcAlphaFactor ]: gl.SRC_ALPHA,\n\t\t[ SrcAlphaSaturateFactor ]: gl.SRC_ALPHA_SATURATE,\n\t\t[ DstColorFactor ]: gl.DST_COLOR,\n\t\t[ DstAlphaFactor ]: gl.DST_ALPHA,\n\t\t[ OneMinusSrcColorFactor ]: gl.ONE_MINUS_SRC_COLOR,\n\t\t[ OneMinusSrcAlphaFactor ]: gl.ONE_MINUS_SRC_ALPHA,\n\t\t[ OneMinusDstColorFactor ]: gl.ONE_MINUS_DST_COLOR,\n\t\t[ OneMinusDstAlphaFactor ]: gl.ONE_MINUS_DST_ALPHA\n\t};\n\n\tfunction setBlending( blending, blendEquation, blendSrc, blendDst, blendEquationAlpha, blendSrcAlpha, blendDstAlpha, premultipliedAlpha ) {\n\n\t\tif ( blending === NoBlending ) {\n\n\t\t\tif ( currentBlendingEnabled ) {\n\n\t\t\t\tdisable( gl.BLEND );\n\t\t\t\tcurrentBlendingEnabled = false;\n\n\t\t\t}\n\n\t\t\treturn;\n\n\t\t}\n\n\t\tif ( ! currentBlendingEnabled ) {\n\n\t\t\tenable( gl.BLEND );\n\t\t\tcurrentBlendingEnabled = true;\n\n\t\t}\n\n\t\tif ( blending !== CustomBlending ) {\n\n\t\t\tif ( blending !== currentBlending || premultipliedAlpha !== currentPremultipledAlpha ) {\n\n\t\t\t\tif ( currentBlendEquation !== AddEquation || currentBlendEquationAlpha !== AddEquation ) {\n\n\t\t\t\t\tgl.blendEquation( gl.FUNC_ADD );\n\n\t\t\t\t\tcurrentBlendEquation = AddEquation;\n\t\t\t\t\tcurrentBlendEquationAlpha = AddEquation;\n\n\t\t\t\t}\n\n\t\t\t\tif ( premultipliedAlpha ) {\n\n\t\t\t\t\tswitch ( blending ) {\n\n\t\t\t\t\t\tcase NormalBlending:\n\t\t\t\t\t\t\tgl.blendFuncSeparate( gl.ONE, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA );\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase AdditiveBlending:\n\t\t\t\t\t\t\tgl.blendFunc( gl.ONE, gl.ONE );\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase SubtractiveBlending:\n\t\t\t\t\t\t\tgl.blendFuncSeparate( gl.ZERO, gl.ZERO, gl.ONE_MINUS_SRC_COLOR, gl.ONE_MINUS_SRC_ALPHA );\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase MultiplyBlending:\n\t\t\t\t\t\t\tgl.blendFuncSeparate( gl.ZERO, gl.SRC_COLOR, gl.ZERO, gl.SRC_ALPHA );\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tconsole.error( 'THREE.WebGLState: Invalid blending: ', blending );\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\n\t\t\t\t\tswitch ( blending ) {\n\n\t\t\t\t\t\tcase NormalBlending:\n\t\t\t\t\t\t\tgl.blendFuncSeparate( gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA );\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase AdditiveBlending:\n\t\t\t\t\t\t\tgl.blendFunc( gl.SRC_ALPHA, gl.ONE );\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase SubtractiveBlending:\n\t\t\t\t\t\t\tgl.blendFunc( gl.ZERO, gl.ONE_MINUS_SRC_COLOR );\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase MultiplyBlending:\n\t\t\t\t\t\t\tgl.blendFunc( gl.ZERO, gl.SRC_COLOR );\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tconsole.error( 'THREE.WebGLState: Invalid blending: ', blending );\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tcurrentBlendSrc = null;\n\t\t\t\tcurrentBlendDst = null;\n\t\t\t\tcurrentBlendSrcAlpha = null;\n\t\t\t\tcurrentBlendDstAlpha = null;\n\n\t\t\t\tcurrentBlending = blending;\n\t\t\t\tcurrentPremultipledAlpha = premultipliedAlpha;\n\n\t\t\t}\n\n\t\t\treturn;\n\n\t\t}\n\n\t\t// custom blending\n\n\t\tblendEquationAlpha = blendEquationAlpha || blendEquation;\n\t\tblendSrcAlpha = blendSrcAlpha || blendSrc;\n\t\tblendDstAlpha = blendDstAlpha || blendDst;\n\n\t\tif ( blendEquation !== currentBlendEquation || blendEquationAlpha !== currentBlendEquationAlpha ) {\n\n\t\t\tgl.blendEquationSeparate( equationToGL[ blendEquation ], equationToGL[ blendEquationAlpha ] );\n\n\t\t\tcurrentBlendEquation = blendEquation;\n\t\t\tcurrentBlendEquationAlpha = blendEquationAlpha;\n\n\t\t}\n\n\t\tif ( blendSrc !== currentBlendSrc || blendDst !== currentBlendDst || blendSrcAlpha !== currentBlendSrcAlpha || blendDstAlpha !== currentBlendDstAlpha ) {\n\n\t\t\tgl.blendFuncSeparate( factorToGL[ blendSrc ], factorToGL[ blendDst ], factorToGL[ blendSrcAlpha ], factorToGL[ blendDstAlpha ] );\n\n\t\t\tcurrentBlendSrc = blendSrc;\n\t\t\tcurrentBlendDst = blendDst;\n\t\t\tcurrentBlendSrcAlpha = blendSrcAlpha;\n\t\t\tcurrentBlendDstAlpha = blendDstAlpha;\n\n\t\t}\n\n\t\tcurrentBlending = blending;\n\t\tcurrentPremultipledAlpha = null;\n\n\t}\n\n\tfunction setMaterial( material, frontFaceCW ) {\n\n\t\tmaterial.side === DoubleSide\n\t\t\t? disable( gl.CULL_FACE )\n\t\t\t: enable( gl.CULL_FACE );\n\n\t\tlet flipSided = ( material.side === BackSide );\n\t\tif ( frontFaceCW ) flipSided = ! flipSided;\n\n\t\tsetFlipSided( flipSided );\n\n\t\t( material.blending === NormalBlending && material.transparent === false )\n\t\t\t? setBlending( NoBlending )\n\t\t\t: setBlending( material.blending, material.blendEquation, material.blendSrc, material.blendDst, material.blendEquationAlpha, material.blendSrcAlpha, material.blendDstAlpha, material.premultipliedAlpha );\n\n\t\tdepthBuffer.setFunc( material.depthFunc );\n\t\tdepthBuffer.setTest( material.depthTest );\n\t\tdepthBuffer.setMask( material.depthWrite );\n\t\tcolorBuffer.setMask( material.colorWrite );\n\n\t\tconst stencilWrite = material.stencilWrite;\n\t\tstencilBuffer.setTest( stencilWrite );\n\t\tif ( stencilWrite ) {\n\n\t\t\tstencilBuffer.setMask( material.stencilWriteMask );\n\t\t\tstencilBuffer.setFunc( material.stencilFunc, material.stencilRef, material.stencilFuncMask );\n\t\t\tstencilBuffer.setOp( material.stencilFail, material.stencilZFail, material.stencilZPass );\n\n\t\t}\n\n\t\tsetPolygonOffset( material.polygonOffset, material.polygonOffsetFactor, material.polygonOffsetUnits );\n\n\t}\n\n\t//\n\n\tfunction setFlipSided( flipSided ) {\n\n\t\tif ( currentFlipSided !== flipSided ) {\n\n\t\t\tif ( flipSided ) {\n\n\t\t\t\tgl.frontFace( gl.CW );\n\n\t\t\t} else {\n\n\t\t\t\tgl.frontFace( gl.CCW );\n\n\t\t\t}\n\n\t\t\tcurrentFlipSided = flipSided;\n\n\t\t}\n\n\t}\n\n\tfunction setCullFace( cullFace ) {\n\n\t\tif ( cullFace !== CullFaceNone ) {\n\n\t\t\tenable( gl.CULL_FACE );\n\n\t\t\tif ( cullFace !== currentCullFace ) {\n\n\t\t\t\tif ( cullFace === CullFaceBack ) {\n\n\t\t\t\t\tgl.cullFace( gl.BACK );\n\n\t\t\t\t} else if ( cullFace === CullFaceFront ) {\n\n\t\t\t\t\tgl.cullFace( gl.FRONT );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tgl.cullFace( gl.FRONT_AND_BACK );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tdisable( gl.CULL_FACE );\n\n\t\t}\n\n\t\tcurrentCullFace = cullFace;\n\n\t}\n\n\tfunction setLineWidth( width ) {\n\n\t\tif ( width !== currentLineWidth ) {\n\n\t\t\tif ( lineWidthAvailable ) gl.lineWidth( width );\n\n\t\t\tcurrentLineWidth = width;\n\n\t\t}\n\n\t}\n\n\tfunction setPolygonOffset( polygonOffset, factor, units ) {\n\n\t\tif ( polygonOffset ) {\n\n\t\t\tenable( gl.POLYGON_OFFSET_FILL );\n\n\t\t\tif ( currentPolygonOffsetFactor !== factor || currentPolygonOffsetUnits !== units ) {\n\n\t\t\t\tgl.polygonOffset( factor, units );\n\n\t\t\t\tcurrentPolygonOffsetFactor = factor;\n\t\t\t\tcurrentPolygonOffsetUnits = units;\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tdisable( gl.POLYGON_OFFSET_FILL );\n\n\t\t}\n\n\t}\n\n\tfunction setScissorTest( scissorTest ) {\n\n\t\tif ( scissorTest ) {\n\n\t\t\tenable( gl.SCISSOR_TEST );\n\n\t\t} else {\n\n\t\t\tdisable( gl.SCISSOR_TEST );\n\n\t\t}\n\n\t}\n\n\t// texture\n\n\tfunction activeTexture( webglSlot ) {\n\n\t\tif ( webglSlot === undefined ) webglSlot = gl.TEXTURE0 + maxTextures - 1;\n\n\t\tif ( currentTextureSlot !== webglSlot ) {\n\n\t\t\tgl.activeTexture( webglSlot );\n\t\t\tcurrentTextureSlot = webglSlot;\n\n\t\t}\n\n\t}\n\n\tfunction bindTexture( webglType, webglTexture ) {\n\n\t\tif ( currentTextureSlot === null ) {\n\n\t\t\tactiveTexture();\n\n\t\t}\n\n\t\tlet boundTexture = currentBoundTextures[ currentTextureSlot ];\n\n\t\tif ( boundTexture === undefined ) {\n\n\t\t\tboundTexture = { type: undefined, texture: undefined };\n\t\t\tcurrentBoundTextures[ currentTextureSlot ] = boundTexture;\n\n\t\t}\n\n\t\tif ( boundTexture.type !== webglType || boundTexture.texture !== webglTexture ) {\n\n\t\t\tgl.bindTexture( webglType, webglTexture || emptyTextures[ webglType ] );\n\n\t\t\tboundTexture.type = webglType;\n\t\t\tboundTexture.texture = webglTexture;\n\n\t\t}\n\n\t}\n\n\tfunction unbindTexture() {\n\n\t\tconst boundTexture = currentBoundTextures[ currentTextureSlot ];\n\n\t\tif ( boundTexture !== undefined && boundTexture.type !== undefined ) {\n\n\t\t\tgl.bindTexture( boundTexture.type, null );\n\n\t\t\tboundTexture.type = undefined;\n\t\t\tboundTexture.texture = undefined;\n\n\t\t}\n\n\t}\n\n\tfunction compressedTexImage2D() {\n\n\t\ttry {\n\n\t\t\tgl.compressedTexImage2D.apply( gl, arguments );\n\n\t\t} catch ( error ) {\n\n\t\t\tconsole.error( 'THREE.WebGLState:', error );\n\n\t\t}\n\n\t}\n\n\tfunction texImage2D() {\n\n\t\ttry {\n\n\t\t\tgl.texImage2D.apply( gl, arguments );\n\n\t\t} catch ( error ) {\n\n\t\t\tconsole.error( 'THREE.WebGLState:', error );\n\n\t\t}\n\n\t}\n\n\tfunction texImage3D() {\n\n\t\ttry {\n\n\t\t\tgl.texImage3D.apply( gl, arguments );\n\n\t\t} catch ( error ) {\n\n\t\t\tconsole.error( 'THREE.WebGLState:', error );\n\n\t\t}\n\n\t}\n\n\t//\n\n\tfunction scissor( scissor ) {\n\n\t\tif ( currentScissor.equals( scissor ) === false ) {\n\n\t\t\tgl.scissor( scissor.x, scissor.y, scissor.z, scissor.w );\n\t\t\tcurrentScissor.copy( scissor );\n\n\t\t}\n\n\t}\n\n\tfunction viewport( viewport ) {\n\n\t\tif ( currentViewport.equals( viewport ) === false ) {\n\n\t\t\tgl.viewport( viewport.x, viewport.y, viewport.z, viewport.w );\n\t\t\tcurrentViewport.copy( viewport );\n\n\t\t}\n\n\t}\n\n\t//\n\n\tfunction reset() {\n\n\t\tenabledCapabilities = {};\n\n\t\tcurrentTextureSlot = null;\n\t\tcurrentBoundTextures = {};\n\n\t\tcurrentProgram = null;\n\n\t\tcurrentBlending = null;\n\n\t\tcurrentFlipSided = null;\n\t\tcurrentCullFace = null;\n\n\t\tcolorBuffer.reset();\n\t\tdepthBuffer.reset();\n\t\tstencilBuffer.reset();\n\n\t}\n\n\treturn {\n\n\t\tbuffers: {\n\t\t\tcolor: colorBuffer,\n\t\t\tdepth: depthBuffer,\n\t\t\tstencil: stencilBuffer\n\t\t},\n\n\t\tenable: enable,\n\t\tdisable: disable,\n\n\t\tuseProgram: useProgram,\n\n\t\tsetBlending: setBlending,\n\t\tsetMaterial: setMaterial,\n\n\t\tsetFlipSided: setFlipSided,\n\t\tsetCullFace: setCullFace,\n\n\t\tsetLineWidth: setLineWidth,\n\t\tsetPolygonOffset: setPolygonOffset,\n\n\t\tsetScissorTest: setScissorTest,\n\n\t\tactiveTexture: activeTexture,\n\t\tbindTexture: bindTexture,\n\t\tunbindTexture: unbindTexture,\n\t\tcompressedTexImage2D: compressedTexImage2D,\n\t\ttexImage2D: texImage2D,\n\t\ttexImage3D: texImage3D,\n\n\t\tscissor: scissor,\n\t\tviewport: viewport,\n\n\t\treset: reset\n\n\t};\n\n}\n\nexport { WebGLState };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { LinearFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, NearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, RGBFormat, RGBAFormat, DepthFormat, DepthStencilFormat, UnsignedShortType, UnsignedIntType, UnsignedInt248Type, FloatType, HalfFloatType, MirroredRepeatWrapping, ClampToEdgeWrapping, RepeatWrapping } from '../../constants.js';\nimport { MathUtils } from '../../math/MathUtils.js';\n\nfunction WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info ) {\n\n\tconst isWebGL2 = capabilities.isWebGL2;\n\tconst maxTextures = capabilities.maxTextures;\n\tconst maxCubemapSize = capabilities.maxCubemapSize;\n\tconst maxTextureSize = capabilities.maxTextureSize;\n\tconst maxSamples = capabilities.maxSamples;\n\n\tconst _videoTextures = new WeakMap();\n\tlet _canvas;\n\n\t// cordova iOS (as of 5.0) still uses UIWebView, which provides OffscreenCanvas,\n\t// also OffscreenCanvas.getContext(\"webgl\"), but not OffscreenCanvas.getContext(\"2d\")!\n\t// Some implementations may only implement OffscreenCanvas partially (e.g. lacking 2d).\n\n\tlet useOffscreenCanvas = false;\n\n\ttry {\n\n\t\tuseOffscreenCanvas = typeof OffscreenCanvas !== 'undefined'\n\t\t\t&& ( new OffscreenCanvas( 1, 1 ).getContext( \"2d\" ) ) !== null;\n\n\t} catch ( err ) {\n\n\t\t// Ignore any errors\n\n\t}\n\n\tfunction createCanvas( width, height ) {\n\n\t\t// Use OffscreenCanvas when available. Specially needed in web workers\n\n\t\treturn useOffscreenCanvas ?\n\t\t\tnew OffscreenCanvas( width, height ) :\n\t\t\tdocument.createElementNS( 'http://www.w3.org/1999/xhtml', 'canvas' );\n\n\t}\n\n\tfunction resizeImage( image, needsPowerOfTwo, needsNewCanvas, maxSize ) {\n\n\t\tlet scale = 1;\n\n\t\t// handle case if texture exceeds max size\n\n\t\tif ( image.width > maxSize || image.height > maxSize ) {\n\n\t\t\tscale = maxSize / Math.max( image.width, image.height );\n\n\t\t}\n\n\t\t// only perform resize if necessary\n\n\t\tif ( scale < 1 || needsPowerOfTwo === true ) {\n\n\t\t\t// only perform resize for certain image types\n\n\t\t\tif ( ( typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement ) ||\n\t\t\t\t( typeof HTMLCanvasElement !== 'undefined' && image instanceof HTMLCanvasElement ) ||\n\t\t\t\t( typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap ) ) {\n\n\t\t\t\tconst floor = needsPowerOfTwo ? MathUtils.floorPowerOfTwo : Math.floor;\n\n\t\t\t\tconst width = floor( scale * image.width );\n\t\t\t\tconst height = floor( scale * image.height );\n\n\t\t\t\tif ( _canvas === undefined ) _canvas = createCanvas( width, height );\n\n\t\t\t\t// cube textures can't reuse the same canvas\n\n\t\t\t\tconst canvas = needsNewCanvas ? createCanvas( width, height ) : _canvas;\n\n\t\t\t\tcanvas.width = width;\n\t\t\t\tcanvas.height = height;\n\n\t\t\t\tconst context = canvas.getContext( '2d' );\n\t\t\t\tcontext.drawImage( image, 0, 0, width, height );\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Texture has been resized from (' + image.width + 'x' + image.height + ') to (' + width + 'x' + height + ').' );\n\n\t\t\t\treturn canvas;\n\n\t\t\t} else {\n\n\t\t\t\tif ( 'data' in image ) {\n\n\t\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Image in DataTexture is too big (' + image.width + 'x' + image.height + ').' );\n\n\t\t\t\t}\n\n\t\t\t\treturn image;\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn image;\n\n\t}\n\n\tfunction isPowerOfTwo( image ) {\n\n\t\treturn MathUtils.isPowerOfTwo( image.width ) && MathUtils.isPowerOfTwo( image.height );\n\n\t}\n\n\tfunction textureNeedsPowerOfTwo( texture ) {\n\n\t\tif ( isWebGL2 ) return false;\n\n\t\treturn ( texture.wrapS !== ClampToEdgeWrapping || texture.wrapT !== ClampToEdgeWrapping ) ||\n\t\t\t( texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter );\n\n\t}\n\n\tfunction textureNeedsGenerateMipmaps( texture, supportsMips ) {\n\n\t\treturn texture.generateMipmaps && supportsMips &&\n\t\t\ttexture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter;\n\n\t}\n\n\tfunction generateMipmap( target, texture, width, height ) {\n\n\t\t_gl.generateMipmap( target );\n\n\t\tconst textureProperties = properties.get( texture );\n\n\t\t// Note: Math.log( x ) * Math.LOG2E used instead of Math.log2( x ) which is not supported by IE11\n\t\ttextureProperties.__maxMipLevel = Math.log( Math.max( width, height ) ) * Math.LOG2E;\n\n\t}\n\n\tfunction getInternalFormat( internalFormatName, glFormat, glType ) {\n\n\t\tif ( isWebGL2 === false ) return glFormat;\n\n\t\tif ( internalFormatName !== null ) {\n\n\t\t\tif ( _gl[ internalFormatName ] !== undefined ) return _gl[ internalFormatName ];\n\n\t\t\tconsole.warn( 'THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format \\'' + internalFormatName + '\\'' );\n\n\t\t}\n\n\t\tlet internalFormat = glFormat;\n\n\t\tif ( glFormat === _gl.RED ) {\n\n\t\t\tif ( glType === _gl.FLOAT ) internalFormat = _gl.R32F;\n\t\t\tif ( glType === _gl.HALF_FLOAT ) internalFormat = _gl.R16F;\n\t\t\tif ( glType === _gl.UNSIGNED_BYTE ) internalFormat = _gl.R8;\n\n\t\t}\n\n\t\tif ( glFormat === _gl.RGB ) {\n\n\t\t\tif ( glType === _gl.FLOAT ) internalFormat = _gl.RGB32F;\n\t\t\tif ( glType === _gl.HALF_FLOAT ) internalFormat = _gl.RGB16F;\n\t\t\tif ( glType === _gl.UNSIGNED_BYTE ) internalFormat = _gl.RGB8;\n\n\t\t}\n\n\t\tif ( glFormat === _gl.RGBA ) {\n\n\t\t\tif ( glType === _gl.FLOAT ) internalFormat = _gl.RGBA32F;\n\t\t\tif ( glType === _gl.HALF_FLOAT ) internalFormat = _gl.RGBA16F;\n\t\t\tif ( glType === _gl.UNSIGNED_BYTE ) internalFormat = _gl.RGBA8;\n\n\t\t}\n\n\t\tif ( internalFormat === _gl.R16F || internalFormat === _gl.R32F ||\n\t\t\tinternalFormat === _gl.RGBA16F || internalFormat === _gl.RGBA32F ) {\n\n\t\t\textensions.get( 'EXT_color_buffer_float' );\n\n\t\t}\n\n\t\treturn internalFormat;\n\n\t}\n\n\t// Fallback filters for non-power-of-2 textures\n\n\tfunction filterFallback( f ) {\n\n\t\tif ( f === NearestFilter || f === NearestMipmapNearestFilter || f === NearestMipmapLinearFilter ) {\n\n\t\t\treturn _gl.NEAREST;\n\n\t\t}\n\n\t\treturn _gl.LINEAR;\n\n\t}\n\n\t//\n\n\tfunction onTextureDispose( event ) {\n\n\t\tconst texture = event.target;\n\n\t\ttexture.removeEventListener( 'dispose', onTextureDispose );\n\n\t\tdeallocateTexture( texture );\n\n\t\tif ( texture.isVideoTexture ) {\n\n\t\t\t_videoTextures.delete( texture );\n\n\t\t}\n\n\t\tinfo.memory.textures --;\n\n\t}\n\n\tfunction onRenderTargetDispose( event ) {\n\n\t\tconst renderTarget = event.target;\n\n\t\trenderTarget.removeEventListener( 'dispose', onRenderTargetDispose );\n\n\t\tdeallocateRenderTarget( renderTarget );\n\n\t\tinfo.memory.textures --;\n\n\t}\n\n\t//\n\n\tfunction deallocateTexture( texture ) {\n\n\t\tconst textureProperties = properties.get( texture );\n\n\t\tif ( textureProperties.__webglInit === undefined ) return;\n\n\t\t_gl.deleteTexture( textureProperties.__webglTexture );\n\n\t\tproperties.remove( texture );\n\n\t}\n\n\tfunction deallocateRenderTarget( renderTarget ) {\n\n\t\tconst renderTargetProperties = properties.get( renderTarget );\n\t\tconst textureProperties = properties.get( renderTarget.texture );\n\n\t\tif ( ! renderTarget ) return;\n\n\t\tif ( textureProperties.__webglTexture !== undefined ) {\n\n\t\t\t_gl.deleteTexture( textureProperties.__webglTexture );\n\n\t\t}\n\n\t\tif ( renderTarget.depthTexture ) {\n\n\t\t\trenderTarget.depthTexture.dispose();\n\n\t\t}\n\n\t\tif ( renderTarget.isWebGLCubeRenderTarget ) {\n\n\t\t\tfor ( let i = 0; i < 6; i ++ ) {\n\n\t\t\t\t_gl.deleteFramebuffer( renderTargetProperties.__webglFramebuffer[ i ] );\n\t\t\t\tif ( renderTargetProperties.__webglDepthbuffer ) _gl.deleteRenderbuffer( renderTargetProperties.__webglDepthbuffer[ i ] );\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\t_gl.deleteFramebuffer( renderTargetProperties.__webglFramebuffer );\n\t\t\tif ( renderTargetProperties.__webglDepthbuffer ) _gl.deleteRenderbuffer( renderTargetProperties.__webglDepthbuffer );\n\t\t\tif ( renderTargetProperties.__webglMultisampledFramebuffer ) _gl.deleteFramebuffer( renderTargetProperties.__webglMultisampledFramebuffer );\n\t\t\tif ( renderTargetProperties.__webglColorRenderbuffer ) _gl.deleteRenderbuffer( renderTargetProperties.__webglColorRenderbuffer );\n\t\t\tif ( renderTargetProperties.__webglDepthRenderbuffer ) _gl.deleteRenderbuffer( renderTargetProperties.__webglDepthRenderbuffer );\n\n\t\t}\n\n\t\tproperties.remove( renderTarget.texture );\n\t\tproperties.remove( renderTarget );\n\n\t}\n\n\t//\n\n\tlet textureUnits = 0;\n\n\tfunction resetTextureUnits() {\n\n\t\ttextureUnits = 0;\n\n\t}\n\n\tfunction allocateTextureUnit() {\n\n\t\tconst textureUnit = textureUnits;\n\n\t\tif ( textureUnit >= maxTextures ) {\n\n\t\t\tconsole.warn( 'THREE.WebGLTextures: Trying to use ' + textureUnit + ' texture units while this GPU supports only ' + maxTextures );\n\n\t\t}\n\n\t\ttextureUnits += 1;\n\n\t\treturn textureUnit;\n\n\t}\n\n\t//\n\n\tfunction setTexture2D( texture, slot ) {\n\n\t\tconst textureProperties = properties.get( texture );\n\n\t\tif ( texture.isVideoTexture ) updateVideoTexture( texture );\n\n\t\tif ( texture.version > 0 && textureProperties.__version !== texture.version ) {\n\n\t\t\tconst image = texture.image;\n\n\t\t\tif ( image === undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Texture marked for update but image is undefined' );\n\n\t\t\t} else if ( image.complete === false ) {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Texture marked for update but image is incomplete' );\n\n\t\t\t} else {\n\n\t\t\t\tuploadTexture( textureProperties, texture, slot );\n\t\t\t\treturn;\n\n\t\t\t}\n\n\t\t}\n\n\t\tstate.activeTexture( _gl.TEXTURE0 + slot );\n\t\tstate.bindTexture( _gl.TEXTURE_2D, textureProperties.__webglTexture );\n\n\t}\n\n\tfunction setTexture2DArray( texture, slot ) {\n\n\t\tconst textureProperties = properties.get( texture );\n\n\t\tif ( texture.version > 0 && textureProperties.__version !== texture.version ) {\n\n\t\t\tuploadTexture( textureProperties, texture, slot );\n\t\t\treturn;\n\n\t\t}\n\n\t\tstate.activeTexture( _gl.TEXTURE0 + slot );\n\t\tstate.bindTexture( _gl.TEXTURE_2D_ARRAY, textureProperties.__webglTexture );\n\n\t}\n\n\tfunction setTexture3D( texture, slot ) {\n\n\t\tconst textureProperties = properties.get( texture );\n\n\t\tif ( texture.version > 0 && textureProperties.__version !== texture.version ) {\n\n\t\t\tuploadTexture( textureProperties, texture, slot );\n\t\t\treturn;\n\n\t\t}\n\n\t\tstate.activeTexture( _gl.TEXTURE0 + slot );\n\t\tstate.bindTexture( _gl.TEXTURE_3D, textureProperties.__webglTexture );\n\n\t}\n\n\tfunction setTextureCube( texture, slot ) {\n\n\t\tif ( texture.image.length !== 6 ) return;\n\n\t\tconst textureProperties = properties.get( texture );\n\n\t\tif ( texture.version > 0 && textureProperties.__version !== texture.version ) {\n\n\t\t\tinitTexture( textureProperties, texture );\n\n\t\t\tstate.activeTexture( _gl.TEXTURE0 + slot );\n\t\t\tstate.bindTexture( _gl.TEXTURE_CUBE_MAP, textureProperties.__webglTexture );\n\n\t\t\t_gl.pixelStorei( _gl.UNPACK_FLIP_Y_WEBGL, texture.flipY );\n\n\t\t\tconst isCompressed = ( texture && ( texture.isCompressedTexture || texture.image[ 0 ].isCompressedTexture ) );\n\t\t\tconst isDataTexture = ( texture.image[ 0 ] && texture.image[ 0 ].isDataTexture );\n\n\t\t\tconst cubeImage = [];\n\n\t\t\tfor ( let i = 0; i < 6; i ++ ) {\n\n\t\t\t\tif ( ! isCompressed && ! isDataTexture ) {\n\n\t\t\t\t\tcubeImage[ i ] = resizeImage( texture.image[ i ], false, true, maxCubemapSize );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tcubeImage[ i ] = isDataTexture ? texture.image[ i ].image : texture.image[ i ];\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tconst image = cubeImage[ 0 ],\n\t\t\t\tsupportsMips = isPowerOfTwo( image ) || isWebGL2,\n\t\t\t\tglFormat = utils.convert( texture.format ),\n\t\t\t\tglType = utils.convert( texture.type ),\n\t\t\t\tglInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType );\n\n\t\t\tsetTextureParameters( _gl.TEXTURE_CUBE_MAP, texture, supportsMips );\n\n\t\t\tlet mipmaps;\n\n\t\t\tif ( isCompressed ) {\n\n\t\t\t\tfor ( let i = 0; i < 6; i ++ ) {\n\n\t\t\t\t\tmipmaps = cubeImage[ i ].mipmaps;\n\n\t\t\t\t\tfor ( let j = 0; j < mipmaps.length; j ++ ) {\n\n\t\t\t\t\t\tconst mipmap = mipmaps[ j ];\n\n\t\t\t\t\t\tif ( texture.format !== RGBAFormat && texture.format !== RGBFormat ) {\n\n\t\t\t\t\t\t\tif ( glFormat !== null ) {\n\n\t\t\t\t\t\t\t\tstate.compressedTexImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data );\n\n\t\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()' );\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\tstate.texImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\ttextureProperties.__maxMipLevel = mipmaps.length - 1;\n\n\t\t\t} else {\n\n\t\t\t\tmipmaps = texture.mipmaps;\n\n\t\t\t\tfor ( let i = 0; i < 6; i ++ ) {\n\n\t\t\t\t\tif ( isDataTexture ) {\n\n\t\t\t\t\t\tstate.texImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, glInternalFormat, cubeImage[ i ].width, cubeImage[ i ].height, 0, glFormat, glType, cubeImage[ i ].data );\n\n\t\t\t\t\t\tfor ( let j = 0; j < mipmaps.length; j ++ ) {\n\n\t\t\t\t\t\t\tconst mipmap = mipmaps[ j ];\n\t\t\t\t\t\t\tconst mipmapImage = mipmap.image[ i ].image;\n\n\t\t\t\t\t\t\tstate.texImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j + 1, glInternalFormat, mipmapImage.width, mipmapImage.height, 0, glFormat, glType, mipmapImage.data );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tstate.texImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, glInternalFormat, glFormat, glType, cubeImage[ i ] );\n\n\t\t\t\t\t\tfor ( let j = 0; j < mipmaps.length; j ++ ) {\n\n\t\t\t\t\t\t\tconst mipmap = mipmaps[ j ];\n\n\t\t\t\t\t\t\tstate.texImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j + 1, glInternalFormat, glFormat, glType, mipmap.image[ i ] );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\ttextureProperties.__maxMipLevel = mipmaps.length;\n\n\t\t\t}\n\n\t\t\tif ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) {\n\n\t\t\t\t// We assume images for cube map have the same size.\n\t\t\t\tgenerateMipmap( _gl.TEXTURE_CUBE_MAP, texture, image.width, image.height );\n\n\t\t\t}\n\n\t\t\ttextureProperties.__version = texture.version;\n\n\t\t\tif ( texture.onUpdate ) texture.onUpdate( texture );\n\n\t\t} else {\n\n\t\t\tstate.activeTexture( _gl.TEXTURE0 + slot );\n\t\t\tstate.bindTexture( _gl.TEXTURE_CUBE_MAP, textureProperties.__webglTexture );\n\n\t\t}\n\n\t}\n\n\tfunction setTextureCubeDynamic( texture, slot ) {\n\n\t\tstate.activeTexture( _gl.TEXTURE0 + slot );\n\t\tstate.bindTexture( _gl.TEXTURE_CUBE_MAP, properties.get( texture ).__webglTexture );\n\n\t}\n\n\tconst wrappingToGL = {\n\t\t[ RepeatWrapping ]: _gl.REPEAT,\n\t\t[ ClampToEdgeWrapping ]: _gl.CLAMP_TO_EDGE,\n\t\t[ MirroredRepeatWrapping ]: _gl.MIRRORED_REPEAT\n\t};\n\n\tconst filterToGL = {\n\t\t[ NearestFilter ]: _gl.NEAREST,\n\t\t[ NearestMipmapNearestFilter ]: _gl.NEAREST_MIPMAP_NEAREST,\n\t\t[ NearestMipmapLinearFilter ]: _gl.NEAREST_MIPMAP_LINEAR,\n\n\t\t[ LinearFilter ]: _gl.LINEAR,\n\t\t[ LinearMipmapNearestFilter ]: _gl.LINEAR_MIPMAP_NEAREST,\n\t\t[ LinearMipmapLinearFilter ]: _gl.LINEAR_MIPMAP_LINEAR\n\t};\n\n\tfunction setTextureParameters( textureType, texture, supportsMips ) {\n\n\t\tif ( supportsMips ) {\n\n\t\t\t_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_S, wrappingToGL[ texture.wrapS ] );\n\t\t\t_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_T, wrappingToGL[ texture.wrapT ] );\n\n\t\t\tif ( textureType === _gl.TEXTURE_3D || textureType === _gl.TEXTURE_2D_ARRAY ) {\n\n\t\t\t\t_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_R, wrappingToGL[ texture.wrapR ] );\n\n\t\t\t}\n\n\t\t\t_gl.texParameteri( textureType, _gl.TEXTURE_MAG_FILTER, filterToGL[ texture.magFilter ] );\n\t\t\t_gl.texParameteri( textureType, _gl.TEXTURE_MIN_FILTER, filterToGL[ texture.minFilter ] );\n\n\t\t} else {\n\n\t\t\t_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_S, _gl.CLAMP_TO_EDGE );\n\t\t\t_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_T, _gl.CLAMP_TO_EDGE );\n\n\t\t\tif ( textureType === _gl.TEXTURE_3D || textureType === _gl.TEXTURE_2D_ARRAY ) {\n\n\t\t\t\t_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_R, _gl.CLAMP_TO_EDGE );\n\n\t\t\t}\n\n\t\t\tif ( texture.wrapS !== ClampToEdgeWrapping || texture.wrapT !== ClampToEdgeWrapping ) {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping.' );\n\n\t\t\t}\n\n\t\t\t_gl.texParameteri( textureType, _gl.TEXTURE_MAG_FILTER, filterFallback( texture.magFilter ) );\n\t\t\t_gl.texParameteri( textureType, _gl.TEXTURE_MIN_FILTER, filterFallback( texture.minFilter ) );\n\n\t\t\tif ( texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter ) {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.' );\n\n\t\t\t}\n\n\t\t}\n\n\t\tconst extension = extensions.get( 'EXT_texture_filter_anisotropic' );\n\n\t\tif ( extension ) {\n\n\t\t\tif ( texture.type === FloatType && extensions.get( 'OES_texture_float_linear' ) === null ) return;\n\t\t\tif ( texture.type === HalfFloatType && ( isWebGL2 || extensions.get( 'OES_texture_half_float_linear' ) ) === null ) return;\n\n\t\t\tif ( texture.anisotropy > 1 || properties.get( texture ).__currentAnisotropy ) {\n\n\t\t\t\t_gl.texParameterf( textureType, extension.TEXTURE_MAX_ANISOTROPY_EXT, Math.min( texture.anisotropy, capabilities.getMaxAnisotropy() ) );\n\t\t\t\tproperties.get( texture ).__currentAnisotropy = texture.anisotropy;\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tfunction initTexture( textureProperties, texture ) {\n\n\t\tif ( textureProperties.__webglInit === undefined ) {\n\n\t\t\ttextureProperties.__webglInit = true;\n\n\t\t\ttexture.addEventListener( 'dispose', onTextureDispose );\n\n\t\t\ttextureProperties.__webglTexture = _gl.createTexture();\n\n\t\t\tinfo.memory.textures ++;\n\n\t\t}\n\n\t}\n\n\tfunction uploadTexture( textureProperties, texture, slot ) {\n\n\t\tlet textureType = _gl.TEXTURE_2D;\n\n\t\tif ( texture.isDataTexture2DArray ) textureType = _gl.TEXTURE_2D_ARRAY;\n\t\tif ( texture.isDataTexture3D ) textureType = _gl.TEXTURE_3D;\n\n\t\tinitTexture( textureProperties, texture );\n\n\t\tstate.activeTexture( _gl.TEXTURE0 + slot );\n\t\tstate.bindTexture( textureType, textureProperties.__webglTexture );\n\n\t\t_gl.pixelStorei( _gl.UNPACK_FLIP_Y_WEBGL, texture.flipY );\n\t\t_gl.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultiplyAlpha );\n\t\t_gl.pixelStorei( _gl.UNPACK_ALIGNMENT, texture.unpackAlignment );\n\n\t\tconst needsPowerOfTwo = textureNeedsPowerOfTwo( texture ) && isPowerOfTwo( texture.image ) === false;\n\t\tconst image = resizeImage( texture.image, needsPowerOfTwo, false, maxTextureSize );\n\n\t\tconst supportsMips = isPowerOfTwo( image ) || isWebGL2,\n\t\t\tglFormat = utils.convert( texture.format );\n\n\t\tlet glType = utils.convert( texture.type ),\n\t\t\tglInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType );\n\n\t\tsetTextureParameters( textureType, texture, supportsMips );\n\n\t\tlet mipmap;\n\t\tconst mipmaps = texture.mipmaps;\n\n\t\tif ( texture.isDepthTexture ) {\n\n\t\t\t// populate depth texture with dummy data\n\n\t\t\tglInternalFormat = _gl.DEPTH_COMPONENT;\n\n\t\t\tif ( isWebGL2 ) {\n\n\t\t\t\tif ( texture.type === FloatType ) {\n\n\t\t\t\t\tglInternalFormat = _gl.DEPTH_COMPONENT32F;\n\n\t\t\t\t} else if ( texture.type === UnsignedIntType ) {\n\n\t\t\t\t\tglInternalFormat = _gl.DEPTH_COMPONENT24;\n\n\t\t\t\t} else if ( texture.type === UnsignedInt248Type ) {\n\n\t\t\t\t\tglInternalFormat = _gl.DEPTH24_STENCIL8;\n\n\t\t\t\t} else {\n\n\t\t\t\t\tglInternalFormat = _gl.DEPTH_COMPONENT16; // WebGL2 requires sized internalformat for glTexImage2D\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\tif ( texture.type === FloatType ) {\n\n\t\t\t\t\tconsole.error( 'WebGLRenderer: Floating point depth texture requires WebGL2.' );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// validation checks for WebGL 1\n\n\t\t\tif ( texture.format === DepthFormat && glInternalFormat === _gl.DEPTH_COMPONENT ) {\n\n\t\t\t\t// The error INVALID_OPERATION is generated by texImage2D if format and internalformat are\n\t\t\t\t// DEPTH_COMPONENT and type is not UNSIGNED_SHORT or UNSIGNED_INT\n\t\t\t\t// (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/)\n\t\t\t\tif ( texture.type !== UnsignedShortType && texture.type !== UnsignedIntType ) {\n\n\t\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture.' );\n\n\t\t\t\t\ttexture.type = UnsignedShortType;\n\t\t\t\t\tglType = utils.convert( texture.type );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif ( texture.format === DepthStencilFormat && glInternalFormat === _gl.DEPTH_COMPONENT ) {\n\n\t\t\t\t// Depth stencil textures need the DEPTH_STENCIL internal format\n\t\t\t\t// (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/)\n\t\t\t\tglInternalFormat = _gl.DEPTH_STENCIL;\n\n\t\t\t\t// The error INVALID_OPERATION is generated by texImage2D if format and internalformat are\n\t\t\t\t// DEPTH_STENCIL and type is not UNSIGNED_INT_24_8_WEBGL.\n\t\t\t\t// (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/)\n\t\t\t\tif ( texture.type !== UnsignedInt248Type ) {\n\n\t\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture.' );\n\n\t\t\t\t\ttexture.type = UnsignedInt248Type;\n\t\t\t\t\tglType = utils.convert( texture.type );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t//\n\n\t\t\tstate.texImage2D( _gl.TEXTURE_2D, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, null );\n\n\t\t} else if ( texture.isDataTexture ) {\n\n\t\t\t// use manually created mipmaps if available\n\t\t\t// if there are no manual mipmaps\n\t\t\t// set 0 level mipmap and then use GL to generate other mipmap levels\n\n\t\t\tif ( mipmaps.length > 0 && supportsMips ) {\n\n\t\t\t\tfor ( let i = 0, il = mipmaps.length; i < il; i ++ ) {\n\n\t\t\t\t\tmipmap = mipmaps[ i ];\n\t\t\t\t\tstate.texImage2D( _gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data );\n\n\t\t\t\t}\n\n\t\t\t\ttexture.generateMipmaps = false;\n\t\t\t\ttextureProperties.__maxMipLevel = mipmaps.length - 1;\n\n\t\t\t} else {\n\n\t\t\t\tstate.texImage2D( _gl.TEXTURE_2D, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, image.data );\n\t\t\t\ttextureProperties.__maxMipLevel = 0;\n\n\t\t\t}\n\n\t\t} else if ( texture.isCompressedTexture ) {\n\n\t\t\tfor ( let i = 0, il = mipmaps.length; i < il; i ++ ) {\n\n\t\t\t\tmipmap = mipmaps[ i ];\n\n\t\t\t\tif ( texture.format !== RGBAFormat && texture.format !== RGBFormat ) {\n\n\t\t\t\t\tif ( glFormat !== null ) {\n\n\t\t\t\t\t\tstate.compressedTexImage2D( _gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data );\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()' );\n\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\n\t\t\t\t\tstate.texImage2D( _gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\ttextureProperties.__maxMipLevel = mipmaps.length - 1;\n\n\t\t} else if ( texture.isDataTexture2DArray ) {\n\n\t\t\tstate.texImage3D( _gl.TEXTURE_2D_ARRAY, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data );\n\t\t\ttextureProperties.__maxMipLevel = 0;\n\n\t\t} else if ( texture.isDataTexture3D ) {\n\n\t\t\tstate.texImage3D( _gl.TEXTURE_3D, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data );\n\t\t\ttextureProperties.__maxMipLevel = 0;\n\n\t\t} else {\n\n\t\t\t// regular Texture (image, video, canvas)\n\n\t\t\t// use manually created mipmaps if available\n\t\t\t// if there are no manual mipmaps\n\t\t\t// set 0 level mipmap and then use GL to generate other mipmap levels\n\n\t\t\tif ( mipmaps.length > 0 && supportsMips ) {\n\n\t\t\t\tfor ( let i = 0, il = mipmaps.length; i < il; i ++ ) {\n\n\t\t\t\t\tmipmap = mipmaps[ i ];\n\t\t\t\t\tstate.texImage2D( _gl.TEXTURE_2D, i, glInternalFormat, glFormat, glType, mipmap );\n\n\t\t\t\t}\n\n\t\t\t\ttexture.generateMipmaps = false;\n\t\t\t\ttextureProperties.__maxMipLevel = mipmaps.length - 1;\n\n\t\t\t} else {\n\n\t\t\t\tstate.texImage2D( _gl.TEXTURE_2D, 0, glInternalFormat, glFormat, glType, image );\n\t\t\t\ttextureProperties.__maxMipLevel = 0;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) {\n\n\t\t\tgenerateMipmap( textureType, texture, image.width, image.height );\n\n\t\t}\n\n\t\ttextureProperties.__version = texture.version;\n\n\t\tif ( texture.onUpdate ) texture.onUpdate( texture );\n\n\t}\n\n\t// Render targets\n\n\t// Setup storage for target texture and bind it to correct framebuffer\n\tfunction setupFrameBufferTexture( framebuffer, renderTarget, attachment, textureTarget ) {\n\n\t\tconst glFormat = utils.convert( renderTarget.texture.format );\n\t\tconst glType = utils.convert( renderTarget.texture.type );\n\t\tconst glInternalFormat = getInternalFormat( renderTarget.texture.internalFormat, glFormat, glType );\n\t\tstate.texImage2D( textureTarget, 0, glInternalFormat, renderTarget.width, renderTarget.height, 0, glFormat, glType, null );\n\t\t_gl.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );\n\t\t_gl.framebufferTexture2D( _gl.FRAMEBUFFER, attachment, textureTarget, properties.get( renderTarget.texture ).__webglTexture, 0 );\n\t\t_gl.bindFramebuffer( _gl.FRAMEBUFFER, null );\n\n\t}\n\n\t// Setup storage for internal depth/stencil buffers and bind to correct framebuffer\n\tfunction setupRenderBufferStorage( renderbuffer, renderTarget, isMultisample ) {\n\n\t\t_gl.bindRenderbuffer( _gl.RENDERBUFFER, renderbuffer );\n\n\t\tif ( renderTarget.depthBuffer && ! renderTarget.stencilBuffer ) {\n\n\t\t\tlet glInternalFormat = _gl.DEPTH_COMPONENT16;\n\n\t\t\tif ( isMultisample ) {\n\n\t\t\t\tconst depthTexture = renderTarget.depthTexture;\n\n\t\t\t\tif ( depthTexture && depthTexture.isDepthTexture ) {\n\n\t\t\t\t\tif ( depthTexture.type === FloatType ) {\n\n\t\t\t\t\t\tglInternalFormat = _gl.DEPTH_COMPONENT32F;\n\n\t\t\t\t\t} else if ( depthTexture.type === UnsignedIntType ) {\n\n\t\t\t\t\t\tglInternalFormat = _gl.DEPTH_COMPONENT24;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tconst samples = getRenderTargetSamples( renderTarget );\n\n\t\t\t\t_gl.renderbufferStorageMultisample( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );\n\n\t\t\t} else {\n\n\t\t\t\t_gl.renderbufferStorage( _gl.RENDERBUFFER, glInternalFormat, renderTarget.width, renderTarget.height );\n\n\t\t\t}\n\n\t\t\t_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.RENDERBUFFER, renderbuffer );\n\n\t\t} else if ( renderTarget.depthBuffer && renderTarget.stencilBuffer ) {\n\n\t\t\tif ( isMultisample ) {\n\n\t\t\t\tconst samples = getRenderTargetSamples( renderTarget );\n\n\t\t\t\t_gl.renderbufferStorageMultisample( _gl.RENDERBUFFER, samples, _gl.DEPTH24_STENCIL8, renderTarget.width, renderTarget.height );\n\n\t\t\t} else {\n\n\t\t\t\t_gl.renderbufferStorage( _gl.RENDERBUFFER, _gl.DEPTH_STENCIL, renderTarget.width, renderTarget.height );\n\n\t\t\t}\n\n\n\t\t\t_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, _gl.RENDERBUFFER, renderbuffer );\n\n\t\t} else {\n\n\t\t\tconst glFormat = utils.convert( renderTarget.texture.format );\n\t\t\tconst glType = utils.convert( renderTarget.texture.type );\n\t\t\tconst glInternalFormat = getInternalFormat( renderTarget.texture.internalFormat, glFormat, glType );\n\n\t\t\tif ( isMultisample ) {\n\n\t\t\t\tconst samples = getRenderTargetSamples( renderTarget );\n\n\t\t\t\t_gl.renderbufferStorageMultisample( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );\n\n\t\t\t} else {\n\n\t\t\t\t_gl.renderbufferStorage( _gl.RENDERBUFFER, glInternalFormat, renderTarget.width, renderTarget.height );\n\n\t\t\t}\n\n\t\t}\n\n\t\t_gl.bindRenderbuffer( _gl.RENDERBUFFER, null );\n\n\t}\n\n\t// Setup resources for a Depth Texture for a FBO (needs an extension)\n\tfunction setupDepthTexture( framebuffer, renderTarget ) {\n\n\t\tconst isCube = ( renderTarget && renderTarget.isWebGLCubeRenderTarget );\n\t\tif ( isCube ) throw new Error( 'Depth Texture with cube render targets is not supported' );\n\n\t\t_gl.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );\n\n\t\tif ( ! ( renderTarget.depthTexture && renderTarget.depthTexture.isDepthTexture ) ) {\n\n\t\t\tthrow new Error( 'renderTarget.depthTexture must be an instance of THREE.DepthTexture' );\n\n\t\t}\n\n\t\t// upload an empty depth texture with framebuffer size\n\t\tif ( ! properties.get( renderTarget.depthTexture ).__webglTexture ||\n\t\t\t\trenderTarget.depthTexture.image.width !== renderTarget.width ||\n\t\t\t\trenderTarget.depthTexture.image.height !== renderTarget.height ) {\n\n\t\t\trenderTarget.depthTexture.image.width = renderTarget.width;\n\t\t\trenderTarget.depthTexture.image.height = renderTarget.height;\n\t\t\trenderTarget.depthTexture.needsUpdate = true;\n\n\t\t}\n\n\t\tsetTexture2D( renderTarget.depthTexture, 0 );\n\n\t\tconst webglDepthTexture = properties.get( renderTarget.depthTexture ).__webglTexture;\n\n\t\tif ( renderTarget.depthTexture.format === DepthFormat ) {\n\n\t\t\t_gl.framebufferTexture2D( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0 );\n\n\t\t} else if ( renderTarget.depthTexture.format === DepthStencilFormat ) {\n\n\t\t\t_gl.framebufferTexture2D( _gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0 );\n\n\t\t} else {\n\n\t\t\tthrow new Error( 'Unknown depthTexture format' );\n\n\t\t}\n\n\t}\n\n\t// Setup GL resources for a non-texture depth buffer\n\tfunction setupDepthRenderbuffer( renderTarget ) {\n\n\t\tconst renderTargetProperties = properties.get( renderTarget );\n\n\t\tconst isCube = ( renderTarget.isWebGLCubeRenderTarget === true );\n\n\t\tif ( renderTarget.depthTexture ) {\n\n\t\t\tif ( isCube ) throw new Error( 'target.depthTexture not supported in Cube render targets' );\n\n\t\t\tsetupDepthTexture( renderTargetProperties.__webglFramebuffer, renderTarget );\n\n\t\t} else {\n\n\t\t\tif ( isCube ) {\n\n\t\t\t\trenderTargetProperties.__webglDepthbuffer = [];\n\n\t\t\t\tfor ( let i = 0; i < 6; i ++ ) {\n\n\t\t\t\t\t_gl.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer[ i ] );\n\t\t\t\t\trenderTargetProperties.__webglDepthbuffer[ i ] = _gl.createRenderbuffer();\n\t\t\t\t\tsetupRenderBufferStorage( renderTargetProperties.__webglDepthbuffer[ i ], renderTarget, false );\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\t_gl.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer );\n\t\t\t\trenderTargetProperties.__webglDepthbuffer = _gl.createRenderbuffer();\n\t\t\t\tsetupRenderBufferStorage( renderTargetProperties.__webglDepthbuffer, renderTarget, false );\n\n\t\t\t}\n\n\t\t}\n\n\t\t_gl.bindFramebuffer( _gl.FRAMEBUFFER, null );\n\n\t}\n\n\t// Set up GL resources for the render target\n\tfunction setupRenderTarget( renderTarget ) {\n\n\t\tconst renderTargetProperties = properties.get( renderTarget );\n\t\tconst textureProperties = properties.get( renderTarget.texture );\n\n\t\trenderTarget.addEventListener( 'dispose', onRenderTargetDispose );\n\n\t\ttextureProperties.__webglTexture = _gl.createTexture();\n\n\t\tinfo.memory.textures ++;\n\n\t\tconst isCube = ( renderTarget.isWebGLCubeRenderTarget === true );\n\t\tconst isMultisample = ( renderTarget.isWebGLMultisampleRenderTarget === true );\n\t\tconst supportsMips = isPowerOfTwo( renderTarget ) || isWebGL2;\n\n\t\t// Handles WebGL2 RGBFormat fallback - #18858\n\n\t\tif ( isWebGL2 && renderTarget.texture.format === RGBFormat && ( renderTarget.texture.type === FloatType || renderTarget.texture.type === HalfFloatType ) ) {\n\n\t\t\trenderTarget.texture.format = RGBAFormat;\n\n\t\t\tconsole.warn( 'THREE.WebGLRenderer: Rendering to textures with RGB format is not supported. Using RGBA format instead.' );\n\n\t\t}\n\n\t\t// Setup framebuffer\n\n\t\tif ( isCube ) {\n\n\t\t\trenderTargetProperties.__webglFramebuffer = [];\n\n\t\t\tfor ( let i = 0; i < 6; i ++ ) {\n\n\t\t\t\trenderTargetProperties.__webglFramebuffer[ i ] = _gl.createFramebuffer();\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\trenderTargetProperties.__webglFramebuffer = _gl.createFramebuffer();\n\n\t\t\tif ( isMultisample ) {\n\n\t\t\t\tif ( isWebGL2 ) {\n\n\t\t\t\t\trenderTargetProperties.__webglMultisampledFramebuffer = _gl.createFramebuffer();\n\t\t\t\t\trenderTargetProperties.__webglColorRenderbuffer = _gl.createRenderbuffer();\n\n\t\t\t\t\t_gl.bindRenderbuffer( _gl.RENDERBUFFER, renderTargetProperties.__webglColorRenderbuffer );\n\n\t\t\t\t\tconst glFormat = utils.convert( renderTarget.texture.format );\n\t\t\t\t\tconst glType = utils.convert( renderTarget.texture.type );\n\t\t\t\t\tconst glInternalFormat = getInternalFormat( renderTarget.texture.internalFormat, glFormat, glType );\n\t\t\t\t\tconst samples = getRenderTargetSamples( renderTarget );\n\t\t\t\t\t_gl.renderbufferStorageMultisample( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );\n\n\t\t\t\t\t_gl.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer );\n\t\t\t\t\t_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, _gl.RENDERBUFFER, renderTargetProperties.__webglColorRenderbuffer );\n\t\t\t\t\t_gl.bindRenderbuffer( _gl.RENDERBUFFER, null );\n\n\t\t\t\t\tif ( renderTarget.depthBuffer ) {\n\n\t\t\t\t\t\trenderTargetProperties.__webglDepthRenderbuffer = _gl.createRenderbuffer();\n\t\t\t\t\t\tsetupRenderBufferStorage( renderTargetProperties.__webglDepthRenderbuffer, renderTarget, true );\n\n\t\t\t\t\t}\n\n\t\t\t\t\t_gl.bindFramebuffer( _gl.FRAMEBUFFER, null );\n\n\n\t\t\t\t} else {\n\n\t\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.' );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\t// Setup color buffer\n\n\t\tif ( isCube ) {\n\n\t\t\tstate.bindTexture( _gl.TEXTURE_CUBE_MAP, textureProperties.__webglTexture );\n\t\t\tsetTextureParameters( _gl.TEXTURE_CUBE_MAP, renderTarget.texture, supportsMips );\n\n\t\t\tfor ( let i = 0; i < 6; i ++ ) {\n\n\t\t\t\tsetupFrameBufferTexture( renderTargetProperties.__webglFramebuffer[ i ], renderTarget, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i );\n\n\t\t\t}\n\n\t\t\tif ( textureNeedsGenerateMipmaps( renderTarget.texture, supportsMips ) ) {\n\n\t\t\t\tgenerateMipmap( _gl.TEXTURE_CUBE_MAP, renderTarget.texture, renderTarget.width, renderTarget.height );\n\n\t\t\t}\n\n\t\t\tstate.bindTexture( _gl.TEXTURE_CUBE_MAP, null );\n\n\t\t} else {\n\n\t\t\tstate.bindTexture( _gl.TEXTURE_2D, textureProperties.__webglTexture );\n\t\t\tsetTextureParameters( _gl.TEXTURE_2D, renderTarget.texture, supportsMips );\n\t\t\tsetupFrameBufferTexture( renderTargetProperties.__webglFramebuffer, renderTarget, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_2D );\n\n\t\t\tif ( textureNeedsGenerateMipmaps( renderTarget.texture, supportsMips ) ) {\n\n\t\t\t\tgenerateMipmap( _gl.TEXTURE_2D, renderTarget.texture, renderTarget.width, renderTarget.height );\n\n\t\t\t}\n\n\t\t\tstate.bindTexture( _gl.TEXTURE_2D, null );\n\n\t\t}\n\n\t\t// Setup depth and stencil buffers\n\n\t\tif ( renderTarget.depthBuffer ) {\n\n\t\t\tsetupDepthRenderbuffer( renderTarget );\n\n\t\t}\n\n\t}\n\n\tfunction updateRenderTargetMipmap( renderTarget ) {\n\n\t\tconst texture = renderTarget.texture;\n\t\tconst supportsMips = isPowerOfTwo( renderTarget ) || isWebGL2;\n\n\t\tif ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) {\n\n\t\t\tconst target = renderTarget.isWebGLCubeRenderTarget ? _gl.TEXTURE_CUBE_MAP : _gl.TEXTURE_2D;\n\t\t\tconst webglTexture = properties.get( texture ).__webglTexture;\n\n\t\t\tstate.bindTexture( target, webglTexture );\n\t\t\tgenerateMipmap( target, texture, renderTarget.width, renderTarget.height );\n\t\t\tstate.bindTexture( target, null );\n\n\t\t}\n\n\t}\n\n\tfunction updateMultisampleRenderTarget( renderTarget ) {\n\n\t\tif ( renderTarget.isWebGLMultisampleRenderTarget ) {\n\n\t\t\tif ( isWebGL2 ) {\n\n\t\t\t\tconst renderTargetProperties = properties.get( renderTarget );\n\n\t\t\t\t_gl.bindFramebuffer( _gl.READ_FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer );\n\t\t\t\t_gl.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, renderTargetProperties.__webglFramebuffer );\n\n\t\t\t\tconst width = renderTarget.width;\n\t\t\t\tconst height = renderTarget.height;\n\t\t\t\tlet mask = _gl.COLOR_BUFFER_BIT;\n\n\t\t\t\tif ( renderTarget.depthBuffer ) mask |= _gl.DEPTH_BUFFER_BIT;\n\t\t\t\tif ( renderTarget.stencilBuffer ) mask |= _gl.STENCIL_BUFFER_BIT;\n\n\t\t\t\t_gl.blitFramebuffer( 0, 0, width, height, 0, 0, width, height, mask, _gl.NEAREST );\n\n\t\t\t\t_gl.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer ); // see #18905\n\n\t\t\t} else {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.' );\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tfunction getRenderTargetSamples( renderTarget ) {\n\n\t\treturn ( isWebGL2 && renderTarget.isWebGLMultisampleRenderTarget ) ?\n\t\t\tMath.min( maxSamples, renderTarget.samples ) : 0;\n\n\t}\n\n\tfunction updateVideoTexture( texture ) {\n\n\t\tconst frame = info.render.frame;\n\n\t\t// Check the last frame we updated the VideoTexture\n\n\t\tif ( _videoTextures.get( texture ) !== frame ) {\n\n\t\t\t_videoTextures.set( texture, frame );\n\t\t\ttexture.update();\n\n\t\t}\n\n\t}\n\n\t// backwards compatibility\n\n\tlet warnedTexture2D = false;\n\tlet warnedTextureCube = false;\n\n\tfunction safeSetTexture2D( texture, slot ) {\n\n\t\tif ( texture && texture.isWebGLRenderTarget ) {\n\n\t\t\tif ( warnedTexture2D === false ) {\n\n\t\t\t\tconsole.warn( \"THREE.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead.\" );\n\t\t\t\twarnedTexture2D = true;\n\n\t\t\t}\n\n\t\t\ttexture = texture.texture;\n\n\t\t}\n\n\t\tsetTexture2D( texture, slot );\n\n\t}\n\n\tfunction safeSetTextureCube( texture, slot ) {\n\n\t\tif ( texture && texture.isWebGLCubeRenderTarget ) {\n\n\t\t\tif ( warnedTextureCube === false ) {\n\n\t\t\t\tconsole.warn( \"THREE.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead.\" );\n\t\t\t\twarnedTextureCube = true;\n\n\t\t\t}\n\n\t\t\ttexture = texture.texture;\n\n\t\t}\n\n\t\t// currently relying on the fact that WebGLCubeRenderTarget.texture is a Texture and NOT a CubeTexture\n\t\t// TODO: unify these code paths\n\t\tif ( ( texture && texture.isCubeTexture ) ||\n\t\t\t( Array.isArray( texture.image ) && texture.image.length === 6 ) ) {\n\n\t\t\t// CompressedTexture can have Array in image :/\n\n\t\t\t// this function alone should take care of cube textures\n\t\t\tsetTextureCube( texture, slot );\n\n\t\t} else {\n\n\t\t\t// assumed: texture property of THREE.WebGLCubeRenderTarget\n\t\t\tsetTextureCubeDynamic( texture, slot );\n\n\t\t}\n\n\t}\n\n\t//\n\n\tthis.allocateTextureUnit = allocateTextureUnit;\n\tthis.resetTextureUnits = resetTextureUnits;\n\n\tthis.setTexture2D = setTexture2D;\n\tthis.setTexture2DArray = setTexture2DArray;\n\tthis.setTexture3D = setTexture3D;\n\tthis.setTextureCube = setTextureCube;\n\tthis.setTextureCubeDynamic = setTextureCubeDynamic;\n\tthis.setupRenderTarget = setupRenderTarget;\n\tthis.updateRenderTargetMipmap = updateRenderTargetMipmap;\n\tthis.updateMultisampleRenderTarget = updateMultisampleRenderTarget;\n\n\tthis.safeSetTexture2D = safeSetTexture2D;\n\tthis.safeSetTextureCube = safeSetTextureCube;\n\n}\n\nexport { WebGLTextures };\n","/**\n * @author thespite / http://www.twitter.com/thespite\n */\n\nimport { RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_10x10_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGBA_ETC2_EAC_Format, RGBA_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGB_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT5_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT1_Format, RGB_S3TC_DXT1_Format, DepthFormat, DepthStencilFormat, LuminanceAlphaFormat, LuminanceFormat, RedFormat, RGBAFormat, RGBFormat, AlphaFormat, RedIntegerFormat, RGFormat, RGIntegerFormat, RGBIntegerFormat, RGBAIntegerFormat, HalfFloatType, FloatType, UnsignedIntType, IntType, UnsignedShortType, ShortType, ByteType, UnsignedInt248Type, UnsignedShort565Type, UnsignedShort5551Type, UnsignedShort4444Type, UnsignedByteType, SRGB8_ALPHA8_ASTC_4x4_Format, SRGB8_ALPHA8_ASTC_5x4_Format, SRGB8_ALPHA8_ASTC_5x5_Format, SRGB8_ALPHA8_ASTC_6x5_Format, SRGB8_ALPHA8_ASTC_6x6_Format, SRGB8_ALPHA8_ASTC_8x5_Format, SRGB8_ALPHA8_ASTC_8x6_Format, SRGB8_ALPHA8_ASTC_8x8_Format, SRGB8_ALPHA8_ASTC_10x5_Format, SRGB8_ALPHA8_ASTC_10x6_Format, SRGB8_ALPHA8_ASTC_10x8_Format, SRGB8_ALPHA8_ASTC_10x10_Format, SRGB8_ALPHA8_ASTC_12x10_Format, SRGB8_ALPHA8_ASTC_12x12_Format, RGBA_BPTC_Format } from '../../constants.js';\n\nfunction WebGLUtils( gl, extensions, capabilities ) {\n\n\tconst isWebGL2 = capabilities.isWebGL2;\n\n\tfunction convert( p ) {\n\n\t\tlet extension;\n\n\t\tif ( p === UnsignedByteType ) return gl.UNSIGNED_BYTE;\n\t\tif ( p === UnsignedShort4444Type ) return gl.UNSIGNED_SHORT_4_4_4_4;\n\t\tif ( p === UnsignedShort5551Type ) return gl.UNSIGNED_SHORT_5_5_5_1;\n\t\tif ( p === UnsignedShort565Type ) return gl.UNSIGNED_SHORT_5_6_5;\n\n\t\tif ( p === ByteType ) return gl.BYTE;\n\t\tif ( p === ShortType ) return gl.SHORT;\n\t\tif ( p === UnsignedShortType ) return gl.UNSIGNED_SHORT;\n\t\tif ( p === IntType ) return gl.INT;\n\t\tif ( p === UnsignedIntType ) return gl.UNSIGNED_INT;\n\t\tif ( p === FloatType ) return gl.FLOAT;\n\n\t\tif ( p === HalfFloatType ) {\n\n\t\t\tif ( isWebGL2 ) return gl.HALF_FLOAT;\n\n\t\t\textension = extensions.get( 'OES_texture_half_float' );\n\n\t\t\tif ( extension !== null ) {\n\n\t\t\t\treturn extension.HALF_FLOAT_OES;\n\n\t\t\t} else {\n\n\t\t\t\treturn null;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( p === AlphaFormat ) return gl.ALPHA;\n\t\tif ( p === RGBFormat ) return gl.RGB;\n\t\tif ( p === RGBAFormat ) return gl.RGBA;\n\t\tif ( p === LuminanceFormat ) return gl.LUMINANCE;\n\t\tif ( p === LuminanceAlphaFormat ) return gl.LUMINANCE_ALPHA;\n\t\tif ( p === DepthFormat ) return gl.DEPTH_COMPONENT;\n\t\tif ( p === DepthStencilFormat ) return gl.DEPTH_STENCIL;\n\t\tif ( p === RedFormat ) return gl.RED;\n\n\t\t// WebGL2 formats.\n\n\t\tif ( p === RedIntegerFormat ) return gl.RED_INTEGER;\n\t\tif ( p === RGFormat ) return gl.RG;\n\t\tif ( p === RGIntegerFormat ) return gl.RG_INTEGER;\n\t\tif ( p === RGBIntegerFormat ) return gl.RGB_INTEGER;\n\t\tif ( p === RGBAIntegerFormat ) return gl.RGBA_INTEGER;\n\n\t\tif ( p === RGB_S3TC_DXT1_Format || p === RGBA_S3TC_DXT1_Format ||\n\t\t\tp === RGBA_S3TC_DXT3_Format || p === RGBA_S3TC_DXT5_Format ) {\n\n\t\t\textension = extensions.get( 'WEBGL_compressed_texture_s3tc' );\n\n\t\t\tif ( extension !== null ) {\n\n\t\t\t\tif ( p === RGB_S3TC_DXT1_Format ) return extension.COMPRESSED_RGB_S3TC_DXT1_EXT;\n\t\t\t\tif ( p === RGBA_S3TC_DXT1_Format ) return extension.COMPRESSED_RGBA_S3TC_DXT1_EXT;\n\t\t\t\tif ( p === RGBA_S3TC_DXT3_Format ) return extension.COMPRESSED_RGBA_S3TC_DXT3_EXT;\n\t\t\t\tif ( p === RGBA_S3TC_DXT5_Format ) return extension.COMPRESSED_RGBA_S3TC_DXT5_EXT;\n\n\t\t\t} else {\n\n\t\t\t\treturn null;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( p === RGB_PVRTC_4BPPV1_Format || p === RGB_PVRTC_2BPPV1_Format ||\n\t\t\tp === RGBA_PVRTC_4BPPV1_Format || p === RGBA_PVRTC_2BPPV1_Format ) {\n\n\t\t\textension = extensions.get( 'WEBGL_compressed_texture_pvrtc' );\n\n\t\t\tif ( extension !== null ) {\n\n\t\t\t\tif ( p === RGB_PVRTC_4BPPV1_Format ) return extension.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;\n\t\t\t\tif ( p === RGB_PVRTC_2BPPV1_Format ) return extension.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;\n\t\t\t\tif ( p === RGBA_PVRTC_4BPPV1_Format ) return extension.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;\n\t\t\t\tif ( p === RGBA_PVRTC_2BPPV1_Format ) return extension.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;\n\n\t\t\t} else {\n\n\t\t\t\treturn null;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( p === RGB_ETC1_Format ) {\n\n\t\t\textension = extensions.get( 'WEBGL_compressed_texture_etc1' );\n\n\t\t\tif ( extension !== null ) {\n\n\t\t\t\treturn extension.COMPRESSED_RGB_ETC1_WEBGL;\n\n\t\t\t} else {\n\n\t\t\t\treturn null;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( p === RGB_ETC2_Format || p === RGBA_ETC2_EAC_Format ) {\n\n\t\t\textension = extensions.get( 'WEBGL_compressed_texture_etc' );\n\n\t\t\tif ( extension !== null ) {\n\n\t\t\t\tif ( p === RGB_ETC2_Format ) return extension.COMPRESSED_RGB8_ETC2;\n\t\t\t\tif ( p === RGBA_ETC2_EAC_Format ) return extension.COMPRESSED_RGBA8_ETC2_EAC;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( p === RGBA_ASTC_4x4_Format || p === RGBA_ASTC_5x4_Format || p === RGBA_ASTC_5x5_Format ||\n\t\t\tp === RGBA_ASTC_6x5_Format || p === RGBA_ASTC_6x6_Format || p === RGBA_ASTC_8x5_Format ||\n\t\t\tp === RGBA_ASTC_8x6_Format || p === RGBA_ASTC_8x8_Format || p === RGBA_ASTC_10x5_Format ||\n\t\t\tp === RGBA_ASTC_10x6_Format || p === RGBA_ASTC_10x8_Format || p === RGBA_ASTC_10x10_Format ||\n\t\t\tp === RGBA_ASTC_12x10_Format || p === RGBA_ASTC_12x12_Format ||\n\t\t\tp === SRGB8_ALPHA8_ASTC_4x4_Format || p === SRGB8_ALPHA8_ASTC_5x4_Format || p === SRGB8_ALPHA8_ASTC_5x5_Format ||\n\t\t\tp === SRGB8_ALPHA8_ASTC_6x5_Format || p === SRGB8_ALPHA8_ASTC_6x6_Format || p === SRGB8_ALPHA8_ASTC_8x5_Format ||\n\t\t\tp === SRGB8_ALPHA8_ASTC_8x6_Format || p === SRGB8_ALPHA8_ASTC_8x8_Format || p === SRGB8_ALPHA8_ASTC_10x5_Format ||\n\t\t\tp === SRGB8_ALPHA8_ASTC_10x6_Format || p === SRGB8_ALPHA8_ASTC_10x8_Format || p === SRGB8_ALPHA8_ASTC_10x10_Format ||\n\t\t\tp === SRGB8_ALPHA8_ASTC_12x10_Format || p === SRGB8_ALPHA8_ASTC_12x12_Format ) {\n\n\t\t\textension = extensions.get( 'WEBGL_compressed_texture_astc' );\n\n\t\t\tif ( extension !== null ) {\n\n\t\t\t\t// TODO Complete?\n\n\t\t\t\treturn p;\n\n\t\t\t} else {\n\n\t\t\t\treturn null;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( p === RGBA_BPTC_Format ) {\n\n\t\t\textension = extensions.get( 'EXT_texture_compression_bptc' );\n\n\t\t\tif ( extension !== null ) {\n\n\t\t\t\t// TODO Complete?\n\n\t\t\t\treturn p;\n\n\t\t\t} else {\n\n\t\t\t\treturn null;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( p === UnsignedInt248Type ) {\n\n\t\t\tif ( isWebGL2 ) return gl.UNSIGNED_INT_24_8;\n\n\t\t\textension = extensions.get( 'WEBGL_depth_texture' );\n\n\t\t\tif ( extension !== null ) {\n\n\t\t\t\treturn extension.UNSIGNED_INT_24_8_WEBGL;\n\n\t\t\t} else {\n\n\t\t\t\treturn null;\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\treturn { convert: convert };\n\n}\n\n\nexport { WebGLUtils };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { PerspectiveCamera } from './PerspectiveCamera.js';\n\nfunction ArrayCamera( array ) {\n\n\tPerspectiveCamera.call( this );\n\n\tthis.cameras = array || [];\n\n}\n\nArrayCamera.prototype = Object.assign( Object.create( PerspectiveCamera.prototype ), {\n\n\tconstructor: ArrayCamera,\n\n\tisArrayCamera: true\n\n} );\n\n\nexport { ArrayCamera };\n","import { Object3D } from '../core/Object3D.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction Group() {\n\n\tObject3D.call( this );\n\n\tthis.type = 'Group';\n\n}\n\nGroup.prototype = Object.assign( Object.create( Object3D.prototype ), {\n\n\tconstructor: Group,\n\n\tisGroup: true\n\n} );\n\n\nexport { Group };\n","import { Group } from '../../objects/Group.js';\n\n/**\n * @author Mugen87 / https://github.com/Mugen87\n */\n\nfunction WebXRController() {\n\n\tthis._targetRay = null;\n\tthis._grip = null;\n\n}\n\nObject.assign( WebXRController.prototype, {\n\n\tconstructor: WebXRController,\n\n\tgetTargetRaySpace: function () {\n\n\t\tif ( this._targetRay === null ) {\n\n\t\t\tthis._targetRay = new Group();\n\t\t\tthis._targetRay.matrixAutoUpdate = false;\n\t\t\tthis._targetRay.visible = false;\n\n\t\t}\n\n\t\treturn this._targetRay;\n\n\t},\n\n\tgetGripSpace: function () {\n\n\t\tif ( this._grip === null ) {\n\n\t\t\tthis._grip = new Group();\n\t\t\tthis._grip.matrixAutoUpdate = false;\n\t\t\tthis._grip.visible = false;\n\n\t\t}\n\n\t\treturn this._grip;\n\n\t},\n\n\tdispatchEvent: function ( event ) {\n\n\t\tif ( this._targetRay !== null ) {\n\n\t\t\tthis._targetRay.dispatchEvent( event );\n\n\t\t}\n\n\t\tif ( this._grip !== null ) {\n\n\t\t\tthis._grip.dispatchEvent( event );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tdisconnect: function ( inputSource ) {\n\n\t\tthis.dispatchEvent( { type: 'disconnected', data: inputSource } );\n\n\t\tif ( this._targetRay !== null ) {\n\n\t\t\tthis._targetRay.visible = false;\n\n\t\t}\n\n\t\tif ( this._grip !== null ) {\n\n\t\t\tthis._grip.visible = false;\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tupdate: function ( inputSource, frame, referenceSpace ) {\n\n\t\tlet inputPose = null;\n\t\tlet gripPose = null;\n\n\t\tconst targetRay = this._targetRay;\n\t\tconst grip = this._grip;\n\n\t\tif ( inputSource ) {\n\n\t\t\tif ( targetRay !== null ) {\n\n\t\t\t\tinputPose = frame.getPose( inputSource.targetRaySpace, referenceSpace );\n\n\t\t\t\tif ( inputPose !== null ) {\n\n\t\t\t\t\ttargetRay.matrix.fromArray( inputPose.transform.matrix );\n\t\t\t\t\ttargetRay.matrix.decompose( targetRay.position, targetRay.rotation, targetRay.scale );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif ( grip !== null && inputSource.gripSpace ) {\n\n\t\t\t\tgripPose = frame.getPose( inputSource.gripSpace, referenceSpace );\n\n\t\t\t\tif ( gripPose !== null ) {\n\n\t\t\t\t\tgrip.matrix.fromArray( gripPose.transform.matrix );\n\t\t\t\t\tgrip.matrix.decompose( grip.position, grip.rotation, grip.scale );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( targetRay !== null ) {\n\n\t\t\ttargetRay.visible = ( inputPose !== null );\n\n\t\t}\n\n\t\tif ( grip !== null ) {\n\n\t\t\tgrip.visible = ( gripPose !== null );\n\n\t\t}\n\n\t\treturn this;\n\n\t}\n\n} );\n\n\nexport { WebXRController };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { ArrayCamera } from '../../cameras/ArrayCamera.js';\nimport { EventDispatcher } from '../../core/EventDispatcher.js';\nimport { PerspectiveCamera } from '../../cameras/PerspectiveCamera.js';\nimport { Vector3 } from '../../math/Vector3.js';\nimport { Vector4 } from '../../math/Vector4.js';\nimport { WebGLAnimation } from '../webgl/WebGLAnimation.js';\nimport { WebXRController } from './WebXRController.js';\n\nfunction WebXRManager( renderer, gl ) {\n\n\tconst scope = this;\n\n\tlet session = null;\n\n\tlet framebufferScaleFactor = 1.0;\n\n\tlet referenceSpace = null;\n\tlet referenceSpaceType = 'local-floor';\n\n\tlet pose = null;\n\n\tconst controllers = [];\n\tconst inputSourcesMap = new Map();\n\n\t//\n\n\tconst cameraL = new PerspectiveCamera();\n\tcameraL.layers.enable( 1 );\n\tcameraL.viewport = new Vector4();\n\n\tconst cameraR = new PerspectiveCamera();\n\tcameraR.layers.enable( 2 );\n\tcameraR.viewport = new Vector4();\n\n\tconst cameras = [ cameraL, cameraR ];\n\n\tconst cameraVR = new ArrayCamera();\n\tcameraVR.layers.enable( 1 );\n\tcameraVR.layers.enable( 2 );\n\n\tlet _currentDepthNear = null;\n\tlet _currentDepthFar = null;\n\n\t//\n\n\tthis.enabled = false;\n\n\tthis.isPresenting = false;\n\n\tthis.getController = function ( index ) {\n\n\t\tlet controller = controllers[ index ];\n\n\t\tif ( controller === undefined ) {\n\n\t\t\tcontroller = new WebXRController();\n\t\t\tcontrollers[ index ] = controller;\n\n\t\t}\n\n\t\treturn controller.getTargetRaySpace();\n\n\t};\n\n\tthis.getControllerGrip = function ( index ) {\n\n\t\tlet controller = controllers[ index ];\n\n\t\tif ( controller === undefined ) {\n\n\t\t\tcontroller = new WebXRController();\n\t\t\tcontrollers[ index ] = controller;\n\n\t\t}\n\n\t\treturn controller.getGripSpace();\n\n\t};\n\n\t//\n\n\tfunction onSessionEvent( event ) {\n\n\t\tconst controller = inputSourcesMap.get( event.inputSource );\n\n\t\tif ( controller ) {\n\n\t\t\tcontroller.dispatchEvent( { type: event.type } );\n\n\t\t}\n\n\t}\n\n\tfunction onSessionEnd() {\n\n\t\tinputSourcesMap.forEach( function ( controller, inputSource ) {\n\n\t\t\tcontroller.disconnect( inputSource );\n\n\t\t} );\n\n\t\tinputSourcesMap.clear();\n\n\t\t//\n\n\t\trenderer.setFramebuffer( null );\n\t\trenderer.setRenderTarget( renderer.getRenderTarget() ); // Hack #15830\n\t\tanimation.stop();\n\n\t\tscope.isPresenting = false;\n\n\t\tscope.dispatchEvent( { type: 'sessionend' } );\n\n\t}\n\n\tfunction onRequestReferenceSpace( value ) {\n\n\t\treferenceSpace = value;\n\n\t\tanimation.setContext( session );\n\t\tanimation.start();\n\n\t\tscope.isPresenting = true;\n\n\t\tscope.dispatchEvent( { type: 'sessionstart' } );\n\n\t}\n\n\tthis.setFramebufferScaleFactor = function ( value ) {\n\n\t\tframebufferScaleFactor = value;\n\n\t\tif ( scope.isPresenting === true ) {\n\n\t\t\tconsole.warn( 'THREE.WebXRManager: Cannot change framebuffer scale while presenting.' );\n\n\t\t}\n\n\t};\n\n\tthis.setReferenceSpaceType = function ( value ) {\n\n\t\treferenceSpaceType = value;\n\n\t\tif ( scope.isPresenting === true ) {\n\n\t\t\tconsole.warn( 'THREE.WebXRManager: Cannot change reference space type while presenting.' );\n\n\t\t}\n\n\t};\n\n\tthis.getReferenceSpace = function () {\n\n\t\treturn referenceSpace;\n\n\t};\n\n\tthis.getSession = function () {\n\n\t\treturn session;\n\n\t};\n\n\tthis.setSession = function ( value ) {\n\n\t\tsession = value;\n\n\t\tif ( session !== null ) {\n\n\t\t\tsession.addEventListener( 'select', onSessionEvent );\n\t\t\tsession.addEventListener( 'selectstart', onSessionEvent );\n\t\t\tsession.addEventListener( 'selectend', onSessionEvent );\n\t\t\tsession.addEventListener( 'squeeze', onSessionEvent );\n\t\t\tsession.addEventListener( 'squeezestart', onSessionEvent );\n\t\t\tsession.addEventListener( 'squeezeend', onSessionEvent );\n\t\t\tsession.addEventListener( 'end', onSessionEnd );\n\n\t\t\tconst attributes = gl.getContextAttributes();\n\n\t\t\tif ( attributes.xrCompatible !== true ) {\n\n\t\t\t\tgl.makeXRCompatible();\n\n\t\t\t}\n\n\t\t\tconst layerInit = {\n\t\t\t\tantialias: attributes.antialias,\n\t\t\t\talpha: attributes.alpha,\n\t\t\t\tdepth: attributes.depth,\n\t\t\t\tstencil: attributes.stencil,\n\t\t\t\tframebufferScaleFactor: framebufferScaleFactor\n\t\t\t};\n\n\t\t\t// eslint-disable-next-line no-undef\n\t\t\tconst baseLayer = new XRWebGLLayer( session, gl, layerInit );\n\n\t\t\tsession.updateRenderState( { baseLayer: baseLayer } );\n\n\t\t\tsession.requestReferenceSpace( referenceSpaceType ).then( onRequestReferenceSpace );\n\n\t\t\t//\n\n\t\t\tsession.addEventListener( 'inputsourceschange', updateInputSources );\n\n\t\t}\n\n\t};\n\n\tfunction updateInputSources( event ) {\n\n\t\tconst inputSources = session.inputSources;\n\n\t\t// Assign inputSources to available controllers\n\n\t\tfor ( let i = 0; i < controllers.length; i ++ ) {\n\n\t\t\tinputSourcesMap.set( inputSources[ i ], controllers[ i ] );\n\n\t\t}\n\n\t\t// Notify disconnected\n\n\t\tfor ( let i = 0; i < event.removed.length; i ++ ) {\n\n\t\t\tconst inputSource = event.removed[ i ];\n\t\t\tconst controller = inputSourcesMap.get( inputSource );\n\n\t\t\tif ( controller ) {\n\n\t\t\t\tcontroller.dispatchEvent( { type: 'disconnected', data: inputSource } );\n\t\t\t\tinputSourcesMap.delete( inputSource );\n\n\t\t\t}\n\n\t\t}\n\n\t\t// Notify connected\n\n\t\tfor ( let i = 0; i < event.added.length; i ++ ) {\n\n\t\t\tconst inputSource = event.added[ i ];\n\t\t\tconst controller = inputSourcesMap.get( inputSource );\n\n\t\t\tif ( controller ) {\n\n\t\t\t\tcontroller.dispatchEvent( { type: 'connected', data: inputSource } );\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\t//\n\n\tconst cameraLPos = new Vector3();\n\tconst cameraRPos = new Vector3();\n\n\t/**\n\t * @author jsantell / https://www.jsantell.com/\n\t *\n\t * Assumes 2 cameras that are parallel and share an X-axis, and that\n\t * the cameras' projection and world matrices have already been set.\n\t * And that near and far planes are identical for both cameras.\n\t * Visualization of this technique: https://computergraphics.stackexchange.com/a/4765\n\t */\n\tfunction setProjectionFromUnion( camera, cameraL, cameraR ) {\n\n\t\tcameraLPos.setFromMatrixPosition( cameraL.matrixWorld );\n\t\tcameraRPos.setFromMatrixPosition( cameraR.matrixWorld );\n\n\t\tconst ipd = cameraLPos.distanceTo( cameraRPos );\n\n\t\tconst projL = cameraL.projectionMatrix.elements;\n\t\tconst projR = cameraR.projectionMatrix.elements;\n\n\t\t// VR systems will have identical far and near planes, and\n\t\t// most likely identical top and bottom frustum extents.\n\t\t// Use the left camera for these values.\n\t\tconst near = projL[ 14 ] / ( projL[ 10 ] - 1 );\n\t\tconst far = projL[ 14 ] / ( projL[ 10 ] + 1 );\n\t\tconst topFov = ( projL[ 9 ] + 1 ) / projL[ 5 ];\n\t\tconst bottomFov = ( projL[ 9 ] - 1 ) / projL[ 5 ];\n\n\t\tconst leftFov = ( projL[ 8 ] - 1 ) / projL[ 0 ];\n\t\tconst rightFov = ( projR[ 8 ] + 1 ) / projR[ 0 ];\n\t\tconst left = near * leftFov;\n\t\tconst right = near * rightFov;\n\n\t\t// Calculate the new camera's position offset from the\n\t\t// left camera. xOffset should be roughly half `ipd`.\n\t\tconst zOffset = ipd / ( - leftFov + rightFov );\n\t\tconst xOffset = zOffset * - leftFov;\n\n\t\t// TODO: Better way to apply this offset?\n\t\tcameraL.matrixWorld.decompose( camera.position, camera.quaternion, camera.scale );\n\t\tcamera.translateX( xOffset );\n\t\tcamera.translateZ( zOffset );\n\t\tcamera.matrixWorld.compose( camera.position, camera.quaternion, camera.scale );\n\t\tcamera.matrixWorldInverse.getInverse( camera.matrixWorld );\n\n\t\t// Find the union of the frustum values of the cameras and scale\n\t\t// the values so that the near plane's position does not change in world space,\n\t\t// although must now be relative to the new union camera.\n\t\tconst near2 = near + zOffset;\n\t\tconst far2 = far + zOffset;\n\t\tconst left2 = left - xOffset;\n\t\tconst right2 = right + ( ipd - xOffset );\n\t\tconst top2 = topFov * far / far2 * near2;\n\t\tconst bottom2 = bottomFov * far / far2 * near2;\n\n\t\tcamera.projectionMatrix.makePerspective( left2, right2, top2, bottom2, near2, far2 );\n\n\t}\n\n\tfunction updateCamera( camera, parent ) {\n\n\t\tif ( parent === null ) {\n\n\t\t\tcamera.matrixWorld.copy( camera.matrix );\n\n\t\t} else {\n\n\t\t\tcamera.matrixWorld.multiplyMatrices( parent.matrixWorld, camera.matrix );\n\n\t\t}\n\n\t\tcamera.matrixWorldInverse.getInverse( camera.matrixWorld );\n\n\t}\n\n\tthis.getCamera = function ( camera ) {\n\n\t\tcameraVR.near = cameraR.near = cameraL.near = camera.near;\n\t\tcameraVR.far = cameraR.far = cameraL.far = camera.far;\n\n\t\tif ( _currentDepthNear !== cameraVR.near || _currentDepthFar !== cameraVR.far ) {\n\n\t\t\t// Note that the new renderState won't apply until the next frame. See #18320\n\n\t\t\tsession.updateRenderState( {\n\t\t\t\tdepthNear: cameraVR.near,\n\t\t\t\tdepthFar: cameraVR.far\n\t\t\t} );\n\n\t\t\t_currentDepthNear = cameraVR.near;\n\t\t\t_currentDepthFar = cameraVR.far;\n\n\t\t}\n\n\t\tconst parent = camera.parent;\n\t\tconst cameras = cameraVR.cameras;\n\n\t\tupdateCamera( cameraVR, parent );\n\n\t\tfor ( let i = 0; i < cameras.length; i ++ ) {\n\n\t\t\tupdateCamera( cameras[ i ], parent );\n\n\t\t}\n\n\t\t// update camera and its children\n\n\t\tcamera.matrixWorld.copy( cameraVR.matrixWorld );\n\n\t\tconst children = camera.children;\n\n\t\tfor ( let i = 0, l = children.length; i < l; i ++ ) {\n\n\t\t\tchildren[ i ].updateMatrixWorld( true );\n\n\t\t}\n\n\t\t// update projection matrix for proper view frustum culling\n\n\t\tif ( cameras.length === 2 ) {\n\n\t\t\tsetProjectionFromUnion( cameraVR, cameraL, cameraR );\n\n\t\t} else {\n\n\t\t\t// assume single camera setup (AR)\n\n\t\t\tcameraVR.projectionMatrix.copy( cameraL.projectionMatrix );\n\n\t\t}\n\n\t\treturn cameraVR;\n\n\t};\n\n\t// Animation Loop\n\n\tlet onAnimationFrameCallback = null;\n\n\tfunction onAnimationFrame( time, frame ) {\n\n\t\tpose = frame.getViewerPose( referenceSpace );\n\n\t\tif ( pose !== null ) {\n\n\t\t\tconst views = pose.views;\n\t\t\tconst baseLayer = session.renderState.baseLayer;\n\n\t\t\trenderer.setFramebuffer( baseLayer.framebuffer );\n\n\t\t\tlet cameraVRNeedsUpdate = false;\n\n\t\t\t// check if it's necessary to rebuild cameraVR's camera list\n\n\t\t\tif ( views.length !== cameraVR.cameras.length ) {\n\n\t\t\t\tcameraVR.cameras.length = 0;\n\t\t\t\tcameraVRNeedsUpdate = true;\n\n\t\t\t}\n\n\t\t\tfor ( let i = 0; i < views.length; i ++ ) {\n\n\t\t\t\tconst view = views[ i ];\n\t\t\t\tconst viewport = baseLayer.getViewport( view );\n\n\t\t\t\tconst camera = cameras[ i ];\n\t\t\t\tcamera.matrix.fromArray( view.transform.matrix );\n\t\t\t\tcamera.projectionMatrix.fromArray( view.projectionMatrix );\n\t\t\t\tcamera.viewport.set( viewport.x, viewport.y, viewport.width, viewport.height );\n\n\t\t\t\tif ( i === 0 ) {\n\n\t\t\t\t\tcameraVR.matrix.copy( camera.matrix );\n\n\t\t\t\t}\n\n\t\t\t\tif ( cameraVRNeedsUpdate === true ) {\n\n\t\t\t\t\tcameraVR.cameras.push( camera );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\t//\n\n\t\tconst inputSources = session.inputSources;\n\n\t\tfor ( let i = 0; i < controllers.length; i ++ ) {\n\n\t\t\tconst controller = controllers[ i ];\n\t\t\tconst inputSource = inputSources[ i ];\n\n\t\t\tcontroller.update( inputSource, frame, referenceSpace );\n\n\t\t}\n\n\t\tif ( onAnimationFrameCallback ) onAnimationFrameCallback( time, frame );\n\n\t}\n\n\tconst animation = new WebGLAnimation();\n\tanimation.setAnimationLoop( onAnimationFrame );\n\n\tthis.setAnimationLoop = function ( callback ) {\n\n\t\tonAnimationFrameCallback = callback;\n\n\t};\n\n\tthis.dispose = function () {};\n\n}\n\nObject.assign( WebXRManager.prototype, EventDispatcher.prototype );\n\nexport { WebXRManager };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { BackSide } from \"../../constants.js\";\n\nfunction WebGLMaterials( properties ) {\n\n\tfunction refreshFogUniforms( uniforms, fog ) {\n\n\t\tuniforms.fogColor.value.copy( fog.color );\n\n\t\tif ( fog.isFog ) {\n\n\t\t\tuniforms.fogNear.value = fog.near;\n\t\t\tuniforms.fogFar.value = fog.far;\n\n\t\t} else if ( fog.isFogExp2 ) {\n\n\t\t\tuniforms.fogDensity.value = fog.density;\n\n\t\t}\n\n\t}\n\n\tfunction refreshMaterialUniforms( uniforms, material, environment, pixelRatio, height ) {\n\n\t\tif ( material.isMeshBasicMaterial ) {\n\n\t\t\trefreshUniformsCommon( uniforms, material );\n\n\t\t} else if ( material.isMeshLambertMaterial ) {\n\n\t\t\trefreshUniformsCommon( uniforms, material );\n\t\t\trefreshUniformsLambert( uniforms, material );\n\n\t\t} else if ( material.isMeshToonMaterial ) {\n\n\t\t\trefreshUniformsCommon( uniforms, material );\n\t\t\trefreshUniformsToon( uniforms, material );\n\n\t\t} else if ( material.isMeshPhongMaterial ) {\n\n\t\t\trefreshUniformsCommon( uniforms, material );\n\t\t\trefreshUniformsPhong( uniforms, material );\n\n\t\t} else if ( material.isMeshStandardMaterial ) {\n\n\t\t\trefreshUniformsCommon( uniforms, material, environment );\n\n\t\t\tif ( material.isMeshPhysicalMaterial ) {\n\n\t\t\t\trefreshUniformsPhysical( uniforms, material, environment );\n\n\t\t\t} else {\n\n\t\t\t\trefreshUniformsStandard( uniforms, material, environment );\n\n\t\t\t}\n\n\t\t} else if ( material.isMeshMatcapMaterial ) {\n\n\t\t\trefreshUniformsCommon( uniforms, material );\n\t\t\trefreshUniformsMatcap( uniforms, material );\n\n\t\t} else if ( material.isMeshDepthMaterial ) {\n\n\t\t\trefreshUniformsCommon( uniforms, material );\n\t\t\trefreshUniformsDepth( uniforms, material );\n\n\t\t} else if ( material.isMeshDistanceMaterial ) {\n\n\t\t\trefreshUniformsCommon( uniforms, material );\n\t\t\trefreshUniformsDistance( uniforms, material );\n\n\t\t} else if ( material.isMeshNormalMaterial ) {\n\n\t\t\trefreshUniformsCommon( uniforms, material );\n\t\t\trefreshUniformsNormal( uniforms, material );\n\n\t\t} else if ( material.isLineBasicMaterial ) {\n\n\t\t\trefreshUniformsLine( uniforms, material );\n\n\t\t\tif ( material.isLineDashedMaterial ) {\n\n\t\t\t\trefreshUniformsDash( uniforms, material );\n\n\t\t\t}\n\n\t\t} else if ( material.isPointsMaterial ) {\n\n\t\t\trefreshUniformsPoints( uniforms, material, pixelRatio, height );\n\n\t\t} else if ( material.isSpriteMaterial ) {\n\n\t\t\trefreshUniformsSprites( uniforms, material );\n\n\t\t} else if ( material.isShadowMaterial ) {\n\n\t\t\tuniforms.color.value.copy( material.color );\n\t\t\tuniforms.opacity.value = material.opacity;\n\n\t\t} else if ( material.isShaderMaterial ) {\n\n\t\t\tmaterial.uniformsNeedUpdate = false; // #15581\n\n\t\t}\n\n\t}\n\n\tfunction refreshUniformsCommon( uniforms, material, environment ) {\n\n\t\tuniforms.opacity.value = material.opacity;\n\n\t\tif ( material.color ) {\n\n\t\t\tuniforms.diffuse.value.copy( material.color );\n\n\t\t}\n\n\t\tif ( material.emissive ) {\n\n\t\t\tuniforms.emissive.value.copy( material.emissive ).multiplyScalar( material.emissiveIntensity );\n\n\t\t}\n\n\t\tif ( material.map ) {\n\n\t\t\tuniforms.map.value = material.map;\n\n\t\t}\n\n\t\tif ( material.alphaMap ) {\n\n\t\t\tuniforms.alphaMap.value = material.alphaMap;\n\n\t\t}\n\n\t\tif ( material.specularMap ) {\n\n\t\t\tuniforms.specularMap.value = material.specularMap;\n\n\t\t}\n\n\t\tconst envMap = material.envMap || environment;\n\n\t\tif ( envMap ) {\n\n\t\t\tuniforms.envMap.value = envMap;\n\n\t\t\tuniforms.flipEnvMap.value = envMap.isCubeTexture ? - 1 : 1;\n\n\t\t\tuniforms.reflectivity.value = material.reflectivity;\n\t\t\tuniforms.refractionRatio.value = material.refractionRatio;\n\n\t\t\tuniforms.maxMipLevel.value = properties.get( envMap ).__maxMipLevel;\n\n\t\t}\n\n\t\tif ( material.lightMap ) {\n\n\t\t\tuniforms.lightMap.value = material.lightMap;\n\t\t\tuniforms.lightMapIntensity.value = material.lightMapIntensity;\n\n\t\t}\n\n\t\tif ( material.aoMap ) {\n\n\t\t\tuniforms.aoMap.value = material.aoMap;\n\t\t\tuniforms.aoMapIntensity.value = material.aoMapIntensity;\n\n\t\t}\n\n\t\t// uv repeat and offset setting priorities\n\t\t// 1. color map\n\t\t// 2. specular map\n\t\t// 3. normal map\n\t\t// 4. bump map\n\t\t// 5. alpha map\n\t\t// 6. emissive map\n\n\t\tlet uvScaleMap;\n\n\t\tif ( material.map ) {\n\n\t\t\tuvScaleMap = material.map;\n\n\t\t} else if ( material.specularMap ) {\n\n\t\t\tuvScaleMap = material.specularMap;\n\n\t\t} else if ( material.displacementMap ) {\n\n\t\t\tuvScaleMap = material.displacementMap;\n\n\t\t} else if ( material.normalMap ) {\n\n\t\t\tuvScaleMap = material.normalMap;\n\n\t\t} else if ( material.bumpMap ) {\n\n\t\t\tuvScaleMap = material.bumpMap;\n\n\t\t} else if ( material.roughnessMap ) {\n\n\t\t\tuvScaleMap = material.roughnessMap;\n\n\t\t} else if ( material.metalnessMap ) {\n\n\t\t\tuvScaleMap = material.metalnessMap;\n\n\t\t} else if ( material.alphaMap ) {\n\n\t\t\tuvScaleMap = material.alphaMap;\n\n\t\t} else if ( material.emissiveMap ) {\n\n\t\t\tuvScaleMap = material.emissiveMap;\n\n\t\t}\n\n\t\tif ( uvScaleMap !== undefined ) {\n\n\t\t\t// backwards compatibility\n\t\t\tif ( uvScaleMap.isWebGLRenderTarget ) {\n\n\t\t\t\tuvScaleMap = uvScaleMap.texture;\n\n\t\t\t}\n\n\t\t\tif ( uvScaleMap.matrixAutoUpdate === true ) {\n\n\t\t\t\tuvScaleMap.updateMatrix();\n\n\t\t\t}\n\n\t\t\tuniforms.uvTransform.value.copy( uvScaleMap.matrix );\n\n\t\t}\n\n\t\t// uv repeat and offset setting priorities for uv2\n\t\t// 1. ao map\n\t\t// 2. light map\n\n\t\tlet uv2ScaleMap;\n\n\t\tif ( material.aoMap ) {\n\n\t\t\tuv2ScaleMap = material.aoMap;\n\n\t\t} else if ( material.lightMap ) {\n\n\t\t\tuv2ScaleMap = material.lightMap;\n\n\t\t}\n\n\t\tif ( uv2ScaleMap !== undefined ) {\n\n\t\t\t// backwards compatibility\n\t\t\tif ( uv2ScaleMap.isWebGLRenderTarget ) {\n\n\t\t\t\tuv2ScaleMap = uv2ScaleMap.texture;\n\n\t\t\t}\n\n\t\t\tif ( uv2ScaleMap.matrixAutoUpdate === true ) {\n\n\t\t\t\tuv2ScaleMap.updateMatrix();\n\n\t\t\t}\n\n\t\t\tuniforms.uv2Transform.value.copy( uv2ScaleMap.matrix );\n\n\t\t}\n\n\t}\n\n\tfunction refreshUniformsLine( uniforms, material ) {\n\n\t\tuniforms.diffuse.value.copy( material.color );\n\t\tuniforms.opacity.value = material.opacity;\n\n\t}\n\n\tfunction refreshUniformsDash( uniforms, material ) {\n\n\t\tuniforms.dashSize.value = material.dashSize;\n\t\tuniforms.totalSize.value = material.dashSize + material.gapSize;\n\t\tuniforms.scale.value = material.scale;\n\n\t}\n\n\tfunction refreshUniformsPoints( uniforms, material, pixelRatio, height ) {\n\n\t\tuniforms.diffuse.value.copy( material.color );\n\t\tuniforms.opacity.value = material.opacity;\n\t\tuniforms.size.value = material.size * pixelRatio;\n\t\tuniforms.scale.value = height * 0.5;\n\n\t\tif ( material.map ) {\n\n\t\t\tuniforms.map.value = material.map;\n\n\t\t}\n\n\t\tif ( material.alphaMap ) {\n\n\t\t\tuniforms.alphaMap.value = material.alphaMap;\n\n\t\t}\n\n\t\t// uv repeat and offset setting priorities\n\t\t// 1. color map\n\t\t// 2. alpha map\n\n\t\tlet uvScaleMap;\n\n\t\tif ( material.map ) {\n\n\t\t\tuvScaleMap = material.map;\n\n\t\t} else if ( material.alphaMap ) {\n\n\t\t\tuvScaleMap = material.alphaMap;\n\n\t\t}\n\n\t\tif ( uvScaleMap !== undefined ) {\n\n\t\t\tif ( uvScaleMap.matrixAutoUpdate === true ) {\n\n\t\t\t\tuvScaleMap.updateMatrix();\n\n\t\t\t}\n\n\t\t\tuniforms.uvTransform.value.copy( uvScaleMap.matrix );\n\n\t\t}\n\n\t}\n\n\tfunction refreshUniformsSprites( uniforms, material ) {\n\n\t\tuniforms.diffuse.value.copy( material.color );\n\t\tuniforms.opacity.value = material.opacity;\n\t\tuniforms.rotation.value = material.rotation;\n\n\t\tif ( material.map ) {\n\n\t\t\tuniforms.map.value = material.map;\n\n\t\t}\n\n\t\tif ( material.alphaMap ) {\n\n\t\t\tuniforms.alphaMap.value = material.alphaMap;\n\n\t\t}\n\n\t\t// uv repeat and offset setting priorities\n\t\t// 1. color map\n\t\t// 2. alpha map\n\n\t\tlet uvScaleMap;\n\n\t\tif ( material.map ) {\n\n\t\t\tuvScaleMap = material.map;\n\n\t\t} else if ( material.alphaMap ) {\n\n\t\t\tuvScaleMap = material.alphaMap;\n\n\t\t}\n\n\t\tif ( uvScaleMap !== undefined ) {\n\n\t\t\tif ( uvScaleMap.matrixAutoUpdate === true ) {\n\n\t\t\t\tuvScaleMap.updateMatrix();\n\n\t\t\t}\n\n\t\t\tuniforms.uvTransform.value.copy( uvScaleMap.matrix );\n\n\t\t}\n\n\t}\n\n\tfunction refreshUniformsLambert( uniforms, material ) {\n\n\t\tif ( material.emissiveMap ) {\n\n\t\t\tuniforms.emissiveMap.value = material.emissiveMap;\n\n\t\t}\n\n\t}\n\n\tfunction refreshUniformsPhong( uniforms, material ) {\n\n\t\tuniforms.specular.value.copy( material.specular );\n\t\tuniforms.shininess.value = Math.max( material.shininess, 1e-4 ); // to prevent pow( 0.0, 0.0 )\n\n\t\tif ( material.emissiveMap ) {\n\n\t\t\tuniforms.emissiveMap.value = material.emissiveMap;\n\n\t\t}\n\n\t\tif ( material.bumpMap ) {\n\n\t\t\tuniforms.bumpMap.value = material.bumpMap;\n\t\t\tuniforms.bumpScale.value = material.bumpScale;\n\t\t\tif ( material.side === BackSide ) uniforms.bumpScale.value *= - 1;\n\n\t\t}\n\n\t\tif ( material.normalMap ) {\n\n\t\t\tuniforms.normalMap.value = material.normalMap;\n\t\t\tuniforms.normalScale.value.copy( material.normalScale );\n\t\t\tif ( material.side === BackSide ) uniforms.normalScale.value.negate();\n\n\t\t}\n\n\t\tif ( material.displacementMap ) {\n\n\t\t\tuniforms.displacementMap.value = material.displacementMap;\n\t\t\tuniforms.displacementScale.value = material.displacementScale;\n\t\t\tuniforms.displacementBias.value = material.displacementBias;\n\n\t\t}\n\n\t}\n\n\tfunction refreshUniformsToon( uniforms, material ) {\n\n\t\tif ( material.gradientMap ) {\n\n\t\t\tuniforms.gradientMap.value = material.gradientMap;\n\n\t\t}\n\n\t\tif ( material.emissiveMap ) {\n\n\t\t\tuniforms.emissiveMap.value = material.emissiveMap;\n\n\t\t}\n\n\t\tif ( material.bumpMap ) {\n\n\t\t\tuniforms.bumpMap.value = material.bumpMap;\n\t\t\tuniforms.bumpScale.value = material.bumpScale;\n\t\t\tif ( material.side === BackSide ) uniforms.bumpScale.value *= - 1;\n\n\t\t}\n\n\t\tif ( material.normalMap ) {\n\n\t\t\tuniforms.normalMap.value = material.normalMap;\n\t\t\tuniforms.normalScale.value.copy( material.normalScale );\n\t\t\tif ( material.side === BackSide ) uniforms.normalScale.value.negate();\n\n\t\t}\n\n\t\tif ( material.displacementMap ) {\n\n\t\t\tuniforms.displacementMap.value = material.displacementMap;\n\t\t\tuniforms.displacementScale.value = material.displacementScale;\n\t\t\tuniforms.displacementBias.value = material.displacementBias;\n\n\t\t}\n\n\t}\n\n\tfunction refreshUniformsStandard( uniforms, material, environment ) {\n\n\t\tuniforms.roughness.value = material.roughness;\n\t\tuniforms.metalness.value = material.metalness;\n\n\t\tif ( material.roughnessMap ) {\n\n\t\t\tuniforms.roughnessMap.value = material.roughnessMap;\n\n\t\t}\n\n\t\tif ( material.metalnessMap ) {\n\n\t\t\tuniforms.metalnessMap.value = material.metalnessMap;\n\n\t\t}\n\n\t\tif ( material.emissiveMap ) {\n\n\t\t\tuniforms.emissiveMap.value = material.emissiveMap;\n\n\t\t}\n\n\t\tif ( material.bumpMap ) {\n\n\t\t\tuniforms.bumpMap.value = material.bumpMap;\n\t\t\tuniforms.bumpScale.value = material.bumpScale;\n\t\t\tif ( material.side === BackSide ) uniforms.bumpScale.value *= - 1;\n\n\t\t}\n\n\t\tif ( material.normalMap ) {\n\n\t\t\tuniforms.normalMap.value = material.normalMap;\n\t\t\tuniforms.normalScale.value.copy( material.normalScale );\n\t\t\tif ( material.side === BackSide ) uniforms.normalScale.value.negate();\n\n\t\t}\n\n\t\tif ( material.displacementMap ) {\n\n\t\t\tuniforms.displacementMap.value = material.displacementMap;\n\t\t\tuniforms.displacementScale.value = material.displacementScale;\n\t\t\tuniforms.displacementBias.value = material.displacementBias;\n\n\t\t}\n\n\t\tif ( material.envMap || environment ) {\n\n\t\t\t//uniforms.envMap.value = material.envMap; // part of uniforms common\n\t\t\tuniforms.envMapIntensity.value = material.envMapIntensity;\n\n\t\t}\n\n\t}\n\n\tfunction refreshUniformsPhysical( uniforms, material, environment ) {\n\n\t\trefreshUniformsStandard( uniforms, material, environment );\n\n\t\tuniforms.reflectivity.value = material.reflectivity; // also part of uniforms common\n\n\t\tuniforms.clearcoat.value = material.clearcoat;\n\t\tuniforms.clearcoatRoughness.value = material.clearcoatRoughness;\n\t\tif ( material.sheen ) uniforms.sheen.value.copy( material.sheen );\n\n\t\tif ( material.clearcoatMap ) {\n\n\t\t\tuniforms.clearcoatMap.value = material.clearcoatMap;\n\n\t\t}\n\n\t\tif ( material.clearcoatRoughnessMap ) {\n\n\t\t\tuniforms.clearcoatRoughnessMap.value = material.clearcoatRoughnessMap;\n\n\t\t}\n\n\t\tif ( material.clearcoatNormalMap ) {\n\n\t\t\tuniforms.clearcoatNormalScale.value.copy( material.clearcoatNormalScale );\n\t\t\tuniforms.clearcoatNormalMap.value = material.clearcoatNormalMap;\n\n\t\t\tif ( material.side === BackSide ) {\n\n\t\t\t\tuniforms.clearcoatNormalScale.value.negate();\n\n\t\t\t}\n\n\t\t}\n\n\t\tuniforms.transparency.value = material.transparency;\n\n\t}\n\n\tfunction refreshUniformsMatcap( uniforms, material ) {\n\n\t\tif ( material.matcap ) {\n\n\t\t\tuniforms.matcap.value = material.matcap;\n\n\t\t}\n\n\t\tif ( material.bumpMap ) {\n\n\t\t\tuniforms.bumpMap.value = material.bumpMap;\n\t\t\tuniforms.bumpScale.value = material.bumpScale;\n\t\t\tif ( material.side === BackSide ) uniforms.bumpScale.value *= - 1;\n\n\t\t}\n\n\t\tif ( material.normalMap ) {\n\n\t\t\tuniforms.normalMap.value = material.normalMap;\n\t\t\tuniforms.normalScale.value.copy( material.normalScale );\n\t\t\tif ( material.side === BackSide ) uniforms.normalScale.value.negate();\n\n\t\t}\n\n\t\tif ( material.displacementMap ) {\n\n\t\t\tuniforms.displacementMap.value = material.displacementMap;\n\t\t\tuniforms.displacementScale.value = material.displacementScale;\n\t\t\tuniforms.displacementBias.value = material.displacementBias;\n\n\t\t}\n\n\t}\n\n\tfunction refreshUniformsDepth( uniforms, material ) {\n\n\t\tif ( material.displacementMap ) {\n\n\t\t\tuniforms.displacementMap.value = material.displacementMap;\n\t\t\tuniforms.displacementScale.value = material.displacementScale;\n\t\t\tuniforms.displacementBias.value = material.displacementBias;\n\n\t\t}\n\n\t}\n\n\tfunction refreshUniformsDistance( uniforms, material ) {\n\n\t\tif ( material.displacementMap ) {\n\n\t\t\tuniforms.displacementMap.value = material.displacementMap;\n\t\t\tuniforms.displacementScale.value = material.displacementScale;\n\t\t\tuniforms.displacementBias.value = material.displacementBias;\n\n\t\t}\n\n\t\tuniforms.referencePosition.value.copy( material.referencePosition );\n\t\tuniforms.nearDistance.value = material.nearDistance;\n\t\tuniforms.farDistance.value = material.farDistance;\n\n\t}\n\n\tfunction refreshUniformsNormal( uniforms, material ) {\n\n\t\tif ( material.bumpMap ) {\n\n\t\t\tuniforms.bumpMap.value = material.bumpMap;\n\t\t\tuniforms.bumpScale.value = material.bumpScale;\n\t\t\tif ( material.side === BackSide ) uniforms.bumpScale.value *= - 1;\n\n\t\t}\n\n\t\tif ( material.normalMap ) {\n\n\t\t\tuniforms.normalMap.value = material.normalMap;\n\t\t\tuniforms.normalScale.value.copy( material.normalScale );\n\t\t\tif ( material.side === BackSide ) uniforms.normalScale.value.negate();\n\n\t\t}\n\n\t\tif ( material.displacementMap ) {\n\n\t\t\tuniforms.displacementMap.value = material.displacementMap;\n\t\t\tuniforms.displacementScale.value = material.displacementScale;\n\t\t\tuniforms.displacementBias.value = material.displacementBias;\n\n\t\t}\n\n\t}\n\n\treturn {\n\t\trefreshFogUniforms: refreshFogUniforms,\n\t\trefreshMaterialUniforms: refreshMaterialUniforms\n\t};\n\n}\n\nexport { WebGLMaterials };\n","/**\n * @author supereggbert / http://www.paulbrunt.co.uk/\n * @author mrdoob / http://mrdoob.com/\n * @author alteredq / http://alteredqualia.com/\n * @author szimek / https://github.com/szimek/\n * @author tschw\n */\n\nimport {\n\tRGBAFormat,\n\tHalfFloatType,\n\tFloatType,\n\tUnsignedByteType,\n\tLinearEncoding,\n\tNoToneMapping\n} from '../constants.js';\nimport { MathUtils } from '../math/MathUtils.js';\nimport { DataTexture } from '../textures/DataTexture.js';\nimport { Frustum } from '../math/Frustum.js';\nimport { Matrix4 } from '../math/Matrix4.js';\nimport { UniformsLib } from './shaders/UniformsLib.js';\nimport { Vector2 } from '../math/Vector2.js';\nimport { Vector3 } from '../math/Vector3.js';\nimport { Vector4 } from '../math/Vector4.js';\nimport { WebGLAnimation } from './webgl/WebGLAnimation.js';\nimport { WebGLAttributes } from './webgl/WebGLAttributes.js';\nimport { WebGLBackground } from './webgl/WebGLBackground.js';\nimport { WebGLBindingStates } from './webgl/WebGLBindingStates.js';\nimport { WebGLBufferRenderer } from './webgl/WebGLBufferRenderer.js';\nimport { WebGLCapabilities } from './webgl/WebGLCapabilities.js';\nimport { WebGLClipping } from './webgl/WebGLClipping.js';\nimport { WebGLExtensions } from './webgl/WebGLExtensions.js';\nimport { WebGLGeometries } from './webgl/WebGLGeometries.js';\nimport { WebGLIndexedBufferRenderer } from './webgl/WebGLIndexedBufferRenderer.js';\nimport { WebGLInfo } from './webgl/WebGLInfo.js';\nimport { WebGLMorphtargets } from './webgl/WebGLMorphtargets.js';\nimport { WebGLObjects } from './webgl/WebGLObjects.js';\nimport { WebGLPrograms } from './webgl/WebGLPrograms.js';\nimport { WebGLProperties } from './webgl/WebGLProperties.js';\nimport { WebGLRenderLists } from './webgl/WebGLRenderLists.js';\nimport { WebGLRenderStates } from './webgl/WebGLRenderStates.js';\nimport { WebGLShadowMap } from './webgl/WebGLShadowMap.js';\nimport { WebGLState } from './webgl/WebGLState.js';\nimport { WebGLTextures } from './webgl/WebGLTextures.js';\nimport { WebGLUniforms } from './webgl/WebGLUniforms.js';\nimport { WebGLUtils } from './webgl/WebGLUtils.js';\nimport { WebXRManager } from './webxr/WebXRManager.js';\nimport { WebGLMaterials } from \"./webgl/WebGLMaterials.js\";\n\nfunction WebGLRenderer( parameters ) {\n\n\tparameters = parameters || {};\n\n\tconst _canvas = parameters.canvas !== undefined ? parameters.canvas : document.createElementNS( 'http://www.w3.org/1999/xhtml', 'canvas' ),\n\t\t_context = parameters.context !== undefined ? parameters.context : null,\n\n\t\t_alpha = parameters.alpha !== undefined ? parameters.alpha : false,\n\t\t_depth = parameters.depth !== undefined ? parameters.depth : true,\n\t\t_stencil = parameters.stencil !== undefined ? parameters.stencil : true,\n\t\t_antialias = parameters.antialias !== undefined ? parameters.antialias : false,\n\t\t_premultipliedAlpha = parameters.premultipliedAlpha !== undefined ? parameters.premultipliedAlpha : true,\n\t\t_preserveDrawingBuffer = parameters.preserveDrawingBuffer !== undefined ? parameters.preserveDrawingBuffer : false,\n\t\t_powerPreference = parameters.powerPreference !== undefined ? parameters.powerPreference : 'default',\n\t\t_failIfMajorPerformanceCaveat = parameters.failIfMajorPerformanceCaveat !== undefined ? parameters.failIfMajorPerformanceCaveat : false;\n\n\tlet currentRenderList = null;\n\tlet currentRenderState = null;\n\n\t// public properties\n\n\tthis.domElement = _canvas;\n\n\t// Debug configuration container\n\tthis.debug = {\n\n\t\t/**\n\t\t * Enables error checking and reporting when shader programs are being compiled\n\t\t * @type {boolean}\n\t\t */\n\t\tcheckShaderErrors: true\n\t};\n\n\t// clearing\n\n\tthis.autoClear = true;\n\tthis.autoClearColor = true;\n\tthis.autoClearDepth = true;\n\tthis.autoClearStencil = true;\n\n\t// scene graph\n\n\tthis.sortObjects = true;\n\n\t// user-defined clipping\n\n\tthis.clippingPlanes = [];\n\tthis.localClippingEnabled = false;\n\n\t// physically based shading\n\n\tthis.gammaFactor = 2.0;\t// for backwards compatibility\n\tthis.outputEncoding = LinearEncoding;\n\n\t// physical lights\n\n\tthis.physicallyCorrectLights = false;\n\n\t// tone mapping\n\n\tthis.toneMapping = NoToneMapping;\n\tthis.toneMappingExposure = 1.0;\n\n\t// morphs\n\n\tthis.maxMorphTargets = 8;\n\tthis.maxMorphNormals = 4;\n\n\t// internal properties\n\n\tconst _this = this;\n\n\tlet _isContextLost = false;\n\n\t// internal state cache\n\n\tlet _framebuffer = null;\n\n\tlet _currentActiveCubeFace = 0;\n\tlet _currentActiveMipmapLevel = 0;\n\tlet _currentRenderTarget = null;\n\tlet _currentFramebuffer = null;\n\tlet _currentMaterialId = - 1;\n\n\tlet _currentCamera = null;\n\tlet _currentArrayCamera = null;\n\n\tconst _currentViewport = new Vector4();\n\tconst _currentScissor = new Vector4();\n\tlet _currentScissorTest = null;\n\n\t//\n\n\tlet _width = _canvas.width;\n\tlet _height = _canvas.height;\n\n\tlet _pixelRatio = 1;\n\tlet _opaqueSort = null;\n\tlet _transparentSort = null;\n\n\tconst _viewport = new Vector4( 0, 0, _width, _height );\n\tconst _scissor = new Vector4( 0, 0, _width, _height );\n\tlet _scissorTest = false;\n\n\t// frustum\n\n\tconst _frustum = new Frustum();\n\n\t// clipping\n\n\tconst _clipping = new WebGLClipping();\n\tlet _clippingEnabled = false;\n\tlet _localClippingEnabled = false;\n\n\t// camera matrices cache\n\n\tconst _projScreenMatrix = new Matrix4();\n\n\tconst _vector3 = new Vector3();\n\n\tconst _emptyScene = { background: null, fog: null, environment: null, overrideMaterial: null, isScene: true };\n\n\tfunction getTargetPixelRatio() {\n\n\t\treturn _currentRenderTarget === null ? _pixelRatio : 1;\n\n\t}\n\n\t// initialize\n\n\tlet _gl = _context;\n\n\tfunction getContext( contextNames, contextAttributes ) {\n\n\t\tfor ( let i = 0; i < contextNames.length; i ++ ) {\n\n\t\t\tconst contextName = contextNames[ i ];\n\t\t\tconst context = _canvas.getContext( contextName, contextAttributes );\n\t\t\tif ( context !== null ) return context;\n\n\t\t}\n\n\t\treturn null;\n\n\t}\n\n\ttry {\n\n\t\tconst contextAttributes = {\n\t\t\talpha: _alpha,\n\t\t\tdepth: _depth,\n\t\t\tstencil: _stencil,\n\t\t\tantialias: _antialias,\n\t\t\tpremultipliedAlpha: _premultipliedAlpha,\n\t\t\tpreserveDrawingBuffer: _preserveDrawingBuffer,\n\t\t\tpowerPreference: _powerPreference,\n\t\t\tfailIfMajorPerformanceCaveat: _failIfMajorPerformanceCaveat\n\t\t};\n\n\t\t// event listeners must be registered before WebGL context is created, see #12753\n\n\t\t_canvas.addEventListener( 'webglcontextlost', onContextLost, false );\n\t\t_canvas.addEventListener( 'webglcontextrestored', onContextRestore, false );\n\n\t\tif ( _gl === null ) {\n\n\t\t\tconst contextNames = [ 'webgl2', 'webgl', 'experimental-webgl' ];\n\n\t\t\tif ( _this.isWebGL1Renderer === true ) {\n\n\t\t\t\tcontextNames.shift();\n\n\t\t\t}\n\n\t\t\t_gl = getContext( contextNames, contextAttributes );\n\n\t\t\tif ( _gl === null ) {\n\n\t\t\t\tif ( getContext( contextNames ) ) {\n\n\t\t\t\t\tthrow new Error( 'Error creating WebGL context with your selected attributes.' );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tthrow new Error( 'Error creating WebGL context.' );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\t// Some experimental-webgl implementations do not have getShaderPrecisionFormat\n\n\t\tif ( _gl.getShaderPrecisionFormat === undefined ) {\n\n\t\t\t_gl.getShaderPrecisionFormat = function () {\n\n\t\t\t\treturn { 'rangeMin': 1, 'rangeMax': 1, 'precision': 1 };\n\n\t\t\t};\n\n\t\t}\n\n\t} catch ( error ) {\n\n\t\tconsole.error( 'THREE.WebGLRenderer: ' + error.message );\n\t\tthrow error;\n\n\t}\n\n\tlet extensions, capabilities, state, info;\n\tlet properties, textures, attributes, geometries, objects;\n\tlet programCache, materials, renderLists, renderStates;\n\n\tlet background, morphtargets, bufferRenderer, indexedBufferRenderer;\n\n\tlet utils, bindingStates;\n\n\tfunction initGLContext() {\n\n\t\textensions = new WebGLExtensions( _gl );\n\n\t\tcapabilities = new WebGLCapabilities( _gl, extensions, parameters );\n\n\t\tif ( capabilities.isWebGL2 === false ) {\n\n\t\t\textensions.get( 'WEBGL_depth_texture' );\n\t\t\textensions.get( 'OES_texture_float' );\n\t\t\textensions.get( 'OES_texture_half_float' );\n\t\t\textensions.get( 'OES_texture_half_float_linear' );\n\t\t\textensions.get( 'OES_standard_derivatives' );\n\t\t\textensions.get( 'OES_element_index_uint' );\n\t\t\textensions.get( 'OES_vertex_array_object' );\n\t\t\textensions.get( 'ANGLE_instanced_arrays' );\n\n\t\t}\n\n\t\textensions.get( 'OES_texture_float_linear' );\n\n\t\tutils = new WebGLUtils( _gl, extensions, capabilities );\n\n\t\tstate = new WebGLState( _gl, extensions, capabilities );\n\t\tstate.scissor( _currentScissor.copy( _scissor ).multiplyScalar( _pixelRatio ).floor() );\n\t\tstate.viewport( _currentViewport.copy( _viewport ).multiplyScalar( _pixelRatio ).floor() );\n\n\t\tinfo = new WebGLInfo( _gl );\n\t\tproperties = new WebGLProperties();\n\t\ttextures = new WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info );\n\t\tattributes = new WebGLAttributes( _gl, capabilities );\n\t\tbindingStates = new WebGLBindingStates( _gl, extensions, attributes, capabilities );\n\t\tgeometries = new WebGLGeometries( _gl, attributes, info, bindingStates );\n\t\tobjects = new WebGLObjects( _gl, geometries, attributes, info );\n\t\tmorphtargets = new WebGLMorphtargets( _gl );\n\t\tprogramCache = new WebGLPrograms( _this, extensions, capabilities, bindingStates );\n\t\tmaterials = new WebGLMaterials( properties );\n\t\trenderLists = new WebGLRenderLists();\n\t\trenderStates = new WebGLRenderStates();\n\n\t\tbackground = new WebGLBackground( _this, state, objects, _premultipliedAlpha );\n\n\t\tbufferRenderer = new WebGLBufferRenderer( _gl, extensions, info, capabilities );\n\t\tindexedBufferRenderer = new WebGLIndexedBufferRenderer( _gl, extensions, info, capabilities );\n\n\t\tinfo.programs = programCache.programs;\n\n\t\t_this.capabilities = capabilities;\n\t\t_this.extensions = extensions;\n\t\t_this.properties = properties;\n\t\t_this.renderLists = renderLists;\n\t\t_this.state = state;\n\t\t_this.info = info;\n\n\t}\n\n\tinitGLContext();\n\n\t// xr\n\n\tconst xr = new WebXRManager( _this, _gl );\n\n\tthis.xr = xr;\n\n\t// shadow map\n\n\tconst shadowMap = new WebGLShadowMap( _this, objects, capabilities.maxTextureSize );\n\n\tthis.shadowMap = shadowMap;\n\n\t// API\n\n\tthis.getContext = function () {\n\n\t\treturn _gl;\n\n\t};\n\n\tthis.getContextAttributes = function () {\n\n\t\treturn _gl.getContextAttributes();\n\n\t};\n\n\tthis.forceContextLoss = function () {\n\n\t\tconst extension = extensions.get( 'WEBGL_lose_context' );\n\t\tif ( extension ) extension.loseContext();\n\n\t};\n\n\tthis.forceContextRestore = function () {\n\n\t\tconst extension = extensions.get( 'WEBGL_lose_context' );\n\t\tif ( extension ) extension.restoreContext();\n\n\t};\n\n\tthis.getPixelRatio = function () {\n\n\t\treturn _pixelRatio;\n\n\t};\n\n\tthis.setPixelRatio = function ( value ) {\n\n\t\tif ( value === undefined ) return;\n\n\t\t_pixelRatio = value;\n\n\t\tthis.setSize( _width, _height, false );\n\n\t};\n\n\tthis.getSize = function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'WebGLRenderer: .getsize() now requires a Vector2 as an argument' );\n\n\t\t\ttarget = new Vector2();\n\n\t\t}\n\n\t\treturn target.set( _width, _height );\n\n\t};\n\n\tthis.setSize = function ( width, height, updateStyle ) {\n\n\t\tif ( xr.isPresenting ) {\n\n\t\t\tconsole.warn( 'THREE.WebGLRenderer: Can\\'t change size while VR device is presenting.' );\n\t\t\treturn;\n\n\t\t}\n\n\t\t_width = width;\n\t\t_height = height;\n\n\t\t_canvas.width = Math.floor( width * _pixelRatio );\n\t\t_canvas.height = Math.floor( height * _pixelRatio );\n\n\t\tif ( updateStyle !== false ) {\n\n\t\t\t_canvas.style.width = width + 'px';\n\t\t\t_canvas.style.height = height + 'px';\n\n\t\t}\n\n\t\tthis.setViewport( 0, 0, width, height );\n\n\t};\n\n\tthis.getDrawingBufferSize = function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'WebGLRenderer: .getdrawingBufferSize() now requires a Vector2 as an argument' );\n\n\t\t\ttarget = new Vector2();\n\n\t\t}\n\n\t\treturn target.set( _width * _pixelRatio, _height * _pixelRatio ).floor();\n\n\t};\n\n\tthis.setDrawingBufferSize = function ( width, height, pixelRatio ) {\n\n\t\t_width = width;\n\t\t_height = height;\n\n\t\t_pixelRatio = pixelRatio;\n\n\t\t_canvas.width = Math.floor( width * pixelRatio );\n\t\t_canvas.height = Math.floor( height * pixelRatio );\n\n\t\tthis.setViewport( 0, 0, width, height );\n\n\t};\n\n\tthis.getCurrentViewport = function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'WebGLRenderer: .getCurrentViewport() now requires a Vector4 as an argument' );\n\n\t\t\ttarget = new Vector4();\n\n\t\t}\n\n\t\treturn target.copy( _currentViewport );\n\n\t};\n\n\tthis.getViewport = function ( target ) {\n\n\t\treturn target.copy( _viewport );\n\n\t};\n\n\tthis.setViewport = function ( x, y, width, height ) {\n\n\t\tif ( x.isVector4 ) {\n\n\t\t\t_viewport.set( x.x, x.y, x.z, x.w );\n\n\t\t} else {\n\n\t\t\t_viewport.set( x, y, width, height );\n\n\t\t}\n\n\t\tstate.viewport( _currentViewport.copy( _viewport ).multiplyScalar( _pixelRatio ).floor() );\n\n\t};\n\n\tthis.getScissor = function ( target ) {\n\n\t\treturn target.copy( _scissor );\n\n\t};\n\n\tthis.setScissor = function ( x, y, width, height ) {\n\n\t\tif ( x.isVector4 ) {\n\n\t\t\t_scissor.set( x.x, x.y, x.z, x.w );\n\n\t\t} else {\n\n\t\t\t_scissor.set( x, y, width, height );\n\n\t\t}\n\n\t\tstate.scissor( _currentScissor.copy( _scissor ).multiplyScalar( _pixelRatio ).floor() );\n\n\t};\n\n\tthis.getScissorTest = function () {\n\n\t\treturn _scissorTest;\n\n\t};\n\n\tthis.setScissorTest = function ( boolean ) {\n\n\t\tstate.setScissorTest( _scissorTest = boolean );\n\n\t};\n\n\tthis.setOpaqueSort = function ( method ) {\n\n\t\t_opaqueSort = method;\n\n\t};\n\n\tthis.setTransparentSort = function ( method ) {\n\n\t\t_transparentSort = method;\n\n\t};\n\n\t// Clearing\n\n\tthis.getClearColor = function () {\n\n\t\treturn background.getClearColor();\n\n\t};\n\n\tthis.setClearColor = function () {\n\n\t\tbackground.setClearColor.apply( background, arguments );\n\n\t};\n\n\tthis.getClearAlpha = function () {\n\n\t\treturn background.getClearAlpha();\n\n\t};\n\n\tthis.setClearAlpha = function () {\n\n\t\tbackground.setClearAlpha.apply( background, arguments );\n\n\t};\n\n\tthis.clear = function ( color, depth, stencil ) {\n\n\t\tlet bits = 0;\n\n\t\tif ( color === undefined || color ) bits |= _gl.COLOR_BUFFER_BIT;\n\t\tif ( depth === undefined || depth ) bits |= _gl.DEPTH_BUFFER_BIT;\n\t\tif ( stencil === undefined || stencil ) bits |= _gl.STENCIL_BUFFER_BIT;\n\n\t\t_gl.clear( bits );\n\n\t};\n\n\tthis.clearColor = function () {\n\n\t\tthis.clear( true, false, false );\n\n\t};\n\n\tthis.clearDepth = function () {\n\n\t\tthis.clear( false, true, false );\n\n\t};\n\n\tthis.clearStencil = function () {\n\n\t\tthis.clear( false, false, true );\n\n\t};\n\n\t//\n\n\tthis.dispose = function () {\n\n\t\t_canvas.removeEventListener( 'webglcontextlost', onContextLost, false );\n\t\t_canvas.removeEventListener( 'webglcontextrestored', onContextRestore, false );\n\n\t\trenderLists.dispose();\n\t\trenderStates.dispose();\n\t\tproperties.dispose();\n\t\tobjects.dispose();\n\t\tbindingStates.dispose();\n\n\t\txr.dispose();\n\n\t\tanimation.stop();\n\n\t};\n\n\t// Events\n\n\tfunction onContextLost( event ) {\n\n\t\tevent.preventDefault();\n\n\t\tconsole.log( 'THREE.WebGLRenderer: Context Lost.' );\n\n\t\t_isContextLost = true;\n\n\t}\n\n\tfunction onContextRestore( /* event */ ) {\n\n\t\tconsole.log( 'THREE.WebGLRenderer: Context Restored.' );\n\n\t\t_isContextLost = false;\n\n\t\tinitGLContext();\n\n\t}\n\n\tfunction onMaterialDispose( event ) {\n\n\t\tconst material = event.target;\n\n\t\tmaterial.removeEventListener( 'dispose', onMaterialDispose );\n\n\t\tdeallocateMaterial( material );\n\n\t}\n\n\t// Buffer deallocation\n\n\tfunction deallocateMaterial( material ) {\n\n\t\treleaseMaterialProgramReference( material );\n\n\t\tproperties.remove( material );\n\n\t}\n\n\n\tfunction releaseMaterialProgramReference( material ) {\n\n\t\tconst programInfo = properties.get( material ).program;\n\n\t\tmaterial.program = undefined;\n\n\t\tif ( programInfo !== undefined ) {\n\n\t\t\tprogramCache.releaseProgram( programInfo );\n\n\t\t}\n\n\t}\n\n\t// Buffer rendering\n\n\tfunction renderObjectImmediate( object, program ) {\n\n\t\tobject.render( function ( object ) {\n\n\t\t\t_this.renderBufferImmediate( object, program );\n\n\t\t} );\n\n\t}\n\n\tthis.renderBufferImmediate = function ( object, program ) {\n\n\t\tbindingStates.initAttributes();\n\n\t\tconst buffers = properties.get( object );\n\n\t\tif ( object.hasPositions && ! buffers.position ) buffers.position = _gl.createBuffer();\n\t\tif ( object.hasNormals && ! buffers.normal ) buffers.normal = _gl.createBuffer();\n\t\tif ( object.hasUvs && ! buffers.uv ) buffers.uv = _gl.createBuffer();\n\t\tif ( object.hasColors && ! buffers.color ) buffers.color = _gl.createBuffer();\n\n\t\tconst programAttributes = program.getAttributes();\n\n\t\tif ( object.hasPositions ) {\n\n\t\t\t_gl.bindBuffer( _gl.ARRAY_BUFFER, buffers.position );\n\t\t\t_gl.bufferData( _gl.ARRAY_BUFFER, object.positionArray, _gl.DYNAMIC_DRAW );\n\n\t\t\tbindingStates.enableAttribute( programAttributes.position );\n\t\t\t_gl.vertexAttribPointer( programAttributes.position, 3, _gl.FLOAT, false, 0, 0 );\n\n\t\t}\n\n\t\tif ( object.hasNormals ) {\n\n\t\t\t_gl.bindBuffer( _gl.ARRAY_BUFFER, buffers.normal );\n\t\t\t_gl.bufferData( _gl.ARRAY_BUFFER, object.normalArray, _gl.DYNAMIC_DRAW );\n\n\t\t\tbindingStates.enableAttribute( programAttributes.normal );\n\t\t\t_gl.vertexAttribPointer( programAttributes.normal, 3, _gl.FLOAT, false, 0, 0 );\n\n\t\t}\n\n\t\tif ( object.hasUvs ) {\n\n\t\t\t_gl.bindBuffer( _gl.ARRAY_BUFFER, buffers.uv );\n\t\t\t_gl.bufferData( _gl.ARRAY_BUFFER, object.uvArray, _gl.DYNAMIC_DRAW );\n\n\t\t\tbindingStates.enableAttribute( programAttributes.uv );\n\t\t\t_gl.vertexAttribPointer( programAttributes.uv, 2, _gl.FLOAT, false, 0, 0 );\n\n\t\t}\n\n\t\tif ( object.hasColors ) {\n\n\t\t\t_gl.bindBuffer( _gl.ARRAY_BUFFER, buffers.color );\n\t\t\t_gl.bufferData( _gl.ARRAY_BUFFER, object.colorArray, _gl.DYNAMIC_DRAW );\n\n\t\t\tbindingStates.enableAttribute( programAttributes.color );\n\t\t\t_gl.vertexAttribPointer( programAttributes.color, 3, _gl.FLOAT, false, 0, 0 );\n\n\t\t}\n\n\t\tbindingStates.disableUnusedAttributes();\n\n\t\t_gl.drawArrays( _gl.TRIANGLES, 0, object.count );\n\n\t\tobject.count = 0;\n\n\t};\n\n\tthis.renderBufferDirect = function ( camera, scene, geometry, material, object, group ) {\n\n\t\tif ( scene === null ) scene = _emptyScene; // renderBufferDirect second parameter used to be fog (could be null)\n\n\t\tconst frontFaceCW = ( object.isMesh && object.matrixWorld.determinant() < 0 );\n\n\t\tconst program = setProgram( camera, scene, material, object );\n\n\t\tstate.setMaterial( material, frontFaceCW );\n\n\t\t//\n\n\t\tlet index = geometry.index;\n\t\tconst position = geometry.attributes.position;\n\n\t\t//\n\n\t\tif ( index === null ) {\n\n\t\t\tif ( position === undefined || position.count === 0 ) return;\n\n\t\t} else if ( index.count === 0 ) {\n\n\t\t\treturn;\n\n\t\t}\n\n\t\t//\n\n\t\tlet rangeFactor = 1;\n\n\t\tif ( material.wireframe === true ) {\n\n\t\t\tindex = geometries.getWireframeAttribute( geometry );\n\t\t\trangeFactor = 2;\n\n\t\t}\n\n\t\tif ( material.morphTargets || material.morphNormals ) {\n\n\t\t\tmorphtargets.update( object, geometry, material, program );\n\n\t\t}\n\n\t\tbindingStates.setup( object, material, program, geometry, index );\n\n\t\tlet attribute;\n\t\tlet renderer = bufferRenderer;\n\n\t\tif ( index !== null ) {\n\n\t\t\tattribute = attributes.get( index );\n\n\t\t\trenderer = indexedBufferRenderer;\n\t\t\trenderer.setIndex( attribute );\n\n\t\t}\n\n\t\t//\n\n\t\tconst dataCount = ( index !== null ) ? index.count : position.count;\n\n\t\tconst rangeStart = geometry.drawRange.start * rangeFactor;\n\t\tconst rangeCount = geometry.drawRange.count * rangeFactor;\n\n\t\tconst groupStart = group !== null ? group.start * rangeFactor : 0;\n\t\tconst groupCount = group !== null ? group.count * rangeFactor : Infinity;\n\n\t\tconst drawStart = Math.max( rangeStart, groupStart );\n\t\tconst drawEnd = Math.min( dataCount, rangeStart + rangeCount, groupStart + groupCount ) - 1;\n\n\t\tconst drawCount = Math.max( 0, drawEnd - drawStart + 1 );\n\n\t\tif ( drawCount === 0 ) return;\n\n\t\t//\n\n\t\tif ( object.isMesh ) {\n\n\t\t\tif ( material.wireframe === true ) {\n\n\t\t\t\tstate.setLineWidth( material.wireframeLinewidth * getTargetPixelRatio() );\n\t\t\t\trenderer.setMode( _gl.LINES );\n\n\t\t\t} else {\n\n\t\t\t\trenderer.setMode( _gl.TRIANGLES );\n\n\t\t\t}\n\n\t\t} else if ( object.isLine ) {\n\n\t\t\tlet lineWidth = material.linewidth;\n\n\t\t\tif ( lineWidth === undefined ) lineWidth = 1; // Not using Line*Material\n\n\t\t\tstate.setLineWidth( lineWidth * getTargetPixelRatio() );\n\n\t\t\tif ( object.isLineSegments ) {\n\n\t\t\t\trenderer.setMode( _gl.LINES );\n\n\t\t\t} else if ( object.isLineLoop ) {\n\n\t\t\t\trenderer.setMode( _gl.LINE_LOOP );\n\n\t\t\t} else {\n\n\t\t\t\trenderer.setMode( _gl.LINE_STRIP );\n\n\t\t\t}\n\n\t\t} else if ( object.isPoints ) {\n\n\t\t\trenderer.setMode( _gl.POINTS );\n\n\t\t} else if ( object.isSprite ) {\n\n\t\t\trenderer.setMode( _gl.TRIANGLES );\n\n\t\t}\n\n\t\tif ( object.isInstancedMesh ) {\n\n\t\t\trenderer.renderInstances( geometry, drawStart, drawCount, object.count );\n\n\t\t} else if ( geometry.isInstancedBufferGeometry ) {\n\n\t\t\tconst instanceCount = Math.min( geometry.instanceCount, geometry._maxInstanceCount );\n\n\t\t\trenderer.renderInstances( geometry, drawStart, drawCount, instanceCount );\n\n\t\t} else {\n\n\t\t\trenderer.render( drawStart, drawCount );\n\n\t\t}\n\n\t};\n\n\t// Compile\n\n\tthis.compile = function ( scene, camera ) {\n\n\t\tcurrentRenderState = renderStates.get( scene, camera );\n\t\tcurrentRenderState.init();\n\n\t\tscene.traverse( function ( object ) {\n\n\t\t\tif ( object.isLight ) {\n\n\t\t\t\tcurrentRenderState.pushLight( object );\n\n\t\t\t\tif ( object.castShadow ) {\n\n\t\t\t\t\tcurrentRenderState.pushShadow( object );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} );\n\n\t\tcurrentRenderState.setupLights( camera );\n\n\t\tconst compiled = new WeakMap();\n\n\t\tscene.traverse( function ( object ) {\n\n\t\t\tlet material = object.material;\n\n\t\t\tif ( material ) {\n\n\t\t\t\tif ( Array.isArray( material ) ) {\n\n\t\t\t\t\tfor ( let i = 0; i < material.length; i ++ ) {\n\n\t\t\t\t\t\tlet material2 = material[ i ];\n\n\t\t\t\t\t\tif ( compiled.has( material2 ) === false ) {\n\n\t\t\t\t\t\t\tinitMaterial( material2, scene, object );\n\t\t\t\t\t\t\tcompiled.set( material2 );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t} else if ( compiled.has( material ) === false ) {\n\n\t\t\t\t\tinitMaterial( material, scene, object );\n\t\t\t\t\tcompiled.set( material );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} );\n\n\t};\n\n\t// Animation Loop\n\n\tlet onAnimationFrameCallback = null;\n\n\tfunction onAnimationFrame( time ) {\n\n\t\tif ( xr.isPresenting ) return;\n\t\tif ( onAnimationFrameCallback ) onAnimationFrameCallback( time );\n\n\t}\n\n\tconst animation = new WebGLAnimation();\n\tanimation.setAnimationLoop( onAnimationFrame );\n\n\tif ( typeof window !== 'undefined' ) animation.setContext( window );\n\n\tthis.setAnimationLoop = function ( callback ) {\n\n\t\tonAnimationFrameCallback = callback;\n\t\txr.setAnimationLoop( callback );\n\n\t\t( callback === null ) ? animation.stop() : animation.start();\n\n\t};\n\n\t// Rendering\n\n\tthis.render = function ( scene, camera ) {\n\n\t\tlet renderTarget, forceClear;\n\n\t\tif ( arguments[ 2 ] !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.WebGLRenderer.render(): the renderTarget argument has been removed. Use .setRenderTarget() instead.' );\n\t\t\trenderTarget = arguments[ 2 ];\n\n\t\t}\n\n\t\tif ( arguments[ 3 ] !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.WebGLRenderer.render(): the forceClear argument has been removed. Use .clear() instead.' );\n\t\t\tforceClear = arguments[ 3 ];\n\n\t\t}\n\n\t\tif ( camera !== undefined && camera.isCamera !== true ) {\n\n\t\t\tconsole.error( 'THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.' );\n\t\t\treturn;\n\n\t\t}\n\n\t\tif ( _isContextLost === true ) return;\n\n\t\t// reset caching for this frame\n\n\t\tbindingStates.resetDefaultState();\n\t\t_currentMaterialId = - 1;\n\t\t_currentCamera = null;\n\n\t\t// update scene graph\n\n\t\tif ( scene.autoUpdate === true ) scene.updateMatrixWorld();\n\n\t\t// update camera matrices and frustum\n\n\t\tif ( camera.parent === null ) camera.updateMatrixWorld();\n\n\t\tif ( xr.enabled === true && xr.isPresenting === true ) {\n\n\t\t\tcamera = xr.getCamera( camera );\n\n\t\t}\n\n\t\t//\n\t\tif ( scene.isScene === true ) scene.onBeforeRender( _this, scene, camera, renderTarget || _currentRenderTarget );\n\n\t\tcurrentRenderState = renderStates.get( scene, camera );\n\t\tcurrentRenderState.init();\n\n\t\t_projScreenMatrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse );\n\t\t_frustum.setFromProjectionMatrix( _projScreenMatrix );\n\n\t\t_localClippingEnabled = this.localClippingEnabled;\n\t\t_clippingEnabled = _clipping.init( this.clippingPlanes, _localClippingEnabled, camera );\n\n\t\tcurrentRenderList = renderLists.get( scene, camera );\n\t\tcurrentRenderList.init();\n\n\t\tprojectObject( scene, camera, 0, _this.sortObjects );\n\n\t\tcurrentRenderList.finish();\n\n\t\tif ( _this.sortObjects === true ) {\n\n\t\t\tcurrentRenderList.sort( _opaqueSort, _transparentSort );\n\n\t\t}\n\n\t\t//\n\n\t\tif ( _clippingEnabled === true ) _clipping.beginShadows();\n\n\t\tconst shadowsArray = currentRenderState.state.shadowsArray;\n\n\t\tshadowMap.render( shadowsArray, scene, camera );\n\n\t\tcurrentRenderState.setupLights( camera );\n\n\t\tif ( _clippingEnabled === true ) _clipping.endShadows();\n\n\t\t//\n\n\t\tif ( this.info.autoReset === true ) this.info.reset();\n\n\t\tif ( renderTarget !== undefined ) {\n\n\t\t\tthis.setRenderTarget( renderTarget );\n\n\t\t}\n\n\t\t//\n\n\t\tbackground.render( currentRenderList, scene, camera, forceClear );\n\n\t\t// render scene\n\n\t\tconst opaqueObjects = currentRenderList.opaque;\n\t\tconst transparentObjects = currentRenderList.transparent;\n\n\t\tif ( opaqueObjects.length > 0 ) renderObjects( opaqueObjects, scene, camera );\n\t\tif ( transparentObjects.length > 0 ) renderObjects( transparentObjects, scene, camera );\n\n\t\t//\n\n\t\tif ( scene.isScene === true ) scene.onAfterRender( _this, scene, camera );\n\n\t\t//\n\n\t\tif ( _currentRenderTarget !== null ) {\n\n\t\t\t// Generate mipmap if we're using any kind of mipmap filtering\n\n\t\t\ttextures.updateRenderTargetMipmap( _currentRenderTarget );\n\n\t\t\t// resolve multisample renderbuffers to a single-sample texture if necessary\n\n\t\t\ttextures.updateMultisampleRenderTarget( _currentRenderTarget );\n\n\t\t}\n\n\t\t// Ensure depth buffer writing is enabled so it can be cleared on next render\n\n\t\tstate.buffers.depth.setTest( true );\n\t\tstate.buffers.depth.setMask( true );\n\t\tstate.buffers.color.setMask( true );\n\n\t\tstate.setPolygonOffset( false );\n\n\t\t// _gl.finish();\n\n\t\tcurrentRenderList = null;\n\t\tcurrentRenderState = null;\n\n\t};\n\n\tfunction projectObject( object, camera, groupOrder, sortObjects ) {\n\n\t\tif ( object.visible === false ) return;\n\n\t\tconst visible = object.layers.test( camera.layers );\n\n\t\tif ( visible ) {\n\n\t\t\tif ( object.isGroup ) {\n\n\t\t\t\tgroupOrder = object.renderOrder;\n\n\t\t\t} else if ( object.isLOD ) {\n\n\t\t\t\tif ( object.autoUpdate === true ) object.update( camera );\n\n\t\t\t} else if ( object.isLight ) {\n\n\t\t\t\tcurrentRenderState.pushLight( object );\n\n\t\t\t\tif ( object.castShadow ) {\n\n\t\t\t\t\tcurrentRenderState.pushShadow( object );\n\n\t\t\t\t}\n\n\t\t\t} else if ( object.isSprite ) {\n\n\t\t\t\tif ( ! object.frustumCulled || _frustum.intersectsSprite( object ) ) {\n\n\t\t\t\t\tif ( sortObjects ) {\n\n\t\t\t\t\t\t_vector3.setFromMatrixPosition( object.matrixWorld )\n\t\t\t\t\t\t\t.applyMatrix4( _projScreenMatrix );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tconst geometry = objects.update( object );\n\t\t\t\t\tconst material = object.material;\n\n\t\t\t\t\tif ( material.visible ) {\n\n\t\t\t\t\t\tcurrentRenderList.push( object, geometry, material, groupOrder, _vector3.z, null );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t} else if ( object.isImmediateRenderObject ) {\n\n\t\t\t\tif ( sortObjects ) {\n\n\t\t\t\t\t_vector3.setFromMatrixPosition( object.matrixWorld )\n\t\t\t\t\t\t.applyMatrix4( _projScreenMatrix );\n\n\t\t\t\t}\n\n\t\t\t\tcurrentRenderList.push( object, null, object.material, groupOrder, _vector3.z, null );\n\n\t\t\t} else if ( object.isMesh || object.isLine || object.isPoints ) {\n\n\t\t\t\tif ( object.isSkinnedMesh ) {\n\n\t\t\t\t\t// update skeleton only once in a frame\n\n\t\t\t\t\tif ( object.skeleton.frame !== info.render.frame ) {\n\n\t\t\t\t\t\tobject.skeleton.update();\n\t\t\t\t\t\tobject.skeleton.frame = info.render.frame;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tif ( ! object.frustumCulled || _frustum.intersectsObject( object ) ) {\n\n\t\t\t\t\tif ( sortObjects ) {\n\n\t\t\t\t\t\t_vector3.setFromMatrixPosition( object.matrixWorld )\n\t\t\t\t\t\t\t.applyMatrix4( _projScreenMatrix );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tconst geometry = objects.update( object );\n\t\t\t\t\tconst material = object.material;\n\n\t\t\t\t\tif ( Array.isArray( material ) ) {\n\n\t\t\t\t\t\tconst groups = geometry.groups;\n\n\t\t\t\t\t\tfor ( let i = 0, l = groups.length; i < l; i ++ ) {\n\n\t\t\t\t\t\t\tconst group = groups[ i ];\n\t\t\t\t\t\t\tconst groupMaterial = material[ group.materialIndex ];\n\n\t\t\t\t\t\t\tif ( groupMaterial && groupMaterial.visible ) {\n\n\t\t\t\t\t\t\t\tcurrentRenderList.push( object, geometry, groupMaterial, groupOrder, _vector3.z, group );\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t} else if ( material.visible ) {\n\n\t\t\t\t\t\tcurrentRenderList.push( object, geometry, material, groupOrder, _vector3.z, null );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tconst children = object.children;\n\n\t\tfor ( let i = 0, l = children.length; i < l; i ++ ) {\n\n\t\t\tprojectObject( children[ i ], camera, groupOrder, sortObjects );\n\n\t\t}\n\n\t}\n\n\tfunction renderObjects( renderList, scene, camera ) {\n\n\t\tconst overrideMaterial = scene.isScene === true ? scene.overrideMaterial : null;\n\n\t\tfor ( let i = 0, l = renderList.length; i < l; i ++ ) {\n\n\t\t\tconst renderItem = renderList[ i ];\n\n\t\t\tconst object = renderItem.object;\n\t\t\tconst geometry = renderItem.geometry;\n\t\t\tconst material = overrideMaterial === null ? renderItem.material : overrideMaterial;\n\t\t\tconst group = renderItem.group;\n\n\t\t\tif ( camera.isArrayCamera ) {\n\n\t\t\t\t_currentArrayCamera = camera;\n\n\t\t\t\tconst cameras = camera.cameras;\n\n\t\t\t\tfor ( let j = 0, jl = cameras.length; j < jl; j ++ ) {\n\n\t\t\t\t\tconst camera2 = cameras[ j ];\n\n\t\t\t\t\tif ( object.layers.test( camera2.layers ) ) {\n\n\t\t\t\t\t\tstate.viewport( _currentViewport.copy( camera2.viewport ) );\n\n\t\t\t\t\t\tcurrentRenderState.setupLights( camera2 );\n\n\t\t\t\t\t\trenderObject( object, scene, camera2, geometry, material, group );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\t_currentArrayCamera = null;\n\n\t\t\t\trenderObject( object, scene, camera, geometry, material, group );\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tfunction renderObject( object, scene, camera, geometry, material, group ) {\n\n\t\tobject.onBeforeRender( _this, scene, camera, geometry, material, group );\n\t\tcurrentRenderState = renderStates.get( scene, _currentArrayCamera || camera );\n\n\t\tobject.modelViewMatrix.multiplyMatrices( camera.matrixWorldInverse, object.matrixWorld );\n\t\tobject.normalMatrix.getNormalMatrix( object.modelViewMatrix );\n\n\t\tif ( object.isImmediateRenderObject ) {\n\n\t\t\tconst program = setProgram( camera, scene, material, object );\n\n\t\t\tstate.setMaterial( material );\n\n\t\t\tbindingStates.reset();\n\n\t\t\trenderObjectImmediate( object, program );\n\n\t\t} else {\n\n\t\t\t_this.renderBufferDirect( camera, scene, geometry, material, object, group );\n\n\t\t}\n\n\t\tobject.onAfterRender( _this, scene, camera, geometry, material, group );\n\t\tcurrentRenderState = renderStates.get( scene, _currentArrayCamera || camera );\n\n\t}\n\n\tfunction initMaterial( material, scene, object ) {\n\n\t\tif ( scene.isScene !== true ) scene = _emptyScene; // scene could be a Mesh, Line, Points, ...\n\n\t\tconst materialProperties = properties.get( material );\n\n\t\tconst lights = currentRenderState.state.lights;\n\t\tconst shadowsArray = currentRenderState.state.shadowsArray;\n\n\t\tconst lightsStateVersion = lights.state.version;\n\n\t\tconst parameters = programCache.getParameters( material, lights.state, shadowsArray, scene, _clipping.numPlanes, _clipping.numIntersection, object );\n\t\tconst programCacheKey = programCache.getProgramCacheKey( parameters );\n\n\t\tlet program = materialProperties.program;\n\t\tlet programChange = true;\n\n\t\tif ( program === undefined ) {\n\n\t\t\t// new material\n\t\t\tmaterial.addEventListener( 'dispose', onMaterialDispose );\n\n\t\t} else if ( program.cacheKey !== programCacheKey ) {\n\n\t\t\t// changed glsl or parameters\n\t\t\treleaseMaterialProgramReference( material );\n\n\t\t} else if ( materialProperties.lightsStateVersion !== lightsStateVersion ) {\n\n\t\t\tmaterialProperties.lightsStateVersion = lightsStateVersion;\n\n\t\t\tprogramChange = false;\n\n\t\t} else if ( parameters.shaderID !== undefined ) {\n\n\t\t\t// same glsl and uniform list\n\t\t\treturn;\n\n\t\t} else {\n\n\t\t\t// only rebuild uniform list\n\t\t\tprogramChange = false;\n\n\t\t}\n\n\t\tif ( programChange ) {\n\n\t\t\tprogram = programCache.acquireProgram( parameters, programCacheKey );\n\n\t\t\tmaterialProperties.program = program;\n\t\t\tmaterialProperties.uniforms = parameters.uniforms;\n\t\t\tmaterialProperties.outputEncoding = parameters.outputEncoding;\n\t\t\tmaterial.program = program;\n\n\t\t}\n\n\t\tconst programAttributes = program.getAttributes();\n\n\t\tif ( material.morphTargets ) {\n\n\t\t\tmaterial.numSupportedMorphTargets = 0;\n\n\t\t\tfor ( let i = 0; i < _this.maxMorphTargets; i ++ ) {\n\n\t\t\t\tif ( programAttributes[ 'morphTarget' + i ] >= 0 ) {\n\n\t\t\t\t\tmaterial.numSupportedMorphTargets ++;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( material.morphNormals ) {\n\n\t\t\tmaterial.numSupportedMorphNormals = 0;\n\n\t\t\tfor ( let i = 0; i < _this.maxMorphNormals; i ++ ) {\n\n\t\t\t\tif ( programAttributes[ 'morphNormal' + i ] >= 0 ) {\n\n\t\t\t\t\tmaterial.numSupportedMorphNormals ++;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tconst uniforms = materialProperties.uniforms;\n\n\t\tif ( ! material.isShaderMaterial &&\n\t\t\t! material.isRawShaderMaterial ||\n\t\t\tmaterial.clipping === true ) {\n\n\t\t\tmaterialProperties.numClippingPlanes = _clipping.numPlanes;\n\t\t\tmaterialProperties.numIntersection = _clipping.numIntersection;\n\t\t\tuniforms.clippingPlanes = _clipping.uniform;\n\n\t\t}\n\n\t\tmaterialProperties.environment = material.isMeshStandardMaterial ? scene.environment : null;\n\t\tmaterialProperties.fog = scene.fog;\n\n\t\t// store the light setup it was created for\n\n\t\tmaterialProperties.needsLights = materialNeedsLights( material );\n\t\tmaterialProperties.lightsStateVersion = lightsStateVersion;\n\n\t\tif ( materialProperties.needsLights ) {\n\n\t\t\t// wire up the material to this renderer's lighting state\n\n\t\t\tuniforms.ambientLightColor.value = lights.state.ambient;\n\t\t\tuniforms.lightProbe.value = lights.state.probe;\n\t\t\tuniforms.directionalLights.value = lights.state.directional;\n\t\t\tuniforms.directionalLightShadows.value = lights.state.directionalShadow;\n\t\t\tuniforms.spotLights.value = lights.state.spot;\n\t\t\tuniforms.spotLightShadows.value = lights.state.spotShadow;\n\t\t\tuniforms.rectAreaLights.value = lights.state.rectArea;\n\t\t\tuniforms.pointLights.value = lights.state.point;\n\t\t\tuniforms.pointLightShadows.value = lights.state.pointShadow;\n\t\t\tuniforms.hemisphereLights.value = lights.state.hemi;\n\n\t\t\tuniforms.directionalShadowMap.value = lights.state.directionalShadowMap;\n\t\t\tuniforms.directionalShadowMatrix.value = lights.state.directionalShadowMatrix;\n\t\t\tuniforms.spotShadowMap.value = lights.state.spotShadowMap;\n\t\t\tuniforms.spotShadowMatrix.value = lights.state.spotShadowMatrix;\n\t\t\tuniforms.pointShadowMap.value = lights.state.pointShadowMap;\n\t\t\tuniforms.pointShadowMatrix.value = lights.state.pointShadowMatrix;\n\t\t\t// TODO (abelnation): add area lights shadow info to uniforms\n\n\t\t}\n\n\t\tconst progUniforms = materialProperties.program.getUniforms(),\n\t\t\tuniformsList =\n\t\t\t\tWebGLUniforms.seqWithValue( progUniforms.seq, uniforms );\n\n\t\tmaterialProperties.uniformsList = uniformsList;\n\n\t}\n\n\tfunction setProgram( camera, scene, material, object ) {\n\n\t\tif ( scene.isScene !== true ) scene = _emptyScene; // scene could be a Mesh, Line, Points, ...\n\n\t\ttextures.resetTextureUnits();\n\n\t\tconst fog = scene.fog;\n\t\tconst environment = material.isMeshStandardMaterial ? scene.environment : null;\n\t\tconst encoding = ( _currentRenderTarget === null ) ? _this.outputEncoding : _currentRenderTarget.texture.encoding;\n\n\t\tconst materialProperties = properties.get( material );\n\t\tconst lights = currentRenderState.state.lights;\n\n\t\tif ( _clippingEnabled === true ) {\n\n\t\t\tif ( _localClippingEnabled === true || camera !== _currentCamera ) {\n\n\t\t\t\tconst useCache =\n\t\t\t\t\tcamera === _currentCamera &&\n\t\t\t\t\tmaterial.id === _currentMaterialId;\n\n\t\t\t\t// we might want to call this function with some ClippingGroup\n\t\t\t\t// object instead of the material, once it becomes feasible\n\t\t\t\t// (#8465, #8379)\n\t\t\t\t_clipping.setState(\n\t\t\t\t\tmaterial.clippingPlanes, material.clipIntersection, material.clipShadows,\n\t\t\t\t\tcamera, materialProperties, useCache );\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( material.version === materialProperties.__version ) {\n\n\t\t\tif ( materialProperties.program === undefined ) {\n\n\t\t\t\tinitMaterial( material, scene, object );\n\n\t\t\t} else if ( material.fog && materialProperties.fog !== fog ) {\n\n\t\t\t\tinitMaterial( material, scene, object );\n\n\t\t\t} else if ( materialProperties.environment !== environment ) {\n\n\t\t\t\tinitMaterial( material, scene, object );\n\n\t\t\t} else if ( materialProperties.needsLights && ( materialProperties.lightsStateVersion !== lights.state.version ) ) {\n\n\t\t\t\tinitMaterial( material, scene, object );\n\n\t\t\t} else if ( materialProperties.numClippingPlanes !== undefined &&\n\t\t\t\t( materialProperties.numClippingPlanes !== _clipping.numPlanes ||\n\t\t\t\tmaterialProperties.numIntersection !== _clipping.numIntersection ) ) {\n\n\t\t\t\tinitMaterial( material, scene, object );\n\n\t\t\t} else if ( materialProperties.outputEncoding !== encoding ) {\n\n\t\t\t\tinitMaterial( material, scene, object );\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tinitMaterial( material, scene, object );\n\t\t\tmaterialProperties.__version = material.version;\n\n\t\t}\n\n\t\tlet refreshProgram = false;\n\t\tlet refreshMaterial = false;\n\t\tlet refreshLights = false;\n\n\t\tconst program = materialProperties.program,\n\t\t\tp_uniforms = program.getUniforms(),\n\t\t\tm_uniforms = materialProperties.uniforms;\n\n\t\tif ( state.useProgram( program.program ) ) {\n\n\t\t\trefreshProgram = true;\n\t\t\trefreshMaterial = true;\n\t\t\trefreshLights = true;\n\n\t\t}\n\n\t\tif ( material.id !== _currentMaterialId ) {\n\n\t\t\t_currentMaterialId = material.id;\n\n\t\t\trefreshMaterial = true;\n\n\t\t}\n\n\t\tif ( refreshProgram || _currentCamera !== camera ) {\n\n\t\t\tp_uniforms.setValue( _gl, 'projectionMatrix', camera.projectionMatrix );\n\n\t\t\tif ( capabilities.logarithmicDepthBuffer ) {\n\n\t\t\t\tp_uniforms.setValue( _gl, 'logDepthBufFC',\n\t\t\t\t\t2.0 / ( Math.log( camera.far + 1.0 ) / Math.LN2 ) );\n\n\t\t\t}\n\n\t\t\tif ( _currentCamera !== camera ) {\n\n\t\t\t\t_currentCamera = camera;\n\n\t\t\t\t// lighting uniforms depend on the camera so enforce an update\n\t\t\t\t// now, in case this material supports lights - or later, when\n\t\t\t\t// the next material that does gets activated:\n\n\t\t\t\trefreshMaterial = true;\t\t// set to true on material change\n\t\t\t\trefreshLights = true;\t\t// remains set until update done\n\n\t\t\t}\n\n\t\t\t// load material specific uniforms\n\t\t\t// (shader material also gets them for the sake of genericity)\n\n\t\t\tif ( material.isShaderMaterial ||\n\t\t\t\tmaterial.isMeshPhongMaterial ||\n\t\t\t\tmaterial.isMeshToonMaterial ||\n\t\t\t\tmaterial.isMeshStandardMaterial ||\n\t\t\t\tmaterial.envMap ) {\n\n\t\t\t\tconst uCamPos = p_uniforms.map.cameraPosition;\n\n\t\t\t\tif ( uCamPos !== undefined ) {\n\n\t\t\t\t\tuCamPos.setValue( _gl,\n\t\t\t\t\t\t_vector3.setFromMatrixPosition( camera.matrixWorld ) );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif ( material.isMeshPhongMaterial ||\n\t\t\t\tmaterial.isMeshToonMaterial ||\n\t\t\t\tmaterial.isMeshLambertMaterial ||\n\t\t\t\tmaterial.isMeshBasicMaterial ||\n\t\t\t\tmaterial.isMeshStandardMaterial ||\n\t\t\t\tmaterial.isShaderMaterial ) {\n\n\t\t\t\tp_uniforms.setValue( _gl, 'isOrthographic', camera.isOrthographicCamera === true );\n\n\t\t\t}\n\n\t\t\tif ( material.isMeshPhongMaterial ||\n\t\t\t\tmaterial.isMeshToonMaterial ||\n\t\t\t\tmaterial.isMeshLambertMaterial ||\n\t\t\t\tmaterial.isMeshBasicMaterial ||\n\t\t\t\tmaterial.isMeshStandardMaterial ||\n\t\t\t\tmaterial.isShaderMaterial ||\n\t\t\t\tmaterial.isShadowMaterial ||\n\t\t\t\tmaterial.skinning ) {\n\n\t\t\t\tp_uniforms.setValue( _gl, 'viewMatrix', camera.matrixWorldInverse );\n\n\t\t\t}\n\n\t\t}\n\n\t\t// skinning uniforms must be set even if material didn't change\n\t\t// auto-setting of texture unit for bone texture must go before other textures\n\t\t// otherwise textures used for skinning can take over texture units reserved for other material textures\n\n\t\tif ( material.skinning ) {\n\n\t\t\tp_uniforms.setOptional( _gl, object, 'bindMatrix' );\n\t\t\tp_uniforms.setOptional( _gl, object, 'bindMatrixInverse' );\n\n\t\t\tconst skeleton = object.skeleton;\n\n\t\t\tif ( skeleton ) {\n\n\t\t\t\tconst bones = skeleton.bones;\n\n\t\t\t\tif ( capabilities.floatVertexTextures ) {\n\n\t\t\t\t\tif ( skeleton.boneTexture === undefined ) {\n\n\t\t\t\t\t\t// layout (1 matrix = 4 pixels)\n\t\t\t\t\t\t// RGBA RGBA RGBA RGBA (=> column1, column2, column3, column4)\n\t\t\t\t\t\t// with 8x8 pixel texture max 16 bones * 4 pixels = (8 * 8)\n\t\t\t\t\t\t// 16x16 pixel texture max 64 bones * 4 pixels = (16 * 16)\n\t\t\t\t\t\t// 32x32 pixel texture max 256 bones * 4 pixels = (32 * 32)\n\t\t\t\t\t\t// 64x64 pixel texture max 1024 bones * 4 pixels = (64 * 64)\n\n\n\t\t\t\t\t\tlet size = Math.sqrt( bones.length * 4 ); // 4 pixels needed for 1 matrix\n\t\t\t\t\t\tsize = MathUtils.ceilPowerOfTwo( size );\n\t\t\t\t\t\tsize = Math.max( size, 4 );\n\n\t\t\t\t\t\tconst boneMatrices = new Float32Array( size * size * 4 ); // 4 floats per RGBA pixel\n\t\t\t\t\t\tboneMatrices.set( skeleton.boneMatrices ); // copy current values\n\n\t\t\t\t\t\tconst boneTexture = new DataTexture( boneMatrices, size, size, RGBAFormat, FloatType );\n\n\t\t\t\t\t\tskeleton.boneMatrices = boneMatrices;\n\t\t\t\t\t\tskeleton.boneTexture = boneTexture;\n\t\t\t\t\t\tskeleton.boneTextureSize = size;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tp_uniforms.setValue( _gl, 'boneTexture', skeleton.boneTexture, textures );\n\t\t\t\t\tp_uniforms.setValue( _gl, 'boneTextureSize', skeleton.boneTextureSize );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tp_uniforms.setOptional( _gl, skeleton, 'boneMatrices' );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( refreshMaterial || materialProperties.receiveShadow !== object.receiveShadow ) {\n\n\t\t\tmaterialProperties.receiveShadow = object.receiveShadow;\n\t\t\tp_uniforms.setValue( _gl, 'receiveShadow', object.receiveShadow );\n\n\t\t}\n\n\t\tif ( refreshMaterial ) {\n\n\t\t\tp_uniforms.setValue( _gl, 'toneMappingExposure', _this.toneMappingExposure );\n\n\t\t\tif ( materialProperties.needsLights ) {\n\n\t\t\t\t// the current material requires lighting info\n\n\t\t\t\t// note: all lighting uniforms are always set correctly\n\t\t\t\t// they simply reference the renderer's state for their\n\t\t\t\t// values\n\t\t\t\t//\n\t\t\t\t// use the current material's .needsUpdate flags to set\n\t\t\t\t// the GL state when required\n\n\t\t\t\tmarkUniformsLightsNeedsUpdate( m_uniforms, refreshLights );\n\n\t\t\t}\n\n\t\t\t// refresh uniforms common to several materials\n\n\t\t\tif ( fog && material.fog ) {\n\n\t\t\t\tmaterials.refreshFogUniforms( m_uniforms, fog );\n\n\t\t\t}\n\n\t\t\tmaterials.refreshMaterialUniforms( m_uniforms, material, environment, _pixelRatio, _height );\n\n\t\t\t// RectAreaLight Texture\n\t\t\t// TODO (mrdoob): Find a nicer implementation\n\n\t\t\tif ( m_uniforms.ltc_1 !== undefined ) m_uniforms.ltc_1.value = UniformsLib.LTC_1;\n\t\t\tif ( m_uniforms.ltc_2 !== undefined ) m_uniforms.ltc_2.value = UniformsLib.LTC_2;\n\n\t\t\tWebGLUniforms.upload( _gl, materialProperties.uniformsList, m_uniforms, textures );\n\n\t\t}\n\n\t\tif ( material.isShaderMaterial && material.uniformsNeedUpdate === true ) {\n\n\t\t\tWebGLUniforms.upload( _gl, materialProperties.uniformsList, m_uniforms, textures );\n\t\t\tmaterial.uniformsNeedUpdate = false;\n\n\t\t}\n\n\t\tif ( material.isSpriteMaterial ) {\n\n\t\t\tp_uniforms.setValue( _gl, 'center', object.center );\n\n\t\t}\n\n\t\t// common matrices\n\n\t\tp_uniforms.setValue( _gl, 'modelViewMatrix', object.modelViewMatrix );\n\t\tp_uniforms.setValue( _gl, 'normalMatrix', object.normalMatrix );\n\t\tp_uniforms.setValue( _gl, 'modelMatrix', object.matrixWorld );\n\n\t\treturn program;\n\n\t}\n\n\t// If uniforms are marked as clean, they don't need to be loaded to the GPU.\n\n\tfunction markUniformsLightsNeedsUpdate( uniforms, value ) {\n\n\t\tuniforms.ambientLightColor.needsUpdate = value;\n\t\tuniforms.lightProbe.needsUpdate = value;\n\n\t\tuniforms.directionalLights.needsUpdate = value;\n\t\tuniforms.directionalLightShadows.needsUpdate = value;\n\t\tuniforms.pointLights.needsUpdate = value;\n\t\tuniforms.pointLightShadows.needsUpdate = value;\n\t\tuniforms.spotLights.needsUpdate = value;\n\t\tuniforms.spotLightShadows.needsUpdate = value;\n\t\tuniforms.rectAreaLights.needsUpdate = value;\n\t\tuniforms.hemisphereLights.needsUpdate = value;\n\n\t}\n\n\tfunction materialNeedsLights( material ) {\n\n\t\treturn material.isMeshLambertMaterial || material.isMeshToonMaterial || material.isMeshPhongMaterial ||\n\t\t\tmaterial.isMeshStandardMaterial || material.isShadowMaterial ||\n\t\t\t( material.isShaderMaterial && material.lights === true );\n\n\t}\n\n\t//\n\tthis.setFramebuffer = function ( value ) {\n\n\t\tif ( _framebuffer !== value && _currentRenderTarget === null ) _gl.bindFramebuffer( _gl.FRAMEBUFFER, value );\n\n\t\t_framebuffer = value;\n\n\t};\n\n\tthis.getActiveCubeFace = function () {\n\n\t\treturn _currentActiveCubeFace;\n\n\t};\n\n\tthis.getActiveMipmapLevel = function () {\n\n\t\treturn _currentActiveMipmapLevel;\n\n\t};\n\n\tthis.getRenderTarget = function () {\n\n\t\treturn _currentRenderTarget;\n\n\t};\n\n\tthis.setRenderTarget = function ( renderTarget, activeCubeFace, activeMipmapLevel ) {\n\n\t\t_currentRenderTarget = renderTarget;\n\t\t_currentActiveCubeFace = activeCubeFace;\n\t\t_currentActiveMipmapLevel = activeMipmapLevel;\n\n\t\tif ( renderTarget && properties.get( renderTarget ).__webglFramebuffer === undefined ) {\n\n\t\t\ttextures.setupRenderTarget( renderTarget );\n\n\t\t}\n\n\t\tlet framebuffer = _framebuffer;\n\t\tlet isCube = false;\n\n\t\tif ( renderTarget ) {\n\n\t\t\tconst __webglFramebuffer = properties.get( renderTarget ).__webglFramebuffer;\n\n\t\t\tif ( renderTarget.isWebGLCubeRenderTarget ) {\n\n\t\t\t\tframebuffer = __webglFramebuffer[ activeCubeFace || 0 ];\n\t\t\t\tisCube = true;\n\n\t\t\t} else if ( renderTarget.isWebGLMultisampleRenderTarget ) {\n\n\t\t\t\tframebuffer = properties.get( renderTarget ).__webglMultisampledFramebuffer;\n\n\t\t\t} else {\n\n\t\t\t\tframebuffer = __webglFramebuffer;\n\n\t\t\t}\n\n\t\t\t_currentViewport.copy( renderTarget.viewport );\n\t\t\t_currentScissor.copy( renderTarget.scissor );\n\t\t\t_currentScissorTest = renderTarget.scissorTest;\n\n\t\t} else {\n\n\t\t\t_currentViewport.copy( _viewport ).multiplyScalar( _pixelRatio ).floor();\n\t\t\t_currentScissor.copy( _scissor ).multiplyScalar( _pixelRatio ).floor();\n\t\t\t_currentScissorTest = _scissorTest;\n\n\t\t}\n\n\t\tif ( _currentFramebuffer !== framebuffer ) {\n\n\t\t\t_gl.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );\n\t\t\t_currentFramebuffer = framebuffer;\n\n\t\t}\n\n\t\tstate.viewport( _currentViewport );\n\t\tstate.scissor( _currentScissor );\n\t\tstate.setScissorTest( _currentScissorTest );\n\n\t\tif ( isCube ) {\n\n\t\t\tconst textureProperties = properties.get( renderTarget.texture );\n\t\t\t_gl.framebufferTexture2D( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_CUBE_MAP_POSITIVE_X + ( activeCubeFace || 0 ), textureProperties.__webglTexture, activeMipmapLevel || 0 );\n\n\t\t}\n\n\t};\n\n\tthis.readRenderTargetPixels = function ( renderTarget, x, y, width, height, buffer, activeCubeFaceIndex ) {\n\n\t\tif ( ! ( renderTarget && renderTarget.isWebGLRenderTarget ) ) {\n\n\t\t\tconsole.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.' );\n\t\t\treturn;\n\n\t\t}\n\n\t\tlet framebuffer = properties.get( renderTarget ).__webglFramebuffer;\n\n\t\tif ( renderTarget.isWebGLCubeRenderTarget && activeCubeFaceIndex !== undefined ) {\n\n\t\t\tframebuffer = framebuffer[ activeCubeFaceIndex ];\n\n\t\t}\n\n\t\tif ( framebuffer ) {\n\n\t\t\tlet restore = false;\n\n\t\t\tif ( framebuffer !== _currentFramebuffer ) {\n\n\t\t\t\t_gl.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );\n\n\t\t\t\trestore = true;\n\n\t\t\t}\n\n\t\t\ttry {\n\n\t\t\t\tconst texture = renderTarget.texture;\n\t\t\t\tconst textureFormat = texture.format;\n\t\t\t\tconst textureType = texture.type;\n\n\t\t\t\tif ( textureFormat !== RGBAFormat && utils.convert( textureFormat ) !== _gl.getParameter( _gl.IMPLEMENTATION_COLOR_READ_FORMAT ) ) {\n\n\t\t\t\t\tconsole.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.' );\n\t\t\t\t\treturn;\n\n\t\t\t\t}\n\n\t\t\t\tif ( textureType !== UnsignedByteType && utils.convert( textureType ) !== _gl.getParameter( _gl.IMPLEMENTATION_COLOR_READ_TYPE ) && // IE11, Edge and Chrome Mac < 52 (#9513)\n\t\t\t\t\t! ( textureType === FloatType && ( capabilities.isWebGL2 || extensions.get( 'OES_texture_float' ) || extensions.get( 'WEBGL_color_buffer_float' ) ) ) && // Chrome Mac >= 52 and Firefox\n\t\t\t\t\t! ( textureType === HalfFloatType && ( capabilities.isWebGL2 ? extensions.get( 'EXT_color_buffer_float' ) : extensions.get( 'EXT_color_buffer_half_float' ) ) ) ) {\n\n\t\t\t\t\tconsole.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.' );\n\t\t\t\t\treturn;\n\n\t\t\t\t}\n\n\t\t\t\tif ( _gl.checkFramebufferStatus( _gl.FRAMEBUFFER ) === _gl.FRAMEBUFFER_COMPLETE ) {\n\n\t\t\t\t\t// the following if statement ensures valid read requests (no out-of-bounds pixels, see #8604)\n\n\t\t\t\t\tif ( ( x >= 0 && x <= ( renderTarget.width - width ) ) && ( y >= 0 && y <= ( renderTarget.height - height ) ) ) {\n\n\t\t\t\t\t\t_gl.readPixels( x, y, width, height, utils.convert( textureFormat ), utils.convert( textureType ), buffer );\n\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\n\t\t\t\t\tconsole.error( 'THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.' );\n\n\t\t\t\t}\n\n\t\t\t} finally {\n\n\t\t\t\tif ( restore ) {\n\n\t\t\t\t\t_gl.bindFramebuffer( _gl.FRAMEBUFFER, _currentFramebuffer );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t};\n\n\tthis.copyFramebufferToTexture = function ( position, texture, level ) {\n\n\t\tif ( level === undefined ) level = 0;\n\n\t\tconst levelScale = Math.pow( 2, - level );\n\t\tconst width = Math.floor( texture.image.width * levelScale );\n\t\tconst height = Math.floor( texture.image.height * levelScale );\n\t\tconst glFormat = utils.convert( texture.format );\n\n\t\ttextures.setTexture2D( texture, 0 );\n\n\t\t_gl.copyTexImage2D( _gl.TEXTURE_2D, level, glFormat, position.x, position.y, width, height, 0 );\n\n\t\tstate.unbindTexture();\n\n\t};\n\n\tthis.copyTextureToTexture = function ( position, srcTexture, dstTexture, level ) {\n\n\t\tif ( level === undefined ) level = 0;\n\n\t\tconst width = srcTexture.image.width;\n\t\tconst height = srcTexture.image.height;\n\t\tconst glFormat = utils.convert( dstTexture.format );\n\t\tconst glType = utils.convert( dstTexture.type );\n\n\t\ttextures.setTexture2D( dstTexture, 0 );\n\n\t\t// As another texture upload may have changed pixelStorei\n\t\t// parameters, make sure they are correct for the dstTexture\n\t\t_gl.pixelStorei( _gl.UNPACK_FLIP_Y_WEBGL, dstTexture.flipY );\n\t\t_gl.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, dstTexture.premultiplyAlpha );\n\t\t_gl.pixelStorei( _gl.UNPACK_ALIGNMENT, dstTexture.unpackAlignment );\n\n\t\tif ( srcTexture.isDataTexture ) {\n\n\t\t\t_gl.texSubImage2D( _gl.TEXTURE_2D, level, position.x, position.y, width, height, glFormat, glType, srcTexture.image.data );\n\n\t\t} else {\n\n\t\t\tif ( srcTexture.isCompressedTexture ) {\n\n\t\t\t\t_gl.compressedTexSubImage2D( _gl.TEXTURE_2D, level, position.x, position.y, srcTexture.mipmaps[ 0 ].width, srcTexture.mipmaps[ 0 ].height, glFormat, srcTexture.mipmaps[ 0 ].data );\n\n\t\t\t} else {\n\n\t\t\t\t_gl.texSubImage2D( _gl.TEXTURE_2D, level, position.x, position.y, glFormat, glType, srcTexture.image );\n\n\t\t\t}\n\n\t\t}\n\n\t\t// Generate mipmaps only when copying level 0\n\t\tif ( level === 0 && dstTexture.generateMipmaps ) _gl.generateMipmap( _gl.TEXTURE_2D );\n\n\t\tstate.unbindTexture();\n\n\t};\n\n\tthis.initTexture = function ( texture ) {\n\n\t\ttextures.setTexture2D( texture, 0 );\n\n\t\tstate.unbindTexture();\n\n\t};\n\n\tif ( typeof __THREE_DEVTOOLS__ !== 'undefined' ) {\n\n\t\t__THREE_DEVTOOLS__.dispatchEvent( new CustomEvent( 'observe', { detail: this } ) ); // eslint-disable-line no-undef\n\n\t}\n\n}\n\nexport { WebGLRenderer };\n","/**\n * @author mrdoob / http://mrdoob.com/\n * @author alteredq / http://alteredqualia.com/\n */\n\nimport { Color } from '../math/Color.js';\n\nfunction Fog( color, near, far ) {\n\n\tthis.name = '';\n\n\tthis.color = new Color( color );\n\n\tthis.near = ( near !== undefined ) ? near : 1;\n\tthis.far = ( far !== undefined ) ? far : 1000;\n\n}\n\nObject.assign( Fog.prototype, {\n\n\tisFog: true,\n\n\tclone: function () {\n\n\t\treturn new Fog( this.color, this.near, this.far );\n\n\t},\n\n\ttoJSON: function ( /* meta */ ) {\n\n\t\treturn {\n\t\t\ttype: 'Fog',\n\t\t\tcolor: this.color.getHex(),\n\t\t\tnear: this.near,\n\t\t\tfar: this.far\n\t\t};\n\n\t}\n\n} );\n\nexport { Fog };\n","import { Material } from './Material.js';\nimport { Color } from '../math/Color.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author alteredq / http://alteredqualia.com/\n *\n * parameters = {\n * color: ,\n * opacity: ,\n *\n * linewidth: ,\n * linecap: \"round\",\n * linejoin: \"round\"\n * }\n */\n\nfunction LineBasicMaterial( parameters ) {\n\n\tMaterial.call( this );\n\n\tthis.type = 'LineBasicMaterial';\n\n\tthis.color = new Color( 0xffffff );\n\n\tthis.linewidth = 1;\n\tthis.linecap = 'round';\n\tthis.linejoin = 'round';\n\n\tthis.morphTargets = false;\n\n\tthis.setValues( parameters );\n\n}\n\nLineBasicMaterial.prototype = Object.create( Material.prototype );\nLineBasicMaterial.prototype.constructor = LineBasicMaterial;\n\nLineBasicMaterial.prototype.isLineBasicMaterial = true;\n\nLineBasicMaterial.prototype.copy = function ( source ) {\n\n\tMaterial.prototype.copy.call( this, source );\n\n\tthis.color.copy( source.color );\n\n\tthis.linewidth = source.linewidth;\n\tthis.linecap = source.linecap;\n\tthis.linejoin = source.linejoin;\n\n\tthis.morphTargets = source.morphTargets;\n\n\treturn this;\n\n};\n\n\nexport { LineBasicMaterial };\n","import { Sphere } from '../math/Sphere.js';\nimport { Ray } from '../math/Ray.js';\nimport { Matrix4 } from '../math/Matrix4.js';\nimport { Object3D } from '../core/Object3D.js';\nimport { Vector3 } from '../math/Vector3.js';\nimport { LineBasicMaterial } from '../materials/LineBasicMaterial.js';\nimport { BufferGeometry } from '../core/BufferGeometry.js';\nimport { Float32BufferAttribute } from '../core/BufferAttribute.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nconst _start = new Vector3();\nconst _end = new Vector3();\nconst _inverseMatrix = new Matrix4();\nconst _ray = new Ray();\nconst _sphere = new Sphere();\n\nfunction Line( geometry, material, mode ) {\n\n\tif ( mode === 1 ) {\n\n\t\tconsole.error( 'THREE.Line: parameter THREE.LinePieces no longer supported. Use THREE.LineSegments instead.' );\n\n\t}\n\n\tObject3D.call( this );\n\n\tthis.type = 'Line';\n\n\tthis.geometry = geometry !== undefined ? geometry : new BufferGeometry();\n\tthis.material = material !== undefined ? material : new LineBasicMaterial();\n\n\tthis.updateMorphTargets();\n\n}\n\nLine.prototype = Object.assign( Object.create( Object3D.prototype ), {\n\n\tconstructor: Line,\n\n\tisLine: true,\n\n\tcopy: function ( source ) {\n\n\t\tObject3D.prototype.copy.call( this, source );\n\n\t\tthis.material = source.material;\n\t\tthis.geometry = source.geometry;\n\n\t\treturn this;\n\n\t},\n\n\tcomputeLineDistances: function () {\n\n\t\tconst geometry = this.geometry;\n\n\t\tif ( geometry.isBufferGeometry ) {\n\n\t\t\t// we assume non-indexed geometry\n\n\t\t\tif ( geometry.index === null ) {\n\n\t\t\t\tconst positionAttribute = geometry.attributes.position;\n\t\t\t\tconst lineDistances = [ 0 ];\n\n\t\t\t\tfor ( let i = 1, l = positionAttribute.count; i < l; i ++ ) {\n\n\t\t\t\t\t_start.fromBufferAttribute( positionAttribute, i - 1 );\n\t\t\t\t\t_end.fromBufferAttribute( positionAttribute, i );\n\n\t\t\t\t\tlineDistances[ i ] = lineDistances[ i - 1 ];\n\t\t\t\t\tlineDistances[ i ] += _start.distanceTo( _end );\n\n\t\t\t\t}\n\n\t\t\t\tgeometry.setAttribute( 'lineDistance', new Float32BufferAttribute( lineDistances, 1 ) );\n\n\t\t\t} else {\n\n\t\t\t\tconsole.warn( 'THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.' );\n\n\t\t\t}\n\n\t\t} else if ( geometry.isGeometry ) {\n\n\t\t\tconst vertices = geometry.vertices;\n\t\t\tconst lineDistances = geometry.lineDistances;\n\n\t\t\tlineDistances[ 0 ] = 0;\n\n\t\t\tfor ( let i = 1, l = vertices.length; i < l; i ++ ) {\n\n\t\t\t\tlineDistances[ i ] = lineDistances[ i - 1 ];\n\t\t\t\tlineDistances[ i ] += vertices[ i - 1 ].distanceTo( vertices[ i ] );\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\traycast: function ( raycaster, intersects ) {\n\n\t\tconst geometry = this.geometry;\n\t\tconst matrixWorld = this.matrixWorld;\n\t\tconst threshold = raycaster.params.Line.threshold;\n\n\t\t// Checking boundingSphere distance to ray\n\n\t\tif ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();\n\n\t\t_sphere.copy( geometry.boundingSphere );\n\t\t_sphere.applyMatrix4( matrixWorld );\n\t\t_sphere.radius += threshold;\n\n\t\tif ( raycaster.ray.intersectsSphere( _sphere ) === false ) return;\n\n\t\t//\n\n\t\t_inverseMatrix.getInverse( matrixWorld );\n\t\t_ray.copy( raycaster.ray ).applyMatrix4( _inverseMatrix );\n\n\t\tconst localThreshold = threshold / ( ( this.scale.x + this.scale.y + this.scale.z ) / 3 );\n\t\tconst localThresholdSq = localThreshold * localThreshold;\n\n\t\tconst vStart = new Vector3();\n\t\tconst vEnd = new Vector3();\n\t\tconst interSegment = new Vector3();\n\t\tconst interRay = new Vector3();\n\t\tconst step = ( this && this.isLineSegments ) ? 2 : 1;\n\n\t\tif ( geometry.isBufferGeometry ) {\n\n\t\t\tconst index = geometry.index;\n\t\t\tconst attributes = geometry.attributes;\n\t\t\tconst positions = attributes.position.array;\n\n\t\t\tif ( index !== null ) {\n\n\t\t\t\tconst indices = index.array;\n\n\t\t\t\tfor ( let i = 0, l = indices.length - 1; i < l; i += step ) {\n\n\t\t\t\t\tconst a = indices[ i ];\n\t\t\t\t\tconst b = indices[ i + 1 ];\n\n\t\t\t\t\tvStart.fromArray( positions, a * 3 );\n\t\t\t\t\tvEnd.fromArray( positions, b * 3 );\n\n\t\t\t\t\tconst distSq = _ray.distanceSqToSegment( vStart, vEnd, interRay, interSegment );\n\n\t\t\t\t\tif ( distSq > localThresholdSq ) continue;\n\n\t\t\t\t\tinterRay.applyMatrix4( this.matrixWorld ); //Move back to world space for distance calculation\n\n\t\t\t\t\tconst distance = raycaster.ray.origin.distanceTo( interRay );\n\n\t\t\t\t\tif ( distance < raycaster.near || distance > raycaster.far ) continue;\n\n\t\t\t\t\tintersects.push( {\n\n\t\t\t\t\t\tdistance: distance,\n\t\t\t\t\t\t// What do we want? intersection point on the ray or on the segment??\n\t\t\t\t\t\t// point: raycaster.ray.at( distance ),\n\t\t\t\t\t\tpoint: interSegment.clone().applyMatrix4( this.matrixWorld ),\n\t\t\t\t\t\tindex: i,\n\t\t\t\t\t\tface: null,\n\t\t\t\t\t\tfaceIndex: null,\n\t\t\t\t\t\tobject: this\n\n\t\t\t\t\t} );\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\tfor ( let i = 0, l = positions.length / 3 - 1; i < l; i += step ) {\n\n\t\t\t\t\tvStart.fromArray( positions, 3 * i );\n\t\t\t\t\tvEnd.fromArray( positions, 3 * i + 3 );\n\n\t\t\t\t\tconst distSq = _ray.distanceSqToSegment( vStart, vEnd, interRay, interSegment );\n\n\t\t\t\t\tif ( distSq > localThresholdSq ) continue;\n\n\t\t\t\t\tinterRay.applyMatrix4( this.matrixWorld ); //Move back to world space for distance calculation\n\n\t\t\t\t\tconst distance = raycaster.ray.origin.distanceTo( interRay );\n\n\t\t\t\t\tif ( distance < raycaster.near || distance > raycaster.far ) continue;\n\n\t\t\t\t\tintersects.push( {\n\n\t\t\t\t\t\tdistance: distance,\n\t\t\t\t\t\t// What do we want? intersection point on the ray or on the segment??\n\t\t\t\t\t\t// point: raycaster.ray.at( distance ),\n\t\t\t\t\t\tpoint: interSegment.clone().applyMatrix4( this.matrixWorld ),\n\t\t\t\t\t\tindex: i,\n\t\t\t\t\t\tface: null,\n\t\t\t\t\t\tfaceIndex: null,\n\t\t\t\t\t\tobject: this\n\n\t\t\t\t\t} );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} else if ( geometry.isGeometry ) {\n\n\t\t\tconst vertices = geometry.vertices;\n\t\t\tconst nbVertices = vertices.length;\n\n\t\t\tfor ( let i = 0; i < nbVertices - 1; i += step ) {\n\n\t\t\t\tconst distSq = _ray.distanceSqToSegment( vertices[ i ], vertices[ i + 1 ], interRay, interSegment );\n\n\t\t\t\tif ( distSq > localThresholdSq ) continue;\n\n\t\t\t\tinterRay.applyMatrix4( this.matrixWorld ); //Move back to world space for distance calculation\n\n\t\t\t\tconst distance = raycaster.ray.origin.distanceTo( interRay );\n\n\t\t\t\tif ( distance < raycaster.near || distance > raycaster.far ) continue;\n\n\t\t\t\tintersects.push( {\n\n\t\t\t\t\tdistance: distance,\n\t\t\t\t\t// What do we want? intersection point on the ray or on the segment??\n\t\t\t\t\t// point: raycaster.ray.at( distance ),\n\t\t\t\t\tpoint: interSegment.clone().applyMatrix4( this.matrixWorld ),\n\t\t\t\t\tindex: i,\n\t\t\t\t\tface: null,\n\t\t\t\t\tfaceIndex: null,\n\t\t\t\t\tobject: this\n\n\t\t\t\t} );\n\n\t\t\t}\n\n\t\t}\n\n\t},\n\n\tupdateMorphTargets: function () {\n\n\t\tconst geometry = this.geometry;\n\n\t\tif ( geometry.isBufferGeometry ) {\n\n\t\t\tconst morphAttributes = geometry.morphAttributes;\n\t\t\tconst keys = Object.keys( morphAttributes );\n\n\t\t\tif ( keys.length > 0 ) {\n\n\t\t\t\tconst morphAttribute = morphAttributes[ keys[ 0 ] ];\n\n\t\t\t\tif ( morphAttribute !== undefined ) {\n\n\t\t\t\t\tthis.morphTargetInfluences = [];\n\t\t\t\t\tthis.morphTargetDictionary = {};\n\n\t\t\t\t\tfor ( let m = 0, ml = morphAttribute.length; m < ml; m ++ ) {\n\n\t\t\t\t\t\tconst name = morphAttribute[ m ].name || String( m );\n\n\t\t\t\t\t\tthis.morphTargetInfluences.push( 0 );\n\t\t\t\t\t\tthis.morphTargetDictionary[ name ] = m;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tconst morphTargets = geometry.morphTargets;\n\n\t\t\tif ( morphTargets !== undefined && morphTargets.length > 0 ) {\n\n\t\t\t\tconsole.error( 'THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.' );\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n} );\n\n\nexport { Line };\n","import { Line } from './Line.js';\nimport { Vector3 } from '../math/Vector3.js';\nimport { Float32BufferAttribute } from '../core/BufferAttribute.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nconst _start = new Vector3();\nconst _end = new Vector3();\n\nfunction LineSegments( geometry, material ) {\n\n\tLine.call( this, geometry, material );\n\n\tthis.type = 'LineSegments';\n\n}\n\nLineSegments.prototype = Object.assign( Object.create( Line.prototype ), {\n\n\tconstructor: LineSegments,\n\n\tisLineSegments: true,\n\n\tcomputeLineDistances: function () {\n\n\t\tconst geometry = this.geometry;\n\n\t\tif ( geometry.isBufferGeometry ) {\n\n\t\t\t// we assume non-indexed geometry\n\n\t\t\tif ( geometry.index === null ) {\n\n\t\t\t\tconst positionAttribute = geometry.attributes.position;\n\t\t\t\tconst lineDistances = [];\n\n\t\t\t\tfor ( let i = 0, l = positionAttribute.count; i < l; i += 2 ) {\n\n\t\t\t\t\t_start.fromBufferAttribute( positionAttribute, i );\n\t\t\t\t\t_end.fromBufferAttribute( positionAttribute, i + 1 );\n\n\t\t\t\t\tlineDistances[ i ] = ( i === 0 ) ? 0 : lineDistances[ i - 1 ];\n\t\t\t\t\tlineDistances[ i + 1 ] = lineDistances[ i ] + _start.distanceTo( _end );\n\n\t\t\t\t}\n\n\t\t\t\tgeometry.setAttribute( 'lineDistance', new Float32BufferAttribute( lineDistances, 1 ) );\n\n\t\t\t} else {\n\n\t\t\t\tconsole.warn( 'THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.' );\n\n\t\t\t}\n\n\t\t} else if ( geometry.isGeometry ) {\n\n\t\t\tconst vertices = geometry.vertices;\n\t\t\tconst lineDistances = geometry.lineDistances;\n\n\t\t\tfor ( let i = 0, l = vertices.length; i < l; i += 2 ) {\n\n\t\t\t\t_start.copy( vertices[ i ] );\n\t\t\t\t_end.copy( vertices[ i + 1 ] );\n\n\t\t\t\tlineDistances[ i ] = ( i === 0 ) ? 0 : lineDistances[ i - 1 ];\n\t\t\t\tlineDistances[ i + 1 ] = lineDistances[ i ] + _start.distanceTo( _end );\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn this;\n\n\t}\n\n} );\n\n\nexport { LineSegments };\n","import { Material } from './Material.js';\nimport { Color } from '../math/Color.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author alteredq / http://alteredqualia.com/\n *\n * parameters = {\n * color: ,\n * opacity: ,\n * map: new THREE.Texture( ),\n * alphaMap: new THREE.Texture( ),\n *\n * size: ,\n * sizeAttenuation: \n *\n * morphTargets: \n * }\n */\n\nfunction PointsMaterial( parameters ) {\n\n\tMaterial.call( this );\n\n\tthis.type = 'PointsMaterial';\n\n\tthis.color = new Color( 0xffffff );\n\n\tthis.map = null;\n\n\tthis.alphaMap = null;\n\n\tthis.size = 1;\n\tthis.sizeAttenuation = true;\n\n\tthis.morphTargets = false;\n\n\tthis.setValues( parameters );\n\n}\n\nPointsMaterial.prototype = Object.create( Material.prototype );\nPointsMaterial.prototype.constructor = PointsMaterial;\n\nPointsMaterial.prototype.isPointsMaterial = true;\n\nPointsMaterial.prototype.copy = function ( source ) {\n\n\tMaterial.prototype.copy.call( this, source );\n\n\tthis.color.copy( source.color );\n\n\tthis.map = source.map;\n\n\tthis.alphaMap = source.alphaMap;\n\n\tthis.size = source.size;\n\tthis.sizeAttenuation = source.sizeAttenuation;\n\n\tthis.morphTargets = source.morphTargets;\n\n\treturn this;\n\n};\n\n\nexport { PointsMaterial };\n","import { Sphere } from '../math/Sphere.js';\nimport { Ray } from '../math/Ray.js';\nimport { Matrix4 } from '../math/Matrix4.js';\nimport { Object3D } from '../core/Object3D.js';\nimport { Vector3 } from '../math/Vector3.js';\nimport { PointsMaterial } from '../materials/PointsMaterial.js';\nimport { BufferGeometry } from '../core/BufferGeometry.js';\n\n/**\n * @author alteredq / http://alteredqualia.com/\n */\n\nconst _inverseMatrix = new Matrix4();\nconst _ray = new Ray();\nconst _sphere = new Sphere();\nconst _position = new Vector3();\n\nfunction Points( geometry, material ) {\n\n\tObject3D.call( this );\n\n\tthis.type = 'Points';\n\n\tthis.geometry = geometry !== undefined ? geometry : new BufferGeometry();\n\tthis.material = material !== undefined ? material : new PointsMaterial();\n\n\tthis.updateMorphTargets();\n\n}\n\nPoints.prototype = Object.assign( Object.create( Object3D.prototype ), {\n\n\tconstructor: Points,\n\n\tisPoints: true,\n\n\tcopy: function ( source ) {\n\n\t\tObject3D.prototype.copy.call( this, source );\n\n\t\tthis.material = source.material;\n\t\tthis.geometry = source.geometry;\n\n\t\treturn this;\n\n\t},\n\n\traycast: function ( raycaster, intersects ) {\n\n\t\tconst geometry = this.geometry;\n\t\tconst matrixWorld = this.matrixWorld;\n\t\tconst threshold = raycaster.params.Points.threshold;\n\n\t\t// Checking boundingSphere distance to ray\n\n\t\tif ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();\n\n\t\t_sphere.copy( geometry.boundingSphere );\n\t\t_sphere.applyMatrix4( matrixWorld );\n\t\t_sphere.radius += threshold;\n\n\t\tif ( raycaster.ray.intersectsSphere( _sphere ) === false ) return;\n\n\t\t//\n\n\t\t_inverseMatrix.getInverse( matrixWorld );\n\t\t_ray.copy( raycaster.ray ).applyMatrix4( _inverseMatrix );\n\n\t\tconst localThreshold = threshold / ( ( this.scale.x + this.scale.y + this.scale.z ) / 3 );\n\t\tconst localThresholdSq = localThreshold * localThreshold;\n\n\t\tif ( geometry.isBufferGeometry ) {\n\n\t\t\tconst index = geometry.index;\n\t\t\tconst attributes = geometry.attributes;\n\t\t\tconst positions = attributes.position.array;\n\n\t\t\tif ( index !== null ) {\n\n\t\t\t\tconst indices = index.array;\n\n\t\t\t\tfor ( let i = 0, il = indices.length; i < il; i ++ ) {\n\n\t\t\t\t\tconst a = indices[ i ];\n\n\t\t\t\t\t_position.fromArray( positions, a * 3 );\n\n\t\t\t\t\ttestPoint( _position, a, localThresholdSq, matrixWorld, raycaster, intersects, this );\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\tfor ( let i = 0, l = positions.length / 3; i < l; i ++ ) {\n\n\t\t\t\t\t_position.fromArray( positions, i * 3 );\n\n\t\t\t\t\ttestPoint( _position, i, localThresholdSq, matrixWorld, raycaster, intersects, this );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tconst vertices = geometry.vertices;\n\n\t\t\tfor ( let i = 0, l = vertices.length; i < l; i ++ ) {\n\n\t\t\t\ttestPoint( vertices[ i ], i, localThresholdSq, matrixWorld, raycaster, intersects, this );\n\n\t\t\t}\n\n\t\t}\n\n\t},\n\n\tupdateMorphTargets: function () {\n\n\t\tconst geometry = this.geometry;\n\n\t\tif ( geometry.isBufferGeometry ) {\n\n\t\t\tconst morphAttributes = geometry.morphAttributes;\n\t\t\tconst keys = Object.keys( morphAttributes );\n\n\t\t\tif ( keys.length > 0 ) {\n\n\t\t\t\tconst morphAttribute = morphAttributes[ keys[ 0 ] ];\n\n\t\t\t\tif ( morphAttribute !== undefined ) {\n\n\t\t\t\t\tthis.morphTargetInfluences = [];\n\t\t\t\t\tthis.morphTargetDictionary = {};\n\n\t\t\t\t\tfor ( let m = 0, ml = morphAttribute.length; m < ml; m ++ ) {\n\n\t\t\t\t\t\tconst name = morphAttribute[ m ].name || String( m );\n\n\t\t\t\t\t\tthis.morphTargetInfluences.push( 0 );\n\t\t\t\t\t\tthis.morphTargetDictionary[ name ] = m;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tconst morphTargets = geometry.morphTargets;\n\n\t\t\tif ( morphTargets !== undefined && morphTargets.length > 0 ) {\n\n\t\t\t\tconsole.error( 'THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.' );\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n} );\n\nfunction testPoint( point, index, localThresholdSq, matrixWorld, raycaster, intersects, object ) {\n\n\tconst rayPointDistanceSq = _ray.distanceSqToPoint( point );\n\n\tif ( rayPointDistanceSq < localThresholdSq ) {\n\n\t\tconst intersectPoint = new Vector3();\n\n\t\t_ray.closestPointToPoint( point, intersectPoint );\n\t\tintersectPoint.applyMatrix4( matrixWorld );\n\n\t\tconst distance = raycaster.ray.origin.distanceTo( intersectPoint );\n\n\t\tif ( distance < raycaster.near || distance > raycaster.far ) return;\n\n\t\tintersects.push( {\n\n\t\t\tdistance: distance,\n\t\t\tdistanceToRay: Math.sqrt( rayPointDistanceSq ),\n\t\t\tpoint: intersectPoint,\n\t\t\tindex: index,\n\t\t\tface: null,\n\t\t\tobject: object\n\n\t\t} );\n\n\t}\n\n}\n\nexport { Points };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { Texture } from './Texture.js';\n\nfunction CanvasTexture( canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ) {\n\n\tTexture.call( this, canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy );\n\n\tthis.needsUpdate = true;\n\n}\n\nCanvasTexture.prototype = Object.create( Texture.prototype );\nCanvasTexture.prototype.constructor = CanvasTexture;\nCanvasTexture.prototype.isCanvasTexture = true;\n\nexport { CanvasTexture };\n","/**\n * @author clockworkgeek / https://github.com/clockworkgeek\n * @author timothypratley / https://github.com/timothypratley\n * @author WestLangley / http://github.com/WestLangley\n * @author Mugen87 / https://github.com/Mugen87\n */\n\nimport { Geometry } from '../core/Geometry.js';\nimport { BufferGeometry } from '../core/BufferGeometry.js';\nimport { Float32BufferAttribute } from '../core/BufferAttribute.js';\nimport { Vector3 } from '../math/Vector3.js';\nimport { Vector2 } from '../math/Vector2.js';\n\n// PolyhedronGeometry\n\nfunction PolyhedronGeometry( vertices, indices, radius, detail ) {\n\n\tGeometry.call( this );\n\n\tthis.type = 'PolyhedronGeometry';\n\n\tthis.parameters = {\n\t\tvertices: vertices,\n\t\tindices: indices,\n\t\tradius: radius,\n\t\tdetail: detail\n\t};\n\n\tthis.fromBufferGeometry( new PolyhedronBufferGeometry( vertices, indices, radius, detail ) );\n\tthis.mergeVertices();\n\n}\n\nPolyhedronGeometry.prototype = Object.create( Geometry.prototype );\nPolyhedronGeometry.prototype.constructor = PolyhedronGeometry;\n\n// PolyhedronBufferGeometry\n\nfunction PolyhedronBufferGeometry( vertices, indices, radius, detail ) {\n\n\tBufferGeometry.call( this );\n\n\tthis.type = 'PolyhedronBufferGeometry';\n\n\tthis.parameters = {\n\t\tvertices: vertices,\n\t\tindices: indices,\n\t\tradius: radius,\n\t\tdetail: detail\n\t};\n\n\tradius = radius || 1;\n\tdetail = detail || 0;\n\n\t// default buffer data\n\n\tconst vertexBuffer = [];\n\tconst uvBuffer = [];\n\n\t// the subdivision creates the vertex buffer data\n\n\tsubdivide( detail );\n\n\t// all vertices should lie on a conceptual sphere with a given radius\n\n\tapplyRadius( radius );\n\n\t// finally, create the uv data\n\n\tgenerateUVs();\n\n\t// build non-indexed geometry\n\n\tthis.setAttribute( 'position', new Float32BufferAttribute( vertexBuffer, 3 ) );\n\tthis.setAttribute( 'normal', new Float32BufferAttribute( vertexBuffer.slice(), 3 ) );\n\tthis.setAttribute( 'uv', new Float32BufferAttribute( uvBuffer, 2 ) );\n\n\tif ( detail === 0 ) {\n\n\t\tthis.computeVertexNormals(); // flat normals\n\n\t} else {\n\n\t\tthis.normalizeNormals(); // smooth normals\n\n\t}\n\n\t// helper functions\n\n\tfunction subdivide( detail ) {\n\n\t\tconst a = new Vector3();\n\t\tconst b = new Vector3();\n\t\tconst c = new Vector3();\n\n\t\t// iterate over all faces and apply a subdivison with the given detail value\n\n\t\tfor ( let i = 0; i < indices.length; i += 3 ) {\n\n\t\t\t// get the vertices of the face\n\n\t\t\tgetVertexByIndex( indices[ i + 0 ], a );\n\t\t\tgetVertexByIndex( indices[ i + 1 ], b );\n\t\t\tgetVertexByIndex( indices[ i + 2 ], c );\n\n\t\t\t// perform subdivision\n\n\t\t\tsubdivideFace( a, b, c, detail );\n\n\t\t}\n\n\t}\n\n\tfunction subdivideFace( a, b, c, detail ) {\n\n\t\tconst cols = Math.pow( 2, detail );\n\n\t\t// we use this multidimensional array as a data structure for creating the subdivision\n\n\t\tconst v = [];\n\n\t\t// construct all of the vertices for this subdivision\n\n\t\tfor ( let i = 0; i <= cols; i ++ ) {\n\n\t\t\tv[ i ] = [];\n\n\t\t\tconst aj = a.clone().lerp( c, i / cols );\n\t\t\tconst bj = b.clone().lerp( c, i / cols );\n\n\t\t\tconst rows = cols - i;\n\n\t\t\tfor ( let j = 0; j <= rows; j ++ ) {\n\n\t\t\t\tif ( j === 0 && i === cols ) {\n\n\t\t\t\t\tv[ i ][ j ] = aj;\n\n\t\t\t\t} else {\n\n\t\t\t\t\tv[ i ][ j ] = aj.clone().lerp( bj, j / rows );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\t// construct all of the faces\n\n\t\tfor ( let i = 0; i < cols; i ++ ) {\n\n\t\t\tfor ( let j = 0; j < 2 * ( cols - i ) - 1; j ++ ) {\n\n\t\t\t\tconst k = Math.floor( j / 2 );\n\n\t\t\t\tif ( j % 2 === 0 ) {\n\n\t\t\t\t\tpushVertex( v[ i ][ k + 1 ] );\n\t\t\t\t\tpushVertex( v[ i + 1 ][ k ] );\n\t\t\t\t\tpushVertex( v[ i ][ k ] );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tpushVertex( v[ i ][ k + 1 ] );\n\t\t\t\t\tpushVertex( v[ i + 1 ][ k + 1 ] );\n\t\t\t\t\tpushVertex( v[ i + 1 ][ k ] );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tfunction applyRadius( radius ) {\n\n\t\tconst vertex = new Vector3();\n\n\t\t// iterate over the entire buffer and apply the radius to each vertex\n\n\t\tfor ( let i = 0; i < vertexBuffer.length; i += 3 ) {\n\n\t\t\tvertex.x = vertexBuffer[ i + 0 ];\n\t\t\tvertex.y = vertexBuffer[ i + 1 ];\n\t\t\tvertex.z = vertexBuffer[ i + 2 ];\n\n\t\t\tvertex.normalize().multiplyScalar( radius );\n\n\t\t\tvertexBuffer[ i + 0 ] = vertex.x;\n\t\t\tvertexBuffer[ i + 1 ] = vertex.y;\n\t\t\tvertexBuffer[ i + 2 ] = vertex.z;\n\n\t\t}\n\n\t}\n\n\tfunction generateUVs() {\n\n\t\tconst vertex = new Vector3();\n\n\t\tfor ( let i = 0; i < vertexBuffer.length; i += 3 ) {\n\n\t\t\tvertex.x = vertexBuffer[ i + 0 ];\n\t\t\tvertex.y = vertexBuffer[ i + 1 ];\n\t\t\tvertex.z = vertexBuffer[ i + 2 ];\n\n\t\t\tconst u = azimuth( vertex ) / 2 / Math.PI + 0.5;\n\t\t\tconst v = inclination( vertex ) / Math.PI + 0.5;\n\t\t\tuvBuffer.push( u, 1 - v );\n\n\t\t}\n\n\t\tcorrectUVs();\n\n\t\tcorrectSeam();\n\n\t}\n\n\tfunction correctSeam() {\n\n\t\t// handle case when face straddles the seam, see #3269\n\n\t\tfor ( let i = 0; i < uvBuffer.length; i += 6 ) {\n\n\t\t\t// uv data of a single face\n\n\t\t\tconst x0 = uvBuffer[ i + 0 ];\n\t\t\tconst x1 = uvBuffer[ i + 2 ];\n\t\t\tconst x2 = uvBuffer[ i + 4 ];\n\n\t\t\tconst max = Math.max( x0, x1, x2 );\n\t\t\tconst min = Math.min( x0, x1, x2 );\n\n\t\t\t// 0.9 is somewhat arbitrary\n\n\t\t\tif ( max > 0.9 && min < 0.1 ) {\n\n\t\t\t\tif ( x0 < 0.2 ) uvBuffer[ i + 0 ] += 1;\n\t\t\t\tif ( x1 < 0.2 ) uvBuffer[ i + 2 ] += 1;\n\t\t\t\tif ( x2 < 0.2 ) uvBuffer[ i + 4 ] += 1;\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tfunction pushVertex( vertex ) {\n\n\t\tvertexBuffer.push( vertex.x, vertex.y, vertex.z );\n\n\t}\n\n\tfunction getVertexByIndex( index, vertex ) {\n\n\t\tconst stride = index * 3;\n\n\t\tvertex.x = vertices[ stride + 0 ];\n\t\tvertex.y = vertices[ stride + 1 ];\n\t\tvertex.z = vertices[ stride + 2 ];\n\n\t}\n\n\tfunction correctUVs() {\n\n\t\tconst a = new Vector3();\n\t\tconst b = new Vector3();\n\t\tconst c = new Vector3();\n\n\t\tconst centroid = new Vector3();\n\n\t\tconst uvA = new Vector2();\n\t\tconst uvB = new Vector2();\n\t\tconst uvC = new Vector2();\n\n\t\tfor ( let i = 0, j = 0; i < vertexBuffer.length; i += 9, j += 6 ) {\n\n\t\t\ta.set( vertexBuffer[ i + 0 ], vertexBuffer[ i + 1 ], vertexBuffer[ i + 2 ] );\n\t\t\tb.set( vertexBuffer[ i + 3 ], vertexBuffer[ i + 4 ], vertexBuffer[ i + 5 ] );\n\t\t\tc.set( vertexBuffer[ i + 6 ], vertexBuffer[ i + 7 ], vertexBuffer[ i + 8 ] );\n\n\t\t\tuvA.set( uvBuffer[ j + 0 ], uvBuffer[ j + 1 ] );\n\t\t\tuvB.set( uvBuffer[ j + 2 ], uvBuffer[ j + 3 ] );\n\t\t\tuvC.set( uvBuffer[ j + 4 ], uvBuffer[ j + 5 ] );\n\n\t\t\tcentroid.copy( a ).add( b ).add( c ).divideScalar( 3 );\n\n\t\t\tconst azi = azimuth( centroid );\n\n\t\t\tcorrectUV( uvA, j + 0, a, azi );\n\t\t\tcorrectUV( uvB, j + 2, b, azi );\n\t\t\tcorrectUV( uvC, j + 4, c, azi );\n\n\t\t}\n\n\t}\n\n\tfunction correctUV( uv, stride, vector, azimuth ) {\n\n\t\tif ( ( azimuth < 0 ) && ( uv.x === 1 ) ) {\n\n\t\t\tuvBuffer[ stride ] = uv.x - 1;\n\n\t\t}\n\n\t\tif ( ( vector.x === 0 ) && ( vector.z === 0 ) ) {\n\n\t\t\tuvBuffer[ stride ] = azimuth / 2 / Math.PI + 0.5;\n\n\t\t}\n\n\t}\n\n\t// Angle around the Y axis, counter-clockwise when looking from above.\n\n\tfunction azimuth( vector ) {\n\n\t\treturn Math.atan2( vector.z, - vector.x );\n\n\t}\n\n\n\t// Angle above the XZ plane.\n\n\tfunction inclination( vector ) {\n\n\t\treturn Math.atan2( - vector.y, Math.sqrt( ( vector.x * vector.x ) + ( vector.z * vector.z ) ) );\n\n\t}\n\n}\n\nPolyhedronBufferGeometry.prototype = Object.create( BufferGeometry.prototype );\nPolyhedronBufferGeometry.prototype.constructor = PolyhedronBufferGeometry;\n\n\nexport { PolyhedronGeometry, PolyhedronBufferGeometry };\n","/**\n * @author timothypratley / https://github.com/timothypratley\n * @author Mugen87 / https://github.com/Mugen87\n */\n\nimport { Geometry } from '../core/Geometry.js';\nimport { PolyhedronBufferGeometry } from './PolyhedronGeometry.js';\n\n// TetrahedronGeometry\n\nfunction TetrahedronGeometry( radius, detail ) {\n\n\tGeometry.call( this );\n\n\tthis.type = 'TetrahedronGeometry';\n\n\tthis.parameters = {\n\t\tradius: radius,\n\t\tdetail: detail\n\t};\n\n\tthis.fromBufferGeometry( new TetrahedronBufferGeometry( radius, detail ) );\n\tthis.mergeVertices();\n\n}\n\nTetrahedronGeometry.prototype = Object.create( Geometry.prototype );\nTetrahedronGeometry.prototype.constructor = TetrahedronGeometry;\n\n// TetrahedronBufferGeometry\n\nfunction TetrahedronBufferGeometry( radius, detail ) {\n\n\tconst vertices = [\n\t\t1, 1, 1, \t- 1, - 1, 1, \t- 1, 1, - 1, \t1, - 1, - 1\n\t];\n\n\tconst indices = [\n\t\t2, 1, 0, \t0, 3, 2,\t1, 3, 0,\t2, 3, 1\n\t];\n\n\tPolyhedronBufferGeometry.call( this, vertices, indices, radius, detail );\n\n\tthis.type = 'TetrahedronBufferGeometry';\n\n\tthis.parameters = {\n\t\tradius: radius,\n\t\tdetail: detail\n\t};\n\n}\n\nTetrahedronBufferGeometry.prototype = Object.create( PolyhedronBufferGeometry.prototype );\nTetrahedronBufferGeometry.prototype.constructor = TetrahedronBufferGeometry;\n\n\nexport { TetrahedronGeometry, TetrahedronBufferGeometry };\n","/**\n * @author timothypratley / https://github.com/timothypratley\n * @author Mugen87 / https://github.com/Mugen87\n */\n\nimport { Geometry } from '../core/Geometry.js';\nimport { PolyhedronBufferGeometry } from './PolyhedronGeometry.js';\n\n// OctahedronGeometry\n\nfunction OctahedronGeometry( radius, detail ) {\n\n\tGeometry.call( this );\n\n\tthis.type = 'OctahedronGeometry';\n\n\tthis.parameters = {\n\t\tradius: radius,\n\t\tdetail: detail\n\t};\n\n\tthis.fromBufferGeometry( new OctahedronBufferGeometry( radius, detail ) );\n\tthis.mergeVertices();\n\n}\n\nOctahedronGeometry.prototype = Object.create( Geometry.prototype );\nOctahedronGeometry.prototype.constructor = OctahedronGeometry;\n\n// OctahedronBufferGeometry\n\nfunction OctahedronBufferGeometry( radius, detail ) {\n\n\tconst vertices = [\n\t\t1, 0, 0, \t- 1, 0, 0,\t0, 1, 0,\n\t\t0, - 1, 0, \t0, 0, 1,\t0, 0, - 1\n\t];\n\n\tconst indices = [\n\t\t0, 2, 4,\t0, 4, 3,\t0, 3, 5,\n\t\t0, 5, 2,\t1, 2, 5,\t1, 5, 3,\n\t\t1, 3, 4,\t1, 4, 2\n\t];\n\n\tPolyhedronBufferGeometry.call( this, vertices, indices, radius, detail );\n\n\tthis.type = 'OctahedronBufferGeometry';\n\n\tthis.parameters = {\n\t\tradius: radius,\n\t\tdetail: detail\n\t};\n\n}\n\nOctahedronBufferGeometry.prototype = Object.create( PolyhedronBufferGeometry.prototype );\nOctahedronBufferGeometry.prototype.constructor = OctahedronBufferGeometry;\n\n\nexport { OctahedronGeometry, OctahedronBufferGeometry };\n","/**\n * @author timothypratley / https://github.com/timothypratley\n * @author Mugen87 / https://github.com/Mugen87\n */\n\nimport { Geometry } from '../core/Geometry.js';\nimport { PolyhedronBufferGeometry } from './PolyhedronGeometry.js';\n\n// IcosahedronGeometry\n\nfunction IcosahedronGeometry( radius, detail ) {\n\n\tGeometry.call( this );\n\n\tthis.type = 'IcosahedronGeometry';\n\n\tthis.parameters = {\n\t\tradius: radius,\n\t\tdetail: detail\n\t};\n\n\tthis.fromBufferGeometry( new IcosahedronBufferGeometry( radius, detail ) );\n\tthis.mergeVertices();\n\n}\n\nIcosahedronGeometry.prototype = Object.create( Geometry.prototype );\nIcosahedronGeometry.prototype.constructor = IcosahedronGeometry;\n\n// IcosahedronBufferGeometry\n\nfunction IcosahedronBufferGeometry( radius, detail ) {\n\n\tconst t = ( 1 + Math.sqrt( 5 ) ) / 2;\n\n\tconst vertices = [\n\t\t- 1, t, 0, \t1, t, 0, \t- 1, - t, 0, \t1, - t, 0,\n\t\t 0, - 1, t, \t0, 1, t,\t0, - 1, - t, \t0, 1, - t,\n\t\t t, 0, - 1, \tt, 0, 1, \t- t, 0, - 1, \t- t, 0, 1\n\t];\n\n\tconst indices = [\n\t\t 0, 11, 5, \t0, 5, 1, \t0, 1, 7, \t0, 7, 10, \t0, 10, 11,\n\t\t 1, 5, 9, \t5, 11, 4,\t11, 10, 2,\t10, 7, 6,\t7, 1, 8,\n\t\t 3, 9, 4, \t3, 4, 2,\t3, 2, 6,\t3, 6, 8,\t3, 8, 9,\n\t\t 4, 9, 5, \t2, 4, 11,\t6, 2, 10,\t8, 6, 7,\t9, 8, 1\n\t];\n\n\tPolyhedronBufferGeometry.call( this, vertices, indices, radius, detail );\n\n\tthis.type = 'IcosahedronBufferGeometry';\n\n\tthis.parameters = {\n\t\tradius: radius,\n\t\tdetail: detail\n\t};\n\n}\n\nIcosahedronBufferGeometry.prototype = Object.create( PolyhedronBufferGeometry.prototype );\nIcosahedronBufferGeometry.prototype.constructor = IcosahedronBufferGeometry;\n\n\nexport { IcosahedronGeometry, IcosahedronBufferGeometry };\n","/**\n * @author oosmoxiecode\n * @author mrdoob / http://mrdoob.com/\n * @author Mugen87 / https://github.com/Mugen87\n */\n\nimport { Geometry } from '../core/Geometry.js';\nimport { BufferGeometry } from '../core/BufferGeometry.js';\nimport { Float32BufferAttribute } from '../core/BufferAttribute.js';\nimport { Vector3 } from '../math/Vector3.js';\n\n// TorusGeometry\n\nfunction TorusGeometry( radius, tube, radialSegments, tubularSegments, arc ) {\n\n\tGeometry.call( this );\n\n\tthis.type = 'TorusGeometry';\n\n\tthis.parameters = {\n\t\tradius: radius,\n\t\ttube: tube,\n\t\tradialSegments: radialSegments,\n\t\ttubularSegments: tubularSegments,\n\t\tarc: arc\n\t};\n\n\tthis.fromBufferGeometry( new TorusBufferGeometry( radius, tube, radialSegments, tubularSegments, arc ) );\n\tthis.mergeVertices();\n\n}\n\nTorusGeometry.prototype = Object.create( Geometry.prototype );\nTorusGeometry.prototype.constructor = TorusGeometry;\n\n// TorusBufferGeometry\n\nfunction TorusBufferGeometry( radius, tube, radialSegments, tubularSegments, arc ) {\n\n\tBufferGeometry.call( this );\n\n\tthis.type = 'TorusBufferGeometry';\n\n\tthis.parameters = {\n\t\tradius: radius,\n\t\ttube: tube,\n\t\tradialSegments: radialSegments,\n\t\ttubularSegments: tubularSegments,\n\t\tarc: arc\n\t};\n\n\tradius = radius || 1;\n\ttube = tube || 0.4;\n\tradialSegments = Math.floor( radialSegments ) || 8;\n\ttubularSegments = Math.floor( tubularSegments ) || 6;\n\tarc = arc || Math.PI * 2;\n\n\t// buffers\n\n\tconst indices = [];\n\tconst vertices = [];\n\tconst normals = [];\n\tconst uvs = [];\n\n\t// helper variables\n\n\tconst center = new Vector3();\n\tconst vertex = new Vector3();\n\tconst normal = new Vector3();\n\n\t// generate vertices, normals and uvs\n\n\tfor ( let j = 0; j <= radialSegments; j ++ ) {\n\n\t\tfor ( let i = 0; i <= tubularSegments; i ++ ) {\n\n\t\t\tconst u = i / tubularSegments * arc;\n\t\t\tconst v = j / radialSegments * Math.PI * 2;\n\n\t\t\t// vertex\n\n\t\t\tvertex.x = ( radius + tube * Math.cos( v ) ) * Math.cos( u );\n\t\t\tvertex.y = ( radius + tube * Math.cos( v ) ) * Math.sin( u );\n\t\t\tvertex.z = tube * Math.sin( v );\n\n\t\t\tvertices.push( vertex.x, vertex.y, vertex.z );\n\n\t\t\t// normal\n\n\t\t\tcenter.x = radius * Math.cos( u );\n\t\t\tcenter.y = radius * Math.sin( u );\n\t\t\tnormal.subVectors( vertex, center ).normalize();\n\n\t\t\tnormals.push( normal.x, normal.y, normal.z );\n\n\t\t\t// uv\n\n\t\t\tuvs.push( i / tubularSegments );\n\t\t\tuvs.push( j / radialSegments );\n\n\t\t}\n\n\t}\n\n\t// generate indices\n\n\tfor ( let j = 1; j <= radialSegments; j ++ ) {\n\n\t\tfor ( let i = 1; i <= tubularSegments; i ++ ) {\n\n\t\t\t// indices\n\n\t\t\tconst a = ( tubularSegments + 1 ) * j + i - 1;\n\t\t\tconst b = ( tubularSegments + 1 ) * ( j - 1 ) + i - 1;\n\t\t\tconst c = ( tubularSegments + 1 ) * ( j - 1 ) + i;\n\t\t\tconst d = ( tubularSegments + 1 ) * j + i;\n\n\t\t\t// faces\n\n\t\t\tindices.push( a, b, d );\n\t\t\tindices.push( b, c, d );\n\n\t\t}\n\n\t}\n\n\t// build geometry\n\n\tthis.setIndex( indices );\n\tthis.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );\n\tthis.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );\n\tthis.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );\n\n}\n\nTorusBufferGeometry.prototype = Object.create( BufferGeometry.prototype );\nTorusBufferGeometry.prototype.constructor = TorusBufferGeometry;\n\n\nexport { TorusGeometry, TorusBufferGeometry };\n","/**\n * @author mrdoob / http://mrdoob.com/\n * @author Mugen87 / https://github.com/Mugen87\n */\n\nimport { Geometry } from '../core/Geometry.js';\nimport { BufferGeometry } from '../core/BufferGeometry.js';\nimport { Float32BufferAttribute } from '../core/BufferAttribute.js';\nimport { Vector3 } from '../math/Vector3.js';\nimport { Vector2 } from '../math/Vector2.js';\n\n// CylinderGeometry\n\nfunction CylinderGeometry( radiusTop, radiusBottom, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength ) {\n\n\tGeometry.call( this );\n\n\tthis.type = 'CylinderGeometry';\n\n\tthis.parameters = {\n\t\tradiusTop: radiusTop,\n\t\tradiusBottom: radiusBottom,\n\t\theight: height,\n\t\tradialSegments: radialSegments,\n\t\theightSegments: heightSegments,\n\t\topenEnded: openEnded,\n\t\tthetaStart: thetaStart,\n\t\tthetaLength: thetaLength\n\t};\n\n\tthis.fromBufferGeometry( new CylinderBufferGeometry( radiusTop, radiusBottom, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength ) );\n\tthis.mergeVertices();\n\n}\n\nCylinderGeometry.prototype = Object.create( Geometry.prototype );\nCylinderGeometry.prototype.constructor = CylinderGeometry;\n\n// CylinderBufferGeometry\n\nfunction CylinderBufferGeometry( radiusTop, radiusBottom, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength ) {\n\n\tBufferGeometry.call( this );\n\n\tthis.type = 'CylinderBufferGeometry';\n\n\tthis.parameters = {\n\t\tradiusTop: radiusTop,\n\t\tradiusBottom: radiusBottom,\n\t\theight: height,\n\t\tradialSegments: radialSegments,\n\t\theightSegments: heightSegments,\n\t\topenEnded: openEnded,\n\t\tthetaStart: thetaStart,\n\t\tthetaLength: thetaLength\n\t};\n\n\tconst scope = this;\n\n\tradiusTop = radiusTop !== undefined ? radiusTop : 1;\n\tradiusBottom = radiusBottom !== undefined ? radiusBottom : 1;\n\theight = height || 1;\n\n\tradialSegments = Math.floor( radialSegments ) || 8;\n\theightSegments = Math.floor( heightSegments ) || 1;\n\n\topenEnded = openEnded !== undefined ? openEnded : false;\n\tthetaStart = thetaStart !== undefined ? thetaStart : 0.0;\n\tthetaLength = thetaLength !== undefined ? thetaLength : Math.PI * 2;\n\n\t// buffers\n\n\tconst indices = [];\n\tconst vertices = [];\n\tconst normals = [];\n\tconst uvs = [];\n\n\t// helper variables\n\n\tlet index = 0;\n\tconst indexArray = [];\n\tconst halfHeight = height / 2;\n\tlet groupStart = 0;\n\n\t// generate geometry\n\n\tgenerateTorso();\n\n\tif ( openEnded === false ) {\n\n\t\tif ( radiusTop > 0 ) generateCap( true );\n\t\tif ( radiusBottom > 0 ) generateCap( false );\n\n\t}\n\n\t// build geometry\n\n\tthis.setIndex( indices );\n\tthis.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );\n\tthis.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );\n\tthis.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );\n\n\tfunction generateTorso() {\n\n\t\tconst normal = new Vector3();\n\t\tconst vertex = new Vector3();\n\n\t\tlet groupCount = 0;\n\n\t\t// this will be used to calculate the normal\n\t\tconst slope = ( radiusBottom - radiusTop ) / height;\n\n\t\t// generate vertices, normals and uvs\n\n\t\tfor ( let y = 0; y <= heightSegments; y ++ ) {\n\n\t\t\tconst indexRow = [];\n\n\t\t\tconst v = y / heightSegments;\n\n\t\t\t// calculate the radius of the current row\n\n\t\t\tconst radius = v * ( radiusBottom - radiusTop ) + radiusTop;\n\n\t\t\tfor ( let x = 0; x <= radialSegments; x ++ ) {\n\n\t\t\t\tconst u = x / radialSegments;\n\n\t\t\t\tconst theta = u * thetaLength + thetaStart;\n\n\t\t\t\tconst sinTheta = Math.sin( theta );\n\t\t\t\tconst cosTheta = Math.cos( theta );\n\n\t\t\t\t// vertex\n\n\t\t\t\tvertex.x = radius * sinTheta;\n\t\t\t\tvertex.y = - v * height + halfHeight;\n\t\t\t\tvertex.z = radius * cosTheta;\n\t\t\t\tvertices.push( vertex.x, vertex.y, vertex.z );\n\n\t\t\t\t// normal\n\n\t\t\t\tnormal.set( sinTheta, slope, cosTheta ).normalize();\n\t\t\t\tnormals.push( normal.x, normal.y, normal.z );\n\n\t\t\t\t// uv\n\n\t\t\t\tuvs.push( u, 1 - v );\n\n\t\t\t\t// save index of vertex in respective row\n\n\t\t\t\tindexRow.push( index ++ );\n\n\t\t\t}\n\n\t\t\t// now save vertices of the row in our index array\n\n\t\t\tindexArray.push( indexRow );\n\n\t\t}\n\n\t\t// generate indices\n\n\t\tfor ( let x = 0; x < radialSegments; x ++ ) {\n\n\t\t\tfor ( let y = 0; y < heightSegments; y ++ ) {\n\n\t\t\t\t// we use the index array to access the correct indices\n\n\t\t\t\tconst a = indexArray[ y ][ x ];\n\t\t\t\tconst b = indexArray[ y + 1 ][ x ];\n\t\t\t\tconst c = indexArray[ y + 1 ][ x + 1 ];\n\t\t\t\tconst d = indexArray[ y ][ x + 1 ];\n\n\t\t\t\t// faces\n\n\t\t\t\tindices.push( a, b, d );\n\t\t\t\tindices.push( b, c, d );\n\n\t\t\t\t// update group counter\n\n\t\t\t\tgroupCount += 6;\n\n\t\t\t}\n\n\t\t}\n\n\t\t// add a group to the geometry. this will ensure multi material support\n\n\t\tscope.addGroup( groupStart, groupCount, 0 );\n\n\t\t// calculate new start value for groups\n\n\t\tgroupStart += groupCount;\n\n\t}\n\n\tfunction generateCap( top ) {\n\n\t\tlet centerIndexStart, centerIndexEnd;\n\n\t\tconst uv = new Vector2();\n\t\tconst vertex = new Vector3();\n\n\t\tlet groupCount = 0;\n\n\t\tconst radius = ( top === true ) ? radiusTop : radiusBottom;\n\t\tconst sign = ( top === true ) ? 1 : - 1;\n\n\t\t// save the index of the first center vertex\n\t\tcenterIndexStart = index;\n\n\t\t// first we generate the center vertex data of the cap.\n\t\t// because the geometry needs one set of uvs per face,\n\t\t// we must generate a center vertex per face/segment\n\n\t\tfor ( let x = 1; x <= radialSegments; x ++ ) {\n\n\t\t\t// vertex\n\n\t\t\tvertices.push( 0, halfHeight * sign, 0 );\n\n\t\t\t// normal\n\n\t\t\tnormals.push( 0, sign, 0 );\n\n\t\t\t// uv\n\n\t\t\tuvs.push( 0.5, 0.5 );\n\n\t\t\t// increase index\n\n\t\t\tindex ++;\n\n\t\t}\n\n\t\t// save the index of the last center vertex\n\n\t\tcenterIndexEnd = index;\n\n\t\t// now we generate the surrounding vertices, normals and uvs\n\n\t\tfor ( let x = 0; x <= radialSegments; x ++ ) {\n\n\t\t\tconst u = x / radialSegments;\n\t\t\tconst theta = u * thetaLength + thetaStart;\n\n\t\t\tconst cosTheta = Math.cos( theta );\n\t\t\tconst sinTheta = Math.sin( theta );\n\n\t\t\t// vertex\n\n\t\t\tvertex.x = radius * sinTheta;\n\t\t\tvertex.y = halfHeight * sign;\n\t\t\tvertex.z = radius * cosTheta;\n\t\t\tvertices.push( vertex.x, vertex.y, vertex.z );\n\n\t\t\t// normal\n\n\t\t\tnormals.push( 0, sign, 0 );\n\n\t\t\t// uv\n\n\t\t\tuv.x = ( cosTheta * 0.5 ) + 0.5;\n\t\t\tuv.y = ( sinTheta * 0.5 * sign ) + 0.5;\n\t\t\tuvs.push( uv.x, uv.y );\n\n\t\t\t// increase index\n\n\t\t\tindex ++;\n\n\t\t}\n\n\t\t// generate indices\n\n\t\tfor ( let x = 0; x < radialSegments; x ++ ) {\n\n\t\t\tconst c = centerIndexStart + x;\n\t\t\tconst i = centerIndexEnd + x;\n\n\t\t\tif ( top === true ) {\n\n\t\t\t\t// face top\n\n\t\t\t\tindices.push( i, i + 1, c );\n\n\t\t\t} else {\n\n\t\t\t\t// face bottom\n\n\t\t\t\tindices.push( i + 1, i, c );\n\n\t\t\t}\n\n\t\t\tgroupCount += 3;\n\n\t\t}\n\n\t\t// add a group to the geometry. this will ensure multi material support\n\n\t\tscope.addGroup( groupStart, groupCount, top === true ? 1 : 2 );\n\n\t\t// calculate new start value for groups\n\n\t\tgroupStart += groupCount;\n\n\t}\n\n}\n\nCylinderBufferGeometry.prototype = Object.create( BufferGeometry.prototype );\nCylinderBufferGeometry.prototype.constructor = CylinderBufferGeometry;\n\n\nexport { CylinderGeometry, CylinderBufferGeometry };\n","/**\n * @author abelnation / http://github.com/abelnation\n */\n\nimport { CylinderGeometry } from './CylinderGeometry.js';\nimport { CylinderBufferGeometry } from './CylinderGeometry.js';\n\n// ConeGeometry\n\nfunction ConeGeometry( radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength ) {\n\n\tCylinderGeometry.call( this, 0, radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength );\n\n\tthis.type = 'ConeGeometry';\n\n\tthis.parameters = {\n\t\tradius: radius,\n\t\theight: height,\n\t\tradialSegments: radialSegments,\n\t\theightSegments: heightSegments,\n\t\topenEnded: openEnded,\n\t\tthetaStart: thetaStart,\n\t\tthetaLength: thetaLength\n\t};\n\n}\n\nConeGeometry.prototype = Object.create( CylinderGeometry.prototype );\nConeGeometry.prototype.constructor = ConeGeometry;\n\n// ConeBufferGeometry\n\nfunction ConeBufferGeometry( radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength ) {\n\n\tCylinderBufferGeometry.call( this, 0, radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength );\n\n\tthis.type = 'ConeBufferGeometry';\n\n\tthis.parameters = {\n\t\tradius: radius,\n\t\theight: height,\n\t\tradialSegments: radialSegments,\n\t\theightSegments: heightSegments,\n\t\topenEnded: openEnded,\n\t\tthetaStart: thetaStart,\n\t\tthetaLength: thetaLength\n\t};\n\n}\n\nConeBufferGeometry.prototype = Object.create( CylinderBufferGeometry.prototype );\nConeBufferGeometry.prototype.constructor = ConeBufferGeometry;\n\n\nexport { ConeGeometry, ConeBufferGeometry };\n","import { Object3D } from '../core/Object3D.js';\nimport { Color } from '../math/Color.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author alteredq / http://alteredqualia.com/\n */\n\nfunction Light( color, intensity ) {\n\n\tObject3D.call( this );\n\n\tthis.type = 'Light';\n\n\tthis.color = new Color( color );\n\tthis.intensity = intensity !== undefined ? intensity : 1;\n\n\tthis.receiveShadow = undefined;\n\n}\n\nLight.prototype = Object.assign( Object.create( Object3D.prototype ), {\n\n\tconstructor: Light,\n\n\tisLight: true,\n\n\tcopy: function ( source ) {\n\n\t\tObject3D.prototype.copy.call( this, source );\n\n\t\tthis.color.copy( source.color );\n\t\tthis.intensity = source.intensity;\n\n\t\treturn this;\n\n\t},\n\n\ttoJSON: function ( meta ) {\n\n\t\tconst data = Object3D.prototype.toJSON.call( this, meta );\n\n\t\tdata.object.color = this.color.getHex();\n\t\tdata.object.intensity = this.intensity;\n\n\t\tif ( this.groundColor !== undefined ) data.object.groundColor = this.groundColor.getHex();\n\n\t\tif ( this.distance !== undefined ) data.object.distance = this.distance;\n\t\tif ( this.angle !== undefined ) data.object.angle = this.angle;\n\t\tif ( this.decay !== undefined ) data.object.decay = this.decay;\n\t\tif ( this.penumbra !== undefined ) data.object.penumbra = this.penumbra;\n\n\t\tif ( this.shadow !== undefined ) data.object.shadow = this.shadow.toJSON();\n\n\t\treturn data;\n\n\t}\n\n} );\n\n\nexport { Light };\n","import { Matrix4 } from '../math/Matrix4.js';\nimport { Vector2 } from '../math/Vector2.js';\nimport { Vector3 } from '../math/Vector3.js';\nimport { Vector4 } from '../math/Vector4.js';\nimport { Frustum } from '../math/Frustum.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction LightShadow( camera ) {\n\n\tthis.camera = camera;\n\n\tthis.bias = 0;\n\tthis.normalBias = 0;\n\tthis.radius = 1;\n\n\tthis.mapSize = new Vector2( 512, 512 );\n\n\tthis.map = null;\n\tthis.mapPass = null;\n\tthis.matrix = new Matrix4();\n\n\tthis.autoUpdate = true;\n\tthis.needsUpdate = false;\n\n\tthis._frustum = new Frustum();\n\tthis._frameExtents = new Vector2( 1, 1 );\n\n\tthis._viewportCount = 1;\n\n\tthis._viewports = [\n\n\t\tnew Vector4( 0, 0, 1, 1 )\n\n\t];\n\n}\n\nObject.assign( LightShadow.prototype, {\n\n\t_projScreenMatrix: new Matrix4(),\n\n\t_lightPositionWorld: new Vector3(),\n\n\t_lookTarget: new Vector3(),\n\n\tgetViewportCount: function () {\n\n\t\treturn this._viewportCount;\n\n\t},\n\n\tgetFrustum: function () {\n\n\t\treturn this._frustum;\n\n\t},\n\n\tupdateMatrices: function ( light ) {\n\n\t\tconst shadowCamera = this.camera,\n\t\t\tshadowMatrix = this.matrix,\n\t\t\tprojScreenMatrix = this._projScreenMatrix,\n\t\t\tlookTarget = this._lookTarget,\n\t\t\tlightPositionWorld = this._lightPositionWorld;\n\n\t\tlightPositionWorld.setFromMatrixPosition( light.matrixWorld );\n\t\tshadowCamera.position.copy( lightPositionWorld );\n\n\t\tlookTarget.setFromMatrixPosition( light.target.matrixWorld );\n\t\tshadowCamera.lookAt( lookTarget );\n\t\tshadowCamera.updateMatrixWorld();\n\n\t\tprojScreenMatrix.multiplyMatrices( shadowCamera.projectionMatrix, shadowCamera.matrixWorldInverse );\n\t\tthis._frustum.setFromProjectionMatrix( projScreenMatrix );\n\n\t\tshadowMatrix.set(\n\t\t\t0.5, 0.0, 0.0, 0.5,\n\t\t\t0.0, 0.5, 0.0, 0.5,\n\t\t\t0.0, 0.0, 0.5, 0.5,\n\t\t\t0.0, 0.0, 0.0, 1.0\n\t\t);\n\n\t\tshadowMatrix.multiply( shadowCamera.projectionMatrix );\n\t\tshadowMatrix.multiply( shadowCamera.matrixWorldInverse );\n\n\t},\n\n\tgetViewport: function ( viewportIndex ) {\n\n\t\treturn this._viewports[ viewportIndex ];\n\n\t},\n\n\tgetFrameExtents: function () {\n\n\t\treturn this._frameExtents;\n\n\t},\n\n\tcopy: function ( source ) {\n\n\t\tthis.camera = source.camera.clone();\n\n\t\tthis.bias = source.bias;\n\t\tthis.radius = source.radius;\n\n\t\tthis.mapSize.copy( source.mapSize );\n\n\t\treturn this;\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor().copy( this );\n\n\t},\n\n\ttoJSON: function () {\n\n\t\tconst object = {};\n\n\t\tif ( this.bias !== 0 ) object.bias = this.bias;\n\t\tif ( this.normalBias !== 0 ) object.normalBias = this.normalBias;\n\t\tif ( this.radius !== 1 ) object.radius = this.radius;\n\t\tif ( this.mapSize.x !== 512 || this.mapSize.y !== 512 ) object.mapSize = this.mapSize.toArray();\n\n\t\tobject.camera = this.camera.toJSON( false ).object;\n\t\tdelete object.camera.matrix;\n\n\t\treturn object;\n\n\t}\n\n} );\n\n\nexport { LightShadow };\n","import { LightShadow } from './LightShadow.js';\nimport { MathUtils } from '../math/MathUtils.js';\nimport { PerspectiveCamera } from '../cameras/PerspectiveCamera.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction SpotLightShadow() {\n\n\tLightShadow.call( this, new PerspectiveCamera( 50, 1, 0.5, 500 ) );\n\n}\n\nSpotLightShadow.prototype = Object.assign( Object.create( LightShadow.prototype ), {\n\n\tconstructor: SpotLightShadow,\n\n\tisSpotLightShadow: true,\n\n\tupdateMatrices: function ( light ) {\n\n\t\tconst camera = this.camera;\n\n\t\tconst fov = MathUtils.RAD2DEG * 2 * light.angle;\n\t\tconst aspect = this.mapSize.width / this.mapSize.height;\n\t\tconst far = light.distance || camera.far;\n\n\t\tif ( fov !== camera.fov || aspect !== camera.aspect || far !== camera.far ) {\n\n\t\t\tcamera.fov = fov;\n\t\t\tcamera.aspect = aspect;\n\t\t\tcamera.far = far;\n\t\t\tcamera.updateProjectionMatrix();\n\n\t\t}\n\n\t\tLightShadow.prototype.updateMatrices.call( this, light );\n\n\t}\n\n} );\n\n\nexport { SpotLightShadow };\n","import { Light } from './Light.js';\nimport { SpotLightShadow } from './SpotLightShadow.js';\nimport { Object3D } from '../core/Object3D.js';\n\n/**\n * @author alteredq / http://alteredqualia.com/\n */\n\nfunction SpotLight( color, intensity, distance, angle, penumbra, decay ) {\n\n\tLight.call( this, color, intensity );\n\n\tthis.type = 'SpotLight';\n\n\tthis.position.copy( Object3D.DefaultUp );\n\tthis.updateMatrix();\n\n\tthis.target = new Object3D();\n\n\tObject.defineProperty( this, 'power', {\n\t\tget: function () {\n\n\t\t\t// intensity = power per solid angle.\n\t\t\t// ref: equation (17) from https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf\n\t\t\treturn this.intensity * Math.PI;\n\n\t\t},\n\t\tset: function ( power ) {\n\n\t\t\t// intensity = power per solid angle.\n\t\t\t// ref: equation (17) from https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf\n\t\t\tthis.intensity = power / Math.PI;\n\n\t\t}\n\t} );\n\n\tthis.distance = ( distance !== undefined ) ? distance : 0;\n\tthis.angle = ( angle !== undefined ) ? angle : Math.PI / 3;\n\tthis.penumbra = ( penumbra !== undefined ) ? penumbra : 0;\n\tthis.decay = ( decay !== undefined ) ? decay : 1;\t// for physically correct lights, should be 2.\n\n\tthis.shadow = new SpotLightShadow();\n\n}\n\nSpotLight.prototype = Object.assign( Object.create( Light.prototype ), {\n\n\tconstructor: SpotLight,\n\n\tisSpotLight: true,\n\n\tcopy: function ( source ) {\n\n\t\tLight.prototype.copy.call( this, source );\n\n\t\tthis.distance = source.distance;\n\t\tthis.angle = source.angle;\n\t\tthis.penumbra = source.penumbra;\n\t\tthis.decay = source.decay;\n\n\t\tthis.target = source.target.clone();\n\n\t\tthis.shadow = source.shadow.clone();\n\n\t\treturn this;\n\n\t}\n\n} );\n\n\nexport { SpotLight };\n","import { Camera } from './Camera.js';\nimport { Object3D } from '../core/Object3D.js';\n\n/**\n * @author alteredq / http://alteredqualia.com/\n * @author arose / http://github.com/arose\n */\n\nfunction OrthographicCamera( left, right, top, bottom, near, far ) {\n\n\tCamera.call( this );\n\n\tthis.type = 'OrthographicCamera';\n\n\tthis.zoom = 1;\n\tthis.view = null;\n\n\tthis.left = ( left !== undefined ) ? left : - 1;\n\tthis.right = ( right !== undefined ) ? right : 1;\n\tthis.top = ( top !== undefined ) ? top : 1;\n\tthis.bottom = ( bottom !== undefined ) ? bottom : - 1;\n\n\tthis.near = ( near !== undefined ) ? near : 0.1;\n\tthis.far = ( far !== undefined ) ? far : 2000;\n\n\tthis.updateProjectionMatrix();\n\n}\n\nOrthographicCamera.prototype = Object.assign( Object.create( Camera.prototype ), {\n\n\tconstructor: OrthographicCamera,\n\n\tisOrthographicCamera: true,\n\n\tcopy: function ( source, recursive ) {\n\n\t\tCamera.prototype.copy.call( this, source, recursive );\n\n\t\tthis.left = source.left;\n\t\tthis.right = source.right;\n\t\tthis.top = source.top;\n\t\tthis.bottom = source.bottom;\n\t\tthis.near = source.near;\n\t\tthis.far = source.far;\n\n\t\tthis.zoom = source.zoom;\n\t\tthis.view = source.view === null ? null : Object.assign( {}, source.view );\n\n\t\treturn this;\n\n\t},\n\n\tsetViewOffset: function ( fullWidth, fullHeight, x, y, width, height ) {\n\n\t\tif ( this.view === null ) {\n\n\t\t\tthis.view = {\n\t\t\t\tenabled: true,\n\t\t\t\tfullWidth: 1,\n\t\t\t\tfullHeight: 1,\n\t\t\t\toffsetX: 0,\n\t\t\t\toffsetY: 0,\n\t\t\t\twidth: 1,\n\t\t\t\theight: 1\n\t\t\t};\n\n\t\t}\n\n\t\tthis.view.enabled = true;\n\t\tthis.view.fullWidth = fullWidth;\n\t\tthis.view.fullHeight = fullHeight;\n\t\tthis.view.offsetX = x;\n\t\tthis.view.offsetY = y;\n\t\tthis.view.width = width;\n\t\tthis.view.height = height;\n\n\t\tthis.updateProjectionMatrix();\n\n\t},\n\n\tclearViewOffset: function () {\n\n\t\tif ( this.view !== null ) {\n\n\t\t\tthis.view.enabled = false;\n\n\t\t}\n\n\t\tthis.updateProjectionMatrix();\n\n\t},\n\n\tupdateProjectionMatrix: function () {\n\n\t\tconst dx = ( this.right - this.left ) / ( 2 * this.zoom );\n\t\tconst dy = ( this.top - this.bottom ) / ( 2 * this.zoom );\n\t\tconst cx = ( this.right + this.left ) / 2;\n\t\tconst cy = ( this.top + this.bottom ) / 2;\n\n\t\tlet left = cx - dx;\n\t\tlet right = cx + dx;\n\t\tlet top = cy + dy;\n\t\tlet bottom = cy - dy;\n\n\t\tif ( this.view !== null && this.view.enabled ) {\n\n\t\t\tconst scaleW = ( this.right - this.left ) / this.view.fullWidth / this.zoom;\n\t\t\tconst scaleH = ( this.top - this.bottom ) / this.view.fullHeight / this.zoom;\n\n\t\t\tleft += scaleW * this.view.offsetX;\n\t\t\tright = left + scaleW * this.view.width;\n\t\t\ttop -= scaleH * this.view.offsetY;\n\t\t\tbottom = top - scaleH * this.view.height;\n\n\t\t}\n\n\t\tthis.projectionMatrix.makeOrthographic( left, right, top, bottom, this.near, this.far );\n\n\t\tthis.projectionMatrixInverse.getInverse( this.projectionMatrix );\n\n\t},\n\n\ttoJSON: function ( meta ) {\n\n\t\tconst data = Object3D.prototype.toJSON.call( this, meta );\n\n\t\tdata.object.zoom = this.zoom;\n\t\tdata.object.left = this.left;\n\t\tdata.object.right = this.right;\n\t\tdata.object.top = this.top;\n\t\tdata.object.bottom = this.bottom;\n\t\tdata.object.near = this.near;\n\t\tdata.object.far = this.far;\n\n\t\tif ( this.view !== null ) data.object.view = Object.assign( {}, this.view );\n\n\t\treturn data;\n\n\t}\n\n} );\n\n\nexport { OrthographicCamera };\n","import { Light } from './Light.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction AmbientLight( color, intensity ) {\n\n\tLight.call( this, color, intensity );\n\n\tthis.type = 'AmbientLight';\n\n\tthis.castShadow = undefined;\n\n}\n\nAmbientLight.prototype = Object.assign( Object.create( Light.prototype ), {\n\n\tconstructor: AmbientLight,\n\n\tisAmbientLight: true\n\n} );\n\n\nexport { AmbientLight };\n","import { Matrix4 } from '../math/Matrix4.js';\nimport { MathUtils } from '../math/MathUtils.js';\nimport { PerspectiveCamera } from './PerspectiveCamera.js';\n\nconst _eyeRight = new Matrix4();\nconst _eyeLeft = new Matrix4();\n\n/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction StereoCamera() {\n\n\tthis.type = 'StereoCamera';\n\n\tthis.aspect = 1;\n\n\tthis.eyeSep = 0.064;\n\n\tthis.cameraL = new PerspectiveCamera();\n\tthis.cameraL.layers.enable( 1 );\n\tthis.cameraL.matrixAutoUpdate = false;\n\n\tthis.cameraR = new PerspectiveCamera();\n\tthis.cameraR.layers.enable( 2 );\n\tthis.cameraR.matrixAutoUpdate = false;\n\n\tthis._cache = {\n\t\tfocus: null,\n\t\tfov: null,\n\t\taspect: null,\n\t\tnear: null,\n\t\tfar: null,\n\t\tzoom: null,\n\t\teyeSep: null\n\t};\n\n}\n\nObject.assign( StereoCamera.prototype, {\n\n\tupdate: function ( camera ) {\n\n\t\tconst cache = this._cache;\n\n\t\tconst needsUpdate = cache.focus !== camera.focus || cache.fov !== camera.fov ||\n\t\t\tcache.aspect !== camera.aspect * this.aspect || cache.near !== camera.near ||\n\t\t\tcache.far !== camera.far || cache.zoom !== camera.zoom || cache.eyeSep !== this.eyeSep;\n\n\t\tif ( needsUpdate ) {\n\n\t\t\tcache.focus = camera.focus;\n\t\t\tcache.fov = camera.fov;\n\t\t\tcache.aspect = camera.aspect * this.aspect;\n\t\t\tcache.near = camera.near;\n\t\t\tcache.far = camera.far;\n\t\t\tcache.zoom = camera.zoom;\n\t\t\tcache.eyeSep = this.eyeSep;\n\n\t\t\t// Off-axis stereoscopic effect based on\n\t\t\t// http://paulbourke.net/stereographics/stereorender/\n\n\t\t\tconst projectionMatrix = camera.projectionMatrix.clone();\n\t\t\tconst eyeSepHalf = cache.eyeSep / 2;\n\t\t\tconst eyeSepOnProjection = eyeSepHalf * cache.near / cache.focus;\n\t\t\tconst ymax = ( cache.near * Math.tan( MathUtils.DEG2RAD * cache.fov * 0.5 ) ) / cache.zoom;\n\t\t\tlet xmin, xmax;\n\n\t\t\t// translate xOffset\n\n\t\t\t_eyeLeft.elements[ 12 ] = - eyeSepHalf;\n\t\t\t_eyeRight.elements[ 12 ] = eyeSepHalf;\n\n\t\t\t// for left eye\n\n\t\t\txmin = - ymax * cache.aspect + eyeSepOnProjection;\n\t\t\txmax = ymax * cache.aspect + eyeSepOnProjection;\n\n\t\t\tprojectionMatrix.elements[ 0 ] = 2 * cache.near / ( xmax - xmin );\n\t\t\tprojectionMatrix.elements[ 8 ] = ( xmax + xmin ) / ( xmax - xmin );\n\n\t\t\tthis.cameraL.projectionMatrix.copy( projectionMatrix );\n\n\t\t\t// for right eye\n\n\t\t\txmin = - ymax * cache.aspect - eyeSepOnProjection;\n\t\t\txmax = ymax * cache.aspect - eyeSepOnProjection;\n\n\t\t\tprojectionMatrix.elements[ 0 ] = 2 * cache.near / ( xmax - xmin );\n\t\t\tprojectionMatrix.elements[ 8 ] = ( xmax + xmin ) / ( xmax - xmin );\n\n\t\t\tthis.cameraR.projectionMatrix.copy( projectionMatrix );\n\n\t\t}\n\n\t\tthis.cameraL.matrixWorld.copy( camera.matrixWorld ).multiply( _eyeLeft );\n\t\tthis.cameraR.matrixWorld.copy( camera.matrixWorld ).multiply( _eyeRight );\n\n\t}\n\n} );\n\n\nexport { StereoCamera };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction Uniform( value ) {\n\n\tif ( typeof value === 'string' ) {\n\n\t\tconsole.warn( 'THREE.Uniform: Type parameter is no longer needed.' );\n\t\tvalue = arguments[ 1 ];\n\n\t}\n\n\tthis.value = value;\n\n}\n\nUniform.prototype.clone = function () {\n\n\treturn new Uniform( this.value.clone === undefined ? this.value : this.value.clone() );\n\n};\n\nexport { Uniform };\n","/**\n * @file Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector2, Vector3, Matrix4, Quaternion } from 'three'\n\nexport function getQuery (id: string) {\n if (typeof window === 'undefined') return undefined\n\n const a = new RegExp(`${id}=([^&#=]*)`)\n const m = a.exec(window.location.search)\n\n if (m) {\n return decodeURIComponent(m[1])\n } else {\n return undefined\n }\n}\n\nexport function boolean (value: any) {\n if (!value) {\n return false\n }\n\n if (typeof value === 'string') {\n return /^1|true|t|yes|y$/i.test(value)\n }\n\n return true\n}\n\nexport function defaults (value: any, defaultValue: any) {\n return value !== undefined ? value : defaultValue\n}\n\nexport function createParams (params: {[k in keyof T]?: any}, defaultParams: T) {\n const o: any = Object.assign({}, params)\n for (const k in defaultParams) {\n const value = params[k]\n if (value === undefined) o[k] = defaultParams[k]\n }\n return o as T\n}\n\nexport function updateParams (params: T, newParams: {[k in keyof T]?: any}) {\n for (const k in newParams) {\n const value = newParams[k]\n if (value !== undefined) params[k] = value\n }\n return params as T\n}\n\nexport function pick (object: { [index: string]: any }) {\n const properties = [].slice.call(arguments, 1)\n return properties.reduce((a: { [index: string]: any }, e: any) => {\n a[ e ] = object[ e ]\n return a\n }, {})\n}\n\nexport function flatten (array: any[], ret: any[]) {\n ret = defaults(ret, [])\n for (let i = 0; i < array.length; i++) {\n if (Array.isArray(array[i])) {\n flatten(array[i], ret)\n } else {\n ret.push(array[i])\n }\n }\n return ret\n}\n\nexport function getProtocol () {\n const protocol = window.location.protocol\n return protocol.match(/http(s)?:/gi) === null ? 'http:' : protocol\n}\n\nexport function getBrowser () {\n if (typeof window === 'undefined') return false\n\n const ua = window.navigator.userAgent\n\n if (/Opera|OPR/.test(ua)) {\n return 'Opera'\n } else if (/Chrome/i.test(ua)) {\n return 'Chrome'\n } else if (/Firefox/i.test(ua)) {\n return 'Firefox'\n } else if (/Mobile(\\/.*)? Safari/i.test(ua)) {\n return 'Mobile Safari'\n } else if (/MSIE/i.test(ua)) {\n return 'Internet Explorer'\n } else if (/Safari/i.test(ua)) {\n return 'Safari'\n }\n\n return false\n}\n\nexport function getAbsolutePath (relativePath: string) {\n const loc = window.location\n const pn = loc.pathname\n const basePath = pn.substring(0, pn.lastIndexOf('/') + 1)\n\n return loc.origin + basePath + relativePath\n}\n\nexport function deepCopy (src: any) {\n if (typeof src !== 'object') {\n return src\n }\n\n const dst: { [index: string]: any } = Array.isArray(src) ? [] : {}\n\n for (let key in src) {\n dst[ key ] = deepCopy(src[ key ])\n }\n\n return dst\n}\n\nexport function deepEqual(a: any, b: any) {\n // from https://github.com/epoberezkin/fast-deep-equal MIT\n if (a === b) return true;\n\n const arrA = Array.isArray(a)\n const arrB = Array.isArray(b)\n\n if (arrA && arrB) {\n if (a.length !== b.length) return false\n for (let i = 0; i < a.length; i++) {\n if (!deepEqual(a[i], b[i])) return false\n }\n return true\n }\n\n if (arrA !== arrB) return false\n\n if (a && b && typeof a === 'object' && typeof b === 'object') {\n const keys = Object.keys(a)\n if (keys.length !== Object.keys(b).length) return false;\n\n const dateA = a instanceof Date\n const dateB = b instanceof Date\n if (dateA && dateB) return a.getTime() === b.getTime()\n if (dateA !== dateB) return false\n\n const regexpA = a instanceof RegExp\n const regexpB = b instanceof RegExp\n if (regexpA && regexpB) return a.toString() === b.toString()\n if (regexpA !== regexpB) return false\n\n for (let i = 0; i < keys.length; i++) {\n if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false\n }\n\n for (let i = 0; i < keys.length; i++) {\n if(!deepEqual(a[keys[i]], b[keys[i]])) return false\n }\n\n return true\n }\n\n return false\n}\n\nfunction openUrl (url: string) {\n const opened = window.open(url, '_blank')\n if (!opened) {\n window.location.href = url\n }\n}\n\nexport function download (data: Blob|string, downloadName = 'download') {\n // using ideas from https://github.com/eligrey/FileSaver.js/blob/master/FileSaver.js\n\n if (!data) return\n\n const isSafari = getBrowser() === 'Safari'\n const isChromeIos = /CriOS\\/[\\d]+/.test(window.navigator.userAgent)\n\n const a = document.createElement('a')\n\n function open (str: string) {\n openUrl(isChromeIos ? str : str.replace(/^data:[^;]*;/, 'data:attachment/file;'))\n }\n\n if (typeof navigator !== 'undefined' && (navigator as any).msSaveOrOpenBlob) {\n // native saveAs in IE 10+\n (navigator as any).msSaveOrOpenBlob(data, downloadName)\n } else if ((isSafari || isChromeIos) && FileReader) {\n if (data instanceof Blob) {\n // no downloading of blob urls in Safari\n var reader = new FileReader()\n reader.onloadend = function () {\n open(reader.result as string)\n }\n reader.readAsDataURL(data)\n } else {\n open(data)\n }\n } else {\n let objectUrlCreated = false\n if (data instanceof Blob) {\n data = URL.createObjectURL(data)\n objectUrlCreated = true\n }\n\n if ('download' in a) {\n // download link available\n a.style.display = 'hidden'\n document.body.appendChild(a)\n a.href = data\n a.download = downloadName\n a.target = '_blank'\n a.click()\n document.body.removeChild(a)\n } else {\n openUrl(data)\n }\n\n if (objectUrlCreated) {\n window.URL.revokeObjectURL(data)\n }\n }\n}\n\nexport function submit (url: string, data: FormData, callback: Function, onerror: Function) {\n const xhr = new XMLHttpRequest()\n xhr.open('POST', url)\n\n xhr.addEventListener('load', function () {\n if (xhr.status === 200 || xhr.status === 304) {\n callback(xhr.response)\n } else {\n if (typeof onerror === 'function') {\n onerror(xhr.status)\n }\n }\n }, false)\n\n xhr.send(data)\n}\n\ninterface HTMLInputEvent extends Event {\n target: HTMLInputElement & EventTarget\n}\n\nexport function open (callback: Function, extensionList = ['*']) {\n const fileInput = document.createElement('input')\n fileInput.type = 'file'\n fileInput.multiple = true\n fileInput.style.display = 'hidden'\n document.body.appendChild(fileInput)\n fileInput.accept = '.' + extensionList.join(',.')\n fileInput.addEventListener('change', function (e: HTMLInputEvent) {\n callback(e.target.files)\n }, false)\n\n fileInput.click()\n}\n\nexport function throttle (func: Function, wait: number, options: { leading?: boolean, trailing?: boolean }) {\n // from http://underscorejs.org/docs/underscore.html\n\n let context: any\n let args: any\n let result: any\n let timeout: any = null\n let previous = 0\n\n if (!options) options = {}\n\n function later () {\n previous = options.leading === false ? 0 : Date.now()\n timeout = null\n result = func.apply(context, args)\n if (!timeout) context = args = null\n }\n\n return function throttle (this: any) {\n var now = Date.now()\n if (!previous && options.leading === false) previous = now\n var remaining = wait - (now - previous)\n context = this\n args = arguments\n if (remaining <= 0 || remaining > wait) {\n if (timeout) {\n clearTimeout(timeout)\n timeout = null\n }\n previous = now\n result = func.apply(context, args)\n if (!timeout) context = args = null\n } else if (!timeout && options.trailing !== false) {\n timeout = setTimeout(later, remaining)\n }\n\n return result\n }\n}\n\nexport function lexicographicCompare (elm1: T, elm2: T) {\n if (elm1 < elm2) return -1\n if (elm1 > elm2) return 1\n return 0\n}\n\n/**\n * Does a binary search to get the index of an element in the input array\n * @function\n * @example\n * var array = [ 1, 2, 3, 4, 5, 6 ];\n * var element = 4;\n * binarySearchIndexOf( array, element ); // returns 3\n *\n * @param {Array} array - sorted array\n * @param {Anything} element - element to search for in the array\n * @param {Function} [compareFunction] - compare function\n * @return {Number} the index of the element or -1 if not in the array\n */\nexport function binarySearchIndexOf (array: T[], element: T, compareFunction = lexicographicCompare) {\n let low = 0\n let high = array.length - 1\n while (low <= high) {\n const mid = (low + high) >> 1\n const cmp = compareFunction(element, array[ mid ])\n if (cmp > 0) {\n low = mid + 1\n } else if (cmp < 0) {\n high = mid - 1\n } else {\n return mid\n }\n }\n return -low - 1\n}\n\nexport function binarySearchForLeftRange (array: number[], leftRange: number) {\n let high = array.length - 1\n if (array[ high ] < leftRange) return -1\n let low = 0\n while (low <= high) {\n const mid = (low + high) >> 1\n if (array[ mid ] >= leftRange) {\n high = mid - 1\n } else {\n low = mid + 1\n }\n }\n return high + 1\n}\n\nexport function binarySearchForRightRange (array: number[], rightRange: number) {\n if (array[ 0 ] > rightRange) return -1\n let low = 0\n let high = array.length - 1\n while (low <= high) {\n const mid = (low + high) >> 1\n if (array[ mid ] > rightRange) {\n high = mid - 1\n } else {\n low = mid + 1\n }\n }\n return low - 1\n}\n\nexport function rangeInSortedArray (array: number[], min: number, max: number) {\n const indexLeft = binarySearchForLeftRange(array, min)\n const indexRight = binarySearchForRightRange(array, max)\n if (indexLeft === -1 || indexRight === -1 || indexLeft > indexRight) {\n return 0\n } else {\n return indexRight - indexLeft + 1\n }\n}\n\nexport function dataURItoImage (dataURI: string) {\n const img = document.createElement('img')\n img.src = dataURI\n return img\n}\n\nexport function uniqueArray (array: any[]) {\n return array.sort().filter(function (value, index, sorted) {\n return (index === 0) || (value !== sorted[ index - 1 ])\n })\n}\n\n// String/arraybuffer conversion\n\nexport function uint8ToString (u8a: Uint8Array) {\n const chunkSize = 0x7000\n\n if (u8a.length > chunkSize) {\n const c = []\n\n for (let i = 0; i < u8a.length; i += chunkSize) {\n c.push(String.fromCharCode.apply(\n null, u8a.subarray(i, i + chunkSize)\n ))\n }\n\n return c.join('')\n } else {\n return String.fromCharCode.apply(null, u8a)\n }\n}\n\nexport function uint8ToLines (u8a: Uint8Array, chunkSize = 1024 * 1024 * 10, newline = '\\n') {\n let partialLine = ''\n let lines: string[] = []\n\n for (let i = 0; i < u8a.length; i += chunkSize) {\n const str = uint8ToString(u8a.subarray(i, i + chunkSize))\n const idx = str.lastIndexOf(newline)\n\n if (idx === -1) {\n partialLine += str\n } else {\n const str2 = partialLine + str.substr(0, idx)\n lines = lines.concat(str2.split(newline))\n\n if (idx === str.length - newline.length) {\n partialLine = ''\n } else {\n partialLine = str.substr(idx + newline.length)\n }\n }\n }\n\n if (partialLine !== '') {\n lines.push(partialLine)\n }\n\n return lines\n}\n\nexport type TypedArrayString = 'int8'|'int16'|'int32'|'uint8'|'uint16'|'uint32'|'float32'\nexport function getTypedArray (arrayType: TypedArrayString, arraySize: number) {\n switch (arrayType) {\n case 'int8':\n return new Int8Array(arraySize)\n case 'int16':\n return new Int16Array(arraySize)\n case 'int32':\n return new Int32Array(arraySize)\n case 'uint8':\n return new Uint8Array(arraySize)\n case 'uint16':\n return new Uint16Array(arraySize)\n case 'uint32':\n return new Uint32Array(arraySize)\n case 'float32':\n return new Float32Array(arraySize)\n default:\n throw new Error('arrayType unknown: ' + arrayType)\n }\n}\n\nexport function getUintArray (sizeOrArray: any, maxUint: number) { // TODO\n const TypedArray = maxUint > 65535 ? Uint32Array : Uint16Array\n return new TypedArray(sizeOrArray)\n}\n\nexport function ensureArray (value: any) {\n return Array.isArray(value) ? value : [value]\n}\n\nexport function ensureBuffer (a: any) { // TODO\n return (a.buffer && a.buffer instanceof ArrayBuffer) ? a.buffer : a\n}\n\nfunction _ensureClassFromArg (arg: any, constructor: { new (arg: any): any }) {\n return arg instanceof constructor ? arg : new constructor(arg)\n}\n\nfunction _ensureClassFromArray (array: any, constructor: { new (): any }) {\n if (array === undefined) {\n array = new constructor()\n } else if (Array.isArray(array)) {\n array = new constructor().fromArray(array)\n }\n return array\n}\n\nexport function ensureVector2 (v?: number[]|Vector2) {\n return _ensureClassFromArray(v, Vector2)\n}\n\nexport function ensureVector3 (v?: number[]|Vector3) {\n return _ensureClassFromArray(v, Vector3)\n}\n\nexport function ensureMatrix4 (m?: number[]|Matrix4) {\n return _ensureClassFromArray(m, Matrix4)\n}\n\nexport function ensureQuaternion (q?: number[]|Quaternion) {\n return _ensureClassFromArray(q, Quaternion)\n}\n\nexport function ensureFloat32Array (a?: number[]|Float32Array) {\n return _ensureClassFromArg(a, Float32Array)\n}\n\nexport interface RingBuffer {\n has: (value: T) => boolean\n get: (value: number) => T\n push: (value: T) => void\n count: number\n data: T[]\n clear: () => void\n}\n\nexport function createRingBuffer (length: number): RingBuffer {\n let pointer = 0\n let count = 0\n const buffer: T[] = []\n\n return {\n has: function (value: any) { return buffer.indexOf(value) !== -1 },\n get: function (idx: number) { return buffer[idx] },\n push: function (item: any) {\n buffer[pointer] = item\n pointer = (length + pointer + 1) % length\n ++count\n },\n get count () { return count },\n get data () { return buffer.slice(0, Math.min(count, length)) },\n clear: function () {\n count = 0\n pointer = 0\n buffer.length = 0\n }\n }\n}\n\nexport interface SimpleDict {\n has: (k: K) => boolean\n add: (k: K, v: V) => void\n del: (k: K) => void\n values: V[]\n}\n\nexport function createSimpleDict (): SimpleDict {\n const set: { [k: string]: V } = {}\n\n return {\n has: function (k: K) { return set[JSON.stringify(k)] !== undefined },\n add: function (k: K, v: V) { set[JSON.stringify(k)] = v },\n del: function (k: K) { delete set[JSON.stringify(k)] },\n get values () { return Object.keys(set).map(k => set[k]) }\n }\n}\n\nexport interface SimpleSet {\n has: (value: T) => boolean\n add: (value: T) => void\n del: (value: T) => void\n list: T[]\n}\n\nexport function createSimpleSet (): SimpleSet {\n const set: { [k: string]: T } = {}\n\n return {\n has: function (v: T) { return set[JSON.stringify(v)] !== undefined },\n add: function (v: T) { set[JSON.stringify(v)] = v },\n del: function (v: T) { delete set[JSON.stringify(v)] },\n get list () { return Object.keys(set).map(k => set[k]) },\n }\n}\n","/**\n * @file Registry\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\n\nfunction toLowerCaseString (value: string) {\n return defaults(value, '').toString().toLowerCase()\n}\n\nexport default class Registry {\n name: string\n private _dict: {[k: string]: any}\n\n constructor (name: string) {\n this.name = name\n this._dict = {}\n }\n\n add (key: string, value: any) {\n this._dict[ toLowerCaseString(key) ] = value\n }\n\n get (key: string) {\n return this._dict[ toLowerCaseString(key) ]\n }\n\n get names () {\n return Object.keys(this._dict)\n }\n}","/**\n * @file Math Utils\n * @author Alexander Rose \n * @private\n */\n\nexport function degToRad (deg: number) {\n return deg * 0.01745 // deg * Math.PI / 180\n}\n\nexport function radToDeg (rad: number) {\n return rad * 57.29578 // rad * 180 / Math.PI\n}\n\n// http://www.broofa.com/Tools/Math.uuid.htm\nconst chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('')\nconst uuid = new Array(36)\n\nexport function generateUUID () {\n let rnd = 0\n let r\n\n for (let i = 0; i < 36; i++) {\n if (i === 8 || i === 13 || i === 18 || i === 23) {\n uuid[ i ] = '-'\n } else if (i === 14) {\n uuid[ i ] = '4'\n } else {\n if (rnd <= 0x02) rnd = 0x2000000 + (Math.random() * 0x1000000) | 0\n r = rnd & 0xf\n rnd = rnd >> 4\n uuid[ i ] = chars[ (i === 19) ? (r & 0x3) | 0x8 : r ]\n }\n }\n\n return uuid.join('')\n}\n\nexport function countSetBits (i: number) {\n i = i - ((i >> 1) & 0x55555555)\n i = (i & 0x33333333) + ((i >> 2) & 0x33333333)\n return (((i + (i >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24\n}\n\nexport function normalize (value: number, min: number, max: number) {\n return (value - min) / (max - min)\n}\n\nexport function clamp (value: number, min: number, max: number) {\n return Math.max(min, Math.min(max, value))\n}\n\nexport function pclamp (value: number) {\n return clamp(value, 0, 100)\n}\n\nexport function saturate (value: number) {\n return clamp(value, 0, 1)\n}\n\nexport function lerp (start: number, stop: number, alpha: number) {\n return start + (stop - start) * alpha\n}\n\nexport function spline (p0: number, p1: number, p2: number, p3: number, t: number, tension: number) {\n const v0 = (p2 - p0) * tension\n const v1 = (p3 - p1) * tension\n const t2 = t * t\n const t3 = t * t2\n return (2 * p1 - 2 * p2 + v0 + v1) * t3 +\n (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 +\n v0 * t + p1\n}\n\nexport function smoothstep (min: number, max: number, x: number) {\n x = saturate(normalize(x, min, max))\n return x * x * (3 - 2 * x)\n}\n\nexport function smootherstep (min: number, max: number, x: number) {\n x = saturate(normalize(x, min, max))\n return x * x * x * (x * (x * 6 - 15) + 10)\n}\n\nexport function smootheststep (min: number, max: number, x: number) {\n x = saturate(normalize(x, min, max))\n return (\n -20 * Math.pow(x, 7) +\n 70 * Math.pow(x, 6) -\n 84 * Math.pow(x, 5) +\n 35 * Math.pow(x, 4)\n )\n}\n\nexport function almostIdentity (value: number, start: number, stop: number) {\n if (value > start) return value\n const a = 2 * stop - start\n const b = 2 * start - 3 * stop\n const t = value / start\n return (a * t + b) * t * t + stop\n}","\n/**\n * @license\n *\n * chroma.js - JavaScript library for color conversions\n * \n * Copyright (c) 2011-2017, Gregor Aisch\n * All rights reserved.\n * \n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n * \n * 1. Redistributions of source code must retain the above copyright notice, this\n * list of conditions and the following disclaimer.\n * \n * 2. Redistributions in binary form must reproduce the above copyright notice,\n * this list of conditions and the following disclaimer in the documentation\n * and/or other materials provided with the distribution.\n * \n * 3. The name Gregor Aisch may not be used to endorse or promote products\n * derived from this software without specific prior written permission.\n * \n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n * DISCLAIMED. IN NO EVENT SHALL GREGOR AISCH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,\n * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\n * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY\n * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\n * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n\n(function() {\n var Color, DEG2RAD, LAB_CONSTANTS, PI, PITHIRD, RAD2DEG, TWOPI, _average_lrgb, _guess_formats, _guess_formats_sorted, _input, _interpolators, abs, atan2, bezier, blend, blend_f, brewer, burn, chroma, clip_rgb, cmyk2rgb, colors, cos, css2rgb, darken, dodge, each, floor, hcg2rgb, hex2rgb, hsi2rgb, hsl2css, hsl2rgb, hsv2rgb, interpolate, interpolate_hsx, interpolate_lab, interpolate_lrgb, interpolate_num, interpolate_rgb, lab2lch, lab2rgb, lab_xyz, lch2lab, lch2rgb, lighten, limit, log, luminance_x, m, max, multiply, normal, num2rgb, overlay, pow, rgb2cmyk, rgb2css, rgb2hcg, rgb2hex, rgb2hsi, rgb2hsl, rgb2hsv, rgb2lab, rgb2lch, rgb2luminance, rgb2num, rgb2temperature, rgb2xyz, rgb_xyz, rnd, root, round, screen, sin, sqrt, temperature2rgb, type, unpack, w3cx11, xyz_lab, xyz_rgb,\n slice = [].slice;\n\n type = (function() {\n\n /*\n for browser-safe type checking+\n ported from jQuery's $.type\n */\n var classToType, len, name, o, ref;\n classToType = {};\n ref = \"Boolean Number String Function Array Date RegExp Undefined Null\".split(\" \");\n for (o = 0, len = ref.length; o < len; o++) {\n name = ref[o];\n classToType[\"[object \" + name + \"]\"] = name.toLowerCase();\n }\n return function(obj) {\n var strType;\n strType = Object.prototype.toString.call(obj);\n return classToType[strType] || \"object\";\n };\n })();\n\n limit = function(x, min, max) {\n if (min == null) {\n min = 0;\n }\n if (max == null) {\n max = 1;\n }\n if (x < min) {\n x = min;\n }\n if (x > max) {\n x = max;\n }\n return x;\n };\n\n unpack = function(args) {\n if (args.length >= 3) {\n return Array.prototype.slice.call(args);\n } else {\n return args[0];\n }\n };\n\n clip_rgb = function(rgb) {\n var i, o;\n rgb._clipped = false;\n rgb._unclipped = rgb.slice(0);\n for (i = o = 0; o < 3; i = ++o) {\n if (i < 3) {\n if (rgb[i] < 0 || rgb[i] > 255) {\n rgb._clipped = true;\n }\n if (rgb[i] < 0) {\n rgb[i] = 0;\n }\n if (rgb[i] > 255) {\n rgb[i] = 255;\n }\n } else if (i === 3) {\n if (rgb[i] < 0) {\n rgb[i] = 0;\n }\n if (rgb[i] > 1) {\n rgb[i] = 1;\n }\n }\n }\n if (!rgb._clipped) {\n delete rgb._unclipped;\n }\n return rgb;\n };\n\n PI = Math.PI, round = Math.round, cos = Math.cos, floor = Math.floor, pow = Math.pow, log = Math.log, sin = Math.sin, sqrt = Math.sqrt, atan2 = Math.atan2, max = Math.max, abs = Math.abs;\n\n TWOPI = PI * 2;\n\n PITHIRD = PI / 3;\n\n DEG2RAD = PI / 180;\n\n RAD2DEG = 180 / PI;\n\n chroma = function() {\n if (arguments[0] instanceof Color) {\n return arguments[0];\n }\n return (function(func, args, ctor) {\n ctor.prototype = func.prototype;\n var child = new ctor, result = func.apply(child, args);\n return Object(result) === result ? result : child;\n })(Color, arguments, function(){});\n };\n\n chroma[\"default\"] = chroma;\n\n _interpolators = [];\n\n if ((typeof module !== \"undefined\" && module !== null) && (module.exports != null)) {\n module.exports = chroma;\n }\n\n if (typeof define === 'function' && define.amd) {\n define([], function() {\n return chroma;\n });\n } else {\n root = typeof exports !== \"undefined\" && exports !== null ? exports : this;\n root.chroma = chroma;\n }\n\n chroma.version = '1.4.1';\n\n _input = {};\n\n _guess_formats = [];\n\n _guess_formats_sorted = false;\n\n Color = (function() {\n function Color() {\n var arg, args, chk, len, len1, me, mode, o, w;\n me = this;\n args = [];\n for (o = 0, len = arguments.length; o < len; o++) {\n arg = arguments[o];\n if (arg != null) {\n args.push(arg);\n }\n }\n if (args.length > 1) {\n mode = args[args.length - 1];\n }\n if (_input[mode] != null) {\n me._rgb = clip_rgb(_input[mode](unpack(args.slice(0, -1))));\n } else {\n if (!_guess_formats_sorted) {\n _guess_formats = _guess_formats.sort(function(a, b) {\n return b.p - a.p;\n });\n _guess_formats_sorted = true;\n }\n for (w = 0, len1 = _guess_formats.length; w < len1; w++) {\n chk = _guess_formats[w];\n mode = chk.test.apply(chk, args);\n if (mode) {\n break;\n }\n }\n if (mode) {\n me._rgb = clip_rgb(_input[mode].apply(_input, args));\n }\n }\n if (me._rgb == null) {\n console.warn('unknown format: ' + args);\n }\n if (me._rgb == null) {\n me._rgb = [0, 0, 0];\n }\n if (me._rgb.length === 3) {\n me._rgb.push(1);\n }\n }\n\n Color.prototype.toString = function() {\n return this.hex();\n };\n\n return Color;\n\n })();\n\n chroma._input = _input;\n\n\n /**\n \tColorBrewer colors for chroma.js\n \n \tCopyright (c) 2002 Cynthia Brewer, Mark Harrower, and The \n \tPennsylvania State University.\n \n \tLicensed under the Apache License, Version 2.0 (the \"License\"); \n \tyou may not use this file except in compliance with the License.\n \tYou may obtain a copy of the License at\t\n \thttp://www.apache.org/licenses/LICENSE-2.0\n \n \tUnless required by applicable law or agreed to in writing, software distributed\n \tunder the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n \tCONDITIONS OF ANY KIND, either express or implied. See the License for the\n \tspecific language governing permissions and limitations under the License.\n \n @preserve\n */\n\n chroma.brewer = brewer = {\n OrRd: ['#fff7ec', '#fee8c8', '#fdd49e', '#fdbb84', '#fc8d59', '#ef6548', '#d7301f', '#b30000', '#7f0000'],\n PuBu: ['#fff7fb', '#ece7f2', '#d0d1e6', '#a6bddb', '#74a9cf', '#3690c0', '#0570b0', '#045a8d', '#023858'],\n BuPu: ['#f7fcfd', '#e0ecf4', '#bfd3e6', '#9ebcda', '#8c96c6', '#8c6bb1', '#88419d', '#810f7c', '#4d004b'],\n Oranges: ['#fff5eb', '#fee6ce', '#fdd0a2', '#fdae6b', '#fd8d3c', '#f16913', '#d94801', '#a63603', '#7f2704'],\n BuGn: ['#f7fcfd', '#e5f5f9', '#ccece6', '#99d8c9', '#66c2a4', '#41ae76', '#238b45', '#006d2c', '#00441b'],\n YlOrBr: ['#ffffe5', '#fff7bc', '#fee391', '#fec44f', '#fe9929', '#ec7014', '#cc4c02', '#993404', '#662506'],\n YlGn: ['#ffffe5', '#f7fcb9', '#d9f0a3', '#addd8e', '#78c679', '#41ab5d', '#238443', '#006837', '#004529'],\n Reds: ['#fff5f0', '#fee0d2', '#fcbba1', '#fc9272', '#fb6a4a', '#ef3b2c', '#cb181d', '#a50f15', '#67000d'],\n RdPu: ['#fff7f3', '#fde0dd', '#fcc5c0', '#fa9fb5', '#f768a1', '#dd3497', '#ae017e', '#7a0177', '#49006a'],\n Greens: ['#f7fcf5', '#e5f5e0', '#c7e9c0', '#a1d99b', '#74c476', '#41ab5d', '#238b45', '#006d2c', '#00441b'],\n YlGnBu: ['#ffffd9', '#edf8b1', '#c7e9b4', '#7fcdbb', '#41b6c4', '#1d91c0', '#225ea8', '#253494', '#081d58'],\n Purples: ['#fcfbfd', '#efedf5', '#dadaeb', '#bcbddc', '#9e9ac8', '#807dba', '#6a51a3', '#54278f', '#3f007d'],\n GnBu: ['#f7fcf0', '#e0f3db', '#ccebc5', '#a8ddb5', '#7bccc4', '#4eb3d3', '#2b8cbe', '#0868ac', '#084081'],\n Greys: ['#ffffff', '#f0f0f0', '#d9d9d9', '#bdbdbd', '#969696', '#737373', '#525252', '#252525', '#000000'],\n YlOrRd: ['#ffffcc', '#ffeda0', '#fed976', '#feb24c', '#fd8d3c', '#fc4e2a', '#e31a1c', '#bd0026', '#800026'],\n PuRd: ['#f7f4f9', '#e7e1ef', '#d4b9da', '#c994c7', '#df65b0', '#e7298a', '#ce1256', '#980043', '#67001f'],\n Blues: ['#f7fbff', '#deebf7', '#c6dbef', '#9ecae1', '#6baed6', '#4292c6', '#2171b5', '#08519c', '#08306b'],\n PuBuGn: ['#fff7fb', '#ece2f0', '#d0d1e6', '#a6bddb', '#67a9cf', '#3690c0', '#02818a', '#016c59', '#014636'],\n Viridis: ['#440154', '#482777', '#3f4a8a', '#31678e', '#26838f', '#1f9d8a', '#6cce5a', '#b6de2b', '#fee825'],\n Spectral: ['#9e0142', '#d53e4f', '#f46d43', '#fdae61', '#fee08b', '#ffffbf', '#e6f598', '#abdda4', '#66c2a5', '#3288bd', '#5e4fa2'],\n RdYlGn: ['#a50026', '#d73027', '#f46d43', '#fdae61', '#fee08b', '#ffffbf', '#d9ef8b', '#a6d96a', '#66bd63', '#1a9850', '#006837'],\n RdBu: ['#67001f', '#b2182b', '#d6604d', '#f4a582', '#fddbc7', '#f7f7f7', '#d1e5f0', '#92c5de', '#4393c3', '#2166ac', '#053061'],\n PiYG: ['#8e0152', '#c51b7d', '#de77ae', '#f1b6da', '#fde0ef', '#f7f7f7', '#e6f5d0', '#b8e186', '#7fbc41', '#4d9221', '#276419'],\n PRGn: ['#40004b', '#762a83', '#9970ab', '#c2a5cf', '#e7d4e8', '#f7f7f7', '#d9f0d3', '#a6dba0', '#5aae61', '#1b7837', '#00441b'],\n RdYlBu: ['#a50026', '#d73027', '#f46d43', '#fdae61', '#fee090', '#ffffbf', '#e0f3f8', '#abd9e9', '#74add1', '#4575b4', '#313695'],\n BrBG: ['#543005', '#8c510a', '#bf812d', '#dfc27d', '#f6e8c3', '#f5f5f5', '#c7eae5', '#80cdc1', '#35978f', '#01665e', '#003c30'],\n RdGy: ['#67001f', '#b2182b', '#d6604d', '#f4a582', '#fddbc7', '#ffffff', '#e0e0e0', '#bababa', '#878787', '#4d4d4d', '#1a1a1a'],\n PuOr: ['#7f3b08', '#b35806', '#e08214', '#fdb863', '#fee0b6', '#f7f7f7', '#d8daeb', '#b2abd2', '#8073ac', '#542788', '#2d004b'],\n Set2: ['#66c2a5', '#fc8d62', '#8da0cb', '#e78ac3', '#a6d854', '#ffd92f', '#e5c494', '#b3b3b3'],\n Accent: ['#7fc97f', '#beaed4', '#fdc086', '#ffff99', '#386cb0', '#f0027f', '#bf5b17', '#666666'],\n Set1: ['#e41a1c', '#377eb8', '#4daf4a', '#984ea3', '#ff7f00', '#ffff33', '#a65628', '#f781bf', '#999999'],\n Set3: ['#8dd3c7', '#ffffb3', '#bebada', '#fb8072', '#80b1d3', '#fdb462', '#b3de69', '#fccde5', '#d9d9d9', '#bc80bd', '#ccebc5', '#ffed6f'],\n Dark2: ['#1b9e77', '#d95f02', '#7570b3', '#e7298a', '#66a61e', '#e6ab02', '#a6761d', '#666666'],\n Paired: ['#a6cee3', '#1f78b4', '#b2df8a', '#33a02c', '#fb9a99', '#e31a1c', '#fdbf6f', '#ff7f00', '#cab2d6', '#6a3d9a', '#ffff99', '#b15928'],\n Pastel2: ['#b3e2cd', '#fdcdac', '#cbd5e8', '#f4cae4', '#e6f5c9', '#fff2ae', '#f1e2cc', '#cccccc'],\n Pastel1: ['#fbb4ae', '#b3cde3', '#ccebc5', '#decbe4', '#fed9a6', '#ffffcc', '#e5d8bd', '#fddaec', '#f2f2f2']\n };\n\n (function() {\n var key, results;\n results = [];\n for (key in brewer) {\n results.push(brewer[key.toLowerCase()] = brewer[key]);\n }\n return results;\n })();\n\n\n /**\n \tX11 color names\n \n \thttp://www.w3.org/TR/css3-color/#svg-color\n */\n\n w3cx11 = {\n aliceblue: '#f0f8ff',\n antiquewhite: '#faebd7',\n aqua: '#00ffff',\n aquamarine: '#7fffd4',\n azure: '#f0ffff',\n beige: '#f5f5dc',\n bisque: '#ffe4c4',\n black: '#000000',\n blanchedalmond: '#ffebcd',\n blue: '#0000ff',\n blueviolet: '#8a2be2',\n brown: '#a52a2a',\n burlywood: '#deb887',\n cadetblue: '#5f9ea0',\n chartreuse: '#7fff00',\n chocolate: '#d2691e',\n coral: '#ff7f50',\n cornflower: '#6495ed',\n cornflowerblue: '#6495ed',\n cornsilk: '#fff8dc',\n crimson: '#dc143c',\n cyan: '#00ffff',\n darkblue: '#00008b',\n darkcyan: '#008b8b',\n darkgoldenrod: '#b8860b',\n darkgray: '#a9a9a9',\n darkgreen: '#006400',\n darkgrey: '#a9a9a9',\n darkkhaki: '#bdb76b',\n darkmagenta: '#8b008b',\n darkolivegreen: '#556b2f',\n darkorange: '#ff8c00',\n darkorchid: '#9932cc',\n darkred: '#8b0000',\n darksalmon: '#e9967a',\n darkseagreen: '#8fbc8f',\n darkslateblue: '#483d8b',\n darkslategray: '#2f4f4f',\n darkslategrey: '#2f4f4f',\n darkturquoise: '#00ced1',\n darkviolet: '#9400d3',\n deeppink: '#ff1493',\n deepskyblue: '#00bfff',\n dimgray: '#696969',\n dimgrey: '#696969',\n dodgerblue: '#1e90ff',\n firebrick: '#b22222',\n floralwhite: '#fffaf0',\n forestgreen: '#228b22',\n fuchsia: '#ff00ff',\n gainsboro: '#dcdcdc',\n ghostwhite: '#f8f8ff',\n gold: '#ffd700',\n goldenrod: '#daa520',\n gray: '#808080',\n green: '#008000',\n greenyellow: '#adff2f',\n grey: '#808080',\n honeydew: '#f0fff0',\n hotpink: '#ff69b4',\n indianred: '#cd5c5c',\n indigo: '#4b0082',\n ivory: '#fffff0',\n khaki: '#f0e68c',\n laserlemon: '#ffff54',\n lavender: '#e6e6fa',\n lavenderblush: '#fff0f5',\n lawngreen: '#7cfc00',\n lemonchiffon: '#fffacd',\n lightblue: '#add8e6',\n lightcoral: '#f08080',\n lightcyan: '#e0ffff',\n lightgoldenrod: '#fafad2',\n lightgoldenrodyellow: '#fafad2',\n lightgray: '#d3d3d3',\n lightgreen: '#90ee90',\n lightgrey: '#d3d3d3',\n lightpink: '#ffb6c1',\n lightsalmon: '#ffa07a',\n lightseagreen: '#20b2aa',\n lightskyblue: '#87cefa',\n lightslategray: '#778899',\n lightslategrey: '#778899',\n lightsteelblue: '#b0c4de',\n lightyellow: '#ffffe0',\n lime: '#00ff00',\n limegreen: '#32cd32',\n linen: '#faf0e6',\n magenta: '#ff00ff',\n maroon: '#800000',\n maroon2: '#7f0000',\n maroon3: '#b03060',\n mediumaquamarine: '#66cdaa',\n mediumblue: '#0000cd',\n mediumorchid: '#ba55d3',\n mediumpurple: '#9370db',\n mediumseagreen: '#3cb371',\n mediumslateblue: '#7b68ee',\n mediumspringgreen: '#00fa9a',\n mediumturquoise: '#48d1cc',\n mediumvioletred: '#c71585',\n midnightblue: '#191970',\n mintcream: '#f5fffa',\n mistyrose: '#ffe4e1',\n moccasin: '#ffe4b5',\n navajowhite: '#ffdead',\n navy: '#000080',\n oldlace: '#fdf5e6',\n olive: '#808000',\n olivedrab: '#6b8e23',\n orange: '#ffa500',\n orangered: '#ff4500',\n orchid: '#da70d6',\n palegoldenrod: '#eee8aa',\n palegreen: '#98fb98',\n paleturquoise: '#afeeee',\n palevioletred: '#db7093',\n papayawhip: '#ffefd5',\n peachpuff: '#ffdab9',\n peru: '#cd853f',\n pink: '#ffc0cb',\n plum: '#dda0dd',\n powderblue: '#b0e0e6',\n purple: '#800080',\n purple2: '#7f007f',\n purple3: '#a020f0',\n rebeccapurple: '#663399',\n red: '#ff0000',\n rosybrown: '#bc8f8f',\n royalblue: '#4169e1',\n saddlebrown: '#8b4513',\n salmon: '#fa8072',\n sandybrown: '#f4a460',\n seagreen: '#2e8b57',\n seashell: '#fff5ee',\n sienna: '#a0522d',\n silver: '#c0c0c0',\n skyblue: '#87ceeb',\n slateblue: '#6a5acd',\n slategray: '#708090',\n slategrey: '#708090',\n snow: '#fffafa',\n springgreen: '#00ff7f',\n steelblue: '#4682b4',\n tan: '#d2b48c',\n teal: '#008080',\n thistle: '#d8bfd8',\n tomato: '#ff6347',\n turquoise: '#40e0d0',\n violet: '#ee82ee',\n wheat: '#f5deb3',\n white: '#ffffff',\n whitesmoke: '#f5f5f5',\n yellow: '#ffff00',\n yellowgreen: '#9acd32'\n };\n\n chroma.colors = colors = w3cx11;\n\n lab2rgb = function() {\n var a, args, b, g, l, r, x, y, z;\n args = unpack(arguments);\n l = args[0], a = args[1], b = args[2];\n y = (l + 16) / 116;\n x = isNaN(a) ? y : y + a / 500;\n z = isNaN(b) ? y : y - b / 200;\n y = LAB_CONSTANTS.Yn * lab_xyz(y);\n x = LAB_CONSTANTS.Xn * lab_xyz(x);\n z = LAB_CONSTANTS.Zn * lab_xyz(z);\n r = xyz_rgb(3.2404542 * x - 1.5371385 * y - 0.4985314 * z);\n g = xyz_rgb(-0.9692660 * x + 1.8760108 * y + 0.0415560 * z);\n b = xyz_rgb(0.0556434 * x - 0.2040259 * y + 1.0572252 * z);\n return [r, g, b, args.length > 3 ? args[3] : 1];\n };\n\n xyz_rgb = function(r) {\n return 255 * (r <= 0.00304 ? 12.92 * r : 1.055 * pow(r, 1 / 2.4) - 0.055);\n };\n\n lab_xyz = function(t) {\n if (t > LAB_CONSTANTS.t1) {\n return t * t * t;\n } else {\n return LAB_CONSTANTS.t2 * (t - LAB_CONSTANTS.t0);\n }\n };\n\n LAB_CONSTANTS = {\n Kn: 18,\n Xn: 0.950470,\n Yn: 1,\n Zn: 1.088830,\n t0: 0.137931034,\n t1: 0.206896552,\n t2: 0.12841855,\n t3: 0.008856452\n };\n\n rgb2lab = function() {\n var b, g, r, ref, ref1, x, y, z;\n ref = unpack(arguments), r = ref[0], g = ref[1], b = ref[2];\n ref1 = rgb2xyz(r, g, b), x = ref1[0], y = ref1[1], z = ref1[2];\n return [116 * y - 16, 500 * (x - y), 200 * (y - z)];\n };\n\n rgb_xyz = function(r) {\n if ((r /= 255) <= 0.04045) {\n return r / 12.92;\n } else {\n return pow((r + 0.055) / 1.055, 2.4);\n }\n };\n\n xyz_lab = function(t) {\n if (t > LAB_CONSTANTS.t3) {\n return pow(t, 1 / 3);\n } else {\n return t / LAB_CONSTANTS.t2 + LAB_CONSTANTS.t0;\n }\n };\n\n rgb2xyz = function() {\n var b, g, r, ref, x, y, z;\n ref = unpack(arguments), r = ref[0], g = ref[1], b = ref[2];\n r = rgb_xyz(r);\n g = rgb_xyz(g);\n b = rgb_xyz(b);\n x = xyz_lab((0.4124564 * r + 0.3575761 * g + 0.1804375 * b) / LAB_CONSTANTS.Xn);\n y = xyz_lab((0.2126729 * r + 0.7151522 * g + 0.0721750 * b) / LAB_CONSTANTS.Yn);\n z = xyz_lab((0.0193339 * r + 0.1191920 * g + 0.9503041 * b) / LAB_CONSTANTS.Zn);\n return [x, y, z];\n };\n\n chroma.lab = function() {\n return (function(func, args, ctor) {\n ctor.prototype = func.prototype;\n var child = new ctor, result = func.apply(child, args);\n return Object(result) === result ? result : child;\n })(Color, slice.call(arguments).concat(['lab']), function(){});\n };\n\n _input.lab = lab2rgb;\n\n Color.prototype.lab = function() {\n return rgb2lab(this._rgb);\n };\n\n bezier = function(colors) {\n var I, I0, I1, c, lab0, lab1, lab2, lab3, ref, ref1, ref2;\n colors = (function() {\n var len, o, results;\n results = [];\n for (o = 0, len = colors.length; o < len; o++) {\n c = colors[o];\n results.push(chroma(c));\n }\n return results;\n })();\n if (colors.length === 2) {\n ref = (function() {\n var len, o, results;\n results = [];\n for (o = 0, len = colors.length; o < len; o++) {\n c = colors[o];\n results.push(c.lab());\n }\n return results;\n })(), lab0 = ref[0], lab1 = ref[1];\n I = function(t) {\n var i, lab;\n lab = (function() {\n var o, results;\n results = [];\n for (i = o = 0; o <= 2; i = ++o) {\n results.push(lab0[i] + t * (lab1[i] - lab0[i]));\n }\n return results;\n })();\n return chroma.lab.apply(chroma, lab);\n };\n } else if (colors.length === 3) {\n ref1 = (function() {\n var len, o, results;\n results = [];\n for (o = 0, len = colors.length; o < len; o++) {\n c = colors[o];\n results.push(c.lab());\n }\n return results;\n })(), lab0 = ref1[0], lab1 = ref1[1], lab2 = ref1[2];\n I = function(t) {\n var i, lab;\n lab = (function() {\n var o, results;\n results = [];\n for (i = o = 0; o <= 2; i = ++o) {\n results.push((1 - t) * (1 - t) * lab0[i] + 2 * (1 - t) * t * lab1[i] + t * t * lab2[i]);\n }\n return results;\n })();\n return chroma.lab.apply(chroma, lab);\n };\n } else if (colors.length === 4) {\n ref2 = (function() {\n var len, o, results;\n results = [];\n for (o = 0, len = colors.length; o < len; o++) {\n c = colors[o];\n results.push(c.lab());\n }\n return results;\n })(), lab0 = ref2[0], lab1 = ref2[1], lab2 = ref2[2], lab3 = ref2[3];\n I = function(t) {\n var i, lab;\n lab = (function() {\n var o, results;\n results = [];\n for (i = o = 0; o <= 2; i = ++o) {\n results.push((1 - t) * (1 - t) * (1 - t) * lab0[i] + 3 * (1 - t) * (1 - t) * t * lab1[i] + 3 * (1 - t) * t * t * lab2[i] + t * t * t * lab3[i]);\n }\n return results;\n })();\n return chroma.lab.apply(chroma, lab);\n };\n } else if (colors.length === 5) {\n I0 = bezier(colors.slice(0, 3));\n I1 = bezier(colors.slice(2, 5));\n I = function(t) {\n if (t < 0.5) {\n return I0(t * 2);\n } else {\n return I1((t - 0.5) * 2);\n }\n };\n }\n return I;\n };\n\n chroma.bezier = function(colors) {\n var f;\n f = bezier(colors);\n f.scale = function() {\n return chroma.scale(f);\n };\n return f;\n };\n\n chroma.cubehelix = function(start, rotations, hue, gamma, lightness) {\n var dh, dl, f;\n if (start == null) {\n start = 300;\n }\n if (rotations == null) {\n rotations = -1.5;\n }\n if (hue == null) {\n hue = 1;\n }\n if (gamma == null) {\n gamma = 1;\n }\n if (lightness == null) {\n lightness = [0, 1];\n }\n dh = 0;\n if (type(lightness) === 'array') {\n dl = lightness[1] - lightness[0];\n } else {\n dl = 0;\n lightness = [lightness, lightness];\n }\n f = function(fract) {\n var a, amp, b, cos_a, g, h, l, r, sin_a;\n a = TWOPI * ((start + 120) / 360 + rotations * fract);\n l = pow(lightness[0] + dl * fract, gamma);\n h = dh !== 0 ? hue[0] + fract * dh : hue;\n amp = h * l * (1 - l) / 2;\n cos_a = cos(a);\n sin_a = sin(a);\n r = l + amp * (-0.14861 * cos_a + 1.78277 * sin_a);\n g = l + amp * (-0.29227 * cos_a - 0.90649 * sin_a);\n b = l + amp * (+1.97294 * cos_a);\n return chroma(clip_rgb([r * 255, g * 255, b * 255, 1]));\n };\n f.start = function(s) {\n if (s == null) {\n return start;\n }\n start = s;\n return f;\n };\n f.rotations = function(r) {\n if (r == null) {\n return rotations;\n }\n rotations = r;\n return f;\n };\n f.gamma = function(g) {\n if (g == null) {\n return gamma;\n }\n gamma = g;\n return f;\n };\n f.hue = function(h) {\n if (h == null) {\n return hue;\n }\n hue = h;\n if (type(hue) === 'array') {\n dh = hue[1] - hue[0];\n if (dh === 0) {\n hue = hue[1];\n }\n } else {\n dh = 0;\n }\n return f;\n };\n f.lightness = function(h) {\n if (h == null) {\n return lightness;\n }\n if (type(h) === 'array') {\n lightness = h;\n dl = h[1] - h[0];\n } else {\n lightness = [h, h];\n dl = 0;\n }\n return f;\n };\n f.scale = function() {\n return chroma.scale(f);\n };\n f.hue(hue);\n return f;\n };\n\n chroma.random = function() {\n var code, digits, i, o;\n digits = '0123456789abcdef';\n code = '#';\n for (i = o = 0; o < 6; i = ++o) {\n code += digits.charAt(floor(Math.random() * 16));\n }\n return new Color(code);\n };\n\n _interpolators = [];\n\n interpolate = function(col1, col2, f, m) {\n var interpol, len, o, res;\n if (f == null) {\n f = 0.5;\n }\n if (m == null) {\n m = 'rgb';\n }\n\n /*\n interpolates between colors\n f = 0 --> me\n f = 1 --> col\n */\n if (type(col1) !== 'object') {\n col1 = chroma(col1);\n }\n if (type(col2) !== 'object') {\n col2 = chroma(col2);\n }\n for (o = 0, len = _interpolators.length; o < len; o++) {\n interpol = _interpolators[o];\n if (m === interpol[0]) {\n res = interpol[1](col1, col2, f, m);\n break;\n }\n }\n if (res == null) {\n throw \"color mode \" + m + \" is not supported\";\n }\n return res.alpha(col1.alpha() + f * (col2.alpha() - col1.alpha()));\n };\n\n chroma.interpolate = interpolate;\n\n Color.prototype.interpolate = function(col2, f, m) {\n return interpolate(this, col2, f, m);\n };\n\n chroma.mix = interpolate;\n\n Color.prototype.mix = Color.prototype.interpolate;\n\n _input.rgb = function() {\n var k, ref, results, v;\n ref = unpack(arguments);\n results = [];\n for (k in ref) {\n v = ref[k];\n results.push(v);\n }\n return results;\n };\n\n chroma.rgb = function() {\n return (function(func, args, ctor) {\n ctor.prototype = func.prototype;\n var child = new ctor, result = func.apply(child, args);\n return Object(result) === result ? result : child;\n })(Color, slice.call(arguments).concat(['rgb']), function(){});\n };\n\n Color.prototype.rgb = function(round) {\n if (round == null) {\n round = true;\n }\n if (round) {\n return this._rgb.map(Math.round).slice(0, 3);\n } else {\n return this._rgb.slice(0, 3);\n }\n };\n\n Color.prototype.rgba = function(round) {\n if (round == null) {\n round = true;\n }\n if (!round) {\n return this._rgb.slice(0);\n }\n return [Math.round(this._rgb[0]), Math.round(this._rgb[1]), Math.round(this._rgb[2]), this._rgb[3]];\n };\n\n _guess_formats.push({\n p: 3,\n test: function(n) {\n var a;\n a = unpack(arguments);\n if (type(a) === 'array' && a.length === 3) {\n return 'rgb';\n }\n if (a.length === 4 && type(a[3]) === \"number\" && a[3] >= 0 && a[3] <= 1) {\n return 'rgb';\n }\n }\n });\n\n _input.lrgb = _input.rgb;\n\n interpolate_lrgb = function(col1, col2, f, m) {\n var xyz0, xyz1;\n xyz0 = col1._rgb;\n xyz1 = col2._rgb;\n return new Color(sqrt(pow(xyz0[0], 2) * (1 - f) + pow(xyz1[0], 2) * f), sqrt(pow(xyz0[1], 2) * (1 - f) + pow(xyz1[1], 2) * f), sqrt(pow(xyz0[2], 2) * (1 - f) + pow(xyz1[2], 2) * f), m);\n };\n\n _average_lrgb = function(colors) {\n var col, f, len, o, rgb, xyz;\n f = 1 / colors.length;\n xyz = [0, 0, 0, 0];\n for (o = 0, len = colors.length; o < len; o++) {\n col = colors[o];\n rgb = col._rgb;\n xyz[0] += pow(rgb[0], 2) * f;\n xyz[1] += pow(rgb[1], 2) * f;\n xyz[2] += pow(rgb[2], 2) * f;\n xyz[3] += rgb[3] * f;\n }\n xyz[0] = sqrt(xyz[0]);\n xyz[1] = sqrt(xyz[1]);\n xyz[2] = sqrt(xyz[2]);\n if (xyz[3] > 1) {\n xyz[3] = 1;\n }\n return new Color(clip_rgb(xyz));\n };\n\n _interpolators.push(['lrgb', interpolate_lrgb]);\n\n chroma.average = function(colors, mode) {\n var A, alpha, c, cnt, dx, dy, first, i, l, len, o, xyz, xyz2;\n if (mode == null) {\n mode = 'rgb';\n }\n l = colors.length;\n colors = colors.map(function(c) {\n return chroma(c);\n });\n first = colors.splice(0, 1)[0];\n if (mode === 'lrgb') {\n return _average_lrgb(colors);\n }\n xyz = first.get(mode);\n cnt = [];\n dx = 0;\n dy = 0;\n for (i in xyz) {\n xyz[i] = xyz[i] || 0;\n cnt.push(isNaN(xyz[i]) ? 0 : 1);\n if (mode.charAt(i) === 'h' && !isNaN(xyz[i])) {\n A = xyz[i] / 180 * PI;\n dx += cos(A);\n dy += sin(A);\n }\n }\n alpha = first.alpha();\n for (o = 0, len = colors.length; o < len; o++) {\n c = colors[o];\n xyz2 = c.get(mode);\n alpha += c.alpha();\n for (i in xyz) {\n if (!isNaN(xyz2[i])) {\n cnt[i] += 1;\n if (mode.charAt(i) === 'h') {\n A = xyz2[i] / 180 * PI;\n dx += cos(A);\n dy += sin(A);\n } else {\n xyz[i] += xyz2[i];\n }\n }\n }\n }\n for (i in xyz) {\n if (mode.charAt(i) === 'h') {\n A = atan2(dy / cnt[i], dx / cnt[i]) / PI * 180;\n while (A < 0) {\n A += 360;\n }\n while (A >= 360) {\n A -= 360;\n }\n xyz[i] = A;\n } else {\n xyz[i] = xyz[i] / cnt[i];\n }\n }\n return chroma(xyz, mode).alpha(alpha / l);\n };\n\n hex2rgb = function(hex) {\n var a, b, g, r, rgb, u;\n if (hex.match(/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/)) {\n if (hex.length === 4 || hex.length === 7) {\n hex = hex.substr(1);\n }\n if (hex.length === 3) {\n hex = hex.split(\"\");\n hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];\n }\n u = parseInt(hex, 16);\n r = u >> 16;\n g = u >> 8 & 0xFF;\n b = u & 0xFF;\n return [r, g, b, 1];\n }\n if (hex.match(/^#?([A-Fa-f0-9]{8})$/)) {\n if (hex.length === 9) {\n hex = hex.substr(1);\n }\n u = parseInt(hex, 16);\n r = u >> 24 & 0xFF;\n g = u >> 16 & 0xFF;\n b = u >> 8 & 0xFF;\n a = round((u & 0xFF) / 0xFF * 100) / 100;\n return [r, g, b, a];\n }\n if ((_input.css != null) && (rgb = _input.css(hex))) {\n return rgb;\n }\n throw \"unknown color: \" + hex;\n };\n\n rgb2hex = function(channels, mode) {\n var a, b, g, hxa, r, str, u;\n if (mode == null) {\n mode = 'auto';\n }\n r = channels[0], g = channels[1], b = channels[2], a = channels[3];\n if (mode === 'auto') {\n mode = a < 1 ? 'rgba' : 'rgb';\n }\n r = Math.round(r);\n g = Math.round(g);\n b = Math.round(b);\n u = r << 16 | g << 8 | b;\n str = \"000000\" + u.toString(16);\n str = str.substr(str.length - 6);\n hxa = '0' + round(a * 255).toString(16);\n hxa = hxa.substr(hxa.length - 2);\n return \"#\" + (function() {\n switch (mode.toLowerCase()) {\n case 'rgba':\n return str + hxa;\n case 'argb':\n return hxa + str;\n default:\n return str;\n }\n })();\n };\n\n _input.hex = function(h) {\n return hex2rgb(h);\n };\n\n chroma.hex = function() {\n return (function(func, args, ctor) {\n ctor.prototype = func.prototype;\n var child = new ctor, result = func.apply(child, args);\n return Object(result) === result ? result : child;\n })(Color, slice.call(arguments).concat(['hex']), function(){});\n };\n\n Color.prototype.hex = function(mode) {\n if (mode == null) {\n mode = 'auto';\n }\n return rgb2hex(this._rgb, mode);\n };\n\n _guess_formats.push({\n p: 4,\n test: function(n) {\n if (arguments.length === 1 && type(n) === \"string\") {\n return 'hex';\n }\n }\n });\n\n hsl2rgb = function() {\n var args, b, c, g, h, i, l, o, r, ref, s, t1, t2, t3;\n args = unpack(arguments);\n h = args[0], s = args[1], l = args[2];\n if (s === 0) {\n r = g = b = l * 255;\n } else {\n t3 = [0, 0, 0];\n c = [0, 0, 0];\n t2 = l < 0.5 ? l * (1 + s) : l + s - l * s;\n t1 = 2 * l - t2;\n h /= 360;\n t3[0] = h + 1 / 3;\n t3[1] = h;\n t3[2] = h - 1 / 3;\n for (i = o = 0; o <= 2; i = ++o) {\n if (t3[i] < 0) {\n t3[i] += 1;\n }\n if (t3[i] > 1) {\n t3[i] -= 1;\n }\n if (6 * t3[i] < 1) {\n c[i] = t1 + (t2 - t1) * 6 * t3[i];\n } else if (2 * t3[i] < 1) {\n c[i] = t2;\n } else if (3 * t3[i] < 2) {\n c[i] = t1 + (t2 - t1) * ((2 / 3) - t3[i]) * 6;\n } else {\n c[i] = t1;\n }\n }\n ref = [round(c[0] * 255), round(c[1] * 255), round(c[2] * 255)], r = ref[0], g = ref[1], b = ref[2];\n }\n if (args.length > 3) {\n return [r, g, b, args[3]];\n } else {\n return [r, g, b];\n }\n };\n\n rgb2hsl = function(r, g, b) {\n var h, l, min, ref, s;\n if (r !== void 0 && r.length >= 3) {\n ref = r, r = ref[0], g = ref[1], b = ref[2];\n }\n r /= 255;\n g /= 255;\n b /= 255;\n min = Math.min(r, g, b);\n max = Math.max(r, g, b);\n l = (max + min) / 2;\n if (max === min) {\n s = 0;\n h = Number.NaN;\n } else {\n s = l < 0.5 ? (max - min) / (max + min) : (max - min) / (2 - max - min);\n }\n if (r === max) {\n h = (g - b) / (max - min);\n } else if (g === max) {\n h = 2 + (b - r) / (max - min);\n } else if (b === max) {\n h = 4 + (r - g) / (max - min);\n }\n h *= 60;\n if (h < 0) {\n h += 360;\n }\n return [h, s, l];\n };\n\n chroma.hsl = function() {\n return (function(func, args, ctor) {\n ctor.prototype = func.prototype;\n var child = new ctor, result = func.apply(child, args);\n return Object(result) === result ? result : child;\n })(Color, slice.call(arguments).concat(['hsl']), function(){});\n };\n\n _input.hsl = hsl2rgb;\n\n Color.prototype.hsl = function() {\n return rgb2hsl(this._rgb);\n };\n\n hsv2rgb = function() {\n var args, b, f, g, h, i, p, q, r, ref, ref1, ref2, ref3, ref4, ref5, s, t, v;\n args = unpack(arguments);\n h = args[0], s = args[1], v = args[2];\n v *= 255;\n if (s === 0) {\n r = g = b = v;\n } else {\n if (h === 360) {\n h = 0;\n }\n if (h > 360) {\n h -= 360;\n }\n if (h < 0) {\n h += 360;\n }\n h /= 60;\n i = floor(h);\n f = h - i;\n p = v * (1 - s);\n q = v * (1 - s * f);\n t = v * (1 - s * (1 - f));\n switch (i) {\n case 0:\n ref = [v, t, p], r = ref[0], g = ref[1], b = ref[2];\n break;\n case 1:\n ref1 = [q, v, p], r = ref1[0], g = ref1[1], b = ref1[2];\n break;\n case 2:\n ref2 = [p, v, t], r = ref2[0], g = ref2[1], b = ref2[2];\n break;\n case 3:\n ref3 = [p, q, v], r = ref3[0], g = ref3[1], b = ref3[2];\n break;\n case 4:\n ref4 = [t, p, v], r = ref4[0], g = ref4[1], b = ref4[2];\n break;\n case 5:\n ref5 = [v, p, q], r = ref5[0], g = ref5[1], b = ref5[2];\n }\n }\n return [r, g, b, args.length > 3 ? args[3] : 1];\n };\n\n rgb2hsv = function() {\n var b, delta, g, h, min, r, ref, s, v;\n ref = unpack(arguments), r = ref[0], g = ref[1], b = ref[2];\n min = Math.min(r, g, b);\n max = Math.max(r, g, b);\n delta = max - min;\n v = max / 255.0;\n if (max === 0) {\n h = Number.NaN;\n s = 0;\n } else {\n s = delta / max;\n if (r === max) {\n h = (g - b) / delta;\n }\n if (g === max) {\n h = 2 + (b - r) / delta;\n }\n if (b === max) {\n h = 4 + (r - g) / delta;\n }\n h *= 60;\n if (h < 0) {\n h += 360;\n }\n }\n return [h, s, v];\n };\n\n chroma.hsv = function() {\n return (function(func, args, ctor) {\n ctor.prototype = func.prototype;\n var child = new ctor, result = func.apply(child, args);\n return Object(result) === result ? result : child;\n })(Color, slice.call(arguments).concat(['hsv']), function(){});\n };\n\n _input.hsv = hsv2rgb;\n\n Color.prototype.hsv = function() {\n return rgb2hsv(this._rgb);\n };\n\n num2rgb = function(num) {\n var b, g, r;\n if (type(num) === \"number\" && num >= 0 && num <= 0xFFFFFF) {\n r = num >> 16;\n g = (num >> 8) & 0xFF;\n b = num & 0xFF;\n return [r, g, b, 1];\n }\n console.warn(\"unknown num color: \" + num);\n return [0, 0, 0, 1];\n };\n\n rgb2num = function() {\n var b, g, r, ref;\n ref = unpack(arguments), r = ref[0], g = ref[1], b = ref[2];\n return (r << 16) + (g << 8) + b;\n };\n\n chroma.num = function(num) {\n return new Color(num, 'num');\n };\n\n Color.prototype.num = function(mode) {\n if (mode == null) {\n mode = 'rgb';\n }\n return rgb2num(this._rgb, mode);\n };\n\n _input.num = num2rgb;\n\n _guess_formats.push({\n p: 1,\n test: function(n) {\n if (arguments.length === 1 && type(n) === \"number\" && n >= 0 && n <= 0xFFFFFF) {\n return 'num';\n }\n }\n });\n\n hcg2rgb = function() {\n var _c, _g, args, b, c, f, g, h, i, p, q, r, ref, ref1, ref2, ref3, ref4, ref5, t, v;\n args = unpack(arguments);\n h = args[0], c = args[1], _g = args[2];\n c = c / 100;\n g = g / 100 * 255;\n _c = c * 255;\n if (c === 0) {\n r = g = b = _g;\n } else {\n if (h === 360) {\n h = 0;\n }\n if (h > 360) {\n h -= 360;\n }\n if (h < 0) {\n h += 360;\n }\n h /= 60;\n i = floor(h);\n f = h - i;\n p = _g * (1 - c);\n q = p + _c * (1 - f);\n t = p + _c * f;\n v = p + _c;\n switch (i) {\n case 0:\n ref = [v, t, p], r = ref[0], g = ref[1], b = ref[2];\n break;\n case 1:\n ref1 = [q, v, p], r = ref1[0], g = ref1[1], b = ref1[2];\n break;\n case 2:\n ref2 = [p, v, t], r = ref2[0], g = ref2[1], b = ref2[2];\n break;\n case 3:\n ref3 = [p, q, v], r = ref3[0], g = ref3[1], b = ref3[2];\n break;\n case 4:\n ref4 = [t, p, v], r = ref4[0], g = ref4[1], b = ref4[2];\n break;\n case 5:\n ref5 = [v, p, q], r = ref5[0], g = ref5[1], b = ref5[2];\n }\n }\n return [r, g, b, args.length > 3 ? args[3] : 1];\n };\n\n rgb2hcg = function() {\n var _g, b, c, delta, g, h, min, r, ref;\n ref = unpack(arguments), r = ref[0], g = ref[1], b = ref[2];\n min = Math.min(r, g, b);\n max = Math.max(r, g, b);\n delta = max - min;\n c = delta * 100 / 255;\n _g = min / (255 - delta) * 100;\n if (delta === 0) {\n h = Number.NaN;\n } else {\n if (r === max) {\n h = (g - b) / delta;\n }\n if (g === max) {\n h = 2 + (b - r) / delta;\n }\n if (b === max) {\n h = 4 + (r - g) / delta;\n }\n h *= 60;\n if (h < 0) {\n h += 360;\n }\n }\n return [h, c, _g];\n };\n\n chroma.hcg = function() {\n return (function(func, args, ctor) {\n ctor.prototype = func.prototype;\n var child = new ctor, result = func.apply(child, args);\n return Object(result) === result ? result : child;\n })(Color, slice.call(arguments).concat(['hcg']), function(){});\n };\n\n _input.hcg = hcg2rgb;\n\n Color.prototype.hcg = function() {\n return rgb2hcg(this._rgb);\n };\n\n css2rgb = function(css) {\n var aa, ab, hsl, i, m, o, rgb, w;\n css = css.toLowerCase();\n if ((chroma.colors != null) && chroma.colors[css]) {\n return hex2rgb(chroma.colors[css]);\n }\n if (m = css.match(/rgb\\(\\s*(\\-?\\d+),\\s*(\\-?\\d+)\\s*,\\s*(\\-?\\d+)\\s*\\)/)) {\n rgb = m.slice(1, 4);\n for (i = o = 0; o <= 2; i = ++o) {\n rgb[i] = +rgb[i];\n }\n rgb[3] = 1;\n } else if (m = css.match(/rgba\\(\\s*(\\-?\\d+),\\s*(\\-?\\d+)\\s*,\\s*(\\-?\\d+)\\s*,\\s*([01]|[01]?\\.\\d+)\\)/)) {\n rgb = m.slice(1, 5);\n for (i = w = 0; w <= 3; i = ++w) {\n rgb[i] = +rgb[i];\n }\n } else if (m = css.match(/rgb\\(\\s*(\\-?\\d+(?:\\.\\d+)?)%,\\s*(\\-?\\d+(?:\\.\\d+)?)%\\s*,\\s*(\\-?\\d+(?:\\.\\d+)?)%\\s*\\)/)) {\n rgb = m.slice(1, 4);\n for (i = aa = 0; aa <= 2; i = ++aa) {\n rgb[i] = round(rgb[i] * 2.55);\n }\n rgb[3] = 1;\n } else if (m = css.match(/rgba\\(\\s*(\\-?\\d+(?:\\.\\d+)?)%,\\s*(\\-?\\d+(?:\\.\\d+)?)%\\s*,\\s*(\\-?\\d+(?:\\.\\d+)?)%\\s*,\\s*([01]|[01]?\\.\\d+)\\)/)) {\n rgb = m.slice(1, 5);\n for (i = ab = 0; ab <= 2; i = ++ab) {\n rgb[i] = round(rgb[i] * 2.55);\n }\n rgb[3] = +rgb[3];\n } else if (m = css.match(/hsl\\(\\s*(\\-?\\d+(?:\\.\\d+)?),\\s*(\\-?\\d+(?:\\.\\d+)?)%\\s*,\\s*(\\-?\\d+(?:\\.\\d+)?)%\\s*\\)/)) {\n hsl = m.slice(1, 4);\n hsl[1] *= 0.01;\n hsl[2] *= 0.01;\n rgb = hsl2rgb(hsl);\n rgb[3] = 1;\n } else if (m = css.match(/hsla\\(\\s*(\\-?\\d+(?:\\.\\d+)?),\\s*(\\-?\\d+(?:\\.\\d+)?)%\\s*,\\s*(\\-?\\d+(?:\\.\\d+)?)%\\s*,\\s*([01]|[01]?\\.\\d+)\\)/)) {\n hsl = m.slice(1, 4);\n hsl[1] *= 0.01;\n hsl[2] *= 0.01;\n rgb = hsl2rgb(hsl);\n rgb[3] = +m[4];\n }\n return rgb;\n };\n\n rgb2css = function(rgba) {\n var mode;\n mode = rgba[3] < 1 ? 'rgba' : 'rgb';\n if (mode === 'rgb') {\n return mode + '(' + rgba.slice(0, 3).map(round).join(',') + ')';\n } else if (mode === 'rgba') {\n return mode + '(' + rgba.slice(0, 3).map(round).join(',') + ',' + rgba[3] + ')';\n } else {\n\n }\n };\n\n rnd = function(a) {\n return round(a * 100) / 100;\n };\n\n hsl2css = function(hsl, alpha) {\n var mode;\n mode = alpha < 1 ? 'hsla' : 'hsl';\n hsl[0] = rnd(hsl[0] || 0);\n hsl[1] = rnd(hsl[1] * 100) + '%';\n hsl[2] = rnd(hsl[2] * 100) + '%';\n if (mode === 'hsla') {\n hsl[3] = alpha;\n }\n return mode + '(' + hsl.join(',') + ')';\n };\n\n _input.css = function(h) {\n return css2rgb(h);\n };\n\n chroma.css = function() {\n return (function(func, args, ctor) {\n ctor.prototype = func.prototype;\n var child = new ctor, result = func.apply(child, args);\n return Object(result) === result ? result : child;\n })(Color, slice.call(arguments).concat(['css']), function(){});\n };\n\n Color.prototype.css = function(mode) {\n if (mode == null) {\n mode = 'rgb';\n }\n if (mode.slice(0, 3) === 'rgb') {\n return rgb2css(this._rgb);\n } else if (mode.slice(0, 3) === 'hsl') {\n return hsl2css(this.hsl(), this.alpha());\n }\n };\n\n _input.named = function(name) {\n return hex2rgb(w3cx11[name]);\n };\n\n _guess_formats.push({\n p: 5,\n test: function(n) {\n if (arguments.length === 1 && (w3cx11[n] != null)) {\n return 'named';\n }\n }\n });\n\n Color.prototype.name = function(n) {\n var h, k;\n if (arguments.length) {\n if (w3cx11[n]) {\n this._rgb = hex2rgb(w3cx11[n]);\n }\n this._rgb[3] = 1;\n this;\n }\n h = this.hex('rgb');\n for (k in w3cx11) {\n if (h === w3cx11[k]) {\n return k;\n }\n }\n return h;\n };\n\n lch2lab = function() {\n\n /*\n Convert from a qualitative parameter h and a quantitative parameter l to a 24-bit pixel.\n These formulas were invented by David Dalrymple to obtain maximum contrast without going\n out of gamut if the parameters are in the range 0-1.\n \n A saturation multiplier was added by Gregor Aisch\n */\n var c, h, l, ref;\n ref = unpack(arguments), l = ref[0], c = ref[1], h = ref[2];\n h = h * DEG2RAD;\n return [l, cos(h) * c, sin(h) * c];\n };\n\n lch2rgb = function() {\n var L, a, args, b, c, g, h, l, r, ref, ref1;\n args = unpack(arguments);\n l = args[0], c = args[1], h = args[2];\n ref = lch2lab(l, c, h), L = ref[0], a = ref[1], b = ref[2];\n ref1 = lab2rgb(L, a, b), r = ref1[0], g = ref1[1], b = ref1[2];\n return [r, g, b, args.length > 3 ? args[3] : 1];\n };\n\n lab2lch = function() {\n var a, b, c, h, l, ref;\n ref = unpack(arguments), l = ref[0], a = ref[1], b = ref[2];\n c = sqrt(a * a + b * b);\n h = (atan2(b, a) * RAD2DEG + 360) % 360;\n if (round(c * 10000) === 0) {\n h = Number.NaN;\n }\n return [l, c, h];\n };\n\n rgb2lch = function() {\n var a, b, g, l, r, ref, ref1;\n ref = unpack(arguments), r = ref[0], g = ref[1], b = ref[2];\n ref1 = rgb2lab(r, g, b), l = ref1[0], a = ref1[1], b = ref1[2];\n return lab2lch(l, a, b);\n };\n\n chroma.lch = function() {\n var args;\n args = unpack(arguments);\n return new Color(args, 'lch');\n };\n\n chroma.hcl = function() {\n var args;\n args = unpack(arguments);\n return new Color(args, 'hcl');\n };\n\n _input.lch = lch2rgb;\n\n _input.hcl = function() {\n var c, h, l, ref;\n ref = unpack(arguments), h = ref[0], c = ref[1], l = ref[2];\n return lch2rgb([l, c, h]);\n };\n\n Color.prototype.lch = function() {\n return rgb2lch(this._rgb);\n };\n\n Color.prototype.hcl = function() {\n return rgb2lch(this._rgb).reverse();\n };\n\n rgb2cmyk = function(mode) {\n var b, c, f, g, k, m, r, ref, y;\n if (mode == null) {\n mode = 'rgb';\n }\n ref = unpack(arguments), r = ref[0], g = ref[1], b = ref[2];\n r = r / 255;\n g = g / 255;\n b = b / 255;\n k = 1 - Math.max(r, Math.max(g, b));\n f = k < 1 ? 1 / (1 - k) : 0;\n c = (1 - r - k) * f;\n m = (1 - g - k) * f;\n y = (1 - b - k) * f;\n return [c, m, y, k];\n };\n\n cmyk2rgb = function() {\n var alpha, args, b, c, g, k, m, r, y;\n args = unpack(arguments);\n c = args[0], m = args[1], y = args[2], k = args[3];\n alpha = args.length > 4 ? args[4] : 1;\n if (k === 1) {\n return [0, 0, 0, alpha];\n }\n r = c >= 1 ? 0 : 255 * (1 - c) * (1 - k);\n g = m >= 1 ? 0 : 255 * (1 - m) * (1 - k);\n b = y >= 1 ? 0 : 255 * (1 - y) * (1 - k);\n return [r, g, b, alpha];\n };\n\n _input.cmyk = function() {\n return cmyk2rgb(unpack(arguments));\n };\n\n chroma.cmyk = function() {\n return (function(func, args, ctor) {\n ctor.prototype = func.prototype;\n var child = new ctor, result = func.apply(child, args);\n return Object(result) === result ? result : child;\n })(Color, slice.call(arguments).concat(['cmyk']), function(){});\n };\n\n Color.prototype.cmyk = function() {\n return rgb2cmyk(this._rgb);\n };\n\n _input.gl = function() {\n var i, k, o, rgb, v;\n rgb = (function() {\n var ref, results;\n ref = unpack(arguments);\n results = [];\n for (k in ref) {\n v = ref[k];\n results.push(v);\n }\n return results;\n }).apply(this, arguments);\n for (i = o = 0; o <= 2; i = ++o) {\n rgb[i] *= 255;\n }\n return rgb;\n };\n\n chroma.gl = function() {\n return (function(func, args, ctor) {\n ctor.prototype = func.prototype;\n var child = new ctor, result = func.apply(child, args);\n return Object(result) === result ? result : child;\n })(Color, slice.call(arguments).concat(['gl']), function(){});\n };\n\n Color.prototype.gl = function() {\n var rgb;\n rgb = this._rgb;\n return [rgb[0] / 255, rgb[1] / 255, rgb[2] / 255, rgb[3]];\n };\n\n rgb2luminance = function(r, g, b) {\n var ref;\n ref = unpack(arguments), r = ref[0], g = ref[1], b = ref[2];\n r = luminance_x(r);\n g = luminance_x(g);\n b = luminance_x(b);\n return 0.2126 * r + 0.7152 * g + 0.0722 * b;\n };\n\n luminance_x = function(x) {\n x /= 255;\n if (x <= 0.03928) {\n return x / 12.92;\n } else {\n return pow((x + 0.055) / 1.055, 2.4);\n }\n };\n\n interpolate_rgb = function(col1, col2, f, m) {\n var xyz0, xyz1;\n xyz0 = col1._rgb;\n xyz1 = col2._rgb;\n return new Color(xyz0[0] + f * (xyz1[0] - xyz0[0]), xyz0[1] + f * (xyz1[1] - xyz0[1]), xyz0[2] + f * (xyz1[2] - xyz0[2]), m);\n };\n\n _interpolators.push(['rgb', interpolate_rgb]);\n\n Color.prototype.luminance = function(lum, mode) {\n var cur_lum, eps, max_iter, rgba, test;\n if (mode == null) {\n mode = 'rgb';\n }\n if (!arguments.length) {\n return rgb2luminance(this._rgb);\n }\n rgba = this._rgb;\n if (lum === 0) {\n rgba = [0, 0, 0, this._rgb[3]];\n } else if (lum === 1) {\n rgba = [255, 255, 255, this[3]];\n } else {\n cur_lum = rgb2luminance(this._rgb);\n eps = 1e-7;\n max_iter = 20;\n test = function(l, h) {\n var lm, m;\n m = l.interpolate(h, 0.5, mode);\n lm = m.luminance();\n if (Math.abs(lum - lm) < eps || !max_iter--) {\n return m;\n }\n if (lm > lum) {\n return test(l, m);\n }\n return test(m, h);\n };\n if (cur_lum > lum) {\n rgba = test(chroma('black'), this).rgba();\n } else {\n rgba = test(this, chroma('white')).rgba();\n }\n }\n return chroma(rgba).alpha(this.alpha());\n };\n\n temperature2rgb = function(kelvin) {\n var b, g, r, temp;\n temp = kelvin / 100;\n if (temp < 66) {\n r = 255;\n g = -155.25485562709179 - 0.44596950469579133 * (g = temp - 2) + 104.49216199393888 * log(g);\n b = temp < 20 ? 0 : -254.76935184120902 + 0.8274096064007395 * (b = temp - 10) + 115.67994401066147 * log(b);\n } else {\n r = 351.97690566805693 + 0.114206453784165 * (r = temp - 55) - 40.25366309332127 * log(r);\n g = 325.4494125711974 + 0.07943456536662342 * (g = temp - 50) - 28.0852963507957 * log(g);\n b = 255;\n }\n return [r, g, b];\n };\n\n rgb2temperature = function() {\n var b, eps, g, maxTemp, minTemp, r, ref, rgb, temp;\n ref = unpack(arguments), r = ref[0], g = ref[1], b = ref[2];\n minTemp = 1000;\n maxTemp = 40000;\n eps = 0.4;\n while (maxTemp - minTemp > eps) {\n temp = (maxTemp + minTemp) * 0.5;\n rgb = temperature2rgb(temp);\n if ((rgb[2] / rgb[0]) >= (b / r)) {\n maxTemp = temp;\n } else {\n minTemp = temp;\n }\n }\n return round(temp);\n };\n\n chroma.temperature = chroma.kelvin = function() {\n return (function(func, args, ctor) {\n ctor.prototype = func.prototype;\n var child = new ctor, result = func.apply(child, args);\n return Object(result) === result ? result : child;\n })(Color, slice.call(arguments).concat(['temperature']), function(){});\n };\n\n _input.temperature = _input.kelvin = _input.K = temperature2rgb;\n\n Color.prototype.temperature = function() {\n return rgb2temperature(this._rgb);\n };\n\n Color.prototype.kelvin = Color.prototype.temperature;\n\n chroma.contrast = function(a, b) {\n var l1, l2, ref, ref1;\n if ((ref = type(a)) === 'string' || ref === 'number') {\n a = new Color(a);\n }\n if ((ref1 = type(b)) === 'string' || ref1 === 'number') {\n b = new Color(b);\n }\n l1 = a.luminance();\n l2 = b.luminance();\n if (l1 > l2) {\n return (l1 + 0.05) / (l2 + 0.05);\n } else {\n return (l2 + 0.05) / (l1 + 0.05);\n }\n };\n\n chroma.distance = function(a, b, mode) {\n var d, i, l1, l2, ref, ref1, sum_sq;\n if (mode == null) {\n mode = 'lab';\n }\n if ((ref = type(a)) === 'string' || ref === 'number') {\n a = new Color(a);\n }\n if ((ref1 = type(b)) === 'string' || ref1 === 'number') {\n b = new Color(b);\n }\n l1 = a.get(mode);\n l2 = b.get(mode);\n sum_sq = 0;\n for (i in l1) {\n d = (l1[i] || 0) - (l2[i] || 0);\n sum_sq += d * d;\n }\n return Math.sqrt(sum_sq);\n };\n\n chroma.deltaE = function(a, b, L, C) {\n var L1, L2, a1, a2, b1, b2, c1, c2, c4, dH2, delA, delB, delC, delL, f, h1, ref, ref1, ref2, ref3, sc, sh, sl, t, v1, v2, v3;\n if (L == null) {\n L = 1;\n }\n if (C == null) {\n C = 1;\n }\n if ((ref = type(a)) === 'string' || ref === 'number') {\n a = new Color(a);\n }\n if ((ref1 = type(b)) === 'string' || ref1 === 'number') {\n b = new Color(b);\n }\n ref2 = a.lab(), L1 = ref2[0], a1 = ref2[1], b1 = ref2[2];\n ref3 = b.lab(), L2 = ref3[0], a2 = ref3[1], b2 = ref3[2];\n c1 = sqrt(a1 * a1 + b1 * b1);\n c2 = sqrt(a2 * a2 + b2 * b2);\n sl = L1 < 16.0 ? 0.511 : (0.040975 * L1) / (1.0 + 0.01765 * L1);\n sc = (0.0638 * c1) / (1.0 + 0.0131 * c1) + 0.638;\n h1 = c1 < 0.000001 ? 0.0 : (atan2(b1, a1) * 180.0) / PI;\n while (h1 < 0) {\n h1 += 360;\n }\n while (h1 >= 360) {\n h1 -= 360;\n }\n t = (h1 >= 164.0) && (h1 <= 345.0) ? 0.56 + abs(0.2 * cos((PI * (h1 + 168.0)) / 180.0)) : 0.36 + abs(0.4 * cos((PI * (h1 + 35.0)) / 180.0));\n c4 = c1 * c1 * c1 * c1;\n f = sqrt(c4 / (c4 + 1900.0));\n sh = sc * (f * t + 1.0 - f);\n delL = L1 - L2;\n delC = c1 - c2;\n delA = a1 - a2;\n delB = b1 - b2;\n dH2 = delA * delA + delB * delB - delC * delC;\n v1 = delL / (L * sl);\n v2 = delC / (C * sc);\n v3 = sh;\n return sqrt(v1 * v1 + v2 * v2 + (dH2 / (v3 * v3)));\n };\n\n Color.prototype.get = function(modechan) {\n var channel, i, me, mode, ref, src;\n me = this;\n ref = modechan.split('.'), mode = ref[0], channel = ref[1];\n src = me[mode]();\n if (channel) {\n i = mode.indexOf(channel);\n if (i > -1) {\n return src[i];\n } else {\n return console.warn('unknown channel ' + channel + ' in mode ' + mode);\n }\n } else {\n return src;\n }\n };\n\n Color.prototype.set = function(modechan, value) {\n var channel, i, me, mode, ref, src;\n me = this;\n ref = modechan.split('.'), mode = ref[0], channel = ref[1];\n if (channel) {\n src = me[mode]();\n i = mode.indexOf(channel);\n if (i > -1) {\n if (type(value) === 'string') {\n switch (value.charAt(0)) {\n case '+':\n src[i] += +value;\n break;\n case '-':\n src[i] += +value;\n break;\n case '*':\n src[i] *= +(value.substr(1));\n break;\n case '/':\n src[i] /= +(value.substr(1));\n break;\n default:\n src[i] = +value;\n }\n } else {\n src[i] = value;\n }\n } else {\n console.warn('unknown channel ' + channel + ' in mode ' + mode);\n }\n } else {\n src = value;\n }\n return chroma(src, mode).alpha(me.alpha());\n };\n\n Color.prototype.clipped = function() {\n return this._rgb._clipped || false;\n };\n\n Color.prototype.alpha = function(a) {\n if (arguments.length) {\n return chroma.rgb([this._rgb[0], this._rgb[1], this._rgb[2], a]);\n }\n return this._rgb[3];\n };\n\n Color.prototype.darken = function(amount) {\n var lab, me;\n if (amount == null) {\n amount = 1;\n }\n me = this;\n lab = me.lab();\n lab[0] -= LAB_CONSTANTS.Kn * amount;\n return chroma.lab(lab).alpha(me.alpha());\n };\n\n Color.prototype.brighten = function(amount) {\n if (amount == null) {\n amount = 1;\n }\n return this.darken(-amount);\n };\n\n Color.prototype.darker = Color.prototype.darken;\n\n Color.prototype.brighter = Color.prototype.brighten;\n\n Color.prototype.saturate = function(amount) {\n var lch, me;\n if (amount == null) {\n amount = 1;\n }\n me = this;\n lch = me.lch();\n lch[1] += amount * LAB_CONSTANTS.Kn;\n if (lch[1] < 0) {\n lch[1] = 0;\n }\n return chroma.lch(lch).alpha(me.alpha());\n };\n\n Color.prototype.desaturate = function(amount) {\n if (amount == null) {\n amount = 1;\n }\n return this.saturate(-amount);\n };\n\n Color.prototype.premultiply = function() {\n var a, rgb;\n rgb = this.rgb();\n a = this.alpha();\n return chroma(rgb[0] * a, rgb[1] * a, rgb[2] * a, a);\n };\n\n blend = function(bottom, top, mode) {\n if (!blend[mode]) {\n throw 'unknown blend mode ' + mode;\n }\n return blend[mode](bottom, top);\n };\n\n blend_f = function(f) {\n return function(bottom, top) {\n var c0, c1;\n c0 = chroma(top).rgb();\n c1 = chroma(bottom).rgb();\n return chroma(f(c0, c1), 'rgb');\n };\n };\n\n each = function(f) {\n return function(c0, c1) {\n var i, o, out;\n out = [];\n for (i = o = 0; o <= 3; i = ++o) {\n out[i] = f(c0[i], c1[i]);\n }\n return out;\n };\n };\n\n normal = function(a, b) {\n return a;\n };\n\n multiply = function(a, b) {\n return a * b / 255;\n };\n\n darken = function(a, b) {\n if (a > b) {\n return b;\n } else {\n return a;\n }\n };\n\n lighten = function(a, b) {\n if (a > b) {\n return a;\n } else {\n return b;\n }\n };\n\n screen = function(a, b) {\n return 255 * (1 - (1 - a / 255) * (1 - b / 255));\n };\n\n overlay = function(a, b) {\n if (b < 128) {\n return 2 * a * b / 255;\n } else {\n return 255 * (1 - 2 * (1 - a / 255) * (1 - b / 255));\n }\n };\n\n burn = function(a, b) {\n return 255 * (1 - (1 - b / 255) / (a / 255));\n };\n\n dodge = function(a, b) {\n if (a === 255) {\n return 255;\n }\n a = 255 * (b / 255) / (1 - a / 255);\n if (a > 255) {\n return 255;\n } else {\n return a;\n }\n };\n\n blend.normal = blend_f(each(normal));\n\n blend.multiply = blend_f(each(multiply));\n\n blend.screen = blend_f(each(screen));\n\n blend.overlay = blend_f(each(overlay));\n\n blend.darken = blend_f(each(darken));\n\n blend.lighten = blend_f(each(lighten));\n\n blend.dodge = blend_f(each(dodge));\n\n blend.burn = blend_f(each(burn));\n\n chroma.blend = blend;\n\n chroma.analyze = function(data) {\n var len, o, r, val;\n r = {\n min: Number.MAX_VALUE,\n max: Number.MAX_VALUE * -1,\n sum: 0,\n values: [],\n count: 0\n };\n for (o = 0, len = data.length; o < len; o++) {\n val = data[o];\n if ((val != null) && !isNaN(val)) {\n r.values.push(val);\n r.sum += val;\n if (val < r.min) {\n r.min = val;\n }\n if (val > r.max) {\n r.max = val;\n }\n r.count += 1;\n }\n }\n r.domain = [r.min, r.max];\n r.limits = function(mode, num) {\n return chroma.limits(r, mode, num);\n };\n return r;\n };\n\n chroma.scale = function(colors, positions) {\n var _classes, _colorCache, _colors, _correctLightness, _domain, _fixed, _gamma, _max, _min, _mode, _nacol, _out, _padding, _pos, _spread, _useCache, classifyValue, f, getClass, getColor, resetCache, setColors, tmap;\n _mode = 'rgb';\n _nacol = chroma('#ccc');\n _spread = 0;\n _fixed = false;\n _domain = [0, 1];\n _pos = [];\n _padding = [0, 0];\n _classes = false;\n _colors = [];\n _out = false;\n _min = 0;\n _max = 1;\n _correctLightness = false;\n _colorCache = {};\n _useCache = true;\n _gamma = 1;\n setColors = function(colors) {\n var c, col, o, ref, ref1, w;\n if (colors == null) {\n colors = ['#fff', '#000'];\n }\n if ((colors != null) && type(colors) === 'string' && (chroma.brewer != null)) {\n colors = chroma.brewer[colors] || chroma.brewer[colors.toLowerCase()] || colors;\n }\n if (type(colors) === 'array') {\n if (colors.length === 1) {\n colors = [colors[0], colors[0]];\n }\n colors = colors.slice(0);\n for (c = o = 0, ref = colors.length - 1; 0 <= ref ? o <= ref : o >= ref; c = 0 <= ref ? ++o : --o) {\n col = colors[c];\n if (type(col) === \"string\") {\n colors[c] = chroma(col);\n }\n }\n _pos.length = 0;\n for (c = w = 0, ref1 = colors.length - 1; 0 <= ref1 ? w <= ref1 : w >= ref1; c = 0 <= ref1 ? ++w : --w) {\n _pos.push(c / (colors.length - 1));\n }\n }\n resetCache();\n return _colors = colors;\n };\n getClass = function(value) {\n var i, n;\n if (_classes != null) {\n n = _classes.length - 1;\n i = 0;\n while (i < n && value >= _classes[i]) {\n i++;\n }\n return i - 1;\n }\n return 0;\n };\n tmap = function(t) {\n return t;\n };\n classifyValue = function(value) {\n var i, maxc, minc, n, val;\n val = value;\n if (_classes.length > 2) {\n n = _classes.length - 1;\n i = getClass(value);\n minc = _classes[0] + (_classes[1] - _classes[0]) * (0 + _spread * 0.5);\n maxc = _classes[n - 1] + (_classes[n] - _classes[n - 1]) * (1 - _spread * 0.5);\n val = _min + ((_classes[i] + (_classes[i + 1] - _classes[i]) * 0.5 - minc) / (maxc - minc)) * (_max - _min);\n }\n return val;\n };\n getColor = function(val, bypassMap) {\n var c, col, i, k, o, p, ref, t;\n if (bypassMap == null) {\n bypassMap = false;\n }\n if (isNaN(val) || val === null) {\n return _nacol;\n }\n if (!bypassMap) {\n if (_classes && _classes.length > 2) {\n c = getClass(val);\n t = c / (_classes.length - 2);\n } else if (_max !== _min) {\n t = (val - _min) / (_max - _min);\n } else {\n t = 1;\n }\n } else {\n t = val;\n }\n if (!bypassMap) {\n t = tmap(t);\n }\n if (_gamma !== 1) {\n t = pow(t, _gamma);\n }\n t = _padding[0] + (t * (1 - _padding[0] - _padding[1]));\n t = Math.min(1, Math.max(0, t));\n k = Math.floor(t * 10000);\n if (_useCache && _colorCache[k]) {\n col = _colorCache[k];\n } else {\n if (type(_colors) === 'array') {\n for (i = o = 0, ref = _pos.length - 1; 0 <= ref ? o <= ref : o >= ref; i = 0 <= ref ? ++o : --o) {\n p = _pos[i];\n if (t <= p) {\n col = _colors[i];\n break;\n }\n if (t >= p && i === _pos.length - 1) {\n col = _colors[i];\n break;\n }\n if (t > p && t < _pos[i + 1]) {\n t = (t - p) / (_pos[i + 1] - p);\n col = chroma.interpolate(_colors[i], _colors[i + 1], t, _mode);\n break;\n }\n }\n } else if (type(_colors) === 'function') {\n col = _colors(t);\n }\n if (_useCache) {\n _colorCache[k] = col;\n }\n }\n return col;\n };\n resetCache = function() {\n return _colorCache = {};\n };\n setColors(colors);\n f = function(v) {\n var c;\n c = chroma(getColor(v));\n if (_out && c[_out]) {\n return c[_out]();\n } else {\n return c;\n }\n };\n f.classes = function(classes) {\n var d;\n if (classes != null) {\n if (type(classes) === 'array') {\n _classes = classes;\n _domain = [classes[0], classes[classes.length - 1]];\n } else {\n d = chroma.analyze(_domain);\n if (classes === 0) {\n _classes = [d.min, d.max];\n } else {\n _classes = chroma.limits(d, 'e', classes);\n }\n }\n return f;\n }\n return _classes;\n };\n f.domain = function(domain) {\n var c, d, k, len, o, ref, w;\n if (!arguments.length) {\n return _domain;\n }\n _min = domain[0];\n _max = domain[domain.length - 1];\n _pos = [];\n k = _colors.length;\n if (domain.length === k && _min !== _max) {\n for (o = 0, len = domain.length; o < len; o++) {\n d = domain[o];\n _pos.push((d - _min) / (_max - _min));\n }\n } else {\n for (c = w = 0, ref = k - 1; 0 <= ref ? w <= ref : w >= ref; c = 0 <= ref ? ++w : --w) {\n _pos.push(c / (k - 1));\n }\n }\n _domain = [_min, _max];\n return f;\n };\n f.mode = function(_m) {\n if (!arguments.length) {\n return _mode;\n }\n _mode = _m;\n resetCache();\n return f;\n };\n f.range = function(colors, _pos) {\n setColors(colors, _pos);\n return f;\n };\n f.out = function(_o) {\n _out = _o;\n return f;\n };\n f.spread = function(val) {\n if (!arguments.length) {\n return _spread;\n }\n _spread = val;\n return f;\n };\n f.correctLightness = function(v) {\n if (v == null) {\n v = true;\n }\n _correctLightness = v;\n resetCache();\n if (_correctLightness) {\n tmap = function(t) {\n var L0, L1, L_actual, L_diff, L_ideal, max_iter, pol, t0, t1;\n L0 = getColor(0, true).lab()[0];\n L1 = getColor(1, true).lab()[0];\n pol = L0 > L1;\n L_actual = getColor(t, true).lab()[0];\n L_ideal = L0 + (L1 - L0) * t;\n L_diff = L_actual - L_ideal;\n t0 = 0;\n t1 = 1;\n max_iter = 20;\n while (Math.abs(L_diff) > 1e-2 && max_iter-- > 0) {\n (function() {\n if (pol) {\n L_diff *= -1;\n }\n if (L_diff < 0) {\n t0 = t;\n t += (t1 - t) * 0.5;\n } else {\n t1 = t;\n t += (t0 - t) * 0.5;\n }\n L_actual = getColor(t, true).lab()[0];\n return L_diff = L_actual - L_ideal;\n })();\n }\n return t;\n };\n } else {\n tmap = function(t) {\n return t;\n };\n }\n return f;\n };\n f.padding = function(p) {\n if (p != null) {\n if (type(p) === 'number') {\n p = [p, p];\n }\n _padding = p;\n return f;\n } else {\n return _padding;\n }\n };\n f.colors = function(numColors, out) {\n var dd, dm, i, o, ref, result, results, samples, w;\n if (arguments.length < 2) {\n out = 'hex';\n }\n result = [];\n if (arguments.length === 0) {\n result = _colors.slice(0);\n } else if (numColors === 1) {\n result = [f(0.5)];\n } else if (numColors > 1) {\n dm = _domain[0];\n dd = _domain[1] - dm;\n result = (function() {\n results = [];\n for (var o = 0; 0 <= numColors ? o < numColors : o > numColors; 0 <= numColors ? o++ : o--){ results.push(o); }\n return results;\n }).apply(this).map(function(i) {\n return f(dm + i / (numColors - 1) * dd);\n });\n } else {\n colors = [];\n samples = [];\n if (_classes && _classes.length > 2) {\n for (i = w = 1, ref = _classes.length; 1 <= ref ? w < ref : w > ref; i = 1 <= ref ? ++w : --w) {\n samples.push((_classes[i - 1] + _classes[i]) * 0.5);\n }\n } else {\n samples = _domain;\n }\n result = samples.map(function(v) {\n return f(v);\n });\n }\n if (chroma[out]) {\n result = result.map(function(c) {\n return c[out]();\n });\n }\n return result;\n };\n f.cache = function(c) {\n if (c != null) {\n _useCache = c;\n return f;\n } else {\n return _useCache;\n }\n };\n f.gamma = function(g) {\n if (g != null) {\n _gamma = g;\n return f;\n } else {\n return _gamma;\n }\n };\n f.nodata = function(d) {\n if (d != null) {\n _nacol = chroma(d);\n return f;\n } else {\n return _nacol;\n }\n };\n return f;\n };\n\n if (chroma.scales == null) {\n chroma.scales = {};\n }\n\n chroma.scales.cool = function() {\n return chroma.scale([chroma.hsl(180, 1, .9), chroma.hsl(250, .7, .4)]);\n };\n\n chroma.scales.hot = function() {\n return chroma.scale(['#000', '#f00', '#ff0', '#fff'], [0, .25, .75, 1]).mode('rgb');\n };\n\n chroma.analyze = function(data, key, filter) {\n var add, k, len, o, r, val, visit;\n r = {\n min: Number.MAX_VALUE,\n max: Number.MAX_VALUE * -1,\n sum: 0,\n values: [],\n count: 0\n };\n if (filter == null) {\n filter = function() {\n return true;\n };\n }\n add = function(val) {\n if ((val != null) && !isNaN(val)) {\n r.values.push(val);\n r.sum += val;\n if (val < r.min) {\n r.min = val;\n }\n if (val > r.max) {\n r.max = val;\n }\n r.count += 1;\n }\n };\n visit = function(val, k) {\n if (filter(val, k)) {\n if ((key != null) && type(key) === 'function') {\n return add(key(val));\n } else if ((key != null) && type(key) === 'string' || type(key) === 'number') {\n return add(val[key]);\n } else {\n return add(val);\n }\n }\n };\n if (type(data) === 'array') {\n for (o = 0, len = data.length; o < len; o++) {\n val = data[o];\n visit(val);\n }\n } else {\n for (k in data) {\n val = data[k];\n visit(val, k);\n }\n }\n r.domain = [r.min, r.max];\n r.limits = function(mode, num) {\n return chroma.limits(r, mode, num);\n };\n return r;\n };\n\n chroma.limits = function(data, mode, num) {\n var aa, ab, ac, ad, ae, af, ag, ah, ai, aj, ak, al, am, assignments, best, centroids, cluster, clusterSizes, dist, i, j, kClusters, limits, max_log, min, min_log, mindist, n, nb_iters, newCentroids, o, p, pb, pr, ref, ref1, ref10, ref11, ref12, ref13, ref14, ref2, ref3, ref4, ref5, ref6, ref7, ref8, ref9, repeat, sum, tmpKMeansBreaks, v, value, values, w;\n if (mode == null) {\n mode = 'equal';\n }\n if (num == null) {\n num = 7;\n }\n if (type(data) === 'array') {\n data = chroma.analyze(data);\n }\n min = data.min;\n max = data.max;\n sum = data.sum;\n values = data.values.sort(function(a, b) {\n return a - b;\n });\n if (num === 1) {\n return [min, max];\n }\n limits = [];\n if (mode.substr(0, 1) === 'c') {\n limits.push(min);\n limits.push(max);\n }\n if (mode.substr(0, 1) === 'e') {\n limits.push(min);\n for (i = o = 1, ref = num - 1; 1 <= ref ? o <= ref : o >= ref; i = 1 <= ref ? ++o : --o) {\n limits.push(min + (i / num) * (max - min));\n }\n limits.push(max);\n } else if (mode.substr(0, 1) === 'l') {\n if (min <= 0) {\n throw 'Logarithmic scales are only possible for values > 0';\n }\n min_log = Math.LOG10E * log(min);\n max_log = Math.LOG10E * log(max);\n limits.push(min);\n for (i = w = 1, ref1 = num - 1; 1 <= ref1 ? w <= ref1 : w >= ref1; i = 1 <= ref1 ? ++w : --w) {\n limits.push(pow(10, min_log + (i / num) * (max_log - min_log)));\n }\n limits.push(max);\n } else if (mode.substr(0, 1) === 'q') {\n limits.push(min);\n for (i = aa = 1, ref2 = num - 1; 1 <= ref2 ? aa <= ref2 : aa >= ref2; i = 1 <= ref2 ? ++aa : --aa) {\n p = (values.length - 1) * i / num;\n pb = floor(p);\n if (pb === p) {\n limits.push(values[pb]);\n } else {\n pr = p - pb;\n limits.push(values[pb] * (1 - pr) + values[pb + 1] * pr);\n }\n }\n limits.push(max);\n } else if (mode.substr(0, 1) === 'k') {\n\n /*\n implementation based on\n http://code.google.com/p/figue/source/browse/trunk/figue.js#336\n simplified for 1-d input values\n */\n n = values.length;\n assignments = new Array(n);\n clusterSizes = new Array(num);\n repeat = true;\n nb_iters = 0;\n centroids = null;\n centroids = [];\n centroids.push(min);\n for (i = ab = 1, ref3 = num - 1; 1 <= ref3 ? ab <= ref3 : ab >= ref3; i = 1 <= ref3 ? ++ab : --ab) {\n centroids.push(min + (i / num) * (max - min));\n }\n centroids.push(max);\n while (repeat) {\n for (j = ac = 0, ref4 = num - 1; 0 <= ref4 ? ac <= ref4 : ac >= ref4; j = 0 <= ref4 ? ++ac : --ac) {\n clusterSizes[j] = 0;\n }\n for (i = ad = 0, ref5 = n - 1; 0 <= ref5 ? ad <= ref5 : ad >= ref5; i = 0 <= ref5 ? ++ad : --ad) {\n value = values[i];\n mindist = Number.MAX_VALUE;\n for (j = ae = 0, ref6 = num - 1; 0 <= ref6 ? ae <= ref6 : ae >= ref6; j = 0 <= ref6 ? ++ae : --ae) {\n dist = abs(centroids[j] - value);\n if (dist < mindist) {\n mindist = dist;\n best = j;\n }\n }\n clusterSizes[best]++;\n assignments[i] = best;\n }\n newCentroids = new Array(num);\n for (j = af = 0, ref7 = num - 1; 0 <= ref7 ? af <= ref7 : af >= ref7; j = 0 <= ref7 ? ++af : --af) {\n newCentroids[j] = null;\n }\n for (i = ag = 0, ref8 = n - 1; 0 <= ref8 ? ag <= ref8 : ag >= ref8; i = 0 <= ref8 ? ++ag : --ag) {\n cluster = assignments[i];\n if (newCentroids[cluster] === null) {\n newCentroids[cluster] = values[i];\n } else {\n newCentroids[cluster] += values[i];\n }\n }\n for (j = ah = 0, ref9 = num - 1; 0 <= ref9 ? ah <= ref9 : ah >= ref9; j = 0 <= ref9 ? ++ah : --ah) {\n newCentroids[j] *= 1 / clusterSizes[j];\n }\n repeat = false;\n for (j = ai = 0, ref10 = num - 1; 0 <= ref10 ? ai <= ref10 : ai >= ref10; j = 0 <= ref10 ? ++ai : --ai) {\n if (newCentroids[j] !== centroids[i]) {\n repeat = true;\n break;\n }\n }\n centroids = newCentroids;\n nb_iters++;\n if (nb_iters > 200) {\n repeat = false;\n }\n }\n kClusters = {};\n for (j = aj = 0, ref11 = num - 1; 0 <= ref11 ? aj <= ref11 : aj >= ref11; j = 0 <= ref11 ? ++aj : --aj) {\n kClusters[j] = [];\n }\n for (i = ak = 0, ref12 = n - 1; 0 <= ref12 ? ak <= ref12 : ak >= ref12; i = 0 <= ref12 ? ++ak : --ak) {\n cluster = assignments[i];\n kClusters[cluster].push(values[i]);\n }\n tmpKMeansBreaks = [];\n for (j = al = 0, ref13 = num - 1; 0 <= ref13 ? al <= ref13 : al >= ref13; j = 0 <= ref13 ? ++al : --al) {\n tmpKMeansBreaks.push(kClusters[j][0]);\n tmpKMeansBreaks.push(kClusters[j][kClusters[j].length - 1]);\n }\n tmpKMeansBreaks = tmpKMeansBreaks.sort(function(a, b) {\n return a - b;\n });\n limits.push(tmpKMeansBreaks[0]);\n for (i = am = 1, ref14 = tmpKMeansBreaks.length - 1; am <= ref14; i = am += 2) {\n v = tmpKMeansBreaks[i];\n if (!isNaN(v) && limits.indexOf(v) === -1) {\n limits.push(v);\n }\n }\n }\n return limits;\n };\n\n hsi2rgb = function(h, s, i) {\n\n /*\n borrowed from here:\n http://hummer.stanford.edu/museinfo/doc/examples/humdrum/keyscape2/hsi2rgb.cpp\n */\n var args, b, g, r;\n args = unpack(arguments);\n h = args[0], s = args[1], i = args[2];\n if (isNaN(h)) {\n h = 0;\n }\n h /= 360;\n if (h < 1 / 3) {\n b = (1 - s) / 3;\n r = (1 + s * cos(TWOPI * h) / cos(PITHIRD - TWOPI * h)) / 3;\n g = 1 - (b + r);\n } else if (h < 2 / 3) {\n h -= 1 / 3;\n r = (1 - s) / 3;\n g = (1 + s * cos(TWOPI * h) / cos(PITHIRD - TWOPI * h)) / 3;\n b = 1 - (r + g);\n } else {\n h -= 2 / 3;\n g = (1 - s) / 3;\n b = (1 + s * cos(TWOPI * h) / cos(PITHIRD - TWOPI * h)) / 3;\n r = 1 - (g + b);\n }\n r = limit(i * r * 3);\n g = limit(i * g * 3);\n b = limit(i * b * 3);\n return [r * 255, g * 255, b * 255, args.length > 3 ? args[3] : 1];\n };\n\n rgb2hsi = function() {\n\n /*\n borrowed from here:\n http://hummer.stanford.edu/museinfo/doc/examples/humdrum/keyscape2/rgb2hsi.cpp\n */\n var b, g, h, i, min, r, ref, s;\n ref = unpack(arguments), r = ref[0], g = ref[1], b = ref[2];\n TWOPI = Math.PI * 2;\n r /= 255;\n g /= 255;\n b /= 255;\n min = Math.min(r, g, b);\n i = (r + g + b) / 3;\n s = 1 - min / i;\n if (s === 0) {\n h = 0;\n } else {\n h = ((r - g) + (r - b)) / 2;\n h /= Math.sqrt((r - g) * (r - g) + (r - b) * (g - b));\n h = Math.acos(h);\n if (b > g) {\n h = TWOPI - h;\n }\n h /= TWOPI;\n }\n return [h * 360, s, i];\n };\n\n chroma.hsi = function() {\n return (function(func, args, ctor) {\n ctor.prototype = func.prototype;\n var child = new ctor, result = func.apply(child, args);\n return Object(result) === result ? result : child;\n })(Color, slice.call(arguments).concat(['hsi']), function(){});\n };\n\n _input.hsi = hsi2rgb;\n\n Color.prototype.hsi = function() {\n return rgb2hsi(this._rgb);\n };\n\n interpolate_hsx = function(col1, col2, f, m) {\n var dh, hue, hue0, hue1, lbv, lbv0, lbv1, res, sat, sat0, sat1, xyz0, xyz1;\n if (m === 'hsl') {\n xyz0 = col1.hsl();\n xyz1 = col2.hsl();\n } else if (m === 'hsv') {\n xyz0 = col1.hsv();\n xyz1 = col2.hsv();\n } else if (m === 'hcg') {\n xyz0 = col1.hcg();\n xyz1 = col2.hcg();\n } else if (m === 'hsi') {\n xyz0 = col1.hsi();\n xyz1 = col2.hsi();\n } else if (m === 'lch' || m === 'hcl') {\n m = 'hcl';\n xyz0 = col1.hcl();\n xyz1 = col2.hcl();\n }\n if (m.substr(0, 1) === 'h') {\n hue0 = xyz0[0], sat0 = xyz0[1], lbv0 = xyz0[2];\n hue1 = xyz1[0], sat1 = xyz1[1], lbv1 = xyz1[2];\n }\n if (!isNaN(hue0) && !isNaN(hue1)) {\n if (hue1 > hue0 && hue1 - hue0 > 180) {\n dh = hue1 - (hue0 + 360);\n } else if (hue1 < hue0 && hue0 - hue1 > 180) {\n dh = hue1 + 360 - hue0;\n } else {\n dh = hue1 - hue0;\n }\n hue = hue0 + f * dh;\n } else if (!isNaN(hue0)) {\n hue = hue0;\n if ((lbv1 === 1 || lbv1 === 0) && m !== 'hsv') {\n sat = sat0;\n }\n } else if (!isNaN(hue1)) {\n hue = hue1;\n if ((lbv0 === 1 || lbv0 === 0) && m !== 'hsv') {\n sat = sat1;\n }\n } else {\n hue = Number.NaN;\n }\n if (sat == null) {\n sat = sat0 + f * (sat1 - sat0);\n }\n lbv = lbv0 + f * (lbv1 - lbv0);\n return res = chroma[m](hue, sat, lbv);\n };\n\n _interpolators = _interpolators.concat((function() {\n var len, o, ref, results;\n ref = ['hsv', 'hsl', 'hsi', 'hcl', 'lch', 'hcg'];\n results = [];\n for (o = 0, len = ref.length; o < len; o++) {\n m = ref[o];\n results.push([m, interpolate_hsx]);\n }\n return results;\n })());\n\n interpolate_num = function(col1, col2, f, m) {\n var n1, n2;\n n1 = col1.num();\n n2 = col2.num();\n return chroma.num(n1 + (n2 - n1) * f, 'num');\n };\n\n _interpolators.push(['num', interpolate_num]);\n\n interpolate_lab = function(col1, col2, f, m) {\n var res, xyz0, xyz1;\n xyz0 = col1.lab();\n xyz1 = col2.lab();\n return res = new Color(xyz0[0] + f * (xyz1[0] - xyz0[0]), xyz0[1] + f * (xyz1[1] - xyz0[1]), xyz0[2] + f * (xyz1[2] - xyz0[2]), m);\n };\n\n _interpolators.push(['lab', interpolate_lab]);\n\n}).call(this);\n","/**\n * @file Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Color } from 'three'\nimport * as chroma from 'chroma-js'\n\nimport { createParams } from '../utils'\nimport { NumberArray } from '../types'\nimport Structure from '../structure/structure'\nimport Surface from '../surface/surface'\nimport Volume from '../surface/volume'\nimport AtomProxy from '../proxy/atom-proxy'\nimport BondProxy from '../proxy/bond-proxy'\n\nexport type ColorMode = 'rgb'|'hsv'|'hsl'|'hsi'|'lab'|'hcl'\nexport type ColorSpace = 'sRGB' | 'linear'\n\n/**\n * Internal color space for all colors (global).\n * Colors are always specified as sRGB; if this is set to\n * 'linear' then colors get linearized when used internally\n * as vertex or texture colors.\n * @see setColorSpace/getColorSpace.\n */\nvar colorSpace: ColorSpace = 'sRGB' // default: don't linearize\n\n/** Set the global internal color space for colormakers */\nexport function setColorSpace(space: ColorSpace) {\n colorSpace = space\n}\n\n/** Get the global internal color space for colormakers */\nexport function getColorSpace() {\n return colorSpace\n}\n\nexport const ScaleDefaultParameters = {\n scale: 'uniform' as string|string[],\n mode: 'hcl' as ColorMode,\n domain: [ 0, 1 ] as number[],\n value: 0xFFFFFF,\n reverse: false,\n}\nexport type ScaleParameters = typeof ScaleDefaultParameters\n\nexport interface ColorData {\n atomData?: number[],\n bondData?: number[]\n}\n\nexport interface ColormakerParameters extends ScaleParameters {\n structure?: Structure\n volume?: Volume\n surface?: Surface\n data?: ColorData\n}\n\nexport type StuctureColormakerParams = { structure: Structure } & Partial\nexport type VolumeColormakerParams = { volume: Volume } & Partial\nexport type ColormakerScale = (v: number) => number\n\nconst tmpColor = new Color()\n\n/** Decorator for optionally linearizing a numeric color */\ntype colorFuncType = (value: any, fromTo?: boolean) => number // decorator applies to functions with this shape\nexport function manageColor\n (_target: Object,\n _name: string | symbol,\n descriptor: TypedPropertyDescriptor): PropertyDescriptor {\n const originalMethod = descriptor.value\n const linearize: colorFuncType = function (this: T, value: any, fromTo?: boolean) {\n let result = originalMethod!.bind(this, value, fromTo)()\n if (colorSpace == 'linear') {\n tmpColor.set(result)\n tmpColor.convertSRGBToLinear()\n return tmpColor.getHex()\n } else {\n return result\n }\n }\n descriptor.value = linearize\n return descriptor\n }\n\n/**\n * Class for making colors.\n * @interface\n */\nabstract class Colormaker {\n parameters: ColormakerParameters\n atomProxy?: AtomProxy\n\n /**\n * Create a colormaker instance\n * @param {ColormakerParameters} params - colormaker parameter\n */\n constructor (params: Partial = {}) {\n this.parameters = createParams(params, ScaleDefaultParameters)\n\n if (typeof this.parameters.value === 'string') {\n this.parameters.value = tmpColor.set(this.parameters.value).getHex()\n }\n\n if (this.parameters.structure) {\n this.atomProxy = this.parameters.structure.getAtomProxy()\n }\n }\n\n getScale (params: Partial = {}) {\n const p = createParams(params, this.parameters)\n\n if (p.scale === 'rainbow') {\n p.scale = [ 'red', 'orange', 'yellow', 'green', 'blue' ]\n } else if (p.scale === 'rwb') {\n p.scale = [ 'red', 'white', 'blue' ]\n }\n\n if (p.reverse) {\n p.domain = p.domain.slice().reverse()\n }\n return chroma\n .scale(p.scale as any) // TODO\n .mode(p.mode)\n .domain(p.domain)\n .out('num' as any) // returns RGB color as numeric (not string \"#ffffff\")\n }\n\n /**\n * save a color to an array\n * @param {Integer} color - hex color value\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n colorToArray (color: number, array: NumberArray = [], offset = 0) {\n array[ offset ] = (color >> 16 & 255) / 255\n array[ offset + 1 ] = (color >> 8 & 255) / 255\n array[ offset + 2 ] = (color & 255) / 255\n\n return array\n }\n\n atomColor? (atom: AtomProxy): number\n\n /**\n * save an atom color to an array\n * @param {AtomProxy} atom - atom to get color for\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n atomColorToArray (atom: AtomProxy, array: NumberArray, offset: number) {\n return this.colorToArray(\n this.atomColor ? this.atomColor(atom) : 0x000000, array, offset\n )\n }\n\n /**\n * return the color for an bond\n * @param {BondProxy} bond - bond to get color for\n * @param {Boolean} fromTo - whether to use the first or second atom of the bond\n * @return {Integer} hex bond color\n */\n bondColor (bond: BondProxy, fromTo: boolean) {\n if (this.atomProxy && this.atomColor) {\n this.atomProxy.index = fromTo ? bond.atomIndex1 : bond.atomIndex2\n return this.atomColor(this.atomProxy)\n } else {\n return 0x000000\n }\n }\n\n /**\n * safe a bond color to an array\n * @param {BondProxy} bond - bond to get color for\n * @param {Boolean} fromTo - whether to use the first or second atom of the bond\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n bondColorToArray (bond: BondProxy, fromTo: boolean, array: NumberArray, offset: number) {\n return this.colorToArray(\n this.bondColor(bond, fromTo), array, offset\n )\n }\n\n volumeColor? (index: number): number\n\n /**\n * safe a volume cell color to an array\n * @param {Integer} index - volume cell index\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n volumeColorToArray (index: number, array: NumberArray, offset: number) {\n return this.colorToArray(\n this.volumeColor ? this.volumeColor(index) : 0x000000, array, offset\n )\n }\n\n positionColor? (position: Vector3): number\n\n /**\n * safe a color for coordinates in space to an array\n * @param {Vector3} coords - xyz coordinates\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n positionColorToArray (coords: Vector3, array: NumberArray, offset: number) {\n return this.colorToArray(\n this.positionColor ? this.positionColor(coords) : 0x000000, array, offset\n )\n }\n}\n\nexport default Colormaker\n","/**\n * @file Selection Constants\n * @author Alexander Rose \n * @private\n */\n\nexport enum kwd {\n PROTEIN = 1,\n NUCLEIC = 2,\n RNA = 3,\n DNA = 4,\n POLYMER = 5,\n WATER = 6,\n HELIX = 7,\n SHEET = 8,\n TURN = 9,\n BACKBONE = 10,\n SIDECHAIN = 11,\n ALL = 12,\n HETERO = 13,\n ION = 14,\n SACCHARIDE = 15,\n SUGAR = 15,\n BONDED = 16,\n RING = 17,\n AROMATICRING = 18,\n METAL = 19,\n POLARH = 20,\n NONE = 21\n}\n\nexport const SelectAllKeyword = [ '*', '', 'ALL' ]\nexport const SelectNoneKeyword = [ 'NONE' ]\n\nexport const AtomOnlyKeywords = [\n kwd.BACKBONE, kwd.SIDECHAIN, kwd.BONDED, kwd.RING, kwd.AROMATICRING, kwd.METAL, kwd.POLARH\n]\n\nexport const ChainKeywords = [\n kwd.POLYMER, kwd.WATER\n]\n\nexport const SmallResname = [ 'ALA', 'GLY', 'SER' ]\nexport const NucleophilicResname = [ 'CYS', 'SER', 'THR' ]\nexport const HydrophobicResname = [ 'ALA', 'ILE', 'LEU', 'MET', 'PHE', 'PRO', 'TRP', 'VAL' ]\nexport const AromaticResname = [ 'PHE', 'TRP', 'TYR', 'HIS' ]\nexport const AmideResname = [ 'ASN', 'GLN' ]\nexport const AcidicResname = [ 'ASP', 'GLU' ]\nexport const BasicResname = [ 'ARG', 'HIS', 'LYS' ]\nexport const ChargedResname = [ 'ARG', 'ASP', 'GLU', 'HIS', 'LYS' ]\nexport const PolarResname = [ 'ASN', 'ARG', 'ASP', 'CYS', 'GLY', 'GLN', 'GLU', 'HIS', 'LYS', 'SER', 'THR', 'TYR' ]\nexport const NonpolarResname = [ 'ALA', 'ILE', 'LEU', 'MET', 'PHE', 'PRO', 'TRP', 'VAL' ]\nexport const CyclicResname = [ 'HIS', 'PHE', 'PRO', 'TRP', 'TYR' ]\nexport const AliphaticResname = [ 'ALA', 'GLY', 'ILE', 'LEU', 'VAL' ]\n","/*jslint onevar:true, undef:true, newcap:true, regexp:true, bitwise:true, maxerr:50, indent:4, white:false, nomen:false, plusplus:false */\n/*global define:false, require:false, exports:false, module:false, signals:false */\n\n/** @license\n * JS Signals \n * Released under the MIT license\n * Author: Miller Medeiros\n * Version: 1.0.0 - Build: 268 (2012/11/29 05:48 PM)\n */\n\n(function(global){\n\n // SignalBinding -------------------------------------------------\n //================================================================\n\n /**\n * Object that represents a binding between a Signal and a listener function.\n *
- This is an internal constructor and shouldn't be called by regular users.\n *
- inspired by Joa Ebert AS3 SignalBinding and Robert Penner's Slot classes.\n * @author Miller Medeiros\n * @constructor\n * @internal\n * @name SignalBinding\n * @param {Signal} signal Reference to Signal object that listener is currently bound to.\n * @param {Function} listener Handler function bound to the signal.\n * @param {boolean} isOnce If binding should be executed just once.\n * @param {Object} [listenerContext] Context on which listener will be executed (object that should represent the `this` variable inside listener function).\n * @param {Number} [priority] The priority level of the event listener. (default = 0).\n */\n function SignalBinding(signal, listener, isOnce, listenerContext, priority) {\n\n /**\n * Handler function bound to the signal.\n * @type Function\n * @private\n */\n this._listener = listener;\n\n /**\n * If binding should be executed just once.\n * @type boolean\n * @private\n */\n this._isOnce = isOnce;\n\n /**\n * Context on which listener will be executed (object that should represent the `this` variable inside listener function).\n * @memberOf SignalBinding.prototype\n * @name context\n * @type Object|undefined|null\n */\n this.context = listenerContext;\n\n /**\n * Reference to Signal object that listener is currently bound to.\n * @type Signal\n * @private\n */\n this._signal = signal;\n\n /**\n * Listener priority\n * @type Number\n * @private\n */\n this._priority = priority || 0;\n }\n\n SignalBinding.prototype = {\n\n /**\n * If binding is active and should be executed.\n * @type boolean\n */\n active : true,\n\n /**\n * Default parameters passed to listener during `Signal.dispatch` and `SignalBinding.execute`. (curried parameters)\n * @type Array|null\n */\n params : null,\n\n /**\n * Call listener passing arbitrary parameters.\n *

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

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

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

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

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

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

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

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

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

Find out how to get it here.

'\n\n/**\n * List of file extensions to be recognized as scripts\n */\nexport const ScriptExtensions = [ 'ngl', 'js' ]\n\nexport const WorkerRegistry = new _WorkerRegistry()\nexport const ColormakerRegistry = new _ColormakerRegistry()\nexport const DatasourceRegistry = new Registry('datasource')\nexport const RepresentationRegistry = new Registry('representatation')\nexport const ParserRegistry = new _ParserRegistry()\nexport const ShaderRegistry = new Registry('shader')\nexport const DecompressorRegistry = new Registry('decompressor')\nexport const ComponentRegistry = new Registry('component')\nexport const BufferRegistry = new Registry('buffer')\nexport const PickerRegistry = new Registry('picker')\n\nexport let ListingDatasource: any\nexport function setListingDatasource (value: any) {\n ListingDatasource = value\n}\n\nexport let TrajectoryDatasource: any // TODO should accept mdsrvDatasource\nexport function setTrajectoryDatasource (value: any) {\n TrajectoryDatasource = value\n}\n","/**\n * @file Worker Registry\n * @author Alexander Rose \n * @private\n */\n\nimport { makeWorkerBlob } from './worker-utils'\n\nclass WorkerRegistry {\n activeWorkerCount = 0\n\n private _funcDict: { [k: string]: Function } = {}\n private _depsDict: { [k: string]: Function[] } = {}\n private _blobDict: { [k: string]: Blob } = {}\n\n add (name: string, func: Function, deps: Function[]) {\n this._funcDict[ name ] = func\n this._depsDict[ name ] = deps\n }\n\n get (name: string) {\n if (!this._blobDict[ name ]) {\n this._blobDict[ name ] = makeWorkerBlob(\n this._funcDict[ name ], this._depsDict[ name ]\n )\n }\n return this._blobDict[ name ]\n }\n}\n\nexport default WorkerRegistry\n","/**\n * @file Parser Registry\n * @author Alexander Rose \n * @private\n */\n\nimport Registry from '../utils/registry'\n\nclass ParserRegistry extends Registry {\n constructor () {\n super('parser')\n }\n\n __hasObjName (key: string, objName: string) {\n const parser = this.get(key)\n return parser && parser.prototype.__objName === objName\n }\n\n isTrajectory (key: string) {\n return this.__hasObjName(key, 'frames')\n }\n\n isStructure (key: string) {\n return this.__hasObjName(key, 'structure')\n }\n\n isVolume (key: string) {\n return this.__hasObjName(key, 'volume')\n }\n\n isSurface (key: string) {\n return this.__hasObjName(key, 'surface')\n }\n\n isBinary (key: string) {\n const parser = this.get(key)\n return parser && parser.prototype.isBinary\n }\n\n isXml (key: string) {\n const parser = this.get(key)\n return parser && parser.prototype.isXml\n }\n\n isJson (key: string) {\n const parser = this.get(key)\n return parser && parser.prototype.isJson\n }\n\n getTrajectoryExtensions () {\n return this.names.filter(name => this.isTrajectory(name))\n }\n\n getStructureExtensions () {\n return this.names.filter(name => this.isStructure(name))\n }\n\n getVolumeExtensions () {\n return this.names.filter(name => this.isVolume(name))\n }\n\n getSurfaceExtensions () {\n return this.names.filter(name => this.isSurface(name))\n }\n}\n\nexport default ParserRegistry\n","/**\n * @file Streamer\n * @author Alexander Rose \n * @private\n */\n\nimport { DecompressorRegistry } from '../globals'\nimport { uint8ToString, defaults } from '../utils'\n\nexport interface StreamerParams {\n compressed?: string|false\n binary?: boolean\n json?: boolean\n xml?: boolean\n}\n\nabstract class Streamer {\n src: any\n data: any\n\n compressed: string|false\n binary: boolean\n json: boolean\n xml: boolean\n\n chunkSize = 1024 * 1024 * 10\n newline = '\\n'\n\n protected __pointer = 0\n protected __partialLine = ''\n\n constructor (src: any, params: StreamerParams = {}) {\n this.compressed = defaults(params.compressed, false)\n this.binary = defaults(params.binary, false)\n this.json = defaults(params.json, false)\n this.xml = defaults(params.xml, false)\n\n this.src = src\n }\n\n isBinary () {\n return this.binary || this.compressed\n }\n\n read () {\n return this._read().then(data => {\n const decompressFn = this.compressed ? DecompressorRegistry.get(this.compressed) : undefined\n\n if (this.compressed && decompressFn) {\n this.data = decompressFn(data)\n } else {\n if ((this.binary || this.compressed) && data instanceof ArrayBuffer) {\n data = new Uint8Array(data)\n }\n this.data = data\n }\n\n return this.data\n })\n }\n\n protected abstract _read (): Promise\n\n protected _chunk (start: number, end: number) {\n end = Math.min(this.data.length, end)\n\n if (start === 0 && this.data.length === end) {\n return this.data\n } else {\n if (this.isBinary()) {\n return this.data.subarray(start, end)\n } else {\n return this.data.substring(start, end)\n }\n }\n }\n\n chunk (start: number) {\n const end = start + this.chunkSize\n\n return this._chunk(start, end)\n }\n\n peekLines (m: number) {\n const data = this.data\n const n = data.length\n\n // FIXME does not work for multi-char newline\n const newline = this.isBinary() ? this.newline.charCodeAt(0) : this.newline\n\n let i\n let count = 0\n for (i = 0; i < n; ++i) {\n if (data[ i ] === newline) ++count\n if (count === m) break\n }\n\n const chunk = this._chunk(0, i + 1)\n const d = this.chunkToLines(chunk, '', i > n)\n\n return d.lines\n }\n\n chunkCount () {\n return Math.floor(this.data.length / this.chunkSize) + 1\n }\n\n asText () {\n return this.isBinary() ? uint8ToString(this.data) : this.data\n }\n\n chunkToLines (chunk: string|Uint8Array, partialLine: string, isLast: boolean) {\n const newline = this.newline\n\n if (!this.isBinary() && chunk.length === this.data.length) {\n return {\n lines: (chunk as string).split(newline),\n partialLine: ''\n }\n }\n\n let lines: string[] = []\n const str = this.isBinary() ? uint8ToString(chunk as Uint8Array) : chunk\n const idx = str.lastIndexOf(newline)\n\n if (idx === -1) {\n partialLine += str\n } else {\n const str2 = partialLine + str.substr(0, idx)\n lines = lines.concat(str2.split(newline))\n\n if (idx === str.length - newline.length) {\n partialLine = ''\n } else {\n partialLine = str.substr(idx + newline.length)\n }\n }\n\n if (isLast && partialLine !== '') {\n lines.push(partialLine)\n }\n\n return {\n lines: lines,\n partialLine: partialLine\n }\n }\n\n nextChunk () {\n const start = this.__pointer\n\n if (start > this.data.length) {\n return undefined\n }\n\n this.__pointer += this.chunkSize\n return this.chunk(start)\n }\n\n nextChunkOfLines () {\n const chunk = this.nextChunk()\n\n if (chunk === undefined) {\n return undefined\n }\n\n const isLast = this.__pointer > this.data.length\n const d = this.chunkToLines(chunk, this.__partialLine, isLast)\n\n this.__partialLine = d.partialLine\n\n return d.lines\n }\n\n eachChunk (callback: (chunk: string|Uint8Array, chunkNo: number, chunkCount: number) => void) {\n const chunkSize = this.chunkSize\n const n = this.data.length\n const chunkCount = this.chunkCount()\n\n for (let i = 0; i < n; i += chunkSize) {\n const chunk = this.chunk(i)\n const chunkNo = Math.round(i / chunkSize)\n\n callback(chunk, chunkNo, chunkCount)\n }\n }\n\n eachChunkOfLines (callback: (chunk: string[], chunkNo: number, chunkCount: number) => void) {\n this.eachChunk((chunk, chunkNo, chunkCount) => {\n const isLast = chunkNo === chunkCount + 1\n const d = this.chunkToLines(chunk, this.__partialLine, isLast)\n\n this.__partialLine = d.partialLine\n\n callback(d.lines, chunkNo, chunkCount)\n })\n }\n\n dispose () {\n delete this.src\n }\n}\n\nexport default Streamer\n","/**\n * @file File Streamer\n * @author Alexander Rose \n * @private\n */\n\nimport Streamer from './streamer'\n\ninterface FileReaderEventTarget extends EventTarget {\n result:string | ArrayBuffer | null\n}\n\ninterface FileReaderEvent extends ProgressEvent {\n target: FileReaderEventTarget | null;\n}\n\nclass FileStreamer extends Streamer {\n _read () {\n return new Promise((resolve, reject) => {\n const file = this.src\n const reader = new FileReader()\n\n reader.onload = (event: FileReaderEvent) => {\n if(event.target) resolve(event.target.result)\n }\n\n // if (typeof this.onprogress === 'function') {\n // reader.onprogress = event => this.onprogress(event)\n // }\n\n reader.onerror = event => reject(event)\n\n if (this.binary || this.compressed) {\n reader.readAsArrayBuffer(file)\n } else {\n reader.readAsText(file)\n }\n })\n }\n}\n\nexport default FileStreamer\n","/**\n * @file Network Streamer\n * @author Alexander Rose \n * @private\n */\n\nimport Streamer from './streamer'\n\nclass NetworkStreamer extends Streamer {\n _read () {\n return new Promise((resolve, reject) => {\n const url = this.src\n const xhr = new XMLHttpRequest()\n\n xhr.open('GET', url, true)\n\n xhr.addEventListener('load', () => {\n if (xhr.status === 200 || xhr.status === 304 ||\n // when requesting from local file system\n // the status in Google Chrome/Chromium is 0\n xhr.status === 0\n ) {\n try {\n resolve(xhr.response)\n } catch (e) {\n reject(e)\n }\n } else {\n reject(xhr.statusText)\n }\n }, false)\n\n // if (typeof this.onprogress === 'function') {\n // xhr.addEventListener('progress', event => this.onprogress(event), false);\n // }\n\n xhr.addEventListener('error', event => reject('network error'), false)\n\n if (this.isBinary()) {\n xhr.responseType = 'arraybuffer'\n } else if (this.json) {\n xhr.responseType = 'json'\n } else if (this.xml) {\n xhr.responseType = 'document'\n } else {\n xhr.responseType = 'text'\n }\n // xhr.crossOrigin = true;\n\n xhr.send()\n })\n }\n}\n\nexport default NetworkStreamer\n","/**\n * @file Loader\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport { createParams } from '../utils'\nimport FileStreamer from '../streamer/file-streamer'\nimport NetworkStreamer from '../streamer/network-streamer'\nimport { LoaderParameters, LoaderInput } from './loader-utils'\n\n/**\n * Loader parameter object.\n * @typedef {Object} LoaderParameters - loader parameters\n * @property {String} ext - file extension, determines file type\n * @property {Boolean} compressed - flag data as compressed\n * @property {Boolean} binary - flag data as binary\n * @property {String} name - set data name\n */\n\n/**\n * Loader base class\n */\nabstract class Loader {\n parameters: LoaderParameters\n streamer: FileStreamer | NetworkStreamer\n\n /**\n * Construct a loader object\n * @param {String|File|Blob} src - data source, string is interpreted as an URL\n * @param {LoaderParameters} params - parameters object\n */\n constructor (src: LoaderInput, params: Partial = {}) {\n this.parameters = createParams(params, {\n ext: '',\n compressed: false,\n binary: ParserRegistry.isBinary(params.ext || ''),\n name: '',\n\n dir: '',\n path: '',\n protocol: ''\n } as LoaderParameters)\n\n const streamerParams = {\n compressed: this.parameters.compressed as string|false,\n binary: this.parameters.binary,\n json: ParserRegistry.isJson(this.parameters.ext),\n xml: ParserRegistry.isXml(this.parameters.ext)\n }\n\n if ((typeof File !== 'undefined' && src instanceof File) ||\n (typeof Blob !== 'undefined' && src instanceof Blob)\n ) {\n this.streamer = new FileStreamer(src, streamerParams)\n } else {\n this.streamer = new NetworkStreamer(src, streamerParams)\n }\n }\n\n /**\n * Load data\n * @abstract\n * @return {Promise} resolves to the loaded data {@link Object}\n */\n abstract load (): Promise\n}\n\nexport default Loader\n","/**\n * @file Parser Loader\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport type { InferBondsOptions } from '../structure/structure-utils'\nimport Loader from './loader'\nimport { LoaderParameters, LoaderInput } from './loader-utils'\n\nexport interface ParserParams {\n voxelSize?: number\n firstModelOnly?: boolean\n asTrajectory?: boolean\n cAlphaOnly?: boolean\n name?: string\n path?: string\n delimiter?: string\n comment?: string\n columnNames?: string\n inferBonds?: InferBondsOptions\n}\n\n/**\n * Parser loader class\n * @extends Loader\n */\nclass ParserLoader extends Loader {\n parserParams: ParserParams\n\n constructor (src: LoaderInput, params: Partial & ParserParams = {}) {\n super(src, params)\n this.parserParams = {\n voxelSize: params.voxelSize,\n firstModelOnly: params.firstModelOnly,\n asTrajectory: params.asTrajectory,\n cAlphaOnly: params.cAlphaOnly,\n delimiter: params.delimiter,\n comment: params.comment,\n columnNames: params.columnNames,\n inferBonds: params.inferBonds,\n name: this.parameters.name,\n path: this.parameters.path\n }\n }\n\n /**\n * Load parsed object\n * @return {Promise} resolves to the loaded & parsed {@link Structure},\n * {@link Volume}, {@link Surface} or data object\n */\n load () {\n var ParserClass = ParserRegistry.get(this.parameters.ext)\n var parser = new ParserClass(this.streamer, this.parserParams)\n\n return parser.parse()\n }\n}\n\nexport default ParserLoader\n","/**\n * @file Script\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { Log } from './globals'\nimport Stage from './stage/stage'\n\nexport interface ScriptSignals {\n elementAdded: Signal\n elementRemoved: Signal\n nameChanged: Signal\n}\n\n/**\n * Script class\n */\nclass Script {\n readonly signals: ScriptSignals = {\n elementAdded: new Signal(),\n elementRemoved: new Signal(),\n nameChanged: new Signal()\n }\n\n readonly dir: string\n readonly fn: Function\n\n readonly type = 'Script'\n\n /**\n * Create a script instance\n * @param {String} functionBody - the function source\n * @param {String} name - name of the script\n * @param {String} path - path of the script\n */\n constructor (functionBody: string, readonly name: string, readonly path: string) {\n this.dir = path.substring(0, path.lastIndexOf('/') + 1)\n\n try {\n /* eslint-disable no-new-func */\n this.fn = new Function('stage', '__name', '__path', '__dir', functionBody)\n } catch (e) {\n Log.error('Script compilation failed', e)\n this.fn = function () {}\n }\n }\n\n /**\n * Execute the script\n * @param {Stage} stage - the stage context\n * @return {Promise} - resolve when script finished running\n */\n run (stage: Stage): Promise {\n return new Promise((resolve, reject) => {\n try {\n this.fn.apply(null, [ stage, this.name, this.path, this.dir ])\n resolve()\n } catch (e) {\n Log.error('Script.fn', e)\n reject(e)\n }\n })\n }\n}\n\nexport default Script\n","/**\n * @file Script Loader\n * @author Alexander Rose \n * @private\n */\n\nimport Loader from './loader'\nimport Script from '../script'\n\n/**\n * Script loader class\n * @extends Loader\n */\nclass ScriptLoader extends Loader {\n /**\n * Load script\n * @return {Promise} resolves to the loaded {@link Script}\n */\n load () {\n return this.streamer.read().then(() => {\n return new Script(\n this.streamer.asText(), this.parameters.name, this.parameters.path\n )\n })\n }\n}\n\nexport default ScriptLoader\n","/**\n * @file Loader Utils\n * @author Alexander Rose \n * @private\n */\n\nimport {\n DatasourceRegistry, DecompressorRegistry, ParserRegistry, ScriptExtensions\n} from '../globals'\nimport ParserLoader, { ParserParams } from './parser-loader'\nimport ScriptLoader from './script-loader'\n\nexport interface LoaderParameters {\n ext: string // file extension, determines file type\n compressed: string|false // flag data as compressed\n binary: boolean // flag data as binary\n name: string // set data name\n\n dir: string\n path: string\n protocol: string\n}\n\nexport type LoaderInput = File|Blob|string\n\nexport function getFileInfo (file: LoaderInput) {\n const compressedExtList = DecompressorRegistry.names\n\n let path: string\n let compressed: string|false\n let protocol = ''\n\n if (file instanceof File) {\n path = file.name\n } else if (file instanceof Blob) {\n path = ''\n } else {\n path = file\n }\n const queryIndex = path.lastIndexOf('?')\n const query = queryIndex !== -1 ? path.substring(queryIndex) : ''\n path = path.substring(0, queryIndex === -1 ? path.length : queryIndex)\n\n const name = path.replace(/^.*[\\\\/]/, '')\n let base = name.substring(0, name.lastIndexOf('.'))\n\n const nameSplit = name.split('.')\n let ext = nameSplit.length > 1 ? (nameSplit.pop() || '').toLowerCase() : ''\n\n const protocolMatch = path.match(/^(.+):\\/\\/(.+)$/)\n if (protocolMatch) {\n protocol = protocolMatch[ 1 ].toLowerCase()\n path = protocolMatch[ 2 ] || ''\n }\n\n const dir = path.substring(0, path.lastIndexOf('/') + 1)\n\n if (compressedExtList.includes(ext)) {\n compressed = ext\n const n = path.length - ext.length - 1\n ext = (path.substr(0, n).split('.').pop() || '').toLowerCase()\n const m = base.length - ext.length - 1\n base = base.substr(0, m)\n } else {\n compressed = false\n }\n\n return { path, name, ext, base, dir, compressed, protocol, query, 'src': file }\n}\n\nexport function getDataInfo (src: LoaderInput) {\n let info = getFileInfo(src)\n const datasource = DatasourceRegistry.get(info.protocol)\n if (datasource) {\n info = getFileInfo(datasource.getUrl(info.src))\n if (!info.ext && datasource.getExt) {\n info.ext = datasource.getExt(src)\n }\n }\n return info\n}\n\n/**\n * Load a file\n *\n * @example\n * // load from URL\n * NGL.autoLoad( \"http://files.rcsb.org/download/5IOS.cif\" );\n *\n * @example\n * // load binary data in CCP4 format via a Blob\n * var binaryBlob = new Blob( [ ccp4Data ], { type: 'application/octet-binary'} );\n * NGL.autoLoad( binaryBlob, { ext: \"ccp4\" } );\n *\n * @example\n * // load string data in PDB format via a Blob\n * var stringBlob = new Blob( [ pdbData ], { type: 'text/plain'} );\n * NGL.autoLoad( stringBlob, { ext: \"pdb\" } );\n *\n * @example\n * // load a File object\n * NGL.autoLoad( file );\n *\n * @param {String|File|Blob} file - either a URL or an object containing the file data\n * @param {LoaderParameters} params - loading parameters\n * @return {Promise} Promise resolves to the loaded data\n */\nexport function autoLoad (file: LoaderInput, params: Partial = {}) {\n const p = Object.assign(getDataInfo(file), params)\n\n let loader\n if (ParserRegistry.names.includes(p.ext)) {\n loader = new ParserLoader(p.src, p)\n } else if (ScriptExtensions.includes(p.ext)) {\n loader = new ScriptLoader(p.src, p)\n }\n\n if (loader) {\n return loader.load()\n } else {\n return Promise.reject(new Error(`autoLoad: ext '${p.ext}' unknown`))\n }\n}\n","/* global window, exports, define */\n\n!function() {\n 'use strict'\n\n var re = {\n not_string: /[^s]/,\n not_bool: /[^t]/,\n not_type: /[^T]/,\n not_primitive: /[^v]/,\n number: /[diefg]/,\n numeric_arg: /[bcdiefguxX]/,\n json: /[j]/,\n not_json: /[^j]/,\n text: /^[^\\x25]+/,\n modulo: /^\\x25{2}/,\n placeholder: /^\\x25(?:([1-9]\\d*)\\$|\\(([^)]+)\\))?(\\+)?(0|'[^$])?(-)?(\\d+)?(?:\\.(\\d+))?([b-gijostTuvxX])/,\n key: /^([a-z_][a-z_\\d]*)/i,\n key_access: /^\\.([a-z_][a-z_\\d]*)/i,\n index_access: /^\\[(\\d+)\\]/,\n sign: /^[+-]/\n }\n\n function sprintf(key) {\n // `arguments` is not an array, but should be fine for this call\n return sprintf_format(sprintf_parse(key), arguments)\n }\n\n function vsprintf(fmt, argv) {\n return sprintf.apply(null, [fmt].concat(argv || []))\n }\n\n function sprintf_format(parse_tree, argv) {\n var cursor = 1, tree_length = parse_tree.length, arg, output = '', i, k, ph, pad, pad_character, pad_length, is_positive, sign\n for (i = 0; i < tree_length; i++) {\n if (typeof parse_tree[i] === 'string') {\n output += parse_tree[i]\n }\n else if (typeof parse_tree[i] === 'object') {\n ph = parse_tree[i] // convenience purposes only\n if (ph.keys) { // keyword argument\n arg = argv[cursor]\n for (k = 0; k < ph.keys.length; k++) {\n if (arg == undefined) {\n throw new Error(sprintf('[sprintf] Cannot access property \"%s\" of undefined value \"%s\"', ph.keys[k], ph.keys[k-1]))\n }\n arg = arg[ph.keys[k]]\n }\n }\n else if (ph.param_no) { // positional argument (explicit)\n arg = argv[ph.param_no]\n }\n else { // positional argument (implicit)\n arg = argv[cursor++]\n }\n\n if (re.not_type.test(ph.type) && re.not_primitive.test(ph.type) && arg instanceof Function) {\n arg = arg()\n }\n\n if (re.numeric_arg.test(ph.type) && (typeof arg !== 'number' && isNaN(arg))) {\n throw new TypeError(sprintf('[sprintf] expecting number but found %T', arg))\n }\n\n if (re.number.test(ph.type)) {\n is_positive = arg >= 0\n }\n\n switch (ph.type) {\n case 'b':\n arg = parseInt(arg, 10).toString(2)\n break\n case 'c':\n arg = String.fromCharCode(parseInt(arg, 10))\n break\n case 'd':\n case 'i':\n arg = parseInt(arg, 10)\n break\n case 'j':\n arg = JSON.stringify(arg, null, ph.width ? parseInt(ph.width) : 0)\n break\n case 'e':\n arg = ph.precision ? parseFloat(arg).toExponential(ph.precision) : parseFloat(arg).toExponential()\n break\n case 'f':\n arg = ph.precision ? parseFloat(arg).toFixed(ph.precision) : parseFloat(arg)\n break\n case 'g':\n arg = ph.precision ? String(Number(arg.toPrecision(ph.precision))) : parseFloat(arg)\n break\n case 'o':\n arg = (parseInt(arg, 10) >>> 0).toString(8)\n break\n case 's':\n arg = String(arg)\n arg = (ph.precision ? arg.substring(0, ph.precision) : arg)\n break\n case 't':\n arg = String(!!arg)\n arg = (ph.precision ? arg.substring(0, ph.precision) : arg)\n break\n case 'T':\n arg = Object.prototype.toString.call(arg).slice(8, -1).toLowerCase()\n arg = (ph.precision ? arg.substring(0, ph.precision) : arg)\n break\n case 'u':\n arg = parseInt(arg, 10) >>> 0\n break\n case 'v':\n arg = arg.valueOf()\n arg = (ph.precision ? arg.substring(0, ph.precision) : arg)\n break\n case 'x':\n arg = (parseInt(arg, 10) >>> 0).toString(16)\n break\n case 'X':\n arg = (parseInt(arg, 10) >>> 0).toString(16).toUpperCase()\n break\n }\n if (re.json.test(ph.type)) {\n output += arg\n }\n else {\n if (re.number.test(ph.type) && (!is_positive || ph.sign)) {\n sign = is_positive ? '+' : '-'\n arg = arg.toString().replace(re.sign, '')\n }\n else {\n sign = ''\n }\n pad_character = ph.pad_char ? ph.pad_char === '0' ? '0' : ph.pad_char.charAt(1) : ' '\n pad_length = ph.width - (sign + arg).length\n pad = ph.width ? (pad_length > 0 ? pad_character.repeat(pad_length) : '') : ''\n output += ph.align ? sign + arg + pad : (pad_character === '0' ? sign + pad + arg : pad + sign + arg)\n }\n }\n }\n return output\n }\n\n var sprintf_cache = Object.create(null)\n\n function sprintf_parse(fmt) {\n if (sprintf_cache[fmt]) {\n return sprintf_cache[fmt]\n }\n\n var _fmt = fmt, match, parse_tree = [], arg_names = 0\n while (_fmt) {\n if ((match = re.text.exec(_fmt)) !== null) {\n parse_tree.push(match[0])\n }\n else if ((match = re.modulo.exec(_fmt)) !== null) {\n parse_tree.push('%')\n }\n else if ((match = re.placeholder.exec(_fmt)) !== null) {\n if (match[2]) {\n arg_names |= 1\n var field_list = [], replacement_field = match[2], field_match = []\n if ((field_match = re.key.exec(replacement_field)) !== null) {\n field_list.push(field_match[1])\n while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') {\n if ((field_match = re.key_access.exec(replacement_field)) !== null) {\n field_list.push(field_match[1])\n }\n else if ((field_match = re.index_access.exec(replacement_field)) !== null) {\n field_list.push(field_match[1])\n }\n else {\n throw new SyntaxError('[sprintf] failed to parse named argument key')\n }\n }\n }\n else {\n throw new SyntaxError('[sprintf] failed to parse named argument key')\n }\n match[2] = field_list\n }\n else {\n arg_names |= 2\n }\n if (arg_names === 3) {\n throw new Error('[sprintf] mixing positional and named placeholders is not (yet) supported')\n }\n\n parse_tree.push(\n {\n placeholder: match[0],\n param_no: match[1],\n keys: match[2],\n sign: match[3],\n pad_char: match[4],\n align: match[5],\n width: match[6],\n precision: match[7],\n type: match[8]\n }\n )\n }\n else {\n throw new SyntaxError('[sprintf] unexpected placeholder')\n }\n _fmt = _fmt.substring(match[0].length)\n }\n return sprintf_cache[fmt] = parse_tree\n }\n\n /**\n * export to either browser or node.js\n */\n /* eslint-disable quote-props */\n if (typeof exports !== 'undefined') {\n exports['sprintf'] = sprintf\n exports['vsprintf'] = vsprintf\n }\n if (typeof window !== 'undefined') {\n window['sprintf'] = sprintf\n window['vsprintf'] = vsprintf\n\n if (typeof define === 'function' && define['amd']) {\n define(function() {\n return {\n 'sprintf': sprintf,\n 'vsprintf': vsprintf\n }\n })\n }\n }\n /* eslint-enable quote-props */\n}(); // eslint-disable-line\n","/**\n * @file Writer\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults, download } from '../utils'\n\n/**\n * Base class for writers\n * @interface\n */\nabstract class Writer {\n readonly mimeType: string\n readonly defaultName: string\n readonly defaultExt: string\n\n /**\n * @abstract\n * @return {Anything} the data to be written\n */\n abstract getData (): any\n\n /**\n * Get a blob with the written data\n * @return {Blob} the blob\n */\n getBlob () {\n return new Blob([ this.getData() ], { type: this.mimeType })\n }\n\n /**\n * Trigger a download of the\n * @param {[type]} name [description]\n * @param {[type]} ext [description]\n * @return {[type]} [description]\n */\n download (name?: string, ext?: string) {\n name = defaults(name, this.defaultName)\n ext = defaults(ext, this.defaultExt)\n\n download(this.getBlob(), `${name}.${ext}`)\n }\n}\n\nexport default Writer","/**\n * @file IO Buffer\n * @author Alexander Rose \n * @private\n *\n * Adapted and converted to TypeScript from https://github.com/image-js/iobuffer\n * MIT License, Copyright (c) 2015 Michaël Zasso\n */\n\nimport { TypedArray } from '../types'\n\nconst defaultByteLength = 1024 * 8\nconst charArray: string[] = []\n\nexport interface IOBufferParameters {\n offset?: number // Ignore the first n bytes of the ArrayBuffer\n}\n\n/**\n * Class for writing and reading binary data\n */\nclass IOBuffer {\n private _lastWrittenByte: number\n private _mark = 0\n private _marks: number[] = []\n private _data: DataView\n\n offset = 0 // The current offset of the buffer's pointer\n littleEndian = true\n buffer: ArrayBuffer // Reference to the internal ArrayBuffer object\n length: number // Byte length of the internal ArrayBuffer\n byteLength: number // Byte length of the internal ArrayBuffer\n byteOffset: number // Byte offset of the internal ArrayBuffer\n\n /**\n * If it's a number, it will initialize the buffer with the number as\n * the buffer's length. If it's undefined, it will initialize the buffer\n * with a default length of 8 Kb. If its an ArrayBuffer, a TypedArray,\n * it will create a view over the underlying ArrayBuffer.\n */\n constructor (data: number|ArrayBuffer|TypedArray, params: IOBufferParameters = {}) {\n let dataIsGiven = false\n if (data === undefined) {\n data = defaultByteLength\n }\n if (typeof data === 'number') {\n data = new ArrayBuffer(data)\n } else {\n dataIsGiven = true\n }\n\n const offset = params.offset ? params.offset >>> 0 : 0\n let byteLength = data.byteLength - offset\n let dvOffset = offset\n if (!(data instanceof ArrayBuffer)) {\n if (data.byteLength !== data.buffer.byteLength) {\n dvOffset = data.byteOffset + offset\n }\n data = data.buffer\n }\n if (dataIsGiven) {\n this._lastWrittenByte = byteLength\n } else {\n this._lastWrittenByte = 0\n }\n\n this.buffer = data\n this.length = byteLength\n this.byteLength = byteLength\n this.byteOffset = dvOffset\n\n this._data = new DataView(this.buffer, dvOffset, byteLength)\n }\n\n /**\n * Checks if the memory allocated to the buffer is sufficient to store more bytes after the offset\n * @param {number} [byteLength=1] The needed memory in bytes\n * @return {boolean} Returns true if there is sufficient space and false otherwise\n */\n available (byteLength: number) {\n if (byteLength === undefined) byteLength = 1\n return (this.offset + byteLength) <= this.length\n }\n\n /**\n * Check if little-endian mode is used for reading and writing multi-byte values\n * @return {boolean} Returns true if little-endian mode is used, false otherwise\n */\n isLittleEndian () {\n return this.littleEndian\n }\n\n /**\n * Set little-endian mode for reading and writing multi-byte values\n * @return {IOBuffer}\n */\n setLittleEndian () {\n this.littleEndian = true\n return this\n }\n\n /**\n * Check if big-endian mode is used for reading and writing multi-byte values\n * @return {boolean} Returns true if big-endian mode is used, false otherwise\n */\n isBigEndian () {\n return !this.littleEndian\n }\n\n /**\n * Switches to big-endian mode for reading and writing multi-byte values\n * @return {IOBuffer}\n */\n setBigEndian () {\n this.littleEndian = false\n return this\n }\n\n /**\n * Move the pointer n bytes forward\n * @param {number} n\n * @return {IOBuffer}\n */\n skip (n: number) {\n if (n === undefined) n = 1\n this.offset += n\n return this\n }\n\n /**\n * Move the pointer to the given offset\n * @param {number} offset\n * @return {IOBuffer}\n */\n seek (offset: number) {\n this.offset = offset\n return this\n }\n\n /**\n * Store the current pointer offset.\n * @see {@link IOBuffer#reset}\n * @return {IOBuffer}\n */\n mark () {\n this._mark = this.offset\n return this\n }\n\n /**\n * Move the pointer back to the last pointer offset set by mark\n * @see {@link IOBuffer#mark}\n * @return {IOBuffer}\n */\n reset () {\n this.offset = this._mark\n return this\n }\n\n /**\n * Push the current pointer offset to the mark stack\n * @see {@link IOBuffer#popMark}\n * @return {IOBuffer}\n */\n pushMark () {\n this._marks.push(this.offset)\n return this\n }\n\n /**\n * Pop the last pointer offset from the mark stack, and set the current pointer offset to the popped value\n * @see {@link IOBuffer#pushMark}\n * @return {IOBuffer}\n */\n popMark () {\n const offset = this._marks.pop()\n if (offset === undefined) throw new Error('Mark stack empty')\n this.seek(offset)\n return this\n }\n\n /**\n * Move the pointer offset back to 0\n * @return {IOBuffer}\n */\n rewind () {\n this.offset = 0\n return this\n }\n\n /**\n * Make sure the buffer has sufficient memory to write a given byteLength at the current pointer offset\n * If the buffer's memory is insufficient, this method will create a new buffer (a copy) with a length\n * that is twice (byteLength + current offset)\n * @param {number} [byteLength = 1]\n * @return {IOBuffer}\n */\n ensureAvailable (byteLength: number) {\n if (byteLength === undefined) byteLength = 1\n if (!this.available(byteLength)) {\n const lengthNeeded = this.offset + byteLength\n const newLength = lengthNeeded * 2\n const newArray = new Uint8Array(newLength)\n newArray.set(new Uint8Array(this.buffer))\n this.buffer = newArray.buffer\n this.length = this.byteLength = newLength\n this._data = new DataView(this.buffer)\n }\n return this\n }\n\n /**\n * Read a byte and return false if the byte's value is 0, or true otherwise\n * Moves pointer forward\n * @return {boolean}\n */\n readBoolean () {\n return this.readUint8() !== 0\n }\n\n /**\n * Read a signed 8-bit integer and move pointer forward\n * @return {number}\n */\n readInt8 () {\n return this._data.getInt8(this.offset++)\n }\n\n /**\n * Read an unsigned 8-bit integer and move pointer forward\n * @return {number}\n */\n readUint8 () {\n return this._data.getUint8(this.offset++)\n }\n\n /**\n * Alias for {@link IOBuffer#readUint8}\n * @return {number}\n */\n readByte () {\n return this.readUint8()\n }\n\n /**\n * Read n bytes and move pointer forward.\n * @param {number} n\n * @return {Uint8Array}\n */\n readBytes (n: number) {\n if (n === undefined) n = 1\n var bytes = new Uint8Array(n)\n for (var i = 0; i < n; i++) {\n bytes[i] = this.readByte()\n }\n return bytes\n }\n\n /**\n * Read a 16-bit signed integer and move pointer forward\n * @return {number}\n */\n readInt16 () {\n var value = this._data.getInt16(this.offset, this.littleEndian)\n this.offset += 2\n return value\n }\n\n /**\n * Read a 16-bit unsigned integer and move pointer forward\n * @return {number}\n */\n readUint16 () {\n var value = this._data.getUint16(this.offset, this.littleEndian)\n this.offset += 2\n return value\n }\n\n /**\n * Read a 32-bit signed integer and move pointer forward\n * @return {number}\n */\n readInt32 () {\n var value = this._data.getInt32(this.offset, this.littleEndian)\n this.offset += 4\n return value\n }\n\n /**\n * Read a 32-bit unsigned integer and move pointer forward\n * @return {number}\n */\n readUint32 () {\n var value = this._data.getUint32(this.offset, this.littleEndian)\n this.offset += 4\n return value\n }\n\n /**\n * Read a 32-bit floating number and move pointer forward\n * @return {number}\n */\n readFloat32 () {\n var value = this._data.getFloat32(this.offset, this.littleEndian)\n this.offset += 4\n return value\n }\n\n /**\n * Read a 64-bit floating number and move pointer forward\n * @return {number}\n */\n readFloat64 () {\n var value = this._data.getFloat64(this.offset, this.littleEndian)\n this.offset += 8\n return value\n }\n\n /**\n * Read 1-byte ascii character and move pointer forward\n * @return {string}\n */\n readChar () {\n return String.fromCharCode(this.readInt8())\n }\n\n /**\n * Read n 1-byte ascii characters and move pointer forward\n * @param {number} n\n * @return {string}\n */\n readChars (n = 1) {\n charArray.length = n\n for (var i = 0; i < n; i++) {\n charArray[i] = this.readChar()\n }\n return charArray.join('')\n }\n\n /**\n * Write 0xff if the passed value is truthy, 0x00 otherwise\n * @param {any} value\n * @return {IOBuffer}\n */\n writeBoolean (value = false) {\n this.writeUint8(value ? 0xff : 0x00)\n return this\n }\n\n /**\n * Write value as an 8-bit signed integer\n * @param {number} value\n * @return {IOBuffer}\n */\n writeInt8 (value: number) {\n this.ensureAvailable(1)\n this._data.setInt8(this.offset++, value)\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write value as a 8-bit unsigned integer\n * @param {number} value\n * @return {IOBuffer}\n */\n writeUint8 (value: number) {\n this.ensureAvailable(1)\n this._data.setUint8(this.offset++, value)\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * An alias for {@link IOBuffer#writeUint8}\n * @param {number} value\n * @return {IOBuffer}\n */\n writeByte (value: number) {\n return this.writeUint8(value)\n }\n\n /**\n * Write bytes\n * @param {Array|Uint8Array} bytes\n * @return {IOBuffer}\n */\n writeBytes (bytes: number[]|Uint8Array) {\n this.ensureAvailable(bytes.length)\n for (var i = 0; i < bytes.length; i++) {\n this._data.setUint8(this.offset++, bytes[i])\n }\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write value as an 16-bit signed integer\n * @param {number} value\n * @return {IOBuffer}\n */\n writeInt16 (value: number) {\n this.ensureAvailable(2)\n this._data.setInt16(this.offset, value, this.littleEndian)\n this.offset += 2\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write value as a 16-bit unsigned integer\n * @param {number} value\n * @return {IOBuffer}\n */\n writeUint16 (value: number) {\n this.ensureAvailable(2)\n this._data.setUint16(this.offset, value, this.littleEndian)\n this.offset += 2\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write a 32-bit signed integer at the current pointer offset\n * @param {number} value\n * @return {IOBuffer}\n */\n writeInt32 (value: number) {\n this.ensureAvailable(4)\n this._data.setInt32(this.offset, value, this.littleEndian)\n this.offset += 4\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write a 32-bit unsigned integer at the current pointer offset\n * @param {number} value - The value to set\n * @return {IOBuffer}\n */\n writeUint32 (value: number) {\n this.ensureAvailable(4)\n this._data.setUint32(this.offset, value, this.littleEndian)\n this.offset += 4\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write a 32-bit floating number at the current pointer offset\n * @param {number} value - The value to set\n * @return {IOBuffer}\n */\n writeFloat32 (value: number) {\n this.ensureAvailable(4)\n this._data.setFloat32(this.offset, value, this.littleEndian)\n this.offset += 4\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write a 64-bit floating number at the current pointer offset\n * @param {number} value\n * @return {IOBuffer}\n */\n writeFloat64 (value: number) {\n this.ensureAvailable(8)\n this._data.setFloat64(this.offset, value, this.littleEndian)\n this.offset += 8\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write the charCode of the passed string's first character to the current pointer offset\n * @param {string} str - The character to set\n * @return {IOBuffer}\n */\n writeChar (str: string) {\n return this.writeUint8(str.charCodeAt(0))\n }\n\n /**\n * Write the charCodes of the passed string's characters to the current pointer offset\n * @param {string} str\n * @return {IOBuffer}\n */\n writeChars (str: string) {\n for (var i = 0; i < str.length; i++) {\n this.writeUint8(str.charCodeAt(i))\n }\n return this\n }\n\n /**\n * Export a Uint8Array view of the internal buffer.\n * The view starts at the byte offset and its length\n * is calculated to stop at the last written byte or the original length.\n * @return {Uint8Array}\n */\n toArray () {\n return new Uint8Array(this.buffer, this.byteOffset, this._lastWrittenByte)\n }\n\n /**\n * Update the last written byte offset\n * @private\n */\n _updateLastWrittenByte () {\n if (this.offset > this._lastWrittenByte) {\n this._lastWrittenByte = this.offset\n }\n }\n}\n\nexport default IOBuffer\n","/**\n * @file Counter\n * @author Alexander Rose \n * @private\n */\n\nimport { Log } from '../globals'\n\nimport * as signalsWrapper from 'signals'\n\n/**\n * {@link Signal}, dispatched when the `count` changes\n * @example\n * counter.signals.countChanged.add( function( delta ){ ... } );\n * @event Counter#countChanged\n * @type {Integer}\n */\n\nexport interface CounterSignals {\n countChanged: signalsWrapper.Signal\n}\n\n/**\n * Counter class for keeping track of counts\n */\nclass Counter {\n count = 0\n\n signals: CounterSignals = {\n countChanged: new signalsWrapper.Signal()\n }\n\n /**\n * Set the `count` to zero\n * @return {undefined}\n */\n clear () {\n this.change(-this.count)\n }\n\n /**\n * Change the `count`\n * @fires Counter#countChanged\n * @param {Integer} delta - count change\n * @return {undefined}\n */\n change (delta: number) {\n this.count += delta\n this.signals.countChanged.dispatch(delta, this.count)\n\n if (this.count < 0) {\n Log.warn('Counter.count below zero', this.count)\n }\n }\n\n /**\n * Increments the `count` by one.\n * @return {undefined}\n */\n increment () {\n this.change(1)\n }\n\n /**\n * Decrements the `count` by one.\n * @return {undefined}\n */\n decrement () {\n this.change(-1)\n }\n\n /**\n * Listen to another counter object and change this `count` by the\n * same amount\n * @param {Counter} counter - the counter object to listen to\n * @return {undefined}\n */\n listen (counter: Counter) {\n this.change(counter.count)\n counter.signals.countChanged.add(this.change, this)\n }\n\n /**\n * Stop listening to the other counter object\n * @param {Counter} counter - the counter object to stop listening to\n * @return {undefined}\n */\n unlisten (counter: Counter) {\n const countChanged = counter.signals.countChanged\n if (countChanged.has(this.change, this)) {\n countChanged.remove(this.change, this)\n }\n }\n\n /**\n * Invole the callback function once, when the `count` becomes zero\n * @param {Function} callback - the callback function\n * @param {Object} context - the context for the callback function\n * @return {undefined}\n */\n onZeroOnce (callback: () => void, context?: any) {\n if (this.count === 0) {\n callback.call(context)\n } else {\n const fn = () => {\n if (this.count === 0) {\n this.signals.countChanged.remove(fn, this)\n callback.call(context)\n }\n }\n this.signals.countChanged.add(fn, this)\n }\n }\n\n dispose () {\n this.clear()\n this.signals.countChanged.dispose()\n }\n}\n\nexport default Counter\n","/**\n * @file Stats\n * @author Alexander Rose \n * @private\n */\n\nimport * as signalsWrapper from 'signals'\n\nexport default class Stats {\n signals = {\n updated: new signalsWrapper.Signal()\n }\n\n maxDuration = -Infinity\n minDuration = Infinity\n avgDuration = 14\n lastDuration = Infinity\n\n prevFpsTime = 0\n lastFps = Infinity\n lastFrames = 1\n frames = 0\n count = 0\n\n startTime: number\n currentTime: number\n\n constructor () {\n this.begin()\n }\n\n update () {\n this.startTime = this.end()\n this.currentTime = this.startTime\n this.signals.updated.dispatch()\n }\n\n begin () {\n this.startTime = window.performance.now()\n this.lastFrames = this.frames\n }\n\n end () {\n const time = window.performance.now()\n\n this.count += 1\n this.frames += 1\n\n this.lastDuration = time - this.startTime\n this.minDuration = Math.min(this.minDuration, this.lastDuration)\n this.maxDuration = Math.max(this.maxDuration, this.lastDuration)\n this.avgDuration -= this.avgDuration / 30\n this.avgDuration += this.lastDuration / 30\n\n if (time > this.prevFpsTime + 1000) {\n this.lastFps = this.frames\n this.prevFpsTime = time\n this.frames = 0\n }\n\n return time\n }\n}","/**\n * @file Shader Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { ShaderChunk } from 'three'\n\nimport './chunk/fog_fragment.glsl'\nimport './chunk/interior_fragment.glsl'\nimport './chunk/matrix_scale.glsl'\nimport './chunk/nearclip_vertex.glsl'\nimport './chunk/nearclip_fragment.glsl'\nimport './chunk/opaque_back_fragment.glsl'\nimport './chunk/radiusclip_vertex.glsl'\nimport './chunk/radiusclip_fragment.glsl'\nimport './chunk/unpack_color.glsl'\n\nimport { ShaderRegistry } from '../globals'\n\nexport type ShaderDefine = (\n 'NEAR_CLIP'|'RADIUS_CLIP'|'PICKING'|'NOLIGHT'|'FLAT_SHADED'|'OPAQUE_BACK'|\n 'DIFFUSE_INTERIOR'|'USE_INTERIOR_COLOR'|\n 'USE_SIZEATTENUATION'|'USE_MAP'|'ALPHATEST'|'SDF'|'FIXED_SIZE'|\n 'CUBIC_INTERPOLATION'|'BSPLINE_FILTER'|'CATMULROM_FILTER'|'MITCHELL_FILTER'\n)\nexport type ShaderDefines = {\n [k in ShaderDefine]?: number|string\n}\n\nfunction getDefines (defines: ShaderDefines) {\n if (defines === undefined) return ''\n\n const lines = []\n\n for (const name in defines) {\n const value = defines[ name as keyof ShaderDefines ]\n\n if (!value) continue\n\n lines.push(`#define ${name} ${value}`)\n }\n\n return lines.join('\\n') + '\\n'\n}\n\nconst reInclude = /^(?!\\/\\/)\\s*#include\\s+(\\S+)/gmi\nconst shaderCache: { [k: string]: string } = {}\n\nexport function getShader (name: string, defines: ShaderDefines = {}) {\n let hash = name + '|'\n for (const key in defines) {\n hash += key + ':' + defines[ key as keyof ShaderDefines ]\n }\n\n if (!shaderCache[ hash ]) {\n const definesText = getDefines(defines)\n\n let shaderText = ShaderRegistry.get(`shader/${name}`) as string\n if (!shaderText) {\n throw new Error(`empty shader, '${name}'`)\n }\n shaderText = shaderText.replace(reInclude, function (match, p1) {\n const path = `shader/chunk/${p1}.glsl`\n const chunk = ShaderRegistry.get(path) || ShaderChunk[ p1 ]\n if (!chunk) {\n throw new Error(`empty chunk, '${p1}'`)\n }\n return chunk\n })\n\n shaderCache[ hash ] = definesText + shaderText\n }\n\n return shaderCache[ hash ]\n}\n","/**\n * @file Viewer Constants\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug } from '../globals'\n\nif (typeof WebGLRenderingContext !== 'undefined') {\n const wrcp = WebGLRenderingContext.prototype\n\n // wrap WebGL debug function used by three.js and\n // ignore calls to them when the debug flag is not set\n\n const _getShaderParameter = wrcp.getShaderParameter\n wrcp.getShaderParameter = function getShaderParameter (this: WebGLRenderingContext) {\n if (Debug) {\n return _getShaderParameter.apply(this, arguments)\n } else {\n return true\n }\n }\n\n const _getShaderInfoLog = wrcp.getShaderInfoLog\n wrcp.getShaderInfoLog = function getShaderInfoLog (this: WebGLRenderingContext) {\n if (Debug) {\n return _getShaderInfoLog.apply(this, arguments)\n } else {\n return ''\n }\n }\n\n const _getProgramParameter = wrcp.getProgramParameter\n wrcp.getProgramParameter = function getProgramParameter (this: WebGLRenderingContext, program, pname) {\n if (Debug || pname !== wrcp.LINK_STATUS) {\n return _getProgramParameter.apply(this, arguments)\n } else {\n return true\n }\n }\n\n const _getProgramInfoLog = wrcp.getProgramInfoLog\n wrcp.getProgramInfoLog = function getProgramInfoLog (this: WebGLRenderingContext) {\n if (Debug) {\n return _getProgramInfoLog.apply(this, arguments)\n } else {\n return ''\n }\n }\n}\n\nexport const JitterVectors = [\n [\n [ 0, 0 ]\n ],\n [\n [ 4, 4 ], [ -4, -4 ]\n ],\n [\n [ -2, -6 ], [ 6, -2 ], [ -6, 2 ], [ 2, 6 ]\n ],\n [\n [ 1, -3 ], [ -1, 3 ], [ 5, 1 ], [ -3, -5 ],\n [ -5, 5 ], [ -7, -1 ], [ 3, 7 ], [ 7, -7 ]\n ],\n [\n [ 1, 1 ], [ -1, -3 ], [ -3, 2 ], [ 4, -1 ],\n [ -5, -2 ], [ 2, 5 ], [ 5, 3 ], [ 3, -5 ],\n [ -2, 6 ], [ 0, -7 ], [ -4, -6 ], [ -6, 4 ],\n [ -8, 0 ], [ 7, -4 ], [ 6, 7 ], [ -7, -8 ]\n ],\n [\n [ -4, -7 ], [ -7, -5 ], [ -3, -5 ], [ -5, -4 ],\n [ -1, -4 ], [ -2, -2 ], [ -6, -1 ], [ -4, 0 ],\n [ -7, 1 ], [ -1, 2 ], [ -6, 3 ], [ -3, 3 ],\n [ -7, 6 ], [ -3, 6 ], [ -5, 7 ], [ -1, 7 ],\n [ 5, -7 ], [ 1, -6 ], [ 6, -5 ], [ 4, -4 ],\n [ 2, -3 ], [ 7, -2 ], [ 1, -1 ], [ 4, -1 ],\n [ 2, 1 ], [ 6, 2 ], [ 0, 4 ], [ 4, 4 ],\n [ 2, 5 ], [ 7, 5 ], [ 5, 6 ], [ 3, 7 ]\n ]\n]\n\nJitterVectors.forEach(offsetList => {\n offsetList.forEach(offset => {\n // 0.0625 = 1 / 16\n offset[ 0 ] *= 0.0625\n offset[ 1 ] *= 0.0625\n })\n})\n","/**\n * @file Tiled Renderer\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { Camera, WebGLRenderer } from 'three'\nimport Viewer from './viewer'\n\nexport interface TiledRendererParams {\n factor?: number\n antialias?: boolean\n onProgress?: Function\n onFinish?: Function\n}\n\nclass TiledRenderer {\n canvas = document.createElement('canvas')\n\n private _width: number\n private _height: number\n private _n: number\n private _factor: number\n private _antialias: boolean\n private _viewerSampleLevel: number\n\n private _viewer: Viewer\n private _onProgress?: Function\n private _onFinish?: Function\n private _ctx: CanvasRenderingContext2D\n\n constructor(renderer: WebGLRenderer, camera: Camera, viewer: Viewer, params: TiledRendererParams) {\n this._viewer = viewer\n\n this._factor = defaults(params.factor, 2)\n this._antialias = defaults(params.antialias, false)\n\n this._onProgress = params.onProgress\n this._onFinish = params.onFinish\n\n if (this._antialias) this._factor *= 2\n this._n = this._factor * this._factor\n\n // canvas\n\n this._width = this._viewer.width\n this._height = this._viewer.height\n\n if (this._antialias) {\n this.canvas.width = this._width * this._factor / 2\n this.canvas.height = this._height * this._factor / 2\n } else {\n this.canvas.width = this._width * this._factor\n this.canvas.height = this._height * this._factor\n }\n\n this._ctx = this.canvas.getContext('2d')!\n\n this._viewerSampleLevel = viewer.sampleLevel\n this._viewer.setSampling(-1)\n }\n\n private _renderTile (i: number) {\n const viewer = this._viewer\n const width = this._width\n const height = this._height\n const factor = this._factor\n\n const x = i % factor\n const y = Math.floor(i / factor)\n\n const offsetX = x * width\n const offsetY = y * height\n\n viewer.camera.setViewOffset(\n width * factor,\n height * factor,\n offsetX,\n offsetY,\n width,\n height\n )\n\n viewer.render()\n\n if (this._antialias) {\n const w = Math.round((offsetX + width) / 2) - Math.round (offsetX / 2);\n const h = Math.round((offsetY + height) / 2) - Math.round (offsetY / 2);\n this._ctx.drawImage(\n viewer.renderer.domElement,\n Math.round(offsetX / 2),\n Math.round(offsetY / 2),\n w,\n h\n )\n } else {\n this._ctx.drawImage(\n viewer.renderer.domElement,\n Math.floor(offsetX),\n Math.floor(offsetY),\n Math.ceil(width),\n Math.ceil(height)\n )\n }\n\n if (typeof this._onProgress === 'function') {\n this._onProgress(i + 1, this._n, false)\n }\n }\n\n private _finalize () {\n this._viewer.setSampling(this._viewerSampleLevel)\n this._viewer.camera.view = null! // TODO\n\n if (typeof this._onFinish === 'function') {\n this._onFinish(this._n + 1, this._n, false)\n }\n }\n\n render () {\n for (let i = 0; i <= this._n; ++i) {\n if (i === this._n) {\n this._finalize()\n } else {\n this._renderTile(i)\n }\n }\n }\n\n renderAsync () {\n let count = 0\n const n = this._n\n\n const fn = () => {\n if (count === n) {\n this._finalize()\n } else {\n this._renderTile(count)\n }\n count += 1\n }\n\n for (let i = 0; i <= n; ++i) {\n setTimeout(fn, 0)\n }\n }\n}\n\nexport default TiledRenderer\n","/**\n * @file Math Constants\n * @author Alexander Rose \n * @private\n */\n\nexport const EPS = 0.0000001\nexport const TwoPI = 2 * Math.PI\n\nexport const DEG2RAD = Math.PI / 180\nexport const RAD2DEG = 180 / Math.PI\n","/**\n * @file Array Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { NumberArray } from '../types'\nimport { TwoPI } from './math-constants'\n\nexport function circularMean (array: NumberArray, max: number, stride = 1, offset = 0, indices?: NumberArray) {\n // http://en.wikipedia.org/wiki/Center_of_mass#Systems_with_periodic_boundary_conditions\n\n // Bai, Linge; Breen, David (2008). Calculating Center of Mass in an Unbounded 2D Environment. Journal of Graphics, GPU, and Game Tools 13 (4): 53–60.\n\n // http://stackoverflow.com/questions/18166507/using-fft-to-find-the-center-of-mass-under-periodic-boundary-conditions\n\n const n = indices ? indices.length : array.length / stride\n\n let cosMean = 0\n let sinMean = 0\n\n if (indices) {\n for (let i = 0; i < n; ++i) {\n const c = (array[ indices[ i ] * stride + offset ] + max) % max\n const angle = (c / max) * TwoPI - Math.PI\n\n cosMean += Math.cos(angle)\n sinMean += Math.sin(angle)\n }\n } else {\n for (let i = offset; i < n; i += stride) {\n const c = (array[ i ] + max) % max\n const angle = (c / max) * TwoPI - Math.PI\n\n cosMean += Math.cos(angle)\n sinMean += Math.sin(angle)\n }\n }\n\n cosMean /= n\n sinMean /= n\n\n const meanAngle = Math.atan2(sinMean, cosMean)\n const mean = (meanAngle + Math.PI) / TwoPI * max\n\n return mean\n}\n\nexport function calculateCenterArray (array1: NumberArray, array2: NumberArray, center?: T, offset = 0): T {\n const n = array1.length\n const c = center || new Float32Array(n)\n\n for (let i = 0; i < n; i += 3) {\n c[ offset + i + 0 ] = (array1[ i + 0 ] + array2[ i + 0 ]) / 2.0\n c[ offset + i + 1 ] = (array1[ i + 1 ] + array2[ i + 1 ]) / 2.0\n c[ offset + i + 2 ] = (array1[ i + 2 ] + array2[ i + 2 ]) / 2.0\n }\n\n return c as T\n}\n\nexport function calculateDirectionArray (array1: NumberArray, array2: NumberArray) {\n const n = array1.length\n const direction = new Float32Array(n)\n\n for (let i = 0; i < n; i += 3) {\n direction[ i + 0 ] = array2[ i + 0 ] - array1[ i + 0 ]\n direction[ i + 1 ] = array2[ i + 1 ] - array1[ i + 1 ]\n direction[ i + 2 ] = array2[ i + 2 ] - array1[ i + 2 ]\n }\n\n return direction\n}\n\nexport function uniformArray (n: number, a: number, optionalTarget?: T): T {\n const array = optionalTarget || new Float32Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = a\n }\n\n return array as T\n}\n\nexport function uniformArray3 (n: number, a: number, b: number, c: number, optionalTarget?: NumberArray) {\n const array = optionalTarget || new Float32Array(n * 3)\n\n for (let i = 0; i < n; ++i) {\n const j = i * 3\n\n array[ j + 0 ] = a\n array[ j + 1 ] = b\n array[ j + 2 ] = c\n }\n\n return array\n}\n\nexport function centerArray3 (array: NumberArray, center = new Vector3()) {\n const n = array.length\n\n for (let i = 0; i < n; i += 3) {\n center.x += array[ i ]\n center.y += array[ i + 1 ]\n center.z += array[ i + 2 ]\n }\n\n center.divideScalar(n / 3)\n\n return center\n}\n\nexport function serialArray (n: number) {\n const array = new Float32Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = i\n }\n\n return array\n}\n\nexport function serialBlockArray (n: number, b: number, offset = 0, optionalTarget?: NumberArray) {\n const array = optionalTarget || new Float32Array(n * b)\n\n for (let i = 0; i < n; ++i) {\n const k = offset + i * b\n\n for (let j = 0; j < b; ++j) {\n array[ k + j ] = i\n }\n }\n\n return array\n}\n\nexport function randomColorArray (n: number) {\n const array = new Float32Array(n * 3)\n\n for (let i = 0; i < n; ++i) {\n const j = i * 3\n\n array[ j + 0 ] = Math.random()\n array[ j + 1 ] = Math.random()\n array[ j + 2 ] = Math.random()\n }\n\n return array\n}\n\nexport function replicateArrayEntries (array: NumberArray, m: number) {\n const n = array.length\n const repArr = new Float32Array(n * m)\n\n for (let i = 0; i < n; ++i) {\n const k = i * m\n const a = array[ i ]\n\n for (let j = 0; j < m; ++j) {\n repArr[ k + j ] = a\n }\n }\n\n return repArr\n}\n\nexport function replicateArray3Entries (array: NumberArray, m: number) {\n const n = array.length / 3\n const repArr = new Float32Array(n * m * 3)\n\n for (let i = 0; i < n; ++i) {\n const v = i * 3\n const k = i * m * 3\n\n const a = array[ v + 0 ]\n const b = array[ v + 1 ]\n const c = array[ v + 2 ]\n\n for (let j = 0; j < m; ++j) {\n const l = k + j * 3\n\n repArr[ l + 0 ] = a\n repArr[ l + 1 ] = b\n repArr[ l + 2 ] = c\n }\n }\n\n return repArr\n}\n\nexport function calculateMeanArray (array1: NumberArray, array2: NumberArray) {\n const n = array1.length\n const mean = new Float32Array(n)\n\n for (let i = 0; i < n; i++) {\n mean[ i ] = (array1[ i ] + array2[ i ]) / 2.0\n }\n\n return mean\n}\n\nexport function calculateMinArray (array1: NumberArray, array2: NumberArray) {\n const n = array1.length\n const min = new Float32Array(n)\n\n for (let i = 0; i < n; i++) {\n min[ i ] = Math.min(array1[ i ], array2[ i ])\n }\n\n return min\n}\n\nexport function copyArray (src: T, dst: T, srcOffset: number, dstOffset: number, length: number) {\n for (let i = 0; i < length; ++i) {\n dst[ dstOffset + i ] = src[ srcOffset + i ]\n }\n}\n\nexport function copyWithin (array: NumberArray|any[], srcOffset: number, dstOffset: number, length: number) {\n copyArray(array, array, srcOffset, dstOffset, length)\n}\n\nconst swap = new Float32Array(4)\nconst temp = new Float32Array(4)\n/**\n * quicksortIP\n * @function\n * @author Roman Bolzern , 2013\n * @author I4DS http://www.fhnw.ch/i4ds, 2013\n * @license MIT License \n * @description\n * In-place quicksort for typed arrays (e.g. for Float32Array)\n * provides fast sorting\n * useful e.g. for a custom shader and/or BufferGeometry\n * Complexity: http://bigocheatsheet.com/ see Quicksort\n *\n * @example\n * points: [x, y, z, x, y, z, x, y, z, ...]\n * eleSize: 3 //because of (x, y, z)\n * orderElement: 0 //order according to x\n *\n * @param {TypedArray} arr - array to be sorted\n * @param {Integer} eleSize - element size\n * @param {Integer} orderElement - index of element used for sorting, < eleSize\n * @param {Integer} [begin] - start index for range to be sorted\n * @param {Integer} [end] - end index for range to be sorted\n * @return {TypedArray} the input array\n */\nexport function quicksortIP (arr: NumberArray, eleSize: number, orderElement: number, begin = 0, end?: number) {\n end = (end || (arr.length / eleSize)) - 1\n\n const stack = []\n let sp = -1\n let left = begin\n let right = end\n let tmp = 0.0\n let x = 0\n let y = 0\n\n const swapF = function (a: number, b: number) {\n a *= eleSize; b *= eleSize\n for (y = 0; y < eleSize; y++) {\n tmp = arr[ a + y ]\n arr[ a + y ] = arr[ b + y ]\n arr[ b + y ] = tmp\n }\n }\n\n let i, j\n\n while (true) {\n if (right - left <= 25) {\n for (j = left + 1; j <= right; j++) {\n for (x = 0; x < eleSize; x++) {\n swap[ x ] = arr[ j * eleSize + x ]\n }\n\n i = j - 1\n\n while (i >= left && arr[ i * eleSize + orderElement ] > swap[ orderElement ]) {\n for (x = 0; x < eleSize; x++) {\n arr[ (i + 1) * eleSize + x ] = arr[ i * eleSize + x ]\n }\n i--\n }\n\n for (x = 0; x < eleSize; x++) {\n arr[ (i + 1) * eleSize + x ] = swap[ x ]\n }\n }\n\n if (sp === -1) break\n\n right = stack[ sp-- ] // ?\n left = stack[ sp-- ]\n } else {\n const median = (left + right) >> 1\n\n i = left + 1\n j = right\n\n swapF(median, i)\n\n if (arr[ left * eleSize + orderElement ] > arr[ right * eleSize + orderElement ]) {\n swapF(left, right)\n }\n\n if (arr[ i * eleSize + orderElement ] > arr[ right * eleSize + orderElement ]) {\n swapF(i, right)\n }\n\n if (arr[ left * eleSize + orderElement ] > arr[ i * eleSize + orderElement ]) {\n swapF(left, i)\n }\n\n for (x = 0; x < eleSize; x++) {\n temp[ x ] = arr[ i * eleSize + x ]\n }\n\n while (true) {\n do i++; while (arr[ i * eleSize + orderElement ] < temp[ orderElement ])\n do j--; while (arr[ j * eleSize + orderElement ] > temp[ orderElement ])\n if (j < i) break\n swapF(i, j)\n }\n\n for (x = 0; x < eleSize; x++) {\n arr[ (left + 1) * eleSize + x ] = arr[ j * eleSize + x ]\n arr[ j * eleSize + x ] = temp[ x ]\n }\n\n if (right - i + 1 >= j - left) {\n stack[ ++sp ] = i\n stack[ ++sp ] = right\n right = j - 1\n } else {\n stack[ ++sp ] = left\n stack[ ++sp ] = j - 1\n left = i\n }\n }\n }\n\n return arr\n}\n\nexport function quicksortCmp (arr: NumberArray|T[], cmp?: (a: number|T, b: number|T) => number, begin = 0, end?: number) {\n cmp = cmp || function cmp (a, b) {\n if (a > b) return 1\n if (a < b) return -1\n return 0\n }\n end = (end || arr.length) - 1\n\n const stack = []\n let sp = -1\n let left = begin\n let right = end\n let tmp: number|T\n\n function swap (a: number, b: number) {\n const tmp2 = arr[ a ]\n arr[ a ] = arr[ b ]\n arr[ b ] = tmp2\n }\n\n let i, j\n\n while (true) {\n if (right - left <= 25) {\n for (let k = left + 1; k <= right; ++k) {\n tmp = arr[ k ]\n i = k - 1\n\n while (i >= left && cmp(arr[ i ], tmp) > 0) {\n arr[ i + 1 ] = arr[ i ]\n --i\n }\n\n arr[ i + 1 ] = tmp\n }\n\n if (sp === -1) break\n\n right = stack[ sp-- ] // ?\n left = stack[ sp-- ]\n } else {\n const median = (left + right) >> 1\n\n i = left + 1\n j = right\n\n swap(median, i)\n\n if (cmp(arr[ left ], arr[ right ]) > 0) {\n swap(left, right)\n }\n\n if (cmp(arr[ i ], arr[ right ]) > 0) {\n swap(i, right)\n }\n\n if (cmp(arr[ left ], arr[ i ]) > 0) {\n swap(left, i)\n }\n\n tmp = arr[ i ]\n\n while (true) {\n do i++; while (cmp(arr[ i ], tmp) < 0)\n do j--; while (cmp(arr[ j ], tmp) > 0)\n if (j < i) break\n swap(i, j)\n }\n\n arr[ left + 1 ] = arr[ j ]\n arr[ j ] = tmp\n\n if (right - i + 1 >= j - left) {\n stack[ ++sp ] = i\n stack[ ++sp ] = right\n right = j - 1\n } else {\n stack[ ++sp ] = left\n stack[ ++sp ] = j - 1\n left = i\n }\n }\n }\n\n return arr\n}\n\nexport function quickselectCmp (arr: NumberArray|T[], n: number, cmp?: (a: number|T, b: number|T) => number, left = 0, right?: number) {\n cmp = cmp || function cmp (a, b) {\n if (a > b) return 1\n if (a < b) return -1\n return 0\n }\n right = (right || arr.length) - 1\n\n let pivotIndex, pivotValue, storeIndex\n\n function swap (a: number, b: number) {\n const tmp = arr[ a ]\n arr[ a ] = arr[ b ]\n arr[ b ] = tmp\n }\n\n while (true) {\n if (left === right) {\n return arr[ left ]\n }\n pivotIndex = (left + right) >> 1\n pivotValue = arr[ pivotIndex ]\n swap(pivotIndex, right)\n storeIndex = left\n for (let i = left; i < right; ++i) {\n if (cmp(arr[ i ], pivotValue) < 0) {\n swap(storeIndex, i)\n ++storeIndex\n }\n }\n swap(right, storeIndex)\n pivotIndex = storeIndex\n if (n === pivotIndex) {\n return arr[ n ]\n } else if (n < pivotIndex) {\n right = pivotIndex - 1\n } else {\n left = pivotIndex + 1\n }\n }\n}\n\nexport function arrayMax (array: NumberArray) {\n let max = -Infinity\n for (let i = 0, il = array.length; i < il; ++i) {\n if (array[ i ] > max) max = array[ i ]\n }\n return max\n}\n\nexport function arrayMin (array: NumberArray) {\n let min = Infinity\n for (let i = 0, il = array.length; i < il; ++i) {\n if (array[ i ] < min) min = array[ i ]\n }\n return min\n}\n\nexport function arraySum (array: NumberArray, stride = 1, offset = 0) {\n const n = array.length\n let sum = 0\n for (let i = offset; i < n; i += stride) {\n sum += array[ i ]\n }\n return sum\n}\n\nexport function arrayMean (array: NumberArray, stride = 1, offset = 0) {\n return arraySum(array, stride, offset) / (array.length / stride)\n}\n\nexport function arrayRms (array: NumberArray) {\n const n = array.length\n let sumSq = 0\n for (let i = 0; i < n; ++i) {\n const di = array[ i ]\n sumSq += di * di\n }\n return Math.sqrt(sumSq / n)\n}\n\nexport function arraySorted (array: NumberArray) {\n for (let i = 1, il = array.length; i < il; ++i) {\n if (array[ i - 1 ] > array[ i ]) return false\n }\n return true\n}\n\nexport function arraySortedCmp (array: NumberArray|T[], cmp: (a: number|T, b: number|T) => number) {\n for (let i = 1, il = array.length; i < il; ++i) {\n if (cmp(array[ i - 1 ], array[ i ]) > 0) return false\n }\n return true\n}\n","/**\n * @file Viewer Utils\n * @author Alexander Rose \n * @private\n */\n\nimport {\n Vector2, Vector3, Matrix4, Points, Scene, Camera,\n Object3D, WebGLRenderer\n} from 'three'\n\nimport { createParams } from '../utils'\nimport TiledRenderer from './tiled-renderer'\nimport { quicksortCmp } from '../math/array-utils'\nimport Viewer from './viewer'\n\nfunction _trimCanvas (canvas: HTMLCanvasElement, r: number, g: number, b: number, a: number) {\n const canvasHeight = canvas.height\n const canvasWidth = canvas.width\n\n const ctx = canvas.getContext('2d')!\n const pixels = ctx.getImageData(0, 0, canvasWidth, canvasHeight).data\n\n let x, y, doBreak, off\n\n doBreak = false\n for (y = 0; y < canvasHeight; y++) {\n for (x = 0; x < canvasWidth; x++) {\n off = (y * canvasWidth + x) * 4\n if (pixels[ off ] !== r || pixels[ off + 1 ] !== g ||\n pixels[ off + 2 ] !== b || pixels[ off + 3 ] !== a\n ) {\n doBreak = true\n break\n }\n }\n if (doBreak) {\n break\n }\n }\n const topY = y\n\n doBreak = false\n for (x = 0; x < canvasWidth; x++) {\n for (y = 0; y < canvasHeight; y++) {\n off = (y * canvasWidth + x) * 4\n if (pixels[ off ] !== r || pixels[ off + 1 ] !== g ||\n pixels[ off + 2 ] !== b || pixels[ off + 3 ] !== a\n ) {\n doBreak = true\n break\n }\n }\n if (doBreak) {\n break\n }\n }\n const topX = x\n\n doBreak = false\n for (y = canvasHeight - 1; y >= 0; y--) {\n for (x = canvasWidth - 1; x >= 0; x--) {\n off = (y * canvasWidth + x) * 4\n if (pixels[ off ] !== r || pixels[ off + 1 ] !== g ||\n pixels[ off + 2 ] !== b || pixels[ off + 3 ] !== a\n ) {\n doBreak = true\n break\n }\n }\n if (doBreak) {\n break\n }\n }\n const bottomY = y\n\n doBreak = false\n for (x = canvasWidth - 1; x >= 0; x--) {\n for (y = canvasHeight - 1; y >= 0; y--) {\n off = (y * canvasWidth + x) * 4\n if (pixels[ off ] !== r || pixels[ off + 1 ] !== g ||\n pixels[ off + 2 ] !== b || pixels[ off + 3 ] !== a\n ) {\n doBreak = true\n break\n }\n }\n if (doBreak) {\n break\n }\n }\n const bottomX = x\n\n const trimedCanvas = document.createElement('canvas')\n trimedCanvas.width = bottomX - topX\n trimedCanvas.height = bottomY - topY\n\n const trimedCtx = trimedCanvas.getContext('2d')!\n trimedCtx.drawImage(\n canvas,\n topX, topY,\n trimedCanvas.width, trimedCanvas.height,\n 0, 0,\n trimedCanvas.width, trimedCanvas.height\n )\n\n return trimedCanvas\n}\n\n/**\n * Image parameter object.\n * @typedef {Object} ImageParameters - image generation parameters\n * @property {Boolean} trim - trim the image\n * @property {Integer} factor - scaling factor to apply to the viewer canvas\n * @property {Boolean} antialias - antialias the image\n * @property {Boolean} transparent - transparent image background\n */\n\nexport const ImageDefaultParameters = {\n trim: false,\n factor: 1,\n antialias: false,\n transparent: false,\n onProgress: undefined as Function|undefined\n}\nexport type ImageParameters = typeof ImageDefaultParameters\n\n/**\n * Make image from what is shown in a viewer canvas\n * @param {Viewer} viewer - the viewer\n * @param {ImageParameters} params - parameters object\n * @return {Promise} A Promise object that resolves to an image {@link Blob}.\n */\nexport function makeImage (viewer: Viewer, params: Partial = {}) {\n const {trim, factor, antialias, transparent} = createParams(params, ImageDefaultParameters)\n\n const renderer = viewer.renderer\n const camera = viewer.camera\n\n const originalClearAlpha = renderer.getClearAlpha()\n const backgroundColor = renderer.getClearColor()\n\n function setLineWidthAndPixelSize (invert = false) {\n let _factor = factor\n if (antialias) _factor *= 2\n if (invert) _factor = 1 / _factor\n viewer.scene.traverse(function (o: any) { // TODO\n const m = o.material\n if (m && m.linewidth) {\n m.linewidth *= _factor\n }\n if (m && m.uniforms && m.uniforms.size) {\n if (m.uniforms.size.__seen === undefined) {\n m.uniforms.size.value *= _factor\n m.uniforms.size.__seen = true\n }\n }\n if (m && m.uniforms && m.uniforms.linewidth) {\n if (m.uniforms.linewidth.__seen === undefined) {\n m.uniforms.linewidth.value *= _factor\n m.uniforms.linewidth.__seen = true\n }\n }\n })\n viewer.scene.traverse(function (o: any) { // TODO\n const m = o.material\n if (m && m.uniforms && m.uniforms.size) {\n delete m.uniforms.size.__seen\n }\n if (m && m.uniforms && m.uniforms.linewidth) {\n delete m.uniforms.linewidth.__seen\n }\n })\n }\n\n function trimCanvas (canvas: HTMLCanvasElement) {\n if (trim) {\n const bg = backgroundColor\n const r = transparent ? 0 : bg.r * 255\n const g = transparent ? 0 : bg.g * 255\n const b = transparent ? 0 : bg.b * 255\n const a = transparent ? 0 : 255\n return _trimCanvas(canvas, r, g, b, a)\n } else {\n return canvas\n }\n }\n\n function onProgress (i: number, n: number, finished: boolean) {\n if (typeof params.onProgress === 'function') {\n params.onProgress(i, n, finished)\n }\n }\n\n return new Promise(function (resolve, reject) {\n const tiledRenderer = new TiledRenderer(\n renderer, camera, viewer,\n { factor, antialias, onProgress, onFinish }\n )\n\n renderer.setClearAlpha(transparent ? 0 : 1)\n setLineWidthAndPixelSize()\n tiledRenderer.renderAsync()\n\n function onFinish (i: number, n: number) {\n const canvas = trimCanvas(tiledRenderer.canvas)\n canvas.toBlob(\n function (blob) {\n renderer.setClearAlpha(originalClearAlpha)\n setLineWidthAndPixelSize(true)\n viewer.requestRender()\n onProgress(n, n, true)\n if (blob) {\n resolve(blob)\n } else {\n reject('error creating image')\n }\n },\n 'image/png'\n )\n }\n })\n}\n\nconst vertex = new Vector3()\nconst matrix = new Matrix4()\nconst modelViewProjectionMatrix = new Matrix4()\n\nexport function sortProjectedPosition (scene: Scene, camera: Camera) {\n // console.time( \"sort\" );\n\n scene.traverseVisible(function (o) {\n if (!(o instanceof Points) || !o.userData.buffer.parameters.sortParticles) {\n return\n }\n\n const attributes = (o.geometry as any).attributes // TODO\n const n = attributes.position.count\n\n if (n === 0) return\n\n matrix.multiplyMatrices(\n camera.matrixWorldInverse, o.matrixWorld\n )\n modelViewProjectionMatrix.multiplyMatrices(\n camera.projectionMatrix, matrix\n )\n\n let sortData, sortArray, zArray: Float32Array, cmpFn\n\n if (!o.userData.sortData) {\n zArray = new Float32Array(n)\n sortArray = new Uint32Array(n)\n cmpFn = function (ai: number, bi: number) {\n const a = zArray[ ai ]\n const b = zArray[ bi ]\n if (a > b) return 1\n if (a < b) return -1\n return 0\n }\n\n sortData = {\n __zArray: zArray,\n __sortArray: sortArray,\n __cmpFn: cmpFn\n }\n\n o.userData.sortData = sortData\n } else {\n sortData = o.userData.sortData\n zArray = sortData.__zArray\n sortArray = sortData.__sortArray\n cmpFn = sortData.__cmpFn\n }\n\n for (let i = 0; i < n; ++i) {\n vertex.fromArray(attributes.position.array, i * 3)\n vertex.applyMatrix4(modelViewProjectionMatrix)\n\n // negate, so that sorting order is reversed\n zArray[ i ] = -vertex.z\n sortArray[ i ] = i\n }\n\n quicksortCmp(sortArray, cmpFn)\n\n let index, indexSrc, indexDst, tmpTab\n\n for (let name in attributes) {\n const attr = attributes[ name ]\n const array = attr.array\n const itemSize = attr.itemSize\n\n if (!sortData[ name ]) {\n sortData[ name ] = new Float32Array(itemSize * n)\n }\n\n tmpTab = sortData[ name ]\n sortData[ name ] = array\n\n for (let i = 0; i < n; ++i) {\n index = sortArray[ i ]\n\n for (let j = 0; j < itemSize; ++j) {\n indexSrc = index * itemSize + j\n indexDst = i * itemSize + j\n tmpTab[ indexDst ] = array[ indexSrc ]\n }\n }\n\n attributes[ name ].array = tmpTab\n attributes[ name ].needsUpdate = true\n }\n })\n\n // console.timeEnd( \"sort\" );\n}\n\nconst resolution = new Vector2()\nconst projectionMatrixInverse = new Matrix4()\nconst projectionMatrixTranspose = new Matrix4()\n\nexport function updateMaterialUniforms (group: Object3D, camera: Camera, renderer: WebGLRenderer, cDist: number, bRadius: number) {\n let size = new Vector2()\n renderer.getSize(size)\n const canvasHeight = size.height\n const pixelRatio = renderer.getPixelRatio()\n const ortho = camera.type === 'OrthographicCamera'\n\n resolution.set(size.width, size.height)\n projectionMatrixInverse.getInverse(camera.projectionMatrix)\n projectionMatrixTranspose.copy(camera.projectionMatrix).transpose()\n\n group.traverse(function (o: any) {\n const m = o.material\n if (!m) return\n\n const u = m.uniforms\n if (!u) return\n\n if (m.clipNear) {\n const nearFactor = (50 - m.clipNear) / 50\n const nearClip = cDist - (bRadius * nearFactor)\n u.clipNear.value = nearClip\n }\n\n if (u.canvasHeight) {\n u.canvasHeight.value = canvasHeight\n }\n\n if (u.resolution) {\n u.resolution.value.copy(resolution)\n }\n\n if (u.pixelRatio) {\n u.pixelRatio.value = pixelRatio\n }\n\n if (u.projectionMatrixInverse) {\n u.projectionMatrixInverse.value.copy(projectionMatrixInverse)\n }\n\n if (u.projectionMatrixTranspose) {\n u.projectionMatrixTranspose.value.copy(projectionMatrixTranspose)\n }\n\n if (u.ortho) {\n u.ortho.value = ortho\n }\n })\n}\n\nexport function updateCameraUniforms (group: Object3D, camera: Camera) {\n projectionMatrixInverse.getInverse(camera.projectionMatrix)\n projectionMatrixTranspose.copy(camera.projectionMatrix).transpose()\n\n group.traverse(function (o: any) {\n const m = o.material\n if (!m) return\n\n const u = m.uniforms\n if (!u) return\n\n if (u.projectionMatrixInverse) {\n u.projectionMatrixInverse.value.copy(projectionMatrixInverse)\n }\n\n if (u.projectionMatrixTranspose) {\n u.projectionMatrixTranspose.value.copy(projectionMatrixTranspose)\n }\n })\n}\n","/**\n * @file Viewer\n * @author Alexander Rose \n * @private\n */\n\n// adapted from https://webglfundamentals.org/webgl/resources/webgl-utils.js\n// Copyright 2012, Gregg Tavares. Modified BSD License\n\nexport function createProgram(gl: WebGLRenderingContext, shaders: WebGLShader[], attribs?: string[], locations?: number[]) {\n const program = gl.createProgram()\n if (!program) {\n console.log(`error creating WebGL program`)\n return\n }\n shaders.forEach(shader => gl.attachShader(program, shader))\n if (attribs) {\n attribs.forEach((attrib, i) => {\n gl.bindAttribLocation(program, locations ? locations[i] : i, attrib)\n })\n }\n gl.linkProgram(program);\n\n // Check the link status\n const linked = gl.getProgramParameter(program, gl.LINK_STATUS)\n if (!linked) {\n console.log(`error linking program: ${gl.getProgramInfoLog(program)}`)\n gl.deleteProgram(program)\n return null\n }\n return program\n}\n\nexport function loadShader(gl: WebGLRenderingContext, shaderSource: string, shaderType: number) {\n const shader = gl.createShader(shaderType)\n if (!shader) {\n console.log(`error creating WebGL shader ${shaderType}`)\n return // can't create shader\n }\n gl.shaderSource(shader, shaderSource)\n gl.compileShader(shader)\n\n // Check the compile status\n const compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS)\n if (!compiled) {\n console.log(`error compiling shader ${shader}: ${gl.getShaderInfoLog(shader)}`)\n gl.deleteShader(shader)\n return null\n }\n\n return shader\n}\n\n//\n\nexport function getErrorDescription(gl: WebGLRenderingContext, error: number) {\n switch (error) {\n case gl.NO_ERROR: return 'no error'\n case gl.INVALID_ENUM: return 'invalid enum'\n case gl.INVALID_VALUE: return 'invalid value'\n case gl.INVALID_OPERATION: return 'invalid operation'\n case gl.INVALID_FRAMEBUFFER_OPERATION: return 'invalid framebuffer operation'\n case gl.OUT_OF_MEMORY: return 'out of memory'\n case gl.CONTEXT_LOST_WEBGL: return 'context lost'\n }\n return 'unknown error'\n}\n\nexport function getExtension (gl: WebGLRenderingContext, name: string) {\n const ext = gl.getExtension(name)\n if (!ext) console.log(`extension '${name}' not available`)\n return ext\n}\n\nconst TextureTestVertShader = `\nattribute vec4 a_position;\n\nvoid main() {\n gl_Position = a_position;\n}`\n\nconst TextureTestFragShader = `\nprecision mediump float;\nuniform vec4 u_color;\nuniform sampler2D u_texture;\n\nvoid main() {\n gl_FragColor = texture2D(u_texture, vec2(0.5, 0.5)) * u_color;\n}`\n\nconst TextureTestTexCoords = new Float32Array([\n -1.0, -1.0, 1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0\n])\n\nexport function testTextureSupport (type: number) {\n // adapted from\n // https://stackoverflow.com/questions/28827511/webgl-ios-render-to-floating-point-texture\n\n // Get A WebGL context\n const canvas = document.createElement('canvas')\n canvas.width = 16\n canvas.height = 16\n canvas.style.width = 16 + 'px'\n canvas.style.height = 16 + 'px'\n const gl = canvas.getContext(\"webgl\") || canvas.getContext(\"experimental-webgl\");\n if (!gl) {\n console.log(`error creating webgl context for ${type}`)\n return false\n }\n if (!(gl instanceof WebGLRenderingContext)) {\n console.log(`Got unexpected type for WebGL rendering context`)\n return false\n }\n\n getExtension(gl, 'OES_texture_float')\n getExtension(gl, 'OES_texture_half_float')\n getExtension(gl, 'WEBGL_color_buffer_float')\n\n // setup shaders\n const vertShader = loadShader(gl, TextureTestVertShader, gl.VERTEX_SHADER)\n const fragShader = loadShader(gl, TextureTestFragShader, gl.FRAGMENT_SHADER)\n if (!vertShader || !fragShader) return false\n\n // setup program\n const program = createProgram(gl, [ vertShader, fragShader ])\n if (!program) {\n console.log(`error creating WebGL program`)\n return false\n }\n gl.useProgram(program);\n\n // look up where the vertex data needs to go.\n const positionLocation = gl.getAttribLocation(program, \"a_position\");\n const colorLoc = gl.getUniformLocation(program, \"u_color\");\n if (!colorLoc) {\n console.log(`error getting 'u_color' uniform location`)\n return false\n }\n\n // provide texture coordinates for the rectangle.\n const positionBuffer = gl.createBuffer()\n gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer)\n gl.bufferData(gl.ARRAY_BUFFER, TextureTestTexCoords, gl.STATIC_DRAW)\n gl.enableVertexAttribArray(positionLocation)\n gl.vertexAttribPointer(positionLocation, 2, gl.FLOAT, false, 0, 0)\n\n const whiteTex = gl.createTexture()\n const whiteData = new Uint8Array([255, 255, 255, 255])\n gl.bindTexture(gl.TEXTURE_2D, whiteTex)\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, whiteData)\n\n const tex = gl.createTexture()\n gl.bindTexture(gl.TEXTURE_2D, tex)\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, type, null)\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST)\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST)\n\n const fb = gl.createFramebuffer()\n gl.bindFramebuffer(gl.FRAMEBUFFER, fb)\n gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, tex, 0)\n const status = gl.checkFramebufferStatus(gl.FRAMEBUFFER)\n if (status !== gl.FRAMEBUFFER_COMPLETE) {\n console.log(`error creating framebuffer for ${type}`)\n return false\n }\n\n // Draw the rectangle.\n gl.bindTexture(gl.TEXTURE_2D, whiteTex)\n gl.uniform4fv(colorLoc, [0, 10, 20, 1])\n gl.drawArrays(gl.TRIANGLES, 0, 6)\n\n gl.bindTexture(gl.TEXTURE_2D, tex)\n gl.bindFramebuffer(gl.FRAMEBUFFER, null)\n gl.clearColor(1, 0, 0, 1)\n gl.clear(gl.COLOR_BUFFER_BIT)\n gl.uniform4fv(colorLoc, [0, 1/10, 1/20, 1])\n gl.drawArrays(gl.TRIANGLES, 0, 6)\n\n // Check if rendered correctly\n const pixel = new Uint8Array(4)\n gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, pixel)\n if (pixel[0] !== 0 || pixel[1] < 248 || pixel[2] < 248 || pixel[3] < 254) {\n console.log(`not able to actually render to ${type} texture`)\n return false\n }\n\n // Check reading from float texture\n if (type === gl.FLOAT) {\n gl.bindFramebuffer(gl.FRAMEBUFFER, fb)\n const floatPixel = new Float32Array(4)\n gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.FLOAT, floatPixel)\n const error = gl.getError()\n if (error) {\n console.log(`error reading pixels as float: '${getErrorDescription(gl, error)}'`)\n return false\n }\n }\n\n return true\n}\n","/**\n * @file Viewer\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\nimport {\n PerspectiveCamera, OrthographicCamera, StereoCamera,\n Vector2, Box3, Vector3, Matrix4, Color,\n WebGLRenderer, WebGLRenderTarget,\n NearestFilter, LinearFilter, AdditiveBlending,\n RGBAFormat, FloatType, /*HalfFloatType, */UnsignedByteType,\n ShaderMaterial,\n PlaneGeometry, Geometry,\n Scene, Mesh, Group, Object3D, Uniform,\n Fog, SpotLight, AmbientLight,\n BufferGeometry, BufferAttribute,\n LineSegments,\n LinearEncoding, sRGBEncoding, TextureEncoding\n} from 'three'\nimport '../shader/BasicLine.vert'\nimport '../shader/BasicLine.frag'\nimport '../shader/Quad.vert'\nimport '../shader/Quad.frag'\n\nimport {\n Debug, Log, WebglErrorMessage, Browser,\n setExtensionFragDepth, SupportsReadPixelsFloat, setSupportsReadPixelsFloat\n} from '../globals'\nimport { degToRad } from '../math/math-utils'\nimport Stats from './stats'\nimport { getShader } from '../shader/shader-utils'\nimport { setColorSpace } from '../color/colormaker'\nimport { JitterVectors } from './viewer-constants'\nimport {\n makeImage, ImageParameters,\n sortProjectedPosition, updateMaterialUniforms, updateCameraUniforms\n} from './viewer-utils'\nimport { testTextureSupport } from './gl-utils'\n\nimport Buffer from '../buffer/buffer'\n\nconst pixelBufferFloat = new Float32Array(4 * 25)\nconst pixelBufferUint = new Uint8Array(4 * 25)\n\n// When picking, we read a 25 pixel (5x5) array (readRenderTargetPixels)\n// We read the pixels in the order below to find what was picked.\n// This starts at the center and tries successively further points.\n// (Many points will be at equal distance to the center, their order\n// is arbitrary).\nconst pixelOrder = [12,7,13,17,11,6,8,18,16,2,14,22,10,1,3,9,19,23,21,15,5,0,4,24,20]\n\n\nconst tmpMatrix = new Matrix4()\n\nfunction onBeforeRender (this: Object3D, renderer: WebGLRenderer, scene: Scene, camera: PerspectiveCamera|OrthographicCamera, geometry: Geometry, material: ShaderMaterial/*, group */) {\n const u = material.uniforms\n const updateList = []\n\n if (!u) return // See #908 - some materials may not have uniforms, ignore these\n\n if (u.objectId) {\n u.objectId.value = SupportsReadPixelsFloat ? this.id : this.id / 255\n updateList.push('objectId')\n }\n\n if (u.modelViewMatrixInverse || u.modelViewMatrixInverseTranspose ||\n u.modelViewProjectionMatrix || u.modelViewProjectionMatrixInverse\n ) {\n this.modelViewMatrix.multiplyMatrices(camera.matrixWorldInverse, this.matrixWorld)\n }\n\n if (u.modelViewMatrixInverse) {\n u.modelViewMatrixInverse.value.getInverse(this.modelViewMatrix)\n updateList.push('modelViewMatrixInverse')\n }\n\n if (u.modelViewMatrixInverseTranspose) {\n if (u.modelViewMatrixInverse) {\n u.modelViewMatrixInverseTranspose.value.copy(\n u.modelViewMatrixInverse.value\n ).transpose()\n } else {\n u.modelViewMatrixInverseTranspose.value\n .getInverse(this.modelViewMatrix)\n .transpose()\n }\n updateList.push('modelViewMatrixInverseTranspose')\n }\n\n if (u.modelViewProjectionMatrix) {\n u.modelViewProjectionMatrix.value.multiplyMatrices(\n camera.projectionMatrix, this.modelViewMatrix\n )\n updateList.push('modelViewProjectionMatrix')\n }\n\n if (u.modelViewProjectionMatrixInverse) {\n if (u.modelViewProjectionMatrix) {\n tmpMatrix.copy(\n u.modelViewProjectionMatrix.value\n )\n u.modelViewProjectionMatrixInverse.value.getInverse(\n tmpMatrix\n )\n } else {\n tmpMatrix.multiplyMatrices(\n camera.projectionMatrix, this.modelViewMatrix\n )\n u.modelViewProjectionMatrixInverse.value.getInverse(\n tmpMatrix\n )\n }\n updateList.push('modelViewProjectionMatrixInverse')\n }\n\n if (updateList.length) {\n const materialProperties = renderer.properties.get(material)\n\n if (materialProperties.program) {\n const gl = renderer.getContext()\n const p = materialProperties.program\n gl.useProgram(p.program)\n const pu = p.getUniforms()\n\n updateList.forEach(function (name) {\n pu.setValue(gl, name, u[ name ].value)\n })\n }\n }\n}\n\nexport type CameraType = 'perspective'|'orthographic'|'stereo'\nexport type ColorWorkflow = 'linear' | 'sRGB'\n\nexport interface ViewerSignals {\n ticked: Signal,\n rendered: Signal\n}\n\nexport interface ViewerParameters {\n fogColor: Color\n fogNear: number\n fogFar: number\n\n backgroundColor: Color\n\n cameraType: CameraType\n cameraFov: number\n cameraEyeSep: number\n cameraZ: number\n\n clipNear: number\n clipFar: number\n clipDist: number\n clipMode: string // \"scene\" or \"camera\"\n clipScale: string // \"relative\" or \"absolute\"\n\n lightColor: Color\n lightIntensity: number\n ambientColor: Color\n ambientIntensity: number\n\n sampleLevel: number\n\n rendererEncoding: TextureEncoding // default is three.LinearEncoding; three.sRGBEncoding gives more correct results\n}\n\nexport interface BufferInstance {\n matrix: Matrix4\n}\n\n/**\n * Viewer class\n * @class\n * @param {String|Element} [idOrElement] - dom id or element\n */\nexport default class Viewer {\n signals: ViewerSignals\n\n container: HTMLElement\n wrapper: HTMLElement\n\n private rendering: boolean\n private renderPending: boolean\n private lastRenderedPicking: boolean\n private isStill: boolean\n private frameRequest: number\n\n sampleLevel: number\n private cDist: number\n private bRadius: number\n\n private parameters: ViewerParameters\n stats: Stats\n\n perspectiveCamera: PerspectiveCamera\n private orthographicCamera: OrthographicCamera\n private stereoCamera: StereoCamera\n camera: PerspectiveCamera|OrthographicCamera\n\n width: number\n height: number\n\n scene: Scene\n private spotLight: SpotLight\n private ambientLight: AmbientLight\n rotationGroup: Group\n translationGroup: Group\n private modelGroup: Group\n private pickingGroup: Group\n private backgroundGroup: Group\n private helperGroup: Group\n\n renderer: WebGLRenderer\n private supportsHalfFloat: boolean\n\n private pickingTarget: WebGLRenderTarget\n private sampleTarget: WebGLRenderTarget\n private holdTarget: WebGLRenderTarget\n\n private compositeUniforms: {\n tForeground: Uniform\n scale: Uniform\n }\n private compositeMaterial: ShaderMaterial\n private compositeCamera: OrthographicCamera\n private compositeScene: Scene\n\n private boundingBoxMesh: LineSegments\n boundingBox = new Box3()\n private boundingBoxSize = new Vector3()\n private boundingBoxLength = 0\n\n private info = {\n memory: {\n programs: 0,\n geometries: 0,\n textures: 0\n },\n render: {\n calls: 0,\n vertices: 0,\n faces: 0,\n points: 0\n }\n }\n\n private distVector = new Vector3()\n\n constructor (idOrElement: string|HTMLElement) {\n this.signals = {\n ticked: new Signal(),\n rendered: new Signal()\n }\n\n if (typeof idOrElement === 'string') {\n const elm = document.getElementById(idOrElement)\n if (elm === null) {\n this.container = document.createElement('div')\n }else {\n this.container = elm\n }\n } else if (idOrElement instanceof HTMLElement) {\n this.container = idOrElement\n } else {\n this.container = document.createElement('div')\n }\n\n if (this.container === document.body) {\n this.width = window.innerWidth || 1\n this.height = window.innerHeight || 1\n } else {\n const box = this.container.getBoundingClientRect()\n this.width = box.width || 1\n this.height = box.height || 1\n this.container.style.overflow = 'hidden'\n }\n\n this.wrapper = document.createElement('div')\n this.wrapper.style.position = 'relative'\n this.container.appendChild(this.wrapper)\n\n this._initParams()\n this._initStats()\n this._initCamera()\n this._initScene()\n\n if (this._initRenderer() === false) {\n Log.error('Viewer: could not initialize renderer')\n return\n }\n\n this._initHelper()\n\n // fog & background\n this.setBackground()\n this.setFog()\n\n this.animate = this.animate.bind(this)\n }\n\n private _initParams () {\n this.parameters = {\n fogColor: new Color(0x000000),\n fogNear: 50,\n fogFar: 100,\n\n backgroundColor: new Color(0x000000),\n\n cameraType: 'perspective',\n cameraFov: 40,\n cameraEyeSep: 0.3,\n cameraZ: -80, // FIXME initial value should be automatically determined\n\n clipNear: 0,\n clipFar: 100,\n clipDist: 10,\n clipMode: 'scene',\n clipScale: 'relative',\n\n lightColor: new Color(0xdddddd),\n lightIntensity: 1.0,\n ambientColor: new Color(0xdddddd),\n ambientIntensity: 0.2,\n\n sampleLevel: 0,\n\n // output encoding: use sRGB for a linear internal workflow, linear for traditional sRGB workflow.\n rendererEncoding: LinearEncoding,\n }\n }\n\n private _initCamera () {\n const lookAt = new Vector3(0, 0, 0)\n const {width, height} = this\n\n this.perspectiveCamera = new PerspectiveCamera(\n this.parameters.cameraFov, width / height\n )\n this.perspectiveCamera.position.z = this.parameters.cameraZ\n this.perspectiveCamera.lookAt(lookAt)\n\n this.orthographicCamera = new OrthographicCamera(\n width / -2, width / 2, height / 2, height / -2\n )\n this.orthographicCamera.position.z = this.parameters.cameraZ\n this.orthographicCamera.lookAt(lookAt)\n\n this.stereoCamera = new StereoCamera()\n this.stereoCamera.aspect = 0.5\n this.stereoCamera.eyeSep = this.parameters.cameraEyeSep\n\n const cameraType = this.parameters.cameraType\n if (cameraType === 'orthographic') {\n this.camera = this.orthographicCamera\n } else if(cameraType === 'perspective' || cameraType === 'stereo') {\n this.camera = this.perspectiveCamera\n } else {\n throw new Error(`Unknown cameraType '${cameraType}'`)\n }\n this.camera.updateProjectionMatrix()\n }\n\n private _initStats () {\n this.stats = new Stats()\n }\n\n private _initScene () {\n if (!this.scene) {\n this.scene = new Scene()\n this.scene.name = 'scene'\n }\n\n this.rotationGroup = new Group()\n this.rotationGroup.name = 'rotationGroup'\n this.scene.add(this.rotationGroup)\n\n this.translationGroup = new Group()\n this.translationGroup.name = 'translationGroup'\n this.rotationGroup.add(this.translationGroup)\n\n this.modelGroup = new Group()\n this.modelGroup.name = 'modelGroup'\n this.translationGroup.add(this.modelGroup)\n\n this.pickingGroup = new Group()\n this.pickingGroup.name = 'pickingGroup'\n this.translationGroup.add(this.pickingGroup)\n\n this.backgroundGroup = new Group()\n this.backgroundGroup.name = 'backgroundGroup'\n this.translationGroup.add(this.backgroundGroup)\n\n this.helperGroup = new Group()\n this.helperGroup.name = 'helperGroup'\n this.translationGroup.add(this.helperGroup)\n\n // fog\n\n this.scene.fog = new Fog(this.parameters.fogColor.getHex())\n\n // light\n\n this.spotLight = new SpotLight(\n this.parameters.lightColor.getHex(), this.parameters.lightIntensity\n )\n this.scene.add(this.spotLight)\n\n this.ambientLight = new AmbientLight(\n this.parameters.ambientColor.getHex(), this.parameters.ambientIntensity\n )\n this.scene.add(this.ambientLight)\n }\n\n private _initRenderer () {\n const dpr = window.devicePixelRatio\n const {width, height} = this\n\n try {\n this.renderer = new WebGLRenderer({\n preserveDrawingBuffer: true,\n alpha: true,\n antialias: true\n })\n } catch (e) {\n this.wrapper.innerHTML = WebglErrorMessage\n return false\n }\n this.renderer.setPixelRatio(dpr)\n this.renderer.setSize(width, height)\n this.renderer.autoClear = false\n this.renderer.sortObjects = true\n this.renderer.outputEncoding = this.parameters.rendererEncoding\n\n const gl = this.renderer.getContext()\n // console.log(gl.getContextAttributes().antialias)\n // console.log(gl.getParameter(gl.SAMPLES))\n\n // For WebGL1, extensions must be explicitly enabled.\n // The following are builtin to WebGL2 (and don't appear as\n // extensions)\n // EXT_frag_depth, OES_element_index_uint, OES_texture_float\n // OES_texture_half_float\n\n // The WEBGL_color_buffer_float extension is replaced by\n // EXT_color_buffer_float\n\n // If not webgl2 context, explicitly check for these\n if (!this.renderer.capabilities.isWebGL2) {\n setExtensionFragDepth(this.renderer.extensions.get('EXT_frag_depth'))\n this.renderer.extensions.get('OES_element_index_uint')\n\n setSupportsReadPixelsFloat(\n (this.renderer.extensions.get('OES_texture_float') &&\n this.renderer.extensions.get('WEBGL_color_buffer_float')) ||\n (this.renderer.extensions.get('OES_texture_float') &&\n testTextureSupport(gl.FLOAT))\n )\n // picking texture\n\n this.renderer.extensions.get('OES_texture_float')\n\n this.supportsHalfFloat = (\n this.renderer.extensions.get('OES_texture_half_float') &&\n testTextureSupport(0x8D61)\n )\n\n } else {\n setExtensionFragDepth(true)\n setSupportsReadPixelsFloat(\n this.renderer.extensions.get('EXT_color_buffer_float')\n )\n this.supportsHalfFloat = true\n }\n\n this.wrapper.appendChild(this.renderer.domElement)\n\n const dprWidth = width * dpr\n const dprHeight = height * dpr\n\n\n if (Debug) {\n console.log(JSON.stringify({\n 'Browser': Browser,\n 'OES_texture_float': !!this.renderer.extensions.get('OES_texture_float'),\n 'OES_texture_half_float': !!this.renderer.extensions.get('OES_texture_half_float'),\n 'WEBGL_color_buffer_float': !!this.renderer.extensions.get('WEBGL_color_buffer_float'),\n 'testTextureSupport Float': testTextureSupport(gl.FLOAT),\n 'testTextureSupport HalfFloat': testTextureSupport(0x8D61),\n 'this.supportsHalfFloat': this.supportsHalfFloat,\n 'SupportsReadPixelsFloat': SupportsReadPixelsFloat\n }, null, 2))\n }\n\n this.pickingTarget = new WebGLRenderTarget(\n dprWidth, dprHeight,\n {\n minFilter: NearestFilter,\n magFilter: NearestFilter,\n stencilBuffer: false,\n format: RGBAFormat,\n type: SupportsReadPixelsFloat ? FloatType : UnsignedByteType\n }\n )\n this.pickingTarget.texture.generateMipmaps = false\n this.pickingTarget.texture.encoding = this.parameters.rendererEncoding\n\n // workaround to reset the gl state after using testTextureSupport\n // fixes some bug where nothing is rendered to the canvas\n // when animations are started on page load\n this.renderer.setRenderTarget(this.pickingTarget)\n this.renderer.clear()\n this.renderer.setRenderTarget(null!)\n\n // ssaa textures\n\n this.sampleTarget = new WebGLRenderTarget(\n dprWidth, dprHeight,\n {\n minFilter: LinearFilter,\n magFilter: LinearFilter,\n format: RGBAFormat\n }\n )\n this.sampleTarget.texture.encoding = this.parameters.rendererEncoding\n\n this.holdTarget = new WebGLRenderTarget(\n dprWidth, dprHeight,\n {\n minFilter: NearestFilter,\n magFilter: NearestFilter,\n format: RGBAFormat,\n type: UnsignedByteType\n // using HalfFloatType or FloatType does not work on some Chrome 61 installations\n // type: this.supportsHalfFloat ? HalfFloatType : (\n // SupportsReadPixelsFloat ? FloatType : UnsignedByteType\n // )\n }\n )\n this.holdTarget.texture.encoding = this.parameters.rendererEncoding\n\n this.compositeUniforms = {\n 'tForeground': new Uniform(this.sampleTarget.texture),\n 'scale': new Uniform(1.0)\n }\n\n this.compositeMaterial = new ShaderMaterial({\n uniforms: this.compositeUniforms,\n vertexShader: getShader('Quad.vert'),\n fragmentShader: getShader('Quad.frag'),\n premultipliedAlpha: true,\n transparent: true,\n blending: AdditiveBlending,\n depthTest: false,\n depthWrite: false\n })\n\n this.compositeCamera = new OrthographicCamera(-1, 1, 1, -1, 0, 1)\n this.compositeScene = new Scene()\n this.compositeScene.name = 'compositeScene'\n this.compositeScene.add(new Mesh(\n new PlaneGeometry(2, 2), this.compositeMaterial\n ))\n }\n\n private _initHelper () {\n const indices = new Uint16Array([\n 0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6,\n 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7\n ])\n const positions = new Float32Array(8 * 3)\n\n const bbGeometry = new BufferGeometry()\n bbGeometry.setIndex(new BufferAttribute(indices, 1))\n bbGeometry.setAttribute('position', new BufferAttribute(positions, 3))\n const bbMaterial = new ShaderMaterial({\n uniforms: { 'uColor': { value: new Color('skyblue') } },\n vertexShader: getShader('BasicLine.vert'),\n fragmentShader: getShader('BasicLine.frag')\n })\n\n this.boundingBoxMesh = new LineSegments(bbGeometry, bbMaterial)\n this.helperGroup.add(this.boundingBoxMesh)\n }\n\n updateHelper () {\n const position = ((this.boundingBoxMesh.geometry as BufferGeometry).attributes as any).position // TODO\n const array = position.array\n const {min, max} = this.boundingBox\n\n array[ 0 ] = max.x; array[ 1 ] = max.y; array[ 2 ] = max.z\n array[ 3 ] = min.x; array[ 4 ] = max.y; array[ 5 ] = max.z\n array[ 6 ] = min.x; array[ 7 ] = min.y; array[ 8 ] = max.z\n array[ 9 ] = max.x; array[ 10 ] = min.y; array[ 11 ] = max.z\n array[ 12 ] = max.x; array[ 13 ] = max.y; array[ 14 ] = min.z\n array[ 15 ] = min.x; array[ 16 ] = max.y; array[ 17 ] = min.z\n array[ 18 ] = min.x; array[ 19 ] = min.y; array[ 20 ] = min.z\n array[ 21 ] = max.x; array[ 22 ] = min.y; array[ 23 ] = min.z\n\n position.needsUpdate = true\n\n if (!this.boundingBox.isEmpty()) {\n this.boundingBoxMesh.geometry.computeBoundingSphere()\n }\n }\n\n /** Distance from origin (lookAt point) */\n get cameraDistance(): number {\n return Math.abs(this.camera.position.z)\n }\n\n /** Set distance from origin (lookAt point); along the -z axis */\n set cameraDistance(d: number) {\n this.camera.position.z = -d\n }\n\n add (buffer: Buffer, instanceList?: BufferInstance[]) {\n // Log.time( \"Viewer.add\" );\n\n if (instanceList) {\n instanceList.forEach(instance => this.addBuffer(buffer, instance))\n } else {\n this.addBuffer(buffer)\n }\n\n buffer.group.name = 'meshGroup'\n buffer.wireframeGroup.name = 'wireframeGroup'\n if (buffer.parameters.background) {\n this.backgroundGroup.add(buffer.group)\n this.backgroundGroup.add(buffer.wireframeGroup)\n } else {\n this.modelGroup.add(buffer.group)\n this.modelGroup.add(buffer.wireframeGroup)\n }\n\n if (buffer.pickable) {\n this.pickingGroup.add(buffer.pickingGroup)\n }\n\n if (Debug) this.updateHelper()\n\n // Log.timeEnd( \"Viewer.add\" );\n }\n\n addBuffer (buffer: Buffer, instance?: BufferInstance) {\n // Log.time( \"Viewer.addBuffer\" );\n\n function setUserData (object: Object3D) {\n if (object instanceof Group) {\n object.children.forEach(setUserData)\n } else {\n object.userData.buffer = buffer\n object.userData.instance = instance\n object.onBeforeRender = onBeforeRender\n }\n }\n\n const mesh = buffer.getMesh()\n if (instance) {\n mesh.applyMatrix4(instance.matrix)\n }\n setUserData(mesh)\n buffer.group.add(mesh)\n\n const wireframeMesh = buffer.getWireframeMesh()\n if (instance) {\n // wireframeMesh.applyMatrix( instance.matrix );\n wireframeMesh.matrix.copy(mesh.matrix)\n wireframeMesh.position.copy(mesh.position)\n wireframeMesh.quaternion.copy(mesh.quaternion)\n wireframeMesh.scale.copy(mesh.scale)\n }\n setUserData(wireframeMesh)\n buffer.wireframeGroup.add(wireframeMesh)\n\n if (buffer.pickable) {\n const pickingMesh = buffer.getPickingMesh()\n if (instance) {\n // pickingMesh.applyMatrix( instance.matrix );\n pickingMesh.matrix.copy(mesh.matrix)\n pickingMesh.position.copy(mesh.position)\n pickingMesh.quaternion.copy(mesh.quaternion)\n pickingMesh.scale.copy(mesh.scale)\n }\n setUserData(pickingMesh)\n buffer.pickingGroup.add(pickingMesh)\n }\n\n if (instance) {\n this._updateBoundingBox(buffer.geometry, buffer.matrix, instance.matrix)\n } else {\n this._updateBoundingBox(buffer.geometry, buffer.matrix)\n }\n\n // Log.timeEnd( \"Viewer.addBuffer\" );\n }\n\n remove (buffer: Buffer) {\n this.translationGroup.children.forEach(function (group) {\n group.remove(buffer.group)\n group.remove(buffer.wireframeGroup)\n })\n\n if (buffer.pickable) {\n this.pickingGroup.remove(buffer.pickingGroup)\n }\n\n this.updateBoundingBox()\n if (Debug) this.updateHelper()\n\n // this.requestRender();\n }\n\n private _updateBoundingBox (geometry?: BufferGeometry, matrix?: Matrix4, instanceMatrix?: Matrix4) {\n const boundingBox = this.boundingBox\n\n function updateGeometry (geometry: BufferGeometry, matrix?: Matrix4, instanceMatrix?: Matrix4) {\n if (geometry.boundingBox == null) {\n geometry.computeBoundingBox()\n }\n\n const geoBoundingBox = (geometry.boundingBox as Box3).clone()\n\n if (matrix) {\n geoBoundingBox.applyMatrix4(matrix)\n }\n if (instanceMatrix) {\n geoBoundingBox.applyMatrix4(instanceMatrix)\n }\n\n if (geoBoundingBox.min.equals(geoBoundingBox.max)) {\n // mainly to give a single impostor geometry some volume\n // as it is only expanded in the shader on the GPU\n geoBoundingBox.expandByScalar(5)\n }\n\n boundingBox.union(geoBoundingBox)\n }\n\n function updateNode (node: Mesh) {\n if (node.geometry !== undefined) {\n let matrix, instanceMatrix\n if (node.userData.buffer) {\n matrix = node.userData.buffer.matrix\n }\n if (node.userData.instance) {\n instanceMatrix = node.userData.instance.matrix\n }\n updateGeometry(node.geometry as BufferGeometry, matrix, instanceMatrix) // TODO\n }\n }\n\n if (geometry) {\n updateGeometry(geometry, matrix, instanceMatrix)\n } else {\n boundingBox.makeEmpty()\n this.modelGroup.traverse(updateNode)\n this.backgroundGroup.traverse(updateNode)\n }\n\n boundingBox.getSize(this.boundingBoxSize)\n this.boundingBoxLength = this.boundingBoxSize.length()\n }\n\n updateBoundingBox () {\n this._updateBoundingBox()\n if (Debug) this.updateHelper()\n }\n\n getPickingPixels () {\n const {width, height} = this\n\n const n = width * height * 4\n const imgBuffer = SupportsReadPixelsFloat ? new Float32Array(n) : new Uint8Array(n)\n\n this.render(true)\n this.renderer.readRenderTargetPixels(\n this.pickingTarget, 0, 0, width, height, imgBuffer\n )\n\n return imgBuffer\n }\n\n getImage (picking: boolean) {\n return new Promise(resolve => {\n if (picking) {\n const {width, height} = this\n const n = width * height * 4\n let imgBuffer = this.getPickingPixels()\n\n if (SupportsReadPixelsFloat) {\n const imgBuffer2 = new Uint8Array(n)\n for (let i = 0; i < n; ++i) {\n imgBuffer2[ i ] = Math.round(imgBuffer[ i ] * 255)\n }\n imgBuffer = imgBuffer2\n }\n\n const canvas = document.createElement('canvas')\n canvas.width = width\n canvas.height = height\n const ctx = canvas.getContext('2d')! // TODO\n const imgData = ctx.getImageData(0, 0, width, height)\n imgData.data.set(imgBuffer as any) // TODO\n ctx.putImageData(imgData, 0, 0)\n canvas.toBlob(resolve as any, 'image/png') // TODO\n } else {\n this.renderer.domElement.toBlob(resolve as any, 'image/png') // TODO\n }\n })\n }\n\n makeImage (params: Partial = {}) {\n return makeImage(this, params)\n }\n\n setLight (color: Color|number|string, intensity: number, ambientColor: Color|number|string, ambientIntensity: number) {\n const p = this.parameters\n\n if (color !== undefined) p.lightColor.set(color as string) // TODO\n if (intensity !== undefined) p.lightIntensity = intensity\n if (ambientColor !== undefined) p.ambientColor.set(ambientColor as string) // TODO\n if (ambientIntensity !== undefined) p.ambientIntensity = ambientIntensity\n\n this.requestRender()\n }\n\n setFog (color?: Color|number|string, near?: number, far?: number) {\n const p = this.parameters\n\n if (color !== undefined) p.fogColor.set(color as string) // TODO\n if (near !== undefined) p.fogNear = near\n if (far !== undefined) p.fogFar = far\n\n this.requestRender()\n }\n\n setBackground (color?: Color|number|string) {\n const p = this.parameters\n\n if (color) p.backgroundColor.set(color as string) // TODO\n\n this.setFog(p.backgroundColor)\n this.renderer.setClearColor(p.backgroundColor, 0)\n this.renderer.domElement.style.backgroundColor = p.backgroundColor.getStyle()\n\n this.requestRender()\n }\n\n setSampling (level: number) {\n if (level !== undefined) {\n this.parameters.sampleLevel = level\n this.sampleLevel = level\n }\n\n this.requestRender()\n }\n\n /**\n * Set the output color encoding, i.e. how the renderer translates\n * colorspaces as it renders to the screen.\n\n * The default is LinearEncoding, because the internals of NGL are\n * already sRGB so no translation is needed to show sRGB colors.\n * Set to sRGBEncoding to create a linear workflow, and also call\n * `setColorEncoding(LinearEncoding)` to linearize colors on input.\n * @see setColorEncoding\n */\n private setOutputEncoding (encoding: TextureEncoding) {\n this.parameters.rendererEncoding = encoding\n this.renderer.outputEncoding = encoding\n this.pickingTarget.texture.encoding = encoding\n this.sampleTarget.texture.encoding = encoding\n this.holdTarget.texture.encoding = encoding\n }\n\n /**\n * Set the internal color workflow, linear or sRGB.\n * sRGB, the default, is more \"vibrant\" at the cost of accuracy.\n * Linear gives more accurate results, especially for transparent objects.\n * In all cases, the output is always sRGB; this just affects how colors are computed internally.\n * Call this just after creating the viewer, before loading any models.\n */\n setColorWorkflow (encoding: ColorWorkflow) {\n if (encoding != 'linear' && encoding != 'sRGB')\n throw new Error(`setColorWorkflow: invalid color workflow ${encoding}`)\n setColorSpace(encoding == 'linear' ? 'linear' : 'sRGB')\n this.setOutputEncoding(encoding == 'linear' ? sRGBEncoding : LinearEncoding)\n // Note: this doesn't rebuild models, so existing geometry will have\n // the old color encoding.\n this.requestRender()\n }\n\n setCamera (type: CameraType, fov?: number, eyeSep?: number) {\n const p = this.parameters\n\n if (type) p.cameraType = type\n if (fov) p.cameraFov = fov\n if (eyeSep) p.cameraEyeSep = eyeSep\n\n if (p.cameraType === 'orthographic') {\n if (this.camera !== this.orthographicCamera) {\n this.camera = this.orthographicCamera\n this.camera.position.copy(this.perspectiveCamera.position)\n this.camera.up.copy(this.perspectiveCamera.up)\n this.updateZoom()\n }\n } else if (p.cameraType === 'perspective' || p.cameraType === 'stereo') {\n if (this.camera !== this.perspectiveCamera) {\n this.camera = this.perspectiveCamera\n this.camera.position.copy(this.orthographicCamera.position)\n this.camera.up.copy(this.orthographicCamera.up)\n }\n } else {\n throw new Error(`Unknown cameraType '${p.cameraType}'`)\n }\n\n this.perspectiveCamera.fov = p.cameraFov\n this.stereoCamera.eyeSep = p.cameraEyeSep\n this.camera.updateProjectionMatrix()\n\n this.requestRender()\n }\n\n setClip (near: number, far: number, dist: number, clipMode?: string, clipScale?: string) {\n const p = this.parameters\n\n if (near !== undefined) p.clipNear = near\n if (far !== undefined) p.clipFar = far\n if (dist !== undefined) p.clipDist = dist\n if (clipMode !== undefined) p.clipMode = clipMode\n if (clipScale !== undefined) p.clipScale = clipScale\n\n this.requestRender()\n }\n\n setSize (width: number, height: number) {\n this.width = width || 1\n this.height = height || 1\n\n this.perspectiveCamera.aspect = this.width / this.height\n this.orthographicCamera.left = -this.width / 2\n this.orthographicCamera.right = this.width / 2\n this.orthographicCamera.top = this.height / 2\n this.orthographicCamera.bottom = -this.height / 2\n this.camera.updateProjectionMatrix()\n\n const dpr = window.devicePixelRatio\n\n this.renderer.setPixelRatio(dpr)\n this.renderer.setSize(width, height)\n\n const dprWidth = this.width * dpr\n const dprHeight = this.height * dpr\n\n this.pickingTarget.setSize(dprWidth, dprHeight)\n this.sampleTarget.setSize(dprWidth, dprHeight)\n this.holdTarget.setSize(dprWidth, dprHeight)\n\n this.requestRender()\n }\n\n handleResize () {\n if (this.container === document.body) {\n this.setSize(window.innerWidth, window.innerHeight)\n } else {\n const box = this.container.getBoundingClientRect()\n this.setSize(box.width, box.height)\n }\n }\n\n updateInfo (reset?: boolean) {\n const { memory, render } = this.info\n\n if (reset) {\n memory.programs = 0\n memory.geometries = 0\n memory.textures = 0\n\n render.calls = 0\n render.vertices = 0\n render.points = 0\n } else {\n const rInfo = this.renderer.info\n const rMemory = rInfo.memory\n const rRender = rInfo.render\n\n memory.geometries = rMemory.geometries\n memory.textures = rMemory.textures\n\n render.calls += rRender.calls\n render.faces += rRender.triangles\n render.points += rRender.points\n }\n }\n\n animate () {\n this.signals.ticked.dispatch(this.stats)\n const delta = window.performance.now() - this.stats.startTime\n\n if (delta > 500 && !this.isStill && this.sampleLevel < 3 && this.sampleLevel !== -1) {\n const currentSampleLevel = this.sampleLevel\n this.sampleLevel = 3\n this.renderPending = true\n this.render()\n this.isStill = true\n this.sampleLevel = currentSampleLevel\n if (Debug) Log.log('rendered still frame')\n }\n\n this.frameRequest = window.requestAnimationFrame(this.animate)\n }\n\n pick (x: number, y: number) {\n if (this.parameters.cameraType === 'stereo') {\n // TODO picking broken for stereo camera\n return {\n 'pid': 0,\n 'instance': undefined,\n 'picker': undefined\n }\n }\n\n x *= window.devicePixelRatio\n y *= window.devicePixelRatio\n\n x = Math.max(x - 2, 0)\n y = Math.max(y - 2, 0)\n\n let pid = 0, instance, picker\n const pixelBuffer = SupportsReadPixelsFloat ? pixelBufferFloat : pixelBufferUint\n\n this.render(true)\n this.renderer.readRenderTargetPixels(\n this.pickingTarget, x, y, 5, 5, pixelBuffer\n )\n\n for (let i = 0; i < pixelOrder.length; i++) {\n\n const offset = pixelOrder[i] * 4\n\n const oid = Math.round(pixelBuffer[ offset + 3 ])\n const object = this.pickingGroup.getObjectById(oid)\n if (object) {\n instance = object.userData.instance\n picker = object.userData.buffer.picking\n } else {\n continue\n }\n\n if (SupportsReadPixelsFloat) {\n pid =\n ((Math.round(pixelBuffer[offset] * 255) << 16) & 0xFF0000) |\n ((Math.round(pixelBuffer[offset + 1] * 255) << 8) & 0x00FF00) |\n ((Math.round(pixelBuffer[offset + 2] * 255)) & 0x0000FF)\n } else {\n pid =\n (pixelBuffer[offset] << 16) |\n (pixelBuffer[offset + 1] << 8) |\n (pixelBuffer[offset + 2])\n }\n }\n // if( Debug ){\n // const rgba = Array.apply( [], pixelBuffer );\n // Log.log( pixelBuffer );\n // Log.log(\n // \"picked color\",\n // rgba.map( c => { return c.toPrecision( 2 ) } )\n // );\n // Log.log( \"picked pid\", pid );\n // Log.log( \"picked oid\", oid );\n // Log.log( \"picked object\", object );\n // Log.log( \"picked instance\", instance );\n // Log.log( \"picked position\", x, y );\n // Log.log( \"devicePixelRatio\", window.devicePixelRatio );\n // }\n\n return { pid, instance, picker }\n }\n\n requestRender () {\n if (this.renderPending) {\n // Log.info(\"there is still a 'render' call pending\")\n return\n }\n\n // start gathering stats anew after inactivity\n if (window.performance.now() - this.stats.startTime > 22) {\n this.stats.begin()\n this.isStill = false\n }\n\n this.renderPending = true\n\n window.requestAnimationFrame(() => {\n this.render()\n this.stats.update()\n })\n }\n\n updateZoom () {\n const fov = degToRad(this.perspectiveCamera.fov)\n const height = 2 * Math.tan(fov / 2) * this.cameraDistance\n this.orthographicCamera.zoom = this.height / height\n }\n\n /**\n * Convert an absolute clip value to a relative one using bRadius.\n *\n * 0.0 -> 50.0\n * bRadius -> 0.0\n */\n absoluteToRelative (d: number) :number {\n return 50 * (1 - d / this.bRadius)\n }\n\n /**\n * Convert a relative clip value to an absolute one using bRadius\n *\n * 0.0 -> bRadius\n * 50.0 -> 0.0\n */\n relativeToAbsolute (d: number) : number {\n return this.bRadius * (1 - d / 50)\n }\n\n /**\n * Intepret clipMode, clipScale and set the camera and fog clipping.\n * Also ensures bRadius and cDist are valid\n */\n private __updateClipping () {\n const p = this.parameters\n\n // bRadius must always be updated for material-based clipping\n // and for focus calculations\n this.bRadius = Math.max(10, this.boundingBoxLength * 0.5)\n\n // FL: Removed below, but leaving commented as I don't understand intention\n // this.bRadius += this.boundingBox.getCenter(this.distVector).length()\n\n if (!isFinite(this.bRadius)) {\n this.bRadius = 50\n }\n\n this.camera.getWorldPosition(this.distVector)\n this.cDist = this.distVector.length()\n if (!this.cDist) {\n // recover from a broken (NaN) camera position\n this.cameraDistance = Math.abs(p.cameraZ)\n this.cDist = Math.abs(p.cameraZ)\n }\n\n // fog\n const fog = this.scene.fog as Fog\n fog.color.set(p.fogColor)\n\n if (p.clipMode === 'camera') {\n // Always interpret clipScale as absolute for clipMode camera\n\n this.camera.near = p.clipNear\n this.camera.far = p.clipFar\n fog.near = p.fogNear\n fog.far = p.fogFar\n\n } else {\n // scene mode\n\n if (p.clipScale === 'absolute') {\n // absolute scene mode; offset clip planes from scene center\n // (note: positive values move near plane towards camera and rear plane away)\n\n this.camera.near = this.cDist - p.clipNear\n this.camera.far = this.cDist + p.clipFar\n fog.near = this.cDist - p.fogNear\n fog.far = this.cDist + p.fogFar\n\n } else {\n // relative scene mode (default): convert pecentages to Angstroms\n\n const nearFactor = (50 - p.clipNear) / 50\n const farFactor = -(50 - p.clipFar) / 50\n this.camera.near = this.cDist - (this.bRadius * nearFactor)\n this.camera.far = this.cDist + (this.bRadius * farFactor)\n\n const fogNearFactor = (50 - p.fogNear) / 50\n const fogFarFactor = -(50 - p.fogFar) / 50\n fog.near = this.cDist - (this.bRadius * fogNearFactor)\n fog.far = this.cDist + (this.bRadius * fogFarFactor)\n }\n }\n\n if (p.clipMode !== 'camera') {\n\n if (this.camera.type === 'PerspectiveCamera') {\n\n this.camera.near = Math.max(0.1, p.clipDist, this.camera.near)\n this.camera.far = Math.max(1, this.camera.far)\n fog.near = Math.max(0.1, fog.near)\n fog.far = Math.max(1, fog.far)\n } else if (this.camera.type === 'OrthographicCamera') {\n\n if (p.clipDist > 0) {\n this.camera.near = Math.max(p.clipDist, this.camera.near)\n }\n }\n }\n }\n\n private __updateCamera () {\n const camera = this.camera\n camera.updateMatrix()\n camera.updateMatrixWorld(true)\n camera.updateProjectionMatrix()\n\n updateMaterialUniforms(this.scene, camera, this.renderer, this.cDist, this.bRadius)\n sortProjectedPosition(this.scene, camera)\n }\n\n private __setVisibility (model: boolean, picking: boolean, background: boolean, helper: boolean) {\n this.modelGroup.visible = model\n this.pickingGroup.visible = picking\n this.backgroundGroup.visible = background\n this.helperGroup.visible = helper\n }\n\n private __updateLights () {\n this.spotLight.color.set(this.parameters.lightColor)\n this.spotLight.intensity = this.parameters.lightIntensity\n\n this.distVector.copy(this.camera.position).setLength(this.boundingBoxLength * 100)\n this.spotLight.position.copy(this.camera.position).add(this.distVector)\n\n this.ambientLight.color.set(this.parameters.ambientColor)\n this.ambientLight.intensity = this.parameters.ambientIntensity\n }\n\n private __renderPickingGroup (camera: PerspectiveCamera|OrthographicCamera) {\n this.renderer.setRenderTarget(this.pickingTarget || null)\n this.renderer.clear()\n this.__setVisibility(false, true, false, false)\n this.renderer.render(this.scene, camera)\n // back to standard render target\n this.renderer.setRenderTarget(null)\n this.updateInfo()\n\n // if (Debug) {\n // this.__setVisibility(false, true, false, true);\n\n // this.renderer.clear();\n // this.renderer.render(this.scene, camera);\n // }\n }\n\n private __renderModelGroup (camera: PerspectiveCamera|OrthographicCamera, renderTarget?: WebGLRenderTarget) {\n this.renderer.setRenderTarget(renderTarget || null)\n this.renderer.clear()\n this.__setVisibility(false, false, true, false)\n this.renderer.render(this.scene, camera)\n this.renderer.clear(false, true, true)\n this.updateInfo()\n\n this.__setVisibility(true, false, false, Debug)\n this.renderer.render(this.scene, camera)\n this.renderer.setRenderTarget(null) // set back to default canvas\n this.updateInfo()\n }\n\n private __renderSuperSample (camera: PerspectiveCamera|OrthographicCamera, renderTarget?: WebGLRenderTarget) {\n // based on the Supersample Anti-Aliasing Render Pass\n // contributed to three.js by bhouston / http://clara.io/\n //\n // This manual approach to SSAA re-renders the scene ones for\n // each sample with camera jitter and accumulates the results.\n // References: https://en.wikipedia.org/wiki/Supersampling\n const offsetList = JitterVectors[ Math.max(0, Math.min(this.sampleLevel, 5)) ]\n\n const baseSampleWeight = 1.0 / offsetList.length\n const roundingRange = 1 / 32\n\n this.compositeUniforms.tForeground.value = this.sampleTarget.texture\n\n let width = this.sampleTarget.width\n const height = this.sampleTarget.height\n if (this.parameters.cameraType === 'stereo') {\n width /= 2\n }\n\n // render the scene multiple times, each slightly jitter offset\n // from the last and accumulate the results.\n for (let i = 0; i < offsetList.length; ++i) {\n const offset = offsetList[ i ]\n camera.setViewOffset(\n width, height, offset[ 0 ], offset[ 1 ], width, height\n )\n camera.updateProjectionMatrix()\n updateCameraUniforms(this.scene, camera)\n\n let sampleWeight = baseSampleWeight\n // the theory is that equal weights for each sample lead to an\n // accumulation of rounding errors.\n // The following equation varies the sampleWeight per sample\n // so that it is uniformly distributed across a range of values\n // whose rounding errors cancel each other out.\n const uniformCenteredDistribution = -0.5 + (i + 0.5) / offsetList.length\n sampleWeight += roundingRange * uniformCenteredDistribution\n this.compositeUniforms.scale.value = sampleWeight\n\n this.__renderModelGroup(camera, this.sampleTarget)\n this.renderer.setRenderTarget(this.holdTarget)\n if (i === 0) {\n this.renderer.clear()\n }\n\n this.renderer.render(this.compositeScene, this.compositeCamera)\n }\n\n this.compositeUniforms.scale.value = 1.0\n this.compositeUniforms.tForeground.value = this.holdTarget.texture\n\n camera.clearViewOffset()\n this.renderer.setRenderTarget(renderTarget || null)\n this.renderer.clear()\n this.renderer.render(this.compositeScene, this.compositeCamera)\n }\n\n private __renderStereo (picking = false, _renderTarget?: WebGLRenderTarget) {\n const stereoCamera = this.stereoCamera\n stereoCamera.update(this.perspectiveCamera);\n\n const renderer = this.renderer\n let size = new Vector2()\n renderer.getSize(size)\n\n renderer.setScissorTest(true)\n\n renderer.setScissor(0, 0, size.width / 2, size.height)\n renderer.setViewport(0, 0, size.width / 2, size.height)\n updateCameraUniforms(this.scene, stereoCamera.cameraL)\n this.__render(picking, stereoCamera.cameraL)\n\n renderer.setScissor(size.width / 2, 0, size.width / 2, size.height)\n renderer.setViewport(size.width / 2, 0, size.width / 2, size.height)\n updateCameraUniforms(this.scene, stereoCamera.cameraR)\n this.__render(picking, stereoCamera.cameraR)\n\n renderer.setScissorTest(false)\n renderer.setViewport(0, 0, size.width, size.height)\n }\n\n private __render(picking = false, camera: PerspectiveCamera|OrthographicCamera, renderTarget?: WebGLRenderTarget) {\n if (picking) {\n if (!this.lastRenderedPicking) this.__renderPickingGroup(camera)\n } else if (this.sampleLevel > 0 && this.parameters.cameraType !== 'stereo') {\n // TODO super sample broken for stereo camera\n this.__renderSuperSample(camera, renderTarget)\n } else {\n this.__renderModelGroup(camera, renderTarget)\n }\n }\n\n render (picking = false, renderTarget?: WebGLRenderTarget) {\n if (this.rendering) {\n Log.warn(\"'tried to call 'render' from within 'render'\")\n return\n }\n\n // Log.time('Viewer.render')\n\n this.rendering = true\n\n try {\n this.__updateClipping()\n this.__updateCamera()\n this.__updateLights()\n this.updateInfo(true)\n\n // render\n if (this.parameters.cameraType === 'stereo') {\n this.__renderStereo(picking, renderTarget)\n } else {\n this.__render(picking, this.camera, renderTarget)\n }\n this.lastRenderedPicking = picking\n } finally {\n this.rendering = false\n this.renderPending = false\n }\n this.signals.rendered.dispatch()\n\n // Log.timeEnd('Viewer.render')\n // Log.log(this.info.memory, this.info.render)\n }\n\n clear () {\n Log.log('scene cleared')\n this.scene.remove(this.rotationGroup)\n this._initScene()\n this.renderer.clear()\n }\n\n dispose () {\n this.renderer.dispose()\n window.cancelAnimationFrame(this.frameRequest)\n }\n}\n","/**\n * @file Mouse Observer\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector2 } from 'three'\nimport { Signal } from 'signals'\n\nimport { LeftMouseButton, RightMouseButton } from '../constants'\nimport { defaults } from '../utils'\nimport Viewer from '../viewer/viewer'\nimport MouseControls from '../controls/mouse-controls'\n\ntype Optional = Pick, K> & Omit;\n\n/**\n * @example\n * mouseObserver.signals.scrolled.add( function( delta ){ ... } );\n *\n * @typedef {Object} MouseSignals\n * @property {Signal} moved - on move: deltaX, deltaY\n * @property {Signal} scrolled - on scroll: delta\n * @property {Signal} dragged - on drag: deltaX, deltaY\n * @property {Signal} dropped - on drop\n * @property {Signal} clicked - on click\n * @property {Signal} hovered - on hover\n */\n\nfunction getTouchDistance (event: TouchEvent) {\n const dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX\n const dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY\n return Math.sqrt(dx * dx + dy * dy)\n}\n\nfunction getMouseButtons (event: MouseEvent) {\n if (typeof event === 'object') {\n if ('buttons' in event) {\n return event.buttons\n } else if ('which' in event as any) {\n const b = (event as any).which\n if (b === 2) {\n return 4\n } else if (b === 3) {\n return 2\n } else if (b > 0) {\n return 1 << (b - 1)\n }\n } else if ('button' in event as any) {\n const b = (event as any).button\n if (b === 1) {\n return 4\n } else if (b === 2) {\n return 2\n } else if (b >= 0) {\n return 1 << b\n }\n }\n }\n return 0\n}\n\nexport interface MouseSignals {\n moved: Signal // on move: deltaX, deltaY\n scrolled: Signal // on scroll: delta\n dragged: Signal // on drag: deltaX, deltaY\n dropped: Signal // on drop\n clicked: Signal // on click\n hovered: Signal // on hover\n doubleClicked: Signal\n}\n\nexport interface MouseParams {\n hoverTimeout?: number\n handleScroll?:boolean\n doubleClickSpeed?: number\n}\n\n/**\n * Mouse observer\n *\n * @example\n * // listen to mouse moving (and touch-moving) events\n * mouseObserver.moved.moved.add( function( deltaX, deltaY ){ ... } );\n *\n * @example\n * // listen to scrolling (and pinching) events\n * mouseObserver.signals.scrolled.add( function( delta ){ ... } );\n *\n * @example\n * // listen to dragging (and touch-dragging) events\n * mouseObserver.signals.dragged.add( function( deltaX, deltaY ){ ... } );\n *\n * @example\n * // listen to clicking (and tapping) events\n * mouseObserver.signals.clicked.add( function(){ ... } );\n *\n * @example\n * // listen to double clicking (and double tapping) events\n * mouseObserver.signals.doubleClicked.add( function(){ ... } );\n *\n * @example\n * // listen to hovering events\n * mouseObserver.signals.hovered.add( function(){ ... } );\n */\nclass MouseObserver {\n signals: MouseSignals = {\n moved: new Signal(),\n scrolled: new Signal(),\n dragged: new Signal(),\n dropped: new Signal(),\n clicked: new Signal(),\n hovered: new Signal(),\n doubleClicked: new Signal()\n }\n\n hoverTimeout: number\n handleScroll:boolean\n doubleClickSpeed: number\n\n viewer: Viewer\n mouse: MouseObserver\n controls: MouseControls\n\n position = new Vector2() // Position on page\n prevPosition = new Vector2() // Previous position on page\n down = new Vector2() // Position on page when clicked\n canvasPosition = new Vector2() // Position on dom element\n prevClickCP = new Vector2()\n\n moving = false // Flag indicating if the mouse is moving\n hovering = true // Flag indicating if the mouse is hovering\n scrolled = false // Flag indicating if there was a scolling event since the last mouse move\n lastMoved = Infinity // Timestamp of last mouse move\n which? = 0 // 0: No button; 1: Left button; 2: Middle button; 3: Right button\n buttons? = 0 // 0: No button; 1: Left button; 2: Right button; 4: Middle button\n pressed? = false // Flag indicating if the mouse is pressed down\n altKey = false // Flag indicating if the alt key is pressed\n ctrlKey = false // Flag indicating if the ctrl key is pressed\n metaKey = false // Flag indicating if the meta key is pressed\n shiftKey = false // Flag indicating if the shift key is pressed\n\n doubleClickPending: boolean\n lastClicked: number\n overElement: boolean\n lastTouchDistance: number\n private frameRequest: number\n\n /**\n * @param {Element} domElement - the dom element to observe mouse events in\n * @param {Object} params - parameters object\n * @param {Integer} params.hoverTimeout - timeout in ms until the {@link MouseSignals.hovered}\n * signal is fired, set to -1 to ignore hovering\n * @param {Boolean} params.handleScroll - whether or not to handle scroll events\n * @param {Integer} params.doubleClickSpeed - max time in ms to trigger double click\n */\n constructor (readonly domElement: HTMLCanvasElement, params: MouseParams = {}) {\n this.domElement.style.touchAction = 'none'\n\n this.hoverTimeout = defaults(params.hoverTimeout, 50)\n this.handleScroll = defaults(params.handleScroll, true)\n this.doubleClickSpeed = defaults(params.doubleClickSpeed, 500)\n\n this._listen = this._listen.bind(this)\n this._onMousewheel = this._onMousewheel.bind(this)\n this._onMousemove = this._onMousemove.bind(this)\n this._onMousedown = this._onMousedown.bind(this)\n this._onMouseup = this._onMouseup.bind(this)\n this._onContextmenu = this._onContextmenu.bind(this)\n this._onTouchstart = this._onTouchstart.bind(this)\n this._onTouchend = this._onTouchend.bind(this)\n this._onTouchmove = this._onTouchmove.bind(this)\n\n this._listen()\n\n const opt = { passive: false } // treat as 'passive' so preventDefault can be called\n document.addEventListener('mousewheel', this._onMousewheel, opt)\n document.addEventListener('wheel', this._onMousewheel, opt)\n document.addEventListener('MozMousePixelScroll', this._onMousewheel, opt)\n document.addEventListener('mousemove', this._onMousemove, opt)\n document.addEventListener('mousedown', this._onMousedown, opt)\n document.addEventListener('mouseup', this._onMouseup, opt)\n document.addEventListener('contextmenu', this._onContextmenu, opt)\n document.addEventListener('touchstart', this._onTouchstart, opt)\n document.addEventListener('touchend', this._onTouchend, opt)\n document.addEventListener('touchmove', this._onTouchmove, opt)\n }\n\n get key () {\n let key = 0\n if (this.altKey) key += 1\n if (this.ctrlKey) key += 2\n if (this.metaKey) key += 4\n if (this.shiftKey) key += 8\n return key\n }\n\n setParameters (params: MouseParams = {}) {\n this.hoverTimeout = defaults(params.hoverTimeout, this.hoverTimeout)\n }\n\n /**\n * listen to mouse actions\n * @emits {MouseSignals.clicked} when clicked\n * @emits {MouseSignals.hovered} when hovered\n * @return {undefined}\n */\n _listen () {\n const now = window.performance.now()\n const cp = this.canvasPosition\n if (this.doubleClickPending && now - this.lastClicked > this.doubleClickSpeed) {\n this.doubleClickPending = false\n }\n if (now - this.lastMoved > this.hoverTimeout) {\n this.moving = false\n }\n if (this.scrolled || (!this.moving && !this.hovering)) {\n this.scrolled = false\n if (this.hoverTimeout !== -1 && this.overElement) {\n this.hovering = true\n this.signals.hovered.dispatch(cp.x, cp.y)\n }\n }\n this.frameRequest = window.requestAnimationFrame(this._listen)\n }\n\n /**\n * handle mouse scroll\n * @emits {MouseSignals.scrolled} when scrolled\n * @param {Event} event - mouse event\n * @return {undefined}\n */\n _onMousewheel(event: Optional & { wheelDelta?: number, wheelDeltaY?: number }) {\n if (event.target !== this.domElement || !this.handleScroll) {\n return\n }\n event.preventDefault()\n this._setKeys(event as any)\n\n let delta = 0\n // This has to be written in a particular way to handle old browsers that\n // all send events with different properties set in different ways.\n if ('deltaY' in event && 'deltaMode' in event &&\n event.deltaY !== undefined && event.deltaMode !== undefined) {\n // all modern browsers, using WheelEvent; deltaY + down (toward user)\n if (event.deltaMode === WheelEvent.DOM_DELTA_PIXEL)\n // everything except Firefox: normally 100 per wheel click\n delta = -event.deltaY * (2.5 / 100.0)\n else if (event.deltaMode === WheelEvent.DOM_DELTA_LINE)\n // Firefox in line mode, normally 3 per wheel click\n delta = -event.deltaY * (2.5 / 3.0)\n else // page mode: 1 per wheel click\n delta = -event.deltaY * 2.5\n } else if ('deltaY' in event && !('detail' in event)) {\n // Old Firefox or IE 11: deltaY but no deltaMode; treat as pixels\n delta = -event.deltaY * (2.5 / 100.0)\n } else if (event.wheelDelta !== undefined) {\n delta = -event.wheelDelta * (2.5 / 100)\n } else if (event.wheelDeltaY !== undefined) {\n delta = -event.wheelDeltaY * (2.5 / 100)\n } else if (event.detail !== undefined){\n // Old Firefox, MouseWheelEvent\n delta = -event.detail / 3\n }\n this.signals.scrolled.dispatch(delta)\n\n setTimeout(() => {\n this.scrolled = true\n }, this.hoverTimeout)\n }\n\n /**\n * handle mouse move\n * @emits {MouseSignals.moved} when moved\n * @emits {MouseSignals.dragged} when dragged\n * @param {Event} event - mouse event\n * @return {undefined}\n */\n _onMousemove (event: MouseEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n this.overElement = true\n } else {\n this.overElement = false\n }\n this._setKeys(event)\n this.moving = true\n this.hovering = false\n this.lastMoved = window.performance.now()\n this.prevPosition.copy(this.position)\n this.position.set(event.clientX, event.clientY)\n this._setCanvasPosition(event)\n const dx = this.prevPosition.x - this.position.x\n const dy = this.prevPosition.y - this.position.y\n this.signals.moved.dispatch(dx, dy)\n if (this.pressed) {\n this.signals.dragged.dispatch(dx, dy)\n }\n }\n\n _onMousedown (event: MouseEvent) {\n if (event.target !== this.domElement) {\n return\n }\n event.preventDefault()\n this._setKeys(event)\n this.moving = false\n this.hovering = false\n this.down.set(event.clientX, event.clientY)\n this.position.set(event.clientX, event.clientY)\n this.which = event.which\n this.buttons = getMouseButtons(event)\n this.pressed = true\n this._setCanvasPosition(event)\n }\n\n /**\n * handle mouse up\n * @emits {MouseSignals.doubleClicked} when double clicked\n * @emits {MouseSignals.dropped} when dropped\n * @param {Event} event - mouse event\n * @return {undefined}\n */\n _onMouseup (event: MouseEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n }\n this._setKeys(event)\n const cp = this.canvasPosition\n if (this._distance() < 4) {\n this.lastClicked = window.performance.now()\n if (this.doubleClickPending && this.prevClickCP.distanceTo(cp) < 4) {\n this.signals.doubleClicked.dispatch(cp.x, cp.y)\n this.doubleClickPending = false\n }\n this.signals.clicked.dispatch(cp.x, cp.y)\n this.doubleClickPending = true\n this.prevClickCP.copy(cp)\n }\n this.which = undefined\n this.buttons = undefined\n this.pressed = undefined\n // if (this._distance() > 3 || event.which === RightMouseButton) {\n // this.signals.dropped.dispatch();\n // }\n }\n\n _onContextmenu (event: MouseEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n }\n }\n\n _onTouchstart (event: TouchEvent) {\n if (event.target !== this.domElement) {\n return\n }\n event.preventDefault()\n this.pressed = true\n switch (event.touches.length) {\n case 1: {\n this.moving = false\n this.hovering = false\n this.down.set(\n event.touches[ 0 ].pageX,\n event.touches[ 0 ].pageY\n )\n this.position.set(\n event.touches[ 0 ].pageX,\n event.touches[ 0 ].pageY\n )\n this._setCanvasPosition(event.touches[ 0 ])\n break\n }\n\n case 2: {\n this.down.set(\n (event.touches[ 0 ].pageX + event.touches[ 1 ].pageX) / 2,\n (event.touches[ 0 ].pageY + event.touches[ 1 ].pageY) / 2\n )\n this.position.set(\n (event.touches[ 0 ].pageX + event.touches[ 1 ].pageX) / 2,\n (event.touches[ 0 ].pageY + event.touches[ 1 ].pageY) / 2\n )\n this.lastTouchDistance = getTouchDistance(event)\n }\n }\n }\n\n _onTouchend (event: TouchEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n }\n this.which = undefined\n this.buttons = undefined\n this.pressed = undefined\n }\n\n _onTouchmove (event: TouchEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n this.overElement = true\n } else {\n this.overElement = false\n }\n switch (event.touches.length) {\n case 1: {\n this._setKeys(event)\n this.which = LeftMouseButton\n this.buttons = 1\n this.moving = true\n this.hovering = false\n this.lastMoved = window.performance.now()\n this.prevPosition.copy(this.position)\n this.position.set(\n event.touches[ 0 ].pageX,\n event.touches[ 0 ].pageY\n )\n this._setCanvasPosition(event.touches[ 0 ])\n const dx = this.prevPosition.x - this.position.x\n const dy = this.prevPosition.y - this.position.y\n this.signals.moved.dispatch(dx, dy)\n if (this.pressed) {\n this.signals.dragged.dispatch(dx, dy)\n }\n break\n }\n\n case 2: {\n const touchDistance = getTouchDistance(event)\n const delta = touchDistance - this.lastTouchDistance\n this.lastTouchDistance = touchDistance\n this.prevPosition.copy(this.position)\n this.position.set(\n (event.touches[ 0 ].pageX + event.touches[ 1 ].pageX) / 2,\n (event.touches[ 0 ].pageY + event.touches[ 1 ].pageY) / 2\n )\n if (Math.abs(delta) > 2 && this.handleScroll &&\n this.position.distanceTo(this.prevPosition) < 2\n ) {\n this.which = 0\n this.buttons = 0\n this.signals.scrolled.dispatch(delta / 2)\n } else {\n this.which = RightMouseButton\n this.buttons = 2\n const dx = this.prevPosition.x - this.position.x\n const dy = this.prevPosition.y - this.position.y\n this.signals.moved.dispatch(dx, dy)\n if (this.pressed) {\n this.signals.dragged.dispatch(dx, dy)\n }\n }\n }\n }\n }\n\n _distance () {\n return this.position.distanceTo(this.down)\n }\n\n _setCanvasPosition (event: any) { // TODO\n const box = this.domElement.getBoundingClientRect()\n let offsetX, offsetY;\n if ('clientX' in event && 'clientY' in event) {\n offsetX = event.clientX - box.left\n offsetY = event.clientY - box.top\n } else {\n offsetX = event.offsetX\n offsetY = event.offsetY\n }\n this.canvasPosition.set(offsetX, box.height - offsetY)\n }\n\n _setKeys (event: MouseEvent|TouchEvent) {\n this.altKey = event.altKey\n this.ctrlKey = event.ctrlKey\n this.metaKey = event.metaKey\n this.shiftKey = event.shiftKey\n }\n\n dispose () {\n document.removeEventListener('mousewheel', this._onMousewheel)\n document.removeEventListener('wheel', this._onMousewheel)\n document.removeEventListener('MozMousePixelScroll', this._onMousewheel)\n document.removeEventListener('mousemove', this._onMousemove)\n document.removeEventListener('mousedown', this._onMousedown)\n document.removeEventListener('mouseup', this._onMouseup)\n document.removeEventListener('contextmenu', this._onContextmenu)\n document.removeEventListener('touchstart', this._onTouchstart)\n document.removeEventListener('touchend', this._onTouchend)\n document.removeEventListener('touchmove', this._onTouchmove)\n window.cancelAnimationFrame(this.frameRequest)\n }\n}\n\nexport default MouseObserver\n","/**\n * @file Constants\n * @author Alexander Rose \n * @private\n */\n\nexport const LeftMouseButton = 1\nexport const MiddleMouseButton = 2\nexport const RightMouseButton = 3\n","/**\n * @file Trackball Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4, Quaternion } from 'three'\n\nimport { defaults } from '../utils'\nimport Stage from '../stage/stage'\nimport MouseObserver from '../stage/mouse-observer'\nimport Viewer from '../viewer/viewer'\nimport ViewerControls from './viewer-controls'\nimport AtomProxy from '../proxy/atom-proxy';\nimport Component from '../component/component';\n\nconst tmpRotateXMatrix = new Matrix4()\nconst tmpRotateYMatrix = new Matrix4()\nconst tmpRotateZMatrix = new Matrix4()\nconst tmpRotateMatrix = new Matrix4()\nconst tmpRotateCameraMatrix = new Matrix4()\nconst tmpRotateVector = new Vector3()\nconst tmpRotateQuaternion = new Quaternion()\nconst tmpRotateQuaternion2 = new Quaternion()\nconst tmpPanMatrix = new Matrix4()\nconst tmpPanVector = new Vector3()\nconst tmpAtomVector = new Vector3()\n\nexport interface TrackballControlsParams {\n rotateSpeed?: number\n zoomSpeed?: number\n panSpeed?: number\n}\n\n/**\n * Trackball controls\n */\nclass TrackballControls {\n viewer: Viewer\n mouse: MouseObserver\n controls: ViewerControls\n\n rotateSpeed: number\n zoomSpeed: number\n panSpeed: number\n\n constructor (readonly stage: Stage, params: TrackballControlsParams = {}) {\n this.rotateSpeed = defaults(params.rotateSpeed, 2.0)\n this.zoomSpeed = defaults(params.zoomSpeed, 1.2)\n this.panSpeed = defaults(params.panSpeed, 1.0)\n\n this.viewer = stage.viewer\n this.mouse = stage.mouseObserver\n this.controls = stage.viewerControls\n }\n\n get component (): Component|undefined {\n return this.stage.transformComponent\n }\n\n get atom (): AtomProxy|undefined {\n return this.stage.transformAtom\n }\n\n private _setPanVector (x: number, y: number, z = 0) {\n const scaleFactor = this.controls.getCanvasScaleFactor(z)\n tmpPanVector.set(x, y, 0)\n tmpPanVector.multiplyScalar(this.panSpeed * scaleFactor)\n }\n\n private _getRotateXY (x: number, y: number) {\n return [\n this.rotateSpeed * -x * 0.01,\n this.rotateSpeed * y * 0.01\n ]\n }\n\n private _getCameraRotation(m: Matrix4) {\n m.extractRotation(this.viewer.camera.matrixWorld)\n m.multiply(tmpRotateYMatrix.makeRotationY(Math.PI))\n\n return m\n }\n\n private _transformPanVector () {\n if (!this.component) return\n\n // Adjust for component and scene rotation\n tmpPanMatrix.extractRotation(this.component.transform)\n tmpPanMatrix.premultiply(this.viewer.rotationGroup.matrix)\n tmpPanMatrix.getInverse(tmpPanMatrix)\n\n // Adjust for camera rotation\n tmpPanMatrix.multiply(this._getCameraRotation(tmpRotateMatrix))\n\n tmpPanVector.applyMatrix4(tmpPanMatrix)\n }\n\n zoom (delta: number) {\n this.controls.zoom(this.zoomSpeed * delta * 0.02)\n }\n\n pan (x: number, y: number) {\n this._setPanVector(x, y)\n\n // Adjust for scene rotation\n tmpPanMatrix.getInverse(this.viewer.rotationGroup.matrix)\n\n // Adjust for camera rotation\n tmpPanMatrix.multiply(this._getCameraRotation(tmpRotateMatrix))\n\n tmpPanVector.applyMatrix4(tmpPanMatrix)\n this.controls.translate(tmpPanVector)\n }\n\n panComponent (x: number, y: number) {\n if (!this.component) return\n\n this._setPanVector(x, y)\n this._transformPanVector()\n\n this.component.position.add(tmpPanVector)\n this.component.updateMatrix()\n }\n\n panAtom (x: number, y: number) {\n if (!this.atom || !this.component) return\n\n this.atom.positionToVector3(tmpAtomVector)\n tmpAtomVector.add(this.viewer.translationGroup.position)\n tmpAtomVector.applyMatrix4(this.viewer.rotationGroup.matrix)\n\n this._setPanVector(x, y, tmpAtomVector.z)\n this._transformPanVector()\n\n this.atom.positionAdd(tmpPanVector)\n this.component.updateRepresentations({ 'position': true })\n }\n\n rotate (x: number, y: number) {\n const [ dx, dy ] = this._getRotateXY(x, y)\n\n // rotate around screen X then screen Y\n this._getCameraRotation(tmpRotateMatrix)\n tmpRotateVector.set(1, 0, 0) // X axis\n tmpRotateVector.applyMatrix4(tmpRotateMatrix) // screen X\n tmpRotateQuaternion.setFromAxisAngle(tmpRotateVector, dy)\n\n tmpRotateVector.set(0, 1, 0) // Y axis\n tmpRotateVector.applyMatrix4(tmpRotateMatrix) // screen Y\n tmpRotateQuaternion2.setFromAxisAngle(tmpRotateVector, dx)\n\n tmpRotateQuaternion.multiply(tmpRotateQuaternion2)\n tmpRotateMatrix.makeRotationFromQuaternion(tmpRotateQuaternion)\n this.controls.applyMatrix(tmpRotateMatrix)\n }\n\n zRotate (x: number, y: number) {\n const dz = this.rotateSpeed * ((-x + y) / -2) * 0.01\n\n tmpRotateZMatrix.makeRotationZ(dz)\n this.controls.applyMatrix(tmpRotateZMatrix)\n }\n\n rotateComponent (x: number, y: number) {\n if (!this.component) return\n\n const [ dx, dy ] = this._getRotateXY(x, y)\n\n this._getCameraRotation(tmpRotateCameraMatrix)\n\n tmpRotateMatrix.extractRotation(this.component.transform)\n tmpRotateMatrix.premultiply(this.viewer.rotationGroup.matrix)\n tmpRotateMatrix.getInverse(tmpRotateMatrix)\n tmpRotateMatrix.premultiply(tmpRotateCameraMatrix)\n\n tmpRotateVector.set(1, 0, 0)\n tmpRotateVector.applyMatrix4(tmpRotateMatrix)\n tmpRotateXMatrix.makeRotationAxis(tmpRotateVector, dy)\n\n tmpRotateVector.set(0, 1, 0)\n tmpRotateVector.applyMatrix4(tmpRotateMatrix)\n tmpRotateYMatrix.makeRotationAxis(tmpRotateVector, dx)\n\n tmpRotateXMatrix.multiply(tmpRotateYMatrix)\n tmpRotateQuaternion.setFromRotationMatrix(tmpRotateXMatrix)\n this.component.quaternion.premultiply(tmpRotateQuaternion)\n this.component.quaternion.normalize()\n this.component.updateMatrix()\n }\n}\n\nexport default TrackballControls\n","/**\n * @file Picking Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4, Vector2 } from 'three'\n\nimport Stage from '../stage/stage'\nimport StructureComponent from '../component/structure-component'\nimport MouseObserver from '../stage/mouse-observer'\nimport { Picker } from '../utils/picker'\nimport ViewerControls from './viewer-controls'\nimport Shape from '../geometry/shape'\nimport Structure from '../structure/structure'\nimport BondProxy from '../proxy/bond-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Surface from '../surface/surface'\nimport Volume from '../surface/volume'\nimport Unitcell from '../symmetry/unitcell'\nimport Component from '../component/component';\n\nconst tmpVec = new Vector3()\n\nexport interface ShapePrimitive {\n name: string\n shape: Shape\n}\n\nfunction closer (x: Vector3, a: Vector3, b: Vector3) {\n return x.distanceTo(a) < x.distanceTo(b)\n}\n\n/**\n * Picking data object.\n * @typedef {Object} PickingData - picking data\n * @property {Number} [pid] - picking id\n * @property {Object} [instance] - instance data\n * @property {Integer} instance.id - instance id\n * @property {String|Integer} instance.name - instance name\n * @property {Matrix4} instance.matrix - transformation matrix of the instance\n * @property {Picker} [picker] - picker object\n */\n\nexport interface InstanceData {\n id: number\n name: number|string\n matrix: Matrix4\n}\n\nexport interface PickingData {\n pid: number\n instance: InstanceData\n picker: Picker\n}\n\n/**\n * Picking proxy class.\n */\nclass PickingProxy {\n pid: number\n picker: Picker\n instance: InstanceData\n controls: ViewerControls\n mouse: MouseObserver\n\n /**\n * Create picking proxy object\n * @param {PickingData} pickingData - picking data\n * @param {Stage} stage - stage object\n */\n constructor (pickingData: PickingData, readonly stage: Stage) {\n this.pid = pickingData.pid\n this.picker = pickingData.picker\n\n /**\n * @type {Object}\n */\n this.instance = pickingData.instance\n\n /**\n * @type {Stage}\n */\n this.stage = stage\n /**\n * @type {ViewerControls}\n */\n this.controls = stage.viewerControls\n /**\n * @type {MouseObserver}\n */\n this.mouse = stage.mouseObserver\n }\n\n /**\n * Kind of the picked data\n * @type {String}\n */\n get type () { return this.picker.type }\n\n /**\n * If the `alt` key was pressed\n * @type {Boolean}\n */\n get altKey () { return this.mouse.altKey }\n /**\n * If the `ctrl` key was pressed\n * @type {Boolean}\n */\n get ctrlKey () { return this.mouse.ctrlKey }\n /**\n * If the `meta` key was pressed\n * @type {Boolean}\n */\n get metaKey () { return this.mouse.metaKey }\n /**\n * If the `shift` key was pressed\n * @type {Boolean}\n */\n get shiftKey () { return this.mouse.shiftKey }\n\n /**\n * Position of the mouse on the canvas\n * @type {Vector2}\n */\n get canvasPosition (): Vector2 { return this.mouse.canvasPosition }\n\n /**\n * The component the picked data is part of\n * @type {Component}\n */\n get component (): Component {\n return this.stage.getComponentsByObject(this.picker.data as any).list[ 0 ] // TODO\n }\n\n /**\n * The picked object data\n * @type {Object}\n */\n get object () {\n return this.picker.getObject(this.pid)\n }\n\n /**\n * The 3d position in the scene of the picked object\n * @type {Vector3}\n */\n get position () {\n return this.picker.getPosition(this.pid, this.instance, this.component)\n }\n\n /**\n * The atom of a picked bond that is closest to the mouse\n * @type {AtomProxy}\n */\n get closestBondAtom (): AtomProxy|undefined {\n if (this.type !== 'bond' || !this.bond) return undefined\n\n const bond = this.bond\n const controls = this.controls\n const cp = this.canvasPosition\n\n const v1 = bond.atom1.positionToVector3()\n const v2 = bond.atom2.positionToVector3()\n\n v1.applyMatrix4(this.component.matrix)\n v2.applyMatrix4(this.component.matrix)\n\n const acp1 = controls.getPositionOnCanvas(v1)\n const acp2 = controls.getPositionOnCanvas(v2)\n\n return closer(cp as any, acp1, acp2) ? bond.atom1 : bond.atom2\n }\n\n /**\n * Close-by atom\n * @type {AtomProxy}\n */\n get closeAtom (): AtomProxy|undefined {\n const cp = this.canvasPosition\n const ca = this.closestBondAtom\n if (!ca) return undefined\n\n const v = ca.positionToVector3().applyMatrix4(this.component.matrix)\n\n const acp = this.controls.getPositionOnCanvas(v)\n\n ca.positionToVector3(tmpVec)\n if (this.instance) tmpVec.applyMatrix4(this.instance.matrix)\n tmpVec.applyMatrix4(this.component.matrix)\n const viewer = this.controls.viewer\n tmpVec.add(viewer.translationGroup.position)\n tmpVec.applyMatrix4(viewer.rotationGroup.matrix)\n\n const scaleFactor = this.controls.getCanvasScaleFactor(tmpVec.z)\n const sc = this.component as StructureComponent\n const radius = sc.getMaxRepresentationRadius(ca.index)\n //console.log(scaleFactor, cp.distanceTo(acp), radius/scaleFactor, radius)\n\n if (cp.distanceTo(acp) <= radius/scaleFactor) {\n return ca\n } else {\n return undefined\n }\n }\n\n /**\n * @type {Object}\n */\n get arrow () { return this._objectIfType('arrow') as ShapePrimitive }\n /**\n * @type {AtomProxy}\n */\n get atom () { return this._objectIfType('atom') as AtomProxy }\n /**\n * @type {Object}\n */\n get axes () { return this._objectIfType('axes') }\n /**\n * @type {BondProxy}\n */\n get bond () { return this._objectIfType('bond') as BondProxy }\n /**\n * @type {Object}\n */\n get box () { return this._objectIfType('box') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get cone () { return this._objectIfType('cone') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get clash () { return this._objectIfType('clash') as { clash: { sele1: string, sele2: string } } }\n /**\n * @type {BondProxy}\n */\n get contact () { return this._objectIfType('contact') as { type: string, atom1: AtomProxy, atom2: AtomProxy } }\n /**\n * @type {Object}\n */\n get cylinder () { return this._objectIfType('cylinder') as ShapePrimitive }\n /**\n * @type {BondProxy}\n */\n get distance () { return this._objectIfType('distance') as BondProxy }\n /**\n * @type {Object}\n */\n get ellipsoid () { return this._objectIfType('ellipsoid') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get octahedron () { return this._objectIfType('octahedron') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get point () { return this._objectIfType('point') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get mesh () { return this._objectIfType('mesh') as { name: string, shape: Shape, serial: number } }\n /**\n * @type {Object}\n */\n get slice () { return this._objectIfType('slice') as { volume: Volume, value: number } }\n /**\n * @type {Object}\n */\n get sphere () { return this._objectIfType('sphere') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get tetrahedron () { return this._objectIfType('tetrahedron') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get torus () { return this._objectIfType('torus') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get surface () { return this._objectIfType('surface') as { surface: Surface, index: number } }\n /**\n * @type {Object}\n */\n get unitcell () { return this._objectIfType('unitcell') as { unitcell: Unitcell, structure: Structure } }\n /**\n * @type {Object}\n */\n get unknown () { return this._objectIfType('unknown') }\n /**\n * @type {Object}\n */\n get volume () { return this._objectIfType('volume') as { volume: Volume, value: number } }\n /**\n * @type {Object}\n */\n get wideline () { return this._objectIfType('wideline') as ShapePrimitive }\n\n _objectIfType (type: string) {\n return this.type === type ? this.object : undefined\n }\n\n getLabel () {\n const atom = this.atom || this.closeAtom\n let msg = 'nothing'\n if (this.arrow) {\n msg = this.arrow.name\n } else if (atom) {\n msg = `atom: ${atom.qualifiedName()} (${atom.structure.name})`\n } else if (this.axes) {\n msg = 'axes'\n } else if (this.bond) {\n msg = `bond: ${this.bond.atom1.qualifiedName()} - ${this.bond.atom2.qualifiedName()} (${this.bond.structure.name})`\n } else if (this.box) {\n msg = this.box.name\n } else if (this.cone) {\n msg = this.cone.name\n } else if (this.clash) {\n msg = `clash: ${this.clash.clash.sele1} - ${this.clash.clash.sele2}`\n } else if (this.contact) {\n msg = `${this.contact.type}: ${this.contact.atom1.qualifiedName()} - ${this.contact.atom2.qualifiedName()} (${this.contact.atom1.structure.name})`\n } else if (this.cylinder) {\n msg = this.cylinder.name\n } else if (this.distance) {\n msg = `distance: ${this.distance.atom1.qualifiedName()} - ${this.distance.atom2.qualifiedName()} (${this.distance.structure.name})`\n } else if (this.ellipsoid) {\n msg = this.ellipsoid.name\n } else if (this.octahedron) {\n msg = this.octahedron.name\n } else if (this.point) {\n msg = this.point.name\n } else if (this.mesh) {\n msg = `mesh: ${this.mesh.name || this.mesh.serial} (${this.mesh.shape.name})`\n } else if (this.slice) {\n msg = `slice: ${this.slice.value.toPrecision(3)} (${this.slice.volume.name})`\n } else if (this.sphere) {\n msg = this.sphere.name\n } else if (this.surface) {\n msg = `surface: ${this.surface.surface.name}`\n } else if (this.tetrahedron) {\n msg = this.tetrahedron.name\n } else if (this.torus) {\n msg = this.torus.name\n } else if (this.unitcell) {\n msg = `unitcell: ${this.unitcell.unitcell.spacegroup} (${this.unitcell.structure.name})`\n } else if (this.unknown) {\n msg = 'unknown'\n } else if (this.volume) {\n msg = `volume: ${this.volume.value.toPrecision(3)} (${this.volume.volume.name})`\n } else if (this.wideline) {\n msg = this.wideline.name\n }\n return msg\n }\n}\n\nexport default PickingProxy\n","/**\n * @file Picking Controls\n * @author Alexander Rose \n * @private\n */\n\nimport PickingProxy from './picking-proxy'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\n\n/**\n * Picking controls\n */\nclass PickingControls {\n viewer: Viewer\n\n constructor (readonly stage: Stage) {\n this.viewer = stage.viewer\n }\n\n /**\n * get picking data\n * @param {Number} x - canvas x coordinate\n * @param {Number} y - canvas y coordinate\n * @return {PickingProxy|undefined} picking proxy\n */\n pick (x: number, y: number) {\n const pickingData = this.viewer.pick(x, y)\n\n if (pickingData.picker &&\n pickingData.picker.type !== 'ignore' &&\n pickingData.pid !== undefined\n ) {\n const pickerArray = pickingData.picker.array\n if (pickerArray && pickingData.pid >= pickerArray.length) {\n console.error('pid >= picker.array.length')\n } else {\n return new PickingProxy(pickingData, this.stage)\n }\n }\n }\n}\n\nexport default PickingControls\n","/**\n * @file Viewer Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector2, Vector3, Matrix4, Quaternion, OrthographicCamera } from 'three'\nimport * as signalsWrapper from 'signals'\n\nimport {\n ensureVector2, ensureVector3, ensureMatrix4, ensureQuaternion\n} from '../utils'\nimport { degToRad } from '../math/math-utils'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\n\n/**\n * Orientation matrix, a 4x4 transformation matrix with rotation part\n * used for scene rotation, scale part for scene camera distance and\n * position part for scene translation\n * @typedef {Matrix4} OrientationMatrix - orientation matrix\n */\n\nconst tmpQ = new Quaternion()\nconst tmpP = new Vector3()\nconst tmpS = new Vector3()\n\nconst tmpCanvasVector = new Vector3()\nconst tmpScaleVector = new Vector3()\nconst tmpRotateMatrix = new Matrix4()\nconst tmpRotateVector = new Vector3()\nconst tmpAlignMatrix = new Matrix4()\n\n/**\n * Viewer controls\n */\nclass ViewerControls {\n signals = {\n changed: new signalsWrapper.Signal()\n }\n\n viewer: Viewer\n\n /**\n * @param {Stage} stage - the stage object\n */\n constructor (readonly stage: Stage) {\n this.viewer = stage.viewer\n }\n\n /**\n * scene center position\n * @type {Vector3}\n */\n get position () {\n return this.viewer.translationGroup.position\n }\n\n /**\n * scene rotation\n * @type {Quaternion}\n */\n get rotation () {\n return this.viewer.rotationGroup.quaternion\n }\n\n /**\n * Trigger render and emit changed event\n * @emits {ViewerControls.signals.changed}\n * @return {undefined}\n */\n changed () {\n this.viewer.requestRender()\n this.signals.changed.dispatch()\n }\n\n getPositionOnCanvas (position: Vector3, optionalTarget?: Vector2) {\n const canvasPosition = ensureVector2(optionalTarget)\n const viewer = this.viewer\n\n tmpCanvasVector.copy(position)\n .add(viewer.translationGroup.position)\n .applyMatrix4(viewer.rotationGroup.matrix)\n .project(viewer.camera)\n\n return canvasPosition.set(\n (tmpCanvasVector.x + 1) * viewer.width / 2,\n (tmpCanvasVector.y + 1) * viewer.height / 2\n )\n }\n\n getCanvasScaleFactor (z = 0) {\n const camera = this.viewer.camera\n if (camera instanceof OrthographicCamera) {\n return 1 / camera.zoom\n } else {\n z = Math.abs(z)\n z += this.getCameraDistance()\n const fov = degToRad(camera.fov)\n const unitHeight = 2.0 * z * Math.tan(fov / 2)\n return unitHeight / this.viewer.height\n }\n }\n\n /**\n * get scene orientation\n * @param {Matrix4} optionalTarget - pre-allocated target matrix\n * @return {OrientationMatrix} scene orientation\n */\n getOrientation (optionalTarget?: Matrix4) {\n const m = ensureMatrix4(optionalTarget)\n\n m.copy(this.viewer.rotationGroup.matrix)\n const z = this.getCameraDistance()\n m.scale(tmpScaleVector.set(z, z, z))\n m.setPosition(this.viewer.translationGroup.position)\n\n return m\n }\n\n /**\n * set scene orientation\n * @param {OrientationMatrix|Array} orientation - scene orientation\n * @return {undefined}\n */\n orient (orientation?: Matrix4) {\n ensureMatrix4(orientation).decompose(tmpP, tmpQ, tmpS)\n\n const v = this.viewer\n v.rotationGroup.setRotationFromQuaternion(tmpQ)\n v.translationGroup.position.copy(tmpP)\n v.cameraDistance = tmpS.z\n v.updateZoom()\n this.changed()\n }\n\n /**\n * translate scene\n * @param {Vector3|Array} vector - translation vector\n * @return {undefined}\n */\n translate (vector: Vector3|number[]) {\n this.viewer.translationGroup.position\n .add(ensureVector3(vector))\n this.changed()\n }\n\n /**\n * center scene\n * @param {Vector3|Array} position - center position\n * @return {undefined}\n */\n center (position: Vector3|number[]) {\n this.viewer.translationGroup.position\n .copy(ensureVector3(position)).negate()\n this.changed()\n }\n\n /**\n * \"zoom\" scene by moving camera closer to origin\n * @param {Number} delta - zoom change\n * @return {undefined}\n */\n zoom (delta: number) {\n this.distance(this.getCameraDistance() * (1 - delta))\n }\n\n /**\n * get camera distance\n */\n getCameraDistance(): number {\n return this.viewer.cameraDistance\n }\n\n /**\n * camera distance\n * @param {Number} z - distance\n * @return {undefined}\n */\n distance (distance: number) {\n // Math.abs because distance used to be \"z\", normally negative.\n // Math.max to prevent us from getting _too_ close.\n this.viewer.cameraDistance = Math.max(Math.abs(distance), 0.2)\n this.viewer.updateZoom()\n this.changed()\n }\n\n /**\n * spin scene on axis\n * @param {Vector3|Array} axis - rotation axis\n * @param {Number} angle - amount to spin\n * @return {undefined}\n */\n spin (axis: Vector3|number[], angle: number) {\n tmpRotateMatrix.getInverse(this.viewer.rotationGroup.matrix)\n tmpRotateVector\n .copy(ensureVector3(axis)).applyMatrix4(tmpRotateMatrix)\n\n this.viewer.rotationGroup.rotateOnAxis(tmpRotateVector, angle)\n this.changed()\n }\n\n /**\n * rotate scene\n * @param {Quaternion|Array} quaternion - rotation quaternion\n * @return {undefined}\n */\n rotate (quaternion: Quaternion|number[]) {\n this.viewer.rotationGroup\n .setRotationFromQuaternion(ensureQuaternion(quaternion))\n this.changed()\n }\n\n /**\n * align scene to basis matrix\n * @param {Matrix4|Array} basis - basis matrix\n * @return {undefined}\n */\n align (basis: Matrix4|number[]) {\n tmpAlignMatrix.getInverse(ensureMatrix4(basis))\n\n this.viewer.rotationGroup.setRotationFromMatrix(tmpAlignMatrix)\n this.changed()\n }\n\n /**\n * apply rotation matrix to scene\n * @param {Matrix4|Array} matrix - rotation matrix\n * @return {undefined}\n */\n applyMatrix (matrix: Matrix4|number[]) {\n this.viewer.rotationGroup.applyMatrix4(ensureMatrix4(matrix))\n this.changed()\n }\n}\n\nexport default ViewerControls\n","/**\n * @file Animation\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Quaternion } from 'three'\n\nimport { defaults, ensureVector3, ensureQuaternion } from '../utils'\nimport { lerp, smoothstep } from '../math/math-utils'\nimport ViewerControls from '../controls/viewer-controls'\nimport Stats from '../viewer/stats'\n\n/**\n * Animation. Base animation class.\n * @interface\n */\nabstract class Animation {\n duration: number\n controls: ViewerControls\n\n alpha: number\n startTime: number\n\n pausedTime = -1\n elapsedDuration = 0\n pausedDuration = 0\n ignoreGlobalToggle = false\n\n private _paused = false\n private _resolveList: Function[] = []\n private _hold: boolean\n\n constructor (duration: number|undefined, controls: ViewerControls, ...args: any[]) {\n this.duration = defaults(duration, 1000)\n this.controls = controls\n\n this.startTime = window.performance.now()\n\n this._init(...args)\n }\n\n /**\n * True when animation has finished\n */\n get done () {\n return this.alpha === 1\n }\n\n /**\n * True when animation is paused\n */\n get paused () {\n return this._paused\n }\n\n /**\n * init animation\n */\n abstract _init (...args: any[]): void\n\n /**\n * called on every tick\n */\n abstract _tick (stats?: Stats): void\n\n tick (stats: Stats) {\n if (this._paused) return\n\n this.elapsedDuration = stats.currentTime - this.startTime - this.pausedDuration\n\n if (this.duration === 0) {\n this.alpha = 1\n } else {\n this.alpha = smoothstep(0, 1, this.elapsedDuration / this.duration)\n }\n\n this._tick(stats)\n\n if (this.done) {\n this._resolveList.forEach(resolve => resolve())\n }\n\n return this.done\n }\n\n /**\n * Pause animation\n * @param {boolean} [hold] - put animation on a hold which\n * must be release before it can be resumed\n */\n pause (hold?: boolean) {\n if (hold) this._hold = true\n\n if (this.pausedTime === -1) {\n this.pausedTime = window.performance.now()\n }\n this._paused = true\n }\n\n /**\n * Resume animation\n * @param {Boolean} [releaseHold] - release a hold on the animation\n */\n resume (releaseHold?: boolean) {\n if (!releaseHold && this._hold) return\n\n this.pausedDuration += window.performance.now() - this.pausedTime\n this._paused = false\n this._hold = false\n this.pausedTime = -1\n }\n\n /**\n * Toggle animation\n */\n toggle () {\n if (this._paused) {\n this.resume()\n } else {\n this.pause()\n }\n }\n\n /**\n * Promise-like interface\n */\n then (callback: Function) {\n let p: Promise\n\n if (this.done) {\n p = Promise.resolve()\n } else {\n p = new Promise(resolve => this._resolveList.push(resolve))\n }\n\n return p.then(callback as any)\n }\n}\n\nexport default Animation\n\n/**\n * Spin animation. Spin around an axis.\n */\nexport class SpinAnimation extends Animation {\n axis: Vector3\n angle: number\n\n constructor (duration: number|undefined, controls: ViewerControls, ...args: any[]) {\n super(defaults(duration, Infinity), controls, ...args)\n }\n\n _init (axis: number[]|Vector3, angle: number) {\n if (Array.isArray(axis)) {\n this.axis = new Vector3().fromArray(axis)\n } else {\n this.axis = defaults(axis, new Vector3(0, 1, 0))\n }\n this.angle = defaults(angle, 0.01)\n }\n\n _tick (stats: Stats) {\n if (!this.axis || !this.angle) return\n\n this.controls.spin(\n this.axis, this.angle * stats.lastDuration / 16\n )\n }\n}\n\n/**\n * Rock animation. Rock around an axis.\n */\nexport class RockAnimation extends Animation {\n axis: Vector3\n angleStep: number\n angleEnd: number\n angleSum = 0\n direction = 1\n\n constructor (duration: number|undefined, controls: ViewerControls, ...args: any[]) {\n super(defaults(duration, Infinity), controls, ...args)\n }\n\n _init (axis: number[]|Vector3, angleStep: number, angleEnd: number) {\n if (Array.isArray(axis)) {\n this.axis = new Vector3().fromArray(axis)\n } else {\n this.axis = defaults(axis, new Vector3(0, 1, 0))\n }\n this.angleStep = defaults(angleStep, 0.01)\n this.angleEnd = defaults(angleEnd, 0.2)\n }\n\n _tick (stats: Stats) {\n if (!this.axis || !this.angleStep || !this.angleEnd) return\n\n const alpha = smoothstep(\n 0, 1, Math.abs(this.angleSum) / this.angleEnd\n )\n const angle = this.angleStep * this.direction * (1.1 - alpha)\n\n this.controls.spin(\n this.axis, angle * stats.lastDuration / 16\n )\n\n this.angleSum += this.angleStep\n\n if (this.angleSum >= this.angleEnd) {\n this.direction *= -1\n this.angleSum = -this.angleEnd\n }\n }\n}\n\n/**\n * Move animation. Move from one position to another.\n */\nexport class MoveAnimation extends Animation {\n moveFrom: Vector3\n moveTo: Vector3\n\n _init (moveFrom: number[]|Vector3, moveTo: number[]|Vector3) {\n this.moveFrom = ensureVector3(defaults(moveFrom, new Vector3()))\n this.moveTo = ensureVector3(defaults(moveTo, new Vector3()))\n }\n\n _tick (/* stats */) {\n this.controls.position.lerpVectors(\n this.moveFrom, this.moveTo, this.alpha\n ).negate()\n this.controls.changed()\n }\n}\n\n/**\n * Zoom animation. Gradually change the zoom level.\n */\nexport class ZoomAnimation extends Animation {\n zoomFrom: number\n zoomTo: number\n\n _init (zoomFrom: number, zoomTo: number) {\n this.zoomFrom = zoomFrom\n this.zoomTo = zoomTo\n }\n\n _tick () {\n this.controls.distance(lerp(this.zoomFrom, this.zoomTo, this.alpha))\n }\n}\n\n/**\n * Rotate animation. Rotate from one orientation to another.\n */\nexport class RotateAnimation extends Animation {\n rotateFrom: Quaternion\n rotateTo: Quaternion\n\n private _currentRotation = new Quaternion()\n\n _init (rotateFrom: number[]|Quaternion, rotateTo: number[]|Quaternion) {\n this.rotateFrom = ensureQuaternion(rotateFrom)\n this.rotateTo = ensureQuaternion(rotateTo)\n\n this._currentRotation = new Quaternion()\n }\n\n _tick () {\n this._currentRotation\n .copy(this.rotateFrom)\n .slerp(this.rotateTo, this.alpha)\n\n this.controls.rotate(this._currentRotation)\n }\n}\n\n/**\n * Value animation. Call callback with interpolated value.\n */\nexport class ValueAnimation extends Animation {\n valueFrom: number\n valueTo: number\n callback: Function\n\n _init (valueFrom: number, valueTo: number, callback: Function) {\n this.valueFrom = valueFrom\n this.valueTo = valueTo\n\n this.callback = callback\n }\n\n _tick (/* stats */) {\n this.callback(lerp(this.valueFrom, this.valueTo, this.alpha))\n }\n}\n\n/**\n * Timeout animation. Call callback after duration.\n */\nexport class TimeoutAnimation extends Animation {\n callback: Function\n\n _init (callback: Function) {\n this.callback = callback\n }\n\n _tick () {\n if (this.alpha === 1) this.callback()\n }\n}\n\n/**\n * Animation list.\n */\nexport class AnimationList {\n _list: Animation[]\n _resolveList: Function[] = []\n\n constructor (list: Animation[] = []) {\n this._list = list\n }\n\n /**\n * True when all animations have finished\n */\n get done () {\n return this._list.every(animation => {\n return animation.done\n })\n }\n\n /**\n * Promise-like interface\n */\n then (callback: Function) {\n let p: Promise\n\n if (this.done) {\n p = Promise.resolve()\n } else {\n p = new Promise(resolve => {\n this._resolveList.push(resolve)\n this._list.forEach(animation => {\n animation.then(() => {\n this._resolveList.forEach(callback => {\n callback()\n })\n this._resolveList.length = 0\n })\n })\n })\n }\n\n return p.then(callback as any)\n }\n}\n","/**\n * @file Animation Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Quaternion, Matrix4 } from 'three'\n\nimport { ensureMatrix4 } from '../utils'\nimport Animation, {\n SpinAnimation, RockAnimation, MoveAnimation, ZoomAnimation,\n RotateAnimation, ValueAnimation, TimeoutAnimation, AnimationList\n} from '../animation/animation'\nimport Stage from '../stage/stage'\nimport Component from '../component/component'\nimport Viewer from '../viewer/viewer'\nimport Stats from '../viewer/stats'\nimport ViewerControls from './viewer-controls'\n\n/**\n * Animation controls\n */\nclass AnimationControls {\n viewer: Viewer\n controls: ViewerControls\n\n animationList: Animation[] = []\n finishedList: Animation[] = []\n\n /**\n * Create animation controls\n * @param {Stage} stage - the stage object\n */\n constructor (readonly stage: Stage) {\n this.viewer = stage.viewer\n this.controls = stage.viewerControls\n }\n\n /**\n * True when all animations are paused\n * @type {Boolean}\n */\n get paused () {\n return this.animationList.every((animation: Animation) => animation.paused)\n }\n\n /**\n * Add an animation\n */\n add (animation: Animation) {\n if (animation.duration === 0) {\n animation.tick(this.viewer.stats)\n } else {\n this.animationList.push(animation)\n }\n\n return animation\n }\n\n /**\n * Remove an animation\n */\n remove (animation: Animation) {\n const list = this.animationList\n const index = list.indexOf(animation)\n\n if (index > -1) {\n list.splice(index, 1)\n }\n }\n\n /**\n * Run all animations\n */\n run (stats: Stats) {\n const finishedList = this.finishedList\n const animationList = this.animationList\n\n const n = animationList.length\n for (let i = 0; i < n; ++i) {\n const animation = animationList[ i ]\n // tick returns true when finished\n if (animation.tick(stats)) {\n finishedList.push(animation)\n }\n }\n\n const m = finishedList.length\n if (m) {\n for (let j = 0; j < m; ++j) {\n this.remove(finishedList[ j ])\n }\n finishedList.length = 0\n }\n }\n\n /**\n * Add a spin animation\n * @param {Vector3} axis - axis to spin around\n * @param {Number} angle - amount to spin per frame, radians\n * @param {Number} duration - animation time in milliseconds\n * @return {SpinAnimation} the animation\n */\n spin (axis: Vector3|number[], angle?: number, duration?: number) {\n return this.add(\n new SpinAnimation(duration, this.controls, axis, angle)\n )\n }\n\n /**\n * Add a rock animation\n * @param {Vector3} axis - axis to rock around\n * @param {Number} angle - amount to spin per frame, radians\n * @param {Number} end - maximum extend of motion, radians\n * @param {Number} duration - animation time in milliseconds\n * @return {SpinAnimation} the animation\n */\n rock (axis: Vector3|number[], angle?: number, end?: number, duration?: number) {\n return this.add(\n new RockAnimation(duration, this.controls, axis, angle, end)\n )\n }\n\n /**\n * Add a rotate animation\n * @param {Quaternion} rotateTo - target rotation\n * @param {Number} duration - animation time in milliseconds\n * @return {RotateAnimation} the animation\n */\n rotate (rotateTo: Quaternion|number[], duration?: number) {\n const rotateFrom = this.viewer.rotationGroup.quaternion.clone()\n\n return this.add(\n new RotateAnimation(duration, this.controls, rotateFrom, rotateTo)\n )\n }\n\n /**\n * Add a move animation\n * @param {Vector3} moveTo - target position\n * @param {Number} duration - animation time in milliseconds\n * @return {MoveAnimation} the animation\n */\n move (moveTo: Vector3|number[], duration?: number) {\n const moveFrom = this.controls.position.clone().negate()\n\n return this.add(\n new MoveAnimation(duration, this.controls, moveFrom, moveTo)\n )\n }\n\n /**\n * Add a zoom animation\n * @param {Number} zoomTo - target distance\n * @param {Number} duration - animation time in milliseconds\n * @return {ZoomAnimation} the animation\n */\n zoom (zoomTo: number, duration?: number) {\n const zoomFrom = this.viewer.camera.position.z\n\n return this.add(\n new ZoomAnimation(duration, this.controls, zoomFrom, zoomTo)\n )\n }\n\n /**\n * Add a zoom and a move animation\n * @param {Vector3} moveTo - target position\n * @param {Number} zoomTo - target distance\n * @param {Number} duration - animation time in milliseconds\n * @return {Array} the animations\n */\n zoomMove (moveTo: Vector3, zoomTo: number, duration?: number) {\n return new AnimationList([\n this.move(moveTo, duration),\n this.zoom(zoomTo, duration)\n ])\n }\n\n /**\n * Add an orient animation\n * @param {OrientationMatrix|Array} orientTo - target orientation\n * @param {Number} duration - animation time in milliseconds\n * @return {Array} the animations\n */\n orient (orientTo: Matrix4|number[], duration?: number) {\n const p = new Vector3()\n const q = new Quaternion()\n const s = new Vector3()\n\n ensureMatrix4(orientTo).decompose(p, q, s)\n\n return new AnimationList([\n this.move(p.negate(), duration),\n this.rotate(q, duration),\n this.zoom(-s.x, duration)\n ])\n }\n\n /**\n * Add a value animation\n * @param {Number} valueFrom - start value\n * @param {Number} valueTo - target value\n * @param {Function} callback - called on every tick\n * @param {Number} duration - animation time in milliseconds\n * @return {ValueAnimation} the animation\n */\n value (valueFrom: number, valueTo: number, callback: Function, duration?: number) {\n return this.add(\n new ValueAnimation(duration, this.controls, valueFrom, valueTo, callback)\n )\n }\n\n /**\n * Add a timeout animation\n * @param {Function} callback - called after duration\n * @param {Number} duration - timeout in milliseconds\n * @return {TimeoutAnimation} the animation\n */\n timeout (callback: Function, duration?: number) {\n return this.add(\n new TimeoutAnimation(duration, this.controls, callback)\n )\n }\n\n /**\n * Add a component spin animation\n * @param {Component} component - object to move\n * @param {Vector3} axis - axis to spin around\n * @param {Number} angle - amount to spin per frame, radians\n * @param {Number} duration - animation time in milliseconds\n * @return {SpinAnimation} the animation\n */\n spinComponent (component: Component, axis?: Vector3|number[], angle?: number, duration?: number) {\n return this.add(\n // TODO\n new SpinAnimation(duration, component.controls as any, axis, angle)\n )\n }\n\n /**\n * Add a component rock animation\n * @param {Component} component - object to move\n * @param {Vector3} axis - axis to rock around\n * @param {Number} angle - amount to spin per frame, radians\n * @param {Number} end - maximum extend of motion, radians\n * @param {Number} duration - animation time in milliseconds\n * @return {SpinAnimation} the animation\n */\n rockComponent (component: Component, axis: Vector3|number[], angle?: number, end?: number, duration?: number) {\n return this.add(\n // TODO\n new RockAnimation(duration, component.controls as any, axis, angle, end)\n )\n }\n\n /**\n * Add a component move animation\n * @param {Component} component - object to move\n * @param {Vector3} moveTo - target position\n * @param {Number} duration - animation time in milliseconds\n * @return {MoveAnimation} the animation\n */\n moveComponent (component: Component, moveTo: Vector3|number[], duration?: number) {\n const moveFrom = component.controls.position.clone().negate()\n\n return this.add(\n // TODO\n new MoveAnimation(duration, component.controls as any, moveFrom, moveTo)\n )\n }\n\n /**\n * Pause all animations\n * @return {undefined}\n */\n pause () {\n this.animationList.forEach(animation => animation.pause())\n }\n\n /**\n * Resume all animations\n * @return {undefined}\n */\n resume () {\n this.animationList.forEach(animation => animation.resume())\n }\n\n /**\n * Toggle all animations\n * @return {undefined}\n */\n toggle () {\n if (this.paused) {\n this.resume()\n } else {\n this.pause()\n }\n }\n\n /**\n * Clear all animations\n * @return {undefined}\n */\n clear () {\n this.animationList.length = 0\n }\n\n dispose () {\n this.clear()\n }\n}\n\nexport default AnimationControls\n","/**\n * @file Queue\n * @author Alexander Rose \n * @private\n */\n\nclass Queue {\n queue: T[] = []\n pending = false\n\n constructor(readonly fn: Function, argList?: T[]) {\n this.next = this.next.bind(this)\n\n if (argList) {\n for (let i = 0, il = argList.length; i < il; ++i) {\n this.queue.push(argList[ i ])\n }\n this.next()\n }\n }\n\n private run (arg: any) {\n this.fn(arg, this.next)\n }\n\n private next () {\n const arg = this.queue.shift()\n if (arg !== undefined) {\n this.pending = true\n setTimeout(() => this.run(arg))\n } else {\n this.pending = false\n }\n }\n\n push (arg: T) {\n this.queue.push(arg)\n if (!this.pending) this.next()\n }\n\n kill () {\n this.queue.length = 0\n }\n\n length () {\n return this.queue.length\n }\n}\n\nexport default Queue\n","/**\n * @file Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { Color, Vector3, Matrix4 } from 'three'\n\nimport { Debug, Log, ColormakerRegistry, ExtensionFragDepth } from '../globals'\nimport { defaults } from '../utils'\nimport Queue from '../utils/queue'\nimport Counter from '../utils/counter'\nimport Viewer from '../viewer/viewer'\nimport { BufferParameters, BufferSide, default as Buffer } from '../buffer/buffer';\nimport { ColorData, ColormakerParameters, ColorMode } from '../color/colormaker';\nimport { GenericColor } from '../types'\n\nexport interface RepresentationParameters {\n name: string\n lazy: boolean,\n clipNear: number,\n clipRadius: number,\n clipCenter: Vector3,\n flatShaded: boolean,\n opacity: number,\n depthWrite: boolean,\n side: BufferSide,\n wireframe: boolean,\n colorData: ColorData,\n colorScheme: string,\n colorScale: string | number[],\n colorReverse: boolean,\n colorValue: GenericColor,\n colorDomain: number[],\n colorMode: ColorMode,\n colorSpace: 'sRGB' | 'linear',\n roughness: number,\n metalness: number,\n diffuse: GenericColor,\n diffuseInterior: boolean,\n useInteriorColor: boolean,\n interiorColor: GenericColor,\n interiorDarkening: number,\n disablePicking: boolean,\n matrix: Matrix4\n quality: string,\n visible: boolean,\n color: GenericColor,\n sphereDetail: number,\n radialSegments: number,\n openEnded: boolean\n disableImpostor: boolean\n [key: string]: any//boolean | number | undefined | Color | string | Vector3 | Matrix4 | number[]\n}\n/**\n * Representation parameter object.\n * @typedef {Object} RepresentationParameters - representation parameters\n * @property {Boolean} [lazy] - only build & update the representation when visible\n * otherwise defer changes until set visible again\n * @property {Integer} [clipNear] - position of camera near/front clipping plane\n * in percent of scene bounding box\n * @property {Integer} [clipRadius] - radius of clipping sphere\n * @property {Vector3} [clipCenter] - position of for spherical clipping\n * @property {Boolean} [flatShaded] - render flat shaded\n * @property {Float} [opacity] - translucency: 1 is fully opaque, 0 is fully transparent\n * @property {Boolean} [depthWrite] - depth write\n * @property {String} [side] - which triangle sides to render, \"front\" front-side,\n * \"back\" back-side, \"double\" front- and back-side\n * @property {Boolean} [wireframe] - render as wireframe\n * @property {ColorData} [colorData] - atom or bond indexed data for coloring\n * @property {String} [colorScheme] - color scheme\n * @property {String} [colorScale] - color scale, either a string for a\n * predefined scale or an array of\n * colors to be used as the scale\n * @property {Boolean} [colorReverse] - reverse color scale\n * @property {Color} [colorValue] - color value\n * @property {Integer[]} [colorDomain] - scale value range\n * @property {Integer} colorDomain.0 - min value\n * @property {Integer} colorDomain.1 - max value\n * @property {String} [colorMode] - color mode, one of rgb, hsv, hsl, hsi, lab, hcl\n * @property {Float} [roughness] - how rough the material is, between 0 and 1\n * @property {Float} [metalness] - how metallic the material is, between 0 and 1\n * @property {Color} [diffuse] - diffuse color for lighting\n * @property {Boolean} [diffuseInterior] - diffuse interior, i.e. ignore normal\n * @property {Boolean} [useInteriorColor] - use interior color\n * @property {Color} [interiorColor] - interior color\n * @property {Float} [interiorDarkening] - interior darkening: 0 no darking, 1 fully darkened\n * @property {Boolean} [disablePicking] - disable picking\n */\n\n/**\n * Representation object\n * @interface\n * @param {Object} object - the object to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {RepresentationParameters} [params] - representation parameters\n */\nclass Representation {\n parameters: any\n type: string\n viewer: Viewer\n tasks: Counter\n private queue: Queue\n bufferList: Buffer[]\n\n lazy: boolean\n lazyProps: { build: boolean, bufferParams: BufferParameters | {}, what: {}}\n protected name: string\n protected clipNear: number\n protected clipRadius: number\n protected clipCenter: Vector3\n protected flatShaded: boolean\n protected opacity: number\n protected depthWrite: boolean\n protected side: BufferSide\n protected wireframe: boolean\n protected colorData: ColorData\n protected colorScheme: string\n protected colorScale: string | string[]\n protected colorReverse: boolean\n protected colorValue: number\n protected colorDomain: number[]\n protected colorMode: ColorMode\n protected roughness: number\n protected metalness: number\n protected diffuse: GenericColor\n protected diffuseInterior?: boolean\n protected useInteriorColor?: boolean\n protected interiorColor: GenericColor\n protected interiorDarkening: number\n protected disablePicking: boolean\n protected sphereDetail: number\n protected radialSegments: number\n protected openEnded: boolean\n protected disableImpostor: boolean\n protected disposed: boolean\n\n protected matrix: Matrix4\n\n private quality: string\n visible: boolean\n\n protected manualAttach: ()=> any\n\n protected toBePrepared: boolean\n\n [key: string]: any\n\n constructor (object: any, viewer: Viewer, params: Partial) {\n // eslint-disable-next-line no-unused-vars\n // const p = params || {}\n\n this.type = ''\n\n this.parameters = {\n\n lazy: {\n type: 'boolean'\n },\n\n clipNear: {\n type: 'range', step: 1, max: 100, min: 0, buffer: true\n },\n clipRadius: {\n type: 'number', precision: 1, max: 1000, min: 0, buffer: true\n },\n clipCenter: {\n type: 'vector3', precision: 1, buffer: true\n },\n flatShaded: {\n type: 'boolean', buffer: true\n },\n opacity: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n depthWrite: {\n type: 'boolean', buffer: true\n },\n side: {\n type: 'select',\n buffer: true,\n options: { front: 'front', back: 'back', double: 'double' }\n },\n wireframe: {\n type: 'boolean', buffer: true\n },\n\n colorData: {\n type: 'hidden',\n update: 'color',\n },\n\n colorScheme: {\n type: 'select',\n update: 'color',\n options: {}\n },\n colorScale: {\n type: 'select',\n update: 'color',\n options: ColormakerRegistry.getScales()\n },\n colorReverse: {\n type: 'boolean', update: 'color'\n },\n colorValue: {\n type: 'color', update: 'color'\n },\n colorDomain: {\n type: 'hidden', update: 'color'\n },\n colorMode: {\n type: 'select',\n update: 'color',\n options: ColormakerRegistry.getModes()\n },\n\n roughness: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n metalness: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n diffuse: {\n type: 'color', buffer: true\n },\n\n diffuseInterior: {\n type: 'boolean', buffer: true\n },\n useInteriorColor: {\n type: 'boolean', buffer: true\n },\n interiorColor: {\n type: 'color', buffer: true\n },\n interiorDarkening: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n\n matrix: {\n type: 'hidden', buffer: true\n },\n\n disablePicking: {\n type: 'boolean', rebuild: true\n }\n\n }\n\n /**\n * @type {Viewer}\n */\n this.viewer = viewer\n\n /**\n * Counter that keeps track of tasks related to the creation of\n * the representation, including surface calculations.\n * @type {Counter}\n */\n this.tasks = new Counter()\n\n /**\n * @type {Queue}\n * @private\n */\n this.queue = new Queue(this.make.bind(this))\n\n /**\n * @type {Array}\n * @private\n */\n this.bufferList = []\n\n if (this.parameters.colorScheme) {\n this.parameters.colorScheme.options = ColormakerRegistry.getSchemes()\n }\n\n this.toBePrepared = false\n }\n\n init (params: Partial) {\n const p = params || {}\n\n this.clipNear = defaults(p.clipNear, 0)\n this.clipRadius = defaults(p.clipRadius, 0)\n this.clipCenter = defaults(p.clipCenter, new Vector3())\n this.flatShaded = defaults(p.flatShaded, false)\n this.side = defaults(p.side, 'double')\n this.opacity = defaults(p.opacity, 1.0)\n this.depthWrite = defaults(p.depthWrite, true)\n this.wireframe = defaults(p.wireframe, false)\n\n this.setColor(p.color, p)\n\n this.colorData = defaults(p.colorData, undefined)\n this.colorScheme = defaults(p.colorScheme, 'uniform')\n this.colorScale = defaults(p.colorScale, '')\n this.colorReverse = defaults(p.colorReverse, false)\n this.colorValue = defaults(p.colorValue, 0x909090)\n this.colorDomain = defaults(p.colorDomain, undefined)\n this.colorMode = defaults(p.colorMode, 'hcl')\n\n this.visible = defaults(p.visible, true)\n this.quality = defaults(p.quality, undefined)\n\n this.roughness = defaults(p.roughness, 0.4)\n this.metalness = defaults(p.metalness, 0.0)\n this.diffuse = defaults(p.diffuse, 0xffffff)\n\n this.diffuseInterior = defaults(p.diffuseInterior, false)\n this.useInteriorColor = defaults(p.useInteriorColor, false)\n this.interiorColor = defaults(p.interiorColor, 0x222222)\n this.interiorDarkening = defaults(p.interiorDarkening, 0)\n\n this.lazy = defaults(p.lazy, false)\n this.lazyProps = {\n build: false,\n bufferParams: {},\n what: {}\n }\n\n this.matrix = defaults(p.matrix, new Matrix4())\n\n this.disablePicking = defaults(p.disablePicking, false)\n\n // handle common parameters when applicable\n\n const tp = this.parameters\n\n if (tp.sphereDetail === true) {\n tp.sphereDetail = {\n type: 'integer', max: 3, min: 0, rebuild: 'impostor'\n }\n }\n if (tp.radialSegments === true) {\n tp.radialSegments = {\n type: 'integer', max: 25, min: 5, rebuild: 'impostor'\n }\n }\n if (tp.openEnded === true) {\n tp.openEnded = {\n type: 'boolean', rebuild: 'impostor', buffer: true\n }\n }\n if (tp.disableImpostor === true) {\n tp.disableImpostor = {\n type: 'boolean', rebuild: true\n }\n }\n\n if (p.quality === 'low') {\n if (tp.sphereDetail) this.sphereDetail = 0\n if (tp.radialSegments) this.radialSegments = 5\n } else if (p.quality === 'medium') {\n if (tp.sphereDetail) this.sphereDetail = 1\n if (tp.radialSegments) this.radialSegments = 10\n } else if (p.quality === 'high') {\n if (tp.sphereDetail) this.sphereDetail = 2\n if (tp.radialSegments) this.radialSegments = 20\n } else {\n if (tp.sphereDetail) {\n this.sphereDetail = defaults(p.sphereDetail, 1)\n }\n if (tp.radialSegments) {\n this.radialSegments = defaults(p.radialSegments, 10)\n }\n }\n\n if (tp.openEnded) {\n this.openEnded = defaults(p.openEnded, true)\n }\n\n if (tp.disableImpostor) {\n this.disableImpostor = defaults(p.disableImpostor, false)\n }\n\n }\n\n getColorParams (p?: {[k: string]: any}): { scheme: string, [k: string]: any } & ColormakerParameters {\n return Object.assign({\n\n data: this.colorData,\n scheme: this.colorScheme,\n scale: this.colorScale,\n reverse: this.colorReverse,\n value: this.colorValue,\n domain: this.colorDomain,\n mode: this.colorMode,\n colorSpace: this.colorSpace,\n\n }, p)\n }\n\n getBufferParams (p: {[k: string]: any} = {}) {\n return Object.assign({\n\n clipNear: this.clipNear,\n clipRadius: this.clipRadius,\n clipCenter: this.clipCenter,\n flatShaded: this.flatShaded,\n opacity: this.opacity,\n depthWrite: this.depthWrite,\n side: this.side,\n wireframe: this.wireframe,\n\n roughness: this.roughness,\n metalness: this.metalness,\n diffuse: this.diffuse,\n\n diffuseInterior: this.diffuseInterior,\n useInteriorColor: this.useInteriorColor,\n interiorColor: this.interiorColor,\n interiorDarkening: this.interiorDarkening,\n\n matrix: this.matrix,\n\n disablePicking: this.disablePicking\n\n }, p)\n }\n\n setColor (value: number | string | Color | undefined , p?: Partial) {\n const types = Object.keys(ColormakerRegistry.getSchemes())\n\n if (typeof value === 'string' && types.includes(value.toLowerCase())) {\n if (p) {\n p.colorScheme = value\n } else {\n this.setParameters({ colorScheme: value })\n }\n } else if (value !== undefined) {\n let val = new Color(value as string).getHex() //TODO\n if (p) {\n p.colorScheme = 'uniform'\n p.colorValue = val\n } else {\n this.setParameters({\n colorScheme: 'uniform', colorValue: val\n })\n }\n }\n\n return this\n }\n\n // TODO\n prepare (cb: ()=> void) {\n\n }\n\n create () {\n // this.bufferList.length = 0;\n }\n\n update (what?: any) {\n this.build()\n }\n\n build (updateWhat?: {[k: string]: boolean}) {\n if (this.lazy && (!this.visible || !this.opacity)) {\n this.lazyProps.build = true\n return\n }\n\n if (!this.toBePrepared) {\n this.tasks.increment()\n this.make()\n return\n }\n\n // don't let tasks accumulate\n if (this.queue.length() > 0) {\n this.tasks.change(1 - this.queue.length())\n this.queue.kill()\n } else {\n this.tasks.increment()\n }\n\n this.queue.push(updateWhat || false)\n }\n\n make (updateWhat?: boolean, callback?: () => void) {\n if (Debug) Log.time('Representation.make ' + this.type)\n\n const _make = () => {\n if (updateWhat) {\n this.update(updateWhat)\n this.viewer.requestRender()\n this.tasks.decrement()\n if (callback) callback()\n } else {\n this.clear()\n this.create()\n if (!this.manualAttach && !this.disposed) {\n if (Debug) Log.time('Representation.attach ' + this.type)\n this.attach(() => {\n if (Debug) Log.timeEnd('Representation.attach ' + this.type)\n this.tasks.decrement()\n if (callback) callback()\n })\n }\n }\n\n if (Debug) Log.timeEnd('Representation.make ' + this.type)\n }\n\n if (this.toBePrepared) {\n this.prepare(_make)\n } else {\n _make()\n }\n }\n\n attach (callback: () => void) {\n this.setVisibility(this.visible)\n\n callback()\n }\n\n /**\n * Set the visibility of the representation\n * @param {Boolean} value - visibility flag\n * @param {Boolean} [noRenderRequest] - whether or not to request a re-render from the viewer\n * @return {Representation} this object\n */\n setVisibility (value: boolean, noRenderRequest?: boolean): Representation {\n this.visible = value\n\n if (this.visible && this.opacity) {\n const lazyProps = this.lazyProps\n const bufferParams = lazyProps.bufferParams\n const what = lazyProps.what\n\n if (lazyProps.build) {\n lazyProps.build = false\n this.build()\n return this\n } else if (Object.keys(bufferParams).length || Object.keys(what).length) {\n lazyProps.bufferParams = {}\n lazyProps.what = {}\n this.updateParameters(bufferParams, what)\n }\n }\n\n this.bufferList.forEach(function (buffer) {\n buffer.setVisibility(value)\n })\n\n if (!noRenderRequest) this.viewer.requestRender()\n\n return this\n }\n\n /**\n * Set the visibility of the representation\n * @param {RepresentationParameters} params - parameters object\n * @param {Object} [what] - buffer data attributes to be updated,\n * note that this needs to be implemented in the\n * derived classes. Generally it allows more\n * fine-grained control over updating than\n * forcing a rebuild.\n * @param {Boolean} what.position - update position data\n * @param {Boolean} what.color - update color data\n * @param {Boolean} [rebuild] - whether or not to rebuild the representation\n * @return {Representation} this object\n */\n setParameters (params: Partial, what:{[propName: string]: any} = {}, rebuild = false) {\n const p = params || {}\n const tp = this.parameters\n const bufferParams: BufferParameters = {}\n\n if (!this.opacity && p.opacity !== undefined) {\n if (this.lazyProps.build) {\n this.lazyProps.build = false\n rebuild = true\n } else {\n Object.assign(bufferParams, this.lazyProps.bufferParams)\n Object.assign(what, this.lazyProps.what)\n this.lazyProps.bufferParams = {}\n this.lazyProps.what = {}\n }\n }\n\n this.setColor(p.color, p)\n\n for (let name in p) {\n if (p[ name ] === undefined) continue\n if (tp[ name ] == undefined ) continue // Skip nulls as well as undefined\n\n if (tp[ name ].int) p[ name ] = parseInt(p[ name ] as string)\n if (tp[ name ].float) p[ name ] = parseFloat(p[ name ] as string)\n\n // no value change\n if (p[ name ] === this[ name ] && (\n !p[ name ].equals || p[ name ].equals(this[ name ])\n )) continue\n\n if (this[ name ] && this[ name ].copy && p[ name ].copy) {\n this[ name ].copy(p[ name ])\n } else if (this[ name ] && this[ name ].set) {\n this[ name ].set(p[ name ])\n } else {\n this[ name ] = p[ name ]\n }\n\n // buffer param\n if (tp[ name ].buffer) {\n if (tp[ name ].buffer === true) {\n (bufferParams[ name as keyof BufferParameters ] as any) = p[ name ]\n } else {\n let key: (keyof BufferParameters) = tp[ name ].buffer;\n (bufferParams[ key ] as any) = p[ name ]\n }\n }\n\n // mark for update\n if (tp[ name ].update) {\n what[ tp[ name ].update ] = true\n }\n\n // mark for rebuild\n if (tp[ name ].rebuild &&\n !(tp[ name ].rebuild === 'impostor' &&\n ExtensionFragDepth && !this.disableImpostor)\n ) {\n rebuild = true\n }\n }\n\n //\n\n if (rebuild) {\n this.build()\n } else {\n this.updateParameters(bufferParams, what)\n }\n\n return this\n }\n\n updateParameters (bufferParams: BufferParameters | {} = {}, what?: any) {\n if (this.lazy && (!this.visible || !this.opacity) && bufferParams.hasOwnProperty('opacity') === false) {\n Object.assign(this.lazyProps.bufferParams, bufferParams)\n Object.assign(this.lazyProps.what, what)\n return\n }\n\n this.bufferList.forEach(function (buffer) {\n buffer.setParameters(bufferParams)\n })\n\n if (Object.keys(what).length) {\n this.update(what) // update buffer attribute\n }\n\n this.viewer.requestRender()\n }\n\n getParameters () {\n const params: Partial = {\n lazy: this.lazy,\n visible: this.visible,\n quality: this.quality\n }\n\n Object.keys(this.parameters).forEach(name => {\n if (this.parameters[ name ] !== null) {\n params[ name ] = this[ name ]\n }\n })\n\n return params\n }\n\n clear () {\n this.bufferList.forEach(buffer => {\n this.viewer.remove(buffer)\n buffer.dispose()\n })\n this.bufferList.length = 0\n\n this.viewer.requestRender()\n }\n\n dispose () {\n this.disposed = true\n this.queue.kill()\n this.tasks.dispose()\n this.clear()\n }\n}\n\nexport default Representation\n","/**\n * @file Worker\n * @author Alexander Rose \n * @private\n */\n\nimport { Log, Debug, WorkerRegistry } from '../globals'\n\nexport default class _Worker {\n\n pending = 0\n postCount = 0\n onmessageDict: { [k: number]: Function|undefined } = {}\n onerrorDict: { [k: number]: Function|undefined } = {}\n\n name: string\n blobUrl: string\n worker: Worker\n\n constructor (name: string) {\n\n this.name = name\n this.blobUrl = window.URL.createObjectURL(WorkerRegistry.get(name))\n this.worker = new Worker(this.blobUrl)\n\n WorkerRegistry.activeWorkerCount += 1\n\n this.worker.onmessage = (event: any) => {\n this.pending -= 1\n const postId = event.data.__postId\n\n if (Debug) Log.timeEnd('Worker.postMessage ' + name + ' #' + postId)\n\n const onmessage = this.onmessageDict[ postId ]\n if (onmessage) {\n onmessage.call(this.worker, event)\n } else {\n // Log.debug('No onmessage', postId, name)\n }\n\n delete this.onmessageDict[ postId ]\n delete this.onerrorDict[ postId ]\n }\n\n this.worker.onerror = (event: any) => {\n this.pending -= 1\n if (event.data) {\n const postId = event.data.__postId\n\n const onerror = this.onerrorDict[ postId ]\n if (onerror) {\n onerror.call(this.worker, event)\n } else {\n Log.error('Worker.onerror', postId, name, event)\n }\n\n delete this.onmessageDict[ postId ]\n delete this.onerrorDict[ postId ]\n } else {\n Log.error('Worker.onerror', name, event)\n }\n }\n }\n\n post (aMessage: any = {}, transferList?: any, onmessage?: Function, onerror?: Function) {\n this.onmessageDict[ this.postCount ] = onmessage\n this.onerrorDict[ this.postCount ] = onerror\n\n aMessage.__name = this.name\n aMessage.__postId = this.postCount\n aMessage.__debug = Debug\n\n if (Debug) Log.time(`Worker.postMessage ${this.name} #${this.postCount}`)\n\n try {\n this.worker.postMessage(aMessage, transferList)\n } catch (error) {\n Log.error('worker.post:', error)\n this.worker.postMessage(aMessage)\n }\n\n this.pending += 1\n this.postCount += 1\n\n return this\n }\n\n terminate () {\n if (this.worker) {\n this.worker.terminate()\n window.URL.revokeObjectURL(this.blobUrl)\n WorkerRegistry.activeWorkerCount -= 1\n } else {\n Log.log('no worker to terminate')\n }\n }\n}\n","/**\n * @file Worker Pool\n * @author Alexander Rose \n * @private\n */\n\nimport Worker from './worker'\n\nclass WorkerPool {\n maxCount: number\n pool: Worker[] = []\n count = 0\n name: string\n\n constructor (name: string, maxCount = 2) {\n this.maxCount = Math.min(8, maxCount)\n this.name = name\n }\n\n post (aMessage: any = {}, transferList?: any, onmessage?: Function, onerror?: Function) {\n const worker = this.getNextWorker()\n if (worker) {\n worker.post(aMessage, transferList, onmessage, onerror)\n } else {\n console.error('unable to get worker from pool')\n }\n\n return this\n }\n\n terminate () {\n this.pool.forEach(function (worker) {\n worker.terminate()\n })\n }\n\n getNextWorker () {\n let nextWorker\n let minPending = Infinity\n\n for (let i = 0; i < this.maxCount; ++i) {\n if (i >= this.count) {\n nextWorker = new Worker(this.name)\n this.pool.push(nextWorker)\n this.count += 1\n break\n }\n\n const worker = this.pool[ i ]\n\n if (worker.pending === 0) {\n nextWorker = worker\n break\n } else if (worker.pending < minPending) {\n minPending = worker.pending\n nextWorker = worker\n }\n }\n\n return nextWorker\n }\n}\n\nWorkerPool.prototype.constructor = WorkerPool\n\nexport default WorkerPool\n","/**\n * @file Vector Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { NumberArray } from '../types'\nimport { EPS } from './math-constants'\n\n/**\n * Calculate the two intersection points\n * Converted to JavaScript from\n * {@link http://paulbourke.net/geometry/pointlineplane/lineline.c}\n */\nexport function lineLineIntersect (p1: Vector3, p2: Vector3, p3: Vector3, p4: Vector3) {\n const p13 = new Vector3()\n const p43 = new Vector3()\n const p21 = new Vector3()\n let d1343, d4321, d1321, d4343, d2121\n let denom, numer\n\n p13.x = p1.x - p3.x\n p13.y = p1.y - p3.y\n p13.z = p1.z - p3.z\n p43.x = p4.x - p3.x\n p43.y = p4.y - p3.y\n p43.z = p4.z - p3.z\n if (Math.abs(p43.x) < EPS && Math.abs(p43.y) < EPS && Math.abs(p43.z) < EPS) { return null }\n\n p21.x = p2.x - p1.x\n p21.y = p2.y - p1.y\n p21.z = p2.z - p1.z\n if (Math.abs(p21.x) < EPS && Math.abs(p21.y) < EPS && Math.abs(p21.z) < EPS) { return null }\n\n d1343 = p13.x * p43.x + p13.y * p43.y + p13.z * p43.z\n d4321 = p43.x * p21.x + p43.y * p21.y + p43.z * p21.z\n d1321 = p13.x * p21.x + p13.y * p21.y + p13.z * p21.z\n d4343 = p43.x * p43.x + p43.y * p43.y + p43.z * p43.z\n d2121 = p21.x * p21.x + p21.y * p21.y + p21.z * p21.z\n\n denom = d2121 * d4343 - d4321 * d4321\n if (Math.abs(denom) < EPS) { return null }\n numer = d1343 * d4321 - d1321 * d4343\n\n const mua = numer / denom\n const mub = (d1343 + d4321 * mua) / d4343\n\n const pa = new Vector3(\n p1.x + mua * p21.x,\n p1.y + mua * p21.y,\n p1.z + mua * p21.z\n )\n const pb = new Vector3(\n p3.x + mub * p43.x,\n p3.y + mub * p43.y,\n p3.z + mub * p43.z\n )\n\n return [ pa, pb ]\n}\n\nexport function calculateMeanVector3 (array: NumberArray) {\n const n = array.length\n const m = n / 3\n\n let x = 0\n let y = 0\n let z = 0\n\n for (let i = 0; i < n; i += 3) {\n x += array[ i + 0 ]\n y += array[ i + 1 ]\n z += array[ i + 2 ]\n }\n\n return new Vector3(x / m, y / m, z / m)\n}\n\nexport function isPointOnSegment (p: Vector3, l1: Vector3, l2: Vector3) {\n const len = l1.distanceTo(l2)\n\n return p.distanceTo(l1) <= len && p.distanceTo(l2) <= len\n}\n\nexport function projectPointOnVector (point: Vector3, vector: Vector3, origin?: Vector3) {\n if (origin) {\n point.sub(origin).projectOnVector(vector).add(origin)\n } else {\n point.projectOnVector(vector)\n }\n\n return point\n}\n\nexport function computeBoundingBox (array: NumberArray) {\n let minX = +Infinity\n let minY = +Infinity\n let minZ = +Infinity\n let maxX = -Infinity\n let maxY = -Infinity\n let maxZ = -Infinity\n for (let i = 0, l = array.length; i < l; i += 3) {\n const x = array[ i ]\n const y = array[ i + 1 ]\n const z = array[ i + 2 ]\n if (x < minX) minX = x\n if (y < minY) minY = y\n if (z < minZ) minZ = z\n if (x > maxX) maxX = x\n if (y > maxY) maxY = y\n if (z > maxZ) maxZ = z\n }\n return [\n v3new([ minX, minY, minZ ]),\n v3new([ maxX, maxY, maxZ ])\n ]\n}\n(computeBoundingBox as any).__deps = [ v3new ]\n\nexport function applyMatrix4toVector3array (m: Float32Array, a: Float32Array) {\n for (let i = 0, il = a.length; i < il; i += 3) {\n const x = a[ i ]\n const y = a[ i + 1 ]\n const z = a[ i + 2 ]\n a[ i ] = m[ 0 ] * x + m[ 4 ] * y + m[ 8 ] * z + m[ 12 ]\n a[ i + 1 ] = m[ 1 ] * x + m[ 5 ] * y + m[ 9 ] * z + m[ 13 ]\n a[ i + 2 ] = m[ 2 ] * x + m[ 6 ] * y + m[ 10 ] * z + m[ 14 ]\n }\n}\n\nexport function applyMatrix3toVector3array (m: Float32Array, a: Float32Array) {\n for (let i = 0, il = a.length; i < il; i += 3) {\n const x = a[ i ]\n const y = a[ i + 1 ]\n const z = a[ i + 2 ]\n a[ i ] = m[ 0 ] * x + m[ 3 ] * y + m[ 6 ] * z\n a[ i + 1 ] = m[ 1 ] * x + m[ 4 ] * y + m[ 7 ] * z\n a[ i + 2 ] = m[ 2 ] * x + m[ 5 ] * y + m[ 8 ] * z\n }\n}\n\nexport function normalizeVector3array (a: Float32Array) {\n for (let i = 0, il = a.length; i < il; i += 3) {\n const x = a[ i ]\n const y = a[ i + 1 ]\n const z = a[ i + 2 ]\n const len2 = x * x + y * y + z * z\n if (len2 > 0) { // avoid divide by zero\n const s = 1 / Math.sqrt(len2)\n a[ i ] = x * s\n a[ i + 1 ] = y * s\n a[ i + 2 ] = z * s\n }\n // else leave as all zeros\n }\n}\n\nexport function v3new (array?: NumberArray) {\n return new Float32Array(array as any || 3) // TODO\n}\n\nexport function v3cross (out: Float32Array, a: Float32Array, b: Float32Array) {\n const ax = a[0]\n const ay = a[1]\n const az = a[2]\n const bx = b[0]\n const by = b[1]\n const bz = b[2]\n out[0] = ay * bz - az * by\n out[1] = az * bx - ax * bz\n out[2] = ax * by - ay * bx\n}\n\nexport function v3dot (a: Float32Array, b: Float32Array) {\n return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]\n}\n\nexport function v3sub (out: Float32Array, a: Float32Array, b: Float32Array) {\n out[0] = a[0] - b[0]\n out[1] = a[1] - b[1]\n out[2] = a[2] - b[2]\n}\n\nexport function v3add (out: Float32Array, a: Float32Array, b: Float32Array) {\n out[0] = a[0] + b[0]\n out[1] = a[1] + b[1]\n out[2] = a[2] + b[2]\n}\n\nexport function v3fromArray (out: Float32Array, array: Float32Array, offset = 0) {\n out[0] = array[offset]\n out[1] = array[offset + 1]\n out[2] = array[offset + 2]\n}\n\nexport function v3toArray (input: Float32Array, array: Float32Array, offset = 0) {\n array[offset] = input[0]\n array[offset + 1] = input[1]\n array[offset + 2] = input[2]\n}\n\nexport function v3forEach (array: Float32Array, fn: (i: Float32Array, j: Float32Array, k: Float32Array) => void, b: Float32Array) {\n const a = v3new()\n for (let i = 0, n = array.length; i < n; i += 3) {\n v3fromArray(a, array, i)\n fn(a, a, b)\n v3toArray(a, array, i)\n }\n}\n(v3forEach as any).__deps = [ v3new, v3fromArray, v3toArray ]\n\nexport function v3length2 (a: Float32Array) {\n return a[0] * a[0] + a[1] * a[1] + a[2] * a[2]\n}\n\nexport function v3length (a: Float32Array) {\n return Math.sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2])\n}\n\nexport function v3divide (out: Float32Array, a: Float32Array, b: Float32Array) {\n out[0] = a[0] / b[0]\n out[1] = a[1] / b[1]\n out[2] = a[2] / b[2]\n}\n\nexport function v3multiply (out: Float32Array, a: Float32Array, b: Float32Array) {\n out[0] = a[0] * b[0]\n out[1] = a[1] * b[1]\n out[2] = a[2] * b[2]\n}\n\nexport function v3divideScalar (out: Float32Array, a: Float32Array, s: number) {\n v3multiplyScalar(out, a, 1 / s)\n}\n(v3divideScalar as any).__deps = [ v3multiplyScalar ]\n\nexport function v3multiplyScalar (out: Float32Array, a: Float32Array, s: number) {\n out[0] = a[0] * s\n out[1] = a[1] * s\n out[2] = a[2] * s\n}\n\nexport function v3normalize (out: Float32Array, a: Float32Array) {\n const length2 = v3length2(a)\n if (length2 == 0) {\n out[0] = a[0]\n out[1] = a[1]\n out[2] = a[2]\n } else {\n v3multiplyScalar(out, a, 1 / Math.sqrt(length2))\n }\n}\n(v3normalize as any).__deps = [ v3multiplyScalar, v3length2 ]\n\nexport function v3subScalar (out: Float32Array, a: Float32Array, s: number) {\n out[0] = a[0] - s\n out[1] = a[1] - s\n out[2] = a[2] - s\n}\n\nexport function v3addScalar (out: Float32Array, a: Float32Array, s: number) {\n out[0] = a[0] + s\n out[1] = a[1] + s\n out[2] = a[2] + s\n}\n\nexport function v3floor (out: Float32Array, a: Float32Array) {\n out[0] = Math.floor(a[0])\n out[1] = Math.floor(a[1])\n out[2] = Math.floor(a[2])\n}\n\nexport function v3ceil (out: Float32Array, a: Float32Array) {\n out[0] = Math.ceil(a[0])\n out[1] = Math.ceil(a[1])\n out[2] = Math.ceil(a[2])\n}\n\nexport function v3round (out: Float32Array, a: Float32Array) {\n out[0] = Math.round(a[0])\n out[1] = Math.round(a[1])\n out[2] = Math.round(a[2])\n}\n\nexport function v3negate (out: Float32Array, a: Float32Array) {\n out[0] = -a[0]\n out[1] = -a[1]\n out[2] = -a[2]\n}\n\nexport function v3angle (a: Float32Array, b: Float32Array) {\n const ax = a[0]\n const ay = a[1]\n const az = a[2]\n const bx = b[0]\n const by = b[1]\n const bz = b[2]\n const cx = ay * bz - az * by\n const cy = az * bx - ax * bz\n const cz = ax * by - ay * bx\n const s = Math.sqrt(cx * cx + cy * cy + cz * cz)\n const c = ax * bx + ay * by + az * bz\n return Math.atan2(s, c)\n}\n","/**\n * @file Dash\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport { WideLineBufferData } from '../buffer/wideline-buffer'\nimport {\n calculateDirectionArray, calculateCenterArray,\n replicateArrayEntries, replicateArray3Entries\n} from '../math/array-utils'\n\nexport function getFixedCountDashData (data: T, segmentCount: number = 9) {\n\n const s = Math.floor(segmentCount / 2)\n const n = data.position1.length / 3\n const sn = s * n\n const sn3 = sn * 3\n const step = 1 / segmentCount\n\n const direction = calculateDirectionArray(data.position1, data.position2)\n const position1 = new Float32Array(sn3)\n const position2 = new Float32Array(sn3)\n\n const v = new Vector3()\n\n for (let i = 0; i < n; ++i) {\n const i3 = i * 3\n v.set(direction[ i3 ], direction[ i3 + 1 ], direction[ i3 + 2 ])\n\n const x = data.position1[ i3 ]\n const y = data.position1[ i3 + 1 ]\n const z = data.position1[ i3 + 2 ]\n\n for (let j = 0; j < s; ++j) {\n const j3 = s * i3 + j * 3\n\n const f1 = step * (j * 2 + 1)\n const f2 = step * (j * 2 + 2)\n\n position1[ j3 ] = x + v.x * f1\n position1[ j3 + 1 ] = y + v.y * f1\n position1[ j3 + 2 ] = z + v.z * f1\n\n position2[ j3 ] = x + v.x * f2\n position2[ j3 + 1 ] = y + v.y * f2\n position2[ j3 + 2 ] = z + v.z * f2\n }\n }\n\n const position = calculateCenterArray(position1, position2) as Float32Array\n const color = replicateArray3Entries(data.color!, s) // TODO\n const color2 = color\n\n const d: any = { position, position1, position2, color, color2 }\n\n if ((data as any).radius) { // TODO\n d.radius = replicateArrayEntries((data as any).radius, s) // TODO\n }\n\n if (data.picking && data.picking.array) {\n data.picking.array = replicateArrayEntries(data.picking.array, s)\n d.picking = data.picking\n }\n if (data.primitiveId) {\n d.primitiveId = replicateArrayEntries(data.primitiveId, s)\n }\n\n return d as T\n}\n\nexport function getFixedLengthDashData (data: T, segmentLength: number = 0.1) {\n\n const direction = calculateDirectionArray(data.position1, data.position2)\n const pos1: number[] = []\n const pos2: number[] = []\n const col: number[] = []\n const rad: number[]|undefined = (data as any).radius ? [] : undefined\n const pick: number[]|undefined = (data as any).picking ? [] : undefined\n const id: number[]|undefined = (data as any).primitiveId ? [] : undefined\n\n const v = new Vector3()\n const n = data.position1.length / 3\n\n let k = 0\n\n for (let i = 0; i < n; ++i) {\n const i3 = i * 3\n v.set(direction[ i3 ], direction[ i3 + 1 ], direction[ i3 + 2 ])\n\n const vl = v.length()\n const segmentCount = vl / segmentLength\n const s = Math.floor(segmentCount / 2)\n const step = 1 / segmentCount\n\n const x = data.position1[ i3 ]\n const y = data.position1[ i3 + 1 ]\n const z = data.position1[ i3 + 2 ]\n\n for (let j = 0; j < s; ++j) {\n const j3 = k * 3 + j * 3\n\n const f1 = step * (j * 2 + 1)\n const f2 = step * (j * 2 + 2)\n\n pos1[ j3 ] = x + v.x * f1\n pos1[ j3 + 1 ] = y + v.y * f1\n pos1[ j3 + 2 ] = z + v.z * f1\n\n pos2[ j3 ] = x + v.x * f2\n pos2[ j3 + 1 ] = y + v.y * f2\n pos2[ j3 + 2 ] = z + v.z * f2\n\n if (data.color) {\n col[ j3 ] = data.color[ i3 ]\n col[ j3 + 1 ] = data.color[ i3 + 1 ]\n col[ j3 + 2 ] = data.color[ i3 + 2 ]\n }\n\n if (rad) rad[ k + j ] = (data as any).radius[ i ]\n if (pick) {\n if ((data as any).picking.array) {\n pick[ k + j ] = (data as any).picking.array[ i ]\n } else {\n pick[ k + j ] = i\n }\n }\n if (id) id[ k + j ] = (data as any).primitiveId[ i ]\n }\n\n k += s\n }\n\n const position1 = new Float32Array(pos1)\n const position2 = new Float32Array(pos2)\n const position = calculateCenterArray(position1, position2) as Float32Array\n const color = new Float32Array(col)\n const color2 = color\n\n const d: any = { position, position1, position2, color, color2 }\n\n if (rad) d.radius = new Float32Array(rad)\n if (pick && data.picking) {\n data.picking.array = new Float32Array(pick)\n d.picking = data.picking\n }\n if (id) d.primitiveId = new Float32Array(id)\n\n return d as T\n}\n\nexport function getFixedLengthWrappedDashData (data: T, segmentLength: number = 0.1) {\n\n const direction = calculateDirectionArray(data.position1, data.position2)\n const pos1: number[] = []\n const pos2: number[] = []\n const col: number[] = []\n const rad: number[]|undefined = (data as any).radius ? [] : undefined\n const pick: number[]|undefined = (data as any).picking ? [] : undefined\n const id: number[]|undefined = (data as any).primitiveId ? [] : undefined\n\n const v = new Vector3()\n const n = data.position1.length / 3\n\n let remaining = segmentLength\n let drawing = true\n\n let k = 0\n let k3 = 0\n let kprev = 0\n\n for (let i = 0; i < n; ++i) {\n const i3 = i * 3\n const x = data.position1[ i3 ]\n const y = data.position1[ i3 + 1 ]\n const z = data.position1[ i3 + 2 ]\n\n v.set(direction[ i3 ], direction[ i3 + 1 ], direction[ i3 + 2 ])\n const vl = v.length()\n\n if (drawing) {\n pos1[ k3 ] = x\n pos1[ k3 + 1 ] = y\n pos1[ k3 + 2 ] = z\n }\n\n let dist = remaining\n const inv = 1 / vl\n while (dist < vl) {\n const a = drawing ? pos2 : pos1\n a[ k3 ] = x + v.x * dist * inv\n a[ k3 + 1 ] = y + v.y * dist * inv\n a[ k3 + 2 ] = z + v.z * dist * inv\n if (drawing) {\n k++\n k3 = k * 3\n }\n drawing = !drawing\n remaining = segmentLength\n dist += segmentLength\n }\n\n if (drawing) {\n pos2[ k3 ] = data.position2[ i3 ]\n pos2[ k3 + 1 ] = data.position2[ i3 + 1 ]\n pos2[ k3 + 2 ] = data.position2[ i3 + 2 ]\n k++\n k3 = k * 3\n }\n\n remaining = dist - vl\n\n for (let j = kprev; j < k ; j++){\n if (data.color) {\n const j3 = j * 3\n col[ j3 ] = data.color[ i3 ]\n col[ j3 + 1 ] = data.color[ i3 + 1 ]\n col[ j3 + 2 ] = data.color[ i3 + 2 ]\n }\n\n if (rad) rad[ j ] = (data as any).radius[ i ]\n if (pick) {\n if ((data as any).picking.array) {\n pick[ j ] = (data as any).picking.array[ i ]\n } else {\n pick[ j ] = i\n }\n }\n if (id) id[ j ] = (data as any).primitiveId[ i ]\n }\n\n kprev = k\n\n }\n\n if (!drawing && n > 0) {\n const k3 = k * 3\n pos2[ k3 ] = data.position2[ 3 * n - 3 ]\n pos2[ k3 + 1 ] = data.position2[ 3 * n - 2 ]\n pos2[ k3 + 1 ] = data.position2[ 3 * n - 1 ]\n }\n\n const position1 = new Float32Array(pos1)\n const position2 = new Float32Array(pos2)\n const position = calculateCenterArray(position1, position2) as Float32Array\n const color = new Float32Array(col)\n const color2 = color\n\n const d: any = { position, position1, position2, color, color2 }\n\n if (rad) d.radius = new Float32Array(rad)\n if (pick && data.picking) {\n data.picking.array = new Float32Array(pick)\n d.picking = data.picking\n }\n if (id) d.primitiveId = new Float32Array(id)\n\n return d as T\n}\n","/**\n * @file Primitive\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Color, Box3 } from 'three'\n\nimport { BufferRegistry, PickerRegistry } from '../globals'\nimport Shape from './shape'\nimport { getFixedLengthDashData } from './dash'\n\nfunction addElement (elm: any, array: any[]) {\n if (elm.toArray !== undefined) {\n elm = elm.toArray()\n } else if (elm.x !== undefined) {\n elm = [ elm.x, elm.y, elm.z ]\n } else if (elm.r !== undefined) {\n elm = [ elm.r, elm.g, elm.b ]\n }\n array.push.apply(array, elm)\n}\n\nconst tmpVec = new Vector3()\n\nexport type PrimitiveFields = { [k: string]: string }\n\n/**\n * Base class for geometry primitives\n * @interface\n */\nexport abstract class Primitive {\n static type = ''\n static fields: PrimitiveFields = {}\n\n static get Picker () { return PickerRegistry.get(this.type) }\n static get Buffer () { return BufferRegistry.get(this.type) }\n\n static getShapeKey (name: string) {\n return this.type + name[0].toUpperCase() + name.substr(1)\n }\n\n static expandBoundingBox (box: Box3, data: any) {}\n\n static valueToShape (shape: Shape, name: string, value: any) {\n const data = shape._primitiveData[this.getShapeKey(name)]\n const type = this.fields[name]\n\n switch (type) {\n case 'v3':\n case 'c':\n addElement(value, data)\n break\n default:\n data.push(value)\n }\n }\n\n static objectToShape (shape: Shape, data: any) {\n Object.keys(this.fields).forEach(name => {\n this.valueToShape(shape, name, data[name])\n })\n this.valueToShape(shape, 'name', data.name)\n this.expandBoundingBox(shape.boundingBox, data)\n }\n\n static valueFromShape (shape: Shape, pid: number, name: string) {\n const data = shape._primitiveData[this.getShapeKey(name)]\n const type = this.fields[name]\n\n switch (type) {\n case 'v3':\n return new Vector3().fromArray(data, 3 * pid)\n case 'c':\n return new Color().fromArray(data, 3 * pid)\n default:\n return data[pid]\n }\n }\n\n static objectFromShape (shape: Shape, pid: number) {\n let name = this.valueFromShape(shape, pid, 'name')\n if (name === undefined) {\n name = `${this.type}: ${pid} (${shape.name})`\n }\n const o: any = { shape, name }\n\n Object.keys(this.fields).forEach(name => {\n o[name] = this.valueFromShape(shape, pid, name)\n })\n\n return o\n }\n\n static arrayFromShape (shape: Shape, name: string) {\n const data = shape._primitiveData[this.getShapeKey(name)]\n const type = this.fields[name]\n\n switch (type) {\n case 's':\n return data\n default:\n return new Float32Array(data)\n }\n }\n\n static dataFromShape (shape: Shape) {\n const data: any = {}\n\n if (this.Picker) {\n data.picking = new this.Picker(shape)\n }\n\n Object.keys(this.fields).forEach(name => {\n data[name] = this.arrayFromShape(shape, name)\n })\n\n return data\n }\n\n static bufferFromShape (shape: Shape, params: any) {\n return new this.Buffer(this.dataFromShape(shape), params)\n }\n}\n\n/**\n * Sphere geometry primitive\n */\nexport class SpherePrimitive extends Primitive {\n static type = 'sphere'\n\n static fields = {\n position: 'v3',\n color: 'c',\n radius: 'f'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n return this.valueFromShape(shape, pid, 'position')\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position))\n }\n}\n\n/**\n * Box geometry primitive\n */\nexport class BoxPrimitive extends Primitive {\n static type = 'box'\n\n static fields = {\n position: 'v3',\n color: 'c',\n size: 'f',\n heightAxis: 'v3',\n depthAxis: 'v3'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n return this.valueFromShape(shape, pid, 'position')\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position))\n }\n}\n\n/**\n * Octahedron geometry primitive\n */\nexport class OctahedronPrimitive extends BoxPrimitive {\n static type = 'octahedron'\n}\n\n/**\n * Tetrahedron geometry primitive\n */\nexport class TetrahedronPrimitive extends BoxPrimitive {\n static type = 'tetrahedron'\n}\n\n/**\n * Cylinder geometry primitive\n */\nexport class CylinderPrimitive extends Primitive {\n static type = 'cylinder'\n\n static fields = {\n position1: 'v3',\n position2: 'v3',\n color: 'c',\n radius: 'f'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n const p1 = this.valueFromShape(shape, pid, 'position1')\n const p2 = this.valueFromShape(shape, pid, 'position2')\n return p1.add(p2).multiplyScalar(0.5)\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position1))\n box.expandByPoint(tmpVec.fromArray(data.position2))\n }\n\n static bufferFromShape (shape: Shape, params: any = {}) {\n let data = this.dataFromShape(shape)\n if (this.type === 'cylinder' && params.dashedCylinder) {\n data = getFixedLengthDashData(data)\n }\n return new this.Buffer(data, params)\n }\n}\n\n/**\n * Arrow geometry primitive\n */\nexport class ArrowPrimitive extends CylinderPrimitive {\n static type = 'arrow'\n}\n\n/**\n * Cone geometry primitive\n */\nexport class ConePrimitive extends CylinderPrimitive {\n static type = 'cone'\n}\n\n/**\n * Ellipsoid geometry primitive\n */\nexport class EllipsoidPrimitive extends SpherePrimitive {\n static type = 'ellipsoid'\n\n static fields = {\n position: 'v3',\n color: 'c',\n radius: 'f',\n majorAxis: 'v3',\n minorAxis: 'v3'\n }\n}\n\n/**\n * Torus geometry primitive\n */\nexport class TorusPrimitive extends EllipsoidPrimitive {\n static type = 'torus'\n}\n\n/**\n * Text geometry primitive\n */\nexport class TextPrimitive extends Primitive {\n static type = 'text'\n\n static fields = {\n position: 'v3',\n color: 'c',\n size: 'f',\n text: 's'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n return this.valueFromShape(shape, pid, 'position')\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position))\n }\n}\n\n/**\n * Point primitive\n */\nexport class PointPrimitive extends Primitive {\n static type = 'point'\n\n static fields = {\n position: 'v3',\n color: 'c',\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n return this.valueFromShape(shape, pid, 'position')\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position))\n }\n}\n\n/**\n * Wideline geometry primitive\n */\nexport class WidelinePrimitive extends Primitive {\n static type = 'wideline'\n\n static fields = {\n position1: 'v3',\n position2: 'v3',\n color: 'c'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n const p1 = this.valueFromShape(shape, pid, 'position1')\n const p2 = this.valueFromShape(shape, pid, 'position2')\n return p1.add(p2).multiplyScalar(0.5)\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position1))\n box.expandByPoint(tmpVec.fromArray(data.position2))\n }\n}\n","/**\n * @file Spatial Hash\n * @author Alexander Rose \n * @private\n */\n\nimport { Box3 } from 'three'\n\nexport type Positions = {\n x: ArrayLike,\n y: ArrayLike,\n z: ArrayLike,\n count?:number\n}\n\nfunction createBoundingBox(positions: Positions) {\n const { x, y, z } = positions\n const boundingBox = new Box3()\n const count = x.length\n const { min, max } = boundingBox\n\n for (let i = 0; i < count; i++) {\n min.x = Math.min(x[i], min.x)\n min.y = Math.min(y[i], min.y)\n min.z = Math.min(z[i], min.z)\n max.x = Math.max(x[i], max.x)\n max.y = Math.max(y[i], max.y)\n max.z = Math.max(z[i], max.z)\n }\n\n return boundingBox\n}\n\nexport default class SpatialHash {\n exp = 3\n\n minX: number\n minY: number\n minZ: number\n\n boundX: number\n boundY: number\n boundZ: number\n\n grid: Uint32Array\n bucketCount: Uint16Array\n bucketOffset: Uint32Array\n bucketArray: Int32Array\n\n xArray: ArrayLike\n yArray: ArrayLike\n zArray: ArrayLike\n\n constructor(positions: Positions, boundingBox?: Box3) {\n const bb = boundingBox || createBoundingBox(positions)\n this.minX = bb.min.x\n this.minY = bb.min.y\n this.minZ = bb.min.z\n this.boundX = ((bb.max.x - this.minX) >> this.exp) + 1\n this.boundY = ((bb.max.y - this.minY) >> this.exp) + 1\n this.boundZ = ((bb.max.z - this.minZ) >> this.exp) + 1\n\n const n = this.boundX * this.boundY * this.boundZ\n const an = (positions.count !== undefined) ? positions.count : positions.x.length\n\n const xArray = positions.x\n const yArray = positions.y\n const zArray = positions.z\n\n let count = 0\n const grid = new Uint32Array(n)\n const bucketIndex = new Int32Array(an)\n for (let i = 0; i < an; ++i) {\n const x = (xArray[ i ] - this.minX) >> this.exp\n const y = (yArray[ i ] - this.minY) >> this.exp\n const z = (zArray[ i ] - this.minZ) >> this.exp\n const idx = (((x * this.boundY) + y) * this.boundZ) + z\n if ((grid[ idx ] += 1) === 1) {\n count += 1\n }\n bucketIndex[ i ] = idx\n }\n\n const bucketCount = new Uint16Array(count)\n for (let i = 0, j = 0; i < n; ++i) {\n const c = grid[ i ]\n if (c > 0) {\n grid[ i ] = j + 1\n bucketCount[ j ] = c\n j += 1\n }\n }\n\n const bucketOffset = new Uint32Array(count)\n for (let i = 1; i < count; ++i) {\n bucketOffset[ i ] += bucketOffset[ i - 1 ] + bucketCount[ i - 1 ]\n }\n\n const bucketFill = new Uint16Array(count)\n const bucketArray = new Int32Array(an)\n for (let i = 0; i < an; ++i) {\n const bucketIdx = grid[ bucketIndex[ i ] ]\n if (bucketIdx > 0) {\n const k = bucketIdx - 1\n bucketArray[ bucketOffset[ k ] + bucketFill[ k ] ] = i\n bucketFill[ k ] += 1\n }\n }\n\n this.grid = grid\n this.bucketCount = bucketCount\n this.bucketOffset = bucketOffset\n this.bucketArray = bucketArray\n\n this.xArray = xArray\n this.yArray = yArray\n this.zArray = zArray\n }\n\n within (x: number, y: number, z: number, r: number) {\n const result: number[] = []\n\n this.eachWithin(x, y, z, r, atomIndex => result.push(atomIndex))\n\n return result\n }\n\n eachWithin (x: number, y: number, z: number, r: number, callback: (atomIndex: number, dSq: number) => void) {\n const rSq = r * r\n\n const loX = Math.max(0, (x - r - this.minX) >> this.exp)\n const loY = Math.max(0, (y - r - this.minY) >> this.exp)\n const loZ = Math.max(0, (z - r - this.minZ) >> this.exp)\n\n const hiX = Math.min(this.boundX, ((x + r - this.minX) >> this.exp) + 1)\n const hiY = Math.min(this.boundY, ((y + r - this.minY) >> this.exp) + 1)\n const hiZ = Math.min(this.boundZ, ((z + r - this.minZ) >> this.exp) + 1)\n\n for (let ix = loX; ix < hiX; ++ix) {\n for (let iy = loY; iy < hiY; ++iy) {\n for (let iz = loZ; iz < hiZ; ++iz) {\n const idx = (((ix * this.boundY) + iy) * this.boundZ) + iz\n const bucketIdx = this.grid[ idx ]\n\n if (bucketIdx > 0) {\n const k = bucketIdx - 1\n const offset = this.bucketOffset[ k ]\n const count = this.bucketCount[ k ]\n const end = offset + count\n\n for (let i = offset; i < end; ++i) {\n const atomIndex = this.bucketArray[ i ]\n const dx = this.xArray[ atomIndex ] - x\n const dy = this.yArray[ atomIndex ] - y\n const dz = this.zArray[ atomIndex ] - z\n\n const dSq = dx * dx + dy * dy + dz * dz\n if (dSq <= rSq) callback(atomIndex, dSq)\n }\n }\n }\n }\n }\n }\n}","/**\n * @file Store\n * @author Alexander Rose \n * @private\n */\n\nimport { Log } from '../globals'\nimport { getTypedArray, TypedArrayString } from '../utils'\n\nexport type StoreField = [string, number, TypedArrayString]\n\n/**\n * Store base class\n * @interface\n */\nexport default class Store {\n [k: string]: any\n\n length: number\n count: number\n\n _fields: StoreField[]\n get _defaultFields(): StoreField[] { return [] }\n\n /**\n * @param {Integer} [size] - initial size\n */\n constructor (size = 0) {\n this._fields = this._defaultFields\n this._init(0)\n }\n\n /**\n * Initialize the store\n * @param {Integer} size - size to initialize\n * @return {undefined}\n */\n _init (size: number) {\n this.length = size\n this.count = 0\n\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const [name, size, type]: StoreField = this._fields[ i ]\n this._initField(name, size, type)\n }\n }\n\n /**\n * Initialize a field\n * @param {String} name - field name\n * @param {Integer} size - element size\n * @param {String} type - data type, one of int8, int16, int32,\n * uint8, uint16, uint32, float32\n * @return {undefined}\n */\n _initField (name: string, size: number, type: TypedArrayString) {\n this[ name ] = getTypedArray(type, this.length * size)\n }\n\n /**\n * Add a field\n * @param {String} name - field name\n * @param {Integer} size - element size\n * @param {String} type - data type, one of int8, int16, int32,\n * uint8, uint16, uint32, float32\n * @return {undefined}\n */\n addField (name: string, size: number, type: TypedArrayString) {\n this._fields.push([name, size, type])\n this._initField(name, size, type)\n }\n\n /**\n * Resize the store to the new size\n * @param {Integer} size - new size\n * @return {undefined}\n */\n resize (size?: number) {\n // Log.time( \"Store.resize\" );\n\n this.length = Math.round(size || 0)\n this.count = Math.min(this.count, this.length)\n\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const name = this._fields[ i ][ 0 ]\n const itemSize = this._fields[ i ][ 1 ]\n const arraySize = this.length * itemSize\n const tmpArray = new this[ name ].constructor(arraySize)\n\n if (this[ name ].length > arraySize) {\n tmpArray.set(this[ name ].subarray(0, arraySize))\n } else {\n tmpArray.set(this[ name ])\n }\n this[ name ] = tmpArray\n }\n\n // Log.timeEnd( \"Store.resize\" );\n }\n\n /**\n * Resize the store to 1.5 times its current size if full\n * @return {undefined}\n */\n growIfFull () {\n if (this.count >= this.length) {\n const size = Math.round(this.length * 1.5)\n this.resize(Math.max(256, size))\n }\n }\n\n /**\n * Copy data from one store to another\n * @param {Store} other - store to copy from\n * @param {Integer} thisOffset - offset to start copying to\n * @param {Integer} otherOffset - offset to start copying from\n * @param {Integer} length - number of entries to copy\n * @return {undefined}\n */\n copyFrom (other: Store, thisOffset: number, otherOffset: number, length: number) {\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const name = this._fields[ i ][ 0 ]\n const itemSize = this._fields[ i ][ 1 ]\n const thisField = this[ name ]\n const otherField = other[ name ]\n\n for (let j = 0; j < length; ++j) {\n const thisIndex = itemSize * (thisOffset + j)\n const otherIndex = itemSize * (otherOffset + j)\n for (let k = 0; k < itemSize; ++k) {\n thisField[ thisIndex + k ] = otherField[ otherIndex + k ]\n }\n }\n }\n }\n\n /**\n * Copy data within this store\n * @param {Integer} thisOffset - offset to start copying to\n * @param {Integer} otherOffset - offset to start copying from\n * @param {Integer} length - number of entries to copy\n * @return {undefined}\n */\n copyWithin (offsetTarget: number, offsetSource: number, length: number) {\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const name = this._fields[ i ][ 0 ]\n const itemSize = this._fields[ i ][ 1 ]\n const thisField = this[ name ]\n\n for (let j = 0; j < length; ++j) {\n const targetIndex = itemSize * (offsetTarget + j)\n const sourceIndex = itemSize * (offsetSource + j)\n for (let k = 0; k < itemSize; ++k) {\n thisField[ targetIndex + k ] = thisField[ sourceIndex + k ]\n }\n }\n }\n }\n\n /**\n * Sort entries in the store given the compare function\n * @param {[type]} compareFunction - function to sort by\n * @return {undefined}\n */\n sort (compareFunction: (a: any, b: any) => number) {\n Log.time('Store.sort')\n\n const thisStore = this\n const tmpStore = new (this.constructor as any)(1)\n\n function swap (index1: number, index2: number) {\n if (index1 === index2) return\n tmpStore.copyFrom(thisStore, 0, index1, 1)\n thisStore.copyWithin(index1, index2, 1)\n thisStore.copyFrom(tmpStore, index2, 0, 1)\n }\n\n function quicksort (left: number, right: number) {\n if (left < right) {\n let pivot = Math.floor((left + right) / 2)\n let leftNew = left\n let rightNew = right\n do {\n while (compareFunction(leftNew, pivot) < 0) {\n leftNew += 1\n }\n while (compareFunction(rightNew, pivot) > 0) {\n rightNew -= 1\n }\n if (leftNew <= rightNew) {\n if (leftNew === pivot) {\n pivot = rightNew\n } else if (rightNew === pivot) {\n pivot = leftNew\n }\n swap(leftNew, rightNew)\n leftNew += 1\n rightNew -= 1\n }\n } while (leftNew <= rightNew)\n quicksort(left, rightNew)\n quicksort(leftNew, right)\n }\n }\n\n quicksort(0, this.count - 1)\n\n Log.timeEnd('Store.sort')\n }\n\n /**\n * Empty the store\n * @return {undefined}\n */\n clear () {\n this.count = 0\n }\n\n /**\n * Dispose of the store entries and fields\n * @return {undefined}\n */\n dispose () {\n\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const name = this._fields[ i ][ 0 ]\n delete this[ name ]\n }\n }\n}\n","/**\n * @file Contact Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Bond store\n */\nexport default class ContactStore extends Store {\n index1: Uint32Array\n index2: Uint32Array\n type: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'index1', 1, 'int32' ],\n [ 'index2', 1, 'int32' ],\n [ 'type', 1, 'int8' ]\n ] as StoreField[]\n }\n\n addContact (index1: number, index2: number, type?: number) {\n this.growIfFull()\n\n const i = this.count\n\n if (index1 < index2) {\n this.index1[ i ] = index1\n this.index2[ i ] = index2\n } else {\n this.index2[ i ] = index1\n this.index1[ i ] = index2\n }\n if (type) this.type[ i ] = type\n\n this.count += 1\n }\n}","/**\n * @file Bit array\n * @author Alexander Rose \n * @author Paul Pillot \n * @private\n */\n\n/**\n * Compute the Hamming weight of a 32-bit unsigned integer\n * @param {Integer} v - a 32-bit unsigned integer\n * @return {Integer} the Hamming weight\n */\nfunction hammingWeight (v: number) {\n // works with signed or unsigned shifts\n v -= ((v >>> 1) & 0x55555555)\n v = (v & 0x33333333) + ((v >>> 2) & 0x33333333)\n return ((v + (v >>> 4) & 0xF0F0F0F) * 0x1010101) >>> 24\n}\n\n/**\n * Bit array\n *\n * Based heavily on https://github.com/lemire/FastBitSet.js\n * which is licensed under the Apache License, Version 2.0.\n */\nexport default class BitArray {\n private _words: Uint32Array\n public length: number\n\n /**\n * @param {Integer} length - array length\n * @param {Boolean} [setAll] - initialize with true\n */\n constructor (length: number, setAll?: boolean) {\n this.length = length\n this._words = new Uint32Array((length + 32) >>> 5)\n if (setAll === true) {\n this.setAll()\n }\n }\n\n /**\n * Get value at index\n * @param {Integer} index - the index\n * @return {Boolean} value\n */\n get (index: number) {\n return (this._words[ index >>> 5 ] & (1 << index)) !== 0\n }\n\n /**\n * Set value at index to true\n * @param {Integer} index - the index\n * @return {undefined}\n */\n set (index: number) {\n this._words[ index >>> 5 ] |= 1 << index\n }\n\n /**\n * Set value at index to false\n * @param {Integer} index - the index\n * @return {undefined}\n */\n clear (index: number) {\n this._words[ index >>> 5 ] &= ~(1 << index)\n }\n\n /**\n * Flip value at index\n * @param {Integer} index - the index\n * @return {undefined}\n */\n flip (index: number) {\n this._words[ index >>> 5 ] ^= 1 << index\n }\n\n _assignRange (start: number, end: number, value: boolean) {\n if (end < start) return\n const words = this._words\n const wordValue = value === true ? 0xFFFFFFFF : 0\n const wordStart = start >>> 5\n const wordEnd = end >>> 5\n // set complete words when applicable\n for (let k = wordStart + 1; k < wordEnd; ++k) {\n words[ k ] = wordValue\n }\n // set parts of the range not spanning complete words\n const startWord = wordStart << 5\n const endWord = wordEnd << 5\n if (value === true) {\n if (end - start < 32) {\n for (let i = start, n = end + 1; i < n; ++i) {\n words[ i >>> 5 ] |= 1 << i\n }\n } else {\n for (let i = start, n = startWord + 32; i < n; ++i) {\n words[ i >>> 5 ] |= 1 << i\n }\n for (let i = endWord, n = end + 1; i < n; ++i) {\n words[ i >>> 5 ] |= 1 << i\n }\n }\n } else {\n if (end - start < 32) {\n for (let i = start, n = end + 1; i < n; ++i) {\n words[ i >>> 5 ] &= ~(1 << i)\n }\n } else {\n for (let i = start, n = startWord + 32; i < n; ++i) {\n words[ i >>> 5 ] &= ~(1 << i)\n }\n for (let i = endWord, n = end + 1; i < n; ++i) {\n words[ i >>> 5 ] &= ~(1 << i)\n }\n }\n }\n return this\n }\n\n /**\n * Set bits of the given range\n * @param {Integer} start - start index\n * @param {Integer} end - end index\n * @return {BitArray} this object\n */\n setRange (start: number, end: number) {\n return this._assignRange(start, end, true)\n }\n\n /**\n * Clear bits of the given range\n * @param {Integer} start - start index\n * @param {Integer} end - end index\n * @return {BitArray} this object\n */\n clearRange (start: number, end: number) {\n return this._assignRange(start, end, false)\n }\n\n /**\n * Set bits at all given indices\n * @param {...Integer} arguments - indices\n * @return {Boolean} this object\n */\n setBits (...indices: number[]) {\n const words = this._words\n const n = indices.length\n for (let i = 0; i < n; ++i) {\n const index = indices[ i ]\n words[ index >>> 5 ] |= 1 << index\n }\n return this\n }\n\n /**\n * Clear bits at all given indices\n * @param {...Integer} arguments - indices\n * @return {Boolean} this object\n */\n clearBits (...indices: number[]) {\n const words = this._words\n const n = indices.length\n for (let i = 0; i < n; ++i) {\n const index = indices[ i ]\n words[ index >>> 5 ] &= ~(1 << index)\n }\n return this\n }\n\n /**\n * Set all bits of the array\n * @return {BitArray} this object\n */\n setAll () {\n return this._assignRange(0, this.length - 1, true)\n }\n\n /**\n * Clear all bits of the array\n * @return {BitArray} this object\n */\n clearAll () {\n return this._assignRange(0, this.length - 1, false)\n }\n\n /**\n * Flip all the values in the array\n * @return {BitArray} this object\n */\n flipAll () {\n const count = this._words.length\n const words = this._words\n const bs = 32 - this.length % 32\n for (let k = 0; k < count - 1; ++k) {\n words[k] = ~words[ k ]\n }\n words[ count - 1 ] = (~(words[ count - 1 ] << bs)) >>> bs\n return this\n }\n\n _isRangeValue (start: number, end: number, value: boolean) {\n if (end < start) return\n const words = this._words\n const wordValue = value === true ? 0xFFFFFFFF : 0\n const wordStart = start >>> 5\n const wordEnd = end >>> 5\n // set complete words when applicable\n for (let k = wordStart + 1; k < wordEnd; ++k) {\n if (words[ k ] !== wordValue) return false\n }\n // set parts of the range not spanning complete words\n if (end - start < 32) {\n for (let i = start, n = end + 1; i < n; ++i) {\n if (!!(words[ i >>> 5 ] & (1 << i)) !== value) return false\n }\n } else {\n const startWord = wordStart << 5\n const endWord = wordEnd << 5\n for (let i = start, n = startWord + 32; i < n; ++i) {\n if (!!(words[ i >>> 5 ] & (1 << i)) !== value) return false\n }\n for (let i = endWord, n = end + 1; i < n; ++i) {\n if (!!(words[ i >>> 5 ] & (1 << i)) !== value) return false\n }\n }\n return true\n }\n\n /**\n * Test if bits in given range are set\n * @param {Integer} start - start index\n * @param {Integer} end - end index\n * @return {BitArray} this object\n */\n isRangeSet (start: number, end: number) {\n return this._isRangeValue(start, end, true)\n }\n\n /**\n * Test if bits in given range are clear\n * @param {Integer} start - start index\n * @param {Integer} end - end index\n * @return {BitArray} this object\n */\n isRangeClear (start: number, end: number) {\n return this._isRangeValue(start, end, false)\n }\n\n /**\n * Test if all bits in the array are set\n * @return {Boolean} test result\n */\n isAllSet () {\n return this._isRangeValue(0, this.length - 1, true)\n }\n\n /**\n * Test if all bits in the array are clear\n * @return {Boolean} test result\n */\n isAllClear () {\n return this._isRangeValue(0, this.length - 1, false)\n }\n\n /**\n * Test if bits at all given indices are set\n * @param {...Integer} arguments - indices\n * @return {Boolean} test result\n */\n isSet (...indices: number[]) {\n const words = this._words\n const n = indices.length\n for (let i = 0; i < n; ++i) {\n const index = indices[ i ]\n if ((words[ index >>> 5 ] & (1 << index)) === 0) return false\n }\n return true\n }\n\n /**\n * Test if bits at all given indices are clear\n * @param {...Integer} arguments - indices\n * @return {Boolean} test result\n */\n isClear (...indices: number[]) {\n const words = this._words\n const n = indices.length\n for (let i = 0; i < n; ++i) {\n const index = indices[ i ]\n if ((words[ index >>> 5 ] & (1 << index)) !== 0) return false\n }\n return true\n }\n\n /**\n * Test if two BitArrays are identical in all their values\n * @param {BitArray} otherBitarray - the other BitArray\n * @return {Boolean} test result\n */\n isEqualTo (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n if (words1[ k ] !== words2[ k ]) {\n return false\n }\n }\n return true\n }\n\n /**\n * How many set bits?\n * @return {Integer} number of set bits\n */\n getSize () {\n const count = this._words.length\n const words = this._words\n let size = 0\n for (let i = 0; i < count; ++i) {\n size += hammingWeight(words[ i ])\n }\n return size\n }\n\n /**\n * Calculate difference betwen this and another bit array.\n * Store result in this object.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {BitArray} this object\n */\n difference (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n words1[ k ] = words1[ k ] & ~words2[ k ]\n }\n for (let k = words1.length; k < count; ++k) {\n words1[ k ] = 0\n }\n return this\n }\n\n /**\n * Calculate union betwen this and another bit array.\n * Store result in this object.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {BitArray} this object\n */\n union (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n words1[ k ] |= words2[ k ]\n }\n for (let k = words1.length; k < count; ++k) {\n words1[ k ] = 0\n }\n return this\n }\n\n /**\n * Calculate intersection betwen this and another bit array.\n * Store result in this object.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {BitArray} this object\n */\n intersection (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n words1[ k ] &= words2[ k ]\n }\n for (let k = words1.length; k < count; ++k) {\n words1[ k ] = 0\n }\n return this\n }\n\n /**\n * Test if there is any intersection betwen this and another bit array.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {Boolean} test result\n */\n intersects (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n if ((words1[ k ] & words2[ k ]) !== 0) {\n return true\n }\n }\n return false\n }\n\n /**\n * Calculate the number of bits in common betwen this and another bit array.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {Integer} size\n */\n getIntersectionSize (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n let size = 0\n for (let k = 0; k < count; ++k) {\n size += hammingWeight(words1[ k ] & words2[ k ])\n }\n return size\n }\n\n /**\n * Calculate intersection betwen this and another bit array.\n * Store result in a new bit array.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {BitArray} the new bit array\n */\n makeIntersection (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n const wordsA = new Uint32Array(count)\n const intersection = Object.create(BitArray.prototype)\n intersection._words = wordsA\n intersection.length = Math.min(this.length, otherBitarray.length)\n for (let k = 0; k < count; ++k) {\n wordsA[ k ] = words1[ k ] & words2[ k ]\n }\n return intersection\n }\n\n /**\n * Iterate over all set bits in the array\n * @param {function( index: Integer, i: Integer )} callback - the callback\n * @return {undefined}\n */\n forEach (callback: (index: number, i: number) => any) {\n const count = this._words.length\n const words = this._words\n let i = 0\n for (let k = 0; k < count; ++k) {\n let w = words[ k ]\n while (w !== 0) {\n const t = w & -w\n const index = (k << 5) + hammingWeight(t - 1)\n callback(index, i)\n w ^= t\n ++i\n }\n }\n }\n\n /**\n * Get an array with the set bits\n * @return {Array} bit indices\n */\n toArray () {\n const words = this._words\n const answer = new Array(this.getSize())\n const count = this._words.length\n let pos = 0\n for (let k = 0; k < count; ++k) {\n let w = words[ k ]\n while (w !== 0) {\n const t = w & -w\n answer[ pos++ ] = (k << 5) + hammingWeight(t - 1)\n w ^= t\n }\n }\n return answer\n }\n\n toString () {\n return '{' + this.toArray().join(',') + '}'\n }\n\n toSeleString () {\n const sele = this.toArray().join(',')\n return sele ? '@' + sele : 'NONE'\n }\n\n /**\n * Clone this object\n * @return {BitArray} the cloned object\n */\n clone () {\n const clone = Object.create(BitArray.prototype)\n clone.length = this.length\n clone._words = new Uint32Array(this._words)\n return clone\n }\n}","/**\n * @file Adjacency List\n * @author Alexander Rose \n * @private\n */\n\nexport interface Edges {\n nodeArray1: ArrayLike\n nodeArray2: ArrayLike\n edgeCount: number\n nodeCount: number\n}\n\nexport interface AdjacencyList {\n /* number of edges for each node */\n countArray: Uint8Array\n /* offset into indexArray for each node */\n offsetArray: Int32Array\n /* edge indices, grouped by nodes */\n indexArray: Int32Array\n}\n\nexport function createAdjacencyList (edges: Edges): AdjacencyList {\n const { edgeCount, nodeCount, nodeArray1, nodeArray2 } = edges\n\n const countArray = new Uint8Array(nodeCount)\n const offsetArray = new Int32Array(nodeCount)\n\n // count edges per node\n for (let i = 0; i < edgeCount; ++i) {\n countArray[ nodeArray1[ i ] ] += 1\n countArray[ nodeArray2[ i ] ] += 1\n }\n\n // get offsets to node edges\n for (let i = 1; i < nodeCount; ++i) {\n offsetArray[ i ] += offsetArray[ i - 1 ] + countArray[ i - 1 ]\n }\n\n // prepare index array\n const bondCount2 = edgeCount * 2\n const indexArray = new Int32Array(bondCount2)\n for (let j = 0; j < bondCount2; ++j) {\n indexArray[ j ] = -1\n }\n\n // build index array\n for (let i = 0; i < edgeCount; ++i) {\n const idx1 = nodeArray1[ i ]\n const idx2 = nodeArray2[ i ]\n let j1 = offsetArray[ idx1 ]\n while (indexArray[ j1 ] !== -1 && j1 < bondCount2) {\n j1 += 1\n }\n indexArray[ j1 ] = i\n let j2 = offsetArray[ idx2 ]\n while (indexArray[ j2 ] !== -1 && j2 < bondCount2) {\n j2 += 1\n }\n indexArray[ j2 ] = i\n }\n\n return { countArray, offsetArray, indexArray }\n}\n","/**\n * @file Features\n * @author Alexander Rose \n */\n\nimport AtomProxy from '../../proxy/atom-proxy'\n\nexport interface Features {\n types: FeatureType[]\n groups: FeatureGroup[]\n centers: { x: number[], y: number[], z: number[] }\n atomSets: number[][]\n}\n\nexport const enum FeatureType {\n Unknown = 0,\n PositiveCharge = 1,\n NegativeCharge = 2,\n AromaticRing = 3,\n HydrogenDonor = 4,\n HydrogenAcceptor = 5,\n HalogenDonor = 6,\n HalogenAcceptor = 7,\n Hydrophobic = 8,\n WeakHydrogenDonor = 9,\n IonicTypePartner = 10,\n DativeBondPartner = 11,\n TransitionMetal = 12,\n IonicTypeMetal = 13\n}\n\nexport const enum FeatureGroup {\n Unknown = 0,\n QuaternaryAmine = 1,\n TertiaryAmine = 2,\n Sulfonium = 3,\n SulfonicAcid = 4,\n Sulfate = 5,\n Phosphate = 6,\n Halocarbon = 7,\n Guanidine = 8,\n Acetamidine = 9,\n Carboxylate = 10\n}\n\nexport function createFeatures (): Features {\n return {\n types: [],\n groups: [],\n centers: { x: [], y: [], z: [] },\n atomSets: []\n }\n}\n\nexport interface FeatureState {\n type: FeatureType\n group: FeatureGroup\n x: number\n y: number\n z: number\n atomSet: number[]\n}\n\nexport function createFeatureState(type = FeatureType.Unknown, group = FeatureGroup.Unknown): FeatureState {\n return { type, group, x: 0, y: 0, z: 0, atomSet: [] }\n}\n\nexport function addAtom (state: FeatureState, atom: AtomProxy) {\n state.x += atom.x\n state.y += atom.y\n state.z += atom.z\n state.atomSet.push(atom.index)\n}\n\nexport function addFeature (features: Features, state: FeatureState) {\n const n = state.atomSet.length\n if (n > 0) {\n const { types, groups, centers, atomSets } = features\n types.push(state.type)\n groups.push(state.group)\n centers.x.push(state.x / n)\n centers.y.push(state.y / n)\n centers.z.push(state.z / n)\n atomSets.push(state.atomSet)\n }\n}\n","/**\n * @file Structure Constants\n * @author Alexander Rose \n * @private\n */\n\n// entity types\nexport const UnknownEntity = 0\nexport const PolymerEntity = 1\nexport const NonPolymerEntity = 2\nexport const MacrolideEntity = 3\nexport const WaterEntity = 4\n\n// molecule types\nexport const UnknownType = 0\nexport const WaterType = 1\nexport const IonType = 2\nexport const ProteinType = 3\nexport const RnaType = 4\nexport const DnaType = 5\nexport const SaccharideType = 6\n\n// backbone types\nexport const UnknownBackboneType = 0\nexport const ProteinBackboneType = 1\nexport const RnaBackboneType = 2\nexport const DnaBackboneType = 3\nexport const CgProteinBackboneType = 4\nexport const CgRnaBackboneType = 5\nexport const CgDnaBackboneType = 6\n\n// chemical component types\nexport const ChemCompProtein = [\n 'D-BETA-PEPTIDE, C-GAMMA LINKING', 'D-GAMMA-PEPTIDE, C-DELTA LINKING',\n 'D-PEPTIDE COOH CARBOXY TERMINUS', 'D-PEPTIDE NH3 AMINO TERMINUS', 'D-PEPTIDE LINKING',\n 'L-BETA-PEPTIDE, C-GAMMA LINKING', 'L-GAMMA-PEPTIDE, C-DELTA LINKING',\n 'L-PEPTIDE COOH CARBOXY TERMINUS', 'L-PEPTIDE NH3 AMINO TERMINUS', 'L-PEPTIDE LINKING',\n 'PEPTIDE LINKING', 'PEPTIDE-LIKE'\n]\nexport const ChemCompRna = [\n 'RNA OH 3 PRIME TERMINUS', 'RNA OH 5 PRIME TERMINUS', 'RNA LINKING'\n]\nexport const ChemCompDna = [\n 'DNA OH 3 PRIME TERMINUS', 'DNA OH 5 PRIME TERMINUS', 'DNA LINKING',\n 'L-DNA LINKING', 'L-RNA LINKING'\n]\nexport const ChemCompSaccharide = [\n 'D-SACCHARIDE', 'D-SACCHARIDE 1,4 AND 1,4 LINKING', 'D-SACCHARIDE 1,4 AND 1,6 LINKING',\n 'L-SACCHARIDE', 'L-SACCHARIDE 1,4 AND 1,4 LINKING', 'L-SACCHARIDE 1,4 AND 1,6 LINKING',\n 'SACCHARIDE'\n]\nexport const ChemCompOther = [\n 'OTHER'\n]\nexport const ChemCompNonPolymer = [\n 'NON-POLYMER'\n]\nexport const ChemCompHetero = ChemCompNonPolymer.concat(ChemCompOther, ChemCompSaccharide)\n\n// secondary structure\nexport const SecStrucHelix = [ 'h', 'g', 'i' ]\nexport const SecStrucSheet = [ 'e', 'b' ]\nexport const SecStrucTurn = [ 's', 't', 'l', '' ]\n\nexport const AtomicNumbers: { [e: string]: number | undefined } = {\n 'H': 1, 'D': 1, 'T': 1, 'HE': 2, 'LI': 3, 'BE': 4, 'B': 5, 'C': 6, 'N': 7, 'O': 8, 'F': 9, 'NE': 10, 'NA': 11, 'MG': 12, 'AL': 13, 'SI': 14, 'P': 15, 'S': 16, 'CL': 17, 'AR': 18, 'K': 19, 'CA': 20, 'SC': 21, 'TI': 22, 'V': 23, 'CR': 24, 'MN': 25, 'FE': 26, 'CO': 27, 'NI': 28, 'CU': 29, 'ZN': 30, 'GA': 31, 'GE': 32, 'AS': 33, 'SE': 34, 'BR': 35, 'KR': 36, 'RB': 37, 'SR': 38, 'Y': 39, 'ZR': 40, 'NB': 41, 'MO': 42, 'TC': 43, 'RU': 44, 'RH': 45, 'PD': 46, 'AG': 47, 'CD': 48, 'IN': 49, 'SN': 50, 'SB': 51, 'TE': 52, 'I': 53, 'XE': 54, 'CS': 55, 'BA': 56, 'LA': 57, 'CE': 58, 'PR': 59, 'ND': 60, 'PM': 61, 'SM': 62, 'EU': 63, 'GD': 64, 'TB': 65, 'DY': 66, 'HO': 67, 'ER': 68, 'TM': 69, 'YB': 70, 'LU': 71, 'HF': 72, 'TA': 73, 'W': 74, 'RE': 75, 'OS': 76, 'IR': 77, 'PT': 78, 'AU': 79, 'HG': 80, 'TL': 81, 'PB': 82, 'BI': 83, 'PO': 84, 'AT': 85, 'RN': 86, 'FR': 87, 'RA': 88, 'AC': 89, 'TH': 90, 'PA': 91, 'U': 92, 'NP': 93, 'PU': 94, 'AM': 95, 'CM': 96, 'BK': 97, 'CF': 98, 'ES': 99, 'FM': 100, 'MD': 101, 'NO': 102, 'LR': 103, 'RF': 104, 'DB': 105, 'SG': 106, 'BH': 107, 'HS': 108, 'MT': 109, 'DS': 110, 'RG': 111, 'CN': 112, 'NH': 113, 'FL': 114, 'MC': 115, 'LV': 116, 'TS': 117, 'OG': 118\n}\nexport const DefaultAtomicNumber = 0\n\n/**\n * Enum mapping element to atomic number\n */\nexport const enum Elements {\n H = 1, D = 1, T = 1, HE = 2, LI = 3, BE = 4, B = 5, C = 6, N = 7, O = 8, F = 9, NE = 10, NA = 11, MG = 12, AL = 13, SI = 14, P = 15, S = 16, CL = 17, AR = 18, K = 19, CA = 20, SC = 21, TI = 22, V = 23, CR = 24, MN = 25, FE = 26, CO = 27, NI = 28, CU = 29, ZN = 30, GA = 31, GE = 32, AS = 33, SE = 34, BR = 35, KR = 36, RB = 37, SR = 38, Y = 39, ZR = 40, NB = 41, MO = 42, TC = 43, RU = 44, RH = 45, PD = 46, AG = 47, CD = 48, IN = 49, SN = 50, SB = 51, TE = 52, I = 53, XE = 54, CS = 55, BA = 56, LA = 57, CE = 58, PR = 59, ND = 60, PM = 61, SM = 62, EU = 63, GD = 64, TB = 65, DY = 66, HO = 67, ER = 68, TM = 69, YB = 70, LU = 71, HF = 72, TA = 73, W = 74, RE = 75, OS = 76, IR = 77, PT = 78, AU = 79, HG = 80, TL = 81, PB = 82, BI = 83, PO = 84, AT = 85, RN = 86, FR = 87, RA = 88, AC = 89, TH = 90, PA = 91, U = 92, NP = 93, PU = 94, AM = 95, CM = 96, BK = 97, CF = 98, ES = 99, FM = 100, MD = 101, NO = 102, LR = 103, RF = 104, DB = 105, SG = 106, BH = 107, HS = 108, MT = 109, DS = 110, RG = 111, CN = 112, NH = 113, FL = 114, MC = 115, LV = 116, TS = 117, OG = 118\n}\n\n// https://doi.org/10.1515/pac-2015-0305 (table 2, 3, and 4)\nexport const AtomWeights: { [e: number]: number | undefined } = {\n 1: 1.008, 2: 4.0026, 3: 6.94, 4: 9.0122, 5: 10.81, 6: 10.81, 7: 14.007, 8: 15.999, 9: 18.998, 10: 20.180, 11: 22.990, 12: 24.305, 13: 26.982, 14: 28.085, 15: 30.974, 16: 32.06, 17: 35.45, 18: 39.948, 19: 39.098, 20: 40.078, 21: 44.956, 22: 47.867, 23: 50.942, 24: 51.996, 25: 54.938, 26: 55.845, 27: 58.933, 28: 58.693, 29: 63.546, 30: 65.38, 31: 69.723, 32: 72.630, 33: 74.922, 34: 78.971, 35: 79.904, 36: 83.798, 37: 85.468, 38: 87.62, 39: 88.906, 40: 91.224, 41: 92.906, 42: 95.95, 43: 96.906, 44: 101.07, 45: 102.91, 46: 106.42, 47: 107.87, 48: 112.41, 49: 114.82, 50: 118.71, 51: 121.76, 52: 127.60, 53: 127.60, 54: 131.29, 55: 132.91, 56: 137.33, 57: 138.91, 58: 140.12, 59: 140.91, 60: 144.24, 61: 144.912, 62: 150.36, 63: 151.96, 64: 157.25, 65: 158.93, 66: 162.50, 67: 164.93, 68: 167.26, 69: 168.93, 70: 173.05, 71: 174.97, 72: 178.49, 73: 180.95, 74: 183.84, 75: 186.21, 76: 190.23, 77: 192.22, 78: 195.08, 79: 196.97, 80: 200.59, 81: 204.38, 82: 207.2, 83: 208.98, 84: 1.97, 85: 2.02, 86: 2.2, 87: 3.48, 88: 2.83, 89: 2.0, 90: 232.04, 91: 231.04, 92: 238.03, 93: 237.048, 94: 244.064, 95: 243.061, 96: 247.070, 97: 247.070, 98: 251.079, 99: 252.083, 100: 257.095, 101: 258.098, 102: 259.101, 103: 262.110, 104: 267.122, 105: 270.131, 106: 271.134, 107: 270.133, 108: 270.134, 109: 278.156, 110: 281.165, 111: 281.166, 112: 285.177, 113: 286.182, 114: 289.190, 115: 289.194, 116: 293.204, 117: 293.208, 118: 294.214\n}\nexport const DefaultAtomWeight = 10.81 // C\n\n// http://dx.doi.org/10.1021/jp8111556 (or 2.0)\nexport const VdwRadii: { [e: number]: number | undefined } = {\n 1: 1.1, 2: 1.4, 3: 1.81, 4: 1.53, 5: 1.92, 6: 1.7, 7: 1.55, 8: 1.52, 9: 1.47, 10: 1.54, 11: 2.27, 12: 1.73, 13: 1.84, 14: 2.1, 15: 1.8, 16: 1.8, 17: 1.75, 18: 1.88, 19: 2.75, 20: 2.31, 21: 2.3, 22: 2.15, 23: 2.05, 24: 2.05, 25: 2.05, 26: 2.05, 27: 2.0, 28: 2.0, 29: 2.0, 30: 2.1, 31: 1.87, 32: 2.11, 33: 1.85, 34: 1.9, 35: 1.83, 36: 2.02, 37: 3.03, 38: 2.49, 39: 2.4, 40: 2.3, 41: 2.15, 42: 2.1, 43: 2.05, 44: 2.05, 45: 2.0, 46: 2.05, 47: 2.1, 48: 2.2, 49: 2.2, 50: 1.93, 51: 2.17, 52: 2.06, 53: 1.98, 54: 2.16, 55: 3.43, 56: 2.68, 57: 2.5, 58: 2.48, 59: 2.47, 60: 2.45, 61: 2.43, 62: 2.42, 63: 2.4, 64: 2.38, 65: 2.37, 66: 2.35, 67: 2.33, 68: 2.32, 69: 2.3, 70: 2.28, 71: 2.27, 72: 2.25, 73: 2.2, 74: 2.1, 75: 2.05, 76: 2.0, 77: 2.0, 78: 2.05, 79: 2.1, 80: 2.05, 81: 1.96, 82: 2.02, 83: 2.07, 84: 1.97, 85: 2.02, 86: 2.2, 87: 3.48, 88: 2.83, 89: 2.0, 90: 2.4, 91: 2.0, 92: 2.3, 93: 2.0, 94: 2.0, 95: 2.0, 96: 2.0, 97: 2.0, 98: 2.0, 99: 2.0, 100: 2.0, 101: 2.0, 102: 2.0, 103: 2.0, 104: 2.0, 105: 2.0, 106: 2.0, 107: 2.0, 108: 2.0, 109: 2.0, 110: 2.0, 111: 2.0, 112: 2.0, 113: 2.0, 114: 2.0, 115: 2.0, 116: 2.0, 117: 2.0, 118: 2.0\n}\nexport const DefaultVdwRadius = 2.0 // C\n\n// Peter Rose (peter.rose@rcsb.org), private communication, average accross PDB\nexport const ResidueRadii: { [k: string]: number } = {\n '2QY': 6.58,\n 'CY0': 11.98,\n '2QZ': 2.52,\n 'CY1': 6.59,\n 'HHK': 5.11,\n 'CXM': 4.69,\n 'HHI': 4.58,\n 'CY4': 4.57,\n 'S12': 18.57,\n 'CY3': 2.79,\n 'C5C': 5.35,\n 'PFX': 11.84,\n '2R3': 6.94,\n '2R1': 3.78,\n 'ILX': 4.99,\n '32S': 5.68,\n 'BTK': 8.59,\n '32T': 5.72,\n 'FAK': 9.8,\n 'B27': 2.78,\n 'ILM': 3.84,\n 'C4R': 5.63,\n '32L': 6.75,\n 'SYS': 3.01,\n '1MH': 5.04,\n 'ILE': 3.65,\n 'YNM': 6.39,\n '2RX': 4.91,\n 'B3A': 2.48,\n 'GEE': 4.76,\n '7MN': 7.34,\n 'B3E': 5.4,\n 'ARG': 6.33,\n '200': 6.89,\n 'HIP': 5.47,\n 'HIA': 4.64,\n 'B3K': 5.89,\n 'HIC': 5.76,\n 'B3L': 4.96,\n 'B3M': 5.07,\n 'ARM': 6.86,\n 'ARO': 7.35,\n 'AR4': 8.42,\n 'PG1': 10.67,\n 'YOF': 6.44,\n 'IML': 3.74,\n 'SXE': 6.65,\n 'HIQ': 7.98,\n 'PFF': 6.31,\n 'HIS': 4.52,\n '0TD': 3.62,\n 'C3Y': 5.24,\n '1OP': 11.55,\n '02Y': 4.77,\n '02V': 4.83,\n 'ASB': 5.59,\n '30V': 8.53,\n 'S2P': 4.81,\n 'ASP': 3.55,\n 'ASN': 3.54,\n '2OR': 6.91,\n 'QMM': 6.13,\n '2P0': 8.52,\n 'ASL': 5.36,\n 'HFA': 5.14,\n '5PG': 5.69,\n 'B3X': 4.38,\n 'AS9': 4.1,\n 'ARV': 7.59,\n 'B3U': 6.06,\n 'S2C': 7.54,\n 'B3T': 3.34,\n '175': 5.64,\n 'GFT': 8.18,\n 'HG7': 6.8,\n 'B3Q': 4.48,\n 'ASA': 3.64,\n '02K': 2.94,\n 'B3Y': 7.45,\n 'PHD': 5.35,\n 'C6C': 6.42,\n 'BUC': 5.8,\n 'HGL': 8.07,\n 'PHE': 5.06,\n '03Y': 2.6,\n 'PHA': 5.11,\n 'OCY': 5.0,\n '4PH': 6.79,\n '5OH': 4.7,\n '31Q': 10.46,\n 'BTR': 7.98,\n '3PX': 4.7,\n '1PA': 8.07,\n 'ASX': 3.54,\n 'IOR': 7.23,\n '03E': 3.38,\n 'PHL': 5.17,\n 'KWS': 5.09,\n 'PHI': 7.12,\n 'NAL': 7.22,\n 'S1H': 19.21,\n '2ML': 3.86,\n '2MR': 7.35,\n 'GHG': 4.83,\n 'TYY': 6.54,\n '2MT': 3.67,\n '56A': 13.01,\n 'SVA': 5.46,\n 'TYX': 8.31,\n 'TYS': 8.59,\n 'TYR': 6.38,\n 'TYQ': 6.43,\n 'HLU': 3.99,\n 'MYK': 19.47,\n 'TYO': 7.71,\n 'HLX': 4.98,\n 'TYN': 9.87,\n 'TYJ': 6.25,\n 'TYI': 6.49,\n 'LYH': 5.13,\n 'LYF': 12.19,\n 'SUN': 6.73,\n 'LYR': 18.28,\n 'TYB': 6.46,\n '11W': 14.39,\n 'LYS': 5.54,\n 'LYN': 4.8,\n '11Q': 4.85,\n 'LYO': 4.71,\n 'LYZ': 1.76,\n 'TXY': 6.44,\n 'MYN': 4.71,\n 'TY5': 10.6,\n 'HMR': 5.09,\n '01W': 8.55,\n 'LYX': 13.36,\n 'TY8': 7.22,\n 'TY2': 6.49,\n 'KYN': 6.18,\n 'KYQ': 9.75,\n 'CZZ': 5.14,\n 'IIL': 3.81,\n 'HNC': 10.41,\n 'OIC': 4.62,\n 'LVN': 2.89,\n 'QIL': 3.84,\n 'JJL': 8.3,\n 'VAH': 3.88,\n 'JJJ': 7.5,\n 'JJK': 7.43,\n 'VAD': 2.56,\n 'CYW': 4.65,\n '0QL': 5.72,\n '143': 8.22,\n 'SVX': 7.04,\n 'CYJ': 11.64,\n 'SVY': 7.1,\n 'SVZ': 6.6,\n 'CYG': 8.03,\n 'CYF': 13.54,\n 'SVV': 5.09,\n 'GL3': 2.72,\n '8SP': 14.26,\n 'CYS': 2.78,\n '004': 4.33,\n 'CYR': 10.33,\n 'PLJ': 3.71,\n 'EXY': 7.37,\n 'HL2': 3.75,\n 'A5N': 5.21,\n 'CYQ': 5.67,\n 'CZ2': 5.16,\n 'LWY': 4.12,\n 'PM3': 8.78,\n 'OHS': 6.98,\n 'OHI': 5.35,\n '3TY': 8.42,\n 'CYD': 8.55,\n 'DYS': 7.87,\n 'DAH': 6.47,\n '4IK': 11.81,\n '3EG': 3.66,\n 'AYA': 3.65,\n '4IN': 6.31,\n 'DAB': 3.48,\n '4HT': 6.03,\n 'RGL': 7.03,\n 'DAM': 2.49,\n 'NFA': 5.04,\n 'WFP': 6.07,\n '2JC': 2.97,\n 'HAR': 7.55,\n '2JG': 5.67,\n 'MH6': 1.72,\n '2JF': 9.13,\n '3FG': 4.96,\n 'MGN': 4.84,\n 'AZH': 5.36,\n 'AZK': 6.03,\n 'ZBZ': 7.79,\n 'TBG': 2.58,\n 'VAL': 2.51,\n 'MGG': 7.34,\n 'AZS': 5.61,\n 'FHL': 9.75,\n '2JH': 4.56,\n 'IEL': 7.07,\n 'FHO': 6.75,\n 'DA2': 7.79,\n 'FH7': 6.99,\n 'ME0': 4.52,\n '3GL': 4.84,\n 'MDO': 5.03,\n 'AZY': 7.37,\n 'A8E': 3.76,\n 'ZCL': 6.71,\n 'MDH': 2.58,\n 'LA2': 14.07,\n '4FW': 6.1,\n 'YCM': 5.32,\n 'MDF': 4.95,\n 'YCP': 3.01,\n 'TEF': 8.63,\n 'FGP': 4.34,\n 'UF0': 19.72,\n 'XCN': 4.57,\n 'FGL': 2.56,\n 'MF3': 6.37,\n 'MEQ': 5.13,\n 'LAA': 3.23,\n 'IGL': 5.52,\n 'MET': 4.49,\n 'NIY': 6.81,\n 'QCS': 5.18,\n 'TCQ': 8.56,\n 'MEN': 4.33,\n '4HL': 8.79,\n 'MEA': 4.95,\n 'EFC': 5.28,\n 'LAL': 2.41,\n '2HF': 5.52,\n 'KBE': 5.64,\n 'OCS': 3.94,\n 'CAF': 5.46,\n 'NC1': 11.4,\n 'NBQ': 9.82,\n 'CAB': 4.19,\n 'MBQ': 9.55,\n '193': 7.38,\n '192': 2.44,\n '0WZ': 7.61,\n 'CAS': 5.35,\n 'NB8': 11.98,\n 'OBS': 11.71,\n '1AC': 2.42,\n 'PCA': 3.48,\n 'MCL': 9.73,\n 'LBY': 7.75,\n 'GAU': 4.67,\n 'PBF': 9.75,\n 'MCG': 6.46,\n 'DDE': 6.86,\n '19W': 3.94,\n 'MD5': 9.33,\n 'MD6': 6.44,\n 'MD3': 8.41,\n 'MCS': 7.56,\n 'OBF': 3.64,\n 'UAL': 4.68,\n 'PAT': 6.05,\n 'IAM': 8.88,\n 'PAQ': 8.77,\n 'FDL': 9.49,\n 'NCB': 3.45,\n 'LCK': 9.81,\n 'DDZ': 2.52,\n '2FM': 5.54,\n 'IAR': 6.77,\n 'OAS': 4.8,\n 'HBN': 8.8,\n 'TA4': 5.55,\n '1C3': 7.43,\n 'ECX': 5.51,\n 'PF5': 6.28,\n 'RE3': 5.29,\n 'FCL': 6.25,\n 'ECC': 4.79,\n 'LDH': 7.06,\n 'NCY': 2.91,\n 'CCS': 4.58,\n 'PEC': 6.54,\n '2CO': 4.45,\n 'LE1': 2.72,\n 'HCM': 5.53,\n '07O': 8.05,\n 'HCL': 4.96,\n 'NEP': 6.94,\n 'PE1': 8.01,\n 'LEF': 4.37,\n 'FC0': 5.18,\n 'LED': 4.34,\n 'HCS': 4.09,\n 'DBU': 2.49,\n 'RE0': 5.53,\n 'LEN': 3.82,\n '1E3': 8.71,\n 'BB9': 2.56,\n 'BB8': 5.14,\n 'PCS': 5.05,\n 'BB7': 4.56,\n 'BB6': 2.62,\n 'LEU': 3.83,\n 'DBZ': 7.08,\n 'LET': 11.29,\n 'DBY': 6.46,\n 'ICY': 7.76,\n 'MAA': 2.4,\n 'CGA': 7.91,\n '5CS': 8.34,\n 'UGY': 3.7,\n 'LGY': 11.71,\n 'N10': 8.96,\n 'AAR': 6.39,\n 'FT6': 7.5,\n 'MOD': 12.62,\n '5CW': 7.21,\n 'PVH': 4.58,\n 'BBC': 6.42,\n 'YYA': 7.3,\n 'O12': 14.08,\n 'NOT': 7.15,\n 'KGC': 9.88,\n 'MP4': 5.86,\n '0CS': 4.07,\n 'MP8': 3.75,\n 'VLL': 2.54,\n 'VLM': 2.51,\n 'BCS': 8.03,\n 'MNL': 4.9,\n 'AA4': 4.47,\n 'SAC': 3.49,\n 'BCX': 2.99,\n '3CF': 6.47,\n 'SAH': 11.7,\n 'NNH': 6.86,\n 'CGU': 4.71,\n 'SIB': 12.41,\n 'TLY': 8.78,\n 'SIC': 4.81,\n 'VMS': 8.82,\n 'TMD': 6.76,\n 'MMO': 6.53,\n 'PXU': 2.46,\n '4AW': 6.22,\n 'OTH': 3.6,\n 'DLS': 6.84,\n 'MME': 4.99,\n 'DM0': 6.99,\n '0FL': 2.76,\n 'SBL': 8.96,\n 'CDV': 3.72,\n 'OTY': 6.51,\n 'PYA': 7.75,\n '2AS': 3.57,\n 'DMH': 4.92,\n 'ELY': 7.42,\n 'GVL': 9.6,\n 'FVA': 2.9,\n 'SAR': 2.48,\n '4BF': 6.92,\n 'EME': 4.69,\n 'CDE': 2.51,\n '3AR': 7.86,\n '3AH': 9.11,\n 'AC5': 2.44,\n 'FTR': 6.08,\n 'MLL': 3.76,\n 'NPH': 11.66,\n 'NPI': 6.9,\n 'DMT': 6.67,\n 'PYX': 11.3,\n 'MLE': 3.87,\n 'PYL': 9.67,\n 'ZZU': 6.94,\n 'H5M': 3.61,\n 'SCH': 4.46,\n 'DMK': 3.52,\n 'FTY': 9.07,\n '2AG': 3.7,\n 'ABA': 2.55,\n 'ZZJ': 2.44,\n 'MLZ': 6.8,\n 'MLY': 6.88,\n 'KCX': 7.28,\n 'ZZD': 8.16,\n '3A5': 5.37,\n 'LHC': 7.75,\n '9AT': 2.47,\n 'OZT': 3.4,\n 'THO': 2.62,\n 'THR': 2.5,\n 'DFI': 3.93,\n 'MKD': 6.42,\n '4CY': 4.6,\n 'SDP': 6.07,\n 'DFO': 3.94,\n '0A0': 3.45,\n '4DB': 9.73,\n 'ML3': 6.26,\n 'BG1': 8.02,\n 'SD4': 4.57,\n 'THC': 3.8,\n 'SCS': 5.48,\n 'TH5': 4.65,\n 'BFD': 5.33,\n 'AEI': 6.34,\n 'TH6': 2.85,\n 'SCY': 4.53,\n 'TIS': 4.81,\n 'SEE': 4.53,\n 'BHD': 3.48,\n 'SEB': 8.18,\n 'SEC': 2.96,\n 'SEP': 4.8,\n 'CLH': 7.13,\n 'TIH': 5.02,\n 'CLG': 13.62,\n 'SEN': 6.43,\n 'XXA': 7.34,\n 'SEL': 2.46,\n 'SE7': 4.19,\n '4CF': 7.72,\n 'G8M': 3.57,\n 'BH2': 3.51,\n 'UN2': 3.22,\n 'VR0': 10.51,\n 'MK8': 4.76,\n 'DHA': 2.32,\n 'LMQ': 4.69,\n 'SFE': 5.01,\n 'AHB': 3.47,\n 'OXX': 7.05,\n 'BIF': 9.63,\n 'IZO': 4.47,\n 'NMM': 8.25,\n '0BN': 7.0,\n 'HZP': 3.12,\n 'NMC': 4.23,\n 'DHL': 2.69,\n '9DS': 9.29,\n 'SER': 2.41,\n 'CHG': 4.2,\n 'MIR': 6.54,\n 'AGQ': 7.79,\n 'SET': 2.46,\n 'MIS': 6.32,\n '4FB': 3.08,\n '0AR': 8.46,\n 'LME': 3.99,\n 'FZN': 24.42,\n 'AGT': 9.04,\n 'IYR': 6.46,\n '9DN': 9.31,\n 'CHP': 5.75,\n 'UNK': 1.64,\n 'XX1': 9.92,\n 'AGM': 6.57,\n '0AH': 5.78,\n 'LLP': 10.22,\n '0AF': 6.72,\n '4DP': 9.28,\n 'HYP': 2.25,\n 'DIR': 5.8,\n 'LLY': 8.71,\n '0AK': 6.11,\n 'NLE': 4.67,\n 'OYL': 6.42,\n 'WVL': 4.69,\n '0A8': 8.1,\n 'NLY': 6.37,\n 'MHO': 4.89,\n 'VOL': 2.55,\n '0A1': 7.1,\n 'MHL': 3.92,\n 'NLP': 4.81,\n 'NLQ': 4.65,\n 'MHW': 2.74,\n 'BIL': 4.7,\n 'NLO': 4.8,\n 'MHU': 7.51,\n 'XW1': 9.36,\n 'LLO': 10.13,\n 'SGB': 6.88,\n 'MHV': 3.6,\n 'MHS': 4.51,\n '0A9': 5.17,\n '0LF': 9.96,\n 'HT7': 6.82,\n 'X2W': 6.6,\n 'YPZ': 9.38,\n 'I58': 6.73,\n 'FLA': 2.4,\n 'M0H': 4.83,\n 'HSL': 2.46,\n 'FLE': 6.17,\n 'KOR': 10.1,\n '1VR': 3.89,\n 'HSO': 4.56,\n 'TTS': 9.41,\n 'RVX': 7.01,\n 'TTQ': 7.71,\n 'H14': 5.27,\n 'HTI': 7.8,\n 'ONH': 6.14,\n 'LP6': 8.58,\n 'ONL': 4.83,\n 'AHH': 5.06,\n 'HS8': 7.4,\n 'HS9': 4.71,\n 'BL2': 5.82,\n 'AHP': 5.26,\n '6HN': 7.34,\n 'HRP': 5.46,\n 'POM': 3.6,\n 'WPA': 5.11,\n '2ZC': 4.29,\n 'CPC': 2.65,\n 'AIB': 2.4,\n 'XSN': 3.47,\n 'M2S': 5.28,\n 'GND': 6.67,\n 'GNC': 4.6,\n 'MVA': 2.56,\n 'OLZ': 5.32,\n 'M2L': 6.15,\n 'TRF': 6.69,\n 'NZH': 7.66,\n 'SRZ': 5.27,\n 'OLD': 10.47,\n 'CME': 5.86,\n 'CMH': 5.3,\n 'ALA': 2.38,\n 'TRQ': 7.36,\n 'PPN': 7.24,\n 'TRP': 6.07,\n 'TRO': 5.82,\n 'TRN': 5.95,\n 'NYS': 8.1,\n 'ALC': 5.26,\n 'U3X': 11.7,\n 'HVA': 2.58,\n 'TS9': 3.92,\n 'TRX': 7.27,\n 'TRW': 11.8,\n 'LPL': 7.51,\n 'GMA': 4.4,\n 'OMT': 5.07,\n 'CMT': 3.54,\n 'GME': 4.66,\n 'NYB': 6.07,\n 'PR3': 5.12,\n 'LPD': 2.48,\n 'GLU': 4.49,\n '1X6': 6.84,\n 'LPG': 2.39,\n 'GLX': 4.52,\n 'PR4': 4.52,\n 'CML': 6.16,\n 'FME': 4.52,\n 'HTR': 6.48,\n 'PR7': 4.66,\n 'Z3E': 7.2,\n 'GLZ': 2.39,\n 'BMT': 6.37,\n 'WRP': 8.16,\n 'GLY': 2.37,\n 'OMY': 6.11,\n 'MTY': 5.46,\n 'OMX': 6.15,\n 'GLN': 4.46,\n '2XA': 8.25,\n '28X': 7.84,\n '7JA': 9.46,\n 'FLT': 9.65,\n 'GLJ': 3.7,\n 'OMH': 5.26,\n 'TSY': 4.26,\n 'PRV': 4.28,\n 'CS4': 11.21,\n 'DOA': 12.33,\n '23P': 5.42,\n 'CS3': 8.24,\n '6CL': 6.47,\n 'PRR': 5.58,\n 'KST': 11.58,\n 'CS1': 7.23,\n 'PRS': 2.63,\n 'ZYJ': 11.4,\n 'IT1': 9.75,\n 'UU5': 4.98,\n 'ESB': 6.69,\n 'UU4': 2.49,\n 'ESC': 5.65,\n 'LSO': 10.58,\n 'ZYK': 11.45,\n '9NV': 8.99,\n '23F': 5.27,\n 'ORN': 4.25,\n 'HOX': 6.61,\n 'CSD': 3.95,\n 'FP9': 3.03,\n 'DO2': 4.44,\n 'SLL': 11.53,\n 'P3Q': 9.54,\n 'ORQ': 6.04,\n 'MSL': 5.21,\n 'DNP': 2.45,\n 'CSB': 3.51,\n 'WLU': 4.24,\n 'CSA': 5.7,\n 'MT2': 5.51,\n 'CSO': 3.53,\n 'TPO': 4.73,\n 'MSP': 13.11,\n '23S': 6.09,\n 'MSO': 4.96,\n 'PRO': 2.41,\n 'TPL': 5.41,\n 'DNS': 8.79,\n 'CSK': 3.91,\n 'Z70': 7.4,\n 'CSJ': 7.51,\n 'DNW': 7.97,\n 'PRK': 9.15,\n 'GSU': 11.81,\n 'LTA': 6.57,\n 'HPE': 6.63,\n 'TPQ': 6.48,\n 'PRJ': 5.26,\n 'PSW': 4.65,\n 'L3O': 3.89,\n 'CSU': 4.89,\n 'ALY': 7.38,\n 'M3L': 7.12,\n 'CSW': 3.68,\n 'XPR': 7.68,\n 'D4P': 5.66,\n 'FOE': 8.17,\n 'SLZ': 5.69,\n 'CSP': 5.26,\n 'TQI': 7.68,\n 'ALT': 2.72,\n 'CSR': 5.42,\n 'CSS': 3.61,\n 'M3R': 7.18,\n 'ALO': 2.57,\n 'R4K': 4.67,\n 'SMF': 9.0,\n 'MSA': 2.73,\n 'SMC': 3.39,\n 'CSX': 3.47,\n 'SME': 4.8,\n 'ETA': 2.4,\n 'CSZ': 3.6,\n '22G': 8.8,\n 'MSE': 4.62,\n 'ALN': 6.16,\n 'PSH': 7.26,\n 'CTE': 7.27,\n 'DON': 6.72,\n 'CTH': 3.45,\n 'U2X': 11.54,\n '6CW': 7.56,\n 'TQZ': 6.97,\n '3YM': 6.52,\n 'OSE': 4.49,\n '2VA': 9.82,\n 'TQQ': 7.76,\n 'NRG': 8.35,\n 'BPE': 7.24,\n 'F2F': 6.25,\n '1TQ': 8.58,\n 'I2M': 3.13,\n 'NVA': 3.76,\n 'R1A': 8.2,\n 'QPA': 6.95,\n 'C1X': 11.63,\n 'FRD': 5.05,\n 'HR7': 6.98,\n 'SNC': 3.93,\n 'QPH': 5.15,\n '26B': 8.39,\n 'DPQ': 6.54,\n 'DPP': 2.51,\n '2TY': 8.65,\n 'TNR': 6.88,\n 'PTH': 8.35,\n 'DPL': 3.58,\n 'APK': 8.79,\n '1TY': 8.84,\n 'HRG': 7.36,\n 'PTM': 8.74,\n '1U8': 3.62,\n 'PTR': 8.64,\n 'LVG': 3.01,\n '6FL': 4.85,\n 'SOC': 4.05,\n 'KPI': 9.79,\n 'IPG': 2.91,\n 'P2Y': 2.51,\n 'N2C': 3.55,\n 'T0I': 7.34,\n 'MPH': 5.29,\n 'R2T': 4.71,\n 'TOX': 6.78,\n 'P2Q': 9.8,\n 'GPL': 10.77,\n 'MPJ': 5.07,\n 'F2Y': 6.2,\n 'T11': 8.58,\n '9NR': 9.33,\n 'FPR': 8.85,\n '9NF': 8.93,\n 'KPY': 10.17,\n '9NE': 9.77,\n 'TOQ': 7.5,\n 'MPQ': 4.2,\n 'FPK': 3.08,\n 'HQA': 7.25,\n 'SOY': 10.94\n}\nexport const DefaultResidueRadius = 5.0\n\n// http://dx.doi.org/10.1039/b801115j (or 1.6)\nexport const CovalentRadii: { [e: number]: number | undefined } = {\n 1: 0.31, 2: 0.28, 3: 1.28, 4: 0.96, 5: 0.84, 6: 0.76, 7: 0.71, 8: 0.66, 9: 0.57, 10: 0.58, 11: 1.66, 12: 1.41, 13: 1.21, 14: 1.11, 15: 1.07, 16: 1.05, 17: 1.02, 18: 1.06, 19: 2.03, 20: 1.76, 21: 1.7, 22: 1.6, 23: 1.53, 24: 1.39, 25: 1.39, 26: 1.32, 27: 1.26, 28: 1.24, 29: 1.32, 30: 1.22, 31: 1.22, 32: 1.2, 33: 1.19, 34: 1.2, 35: 1.2, 36: 1.16, 37: 2.2, 38: 1.95, 39: 1.9, 40: 1.75, 41: 1.64, 42: 1.54, 43: 1.47, 44: 1.46, 45: 1.42, 46: 1.39, 47: 1.45, 48: 1.44, 49: 1.42, 50: 1.39, 51: 1.39, 52: 1.38, 53: 1.39, 54: 1.4, 55: 2.44, 56: 2.15, 57: 2.07, 58: 2.04, 59: 2.03, 60: 2.01, 61: 1.99, 62: 1.98, 63: 1.98, 64: 1.96, 65: 1.94, 66: 1.92, 67: 1.92, 68: 1.89, 69: 1.9, 70: 1.87, 71: 1.87, 72: 1.75, 73: 1.7, 74: 1.62, 75: 1.51, 76: 1.44, 77: 1.41, 78: 1.36, 79: 1.36, 80: 1.32, 81: 1.45, 82: 1.46, 83: 1.48, 84: 1.4, 85: 1.5, 86: 1.5, 87: 2.6, 88: 2.21, 89: 2.15, 90: 2.06, 91: 2.0, 92: 1.96, 93: 1.9, 94: 1.87, 95: 1.8, 96: 1.69, 97: 1.6, 98: 1.6, 99: 1.6, 100: 1.6, 101: 1.6, 102: 1.6, 103: 1.6, 104: 1.6, 105: 1.6, 106: 1.6, 107: 1.6, 108: 1.6, 109: 1.6, 110: 1.6, 111: 1.6, 112: 1.6, 113: 1.6, 114: 1.6, 115: 1.6, 116: 1.6, 117: 1.6, 118: 1.6\n}\nexport const DefaultCovalentRadius = 1.6\n\nexport const Valences: { [e: number]: number[] | undefined } = {\n 1: [ 1 ],\n 2: [ 0 ],\n 3: [ 1 ],\n 4: [ 2 ],\n 5: [ 3 ],\n 6: [ 4 ],\n 7: [ 3 ],\n 8: [ 2 ],\n 9: [ 1 ],\n 10: [ 0 ],\n 11: [ 1 ],\n 12: [ 2 ],\n 13: [ 6 ],\n 14: [ 6 ],\n 15: [ 3, 5, 7 ],\n 16: [ 2, 4, 6 ],\n 17: [ 1 ],\n 18: [ 0 ],\n 19: [ 1 ],\n 20: [ 2 ],\n\n 31: [ 3 ],\n 32: [ 4 ],\n 33: [ 3, 5 ],\n 34: [ 2, 4, 6 ],\n 35: [ 1 ],\n 36: [ 0 ],\n 37: [ 1 ],\n 38: [ 2 ],\n\n 49: [ 3 ],\n 50: [ 4 ],\n 51: [ 3, 5 ],\n 52: [ 2 ],\n 53: [ 1, 2, 5 ],\n 54: [ 0, 2 ],\n 55: [ 1 ],\n 56: [ 2 ],\n\n 81: [ 3 ],\n 82: [ 4 ],\n 83: [ 3 ],\n 84: [ 2 ],\n 85: [ 1 ],\n 86: [ 0 ],\n 87: [ 1 ],\n 88: [ 2 ]\n}\nexport const DefaultValence = -1\n\nexport const OuterShellElectronCounts: { [e: number]: number | undefined } = {\n1: 1, 2: 2, 3: 1, 4: 2, 5: 3, 6: 4, 7: 5, 8: 6, 9: 7, 10: 8, 11: 1, 12: 2, 13: 3, 14: 4, 15: 5, 16: 6, 17: 7, 18: 8, 19: 1, 20: 2, 21: 3, 22: 4, 23: 5, 24: 6, 25: 7, 26: 8, 27: 9, 28: 10, 29: 11, 30: 2, 31: 3, 32: 4, 33: 5, 34: 6, 35: 7, 36: 8, 37: 1, 38: 2, 39: 3, 40: 4, 41: 5, 42: 6, 43: 7, 44: 8, 45: 9, 46: 10, 47: 11, 48: 2, 49: 3, 50: 4, 51: 5, 52: 6, 53: 7, 54: 8, 55: 1, 56: 2, 57: 3, 58: 4, 59: 3, 60: 4, 61: 5, 62: 6, 63: 7, 64: 8, 65: 9, 66: 10, 67: 11, 68: 12, 69: 13, 70: 14, 71: 15, 72: 4, 73: 5, 74: 6, 75: 7, 76: 8, 77: 9, 78: 10, 79: 11, 80: 2, 81: 3, 82: 4, 83: 5, 84: 6, 85: 7, 86: 8, 87: 1, 88: 2, 89: 3, 90: 4, 91: 3, 92: 4, 93: 5, 94: 6, 95: 7, 96: 8, 97: 9, 98: 10, 99: 11, 100: 12, 101: 13, 102: 14, 103: 15, 104: 2, 105: 2, 106: 2, 107: 2, 108: 2, 109: 2, 110: 2, 111: 2, 112: 2, 113: 3, 114: 4, 115: 5, 116: 6, 117: 7, 118: 8\n}\nexport const DefaultOuterShellElectronCount = 2\n\n// http://blanco.biomol.uci.edu/Whole_residue_HFscales.txt\n// https://www.nature.com/articles/nsb1096-842\nexport const ResidueHydrophobicity: { [k: string]: [number, number, number] } = {\n // AA DGwif DGwoct Oct-IF\n 'ALA': [ 0.17, 0.50, 0.33 ],\n 'ARG': [ 0.81, 1.81, 1.00 ],\n 'ASN': [ 0.42, 0.85, 0.43 ],\n 'ASP': [ 1.23, 3.64, 2.41 ],\n 'ASH': [ -0.07, 0.43, 0.50 ],\n 'CYS': [ -0.24, -0.02, 0.22 ],\n 'GLN': [ 0.58, 0.77, 0.19 ],\n 'GLU': [ 2.02, 3.63, 1.61 ],\n 'GLH': [ -0.01, 0.11, 0.12 ],\n 'GLY': [ 0.01, 1.15, 1.14 ],\n // \"His+\": [ 0.96, 2.33, 1.37 ],\n 'HIS': [ 0.17, 0.11, -0.06 ],\n 'ILE': [ -0.31, -1.12, -0.81 ],\n 'LEU': [ -0.56, -1.25, -0.69 ],\n 'LYS': [ 0.99, 2.80, 1.81 ],\n 'MET': [ -0.23, -0.67, -0.44 ],\n 'PHE': [ -1.13, -1.71, -0.58 ],\n 'PRO': [ 0.45, 0.14, -0.31 ],\n 'SER': [ 0.13, 0.46, 0.33 ],\n 'THR': [ 0.14, 0.25, 0.11 ],\n 'TRP': [ -1.85, -2.09, -0.24 ],\n 'TYR': [ -0.94, -0.71, 0.23 ],\n 'VAL': [ 0.07, -0.46, -0.53 ]\n}\nexport const DefaultResidueHydrophobicity = [ 0.00, 0.00, 0.00 ]\n\nexport const AA1: { [k: string]: string } = {\n 'HIS': 'H',\n 'ARG': 'R',\n 'LYS': 'K',\n 'ILE': 'I',\n 'PHE': 'F',\n 'LEU': 'L',\n 'TRP': 'W',\n 'ALA': 'A',\n 'MET': 'M',\n 'PRO': 'P',\n 'CYS': 'C',\n 'ASN': 'N',\n 'VAL': 'V',\n 'GLY': 'G',\n 'SER': 'S',\n 'GLN': 'Q',\n 'TYR': 'Y',\n 'ASP': 'D',\n 'GLU': 'E',\n 'THR': 'T',\n\n 'SEC': 'U', // as per IUPAC definition\n 'PYL': 'O', // as per IUPAC definition\n}\n\nexport const AA3 = Object.keys(AA1)\n\nexport const RnaBases = [ 'A', 'C', 'T', 'G', 'U', 'I' ]\n\nexport const DnaBases = [ 'DA', 'DC', 'DT', 'DG', 'DU', 'DI' ]\n\nexport const PurinBases = [ 'A', 'G', 'I', 'DA', 'DG', 'DI' ]\n\nexport const Bases = RnaBases.concat(DnaBases)\n\nexport const WaterNames = [\n 'SOL', 'WAT', 'HOH', 'H2O', 'W', 'DOD', 'D3O', 'TIP3', 'TIP4', 'SPC'\n]\n\n// all chemical components with the word \"ion\" in their name, Sep 2016\n//\n// SET SESSION group_concat_max_len = 1000000;\n// SELECT GROUP_CONCAT(id_ ORDER BY id_ ASC SEPARATOR '\", \"') from\n// (\n// SELECT count(obj_id) as c, id_\n// FROM pdb.chem_comp WHERE name LIKE \"% ION%\"\n// GROUP BY id_\n// ) AS t1;\nexport const IonNames = [\n '118', '119', '1AL', '1CU', '2FK', '2HP', '2OF', '3CO',\n '3MT', '3NI', '3OF', '3P8', '4MO', '4PU', '543', '6MO', 'ACT', 'AG', 'AL',\n 'ALF', 'AM', 'ATH', 'AU', 'AU3', 'AUC', 'AZI', 'BA', 'BCT', 'BEF', 'BF4', 'BO4',\n 'BR', 'BS3', 'BSY', 'CA', 'CAC', 'CD', 'CD1', 'CD3', 'CD5', 'CE', 'CHT', 'CL',\n 'CO', 'CO3', 'CO5', 'CON', 'CR', 'CS', 'CSB', 'CU', 'CU1', 'CU3', 'CUA', 'CUZ',\n 'CYN', 'DME', 'DMI', 'DSC', 'DTI', 'DY', 'E4N', 'EDR', 'EMC', 'ER3', 'EU',\n 'EU3', 'F', 'FE', 'FE2', 'FPO', 'GA', 'GD3', 'GEP', 'HAI', 'HG', 'HGC', 'IN',\n 'IOD', 'IR', 'IR3', 'IRI', 'IUM', 'K', 'KO4', 'LA', 'LCO', 'LCP', 'LI', 'LU',\n 'MAC', 'MG', 'MH2', 'MH3', 'MLI', 'MLT', 'MMC', 'MN', 'MN3', 'MN5', 'MN6',\n 'MO1', 'MO2', 'MO3', 'MO4', 'MO5', 'MO6', 'MOO', 'MOS', 'MOW', 'MW1', 'MW2',\n 'MW3', 'NA', 'NA2', 'NA5', 'NA6', 'NAO', 'NAW', 'NCO', 'NET', 'NH4', 'NI',\n 'NI1', 'NI2', 'NI3', 'NO2', 'NO3', 'NRU', 'O4M', 'OAA', 'OC1', 'OC2', 'OC3',\n 'OC4', 'OC5', 'OC6', 'OC7', 'OC8', 'OCL', 'OCM', 'OCN', 'OCO', 'OF1', 'OF2',\n 'OF3', 'OH', 'OS', 'OS4', 'OXL', 'PB', 'PBM', 'PD', 'PDV', 'PER', 'PI', 'PO3',\n 'PO4', 'PR', 'PT', 'PT4', 'PTN', 'RB', 'RH3', 'RHD', 'RU', 'SB', 'SCN', 'SE4',\n 'SEK', 'SM', 'SMO', 'SO3', 'SO4', 'SR', 'T1A', 'TB', 'TBA', 'TCN', 'TEA', 'TH',\n 'THE', 'TL', 'TMA', 'TRA', 'UNX', 'V', 'VN3', 'VO4', 'W', 'WO5', 'Y1', 'YB',\n 'YB2', 'YH', 'YT3', 'ZCM', 'ZN', 'ZN2', 'ZN3', 'ZNO', 'ZO3',\n // additional ion names\n 'OHX'\n]\n\n// all chemical components with the word \"%saccharide%\" in their type, Sep 2016\n//\n// SET SESSION group_concat_max_len = 1000000;\n// select GROUP_CONCAT(id_ ORDER BY id_ ASC SEPARATOR '\", \"') from\n// (\n// SELECT count(obj_id), id_\n// FROM pdb.chem_comp WHERE type like \"%SACCHARIDE%\"\n// GROUP BY id_\n// ) AS t1;\nexport const SaccharideNames = [\n '045', '0AT', '0BD', '0MK', '0NZ', '0TS', '0V4', '0XY', '0YT', '10M',\n '147', '149', '14T', '15L', '16G', '18T', '18Y', '1AR', '1BW', '1GL', '1GN',\n '1JB', '1LL', '1NA', '1S3', '26M', '26Q', '26R', '26V', '26W', '26Y', '27C',\n '289', '291', '293', '2DG', '2F8', '2FG', '2FL', '2FP', '2GL', '2M4', '2M5',\n '32O', '34V', '3CM', '3DO', '3DY', '3FM', '3LR', '3MF', '3MG', '3SA', '3ZW',\n '46D', '46M', '46Z', '48Z', '4CQ', '4GC', '4NN', '50A', '5DI', '5GF', '5MM',\n '5RP', '5SA', '5SP', '64K', '6PG', '6SA', '7JZ', '7SA', 'A1Q', 'A2G', 'AAB',\n 'AAL', 'AAO', 'ABC', 'ABD', 'ABE', 'ABF', 'ABL', 'ACG', 'ACI', 'ACR', 'ACX',\n 'ADA', 'ADG', 'ADR', 'AF1', 'AFD', 'AFL', 'AFO', 'AFP', 'AFR', 'AGC', 'AGH',\n 'AGL', 'AHR', 'AIG', 'ALL', 'ALX', 'AMU', 'AOG', 'AOS', 'ARA', 'ARB', 'ARE',\n 'ARI', 'ASG', 'ASO', 'AXP', 'AXR', 'B0D', 'B16', 'B2G', 'B4G', 'B6D', 'B8D',\n 'B9D', 'BBK', 'BCD', 'BDG', 'BDP', 'BDR', 'BEM', 'BFP', 'BGC', 'BGL', 'BGP',\n 'BGS', 'BHG', 'BMA', 'BMX', 'BNG', 'BNX', 'BOG', 'BRI', 'BXF', 'BXP', 'BXX',\n 'BXY', 'C3X', 'C4X', 'C5X', 'CAP', 'CBI', 'CBK', 'CBS', 'CDR', 'CEG', 'CGF',\n 'CHO', 'CR1', 'CR6', 'CRA', 'CT3', 'CTO', 'CTR', 'CTT', 'D6G', 'DAF', 'DAG',\n 'DDA', 'DDB', 'DDL', 'DEL', 'DFR', 'DFX', 'DG0', 'DGC', 'DGD', 'DGM', 'DGS',\n 'DIG', 'DLF', 'DLG', 'DMU', 'DNO', 'DOM', 'DP5', 'DQQ', 'DQR', 'DR2', 'DR3',\n 'DR4', 'DRI', 'DSR', 'DT6', 'DVC', 'E4P', 'E5G', 'EAG', 'EBG', 'EBQ', 'EGA',\n 'EJT', 'EPG', 'ERE', 'ERI', 'F1P', 'F1X', 'F6P', 'FBP', 'FCA', 'FCB', 'FCT',\n 'FDP', 'FDQ', 'FFC', 'FIX', 'FMO', 'FRU', 'FSI', 'FU4', 'FUB', 'FUC', 'FUD',\n 'FUL', 'FXP', 'G16', 'G1P', 'G2F', 'G3I', 'G4D', 'G4S', 'G6D', 'G6P', 'G6S',\n 'GAC', 'GAD', 'GAL', 'GC1', 'GC4', 'GCD', 'GCN', 'GCO', 'GCS', 'GCT', 'GCU',\n 'GCV', 'GCW', 'GCX', 'GE1', 'GFG', 'GFP', 'GIV', 'GL0', 'GL2', 'GL5', 'GL6',\n 'GL7', 'GL9', 'GLA', 'GLB', 'GLC', 'GLD', 'GLF', 'GLG', 'GLO', 'GLP', 'GLS',\n 'GLT', 'GLW', 'GMH', 'GN1', 'GNX', 'GP1', 'GP4', 'GPH', 'GPM', 'GQ1', 'GQ2',\n 'GQ4', 'GS1', 'GS4', 'GSA', 'GSD', 'GTE', 'GTH', 'GTK', 'GTR', 'GTZ', 'GU0',\n 'GU1', 'GU2', 'GU3', 'GU4', 'GU5', 'GU6', 'GU8', 'GU9', 'GUF', 'GUP', 'GUZ',\n 'GYP', 'GYV', 'H2P', 'HDL', 'HMS', 'HS2', 'HSD', 'HSG', 'HSH', 'HSJ', 'HSQ',\n 'HSR', 'HSU', 'HSX', 'HSY', 'HSZ', 'IAB', 'IDG', 'IDR', 'IDS', 'IDT', 'IDU',\n 'IDX', 'IDY', 'IMK', 'IN1', 'IPT', 'ISL', 'KBG', 'KD2', 'KDA', 'KDM', 'KDO',\n 'KFN', 'KO1', 'KO2', 'KTU', 'L6S', 'LAG', 'LAI', 'LAK', 'LAO', 'LAT', 'LB2',\n 'LBT', 'LCN', 'LDY', 'LGC', 'LGU', 'LM2', 'LMT', 'LMU', 'LOG', 'LOX', 'LPK',\n 'LSM', 'LTM', 'LVZ', 'LXB', 'LXZ', 'M1F', 'M3M', 'M6P', 'M8C', 'MA1', 'MA2',\n 'MA3', 'MAB', 'MAG', 'MAL', 'MAN', 'MAT', 'MAV', 'MAW', 'MBG', 'MCU', 'MDA',\n 'MDM', 'MDP', 'MFA', 'MFB', 'MFU', 'MG5', 'MGA', 'MGL', 'MLB', 'MMA', 'MMN',\n 'MN0', 'MRP', 'MTT', 'MUG', 'MVP', 'MXY', 'N1L', 'N9S', 'NAA', 'NAG', 'NBG',\n 'NDG', 'NED', 'NG1', 'NG6', 'NGA', 'NGB', 'NGC', 'NGE', 'NGF', 'NGL', 'NGS',\n 'NGY', 'NHF', 'NM6', 'NM9', 'NTF', 'NTO', 'NTP', 'NXD', 'NYT', 'OPG', 'OPM',\n 'ORP', 'OX2', 'P3M', 'P53', 'P6P', 'PA5', 'PNA', 'PNG', 'PNW', 'PRP', 'PSJ',\n 'PSV', 'PTQ', 'QDK', 'QPS', 'QV4', 'R1P', 'R1X', 'R2B', 'R5P', 'RAA', 'RAE',\n 'RAF', 'RAM', 'RAO', 'RAT', 'RB5', 'RBL', 'RCD', 'RDP', 'REL', 'RER', 'RF5',\n 'RG1', 'RGG', 'RHA', 'RIB', 'RIP', 'RNS', 'RNT', 'ROB', 'ROR', 'RPA', 'RST',\n 'RUB', 'RUU', 'RZM', 'S6P', 'S7P', 'SA0', 'SCR', 'SDD', 'SF6', 'SF9', 'SG4',\n 'SG5', 'SG6', 'SG7', 'SGA', 'SGC', 'SGD', 'SGN', 'SGS', 'SHB', 'SHG', 'SI3',\n 'SIO', 'SOE', 'SOL', 'SSG', 'SUC', 'SUP', 'SUS', 'T6P', 'T6T', 'TAG', 'TCB',\n 'TDG', 'TGK', 'TGY', 'TH1', 'TIA', 'TM5', 'TM6', 'TM9', 'TMR', 'TMX', 'TOA',\n 'TOC', 'TRE', 'TYV', 'UCD', 'UDC', 'VG1', 'X0X', 'X1X', 'X2F', 'X4S', 'X5S',\n 'X6X', 'XBP', 'XDN', 'XDP', 'XIF', 'XIM', 'XLF', 'XLS', 'XMM', 'XUL', 'XXR',\n 'XYP', 'XYS', 'YO5', 'Z3Q', 'Z6J', 'Z9M', 'ZDC', 'ZDM'\n]\n\nexport const ProteinBackboneAtoms = [\n 'CA', 'C', 'N', 'O',\n 'O1', 'O2', 'OC1', 'OC2', 'OX1', 'OXT', 'OT1', 'OT2',\n 'H', 'H1', 'H2', 'H3', 'HA', 'HN',\n 'BB'\n]\n\nexport const NucleicBackboneAtoms = [\n 'P', 'OP1', 'OP2', 'HOP2', 'HOP3',\n \"O2'\", \"O3'\", \"O4'\", \"O5'\", \"C1'\", \"C2'\", \"C3'\", \"C4'\", \"C5'\",\n \"H1'\", \"H2'\", \"H2''\", \"HO2'\", \"H3'\", \"H4'\", \"H5'\", \"H5''\", \"HO3'\", \"HO5'\",\n 'O2*', 'O3*', 'O4*', 'O5*', 'C1*', 'C2*', 'C3*', 'C4*', 'C5*'\n]\n\nexport const ResidueTypeAtoms: { [k: number]: { [k: string]: string|string[] } } = {}\n\nResidueTypeAtoms[ ProteinBackboneType ] = {\n trace: 'CA',\n direction1: 'C',\n direction2: [ 'O', 'OC1', 'O1', 'OX1', 'OXT', 'OT1', 'OT2' ],\n backboneStart: 'N',\n backboneEnd: 'C'\n}\n\nResidueTypeAtoms[ RnaBackboneType ] = {\n trace: [ \"C4'\", 'C4*' ],\n direction1: [ \"C1'\", 'C1*' ],\n direction2: [ \"C3'\", 'C3*' ],\n backboneStart: 'P',\n backboneEnd: [ \"O3'\", 'O3*' ]\n}\n\nResidueTypeAtoms[ DnaBackboneType ] = {\n trace: [ \"C3'\", 'C3*' ],\n direction1: [ \"C2'\", 'C2*' ],\n direction2: [ \"O4'\", 'O4*' ],\n backboneStart: 'P',\n backboneEnd: [ \"O3'\", 'O3*' ]\n}\n\nResidueTypeAtoms[ CgProteinBackboneType ] = {\n trace: [ 'CA', 'BB' ],\n backboneStart: [ 'CA', 'BB' ],\n backboneEnd: [ 'CA', 'BB' ]\n}\n\nResidueTypeAtoms[ CgRnaBackboneType ] = {\n trace: [ \"C4'\", 'C4*', 'P' ],\n backboneStart: [ \"C4'\", 'C4*', 'P' ],\n backboneEnd: [ \"C4'\", 'C4*', 'P' ]\n}\n\nResidueTypeAtoms[ CgDnaBackboneType ] = {\n trace: [ \"C3'\", 'C3*', \"C2'\", 'P' ], // C2' is used in martini ff\n backboneStart: [ \"C3'\", 'C3*', \"C2'\", 'P' ],\n backboneEnd: [ \"C3'\", 'C3*', \"C2'\", 'P' ]\n}\n\nResidueTypeAtoms[ UnknownBackboneType ] = {}\n\n// Mappings taken from Meeko: https://github.com/forlilab/Meeko/blob/develop/meeko/utils/autodock4_atom_types_elements.py\nexport const PDBQTSpecialElements = {\n 'HD': 'H',\n 'HS': 'H',\n 'A': 'C',\n 'NA': 'N',\n 'NS': 'N',\n 'OA': 'O',\n 'OS': 'O',\n 'SA': 'S',\n 'G0': 'C',\n 'G1': 'C',\n 'G2': 'C',\n 'G3': 'C',\n 'CG0': 'C',\n 'CG1': 'C',\n 'CG2': 'C',\n 'CG3': 'C',\n 'W': 'O'\n}","/**\n * @file Geometry\n * @author Fred Ludlow \n * @author Alexander Rose \n */\n\nimport { Vector3 } from 'three'\n\nimport { Elements } from '../structure/structure-constants'\nimport { degToRad } from '../math/math-utils'\nimport AtomProxy from '../proxy/atom-proxy'\n\n// Changed numbering so they're mostly inline with coordination number\n// from VSEPR\nexport const enum AtomGeometry {\n Spherical = 0,\n Terminal = 1,\n Linear = 2,\n Trigonal = 3,\n Tetrahedral = 4,\n TrigonalBiPyramidal = 5,\n Octahedral = 6,\n SquarePlanar = 7, // Okay, it breaks down somewhere!\n Unknown = 8\n}\n\nexport function assignGeometry (totalCoordination: number): AtomGeometry {\n switch(totalCoordination){\n case 0:\n return AtomGeometry.Spherical\n case 1:\n return AtomGeometry.Terminal\n case 2:\n return AtomGeometry.Linear\n case 3:\n return AtomGeometry.Trigonal\n case 4:\n return AtomGeometry.Tetrahedral\n default:\n return AtomGeometry.Unknown\n }\n}\n\nexport const Angles = new Map([\n [ AtomGeometry.Linear, degToRad(180) ],\n [ AtomGeometry.Trigonal, degToRad(120) ],\n [ AtomGeometry.Tetrahedral, degToRad(109.4721) ],\n [ AtomGeometry.Octahedral, degToRad(90) ]\n])\n\n/**\n * Calculate the angles x-1-2 for all x where x is a heavy atom bonded to ap1.\n * @param {AtomProxy} ap1 First atom (angle centre)\n * @param {AtomProxy} ap2 Second atom\n * @return {number[]} Angles in radians\n */\nexport function calcAngles (ap1: AtomProxy, ap2: AtomProxy): number[] {\n let angles: number[] = []\n const d1 = new Vector3()\n const d2 = new Vector3()\n d1.subVectors(ap2 as any, ap1 as any)\n ap1.eachBondedAtom( x => {\n if (x.number !== Elements.H) {\n d2.subVectors(x as any, ap1 as any)\n angles.push(d1.angleTo(d2))\n }\n })\n return angles\n}\n\n/**\n * Find two neighbours of ap1 to define a plane (if possible) and\n * measure angle out of plane to ap2\n * @param {AtomProxy} ap1 First atom (angle centre)\n * @param {AtomProxy} ap2 Second atom (out-of-plane)\n * @return {number} Angle from plane to second atom\n */\nexport function calcPlaneAngle (ap1: AtomProxy, ap2: AtomProxy): number | undefined {\n const x1 = ap1.clone()\n\n const v12 = new Vector3()\n v12.subVectors(ap2 as any, ap1 as any)\n\n const neighbours = [new Vector3(), new Vector3()]\n let ni = 0\n ap1.eachBondedAtom( x => {\n if (ni > 1) { return }\n if (x.number !== Elements.H) {\n x1.index = x.index\n neighbours[ni++].subVectors(x as any, ap1 as any)\n }\n })\n if (ni === 1) {\n x1.eachBondedAtom( x => {\n if (ni > 1) { return }\n if (x.number !== Elements.H && x.index !== ap1.index){\n neighbours[ni++].subVectors(x as any, ap1 as any)\n }\n })\n }\n if (ni !== 2) {\n return\n }\n\n const cp = neighbours[0].cross(neighbours[1])\n return Math.abs((Math.PI / 2) - cp.angleTo(v12))\n}\n","/**\n * @file Valence Model\n * @author Fred Ludlow \n * @author Alexander Rose \n */\n\n/**\n * Reworked ValenceModel\n *\n * TODO:\n * Ensure proper treatment of disorder/models. e.g. V257 N in 5vim\n * Formal charge of 255 for SO4 anion (e.g. 5ghl)\n * Have removed a lot of explicit features (as I think they're more\n * generally captured by better VM).\n * Could we instead have a \"delocalised negative/positive\" charge\n * feature and flag these up?\n *\n */\nimport { Data } from '../structure/data'\nimport AtomProxy from '../proxy/atom-proxy'\nimport { AtomGeometry, assignGeometry } from './geometry'\nimport { Elements } from '../structure/structure-constants'\n\n/**\n * Are we involved in some kind of pi system. Either explicitly forming\n * double bond or N, O next to a double bond, except:\n *\n * N,O with degree 4 cannot be conjugated.\n * N,O adjacent to P=O or S=O do not qualify (keeps sulfonamide N sp3 geom)\n */\nfunction isConjugated (a: AtomProxy) {\n const _bp = a.structure.getBondProxy()\n const atomicNumber = a.number\n const hetero = atomicNumber === Elements.O || atomicNumber === Elements.N\n\n if (hetero && a.bondCount === 4) {\n return false\n }\n\n let flag = false\n\n a.eachBond(b => {\n if (b.bondOrder > 1) {\n flag = true\n return\n }\n if (hetero) {\n const a2 = b.getOtherAtom(a)\n\n a2.eachBond(b2 => {\n if (b2.bondOrder > 1) {\n const atomicNumber2 = a2.number\n if (\n (atomicNumber2 === Elements.P || atomicNumber2 === Elements.S) &&\n b2.getOtherAtom(a2).number === Elements.O\n ) {\n return\n }\n flag = true\n }\n }, _bp) // Avoid reuse of structure._bp\n }\n })\n\n return flag\n}\n\n/* function hasExplicitCharge(r: ResidueProxy) {\n let flag = false\n r.eachAtom(a => {\n if (a.formalCharge != null && a.formalCharge !== 0) flag = true\n })\n return flag\n}\n\nfunction hasExplicitHydrogen(r: ResidueProxy) {\n let flag = false\n r.eachAtom(a => {\n if (a.number === Elements.H) flag = true\n })\n return flag\n} */\n\nexport function explicitValence (a: AtomProxy) {\n let v = 0\n a.eachBond(b => v += b.bondOrder)\n return v\n}\n\n/**\n * Attempts to produce a consistent charge and implicit\n * H-count for an atom.\n *\n * If both params.assignCharge and params.assignH, this\n * approximately followsthe rules described in\n * https://docs.eyesopen.com/toolkits/python/oechemtk/valence.html#openeye-hydrogen-count-model\n *\n * If only charge or hydrogens are to be assigned it takes\n * a much simpler view and deduces one from the other\n *\n * @param {AtomProxy} a Atom to analyze\n * @param {assignChargeHParams} params What to assign\n */\nexport function calculateHydrogensCharge (a: AtomProxy, params: ValenceModelParams) {\n const hydrogenCount = a.bondToElementCount(Elements.H)\n let charge = a.formalCharge || 0\n\n const assignCharge = (params.assignCharge === 'always' ||\n (params.assignCharge === 'auto' && charge === 0))\n const assignH = (params.assignH === 'always' ||\n (params.assignH === 'auto' && hydrogenCount === 0))\n\n const degree = a.bondCount\n const valence = explicitValence(a)\n\n const conjugated = isConjugated(a)\n const multiBond = (valence - degree > 0)\n\n\n let implicitHCount = 0\n let geom = AtomGeometry.Unknown\n\n switch (a.number) {\n case Elements.H:\n if (assignCharge){\n if (degree === 0){\n charge = 1\n geom = AtomGeometry.Spherical\n } else if (degree === 1) {\n charge = 0\n geom = AtomGeometry.Terminal\n }\n }\n break\n\n case Elements.C:\n // TODO: Isocyanide?\n if (assignCharge) {\n charge = 0 // Assume carbon always neutral\n }\n if (assignH) {\n // Carbocation/carbanion are 3-valent\n implicitHCount = Math.max(0, 4 - valence - Math.abs(charge))\n }\n // Carbocation is planar, carbanion is tetrahedral\n geom = assignGeometry(degree + implicitHCount + Math.max(0, -charge))\n break\n\n case Elements.N:\n if (assignCharge) {\n if (!assignH) { // Trust input H explicitly:\n charge = valence - 3\n } else if (conjugated && valence < 4) {\n // Neutral unless amidine/guanidine double-bonded N:\n if (degree - hydrogenCount === 1 && valence - hydrogenCount === 2) {\n charge = 1\n } else {\n charge = 0\n }\n } else {\n // Sulfonamide nitrogen and classed as sp3 in conjugation model but\n // they won't be charged\n // Don't assign charge to nitrogens bound to metals\n let flag = false\n a.eachBondedAtom(ba => {\n if (ba.number === Elements.S || ba.isMetal()) flag = true\n })\n if (flag) charge = 0\n else charge = 1\n // TODO: Planarity sanity check?\n }\n\n }\n\n if (assignH) {\n // NH4+ -> 4, 1' amide -> 2, nitro N/N+ depiction -> 0\n implicitHCount = Math.max(0, 3 - valence + charge)\n }\n\n if (conjugated && !multiBond) {\n // Amide, anilinic N etc. cannot consider lone-pair for geometry purposes\n // Anilinic N geometry is depenent on ring electronics, for our purposes we\n // assume it's trigonal!\n geom = assignGeometry(degree + implicitHCount - charge)\n } else {\n // Everything else, pyridine, amine, nitrile, lp plays normal role:\n geom = assignGeometry(degree + implicitHCount + 1 - charge)\n }\n break\n\n case Elements.O:\n if (assignCharge) {\n if (!assignH) {\n charge = valence - 2 //\n }\n if (valence === 1) {\n a.eachBondedAtom(ba => {\n ba.eachBond(b => {\n const oa = b.getOtherAtom(ba)\n if (oa.index !== a.index && oa.number === Elements.O && b.bondOrder === 2){\n charge = -1\n }\n })\n })\n }\n }\n if (assignH) {\n // ethanol -> 1, carboxylate -> -1\n implicitHCount = Math.max(0, 2 - valence + charge)\n }\n if (conjugated && !multiBond){\n // carboxylate OH, phenol OH, one lone-pair taken up with conjugation\n geom = assignGeometry(degree + implicitHCount - charge + 1)\n } else {\n // Carbonyl (trigonal)\n geom = assignGeometry(degree + implicitHCount - charge + 2)\n }\n break\n\n // Only handles thiols/thiolates/thioether/sulfonium. Sulfoxides and higher\n // oxidiation states are assumed neutral S (charge carried on O if required)\n case Elements.S:\n if (assignCharge) {\n if (!assignH) {\n if (valence <= 3 && !a.bondToElementCount(Elements.O)) {\n charge = valence - 2 // e.g. explicitly deprotonated thiol\n } else {\n charge = 0\n }\n }\n }\n if (assignH){\n if (valence < 2){\n implicitHCount = Math.max(0, 2 - valence + charge)\n }\n }\n if (valence <= 3){\n // Thiol, thiolate, tioether -> tetrahedral\n geom = assignGeometry(degree + implicitHCount - charge + 2)\n }\n\n break\n\n case Elements.F:\n case Elements.CL:\n case Elements.BR:\n case Elements.I:\n case Elements.AT:\n // Never implicitly protonate halides\n if (assignCharge) {\n charge = valence - 1\n }\n break\n\n case Elements.LI:\n case Elements.NA:\n case Elements.K:\n case Elements.RB:\n case Elements.CS:\n case Elements.FR:\n if (assignCharge) {\n charge = 1 - valence\n }\n break\n\n case Elements.BE:\n case Elements.MG:\n case Elements.CA:\n case Elements.SR:\n case Elements.BA:\n case Elements.RA:\n if (assignCharge) {\n charge = 2 - valence\n }\n break\n\n default:\n console.warn('Requested charge, protonation for an unhandled element', a.element)\n }\n\n return [ charge, implicitHCount, implicitHCount + hydrogenCount, geom ]\n}\n\n\nexport interface ValenceModel {\n charge: Int8Array,\n implicitH: Int8Array,\n totalH: Int8Array,\n idealGeometry: Int8Array\n}\n\nexport interface ValenceModelParams {\n assignCharge: string,\n assignH: string\n}\n\nexport function ValenceModel (data: Data, params: ValenceModelParams) {\n const structure = data.structure\n const n = structure.atomCount\n\n const charge = new Int8Array(n)\n const implicitH = new Int8Array(n)\n const totalH = new Int8Array(n)\n const idealGeometry = new Int8Array(n)\n\n structure.eachAtom(a => {\n const i = a.index\n const [ chg, implH, totH, geom ] = calculateHydrogensCharge(a, params)\n charge[ i ] = chg\n implicitH[ i ] = implH\n totalH[ i ] = totH\n idealGeometry[ i ] = geom\n })\n\n return { charge, implicitH, totalH, idealGeometry }\n}","\nimport Structure from './structure'\nimport SpatialHash from '../geometry/spatial-hash'\nimport { ValenceModel } from '../chemistry/valence-model'\n\nexport interface Data {\n structure: Structure\n '@spatialLookup': SpatialHash | undefined\n '@valenceModel': ValenceModel | undefined\n}\n\nexport function createData(structure: Structure): Data {\n return {\n structure,\n '@spatialLookup': undefined,\n '@valenceModel': undefined\n }\n}\n\nexport function spatialLookup(data: Data): SpatialHash {\n if (data['@spatialLookup']) return data['@spatialLookup']!\n const lookup = new SpatialHash(data.structure.atomStore, data.structure.boundingBox)\n data['@spatialLookup'] = lookup\n return lookup\n}\n\nexport function valenceModel(data: Data): ValenceModel {\n if (data['@valenceModel']) return data['@valenceModel']!\n const valenceModel = ValenceModel(data, {assignCharge: 'auto', assignH: 'auto'})\n data['@valenceModel'] = valenceModel\n return valenceModel\n}\n","/**\n * @file Functional Groups\n * @author Alexander Rose \n */\n\nimport AtomProxy from '../proxy/atom-proxy'\nimport { Elements } from '../structure/structure-constants'\n\n/**\n * Nitrogen in a quaternary amine\n */\nexport function isQuaternaryAmine (a: AtomProxy) {\n return (\n a.number === 7 &&\n a.bondCount === 4 &&\n a.bondToElementCount(Elements.H) === 0\n )\n}\n\n/**\n * Nitrogen in a tertiary amine\n */\nexport function isTertiaryAmine (a: AtomProxy, idealValence: number) {\n return (\n a.number === 7 &&\n a.bondCount >= 3 &&\n idealValence === 3\n )\n}\n\n/**\n * Nitrogen in an imide\n */\nexport function isImide (a: AtomProxy) {\n let flag = false\n if (a.number === Elements.N && (a.bondCount - a.bondToElementCount(Elements.H)) === 2) {\n let carbonylCount = 0\n a.eachBondedAtom(ba => {\n if (isCarbonyl(ba)) ++carbonylCount\n })\n flag = carbonylCount === 2\n }\n return flag\n}\n\n/**\n * Nitrogen in an amide\n */\nexport function isAmide (a: AtomProxy) {\n let flag = false\n if (a.number === Elements.N && (a.bondCount - a.bondToElementCount(Elements.H)) === 2) {\n let carbonylCount = 0\n a.eachBondedAtom(ba => {\n if (isCarbonyl(ba)) ++carbonylCount\n })\n flag = carbonylCount === 1\n }\n return flag\n}\n\n/**\n * Sulfur in a sulfonium group\n */\nexport function isSulfonium (a: AtomProxy) {\n return (\n a.number === 16 &&\n a.bondCount === 3 &&\n a.bondToElementCount(Elements.H) === 0\n )\n}\n\n/**\n * Sulfur in a sulfonic acid or sulfonate group\n */\nexport function isSulfonicAcid (a: AtomProxy) {\n return (\n a.number === 16 &&\n a.bondToElementCount(Elements.O) === 3\n )\n}\n\n/**\n * Sulfur in a sulfate group\n */\nexport function isSulfate (a: AtomProxy) {\n return (\n a.number === 16 &&\n a.bondToElementCount(Elements.O) === 4\n )\n}\n\n/**\n * Phosphor in a phosphate group\n */\nexport function isPhosphate (a: AtomProxy) {\n return (\n a.number === 15 &&\n a.bondToElementCount(Elements.O) === a.bondCount\n )\n}\n\n/**\n * Halogen with one bond to a carbon\n */\nexport function isHalocarbon (a: AtomProxy) {\n return (\n a.isHalogen() &&\n a.bondCount === 1 &&\n a.bondToElementCount(Elements.C) === 1\n )\n}\n\n/**\n * Carbon in a carbonyl/acyl group\n */\nexport function isCarbonyl (a: AtomProxy) {\n let flag = false\n if (a.number === Elements.C) {\n a.eachBond(b => {\n if (b.bondOrder === 2 && b.getOtherAtom(a).number === Elements.O) {\n flag = true\n }\n })\n }\n return flag\n}\n\n/**\n * Carbon in a carboxylate group\n */\nexport function isCarboxylate (a: AtomProxy) {\n let terminalOxygenCount = 0\n if (\n a.number === 6 &&\n a.bondToElementCount(Elements.O) === 2 &&\n a.bondToElementCount(Elements.C) === 1\n ) {\n a.eachBondedAtom(ba => {\n if (ba.number === 8 && ba.bondCount - ba.bondToElementCount(Elements.H) === 1) {\n ++terminalOxygenCount\n }\n })\n }\n return terminalOxygenCount === 2\n}\n\n/**\n * Carbon in a guanidine group\n */\nexport function isGuanidine (a: AtomProxy) {\n let terminalNitrogenCount = 0\n if (\n a.number === 6 &&\n a.bondCount === 3 &&\n a.bondToElementCount(Elements.N) === 3\n ) {\n a.eachBondedAtom(ba => {\n if (ba.bondCount - ba.bondToElementCount(Elements.H) === 1) {\n ++terminalNitrogenCount\n }\n })\n }\n return terminalNitrogenCount === 2\n}\n\n/**\n * Carbon in a acetamidine group\n */\nexport function isAcetamidine (a: AtomProxy) {\n let terminalNitrogenCount = 0\n if (\n a.number === 6 &&\n a.bondCount === 3 &&\n a.bondToElementCount(Elements.N) === 2 &&\n a.bondToElementCount(Elements.C) === 1\n ) {\n a.eachBondedAtom(ba => {\n if (ba.bondCount - ba.bondToElementCount(Elements.H) === 1) {\n ++terminalNitrogenCount\n }\n })\n }\n return terminalNitrogenCount === 2\n}\n\nconst PolarElements = [\n Elements.N, Elements.O, Elements.S,\n Elements.F, Elements.CL, Elements.BR, Elements.I\n]\n\nexport function isPolar (a: AtomProxy) {\n return PolarElements.includes(a.number)\n}\n\nexport function hasPolarNeighbour (a: AtomProxy) {\n let flag = false\n a.eachBondedAtom(ba => {\n if (isPolar(ba)) flag = true\n })\n return flag\n}\n\nexport function hasAromaticNeighbour (a: AtomProxy) {\n let flag = false\n a.eachBondedAtom(function (bap) {\n if (bap.aromatic) flag = true\n })\n return flag\n}\n","/**\n * @file Charged\n * @author Alexander Rose \n * @author Fred Ludlow \n */\n\nimport { Vector3 } from 'three'\n\nimport { defaults } from '../../utils'\nimport { radToDeg } from '../../math/math-utils'\nimport Structure from '../../structure/structure'\nimport { AA3, Bases, Elements } from '../../structure/structure-constants'\nimport { valenceModel } from '../../structure/data'\nimport {\n isGuanidine, isAcetamidine, isSulfonicAcid, isPhosphate, isSulfate, isCarboxylate\n} from '../functional-groups'\nimport {\n Features, FeatureType, FeatureGroup,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\n\nconst PositvelyCharged = [ 'ARG', 'HIS', 'LYS' ]\nconst NegativelyCharged = [ 'GLU', 'ASP' ]\n\nexport function addPositiveCharges (structure: Structure, features: Features) {\n const { charge } = valenceModel(structure.data)\n const atomInGroupDict: { [atomIndex: number]: true } = {}\n\n structure.eachResidue(r => {\n if (PositvelyCharged.includes(r.resname)) {\n const state = createFeatureState(FeatureType.PositiveCharge)\n r.eachAtom(a => {\n if (a.number === Elements.N && a.isSidechain()) {\n addAtom(state, a)\n }\n })\n addFeature(features, state)\n } else if(!AA3.includes(r.resname) && !r.isNucleic()) {\n r.eachAtom(a => {\n let addGroup = false\n const state = createFeatureState(FeatureType.PositiveCharge)\n if (isGuanidine(a)) {\n state.group = FeatureGroup.Guanidine\n addGroup = true\n } else if (isAcetamidine(a)) {\n state.group = FeatureGroup.Acetamidine\n addGroup = true\n }\n if (addGroup) {\n a.eachBondedAtom(a => {\n if (a.number === Elements.N) {\n atomInGroupDict[a.index] = true\n addAtom(state, a)\n }\n })\n addFeature(features, state)\n }\n })\n r.eachAtom(a => {\n const state = createFeatureState(FeatureType.PositiveCharge)\n if (charge[a.index] > 0) {\n if (!atomInGroupDict[a.index]) {\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n })\n }\n })\n}\n\nexport function addNegativeCharges (structure: Structure, features: Features) {\n const { charge } = valenceModel(structure.data)\n const atomInGroupDict: { [atomIndex: number]: true } = {}\n\n structure.eachResidue(r => {\n if (NegativelyCharged.includes(r.resname)) {\n const state = createFeatureState(FeatureType.NegativeCharge)\n r.eachAtom(a => {\n if (a.number === Elements.O && a.isSidechain()) {\n addAtom(state, a)\n }\n })\n addFeature(features, state)\n } else if (Bases.includes(r.resname)) {\n const state = createFeatureState(FeatureType.NegativeCharge)\n r.eachAtom(a => {\n if (isPhosphate(a)) {\n state.group = FeatureGroup.Phosphate\n a.eachBondedAtom(a => {\n if (a.number === Elements.O) addAtom(state, a)\n })\n addFeature(features, state)\n }\n })\n } else if(!AA3.includes(r.resname) && !Bases.includes(r.resname)) {\n r.eachAtom(a => {\n let addGroup = false\n const state = createFeatureState(FeatureType.NegativeCharge)\n if (isSulfonicAcid(a)) {\n state.group = FeatureGroup.SulfonicAcid\n addGroup = true\n } else if (isPhosphate(a)) {\n state.group = FeatureGroup.Phosphate\n addGroup = true\n } else if (isSulfate(a)) {\n state.group = FeatureGroup.Sulfate\n addGroup = true\n } else if (isCarboxylate(a)) {\n state.group = FeatureGroup.Carboxylate\n addGroup = true\n }\n if (addGroup) {\n a.eachBondedAtom(a => {\n if (a.number === Elements.O) {\n atomInGroupDict[a.index] = true\n addAtom(state, a)\n }\n })\n addFeature(features, state)\n }\n })\n r.eachAtom(a => {\n const state = createFeatureState(FeatureType.NegativeCharge)\n if (charge[a.index] < 0) {\n if (!atomInGroupDict[a.index]) {\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n })\n }\n })\n}\n\nexport function addAromaticRings (structure: Structure, features: Features) {\n const a = structure.getAtomProxy()\n structure.eachResidue(r => {\n const rings = r.getAromaticRings()\n if (rings) {\n const offset = r.atomOffset\n rings.forEach(ring => {\n const state = createFeatureState(FeatureType.AromaticRing)\n ring.forEach(i => {\n a.index = i + offset\n addAtom(state, a)\n })\n addFeature(features, state)\n })\n }\n })\n}\n\nfunction isIonicInteraction (ti: FeatureType, tj: FeatureType) {\n return (\n (ti === FeatureType.NegativeCharge && tj === FeatureType.PositiveCharge) ||\n (ti === FeatureType.PositiveCharge && tj === FeatureType.NegativeCharge)\n )\n}\n\nfunction isPiStacking (ti: FeatureType, tj: FeatureType) {\n return ti === FeatureType.AromaticRing && tj === FeatureType.AromaticRing\n}\n\nfunction isCationPi (ti: FeatureType, tj: FeatureType) {\n return (\n (ti === FeatureType.AromaticRing && tj === FeatureType.PositiveCharge) ||\n (ti === FeatureType.PositiveCharge && tj === FeatureType.AromaticRing)\n )\n}\n\nexport interface ChargedContactsParams {\n maxIonicDist?: number\n maxPiStackingDist?: number\n maxPiStackingOffset?: number\n maxPiStackingAngle?: number\n maxCationPiDist?: number\n maxCationPiOffset?: number\n masterModelIndex?: number\n}\n\nexport function addChargedContacts (structure: Structure, contacts: Contacts, params: ChargedContactsParams = {}) {\n const maxIonicDist = defaults(params.maxIonicDist, ContactDefaultParams.maxIonicDist)\n const maxPiStackingDist = defaults(params.maxPiStackingDist, ContactDefaultParams.maxPiStackingDist)\n const maxPiStackingOffset = defaults(params.maxPiStackingOffset, ContactDefaultParams.maxPiStackingOffset)\n const maxPiStackingAngle = defaults(params.maxPiStackingAngle, ContactDefaultParams.maxPiStackingAngle)\n const maxCationPiDist = defaults(params.maxCationPiDist, ContactDefaultParams.maxCationPiDist)\n const maxCationPiOffset = defaults(params.maxCationPiOffset, ContactDefaultParams.maxCationPiOffset)\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const maxDistance = Math.max(maxIonicDist + 2, maxPiStackingDist, maxCationPiDist)\n // const maxSaltBridgeDistSq = maxSaltBridgeDist * maxSaltBridgeDist\n const maxPiStackingDistSq = maxPiStackingDist * maxPiStackingDist\n const maxCationPiDistSq = maxCationPiDist * maxCationPiDist\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const ax = structure.atomStore.x\n const ay = structure.atomStore.y\n const az = structure.atomStore.z\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n const areAtomSetsWithinDist = function (atomSet1: number[], atomSet2: number[], maxDist: number) {\n const sn = atomSet1.length\n const sm = atomSet2.length\n for (let si = 0; si < sn; ++si) {\n ap1.index = atomSet1[ si ]\n for (let sj = 0; sj < sm; ++sj) {\n ap2.index = atomSet2[ sj ]\n if (ap1.distanceTo(ap2) <= maxDist) {\n return true\n }\n }\n }\n return false\n }\n\n const v1 = new Vector3()\n const v2 = new Vector3()\n const v3 = new Vector3()\n const d1 = new Vector3()\n const d2 = new Vector3()\n const n1 = new Vector3()\n const n2 = new Vector3()\n\n const getNormal = function (atoms: number[], normal: Vector3) {\n v1.set(ax[ atoms[ 0 ] ], ay[ atoms[ 0 ] ], az[ atoms[ 0 ] ])\n v2.set(ax[ atoms[ 1 ] ], ay[ atoms[ 1 ] ], az[ atoms[ 1 ] ])\n v3.set(ax[ atoms[ 2 ] ], ay[ atoms[ 2 ] ], az[ atoms[ 2 ] ])\n d1.subVectors(v1, v2)\n d2.subVectors(v1, v3)\n normal.crossVectors(d1, d2)\n }\n\n const getOffset = function (i: number, j: number, normal: Vector3) {\n v1.set(x[ i ], y[ i ], z[ i ])\n v2.set(x[ j ], y[ j ], z[ j ])\n return v1.sub(v2).projectOnPlane(normal).add(v2).distanceTo(v2)\n }\n\n const add = function (i: number, j: number, ct: ContactType) {\n featureSet.setBits(i, j)\n contactStore.addContact(i, j, ct)\n }\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxDistance, (j, dSq) => {\n if (j <= i) return\n\n ap1.index = atomSets[ i ][ 0 ]\n ap2.index = atomSets[ j ][ 0 ]\n\n if (invalidAtomContact(ap1, ap2, masterIdx)) return\n\n const ti = types[ i ]\n const tj = types[ j ]\n\n if (isIonicInteraction(ti, tj)) {\n if (areAtomSetsWithinDist(atomSets[ i ], atomSets[ j ], maxIonicDist)) {\n add(i, j, ContactType.IonicInteraction)\n }\n } else if (isPiStacking(ti, tj)) {\n if (dSq <= maxPiStackingDistSq) {\n getNormal(atomSets[ i ], n1)\n getNormal(atomSets[ j ], n2)\n\n const angle = radToDeg(n1.angleTo(n2))\n const offset = Math.min(getOffset(i, j, n2), getOffset(j, i, n1))\n if (offset <= maxPiStackingOffset) {\n if (angle <= maxPiStackingAngle || angle >= 180 - maxPiStackingAngle) {\n add(i, j, ContactType.PiStacking) // parallel\n } else if (angle <= maxPiStackingAngle + 90 && angle >= 90 - maxPiStackingAngle) {\n add(i, j, ContactType.PiStacking) // t-shaped\n }\n }\n }\n } else if (isCationPi(ti, tj)) {\n if (dSq <= maxCationPiDistSq) {\n const [ l, k ] = ti === FeatureType.AromaticRing ? [ i, j ] : [ j, i ]\n\n getNormal(atomSets[ l ], n1)\n const offset = getOffset(k, l, n1)\n if (offset <= maxCationPiOffset) {\n add(l, k, ContactType.CationPi)\n }\n }\n }\n })\n }\n}\n","/**\n * @file Hydrogen Bonds\n * @author Alexander Rose \n * @author Fred Ludlow \n */\nimport { defaults } from '../../utils'\nimport { degToRad } from '../../math/math-utils'\nimport Structure from '../../structure/structure'\nimport AtomProxy from '../../proxy/atom-proxy'\nimport { valenceModel } from '../../structure/data'\nimport { Elements } from '../../structure/structure-constants'\nimport { Angles, AtomGeometry, calcAngles, calcPlaneAngle } from '../geometry'\nimport {\n Features, FeatureType,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\n\n\n// Geometric characteristics of hydrogen bonds involving sulfur atoms in proteins\n// https://doi.org/10.1002/prot.22327\n\n// Satisfying Hydrogen Bonding Potential in Proteins (HBPLUS)\n// https://doi.org/10.1006/jmbi.1994.1334\n// http://www.csb.yale.edu/userguides/datamanip/hbplus/hbplus_descrip.html\n\n/**\n * Potential hydrogen donor\n */\nexport function addHydrogenDonors (structure: Structure, features: Features) {\n const { totalH } = valenceModel(structure.data)\n\n structure.eachAtom(a => {\n const state = createFeatureState(FeatureType.HydrogenDonor)\n\n const an = a.number\n if (isHistidineNitrogen(a)) {\n // include both nitrogen atoms in histidine due to\n // their often ambiguous protonation assignment\n addAtom(state, a)\n addFeature(features, state)\n } else if (\n totalH[ a.index ] > 0 &&\n (an === Elements.N || an === Elements.O || an === Elements.S)\n ) {\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\n/**\n * Weak hydrogen donor.\n */\nexport function addWeakHydrogenDonors (structure: Structure, features: Features) {\n const { totalH } = valenceModel(structure.data)\n\n structure.eachAtom(a => {\n if (\n a.number === Elements.C &&\n totalH[ a.index ] > 0 &&\n (\n a.bondToElementCount(Elements.N) > 0 ||\n a.bondToElementCount(Elements.O) > 0 ||\n inAromaticRingWithElectronNegativeElement(a)\n )\n ) {\n const state = createFeatureState(FeatureType.WeakHydrogenDonor)\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\nfunction inAromaticRingWithElectronNegativeElement (a: AtomProxy) {\n if (!a.isAromatic()) return false\n\n const ringData = a.residueType.getRings()\n if (!ringData) return false\n\n let hasElement = false\n const rings = ringData.rings\n rings.forEach(ring => {\n if (hasElement) return // already found one\n if (ring.some(idx => (a.index - a.residueAtomOffset) === idx)) { // in ring\n hasElement = ring.some(idx => {\n const atomTypeId = a.residueType.atomTypeIdList[ idx ]\n const number = a.atomMap.get(atomTypeId).number\n return number === Elements.N || number === Elements.O\n })\n }\n })\n\n return hasElement\n}\n\n/**\n * Potential hydrogen acceptor\n */\nexport function addHydrogenAcceptors (structure: Structure, features: Features) {\n const { charge, implicitH, idealGeometry } = valenceModel(structure.data)\n\n structure.eachAtom(a => {\n const state = createFeatureState(FeatureType.HydrogenAcceptor)\n\n const an = a.number\n if (an === Elements.O) {\n // Basically assume all oxygen atoms are acceptors!\n addAtom(state, a)\n addFeature(features, state)\n }else if (an === Elements.N) {\n if (isHistidineNitrogen(a)) {\n // include both nitrogen atoms in histidine due to\n // their often ambiguous protonation assignment\n addAtom(state, a)\n addFeature(features, state)\n } else if (charge[ a.index ] < 1){\n // Neutral nitrogen might be an acceptor\n // It must have at least one lone pair not conjugated\n const totalBonds = a.bondCount + implicitH[ a.index ]\n const ig = idealGeometry[ a.index ]\n if (\n (ig === AtomGeometry.Tetrahedral && totalBonds < 4) ||\n (ig === AtomGeometry.Trigonal && totalBonds < 3) ||\n (ig === AtomGeometry.Linear && totalBonds < 2)\n ) {\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n }else if (an === 16) { // S\n if (a.resname === 'CYS' || a.resname === 'MET' || a.formalCharge === -1) {\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n })\n}\n\n/**\n * Atom that is only bound to carbon or hydrogen\n */\n// function isHydrocarbon (atom: AtomProxy) {\n// let flag = true\n// atom.eachBondedAtom(ap => {\n// const e = ap.element\n// if (e !== 'C' && e !== 'H') flag = false\n// })\n// return flag\n// }\n\nfunction isHistidineNitrogen (ap: AtomProxy) {\n return ap.resname === 'HIS' && ap.number == Elements.N && ap.isRing()\n}\n\nfunction isBackboneHydrogenBond (ap1: AtomProxy, ap2: AtomProxy) {\n return ap1.isBackbone() && ap2.isBackbone()\n}\n\nfunction isWaterHydrogenBond (ap1: AtomProxy, ap2: AtomProxy) {\n return ap1.isWater() && ap2.isWater()\n}\n\nfunction isHydrogenBond (ti: FeatureType, tj: FeatureType) {\n return (\n (ti === FeatureType.HydrogenAcceptor && tj === FeatureType.HydrogenDonor) ||\n (ti === FeatureType.HydrogenDonor && tj === FeatureType.HydrogenAcceptor)\n )\n}\n\nfunction isWeakHydrogenBond (ti: FeatureType, tj: FeatureType){\n return (\n (ti === FeatureType.WeakHydrogenDonor && tj === FeatureType.HydrogenAcceptor) ||\n (ti === FeatureType.HydrogenAcceptor && tj === FeatureType.WeakHydrogenDonor)\n )\n}\n\nfunction getHydrogenBondType (ap1: AtomProxy, ap2: AtomProxy) {\n if (isWaterHydrogenBond(ap1, ap2)) {\n return ContactType.WaterHydrogenBond\n } else if (isBackboneHydrogenBond(ap1, ap2)) {\n return ContactType.BackboneHydrogenBond\n } else {\n return ContactType.HydrogenBond\n }\n}\n\nexport interface HydrogenBondParams {\n maxHbondDist?: number\n maxHbondSulfurDist?: number\n maxHbondAccAngle?: number\n maxHbondDonAngle?: number\n maxHbondAccPlaneAngle?: number\n maxHbondDonPlaneAngle?: number\n backboneHbond?: boolean\n waterHbond?: boolean\n masterModelIndex?: number\n}\n\n/**\n * All pairs of hydrogen donor and acceptor atoms\n */\nexport function addHydrogenBonds (structure: Structure, contacts: Contacts, params: HydrogenBondParams = {}) {\n const maxHbondDist = defaults(params.maxHbondDist, ContactDefaultParams.maxHbondDist)\n const maxHbondSulfurDist = defaults(params.maxHbondSulfurDist, ContactDefaultParams.maxHbondSulfurDist)\n const maxHbondAccAngle = degToRad(defaults(params.maxHbondAccAngle, ContactDefaultParams.maxHbondAccAngle))\n const maxHbondDonAngle = degToRad(defaults(params.maxHbondDonAngle, ContactDefaultParams.maxHbondDonAngle))\n const maxHbondAccPlaneAngle = degToRad(defaults(params.maxHbondAccPlaneAngle, ContactDefaultParams.maxHbondAccPlaneAngle))\n const maxHbondDonPlaneAngle = degToRad(defaults(params.maxHbondDonPlaneAngle, ContactDefaultParams.maxHbondDonPlaneAngle))\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const maxDist = Math.max(maxHbondDist, maxHbondSulfurDist)\n const maxHbondDistSq = maxHbondDist * maxHbondDist\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const { idealGeometry } = valenceModel(structure.data)\n\n const donor = structure.getAtomProxy()\n const acceptor = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxDist, (j, dSq) => {\n if (j <= i) return\n\n const ti = types[ i ]\n const tj = types[ j ]\n\n const isWeak = isWeakHydrogenBond(ti, tj)\n if (!isWeak && !isHydrogenBond(ti, tj)) return\n\n const [ l, k ] = tj === FeatureType.HydrogenAcceptor ? [ i, j ] : [ j, i ]\n\n donor.index = atomSets[ l ][ 0 ]\n acceptor.index = atomSets[ k ][ 0 ]\n\n if (acceptor.index === donor.index) return // DA to self\n\n if (invalidAtomContact(donor, acceptor, masterIdx)) return\n if (donor.number !== Elements.S && acceptor.number !== Elements.S && dSq > maxHbondDistSq) return\n if (donor.connectedTo(acceptor)) return\n\n const donorAngles = calcAngles(donor, acceptor)\n const idealDonorAngle = Angles.get(idealGeometry[donor.index]) || degToRad(120)\n if (donorAngles.some(donorAngle => {\n return Math.abs(idealDonorAngle - donorAngle) > maxHbondDonAngle\n })) return\n\n if (idealGeometry[donor.index] === AtomGeometry.Trigonal){\n const outOfPlane = calcPlaneAngle(donor, acceptor)\n if (outOfPlane !== undefined && outOfPlane > maxHbondDonPlaneAngle) return\n }\n\n const acceptorAngles = calcAngles(acceptor, donor)\n const idealAcceptorAngle = Angles.get(idealGeometry[acceptor.index]) || degToRad(120)\n if (acceptorAngles.some(acceptorAngle => {\n // Do not limit large acceptor angles\n return idealAcceptorAngle - acceptorAngle > maxHbondAccAngle\n })) return\n\n if (idealGeometry[acceptor.index] === AtomGeometry.Trigonal){\n const outOfPlane = calcPlaneAngle(acceptor, donor)\n if (outOfPlane !== undefined && outOfPlane > maxHbondAccPlaneAngle) return\n }\n\n featureSet.setBits(l, k)\n const bondType = isWeak ? ContactType.WeakHydrogenBond : getHydrogenBondType(donor, acceptor)\n contactStore.addContact(l, k, bondType)\n })\n }\n}\n","/**\n * @file Metal Binding\n * @author Alexander Rose \n */\n\nimport { defaults } from '../../utils'\nimport Structure from '../../structure/structure'\n// import { valenceModel } from '../../structure/data'\nimport { Elements, AA3, Bases } from '../../structure/structure-constants'\n// import { hasAromaticNeighbour } from '../functional-groups'\nimport {\n Features, FeatureType,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\n\nconst IonicTypeMetals = [\n Elements.LI, Elements.NA, Elements.K, Elements.RB, Elements.CS,\n Elements.MG, Elements.CA, Elements.SR, Elements.BA, Elements.AL,\n Elements.GA, Elements.IN, Elements.TL, Elements.SC, Elements.SN,\n Elements.PB, Elements.BI, Elements.SB, Elements.HG\n]\n\n/**\n * Metal binding partners (dative bond or ionic-type interaction)\n */\nexport function addMetalBinding (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n let dative = false\n let ionic = false\n\n const isStandardAminoacid = AA3.includes(a.resname)\n const isStandardBase = Bases.includes(a.resname)\n\n if (!isStandardAminoacid && !isStandardBase) {\n if (a.isHalogen() || a.number === Elements.O || a.number === Elements.S) {\n dative = true\n ionic = true\n } else if (a.number === Elements.N) {\n dative = true\n }\n } else if (isStandardAminoacid){\n // main chain oxygen atom or oxygen, nitrogen and sulfur from specific amino acids\n if (a.number === Elements.O) {\n if(['ASP', 'GLU', 'SER', 'THR', 'TYR', 'ASN', 'GLN'].includes(a.resname) && a.isSidechain()) {\n dative = true\n ionic = true\n } else if (a.isBackbone()) {\n dative = true\n ionic = true\n }\n } else if (a.number === Elements.S && 'CYS' === a.resname) {\n dative = true\n ionic = true\n } else if (a.number === Elements.N) {\n if(a.resname === 'HIS' && a.isSidechain()) {\n dative = true\n }\n }\n } else if (isStandardBase){\n // http://pubs.acs.org/doi/pdf/10.1021/acs.accounts.6b00253\n // http://onlinelibrary.wiley.com/doi/10.1002/anie.200900399/full\n if (a.number === Elements.O && a.isBackbone()) {\n dative = true\n ionic = true\n } else if(['N3', 'N4', 'N7'].includes(a.atomname)) {\n dative = true\n } else if(['O2', 'O4', 'O6'].includes(a.atomname)) {\n dative = true\n ionic = true\n }\n }\n if (dative) {\n const state = createFeatureState(FeatureType.DativeBondPartner)\n addAtom(state, a)\n addFeature(features, state)\n }\n if (ionic) {\n const state = createFeatureState(FeatureType.IonicTypePartner)\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\n/**\n * Metal Pi complexation partner\n */\n// export function addMetalPiPartners (structure: Structure, features: Features) {\n// const { charge } = valenceModel(structure.data)\n\n// structure.eachAtom(a => {\n// const state = createFeatureState(FeatureType.MetalPiPartner)\n\n// const resname = a.resname\n// const element = a.element\n// const atomname = a.atomname\n// if (!a.isPolymer()) {\n// // water oxygen, as well as oxygen from carboxylate, phosphoryl, phenolate, alcohol;\n// // nitrogen from imidazole; sulfur from thiolate\n// if (element === 'O') {\n// // Water oxygen\n// if (a.bondCount === 0 || a.isWater()) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// // Oxygen in alcohol (R-[O]-H)\n// if (a.bondCount === 2 && charge[ a.index ] || a.hasBondToElement('H')) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// // Phenolate oxygen\n// if (hasAromaticNeighbour(a) && !a.aromatic) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// // Carboxylic acid oxygen\n// if (a.bondToElementCount('C') === 1) {\n// let flag = false\n// a.eachBondedAtom(ba => {\n// if (ba.element === 'C' && ba.bondToElementCount('O') === 2 && ba.bondToElementCount('C') === 1) {\n// flag = true\n// }\n// })\n// if (flag) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// }\n// // Phosphoryl oxygen\n// if (a.bondToElementCount('P') === 1) {\n// let flag = false\n// a.eachBondedAtom(ba => {\n// if (ba.element === 'P' && ba.bondToElementCount('O') >= 3) {\n// flag = true\n// }\n// })\n// if (flag) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// }\n// } else if (element === 'N') {\n// // Imidazole/pyrrole or similar\n// if (a.bondToElementCount('C') === 2) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// } else if (element === 'S') {\n// // Thiolate\n// if (hasAromaticNeighbour(a) && !a.aromatic) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// // Sulfur in Iron sulfur cluster\n// const ironCount = a.bondToElementCount('FE')\n// if (ironCount > 0 && ironCount === a.bondCount) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// }\n// }\n// })\n// }\n\nexport function addMetals (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n if (a.isTransitionMetal() || a.number === Elements.ZN || a.number === Elements.CD) {\n const state = createFeatureState(FeatureType.TransitionMetal)\n addAtom(state, a)\n addFeature(features, state)\n } else if (IonicTypeMetals.includes(a.number)) {\n const state = createFeatureState(FeatureType.IonicTypeMetal)\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\nfunction isMetalComplex (ti: FeatureType, tj: FeatureType) {\n if (ti === FeatureType.TransitionMetal) {\n return (\n tj === FeatureType.DativeBondPartner ||\n tj === FeatureType.TransitionMetal\n )\n } else if (ti === FeatureType.IonicTypeMetal) {\n return (\n tj === FeatureType.IonicTypePartner\n )\n }\n}\n\nexport interface MetalComplexationParams {\n maxMetalDist?: number\n masterModelIndex?: number\n}\n\n/**\n * Metal complexes of metals and appropriate groups in protein and ligand, including water\n */\nexport function addMetalComplexation (structure: Structure, contacts: Contacts, params: MetalComplexationParams = {}) {\n const maxMetalDist = defaults(params.maxMetalDist, ContactDefaultParams.maxMetalDist)\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxMetalDist, (j, dSq) => {\n if (j <= i) return\n\n ap1.index = atomSets[ i ][ 0 ]\n ap2.index = atomSets[ j ][ 0 ]\n\n if (invalidAtomContact(ap1, ap2, masterIdx)) return\n\n const m1 = ap1.isMetal()\n const m2 = ap2.isMetal()\n if (!m1 && !m2) return\n\n const [ ti, tj ] = m1 ? [ types[ i ],types[ j ] ] : [ types[ j ],types[ i ] ]\n\n if (isMetalComplex(ti, tj)) {\n featureSet.setBits(i, j)\n contactStore.addContact(i, j, ContactType.MetalCoordination)\n }\n })\n }\n}\n","/**\n * @file Halogen Bonds\n * @author Alexander Rose \n * @author Fred Ludlow \n */\n\nimport { defaults } from '../../utils'\nimport Structure from '../../structure/structure'\nimport { Elements } from '../../structure/structure-constants'\nimport { degToRad } from '../../math/math-utils'\nimport {\n Features, FeatureType,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\nimport { calcAngles } from '../geometry'\n\nconst halBondElements = [17, 35, 53, 85]\n\n/**\n * Halogen bond donors (X-C, with X one of Cl, Br, I or At) not F!\n */\nexport function addHalogenDonors (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n if (halBondElements.includes(a.number) && a.bondToElementCount(Elements.C) === 1) {\n const state = createFeatureState(FeatureType.HalogenDonor)\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\nconst X = [ Elements.N, Elements.O, Elements.S ]\nconst Y = [ Elements.C, Elements.N, Elements.P, Elements.S ]\n\n/**\n * Halogen bond acceptors (Y-{O|N|S}, with Y=C,P,N,S)\n */\nexport function addHalogenAcceptors (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n if (X.includes(a.number)) {\n let flag = false\n a.eachBondedAtom(ba => {\n if (Y.includes(ba.number)) {\n flag = true\n }\n })\n if (flag) {\n const state = createFeatureState(FeatureType.HalogenAcceptor)\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n })\n}\n\nfunction isHalogenBond (ti: FeatureType, tj: FeatureType) {\n return (\n (ti === FeatureType.HalogenAcceptor && tj === FeatureType.HalogenDonor) ||\n (ti === FeatureType.HalogenDonor && tj === FeatureType.HalogenAcceptor)\n )\n}\n\nexport interface HalogenBondsParams {\n maxHalogenBondDist?: number\n maxHalogenBondAngle?: number\n masterModelIndex?: number\n}\n\n// http://www.pnas.org/content/101/48/16789.full\nconst OptimalHalogenAngle = degToRad(180) // adjusted from 165 to account for spherical statistics\nconst OptimalAcceptorAngle = degToRad(120)\n\n/**\n * All pairs of halogen donor and acceptor atoms\n */\nexport function addHalogenBonds (structure: Structure, contacts: Contacts, params: HalogenBondsParams = {}) {\n const maxHalogenBondDist = defaults(params.maxHalogenBondDist, ContactDefaultParams.maxHalogenBondDist)\n const maxHalogenBondAngle = degToRad(defaults(params.maxHalogenBondAngle, ContactDefaultParams.maxHalogenBondAngle))\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxHalogenBondDist, (j, dSq) => {\n if (j <= i) return\n\n ap1.index = atomSets[ i ][ 0 ]\n ap2.index = atomSets[ j ][ 0 ]\n\n if (invalidAtomContact(ap1, ap2, masterIdx)) return\n if (!isHalogenBond(types[ i ], types[ j ])) return\n\n const [ halogen, acceptor ] = types[ i ] === FeatureType.HalogenDonor ? [ ap1, ap2 ] : [ ap2, ap1 ]\n\n const halogenAngles = calcAngles(halogen, acceptor)\n // Singly bonded halogen only (not bromide ion for example)\n if (halogenAngles.length !== 1) return\n if (OptimalHalogenAngle - halogenAngles[0] > maxHalogenBondAngle) return\n\n const acceptorAngles = calcAngles(acceptor, halogen)\n // Angle must be defined. Excludes water as acceptor. Debatable\n if (acceptorAngles.length === 0) return\n if (acceptorAngles.some(acceptorAngle => {\n return (OptimalAcceptorAngle - acceptorAngle > maxHalogenBondAngle)\n })) return\n\n\n featureSet.setBits(i, j)\n contactStore.addContact(i, j, ContactType.HalogenBond)\n\n })\n }\n}\n","/**\n * @file Refine Contacts\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { Debug, Log } from '../../globals'\nimport { defaults } from '../../utils'\nimport Structure from '../../structure/structure'\nimport AtomProxy from '../../proxy/atom-proxy'\nimport { Elements } from '../../structure/structure-constants'\nimport { FrozenContacts, ContactType, ContactDefaultParams, isMasterContact } from './contact'\nimport { FeatureType } from './features'\n\nexport interface LineOfSightParams {\n lineOfSightDistFactor?: number\n masterModelIndex?: number\n}\n\n// also allows intra-residue contacts\nexport function invalidAtomContact (ap1: AtomProxy, ap2: AtomProxy, masterIdx: number) {\n return !isMasterContact(ap1, ap2, masterIdx) && (\n ap1.modelIndex !== ap2.modelIndex ||\n (ap1.altloc && ap2.altloc && ap1.altloc !== ap2.altloc)\n )\n}\n\nexport function refineLineOfSight (structure: Structure, contacts: FrozenContacts, params: LineOfSightParams = {}) {\n if (Debug) Log.time('refineLineOfSight')\n\n const lineOfSightDistFactor = defaults(params.lineOfSightDistFactor, ContactDefaultParams.lineOfSightDistFactor)\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const spatialHash = structure.spatialHash!\n const { contactSet, contactStore, features } = contacts\n const { index1, index2 } = contactStore\n const { centers, atomSets } = features\n const { x, y, z } = centers\n\n const ac1 = structure.getAtomProxy()\n const ac2 = structure.getAtomProxy()\n const aw = structure.getAtomProxy()\n\n const c1 = new Vector3()\n const c2 = new Vector3()\n\n const lineOfSightDist = 3 * lineOfSightDistFactor\n const lineOfSightDistFactorSq = lineOfSightDistFactor * lineOfSightDistFactor\n\n contactSet.forEach(i => {\n c1.set(x[index1[i]], y[index1[i]], z[index1[i]])\n c2.set(x[index2[i]], y[index2[i]], z[index2[i]])\n\n const cx = ( c1.x + c2.x ) / 2\n const cy = ( c1.y + c2.y ) / 2\n const cz = ( c1.z + c2.z ) / 2\n\n const as1 = atomSets[ index1[ i ] ]\n const as2 = atomSets[ index2[ i ] ]\n\n ac1.index = as1[ 0 ]\n ac2.index = as2[ 0 ]\n\n spatialHash.eachWithin(cx, cy, cz, lineOfSightDist, (j, dSq) => {\n aw.index = j\n if (\n aw.number !== Elements.H &&\n (aw.vdw * aw.vdw * lineOfSightDistFactorSq) > dSq &&\n !invalidAtomContact(ac1, aw, masterIdx) &&\n !invalidAtomContact(ac2, aw, masterIdx) &&\n !as1.includes(j) &&\n !as2.includes(j) &&\n // to ignore atoms in the center of functional groups\n c1.distanceToSquared(aw as any) > 1 &&\n c2.distanceToSquared(aw as any) > 1\n ) {\n contactSet.clear(i)\n if (Debug) Log.log('removing', ac1.qualifiedName(), ac2.qualifiedName(), 'because', aw.qualifiedName())\n }\n })\n })\n\n if (Debug) Log.timeEnd('refineLineOfSight')\n}\n\n/**\n * For atoms interacting with several atoms in the same residue\n * only the one with the closest distance is kept.\n */\nexport function refineHydrophobicContacts (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features } = contacts\n const { type, index1, index2 } = contactStore\n const { atomSets } = features\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n const residueContactDict: { [k: string]: number[] } = {}\n\n /* keep only closest contact between residues */\n const handleResidueContact = function (dist: number, i: number, key: string) {\n const [ minDist, minIndex ] = residueContactDict[ key ] || [ Infinity, -1 ]\n if (dist < minDist) {\n if (minIndex !== -1) contactSet.clear(minIndex)\n residueContactDict[ key ] = [ dist, i ]\n } else {\n contactSet.clear(i)\n }\n }\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.Hydrophobic) return\n\n ap1.index = atomSets[ index1[ i ] ][ 0 ]\n ap2.index = atomSets[ index2[ i ] ][ 0 ]\n\n const dist = ap1.distanceTo(ap2)\n handleResidueContact(dist, i, `${ap1.index}|${ap2.residueIndex}`)\n handleResidueContact(dist, i, `${ap2.index}|${ap1.residueIndex}`)\n })\n}\n\nfunction isHydrogenBondType (type: number) {\n return (\n type === ContactType.HydrogenBond ||\n type === ContactType.WaterHydrogenBond ||\n type === ContactType.BackboneHydrogenBond\n )\n}\n\n/**\n * Remove weak hydrogen bonds when the acceptor is involved in\n * a normal/strong hydrogen bond\n */\nexport function refineWeakHydrogenBonds (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features, adjacencyList } = contacts\n const { type, index1, index2 } = contactStore\n const { types } = features\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.WeakHydrogenBond) return\n\n let accFeat: number\n if (types[ index1[ i ] ] === FeatureType.WeakHydrogenDonor) {\n accFeat = index2[ i ]\n } else {\n accFeat = index1[ i ]\n }\n\n const n = adjacencyList.countArray[ accFeat ]\n const offset = adjacencyList.offsetArray[ accFeat ]\n for (let j = 0; j < n; ++j) {\n const ci = adjacencyList.indexArray[ offset + j ]\n if (isHydrogenBondType(type[ ci ])) {\n contactSet.clear(i)\n return\n }\n }\n })\n}\n\n/**\n * Remove hydrogen bonds between groups that also form\n * a salt bridge between each other\n */\nexport function refineSaltBridges (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features } = contacts\n const { type, index1, index2 } = contactStore\n const { atomSets } = features\n\n const ionicInteractionDict: { [atomIndex: number]: number[] } = {}\n\n const add = function(idx: number, i: number) {\n if (!ionicInteractionDict[ idx ]) ionicInteractionDict[ idx ] = []\n ionicInteractionDict[ idx ].push(i)\n }\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.IonicInteraction) return\n atomSets[ index1[ i ] ].forEach(idx => add(idx, i))\n atomSets[ index2[ i ] ].forEach(idx => add(idx, i))\n })\n\n contactSet.forEach(i => {\n if (!isHydrogenBondType(type[ i ])) return\n\n const iil1 = ionicInteractionDict[ atomSets[ index1[ i ] ][ 0 ] ]\n const iil2 = ionicInteractionDict[ atomSets[ index2[ i ] ][ 0 ] ]\n if (!iil1 || !iil2) return\n\n const n = iil1.length\n for (let j = 0; j < n; ++j) {\n if (iil2.includes(iil1[j])) {\n contactSet.clear(i)\n return\n }\n }\n })\n}\n\n/**\n * Remove hydrophobic and cation-pi interactions between groups that also form\n * a pi-stacking interaction between each other\n */\nexport function refinePiStacking (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features } = contacts\n const { type, index1, index2 } = contactStore\n const { atomSets } = features\n\n const piStackingDict: { [atomIndex: number]: number[] } = {}\n\n const add = function(idx: number, i: number) {\n if (!piStackingDict[ idx ]) piStackingDict[ idx ] = []\n piStackingDict[ idx ].push(i)\n }\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.PiStacking) return\n atomSets[ index1[ i ] ].forEach(idx => add(idx, i))\n atomSets[ index2[ i ] ].forEach(idx => add(idx, i))\n })\n\n contactSet.forEach(i => {\n if (\n type[ i ] !== ContactType.Hydrophobic &&\n type[ i ] !== ContactType.CationPi\n ) return\n\n const pil1 = piStackingDict[ atomSets[ index1[ i ] ][ 0 ] ]\n const pil2 = piStackingDict[ atomSets[ index2[ i ] ][ 0 ] ]\n if (!pil1 || !pil2) return\n\n const n = pil1.length\n for (let j = 0; j < n; ++j) {\n if (pil2.includes(pil1[j])) {\n contactSet.clear(i)\n return\n }\n }\n })\n}\n\n/**\n * Remove ionic interactions between groups that also form\n * a metal coordination between each other\n */\nexport function refineMetalCoordination (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features } = contacts\n const { type, index1, index2 } = contactStore\n const { atomSets } = features\n\n const ionicInteractionDict: { [atomIndex: number]: number[] } = {}\n\n const add = function(idx: number, i: number) {\n if (!ionicInteractionDict[ idx ]) ionicInteractionDict[ idx ] = []\n ionicInteractionDict[ idx ].push(i)\n }\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.IonicInteraction) return\n atomSets[ index1[ i ] ].forEach(idx => add(idx, i))\n atomSets[ index2[ i ] ].forEach(idx => add(idx, i))\n })\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.MetalCoordination) return\n\n const iil1 = ionicInteractionDict[ atomSets[ index1[ i ] ][ 0 ] ]\n const iil2 = ionicInteractionDict[ atomSets[ index2[ i ] ][ 0 ] ]\n if (!iil1 || !iil2) return\n\n const n = iil1.length\n for (let j = 0; j < n; ++j) {\n if (iil2.includes(iil1[j])) {\n contactSet.clear(iil1[j])\n return\n }\n }\n })\n}\n\n// TODO: refactor refineSaltBridges, refinePiStacking and refineMetalCoordination to be DRY\n","/**\n * @file Contact\n * @author Alexander Rose \n */\n\nimport { Color } from 'three'\n\nimport { Debug, Log } from '../../globals'\nimport { createParams } from '../../utils'\nimport { TextBufferData } from '../../buffer/text-buffer'\nimport Structure from '../../structure/structure'\nimport AtomProxy from '../../proxy/atom-proxy'\nimport SpatialHash from '../../geometry/spatial-hash'\nimport { calculateCenterArray, calculateDirectionArray, uniformArray } from '../../math/array-utils'\nimport ContactStore from '../../store/contact-store'\nimport BitArray from '../../utils/bitarray'\nimport Selection from '../../selection/selection'\nimport { ContactPicker } from '../../utils/picker'\nimport { createAdjacencyList, AdjacencyList } from '../../utils/adjacency-list'\nimport { createFeatures, Features } from './features'\nimport { addAromaticRings, addNegativeCharges, addPositiveCharges, addChargedContacts } from './charged'\nimport { addHydrogenAcceptors, addHydrogenDonors, addHydrogenBonds, addWeakHydrogenDonors } from './hydrogen-bonds'\nimport { addMetalBinding, addMetals, addMetalComplexation } from './metal-binding'\nimport { addHydrophobic, addHydrophobicContacts } from './hydrophobic'\nimport { addHalogenAcceptors, addHalogenDonors, addHalogenBonds } from './halogen-bonds'\nimport {\n refineLineOfSight,\n refineHydrophobicContacts, refineSaltBridges, refinePiStacking, refineMetalCoordination\n} from './refine-contacts'\n\nexport interface Contacts {\n features: Features\n spatialHash: SpatialHash\n contactStore: ContactStore\n featureSet: BitArray\n}\n\nexport interface FrozenContacts extends Contacts {\n contactSet: BitArray\n adjacencyList: AdjacencyList\n}\n\nexport const enum ContactType {\n Unknown = 0,\n IonicInteraction = 1,\n CationPi = 2,\n PiStacking = 3,\n HydrogenBond = 4,\n HalogenBond = 5,\n Hydrophobic = 6,\n MetalCoordination = 7,\n WeakHydrogenBond = 8,\n WaterHydrogenBond = 9,\n BackboneHydrogenBond = 10\n}\n\nexport const ContactDefaultParams = {\n maxHydrophobicDist: 4.0,\n maxHbondDist: 3.5,\n maxHbondSulfurDist: 4.1,\n maxHbondAccAngle: 45,\n maxHbondDonAngle: 45,\n maxHbondAccPlaneAngle: 90,\n maxHbondDonPlaneAngle: 30,\n maxPiStackingDist: 5.5,\n maxPiStackingOffset: 2.0,\n maxPiStackingAngle: 30,\n maxCationPiDist: 6.0,\n maxCationPiOffset: 2.0,\n maxIonicDist: 5.0,\n maxHalogenBondDist: 4.0,\n maxHalogenBondAngle: 30,\n maxMetalDist: 3.0,\n refineSaltBridges: true,\n masterModelIndex: -1,\n lineOfSightDistFactor: 1.0\n}\n\nexport function isMasterContact (ap1: AtomProxy, ap2: AtomProxy, masterIdx: number) {\n return (\n (ap1.modelIndex === masterIdx && ap2.modelIndex !== masterIdx) ||\n (ap2.modelIndex === masterIdx && ap1.modelIndex !== masterIdx)\n )\n}\n\nexport function invalidAtomContact (ap1: AtomProxy, ap2: AtomProxy, masterIdx: number) {\n return !isMasterContact(ap1, ap2, masterIdx) && (\n ap1.modelIndex !== ap2.modelIndex ||\n ap1.residueIndex === ap2.residueIndex ||\n (ap1.altloc && ap2.altloc && ap1.altloc !== ap2.altloc)\n )\n}\n\nexport function createContacts (features: Features): Contacts {\n const { types, centers } = features\n\n const spatialHash = new SpatialHash(centers)\n const contactStore = new ContactStore()\n const featureSet = new BitArray(types.length, false)\n\n return { features, spatialHash, contactStore, featureSet }\n}\n\nexport function createFrozenContacts (contacts: Contacts): FrozenContacts {\n const { index1, index2, count } = contacts.contactStore\n\n const adjacencyList = createAdjacencyList({\n nodeArray1: index1,\n nodeArray2: index2,\n edgeCount: count,\n nodeCount: contacts.featureSet.length\n })\n const contactSet = new BitArray(contacts.contactStore.count, true)\n\n return Object.assign({ adjacencyList, contactSet }, contacts)\n}\n\nfunction calculateFeatures (structure: Structure) {\n const features = createFeatures()\n\n if (Debug) Log.time('calculateFeatures')\n\n addPositiveCharges(structure, features)\n addNegativeCharges(structure, features)\n addAromaticRings(structure, features)\n\n addHydrogenAcceptors(structure, features)\n addHydrogenDonors(structure, features)\n addWeakHydrogenDonors(structure, features)\n\n addMetalBinding(structure, features)\n addMetals(structure, features)\n\n addHydrophobic(structure, features)\n\n addHalogenAcceptors(structure, features)\n addHalogenDonors(structure, features)\n\n if (Debug) Log.timeEnd('calculateFeatures')\n\n return features\n}\n\nexport function calculateContacts (structure: Structure, params = ContactDefaultParams) {\n const features = calculateFeatures(structure)\n const contacts = createContacts(features)\n\n if (Debug) Log.time('calculateContacts')\n\n addChargedContacts(structure, contacts, params)\n addHydrogenBonds(structure, contacts, params)\n addMetalComplexation(structure, contacts, params)\n addHydrophobicContacts(structure, contacts, params)\n addHalogenBonds(structure, contacts, params)\n\n const frozenContacts = createFrozenContacts(contacts)\n\n refineLineOfSight(structure, frozenContacts, params)\n refineHydrophobicContacts(structure, frozenContacts)\n if (params.refineSaltBridges) refineSaltBridges(structure, frozenContacts)\n refinePiStacking(structure, frozenContacts)\n refineMetalCoordination(structure, frozenContacts)\n\n if (Debug) Log.timeEnd('calculateContacts')\n\n return frozenContacts\n}\n\nexport function contactTypeName (type: ContactType) {\n switch (type) {\n case ContactType.HydrogenBond:\n case ContactType.WaterHydrogenBond:\n case ContactType.BackboneHydrogenBond:\n return 'hydrogen bond'\n case ContactType.Hydrophobic:\n return 'hydrophobic contact'\n case ContactType.HalogenBond:\n return 'halogen bond'\n case ContactType.IonicInteraction:\n return 'ionic interaction'\n case ContactType.MetalCoordination:\n return 'metal coordination'\n case ContactType.CationPi:\n return 'cation-pi interaction'\n case ContactType.PiStacking:\n return 'pi-pi stacking'\n case ContactType.WeakHydrogenBond:\n return 'weak hydrogen bond'\n default:\n return 'unknown contact'\n }\n}\n\nexport const ContactDataDefaultParams = {\n hydrogenBond: true,\n hydrophobic: true,\n halogenBond: true,\n ionicInteraction: true,\n metalCoordination: true,\n cationPi: true,\n piStacking: true,\n weakHydrogenBond: true,\n waterHydrogenBond: true,\n backboneHydrogenBond: true,\n radius: 1,\n filterSele: ''\n}\nexport type ContactDataParams = typeof ContactDataDefaultParams\n | { filterSele: string|[string, string] }\n\nexport const ContactLabelDefaultParams = {\n unit: '',\n size: 2.0\n}\n\nexport type ContactLabelParams = typeof ContactLabelDefaultParams\n\nconst tmpColor = new Color()\nfunction contactColor (type: ContactType) {\n switch (type) {\n case ContactType.HydrogenBond:\n case ContactType.WaterHydrogenBond:\n case ContactType.BackboneHydrogenBond:\n return tmpColor.setHex(0x2B83BA).toArray()\n case ContactType.Hydrophobic:\n return tmpColor.setHex(0x808080).toArray()\n case ContactType.HalogenBond:\n return tmpColor.setHex(0x40FFBF).toArray()\n case ContactType.IonicInteraction:\n return tmpColor.setHex(0xF0C814).toArray()\n case ContactType.MetalCoordination:\n return tmpColor.setHex(0x8C4099).toArray()\n case ContactType.CationPi:\n return tmpColor.setHex(0xFF8000).toArray()\n case ContactType.PiStacking:\n return tmpColor.setHex(0x8CB366).toArray()\n case ContactType.WeakHydrogenBond:\n return tmpColor.setHex(0xC5DDEC).toArray()\n default:\n return tmpColor.setHex(0xCCCCCC).toArray()\n }\n}\n\nexport interface ContactData {\n position1: Float32Array,\n position2: Float32Array,\n color: Float32Array,\n color2: Float32Array,\n radius: Float32Array,\n picking: ContactPicker\n}\n\nexport function getContactData (contacts: FrozenContacts, structure: Structure, params: ContactDataParams): ContactData {\n const p = createParams(params, ContactDataDefaultParams)\n const types: ContactType[] = []\n if (p.hydrogenBond) types.push(ContactType.HydrogenBond)\n if (p.hydrophobic) types.push(ContactType.Hydrophobic)\n if (p.halogenBond) types.push(ContactType.HalogenBond)\n if (p.ionicInteraction) types.push(ContactType.IonicInteraction)\n if (p.metalCoordination) types.push(ContactType.MetalCoordination)\n if (p.cationPi) types.push(ContactType.CationPi)\n if (p.piStacking) types.push(ContactType.PiStacking)\n if (p.weakHydrogenBond) types.push(ContactType.WeakHydrogenBond)\n if (p.waterHydrogenBond) types.push(ContactType.WaterHydrogenBond)\n if (p.backboneHydrogenBond) types.push(ContactType.BackboneHydrogenBond)\n\n const { features, contactSet, contactStore } = contacts\n const { centers, atomSets } = features\n const { x, y, z } = centers\n const { index1, index2, type } = contactStore\n\n const position1: number[] = []\n const position2: number[] = []\n const color: number[] = []\n const radius: number[] = []\n const picking: number[] = []\n\n let filterSet: BitArray | BitArray[] | undefined\n if (p.filterSele) {\n if (Array.isArray(p.filterSele)) {\n filterSet = p.filterSele.map(sele => {\n return structure.getAtomSet(new Selection(sele))\n })\n } else {\n filterSet = structure.getAtomSet(new Selection(p.filterSele))\n }\n }\n\n contactSet.forEach(i => {\n const ti = type[ i ]\n if (!types.includes(ti)) return\n\n if (filterSet) {\n const idx1 = atomSets[index1[i]][0]\n const idx2 = atomSets[index2[i]][0]\n\n if (Array.isArray(filterSet)) {\n if (!(filterSet[0].isSet(idx1) && filterSet[1].isSet(idx2) || (filterSet[1].isSet(idx1) && filterSet[0].isSet(idx2)))) return\n } else {\n if (!filterSet.isSet(idx1) && !filterSet.isSet(idx2)) return\n }\n }\n\n const k = index1[i]\n const l = index2[i]\n position1.push(x[k], y[k], z[k])\n position2.push(x[l], y[l], z[l])\n color.push(...contactColor(ti))\n radius.push(p.radius)\n picking.push(i)\n })\n\n return {\n position1: new Float32Array(position1),\n position2: new Float32Array(position2),\n color: new Float32Array(color),\n color2: new Float32Array(color),\n radius: new Float32Array(radius),\n picking: new ContactPicker(picking, contacts, structure)\n }\n}\n\nexport function getLabelData (contactData: ContactData, params: ContactLabelParams): TextBufferData {\n\n const position = calculateCenterArray(contactData.position1, contactData.position2)\n const text: string[] = []\n\n const direction = calculateDirectionArray(contactData.position1, contactData.position2)\n\n const n = direction.length / 3\n for (let i=0; i\n */\n\nimport { defaults } from '../../utils'\nimport Structure from '../../structure/structure'\nimport { Elements } from '../../structure/structure-constants'\nimport {\n Features, FeatureType,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\n\n/**\n * Hydrophobic carbon (only bonded to carbon or hydrogen); fluorine\n */\nexport function addHydrophobic (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n const state = createFeatureState(FeatureType.Hydrophobic)\n let flag = false\n if (a.number === Elements.C) {\n flag = true\n a.eachBondedAtom(ap => {\n const an = ap.number\n if (an !== Elements.C && an !== Elements.H) flag = false\n })\n } else if (a.number === Elements.F) {\n flag = true\n }\n if (flag) {\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\nfunction isHydrophobicContact (ti: FeatureType, tj: FeatureType) {\n return ti === FeatureType.Hydrophobic && tj === FeatureType.Hydrophobic\n}\n\nexport interface HydrophobicContactsParams {\n maxHydrophobicDist?: number\n masterModelIndex?: number\n}\n\n/**\n * All hydrophobic contacts\n */\nexport function addHydrophobicContacts (structure: Structure, contacts: Contacts, params: HydrophobicContactsParams = {}) {\n const maxHydrophobicDist = defaults(params.maxHydrophobicDist, ContactDefaultParams.maxHydrophobicDist)\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxHydrophobicDist, (j, dSq) => {\n if (j <= i) return\n\n ap1.index = atomSets[ i ][ 0 ]\n ap2.index = atomSets[ j ][ 0 ]\n\n if (invalidAtomContact(ap1, ap2, masterIdx)) return\n if (ap1.number === Elements.F && ap2.number === Elements.F) return\n if (ap1.connectedTo(ap2)) return\n\n if (isHydrophobicContact(types[ i ], types[ j ])) {\n featureSet.setBits(i, j)\n contactStore.addContact(i, j, ContactType.Hydrophobic)\n }\n })\n }\n}\n","/**\n * @file Picker\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { PickerRegistry } from '../globals'\nimport { calculateMeanVector3 } from '../math/vector-utils'\nimport Selection from '../selection/selection'\nimport {\n ArrowPrimitive, BoxPrimitive, ConePrimitive, CylinderPrimitive,\n EllipsoidPrimitive, OctahedronPrimitive, SpherePrimitive,\n TetrahedronPrimitive, TorusPrimitive, PointPrimitive, WidelinePrimitive\n} from '../geometry/primitive'\nimport { contactTypeName, Contacts } from '../chemistry/interactions/contact'\nimport { TypedArray } from '../types';\nimport Component from '../component/component';\nimport { Shape, Structure, Volume } from '../ngl';\nimport BondStore from '../store/bond-store';\nimport Validation from '../structure/validation';\nimport PrincipalAxes from '../math/principal-axes';\nimport Surface from '../surface/surface';\nimport Unitcell from '../symmetry/unitcell';\nimport BondProxy from '../proxy/bond-proxy';\nimport AtomProxy from '../proxy/atom-proxy';\n\n/**\n * Picker class\n * @interface\n */\nclass Picker {\n array: number[]|TypedArray|undefined\n /**\n * @param {Array|TypedArray} [array] - mapping\n */\n constructor (array?: number[]|TypedArray) {\n this.array = array\n }\n\n get type () { return '' }\n get data () { return {} }\n\n /**\n * Get the index for the given picking id\n * @param {Integer} pid - the picking id\n * @return {Integer} the index\n */\n getIndex (pid: number) {\n return this.array ? this.array[ pid ] : pid\n }\n\n /**\n * Get object data\n * @abstract\n * @param {Integer} pid - the picking id\n * @return {Object} the object data\n */\n getObject (pid: number) {\n return {}\n }\n\n _applyTransformations (vector: Vector3, instance: any, component: Component) {\n if (instance) {\n vector.applyMatrix4(instance.matrix)\n }\n if (component) {\n vector.applyMatrix4(component.matrix)\n }\n return vector\n }\n\n /**\n * Get object position\n * @abstract\n * @param {Integer} pid - the picking id\n * @return {Vector3} the object position\n */\n _getPosition (pid: number) {\n return new Vector3()\n }\n\n /**\n * Get position for the given picking id\n * @param {Integer} pid - the picking id\n * @param {Object} instance - the instance that should be applied\n * @param {Component} component - the component of the picked object\n * @return {Vector3} the position\n */\n getPosition (pid: number, instance: any, component: Component) {\n return this._applyTransformations(\n this._getPosition(pid), instance, component\n )\n }\n}\n\n/**\n * Shape picker class\n * @interface\n */\nclass ShapePicker extends Picker {\n shape: Shape\n /**\n * @param {Shape} shape - shape object\n */\n constructor (shape: Shape) {\n super()\n this.shape = shape\n }\n\n get primitive (): any { return }\n\n get data () { return this.shape }\n get type () { return this.primitive.type }\n\n getObject (pid: number) {\n return this.primitive.objectFromShape(this.shape, this.getIndex(pid))\n }\n\n _getPosition (pid: number) {\n return this.primitive.positionFromShape(this.shape, this.getIndex(pid))\n }\n}\n\n//\n\nclass CylinderPicker extends ShapePicker {\n get primitive () { return CylinderPrimitive }\n}\n\nclass ArrowPicker extends ShapePicker {\n get primitive () { return ArrowPrimitive }\n}\n\nclass AtomPicker extends Picker {\n structure: Structure\n constructor (array: Float32Array, structure: Structure) {\n super(array)\n this.structure = structure\n }\n\n get type () { return 'atom' }\n get data () { return this.structure }\n\n getObject (pid: number): AtomProxy {\n return this.structure.getAtomProxy(this.getIndex(pid))\n }\n\n _getPosition (pid: number) {\n return new Vector3().copy(this.getObject(pid) as any)\n }\n}\n\nclass AxesPicker extends Picker {\n axes: PrincipalAxes\n constructor (axes: PrincipalAxes) {\n super()\n this.axes = axes\n }\n\n get type () { return 'axes' }\n get data () { return this.axes }\n\n getObject (/* pid */) {\n return {\n axes: this.axes\n }\n }\n\n _getPosition (/* pid */) {\n return this.axes.center.clone()\n }\n}\n\nclass BondPicker extends Picker {\n structure: Structure\n bondStore: BondStore\n constructor (array: number[]|TypedArray|undefined, structure: Structure, bondStore?: BondStore) {\n super(array)\n this.structure = structure\n this.bondStore = bondStore || structure.bondStore\n }\n\n get type () { return 'bond' }\n get data () { return this.structure }\n\n getObject (pid: number): BondProxy {\n const bp = this.structure.getBondProxy(this.getIndex(pid))\n bp.bondStore = this.bondStore\n return bp\n }\n\n _getPosition (pid: number) {\n const b = this.getObject(pid)\n return new Vector3()\n .copy(b.atom1 as any)\n .add(b.atom2 as any)\n .multiplyScalar(0.5)\n }\n}\n\nclass ContactPicker extends Picker {\n contacts: Contacts\n structure: Structure\n constructor (array: number[]|TypedArray|undefined, contacts: Contacts, structure: Structure) {\n super(array)\n this.contacts = contacts\n this.structure = structure\n }\n\n get type () { return 'contact' }\n get data () { return this.contacts }\n\n getObject (pid: number) {\n const idx = this.getIndex(pid)\n const { features, contactStore } = this.contacts\n const { centers, atomSets } = features\n const { x, y, z } = centers\n const { index1, index2, type } = contactStore\n const k = index1[idx]\n const l = index2[idx]\n return {\n center1: new Vector3(x[k], y[k], z[k]),\n center2: new Vector3(x[l], y[l], z[l]),\n atom1: this.structure.getAtomProxy(atomSets[k][0]),\n atom2: this.structure.getAtomProxy(atomSets[l][0]),\n type: contactTypeName(type[idx])\n }\n }\n\n _getPosition (pid: number) {\n const { center1, center2 } = this.getObject(pid)\n return new Vector3().addVectors(center1, center2).multiplyScalar(0.5)\n }\n}\n\nclass ConePicker extends ShapePicker {\n get primitive () { return ConePrimitive }\n}\n\nclass ClashPicker extends Picker {\n validation: Validation\n structure: Structure\n constructor (array: number[]|TypedArray|undefined, validation: Validation, structure: Structure) {\n super(array)\n this.validation = validation\n this.structure = structure\n }\n\n get type () { return 'clash' }\n get data () { return this.validation }\n\n getObject (pid: number) {\n const val = this.validation\n const idx = this.getIndex(pid)\n return {\n validation: val,\n index: idx,\n clash: val.clashArray[ idx ]\n }\n }\n\n _getAtomProxyFromSele (sele: string) {\n const selection = new Selection(sele)\n const idx = this.structure.getAtomIndices(selection)![ 0 ]\n return this.structure.getAtomProxy(idx)\n }\n\n _getPosition (pid: number) {\n const clash = this.getObject(pid).clash\n const ap1 = this._getAtomProxyFromSele(clash.sele1)\n const ap2 = this._getAtomProxyFromSele(clash.sele2)\n return new Vector3().copy(ap1 as any).add(ap2 as any).multiplyScalar(0.5)\n }\n}\n\nclass DistancePicker extends BondPicker {\n get type () { return 'distance' }\n}\n\nclass EllipsoidPicker extends ShapePicker {\n get primitive () { return EllipsoidPrimitive }\n}\n\nclass OctahedronPicker extends ShapePicker {\n get primitive () { return OctahedronPrimitive }\n}\n\nclass BoxPicker extends ShapePicker {\n get primitive () { return BoxPrimitive }\n}\n\nclass IgnorePicker extends Picker {\n get type () { return 'ignore' }\n}\n\nexport interface MeshData {\n name: string|undefined\n serial: number\n index: Uint32Array|Uint16Array|number[]\n normal?: Float32Array|number[]\n position: Float32Array|number[]\n color: Float32Array|number[]\n}\nclass MeshPicker extends ShapePicker {\n mesh: MeshData\n __position: Vector3\n\n constructor (shape: Shape, mesh: MeshData) {\n super(shape)\n this.mesh = mesh\n }\n\n get type () { return 'mesh' }\n\n getObject (/* pid */) {\n const m = this.mesh\n return {\n shape: this.shape,\n name: m.name,\n serial: m.serial\n }\n }\n\n _getPosition (/* pid */) {\n if (!this.__position) {\n this.__position = calculateMeanVector3(this.mesh.position as any)\n }\n return this.__position\n }\n}\n\nclass SpherePicker extends ShapePicker {\n get primitive () { return SpherePrimitive }\n}\n\nclass SurfacePicker extends Picker {\n surface: Surface\n constructor (array: number[]|TypedArray|undefined, surface: Surface) {\n super(array)\n this.surface = surface\n }\n\n get type () { return 'surface' }\n get data () { return this.surface }\n\n getObject (pid: number) {\n return {\n surface: this.surface,\n index: this.getIndex(pid)\n }\n }\n\n _getPosition (/* pid */) {\n return this.surface.center.clone()\n }\n}\n\nclass TetrahedronPicker extends ShapePicker {\n get primitive () { return TetrahedronPrimitive }\n}\n\nclass TorusPicker extends ShapePicker {\n get primitive () { return TorusPrimitive }\n}\n\nclass UnitcellPicker extends Picker {\n unitcell: Unitcell\n structure: Structure\n\n constructor (unitcell: Unitcell, structure: Structure) {\n super()\n this.unitcell = unitcell\n this.structure = structure\n }\n\n get type () { return 'unitcell' }\n get data () { return this.unitcell }\n\n getObject (/* pid */) {\n return {\n unitcell: this.unitcell,\n structure: this.structure\n }\n }\n\n _getPosition (/* pid */) {\n return this.unitcell.getCenter(this.structure)\n }\n}\n\nclass UnknownPicker extends Picker {\n get type () { return 'unknown' }\n}\n\nclass VolumePicker extends Picker {\n volume: Volume\n constructor (array: TypedArray, volume: Volume) {\n super(array)\n this.volume = volume\n }\n\n get type () { return 'volume' }\n get data () { return this.volume }\n\n getObject (pid: number) {\n const vol = this.volume\n const idx = this.getIndex(pid)\n return {\n volume: vol,\n index: idx,\n value: vol.data[ idx ]\n }\n }\n\n _getPosition (pid: number) {\n const dp = this.volume.position\n const idx = this.getIndex(pid)\n return new Vector3(\n dp[ idx * 3 ],\n dp[ idx * 3 + 1 ],\n dp[ idx * 3 + 2 ]\n )\n }\n}\n\nclass SlicePicker extends VolumePicker {\n get type () { return 'slice' }\n}\n\nclass PointPicker extends ShapePicker {\n get primitive () { return PointPrimitive }\n}\n\nclass WidelinePicker extends ShapePicker {\n get primitive () { return WidelinePrimitive }\n}\n\nPickerRegistry.add('arrow', ArrowPicker)\nPickerRegistry.add('box', BoxPicker)\nPickerRegistry.add('cone', ConePicker)\nPickerRegistry.add('cylinder', CylinderPicker)\nPickerRegistry.add('ellipsoid', EllipsoidPicker)\nPickerRegistry.add('octahedron', OctahedronPicker)\nPickerRegistry.add('sphere', SpherePicker)\nPickerRegistry.add('tetrahedron', TetrahedronPicker)\nPickerRegistry.add('torus', TorusPicker)\nPickerRegistry.add('point', PointPicker)\nPickerRegistry.add('wideline', WidelinePicker)\n\nexport {\n Picker,\n ShapePicker,\n ArrowPicker,\n AtomPicker,\n AxesPicker,\n BondPicker,\n BoxPicker,\n ConePicker,\n ContactPicker,\n CylinderPicker,\n ClashPicker,\n DistancePicker,\n EllipsoidPicker,\n IgnorePicker,\n OctahedronPicker,\n MeshPicker,\n SlicePicker,\n SpherePicker,\n SurfacePicker,\n TetrahedronPicker,\n TorusPicker,\n UnitcellPicker,\n UnknownPicker,\n VolumePicker,\n PointPicker,\n WidelinePicker\n}\n","/**\n * @file Marching Cubes\n * @author Alexander Rose \n * @private\n */\n\nimport { getUintArray } from '../utils'\n\nfunction getEdgeTable () {\n return new Uint32Array([\n 0x0, 0x109, 0x203, 0x30a, 0x406, 0x50f, 0x605, 0x70c,\n 0x80c, 0x905, 0xa0f, 0xb06, 0xc0a, 0xd03, 0xe09, 0xf00,\n 0x190, 0x99, 0x393, 0x29a, 0x596, 0x49f, 0x795, 0x69c,\n 0x99c, 0x895, 0xb9f, 0xa96, 0xd9a, 0xc93, 0xf99, 0xe90,\n 0x230, 0x339, 0x33, 0x13a, 0x636, 0x73f, 0x435, 0x53c,\n 0xa3c, 0xb35, 0x83f, 0x936, 0xe3a, 0xf33, 0xc39, 0xd30,\n 0x3a0, 0x2a9, 0x1a3, 0xaa, 0x7a6, 0x6af, 0x5a5, 0x4ac,\n 0xbac, 0xaa5, 0x9af, 0x8a6, 0xfaa, 0xea3, 0xda9, 0xca0,\n 0x460, 0x569, 0x663, 0x76a, 0x66, 0x16f, 0x265, 0x36c,\n 0xc6c, 0xd65, 0xe6f, 0xf66, 0x86a, 0x963, 0xa69, 0xb60,\n 0x5f0, 0x4f9, 0x7f3, 0x6fa, 0x1f6, 0xff, 0x3f5, 0x2fc,\n 0xdfc, 0xcf5, 0xfff, 0xef6, 0x9fa, 0x8f3, 0xbf9, 0xaf0,\n 0x650, 0x759, 0x453, 0x55a, 0x256, 0x35f, 0x55, 0x15c,\n 0xe5c, 0xf55, 0xc5f, 0xd56, 0xa5a, 0xb53, 0x859, 0x950,\n 0x7c0, 0x6c9, 0x5c3, 0x4ca, 0x3c6, 0x2cf, 0x1c5, 0xcc,\n 0xfcc, 0xec5, 0xdcf, 0xcc6, 0xbca, 0xac3, 0x9c9, 0x8c0,\n 0x8c0, 0x9c9, 0xac3, 0xbca, 0xcc6, 0xdcf, 0xec5, 0xfcc,\n 0xcc, 0x1c5, 0x2cf, 0x3c6, 0x4ca, 0x5c3, 0x6c9, 0x7c0,\n 0x950, 0x859, 0xb53, 0xa5a, 0xd56, 0xc5f, 0xf55, 0xe5c,\n 0x15c, 0x55, 0x35f, 0x256, 0x55a, 0x453, 0x759, 0x650,\n 0xaf0, 0xbf9, 0x8f3, 0x9fa, 0xef6, 0xfff, 0xcf5, 0xdfc,\n 0x2fc, 0x3f5, 0xff, 0x1f6, 0x6fa, 0x7f3, 0x4f9, 0x5f0,\n 0xb60, 0xa69, 0x963, 0x86a, 0xf66, 0xe6f, 0xd65, 0xc6c,\n 0x36c, 0x265, 0x16f, 0x66, 0x76a, 0x663, 0x569, 0x460,\n 0xca0, 0xda9, 0xea3, 0xfaa, 0x8a6, 0x9af, 0xaa5, 0xbac,\n 0x4ac, 0x5a5, 0x6af, 0x7a6, 0xaa, 0x1a3, 0x2a9, 0x3a0,\n 0xd30, 0xc39, 0xf33, 0xe3a, 0x936, 0x83f, 0xb35, 0xa3c,\n 0x53c, 0x435, 0x73f, 0x636, 0x13a, 0x33, 0x339, 0x230,\n 0xe90, 0xf99, 0xc93, 0xd9a, 0xa96, 0xb9f, 0x895, 0x99c,\n 0x69c, 0x795, 0x49f, 0x596, 0x29a, 0x393, 0x99, 0x190,\n 0xf00, 0xe09, 0xd03, 0xc0a, 0xb06, 0xa0f, 0x905, 0x80c,\n 0x70c, 0x605, 0x50f, 0x406, 0x30a, 0x203, 0x109, 0x0\n ])\n}\n\nfunction getTriTable (): Int32Array {\n return new Int32Array([\n -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 8, 3, 9, 8, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 2, 10, 0, 2, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 8, 3, 2, 10, 8, 10, 9, 8, -1, -1, -1, -1, -1, -1, -1,\n 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 11, 2, 8, 11, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 9, 0, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 11, 2, 1, 9, 11, 9, 8, 11, -1, -1, -1, -1, -1, -1, -1,\n 3, 10, 1, 11, 10, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 10, 1, 0, 8, 10, 8, 11, 10, -1, -1, -1, -1, -1, -1, -1,\n 3, 9, 0, 3, 11, 9, 11, 10, 9, -1, -1, -1, -1, -1, -1, -1,\n 9, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 3, 0, 7, 3, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 9, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 1, 9, 4, 7, 1, 7, 3, 1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 4, 7, 3, 0, 4, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1,\n 9, 2, 10, 9, 0, 2, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1,\n 2, 10, 9, 2, 9, 7, 2, 7, 3, 7, 9, 4, -1, -1, -1, -1,\n 8, 4, 7, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 11, 4, 7, 11, 2, 4, 2, 0, 4, -1, -1, -1, -1, -1, -1, -1,\n 9, 0, 1, 8, 4, 7, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1,\n 4, 7, 11, 9, 4, 11, 9, 11, 2, 9, 2, 1, -1, -1, -1, -1,\n 3, 10, 1, 3, 11, 10, 7, 8, 4, -1, -1, -1, -1, -1, -1, -1,\n 1, 11, 10, 1, 4, 11, 1, 0, 4, 7, 11, 4, -1, -1, -1, -1,\n 4, 7, 8, 9, 0, 11, 9, 11, 10, 11, 0, 3, -1, -1, -1, -1,\n 4, 7, 11, 4, 11, 9, 9, 11, 10, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 4, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 5, 4, 1, 5, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 8, 5, 4, 8, 3, 5, 3, 1, 5, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 8, 1, 2, 10, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1,\n 5, 2, 10, 5, 4, 2, 4, 0, 2, -1, -1, -1, -1, -1, -1, -1,\n 2, 10, 5, 3, 2, 5, 3, 5, 4, 3, 4, 8, -1, -1, -1, -1,\n 9, 5, 4, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 11, 2, 0, 8, 11, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1,\n 0, 5, 4, 0, 1, 5, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1,\n 2, 1, 5, 2, 5, 8, 2, 8, 11, 4, 8, 5, -1, -1, -1, -1,\n 10, 3, 11, 10, 1, 3, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1,\n 4, 9, 5, 0, 8, 1, 8, 10, 1, 8, 11, 10, -1, -1, -1, -1,\n 5, 4, 0, 5, 0, 11, 5, 11, 10, 11, 0, 3, -1, -1, -1, -1,\n 5, 4, 8, 5, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1,\n 9, 7, 8, 5, 7, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 3, 0, 9, 5, 3, 5, 7, 3, -1, -1, -1, -1, -1, -1, -1,\n 0, 7, 8, 0, 1, 7, 1, 5, 7, -1, -1, -1, -1, -1, -1, -1,\n 1, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 7, 8, 9, 5, 7, 10, 1, 2, -1, -1, -1, -1, -1, -1, -1,\n 10, 1, 2, 9, 5, 0, 5, 3, 0, 5, 7, 3, -1, -1, -1, -1,\n 8, 0, 2, 8, 2, 5, 8, 5, 7, 10, 5, 2, -1, -1, -1, -1,\n 2, 10, 5, 2, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1,\n 7, 9, 5, 7, 8, 9, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 7, 9, 7, 2, 9, 2, 0, 2, 7, 11, -1, -1, -1, -1,\n 2, 3, 11, 0, 1, 8, 1, 7, 8, 1, 5, 7, -1, -1, -1, -1,\n 11, 2, 1, 11, 1, 7, 7, 1, 5, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 8, 8, 5, 7, 10, 1, 3, 10, 3, 11, -1, -1, -1, -1,\n 5, 7, 0, 5, 0, 9, 7, 11, 0, 1, 0, 10, 11, 10, 0, -1,\n 11, 10, 0, 11, 0, 3, 10, 5, 0, 8, 0, 7, 5, 7, 0, -1,\n 11, 10, 5, 7, 11, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 0, 1, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 8, 3, 1, 9, 8, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1,\n 1, 6, 5, 2, 6, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 6, 5, 1, 2, 6, 3, 0, 8, -1, -1, -1, -1, -1, -1, -1,\n 9, 6, 5, 9, 0, 6, 0, 2, 6, -1, -1, -1, -1, -1, -1, -1,\n 5, 9, 8, 5, 8, 2, 5, 2, 6, 3, 2, 8, -1, -1, -1, -1,\n 2, 3, 11, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 11, 0, 8, 11, 2, 0, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 9, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1,\n 5, 10, 6, 1, 9, 2, 9, 11, 2, 9, 8, 11, -1, -1, -1, -1,\n 6, 3, 11, 6, 5, 3, 5, 1, 3, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 11, 0, 11, 5, 0, 5, 1, 5, 11, 6, -1, -1, -1, -1,\n 3, 11, 6, 0, 3, 6, 0, 6, 5, 0, 5, 9, -1, -1, -1, -1,\n 6, 5, 9, 6, 9, 11, 11, 9, 8, -1, -1, -1, -1, -1, -1, -1,\n 5, 10, 6, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 3, 0, 4, 7, 3, 6, 5, 10, -1, -1, -1, -1, -1, -1, -1,\n 1, 9, 0, 5, 10, 6, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1,\n 10, 6, 5, 1, 9, 7, 1, 7, 3, 7, 9, 4, -1, -1, -1, -1,\n 6, 1, 2, 6, 5, 1, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 5, 5, 2, 6, 3, 0, 4, 3, 4, 7, -1, -1, -1, -1,\n 8, 4, 7, 9, 0, 5, 0, 6, 5, 0, 2, 6, -1, -1, -1, -1,\n 7, 3, 9, 7, 9, 4, 3, 2, 9, 5, 9, 6, 2, 6, 9, -1,\n 3, 11, 2, 7, 8, 4, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1,\n 5, 10, 6, 4, 7, 2, 4, 2, 0, 2, 7, 11, -1, -1, -1, -1,\n 0, 1, 9, 4, 7, 8, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1,\n 9, 2, 1, 9, 11, 2, 9, 4, 11, 7, 11, 4, 5, 10, 6, -1,\n 8, 4, 7, 3, 11, 5, 3, 5, 1, 5, 11, 6, -1, -1, -1, -1,\n 5, 1, 11, 5, 11, 6, 1, 0, 11, 7, 11, 4, 0, 4, 11, -1,\n 0, 5, 9, 0, 6, 5, 0, 3, 6, 11, 6, 3, 8, 4, 7, -1,\n 6, 5, 9, 6, 9, 11, 4, 7, 9, 7, 11, 9, -1, -1, -1, -1,\n 10, 4, 9, 6, 4, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 10, 6, 4, 9, 10, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1,\n 10, 0, 1, 10, 6, 0, 6, 4, 0, -1, -1, -1, -1, -1, -1, -1,\n 8, 3, 1, 8, 1, 6, 8, 6, 4, 6, 1, 10, -1, -1, -1, -1,\n 1, 4, 9, 1, 2, 4, 2, 6, 4, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 8, 1, 2, 9, 2, 4, 9, 2, 6, 4, -1, -1, -1, -1,\n 0, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 8, 3, 2, 8, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1,\n 10, 4, 9, 10, 6, 4, 11, 2, 3, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 2, 2, 8, 11, 4, 9, 10, 4, 10, 6, -1, -1, -1, -1,\n 3, 11, 2, 0, 1, 6, 0, 6, 4, 6, 1, 10, -1, -1, -1, -1,\n 6, 4, 1, 6, 1, 10, 4, 8, 1, 2, 1, 11, 8, 11, 1, -1,\n 9, 6, 4, 9, 3, 6, 9, 1, 3, 11, 6, 3, -1, -1, -1, -1,\n 8, 11, 1, 8, 1, 0, 11, 6, 1, 9, 1, 4, 6, 4, 1, -1,\n 3, 11, 6, 3, 6, 0, 0, 6, 4, -1, -1, -1, -1, -1, -1, -1,\n 6, 4, 8, 11, 6, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 7, 10, 6, 7, 8, 10, 8, 9, 10, -1, -1, -1, -1, -1, -1, -1,\n 0, 7, 3, 0, 10, 7, 0, 9, 10, 6, 7, 10, -1, -1, -1, -1,\n 10, 6, 7, 1, 10, 7, 1, 7, 8, 1, 8, 0, -1, -1, -1, -1,\n 10, 6, 7, 10, 7, 1, 1, 7, 3, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 6, 1, 6, 8, 1, 8, 9, 8, 6, 7, -1, -1, -1, -1,\n 2, 6, 9, 2, 9, 1, 6, 7, 9, 0, 9, 3, 7, 3, 9, -1,\n 7, 8, 0, 7, 0, 6, 6, 0, 2, -1, -1, -1, -1, -1, -1, -1,\n 7, 3, 2, 6, 7, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 3, 11, 10, 6, 8, 10, 8, 9, 8, 6, 7, -1, -1, -1, -1,\n 2, 0, 7, 2, 7, 11, 0, 9, 7, 6, 7, 10, 9, 10, 7, -1,\n 1, 8, 0, 1, 7, 8, 1, 10, 7, 6, 7, 10, 2, 3, 11, -1,\n 11, 2, 1, 11, 1, 7, 10, 6, 1, 6, 7, 1, -1, -1, -1, -1,\n 8, 9, 6, 8, 6, 7, 9, 1, 6, 11, 6, 3, 1, 3, 6, -1,\n 0, 9, 1, 11, 6, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 7, 8, 0, 7, 0, 6, 3, 11, 0, 11, 6, 0, -1, -1, -1, -1,\n 7, 11, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 8, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 9, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 8, 1, 9, 8, 3, 1, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1,\n 10, 1, 2, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 3, 0, 8, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1,\n 2, 9, 0, 2, 10, 9, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1,\n 6, 11, 7, 2, 10, 3, 10, 8, 3, 10, 9, 8, -1, -1, -1, -1,\n 7, 2, 3, 6, 2, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 7, 0, 8, 7, 6, 0, 6, 2, 0, -1, -1, -1, -1, -1, -1, -1,\n 2, 7, 6, 2, 3, 7, 0, 1, 9, -1, -1, -1, -1, -1, -1, -1,\n 1, 6, 2, 1, 8, 6, 1, 9, 8, 8, 7, 6, -1, -1, -1, -1,\n 10, 7, 6, 10, 1, 7, 1, 3, 7, -1, -1, -1, -1, -1, -1, -1,\n 10, 7, 6, 1, 7, 10, 1, 8, 7, 1, 0, 8, -1, -1, -1, -1,\n 0, 3, 7, 0, 7, 10, 0, 10, 9, 6, 10, 7, -1, -1, -1, -1,\n 7, 6, 10, 7, 10, 8, 8, 10, 9, -1, -1, -1, -1, -1, -1, -1,\n 6, 8, 4, 11, 8, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 6, 11, 3, 0, 6, 0, 4, 6, -1, -1, -1, -1, -1, -1, -1,\n 8, 6, 11, 8, 4, 6, 9, 0, 1, -1, -1, -1, -1, -1, -1, -1,\n 9, 4, 6, 9, 6, 3, 9, 3, 1, 11, 3, 6, -1, -1, -1, -1,\n 6, 8, 4, 6, 11, 8, 2, 10, 1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 3, 0, 11, 0, 6, 11, 0, 4, 6, -1, -1, -1, -1,\n 4, 11, 8, 4, 6, 11, 0, 2, 9, 2, 10, 9, -1, -1, -1, -1,\n 10, 9, 3, 10, 3, 2, 9, 4, 3, 11, 3, 6, 4, 6, 3, -1,\n 8, 2, 3, 8, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1,\n 0, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 9, 0, 2, 3, 4, 2, 4, 6, 4, 3, 8, -1, -1, -1, -1,\n 1, 9, 4, 1, 4, 2, 2, 4, 6, -1, -1, -1, -1, -1, -1, -1,\n 8, 1, 3, 8, 6, 1, 8, 4, 6, 6, 10, 1, -1, -1, -1, -1,\n 10, 1, 0, 10, 0, 6, 6, 0, 4, -1, -1, -1, -1, -1, -1, -1,\n 4, 6, 3, 4, 3, 8, 6, 10, 3, 0, 3, 9, 10, 9, 3, -1,\n 10, 9, 4, 6, 10, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 9, 5, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 4, 9, 5, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1,\n 5, 0, 1, 5, 4, 0, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1,\n 11, 7, 6, 8, 3, 4, 3, 5, 4, 3, 1, 5, -1, -1, -1, -1,\n 9, 5, 4, 10, 1, 2, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1,\n 6, 11, 7, 1, 2, 10, 0, 8, 3, 4, 9, 5, -1, -1, -1, -1,\n 7, 6, 11, 5, 4, 10, 4, 2, 10, 4, 0, 2, -1, -1, -1, -1,\n 3, 4, 8, 3, 5, 4, 3, 2, 5, 10, 5, 2, 11, 7, 6, -1,\n 7, 2, 3, 7, 6, 2, 5, 4, 9, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 4, 0, 8, 6, 0, 6, 2, 6, 8, 7, -1, -1, -1, -1,\n 3, 6, 2, 3, 7, 6, 1, 5, 0, 5, 4, 0, -1, -1, -1, -1,\n 6, 2, 8, 6, 8, 7, 2, 1, 8, 4, 8, 5, 1, 5, 8, -1,\n 9, 5, 4, 10, 1, 6, 1, 7, 6, 1, 3, 7, -1, -1, -1, -1,\n 1, 6, 10, 1, 7, 6, 1, 0, 7, 8, 7, 0, 9, 5, 4, -1,\n 4, 0, 10, 4, 10, 5, 0, 3, 10, 6, 10, 7, 3, 7, 10, -1,\n 7, 6, 10, 7, 10, 8, 5, 4, 10, 4, 8, 10, -1, -1, -1, -1,\n 6, 9, 5, 6, 11, 9, 11, 8, 9, -1, -1, -1, -1, -1, -1, -1,\n 3, 6, 11, 0, 6, 3, 0, 5, 6, 0, 9, 5, -1, -1, -1, -1,\n 0, 11, 8, 0, 5, 11, 0, 1, 5, 5, 6, 11, -1, -1, -1, -1,\n 6, 11, 3, 6, 3, 5, 5, 3, 1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 9, 5, 11, 9, 11, 8, 11, 5, 6, -1, -1, -1, -1,\n 0, 11, 3, 0, 6, 11, 0, 9, 6, 5, 6, 9, 1, 2, 10, -1,\n 11, 8, 5, 11, 5, 6, 8, 0, 5, 10, 5, 2, 0, 2, 5, -1,\n 6, 11, 3, 6, 3, 5, 2, 10, 3, 10, 5, 3, -1, -1, -1, -1,\n 5, 8, 9, 5, 2, 8, 5, 6, 2, 3, 8, 2, -1, -1, -1, -1,\n 9, 5, 6, 9, 6, 0, 0, 6, 2, -1, -1, -1, -1, -1, -1, -1,\n 1, 5, 8, 1, 8, 0, 5, 6, 8, 3, 8, 2, 6, 2, 8, -1,\n 1, 5, 6, 2, 1, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 3, 6, 1, 6, 10, 3, 8, 6, 5, 6, 9, 8, 9, 6, -1,\n 10, 1, 0, 10, 0, 6, 9, 5, 0, 5, 6, 0, -1, -1, -1, -1,\n 0, 3, 8, 5, 6, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 10, 5, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 11, 5, 10, 7, 5, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 11, 5, 10, 11, 7, 5, 8, 3, 0, -1, -1, -1, -1, -1, -1, -1,\n 5, 11, 7, 5, 10, 11, 1, 9, 0, -1, -1, -1, -1, -1, -1, -1,\n 10, 7, 5, 10, 11, 7, 9, 8, 1, 8, 3, 1, -1, -1, -1, -1,\n 11, 1, 2, 11, 7, 1, 7, 5, 1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 1, 2, 7, 1, 7, 5, 7, 2, 11, -1, -1, -1, -1,\n 9, 7, 5, 9, 2, 7, 9, 0, 2, 2, 11, 7, -1, -1, -1, -1,\n 7, 5, 2, 7, 2, 11, 5, 9, 2, 3, 2, 8, 9, 8, 2, -1,\n 2, 5, 10, 2, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1,\n 8, 2, 0, 8, 5, 2, 8, 7, 5, 10, 2, 5, -1, -1, -1, -1,\n 9, 0, 1, 5, 10, 3, 5, 3, 7, 3, 10, 2, -1, -1, -1, -1,\n 9, 8, 2, 9, 2, 1, 8, 7, 2, 10, 2, 5, 7, 5, 2, -1,\n 1, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 7, 0, 7, 1, 1, 7, 5, -1, -1, -1, -1, -1, -1, -1,\n 9, 0, 3, 9, 3, 5, 5, 3, 7, -1, -1, -1, -1, -1, -1, -1,\n 9, 8, 7, 5, 9, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 5, 8, 4, 5, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1,\n 5, 0, 4, 5, 11, 0, 5, 10, 11, 11, 3, 0, -1, -1, -1, -1,\n 0, 1, 9, 8, 4, 10, 8, 10, 11, 10, 4, 5, -1, -1, -1, -1,\n 10, 11, 4, 10, 4, 5, 11, 3, 4, 9, 4, 1, 3, 1, 4, -1,\n 2, 5, 1, 2, 8, 5, 2, 11, 8, 4, 5, 8, -1, -1, -1, -1,\n 0, 4, 11, 0, 11, 3, 4, 5, 11, 2, 11, 1, 5, 1, 11, -1,\n 0, 2, 5, 0, 5, 9, 2, 11, 5, 4, 5, 8, 11, 8, 5, -1,\n 9, 4, 5, 2, 11, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 5, 10, 3, 5, 2, 3, 4, 5, 3, 8, 4, -1, -1, -1, -1,\n 5, 10, 2, 5, 2, 4, 4, 2, 0, -1, -1, -1, -1, -1, -1, -1,\n 3, 10, 2, 3, 5, 10, 3, 8, 5, 4, 5, 8, 0, 1, 9, -1,\n 5, 10, 2, 5, 2, 4, 1, 9, 2, 9, 4, 2, -1, -1, -1, -1,\n 8, 4, 5, 8, 5, 3, 3, 5, 1, -1, -1, -1, -1, -1, -1, -1,\n 0, 4, 5, 1, 0, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 8, 4, 5, 8, 5, 3, 9, 0, 5, 0, 3, 5, -1, -1, -1, -1,\n 9, 4, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 11, 7, 4, 9, 11, 9, 10, 11, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 4, 9, 7, 9, 11, 7, 9, 10, 11, -1, -1, -1, -1,\n 1, 10, 11, 1, 11, 4, 1, 4, 0, 7, 4, 11, -1, -1, -1, -1,\n 3, 1, 4, 3, 4, 8, 1, 10, 4, 7, 4, 11, 10, 11, 4, -1,\n 4, 11, 7, 9, 11, 4, 9, 2, 11, 9, 1, 2, -1, -1, -1, -1,\n 9, 7, 4, 9, 11, 7, 9, 1, 11, 2, 11, 1, 0, 8, 3, -1,\n 11, 7, 4, 11, 4, 2, 2, 4, 0, -1, -1, -1, -1, -1, -1, -1,\n 11, 7, 4, 11, 4, 2, 8, 3, 4, 3, 2, 4, -1, -1, -1, -1,\n 2, 9, 10, 2, 7, 9, 2, 3, 7, 7, 4, 9, -1, -1, -1, -1,\n 9, 10, 7, 9, 7, 4, 10, 2, 7, 8, 7, 0, 2, 0, 7, -1,\n 3, 7, 10, 3, 10, 2, 7, 4, 10, 1, 10, 0, 4, 0, 10, -1,\n 1, 10, 2, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 9, 1, 4, 1, 7, 7, 1, 3, -1, -1, -1, -1, -1, -1, -1,\n 4, 9, 1, 4, 1, 7, 0, 8, 1, 8, 7, 1, -1, -1, -1, -1,\n 4, 0, 3, 7, 4, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 8, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 9, 3, 9, 11, 11, 9, 10, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 10, 0, 10, 8, 8, 10, 11, -1, -1, -1, -1, -1, -1, -1,\n 3, 1, 10, 11, 3, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 11, 1, 11, 9, 9, 11, 8, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 9, 3, 9, 11, 1, 2, 9, 2, 11, 9, -1, -1, -1, -1,\n 0, 2, 11, 8, 0, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 2, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 3, 8, 2, 8, 10, 10, 8, 9, -1, -1, -1, -1, -1, -1, -1,\n 9, 10, 2, 0, 9, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 3, 8, 2, 8, 10, 0, 1, 8, 1, 10, 8, -1, -1, -1, -1,\n 1, 10, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 3, 8, 9, 1, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 9, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 3, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1\n ])\n}\n\ninterface MarchingCubes {\n new (field: number[], nx: number, ny: number, nz: number, atomindex: number[]): void\n triangulate: (_isolevel: number, _noNormals: boolean, _box: number[][]|undefined, _contour: boolean, _wrap: boolean) => {\n position: Float32Array\n normal: undefined|Float32Array\n index: Uint32Array|Uint16Array\n atomindex: Int32Array|undefined\n contour: boolean\n }\n}\nfunction MarchingCubes (this: MarchingCubes, field: number[], nx: number, ny: number, nz: number, atomindex: number[]) {\n // Based on alteredq / http://alteredqualia.com/\n // port of greggman's ThreeD version of marching cubes to Three.js\n // http://webglsamples.googlecode.com/hg/blob/blob.html\n //\n // Adapted for NGL by Alexander Rose\n\n // Triangles are constructed between points on cube edges.\n // allowedContours[edge1][edge1] indicates which lines from a given\n // triangle should be shown in line mode.\n\n // Values are bitmasks:\n // In loop over cubes we keep another bitmask indicating whether our current\n // cell is the first x-value (1),\n // first y-value (2) or first z-value (4) of the current loop.\n // We draw all lines on leading faces but only draw trailing face lines the first\n // time through the loop\n // A value of 8 below means the edge is always drawn (leading face)\n\n // E.g. the first row, lines between edge0 and other edges in the bottom\n // x-y plane are only drawn for the first value of z, edges in the\n // x-z plane are only drawn for the first value of y. No other lines\n // are drawn as they're redundant\n // The line between edge 1 and 5 is always drawn as it's on the leading edge\n var allowedContours = [\n\n [ 0, 4, 4, 4, 2, 0, 0, 0, 2, 2, 0, 0 ], // 1 2 3 4 8 9\n [ 4, 0, 4, 4, 0, 8, 0, 0, 0, 8, 8, 0 ], // 0 2 3 5 9 10\n [ 4, 4, 0, 4, 0, 0, 8, 0, 0, 0, 8, 8 ], // 0 1 3 6 10 11\n [ 4, 4, 4, 0, 0, 0, 0, 1, 1, 0, 0, 1 ], // 0 1 2 7 8 11\n [ 2, 0, 0, 0, 0, 8, 8, 8, 2, 2, 0, 0 ], // 0 5 6 7 8 9\n [ 0, 8, 0, 0, 8, 0, 8, 8, 0, 8, 8, 0 ], // And rotate it\n [ 0, 0, 8, 0, 8, 8, 0, 8, 0, 0, 8, 8 ],\n [ 0, 0, 0, 1, 8, 8, 8, 0, 1, 0, 0, 1 ],\n [ 2, 0, 0, 1, 2, 0, 0, 1, 0, 2, 0, 1 ], // 0 3 4 7 9 11\n [ 2, 8, 0, 0, 2, 8, 0, 0, 2, 0, 8, 0 ], // And rotate some more\n [ 0, 8, 8, 0, 0, 8, 8, 0, 0, 8, 0, 8 ],\n [ 0, 0, 8, 1, 0, 0, 8, 1, 1, 0, 8, 0 ]\n\n ]\n\n var isolevel = 0\n var noNormals = false\n var contour = false\n var wrap = false\n var isNegativeIso = false\n var normalFactor = -1\n\n\n var n = nx * ny * nz\n\n // deltas\n var yd = nx\n var zd = nx * ny\n\n var normalCache: Float32Array, vertexIndex: Int32Array\n var count: number, icount: number\n\n var ilist = new Int32Array(12)\n\n var positionArray: number[] = []\n var normalArray: number[] = []\n var indexArray: number[] = []\n var atomindexArray: number[] = []\n\n var edgeTable = getEdgeTable()\n var triTable = getTriTable()\n\n var mx: number, my: number, mz: number\n\n //\n\n this.triangulate = function (_isolevel: number, _noNormals: boolean, _box: number[][]|undefined, _contour: boolean, _wrap: boolean) {\n isolevel = _isolevel\n isNegativeIso = isolevel < 0.0\n contour = _contour\n wrap = _wrap\n // Normals currently disabled in contour mode for performance (unused)\n noNormals = _noNormals || contour\n\n if (!noNormals) {\n normalFactor = isolevel > 0 ? -1.0 : 1.0\n if (!normalCache) {\n normalCache = new Float32Array(n * 3)\n } \n }\n\n var vIndexLength = n * 3\n\n if (!vertexIndex || vertexIndex.length !== vIndexLength) {\n vertexIndex = new Int32Array(vIndexLength)\n }\n\n count = 0\n icount = 0\n\n if (_box !== undefined) {\n var min = _box[ 0 ].map(Math.round)\n var max = _box[ 1 ].map(Math.round)\n\n mx = nx * Math.ceil(Math.abs(min[ 0 ]) / nx)\n my = ny * Math.ceil(Math.abs(min[ 1 ]) / ny)\n mz = nz * Math.ceil(Math.abs(min[ 2 ]) / nz)\n\n triangulate(\n min[ 0 ], min[ 1 ], min[ 2 ],\n max[ 0 ], max[ 1 ], max[ 2 ]\n )\n } else {\n mx = my = mz = 0\n\n triangulate()\n }\n\n positionArray.length = count * 3\n if (!noNormals) normalArray.length = count * 3\n indexArray.length = icount\n if (atomindex) atomindexArray.length = count\n\n return {\n position: new Float32Array(positionArray),\n normal: noNormals ? undefined : new Float32Array(normalArray),\n index: getUintArray(indexArray, positionArray.length / 3),\n atomindex: atomindex ? new Int32Array(atomindexArray) : undefined,\n contour: contour\n }\n }\n\n // polygonization\n\n function lerp (a: number, b: number, t: number) { return a + (b - a) * t }\n\n function index (x: number, y: number, z: number) {\n x = (x + mx) % nx\n y = (y + my) % ny\n z = (z + mz) % nz\n return ((zd * z) + yd * y) + x\n }\n\n function VIntX (q: number, offset: number, x: number, y: number, z: number, valp1: number, valp2: number) {\n var _q = 3 * q\n\n if (vertexIndex[ _q ] < 0) {\n var mu = (isolevel - valp1) / (valp2 - valp1)\n var nc = normalCache\n\n var c = count * 3\n\n positionArray[ c ] = x + mu\n positionArray[ c + 1 ] = y\n positionArray[ c + 2 ] = z\n\n if (!noNormals) {\n var q3 = q * 3\n\n normalArray[ c ] = normalFactor * lerp(nc[ q3 ], nc[ q3 + 3 ], mu)\n normalArray[ c + 1 ] = normalFactor * lerp(nc[ q3 + 1 ], nc[ q3 + 4 ], mu)\n normalArray[ c + 2 ] = normalFactor * lerp(nc[ q3 + 2 ], nc[ q3 + 5 ], mu)\n }\n\n if (atomindex) atomindexArray[ count ] = atomindex[ q + Math.round(mu) ]\n\n vertexIndex[ _q ] = count\n ilist[ offset ] = count\n\n count += 1\n } else {\n ilist[ offset ] = vertexIndex[ _q ]\n }\n }\n\n function VIntY (q: number, offset: number, x: number, y: number, z: number, valp1: number, valp2: number) {\n var _q = 3 * q + 1\n\n if (vertexIndex[ _q ] < 0) {\n var mu = (isolevel - valp1) / (valp2 - valp1)\n var nc = normalCache\n\n var c = count * 3\n\n positionArray[ c ] = x\n positionArray[ c + 1 ] = y + mu\n positionArray[ c + 2 ] = z\n\n if (!noNormals) {\n var q3 = q * 3\n var q6 = q3 + yd * 3\n\n normalArray[ c ] = normalFactor * lerp(nc[ q3 ], nc[ q6 ], mu)\n normalArray[ c + 1 ] = normalFactor * lerp(nc[ q3 + 1 ], nc[ q6 + 1 ], mu)\n normalArray[ c + 2 ] = normalFactor * lerp(nc[ q3 + 2 ], nc[ q6 + 2 ], mu)\n }\n\n if (atomindex) atomindexArray[ count ] = atomindex[ q + Math.round(mu) * yd ]\n\n vertexIndex[ _q ] = count\n ilist[ offset ] = count\n\n count += 1\n } else {\n ilist[ offset ] = vertexIndex[ _q ]\n }\n }\n\n function VIntZ (q: number, offset: number, x: number, y: number, z: number, valp1: number, valp2: number) {\n var _q = 3 * q + 2\n\n if (vertexIndex[ _q ] < 0) {\n var mu = (isolevel - valp1) / (valp2 - valp1)\n var nc = normalCache\n\n var c = count * 3\n\n positionArray[ c ] = x\n positionArray[ c + 1 ] = y\n positionArray[ c + 2 ] = z + mu\n\n if (!noNormals) {\n var q3 = q * 3\n var q6 = q3 + zd * 3\n\n normalArray[ c ] = normalFactor * lerp(nc[ q3 ], nc[ q6 ], mu)\n normalArray[ c + 1 ] = normalFactor * lerp(nc[ q3 + 1 ], nc[ q6 + 1 ], mu)\n normalArray[ c + 2 ] = normalFactor * lerp(nc[ q3 + 2 ], nc[ q6 + 2 ], mu)\n }\n\n if (atomindex) atomindexArray[ count ] = atomindex[ q + Math.round(mu) * zd ]\n\n vertexIndex[ _q ] = count\n ilist[ offset ] = count\n\n count += 1\n } else {\n ilist[ offset ] = vertexIndex[ _q ]\n }\n }\n\n function compNorm (q: number) {\n var q3 = q * 3\n\n if (normalCache[ q3 ] === 0.0) {\n normalCache[ q3 ] = field[ (q - 1 + n) % n ] - field[ (q + 1) % n ]\n normalCache[ q3 + 1 ] = field[ (q - yd + n) % n ] - field[ (q + yd) % n ]\n normalCache[ q3 + 2 ] = field[ (q - zd + n) % n ] - field[ (q + zd) % n ]\n }\n }\n\n function polygonize (fx: number, fy: number, fz: number, q: number, edgeFilter: number) {\n // cache indices\n var q1\n var qy\n var qz\n var q1y\n var q1z\n var qyz\n var q1yz\n if (wrap) {\n q = index(fx, fy, fz)\n q1 = index(fx + 1, fy, fz)\n qy = index(fx, fy + 1, fz)\n qz = index(fx, fy, fz + 1)\n q1y = index(fx + 1, fy + 1, fz)\n q1z = index(fx + 1, fy, fz + 1)\n qyz = index(fx, fy + 1, fz + 1)\n q1yz = index(fx + 1, fy + 1, fz + 1)\n } else {\n q1 = q + 1\n qy = q + yd\n qz = q + zd\n q1y = qy + 1\n q1z = qz + 1\n qyz = qy + zd\n q1yz = qyz + 1\n }\n\n var cubeindex = 0\n var field0 = field[ q ]\n var field1 = field[ q1 ]\n var field2 = field[ qy ]\n var field3 = field[ q1y ]\n var field4 = field[ qz ]\n var field5 = field[ q1z ]\n var field6 = field[ qyz ]\n var field7 = field[ q1yz ]\n\n if (field0 < isolevel) cubeindex |= 1\n if (field1 < isolevel) cubeindex |= 2\n if (field2 < isolevel) cubeindex |= 8\n if (field3 < isolevel) cubeindex |= 4\n if (field4 < isolevel) cubeindex |= 16\n if (field5 < isolevel) cubeindex |= 32\n if (field6 < isolevel) cubeindex |= 128\n if (field7 < isolevel) cubeindex |= 64\n\n // if cube is entirely in/out of the surface - bail, nothing to draw\n\n var bits = edgeTable[ cubeindex ]\n if (bits === 0) return 0\n\n var fx2 = fx + 1\n var fy2 = fy + 1\n var fz2 = fz + 1\n\n // top of the cube\n\n if (bits & 1) {\n if (!noNormals) {\n compNorm(q)\n compNorm(q1)\n }\n VIntX(q, 0, fx, fy, fz, field0, field1)\n }\n\n if (bits & 2) {\n if (!noNormals) {\n compNorm(q1)\n compNorm(q1y)\n }\n VIntY(q1, 1, fx2, fy, fz, field1, field3)\n }\n\n if (bits & 4) {\n if (!noNormals) {\n compNorm(qy)\n compNorm(q1y)\n }\n VIntX(qy, 2, fx, fy2, fz, field2, field3)\n }\n\n if (bits & 8) {\n if (!noNormals) {\n compNorm(q)\n compNorm(qy)\n }\n VIntY(q, 3, fx, fy, fz, field0, field2)\n }\n\n // bottom of the cube\n\n if (bits & 16) {\n if (!noNormals) {\n compNorm(qz)\n compNorm(q1z)\n }\n VIntX(qz, 4, fx, fy, fz2, field4, field5)\n }\n\n if (bits & 32) {\n if (!noNormals) {\n compNorm(q1z)\n compNorm(q1yz)\n }\n VIntY(q1z, 5, fx2, fy, fz2, field5, field7)\n }\n\n if (bits & 64) {\n if (!noNormals) {\n compNorm(qyz)\n compNorm(q1yz)\n }\n VIntX(qyz, 6, fx, fy2, fz2, field6, field7)\n }\n\n if (bits & 128) {\n if (!noNormals) {\n compNorm(qz)\n compNorm(qyz)\n }\n VIntY(qz, 7, fx, fy, fz2, field4, field6)\n }\n\n // vertical lines of the cube\n\n if (bits & 256) {\n if (!noNormals) {\n compNorm(q)\n compNorm(qz)\n }\n VIntZ(q, 8, fx, fy, fz, field0, field4)\n }\n\n if (bits & 512) {\n if (!noNormals) {\n compNorm(q1)\n compNorm(q1z)\n }\n VIntZ(q1, 9, fx2, fy, fz, field1, field5)\n }\n\n if (bits & 1024) {\n if (!noNormals) {\n compNorm(q1y)\n compNorm(q1yz)\n }\n VIntZ(q1y, 10, fx2, fy2, fz, field3, field7)\n }\n\n if (bits & 2048) {\n if (!noNormals) {\n compNorm(qy)\n compNorm(qyz)\n }\n VIntZ(qy, 11, fx, fy2, fz, field2, field6)\n }\n\n var triIndex = cubeindex << 4 // re-purpose cubeindex into an offset into triTable\n\n var e1\n var e2\n var e3\n var i = 0\n\n // here is where triangles are created\n\n while (triTable[ triIndex + i ] !== -1) {\n e1 = triTable[ triIndex + i ]\n e2 = triTable[ triIndex + i + 1 ]\n e3 = triTable[ triIndex + i + 2 ]\n\n if (contour) {\n if (allowedContours[ e1 ][ e2 ] & edgeFilter) {\n indexArray[ icount++ ] = ilist[ e1 ]\n indexArray[ icount++ ] = ilist[ e2 ]\n }\n if (allowedContours[ e2 ][ e3 ] & edgeFilter) {\n indexArray[ icount++ ] = ilist[ e2 ]\n indexArray[ icount++ ] = ilist[ e3 ]\n }\n if (allowedContours[ e1 ][ e3 ] & edgeFilter) {\n indexArray[ icount++ ] = ilist[ e1 ]\n indexArray[ icount++ ] = ilist[ e3 ]\n }\n } else {\n indexArray[ icount++ ] = ilist[ isNegativeIso ? e1 : e2 ]\n indexArray[ icount++ ] = ilist[ isNegativeIso ? e2 : e1 ]\n indexArray[ icount++ ] = ilist[ e3 ]\n }\n\n i += 3\n }\n }\n\n function triangulate (xBeg?: number, yBeg?: number, zBeg?: number, xEnd?: number, yEnd?: number, zEnd?: number) {\n let q\n let q3\n let x\n let y\n let z\n let yOffset\n let zOffset\n\n xBeg = xBeg !== undefined ? xBeg : 0\n yBeg = yBeg !== undefined ? yBeg : 0\n zBeg = zBeg !== undefined ? zBeg : 0\n\n xEnd = xEnd !== undefined ? xEnd : nx - 1\n yEnd = yEnd !== undefined ? yEnd : ny - 1\n zEnd = zEnd !== undefined ? zEnd : nz - 1\n\n if (!wrap) {\n if (noNormals) {\n xBeg = Math.max(0, xBeg)\n yBeg = Math.max(0, yBeg)\n zBeg = Math.max(0, zBeg)\n\n xEnd = Math.min(nx - 1, xEnd)\n yEnd = Math.min(ny - 1, yEnd)\n zEnd = Math.min(nz - 1, zEnd)\n } else {\n xBeg = Math.max(1, xBeg)\n yBeg = Math.max(1, yBeg)\n zBeg = Math.max(1, zBeg)\n\n xEnd = Math.min(nx - 2, xEnd)\n yEnd = Math.min(ny - 2, yEnd)\n zEnd = Math.min(nz - 2, zEnd)\n }\n }\n\n let xBeg2, yBeg2, zBeg2, xEnd2, yEnd2, zEnd2\n\n if (!wrap) {\n // init part of the vertexIndex\n // (takes a significant amount of time to do for all)\n\n xBeg2 = Math.max(0, xBeg - 2)\n yBeg2 = Math.max(0, yBeg - 2)\n zBeg2 = Math.max(0, zBeg - 2)\n\n xEnd2 = Math.min(nx, xEnd + 2)\n yEnd2 = Math.min(ny, yEnd + 2)\n zEnd2 = Math.min(nz, zEnd + 2)\n\n for (z = zBeg2; z < zEnd2; ++z) {\n zOffset = zd * z\n for (y = yBeg2; y < yEnd2; ++y) {\n yOffset = zOffset + yd * y\n for (x = xBeg2; x < xEnd2; ++x) {\n q = 3 * (yOffset + x)\n vertexIndex[ q ] = -1\n vertexIndex[ q + 1 ] = -1\n vertexIndex[ q + 2 ] = -1\n }\n }\n }\n } else {\n xBeg2 = xBeg - 2\n yBeg2 = yBeg - 2\n zBeg2 = zBeg - 2\n\n xEnd2 = xEnd + 2\n yEnd2 = yEnd + 2\n zEnd2 = zEnd + 2\n\n for (z = zBeg2; z < zEnd2; ++z) {\n for (y = yBeg2; y < yEnd2; ++y) {\n for (x = xBeg2; x < xEnd2; ++x) {\n q3 = index(x, y, z) * 3\n vertexIndex[ q3 ] = -1\n vertexIndex[ q3 + 1 ] = -1\n vertexIndex[ q3 + 2 ] = -1\n }\n }\n }\n }\n\n if (!wrap) {\n // clip space where the isovalue is too low\n\n var __break\n var __xBeg = xBeg; var __yBeg = yBeg; var __zBeg = zBeg\n var __xEnd = xEnd; var __yEnd = yEnd; var __zEnd = zEnd\n\n __break = false\n for (z = zBeg; z < zEnd; ++z) {\n for (y = yBeg; y < yEnd; ++y) {\n for (x = xBeg; x < xEnd; ++x) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __zBeg = z\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (y = yBeg; y < yEnd; ++y) {\n for (z = __zBeg; z < zEnd; ++z) {\n for (x = xBeg; x < xEnd; ++x) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __yBeg = y\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (x = xBeg; x < xEnd; ++x) {\n for (y = __yBeg; y < yEnd; ++y) {\n for (z = __zBeg; z < zEnd; ++z) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __xBeg = x\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (z = zEnd; z >= zBeg; --z) {\n for (y = yEnd; y >= yBeg; --y) {\n for (x = xEnd; x >= xBeg; --x) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __zEnd = z\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (y = yEnd; y >= yBeg; --y) {\n for (z = __zEnd; z >= zBeg; --z) {\n for (x = xEnd; x >= xBeg; --x) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __yEnd = y\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (x = xEnd; x >= xBeg; --x) {\n for (y = __yEnd; y >= yBeg; --y) {\n for (z = __zEnd; z >= zBeg; --z) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __xEnd = x\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n //\n\n if (noNormals) {\n xBeg = Math.max(0, __xBeg - 1)\n yBeg = Math.max(0, __yBeg - 1)\n zBeg = Math.max(0, __zBeg - 1)\n\n xEnd = Math.min(nx - 1, __xEnd + 1)\n yEnd = Math.min(ny - 1, __yEnd + 1)\n zEnd = Math.min(nz - 1, __zEnd + 1)\n } else {\n xBeg = Math.max(1, __xBeg - 1)\n yBeg = Math.max(1, __yBeg - 1)\n zBeg = Math.max(1, __zBeg - 1)\n\n xEnd = Math.min(nx - 2, __xEnd + 1)\n yEnd = Math.min(ny - 2, __yEnd + 1)\n zEnd = Math.min(nz - 2, __zEnd + 1)\n }\n }\n\n // polygonize part of the grid\n var edgeFilter = 15\n for (z = zBeg; z < zEnd; ++z, edgeFilter &= ~4) {\n zOffset = zd * z\n edgeFilter |= 2\n for (y = yBeg; y < yEnd; ++y, edgeFilter &= ~2) {\n yOffset = zOffset + yd * y\n edgeFilter |= 1\n for (x = xBeg; x < xEnd; ++x, edgeFilter &= ~1) {\n q = yOffset + x\n polygonize(x, y, z, q, edgeFilter)\n }\n }\n }\n }\n}\nObject.assign(MarchingCubes, {__deps: [ getEdgeTable, getTriTable, getUintArray ]})\n\nexport default MarchingCubes\n","/**\n * @file Matrix Utils\n * @private\n * @author Alexander Rose \n *\n * svd methods from Eugene Zatepyakin / http://inspirit.github.io/jsfeat/\n */\n\nimport { NumberArray } from '../types'\nimport { v3new, v3cross } from './vector-utils'\n\nexport class Matrix {\n size: number\n data: Float32Array\n\n constructor (readonly cols: number, readonly rows: number) {\n this.size = this.cols * this.rows\n this.data = new Float32Array(this.size)\n }\n\n copyTo (matrix: Matrix) {\n matrix.data.set(this.data)\n }\n}\n\nexport function transpose (At: Matrix, A: Matrix) {\n let i = 0\n let j = 0\n const nrows = A.rows\n const ncols = A.cols\n let Ai = 0\n let Ati = 0\n let pAt = 0\n const ad = A.data\n const atd = At.data\n\n for (; i < nrows; Ati += 1, Ai += ncols, i++) {\n pAt = Ati\n for (j = 0; j < ncols; pAt += nrows, j++) atd[pAt] = ad[Ai + j]\n }\n}\n\n// C = A * B\nexport function multiply (C: Matrix, A: Matrix, B: Matrix) {\n let i = 0\n let j = 0\n let k = 0\n let Ap = 0\n let pA = 0\n let pB = 0\n let _pB = 0\n let Cp = 0\n const ncols = A.cols\n const nrows = A.rows\n const mcols = B.cols\n const ad = A.data\n const bd = B.data\n const cd = C.data\n let sum = 0.0\n\n for (; i < nrows; Ap += ncols, i++) {\n for (_pB = 0, j = 0; j < mcols; Cp++, _pB++, j++) {\n pB = _pB\n pA = Ap\n sum = 0.0\n for (k = 0; k < ncols; pA++, pB += mcols, k++) {\n sum += ad[pA] * bd[pB]\n }\n cd[Cp] = sum\n }\n }\n}\n\n// C = A * B'\nexport function multiplyABt (C: Matrix, A: Matrix, B: Matrix) {\n let i = 0\n let j = 0\n let k = 0\n let Ap = 0\n let pA = 0\n let pB = 0\n let Cp = 0\n const ncols = A.cols\n const nrows = A.rows\n const mrows = B.rows\n const ad = A.data\n const bd = B.data\n const cd = C.data\n let sum = 0.0\n\n for (; i < nrows; Ap += ncols, i++) {\n for (pB = 0, j = 0; j < mrows; Cp++, j++) {\n pA = Ap\n sum = 0.0\n for (k = 0; k < ncols; pA++, pB++, k++) {\n sum += ad[pA] * bd[pB]\n }\n cd[Cp] = sum\n }\n }\n}\n\n// C = A' * B\nexport function multiplyAtB (C: Matrix, A: Matrix, B: Matrix) {\n let i = 0\n let j = 0\n let k = 0\n let Ap = 0\n let pA = 0\n let pB = 0\n let _pB = 0\n let Cp = 0\n const ncols = A.cols\n const nrows = A.rows\n const mcols = B.cols\n const ad = A.data\n const bd = B.data\n const cd = C.data\n let sum = 0.0\n\n for (; i < ncols; Ap++, i++) {\n for (_pB = 0, j = 0; j < mcols; Cp++, _pB++, j++) {\n pB = _pB\n pA = Ap\n sum = 0.0\n for (k = 0; k < nrows; pA += ncols, pB += mcols, k++) {\n sum += ad[pA] * bd[pB]\n }\n cd[Cp] = sum\n }\n }\n}\n\nexport function invert3x3 (from: Matrix, to: Matrix) {\n const A = from.data\n const invA = to.data\n const t1 = A[4]\n const t2 = A[8]\n const t4 = A[5]\n const t5 = A[7]\n const t8 = A[0]\n\n const t9 = t8 * t1\n const t11 = t8 * t4\n const t13 = A[3]\n const t14 = A[1]\n const t15 = t13 * t14\n const t17 = A[2]\n const t18 = t13 * t17\n const t20 = A[6]\n const t21 = t20 * t14\n const t23 = t20 * t17\n const t26 = 1.0 / (t9 * t2 - t11 * t5 - t15 * t2 + t18 * t5 + t21 * t4 - t23 * t1)\n invA[0] = (t1 * t2 - t4 * t5) * t26\n invA[1] = -(t14 * t2 - t17 * t5) * t26\n invA[2] = -(-t14 * t4 + t17 * t1) * t26\n invA[3] = -(t13 * t2 - t4 * t20) * t26\n invA[4] = (t8 * t2 - t23) * t26\n invA[5] = -(t11 - t18) * t26\n invA[6] = -(-t13 * t5 + t1 * t20) * t26\n invA[7] = -(t8 * t5 - t21) * t26\n invA[8] = (t9 - t15) * t26\n}\n\nexport function mat3x3determinant (M: Matrix) {\n const md = M.data\n return md[0] * md[4] * md[8] -\n md[0] * md[5] * md[7] -\n md[3] * md[1] * md[8] +\n md[3] * md[2] * md[7] +\n md[6] * md[1] * md[5] -\n md[6] * md[2] * md[4]\n}\n\n// C = A * B\nexport function multiply3x3 (C: Matrix, A: Matrix, B: Matrix) {\n const Cd = C.data\n const Ad = A.data\n const Bd = B.data\n const m10 = Ad[0]\n const m11 = Ad[1]\n const m12 = Ad[2]\n const m13 = Ad[3]\n const m14 = Ad[4]\n const m15 = Ad[5]\n const m16 = Ad[6]\n const m17 = Ad[7]\n const m18 = Ad[8]\n\n const m20 = Bd[0]\n const m21 = Bd[1]\n const m22 = Bd[2]\n const m23 = Bd[3]\n const m24 = Bd[4]\n const m25 = Bd[5]\n const m26 = Bd[6]\n const m27 = Bd[7]\n const m28 = Bd[8]\n\n Cd[0] = m10 * m20 + m11 * m23 + m12 * m26\n Cd[1] = m10 * m21 + m11 * m24 + m12 * m27\n Cd[2] = m10 * m22 + m11 * m25 + m12 * m28\n Cd[3] = m13 * m20 + m14 * m23 + m15 * m26\n Cd[4] = m13 * m21 + m14 * m24 + m15 * m27\n Cd[5] = m13 * m22 + m14 * m25 + m15 * m28\n Cd[6] = m16 * m20 + m17 * m23 + m18 * m26\n Cd[7] = m16 * m21 + m17 * m24 + m18 * m27\n Cd[8] = m16 * m22 + m17 * m25 + m18 * m28\n}\n\nexport function meanRows (A: Matrix) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n const mean = new Array(ncols)\n\n for (let j = 0; j < ncols; ++j) {\n mean[ j ] = 0.0\n }\n\n for (let i = 0, p = 0; i < nrows; ++i) {\n for (let j = 0; j < ncols; ++j, ++p) {\n mean[ j ] += Ad[ p ]\n }\n }\n\n for (let j = 0; j < ncols; ++j) {\n mean[ j ] /= nrows\n }\n\n return mean\n}\n\nexport function meanCols (A: Matrix) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n const mean = new Array(nrows)\n\n for (let j = 0; j < nrows; ++j) {\n mean[ j ] = 0.0\n }\n\n for (let i = 0, p = 0; i < ncols; ++i) {\n for (let j = 0; j < nrows; ++j, ++p) {\n mean[ j ] += Ad[ p ]\n }\n }\n\n for (let j = 0; j < nrows; ++j) {\n mean[ j ] /= ncols\n }\n\n return mean\n}\n\nexport function subRows (A: Matrix, row: number[]) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n\n for (let i = 0, p = 0; i < nrows; ++i) {\n for (let j = 0; j < ncols; ++j, ++p) {\n Ad[ p ] -= row[ j ]\n }\n }\n}\n\nexport function subCols (A: Matrix, col: number[]) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n\n for (let i = 0, p = 0; i < ncols; ++i) {\n for (let j = 0; j < nrows; ++j, ++p) {\n Ad[ p ] -= col[ j ]\n }\n }\n}\n\nexport function addRows (A: Matrix, row: number[]) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n\n for (let i = 0, p = 0; i < nrows; ++i) {\n for (let j = 0; j < ncols; ++j, ++p) {\n Ad[ p ] += row[ j ]\n }\n }\n}\n\nexport function addCols (A: Matrix, col: number[]) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n\n for (let i = 0, p = 0; i < ncols; ++i) {\n for (let j = 0; j < nrows; ++j, ++p) {\n Ad[ p ] += col[ j ]\n }\n }\n}\n\nexport function swap (A: NumberArray, i0: number, i1: number, t: number) {\n t = A[i0]\n A[i0] = A[i1]\n A[i1] = t\n}\n\nexport function hypot (a: number, b: number) {\n a = Math.abs(a)\n b = Math.abs(b)\n if (a > b) {\n b /= a\n return a * Math.sqrt(1.0 + b * b)\n }\n if (b > 0) {\n a /= b\n return b * Math.sqrt(1.0 + a * a)\n }\n return 0.0\n}\n\nconst EPSILON = 0.0000001192092896\nconst FLT_MIN = 1E-37\n\nexport function JacobiSVDImpl (At: NumberArray, astep: number, _W: NumberArray, Vt: NumberArray, vstep: number, m: number, n: number, n1: number) {\n const eps = EPSILON * 2.0\n const minval = FLT_MIN\n let i = 0\n let j = 0\n let k = 0\n let iter = 0\n const maxIter = Math.max(m, 30)\n let Ai = 0\n let Aj = 0\n let Vi = 0\n let Vj = 0\n let changed = 0\n let c = 0.0\n let s = 0.0\n let t = 0.0\n let t0 = 0.0\n let t1 = 0.0\n let sd = 0.0\n let beta = 0.0\n let gamma = 0.0\n let delta = 0.0\n let a = 0.0\n let p = 0.0\n let b = 0.0\n let seed = 0x1234\n let val = 0.0\n let val0 = 0.0\n let asum = 0.0\n\n const W = new Float64Array(n << 3)\n\n for (; i < n; i++) {\n for (k = 0, sd = 0; k < m; k++) {\n t = At[i * astep + k]\n sd += t * t\n }\n W[i] = sd\n\n if (Vt) {\n for (k = 0; k < n; k++) {\n Vt[i * vstep + k] = 0\n }\n Vt[i * vstep + i] = 1\n }\n }\n\n for (; iter < maxIter; iter++) {\n changed = 0\n\n for (i = 0; i < n - 1; i++) {\n for (j = i + 1; j < n; j++) {\n Ai = (i * astep) | 0\n Aj = (j * astep) | 0\n a = W[i]\n p = 0\n b = W[j]\n\n k = 2\n p += At[Ai] * At[Aj]\n p += At[Ai + 1] * At[Aj + 1]\n\n for (; k < m; k++) { p += At[Ai + k] * At[Aj + k] }\n\n if (Math.abs(p) <= eps * Math.sqrt(a * b)) continue\n\n p *= 2.0\n beta = a - b\n gamma = hypot(p, beta)\n if (beta < 0) {\n delta = (gamma - beta) * 0.5\n s = Math.sqrt(delta / gamma)\n c = (p / (gamma * s * 2.0))\n } else {\n c = Math.sqrt((gamma + beta) / (gamma * 2.0))\n s = (p / (gamma * c * 2.0))\n }\n\n a = 0.0\n b = 0.0\n\n k = 2 // unroll\n t0 = c * At[Ai] + s * At[Aj]\n t1 = -s * At[Ai] + c * At[Aj]\n At[Ai] = t0; At[Aj] = t1\n a += t0 * t0; b += t1 * t1\n\n t0 = c * At[Ai + 1] + s * At[Aj + 1]\n t1 = -s * At[Ai + 1] + c * At[Aj + 1]\n At[Ai + 1] = t0; At[Aj + 1] = t1\n a += t0 * t0; b += t1 * t1\n\n for (; k < m; k++) {\n t0 = c * At[Ai + k] + s * At[Aj + k]\n t1 = -s * At[Ai + k] + c * At[Aj + k]\n At[Ai + k] = t0; At[Aj + k] = t1\n\n a += t0 * t0; b += t1 * t1\n }\n\n W[i] = a\n W[j] = b\n\n changed = 1\n\n if (Vt) {\n Vi = (i * vstep) | 0\n Vj = (j * vstep) | 0\n\n k = 2\n t0 = c * Vt[Vi] + s * Vt[Vj]\n t1 = -s * Vt[Vi] + c * Vt[Vj]\n Vt[Vi] = t0; Vt[Vj] = t1\n\n t0 = c * Vt[Vi + 1] + s * Vt[Vj + 1]\n t1 = -s * Vt[Vi + 1] + c * Vt[Vj + 1]\n Vt[Vi + 1] = t0; Vt[Vj + 1] = t1\n\n for (; k < n; k++) {\n t0 = c * Vt[Vi + k] + s * Vt[Vj + k]\n t1 = -s * Vt[Vi + k] + c * Vt[Vj + k]\n Vt[Vi + k] = t0; Vt[Vj + k] = t1\n }\n }\n }\n }\n if (changed === 0) break\n }\n\n for (i = 0; i < n; i++) {\n for (k = 0, sd = 0; k < m; k++) {\n t = At[i * astep + k]\n sd += t * t\n }\n W[i] = Math.sqrt(sd)\n }\n\n for (i = 0; i < n - 1; i++) {\n j = i\n for (k = i + 1; k < n; k++) {\n if (W[j] < W[k]) { j = k }\n }\n if (i !== j) {\n swap(W, i, j, sd)\n if (Vt) {\n for (k = 0; k < m; k++) {\n swap(At, i * astep + k, j * astep + k, t)\n }\n\n for (k = 0; k < n; k++) {\n swap(Vt, i * vstep + k, j * vstep + k, t)\n }\n }\n }\n }\n\n for (i = 0; i < n; i++) {\n _W[i] = W[i]\n }\n\n if (!Vt) {\n return\n }\n\n for (i = 0; i < n1; i++) {\n sd = i < n ? W[i] : 0\n\n while (sd <= minval) {\n // if we got a zero singular value, then in order to get the corresponding left singular vector\n // we generate a random vector, project it to the previously computed left singular vectors,\n // subtract the projection and normalize the difference.\n val0 = (1.0 / m)\n for (k = 0; k < m; k++) {\n seed = (seed * 214013 + 2531011)\n val = (((seed >> 16) & 0x7fff) & 256) !== 0 ? val0 : -val0\n At[i * astep + k] = val\n }\n for (iter = 0; iter < 2; iter++) {\n for (j = 0; j < i; j++) {\n sd = 0\n for (k = 0; k < m; k++) {\n sd += At[i * astep + k] * At[j * astep + k]\n }\n asum = 0.0\n for (k = 0; k < m; k++) {\n t = (At[i * astep + k] - sd * At[j * astep + k])\n At[i * astep + k] = t\n asum += Math.abs(t)\n }\n asum = asum ? 1.0 / asum : 0\n for (k = 0; k < m; k++) {\n At[i * astep + k] *= asum\n }\n }\n }\n sd = 0\n for (k = 0; k < m; k++) {\n t = At[i * astep + k]\n sd += t * t\n }\n sd = Math.sqrt(sd)\n }\n\n s = (1.0 / sd)\n for (k = 0; k < m; k++) {\n At[i * astep + k] *= s\n }\n }\n}\n\nexport function svd (A: Matrix, W: Matrix, U: Matrix, V: Matrix) {\n let at = 0\n let i = 0\n const _m = A.rows\n const _n = A.cols\n let m = _m\n let n = _n\n\n if (m < n) {\n at = 1\n i = m\n m = n\n n = i\n }\n\n const amt = new Matrix(m, m)\n const wmt = new Matrix(1, n)\n const vmt = new Matrix(n, n)\n\n if (at === 0) {\n transpose(amt, A)\n } else {\n for (i = 0; i < _n * _m; i++) {\n amt.data[i] = A.data[i]\n }\n for (; i < n * m; i++) {\n amt.data[i] = 0\n }\n }\n\n JacobiSVDImpl(amt.data, m, wmt.data, vmt.data, n, m, n, m)\n\n if (W) {\n for (i = 0; i < n; i++) {\n W.data[i] = wmt.data[i]\n }\n for (; i < _n; i++) {\n W.data[i] = 0\n }\n }\n\n if (at === 0) {\n if (U) transpose(U, amt)\n if (V) transpose(V, vmt)\n } else {\n if (U) transpose(U, vmt)\n if (V) transpose(V, amt)\n }\n}\n\n//\n\nexport function m4new () {\n return new Float32Array([\n 1, 0, 0, 0,\n 0, 1, 0, 0,\n 0, 0, 1, 0,\n 0, 0, 0, 1\n ])\n}\n\nexport function m4set (out: Float32Array, n11: number, n12: number, n13: number, n14: number, n21: number, n22: number, n23: number, n24: number, n31: number, n32: number, n33: number, n34: number, n41: number, n42: number, n43: number, n44: number) {\n out[ 0 ] = n11; out[ 4 ] = n12; out[ 8 ] = n13; out[ 12 ] = n14\n out[ 1 ] = n21; out[ 5 ] = n22; out[ 9 ] = n23; out[ 13 ] = n24\n out[ 2 ] = n31; out[ 6 ] = n32; out[ 10 ] = n33; out[ 14 ] = n34\n out[ 3 ] = n41; out[ 7 ] = n42; out[ 11 ] = n43; out[ 15 ] = n44\n}\n\nexport function m4identity (out: Float32Array) {\n m4set(out,\n 1, 0, 0, 0,\n 0, 1, 0, 0,\n 0, 0, 1, 0,\n 0, 0, 0, 1\n )\n}\n(m4identity as any).__deps = [ m4set ]\n\nexport function m4multiply (out: Float32Array, a: Float32Array, b: Float32Array) {\n const a11 = a[ 0 ]\n const a12 = a[ 4 ]\n const a13 = a[ 8 ]\n const a14 = a[ 12 ]\n const a21 = a[ 1 ]\n const a22 = a[ 5 ]\n const a23 = a[ 9 ]\n const a24 = a[ 13 ]\n const a31 = a[ 2 ]\n const a32 = a[ 6 ]\n const a33 = a[ 10 ]\n const a34 = a[ 14 ]\n const a41 = a[ 3 ]\n const a42 = a[ 7 ]\n const a43 = a[ 11 ]\n const a44 = a[ 15 ]\n\n const b11 = b[ 0 ]\n const b12 = b[ 4 ]\n const b13 = b[ 8 ]\n const b14 = b[ 12 ]\n const b21 = b[ 1 ]\n const b22 = b[ 5 ]\n const b23 = b[ 9 ]\n const b24 = b[ 13 ]\n const b31 = b[ 2 ]\n const b32 = b[ 6 ]\n const b33 = b[ 10 ]\n const b34 = b[ 14 ]\n const b41 = b[ 3 ]\n const b42 = b[ 7 ]\n const b43 = b[ 11 ]\n const b44 = b[ 15 ]\n\n out[ 0 ] = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41\n out[ 4 ] = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42\n out[ 8 ] = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43\n out[ 12 ] = a11 * b14 + a12 * b24 + a13 * b34 + a14 * b44\n\n out[ 1 ] = a21 * b11 + a22 * b21 + a23 * b31 + a24 * b41\n out[ 5 ] = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42\n out[ 9 ] = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43\n out[ 13 ] = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44\n\n out[ 2 ] = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41\n out[ 6 ] = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42\n out[ 10 ] = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43\n out[ 14 ] = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44\n\n out[ 3 ] = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41\n out[ 7 ] = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42\n out[ 11 ] = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43\n out[ 15 ] = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44\n}\n\nexport function m4makeScale (out: Float32Array, x: number, y: number, z: number) {\n m4set(out,\n x, 0, 0, 0,\n 0, y, 0, 0,\n 0, 0, z, 0,\n 0, 0, 0, 1\n )\n}\n(m4makeScale as any).__deps = [ m4set ]\n\nexport function m4makeTranslation (out: Float32Array, x: number, y: number, z: number) {\n m4set(out,\n 1, 0, 0, x,\n 0, 1, 0, y,\n 0, 0, 1, z,\n 0, 0, 0, 1\n )\n}\n(m4makeTranslation as any).__deps = [ m4set ]\n\nexport function m4makeRotationY (out: Float32Array, theta: number) {\n const c = Math.cos(theta)\n const s = Math.sin(theta)\n m4set(out,\n c, 0, s, 0,\n 0, 1, 0, 0,\n -s, 0, c, 0,\n 0, 0, 0, 1\n )\n}\n(m4makeRotationY as any).__deps = [ m4set ]\n\n//\n\nexport function m3new () {\n return new Float32Array([\n 1, 0, 0,\n 0, 1, 0,\n 0, 0, 1\n ])\n}\n\nexport function m3makeNormal (out: Float32Array, m4: Float32Array) {\n const r0 = v3new([ m4[0], m4[1], m4[2] ])\n const r1 = v3new([ m4[4], m4[5], m4[6] ])\n const r2 = v3new([ m4[8], m4[9], m4[10] ])\n const cp = v3new()\n // [ r0 ] [ r1 x r2 ]\n // M3x3 = [ r1 ] N = [ r2 x r0 ]\n // [ r2 ] [ r0 x r1 ]\n v3cross(cp, r1, r2)\n out[ 0 ] = cp[ 0 ]\n out[ 1 ] = cp[ 1 ]\n out[ 2 ] = cp[ 2 ]\n v3cross(cp, r2, r0)\n out[ 3 ] = cp[ 0 ]\n out[ 4 ] = cp[ 1 ]\n out[ 5 ] = cp[ 2 ]\n v3cross(cp, r0, r1)\n out[ 6 ] = cp[ 0 ]\n out[ 7 ] = cp[ 1 ]\n out[ 8 ] = cp[ 2 ]\n}\n(m3makeNormal as any).__deps = [ v3new, v3cross ]\n","/**\n * @file Surface Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { degToRad } from '../math/math-utils'\nimport {\n m4new, m4multiply, m4makeTranslation, m4makeScale, m4makeRotationY\n} from '../math/matrix-utils'\nimport {\n v3addScalar, v3subScalar, v3divideScalar, v3multiplyScalar,\n v3floor, v3ceil, v3sub, v3negate,\n v3cross, v3fromArray, normalizeVector3array\n} from '../math/vector-utils'\nimport { NumberArray } from '../types'\n\nfunction laplacianSmooth (verts: Float32Array, faces: Float32Array, numiter: number, inflate: boolean) {\n // based on D. Xu, Y. Zhang (2009) Generating Triangulated Macromolecular\n // Surfaces by Euclidean Distance Transform. PLoS ONE 4(12): e8140.\n //\n // Permission to use, copy, modify, and distribute this program for\n // any purpose, with or without fee, is hereby granted, provided that\n // the notices on the head, the reference information, and this\n // copyright notice appear in all copies or substantial portions of\n // the Software. It is provided \"as is\" without express or implied\n // warranty.\n //\n // ported to JavaScript and adapted to NGL by Alexander Rose\n\n numiter = numiter || 1\n inflate = inflate || true\n\n const nv = verts.length / 3\n const nf = faces.length / 3\n let norms: Float32Array | undefined = undefined\n\n if (inflate) {\n norms = new Float32Array(nv * 3)\n }\n\n const tps = new Float32Array(nv * 3)\n\n let i\n const ndeg = 20\n const vertdeg = new Array(ndeg)\n\n for (i = 0; i < ndeg; ++i) {\n vertdeg[ i ] = new Uint32Array(nv)\n }\n\n for (i = 0; i < nv; ++i) {\n vertdeg[ 0 ][ i ] = 0\n }\n\n let j, jl\n let flagvert: boolean\n\n // for each face\n\n for (i = 0; i < nf; ++i) {\n var ao = i * 3\n var bo = i * 3 + 1\n var co = i * 3 + 2\n\n // vertex a\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ao] ]; j < jl; ++j) {\n if (faces[ bo ] === vertdeg[ j + 1 ][ faces[ ao ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ ao ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ ao ] ] ][ faces[ ao ] ] = faces[ bo ]\n }\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ ao ] ]; j < jl; ++j) {\n if (faces[ co ] === vertdeg[ j + 1 ][ faces[ ao ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ ao ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ ao ] ] ][ faces[ ao ] ] = faces[ co ]\n }\n\n // vertex b\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ bo ] ]; j < jl; ++j) {\n if (faces[ ao ] === vertdeg[ j + 1 ][ faces[ bo ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ bo ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ bo ] ] ][ faces[ bo ] ] = faces[ ao ]\n }\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ bo ] ]; j < jl; ++j) {\n if (faces[ co ] === vertdeg[ j + 1 ][ faces[ bo ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ bo ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ bo ] ] ][ faces[ bo ] ] = faces[ co ]\n }\n\n // vertex c\n\n flagvert = true\n for (j = 0; j < vertdeg[ 0 ][ faces[ co ] ]; ++j) {\n if (faces[ ao ] === vertdeg[ j + 1 ][ faces[ co ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ co ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ co ] ] ][ faces[ co ] ] = faces[ ao ]\n }\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ co ] ]; j < jl; ++j) {\n if (faces[ bo ] === vertdeg[ j + 1 ][ faces[ co ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ co ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ co ] ] ][ faces[ co ] ] = faces[ bo ]\n }\n }\n\n var wt = 1.0\n var wt2 = 0.5\n var i3, vi3, vdi, wtvi, wt2vi\n var ssign = -1\n var scaleFactor = 1\n var outwt = 0.75 / (scaleFactor + 3.5) // area-preserving\n\n // smoothing iterations\n\n for (var k = 0; k < numiter; ++k) {\n // for each vertex\n\n for (i = 0; i < nv; ++i) {\n i3 = i * 3\n vdi = vertdeg[ 0 ][ i ]\n\n if (vdi < 3) {\n tps[ i3 ] = verts[ i3 ]\n tps[ i3 + 1 ] = verts[ i3 + 1 ]\n tps[ i3 + 2 ] = verts[ i3 + 2 ]\n } else if (vdi === 3 || vdi === 4) {\n tps[ i3 ] = 0\n tps[ i3 + 1 ] = 0\n tps[ i3 + 2 ] = 0\n\n for (j = 0; j < vdi; ++j) {\n vi3 = vertdeg[ j + 1 ][ i ] * 3\n tps[ i3 ] += verts[ vi3 ]\n tps[ i3 + 1 ] += verts[ vi3 + 1 ]\n tps[ i3 + 2 ] += verts[ vi3 + 2 ]\n }\n\n tps[ i3 ] += wt2 * verts[ i3 ]\n tps[ i3 + 1 ] += wt2 * verts[ i3 + 1 ]\n tps[ i3 + 2 ] += wt2 * verts[ i3 + 2 ]\n\n wt2vi = wt2 + vdi\n tps[ i3 ] /= wt2vi\n tps[ i3 + 1 ] /= wt2vi\n tps[ i3 + 2 ] /= wt2vi\n } else {\n tps[ i3 ] = 0\n tps[ i3 + 1 ] = 0\n tps[ i3 + 2 ] = 0\n\n for (j = 0; j < vdi; ++j) {\n vi3 = vertdeg[ j + 1 ][ i ] * 3\n tps[ i3 ] += verts[ vi3 ]\n tps[ i3 + 1 ] += verts[ vi3 + 1 ]\n tps[ i3 + 2 ] += verts[ vi3 + 2 ]\n }\n\n tps[ i3 ] += wt * verts[ i3 ]\n tps[ i3 + 1 ] += wt * verts[ i3 + 1 ]\n tps[ i3 + 2 ] += wt * verts[ i3 + 2 ]\n\n wtvi = wt + vdi\n tps[ i3 ] /= wtvi\n tps[ i3 + 1 ] /= wtvi\n tps[ i3 + 2 ] /= wtvi\n }\n }\n\n verts.set(tps) // copy smoothed positions\n\n if (inflate) {\n computeVertexNormals(verts, faces, norms)\n var nv3 = nv * 3\n\n for (i3 = 0; i3 < nv3; i3 += 3) {\n // if(verts[i].inout) ssign=1;\n // else ssign=-1;\n\n verts[ i3 ] += ssign * outwt * norms![ i3 ]\n verts[ i3 + 1 ] += ssign * outwt * norms![ i3 + 1 ]\n verts[ i3 + 2 ] += ssign * outwt * norms![ i3 + 2 ]\n }\n }\n }\n}\nObject.assign(laplacianSmooth, {__deps: [ computeVertexNormals ]})\n\nfunction computeVertexNormals (position: Float32Array, index?: NumberArray, normal?: Float32Array) {\n var i, il\n\n if (normal === undefined) {\n normal = new Float32Array(position.length)\n } else {\n // reset existing normals to zero\n for (i = 0, il = normal.length; i < il; i++) {\n normal[ i ] = 0\n }\n }\n\n var a = new Float32Array(3)\n var b = new Float32Array(3)\n var c = new Float32Array(3)\n var cb = new Float32Array(3)\n var ab = new Float32Array(3)\n\n if (index) {\n // indexed elements\n for (i = 0, il = index.length; i < il; i += 3) {\n var ai = index[ i ] * 3\n var bi = index[ i + 1 ] * 3\n var ci = index[ i + 2 ] * 3\n\n v3fromArray(a, position, ai)\n v3fromArray(b, position, bi)\n v3fromArray(c, position, ci)\n\n v3sub(cb, c, b)\n v3sub(ab, a, b)\n v3cross(cb, cb, ab)\n\n normal[ ai ] += cb[ 0 ]\n normal[ ai + 1 ] += cb[ 1 ]\n normal[ ai + 2 ] += cb[ 2 ]\n\n normal[ bi ] += cb[ 0 ]\n normal[ bi + 1 ] += cb[ 1 ]\n normal[ bi + 2 ] += cb[ 2 ]\n\n normal[ ci ] += cb[ 0 ]\n normal[ ci + 1 ] += cb[ 1 ]\n normal[ ci + 2 ] += cb[ 2 ]\n }\n } else {\n // non-indexed elements (unconnected triangle soup)\n for (i = 0, il = position.length; i < il; i += 9) {\n v3fromArray(a, position, i)\n v3fromArray(b, position, i + 3)\n v3fromArray(c, position, i + 6)\n\n v3sub(cb, c, b)\n v3sub(ab, a, b)\n v3cross(cb, cb, ab)\n\n normal[ i ] = cb[ 0 ]\n normal[ i + 1 ] = cb[ 1 ]\n normal[ i + 2 ] = cb[ 2 ]\n\n normal[ i + 3 ] = cb[ 0 ]\n normal[ i + 4 ] = cb[ 1 ]\n normal[ i + 5 ] = cb[ 2 ]\n\n normal[ i + 6 ] = cb[ 0 ]\n normal[ i + 7 ] = cb[ 1 ]\n normal[ i + 8 ] = cb[ 2 ]\n }\n }\n\n normalizeVector3array(normal)\n\n return normal\n}\nObject.assign(computeVertexNormals, {__deps: [\n v3sub, v3cross, v3fromArray, normalizeVector3array\n]})\n\nfunction getRadiusDict (radiusList: number[]) {\n var radiusDict: {[k: number]: boolean} = {}\n for (var i = 0, il = radiusList.length; i < il; ++i) {\n radiusDict[ radiusList[ i ] ] = true\n }\n return radiusDict\n}\n\nfunction getSurfaceGrid (min: Float32Array, max: Float32Array, maxRadius: number, scaleFactor: number, extraMargin: number) {\n // need margin to avoid boundary/round off effects\n var margin = (1 / scaleFactor) * 3\n margin += maxRadius\n\n v3subScalar(min, min, extraMargin + margin)\n v3addScalar(max, max, extraMargin + margin)\n\n v3multiplyScalar(min, min, scaleFactor)\n v3floor(min, min)\n v3divideScalar(min, min, scaleFactor)\n\n v3multiplyScalar(max, max, scaleFactor)\n v3ceil(max, max)\n v3divideScalar(max, max, scaleFactor)\n\n var dim = new Float32Array(3)\n v3sub(dim, max, min)\n v3multiplyScalar(dim, dim, scaleFactor)\n v3ceil(dim, dim)\n v3addScalar(dim, dim, 1)\n\n var maxSize = Math.pow(10, 6) * 256\n var tmpSize = dim[ 0 ] * dim[ 1 ] * dim[ 2 ] * 3\n\n if (maxSize <= tmpSize) {\n scaleFactor *= Math.pow(maxSize / tmpSize, 1 / 3)\n\n v3multiplyScalar(min, min, scaleFactor)\n v3floor(min, min)\n v3divideScalar(min, min, scaleFactor)\n\n v3multiplyScalar(max, max, scaleFactor)\n v3ceil(max, max)\n v3divideScalar(max, max, scaleFactor)\n\n v3sub(dim, max, min)\n v3multiplyScalar(dim, dim, scaleFactor)\n v3ceil(dim, dim)\n v3addScalar(dim, dim, 1)\n }\n\n var tran = new Float32Array(min)\n v3negate(tran, tran)\n\n // coordinate transformation matrix\n var matrix = m4new()\n var mroty = m4new()\n m4makeRotationY(mroty, degToRad(90))\n m4multiply(matrix, matrix, mroty)\n\n var mscale = m4new()\n m4makeScale(\n mscale,\n -1 / scaleFactor,\n 1 / scaleFactor,\n 1 / scaleFactor\n )\n m4multiply(matrix, matrix, mscale)\n\n var mtrans = m4new()\n m4makeTranslation(\n mtrans,\n -scaleFactor * tran[2],\n -scaleFactor * tran[1],\n -scaleFactor * tran[0]\n )\n m4multiply(matrix, matrix, mtrans)\n\n return {\n dim: dim,\n tran: tran,\n matrix: matrix,\n scaleFactor: scaleFactor\n }\n}\nObject.assign(getSurfaceGrid, {__deps: [\n degToRad,\n v3subScalar, v3addScalar, v3divideScalar, v3multiplyScalar,\n v3floor, v3ceil, v3sub, v3negate,\n m4new, m4multiply, m4makeTranslation, m4makeScale, m4makeRotationY\n]})\n\nexport {\n laplacianSmooth,\n computeVertexNormals,\n getRadiusDict,\n getSurfaceGrid\n}\n","/**\n * @file Surface\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3, Geometry, BufferGeometry, Group, Color } from 'three'\n\nimport { Debug, Log, ColormakerRegistry } from '../globals'\nimport { getUintArray } from '../utils'\nimport { AtomPicker, SurfacePicker } from '../utils/picker'\nimport { uniformArray, uniformArray3, serialArray } from '../math/array-utils'\nimport Selection from '../selection/selection'\nimport { ColormakerParameters } from '../color/colormaker';\nimport { Structure, Volume } from '../ngl';\n\nexport interface SurfaceData {\n position: Float32Array\n index: Uint32Array|Uint16Array|undefined\n normal: Float32Array\n color: Float32Array\n atomindex: Int32Array\n contour: boolean\n}\n/**\n * Surface\n */\nclass Surface {\n name: string\n path: string\n position: Float32Array\n index: Uint32Array|Uint16Array|undefined\n normal: Float32Array|undefined\n color: Float32Array|undefined\n atomindex: Int32Array|undefined\n contour: boolean\n center: Vector3\n boundingBox: Box3\n size: number\n info: {\n type?: string\n probeRadius?: number\n scaleFactor?: number\n smooth?: number\n cutoff?: number\n isolevel?: number\n volume?: Volume\n }\n\n /**\n * @param {String} name - surface name\n * @param {String} path - source path\n * @param {Object} data - surface data\n * @param {Float32Array} data.position - surface positions\n * @param {Int32Array} data.index - surface indices\n * @param {Float32Array} data.normal - surface normals\n * @param {Float32Array} data.color - surface colors\n * @param {Int32Array} data.atomindex - atom indices\n * @param {boolean} data.contour - contour mode flag\n */\n constructor (name: string, path: string, data?: SurfaceData) {\n this.name = name || ''\n this.path = path || ''\n this.info = {}\n\n this.center = new Vector3()\n this.boundingBox = new Box3()\n\n if (data instanceof Geometry ||\n data instanceof BufferGeometry ||\n data instanceof Group\n ) {\n // to be removed\n this.fromGeometry(data)\n } else if (data) {\n this.set(\n data.position,\n data.index,\n data.normal,\n data.color,\n data.atomindex,\n data.contour\n )\n\n this.boundingBox.setFromArray(data.position)\n this.boundingBox.getCenter(this.center)\n }\n }\n\n get type () { return 'Surface' }\n\n /**\n * set surface data\n * @param {Float32Array} position - surface positions\n * @param {Int32Array} index - surface indices\n * @param {Float32Array} normal - surface normals\n * @param {Float32Array} color - surface colors\n * @param {Int32Array} atomindex - atom indices\n * @param {boolean} contour - contour mode flag\n * @return {undefined}\n */\n set (position: Float32Array,\n index: Uint32Array|Uint16Array|undefined,\n normal: Float32Array|undefined,\n color: Float32Array|undefined,\n atomindex: Int32Array|undefined,\n contour: boolean = false) {\n /**\n * @type {Float32Array}\n */\n this.position = position\n /**\n * @type {Uint32Array|Uint16Array|undefined}\n */\n this.index = index\n /**\n * @type {Float32Array|undefined}\n */\n this.normal = normal\n /**\n * @type {Float32Array|undefined}\n */\n this.color = color\n /**\n * @type {Int32Array|undefined}\n */\n this.atomindex = atomindex\n\n this.size = position.length / 3\n this.contour = contour\n }\n\n fromGeometry (geometry: Geometry|BufferGeometry|Group) {\n if (Debug) Log.time('GeometrySurface.fromGeometry')\n\n let geo\n\n if (geometry instanceof Geometry) {\n geometry.computeVertexNormals(true)\n geo = new BufferGeometry().fromGeometry(geometry)\n } else if (geometry instanceof BufferGeometry) {\n geo = geometry\n } else {\n geo = (geometry as any)[ 0 ]\n }\n\n if (!geo.boundingBox) geo.computeBoundingBox()\n\n this.boundingBox.copy(geo.boundingBox)\n this.boundingBox.getCenter(this.center)\n\n let position, color, index, normal\n\n if (geo instanceof BufferGeometry) {\n const attr = geo.attributes\n const an = (attr as any).normal ? (attr as any).normal.array : false\n\n // assume there are no normals if the first is zero\n if (!an || (an[ 0 ] === 0 && an[ 1 ] === 0 && an[ 2 ] === 0)) {\n geo.computeVertexNormals()\n }\n\n position = (attr).position.array\n index = (attr).index ? (attr).index.array : null\n normal = (attr).normal.array\n }\n\n this.set(position, index, normal, color, undefined)\n\n if (Debug) Log.timeEnd('GeometrySurface.setGeometry')\n }\n\n getPosition () {\n return this.position\n }\n\n getColor (params: ColormakerParameters&{ scheme: string}) {\n const p = params || {}\n p.surface = this\n\n const n = this.size\n const array = new Float32Array(n * 3)\n const colormaker = ColormakerRegistry.getScheme(p)\n\n if (colormaker.volumeColor || p.scheme === 'random') {\n for (let i = 0; i < n; ++i) {\n colormaker.volumeColorToArray(i, array, i * 3)\n }\n } else if (colormaker.positionColor) {\n const v = new Vector3()\n const pos = this.position\n\n for (let i = 0; i < n; ++i) {\n var i3 = i * 3\n v.set(pos[ i3 ], pos[ i3 + 1 ], pos[ i3 + 2 ])\n colormaker.positionColorToArray(v, array, i3)\n }\n } else if (colormaker.atomColor && this.atomindex) {\n const atomProxy = p.structure!.getAtomProxy()\n const atomindex = this.atomindex\n\n for (let i = 0; i < n; ++i) {\n atomProxy.index = atomindex[ i ]\n colormaker.atomColorToArray(atomProxy, array, i * 3)\n }\n } else {\n const tc = new Color(p.value)\n uniformArray3(n, tc.r, tc.g, tc.b, array)\n }\n\n return array\n }\n\n getPicking (structure?: Structure) {\n if (this.atomindex && structure) {\n return new AtomPicker(this.atomindex as any, structure)\n } else {\n return new SurfacePicker(serialArray(this.size), this)\n }\n }\n\n getNormal () {\n return this.normal\n }\n\n getSize (size: number, scale: number) {\n return uniformArray(this.size, size * scale)\n }\n\n getIndex () {\n return this.index\n }\n\n getFilteredIndex (sele: string, structure: Structure) {\n if (sele && this.atomindex) {\n const selection = new Selection(sele)\n const atomSet = structure.getAtomSet(selection)\n const filteredIndex = []\n\n const atomindex = this.atomindex\n const index = this.index\n const n = index!.length\n const elementSize = this.contour ? 2 : 3\n\n let j = 0\n\n for (let i = 0; i < n; i += elementSize) {\n let include = true\n\n for (let a = 0; a < elementSize; a++) {\n const idx = index![ i + a ]\n const ai = atomindex[ idx ]\n if (!atomSet.get(ai)) {\n include = false\n break\n }\n }\n\n if (!include) { continue }\n\n for (let a = 0; a < elementSize; a++, j++) {\n filteredIndex[ j ] = index![ i + a ]\n }\n }\n\n return getUintArray(filteredIndex, this.position.length / 3)\n } else {\n return this.index\n }\n }\n\n getAtomindex () {\n return this.atomindex\n }\n\n dispose () {\n\n //\n\n }\n}\n\nexport default Surface\n","/**\n * @file Volume\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3, Matrix3, Matrix4 } from 'three'\n\nimport { WorkerRegistry, ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport WorkerPool from '../worker/worker-pool'\nimport { VolumePicker } from '../utils/picker'\nimport {\n uniformArray, serialArray,\n arrayMin, arrayMax, arraySum, arrayMean, arrayRms\n} from '../math/array-utils'\nimport MarchingCubes from './marching-cubes'\nimport { laplacianSmooth, computeVertexNormals } from './surface-utils'\nimport {\n applyMatrix4toVector3array, applyMatrix3toVector3array\n} from '../math/vector-utils'\nimport { m3new, m3makeNormal } from '../math/matrix-utils'\nimport Surface from './surface'\nimport { NumberArray } from '../types';\nimport { ColormakerParameters } from '../color/colormaker';\n\nexport interface VolumeSurface {\n new (data: NumberArray, nx: number, ny: number, nz: number, atomindex: NumberArray): void\n getSurface: (isolevel: number, smooth: boolean|number, box: number[][]|undefined, matrix: Float32Array, contour: boolean, wrap?: boolean) => {\n position: Float32Array\n normal: undefined|Float32Array\n index: Uint32Array|Uint16Array\n atomindex: Int32Array|undefined\n contour: boolean\n }\n}\nexport function VolumeSurface (this: VolumeSurface,data: NumberArray, nx: number, ny: number, nz: number, atomindex: NumberArray) {\n var mc = new (MarchingCubes as any)(data, nx, ny, nz, atomindex) as MarchingCubes\n\n function getSurface (isolevel: number, smooth: boolean|number, box: number[][]|undefined, matrix: Float32Array, contour: boolean, wrap: boolean = false) {\n const sd = mc.triangulate(isolevel, smooth as boolean, box, contour, wrap)\n if (smooth && !contour) {\n laplacianSmooth(sd.position, sd.index as any, smooth as number, true)\n sd.normal = computeVertexNormals(sd.position, sd.index as any)\n }\n if (matrix) {\n applyMatrix4toVector3array(matrix, sd.position)\n if (sd.normal) {\n const normalMatrix = m3new()\n m3makeNormal(normalMatrix, matrix)\n applyMatrix3toVector3array(normalMatrix, sd.normal)\n }\n }\n return sd\n }\n\n this.getSurface = getSurface\n}\nObject.assign(VolumeSurface, {__deps: [\n laplacianSmooth, computeVertexNormals, MarchingCubes,\n applyMatrix4toVector3array, applyMatrix3toVector3array,\n m3new, m3makeNormal\n]})\n\nWorkerRegistry.add('surf', function func (e: any, callback: (data: any, transferList: any) => void) {\n const a = e.data.args\n const p = e.data.params\n if (a) {\n /* global self */\n (self as any).volsurf = new (VolumeSurface as any)(a[0], a[1], a[2], a[3], a[4]) as VolumeSurface\n }\n if (p) {\n const sd = ((self as any).volsurf as VolumeSurface).getSurface(\n p.isolevel, p.smooth, p.box, p.matrix, p.contour, p.wrap\n )\n const transferList = [ sd.position.buffer, sd.index.buffer ]\n if (sd.normal) transferList.push(sd.normal.buffer)\n if (sd.atomindex) transferList.push(sd.atomindex.buffer)\n const data = {\n sd: sd,\n p: p\n }\n callback(data, transferList)\n }\n}, [ VolumeSurface ])\n\nexport type VolumeSize = 'value'|'abs-value'|'value-min'|'deviation'\n/**\n * Volume\n */\nclass Volume {\n name: string\n path: string\n\n matrix: Matrix4\n normalMatrix: Matrix3\n inverseMatrix: Matrix4\n center: Vector3\n boundingBox: Box3\n\n nx: number\n ny: number\n nz: number\n data: Float32Array\n\n worker: Worker\n workerPool: WorkerPool\n _position: Float32Array\n _min: number|undefined\n _max: number|undefined\n _mean: number|undefined\n _rms: number|undefined\n _sum: number|undefined\n __box: Box3|undefined\n\n atomindex: Int32Array|undefined\n volsurf: VolumeSurface|undefined\n header: any\n /**\n * Make Volume instance\n * @param {String} name - volume name\n * @param {String} path - source path\n * @param {Float32array} data - volume 3d grid\n * @param {Integer} nx - x dimension of the 3d volume\n * @param {Integer} ny - y dimension of the 3d volume\n * @param {Integer} nz - z dimension of the 3d volume\n * @param {Int32Array} atomindex - atom indices corresponding to the cells in the 3d grid\n */\n constructor (name: string, path: string, data?: Float32Array, nx?: number, ny?: number, nz?: number, atomindex?: Int32Array) {\n this.name = name\n this.path = path\n\n this.matrix = new Matrix4()\n this.normalMatrix = new Matrix3()\n this.inverseMatrix = new Matrix4()\n this.center = new Vector3()\n this.boundingBox = new Box3()\n\n this.setData(data, nx, ny, nz, atomindex)\n }\n\n get type () { return 'Volume' }\n\n /**\n * set volume data\n * @param {Float32array} data - volume 3d grid\n * @param {Integer} nx - x dimension of the 3d volume\n * @param {Integer} ny - y dimension of the 3d volume\n * @param {Integer} nz - z dimension of the 3d volume\n * @param {Int32Array} atomindex - atom indices corresponding to the cells in the 3d grid\n * @return {undefined}\n */\n setData (data?: Float32Array, nx?: number, ny?: number, nz?: number, atomindex?: Int32Array) {\n this.nx = nx || 1\n this.ny = ny || 1\n this.nz = nz || 1\n\n this.data = data || new Float32Array(1)\n this.setAtomindex(atomindex)\n\n this._position = new Float32Array()\n\n delete this._min\n delete this._max\n delete this._mean\n delete this._rms\n\n if (this.worker) this.worker.terminate()\n }\n\n /**\n * Set statistics, which can be different from the data in this volume,\n * if this volume is a slice of a bigger volume\n * @param {Number|undefined} min - minimum value of the whole data set\n * @param {Number|undefined} max - maximum value of the whole data set\n * @param {Number|undefined} mean - average value of the whole data set\n * @param {Number|undefined} rms - sigma value of the whole data set\n */\n setStats (min: number|undefined, max: number|undefined, mean: number|undefined, rms: number|undefined) {\n this._min = min\n this._max = max\n this._mean = mean\n this._rms = rms\n }\n\n /**\n * set transformation matrix\n * @param {Matrix4} matrix - 4x4 transformation matrix\n * @return {undefined}\n */\n setMatrix (matrix: Matrix4) {\n this.matrix.copy(matrix)\n\n const bb = this.boundingBox\n const v = this.center // temporary re-purposing\n\n const x = this.nx - 1\n const y = this.ny - 1\n const z = this.nz - 1\n\n bb.makeEmpty()\n\n bb.expandByPoint(v.set(x, y, z))\n bb.expandByPoint(v.set(x, y, 0))\n bb.expandByPoint(v.set(x, 0, z))\n bb.expandByPoint(v.set(x, 0, 0))\n bb.expandByPoint(v.set(0, y, z))\n bb.expandByPoint(v.set(0, 0, z))\n bb.expandByPoint(v.set(0, y, 0))\n bb.expandByPoint(v.set(0, 0, 0))\n\n bb.applyMatrix4(this.matrix)\n bb.getCenter(this.center)\n\n // make normal matrix\n\n const me = this.matrix.elements\n const r0 = new Vector3(me[0], me[1], me[2])\n const r1 = new Vector3(me[4], me[5], me[6])\n const r2 = new Vector3(me[8], me[9], me[10])\n const cp = new Vector3()\n // [ r0 ] [ r1 x r2 ]\n // M3x3 = [ r1 ] N = [ r2 x r0 ]\n // [ r2 ] [ r0 x r1 ]\n const ne = this.normalMatrix.elements\n cp.crossVectors(r1, r2)\n ne[ 0 ] = cp.x\n ne[ 1 ] = cp.y\n ne[ 2 ] = cp.z\n cp.crossVectors(r2, r0)\n ne[ 3 ] = cp.x\n ne[ 4 ] = cp.y\n ne[ 5 ] = cp.z\n cp.crossVectors(r0, r1)\n ne[ 6 ] = cp.x\n ne[ 7 ] = cp.y\n ne[ 8 ] = cp.z\n\n this.inverseMatrix.getInverse(this.matrix)\n }\n\n /**\n * set atom indices\n * @param {Int32Array} atomindex - atom indices corresponding to the cells in the 3d grid\n * @return {undefined}\n */\n setAtomindex (atomindex?: Int32Array) {\n this.atomindex = atomindex\n }\n\n getBox (center: Vector3, size: number, target: Box3) {\n if (!target) target = new Box3()\n\n target.set(center, center)\n target.expandByScalar(size)\n target.applyMatrix4(this.inverseMatrix)\n\n target.min.round()\n target.max.round()\n\n return target\n }\n\n _getBox (center: Vector3|undefined, size: number) {\n if (!center || !size) return\n\n if (!this.__box) this.__box = new Box3()\n const box = this.getBox(center, size, this.__box)\n return [ box.min.toArray(), box.max.toArray() ]\n }\n\n _makeSurface (sd: any, isolevel: number, smooth: number) {\n const name = this.name + '@' + isolevel.toPrecision(2)\n const surface = new Surface(name, '', sd)\n surface.info.isolevel = isolevel\n surface.info.smooth = smooth\n surface.info.volume = this\n\n return surface\n }\n\n getSurface (isolevel: number, smooth: number, center: Vector3, size: number, contour: boolean, wrap: boolean = false) {\n isolevel = isNaN(isolevel) ? this.getValueForSigma(2) : isolevel\n smooth = defaults(smooth, 0)\n\n //\n\n if (this.volsurf === undefined) {\n this.volsurf = new (VolumeSurface as any)(\n this.data, this.nx, this.ny, this.nz, this.atomindex\n ) as VolumeSurface\n }\n\n const box = this._getBox(center, size)\n const sd = this.volsurf.getSurface(\n isolevel, smooth, box!, this.matrix.elements as unknown as Float32Array, contour, wrap\n )\n\n return this._makeSurface(sd, isolevel, smooth)\n }\n\n getSurfaceWorker (isolevel: number, smooth: number, center: Vector3, size: number, contour: boolean, wrap: boolean, callback: (s: Surface) => void) {\n isolevel = isNaN(isolevel) ? this.getValueForSigma(2) : isolevel\n smooth = smooth || 0\n\n //\n\n if (window.hasOwnProperty('Worker')) {\n if (this.workerPool === undefined) {\n this.workerPool = new WorkerPool('surf', 2)\n }\n\n const msg = {}\n const worker = this.workerPool.getNextWorker()\n\n if (worker!.postCount === 0) {\n Object.assign(msg, {\n args: [\n this.data, this.nx, this.ny, this.nz, this.atomindex\n ]\n })\n }\n\n Object.assign(msg, {\n params: {\n isolevel: isolevel,\n smooth: smooth,\n box: this._getBox(center, size),\n matrix: this.matrix.elements,\n contour: contour,\n wrap: wrap\n }\n })\n\n worker!.post(msg, undefined,\n (e: any) => {\n const sd = e.data.sd\n const p = e.data.p\n callback(this._makeSurface(sd, p.isolevel, p.smooth))\n },\n (e : string) => {\n console.warn(\n 'Volume.getSurfaceWorker error - trying without worker', e\n )\n const surface = this.getSurface(isolevel, smooth, center, size, contour, wrap)\n callback(surface)\n }\n )\n } else {\n const surface = this.getSurface(isolevel, smooth, center, size, contour, wrap)\n callback(surface)\n }\n }\n\n getValueForSigma (sigma: number) {\n return this.mean + defaults(sigma, 2) * this.rms\n }\n\n getSigmaForValue (value: number) {\n return (defaults(value, 0) - this.mean) / this.rms\n }\n\n get position () {\n if (!this._position) {\n const nz = this.nz\n const ny = this.ny\n const nx = this.nx\n const position = new Float32Array(nx * ny * nz * 3)\n\n let p = 0\n for (let z = 0; z < nz; ++z) {\n for (let y = 0; y < ny; ++y) {\n for (let x = 0; x < nx; ++x) {\n position[ p + 0 ] = x\n position[ p + 1 ] = y\n position[ p + 2 ] = z\n p += 3\n }\n }\n }\n\n applyMatrix4toVector3array(this.matrix.elements as unknown as Float32Array, position)\n this._position = position\n }\n\n return this._position\n }\n\n getDataAtomindex () {\n return this.atomindex\n }\n\n getDataPosition () {\n return this.position\n }\n\n getDataColor (params: ColormakerParameters & {scheme: string}) {\n const p = params || {}\n p.volume = this\n p.scale = p.scale || 'Spectral'\n p.domain = p.domain || [ this.min, this.max ]\n\n const colormaker = ColormakerRegistry.getScheme(p)\n\n const n = this.position.length / 3\n const array = new Float32Array(n * 3)\n\n // var atoms = p.structure.atoms;\n // var atomindex = this.atomindex;\n\n for (let i = 0; i < n; ++i) {\n colormaker.volumeColorToArray(i, array, i * 3)\n // a = atoms[ atomindex[ i ] ];\n // if( a ) colormaker.atomColorToArray( a, array, i * 3 );\n }\n\n return array\n }\n\n getDataPicking () {\n const picking = serialArray(this.position.length / 3)\n return new VolumePicker(picking, this)\n }\n\n getDataSize (size: VolumeSize|number, scale: number) {\n const data = this.data\n const n = this.position.length / 3\n let array\n\n switch (size) {\n case 'value':\n array = new Float32Array(data)\n break\n\n case 'abs-value':\n array = new Float32Array(data)\n for (let i = 0; i < n; ++i) {\n array[ i ] = Math.abs(array[ i ])\n }\n break\n\n case 'value-min': {\n array = new Float32Array(data)\n const min = this.min\n for (let i = 0; i < n; ++i) {\n array[ i ] -= min\n }\n break\n }\n\n case 'deviation':\n array = new Float32Array(data)\n break\n\n default:\n array = uniformArray(n, size)\n break\n }\n\n if (scale !== 1.0) {\n for (let i = 0; i < n; ++i) {\n array[ i ] *= scale\n }\n }\n\n return array\n }\n\n get min () {\n if (this._min === undefined) {\n this._min = arrayMin(this.data)\n }\n return this._min\n }\n\n get max () {\n if (this._max === undefined) {\n this._max = arrayMax(this.data)\n }\n return this._max\n }\n\n get sum () {\n if (this._sum === undefined) {\n this._sum = arraySum(this.data)\n }\n return this._sum\n }\n\n get mean () {\n if (this._mean === undefined) {\n this._mean = arrayMean(this.data)\n }\n return this._mean\n }\n\n get rms () {\n if (this._rms === undefined) {\n this._rms = arrayRms(this.data)\n }\n return this._rms\n }\n\n clone () {\n const vol = new Volume(\n this.name,\n this.path,\n\n this.data,\n\n this.nx,\n this.ny,\n this.nz,\n\n this.atomindex\n )\n\n vol.matrix.copy(this.matrix)\n vol.header = Object.assign({}, this.header)\n\n return vol\n }\n\n dispose () {\n if (this.workerPool) this.workerPool.terminate()\n }\n}\n\nexport default Volume\n","/**\n * @file Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport {\n Color, Vector3, Matrix4,\n FrontSide, BackSide, DoubleSide,\n // VertexColors,\n NoBlending,\n BufferGeometry, BufferAttribute,\n UniformsUtils, UniformsLib, Uniform,\n Group, LineSegments, Points, Mesh, Object3D,\n ShaderMaterial\n} from 'three'\n\nimport { Log } from '../globals'\nimport { createParams, getTypedArray, getUintArray } from '../utils'\nimport { GenericColor, NumberArray } from '../types'\nimport { getShader, ShaderDefines } from '../shader/shader-utils'\nimport { serialArray } from '../math/array-utils'\nimport { Picker } from '../utils/picker'\n\nexport type BufferSide = 'front'|'back'|'double'\n\nfunction getThreeSide (side: BufferSide) {\n if (side === 'front') {\n return FrontSide\n } else if (side === 'back') {\n return BackSide\n } else if (side === 'double') {\n return DoubleSide\n } else {\n return DoubleSide\n }\n}\n\nconst itemSize = {\n 'f': 1, 'v2': 2, 'v3': 3, 'c': 3\n}\n\nfunction setObjectMatrix (object: Object3D, matrix: Matrix4) {\n object.matrix.copy(matrix)\n object.matrix.decompose(object.position, object.quaternion, object.scale)\n object.matrixWorldNeedsUpdate = true\n}\n\nexport type BufferTypes = 'picking'|'background'\nexport type BufferMaterials = 'material'|'wireframeMaterial'|'pickingMaterial'\n\nexport interface _BufferAttribute {\n type: 'f'|'v2'|'v3'|'c'\n value?: NumberArray\n}\n\nexport type Uniforms = { [k: string]: Uniform|{ value: any } }\n\nexport const BufferDefaultParameters = {\n opaqueBack: false,\n side: 'double' as BufferSide, // which triangle sides to render\n opacity: 1.0, // translucency: 1 is fully opaque, 0 is fully transparent\n depthWrite: true,\n clipNear: 0, // position of camera near/front clipping plane in percent of scene bounding box\n clipRadius: 0,\n clipCenter: new Vector3(),\n flatShaded: false, // render flat shaded\n wireframe: false, // render as wireframe\n roughness: 0.4, // how rough the material is, between 0 and 1\n metalness: 0.0, // how metallic the material is, between 0 and 1\n diffuse: 0xffffff, // diffuse color for lighting\n diffuseInterior: false,\n useInteriorColor: false, // render back-side with interior color\n interiorColor: 0xdddddd, // interior color\n interiorDarkening: 0, // interior darkening factor\n forceTransparent: false, // force the material to allow transparency\n matrix: new Matrix4(), // additional transformation matrix\n disablePicking: false, // disable picking\n sortParticles: false,\n background: false\n}\nexport type BufferParameters = Omit & { diffuse: GenericColor; interiorColor: GenericColor }\n\nexport const BufferParameterTypes = {\n opaqueBack: { updateShader: true },\n side: { updateShader: true, property: true },\n opacity: { uniform: true },\n depthWrite: { property: true },\n clipNear: { updateShader: true, property: true },\n clipRadius: { updateShader: true, uniform: true },\n clipCenter: { uniform: true },\n flatShaded: { updateShader: true },\n background: { updateShader: true },\n wireframe: { updateVisibility: true },\n roughness: { uniform: true },\n metalness: { uniform: true },\n diffuse: { uniform: true },\n diffuseInterior: { updateShader: true },\n useInteriorColor: { updateShader: true },\n interiorColor: { uniform: true },\n interiorDarkening: { uniform: true },\n matrix: {}\n}\n\nexport interface BufferData {\n position?: Float32Array\n position1?: Float32Array // TODO\n color?: Float32Array\n index?: Uint32Array|Uint16Array\n normal?: Float32Array\n\n picking?: Picker\n primitiveId?: Float32Array\n}\n\n/**\n * Buffer class. Base class for buffers.\n * @interface\n */\nclass Buffer {\n parameterTypes = BufferParameterTypes\n get defaultParameters() { return BufferDefaultParameters }\n parameters: BufferParameters\n uniforms: Uniforms\n pickingUniforms: Uniforms\n\n private _positionDataSize: number\n\n geometry = new BufferGeometry()\n indexVersion = 0\n wireframeIndexVersion = -1\n group = new Group()\n wireframeGroup = new Group()\n pickingGroup = new Group()\n\n vertexShader = ''\n fragmentShader = ''\n isImpostor = false\n isText = false\n isSurface = false\n isPoint = false\n isLine = false\n dynamic = true\n visible = true\n\n picking?: Picker\n\n material: ShaderMaterial\n wireframeMaterial: ShaderMaterial\n pickingMaterial: ShaderMaterial\n\n wireframeIndex?: Uint32Array|Uint16Array\n wireframeIndexCount = 0\n wireframeGeometry?: BufferGeometry\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Uint32Array|Uint16Array} data.index - triangle indices\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} params - parameters object\n */\n constructor (data: BufferData, params: Partial = {}) {\n this.parameters = createParams(params, this.defaultParameters)\n\n this.uniforms = UniformsUtils.merge([\n UniformsLib.common,\n {\n fogColor: { value: new Color(0x000000) },\n fogNear: { value: 0.0 },\n fogFar: { value: 0.0 },\n opacity: { value: this.parameters.opacity },\n clipNear: { value: 0.0 },\n clipRadius: { value: this.parameters.clipRadius },\n clipCenter: { value: this.parameters.clipCenter }\n },\n {\n emissive: { value: new Color(0x000000) },\n roughness: { value: this.parameters.roughness },\n metalness: { value: this.parameters.metalness },\n interiorColor: { value: new Color(this.parameters.interiorColor) },\n interiorDarkening: { value: this.parameters.interiorDarkening },\n },\n UniformsLib.lights\n ])\n\n this.uniforms.diffuse.value.set(this.parameters.diffuse)\n\n this.pickingUniforms = {\n clipNear: { value: 0.0 },\n objectId: { value: 0 },\n opacity: { value: this.parameters.opacity }\n }\n\n //\n\n const position = data.position || data.position1\n this._positionDataSize = position ? position.length / 3 : 0\n\n if (!data.primitiveId) {\n data.primitiveId = serialArray(this._positionDataSize)\n }\n\n this.addAttributes({\n position: { type: 'v3', value: data.position },\n color: { type: 'c', value: data.color },\n primitiveId: { type: 'f', value: data.primitiveId }\n })\n\n if (params.matrix) {\n this.matrix = params.matrix\n }\n\n if (data.index) {\n this.initIndex(data.index)\n }\n this.picking = data.picking\n\n this.makeWireframeGeometry()\n }\n\n set matrix (m) {\n this.setMatrix(m)\n }\n get matrix () {\n return this.group.matrix.clone()\n }\n\n get transparent () {\n return this.parameters.opacity < 1 || this.parameters.forceTransparent\n }\n\n get size () {\n return this._positionDataSize\n }\n\n get attributeSize () {\n return this.size\n }\n\n get pickable () {\n return !!this.picking && !this.parameters.disablePicking\n }\n\n setMatrix (m: Matrix4) {\n setObjectMatrix(this.group, m)\n setObjectMatrix(this.wireframeGroup, m)\n setObjectMatrix(this.pickingGroup, m)\n }\n\n initIndex (index: Uint32Array|Uint16Array) {\n this.geometry.setIndex(\n new BufferAttribute(index, 1)\n )\n const nindex = this.geometry.getIndex();\n if (!nindex) { Log.error('Index is null'); return; }\n nindex.setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n }\n\n makeMaterial () {\n const side = getThreeSide(this.parameters.side)\n\n const m = new ShaderMaterial({\n uniforms: this.uniforms,\n vertexShader: '',\n fragmentShader: '',\n depthTest: true,\n transparent: this.transparent,\n depthWrite: this.parameters.depthWrite,\n lights: true,\n fog: true,\n side: side\n })\n m.vertexColors = true\n m.extensions.derivatives = true\n m.extensions.fragDepth = this.isImpostor\n\n const wm = new ShaderMaterial({\n uniforms: this.uniforms,\n vertexShader: '',\n fragmentShader: '',\n depthTest: true,\n transparent: this.transparent,\n depthWrite: this.parameters.depthWrite,\n lights: false,\n fog: true,\n side: side\n })\n wm.vertexColors = true\n\n const pm = new ShaderMaterial({\n uniforms: this.pickingUniforms,\n vertexShader: '',\n fragmentShader: '',\n depthTest: true,\n transparent: false,\n depthWrite: this.parameters.depthWrite,\n lights: false,\n fog: false,\n side: side,\n blending: NoBlending\n })\n pm.vertexColors = true\n pm.extensions.fragDepth = this.isImpostor\n\n ;(m as any).clipNear = this.parameters.clipNear\n ;(wm as any).clipNear = this.parameters.clipNear\n ;(pm as any).clipNear = this.parameters.clipNear\n\n this.material = m\n this.wireframeMaterial = wm\n this.pickingMaterial = pm\n\n // also sets vertexShader/fragmentShader\n this.updateShader()\n }\n\n makeWireframeGeometry () {\n this.makeWireframeIndex()\n\n const geometry = this.geometry\n const wireframeIndex = this.wireframeIndex\n const wireframeGeometry = new BufferGeometry()\n\n wireframeGeometry.attributes = geometry.attributes\n if (wireframeIndex) {\n wireframeGeometry.setIndex(\n new BufferAttribute(wireframeIndex, 1).setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n wireframeGeometry.setDrawRange(0, this.wireframeIndexCount)\n }\n\n this.wireframeGeometry = wireframeGeometry\n }\n\n makeWireframeIndex () {\n const edges: number[][] = []\n\n function checkEdge (a: number, b: number) {\n if (a > b) {\n const tmp = a\n a = b\n b = tmp\n }\n\n const list = edges[ a ]\n\n if (list === undefined) {\n edges[ a ] = [ b ]\n return true\n } else if (!list.includes(b)) {\n list.push(b)\n return true\n }\n\n return false\n }\n\n const geometry = this.geometry\n const index = geometry.index\n\n if (!this.parameters.wireframe) {\n this.wireframeIndex = new Uint16Array(0)\n this.wireframeIndexCount = 0\n } else if (index) {\n const array = index.array\n let n = array.length\n if (geometry.drawRange.count !== Infinity) {\n n = geometry.drawRange.count\n }\n let wireframeIndex\n if (this.wireframeIndex && this.wireframeIndex.length > n * 2) {\n wireframeIndex = this.wireframeIndex\n } else {\n const count = (geometry.attributes as any).position.count // TODO\n wireframeIndex = getUintArray(n * 2, count)\n }\n\n let j = 0\n edges.length = 0\n\n for (let i = 0; i < n; i += 3) {\n const a = array[ i + 0 ]\n const b = array[ i + 1 ]\n const c = array[ i + 2 ]\n\n if (checkEdge(a, b)) {\n wireframeIndex[ j + 0 ] = a\n wireframeIndex[ j + 1 ] = b\n j += 2\n }\n if (checkEdge(b, c)) {\n wireframeIndex[ j + 0 ] = b\n wireframeIndex[ j + 1 ] = c\n j += 2\n }\n if (checkEdge(c, a)) {\n wireframeIndex[ j + 0 ] = c\n wireframeIndex[ j + 1 ] = a\n j += 2\n }\n }\n\n this.wireframeIndex = wireframeIndex\n this.wireframeIndexCount = j\n this.wireframeIndexVersion = this.indexVersion\n } else {\n const n = (geometry.attributes as any).position.count // TODO\n\n let wireframeIndex\n if (this.wireframeIndex && this.wireframeIndex.length > n * 2) {\n wireframeIndex = this.wireframeIndex\n } else {\n wireframeIndex = getUintArray(n * 2, n)\n }\n\n for (let i = 0, j = 0; i < n; i += 3) {\n wireframeIndex[ j + 0 ] = i\n wireframeIndex[ j + 1 ] = i + 1\n wireframeIndex[ j + 2 ] = i + 1\n wireframeIndex[ j + 3 ] = i + 2\n wireframeIndex[ j + 4 ] = i + 2\n wireframeIndex[ j + 5 ] = i\n\n j += 6\n }\n\n this.wireframeIndex = wireframeIndex\n this.wireframeIndexCount = n * 2\n this.wireframeIndexVersion = this.indexVersion\n }\n }\n\n updateWireframeIndex () {\n if (!this.wireframeGeometry || !this.wireframeIndex) return\n\n this.wireframeGeometry.setDrawRange(0, Infinity)\n if (this.wireframeIndexVersion < this.indexVersion) this.makeWireframeIndex()\n\n if (this.wireframeGeometry.index &&\n this.wireframeIndex.length > this.wireframeGeometry.index.array.length) {\n this.wireframeGeometry.setIndex(\n new BufferAttribute(this.wireframeIndex, 1).setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n } else {\n const index = this.wireframeGeometry.getIndex()\n if (!index) { Log.error('Index is null'); return; }\n index.set(this.wireframeIndex)\n index.needsUpdate = this.wireframeIndexCount > 0\n index.updateRange.count = this.wireframeIndexCount\n }\n\n this.wireframeGeometry.setDrawRange(0, this.wireframeIndexCount)\n }\n\n getRenderOrder () {\n let renderOrder = 0\n\n if (this.isText) {\n renderOrder = 1\n } else if (this.transparent) {\n if (this.isSurface) {\n renderOrder = 3\n } else {\n renderOrder = 2\n }\n }\n\n return renderOrder\n }\n\n _getMesh (materialName: BufferMaterials) {\n if (!this.material) this.makeMaterial()\n\n const g = this.geometry\n const m = this[ materialName ]\n\n let mesh\n\n if (this.isLine) {\n mesh = new LineSegments(g, m)\n } else if (this.isPoint) {\n mesh = new Points(g, m)\n } else {\n mesh = new Mesh(g, m)\n }\n\n mesh.frustumCulled = false\n mesh.renderOrder = this.getRenderOrder()\n\n return mesh\n }\n\n getMesh () {\n return this._getMesh('material')\n }\n\n getWireframeMesh () {\n let mesh\n\n if (!this.material) this.makeMaterial()\n if (!this.wireframeGeometry) this.makeWireframeGeometry()\n\n mesh = new LineSegments(\n this.wireframeGeometry, this.wireframeMaterial\n )\n\n mesh.frustumCulled = false\n mesh.renderOrder = this.getRenderOrder()\n\n return mesh\n }\n\n getPickingMesh () {\n return this._getMesh('pickingMaterial')\n }\n\n getShader (name: string, type?: BufferTypes) {\n return getShader(name, this.getDefines(type))\n }\n\n getVertexShader (type?: BufferTypes) {\n return this.getShader(this.vertexShader, type)\n }\n\n getFragmentShader (type?: BufferTypes) {\n return this.getShader(this.fragmentShader, type)\n }\n\n getDefines (type?: BufferTypes) {\n const defines: ShaderDefines = {}\n\n if (this.parameters.clipNear) {\n defines.NEAR_CLIP = 1\n }\n\n if (this.parameters.clipRadius) {\n defines.RADIUS_CLIP = 1\n }\n\n if (type === 'picking') {\n defines.PICKING = 1\n } else {\n if (type === 'background' || this.parameters.background) {\n defines.NOLIGHT = 1\n }\n if (this.parameters.flatShaded) {\n defines.FLAT_SHADED = 1\n }\n if (this.parameters.opaqueBack) {\n defines.OPAQUE_BACK = 1\n }\n if (this.parameters.diffuseInterior) {\n defines.DIFFUSE_INTERIOR = 1\n }\n if (this.parameters.useInteriorColor) {\n defines.USE_INTERIOR_COLOR = 1\n }\n }\n\n return defines\n }\n\n getParameters () {\n return this.parameters\n }\n\n addUniforms (uniforms: Uniforms) {\n this.uniforms = UniformsUtils.merge(\n [ this.uniforms, uniforms ]\n )\n\n this.pickingUniforms = UniformsUtils.merge(\n [ this.pickingUniforms, uniforms ]\n )\n }\n\n addAttributes (attributes: { [k: string]: _BufferAttribute }) {\n for (let name in attributes) {\n let buf\n const a = attributes[ name ]\n const arraySize = this.attributeSize * itemSize[ a.type ]\n\n if (a.value) {\n if (arraySize !== a.value.length) {\n Log.error('attribute value has wrong length', name)\n }\n buf = a.value\n } else {\n buf = getTypedArray('float32', arraySize)\n }\n\n this.geometry.setAttribute(\n name,\n new BufferAttribute(buf, itemSize[ a.type ]).setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n }\n }\n\n updateRenderOrder () {\n const renderOrder = this.getRenderOrder()\n function setRenderOrder (mesh: Object3D) {\n mesh.renderOrder = renderOrder\n }\n\n this.group.children.forEach(setRenderOrder)\n if (this.pickingGroup) {\n this.pickingGroup.children.forEach(setRenderOrder)\n }\n }\n\n updateShader () {\n const m = this.material\n const wm = this.wireframeMaterial\n const pm = this.pickingMaterial\n\n m.vertexShader = this.getVertexShader()\n m.fragmentShader = this.getFragmentShader()\n m.needsUpdate = true\n\n wm.vertexShader = this.getShader('Line.vert')\n wm.fragmentShader = this.getShader('Line.frag')\n wm.needsUpdate = true\n\n pm.vertexShader = this.getVertexShader('picking')\n pm.fragmentShader = this.getFragmentShader('picking')\n pm.needsUpdate = true\n }\n\n /**\n * Set buffer parameters\n * @param {BufferParameters} params - buffer parameters object\n * @return {undefined}\n */\n setParameters (params: Partial) {\n const p = params as any\n const pt = this.parameterTypes as any\n const pv = this.parameters as any\n\n const propertyData: { [k: string]: any } = {}\n const uniformData: { [k: string]: any } = {}\n let doShaderUpdate = false\n let doVisibilityUpdate = false\n\n for (const name in p) {\n const value = p[ name ]\n\n if (value === undefined) continue\n pv[ name ] = value\n\n if (pt[ name ] === undefined) continue\n\n if (pt[ name ].property) {\n if (pt[ name ].property !== true) {\n propertyData[ pt[ name ].property as any ] = value\n } else {\n propertyData[ name ] = value\n }\n }\n\n if (pt[ name ].uniform) {\n if (pt[ name ].uniform !== true) {\n uniformData[ pt[ name ].uniform as any ] = value\n } else {\n uniformData[ name ] = value\n }\n }\n\n if (pt[ name ].updateShader) {\n doShaderUpdate = true\n }\n\n if (pt[ name ].updateVisibility) {\n doVisibilityUpdate = true\n }\n\n if (this.dynamic && name === 'wireframe' && value === true) {\n this.updateWireframeIndex()\n }\n\n if (name === 'forceTransparent') {\n propertyData.transparent = this.transparent\n }\n\n if (name === 'matrix') {\n this.matrix = value\n }\n }\n\n this.setProperties(propertyData)\n this.setUniforms(uniformData)\n if (doShaderUpdate) this.updateShader()\n if (doVisibilityUpdate) this.setVisibility(this.visible)\n }\n\n /**\n * Sets buffer attributes\n * @param {Object} data - An object where the keys are the attribute names\n * and the values are the attribute data.\n * @example\n * var buffer = new Buffer();\n * buffer.setAttributes({ attrName: attrData });\n */\n setAttributes (data: any) { // TODO\n const geometry = this.geometry\n const attributes = geometry.attributes as any // TODO\n\n for (const name in data) {\n if (name === 'picking') continue\n\n const array = data[ name ]\n const length = array.length\n\n if (name === 'index') {\n const index = geometry.getIndex()\n if (!index) { Log.error('Index is null'); continue; }\n geometry.setDrawRange(0, Infinity)\n\n if (length > index.array.length) {\n geometry.setIndex(\n new BufferAttribute(array, 1)\n .setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n } else {\n index.set(array)\n index.count = length\n index.needsUpdate = length > 0\n index.updateRange.count = length\n geometry.setDrawRange(0, length)\n }\n\n this.indexVersion++\n if (this.parameters.wireframe) this.updateWireframeIndex()\n } else {\n const attribute = attributes[ name ]\n\n if (length > attribute.array.length) {\n geometry.setAttribute(\n name,\n new BufferAttribute(array, attribute.itemSize)\n .setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n } else {\n attributes[ name ].set(array)\n attributes[ name ].needsUpdate = length > 0\n attributes[ name ].updateRange.count = length\n }\n }\n }\n }\n\n setUniforms (data: any) { // TODO\n if (!data) return\n\n const u = this.material.uniforms\n const wu = this.wireframeMaterial.uniforms\n const pu = this.pickingMaterial.uniforms\n\n for (let name in data) {\n if (name === 'opacity') {\n this.setProperties({ transparent: this.transparent })\n }\n\n if (u[ name ] !== undefined) {\n if (u[ name ].value.isVector3) {\n u[ name ].value.copy(data[ name ])\n } else if (u[ name ].value.set) {\n u[ name ].value.set(data[ name ])\n } else {\n u[ name ].value = data[ name ]\n }\n }\n\n if (wu[ name ] !== undefined) {\n if (wu[ name ].value.isVector3) {\n wu[ name ].value.copy(data[ name ])\n } else if (wu[ name ].value.set) {\n wu[ name ].value.set(data[ name ])\n } else {\n wu[ name ].value = data[ name ]\n }\n }\n\n if (pu[ name ] !== undefined) {\n if (pu[ name ].value.isVector3) {\n pu[ name ].value.copy(data[ name ])\n } else if (pu[ name ].value.set) {\n pu[ name ].value.set(data[ name ])\n } else {\n pu[ name ].value = data[ name ]\n }\n }\n }\n }\n\n setProperties (data: any) { // TODO\n if (!data) return\n\n const m = this.material\n const wm = this.wireframeMaterial\n const pm = this.pickingMaterial\n\n for (const _name in data) {\n const name = _name as 'side'|'transparent' // TODO\n\n let value = data[ name ]\n\n if (name === 'transparent') {\n this.updateRenderOrder()\n } else if (name === 'side') {\n value = getThreeSide(value)\n }\n\n (m[ name ] as any) = value;\n (wm[ name ] as any) = value;\n (pm[ name ] as any) = value\n }\n\n m.needsUpdate = true\n wm.needsUpdate = true\n pm.needsUpdate = true\n }\n\n /**\n * Set buffer visibility\n * @param {Boolean} value - visibility value\n * @return {undefined}\n */\n setVisibility (value: boolean) {\n this.visible = value\n\n if (this.parameters.wireframe) {\n this.group.visible = false\n this.wireframeGroup.visible = value\n if (this.pickable) {\n this.pickingGroup.visible = false\n }\n } else {\n this.group.visible = value\n this.wireframeGroup.visible = false\n if (this.pickable) {\n this.pickingGroup.visible = value\n }\n }\n }\n\n /**\n * Free buffer resources\n * @return {undefined}\n */\n dispose () {\n if (this.material) this.material.dispose()\n if (this.wireframeMaterial) this.wireframeMaterial.dispose()\n if (this.pickingMaterial) this.pickingMaterial.dispose()\n\n this.geometry.dispose()\n if (this.wireframeGeometry) this.wireframeGeometry.dispose()\n }\n\n /**\n * Customize JSON serialization to avoid circular references\n */\n toJSON () {\n var result: any = {};\n for (var x in this) {\n if (x !== \"group\" && x !== \"wireframeGroup\" && x != \"pickingGroup\"\n && x !== \"picking\") {\n result[x] = this[x];\n }\n }\n return result;\n }\n}\n\nexport default Buffer\n","/**\n * @file Mesh Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport '../shader/Mesh.vert'\nimport '../shader/Mesh.frag'\n\nimport Buffer, { BufferParameters, BufferData } from './buffer'\n\n/**\n * Mesh buffer. Draws a triangle mesh.\n *\n * @example\n * var meshBuffer = new MeshBuffer({\n * position: new Float32Array(\n * [ 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1 ]\n * ),\n * color: new Float32Array(\n * [ 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0 ]\n * )\n * });\n */\nclass MeshBuffer extends Buffer {\n vertexShader = 'Mesh.vert'\n fragmentShader = 'Mesh.frag'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} [data.index] - triangle indices\n * @param {Float32Array} [data.normal] - radii\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: BufferData, params: Partial = {}) {\n super(data, params)\n\n this.addAttributes({\n 'normal': { type: 'v3', value: data.normal }\n })\n\n if (data.normal === undefined) {\n this.geometry.computeVertexNormals()\n }\n }\n}\n\nexport default MeshBuffer\n","/**\n * @file Surface Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport MeshBuffer from './mesh-buffer'\n\n/**\n * Surface buffer. Like a {@link MeshBuffer}, but with `.isSurface` set to `true`.\n */\nclass SurfaceBuffer extends MeshBuffer {\n isSurface = true\n}\n\nexport default SurfaceBuffer\n","/**\n * @file Double Sided Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { Group, BufferGeometry, Object3D, Mesh, LineSegments, Vector3, Matrix4 } from 'three'\n\nimport Buffer, { BufferSide } from './buffer'\nimport { Picker } from '../utils/picker'\n\nfunction setVisibilityTrue (m: Object3D) { m.visible = true }\nfunction setVisibilityFalse (m: Object3D) { m.visible = false }\n\n/**\n * A double-sided mesh buffer. Takes a buffer and renders the front and\n * the back as seperate objects to avoid some artifacts when rendering\n * transparent meshes. Also allows to render the back of a mesh opaque\n * while the front is transparent.\n * @implements {Buffer}\n *\n * @example\n * var sphereGeometryBuffer = new SphereGeometryBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n * var doubleSidedBuffer = new DoubleSidedBuffer(sphereGeometryBuffer);\n */\nclass DoubleSidedBuffer {\n size: number\n side: BufferSide\n visible: boolean\n wireframe: boolean\n geometry: BufferGeometry\n\n picking?: Picker\n\n group = new Group()\n wireframeGroup = new Group()\n pickingGroup = new Group()\n\n frontMeshes: (Mesh|LineSegments)[] = []\n backMeshes: (Mesh|LineSegments)[] = []\n\n buffer: Buffer\n frontBuffer: Buffer\n backBuffer: Buffer\n\n /**\n * Create a double sided buffer\n * @param {Buffer} buffer - the buffer to be rendered double-sided\n */\n constructor (buffer: Buffer) {\n this.size = buffer.size\n this.side = buffer.parameters.side\n this.visible = buffer.visible\n this.geometry = buffer.geometry\n this.picking = buffer.picking\n\n this.group = new Group()\n this.wireframeGroup = new Group()\n this.pickingGroup = new Group()\n\n // requires Group objects to be present\n this.matrix = buffer.matrix\n\n const frontBuffer = buffer\n const backBuffer = new (buffer as any).constructor({ // TODO\n position: new Float32Array(0)\n }) as Buffer\n\n frontBuffer.makeMaterial()\n backBuffer.makeMaterial()\n\n backBuffer.picking = buffer.picking\n backBuffer.geometry = buffer.geometry\n backBuffer.wireframeGeometry = buffer.wireframeGeometry\n backBuffer.setParameters(buffer.getParameters())\n backBuffer.updateShader()\n\n frontBuffer.setParameters({\n side: 'front'\n })\n backBuffer.setParameters({\n side: 'back',\n opacity: backBuffer.parameters.opacity\n })\n\n this.buffer = buffer\n this.frontBuffer = frontBuffer\n this.backBuffer = backBuffer\n }\n\n set matrix (m) {\n Buffer.prototype.setMatrix.call(this, m)\n }\n get matrix () {\n return this.group.matrix.clone()\n }\n\n get pickable () {\n return !!this.picking && !this.parameters.disablePicking\n }\n\n get parameters () {\n return this.buffer.parameters\n }\n\n getParameters () {\n const p = Object.assign({}, this.buffer.parameters)\n p.side = this.side\n return p\n }\n\n getMesh (picking: boolean) {\n let front, back\n\n if (picking) {\n back = this.backBuffer.getPickingMesh()\n front = this.frontBuffer.getPickingMesh()\n } else {\n back = this.backBuffer.getMesh()\n front = this.frontBuffer.getMesh()\n }\n\n this.frontMeshes.push(front)\n this.backMeshes.push(back)\n\n this.setParameters({ side: this.side })\n\n return new Group().add(back, front)\n }\n\n getWireframeMesh () {\n return this.buffer.getWireframeMesh()\n }\n\n getPickingMesh () {\n return this.getMesh(true)\n }\n\n setAttributes (data: any) { // TODO\n this.buffer.setAttributes(data)\n }\n\n setParameters (data: any) { // TODO\n data = Object.assign({}, data)\n\n if (data.side === 'front') {\n this.frontMeshes.forEach(setVisibilityTrue)\n this.backMeshes.forEach(setVisibilityFalse)\n } else if (data.side === 'back') {\n this.frontMeshes.forEach(setVisibilityFalse)\n this.backMeshes.forEach(setVisibilityTrue)\n } else if (data.side === 'double') {\n this.frontMeshes.forEach(setVisibilityTrue)\n this.backMeshes.forEach(setVisibilityTrue)\n }\n\n if (data.side !== undefined) {\n this.side = data.side\n }\n delete data.side\n\n if (data.matrix !== undefined) {\n this.matrix = data.matrix\n }\n delete data.matrix\n\n this.frontBuffer.setParameters(data)\n\n if (data.wireframe !== undefined) {\n this.wireframe = data.wireframe\n this.setVisibility(this.visible)\n }\n delete data.wireframe\n\n this.backBuffer.setParameters(data)\n }\n\n setVisibility (value: boolean) {\n this.visible = value\n\n if (this.parameters.wireframe) {\n this.group.visible = false\n this.wireframeGroup.visible = value\n if (this.pickable) {\n this.pickingGroup.visible = false\n }\n } else {\n this.group.visible = value\n this.wireframeGroup.visible = false\n if (this.pickable) {\n this.pickingGroup.visible = value\n }\n }\n }\n\n dispose () {\n this.frontBuffer.dispose()\n this.backBuffer.dispose()\n }\n\n /**\n * Customize JSON serialization to avoid circular references.\n * Only export simple params which could be useful.\n */\n toJSON () {\n var result: any = {};\n for (var x in this) {\n if (['side', 'size', 'visible', 'matrix', 'parameters'].includes(x)) {\n result[x] = this[x];\n }\n }\n return result;\n }\n}\n\nexport default DoubleSidedBuffer\n","/**\n * @file Contour Buffer\n * @author Fred ludlow \n * @private\n */\n\nimport '../shader/Line.vert'\nimport '../shader/Line.frag'\n\nimport Buffer from './buffer'\n\n/**\n * Contour buffer. A buffer that draws lines (instead of triangle meshes).\n */\nclass ContourBuffer extends Buffer {\n isLine = true\n vertexShader = 'Line.vert'\n fragmentShader = 'Line.frag'\n}\n\nexport default ContourBuffer\n","/**\n * @file Surface Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3, Box3 } from 'three'\n\nimport { defaults } from '../utils'\nimport Representation, { RepresentationParameters } from './representation'\nimport Volume from '../surface/volume'\nimport SurfaceBuffer from '../buffer/surface-buffer'\nimport DoubleSidedBuffer from '../buffer/doublesided-buffer'\nimport ContourBuffer from '../buffer/contour-buffer'\nimport Surface from '../surface/surface';\nimport Viewer from '../viewer/viewer';\nimport {SurfaceData} from '../surface/surface'\n// @ts-ignore: unused import ColormakerParameters required for declaration only\nimport { ColormakerParameters } from '../color/colormaker';\nexport type SurfaceDataFields = {position: boolean, color: boolean, index: boolean, normal: boolean, radius: boolean}\n\n/**\n * Surface representation parameter object. Extends {@link RepresentationParameters}\n *\n * @typedef {Object} SurfaceRepresentationParameters - surface representation parameters\n *\n * @property {String} isolevelType - Meaning of the isolevel value. Either *value* for the literal value or *sigma* as a factor of the sigma of the data. For volume data only.\n * @property {Float} isolevel - The value at which to create the isosurface. For volume data only.\n * @property {Boolean} negateIsolevel - For volume data only.\n * @property {Boolean} isolevelScroll - For volume data only\n * @property {Integer} smooth - How many iterations of laplacian smoothing after surface triangulation. For volume data only.\n * @property {Boolean} background - Render the surface in the background, unlit.\n * @property {Boolean} opaqueBack - Render the back-faces (where normals point away from the camera) of the surface opaque, ignoring the transparency parameter.\n * @property {Integer} boxSize - Size of the box to triangulate volume data in. Set to zero to triangulate the whole volume. For volume data only.\n * @property {Boolean} useWorker - Weather or not to triangulate the volume asynchronously in a Web Worker. For volume data only.\n * @property {Boolean} wrap - Wrap volume data around the edges; use in conjuction with boxSize but not larger than the volume dimension. For volume data only.\n */\nexport interface SurfaceRepresentationParameters extends RepresentationParameters {\n isolevelType: 'value'|'sigma'\n isolevel: number\n smooth: number\n background: boolean\n opaqueBack: boolean\n boxSize: number\n useWorker: boolean\n wrap: boolean\n}\n/**\n * Surface representation\n */\n/**\n * Create Surface representation object\n * @param {Surface|Volume} surface - the surface or volume to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {SurfaceRepresentationParameters} params - surface representation parameters\n */\nclass SurfaceRepresentation extends Representation {\n protected surface: Surface|Volume|undefined\n protected volume: Volume|undefined\n protected boxCenter: Vector3\n protected __boxCenter: Vector3\n protected box: Box3\n protected __box: Box3\n protected _position: Vector3\n protected isolevelType: 'value'|'sigma'\n protected isolevel: number\n protected negateIsolevel: boolean\n protected isolevelScroll: boolean\n protected smooth: number\n protected background: boolean\n protected opaqueBack: boolean\n protected boxSize: number\n protected inverseMatrix: Matrix4\n protected colorVolume: Volume\n protected contour: boolean\n protected useWorker: boolean\n protected wrap: boolean\n\n protected __isolevel: number\n protected __smooth: number\n protected __contour: boolean\n protected __wrap: boolean\n protected __boxSize: number\n\n setBox: () => void\n\n constructor (surface: Surface, viewer: Viewer, params: Partial) {\n super(surface, viewer, params)\n\n this.type = 'surface'\n\n this.parameters = Object.assign({\n\n isolevelType: {\n type: 'select',\n options: {\n 'value': 'value', 'sigma': 'sigma'\n }\n },\n isolevel: {\n type: 'number', precision: 2, max: 1000, min: -1000\n },\n negateIsolevel: {\n type: 'boolean'\n },\n isolevelScroll: {\n type: 'boolean'\n },\n smooth: {\n type: 'integer', precision: 1, max: 10, min: 0\n },\n background: {\n type: 'boolean', rebuild: true // FIXME\n },\n opaqueBack: {\n type: 'boolean', buffer: true\n },\n boxSize: {\n type: 'integer', precision: 1, max: 100, min: 0\n },\n colorVolume: {\n type: 'hidden'\n },\n contour: {\n type: 'boolean', rebuild: true\n },\n useWorker: {\n type: 'boolean', rebuild: true\n },\n wrap: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters)\n\n if (surface instanceof Volume) {\n this.surface = undefined\n this.volume = surface\n } else {\n this.surface = surface\n this.volume = undefined\n }\n\n this.boxCenter = new Vector3()\n this.__boxCenter = new Vector3()\n this.box = new Box3()\n this.__box = new Box3()\n\n this._position = new Vector3()\n this.inverseMatrix = new Matrix4()\n\n this.setBox = function setBox () {\n this._position.copy(viewer.translationGroup.position).negate()\n this._position.applyMatrix4(this.inverseMatrix)\n if (!this._position.equals(this.boxCenter)) {\n this.setParameters({ 'boxCenter': this._position })\n }\n }\n\n this.toBePrepared = true\n\n this.viewer.signals.ticked.add(this.setBox, this)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'uniform')\n p.colorValue = defaults(p.colorValue, 0xDDDDDD)\n\n this.isolevelType = defaults(p.isolevelType, 'sigma')\n this.isolevel = defaults(p.isolevel, 2.0)\n this.negateIsolevel = defaults(p.negateIsolevel, false)\n this.isolevelScroll = defaults(p.isolevelScroll, false)\n this.smooth = defaults(p.smooth, 0)\n this.background = defaults(p.background, false)\n this.opaqueBack = defaults(p.opaqueBack, true)\n this.boxSize = defaults(p.boxSize, 0)\n this.colorVolume = defaults(p.colorVolume, undefined)\n this.contour = defaults(p.contour, false)\n this.useWorker = defaults(p.useWorker, true)\n this.wrap = defaults(p.wrap, false)\n\n super.init(p)\n\n this.inverseMatrix.getInverse(this.matrix)\n\n this.build()\n }\n\n attach (callback: () => void) {\n this.bufferList.forEach(buffer => {\n this.viewer.add(buffer)\n })\n\n this.setVisibility(this.visible)\n\n callback()\n }\n\n prepare (callback: () => void) {\n if (this.volume) {\n let isolevel\n\n if (this.isolevelType === 'sigma') {\n isolevel = this.volume.getValueForSigma(this.isolevel)\n } else {\n isolevel = this.isolevel\n }\n if (this.negateIsolevel) isolevel *= -1\n\n if (!this.surface ||\n this.__isolevel !== isolevel ||\n this.__smooth !== this.smooth ||\n this.__contour !== this.contour ||\n this.__wrap !== this.wrap ||\n this.__boxSize !== this.boxSize ||\n (this.boxSize > 0 &&\n !this.__boxCenter.equals(this.boxCenter))\n ) {\n this.__isolevel = isolevel\n this.__smooth = this.smooth\n this.__contour = this.contour\n this.__wrap = this.wrap\n this.__boxSize = this.boxSize\n this.__boxCenter.copy(this.boxCenter)\n this.__box.copy(this.box)\n\n const onSurfaceFinish = (surface: Surface) => {\n this.surface = surface\n callback()\n }\n\n if (this.useWorker) {\n this.volume.getSurfaceWorker(\n isolevel, this.smooth, this.boxCenter, this.boxSize,\n this.contour, this.wrap, onSurfaceFinish\n )\n } else {\n onSurfaceFinish(\n this.volume.getSurface(\n isolevel, this.smooth, this.boxCenter, this.boxSize,\n this.contour, this.wrap\n )\n )\n }\n } else {\n callback()\n }\n } else {\n callback()\n }\n }\n\n create () {\n const sd = {\n position: (this.surface as Surface).getPosition(),\n color: (this.surface as Surface).getColor(this.getColorParams()),\n index: (this.surface as Surface).getIndex()\n }\n\n let buffer\n\n if (this.contour) {\n buffer = new ContourBuffer(\n sd,\n this.getBufferParams({ wireframe: false })\n )\n } else {\n Object.assign(sd, {\n normal: (this.surface as Surface).getNormal(),\n picking: (this.surface as Surface).getPicking()\n })\n\n const surfaceBuffer = new SurfaceBuffer(\n sd,\n this.getBufferParams({\n background: this.background,\n opaqueBack: this.opaqueBack,\n dullInterior: false\n })\n )\n\n buffer = new DoubleSidedBuffer(surfaceBuffer)\n }\n\n this.bufferList.push(buffer as ContourBuffer)\n }\n\n update (what: SurfaceDataFields) {\n if (this.bufferList.length === 0) return\n\n what = what || {}\n\n const surfaceData: Partial = {}\n\n if (what.position) {\n surfaceData.position = (this.surface as Surface).getPosition()\n }\n\n if (what.color) {\n surfaceData.color = (this.surface as Surface).getColor(\n this.getColorParams()\n )\n }\n\n if (what.index) {\n surfaceData.index = (this.surface as Surface).getIndex()\n }\n\n if (what.normal) {\n surfaceData.normal = (this.surface as Surface).getNormal()\n }\n\n this.bufferList.forEach(function (buffer) {\n buffer.setAttributes(surfaceData)\n })\n }\n\n /**\n * Set representation parameters\n * @alias SurfaceRepresentation#setParameters\n * @param {SurfaceRepresentationParameters} params - surface parameter object\n * @param {Object} [what] - buffer data attributes to be updated,\n * note that this needs to be implemented in the\n * derived classes. Generally it allows more\n * fine-grained control over updating than\n * forcing a rebuild.\n * @param {Boolean} what.position - update position data\n * @param {Boolean} what.color - update color data\n * @param {Boolean} [rebuild] - whether or not to rebuild the representation\n * @return {SurfaceRepresentation} this object\n */\n setParameters (params: Partial, what?: SurfaceDataFields, rebuild?: boolean) {\n if (params && params.isolevelType !== undefined &&\n this.volume\n ) {\n if (this.isolevelType === 'value' &&\n params.isolevelType === 'sigma'\n ) {\n this.isolevel = this.volume.getSigmaForValue(this.isolevel)\n } else if (this.isolevelType === 'sigma' &&\n params.isolevelType === 'value'\n ) {\n this.isolevel = this.volume.getValueForSigma(this.isolevel)\n }\n\n this.isolevelType = params.isolevelType\n }\n\n if (params && params.boxCenter) {\n this.boxCenter.copy(params.boxCenter)\n delete params.boxCenter\n }\n\n // Forbid wireframe && contour as in molsurface\n if (params && params.wireframe && (\n params.contour || (params.contour === undefined && this.contour)\n )) {\n params.wireframe = false\n }\n\n super.setParameters(params, what, rebuild)\n\n if (params.matrix) {\n this.inverseMatrix.getInverse(params.matrix)\n }\n\n if (this.volume) {\n this.volume.getBox(this.boxCenter, this.boxSize, this.box)\n }\n\n if (params && params.colorVolume !== undefined) {\n if (what) what.color = true\n }\n\n if (this.surface && (\n params.isolevel !== undefined ||\n params.negateIsolevel !== undefined ||\n params.smooth !== undefined ||\n params.wrap !== undefined ||\n params.boxSize !== undefined ||\n (this.boxSize > 0 &&\n !this.__box.equals(this.box))\n )) {\n this.build({\n 'position': true,\n 'color': true,\n 'index': true,\n 'normal': !this.contour\n })\n }\n\n return this\n }\n\n getColorParams () {\n const p = super.getColorParams()\n\n p.volume = this.colorVolume\n\n return p\n }\n\n dispose () {\n this.viewer.signals.ticked.remove(this.setBox, this)\n\n super.dispose()\n }\n}\n\nexport default SurfaceRepresentation\n","/**\n * @file Mouse Actions\n * @author Alexander Rose \n * @private\n */\n\nimport PickingProxy from './picking-proxy'\nimport { almostIdentity } from '../math/math-utils'\nimport Stage from '../stage/stage'\nimport StructureComponent from '../component/structure-component'\nimport SurfaceRepresentation from '../representation/surface-representation'\n\nexport type ScrollCallback = (stage: Stage, delta: number) => void\nexport type DragCallback = (stage: Stage, dx: number, dy: number) => void\nexport type PickCallback = (stage: Stage, pickingProxy: PickingProxy) => void\nexport type MouseActionCallback = ScrollCallback | DragCallback | PickCallback\n\n/**\n * Mouse actions provided as static methods\n */\nclass MouseActions {\n /**\n * Zoom scene based on scroll-delta\n * @param {Stage} stage - the stage\n * @param {Number} delta - amount to zoom\n * @return {undefined}\n */\n static zoomScroll (stage: Stage, delta: number) {\n stage.trackballControls.zoom(delta)\n }\n\n /**\n * Move near clipping plane based on scroll-delta\n * @param {Stage} stage - the stage\n * @param {Number} delta - amount to move clipping plane\n * @return {undefined}\n */\n static clipNearScroll (stage: Stage, delta: number) {\n const sp = stage.getParameters()\n stage.setParameters({ clipNear: sp.clipNear + delta / 10 })\n }\n\n /**\n * Move clipping planes based on scroll-delta.\n * @param {Stage} stage - the stage\n * @param {Number} delta - direction to move planes\n * @return {undefined}\n */\n static focusScroll (stage: Stage, delta: number) {\n const focus = stage.getFocus()\n const sign = Math.sign(delta)\n const step = sign * almostIdentity((100 - focus) / 10, 5, 0.2)\n stage.setFocus(focus + step)\n }\n\n /**\n * Zoom scene based on scroll-delta and\n * move focus planes based on camera position (zoom)\n * @param {Stage} stage - the stage\n * @param {Number} delta - amount to move focus planes and zoom\n * @return {undefined}\n */\n static zoomFocusScroll (stage: Stage, delta: number) {\n stage.trackballControls.zoom(delta)\n const z = stage.viewer.camera.position.z\n stage.setFocus(100 - Math.abs(z / 8))\n }\n\n /**\n * Change isolevel of volume surfaces based on scroll-delta\n * @param {Stage} stage - the stage\n * @param {Number} delta - amount to change isolevel\n * @return {undefined}\n */\n static isolevelScroll (stage: Stage, delta: number) {\n const d = Math.sign(delta) / 10\n stage.eachRepresentation((reprElem, comp) => {\n if (reprElem.repr instanceof SurfaceRepresentation) {\n const p = reprElem.getParameters() as any // TODO\n if (p.isolevelScroll) {\n reprElem.setParameters({ isolevel: p.isolevel + d })\n }\n }\n })\n }\n\n /**\n * Pan scene based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to pan in x direction\n * @param {Number} dy - amount to pan in y direction\n * @return {undefined}\n */\n static panDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.pan(dx, dy)\n }\n\n /**\n * Rotate scene based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to rotate in x direction\n * @param {Number} dy - amount to rotate in y direction\n * @return {undefined}\n */\n static rotateDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.rotate(dx, dy)\n }\n\n /**\n * Rotate scene around z axis based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to rotate in x direction\n * @param {Number} dy - amount to rotate in y direction\n * @return {undefined}\n */\n static zRotateDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.zRotate(dx, dy)\n }\n\n /**\n * Zoom scene based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to zoom\n * @param {Number} dy - amount to zoom\n * @return {undefined}\n */\n static zoomDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.zoom((dx + dy) / -2)\n }\n\n /**\n * Zoom scene based on mouse coordinate changes and\n * move focus planes based on camera position (zoom)\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to zoom and focus\n * @param {Number} dy - amount to zoom and focus\n * @return {undefined}\n */\n static zoomFocusDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.zoom((dx + dy) / -2)\n const z = stage.viewer.camera.position.z\n stage.setFocus(100 - Math.abs(z / 8))\n }\n\n /**\n * Pan picked component based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to pan in x direction\n * @param {Number} dy - amount to pan in y direction\n * @return {undefined}\n */\n static panComponentDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.panComponent(dx, dy)\n }\n\n /**\n * Pan picked atom based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to pan in x direction\n * @param {Number} dy - amount to pan in y direction\n * @return {undefined}\n */\n static panAtomDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.panAtom(dx, dy)\n }\n\n /**\n * Rotate picked component based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to rotate in x direction\n * @param {Number} dy - amount to rotate in y direction\n * @return {undefined}\n */\n static rotateComponentDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.rotateComponent(dx, dy)\n }\n\n /**\n * Move picked element to the center of the screen\n * @param {Stage} stage - the stage\n * @param {PickingProxy} pickingProxy - the picking data object\n * @return {undefined}\n */\n static movePick (stage: Stage, pickingProxy: PickingProxy) {\n if (pickingProxy) {\n stage.animationControls.move(pickingProxy.position.clone())\n }\n }\n\n /**\n * Show tooltip with information of picked element\n * @param {Stage} stage - the stage\n * @param {PickingProxy} pickingProxy - the picking data object\n * @return {undefined}\n */\n static tooltipPick (stage: Stage, pickingProxy: PickingProxy) {\n const tt = stage.tooltip\n const sp = stage.getParameters() as any\n if (sp.tooltip && pickingProxy) {\n const mp = pickingProxy.mouse.position\n tt.innerText = pickingProxy.getLabel()\n tt.style.bottom = (window.innerHeight - mp.y + 3) + 'px'\n tt.style.left = (mp.x + 3) + 'px'\n tt.style.display = 'block'\n } else {\n tt.style.display = 'none'\n }\n }\n\n static measurePick (stage: Stage, pickingProxy: PickingProxy) {\n if (pickingProxy && (pickingProxy.atom || pickingProxy.bond)) {\n const atom = pickingProxy.atom || pickingProxy.closestBondAtom\n const sc = pickingProxy.component as StructureComponent\n sc.measurePick(atom)\n } else {\n stage.measureClear()\n }\n }\n}\n\ntype MouseActionPreset = [ string, MouseActionCallback ][]\nexport const MouseActionPresets = {\n default: [\n [ 'scroll', MouseActions.zoomScroll ],\n [ 'scroll-shift', MouseActions.focusScroll ],\n [ 'scroll-ctrl', MouseActions.isolevelScroll ],\n [ 'scroll-shift-ctrl', MouseActions.zoomFocusScroll ],\n\n [ 'drag-left', MouseActions.rotateDrag ],\n [ 'drag-right', MouseActions.panDrag ],\n [ 'drag-ctrl-left', MouseActions.panDrag ],\n [ 'drag-ctrl-right', MouseActions.zRotateDrag ],\n [ 'drag-shift-left', MouseActions.zoomDrag ],\n [ 'drag-middle', MouseActions.zoomFocusDrag ],\n\n [ 'drag-ctrl-shift-right', MouseActions.panComponentDrag ],\n [ 'drag-ctrl-shift-left', MouseActions.rotateComponentDrag ],\n\n [ 'clickPick-right', MouseActions.measurePick ],\n [ 'clickPick-ctrl-left', MouseActions.measurePick ],\n [ 'clickPick-middle', MouseActions.movePick ],\n [ 'clickPick-left', MouseActions.movePick ],\n [ 'hoverPick', MouseActions.tooltipPick ]\n ] as MouseActionPreset,\n pymol: [\n [ 'drag-left', MouseActions.rotateDrag ],\n [ 'drag-middle', MouseActions.panDrag ],\n [ 'drag-right', MouseActions.zoomDrag ],\n [ 'scroll', MouseActions.focusScroll ],\n [ 'drag-shift-right', MouseActions.focusScroll ],\n\n [ 'clickPick-ctrl+shift-middle', MouseActions.movePick ],\n [ 'hoverPick', MouseActions.tooltipPick ]\n ] as MouseActionPreset,\n coot: [\n [ 'scroll', MouseActions.isolevelScroll ],\n\n [ 'drag-left', MouseActions.rotateDrag ],\n [ 'drag-middle', MouseActions.panDrag ],\n [ 'drag-ctrl-left', MouseActions.panDrag ],\n [ 'drag-right', MouseActions.zoomFocusDrag ],\n [ 'drag-ctrl-right', MouseActions.focusScroll ],\n\n [ 'clickPick-middle', MouseActions.movePick ],\n [ 'hoverPick', MouseActions.tooltipPick ]\n ] as MouseActionPreset,\n astexviewer: [\n [ 'drag-left', MouseActions.rotateDrag ],\n [ 'drag-ctrl-left', MouseActions.panDrag ],\n [ 'drag-shift-left', MouseActions.zoomDrag ],\n [ 'scroll', MouseActions.focusScroll ],\n [ 'clickPick-middle', MouseActions.movePick ],\n [ 'hoverPick', MouseActions.tooltipPick ]\n ] as MouseActionPreset\n}\n\nexport default MouseActions\n","/**\n * @file Mouse Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { MouseActionPresets, MouseActionCallback } from './mouse-actions'\nimport Stage from '../stage/stage'\nimport MouseObserver from '../stage/mouse-observer'\n\nexport type MouseControlPreset = keyof typeof MouseActionPresets\nexport interface MouseControlsParams {\n preset?: MouseControlPreset\n disabled?: boolean\n}\n\nexport type MouseActionType = ''|'scroll'|'drag'|'click'|'doubleClick'|'hover'|'clickPick'|'hoverPick'\nexport interface MouseAction {\n type: MouseActionType\n key: number\n button: number\n callback: MouseActionCallback\n}\n\n/**\n * Strings to describe mouse events (including optional keyboard modifiers).\n * Must contain an event type: \"scroll\", \"drag\", \"click\", \"doubleClick\",\n * \"hover\", \"clickPick\" or \"hoverPick\". Optionally contain one or more\n * (seperated by plus signs) keyboard modifiers: \"alt\", \"ctrl\", \"meta\" or\n * \"shift\". Can contain the mouse button performing the event: \"left\",\n * \"middle\" or \"right\". The type, key and button parts must be seperated by\n * dashes.\n *\n * @example\n * // triggered on scroll event (no key or button)\n * \"scroll\"\n *\n * @example\n * // triggered on scroll event while shift key is pressed\n * \"scroll-shift\"\n *\n * @example\n * // triggered on drag event with left mouse button\n * \"drag-left\"\n *\n * @example\n * // triggered on drag event with right mouse button\n * // while ctrl and shift keys are pressed\n * \"drag-right-ctrl+shift\"\n *\n * @typedef {String} TriggerString\n */\n\n/**\n * Get event type, key and button\n * @param {TriggerString} str - input trigger string\n * @return {Array} event type, key and button\n */\nfunction triggerFromString (str: string) {\n const tokens = str.split(/[-+]/)\n\n let type = ''\n if (tokens.includes('scroll')) type = 'scroll'\n if (tokens.includes('drag')) type = 'drag'\n if (tokens.includes('click')) type = 'click'\n if (tokens.includes('doubleClick')) type = 'doubleClick'\n if (tokens.includes('hover')) type = 'hover'\n if (tokens.includes('clickPick')) type = 'clickPick'\n if (tokens.includes('hoverPick')) type = 'hoverPick'\n\n let key = 0\n if (tokens.includes('alt')) key += 1\n if (tokens.includes('ctrl')) key += 2\n if (tokens.includes('meta')) key += 4\n if (tokens.includes('shift')) key += 8\n\n let button = 0\n if (tokens.includes('left')) button += 1\n if (tokens.includes('right')) button += 2\n if (tokens.includes('middle')) button += 4\n\n return [ type, key, button ] as [ MouseActionType, number, number ]\n}\n\n/**\n * Mouse controls\n */\nclass MouseControls {\n actionList: MouseAction[] = []\n mouse: MouseObserver\n\n disabled: boolean // Flag to disable all actions\n\n /**\n * @param {Stage} stage - the stage object\n * @param {Object} [params] - the parameters\n * @param {String} params.preset - one of \"default\", \"pymol\", \"coot\"\n * @param {String} params.disabled - flag to disable all actions\n */\n constructor (readonly stage: Stage, params: MouseControlsParams = {}) {\n this.mouse = stage.mouseObserver\n this.disabled = params.disabled || false\n this.preset(params.preset || 'default')\n }\n\n run (type: MouseActionType, ...args: any[]) {\n if (this.disabled) return\n\n const key = this.mouse.key || 0\n const button = this.mouse.buttons || 0\n\n this.actionList.forEach(a => {\n if (a.type === type && a.key === key && a.button === button) {\n (a.callback as any)(this.stage, ...args) // TODO\n }\n })\n }\n\n /**\n * Add a new mouse action triggered by an event, key and button combination.\n * The {@link MouseActions} class provides a number of static methods for\n * use as callback functions.\n *\n * @example\n * // change ambient light intensity on mouse scroll\n * // while the ctrl and shift keys are pressed\n * stage.mouseControls.add( \"scroll-ctrl+shift\", function( stage, delta ){\n * var ai = stage.getParameters().ambientIntensity;\n * stage.setParameters( { ambientIntensity: Math.max( 0, ai + delta / 50 ) } );\n * } );\n *\n * @example\n * // Call the MouseActions.zoomDrag method on mouse drag events\n * // with left and right mouse buttons simultaneous\n * stage.mouseControls.add( \"drag-left+right\", MouseActions.zoomDrag );\n *\n * @param {TriggerString} triggerStr - the trigger for the action\n * @param {function(stage: Stage, ...args: Any)} callback - the callback function for the action\n * @return {undefined}\n */\n add (triggerStr: string, callback: MouseActionCallback) {\n const [ type, key, button ] = triggerFromString(triggerStr)\n\n this.actionList.push({ type, key, button, callback })\n }\n\n /**\n * Remove a mouse action. The trigger string can contain an asterix (*)\n * as a wildcard for any key or mouse button. When the callback function\n * is given, only actions that call that function are removed.\n *\n * @example\n * // remove actions triggered solely by a scroll event\n * stage.mouseControls.remove( \"scroll\" );\n *\n * @example\n * // remove actions triggered by a scroll event, including\n * // those requiring a key pressed or mouse button used\n * stage.mouseControls.remove( \"scroll-*\" );\n *\n * @example\n * // remove actions triggered by a scroll event\n * // while the shift key is pressed\n * stage.mouseControls.remove( \"scroll-shift\" );\n *\n * @param {TriggerString} triggerStr - the trigger for the action\n * @param {Function} [callback] - the callback function for the action\n * @return {undefined}\n */\n remove (triggerStr: string, callback?: MouseActionCallback) {\n const wildcard = triggerStr.includes('*')\n const [ type, key, button ] = triggerFromString(triggerStr)\n\n const actionList = this.actionList.filter(function (a) {\n return !(\n (a.type === type || (wildcard && type === '')) &&\n (a.key === key || (wildcard && key === 0)) &&\n (a.button === button || (wildcard && button === 0)) &&\n (a.callback === callback || callback === undefined)\n )\n })\n\n this.actionList = actionList\n }\n\n /**\n * Set mouse action preset\n * @param {String} name - one of \"default\", \"pymol\", \"coot\"\n * @return {undefined}\n */\n preset (name: MouseControlPreset) {\n this.clear()\n\n const list = MouseActionPresets[ name ] || []\n\n list.forEach(action => this.add(action[0], action[1]))\n }\n\n /**\n * Remove all mouse actions\n * @return {undefined}\n */\n clear () {\n this.actionList.length = 0\n }\n}\n\nexport default MouseControls\n","/**\n * @file Key Actions\n * @author Alexander Rose \n * @private\n */\n\nimport Stage from '../stage/stage'\n\nexport type KeyActionCallback = (stage: Stage) => void\n\n/**\n * Key actions provided as static methods\n */\nclass KeyActions {\n /**\n * Stage auto view\n */\n static autoView (stage: Stage) {\n stage.autoView(1000)\n }\n\n /**\n * Toggle stage animations\n */\n static toggleAnimations (stage: Stage) {\n stage.animationControls.toggle()\n }\n\n /**\n * Toggle stage rocking\n */\n static toggleRock (stage: Stage) {\n stage.toggleRock()\n }\n\n /**\n * Toggle stage spinning\n */\n static toggleSpin (stage: Stage) {\n stage.toggleSpin()\n }\n\n /**\n * Toggle anti-aliasing\n */\n static toggleAntialiasing (stage: Stage) {\n const p = stage.getParameters()\n stage.setParameters({ sampleLevel: p.sampleLevel === -1 ? 0 : -1 })\n }\n}\n\ntype KeyActionPreset = [ string, KeyActionCallback ][]\nexport const KeyActionPresets = {\n default: [\n [ 'i', KeyActions.toggleSpin ],\n [ 'k', KeyActions.toggleRock ],\n [ 'p', KeyActions.toggleAnimations ],\n [ 'a', KeyActions.toggleAntialiasing ],\n [ 'r', KeyActions.autoView ]\n ] as KeyActionPreset\n}\n\nexport default KeyActions\n","/**\n * @file Key Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { KeyActionPresets, KeyActionCallback } from './key-actions'\nimport Stage from '../stage/stage'\n\nexport type KeyControlPreset = keyof typeof KeyActionPresets\nexport interface KeyControlsParams {\n preset?: KeyControlPreset\n disabled?: boolean\n}\n\nexport interface KeyAction {\n key: string,\n callback: KeyActionCallback\n}\n\n/**\n * Mouse controls\n */\nclass KeyControls {\n actionList: KeyAction[] = []\n\n disabled: boolean // Flag to disable all actions\n\n /**\n * @param {Stage} stage - the stage object\n * @param {Object} [params] - the parameters\n * @param {String} params.preset - one of \"default\"\n * @param {String} params.disabled - flag to disable all actions\n */\n constructor (readonly stage: Stage, params: KeyControlsParams = {}) {\n this.disabled = params.disabled || false\n this.preset(params.preset || 'default')\n }\n\n run (key: string) {\n if (this.disabled) return\n\n this.actionList.forEach(a => {\n if (a.key === key) {\n a.callback(this.stage)\n }\n })\n }\n\n /**\n * Add a key action triggered by pressing the given character.\n * The {@link KeyActions} class provides a number of static methods for\n * use as callback functions.\n *\n * @example\n * // call KeyActions.toggleRock when \"k\" is pressed\n * stage.keyControls.remove( \"k\", KeyActions.toggleRock );\n *\n * @param {Char} char - the key/character\n * @param {Function} callback - the callback function for the action\n * @return {undefined}\n */\n add (char: string, callback: KeyActionCallback) {\n this.actionList.push({ key: char, callback })\n }\n\n /**\n * Remove a key action. When the callback function\n * is given, only actions that call that function are removed.\n *\n * @example\n * // remove all actions triggered by pressing \"k\"\n * stage.keyControls.remove( \"k\" );\n *\n * @example\n * // remove action `toggleRock` triggered by pressing \"k\"\n * stage.keyControls.remove( \"k\", toggleRock );\n *\n * @param {Char} char - the key/character\n * @param {Function} [callback] - the callback function for the action\n * @return {undefined}\n */\n remove (char: string, callback: KeyActionCallback) {\n\n const actionList = this.actionList.filter(function (a) {\n return !(\n (a.key === char) &&\n (a.callback === callback || callback === undefined)\n )\n })\n\n this.actionList = actionList\n }\n\n /**\n * Set key action preset\n * @param {String} name - one of \"default\"\n * @return {undefined}\n */\n preset (name: KeyControlPreset) {\n this.clear()\n\n const list = KeyActionPresets[ name ] || []\n\n list.forEach(action => this.add(action[0], action[1]))\n }\n\n /**\n * Remove all key actions\n * @return {undefined}\n */\n clear () {\n this.actionList.length = 0\n }\n}\n\nexport default KeyControls\n","/**\n * @file Picking Behavior\n * @author Alexander Rose \n * @private\n */\n\nimport Stage from './stage'\nimport MouseObserver from './mouse-observer'\nimport Viewer from '../viewer/viewer'\nimport MouseControls from '../controls/mouse-controls'\n\nclass PickingBehavior {\n viewer: Viewer\n mouse: MouseObserver\n controls: MouseControls\n\n constructor (readonly stage: Stage) {\n this.stage = stage\n this.mouse = stage.mouseObserver\n this.controls = stage.mouseControls\n\n this.mouse.signals.clicked.add(this._onClick, this)\n this.mouse.signals.hovered.add(this._onHover, this)\n }\n\n _onClick (x: number, y: number) {\n const pickingProxy = this.stage.pickingControls.pick(x, y)\n this.stage.signals.clicked.dispatch(pickingProxy)\n this.controls.run('clickPick', pickingProxy)\n }\n\n _onHover (x: number, y: number) {\n const pickingProxy = this.stage.pickingControls.pick(x, y)\n if (pickingProxy && this.mouse.down.equals(this.mouse.position)) {\n this.stage.transformComponent = pickingProxy.component\n this.stage.transformAtom = pickingProxy.atom\n }\n this.stage.signals.hovered.dispatch(pickingProxy)\n this.controls.run('hoverPick', pickingProxy)\n }\n\n dispose () {\n this.mouse.signals.clicked.remove(this._onClick, this)\n this.mouse.signals.hovered.remove(this._onHover, this)\n }\n}\n\nexport default PickingBehavior\n","/**\n * @file Mouse Behavior\n * @author Alexander Rose \n * @private\n */\n\nimport Stage from './stage'\nimport MouseObserver from './mouse-observer'\nimport Viewer from '../viewer/viewer'\nimport MouseControls from '../controls/mouse-controls'\n\nclass MouseBehavior {\n viewer: Viewer\n mouse: MouseObserver\n controls: MouseControls\n domElement: HTMLCanvasElement\n\n constructor (readonly stage: Stage) {\n this.stage = stage\n this.mouse = stage.mouseObserver\n this.controls = stage.mouseControls\n\n this.mouse.signals.moved.add(this._onMove, this)\n this.mouse.signals.scrolled.add(this._onScroll, this)\n this.mouse.signals.dragged.add(this._onDrag, this)\n this.mouse.signals.clicked.add(this._onClick, this)\n this.mouse.signals.hovered.add(this._onHover, this)\n this.mouse.signals.doubleClicked.add(this._onDblclick, this)\n }\n\n _onMove (/* x, y */) {\n this.stage.tooltip.style.display = 'none'\n }\n\n _onScroll (delta: number) {\n this.controls.run('scroll', delta)\n }\n\n _onDrag (dx: number, dy: number) {\n this.controls.run('drag', dx, dy)\n }\n\n _onClick (x: number, y: number) {\n this.controls.run('click', x, y)\n }\n\n _onDblclick (x: number, y: number) {\n this.controls.run('doubleClick', x, y)\n }\n\n _onHover (x: number, y: number) {\n this.controls.run('hover', x, y)\n }\n\n dispose () {\n this.mouse.signals.moved.remove(this._onMove, this)\n this.mouse.signals.scrolled.remove(this._onScroll, this)\n this.mouse.signals.dragged.remove(this._onDrag, this)\n this.mouse.signals.clicked.remove(this._onClick, this)\n this.mouse.signals.hovered.remove(this._onHover, this)\n }\n}\n\nexport default MouseBehavior\n","/**\n * @file Animation Behavior\n * @author Alexander Rose \n * @private\n */\n\nimport Stage from './stage'\nimport Viewer from '../viewer/viewer'\nimport Stats from '../viewer/stats'\nimport AnimationControls from '../controls/animation-controls'\n\nclass AnimationBehavior {\n viewer: Viewer\n animationControls: AnimationControls\n\n constructor (readonly stage: Stage) {\n this.viewer = stage.viewer\n this.animationControls = stage.animationControls\n\n this.viewer.signals.ticked.add(this._onTick, this)\n }\n\n _onTick (stats: Stats) {\n this.animationControls.run(stats)\n }\n\n dispose () {\n this.viewer.signals.ticked.remove(this._onTick, this)\n }\n}\n\nexport default AnimationBehavior\n","/**\n * @file Key Behavior\n * @author Alexander Rose \n * @private\n */\n\nimport { SupportsPassiveEventHandler } from '../globals'\nimport Stage from './stage'\nimport Viewer from '../viewer/viewer'\nimport KeyControls from '../controls/key-controls'\n\nconst passive = SupportsPassiveEventHandler ? { passive: true } : false\n\nclass KeyBehavior {\n viewer: Viewer\n controls: KeyControls\n domElement: HTMLCanvasElement\n\n /**\n * @param {Stage} stage - the stage object\n */\n constructor (readonly stage: Stage) {\n this.stage = stage\n this.controls = stage.keyControls\n this.domElement = stage.viewer.renderer.domElement\n\n // ensure the domElement is focusable\n this.domElement.setAttribute('tabIndex', '-1')\n this.domElement.style.outline = 'none'\n\n this._focusDomElement = this._focusDomElement.bind(this)\n this._onKeydown = this._onKeydown.bind(this)\n this._onKeyup = this._onKeyup.bind(this)\n this._onKeypress = this._onKeypress.bind(this)\n\n this.domElement.addEventListener('mousedown', this._focusDomElement)\n this.domElement.addEventListener('touchstart', this._focusDomElement, passive as any) // TODO\n this.domElement.addEventListener('keydown', this._onKeydown)\n this.domElement.addEventListener('keyup', this._onKeyup)\n this.domElement.addEventListener('keypress', this._onKeypress)\n }\n\n /**\n * handle key down\n * @param {Event} event - key event\n * @return {undefined}\n */\n _onKeydown (/* event */) {\n // console.log( \"down\", event.keyCode, String.fromCharCode( event.keyCode ) );\n }\n\n /**\n * handle key up\n * @param {Event} event - key event\n * @return {undefined}\n */\n _onKeyup (/* event */) {\n // console.log( \"up\", event.keyCode, String.fromCharCode( event.keyCode ) );\n }\n\n /**\n * handle key press\n * @param {Event} event - key event\n * @return {undefined}\n */\n _onKeypress (event: KeyboardEvent) {\n // console.log( \"press\", event.keyCode, String.fromCharCode( event.keyCode ) );\n let pressedKey: string;\n if (\"key\" in KeyboardEvent.prototype) {\n pressedKey = event.key;\n // some mobile browsers don't support this attribute\n } else {\n pressedKey = String.fromCharCode(event.which || event.keyCode);\n }\n this.controls.run(pressedKey);\n }\n\n _focusDomElement () {\n this.domElement.focus()\n }\n\n dispose () {\n this.domElement.removeEventListener('mousedown', this._focusDomElement)\n this.domElement.removeEventListener('touchstart', this._focusDomElement, passive as any) // TODO\n this.domElement.removeEventListener('keydown', this._onKeypress)\n this.domElement.removeEventListener('keyup', this._onKeypress)\n this.domElement.removeEventListener('keypress', this._onKeypress)\n }\n}\n\nexport default KeyBehavior\n","/**\n * @file Annotation\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector2, Vector3 } from 'three'\n\nimport { defaults } from '../utils'\nimport { smoothstep } from '../math/math-utils'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\nimport Component from './component'\n\nexport interface AnnotationParams {\n offsetX?: number\n offsetY?: number\n visible?: boolean\n}\n\n/**\n * Annotation HTML element floating on top of a position rendered in 3d\n */\nexport default class Annotation {\n offsetX: number\n offsetY: number\n visible: boolean\n\n stage: Stage\n viewer: Viewer\n element: HTMLElement\n\n private _viewerPosition: Vector3\n private _canvasPosition: Vector2\n private _cameraPosition: Vector3\n private _clientRect: ClientRect\n\n /**\n * @param {Component} component - the associated component\n * @param {Vector3} position - position in 3d\n * @param {String|Element} content - HTML content\n * @param {Object} [params] - parameters\n * @param {Integer} params.offsetX - 2d offset in x direction\n * @param {Integer} params.offsetY - 2d offset in y direction\n * @param {Boolean} params.visible - visibility flag\n */\n constructor (readonly component: Component, readonly position: Vector3, content: string|HTMLElement, params: AnnotationParams = {}) {\n this.offsetX = defaults(params.offsetX, 0)\n this.offsetY = defaults(params.offsetY, 0)\n this.visible = defaults(params.visible, true)\n\n this.stage = component.stage\n this.viewer = component.stage.viewer\n\n this._viewerPosition = new Vector3()\n this._updateViewerPosition()\n this._canvasPosition = new Vector2()\n this._cameraPosition = new Vector3()\n\n this.element = document.createElement('div')\n Object.assign(this.element.style, {\n display: 'block',\n position: 'absolute',\n pointerEvents: 'none',\n whiteSpace: 'nowrap',\n left: '-10000px'\n })\n\n this.viewer.wrapper.appendChild(this.element)\n this.setContent(content)\n this.updateVisibility()\n this.viewer.signals.rendered.add(this._update, this)\n this.component.signals.matrixChanged.add(this._updateViewerPosition, this)\n }\n\n /**\n * Set HTML content of the annotation\n * @param {String|Element} value - HTML content\n * @return {undefined}\n */\n setContent (value: string|HTMLElement) {\n const displayValue = this.element.style.display\n if (displayValue === 'none') {\n this.element.style.left = '-10000px'\n this.element.style.display = 'block'\n }\n\n if (value instanceof HTMLElement) {\n this.element.appendChild(value)\n } else {\n const content = document.createElement('div')\n content.innerText = value\n Object.assign(content.style, {\n backgroundColor: 'rgba( 0, 0, 0, 0.6 )',\n color: 'lightgrey',\n padding: '8px',\n fontFamily: 'sans-serif',\n })\n this.element.appendChild(content)\n }\n\n this._clientRect = this.element.getBoundingClientRect()\n\n if (displayValue === 'none') {\n this.element.style.display = displayValue\n }\n }\n\n /**\n * Set visibility of the annotation\n * @param {Boolean} value - visibility flag\n * @return {undefined}\n */\n setVisibility (value: boolean) {\n this.visible = value\n this.updateVisibility()\n }\n\n getVisibility () {\n return this.visible && this.component.parameters.visible\n }\n\n updateVisibility () {\n this.element.style.display = this.getVisibility() ? 'block' : 'none'\n }\n\n _updateViewerPosition () {\n this._viewerPosition\n .copy(this.position)\n .applyMatrix4(this.component.matrix)\n }\n\n _update () {\n if (!this.getVisibility()) return\n\n const s = this.element.style\n const cp = this._canvasPosition\n const vp = this._viewerPosition\n const cr = this._clientRect\n\n this._cameraPosition.copy(vp)\n .add(this.viewer.translationGroup.position)\n .applyMatrix4(this.viewer.rotationGroup.matrix)\n .sub(this.viewer.camera.position)\n\n if (this._cameraPosition.z < 0) {\n s.display = 'none'\n return\n } else {\n s.display = 'block'\n }\n\n const depth = this._cameraPosition.length()\n const fog = this.viewer.scene.fog as any // TODO\n\n s.opacity = (1 - smoothstep(fog.near, fog.far, depth)).toString()\n s.zIndex = (Math.round((fog.far - depth) * 100)).toString()\n\n this.stage.viewerControls.getPositionOnCanvas(vp, cp)\n\n s.bottom = (this.offsetX + cp.y + cr.height / 2) + 'px'\n s.left = (this.offsetY + cp.x - cr.width / 2) + 'px'\n }\n\n /**\n * Safely remove the annotation\n * @return {undefined}\n */\n dispose () {\n this.viewer.wrapper.removeChild(this.element)\n this.viewer.signals.ticked.remove(this._update, this)\n this.component.signals.matrixChanged.remove(this._updateViewerPosition, this)\n }\n}","/**\n * @file Component Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4, Quaternion } from 'three'\nimport * as signalsWrapper from 'signals'\n\nimport { ensureVector3 } from '../utils'\nimport Component from '../component/component'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\n\nconst tmpRotateMatrix = new Matrix4()\nconst tmpRotateVector = new Vector3()\nconst tmpRotateQuaternion = new Quaternion()\n\n/**\n * Component controls\n */\nclass ComponentControls {\n signals = {\n changed: new signalsWrapper.Signal()\n }\n\n stage: Stage\n viewer: Viewer\n\n /**\n * @param {Component} component - the component object\n */\n constructor (readonly component: Component) {\n this.stage = component.stage\n this.viewer = component.stage.viewer\n }\n\n /**\n * component center position\n * @type {Vector3}\n */\n get position () {\n return this.component.position\n }\n\n /**\n * component rotation\n * @type {Quaternion}\n */\n get rotation () {\n return this.component.quaternion\n }\n\n /**\n * Trigger render and emit changed event\n * @emits {ComponentControls.signals.changed}\n * @return {undefined}\n */\n changed () {\n this.component.updateMatrix()\n this.viewer.requestRender()\n this.signals.changed.dispatch()\n }\n\n /**\n * spin component on axis\n * @param {Vector3|Array} axis - rotation axis\n * @param {Number} angle - amount to spin\n * @return {undefined}\n */\n spin (axis: Vector3, angle: number) {\n tmpRotateMatrix.getInverse(this.viewer.rotationGroup.matrix)\n tmpRotateVector\n .copy(ensureVector3(axis)).applyMatrix4(tmpRotateMatrix)\n\n tmpRotateMatrix.extractRotation(this.component.transform)\n tmpRotateMatrix.premultiply(this.viewer.rotationGroup.matrix)\n tmpRotateMatrix.getInverse(tmpRotateMatrix)\n\n tmpRotateVector.copy(ensureVector3(axis))\n tmpRotateVector.applyMatrix4(tmpRotateMatrix)\n tmpRotateMatrix.makeRotationAxis(tmpRotateVector, angle)\n tmpRotateQuaternion.setFromRotationMatrix(tmpRotateMatrix)\n\n this.component.quaternion.premultiply(tmpRotateQuaternion)\n this.changed()\n }\n}\n\nexport default ComponentControls\n","/**\n * @file Radius Factory\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { NucleicBackboneAtoms } from '../structure/structure-constants'\nimport AtomProxy from '../proxy/atom-proxy'\n\nexport const RadiusFactoryTypes = {\n '': '',\n 'vdw': 'by vdW radius',\n 'covalent': 'by covalent radius',\n 'sstruc': 'by secondary structure',\n 'bfactor': 'by bfactor',\n 'size': 'size',\n 'data': 'data',\n 'explicit' : 'explicit'\n}\nexport type RadiusType = keyof typeof RadiusFactoryTypes\n\nexport interface RadiusParams {\n type?: RadiusType\n scale?: number\n size?: number\n data?: { [k: number]: number }\n}\n\nclass RadiusFactory {\n max = 10\n\n static types = RadiusFactoryTypes\n\n readonly type: RadiusType\n readonly scale: number\n readonly size: number\n readonly data: { [k: number]: number }\n\n constructor (params: RadiusParams = {}) {\n this.type = defaults(params.type, 'size')\n this.scale = defaults(params.scale, 1)\n this.size = defaults(params.size, 1)\n this.data = defaults(params.data, {})\n }\n\n atomRadius (a: AtomProxy) {\n let r\n\n switch (this.type) {\n case 'vdw':\n r = a.vdw\n break\n\n case 'covalent':\n r = a.covalent\n break\n\n case 'bfactor':\n r = a.bfactor || 1.0\n break\n\n case 'sstruc':\n const sstruc = a.sstruc\n if (sstruc === 'h') {\n r = 0.25\n } else if (sstruc === 'g') {\n r = 0.25\n } else if (sstruc === 'i') {\n r = 0.25\n } else if (sstruc === 'e') {\n r = 0.25\n } else if (sstruc === 'b') {\n r = 0.25\n } else if (NucleicBackboneAtoms.includes(a.atomname)) {\n r = 0.4\n } else {\n r = 0.1\n }\n break\n\n case 'data':\n r = defaults(this.data[ a.index ], 1.0)\n break\n\n case 'explicit':\n // defaults is inappropriate as AtomProxy.radius returns\n // null for missing radii\n r = a.radius\n if (r === null) r = this.size\n break\n\n default:\n r = this.size\n break\n }\n\n return Math.min(r * this.scale, this.max)\n }\n\n}\n\nexport default RadiusFactory\n","/**\n * @file Principal Axes\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4, Quaternion } from 'three'\n\nimport {\n Matrix, meanRows, subRows, transpose, multiplyABt, svd\n} from './matrix-utils'\nimport { projectPointOnVector } from './vector-utils'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\n\nconst negateVector = new Vector3(-1, -1, -1)\nconst tmpMatrix = new Matrix4()\n\n/**\n * Principal axes\n */\nclass PrincipalAxes {\n begA: Vector3\n endA: Vector3\n begB: Vector3\n endB: Vector3\n begC: Vector3\n endC: Vector3\n\n center: Vector3\n\n vecA: Vector3\n vecB: Vector3\n vecC: Vector3\n\n normVecA: Vector3\n normVecB: Vector3\n normVecC: Vector3\n\n /**\n * @param {Matrix} points - 3 by N matrix\n */\n constructor (points: Matrix) {\n // console.time( \"PrincipalAxes\" );\n\n const n = points.rows\n const n3 = n / 3\n const pointsT = new Matrix(n, 3)\n const A = new Matrix(3, 3)\n const W = new Matrix(1, 3)\n const U = new Matrix(3, 3)\n const V = new Matrix(3, 3)\n\n // calculate\n const mean = meanRows(points)\n subRows(points, mean)\n transpose(pointsT, points)\n multiplyABt(A, pointsT, pointsT)\n svd(A, W, U, V)\n\n // console.log( points, pointsT, mean )\n // console.log( n, A, W, U, V );\n\n // center\n const vm = new Vector3(mean[0], mean[1], mean[2])\n\n // normalized\n const van = new Vector3(U.data[0], U.data[3], U.data[6])\n const vbn = new Vector3(U.data[1], U.data[4], U.data[7])\n const vcn = new Vector3(U.data[2], U.data[5], U.data[8])\n\n // scaled\n const va = van.clone().multiplyScalar(Math.sqrt(W.data[0] / n3))\n const vb = vbn.clone().multiplyScalar(Math.sqrt(W.data[1] / n3))\n const vc = vcn.clone().multiplyScalar(Math.sqrt(W.data[2] / n3))\n\n // points\n this.begA = vm.clone().sub(va)\n this.endA = vm.clone().add(va)\n this.begB = vm.clone().sub(vb)\n this.endB = vm.clone().add(vb)\n this.begC = vm.clone().sub(vc)\n this.endC = vm.clone().add(vc)\n\n //\n\n this.center = vm\n\n this.vecA = va\n this.vecB = vb\n this.vecC = vc\n\n this.normVecA = van\n this.normVecB = vbn\n this.normVecC = vcn\n\n // console.timeEnd( \"PrincipalAxes\" );\n }\n\n /**\n * Get the basis matrix descriping the axes\n * @param {Matrix4} [optionalTarget] - target object\n * @return {Matrix4} the basis\n */\n getBasisMatrix (optionalTarget = new Matrix4()) {\n const basis = optionalTarget\n\n basis.makeBasis(this.normVecB, this.normVecA, this.normVecC)\n if (basis.determinant() < 0) {\n basis.scale(negateVector)\n }\n\n return basis\n }\n\n /**\n * Get a quaternion descriping the axes rotation\n * @param {Quaternion} [optionalTarget] - target object\n * @return {Quaternion} the rotation\n */\n getRotationQuaternion (optionalTarget = new Quaternion()) {\n const q = optionalTarget\n q.setFromRotationMatrix(this.getBasisMatrix(tmpMatrix))\n\n return q.inverse()\n }\n\n /**\n * Get the scale/length for each dimension for a box around the axes\n * to enclose the atoms of a structure\n * @param {Structure|StructureView} structure - the structure\n * @return {{d1a: Number, d2a: Number, d3a: Number, d1b: Number, d2b: Number, d3b: Number}} scale\n */\n getProjectedScaleForAtoms (structure: Structure) {\n let d1a = -Infinity\n let d1b = -Infinity\n let d2a = -Infinity\n let d2b = -Infinity\n let d3a = -Infinity\n let d3b = -Infinity\n\n const p = new Vector3()\n const t = new Vector3()\n\n const center = this.center\n const ax1 = this.normVecA\n const ax2 = this.normVecB\n const ax3 = this.normVecC\n\n structure.eachAtom(function (ap: AtomProxy) {\n projectPointOnVector(p.copy(ap as any), ax1, center) // TODO\n const dp1 = t.subVectors(p, center).normalize().dot(ax1)\n const dt1 = p.distanceTo(center)\n if (dp1 > 0) {\n if (dt1 > d1a) d1a = dt1\n } else {\n if (dt1 > d1b) d1b = dt1\n }\n\n projectPointOnVector(p.copy(ap as any), ax2, center)\n const dp2 = t.subVectors(p, center).normalize().dot(ax2)\n const dt2 = p.distanceTo(center)\n if (dp2 > 0) {\n if (dt2 > d2a) d2a = dt2\n } else {\n if (dt2 > d2b) d2b = dt2\n }\n\n projectPointOnVector(p.copy(ap as any), ax3, center)\n const dp3 = t.subVectors(p, center).normalize().dot(ax3)\n const dt3 = p.distanceTo(center)\n if (dp3 > 0) {\n if (dt3 > d3a) d3a = dt3\n } else {\n if (dt3 > d3b) d3b = dt3\n }\n })\n\n return {\n d1a: d1a,\n d2a: d2a,\n d3a: d3a,\n d1b: -d1b,\n d2b: -d2b,\n d3b: -d3b\n }\n }\n}\n\nexport default PrincipalAxes\n","/**\n * @file Filtered Volume\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport Volume from './volume'\nimport { Box3, Matrix4, Matrix3, Vector3 } from 'three';\n\nclass FilteredVolume {\n volume: Volume\n data: Float32Array\n position: Float32Array\n atomindex: Int32Array\n _filterHash: string\n _dataBuffer: ArrayBuffer\n _positionBuffer: ArrayBuffer\n _atomindexBuffer: ArrayBuffer\n getValueForSigma: typeof Volume.prototype.getValueForSigma\n getSigmaForValue: typeof Volume.prototype.getSigmaForValue\n getDataAtomindex: typeof Volume.prototype.getDataAtomindex\n getDataPosition: typeof Volume.prototype.getDataPosition\n getDataColor: typeof Volume.prototype.getDataColor\n getDataPicking: typeof Volume.prototype.getDataPicking\n getDataSize: typeof Volume.prototype.getDataSize\n\n\n constructor (volume: Volume, minValue?: number, maxValue?: number, outside?: boolean) {\n this.volume = volume\n this.setFilter(minValue, maxValue, outside)\n }\n\n get header () { return this.volume.header }\n get matrix (): Matrix4 { return this.volume.matrix }\n get normalMatrix (): Matrix3 { return this.volume.normalMatrix }\n get inverseMatrix (): Matrix4 { return this.volume.inverseMatrix }\n get center (): Vector3 { return this.volume.center }\n get boundingBox (): Box3 { return this.volume.boundingBox }\n get min () { return this.volume.min }\n get max () { return this.volume.max }\n get mean () { return this.volume.mean }\n get rms () { return this.volume.rms }\n\n _getFilterHash (minValue: number, maxValue: number, outside: boolean) {\n return JSON.stringify([ minValue, maxValue, outside ])\n }\n\n setFilter (minValue: number|undefined, maxValue: number|undefined, outside: boolean|undefined) {\n if (isNaN(minValue) && this.header) {\n minValue = this.header.DMEAN + 2.0 * this.header.ARMS\n }\n\n minValue = (minValue !== undefined && !isNaN(minValue)) ? minValue : -Infinity\n maxValue = defaults(maxValue, Infinity) as number\n outside = defaults(outside, false) as boolean\n\n const data = this.volume.data\n const position = this.volume.position\n const atomindex = this.volume.atomindex\n\n const filterHash = this._getFilterHash(minValue, maxValue, outside)\n\n if (filterHash === this._filterHash) {\n // already filtered\n return\n } else if (minValue === -Infinity && maxValue === Infinity) {\n this.data = data\n this.position = position\n this.atomindex = atomindex!\n } else {\n const n = data.length\n\n if (!this._dataBuffer) {\n // ArrayBuffer for re-use as Float32Array backend\n\n this._dataBuffer = new ArrayBuffer(n * 4)\n this._positionBuffer = new ArrayBuffer(n * 3 * 4)\n if (atomindex) this._atomindexBuffer = new ArrayBuffer(n * 4)\n }\n\n const filteredData = new Float32Array(this._dataBuffer)\n const filteredPosition = new Float32Array(this._positionBuffer)\n let filteredAtomindex\n if (atomindex) filteredAtomindex = new Uint32Array(this._atomindexBuffer)\n\n let j = 0\n\n for (let i = 0; i < n; ++i) {\n const i3 = i * 3\n const v = data[ i ]\n\n if ((!outside && v >= minValue && v <= maxValue) ||\n (outside && (v < minValue || v > maxValue))\n ) {\n const j3 = j * 3\n\n filteredData[ j ] = v\n\n filteredPosition[ j3 + 0 ] = position[ i3 + 0 ]\n filteredPosition[ j3 + 1 ] = position[ i3 + 1 ]\n filteredPosition[ j3 + 2 ] = position[ i3 + 2 ]\n\n if (atomindex && filteredAtomindex) filteredAtomindex[ j ] = atomindex[ i ]\n\n j += 1\n }\n }\n\n // set views\n\n this.data = new Float32Array(this._dataBuffer, 0, j)\n this.position = new Float32Array(this._positionBuffer, 0, j * 3)\n if (atomindex) this.atomindex = new Int32Array(this._atomindexBuffer, 0, j)\n }\n\n this._filterHash = filterHash\n }\n}\n\nFilteredVolume.prototype.getValueForSigma = Volume.prototype.getValueForSigma\nFilteredVolume.prototype.getSigmaForValue = Volume.prototype.getSigmaForValue\n\nFilteredVolume.prototype.getDataAtomindex = Volume.prototype.getDataAtomindex\nFilteredVolume.prototype.getDataPosition = Volume.prototype.getDataPosition\nFilteredVolume.prototype.getDataColor = Volume.prototype.getDataColor\nFilteredVolume.prototype.getDataPicking = Volume.prototype.getDataPicking\nFilteredVolume.prototype.getDataSize = Volume.prototype.getDataSize\n\nexport default FilteredVolume\n","/**\n * @file Bond Hash\n * @author Alexander Rose \n * @private\n */\n\nimport BondStore from './bond-store'\nimport { createAdjacencyList } from '../utils/adjacency-list'\n\nclass BondHash {\n countArray: Uint8Array\n offsetArray: Int32Array\n indexArray: Int32Array\n\n constructor (bondStore: BondStore, atomCount: number) {\n const al = createAdjacencyList({\n nodeArray1: bondStore.atomIndex1,\n nodeArray2: bondStore.atomIndex2,\n edgeCount: bondStore.count,\n nodeCount: atomCount\n })\n\n this.countArray = al.countArray\n this.offsetArray = al.offsetArray\n this.indexArray = al.indexArray\n }\n}\n\nexport default BondHash\n","/**\n * @file Bond Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Bond store\n */\nexport default class BondStore extends Store {\n atomIndex1: Uint32Array\n atomIndex2: Uint32Array\n bondOrder: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'atomIndex1', 1, 'int32' ],\n [ 'atomIndex2', 1, 'int32' ],\n [ 'bondOrder', 1, 'int8' ]\n ] as StoreField[]\n }\n\n addBond (atom1: AtomProxy, atom2: AtomProxy, bondOrder?: number) {\n this.growIfFull()\n\n const i = this.count\n const ai1 = atom1.index\n const ai2 = atom2.index\n\n if (ai1 < ai2) {\n this.atomIndex1[ i ] = ai1\n this.atomIndex2[ i ] = ai2\n } else {\n this.atomIndex2[ i ] = ai1\n this.atomIndex1[ i ] = ai2\n }\n if (bondOrder) this.bondOrder[ i ] = bondOrder\n\n this.count += 1\n }\n\n addBondIfConnected (atom1: AtomProxy, atom2: AtomProxy, bondOrder?: number) {\n if (atom1.connectedTo(atom2)) {\n this.addBond(atom1, atom2, bondOrder)\n return true\n }\n\n return false\n }\n}","/**\n * @file Atom Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Atom store\n */\nexport default class AtomStore extends Store {\n residueIndex: Uint32Array\n atomTypeId: Uint16Array\n\n x: Float32Array\n y: Float32Array\n z: Float32Array\n serial: Int32Array\n bfactor: Float32Array\n altloc: Uint8Array\n occupancy: Float32Array\n\n partialCharge?: Float32Array\n formalCharge?: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'residueIndex', 1, 'uint32' ],\n [ 'atomTypeId', 1, 'uint16' ],\n\n [ 'x', 1, 'float32' ],\n [ 'y', 1, 'float32' ],\n [ 'z', 1, 'float32' ],\n [ 'serial', 1, 'int32' ],\n [ 'bfactor', 1, 'float32' ],\n [ 'altloc', 1, 'uint8' ],\n [ 'occupancy', 1, 'float32' ]\n ] as StoreField[]\n }\n\n setAltloc (i: number, str: string) {\n this.altloc[ i ] = str.charCodeAt(0)\n }\n\n getAltloc (i: number) {\n const code = this.altloc[ i ]\n return code ? String.fromCharCode(code) : ''\n }\n}","/**\n * @file Residue Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Residue store\n */\nexport default class ResidueStore extends Store {\n chainIndex: Uint32Array\n atomOffset: Uint32Array\n atomCount: Uint32Array\n residueTypeId: Uint16Array\n\n resno: Uint32Array\n sstruc: Uint8Array\n inscode: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'chainIndex', 1, 'uint32' ],\n [ 'atomOffset', 1, 'uint32' ],\n [ 'atomCount', 1, 'uint32' ],\n [ 'residueTypeId', 1, 'uint16' ],\n\n [ 'resno', 1, 'int32' ],\n [ 'sstruc', 1, 'uint8' ],\n [ 'inscode', 1, 'uint8' ]\n ] as StoreField[]\n }\n\n setSstruc (i: number, str: string) {\n this.sstruc[ i ] = str.charCodeAt(0)\n }\n\n getSstruc (i: number) {\n const code = this.sstruc[ i ]\n return code ? String.fromCharCode(code) : ''\n }\n\n setInscode (i: number, str: string) {\n this.inscode[ i ] = str.charCodeAt(0)\n }\n\n getInscode (i: number) {\n const code = this.inscode[ i ]\n return code ? String.fromCharCode(code) : ''\n }\n}","/**\n * @file Chain Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Chain store\n */\nexport default class ChainStore extends Store {\n entityIndex: Uint16Array\n modelIndex: Uint16Array\n residueOffset: Uint32Array\n residueCount: Uint32Array\n\n chainname: Uint8Array\n chainid: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'entityIndex', 1, 'uint16' ],\n [ 'modelIndex', 1, 'uint16' ],\n [ 'residueOffset', 1, 'uint32' ],\n [ 'residueCount', 1, 'uint32' ],\n\n [ 'chainname', 4, 'uint8' ],\n [ 'chainid', 4, 'uint8' ]\n ] as StoreField[]\n }\n\n setChainname (i: number, str: string) {\n const j = 4 * i\n this.chainname[ j ] = str.charCodeAt(0)\n this.chainname[ j + 1 ] = str.charCodeAt(1)\n this.chainname[ j + 2 ] = str.charCodeAt(2)\n this.chainname[ j + 3 ] = str.charCodeAt(3)\n }\n\n getChainname (i: number) {\n let chainname = ''\n for (let k = 0; k < 4; ++k) {\n const code = this.chainname[ 4 * i + k ]\n if (code) {\n chainname += String.fromCharCode(code)\n } else {\n break\n }\n }\n return chainname\n }\n\n setChainid (i: number, str: string) {\n const j = 4 * i\n this.chainid[ j ] = str.charCodeAt(0)\n this.chainid[ j + 1 ] = str.charCodeAt(1)\n this.chainid[ j + 2 ] = str.charCodeAt(2)\n this.chainid[ j + 3 ] = str.charCodeAt(3)\n }\n\n getChainid (i: number) {\n let chainid = ''\n for (let k = 0; k < 4; ++k) {\n const code = this.chainid[ 4 * i + k ]\n if (code) {\n chainid += String.fromCharCode(code)\n } else {\n break\n }\n }\n return chainid\n }\n}\n","/**\n * @file Model Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Model store\n */\nexport default class ModelStore extends Store {\n\tchainOffset: Uint32Array\n\tchainCount: Uint32Array\n\n get _defaultFields () {\n return [\n [ 'chainOffset', 1, 'uint32' ],\n [ 'chainCount', 1, 'uint32' ]\n ] as StoreField[]\n }\n}","/**\n * @file Helixorient\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport { ColormakerParameters } from '../color/colormaker'\nimport { AtomPicker } from '../utils/picker'\nimport RadiusFactory, { RadiusParams } from '../utils/radius-factory'\nimport { copyArray } from '../math/array-utils'\nimport { projectPointOnVector } from '../math/vector-utils'\nimport Polymer from '../proxy/polymer'\n\nexport interface HelixIterator {\n size: number\n next: () => Vector3\n get: (idx: number) => Vector3\n reset: () => void\n}\n\nexport interface HelixPosition {\n center: Float32Array\n axis: Float32Array\n bending: Float32Array\n radius: Float32Array\n rise: Float32Array\n twist: Float32Array\n resdir: Float32Array\n}\n\nclass Helixorient {\n size: number\n\n constructor (readonly polymer: Polymer) {\n this.size = polymer.residueCount\n }\n\n getCenterIterator (smooth = 0): HelixIterator {\n const center = this.getPosition().center\n const size = center.length / 3\n\n let i = 0\n let j = -1\n\n const cache = [\n new Vector3(),\n new Vector3(),\n new Vector3(),\n new Vector3()\n ]\n\n function next (this: HelixIterator) {\n const vector = this.get(j)\n j += 1\n return vector\n }\n\n function get (idx: number) {\n idx = Math.min(size - 1, Math.max(0, idx))\n const v = cache[ i % 4 ]\n const idx3 = 3 * idx\n v.fromArray(center as any, idx3) // TODO\n if (smooth) {\n const w = Math.min(smooth, idx, size - idx - 1)\n for (let k = 1; k <= w; ++k) {\n const l = k * 3\n const t = (w + 1 - k) / (w + 1)\n v.x += t * center[ idx3 - l + 0 ] + t * center[ idx3 + l + 0 ]\n v.y += t * center[ idx3 - l + 1 ] + t * center[ idx3 + l + 1 ]\n v.z += t * center[ idx3 - l + 2 ] + t * center[ idx3 + l + 2 ]\n }\n v.x /= w + 1\n v.y /= w + 1\n v.z /= w + 1\n }\n i += 1\n return v\n }\n\n function reset () {\n i = 0\n j = -1\n }\n\n return { size, next, get, reset }\n }\n\n getColor (params: { scheme: string } & ColormakerParameters) {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const residueIndexStart = polymer.residueIndexStart\n\n const col = new Float32Array(n * 3)\n\n const p = params || {}\n p.structure = structure\n\n const colormaker = ColormakerRegistry.getScheme(p)\n\n const rp = structure.getResidueProxy()\n const ap = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n rp.index = residueIndexStart + i\n ap.index = rp.traceAtomIndex\n\n colormaker.atomColorToArray(ap, col, i * 3)\n }\n\n return {\n 'color': col\n }\n }\n\n getPicking () {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const residueIndexStart = polymer.residueIndexStart\n\n const pick = new Float32Array(n)\n const rp = structure.getResidueProxy()\n\n for (let i = 0; i < n; ++i) {\n rp.index = residueIndexStart + i\n pick[ i ] = rp.traceAtomIndex\n }\n\n return {\n 'picking': new AtomPicker(pick, structure)\n }\n }\n\n getSize (params: RadiusParams) {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const residueIndexStart = polymer.residueIndexStart\n\n const size = new Float32Array(n)\n const radiusFactory = new RadiusFactory(params)\n\n const rp = structure.getResidueProxy()\n const ap = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n rp.index = residueIndexStart + i\n ap.index = rp.traceAtomIndex\n size[ i ] = radiusFactory.atomRadius(ap)\n }\n\n return { size }\n }\n\n getPosition (): HelixPosition {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const n3 = n - 3\n\n const center = new Float32Array(3 * n)\n const axis = new Float32Array(3 * n)\n const diff = new Float32Array(n)\n const radius = new Float32Array(n)\n const rise = new Float32Array(n)\n const twist = new Float32Array(n)\n const resdir = new Float32Array(3 * n)\n\n const r12 = new Vector3()\n const r23 = new Vector3()\n const r34 = new Vector3()\n\n const diff13 = new Vector3()\n const diff24 = new Vector3()\n\n const v1 = new Vector3()\n const v2 = new Vector3()\n const vt = new Vector3()\n\n const _axis = new Vector3()\n const _prevAxis = new Vector3()\n\n const _resdir = new Vector3()\n const _center = new Vector3(0, 0, 0)\n\n const type = 'trace'\n const a1 = structure.getAtomProxy()\n const a2 = structure.getAtomProxy(polymer.getAtomIndexByType(0, type))\n const a3 = structure.getAtomProxy(polymer.getAtomIndexByType(1, type))\n const a4 = structure.getAtomProxy(polymer.getAtomIndexByType(2, type))\n\n for (let i = 0; i < n3; ++i) {\n a1.index = a2.index\n a2.index = a3.index\n a3.index = a4.index\n a4.index = polymer.getAtomIndexByType(i + 3, type)! // TODO\n\n const j = 3 * i\n\n // ported from GROMACS src/tools/gmx_helixorient.c\n\n r12.subVectors(a2 as any, a1 as any) // TODO\n r23.subVectors(a3 as any, a2 as any) // TODO\n r34.subVectors(a4 as any, a3 as any) // TODO\n\n diff13.subVectors(r12, r23)\n diff24.subVectors(r23, r34)\n\n _axis.crossVectors(diff13, diff24).normalize()\n _axis.toArray(axis as any, j) // TODO\n\n if (i > 0) {\n diff[ i ] = _axis.angleTo(_prevAxis)\n }\n\n const tmp = Math.cos(diff13.angleTo(diff24))\n twist[ i ] = 180.0 / Math.PI * Math.acos(tmp)\n\n const diff13Length = diff13.length()\n const diff24Length = diff24.length()\n\n radius[ i ] = (\n Math.sqrt(diff24Length * diff13Length) /\n // clamp, to avoid instabilities for when\n // angle between diff13 and diff24 is near 0\n Math.max(2.0, 2.0 * (1.0 - tmp))\n )\n\n rise[ i ] = Math.abs(r23.dot(_axis))\n\n //\n\n v1.copy(diff13).multiplyScalar(radius[ i ] / diff13Length)\n v2.copy(diff24).multiplyScalar(radius[ i ] / diff24Length)\n\n v1.subVectors(a2 as any, v1) // TODO\n v2.subVectors(a3 as any, v2) // TODO\n\n v1.toArray(center as any, j + 3) // TODO\n v2.toArray(center as any, j + 6) // TODO\n\n //\n\n _resdir.subVectors(a1 as any, _center) // TODO\n _resdir.toArray(resdir as any, j) // TODO\n\n _prevAxis.copy(_axis)\n _center.copy(v1)\n }\n\n //\n\n // calc axis as dir of second and third center pos\n // project first traceAtom onto axis to get first center pos\n v1.fromArray(center as any, 3) // TODO\n v2.fromArray(center as any, 6) // TODO\n _axis.subVectors(v1, v2).normalize()\n // _center.copy( res[ 0 ].getTraceAtom() );\n a1.index = polymer.getAtomIndexByType(0, type)! // TODO\n _center.copy(a1 as any) // TODO\n vt.copy(a1 as any) // TODO\n projectPointOnVector(vt, _axis, v1)\n vt.toArray(center as any, 0) // TODO\n\n // calc first resdir\n _resdir.subVectors(_center, v1)\n _resdir.toArray(resdir as any, 0) // TODO\n\n // calc axis as dir of n-1 and n-2 center pos\n // project last traceAtom onto axis to get last center pos\n v1.fromArray(center as any, 3 * n - 6) // TODO\n v2.fromArray(center as any, 3 * n - 9) // TODO\n _axis.subVectors(v1, v2).normalize()\n // _center.copy( res[ n - 1 ].getTraceAtom() );\n a1.index = polymer.getAtomIndexByType(n - 1, type)! // TODO\n _center.copy(a1 as any) // TODO\n vt.copy(a1 as any) // TODO\n projectPointOnVector(vt, _axis, v1)\n vt.toArray(center as any, 3 * n - 3) // TODO\n\n // calc last three resdir\n for (let i = n - 3; i < n; ++i) {\n v1.fromArray(center as any, 3 * i) // TODO\n // _center.copy( res[ i ].getTraceAtom() );\n a1.index = polymer.getAtomIndexByType(i, type)! // TODO\n _center.copy(a1 as any) // TODO\n\n _resdir.subVectors(_center, v1)\n _resdir.toArray(resdir as any, 3 * i) // TODO\n }\n\n // average measures to define them on the residues\n\n const resRadius = new Float32Array(n)\n const resTwist = new Float32Array(n)\n const resRise = new Float32Array(n)\n const resBending = new Float32Array(n)\n\n resRadius[ 1 ] = radius[ 0 ]\n resTwist[ 1 ] = twist[ 0 ]\n resRise[ 1 ] = radius[ 0 ]\n\n for (let i = 2; i < n - 2; ++i) {\n resRadius[ i ] = 0.5 * (radius[ i - 2 ] + radius[ i - 1 ])\n resTwist[ i ] = 0.5 * (twist[ i - 2 ] + twist[ i - 1 ])\n resRise[ i ] = 0.5 * (rise[ i - 2 ] + rise[ i - 1 ])\n\n v1.fromArray(axis as any, 3 * (i - 2)) // TODO\n v2.fromArray(axis as any, 3 * (i - 1)) // TODO\n resBending[ i ] = 180.0 / Math.PI * Math.acos(Math.cos(v1.angleTo(v2)))\n }\n\n resRadius[ n - 2 ] = radius[ n - 4 ]\n resTwist[ n - 2 ] = twist[ n - 4 ]\n resRise[ n - 2 ] = rise[ n - 4 ]\n\n // average helix axes to define them on the residues\n\n const resAxis = new Float32Array(3 * n)\n\n copyArray(axis, resAxis, 0, 0, 3)\n copyArray(axis, resAxis, 0, 3, 3)\n\n for (let i = 2; i < n - 2; ++i) {\n v1.fromArray(axis as any, 3 * (i - 2)) // TODO\n v2.fromArray(axis as any, 3 * (i - 1)) // TODO\n\n _axis.addVectors(v2, v1).multiplyScalar(0.5).normalize()\n _axis.toArray(resAxis as any, 3 * i) // TODO\n }\n\n copyArray(axis, resAxis, 3 * n - 12, 3 * n - 6, 3)\n copyArray(axis, resAxis, 3 * n - 12, 3 * n - 3, 3)\n\n return {\n center,\n axis: resAxis,\n bending: resBending,\n radius: resRadius,\n rise: resRise,\n twist: resTwist,\n resdir: resdir\n }\n }\n\n}\n\nexport default Helixorient\n","/**\n * @file Helixbundle\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport { AtomPicker } from '../utils/picker'\nimport RadiusFactory, { RadiusParams } from '../utils/radius-factory'\nimport Helixorient, { HelixPosition } from './helixorient'\nimport { calculateMeanVector3, projectPointOnVector } from '../math/vector-utils'\nimport Polymer from '../proxy/polymer'\nimport { ColormakerParameters } from '../color/colormaker';\n\nexport interface Axis {\n axis: Float32Array\n center: Float32Array\n begin: Float32Array\n end: Float32Array\n color: Float32Array\n picking: AtomPicker\n size: Float32Array\n residueOffset: number[]\n residueCount: number[]\n}\n\nclass Helixbundle {\n helixorient: Helixorient;\n position: HelixPosition;\n\n constructor (readonly polymer: Polymer) {\n\n this.helixorient = new Helixorient(polymer)\n this.position = this.helixorient.getPosition()\n }\n\n getAxis (localAngle: number, centerDist: number, ssBorder: boolean, colorParams: { scheme: string} & ColormakerParameters, radiusParams: RadiusParams): Axis {\n localAngle = localAngle || 30\n centerDist = centerDist || 2.5\n ssBorder = ssBorder === undefined ? false : ssBorder\n\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const residueIndexStart = polymer.residueIndexStart\n\n const pos = this.position\n\n const cp = colorParams || {}\n cp.structure = structure\n\n const colormaker = ColormakerRegistry.getScheme(cp)\n\n const radiusFactory = new RadiusFactory(radiusParams)\n\n let j = 0\n let k = 0\n\n const axis: number[] = []\n const center: number[] = []\n const beg: number[] = []\n const end: number[] = []\n const col: number[] = []\n const pick = []\n const size = []\n const residueOffset = []\n const residueCount = []\n\n let tmpAxis = new Float32Array(n * 3)\n let tmpCenter = new Float32Array(n * 3)\n\n let _axis, _center\n const _beg = new Vector3()\n const _end = new Vector3()\n\n const rp1 = structure.getResidueProxy()\n const rp2 = structure.getResidueProxy()\n const ap = structure.getAtomProxy()\n\n const c1 = new Vector3()\n const c2 = new Vector3()\n\n let split = false\n\n for (let i = 0; i < n; ++i) {\n rp1.index = residueIndexStart + i\n c1.fromArray(pos.center as any, i * 3)\n\n if (i === n - 1) {\n split = true\n } else {\n rp2.index = residueIndexStart + i + 1\n c2.fromArray(pos.center as any, i * 3 + 3)\n\n if (ssBorder && rp1.sstruc !== rp2.sstruc) {\n split = true\n } else if (c1.distanceTo(c2) > centerDist) {\n split = true\n } else if (pos.bending[ i ] > localAngle) {\n split = true\n }\n }\n\n if (split) {\n if (i - j < 4) {\n j = i\n split = false\n continue\n }\n\n ap.index = rp1.traceAtomIndex\n\n // ignore first and last axis\n tmpAxis = pos.axis.subarray(j * 3 + 3, i * 3)\n tmpCenter = pos.center.subarray(j * 3, i * 3 + 3)\n\n _axis = calculateMeanVector3(tmpAxis).normalize()\n _center = calculateMeanVector3(tmpCenter)\n\n _beg.fromArray(tmpCenter as any)\n projectPointOnVector(_beg, _axis, _center)\n\n _end.fromArray(tmpCenter as any, tmpCenter.length - 3)\n projectPointOnVector(_end, _axis, _center)\n\n _axis.subVectors(_end, _beg)\n\n _axis.toArray(axis as any, k)\n _center.toArray(center as any, k)\n _beg.toArray(beg as any, k)\n _end.toArray(end as any, k)\n\n colormaker.atomColorToArray(ap, col, k)\n\n pick.push(ap.index)\n\n size.push(radiusFactory.atomRadius(ap))\n\n residueOffset.push(residueIndexStart + j)\n residueCount.push(residueIndexStart + i + 1 - j)\n\n k += 3\n j = i\n split = false\n }\n }\n\n const picking = new Float32Array(pick)\n\n return {\n axis: new Float32Array(axis),\n center: new Float32Array(center),\n begin: new Float32Array(beg),\n end: new Float32Array(end),\n color: new Float32Array(col),\n picking: new AtomPicker(picking, structure),\n size: new Float32Array(size),\n residueOffset: residueOffset,\n residueCount: residueCount\n }\n }\n}\n\nexport default Helixbundle\n","/**\n * @file Binary Heap\n * @author Alexander Rose \n * @private\n */\n\n/**\n * Binary heap implementation\n * @class\n * @author http://eloquentjavascript.net/appendix2.htm\n * @param {Function} scoreFunction - the heap scoring function\n */\nclass BinaryHeap {\n content: T[] = []\n\n constructor(readonly scoreFunction: (x: T) => number) {\n\n this.scoreFunction = scoreFunction\n }\n\n push (element: T) {\n // Add the new element to the end of the array.\n this.content.push(element)\n\n // Allow it to bubble up.\n this.bubbleUp(this.content.length - 1)\n }\n\n pop () {\n // Store the first element so we can return it later.\n const result = this.content[ 0 ]\n\n // Get the element at the end of the array.\n const end = this.content.pop()\n\n // If there are any elements left, put the end element at the\n // start, and let it sink down.\n if (end && this.content.length > 0) {\n this.content[ 0 ] = end\n this.sinkDown(0)\n }\n\n return result\n }\n\n peek () {\n return this.content[ 0 ]\n }\n\n remove (element: T) {\n const len = this.content.length\n\n // To remove a value, we must search through the array to find it.\n for (let i = 0; i < len; i++) {\n if (this.content[ i ] === element) {\n // When it is found, the process seen in 'pop' is repeated\n // to fill up the hole.\n const end = this.content.pop()\n\n if (end && i !== len - 1) {\n this.content[ i ] = end\n\n if (this.scoreFunction(end) < this.scoreFunction(element)) {\n this.bubbleUp(i)\n } else {\n this.sinkDown(i)\n }\n }\n\n return\n }\n }\n\n throw new Error('Node not found.')\n }\n\n size () {\n return this.content.length\n }\n\n bubbleUp (n: number) {\n // Fetch the element that has to be moved.\n const element = this.content[ n ]\n\n // When at 0, an element can not go up any further.\n while (n > 0) {\n // Compute the parent element's index, and fetch it.\n const parentN = Math.floor((n + 1) / 2) - 1\n const parent = this.content[ parentN ]\n\n // Swap the elements if the parent is greater.\n if (this.scoreFunction(element) < this.scoreFunction(parent)) {\n this.content[ parentN ] = element\n this.content[ n ] = parent\n\n // Update 'n' to continue at the new position.\n n = parentN\n } else {\n // Found a parent that is less, no need to move it further.\n break\n }\n }\n }\n\n sinkDown (n: number) {\n // Look up the target element and its score.\n const length = this.content.length\n const element = this.content[ n ]\n const elemScore = this.scoreFunction(element)\n\n let child1Score = 0\n let child2Score = 0\n\n while (true) {\n // Compute the indices of the child elements.\n const child2N = (n + 1) * 2\n const child1N = child2N - 1\n\n // This is used to store the new position of the element, if any.\n let swap = null\n\n // If the first child exists (is inside the array)...\n if (child1N < length) {\n // Look it up and compute its score.\n const child1 = this.content[ child1N ]\n child1Score = this.scoreFunction(child1)\n\n // If the score is less than our element's, we need to swap.\n if (child1Score < elemScore) swap = child1N\n }\n\n // Do the same checks for the other child.\n if (child2N < length) {\n const child2 = this.content[ child2N ]\n child2Score = this.scoreFunction(child2)\n\n if (child2Score < (swap === null ? elemScore : child1Score)) swap = child2N\n }\n\n // If the element needs to be moved, swap it, and continue.\n if (swap !== null) {\n this.content[ n ] = this.content[ swap ]\n this.content[ swap ] = element\n n = swap\n } else {\n // Otherwise, we are done.\n break\n }\n }\n }\n\n}\n\nexport default BinaryHeap\n","/**\n * @file Kdtree\n * @author Alexander Rose \n * @private\n */\n\nimport { NumberArray } from '../types'\nimport BinaryHeap from './binary-heap'\n\n/**\n * Kdtree\n * @class\n * @author Alexander Rose , 2016\n * @author Roman Bolzern , 2013\n * @author I4DS http://www.fhnw.ch/i4ds, 2013\n * @license MIT License \n * @description\n * k-d Tree for typed arrays of 3d points (e.g. for Float32Array), in-place\n * provides fast nearest neighbour search\n *\n * Based on https://github.com/ubilabs/kd-tree-javascript by Ubilabs\n *\n * Further information (including mathematical properties)\n * http://en.wikipedia.org/wiki/Binary_tree\n * http://en.wikipedia.org/wiki/K-d_tree\n *\n * @example\n * points: [x, y, z, x, y, z, x, y, z, ...]\n * metric: function(a, b){\n * return Math.pow(a[0]-b[0], 2) + Math.pow(a[1]-b[1], 2) + Math.pow(a[2]-b[2], 2);\n * }\n *\n * @param {Float32Array} points - points\n * @param {Function} metric - metric\n */\nclass Kdtree {\n indices: Uint32Array\n nodes: Int32Array\n rootIndex: number\n\n maxDepth = 0\n currentNode = 0\n\n constructor(readonly points: NumberArray, readonly metric: (a: NumberArray, b: NumberArray) => number) {\n const n = points.length / 3\n\n const indices = new Uint32Array(n)\n for (let i = 0; i < n; ++i) {\n indices[ i ] = i\n }\n this.indices = indices\n this.nodes = new Int32Array(n * 4)\n this.rootIndex = this.buildTree(0, -1, 0, n)\n }\n\n buildTree (depth: number, parent: number, arrBegin: number, arrEnd: number) {\n if (depth > this.maxDepth) this.maxDepth = depth\n\n const plength = arrEnd - arrBegin\n if (plength === 0) {\n return -1\n }\n\n const nodeIndex = this.currentNode * 4\n const nodes = this.nodes\n\n this.currentNode += 1\n if (plength === 1) {\n nodes[ nodeIndex ] = arrBegin\n nodes[ nodeIndex + 1 ] = -1\n nodes[ nodeIndex + 2 ] = -1\n nodes[ nodeIndex + 3 ] = parent\n return nodeIndex\n }\n // if(plength <= 32){\n // return nodeIndex;\n // }\n\n const indices = this.indices\n const points = this.points\n\n const arrMedian = arrBegin + Math.floor(plength / 2)\n const currentDim = depth % 3\n\n // inlined quickselect function\n let j, tmp, pivotIndex, pivotValue, storeIndex\n let left = arrBegin\n let right = arrEnd - 1\n while (right > left) {\n pivotIndex = (left + right) >> 1\n pivotValue = points[ indices[ pivotIndex ] * 3 + currentDim ]\n // swap( pivotIndex, right );\n tmp = indices[ pivotIndex ]\n indices[ pivotIndex ] = indices[ right ]\n indices[ right ] = tmp\n storeIndex = left\n for (j = left; j < right; ++j) {\n if (points[ indices[ j ] * 3 + currentDim ] < pivotValue) {\n // swap( storeIndex, j );\n tmp = indices[ storeIndex ]\n indices[ storeIndex ] = indices[ j ]\n indices[ j ] = tmp\n ++storeIndex\n }\n }\n // swap( right, storeIndex );\n tmp = indices[ right ]\n indices[ right ] = indices[ storeIndex ]\n indices[ storeIndex ] = tmp\n pivotIndex = storeIndex\n if (arrMedian === pivotIndex) {\n break\n } else if (arrMedian < pivotIndex) {\n right = pivotIndex - 1\n } else {\n left = pivotIndex + 1\n }\n }\n\n nodes[ nodeIndex ] = arrMedian\n nodes[ nodeIndex + 1 ] = this.buildTree(depth + 1, nodeIndex, arrBegin, arrMedian)\n nodes[ nodeIndex + 2 ] = this.buildTree(depth + 1, nodeIndex, arrMedian + 1, arrEnd)\n nodes[ nodeIndex + 3 ] = parent\n\n return nodeIndex\n }\n\n getNodeDepth (nodeIndex: number): number {\n const parentIndex = this.nodes[ nodeIndex + 3 ]\n return (parentIndex === -1) ? 0 : this.getNodeDepth(parentIndex) + 1\n }\n\n // TODO\n // function getNodePos (node) {}\n\n /**\n * find nearest points\n * @param {Array} point - array of size 3\n * @param {Integer} maxNodes - max amount of nodes to return\n * @param {Float} maxDistance - maximum distance of point to result nodes\n * @return {Array} array of point, distance pairs\n */\n nearest (point: NumberArray, maxNodes: number, maxDistance: number) {\n const bestNodes = new BinaryHeap<[number, number]>(e => -e[ 1 ])\n\n const nodes = this.nodes\n const points = this.points\n const indices = this.indices\n\n const nearestSearch = (nodeIndex: number) => {\n let bestChild, otherChild\n const dimension = this.getNodeDepth(nodeIndex) % 3\n const pointIndex = indices[ nodes[ nodeIndex ] ] * 3\n const ownPoint = [\n points[ pointIndex + 0 ],\n points[ pointIndex + 1 ],\n points[ pointIndex + 2 ]\n ]\n const ownDistance = this.metric(point, ownPoint)\n\n function saveNode (nodeIndex: number, distance: number) {\n bestNodes.push([ nodeIndex, distance ])\n if (bestNodes.size() > maxNodes) {\n bestNodes.pop()\n }\n }\n\n const leftIndex = nodes[ nodeIndex + 1 ]\n const rightIndex = nodes[ nodeIndex + 2 ]\n\n // if it's a leaf\n if (rightIndex === -1 && leftIndex === -1) {\n if ((bestNodes.size() < maxNodes || ownDistance < bestNodes.peek()[ 1 ]) &&\n ownDistance <= maxDistance\n ) {\n saveNode(nodeIndex, ownDistance)\n }\n return\n }\n\n if (rightIndex === -1) {\n bestChild = leftIndex\n } else if (leftIndex === -1) {\n bestChild = rightIndex\n } else {\n if (point[ dimension ] <= points[ pointIndex + dimension ]) {\n bestChild = leftIndex\n } else {\n bestChild = rightIndex\n }\n }\n\n // recursive search\n nearestSearch(bestChild)\n\n if ((bestNodes.size() < maxNodes || ownDistance < bestNodes.peek()[ 1 ]) &&\n ownDistance <= maxDistance\n ) {\n saveNode(nodeIndex, ownDistance)\n }\n\n // if there's still room or the current distance is nearer than the best distance\n const linearPoint = []\n for (let i = 0; i < 3; i += 1) {\n if (i === dimension) {\n linearPoint[ i ] = point[ i ]\n } else {\n linearPoint[ i ] = points[ pointIndex + i ]\n }\n }\n const linearDistance = this.metric(linearPoint, ownPoint)\n\n if ((bestNodes.size() < maxNodes || Math.abs(linearDistance) < bestNodes.peek()[ 1 ]) &&\n Math.abs(linearDistance) <= maxDistance\n ) {\n if (bestChild === leftIndex) {\n otherChild = rightIndex\n } else {\n otherChild = leftIndex\n }\n if (otherChild !== -1) {\n nearestSearch(otherChild)\n }\n }\n }\n\n nearestSearch(this.rootIndex)\n\n const result = []\n for (let i = 0, il = Math.min(bestNodes.size(), maxNodes); i < il; i += 1) {\n result.push(bestNodes.content[ i ])\n }\n\n return result\n }\n\n verify (nodeIndex?: number, depth = 0) {\n let count = 1\n\n if (nodeIndex === undefined) {\n nodeIndex = this.rootIndex\n }\n\n if (nodeIndex === -1) {\n throw new Error('node is null')\n }\n\n const dim = depth % 3\n const nodes = this.nodes\n const points = this.points\n const indices = this.indices\n\n const leftIndex = nodes[ nodeIndex + 1 ]\n const rightIndex = nodes[ nodeIndex + 2 ]\n\n if (leftIndex !== -1) {\n if (points[ indices[ nodes[ leftIndex ] ] * 3 + dim ] >\n points[ indices[ nodes[ nodeIndex ] ] * 3 + dim ]\n ) {\n throw new Error('left child is > parent!')\n }\n count += this.verify(leftIndex, depth + 1)\n }\n\n if (rightIndex !== -1) {\n if (points[ indices[ nodes[ rightIndex ] ] * 3 + dim ] <\n points[ indices[ nodes[ nodeIndex ] ] * 3 + dim ]\n ) {\n throw new Error('right child is < parent!')\n }\n count += this.verify(rightIndex, depth + 1)\n }\n\n return count\n }\n}\n\nexport default Kdtree\n","/**\n * @file Atom Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { NumberArray } from '../types'\nimport {\n Elements,\n SecStrucHelix, SecStrucSheet, SecStrucTurn,\n ProteinType, RnaType, DnaType, WaterType, IonType, SaccharideType,\n CgProteinBackboneType, CgRnaBackboneType, CgDnaBackboneType\n} from '../structure/structure-constants'\n\nimport Structure from '../structure/structure'\n\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\nimport AtomStore from '../store/atom-store'\n\nimport AtomMap from '../store/atom-map'\nimport ResidueMap from '../store/residue-map'\n\nimport BondProxy from '../proxy/bond-proxy'\nimport AtomType from '../store/atom-type';\nimport ResidueType from '../store/residue-type';\nimport ResidueProxy from './residue-proxy';\nimport Entity from '../structure/entity';\nimport BondHash from '../store/bond-hash';\n\n/**\n * Atom proxy\n */\nclass AtomProxy {\n index: number\n\n chainStore: ChainStore\n residueStore: ResidueStore\n atomStore: AtomStore\n\n residueMap: ResidueMap\n atomMap: AtomMap\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n this.atomStore = structure.atomStore\n this.residueMap = structure.residueMap\n this.atomMap = structure.atomMap\n }\n\n /**\n * @type {BondHash}\n */\n get bondHash (): BondHash|undefined { return this.structure.bondHash }\n\n /**\n * Molecular enity\n * @type {Entity}\n */\n get entity (): Entity {\n return this.structure.entityList[ this.entityIndex ]\n }\n get entityIndex () {\n return this.chainStore.entityIndex[ this.chainIndex ]\n }\n get modelIndex () {\n return this.chainStore.modelIndex[ this.chainIndex ]\n }\n get chainIndex () {\n return this.residueStore.chainIndex[ this.residueIndex ]\n }\n /**\n * @type {ResidueProxy}\n */\n get residue (): ResidueProxy {\n console.warn('residue - might be expensive')\n return this.structure.getResidueProxy(this.residueIndex)\n }\n\n get residueIndex () {\n return this.atomStore.residueIndex[ this.index ]\n }\n set residueIndex (value) {\n this.atomStore.residueIndex[ this.index ] = value\n }\n\n //\n\n /**\n * Secondary structure code\n * @type {String}\n */\n get sstruc () {\n return this.residueStore.getSstruc(this.residueIndex)\n }\n /**\n * Insertion code\n * @type {String}\n */\n get inscode () {\n return this.residueStore.getInscode(this.residueIndex)\n }\n /**\n * Residue number/label\n * @type {Integer}\n */\n get resno () {\n return this.residueStore.resno[ this.residueIndex ]\n }\n /**\n * Chain name\n * @type {String}\n */\n get chainname () {\n return this.chainStore.getChainname(this.chainIndex)\n }\n /**\n * Chain id\n * @type {String}\n */\n get chainid () {\n return this.chainStore.getChainid(this.chainIndex)\n }\n\n //\n\n /**\n * @type {ResidueType}\n */\n get residueType (): ResidueType {\n return this.residueMap.get(this.residueStore.residueTypeId[ this.residueIndex ])\n }\n /**\n * @type {AtomType}\n */\n get atomType (): AtomType {\n return this.atomMap.get(this.atomStore.atomTypeId[ this.index ])\n }\n get residueAtomOffset () {\n return this.residueStore.atomOffset[ this.residueIndex ]\n }\n\n //\n\n /**\n * Residue name\n */\n get resname () {\n return this.residueType.resname\n }\n /**\n * Hetero flag\n */\n get hetero () {\n return this.residueType.hetero\n }\n\n //\n\n /**\n * Atom name\n */\n get atomname () {\n return this.atomType.atomname\n }\n /**\n * Atomic number\n */\n get number () {\n return this.atomType.number\n }\n /**\n * Element\n */\n get element () {\n return this.atomType.element\n }\n /**\n * Van-der-Waals radius\n */\n get vdw () {\n return this.atomType.vdw\n }\n /**\n * Covalent radius\n */\n get covalent () {\n return this.atomType.covalent\n }\n\n //\n\n /**\n * X coordinate\n */\n get x () {\n return this.atomStore.x[ this.index ]\n }\n set x (value) {\n this.atomStore.x[ this.index ] = value\n }\n\n /**\n * Y coordinate\n */\n get y () {\n return this.atomStore.y[ this.index ]\n }\n set y (value) {\n this.atomStore.y[ this.index ] = value\n }\n\n /**\n * Z coordinate\n */\n get z () {\n return this.atomStore.z[ this.index ]\n }\n set z (value) {\n this.atomStore.z[ this.index ] = value\n }\n\n /**\n * Serial number\n */\n get serial () {\n return this.atomStore.serial[ this.index ]\n }\n set serial (value) {\n this.atomStore.serial[ this.index ] = value\n }\n\n /**\n * B-factor value\n */\n get bfactor () {\n return this.atomStore.bfactor[ this.index ]\n }\n set bfactor (value) {\n this.atomStore.bfactor[ this.index ] = value\n }\n\n /**\n * Occupancy value\n */\n get occupancy () {\n return this.atomStore.occupancy[ this.index ]\n }\n set occupancy (value) {\n this.atomStore.occupancy[ this.index ] = value\n }\n\n /**\n * Alternate location identifier\n */\n get altloc () {\n return this.atomStore.getAltloc(this.index)\n }\n set altloc (value) {\n this.atomStore.setAltloc(this.index, value)\n }\n\n /**\n * Partial charge\n */\n get partialCharge () {\n return this.atomStore.partialCharge ? this.atomStore.partialCharge[ this.index ] : null\n }\n set partialCharge (value) {\n if (this.atomStore.partialCharge) {\n this.atomStore.partialCharge[ this.index ] = value as number\n }\n }\n\n /**\n * Explicit radius\n */\n get radius () {\n return this.atomStore.radius ? this.atomStore.radius[ this.index ] : null\n }\n set radius (value) {\n if (this.atomStore.radius) {\n this.atomStore.radius[ this.index ] = value as number\n }\n }\n\n /**\n * Formal charge\n */\n get formalCharge () {\n return this.atomStore.formalCharge ? this.atomStore.formalCharge[ this.index ] : null\n }\n set formalCharge (value) {\n if (this.atomStore.formalCharge) {\n this.atomStore.formalCharge[ this.index ] = value as number\n }\n }\n\n /**\n * Aromaticity flag\n */\n get aromatic () {\n if (this.atomStore.aromatic) {\n return this.atomStore.aromatic[ this.index ] as number\n } else {\n return this.residueType.isAromatic(this) ? 1 : 0\n }\n }\n set aromatic (value) {\n if (this.atomStore.aromatic) {\n this.atomStore.aromatic[ this.index ] = value as number\n }\n }\n\n //\n\n get bondCount () {\n return this.bondHash!.countArray[ this.index ] // TODO\n }\n\n //\n\n /**\n * Iterate over each bond\n * @param {function(bond: BondProxy)} callback - iterator callback function\n * @param {BondProxy} [bp] - optional target bond proxy for use in the callback\n * @return {undefined}\n */\n eachBond (callback: (bp: BondProxy) => void, bp?: BondProxy) {\n bp = bp || this.structure._bp\n const idx = this.index\n const bondHash = this.bondHash! // TODO\n const indexArray = bondHash.indexArray\n const n = bondHash.countArray[ idx ]\n const offset = bondHash.offsetArray[ idx ]\n\n for (let i = 0; i < n; ++i) {\n bp.index = indexArray[ offset + i ]\n callback(bp)\n }\n }\n\n /**\n * Iterate over each bonded atom\n * @param {function(atom: AtomProxy)} callback - iterator callback function\n * @param {AtomProxy} [ap] - optional target atom proxy for use in the callback\n * @return {undefined}\n */\n eachBondedAtom (callback: (ap: AtomProxy) => void, _ap?: AtomProxy) {\n const ap = _ap ? _ap : this.structure._ap\n const idx = this.index\n\n this.eachBond(function (bp) {\n ap.index = idx !== bp.atomIndex1 ? bp.atomIndex1 : bp.atomIndex2\n callback(ap)\n })\n this.index = idx\n }\n\n /**\n * Check if this atom is bonded to the given atom,\n * assumes both atoms are from the same structure\n * @param {AtomProxy} ap - the given atom\n * @return {Boolean} whether a bond exists or not\n */\n hasBondTo (ap: AtomProxy) {\n let flag = false\n this.eachBondedAtom(function (bap) {\n if (ap.index === bap.index) flag = true\n })\n return flag\n }\n\n bondToElementCount (element: Elements) {\n let count = 0\n const idx = this.index // Avoid reentrancy problems\n this.eachBondedAtom(function (bap) {\n if (bap.number === element) count += 1\n })\n this.index = idx\n return count\n }\n\n hasBondToElement (element: Elements) {\n return this.bondToElementCount(element) > 0\n }\n\n //\n\n /**\n * If atom is part of a backbone\n * @return {Boolean} flag\n */\n isBackbone () {\n const backboneIndexList = this.residueType.backboneIndexList\n if (backboneIndexList.length > 0) {\n return backboneIndexList.includes(this.index - this.residueAtomOffset)\n } else {\n return false\n }\n }\n\n /**\n * If atom is part of a polymer\n * @return {Boolean} flag\n */\n isPolymer () {\n if (this.structure.entityList.length > 0) {\n return this.entity.isPolymer()\n } else {\n const moleculeType = this.residueType.moleculeType\n return (\n moleculeType === ProteinType ||\n moleculeType === RnaType ||\n moleculeType === DnaType\n )\n }\n }\n\n /**\n * If atom is part of a sidechin\n * @return {Boolean} flag\n */\n isSidechain () {\n return this.isPolymer() && !this.isBackbone()\n }\n\n /**\n * If atom is part of a coarse-grain group\n * @return {Boolean} flag\n */\n isCg () {\n const backboneType = this.residueType.backboneType\n return (\n backboneType === CgProteinBackboneType ||\n backboneType === CgRnaBackboneType ||\n backboneType === CgDnaBackboneType\n )\n }\n\n isTrace () {\n return this.index === (this.residueType.traceAtomIndex + this.residueAtomOffset)\n }\n\n /**\n * If atom is part of a hetero group\n * @return {Boolean} flag\n */\n isHetero () {\n return this.residueType.hetero === 1\n }\n\n /**\n * If atom is part of a protein molecule\n * @return {Boolean} flag\n */\n isProtein () {\n return this.residueType.moleculeType === ProteinType\n }\n\n /**\n * If atom is part of a nucleic molecule\n * @return {Boolean} flag\n */\n isNucleic () {\n const moleculeType = this.residueType.moleculeType\n return moleculeType === RnaType || moleculeType === DnaType\n }\n\n /**\n * If atom is part of a rna\n * @return {Boolean} flag\n */\n isRna () {\n return this.residueType.moleculeType === RnaType\n }\n\n /**\n * If atom is part of a dna\n * @return {Boolean} flag\n */\n isDna () {\n return this.residueType.moleculeType === DnaType\n }\n\n /**\n * If atom is part of a water molecule\n * @return {Boolean} flag\n */\n isWater () {\n return this.residueType.moleculeType === WaterType\n }\n\n /**\n * If atom is part of an ion\n * @return {Boolean} flag\n */\n isIon () {\n return this.residueType.moleculeType === IonType\n }\n\n /**\n * If atom is part of a saccharide\n * @return {Boolean} flag\n */\n isSaccharide () {\n return this.residueType.moleculeType === SaccharideType\n }\n\n /**\n * If atom is part of a helix\n * @return {Boolean} flag\n */\n isHelix () {\n return SecStrucHelix.includes(this.sstruc)\n }\n\n /**\n * If atom is part of a sheet\n * @return {Boolean} flag\n */\n isSheet () {\n return SecStrucSheet.includes(this.sstruc)\n }\n\n /**\n * If atom is part of a turn\n * @return {Boolean} flag\n */\n isTurn () {\n return SecStrucTurn.includes(this.sstruc) && this.isProtein()\n }\n\n isBonded () {\n return this.bondHash!.countArray[ this.index ] !== 0 // TODO\n }\n\n /**\n * If atom is part of a ring\n * @return {Boolean} flag\n */\n isRing () {\n const atomRings = this.residueType.getRings()!.atomRings // TODO\n return atomRings[ this.index - this.residueAtomOffset ] !== undefined\n }\n\n isAromatic () {\n return this.aromatic === 1\n }\n\n isPolarHydrogen () {\n let result = false\n\n if (this.number !== 1) return result\n\n result = !this.hasBondToElement(Elements.C)\n\n return result\n }\n\n isMetal () { return this.atomType.isMetal() }\n isNonmetal () { return this.atomType.isNonmetal() }\n isMetalloid () { return this.atomType.isMetalloid() }\n isHalogen () { return this.atomType.isHalogen() }\n isDiatomicNonmetal () { return this.atomType.isDiatomicNonmetal() }\n isPolyatomicNonmetal () { return this.atomType.isPolyatomicNonmetal() }\n isAlkaliMetal () { return this.atomType.isAlkaliMetal() }\n isAlkalineEarthMetal () { return this.atomType.isAlkalineEarthMetal() }\n isNobleGas () { return this.atomType.isNobleGas() }\n isTransitionMetal () { return this.atomType.isTransitionMetal() }\n isPostTransitionMetal () { return this.atomType.isPostTransitionMetal() }\n isLanthanide () { return this.atomType.isLanthanide() }\n isActinide () { return this.atomType.isActinide() }\n\n getDefaultValence () { return this.atomType.getDefaultValence() }\n getValenceList () { return this.atomType.getValenceList() }\n getOuterShellElectronCount () { return this.atomType.getOuterShellElectronCount() }\n\n /**\n * Distance to another atom\n * @param {AtomProxy} atom - the other atom\n * @return {Number} the distance\n */\n distanceTo (atom: AtomProxy) {\n const taa = this.atomStore\n const aaa = atom.atomStore\n const ti = this.index\n const ai = atom.index\n const x = taa.x[ ti ] - aaa.x[ ai ]\n const y = taa.y[ ti ] - aaa.y[ ai ]\n const z = taa.z[ ti ] - aaa.z[ ai ]\n const distSquared = x * x + y * y + z * z\n return Math.sqrt(distSquared)\n }\n\n /**\n * If connected to another atom\n * @param {AtomProxy} atom - the other atom\n * @return {Boolean} flag\n */\n connectedTo (atom: AtomProxy) {\n const taa = this.atomStore\n const aaa = atom.atomStore\n const ti = this.index\n const ai = atom.index\n\n if (taa.altloc && aaa.altloc) {\n const ta = taa.altloc[ ti ] // use Uint8 value to compare\n const aa = aaa.altloc[ ai ] // no need to convert to char\n // 0 is the Null character, 32 is the space character\n if (!(ta === 0 || aa === 0 || ta === 32 || aa === 32 || (ta === aa))) return false\n }\n\n const x = taa.x[ ti ] - aaa.x[ ai ]\n const y = taa.y[ ti ] - aaa.y[ ai ]\n const z = taa.z[ ti ] - aaa.z[ ai ]\n\n const distSquared = x * x + y * y + z * z\n\n // if( this.isCg() ) console.log( this.qualifiedName(), Math.sqrt( distSquared ), distSquared )\n if (distSquared < 48.0 && this.isCg()) return true\n\n if (isNaN(distSquared)) return false\n\n const d = this.covalent + atom.covalent\n const d1 = d + 0.3\n const d2 = d - 0.5\n\n return distSquared < (d1 * d1) && distSquared > (d2 * d2)\n }\n\n /**\n * Set atom position from array\n * @param {Array|TypedArray} array - input array\n * @param {Integer} [offset] - the offset\n * @return {AtomProxy} this object\n */\n positionFromArray (array: NumberArray, offset = 0) {\n this.x = array[ offset + 0 ]\n this.y = array[ offset + 1 ]\n this.z = array[ offset + 2 ]\n\n return this\n }\n\n /**\n * Write atom position to array\n * @param {Array|TypedArray} [array] - target array\n * @param {Integer} [offset] - the offset\n * @return {Array|TypedArray} target array\n */\n positionToArray (array: NumberArray = [], offset = 0) {\n const index = this.index\n const atomStore = this.atomStore\n\n array[ offset + 0 ] = atomStore.x[ index ]\n array[ offset + 1 ] = atomStore.y[ index ]\n array[ offset + 2 ] = atomStore.z[ index ]\n\n return array\n }\n\n /**\n * Write atom position to vector\n * @param {Vector3} [v] - target vector\n * @return {Vector3} target vector\n */\n positionToVector3 (v?: Vector3) {\n if (v === undefined) v = new Vector3()\n\n v.x = this.x\n v.y = this.y\n v.z = this.z\n\n return v\n }\n\n /**\n * Set atom position from vector\n * @param {Vector3} v - input vector\n * @return {AtomProxy} this object\n */\n positionFromVector3 (v: Vector3) {\n this.x = v.x\n this.y = v.y\n this.z = v.z\n\n return this\n }\n\n /**\n * Add vector to atom position\n * @param {Vector3} v - input vector\n * @return {AtomProxy} this object\n */\n positionAdd (v: Vector3|AtomProxy) {\n this.x += v.x\n this.y += v.y\n this.z += v.z\n\n return this\n }\n\n /**\n * Subtract vector from atom position\n * @param {Vector3} v - input vector\n * @return {AtomProxy} this object\n */\n positionSub (v: Vector3|AtomProxy) {\n this.x -= v.x\n this.y -= v.y\n this.z -= v.z\n\n return this\n }\n\n /**\n * Get intra group/residue bonds\n * @param {Boolean} firstOnly - immediately return the first connected atomIndex\n * @return {Integer[]|Integer|undefined} connected atomIndices\n */\n getResidueBonds (firstOnly = false) {\n const residueAtomOffset = this.residueAtomOffset\n const relativeIndex = this.index - this.residueAtomOffset\n const bonds = this.residueType.getBonds()! // TODO\n const atomIndices1 = bonds.atomIndices1\n const atomIndices2 = bonds.atomIndices2\n let idx1, idx2, connectedAtomIndex\n let connectedAtomIndices: number[]|undefined\n\n if (!firstOnly) connectedAtomIndices = []\n\n idx1 = atomIndices1.indexOf(relativeIndex)\n while (idx1 !== -1) {\n connectedAtomIndex = atomIndices2[ idx1 ] + residueAtomOffset\n if (connectedAtomIndices) {\n connectedAtomIndices.push(connectedAtomIndex)\n idx1 = atomIndices1.indexOf(relativeIndex, idx1 + 1)\n } else {\n return connectedAtomIndex\n }\n }\n\n idx2 = atomIndices2.indexOf(relativeIndex)\n while (idx2 !== -1) {\n connectedAtomIndex = atomIndices1[ idx2 ] + residueAtomOffset\n if (connectedAtomIndices) {\n connectedAtomIndices.push(connectedAtomIndex)\n idx2 = atomIndices2.indexOf(relativeIndex, idx2 + 1)\n } else {\n return connectedAtomIndex\n }\n }\n\n return connectedAtomIndices\n }\n\n //\n\n qualifiedName (noResname = false) {\n var name = ''\n if (this.resname && !noResname) name += '[' + this.resname + ']'\n if (this.resno !== undefined) name += this.resno\n if (this.inscode) name += '^' + this.inscode\n if (this.chainname) name += ':' + this.chainname\n if (this.atomname) name += '.' + this.atomname\n if (this.altloc) name += '%' + this.altloc\n if (this.structure.modelStore.count > 1) name += '/' + this.modelIndex\n return name\n }\n\n /**\n * Clone object\n * @return {AtomProxy} cloned atom\n */\n clone () {\n return new AtomProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n index: this.index,\n residueIndex: this.residueIndex,\n\n resname: this.resname,\n x: this.x,\n y: this.y,\n z: this.z,\n element: this.element,\n chainname: this.chainname,\n resno: this.resno,\n serial: this.serial,\n vdw: this.vdw,\n covalent: this.covalent,\n hetero: this.hetero,\n bfactor: this.bfactor,\n altloc: this.altloc,\n atomname: this.atomname,\n modelIndex: this.modelIndex\n }\n }\n}\n\nexport default AtomProxy\n","/**\n * @file Kdtree\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { Debug, Log } from '../globals'\nimport _Kdtree from '../utils/kdtree'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\n\nfunction euclideanDistSq(a: number[], b: number[]) {\n const dx = a[0] - b[0]\n const dy = a[1] - b[1]\n const dz = a[2] - b[2]\n return dx * dx + dy * dy + dz * dz\n}\n\nfunction euclideanDist(a: number[], b: number[]) {\n return Math.sqrt(euclideanDistSq(a, b))\n}\n\nconst pointArray = new Float32Array(3)\n\nclass Kdtree {\n points: Float32Array\n atomIndices: Uint32Array\n kdtree: _Kdtree\n\n constructor(structure: Structure|ResidueProxy, useSquaredDist = false) {\n if (Debug) Log.time('Kdtree build')\n\n const metric = useSquaredDist ? euclideanDistSq : euclideanDist\n\n const points = new Float32Array(structure.atomCount * 3)\n const atomIndices = new Uint32Array(structure.atomCount)\n let i = 0\n\n structure.eachAtom(function (ap) {\n points[ i + 0 ] = ap.x\n points[ i + 1 ] = ap.y\n points[ i + 2 ] = ap.z\n atomIndices[ i / 3 ] = ap.index\n i += 3\n })\n\n this.atomIndices = atomIndices\n this.points = points\n this.kdtree = new _Kdtree(points, metric)\n\n if (Debug) Log.timeEnd('Kdtree build')\n\n // console.log(\"this.kdtree.verify()\", this.kdtree.verify())\n }\n\n nearest (point: number[]|Vector3, maxNodes: number, maxDistance: number) {\n // Log.time( \"Kdtree nearest\" );\n\n if (point instanceof Vector3) {\n point.toArray(pointArray as any)\n } else if (point instanceof AtomProxy) {\n point.positionToArray(pointArray)\n }\n\n const nodeList = this.kdtree.nearest(pointArray, maxNodes, maxDistance)\n\n const indices = this.kdtree.indices\n const nodes = this.kdtree.nodes\n const atomIndices = this.atomIndices\n const resultList = []\n\n for (let i = 0, n = nodeList.length; i < n; ++i) {\n const d = nodeList[ i ]\n const nodeIndex = d[ 0 ]\n const dist = d[ 1 ]\n\n resultList.push({\n index: atomIndices[ indices[ nodes[ nodeIndex ] ] ],\n distance: dist\n })\n }\n\n // Log.timeEnd( \"Kdtree nearest\" );\n\n return resultList\n }\n}\n\nexport default Kdtree\n","/**\n * @file Symmetry Constants\n * @author Alexander Rose \n * @private\n */\n\nexport const SymOpCode: { [k: string]: string } = {\n ' ': 'X',\n '!': 'Y',\n '#': 'Z',\n '$': '-X',\n '%': '-Y',\n '&': '-Z',\n \"'\": 'Y+1/2',\n '(': '1/2+X',\n ')': '1/2+Y',\n '*': '1/2-X',\n '+': '1/2+Z',\n ',': '1/2-Y',\n '-': '1/2-Z',\n '.': 'X+1/2',\n '/': 'Z+1/2',\n '0': '-X+1/2',\n '1': '-Y+1/2',\n '2': '-Z+1/2',\n '3': '1/4+X',\n '4': '1/4-Y',\n '5': '1/4+Z',\n '6': '1/4-X',\n '7': '1/4+Y',\n '8': '3/4-Y',\n '9': '3/4+Z',\n ':': '3/4+Y',\n ';': '3/4+X',\n '<': '3/4-X',\n '=': '1/4-Z',\n '>': '3/4-Z',\n '?': 'X-Y',\n '@': 'Y-X',\n 'A': 'Z+1/3',\n 'B': 'Z+2/3',\n 'C': 'X+2/3',\n 'D': 'Y+1/3',\n 'E': '-Y+2/3',\n 'F': 'X-Y+1/3',\n 'G': 'Y-X+2/3',\n 'H': '-X+1/3',\n 'I': 'X+1/3',\n 'J': 'Y+2/3',\n 'K': '-Y+1/3',\n 'L': 'X-Y+2/3',\n 'M': 'Y-X+1/3',\n 'N': '-X+2/3',\n 'O': '2/3+X',\n 'P': '1/3+Y',\n 'Q': '1/3+Z',\n 'R': '2/3-Y',\n 'S': '1/3+X-Y',\n 'T': '2/3+Y-X',\n 'U': '1/3-X',\n 'V': '2/3-X',\n 'W': '1/3-Y',\n 'X': '1/3-Z',\n 'Y': '2/3+Y',\n 'Z': '1/3+Y-X',\n '[': '2/3+X-Y',\n ']': '1/3+X',\n '^': '2/3+Z',\n '_': '2/3-Z',\n '`': '5/6+Z',\n 'a': '1/6+Z',\n 'b': '5/6-Z',\n 'c': '1/6-Z',\n 'd': 'Z+5/6',\n 'e': 'Z+1/6',\n 'f': 'Z+1/4',\n 'g': '+Y'\n}\n\n// encoded, originally from CCP4 symop.lib\nexport const EncodedSymOp: { [k: string]: string } = {\n 'P 1': ' !#',\n 'P -1': ' !#$%&',\n 'P 1 2 1': ' !#$!&',\n 'P 1 21 1': \" !#$'&\",\n 'C 1 2 1': ' !#$!&()#*)&',\n 'P 1 m 1': ' !# %#',\n 'P 1 c 1': ' !# %+',\n 'C 1 m 1': ' !# %#()#(,#',\n 'C 1 c 1': ' !# %+()#(,+',\n 'P 1 2/m 1': ' !# %#$!&$%&',\n 'P 1 21/m 1': ' !#$)&$%& ,#',\n 'C 1 2/m 1': ' !# %#$!&$%&()#(,#*)&*,&',\n 'P 1 2/c 1': ' !#$!-$%& %+',\n 'P 1 21/c 1': ' !#$%&$)- ,+',\n 'C 1 2/c 1': ' !#$!-$%& %+()#*)-*,&(,+',\n 'P 2 2 2': ' !#$%#$!& %&',\n 'P 2 2 21': ' !#$%+$!- %&',\n 'P 21 21 2': ' !#$%#*)&(,&',\n 'P 21 21 21': ' !#*%+$)-(,&',\n 'C 2 2 21': ' !#$%+$!- %&()#*,+*)-(,&',\n 'C 2 2 2': ' !#$%#$!& %&()#*,#*)&(,&',\n 'F 2 2 2': ' !#$%#$!& %& )+$,+$)- ,-(!+*%+*!-(%-()#*,#*)&(,&',\n 'I 2 2 2': \" !#$%# %&$!&.'/01/.120'2\",\n 'I 21 21 21': ' !#*%+$)-(,&()+$,#*!& %-',\n 'P m m 2': ' !#$%# %#$!#',\n 'P m c 21': ' !#$%+ %+$!#',\n 'P c c 2': ' !#$%# %+$!+',\n 'P m a 2': ' !#$%#(%#*!#',\n 'P c a 21': ' !#$%+(%#*!+',\n 'P n c 2': ' !#$%# ,+$)+',\n 'P m n 21': ' !#*%+(%+$!#',\n 'P b a 2': ' !#$%#(,#*)#',\n 'P n a 21': ' !#$%+(,#*)+',\n 'P n n 2': ' !#$%#(,+*)+',\n 'C m m 2': ' !#$%# %#$!#()#*,#(,#*)#',\n 'C m c 21': ' !#$%+ %+$!#()#*,+(,+*)#',\n 'C c c 2': ' !#$%# %+$!+()#*,#(,+*)+',\n 'A m m 2': ' !#$%# %#$!# )+$,+ ,+$)+',\n 'A b m 2': ' !#$%# ,#$)# )+$,+ %+$!+',\n 'A m a 2': ' !#$%#(%#*!# )+$,+(,+*)+',\n 'A b a 2': ' !#$%#(,#*)# )+$,+(%+*!+',\n 'F m m 2': ' !#$%# %#$!# )+$,+ ,+$)+(!+*%+(%+*!+()#*,#(,#*)#',\n 'F d d 2': ' !#$%#345675 )+$,+3896:9(!+*%+;49<79()#*,#;85<:5',\n 'I m m 2': ' !#$%# %#$!#()+*,+(,+*)+',\n 'I b a 2': ' !#$%#(,#*)#()+*,+ %+$!+',\n 'I m a 2': ' !#$%#(%#*!#()+*,+ ,+$)+',\n 'P 2/m 2/m 2/m': ' !#$%#$!& %&$%& !& %#$!#',\n 'P 2/n 2/n 2/n': ' !#$%#$!& %&*,-()-(,+*)+',\n 'P 2/c 2/c 2/m': ' !#$%#$!- %-$%& !& %+$!+',\n 'P 2/b 2/a 2/n': ' !#$%#$!& %&*,&()&(,#*)#',\n 'P 21/m 2/m 2/a': ' !#*%#$!&(%&$%&(!& %#*!#',\n 'P 2/n 21/n 2/a': ' !#*%#*)- ,-$%&(!&(,+$)+',\n 'P 2/m 2/n 21/a': ' !#*%+*!- %&$%&(!-(%+$!#',\n 'P 21/c 2/c 2/a': ' !#*%#$!-(%-$%&(!& %+*!+',\n 'P 21/b 21/a 2/m': ' !#$%#*)&(,&$%& !&(,#*)#',\n 'P 21/c 21/c 2/n': ' !#*,#$)-(%-$%&()& ,+*!+',\n 'P 2/b 21/c 21/m': ' !#$%+$)- ,&$%& !- ,+$)#',\n 'P 21/n 21/n 2/m': ' !#$%#*)-(,-$%& !&(,+*)+',\n 'P 21/m 21/m 2/n': \" !#$%#*'&.,&*,&.'& %#$!#\",\n 'P 21/b 2/c 21/n': ' !#*,+$!-(,&$%&()- %+*)#',\n 'P 21/b 21/c 21/a': ' !#*%+$)-(,&$%&(!- ,+*)#',\n 'P 21/n 21/m 21/a': \" !#0%/$'&.12$%&.!2 1#0'/\",\n 'C 2/m 2/c 21/m': ' !#$%+$!- %&$%& !- %+$!#()#*,+*)-(,&*,&()-(,+*)#',\n 'C 2/m 2/c 21/a': ' !#$,+$)- %&$%& )- ,+$!#()#*%+*!-(,&*,&(!-(%+*)#',\n 'C 2/m 2/m 2/m': ' !#$%#$!& %&$%& !& %#$!#()#*,#*)&(,&*,&()&(,#*)#',\n 'C 2/c 2/c 2/m': ' !#$%#$!- %-$%& !& %+$!+()#*,#*)-(,-*,&()&(,+*)+',\n 'C 2/m 2/m 2/a': ' !#$,#$)& %&$%& )& ,#$!#()#*%#*!&(,&*,&(!&(%#*)#',\n 'C 2/c 2/c 2/a': ' !#*,#$!&(,&$,-(!- ,+*!+()#$%#*)& %&*%- )-(%+$)+',\n 'F 2/m 2/m 2/m': ' !#$%#$!& %&$%& !& %#$!# )+$,+$)- ,-$,- )- ,+$)+(!+*%+*!-(%-*%-(!-(%+*!+()#*,#*)&(,&*,&()&(,#*)#',\n 'F 2/d 2/d 2/d': ' !#$%#$!& %&64=37=345675 )+$,+$)- ,-68>3:>3896:9(!+*%+*!-(%-<4>;7>;49<79()#*,#*)&(,&<8=;:=;85<:5',\n 'I 2/m 2/m 2/m': ' !#$%#$!& %&$%& !& %#$!#()+*,+*)-(,-*,-()-(,+*)+',\n 'I 2/b 2/a 2/m': ' !#$%#*)&(,&$%& !&(,#*)#()+*,+$!- %-*,-()- %+$!+',\n 'I 21/b 21/c 21/a': ' !#*%+$)-(,&$%&(!- ,+*)#()+$,#*!& %-*,- )&(%#$!+',\n 'I 21/m 21/m 21/a': ' !#$,#$)& %&$%& )& ,#$!#()+*%+*!-(,-*,-(!-(%+*)+',\n 'P 4': ' !#$%#% #!$#',\n 'P 41': ' !#$%+% 5!$9',\n 'P 42': ' !#$%#% +!$+',\n 'P 43': ' !#$%+% 9!$5',\n 'I 4': ' !#$%#% #!$#()+*,+,(+)*+',\n 'I 41': ' !#*,+%(5)$9()+$%#, 9!*5',\n 'P -4': ' !#$%#!$&% &',\n 'I -4': ' !#$%#!$&% &()+*,+)*-,(-',\n 'P 4/m': ' !#$%#% #!$#$%& !&!$&% &',\n 'P 42/m': ' !#$%#% +!$+$%& !&!$-% -',\n 'P 4/n': ' !#$%#,(#)*#*,&()&!$&% &',\n 'P 42/n': ' !#$%#,(+)*+*,-()-!$&% &',\n 'I 4/m': ' !#$%#% #!$#$%& !&!$&% &()+*,+,(+)*+*,-()-)*-,(-',\n 'I 41/a': ' !#*,+%(5)$9$,=(!>!$&,(-()+$%#, 9!*5*%> )=)*-% &',\n 'P 4 2 2': ' !#$%#% #!$#$!& %&! &%$&',\n 'P 4 21 2': ' !#$%#,(#)*#*)&(,&! &%$&',\n 'P 41 2 2': ' !#$%+% 5!$9$!& %-! >%$=',\n 'P 41 21 2': ' !#$%+,(5)*9*)=(,>! &%$-',\n 'P 42 2 2': ' !#$%#% +!$+$!& %&! -%$-',\n 'P 42 21 2': ' !#$%#,(+)*+*)-(,-! &%$&',\n 'P 43 2 2': ' !#$%+% 9!$5$!& %-! =%$>',\n 'P 43 21 2': ' !#$%+,(9)*5*)>(,=! &%$-',\n 'I 4 2 2': ' !#$%#% #!$#$!& %&! &%$&()+*,+,(+)*+*)-(,-)(-,*-',\n 'I 41 2 2': ' !#*,+%(5)$9*!> ,=)(-%$&()+$%#, 9!*5$)=(%>! &,*-',\n 'P 4 m m': ' !#$%#% #!$# %#$!#%$#! #',\n 'P 4 b m': ' !#$%#% #!$#(,#*)#,*#)(#',\n 'P 42 c m': ' !#$%#% +!$+ %+$!+%$#! #',\n 'P 42 n m': ' !#$%#,(+)*+(,+*)+%$#! #',\n 'P 4 c c': ' !#$%#% #!$# %+$!+%$+! +',\n 'P 4 n c': ' !#$%#% #!$#(,+*)+,*+)(+',\n 'P 42 m c': ' !#$%#% +!$+ %#$!#%$+! +',\n 'P 42 b c': ' !#$%#% +!$+(,#*)#,*+)(+',\n 'I 4 m m': ' !#$%#% #!$# %#$!#%$#! #()+*,+,(+)*+(,+*)+,*+)(+',\n 'I 4 c m': ' !#$%#% #!$# %+$!+%$+! +()+*,+,(+)*+(,#*)#,*#)(#',\n 'I 41 m d': ' !#*,+%(5)$9 %#*)+%*5) 9()+$%#, 9!*5(,+$!#,$9!(5',\n 'I 41 c d': ' !#*,+%(5)$9 %+*)#%*9) 5()+$%#, 9!*5(,#$!+,$5!(9',\n 'P -4 2 m': ' !#$%#% &!$&$!& %&%$#! #',\n 'P -4 2 c': ' !#$%#% &!$&$!- %-%$+! +',\n 'P -4 21 m': ' !#$%#% &!$&*)&(,&,*#)(#',\n 'P -4 21 c': ' !#$%#% &!$&*)-(,-,*+)(+',\n 'P -4 m 2': ' !#$%#!$&% & %#$!#! &%$&',\n 'P -4 c 2': ' !#$%#% &!$& %+$!+! -%$-',\n 'P -4 b 2': ' !#$%#% &!$&(,#*)#)(&,*&',\n 'P -4 n 2': ' !#$%#% &!$&(,+*)+)(-,*-',\n 'I -4 m 2': ' !#$%#% &!$& %#$!#! &%$&()+*,+,(-)*-(,+*)+)(-,*-',\n 'I -4 c 2': ' !#$%#% &!$& %+$!+! -%$-()+*,+,(-)*-(,#*)#)(&,*&',\n 'I -4 2 m': ' !#$%#% &!$&$!& %&%$#! #()+*,+,(-)*-*)-(,-,*+)(+',\n 'I -4 2 d': ' !#$%#% &!$&*!>(%>,$9) 9()+*,+,(-)*-$)= ,=%*5!(5',\n 'P 4/m 2/m 2/m': ' !#$%#% #!$#$!& %&! &%$&$%& !&!$&% & %#$!#%$#! #',\n 'P 4/m 2/c 2/c': ' !#$%#% #!$#$!- %-! -%$-$%& !&!$&% & %+$!+%$+! +',\n 'P 4/n 2/b 2/m': ' !#$%#% #!$#$!& %&! &%$&*,&()&)*&,(&(,#*)#,*#)(#',\n 'P 4/n 2/n 2/c': ' !#$%#% #!$#$!& %&! &%$&*,-()-)*-,(-(,+*)+,*+)(+',\n 'P 4/m 21/b 2/m': ' !#$%#% #!$#*)&(,&)(&,*&$%& !&!$&% &(,#*)#,*#)(#',\n 'P 4/m 21/n 2/c': ' !#$%#% #!$#*)-(,-)(-,*-$%& !&!$&% &(,+*)+,*+)(+',\n 'P 4/n 21/m 2/m': ' !#$%#,(#)*#*)&(,&! &%$&*,&()&!$&% & %#$!#,*#)(#',\n 'P 4/n 2/c 2/c': ' !#$%#,(#)*#*)-(,-! -%$-*,&()&!$&% & %+$!+,*+)(+',\n 'P 42/m 2/m 2/c': ' !#$%#% +!$+$!& %&! -%$-$%& !&!$-% - %#$!#%$+! +',\n 'P 42/m 2/c 2/m': ' !#$%#% +!$+$!- %-! &%$&$%& !&!$-% - %+$!+%$#! #',\n 'P 42/n 2/b 2/c': ' !#$%#,(+)*+$!- %-)(&,*&*,-()-!$&% &(,#*)#%$+! +',\n 'P 42/n 2/n 2/m': ' !#$%#,(+)*+$!& %&)(-,*-*,-()-!$&% &(,+*)+%$#! #',\n 'P 42/m 21/b 2/c': ' !#$%#% +!$+*)&(,&)(-,*-$%& !&!$-% -(,#*)#,*+)(+',\n 'P 42/m 21/n 2/m': \" !#$%#,./'*/*'-.,-! &%$&$%& !&'*-,.-.,/*'/%$#! #\",\n 'P 42/n 21/m 2/c': ' !#$%#,(+)*+*)-(,-! &%$&*,-()-!$&% & %#$!#,*+)(+',\n 'P 42/n 21/c 2/m': ' !#$%#,(+)*+*)&(,&! -%$-*,-()-!$&% & %+$!+,*#)(#',\n 'I 4/m 2/m 2/m': ' !#$%#% #!$#$!& %&! &%$&$%& !&!$&% & %#$!#%$#! #()+*,+,(+)*+*)-(,-)(-,*-*,-()-)*-,(-(,+*)+,*+)(+',\n 'I 4/m 2/c 2/m': ' !#$%#% #!$#$!- %-! -%$-$%& !&!$&% & %+$!+%$+! +()+*,+,(+)*+*)&(,&)(&,*&*,-()-)*-,(-(,#*)#,*#)(#',\n 'I 41/a 2/m 2/d': ' !#*,+%(5)$9*!> ,=)(-%$&$,=(!>!$&,(-(,+$!#,$9!(5()+$%#, 9!*5$)=(%>! &,*-*%> )=)*-% & %#*)+%*5) 9',\n 'I 41/a 2/c 2/d': ' !#*,+%(5)$9*!= ,>)(&%$-$,=(!>!$&,(-(,#$!+,$5!(9()+$%#, 9!*5$)>(%=! -,*&*%> )=)*-% & %+*)#%*9) 5',\n 'P 3': ' !#%?#@$#',\n 'P 31': ' !#%?A@$B',\n 'P 32': ' !#%?B@$A',\n 'H 3': ' !#%?#@$#CDAEFAGHAIJBKLBMNB',\n 'R 3': ' !## !!# ',\n 'P -3': ' !#%?#@$#$%&!@&? &',\n 'H -3': ' !#%?#@$#$%&!@&? &OPQRSQTUQVWXYZX[]X]Y^W[^ZV^UR_PT_SO_',\n 'R -3': ' !## !!# $%&&$%%&$',\n 'P 3 1 2': ' !#%?#@$#%$&@!& ?&',\n 'P 3 2 1': ' !#%?#@$#! &?%&$@&',\n 'P 31 1 2': ' !#%?Q@$^%$_@!X ?&',\n 'P 31 2 1': ' !#%?A@$B! &?%_$@X',\n 'P 32 1 2': ' !#%?^@$Q%$X@!_ ?&',\n 'P 32 2 1': ' !#%?B@$A! &?%X$@_',\n 'H 3 2': ' !#%?#@$#! &?%&$@&OPQRSQTUQY]X[WXVZX]Y^W[^ZV^PO_SR_UT_',\n 'R 3 2': ' !## !!# %$&$&%&%$',\n 'P 3 m 1': ' !#%?#@$#%$#@!# ?#',\n 'P 3 1 m': ' !#%?#@$#! #?%#$@#',\n 'P 3 c 1': ' !#%?#@$#%$+@!+ ?+',\n 'P 3 1 c': ' !#%?#@$#! +?%+$@+',\n 'H 3 m': ' !#%?#@$#%$#@!# ?#OPQRSQTUQRUQTPQOSQ]Y^W[^ZV^WV^ZY^][^',\n 'R 3 m': ' !## !!# ! # #!#! ',\n 'H 3 c': ' !#%?#@$#%$+@!+ ?+OPQRSQTUQRU`TP`OS`]Y^W[^ZV^WVaZYa][a',\n 'R 3 c': \" !## !!# '././'/'.\",\n 'P -3 1 2/m': ' !#%?#@$#%$&@!& ?&$%&!@&? &! #?%#$@#',\n 'P -3 1 2/c': ' !#%?#@$#%$-@!- ?-$%&!@&? &! +?%+$@+',\n 'P -3 2/m 1': ' !#%?#@$#! &?%&$@&$%&!@&? &%$#@!# ?#',\n 'P -3 2/c 1': ' !#%?#@$#! -?%-$@-$%&!@&? &%$+@!+ ?+',\n 'H -3 2/m': ' !#%?#@$#! &?%&$@&$%&!@&? &%$#@!# ?#OPQRSQTUQY]X[WXVZXVWXYZX[]XRUQTPQOSQ]Y^W[^ZV^PO_SR_UT_UR_PT_SO_WV^ZY^][^',\n 'R -3 2/m': ' !## !!# %$&$&%&%$$%&&$%%&$! # #!#! ',\n 'H -3 2/c': ' !#%?#@$#! -?%-$@-$%&!@&? &%$+@!+ ?+OPQRSQTUQY]b[WbVZbVWXYZX[]XRU`TP`OS`]Y^W[^ZV^POcSRcUTcUR_PT_SO_WVaZYa][a',\n 'R -3 2/c': \" !## !!# 102021210$%&&$%%&$'././'/'.\",\n 'P 6': ' !#%?#@$#$%#!@#? #',\n 'P 61': ' !#%?A@$B$%/!@d? e',\n 'P 65': ' !#%?B@$A$%/!@e? d',\n 'P 62': ' !#%?^@$Q$%#!@^? Q',\n 'P 64': ' !#%?Q@$^$%#!@Q? ^',\n 'P 63': ' !#%?#@$#$%+!@+? +',\n 'P -6': ' !#%?#@$# !&%?&@$&',\n 'P 6/m': ' !#%?#@$#$%#!@#? #$%&!@&? & !&%?&@$&',\n 'P 63/m': ' !#%?#@$#$%+!@+? +$%&!@&? & !-%?-@$-',\n 'P 6 2 2': ' !#%?#@$#$%#!@#? #! &?%&$@&%$&@!& ?&',\n 'P 61 2 2': ' !#%?Q@$^$%+!@`? a! X?%&$@_%$b@!- ?c',\n 'P 65 2 2': ' !#%?^@$Q$%+!@a? `! _?%&$@X%$c@!- ?b',\n 'P 62 2 2': ' !#%?^@$Q$%#!@^? Q! _?%&$@X%$_@!& ?X',\n 'P 64 2 2': ' !#%?Q@$^$%#!@Q? ^! X?%&$@_%$X@!& ?_',\n 'P 63 2 2': ' !#%?#@$#$%+!@+? +! &?%&$@&%$-@!- ?-',\n 'P 6 m m': ' !#%?#@$#$%#!@#? #%$#@!# ?#! #?%#$@#',\n 'P 6 c c': ' !#%?#@$#$%#!@#? #%$+@!+ ?+! +?%+$@+',\n 'P 63 c m': ' !#%?#@$#$%+!@+? +%$+@!+ ?+! #?%#$@#',\n 'P 63 m c': ' !#%?#@$#$%+!@+? +%$#@!# ?#! +?%+$@+',\n 'P -6 m 2': ' !#%?#@$# !&%?&@$&%$#@!# ?#%$&@!& ?&',\n 'P -6 c 2': ' !#%?#@$# !-%?-@$-%$+@!+ ?+%$&@!& ?&',\n 'P -6 2 m': ' !#%?#@$# !&%?&@$&! &?%&$@&! #?%#$@#',\n 'P -6 2 c': ' !#%?#@$# !-%?-@$-! &?%&$@&! +?%+$@+',\n 'P 6/m 2/m 2/m': ' !#%?#@$#$%#!@#? #! &?%&$@&%$&@!& ?&$%&!@&? & !&@$&%?&%$#@!# ?#! #?%#$@#',\n 'P 6/m 2/c 2/c': ' !#%?#@$#$%#!@#? #! -?%-$@-%$-@!- ?-$%&!@&? & !&@$&%?&%$+@!+ ?+! +?%+$@+',\n 'P 63/m 2/c 2/m': ' !#%?#@$#$%+!@+? +! -?%-$@-%$&@!& ?&$%&!@&? & !-@$-%?-%$+@!+ ?+! #?%#$@#',\n 'P 63/m 2/m 2/c': ' !#%?#@$#$%+!@+? +! &?%&$@&%$-@!- ?-$%&!@&? & !-@$-%?-%$#@!# ?#! +?%+$@+',\n 'P 2 3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ',\n 'F 2 3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ',\n 'I 2 3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-(',\n 'P 21 3': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(',\n 'I 21 3': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- ',\n 'P 2/m -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$',\n 'P 2/n -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& *,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*',\n 'F 2/m -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$ )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-($,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(*%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- *,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$',\n 'F 2/d -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& 64=37=345675=64=375345674=67=3453756 )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(68>3:>3896:9=<8=;:5;85<:4><7>;49;79<(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(<4>;7>;49<79>68>3:93896:8=<:=;85;:5<()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- <8=;:=;8f<:f><4>;79;49<78>6:>3893:96',\n 'I 2/m -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-(*,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*',\n 'P 21/a -3': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&($%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*',\n 'I 21/a -3': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&($%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*()+$,#*g& %-+()#$,&*!- %)+(,#$!&*%- *,- )&(%#$!+-*,& )#(%+$!,-*)& %#(!+$',\n 'P 4 3 2': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$',\n 'P 42 3 2': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*',\n 'F 4 3 2': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$ )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(-%*-!*+%(+ +,$+)$-, -)#)*#,(&)(&,*(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() -,$-)$+, +(#,*#)*&,(&)+!*+%(-!(-%*()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(&,*&)*#,(#(+%*+!*-%(-!+)$+, -) -,$',\n 'F 41 3 2': ' !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=46 )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<(!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>86',\n 'I 4 3 2': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*',\n 'P 43 3 2': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(7;>46=:<5839398<5:6=4;>75:<983>7;=46',\n 'P 41 3 2': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<',\n 'I 41 3 2': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- 7;>46=:<5839398<5:6=4;>75:<983>7;=46',\n 'P -4 3 m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% ',\n 'F -4 3 m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(+%*+!*-%(- +)$+,$-) -,#)(#,*&)*&,((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() +,$+)$-, -(#)*#,*&)(&,+!(+%*-!*-%(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(#,*#)*&,(&(+!*+%*-!(-%+) +,$-)$-, ',\n 'I -4 3 m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,(',\n 'P -4 3 n': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,(',\n 'F -4 3 c': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,( )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-() #,$#)$&, &(#!*#%*&!(&%+! +%$-!$-% (!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(!(#%*#!*&%(& +!$+%$-! -%#) #,$&)$&, ()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ! +%$+!$-% - #)$#,$&) &,#!(#%*&!*&%(',\n 'I -4 3 d': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(7354<9:6>8;=357<946>:;=857394<>:6=8;()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- :;98657<=43>;9:658<=73>49:;586=7<>43',\n 'P 4/m -3 2/m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ',\n 'P 4/n -3 2/n': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$*,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(',\n 'P 42/m -3 2/n': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(',\n 'P 42/n -3 2/m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,**,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ',\n 'F 4/m -3 2/m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(-%*-!*+%(+ +,$+)$-, -)#)*#,(&)(&,*$,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*%*+!(+%(-!*-$-) -, +)$+,&,(&)*#,*#)((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() -,$-)$+, +(#,*#)*&,(&)+!*+%(-!(-%**%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*,$+) +, -)$-*&)(&,(#)*#,-%(-!*+%*+!(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(&,*&)*#,(#(+%*+!*-%(-!+)$+, -) -,$*,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$,*#)(#,(&)*&*-!(-%(+!*+%-, -)$+,$+) ',\n 'F 4/m -3 2/c': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)( )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-() &,$&)$#, #(#%*#!*&%(&!+!$+% -! -%$$,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*,$#) #, &)$&*&!(&%(#!*#%-% -!$+%$+! (!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(!(&%*&!*#%(# +%$+!$-% -!#)$#, &) &,$*%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*%*#!(#%(&!*&$-! -% +!$+%&, &)$#,$#) ()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ! -%$-!$+% + #,$#)$&, &)#!*#%(&!(&%**,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$%$+! +% -!$-$&) &, #)$#,&%(&!*#%*#!(',\n 'F 41/d -3 2/m': ' !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=4664=3:>;85<79=64>3:5;89<74=6:>385;79<,$+! #%(-)*&*&)(-% #!$+,-%(&)*+,$#! )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<68>37=;49<:5=<8>;753496:4><:=;893756,*#!(+% &)$-*-!(&, +)$#%-, &!$+%*#)((!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<<4>;:=389675>68=379;45<:8=<7>;453:96%$#) +,(&!*-$&! -,(#)*+%&% -)$#,*+!(()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>86<8=;7>3456:9><4=;:9385678>67=349;:5<%*+)(#, -!$&$-) &%(+!*#,&,(-!*#%$+) ',\n 'F 41/d -3 2/c': ' !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=46<8>;7=3496:5><8=;793456:8><7=;493:56%*#)(+, &!$-$-! &,(+)*#%&, -!$#%*+)( )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<<4=;:>385679>64=3:9;85<78=67>345;:9<%$+) #,(-!*&$&) -%(#!*+,&%(-)*#,$+! (!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<68=37>;45<:9=<4>;:5389674>6:=389;75<,*+!(#% -)$&*-)(&% +!$#,-,(&!*+%$#) ()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>8664>3:=;89<75=68>375;49<:4=<:>;853796,$#! +%(&)*-*&!(-, #)$+%-% &)$+,*#!(',\n 'I 4/m -3 2/m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,**,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(',\n 'I 41/a -3 2/d': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<$%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*4<97358;=:6>6>:;=8357<94=8;>:694<573()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- 7;>46=:<5839398<5:6=4;>75:<983>7;=46*,- )&(%#$!+-*,& )#(%+$!,-*)& %#(!+$865:;943>7<=<=73>4;9:658>43=7<5869:;',\n 'P 1 1 2': ' !#$%#',\n 'P 1 1 21': ' !#$%+',\n 'B 1 1 2': ' !#$%#(g+*%+',\n 'A 1 2 1': ' !#$!& )+$)-',\n 'C 1 21 1': ' !#$)&()#*!&',\n 'I 1 2 1': \" !#$!&.'/0'2\",\n 'I 1 21 1': \" !#$)&.'/0!-\",\n 'P 1 1 m': ' !# !&',\n 'P 1 1 b': ' !# )&',\n 'B 1 1 m': ' !# !&(!+(!-',\n 'B 1 1 b': ' !# )&(!+()-',\n 'P 1 1 2/m': ' !# !&$%#$%&',\n 'P 1 1 21/m': ' !#$%+$%& !-',\n 'B 1 1 2/m': ' !# !&$%#$%&(!+(!-*%+*%-',\n 'P 1 1 2/b': ' !#$,#$%& )&',\n 'P 1 1 21/b': ' !#$%&$,+ )-',\n 'B 1 1 2/b': ' !#$,#$%& )&(!+*,+*%-()-',\n 'P 21 2 2': ' !#$!&(%&*%#',\n 'P 2 21 2': ' !# ,&$)&$%#',\n 'P 21 21 2 (a)': \" !#*,#.%&$'&\",\n 'P 21 2 21': ' !#$!&(%-*%+',\n 'P 2 21 21': ' !# %&$)-$,+',\n 'C 2 2 21a)': ' !#*%+(,&$)-()#$,+ %&*!-',\n 'C 2 2 2a': \" !#*,#.%&$'&()#$%# ,&*!&\",\n 'F 2 2 2a': \" !#*,#.%&$'& '/*%/.12$!2.!/$,/ %20'2.'#$%# 1&0!&\",\n 'I 2 2 2a': \" !#*,#.%&$'&()+$%+*!- ,-\",\n 'P 21/m 21/m 2/n a': \" !#*,#$)&(%&$%&.'& ,#*!#\",\n 'P 42 21 2a': \" !#*,#%.+'$+$'&.%&! -,*-\",\n 'I 2 3a': \" !#*,#.%&$'&!# ,- '&$%/$# !-*!/$%&.%()+$%+ ,-*!-)+(%&(!-*,#*+()&$)#*,- ,\"\n}\n","/**\n * @file Symmetry Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Log } from '../globals'\nimport { EncodedSymOp, SymOpCode } from './symmetry-constants'\n\nconst reInteger = /^[1-9]$/\n\nexport function getSymmetryOperations (spacegroup: string) {\n const encodedSymopList = EncodedSymOp[ spacegroup ]\n const matrixDict: { [k: string]: Matrix4 } = {}\n\n if (encodedSymopList === undefined) {\n console.warn(`spacegroup '${spacegroup}' not found in symop library`)\n return matrixDict\n }\n\n const symopList = []\n for (let i = 0, il = encodedSymopList.length; i < il; i += 3) {\n const symop = []\n for (let j = 0; j < 3; ++j) {\n symop.push(SymOpCode[ encodedSymopList[ i + j ] ])\n }\n symopList.push(symop)\n }\n\n symopList.forEach(function (symop) {\n let row = 0\n const matrix = new Matrix4().set(\n 0, 0, 0, 0,\n 0, 0, 0, 0,\n 0, 0, 0, 0,\n 0, 0, 0, 1\n )\n const me = matrix.elements\n\n matrixDict[ symop.toString() ] = matrix\n\n symop.forEach(function (elm) {\n let negate = false\n let denominator = false\n\n for (let i = 0, n = elm.length; i < n; ++i) {\n const c = elm[ i ]\n\n if (c === '-') {\n negate = true\n } else if (c === '+') {\n negate = false\n } else if (c === '/') {\n denominator = true\n } else if (c === 'X') {\n me[ 0 + row ] = negate ? -1 : 1\n } else if (c === 'Y') {\n me[ 4 + row ] = negate ? -1 : 1\n } else if (c === 'Z') {\n me[ 8 + row ] = negate ? -1 : 1\n } else if (reInteger.test(c)) {\n const integer = parseInt(c)\n if (denominator) {\n me[ 12 + row ] /= integer\n } else {\n me[ 12 + row ] = integer\n }\n } else {\n Log.warn(`getSymmetryOperations: unknown token '${c}'`)\n }\n }\n\n row += 1\n })\n })\n\n return matrixDict\n}\n","/**\n * @file Assembly\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Box3, Vector3 } from 'three'\n\nimport { uniqueArray } from '../utils'\nimport Selection from '../selection/selection'\nimport Structure from '../structure/structure'\nimport StructureView from '../structure/structure-view';\n\nfunction selectionFromChains (chainList: string[]) {\n let sele = ''\n if (chainList.length > 0) {\n sele = ':' + uniqueArray(chainList).join(' OR :')\n }\n return new Selection(sele)\n}\n\n/**\n * Assembly of transformed parts of a {@link Structure}\n */\nclass Assembly {\n partList: AssemblyPart[] = []\n\n /**\n * @param {String} name - assembly name\n */\n constructor (readonly name = '') {}\n\n get type () { return 'Assembly' }\n\n /**\n * Add transformed parts to the assembly\n * @example\n * var m1 = new NGL.Matrix4().set( ... );\n * var m2 = new NGL.Matrix4().set( ... );\n * var assembly = new NGL.Assembly( \"myAssembly\" );\n * // add part that transforms chain 'A' and 'B' using matrices `m1` and `m2`\n * assembly.addPart( [ m1, m2 ], [ \"A\", \"B\" ] )\n *\n * @param {Matrix4[]} matrixList - array of 4x4 transformation matrices\n * @param {String[]} chainList - array of chain names\n * @return {AssemblyPart} the added assembly part\n */\n addPart (matrixList?: Matrix4[], chainList?: string[]) {\n const part = new AssemblyPart(matrixList, chainList)\n this.partList.push(part)\n return part\n }\n\n /**\n * Get the number of atom for a given structure\n * @param {Structure} structure - the given structure\n * @return {Integer} number of atoms in the assembly\n */\n getAtomCount (structure: Structure) {\n return this.partList.reduce(\n (count, part) => count + part.getAtomCount(structure), 0\n )\n }\n\n /**\n * Get the number of residues for a given structure\n * @param {Structure} structure - the given structure\n * @return {Integer} number of residues in the assembly\n */\n getResidueCount (structure: Structure) {\n return this.partList.reduce(\n (count, part) => count + part.getResidueCount(structure), 0\n )\n }\n\n /**\n * Get number of instances the assembly will produce, i.e.\n * the number of transformations performed by the assembly\n * @return {Integer} number of instances\n */\n getInstanceCount () {\n let instanceCount = 0\n\n this.partList.forEach(function (part) {\n instanceCount += part.matrixList.length\n })\n\n return instanceCount\n }\n\n /**\n * Determine if the assembly is the full and untransformed structure\n * @param {Structure} structure - the given structure\n * @return {Boolean} whether the assembly is identical to the structure\n */\n isIdentity (structure: Structure) {\n if (this.partList.length !== 1) return false\n\n const part = this.partList[ 0 ]\n if (part.matrixList.length !== 1) return false\n\n const identityMatrix = new Matrix4()\n if (!identityMatrix.equals(part.matrixList[ 0 ])) return false\n\n let structureChainList: string[] = []\n structure.eachChain(function (cp) {\n structureChainList.push(cp.chainname)\n })\n structureChainList = uniqueArray(structureChainList)\n if (part.chainList.length !== structureChainList.length) return false\n\n return true\n }\n\n getBoundingBox (structure: Structure) {\n const boundingBox = new Box3()\n\n this.partList.forEach(function (part) {\n const partBox = part.getBoundingBox(structure)\n boundingBox.expandByPoint(partBox.min)\n boundingBox.expandByPoint(partBox.max)\n })\n\n return boundingBox\n }\n\n getCenter (structure: Structure) {\n return this.getBoundingBox(structure).getCenter(new Vector3())\n }\n\n getSelection () {\n let chainList: string[] = []\n this.partList.forEach(function (part) {\n chainList = chainList.concat(part.chainList)\n })\n return selectionFromChains(chainList)\n }\n}\n\nexport class AssemblyPart {\n constructor (readonly matrixList: Matrix4[] = [], readonly chainList: string[] = []) {}\n\n get type () { return 'AssemblyPart' }\n\n _getCount (structure: Structure, propertyName: 'atomCount'|'residueCount') {\n let count = 0\n\n structure.eachChain(cp => {\n if (this.chainList.length === 0 || this.chainList.includes(cp.chainname)) {\n count += cp[ propertyName ]\n }\n })\n\n return this.matrixList.length * count\n }\n\n getAtomCount (structure: Structure) {\n return this._getCount(structure, 'atomCount')\n }\n\n getResidueCount (structure: Structure) {\n return this._getCount(structure, 'residueCount')\n }\n\n getBoundingBox (structure: Structure) {\n const partBox = new Box3()\n const instanceBox = new Box3()\n\n const selection = this.getSelection()\n const structureBox = structure.getBoundingBox(selection)\n\n this.matrixList.forEach(function (matrix) {\n instanceBox.copy(structureBox).applyMatrix4(matrix)\n partBox.expandByPoint(instanceBox.min)\n partBox.expandByPoint(instanceBox.max)\n })\n\n return partBox\n }\n\n getSelection () {\n return selectionFromChains(this.chainList)\n }\n\n getView (structure: Structure): Structure | StructureView {\n const selection = this.getSelection()\n if (selection) {\n return structure.getView(selection)\n } else {\n return structure\n }\n }\n\n getInstanceList () {\n const instanceList = []\n for (let j = 0, jl = this.matrixList.length; j < jl; ++j) {\n instanceList.push({\n id: j + 1,\n name: j,\n matrix: this.matrixList[ j ]\n })\n }\n return instanceList\n }\n}\n\nexport default Assembly\n","/**\n * @file Structure Builder\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from './structure'\n\nclass StructureBuilder {\n currentModelindex: number|null = null\n currentChainid: string|null = null\n currentResname: string|null = null\n currentResno: number|null = null\n currentInscode: string|undefined = undefined\n currentHetero: boolean|null = null\n\n previousResname: string|null = ''\n previousHetero: boolean|null = null\n\n ai = -1\n ri = -1\n ci = -1\n mi = -1\n\n constructor(readonly structure: Structure) {}\n\n addResidueType (ri: number) {\n const atomStore = this.structure.atomStore\n const residueStore = this.structure.residueStore\n const residueMap = this.structure.residueMap\n\n const count = residueStore.atomCount[ ri ]\n const offset = residueStore.atomOffset[ ri ]\n const atomTypeIdList = new Array(count)\n for (let i = 0; i < count; ++i) {\n atomTypeIdList[ i ] = atomStore.atomTypeId[ offset + i ]\n }\n residueStore.residueTypeId[ ri ] = residueMap.add(\n this.previousResname!, atomTypeIdList, this.previousHetero! // TODO\n )\n }\n\n addAtom (modelindex: number, chainname: string, chainid: string, resname: string, resno: number, hetero: boolean, sstruc?: string|undefined, inscode?: string|undefined) {\n const atomStore = this.structure.atomStore\n const residueStore = this.structure.residueStore\n const chainStore = this.structure.chainStore\n const modelStore = this.structure.modelStore\n\n let addModel = false\n let addChain = false\n let addResidue = false\n\n if (this.currentModelindex !== modelindex) {\n addModel = true\n addChain = true\n addResidue = true\n this.mi += 1\n this.ci += 1\n this.ri += 1\n } else if (this.currentChainid !== chainid) {\n addChain = true\n addResidue = true\n this.ci += 1\n this.ri += 1\n } else if (this.currentResno !== resno || this.currentResname !== resname || this.currentInscode !== inscode) {\n addResidue = true\n this.ri += 1\n }\n this.ai += 1\n\n if (addModel) {\n modelStore.growIfFull()\n modelStore.chainOffset[ this.mi ] = this.ci\n modelStore.chainCount[ this.mi ] = 0\n modelStore.count += 1\n chainStore.modelIndex[ this.ci ] = this.mi\n }\n\n if (addChain) {\n chainStore.growIfFull()\n chainStore.setChainname(this.ci, chainname)\n chainStore.setChainid(this.ci, chainid)\n chainStore.residueOffset[ this.ci ] = this.ri\n chainStore.residueCount[ this.ci ] = 0\n chainStore.count += 1\n chainStore.modelIndex[ this.ci ] = this.mi\n modelStore.chainCount[ this.mi ] += 1\n residueStore.chainIndex[ this.ri ] = this.ci\n }\n\n if (addResidue) {\n this.previousResname = this.currentResname\n this.previousHetero = this.currentHetero\n if (this.ri > 0) this.addResidueType(this.ri - 1)\n residueStore.growIfFull()\n residueStore.resno[ this.ri ] = resno\n if (sstruc !== undefined) {\n residueStore.sstruc[ this.ri ] = sstruc.charCodeAt(0)\n }\n if (inscode !== undefined) {\n residueStore.inscode[ this.ri ] = inscode.charCodeAt(0)\n }\n residueStore.atomOffset[ this.ri ] = this.ai\n residueStore.atomCount[ this.ri ] = 0\n residueStore.count += 1\n residueStore.chainIndex[ this.ri ] = this.ci\n chainStore.residueCount[ this.ci ] += 1\n }\n\n atomStore.count += 1\n atomStore.residueIndex[ this.ai ] = this.ri\n residueStore.atomCount[ this.ri ] += 1\n\n this.currentModelindex = modelindex\n this.currentChainid = chainid\n this.currentResname = resname\n this.currentResno = resno\n this.currentInscode = inscode\n this.currentHetero = hetero\n }\n\n finalize () {\n this.previousResname = this.currentResname\n this.previousHetero = this.currentHetero\n if (this.ri > -1) this.addResidueType(this.ri)\n }\n}\n\nexport default StructureBuilder\n","/**\n * @file Structure Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4 } from 'three'\n\nimport { Debug, Log } from '../globals'\nimport { binarySearchIndexOf } from '../utils'\nimport Helixbundle from '../geometry/helixbundle'\nimport Kdtree from '../geometry/kdtree'\nimport { getSymmetryOperations } from '../symmetry/symmetry-utils'\nimport Assembly from '../symmetry/assembly'\nimport Structure from '../structure/structure'\nimport StructureBuilder from '../structure/structure-builder'\nimport Polymer from '../proxy/polymer'\nimport ResidueProxy from '../proxy/residue-proxy'\n\nimport { UnknownBackboneType, AA3, Bases, AtomicNumbers } from './structure-constants'\n\nexport function reorderAtoms (structure: Structure) {\n if (Debug) Log.time('reorderAtoms')\n\n var ap1 = structure.getAtomProxy()\n var ap2 = structure.getAtomProxy()\n\n function compareModelChainResno (index1: number, index2: number) {\n ap1.index = index1\n ap2.index = index2\n if (ap1.modelIndex < ap2.modelIndex) {\n return -1\n } else if (ap1.modelIndex > ap2.modelIndex) {\n return 1\n } else {\n if (ap1.chainname < ap2.chainname) {\n return -1\n } else if (ap1.chainname > ap2.chainname) {\n return 1\n } else {\n if (ap1.resno < ap2.resno) {\n return -1\n } else if (ap1.resno > ap2.resno) {\n return 1\n } else {\n return 0\n }\n }\n }\n }\n\n structure.atomStore.sort(compareModelChainResno)\n\n if (Debug) Log.timeEnd('reorderAtoms')\n}\n\nexport interface SecStruct {\n helices: [string, number, string, string, number, string, number][]\n sheets: [string, number, string, string, number, string][]\n}\n\nexport function assignSecondaryStructure (structure: Structure, secStruct: SecStruct) {\n if (!secStruct) return\n\n if (Debug) Log.time('assignSecondaryStructure')\n\n const chainnames: string[] = []\n structure.eachModel(function (mp) {\n mp.eachChain(function (cp) {\n chainnames.push(cp.chainname)\n })\n })\n\n const chainnamesSorted = chainnames.slice().sort()\n const chainnamesIndex: number[] = []\n chainnamesSorted.forEach(function (c) {\n chainnamesIndex.push(chainnames.indexOf(c))\n })\n\n // helix assignment\n\n const helices = secStruct.helices.filter(function (h) {\n return binarySearchIndexOf(chainnamesSorted, h[ 0 ]) >= 0\n })\n\n helices.sort(function (h1, h2) {\n const c1 = h1[ 0 ]\n const c2 = h2[ 0 ]\n const r1 = h1[ 1 ]\n const r2 = h2[ 1 ]\n\n if (c1 === c2) {\n if (r1 === r2) {\n return 0\n } else {\n return r1 < r2 ? -1 : 1\n }\n } else {\n const idx1 = binarySearchIndexOf(chainnamesSorted, c1)\n const idx2 = binarySearchIndexOf(chainnamesSorted, c2)\n return chainnamesIndex[ idx1 ] < chainnamesIndex[ idx2 ] ? -1 : 1\n }\n })\n\n const residueStore = structure.residueStore\n\n structure.eachModel(function (mp) {\n let i = 0\n const n = helices.length\n if (n === 0) return\n let helix = helices[ i ]\n let helixRun = false\n let done = false\n\n mp.eachChain(function (cp) {\n let chainChange = false\n\n if (cp.chainname === helix[ 0 ]) {\n const count = cp.residueCount\n const offset = cp.residueOffset\n const end = offset + count\n\n for (let j = offset; j < end; ++j) {\n if (residueStore.resno[ j ] === helix[ 1 ] && // resnoBeg\n residueStore.getInscode(j) === helix[ 2 ] // inscodeBeg\n ) {\n helixRun = true\n }\n\n if (helixRun) {\n residueStore.sstruc[ j ] = helix[ 6 ]\n\n if (residueStore.resno[ j ] === helix[ 4 ] && // resnoEnd\n residueStore.getInscode(j) === helix[ 5 ] // inscodeEnd\n ) {\n helixRun = false\n i += 1\n\n if (i < n) {\n // must look at previous residues as\n // residues may not be ordered by resno\n j = offset - 1\n helix = helices[ i ]\n chainChange = cp.chainname !== helix[ 0 ]\n } else {\n done = true\n }\n }\n }\n\n if (chainChange || done) return\n }\n }\n })\n })\n\n // sheet assignment\n\n const sheets = secStruct.sheets.filter(function (s) {\n return binarySearchIndexOf(chainnamesSorted, s[ 0 ]) >= 0\n })\n\n sheets.sort(function (s1, s2) {\n const c1 = s1[ 0 ]\n const c2 = s2[ 0 ]\n\n if (c1 === c2) return 0\n const idx1 = binarySearchIndexOf(chainnamesSorted, c1)\n const idx2 = binarySearchIndexOf(chainnamesSorted, c2)\n return chainnamesIndex[ idx1 ] < chainnamesIndex[ idx2 ] ? -1 : 1\n })\n\n const strandCharCode = 'e'.charCodeAt(0)\n structure.eachModel(function (mp) {\n let i = 0\n const n = sheets.length\n if (n === 0) return\n let sheet = sheets[ i ]\n let sheetRun = false\n let done = false\n\n mp.eachChain(function (cp) {\n let chainChange = false\n\n if (cp.chainname === sheet[ 0 ]) {\n const count = cp.residueCount\n const offset = cp.residueOffset\n const end = offset + count\n\n for (let j = offset; j < end; ++j) {\n if (residueStore.resno[ j ] === sheet[ 1 ] && // resnoBeg\n residueStore.getInscode(j) === sheet[ 2 ] // inscodeBeg\n ) {\n sheetRun = true\n }\n\n if (sheetRun) {\n residueStore.sstruc[ j ] = strandCharCode\n\n if (residueStore.resno[ j ] === sheet[ 4 ] && // resnoEnd\n residueStore.getInscode(j) === sheet[ 5 ] // inscodeEnd\n ) {\n sheetRun = false\n i += 1\n\n if (i < n) {\n // must look at previous residues as\n // residues may not be ordered by resno\n j = offset - 1\n sheet = sheets[ i ]\n chainChange = cp.chainname !== sheet[ 0 ]\n } else {\n done = true\n }\n }\n }\n\n if (chainChange || done) return\n }\n }\n })\n })\n\n if (Debug) Log.timeEnd('assignSecondaryStructure')\n}\n\nexport const calculateSecondaryStructure = (function () {\n // Implementation for proteins based on \"pv\"\n //\n // assigns secondary structure information based on a simple and very fast\n // algorithm published by Zhang and Skolnick in their TM-align paper.\n // Reference:\n //\n // TM-align: a protein structure alignment algorithm based on the Tm-score\n // (2005) NAR, 33(7) 2302-2309\n\n const zhangSkolnickSS = function (polymer: Polymer, i: number, distances: number[], delta: number) {\n const structure = polymer.structure\n const offset = polymer.residueIndexStart\n const rp1 = structure.getResidueProxy()\n const rp2 = structure.getResidueProxy()\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n for (let j = Math.max(0, i - 2); j <= i; ++j) {\n for (let k = 2; k < 5; ++k) {\n if (j + k >= polymer.residueCount) {\n continue\n }\n\n rp1.index = offset + j\n rp2.index = offset + j + k\n ap1.index = rp1.traceAtomIndex\n ap2.index = rp2.traceAtomIndex\n\n const d = ap1.distanceTo(ap2)\n\n if (Math.abs(d - distances[ k - 2 ]) > delta) {\n return false\n }\n }\n }\n\n return true\n }\n\n const isHelical = function (polymer: Polymer, i: number) {\n const helixDistances = [ 5.45, 5.18, 6.37 ]\n const helixDelta = 2.1\n return zhangSkolnickSS(polymer, i, helixDistances, helixDelta)\n }\n\n const isSheet = function (polymer: Polymer, i: number) {\n const sheetDistances = [ 6.1, 10.4, 13.0 ]\n const sheetDelta = 1.42\n return zhangSkolnickSS(polymer, i, sheetDistances, sheetDelta)\n }\n\n const proteinPolymer = function (p: Polymer) {\n const residueStore = p.residueStore\n const offset = p.residueIndexStart\n for (let i = 0, il = p.residueCount; i < il; ++i) {\n let sstruc = 'c'\n if (isHelical(p, i)) {\n sstruc = 'h'\n } else if (isSheet(p, i)) {\n sstruc = 'e'\n }\n residueStore.sstruc[ offset + i ] = sstruc.charCodeAt(0)\n }\n }\n\n const cgPolymer = function (p: Polymer) {\n const localAngle = 20\n const centerDist = 2.0\n\n const residueStore = p.residueStore\n const offset = p.residueIndexStart\n\n const helixbundle = new Helixbundle(p)\n const pos = helixbundle.position\n\n const c1 = new Vector3()\n const c2 = new Vector3()\n\n for (let i = 0, il = p.residueCount; i < il; ++i) {\n c1.fromArray(pos.center as any, i * 3) // TODO\n c2.fromArray(pos.center as any, i * 3 + 3) // TODO\n const d = c1.distanceTo(c2)\n\n if (d < centerDist && d > 1.0 && pos.bending[ i ] < localAngle) {\n residueStore.sstruc[ offset + i ] = 'h'.charCodeAt(0)\n residueStore.sstruc[ offset + i + 1 ] = 'h'.charCodeAt(0)\n }\n }\n }\n\n return function calculateSecondaryStructure (structure: Structure) {\n if (Debug) Log.time('calculateSecondaryStructure')\n\n structure.eachPolymer(function (p) {\n // assign secondary structure\n if (p.residueCount < 4) return\n if (p.isCg()) {\n cgPolymer(p)\n } else if (p.isProtein()) {\n proteinPolymer(p)\n } else {\n return\n }\n\n // set lone secondary structure assignments to \"c\"\n let prevSstruc: string\n let sstrucCount = 0\n p.eachResidue(function (r: ResidueProxy) {\n if (r.sstruc === prevSstruc) {\n sstrucCount += 1\n } else {\n if (sstrucCount === 1) {\n r.index -= 1\n r.sstruc = 'c'\n }\n sstrucCount = 1\n prevSstruc = r.sstruc\n }\n })\n })\n\n if (Debug) Log.timeEnd('calculateSecondaryStructure')\n }\n}())\n\n// const ChainnameAlphabet = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\" +\n// \"abcdefghijklmnopqrstuvwxyz\" +\n// \"0123456789\";\nconst ChainnameAlphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\n\nexport function getChainname (index: number) {\n const n = ChainnameAlphabet.length\n let j = index\n let k = 0\n let chainname = ChainnameAlphabet[j % n]\n while (j >= n) {\n j = Math.floor(j / n)\n chainname += ChainnameAlphabet[j % n]\n k += 1\n }\n if (k >= 5) {\n Log.warn('chainname overflow')\n }\n return chainname\n}\n\ninterface ChainData {\n mIndex: number\n chainname: string\n rStart: number\n rCount: number\n}\n\n/**\n * When no chain names are set for the given structure, calculates\n * chains based on:\n * - polymer connectivity: when adjacent residues are not bonded, a new chain is created.\n * - non polymer chemical type: adjacent residues which are not polymers but are of the same\n * chemical type (e.g. water molecules) are grouped into the same chain.\n **/\nexport function calculateChainnames (structure: Structure, useExistingBonds = false) {\n if (Debug) Log.time('calculateChainnames')\n\n let doAutoChainName = true\n structure.eachChain(function (c) {\n if (c.chainname) doAutoChainName = false\n })\n\n if (doAutoChainName) {\n const modelStore = structure.modelStore\n const chainStore = structure.chainStore\n const residueStore = structure.residueStore\n\n const addChain = function (mIndex: number, chainname: string, rOffset: number, rCount: number) {\n const ci = chainStore.count\n for (let i = 0; i < rCount; ++i) {\n residueStore.chainIndex[ rOffset + i ] = ci\n }\n chainStore.growIfFull()\n chainStore.modelIndex[ ci ] = mIndex\n chainStore.setChainname(ci, chainname)\n chainStore.setChainid(ci, chainname)\n chainStore.residueOffset[ ci ] = rOffset\n chainStore.residueCount[ ci ] = rCount\n chainStore.count += 1\n modelStore.chainCount[ mIndex ] += 1\n }\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n let i = 0\n let mi = 0\n let rStart = 0\n let rEnd = 0\n const chainData: ChainData[] = []\n\n if (residueStore.count === 1) {\n chainData.push({\n mIndex: 0,\n chainname: 'A',\n rStart: 0,\n rCount: 1\n })\n } else {\n structure.eachResidueN(2, function (rp1: ResidueProxy, rp2: ResidueProxy) {\n let newChain = false\n\n const bbType1 = rp1.backboneType\n const bbType2 = rp2.backboneType\n const bbTypeUnk = UnknownBackboneType\n\n rEnd = rp1.index\n\n if (rp1.modelIndex !== rp2.modelIndex) {\n newChain = true\n } else if (rp1.moleculeType !== rp2.moleculeType) {\n newChain = true\n } else if (bbType1 !== bbTypeUnk && bbType1 === bbType2) {\n ap1.index = rp1.backboneEndAtomIndex\n ap2.index = rp2.backboneStartAtomIndex\n if (useExistingBonds) {\n newChain = !ap1.hasBondTo(ap2)\n } else {\n newChain = !ap1.connectedTo(ap2)\n }\n }\n\n // current chain goes to end of the structure\n if (!newChain && rp2.index === residueStore.count - 1) {\n newChain = true\n rEnd = rp2.index\n }\n\n if (newChain) {\n chainData.push({\n mIndex: mi,\n chainname: getChainname(i),\n rStart: rStart,\n rCount: rEnd - rStart + 1\n })\n\n i += 1\n\n if (rp1.modelIndex !== rp2.modelIndex) {\n i = 0\n mi += 1\n }\n\n // new chain for the last residue of the structure\n if (rp2.index === residueStore.count - 1 && rEnd !== rp2.index) {\n chainData.push({\n mIndex: mi,\n chainname: getChainname(i),\n rStart: residueStore.count - 1,\n rCount: 1\n })\n }\n\n rStart = rp2.index\n rEnd = rp2.index\n }\n })\n }\n\n //\n\n chainStore.count = 0\n modelStore.chainCount.fill(0, 0, modelStore.count)\n modelStore.chainOffset.fill(0, 0, modelStore.count)\n chainData.forEach(function (d) {\n addChain(d.mIndex, d.chainname, d.rStart, d.rCount)\n })\n\n let chainOffset = 0\n structure.eachModel(function (mp) {\n modelStore.chainOffset[ mp.index ] = chainOffset\n chainOffset += modelStore.chainCount[ mp.index ]\n })\n }\n\n if (Debug) Log.timeEnd('calculateChainnames')\n}\n\nexport function calculateBonds (structure: Structure, inferBonds: InferBondsOptions='all') {\n if (inferBonds === 'none') return \n if (Debug) Log.time('calculateBonds')\n\n calculateBondsWithin(structure, false, inferBonds)\n calculateBondsBetween(structure)\n\n if (Debug) Log.timeEnd('calculateBonds')\n}\n\n/**\n * Should Bonds be inferred for `all` atoms, `none` or `auto`\n * If `auto`, any hetgroup residue with at least one CONECT record will \n * not have bonding inferred, and will rely on the CONECT records\n */\nexport type InferBondsOptions = 'all' | 'none' | 'auto'\n\nexport interface ResidueBonds {\n atomIndices1: number[]\n atomIndices2: number[]\n bondOrders: number[]\n}\n\n\nconst BondOrderTable: { [k: string]: number } = {\n 'HIS|CD2|CG': 2,\n 'HIS|CE1|ND1': 2,\n 'ARG|CZ|NH2': 2,\n 'PHE|CE1|CZ': 2,\n 'PHE|CD2|CE2': 2,\n 'PHE|CD1|CG': 2,\n 'TRP|CD1|CG': 2,\n 'TRP|CD2|CE2': 2,\n 'TRP|CE3|CZ3': 2,\n 'TRP|CH2|CZ2': 2,\n 'ASN|CG|OD1': 2,\n 'GLN|CD|OE1': 2,\n 'TYR|CD1|CG': 2,\n 'TYR|CD2|CE2': 2,\n 'TYR|CE1|CZ': 2,\n 'ASP|CG|OD1': 2,\n 'GLU|CD|OE1': 2,\n\n 'G|C8|N7': 2,\n 'G|C4|C5': 2,\n 'G|C2|N3': 2,\n 'G|C6|O6': 2,\n 'C|C4|N3': 2,\n 'C|C5|C6': 2,\n 'C|C2|O2': 2,\n 'A|C2|N3': 2,\n 'A|C6|N1': 2,\n 'A|C4|C5': 2,\n 'A|C8|N7': 2,\n 'U|C5|C6': 2,\n 'U|C2|O2': 2,\n 'U|C4|O4': 2,\n\n 'DG|C8|N7': 2,\n 'DG|C4|C5': 2,\n 'DG|C2|N3': 2,\n 'DG|C6|O6': 2,\n 'DC|C4|N3': 2,\n 'DC|C5|C6': 2,\n 'DC|C2|O2': 2,\n 'DA|C2|N3': 2,\n 'DA|C6|N1': 2,\n 'DA|C4|C5': 2,\n 'DA|C8|N7': 2,\n 'DT|C5|C6': 2,\n 'DT|C2|O2': 2,\n 'DT|C4|O4': 2\n}\nfunction getBondOrderFromTable (resname: string, atomname1: string, atomname2: string) {\n [ atomname1, atomname2 ] = atomname1 < atomname2 ? [ atomname1, atomname2 ] : [ atomname2, atomname1 ]\n if (AA3.includes(resname) && atomname1 === 'C' && atomname2 === 'O') return 2\n if (Bases.includes(resname) && atomname1 === 'OP1' && atomname2 === 'P') return 2\n return BondOrderTable[ `${resname}|${atomname1}|${atomname2}` ] || 1\n}\n\nexport function calculateResidueBonds (r: ResidueProxy) {\n const structure = r.structure\n const a1 = structure.getAtomProxy()\n const a2 = structure.getAtomProxy()\n\n const count = r.atomCount\n const offset = r.atomOffset\n const end = offset + count\n const end1 = end - 1\n\n const atomIndices1 = []\n const atomIndices2 = []\n const bondOrders = []\n\n if (count > 500) {\n if (Debug) Log.warn('more than 500 atoms, skip residue for auto-bonding', r.qualifiedName())\n } else {\n if (count > 50) {\n const kdtree = new Kdtree(r, true)\n const radius = r.isCg() ? 1.2 : 2.3\n\n for (let i = offset; i < end1; ++i) {\n a1.index = i\n const maxd = a1.covalent + radius + 0.3\n const nearestAtoms = kdtree.nearest(a1 as any, Infinity, maxd * maxd) // TODO\n const m = nearestAtoms.length\n for (let j = 0; j < m; ++j) {\n a2.index = nearestAtoms[ j ].index\n if (a1.index < a2.index) {\n if (a1.connectedTo(a2)) {\n atomIndices1.push(a1.index - offset)\n atomIndices2.push(a2.index - offset)\n bondOrders.push(getBondOrderFromTable(a1.resname, a1.atomname, a2.atomname))\n }\n }\n }\n }\n } else {\n for (let i = offset; i < end1; ++i) {\n a1.index = i\n for (let j = i + 1; j <= end1; ++j) {\n a2.index = j\n if (a1.connectedTo(a2)) {\n atomIndices1.push(i - offset)\n atomIndices2.push(j - offset)\n bondOrders.push(getBondOrderFromTable(a1.resname, a1.atomname, a2.atomname))\n }\n }\n }\n }\n }\n\n return {\n atomIndices1: atomIndices1,\n atomIndices2: atomIndices2,\n bondOrders: bondOrders\n }\n}\n\nexport function calculateAtomBondMap (structure: Structure) {\n if (Debug) Log.time('calculateAtomBondMap')\n\n var atomBondMap: number[][] = []\n\n structure.eachBond(function (bp) {\n var ai1 = bp.atomIndex1\n var ai2 = bp.atomIndex2\n if (atomBondMap[ ai1 ] === undefined) atomBondMap[ ai1 ] = []\n atomBondMap[ ai1 ][ ai2 ] = bp.index\n })\n\n if (Debug) Log.timeEnd('calculateAtomBondMap')\n\n return atomBondMap\n}\n\nexport function calculateBondsWithin (structure: Structure, onlyAddRung = false, inferBonds: InferBondsOptions='all') {\n if (Debug) Log.time('calculateBondsWithin')\n\n const bondStore = structure.bondStore\n const rungBondStore = structure.rungBondStore\n const rungAtomSet = structure.getAtomSet(false)\n const a1 = structure.getAtomProxy()\n const a2 = structure.getAtomProxy()\n const bp = structure.getBondProxy()\n const atomBondMap = onlyAddRung ? null : calculateAtomBondMap(structure)\n\n let bondedAtoms: Set\n if (!onlyAddRung && inferBonds === 'auto') {\n bondedAtoms = new Set()\n atomBondMap!.forEach((a, i) => {\n bondedAtoms.add(i)\n a.forEach(j => {bondedAtoms.add(j)})\n })\n }\n\n structure.eachResidue(function (r) {\n if (!onlyAddRung && atomBondMap) {\n const count = r.atomCount\n const offset = r.atomOffset\n\n if (count > 500) {\n Log.warn('more than 500 atoms, skip residue for auto-bonding', r.qualifiedName())\n return\n }\n\n if (inferBonds === 'auto' && r.hetero) {\n // Are bonds present on this residue?\n for (let rai=r.atomOffset; rai {\n ncsMatrixList.forEach(nm => {\n ncsUnitcellMatrixList.push(sm.clone().multiply(nm))\n })\n })\n unitcellAssembly.addPart(ncsUnitcellMatrixList)\n } else {\n unitcellAssembly.addPart(unitcellMatrixList)\n }\n\n const vec = new Vector3()\n const supercellAssembly = new Assembly('SUPERCELL')\n const supercellMatrixList = Array.prototype.concat.call(\n getMatrixList(vec.set(1, 0, 0)), // 655\n getMatrixList(vec.set(0, 1, 0)), // 565\n getMatrixList(vec.set(0, 0, 1)), // 556\n\n getMatrixList(vec.set(-1, 0, 0)), // 455\n getMatrixList(vec.set(0, -1, 0)), // 545\n getMatrixList(vec.set(0, 0, -1)), // 554\n\n getMatrixList(vec.set(1, 1, 0)), // 665\n getMatrixList(vec.set(1, 0, 1)), // 656\n getMatrixList(vec.set(0, 1, 1)), // 566\n\n getMatrixList(vec.set(-1, -1, 0)), // 445\n getMatrixList(vec.set(-1, 0, -1)), // 454\n getMatrixList(vec.set(0, -1, -1)), // 544\n\n getMatrixList(vec.set(1, -1, -1)), // 644\n getMatrixList(vec.set(1, 1, -1)), // 664\n getMatrixList(vec.set(1, -1, 1)), // 646\n getMatrixList(vec.set(-1, 1, 1)), // 466\n getMatrixList(vec.set(-1, -1, 1)), // 446\n getMatrixList(vec.set(-1, 1, -1)), // 464\n\n getMatrixList(vec.set(0, 1, -1)), // 564\n getMatrixList(vec.set(0, -1, 1)), // 546\n getMatrixList(vec.set(1, 0, -1)), // 654\n getMatrixList(vec.set(-1, 0, 1)), // 456\n getMatrixList(vec.set(1, -1, 0)), // 645\n getMatrixList(vec.set(-1, 1, 0)), // 465\n\n getMatrixList(), // 555\n getMatrixList(vec.set(1, 1, 1)), // 666\n getMatrixList(vec.set(-1, -1, -1)) // 444\n )\n if (structure.biomolDict.NCS) {\n const ncsSupercellMatrixList: Matrix4[] = []\n supercellMatrixList.forEach(function (sm: Matrix4) {\n ncsMatrixList.forEach(function (nm) {\n ncsSupercellMatrixList.push(sm.clone().multiply(nm))\n })\n })\n supercellAssembly.addPart(ncsSupercellMatrixList)\n } else {\n supercellAssembly.addPart(supercellMatrixList)\n }\n\n structure.biomolDict.UNITCELL = unitcellAssembly\n structure.biomolDict.SUPERCELL = supercellAssembly\n\n if (Debug) Log.timeEnd('buildUnitcellAssembly')\n}\n\nconst elm1 = [ 'H', 'C', 'O', 'N', 'S', 'P' ]\nconst elm2 = [ 'NA', 'CL', 'FE' ]\n\nexport function guessElement (atomName: string) {\n // Retain first group of letters in atomName\n let at = atomName.toUpperCase()\n let begin = 0, end = 0\n for (let i = 0; i < at.length ; i++) {\n if (at.charCodeAt(i) < 65) {\n if (end > 0) break\n ++begin\n }\n else end = i + 1\n }\n if (begin > 0 || end < at.length) at = at.substring(begin, end)\n \n const n = at.length\n\n if (n === 0) return ''\n if (n === 1) return at\n if (n === 2) {\n if (elm2.indexOf(at) !== -1) return at\n if (elm1.indexOf(at[0]) !== -1) return at[0]\n if (at in AtomicNumbers) return at\n }\n if (n >= 3) {\n if (elm1.indexOf(at[0]) !== -1) return at[0]\n }\n return ''\n}\n\n/**\n * Assigns ResidueType bonds.\n * @param {Structure} structure - the structure object\n * @return {undefined}\n */\nexport function assignResidueTypeBonds (structure: Structure) {\n // if( Debug ) Log.time( \"assignResidueTypeBonds\" )\n\n const bondHash = structure.bondHash! // TODO\n const countArray = bondHash.countArray\n const offsetArray = bondHash.offsetArray\n const indexArray = bondHash.indexArray\n const bp = structure.getBondProxy()\n\n structure.eachResidue(function (rp) {\n const residueType = rp.residueType\n if (residueType.bonds !== undefined) return\n\n var atomOffset = rp.atomOffset\n var atomIndices1: number[] = []\n var atomIndices2: number[] = []\n var bondOrders: number[] = []\n var bondDict: { [k: string]: boolean } = {}\n\n const nextAtomOffset = atomOffset + rp.atomCount\n\n rp.eachAtom(function (ap) {\n const index = ap.index\n const offset = offsetArray[ index ]\n const count = countArray[ index ]\n for (let i = 0, il = count; i < il; ++i) {\n bp.index = indexArray[ offset + i ]\n let idx1 = bp.atomIndex1\n if (idx1 < atomOffset || idx1 >= nextAtomOffset) {\n // Don't add bonds outside of this resiude\n continue\n }\n let idx2 = bp.atomIndex2\n if (idx2 < atomOffset || idx2 >= nextAtomOffset) {\n continue\n }\n\n if (idx1 > idx2) {\n const tmp = idx2\n idx2 = idx1\n idx1 = tmp\n }\n const hash = idx1 + '|' + idx2\n if (bondDict[ hash ] === undefined) {\n bondDict[ hash ] = true\n atomIndices1.push(idx1 - atomOffset)\n atomIndices2.push(idx2 - atomOffset)\n bondOrders.push(bp.bondOrder)\n }\n }\n })\n\n residueType.bonds = {\n atomIndices1: atomIndices1,\n atomIndices2: atomIndices2,\n bondOrders: bondOrders\n }\n })\n\n // if( Debug ) Log.timeEnd( \"assignResidueTypeBonds\" )\n}\n\nexport function concatStructures (name: string, ...structures: Structure[]) {\n if( Debug ) Log.time( \"concatStructures\" )\n\n const s = new Structure(name, '')\n const sb = new StructureBuilder(s)\n\n const atomStore = s.atomStore as any\n const atomMap = s.atomMap\n atomStore.addField('formalCharge', 1, 'int8')\n atomStore.addField('partialCharge', 1, 'float32')\n\n const atomIndexDict: { [k: number]: number } = {}\n\n let idx = 0\n let atomCount = 0\n let modelCount = 0\n structures.forEach(structure => {\n structure.eachAtom(a => {\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(a.atomname, a.element)\n\n atomStore.x[ idx ] = a.x\n atomStore.y[ idx ] = a.y\n atomStore.z[ idx ] = a.z\n atomStore.serial[ idx ] = a.serial\n atomStore.formalCharge[ idx ] = a.formalCharge\n atomStore.partialCharge[ idx ] = a.partialCharge\n atomStore.altloc[ idx ] = a.altloc\n atomStore.occupancy[ idx ] = a.occupancy\n atomStore.bfactor[ idx ] = a.bfactor\n\n sb.addAtom(\n a.modelIndex + modelCount,\n a.chainname,\n a.chainid,\n a.resname,\n a.resno,\n a.hetero === 1,\n a.sstruc,\n a.inscode\n )\n\n atomIndexDict[a.index + atomCount] = idx\n idx += 1\n })\n atomCount += structure.atomStore.count\n modelCount += structure.modelStore.count\n })\n\n const bondStore = s.bondStore\n const a1 = s.getAtomProxy()\n const a2 = s.getAtomProxy()\n\n atomCount = 0\n structures.forEach(structure => {\n structure.eachBond(b => {\n a1.index = atomIndexDict[ b.atomIndex1 + atomCount ]\n a2.index = atomIndexDict[ b.atomIndex2 + atomCount ]\n bondStore.addBond(a1, a2, b.bondOrder)\n })\n atomCount += structure.atomStore.count\n })\n\n sb.finalize()\n\n calculateBondsBetween(s, true) // calculate backbone bonds\n calculateBondsWithin(s, true) // calculate rung bonds\n\n s.finalizeAtoms()\n s.finalizeBonds()\n assignResidueTypeBonds(s)\n\n if( Debug ) Log.timeEnd( \"concatStructures\" )\n\n return s\n}\n","/**\n * @file Atom Type\n * @author Alexander Rose \n * @private\n */\n\nimport { guessElement } from '../structure/structure-utils'\nimport {\n AtomicNumbers, DefaultAtomicNumber,\n VdwRadii, DefaultVdwRadius,\n CovalentRadii, DefaultCovalentRadius,\n Valences, DefaultValence,\n OuterShellElectronCounts, DefaultOuterShellElectronCount\n} from '../structure/structure-constants'\nimport Structure from '../structure/structure'\n\n// Li, Na, K, Rb, Cs Fr\nconst AlkaliMetals = [ 3, 11, 19, 37, 55, 87 ]\n\n// Be, Mg, Ca, Sr, Ba, Ra\nconst AlkalineEarthMetals = [ 4, 12, 20, 38, 56, 88 ]\n\n// C, P, S, Se\nconst PolyatomicNonmetals = [ 6, 15, 16, 34, ]\n\n// H, N, O, F, Cl, Br, I\nconst DiatomicNonmetals = [ 1, 7, 8, 9, 17, 35, 53 ]\n\n// He, Ne, Ar, Kr, Xe, Rn\nconst NobleGases = [ 2, 10, 18, 36, 54, 86 ]\n\n// Zn, Ga, Cd, In, Sn, Hg, Ti, Pb, Bi, Po, Cn\nconst PostTransitionMetals = [ 13, 30, 31, 48, 49, 50, 80, 81, 82, 83, 84, 85, 112 ]\n\n// B, Si, Ge, As, Sb, Te, At\nconst Metalloids = [ 5, 14, 32, 33, 51, 52, 85 ]\n\n// F, Cl, Br, I, At\nconst Halogens = [ 9, 17, 35, 53, 85 ]\n\n/**\n * Atom type\n */\nclass AtomType {\n element: string\n number: number\n vdw: number\n covalent: number\n\n /**\n * @param {Structure} structure - the structure object\n * @param {String} atomname - the name of the atom\n * @param {String} element - the chemical element\n */\n constructor (readonly structure: Structure, readonly atomname: string, element?: string) {\n element = element || guessElement(atomname)\n\n this.element = element\n this.number = AtomicNumbers[ element ] || DefaultAtomicNumber\n this.vdw = VdwRadii[ this.number ] || DefaultVdwRadius\n this.covalent = CovalentRadii[ this.number ] || DefaultCovalentRadius\n }\n\n getDefaultValence() {\n const vl = Valences[ this.number ]\n return vl ? vl[ 0 ] : DefaultValence\n }\n\n getValenceList () {\n return Valences[ this.number ] || []\n }\n\n getOuterShellElectronCount () {\n return OuterShellElectronCounts[ this.number ] || DefaultOuterShellElectronCount\n }\n\n isMetal () {\n return (\n this.isAlkaliMetal() ||\n this.isAlkalineEarthMetal() ||\n this.isLanthanide() ||\n this.isActinide() ||\n this.isTransitionMetal() ||\n this.isPostTransitionMetal()\n )\n }\n\n isNonmetal () {\n return (\n this.isDiatomicNonmetal() ||\n this.isPolyatomicNonmetal() ||\n this.isNobleGas()\n )\n }\n\n isMetalloid () {\n return Metalloids.includes(this.number)\n }\n\n isHalogen () {\n return Halogens.includes(this.number)\n }\n\n isDiatomicNonmetal () {\n return DiatomicNonmetals.includes(this.number)\n }\n\n isPolyatomicNonmetal () {\n return PolyatomicNonmetals.includes(this.number)\n }\n\n isAlkaliMetal () {\n return AlkaliMetals.includes(this.number)\n }\n\n isAlkalineEarthMetal () {\n return AlkalineEarthMetals.includes(this.number)\n }\n\n isNobleGas () {\n return NobleGases.includes(this.number)\n }\n\n isTransitionMetal () {\n const no = this.number\n return (\n (no >= 21 && no <= 29) ||\n (no >= 39 && no <= 47) ||\n (no >= 72 && no <= 79) ||\n (no >= 104 && no <= 108)\n )\n }\n\n isPostTransitionMetal () {\n return PostTransitionMetals.includes(this.number)\n }\n\n isLanthanide () {\n return this.number >= 57 && this.number <= 71\n }\n\n isActinide () {\n return this.number >= 89 && this.number <= 103\n }\n\n}\n\nexport default AtomType","/**\n * @file Atom Map\n * @author Alexander Rose \n * @private\n */\n\nimport AtomType from './atom-type'\nimport { guessElement } from '../structure/structure-utils'\nimport Structure from '../structure/structure'\n\nfunction getHash (atomname: string, element: string) {\n return atomname + '|' + element\n}\n\nclass AtomMap {\n dict: { [k: string]: number } = {}\n list: AtomType[] = []\n\n constructor (readonly structure: Structure) {\n this.structure = structure\n }\n\n add (atomname: string, element?: string) {\n atomname = atomname.toUpperCase()\n if (!element) {\n element = guessElement(atomname)\n } else {\n element = element.toUpperCase()\n }\n const hash = getHash(atomname, element)\n let id = this.dict[ hash ]\n if (id === undefined) {\n const atomType = new AtomType(this.structure, atomname, element)\n id = this.list.length\n this.dict[ hash ] = id\n this.list.push(atomType)\n }\n return id\n }\n\n get (id: number) {\n return this.list[ id ]\n }\n}\n\nexport default AtomMap\n","/**\n * @file Residue Type\n * @author Alexander Rose \n * @author Fred Ludlow\n * @private\n */\n\nimport { defaults } from '../utils'\nimport PrincipalAxes from '../math/principal-axes'\nimport { Matrix } from '../math/matrix-utils'\nimport { calculateResidueBonds, ResidueBonds } from '../structure/structure-utils'\nimport {\n Elements,\n ProteinType, RnaType, DnaType, WaterType, IonType, SaccharideType, UnknownType,\n ProteinBackboneType, RnaBackboneType, DnaBackboneType, UnknownBackboneType,\n CgProteinBackboneType, CgRnaBackboneType, CgDnaBackboneType,\n ChemCompProtein, ChemCompRna, ChemCompDna, ChemCompSaccharide,\n AA3, PurinBases, RnaBases, DnaBases, Bases, IonNames, WaterNames, SaccharideNames,\n ProteinBackboneAtoms, NucleicBackboneAtoms, ResidueTypeAtoms\n} from '../structure/structure-constants'\nimport Structure from '../structure/structure'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\n\nexport interface BondGraph {\n [k: number]: number[]\n}\n\nexport interface RingData {\n atomRings: number[][] // sparse array:\n // atomRings[atomIdx] -> array of ring indices\n rings: number[][] // rings as arrays of indices\n}\n\n/**\n * Residue type\n */\nexport default class ResidueType {\n resname: string\n atomTypeIdList: number[]\n hetero: number\n chemCompType: string\n bonds?: ResidueBonds\n rings?: RingData\n bondGraph?: BondGraph\n aromaticAtoms?: Uint8Array\n aromaticRings?: number[][]\n\n atomCount: number\n\n moleculeType: number\n backboneType: number\n backboneEndType: number\n backboneStartType: number\n backboneIndexList: number[]\n\n traceAtomIndex: number\n direction1AtomIndex: number\n direction2AtomIndex: number\n backboneStartAtomIndex: number\n backboneEndAtomIndex: number\n rungEndAtomIndex: number\n\n // Sparse array containing the reference atom index for each bond.\n bondReferenceAtomIndices: number[] = []\n\n /**\n * @param {Structure} structure - the structure object\n * @param {String} resname - name of the residue\n * @param {Array} atomTypeIdList - list of IDs of {@link AtomType}s corresponding\n * to the atoms of the residue\n * @param {Boolean} hetero - hetero flag\n * @param {String} chemCompType - chemical component type\n * @param {Object} [bonds] - TODO\n */\n constructor (readonly structure: Structure, resname: string, atomTypeIdList: number[], hetero: boolean, chemCompType: string, bonds?: ResidueBonds) {\n this.resname = resname\n this.atomTypeIdList = atomTypeIdList\n this.hetero = hetero ? 1 : 0\n this.chemCompType = chemCompType\n this.bonds = bonds\n this.atomCount = atomTypeIdList.length\n\n this.moleculeType = this.getMoleculeType()\n this.backboneType = this.getBackboneType(0)\n this.backboneEndType = this.getBackboneType(-1)\n this.backboneStartType = this.getBackboneType(1)\n this.backboneIndexList = this.getBackboneIndexList()\n\n const atomnames = ResidueTypeAtoms[ this.backboneType ]\n const atomnamesStart = ResidueTypeAtoms[ this.backboneStartType ]\n const atomnamesEnd = ResidueTypeAtoms[ this.backboneEndType ]\n\n const traceIndex = this.getAtomIndexByName(atomnames.trace)\n this.traceAtomIndex = defaults(traceIndex, -1)\n\n const dir1Index = this.getAtomIndexByName(atomnames.direction1)\n this.direction1AtomIndex = defaults(dir1Index, -1)\n\n const dir2Index = this.getAtomIndexByName(atomnames.direction2)\n this.direction2AtomIndex = defaults(dir2Index, -1)\n\n const bbStartIndex = this.getAtomIndexByName(atomnamesStart.backboneStart)\n this.backboneStartAtomIndex = defaults(bbStartIndex, -1)\n\n const bbEndIndex = this.getAtomIndexByName(atomnamesEnd.backboneEnd)\n this.backboneEndAtomIndex = defaults(bbEndIndex, -1)\n\n let rungEndIndex\n if (PurinBases.includes(resname)) {\n rungEndIndex = this.getAtomIndexByName('N1')\n } else {\n rungEndIndex = this.getAtomIndexByName('N3')\n }\n this.rungEndAtomIndex = defaults(rungEndIndex, -1)\n }\n\n getBackboneIndexList () {\n const backboneIndexList: number[] = []\n let atomnameList\n switch (this.moleculeType) {\n case ProteinType:\n atomnameList = ProteinBackboneAtoms\n break\n case RnaType:\n case DnaType:\n atomnameList = NucleicBackboneAtoms\n break\n default:\n return backboneIndexList\n }\n const atomMap = this.structure.atomMap\n const atomTypeIdList = this.atomTypeIdList\n for (let i = 0, il = this.atomCount; i < il; ++i) {\n const atomType = atomMap.get(atomTypeIdList[ i ])\n if (atomnameList.includes(atomType.atomname)) {\n backboneIndexList.push(i)\n }\n }\n return backboneIndexList\n }\n\n getMoleculeType () {\n if (this.isProtein()) {\n return ProteinType\n } else if (this.isRna()) {\n return RnaType\n } else if (this.isDna()) {\n return DnaType\n } else if (this.isWater()) {\n return WaterType\n } else if (this.isIon()) {\n return IonType\n } else if (this.isSaccharide()) {\n return SaccharideType\n } else {\n return UnknownType\n }\n }\n\n getBackboneType (position: number) {\n if (this.hasProteinBackbone(position)) {\n return ProteinBackboneType\n } else if (this.hasRnaBackbone(position)) {\n return RnaBackboneType\n } else if (this.hasDnaBackbone(position)) {\n return DnaBackboneType\n } else if (this.hasCgProteinBackbone(position)) {\n return CgProteinBackboneType\n } else if (this.hasCgRnaBackbone(position)) {\n return CgRnaBackboneType\n } else if (this.hasCgDnaBackbone(position)) {\n return CgDnaBackboneType\n } else {\n return UnknownBackboneType\n }\n }\n\n isProtein () {\n if (this.chemCompType) {\n return ChemCompProtein.includes(this.chemCompType)\n } else {\n return (\n this.hasAtomWithName('CA', 'C', 'N') ||\n AA3.includes(this.resname)\n )\n }\n }\n\n isCg () {\n const backboneType = this.backboneType\n return (\n backboneType === CgProteinBackboneType ||\n backboneType === CgRnaBackboneType ||\n backboneType === CgDnaBackboneType\n )\n }\n\n isNucleic () {\n return this.isRna() || this.isDna()\n }\n\n isRna () {\n if (this.chemCompType) {\n return ChemCompRna.includes(this.chemCompType)\n } else if (this.hetero === 1) {\n return false\n } else {\n return (\n this.hasAtomWithName(\n [ 'P', \"O3'\", 'O3*' ], [ \"C4'\", 'C4*' ], [ \"O2'\", 'O2*', \"F2'\", 'F2*' ]\n ) ||\n (RnaBases.includes(this.resname) &&\n (this.hasAtomWithName([ \"O2'\", 'O2*', \"F2'\", 'F2*' ])))\n )\n }\n }\n\n isDna () {\n if (this.chemCompType) {\n return ChemCompDna.includes(this.chemCompType)\n } else if (this.hetero === 1) {\n return false\n } else {\n return (\n (this.hasAtomWithName([ 'P', \"O3'\", 'O3*' ], [ \"C3'\", 'C3*' ]) &&\n !this.hasAtomWithName([ \"O2'\", 'O2*', \"F2'\", 'F2*' ])) ||\n DnaBases.includes(this.resname)\n )\n }\n }\n\n isHetero () {\n return this.hetero === 1\n }\n\n isIon () {\n return IonNames.includes(this.resname)\n }\n\n isWater () {\n return WaterNames.includes(this.resname)\n }\n\n isSaccharide () {\n if (this.chemCompType) {\n return ChemCompSaccharide.includes(this.chemCompType)\n } else {\n return SaccharideNames.includes(this.resname)\n }\n }\n\n isStandardAminoacid () {\n return AA3.includes(this.resname)\n }\n\n isStandardBase () {\n return Bases.includes(this.resname)\n }\n\n hasBackboneAtoms (position: number, type: number) {\n const atomnames = ResidueTypeAtoms[ type ]\n if (position === -1) {\n return this.hasAtomWithName(\n atomnames.trace,\n atomnames.backboneEnd,\n atomnames.direction1,\n atomnames.direction2\n )\n } else if (position === 0) {\n return this.hasAtomWithName(\n atomnames.trace,\n atomnames.direction1,\n atomnames.direction2\n )\n } else if (position === 1) {\n return this.hasAtomWithName(\n atomnames.trace,\n atomnames.backboneStart,\n atomnames.direction1,\n atomnames.direction2\n )\n } else {\n return this.hasAtomWithName(\n atomnames.trace,\n atomnames.backboneStart,\n atomnames.backboneEnd,\n atomnames.direction1,\n atomnames.direction2\n )\n }\n }\n\n hasProteinBackbone (position: number) {\n return (\n this.isProtein() &&\n this.hasBackboneAtoms(position, ProteinBackboneType)\n )\n }\n\n hasRnaBackbone (position: number) {\n return (\n this.isRna() &&\n this.hasBackboneAtoms(position, RnaBackboneType)\n )\n }\n\n hasDnaBackbone (position: number) {\n return (\n this.isDna() &&\n this.hasBackboneAtoms(position, DnaBackboneType)\n )\n }\n\n hasCgProteinBackbone (position: number) {\n return (\n this.atomCount < 7 &&\n this.isProtein() &&\n this.hasBackboneAtoms(position, CgProteinBackboneType)\n )\n }\n\n hasCgRnaBackbone (position: number) {\n return (\n this.atomCount < 11 &&\n this.isRna() &&\n this.hasBackboneAtoms(position, CgRnaBackboneType)\n )\n }\n\n hasCgDnaBackbone (position: number) {\n return (\n this.atomCount < 11 &&\n this.isDna() &&\n this.hasBackboneAtoms(position, CgDnaBackboneType)\n )\n }\n\n hasBackbone (position: number) {\n return (\n this.hasProteinBackbone(position) ||\n this.hasRnaBackbone(position) ||\n this.hasDnaBackbone(position) ||\n this.hasCgProteinBackbone(position) ||\n this.hasCgRnaBackbone(position) ||\n this.hasCgDnaBackbone(position)\n )\n }\n\n getAtomIndexByName (atomname: string|string[]) {\n const n = this.atomCount\n const atomMap = this.structure.atomMap\n const atomTypeIdList = this.atomTypeIdList\n if (Array.isArray(atomname)) {\n for (let i = 0; i < n; ++i) {\n const index = atomTypeIdList[ i ]\n if (atomname.includes(atomMap.get(index).atomname)) {\n return i\n }\n }\n } else {\n for (let i = 0; i < n; ++i) {\n const index = atomTypeIdList[ i ]\n if (atomname === atomMap.get(index).atomname) {\n return i\n }\n }\n }\n return undefined\n }\n\n hasAtomWithName (...atomnames: (string|string[])[]) {\n const n = atomnames.length\n for (let i = 0; i < n; ++i) {\n if (atomnames[ i ] === undefined) continue\n if (this.getAtomIndexByName(atomnames[ i ]) === undefined) {\n return false\n }\n }\n return true\n }\n\n getBonds (r?: ResidueProxy) {\n if (this.bonds === undefined) {\n this.bonds = calculateResidueBonds(r!) // TODO\n }\n return this.bonds\n }\n\n getRings () {\n if (this.rings === undefined) {\n this.calculateRings()\n }\n return this.rings\n }\n\n getBondGraph () {\n if (this.bondGraph === undefined) {\n this.calculateBondGraph()\n }\n return this.bondGraph\n }\n\n getAromatic (a?: AtomProxy) {\n if (this.aromaticAtoms === undefined) {\n this.calculateAromatic(this.structure.getResidueProxy((a!).residueIndex)) // TODO\n }\n return this.aromaticAtoms\n }\n\n getAromaticRings (r?: ResidueProxy) {\n if (this.aromaticRings === undefined) {\n this.calculateAromatic(r!) // TODO\n }\n return this.aromaticRings\n }\n\n /**\n * @return {Object} bondGraph - represents the bonding in this\n * residue: { ai1: [ ai2, ai3, ...], ...}\n */\n calculateBondGraph () {\n const bondGraph: BondGraph = this.bondGraph = {}\n const bonds = this.getBonds()\n const nb = bonds.atomIndices1.length\n const atomIndices1 = bonds.atomIndices1\n const atomIndices2 = bonds.atomIndices2\n\n for (let i = 0; i < nb; ++i) {\n const ai1 = atomIndices1[i]\n const ai2 = atomIndices2[i]\n\n const a1 = bondGraph[ ai1 ] = bondGraph[ ai1 ] || []\n a1.push(ai2)\n\n const a2 = bondGraph[ ai2 ] = bondGraph[ ai2 ] || []\n a2.push(ai1)\n }\n }\n\n /**\n * Find all rings up to 2 * RingFinderMaxDepth\n */\n calculateRings () {\n const bondGraph = this.getBondGraph()! // TODO\n const state = RingFinderState(bondGraph, this.atomCount)\n\n for (let i = 0; i < state.count; i++) {\n if (state.visited[i] >= 0) continue\n findRings(state, i)\n }\n\n this.rings = { atomRings: state.atomRings, rings: state.rings }\n }\n\n isAromatic (atom: AtomProxy) {\n this.aromaticAtoms = this.getAromatic(atom)! // TODO\n return this.aromaticAtoms[atom.index - atom.residueAtomOffset] === 1\n }\n\n calculateAromatic (r: ResidueProxy) {\n const aromaticAtoms = this.aromaticAtoms = new Uint8Array(this.atomCount)\n const rings = this.getRings()!.rings\n\n const aromaticRingFlags = rings.map(ring => {\n return isRingAromatic(ring.map(idx => {\n return this.structure.getAtomProxy(idx + r.atomOffset)\n }))\n })\n\n const aromaticRings: number[][] = this.aromaticRings = []\n rings.forEach((ring, i) => {\n if (aromaticRingFlags[i]) {\n aromaticRings.push(ring)\n ring.forEach(idx => aromaticAtoms[idx] = 1)\n }\n })\n }\n\n /**\n * For bonds with order > 1, pick a reference atom\n * @return {undefined}\n */\n assignBondReferenceAtomIndices () {\n const bondGraph = this.getBondGraph()! // TODO\n const rings = this.getRings()! // TODO\n const atomRings = rings.atomRings\n const ringData = rings.rings\n\n const bonds = this.bonds! // TODO\n const atomIndices1 = bonds.atomIndices1\n const atomIndices2 = bonds.atomIndices2\n const bondOrders = bonds.bondOrders\n const bondReferenceAtomIndices = this.bondReferenceAtomIndices\n\n const nb = bonds.atomIndices1.length\n\n bondReferenceAtomIndices.length = 0 // reset array\n\n for (let i = 0; i < nb; ++i) {\n // Not required for single bonds\n if (bondOrders[i] <= 1) continue\n\n let refRing\n\n const ai1 = atomIndices1[i]\n const ai2 = atomIndices2[i]\n\n const rings1 = atomRings[ ai1 ]\n const rings2 = atomRings[ ai2 ]\n // Are both atoms in a ring?\n if (rings1 && rings2) {\n // Are they in the same ring? (If not, ignore ring info)\n for (let ri1 = 0; ri1 < rings1.length; ri1++){\n if (rings2.indexOf(rings1[ ri1 ]) !== -1) {\n refRing = ringData[ rings1[ ri1 ] ]\n break\n }\n }\n }\n\n // Find the first neighbour.\n if (bondGraph[ ai1 ].length > 1) {\n for (let j = 0; j < bondGraph[ ai1 ].length; ++j) {\n const ai3 = bondGraph[ ai1 ][ j ]\n if (ai3 !== ai2) {\n if (refRing === undefined || refRing.indexOf(ai3) !== -1){\n bondReferenceAtomIndices[i] = ai3\n break\n }\n }\n }\n } else if (bondGraph[ ai2 ].length > 1) {\n for (let j = 0; j < bondGraph[ ai2 ].length; ++j) {\n const ai3 = bondGraph[ ai2 ][ j ]\n if (ai3 !== ai1) {\n if (refRing === undefined || refRing.indexOf(ai3) !== -1){\n bondReferenceAtomIndices[i] = ai3\n break\n }\n }\n }\n } // No reference atom could be found (e.g. diatomic molecule/fragment)\n }\n }\n\n getBondIndex (atomIndex1: number, atomIndex2: number) {\n const bonds = this.bonds! // TODO\n const atomIndices1 = bonds.atomIndices1\n const atomIndices2 = bonds.atomIndices2\n let idx1 = atomIndices1.indexOf(atomIndex1)\n let idx2 = atomIndices2.indexOf(atomIndex2)\n const _idx2 = idx2\n while (idx1 !== -1) {\n while (idx2 !== -1) {\n if (idx1 === idx2) return idx1\n idx2 = atomIndices2.indexOf(atomIndex2, idx2 + 1)\n }\n idx1 = atomIndices1.indexOf(atomIndex1, idx1 + 1)\n idx2 = _idx2\n }\n // returns undefined when no bond is found\n }\n\n getBondReferenceAtomIndex (atomIndex1: number, atomIndex2: number) {\n const bondIndex = this.getBondIndex(atomIndex1, atomIndex2)\n if (bondIndex === undefined) return undefined\n if (this.bondReferenceAtomIndices.length === 0) {\n this.assignBondReferenceAtomIndices()\n }\n return this.bondReferenceAtomIndices[ bondIndex ]\n }\n}\n\n//\n\nconst AromaticRingElements = [\n Elements.B, Elements.C, Elements.N, Elements.O,\n Elements.SI, Elements.P, Elements.S,\n Elements.GE, Elements.AS,\n Elements.SN, Elements.SB,\n Elements.BI\n]\nconst AromaticRingPlanarityThreshold = 0.05\n\nfunction isRingAromatic (ring: AtomProxy[]) {\n if (ring.some(a => !AromaticRingElements.includes(a.number))) return false\n\n let i = 0\n const coords = new Matrix(3, ring.length)\n const cd = coords.data\n\n ring.forEach(a => {\n cd[ i + 0 ] = a.x\n cd[ i + 1 ] = a.y\n cd[ i + 2 ] = a.z\n i += 3\n })\n\n const pa = new PrincipalAxes(coords)\n\n return pa.vecC.length() < AromaticRingPlanarityThreshold\n}\n\n//\n\n/**\n * Ring finding code below adapted from MolQL\n * Copyright (c) 2017 MolQL contributors, licensed under MIT\n * @author David Sehnal \n */\n\nfunction addRing(state: RingFinderState, a: number, b: number) {\n // only \"monotonous\" rings\n if (b < a) return\n\n const { pred, color, left, right } = state\n const nc = ++state.currentColor\n\n let current = a\n\n for (let t = 0; t < RingFinderMaxDepth; t++) {\n color[current] = nc\n current = pred[current]\n if (current < 0) break\n }\n\n let leftOffset = 0\n let rightOffset = 0\n\n let found = false\n let target = 0\n current = b\n for (let t = 0; t < RingFinderMaxDepth; t++) {\n if (color[current] === nc) {\n target = current\n found = true\n break\n }\n right[rightOffset++] = current\n current = pred[current]\n if (current < 0) break\n }\n if (!found) return\n\n current = a\n for (let t = 0; t < RingFinderMaxDepth; t++) {\n left[leftOffset++] = current\n if (target === current) break\n current = pred[current]\n if (current < 0) break\n }\n\n const rn = leftOffset + rightOffset\n const ring: number[] = new Array(rn)\n let ringOffset = 0;\n for (let t = 0; t < leftOffset; t++) {\n ring[ringOffset++] = left[t]\n }\n for (let t = rightOffset - 1; t >= 0; t--) {\n ring[ringOffset++] = right[t]\n }\n\n const ri = state.rings.length\n // set atomRing indices:\n for (let i = 0; i < rn; ++i) {\n const ai = ring[i]\n if (state.atomRings[ai]) {\n state.atomRings[ai].push(ri)\n } else {\n state.atomRings[ai] = [ri]\n }\n }\n\n state.rings.push(ring)\n}\n\nfunction findRings(state: RingFinderState, from: number) {\n const { bonds, visited, queue, pred } = state\n\n visited[from] = 1\n queue[0] = from\n\n let head = 0\n let size = 1\n\n while (head < size) {\n const top = queue[head++]\n const start = 0\n if (bonds[top] === undefined) {\n continue\n }\n const end = bonds[top].length\n\n for (let i = start; i < end; i++) {\n const other = bonds[top][i]\n\n if (visited[other] > 0) {\n if (pred[other] !== top && pred[top] !== other) {\n addRing(state, top, other)\n }\n continue\n }\n\n visited[other] = 1\n queue[size++] = other\n pred[other] = top\n }\n }\n}\n\nconst RingFinderMaxDepth = 4\n\ninterface RingFinderState {\n count: number,\n visited: Int32Array,\n queue: Int32Array,\n color: Int32Array,\n pred: Int32Array,\n\n left: Int32Array,\n right: Int32Array,\n\n currentColor: number,\n\n rings: number[][],\n atomRings: number[][],\n\n bonds: BondGraph\n}\n\nfunction RingFinderState(bonds: BondGraph, capacity: number): RingFinderState {\n const state = {\n count: capacity,\n visited: new Int32Array(capacity),\n queue: new Int32Array(capacity),\n pred: new Int32Array(capacity),\n left: new Int32Array(RingFinderMaxDepth),\n right: new Int32Array(RingFinderMaxDepth),\n color: new Int32Array(capacity),\n currentColor: 0,\n rings: [],\n atomRings: [],\n bonds\n }\n for (let i = 0; i < capacity; i++) {\n state.visited[i] = -1\n state.pred[i] = -1\n }\n return state\n}\n","/**\n * @file Residue Map\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport { ResidueBonds } from '../structure/structure-utils'\nimport ResidueType from './residue-type'\n\nfunction getHash (resname: string, atomTypeIdList: number[], hetero: boolean, chemCompType = '') {\n return (\n resname + '|' +\n atomTypeIdList.join(',') + '|' +\n (hetero ? 1 : 0) + '|' +\n chemCompType\n )\n}\n\nclass ResidueMap {\n dict: { [k: string]: number } = {}\n list: ResidueType[] = []\n\n constructor (readonly structure: Structure) {}\n\n add (resname: string, atomTypeIdList: number[], hetero: boolean, chemCompType = '', bonds?: ResidueBonds) {\n resname = resname.toUpperCase()\n const hash = getHash(resname, atomTypeIdList, hetero, chemCompType)\n let id = this.dict[ hash ]\n if (id === undefined) {\n const residueType = new ResidueType(\n this.structure, resname, atomTypeIdList, hetero, chemCompType, bonds\n )\n id = this.list.length\n this.dict[ hash ] = id\n this.list.push(residueType)\n }\n return id\n }\n\n get (id: number) {\n return this.list[ id ]\n }\n}\n\nexport default ResidueMap\n","/**\n * @file Bond Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport Structure from '../structure/structure'\nimport BondStore from '../store/bond-store'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Bond proxy\n */\nclass BondProxy {\n index: number\n\n bondStore: BondStore\n\n private _v12: Vector3\n private _v13: Vector3\n private _ap1: AtomProxy\n private _ap2: AtomProxy\n private _ap3: AtomProxy\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.bondStore = structure.bondStore\n\n this._v12 = new Vector3()\n this._v13 = new Vector3()\n this._ap1 = this.structure.getAtomProxy()\n this._ap2 = this.structure.getAtomProxy()\n this._ap3 = this.structure.getAtomProxy()\n }\n\n /**\n * @type {AtomProxy}\n */\n get atom1 () {\n return this.structure.getAtomProxy(this.atomIndex1)\n }\n\n /**\n * @type {AtomProxy}\n */\n get atom2 () {\n return this.structure.getAtomProxy(this.atomIndex2)\n }\n\n /**\n * @type {Integer}\n */\n get atomIndex1 () {\n return this.bondStore.atomIndex1[ this.index ]\n }\n set atomIndex1 (value) {\n this.bondStore.atomIndex1[ this.index ] = value\n }\n\n /**\n * @type {Integer}\n */\n get atomIndex2 () {\n return this.bondStore.atomIndex2[ this.index ]\n }\n set atomIndex2 (value) {\n this.bondStore.atomIndex2[ this.index ] = value\n }\n\n /**\n * @type {Integer}\n */\n get bondOrder () {\n return this.bondStore.bondOrder[ this.index ]\n }\n set bondOrder (value) {\n this.bondStore.bondOrder[ this.index ] = value\n }\n\n getOtherAtomIndex (atomIndex: number) {\n return atomIndex === this.atomIndex1 ? this.atomIndex2 : this.atomIndex1\n }\n\n getOtherAtom (atom: AtomProxy) {\n return this.structure.getAtomProxy(this.getOtherAtomIndex(atom.index))\n }\n\n /**\n * Get reference atom index for the bond\n * @return {Integer|undefined} atom index, or `undefined` if unavailable\n */\n getReferenceAtomIndex () {\n const ap1 = this._ap1\n const ap2 = this._ap2\n ap1.index = this.atomIndex1\n ap2.index = this.atomIndex2\n if (ap1.residueIndex !== ap2.residueIndex) {\n return undefined // Bond between residues, for now ignore (could detect)\n }\n const typeAtomIndex1 = ap1.index - ap1.residueAtomOffset\n const typeAtomIndex2 = ap2.index - ap2.residueAtomOffset\n const residueType = ap1.residueType\n const ix = residueType.getBondReferenceAtomIndex(typeAtomIndex1, typeAtomIndex2)\n if (ix !== undefined) {\n return ix + ap1.residueAtomOffset\n } else {\n console.warn('No reference atom found', ap1.index, ap2.index)\n }\n }\n\n /**\n * calculate shift direction for displaying double/triple bonds\n * @param {Vector3} [v] pre-allocated output vector\n * @return {Vector3} the shift direction vector\n */\n calculateShiftDir (v = new Vector3()) {\n const ap1 = this._ap1\n const ap2 = this._ap2\n const ap3 = this._ap3\n const v12 = this._v12\n const v13 = this._v13\n\n ap1.index = this.atomIndex1\n ap2.index = this.atomIndex2\n const ai3 = this.getReferenceAtomIndex()\n\n v12.subVectors(ap1 as any, ap2 as any).normalize() // TODO\n if (ai3 !== undefined) {\n ap3.index = ai3\n v13.subVectors(ap1 as any, ap3 as any) // TODO\n } else {\n v13.copy(ap1 as any) // no reference point, use origin // TODO\n }\n v13.normalize()\n\n // make sure v13 and v12 are not colinear\n let dp = v12.dot(v13)\n if (1 - Math.abs(dp) < 1e-5) {\n v13.set(1, 0, 0)\n dp = v12.dot(v13)\n if (1 - Math.abs(dp) < 1e-5) {\n v13.set(0, 1, 0)\n dp = v12.dot(v13)\n }\n }\n\n return v.copy(v13.sub(v12.multiplyScalar(dp))).normalize()\n }\n\n qualifiedName () {\n return this.atomIndex1 + '=' + this.atomIndex2\n }\n\n /**\n * Clone object\n * @return {BondProxy} cloned bond\n */\n clone () {\n return new BondProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n atomIndex1: this.atomIndex1,\n atomIndex2: this.atomIndex2,\n bondOrder: this.bondOrder\n }\n }\n}\n\nexport default BondProxy\n","/**\n * @file Residue Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { NumberArray } from '../types'\nimport { defaults } from '../utils'\nimport {\n SecStrucHelix, SecStrucSheet, SecStrucTurn,\n ProteinType, RnaType, DnaType, WaterType, IonType, SaccharideType,\n CgProteinBackboneType, CgRnaBackboneType, CgDnaBackboneType,\n AA1\n} from '../structure/structure-constants'\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\n\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\nimport AtomStore from '../store/atom-store'\n\nimport AtomMap from '../store/atom-map'\nimport ResidueMap from '../store/residue-map'\n\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueType, { RingData } from '../store/residue-type';\nimport { ResidueBonds } from '../structure/structure-utils';\nimport AtomType from '../store/atom-type';\nimport ChainProxy from './chain-proxy';\nimport Entity from '../structure/entity';\n\n/**\n * Residue proxy\n */\nclass ResidueProxy {\n index: number\n\n chainStore: ChainStore\n residueStore: ResidueStore\n atomStore: AtomStore\n\n residueMap: ResidueMap\n atomMap: AtomMap\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n this.atomStore = structure.atomStore\n this.residueMap = structure.residueMap\n this.atomMap = structure.atomMap\n }\n\n /**\n * Entity\n * @type {Entity}\n */\n get entity (): Entity {\n return this.structure.entityList[ this.entityIndex ]\n }\n get entityIndex () {\n return this.chainStore.entityIndex[ this.chainIndex ]\n }\n /**\n * Chain\n * @type {ChainProxy}\n */\n get chain (): ChainProxy {\n return this.structure.getChainProxy(this.chainIndex)\n }\n\n get chainIndex () {\n return this.residueStore.chainIndex[ this.index ]\n }\n set chainIndex (value) {\n this.residueStore.chainIndex[ this.index ] = value\n }\n\n get atomOffset () {\n return this.residueStore.atomOffset[ this.index ]\n }\n set atomOffset (value) {\n this.residueStore.atomOffset[ this.index ] = value\n }\n\n /**\n * Atom count\n * @type {Integer}\n */\n get atomCount () {\n return this.residueStore.atomCount[ this.index ]\n }\n set atomCount (value) {\n this.residueStore.atomCount[ this.index ] = value\n }\n\n get atomEnd () {\n return this.atomOffset + this.atomCount - 1\n }\n\n //\n\n get modelIndex () {\n return this.chainStore.modelIndex[ this.chainIndex ]\n }\n /**\n * Chain name\n * @type {String}\n */\n get chainname () {\n return this.chainStore.getChainname(this.chainIndex)\n }\n /**\n * Chain id\n * @type {String}\n */\n get chainid () {\n return this.chainStore.getChainid(this.chainIndex)\n }\n\n //\n\n /**\n * Residue number/label\n * @type {Integer}\n */\n get resno () {\n return this.residueStore.resno[ this.index ]\n }\n set resno (value) {\n this.residueStore.resno[ this.index ] = value\n }\n\n /**\n * Secondary structure code\n * @type {String}\n */\n get sstruc () {\n return this.residueStore.getSstruc(this.index)\n }\n set sstruc (value) {\n this.residueStore.setSstruc(this.index, value)\n }\n\n /**\n * Insertion code\n * @type {String}\n */\n get inscode () {\n return this.residueStore.getInscode(this.index)\n }\n set inscode (value) {\n this.residueStore.setInscode(this.index, value)\n }\n\n //\n\n get residueType (): ResidueType {\n return this.residueMap.get(this.residueStore.residueTypeId[ this.index ])\n }\n\n /**\n * Residue name\n * @type {String}\n */\n get resname () {\n return this.residueType.resname\n }\n /**\n * Hetero flag\n * @type {Boolean}\n */\n get hetero () {\n return this.residueType.hetero\n }\n get moleculeType () {\n return this.residueType.moleculeType\n }\n get backboneType () {\n return this.residueType.backboneType\n }\n get backboneStartType () {\n return this.residueType.backboneStartType\n }\n get backboneEndType () {\n return this.residueType.backboneEndType\n }\n get traceAtomIndex () {\n return this.residueType.traceAtomIndex + this.atomOffset\n }\n get direction1AtomIndex () {\n return this.residueType.direction1AtomIndex + this.atomOffset\n }\n get direction2AtomIndex () {\n return this.residueType.direction2AtomIndex + this.atomOffset\n }\n get backboneStartAtomIndex () {\n return this.residueType.backboneStartAtomIndex + this.atomOffset\n }\n get backboneEndAtomIndex () {\n return this.residueType.backboneEndAtomIndex + this.atomOffset\n }\n get rungEndAtomIndex () {\n return this.residueType.rungEndAtomIndex + this.atomOffset\n }\n\n //\n\n get x () {\n let x = 0\n for (let i = this.atomOffset; i <= this.atomEnd; ++i) {\n x += this.atomStore.x[ i ]\n }\n return x / this.atomCount\n }\n\n get y () {\n let y = 0\n for (let i = this.atomOffset; i <= this.atomEnd; ++i) {\n y += this.atomStore.y[ i ]\n }\n return y / this.atomCount\n }\n\n get z () {\n let z = 0\n for (let i = this.atomOffset; i <= this.atomEnd; ++i) {\n z += this.atomStore.z[ i ]\n }\n return z / this.atomCount\n }\n\n //\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (ap: AtomProxy) => void, selection?: Selection) {\n const count = this.atomCount\n const offset = this.atomOffset\n const ap = this.structure._ap\n const end = offset + count\n\n if (selection && selection.atomOnlyTest) {\n const atomOnlyTest = selection.atomOnlyTest\n for (let i = offset; i < end; ++i) {\n ap.index = i\n if (atomOnlyTest(ap)) callback(ap)\n }\n } else {\n for (let i = offset; i < end; ++i) {\n ap.index = i\n callback(ap)\n }\n }\n }\n\n //\n\n /**\n * Write residue center position to array\n * @param {Array|TypedArray} [array] - target array\n * @param {Integer} [offset] - the offset\n * @return {Array|TypedArray} target array\n */\n positionToArray (array: NumberArray = [], offset = 0) {\n array[ offset + 0 ] = this.x\n array[ offset + 1 ] = this.y\n array[ offset + 2 ] = this.z\n\n return array\n }\n\n //\n\n /**\n * If residue is from a protein\n * @return {Boolean} flag\n */\n isProtein () {\n return this.residueType.moleculeType === ProteinType\n }\n\n /**\n * If residue is nucleic\n * @return {Boolean} flag\n */\n isNucleic () {\n const moleculeType = this.residueType.moleculeType\n return moleculeType === RnaType || moleculeType === DnaType\n }\n\n /**\n * If residue is rna\n * @return {Boolean} flag\n */\n isRna () {\n return this.residueType.moleculeType === RnaType\n }\n\n /**\n * If residue is dna\n * @return {Boolean} flag\n */\n isDna () {\n return this.residueType.moleculeType === DnaType\n }\n\n /**\n * If residue is coarse-grain\n * @return {Boolean} flag\n */\n isCg () {\n const backboneType = this.residueType.backboneType\n return (\n backboneType === CgProteinBackboneType ||\n backboneType === CgRnaBackboneType ||\n backboneType === CgDnaBackboneType\n )\n }\n\n /**\n * If residue is from a polymer\n * @return {Boolean} flag\n */\n isPolymer () {\n if (this.structure.entityList.length > 0) {\n return this.entity.isPolymer()\n } else {\n const moleculeType = this.residueType.moleculeType\n return (\n moleculeType === ProteinType ||\n moleculeType === RnaType ||\n moleculeType === DnaType\n )\n }\n }\n\n /**\n * If residue is hetero\n * @return {Boolean} flag\n */\n isHetero () {\n return this.residueType.hetero === 1\n }\n\n /**\n * If residue is a water molecule\n * @return {Boolean} flag\n */\n isWater () {\n return this.residueType.moleculeType === WaterType\n }\n\n /**\n * If residue is an ion\n * @return {Boolean} flag\n */\n isIon () {\n return this.residueType.moleculeType === IonType\n }\n\n /**\n * If residue is a saccharide\n * @return {Boolean} flag\n */\n isSaccharide () {\n return this.residueType.moleculeType === SaccharideType\n }\n\n isStandardAminoacid () {\n return this.residueType.isStandardAminoacid()\n }\n\n isStandardBase () {\n return this.residueType.isStandardBase()\n }\n\n /**\n * If residue is part of a helix\n * @return {Boolean} flag\n */\n isHelix () {\n return SecStrucHelix.includes(this.sstruc)\n }\n\n /**\n * If residue is part of a sheet\n * @return {Boolean} flag\n */\n isSheet () {\n return SecStrucSheet.includes(this.sstruc)\n }\n\n /**\n * If residue is part of a turn\n * @return {Boolean} flag\n */\n isTurn () {\n return SecStrucTurn.includes(this.sstruc) && this.isProtein()\n }\n\n getAtomType (index: number): AtomType {\n return this.atomMap.get(this.atomStore.atomTypeId[ index ])\n }\n\n getResname1 () {\n // FIXME nucleic support\n return AA1[ this.resname.toUpperCase() ] || 'X'\n }\n\n getBackboneType (position: number) {\n switch (position) {\n case -1:\n return this.residueType.backboneStartType\n case 1:\n return this.residueType.backboneEndType\n default:\n return this.residueType.backboneType\n }\n }\n\n getAtomIndexByName (atomname: string) {\n let index = this.residueType.getAtomIndexByName(atomname)\n if (index !== undefined) {\n index += this.atomOffset\n }\n return index\n }\n\n hasAtomWithName (atomname: string) {\n return this.residueType.hasAtomWithName(atomname)\n }\n\n getAtomnameList () {\n console.warn('getAtomnameList - might be expensive')\n\n const n = this.atomCount\n const offset = this.atomOffset\n const list = new Array(n)\n for (let i = 0; i < n; ++i) {\n list[ i ] = this.getAtomType(offset + i).atomname\n }\n return list\n }\n\n /**\n * If residue is connected to another\n * @param {ResidueProxy} rNext - the other residue\n * @return {Boolean} - flag\n */\n connectedTo (rNext: ResidueProxy) {\n const bbAtomEnd = this.structure.getAtomProxy(this.backboneEndAtomIndex)\n const bbAtomStart = this.structure.getAtomProxy(rNext.backboneStartAtomIndex)\n if (bbAtomEnd && bbAtomStart) {\n return bbAtomEnd.connectedTo(bbAtomStart)\n } else {\n return false\n }\n }\n\n getNextConnectedResidue () {\n const rOffset = this.chainStore.residueOffset[ this.chainIndex ]\n const rCount = this.chainStore.residueCount[ this.chainIndex ]\n const nextIndex = this.index + 1\n if (nextIndex < rOffset + rCount) {\n const rpNext = this.structure.getResidueProxy(nextIndex)\n if (this.connectedTo(rpNext)) {\n return rpNext\n }\n } else if (nextIndex === rOffset + rCount) { // cyclic\n const rpFirst = this.structure.getResidueProxy(rOffset)\n if (this.connectedTo(rpFirst)) {\n return rpFirst\n }\n }\n return undefined\n }\n\n getPreviousConnectedResidue (residueProxy?: ResidueProxy) {\n const rOffset = this.chainStore.residueOffset[ this.chainIndex ]\n const prevIndex = this.index - 1\n if (prevIndex >= rOffset) {\n const rpPrev = defaults(residueProxy, this.structure.getResidueProxy())\n rpPrev.index = prevIndex\n if (rpPrev.connectedTo(this)) {\n return rpPrev\n }\n } else if (prevIndex === rOffset - 1) { // cyclic\n const rCount = this.chainStore.residueCount[ this.chainIndex ]\n const rpLast = defaults(residueProxy, this.structure.getResidueProxy())\n rpLast.index = rOffset + rCount - 1\n if (rpLast.connectedTo(this)) {\n return rpLast\n }\n }\n return undefined\n }\n\n getBonds (): ResidueBonds {\n return this.residueType.getBonds(this)\n }\n\n getRings (): RingData|undefined {\n return this.residueType.getRings()\n }\n\n getAromaticRings () {\n return this.residueType.getAromaticRings(this)\n }\n\n qualifiedName (noResname = false) {\n let name = ''\n if (this.resname && !noResname) name += '[' + this.resname + ']'\n if (this.resno !== undefined) name += this.resno\n if (this.inscode) name += '^' + this.inscode\n if (this.chain) name += ':' + this.chainname\n name += '/' + this.modelIndex\n return name\n }\n\n /**\n * Clone object\n * @return {ResidueProxy} cloned residue\n */\n clone () {\n return new ResidueProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n index: this.index,\n chainIndex: this.chainIndex,\n atomOffset: this.atomOffset,\n atomCount: this.atomCount,\n\n resno: this.resno,\n resname: this.resname,\n sstruc: this.sstruc\n }\n }\n}\n\nexport default ResidueProxy\n","/**\n * @file Polymer\n * @author Alexander Rose \n * @private\n */\n\n// import { Log } from '../globals'\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\n\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\nimport AtomStore from '../store/atom-store'\n\nimport ResidueProxy from '../proxy/residue-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Polymer\n */\nclass Polymer {\n chainStore: ChainStore\n residueStore: ResidueStore\n atomStore: AtomStore\n\n residueCount: number\n\n isPrevConnected: boolean\n isNextConnected: boolean\n isNextNextConnected: boolean\n isCyclic: boolean\n\n private __residueProxy: ResidueProxy\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} residueIndexStart - the index of the first residue\n * @param {Integer} residueIndexEnd - the index of the last residue\n */\n constructor (readonly structure: Structure, readonly residueIndexStart: number, readonly residueIndexEnd: number) {\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n this.atomStore = structure.atomStore\n\n /**\n * @type {Integer}\n */\n this.residueCount = residueIndexEnd - residueIndexStart + 1\n\n const rpStart = this.structure.getResidueProxy(this.residueIndexStart)\n const rpEnd = this.structure.getResidueProxy(this.residueIndexEnd)\n this.isPrevConnected = rpStart.getPreviousConnectedResidue() !== undefined\n const rpNext = rpEnd.getNextConnectedResidue()\n this.isNextConnected = rpNext !== undefined\n this.isNextNextConnected = rpNext !== undefined && rpNext.getNextConnectedResidue() !== undefined\n this.isCyclic = rpEnd.connectedTo(rpStart)\n\n this.__residueProxy = this.structure.getResidueProxy()\n\n // console.log( this.qualifiedName(), this );\n }\n\n get chainIndex () {\n return this.residueStore.chainIndex[ this.residueIndexStart ]\n }\n get modelIndex () {\n return this.chainStore.modelIndex[ this.chainIndex ]\n }\n\n /**\n * @type {String}\n */\n get chainname () {\n return this.chainStore.getChainname(this.chainIndex)\n }\n\n //\n\n /**\n * If first residue is from aprotein\n * @return {Boolean} flag\n */\n isProtein () {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.isProtein()\n }\n\n /**\n * If atom is part of a coarse-grain group\n * @return {Boolean} flag\n */\n isCg () {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.isCg()\n }\n\n /**\n * If atom is part of a nucleic molecule\n * @return {Boolean} flag\n */\n isNucleic () {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.isNucleic()\n }\n\n getMoleculeType () {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.moleculeType\n }\n\n getBackboneType (position: number) {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.getBackboneType(position)\n }\n\n getAtomIndexByType (index: number, type: string) {\n // TODO pre-calculate, add to residueStore???\n\n if (this.isCyclic) {\n if (index === -1) {\n index = this.residueCount - 1\n } else if (index === this.residueCount) {\n index = 0\n }\n } else {\n if (index === -1 && !this.isPrevConnected) index += 1\n if (index === this.residueCount && !this.isNextNextConnected) index -= 1\n // if( index === this.residueCount - 1 && !this.isNextConnected ) index -= 1;\n }\n\n const rp = this.__residueProxy\n rp.index = this.residueIndexStart + index\n let aIndex\n\n switch (type) {\n case 'trace':\n aIndex = rp.traceAtomIndex\n break\n case 'direction1':\n aIndex = rp.direction1AtomIndex\n break\n case 'direction2':\n aIndex = rp.direction2AtomIndex\n break\n default:\n aIndex = rp.getAtomIndexByName(type)\n }\n\n // if (!ap){\n // console.log(this, type, rp.residueType)\n // // console.log(rp.qualifiedName(), rp.index, index, this.residueCount - 1)\n // // rp.index = this.residueIndexStart;\n // // console.log(rp.qualifiedName(), this.residueIndexStart)\n // // rp.index = this.residueIndexEnd;\n // // console.log(rp.qualifiedName(), this.residueIndexEnd)\n // }\n\n return aIndex\n }\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (ap: AtomProxy) => void, selection?: Selection) {\n this.eachResidue(function (rp) {\n rp.eachAtom(callback, selection)\n })\n }\n\n eachAtomN (n: number, callback: (...apArray: AtomProxy[]) => void, type: string) {\n const m = this.residueCount\n const array: AtomProxy[] = new Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = this.structure.getAtomProxy(this.getAtomIndexByType(i, type))\n }\n callback.apply(this, array)\n\n for (var j = n; j < m; ++j) {\n for (let i = 1; i < n; ++i) {\n array[ i - 1 ].index = array[ i ].index\n }\n array[ n - 1 ].index = this.getAtomIndexByType(j, type)! // TODO\n callback.apply(this, array)\n }\n }\n\n /**\n * Residue iterator\n * @param {function(residue: ResidueProxy)} callback - the callback\n * @return {undefined}\n */\n eachResidue (callback: (rp: ResidueProxy) => void) {\n const rp = this.structure.getResidueProxy()\n const n = this.residueCount\n const rStartIndex = this.residueIndexStart\n\n for (let i = 0; i < n; ++i) {\n rp.index = rStartIndex + i\n callback(rp)\n }\n }\n\n qualifiedName () {\n const rpStart = this.structure.getResidueProxy(this.residueIndexStart)\n const rpEnd = this.structure.getResidueProxy(this.residueIndexEnd)\n return rpStart.qualifiedName() + ' - ' + rpEnd.qualifiedName()\n }\n}\n\nexport default Polymer\n","/**\n * @file Chain Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { UnknownBackboneType } from '../structure/structure-constants'\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\n\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\n\nimport Polymer from '../proxy/polymer'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ModelProxy from './model-proxy';\nimport Entity from '../structure/entity';\n\n/**\n * Chain proxy\n */\nclass ChainProxy {\n index: number\n\n chainStore: ChainStore\n residueStore: ResidueStore\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n }\n\n /**\n * Entity\n * @type {Entity}\n */\n get entity (): Entity {\n return this.structure.entityList[ this.entityIndex ]\n }\n /**\n * Model\n * @type {ModelProxy}\n */\n get model (): ModelProxy {\n return this.structure.getModelProxy(this.modelIndex)\n }\n\n get entityIndex () {\n return this.chainStore.entityIndex[ this.index ]\n }\n set entityIndex (value) {\n this.chainStore.entityIndex[ this.index ] = value\n }\n\n get modelIndex () {\n return this.chainStore.modelIndex[ this.index ]\n }\n set modelIndex (value) {\n this.chainStore.modelIndex[ this.index ] = value\n }\n\n get residueOffset () {\n return this.chainStore.residueOffset[ this.index ]\n }\n set residueOffset (value) {\n this.chainStore.residueOffset[ this.index ] = value\n }\n\n /**\n * Residue count\n * @type {Integer}\n */\n get residueCount () {\n return this.chainStore.residueCount[ this.index ]\n }\n set residueCount (value) {\n this.chainStore.residueCount[ this.index ] = value\n }\n\n get residueEnd () {\n return this.residueOffset + this.residueCount - 1\n }\n\n get atomOffset () {\n return this.residueStore.atomOffset[ this.residueOffset ]\n }\n get atomEnd () {\n return (\n this.residueStore.atomOffset[ this.residueEnd ] +\n this.residueStore.atomCount[ this.residueEnd ] - 1\n )\n }\n /**\n * Atom count\n * @type {Integer}\n */\n get atomCount () {\n if (this.residueCount === 0) {\n return 0\n } else {\n return this.atomEnd - this.atomOffset + 1\n }\n }\n\n //\n\n /**\n * Chain name\n * @type {String}\n */\n get chainname () {\n return this.chainStore.getChainname(this.index)\n }\n set chainname (value) {\n this.chainStore.setChainname(this.index, value)\n }\n\n /**\n * Chain id\n * @type {String}\n */\n get chainid () {\n return this.chainStore.getChainid(this.index)\n }\n set chainid (value) {\n this.chainStore.setChainid(this.index, value)\n }\n\n //\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (ap: AtomProxy) => void, selection?: Selection) {\n this.eachResidue(function (rp) {\n rp.eachAtom(callback, selection)\n }, selection)\n }\n\n /**\n * Residue iterator\n * @param {function(residue: ResidueProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachResidue (callback: (rp: ResidueProxy) => void, selection?: Selection) {\n const count = this.residueCount\n const offset = this.residueOffset\n const rp = this.structure._rp\n const end = offset + count\n\n if (selection && selection.test) {\n const residueOnlyTest = selection.residueOnlyTest\n if (residueOnlyTest) {\n for (let i = offset; i < end; ++i) {\n rp.index = i\n if (residueOnlyTest(rp)) {\n callback(rp)\n }\n }\n } else {\n for (let i = offset; i < end; ++i) {\n rp.index = i\n callback(rp)\n }\n }\n } else {\n for (let i = offset; i < end; ++i) {\n rp.index = i\n callback(rp)\n }\n }\n }\n\n /**\n * Multi-residue iterator\n * @param {Integer} n - window size\n * @param {function(residueList: ResidueProxy[])} callback - the callback\n * @return {undefined}\n */\n eachResidueN (n: number, callback: (...rpArray: ResidueProxy[]) => void) {\n const count = this.residueCount\n const offset = this.residueOffset\n const end = offset + count\n if (count < n) return\n const array: ResidueProxy[] = new Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = this.structure.getResidueProxy(offset + i)\n }\n callback.apply(this, array)\n\n for (let j = offset + n; j < end; ++j) {\n for (let i = 0; i < n; ++i) {\n array[ i ].index += 1\n }\n callback.apply(this, array)\n }\n }\n\n /**\n * Polymer iterator\n * @param {function(polymer: Polymer)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachPolymer (callback: (p: Polymer) => void, selection?: Selection) {\n let rStartIndex = 0\n let rNextIndex = 0\n const test = selection ? selection.residueOnlyTest : undefined\n const structure = this.model.structure\n\n const count = this.residueCount\n const offset = this.residueOffset\n const end = offset + count\n\n const rp1 = this.structure.getResidueProxy()\n const rp2 = this.structure.getResidueProxy(offset)\n\n const ap1 = this.structure.getAtomProxy()\n const ap2 = this.structure.getAtomProxy()\n\n let first = true\n\n for (let i = offset + 1; i < end; ++i) {\n rp1.index = rp2.index\n rp2.index = i\n\n const bbType1 = first ? rp1.backboneEndType : rp1.backboneType\n const bbType2 = rp2.backboneType\n\n if (first) {\n rStartIndex = rp1.index\n first = false\n }\n rNextIndex = rp2.index\n\n if (bbType1 !== UnknownBackboneType && bbType1 === bbType2) {\n ap1.index = rp1.backboneEndAtomIndex\n ap2.index = rp2.backboneStartAtomIndex\n } else {\n if (bbType1 !== UnknownBackboneType) {\n if (rp1.index - rStartIndex > 1) {\n // console.log(\"FOO1\",rStartIndex, rp1.index)\n callback(new Polymer(structure, rStartIndex, rp1.index))\n }\n }\n rStartIndex = rNextIndex\n\n continue\n }\n\n if (!ap1 || !ap2 || !ap1.connectedTo(ap2) ||\n (test && (!test(rp1) || !test(rp2)))\n ) {\n if (rp1.index - rStartIndex > 1) {\n // console.log(\"FOO2\",rStartIndex, rp1.index)\n callback(new Polymer(structure, rStartIndex, rp1.index))\n }\n rStartIndex = rNextIndex\n }\n }\n\n if (rNextIndex - rStartIndex > 1) {\n if (this.structure.getResidueProxy(rStartIndex).backboneEndType) {\n // console.log(\"FOO3\",rStartIndex, rNextIndex)\n callback(new Polymer(structure, rStartIndex, rNextIndex))\n }\n }\n }\n\n //\n\n qualifiedName () {\n var name = ':' + this.chainname + '/' + this.modelIndex\n return name\n }\n\n /**\n * Clone object\n * @return {ChainProxy} cloned chain\n */\n clone () {\n return new ChainProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n index: this.index,\n residueOffset: this.residueOffset,\n residueCount: this.residueCount,\n\n chainname: this.chainname\n }\n }\n}\n\nexport default ChainProxy\n","/**\n * @file Model Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\n\nimport ModelStore from '../store/model-store'\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\n\nimport ChainProxy from '../proxy/chain-proxy'\nimport Polymer from '../proxy/polymer'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Model proxy\n */\nclass ModelProxy {\n index: number\n\n modelStore: ModelStore\n chainStore: ChainStore\n residueStore: ResidueStore\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.modelStore = structure.modelStore\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n }\n\n get chainOffset () {\n return this.modelStore.chainOffset[ this.index ]\n }\n set chainOffset (value) {\n this.modelStore.chainOffset[ this.index ] = value\n }\n\n get chainCount () {\n return this.modelStore.chainCount[ this.index ]\n }\n set chainCount (value) {\n this.modelStore.chainCount[ this.index ] = value\n }\n\n get residueOffset () {\n return this.chainStore.residueOffset[ this.chainOffset ]\n }\n get atomOffset () {\n return this.residueStore.atomOffset[ this.residueOffset ]\n }\n\n get chainEnd () {\n return this.chainOffset + this.chainCount - 1\n }\n get residueEnd () {\n return (\n this.chainStore.residueOffset[ this.chainEnd ] +\n this.chainStore.residueCount[ this.chainEnd ] - 1\n )\n }\n get atomEnd () {\n return (\n this.residueStore.atomOffset[ this.residueEnd ] +\n this.residueStore.atomCount[ this.residueEnd ] - 1\n )\n }\n\n /**\n * Residue count\n * @type {Integer}\n */\n get residueCount () {\n if (this.chainCount === 0) {\n return 0\n } else {\n return this.residueEnd - this.residueOffset + 1\n }\n }\n\n /**\n * Atom count\n * @type {Integer}\n */\n get atomCount () {\n if (this.residueCount === 0) {\n return 0\n } else {\n return this.atomEnd - this.atomOffset + 1\n }\n }\n\n //\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (ap: AtomProxy) => void, selection?: Selection) {\n this.eachChain(function (cp) {\n cp.eachAtom(callback, selection)\n }, selection)\n }\n\n /**\n * Residue iterator\n * @param {function(residue: ResidueProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachResidue (callback: (rp: ResidueProxy) => void, selection?: Selection) {\n this.eachChain(function (cp) {\n cp.eachResidue(callback, selection)\n }, selection)\n }\n\n /**\n * Polymer iterator\n * @param {function(polymer: Polymer)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachPolymer (callback: (p: Polymer) => void, selection?: Selection) {\n if (selection && selection.chainOnlyTest) {\n const chainOnlyTest = selection.chainOnlyTest\n\n this.eachChain(function (cp) {\n if (chainOnlyTest(cp)) {\n cp.eachPolymer(callback, selection)\n }\n })\n } else {\n this.eachChain(function (cp) {\n cp.eachPolymer(callback, selection)\n })\n }\n }\n\n /**\n * Chain iterator\n * @param {function(chain: ChainProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachChain (callback: (cp: ChainProxy) => void, selection?: Selection) {\n const count = this.chainCount\n const offset = this.chainOffset\n const cp = this.structure._cp\n const end = offset + count\n\n if (selection && selection.test) {\n const chainOnlyTest = selection.chainOnlyTest\n if (chainOnlyTest) {\n for (let i = offset; i < end; ++i) {\n cp.index = i\n if (chainOnlyTest(cp)) {\n callback(cp)\n }\n }\n } else {\n for (let i = offset; i < end; ++i) {\n cp.index = i\n callback(cp)\n }\n }\n } else {\n for (let i = offset; i < end; ++i) {\n cp.index = i\n callback(cp)\n }\n }\n }\n\n //\n\n qualifiedName () {\n const name = '/' + this.index\n return name\n }\n\n /**\n * Clone object\n * @return {ModelProxy} cloned model\n */\n clone () {\n return new ModelProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n index: this.index,\n chainOffset: this.chainOffset,\n chainCount: this.chainCount\n }\n }\n}\n\nexport default ModelProxy\n","/**\n * @file Structure\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3 } from 'three'\nimport { Signal } from 'signals'\n\nimport { Debug, Log, ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { AtomPicker, BondPicker } from '../utils/picker'\nimport { copyWithin, arrayMin, arrayMax } from '../math/array-utils'\nimport BitArray from '../utils/bitarray'\nimport RadiusFactory, { RadiusParams } from '../utils/radius-factory'\nimport { Matrix } from '../math/matrix-utils'\nimport PrincipalAxes from '../math/principal-axes'\nimport SpatialHash from '../geometry/spatial-hash'\nimport FilteredVolume from '../surface/filtered-volume'\nimport StructureView from './structure-view'\nimport { AtomDataParams, AtomData, BondDataParams, BondData } from './structure-data'\nimport { Data, createData } from './data'\n\nimport Entity from './entity'\nimport Unitcell from '../symmetry/unitcell'\nimport Validation from './validation'\nimport Selection from '../selection/selection'\nimport Assembly from '../symmetry/assembly'\nimport Volume from '../surface/volume'\nimport Polymer from '../proxy/polymer'\n\nimport BondHash from '../store/bond-hash'\nimport BondStore from '../store/bond-store'\nimport AtomStore from '../store/atom-store'\nimport ResidueStore from '../store/residue-store'\nimport ChainStore from '../store/chain-store'\nimport ModelStore from '../store/model-store'\n\nimport AtomMap from '../store/atom-map'\nimport ResidueMap from '../store/residue-map'\n\nimport BondProxy from '../proxy/bond-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\ninterface Structure {\n signals: StructureSignals\n\n name: string\n path: string\n title: string\n id: string\n\n data: Data\n\n atomCount: number\n bondCount: number\n\n header: StructureHeader\n extraData: StructureExtraData\n\n atomSetCache: { [k: string]: BitArray }\n atomSetDict: { [k: string]: BitArray }\n biomolDict: { [k: string]: Assembly }\n\n entityList: Entity[]\n unitcell?: Unitcell\n\n frames: Float32Array[]\n boxes: Float32Array[]\n\n validation?: Validation\n\n bondStore: BondStore\n backboneBondStore: BondStore\n rungBondStore: BondStore\n atomStore: AtomStore\n residueStore: ResidueStore\n chainStore: ChainStore\n modelStore: ModelStore\n\n atomMap: AtomMap\n residueMap: ResidueMap\n\n bondHash?: BondHash\n spatialHash?: SpatialHash\n\n atomSet?: BitArray\n bondSet?: BitArray\n\n center: Vector3\n boundingBox: Box3\n\n trajectory?: {\n name: string\n frame: number\n }\n\n getView(selection: Selection): StructureView\n\n _hasCoords?: boolean\n\n _bp: BondProxy\n _ap: AtomProxy\n _rp: ResidueProxy\n _cp: ChainProxy\n}\n\nexport type StructureHeader = {\n releaseDate?: string\n depositionDate?: string\n resolution?: number\n rFree?: number\n rWork?: number\n experimentalMethods?: string[]\n}\n\nexport type StructureExtraData = {\n cif?: object\n sdf?: object[]\n}\n\nexport type StructureSignals = {\n refreshed: Signal\n}\n\n/**\n * Structure\n */\nclass Structure implements Structure{\n signals: StructureSignals = {\n refreshed: new Signal()\n }\n\n /**\n * @param {String} name - structure name\n * @param {String} path - source path\n */\n constructor (name = '', path = '') {\n this.init(name, path)\n }\n\n init (name: string, path: string) {\n this.name = name\n this.path = path\n this.title = ''\n this.id = ''\n\n this.data = createData(this)\n\n this.header = {}\n this.extraData = {}\n\n this.atomSetCache = {}\n this.atomSetDict = {}\n this.biomolDict = {}\n\n this.entityList = []\n this.unitcell = undefined\n\n this.frames = []\n this.boxes = []\n\n this.validation = undefined\n\n this.bondStore = new BondStore(0)\n this.backboneBondStore = new BondStore(0)\n this.rungBondStore = new BondStore(0)\n this.atomStore = new AtomStore(0)\n this.residueStore = new ResidueStore(0)\n this.chainStore = new ChainStore(0)\n this.modelStore = new ModelStore(0)\n\n this.atomMap = new AtomMap(this)\n this.residueMap = new ResidueMap(this)\n\n this.bondHash = undefined\n this.spatialHash = undefined\n\n this.atomSet = undefined\n this.bondSet = undefined\n\n this.center = new Vector3()\n this.boundingBox = new Box3()\n\n this._bp = this.getBondProxy()\n this._ap = this.getAtomProxy()\n this._rp = this.getResidueProxy()\n this._cp = this.getChainProxy()\n }\n\n get type () { return 'Structure' }\n\n finalizeAtoms () {\n this.atomSet = this.getAtomSet()\n this.atomCount = this.atomStore.count\n this.boundingBox = this.getBoundingBox(undefined, this.boundingBox)\n this.center = this.boundingBox.getCenter(new Vector3())\n this.spatialHash = new SpatialHash(this.atomStore, this.boundingBox)\n }\n\n finalizeBonds () {\n this.bondSet = this.getBondSet()\n this.bondCount = this.bondStore.count\n this.bondHash = new BondHash(this.bondStore, this.atomStore.count)\n\n this.atomSetCache = {}\n if (!this.atomSetDict.rung) {\n this.atomSetDict.rung = this.getAtomSet(false)\n }\n\n for (let name in this.atomSetDict) {\n this.atomSetCache[ '__' + name ] = this.atomSetDict[ name ].clone()\n }\n }\n\n //\n\n getBondProxy (index?: number) {\n return new BondProxy(this, index)\n }\n\n getAtomProxy (index?: number) {\n return new AtomProxy(this, index)\n }\n\n getResidueProxy (index?: number) {\n return new ResidueProxy(this, index)\n }\n\n getChainProxy (index?: number) {\n return new ChainProxy(this, index)\n }\n\n getModelProxy (index?: number) {\n return new ModelProxy(this, index)\n }\n\n //\n\n getBondSet (/* selection */) {\n // TODO implement selection parameter\n\n const n = this.bondStore.count\n const bondSet = new BitArray(n)\n const atomSet = this.atomSet\n\n if (atomSet) {\n if (atomSet.isAllSet()) {\n bondSet.setAll()\n } else if (atomSet.isAllClear()) {\n bondSet.clearAll()\n } else {\n const bp = this.getBondProxy()\n\n for (let i = 0; i < n; ++i) {\n bp.index = i\n if (atomSet.isSet(bp.atomIndex1, bp.atomIndex2)) {\n bondSet.set(bp.index)\n }\n }\n }\n } else {\n bondSet.setAll()\n }\n\n return bondSet\n }\n\n getBackboneBondSet (/* selection */) {\n // TODO implement selection parameter\n\n const n = this.backboneBondStore.count\n const backboneBondSet = new BitArray(n)\n const backboneAtomSet = this.atomSetCache.__backbone\n\n if (backboneAtomSet) {\n const bp = this.getBondProxy()\n bp.bondStore = this.backboneBondStore\n\n for (let i = 0; i < n; ++i) {\n bp.index = i\n if (backboneAtomSet.isSet(bp.atomIndex1, bp.atomIndex2)) {\n backboneBondSet.set(bp.index)\n }\n }\n } else {\n backboneBondSet.setAll()\n }\n\n return backboneBondSet\n }\n\n getRungBondSet (/* selection */) {\n // TODO implement selection parameter\n\n const n = this.rungBondStore.count\n const rungBondSet = new BitArray(n)\n const rungAtomSet = this.atomSetCache.__rung\n\n if (rungAtomSet) {\n const bp = this.getBondProxy()\n bp.bondStore = this.rungBondStore\n\n for (let i = 0; i < n; ++i) {\n bp.index = i\n if (rungAtomSet.isSet(bp.atomIndex1, bp.atomIndex2)) {\n rungBondSet.set(bp.index)\n }\n }\n } else {\n rungBondSet.setAll()\n }\n\n return rungBondSet\n }\n\n /**\n * Get a set of atoms\n * @param {Boolean|Selection|BitArray} selection - object defining how to\n * initialize the atom set.\n * Boolean: init with value;\n * Selection: init with selection;\n * BitArray: return bit array\n * @return {BitArray} set of atoms\n */\n getAtomSet (selection?: boolean|Selection|BitArray) {\n const n = this.atomStore.count\n\n if (selection === undefined) {\n return new BitArray(n, true)\n } else if (selection instanceof BitArray) {\n return selection\n } else if (selection === true) {\n return new BitArray(n, true)\n } else if (selection && selection.test) {\n const seleString = selection.string\n if (seleString in this.atomSetCache) {\n return this.atomSetCache[ seleString ]\n } else {\n if (seleString === '') {\n return new BitArray(n, true)\n } else {\n const atomSet = new BitArray(n)\n this.eachAtom(function (ap: AtomProxy) {\n atomSet.set(ap.index)\n }, selection)\n this.atomSetCache[ seleString ] = atomSet\n return atomSet\n }\n }\n } else if (selection === false) {\n return new BitArray(n)\n }\n\n return new BitArray(n, true)\n }\n\n /**\n * Get set of atoms around a set of atoms from a selection\n * @param {Selection} selection - the selection object\n * @param {Number} radius - radius to select within\n * @return {BitArray} set of atoms\n */\n getAtomSetWithinSelection (selection: boolean|Selection|BitArray, radius: number) {\n const spatialHash = this.spatialHash\n const atomSet = this.getAtomSet(false)\n const ap = this.getAtomProxy()\n\n if (!spatialHash) return atomSet\n\n this.getAtomSet(selection).forEach(function (idx: number) {\n ap.index = idx\n spatialHash.within(ap.x, ap.y, ap.z, radius).forEach(function (idx2: number) {\n atomSet.set(idx2)\n })\n })\n\n return atomSet\n }\n\n /**\n * Get set of atoms around a point\n * @param {Vector3|AtomProxy} point - the point\n * @param {Number} radius - radius to select within\n * @return {BitArray} set of atoms\n */\n getAtomSetWithinPoint (point: Vector3|AtomProxy, radius: number) {\n const p = point\n const atomSet = this.getAtomSet(false)\n\n if (!this.spatialHash) return atomSet\n\n this.spatialHash.within(p.x, p.y, p.z, radius).forEach(function (idx: number) {\n atomSet.set(idx)\n })\n\n return atomSet\n }\n\n /**\n * Get set of atoms within a volume\n * @param {Volume} volume - the volume\n * @param {Number} radius - radius to select within\n * @param {[type]} minValue - minimum value to be considered as within the volume\n * @param {[type]} maxValue - maximum value to be considered as within the volume\n * @param {[type]} outside - use only values falling outside of the min/max values\n * @return {BitArray} set of atoms\n */\n getAtomSetWithinVolume (volume: Volume, radius: number, minValue: number, maxValue: number, outside: boolean) {\n const fv = new FilteredVolume(volume, minValue, maxValue, outside) as any // TODO\n\n const dp = fv.getDataPosition()\n const n = dp.length\n const r = fv.matrix.getMaxScaleOnAxis()\n const atomSet = this.getAtomSet(false)\n\n if (!this.spatialHash) return atomSet\n\n for (let i = 0; i < n; i += 3) {\n this.spatialHash.within(dp[ i ], dp[ i + 1 ], dp[ i + 2 ], r).forEach(function (idx) {\n atomSet.set(idx)\n })\n }\n\n return atomSet\n }\n\n /**\n * Get set of all atoms within the groups of a selection\n * @param {Selection} selection - the selection object\n * @return {BitArray} set of atoms\n */\n getAtomSetWithinGroup (selection: boolean|Selection|BitArray) {\n const atomResidueIndex = this.atomStore.residueIndex\n const atomSet = this.getAtomSet(false)\n const rp = this.getResidueProxy()\n\n this.getAtomSet(selection).forEach(function (idx) {\n rp.index = atomResidueIndex[ idx ]\n for (let idx2 = rp.atomOffset; idx2 <= rp.atomEnd; ++idx2) {\n atomSet.set(idx2)\n }\n })\n\n return atomSet\n }\n\n //\n\n getSelection (): undefined|Selection {\n return\n }\n\n getStructure (): Structure|StructureView {\n return this\n }\n\n /**\n * Entity iterator\n * @param {function(entity: Entity)} callback - the callback\n * @param {EntityType} type - entity type\n * @return {undefined}\n */\n eachEntity (callback: (entity: Entity) => void, type: number) {\n this.entityList.forEach(function (entity) {\n if (type === undefined || entity.getEntityType() === type) {\n callback(entity)\n }\n })\n }\n\n /**\n * Bond iterator\n * @param {function(bond: BondProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachBond (callback: (entity: BondProxy) => void, selection?: Selection) {\n const bp = this.getBondProxy()\n let bondSet\n\n if (selection && selection.test) {\n bondSet = this.getBondSet(/*selection*/)\n if (this.bondSet) {\n bondSet.intersection(this.bondSet)\n }\n }\n\n if (bondSet) {\n bondSet.forEach(function (index) {\n bp.index = index\n callback(bp)\n })\n } else {\n const n = this.bondStore.count\n for (let i = 0; i < n; ++i) {\n bp.index = i\n callback(bp)\n }\n }\n }\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (entity: AtomProxy) => void, selection?: Selection) {\n if (selection && selection.test) {\n this.eachModel(function (mp) {\n mp.eachAtom(callback, selection)\n }, selection)\n } else {\n const an = this.atomStore.count\n const ap = this.getAtomProxy()\n for (let i = 0; i < an; ++i) {\n ap.index = i\n callback(ap)\n }\n }\n }\n\n /**\n * Residue iterator\n * @param {function(residue: ResidueProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachResidue (callback: (entity: ResidueProxy) => void, selection?: Selection) {\n if (selection && selection.test) {\n const mn = this.modelStore.count\n const mp = this.getModelProxy()\n const modelOnlyTest = selection.modelOnlyTest\n if (modelOnlyTest) {\n for (let i = 0; i < mn; ++i) {\n mp.index = i\n if (modelOnlyTest(mp)) {\n mp.eachResidue(callback, selection)\n }\n }\n } else {\n for (let i = 0; i < mn; ++i) {\n mp.index = i\n mp.eachResidue(callback, selection)\n }\n }\n } else {\n const rn = this.residueStore.count\n const rp = this.getResidueProxy()\n for (let i = 0; i < rn; ++i) {\n rp.index = i\n callback(rp)\n }\n }\n }\n\n /**\n * Multi-residue iterator\n * @param {Integer} n - window size\n * @param {function(residueList: ResidueProxy[])} callback - the callback\n * @return {undefined}\n */\n eachResidueN (n: number, callback: (...entityArray: ResidueProxy[]) => void) {\n const rn = this.residueStore.count\n if (rn < n) return\n const array: ResidueProxy[] = new Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = this.getResidueProxy(i)\n }\n callback.apply(this, array)\n\n for (let j = n; j < rn; ++j) {\n for (let i = 0; i < n; ++i) {\n array[ i ].index += 1\n }\n callback.apply(this, array)\n }\n }\n\n /**\n * Polymer iterator\n * @param {function(polymer: Polymer)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachPolymer (callback: (entity: Polymer) => void, selection?: Selection) {\n if (selection && selection.modelOnlyTest) {\n const modelOnlyTest = selection.modelOnlyTest\n\n this.eachModel(function (mp) {\n if (modelOnlyTest(mp)) {\n mp.eachPolymer(callback, selection)\n }\n })\n } else {\n this.eachModel(function (mp) {\n mp.eachPolymer(callback, selection)\n })\n }\n }\n\n /**\n * Chain iterator\n * @param {function(chain: ChainProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachChain (callback: (entity: ChainProxy) => void, selection?: Selection) {\n if (selection && selection.test) {\n this.eachModel(function (mp) {\n mp.eachChain(callback, selection)\n })\n } else {\n const cn = this.chainStore.count\n const cp = this.getChainProxy()\n for (let i = 0; i < cn; ++i) {\n cp.index = i\n callback(cp)\n }\n }\n }\n\n /**\n * Model iterator\n * @param {function(model: ModelProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachModel (callback: (entity: ModelProxy) => void, selection?: Selection) {\n const n = this.modelStore.count\n const mp = this.getModelProxy()\n\n if (selection && selection.test) {\n const modelOnlyTest = selection.modelOnlyTest\n if (modelOnlyTest) {\n for (let i = 0; i < n; ++i) {\n mp.index = i\n if (modelOnlyTest(mp)) {\n callback(mp)\n }\n }\n } else {\n for (let i = 0; i < n; ++i) {\n mp.index = i\n callback(mp)\n }\n }\n } else {\n for (let i = 0; i < n; ++i) {\n mp.index = i\n callback(mp)\n }\n }\n }\n\n //\n\n getAtomData (params: AtomDataParams) {\n const p = Object.assign({}, params)\n if (p.colorParams) p.colorParams.structure = this.getStructure()\n\n const what = p.what\n const atomSet = defaults(p.atomSet, this.atomSet)\n\n let radiusFactory: any // TODO\n let colormaker: any // TODO\n\n const atomData: AtomData = {}\n const ap = this.getAtomProxy()\n const atomCount = atomSet.getSize()\n\n if (!what || what.position) {\n atomData.position = new Float32Array(atomCount * 3)\n }\n if ((!what || what.color) && p.colorParams) {\n atomData.color = new Float32Array(atomCount * 3)\n colormaker = ColormakerRegistry.getScheme(p.colorParams)\n }\n if (!what || what.picking) {\n atomData.picking = new AtomPicker(new Float32Array(atomCount), this.getStructure())\n }\n if (!what || what.radius) {\n atomData.radius = new Float32Array(atomCount)\n radiusFactory = new RadiusFactory(p.radiusParams as RadiusParams)\n }\n if (!what || what.index) {\n atomData.index = new Uint32Array(atomCount)\n }\n\n const {position, color, picking, radius, index} = atomData\n\n atomSet.forEach((idx: number, i: number) => {\n const i3 = i * 3\n ap.index = idx\n if (position) {\n ap.positionToArray(position, i3)\n }\n if (color) {\n colormaker.atomColorToArray(ap, color, i3)\n }\n if (picking) {\n picking.array![ i ] = idx\n }\n if (radius) {\n radius[ i ] = radiusFactory.atomRadius(ap)\n }\n if (index) {\n index[ i ] = idx\n }\n })\n return atomData\n }\n\n getBondData (params: BondDataParams) {\n const p = Object.assign({}, params)\n if (p.colorParams) p.colorParams.structure = this.getStructure()\n\n const what = p.what\n const bondSet = defaults(p.bondSet, this.bondSet)\n const multipleBond = defaults(p.multipleBond, 'off')\n const isMulti = multipleBond !== 'off'\n const isOffset = multipleBond === 'offset'\n const bondScale = defaults(p.bondScale, 0.4)\n const bondSpacing = defaults(p.bondSpacing, 1.0)\n\n let radiusFactory: any // TODO\n let colormaker: any // TODO\n\n const bondData: BondData = {}\n const bp = this.getBondProxy()\n if (p.bondStore) bp.bondStore = p.bondStore\n const ap1 = this.getAtomProxy()\n const ap2 = this.getAtomProxy()\n\n let bondCount: number\n if (isMulti) {\n const storeBondOrder = bp.bondStore.bondOrder\n bondCount = 0\n bondSet.forEach(function (index: number) {\n bondCount += storeBondOrder[ index ]\n })\n } else {\n bondCount = bondSet.getSize()\n }\n\n if (!what || what.position) {\n bondData.position1 = new Float32Array(bondCount * 3)\n bondData.position2 = new Float32Array(bondCount * 3)\n }\n if ((!what || what.color) && p.colorParams) {\n bondData.color = new Float32Array(bondCount * 3)\n bondData.color2 = new Float32Array(bondCount * 3)\n colormaker = ColormakerRegistry.getScheme(p.colorParams)\n }\n if (!what || what.picking) {\n bondData.picking = new BondPicker(new Float32Array(bondCount), this.getStructure(), p.bondStore)\n }\n if (!what || what.radius || (isMulti && what.position)) {\n radiusFactory = new RadiusFactory(p.radiusParams as RadiusParams)\n }\n if (!what || what.radius) {\n bondData.radius = new Float32Array(bondCount)\n if (p.radius2) {\n bondData.radius2 = new Float32Array(bondCount)\n }\n }\n\n const {position1, position2, color, color2, picking, radius, radius2} = bondData\n\n let i = 0\n let j, i3, k, bondOrder, absOffset\n let multiRadius\n\n const vt = new Vector3()\n const vShortening = new Vector3()\n const vShift = new Vector3()\n\n bondSet.forEach((index: number) => {\n i3 = i * 3\n bp.index = index\n ap1.index = bp.atomIndex1\n ap2.index = bp.atomIndex2\n bondOrder = bp.bondOrder\n if (position1) {\n if (isMulti && bondOrder > 1) {\n const atomRadius = radiusFactory.atomRadius(ap1)\n multiRadius = atomRadius * bondScale / (0.5 * bondOrder)\n\n bp.calculateShiftDir(vShift)\n\n if (isOffset) {\n absOffset = 2 * bondSpacing * atomRadius\n vShift.multiplyScalar(absOffset)\n vShift.negate()\n\n // Shortening is calculated so that neighbouring double\n // bonds on tetrahedral geometry (e.g. sulphonamide)\n // are not quite touching (arccos(1.9 / 2) ~ 109deg)\n // but don't shorten beyond 10% each end or it looks odd\n vShortening.subVectors(ap2 as any, ap1 as any).multiplyScalar( // TODO\n Math.max(0.1, absOffset / 1.88)\n )\n ap1.positionToArray(position1, i3)\n ap2.positionToArray(position2, i3)\n\n if (bondOrder >= 2) {\n vt.addVectors(ap1 as any, vShift).add(vShortening).toArray(position1 as any, i3 + 3) // TODO\n vt.addVectors(ap2 as any, vShift).sub(vShortening).toArray(position2 as any, i3 + 3) // TODO\n\n if (bondOrder >= 3) {\n vt.subVectors(ap1 as any, vShift).add(vShortening).toArray(position1 as any, i3 + 6) // TODO\n vt.subVectors(ap2 as any, vShift).sub(vShortening).toArray(position2 as any, i3 + 6) // TODO\n }\n }\n } else {\n absOffset = (bondSpacing - bondScale) * atomRadius\n vShift.multiplyScalar(absOffset)\n\n if (bondOrder === 2) {\n vt.addVectors(ap1 as any, vShift).toArray(position1 as any, i3) // TODO\n vt.subVectors(ap1 as any, vShift).toArray(position1 as any, i3 + 3) // TODO\n vt.addVectors(ap2 as any, vShift).toArray(position2 as any, i3) // TODO\n vt.subVectors(ap2 as any, vShift).toArray(position2 as any, i3 + 3) // TODO\n } else if (bondOrder === 3) {\n ap1.positionToArray(position1, i3)\n vt.addVectors(ap1 as any, vShift).toArray(position1 as any, i3 + 3) // TODO\n vt.subVectors(ap1 as any, vShift).toArray(position1 as any, i3 + 6) // TODO\n ap2.positionToArray(position2, i3)\n vt.addVectors(ap2 as any, vShift).toArray(position2 as any, i3 + 3) // TODO\n vt.subVectors(ap2 as any, vShift).toArray(position2 as any, i3 + 6) // TODO\n } else {\n // todo, better fallback\n ap1.positionToArray(position1, i3)\n ap2.positionToArray(position2, i3)\n }\n }\n } else {\n ap1.positionToArray(position1, i3)\n ap2.positionToArray(position2, i3)\n }\n }\n if (color && color2) {\n colormaker.bondColorToArray(bp, 1, color, i3)\n colormaker.bondColorToArray(bp, 0, color2, i3)\n if (isMulti && bondOrder > 1) {\n for (j = 1; j < bondOrder; ++j) {\n k = j * 3 + i3\n copyWithin(color, i3, k, 3)\n copyWithin(color2, i3, k, 3)\n }\n }\n }\n if (picking && picking.array) {\n picking.array[ i ] = index\n if (isMulti && bondOrder > 1) {\n for (j = 1; j < bondOrder; ++j) {\n picking.array[ i + j ] = index\n }\n }\n }\n if (radius) {\n radius[ i ] = radiusFactory.atomRadius(ap1)\n if (isMulti && bondOrder > 1) {\n multiRadius = radius[ i ] * bondScale / (isOffset ? 1 : (0.5 * bondOrder))\n for (j = isOffset ? 1 : 0; j < bondOrder; ++j) {\n radius[ i + j ] = multiRadius\n }\n }\n }\n if (radius2) {\n radius2[ i ] = radiusFactory.atomRadius(ap2)\n if (isMulti && bondOrder > 1) {\n multiRadius = radius2[ i ] * bondScale / (isOffset ? 1 : (0.5 * bondOrder))\n for (j = isOffset ? 1 : 0; j < bondOrder; ++j) {\n radius2[ i + j ] = multiRadius\n }\n }\n }\n i += isMulti ? bondOrder : 1\n })\n\n return bondData\n }\n\n getBackboneAtomData (params: AtomDataParams) {\n params = Object.assign({\n atomSet: this.atomSetCache.__backbone\n }, params)\n\n return this.getAtomData(params)\n }\n\n getBackboneBondData (params: BondDataParams) {\n params = Object.assign({\n bondSet: this.getBackboneBondSet(),\n bondStore: this.backboneBondStore\n }, params)\n\n return this.getBondData(params)\n }\n\n getRungAtomData (params: AtomDataParams) {\n params = Object.assign({\n atomSet: this.atomSetCache.__rung\n }, params)\n\n return this.getAtomData(params)\n }\n\n getRungBondData (params: BondDataParams) {\n params = Object.assign({\n bondSet: this.getRungBondSet(),\n bondStore: this.rungBondStore\n }, params)\n\n return this.getBondData(params)\n }\n\n //\n\n /**\n * Gets the bounding box of the (selected) structure atoms\n * @param {Selection} [selection] - the selection\n * @param {Box3} [box] - optional target\n * @return {Vector3} the box\n */\n getBoundingBox (selection?: Selection, box?: Box3) {\n if (Debug) Log.time('getBoundingBox')\n\n box = box || new Box3()\n\n let minX = +Infinity\n let minY = +Infinity\n let minZ = +Infinity\n\n let maxX = -Infinity\n let maxY = -Infinity\n let maxZ = -Infinity\n\n this.eachAtom(ap => {\n const x = ap.x\n const y = ap.y\n const z = ap.z\n\n if (x < minX) minX = x\n if (y < minY) minY = y\n if (z < minZ) minZ = z\n\n if (x > maxX) maxX = x\n if (y > maxY) maxY = y\n if (z > maxZ) maxZ = z\n }, selection)\n\n box.min.set(minX, minY, minZ)\n box.max.set(maxX, maxY, maxZ)\n\n if (Debug) Log.timeEnd('getBoundingBox')\n\n return box\n }\n\n /**\n * Gets the principal axes of the (selected) structure atoms\n * @param {Selection} [selection] - the selection\n * @return {PrincipalAxes} the principal axes\n */\n getPrincipalAxes (selection?: Selection) {\n if (Debug) Log.time('getPrincipalAxes')\n\n let i = 0\n const coords = new Matrix(3, this.atomCount)\n const cd = coords.data\n\n this.eachAtom(a => {\n cd[ i + 0 ] = a.x\n cd[ i + 1 ] = a.y\n cd[ i + 2 ] = a.z\n i += 3\n }, selection)\n\n if (Debug) Log.timeEnd('getPrincipalAxes')\n\n return new PrincipalAxes(coords)\n }\n\n /**\n * Gets the center of the (selected) structure atoms\n * @param {Selection} [selection] - the selection\n * @return {Vector3} the center\n */\n atomCenter (selection?: Selection) {\n if (selection) {\n return this.getBoundingBox(selection).getCenter(new Vector3())\n } else {\n return this.center.clone()\n }\n }\n\n hasCoords () {\n if (this._hasCoords === undefined) {\n const atomStore = this.atomStore\n this._hasCoords = (\n arrayMin(atomStore.x) !== 0 || arrayMax(atomStore.x) !== 0 ||\n arrayMin(atomStore.y) !== 0 || arrayMax(atomStore.y) !== 0 ||\n arrayMin(atomStore.z) !== 0 || arrayMax(atomStore.z) !== 0\n ) || (\n // allow models with a single atom at the origin\n atomStore.count / this.modelStore.count === 1\n )\n }\n return this._hasCoords;\n }\n\n getSequence (selection?: Selection) {\n const seq: string[] = []\n const rp = this.getResidueProxy()\n\n this.eachAtom(function (ap: AtomProxy) {\n rp.index = ap.residueIndex\n if (ap.index === rp.traceAtomIndex) {\n seq.push(rp.getResname1())\n }\n }, selection)\n\n return seq\n }\n\n getAtomIndices (selection?: Selection) {\n if (selection && selection.string) {\n const indices: number[] = []\n this.eachAtom(function (ap: AtomProxy) {\n indices.push(ap.index)\n }, selection)\n return new Uint32Array(indices)\n } else {\n const p = { what: { index: true } }\n return this.getAtomData(p).index\n }\n }\n\n /**\n * Get number of unique chainnames\n * @param {Selection} selection - limit count to selection\n * @return {Integer} count\n */\n getChainnameCount (selection?: Selection) {\n const chainnames = new Set()\n this.eachChain(function (cp: ChainProxy) {\n if (cp.residueCount) {\n chainnames.add(cp.chainname)\n }\n }, selection)\n\n return chainnames.size\n }\n\n /**\n * Update atomic positions\n * @param position - Array to copy positions from\n * @param refresh - Whether or not to issue a full refresh (automatically\n * triggers re-calculation of bounding boxes, spatial hash,\n * representations etc etc). This provides compatibility with\n * the old behaviour\n */\n updatePosition (position: Float32Array|number[], refresh: boolean = true) {\n let i = 0\n\n this.eachAtom(function (ap: AtomProxy) {\n ap.positionFromArray(position, i)\n i += 3\n }, undefined)\n\n this._hasCoords = undefined // to trigger recalculation (of the _hasCoords value)\n\n if (refresh) { \n this.refreshPosition() // Recalculate bounds - structure-component listener will \n // trigger representation rebuild\n }\n\n }\n\n refreshPosition () {\n this.getBoundingBox(undefined, this.boundingBox)\n this.boundingBox.getCenter(this.center)\n this.spatialHash = new SpatialHash(this.atomStore, this.boundingBox)\n\n this.signals.refreshed.dispatch(this)\n }\n\n /**\n * Calls dispose() method of property objects.\n * Unsets properties to help garbage collection.\n * @return {undefined}\n */\n dispose () {\n if (this.frames) this.frames.length = 0\n if (this.boxes) this.boxes.length = 0\n\n this.bondStore.dispose()\n this.backboneBondStore.dispose()\n this.rungBondStore.dispose()\n this.atomStore.dispose()\n this.residueStore.dispose()\n this.chainStore.dispose()\n this.modelStore.dispose()\n\n // can't delete non-optional properties as of TS 4\n // and since we've already disposed them, don't need to.\n\n delete this.bondSet\n delete this.atomSet\n }\n}\n\nexport default Structure\n","/**\n * @file Shape\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Matrix4 required for declaration only\nimport { Box3, Vector3, Color, Matrix4 } from 'three'\n\nimport { createParams, ensureFloat32Array, getUintArray } from '../utils'\nimport {\n ArrowPrimitive, BoxPrimitive, ConePrimitive, CylinderPrimitive, EllipsoidPrimitive,\n OctahedronPrimitive, SpherePrimitive, TetrahedronPrimitive, TextPrimitive,\n TorusPrimitive, PointPrimitive, WidelinePrimitive\n} from './primitive'\nimport { MeshPicker } from '../utils/picker'\nimport Buffer from '../buffer/buffer'\nimport MeshBuffer from '../buffer/mesh-buffer'\nimport { TextBufferParameters } from '../buffer/text-buffer'\n\nconst tmpBox = new Box3()\n\nconst Primitives = [\n ArrowPrimitive, BoxPrimitive, ConePrimitive, CylinderPrimitive,\n EllipsoidPrimitive, OctahedronPrimitive, SpherePrimitive, TetrahedronPrimitive,\n TextPrimitive, TorusPrimitive, PointPrimitive, WidelinePrimitive\n]\n\nexport const ShapeDefaultParameters = {\n aspectRatio: 1.5,\n sphereDetail: 2,\n radialSegments: 50,\n disableImpostor: false,\n openEnded: false,\n dashedCylinder: false,\n labelParams: {} as Partial,\n pointSize: 2,\n sizeAttenuation: false,\n useTexture: true,\n linewidth: 2\n}\nexport type ShapeParameters = typeof ShapeDefaultParameters\n\n/**\n * Class for building custom shapes.\n *\n * @example\n * var shape = new NGL.Shape('shape', { disableImpostor: true });\n * shape.addSphere([ 0, 0, 9 ], [ 1, 0, 0 ], 1.5 );\n * shape.addEllipsoid([ 6, 0, 0 ], [ 1, 0, 0 ], 1.5, [ 3, 0, 0 ], [ 0, 2, 0 ]);\n * shape.addCylinder([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ], 0.5);\n * shape.addCone([ 0, 2, 7 ], [ 0, 3, 3 ], [ 1, 1, 0 ], 1.5);\n * shape.addArrow([ 1, 2, 7 ], [ 30, 3, 3 ], [ 1, 0, 1 ], 1.0);\n * shape.addBox([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);\n * var shapeComp = stage.addComponentFromObject(shape);\n * geoComp.addRepresentation('buffer');\n */\nclass Shape {\n name: string\n parameters: ShapeParameters\n\n boundingBox = new Box3()\n bufferList: Buffer[] = []\n meshCount = 0\n\n _center?: Vector3\n _primitiveData: { [k: string]: any } = {}\n\n /**\n * @param {String} name - name\n * @param {Object} params - parameter object\n * @param {Integer} params.aspectRatio - arrow aspect ratio, used for cylinder radius and cone length\n * @param {Integer} params.sphereDetail - sphere quality (icosahedron subdivisions)\n * @param {Integer} params.radialSegments - cylinder quality (number of segments)\n * @param {Boolean} params.disableImpostor - disable use of raycasted impostors for rendering\n * @param {Boolean} params.openEnded - capped or not\n * @param {TextBufferParameters} params.labelParams - label parameters\n */\n constructor (name = 'shape', params: Partial = {}) {\n this.name = name\n\n this.parameters = createParams(params, ShapeDefaultParameters)\n\n Primitives.forEach(P => {\n Object.keys(P.fields).forEach(name => {\n this._primitiveData[ P.getShapeKey(name) ] = []\n })\n this._primitiveData[ P.getShapeKey('name') ] = []\n })\n }\n\n /**\n * Add a buffer\n * @param {Buffer} buffer - buffer object\n * @return {Shape} this object\n */\n addBuffer (buffer: Buffer) {\n this.bufferList.push(buffer)\n\n const geometry = (buffer as any).geometry // TODO\n if (!geometry.boundingBox) {\n geometry.computeBoundingBox()\n }\n this.boundingBox.union(geometry.boundingBox)\n\n return this\n }\n\n /**\n * Add a mesh\n * @example\n * shape.addMesh(\n * [ 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1 ],\n * [ 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0 ]\n * );\n *\n * @param {Float32Array|Array} position - positions\n * @param {Float32Array|Array} color - colors\n * @param {Uint32Array|Uint16Array|Array} [index] - indices\n * @param {Float32Array|Array} [normal] - normals\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addMesh (position: Float32Array|number[], color:Float32Array|number[], index: Uint32Array|Uint16Array|number[], normal?: Float32Array|number[], name?: string) {\n position = ensureFloat32Array(position)\n color = ensureFloat32Array(color)\n\n if (Array.isArray(index)) {\n index = getUintArray(index, position.length)\n }\n if (normal) {\n normal = ensureFloat32Array(normal)\n }\n\n let data\n if (normal === undefined || normal.length == 0 ) {\n data = { position, color, index }\n } else {\n data = { position, color, index, normal }\n }\n //const data = { position, color, index, normal }\n const picking = new MeshPicker(\n this, Object.assign({ serial: this.meshCount, name }, data)\n )\n const meshBuffer = new MeshBuffer(\n Object.assign({ picking }, data) as any\n )\n this.bufferList.push(meshBuffer)\n\n tmpBox.setFromArray(position)\n this.boundingBox.union(tmpBox)\n this.meshCount += 1\n\n return this\n }\n\n /**\n * Add a sphere\n * @example\n * shape.addSphere([ 0, 0, 9 ], [ 1, 0, 0 ], 1.5);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addSphere (position: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, name: string) {\n SpherePrimitive.objectToShape(\n this, { position, color, radius, name }\n )\n return this\n }\n\n /**\n * Add an ellipsoid\n * @example\n * shape.addEllipsoid([ 6, 0, 0 ], [ 1, 0, 0 ], 1.5, [ 3, 0, 0 ], [ 0, 2, 0 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {Vector3|Array} majorAxis - major axis vector or array\n * @param {Vector3|Array} minorAxis - minor axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addEllipsoid (position: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, majorAxis: Vector3|[number, number, number], minorAxis: Vector3|[number, number, number], name: string) {\n EllipsoidPrimitive.objectToShape(\n this, { position, color, radius, majorAxis, minorAxis, name }\n )\n return this\n }\n\n /**\n * Add a torus\n * @example\n * shape.addTorus([ 6, 0, 0 ], [ 1, 0, 0 ], 1.5, [ 3, 0, 0 ], [ 0, 2, 0 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {Vector3|Array} majorAxis - major axis vector or array\n * @param {Vector3|Array} minorAxis - minor axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addTorus (position: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, majorAxis: Vector3|[number, number, number], minorAxis: Vector3|[number, number, number], name: string) {\n TorusPrimitive.objectToShape(\n this, { position, color, radius, majorAxis, minorAxis, name }\n )\n return this\n }\n\n /**\n * Add a cylinder\n * @example\n * shape.addCylinder([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ], 0.5);\n *\n * @param {Vector3|Array} position1 - from position vector or array\n * @param {Vector3|Array} position2 - to position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addCylinder (position1: Vector3|[number, number, number], position2: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, name: string) {\n CylinderPrimitive.objectToShape(\n this, { position1, position2, color, radius, name }\n )\n return this\n }\n\n /**\n * Add a cone\n * @example\n * shape.addCone([ 0, 2, 7 ], [ 0, 3, 3 ], [ 1, 1, 0 ], 1.5);\n *\n * @param {Vector3|Array} position1 - from position vector or array\n * @param {Vector3|Array} position2 - to position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addCone (position1: Vector3|[number, number, number], position2: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, name: string) {\n ConePrimitive.objectToShape(\n this, { position1, position2, color, radius, name }\n )\n return this\n }\n\n /**\n * Add an arrow\n * @example\n * shape.addArrow([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ], 0.5);\n *\n * @param {Vector3|Array} position1 - from position vector or array\n * @param {Vector3|Array} position2 - to position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addArrow (position1: Vector3|[number, number, number], position2: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, name: string) {\n ArrowPrimitive.objectToShape(\n this, { position1, position2, color, radius, name }\n )\n return this\n }\n\n /**\n * Add a box\n * @example\n * shape.addBox([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} size - size value\n * @param {Vector3|Array} heightAxis - height axis vector or array\n * @param {Vector3|Array} depthAxis - depth axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addBox (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, heightAxis: Vector3|[number, number, number], depthAxis: Vector3|[number, number, number], name: string) {\n BoxPrimitive.objectToShape(\n this, { position, color, size, heightAxis, depthAxis, name }\n )\n return this\n }\n\n /**\n * Add an octahedron\n * @example\n * shape.addOctahedron([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} size - size value\n * @param {Vector3|Array} heightAxis - height axis vector or array\n * @param {Vector3|Array} depthAxis - depth axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addOctahedron (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, heightAxis: Vector3|[number, number, number], depthAxis: Vector3|[number, number, number], name: string) {\n OctahedronPrimitive.objectToShape(\n this, { position, color, size, heightAxis, depthAxis, name }\n )\n return this\n }\n\n /**\n * Add a tetrahedron\n * @example\n * shape.addTetrahedron([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} size - size value\n * @param {Vector3|Array} heightAxis - height axis vector or array\n * @param {Vector3|Array} depthAxis - depth axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addTetrahedron (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, heightAxis: Vector3|[number, number, number], depthAxis: Vector3|[number, number, number], name: string) {\n TetrahedronPrimitive.objectToShape(\n this, { position, color, size, heightAxis, depthAxis, name }\n )\n return this\n }\n\n /**\n * Add text\n * @example\n * shape.addText([ 10, -2, 4 ], [ 0.2, 0.5, 0.8 ], 0.5, \"Hello\");\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} size - size value\n * @param {String} text - text value\n * @return {Shape} this object\n */\n addText (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, text: string) {\n TextPrimitive.objectToShape(\n this, { position, color, size, text }\n )\n return this\n }\n\n /**\n * Add point\n * @example\n * shape.addPoint([ 10, -2, 4 ], [ 0.2, 0.5, 0.8 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addPoint (position: Vector3|[number, number, number], color: Color|[number, number, number], name: string) {\n PointPrimitive.objectToShape(\n this, { position, color, name }\n )\n return this\n }\n\n /**\n * Add a wideline\n * @example\n * shape.addWideline([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ]);\n *\n * @param {Vector3|Array} position1 - from position vector or array\n * @param {Vector3|Array} position2 - to position vector or array\n * @param {Color|Array} color - color object or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addWideline (position1: Vector3|[number, number, number], position2: Vector3|[number, number, number], color: Color|[number, number, number], linewidth: number, name: string) {\n this.parameters.linewidth = linewidth\n WidelinePrimitive.objectToShape(\n this, { position1, position2, color, name }\n )\n return this\n }\n\n /**\n * Deprecated, use `.addText`\n */\n addLabel (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, text: string) {\n console.warn('Shape.addLabel is deprecated, use .addText instead')\n return this.addText(position, color, size, text)\n }\n\n getBufferList () {\n const buffers: Buffer[] = []\n\n Primitives.forEach(P => {\n if (this._primitiveData[ P.getShapeKey('color') ].length) {\n buffers.push(P.bufferFromShape(this, this.parameters))\n }\n })\n\n return this.bufferList.concat(buffers)\n }\n\n dispose () {\n this.bufferList.forEach(function (buffer) {\n buffer.dispose()\n })\n this.bufferList.length = 0\n\n Primitives.forEach(P => {\n Object.keys(P.fields).forEach(name => {\n this._primitiveData[ P.getShapeKey(name) ].length = 0\n })\n this._primitiveData[ P.getShapeKey('name') ].length = 0\n })\n }\n\n get center () {\n if (!this._center) {\n this._center = this.boundingBox.getCenter(new Vector3())\n }\n return this._center\n }\n\n get type () { return 'Shape' }\n}\n\nexport default Shape\n","/**\n * @file Buffer Representation\n * @author Alexander Rose \n * @private\n */\n\nimport Representation, { RepresentationParameters } from './representation'\nimport Viewer from '../viewer/viewer';\n\n/**\n * Representation for showing buffer objects. Good for efficiently showing\n * large amounts of geometric primitives e.g. spheres via {@link SphereBuffer}.\n * Smaller numbers of geometric primitives are more easily shown with help\n * from the {@link Shape} class.\n *\n * __Name:__ _buffer_\n *\n * @example\n * // add a single red sphere from a buffer to a shape instance\n * var shape = new NGL.Shape( \"shape\" );\n * var sphereBuffer = new NGL.SphereBuffer( {\n * position: new Float32Array( [ 0, 0, 0 ] ),\n * color: new Float32Array( [ 1, 0, 0 ] ),\n * radius: new Float32Array( [ 1 ] )\n * } );\n * shape.addBuffer( sphereBuffer );\n * var shapeComp = stage.addComponentFromObject( shape );\n * shapeComp.addRepresentation( \"buffer\" );\n *\n * @example\n * // add a single red sphere from a buffer to a structure component instance\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * var sphereBuffer = new NGL.SphereBuffer( {\n * position: new Float32Array( [ 0, 0, 0 ] ),\n * color: new Float32Array( [ 1, 0, 0 ] ),\n * radius: new Float32Array( [ 1 ] )\n * } );\n * o.addBufferRepresentation( sphereBuffer, { opacity: 0.5 } );\n * } );\n */\nclass BufferRepresentation extends Representation {\n buffer: Buffer[]\n /**\n * Create Buffer representation\n * @param {Buffer} buffer - a buffer object\n * @param {Viewer} viewer - a viewer object\n * @param {RepresentationParameters} params - representation parameters\n */\n constructor (buffer: Buffer|Buffer[], viewer: Viewer, params: Partial) {\n if (!Array.isArray(buffer)) {\n buffer = [ buffer ]\n }\n\n super(buffer, viewer, params)\n\n this.type = 'buffer'\n\n this.parameters = Object.assign({\n\n }, this.parameters, {\n\n colorScheme: null,\n colorScale: null,\n colorValue: null,\n colorDomain: null,\n colorMode: null\n\n })\n\n this.buffer = buffer\n\n this.init(params)\n }\n\n init (params: Partial) {\n super.init(params)\n\n this.build()\n }\n\n create () {\n this.bufferList.push.apply(this.bufferList, this.buffer)\n }\n\n attach (callback: ()=> void) {\n this.bufferList.forEach(buffer => {\n this.viewer.add(buffer)\n buffer.setParameters(this.getBufferParams())\n })\n this.setVisibility(this.visible)\n\n callback()\n }\n}\n\nexport default BufferRepresentation\n","/**\n * @file Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3 required for declaration only\n import { Vector3, Matrix4, Matrix3, BufferGeometry } from 'three'\n\nimport { getUintArray } from '../utils'\nimport { serialBlockArray } from '../math/array-utils'\nimport { applyMatrix3toVector3array, applyMatrix4toVector3array } from '../math/vector-utils'\nimport MeshBuffer from './mesh-buffer'\nimport { BufferParameters, BufferData } from './buffer'\nimport {Log} from \"../globals\";\n\nconst matrix = new Matrix4()\nconst normalMatrix = new Matrix3()\n\nfunction getData(data: BufferData, geo: BufferGeometry){\n const geoPosition = (geo.attributes as any).position.array\n const geoIndex = geo.index ? geo.index.array : undefined\n\n const n = data.position!.length / 3\n const m = geoPosition.length / 3\n\n const size = n * m\n\n const meshPosition = new Float32Array(size * 3)\n const meshNormal = new Float32Array(size * 3)\n const meshColor = new Float32Array(size * 3)\n\n let meshIndex\n if (geoIndex) {\n meshIndex = getUintArray(n * geoIndex.length, size)\n }\n\n return {\n position: meshPosition,\n color: meshColor,\n index: meshIndex,\n normal: meshNormal,\n primitiveId: data.primitiveId || serialBlockArray(n, m) as Float32Array,\n picking: data.picking\n }\n}\n\n/**\n * Geometry buffer. Base class for geometry-based buffers. Used to draw\n * geometry primitives given a mesh.\n * @interface\n */\nabstract class GeometryBuffer extends MeshBuffer {\n updateNormals = false\n\n geoPosition: Float32Array\n geoNormal: Float32Array\n geoIndex?: Uint32Array|Uint16Array\n\n positionCount: number\n geoPositionCount: number\n\n transformedGeoPosition: Float32Array\n transformedGeoNormal: Float32Array\n\n meshPosition: Float32Array\n meshColor: Float32Array\n meshIndex: Uint32Array|Uint16Array\n meshNormal: Float32Array\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n * @param {BufferGeometry} geo - geometry object\n */\n constructor (data: BufferData, params: Partial = {}, geo: BufferGeometry) {\n super(getData(data, geo), params)\n\n const geoPosition = (geo.attributes as any).position.array\n const geoNormal = (geo.attributes as any).normal.array\n const geoIndex = geo.index ? (geo.index.array as Uint32Array|Uint16Array) : undefined\n\n this.geoPosition = geoPosition\n this.geoNormal = geoNormal\n this.geoIndex = geoIndex\n\n this.positionCount = data.position!.length / 3\n this.geoPositionCount = geoPosition.length / 3\n\n this.transformedGeoPosition = new Float32Array(this.geoPositionCount * 3)\n this.transformedGeoNormal = new Float32Array(this.geoPositionCount * 3)\n\n const attributes = this.geometry.attributes as any // TODO\n this.meshPosition = attributes.position.array\n this.meshColor = attributes.color.array\n this.meshNormal = attributes.normal.array\n\n this.setAttributes(data)\n\n if (geoIndex) {\n const index = this.geometry.getIndex()\n if (!index) { Log.error('Index is null'); return; }\n this.meshIndex = index.array as Uint32Array|Uint16Array\n this.makeIndex()\n }\n }\n\n abstract applyPositionTransform (matrix: Matrix4, i: number, i3?: number): void\n\n setAttributes (data: Partial = {}, initNormals = false) {\n const attributes = this.geometry.attributes as any // TODO\n\n let position, color\n let geoPosition, geoNormal\n let transformedGeoPosition, transformedGeoNormal\n let meshPosition, meshColor, meshNormal\n\n const updateNormals = this.updateNormals\n\n if (data.position) {\n position = data.position\n geoPosition = this.geoPosition\n meshPosition = this.meshPosition\n transformedGeoPosition = this.transformedGeoPosition\n attributes.position.needsUpdate = true\n if (updateNormals || initNormals) {\n geoNormal = this.geoNormal\n meshNormal = this.meshNormal\n transformedGeoNormal = this.transformedGeoNormal\n attributes.normal.needsUpdate = true\n }\n }\n\n if (data.color) {\n color = data.color\n meshColor = this.meshColor\n attributes.color.needsUpdate = true\n }\n\n const n = this.positionCount\n const m = this.geoPositionCount\n\n for (let i = 0; i < n; ++i) {\n let j, l\n const k = i * m * 3\n const i3 = i * 3\n\n if (position && transformedGeoPosition && meshPosition && meshNormal && geoPosition && geoNormal) {\n transformedGeoPosition.set(geoPosition)\n matrix.makeTranslation(\n position[ i3 ], position[ i3 + 1 ], position[ i3 + 2 ]\n )\n this.applyPositionTransform(matrix, i, i3)\n applyMatrix4toVector3array(matrix.elements as unknown as Float32Array,\n transformedGeoPosition)\n\n meshPosition.set(transformedGeoPosition, k)\n\n if (updateNormals && transformedGeoNormal) {\n transformedGeoNormal.set(geoNormal)\n normalMatrix.getNormalMatrix(matrix)\n applyMatrix3toVector3array(normalMatrix.elements as unknown as Float32Array,\n transformedGeoNormal)\n\n meshNormal.set(transformedGeoNormal, k)\n } else if (initNormals) {\n meshNormal.set(geoNormal, k)\n }\n }\n\n if (color && meshColor) {\n for (j = 0; j < m; ++j) {\n l = k + 3 * j\n\n meshColor[ l ] = color[ i3 ]\n meshColor[ l + 1 ] = color[ i3 + 1 ]\n meshColor[ l + 2 ] = color[ i3 + 2 ]\n }\n }\n }\n }\n\n makeIndex () {\n const geoIndex = this.geoIndex\n const meshIndex = this.meshIndex\n\n if (!geoIndex) return\n\n const n = this.positionCount\n const m = this.geoPositionCount\n const o = geoIndex.length / 3\n\n const o3 = o * 3\n\n for (let i = 0; i < n; ++i) {\n const j = i * o3\n const q = j + o3\n\n meshIndex.set(geoIndex, j)\n for (let p = j; p < q; ++p) meshIndex[ p ] += i * m\n }\n }\n}\n\nexport default GeometryBuffer\n","/**\n * @file Sphere Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { IcosahedronBufferGeometry, Vector3, Matrix4 } from 'three'\nimport { defaults } from '../utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { SphereBufferData } from './sphere-buffer'\nimport { BufferDefaultParameters, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\n\nexport const SphereGeometryBufferDefaultParameters = Object.assign({\n sphereDetail: 1\n}, BufferDefaultParameters)\nexport type SphereGeometryBufferParameters = BufferParameters & { sphereDetail: number }\n\n/**\n * Sphere geometry buffer.\n *\n * @example\n * var sphereGeometryBuffer = new SphereGeometryBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass SphereGeometryBuffer extends GeometryBuffer {\n get defaultParameters() { return SphereGeometryBufferDefaultParameters }\n parameters: SphereGeometryBufferParameters\n\n private _radius: Float32Array\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: SphereBufferData, params: Partial = {}) {\n super(data, params, new IcosahedronBufferGeometry(1, defaults(params.sphereDetail, 1)))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number) {\n const r = this._radius[ i ]\n scale.set(r, r, r)\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.radius) this._radius = data.radius\n\n super.setAttributes(data, initNormals)\n }\n}\n\nexport default SphereGeometryBuffer\n","/**\n * @file Mapped Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { getUintArray } from '../utils'\nimport { calculateCenterArray, serialArray } from '../math/array-utils'\nimport Buffer, { BufferParameters, BufferData } from './buffer'\n\nexport type MappingType = 'v2'|'v3'\n\n/**\n * Mapped buffer. Sends mapping attribute to the GPU and repeats data in\n * others attributes. Used to render imposters.\n * @interface\n */\nabstract class MappedBuffer extends Buffer {\n index: Uint32Array|Uint16Array\n\n constructor (mappingType: MappingType, data: BufferData, params: Partial = {}) {\n super(data, params)\n\n this.index = getUintArray(this.indexSize, this.attributeSize)\n this.makeIndex()\n this.initIndex(this.index)\n\n this.addAttributes({\n 'mapping': { type: mappingType, value: null }\n })\n\n this.setAttributes({ primitiveId: serialArray(this.size) })\n }\n\n abstract get mapping (): Float32Array\n abstract get mappingIndices (): Uint32Array|Uint16Array\n abstract get mappingIndicesSize (): number\n abstract get mappingSize (): number\n abstract get mappingItemSize (): number\n\n get attributeSize () {\n return this.size * this.mappingSize\n }\n\n get indexSize () {\n return this.size * this.mappingIndicesSize\n }\n\n addAttributes (attributes: any) {\n const nullValueAttributes: any = {}\n for (const name in attributes) {\n const a = attributes[ name ]\n nullValueAttributes[ name ] = {\n type: a.type,\n value: null\n }\n }\n\n super.addAttributes(nullValueAttributes)\n }\n\n getAttributeIndex (dataIndex: number) {\n return dataIndex * 3 * this.mappingSize\n }\n\n setAttributes (data: any) { // TODO\n if (data && !data.position && data.position1 && data.position2) {\n data.position = calculateCenterArray(data.position1, data.position2)\n }\n\n const size = this.size\n const mappingSize = this.mappingSize\n const attributes = this.geometry.attributes as any // TODO\n\n let a, d, itemSize, array, n, i, j\n\n for (const name in data) {\n if (name === 'index' || name === 'picking') continue\n\n d = data[ name ]\n a = attributes[ name ]\n itemSize = a.itemSize\n array = a.array\n\n for (let k = 0; k < size; ++k) {\n n = k * itemSize\n i = n * mappingSize\n\n for (let l = 0; l < mappingSize; ++l) {\n j = i + (itemSize * l)\n\n for (let m = 0; m < itemSize; ++m) {\n array[ j + m ] = d[ n + m ]\n }\n }\n }\n\n a.needsUpdate = true\n }\n }\n\n makeMapping () {\n const size = this.size\n const mapping = this.mapping\n const mappingSize = this.mappingSize\n const mappingItemSize = this.mappingItemSize\n\n const attributes = this.geometry.attributes as any // TODO\n const aMapping = attributes.mapping.array\n\n for (let v = 0; v < size; v++) {\n aMapping.set(mapping, v * mappingItemSize * mappingSize)\n }\n }\n\n makeIndex () {\n const size = this.size\n const mappingSize = this.mappingSize\n const mappingIndices = this.mappingIndices\n const mappingIndicesSize = this.mappingIndicesSize\n\n const index = this.index\n\n for (let v = 0; v < size; v++) {\n const ix = v * mappingIndicesSize\n const it = v * mappingSize\n\n index.set(mappingIndices, ix)\n\n for (let s = 0; s < mappingIndicesSize; ++s) {\n index[ ix + s ] += it\n }\n }\n }\n}\n\nexport default MappedBuffer\n","/**\n * @file Mapped Quad Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { BufferParameters, BufferData } from './buffer'\nimport MappedBuffer from './mapped-buffer'\n\nconst mapping = new Float32Array([\n -1.0, 1.0,\n -1.0, -1.0,\n 1.0, 1.0,\n 1.0, -1.0\n])\n\nconst mappingIndices = new Uint16Array([\n 0, 1, 2,\n 1, 3, 2\n])\n\n/**\n * Mapped Quad buffer. Draws screen-aligned quads. Used to render impostors.\n * @interface\n */\nclass MappedQuadBuffer extends MappedBuffer {\n constructor(data: BufferData, params: Partial = {}) {\n super('v2', data, params)\n }\n get mapping () { return mapping }\n get mappingIndices () { return mappingIndices }\n get mappingIndicesSize () { return 6 }\n get mappingSize () { return 4 }\n get mappingItemSize () { return 2 }\n}\n\nexport default MappedQuadBuffer\n","/**\n * @file Sphere Impostor Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport '../shader/SphereImpostor.vert'\nimport '../shader/SphereImpostor.frag'\n\nimport MappedQuadBuffer from './mappedquad-buffer'\nimport { SphereBufferData } from './sphere-buffer'\nimport { BufferParameters } from './buffer'\n\n/**\n * Sphere impostor buffer.\n *\n * @example\n * var sphereImpostorBuffer = new SphereImpostorBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass SphereImpostorBuffer extends MappedQuadBuffer {\n isImpostor = true\n vertexShader = 'SphereImpostor.vert'\n fragmentShader = 'SphereImpostor.frag'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: SphereBufferData, params: Partial = {}) {\n super(data, params)\n\n this.addUniforms({\n 'projectionMatrixInverse': { value: new Matrix4() },\n 'ortho': { value: 0.0 }\n })\n\n this.addAttributes({\n 'radius': { type: 'f', value: null }\n })\n\n this.setAttributes(data)\n this.makeMapping()\n }\n}\n\nexport default SphereImpostorBuffer\n","/**\n * @file Sphere Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only \nimport { Vector3, Matrix4 } from 'three'\nimport { BufferRegistry, ExtensionFragDepth } from '../globals'\nimport SphereGeometryBuffer, { SphereGeometryBufferDefaultParameters, SphereGeometryBufferParameters } from './spheregeometry-buffer'\nimport SphereImpostorBuffer from './sphereimpostor-buffer'\nimport { BufferData } from './buffer'\n\nexport interface SphereBufferData extends BufferData {\n radius: Float32Array\n}\n\nexport const SphereBufferDefaultParameters = Object.assign({\n disableImpostor: false\n}, SphereGeometryBufferDefaultParameters)\nexport type SphereBufferParameters = SphereGeometryBufferParameters & { disableImpostor: boolean }\n\nclass SphereBufferImpl {\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} params - parameters object\n * @return {SphereGeometryBuffer|SphereImpostorBuffer} the buffer object\n */\n constructor (data: SphereBufferData, params: SphereBufferParameters) {\n if (!ExtensionFragDepth || (params && params.disableImpostor)) {\n return new SphereGeometryBuffer(data, params)\n } else {\n return new SphereImpostorBuffer(data, params)\n }\n }\n}\n\n/**\n * Sphere buffer. Depending on the value {@link ExtensionFragDepth} and\n * `params.disableImpostor` the constructor returns either a\n * {@link SphereGeometryBuffer} or a {@link SphereImpostorBuffer}\n * @implements {Buffer}\n *\n * @example\n * var sphereBuffer = new SphereBuffer( {\n * position: new Float32Array( [ 0, 0, 0 ] ),\n * color: new Float32Array( [ 1, 0, 0 ] ),\n * radius: new Float32Array( [ 1 ] )\n * } );\n */\n//@ts-expect-error Incompatible constructor signatures\nconst SphereBuffer: {\n new(data: SphereBufferData, params: SphereBufferParameters): SphereGeometryBuffer | SphereImpostorBuffer;\n} = SphereBufferImpl;\n\ntype SphereBuffer = SphereGeometryBuffer | SphereImpostorBuffer;\n\nBufferRegistry.add('sphere', SphereBuffer)\n\nexport default SphereBuffer\n","/**\n * @file Point Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { DataTexture, Vector3, Matrix4 } from 'three'\n\nimport '../shader/Point.vert'\nimport '../shader/Point.frag'\n\nimport { BufferRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { smoothstep } from '../math/math-utils'\nimport Buffer, { BufferDefaultParameters, BufferParameterTypes, BufferData, BufferTypes, BufferParameters } from './buffer'\n\nfunction distance (x0: number, y0: number, x1: number, y1: number) {\n const dx = x1 - x0\n const dy = y1 - y0\n return Math.sqrt(dx * dx + dy * dy)\n}\n\ninterface PointTextureParams {\n width?: number\n height?: number\n delta?: number\n}\n\nfunction makePointTexture (params: PointTextureParams) {\n const p = params || {}\n\n const width = defaults(p.width, 256)\n const height = defaults(p.height, 256)\n const center = [ width / 2, height / 2 ]\n const radius = Math.min(width / 2, height / 2)\n const delta = defaults(p.delta, 1 / (radius + 1)) * radius\n\n let x = 0\n let y = 0\n const data = new Uint8Array(width * height * 4)\n\n for (let i = 0, il = data.length; i < il; i += 4) {\n const dist = distance(x, y, center[ 0 ], center[ 1 ])\n const value = 1 - smoothstep(radius - delta, radius, dist)\n\n data[ i ] = value * 255\n data[ i + 1 ] = value * 255\n data[ i + 2 ] = value * 255\n data[ i + 3 ] = value * 255\n\n if (++x === width) {\n x = 0\n y++\n }\n }\n\n const tex = new DataTexture(data, width, height)\n tex.needsUpdate = true\n\n return tex\n}\n\nexport const PointBufferDefaultParameters = Object.assign({\n pointSize: 1,\n sizeAttenuation: true,\n sortParticles: false,\n alphaTest: 0.5,\n useTexture: false,\n forceTransparent: false,\n edgeBleach: 0.0\n}, BufferDefaultParameters)\nexport type PointBufferParameters = BufferParameters & {\n pointSize: number,\n sizeAttenuation: boolean,\n sortParticles: boolean,\n alphaTest: number,\n useTexture: boolean,\n forceTransparent: boolean,\n edgeBleach: number\n}\n\nconst PointBufferParameterTypes = Object.assign({\n pointSize: { uniform: 'size' },\n sizeAttenuation: { updateShader: true },\n sortParticles: {},\n alphaTest: { updateShader: true },\n useTexture: { updateShader: true },\n forceTransparent: {},\n edgeBleach: { uniform: true }\n}, BufferParameterTypes)\n\n/**\n * Point buffer. Draws points. Optionally textured.\n *\n * @example\n * var pointBuffer = new PointBuffer( {\n * position: new Float32Array( [ 0, 0, 0 ] ),\n * color: new Float32Array( [ 1, 0, 0 ] )\n * } );\n */\nclass PointBuffer extends Buffer {\n parameterTypes = PointBufferParameterTypes\n get defaultParameters() { return PointBufferDefaultParameters }\n parameters: PointBufferParameters\n\n vertexShader = 'Point.vert'\n fragmentShader ='Point.frag'\n\n isPoint = true\n tex: DataTexture\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: BufferData, params: Partial = {}) {\n super(data, params)\n\n this.addUniforms({\n 'size': { value: this.parameters.pointSize },\n 'canvasHeight': { value: 1.0 },\n 'pixelRatio': { value: 1.0 },\n 'map': { value: null }\n })\n }\n\n makeMaterial () {\n super.makeMaterial()\n\n this.makeTexture()\n\n const m = this.material\n const wm = this.wireframeMaterial\n const pm = this.pickingMaterial\n\n m.uniforms.map.value = this.tex\n m.needsUpdate = true\n\n wm.uniforms.map.value = this.tex\n wm.needsUpdate = true\n\n pm.uniforms.map.value = this.tex\n pm.needsUpdate = true\n }\n\n makeTexture () {\n if (this.tex) this.tex.dispose()\n this.tex = makePointTexture({ delta: this.parameters.edgeBleach })\n }\n\n getDefines (type?: BufferTypes) {\n const defines = super.getDefines(type)\n\n if (this.parameters.sizeAttenuation) {\n defines.USE_SIZEATTENUATION = 1\n }\n\n if (this.parameters.useTexture) {\n defines.USE_MAP = 1\n }\n\n if (this.parameters.alphaTest > 0 && this.parameters.alphaTest <= 1) {\n defines.ALPHATEST = this.parameters.alphaTest.toPrecision(2)\n }\n\n return defines\n }\n\n setUniforms (data: any) {\n if (data && data.edgeBleach !== undefined) {\n this.makeTexture()\n data.map = this.tex\n }\n\n super.setUniforms(data)\n }\n\n dispose () {\n super.dispose()\n\n if (this.tex) this.tex.dispose()\n }\n}\n\nBufferRegistry.add('point', PointBuffer)\n\nexport default PointBuffer\n","/**\n * @file Dot Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { ExtensionFragDepth } from '../globals'\nimport { defaults } from '../utils'\nimport Representation, { RepresentationParameters } from './representation'\nimport Volume from '../surface/volume'\nimport FilteredVolume from '../surface/filtered-volume'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport PointBuffer from '../buffer/point-buffer'\nimport Surface from '../surface/surface';\nimport Viewer from '../viewer/viewer';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\n\nexport interface DotDataFields {\n color?: boolean,\n radius?: boolean,\n scale?: boolean\n}\n\n/**\n * Dot representation parameter object. Extends {@link RepresentationParameters}\n *\n * @typedef {Object} DotRepresentationParameters - dot representation parameters\n *\n * @property {String} thresholdType - Meaning of the threshold values. Either *value* for the literal value or *sigma* as a factor of the sigma of the data. For volume data only.\n * @property {Number} thresholdMin - Minimum value to be displayed. For volume data only.\n * @property {Number} thresholdMax - Maximum value to be displayed. For volume data only.\n * @property {Number} thresholdOut - Show only values falling outside of the treshold minumum and maximum. For volume data only.\n */\nexport interface DotRepresentationParameters extends RepresentationParameters {\n thresholdType: 'value'|'value'|'sigma'|'sigma'\n thresholdMin: number\n thresholdMax: number\n thresholdOut: boolean\n dotType: ''|'sphere'|'point'\n radiusType: ''|'value'|'abs-value'|'value-min'|'deviation'|'size'|'radius' //TODO had to add 'radius' because of test in line 333\n radius: number\n scale: number\n sphereDetail: number\n disableImpostor: boolean\n pointSize: number\n sizeAttenuation: boolean\n sortParticles: boolean\n useTexture: boolean\n alphaTest: number\n forceTransparent: boolean\n edgeBleach: number\n}\n/**\n * Dot representation\n */\nclass DotRepresentation extends Representation {\n protected thresholdType: 'value'|'value'|'sigma'|'sigma'\n protected thresholdMin: number\n protected thresholdMax: number\n protected thresholdOut: boolean\n protected dotType: ''|'sphere'|'point'\n protected radiusType: ''|'value'|'abs-value'|'value-min'|'deviation'|'size'|'radius' //TODO had to add 'radius' because of test in line 333\n protected radius: number\n protected scale: number\n protected sphereDetail: number\n protected disableImpostor: boolean\n protected pointSize: number\n protected sizeAttenuation: boolean\n protected sortParticles: boolean\n protected useTexture: boolean\n protected alphaTest: number\n protected forceTransparent: boolean\n protected edgeBleach: number\n\n protected surface: Surface|undefined\n protected volume: FilteredVolume|undefined\n protected dotBuffer: SphereBuffer|PointBuffer\n /**\n * Create Dot representation object\n * @param {Surface|Volume} surface - the surface or volume to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {DotRepresentationParameters} params - dot representation parameters\n */\n constructor (surface: Surface, viewer: Viewer, params: Partial) {\n super(surface, viewer, params)\n\n this.type = 'dot'\n\n this.parameters = Object.assign({\n\n thresholdType: {\n type: 'select',\n rebuild: true,\n options: {\n 'value': 'value', 'sigma': 'sigma'\n }\n },\n thresholdMin: {\n type: 'number', precision: 3, max: Infinity, min: -Infinity, rebuild: true\n },\n thresholdMax: {\n type: 'number', precision: 3, max: Infinity, min: -Infinity, rebuild: true\n },\n thresholdOut: {\n type: 'boolean', rebuild: true\n },\n dotType: {\n type: 'select',\n rebuild: true,\n options: {\n '': '',\n 'sphere': 'sphere',\n 'point': 'point'\n }\n },\n radiusType: {\n type: 'select',\n options: {\n '': '',\n 'value': 'value',\n 'abs-value': 'abs-value',\n 'value-min': 'value-min',\n 'deviation': 'deviation',\n 'size': 'size'\n }\n },\n radius: {\n type: 'number', precision: 3, max: 10.0, min: 0.001, property: 'size'\n },\n scale: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n sphereDetail: true,\n disableImpostor: true,\n\n pointSize: {\n type: 'number', precision: 1, max: 100, min: 0, buffer: true\n },\n sizeAttenuation: {\n type: 'boolean', buffer: true\n },\n sortParticles: {\n type: 'boolean', rebuild: true\n },\n useTexture: {\n type: 'boolean', buffer: true\n },\n alphaTest: {\n type: 'range', step: 0.001, max: 1, min: 0, buffer: true\n },\n forceTransparent: {\n type: 'boolean', buffer: true\n },\n edgeBleach: {\n type: 'range', step: 0.001, max: 1, min: 0, buffer: true\n }\n\n }, this.parameters, {\n\n colorScheme: {\n type: 'select',\n update: 'color',\n options: {\n '': '',\n 'value': 'value',\n 'uniform': 'uniform',\n 'random': 'random'\n }\n }\n\n })\n\n if (surface instanceof Volume) {\n this.surface = undefined\n this.volume = new FilteredVolume(surface)\n } else {\n this.surface = surface\n this.volume = undefined\n }\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'uniform')\n p.colorValue = defaults(p.colorValue, 0xDDDDDD)\n\n this.thresholdType = defaults(p.thresholdType, 'sigma')\n this.thresholdMin = defaults(p.thresholdMin, 2.0)\n this.thresholdMax = defaults(p.thresholdMax, Infinity)\n this.thresholdOut = defaults(p.thresholdOut, false)\n this.dotType = defaults(p.dotType, 'point')\n this.radius = defaults(p.radius, 0.1)\n this.scale = defaults(p.scale, 1.0)\n\n this.pointSize = defaults(p.pointSize, 1)\n this.sizeAttenuation = defaults(p.sizeAttenuation, true)\n this.sortParticles = defaults(p.sortParticles, false)\n this.useTexture = defaults(p.useTexture, false)\n this.alphaTest = defaults(p.alphaTest, 0.5)\n this.forceTransparent = defaults(p.forceTransparent, false)\n this.edgeBleach = defaults(p.edgeBleach, 0.0)\n\n super.init(p)\n\n this.build()\n }\n\n attach (callback: () => void) {\n this.bufferList.forEach(buffer => {\n this.viewer.add(buffer)\n })\n this.setVisibility(this.visible)\n\n callback()\n }\n\n create () {\n var dotData: SphereBufferData|{} = {}\n\n if (this.volume) {\n var volume = this.volume\n var thresholdMin, thresholdMax\n\n if (this.thresholdType === 'sigma') {\n thresholdMin = volume.getValueForSigma(this.thresholdMin)\n thresholdMax = volume.getValueForSigma(this.thresholdMax)\n } else {\n thresholdMin = this.thresholdMin\n thresholdMax = this.thresholdMax\n }\n volume.setFilter(thresholdMin, thresholdMax, this.thresholdOut)\n\n Object.assign(dotData, {\n position: volume.getDataPosition(),\n color: volume.getDataColor(this.getColorParams())\n })\n if (this.dotType === 'sphere') {\n Object.assign(dotData, {\n radius: volume.getDataSize(this.radius, this.scale),\n picking: volume.getDataPicking()\n })\n }\n } else {\n var surface = this.surface\n Object.assign(dotData, {\n position: (surface as Surface).getPosition(),\n color: (surface as Surface).getColor(this.getColorParams())\n })\n if (this.dotType === 'sphere') {\n Object.assign(dotData, {\n radius: (surface as Surface).getSize(this.radius, this.scale),\n picking: (surface as Surface).getPicking()\n })\n }\n }\n\n if (this.dotType === 'sphere') {\n this.dotBuffer = new SphereBuffer(\n dotData as SphereBufferData,\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: false\n }) as SphereBufferParameters\n ) as SphereGeometryBuffer\n } else {\n this.dotBuffer = new PointBuffer(\n dotData,\n this.getBufferParams({\n pointSize: this.pointSize,\n sizeAttenuation: this.sizeAttenuation,\n sortParticles: this.sortParticles,\n useTexture: this.useTexture,\n alphaTest: this.alphaTest,\n forceTransparent: this.forceTransparent,\n edgeBleach: this.edgeBleach\n })\n )\n }\n\n this.bufferList.push(this.dotBuffer as SphereGeometryBuffer)\n }\n\n update (what: DotDataFields = {}) {\n if (this.bufferList.length === 0) return\n\n const dotData: SphereBufferData|{} = {}\n\n if (what.color) {\n if (this.volume) {\n Object.assign(dotData, {\n color: this.volume.getDataColor(\n this.getColorParams()\n )\n })\n } else {\n Object.assign(dotData, {\n color: (this.surface as Surface).getColor(\n this.getColorParams()\n )\n })\n }\n }\n\n if (this.dotType === 'sphere' && (what.radius || what.scale)) {\n if (this.volume) {\n Object.assign(dotData, {\n radius: this.volume.getDataSize(\n this.radius, this.scale\n )\n })\n } else {\n Object.assign(dotData, {\n radius: (this.surface as Surface).getSize(\n this.radius, this.scale\n )\n })\n }\n }\n\n (this.dotBuffer as SphereGeometryBuffer).setAttributes(dotData)\n }\n\n setParameters (params: Partial, what: DotDataFields = {}, rebuild: boolean) {\n \n if (params && params.thresholdType !== undefined &&\n this.volume instanceof Volume\n ) {\n if (this.thresholdType === 'value' &&\n params.thresholdType === 'sigma'\n ) {\n this.thresholdMin = this.volume.getSigmaForValue(\n this.thresholdMin\n )\n this.thresholdMax = this.volume.getSigmaForValue(\n this.thresholdMax\n )\n } else if (this.thresholdType === 'sigma' &&\n params.thresholdType === 'value'\n ) {\n this.thresholdMin = this.volume.getValueForSigma(\n this.thresholdMin\n )\n this.thresholdMax = this.volume.getValueForSigma(\n this.thresholdMax\n )\n }\n\n this.thresholdType = params.thresholdType\n }\n\n if (params && params.radiusType !== undefined) {\n if (params.radiusType === 'radius') {\n this.radius = 0.1\n } else {\n this.radius = parseFloat(params.radiusType)\n }\n what.radius = true\n if (this.dotType === 'sphere' &&\n (!ExtensionFragDepth || this.disableImpostor)\n ) {\n rebuild = true\n }\n }\n\n if (params && params.radius !== undefined) {\n what.radius = true\n if (this.dotType === 'sphere' &&\n (!ExtensionFragDepth || this.disableImpostor)\n ) {\n rebuild = true\n }\n }\n\n if (params && params.scale !== undefined) {\n what.scale = true\n if (this.dotType === 'sphere' &&\n (!ExtensionFragDepth || this.disableImpostor)\n ) {\n rebuild = true\n }\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nexport default DotRepresentation\n","/**\n * @file Image Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport {\n // @ts-ignore: unused import Vector3, Matrix4 required for declaration only\n Vector2, Vector3, Matrix4, BufferAttribute, DataTexture,\n NormalBlending, NearestFilter, LinearFilter\n} from 'three'\n\nimport '../shader/Image.vert'\nimport '../shader/Image.frag'\n\nimport { Picker } from '../utils/picker'\nimport Buffer, { BufferDefaultParameters, BufferParameterTypes, BufferTypes } from './buffer'\n\n\nconst quadIndices = new Uint16Array([\n 0, 1, 2,\n 1, 3, 2\n])\n\nconst quadUvs = new Float32Array([\n 0, 1,\n 0, 0,\n 1, 1,\n 1, 0\n])\n\ntype ImageFilterTypes = 'nearest'|'linear'|'cubic-bspline'|'cubic-catmulrom'|'cubic-mitchell'\n\nexport interface ImageBufferData {\n position: Float32Array\n imageData: Uint8Array\n width: number\n height: number\n\n picking?: Picker\n}\n\nexport const ImageBufferDefaultParameters = Object.assign({\n filter: 'nearest' as ImageFilterTypes,\n forceTransparent: true\n}, BufferDefaultParameters)\nexport type ImageBufferParameters = typeof ImageBufferDefaultParameters\n\nexport const ImageBufferParameterTypes = Object.assign({\n filter: { updateShader: true, uniform: true }\n}, BufferParameterTypes)\n\n/**\n * Image buffer. Draw a single image. Optionally interpolate.\n */\nclass ImageBuffer extends Buffer {\n parameterTypes = ImageBufferParameterTypes\n get defaultParameters() { return ImageBufferDefaultParameters }\n parameters: ImageBufferParameters\n\n alwaysTransparent = true\n hasWireframe = false\n vertexShader = 'Image.vert'\n fragmentShader = 'Image.frag'\n\n tex: DataTexture\n pickingTex: DataTexture\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position - image position\n * @param {Float32Array} data.imageData - image data, rgba channels\n * @param {Float32Array} data.width - image width\n * @param {Float32Array} data.height - image height\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n */\n constructor (data: ImageBufferData, params: ImageBufferParameters) {\n super({\n position: data.position,\n index: quadIndices,\n picking: data.picking\n }, params)\n\n const {imageData, width, height} = data\n\n const tex = new DataTexture(imageData, width, height)\n tex.flipY = true\n this.tex = tex\n\n const n = imageData.length\n const pickingData = new Uint8Array(n)\n for (let i = 0; i < n; i += 4) {\n const j = i / 4\n pickingData[ i ] = j >> 16 & 255\n pickingData[ i + 1 ] = j >> 8 & 255\n pickingData[ i + 2 ] = j & 255\n }\n\n const pickingTex = new DataTexture(pickingData, width, height)\n pickingTex.flipY = true\n pickingTex.minFilter = NearestFilter\n pickingTex.magFilter = NearestFilter\n this.pickingTex = pickingTex\n\n this.addUniforms({\n 'map': { value: tex },\n 'pickingMap': { value: pickingTex },\n 'mapSize': { value: new Vector2(width, height) }\n })\n\n this.geometry.setAttribute('uv', new BufferAttribute(quadUvs, 2))\n }\n\n getDefines (type: BufferTypes) {\n const defines = super.getDefines(type)\n const filter = this.parameters.filter\n\n if (filter.startsWith('cubic')) {\n defines.CUBIC_INTERPOLATION = 1\n if (filter.endsWith('bspline')) {\n defines.BSPLINE_FILTER = 1\n } else if (filter.endsWith('catmulrom')) {\n defines.CATMULROM_FILTER = 1\n } else if (filter.endsWith('mitchell')) {\n defines.MITCHELL_FILTER = 1\n }\n }\n\n return defines\n }\n\n updateTexture () {\n const tex = this.tex\n const filter = this.parameters.filter\n\n if (filter.startsWith('cubic')) {\n tex.minFilter = NearestFilter\n tex.magFilter = NearestFilter\n } else if (filter === 'linear') {\n tex.minFilter = LinearFilter\n tex.magFilter = LinearFilter\n } else { // filter === \"nearest\"\n tex.minFilter = NearestFilter\n tex.magFilter = NearestFilter\n }\n\n tex.needsUpdate = true\n this.pickingTex.needsUpdate = true\n }\n\n makeMaterial () {\n super.makeMaterial()\n this.updateTexture()\n\n const m = this.material\n m.uniforms.map.value = this.tex\n m.blending = NormalBlending\n m.needsUpdate = true\n\n const wm = this.wireframeMaterial\n wm.uniforms.map.value = this.tex\n wm.blending = NormalBlending\n wm.needsUpdate = true\n\n const pm = this.pickingMaterial\n pm.uniforms.map.value = this.tex\n pm.uniforms.pickingMap.value = this.pickingTex\n pm.blending = NormalBlending\n pm.needsUpdate = true\n }\n\n setUniforms (data: any) { // TODO\n if (data && data.filter !== undefined) {\n this.updateTexture()\n data.map = this.tex\n }\n\n super.setUniforms(data)\n }\n}\n\nexport default ImageBuffer\n","/**\n * @file Volume Slice\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { SlicePicker } from '../utils/picker'\nimport { Volume } from '../ngl';\nimport { SliceRepresentationParameters } from '../representation/slice-representation';\n\nclass VolumeSlice {\n dimension: 'x'|'y'|'z'\n positionType: 'percent'|'coordinate'\n position: number\n thresholdType: 'sigma'|'value'\n thresholdMin: number\n thresholdMax: number\n normalize: boolean\n volume: Volume\n\n constructor (volume: Volume, params: Partial) {\n const p = params || {}\n\n this.dimension = defaults(p.dimension, 'x')\n this.positionType = defaults(p.positionType, 'percent')\n this.position = defaults(p.position, 30)\n this.thresholdType = defaults(p.thresholdType, 'sigma')\n this.thresholdMin = defaults(p.thresholdMin, -Infinity)\n this.thresholdMax = defaults(p.thresholdMax, Infinity)\n this.normalize = defaults(p.normalize, false)\n\n this.volume = volume\n }\n\n getPositionFromCoordinate (coord: number) {\n const dim = this.dimension\n const v = this.volume\n const m = v.matrix\n\n const mp = new Vector3().setFromMatrixPosition(m)[ dim ]\n const ms = new Vector3().setFromMatrixScale(m)[ dim ]\n\n let vn\n if (dim === 'x') {\n vn = v.nx\n } else if (dim === 'y') {\n vn = v.ny\n } else {\n vn = v.nz\n }\n\n return Math.round((((coord - mp) / (vn / 100)) + 1) / ms)\n }\n\n getData (params: any) {\n params = params || {}\n\n const v = this.volume\n const d = v.data\n const m = v.matrix\n\n let p: number\n if (this.positionType === 'coordinate') {\n p = this.getPositionFromCoordinate(this.position)\n } else {\n p = this.position\n }\n\n function pos (dimLen: number) {\n return Math.round((dimLen / 100) * (p - 1))\n }\n\n function index (x: number, y: number, z: number, i: number) {\n return (z * v.ny * v.nx + y * v.nx + x) * 3 + i\n }\n\n const position = new Float32Array(4 * 3)\n const vec = new Vector3()\n\n let width, height\n let x\n let y\n let z\n let x0 = 0\n let y0 = 0\n let z0 = 0\n let nx = v.nx\n let ny = v.ny\n let nz = v.nz\n\n function setVec (x: number, y: number, z: number, offset: number) {\n vec.set(x, y, z).applyMatrix4(m).toArray(position as any, offset)\n }\n\n if (this.dimension === 'x') {\n x = pos(v.nx)\n y = v.ny - 1\n z = v.nz - 1\n\n width = v.nz\n height = v.ny\n\n x0 = x\n nx = x0 + 1\n\n setVec(x, 0, 0, 0)\n setVec(x, y, 0, 3)\n setVec(x, 0, z, 6)\n setVec(x, y, z, 9)\n } else if (this.dimension === 'y') {\n x = v.nx - 1\n y = pos(v.ny)\n z = v.nz - 1\n\n width = v.nz\n height = v.nx\n\n y0 = y\n ny = y0 + 1\n\n setVec(0, y, 0, 0)\n setVec(x, y, 0, 3)\n setVec(0, y, z, 6)\n setVec(x, y, z, 9)\n } else if (this.dimension === 'z') {\n x = v.nx - 1\n y = v.ny - 1\n z = pos(v.nz)\n\n width = v.nx\n height = v.ny\n\n z0 = z\n nz = z0 + 1\n\n setVec(0, 0, z, 0)\n setVec(0, y, z, 3)\n setVec(x, 0, z, 6)\n setVec(x, y, z, 9)\n }\n\n let i = 0\n let j = 0\n const imageData = new Uint8Array(width * height * 4)\n const pickingArray = new Float32Array(width * height)\n\n let tMin, tMax\n if (this.thresholdType === 'sigma') {\n tMin = v.getValueForSigma(this.thresholdMin)\n tMax = v.getValueForSigma(this.thresholdMax)\n } else {\n tMin = this.thresholdMin\n tMax = this.thresholdMax\n }\n\n const cp = Object.assign({}, params.colorParams, { volume: v })\n if (this.normalize) {\n cp.domain = [ 0, 1 ]\n }\n const colormaker = ColormakerRegistry.getScheme(cp)\n const tmp = new Float32Array(3)\n const scale = colormaker.getScale()\n\n let min = 0, max, diff = 0\n if (this.normalize) {\n min = +Infinity\n max = -Infinity\n for (let iy = y0; iy < ny; ++iy) {\n for (let ix = x0; ix < nx; ++ix) {\n for (let iz = z0; iz < nz; ++iz) {\n const idx = index(ix, iy, iz, 0) / 3\n const val = d[ idx ]\n if (val < min) min = val\n if (val > max) max = val\n }\n }\n }\n diff = max - min\n }\n\n for (let iy = y0; iy < ny; ++iy) {\n for (let ix = x0; ix < nx; ++ix) {\n for (let iz = z0; iz < nz; ++iz) {\n const idx = index(ix, iy, iz, 0) / 3\n let val = d[ idx ]\n if (this.normalize) {\n val = (val - min) / diff\n }\n\n colormaker.colorToArray(scale(val), tmp)\n imageData[ i ] = Math.round(tmp[ 0 ] * 255)\n imageData[ i + 1 ] = Math.round(tmp[ 1 ] * 255)\n imageData[ i + 2 ] = Math.round(tmp[ 2 ] * 255)\n imageData[ i + 3 ] = (val > tMin && val < tMax) ? 255 : 0\n\n pickingArray[ j ] = idx\n\n ++j\n i += 4\n }\n }\n }\n\n const picking = new SlicePicker(pickingArray, v)\n\n return { position, imageData, width, height, picking }\n }\n}\n\nexport default VolumeSlice\n","/**\n * @file Slice Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport Representation, { RepresentationParameters } from './representation'\nimport ImageBuffer, { ImageBufferParameters, ImageBufferData } from '../buffer/image-buffer'\nimport VolumeSlice from '../surface/volume-slice'\nimport Viewer from '../viewer/viewer';\nimport { Volume } from '../ngl';\n\n/**\n * Slice representation parameter object. Extends {@link RepresentationParameters}\n *\n * @typedef {Object} SliceRepresentationParameters - slice representation parameters\n *\n * @property {String} filter - filter applied to map the volume data on the slice, one of \"nearest\", \"linear\", \"cubic-bspline\", \"cubic-catmulrom\", \"cubic-mitchell\".\n * @property {String} positionType - Meaning of the position value. Either \"percent\" od \"coordinate\".\n * @property {Number} position - position of the slice.\n * @property {String} dimension - one of \"x\", \"y\" or \"z\"\n * @property {String} thresholdType - Meaning of the threshold values. Either *value* for the literal value or *sigma* as a factor of the sigma of the data. For volume data only.\n * @property {Number} thresholdMin - Minimum value to be displayed. For volume data only.\n * @property {Number} thresholdMax - Maximum value to be displayed. For volume data only.\n * @property {Boolean} normalize - Flag indicating wheather to normalize the data in a slice when coloring.\n */\nexport interface SliceRepresentationParameters extends RepresentationParameters {\n filter: 'nearest'|'linear'|'cubic-bspline'|'cubic-catmulrom'|'cubic-mitchell'\n positionType: 'percent'|'coordinate'\n position: number\n dimension: 'x'|'y'|'z'\n thresholdType: 'value'|'sigma'\n thresholdMin: number\n thresholdMax: number\n normalize: boolean\n}\n/**\n * Slice representation\n */\nclass SliceRepresentation extends Representation {\n protected filter: 'nearest'|'linear'|'cubic-bspline'|'cubic-catmulrom'|'cubic-mitchell'\n protected positionType: 'percent'|'coordinate'\n protected position: number\n protected dimension: 'x'|'y'|'z'\n protected thresholdType: 'value'|'sigma'\n protected thresholdMin: number\n protected thresholdMax: number\n protected normalize: boolean\n protected volume: Volume\n /**\n * Create Slice representation object\n * @param {Volume} surface - the volume to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {SliceRepresentationParameters} params - slice representation parameters\n */\n constructor (volume: Volume, viewer: Viewer, params: Partial) {\n super(volume, viewer, params)\n\n this.type = 'slice'\n\n this.parameters = Object.assign({\n\n filter: {\n type: 'select',\n buffer: true,\n options: {\n 'nearest': 'nearest',\n 'linear': 'linear',\n 'cubic-bspline': 'cubic-bspline',\n 'cubic-catmulrom': 'cubic-catmulrom',\n 'cubic-mitchell': 'cubic-mitchell'\n }\n },\n positionType: {\n type: 'select',\n rebuild: true,\n options: {\n 'percent': 'percent', 'coordinate': 'coordinate'\n }\n },\n position: {\n type: 'range',\n step: 0.1,\n max: 100,\n min: 1,\n rebuild: true\n },\n dimension: {\n type: 'select',\n rebuild: true,\n options: {\n 'x': 'x', 'y': 'y', 'z': 'z'\n }\n },\n thresholdType: {\n type: 'select',\n rebuild: true,\n options: {\n 'value': 'value', 'sigma': 'sigma'\n }\n },\n thresholdMin: {\n type: 'number', precision: 3, max: Infinity, min: -Infinity, rebuild: true\n },\n thresholdMax: {\n type: 'number', precision: 3, max: Infinity, min: -Infinity, rebuild: true\n },\n normalize: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n\n flatShaded: null,\n side: null,\n wireframe: null,\n linewidth: null,\n colorScheme: null,\n\n roughness: null,\n metalness: null,\n diffuse: null\n\n })\n\n this.volume = volume\n\n this.init(params)\n }\n\n init (params: Partial) {\n const v = this.volume\n const p = params || {}\n p.colorDomain = defaults(p.colorDomain, [ v.min, v.max ])\n p.colorScheme = defaults(p.colorScheme, 'value')\n p.colorScale = defaults(p.colorScale, 'Spectral')\n\n this.colorScheme = 'value'\n this.dimension = defaults(p.dimension, 'x')\n this.filter = defaults(p.filter, 'cubic-bspline')\n this.positionType = defaults(p.positionType, 'percent')\n this.position = defaults(p.position, 30)\n this.thresholdType = defaults(p.thresholdType, 'sigma')\n this.thresholdMin = defaults(p.thresholdMin, -Infinity)\n this.thresholdMax = defaults(p.thresholdMax, Infinity)\n this.normalize = defaults(p.normalize, false)\n\n super.init(p)\n\n this.build()\n }\n\n attach (callback: () => void) {\n this.bufferList.forEach(buffer => {\n this.viewer.add(buffer)\n })\n this.setVisibility(this.visible)\n\n callback()\n }\n\n create () {\n const volumeSlice = new VolumeSlice(this.volume, {\n positionType: this.positionType,\n position: this.position,\n dimension: this.dimension,\n thresholdType: this.thresholdType,\n thresholdMin: this.thresholdMin,\n thresholdMax: this.thresholdMax,\n normalize: this.normalize\n })\n\n const sliceBuffer = new ImageBuffer(\n volumeSlice.getData({ colorParams: this.getColorParams() }) as ImageBufferData,\n this.getBufferParams({\n filter: this.filter\n }) as ImageBufferParameters\n )\n\n this.bufferList.push(sliceBuffer)\n }\n}\n\nexport default SliceRepresentation\n","/**\n * @file Representation Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, RepresentationRegistry } from '../globals'\n\nimport Viewer from '../viewer/viewer'\nimport Structure from '../structure/structure'\nimport Surface from '../surface/surface'\nimport Volume from '../surface/volume'\nimport Shape from '../geometry/shape'\n\nimport BufferRepresentation from './buffer-representation'\nimport SurfaceRepresentation from './surface-representation'\nimport DotRepresentation from './dot-representation'\nimport SliceRepresentation from './slice-representation'\n\nfunction logReprUnknown (type: string) {\n Log.error(`makeRepresentation: representation type ${type} unknown`)\n}\n\nexport function makeRepresentation (type: string, object: any, viewer: Viewer, params: any) { // TODO\n if (Debug) Log.time('makeRepresentation ' + type)\n\n var ReprClass\n\n if (object instanceof Structure) {\n ReprClass = RepresentationRegistry.get(type)\n\n if (!ReprClass) {\n logReprUnknown(type)\n return\n }\n } else if (object instanceof Surface) {\n if (type === 'surface') {\n ReprClass = SurfaceRepresentation\n } else if (type === 'dot') {\n ReprClass = DotRepresentation\n } else {\n logReprUnknown(type)\n return\n }\n } else if (object instanceof Volume) {\n if (type === 'surface') {\n ReprClass = SurfaceRepresentation\n } else if (type === 'dot') {\n ReprClass = DotRepresentation\n } else if (type === 'slice') {\n ReprClass = SliceRepresentation\n } else {\n logReprUnknown(type)\n return\n }\n } else if (object instanceof Shape) {\n ReprClass = BufferRepresentation\n object = object.getBufferList()\n } else if (type === 'buffer') {\n ReprClass = BufferRepresentation\n } else {\n Log.error('makeRepresentation: object ' + object + ' unknown')\n return\n }\n\n const repr = new ReprClass(object, viewer, params)\n\n if (Debug) Log.timeEnd('makeRepresentation ' + type)\n\n return repr\n}\n","/**\n * @file Element\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { createParams } from '../utils'\nimport { generateUUID } from '../math/math-utils'\nimport Stage from '../stage/stage'\n\nexport const ElementDefaultParameters = {\n name: 'some element',\n status: ''\n}\nexport type ElementParameters = typeof ElementDefaultParameters\n\nexport interface ElementSignals {\n statusChanged: Signal // on status change\n nameChanged: Signal // on name change\n disposed: Signal // on dispose\n}\n\n/**\n * Element base class\n */\nabstract class Element {\n /**\n * Events emitted by the element\n */\n signals: ElementSignals = {\n statusChanged: new Signal(),\n nameChanged: new Signal(),\n disposed: new Signal()\n }\n readonly parameters: ElementParameters\n readonly uuid: string\n\n get defaultParameters() { return ElementDefaultParameters }\n\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {ElementParameters} params - component parameters\n */\n constructor (readonly stage: Stage, params: Partial = {}) {\n this.parameters = createParams(params, this.defaultParameters)\n this.uuid = generateUUID()\n }\n\n abstract get type (): string\n\n get name () { return this.parameters.name }\n\n setStatus (value: string) {\n this.parameters.status = value\n this.signals.statusChanged.dispatch(value)\n\n return this\n }\n\n setName (value: string) {\n this.parameters.name = value\n this.signals.nameChanged.dispatch(value)\n\n return this\n }\n\n dispose () {\n this.signals.disposed.dispatch()\n }\n}\n\nexport default Element\n","/**\n * @file Representation Element\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\nimport { Color } from 'three'\n\nimport Stage from '../stage/stage'\nimport Representation, { RepresentationParameters } from '../representation/representation'\nimport Component from './component'\nimport Element, { ElementDefaultParameters, ElementSignals } from './element'\n\nexport const RepresentationElementDefaultParameters = Object.assign({\n visible: true\n}, ElementDefaultParameters)\nexport type RepresentationElementParameters = typeof RepresentationElementDefaultParameters\n\nexport interface RepresentationElementSignals extends ElementSignals {\n visibilityChanged: Signal // on visibility change\n parametersChanged: Signal // on parameters change\n}\n\n/**\n * Element wrapping a {@link Representation} object\n */\nclass RepresentationElement extends Element {\n signals: RepresentationElementSignals\n parameters: RepresentationElementParameters\n get defaultParameters() { return RepresentationElementDefaultParameters }\n\n repr: Representation\n\n /**\n * Create representation component\n * @param {Stage} stage - stage object the component belongs to\n * @param {Representation} repr - representation object to wrap\n * @param {RepresentationParameters} [params] - component parameters\n * @param {Component} [parent] - parent component\n */\n constructor (stage: Stage, repr: Representation, params: Partial = {}, readonly parent: Component) {\n super(stage, Object.assign({ name: repr.type }, params))\n\n this.signals = Object.assign({\n visibilityChanged: new Signal(),\n parametersChanged: new Signal()\n }, this.signals)\n\n this.setRepresentation(repr)\n }\n\n get visible () { return this.parameters.visible }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'representation' }\n\n getType () {\n return this.repr.type\n }\n\n setRepresentation (repr: Representation) {\n this._disposeRepresentation()\n this.repr = repr\n // this.name = repr.type;\n this.stage.tasks.listen(this.repr.tasks)\n this.updateVisibility()\n }\n\n _disposeRepresentation () {\n if (this.repr) {\n this.stage.tasks.unlisten(this.repr.tasks)\n this.repr.dispose()\n }\n }\n\n dispose () {\n if (this.parent && this.parent.hasRepresentation(this)) {\n this.parent.removeRepresentation(this)\n } else {\n this._disposeRepresentation()\n this.signals.disposed.dispatch()\n }\n }\n\n /**\n * Set the visibility of the component, takes parent visibility into account\n * @param {Boolean} value - visibility flag\n * @return {RepresentationElement} this object\n */\n setVisibility (value: boolean) {\n this.parameters.visible = value\n this.updateVisibility()\n this.signals.visibilityChanged.dispatch(this.parameters.visible)\n\n return this\n }\n\n getVisibility () {\n if (this.parent) {\n return this.parent.parameters.visible && this.parameters.visible\n } else {\n return this.parameters.visible\n }\n }\n\n /**\n * Toggle visibility of the component, takes parent visibility into account\n * @return {RepresentationElement} this object\n */\n toggleVisibility () {\n return this.setVisibility(!this.parameters.visible)\n }\n\n updateVisibility () {\n this.repr.setVisibility(this.getVisibility())\n }\n\n /**\n * Set selection\n * @param {Object} what - flags indicating what attributes to update\n * @param {Boolean} what.position - update position attribute\n * @param {Boolean} what.color - update color attribute\n * @param {Boolean} what.radius - update radius attribute\n * @return {RepresentationElement} this object\n */\n update (what: any) { // TODO\n (this.repr as any).update(what) // TODO\n\n return this\n }\n\n build (params?: any) { // TODO\n this.repr.build(params)\n\n return this\n }\n\n /**\n * Set selection\n * @param {String} string - selection string\n * @return {RepresentationElement} this object\n */\n setSelection (string: string) {\n const repr: any = this.repr // TODO\n\n if (repr.setSelection) {\n repr.setSelection(string)\n }\n\n return this\n }\n\n /**\n * Set representation parameters\n * @param {RepresentationParameters} params - parameter object\n * @return {RepresentationElement} this object\n */\n setParameters (params: any) { // TODO\n this.repr.setParameters(params)\n this.signals.parametersChanged.dispatch(\n this.repr.getParameters()\n )\n\n return this\n }\n\n /**\n * Get representation parameters\n * @return {RepresentationParameters} parameter object\n */\n getParameters (): Partial {\n return this.repr.getParameters()\n }\n\n /**\n * Set color\n * @param {String|Color|Hex} value - color value\n * @return {RepresentationElement} this object\n */\n setColor (value: string|number|Color) {\n this.repr.setColor(value)\n\n return this\n }\n}\n\nexport default RepresentationElement\n","\n/**\n * @file Component\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Quaternion, Matrix4, Euler, Box3 } from 'three'\nimport { Signal } from 'signals'\n\nimport { defaults, createParams } from '../utils'\nimport { generateUUID } from '../math/math-utils'\nimport Annotation, { AnnotationParams } from '../component/annotation'\nimport ComponentControls from '../controls/component-controls'\nimport { makeRepresentation } from '../representation/representation-utils'\nimport RepresentationElement from './representation-element'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\n\nconst _m = new Matrix4()\nconst _v = new Vector3()\n\nexport const ComponentDefaultParameters = {\n name: '',\n status: '',\n visible: true\n}\nexport type ComponentParameters = typeof ComponentDefaultParameters\n\n\nexport interface ComponentSignals {\n representationAdded: Signal // when a representation is added\n representationRemoved: Signal // when a representation is removed\n visibilityChanged: Signal // on visibility change\n matrixChanged: Signal // on matrix change\n statusChanged: Signal // on status change\n nameChanged: Signal // on name change\n disposed: Signal // on dispose\n}\n\n/**\n * Base class for components\n */\nabstract class Component {\n /**\n * Events emitted by the component\n */\n readonly signals: ComponentSignals = {\n representationAdded: new Signal(),\n representationRemoved: new Signal(),\n visibilityChanged: new Signal(),\n matrixChanged: new Signal(),\n statusChanged: new Signal(),\n nameChanged: new Signal(),\n disposed: new Signal()\n }\n\n readonly parameters: ComponentParameters\n get defaultParameters () { return ComponentDefaultParameters }\n\n readonly uuid: string\n readonly viewer: Viewer\n\n reprList: RepresentationElement[] = []\n annotationList: Annotation[] = []\n\n matrix = new Matrix4()\n position = new Vector3()\n quaternion = new Quaternion()\n scale = new Vector3(1, 1, 1)\n transform = new Matrix4()\n\n controls: ComponentControls\n\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {ComponentParameters} params - parameter object\n */\n constructor (readonly stage: Stage, readonly object: any, params: Partial = {}) {\n this.parameters = createParams(params, this.defaultParameters)\n this.uuid = generateUUID()\n this.viewer = stage.viewer\n\n this.controls = new ComponentControls(this)\n }\n\n abstract get type (): string\n\n get name () { return this.parameters.name }\n get status () { return this.parameters.status }\n get visible () { return this.parameters.visible }\n\n /**\n * Set position transform\n *\n * @example\n * // translate by 25 angstrom along x axis\n * component.setPosition([ 25, 0, 0 ]);\n *\n * @param {Vector3|Array} p - the coordinates\n * @return {Component} this object\n */\n setPosition (p: [number, number, number]|Vector3) {\n if (Array.isArray(p)) {\n this.position.fromArray(p)\n } else {\n this.position.copy(p)\n }\n this.updateMatrix()\n\n return this\n }\n\n /**\n * Set local rotation transform\n * (for global rotation use setTransform)\n *\n * @example\n * // rotate by 2 degree radians on x axis\n * component.setRotation( [ 2, 0, 0 ] );\n *\n * @param {Quaternion|Euler|Array} r - the rotation\n * @return {Component} this object\n */\n setRotation (r: [number, number, number]|Euler|Quaternion) {\n if (Array.isArray(r)) {\n if (r.length === 3) {\n const e = new Euler().fromArray(r)\n this.quaternion.setFromEuler(e)\n } else {\n this.quaternion.fromArray(r)\n }\n } else if (r instanceof Euler) {\n this.quaternion.setFromEuler(r)\n } else {\n this.quaternion.copy(r)\n }\n this.updateMatrix()\n\n return this\n }\n\n /**\n * Set scale transform\n *\n * @example\n * // scale by factor of two\n * component.setScale( 2 );\n *\n * @param {Number} s - the scale\n * @return {Component} this object\n */\n setScale (s: number) {\n this.scale.set(s, s, s)\n this.updateMatrix()\n\n return this\n }\n\n /**\n * Set general transform. Is applied before and in addition\n * to the position, rotation and scale transformations\n *\n * @example\n * component.setTransform( matrix );\n *\n * @param {Matrix4} m - the matrix\n * @return {Component} this object\n */\n setTransform (m: Matrix4) {\n this.transform.copy(m)\n this.updateMatrix()\n\n return this\n }\n\n updateMatrix () {\n const c = this.getCenterUntransformed(_v)\n this.matrix.makeTranslation(-c.x, -c.y, -c.z)\n\n _m.makeRotationFromQuaternion(this.quaternion)\n this.matrix.premultiply(_m)\n\n _m.makeScale(this.scale.x, this.scale.y, this.scale.z)\n this.matrix.premultiply(_m)\n\n const p = this.position\n _m.makeTranslation(p.x + c.x, p.y + c.y, p.z + c.z)\n this.matrix.premultiply(_m)\n\n this.matrix.premultiply(this.transform)\n\n this.updateRepresentationMatrices()\n\n this.stage.viewer.updateBoundingBox()\n\n this.signals.matrixChanged.dispatch(this.matrix)\n }\n\n /**\n * Propogates our matrix to each representation\n */\n updateRepresentationMatrices () {\n this.reprList.forEach(repr => {\n repr.setParameters({ matrix: this.matrix })\n })\n }\n\n /**\n * Add an anotation object\n * @param {Vector3} position - the 3d position\n * @param {String|Element} content - the HTML content\n * @param {Object} [params] - parameters\n * @param {Integer} params.offsetX - 2d offset in x direction\n * @param {Integer} params.offsetY - 2d offset in y direction\n * @return {Annotation} the added annotation object\n */\n addAnnotation (position: Vector3, content: string|HTMLElement, params: AnnotationParams) {\n const annotation = new Annotation(this, position, content, params)\n this.annotationList.push(annotation)\n\n return annotation\n }\n\n /**\n * Iterator over each annotation and executing the callback\n * @param {Function} callback - function to execute\n * @return {undefined}\n */\n eachAnnotation (callback: (a: Annotation) => void) {\n this.annotationList.slice().forEach(callback)\n }\n\n /**\n * Remove the give annotation from the component\n * @param {Annotation} annotation - the annotation to remove\n * @return {undefined}\n */\n removeAnnotation (annotation: Annotation) {\n const idx = this.annotationList.indexOf(annotation)\n if (idx !== -1) {\n this.annotationList.splice(idx, 1)\n annotation.dispose()\n }\n }\n\n /**\n * Remove all annotations from the component\n * @return {undefined}\n */\n removeAllAnnotations () {\n this.eachAnnotation(annotation => annotation.dispose())\n this.annotationList.length = 0\n }\n\n /**\n * Add a new representation to the component\n * @param {String} type - the name of the representation\n * @param {Object} object - the object on which the representation should be based\n * @param {RepresentationParameters} [params] - representation parameters\n * @return {RepresentationElement} the created representation wrapped into\n * a representation element object\n */\n protected _addRepresentation (type: string, object: any, params: any, hidden = false) { // TODO\n const p = params || {}\n const sp = this.stage.getParameters() as any // TODO\n p.matrix = this.matrix.clone()\n p.quality = p.quality || sp.quality\n p.disableImpostor = defaults(p.disableImpostor, !sp.impostor)\n p.useWorker = defaults(p.useWorker, sp.workerDefault)\n p.visible = defaults(p.visible, true)\n\n const p2 = Object.assign({}, p, { visible: this.parameters.visible && p.visible })\n const repr = makeRepresentation(type, object, this.viewer, p2)\n const reprElem = new RepresentationElement(this.stage, repr, p, this)\n\n if (!hidden) {\n this.reprList.push(reprElem)\n this.signals.representationAdded.dispatch(reprElem)\n }\n return reprElem\n }\n\n abstract addRepresentation (type: any, params: any): any\n\n addBufferRepresentation (buffer: any, params: any) { // TODO\n return this._addRepresentation.call(this, 'buffer', buffer, params)\n }\n\n hasRepresentation (repr: RepresentationElement) {\n return this.reprList.indexOf(repr) !== -1\n }\n\n /**\n * Iterator over each representation and executing the callback\n * @param {Function} callback - function to execute\n * @return {undefined}\n */\n eachRepresentation (callback: (repr: RepresentationElement) => void) {\n this.reprList.slice().forEach(callback)\n }\n\n /**\n * Removes a representation component\n * @param {RepresentationElement} repr - the representation element\n * @return {undefined}\n */\n removeRepresentation (repr: RepresentationElement) {\n const idx = this.reprList.indexOf(repr)\n if (idx !== -1) {\n this.reprList.splice(idx, 1)\n repr.dispose()\n this.signals.representationRemoved.dispatch(repr)\n }\n }\n\n updateRepresentations (what: any) { // TODO\n this.reprList.forEach(repr => repr.update(what))\n this.stage.viewer.requestRender()\n }\n\n /**\n * Removes all representation components\n * @return {undefined}\n */\n removeAllRepresentations () {\n this.eachRepresentation(repr => repr.dispose())\n }\n\n dispose () {\n this.removeAllAnnotations()\n this.removeAllRepresentations()\n\n this.reprList.length = 0\n\n this.signals.disposed.dispatch()\n }\n\n /**\n * Set the visibility of the component, including added representations\n * @param {Boolean} value - visibility flag\n * @return {Component} this object\n */\n setVisibility (value: boolean) {\n this.parameters.visible = value\n\n this.eachRepresentation((repr: RepresentationElement) => repr.updateVisibility())\n this.eachAnnotation((annotation: Annotation) => annotation.updateVisibility())\n\n this.signals.visibilityChanged.dispatch(value)\n\n return this\n }\n\n setStatus (value: string) {\n this.parameters.status = value\n this.signals.statusChanged.dispatch(value)\n\n return this\n }\n\n setName (value: string) {\n this.parameters.name = value\n this.signals.nameChanged.dispatch(value)\n\n return this\n }\n\n /**\n * @return {Box3} the component's bounding box\n */\n getBox (...args: any[]) {\n return this.getBoxUntransformed(...args)\n .clone().applyMatrix4(this.matrix)\n }\n\n /**\n * @return {Vector3} the component's center position\n */\n getCenter (...args: any[]) {\n return this.getCenterUntransformed(...args)\n .clone().applyMatrix4(this.matrix)\n }\n\n getZoom (...args: any[]) {\n return this.stage.getZoomForBox(this.getBox(...args))\n }\n\n /**\n * @abstract\n * @return {Box3} the untransformed component's bounding box\n */\n getBoxUntransformed (...args: any[]): Box3 {\n return new Box3()\n }\n\n getCenterUntransformed (...args: any[]) {\n return this.getBoxUntransformed().getCenter(new Vector3())\n }\n\n /**\n * Automatically center and zoom the component\n * @param {Integer} [duration] - duration of the animation, defaults to 0\n * @return {undefined}\n */\n autoView (duration?: number) {\n this.stage.animationControls.zoomMove(\n this.getCenter(),\n this.getZoom(),\n defaults(duration, 0)\n )\n }\n}\n\nexport default Component\n","/**\n * @file Collection\n * @author Alexander Rose \n * @private\n */\n\nimport Component from './component'\nimport Element from './element'\n\nclass Collection {\n constructor (readonly list: T[] = []) {\n // remove elements from list when they get disposed\n const n = list.length\n\n for (let i = 0; i < n; ++i) {\n const elm = list[ i ]\n elm.signals.disposed.add(this._remove, this)\n }\n }\n\n _remove (elm: T) {\n const idx = this.list.indexOf(elm)\n\n if (idx !== -1) {\n this.list.splice(idx, 1)\n }\n }\n\n get first () {\n return this.list.length > 0 ? this.list[0] : undefined\n }\n\n forEach (fn: (x: T) => any) {\n this.list.forEach(fn)\n\n return this\n }\n\n dispose () {\n return this.forEach((elm) => elm.dispose())\n }\n}\n\nexport default Collection\n","/**\n * @file Component Collection\n * @author Alexander Rose \n * @private\n */\n\nimport RepresentationElement from './representation-element'\nimport Collection from './collection'\nimport { GenericColor } from '../types'\n\nclass RepresentationCollection extends Collection {\n setParameters (params: any) {\n return this.forEach((repr) => repr.setParameters(params))\n }\n\n setVisibility (value: boolean) {\n return this.forEach((repr) => repr.setVisibility(value))\n }\n\n setSelection (string: string) {\n return this.forEach((repr) => repr.setSelection(string))\n }\n\n setColor (color: GenericColor) {\n return this.forEach((repr) => repr.setColor(color))\n }\n\n update (what: any) {\n return this.forEach((repr) => repr.update(what))\n }\n\n build (params?: any) {\n return this.forEach((repr) => repr.build(params))\n }\n\n dispose (params?: any) {\n return this.forEach((repr) => repr.dispose())\n }\n}\n\nexport default RepresentationCollection\n","/**\n * @file Trajectory Component\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport Element, { ElementSignals, ElementDefaultParameters } from './element'\nimport Stage from '../stage/stage'\nimport Trajectory, { TrajectoryParameters } from '../trajectory/trajectory'\nimport TrajectoryPlayer, {\n TrajectoryPlayerDirection, TrajectoryPlayerMode, TrajectoryPlayerInterpolateType\n} from '../trajectory/trajectory-player'\n\n/**\n * Trajectory component parameter object.\n * @typedef {Object} TrajectoryComponentParameters - component parameters\n *\n * @property {String} name - component name\n * @property {Integer} initialFrame - initial frame the trajectory is set to\n * @property {Integer} defaultStep - default step size to be used by trajectory players\n * @property {Integer} defaultTimeout - default timeout to be used by trajectory players\n * @property {String} defaultInterpolateType - one of \"\" (empty string), \"linear\" or \"spline\"\n * @property {Integer} defaultInterpolateStep - window size used for interpolation\n * @property {String} defaultMode - either \"loop\" or \"once\"\n * @property {String} defaultDirection - either \"forward\" or \"backward\"\n */\n\nexport const TrajectoryElementDefaultParameters = Object.assign({\n defaultStep: 1,\n defaultTimeout: 50,\n defaultInterpolateType: '' as TrajectoryPlayerInterpolateType,\n defaultInterpolateStep: 5,\n defaultMode: 'loop' as TrajectoryPlayerMode,\n defaultDirection: 'forward' as TrajectoryPlayerDirection,\n initialFrame: 0\n}, ElementDefaultParameters)\nexport type TrajectoryElementParameters = typeof TrajectoryElementDefaultParameters\n\nexport interface TrajectoryElementSignals extends ElementSignals {\n frameChanged: Signal // on frame change\n playerChanged: Signal // on player change\n countChanged: Signal // when frame count is available\n parametersChanged: Signal // on parameters change\n}\n\n/**\n * Component wrapping a {@link Trajectory} object\n */\nclass TrajectoryElement extends Element {\n signals: TrajectoryElementSignals\n parameters: TrajectoryElementParameters\n get defaultParameters () { return TrajectoryElementDefaultParameters }\n\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {Trajectory} trajectory - the trajectory object\n * @param {TrajectoryComponentParameters} params - component parameters\n * @param {StructureComponent} parent - the parent structure\n */\n constructor (stage: Stage, readonly trajectory: Trajectory, params: Partial = {}) {\n super(stage, Object.assign({ name: trajectory.name }, params))\n\n this.signals = Object.assign(this.signals, {\n frameChanged: new Signal(),\n playerChanged: new Signal(),\n countChanged: new Signal(),\n parametersChanged: new Signal()\n })\n\n // signals\n\n trajectory.signals.frameChanged.add((i: number) => {\n this.signals.frameChanged.dispatch(i)\n })\n\n trajectory.signals.playerChanged.add((player: TrajectoryPlayer) => {\n this.signals.playerChanged.dispatch(player)\n })\n\n trajectory.signals.countChanged.add((n: number) => {\n this.signals.countChanged.dispatch(n)\n })\n\n //\n\n if (params.initialFrame !== undefined) {\n this.setFrame(params.initialFrame)\n }\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'trajectory' }\n\n /**\n * Set the frame of the trajectory\n * @param {Integer} i - frame number\n * @return {undefined}\n */\n setFrame (i: number) {\n this.trajectory.setFrame(i)\n }\n\n /**\n * Set trajectory parameters\n * @param {TrajectoryParameters} params - trajectory parameters\n * @return {undefined}\n */\n setParameters (params: Partial = {}) {\n this.trajectory.setParameters(params)\n this.signals.parametersChanged.dispatch(params)\n }\n\n dispose () {\n this.trajectory.dispose()\n super.dispose()\n }\n}\n\nexport default TrajectoryElement\n","/**\n * @file Frames\n * @author Alexander Rose \n * @private\n */\n\nexport default class Frames {\n coordinates = []\n boxes = []\n times = []\n\n timeOffset = 0\n deltaTime = 1\n\n constructor (readonly name: string, readonly path: string) {}\n\n get type () { return 'Frames' }\n}\n","/**\n * @file Superposition\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\nimport { Debug, Log } from '../globals'\nimport {\n Matrix, svd, meanRows, subRows, transpose,\n multiplyABt, invert3x3, multiply3x3, mat3x3determinant, multiply\n} from '../math/matrix-utils'\nimport Structure from '../structure/structure'\n\nclass Superposition {\n coords1t: Matrix\n coords2t: Matrix\n\n transformationMatrix: Matrix4\n\n mean1: number[]\n mean2: number[]\n\n A = new Matrix(3, 3)\n W = new Matrix(1, 3)\n U = new Matrix(3, 3)\n V = new Matrix(3, 3)\n VH = new Matrix(3, 3)\n R = new Matrix(3, 3)\n\n private tmp = new Matrix(3, 3)\n private c = new Matrix(3, 3)\n\n constructor (atoms1: Structure|Float32Array, atoms2: Structure|Float32Array) {\n // allocate & init data structures\n\n let n1\n if (atoms1 instanceof Structure) {\n n1 = atoms1.atomCount\n } else if (atoms1 instanceof Float32Array) {\n n1 = atoms1.length / 3\n } else {\n return\n }\n\n let n2\n if (atoms2 instanceof Structure) {\n n2 = atoms2.atomCount\n } else if (atoms2 instanceof Float32Array) {\n n2 = atoms2.length / 3\n } else {\n return\n }\n\n const n = Math.min(n1, n2)\n\n const coords1 = new Matrix(3, n)\n const coords2 = new Matrix(3, n)\n\n this.coords1t = new Matrix(n, 3)\n this.coords2t = new Matrix(n, 3)\n\n this.transformationMatrix = new Matrix4()\n\n this.c.data.set([ 1, 0, 0, 0, 1, 0, 0, 0, -1 ])\n\n // prep coords\n\n this.prepCoords(atoms1, coords1, n, false)\n this.prepCoords(atoms2, coords2, n, false)\n\n // superpose\n\n this._superpose(coords1, coords2)\n }\n\n _superpose (coords1: Matrix, coords2: Matrix) {\n this.mean1 = meanRows(coords1)\n this.mean2 = meanRows(coords2)\n\n subRows(coords1, this.mean1)\n subRows(coords2, this.mean2)\n\n transpose(this.coords1t, coords1)\n transpose(this.coords2t, coords2)\n\n multiplyABt(this.A, this.coords2t, this.coords1t)\n\n svd(this.A, this.W, this.U, this.V)\n\n invert3x3(this.V, this.VH)\n multiply3x3(this.R, this.U, this.VH)\n\n if (mat3x3determinant(this.R) < 0.0) {\n if (Debug) Log.log('R not a right handed system')\n\n multiply3x3(this.tmp, this.c, this.VH)\n multiply3x3(this.R, this.U, this.tmp)\n }\n\n //get the transformation matrix\n\n const transformMat_ = new Matrix(4,4)\n const tmp_1 = new Matrix(4,4)\n const tmp_2 = new Matrix(4,4)\n\n const sub = new Matrix(4,4)\n const mult = new Matrix(4,4)\n const add = new Matrix(4,4)\n\n const R = this.R.data\n const M1 = this.mean1\n const M2 = this.mean2\n\n sub.data.set([ 1, 0, 0, -M1[0],\n 0, 1, 0, -M1[1],\n 0, 0, 1, -M1[2],\n 0, 0, 0, 1 ])\n\n mult.data.set([ R[0], R[1], R[2], 0,\n R[3], R[4], R[5], 0,\n R[6], R[7], R[8], 0,\n 0, 0, 0, 1 ])\n\n add.data.set([ 1, 0, 0, M2[0],\n 0, 1, 0, M2[1],\n 0, 0, 1, M2[2],\n 0, 0, 0, 1 ])\n\n transpose(tmp_1,sub)\n multiplyABt(transformMat_,mult,tmp_1)\n transpose(tmp_2,transformMat_)\n multiplyABt(tmp_1,add,tmp_2)\n\n transpose(transformMat_,tmp_1)\n this.transformationMatrix.elements = transformMat_.data as unknown as number[]\n\n }\n\n prepCoords (atoms: Structure|Float32Array, coords: Matrix, n: number, is4X4: boolean) {\n let i = 0\n const cd = coords.data\n\n let c = 3\n let d = n * 3\n\n if (is4X4) {\n d = n * 4\n c = 4\n }\n if (atoms instanceof Structure) {\n atoms.eachAtom(function (a) {\n if (i < d) {\n cd[ i + 0 ] = a.x\n cd[ i + 1 ] = a.y\n cd[ i + 2 ] = a.z\n if (is4X4) cd[ i + 3 ] = 1\n\n i += c\n }\n })\n } else if (atoms instanceof Float32Array) {\n for (; i < d; i += c){\n if (i < d) {\n cd[ i ] = atoms[ i ]\n cd[ i + 1 ] = atoms[ i + 1 ]\n cd[ i + 2 ] = atoms[ i + 2 ]\n if (is4X4) cd[ i + 3 ] = 1\n }\n }\n } else {\n Log.warn('prepCoords: input type unknown')\n }\n }\n\n transform (atoms: Structure|Float32Array) {\n // allocate data structures\n\n let n\n if (atoms instanceof Structure) {\n n = atoms.atomCount\n } else if (atoms instanceof Float32Array) {\n n = atoms.length / 3\n } else {\n return\n }\n\n const coords = new Matrix(4, n)\n const tCoords = new Matrix(n,4)\n\n // prep coords\n\n this.prepCoords(atoms, coords, n, true)\n\n // check for transformation matrix correctness\n\n const transform = this.transformationMatrix\n const det = transform.determinant()\n if (!det){\n return det\n }\n\n // do transform\n\n const mult = new Matrix(4,4)\n mult.data = transform.elements as unknown as Float32Array\n multiply(tCoords,coords,mult)\n\n let i = 0\n const cd = tCoords.data\n if (atoms instanceof Structure) {\n atoms.eachAtom(function (a) {\n a.x = cd[ i ]\n a.y = cd[ i + 1 ]\n a.z = cd[ i + 2 ]\n i += 4\n })\n\n //update transformation matrices for each assembly\n\n const invertTrasform = new Matrix4()\n invertTrasform.getInverse(transform)\n\n const biomolDict = atoms.biomolDict\n\n for (let key in biomolDict) {\n\n if (biomolDict.hasOwnProperty(key)) {\n let assembly = biomolDict[key]\n\n assembly.partList.forEach(function(part){\n\n part.matrixList.forEach(function(mat){\n\n mat.premultiply(transform)\n mat.multiply(invertTrasform)\n\n })\n })\n }\n }\n } else if (atoms instanceof Float32Array) {\n\n const n4 = n * 4\n for (; i < n4; i += 4){\n\n atoms[ i ] = cd[ i ]\n atoms[ i + 1 ] = cd[ i + 1 ]\n atoms[ i + 2 ] = cd[ i + 2 ]\n\n }\n } else {\n Log.warn('transform: input type unknown')\n }\n\n return this.transformationMatrix\n }\n}\nexport default Superposition\n","/**\n * @file Trajectory Player\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { defaults, createParams, updateParams } from '../utils'\nimport Trajectory from './trajectory'\n\nexport type TrajectoryPlayerInterpolateType = ''|'linear'|'spline'\nexport type TrajectoryPlayerMode = 'loop'|'once'\nexport type TrajectoryPlayerDirection = 'forward'|'backward'|'bounce'\n\nexport const TrajectoryPlayerDefaultParameters = {\n step: 1, // how many frames to advance when playing\n timeout: 50, // how many milliseconds to wait between playing frames\n start: 0, // first frame to play\n end: 0, // last frame to play\n interpolateType: '' as TrajectoryPlayerInterpolateType,\n interpolateStep: 5, // window size used for interpolation\n mode: 'loop' as TrajectoryPlayerMode,\n direction: 'forward' as TrajectoryPlayerDirection\n}\nexport type TrajectoryPlayerParameters = typeof TrajectoryPlayerDefaultParameters\n\nexport interface TrajectoryPlayerSignals {\n startedRunning: Signal\n haltedRunning: Signal\n}\n\n/**\n * Trajectory player for animating coordinate frames\n * @example\n * var player = new TrajectoryPlayer(trajectory, {step: 1, timeout: 50});\n * player.play();\n */\nclass TrajectoryPlayer {\n signals: TrajectoryPlayerSignals = {\n startedRunning: new Signal(),\n haltedRunning: new Signal()\n }\n\n parameters: TrajectoryPlayerParameters\n traj: Trajectory\n\n private _run = false\n private _previousTime = 0\n private _currentTime = 0\n private _currentStep = 1\n private _currentFrame: number|[number, number, number, number]\n private _direction: TrajectoryPlayerDirection\n\n /**\n * make trajectory player\n * @param {Trajectory} traj - the trajectory\n * @param {TrajectoryPlayerParameters} [params] - parameter object\n */\n constructor (traj: Trajectory, params: Partial = {}) {\n traj.signals.playerChanged.add((player: TrajectoryPlayer) => {\n if (player !== this) {\n this.pause()\n }\n }, this)\n\n const n = defaults(traj.frameCount, 1)\n\n this.traj = traj\n this.parameters = createParams(params, TrajectoryPlayerDefaultParameters)\n this.parameters.end = Math.min(defaults(params.end, n - 1), n - 1)\n this.parameters.step = defaults(params.step, Math.ceil((n + 1) / 100))\n\n this._currentFrame = this.parameters.start\n this._direction = this.parameters.direction === 'bounce' ? 'forward' : this.parameters.direction\n\n traj.signals.countChanged.add((n: number) => {\n this.parameters.end = Math.min(defaults(this.parameters.end, n - 1), n - 1)\n }, this)\n\n this._animate = this._animate.bind(this)\n }\n\n get isRunning () { return this._run }\n\n /**\n * set player parameters\n * @param {TrajectoryPlayerParameters} [params] - parameter object\n */\n setParameters (params: Partial = {}) {\n updateParams(this.parameters, params)\n\n if (params.direction !== undefined && this.parameters.direction !== 'bounce') {\n this._direction = this.parameters.direction\n }\n }\n\n _animate () {\n if (!this._run) return\n\n this._currentTime = window.performance.now()\n const dt = this._currentTime - this._previousTime\n const step = this.parameters.interpolateType ? this.parameters.interpolateStep : 1\n const timeout = this.parameters.timeout / step\n const traj = this.traj\n\n if (traj && traj.frameCount && !traj.inProgress && dt >= timeout) {\n if (this.parameters.interpolateType) {\n if (this._currentStep > this.parameters.interpolateStep) {\n this._currentStep = 1\n }\n if (this._currentStep === 1) {\n this._currentFrame = this._nextInterpolated()\n }\n if (traj.hasFrame(this._currentFrame)) {\n this._currentStep += 1\n const t = this._currentStep / (this.parameters.interpolateStep + 1)\n const [i, ip, ipp, ippp] = this._currentFrame as [number, number, number, number]\n traj.setFrameInterpolated(\n i, ip, ipp, ippp, t, this.parameters.interpolateType\n )\n this._previousTime = this._currentTime\n } else {\n traj.loadFrame(this._currentFrame)\n }\n } else {\n const i = this._next()\n if (traj.hasFrame(i)) {\n traj.setFrame(i)\n this._previousTime = this._currentTime\n } else {\n traj.loadFrame(i)\n }\n }\n }\n\n window.requestAnimationFrame(this._animate)\n }\n\n _next () {\n const p = this.parameters\n let i\n\n if (this._direction === 'forward') {\n i = this.traj.currentFrame + p.step\n } else {\n i = this.traj.currentFrame - p.step\n }\n\n if (i > p.end || i < p.start) {\n if (p.direction === 'bounce') {\n if (this._direction === 'forward') {\n this._direction = 'backward'\n } else {\n this._direction = 'forward'\n }\n }\n\n if (p.mode === 'once') {\n this.pause()\n\n if (p.direction === 'forward') {\n i = p.end\n } else if (p.direction === 'backward') {\n i = p.start\n } else {\n if (this._direction === 'forward') {\n i = p.start\n } else {\n i = p.end\n }\n }\n } else {\n if (this._direction === 'forward') {\n i = p.start\n if (p.interpolateType) {\n i = Math.min(p.end, i + p.step)\n }\n } else {\n i = p.end\n if (p.interpolateType) {\n i = Math.max(p.start, i - p.step)\n }\n }\n }\n }\n\n return i\n }\n\n _nextInterpolated () {\n const p = this.parameters\n const i = this._next()\n let ip, ipp, ippp\n\n if (this._direction === 'forward') {\n ip = Math.max(p.start, i - p.step)\n ipp = Math.max(p.start, i - 2 * p.step)\n ippp = Math.max(p.start, i - 3 * p.step)\n } else {\n ip = Math.min(p.end, i + p.step)\n ipp = Math.min(p.end, i + 2 * p.step)\n ippp = Math.min(p.end, i + 3 * p.step)\n }\n\n return [i, ip, ipp, ippp] as [number, number, number, number]\n }\n\n /**\n * toggle between playing and pausing the animation\n * @return {undefined}\n */\n toggle () {\n if (this._run) {\n this.pause()\n } else {\n this.play()\n }\n }\n\n /**\n * start the animation\n * @return {undefined}\n */\n play () {\n if (!this._run) {\n if (this.traj.player !== this) {\n this.traj.setPlayer(this)\n }\n this._currentStep = 1\n\n const p = this.parameters\n const frame = this.traj.currentFrame\n\n // snap to the grid implied by this.step division and multiplication\n // thus minimizing cache misses\n let i = Math.ceil(frame / p.step) * p.step\n // wrap when restarting from the limit (i.e. end or start)\n if (p.direction === 'forward' && frame >= p.end) {\n i = p.start\n } else if (p.direction === 'backward' && frame <= p.start) {\n i = p.end\n }\n\n this.traj.setFrame(i)\n\n this._run = true\n this._animate()\n this.signals.startedRunning.dispatch()\n }\n }\n\n /**\n * pause the animation\n * @return {undefined}\n */\n pause () {\n this._run = false\n this.signals.haltedRunning.dispatch()\n }\n\n /**\n * stop the animation (pause and go to start-frame)\n * @return {undefined}\n */\n stop () {\n this.pause()\n this.traj.setFrame(this.parameters.start)\n }\n}\n\nexport default TrajectoryPlayer\n","/**\n * @file Trajectory\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { Log } from '../globals'\nimport { defaults } from '../utils'\nimport { NumberArray } from '../types'\nimport { circularMean, arrayMean } from '../math/array-utils'\nimport { lerp, spline } from '../math/math-utils'\nimport Selection from '../selection/selection'\nimport Superposition from '../align/superposition'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\nimport TrajectoryPlayer, { TrajectoryPlayerInterpolateType } from './trajectory-player'\n\n\nfunction centerPbc (coords: NumberArray, mean: number[], box: ArrayLike) {\n if (box[ 0 ] === 0 || box[ 8 ] === 0 || box[ 4 ] === 0) {\n return\n }\n\n const n = coords.length\n\n const bx = box[ 0 ]\n const by = box[ 1 ]\n const bz = box[ 2 ]\n const mx = mean[ 0 ]\n const my = mean[ 1 ]\n const mz = mean[ 2 ]\n\n const fx = -mx + bx + bx / 2\n const fy = -my + by + by / 2\n const fz = -mz + bz + bz / 2\n\n for (let i = 0; i < n; i += 3) {\n coords[ i + 0 ] = (coords[ i + 0 ] + fx) % bx\n coords[ i + 1 ] = (coords[ i + 1 ] + fy) % by\n coords[ i + 2 ] = (coords[ i + 2 ] + fz) % bz\n }\n}\n\nfunction removePbc (x: NumberArray, box: ArrayLike) {\n if (box[ 0 ] === 0 || box[ 8 ] === 0 || box[ 4 ] === 0) {\n return\n }\n\n // ported from GROMACS src/gmxlib/rmpbc.c:rm_gropbc()\n // in-place\n\n const n = x.length\n\n for (let i = 3; i < n; i += 3) {\n for (let j = 0; j < 3; ++j) {\n const dist = x[ i + j ] - x[ i - 3 + j ]\n\n if (Math.abs(dist) > 0.9 * box[ j * 3 + j ]) {\n if (dist > 0) {\n for (let d = 0; d < 3; ++d) {\n x[ i + d ] -= box[ j * 3 + d ]\n }\n } else {\n for (let d = 0; d < 3; ++d) {\n x[ i + d ] += box[ j * 3 + d ]\n }\n }\n }\n }\n }\n\n return x\n}\n\nfunction removePeriodicity (x: NumberArray, box: ArrayLike, mean: number[]) {\n if (box[ 0 ] === 0 || box[ 8 ] === 0 || box[ 4 ] === 0) {\n return\n }\n\n const n = x.length\n for (let i = 3; i < n; i += 3) {\n for (let j = 0; j < 3; ++j) {\n const f = (x[ i + j ] - mean[ j ]) / box[ j * 3 + j ]\n if (Math.abs(f) > 0.5) {\n x[ i + j ] -= box[ j * 3 + j ] * Math.round(f)\n }\n }\n }\n\n return x\n}\n\nfunction circularMean3 (indices: NumberArray, coords: NumberArray, box: ArrayLike) {\n return [\n circularMean(coords, box[ 0 ], 3, 0, indices),\n circularMean(coords, box[ 1 ], 3, 1, indices),\n circularMean(coords, box[ 2 ], 3, 2, indices)\n ]\n}\n\nfunction arrayMean3 (coords: NumberArray) {\n return [\n arrayMean(coords, 3, 0),\n arrayMean(coords, 3, 1),\n arrayMean(coords, 3, 2)\n ]\n}\n\nfunction interpolateSpline (c: NumberArray, cp: NumberArray, cpp: NumberArray, cppp: NumberArray, t: number) {\n const m = c.length\n const coords = new Float32Array(m)\n\n for (let j0 = 0; j0 < m; j0 += 3) {\n const j1 = j0 + 1\n const j2 = j0 + 2\n coords[ j0 ] = spline(cppp[ j0 ], cpp[ j0 ], cp[ j0 ], c[ j0 ], t, 1)\n coords[ j1 ] = spline(cppp[ j1 ], cpp[ j1 ], cp[ j1 ], c[ j1 ], t, 1)\n coords[ j2 ] = spline(cppp[ j2 ], cpp[ j2 ], cp[ j2 ], c[ j2 ], t, 1)\n }\n\n return coords\n}\n\nfunction interpolateLerp (c: NumberArray, cp: NumberArray, t: number) {\n const m = c.length\n const coords = new Float32Array(m)\n\n for (let j0 = 0; j0 < m; j0 += 3) {\n const j1 = j0 + 1\n const j2 = j0 + 2\n coords[ j0 ] = lerp(cp[ j0 ], c[ j0 ], t)\n coords[ j1 ] = lerp(cp[ j1 ], c[ j1 ], t)\n coords[ j2 ] = lerp(cp[ j2 ], c[ j2 ], t)\n }\n\n return coords\n}\n\n/**\n * Trajectory parameter object.\n * @typedef {Object} TrajectoryParameters - parameters\n *\n * @property {Number} deltaTime - timestep between frames in picoseconds\n * @property {Number} timeOffset - starting time of frames in picoseconds\n * @property {String} sele - to restrict atoms used for superposition\n * @property {Boolean} centerPbc - center on initial frame\n * @property {Boolean} removePeriodicity - move atoms into the origin box\n * @property {Boolean} remo - try fixing periodic boundary discontinuities\n * @property {Boolean} superpose - superpose on initial frame\n */\n\n/**\n * @example\n * trajectory.signals.frameChanged.add( function(i){ ... } );\n *\n * @typedef {Object} TrajectorySignals\n * @property {Signal} countChanged - when the frame count is changed\n * @property {Signal} frameChanged - when the set frame is changed\n * @property {Signal} playerChanged - when the player is changed\n */\n\nexport interface TrajectoryParameters {\n deltaTime: number // timestep between frames in picoseconds\n timeOffset: number // starting time of frames in picoseconds\n sele: string // to restrict atoms used for superposition\n centerPbc: boolean // center on initial frame\n removePbc: boolean // move atoms into the origin box\n removePeriodicity: boolean // try fixing periodic boundary discontinuities\n superpose: boolean // superpose on initial frame\n}\n\nexport interface TrajectorySignals {\n countChanged: Signal\n frameChanged: Signal\n playerChanged: Signal\n}\n\n/**\n * Base class for trajectories, tying structures and coordinates together\n * @interface\n */\nclass Trajectory {\n signals: TrajectorySignals = {\n countChanged: new Signal(),\n frameChanged: new Signal(),\n playerChanged: new Signal()\n }\n\n deltaTime: number\n timeOffset: number\n sele: string\n centerPbc: boolean\n removePbc: boolean\n removePeriodicity: boolean\n superpose: boolean\n\n name: string\n frame: number\n trajPath: string\n\n initialCoords: Float32Array\n structureCoords: Float32Array\n selectionIndices: NumberArray\n backboneIndices: NumberArray\n\n coords1: Float32Array\n coords2: Float32Array\n\n frameCache: { [k: number]: Float32Array } = {}\n loadQueue: { [k: number]: boolean } = {}\n boxCache: { [k: number]: ArrayLike } = {}\n pathCache = {}\n frameCacheSize = 0\n\n atomCount: number\n inProgress: boolean\n\n selection: Selection // selection to restrict atoms used for superposition\n structure: Structure\n player: TrajectoryPlayer\n\n private _frameCount = 0\n private _currentFrame = -1\n private _disposed = false\n\n /**\n * @param {String} trajPath - trajectory source\n * @param {Structure} structure - the structure object\n * @param {TrajectoryParameters} params - trajectory parameters\n */\n constructor (trajPath: string, structure: Structure, params: Partial = {}) {\n this.deltaTime = defaults(params.deltaTime, 0)\n this.timeOffset = defaults(params.timeOffset, 0)\n this.centerPbc = defaults(params.centerPbc, false)\n this.removePbc = defaults(params.removePbc, false)\n this.removePeriodicity = defaults(params.removePeriodicity, false)\n this.superpose = defaults(params.superpose, false)\n\n this.name = trajPath.replace(/^.*[\\\\/]/, '')\n this.trajPath = trajPath\n\n this.selection = new Selection(\n defaults(params.sele, 'backbone and not hydrogen')\n )\n\n this.selection.signals.stringChanged.add(() => {\n this.selectionIndices = this.structure.getAtomIndices(this.selection)!\n this._resetCache()\n this._saveInitialCoords()\n this.setFrame(this._currentFrame)\n })\n }\n\n /**\n * Number of frames in the trajectory\n */\n get frameCount () {\n return this._frameCount\n }\n\n /**\n * Currently set frame of the trajectory\n */\n get currentFrame () {\n return this._currentFrame\n }\n\n _init (structure: Structure) {\n this.setStructure(structure)\n this._loadFrameCount()\n this.setPlayer(new TrajectoryPlayer(this))\n }\n\n _loadFrameCount () {}\n\n setStructure (structure: Structure) {\n this.structure = structure\n this.atomCount = structure.atomCount\n\n this.backboneIndices = this._getIndices(\n new Selection('backbone and not hydrogen')\n )\n this._makeAtomIndices()\n this._saveStructureCoords()\n\n this.selectionIndices = this._getIndices(this.selection)\n this._resetCache()\n this._saveInitialCoords()\n this.setFrame(this._currentFrame)\n }\n\n _saveInitialCoords () {\n if (this.structure.hasCoords()) {\n this.initialCoords = new Float32Array(this.structureCoords)\n this._makeSuperposeCoords()\n } else if (this.frameCache[0]) {\n this.initialCoords = new Float32Array(this.frameCache[0])\n this._makeSuperposeCoords()\n } else {\n this.loadFrame(0, () => this._saveInitialCoords())\n }\n }\n\n _saveStructureCoords () {\n const p = { what: { position: true } }\n this.structureCoords = this.structure.getAtomData(p).position!\n }\n\n setSelection (string: string) {\n this.selection.setString(string)\n return this\n }\n\n _getIndices (selection: Selection) {\n let i = 0\n const test = selection.test\n const indices: number[] = []\n\n if (test) {\n this.structure.eachAtom((ap: AtomProxy) => {\n if (test(ap)) indices.push(i)\n i += 1\n })\n }\n\n return indices\n }\n\n _makeSuperposeCoords () {\n const n = this.selectionIndices.length * 3\n\n this.coords1 = new Float32Array(n)\n this.coords2 = new Float32Array(n)\n\n const y = this.initialCoords\n const coords2 = this.coords2\n\n for (let i = 0; i < n; i += 3) {\n const j = this.selectionIndices[ i / 3 ] * 3\n\n coords2[ i + 0 ] = y[ j + 0 ]\n coords2[ i + 1 ] = y[ j + 1 ]\n coords2[ i + 2 ] = y[ j + 2 ]\n }\n }\n\n _makeAtomIndices () {\n Log.error('Trajectory._makeAtomIndices not implemented')\n }\n\n _resetCache () {\n this.frameCache = {}\n this.loadQueue = {}\n this.boxCache = {}\n this.pathCache = {}\n this.frameCacheSize = 0\n this.initialCoords = new Float32Array(0)\n }\n\n setParameters (params: Partial = {}) {\n let resetCache = false\n\n if (params.centerPbc !== undefined && params.centerPbc !== this.centerPbc) {\n this.centerPbc = params.centerPbc\n resetCache = true\n }\n\n if (params.removePeriodicity !== undefined && params.removePeriodicity !== this.removePeriodicity) {\n this.removePeriodicity = params.removePeriodicity\n resetCache = true\n }\n\n if (params.removePbc !== undefined && params.removePbc !== this.removePbc) {\n this.removePbc = params.removePbc\n resetCache = true\n }\n\n if (params.superpose !== undefined && params.superpose !== this.superpose) {\n this.superpose = params.superpose\n resetCache = true\n }\n\n this.deltaTime = defaults(params.deltaTime, this.deltaTime)\n this.timeOffset = defaults(params.timeOffset, this.timeOffset)\n\n if (resetCache) {\n this._resetCache()\n this.setFrame(this._currentFrame)\n }\n }\n\n /**\n * Check if a frame is available\n * @param {Integer|Integer[]} i - the frame index\n * @return {Boolean} frame availability\n */\n hasFrame (i: number|number[]) {\n if (Array.isArray(i)) {\n return i.every(j => !!this.frameCache[j])\n } else {\n return !!this.frameCache[i]\n }\n }\n\n /**\n * Set trajectory to a frame index\n * @param {Integer} i - the frame index\n * @param {Function} [callback] - fired when the frame has been set\n */\n setFrame (i: number, callback?: Function) {\n if (i === undefined) return this\n\n this.inProgress = true\n\n // i = parseInt(i) // TODO\n\n if (i === -1 || this.frameCache[ i ]) {\n this._updateStructure(i)\n if (callback) callback()\n } else {\n this.loadFrame(i, () => {\n this._updateStructure(i)\n if (callback) callback()\n })\n }\n\n return this\n }\n\n _interpolate (i: number, ip: number, ipp: number, ippp: number, t: number, type: TrajectoryPlayerInterpolateType) {\n const fc = this.frameCache\n\n let coords\n if (type === 'spline') {\n coords = interpolateSpline(fc[ i ], fc[ ip ], fc[ ipp ], fc[ ippp ], t)\n } else {\n coords = interpolateLerp(fc[ i ], fc[ ip ], t)\n }\n\n this.structure.updatePosition(coords)\n this._currentFrame = i\n this.signals.frameChanged.dispatch(i)\n }\n\n /**\n * Interpolated and set trajectory to frame indices\n * @param {Integer} i - the frame index\n * @param {Integer} ip - one before frame index\n * @param {Integer} ipp - two before frame index\n * @param {Integer} ippp - three before frame index\n * @param {Number} t - interpolation step [0,1]\n * @param {String} type - interpolation type, '', 'spline' or 'linear'\n * @param {Function} callback - fired when the frame has been set\n */\n setFrameInterpolated (i: number, ip: number, ipp: number, ippp: number, t: number, type: TrajectoryPlayerInterpolateType, callback?: Function) {\n if (i === undefined) return this\n\n const fc = this.frameCache\n const iList: number[] = []\n\n if (!fc[ ippp ]) iList.push(ippp)\n if (!fc[ ipp ]) iList.push(ipp)\n if (!fc[ ip ]) iList.push(ip)\n if (!fc[ i ]) iList.push(i)\n\n if (iList.length) {\n this.loadFrame(iList, () => {\n this._interpolate(i, ip, ipp, ippp, t, type)\n if (callback) callback()\n })\n } else {\n this._interpolate(i, ip, ipp, ippp, t, type)\n if (callback) callback()\n }\n\n return this\n }\n\n /**\n * Load frame index\n * @param {Integer|Integer[]} i - the frame index\n * @param {Function} callback - fired when the frame has been loaded\n */\n loadFrame (i: number|number[], callback?: Function) {\n if (Array.isArray(i)) {\n i.forEach(j => {\n if (!this.loadQueue[j] && !this.frameCache[j]) {\n this.loadQueue[j] = true\n this._loadFrame(j, () => {\n delete this.loadQueue[j]\n })\n }\n })\n } else {\n if (!this.loadQueue[i] && !this.frameCache[i]) {\n this.loadQueue[i] = true\n this._loadFrame(i, () => {\n delete this.loadQueue[i]\n if (callback) callback()\n })\n }\n }\n }\n\n /**\n * Load frame index\n * @abstract\n * @param {Integer} i - the frame index\n * @param {Function} callback - fired when the frame has been loaded\n */\n _loadFrame (i: number, callback?: Function) {\n Log.error('Trajectory._loadFrame not implemented', i, callback)\n }\n\n _updateStructure (i: number) {\n if (this._disposed) {\n console.error('updateStructure: traj disposed')\n return\n }\n\n if (i === -1) {\n if (this.structureCoords) {\n this.structure.updatePosition(this.structureCoords)\n }\n } else {\n this.structure.updatePosition(this.frameCache[ i ])\n }\n\n this.structure.trajectory = {\n name: this.trajPath,\n frame: i\n }\n\n this._currentFrame = i\n this.inProgress = false\n this.signals.frameChanged.dispatch(i)\n }\n\n _doSuperpose (x: Float32Array) {\n const n = this.selectionIndices.length * 3\n\n const coords1 = this.coords1\n const coords2 = this.coords2\n\n for (let i = 0; i < n; i += 3) {\n const j = this.selectionIndices[ i / 3 ] * 3\n\n coords1[ i + 0 ] = x[ j + 0 ]\n coords1[ i + 1 ] = x[ j + 1 ]\n coords1[ i + 2 ] = x[ j + 2 ]\n }\n\n // TODO re-use superposition object\n const sp = new Superposition(coords1, coords2)\n sp.transform(x)\n }\n\n _process (i: number, box: ArrayLike, coords: Float32Array, frameCount: number) {\n this._setFrameCount(frameCount)\n\n if (box) {\n if (this.backboneIndices.length > 0 && this.centerPbc) {\n const box2 = [ box[ 0 ], box[ 4 ], box[ 8 ] ]\n const circMean = circularMean3(this.backboneIndices, coords, box2)\n centerPbc(coords, circMean, box2)\n }\n\n if (this.removePeriodicity) {\n const mean = arrayMean3(coords)\n removePeriodicity(coords, box, mean)\n }\n\n if (this.removePbc) {\n removePbc(coords, box)\n }\n }\n\n if (this.selectionIndices.length > 0 && this.coords1 && this.superpose) {\n this._doSuperpose(coords)\n }\n\n this.frameCache[ i ] = coords\n this.boxCache[ i ] = box\n this.frameCacheSize += 1\n }\n\n _setFrameCount (n: number) {\n if (n !== this._frameCount) {\n this._frameCount = n\n this.signals.countChanged.dispatch(n)\n }\n }\n\n /**\n * Dispose of the trajectory object\n * @return {undefined}\n */\n dispose () {\n this._resetCache() // aid GC\n this._disposed = true\n if (this.player) this.player.stop()\n }\n\n /**\n * Set player for this trajectory\n * @param {TrajectoryPlayer} player - the player\n */\n setPlayer (player: TrajectoryPlayer) {\n this.player = player\n this.signals.playerChanged.dispatch(player)\n }\n\n /**\n * Get time for frame\n * @param {Integer} i - frame index\n * @return {Number} time in picoseconds\n */\n getFrameTime (i: number) {\n return this.timeOffset + i * this.deltaTime\n }\n}\n\nexport default Trajectory\n","/**\n * @file Frames Trajectory\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport Structure from '../structure/structure'\nimport Frames from './frames'\nimport Trajectory, { TrajectoryParameters } from './trajectory'\n\n/**\n * Frames trajectory class. Gets data from a frames object.\n */\nclass FramesTrajectory extends Trajectory {\n path: string\n\n frames: ArrayLike[]\n boxes: ArrayLike[]\n\n atomIndices?: ArrayLike\n\n constructor (frames: Frames, structure: Structure, params: TrajectoryParameters) {\n const p = params || {}\n p.timeOffset = defaults(p.timeOffset, frames.timeOffset)\n p.deltaTime = defaults(p.deltaTime, frames.deltaTime)\n\n super('', structure, p)\n\n this.name = frames.name\n this.path = frames.path\n\n this.frames = frames.coordinates\n this.boxes = frames.boxes\n\n this._init(structure)\n }\n\n get type () { return 'frames' }\n\n _makeAtomIndices () {\n if (this.structure.type === 'StructureView') {\n this.atomIndices = this.structure.getAtomIndices()\n } else {\n this.atomIndices = undefined\n }\n }\n\n _loadFrame (i: number, callback?: Function) {\n let coords\n const frame = this.frames[ i ]\n\n if (this.atomIndices) {\n const indices = this.atomIndices\n const m = indices.length\n\n coords = new Float32Array(m * 3)\n\n for (let j = 0; j < m; ++j) {\n const j3 = j * 3\n const idx3 = indices[ j ] * 3\n\n coords[ j3 + 0 ] = frame[ idx3 + 0 ]\n coords[ j3 + 1 ] = frame[ idx3 + 1 ]\n coords[ j3 + 2 ] = frame[ idx3 + 2 ]\n }\n } else {\n coords = new Float32Array(frame)\n }\n\n const box = this.boxes[ i ]\n const frameCount = this.frames.length\n\n this._process(i, box, coords, frameCount)\n\n if (typeof callback === 'function') {\n callback()\n }\n }\n\n _loadFrameCount () {\n if (this.frames) {\n this._setFrameCount(this.frames.length)\n }\n }\n}\n\nexport default FramesTrajectory\n","/**\n * @file Structure Trajectory\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Trajectory, { TrajectoryParameters } from './trajectory'\n\n/**\n * Structure trajectory class. Gets data from a structure object.\n */\nclass StructureTrajectory extends Trajectory {\n atomIndices?: ArrayLike\n\n constructor (trajPath: string, structure: Structure, params: TrajectoryParameters) {\n super('', structure, params)\n this._init(structure)\n }\n\n get type () { return 'structure' }\n\n _makeAtomIndices () {\n if (this.structure.atomSet && this.structure.atomSet.getSize() < this.structure.atomStore.count) {\n this.atomIndices = this.structure.getAtomIndices()\n } else {\n this.atomIndices = undefined\n }\n }\n\n _loadFrame (i: number, callback?: Function) {\n let coords\n const structure = this.structure\n const frame = structure.frames[ i ]\n\n if (this.atomIndices) {\n const indices = this.atomIndices\n const m = indices.length\n\n coords = new Float32Array(m * 3)\n\n for (let j = 0; j < m; ++j) {\n const j3 = j * 3\n const idx3 = indices[ j ] * 3\n\n coords[ j3 + 0 ] = frame[ idx3 + 0 ]\n coords[ j3 + 1 ] = frame[ idx3 + 1 ]\n coords[ j3 + 2 ] = frame[ idx3 + 2 ]\n }\n } else {\n coords = new Float32Array(frame)\n }\n\n const box = structure.boxes[ i ]\n const frameCount = structure.frames.length\n\n this._process(i, box, coords, frameCount)\n\n if (typeof callback === 'function') {\n callback()\n }\n }\n\n _loadFrameCount () {\n this._setFrameCount(this.structure.frames.length)\n }\n}\n\nexport default StructureTrajectory\n","/**\n * @file Remote Trajectory\n * @author Alexander Rose \n * @private\n */\n\nimport { Log, TrajectoryDatasource } from '../globals'\nimport Structure from '../structure/structure'\nimport Trajectory, { TrajectoryParameters } from './trajectory'\n\n/**\n * Remote trajectory class. Gets data from an MDsrv instance.\n */\nclass RemoteTrajectory extends Trajectory {\n atomIndices: number[][]\n\n constructor (trajPath: string, structure: Structure, params: TrajectoryParameters) {\n super(trajPath, structure, params)\n this._init(structure)\n }\n\n get type () { return 'remote' }\n\n _makeAtomIndices () {\n const atomIndices = []\n\n if (this.structure.type === 'StructureView') {\n const indices = this.structure.getAtomIndices()! // TODO\n const n = indices.length\n\n let p = indices[ 0 ]\n let q = indices[ 0 ]\n\n for (let i = 1; i < n; ++i) {\n const r = indices[ i ]\n\n if (q + 1 < r) {\n atomIndices.push([ p, q + 1 ])\n p = r\n }\n\n q = r\n }\n\n atomIndices.push([ p, q + 1 ])\n } else {\n atomIndices.push([ 0, this.atomCount ])\n }\n\n this.atomIndices = atomIndices\n }\n\n _loadFrame (i: number, callback?: Function) {\n // TODO implement max frameCache size, re-use arrays\n\n const request = new XMLHttpRequest()\n\n const url = TrajectoryDatasource.getFrameUrl(this.trajPath, i)\n const params = TrajectoryDatasource.getFrameParams(this.trajPath, this.atomIndices)\n\n request.open('POST', url, true)\n request.responseType = 'arraybuffer'\n request.setRequestHeader(\n 'Content-type', 'application/x-www-form-urlencoded'\n )\n\n request.addEventListener('load', () => {\n const arrayBuffer = request.response\n if (!arrayBuffer) {\n Log.error(`empty arrayBuffer for '${url}'`)\n return\n }\n\n const frameCount = new Int32Array(arrayBuffer, 0, 1)[ 0 ]\n // const time = new Float32Array( arrayBuffer, 1 * 4, 1 )[ 0 ];\n const box = new Float32Array(arrayBuffer, 2 * 4, 9)\n const coords = new Float32Array(arrayBuffer, 11 * 4)\n\n this._process(i, box, coords, frameCount)\n if (typeof callback === 'function') {\n callback()\n }\n }, false)\n\n request.send(params)\n }\n\n _loadFrameCount () {\n const request = new XMLHttpRequest()\n\n const url = TrajectoryDatasource.getCountUrl(this.trajPath)\n\n request.open('GET', url, true)\n request.addEventListener('load', () => {\n this._setFrameCount(parseInt(request.response))\n }, false)\n request.send()\n }\n}\n\nexport default RemoteTrajectory\n","/**\n * @file Callback Trajectory\n * @author Tarn W. Burton \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Trajectory, { TrajectoryParameters } from './trajectory'\n\ntype RequestCallback = (responseCallback: Function, i?: number, atomIndices?: number[][]) => void\n\n/**\n * Callback trajectory class. Gets data from an JavaScript function.\n */\nclass CallbackTrajectory extends Trajectory {\n atomIndices: number[][]\n requestCallback: RequestCallback\n\n constructor (requestCallback: RequestCallback, structure: Structure, params: TrajectoryParameters) {\n super('', structure, params)\n this.requestCallback = requestCallback;\n this._init(structure)\n }\n\n get type () { return 'callback' }\n\n _makeAtomIndices () {\n const atomIndices = []\n\n if (this.structure.type === 'StructureView') {\n const indices = this.structure.getAtomIndices()! // TODO\n const n = indices.length\n\n let p = indices[ 0 ]\n let q = indices[ 0 ]\n\n for (let i = 1; i < n; ++i) {\n const r = indices[ i ]\n\n if (q + 1 < r) {\n atomIndices.push([ p, q + 1 ])\n p = r\n }\n\n q = r\n }\n\n atomIndices.push([ p, q + 1 ])\n } else {\n atomIndices.push([ 0, this.atomCount ])\n }\n\n this.atomIndices = atomIndices\n }\n\n _loadFrame (i: number, callback?: Function) {\n this.requestCallback(\n (i: number, box: ArrayLike, coords: Float32Array, frameCount: number) => {\n this._process(i, box, coords, frameCount)\n if (typeof callback === 'function') {\n callback()\n }\n }, i, this.atomIndices)\n }\n\n _loadFrameCount () {\n this.requestCallback((count: number) => this._setFrameCount(count))\n }\n}\n\nexport default CallbackTrajectory\n\n","/**\n * @file Structure View\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3 } from 'three'\n\nimport { Debug, Log } from '../globals'\nimport Structure from './structure'\nimport Selection from '../selection/selection'\nimport BitArray from '../utils/bitarray'\n\nimport BondProxy from '../proxy/bond-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\nimport SpatialHash from '../geometry/spatial-hash';\nimport BondHash from '../store/bond-hash';\nimport ResidueMap from '../store/residue-map';\nimport AtomMap from '../store/atom-map';\nimport ModelStore from '../store/model-store';\nimport ChainStore from '../store/chain-store';\nimport ResidueStore from '../store/residue-store';\nimport AtomStore from '../store/atom-store';\nimport BondStore from '../store/bond-store';\nimport Validation from './validation';\nimport Unitcell from '../symmetry/unitcell';\nimport Entity from './entity';\nimport Assembly from '../symmetry/assembly';\nimport { Data } from './data';\n\n/**\n * Get view on structure restricted to the selection\n * @param {Selection} selection - the selection\n * @return {StructureView} the view on the structure\n */\nStructure.prototype.getView = function (this: Structure, selection: Selection) {\n // added here to avoid cyclic import dependency\n return new StructureView(this, selection)\n}\n\n/**\n * View on the structure, restricted to the selection\n */\nclass StructureView extends Structure {\n structure: Structure\n selection: Selection\n\n /**\n * @param {Structure} structure - the structure\n * @param {Selection} selection - the selection\n */\n constructor (structure: Structure, selection: Selection) {\n super()\n\n this.structure = structure\n this.selection = selection\n\n this.center = new Vector3()\n this.boundingBox = new Box3()\n\n this._bp = this.getBondProxy()\n this._ap = this.getAtomProxy()\n this._rp = this.getResidueProxy()\n this._cp = this.getChainProxy()\n\n if (this.selection) {\n this.selection.signals.stringChanged.add(this.refresh, this)\n }\n\n this.structure.signals.refreshed.add(this.refresh, this)\n\n this.refresh()\n }\n\n init () {}\n\n get type () { return 'StructureView' }\n\n get name () { return this.structure.name }\n get path () { return this.structure.path }\n get title () { return this.structure.title }\n get id () { return this.structure.id }\n get data (): Data { return this.structure.data }\n get atomSetDict () { return this.structure.atomSetDict }\n get biomolDict (): {[k: string]: Assembly} { return this.structure.biomolDict }\n get entityList (): Entity[] { return this.structure.entityList }\n get unitcell (): Unitcell|undefined { return this.structure.unitcell }\n get frames () { return this.structure.frames }\n get boxes () { return this.structure.boxes }\n get validation (): Validation|undefined { return this.structure.validation }\n get bondStore () { return this.structure.bondStore }\n get backboneBondStore () { return this.structure.backboneBondStore }\n get rungBondStore (): BondStore { return this.structure.rungBondStore }\n get atomStore (): AtomStore { return this.structure.atomStore }\n get residueStore (): ResidueStore { return this.structure.residueStore }\n get chainStore (): ChainStore { return this.structure.chainStore }\n get modelStore (): ModelStore { return this.structure.modelStore }\n get atomMap (): AtomMap { return this.structure.atomMap }\n get residueMap (): ResidueMap { return this.structure.residueMap }\n get bondHash (): BondHash|undefined { return this.structure.bondHash }\n get spatialHash (): SpatialHash|undefined { return this.structure.spatialHash }\n\n get _hasCoords () { return this.structure._hasCoords }\n set _hasCoords (value) { this.structure._hasCoords = value }\n\n /**\n * Updates atomSet, bondSet, atomSetCache, atomCount, bondCount, boundingBox, center.\n * @emits {Structure.signals.refreshed} when refreshed\n * @return {undefined}\n */\n refresh () {\n if (Debug) Log.time('StructureView.refresh')\n\n this.atomSetCache = {}\n const structure = this.structure\n\n if (this.selection.isAllSelection() &&\n structure !== this && structure.atomSet && structure.bondSet\n ) {\n this.atomSet = structure.atomSet.clone()\n this.bondSet = structure.bondSet.clone()\n\n for (let name in this.atomSetDict) {\n const atomSet = this.atomSetDict[ name ]\n this.atomSetCache[ '__' + name ] = atomSet.clone()\n }\n\n this.atomCount = structure.atomCount\n this.bondCount = structure.bondCount\n\n this.boundingBox.copy(structure.boundingBox)\n this.center.copy(structure.center)\n } else if (this.selection.isNoneSelection() &&\n structure !== this && structure.atomSet && structure.bondSet\n ) {\n this.atomSet = new BitArray(structure.atomCount)\n this.bondSet = new BitArray(structure.bondCount)\n\n for (let name in this.atomSetDict) {\n this.atomSetCache[ '__' + name ] = new BitArray(structure.atomCount)\n }\n\n this.atomCount = 0\n this.bondCount = 0\n\n this.boundingBox.makeEmpty()\n this.center.set(0, 0, 0)\n } else {\n this.atomSet = this.getAtomSet(this.selection, true)\n if (structure.atomSet) {\n this.atomSet = this.atomSet.intersection(structure.atomSet)\n }\n\n this.bondSet = this.getBondSet()\n\n for (let name in this.atomSetDict) {\n const atomSet = this.atomSetDict[ name ]\n this.atomSetCache[ '__' + name ] = atomSet.makeIntersection(this.atomSet)\n }\n\n this.atomCount = this.atomSet.getSize()\n this.bondCount = this.bondSet.getSize()\n\n this.boundingBox = this.getBoundingBox()\n this.center = this.boundingBox.getCenter(new Vector3())\n }\n\n if (Debug) Log.timeEnd('StructureView.refresh')\n\n this.signals.refreshed.dispatch()\n }\n\n //\n\n setSelection (selection: Selection) {\n this.selection = selection\n\n this.refresh()\n }\n\n getSelection (selection?: Selection) {\n const seleList: string[] = []\n\n if (selection && selection.string) {\n seleList.push(selection.string)\n }\n\n const parentSelection = this.structure.getSelection()\n if (parentSelection && parentSelection.string) {\n seleList.push(parentSelection.string)\n }\n\n if (this.selection && this.selection.string) {\n seleList.push(this.selection.string)\n }\n\n let sele = ''\n if (seleList.length > 0) {\n sele = `( ${seleList.join(' ) AND ( ')} )`\n }\n\n return new Selection(sele)\n }\n\n getStructure () {\n return this.structure.getStructure()\n }\n\n //\n\n eachBond (callback: (entity: BondProxy) => any, selection?: Selection) {\n this.structure.eachBond(callback, this.getSelection(selection))\n }\n\n eachAtom (callback: (entity: AtomProxy) => any, selection?: Selection) {\n const ap = this.getAtomProxy()\n const atomSet = this.getAtomSet(selection)\n const n = this.atomStore.count\n\n if (atomSet.getSize() < n) {\n atomSet.forEach(function (index) {\n ap.index = index\n callback(ap)\n })\n } else {\n for (let i = 0; i < n; ++i) {\n ap.index = i\n callback(ap)\n }\n }\n }\n\n eachResidue (callback: (entity: ResidueProxy) => any, selection?: Selection) {\n this.structure.eachResidue(callback, this.getSelection(selection))\n }\n\n /**\n * Not implemented\n * @alias StructureView#eachResidueN\n * @return {undefined}\n */\n eachResidueN (n: number, callback: (entity: ResidueProxy) => any) {\n console.error('StructureView.eachResidueN() not implemented')\n }\n\n eachChain (callback: (entity: ChainProxy) => any, selection?: Selection) {\n this.structure.eachChain(callback, this.getSelection(selection))\n }\n\n eachModel (callback: (entity: ModelProxy) => any, selection?: Selection) {\n this.structure.eachModel(callback, this.getSelection(selection))\n }\n\n //\n\n getAtomSet (selection?: boolean|Selection|BitArray, ignoreView = false) {\n let atomSet = this.structure.getAtomSet(selection)\n if (!ignoreView && this.atomSet) {\n atomSet = atomSet.makeIntersection(this.atomSet)\n }\n\n return atomSet\n }\n\n //\n\n getAtomIndices (selection?: Selection) {\n return this.structure.getAtomIndices(this.getSelection(selection))\n }\n\n refreshPosition () {\n return this.structure.refreshPosition()\n }\n\n //\n\n dispose () {\n if (this.selection) {\n this.selection.signals.stringChanged.remove(this.refresh, this)\n }\n\n this.structure.signals.refreshed.remove(this.refresh, this)\n\n this.structure = new Structure() // delete old data\n\n delete this.atomSet\n delete this.bondSet\n\n }\n}\n\nexport default StructureView\n","/**\n * @file Alignment\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log } from '../globals'\n\n// const nucleotides = 'ACTG';\nconst aminoacidsX = 'ACDEFGHIKLMNPQRSTVWY'\nconst aminoacids = 'ARNDCQEGHILKMFPSTWYVBZ?'\n\nconst blosum62x = [\n [4, 0, -2, -1, -2, 0, -2, -1, -1, -1, -1, -2, -1, -1, -1, 1, 0, 0, -3, -2], // A\n [0, 9, -3, -4, -2, -3, -3, -1, -3, -1, -1, -3, -3, -3, -3, -1, -1, -1, -2, -2], // C\n [-2, -3, 6, 2, -3, -1, -1, -3, -1, -4, -3, 1, -1, 0, -2, 0, -1, -3, -4, -3], // D\n [-1, -4, 2, 5, -3, -2, 0, -3, 1, -3, -2, 0, -1, 2, 0, 0, -1, -2, -3, -2], // E\n [-2, -2, -3, -3, 6, -3, -1, 0, -3, 0, 0, -3, -4, -3, -3, -2, -2, -1, 1, 3], // F\n [0, -3, -1, -2, -3, 6, -2, -4, -2, -4, -3, 0, -2, -2, -2, 0, -2, -3, -2, -3], // G\n [-2, -3, -1, 0, -1, -2, 8, -3, -1, -3, -2, 1, -2, 0, 0, -1, -2, -3, -2, 2], // H\n [-1, -1, -3, -3, 0, -4, -3, 4, -3, 2, 1, -3, -3, -3, -3, -2, -1, 3, -3, -1], // I\n [-1, -3, -1, 1, -3, -2, -1, -3, 5, -2, -1, 0, -1, 1, 2, 0, -1, -2, -3, -2], // K\n [-1, -1, -4, -3, 0, -4, -3, 2, -2, 4, 2, -3, -3, -2, -2, -2, -1, 1, -2, -1], // L\n [-1, -1, -3, -2, 0, -3, -2, 1, -1, 2, 5, -2, -2, 0, -1, -1, -1, 1, -1, -1], // M\n [-2, -3, 1, 0, -3, 0, 1, -3, 0, -3, -2, 6, -2, 0, 0, 1, 0, -3, -4, -2], // N\n [-1, -3, -1, -1, -4, -2, -2, -3, -1, -3, -2, -2, 7, -1, -2, -1, -1, -2, -4, -3], // P\n [-1, -3, 0, 2, -3, -2, 0, -3, 1, -2, 0, 0, -1, 5, 1, 0, -1, -2, -2, -1], // Q\n [-1, -3, -2, 0, -3, -2, 0, -3, 2, -2, -1, 0, -2, 1, 5, -1, -1, -3, -3, -2], // R\n [1, -1, 0, 0, -2, 0, -1, -2, 0, -2, -1, 1, -1, 0, -1, 4, 1, -2, -3, -2], // S\n [0, -1, -1, -1, -2, -2, -2, -1, -1, -1, -1, 0, -1, -1, -1, 1, 5, 0, -2, -2], // T\n [0, -1, -3, -2, -1, -3, -3, 3, -2, 1, 1, -3, -2, -2, -3, -2, 0, 4, -3, -1], // V\n [-3, -2, -4, -3, 1, -2, -2, -3, -3, -2, -1, -4, -4, -2, -3, -3, -2, -3, 11, 2], // W\n [-2, -2, -3, -2, 3, -3, 2, -1, -2, -1, -1, -2, -3, -1, -2, -2, -2, -1, 2, 7] // Y\n]\n\nconst blosum62 = [\n // A R N D C Q E G H I L K M F P S T W Y V B Z X\n [4, -1, -2, -2, 0, -1, -1, 0, -2, -1, -1, -1, -1, -2, -1, 1, 0, -3, -2, 0, -2, -1, 0], // A\n [-1, 5, 0, -2, -3, 1, 0, -2, 0, -3, -2, 2, -1, -3, -2, -1, -1, -3, -2, -3, -1, 0, -1], // R\n [-2, 0, 6, 1, -3, 0, 0, 0, 1, -3, -3, 0, -2, -3, -2, 1, 0, -4, -2, -3, 3, 0, -1], // N\n [-2, -2, 1, 6, -3, 0, 2, -1, -1, -3, -4, -1, -3, -3, -1, 0, -1, -4, -3, -3, 4, 1, -1], // D\n [0, -3, -3, -3, 9, -3, -4, -3, -3, -1, -1, -3, -1, -2, -3, -1, -1, -2, -2, -1, -3, -3, -2], // C\n [-1, 1, 0, 0, -3, 5, 2, -2, 0, -3, -2, 1, 0, -3, -1, 0, -1, -2, -1, -2, 0, 3, -1], // Q\n [-1, 0, 0, 2, -4, 2, 5, -2, 0, -3, -3, 1, -2, -3, -1, 0, -1, -3, -2, -2, 1, 4, -1], // E\n [0, -2, 0, -1, -3, -2, -2, 6, -2, -4, -4, -2, -3, -3, -2, 0, -2, -2, -3, -3, -1, -2, -1], // G\n [-2, 0, 1, -1, -3, 0, 0, -2, 8, -3, -3, -1, -2, -1, -2, -1, -2, -2, 2, -3, 0, 0, -1], // H\n [-1, -3, -3, -3, -1, -3, -3, -4, -3, 4, 2, -3, 1, 0, -3, -2, -1, -3, -1, 3, -3, -3, -1], // I\n [-1, -2, -3, -4, -1, -2, -3, -4, -3, 2, 4, -2, 2, 0, -3, -2, -1, -2, -1, 1, -4, -3, -1], // L\n [-1, 2, 0, -1, -3, 1, 1, -2, -1, -3, -2, 5, -1, -3, -1, 0, -1, -3, -2, -2, 0, 1, -1], // K\n [-1, -1, -2, -3, -1, 0, -2, -3, -2, 1, 2, -1, 5, 0, -2, -1, -1, -1, -1, 1, -3, -1, -1], // M\n [-2, -3, -3, -3, -2, -3, -3, -3, -1, 0, 0, -3, 0, 6, -4, -2, -2, 1, 3, -1, -3, -3, -1], // F\n [-1, -2, -2, -1, -3, -1, -1, -2, -2, -3, -3, -1, -2, -4, 7, -1, -1, -4, -3, -2, -2, -1, -2], // P\n [1, -1, 1, 0, -1, 0, 0, 0, -1, -2, -2, 0, -1, -2, -1, 4, 1, -3, -2, -2, 0, 0, 0], // S\n [0, -1, 0, -1, -1, -1, -1, -2, -2, -1, -1, -1, -1, -2, -1, 1, 5, -2, -2, 0, -1, -1, 0], // T\n [-3, -3, -4, -4, -2, -2, -3, -2, -2, -3, -2, -3, -1, 1, -4, -3, -2, 11, 2, -3, -4, -3, -2], // W\n [-2, -2, -2, -3, -2, -1, -2, -3, 2, -1, -1, -2, -1, 3, -3, -2, -2, 2, 7, -1, -3, -2, -1], // Y\n [0, -3, -3, -3, -1, -2, -2, -3, -3, 3, 1, -2, 1, -1, -2, -2, 0, -3, -1, 4, -3, -2, -1], // V\n [-2, -1, 3, 4, -3, 0, 1, -1, 0, -3, -4, 0, -3, -3, -2, 0, -1, -4, -3, -3, 4, 1, -1], // B\n [-1, 0, 0, 1, -3, 3, 4, -2, 0, -3, -3, 1, -1, -3, -1, 0, -1, -3, -2, -2, 1, 4, -1], // Z\n [0, -1, -1, -1, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, 0, 0, -2, -1, -1, -1, -1, -1] // X\n]\n\nfunction prepareMatrix (cellNames: string, mat: number[][]) {\n let j: number\n let i = 0\n const matDict: { [k: string]: { [k: string]: number } } = {}\n mat.forEach(function (row) {\n j = 0\n const rowDict: { [k: string]: number } = {}\n row.forEach(function (elm) {\n rowDict[ cellNames[ j++ ] ] = elm\n })\n matDict[ cellNames[ i++ ] ] = rowDict\n })\n return matDict\n}\n\nconst SubstitutionMatrices = (function () {\n return {\n blosum62: prepareMatrix(aminoacids, blosum62),\n blosum62x: prepareMatrix(aminoacidsX, blosum62x)\n }\n}())\nexport type SubstitutionMatrix = ''|'blosum62'|'blosum62x'\n\nclass Alignment {\n substMatrix: { [k: string]: { [k: string]: number } }\n\n n: number\n m: number\n score?: number\n ali: string\n\n S: number[][]\n V: number[][]\n H: number[][]\n\n ali1: string\n ali2: string\n\n constructor (readonly seq1: string, readonly seq2: string, readonly gapPenalty = -10, readonly gapExtensionPenalty = -1, substMatrix: SubstitutionMatrix = 'blosum62') {\n // TODO try encoding seqs as integers and use array subst matrix, maybe faster\n\n if (substMatrix) {\n this.substMatrix = SubstitutionMatrices[ substMatrix ]\n }\n }\n\n initMatrices () {\n this.n = this.seq1.length\n this.m = this.seq2.length\n\n // Log.log(this.n, this.m);\n\n this.score = undefined\n this.ali = ''\n\n this.S = []\n this.V = []\n this.H = []\n\n for (let i = 0; i <= this.n; ++i) {\n this.S[ i ] = []\n this.V[ i ] = []\n this.H[ i ] = []\n\n for (let j = 0; j <= this.m; ++j) {\n this.S[ i ][ j ] = 0\n this.V[ i ][ j ] = 0\n this.H[ i ][ j ] = 0\n }\n }\n\n for (let i = 0; i <= this.n; ++i) {\n this.S[ i ][ 0 ] = this.gap(0)\n this.H[ i ][ 0 ] = -Infinity\n }\n\n for (let j = 0; j <= this.m; ++j) {\n this.S[ 0 ][ j ] = this.gap(0)\n this.V[ 0 ][ j ] = -Infinity\n }\n\n this.S[ 0 ][ 0 ] = 0\n\n // Log.log(this.S, this.V, this.H);\n }\n\n gap (len: number) {\n return this.gapPenalty + len * this.gapExtensionPenalty\n }\n\n makeScoreFn () {\n const seq1 = this.seq1\n const seq2 = this.seq2\n\n const substMatrix = this.substMatrix\n\n if (substMatrix) {\n return function score (i: number, j: number) {\n const c1 = seq1[ i ]\n const c2 = seq2[ j ]\n\n try {\n return substMatrix[ c1 ][ c2 ]\n } catch (e) {\n return -4\n }\n }\n } else {\n Log.warn('Alignment: no subst matrix')\n\n return function scoreNoSubstMat (i: number, j: number) {\n const c1 = seq1[ i ]\n const c2 = seq2[ j ]\n\n return c1 === c2 ? 5 : -3\n }\n }\n }\n\n calc () {\n if (Debug) Log.time('Alignment.calc')\n\n this.initMatrices()\n\n const gap0 = this.gap(0)\n const scoreFn = this.makeScoreFn()\n const gapExtensionPenalty = this.gapExtensionPenalty\n\n const V = this.V\n const H = this.H\n const S = this.S\n\n const n = this.n\n const m = this.m\n\n let Vi1, Si1, Vi, Hi, Si\n\n for (let i = 1; i <= n; ++i) {\n Si1 = S[ i - 1 ]\n Vi1 = V[ i - 1 ]\n\n Vi = V[ i ]\n Hi = H[ i ]\n Si = S[ i ]\n\n for (let j = 1; j <= m; ++j) {\n Vi[j] = Math.max(\n Si1[ j ] + gap0,\n Vi1[ j ] + gapExtensionPenalty\n )\n\n Hi[j] = Math.max(\n Si[ j - 1 ] + gap0,\n Hi[ j - 1 ] + gapExtensionPenalty\n )\n\n Si[j] = Math.max(\n Si1[ j - 1 ] + scoreFn(i - 1, j - 1), // match\n Vi[ j ], // del\n Hi[ j ] // ins\n )\n }\n }\n\n if (Debug) Log.timeEnd('Alignment.calc')\n\n if (Debug) Log.log(this.S, this.V, this.H)\n }\n\n trace () {\n if (Debug) Log.time('Alignment.trace')\n\n this.ali1 = ''\n this.ali2 = ''\n\n const scoreFn = this.makeScoreFn()\n\n let i = this.n\n let j = this.m\n let mat\n\n if (this.S[i][j] >= this.V[i][j]) {\n mat = 'S'\n this.score = this.S[i][j]\n } else if (this.V[i][j] >= this.H[i][j]) {\n mat = 'V'\n this.score = this.V[i][j]\n } else {\n mat = 'H'\n this.score = this.H[i][j]\n }\n\n if (Debug) Log.log('Alignment: SCORE', this.score)\n if (Debug) Log.log('Alignment: S, V, H', this.S[i][j], this.V[i][j], this.H[i][j])\n\n while (i > 0 && j > 0) {\n if (mat === 'S') {\n if (this.S[i][j] === this.S[i - 1][j - 1] + scoreFn(i - 1, j - 1)) {\n this.ali1 = this.seq1[i - 1] + this.ali1\n this.ali2 = this.seq2[j - 1] + this.ali2\n --i\n --j\n mat = 'S'\n } else if (this.S[i][j] === this.V[i][j]) {\n mat = 'V'\n } else if (this.S[i][j] === this.H[i][j]) {\n mat = 'H'\n } else {\n // Log.debug('Alignment: S');\n --i\n --j\n }\n } else if (mat === 'V') {\n if (this.V[i][j] === this.V[i - 1][j] + this.gapExtensionPenalty) {\n this.ali1 = this.seq1[i - 1] + this.ali1\n this.ali2 = '-' + this.ali2\n --i\n mat = 'V'\n } else if (this.V[i][j] === this.S[i - 1][j] + this.gap(0)) {\n this.ali1 = this.seq1[i - 1] + this.ali1\n this.ali2 = '-' + this.ali2\n --i\n mat = 'S'\n } else {\n // Log.debug('Alignment: V');\n --i\n }\n } else if (mat === 'H') {\n if (this.H[i][j] === this.H[i][j - 1] + this.gapExtensionPenalty) {\n this.ali1 = '-' + this.ali1\n this.ali2 = this.seq2[j - 1] + this.ali2\n --j\n mat = 'H'\n } else if (this.H[i][j] === this.S[i][j - 1] + this.gap(0)) {\n this.ali1 = '-' + this.ali1\n this.ali2 = this.seq2[j - 1] + this.ali2\n --j\n mat = 'S'\n } else {\n // Log.debug('Alignment: H');\n --j\n }\n } else {\n Log.error('Alignment: no matrix')\n }\n }\n\n while (i > 0) {\n this.ali1 = this.seq1[ i - 1 ] + this.ali1\n this.ali2 = '-' + this.ali2\n --i\n }\n\n while (j > 0) {\n this.ali1 = '-' + this.ali1\n this.ali2 = this.seq2[ j - 1 ] + this.ali2\n --j\n }\n\n if (Debug) Log.timeEnd('Alignment.trace')\n\n if (Debug) Log.log([this.ali1, this.ali2])\n }\n}\n\nexport default Alignment\n","/**\n * @file Align Utils\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\nimport Alignment from './alignment'\nimport Superposition from './superposition'\n\n/**\n * Perform structural superposition of two structures,\n * optionally guided by a sequence alignment\n * @param {Structure|StructureView} s1 - structure 1 which is superposed onto structure 2\n * @param {Structure|StructureView} s2 - structure 2 onto which structure 1 is superposed\n * @param {Boolean} [align] - guide the superposition by a sequence alignment\n * @param {String} [sele1] - selection string for structure 1\n * @param {String} [sele2] - selection string for structure 2\n * @return {undefined}\n */\nfunction superpose (s1: Structure, s2: Structure, align = false, sele1 = '', sele2 = '') {\n let i: number\n let j: number\n let n: number\n let atoms1\n let atoms2\n\n if (align) {\n let _s1 = s1\n let _s2 = s2\n\n if (sele1 && sele2) {\n _s1 = s1.getView(new Selection(sele1))\n _s2 = s2.getView(new Selection(sele2))\n }\n\n const seq1 = _s1.getSequence()\n const seq2 = _s2.getSequence()\n\n // Log.log( seq1.join(\"\") );\n // Log.log( seq2.join(\"\") );\n\n const ali = new Alignment(seq1.join(''), seq2.join(''))\n\n ali.calc()\n ali.trace()\n\n // Log.log( \"superpose alignment score\", ali.score );\n\n // Log.log( ali.ali1 );\n // Log.log( ali.ali2 );\n\n let _i, _j\n i = 0\n j = 0\n n = ali.ali1.length\n const aliIdx1: boolean[] = []\n const aliIdx2: boolean[] = []\n\n for (let l = 0; l < n; ++l) {\n const x = ali.ali1[ l ]\n const y = ali.ali2[ l ]\n\n _i = 0\n _j = 0\n\n if (x === '-') {\n aliIdx2[ j ] = false\n } else {\n aliIdx2[ j ] = true\n _i = 1\n }\n\n if (y === '-') {\n aliIdx1[ i ] = false\n } else {\n aliIdx1[ i ] = true\n _j = 1\n }\n\n i += _i\n j += _j\n }\n\n // Log.log( i, j );\n\n // Log.log( aliIdx1 );\n // Log.log( aliIdx2 );\n\n const _atoms1: number[] = []\n const _atoms2: number[] = []\n const ap1 = _s1.getAtomProxy()\n const ap2 = _s2.getAtomProxy()\n\n i = 0\n _s1.eachResidue(function (r) {\n if (r.traceAtomIndex === undefined ||\n r.traceAtomIndex !== r.getAtomIndexByName('CA')) return\n\n if (aliIdx1[ i ]) {\n ap1.index = r.getAtomIndexByName('CA')! // TODO\n _atoms1.push(ap1.x, ap1.y, ap1.z)\n }\n i += 1\n })\n\n i = 0\n _s2.eachResidue(function (r) {\n if (r.traceAtomIndex === undefined ||\n r.traceAtomIndex !== r.getAtomIndexByName('CA')) return\n\n if (aliIdx2[ i ]) {\n ap2.index = r.getAtomIndexByName('CA')! // TODO\n _atoms2.push(ap2.x, ap2.y, ap2.z)\n }\n i += 1\n })\n\n atoms1 = new Float32Array(_atoms1)\n atoms2 = new Float32Array(_atoms2)\n } else {\n const sviewCa1 = s1.getView(new Selection(`${sele1} and .CA`))\n const sviewCa2 = s2.getView(new Selection(`${sele2} and .CA`))\n\n atoms1 = sviewCa1\n atoms2 = sviewCa2\n }\n\n const superpose = new Superposition(atoms1, atoms2)\n const result = superpose.transform(s1)\n s1.refreshPosition()\n return result\n}\n\nexport {\n superpose\n}\n","/**\n * @file Sturucture Component\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { ComponentRegistry, MeasurementDefaultParams } from '../globals'\nimport {\n defaults, /*deepEqual, */createRingBuffer, RingBuffer, createSimpleDict, SimpleDict\n} from '../utils'\nimport { smoothstep } from '../math/math-utils'\nimport Component, { ComponentSignals, ComponentDefaultParameters } from './component'\nimport RepresentationCollection from './representation-collection'\nimport TrajectoryElement from './trajectory-element'\nimport RepresentationElement from './representation-element'\nimport { makeTrajectory } from '../trajectory/trajectory-utils'\nimport { TrajectoryParameters } from '../trajectory/trajectory'\nimport Selection from '../selection/selection'\nimport Structure from '../structure/structure'\nimport StructureView from '../structure/structure-view'\nimport { superpose } from '../align/align-utils'\nimport Stage from '../stage/stage'\nimport StructureRepresentation, { StructureRepresentationParameters } from '../representation/structure-representation'\nimport AtomProxy from '../proxy/atom-proxy'\nimport { Vector3, Box3 } from 'three';\nimport { AngleRepresentationParameters } from '../representation/angle-representation';\nimport { AxesRepresentationParameters } from '../representation/axes-representation';\nimport { BallAndStickRepresentationParameters } from '../representation/ballandstick-representation';\nimport { CartoonRepresentationParameters } from '../representation/cartoon-representation';\nimport { ContactRepresentationParameters } from '../representation/contact-representation';\nimport { DihedralRepresentationParameters } from '../representation/dihedral-representation';\nimport { DihedralHistogramRepresentationParameters } from '../representation/dihedral-histogram-representation';\nimport { DistanceRepresentationParameters } from '../representation/distance-representation';\nimport { HyperballRepresentationParameters } from '../representation/hyperball-representation';\nimport { LabelRepresentationParameters } from '../representation/label-representation';\nimport { LineRepresentationParameters } from '../representation/line-representation';\nimport { PointRepresentationParameters } from '../representation/point-representation';\nimport { SurfaceRepresentationParameters } from '../representation/surface-representation';\nimport { RibbonRepresentationParameters } from '../representation/ribbon-representation';\nimport { RocketRepresentationParameters } from '../representation/rocket-representation';\nimport { TraceRepresentationParameters } from '../representation/trace-representation';\nimport { UnitcellRepresentationParameters } from '../representation/unitcell-representation';\nimport { SliceRepresentationParameters } from '../representation/slice-representation'\nimport { MolecularSurfaceRepresentationParameters } from '../representation/molecularsurface-representation'\nimport { DotRepresentationParameters } from '../representation/dot-representation'\n\nexport type StructureRepresentationType = keyof StructureRepresentationParametersMap\n\ninterface StructureRepresentationParametersMap {\n 'angle': AngleRepresentationParameters,\n 'axes' : AxesRepresentationParameters,\n 'backbone': BallAndStickRepresentationParameters,\n 'ball+stick': BallAndStickRepresentationParameters,\n 'base': BallAndStickRepresentationParameters,\n 'cartoon': CartoonRepresentationParameters,\n 'contact': ContactRepresentationParameters,\n 'dihedral': DihedralRepresentationParameters,\n 'dihedral-histogram': DihedralHistogramRepresentationParameters,\n 'distance': DistanceRepresentationParameters,\n 'dot': DotRepresentationParameters,\n 'helixorient': StructureRepresentationParameters,\n 'hyperball': HyperballRepresentationParameters,\n 'label': LabelRepresentationParameters,\n 'licorice': BallAndStickRepresentationParameters,\n 'line': LineRepresentationParameters,\n 'molecularsurface': MolecularSurfaceRepresentationParameters,\n 'point': PointRepresentationParameters,\n 'ribbon': RibbonRepresentationParameters,\n 'rocket': RocketRepresentationParameters,\n 'rope': CartoonRepresentationParameters,\n 'slice': SliceRepresentationParameters,\n 'spacefill': BallAndStickRepresentationParameters,\n 'surface': SurfaceRepresentationParameters,\n 'trace': TraceRepresentationParameters,\n 'tube': CartoonRepresentationParameters,\n 'unitcell': UnitcellRepresentationParameters,\n 'validation': StructureRepresentationParameters\n}\n\nexport const StructureComponentDefaultParameters = Object.assign({\n sele: '',\n defaultAssembly: ''\n}, ComponentDefaultParameters)\nexport type StructureComponentParameters = typeof StructureComponentDefaultParameters\n\nexport interface StructureComponentSignals extends ComponentSignals {\n trajectoryAdded: Signal // when a trajectory is added\n trajectoryRemoved: Signal // when a trajectory is removed\n defaultAssemblyChanged: Signal // on default assembly change\n}\n\n/**\n * Component wrapping a {@link Structure} object\n *\n * @example\n * // get a structure component by loading a structure file into the stage\n * stage.loadFile( \"rcsb://4opj\" ).then( function( structureComponent ){\n * structureComponent.addRepresentation( \"cartoon\" );\n * structureComponent.autoView();\n * } );\n */\nclass StructureComponent extends Component {\n readonly signals: StructureComponentSignals\n readonly parameters: StructureComponentParameters\n get defaultParameters () { return StructureComponentDefaultParameters }\n\n selection: Selection\n structureView: StructureView\n readonly trajList: TrajectoryElement[] = []\n\n pickBuffer: RingBuffer\n pickDict: SimpleDict\n lastPick?: number\n\n spacefillRepresentation: RepresentationElement\n distanceRepresentation: RepresentationElement\n angleRepresentation: RepresentationElement\n dihedralRepresentation: RepresentationElement\n\n measureRepresentations: RepresentationCollection\n\n constructor (stage: Stage, readonly structure: Structure, params: Partial = {}) {\n super(stage, structure, Object.assign({ name: structure.name }, params))\n\n this.signals = Object.assign(this.signals, {\n trajectoryAdded: new Signal(),\n trajectoryRemoved: new Signal(),\n defaultAssemblyChanged: new Signal()\n })\n\n this.initSelection(this.parameters.sele)\n\n //\n\n this.pickBuffer = createRingBuffer(4)\n this.pickDict = createSimpleDict()\n\n this.spacefillRepresentation = this.addRepresentation('spacefill', {\n sele: 'none',\n opacity: MeasurementDefaultParams.opacity,\n color: MeasurementDefaultParams.color,\n disablePicking: true,\n radiusType: 'data'\n }, true)\n\n this.distanceRepresentation = this.addRepresentation(\n 'distance', MeasurementDefaultParams, true\n )\n this.angleRepresentation = this.addRepresentation(\n 'angle', MeasurementDefaultParams, true\n )\n this.dihedralRepresentation = this.addRepresentation(\n 'dihedral', MeasurementDefaultParams, true\n )\n\n this.measureRepresentations = new RepresentationCollection([\n this.spacefillRepresentation,\n this.distanceRepresentation,\n this.angleRepresentation,\n this.dihedralRepresentation\n ])\n\n //\n\n this.setDefaultAssembly(this.parameters.defaultAssembly)\n\n this.structure.signals.refreshed.add(() => {\n this.updateRepresentations({ position: true })\n })\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'structure' }\n\n /**\n * Initialize selection\n * @private\n * @param {String} sele - selection string\n * @return {undefined}\n */\n initSelection (sele: string) {\n /**\n * Selection for {@link StructureComponent#structureView}\n * @private\n * @type {Selection}\n */\n this.selection = new Selection(sele)\n\n /**\n * View on {@link StructureComponent#structure}.\n * Change its selection via {@link StructureComponent#setSelection}.\n * @type {StructureView}\n */\n this.structureView = new StructureView(\n this.structure, this.selection\n )\n\n this.selection.signals.stringChanged.add(() => {\n this.structureView.setSelection(this.selection)\n\n this.rebuildRepresentations()\n this.rebuildTrajectories()\n })\n }\n\n /**\n * Set selection of {@link StructureComponent#structureView}\n * @param {String} string - selection string\n * @return {StructureComponent} this object\n */\n setSelection (string: string) {\n this.parameters.sele = string\n this.selection.setString(string)\n return this\n }\n\n /**\n * Set the default assembly\n * @param {String} value - assembly name\n * @return {undefined}\n */\n setDefaultAssembly (value:string) {\n // filter out non-exsisting assemblies\n if (this.structure.biomolDict[value] === undefined) value = ''\n // only set default assembly when changed\n if (this.parameters.defaultAssembly !== value) {\n const reprParams = { defaultAssembly: value }\n this.reprList.forEach(repr => repr.setParameters(reprParams))\n this.measureRepresentations.setParameters(reprParams)\n this.parameters.defaultAssembly = value\n this.signals.defaultAssemblyChanged.dispatch(value)\n }\n return this\n }\n\n /**\n * Rebuild all representations\n * @return {undefined}\n */\n rebuildRepresentations () {\n this.reprList.forEach((repr: RepresentationElement) => {\n repr.build()\n })\n this.measureRepresentations.build()\n }\n\n /**\n * Rebuild all trajectories\n * @return {undefined}\n */\n rebuildTrajectories () {\n this.trajList.forEach(trajComp => {\n trajComp.trajectory.setStructure(this.structureView)\n })\n }\n\n updateRepresentations (what: any) {\n super.updateRepresentations(what)\n this.measureRepresentations.update(what)\n }\n\n /**\n * Overrides {@link Component.updateRepresentationMatrices} \n * to also update matrix for measureRepresentations \n */\n updateRepresentationMatrices () {\n super.updateRepresentationMatrices()\n this.measureRepresentations.setParameters({ matrix: this.matrix })\n }\n\n addRepresentation (\n type: K,\n params: Partial|{defaultAssembly: string} = {},\n hidden = false\n ) {\n params.defaultAssembly = this.parameters.defaultAssembly\n\n const reprComp = this._addRepresentation(type, this.structureView, params, hidden)\n if (!hidden) {\n reprComp.signals.parametersChanged.add(() => this.measureUpdate())\n }\n return reprComp\n }\n\n /**\n * Add a new trajectory component to the structure\n */\n addTrajectory (trajPath = '', params: { [k: string]: any } = {}) {\n const traj = makeTrajectory(trajPath, this.structureView, params as TrajectoryParameters)\n\n const trajComp = new TrajectoryElement(this.stage, traj, params)\n this.trajList.push(trajComp)\n this.signals.trajectoryAdded.dispatch(trajComp)\n\n return trajComp\n }\n\n removeTrajectory (traj: TrajectoryElement) {\n const idx = this.trajList.indexOf(traj)\n if (idx !== -1) {\n this.trajList.splice(idx, 1)\n }\n\n traj.dispose()\n\n this.signals.trajectoryRemoved.dispatch(traj)\n }\n\n dispose () {\n // copy via .slice because side effects may change trajList\n this.trajList.slice().forEach(traj => traj.dispose())\n\n this.trajList.length = 0\n this.structure.dispose()\n this.measureRepresentations.dispose()\n\n super.dispose()\n }\n\n /**\n * Automatically center and zoom the component\n * @param {String|Integer} [sele] - selection string or duration if integer\n * @param {Integer} [duration] - duration of the animation, defaults to 0\n * @return {undefined}\n */\n autoView (sele?: string|number, duration?: number) {\n if (typeof sele === 'number') {\n duration = sele\n sele = ''\n }\n\n this.stage.animationControls.zoomMove(\n this.getCenter(sele),\n this.getZoom(sele),\n defaults(duration, 0)\n )\n }\n\n getBoxUntransformed (sele: string): Box3 {\n let bb\n\n if (sele) {\n bb = this.structureView.getBoundingBox(new Selection(sele))\n } else {\n bb = this.structureView.boundingBox\n }\n\n return bb\n }\n\n getCenterUntransformed (sele: string): Vector3 {\n if (sele && typeof sele === 'string') {\n return this.structure.atomCenter(new Selection(sele))\n } else {\n return this.structure.center\n }\n }\n\n superpose (component: StructureComponent, align: boolean, sele1: string, sele2: string) {\n superpose(\n this.structureView, component.structureView, align, sele1, sele2\n )\n\n this.updateRepresentations({ 'position': true })\n\n return this\n }\n\n getMaxRepresentationRadius (atomIndex: number) {\n let maxRadius = 0\n const atom = this.structure.getAtomProxy(atomIndex)\n this.eachRepresentation(reprElem => {\n if (reprElem.getVisibility()) {\n const repr: StructureRepresentation = reprElem.repr as any // TODO\n maxRadius = Math.max(repr.getAtomRadius(atom), maxRadius)\n }\n })\n return maxRadius\n }\n\n measurePick (atom: AtomProxy) {\n const pickCount = this.pickBuffer.count\n\n if (this.lastPick === atom.index && pickCount >= 1) {\n if (pickCount > 1) {\n const atomList = this.pickBuffer.data\n const atomListSorted = this.pickBuffer.data.sort()\n if (this.pickDict.has(atomListSorted)) {\n this.pickDict.del(atomListSorted)\n } else {\n this.pickDict.add(atomListSorted, atomList)\n }\n if (pickCount === 2) {\n this.distanceRepresentation.setParameters({\n atomPair: this.pickDict.values.filter(l => l.length === 2)\n })\n } else if (pickCount === 3) {\n this.angleRepresentation.setParameters({\n atomTriple: this.pickDict.values.filter(l => l.length === 3)\n })\n } else if (pickCount === 4) {\n this.dihedralRepresentation.setParameters({\n atomQuad: this.pickDict.values.filter(l => l.length === 4)\n })\n }\n }\n this.pickBuffer.clear()\n this.lastPick = undefined\n } else {\n if (!this.pickBuffer.has(atom.index)) {\n this.pickBuffer.push(atom.index)\n }\n this.lastPick = atom.index\n }\n\n this.measureUpdate()\n }\n\n measureClear () {\n this.pickBuffer.clear()\n this.lastPick = undefined\n this.spacefillRepresentation.setSelection('none')\n }\n\n measureBuild () {\n const md = this.measureData()\n this.distanceRepresentation.setParameters({ atomPair: md.distance })\n this.angleRepresentation.setParameters({ atomTriple: md.angle })\n this.dihedralRepresentation.setParameters({ atomQuad: md.dihedral })\n }\n\n measureUpdate () {\n const pickData = this.pickBuffer.data\n const radiusData: { [k: number]: number } = {}\n pickData.forEach(ai => {\n const r = Math.max(0.1, this.getMaxRepresentationRadius(ai))\n radiusData[ ai ] = r * (2.3 - smoothstep(0.1, 2, r))\n })\n this.spacefillRepresentation.setSelection(\n pickData.length ? ( '@' + pickData.join(',') ) : 'none'\n )\n if (pickData.length)\n this.spacefillRepresentation.setParameters({ radiusData })\n }\n\n measureData () {\n const pv = this.pickDict.values\n return {\n distance: pv.filter(l => l.length === 2),\n angle: pv.filter(l => l.length === 3),\n dihedral: pv.filter(l => l.length === 4)\n }\n }\n\n /**\n * Remove all measurements, optionally limit to distance, angle or dihedral\n */\n removeAllMeasurements (type?: MeasurementFlags) {\n const pd = this.pickDict\n const pv = pd.values\n const remove = function (len: number) {\n pv.filter(l => l.length === len).forEach(l => pd.del(l.slice().sort()))\n }\n if (!type || type & MeasurementFlags.Distance) remove(2)\n if (!type || type & MeasurementFlags.Angle) remove(3)\n if (!type || type & MeasurementFlags.Dihedral) remove(4)\n this.measureBuild()\n }\n\n /**\n * Remove a measurement given as a pair, triple, quad of atom indices\n */\n removeMeasurement (atomList: number[]) {\n this.pickDict.del(atomList.slice().sort())\n this.measureBuild()\n }\n\n /**\n * Add a measurement given as a pair, triple, quad of atom indices\n */\n addMeasurement (atomList: number[]) {\n if (atomList.length < 2 || atomList.length > 4) return\n const atomListSorted = atomList.slice().sort()\n if (!this.pickDict.has(atomListSorted)) {\n this.pickDict.add(atomListSorted, atomList)\n }\n this.measureBuild()\n }\n}\n\nexport const enum MeasurementFlags {\n Distance = 0x1,\n Angle = 0x2,\n Dihedral = 0x4\n}\n\nComponentRegistry.add('structure', StructureComponent)\nComponentRegistry.add('structureview', StructureComponent)\n\nexport default StructureComponent\n","/**\n * @file Trajectory Utils\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Frames from './frames'\nimport { TrajectoryParameters } from './trajectory'\nimport FramesTrajectory from './frames-trajectory'\nimport StructureTrajectory from './structure-trajectory'\nimport RemoteTrajectory from './remote-trajectory'\nimport CallbackTrajectory from './callback-trajectory'\n\nexport function makeTrajectory (trajSrc: string|Frames, structure: Structure, params: TrajectoryParameters) {\n let traj\n\n if (trajSrc && trajSrc instanceof Frames) {\n traj = new FramesTrajectory(trajSrc, structure, params)\n } else if (!trajSrc && structure.frames) {\n traj = new StructureTrajectory(trajSrc, structure, params)\n } else if (trajSrc && typeof trajSrc === 'function') {\n traj = new CallbackTrajectory(trajSrc, structure, params)\n } else {\n traj = new RemoteTrajectory(trajSrc, structure, params)\n }\n\n return traj\n}\n\n","/**\n * @file Surface Component\n * @author Alexander Rose \n * @private\n */\n\nimport { ComponentRegistry } from '../globals'\nimport Component, { ComponentParameters } from './component'\nimport Stage from '../stage/stage'\nimport Surface from '../surface/surface'\nimport { Vector3, Box3 } from 'three';\nimport RepresentationElement from './representation-element';\n\nexport type SurfaceRepresentationType = 'surface'|'dot'\n\n/**\n * Component wrapping a {@link Surface} object\n *\n * @example\n * // get a surface component by loading a surface file into the stage\n * stage.loadFile( \"url/for/surface\" ).then( function( surfaceComponent ){\n * surfaceComponent.addRepresentation( \"surface\" );\n * surfaceComponent.autoView();\n * } );\n */\nclass SurfaceComponent extends Component {\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {Surface} surface - surface object to wrap\n * @param {ComponentParameters} params - component parameters\n */\n constructor (stage: Stage, readonly surface: Surface, params: Partial = {}) {\n super(stage, surface, Object.assign({ name: surface.name }, params))\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'surface' }\n\n /**\n * Add a new surface representation to the component\n * @param {String} type - the name of the representation, one of:\n * surface, dot.\n * @param {SurfaceRepresentationParameters} params - representation parameters\n * @return {RepresentationComponent} the created representation wrapped into\n * a representation component object\n */\n addRepresentation (type: SurfaceRepresentationType, params: { [k: string]: any } = {}): RepresentationElement {\n return this._addRepresentation(type, this.surface, params)\n }\n\n getBoxUntransformed (): Box3 {\n return this.surface.boundingBox\n }\n\n getCenterUntransformed (): Vector3 {\n return this.surface.center\n }\n\n dispose () {\n this.surface.dispose()\n super.dispose()\n }\n}\n\nComponentRegistry.add('surface', SurfaceComponent)\n\nexport default SurfaceComponent\n","/**\n * @file Volume Component\n * @author Alexander Rose \n * @private\n */\n\nimport { ComponentRegistry } from '../globals'\nimport Component, { ComponentParameters } from './component'\nimport Stage from '../stage/stage'\nimport Volume from '../surface/volume'\nimport { Box3, Vector3 } from 'three';\nimport RepresentationElement from './representation-element';\n\nexport type VolumeRepresentationType = 'surface'|'slice'|'dot'\n\n/**\n * Component wrapping a {@link Volume} object\n *\n * @example\n * // get a volume component by loading a volume file into the stage\n * stage.loadFile( \"url/for/volume\" ).then(function(volumeComponent){\n * volumeComponent.addRepresentation('surface');\n * volumeComponent.autoView();\n * });\n */\nclass VolumeComponent extends Component {\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {Volume} volume - volume object to wrap\n * @param {ComponentParameters} params - component parameters\n */\n constructor (stage: Stage, readonly volume: Volume, params: Partial = {}) {\n super(stage, volume, Object.assign({ name: volume.name }, params))\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'volume' }\n\n /**\n * Add a new volume representation to the component\n */\n addRepresentation (type: VolumeRepresentationType, params: { [k: string]: any } = {}): RepresentationElement {\n return this._addRepresentation(type, this.volume, params)\n }\n\n getBoxUntransformed (): Box3 {\n return this.volume.boundingBox\n }\n\n getCenterUntransformed (): Vector3 {\n return this.volume.center\n }\n\n dispose () {\n this.volume.dispose()\n\n super.dispose()\n }\n}\n\nComponentRegistry.add('volume', VolumeComponent)\n\nexport default VolumeComponent\n","/**\n * @file Component Collection\n * @author Alexander Rose \n * @private\n */\n\nimport Component from './component'\nimport Collection from './collection'\n\nclass ComponentCollection extends Collection {\n addRepresentation (name: string, params: any) {\n \treturn this.forEach((comp) => comp.addRepresentation(name, params))\n }\n\n autoView (duration: number) {\n return this.forEach((comp) => comp.autoView(duration))\n }\n}\n\nexport default ComponentCollection\n","/**\n * @file Stage\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3 } from 'three'\nimport { Signal } from 'signals'\n\nimport {\n Debug, Log, Mobile, ComponentRegistry, ParserRegistry\n} from '../globals'\nimport { defaults, createParams, updateParams } from '../utils'\nimport { degToRad, clamp, pclamp } from '../math/math-utils'\nimport Counter from '../utils/counter'\nimport Viewer from '../viewer/viewer'\nimport { ImageParameters } from '../viewer/viewer-utils'\nimport MouseObserver from './mouse-observer'\n\nimport TrackballControls from '../controls/trackball-controls'\nimport PickingControls from '../controls/picking-controls'\nimport ViewerControls from '../controls/viewer-controls'\nimport AnimationControls from '../controls/animation-controls'\nimport MouseControls, { MouseControlPreset } from '../controls/mouse-controls'\nimport KeyControls from '../controls/key-controls'\n\nimport PickingBehavior from './picking-behavior'\nimport MouseBehavior from './mouse-behavior'\nimport AnimationBehavior from './animation-behavior'\nimport KeyBehavior from './key-behavior'\n\nimport Component, { ComponentParameters } from '../component/component'\nimport RepresentationElement from '../component/representation-element'\nimport StructureComponent from '../component/structure-component'\nimport SurfaceComponent from '../component/surface-component'\nimport VolumeComponent from '../component/volume-component'\nimport ComponentCollection from '../component/component-collection'\nimport RepresentationCollection from '../component/representation-collection'\nimport { autoLoad, getFileInfo, LoaderParameters } from '../loader/loader-utils'\nimport { ParserParams } from '../loader/parser-loader'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Animation from '../animation/animation'\nimport Selection from '../selection/selection'\n\nimport Structure from '../structure/structure'\nimport Surface from '../surface/surface'\nimport Volume from '../surface/volume'\nimport Shape from '../geometry/shape'\nimport Script from '../script'\n\nfunction matchName (name: string|RegExp, object: { name: string }) {\n if (name instanceof RegExp) {\n return object.name.match(name) !== null\n } else {\n return object.name === name\n }\n}\n\nconst tmpZoomVector = new Vector3()\n\ndeclare global {\n interface Document {\n mozFullScreen: boolean\n mozFullScreenEnabled: boolean\n mozFullScreenElement: Element\n mozCancelFullScreen(): void\n\n msFullscreenEnabled: boolean\n msFullscreenElement: Element\n msExitFullscreen(): void\n }\n\n interface Element {\n mozRequestFullScreen(): void\n msRequestFullscreen(): void\n }\n}\n\n/**\n * Stage parameter object.\n * @typedef {Object} StageParameters - stage parameters\n * @property {Color} backgroundColor - background color\n * @property {Integer} sampleLevel - sampling level for antialiasing, between -1 and 5;\n * -1: no sampling, 0: only sampling when not moving\n * @property {Boolean} workerDefault - default value for useWorker parameter of representations\n * @property {Float} rotateSpeed - camera-controls rotation speed, between 0 and 10\n * @property {Float} zoomSpeed - camera-controls zoom speed, between 0 and 10\n * @property {Float} panSpeed - camera-controls pan speed, between 0 and 10\n * @property {Float} clipNear - position of camera near/front clipping plane\n * in percent of scene bounding box\n * @property {Float} clipFar - position of camera far/back clipping plane\n * in percent of scene bounding box\n * @property {Float} clipDist - camera clipping distance in Angstrom\n * @property {String} clipMode - how to interpret clipNear/Far and fogNear/Far values: \"scene\" for scene-relative, \"camera\" for camera-relative\n * @property {String} clipScale - \"relative\" or \"absolute\": interpret clipNear/Far and fogNear/Far as percentage of bounding box or absolute Angstroms (ignored when clipMode==camera)\n * @property {Float} fogNear - position of the start of the fog effect\n * in percent of scene bounding box\n * @property {Float} fogFar - position where the fog is in full effect\n * in percent of scene bounding box\n * @property {String} cameraType - type of camera, either 'persepective' or 'orthographic'\n * @property {Float} cameraFov - perspective camera field of view in degree, between 15 and 120\n * @property {Float} cameraEyeSep - stereo camera eye seperation\n * @property {Color} lightColor - point light color\n * @property {Float} lightIntensity - point light intensity\n * @property {Color} ambientColor - ambient light color\n * @property {Float} ambientIntensity - ambient light intensity\n * @property {Integer} hoverTimeout - timeout for hovering\n */\n\nexport interface StageSignals {\n parametersChanged: Signal\n fullscreenChanged: Signal\n componentAdded: Signal\n componentRemoved: Signal\n clicked: Signal\n hovered: Signal\n}\n\nexport type RenderQualityType = 'auto'|'low'|'medium'|'high'\n\nexport const StageDefaultParameters = {\n impostor: true,\n quality: 'medium' as RenderQualityType,\n workerDefault: true,\n sampleLevel: 0,\n backgroundColor: 'black' as string|number,\n rotateSpeed: 2.0,\n zoomSpeed: 1.2,\n panSpeed: 1.0,\n clipNear: 0,\n clipFar: 100,\n clipDist: 10,\n clipMode: 'scene',\n clipScale: 'relative',\n fogNear: 50,\n fogFar: 100,\n cameraFov: 40,\n cameraEyeSep: 0.3,\n cameraType: 'perspective' as 'perspective'|'orthographic'|'stereo',\n lightColor: 0xdddddd as string|number,\n lightIntensity: 1.0,\n ambientColor: 0xdddddd as string|number,\n ambientIntensity: 0.2,\n hoverTimeout: 0,\n tooltip: true,\n mousePreset: 'default' as MouseControlPreset\n}\nexport type StageParameters = typeof StageDefaultParameters\n\nexport interface StageLoadFileParams extends LoaderParameters {\n defaultRepresentation: boolean,\n assembly: string\n}\n\n/**\n * Stage class, central for creating molecular scenes with NGL.\n *\n * @example\n * var stage = new Stage( \"elementId\", { backgroundColor: \"white\" } );\n */\nclass Stage {\n signals: StageSignals = {\n parametersChanged: new Signal(),\n fullscreenChanged: new Signal(),\n componentAdded: new Signal(),\n componentRemoved: new Signal(),\n clicked: new Signal(),\n hovered: new Signal()\n }\n parameters: StageParameters\n\n /**\n * Counter that keeps track of various potentially long-running tasks,\n * including file loading and surface calculation.\n */\n tasks = new Counter()\n compList: Component[] = []\n defaultFileParams = {}\n logList: string[] = []\n\n transformComponent?: Component\n transformAtom?: AtomProxy\n\n viewer: Viewer\n tooltip: HTMLElement\n lastFullscreenElement: HTMLElement\n\n mouseObserver: MouseObserver\n viewerControls: ViewerControls\n trackballControls: TrackballControls\n pickingControls: PickingControls\n animationControls: AnimationControls\n mouseControls: MouseControls\n keyControls: KeyControls\n\n pickingBehavior: PickingBehavior\n mouseBehavior: MouseBehavior\n animationBehavior: AnimationBehavior\n keyBehavior: KeyBehavior\n\n spinAnimation: Animation\n rockAnimation: Animation\n\n constructor (idOrElement: string|HTMLElement, params: Partial = {}) {\n this.viewer = new Viewer(idOrElement)\n if (!this.viewer.renderer) return\n\n this.tooltip = document.createElement('div')\n Object.assign(this.tooltip.style, {\n display: 'none',\n position: 'fixed',\n zIndex: '1000000',\n pointerEvents: 'none',\n backgroundColor: 'rgba( 0, 0, 0, 0.6 )',\n color: 'lightgrey',\n padding: '8px',\n fontFamily: 'sans-serif'\n })\n this.viewer.container.appendChild(this.tooltip)\n\n this.mouseObserver = new MouseObserver(this.viewer.renderer.domElement)\n this.viewerControls = new ViewerControls(this)\n this.trackballControls = new TrackballControls(this)\n this.pickingControls = new PickingControls(this)\n this.animationControls = new AnimationControls(this)\n this.mouseControls = new MouseControls(this)\n this.keyControls = new KeyControls(this)\n\n this.pickingBehavior = new PickingBehavior(this)\n this.mouseBehavior = new MouseBehavior(this)\n this.animationBehavior = new AnimationBehavior(this)\n this.keyBehavior = new KeyBehavior(this)\n\n this.spinAnimation = this.animationControls.spin([ 0, 1, 0 ], 0.005)\n this.spinAnimation.pause(true)\n this.rockAnimation = this.animationControls.rock([ 0, 1, 0 ], 0.005)\n this.rockAnimation.pause(true)\n\n // must come after the viewer has been instantiated\n this.parameters = createParams(params, StageDefaultParameters)\n this.setParameters(this.parameters)\n\n this.viewer.animate()\n }\n\n /**\n * Set stage parameters\n */\n setParameters (params: Partial = {}) {\n updateParams(this.parameters, params)\n\n const p = params\n const tp = this.parameters\n\n const viewer = this.viewer\n const controls = this.trackballControls\n\n // apply parameters\n if (p.quality !== undefined) this.setQuality(tp.quality)\n if (p.impostor !== undefined) this.setImpostor(tp.impostor)\n if (p.rotateSpeed !== undefined) controls.rotateSpeed = tp.rotateSpeed\n if (p.zoomSpeed !== undefined) controls.zoomSpeed = tp.zoomSpeed\n if (p.panSpeed !== undefined) controls.panSpeed = tp.panSpeed\n if (p.mousePreset !== undefined) this.mouseControls.preset(tp.mousePreset)\n this.mouseObserver.setParameters({ hoverTimeout: tp.hoverTimeout })\n viewer.setClip(tp.clipNear, tp.clipFar, tp.clipDist, tp.clipMode, tp.clipScale)\n viewer.setFog(undefined, tp.fogNear, tp.fogFar)\n viewer.setCamera(tp.cameraType, tp.cameraFov, tp.cameraEyeSep)\n viewer.setSampling(tp.sampleLevel)\n viewer.setBackground(tp.backgroundColor)\n viewer.setLight(tp.lightColor, tp.lightIntensity, tp.ambientColor, tp.ambientIntensity)\n\n this.signals.parametersChanged.dispatch(this.getParameters())\n\n return this\n }\n\n log (msg: string) {\n console.log('STAGE LOG', msg)\n this.logList.push(msg)\n }\n\n /**\n * Get stage parameters\n */\n getParameters () {\n return Object.assign({}, this.parameters)\n }\n\n /**\n * Create default representations for the given component\n * @param {StructureComponent|SurfaceComponent} object - component to create the representations for\n * @return {undefined}\n */\n defaultFileRepresentation (component: Component) {\n if (component instanceof StructureComponent) {\n component.setSelection('/0')\n\n let atomCount, residueCount, instanceCount\n const structure = component.structure\n\n if (structure.biomolDict.BU1) {\n const assembly = structure.biomolDict.BU1\n atomCount = assembly.getAtomCount(structure)\n residueCount = assembly.getResidueCount(structure)\n instanceCount = assembly.getInstanceCount()\n component.setDefaultAssembly('BU1')\n } else {\n atomCount = structure.getModelProxy(0).atomCount\n residueCount = structure.getModelProxy(0).residueCount\n instanceCount = 1\n }\n\n let sizeScore = atomCount\n\n if (Mobile) {\n sizeScore *= 4\n }\n\n const backboneOnly = structure.atomStore.count / structure.residueStore.count < 2\n if (backboneOnly) {\n sizeScore *= 10\n }\n\n let colorScheme = 'chainname'\n let colorScale = 'RdYlBu'\n let colorReverse = false\n if (structure.getChainnameCount(new Selection('polymer and /0')) === 1) {\n colorScheme = 'residueindex'\n colorScale = 'Spectral'\n colorReverse = true\n }\n\n if (Debug) console.log(sizeScore, atomCount, instanceCount, backboneOnly)\n\n if (residueCount / instanceCount < 4) {\n component.addRepresentation('ball+stick', {\n colorScheme: 'element',\n radiusScale: 2.0,\n aspectRatio: 1.5,\n bondScale: 0.3,\n bondSpacing: 0.75,\n quality: 'auto'\n })\n } else if ((instanceCount > 5 && sizeScore > 15000) || sizeScore > 700000) {\n let scaleFactor = (\n Math.min(\n 2.0,\n Math.max(\n 0.1,\n 6000 / (sizeScore / instanceCount)\n )\n )\n )\n if (backboneOnly) scaleFactor = Math.min(scaleFactor, 0.5)\n\n component.addRepresentation('surface', {\n colorScheme, colorScale, colorReverse,\n sele: 'polymer',\n surfaceType: 'av',\n probeRadius: 1.4,\n scaleFactor: scaleFactor,\n useWorker: false\n })\n } else if (sizeScore > 250000) {\n component.addRepresentation('backbone', {\n colorScheme, colorScale, colorReverse,\n lineOnly: true\n })\n } else if (sizeScore > 100000) {\n component.addRepresentation('backbone', {\n colorScheme, colorScale, colorReverse,\n quality: 'low',\n disableImpostor: true,\n radiusScale: 2.0\n })\n } else if (sizeScore > 80000) {\n component.addRepresentation('backbone', {\n colorScheme, colorScale, colorReverse,\n radiusScale: 2.0\n })\n } else {\n component.addRepresentation('cartoon', {\n colorScheme, colorScale, colorReverse,\n radiusScale: 0.7,\n aspectRatio: 5,\n quality: 'auto'\n })\n if (sizeScore < 50000) {\n component.addRepresentation('base', {\n colorScheme, colorScale, colorReverse,\n quality: 'auto'\n })\n }\n component.addRepresentation('ball+stick', {\n sele: 'ligand',\n colorScheme: 'element',\n radiusScale: 2.0,\n aspectRatio: 1.5,\n bondScale: 0.3,\n bondSpacing: 0.75,\n quality: 'auto'\n })\n }\n\n // add frames as trajectory\n if (component.structure.frames.length) {\n component.addTrajectory()\n }\n } else if (component instanceof SurfaceComponent) {\n component.addRepresentation('surface')\n } else if (component instanceof VolumeComponent) {\n component.addRepresentation('surface')\n }\n\n this.tasks.onZeroOnce(this.autoView, this)\n }\n\n /**\n * Load a file onto the stage\n *\n * @example\n * // load from URL\n * stage.loadFile( \"http://files.rcsb.org/download/5IOS.cif\" );\n *\n * @example\n * // load binary data in CCP4 format via a Blob\n * var binaryBlob = new Blob( [ ccp4Data ], { type: 'application/octet-binary'} );\n * stage.loadFile( binaryBlob, { ext: \"ccp4\" } );\n *\n * @example\n * // load string data in PDB format via a Blob\n * var stringBlob = new Blob( [ pdbData ], { type: 'text/plain'} );\n * stage.loadFile( stringBlob, { ext: \"pdb\" } );\n *\n * @example\n * // load a File object\n * stage.loadFile( file );\n *\n * @example\n * // load from URL and add a 'ball+stick' representation with double/triple bonds\n * stage.loadFile( \"http://files.rcsb.org/download/1crn.cif\" ).then( function( comp ){\n * comp.addRepresentation( \"ball+stick\", { multipleBond: true } );\n * } );\n *\n * @param {String|File|Blob} path - either a URL or an object containing the file data\n * @param {LoaderParameters} params - loading parameters\n * @param {Boolean} params.asTrajectory - load multi-model structures as a trajectory\n * @return {Promise} A Promise object that resolves to a {@link StructureComponent},\n * a {@link SurfaceComponent} or a {@link ScriptComponent} object,\n * depending on the type of the loaded file.\n */\n loadFile (path: string|File|Blob, params: Partial = {}) {\n const p = Object.assign({}, this.defaultFileParams, params)\n const name = getFileInfo(path).name\n\n this.tasks.increment()\n this.log(`loading file '${name}'`)\n\n const onLoadFn = (object: Structure|Surface|Volume) => {\n this.log(`loaded '${name}'`)\n\n const component = this.addComponentFromObject(object, p)\n if (p.defaultRepresentation) {\n this.defaultFileRepresentation(component as Component)\n }\n this.tasks.decrement()\n\n return component\n }\n\n const onErrorFn = (e: Error|string) => {\n this.tasks.decrement()\n const errorMsg = `error loading file: '${e}'`\n this.log(errorMsg)\n throw errorMsg // throw so it can be catched\n }\n\n const ext = defaults(p.ext, getFileInfo(path).ext)\n let promise: Promise\n\n if (ParserRegistry.isTrajectory(ext)) {\n promise = Promise.reject(\n new Error(`loadFile: ext '${ext}' is a trajectory and must be loaded into a structure component`)\n )\n } else {\n promise = autoLoad(path, p)\n }\n\n return promise.then(onLoadFn, onErrorFn)\n }\n\n loadScript (path: string|File|Blob) {\n const name = getFileInfo(path).name\n\n this.log(`loading script '${name}'`)\n\n return autoLoad(path).then(\n (script: Script) => {\n this.tasks.increment()\n this.log(`running script '${name}'`)\n script.run(this).then(() => {\n this.tasks.decrement()\n this.log(`finished script '${name}'`)\n })\n this.log(`called script '${name}'`)\n },\n (error: Error|string) => {\n this.tasks.decrement()\n const errorMsg = `errored script '${name}' \"${error}\"`\n this.log(errorMsg)\n throw errorMsg // throw so it can be catched\n }\n )\n }\n\n /**\n * Add the given component to the stage\n * @param {Component} component - the component to add\n * @return {undefined}\n */\n addComponent (component: Component) {\n if (!component) {\n Log.warn('Stage.addComponent: no component given')\n return\n }\n\n this.compList.push(component)\n this.signals.componentAdded.dispatch(component)\n }\n\n /**\n * Create a component from the given object and add to the stage\n */\n addComponentFromObject (object: Structure|Surface|Volume|Shape, params: Partial = {}): void|Component {\n const CompClass = ComponentRegistry.get(object.type)\n\n if (CompClass) {\n const component = new CompClass(this, object, params)\n this.addComponent(component)\n return component\n }\n\n Log.warn('no component for object type', object.type)\n }\n\n /**\n * Remove the given component\n * @param {Component} component - the component to remove\n * @return {undefined}\n */\n removeComponent (component: Component) {\n const idx = this.compList.indexOf(component)\n if (idx !== -1) {\n this.compList.splice(idx, 1)\n component.dispose()\n this.signals.componentRemoved.dispatch(component)\n }\n }\n\n /**\n * Remove all components from the stage\n */\n removeAllComponents () {\n this.compList.slice().forEach(o => this.removeComponent(o))\n }\n\n /**\n * Handle any size-changes of the container element\n * @return {undefined}\n */\n handleResize () {\n this.viewer.handleResize()\n }\n\n /**\n * Set width and height\n * @param {String} width - CSS width value\n * @param {String} height - CSS height value\n * @return {undefined}\n */\n setSize (width: string, height: string) {\n const container = this.viewer.container\n\n if (container !== document.body) {\n if (width !== undefined) container.style.width = width\n if (height !== undefined) container.style.height = height\n this.handleResize()\n }\n }\n\n /**\n * Toggle fullscreen\n * @param {Element} [element] - document element to put into fullscreen,\n * defaults to the viewer container\n * @return {undefined}\n */\n toggleFullscreen (element: HTMLElement) {\n if (!document.fullscreenEnabled && !document.mozFullScreenEnabled &&\n !(document as any).webkitFullscreenEnabled && !document.msFullscreenEnabled\n ) {\n Log.log('fullscreen mode (currently) not possible')\n return\n }\n\n const self = this\n element = element || this.viewer.container\n this.lastFullscreenElement = element\n\n //\n\n function getFullscreenElement () {\n return document.fullscreenElement || document.mozFullScreenElement ||\n (document as any).webkitFullscreenElement || document.msFullscreenElement\n }\n\n function resizeElement () {\n if (!getFullscreenElement() && self.lastFullscreenElement) {\n const element = self.lastFullscreenElement\n element.style.width = element.dataset.normalWidth || ''\n element.style.height = element.dataset.normalHeight || ''\n\n document.removeEventListener('fullscreenchange', resizeElement)\n document.removeEventListener('mozfullscreenchange', resizeElement)\n document.removeEventListener('webkitfullscreenchange', resizeElement)\n document.removeEventListener('MSFullscreenChange', resizeElement)\n\n self.handleResize()\n self.signals.fullscreenChanged.dispatch(false)\n }\n }\n\n //\n\n if (!getFullscreenElement()) {\n element.dataset.normalWidth = element.style.width || ''\n element.dataset.normalHeight = element.style.height || ''\n element.style.width = window.screen.width + 'px'\n element.style.height = window.screen.height + 'px'\n\n if (element.requestFullscreen) {\n element.requestFullscreen()\n } else if (element.msRequestFullscreen) {\n element.msRequestFullscreen()\n } else if (element.mozRequestFullScreen) {\n element.mozRequestFullScreen()\n } else if ((element as any).webkitRequestFullscreen) {\n (element as any).webkitRequestFullscreen()\n }\n\n document.addEventListener('fullscreenchange', resizeElement)\n document.addEventListener('mozfullscreenchange', resizeElement)\n document.addEventListener('webkitfullscreenchange', resizeElement)\n document.addEventListener('MSFullscreenChange', resizeElement)\n\n this.handleResize()\n this.signals.fullscreenChanged.dispatch(true)\n\n // workaround for Safari\n setTimeout(function () { self.handleResize() }, 100)\n } else {\n if (document.exitFullscreen) {\n document.exitFullscreen()\n } else if (document.msExitFullscreen) {\n document.msExitFullscreen()\n } else if (document.mozCancelFullScreen) {\n document.mozCancelFullScreen()\n } else if ((document as any).webkitExitFullscreen) {\n (document as any).webkitExitFullscreen()\n }\n }\n }\n\n /**\n * Set spin\n * @param {Boolean} flag - if true start rocking and stop spinning\n * @return {undefined}\n */\n setSpin (flag: boolean) {\n if (flag) {\n this.spinAnimation.resume(true)\n this.rockAnimation.pause(true)\n } else {\n this.spinAnimation.pause(true)\n }\n }\n\n /**\n * Set rock\n * @param {Boolean} flag - if true start rocking and stop spinning\n * @return {undefined}\n */\n setRock (flag: boolean) {\n if (flag) {\n this.rockAnimation.resume(true)\n this.spinAnimation.pause(true)\n } else {\n this.rockAnimation.pause(true)\n }\n }\n\n /**\n * Toggle spin\n * @return {undefined}\n */\n toggleSpin () {\n this.setSpin(this.spinAnimation.paused)\n }\n\n /**\n * Toggle rock\n * @return {undefined}\n */\n toggleRock () {\n this.setRock(this.rockAnimation.paused)\n }\n\n /**\n * Get the current focus from the current clipNear value expressed\n * as 0 (full view) to 100 (completely clipped)\n * Negative values may be returned in some cases.\n *\n * In 'camera' clipMode focus isn't applicable, this method returns 0.0\n *\n * @return {number} focus\n */\n getFocus () : number {\n const p = this.parameters\n if (p.clipMode !== 'scene') return 0.0\n\n let clipNear = p.clipNear\n if (p.clipScale === 'absolute') {\n clipNear = this.viewer.absoluteToRelative(clipNear)\n }\n return clipNear * 2\n }\n\n\n /**\n * Set the focus, a value of 0 sets clipping planes to show full scene,\n * while a value of 100 will compltely clip the scene.\n *\n * @param {number} value focus\n */\n setFocus (value: number) {\n if (this.parameters.clipMode !== 'scene') return\n\n let clipNear\n let clipFar\n let fogNear\n let fogFar\n\n if (this.parameters.clipScale === 'relative') {\n clipNear = clamp(value / 2.0, 0.0, 49.9)\n clipFar = 100 - clipNear\n fogNear = 50\n fogFar = pclamp(2 * clipFar - 50)\n\n } else {\n clipNear = this.viewer.relativeToAbsolute(value / 2.0)\n clipFar = clipNear\n fogNear = 0\n fogFar = 2 * clipFar\n }\n\n this.setParameters({ clipNear, clipFar, fogNear, fogFar })\n }\n\n getZoomForBox (boundingBox: Box3) {\n const bbSize = boundingBox.getSize(tmpZoomVector)\n const maxSize = Math.max(bbSize.x, bbSize.y, bbSize.z)\n const minSize = Math.min(bbSize.x, bbSize.y, bbSize.z)\n let distance = maxSize + Math.sqrt(minSize)\n\n const fov = degToRad(this.viewer.perspectiveCamera.fov)\n const width = this.viewer.width\n const height = this.viewer.height\n const aspect = width / height\n const aspectFactor = (height < width ? 1 : aspect)\n\n distance = Math.abs(\n ((distance * 0.5) / aspectFactor) / Math.sin(fov / 2)\n )\n distance += this.parameters.clipDist\n return -distance\n }\n\n getBox () {\n return this.viewer.boundingBox\n }\n\n getZoom () {\n return this.getZoomForBox(this.getBox())\n }\n\n getCenter (optionalTarget?: Vector3) {\n return this.getBox().getCenter(optionalTarget || new Vector3())\n }\n\n /**\n * Add a zoom and a move animation with automatic targets\n * @param {Integer} duration - animation time in milliseconds\n * @return {undefined}\n */\n autoView (duration?: number) {\n this.animationControls.zoomMove(\n this.getCenter(),\n this.getZoom(),\n defaults(duration, 0)\n )\n }\n\n /**\n * Make image from what is shown in a viewer canvas\n */\n makeImage (params: Partial = {}) {\n return new Promise((resolve, reject) => {\n this.tasks.onZeroOnce(() => {\n this.tasks.increment()\n this.viewer.makeImage(params).then(blob => {\n this.tasks.decrement()\n resolve(blob)\n }).catch(e => {\n this.tasks.decrement()\n reject(e)\n })\n })\n })\n }\n\n setImpostor (value: boolean) {\n this.parameters.impostor = value\n\n const types = [\n 'spacefill', 'ball+stick', 'licorice', 'hyperball',\n 'backbone', 'rocket', 'helixorient', 'contact', 'distance',\n 'dot'\n ]\n\n this.eachRepresentation(function (reprElem) {\n if (!types.includes(reprElem.getType())) return\n\n const p = reprElem.getParameters() as any // TODO\n p.disableImpostor = !value\n reprElem.build(p)\n })\n }\n\n setQuality (value: RenderQualityType) {\n this.parameters.quality = value\n\n const types = [\n 'tube', 'cartoon', 'ribbon', 'trace', 'rope'\n ]\n\n const impostorTypes = [\n 'spacefill', 'ball+stick', 'licorice', 'hyperball',\n 'backbone', 'rocket', 'helixorient', 'contact', 'distance',\n 'dot'\n ]\n\n this.eachRepresentation(function (repr) {\n const p = repr.getParameters() as any // TODO\n\n if (!types.includes(repr.getType())) {\n if (!impostorTypes.includes(repr.getType())) return\n\n if (!p.disableImpostor) {\n (repr.repr as any).quality = value // TODO\n return\n }\n }\n\n p.quality = value\n repr.build(p)\n })\n }\n\n /**\n * Iterator over each component and executing the callback\n */\n eachComponent (callback: (comp: Component) => void, type?: string) {\n this.compList.slice().forEach(comp => {\n if (type === undefined || type === comp.type) callback(comp)\n })\n }\n\n /**\n * Iterator over each representation and executing the callback\n */\n eachRepresentation (callback: (reprElem: RepresentationElement, comp: Component) => void, type?: string) {\n this.eachComponent(comp => {\n comp.reprList.slice().forEach(reprElem => {\n if (type === undefined || type === reprElem.getType()) callback(reprElem, comp)\n })\n })\n }\n\n /**\n * Get collection of components by name\n */\n getComponentsByName (name: string|RegExp) {\n const compList: Component[] = []\n\n this.eachComponent(comp => {\n if (name === undefined || matchName(name, comp)) compList.push(comp)\n })\n\n return new ComponentCollection(compList)\n }\n\n /**\n * Get collection of components by object\n */\n getComponentsByObject (object: Structure|Surface|Volume|Shape) {\n const compList: Component[] = []\n\n this.eachComponent(comp => {\n if (comp.object === object) compList.push(comp)\n })\n\n return new ComponentCollection(compList)\n }\n\n /**\n * Get collection of representations by name\n */\n getRepresentationsByName (name: string|RegExp) {\n const reprList: RepresentationElement[] = []\n\n this.eachRepresentation((repr, comp) => {\n if (name === undefined || matchName(name, repr)) reprList.push(repr)\n })\n\n return new RepresentationCollection(reprList)\n }\n\n measureClear () {\n this.eachComponent((sc: StructureComponent) => sc.measureClear(), 'structure')\n }\n\n measureUpdate () {\n this.eachComponent((sc: StructureComponent) => sc.measureUpdate(), 'structure')\n }\n\n /**\n * Cleanup when disposing of a stage object\n */\n dispose () {\n this.tasks.dispose()\n this.viewer.dispose()\n this.mouseObserver.dispose()\n }\n}\n\nexport default Stage\n","/**\n * @file Shape Component\n * @author Alexander Rose \n * @private\n */\n\nimport { ComponentRegistry } from '../globals'\nimport Component, { ComponentParameters } from './component'\nimport Stage from '../stage/stage'\nimport Shape from '../geometry/shape'\nimport { Vector3, Box3 } from 'three';\nimport RepresentationElement from './representation-element';\n\nexport type ShapeRepresentationType = 'buffer'\n\n/**\n * Component wrapping a {@link Shape} object\n *\n * @example\n * // get a shape component by adding a shape object to the stage\n * var shape = new NGL.Shape( \"shape\" );\n * shape.addSphere( [ 0, 0, 0 ], [ 1, 0, 0 ], 1.5 );\n * var shapeComponent = stage.addComponentFromObject( shape );\n * shapeComponent.addRepresentation( \"buffer\" );\n */\nclass ShapeComponent extends Component {\n constructor (stage: Stage, readonly shape: Shape, params: Partial = {}) {\n super(stage, shape, Object.assign({ name: shape.name }, params))\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'shape' }\n\n /**\n * Add a new shape representation to the component\n * @param {String} type - the name of the representation, one of:\n * buffer.\n * @param {BufferRepresentationParameters} params - representation parameters\n * @return {RepresentationComponent} the created representation wrapped into\n * a representation component object\n */\n addRepresentation (type: ShapeRepresentationType, params: { [k: string]: any } = {}): RepresentationElement {\n return this._addRepresentation(type, this.shape, params)\n }\n\n getBoxUntransformed (): Box3 {\n return this.shape.boundingBox\n }\n\n getCenterUntransformed (): Vector3 {\n return this.shape.center\n }\n\n dispose () {\n this.shape.dispose()\n super.dispose()\n }\n}\n\nComponentRegistry.add('shape', ShapeComponent)\n\nexport default ShapeComponent\n","/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n}\r\n","/**\n * @file Atomindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\n/**\n * Color by atom index. The {@link AtomProxy.index} property is used for coloring.\n * Each {@link ModelProxy} of a {@link Structure} is colored seperately. The\n * `params.domain` parameter is ignored.\n *\n * __Name:__ _atomindex_\n *\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"ball+stick\", { colorScheme: \"atomindex\" } );\n * o.autoView();\n * } );\n */\nclass AtomindexColormaker extends Colormaker {\n scalePerModel: { [k: number]: ColormakerScale }\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rainbow'\n this.parameters.reverse = defaults(params.reverse, true)\n }\n\n this.scalePerModel = {}\n\n params.structure.eachModel((mp: ModelProxy) => {\n this.parameters.domain = [ mp.atomOffset, mp.atomEnd ]\n this.scalePerModel[ mp.index ] = this.getScale() // TODO\n })\n }\n\n /**\n * get color for an atom\n * @param {AtomProxy} atom - atom to get color for\n * @return {Integer} hex atom color\n */\n @manageColor\n atomColor (atom: AtomProxy) {\n return this.scalePerModel[ atom.modelIndex ](atom.index)\n }\n}\n\nColormakerRegistry.add('atomindex', AtomindexColormaker)\n\nexport default AtomindexColormaker\n","/**\n * @file Bfactor Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Selection from '../selection/selection'\n\n/**\n * Color by b-factor. The {@link AtomProxy.bfactor} property is used for coloring.\n * By default the min and max b-factor values are used for the scale`s domain.\n *\n * __Name:__ _bfactor_\n *\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"ball+stick\", { colorScheme: \"bfactor\" } );\n * o.autoView();\n * } );\n */\nclass BfactorColormaker extends Colormaker {\n bfactorScale: ColormakerScale\n\n constructor (params: { sele?: string } & StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'OrRd'\n }\n\n if (!params.domain) {\n let selection\n let min = Infinity\n let max = -Infinity\n\n if (params.sele) {\n selection = new Selection(params.sele)\n }\n\n params.structure.eachAtom(function (a) {\n const bfactor = a.bfactor\n min = Math.min(min, bfactor)\n max = Math.max(max, bfactor)\n }, selection)\n\n this.parameters.domain = [ min, max ]\n }\n\n this.bfactorScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.bfactorScale(a.bfactor)\n }\n}\n\nColormakerRegistry.add('bfactor', BfactorColormaker)\n\nexport default BfactorColormaker\n","/**\n * @file Chainid Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\nexport type ChainidDict = { [k: string]: number }\n\n/**\n * Color by chain id\n */\nclass ChainidColormaker extends Colormaker {\n chainidDictPerModel: { [k: number]: ChainidDict } = {}\n scalePerModel: { [k: number]: ColormakerScale } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'Spectral'\n }\n\n params.structure.eachModel((mp: ModelProxy) => {\n let i = 0\n const chainidDict: ChainidDict = {}\n mp.eachChain(function (cp: ChainProxy) {\n if (chainidDict[ cp.chainid ] === undefined) {\n chainidDict[ cp.chainid ] = i\n i += 1\n }\n })\n this.parameters.domain = [ 0, i - 1 ]\n this.chainidDictPerModel[ mp.index ] = chainidDict\n this.scalePerModel[ mp.index ] = this.getScale()\n })\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n const chainidDict = this.chainidDictPerModel[ a.modelIndex ]\n return this.scalePerModel[ a.modelIndex ](chainidDict[ a.chainid ])\n }\n}\n\nColormakerRegistry.add('chainid', ChainidColormaker)\n\nexport default ChainidColormaker\n","/**\n * @file Chainindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\n/**\n * Color by chain index\n */\nclass ChainindexColormaker extends Colormaker {\n scalePerModel: { [k: number]: ColormakerScale } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'Spectral'\n }\n\n params.structure.eachModel((mp: ModelProxy) => {\n this.parameters.domain = [ mp.chainOffset, mp.chainEnd ]\n this.scalePerModel[ mp.index ] = this.getScale()\n })\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.scalePerModel[ a.modelIndex ](a.chainIndex)\n }\n}\n\nColormakerRegistry.add('chainindex', ChainindexColormaker)\n\nexport default ChainindexColormaker\n","/**\n * @file Chainname Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\nexport type ChainnameDict = { [k: string]: number }\n\n/**\n * Color by chain name\n */\nclass ChainnameColormaker extends Colormaker {\n chainnameDictPerModel: { [k: number]: ChainnameDict } = {}\n scalePerModel: { [k: number]: ColormakerScale } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'Spectral'\n }\n\n params.structure.eachModel((mp: ModelProxy) => {\n let i = 0\n const chainnameDict: ChainnameDict = {}\n mp.eachChain(function (cp: ChainProxy) {\n if (chainnameDict[ cp.chainname ] === undefined) {\n chainnameDict[ cp.chainname ] = i\n i += 1\n }\n })\n this.parameters.domain = [ 0, i - 1 ]\n this.chainnameDictPerModel[ mp.index ] = chainnameDict\n this.scalePerModel[ mp.index ] = this.getScale()\n })\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n const chainnameDict = this.chainnameDictPerModel[ a.modelIndex ]\n return this.scalePerModel[ a.modelIndex ](chainnameDict[ a.chainname ])\n }\n}\n\nColormakerRegistry.add('chainname', ChainnameColormaker)\n\nexport default ChainnameColormaker\n","/**\n * @file Densityfit Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by validation density fit\n */\nclass DensityfitColormaker extends Colormaker {\n rsrzScale: ColormakerScale\n rsccScale: ColormakerScale\n\n rsrzDict: { [k: string]: number|undefined } = {}\n rsccDict: { [k: string]: number|undefined } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'RdYlBu'\n }\n\n this.rsrzScale = this.getScale({ domain: [ 2, 0 ] })\n this.rsccScale = this.getScale({ domain: [ 0.678, 1.0 ] })\n\n const val = params.structure.validation\n if (val) {\n this.rsrzDict = val.rsrzDict\n this.rsccDict = val.rsccDict\n }\n\n }\n\n @manageColor\n atomColor (atom: AtomProxy) {\n let sele = atom.resno + ''\n if (atom.inscode) sele += '^' + atom.inscode\n if (atom.chainname) sele += ':' + atom.chainname\n sele += '/' + atom.modelIndex\n\n const rsrz = this.rsrzDict[ sele ]\n if (rsrz !== undefined) {\n return this.rsrzScale(rsrz)\n }\n\n const rscc = this.rsccDict[ sele ]\n if (rscc !== undefined) {\n return this.rsccScale(rscc)\n }\n\n return 0x909090\n }\n}\n\nColormakerRegistry.add('densityfit', DensityfitColormaker)\n\nexport default DensityfitColormaker\n","/**\n * @file Atomindex Colormaker\n * @author Fred Ludlow \n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport SpatialHash from '../geometry/spatial-hash'\n\n// from CHARMM\nconst partialCharges: { [k: string]: { [k: string]: number } } = {\n 'ARG': {\n 'CD': 0.1,\n 'CZ': 0.5,\n 'NE': -0.1\n },\n 'ASN': {\n 'CG': 0.55,\n 'OD1': -0.55\n },\n 'ASP': {\n 'CB': -0.16,\n 'CG': 0.36,\n 'OD1': -0.6,\n 'OD2': -0.6\n },\n 'CYS': {\n 'CB': 0.19,\n 'SG': -0.19\n },\n 'GLN': {\n 'CD': 0.55,\n 'OE1': -0.55\n },\n 'GLU': {\n 'CD': 0.36,\n 'CG': -0.16,\n 'OE1': -0.6,\n 'OE2': -0.6\n },\n 'HIS': {\n 'CB': 0.1,\n 'CD2': 0.2,\n 'CE1': 0.45,\n 'CG': 0.15,\n 'ND1': 0.05,\n 'NE2': 0.05\n },\n 'LYS': {\n 'CE': 0.25,\n 'NZ': 0.75\n },\n 'MET': {\n 'CE': 0.06,\n 'CG': 0.06,\n 'SD': -0.12\n },\n 'PTR': {\n 'C': 0.55,\n 'CA': 0.1,\n 'CZ': 0.25,\n 'N': -0.35,\n 'O': -0.55,\n 'O1P': -0.85,\n 'O2P': -0.85,\n 'O3P': -0.85,\n 'OG1': -1.1,\n 'P': 1.4\n },\n 'SEP': {\n 'C': 0.55,\n 'CA': 0.1,\n 'CB': 0.25,\n 'N': -0.35,\n 'O': -0.55,\n 'O1P': -0.85,\n 'O2P': -0.85,\n 'O3P': -0.85,\n 'OG1': -1.1,\n 'P': 1.4\n },\n 'SER': {\n 'CB': 0.25,\n 'OG': -0.25\n },\n 'THR': {\n 'CB': 0.25,\n 'OG1': -0.25\n },\n 'TPO': {\n 'C': 0.55,\n 'CA': 0.1,\n 'CB': 0.25,\n 'N': -0.35,\n 'O': -0.55,\n 'OG1': -1.1,\n 'O1P': -0.85,\n 'O2P': -0.85,\n 'O3P': -0.85,\n 'P': 1.4\n },\n 'TRP': {\n 'CD1': 0.06,\n 'CD2': 0.1,\n 'CE2': -0.04,\n 'CE3': -0.03,\n 'CG': -0.03,\n 'NE1': -0.06\n },\n 'TYR': {\n 'CZ': 0.25,\n 'OH': -0.25\n },\n 'backbone': {\n 'C': 0.55,\n 'O': -0.55,\n 'N': -0.35,\n 'CA': 0.1\n }\n}\n\nconst maxRadius = 12.0\nconst nHBondDistance = 1.04\nconst nHCharge = 0.25\n\n/**\n * Populates position vector with location of implicit or explicit H\n * Returns position or undefined if not able to locate H\n *\n * @param {AtomProxy} ap - the nitrogen atom\n * @param {Vector3} [position] - optional target\n * @return {Vectors|undefined} the hydrogen atom position\n */\nfunction backboneNHPosition (ap: AtomProxy, position = new Vector3()) {\n let h = false\n let ca = false\n let c = false\n position.set(2 * ap.x, 2 * ap.y, 2 * ap.z)\n\n ap.eachBondedAtom(function (a2: AtomProxy) {\n // Any time we detect H, reset position and skip\n // future tests\n if (h) return\n if (a2.atomname === 'H') {\n position.set(a2.x, a2.y, a2.z)\n h = true\n return\n }\n if (!ca && a2.atomname === 'CA') {\n position.sub(a2 as any) // TODO\n ca = true\n } else if (!c && a2.atomname === 'C') {\n c = true\n position.sub(a2 as any) // TODO\n }\n })\n\n if (h) { return position }\n\n if (ca && c) {\n position.normalize()\n position.multiplyScalar(nHBondDistance)\n position.add(ap as any)\n return position\n }\n}\n\n/**\n * Takes an array of Vector3 objects and\n * converts to an object that looks like an AtomStore\n *\n * @param {Vector3[]} positions - array of positions\n * @return {Object} AtomStore-like object\n */\nfunction buildStoreLike (positions: Vector3[]) {\n const n = positions.length\n const x = new Float32Array(n)\n const y = new Float32Array(n)\n const z = new Float32Array(n)\n\n for (let i = 0; i < positions.length; i++) {\n const v = positions[ i ]\n x[ i ] = v.x\n y[ i ] = v.y\n z[ i ] = v.z\n }\n\n return { x: x, y: y, z: z, count: n }\n}\n\nfunction chargeForAtom (a: AtomProxy): number {\n if (a.partialCharge !== null) return a.partialCharge\n if (!a.isProtein()) { return 0.0 }\n return (\n (partialCharges[ a.resname ] &&\n partialCharges[ a.resname ][ a.atomname ]) ||\n partialCharges[ 'backbone' ][ a.atomname ] || 0.0\n )\n}\n\n/**\n * Color a surface by electrostatic charge. This is a highly approximate\n * calculation! The partial charges are CHARMM with hydrogens added to heavy\n * atoms and hydrogen positions generated for amides.\n *\n * __Name:__ _electrostatic_\n *\n * @example\n * stage.loadFile( \"rcsb://3dqb\" ).then( function( o ){\n * o.addRepresentation( \"surface\", { colorScheme: \"electrostatic\" } );\n * o.autoView();\n * } );\n */\nclass ElectrostaticColormaker extends Colormaker {\n scale: ColormakerScale\n hHash: SpatialHash\n hash: SpatialHash\n charges: Float32Array\n hStore: { x: Float32Array, y: Float32Array, z: Float32Array, count: number }\n atomProxy: AtomProxy\n\n delta = new Vector3()\n hCharges: number[] = []\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rwb'\n }\n if (!params.domain) {\n this.parameters.domain = [ -50, 50 ]\n }\n\n this.scale = this.getScale()\n\n this.charges = new Float32Array(params.structure.atomCount)\n const hPositions: Vector3[] = []\n\n params.structure.eachAtom((ap: AtomProxy) => {\n this.charges[ ap.index ] = chargeForAtom(ap) * ap.occupancy\n if (ap.atomname === 'N') {\n\n // In the specific case where N forms two bonds to\n // CA and C, try and place a dummy hydrogen\n\n if (ap.bondCount >= 3) return; // Skip if 3 bonds already (e.g. PRO)\n\n if (ap.bondToElementCount(1)) return; // Skip if any H specificed\n\n const hPos = backboneNHPosition(ap)\n if (hPos !== undefined) {\n hPositions.push(hPos)\n this.hCharges.push(nHCharge * ap.occupancy)\n }\n }\n })\n\n const bbox = params.structure.getBoundingBox()\n bbox.expandByScalar(nHBondDistance) // Worst case\n\n // SpatialHash requires x,y,z and count\n this.hStore = buildStoreLike(hPositions)\n this.hHash = new SpatialHash(this.hStore as any, bbox) // TODO\n this.hash = new SpatialHash(params.structure.atomStore, bbox)\n }\n\n @manageColor\n positionColor (v: Vector3) {\n\n const charges = this.charges\n const hCharges = this.hCharges\n\n let p = 0.0\n this.hash.eachWithin(v.x, v.y, v.z, maxRadius, (atomIndex, dSq) => {\n const charge = charges[atomIndex]\n if (charge === 0.0) return\n p += charge / dSq\n })\n\n this.hHash.eachWithin(v.x, v.y, v.z, maxRadius, (atomIndex, dSq) => {\n const charge = hCharges[atomIndex]\n if (charge === 0.0) return\n p += charge / dSq\n })\n\n return this.scale(p * 332) // 332 to convert to kcal/mol\n }\n}\n\nColormakerRegistry.add('electrostatic', ElectrostaticColormaker)\n\nexport default ElectrostaticColormaker\n","/**\n * @file Element Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Colormaker, { ColormakerParameters, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n// from Jmol http://jmol.sourceforge.net/jscolors/ (or 0xFFFFFF)\nconst ElementColors: { [k: string]: number } = {\n 'H': 0xFFFFFF,\n 'HE': 0xD9FFFF,\n 'LI': 0xCC80FF,\n 'BE': 0xC2FF00,\n 'B': 0xFFB5B5,\n 'C': 0x909090,\n 'N': 0x3050F8,\n 'O': 0xFF0D0D,\n 'F': 0x90E050,\n 'NE': 0xB3E3F5,\n 'NA': 0xAB5CF2,\n 'MG': 0x8AFF00,\n 'AL': 0xBFA6A6,\n 'SI': 0xF0C8A0,\n 'P': 0xFF8000,\n 'S': 0xFFFF30,\n 'CL': 0x1FF01F,\n 'AR': 0x80D1E3,\n 'K': 0x8F40D4,\n 'CA': 0x3DFF00,\n 'SC': 0xE6E6E6,\n 'TI': 0xBFC2C7,\n 'V': 0xA6A6AB,\n 'CR': 0x8A99C7,\n 'MN': 0x9C7AC7,\n 'FE': 0xE06633,\n 'CO': 0xF090A0,\n 'NI': 0x50D050,\n 'CU': 0xC88033,\n 'ZN': 0x7D80B0,\n 'GA': 0xC28F8F,\n 'GE': 0x668F8F,\n 'AS': 0xBD80E3,\n 'SE': 0xFFA100,\n 'BR': 0xA62929,\n 'KR': 0x5CB8D1,\n 'RB': 0x702EB0,\n 'SR': 0x00FF00,\n 'Y': 0x94FFFF,\n 'ZR': 0x94E0E0,\n 'NB': 0x73C2C9,\n 'MO': 0x54B5B5,\n 'TC': 0x3B9E9E,\n 'RU': 0x248F8F,\n 'RH': 0x0A7D8C,\n 'PD': 0x006985,\n 'AG': 0xC0C0C0,\n 'CD': 0xFFD98F,\n 'IN': 0xA67573,\n 'SN': 0x668080,\n 'SB': 0x9E63B5,\n 'TE': 0xD47A00,\n 'I': 0x940094,\n 'XE': 0x940094,\n 'CS': 0x57178F,\n 'BA': 0x00C900,\n 'LA': 0x70D4FF,\n 'CE': 0xFFFFC7,\n 'PR': 0xD9FFC7,\n 'ND': 0xC7FFC7,\n 'PM': 0xA3FFC7,\n 'SM': 0x8FFFC7,\n 'EU': 0x61FFC7,\n 'GD': 0x45FFC7,\n 'TB': 0x30FFC7,\n 'DY': 0x1FFFC7,\n 'HO': 0x00FF9C,\n 'ER': 0x00E675,\n 'TM': 0x00D452,\n 'YB': 0x00BF38,\n 'LU': 0x00AB24,\n 'HF': 0x4DC2FF,\n 'TA': 0x4DA6FF,\n 'W': 0x2194D6,\n 'RE': 0x267DAB,\n 'OS': 0x266696,\n 'IR': 0x175487,\n 'PT': 0xD0D0E0,\n 'AU': 0xFFD123,\n 'HG': 0xB8B8D0,\n 'TL': 0xA6544D,\n 'PB': 0x575961,\n 'BI': 0x9E4FB5,\n 'PO': 0xAB5C00,\n 'AT': 0x754F45,\n 'RN': 0x428296,\n 'FR': 0x420066,\n 'RA': 0x007D00,\n 'AC': 0x70ABFA,\n 'TH': 0x00BAFF,\n 'PA': 0x00A1FF,\n 'U': 0x008FFF,\n 'NP': 0x0080FF,\n 'PU': 0x006BFF,\n 'AM': 0x545CF2,\n 'CM': 0x785CE3,\n 'BK': 0x8A4FE3,\n 'CF': 0xA136D4,\n 'ES': 0xB31FD4,\n 'FM': 0xB31FBA,\n 'MD': 0xB30DA6,\n 'NO': 0xBD0D87,\n 'LR': 0xC70066,\n 'RF': 0xCC0059,\n 'DB': 0xD1004F,\n 'SG': 0xD90045,\n 'BH': 0xE00038,\n 'HS': 0xE6002E,\n 'MT': 0xEB0026,\n 'DS': 0xFFFFFF,\n 'RG': 0xFFFFFF,\n 'CN': 0xFFFFFF,\n 'UUT': 0xFFFFFF,\n 'FL': 0xFFFFFF,\n 'UUP': 0xFFFFFF,\n 'LV': 0xFFFFFF,\n 'UUH': 0xFFFFFF,\n\n 'D': 0xFFFFC0,\n 'T': 0xFFFFA0\n}\nconst DefaultElementColor = 0xFFFFFF\n\n/**\n * Color by element\n */\nclass ElementColormaker extends Colormaker {\n constructor (params: ColormakerParameters) {\n params.value = defaults(params.value, ElementColors.C)\n\n super(params)\n }\n\n\n @manageColor\n atomColor (a: AtomProxy) {\n const element = a.element\n\n if (element === 'C') {\n return this.parameters.value\n } else {\n return ElementColors[ element ] || DefaultElementColor\n }\n }\n}\n\nColormakerRegistry.add('element', ElementColormaker)\n\nexport default ElementColormaker\n","/**\n * @file Entityindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by entity index\n */\nclass EntityindexColormaker extends Colormaker {\n entityindexScale: ColormakerScale\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'Spectral'\n }\n if (!params.domain) {\n this.parameters.domain = [ 0, params.structure.entityList.length - 1 ]\n }\n\n this.entityindexScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.entityindexScale(a.entityIndex)\n }\n}\n\nColormakerRegistry.add('entityindex', EntityindexColormaker)\n\nexport default EntityindexColormaker\n","/**\n * @file Entitytype Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\nimport {\n PolymerEntity, NonPolymerEntity, MacrolideEntity, WaterEntity\n} from '../structure/structure-constants'\n\n/**\n * Color by entity type\n */\nclass EntitytypeColormaker extends Colormaker {\n @manageColor\n atomColor (a: AtomProxy) {\n const e = a.entity\n const et = e ? e.entityType : undefined\n switch (et) {\n case PolymerEntity:\n return 0x7fc97f\n case NonPolymerEntity:\n return 0xfdc086\n case MacrolideEntity:\n return 0xbeaed4\n case WaterEntity:\n return 0x386cb0\n default:\n return 0xffff99\n }\n }\n}\n\nColormakerRegistry.add('entitytype', EntitytypeColormaker)\n\nexport default EntitytypeColormaker\n","/**\n * @file Geoquality Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport { countSetBits } from '../math/math-utils'\n\n/**\n * Color by validation gometry quality\n */\nclass GeoqualityColormaker extends Colormaker {\n geoAtomDict: { [k: string]: { [k: string]: number } } = {}\n geoDict: { [k: string]: number|undefined } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n const val = params.structure.validation\n if (val) {\n this.geoAtomDict = val.geoAtomDict\n this.geoDict = val.geoDict\n }\n }\n\n @manageColor\n atomColor (atom: AtomProxy) {\n let sele = atom.resno + ''\n if (atom.inscode) sele += '^' + atom.inscode\n if (atom.chainname) sele += ':' + atom.chainname\n sele += '/' + atom.modelIndex\n\n let geoProblemCount\n const geoAtom = this.geoAtomDict[ sele ]\n if (geoAtom !== undefined) {\n const atomProblems: number = geoAtom[ atom.atomname ] || 0\n geoProblemCount = countSetBits(atomProblems)\n } else {\n geoProblemCount = this.geoDict[ sele ] || 0\n }\n\n if (geoProblemCount === 0) {\n return 0x2166ac\n } else if (geoProblemCount === 1) {\n return 0xfee08b\n } else if (geoProblemCount === 2) {\n return 0xf46d43\n } else if (geoProblemCount >= 3) {\n return 0xa50026\n }\n return 0x909090\n }\n}\n\nColormakerRegistry.add('geoquality', GeoqualityColormaker)\n\nexport default GeoqualityColormaker\n","/**\n * @file Hydrophobicity Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { ColormakerParameters, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\nimport {\n ResidueHydrophobicity, DefaultResidueHydrophobicity\n} from '../structure/structure-constants'\n\n/**\n * Color by hydrophobicity\n */\nclass HydrophobicityColormaker extends Colormaker {\n hfScale: ColormakerScale\n resHF: { [k: string]: number } = {}\n defaultResidueHydrophobicity: number\n\n constructor (params: ColormakerParameters) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'RdYlGn'\n }\n\n const idx = 0 // 0: DGwif, 1: DGwoct, 2: Oct-IF\n\n for (const name in ResidueHydrophobicity) {\n this.resHF[ name ] = ResidueHydrophobicity[ name ][ idx ]\n }\n this.defaultResidueHydrophobicity = DefaultResidueHydrophobicity[idx]\n\n if (!params.domain) {\n let min = Infinity\n let max = -Infinity\n\n for (const name in this.resHF) {\n const val = this.resHF[ name ]\n min = Math.min(min, val)\n max = Math.max(max, val)\n }\n\n this.parameters.domain = [ min, 0, max ]\n }\n\n this.hfScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.hfScale(this.resHF[ a.resname ] || this.defaultResidueHydrophobicity)\n }\n}\n\nColormakerRegistry.add('hydrophobicity', HydrophobicityColormaker)\n\nexport default HydrophobicityColormaker\n","/**\n * @file Modelindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by model index\n */\nclass ModelindexColormaker extends Colormaker {\n modelindexScale: ColormakerScale\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rainbow'\n }\n if (!params.domain) {\n this.parameters.domain = [ 0, params.structure.modelStore.count ]\n }\n\n this.modelindexScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.modelindexScale(a.modelIndex)\n }\n}\n\nColormakerRegistry.add('modelindex', ModelindexColormaker)\n\nexport default ModelindexColormaker\n","/**\n * @file Moleculetype Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\nimport {\n WaterType, IonType, ProteinType, RnaType, DnaType, SaccharideType\n} from '../structure/structure-constants'\n\n/**\n * Color by molecule type\n */\nclass MoleculetypeColormaker extends Colormaker {\n @manageColor\n atomColor (a: AtomProxy) {\n switch (a.residueType.moleculeType) {\n case WaterType:\n return 0x386cb0\n case IonType:\n return 0xf0027f\n case ProteinType:\n return 0xbeaed4\n case RnaType:\n return 0xfdc086\n case DnaType:\n return 0xbf5b17\n case SaccharideType:\n return 0x7fc97f\n default:\n return 0xffff99\n }\n }\n}\n\nColormakerRegistry.add('moleculetype', MoleculetypeColormaker)\n\nexport default MoleculetypeColormaker\n","/**\n * @file Occupancy Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { ColormakerParameters, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by occupancy\n */\nclass OccupancyColormaker extends Colormaker {\n occupancyScale: ColormakerScale\n\n constructor (params: ColormakerParameters) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'PuBu'\n }\n\n if (!params.domain) {\n this.parameters.domain = [ 0.0, 1.0 ]\n }\n\n this.occupancyScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.occupancyScale(a.occupancy)\n }\n}\n\nColormakerRegistry.add('occupancy', OccupancyColormaker)\n\nexport default OccupancyColormaker\n","/**\n * @file Partialcharge Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { ColormakerParameters, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by partial charge. The {@link AtomProxy.partialCharge} property is used for coloring.\n * The default domain is [-1, 1].\n *\n * __Name:__ _partialCharge_\n *\n * @example\n * stage.loadFile(\"rcsb://1crn\").then(function (o) {\n * o.addRepresentation(\"ball+stick\", {colorScheme: \"partialCharge\"});\n * o.autoView();\n * });\n */\nclass PartialchargeColormaker extends Colormaker {\n partialchargeScale: ColormakerScale\n\n constructor (params: ColormakerParameters) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rwb'\n }\n\n if (!params.domain) {\n this.parameters.domain = [-1, 1]\n }\n\n this.partialchargeScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.partialchargeScale(a.partialCharge || 0)\n }\n}\n\nColormakerRegistry.add('partialcharge', PartialchargeColormaker)\n\nexport default PartialchargeColormaker\n","/**\n * @file Random Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\n\nfunction randomColor () {\n return Math.random() * 0xFFFFFF\n}\n\n/**\n * Class by random color\n */\nclass RandomColormaker extends Colormaker {\n /**\n * get color for an atom\n * @return {Integer} random hex color\n */\n @manageColor\n atomColor () {\n return randomColor()\n }\n\n /**\n * get color for volume cell\n * @return {Integer} random hex color\n */\n @manageColor\n volumeColor () {\n return randomColor()\n }\n\n /**\n * get color for coordinates in space\n * @return {Integer} random hex color\n */\n @manageColor\n positionColor () {\n return randomColor()\n }\n}\n\nColormakerRegistry.add('random', RandomColormaker)\n\nexport default RandomColormaker\n","/**\n * @file Randomcoilindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by random coil index\n */\nclass RandomcoilindexColormaker extends Colormaker {\n rciScale: ColormakerScale\n rciDict: { [k: string]: number|undefined } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'RdYlBu'\n }\n\n this.rciScale = this.getScale({ domain: [ 0.6, 0 ] })\n\n const val = params.structure.validation\n if (val) this.rciDict = val.rciDict\n\n }\n\n @manageColor\n atomColor (atom: AtomProxy) {\n let sele = `[${atom.resname}]${atom.resno}`\n if (atom.chainname) sele += ':' + atom.chainname\n\n const rci = this.rciDict[ sele ]\n return rci !== undefined ? this.rciScale(rci) : 0x909090\n }\n}\n\nColormakerRegistry.add('randomcoilindex', RandomcoilindexColormaker)\n\nexport default RandomcoilindexColormaker\n","/**\n * @file Residueindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\n\n/**\n * Color by residue index\n */\nclass ResidueindexColormaker extends Colormaker {\n scalePerChain: { [k: number]: ColormakerScale } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rainbow'\n this.parameters.reverse = defaults(params.reverse, true)\n }\n\n params.structure.eachChain((cp: ChainProxy) => {\n this.parameters.domain = [ cp.residueOffset, cp.residueEnd ]\n this.scalePerChain[ cp.index ] = this.getScale()\n })\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.scalePerChain[ a.chainIndex ](a.residueIndex)\n }\n}\n\nColormakerRegistry.add('residueindex', ResidueindexColormaker)\n\nexport default ResidueindexColormaker\n","/**\n * @file Resname Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n// protein colors from Jmol http://jmol.sourceforge.net/jscolors/\nconst ResidueColors: { [k: string]: number } = {\n 'ALA': 0x8CFF8C,\n 'ARG': 0x00007C,\n 'ASN': 0xFF7C70,\n 'ASP': 0xA00042,\n 'CYS': 0xFFFF70,\n 'GLN': 0xFF4C4C,\n 'GLU': 0x660000,\n 'GLY': 0xFFFFFF,\n 'HIS': 0x7070FF,\n 'ILE': 0x004C00,\n 'LEU': 0x455E45,\n 'LYS': 0x4747B8,\n 'MET': 0xB8A042,\n 'PHE': 0x534C52,\n 'PRO': 0x525252,\n 'SER': 0xFF7042,\n 'THR': 0xB84C00,\n 'TRP': 0x4F4600,\n 'TYR': 0x8C704C,\n 'VAL': 0xFF8CFF,\n\n 'ASX': 0xFF00FF,\n 'GLX': 0xFF00FF,\n 'ASH': 0xFF00FF,\n 'GLH': 0xFF00FF,\n\n 'A': 0xDC143C, // Crimson Red\n 'G': 0x32CD32, // Lime Green\n 'I': 0x9ACD32, // Yellow Green\n 'X': 0x7CFC00, // Lawn Green\n 'C': 0xFFD700, // Gold Yellow\n 'T': 0x4169E1, // Royal Blue\n 'U': 0x40E0D0, // Turquoise Cyan\n 'D': 0x008B8B, // Dark Cyan\n\n 'DA': 0xDC143C,\n 'DG': 0x32CD32,\n 'DI': 0x9ACD32,\n 'DX': 0x7CFC00,\n 'DC': 0xFFD700,\n 'DT': 0x4169E1,\n 'DU': 0x40E0D0,\n 'DD': 0x008B8B\n}\nconst DefaultResidueColor = 0xFF00FF\n\n/**\n * Color by residue name\n */\nclass ResnameColormaker extends Colormaker {\n @manageColor\n atomColor (a: AtomProxy) {\n return ResidueColors[ a.resname ] || DefaultResidueColor\n }\n}\n\nColormakerRegistry.add('resname', ResnameColormaker)\n\nexport default ResnameColormaker\n","/**\n * @file Sstruc Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\n\n// from Jmol http://jmol.sourceforge.net/jscolors/ (shapely)\nconst StructureColors = {\n 'alphaHelix': 0xFF0080,\n 'threeTenHelix': 0xA00080,\n 'piHelix': 0x600080,\n 'betaStrand': 0xFFC800,\n 'betaTurn': 0x6080FF,\n 'coil': 0xFFFFFF,\n\n 'dna': 0xAE00FE,\n 'rna': 0xFD0162,\n\n 'carbohydrate': 0xA6A6FA\n}\nconst DefaultStructureColor = 0x808080\n\n/**\n * Color by secondary structure\n */\nclass SstrucColormaker extends Colormaker {\n residueProxy: ResidueProxy\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n this.residueProxy = params.structure.getResidueProxy()\n }\n\n @manageColor\n atomColor (ap: AtomProxy) {\n const sstruc = ap.sstruc\n const rp = this.residueProxy\n\n if (sstruc === 'h') {\n return StructureColors.alphaHelix\n } else if (sstruc === 'g') {\n return StructureColors.threeTenHelix\n } else if (sstruc === 'i') {\n return StructureColors.piHelix\n } else if (sstruc === 'e' || sstruc === 'b') {\n return StructureColors.betaStrand\n } else if (sstruc === 't') {\n return StructureColors.betaTurn\n } else {\n rp.index = ap.residueIndex\n if (rp.isDna()) {\n return StructureColors.dna\n } else if (rp.isRna()) {\n return StructureColors.rna\n } else if (rp.isSaccharide()) {\n return StructureColors.carbohydrate\n } else if (rp.isProtein() || sstruc === 's' || sstruc === 'l') {\n return StructureColors.coil\n } else {\n return DefaultStructureColor\n }\n }\n }\n}\n\nColormakerRegistry.add('sstruc', SstrucColormaker)\n\nexport default SstrucColormaker\n","/**\n * @file Colordata Colormaker\n * @author Fred Ludlow \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { ColorData, ColormakerScale, manageColor, StuctureColormakerParams } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport BondProxy from '../proxy/bond-proxy'\n\n\nclass StructuredataColormaker extends Colormaker {\n atomData?: ColorData['atomData']\n bondData?: ColorData['bondData']\n scale: ColormakerScale\n\n constructor(params: StuctureColormakerParams) {\n super(params)\n if (!params.scale) {\n this.parameters.scale = 'rwb'\n }\n this.atomData = this.parameters.data?.atomData\n this.bondData = this.parameters.data?.bondData\n this.scale = this.getScale(this.parameters)\n }\n\n @manageColor\n atomColor(a: AtomProxy) {\n const val = this.atomData?.[a.index]\n return (val !== undefined) ? this.scale(val) : this.parameters.value\n }\n\n @manageColor\n bondColor(bond: BondProxy, fromTo: boolean) {\n const val = this.bondData?.[bond.index]\n \n // Explicit bond data?\n if (val !== undefined) return this.scale(val)\n \n \n if (this.atomProxy) {\n this.atomProxy.index = fromTo ? bond.atomIndex1 : bond.atomIndex2\n return this.atomColor(this.atomProxy)\n } \n \n // Fallback\n return this.parameters.value\n }\n}\n\nColormakerRegistry.add('structuredata', StructuredataColormaker)\n\nexport default StructuredataColormaker","/**\n * @file Uniform Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\n\n/**\n * Color by uniform color\n */\nclass UniformColormaker extends Colormaker {\n @manageColor\n atomColor () {\n return this.parameters.value\n }\n\n @manageColor\n bondColor () {\n return this.parameters.value\n }\n\n @manageColor\n valueColor () {\n return this.parameters.value\n }\n\n @manageColor\n volumeColor () {\n return this.parameters.value\n }\n}\n\nColormakerRegistry.add('uniform', UniformColormaker)\n\nexport default UniformColormaker\n","/**\n * @file Value Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { VolumeColormakerParams, ColormakerScale, manageColor } from './colormaker'\n\n/**\n * Color by volume value\n */\nclass ValueColormaker extends Colormaker {\n valueScale: ColormakerScale\n\n constructor (params: VolumeColormakerParams) {\n super(params)\n this.valueScale = this.getScale()\n }\n\n /**\n * return the color for a volume cell\n * @param {Integer} index - volume cell index\n * @return {Integer} hex cell color\n */\n @manageColor\n volumeColor (index: number) {\n return this.valueScale((this.parameters.volume! as any).data[ index ]) // TODO\n }\n}\n\nColormakerRegistry.add('value', ValueColormaker)\n\nexport default ValueColormaker\n","/**\n * @file Volume Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\nimport { lerp } from '../math/math-utils'\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { VolumeColormakerParams, ColormakerScale, manageColor } from './colormaker'\n\n/**\n * Color by volume position\n */\nclass VolumeColormaker extends Colormaker {\n valueScale: ColormakerScale\n vec = new Vector3()\n\n constructor (params: VolumeColormakerParams) {\n super(params)\n this.valueScale = this.getScale()\n }\n\n /**\n * return the color for coordinates in space\n * @param {Vector3} coords - xyz coordinates\n * @return {Integer} hex coords color\n */\n @manageColor\n positionColor (coords: Vector3) {\n const volume = this.parameters.volume as any // TODO\n\n if (!volume || !volume.inverseMatrix) {\n return this.parameters.value\n }\n\n const vec = this.vec\n const data = volume.data\n const nx = volume.nx\n const ny = volume.ny\n const nxy = nx * ny\n\n vec.copy(coords)\n vec.applyMatrix4(volume.inverseMatrix)\n\n // position of grid cell\n const x0 = Math.floor(vec.x)\n const y0 = Math.floor(vec.y)\n const z0 = Math.floor(vec.z)\n\n // Indices\n const i = ((((z0 * ny) + y0) * nx) + x0)\n const i1 = i + 1\n const iy = i + nx\n const iz = i + nxy\n const i1y = iy + 1\n const i1z = iz + 1\n const iyz = iy + nxy\n const i1yz = iyz + 1\n\n // Values\n const v = data[ i ]\n const v1 = data[ i1 ]\n const vy = data[ iy ]\n const vz = data[ iz ]\n const v1y = data[ i1y ]\n const v1z = data[ i1z ]\n const vyz = data[ iyz ]\n const v1yz = data[ i1yz ]\n\n // Position of point in fraction of grid\n const xd = vec.x - x0\n const yd = vec.y - y0\n const zd = vec.z - z0\n\n // 1st Dimension\n const c00 = lerp(v, v1, xd)\n const c01 = lerp(vz, v1z, xd)\n const c10 = lerp(vy, v1y, xd)\n const c11 = lerp(vyz, v1yz, xd)\n\n // 2nd Dimension\n const c0 = lerp(c00, c10, yd)\n const c1 = lerp(c01, c11, yd)\n\n // 3rd Dimension\n const c = lerp(c0, c1, zd)\n\n return this.valueScale(c)\n }\n}\n\nColormakerRegistry.add('volume', VolumeColormaker)\n\nexport default VolumeColormaker\n","/**\n * @file Structure Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { ExtensionFragDepth, Mobile } from '../globals'\nimport { defaults } from '../utils'\nimport { RepresentationParameters, default as Representation } from './representation'\nimport Selection from '../selection/selection'\nimport RadiusFactory, { RadiusFactoryTypes, RadiusType } from '../utils/radius-factory'\nimport Structure from '../structure/structure'\nimport Viewer from '../viewer/viewer'\n// @ts-ignore: unused import Volume required for declaration only\nimport { Assembly, Volume } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport AtomProxy from '../proxy/atom-proxy';\nimport Polymer from '../proxy/polymer';\nimport Buffer from '../buffer/buffer';\nimport { AtomDataFields, BondDataFields, AtomDataParams, BondDataParams } from '../structure/structure-data';\n// @ts-ignore: unused import Surface required for declaration only\nimport Surface from '../surface/surface'\n\n/**\n * Structure representation parameter object.\n * @typedef {Object} StructureRepresentationParameters - structure representation parameters\n * @mixes RepresentationParameters\n *\n * @property {String} radiusType - A list of possible sources of the radius used for rendering the representation. The radius can be based on the *vdW radius*, the *covalent radius* or the *B-factor* value of the corresponding atom. Additionally the radius can be based on the *secondary structure*. Alternatively, when set to *size*, the value from the *radius* parameter is used for all atoms.\n * @property {Float} radius - A number providing a fixed radius used for rendering the representation.\n * @property {Float} scale - A number that scales the value defined by the *radius* or the *radiusType* parameter.\n * @property {String} assembly - name of an assembly object. Included are the asymmetric unit (*AU*) corresponding to the coordinates given in the structure file, biological assemblies from *PDB*, *mmCIF* or *MMTF* files (*BU1*, *BU2*, ...), a filled (crystallographic) unitcell of a given space group (*UNITCELL*), a supercell consisting of a center unitcell and its 26 direct neighbors (*SUPERCELL*). Set to *default* to use the default asemmbly of the structure object.\n */\nexport interface StructureRepresentationParameters extends RepresentationParameters {\n radiusType: string\n radius: number\n scale: number\n assembly: string\n}\nexport interface StructureRepresentationData {\n bufferList: Buffer[]\n polymerList?: Polymer[]\n sview?: StructureView | Structure\n [k: string]: any\n}\n/**\n * Structure representation\n * @interface\n */\nabstract class StructureRepresentation extends Representation {\n\n protected selection: Selection\n protected dataList: StructureRepresentationData[]\n structure: Structure\n structureView: StructureView\n\n protected radiusType: RadiusType\n protected radiusData: {[k: number]: number}\n protected radiusSize: number\n protected radiusScale: number\n protected assembly: string\n protected defaultAssembly: string\n protected needsBuild: boolean\n\n /**\n * Create Structure representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {StructureRepresentationParameters} params - structure representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n const p = params || {}\n\n super(structure, viewer, p)\n\n this.type = 'structure'\n\n this.parameters = Object.assign({\n radiusType: {\n type: 'select', options: RadiusFactory.types\n },\n radiusData: {\n type: 'hidden'\n },\n radiusSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n radiusScale: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n assembly: null,\n defaultAssembly: {\n type: 'hidden'\n }\n }, this.parameters)\n\n /**\n * @type {Selection}\n * @private\n */\n this.selection = new Selection(p.sele)\n\n /**\n * @type {Array}\n * @private\n */\n this.dataList = []\n\n /**\n * @type {Structure}\n */\n this.structure = structure\n\n /**\n * @type {StructureView}\n */\n this.structureView = this.structure.getView(this.selection)\n\n if (structure.biomolDict) {\n const biomolOptions:{[key: string]: string} = {\n 'default': 'default',\n '': (structure.unitcell ? 'AU' : 'FULL')\n }\n Object.keys(structure.biomolDict).forEach(function (k) {\n biomolOptions[ k ] = k\n })\n this.parameters.assembly = {\n type: 'select',\n options: biomolOptions,\n rebuild: true\n }\n } else {\n this.parameters.assembly = null\n }\n }\n\n get defaultScale () {\n return {\n 'vdw': 1.0,\n 'covalent': 1.0,\n 'bfactor': 0.01,\n 'sstruc': 1.0\n }\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'element')\n\n this.setRadius(p.radius, p)\n\n this.radiusType = defaults(p.radiusType, 'vdw')\n this.radiusData = defaults(p.radiusData, {})\n this.radiusSize = defaults(p.radiusSize, 1.0)\n this.radiusScale = defaults(p.radiusScale, 1.0)\n this.assembly = defaults(p.assembly, 'default')\n this.defaultAssembly = defaults(p.defaultAssembly, '')\n\n if (p.quality === 'auto') {\n p.quality = this.getQuality()\n }\n\n super.init(p)\n\n this.selection.signals.stringChanged.add((/* sele */) => {\n this.build()\n })\n\n this.build()\n }\n\n setRadius (value: string | number | undefined, p: Partial) {\n const types = Object.keys(RadiusFactoryTypes)\n\n if (typeof value === 'string' && types.includes(value.toLowerCase())) {\n p.radiusType = value\n } else if (value !== undefined) {\n p.radiusType = 'size'\n p.radiusSize = value\n }\n\n return this\n }\n\n getAssembly (): Assembly {\n const name = this.assembly === 'default' ? this.defaultAssembly : this.assembly\n return this.structure.biomolDict[ name ]\n }\n\n getQuality () {\n let atomCount\n const s = this.structureView\n const assembly = this.getAssembly()\n if (assembly) {\n atomCount = assembly.getAtomCount(s)\n } else {\n atomCount = s.atomCount\n }\n if (Mobile) {\n atomCount *= 4\n }\n const backboneOnly = s.atomStore.count / s.residueStore.count < 2\n if (backboneOnly) {\n atomCount *= 10\n }\n\n if (atomCount < 15000) {\n return 'high'\n } else if (atomCount < 80000) {\n return 'medium'\n } else {\n return 'low'\n }\n }\n\n create () {\n if (this.structureView.atomCount === 0) return\n\n if (!this.structureView.hasCoords()) {\n this.needsBuild = true\n return\n } else {\n this.needsBuild = false\n }\n\n const assembly = this.getAssembly()\n\n if (assembly) {\n assembly.partList.forEach((part, i) => {\n const sview = part.getView(this.structureView)\n if (sview.atomCount === 0) return\n const data = this.createData(sview, i)\n if (data) {\n data.sview = sview\n data.instanceList = part.getInstanceList()\n this.dataList.push(data)\n }\n })\n } else {\n const data = this.createData(this.structureView, 0)\n if (data) {\n data.sview = this.structureView\n this.dataList.push(data)\n }\n }\n }\n\n abstract createData (sview: StructureView, k?: number): StructureRepresentationData|undefined\n\n update (what: AtomDataFields|BondDataFields) {\n if (this.lazy && !this.visible) {\n Object.assign(this.lazyProps.what, what)\n return\n }\n\n if (this.needsBuild) {\n this.build()\n return\n }\n\n this.dataList.forEach((data) => {\n if (data.bufferList.length > 0) {\n this.updateData(what, data)\n }\n }, this)\n }\n\n updateData (what?: AtomDataFields|BondDataFields, data?: any) {\n this.build()\n }\n\n getColorParams () {\n return {\n ...super.getColorParams(),\n structure: this.structure\n }\n }\n\n getRadiusParams (param?: any) {\n return {\n type: this.radiusType,\n scale: this.radiusScale,\n size: this.radiusSize,\n data: this.radiusData\n }\n }\n\n getAtomParams (what?: AtomDataFields, params?: AtomDataParams) {\n return Object.assign({\n what: what,\n colorParams: this.getColorParams(),\n radiusParams: this.getRadiusParams()\n }, params)\n }\n\n getBondParams (what?: BondDataFields, params?: BondDataParams) {\n return Object.assign({\n what: what,\n colorParams: this.getColorParams(),\n radiusParams: this.getRadiusParams()\n }, params)\n }\n\n getAtomRadius (atom: AtomProxy) {\n if (this.structureView.atomSet!.isSet(atom.index)) {\n const radiusFactory = new RadiusFactory(this.getRadiusParams())\n return radiusFactory.atomRadius(atom)\n }\n return 0\n }\n\n /**\n * Set representation parameters\n * @alias StructureRepresentation#setSelection\n * @param {String} string - selection string, see {@tutorial selection-language}\n * @param {Boolean} [silent] - don't trigger a change event in the selection\n * @return {StructureRepresentation} this object\n */\n setSelection (string: string, silent?: boolean) {\n this.selection.setString(string, silent)\n\n return this\n }\n\n /**\n * Set representation parameters\n * @alias StructureRepresentation#setParameters\n * @param {StructureRepresentationParameters} params - structure parameter object\n * @param {Object} [what] - buffer data attributes to be updated,\n * note that this needs to be implemented in the\n * derived classes. Generally it allows more\n * fine-grained control over updating than\n * forcing a rebuild.\n * @param {Boolean} what.position - update position data\n * @param {Boolean} what.color - update color data\n * @param {Boolean} [rebuild] - whether or not to rebuild the representation\n * @return {StructureRepresentation} this object\n */\n setParameters (params: Partial, what: AtomDataFields = {}, rebuild = false) {\n const p = params || {}\n\n this.setRadius(p.radius, p)\n\n if (p.radiusType !== undefined || p.radiusData !== undefined || p.radiusSize !== undefined || p.radiusScale !== undefined) {\n what.radius = true\n if (!ExtensionFragDepth || this.disableImpostor) {\n rebuild = true\n }\n }\n\n if (p.defaultAssembly !== undefined &&\n p.defaultAssembly !== this.defaultAssembly &&\n ((this.assembly === 'default' && p.assembly === undefined) ||\n p.assembly === 'default')\n ) {\n rebuild = true\n }\n\n super.setParameters(p, what, rebuild)\n\n return this\n }\n\n getParameters () {\n const params = Object.assign(\n super.getParameters(),\n {\n sele: this.selection ? this.selection.string : undefined,\n defaultAssembly: this.defaultAssembly\n }\n )\n\n return params\n }\n\n attach (callback: ()=> void) {\n const viewer = this.viewer\n const bufferList = this.bufferList\n\n this.dataList.forEach(function (data) {\n data.bufferList.forEach(function (buffer) {\n bufferList.push(buffer)\n viewer.add(buffer, data.instanceList)\n })\n })\n\n this.setVisibility(this.visible)\n callback()\n }\n\n clear () {\n this.dataList.length = 0\n\n super.clear()\n }\n\n dispose () {\n this.structureView.dispose()\n\n super.dispose()\n }\n}\n\nexport default StructureRepresentation\n","/**\n * @file Measurement Representation\n * @author Fred Ludlow \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { Color, Vector3, Matrix4 } from 'three'\n\nimport Selection from '../selection/selection'\nimport { Browser } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport { uniformArray, uniformArray3 } from '../math/array-utils'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { LabelRepresentationParameters } from './label-representation';\nimport TextBuffer, { TextBufferData } from '../buffer/text-buffer';\nimport { GenericColor } from '../types'\n\nexport interface LabelDataField {\n position?: boolean\n labelColor?: boolean\n labelSize?: boolean\n radius?: boolean\n labelText?: boolean\n}\n\n/**\n * Measurement representation parameter object.\n * @typedef {Object} MeasurementRepresentationParameters - measurement representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n *\n * @property {Float} labelSize - size of the distance label\n * @property {Color} labelColor - color of the distance label\n * @property {Boolean} labelVisible - visibility of the distance label\n * @property {Float} labelZOffset - offset in z-direction (i.e. in camera direction)\n */\nexport interface MeasurementRepresentationParameters extends StructureRepresentationParameters {\n labelVisible: boolean\n labelSize: number\n labelColor: GenericColor\n labelType: 'atomname'|'atomindex'|'occupancy'|'bfactor'|'serial'|'element'|'atom'|'resname'|'resno'|'res'|'text'|'qualified'\n labelText: string\n labelFormat: string\n labelGrouping: 'atom'|'residue'\n labelFontFamily: 'sans-serif'|'monospace'|'serif'\n labelFontStyle: 'normal'|'italic'\n labelFontWeight: 'normal'|'bold'\n labelsdf: boolean\n labelXOffset: number\n labelYOffset: number\n labelZOffset: number\n labelAttachment: 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n labelBorder: boolean\n labelBorderColor: GenericColor\n labelBorderWidth: number\n labelBackground: boolean\n labelBackgroundColor: GenericColor\n labelBackgroundMargin: number\n labelBackgroundOpacity: number\n labelFixedSize: boolean\n lineOpacity: number\n linewidth: number\n}\n\n/**\n * Measurement representation\n * @interface\n */\nabstract class MeasurementRepresentation extends StructureRepresentation {\n protected n: number\n protected labelVisible: boolean\n protected labelSize: number\n protected labelColor: GenericColor\n protected labelType: 'atomname'|'atomindex'|'occupancy'|'bfactor'|'serial'|'element'|'atom'|'resname'|'resno'|'res'|'text'|'qualified'\n protected labelText: string\n protected labelFormat: string\n protected labelGrouping: 'atom'|'residue'\n protected labelFontFamily: 'sans-serif'|'monospace'|'serif'\n protected labelFontStyle: 'normal'|'italic'\n protected labelFontWeight: 'normal'|'bold'\n protected labelsdf: boolean\n protected labelXOffset: number\n protected labelYOffset: number\n protected labelZOffset: number\n protected labelAttachment: 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n protected labelBorder: boolean\n protected labelBorderColor: GenericColor\n protected labelBorderWidth: number\n protected labelBackground: boolean\n protected labelBackgroundColor: GenericColor\n protected labelBackgroundMargin: number\n protected labelBackgroundOpacity: number\n protected labelFixedSize: boolean\n protected lineOpacity: number\n protected linewidth: number\n protected lineVisible: boolean\n\n protected textBuffer: TextBuffer\n /**\n * Handles common label settings and position logic for\n * distance, angle and dihedral representations\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.n = 0 // Subclass create sets value\n this.parameters = Object.assign({\n labelVisible: {\n type: 'boolean'\n },\n labelSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n labelColor: {\n type: 'color'\n },\n labelFontFamily: {\n type: 'select',\n options: {\n 'sans-serif': 'sans-serif',\n 'monospace': 'monospace',\n 'serif': 'serif'\n },\n buffer: 'fontFamily'\n },\n labelFontStyle: {\n type: 'select',\n options: {\n 'normal': 'normal',\n 'italic': 'italic'\n },\n buffer: 'fontStyle'\n },\n labelFontWeight: {\n type: 'select',\n options: {\n 'normal': 'normal',\n 'bold': 'bold'\n },\n buffer: 'fontWeight'\n },\n labelsdf: {\n type: 'boolean', buffer: 'sdf'\n },\n labelXOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: 'xOffset'\n },\n labelYOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: 'yOffset'\n },\n labelZOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: 'zOffset'\n },\n labelAttachment: {\n type: 'select',\n options: {\n 'bottom-left': 'bottom-left',\n 'bottom-center': 'bottom-center',\n 'bottom-right': 'bottom-right',\n 'middle-left': 'middle-left',\n 'middle-center': 'middle-center',\n 'middle-right': 'middle-right',\n 'top-left': 'top-left',\n 'top-center': 'top-center',\n 'top-right': 'top-right'\n },\n rebuild: true\n },\n labelBorder: {\n type: 'boolean', buffer: 'showBorder'\n },\n labelBorderColor: {\n type: 'color', buffer: 'borderColor'\n },\n labelBorderWidth: {\n type: 'number', precision: 2, max: 0.3, min: 0, buffer: 'borderWidth'\n },\n labelBackground: {\n type: 'boolean', rebuild: true\n },\n labelBackgroundColor: {\n type: 'color', buffer: 'backgroundColor'\n },\n labelBackgroundMargin: {\n type: 'number', precision: 2, max: 2, min: 0, rebuild: true\n },\n labelBackgroundOpacity: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: 'backgroundOpacity'\n },\n labelFixedSize: {\n type: 'boolean', buffer: 'fixedSize'\n },\n lineOpacity: {\n type: 'range', min: 0.0, max: 1.0, step: 0.01\n },\n linewidth: {\n type: 'integer', max: 50, min: 1, buffer: true\n }\n }, this.parameters, {\n flatShaded: null\n })\n }\n\n init (params: Partial) {\n const p = params || {}\n this.labelVisible = defaults(p.labelVisible, true)\n this.labelSize = defaults(p.labelSize, 2.0)\n this.labelColor = defaults(p.labelColor, 0xFFFFFF)\n this.labelFontFamily = defaults(p.labelFontFamily, 'sans-serif')\n this.labelFontStyle = defaults(p.labelFontstyle, 'normal')\n this.labelFontWeight = defaults(p.labelFontWeight, 'bold')\n this.labelsdf = defaults(p.labelsdf, Browser === 'Chrome')\n this.labelXOffset = defaults(p.labelXOffset, 0.0)\n this.labelYOffset = defaults(p.labelYOffset, 0.0)\n this.labelZOffset = defaults(p.labelZOffset, 0.5)\n this.labelAttachment = defaults(p.labelAttachment, 'bottom-left')\n this.labelBorder = defaults(p.labelBorder, false)\n this.labelBorderColor = defaults(p.labelBorderColor, 'lightgrey')\n this.labelBorderWidth = defaults(p.labelBorderWidth, 0.15)\n this.labelBackground = defaults(p.labelBackground, false)\n this.labelBackgroundColor = defaults(p.labelBackgroundColor, 'lightgrey')\n this.labelBackgroundMargin = defaults(p.labelBackgroundMargin, 0.5)\n this.labelBackgroundOpacity = defaults(p.labelBackgroundOpacity, 1.0)\n this.labelFixedSize = defaults(p.labelFixedSize, false)\n this.lineOpacity = defaults(p.lineOpacity, 1.0)\n this.linewidth = defaults(p.linewidth, 2)\n\n super.init(p)\n }\n\n // All measurements need to rebuild on position change\n update (what: LabelDataField) {\n if (what.position) {\n this.build()\n } else {\n super.update(what)\n }\n }\n\n updateData (what: LabelDataField & {[k: string]: any}, data: any) {\n const textData: TextBufferData | {} = {}\n if (!what || what.labelSize) {\n Object.assign(textData, {size: uniformArray(this.n, this.labelSize)})\n }\n\n if (!what || what.labelColor) {\n const c = new Color(this.labelColor)\n Object.assign(textData, {color: uniformArray3(this.n, c.r, c.g, c.b)})\n }\n\n this.textBuffer.setAttributes(textData as TextBufferData)\n }\n\n setParameters (params: Partial, what: LabelDataField = {}, rebuild = false) {\n if (params && params.labelSize) {\n what.labelSize = true\n }\n\n if (params && (params.labelColor || params.labelColor === 0x000000)) {\n what.labelColor = true\n rebuild = true\n }\n\n super.setParameters(params, what, rebuild)\n\n if (params && params.opacity !== undefined) {\n this.textBuffer.setParameters({ opacity: 1.0 }) // only opaque labels\n }\n\n if (params && params.labelVisible !== undefined) {\n this.setVisibility(this.visible)\n }\n\n return this\n }\n\n setVisibility (value: boolean, noRenderRequest?: boolean) {\n super.setVisibility(value, true)\n if (this.textBuffer) {\n this.textBuffer.setVisibility(\n this.labelVisible && this.visible\n )\n }\n\n if (!noRenderRequest) this.viewer.requestRender()\n\n return this\n }\n\n getLabelBufferParams (params: Partial = {}) {\n return super.getBufferParams(Object.assign({\n fontFamily: this.labelFontFamily,\n fontStyle: this.labelFontStyle,\n fontWeight: this.labelFontWeight,\n sdf: this.labelsdf,\n xOffset: this.labelXOffset,\n yOffset: this.labelYOffset,\n zOffset: this.labelZOffset,\n attachment: this.labelAttachment,\n showBorder: this.labelBorder,\n borderColor: this.labelBorderColor,\n borderWidth: this.labelBorderWidth,\n showBackground: this.labelBackground,\n backgroundColor: this.labelBackgroundColor,\n backgroundMargin: this.labelBackgroundMargin,\n backgroundOpacity: this.labelBackgroundOpacity,\n fixedSize: this.labelFixedSize,\n disablePicking: true,\n visible: this.labelVisible\n }, params, {\n opacity: 1.0 // only opaque labels\n }))\n }\n\n getAtomRadius () {\n return 0\n }\n}\n\n/**\n * MeasurementRepresentations take atom[Pair|Triple|Quad] parameters.\n *\n * Parses nested array of either integer atom indices or selection\n * expressions into a flat array of coordinates.\n *\n * @param {Structure} sview The structure to which the atoms refer\n * @param {Array} atoms Nested array of atom pairs|triples|quads as\n * Integer indices or selection expressions\n * @return {Float32Array} Flattened array of position coordinates\n */\nfunction parseNestedAtoms (sview: StructureView, atoms: (number|string)[][]) {\n const ap = sview.getAtomProxy()\n const sele = new Selection()\n\n const nSets = atoms.length\n if (nSets === 0) return new Float32Array(0)\n\n // Peek-ahead at first item to determine order and parse mode\n const order = atoms[ 0 ].length\n const selected = sview.getAtomSet()\n\n const a = new Float32Array(nSets * order * 3)\n\n let p = 0\n atoms.forEach(function (group) {\n let _break = false\n for (let j = 0; j < order; j++) {\n const value = group[ j ]\n if (typeof (value) === 'number' && Number.isInteger(value)) {\n if (selected.get(value)) {\n ap.index = value\n } else {\n _break = true\n break\n }\n } else {\n sele.setString(value as string)\n const atomIndices = sview.getAtomIndices(sele)\n if (atomIndices!.length) {\n ap.index = atomIndices![ 0 ]\n } else {\n _break = true\n break\n }\n }\n\n let offset = p + j * 3\n a[ offset++ ] = ap.x\n a[ offset++ ] = ap.y\n a[ offset++ ] = ap.z\n }\n if (!_break) p += 3 * order\n })\n\n return a.subarray(0, p)\n}\n\n/* out = v1 * cos(angle) + v2 * sin(angle) */\nfunction calcArcPoint (out: Float32Array, center: Float32Array, v1: Float32Array, v2: Float32Array, angle: number) {\n const x = Math.cos(angle)\n const y = Math.sin(angle)\n out[ 0 ] = center[ 0 ] + v1[ 0 ] * x + v2[ 0 ] * y\n out[ 1 ] = center[ 1 ] + v1[ 1 ] * x + v2[ 1 ] * y\n out[ 2 ] = center[ 2 ] + v1[ 2 ] * x + v2[ 2 ] * y\n}\n\nexport {\n MeasurementRepresentation as default,\n calcArcPoint,\n parseNestedAtoms\n}\n","/**\n * @file Edt\n * @author Alexander Rose \n * @private\n */\n\nimport { NumberArray } from '../types'\n\n// 2D Euclidean distance transform by Felzenszwalb & Huttenlocher https://cs.brown.edu/~pff/papers/dt-final.pdf\nexport function edt(data: NumberArray, width: number, height: number, f: NumberArray, d: NumberArray, v: NumberArray, z: NumberArray) {\n for (let x = 0; x < width; x++) {\n for (let y = 0; y < height; y++) {\n f[y] = data[y * width + x]\n }\n edt1d(f, d, v, z, height)\n for (let y = 0; y < height; y++) {\n data[y * width + x] = d[y]\n }\n }\n for (let y = 0; y < height; y++) {\n for (let x = 0; x < width; x++) {\n f[x] = data[y * width + x]\n }\n edt1d(f, d, v, z, width)\n for (let x = 0; x < width; x++) {\n data[y * width + x] = Math.sqrt(d[x])\n }\n }\n}\n\n// 1D squared distance transform\nfunction edt1d(f: NumberArray, d: NumberArray, v: NumberArray, z: NumberArray, n: number) {\n v[0] = 0\n z[0] = Number.MIN_SAFE_INTEGER\n z[1] = Number.MAX_SAFE_INTEGER\n\n for (let q = 1, k = 0; q < n; q++) {\n let s = ((f[q] + q * q) - (f[v[k]] + v[k] * v[k])) / (2 * q - 2 * v[k])\n while (s <= z[k]) {\n k--\n s = ((f[q] + q * q) - (f[v[k]] + v[k] * v[k])) / (2 * q - 2 * v[k])\n }\n k++\n v[k] = q\n z[k] = s\n z[k + 1] = Number.MAX_SAFE_INTEGER\n }\n\n for (let q = 0, k = 0; q < n; q++) {\n while (z[k + 1] < q) k++\n d[q] = (q - v[k]) * (q - v[k]) + f[v[k]]\n }\n}\n","/**\n * @file Text Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { Color, CanvasTexture, Vector3, Matrix4 } from 'three'\n\nimport '../shader/SDFFont.vert'\nimport '../shader/SDFFont.frag'\n\nimport { BufferRegistry } from '../globals'\nimport { createParams } from '../utils'\nimport MappedQuadBuffer from './mappedquad-buffer'\nimport { IgnorePicker } from '../utils/picker'\nimport { edt } from '../utils/edt'\nimport { BufferDefaultParameters, BufferParameterTypes, BufferData, BufferTypes, BufferParameters } from './buffer'\nimport { GenericColor } from '../types'\n\nconst TextAtlasCache: { [k: string]: TextAtlas } = {}\n\nfunction getTextAtlas (params: Partial) {\n const hash = JSON.stringify(params)\n if (TextAtlasCache[ hash ] === undefined) {\n TextAtlasCache[ hash ] = new TextAtlas(params)\n }\n return TextAtlasCache[ hash ]\n}\n\ntype TextFonts = 'sans-serif'|'monospace'|'serif'\ntype TextStyles = 'normal'|'italic'\ntype TextVariants = 'normal'\ntype TextWeights = 'normal'|'bold'\n\nexport const TextAtlasDefaultParams = {\n font: 'sans-serif' as TextFonts,\n size: 36,\n style: 'normal' as TextStyles,\n variant: 'normal' as TextVariants,\n weight: 'normal' as TextWeights,\n outline: 3,\n width: 1024,\n height: 1024\n}\nexport type TextAtlasParams = typeof TextAtlasDefaultParams\n\nexport type TextAtlasMap = { x: number, y: number, w: number, h: number }\n\nexport class TextAtlas {\n parameters: TextAtlasParams\n\n gamma = 1\n mapped: { [k: string]: TextAtlasMap } = {}\n scratchW = 0\n scratchH = 0\n currentX = 0\n currentY = 0\n\n cutoff = 0.25\n padding: number\n radius: number\n\n gridOuter: Float64Array\n gridInner: Float64Array\n f: Float64Array\n d: Float64Array\n z: Float64Array\n v: Int16Array\n\n paddedSize: number\n middle: number\n\n texture: CanvasTexture\n canvas: HTMLCanvasElement\n context: CanvasRenderingContext2D\n\n lineHeight: number\n maxWidth: number\n colors: string[]\n scratch: Uint8Array\n canvas2: HTMLCanvasElement\n context2: CanvasRenderingContext2D\n data: Uint8Array\n\n placeholder: TextAtlasMap\n\n constructor (params: Partial = {}) {\n this.parameters = createParams(params, TextAtlasDefaultParams)\n const p = this.parameters\n\n this.radius = p.size / 8\n this.padding = p.size / 3\n\n // Prepare line-height with room for outline and descenders/ascenders\n const lineHeight = this.lineHeight = p.size + 2 * p.outline + Math.round(p.size / 4)\n const maxWidth = this.maxWidth = p.width / 4\n\n // Prepare scratch canvas\n const canvas = this.canvas = document.createElement('canvas')\n canvas.width = maxWidth\n canvas.height = lineHeight\n\n const ctx = this.context = this.canvas.getContext('2d')!\n ctx.font = `${p.style} ${p.variant} ${p.weight} ${p.size}px ${p.font}`\n ctx.fillStyle = 'black'\n ctx.textAlign = 'left'\n ctx.textBaseline = 'bottom'\n ctx.lineJoin = 'round'\n\n // temporary arrays for the distance transform\n this.gridOuter = new Float64Array(lineHeight * maxWidth)\n this.gridInner = new Float64Array(lineHeight * maxWidth)\n this.f = new Float64Array(Math.max(lineHeight, maxWidth))\n this.d = new Float64Array(Math.max(lineHeight, maxWidth))\n this.z = new Float64Array(Math.max(lineHeight, maxWidth) + 1)\n this.v = new Int16Array(Math.max(lineHeight, maxWidth))\n\n //\n this.data = new Uint8Array(p.width * p.height * 4)\n this.canvas2 = document.createElement('canvas')\n this.canvas2.width = p.width\n this.canvas2.height = p.height\n this.context2 = this.canvas2.getContext('2d')!\n\n // Replacement Character\n this.placeholder = this.map(String.fromCharCode(0xFFFD))\n\n // Basic Latin (subset)\n for (let i = 0x0020; i <= 0x007E; ++i) {\n this.map(String.fromCharCode(i))\n }\n\n // TODO: to slow to always prepare them\n // // Latin-1 Supplement (subset)\n // for (let i = 0x00A1; i <= 0x00FF; ++i) {\n // this.map(String.fromCharCode(i))\n // }\n\n // Degree sign\n this.map(String.fromCharCode(0x00B0))\n\n // // Greek and Coptic (subset)\n // for (let i = 0x0391; i <= 0x03C9; ++i) {\n // this.map(String.fromCharCode(i))\n // }\n\n // // Cyrillic (subset)\n // for (let i = 0x0400; i <= 0x044F; ++i) {\n // this.map(String.fromCharCode(i))\n // }\n\n // Angstrom Sign\n this.map(String.fromCharCode(0x212B))\n\n this.texture = new CanvasTexture(this.canvas2)\n this.texture.flipY = false\n this.texture.needsUpdate = true\n }\n\n map (text: string) {\n const p = this.parameters\n\n if (this.mapped[ text ] === undefined) {\n this.draw(text)\n\n if (this.currentX + this.scratchW > p.width) {\n this.currentX = 0\n this.currentY += this.scratchH\n }\n if (this.currentY + this.scratchH > p.height) {\n console.warn('canvas to small')\n }\n\n this.mapped[ text ] = {\n x: this.currentX,\n y: this.currentY,\n w: this.scratchW,\n h: this.scratchH\n }\n\n this.context2.drawImage(\n this.canvas,\n 0, 0,\n this.scratchW, this.scratchH,\n this.currentX, this.currentY,\n this.scratchW, this.scratchH\n )\n\n this.currentX += this.scratchW\n }\n\n return this.mapped[ text ]\n }\n\n get (text: string) {\n return this.mapped[ text ] || this.placeholder\n }\n\n draw (text: string) {\n const p = this.parameters\n\n const h = this.lineHeight\n const o = p.outline\n const ctx = this.context\n // const dst = this.scratch\n const max = this.maxWidth\n // const colors = this.colors\n\n // Bottom aligned, take outline into account\n const x = o\n const y = h - p.outline\n\n // Measure text\n const m = ctx.measureText(text)\n const w = Math.min(max, Math.ceil(m.width + 2 * x + 1))\n\n const n = w * h\n\n // Clear scratch area\n ctx.clearRect(0, 0, w, h)\n\n // Draw text\n ctx.fillText(text, x, y)\n\n const imageData = ctx.getImageData(0, 0, w, h)\n const data = imageData.data\n\n for (let i = 0; i < n; i++) {\n const a = imageData.data[i * 4 + 3] / 255; // alpha value\n this.gridOuter[i] = a === 1 ? 0 : a === 0 ? Number.MAX_SAFE_INTEGER : Math.pow(Math.max(0, 0.5 - a), 2);\n this.gridInner[i] = a === 1 ? Number.MAX_SAFE_INTEGER : a === 0 ? 0 : Math.pow(Math.max(0, a - 0.5), 2);\n }\n\n edt(this.gridOuter, w, h, this.f, this.d, this.v, this.z);\n edt(this.gridInner, w, h, this.f, this.d, this.v, this.z);\n\n for (let i = 0; i < n; i++) {\n const d = this.gridOuter[i] - this.gridInner[i];\n data[i * 4 + 3] = Math.max(0, Math.min(255, Math.round(255 - 255 * (d / this.radius + this.cutoff))));\n }\n\n ctx.putImageData(imageData, 0, 0)\n this.scratchW = w\n this.scratchH = h\n }\n}\n\n/**\n * Text buffer parameter object.\n * @typedef {Object} TextBufferParameters - text buffer parameters\n *\n * @property {Float} opacity - translucency: 1 is fully opaque, 0 is fully transparent\n * @property {Integer} clipNear - position of camera near/front clipping plane\n * in percent of scene bounding box\n * @property {String} labelType - type of the label, one of:\n * \"atomname\", \"atomindex\", \"occupancy\", \"bfactor\",\n * \"serial\", \"element\", \"atom\", \"resname\", \"resno\",\n * \"res\", \"text\", \"qualified\". When set to \"text\", the\n * `labelText` list is used.\n * @property {String[]} labelText - list of label strings, must set `labelType` to \"text\"\n * to take effect\n * @property {String} fontFamily - font family, one of: \"sans-serif\", \"monospace\", \"serif\"\n * @property {String} fontStyle - font style, \"normal\" or \"italic\"\n * @property {String} fontWeight - font weight, \"normal\" or \"bold\"\n * @property {Float} xOffset - offset in x-direction\n * @property {Float} yOffset - offset in y-direction\n * @property {Float} zOffset - offset in z-direction (i.e. in camera direction)\n * @property {String} attachment - attachment of the label, one of:\n * \"bottom-left\", \"bottom-center\", \"bottom-right\",\n * \"middle-left\", \"middle-center\", \"middle-right\",\n * \"top-left\", \"top-center\", \"top-right\"\n * @property {Boolean} showBorder - show border/outline\n * @property {Color} borderColor - color of the border/outline\n * @property {Float} borderWidth - width of the border/outline\n * @property {Boolean} showBackground - show background rectangle\n * @property {Color} backgroundColor - color of the background\n * @property {Float} backgroundMargin - width of the background\n * @property {Float} backgroundOpacity - opacity of the background\n * @property {Boolean} fixedSize - show text with a fixed pixel size\n */\n\nexport interface TextBufferData extends BufferData {\n size: Float32Array\n text: string[]\n}\n\ntype TextAttachments = 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n\nexport const TextBufferDefaultParameters = Object.assign({\n fontFamily: 'sans-serif' as TextFonts,\n fontStyle: 'normal' as TextStyles,\n fontWeight: 'bold' as TextWeights,\n fontSize: 36,\n xOffset: 0.0,\n yOffset: 0.0,\n zOffset: 0.5,\n attachment: 'bottom-left' as TextAttachments,\n showBorder: false,\n borderColor: 'lightgrey' as number|string,\n borderWidth: 0.15,\n showBackground: false,\n backgroundColor: 'lightgrey' as number|string,\n backgroundMargin: 0.5,\n backgroundOpacity: 1.0,\n forceTransparent: true,\n fixedSize: false\n}, BufferDefaultParameters)\nexport type TextBufferParameters = BufferParameters & {\n fontFamily: TextFonts,\n fontStyle: TextStyles,\n fontWeight: TextWeights,\n fontSize: number,\n xOffset: number,\n yOffset: number,\n zOffset: number,\n attachment: TextAttachments,\n showBorder: boolean,\n borderColor: GenericColor,\n borderWidth: number,\n showBackground: boolean,\n backgroundColor: GenericColor,\n backgroundMargin: number,\n backgroundOpacity: number,\n forceTransparent: boolean,\n fixedSize: boolean\n}\n\nconst TextBufferParameterTypes = Object.assign({\n fontFamily: { uniform: true },\n fontStyle: { uniform: true },\n fontWeight: { uniform: true },\n fontSize: { uniform: true },\n xOffset: { uniform: true },\n yOffset: { uniform: true },\n zOffset: { uniform: true },\n showBorder: { uniform: true },\n borderColor: { uniform: true },\n borderWidth: { uniform: true },\n backgroundColor: { uniform: true },\n backgroundOpacity: { uniform: true },\n fixedSize: { updateShader: true }\n}, BufferParameterTypes)\n\nfunction getCharCount (data: TextBufferData, params: Partial) {\n const n = data.position!.length / 3\n let charCount = 0\n for (let i = 0; i < n; ++i) {\n charCount += data.text[ i ].length\n }\n if (params.showBackground) charCount += n\n\n return charCount\n}\n\n/**\n * Text buffer. Renders screen-aligned text strings.\n *\n * @example\n * var textBuffer = new TextBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * size: new Float32Array([ 2 ]),\n * text: [ \"Hello\" ]\n * });\n */\nclass TextBuffer extends MappedQuadBuffer {\n parameterTypes = TextBufferParameterTypes\n get defaultParameters() { return TextBufferDefaultParameters }\n parameters: TextBufferParameters\n\n alwaysTransparent = true\n hasWireframe = false\n isText = true\n vertexShader = 'SDFFont.vert'\n fragmentShader = 'SDFFont.frag'\n\n text: string[]\n positionCount: number\n texture: CanvasTexture\n textAtlas: TextAtlas\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.size - sizes\n * @param {String[]} data.text - text strings\n * @param {TextBufferParameters} params - parameters object\n */\n constructor (data: TextBufferData, params: Partial = {}) {\n super({\n position: new Float32Array(getCharCount(data, params) * 3),\n color: new Float32Array(getCharCount(data, params) * 3),\n picking: new IgnorePicker()\n }, params)\n\n this.text = data.text\n this.positionCount = data.position!.length / 3\n\n this.addUniforms({\n 'fontTexture': { value: null },\n 'xOffset': { value: this.parameters.xOffset },\n 'yOffset': { value: this.parameters.yOffset },\n 'zOffset': { value: this.parameters.zOffset },\n 'ortho': { value: false },\n 'showBorder': { value: this.parameters.showBorder },\n 'borderColor': { value: new Color(this.parameters.borderColor as number) },\n 'borderWidth': { value: this.parameters.borderWidth },\n 'backgroundColor': { value: new Color(this.parameters.backgroundColor as number) },\n 'backgroundOpacity': { value: this.parameters.backgroundOpacity },\n 'canvasHeight': { value: 1.0 },\n 'pixelRatio': { value: 1.0 }\n })\n\n this.addAttributes({\n 'inputTexCoord': { type: 'v2', value: null },\n 'inputSize': { type: 'f', value: null }\n })\n\n this.setAttributes(data)\n\n this.makeTexture()\n this.makeMapping()\n }\n\n makeMaterial () {\n super.makeMaterial()\n\n const tex = this.texture\n\n const m = this.material\n m.transparent = true\n m.extensions.derivatives = true\n m.lights = false\n m.uniforms.fontTexture.value = tex\n m.needsUpdate = true\n\n const wm = this.wireframeMaterial\n wm.transparent = true\n wm.extensions.derivatives = true\n wm.lights = false\n wm.uniforms.fontTexture.value = tex\n wm.needsUpdate = true\n\n const pm = this.pickingMaterial\n pm.extensions.derivatives = true\n pm.lights = false\n pm.uniforms.fontTexture.value = tex\n pm.needsUpdate = true\n }\n\n setAttributes (data: Partial = {}) {\n let position, size, color\n let aPosition, inputSize, aColor\n\n const text = this.text\n const attributes = this.geometry.attributes as any // TODO\n\n if (data.position) {\n position = data.position\n aPosition = attributes.position.array\n attributes.position.needsUpdate = true\n }\n\n if (data.size) {\n size = data.size\n inputSize = attributes.inputSize.array\n attributes.inputSize.needsUpdate = true\n }\n\n if (data.color) {\n color = data.color\n aColor = attributes.color.array\n attributes.color.needsUpdate = true\n }\n\n const n = this.positionCount\n\n let j, o\n let iCharAll = 0\n let txt, iChar, nChar\n\n for (let v = 0; v < n; ++v) {\n o = 3 * v\n txt = text[ v ]\n nChar = txt.length\n if (this.parameters.showBackground) nChar += 1\n\n for (iChar = 0; iChar < nChar; ++iChar, ++iCharAll) {\n for (let m = 0; m < 4; m++) {\n j = iCharAll * 4 * 3 + (3 * m)\n\n if (position) {\n aPosition[ j ] = position[ o ]\n aPosition[ j + 1 ] = position[ o + 1 ]\n aPosition[ j + 2 ] = position[ o + 2 ]\n }\n\n if (size) {\n inputSize[ (iCharAll * 4) + m ] = size[ v ]\n }\n\n if (color) {\n aColor[ j ] = color[ o ]\n aColor[ j + 1 ] = color[ o + 1 ]\n aColor[ j + 2 ] = color[ o + 2 ]\n }\n }\n }\n }\n }\n\n makeTexture () {\n this.textAtlas = getTextAtlas({\n font: this.parameters.fontFamily,\n style: this.parameters.fontStyle,\n weight: this.parameters.fontWeight,\n size: this.parameters.fontSize\n })\n\n this.texture = this.textAtlas.texture\n }\n\n makeMapping () {\n const ta = this.textAtlas\n const text = this.text\n const attachment = this.parameters.attachment\n const margin = (ta.lineHeight * this.parameters.backgroundMargin * 0.1) - 10\n\n const attribs = this.geometry.attributes as any // TODO\n const inputTexCoord = attribs.inputTexCoord.array\n const inputMapping = attribs.mapping.array\n\n const n = this.positionCount\n let iCharAll = 0\n let c, i, txt, xadvance, iChar, nChar, xShift, yShift\n\n for (let v = 0; v < n; ++v) {\n txt = text[ v ]\n xadvance = 0\n nChar = txt.length\n\n // calculate width\n for (iChar = 0; iChar < nChar; ++iChar) {\n c = ta.get(txt[ iChar ])\n xadvance += c.w - 2 * ta.parameters.outline\n }\n\n // attachment\n if (attachment.startsWith('top')) {\n yShift = ta.lineHeight / 1.25\n } else if (attachment.startsWith('middle')) {\n yShift = ta.lineHeight / 2.5\n } else {\n yShift = 0 // \"bottom\"\n }\n if (attachment.endsWith('right')) {\n xShift = xadvance\n } else if (attachment.endsWith('center')) {\n xShift = xadvance / 2\n } else {\n xShift = 0 // \"left\"\n }\n xShift += ta.parameters.outline\n yShift += ta.parameters.outline\n\n // background\n if (this.parameters.showBackground) {\n i = iCharAll * 2 * 4\n inputMapping[ i + 0 ] = -ta.lineHeight / 6 - xShift - margin // top left\n inputMapping[ i + 1 ] = ta.lineHeight - yShift + margin\n inputMapping[ i + 2 ] = -ta.lineHeight / 6 - xShift - margin // bottom left\n inputMapping[ i + 3 ] = 0 - yShift - margin\n inputMapping[ i + 4 ] = xadvance + ta.lineHeight / 6 - xShift + 2 * ta.parameters.outline + margin // top right\n inputMapping[ i + 5 ] = ta.lineHeight - yShift + margin\n inputMapping[ i + 6 ] = xadvance + ta.lineHeight / 6 - xShift + 2 * ta.parameters.outline + margin // bottom right\n inputMapping[ i + 7 ] = 0 - yShift - margin\n inputTexCoord[ i + 0 ] = 10\n inputTexCoord[ i + 2 ] = 10\n inputTexCoord[ i + 4 ] = 10\n inputTexCoord[ i + 6 ] = 10\n iCharAll += 1\n }\n\n xadvance = 0\n\n for (iChar = 0; iChar < nChar; ++iChar, ++iCharAll) {\n c = ta.get(txt[ iChar ])\n i = iCharAll * 2 * 4\n\n inputMapping[ i + 0 ] = xadvance - xShift // top left\n inputMapping[ i + 1 ] = c.h - yShift\n inputMapping[ i + 2 ] = xadvance - xShift // bottom left\n inputMapping[ i + 3 ] = 0 - yShift\n inputMapping[ i + 4 ] = xadvance + c.w - xShift // top right\n inputMapping[ i + 5 ] = c.h - yShift\n inputMapping[ i + 6 ] = xadvance + c.w - xShift // bottom right\n inputMapping[ i + 7 ] = 0 - yShift\n\n const texWidth = ta.parameters.width\n const texHeight = ta.parameters.height\n\n const texCoords = [\n c.x / texWidth, c.y / texHeight, // top left\n c.x / texWidth, (c.y + c.h) / texHeight, // bottom left\n (c.x + c.w) / texWidth, c.y / texHeight, // top right\n (c.x + c.w) / texWidth, (c.y + c.h) / texHeight // bottom right\n ]\n inputTexCoord.set(texCoords, i)\n\n xadvance += c.w - 2 * ta.parameters.outline\n }\n }\n\n attribs.inputTexCoord.needsUpdate = true\n attribs.mapping.needsUpdate = true\n }\n\n getDefines (type: BufferTypes) {\n const defines = super.getDefines(type)\n\n if (this.parameters.fixedSize) {\n defines.FIXED_SIZE = 1\n }\n\n return defines\n }\n\n setUniforms (data: any) { // TODO\n if (data && (\n data.fontFamily !== undefined ||\n data.fontStyle !== undefined ||\n data.fontWeight !== undefined ||\n data.fontSize !== undefined\n )) {\n this.makeTexture()\n this.makeMapping()\n this.texture.needsUpdate = true\n data.fontTexture = this.texture\n }\n\n super.setUniforms(data)\n }\n}\n\nBufferRegistry.add('text', TextBuffer)\n\nexport default TextBuffer\n","/**\n * @file Wide Line Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3 required for declaration only\nimport { Vector2, Vector3, Matrix4 } from 'three'\n\nimport '../shader/WideLine.vert'\nimport '../shader/WideLine.frag'\n\nimport { BufferRegistry } from '../globals'\nimport MappedQuadBuffer from './mappedquad-buffer'\nimport { BufferDefaultParameters, BufferParameterTypes, BufferData, BufferParameters } from './buffer'\n\nexport interface WideLineBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n color2: Float32Array\n}\n\nexport const WideLineBufferDefaultParameters = Object.assign({\n linewidth: 2\n}, BufferDefaultParameters)\nexport type WideLineBufferParameters = BufferParameters & { linewidth: number }\n\nconst WideLineBufferParameterTypes = Object.assign({\n linewidth: { uniform: true }\n}, BufferParameterTypes)\n\n/**\n * Wide Line buffer. Draws lines with a fixed width in pixels.\n *\n * @example\n * var lineBuffer = new WideLineBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ])\n * });\n */\nclass WideLineBuffer extends MappedQuadBuffer {\n parameterTypes = WideLineBufferParameterTypes\n get defaultParameters() { return WideLineBufferDefaultParameters }\n parameters: WideLineBufferParameters\n\n vertexShader = 'WideLine.vert'\n fragmentShader ='WideLine.frag'\n\n constructor (data: Partial, params: Partial = {}) {\n super(data, params)\n\n if (!data.color2 && data.color) data.color2 = data.color\n\n this.addUniforms({\n 'linewidth': { value: this.parameters.linewidth },\n 'resolution': { value: new Vector2() },\n 'projectionMatrixInverse': { value: new Matrix4() }\n })\n\n this.addAttributes({\n 'position1': { type: 'v3', value: null },\n 'position2': { type: 'v3', value: null },\n 'color2': { type: 'c', value: null }\n })\n\n this.setAttributes(data)\n this.makeMapping()\n }\n\n setParameters (params: Partial) {\n super.setParameters(params)\n }\n}\n\nBufferRegistry.add('wideline', WideLineBuffer)\n\nexport default WideLineBuffer\n","/**\n * @file Angle Representation\n * @author Fred Ludlow \n * @private\n */\nimport { Color } from 'three'\n\nimport { RepresentationRegistry } from '../globals'\nimport MeasurementRepresentation, { parseNestedAtoms, calcArcPoint, MeasurementRepresentationParameters, LabelDataField } from './measurement-representation'\nimport { defaults } from '../utils'\n\nimport MeshBuffer from '../buffer/mesh-buffer'\nimport TextBuffer, { TextBufferData, TextBufferParameters } from '../buffer/text-buffer'\nimport WideLineBuffer, { WideLineBufferData } from '../buffer/wideline-buffer'\n\nimport { v3add, v3cross, v3dot, v3fromArray, v3length, v3new,\n v3normalize, v3sub, v3toArray } from '../math/vector-utils'\nimport { copyArray, uniformArray, uniformArray3 } from '../math/array-utils'\nimport { RAD2DEG } from '../math/math-constants'\nimport { getFixedLengthWrappedDashData } from '../geometry/dash'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { BufferData } from '../buffer/buffer';\nimport { StructureRepresentationData, StructureRepresentationParameters } from './structure-representation';\n\n/**\n * @typedef {Object} AngleRepresentationParameters - angle representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n * @mixes MeasurementRepresentationParameters\n *\n * @property {String} atomTriple - list of triplets of selection strings\n * or atom indices\n * @property {Boolean} vectorVisible - Indicate the 3 points for each angle by drawing lines 1-2-3\n * @property {Boolean} arcVisible - Show the arc outline for each angle\n * @property {Number} lineOpacity - opacity for the line part of the representation\n * @property {Number} linewidth - width for line part of representation\n * @property {Boolean} sectorVisible - Show the filled arc for each angle\n */\n\nexport interface AngleRepresentationParameters extends MeasurementRepresentationParameters {\n atomTriple: (number|string)[][]\n vectorVisible: boolean\n arcVisible: boolean\n lineOpacity: number\n lineWidth: number\n sectorVisible: boolean\n}\n\n/**\n * Angle representation object\n *\n * Reperesentation consists of four parts, visibility can be set for each\n * label - the text label with the angle size\n * vectors - lines joining the three points\n * sector - triangles representing the angle\n * arc - line bordering the sector\n *\n * @param {Structure} structure - the structure to measure angles in\n * @param {Viewer} viewer - a viewer object\n * @param {AngleRepresentationParameters} params - angle representation parameters\n */\nclass AngleRepresentation extends MeasurementRepresentation {\n protected atomTriple: (number|string)[][]\n protected vectorVisible: boolean\n protected arcVisible: boolean\n protected lineOpacity: number\n protected lineWidth: number\n protected sectorVisible: boolean\n protected vectorBuffer: WideLineBuffer\n arcLength: number\n sectorLength: number\n arcBuffer: WideLineBuffer\n sectorBuffer: MeshBuffer\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'angle'\n\n this.parameters = Object.assign({\n atomTriple: {\n type: 'hidden', rebuild: true\n },\n vectorVisible: {\n type: 'boolean', default: true\n },\n arcVisible: {\n type: 'boolean', default: true\n },\n sectorVisible: {\n type: 'boolean', default: true\n }\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.side = defaults(p.side, 'double')\n p.opacity = defaults(p.opacity, 0.5)\n\n this.atomTriple = defaults(p.atomTriple, [])\n this.arcVisible = defaults(p.arcVisible, true)\n this.sectorVisible = defaults(p.sectorVisible, true)\n this.vectorVisible = defaults(p.vectorVisible, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n if (!sview.atomCount || !this.atomTriple.length) return\n\n const atomPosition = atomTriplePositions(sview, this.atomTriple)\n const angleData = getAngleData(atomPosition)\n const n = this.n = angleData.labelPosition.length / 3\n\n const labelColor = new Color(this.labelColor)\n\n // Create buffers\n this.textBuffer = new TextBuffer({\n position: angleData.labelPosition,\n size: uniformArray(n, this.labelSize),\n color: uniformArray3(n, labelColor.r, labelColor.g, labelColor.b),\n text: angleData.labelText\n } as TextBufferData, this.getLabelBufferParams() as TextBufferParameters)\n\n const c = new Color(this.colorValue)\n\n this.vectorBuffer = new WideLineBuffer(\n getFixedLengthWrappedDashData({\n position1: angleData.vectorPosition1,\n position2: angleData.vectorPosition2,\n color: uniformArray3(2 * n, c.r, c.g, c.b),\n color2: uniformArray3(2 * n, c.r, c.g, c.b)\n } as WideLineBufferData),\n this.getBufferParams({\n linewidth: this.linewidth,\n visible: this.vectorVisible,\n opacity: this.lineOpacity\n })\n )\n\n this.arcLength = angleData.arcPosition1.length / 3\n\n this.arcBuffer = new WideLineBuffer(\n getFixedLengthWrappedDashData({\n position1: angleData.arcPosition1,\n position2: angleData.arcPosition2,\n color: uniformArray3(this.arcLength, c.r, c.g, c.b),\n color2: uniformArray3(this.arcLength, c.r, c.g, c.b)\n } as WideLineBufferData), this.getBufferParams({\n linewidth: this.linewidth,\n visible: this.arcVisible,\n opacity: this.lineOpacity\n }))\n\n this.sectorLength = angleData.sectorPosition.length / 3\n\n this.sectorBuffer = new MeshBuffer({\n position: angleData.sectorPosition,\n color: uniformArray3(this.sectorLength, c.r, c.g, c.b)\n } as BufferData, this.getBufferParams({\n visible: this.sectorVisible\n }))\n\n return {\n bufferList: [\n this.textBuffer,\n this.vectorBuffer,\n this.arcBuffer,\n this.sectorBuffer\n ]\n }\n }\n\n updateData (what: LabelDataField & {color?: boolean}, data: StructureRepresentationData) {\n super.updateData(what, data)\n const vectorData = {}\n const arcData = {}\n const sectorData = {}\n\n if (what.color) {\n const c = new Color(this.colorValue)\n Object.assign(vectorData, {\n color: uniformArray3(this.n * 2, c.r, c.g, c.b),\n color2: uniformArray3(this.n * 2, c.r, c.g, c.b)\n })\n Object.assign(arcData, {\n color: uniformArray3(this.arcLength, c.r, c.g, c.b),\n color2: uniformArray3(this.arcLength, c.r, c.g, c.b)\n })\n Object.assign(sectorData, {\n color: uniformArray3(this.sectorLength, c.r, c.g, c.b)\n })\n }\n\n // if (what.sectorOpacity) {\n // this.sectorBuffer.opacity = what.sectorOpacity\n // }\n\n this.vectorBuffer.setAttributes(vectorData)\n this.arcBuffer.setAttributes(arcData)\n this.sectorBuffer.setAttributes(sectorData)\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n super.setParameters(params, what, rebuild)\n\n if (params && (\n params.vectorVisible !== undefined ||\n params.arcVisible !== undefined ||\n params.sectorVisible !== undefined)) {\n this.setVisibility(this.visible)\n }\n\n if (params && params.lineOpacity) {\n this.vectorBuffer.setParameters({ opacity: params.lineOpacity })\n this.arcBuffer.setParameters({ opacity: params.lineOpacity })\n }\n\n if (params && params.opacity !== undefined) {\n this.vectorBuffer.setParameters({ opacity: this.lineOpacity })\n this.arcBuffer.setParameters({ opacity: this.lineOpacity })\n }\n\n if (params && params.linewidth) {\n this.vectorBuffer.setParameters({ linewidth: params.linewidth })\n this.arcBuffer.setParameters({ linewidth: params.linewidth })\n }\n\n return this\n }\n\n setVisibility (value: boolean, noRenderRequest?: boolean) {\n super.setVisibility(value, true)\n\n if (this.vectorBuffer) {\n this.vectorBuffer.setVisibility(this.vectorVisible && this.visible)\n }\n\n if (this.arcBuffer) {\n this.arcBuffer.setVisibility(this.arcVisible && this.visible)\n }\n\n if (this.sectorBuffer) {\n this.sectorBuffer.setVisibility(this.sectorVisible && this.visible)\n }\n\n if (!noRenderRequest) this.viewer.requestRender()\n\n return this\n }\n}\n\n/**\n * Ensure mid point does not coincide with first or second\n * @param {Float32Array} position 9*nAngle array of coordinates\n * @return {Float32Array} Filtered position array, may be shorter\n */\nfunction validatePositions (position: Float32Array) {\n const include = []\n const n = position.length / 9\n for (let i = 0; i < n; i++) {\n // Check that first point not same as second and that second not same as third\n let okay = true\n for (let j = i; j < i + 3; j += 3) {\n if (position[j] === position[j + 3] &&\n position[j + 1] === position[j + 4] &&\n position[j + 2] === position[j + 5]) {\n okay = false\n }\n }\n if (okay) include.push(i)\n }\n const outPosition = new Float32Array(include.length * 9)\n let outIdx = 0\n include.forEach(function (i) {\n copyArray(position, outPosition, i * 9, outIdx * 9, 9)\n outIdx++\n })\n return outPosition\n}\n\nfunction atomTriplePositions (sview: StructureView, atomTriple: (number|string)[][]) {\n return validatePositions(parseNestedAtoms(sview, atomTriple))\n}\n\n/**\n * Converts triple positions into data required to build various buffers.\n */\nfunction getAngleData (position: Float32Array, params: Partial = {}) {\n const angleStep = defaults(params.angleStep, Math.PI / 90)\n const n = position.length / 9\n const angles = new Float32Array(n)\n const labelPosition = new Float32Array(n * 3)\n const labelText = new Array(n)\n\n const vectorPosition1 = new Float32Array(n * 6) // Two lines per angle\n const vectorPosition2 = new Float32Array(n * 6)\n\n const arcPositionTmp1 = new Array(n) // Start points for arc lines\n const arcPositionTmp2 = new Array(n) // End points for arc lines\n const sectorPositionTmp = new Array(n) // Triangle points\n\n let totalSegments = 0\n\n // Re-used vectors etc\n const p1 = v3new() // Positions of points for each angel\n const p2 = v3new()\n const p3 = v3new()\n const v21 = v3new() // Vectors\n const v23 = v3new()\n const cross = v3new() // Cross product v21xv23\n const cross2 = v3new() // In-plane cross product v21 x (v21 x v23)\n const labelTmp = v3new()\n const arcPoint = v3new()\n\n for (var i = 0; i < n; i++) {\n let p = 9 * i\n v3fromArray(p1, position, p)\n v3fromArray(p2, position, p + 3)\n v3fromArray(p3, position, p + 6)\n\n let v = 6 * i\n v3toArray(p1, vectorPosition1, v)\n v3toArray(p2, vectorPosition2, v)\n v3toArray(p2, vectorPosition1, v + 3)\n v3toArray(p3, vectorPosition2, v + 3)\n\n v3sub(v21, p1, p2)\n v3sub(v23, p3, p2)\n\n v3normalize(v21, v21) // validatePositions ensures valid\n v3normalize(v23, v23)\n\n v3cross(cross, v21, v23)\n const crossLength = v3length(cross)\n const dot = v3dot(v21, v23)\n\n const angle = angles[i] = Math.atan2(crossLength, dot)\n labelText[i] = (RAD2DEG * angle).toFixed(1) + String.fromCharCode(0x00B0)\n\n if (v3length(cross) === 0.0) {\n // Angle exactly 0/180, pick an arbitrary direction\n cross[ 0 ] = 1.0\n cross[ 1 ] = 0.0\n cross[ 2 ] = 0.0\n }\n v3cross(cross2, cross, v21)\n v3normalize(cross2, cross2)\n\n calcArcPoint(labelTmp, p2, v21, cross2, angle / 2.0)\n // TODO: Scale label position?\n v3toArray(labelTmp, labelPosition, 3 * i)\n\n // Build the arc and sector\n\n const nSegments = Math.ceil(angle / angleStep)\n const sectorVertices = new Float32Array(nSegments * 9)\n sectorPositionTmp[ i ] = sectorVertices\n const arcVertices1 = new Float32Array(nSegments * 3)\n const arcVertices2 = new Float32Array(nSegments * 3)\n arcPositionTmp1[ i ] = arcVertices1\n arcPositionTmp2[ i ] = arcVertices2\n\n v3add(arcPoint, p2, v21) // Our initial arc point\n\n const appendArcSection = function (a: number, j: number) {\n const si = j * 9\n const ai = j * 3\n v3toArray(p2, sectorVertices, si)\n v3toArray(arcPoint, sectorVertices, si + 3)\n v3toArray(arcPoint, arcVertices1, ai)\n\n calcArcPoint(arcPoint, p2, v21, cross2, a)\n\n v3toArray(arcPoint, sectorVertices, si + 6)\n v3toArray(arcPoint, arcVertices2, ai)\n }\n\n let j = 0\n for (let a = angleStep; a < angle; a += angleStep) {\n appendArcSection(a, j)\n j++\n }\n appendArcSection(angle, j)\n totalSegments += nSegments\n }\n\n // Flatten nested arrays of arc/segment points\n const arcSize = totalSegments * 3\n const sectorSize = totalSegments * 9\n const arcPosition1 = new Float32Array(arcSize)\n const arcPosition2 = new Float32Array(arcSize)\n const sectorPosition = new Float32Array(sectorSize)\n\n let sectorOffset = 0\n let arcOffset = 0\n for (let i = 0; i < n; i++) {\n const ap1 = arcPositionTmp1[ i ]\n const ap2 = arcPositionTmp2[ i ]\n copyArray(ap1, arcPosition1, 0, arcOffset, ap1.length)\n copyArray(ap2, arcPosition2, 0, arcOffset, ap2.length)\n arcOffset += ap1.length // === ap2.length\n\n const sp = sectorPositionTmp[ i ]\n copyArray(sp, sectorPosition, 0, sectorOffset, sp.length)\n sectorOffset += sp.length\n }\n\n return {\n labelPosition,\n labelText,\n vectorPosition1,\n vectorPosition2,\n arcPosition1,\n arcPosition2,\n sectorPosition\n }\n}\n\nRepresentationRegistry.add('angle', AngleRepresentation)\n\nexport default AngleRepresentation\n","/**\n * @file Cylinder Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3, CylinderBufferGeometry } from 'three'\n\nimport { defaults } from '../utils'\nimport { calculateCenterArray, serialBlockArray } from '../math/array-utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { CylinderBufferData } from './cylinder-buffer'\nimport { BufferDefaultParameters, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\nconst eye = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3(0, 1, 0)\n\nexport const CylinderGeometryBufferDefaultParameters = Object.assign({\n radialSegments: 1,\n openEnded: true\n}, BufferDefaultParameters)\nexport type CylinderGeometryBufferParameters = BufferParameters & {radialSegments: number, openEnded: boolean}\n\nfunction getData (data: CylinderBufferData, params: Partial = {}) {\n const geo = getGeo(params)\n\n const n = data.position1.length\n\n const geoLength = (geo.attributes as any).position.array.length / 3\n const count = n / 3\n const primitiveId = new Float32Array(count * 2 * geoLength)\n serialBlockArray(count, geoLength, 0, primitiveId)\n serialBlockArray(count, geoLength, count * geoLength, primitiveId)\n\n const position = new Float32Array(n * 2)\n const color = new Float32Array(n * 2)\n\n return {\n position, color, primitiveId, picking: data.picking\n }\n}\n\nfunction getGeo (params: Partial = {}) {\n const radialSegments = defaults(params.radialSegments, 10)\n const openEnded = defaults(params.openEnded, true)\n const matrix = new Matrix4().makeRotationX(Math.PI / 2)\n\n const geo = new CylinderBufferGeometry(\n 1, // radiusTop,\n 1, // radiusBottom,\n 1, // height,\n radialSegments, // radialSegments,\n 1, // heightSegments,\n openEnded // openEnded\n )\n geo.applyMatrix4(matrix)\n\n return geo\n}\n\n/**\n * Cylinder geometry buffer.\n *\n * @example\n * var cylinderGeometryBuffer = new CylinderGeometryBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass CylinderGeometryBuffer extends GeometryBuffer {\n updateNormals = true\n\n get defaultParameters() { return CylinderGeometryBufferDefaultParameters }\n parameters: CylinderGeometryBufferParameters\n\n __center: Float32Array\n _position: Float32Array\n _color: Float32Array\n _from: Float32Array\n _to: Float32Array\n _radius: Float32Array\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - from colors\n * @param {Float32Array} data.color2 - to colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n */\n constructor (data: CylinderBufferData, params: Partial = {}) {\n super(getData(data, params), params, getGeo(params))\n\n const n = data.position1.length\n const m = data.radius.length\n\n this.__center = new Float32Array(n)\n this._position = new Float32Array(n * 2)\n this._color = new Float32Array(n * 2)\n this._from = new Float32Array(n * 2)\n this._to = new Float32Array(n * 2)\n this._radius = new Float32Array(m * 2)\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n eye.fromArray(this._from as any, i3)\n target.fromArray(this._to as any, i3)\n matrix.lookAt(eye, target, up)\n\n const r = this._radius[ i ]\n scale.set(r, r, eye.distanceTo(target))\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n const meshData: Partial = {}\n\n if (data.position1 && data.position2) {\n calculateCenterArray(\n data.position1, data.position2, this.__center\n )\n calculateCenterArray(\n data.position1, this.__center, this._position\n )\n calculateCenterArray(\n this.__center, data.position2, this._position, data.position1.length\n )\n this._from.set(data.position1)\n this._from.set(this.__center, data.position1.length)\n this._to.set(this.__center)\n this._to.set(data.position2, this.__center.length)\n meshData.position = this._position\n }\n\n if (data.color && data.color2) {\n this._color.set(data.color)\n this._color.set(data.color2, data.color.length)\n meshData.color = this._color\n }\n\n if (data.radius) {\n this._radius.set(data.radius)\n this._radius.set(data.radius, data.radius.length)\n meshData.radius = this._radius\n }\n\n super.setAttributes(meshData, initNormals)\n }\n}\n\nexport default CylinderGeometryBuffer\n","/**\n * @file Mapped Aligned Box Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { BufferParameters, BufferData } from './buffer'\nimport MappedBuffer from './mapped-buffer'\n\n// +Y /\n// 0**********2\n// * | / **\n// * |/ * *\n// -----------3---- +X\n// * /| * *\n// * / | * *\n// 1/**|******4\n// / | * *\n// / | ** \n// +Z | 5 \nconst mapping = new Float32Array([\n -1.0, 1.0, -1.0,\n -1.0, -1.0, -1.0,\n 1.0, 1.0, -1.0,\n 1.0, 1.0, 1.0,\n 1.0, -1.0, -1.0,\n 1.0, -1.0, 1.0\n])\n\nconst mappingIndices = new Uint16Array([\n 0, 1, 2,\n 1, 4, 2,\n 2, 4, 3,\n 4, 5, 3\n])\n\n/**\n * Mapped Aligned box buffer. Draws boxes where one side is always screen-space aligned.\n * Used to render cylinder imposters.\n * @interface\n */\nclass MappedAlignedBoxBuffer extends MappedBuffer {\n constructor(data: BufferData, params: Partial = {}) {\n super('v3', data, params)\n }\n get mapping () { return mapping }\n get mappingIndices () { return mappingIndices }\n get mappingIndicesSize () { return 12 }\n get mappingSize () { return 6 }\n get mappingItemSize () { return 3 }\n}\n\nexport default MappedAlignedBoxBuffer\n","/**\n * @file Cylinder Impostor Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3 required for declaration only\nimport { Matrix4, Vector3 } from 'three'\n\nimport '../shader/CylinderImpostor.vert'\nimport '../shader/CylinderImpostor.frag'\n\nimport MappedAlignedBoxBuffer from './mappedalignedbox-buffer'\nimport { BufferDefaultParameters, BufferParameters, BufferParameterTypes, BufferTypes } from './buffer'\nimport { CylinderBufferData } from './cylinder-buffer'\n\nexport const CylinderImpostorBufferDefaultParameters = Object.assign({\n openEnded: false\n}, BufferDefaultParameters)\nexport type CylinderImpostorBufferParameters = BufferParameters & { openEnded: boolean }\n\nconst CylinderImpostorBufferParameterTypes = Object.assign({\n openEnded: { updateShader: true }\n}, BufferParameterTypes)\n\n/**\n * Cylinder impostor buffer.\n *\n * @example\n * var cylinderimpostorBuffer = new CylinderImpostorBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass CylinderImpostorBuffer extends MappedAlignedBoxBuffer {\n parameterTypes = CylinderImpostorBufferParameterTypes\n get defaultParameters() { return CylinderImpostorBufferDefaultParameters }\n parameters: CylinderImpostorBufferParameters\n\n isImpostor = true\n vertexShader = 'CylinderImpostor.vert'\n fragmentShader = 'CylinderImpostor.frag'\n\n /**\n * make cylinder impostor buffer\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - from colors\n * @param {Float32Array} data.color2 - to colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} data.picking - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: CylinderBufferData, params: Partial = {}) {\n super(data, params)\n\n this.addUniforms({\n 'modelViewMatrixInverse': { value: new Matrix4() },\n 'ortho': { value: 0.0 }\n })\n\n this.addAttributes({\n 'position1': { type: 'v3', value: null },\n 'position2': { type: 'v3', value: null },\n 'color2': { type: 'c', value: null },\n 'radius': { type: 'f', value: null }\n })\n\n this.setAttributes(data)\n this.makeMapping()\n }\n\n getDefines (type?: BufferTypes) {\n const defines = MappedAlignedBoxBuffer.prototype.getDefines.call(this, type)\n\n if (!this.parameters.openEnded) {\n defines.CAP = 1\n }\n\n return defines\n }\n}\n\nexport default CylinderImpostorBuffer\n","/**\n * @file Cylinder Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import required for declaration only\nimport { Vector3, Matrix4 } from 'three'\nimport { BufferRegistry, ExtensionFragDepth } from '../globals'\nimport CylinderGeometryBuffer, { CylinderGeometryBufferDefaultParameters, CylinderGeometryBufferParameters } from './cylindergeometry-buffer'\nimport CylinderImpostorBuffer, { CylinderImpostorBufferDefaultParameters, CylinderImpostorBufferParameters } from './cylinderimpostor-buffer'\nimport { BufferData } from './buffer'\n\nexport interface CylinderBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n color2: Float32Array\n radius: Float32Array\n}\n\nexport const CylinderBufferDefaultParameters = Object.assign({\n disableImpostor: false\n}, CylinderGeometryBufferDefaultParameters, CylinderImpostorBufferDefaultParameters)\nexport type CylinderBufferParameters = (CylinderGeometryBufferParameters & {disableImpostor: boolean}) | (CylinderImpostorBufferParameters & {disableImpostor: boolean})\n\nclass CylinderBufferImpl {\n constructor (data: CylinderBufferData, params: Partial = {}) {\n if (!data.color2 && data.color) data.color2 = data.color\n if (!ExtensionFragDepth || (params && params.disableImpostor)) {\n return new CylinderGeometryBuffer(data, params)\n } else {\n return new CylinderImpostorBuffer(data, params)\n }\n }\n}\n\n/**\n * Cylinder buffer. Depending on the value {@link ExtensionFragDepth} and\n * `params.disableImpostor` the constructor returns either a\n * {@link CylinderGeometryBuffer} or a {@link CylinderImpostorBuffer}\n * @implements {Buffer}\n *\n * @example\n * var cylinderBuffer = new CylinderBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\n//@ts-expect-error Incompatible constructor signatures\nconst CylinderBuffer: {\n new(data: CylinderBufferData, params: Partial): CylinderGeometryBuffer | CylinderImpostorBuffer;\n} = CylinderBufferImpl;\n\ntype CylinderBuffer = CylinderGeometryBuffer | CylinderImpostorBuffer;\n\nBufferRegistry.add('cylinder', CylinderBuffer)\n\nexport default CylinderBuffer\n","/**\n * @file Axes Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { Color, Vector3 } from 'three'\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { AxesPicker } from '../utils/picker'\nimport { uniformArray, uniformArray3 } from '../math/array-utils'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport CylinderBuffer, { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport StructureView from '../structure/structure-view';\nimport Viewer from '../viewer/viewer';\nimport { Structure } from '../ngl';\nimport { AtomDataFields } from '../structure/structure-data';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport PrincipalAxes from '../math/principal-axes';\n\nexport interface AxesRepresentationParameters extends StructureRepresentationParameters {\n showAxes: boolean\n showBox: boolean\n}\n\n/**\n * Axes representation. Show principal axes and/or a box aligned with them\n * that fits the structure or selection.\n *\n * __Name:__ _axes_\n *\n * @example\n * stage.loadFile( \"rcsb://3pqr\", {\n * assembly: \"BU1\"\n * } ).then( function( o ){\n * o.addRepresentation( \"cartoon\" );\n * o.addRepresentation( \"axes\", {\n * sele: \"RET\", showAxes: false, showBox: true, radius: 0.2\n * } );\n * o.addRepresentation( \"ball+stick\", { sele: \"RET\" } );\n * o.addRepresentation( \"axes\", {\n * sele: \":B and backbone\", showAxes: false, showBox: true, radius: 0.2\n * } );\n * stage.autoView();\n * var pa = o.structure.getPrincipalAxes();\n * stage.animationControls.rotate( pa.getRotationQuaternion(), 1500 );\n * } );\n */\nclass AxesRepresentation extends StructureRepresentation {\n \n protected showAxes: boolean\n protected showBox: boolean\n protected sphereBuffer: SphereBuffer\n protected cylinderBuffer: CylinderBuffer\n /**\n * @param {Structure} structure - the structure object\n * @param {Viewer} viewer - the viewer object\n * @param {StructureRepresentationParameters} params - parameters object\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'axes'\n\n this.parameters = Object.assign({\n\n radiusSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n sphereDetail: true,\n radialSegments: true,\n disableImpostor: true,\n showAxes: {\n type: 'boolean', rebuild: true\n },\n showBox: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n assembly: null\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.radiusSize = defaults(p.radiusSize, 0.5)\n p.colorValue = defaults(p.colorValue, 'lightgreen')\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.showAxes = defaults(p.showAxes, true)\n this.showBox = defaults(p.showBox, false)\n\n super.init(p)\n }\n\n getPrincipalAxes (): PrincipalAxes {\n let selection\n const assembly = this.getAssembly()\n\n if (assembly) {\n selection = assembly.partList[ 0 ].getSelection()\n }\n\n return this.structureView.getPrincipalAxes(selection)\n }\n\n getAxesData (sview: StructureView) {\n const pa = this.getPrincipalAxes()\n const c = new Color(this.colorValue)\n\n let vn = 0\n let en = 0\n\n if (this.showAxes) {\n vn += 6\n en += 3\n }\n\n if (this.showBox) {\n vn += 8\n en += 12\n }\n\n const vertexPosition = new Float32Array(3 * vn)\n const vertexColor = uniformArray3(vn, c.r, c.g, c.b)\n const vertexRadius = uniformArray(vn, this.radiusSize)\n\n const edgePosition1 = new Float32Array(3 * en)\n const edgePosition2 = new Float32Array(3 * en)\n const edgeColor = uniformArray3(en, c.r, c.g, c.b)\n const edgeRadius = uniformArray(en, this.radiusSize)\n\n let offset = 0\n\n if (this.showAxes) {\n const addAxis = function (v1: Vector3, v2: Vector3) {\n v1.toArray(vertexPosition as any, offset * 2)\n v2.toArray(vertexPosition as any, offset * 2 + 3)\n v1.toArray(edgePosition1 as any, offset)\n v2.toArray(edgePosition2 as any, offset)\n offset += 3\n }\n\n addAxis(pa.begA, pa.endA)\n addAxis(pa.begB, pa.endB)\n addAxis(pa.begC, pa.endC)\n }\n\n if (this.showBox) {\n const v = new Vector3()\n const { d1a, d2a, d3a, d1b, d2b, d3b } = pa.getProjectedScaleForAtoms(sview)\n\n // console.log(d1a, d2a, d3a, d1b, d2b, d3b)\n\n let offset2 = offset * 2\n const addCorner = function (d1: number, d2: number, d3: number) {\n v.copy(pa.center)\n .addScaledVector(pa.normVecA, d1)\n .addScaledVector(pa.normVecB, d2)\n .addScaledVector(pa.normVecC, d3)\n v.toArray(vertexPosition as any, offset2)\n offset2 += 3\n }\n addCorner(d1a, d2a, d3a)\n addCorner(d1a, d2a, d3b)\n addCorner(d1a, d2b, d3b)\n addCorner(d1a, d2b, d3a)\n addCorner(d1b, d2b, d3b)\n addCorner(d1b, d2b, d3a)\n addCorner(d1b, d2a, d3a)\n addCorner(d1b, d2a, d3b)\n\n let edgeOffset = offset\n const addEdge = function (a: number, b: number) {\n v.fromArray(vertexPosition as any, offset * 2 + a * 3)\n .toArray(edgePosition1 as any, edgeOffset)\n v.fromArray(vertexPosition as any, offset * 2 + b * 3)\n .toArray(edgePosition2 as any, edgeOffset)\n edgeOffset += 3\n }\n addEdge(0, 1)\n addEdge(0, 3)\n addEdge(0, 6)\n addEdge(1, 2)\n addEdge(1, 7)\n addEdge(2, 3)\n addEdge(2, 4)\n addEdge(3, 5)\n addEdge(4, 5)\n addEdge(4, 7)\n addEdge(5, 6)\n addEdge(6, 7)\n }\n\n const picker = new AxesPicker(pa)\n\n return {\n vertex: {\n position: vertexPosition,\n color: vertexColor,\n radius: vertexRadius,\n picking: picker\n },\n edge: {\n position1: edgePosition1,\n position2: edgePosition2,\n color: edgeColor,\n color2: edgeColor,\n radius: edgeRadius,\n picking: picker\n }\n }\n }\n\n create () {\n const axesData = this.getAxesData(this.structureView)\n\n this.sphereBuffer = new SphereBuffer(\n axesData.vertex as SphereBufferData,\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters\n )\n\n this.cylinderBuffer = new CylinderBuffer(\n axesData.edge as CylinderBufferData,\n this.getBufferParams({\n openEnded: true,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n this.dataList.push({\n sview: this.structureView,\n bufferList: [ this.sphereBuffer as SphereGeometryBuffer, this.cylinderBuffer as CylinderGeometryBuffer]\n })\n }\n\n createData (sview: StructureView): undefined {\n return\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n const axesData = this.getAxesData(data.sview as StructureView)\n const sphereData = {}\n const cylinderData = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {\n position: axesData.vertex.position\n })\n Object.assign(cylinderData, {\n position1: axesData.edge.position1,\n position2: axesData.edge.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {\n color: axesData.vertex.color as Float32Array\n })\n Object.assign(cylinderData, {\n color: axesData.edge.color as Float32Array,\n color2: axesData.edge.color as Float32Array\n })\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {\n radius: axesData.vertex.radius as Float32Array\n })\n Object.assign(cylinderData, {\n radius: axesData.edge.radius as Float32Array\n })\n }\n\n (this.sphereBuffer as SphereGeometryBuffer).setAttributes(sphereData);\n (this.cylinderBuffer as CylinderGeometryBuffer).setAttributes(cylinderData)\n }\n}\n\nRepresentationRegistry.add('axes', AxesRepresentation)\n\nexport default AxesRepresentation\n","/**\n * @file Ball And Stick Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { ExtensionFragDepth, RepresentationRegistry } from '../globals'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport CylinderBuffer, { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport WideLineBuffer from '../buffer/wideline-buffer'\nimport Viewer from '../viewer/viewer';\n// @ts-ignore: unused import Volume required for declaration only\nimport { Structure, Volume } from '../ngl';\nimport AtomProxy from '../proxy/atom-proxy';\nimport { AtomDataParams, BondDataParams, BondDataFields, AtomDataFields, BondData, AtomData } from '../structure/structure-data';\nimport StructureView from '../structure/structure-view';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\n// @ts-ignore: unused import Surface required for declaration only\nimport Surface from '../surface/surface';\n\nexport interface BallAndStickRepresentationParameters extends StructureRepresentationParameters {\n sphereDetail: number\n radialSegments: number\n openEnded: boolean\n disableImpostor: boolean\n aspectRatio: number\n lineOnly: boolean\n lineWidth: number\n cylinderOnly: boolean\n multipleBond: 'off' | 'symmetric' | 'offset'\n bondSpacing: number\n bondScale: number\n linewidth: number\n}\n\n/**\n * Ball And Stick representation parameter object. Extends {@link RepresentationParameters} and\n * {@link StructureRepresentationParameters}.\n *\n * @typedef {Object} BallAndStickRepresentationParameters - ball and stick representation parameters\n *\n * @property {Integer} sphereDetail - sphere quality (icosahedron subdivisions)\n * @property {Integer} radialSegments - cylinder quality (number of segments)\n * @property {Boolean} openEnded - capped or not\n * @property {Boolean} disableImpostor - disable use of raycasted impostors for rendering\n * @property {Float} aspectRatio - size difference between atom and bond radii\n * @property {Boolean} lineOnly - render only bonds, and only as lines\n * @property {Integer} linewidth - width of lines\n * @property {Boolean} cylinderOnly - render only bonds (no atoms)\n * @property {String} multipleBond - one off \"off\", \"symmetric\", \"offset\"\n * @property {Float} bondSpacing - spacing for multiple bond rendering\n * @property {Float} bondScale - scale/radius for multiple bond rendering\n */\n\n/**\n * Ball And Stick representation. Show atoms as spheres and bonds as cylinders.\n *\n * __Name:__ _ball+stick_\n *\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"ball+stick\" );\n * o.autoView();\n * } );\n */\nclass BallAndStickRepresentation extends StructureRepresentation {\n protected sphereDetail: number\n protected radialSegments: number\n protected openEnded: boolean\n protected disableImpostor: boolean\n protected aspectRatio: number\n protected lineOnly: boolean\n protected lineWidth: number\n protected cylinderOnly: boolean\n protected multipleBond: 'off' | 'symmetric' | 'offset'\n protected bondSpacing: number\n protected bondScale: number\n protected linewidth: number\n\n protected lineBuffer: WideLineBuffer\n /**\n * Create Ball And Stick representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {BallAndStickRepresentationParameters} params - ball and stick representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'ball+stick'\n\n this.parameters = Object.assign({\n\n sphereDetail: true,\n radialSegments: true,\n openEnded: true,\n disableImpostor: true,\n aspectRatio: {\n type: 'number', precision: 1, max: 10.0, min: 1.0\n },\n lineOnly: {\n type: 'boolean', rebuild: true\n },\n cylinderOnly: {\n type: 'boolean', rebuild: true\n },\n multipleBond: {\n type: 'select',\n rebuild: true,\n options: {\n 'off': 'off',\n 'symmetric': 'symmetric',\n 'offset': 'offset'\n }\n },\n bondScale: {\n type: 'number', precision: 2, max: 1.0, min: 0.01\n },\n bondSpacing: {\n type: 'number', precision: 2, max: 2.0, min: 0.5\n },\n linewidth: {\n type: 'integer', max: 50, min: 1, buffer: true\n }\n\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.radiusType = defaults(p.radiusType, 'size')\n p.radiusSize = defaults(p.radiusSize, 0.15)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.aspectRatio = defaults(p.aspectRatio, 2.0)\n this.lineOnly = defaults(p.lineOnly, false)\n this.cylinderOnly = defaults(p.cylinderOnly, false)\n this.multipleBond = defaults(p.multipleBond, 'off')\n this.bondSpacing = defaults(p.bondSpacing, 1.0)\n this.bondScale = defaults(p.bondScale, 0.4)\n this.linewidth = defaults(p.linewidth, 2)\n\n super.init(p)\n }\n\n getAtomRadius (atom: AtomProxy) {\n return this.aspectRatio * super.getAtomRadius(atom)\n }\n\n getAtomParams (what?: AtomDataFields, params?: Partial) {\n var p = super.getAtomParams(what, params)\n p.radiusParams.scale *= this.aspectRatio\n\n return p\n }\n\n getAtomData (sview: StructureView, what?: AtomDataFields, params?: Partial): AtomData {\n return sview.getAtomData(this.getAtomParams(what, params))\n }\n\n getBondParams (what?: BondDataFields, params?: Partial) {\n params = Object.assign({\n multipleBond: this.multipleBond,\n bondSpacing: this.bondSpacing,\n bondScale: this.bondScale\n }, params)\n\n return super.getBondParams(what, params)\n }\n\n getBondData (sview: StructureView, what?: BondDataFields, params?: Partial): BondData {\n return sview.getBondData(this.getBondParams(what, params))\n }\n\n createData (sview: StructureView) {\n const bufferList: any[] = []\n\n if (this.lineOnly) {\n this.lineBuffer = new WideLineBuffer(\n this.getBondData(sview, { position: true, color: true, picking: true }),\n this.getBufferParams({ linewidth: this.linewidth })\n )\n\n bufferList.push(this.lineBuffer)\n } else {\n const cylinderBuffer = new CylinderBuffer(\n (this.getBondData(sview) as CylinderBufferData),\n this.getBufferParams({\n openEnded: this.openEnded,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n bufferList.push(cylinderBuffer as CylinderGeometryBuffer)\n\n if (!this.cylinderOnly) {\n const sphereBuffer = new SphereBuffer(\n (this.getAtomData(sview) as SphereBufferData),\n (this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters)\n )\n\n bufferList.push(sphereBuffer as SphereGeometryBuffer)\n }\n }\n\n return {\n bufferList: bufferList\n }\n }\n\n updateData (what: BondDataFields | AtomDataFields, data: StructureRepresentationData) {\n if (this.multipleBond !== 'off' && what && what.radius) {\n what.position = true\n }\n\n const bondData = this.getBondData(data.sview as StructureView, what)\n\n if (this.lineOnly) {\n const lineData:Partial = {}\n\n if (!what || what.position) {\n Object.assign(lineData, {\n position1: bondData.position1,\n position2: bondData.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(lineData, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n data.bufferList[ 0 ].setAttributes(lineData)\n } else {\n var cylinderData: Partial = {}\n\n if (!what || what.position) {\n Object.assign(cylinderData, {\n position1: bondData.position1,\n position2: bondData.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(cylinderData, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n if (!what || what.radius) {\n Object.assign(cylinderData, {\n radius: bondData.radius\n })\n }\n\n data.bufferList[ 0 ].setAttributes(cylinderData)\n\n if (!this.cylinderOnly) {\n var atomData = this.getAtomData(data.sview as StructureView, what)\n\n var sphereData: Partial = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {\n position: atomData.position\n })\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {\n color: atomData.color\n })\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {\n radius: atomData.radius\n })\n }\n\n data.bufferList[ 1 ].setAttributes(sphereData)\n }\n }\n }\n\n setParameters (params: Partial = {}) {\n let rebuild = false\n const what: AtomDataFields = {}\n\n if (params.aspectRatio || params.bondSpacing || params.bondScale) {\n Object.assign(what, {radius: true})\n if (!ExtensionFragDepth || this.disableImpostor) {\n rebuild = true\n }\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('ball+stick', BallAndStickRepresentation)\n\nexport default BallAndStickRepresentation\n","/**\n * @file Backbone Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport BallAndStickRepresentation, { BallAndStickRepresentationParameters } from './ballandstick-representation'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport StructureView from '../structure/structure-view';\nimport { AtomDataFields, AtomDataParams, BondDataFields, BondDataParams, BondData, AtomData } from '../structure/structure-data';\n\n/**\n * Backbone representation. Show cylinders (or lines) connecting .CA (protein)\n * or .C4'/.C3' (RNA/DNA) of polymers.\n *\n * __Name:__ _backbone_\n *\n * @example\n * stage.loadFile( \"rcsb://1sfi\" ).then( function( o ){\n * o.addRepresentation( \"backbone\" );\n * o.autoView();\n * } );\n */\nclass BackboneRepresentation extends BallAndStickRepresentation {\n /**\n * @param {Structure} structure - the structure object\n * @param {Viewer} viewer - the viewer object\n * @param {BallAndStickRepresentationParameters} params - parameters object\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'backbone'\n\n this.parameters = Object.assign({\n\n }, this.parameters, {\n\n multipleBond: null,\n bondSpacing: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.aspectRatio = defaults(p.aspectRatio, 1.0)\n p.radiusSize = defaults(p.radiusSize, 0.25)\n\n super.init(p)\n }\n\n getAtomRadius (atom: AtomProxy) {\n return atom.isTrace() ? super.getAtomRadius(atom) : 0\n }\n\n getAtomData (sview: StructureView, what?: AtomDataFields, params?: Partial): AtomData {\n return sview.getBackboneAtomData(this.getAtomParams(what, params))\n }\n\n getBondData (sview: StructureView, what?: BondDataFields, params?: Partial): BondData {\n return sview.getBackboneBondData(this.getBondParams(what, params))\n }\n}\n\nRepresentationRegistry.add('backbone', BackboneRepresentation)\n\nexport default BackboneRepresentation\n","/**\n * @file Base Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport BallAndStickRepresentation, { BallAndStickRepresentationParameters } from './ballandstick-representation'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { AtomDataFields, AtomDataParams, BondDataFields, BondDataParams, BondData, AtomData } from '../structure/structure-data';\n\n/**\n * Base representation. Show cylinders for RNA/DNA ladders.\n *\n * __Name:__ _base_\n *\n * @example\n * stage.loadFile( \"rcsb://1d66\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\", { sele: \"nucleic\" } );\n * o.addRepresentation( \"base\", { color: \"resname\" } );\n * o.autoView( \"nucleic\" );\n * } );\n */\nclass BaseRepresentation extends BallAndStickRepresentation {\n /**\n * @param {Structure} structure - the structure object\n * @param {Viewer} viewer - the viewer object\n * @param {BallAndStickRepresentationParameters} params - parameters object\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'base'\n\n this.parameters = Object.assign({\n\n }, this.parameters, {\n\n multipleBond: null,\n bondSpacing: null\n\n })\n }\n\n init (params: Partial) {\n let p = params || {}\n p.aspectRatio = defaults(p.aspectRatio, 1.0)\n p.radiusSize = defaults(p.radiusSize, 0.3)\n\n super.init(p)\n }\n\n getAtomData (sview: StructureView, what?: AtomDataFields, params?: AtomDataParams): AtomData {\n return sview.getRungAtomData(this.getAtomParams(what, params))\n }\n\n getBondData (sview: StructureView, what?: BondDataFields, params?: BondDataParams): BondData {\n let p = this.getBondParams(what, params)\n Object.assign(p.colorParams, {rung: true})\n\n return sview.getRungBondData(p)\n }\n}\n\nRepresentationRegistry.add('base', BaseRepresentation)\n\nexport default BaseRepresentation\n","/**\n * @file Spline\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport { AtomPicker } from '../utils/picker'\nimport RadiusFactory, { RadiusParams } from '../utils/radius-factory'\nimport { copyArray } from '../math/array-utils'\nimport { spline } from '../math/math-utils'\nimport Polymer from '../proxy/polymer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport { ColormakerParameters } from '../color/colormaker';\nimport { NumberArray } from '../types';\n\nexport class Interpolator {\n \n m: number\n tension: number\n dt: number\n delta: number\n vec1: Vector3\n vec2: Vector3\n vDir: Vector3 \n vTan: Vector3\n vNorm: Vector3\n vBin: Vector3\n m2: number\n\n constructor (m: number, tension: number) {\n this.m = m\n this.tension = tension\n this.dt = 1.0 / this.m\n this.delta = 0.0001\n\n this.vec1 = new Vector3()\n this.vec2 = new Vector3()\n\n this.vDir = new Vector3()\n this.vTan = new Vector3()\n this.vNorm = new Vector3()\n this.vBin = new Vector3()\n \n this.m2 = Math.ceil(this.m / 2)\n }\n\n private interpolateToArr (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, t: number, arr: Float32Array, offset: number) {\n arr[ offset + 0 ] = spline(v0.x, v1.x, v2.x, v3.x, t, this.tension)\n arr[ offset + 1 ] = spline(v0.y, v1.y, v2.y, v3.y, t, this.tension)\n arr[ offset + 2 ] = spline(v0.z, v1.z, v2.z, v3.z, t, this.tension)\n }\n\n private interpolateToVec (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, t: number, vec: Vector3) {\n vec.x = spline(v0.x, v1.x, v2.x, v3.x, t, this.tension)\n vec.y = spline(v0.y, v1.y, v2.y, v3.y, t, this.tension)\n vec.z = spline(v0.z, v1.z, v2.z, v3.z, t, this.tension)\n }\n\n private interpolatePosition (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, pos: Float32Array, offset: number) {\n for (var j = 0; j < this.m; ++j) {\n var l = offset + j * 3\n var d = this.dt * j\n this.interpolateToArr(v0, v1, v2, v3, d, pos, l)\n }\n }\n\n private interpolateTangent (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, tan: Float32Array, offset: number) {\n for (var j = 0; j < this.m; ++j) {\n var d = this.dt * j\n var d1 = d - this.delta\n var d2 = d + this.delta\n var l = offset + j * 3\n // capping as a precaution\n if (d1 < 0) d1 = 0\n if (d2 > 1) d2 = 1\n //\n this.interpolateToVec(v0, v1, v2, v3, d1, this.vec1)\n this.interpolateToVec(v0, v1, v2, v3, d2, this.vec2)\n //\n this.vec2.sub(this.vec1).normalize()\n this.vec2.toArray(tan as any, l)\n }\n }\n\n private vectorSubdivide (interpolationFn: (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, array: Float32Array, offset: number) => void,\n iterator: AtomIterator, array: Float32Array, offset: number, isCyclic: boolean) {\n let v0: Vector3\n let v1 = iterator.next()\n let v2 = iterator.next()\n let v3 = iterator.next()\n //\n const n = iterator.size\n const n1 = n - 1\n let k = offset || 0\n for (let i = 0; i < n1; ++i) {\n v0 = v1\n v1 = v2\n v2 = v3\n v3 = iterator.next()\n interpolationFn.apply(this, [v0, v1, v2, v3, array, k])\n k += 3 * this.m\n }\n if (isCyclic) {\n v0 = iterator.get(n - 2)\n v1 = iterator.get(n - 1)\n v2 = iterator.get(0)\n v3 = iterator.get(1)\n interpolationFn.apply(this, [v0, v1, v2, v3, array, k])\n k += 3 * this.m\n }\n }\n\n //\n\n public getPosition (iterator: AtomIterator, array: Float32Array, offset: number, isCyclic: boolean) {\n iterator.reset()\n this.vectorSubdivide(this.interpolatePosition, iterator, array, offset, isCyclic)\n var n1 = iterator.size - 1\n var k = n1 * this.m * 3\n if (isCyclic) k += this.m * 3\n var v = iterator.get(isCyclic ? 0 : n1)\n array[ k ] = v.x\n array[ k + 1 ] = v.y\n array[ k + 2 ] = v.z\n }\n\n public getTangent (iterator: AtomIterator, array: Float32Array, offset: number, isCyclic: boolean) {\n iterator.reset()\n this.vectorSubdivide(this.interpolateTangent, iterator, array, offset, isCyclic)\n const n1 = iterator.size - 1\n let k = n1 * this.m * 3\n if (isCyclic) k += this.m * 3\n copyArray(array, array, k - 3, k, 3)\n }\n\n private interpolateNormalDir (u0: Vector3, u1: Vector3, u2: Vector3, u3: Vector3,\n v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3,\n tan: Float32Array, norm: Float32Array, bin: Float32Array,\n offset: number, shift: boolean) {\n for (let j = 0; j < this.m; ++j) {\n let l = offset + j * 3\n if (shift) l += this.m2 * 3\n const d = this.dt * j\n this.interpolateToVec(u0, u1, u2, u3, d, this.vec1)\n this.interpolateToVec(v0, v1, v2, v3, d, this.vec2)\n this.vDir.subVectors(this.vec2, this.vec1).normalize()\n this.vTan.fromArray(tan as any, l)\n this.vBin.crossVectors(this.vDir, this.vTan).normalize()\n this.vBin.toArray(bin as any, l)\n this.vNorm.crossVectors(this.vTan, this.vBin).normalize()\n this.vNorm.toArray(norm as any, l)\n }\n }\n\n private interpolateNormal (vDir: Vector3, tan: Float32Array, norm: Float32Array, bin: Float32Array, offset: number) {\n for (var j = 0; j < this.m; ++j) {\n var l = offset + j * 3\n vDir.copy(this.vNorm)\n this.vTan.fromArray(tan as any, l)\n this.vBin.crossVectors(vDir, this.vTan).normalize()\n this.vBin.toArray(bin as any, l)\n this.vNorm.crossVectors(this.vTan, this.vBin).normalize()\n this.vNorm.toArray(norm as any, l)\n }\n }\n\n public getNormal (size: number, tan: Float32Array, norm: Float32Array, bin: Float32Array, offset: number, isCyclic: boolean) {\n this.vNorm.set(0, 0, 1)\n const n = size\n const n1 = n - 1\n let k = offset || 0\n for (var i = 0; i < n1; ++i) {\n this.interpolateNormal(this.vDir, tan, norm, bin, k)\n k += 3 * this.m\n }\n if (isCyclic) {\n this.interpolateNormal(this.vDir, tan, norm, bin, k)\n k += 3 * this.m\n }\n this.vBin.toArray(bin as any, k)\n this.vNorm.toArray(norm as any, k)\n }\n\n public getNormalDir (iterDir1: AtomIterator, iterDir2: AtomIterator, tan: Float32Array, norm: Float32Array, bin: Float32Array, offset: number, isCyclic: boolean, shift: boolean) {\n iterDir1.reset()\n iterDir2.reset()\n //\n const vSub1 = new Vector3()\n const vSub2 = new Vector3()\n const vSub3 = new Vector3()\n const vSub4 = new Vector3()\n //\n const d1v1 = new Vector3()\n const d1v2 = new Vector3().copy(iterDir1.next())\n const d1v3 = new Vector3().copy(iterDir1.next())\n const d1v4 = new Vector3().copy(iterDir1.next())\n const d2v1 = new Vector3()\n const d2v2 = new Vector3().copy(iterDir2.next())\n const d2v3 = new Vector3().copy(iterDir2.next())\n const d2v4 = new Vector3().copy(iterDir2.next())\n //\n this.vNorm.set(0, 0, 1)\n let n = iterDir1.size\n let n1 = n - 1\n let k = offset || 0\n for (var i = 0; i < n1; ++i) {\n d1v1.copy(d1v2)\n d1v2.copy(d1v3)\n d1v3.copy(d1v4)\n d1v4.copy(iterDir1.next())\n d2v1.copy(d2v2)\n d2v2.copy(d2v3)\n d2v3.copy(d2v4)\n d2v4.copy(iterDir2.next())\n //\n if (i === 0) {\n vSub1.subVectors(d2v1, d1v1)\n vSub2.subVectors(d2v2, d1v2)\n if (vSub1.dot(vSub2) < 0) {\n vSub2.multiplyScalar(-1)\n d2v2.addVectors(d1v2, vSub2)\n }\n vSub3.subVectors(d2v3, d1v3)\n if (vSub2.dot(vSub3) < 0) {\n vSub3.multiplyScalar(-1)\n d2v3.addVectors(d1v3, vSub3)\n }\n } else {\n vSub3.copy(vSub4)\n }\n vSub4.subVectors(d2v4, d1v4)\n if (vSub3.dot(vSub4) < 0) {\n vSub4.multiplyScalar(-1)\n d2v4.addVectors(d1v4, vSub4)\n }\n this.interpolateNormalDir(\n d1v1, d1v2, d1v3, d1v4,\n d2v1, d2v2, d2v3, d2v4,\n tan, norm, bin, k, shift\n )\n k += 3 * this.m\n }\n if (isCyclic) {\n d1v1.copy(iterDir1.get(n - 2))\n d1v2.copy(iterDir1.get(n - 1))\n d1v3.copy(iterDir1.get(0))\n d1v4.copy(iterDir1.get(1))\n d2v1.copy(iterDir2.get(n - 2))\n d2v2.copy(iterDir2.get(n - 1))\n d2v3.copy(iterDir2.get(0))\n d2v4.copy(iterDir2.get(1))\n //\n vSub3.copy(vSub4)\n vSub4.subVectors(d2v4, d1v4)\n if (vSub3.dot(vSub4) < 0) {\n vSub4.multiplyScalar(-1)\n d2v4.addVectors(d1v4, vSub4)\n }\n this.interpolateNormalDir(\n d1v1, d1v2, d1v3, d1v4,\n d2v1, d2v2, d2v3, d2v4,\n tan, norm, bin, k, shift\n )\n k += 3 * this.m\n }\n if (shift) {\n // FIXME shift requires data from one this.more preceeding residue\n this.vBin.fromArray(bin as any, this.m2 * 3)\n this.vNorm.fromArray(norm as any, this.m2 * 3)\n for (var j = 0; j < this.m2; ++j) {\n this.vBin.toArray(bin as any, j * 3)\n this.vNorm.toArray(norm as any, j * 3)\n }\n } else {\n this.vBin.toArray(bin as any, k)\n this.vNorm.toArray(norm as any, k)\n }\n }\n\n //\n\n private interpolateColor (item1: AtomProxy, item2: AtomProxy, colFn: (...arg: any[]) => void, col: any, offset: number) {\n var j, l\n for (j = 0; j < this.m2; ++j) {\n l = offset + j * 3\n colFn.apply(this, [item1, col, l]) // itemColorToArray\n }\n for (j = this.m2; j < this.m; ++j) {\n l = offset + j * 3\n colFn.apply(this, [item2, col, l]) // itemColorToArray\n }\n }\n\n public getColor (iterator: AtomIterator, colFn: (...arg: any[]) => void, col: any, offset: number, isCyclic: boolean) {\n iterator.reset()\n iterator.next() // first element not needed\n let i0: AtomProxy\n let i1 = iterator.next()\n //\n var n = iterator.size\n var n1 = n - 1\n var k = offset || 0\n for (var i = 0; i < n1; ++i) {\n i0 = i1\n i1 = iterator.next()\n this.interpolateColor(i0, i1, colFn, col, k)\n k += 3 * this.m\n }\n if (isCyclic) {\n i0 = iterator.get(n - 1)\n i1 = iterator.get(0)\n this.interpolateColor(i0, i1, colFn, col, k)\n k += 3 * this.m\n }\n //\n col[ k ] = col[ k - 3 ]\n col[ k + 1 ] = col[ k - 2 ]\n col[ k + 2 ] = col[ k - 1 ]\n }\n\n //\n\n private interpolatePicking (item1: AtomProxy, item2: AtomProxy, pickFn: (item: AtomProxy) => number, pick: Float32Array, offset: number) {\n var j\n for (j = 0; j < this.m2; ++j) {\n pick[ offset + j ] = pickFn.apply(this, [item1])\n }\n for (j = this.m2; j < this.m; ++j) {\n pick[ offset + j ] = pickFn.apply(this, [item2])\n }\n }\n\n public getPicking (iterator: AtomIterator, pickFn: (item: AtomProxy) => number, pick: Float32Array, offset: number, isCyclic: boolean) {\n iterator.reset()\n iterator.next() // first element not needed\n let i0: AtomProxy\n let i1 = iterator.next()\n //\n const n = iterator.size\n const n1 = n - 1\n let k = offset || 0\n for (var i = 0; i < n1; ++i) {\n i0 = i1\n i1 = iterator.next()\n this.interpolatePicking(i0, i1, pickFn, pick, k)\n k += this.m\n }\n if (isCyclic) {\n i0 = iterator.get(n - 1)\n i1 = iterator.get(0)\n this.interpolatePicking(i0, i1, pickFn, pick, k)\n k += this.m\n }\n //\n pick[ k ] = pick[ k - 1 ]\n }\n\n //\n\n private interpolateSize (item1: AtomProxy, item2: AtomProxy, sizeFn: (item: AtomProxy) => number, size: Float32Array, offset: number) {\n const s1: number = sizeFn.apply(this, [item1])\n const s2: number = sizeFn.apply(this, [item2])\n for (let j = 0; j < this.m; ++j) {\n // linear interpolation\n let t = j / this.m\n size[ offset + j ] = (1 - t) * s1 + t * s2\n }\n }\n\n public getSize (iterator: AtomIterator, sizeFn: (item: AtomProxy) => number, size: Float32Array, offset: number, isCyclic: boolean) {\n iterator.reset()\n iterator.next() // first element not needed\n let i0: AtomProxy\n let i1: AtomProxy = iterator.next()\n //\n const n = iterator.size\n const n1 = n - 1\n let k = offset || 0\n for (var i = 0; i < n1; ++i) {\n i0 = i1\n i1 = iterator.next()\n this.interpolateSize(i0, i1, sizeFn, size, k)\n k += this.m\n }\n if (isCyclic) {\n i0 = iterator.get(n - 1)\n i1 = iterator.get(0)\n this.interpolateSize(i0, i1, sizeFn, size, k)\n k += this.m\n }\n //\n size[ k ] = size[ k - 1 ]\n }\n}\n\nexport interface SplineParameters {\n directional?: boolean\n positionIterator?: boolean\n subdiv?: number\n smoothSheet?: boolean\n tension?: number\n}\nexport interface AtomIterator {\n size: number,\n next: () => AtomProxy | Vector3,\n get: (idx: number) => AtomProxy | Vector3,\n reset: () => void\n}\nclass Spline {\n\n polymer: Polymer\n size: number\n directional: boolean\n positionIterator: any\n subdiv: number\n smoothSheet: boolean\n tension: number\n interpolator: Interpolator\n\n constructor (polymer: Polymer, params?: SplineParameters) {\n this.polymer = polymer\n this.size = polymer.residueCount\n\n var p = params || {}\n this.directional = p.directional || false\n this.positionIterator = p.positionIterator || false\n this.subdiv = p.subdiv || 1\n this.smoothSheet = p.smoothSheet || false\n\n if (!p.tension) {\n this.tension = this.polymer.isNucleic() ? 0.5 : 0.9\n } else {\n this.tension = p.tension\n }\n\n this.interpolator = new Interpolator(this.subdiv, this.tension)\n }\n\n getAtomIterator (type: string, smooth?: boolean): AtomIterator {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n\n let i = 0\n let j = -1\n\n const cache = [\n structure.getAtomProxy(),\n structure.getAtomProxy(),\n structure.getAtomProxy(),\n structure.getAtomProxy()\n ]\n\n const cache2 = [\n new Vector3(),\n new Vector3(),\n new Vector3(),\n new Vector3()\n ]\n\n function next () {\n var atomProxy = get(j)\n j += 1\n return atomProxy\n }\n\n var apPrev = structure.getAtomProxy()\n var apNext = structure.getAtomProxy()\n\n function get (idx: number) {\n var atomProxy = cache[ i % 4 ]\n atomProxy.index = polymer.getAtomIndexByType(idx, type) as number\n if (smooth && idx > 0 && idx < n && atomProxy.sstruc === 'e') {\n var vec = cache2[ i % 4 ]\n apPrev.index = polymer.getAtomIndexByType(idx + 1, type) as number\n apNext.index = polymer.getAtomIndexByType(idx - 1, type) as number\n vec.addVectors(apPrev as any, apNext as any)\n .add(atomProxy as any).add(atomProxy as any)\n .multiplyScalar(0.25)\n i += 1\n return vec\n }\n i += 1\n return atomProxy\n }\n\n function reset () {\n i = 0\n j = -1\n }\n\n return {\n size: n,\n next: next,\n get: get,\n reset: reset\n }\n }\n\n getSubdividedColor (params: {scheme: string, [k: string]: any } & ColormakerParameters) {\n var m = this.subdiv\n var polymer = this.polymer\n var n = polymer.residueCount\n var n1 = n - 1\n var nCol = n1 * m * 3 + 3\n if (polymer.isCyclic) nCol += m * 3\n\n var col = new Float32Array(nCol)\n var iterator = this.getAtomIterator('trace')\n\n var p = params || {}\n p.structure = polymer.structure\n\n var colormaker = ColormakerRegistry.getScheme(p)\n\n function colFn (item: AtomProxy, array: NumberArray, offset: number) {\n colormaker.atomColorToArray(item, array, offset)\n }\n\n this.interpolator.getColor(\n iterator, colFn, col, 0, polymer.isCyclic\n )\n\n return {\n 'color': col\n }\n }\n \n getSubdividedPicking () {\n var m = this.subdiv\n var polymer = this.polymer\n var n = polymer.residueCount\n var n1 = n - 1\n var nCol = n1 * m + 1\n if (polymer.isCyclic) nCol += m\n\n var structure = polymer.structure\n var iterator = this.getAtomIterator('trace')\n var pick = new Float32Array(nCol)\n\n function pickFn (item: AtomProxy) {\n return item.index\n }\n\n this.interpolator.getPicking(\n iterator, pickFn, pick, 0, polymer.isCyclic\n )\n\n return {\n 'picking': new AtomPicker(pick, structure)\n }\n }\n\n getSubdividedPosition () {\n var pos = this.getPosition()\n\n return {\n 'position': pos\n }\n }\n \n getSubdividedOrientation () {\n const tan = this.getTangent()\n const normals = this.getNormals(tan)\n\n return {\n 'tangent': tan,\n 'normal': normals.normal,\n 'binormal': normals.binormal\n }\n }\n\n getSubdividedSize (params: RadiusParams) {\n var m = this.subdiv\n var polymer = this.polymer\n var n = polymer.residueCount\n var n1 = n - 1\n var nSize = n1 * m + 1\n if (polymer.isCyclic) nSize += m\n\n var size = new Float32Array(nSize)\n var iterator = this.getAtomIterator('trace')\n\n var radiusFactory = new RadiusFactory(params)\n\n function sizeFn (item: AtomProxy) {\n return radiusFactory.atomRadius(item)\n }\n\n this.interpolator.getSize(\n iterator, sizeFn, size, 0, polymer.isCyclic\n )\n\n return {\n 'size': size\n }\n }\n\n getPosition () {\n const m = this.subdiv\n const polymer = this.polymer\n const n = polymer.residueCount\n const n1 = n - 1\n let nPos = n1 * m * 3 + 3\n if (polymer.isCyclic) nPos += m * 3\n\n const pos = new Float32Array(nPos)\n const iterator = this.positionIterator || this.getAtomIterator('trace', this.smoothSheet)\n\n this.interpolator.getPosition(iterator, pos, 0, polymer.isCyclic)\n\n return pos\n }\n\n getTangent () {\n const m = this.subdiv\n const polymer = this.polymer\n const n = this.size\n const n1 = n - 1\n let nTan = n1 * m * 3 + 3\n if (polymer.isCyclic) nTan += m * 3\n\n const tan = new Float32Array(nTan)\n const iterator = this.positionIterator || this.getAtomIterator('trace', this.smoothSheet)\n\n this.interpolator.getTangent(iterator, tan, 0, polymer.isCyclic)\n\n return tan\n }\n\n getNormals (tan: Float32Array) {\n const m = this.subdiv\n const polymer = this.polymer\n const isProtein = polymer.isProtein()\n const n = this.size\n const n1 = n - 1\n let nNorm = n1 * m * 3 + 3\n if (polymer.isCyclic) nNorm += m * 3\n\n const norm = new Float32Array(nNorm)\n const bin = new Float32Array(nNorm)\n\n if (this.directional && !this.polymer.isCg()) {\n const iterDir1 = this.getAtomIterator('direction1')\n const iterDir2 = this.getAtomIterator('direction2')\n this.interpolator.getNormalDir(\n iterDir1, iterDir2, tan, norm, bin, 0, polymer.isCyclic, isProtein\n )\n } else {\n this.interpolator.getNormal(\n n, tan, norm, bin, 0, polymer.isCyclic\n )\n }\n\n return {\n 'normal': norm,\n 'binormal': bin\n }\n }\n\n}\n\nexport default Spline\n","/**\n * @file Tube Mesh Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Matrix4 required for declaration only\nimport { Vector3, Matrix4 } from 'three'\n\nimport { defaults, getUintArray } from '../utils'\nimport { serialArray } from '../math/array-utils'\nimport MeshBuffer from './mesh-buffer'\nimport { BufferDefaultParameters, BufferData, BufferParameters } from './buffer'\nimport {Log} from \"../globals\";\n\nconst vTangent = new Vector3()\nconst vMeshNormal = new Vector3()\n\nexport interface TubeMeshBufferData extends BufferData {\n binormal: Float32Array\n tangent: Float32Array\n size: Float32Array\n}\n\nexport const TubeMeshBufferDefaultParameters = Object.assign({\n radialSegments: 4,\n capped: false,\n aspectRatio: 1.0\n}, BufferDefaultParameters)\nexport type TubeMeshBufferParameters = BufferParameters & {\n radialSegments: number,\n capped: boolean,\n aspectRatio: number\n}\n\nfunction getData (data: TubeMeshBufferData, params: Partial = {}) {\n const radialSegments = defaults(params.radialSegments, 4)\n const capped = defaults(params.capped, false)\n\n const capVertices = capped ? radialSegments : 0\n const capTriangles = capped ? radialSegments - 2 : 0\n\n const n = data.position!.length / 3\n const n1 = n - 1\n const x = n * radialSegments * 3 + 2 * capVertices * 3\n const xi = n1 * 2 * radialSegments * 3 + 2 * capTriangles * 3\n\n return {\n position: new Float32Array(x),\n color: new Float32Array(x),\n index: getUintArray(xi, x / 3),\n normal: new Float32Array(x),\n picking: data.picking\n }\n}\n\n/**\n * Tube mesh buffer. Draws a tube.\n */\nclass TubeMeshBuffer extends MeshBuffer {\n get defaultParameters() { return TubeMeshBufferDefaultParameters }\n parameters: TubeMeshBufferParameters\n\n capVertices: number\n capTriangles: number\n size2: number\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.normal - normals\n * @param {Float32Array} data.binormal - binormals\n * @param {Float32Array} data.tangent - tangents\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.size - sizes\n * @param {Picker} data.picking - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: TubeMeshBufferData, params: Partial = {}) {\n super(getData(data, params), params)\n\n this.capVertices = this.parameters.capped ? this.parameters.radialSegments : 0\n this.capTriangles = this.parameters.capped ? this.parameters.radialSegments - 2 : 0\n\n this.size2 = data.position!.length / 3\n data.primitiveId = serialArray(this.size2)\n\n this.setAttributes(data)\n this.makeIndex()\n }\n\n setAttributes (data: Partial = {}) {\n const aspectRatio = this.parameters.aspectRatio\n\n const n = this.size2\n const n1 = n - 1\n const radialSegments = this.parameters.radialSegments\n\n const attributes = this.geometry.attributes as any\n\n let position, normal, binormal, tangent, color, size, primitiveId\n let meshPosition, meshColor, meshNormal, meshPrimitiveId\n\n if (data.position) {\n position = data.position\n normal = data.normal\n binormal = data.binormal\n tangent = data.tangent\n size = data.size\n\n meshPosition = attributes.position.array\n meshNormal = attributes.normal.array\n\n attributes.position.needsUpdate = true\n attributes.normal.needsUpdate = true\n }\n\n if (data.color) {\n color = data.color\n meshColor = attributes.color.array\n attributes.color.needsUpdate = true\n }\n\n if (data.primitiveId) {\n primitiveId = data.primitiveId\n meshPrimitiveId = attributes.primitiveId.array\n attributes.primitiveId.needsUpdate = true\n }\n\n let k, l\n let radius = 0\n\n let normX = 0\n let normY = 0\n let normZ = 0\n let biX = 0\n let biY = 0\n let biZ = 0\n let posX = 0\n let posY = 0\n let posZ = 0\n\n const cxArr = []\n const cyArr = []\n const cx1Arr = []\n const cy1Arr = []\n const cx2Arr = []\n const cy2Arr = []\n\n if (position) {\n for (let j = 0; j < radialSegments; ++j) {\n const v = (j / radialSegments) * 2 * Math.PI\n\n cxArr[ j ] = aspectRatio * Math.cos(v)\n cyArr[ j ] = Math.sin(v)\n\n cx1Arr[ j ] = aspectRatio * Math.cos(v - 0.01)\n cy1Arr[ j ] = Math.sin(v - 0.01)\n cx2Arr[ j ] = aspectRatio * Math.cos(v + 0.01)\n cy2Arr[ j ] = Math.sin(v + 0.01)\n }\n }\n\n for (let i = 0; i < n; ++i) {\n k = i * 3\n l = k * radialSegments\n\n if (position && tangent && normal && binormal && size) {\n vTangent.set(\n tangent[ k ], tangent[ k + 1 ], tangent[ k + 2 ]\n )\n\n normX = normal[ k ]\n normY = normal[ k + 1 ]\n normZ = normal[ k + 2 ]\n\n biX = binormal[ k ]\n biY = binormal[ k + 1 ]\n biZ = binormal[ k + 2 ]\n\n posX = position[ k ]\n posY = position[ k + 1 ]\n posZ = position[ k + 2 ]\n\n radius = size[ i ]\n }\n\n for (let j = 0; j < radialSegments; ++j) {\n const s = l + j * 3\n\n if (position) {\n const cx = -radius * cxArr[ j ] // TODO: Hack: Negating it so it faces outside.\n const cy = radius * cyArr[ j ]\n\n const cx1 = -radius * cx1Arr[ j ]\n const cy1 = radius * cy1Arr[ j ]\n const cx2 = -radius * cx2Arr[ j ]\n const cy2 = radius * cy2Arr[ j ]\n\n meshPosition[ s ] = posX + cx * normX + cy * biX\n meshPosition[ s + 1 ] = posY + cx * normY + cy * biY\n meshPosition[ s + 2 ] = posZ + cx * normZ + cy * biZ\n\n // TODO half of these are symmetric\n vMeshNormal.set(\n // ellipse tangent approximated as vector from/to adjacent points\n (cx2 * normX + cy2 * biX) - (cx1 * normX + cy1 * biX),\n (cx2 * normY + cy2 * biY) - (cx1 * normY + cy1 * biY),\n (cx2 * normZ + cy2 * biZ) - (cx1 * normZ + cy1 * biZ)\n ).cross(vTangent)\n\n meshNormal[ s ] = vMeshNormal.x\n meshNormal[ s + 1 ] = vMeshNormal.y\n meshNormal[ s + 2 ] = vMeshNormal.z\n }\n\n if (color) {\n meshColor[ s ] = color[ k ]\n meshColor[ s + 1 ] = color[ k + 1 ]\n meshColor[ s + 2 ] = color[ k + 2 ]\n }\n\n if (primitiveId) {\n meshPrimitiveId[ i * radialSegments + j ] = primitiveId[ i ]\n }\n }\n }\n\n // front cap\n\n k = 0\n l = n * 3 * radialSegments\n\n for (let j = 0; j < radialSegments; ++j) {\n const s = k + j * 3\n const t = l + j * 3\n\n if (position && tangent) {\n meshPosition[ t ] = meshPosition[ s ]\n meshPosition[ t + 1 ] = meshPosition[ s + 1 ]\n meshPosition[ t + 2 ] = meshPosition[ s + 2 ]\n\n meshNormal[ t ] = tangent[ k ]\n meshNormal[ t + 1 ] = tangent[ k + 1 ]\n meshNormal[ t + 2 ] = tangent[ k + 2 ]\n }\n\n if (color) {\n meshColor[ t ] = meshColor[ s ]\n meshColor[ t + 1 ] = meshColor[ s + 1 ]\n meshColor[ t + 2 ] = meshColor[ s + 2 ]\n }\n\n if (primitiveId) {\n meshPrimitiveId[ n * radialSegments + j ] = meshPrimitiveId[ 0 + j ]\n }\n }\n\n // back cap\n\n k = (n - 1) * 3 * radialSegments\n l = (n + 1) * 3 * radialSegments\n\n for (let j = 0; j < radialSegments; ++j) {\n const s = k + j * 3\n const t = l + j * 3\n\n if (position && tangent) {\n meshPosition[ t ] = meshPosition[ s ]\n meshPosition[ t + 1 ] = meshPosition[ s + 1 ]\n meshPosition[ t + 2 ] = meshPosition[ s + 2 ]\n\n meshNormal[ t ] = tangent[ n1 * 3 ]\n meshNormal[ t + 1 ] = tangent[ n1 * 3 + 1 ]\n meshNormal[ t + 2 ] = tangent[ n1 * 3 + 2 ]\n }\n\n if (color) {\n meshColor[ t ] = meshColor[ s ]\n meshColor[ t + 1 ] = meshColor[ s + 1 ]\n meshColor[ t + 2 ] = meshColor[ s + 2 ]\n }\n\n if (primitiveId) {\n meshPrimitiveId[ (n + 1) * radialSegments + j ] = meshPrimitiveId[ (n - 1) * radialSegments + j ]\n }\n }\n }\n\n makeIndex () {\n const index = this.geometry.getIndex()\n if (!index) { Log.error('Index is null'); return; }\n const meshIndex = index.array as Uint32Array|Uint16Array\n\n const n = this.size2\n const n1 = n - 1\n const capTriangles = this.capTriangles\n const radialSegments = this.parameters.radialSegments\n const radialSegments1 = this.parameters.radialSegments + 1\n\n let k, l\n\n for (let i = 0; i < n1; ++i) {\n const k = i * radialSegments * 3 * 2\n\n const irs = i * radialSegments\n const irs1 = (i + 1) * radialSegments\n\n for (let j = 0; j < radialSegments; ++j) {\n l = k + j * 3 * 2\n\n // meshIndex[ l + 0 ] = irs + ( ( j + 0 ) % radialSegments );\n meshIndex[ l ] = irs + j\n meshIndex[ l + 1 ] = irs + ((j + 1) % radialSegments)\n // meshIndex[ l + 2 ] = irs1 + ( ( j + 0 ) % radialSegments );\n meshIndex[ l + 2 ] = irs1 + j\n\n // meshIndex[ l + 3 ] = irs1 + ( ( j + 0 ) % radialSegments );\n meshIndex[ l + 3 ] = irs1 + j\n meshIndex[ l + 4 ] = irs + ((j + 1) % radialSegments)\n meshIndex[ l + 5 ] = irs1 + ((j + 1) % radialSegments)\n }\n }\n\n // capping\n\n const strip = [ 0 ]\n\n for (let j = 1; j < radialSegments1 / 2; ++j) {\n strip.push(j)\n if (radialSegments - j !== j) {\n strip.push(radialSegments - j)\n }\n }\n\n // front cap\n\n l = n1 * radialSegments * 3 * 2\n k = n * radialSegments\n\n for (let j = 0; j < strip.length - 2; ++j) {\n if (j % 2 === 0) {\n meshIndex[ l + j * 3 + 0 ] = k + strip[ j + 0 ]\n meshIndex[ l + j * 3 + 1 ] = k + strip[ j + 1 ]\n meshIndex[ l + j * 3 + 2 ] = k + strip[ j + 2 ]\n } else {\n meshIndex[ l + j * 3 + 0 ] = k + strip[ j + 2 ]\n meshIndex[ l + j * 3 + 1 ] = k + strip[ j + 1 ]\n meshIndex[ l + j * 3 + 2 ] = k + strip[ j + 0 ]\n }\n }\n\n // back cap\n\n l = n1 * radialSegments * 3 * 2 + 3 * capTriangles\n k = n * radialSegments + radialSegments\n\n for (let j = 0; j < strip.length - 2; ++j) {\n if (j % 2 === 0) {\n meshIndex[ l + j * 3 + 0 ] = k + strip[ j + 0 ]\n meshIndex[ l + j * 3 + 1 ] = k + strip[ j + 1 ]\n meshIndex[ l + j * 3 + 2 ] = k + strip[ j + 2 ]\n } else {\n meshIndex[ l + j * 3 + 0 ] = k + strip[ j + 2 ]\n meshIndex[ l + j * 3 + 1 ] = k + strip[ j + 1 ]\n meshIndex[ l + j * 3 + 2 ] = k + strip[ j + 0 ]\n }\n }\n }\n}\n\nexport default TubeMeshBuffer\n","/**\n * @file Cartoon Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { Debug, Log, RepresentationRegistry } from '../globals'\nimport Spline from '../geometry/spline'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport TubeMeshBuffer from '../buffer/tubemesh-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport Polymer from '../proxy/polymer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport StructureView from '../structure/structure-view';\nimport Buffer from '../buffer/buffer';\n\nexport interface CartoonRepresentationParameters extends StructureRepresentationParameters {\n aspectRatio: number\n subdiv: number\n radialSegments: number\n tension: number\n capped: boolean\n smoothSheet: boolean\n}\n\n/**\n * Cartoon representation. Show a thick ribbon that\n * smoothly connecting backbone atoms in polymers.\n *\n * __Name:__ _cartoon_\n *\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\" );\n * o.autoView();\n * } );\n */\nclass CartoonRepresentation extends StructureRepresentation {\n protected aspectRatio: number\n protected tension: number\n protected capped: boolean\n protected smoothSheet: boolean\n protected subdiv: number\n \n /**\n * Create Cartoon representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {StructureRepresentationParameters} params - representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'cartoon'\n\n this.parameters = Object.assign({\n\n aspectRatio: {\n type: 'number', precision: 1, max: 10.0, min: 1.0, rebuild: true\n },\n subdiv: {\n type: 'integer', max: 50, min: 1, rebuild: true\n },\n radialSegments: {\n type: 'integer', max: 50, min: 1, rebuild: true\n },\n tension: {\n type: 'number', precision: 1, max: 1.0, min: 0.1\n },\n capped: {\n type: 'boolean', rebuild: true\n },\n smoothSheet: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'chainname')\n p.colorScale = defaults(p.colorScale, 'RdYlBu')\n p.radiusType = defaults(p.radiusType, 'sstruc')\n p.radiusScale = defaults(p.radiusScale, 0.7)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.aspectRatio = defaults(p.aspectRatio, 5.0)\n this.tension = defaults(p.tension, NaN)\n this.capped = defaults(p.capped, true)\n this.smoothSheet = defaults(p.smoothSheet, false)\n\n if (p.quality === 'low') {\n this.subdiv = 3\n this.radialSegments = 6\n } else if (p.quality === 'medium') {\n this.subdiv = 6\n } else if (p.quality === 'high') {\n this.subdiv = 12\n } else {\n this.subdiv = defaults(p.subdiv, 6)\n }\n\n super.init(p)\n }\n\n getSplineParams (params?: Partial) {\n return Object.assign({\n subdiv: this.subdiv,\n tension: this.tension,\n directional: this.aspectRatio !== 1.0,\n smoothSheet: this.smoothSheet\n }, params)\n }\n\n getSpline (polymer: Polymer): Spline {\n return new Spline(polymer, this.getSplineParams())\n }\n\n getAspectRatio (polymer: Polymer): number {\n return polymer.isCg() ? 1.0 : this.aspectRatio\n }\n\n getAtomRadius (atom: AtomProxy): number {\n return atom.isTrace() ? super.getAtomRadius(atom) : 0\n }\n\n createData (sview: StructureView) {\n let bufferList: Buffer[] = []\n let polymerList: Polymer[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4) return\n polymerList.push(polymer)\n\n const spline = this.getSpline(polymer)\n const aspectRatio = this.getAspectRatio(polymer)\n\n const subPos = spline.getSubdividedPosition()\n const subOri = spline.getSubdividedOrientation()\n const subCol = spline.getSubdividedColor(this.getColorParams())\n const subPick = spline.getSubdividedPicking()\n const subSize = spline.getSubdividedSize(this.getRadiusParams())\n\n bufferList.push(\n new TubeMeshBuffer(\n Object.assign({}, subPos, subOri, subCol, subPick, subSize),\n this.getBufferParams({\n radialSegments: this.radialSegments,\n aspectRatio: aspectRatio,\n capped: this.capped\n })\n )\n )\n }, sview.getSelection())\n\n return {\n bufferList: bufferList,\n polymerList: polymerList\n }\n }\n\n updateData (what: any, data: StructureRepresentationData) {\n if (Debug) Log.time(this.type + ' repr update')\n\n what = what || {}\n\n for (var i = 0, il = data.polymerList!.length; i < il; ++i) {\n var bufferData: {[key: string]: any} = {}\n var polymer = data.polymerList![ i ]\n var spline = this.getSpline(polymer)\n var aspectRatio = this.getAspectRatio(polymer)\n\n Object.assign(data.bufferList[ i ], {aspectRatio: aspectRatio})\n\n if (what.position || what.radius) {\n var subPos = spline.getSubdividedPosition()\n var subOri = spline.getSubdividedOrientation()\n var subSize = spline.getSubdividedSize(this.getRadiusParams(aspectRatio))\n\n bufferData.position = subPos.position\n bufferData.normal = subOri.normal\n bufferData.binormal = subOri.binormal\n bufferData.tangent = subOri.tangent\n bufferData.size = subSize.size\n }\n\n if (what.color) {\n var subCol = spline.getSubdividedColor(this.getColorParams())\n bufferData.color = subCol.color\n }\n\n if (what.picking) {\n var subPick = spline.getSubdividedPicking()\n bufferData.picking = subPick.picking\n }\n\n data.bufferList[ i ].setAttributes(bufferData)\n }\n\n if (Debug) Log.timeEnd(this.type + ' repr update')\n }\n\n setParameters (params: Partial) {\n const rebuild = false\n var what: {[k: string]: any} = {}\n\n if (params && params.aspectRatio) {\n what.radius = true\n }\n\n if (params && params.tension) {\n what.position = true\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('cartoon', CartoonRepresentation)\n\nexport default CartoonRepresentation\n","/**\n * @file Contact Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { RepresentationRegistry } from '../globals'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport { calculateContacts, getContactData, getLabelData } from '../chemistry/interactions/contact'\nimport CylinderBuffer from '../buffer/cylinder-buffer'\nimport TextBuffer from '../buffer/text-buffer'\nimport { getFixedCountDashData } from '../geometry/dash'\nimport Viewer from '../viewer/viewer';\nimport { Structure } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport CylinderImpostorBuffer from '../buffer/cylinderimpostor-buffer';\n// @ts-ignore: unused import ContactPicker required for declaration only\nimport { ContactPicker } from '../utils/picker';\n\nexport interface ContactRepresentationParameters extends StructureRepresentationParameters {\n hydrogenBond: boolean\n weakHydrogenBond: boolean\n waterHydrogenBond: boolean\n backboneHydrogenBond: boolean\n hydrophobic: boolean\n halogenBond: boolean\n ionicInteraction: boolean\n metalCoordination: boolean\n cationPi: boolean\n piStacking: boolean\n filterSele: string|[string, string]\n maxHydrophobicDist: number\n maxHbondDist: number\n maxHbondSulfurDist: number\n maxHbondAccAngle: number\n maxHbondDonAngle: number\n maxHbondAccPlaneAngle: number\n maxHbondDonPlaneAngle: number\n maxPiStackingDist: number\n maxPiStackingOffset: number\n maxPiStackingAngle: number\n maxCationPiDist: number\n maxCationPiOffset: number\n maxIonicDist: number\n maxHalogenBondDist: number\n maxHalogenBondAngle: number\n maxMetalDist: number\n refineSaltBridges: boolean\n masterModelIndex: number\n lineOfSightDistFactor: number\n}\n\n/**\n * Contact representation.\n */\nclass ContactRepresentation extends StructureRepresentation {\n protected hydrogenBond: boolean\n protected weakHydrogenBond: boolean\n protected waterHydrogenBond: boolean\n protected backboneHydrogenBond: boolean\n protected hydrophobic: boolean\n protected halogenBond: boolean\n protected ionicInteraction: boolean\n protected metalCoordination: boolean\n protected cationPi: boolean\n protected piStacking: boolean\n protected filterSele: string|[string, string]\n protected maxHydrophobicDist: number\n protected maxHbondDist: number\n protected maxHbondSulfurDist: number\n protected maxHbondAccAngle: number\n protected maxHbondDonAngle: number\n protected maxHbondAccPlaneAngle: number\n protected maxHbondDonPlaneAngle: number\n protected maxPiStackingDist: number\n protected maxPiStackingOffset: number\n protected maxPiStackingAngle: number\n protected maxCationPiDist: number\n protected maxCationPiOffset: number\n protected maxIonicDist: number\n protected maxHalogenBondDist: number\n protected maxHalogenBondAngle: number\n protected maxMetalDist: number\n protected refineSaltBridges: boolean\n protected masterModelIndex: number\n protected lineOfSightDistFactor: number\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'contact'\n\n this.parameters = Object.assign({\n hydrogenBond: {\n type: 'boolean', rebuild: true\n },\n weakHydrogenBond: {\n type: 'boolean', rebuild: true\n },\n waterHydrogenBond: {\n type: 'boolean', rebuild: true\n },\n backboneHydrogenBond: {\n type: 'boolean', rebuild: true\n },\n hydrophobic: {\n type: 'boolean', rebuild: true\n },\n halogenBond: {\n type: 'boolean', rebuild: true\n },\n ionicInteraction: {\n type: 'boolean', rebuild: true\n },\n metalCoordination: {\n type: 'boolean', rebuild: true\n },\n cationPi: {\n type: 'boolean', rebuild: true\n },\n piStacking: {\n type: 'boolean', rebuild: true\n },\n\n filterSele: {\n type: 'text', rebuild: true\n },\n\n labelVisible: {\n type: 'boolean', rebuild: true\n },\n\n labelFixedSize: {\n type: 'boolean', buffer: 'fixedSize'\n },\n\n labelSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001, rebuild: true\n },\n\n labelUnit: {\n type: 'select',\n rebuild: true,\n options: { '': '', angstrom: 'angstrom', nm: 'nm' }\n },\n\n maxHydrophobicDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHbondDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHbondSulfurDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHbondAccAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n maxHbondDonAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n maxHbondAccPlaneAngle: {\n type: 'integer', max: 90, min: 0, rebuild: true\n },\n maxHbondDonPlaneAngle: {\n type: 'integer', max: 90, min: 0, rebuild: true\n },\n maxPiStackingDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxPiStackingOffset: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxPiStackingAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n maxCationPiDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxCationPiOffset: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxIonicDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHalogenBondDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHalogenBondAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n maxMetalDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n refineSaltBridges: {\n type: 'boolean', rebuild: true\n },\n masterModelIndex: {\n type: 'integer', max: 1000, min: -1, rebuild: true\n },\n lineOfSightDistFactor: {\n type: 'number', precision: 1, max: 10, min: 0.0, rebuild: true\n },\n\n radialSegments: true,\n disableImpostor: true\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.radiusSize = defaults(p.radiusSize, 0.05)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.hydrogenBond = defaults(p.hydrogenBond, true)\n this.weakHydrogenBond = defaults(p.weakHydrogenBond, false)\n this.waterHydrogenBond = defaults(p.waterHydrogenBond, false)\n this.backboneHydrogenBond = defaults(p.backboneHydrogenBond, false)\n this.hydrophobic = defaults(p.hydrophobic, false)\n this.halogenBond = defaults(p.halogenBond, true)\n this.ionicInteraction = defaults(p.ionicInteraction, true)\n this.metalCoordination = defaults(p.metalCoordination, true)\n this.cationPi = defaults(p.cationPi, true)\n this.piStacking = defaults(p.piStacking, true)\n\n this.filterSele = defaults(p.filterSele, '')\n this.labelVisible = defaults(p.labelVisible, false)\n this.labelFixedSize = defaults(p.labelFixedSize, false)\n this.labelSize = defaults(p.labelSize, 2.0)\n this.labelUnit = defaults(p.labelUnit, '')\n\n this.maxHydrophobicDist = defaults(p.maxHydrophobicDist, 4.0)\n this.maxHbondDist = defaults(p.maxHbondDist, 3.5)\n this.maxHbondSulfurDist = defaults(p.maxHbondSulfurDist, 4.1)\n this.maxHbondAccAngle = defaults(p.maxHbondAccAngle, 45)\n this.maxHbondDonAngle = defaults(p.maxHbondDonAngle, 45)\n this.maxHbondAccPlaneAngle = defaults(p.maxHbondAccPlaneAngle, 90)\n this.maxHbondDonPlaneAngle = defaults(p.maxHbondDonPlaneAngle, 30)\n this.maxPiStackingDist = defaults(p.maxPiStackingDist, 5.5)\n this.maxPiStackingOffset = defaults(p.maxPiStackingOffset, 2.0)\n this.maxPiStackingAngle = defaults(p.maxPiStackingAngle, 30)\n this.maxCationPiDist = defaults(p.maxCationPiDist, 6.0)\n this.maxCationPiOffset = defaults(p.maxCationPiOffset, 2.0)\n this.maxIonicDist = defaults(p.maxIonicDist, 5.0)\n this.maxHalogenBondDist = defaults(p.maxHalogenBondDist, 3.5)\n this.maxHalogenBondAngle = defaults(p.maxHalogenBondAngle, 30)\n this.maxMetalDist = defaults(p.maxMetalDist, 3.0)\n this.refineSaltBridges = defaults(p.refineSaltBridges, true)\n this.masterModelIndex = defaults(p.masterModelIndex, -1)\n this.lineOfSightDistFactor = defaults(p.lineOfSightDistFactor, 1.0)\n\n super.init(p)\n }\n\n getAtomRadius () {\n return 0\n }\n\n getContactData (sview: StructureView) {\n const params = {\n maxHydrophobicDist: this.maxHydrophobicDist,\n maxHbondDist: this.maxHbondDist,\n maxHbondSulfurDist: this.maxHbondSulfurDist,\n maxHbondAccAngle: this.maxHbondAccAngle,\n maxHbondDonAngle: this.maxHbondDonAngle,\n maxHbondAccPlaneAngle: this.maxHbondAccPlaneAngle,\n maxHbondDonPlaneAngle: this.maxHbondDonPlaneAngle,\n maxPiStackingDist: this.maxPiStackingDist,\n maxPiStackingOffset: this.maxPiStackingOffset,\n maxPiStackingAngle: this.maxPiStackingAngle,\n maxCationPiDist: this.maxCationPiDist,\n maxCationPiOffset: this.maxCationPiOffset,\n maxIonicDist: this.maxIonicDist,\n maxHalogenBondDist: this.maxHalogenBondDist,\n maxHalogenBondAngle: this.maxHalogenBondAngle,\n maxMetalDist: this.maxMetalDist,\n refineSaltBridges: this.refineSaltBridges,\n masterModelIndex: this.masterModelIndex,\n lineOfSightDistFactor: this.lineOfSightDistFactor\n }\n\n const dataParams = {\n hydrogenBond: this.hydrogenBond,\n weakHydrogenBond: this.weakHydrogenBond,\n waterHydrogenBond: this.waterHydrogenBond,\n backboneHydrogenBond: this.backboneHydrogenBond,\n hydrophobic: this.hydrophobic,\n halogenBond: this.halogenBond,\n ionicInteraction: this.ionicInteraction,\n metalCoordination: this.metalCoordination,\n cationPi: this.cationPi,\n piStacking: this.piStacking,\n radius: this.radiusSize * this.radiusScale,\n filterSele: this.filterSele\n }\n\n const contacts = calculateContacts(sview, params)\n return getContactData(contacts, sview, dataParams)\n }\n\n createData (sview: StructureView) {\n const contactData = this.getContactData(sview)\n\n const bufferList = [\n new CylinderBuffer(\n getFixedCountDashData(contactData),\n this.getBufferParams({\n sphereDetail: 1,\n dullInterior: true,\n disableImpostor: this.disableImpostor\n })\n ) as (CylinderGeometryBuffer | CylinderImpostorBuffer | TextBuffer)\n ]\n\n if (this.labelVisible) {\n const labelParams = {\n size: this.labelSize,\n unit: this.labelUnit\n }\n bufferList.push(new TextBuffer(\n getLabelData(contactData, labelParams),\n this.getBufferParams({fixedSize: this.labelFixedSize})\n ))\n }\n\n return { bufferList }\n }\n}\n\nRepresentationRegistry.add('contact', ContactRepresentation)\n\nexport default ContactRepresentation\n","/**\n * @file Dihedral Representation\n * @author Fred Ludlow \n * @private\n */\nimport { Color } from 'three'\n\nimport { RepresentationRegistry } from '../globals'\nimport MeasurementRepresentation, { calcArcPoint, parseNestedAtoms, MeasurementRepresentationParameters, LabelDataField } from './measurement-representation'\nimport { defaults } from '../utils'\n\nimport MeshBuffer from '../buffer/mesh-buffer'\nimport TextBuffer, { TextBufferData } from '../buffer/text-buffer'\nimport WideLineBuffer from '../buffer/wideline-buffer'\n\nimport { copyArray, uniformArray, uniformArray3 } from '../math/array-utils'\nimport { v3add, v3angle, v3cross, v3dot, v3multiplyScalar, v3fromArray, v3length,\n v3negate, v3new, v3normalize, v3sub, v3toArray } from '../math/vector-utils'\nimport { RAD2DEG } from '../math/math-constants'\nimport { getFixedLengthWrappedDashData } from '../geometry/dash'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { CylinderBufferData } from '../buffer/cylinder-buffer';\nimport { BufferData } from '../buffer/buffer';\nimport { StructureRepresentationData } from './structure-representation';\n\n/**\n * @typedef {Object} DihedralRepresentationParameters - dihedral representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n * @mixes MeasurementRepresentationParameters\n *\n * @property {String} atomQuad - list of quadruplets of selection strings\n * or atom indices\n * @property {Boolean} extendLine - Extend lines in planes\n * @property {Number} lineOpacity - Opacity for the line part of the representation\n * @property {Boolean} lineVisible - Display the line part of the representation\n * @property {Number} linewidth - width for line part of representation\n * @property {Boolean} planeVisible - Display the two planes corresponding to dihedral\n * @property {Boolean} sectorVisible - Display the filled arc for each angle\n */\n\nexport interface DihedralRepresentationParameters extends MeasurementRepresentationParameters {\n atomQuad: (number|string)[][]\n extendLine: boolean\n lineOpacity: number\n lineVisible: boolean\n linewidth: number\n planeVisible: boolean\n sectorVisible: boolean\n}\n\n/**\n * Dihedral representation object\n *\n * Reperesentation consists of three parts, visibility can be set for each\n * label - text label indicating dihedral angle\n * line - line indicating four positions that define the dihedral\n * sector - filled arc section\n *\n * @param {Structure} structure - the structure to measure angles in\n * @param {Viewer} viewer - a viewer object\n * @param {AngleRepresentationParameters} params - angle representation parameters\n */\nclass DihedralRepresentation extends MeasurementRepresentation {\n protected atomQuad: (number|string)[][]\n protected extendLine: boolean\n protected lineOpacity: number\n protected lineVisible: boolean\n protected linewidth: number\n protected planeVisible: boolean\n protected sectorVisible: boolean\n\n protected lineLength: number\n protected planeLength: number\n protected sectorLength: number\n\n protected lineBuffer: WideLineBuffer\n protected planeBuffer: MeshBuffer\n protected sectorBuffer: MeshBuffer\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'dihedral'\n\n this.parameters = Object.assign({\n atomQuad: {\n type: 'hidden', rebuild: true\n },\n extendLine: {\n type: 'boolean', rebuild: true, default: true\n },\n lineVisible: {\n type: 'boolean', default: true\n },\n planeVisible: {\n type: 'boolean', default: true\n },\n sectorVisible: {\n type: 'boolean', default: true\n }\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.side = defaults(p.side, 'double')\n p.opacity = defaults(p.opacity, 0.5)\n\n this.atomQuad = defaults(p.atomQuad, [])\n this.extendLine = defaults(p.extendLine, true)\n this.lineVisible = defaults(p.lineVisible, true)\n this.planeVisible = defaults(p.planeVisible, true)\n this.sectorVisible = defaults(p.sectorVisible, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n if (!sview.atomCount || !this.atomQuad.length) return\n\n const atomPosition = parseNestedAtoms(sview, this.atomQuad)\n const dihedralData = getDihedralData(\n atomPosition, {\n extendLine: this.extendLine\n }\n )\n\n const n = this.n = dihedralData.labelText.length\n const labelColor = new Color(this.labelColor)\n\n this.textBuffer = new TextBuffer({\n position: dihedralData.labelPosition,\n size: uniformArray(n, this.labelSize),\n color: uniformArray3(n, labelColor.r, labelColor.g, labelColor.b),\n text: dihedralData.labelText\n } as TextBufferData, this.getLabelBufferParams())\n\n const c = new Color(this.colorValue)\n this.lineLength = dihedralData.linePosition1.length / 3\n const lineColor = uniformArray3(this.lineLength, c.r, c.g, c.b)\n\n this.lineBuffer = new WideLineBuffer(\n getFixedLengthWrappedDashData({\n position1: dihedralData.linePosition1,\n position2: dihedralData.linePosition2,\n color: lineColor,\n color2: lineColor\n } as CylinderBufferData) ,\n this.getBufferParams({\n linewidth: this.linewidth,\n visible: this.lineVisible,\n opacity: this.lineOpacity\n })\n )\n\n this.planeLength = dihedralData.planePosition.length / 3\n this.planeBuffer = new MeshBuffer({\n position: dihedralData.planePosition,\n color: uniformArray3(this.planeLength, c.r, c.g, c.b)\n } as BufferData, this.getBufferParams({\n visible: this.planeVisible\n }))\n\n this.sectorLength = dihedralData.sectorPosition.length / 3\n this.sectorBuffer = new MeshBuffer({\n position: dihedralData.sectorPosition,\n color: uniformArray3(this.sectorLength, c.r, c.g, c.b)\n } as BufferData, this.getBufferParams({\n visible: this.sectorVisible\n }))\n\n return {\n bufferList: [\n this.textBuffer,\n this.lineBuffer,\n this.planeBuffer,\n this.sectorBuffer\n ]\n }\n }\n\n updateData (what: LabelDataField & {color?: boolean}, data: StructureRepresentationData) {\n super.updateData(what, data)\n const lineData = {}\n const planeData = {}\n const sectorData = {}\n\n if (what.color) {\n const c = new Color(this.colorValue)\n Object.assign(lineData, {\n color: uniformArray3(this.lineLength, c.r, c.g, c.b),\n color2: uniformArray3(this.lineLength, c.r, c.g, c.b)\n })\n Object.assign(planeData, {\n color: uniformArray3(this.planeLength, c.r, c.g, c.b)\n })\n Object.assign(sectorData, {\n color: uniformArray3(this.sectorLength, c.r, c.g, c.b)\n })\n }\n\n this.lineBuffer.setAttributes(lineData)\n this.planeBuffer.setAttributes(planeData)\n this.sectorBuffer.setAttributes(sectorData)\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n super.setParameters(params, what, rebuild)\n\n if (params && (\n params.lineVisible !== undefined ||\n params.sectorVisible !== undefined ||\n params.planeVisible !== undefined)) {\n this.setVisibility(this.visible)\n }\n\n if (params && params.lineOpacity) {\n this.lineBuffer.setParameters({ opacity: params.lineOpacity })\n }\n\n if (params && params.opacity !== undefined) {\n this.lineBuffer.setParameters({ opacity: this.lineOpacity })\n }\n\n if (params && params.linewidth) {\n this.lineBuffer.setParameters({ linewidth: params.linewidth })\n }\n\n return this\n }\n\n setVisibility (value: boolean, noRenderRequest?: boolean) {\n super.setVisibility(value, true)\n\n if (this.lineBuffer) {\n this.lineBuffer.setVisibility(this.lineVisible && this.visible)\n }\n\n if (this.planeBuffer) {\n this.planeBuffer.setVisibility(this.planeVisible && this.visible)\n }\n\n if (this.sectorBuffer) {\n this.sectorBuffer.setVisibility(this.sectorVisible && this.visible)\n }\n\n if (!noRenderRequest) this.viewer.requestRender()\n\n return this\n }\n}\n\n/**\n * Build the data required to create {Buffer} objects, given positions\n * @param {Float32Array} atomPosition 3*4*nDihedral array of coordinates\n * @return {Object} Arrays for building buffers\n */\nfunction getDihedralData (position: Float32Array, params: Partial = {}) {\n const angleStep = defaults(params.angleStep, Math.PI / 90)\n const nPos = position.length\n const n = position.length / 12\n const angles = new Float32Array(n)\n const labelPosition = new Float32Array(n * 3)\n const labelText = new Array(n)\n\n // Temporary arrays as don't know output length yet\n const lineTmp1 = new Array(n)\n const lineTmp2 = new Array(n)\n const sectorTmp = new Array(n)\n const planeTmp = new Array(n)\n\n // Eventual sizes of output arrays\n let totalLines = 0\n let totalSegments = 0\n let totalPlanes = 0\n\n const p1 = v3new()\n const p2 = v3new()\n const p3 = v3new()\n const p4 = v3new()\n\n const v21 = v3new()\n const v23 = v3new()\n const v34 = v3new()\n\n const tmp = v3new()\n const mid = v3new()\n const inPlane1 = v3new()\n const inPlane2 = v3new()\n const start = v3new()\n const end = v3new()\n\n const cross = v3new()\n const arcPoint = v3new()\n\n let i = 0 // Actual output index (after skipping inappropriate)\n\n for (var p = 0; p < nPos; p += 12) {\n // Set Positions\n v3fromArray(p1, position, p)\n v3fromArray(p2, position, p + 3)\n v3fromArray(p3, position, p + 6)\n v3fromArray(p4, position, p + 9)\n\n // Vectors between points\n v3sub(v21, p1, p2)\n v3sub(v23, p3, p2)\n if (v3length(v23) === 0.0) {\n continue // Can't define axis\n }\n\n v3sub(v34, p4, p3)\n\n v3multiplyScalar(tmp, v23, 0.5)\n v3add(mid, p2, tmp)\n\n v3normalize(v21, v21)\n v3normalize(v23, v23)\n v3normalize(v34, v34)\n\n // Which side of plane are p1, p4 (are we measuring something that\n // looks more like an improper? e.g. C, CA, CB, N)\n v3sub(tmp, p1, mid)\n const improperStart = v3dot(tmp, v23) > 0.0\n v3sub(tmp, p4, mid)\n const improperEnd = v3dot(tmp, v23) < 0.0\n\n // Calculate vectors perp to v23 (lying in plane (1,2,3) and (2,3,4))\n v3multiplyScalar(tmp, v23, v3dot(v23, v21))\n v3sub(inPlane1, v21, tmp)\n\n v3multiplyScalar(tmp, v23, v3dot(v23, v34))\n v3sub(inPlane2, v34, tmp)\n\n if (v3length(inPlane1) === 0.0 || v3length(inPlane2) === 0.0) {\n continue // Indeterminate angle\n }\n\n v3normalize(inPlane1, inPlane1)\n v3normalize(inPlane2, inPlane2)\n\n const angle = angles[ i ] = v3angle(inPlane1, inPlane2)\n labelText[ i ] = (RAD2DEG * angle).toFixed(1) + String.fromCharCode(0x00B0)\n\n v3cross(cross, inPlane1, v23)\n v3normalize(cross, cross)\n if (v3dot(cross, inPlane2) < 0.0) {\n v3negate(cross, cross) // Ensure cp faces correct way\n }\n\n calcArcPoint(tmp, mid, inPlane1, cross, angle / 2.0)\n v3toArray(tmp, labelPosition, 3 * i)\n\n const nSegments = Math.ceil(angle / angleStep)\n // For extended display mode, 4 straight lines plus arc/segment edge\n // For non-extended, 2 straight lines plus segment edge\n const nLines = nSegments + ((params.extendLine) ? 4 : 2)\n\n // Don't draw planes if not extending lines\n const nPlanes = params.extendLine ? 36 : 0\n\n const line1 = new Float32Array(nLines * 3)\n const line2 = new Float32Array(nLines * 3)\n const sector = new Float32Array(nSegments * 9)\n // 2 planes, 2 triangles each per dihedral (2*2*9)\n const plane = new Float32Array(nPlanes)\n\n lineTmp1[ i ] = line1\n lineTmp2[ i ] = line2\n sectorTmp[ i ] = sector\n planeTmp[ i ] = plane\n\n // Start points for lines/planes, only required\n // if extending lines\n if (params.extendLine) {\n if (improperStart) { // We'll start on the v3->1 line (tmp)\n v3sub(tmp, p1, p3)\n v3normalize(tmp, tmp)\n v3multiplyScalar(start, tmp, 1.0 / v3dot(inPlane1, tmp))\n v3add(start, start, p3)\n } else { // start on the 2->1 line\n v3multiplyScalar(start, v21, 1.0 / v3dot(inPlane1, v21))\n v3add(start, start, p2)\n }\n\n if (improperEnd) { // Finish on 2->4 line\n v3sub(tmp, p4, p2)\n v3normalize(tmp, tmp)\n v3multiplyScalar(end, tmp, 1.0 / v3dot(inPlane2, tmp))\n v3add(end, end, p2)\n } else { // end on the 3->4 line\n v3multiplyScalar(end, v34, 1.0 / v3dot(inPlane2, v34))\n v3add(end, end, p3)\n }\n }\n\n v3add(arcPoint, mid, inPlane1)\n\n // index into line1, line2\n let li = 0\n // If extending lines, there's a bit of stuff to do here\n // figuring out start and end positions\n if (params.extendLine) {\n v3toArray(p1, line1, li)\n v3toArray(start, line2, li)\n li += 3\n v3toArray(start, line1, li)\n v3toArray(arcPoint, line2, li)\n li += 3\n\n // Construct plane at start, if not extening lines\n // this is skipped\n v3toArray(start, plane, 0)\n v3toArray(arcPoint, plane, 3)\n v3toArray(improperStart ? p3 : p2, plane, 6)\n v3toArray(improperStart ? p3 : p2, plane, 9)\n v3toArray(arcPoint, plane, 12)\n v3toArray(mid, plane, 15)\n } else {\n // Not extending lines\n v3toArray(mid, line1, li)\n v3toArray(arcPoint, line2, li)\n li += 3\n }\n\n const appendArcSection = function (a: number, j: number) {\n const si = j * 9\n\n v3toArray(mid, sector, si)\n v3toArray(arcPoint, sector, si + 3)\n v3toArray(arcPoint, line1, li)\n\n calcArcPoint(arcPoint, mid, inPlane1, cross, a)\n\n v3toArray(arcPoint, sector, si + 6)\n v3toArray(arcPoint, line2, li)\n li += 3\n }\n\n let j = 0\n for (let a = angleStep; a < angle; a += angleStep) {\n appendArcSection(a, j++)\n }\n appendArcSection(angle, j++)\n\n if (params.extendLine) {\n v3toArray(arcPoint, line1, (nLines - 2) * 3)\n v3toArray(end, line2, (nLines - 2) * 3)\n v3toArray(end, line1, (nLines - 1) * 3)\n v3toArray(p4, line2, (nLines - 1) * 3)\n\n // Construct plane at end\n v3toArray(end, plane, 18)\n v3toArray(arcPoint, plane, 21)\n v3toArray(improperEnd ? p2 : p3, plane, 24)\n v3toArray(improperEnd ? p2 : p3, plane, 27)\n v3toArray(arcPoint, plane, 30)\n v3toArray(mid, plane, 33)\n } else {\n v3toArray(arcPoint, line1, li)\n v3toArray(mid, line2, li)\n li += 3\n }\n\n totalLines += nLines * 3\n totalSegments += nSegments * 9\n totalPlanes += nPlanes\n i += 1\n }\n\n const nSuccess = i\n\n const linePosition1 = new Float32Array(totalLines)\n const linePosition2 = new Float32Array(totalLines)\n const sectorPosition = new Float32Array(totalSegments)\n const planePosition = new Float32Array(totalPlanes)\n\n let lineOffset = 0\n let sectorOffset = 0\n let planeOffset = 0\n\n for (let i = 0; i < nSuccess; i++) {\n const lp1 = lineTmp1[ i ]\n const lp2 = lineTmp2[ i ]\n const sp = sectorTmp[ i ]\n const pp = planeTmp[ i ]\n\n copyArray(lp1, linePosition1, 0, lineOffset, lp1.length)\n copyArray(lp2, linePosition2, 0, lineOffset, lp2.length)\n copyArray(sp, sectorPosition, 0, sectorOffset, sp.length)\n copyArray(pp, planePosition, 0, planeOffset, pp.length)\n\n lineOffset += lp1.length\n sectorOffset += sp.length\n planeOffset += pp.length\n }\n\n return {\n labelPosition: labelPosition.subarray(0, nSuccess * 3),\n labelText: labelText.slice(0, nSuccess),\n linePosition1,\n linePosition2,\n planePosition,\n sectorPosition\n }\n}\n\nRepresentationRegistry.add('dihedral', DihedralRepresentation)\n\nexport default DihedralRepresentation\n","/**\n * @file Dihedral Histogram Representation\n * @author Rudolfs Petrovs \n * @private\n */\nimport { Color } from 'three'\n\nimport { calcArcPoint, parseNestedAtoms } from './measurement-representation'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\n\nimport { RepresentationRegistry } from '../globals'\nimport { Structure } from '../ngl'\nimport { defaults } from '../utils'\n\nimport { BufferData } from '../buffer/buffer'\nimport MeshBuffer from '../buffer/mesh-buffer'\nimport WideLineBuffer, { WideLineBufferData } from '../buffer/wideline-buffer'\n\nimport { copyArray, uniformArray3, arraySum } from '../math/array-utils'\nimport {\n v3add, v3cross, v3dot, v3multiplyScalar, v3fromArray,\n v3negate, v3new, v3normalize, v3sub, v3toArray, v3length\n} from '../math/vector-utils'\n\nimport StructureView from '../structure/structure-view'\n\nimport Viewer from '../viewer/viewer'\n\n\nconst pointLength = 3 // One Point Length (number of coordinates of one point in 3D)\nconst pointsInTriangle = 3\n\ntype ColorDefinition = Color | string | number | undefined\n\ninterface HistogramColorParameters {\n histogramBinBorderColor: ColorDefinition\n adjacentBondArrowColor: ColorDefinition\n distantBondArrowColor: ColorDefinition\n frontHistogramColor: ColorDefinition\n backHistogramColor: ColorDefinition\n opaqueMiddleDiscColor: ColorDefinition\n}\n\ninterface HistogramInputData extends Partial {\n atomQuad: (number | string)[]\n histogram360: number[]\n}\n\ninterface HistogramData extends HistogramInputData {\n atomPositions: Float32Array\n histogram360Scaled: number[]\n}\n\ninterface WideLineData {\n startPoints: Float32Array\n endPoints: Float32Array\n startColors: Float32Array\n endColors: Float32Array\n}\n\ninterface MeshData {\n triangles: Float32Array\n triangleColors: Float32Array\n}\n\nfunction createUpdatedObject(o: Object, updateSource: Object) {\n function hasKey(obj: O, key: keyof any): key is keyof O {\n return key in obj\n }\n\n const result = { ...o } // Shallow copy\n for (const key in result) {\n if (hasKey(result, key) && hasKey(updateSource, key)) {\n result[key] = defaults(updateSource[key], result[key])\n }\n }\n return result\n}\n\nfunction createColorArray(color: ColorDefinition, arrayLength: number) {\n const colorValue = new Color(color)\n const targetArray = new Float32Array(arrayLength * 3)\n uniformArray3(arrayLength, colorValue.r, colorValue.g, colorValue.b, targetArray)\n return targetArray\n}\n\n/**\n * @typedef {Object} DihedralHistogramRepresentationParameters - dihedral representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n *\n * @property {HistogramInputData[]} histogramsData\n * List of HistogramInputData objects, which properties specifies each particular\n * histogram, and can contain particular histogram-specific parameters.\n * Obligatory properties are:\n * atomQuad - Quadruplet of selection strings or atom indices\n * histogram360 - List of values, representing histogram from 0 to 360 degrees.\n * @property {Boolean} histogramBinBorderVisible - Display the lines that separate circular histogram bins\n * @property {Boolean} scaleBinToSectorArea - Should sector-based histogram bins'\n * area be proportional to the bins' value\n */\n\nexport interface DihedralHistogramRepresentationParameters extends StructureRepresentationParameters {\n histogramsData: HistogramInputData[]\n\n histogramBinBorderVisible: boolean\n scaleBinToSectorArea: boolean\n}\n\n/**\n * Dihedral Histogram representation object\n *\n * Reperesentation consists of several parts:\n * opaqueMiddleDisc - opaque disc in the middle of the dihedral between front and back histograms\n * frontHistogram - circular histogram from the adjacent bond viewpoint\n * backHistogram - circular histogram from the distant bond viewpoint\n * histogramBinBorder - lines, which separate histogram bins\n * bondArrows - lines, which show the actual angle on the histogram disc\n *\n * @param {Structure} structure - the structure to measure angles in\n * @param {Viewer} viewer - a viewer object\n * @param {DihedralHistogramRepresentationParameters} params - Dihedral histogram representation parameters\n */\nclass DihedralHistogramRepresentation extends StructureRepresentation {\n protected histogramsData: HistogramData[]\n\n protected histogramBinBorderVisible: boolean\n protected histogramBinBorderWidth: number\n protected histogramBinBorderColor: ColorDefinition\n protected histogramBinBorderOpacity: number\n\n protected bondArrowVisible: boolean\n protected bondArrowWidth: number\n protected bondArrowOpacity: number\n\n protected adjacentBondArrowColor: ColorDefinition\n protected distantBondArrowColor: ColorDefinition\n\n protected histogramOpacity: number\n protected frontHistogramColor: ColorDefinition\n protected backHistogramColor: ColorDefinition\n\n protected opaqueMiddleDiscVisible: boolean\n protected opaqueMiddleDiscColor: ColorDefinition\n protected opaqueMiddleDiscOpacity: number\n\n protected scaleBinToSectorArea: boolean\n\n constructor(structure: Structure, viewer: Viewer, params: DihedralHistogramRepresentationParameters) {\n super(structure, viewer, params)\n\n this.type = 'dihedral-histogram'\n\n this.parameters = Object.assign({\n histogramsData: {\n type: 'hidden', rebuild: true\n },\n histogramBinBorderVisible: {\n type: 'boolean', default: true\n },\n scaleBinToSectorArea: {\n type: 'boolean',\n rebuild: true,\n default: false\n }\n }, this.parameters)\n\n this.init(params)\n }\n\n init(params: Partial) {\n const p = params || {}\n\n const defaultColorData = {\n histogramBinBorderColor: 'grey',\n adjacentBondArrowColor: 'black',\n distantBondArrowColor: 'magenta',\n frontHistogramColor: 'green',\n backHistogramColor: 'blue',\n opaqueMiddleDiscColor: 'white'\n }\n\n const colorData = createUpdatedObject(defaultColorData, p)\n Object.assign(this, colorData)\n\n const defaultParameters = {\n histogramsData: [],\n histogramOpacity: 1.0,\n\n opaqueMiddleDiscVisible: true,\n opaqueMiddleDiscOpacity: 1.0,\n\n histogramBinBorderVisible: true,\n histogramBinBorderWidth: 1,\n histogramBinBorderOpacity: 0.5,\n\n bondArrowVisible: true,\n bondArrowWidth: 2,\n bondArrowOpacity: 1.0,\n\n scaleBinToSectorArea: false,\n }\n const parameters = createUpdatedObject(defaultParameters, p)\n Object.assign(this, parameters)\n\n this.histogramsData.forEach(x => {\n const specificColorData = createUpdatedObject(colorData, x)\n Object.assign(x, specificColorData)\n })\n\n p.side = defaults(p.side, 'double')\n p.opacity = defaults(p.opacity, 0.5)\n p.radiusType = defaults(p.radiusType, 'size')\n p.radiusSize = defaults(p.radiusSize, 0.15)\n\n super.init(p)\n }\n\n getHistogramBinBorderBufferParameters() {\n return this.getBufferParams({\n linewidth: this.histogramBinBorderWidth,\n visible: this.histogramBinBorderVisible,\n opacity: this.histogramBinBorderOpacity,\n })\n }\n\n getBondArrowsBufferParameters() {\n return this.getBufferParams({\n linewidth: this.bondArrowWidth,\n visible: this.bondArrowVisible,\n opacity: this.bondArrowOpacity,\n })\n }\n\n getOpaqueMiddleDiscBufferParameters() {\n return this.getBufferParams({\n visible: this.opaqueMiddleDiscVisible,\n opacity: this.opaqueMiddleDiscOpacity\n })\n }\n\n getHistogramBufferParameters() {\n return this.getBufferParams({\n visible: true,\n opacity: this.histogramOpacity,\n side: \"double\"\n })\n }\n\n createData(sview: StructureView) {\n if (!sview.atomCount || !this.histogramsData.length) return\n this.histogramsData.forEach(x => x.atomPositions = parseNestedAtoms(sview, [x.atomQuad]))\n const scaleData = this.scaleBinToSectorArea ? function (y: number) { return Math.sqrt(y) } : function (y: number) { return y }\n this.histogramsData.forEach(x => x.histogram360Scaled = x.histogram360.map(scaleData))\n function Float32Concat(arrays: Float32Array[]) {\n const lengths = arrays.map(x => x.length)\n const result = new Float32Array(arraySum(lengths))\n let accumulatedOffset = 0\n for (let i = 0; i < arrays.length; i++) {\n result.set(arrays[i], accumulatedOffset)\n accumulatedOffset += arrays[i].length\n }\n return result\n }\n\n function createWideLineBuffer(linesList: WideLineData[], params: {}) {\n return new WideLineBuffer(\n {\n position1: Float32Concat(linesList.map(x => x.startPoints)),\n position2: Float32Concat(linesList.map(x => x.endPoints)),\n color: Float32Concat(linesList.map(x => x.startColors)),\n color2: Float32Concat(linesList.map(x => x.endColors)),\n } as WideLineBufferData,\n params)\n }\n\n function createMeshBuffer(mesh: MeshData[], params: {}) {\n return new MeshBuffer(\n {\n position: Float32Concat(mesh.map(x => x.triangles)),\n color: Float32Concat(mesh.map(x => x.triangleColors))\n } as BufferData,\n params)\n }\n\n const dihedralDataArray = []\n\n for (let i = 0; i < this.histogramsData.length; i++) {\n let dihedralData = undefined\n let currentHistogramData = this.histogramsData[i]\n let currentHistogram360 = currentHistogramData.histogram360\n if (currentHistogram360.length >= 3) {\n dihedralData = calculateDihedralHistogram(currentHistogramData)\n }\n if (typeof dihedralData === \"undefined\") continue\n dihedralDataArray.push(dihedralData)\n }\n\n this.frontHistogramBinBordersBuffer = createWideLineBuffer(\n dihedralDataArray.map(x => x.frontHistogramBinBorders),\n this.getHistogramBinBorderBufferParameters()\n )\n\n this.backHistogramBinBordersBuffer = createWideLineBuffer(\n dihedralDataArray.map(x => x.backHistogramBinBorders),\n this.getHistogramBinBorderBufferParameters()\n )\n\n this.adjacentBondArrowsBuffer = createWideLineBuffer(\n dihedralDataArray.map(x => x.adjacentBondArrows),\n this.getBondArrowsBufferParameters()\n )\n\n this.distantBondArrowsBuffer = createWideLineBuffer(\n dihedralDataArray.map(x => x.distantBondArrows),\n this.getBondArrowsBufferParameters()\n )\n\n this.opaqueMiddleDiscBuffer = createMeshBuffer(\n dihedralDataArray.map(x => x.opaqueMiddleDisc),\n this.getOpaqueMiddleDiscBufferParameters()\n )\n\n this.frontHistogramBuffer = createMeshBuffer(\n dihedralDataArray.map(x => x.frontHistogram),\n this.getHistogramBufferParameters()\n )\n\n this.backHistogramBuffer = createMeshBuffer(\n dihedralDataArray.map(x => x.backHistogram),\n this.getHistogramBufferParameters()\n )\n\n return {\n bufferList: [].concat(\n this.frontHistogramBinBordersBuffer,\n this.backHistogramBinBordersBuffer,\n this.adjacentBondArrowsBuffer,\n this.distantBondArrowsBuffer,\n this.opaqueMiddleDiscBuffer,\n this.frontHistogramBuffer,\n this.backHistogramBuffer\n )\n }\n }\n\n setParameters(params: Partial) {\n const rebuild = false\n const what = {}\n super.setParameters(params, what, rebuild)\n\n if (params && (params.histogramBinBorderVisible !== undefined)) {\n this.setVisibility(this.visible)\n }\n return this\n }\n\n setVisibility(value: boolean, noRenderRequest?: boolean) {\n super.setVisibility(value, true)\n if (this.frontHistogramBinBordersBuffer) {\n this.frontHistogramBinBordersBuffer.setVisibility(this.histogramBinBorderVisible)\n }\n if (this.backHistogramBinBordersBuffer) {\n this.backHistogramBinBordersBuffer.setVisibility(this.histogramBinBorderVisible)\n }\n if (!noRenderRequest) this.viewer.requestRender()\n return this\n }\n}\n\n/**\n * Calculates the data required to create {Buffer} objects for one histogram, given positions\n * @param Float32Array positionOfDihedralAtoms 3*4 array of coordinates\n * @param NumberArray histogram array of coordinates\n * @return Arrays for building buffers\n */\nfunction calculateDihedralHistogram(histogramData: HistogramData) {\n const positionOfDihedralAtoms = histogramData.atomPositions\n const histogram = histogramData.histogram360Scaled;\n const totalSectorTrianglesInOpaqueMiddleDisc = histogram.length <= 180 ? 360 : histogram.length * 2\n const frontAndBack = 2\n\n const opaqueMiddleDisc = {\n triangles: new Float32Array(totalSectorTrianglesInOpaqueMiddleDisc * pointsInTriangle * pointLength),\n triangleColors: createColorArray(histogramData.opaqueMiddleDiscColor, totalSectorTrianglesInOpaqueMiddleDisc * pointsInTriangle)\n }\n\n const frontHistogram = {\n triangles: new Float32Array(histogram.length * pointsInTriangle * pointLength),\n triangleColors: createColorArray(histogramData.frontHistogramColor, histogram.length * pointsInTriangle)\n }\n\n const backHistogram = {\n triangles: new Float32Array(histogram.length * pointsInTriangle * pointLength),\n triangleColors: createColorArray(histogramData.backHistogramColor, histogram.length * pointsInTriangle)\n }\n\n const frontHistogramBinBorders = {\n startPoints: new Float32Array(histogram.length * pointLength),\n endPoints: new Float32Array(histogram.length * pointLength),\n startColors: createColorArray(histogramData.histogramBinBorderColor, histogram.length),\n endColors: createColorArray(histogramData.histogramBinBorderColor, histogram.length)\n }\n\n const backHistogramBinBorders = {\n startPoints: new Float32Array(histogram.length * pointLength),\n endPoints: new Float32Array(histogram.length * pointLength),\n startColors: createColorArray(histogramData.histogramBinBorderColor, histogram.length),\n endColors: createColorArray(histogramData.histogramBinBorderColor, histogram.length)\n }\n\n const adjacentBondArrows = {\n startPoints: new Float32Array(frontAndBack * pointLength),\n endPoints: new Float32Array(frontAndBack * pointLength),\n startColors: createColorArray(histogramData.adjacentBondArrowColor, histogram.length),\n endColors: createColorArray(histogramData.adjacentBondArrowColor, histogram.length)\n }\n const distantBondArrows = {\n startPoints: new Float32Array(frontAndBack * pointLength),\n endPoints: new Float32Array(frontAndBack * pointLength),\n startColors: createColorArray(histogramData.distantBondArrowColor, histogram.length),\n endColors: createColorArray(histogramData.distantBondArrowColor, histogram.length)\n }\n\n const p1 = v3new()\n const p2 = v3new()\n const p3 = v3new()\n const p4 = v3new()\n\n const v21 = v3new()\n const v23 = v3new()\n const v32 = v3new()\n const v34 = v3new()\n\n const mid = v3new()\n const inPlane1 = v3new()\n const inPlane2 = v3new()\n\n const cross1 = v3new()\n const cross2 = v3new()\n\n const arcPoint = v3new()\n const tmp = v3new()\n const tmp2 = v3new()\n\n // Set Atom Coordinates\n const dihedralAtomVectors = [p1, p2, p3, p4]\n\n for (let i = 0; i < dihedralAtomVectors.length; i++) {\n v3fromArray(dihedralAtomVectors[i], positionOfDihedralAtoms, i * pointLength)\n }\n\n // Vectors between points\n v3sub(v21, p1, p2)\n v3sub(v23, p3, p2)\n v3sub(v34, p4, p3)\n if (v3length(v23) === 0.0) {\n return // Can't define axis\n }\n\n v3multiplyScalar(tmp, v23, 0.5)\n v3add(mid, p2, tmp)\n\n v3normalize(v21, v21)\n v3normalize(v23, v23)\n v3normalize(v34, v34)\n\n v3negate(v32, v23)\n // Calculate vectors perp to v23 (lying in plane (1,2,3) and (2,3,4))\n v3multiplyScalar(tmp, v32, v3dot(v32, v21))\n v3sub(inPlane1, v21, tmp)\n\n v3multiplyScalar(tmp, v23, v3dot(v23, v34))\n v3sub(inPlane2, v34, tmp)\n\n if (v3length(inPlane1) === 0.0 || v3length(inPlane2) === 0.0) {\n return // Indeterminate angle\n }\n\n v3normalize(inPlane1, inPlane1)\n v3normalize(inPlane2, inPlane2)\n\n // Can use acos as normalized and non-zero\n const absAngle = Math.acos(v3dot(inPlane1, inPlane2))\n\n v3cross(cross1, v32, inPlane1)\n v3cross(cross2, v23, inPlane2)\n v3normalize(cross1, cross1)\n v3normalize(cross2, cross2)\n\n let angle = absAngle\n if (v3dot(cross1, inPlane2) < 0.0) {\n angle = -absAngle\n }\n\n v3add(arcPoint, mid, inPlane1)\n\n // Calculate necessary constants\n const maxHist = Math.max.apply(null, histogram)\n const histBinAngleStep = (Math.PI * 2) / histogram.length\n\n function setHistogramBinCoordinates(out: Float32Array, ind: number, zeroDegreeVector: Float32Array, crossVector: Float32Array, histBinAngleStep: number) {\n const startOffset = ind * pointsInTriangle * pointLength\n v3toArray(mid, out, startOffset)\n const scalingFactor = Number(histogram[ind]) / maxHist\n v3multiplyScalar(tmp, zeroDegreeVector, scalingFactor)\n v3multiplyScalar(tmp2, crossVector, scalingFactor)\n calcArcPoint(arcPoint, mid, tmp, tmp2, ind * histBinAngleStep)\n v3toArray(arcPoint, out, startOffset + 1 * pointLength)\n calcArcPoint(arcPoint, mid, tmp, tmp2, (ind + 1) * histBinAngleStep)\n v3toArray(arcPoint, out, startOffset + 2 * pointLength)\n }\n\n function setOneSideHistogram(discHistogram: MeshData, binBorders: { startPoints: Float32Array, endPoints: Float32Array }, ind: number, zeroDegreeVector: Float32Array, crossVector: Float32Array) {\n // Set Bond Arrows\n\n copyArray(mid, adjacentBondArrows.startPoints, 0, ind * pointLength, mid.length)\n calcArcPoint(tmp, mid, zeroDegreeVector, crossVector, 0 + histBinAngleStep * 0)\n copyArray(tmp, adjacentBondArrows.endPoints, 0, ind * pointLength, mid.length)\n\n copyArray(mid, distantBondArrows.startPoints, 0, ind * pointLength, mid.length)\n calcArcPoint(tmp, mid, zeroDegreeVector, crossVector, angle)\n copyArray(tmp, distantBondArrows.endPoints, 0, ind * pointLength, mid.length)\n\n // Set Histogram Bin Borders\n\n for (let i = 0; i < histogram.length; i++) {\n copyArray(mid, binBorders.startPoints, 0, i * 3, mid.length)\n calcArcPoint(tmp, mid, zeroDegreeVector, crossVector, 0 + histBinAngleStep * i)\n copyArray(tmp, binBorders.endPoints, 0, i * 3, tmp.length)\n }\n\n // Set Histogram Bins\n\n for (let sectionIndex = 0; sectionIndex < histogram.length; sectionIndex++) {\n setHistogramBinCoordinates(discHistogram.triangles, sectionIndex, zeroDegreeVector, crossVector, histBinAngleStep)\n }\n }\n\n // Opaque disc\n const opaqueCircleSectorAngleStep = Math.PI * 2 / totalSectorTrianglesInOpaqueMiddleDisc\n\n for (let sectionIndex = 0; sectionIndex < totalSectorTrianglesInOpaqueMiddleDisc; sectionIndex++) {\n const startOffset = sectionIndex * pointsInTriangle * pointLength\n v3toArray(mid, opaqueMiddleDisc.triangles, startOffset)\n calcArcPoint(arcPoint, mid, inPlane1, cross1, sectionIndex * opaqueCircleSectorAngleStep)\n v3toArray(arcPoint, opaqueMiddleDisc.triangles, startOffset + 1 * pointLength)\n calcArcPoint(arcPoint, mid, inPlane1, cross1, (sectionIndex + 1) * opaqueCircleSectorAngleStep)\n v3toArray(arcPoint, opaqueMiddleDisc.triangles, startOffset + 2 * pointLength)\n }\n\n // Front Histogram\n const distanceToOpaqueDisc = 0.01\n v3multiplyScalar(tmp, v23, -distanceToOpaqueDisc) // Get a vector to move \"mid\" just a bit from opaque disc\n v3add(mid, mid, tmp)\n setOneSideHistogram(frontHistogram, frontHistogramBinBorders, 0, inPlane1, cross1)\n\n // Back Histogram\n v3multiplyScalar(tmp, v23, 2 * distanceToOpaqueDisc) // Get a vector to move \"mid\" back and plus just a bit from opaque disc the other way\n v3add(mid, mid, tmp)\n setOneSideHistogram(backHistogram, backHistogramBinBorders, 1, inPlane2, cross2)\n\n return {\n opaqueMiddleDisc,\n frontHistogram,\n backHistogram,\n frontHistogramBinBorders,\n backHistogramBinBorders,\n adjacentBondArrows,\n distantBondArrows\n }\n}\n\nRepresentationRegistry.add('dihedral-histogram', DihedralHistogramRepresentation)\n\nexport default DihedralHistogramRepresentation\n","/**\n * @file Distance Representation\n * @author Alexander Rose \n * @author Fred Ludlow \n * @private\n */\n\nimport { Color } from 'three'\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { DistancePicker } from '../utils/picker'\nimport { uniformArray, uniformArray3 } from '../math/array-utils'\nimport BitArray from '../utils/bitarray'\nimport MeasurementRepresentation, { MeasurementRepresentationParameters } from './measurement-representation'\nimport Selection from '../selection/selection'\nimport BondStore from '../store/bond-store'\nimport TextBuffer, { TextBufferData, TextBufferParameters } from '../buffer/text-buffer'\nimport WideLineBuffer from '../buffer/wideline-buffer'\nimport CylinderBuffer, { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport { getFixedLengthDashData } from '../geometry/dash'\nimport Viewer from '../viewer/viewer';\nimport { Structure } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport { BondDataFields, BondDataParams, BondData } from '../structure/structure-data';\nimport { StructureRepresentationData } from './structure-representation';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\n\n/**\n * Distance representation parameter object.\n * @typedef {Object} DistanceRepresentationParameters - distance representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n * @mixes MeasurementRepresentationParameters\n *\n * @property {String} labelUnit - distance unit (e.g. \"angstrom\" or \"nm\"). If set, a distance\n * symbol is appended to the label (i.e. 'nm' or '\\u00C5'). In case of 'nm', the\n * distance value is computed in nanometers instead of Angstroms.\n * @property {Array[]} atomPair - list of pairs of selection strings (see {@link Selection})\n * or pairs of atom indices. Using atom indices is much more\n * efficient when the representation is updated often, e.g. by\n * changing the selection or the atom positions, as there\n * are no selection strings to be evaluated.\n */\nexport interface DistanceRepresentationParameters extends MeasurementRepresentationParameters {\n labelUnit: string\n atomPair: AtomPair\n useCylinder: boolean\n}\nexport type AtomPair = (number|string)[][]\n/**\n * Distance representation\n */\nclass DistanceRepresentation extends MeasurementRepresentation {\n protected labelUnit: string\n protected atomPair: AtomPair\n protected useCylinder: boolean\n protected distanceBuffer: WideLineBuffer|CylinderGeometryBuffer\n /**\n * Create Distance representation object\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\" );\n * // either give selections (uses first selected atom) ...\n * var atomPair = [ [ \"1.CA\", \"4.CA\" ], [ \"7.CA\", \"13.CA\" ] ];\n * // or atom indices\n * var atomPair = [ [ 8, 28 ], [ 173, 121 ] ];\n * o.addRepresentation( \"distance\", { atomPair: atomPair } );\n * stage.autoView();\n * } );\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {DistanceRepresentationParameters} params - distance representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'distance'\n\n this.parameters = Object.assign({\n radialSegments: true,\n openEnded: true,\n disableImpostor: true,\n labelUnit: {\n type: 'select',\n rebuild: true,\n options: { '': '', angstrom: 'angstrom', nm: 'nm' }\n },\n useCylinder: {\n type: 'boolean', rebuild: true\n },\n atomPair: {\n type: 'hidden', rebuild: true\n }\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.linewidth = defaults(p.linewidth, 5.0)\n p.radiusType = defaults(p.radiusType, 'size')\n p.radiusSize = defaults(p.radiusSize, 0.2)\n\n this.labelUnit = defaults(p.labelUnit, '')\n this.useCylinder = defaults(p.useCylinder, false)\n this.atomPair = defaults(p.atomPair, [])\n\n super.init(p)\n }\n\n getDistanceData (sview: StructureView, atomPair: AtomPair) {\n let n = atomPair.length\n const text = new Array(n)\n let position = new Float32Array(n * 3)\n const sele1 = new Selection()\n const sele2 = new Selection()\n\n const bondStore = new BondStore()\n\n const ap1 = sview.getAtomProxy()\n const ap2 = sview.getAtomProxy()\n\n let j = 0 // Skipped pairs\n const selected = sview.getAtomSet()\n\n atomPair.forEach((pair, i) => {\n let v1 = pair[ 0 ]\n let v2 = pair[ 1 ]\n\n if (typeof(v1) === 'number' && Number.isInteger(v1) && typeof(v2) === 'number' && Number.isInteger(v2)) {\n if (selected.get(v1) && selected.get(v2)) {\n ap1.index = v1\n ap2.index = v2\n } else {\n j += 1\n return\n }\n } else {\n sele1.setString(v1 as string)\n sele2.setString(v2 as string)\n\n var atomIndices1 = sview.getAtomIndices(sele1)\n var atomIndices2 = sview.getAtomIndices(sele2)\n\n if (atomIndices1!.length && atomIndices2!.length) {\n ap1.index = atomIndices1![ 0 ]\n ap2.index = atomIndices2![ 0 ]\n } else {\n j += 1\n return\n }\n }\n\n bondStore.addBond(ap1, ap2, 1)\n\n i -= j\n var d = ap1.distanceTo(ap2)\n switch (this.labelUnit) {\n case 'angstrom':\n text[ i ] = d.toFixed(2) + ' ' + String.fromCharCode(0x212B)\n break\n case 'nm':\n text[ i ] = (d / 10).toFixed(2) + ' nm'\n break\n default:\n text[ i ] = d.toFixed(2)\n break\n }\n\n var i3 = i * 3\n position[ i3 + 0 ] = (ap1.x + ap2.x) / 2\n position[ i3 + 1 ] = (ap1.y + ap2.y) / 2\n position[ i3 + 2 ] = (ap1.z + ap2.z) / 2\n })\n\n if (j > 0) {\n n -= j\n position = position.subarray(0, n * 3)\n }\n\n var bondSet = new BitArray(bondStore.count, true)\n\n return {\n text: text,\n position: position,\n bondSet: bondSet,\n bondStore: bondStore\n }\n }\n\n getBondData (sview: StructureView, what: BondDataFields, params: BondDataParams): BondData {\n const bondData = sview.getBondData(this.getBondParams(what, params))\n if (bondData.picking) {\n bondData.picking = new DistancePicker(\n bondData.picking.array,\n bondData.picking.structure,\n params.bondStore!\n ) as any\n }\n return bondData\n }\n\n createData (sview: StructureView) {\n if (!sview.atomCount || !this.atomPair.length) return\n\n const n = this.atomPair.length\n const c = new Color(this.labelColor)\n const distanceData = this.getDistanceData(sview, this.atomPair)\n\n this.textBuffer = new TextBuffer({\n position: distanceData.position,\n size: uniformArray(n, this.labelSize),\n color: uniformArray3(n, c.r, c.g, c.b),\n text: distanceData.text\n } as TextBufferData, this.getLabelBufferParams() as TextBufferParameters)\n\n const bondParams = {\n bondSet: distanceData.bondSet,\n bondStore: distanceData.bondStore\n }\n\n const bondData = this.getBondData(\n sview,\n { position: true, color: true, picking: true, radius: this.useCylinder },\n bondParams\n )\n\n if (this.useCylinder) {\n this.distanceBuffer = new CylinderBuffer(\n bondData as CylinderBufferData,\n this.getBufferParams({\n openEnded: this.openEnded,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) \n ) as CylinderGeometryBuffer\n } else {\n this.distanceBuffer = new WideLineBuffer(\n getFixedLengthDashData(bondData as CylinderBufferData),\n this.getBufferParams({\n linewidth: this.linewidth,\n visible: this.lineVisible,\n opacity: this.lineOpacity\n })\n )\n }\n\n return {\n bondSet: distanceData.bondSet,\n bondStore: distanceData.bondStore,\n position: distanceData.position,\n bufferList: [ this.textBuffer, this.distanceBuffer ]\n }\n }\n\n updateData (what: BondDataFields, data: StructureRepresentationData) {\n super.updateData(what, data)\n\n const bondParams = {\n bondSet: data.bondSet,\n bondStore: data.bondStore\n }\n\n const bondData = this.getBondData(data.sview as StructureView, what, bondParams)\n const distanceData = {}\n\n if (!what || what.color) {\n Object.assign( distanceData, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n if (!what || what.radius) {\n Object.assign( distanceData, {radius: bondData.radius})\n }\n\n (this.distanceBuffer as CylinderGeometryBuffer).setAttributes(distanceData)\n }\n\n setParameters (params: Partial) {\n let rebuild = false\n const what = {}\n\n super.setParameters(params, what, rebuild)\n\n if (!this.useCylinder) {\n if (params && params.lineOpacity) {\n (this.distanceBuffer as WideLineBuffer).setParameters({ opacity: params.lineOpacity })\n }\n if (params && params.opacity !== undefined) {\n (this.distanceBuffer as WideLineBuffer).setParameters({ opacity: this.lineOpacity })\n }\n if (params && params.linewidth) {\n (this.distanceBuffer as WideLineBuffer).setParameters({ linewidth: params.linewidth })\n }\n }\n\n return this\n }\n}\n\nRepresentationRegistry.add('distance', DistanceRepresentation)\n\nexport default DistanceRepresentation\n","/**\n * @file Vector Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { Color, Matrix4, Vector3 } from 'three'\n\nimport '../shader/Line.vert'\nimport '../shader/Line.frag'\n\nimport { uniformArray3 } from '../math/array-utils'\nimport Buffer, { BufferDefaultParameters, BufferData, BufferParameters } from './buffer'\nimport { GenericColor } from '../types'\n\nfunction getSize(data: BufferData){\n const n = data.position!.length / 3\n return n * 2 * 3\n}\n\nexport interface VectorBufferData extends BufferData {\n vector: Float32Array\n}\n\nexport const VectorBufferDefaultParameters = Object.assign({\n scale: 1,\n color: 'grey'\n}, BufferDefaultParameters)\nexport type VectorBufferParameters = BufferParameters & { scale: number, color: GenericColor }\n\n/**\n * Vector buffer. Draws vectors as lines.\n */\nclass VectorBuffer extends Buffer {\n get defaultParameters() { return VectorBufferDefaultParameters }\n parameters: VectorBufferParameters\n\n isLine = true\n vertexShader = 'Line.vert'\n fragmentShader = 'Line.frag'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.vector - vectors\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: VectorBufferData, params: Partial = {}) {\n super({\n position: new Float32Array(getSize(data)),\n color: new Float32Array(getSize(data))\n }, params)\n\n const color = new Color(this.parameters.color)\n const attributes = this.geometry.attributes as any // TODO\n uniformArray3(getSize(data) / 3, color.r, color.g, color.b, attributes.color.array)\n\n this.setAttributes(data)\n }\n\n setAttributes (data: Partial = {}) {\n const attributes = this.geometry.attributes as any // TODO\n\n let position, vector\n let aPosition\n\n if (data.position && data.vector) {\n position = data.position\n vector = data.vector\n aPosition = attributes.position.array\n attributes.position.needsUpdate = true\n }\n\n const n = this.size / 2\n const scale = this.parameters.scale\n\n if (position && vector) {\n for (let v = 0; v < n; v++) {\n const i = v * 2 * 3\n const j = v * 3\n\n aPosition[ i + 0 ] = position[ j + 0 ]\n aPosition[ i + 1 ] = position[ j + 1 ]\n aPosition[ i + 2 ] = position[ j + 2 ]\n aPosition[ i + 3 ] = position[ j + 0 ] + vector[ j + 0 ] * scale\n aPosition[ i + 4 ] = position[ j + 1 ] + vector[ j + 1 ] * scale\n aPosition[ i + 5 ] = position[ j + 2 ] + vector[ j + 2 ] * scale\n }\n }\n }\n}\n\nexport default VectorBuffer\n","/**\n * @file Helixorient Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Helixorient from '../geometry/helixorient'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferParameters } from '../buffer/sphere-buffer'\nimport VectorBuffer from '../buffer/vector-buffer'\nimport Viewer from '../viewer/viewer';\nimport { Structure } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport Polymer from '../proxy/polymer';\nimport { AtomDataFields } from '../structure/structure-data';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\nimport SphereImpostorBuffer from '../buffer/sphereimpostor-buffer';\nimport { BufferData } from '../buffer/buffer';\n\n/**\n * Helixorient Representation\n */\nclass HelixorientRepresentation extends StructureRepresentation {\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'helixorient'\n\n this.parameters = Object.assign({\n sphereDetail: true,\n disableImpostor: true\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'sstruc')\n p.radiusType = defaults(p.radiusType, 'size')\n p.radiusSize = defaults(p.radiusSize, 0.15)\n p.radiusScale = defaults(p.radiusScale, 1.0)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n const bufferList: (SphereBuffer|VectorBuffer)[] = []\n const polymerList: Polymer[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4) return\n polymerList.push(polymer)\n\n const helixorient = new Helixorient(polymer)\n const position = helixorient.getPosition()\n const color = helixorient.getColor(this.getColorParams())\n const size = helixorient.getSize(this.getRadiusParams())\n const picking = helixorient.getPicking()\n\n bufferList.push(\n new SphereBuffer(\n {\n position: position.center,\n color: color.color,\n radius: size.size,\n picking: picking.picking\n },\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters\n ),\n new VectorBuffer(\n {\n position: position.center,\n vector: position.axis\n },\n this.getBufferParams({\n color: 'skyblue',\n scale: 1\n })\n ),\n new VectorBuffer(\n {\n position: position.center,\n vector: position.resdir\n },\n this.getBufferParams({\n color: 'lightgreen',\n scale: 1\n })\n )\n )\n }, sview.getSelection())\n\n return {\n bufferList: bufferList as (SphereGeometryBuffer|SphereImpostorBuffer|VectorBuffer)[],\n polymerList: polymerList\n }\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n if (Debug) Log.time(this.type + ' repr update')\n\n what = what || {}\n\n for (let i = 0, il = data.polymerList!.length; i < il; ++i) {\n const j = i * 3\n\n const bufferData: Partial = {}\n const polymer = data.polymerList![ i ]\n const helixorient = new Helixorient(polymer)\n\n if (what.position) {\n const position = helixorient.getPosition()\n\n Object.assign(bufferData, {position: position.center})\n\n data.bufferList[ j + 1 ].setAttributes({\n 'position': position.center,\n 'vector': position.axis\n })\n data.bufferList[ j + 2 ].setAttributes({\n 'position': position.center,\n 'vector': position.resdir\n })\n }\n\n data.bufferList[ j ].setAttributes(bufferData)\n }\n\n if (Debug) Log.timeEnd(this.type + ' repr update')\n }\n}\n\nRepresentationRegistry.add('helixorient', HelixorientRepresentation)\n\nexport default HelixorientRepresentation\n","/**\n * @file Licorice Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport BallAndStickRepresentation, { BallAndStickRepresentationParameters } from './ballandstick-representation'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\n\n/**\n * Licorice representation object ({@link BallAndStickRepresentation} with `aspectRatio` fixed at 1.0)\n */\nclass LicoriceRepresentation extends BallAndStickRepresentation {\n /**\n * Create Licorice representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {BallAndStickRepresentationParameters} params - ball and stick representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'licorice'\n\n this.parameters = Object.assign(\n {}, this.parameters, { aspectRatio: null }\n )\n }\n\n init (params: Partial) {\n var p = params || {}\n p.aspectRatio = 1.0\n\n super.init(p)\n }\n}\n\nRepresentationRegistry.add('licorice', LicoriceRepresentation)\n\nexport default LicoriceRepresentation\n","/**\n * @file Mapped Box Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { BufferParameters, BufferData } from './buffer'\nimport MappedBuffer from './mapped-buffer'\n\nconst mapping = new Float32Array([\n -1.0, -1.0, -1.0,\n 1.0, -1.0, -1.0,\n 1.0, -1.0, 1.0,\n -1.0, -1.0, 1.0,\n -1.0, 1.0, -1.0,\n 1.0, 1.0, -1.0,\n 1.0, 1.0, 1.0,\n -1.0, 1.0, 1.0\n])\n\nconst mappingIndices = new Uint16Array([\n 0, 1, 2,\n 0, 2, 3,\n 1, 5, 6,\n 1, 6, 2,\n 4, 6, 5,\n 4, 7, 6,\n 0, 7, 4,\n 0, 3, 7,\n 0, 5, 1,\n 0, 4, 5,\n 3, 2, 6,\n 3, 6, 7\n])\n\n/**\n * Mapped Box buffer. Draws boxes. Used to render general imposters.\n * @interface\n */\nclass MappedBoxBuffer extends MappedBuffer {\n constructor(data: BufferData, params: Partial = {}) {\n super('v3', data, params)\n }\n get mapping () { return mapping }\n get mappingIndices () { return mappingIndices }\n get mappingIndicesSize () { return 36 }\n get mappingSize () { return 8 }\n get mappingItemSize () { return 3 }\n}\n\nexport default MappedBoxBuffer\n","/**\n * @file Hyperball Stick Impostor Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3 required for declaration only\nimport { Matrix4, Vector3 } from 'three'\n\nimport '../shader/HyperballStickImpostor.vert'\nimport '../shader/HyperballStickImpostor.frag'\n\nimport MappedBoxBuffer from './mappedbox-buffer'\nimport { BufferDefaultParameters, BufferParameterTypes, BufferData, BufferParameters } from './buffer'\n\nexport interface HyperballStickImpostorBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n color2: Float32Array\n radius: Float32Array\n radius2: Float32Array\n}\n\nexport const HyperballStickImpostorBufferDefaultParameters = Object.assign({\n shrink: 0.14\n}, BufferDefaultParameters)\nexport type HyperballStickImpostorBufferParameters = BufferParameters & { shrink: number }\n\nconst HyperballStickImpostorBufferParameterTypes = Object.assign({\n shrink: { uniform: true }\n}, BufferParameterTypes)\n\n/**\n * Hyperball stick impostor buffer.\n *\n * @example\n * var hyperballStickImpostorBuffer = new HyperballStickImpostorBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 2, 2, 2 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ]),\n * radius2: new Float32Array([ 2 ])\n * });\n */\nclass HyperballStickImpostorBuffer extends MappedBoxBuffer {\n parameterTypes = HyperballStickImpostorBufferParameterTypes\n get defaultParameters() { return HyperballStickImpostorBufferDefaultParameters }\n parameters: HyperballStickImpostorBufferParameters\n\n isImpostor = true\n vertexShader = 'HyperballStickImpostor.vert'\n fragmentShader = 'HyperballStickImpostor.frag'\n\n constructor (data: HyperballStickImpostorBufferData, params: Partial = {}) {\n super(data, params)\n\n this.addUniforms({\n 'modelViewProjectionMatrix': { value: new Matrix4() },\n 'modelViewProjectionMatrixInverse': { value: new Matrix4() },\n 'modelViewMatrixInverseTranspose': { value: new Matrix4() },\n 'shrink': { value: this.parameters.shrink }\n })\n\n this.addAttributes({\n 'position1': { type: 'v3', value: null },\n 'position2': { type: 'v3', value: null },\n 'color2': { type: 'c', value: null },\n 'radius': { type: 'f', value: null },\n 'radius2': { type: 'f', value: null }\n })\n\n this.setAttributes(data)\n this.makeMapping()\n }\n}\n\nexport default HyperballStickImpostorBuffer\n","/**\n * @file Hyperball Stick Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import required for declaration only\nimport { Vector3, Matrix4 } from 'three'\nimport { ExtensionFragDepth } from '../globals'\nimport { calculateMinArray } from '../math/array-utils'\nimport CylinderGeometryBuffer, { CylinderGeometryBufferDefaultParameters, CylinderGeometryBufferParameters } from './cylindergeometry-buffer'\nimport HyperballStickImpostorBuffer, { HyperballStickImpostorBufferDefaultParameters, HyperballStickImpostorBufferParameters } from './hyperballstickimpostor-buffer'\nimport { BufferData } from './buffer'\n\nexport interface HyperballStickBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n color2: Float32Array\n radius: Float32Array\n radius2: Float32Array\n}\n\nexport const HyperballStickBufferDefaultParameters = Object.assign({\n disableImpostor: false\n}, CylinderGeometryBufferDefaultParameters, HyperballStickImpostorBufferDefaultParameters)\nexport type HyperballStickBufferParameters = HyperballStickImpostorBufferParameters & CylinderGeometryBufferParameters & { disableImpostor: boolean }\n\nclass HyperballStickBufferImpl {\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - from colors\n * @param {Float32Array} data.color2 - to colors\n * @param {Float32Array} data.radius - from radii\n * @param {Float32Array} data.radius2 - to radii\n * @param {Float32Array} data.picking - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: HyperballStickBufferData, params: Partial = {}) {\n if (!ExtensionFragDepth || (params && params.disableImpostor)) {\n data.radius = calculateMinArray(data.radius, data.radius2)\n return new CylinderGeometryBuffer(data, params)\n } else {\n return new HyperballStickImpostorBuffer(data, params)\n }\n }\n}\n\n/**\n * Hyperball stick buffer. Depending on the value {@link ExtensionFragDepth} and\n * `params.disableImpostor` the constructor returns either a\n * {@link CylinderGeometryBuffer} or a {@link HyperballStickImpostorBuffer}\n * @implements {Buffer}\n *\n * @example\n * var hyperballStickBuffer = new HyperballStickBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 2, 2, 2 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ]),\n * radius2: new Float32Array([ 2 ])\n * });\n */\n//@ts-expect-error Incompatible constructor signatures\nconst HyperballStickBuffer: {\n new(data: HyperballStickBufferData, params: Partial): CylinderGeometryBuffer | HyperballStickImpostorBuffer;\n} = HyperballStickBufferImpl;\n\ntype HyperballStickBuffer = CylinderGeometryBuffer | HyperballStickImpostorBuffer;\n\nexport default HyperballStickBuffer\n","/**\n * @file Hyperball Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { calculateCenterArray } from '../math/array-utils'\nimport LicoriceRepresentation from './licorice-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport HyperballStickBuffer, { HyperballStickBufferData } from '../buffer/hyperballstick-buffer'\nimport { BallAndStickRepresentationParameters } from './ballandstick-representation';\n// @ts-ignore: unused import Volume required for declaration only\nimport { Structure, Volume } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport { BondDataParams, BondDataFields, AtomDataFields } from '../structure/structure-data';\nimport StructureView from '../structure/structure-view';\nimport { StructureRepresentationData } from './structure-representation';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\n// @ts-ignore: unused import Surface required for declaration only\nimport Surface from '../surface/surface';\n\nexport interface HyperballRepresentationParameters extends BallAndStickRepresentationParameters {\n shrink: number\n}\n\n/**\n * Hyperball Representation\n */\nclass HyperballRepresentation extends LicoriceRepresentation {\n protected shrink: number\n protected __center: Float32Array\n \n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'hyperball'\n\n this.parameters = Object.assign({\n\n shrink: {\n type: 'number', precision: 3, max: 1.0, min: 0.001, buffer: true\n }\n\n }, this.parameters, {\n\n multipleBond: null,\n bondSpacing: null\n\n })\n }\n\n init (params: Partial) {\n var p = params || {}\n p.radiusScale = defaults(p.radiusScale, 0.2)\n p.radiusType = defaults(p.radiusType, 'vdw')\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.shrink = defaults(p.shrink, 0.12)\n\n super.init(p)\n }\n\n getBondParams (what?: BondDataFields, params?: BondDataParams) {\n if (!what || what.radius) {\n params = Object.assign({ radius2: true }, params)\n }\n\n return super.getBondParams(what, params)\n }\n\n createData (sview: StructureView) {\n var sphereBuffer = new SphereBuffer(\n (sview.getAtomData(this.getAtomParams()) as SphereBufferData),\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters\n ) as SphereGeometryBuffer\n\n this.__center = new Float32Array(sview.bondCount * 3)\n\n var stickBuffer = new HyperballStickBuffer(\n sview.getBondData(this.getBondParams()) as HyperballStickBufferData,\n this.getBufferParams({\n shrink: this.shrink,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n return {\n bufferList: [ sphereBuffer, stickBuffer ]\n }\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n var atomData = data.sview!.getAtomData(this.getAtomParams())\n var bondData = data.sview!.getBondData(this.getBondParams())\n var sphereData = {}\n var stickData = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {position: atomData.position})\n var from = bondData.position1\n var to = bondData.position2\n Object.assign(stickData, {\n position: calculateCenterArray(from!, to!, this.__center),\n position1: from,\n position2: to\n })\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {color: atomData.color})\n Object.assign(stickData, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {radius: atomData.radius})\n Object.assign(stickData, {\n radius: bondData.radius,\n radius2: bondData.radius2\n })\n }\n\n data.bufferList[ 0 ].setAttributes(sphereData)\n data.bufferList[ 1 ].setAttributes(stickData)\n }\n}\n\nRepresentationRegistry.add('hyperball', HyperballRepresentation)\n\nexport default HyperballRepresentation\n","/**\n * @file Label Factory\n * @author Alexander Rose \n * @private\n */\n\nimport { AA1 } from '../structure/structure-constants'\nimport AtomProxy from '../proxy/atom-proxy'\nimport { sprintf } from 'sprintf-js'\n\nexport const LabelFactoryTypes = {\n '': '',\n 'atomname': 'atom name',\n 'atomindex': 'atom index',\n 'occupancy': 'occupancy',\n 'bfactor': 'b-factor',\n 'serial': 'serial',\n 'element': 'element',\n 'atom': 'atom name + index',\n 'resname': 'residue name',\n 'resno': 'residue no',\n 'res': 'one letter code + no',\n 'residue': '[residue name] + no + inscode',\n 'text': 'text',\n 'format': 'format',\n 'qualified': 'qualified name'\n}\nexport type LabelType = keyof typeof LabelFactoryTypes\n\nclass LabelFactory {\n\n static types = LabelFactoryTypes\n errorLogged: boolean = false\n\n constructor(readonly type: LabelType, readonly text: { [k: number]: string } = {},\n readonly format: string = '') {}\n\n atomLabel (a: AtomProxy) {\n const type = this.type\n\n let l\n\n switch (type) {\n case 'atomname':\n l = a.atomname\n break\n\n case 'atomindex':\n l = `${a.index}`\n break\n\n case 'occupancy':\n l = a.occupancy.toFixed(2)\n break\n\n case 'bfactor':\n l = a.bfactor.toFixed(2)\n break\n\n case 'serial':\n l = `${a.serial}`\n break\n\n case 'element':\n l = a.element\n break\n\n case 'atom':\n l = `${a.atomname}|${a.index}`\n break\n\n case 'resname':\n l = a.resname\n break\n\n case 'resno':\n l = `${a.resno}`\n break\n\n case 'res':\n l = `${(AA1[ a.resname.toUpperCase() ] || a.resname)}${a.resno}`\n break\n\n case 'residue':\n const aa1 = AA1[ a.resname.toUpperCase() ]\n if (aa1 && !a.inscode) {\n l = `${aa1}${a.resno}`\n } else {\n l = `[${a.resname}]${a.resno}${a.inscode}`\n }\n break\n\n case 'text':\n l = this.text[ a.index ]\n break\n\n case 'format':\n try {\n l = sprintf(this.format, a)\n } catch (e) {\n if (!this.errorLogged) {\n this.errorLogged = true\n console.log(e.message)\n }\n }\n break\n\n // case \"qualified\":\n default:\n l = a.qualifiedName()\n break\n }\n\n return l === undefined ? '' : l\n }\n}\n\nexport default LabelFactory\n","/**\n * @file Label Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry, ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport LabelFactory, { LabelType } from '../utils/label-factory'\nimport RadiusFactory from '../utils/radius-factory'\nimport StructureRepresentation, { StructureRepresentationData } from './structure-representation'\nimport TextBuffer, { TextBufferData } from '../buffer/text-buffer'\nimport { RepresentationParameters } from './representation';\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { GenericColor } from '../types'\n\nexport interface TextDataField {\n position?: boolean\n color?: boolean\n radius?: boolean\n text?: boolean\n}\n\n/**\n * Label representation parameter object. Extends {@link RepresentationParameters} and\n * {@link StructureRepresentationParameters}.\n *\n * @typedef {Object} LabelRepresentationParameters - label representation parameters\n *\n * @property {Integer} clipNear - position of camera near/front clipping plane\n * in percent of scene bounding box\n * @property {Float} opacity - translucency: 1 is fully opaque, 0 is fully transparent\n * @property {String} labelType - type of the label, one of:\n * \"atomname\", \"atomindex\", \"occupancy\", \"bfactor\",\n * \"serial\", \"element\", \"atom\", \"resname\", \"resno\",\n * \"res\", \"text\", \"qualified\". When set to \"text\", the\n * `labelText` list is used.\n * @property {String[]} labelText - list of label strings, must set `labelType` to \"text\"\n * to take effect\n * @property {String} labelFormat - sprintf-js format string, any attribute of\n * {@link AtomProxy} can be used\n * @property {String} labelGrouping - grouping of the label, one of:\n * \"atom\", \"residue\".\n * @property {String} fontFamily - font family, one of: \"sans-serif\", \"monospace\", \"serif\"\n * @property {String} fontStyle - font style, \"normal\" or \"italic\"\n * @property {String} fontWeight - font weight, \"normal\" or \"bold\"\n * @property {Float} xOffset - offset in x-direction\n * @property {Float} yOffset - offset in y-direction\n * @property {Float} zOffset - offset in z-direction (i.e. in camera direction)\n * @property {String} attachment - attachment of the label, one of:\n * \"bottom-left\", \"bottom-center\", \"bottom-right\",\n * \"middle-left\", \"middle-center\", \"middle-right\",\n * \"top-left\", \"top-center\", \"top-right\"\n * @property {Boolean} showBorder - show border/outline\n * @property {Color} borderColor - color of the border/outline\n * @property {Float} borderWidth - width of the border/outline\n * @property {Boolean} showBackground - show background rectangle\n * @property {Color} backgroundColor - color of the background\n * @property {Float} backgroundMargin - width of the background\n * @property {Float} backgroundOpacity - opacity of the background\n * @property {Boolean} fixedSize - show text with a fixed pixel size\n */\nexport interface LabelRepresentationParameters extends RepresentationParameters {\n labelType: LabelType\n labelText: string[]\n labelFormat: string\n labelGrouping: 'atom'|'residue'\n fontFamily: 'sans-serif'|'monospace'|'serif'\n fontStyle: 'normal'|'italic'\n fontWeight: 'normal'|'bold'\n xOffset: number\n yOffset: number\n zOffset: number\n attachment: 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n showBorder: boolean\n borderColor: GenericColor\n borderWidth: number\n showBackground: boolean\n backgroundColor: GenericColor\n backgroundMargin: number\n backgroundOpacity: number\n fixedSize: boolean\n}\n/**\n * Label representation\n */\nclass LabelRepresentation extends StructureRepresentation {\n\n protected labelType: LabelType\n protected labelText: string[]\n protected labelFormat: string\n protected labelGrouping: 'atom'|'residue'\n protected fontFamily: 'sans-serif'|'monospace'|'serif'\n protected fontStyle: 'normal'|'italic'\n protected fontWeight: 'normal'|'bold'\n protected xOffset: number\n protected yOffset: number\n protected zOffset: number\n protected attachment: 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n protected showBorder: boolean\n protected borderColor: GenericColor\n protected borderWidth: number\n protected showBackground: boolean\n protected backgroundColor: GenericColor\n protected backgroundMargin: number\n protected backgroundOpacity: number\n protected fixedSize: boolean\n\n /**\n * Create Label representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {LabelRepresentationParameters} params - label representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'label'\n\n this.parameters = Object.assign({\n\n labelType: {\n type: 'select', options: LabelFactory.types, rebuild: true\n },\n labelText: {\n type: 'hidden', rebuild: true\n },\n labelFormat: {\n type: 'text', rebuild: true\n },\n labelGrouping: {\n type: 'select',\n options: {\n 'atom': 'atom',\n 'residue': 'residue'\n },\n rebuild: true\n },\n fontFamily: {\n type: 'select',\n options: {\n 'sans-serif': 'sans-serif',\n 'monospace': 'monospace',\n 'serif': 'serif'\n },\n buffer: true\n },\n fontStyle: {\n type: 'select',\n options: {\n 'normal': 'normal',\n 'italic': 'italic'\n },\n buffer: true\n },\n fontWeight: {\n type: 'select',\n options: {\n 'normal': 'normal',\n 'bold': 'bold'\n },\n buffer: true\n },\n xOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: true\n },\n yOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: true\n },\n zOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: true\n },\n attachment: {\n type: 'select',\n options: {\n 'bottom-left': 'bottom-left',\n 'bottom-center': 'bottom-center',\n 'bottom-right': 'bottom-right',\n 'middle-left': 'middle-left',\n 'middle-center': 'middle-center',\n 'middle-right': 'middle-right',\n 'top-left': 'top-left',\n 'top-center': 'top-center',\n 'top-right': 'top-right'\n },\n rebuild: true\n },\n showBorder: {\n type: 'boolean', buffer: true\n },\n borderColor: {\n type: 'color', buffer: true\n },\n borderWidth: {\n type: 'number', precision: 2, max: 0.3, min: 0, buffer: true\n },\n showBackground: {\n type: 'boolean', rebuild: true\n },\n backgroundColor: {\n type: 'color', buffer: true\n },\n backgroundMargin: {\n type: 'number', precision: 2, max: 2, min: 0, rebuild: true\n },\n backgroundOpacity: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n fixedSize: {\n type: 'boolean', buffer: true\n }\n\n }, this.parameters, {\n\n side: null,\n flatShaded: null,\n wireframe: null,\n linewidth: null,\n\n roughness: null,\n metalness: null,\n diffuse: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n\n this.labelType = defaults(p.labelType, 'res')\n this.labelText = defaults(p.labelText, {})\n this.labelFormat = defaults(p.labelFormat, '')\n this.labelGrouping = defaults(p.labelGrouping, 'atom')\n this.fontFamily = defaults(p.fontFamily, 'sans-serif')\n this.fontStyle = defaults(p.fontStyle, 'normal')\n this.fontWeight = defaults(p.fontWeight, 'bold')\n this.xOffset = defaults(p.xOffset, 0.0)\n this.yOffset = defaults(p.yOffset, 0.0)\n this.zOffset = defaults(p.zOffset, 0.5)\n this.attachment = defaults(p.attachment, 'bottom-left')\n this.showBorder = defaults(p.showBorder, false)\n this.borderColor = defaults(p.borderColor, 'lightgrey')\n this.borderWidth = defaults(p.borderWidth, 0.15)\n this.showBackground = defaults(p.showBackground, false)\n this.backgroundColor = defaults(p.backgroundColor, 'lightgrey')\n this.backgroundMargin = defaults(p.backgroundMargin, 0.5)\n this.backgroundOpacity = defaults(p.backgroundOpacity, 1.0)\n this.fixedSize = defaults(p.fixedSize, false)\n\n super.init(p)\n }\n\n getTextData (sview: StructureView, what?: TextDataField) {\n const p = this.getAtomParams(what)\n const labelFactory = new LabelFactory(this.labelType, this.labelText, this.labelFormat)\n let position: Float32Array, size: Float32Array, color: Float32Array, text: string[],\n positionN: number[], sizeN: number[], colorN: number[]\n if (this.labelGrouping === 'atom') {\n const atomData = sview.getAtomData(p)\n position = atomData.position as Float32Array\n size = atomData.radius as Float32Array\n color = atomData.color as Float32Array\n if (!what || what.text) {\n text = []\n sview.eachAtom(ap => text.push(labelFactory.atomLabel(ap)))\n }\n } else if (this.labelGrouping === 'residue') {\n if (!what || what.position) positionN = []\n if (!what || what.color) colorN = []\n if (!what || what.radius) sizeN = []\n if (!what || what.text) text = []\n if (p.colorParams) p.colorParams.structure = sview.getStructure()\n const colormaker = ColormakerRegistry.getScheme(p.colorParams)\n const radiusFactory = new RadiusFactory(p.radiusParams)\n const ap1 = sview.getAtomProxy()\n\n let i = 0\n sview.eachResidue(rp => {\n const i3 = i * 3\n if (rp.isProtein() || rp.isNucleic()) {\n ap1.index = rp.traceAtomIndex\n if (!what || what.position) {\n ap1.positionToArray(positionN, i3)\n }\n } else {\n ap1.index = rp.atomOffset\n if (!what || what.position) {\n rp.positionToArray(positionN, i3)\n }\n }\n if (!what || what.color) {\n colormaker.atomColorToArray(ap1, colorN, i3)\n }\n if (!what || what.radius) {\n sizeN[ i ] = radiusFactory.atomRadius(ap1)\n }\n if (!what || what.text) {\n text.push(labelFactory.atomLabel(ap1))\n }\n ++i\n })\n\n if (!what || what.position) position = new Float32Array(positionN!)\n if (!what || what.color) color = new Float32Array(colorN!)\n if (!what || what.radius) size = new Float32Array(sizeN!)\n }\n\n return { position: position!, size: size!, color: color!, text: text! }\n }\n\n createData (sview: StructureView) {\n const what: TextDataField = { position: true, color: true, radius: true, text: true }\n\n const textBuffer = new TextBuffer(\n this.getTextData(sview, what) as TextBufferData,\n this.getBufferParams({\n fontFamily: this.fontFamily,\n fontStyle: this.fontStyle,\n fontWeight: this.fontWeight,\n xOffset: this.xOffset,\n yOffset: this.yOffset,\n zOffset: this.zOffset,\n attachment: this.attachment,\n showBorder: this.showBorder,\n borderColor: this.borderColor,\n borderWidth: this.borderWidth,\n showBackground: this.showBackground,\n backgroundColor: this.backgroundColor,\n backgroundMargin: this.backgroundMargin,\n backgroundOpacity: this.backgroundOpacity,\n fixedSize: this.fixedSize\n })\n )\n\n return { bufferList: [ textBuffer ] }\n }\n\n updateData (what: TextDataField, data: StructureRepresentationData) {\n data.bufferList[ 0 ].setAttributes(this.getTextData(data.sview as StructureView, what))\n }\n\n getAtomRadius () {\n return 0\n }\n}\n\nRepresentationRegistry.add('label', LabelRepresentation)\n\nexport default LabelRepresentation\n","/**\n * @file Line Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { RepresentationRegistry } from '../globals'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport WideLineBuffer from '../buffer/wideline-buffer'\nimport { AtomPicker } from '../utils/picker'\n// @ts-ignore: unused import Volume required for declaration only\nimport { Structure, Volume } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport Viewer from '../viewer/viewer';\nimport AtomProxy from '../proxy/atom-proxy';\n// @ts-ignore: unused import Surface required for declaration only\nimport Surface from '../surface/surface';\n// @ts-ignore: unused import BondDataFields, BondDataParams required for declaration only\nimport { BondDataFields, BondDataParams } from '../structure/structure-data';\n\n/**\n * Determine which atoms in a Structure[View] form no bonds to any other atoms\n * in that Structure.\n *\n * This differs from setting the selection to \"nonbonded\" as it finds atoms\n * that have no bonds within the current selection.\n * @param {Structure} structure - The Structure or StructureView object\n * @return {AtomSet} AtomSet of lone atoms\n */\nfunction getLoneAtomSet (structure: Structure | StructureView) {\n const atomSet = structure.getAtomSet()\n const bondSet = structure.getBondSet()\n const bp = structure.getBondProxy()\n bondSet.forEach(function (idx) {\n bp.index = idx\n atomSet.clear(bp.atomIndex1)\n atomSet.clear(bp.atomIndex2)\n })\n return atomSet\n}\n\nexport interface LineRepresentationParameters extends StructureRepresentationParameters {\n multipleBond: 'off' | 'symmetric' | 'offset'\n bondSpacing: number\n linewidth: number\n lines: boolean\n crosses: 'off' | 'all' | 'lone'\n crossSize: number\n}\n\nexport interface CrossData {\n position1?: Float32Array\n position2?: Float32Array\n color?: Float32Array\n color2?: Float32Array\n picking?: AtomPicker\n}\n\n/**\n * Line representation\n */\nclass LineRepresentation extends StructureRepresentation {\n protected multipleBond: 'off' | 'symmetric' | 'offset'\n protected bondSpacing: number\n protected linewidth: number\n protected lines: boolean\n protected crosses: 'off' | 'all' | 'lone'\n protected crossSize: number\n /**\n * Create Line representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {RepresentationParameters} params - representation parameters, plus the properties listed below\n * @property {String} multipleBond - one off \"off\", \"symmetric\", \"offset\"\n * @param {Float} params.bondSpacing - spacing for multiple bond rendering\n * @param {Integer} params.linewidth - width of lines\n * @param {Boolean} params.lines - render bonds as lines\n * @param {String} params.crosses - render atoms as crosses: \"off\", \"all\" or \"lone\" (default)\n * @param {Float} params.crossSize - size of cross\n * @param {null} params.flatShaded - not available\n * @param {null} params.side - not available\n * @param {null} params.wireframe - not available\n * @param {null} params.roughness - not available\n * @param {null} params.metalness - not available\n * @param {null} params.diffuse - not available\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'line'\n\n this.parameters = Object.assign({\n\n multipleBond: {\n type: 'select',\n rebuild: true,\n options: {\n 'off': 'off',\n 'symmetric': 'symmetric',\n 'offset': 'offset'\n }\n },\n bondSpacing: {\n type: 'number', precision: 2, max: 2.0, min: 0.5\n },\n linewidth: {\n type: 'integer', max: 50, min: 1, buffer: true\n },\n lines: {\n type: 'boolean', rebuild: true\n },\n crosses: {\n type: 'select',\n rebuild: true,\n options: {\n 'off': 'off',\n 'lone': 'lone',\n 'all': 'all'\n }\n },\n crossSize: {\n type: 'number', precision: 2, max: 2.0, min: 0.1\n }\n\n }, this.parameters, {\n\n flatShaded: null,\n side: null,\n wireframe: null,\n\n roughness: null,\n metalness: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n\n this.multipleBond = defaults(p.multipleBond, 'off')\n this.bondSpacing = defaults(p.bondSpacing, 1.0)\n this.linewidth = defaults(p.linewidth, 2)\n this.lines = defaults(p.lines, true)\n this.crosses = defaults(p.crosses, 'lone')\n this.crossSize = defaults(p.crossSize, 0.4)\n\n super.init(p)\n }\n\n getAtomRadius (atom:AtomProxy) {\n return 0.1\n }\n\n getBondParams (what: any, params?: Partial) {\n params = Object.assign({\n multipleBond: this.multipleBond,\n bondSpacing: this.bondSpacing,\n radiusParams: { 'type': 'size', 'size': 0.1, 'scale': 1 }\n }, params)\n\n return super.getBondParams(what, params)\n }\n\n _crossData (what: any, sview: StructureView) {\n if (what) {\n if (!what.position && !what.color) return\n }\n\n const p = {}\n if (this.crosses === 'lone') {\n Object.assign(p, {atomSet : getLoneAtomSet(sview)})\n }\n\n const atomData = sview.getAtomData(this.getAtomParams(what, p))\n const crossData: CrossData = {}\n const position = atomData.position\n const color = atomData.color\n const picking = atomData.picking\n\n const size = (position! || color).length\n const attrSize = size * 3\n\n let cPosition1 = new Float32Array(0)\n let cPosition2 = new Float32Array(0)\n let cColor = new Float32Array(0)\n let cColor2 = new Float32Array(0)\n let cOffset: number = 0\n\n let pickingArray = new Float32Array(0)\n\n if (!what || what.position) {\n cPosition1 = crossData.position1 = new Float32Array(attrSize)\n cPosition2 = crossData.position2 = new Float32Array(attrSize)\n cOffset = this.crossSize / 2\n }\n if (!what || what.color) {\n cColor = crossData.color = new Float32Array(attrSize)\n cColor2 = crossData.color2 = new Float32Array(attrSize)\n }\n if (!what || what.picking) {\n pickingArray = new Float32Array(atomData.picking!.array!.length * 3) // Needs padding??\n }\n\n for (let v = 0; v < size; v++) {\n const j = v * 3\n const i = j * 3\n\n if (!what || what.position) {\n const x = position![ j ]\n const y = position![ j + 1 ]\n const z = position![ j + 2 ]\n\n cPosition1[ i ] = x - cOffset!\n cPosition1[ i + 1 ] = y\n cPosition1[ i + 2 ] = z\n cPosition2[ i ] = x + cOffset\n cPosition2[ i + 1 ] = y\n cPosition2[ i + 2 ] = z\n\n cPosition1[ i + 3 ] = x\n cPosition1[ i + 4 ] = y - cOffset\n cPosition1[ i + 5 ] = z\n cPosition2[ i + 3 ] = x\n cPosition2[ i + 4 ] = y + cOffset\n cPosition2[ i + 5 ] = z\n\n cPosition1[ i + 6 ] = x\n cPosition1[ i + 7 ] = y\n cPosition1[ i + 8 ] = z - cOffset\n cPosition2[ i + 6 ] = x\n cPosition2[ i + 7 ] = y\n cPosition2[ i + 8 ] = z + cOffset\n }\n\n if (!what || what.color) {\n const cimax = i + 9\n for (let ci = i; ci < cimax; ci += 3) {\n cColor[ ci ] = cColor2[ ci ] = color![ j ]\n cColor[ ci + 1 ] = cColor2[ ci + 1 ] = color![ j + 1 ]\n cColor[ ci + 2 ] = cColor2[ ci + 2 ] = color![ j + 2 ]\n }\n }\n\n if (!what || what.picking) {\n pickingArray[ j ] =\n pickingArray[ j + 1 ] =\n pickingArray[ j + 2 ] = picking!.array![ v ]\n }\n }\n\n if (!what || what.picking) {\n crossData.picking = new AtomPicker(\n pickingArray, picking!.structure\n )\n }\n\n return crossData\n }\n\n createData (sview: StructureView) {\n const what = { position: true, color: true, picking: true }\n\n const bufferList = []\n\n if (this.lines) {\n const bondData = sview.getBondData(this.getBondParams(what))\n\n const lineBuffer = new WideLineBuffer(\n bondData, this.getBufferParams({ linewidth: this.linewidth })\n )\n\n bufferList.push(lineBuffer)\n }\n\n if (this.crosses !== 'off') {\n const crossBuffer = new WideLineBuffer(\n (this._crossData(what, sview) as CrossData),\n this.getBufferParams({linewidth: this.linewidth})\n )\n bufferList.push(crossBuffer)\n }\n\n return {\n bufferList: bufferList\n }\n }\n\n updateData (what: any, data: StructureRepresentationData) {\n let bufferIdx = 0\n\n if (this.lines) {\n const bondData = data.sview!.getBondData(this.getBondParams(what))\n const lineAttributes = {}\n\n if (!what || what.position) {\n Object.assign(lineAttributes, {\n position1: bondData.position1,\n position2: bondData.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(lineAttributes, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n data.bufferList[ bufferIdx++ ].setAttributes(lineAttributes)\n }\n\n if (this.crosses !== 'off') {\n const crossData = this._crossData(what, (data.sview as StructureView))\n const crossAttributes = {}\n\n if (!what || what.position) {\n Object.assign(crossAttributes, {\n position1: crossData!.position1,\n position2: crossData!.position2\n })\n }\n if (!what || what.color) {\n Object.assign(crossAttributes, {\n color: crossData!.color,\n color2: crossData!.color2\n })\n }\n\n data.bufferList[ bufferIdx++ ].setAttributes(crossAttributes)\n }\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n if (params && (params.bondSpacing || params.crossSize)) {\n Object.assign(what, { position: true })\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('line', LineRepresentation)\n\nexport default LineRepresentation\n","import { NumberArray, TypedArray } from \"../types\";\n\n/**\n * @file Grid\n * @author Alexander Rose \n * @private\n */\nexport interface iGrid {\n data: TypedArray\n index: (x: number, y: number, z: number) => number\n set: (x: number, y: number, z: number, ...arg: number[]) => void\n toArray: (x: number, y: number, z: number, array?: NumberArray, offset?: number) => void\n fromArray: (x: number, y: number, z: number, array: NumberArray, offset?: number) => void\n copy: (grid: iGrid) => void\n // clone: () => iGrid\n}\n\nfunction makeGrid (length: number, width: number, height: number, DataCtor: any, elemSize: number) : iGrid {\n DataCtor = DataCtor || Int32Array\n elemSize = elemSize || 1\n\n const data = new DataCtor(length * width * height * elemSize)\n\n function index (x: number, y: number, z: number) {\n return ((((x * width) + y) * height) + z) * elemSize\n }\n\n function set (x: number, y: number, z: number, ...args: number[]) {\n const i = index(x, y, z)\n\n for (let j = 0; j < elemSize; ++j) {\n data[ i + j ] = args[ j ]\n }\n }\n\n function toArray (x: number, y: number, z: number, array: NumberArray = [], offset: number = 0) {\n const i = index(x, y, z)\n\n for (let j = 0; j < elemSize; ++j) {\n array[ offset + j ] = data[ i + j ]\n }\n }\n\n function fromArray(x: number, y: number, z: number, array: NumberArray, offset: number = 0) {\n const i = index(x, y, z)\n\n for (let j = 0; j < elemSize; ++j) {\n data[ i + j ] = array[ offset + j ]\n }\n }\n\n function copy(grid: iGrid) {\n data.set(grid.data)\n }\n\n // function clone() {\n // return makeGrid(\n // length, width, height, DataCtor, elemSize\n // ).copy(this)\n // }\n return { data, index, set, toArray, fromArray, copy }\n}\n\nexport { makeGrid }","/**\n * @file EDT Surface\n * @author Alexander Rose \n * @private\n */\n\nimport { VolumeSurface } from './volume'\nimport { iGrid, makeGrid } from '../geometry/grid'\nimport { computeBoundingBox } from '../math/vector-utils'\nimport { getRadiusDict, getSurfaceGrid } from './surface-utils'\nimport { TypedArray } from '../types';\n\ninterface EDTSurface {\n getVolume: (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean) => {\n data: TypedArray\n nx: number\n ny: number\n nz: number\n atomindex: TypedArray\n }\n getSurface: (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean, smooth: number, contour: boolean) => any\n}\n\nfunction EDTSurface (this: EDTSurface, coordList: Float32Array, radiusList: Float32Array, indexList: Uint16Array|Uint32Array) {\n // based on D. Xu, Y. Zhang (2009) Generating Triangulated Macromolecular\n // Surfaces by Euclidean Distance Transform. PLoS ONE 4(12): e8140.\n //\n // Permission to use, copy, modify, and distribute this program for\n // any purpose, with or without fee, is hereby granted, provided that\n // the notices on the head, the reference information, and this\n // copyright notice appear in all copies or substantial portions of\n // the Software. It is provided \"as is\" without express or implied\n // warranty.\n //\n // ported to JavaScript by biochem_fan (http://webglmol.sourceforge.jp/)\n // refactored by dkoes (https://github.com/dkoes)\n //\n // adapted to NGL by Alexander Rose\n\n var radiusDict = getRadiusDict(radiusList as any)\n var bbox = computeBoundingBox(coordList)\n if (coordList.length === 0) {\n bbox[ 0 ].set([ 0, 0, 0 ])\n bbox[ 1 ].set([ 0, 0, 0 ])\n }\n var min = bbox[ 0 ]\n var max = bbox[ 1 ]\n\n var probeRadius: number, scaleFactor: number, cutoff: number\n var pLength: number, pWidth: number, pHeight: number\n var matrix: Float32Array, ptran: Float32Array\n var depty: {[k: string]: TypedArray}, widxz: {[k: string]: number}\n var cutRadius: number\n var setAtomID: boolean\n var vpBits: TypedArray, vpDistance: TypedArray, vpAtomID: TypedArray\n\n function init (btype: boolean, _probeRadius: number, _scaleFactor: number, _cutoff: number, _setAtomID: boolean) {\n probeRadius = _probeRadius || 1.4\n scaleFactor = _scaleFactor || 2.0\n setAtomID = _setAtomID || true\n\n var maxRadius = 0\n for (var radius in radiusDict) {\n maxRadius = Math.max(maxRadius, radius as any)\n }\n\n var grid = getSurfaceGrid(\n min, max, maxRadius, scaleFactor, btype ? probeRadius : 0\n )\n\n pLength = grid.dim[0]\n pWidth = grid.dim[1]\n pHeight = grid.dim[2]\n\n matrix = grid.matrix\n ptran = grid.tran\n scaleFactor = grid.scaleFactor\n\n // boundingatom caches\n depty = {}\n widxz = {}\n boundingatom(btype)\n\n cutRadius = probeRadius * scaleFactor\n\n if (_cutoff) {\n cutoff = _cutoff\n } else {\n // cutoff = Math.max( 0.1, -1.2 + scaleFactor * probeRadius );\n cutoff = probeRadius / scaleFactor\n }\n\n vpBits = new Uint8Array(pLength * pWidth * pHeight)\n if (btype) {\n vpDistance = new Float64Array(pLength * pWidth * pHeight)\n }\n if (setAtomID) {\n vpAtomID = new Int32Array(pLength * pWidth * pHeight)\n }\n }\n\n // constants for vpBits bitmasks\n var INOUT = 1\n var ISDONE = 2\n var ISBOUND = 4\n\n var nb = [\n new Int32Array([ 1, 0, 0 ]), new Int32Array([ -1, 0, 0 ]),\n new Int32Array([ 0, 1, 0 ]), new Int32Array([ 0, -1, 0 ]),\n new Int32Array([ 0, 0, 1 ]), new Int32Array([ 0, 0, -1 ]),\n new Int32Array([ 1, 1, 0 ]), new Int32Array([ 1, -1, 0 ]),\n new Int32Array([ -1, 1, 0 ]), new Int32Array([ -1, -1, 0 ]),\n new Int32Array([ 1, 0, 1 ]), new Int32Array([ 1, 0, -1 ]),\n new Int32Array([ -1, 0, 1 ]), new Int32Array([ -1, 0, -1 ]),\n new Int32Array([ 0, 1, 1 ]), new Int32Array([ 0, 1, -1 ]),\n new Int32Array([ 0, -1, 1 ]), new Int32Array([ 0, -1, -1 ]),\n new Int32Array([ 1, 1, 1 ]), new Int32Array([ 1, 1, -1 ]),\n new Int32Array([ 1, -1, 1 ]), new Int32Array([ -1, 1, 1 ]),\n new Int32Array([ 1, -1, -1 ]), new Int32Array([ -1, -1, 1 ]),\n new Int32Array([ -1, 1, -1 ]), new Int32Array([ -1, -1, -1 ])\n ]\n\n //\n\n this.getVolume = function (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean) {\n console.time('EDTSurface.getVolume')\n\n var btype = type !== 'vws'\n\n init(btype, probeRadius, scaleFactor, cutoff, setAtomID)\n\n fillvoxels(btype)\n buildboundary()\n\n if (type === 'ms' || type === 'ses') {\n fastdistancemap()\n }\n\n if (type === 'ses') {\n boundingatom(false)\n fillvoxelswaals()\n }\n\n marchingcubeinit(type)\n\n // set atomindex in the volume data\n for (var i = 0, il = vpAtomID.length; i < il; ++i) {\n vpAtomID[ i ] = indexList[ vpAtomID[ i ] ]\n }\n\n console.timeEnd('EDTSurface.getVolume')\n\n return {\n data: vpBits,\n nx: pHeight,\n ny: pWidth,\n nz: pLength,\n atomindex: vpAtomID\n }\n }\n\n this.getSurface = function (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean, smooth: number, contour: boolean) {\n var vd = this.getVolume(\n type, probeRadius, scaleFactor, cutoff, setAtomID\n )\n\n var volsurf = new (VolumeSurface as any)(\n vd.data, vd.nx, vd.ny, vd.nz, vd.atomindex\n ) as VolumeSurface\n\n return (volsurf!.getSurface as any)(1, smooth, undefined, matrix, contour)\n }\n\n function boundingatom (btype: boolean) {\n var r\n var j\n var k\n var txz\n var tdept\n var sradius\n var tradius\n var widxzR\n var deptyName\n var indx\n\n for (var name in radiusDict) {\n r = parseFloat(name)\n\n if (depty[ name ]) continue\n\n if (!btype) {\n tradius = r * scaleFactor + 0.5\n } else {\n tradius = (r + probeRadius) * scaleFactor + 0.5\n }\n\n sradius = tradius * tradius\n widxzR = Math.floor(tradius) + 1\n deptyName = new Int32Array(widxzR * widxzR)\n indx = 0\n\n for (j = 0; j < widxzR; ++j) {\n for (k = 0; k < widxzR; ++k) {\n txz = j * j + k * k\n\n if (txz > sradius) {\n deptyName[ indx ] = -1\n } else {\n tdept = Math.sqrt(sradius - txz)\n deptyName[ indx ] = Math.floor(tdept)\n }\n\n ++indx\n }\n }\n\n widxz[ name ] = widxzR\n depty[ name ] = deptyName\n }\n }\n\n function fillatom (idx: number) {\n var ci = idx * 3\n var ri = idx\n\n var cx, cy, cz, ox, oy, oz, mi, mj, mk, i, j, k, si, sj, sk\n var ii, jj, kk\n\n cx = Math.floor(0.5 + scaleFactor * (coordList[ ci ] + ptran[0]))\n cy = Math.floor(0.5 + scaleFactor * (coordList[ ci + 1 ] + ptran[1]))\n cz = Math.floor(0.5 + scaleFactor * (coordList[ ci + 2 ] + ptran[2]))\n\n var at = radiusList[ ri ]\n var deptyAt = depty[ at ]\n var nind = 0\n var pWH = pWidth * pHeight\n var n = widxz[ at ]\n\n var deptyAtNind\n\n for (i = 0; i < n; ++i) {\n for (j = 0; j < n; ++j) {\n deptyAtNind = deptyAt[ nind ]\n\n if (deptyAtNind !== -1) {\n for (ii = -1; ii < 2; ++ii) {\n for (jj = -1; jj < 2; ++jj) {\n for (kk = -1; kk < 2; ++kk) {\n if (ii !== 0 && jj !== 0 && kk !== 0) {\n mi = ii * i\n mk = kk * j\n\n for (k = 0; k <= deptyAtNind; ++k) {\n mj = k * jj\n si = cx + mi\n sj = cy + mj\n sk = cz + mk\n\n if (si < 0 || sj < 0 || sk < 0 ||\n si >= pLength || sj >= pWidth || sk >= pHeight\n ) {\n continue\n }\n\n var index = si * pWH + sj * pHeight + sk\n\n if (!setAtomID) {\n vpBits[ index ] |= INOUT\n } else {\n if (!(vpBits[ index ] & INOUT)) {\n vpBits[ index ] |= INOUT\n vpAtomID[ index ] = idx\n } else if (vpBits[ index ] & INOUT) {\n var ci2 = vpAtomID[ index ]\n\n if (ci2 !== ci) {\n ox = cx + mi - Math.floor(0.5 + scaleFactor * (coordList[ci2] + ptran[0]))\n oy = cy + mj - Math.floor(0.5 + scaleFactor * (coordList[ci2 + 1] + ptran[1]))\n oz = cz + mk - Math.floor(0.5 + scaleFactor * (coordList[ci2 + 2] + ptran[2]))\n\n if (mi * mi + mj * mj + mk * mk < ox * ox + oy * oy + oz * oz) {\n vpAtomID[ index ] = idx\n }\n }\n }\n }\n } // k\n } // if\n } // kk\n } // jj\n } // ii\n } // if\n\n nind++\n } // j\n } // i\n }\n\n function fillvoxels (btype: boolean) {\n console.time('EDTSurface fillvoxels')\n\n var i, il\n\n for (i = 0, il = vpBits.length; i < il; ++i) {\n vpBits[ i ] = 0\n if (btype) vpDistance[ i ] = -1.0\n if (setAtomID) vpAtomID[ i ] = -1\n }\n\n for (i = 0, il = coordList.length / 3; i < il; ++i) {\n fillatom(i)\n }\n\n for (i = 0, il = vpBits.length; i < il; ++i) {\n if (vpBits[ i ] & INOUT) {\n vpBits[ i ] |= ISDONE\n }\n }\n\n console.timeEnd('EDTSurface fillvoxels')\n }\n\n function fillAtomWaals (idx: number) {\n var ci = idx * 3\n var ri = idx\n\n var cx\n var cy\n var cz\n var ox\n var oy\n var oz\n var nind = 0\n\n var mi\n var mj\n var mk\n var si\n var sj\n var sk\n var i\n var j\n var k\n var ii\n var jj\n var kk\n var n\n\n cx = Math.floor(0.5 + scaleFactor * (coordList[ ci ] + ptran[0]))\n cy = Math.floor(0.5 + scaleFactor * (coordList[ ci + 1 ] + ptran[1]))\n cz = Math.floor(0.5 + scaleFactor * (coordList[ ci + 2 ] + ptran[2]))\n\n var at = radiusList[ ri ]\n var pWH = pWidth * pHeight\n\n for (i = 0, n = widxz[at]; i < n; ++i) {\n for (j = 0; j < n; ++j) {\n if (depty[ at ][ nind ] !== -1) {\n for (ii = -1; ii < 2; ++ii) {\n for (jj = -1; jj < 2; ++jj) {\n for (kk = -1; kk < 2; ++kk) {\n if (ii !== 0 && jj !== 0 && kk !== 0) {\n mi = ii * i\n mk = kk * j\n\n for (k = 0; k <= depty[ at ][ nind ]; ++k) {\n mj = k * jj\n si = cx + mi\n sj = cy + mj\n sk = cz + mk\n\n if (si < 0 || sj < 0 || sk < 0 ||\n si >= pLength || sj >= pWidth || sk >= pHeight\n ) {\n continue\n }\n\n var index = si * pWH + sj * pHeight + sk\n\n if (!(vpBits[ index ] & ISDONE)) {\n vpBits[ index ] |= ISDONE\n if (setAtomID) vpAtomID[ index ] = idx\n } else if (setAtomID) {\n var ci2 = vpAtomID[ index ]\n\n ox = Math.floor(0.5 + scaleFactor * (coordList[ ci2 ] + ptran[0]))\n oy = Math.floor(0.5 + scaleFactor * (coordList[ ci2 + 1 ] + ptran[1]))\n oz = Math.floor(0.5 + scaleFactor * (coordList[ ci2 + 2 ] + ptran[2]))\n\n if (mi * mi + mj * mj + mk * mk < ox * ox + oy * oy + oz * oz) {\n vpAtomID[ index ] = idx\n }\n }\n } // k\n } // if\n } // kk\n } // jj\n } // ii\n } // if\n\n nind++\n } // j\n } // i\n }\n\n function fillvoxelswaals () {\n var i, il\n\n for (i = 0, il = vpBits.length; i < il; ++i) {\n vpBits[ i ] &= ~ISDONE // not isdone\n }\n\n for (i = 0, il = coordList.length / 3; i < il; ++i) {\n fillAtomWaals(i)\n }\n }\n\n function buildboundary () {\n var i, j, k\n var pWH = pWidth * pHeight\n\n for (i = 0; i < pLength; ++i) {\n for (j = 0; j < pHeight; ++j) {\n for (k = 0; k < pWidth; ++k) {\n var index = i * pWH + k * pHeight + j\n\n if (vpBits[ index ] & INOUT) {\n // var flagbound = false;\n var ii = 0\n\n // while( !flagbound && ii < 26 ){\n while (ii < 26) {\n var ti = i + nb[ ii ][ 0 ]\n var tj = j + nb[ ii ][ 2 ]\n var tk = k + nb[ ii ][ 1 ]\n\n if (ti > -1 && ti < pLength &&\n tk > -1 && tk < pWidth &&\n tj > -1 && tj < pHeight &&\n !(vpBits[ ti * pWH + tk * pHeight + tj ] & INOUT)\n ) {\n vpBits[ index ] |= ISBOUND\n // flagbound = true;\n break\n } else {\n ii++\n }\n }\n }\n } // k\n } // j\n } // i\n }\n\n function fastdistancemap () {\n console.time('EDTSurface fastdistancemap')\n\n var i, j, k, n\n\n var boundPoint = makeGrid(\n pLength, pWidth, pHeight, Uint16Array, 3\n )\n var pWH = pWidth * pHeight\n var cutRSq = cutRadius * cutRadius\n\n var totalsurfacevox = 0\n // var totalinnervox = 0;\n\n var index\n\n for (i = 0; i < pLength; ++i) {\n for (j = 0; j < pWidth; ++j) {\n for (k = 0; k < pHeight; ++k) {\n index = i * pWH + j * pHeight + k\n\n vpBits[ index ] &= ~ISDONE\n\n if (vpBits[ index ] & INOUT) {\n if (vpBits[ index ] & ISBOUND) {\n boundPoint.set(\n i, j, k,\n i, j, k\n )\n\n vpDistance[ index ] = 0\n vpBits[ index ] |= ISDONE\n\n totalsurfacevox += 1\n }/* else{\n totalinnervox += 1;\n } */\n }\n }\n }\n }\n\n var inarray = new Int32Array(3 * totalsurfacevox)\n var positin = 0\n var outarray = new Int32Array(3 * totalsurfacevox)\n var positout = 0\n\n for (i = 0; i < pLength; ++i) {\n for (j = 0; j < pWidth; ++j) {\n for (k = 0; k < pHeight; ++k) {\n index = i * pWH + j * pHeight + k\n\n if (vpBits[ index ] & ISBOUND) {\n inarray[ positin ] = i\n inarray[ positin + 1 ] = j\n inarray[ positin + 2 ] = k\n positin += 3\n\n vpBits[ index ] &= ~ISBOUND\n }\n }\n }\n }\n\n do {\n positout = fastoneshell(inarray, boundPoint, positin, outarray)\n positin = 0\n\n for (i = 0, n = positout; i < n; i += 3) {\n index = pWH * outarray[ i ] + pHeight * outarray[ i + 1 ] + outarray[ i + 2 ]\n vpBits[ index ] &= ~ISBOUND\n\n if (vpDistance[ index ] <= 1.0404 * cutRSq) {\n // if( vpDistance[ index ] <= 1.02 * cutRadius ){\n\n inarray[ positin ] = outarray[ i ]\n inarray[ positin + 1 ] = outarray[ i + 1 ]\n inarray[ positin + 2 ] = outarray[ i + 2 ]\n positin += 3\n }\n }\n } while (positin > 0)\n\n // var cutsf = Math.max( 0, scaleFactor - 0.5 );\n // cutoff = cutRadius - 0.5 / ( 0.1 + cutsf );\n var cutoffSq = cutoff * cutoff\n\n var index2\n var bp = new Uint16Array(3)\n\n for (i = 0; i < pLength; ++i) {\n for (j = 0; j < pWidth; ++j) {\n for (k = 0; k < pHeight; ++k) {\n index = i * pWH + j * pHeight + k\n vpBits[ index ] &= ~ISBOUND\n\n // ses solid\n\n if (vpBits[ index ] & INOUT) {\n if (!(vpBits[ index ] & ISDONE) ||\n ((vpBits[ index ] & ISDONE) && vpDistance[ index ] >= cutoffSq)\n ) {\n vpBits[ index ] |= ISBOUND\n\n if (setAtomID && (vpBits[ index ] & ISDONE)) {\n boundPoint.toArray(i, j, k, bp)\n index2 = bp[ 0 ] * pWH + bp[ 1 ] * pHeight + bp[ 2 ]\n\n vpAtomID[ index ] = vpAtomID[ index2 ]\n }\n }\n }\n }\n }\n }\n\n console.timeEnd('EDTSurface fastdistancemap')\n }\n\n function fastoneshell (inarray: Int32Array, boundPoint: iGrid, positin: number, outarray: Int32Array) {\n // *allocout,voxel2\n // ***boundPoint, int*\n // outnum, int *elimi)\n var tx, ty, tz\n var dx, dy, dz\n var i, j, n\n var square\n var index\n var nbj\n var bp = new Uint16Array(3)\n var positout = 0\n\n if (positin === 0) {\n return positout\n }\n\n var tnvix = -1\n var tnviy = -1\n var tnviz = -1\n\n var pWH = pWidth * pHeight\n\n for (i = 0, n = positin; i < n; i += 3) {\n tx = inarray[ i ]\n ty = inarray[ i + 1 ]\n tz = inarray[ i + 2 ]\n boundPoint.toArray(tx, ty, tz, bp)\n\n for (j = 0; j < 6; ++j) {\n nbj = nb[ j ]\n tnvix = tx + nbj[ 0 ]\n tnviy = ty + nbj[ 1 ]\n tnviz = tz + nbj[ 2 ]\n\n if (tnvix < pLength && tnvix > -1 &&\n tnviy < pWidth && tnviy > -1 &&\n tnviz < pHeight && tnviz > -1\n ) {\n index = tnvix * pWH + pHeight * tnviy + tnviz\n\n if ((vpBits[ index ] & INOUT) && !(vpBits[ index ] & ISDONE)) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n vpDistance[ index ] = square\n vpBits[ index ] |= ISDONE\n vpBits[ index ] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n } else if ((vpBits[ index ] & INOUT) && (vpBits[ index ] & ISDONE)) {\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n if (square < vpDistance[ index ]) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n vpDistance[ index ] = square\n\n if (!(vpBits[ index ] & ISBOUND)) {\n vpBits[ index ] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n }\n }\n }\n }\n }\n }\n\n for (i = 0, n = positin; i < n; i += 3) {\n tx = inarray[ i ]\n ty = inarray[ i + 1 ]\n tz = inarray[ i + 2 ]\n boundPoint.toArray(tx, ty, tz, bp)\n\n for (j = 6; j < 18; j++) {\n nbj = nb[ j ]\n tnvix = tx + nbj[ 0 ]\n tnviy = ty + nbj[ 1 ]\n tnviz = tz + nbj[ 2 ]\n\n if (tnvix < pLength && tnvix > -1 &&\n tnviy < pWidth && tnviy > -1 &&\n tnviz < pHeight && tnviz > -1\n ) {\n index = tnvix * pWH + pHeight * tnviy + tnviz\n\n if ((vpBits[index] & INOUT) && !(vpBits[index] & ISDONE)) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n vpDistance[index] = square\n vpBits[index] |= ISDONE\n vpBits[index] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n } else if ((vpBits[index] & INOUT) && (vpBits[index] & ISDONE)) {\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n if (square < vpDistance[index]) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n vpDistance[index] = square\n\n if (!(vpBits[index] & ISBOUND)) {\n vpBits[index] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n }\n }\n }\n }\n }\n }\n\n for (i = 0, n = positin; i < n; i += 3) {\n tx = inarray[ i ]\n ty = inarray[ i + 1 ]\n tz = inarray[ i + 2 ]\n boundPoint.toArray(tx, ty, tz, bp)\n\n for (j = 18; j < 26; j++) {\n nbj = nb[ j ]\n tnvix = tx + nbj[ 0 ]\n tnviy = ty + nbj[ 1 ]\n tnviz = tz + nbj[ 2 ]\n\n if (tnvix < pLength && tnvix > -1 &&\n tnviy < pWidth && tnviy > -1 &&\n tnviz < pHeight && tnviz > -1\n ) {\n index = tnvix * pWH + pHeight * tnviy + tnviz\n\n if ((vpBits[index] & INOUT) && !(vpBits[index] & ISDONE)) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n vpDistance[index] = square\n vpBits[index] |= ISDONE\n vpBits[index] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n } else if ((vpBits[index] & INOUT) && (vpBits[index] & ISDONE)) {\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n if (square < vpDistance[index]) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n vpDistance[index] = square\n\n if (!(vpBits[index] & ISBOUND)) {\n vpBits[index] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n }\n }\n }\n }\n }\n }\n\n return positout\n }\n\n function marchingcubeinit (stype: string) {\n var i\n var n = vpBits.length\n\n if (stype === 'vws') {\n for (i = 0; i < n; ++i) {\n vpBits[ i ] &= ~ISBOUND\n vpBits[ i ] = (vpBits[ i ] & ISDONE) ? 1 : 0\n }\n } else if (stype === 'ms') { // ses without vdw => ms\n for (i = 0; i < n; ++i) {\n vpBits[ i ] &= ~ISDONE\n if (vpBits[ i ] & ISBOUND) {\n vpBits[ i ] |= ISDONE\n }\n vpBits[ i ] &= ~ISBOUND\n vpBits[ i ] = (vpBits[ i ] & ISDONE) ? 1 : 0\n }\n } else if (stype === 'ses') {\n for (i = 0; i < n; ++i) {\n if ((vpBits[ i ] & ISBOUND) && (vpBits[ i ] & ISDONE)) {\n vpBits[ i ] &= ~ISBOUND\n } else if ((vpBits[ i ] & ISBOUND) && !(vpBits[ i ] & ISDONE)) {\n vpBits[ i ] |= ISDONE\n }\n vpBits[ i ] = (vpBits[ i ] & ISDONE) ? 1 : 0\n }\n } else if (stype === 'sas') {\n for (i = 0; i < n; ++i) {\n vpBits[ i ] &= ~ISBOUND\n vpBits[ i ] = (vpBits[ i ] & ISDONE) ? 1 : 0\n }\n }\n }\n}\nObject.assign(EDTSurface, {__deps: [\n getSurfaceGrid, getRadiusDict, VolumeSurface, computeBoundingBox, makeGrid\n]})\n\nexport default EDTSurface\n","/**\n * @file AV Surface\n * @author Fred Ludlow \n * @private\n */\n\nimport { getSurfaceGrid } from './surface-utils'\nimport { VolumeSurface } from './volume'\nimport { uniformArray } from '../math/array-utils'\nimport {\n computeBoundingBox, v3multiplyScalar, v3cross, v3normalize\n} from '../math/vector-utils'\nimport { defaults } from '../utils'\nimport { NumberArray } from '../types';\n\n\n/**\n * Modifed from SpatialHash\n *\n * Main differences are:\n * - Optimized grid size to ensure we only ever need to look +/-1 cell\n * - Aware of atomic radii and will only output atoms within rAtom + rExtra\n * (see withinRadii method)\n *\n * (Uses rounding rather than bitshifting as consequence of arbitrary grid size)\n * @class\n * @param {Float32Array} atomsX - x coordinates\n * @param {Float32Array} atomsY - y coordinates\n * @param {Float32Array} atomsZ - z coordinates\n * @param {Float32Array} atomsR - atom radii\n * @param {Float32Array} min - xyz min coordinates\n * @param {Float32Array} max - xyz max coordinates\n * @param {Float} maxDistance - max distance\n */\nexport interface iAVHash {\n neighbourListLength: number\n withinRadii: (x: number, y: number, z: number, rExtra: number, out: Int32Array) => void\n}\n\n\nfunction makeAVHash (atomsX: Float32Array, atomsY: Float32Array, atomsZ: Float32Array, atomsR: Float32Array, min: Float32Array, max: Float32Array, maxDistance: number): iAVHash {\n maxDistance = Math.max(0.1, maxDistance) // Avoid maxDistance of zero, see #802\n var nAtoms = atomsX.length\n\n var minX = min[ 0 ]\n var minY = min[ 1 ]\n var minZ = min[ 2 ]\n\n var maxX = max[ 0 ]\n var maxY = max[ 1 ]\n var maxZ = max[ 2 ]\n\n function hashFunc (w: number, minW: number) {\n return Math.floor((w - minW) / maxDistance)\n }\n\n var iDim = hashFunc(maxX, minX) + 1\n var jDim = hashFunc(maxY, minY) + 1\n var kDim = hashFunc(maxZ, minZ) + 1\n\n var nCells = iDim * jDim * kDim\n\n var jkDim = jDim * kDim\n\n /* Get cellID for cartesian x,y,z */\n var cellID = function (x: number, y: number, z: number) {\n return (((hashFunc(x, minX) * jDim) + hashFunc(y, minY)) * kDim) + hashFunc(z, minZ)\n }\n\n /* Initial building, could probably be optimized further */\n var preHash = [] // preHash[ cellID ] = [ atomId1, atomId2 ];\n\n for (var i = 0; i < nAtoms; i++) {\n var cid = cellID(atomsX[ i ], atomsY[ i ], atomsZ[ i ])\n\n if (preHash[ cid ] === undefined) {\n preHash[ cid ] = [ i ]\n } else {\n preHash[ cid ].push(i)\n }\n }\n\n var cellOffsets = new Uint32Array(nCells)\n var cellLengths = new Uint16Array(nCells)\n var data = new Uint32Array(nAtoms)\n\n var offset = 0\n var maxCellLength = 0\n\n for (i = 0; i < nCells; i++) {\n var start = cellOffsets[ i ] = offset\n\n var subArray = preHash[ i ]\n\n if (subArray !== undefined) {\n for (var j = 0; j < subArray.length; j++) {\n data[ offset ] = subArray[ j ]\n offset++\n }\n }\n\n var cellLength = offset - start\n cellLengths[ i ] = cellLength\n\n if (cellLength > maxCellLength) { maxCellLength = cellLength }\n }\n\n // Maximum number of neighbours we could ever produce (27 adjacent cells of equal population)\n const neighbourListLength = (27 * maxCellLength) + 1\n\n /**\n * Populate the supplied out array with atom indices that are within rAtom + rExtra\n * of x,y,z\n *\n * -1 in out array indicates the end of the list\n *\n * @param {Float} x - x coordinate\n * @param {Float} y - y coordinate\n * @param {Float} z - z coordinate\n * @param {Float} rExtra - additional radius\n * @param {Float32Array} out - pre-allocated output array\n * @return {undefined}\n */\n const withinRadii = function (x: number, y: number, z: number, rExtra: number, out: Int32Array) {\n var outIdx = 0\n\n var nearI = hashFunc(x, minX)\n var nearJ = hashFunc(y, minY)\n var nearK = hashFunc(z, minZ)\n\n var loI = Math.max(0, nearI - 1)\n var loJ = Math.max(0, nearJ - 1)\n var loK = Math.max(0, nearK - 1)\n\n var hiI = Math.min(iDim, nearI + 2)\n var hiJ = Math.min(jDim, nearJ + 2)\n var hiK = Math.min(kDim, nearK + 2)\n\n for (var i = loI; i < hiI; ++i) {\n var iOffset = i * jkDim\n\n for (var j = loJ; j < hiJ; ++j) {\n var jOffset = j * kDim\n\n for (var k = loK; k < hiK; ++k) {\n var cid = iOffset + jOffset + k\n\n var cellStart = cellOffsets[ cid ]\n var cellEnd = cellStart + cellLengths[ cid ]\n\n for (var dataIndex = cellStart; dataIndex < cellEnd; dataIndex++) {\n var atomIndex = data[ dataIndex ]\n var dx = atomsX[ atomIndex ] - x\n var dy = atomsY[ atomIndex ] - y\n var dz = atomsZ[ atomIndex ] - z\n var rSum = atomsR[ atomIndex ] + rExtra\n\n if ((dx * dx + dy * dy + dz * dz) <= (rSum * rSum)) {\n out[ outIdx++ ] = data[ dataIndex ]\n }\n }\n }\n }\n }\n // Add terminator\n out[ outIdx ] = -1\n }\n return {\n neighbourListLength: neighbourListLength,\n withinRadii: withinRadii\n }\n}\n\ninterface AVSurface {\n getSurface: (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean, smooth: number, contour: boolean) => any\n}\nfunction AVSurface (this: AVSurface, coordList: Float32Array, radiusList: Float32Array, indexList: Uint16Array|Uint32Array) {\n // Field generation method adapted from AstexViewer (Mike Hartshorn)\n // by Fred Ludlow.\n // Other parts based heavily on NGL (Alexander Rose) EDT Surface class\n //\n // Should work as a drop-in alternative to EDTSurface (though some of\n // the EDT paramters are not relevant in this method).\n\n const nAtoms = radiusList.length\n\n const x = new Float32Array(nAtoms)\n const y = new Float32Array(nAtoms)\n const z = new Float32Array(nAtoms)\n\n for (let i = 0; i < nAtoms; i++) {\n const ci = 3 * i\n x[ i ] = coordList[ ci ]\n y[ i ] = coordList[ ci + 1 ]\n z[ i ] = coordList[ ci + 2 ]\n }\n\n let bbox = computeBoundingBox(coordList)\n if (coordList.length === 0) {\n bbox[ 0 ].set([ 0, 0, 0 ])\n bbox[ 1 ].set([ 0, 0, 0 ])\n }\n const min = bbox[0]\n const max = bbox[1]\n\n let r: Float32Array, r2: Float32Array // Atom positions, expanded radii (squared)\n let maxRadius: number\n\n // Parameters\n let probeRadius: number, scaleFactor: number, setAtomID: boolean, probePositions: number\n\n // Cache last value for obscured test\n let lastClip = -1\n\n // Grid params\n let dim: Float32Array, matrix: Float32Array, grid: NumberArray, atomIndex: Int32Array\n\n // grid indices -> xyz coords\n let gridx: Float32Array, gridy: Float32Array, gridz: Float32Array\n\n // Lookup tables:\n let sinTable: Float32Array, cosTable: Float32Array\n\n // Spatial Hash\n let hash: iAVHash\n\n // Neighbour array to be filled by hash\n let neighbours: Int32Array\n\n // Vectors for Torus Projection\n const atob = new Float32Array([ 0.0, 0.0, 0.0 ])\n const mid = new Float32Array([ 0.0, 0.0, 0.0 ])\n const n1 = new Float32Array([ 0.0, 0.0, 0.0 ])\n const n2 = new Float32Array([ 0.0, 0.0, 0.0 ])\n\n let ngTorus: number\n\n function init (_probeRadius?: number, _scaleFactor?: number, _setAtomID?: boolean, _probePositions?: number) {\n probeRadius = defaults(_probeRadius, 1.4)\n scaleFactor = defaults(_scaleFactor, 2.0)\n setAtomID = defaults(_setAtomID, true)\n probePositions = defaults(_probePositions, 30)\n\n r = new Float32Array(nAtoms)\n r2 = new Float32Array(nAtoms)\n\n for (let i = 0; i < r.length; ++i) {\n var rExt = radiusList[ i ] + probeRadius\n r[ i ] = rExt\n r2[ i ] = rExt * rExt\n }\n\n maxRadius = 0\n for (let j = 0; j < r.length; ++j) {\n if (r[ j ] > maxRadius) maxRadius = r[ j ]\n }\n\n initializeGrid()\n initializeAngleTables()\n initializeHash()\n\n lastClip = -1\n }\n\n function fillGridDim (a: Float32Array, start: number, step: number) {\n for (let i = 0; i < a.length; i++) {\n a[i] = start + (step * i)\n }\n }\n\n function initializeGrid () {\n const surfGrid = getSurfaceGrid(\n min, max, maxRadius, scaleFactor, 0.0\n )\n\n scaleFactor = surfGrid.scaleFactor\n dim = surfGrid.dim\n matrix = surfGrid.matrix\n\n ngTorus = Math.max(5, 2 + Math.floor(probeRadius * scaleFactor))\n\n grid = uniformArray(dim[0] * dim[1] * dim[2], -1001.0)\n\n atomIndex = new Int32Array(grid.length)\n\n gridx = new Float32Array(dim[0])\n gridy = new Float32Array(dim[1])\n gridz = new Float32Array(dim[2])\n\n fillGridDim(gridx, min[0], 1 / scaleFactor)\n fillGridDim(gridy, min[1], 1 / scaleFactor)\n fillGridDim(gridz, min[2], 1 / scaleFactor)\n }\n\n function initializeAngleTables () {\n var theta = 0.0\n var step = 2 * Math.PI / probePositions\n\n cosTable = new Float32Array(probePositions)\n sinTable = new Float32Array(probePositions)\n for (var i = 0; i < probePositions; i++) {\n cosTable[ i ] = Math.cos(theta)\n sinTable[ i ] = Math.sin(theta)\n theta += step\n }\n }\n\n function initializeHash () {\n hash = makeAVHash(x, y, z, r, min, max, 2.01 * maxRadius)\n neighbours = new Int32Array(hash.neighbourListLength)\n }\n\n function obscured (x: number, y: number, z: number, a: number, b: number) {\n // Is the point at x,y,z obscured by any of the atoms\n // specifeid by indices in neighbours. Ignore indices\n // a and b (these are the relevant atoms in projectPoints/Torii)\n\n // Cache the last clipped atom (as very often the same one in\n // subsequent calls)\n let ai: number\n\n if (lastClip !== -1) {\n ai = lastClip\n if (ai !== a && ai !== b && singleAtomObscures(ai, x, y, z)) {\n return ai\n } else {\n lastClip = -1\n }\n }\n\n var ni = 0\n ai = neighbours[ ni ]\n while (ai >= 0) {\n if (ai !== a && ai !== b && singleAtomObscures(ai, x, y, z)) {\n lastClip = ai\n return ai\n }\n ai = neighbours[ ++ni ]\n }\n\n lastClip = -1\n\n return -1\n }\n\n function singleAtomObscures (ai: number, x: number, y: number, z: number) {\n var ci = 3 * ai\n var ra2 = r2[ ai ]\n var dx = coordList[ ci ] - x\n var dy = coordList[ ci + 1 ] - y\n var dz = coordList[ ci + 2 ] - z\n var d2 = dx * dx + dy * dy + dz * dz\n\n return d2 < ra2\n }\n\n function projectPoints () {\n // For each atom:\n // Iterate over a subsection of the grid, for each point:\n // If current value < 0.0, unvisited, set positive\n //\n // In any case: Project this point onto surface of the atomic sphere\n // If this projected point is not obscured by any other atom\n // Calcualte delta distance and set grid value to minimum of\n // itself and delta\n\n // Should we alias frequently accessed closure variables??\n // Assume JS engine capable of optimizing this\n // anyway...\n\n for (var i = 0; i < nAtoms; i++) {\n var ax = x[ i ]\n var ay = y[ i ]\n var az = z[ i ]\n var ar = r[ i ]\n var ar2 = r2[ i ]\n\n hash.withinRadii(ax, ay, az, ar, neighbours)\n\n // Number of grid points, round this up...\n var ng = Math.ceil(ar * scaleFactor)\n\n // Center of the atom, mapped to grid points (take floor)\n var iax = Math.floor(scaleFactor * (ax - min[ 0 ]))\n var iay = Math.floor(scaleFactor * (ay - min[ 1 ]))\n var iaz = Math.floor(scaleFactor * (az - min[ 2 ]))\n\n // Extents of grid to consider for this atom\n var minx = Math.max(0, iax - ng)\n var miny = Math.max(0, iay - ng)\n var minz = Math.max(0, iaz - ng)\n\n // Add two to these points:\n // - iax are floor'd values so this ensures coverage\n // - these are loop limits (exclusive)\n var maxx = Math.min(dim[ 0 ], iax + ng + 2)\n var maxy = Math.min(dim[ 1 ], iay + ng + 2)\n var maxz = Math.min(dim[ 2 ], iaz + ng + 2)\n\n for (var ix = minx; ix < maxx; ix++) {\n var dx = gridx[ ix ] - ax\n var xoffset = dim[ 1 ] * dim[ 2 ] * ix\n\n for (var iy = miny; iy < maxy; iy++) {\n var dy = gridy[ iy ] - ay\n var dxy2 = dx * dx + dy * dy\n var xyoffset = xoffset + dim[ 2 ] * iy\n\n for (var iz = minz; iz < maxz; iz++) {\n var dz = gridz[ iz ] - az\n var d2 = dxy2 + dz * dz\n\n if (d2 < ar2) {\n var idx = iz + xyoffset\n\n if (grid[idx] < 0.0) {\n // Unvisited, make positive\n grid[ idx ] = -grid[ idx ]\n }\n // Project on to the surface of the sphere\n // sp is the projected point ( dx, dy, dz ) * ( ra / d )\n var d = Math.sqrt(d2)\n var ap = ar / d\n var spx = dx * ap\n var spy = dy * ap\n var spz = dz * ap\n\n spx += ax\n spy += ay\n spz += az\n\n if (obscured(spx, spy, spz, i, -1) === -1) {\n var dd = ar - d\n if (dd < grid[ idx ]) {\n grid[ idx ] = dd\n if (setAtomID) atomIndex[ idx ] = i\n }\n }\n }\n }\n }\n }\n }\n }\n\n function projectTorii () {\n for (var i = 0; i < nAtoms; i++) {\n hash.withinRadii(x[ i ], y[ i ], z[ i ], r[ i ], neighbours)\n var ia = 0\n var ni = neighbours[ ia ]\n while (ni >= 0) {\n if (i < ni) {\n projectTorus(i, ni)\n }\n ni = neighbours[ ++ia ]\n }\n }\n }\n\n function projectTorus (a: number, b: number) {\n var r1 = r[ a ]\n var r2 = r[ b ]\n var dx = atob[ 0 ] = x[ b ] - x[ a ]\n var dy = atob[ 1 ] = y[ b ] - y[ a ]\n var dz = atob[ 2 ] = z[ b ] - z[ a ]\n var d2 = dx * dx + dy * dy + dz * dz\n\n // This check now redundant as already done in AVHash.withinRadii\n // if( d2 > (( r1 + r2 ) * ( r1 + r2 )) ){ return; }\n\n var d = Math.sqrt(d2)\n\n // Find angle between a->b vector and the circle\n // of their intersection by cosine rule\n var cosA = (r1 * r1 + d * d - r2 * r2) / (2.0 * r1 * d)\n\n // distance along a->b at intersection\n var dmp = r1 * cosA\n\n v3normalize(atob, atob)\n\n // Create normal to line\n normalToLine(n1 as any, atob)\n v3normalize(n1, n1)\n\n // Cross together for second normal vector\n v3cross(n2, atob, n1)\n v3normalize(n2, n2)\n\n // r is radius of circle of intersection\n var rInt = Math.sqrt(r1 * r1 - dmp * dmp)\n\n v3multiplyScalar(n1, n1, rInt)\n v3multiplyScalar(n2, n2, rInt)\n v3multiplyScalar(atob, atob, dmp)\n\n mid[ 0 ] = atob[ 0 ] + x[ a ]\n mid[ 1 ] = atob[ 1 ] + y[ a ]\n mid[ 2 ] = atob[ 2 ] + z[ a ]\n\n lastClip = -1\n\n var ng = ngTorus\n\n for (var i = 0; i < probePositions; i++) {\n var cost = cosTable[ i ]\n var sint = sinTable[ i ]\n\n var px = mid[ 0 ] + cost * n1[ 0 ] + sint * n2[ 0 ]\n var py = mid[ 1 ] + cost * n1[ 1 ] + sint * n2[ 1 ]\n var pz = mid[ 2 ] + cost * n1[ 2 ] + sint * n2[ 2 ]\n\n if (obscured(px, py, pz, a, b) === -1) {\n // As above, iterate over our grid...\n // px, py, pz in grid coords\n var iax = Math.floor(scaleFactor * (px - min[ 0 ]))\n var iay = Math.floor(scaleFactor * (py - min[ 1 ]))\n var iaz = Math.floor(scaleFactor * (pz - min[ 2 ]))\n\n var minx = Math.max(0, iax - ng)\n var miny = Math.max(0, iay - ng)\n var minz = Math.max(0, iaz - ng)\n\n var maxx = Math.min(dim[ 0 ], iax + ng + 2)\n var maxy = Math.min(dim[ 1 ], iay + ng + 2)\n var maxz = Math.min(dim[ 2 ], iaz + ng + 2)\n\n for (var ix = minx; ix < maxx; ix++) {\n dx = px - gridx[ ix ]\n var xoffset = dim[ 1 ] * dim[ 2 ] * ix\n\n for (var iy = miny; iy < maxy; iy++) {\n dy = py - gridy[ iy ]\n var dxy2 = dx * dx + dy * dy\n var xyoffset = xoffset + dim[ 2 ] * iy\n\n for (var iz = minz; iz < maxz; iz++) {\n dz = pz - gridz[ iz ]\n d2 = dxy2 + dz * dz\n var idx = iz + xyoffset\n var current = grid[ idx ]\n\n if (current > 0.0 && d2 < (current * current)) {\n grid[ idx ] = Math.sqrt(d2)\n if (setAtomID) {\n // Is this grid point closer to a or b?\n // Take dot product of atob and gridpoint->p (dx, dy, dz)\n const dp = dx * atob[ 0 ] + dy * atob [ 1 ] + dz * atob[ 2 ]\n atomIndex[ idx ] = dp < 0.0 ? b : a\n }\n }\n }\n }\n }\n }\n }\n }\n\n function normalToLine (out: Int32Array, p: Float32Array) {\n out[ 0 ] = out[ 1 ] = out[ 2 ] = 1.0\n if (p[ 0 ] !== 0) {\n out[ 0 ] = (p[ 1 ] + p[ 2 ]) / -p[ 0 ]\n } else if (p[ 1 ] !== 0) {\n out[ 1 ] = (p[ 0 ] + p[ 2 ]) / -p[ 1 ]\n } else if (p[ 2 ] !== 0) {\n out[ 2 ] = (p[ 0 ] + p[ 1 ]) / -p[ 2 ]\n }\n return out\n }\n\n function fixNegatives () {\n for (var i = 0; i < grid.length; i++) {\n if (grid[ i ] < 0) grid[ i ] = 0\n }\n }\n\n function fixAtomIDs () {\n for (var i = 0; i < atomIndex.length; i++) {\n atomIndex[ i ] = indexList[ atomIndex[ i ] ]\n }\n }\n\n function getVolume (probeRadius: number, scaleFactor: number, setAtomID: boolean) {\n // Basic steps are:\n // 1) Initialize\n // 2) Project points\n // 3) Project torii\n\n console.time('AVSurface.getVolume')\n\n console.time('AVSurface.init')\n init(probeRadius, scaleFactor, setAtomID)\n console.timeEnd('AVSurface.init')\n\n console.time('AVSurface.projectPoints')\n projectPoints()\n console.timeEnd('AVSurface.projectPoints')\n\n console.time('AVSurface.projectTorii')\n projectTorii()\n console.timeEnd('AVSurface.projectTorii')\n fixNegatives()\n fixAtomIDs()\n\n console.timeEnd('AVSurface.getVolume')\n }\n\n this.getSurface = function (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean, smooth: number, contour: boolean) {\n // type and cutoff left in for compatibility with EDTSurface.getSurface\n // function signature\n\n getVolume(probeRadius, scaleFactor, setAtomID)\n\n var volsurf = new (VolumeSurface as any)(\n grid, dim[ 2 ], dim[ 1 ], dim[ 0 ], atomIndex\n ) as VolumeSurface\n\n return volsurf.getSurface!(probeRadius, false, undefined, matrix, contour)\n }\n}\nObject.assign(AVSurface, {__deps: [\n getSurfaceGrid, VolumeSurface, uniformArray, computeBoundingBox,\n v3multiplyScalar, v3cross, v3normalize,\n makeAVHash,\n defaults\n]})\n\nexport { AVSurface, makeAVHash }\n","/**\n * @file Molecular Surface\n * @author Alexander Rose \n * @private\n */\n\nimport { WorkerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Worker from '../worker/worker'\nimport EDTSurface from './edt-surface'\nimport { AVSurface } from './av-surface'\nimport Surface, { SurfaceData } from './surface'\nimport { Structure } from '../ngl';\nimport { AtomData, RadiusParams } from '../structure/structure-data';\n\nWorkerRegistry.add('molsurf', function func (e: any, callback: (data: any, buffers: any[])=> void) {\n const a = e.data.args\n const p = e.data.params\n if (a && p) {\n const SurfClass = (p.type === 'av') ? AVSurface : EDTSurface\n const surf = new (SurfClass as any)(a.coordList, a.radiusList, a.indexList) as AVSurface|EDTSurface\n const sd = surf.getSurface(\n p.type, p.probeRadius, p.scaleFactor, p.cutoff, true, p.smooth, p.contour\n ) as SurfaceData\n const transferList = [ sd.position.buffer, sd.index!.buffer ]\n if (sd.normal) transferList.push(sd.normal.buffer)\n if (sd.atomindex) transferList.push(sd.atomindex.buffer)\n const data = {\n sd: sd,\n p: p\n }\n callback(data, transferList)\n }\n}, [ EDTSurface, AVSurface ])\n\n/**\n * Molecular surface parameter object.\n * @typedef {Object} MolecularSurfaceParameters - stage parameters\n * @property {String} type - \"av\" or \"edt\"\n * @property {Number} probeRadius - probe radius\n * @property {Number} scaleFactor - higher for better quality\n * @property {Integer} smooth - number of smoothing cycles to apply\n * @property {String} name - name for created surface\n */\nexport interface MolecularSurfaceParameters {\n type: 'av'|'edt'\n probeRadius: number\n scaleFactor: number\n smooth: number\n name: string\n cutoff: number\n contour: boolean,\n radiusParams: RadiusParams\n}\n/**\n * Create Molecular surfaces\n */\nclass MolecularSurface {\n structure: Structure\n worker: Worker|undefined\n\n constructor (structure: Structure) {\n this.structure = structure\n }\n\n _getAtomData (params: Partial): AtomData {\n return this.structure.getAtomData({\n what: { position: true, radius: true, index: true },\n radiusParams: defaults(params.radiusParams, {\n type: 'vdw', scale: 1.0\n })\n })\n }\n\n _makeSurface (sd: SurfaceData, p: Partial) {\n var surface = new Surface(p.name!, '', sd)\n\n surface.info.type = p.type\n surface.info.probeRadius = p.probeRadius\n surface.info.scaleFactor = p.scaleFactor\n surface.info.smooth = p.smooth\n surface.info.cutoff = p.cutoff\n\n return surface\n }\n\n /**\n * Get molecular surface\n * @param {MolecularSurfaceParameters} params - parameters for surface creation\n * @return {Surface} the surface\n */\n getSurface (params: Partial) {\n const p = params || {}\n\n const atomData = this._getAtomData(params)\n const coordList = atomData.position\n const radiusList = atomData.radius\n const indexList = atomData.index\n\n const SurfClass = (p.type === 'av') ? AVSurface : EDTSurface\n const surf = new (SurfClass as any)(coordList, radiusList, indexList) as AVSurface|EDTSurface\n const sd = surf.getSurface(\n p.type!, p.probeRadius!, p.scaleFactor!, p.cutoff!, true, p.smooth!, p.contour!\n )\n\n return this._makeSurface(sd, p)\n }\n\n /**\n * Get molecular surface asynchronous\n * @param {MolecularSurfaceParameters} params - parameters for surface creation\n * @param {function(surface: Surface)} callback - function to be called after surface is created\n * @return {undefined}\n */\n getSurfaceWorker (params: MolecularSurfaceParameters, callback: (s: Surface) => void) {\n const p = Object.assign({}, params)\n\n if (window.hasOwnProperty('Worker')) {\n if (this.worker === undefined) {\n this.worker = new Worker('molsurf')\n }\n\n const atomData = this._getAtomData(params)\n const coordList = atomData.position\n const radiusList = atomData.radius\n const indexList = atomData.index\n\n const msg = {\n args: {\n coordList: coordList,\n radiusList: radiusList,\n indexList: indexList\n },\n params: p\n }\n\n const transferList = [\n coordList!.buffer, radiusList!.buffer, indexList!.buffer\n ]\n\n this.worker.post(msg, transferList,\n\n (e: any) => {\n callback(this._makeSurface(e.data.sd, p))\n },\n\n (e: string) => {\n console.warn(\n 'MolecularSurface.getSurfaceWorker error - trying without worker', e\n )\n this.worker!.terminate()\n this.worker = undefined\n const surface = this.getSurface(p)\n callback(surface)\n }\n\n )\n } else {\n const surface = this.getSurface(p)\n callback(surface)\n }\n }\n\n /**\n * Cleanup\n * @return {undefined}\n */\n dispose () {\n if (this.worker) this.worker.terminate()\n }\n}\n\nexport default MolecularSurface\n","/**\n * @file Molecular Surface Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport MolecularSurface, { MolecularSurfaceParameters } from '../surface/molecular-surface'\nimport SurfaceBuffer from '../buffer/surface-buffer'\nimport ContourBuffer from '../buffer/contour-buffer'\nimport DoubleSidedBuffer from '../buffer/doublesided-buffer'\nimport Selection from '../selection/selection'\nimport Viewer from '../viewer/viewer';\n// @ts-ignore: unused import Volume required for declaration only\nimport { Structure, Vector3, Volume } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport { SurfaceDataFields } from './surface-representation';\nimport Surface, {SurfaceData} from '../surface/surface';\n\nexport interface MolecularSurfaceRepresentationParameters extends StructureRepresentationParameters {\n surfaceType: 'vws'|'sas'|'ms'|'ses'|'av'\n probeRadius: number\n smooth: number\n scaleFactor: number\n cutoff: number\n contour: boolean\n background: boolean\n opaqueBack: boolean\n filterSele: string\n colorVolume: any\n useWorker: boolean\n}\n\nexport interface MolecularSurfaceInfo {\n molsurf?: MolecularSurface\n sele?: string\n surface?: Surface\n}\n\n/**\n * Molecular Surface Representation\n */\nclass MolecularSurfaceRepresentation extends StructureRepresentation {\n protected surfaceType: 'vws'|'sas'|'ms'|'ses'|'av'\n protected probeRadius: number\n protected smooth: number\n protected scaleFactor: number\n protected cutoff: number\n protected contour: boolean\n protected background: boolean\n protected opaqueBack: boolean\n protected filterSele: string\n protected colorVolume: any\n protected useWorker: boolean\n\n protected __infoList: MolecularSurfaceInfo[]\n protected __forceNewMolsurf: boolean\n protected __sele: string\n protected __surfaceParams: string\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'surface'\n\n this.parameters = Object.assign({\n\n surfaceType: {\n type: 'select',\n rebuild: true,\n options: {\n 'vws': 'vws',\n 'sas': 'sas',\n 'ms': 'ms',\n 'ses': 'ses',\n 'av': 'av'\n }\n },\n probeRadius: {\n type: 'number',\n precision: 1,\n max: 20,\n min: 0,\n rebuild: true\n },\n smooth: {\n type: 'integer',\n precision: 1,\n max: 10,\n min: 0,\n rebuild: true\n },\n scaleFactor: {\n type: 'number',\n precision: 1,\n max: 5,\n min: 0,\n rebuild: true\n },\n cutoff: {\n type: 'number',\n precision: 2,\n max: 50,\n min: 0,\n rebuild: true\n },\n contour: {\n type: 'boolean', rebuild: true\n },\n background: {\n type: 'boolean', rebuild: true // FIXME\n },\n opaqueBack: {\n type: 'boolean', buffer: true\n },\n filterSele: {\n type: 'text', rebuild: true\n },\n colorVolume: {\n type: 'hidden'\n },\n useWorker: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n\n radius: null,\n scale: null\n\n })\n\n this.__infoList = []\n\n // TODO find a more direct way\n this.structure.signals.refreshed.add(() => {\n this.__forceNewMolsurf = true\n })\n\n this.toBePrepared = true\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'uniform')\n p.colorValue = defaults(p.colorValue, 0xDDDDDD)\n p.disablePicking = defaults(p.disablePicking, true)\n\n this.surfaceType = defaults(p.surfaceType, 'ms')\n this.probeRadius = defaults(p.probeRadius, 1.4)\n this.smooth = defaults(p.smooth, 2)\n this.scaleFactor = defaults(p.scaleFactor, 2.0)\n this.cutoff = defaults(p.cutoff, 0.0)\n this.contour = defaults(p.contour, false)\n this.background = defaults(p.background, false)\n this.opaqueBack = defaults(p.opaqueBack, true)\n this.filterSele = defaults(p.filterSele, '')\n this.colorVolume = defaults(p.colorVolume, undefined)\n this.useWorker = defaults(p.useWorker, true)\n\n super.init(params)\n }\n\n prepareData (sview: StructureView, i: number, callback: (i: number) => void) {\n let info: MolecularSurfaceInfo = this.__infoList[ i ]\n if (!info) {\n info = {}\n this.__infoList[ i ] = info\n }\n\n if (!info.molsurf || info.sele !== sview.selection.string) {\n if (this.filterSele) {\n const sviewFilter = sview.structure.getView(new Selection(this.filterSele))\n const bbSize = sviewFilter.boundingBox.getSize(new Vector3())\n const maxDim = Math.max(bbSize.x, bbSize.y, bbSize.z)\n const asWithin = sview.getAtomSetWithinPoint(sviewFilter.center, (maxDim / 2) + 6.0)\n sview = sview.getView(\n new Selection(sview.getAtomSetWithinSelection(asWithin, 3).toSeleString())\n )\n if (sview.atomCount === 0) {\n callback(i)\n return\n }\n }\n\n info.sele = sview.selection.string\n info.molsurf = new MolecularSurface(sview)\n\n const p = this.getSurfaceParams()\n const onSurfaceFinish = (surface: Surface) => {\n info.surface = surface\n callback(i)\n }\n\n if (this.useWorker) {\n info.molsurf.getSurfaceWorker(p as MolecularSurfaceParameters, onSurfaceFinish)\n } else {\n onSurfaceFinish(info.molsurf.getSurface(p as {name: string, type: 'av'|'edt' } & MolecularSurfaceRepresentationParameters))\n }\n } else {\n callback(i)\n }\n }\n\n prepare (callback: () => void) {\n if (this.__forceNewMolsurf || this.__sele !== this.selection.string ||\n this.__surfaceParams !== JSON.stringify(this.getSurfaceParams())) {\n this.__infoList.forEach((info: MolecularSurfaceInfo) => {\n if (info && info.molsurf) {\n info.molsurf.dispose()\n }\n })\n this.__infoList.length = 0\n }\n\n if (this.structureView.atomCount === 0) {\n callback()\n return\n }\n\n const after = () => {\n this.__sele = this.selection.string\n this.__surfaceParams = JSON.stringify(this.getSurfaceParams())\n this.__forceNewMolsurf = false\n callback()\n }\n\n const name = this.assembly === 'default' ? this.defaultAssembly : this.assembly\n const assembly = this.structure.biomolDict[ name ]\n\n if (assembly) {\n assembly.partList.forEach((part, i) => {\n const sview = part.getView(this.structureView)\n this.prepareData(sview as StructureView, i, (_i) => {\n if (_i === assembly.partList.length - 1) after()\n })\n })\n } else {\n this.prepareData(this.structureView, 0, after)\n }\n }\n\n createData (sview: StructureView, i: number) {\n const info = this.__infoList[ i ]\n const surface = info.surface\n\n if (!surface) {\n // Surface creation bailed (no surface generated for this sview)\n return\n }\n\n const surfaceData = {\n position: surface!.getPosition(),\n color: surface!.getColor(this.getColorParams()),\n index: surface!.getFilteredIndex(this.filterSele, sview)\n }\n\n const bufferList = []\n\n if (surface.contour) {\n const contourBuffer = new ContourBuffer(\n surfaceData,\n this.getBufferParams({\n wireframe: false\n })\n )\n\n bufferList.push(contourBuffer)\n } else {\n Object.assign(surfaceData, {\n normal: surface.getNormal(),\n picking: surface.getPicking(sview.getStructure())\n })\n\n const surfaceBuffer = new SurfaceBuffer(\n surfaceData,\n this.getBufferParams({\n background: this.background,\n opaqueBack: this.opaqueBack,\n dullInterior: false\n })\n )\n\n if (this.getBufferParams().side == 'double') {\n const doubleSidedBuffer = new DoubleSidedBuffer(surfaceBuffer)\n bufferList.push(doubleSidedBuffer)\n }\n else {\n bufferList.push(surfaceBuffer)\n }\n }\n\n return { bufferList, info } as StructureRepresentationData\n }\n\n updateData (what: SurfaceDataFields, data: StructureRepresentationData) {\n const surfaceData: Partial = {}\n\n if (what.position || what.radius) {\n this.__forceNewMolsurf = true\n this.build()\n return\n }\n\n if (what.color) {\n surfaceData.color = data.info.surface.getColor(this.getColorParams())\n }\n\n if (what.index) {\n surfaceData.index = data.info.surface.getFilteredIndex(this.filterSele, data.sview)\n }\n\n data.bufferList[ 0 ].setAttributes(surfaceData)\n }\n\n setParameters (params: Partial, what: Partial = {}, rebuild?: boolean) {\n if (params && params.filterSele) {\n what.index = true\n }\n\n if (params && params.colorVolume !== undefined) {\n what.color = true\n }\n\n // forbid setting wireframe to true when contour is true\n if (params && params.wireframe && (\n params.contour || (params.contour === undefined && this.contour)\n )\n ) {\n params.wireframe = false\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n\n getSurfaceParams (params: Partial = {}) {\n const p = Object.assign({\n type: this.surfaceType as string,\n probeRadius: this.probeRadius as number,\n scaleFactor: this.scaleFactor as number,\n smooth: this.smooth && !this.contour,\n cutoff: this.cutoff as number,\n contour: this.contour as boolean,\n useWorker: this.useWorker as boolean,\n radiusParams: this.getRadiusParams()\n }, params)\n\n return p\n }\n\n getColorParams () {\n const p = super.getColorParams()\n\n p.volume = this.colorVolume\n\n return p\n }\n\n getAtomRadius () {\n return 0\n }\n\n clear () {\n super.clear()\n }\n\n dispose () {\n this.__infoList.forEach((info: MolecularSurfaceInfo) => {\n if (info && info.molsurf) {\n info.molsurf.dispose()\n }\n })\n this.__infoList.length = 0\n\n super.dispose()\n }\n}\n\nRepresentationRegistry.add('surface', MolecularSurfaceRepresentation)\n\nexport default MolecularSurfaceRepresentation\n","/**\n * @file Point Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport PointBuffer from '../buffer/point-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { AtomDataFields } from '../structure/structure-data';\n\nexport interface PointRepresentationParameters extends StructureRepresentationParameters {\n pointSize: number\n sizeAttenuation: boolean\n sortParticles: boolean\n useTexture: boolean\n alphaTest: number\n forceTransparent: boolean\n edgeBleach: number\n}\n\n/**\n * Point Representation\n */\nclass PointRepresentation extends StructureRepresentation {\n protected pointSize: number\n protected sizeAttenuation: boolean\n protected sortParticles: boolean\n protected useTexture: boolean\n protected alphaTest: number\n protected forceTransparent: boolean\n protected edgeBleach: number\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'point'\n\n this.parameters = Object.assign({\n\n pointSize: {\n type: 'number', precision: 1, max: 100, min: 0, buffer: true\n },\n sizeAttenuation: {\n type: 'boolean', buffer: true\n },\n sortParticles: {\n type: 'boolean', rebuild: true\n },\n useTexture: {\n type: 'boolean', buffer: true\n },\n alphaTest: {\n type: 'range', step: 0.001, max: 1, min: 0, buffer: true\n },\n forceTransparent: {\n type: 'boolean', buffer: true\n },\n edgeBleach: {\n type: 'range', step: 0.001, max: 1, min: 0, buffer: true\n }\n\n }, this.parameters, {\n\n flatShaded: null,\n wireframe: null,\n linewidth: null,\n side: null,\n\n roughness: null,\n metalness: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n\n this.pointSize = defaults(p.pointSize, 1)\n this.sizeAttenuation = defaults(p.sizeAttenuation, true)\n this.sortParticles = defaults(p.sortParticles, false)\n this.useTexture = defaults(p.useTexture, false)\n this.alphaTest = defaults(p.alphaTest, 0.5)\n this.forceTransparent = defaults(p.forceTransparent, false)\n this.edgeBleach = defaults(p.edgeBleach, 0.0)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n var what = { position: true, color: true, picking: true }\n var atomData = sview.getAtomData(this.getAtomParams(what))\n\n var pointBuffer = new PointBuffer(\n atomData,\n this.getBufferParams({\n pointSize: this.pointSize,\n sizeAttenuation: this.sizeAttenuation,\n sortParticles: this.sortParticles,\n useTexture: this.useTexture,\n alphaTest: this.alphaTest,\n forceTransparent: this.forceTransparent,\n edgeBleach: this.edgeBleach\n })\n )\n\n return {\n bufferList: [ pointBuffer ]\n }\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n var atomData = data.sview!.getAtomData(this.getAtomParams(what))\n var pointData = {}\n\n if (!what || what.position) {\n Object.assign(pointData, {position: atomData.position})\n }\n\n if (!what || what.color) {\n Object.assign(pointData, {color: atomData.color})\n }\n\n data.bufferList[ 0 ].setAttributes(pointData)\n }\n\n getAtomRadius () {\n return 0.1\n }\n}\n\nRepresentationRegistry.add('point', PointRepresentation)\n\nexport default PointRepresentation\n","/**\n * @file Ribbon Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport '../shader/Ribbon.vert'\n\nimport { getUintArray } from '../utils'\nimport { serialArray } from '../math/array-utils'\nimport MeshBuffer from './mesh-buffer'\nimport { BufferParameters, BufferData } from './buffer'\nimport {Log} from \"../globals\";\n\nconst quadIndices = new Uint16Array([\n 0, 1, 2,\n 1, 3, 2\n])\n\nexport interface RibbonBufferData extends BufferData {\n normal: Float32Array\n dir: Float32Array\n size: Float32Array\n}\n\nfunction getSize(data: RibbonBufferData){\n const n = (data.position!.length / 3) - 1\n const n4 = n * 4\n const x = n4 * 3\n return x\n}\n\n/**\n * Ribbon buffer. Draws a thin ribbon.\n */\nclass RibbonBuffer extends MeshBuffer {\n vertexShader = 'Ribbon.vert'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.normal - normals\n * @param {Float32Array} data.dir - binormals\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.size - sizes\n * @param {Picker} data.picking - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: RibbonBufferData, params: Partial = {}) {\n super({\n position: new Float32Array(getSize(data)),\n color: new Float32Array(getSize(data)),\n index: getUintArray(getSize(data), getSize(data) / 3),\n normal: new Float32Array(getSize(data)),\n picking: data.picking\n }, params)\n\n const n = (data.position!.length / 3) - 1\n const n4 = n * 4\n const x = n4 * 3\n\n this.addAttributes({\n 'dir': { type: 'v3', value: new Float32Array(x) }\n })\n this.addAttributes({\n 'size': { type: 'f', value: new Float32Array(n4) }\n })\n\n data.primitiveId = serialArray(n)\n this.setAttributes(data)\n\n this.makeIndex()\n }\n\n setAttributes (data: Partial = {}) {\n const n4 = this.size\n const n = n4 / 4\n\n const attributes = this.geometry.attributes as any // TODO\n\n let position, normal, size, dir, color, primitiveId\n let aPosition, aNormal, aSize, aDir, aColor, aPrimitiveId\n\n if (data.position) {\n position = data.position\n aPosition = attributes.position.array\n attributes.position.needsUpdate = true\n }\n\n if (data.normal) {\n normal = data.normal\n aNormal = attributes.normal.array\n attributes.normal.needsUpdate = true\n }\n\n if (data.size) {\n size = data.size\n aSize = attributes.size.array\n attributes.size.needsUpdate = true\n }\n\n if (data.dir) {\n dir = data.dir\n aDir = attributes.dir.array\n attributes.dir.needsUpdate = true\n }\n\n if (data.color) {\n color = data.color\n aColor = attributes.color.array\n attributes.color.needsUpdate = true\n }\n\n if (data.primitiveId) {\n primitiveId = data.primitiveId\n aPrimitiveId = attributes.primitiveId.array\n attributes.primitiveId.needsUpdate = true\n }\n\n let v, i, k, p, l, v3\n let currSize\n let prevSize = size ? size[ 0 ] : null\n\n for (v = 0; v < n; ++v) {\n v3 = v * 3\n k = v * 3 * 4\n l = v * 4\n\n if (position) {\n aPosition[ k ] = aPosition[ k + 3 ] = position[ v3 ]\n aPosition[ k + 1 ] = aPosition[ k + 4 ] = position[ v3 + 1 ]\n aPosition[ k + 2 ] = aPosition[ k + 5 ] = position[ v3 + 2 ]\n\n aPosition[ k + 6 ] = aPosition[ k + 9 ] = position[ v3 + 3 ]\n aPosition[ k + 7 ] = aPosition[ k + 10 ] = position[ v3 + 4 ]\n aPosition[ k + 8 ] = aPosition[ k + 11 ] = position[ v3 + 5 ]\n }\n\n if (normal) {\n aNormal[ k ] = aNormal[ k + 3 ] = -normal[ v3 ]\n aNormal[ k + 1 ] = aNormal[ k + 4 ] = -normal[ v3 + 1 ]\n aNormal[ k + 2 ] = aNormal[ k + 5 ] = -normal[ v3 + 2 ]\n\n aNormal[ k + 6 ] = aNormal[ k + 9 ] = -normal[ v3 + 3 ]\n aNormal[ k + 7 ] = aNormal[ k + 10 ] = -normal[ v3 + 4 ]\n aNormal[ k + 8 ] = aNormal[ k + 11 ] = -normal[ v3 + 5 ]\n }\n\n for (i = 0; i < 4; ++i) {\n p = k + 3 * i\n\n if (color) {\n aColor[ p ] = color[ v3 ]\n aColor[ p + 1 ] = color[ v3 + 1 ]\n aColor[ p + 2 ] = color[ v3 + 2 ]\n }\n\n if (primitiveId) {\n aPrimitiveId[ l + i ] = primitiveId[ v ]\n }\n }\n\n if (size) {\n currSize = size[ v ]\n\n if (prevSize !== size[ v ]) {\n aSize[ l ] = prevSize\n aSize[ l + 1 ] = prevSize\n aSize[ l + 2 ] = currSize\n aSize[ l + 3 ] = currSize\n } else {\n aSize[ l ] = currSize\n aSize[ l + 1 ] = currSize\n aSize[ l + 2 ] = currSize\n aSize[ l + 3 ] = currSize\n }\n\n prevSize = currSize\n }\n\n if (dir) {\n aDir[ k ] = dir[ v3 ]\n aDir[ k + 1 ] = dir[ v3 + 1 ]\n aDir[ k + 2 ] = dir[ v3 + 2 ]\n\n aDir[ k + 3 ] = -dir[ v3 ]\n aDir[ k + 4 ] = -dir[ v3 + 1 ]\n aDir[ k + 5 ] = -dir[ v3 + 2 ]\n\n aDir[ k + 6 ] = dir[ v3 + 3 ]\n aDir[ k + 7 ] = dir[ v3 + 4 ]\n aDir[ k + 8 ] = dir[ v3 + 5 ]\n\n aDir[ k + 9 ] = -dir[ v3 + 3 ]\n aDir[ k + 10 ] = -dir[ v3 + 4 ]\n aDir[ k + 11 ] = -dir[ v3 + 5 ]\n }\n }\n }\n\n makeIndex () {\n const index = this.geometry.getIndex()\n if (!index) { Log.error('Index is null'); return; }\n const meshIndex = index.array as Uint32Array|Uint16Array\n const n = meshIndex.length / 4 / 3\n\n for (let v = 0; v < n; ++v) {\n const ix = v * 6\n const it = v * 4\n\n meshIndex.set(quadIndices, ix)\n for (let s = 0; s < 6; ++s) {\n meshIndex[ ix + s ] += it\n }\n }\n }\n}\n\nexport default RibbonBuffer\n","/**\n * @file Ribbon Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Spline, { SplineParameters } from '../geometry/spline'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport RibbonBuffer from '../buffer/ribbon-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport StructureView from '../structure/structure-view';\nimport Polymer from '../proxy/polymer';\n\nexport interface RibbonRepresentationParameters extends StructureRepresentationParameters {\n subdiv: number\n tension: number\n smoothSheet: boolean\n}\n\n/**\n * Ribbon Representation\n */\nclass RibbonRepresentation extends StructureRepresentation {\n protected subdiv: number\n protected tension: number\n protected smoothSheet: boolean\n \n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'ribbon'\n\n this.parameters = Object.assign({\n\n subdiv: {\n type: 'integer', max: 50, min: 1, rebuild: true\n },\n tension: {\n type: 'number', precision: 1, max: 1.0, min: 0.1\n },\n smoothSheet: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n\n side: null,\n wireframe: null,\n linewidth: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'chainname')\n p.colorScale = defaults(p.colorScale, 'RdYlBu')\n p.radiusType = defaults(p.radiusType, 'sstruc')\n p.radiusScale = defaults(p.radiusScale, 4.0)\n\n if (p.quality === 'low') {\n this.subdiv = 3\n } else if (p.quality === 'medium') {\n this.subdiv = 6\n } else if (p.quality === 'high') {\n this.subdiv = 12\n } else {\n this.subdiv = defaults(p.subdiv, 6)\n }\n\n this.tension = defaults(p.tension, NaN)\n this.smoothSheet = defaults(p.smoothSheet, false)\n\n super.init(p)\n }\n\n getSplineParams (params?: Partial) {\n return Object.assign({\n subdiv: this.subdiv,\n tension: this.tension,\n directional: true,\n smoothSheet: this.smoothSheet\n }, params)\n }\n\n getAtomRadius (atom: AtomProxy) {\n return atom.isTrace() ? super.getAtomRadius(atom) : 0\n }\n\n createData (sview: StructureView) {\n var bufferList: RibbonBuffer[] = []\n var polymerList: Polymer[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4) return\n polymerList.push(polymer)\n\n var spline = new Spline(polymer, this.getSplineParams())\n var subPos = spline.getSubdividedPosition()\n var subOri = spline.getSubdividedOrientation()\n var subCol = spline.getSubdividedColor(this.getColorParams())\n var subPick = spline.getSubdividedPicking()\n var subSize = spline.getSubdividedSize(this.getRadiusParams())\n\n bufferList.push(\n new RibbonBuffer(\n ({\n position: subPos.position,\n normal: subOri.binormal,\n dir: subOri.normal,\n color: subCol.color,\n size: subSize.size,\n picking: subPick.picking\n }),\n this.getBufferParams()\n )\n )\n }, sview.getSelection())\n\n return {\n bufferList: bufferList,\n polymerList: polymerList\n }\n }\n\n updateData (what: {position?: boolean, radius?: boolean, scale?: boolean, color?: boolean}, data: {polymerList: Polymer[], bufferList: RibbonBuffer[]}) {\n what = what || {}\n\n var i = 0\n var n = data.polymerList.length\n\n for (i = 0; i < n; ++i) {\n var bufferData = {}\n var spline = new Spline(data.polymerList[ i ], this.getSplineParams())\n\n if (what.position) {\n var subPos = spline.getSubdividedPosition()\n var subOri = spline.getSubdividedOrientation()\n Object.assign(bufferData, {\n position: subPos.position,\n normal: subOri.binormal,\n dir: subOri.normal\n })\n }\n\n if (what.radius || what.scale) {\n var subSize = spline.getSubdividedSize(this.getRadiusParams())\n Object.assign(bufferData, {size: subSize.size})\n }\n\n if (what.color) {\n var subCol = spline.getSubdividedColor(this.getColorParams())\n Object.assign(bufferData, {color: subCol.color})\n }\n\n data.bufferList[ i ].setAttributes(bufferData)\n }\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n if (params && params.tension) {\n Object.assign(what, {position: true})\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('ribbon', RibbonRepresentation)\n\nexport default RibbonRepresentation\n","/**\n * @file Rocket Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { AtomPicker } from '../utils/picker'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport Helixbundle, { Axis } from '../geometry/helixbundle'\nimport CylinderBuffer from '../buffer/cylinder-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport CylinderImpostorBuffer from '../buffer/cylinderimpostor-buffer';\n\nexport interface RocketRepresentationParameters extends StructureRepresentationParameters {\n localAngle: number\n centerDist: number\n ssBorder: boolean\n radialSegments: number\n openEnded: boolean\n disableImpostor: boolean\n}\n\nexport interface AxisData {\n begin: Float32Array\n end: Float32Array\n size: Float32Array\n color: Float32Array\n picking: AtomPicker\n}\n\n/**\n * Rocket Representation\n */\nclass RocketRepresentation extends StructureRepresentation {\n\n protected localAngle: number\n protected centerDist: number\n protected ssBorder: boolean\n protected radialSegments: number\n protected openEnded: boolean\n protected disableImpostor: boolean\n // protected helixbundleList: Helixbundle[]\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'rocket'\n\n this.parameters = Object.assign({\n\n localAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n centerDist: {\n type: 'number', precision: 1, max: 10, min: 0, rebuild: true\n },\n ssBorder: {\n type: 'boolean', rebuild: true\n },\n radialSegments: true,\n openEnded: true,\n disableImpostor: true\n\n }, this.parameters)\n\n // this.helixbundleList = []\n\n this.init(params)\n }\n\n init (params: Partial) {\n let p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'sstruc')\n p.radiusSize = defaults(p.radiusSize, 1.5)\n p.radiusScale = defaults(p.radiusScale, 1.0)\n p.openEnded = defaults(p.openEnded, false)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.localAngle = defaults(p.localAngle, 30)\n this.centerDist = defaults(p.centerDist, 2.5)\n this.ssBorder = defaults(p.ssBorder, false)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n let length = 0\n const axisList:Axis[] = []\n const helixbundleList:Helixbundle[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4 || polymer.isNucleic()) return\n\n const helixbundle = new Helixbundle(polymer)\n const axis = helixbundle.getAxis(\n this.localAngle, this.centerDist, this.ssBorder,\n this.getColorParams(), this.getRadiusParams()\n )\n\n length += axis.size.length\n axisList.push(axis)\n helixbundleList.push(helixbundle)\n }, sview.getSelection())\n\n const axisData = {\n begin: new Float32Array(length * 3),\n end: new Float32Array(length * 3),\n size: new Float32Array(length),\n color: new Float32Array(length * 3),\n picking: {}\n }\n\n let picking = new Float32Array(length)\n\n let offset = 0\n\n axisList.forEach(function (axis) {\n axisData.begin.set(axis.begin, offset * 3)\n axisData.end.set(axis.end, offset * 3)\n axisData.size.set(axis.size, offset)\n axisData.color.set(axis.color, offset * 3)\n picking.set(axis.picking.array!, offset)\n offset += axis.size.length\n })\n\n if (length) {\n axisData.picking = new AtomPicker(\n picking, sview.getStructure()\n )\n }\n\n const cylinderBuffer = new CylinderBuffer(\n {\n position1: axisData.begin,\n position2: axisData.end,\n color: axisData.color,\n color2: axisData.color,\n radius: axisData.size,\n picking: axisData.picking\n },\n this.getBufferParams({\n openEnded: this.openEnded,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n return {\n bufferList: [ cylinderBuffer as CylinderGeometryBuffer|CylinderImpostorBuffer ],\n axisList: axisList,\n helixbundleList: helixbundleList,\n axisData: axisData\n }\n }\n\n \n updateData (what: any, data: {bufferList: CylinderBuffer[], helixbundleList: Helixbundle[], axisList: Axis[], axisData: AxisData}) {\n what = what || {}\n\n if (what.position) {\n this.build()\n return\n }\n\n var cylinderData = {}\n\n if (what.color || what.radius) {\n var offset = 0\n\n data.helixbundleList.forEach((helixbundle) => {\n var axis = helixbundle.getAxis(\n this.localAngle, this.centerDist, this.ssBorder,\n this.getColorParams(), this.getRadiusParams()\n )\n if (what.color) {\n data.axisData.color.set(axis.color, offset * 3)\n }\n if (what.radius || what.scale) {\n data.axisData.size.set(axis.size, offset)\n }\n offset += axis.size.length\n })\n\n if (what.color) {\n Object.assign(cylinderData, {\n color: data.axisData.color,\n color2: data.axisData.color\n })\n }\n\n if (what.radius || what.scale) {\n Object.assign(cylinderData, {\n radius: data.axisData.size\n })\n }\n }\n\n (data.bufferList[ 0 ] as CylinderGeometryBuffer).setAttributes(cylinderData)\n }\n}\n\nRepresentationRegistry.add('rocket', RocketRepresentation)\n\nexport default RocketRepresentation\n","/**\n * @file Rope Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport CartoonRepresentation, { CartoonRepresentationParameters } from './cartoon-representation'\nimport Helixorient from '../geometry/helixorient'\nimport Spline from '../geometry/spline'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport Polymer from '../proxy/polymer';\n\n/**\n * Rope Representation\n */\nclass RopeRepresentation extends CartoonRepresentation {\n protected smooth: number\n \n constructor (structure: Structure, viewer: Viewer, params: Partial&{smooth: number}) {\n super(structure, viewer, params)\n\n this.type = 'rope'\n\n this.parameters = Object.assign({\n\n smooth: {\n type: 'integer', max: 15, min: 0, rebuild: true\n }\n\n }, this.parameters, {\n aspectRatio: null,\n smoothSheet: null\n })\n }\n\n init (params: Partial) {\n var p = params || {}\n p.aspectRatio = 1.0\n p.tension = defaults(p.tension, 0.5)\n p.radiusScale = defaults(p.radiusScale, 5.0)\n p.smoothSheet = false\n\n this.smooth = defaults(p.smooth, 2)\n\n super.init(p)\n }\n\n getSpline (polymer: Polymer) {\n var helixorient = new Helixorient(polymer)\n\n return new Spline(polymer, this.getSplineParams({\n directional: false,\n positionIterator: helixorient.getCenterIterator(this.smooth)\n }))\n }\n}\n\nRepresentationRegistry.add('rope', RopeRepresentation)\n\nexport default RopeRepresentation\n","/**\n * @file Spacefill Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { RepresentationRegistry } from '../globals'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\nimport { AtomDataFields } from '../structure/structure-data';\nimport SphereImpostorBuffer from '../buffer/sphereimpostor-buffer';\n\n/**\n * Spacefill Representation\n */\nclass SpacefillRepresentation extends StructureRepresentation {\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'spacefill'\n\n this.parameters = Object.assign({\n sphereDetail: true,\n disableImpostor: true\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n var sphereBuffer = new SphereBuffer(\n (sview.getAtomData(this.getAtomParams()) as SphereBufferData),\n (this.getBufferParams({\n sphereDetail: this.sphereDetail,\n dullInterior: true,\n disableImpostor: this.disableImpostor\n }) as SphereBufferParameters)\n )\n\n return {\n bufferList: [ sphereBuffer as SphereGeometryBuffer|SphereImpostorBuffer ]\n }\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n var atomData = data.sview!.getAtomData(this.getAtomParams(what))\n var sphereData: Partial = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {position: atomData.position})\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {color: atomData.color})\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {radius: atomData.radius})\n }\n\n data.bufferList[ 0 ].setAttributes(sphereData)\n }\n}\n\nRepresentationRegistry.add('spacefill', SpacefillRepresentation)\n\nexport default SpacefillRepresentation\n","/**\n * @file Trace Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport '../shader/Line.vert'\nimport '../shader/Line.frag'\n\nimport { Log } from '../globals'\nimport Buffer, { BufferParameters, BufferData } from './buffer'\n\nfunction getSize(data: BufferData){\n const n = data.position!.length / 3\n const n1 = n - 1\n return n1 * 3 * 2\n}\n\n/**\n * Trace buffer. Draws a series of lines.\n */\nclass TraceBuffer extends Buffer {\n isLine = true\n vertexShader = 'Line.vert'\n fragmentShader = 'Line.frag'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: BufferData, params: Partial = {}) {\n super({\n position: new Float32Array(getSize(data)),\n color: new Float32Array(getSize(data))\n }, params)\n\n this.setAttributes(data)\n }\n\n setAttributes (data: Partial) {\n let position, color\n let linePosition, lineColor\n\n const attributes = this.geometry.attributes as any // TODO\n\n if (data.position) {\n position = data.position\n linePosition = attributes.position.array\n attributes.position.needsUpdate = true\n }\n\n if (data.color) {\n color = data.color\n lineColor = attributes.color.array\n attributes.color.needsUpdate = true\n }\n\n if (!position && !color) {\n Log.warn('TraceBuffer.prototype.setAttributes no data')\n return\n }\n\n let v, v2\n const n = this.size\n const n1 = n - 1\n\n for (let i = 0; i < n1; ++i) {\n v = 3 * i\n v2 = 3 * i * 2\n\n if (position) {\n linePosition[ v2 ] = position[ v ]\n linePosition[ v2 + 1 ] = position[ v + 1 ]\n linePosition[ v2 + 2 ] = position[ v + 2 ]\n\n linePosition[ v2 + 3 ] = position[ v + 3 ]\n linePosition[ v2 + 4 ] = position[ v + 4 ]\n linePosition[ v2 + 5 ] = position[ v + 5 ]\n }\n\n if (color) {\n lineColor[ v2 ] = color[ v ]\n lineColor[ v2 + 1 ] = color[ v + 1 ]\n lineColor[ v2 + 2 ] = color[ v + 2 ]\n\n lineColor[ v2 + 3 ] = color[ v + 3 ]\n lineColor[ v2 + 4 ] = color[ v + 4 ]\n lineColor[ v2 + 5 ] = color[ v + 5 ]\n }\n }\n }\n}\n\nexport default TraceBuffer\n","/**\n * @file Trace Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Spline from '../geometry/spline'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport TraceBuffer from '../buffer/trace-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport StructureView from '../structure/structure-view';\nimport Polymer from '../proxy/polymer';\n\nexport interface TraceRepresentationParameters extends StructureRepresentationParameters {\n subdiv: number\n tension: number\n smoothSheet: boolean\n}\n/**\n * Trace Representation\n */\nclass TraceRepresentation extends StructureRepresentation {\n protected subdiv: number\n protected tension: number\n protected smoothSheet: boolean\n \n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'trace'\n\n this.parameters = Object.assign({\n\n subdiv: {\n type: 'integer', max: 50, min: 1, rebuild: true\n },\n tension: {\n type: 'number', precision: 1, max: 1.0, min: 0.1\n },\n smoothSheet: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n\n flatShaded: null,\n side: null,\n wireframe: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'chainname')\n p.colorScale = defaults(p.colorScale, 'RdYlBu')\n\n if (p.quality === 'low') {\n this.subdiv = 3\n } else if (p.quality === 'medium') {\n this.subdiv = 6\n } else if (p.quality === 'high') {\n this.subdiv = 12\n } else {\n this.subdiv = defaults(p.subdiv, 6)\n }\n\n this.tension = defaults(p.tension, NaN)\n this.smoothSheet = defaults(p.smoothSheet, false)\n\n super.init(p)\n }\n\n getSplineParams (params?: {[k:string]: any}) {\n return Object.assign({\n subdiv: this.subdiv,\n tension: this.tension,\n directional: false,\n smoothSheet: this.smoothSheet\n }, params)\n }\n\n getAtomRadius (atom: AtomProxy) {\n return atom.isTrace() ? 0.1 : 0\n }\n\n createData (sview: StructureView) {\n var bufferList: TraceBuffer[] = []\n var polymerList: Polymer[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4) return\n polymerList.push(polymer)\n\n var spline = new Spline(polymer, this.getSplineParams())\n var subPos = spline.getSubdividedPosition()\n var subCol = spline.getSubdividedColor(this.getColorParams())\n\n bufferList.push(\n new TraceBuffer(\n Object.assign({}, subPos, subCol),\n this.getBufferParams()\n )\n )\n }, sview.getSelection())\n\n return {\n bufferList: bufferList,\n polymerList: polymerList\n }\n }\n\n updateData (what: any, data: StructureRepresentationData) {\n what = what || {}\n\n var i = 0\n var n = data.polymerList!.length\n\n for (i = 0; i < n; ++i) {\n var bufferData = {}\n var spline = new Spline(data.polymerList![ i ], this.getSplineParams())\n\n if (what.position) {\n var subPos = spline.getSubdividedPosition()\n Object.assign(bufferData, { position: subPos.position })\n }\n\n if (what.color) {\n var subCol = spline.getSubdividedColor(this.getColorParams())\n Object.assign(bufferData, { color: subCol.color })\n }\n\n data.bufferList[ i ].setAttributes(bufferData)\n }\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n if (params && params.tension) {\n Object.assign(what, {position: true})\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('trace', TraceRepresentation)\n\nexport default TraceRepresentation\n","/**\n * @file Tube Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport CartoonRepresentation, {CartoonRepresentationParameters} from './cartoon-representation'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\n\n/**\n * Tube Representation\n */\nclass TubeRepresentation extends CartoonRepresentation {\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'tube'\n\n this.parameters = Object.assign(\n {}, this.parameters, { aspectRatio: null }\n )\n }\n\n init (params: Partial) {\n var p = params || {}\n p.aspectRatio = 1.0\n p.radiusScale = defaults(p.radiusScale, 2.0)\n\n if (p.quality === 'low') {\n this.radialSegments = 5\n }\n\n super.init(p)\n }\n\n getSplineParams (/* params */) {\n return super.getSplineParams({\n directional: false\n })\n }\n}\n\nRepresentationRegistry.add('tube', TubeRepresentation)\n\nexport default TubeRepresentation\n","/**\n * @file Unitcell Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport CylinderBuffer, { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport { AtomDataFields } from '../structure/structure-data';\nimport StructureView from '../structure/structure-view';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\n// @ts-ignore: unused import UnitcellPicker required for declaration only\nimport { UnitcellPicker } from '../utils/picker';\n\nexport interface UnitcellRepresentationParameters extends StructureRepresentationParameters {\n radiusSize: number\n sphereDetail: number\n radialSegments: number\n disableImpostor: boolean\n}\n\n/**\n * Unitcell Representation\n */\nclass UnitcellRepresentation extends StructureRepresentation {\n sphereBuffer: SphereBuffer\n cylinderBuffer: CylinderBuffer\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'unitcell'\n\n this.parameters = Object.assign({\n\n radiusSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n sphereDetail: true,\n radialSegments: true,\n disableImpostor: true\n\n }, this.parameters, {\n assembly: null\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n\n let defaultRadius = 0.5\n if (this.structure.unitcell) {\n defaultRadius = Math.cbrt(this.structure.unitcell.volume) / 200\n }\n\n p.radiusSize = defaults(p.radiusSize, defaultRadius)\n p.colorValue = defaults(p.colorValue, 'orange')\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n super.init(p)\n }\n\n getUnitcellData (structure: Structure) {\n return structure.unitcell!.getData(structure)\n }\n\n create () {\n const structure = this.structureView.getStructure()\n if (!structure.unitcell) return\n const unitcellData = this.getUnitcellData(structure)\n\n this.sphereBuffer = new SphereBuffer(\n unitcellData.vertex as SphereBufferData,\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters\n )\n\n this.cylinderBuffer = new CylinderBuffer(\n unitcellData.edge as CylinderBufferData,\n this.getBufferParams({\n openEnded: true,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n this.dataList.push({\n sview: this.structureView,\n bufferList: [ this.sphereBuffer as SphereGeometryBuffer, this.cylinderBuffer as CylinderGeometryBuffer ]\n })\n }\n\n createData (sview: StructureView): undefined {\n return\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n const structure = data.sview!.getStructure()\n if (!structure.unitcell) return\n const unitcellData = this.getUnitcellData(structure)\n const sphereData: Partial = {}\n const cylinderData: Partial = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {position: unitcellData.vertex.position})\n Object.assign(cylinderData, {\n position1: unitcellData.edge.position1,\n position2: unitcellData.edge.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {color: unitcellData.vertex.color})\n Object.assign(cylinderData, {\n color: unitcellData.edge.color,\n color2: unitcellData.edge.color2\n })\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {radius: unitcellData.vertex.radius})\n Object.assign(cylinderData, {radius: unitcellData.edge.radius})\n }\n\n (this.sphereBuffer as SphereGeometryBuffer).setAttributes(sphereData);\n (this.cylinderBuffer as CylinderGeometryBuffer).setAttributes(cylinderData)\n }\n}\n\nRepresentationRegistry.add('unitcell', UnitcellRepresentation)\n\nexport default UnitcellRepresentation\n","/**\n * @file Validation Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport CylinderBuffer from '../buffer/cylinder-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport CylinderImpostorBuffer from '../buffer/cylinderimpostor-buffer';\n\n/**\n * Validation representation\n */\nclass ValidationRepresentation extends StructureRepresentation {\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'validation'\n\n this.parameters = Object.assign({\n\n }, this.parameters, {\n radiusType: null,\n radiusSize: null,\n radiusScale: null\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorValue = defaults(p.colorValue, '#f0027f')\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n if (!sview.validation) return\n\n const clashData = sview.validation.getClashData({\n structure: sview,\n color: this.colorValue\n })\n\n const cylinderBuffer = new CylinderBuffer(\n clashData, this.getBufferParams({ openEnded: false })\n )\n\n return {\n bufferList: [ cylinderBuffer as CylinderGeometryBuffer|CylinderImpostorBuffer ]\n }\n }\n}\n\nRepresentationRegistry.add('validation', ValidationRepresentation)\n\nexport default ValidationRepresentation\n","/**\n * @file Cone Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3, ConeBufferGeometry } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { calculateCenterArray } from '../math/array-utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferDefaultParameters } from './buffer'\n\nconst scale = new Vector3()\nconst eye = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3(0, 1, 0)\n\nfunction getGeo (params: Partial = {}) {\n const geo = new ConeBufferGeometry(\n 1, // radius\n 1, // height\n defaults(params.radialSegments, 60), // radialSegments\n 1, // heightSegments\n defaults(params.openEnded, false) // openEnded\n )\n geo.applyMatrix4(new Matrix4().makeRotationX(-Math.PI / 2))\n\n return geo\n}\n\nexport interface ConeBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n radius: Float32Array\n}\n\nexport const ConeBufferDefaultParameters = Object.assign({\n radialSegments: 60,\n openEnded: false\n}, BufferDefaultParameters)\nexport type ConeBufferParameters = typeof ConeBufferDefaultParameters\n\n\n/**\n * Cone geometry buffer.\n *\n * @example\n * var coneBuffer = new ConeBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass ConeBuffer extends GeometryBuffer {\n updateNormals = true\n\n get defaultParameters() { return ConeBufferDefaultParameters }\n parameters: ConeBufferParameters\n\n _position: Float32Array\n _position1: Float32Array\n _position2: Float32Array\n _radius: Float32Array\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n */\n constructor (data: ConeBufferData, params: Partial = {}) {\n super({\n position: new Float32Array(data.position1.length),\n color: data.color,\n picking: data.picking\n }, params, getGeo(params))\n\n this._position = new Float32Array(data.position1.length)\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n eye.fromArray(this._position1 as any, i3)\n target.fromArray(this._position2 as any, i3)\n matrix.lookAt(eye, target, up)\n\n const r = this._radius[ i ]\n scale.set(r, r, eye.distanceTo(target))\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.position1 && data.position2) {\n calculateCenterArray(data.position1, data.position2, this._position)\n this._position1 = data.position1\n this._position2 = data.position2\n data.position = this._position\n }\n if (data.radius) this._radius = data.radius\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('cone', ConeBuffer)\n\nexport default ConeBuffer\n","/**\n * @file Geometry Group\n * @author Alexander Rose \n * @private\n */\n\nimport { Box3, BufferGeometry } from 'three'\n\nclass GeometryGroup {\n geometryList: BufferGeometry[]\n boundingBox: Box3\n\n constructor (geometryList: BufferGeometry[] = []) {\n this.geometryList = geometryList\n }\n\n computeBoundingBox () {\n if (!this.boundingBox) {\n this.boundingBox = new Box3()\n } else {\n this.boundingBox.empty()\n }\n\n this.geometryList.forEach(geo => {\n if (!geo.boundingBox) geo.computeBoundingBox()\n this.boundingBox.union(geo.boundingBox as Box3)\n })\n }\n}\n\nexport default GeometryGroup\n","/**\n * @file Arrow Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3, Group } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport { createParams, defaults } from '../utils'\nimport { Picker } from '../utils/picker'\nimport Buffer from './buffer'\nimport CylinderBuffer, { CylinderBufferData } from './cylinder-buffer'\nimport CylinderGeometryBuffer from './cylindergeometry-buffer'\nimport ConeBuffer, { ConeBufferData } from './cone-buffer'\nimport GeometryGroup from '../viewer/geometry-group'\nimport { BufferData, BufferDefaultParameters } from './buffer'\n\nexport interface ArrowBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n radius: Float32Array\n}\n\nexport const ArrowBufferDefaultParameters = Object.assign({\n aspectRatio: 1.5,\n radialSegments: 50,\n openEnded: false,\n disableImpostor: false\n}, BufferDefaultParameters)\nexport type ArrowBufferParameters = typeof ArrowBufferDefaultParameters\n\n/**\n * Arrow buffer. Draws arrows made from a cylinder and a cone.\n * @implements {Buffer}\n *\n * @example\n * var arrowBuffer = new ArrowBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 10, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass ArrowBuffer {\n parameters: ArrowBufferParameters\n get defaultParameters() { return ArrowBufferDefaultParameters }\n\n cylinderBuffer: CylinderGeometryBuffer\n coneBuffer: ConeBuffer\n\n splitPosition: Float32Array\n cylinderRadius: Float32Array\n\n geometry: GeometryGroup\n picking?: Picker\n\n group = new Group()\n wireframeGroup = new Group()\n pickingGroup = new Group()\n\n visible = true\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n */\n constructor (data: ArrowBufferData, params: Partial = {}) {\n this.parameters = createParams(params, this.defaultParameters)\n\n this.splitPosition = new Float32Array(data.position1.length)\n this.cylinderRadius = new Float32Array(data.radius.length)\n\n const attr = this.makeAttributes(data)\n const bufferParams = {\n radialSegments: this.parameters.radialSegments,\n openEnded: this.parameters.openEnded,\n disableImpostor: this.parameters.disableImpostor\n }\n\n this.cylinderBuffer = new CylinderBuffer(\n attr.cylinder as CylinderBufferData, bufferParams\n ) as CylinderGeometryBuffer\n this.coneBuffer = new ConeBuffer(\n attr.cone as ConeBufferData, bufferParams\n )\n\n this.geometry = new GeometryGroup([\n this.cylinderBuffer.geometry,\n this.coneBuffer.geometry\n ])\n\n // requires Group objects to be present\n this.matrix = defaults(params.matrix, new Matrix4())\n\n this.picking = data.picking\n }\n\n set matrix (m) {\n Buffer.prototype.setMatrix.call(this, m)\n }\n get matrix () {\n return this.group.matrix.clone()\n }\n\n get pickable () {\n return !!this.picking\n }\n\n makeAttributes (data: Partial = {}) {\n const splitPosition = this.splitPosition\n const cylinderRadius = this.cylinderRadius\n\n const aspectRatio = this.parameters.aspectRatio\n\n let i, il\n const cylinder: Partial = {}\n const cone: Partial = {}\n\n if (data.radius) {\n for (i = 0, il = cylinderRadius.length; i < il; ++i) {\n cylinderRadius[ i ] = data.radius[ i ] / aspectRatio\n }\n cylinder.radius = cylinderRadius\n cone.radius = data.radius\n }\n\n if (data.position1 && data.position2) {\n const vFrom = new Vector3()\n const vTo = new Vector3()\n const vDir = new Vector3()\n const vSplit = new Vector3()\n for (i = 0, il = splitPosition.length; i < il; i += 3) {\n vFrom.fromArray(data.position1 as any, i)\n vTo.fromArray(data.position2 as any, i)\n vDir.subVectors(vFrom, vTo)\n const fullLength = vDir.length()\n const coneLength = cylinderRadius[ i / 3 ] * aspectRatio * 2\n const length = Math.min(fullLength, coneLength)\n vDir.setLength(length)\n vSplit.copy(vTo).add(vDir)\n vSplit.toArray(splitPosition as any, i)\n }\n cylinder.position1 = data.position1\n cylinder.position2 = splitPosition\n cone.position1 = splitPosition\n cone.position2 = data.position2\n }\n\n if (data.color) {\n cylinder.color = data.color\n cylinder.color2 = data.color\n cone.color = data.color\n }\n\n return {\n cylinder: cylinder,\n cone: cone\n }\n }\n\n getMesh () {\n return new Group().add(\n this.cylinderBuffer.getMesh(),\n this.coneBuffer.getMesh()\n )\n }\n\n getWireframeMesh () {\n return new Group().add(\n this.cylinderBuffer.getWireframeMesh(),\n this.coneBuffer.getWireframeMesh()\n )\n }\n\n getPickingMesh () {\n return new Group().add(\n this.cylinderBuffer.getPickingMesh(),\n this.coneBuffer.getPickingMesh()\n )\n }\n\n setAttributes (data: Partial = {}) {\n const attr = this.makeAttributes(data)\n\n this.cylinderBuffer.setAttributes(attr.cylinder)\n this.coneBuffer.setAttributes(attr.cone)\n }\n\n /**\n * Set buffer parameters\n * @param {BufferParameters} params - buffer parameters object\n * @return {undefined}\n */\n setParameters (params: Partial = {}) {\n params = Object.assign({}, params)\n\n if (params && params.matrix !== undefined) {\n this.matrix = params.matrix\n }\n delete params.matrix\n\n if (params && params.wireframe !== undefined) {\n this.parameters.wireframe = params.wireframe\n this.setVisibility(this.visible)\n }\n\n this.cylinderBuffer.setParameters(params)\n this.coneBuffer.setParameters(params)\n }\n\n setVisibility (value: boolean) {\n Buffer.prototype.setVisibility.call(this, value)\n }\n\n dispose () {\n this.cylinderBuffer.dispose()\n this.coneBuffer.dispose()\n }\n}\n\nBufferRegistry.add('arrow', ArrowBuffer)\n\nexport default ArrowBuffer\n","/**\n * @file Box Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { BoxBufferGeometry, Vector3, Matrix4 } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface BoxBufferData extends BufferData {\n heightAxis: Float32Array\n depthAxis: Float32Array\n size: Float32Array\n}\n\n/**\n * Box buffer. Draws boxes.\n *\n * @example\n * var boxBuffer = new BoxBuffer({\n * position: new Float32Array([ 0, 3, 0, -2, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 1, 0, 1, 0 ]),\n * size: new Float32Array([ 2, 1.5 ]),\n * heightAxis: new Float32Array([ 0, 1, 1, 0, 2, 0 ]),\n * depthAxis: new Float32Array([ 1, 0, 1, 0, 0, 2 ])\n * })\n */\nclass BoxBuffer extends GeometryBuffer {\n updateNormals = true\n\n _heightAxis: Float32Array\n _depthAxis: Float32Array\n _size: Float32Array\n\n constructor (data: BoxBufferData, params: Partial = {}) {\n super(data, params, new BoxBufferGeometry(1, 1, 1))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._heightAxis as any, i3)\n up.fromArray(this._depthAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n scale.set(this._size[ i ], up.length(), target.length())\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.size) this._size = data.size\n if (data.heightAxis) this._heightAxis = data.heightAxis\n if (data.depthAxis) this._depthAxis = data.depthAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('box', BoxBuffer)\n\nexport default BoxBuffer\n","/**\n * @file Ellipsoid Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { IcosahedronBufferGeometry, Vector3, Matrix4 } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferDefaultParameters } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface EllipsoidBufferData extends BufferData {\n majorAxis: Float32Array\n minorAxis: Float32Array\n radius: Float32Array\n}\n\nexport const EllipsoidBufferDefaultParameters = Object.assign({\n sphereDetail: 2,\n}, BufferDefaultParameters)\nexport type EllipsoidBufferParameters = typeof EllipsoidBufferDefaultParameters\n\n/**\n * Ellipsoid buffer. Draws ellipsoids.\n *\n * @example\n * var ellipsoidBuffer = new EllipsoidBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ]),\n * majorAxis: new Float32Array([ 1, 1, 0 ]),\n * minorAxis: new Float32Array([ 0.5, 0, 0.5 ]),\n * });\n */\nclass EllipsoidBuffer extends GeometryBuffer {\n updateNormals = true\n\n get defaultParameters() { return EllipsoidBufferDefaultParameters }\n parameters: EllipsoidBufferParameters\n\n _majorAxis: Float32Array\n _minorAxis: Float32Array\n _radius: Float32Array\n\n constructor (data: EllipsoidBufferData, params: Partial = {}) {\n super(data, params, new IcosahedronBufferGeometry(1, defaults(params.sphereDetail, 2)))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._majorAxis as any, i3)\n up.fromArray(this._minorAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n scale.set(this._radius[ i ], up.length(), target.length())\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.radius) this._radius = data.radius\n if (data.majorAxis) this._majorAxis = data.majorAxis\n if (data.minorAxis) this._minorAxis = data.minorAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('ellipsoid', EllipsoidBuffer)\n\nexport default EllipsoidBuffer\n","/**\n * @file Octahedron Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { OctahedronBufferGeometry, Vector3, Matrix4 } from 'three'\nimport { BufferRegistry } from '../globals'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface OctahedronBufferData extends BufferData {\n heightAxis: Float32Array\n depthAxis: Float32Array\n size: Float32Array\n}\n\n/**\n * Octahedron buffer. Draws octahedrons.\n *\n * @example\n * var octahedronBuffer = new OctahedronBuffer({\n * position: new Float32Array([ 0, 3, 0, -2, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 1, 0, 1, 0 ]),\n * size: new Float32Array([ 2, 1.5 ]),\n * heightAxis: new Float32Array([ 0, 1, 1, 0, 2, 0 ]),\n * depthAxis: new Float32Array([ 1, 0, 1, 0, 0, 2 ])\n * })\n */\nclass OctahedronBuffer extends GeometryBuffer {\n updateNormals = true\n\n _heightAxis: Float32Array\n _depthAxis: Float32Array\n _size: Float32Array\n\n constructor (data: OctahedronBufferData, params: Partial = {}) {\n super(data, params, new OctahedronBufferGeometry(1, 0))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._heightAxis as any, i3)\n up.fromArray(this._depthAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n scale.set(this._size[ i ], up.length(), target.length())\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.size) this._size = data.size\n if (data.heightAxis) this._heightAxis = data.heightAxis\n if (data.depthAxis) this._depthAxis = data.depthAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('octahedron', OctahedronBuffer)\n\nexport default OctahedronBuffer\n","/**\n * @file Tetrahedron Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { TetrahedronBufferGeometry, Vector3, Matrix4 } from 'three'\nimport { BufferRegistry } from '../globals'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface TetrahedronBufferData extends BufferData {\n heightAxis: Float32Array\n depthAxis: Float32Array\n size: Float32Array\n}\n\n/**\n * Tetrahedron buffer. Draws tetrahedrons.\n *\n * @example\n * var tetrahedronBuffer = new TetrahedronBuffer({\n * position: new Float32Array([ 0, 3, 0, -2, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 1, 0, 1, 0 ]),\n * size: new Float32Array([ 2, 1.5 ]),\n * heightAxis: new Float32Array([ 0, 1, 1, 0, 2, 0 ]),\n * depthAxis: new Float32Array([ 1, 0, 1, 0, 0, 2 ])\n * })\n */\nclass TetrahedronBuffer extends GeometryBuffer {\n updateNormals = true\n\n _heightAxis: Float32Array\n _depthAxis: Float32Array\n _size: Float32Array\n\n constructor (data: TetrahedronBufferData, params: Partial = {}) {\n super(data, params, new TetrahedronBufferGeometry(1, 0))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._heightAxis as any, i3)\n up.fromArray(this._depthAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n scale.set(this._size[ i ], up.length(), target.length())\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.size) this._size = data.size\n if (data.heightAxis) this._heightAxis = data.heightAxis\n if (data.depthAxis) this._depthAxis = data.depthAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('tetrahedron', TetrahedronBuffer)\n\nexport default TetrahedronBuffer\n","/**\n * @file Tetrahedron Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { TorusBufferGeometry, Vector3, Matrix4 } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferDefaultParameters, BufferData } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface TorusBufferData extends BufferData {\n majorAxis: Float32Array\n minorAxis: Float32Array\n radius: Float32Array\n}\n\nexport const TorusBufferDefaultParameters = Object.assign({\n radiusRatio: 0.2,\n radialSegments: 16,\n tubularSegments: 32\n}, BufferDefaultParameters)\nexport type TorusBufferParameters = typeof TorusBufferDefaultParameters\n\n/**\n * Torus geometry buffer. Draws torii.\n *\n * @example\n * var torusBuffer = new TorusBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ]),\n * majorAxis: new Float32Array([ 1, 1, 0 ]),\n * minorAxis: new Float32Array([ 0.5, 0, 0.5 ]),\n * });\n */\nclass TorusBuffer extends GeometryBuffer {\n updateNormals = true\n\n get defaultParameters() { return TorusBufferDefaultParameters }\n parameters: TorusBufferParameters\n\n _majorAxis: Float32Array\n _minorAxis: Float32Array\n _radius: Float32Array\n\n constructor (data: TorusBufferData, params: Partial = {}) {\n super(data, params, new TorusBufferGeometry(\n 1,\n defaults(params.radiusRatio, 0.2),\n defaults(params.radialSegments, 16),\n defaults(params.tubularSegments, 32)\n ))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._majorAxis as any, i3)\n up.fromArray(this._minorAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n const r = this._radius[ i ]\n scale.set(r, r, r)\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.radius) this._radius = data.radius\n if (data.majorAxis) this._majorAxis = data.majorAxis\n if (data.minorAxis) this._minorAxis = data.minorAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('torus', TorusBuffer)\n\nexport default TorusBuffer\n","/**\n * @file Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log } from '../globals'\nimport { defaults } from '../utils'\nimport Streamer from '../streamer/streamer';\n\nexport interface ParserParameters {\n name: string\n path: string\n}\n\nclass Parser {\n streamer: Streamer\n name: string\n path: string\n [k: string]: any\n \n constructor (streamer: Streamer, params?: Partial) {\n var p = params || {}\n\n this.streamer = streamer\n\n this.name = defaults(p.name, '')\n this.path = defaults(p.path, '')\n }\n\n get type () { return '' }\n get __objName () { return '' }\n get isBinary () { return false }\n get isJson () { return false }\n get isXml () { return false }\n\n parse () {\n return this.streamer.read().then(() => {\n this._beforeParse()\n this._parse()\n this._afterParse()\n return this[ this.__objName ]\n })\n }\n\n _parse () {}\n\n _beforeParse () {}\n\n _afterParse () {\n if (Debug) Log.log(this[ this.__objName ])\n }\n}\n\nexport default Parser\n","/**\n * @file Structure Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport Parser, { ParserParameters } from './parser'\nimport Structure from '../structure/structure'\nimport StructureBuilder from '../structure/structure-builder'\nimport Streamer from '../streamer/streamer';\n\nexport interface StructureParserParameters extends ParserParameters {\n firstModelOnly: boolean\n asTrajectory: boolean\n cAlphaOnly: boolean\n}\nclass StructureParser extends Parser {\n\n structureBuilder: StructureBuilder\n\n constructor (streamer: Streamer, params?: Partial) {\n var p = params || {}\n\n super(streamer, p)\n\n this.firstModelOnly = defaults(p.firstModelOnly, false)\n this.asTrajectory = defaults(p.asTrajectory, false)\n this.cAlphaOnly = defaults(p.cAlphaOnly, false)\n\n this.structure = new Structure(this.name, this.path)\n this.structureBuilder = new StructureBuilder(this.structure)\n }\n\n get type () { return 'structure' }\n get __objName () { return 'structure' }\n}\n\nexport default StructureParser\n","/**\n * @file Entity\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from './structure'\nimport {\n UnknownEntity, PolymerEntity, NonPolymerEntity, MacrolideEntity, WaterEntity\n} from './structure-constants'\nimport ChainProxy from '../proxy/chain-proxy'\n\nfunction entityTypeFromString (string: string) {\n string = string.toLowerCase()\n switch (string) {\n case 'polymer':\n return PolymerEntity\n case 'non-polymer':\n return NonPolymerEntity\n case 'macrolide':\n return MacrolideEntity\n case 'water':\n return WaterEntity\n default:\n return UnknownEntity\n }\n}\n\nfunction entityFromType (type: number) {\n switch (type) {\n case PolymerEntity:\n return 'polymer'\n case NonPolymerEntity:\n return 'non-polymer'\n case MacrolideEntity:\n return 'macrolide'\n case WaterEntity:\n return 'water'\n default:\n return undefined\n }\n}\n\nexport const EntityTypeString = {\n 'polymer': PolymerEntity,\n 'non-polymer': NonPolymerEntity,\n 'macrolide': MacrolideEntity,\n 'water': WaterEntity,\n}\nexport type EntityTypeString = keyof typeof EntityTypeString\n\n/**\n * Entity of a {@link Structure}\n */\nexport default class Entity {\n structure: Structure\n index: number\n description: string\n entityType: number\n chainIndexList: number[]\n\n /**\n * @param {Structure} structure - structure the entity belongs to\n * @param {Integer} index - index within structure.entityList\n * @param {String} description - entity description\n * @param {String} type - entity type\n * @param {Array} chainIndexList - entity chainIndexList\n */\n constructor (structure: Structure, index: number, description = '', type?: EntityTypeString, chainIndexList: number[] = []) {\n this.structure = structure\n this.index = index\n this.description = description\n this.entityType = entityTypeFromString(type || '')\n this.chainIndexList = chainIndexList\n\n chainIndexList.forEach(function (ci: number) {\n structure.chainStore.entityIndex[ ci ] = index\n })\n }\n\n get type () { return entityFromType(this.entityType) }\n\n getEntityType () {\n return this.entityType\n }\n\n isPolymer () {\n return this.entityType === PolymerEntity\n }\n\n isNonPolymer () {\n return this.entityType === NonPolymerEntity\n }\n\n isMacrolide () {\n return this.entityType === MacrolideEntity\n }\n\n isWater () {\n return this.entityType === WaterEntity\n }\n\n eachChain (callback: (cp: ChainProxy) => any) {\n const cp = this.structure.getChainProxy()\n\n this.chainIndexList.forEach(function (index) {\n cp.index = index\n callback(cp)\n })\n }\n}","/**\n * @file Unitcell\n * @author Alexander Rose \n * @private\n */\n\nimport { Color, Vector3, Matrix4 } from 'three'\n\nimport { defaults } from '../utils'\nimport { degToRad } from '../math/math-utils'\nimport {\n uniformArray, uniformArray3, centerArray3\n} from '../math/array-utils'\nimport { UnitcellPicker } from '../utils/picker'\nimport Structure from '../structure/structure'\n\nexport interface UnitcellParams {\n a: number\n b: number\n c: number\n alpha: number\n beta: number\n gamma: number\n spacegroup: string\n cartToFrac?: Matrix4\n}\n\nconst DefaultBoxParams = {\n a: 1,\n b: 1,\n c: 1,\n alpha: 90,\n beta: 90,\n gamma: 90,\n spacegroup: 'P 1'\n}\n\nexport interface UnitcellDataParams {\n colorValue?: string|number,\n radius?: number\n}\n\n/**\n * Unitcell class\n */\nclass Unitcell {\n a: number\n b: number\n c: number\n alpha: number\n beta: number\n gamma: number\n\n spacegroup: string\n\n cartToFrac = new Matrix4()\n fracToCart = new Matrix4()\n\n volume: number\n\n /**\n * @param {Object} params - unitcell parameters\n * @param {Number} params.a - length a\n * @param {Number} params.b - length b\n * @param {Number} params.c - length c\n * @param {Number} params.alpha - angle alpha\n * @param {Number} params.beta - angle beta\n * @param {Number} params.gamma - angle gamma\n * @param {String} params.spacegroup - spacegroup\n * @param {Matrix4} [params.cartToFrac] - transformation matrix from\n * cartesian to fractional coordinates\n * @param {Matrix4} [params.scale] - alias for `params.cartToFrac`\n */\n constructor (params: UnitcellParams = DefaultBoxParams) {\n this.a = params.a\n this.b = params.b\n this.c = params.c\n this.alpha = params.alpha\n this.beta = params.beta\n this.gamma = params.gamma\n this.spacegroup = params.spacegroup\n\n const alphaRad = degToRad(this.alpha)\n const betaRad = degToRad(this.beta)\n const gammaRad = degToRad(this.gamma)\n const cosAlpha = Math.cos(alphaRad)\n const cosBeta = Math.cos(betaRad)\n const cosGamma = Math.cos(gammaRad)\n const sinBeta = Math.sin(betaRad)\n const sinGamma = Math.sin(gammaRad)\n\n this.volume = (\n this.a * this.b * this.c *\n Math.sqrt(\n 1 - cosAlpha * cosAlpha - cosBeta * cosBeta - cosGamma * cosGamma +\n 2.0 * cosAlpha * cosBeta * cosGamma\n )\n )\n\n if (params.cartToFrac === undefined) {\n // https://github.com/biojava/biojava/blob/master/biojava-structure/src/main/java/org/biojava/nbio/structure/xtal/CrystalCell.java\n\n const cStar = (this.a * this.b * sinGamma) / this.volume\n const cosAlphaStar = (\n (cosBeta * cosGamma - cosAlpha) / (sinBeta * sinGamma)\n )\n\n this.fracToCart.set(\n this.a, 0, 0, 0,\n this.b * cosGamma, this.b * sinGamma, 0, 0,\n this.c * cosBeta, -this.c * sinBeta * cosAlphaStar, 1.0 / cStar, 0,\n 0, 0, 0, 1\n ).transpose()\n this.cartToFrac.getInverse(this.fracToCart)\n } else {\n this.cartToFrac.copy(params.cartToFrac)\n this.fracToCart.getInverse(this.cartToFrac)\n }\n }\n\n getPosition (structure: Structure): Float32Array {\n const vertexPosition = new Float32Array(3 * 8)\n\n if (structure.unitcell) {\n const uc = structure.unitcell\n const centerFrac = structure.center.clone().applyMatrix4(uc.cartToFrac).floor()\n const v = new Vector3()\n\n let cornerOffset = 0\n const addCorner = function (x: number, y: number, z: number) {\n v.set(x, y, z)\n .add(centerFrac)\n .applyMatrix4(uc.fracToCart)\n .toArray(vertexPosition as any, cornerOffset)\n cornerOffset += 3\n }\n addCorner(0, 0, 0)\n addCorner(1, 0, 0)\n addCorner(0, 1, 0)\n addCorner(0, 0, 1)\n addCorner(1, 1, 0)\n addCorner(1, 0, 1)\n addCorner(0, 1, 1)\n addCorner(1, 1, 1)\n }\n\n return vertexPosition\n }\n\n getCenter (structure: Structure) {\n return centerArray3(this.getPosition(structure))\n }\n\n getData (structure: Structure, params: UnitcellDataParams = {}) {\n const colorValue = defaults(params.colorValue, 'orange')\n const radius = defaults(params.radius, Math.cbrt(this.volume) / 200)\n\n const c = new Color(colorValue)\n const v = new Vector3()\n\n const vertexPosition = this.getPosition(structure)\n const vertexColor = uniformArray3(8, c.r, c.g, c.b)\n const vertexRadius = uniformArray(8, radius)\n\n const edgePosition1 = new Float32Array(3 * 12)\n const edgePosition2 = new Float32Array(3 * 12)\n const edgeColor = uniformArray3(12, c.r, c.g, c.b)\n const edgeRadius = uniformArray(12, radius)\n\n let edgeOffset = 0\n function addEdge (a: number, b: number) {\n v.fromArray(vertexPosition as any, a * 3)\n .toArray(edgePosition1 as any, edgeOffset)\n v.fromArray(vertexPosition as any, b * 3)\n .toArray(edgePosition2 as any, edgeOffset)\n edgeOffset += 3\n }\n addEdge(0, 1)\n addEdge(0, 2)\n addEdge(0, 3)\n addEdge(1, 4)\n addEdge(1, 5)\n addEdge(2, 6)\n addEdge(3, 5)\n addEdge(4, 7)\n addEdge(5, 7)\n addEdge(2, 4)\n addEdge(7, 6)\n addEdge(3, 6)\n\n const picker = new UnitcellPicker(this, structure)\n\n return {\n vertex: {\n position: vertexPosition,\n color: vertexColor,\n radius: vertexRadius,\n picking: picker\n },\n edge: {\n position1: edgePosition1,\n position2: edgePosition2,\n color: edgeColor,\n color2: edgeColor,\n radius: edgeRadius,\n picking: picker\n }\n }\n }\n}\n\nexport default Unitcell\n","/**\n * @file Pdb Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureParser from './structure-parser'\nimport Entity, { EntityTypeString } from '../structure/entity'\nimport Unitcell, { UnitcellParams } from '../symmetry/unitcell'\nimport Assembly, { AssemblyPart } from '../symmetry/assembly'\nimport { PDBQTSpecialElements, WaterNames } from '../structure/structure-constants'\nimport {\n assignSecondaryStructure, InferBondsOptions, buildUnitcellAssembly,\n calculateBonds, calculateChainnames, calculateSecondaryStructure\n} from '../structure/structure-utils'\nimport Streamer from '../streamer/streamer';\nimport { ParserParameters } from './parser';\nimport { NumberArray } from '../types';\nimport { Structure } from '../ngl';\n\n// PDB helix record encoding\nconst HelixTypes: {[k: number]: string} = {\n 1: 'h', // Right-handed alpha (default)\n 2: 'h', // Right-handed omega\n 3: 'i', // Right-handed pi\n 4: 'h', // Right-handed gamma\n 5: 'g', // Right-handed 310\n 6: 'h', // Left-handed alpha\n 7: 'h', // Left-handed omega\n 8: 'h', // Left-handed gamma\n 9: 'h', // 27 ribbon/helix\n 10: 'h', // Polyproline\n 0: 'h' //Used to be ''\n}\n\nconst dAminoAcids = [\n 'DAL', // D-ALANINE\n 'DAR', // D-ARGININE\n 'DSG', // D-ASPARAGINE\n 'DAS', // D-ASPARTIC ACID\n 'DCY', // D-CYSTEINE\n 'DGL', // D-GLUTAMIC ACID\n 'DGN', // D-GLUTAMINE\n 'DHI', // D-HISTIDINE\n 'DIL', // D-ISOLEUCINE\n 'DLE', // D-LEUCINE\n 'DLY', // D-LYSINE\n 'MED', // D-METHIONINE\n 'DPN', // D-PHENYLALANINE\n 'DPR', // D-PROLINE\n 'DSN', // D-SERINE\n 'DTH', // D-THREONINE\n 'DTR', // D-TRYPTOPHAN\n 'DTY', // D-TYROSINE\n 'DVA', // D-VALINE\n\n 'DNE' // D-NORLEUCINE\n\n // ??? // D-SELENOCYSTEINE\n]\n\nconst entityKeyList = [\n 'MOL_ID', 'MOLECULE', 'CHAIN', 'FRAGMENT', 'SYNONYM',\n 'EC', 'ENGINEERED', 'MUTATION', 'OTHER_DETAILS'\n]\n\nconst reWhitespace = /\\s+/\n\nfunction getModresId (resno: number, chainname?: string, inscode?: string) {\n let id = `${resno}`\n if (chainname) id += `:${chainname}`\n if (inscode) id += `^${inscode}`\n return id\n}\n\nexport interface PdbParserParameters extends ParserParameters {\n hex: boolean\n inferBonds: InferBondsOptions\n}\n\nclass PdbParser extends StructureParser {\n\n hex: boolean\n inferBonds: InferBondsOptions\n\n /**\n * Create a pdb parser\n * @param {Streamer} streamer - streamer object\n * @param {Object} params - params object\n * @param {Boolean} params.hex - hexadecimal parsing of\n * atom numbers >99.999 and\n * residue numbers >9.999\n * @param {InferBondsOptions} params.inferBonds: 'all': use explicit bonds and detect by distance\n * 'auto': If a hetgroup residue has explicit bonds, don't auto-detect\n * 'none': Don't add any bonds automatically\n * @return {undefined}\n */\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.hex = defaults(p.hex, false)\n this.inferBonds = defaults(p.inferBonds, 'all')\n }\n\n get type () { return 'pdb' }\n\n _parse () {\n // http://www.wwpdb.org/documentation/file-format.php\n\n if (Debug) Log.time('PdbParser._parse ' + this.name)\n\n let isLegacy = false\n const headerLine = this.streamer.peekLines(1)[ 0 ]\n const headerId = headerLine.substr(62, 4)\n const legacyId = headerLine.substr(72, 4)\n if (headerId === legacyId && legacyId.trim()) {\n isLegacy = true\n }\n\n const isPqr = this.type === 'pqr'\n const isPdbqt = this.type === 'pdbqt'\n\n const s: Structure = this.structure\n const sb = this.structureBuilder\n\n const hex = this.hex\n let serialRadix = 10\n let resnoRadix = 10\n\n const firstModelOnly = this.firstModelOnly\n const asTrajectory = this.asTrajectory\n const cAlphaOnly = this.cAlphaOnly\n\n const frames = s.frames\n const boxes = s.boxes\n let doFrames = false\n let currentFrame: NumberArray, currentCoord: number\n\n const biomolDict = s.biomolDict\n let currentBiomol: Assembly\n let currentPart: AssemblyPart\n let currentMatrix: Matrix4\n\n let line, recordName\n let serial, chainname: string, resno: number, resname: string, occupancy: number\n let inscode: string, atomname, hetero: boolean, bfactor: number, altloc\n let formalCharge: number\n\n let startChain, startResi, startIcode\n let endChain, endResi, endIcode\n\n let serialDict: {[k: number]: number} = {}\n const unitcellDict: Partial<{\n origx: Matrix4\n scale: Matrix4\n a: number\n b: number\n c: number\n alpha: number\n beta: number\n gamma: number\n spacegroup: string\n }> = {}\n const bondDict: {[k: string]: boolean} = {}\n\n const entityDataList: {chainList: string[], name: string}[] = []\n let currentEntityData: {chainList: string[], name: string}\n let currentEntityKey: 'MOL_ID'|'MOLECULE'|'CHAIN'|'FRAGMENT'|'SYNONYM'|'EC'|'ENGINEERED'|'MUTATION'|'OTHER_DETAILS'\n // MOL_ID Numbers each component; also used in SOURCE to associate\n // the information.\n // MOLECULE Name of the macromolecule.\n // CHAIN Comma-separated list of chain identifier(s).\n // FRAGMENT Specifies a domain or region of the molecule.\n // SYNONYM Comma-separated list of synonyms for the MOLECULE.\n // EC The Enzyme Commission number associated with the molecule.\n // If there is more than one EC number, they are presented\n // as a comma-separated list.\n // ENGINEERED Indicates that the molecule was produced using\n // recombinant technology or by purely chemical synthesis.\n // MUTATION Indicates if there is a mutation.\n // OTHER_DETAILS Additional comments.\n\n const hetnameDict: {[k: string]: string} = {}\n const modresDict: {[k: string]: any} = {}\n\n const chainDict: {[k: string]: number} = {}\n let chainIdx: number, chainid: string, newChain: boolean\n let currentChainname: string, currentResno: number, currentResname: string, currentInscode: string\n\n const seqresDict: {[k: string]: string[]} = {}\n let currentSeqresChainname: string\n\n const secStruct = {\n helices: [] as any[],\n sheets: [] as any[]\n }\n const helices = secStruct.helices\n const sheets = secStruct.sheets\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.resize(Math.round(this.streamer.data.length / 80))\n if (isPqr || isPdbqt) atomStore.addField('partialCharge', 1, 'float32')\n if (isPqr) atomStore.addField('radius', 1, 'float32')\n\n const ap1 = s.getAtomProxy()\n const ap2 = s.getAtomProxy()\n\n let idx = 0\n let modelIdx = 0\n let pendingStart = true\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n line = lines[ i ]\n recordName = line.substr(0, 6)\n\n if (recordName === 'ATOM ' || recordName === 'HETATM') {\n // http://www.wwpdb.org/documentation/file-format-content/format33/sect9.html#ATOM\n // PQR: Field_name Atom_number Atom_name Residue_name Chain_ID Residue_number X Y Z Charge Radius\n\n if (pendingStart) {\n if (asTrajectory) {\n if (doFrames) {\n currentFrame = new Float32Array(atomStore.count * 3)\n frames.push(currentFrame)\n } else {\n currentFrame = []\n }\n currentCoord = 0\n } else {\n if (!firstModelOnly) serialDict = {}\n }\n\n chainIdx = 1\n chainid = chainIdx.toString()\n newChain = true\n\n pendingStart = false\n }\n\n if (firstModelOnly && modelIdx > 0) continue\n\n let x, y, z, ls: string[], dd = 0\n\n if (isPqr) {\n ls = line.split(reWhitespace)\n dd = ls.length === 10 ? 1 : 0\n\n atomname = ls[ 2 ]\n if (cAlphaOnly && atomname !== 'CA') continue\n\n x = parseFloat(ls[ 6 - dd ])\n y = parseFloat(ls[ 7 - dd ])\n z = parseFloat(ls[ 8 - dd ])\n } else {\n atomname = line.substr(12, 4).trim()\n if (cAlphaOnly && atomname !== 'CA') continue\n\n x = parseFloat(line.substr(30, 8))\n y = parseFloat(line.substr(38, 8))\n z = parseFloat(line.substr(46, 8))\n }\n\n if (asTrajectory) {\n const j = currentCoord * 3\n\n currentFrame[ j + 0 ] = x\n currentFrame[ j + 1 ] = y\n currentFrame[ j + 2 ] = z\n\n currentCoord += 1\n\n if (doFrames) continue\n }\n\n let element\n\n if (isPqr) {\n serial = parseInt(ls![ 1 ])\n element = ''\n hetero = (line[ 0 ] === 'H')\n chainname = dd ? '' : ls![ 4 ]\n resno = parseInt(ls![ 5 - dd! ])\n inscode = ''\n resname = ls![ 3 ]\n altloc = ''\n occupancy = 1.0\n } else {\n serial = parseInt(line.substr(6, 5), serialRadix)\n if (hex && serial === 99999) {\n serialRadix = 16\n }\n hetero = (line[ 0 ] === 'H')\n chainname = line[ 21 ].trim()\n resno = parseInt(line.substr(22, 4), resnoRadix)\n if (hex && resno === 9999) {\n resnoRadix = 16\n }\n inscode = line[ 26 ].trim()\n resname = line.substr(17, 4).trim() || 'MOL'\n bfactor = parseFloat(line.substr(60, 6))\n altloc = line[ 16 ].trim()\n occupancy = parseFloat(line.substr(54, 6))\n\n if (!isLegacy) {\n if (isPdbqt) {\n element = line.substr(76, 3).trim()\n // @ts-expect-error TS limitation on narrowing indexes types with `in`\n if (element in PDBQTSpecialElements) element = PDBQTSpecialElements[element]\n } else {\n element = line.substr(76, 2).trim()\n if (!chainname) {\n chainname = line.substr(72, 4).trim() // segid\n }\n }\n // Where specified, formalCharge is of form \"2-\" or \"1+\"\n formalCharge = parseInt((line.substr(79,1) + line.substr(78, 1)).trim())\n }\n }\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname, element)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = serial\n atomStore.altloc[ idx ] = altloc.charCodeAt(0)\n atomStore.occupancy[ idx ] = isNaN(occupancy) ? 0 : occupancy\n\n if (isPqr) {\n atomStore.partialCharge![ idx ] = parseFloat(ls![ 9 - dd! ])\n atomStore.radius[ idx ] = parseFloat(ls![ 10 - dd! ])\n } else {\n atomStore.bfactor[ idx ] = isNaN(bfactor) ? 0 : bfactor\n if (isPdbqt) {\n atomStore.partialCharge![ idx ] = parseFloat(line.substr(70, 6))\n }\n // isFinite check will reject undefined (in legacy case) and NaN values\n if (isFinite(formalCharge)) {\n if (!atomStore.formalCharge) {\n atomStore.addField('formalCharge', 1, 'int8')\n }\n atomStore.formalCharge![ idx ] = formalCharge\n }\n }\n\n const modresId = getModresId(resno, chainname, inscode)\n\n // TODO instead of looking at MODRES look at SEQRES and\n // missing residues in REMARK 465\n if (hetero && !modresDict[modresId] && !dAminoAcids.includes(resname)) {\n if (currentChainname !== chainname || currentResname !== resname ||\n (!WaterNames.includes(resname) &&\n (currentResno !== resno || currentInscode !== inscode))\n ) {\n chainIdx += 1\n chainid = chainIdx.toString()\n\n currentResno = resno\n currentResname = resname\n currentInscode = inscode\n }\n } else if (!newChain && currentChainname !== chainname) {\n chainIdx += 1\n chainid = chainIdx.toString()\n }\n\n sb.addAtom(modelIdx, chainname, chainid, resname, resno, hetero, undefined, inscode)\n\n serialDict[ serial ] = idx\n idx += 1\n newChain = false\n currentChainname = chainname\n } else if (recordName === 'CONECT') {\n const fromIdx = serialDict[ parseInt(line.substr(6, 5)) ]\n const pos = [ 11, 16, 21, 26 ]\n const bondIndex: {[k: number]: number} = {}\n\n if (fromIdx === undefined) {\n // Log.log( \"missing CONNECT serial\" );\n continue\n }\n\n for (let j = 0; j < 4; ++j) {\n let toIdx = parseInt(line.substr(pos[ j ], 5))\n if (Number.isNaN(toIdx)) continue\n toIdx = serialDict[ toIdx ]\n if (toIdx === undefined) {\n // Log.log( \"missing CONNECT serial\" );\n continue\n }/* else if( toIdx < fromIdx ){\n // likely a duplicate in standard PDB format\n // but not necessarily, so better remove duplicates\n // in a pass after parsing (and auto bonding)\n continue;\n } */\n\n if (fromIdx < toIdx) {\n ap1.index = fromIdx\n ap2.index = toIdx\n } else {\n ap1.index = toIdx\n ap2.index = fromIdx\n }\n\n // interpret records where a 'toIdx' atom is given multiple times\n // as double/triple bonds, e.g. CONECT 1529 1528 1528 is a double bond\n if (bondIndex[ toIdx ] !== undefined) {\n s.bondStore.bondOrder[ bondIndex[ toIdx ] ] += 1\n } else {\n const hash = ap1.index + '|' + ap2.index\n if (bondDict[ hash ] === undefined) {\n bondDict[ hash ] = true\n bondIndex[ toIdx ] = s.bondStore.count\n s.bondStore.addBond(ap1, ap2, 1) // start/assume with single bond\n }\n }\n }\n } else if (recordName === 'HELIX ') {\n startChain = line[ 19 ].trim()\n startResi = parseInt(line.substr(21, 4))\n startIcode = line[ 25 ].trim()\n endChain = line[ 31 ].trim()\n endResi = parseInt(line.substr(33, 4))\n endIcode = line[ 37 ].trim()\n let helixType = parseInt(line.substr(39, 1))\n helixType = (HelixTypes[ helixType ] || HelixTypes[0]).charCodeAt(0)\n helices.push([\n startChain, startResi, startIcode,\n endChain, endResi, endIcode,\n helixType\n ])\n } else if (recordName === 'SHEET ') {\n startChain = line[ 21 ].trim()\n startResi = parseInt(line.substr(22, 4))\n startIcode = line[ 26 ].trim()\n endChain = line[ 32 ].trim()\n endResi = parseInt(line.substr(33, 4))\n endIcode = line[ 37 ].trim()\n sheets.push([\n startChain, startResi, startIcode,\n endChain, endResi, endIcode\n ])\n } else if (recordName === 'HETNAM') {\n hetnameDict[ line.substr(11, 3) ] = line.substr(15).trim()\n } else if (recordName === 'SEQRES') {\n const seqresChainname = line[11].trim()\n if (seqresChainname !== currentSeqresChainname) {\n seqresDict[ seqresChainname ] = []\n currentSeqresChainname = seqresChainname\n }\n seqresDict[ seqresChainname ].push(\n ...line.substr(19).trim().split(reWhitespace)\n )\n } else if (recordName === 'MODRES') {\n // MODRES 2SRC PTR A 527 TYR O-PHOSPHOTYROSINE\n const resname = line.substr(12, 3).trim()\n const chainname = line[16].trim()\n const inscode = line[22].trim()\n const resno = parseInt(line.substr(18, 4).trim())\n const id = getModresId(resno, chainname, inscode)\n modresDict[ id ] = { resname, chainname, inscode, resno }\n } else if (recordName === 'COMPND') {\n const comp = line.substr(10, 70).trim()\n const keyEnd = comp.indexOf(':')\n const key = comp.substring(0, keyEnd)\n let value\n\n if (entityKeyList.includes(key)) {\n currentEntityKey = key as 'MOL_ID'|'MOLECULE'|'CHAIN'|'FRAGMENT'|'SYNONYM'|'EC'|'ENGINEERED'|'MUTATION'|'OTHER_DETAILS'\n value = comp.substring(keyEnd + 2)\n } else {\n value = comp\n }\n value = value.replace(/;$/, '')\n\n if (currentEntityKey === 'MOL_ID') {\n currentEntityData = {\n chainList: [],\n name: ''\n }\n entityDataList.push(currentEntityData)\n } else if (currentEntityKey === 'MOLECULE') {\n if (currentEntityData.name) currentEntityData.name += ' '\n currentEntityData.name += value\n } else if (currentEntityKey === 'CHAIN') {\n Array.prototype.push.apply(\n currentEntityData.chainList,\n value.split(/\\s*,\\s*/)\n )\n }\n } else if (line.startsWith('TER')) {\n const cp = s.getChainProxy(s.chainStore.count - 1)\n chainDict[ cp.chainname ] = cp.index\n chainIdx += 1\n chainid = chainIdx.toString()\n newChain = true\n } else if (recordName === 'REMARK' && line.substr(7, 3) === '350') {\n if (line.substr(11, 12) === 'BIOMOLECULE:') {\n let name = line.substr(23).trim()\n if (/^(0|[1-9][0-9]*)$/.test(name)) name = 'BU' + name\n\n currentBiomol = new Assembly(name)\n biomolDict[ name ] = currentBiomol\n } else if (line.substr(13, 5) === 'BIOMT') {\n const biomt = line.split(/\\s+/)\n const row = parseInt(line[ 18 ]) - 1\n\n if (row === 0) {\n currentMatrix = new Matrix4()\n currentPart.matrixList.push(currentMatrix)\n }\n\n const biomtElms = currentMatrix.elements\n\n biomtElms[ 4 * 0 + row ] = parseFloat(biomt[ 4 ])\n biomtElms[ 4 * 1 + row ] = parseFloat(biomt[ 5 ])\n biomtElms[ 4 * 2 + row ] = parseFloat(biomt[ 6 ])\n biomtElms[ 4 * 3 + row ] = parseFloat(biomt[ 7 ])\n } else if (\n line.substr(11, 30) === 'APPLY THE FOLLOWING TO CHAINS:' ||\n line.substr(11, 30) === ' AND CHAINS:'\n ) {\n if (line.substr(11, 5) === 'APPLY') {\n currentPart = currentBiomol.addPart()\n }\n\n const chainList = line.substr(41, 30).split(',')\n for (let j = 0, jl = chainList.length; j < jl; ++j) {\n const c = chainList[ j ].trim()\n if (c) currentPart.chainList.push(c)\n }\n }\n } else if (recordName === 'HEADER') {\n s.id = line.substr(62, 4)\n } else if (recordName === 'TITLE ') {\n s.title += (s.title ? ' ' : '') + line.substr(10, 70).trim()\n } else if (recordName === 'MODEL ') {\n pendingStart = true\n } else if (recordName === 'ENDMDL' || line.trim() === 'END') {\n if (pendingStart) continue\n\n if (asTrajectory && !doFrames) {\n frames.push(new Float32Array(currentFrame))\n doFrames = true\n }\n\n modelIdx += 1\n pendingStart = true\n } else if (line.substr(0, 5) === 'MTRIX') {\n // ignore 'given' operators\n if (line[ 59 ] === '1') continue\n\n if (!currentBiomol || currentBiomol.name !== 'NCS') {\n const ncsName = 'NCS'\n currentBiomol = new Assembly(ncsName)\n biomolDict[ ncsName ] = currentBiomol\n currentPart = currentBiomol.addPart()\n }\n\n const ncs = line.split(/\\s+/)\n const ncsRow = parseInt(line[ 5 ]) - 1\n\n if (ncsRow === 0) {\n currentMatrix = new Matrix4()\n currentPart.matrixList.push(currentMatrix)\n }\n\n const ncsElms = currentMatrix.elements\n\n ncsElms[ 4 * 0 + ncsRow ] = parseFloat(ncs[ 2 ])\n ncsElms[ 4 * 1 + ncsRow ] = parseFloat(ncs[ 3 ])\n ncsElms[ 4 * 2 + ncsRow ] = parseFloat(ncs[ 4 ])\n ncsElms[ 4 * 3 + ncsRow ] = parseFloat(ncs[ 5 ])\n } else if (line.substr(0, 5) === 'ORIGX') {\n if (!unitcellDict.origx) {\n unitcellDict.origx = new Matrix4()\n }\n\n const orgix = line.split(/\\s+/)\n const origxRow = parseInt(line[ 5 ]) - 1\n const origxElms = unitcellDict.origx.elements\n\n origxElms[ 4 * 0 + origxRow ] = parseFloat(orgix[ 1 ])\n origxElms[ 4 * 1 + origxRow ] = parseFloat(orgix[ 2 ])\n origxElms[ 4 * 2 + origxRow ] = parseFloat(orgix[ 3 ])\n origxElms[ 4 * 3 + origxRow ] = parseFloat(orgix[ 4 ])\n } else if (line.substr(0, 5) === 'SCALE') {\n if (!unitcellDict.scale) {\n unitcellDict.scale = new Matrix4()\n }\n\n const scale = line.split(/\\s+/)\n const scaleRow = parseInt(line[ 5 ]) - 1\n const scaleElms = unitcellDict.scale.elements\n\n scaleElms[ 4 * 0 + scaleRow ] = parseFloat(scale[ 1 ])\n scaleElms[ 4 * 1 + scaleRow ] = parseFloat(scale[ 2 ])\n scaleElms[ 4 * 2 + scaleRow ] = parseFloat(scale[ 3 ])\n scaleElms[ 4 * 3 + scaleRow ] = parseFloat(scale[ 4 ])\n } else if (recordName === 'CRYST1') {\n // CRYST1 55.989 55.989 55.989 90.00 90.00 90.00 P 1 1\n // 7 - 15 Real(9.3) a (Angstroms)\n // 16 - 24 Real(9.3) b (Angstroms)\n // 25 - 33 Real(9.3) c (Angstroms)\n // 34 - 40 Real(7.2) alpha alpha (degrees).\n // 41 - 47 Real(7.2) beta beta (degrees).\n // 48 - 54 Real(7.2) gamma gamma (degrees).\n // 56 - 66 LString sGroup Space group.\n // 67 - 70 Integer z Z value.\n\n const aLength = parseFloat(line.substr(6, 9))\n const bLength = parseFloat(line.substr(15, 9))\n const cLength = parseFloat(line.substr(24, 9))\n\n const alpha = parseFloat(line.substr(33, 7))\n const beta = parseFloat(line.substr(40, 7))\n const gamma = parseFloat(line.substr(47, 7))\n\n const sGroup = line.substr(55, 11).trim()\n // const zValue = parseInt( line.substr( 66, 4 ) );\n\n const box = new Float32Array(9)\n box[ 0 ] = aLength\n box[ 4 ] = bLength\n box[ 8 ] = cLength\n boxes.push(box)\n\n if (modelIdx === 0) {\n unitcellDict.a = aLength\n unitcellDict.b = bLength\n unitcellDict.c = cLength\n unitcellDict.alpha = alpha\n unitcellDict.beta = beta\n unitcellDict.gamma = gamma\n unitcellDict.spacegroup = sGroup\n }\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n\n // finalize ensures resname will be defined for all rp.resname\n // (required in entity handling below)\n sb.finalize()\n\n //\n\n const en = entityDataList.length\n\n if (en) {\n s.eachChain(function (cp) {\n cp.entityIndex = en\n })\n\n entityDataList.forEach(function (e, i) {\n const chainIndexList = e.chainList.map(function (chainname) {\n return chainDict[ chainname ]\n })\n s.entityList.push(new Entity(\n s, i, e.name, 'polymer', chainIndexList\n ))\n })\n\n let ei = entityDataList.length\n const rp = s.getResidueProxy()\n const residueDict: {[k: string]: number[]} = {}\n\n s.eachChain(function (cp) {\n if (cp.entityIndex === en) {\n rp.index = cp.residueOffset\n if (!residueDict[ rp.resname ]) {\n residueDict[ rp.resname ] = []\n }\n residueDict[ rp.resname ].push(cp.index)\n }\n })\n\n Object.keys(residueDict).forEach(function (resname) {\n const chainList = residueDict[ resname ]\n let type: EntityTypeString = 'non-polymer'\n let name = hetnameDict[ resname ] || resname\n if (WaterNames.includes(resname)) {\n name = 'water'\n type = 'water'\n }\n s.entityList.push(new Entity(\n s, ei, name, type, chainList\n ))\n ei += 1\n })\n }\n\n //\n\n if (unitcellDict.a !== undefined) {\n s.unitcell = new Unitcell(unitcellDict as UnitcellParams)\n } else {\n s.unitcell = undefined\n }\n\n if (helices.length || sheets.length) {\n assignSecondaryStructure(s, secStruct)\n }\n\n s.finalizeAtoms()\n if (!isLegacy) calculateChainnames(s)\n calculateBonds(s, this.inferBonds)\n s.finalizeBonds()\n\n if (!helices.length && !sheets.length) {\n calculateSecondaryStructure(s)\n }\n buildUnitcellAssembly(s)\n\n if (Debug) Log.timeEnd('PdbParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('pdb', PdbParser)\nParserRegistry.add('pdb1', PdbParser)\nParserRegistry.add('ent', PdbParser)\n\nexport default PdbParser\n\nexport {\n HelixTypes\n}\n","/**\n * @file Cif Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport { HelixTypes } from './pdb-parser'\nimport Entity from '../structure/entity'\nimport Unitcell, { UnitcellParams } from '../symmetry/unitcell'\nimport Assembly from '../symmetry/assembly'\nimport Selection from '../selection/selection'\nimport {\n assignResidueTypeBonds, assignSecondaryStructure, buildUnitcellAssembly,\n calculateBonds, calculateSecondaryStructure\n} from '../structure/structure-utils'\nimport { Structure } from '../ngl';\nimport StructureBuilder from '../structure/structure-builder';\nimport { NumberArray } from '../types';\n\nconst reWhitespace = /\\s+/\nconst reQuotedWhitespace = /'((?:(?!'\\s).)*)'|\"((?:(?!\"\\s).)*)\"|(\\S+)/g\nconst reDoubleQuote = /\"/g\nconst reTrimQuotes = /^['\"]+|['\"]+$/g\n\ninterface Cif {[k: string]: any}\n\nfunction trimQuotes (str: string) {\n if (str && str[0] === str[ str.length - 1 ] && (str[0] === \"'\" || str[0] === '\"')) {\n return str.substring(1, str.length - 1)\n } else {\n return str\n }\n}\n\nfunction ensureArray (dict: {[k: string]: any[]}, field: string) {\n if (!Array.isArray(dict[ field ])) {\n Object.keys(dict).forEach(function (key) {\n dict[ key ] = [ dict[ key ] ]\n })\n }\n}\n\nfunction hasValue (d: string) {\n return d !== '?'\n}\n\nfunction cifDefaults (value: string, defaultValue: string) {\n return hasValue(value) ? value : defaultValue\n}\n\nfunction getBondOrder (valueOrder: string) {\n switch (valueOrder.toLowerCase()) {\n case '?': // assume single bond\n case 'sing':\n return 1\n case 'doub':\n return 2\n case 'trip':\n return 3\n case 'quad':\n return 4\n }\n return 0\n}\n\nfunction parseChemComp (cif: Cif, structure: Structure, structureBuilder: StructureBuilder) {\n const atomStore = structure.atomStore\n const atomMap = structure.atomMap\n\n let i, n\n const cc = cif.chem_comp\n const cca = cif.chem_comp_atom\n const ccb = cif.chem_comp_bond\n\n if (cc) {\n if (cc.name) {\n structure.title = cc.name.trim().replace(reTrimQuotes, '')\n }\n if (cc.id) {\n structure.id = cc.id.trim().replace(reTrimQuotes, '')\n }\n }\n\n var atomnameDict: {[k: string]: number} = {}\n\n if (cca) {\n ensureArray(cca, 'comp_id')\n\n var atomname, element, resname, resno\n n = cca.comp_id.length\n\n for (i = 0; i < n; ++i) {\n atomStore.growIfFull()\n\n atomname = cca.atom_id[ i ].replace(reDoubleQuote, '')\n element = cca.type_symbol[ i ]\n\n atomnameDict[ atomname ] = i\n atomStore.atomTypeId[ i ] = atomMap.add(atomname, element)\n\n atomStore.x[ i ] = cca.model_Cartn_x[ i ]\n atomStore.y[ i ] = cca.model_Cartn_y[ i ]\n atomStore.z[ i ] = cca.model_Cartn_z[ i ]\n atomStore.serial[ i ] = i\n\n resname = cca.pdbx_component_comp_id[ i ]\n resno = cca.pdbx_residue_numbering ? cca.pdbx_residue_numbering[ i ] : 1\n\n structureBuilder.addAtom(0, '', '', resname, resno, true)\n }\n\n for (i = 0; i < n; ++i) {\n var j = i + n\n\n atomStore.growIfFull()\n\n atomname = cca.atom_id[ i ].replace(reDoubleQuote, '')\n element = cca.type_symbol[ i ]\n\n atomStore.atomTypeId[ j ] = atomMap.add(atomname, element)\n\n atomStore.x[ j ] = cca.pdbx_model_Cartn_x_ideal[ i ]\n atomStore.y[ j ] = cca.pdbx_model_Cartn_y_ideal[ i ]\n atomStore.z[ j ] = cca.pdbx_model_Cartn_z_ideal[ i ]\n atomStore.serial[ j ] = j\n\n resname = cca.pdbx_component_comp_id[ i ]\n resno = cca.pdbx_residue_numbering ? cca.pdbx_residue_numbering[ i ] : 1\n\n structureBuilder.addAtom(1, '', '', resname, resno, true)\n }\n }\n\n if (cca && ccb) {\n ensureArray(ccb, 'comp_id')\n\n var atomname1, atomname2, bondOrder\n n = ccb.comp_id.length\n var na = cca.comp_id.length\n\n var ap1 = structure.getAtomProxy()\n var ap2 = structure.getAtomProxy()\n\n for (i = 0; i < n; ++i) {\n atomname1 = ccb.atom_id_1[ i ].replace(reDoubleQuote, '')\n atomname2 = ccb.atom_id_2[ i ].replace(reDoubleQuote, '')\n bondOrder = getBondOrder(ccb.value_order[ i ])\n\n ap1.index = atomnameDict[ atomname1 ]\n ap2.index = atomnameDict[ atomname2 ]\n structure.bondStore.growIfFull()\n structure.bondStore.addBond(ap1, ap2, bondOrder)\n\n ap1.index += na\n ap2.index += na\n structure.bondStore.growIfFull()\n structure.bondStore.addBond(ap1, ap2, bondOrder)\n }\n }\n}\n\nfunction parseCore (cif: Cif, structure: Structure, structureBuilder: StructureBuilder) {\n var atomStore = structure.atomStore\n var atomMap = structure.atomMap\n\n if (cif.data) {\n structure.id = cif.data\n structure.name = cif.data\n }\n\n structure.unitcell = new Unitcell({\n a: parseFloat(cif.cell_length_a),\n b: parseFloat(cif.cell_length_b),\n c: parseFloat(cif.cell_length_c),\n alpha: parseFloat(cif.cell_angle_alpha),\n beta: parseFloat(cif.cell_angle_beta),\n gamma: parseFloat(cif.cell_angle_gamma),\n spacegroup: trimQuotes(cif['symmetry_space_group_name_H-M'])\n })\n\n const v = new Vector3()\n const c = new Vector3()\n const n = cif.atom_site_type_symbol.length\n\n for (let i = 0; i < n; ++i) {\n atomStore.growIfFull()\n\n const atomname = cif.atom_site_label[ i ]\n const element = cif.atom_site_type_symbol[ i ]\n\n atomStore.atomTypeId[ i ] = atomMap.add(atomname, element)\n\n v.set(\n cif.atom_site_fract_x[ i ],\n cif.atom_site_fract_y[ i ],\n cif.atom_site_fract_z[ i ]\n )\n v.applyMatrix4(structure.unitcell.fracToCart)\n c.add(v)\n\n atomStore.x[ i ] = v.x\n atomStore.y[ i ] = v.y\n atomStore.z[ i ] = v.z\n if (cif.atom_site_occupancy) {\n atomStore.occupancy[ i ] = parseFloat(cif.atom_site_occupancy[ i ])\n }\n atomStore.serial[ i ] = i\n\n structureBuilder.addAtom(0, '', '', 'HET', 1, true)\n }\n\n c.divideScalar(n)\n structure.center = c\n buildUnitcellAssembly(structure)\n\n const v2 = new Vector3()\n const v3 = new Vector3()\n const ml = structure.biomolDict.SUPERCELL.partList[ 0 ].matrixList\n\n let k = n\n\n function covalent (idx: number) {\n return atomMap.get(atomStore.atomTypeId[ idx ]).covalent\n }\n const identityMatrix = new Matrix4()\n\n for (let i = 0; i < n; ++i) {\n const covalentI = covalent(i)\n\n v.set(\n atomStore.x[ i ],\n atomStore.y[ i ],\n atomStore.z[ i ]\n )\n\n ml.forEach(function (m) {\n if (identityMatrix.equals(m)) return\n\n v2.copy(v)\n v2.applyMatrix4(m)\n\n for (let j = 0; j < n; ++j) {\n v3.set(\n atomStore.x[ j ],\n atomStore.y[ j ],\n atomStore.z[ j ]\n )\n\n const distSquared = v2.distanceToSquared(v3)\n const d = covalent(j) + covalentI\n const d1 = d + 0.3\n const d2 = d - 0.5\n\n if (distSquared < (d1 * d1) && distSquared > (d2 * d2)) {\n atomStore.growIfFull()\n\n atomStore.atomTypeId[ k ] = atomStore.atomTypeId[ i ]\n atomStore.x[ k ] = v2.x\n atomStore.y[ k ] = v2.y\n atomStore.z[ k ] = v2.z\n atomStore.occupancy[ k ] = atomStore.occupancy[ i ]\n atomStore.serial[ k ] = k\n atomStore.altloc[ k ] = 'A'.charCodeAt(0)\n\n structureBuilder.addAtom(0, '', '', 'HET', 1, true)\n\n k += 1\n return\n }\n }\n })\n }\n}\n\nfunction processSecondaryStructure (cif: Cif, structure: Structure, asymIdDict: {[k: string]: string}) {\n var helices: [string, number, string, string, number, string, number][] = []\n var sheets: [string, number, string, string, number, string][] = []\n\n var i, il, begIcode, endIcode\n\n // get helices\n var sc = cif.struct_conf\n\n if (sc?.pdbx_PDB_helix_class) {\n ensureArray(sc, 'id')\n\n for (i = 0, il = sc.beg_auth_seq_id.length; i < il; ++i) {\n var helixType = parseInt(sc.pdbx_PDB_helix_class[ i ])\n if (!Number.isNaN(helixType)) {\n begIcode = sc.pdbx_beg_PDB_ins_code[ i ]\n endIcode = sc.pdbx_end_PDB_ins_code[ i ]\n helices.push([\n asymIdDict[ sc.beg_label_asym_id[ i ] ],\n parseInt(sc.beg_auth_seq_id[ i ]),\n cifDefaults(begIcode, ''),\n asymIdDict[ sc.end_label_asym_id[ i ] ],\n parseInt(sc.end_auth_seq_id[ i ]),\n cifDefaults(endIcode, ''),\n (HelixTypes[ helixType ] || HelixTypes[0]).charCodeAt(0)\n ])\n }\n }\n }\n\n // get sheets\n var ssr = cif.struct_sheet_range\n\n if (ssr) {\n ensureArray(ssr, 'id')\n\n for (i = 0, il = ssr.beg_auth_seq_id.length; i < il; ++i) {\n begIcode = ssr.pdbx_beg_PDB_ins_code[ i ]\n endIcode = ssr.pdbx_end_PDB_ins_code[ i ]\n sheets.push([\n asymIdDict[ ssr.beg_label_asym_id[ i ] ],\n parseInt(ssr.beg_auth_seq_id[ i ]),\n cifDefaults(begIcode, ''),\n asymIdDict[ ssr.end_label_asym_id[ i ] ],\n parseInt(ssr.end_auth_seq_id[ i ]),\n cifDefaults(endIcode, '')\n ])\n }\n }\n\n if (sc || ssr) {\n return {\n helices: helices,\n sheets: sheets\n }\n } else {\n return false\n }\n}\n\nfunction processSymmetry (cif: Cif, structure: Structure, asymIdDict: {[k: string]: string}) {\n // biomol & ncs processing\n var operDict: {[k: string]: Matrix4} = {}\n var biomolDict = structure.biomolDict\n\n if (cif.pdbx_struct_oper_list) {\n var biomolOp = cif.pdbx_struct_oper_list\n ensureArray(biomolOp, 'id')\n\n biomolOp.id.forEach(function (id: number, i: number) {\n var m = new Matrix4()\n var elms = m.elements\n\n elms[ 0 ] = parseFloat(biomolOp[ 'matrix[1][1]' ][ i ])\n elms[ 1 ] = parseFloat(biomolOp[ 'matrix[1][2]' ][ i ])\n elms[ 2 ] = parseFloat(biomolOp[ 'matrix[1][3]' ][ i ])\n\n elms[ 4 ] = parseFloat(biomolOp[ 'matrix[2][1]' ][ i ])\n elms[ 5 ] = parseFloat(biomolOp[ 'matrix[2][2]' ][ i ])\n elms[ 6 ] = parseFloat(biomolOp[ 'matrix[2][3]' ][ i ])\n\n elms[ 8 ] = parseFloat(biomolOp[ 'matrix[3][1]' ][ i ])\n elms[ 9 ] = parseFloat(biomolOp[ 'matrix[3][2]' ][ i ])\n elms[ 10 ] = parseFloat(biomolOp[ 'matrix[3][3]' ][ i ])\n\n elms[ 3 ] = parseFloat(biomolOp[ 'vector[1]' ][ i ])\n elms[ 7 ] = parseFloat(biomolOp[ 'vector[2]' ][ i ])\n elms[ 11 ] = parseFloat(biomolOp[ 'vector[3]' ][ i ])\n\n m.transpose()\n\n operDict[ id ] = m\n })\n }\n\n if (cif.pdbx_struct_assembly_gen) {\n var gen = cif.pdbx_struct_assembly_gen\n ensureArray(gen, 'assembly_id')\n\n var getMatrixDict = function (expr: string) {\n var matDict: {[k: string]: Matrix4} = {}\n\n var l = expr.replace(/[()']/g, '').split(',')\n\n l.forEach(function (e) {\n if (e.includes('-')) {\n var es = e.split('-')\n\n var j = parseInt(es[ 0 ])\n var m = parseInt(es[ 1 ])\n\n for (; j <= m; ++j) {\n matDict[ j ] = operDict[ j ]\n }\n } else {\n matDict[ e ] = operDict[ e ]\n }\n })\n\n return matDict\n }\n\n gen.assembly_id.forEach(function (id: string, i: number) {\n var md:{[k: string]: Matrix4} = {}\n var oe = gen.oper_expression[ i ].replace(/['\"]\\(|['\"]/g, '')\n\n if (oe.includes(')(') || oe.indexOf('(') > 0) {\n oe = oe.split('(')\n\n var md1 = getMatrixDict(oe[ 0 ])\n var md2 = getMatrixDict(oe[ 1 ])\n\n Object.keys(md1).forEach(function (k1) {\n Object.keys(md2).forEach(function (k2) {\n var mat = new Matrix4()\n\n mat.multiplyMatrices(md1[ k1 ], md2[ k2 ])\n md[ k1 + 'x' + k2 ] = mat\n })\n })\n } else {\n md = getMatrixDict(oe)\n }\n\n var matrixList = []\n for (var k in md) {\n matrixList.push(md[ k ])\n }\n\n var name = id\n if (/^(0|[1-9][0-9]*)$/.test(name)) name = 'BU' + name\n\n var chainList = gen.asym_id_list[ i ].split(',')\n for (var j = 0, jl = chainList.length; j < jl; ++j) {\n chainList[ j ] = asymIdDict[ chainList[ j ] ]\n }\n\n if (biomolDict[ name ] === undefined) {\n biomolDict[ name ] = new Assembly(name)\n }\n biomolDict[ name ].addPart(matrixList, chainList)\n })\n }\n\n // non-crystallographic symmetry operations\n if (cif.struct_ncs_oper) {\n var ncsOp = cif.struct_ncs_oper\n ensureArray(ncsOp, 'id')\n\n var ncsName = 'NCS'\n biomolDict[ ncsName ] = new Assembly(ncsName)\n var ncsPart = biomolDict[ ncsName ].addPart()\n\n ncsOp.id.forEach(function (id: string, i: number) {\n // ignore 'given' operators\n if (ncsOp.code[ i ] === 'given') return\n\n var m = new Matrix4()\n var elms = m.elements\n\n elms[ 0 ] = parseFloat(ncsOp[ 'matrix[1][1]' ][ i ])\n elms[ 1 ] = parseFloat(ncsOp[ 'matrix[1][2]' ][ i ])\n elms[ 2 ] = parseFloat(ncsOp[ 'matrix[1][3]' ][ i ])\n\n elms[ 4 ] = parseFloat(ncsOp[ 'matrix[2][1]' ][ i ])\n elms[ 5 ] = parseFloat(ncsOp[ 'matrix[2][2]' ][ i ])\n elms[ 6 ] = parseFloat(ncsOp[ 'matrix[2][3]' ][ i ])\n\n elms[ 8 ] = parseFloat(ncsOp[ 'matrix[3][1]' ][ i ])\n elms[ 9 ] = parseFloat(ncsOp[ 'matrix[3][2]' ][ i ])\n elms[ 10 ] = parseFloat(ncsOp[ 'matrix[3][3]' ][ i ])\n\n elms[ 3 ] = parseFloat(ncsOp[ 'vector[1]' ][ i ])\n elms[ 7 ] = parseFloat(ncsOp[ 'vector[2]' ][ i ])\n elms[ 11 ] = parseFloat(ncsOp[ 'vector[3]' ][ i ])\n\n m.transpose()\n\n ncsPart.matrixList.push(m)\n })\n\n if (ncsPart.matrixList.length === 0) {\n delete biomolDict[ ncsName ]\n }\n }\n\n // cell & symmetry\n const unitcellDict: {\n a?: number\n b?: number\n c?: number\n alpha?: number\n beta?: number\n gamma?: number\n spacegroup?: string\n origx?: Matrix4\n scale?: Matrix4\n } = {}\n\n if (cif.cell) {\n const cell = cif.cell\n\n const a = parseFloat(cell.length_a)\n const b = parseFloat(cell.length_b)\n const c = parseFloat(cell.length_c)\n\n const box = new Float32Array(9)\n box[ 0 ] = a\n box[ 4 ] = b\n box[ 8 ] = c\n structure.boxes.push(box)\n\n unitcellDict.a = a\n unitcellDict.b = b\n unitcellDict.c = c\n unitcellDict.alpha = parseFloat(cell.angle_alpha)\n unitcellDict.beta = parseFloat(cell.angle_beta)\n unitcellDict.gamma = parseFloat(cell.angle_gamma)\n }\n\n if (cif.symmetry) {\n unitcellDict.spacegroup = trimQuotes(\n cif.symmetry[ 'space_group_name_H-M' ]\n )\n }\n\n // origx\n var origx = new Matrix4()\n\n if (cif.database_PDB_matrix) {\n var origxMat = cif.database_PDB_matrix\n var origxElms = origx.elements\n\n origxElms[ 0 ] = parseFloat(origxMat[ 'origx[1][1]' ])\n origxElms[ 1 ] = parseFloat(origxMat[ 'origx[1][2]' ])\n origxElms[ 2 ] = parseFloat(origxMat[ 'origx[1][3]' ])\n\n origxElms[ 4 ] = parseFloat(origxMat[ 'origx[2][1]' ])\n origxElms[ 5 ] = parseFloat(origxMat[ 'origx[2][2]' ])\n origxElms[ 6 ] = parseFloat(origxMat[ 'origx[2][3]' ])\n\n origxElms[ 8 ] = parseFloat(origxMat[ 'origx[3][1]' ])\n origxElms[ 9 ] = parseFloat(origxMat[ 'origx[3][2]' ])\n origxElms[ 10 ] = parseFloat(origxMat[ 'origx[3][3]' ])\n\n origxElms[ 3 ] = parseFloat(origxMat[ 'origx_vector[1]' ])\n origxElms[ 7 ] = parseFloat(origxMat[ 'origx_vector[2]' ])\n origxElms[ 11 ] = parseFloat(origxMat[ 'origx_vector[3]' ])\n\n origx.transpose()\n\n unitcellDict.origx = origx\n }\n\n // scale\n var scale = new Matrix4()\n\n if (cif.atom_sites) {\n var scaleMat = cif.atom_sites\n var scaleElms = scale.elements\n\n scaleElms[ 0 ] = parseFloat(scaleMat[ 'fract_transf_matrix[1][1]' ])\n scaleElms[ 1 ] = parseFloat(scaleMat[ 'fract_transf_matrix[1][2]' ])\n scaleElms[ 2 ] = parseFloat(scaleMat[ 'fract_transf_matrix[1][3]' ])\n\n scaleElms[ 4 ] = parseFloat(scaleMat[ 'fract_transf_matrix[2][1]' ])\n scaleElms[ 5 ] = parseFloat(scaleMat[ 'fract_transf_matrix[2][2]' ])\n scaleElms[ 6 ] = parseFloat(scaleMat[ 'fract_transf_matrix[2][3]' ])\n\n scaleElms[ 8 ] = parseFloat(scaleMat[ 'fract_transf_matrix[3][1]' ])\n scaleElms[ 9 ] = parseFloat(scaleMat[ 'fract_transf_matrix[3][2]' ])\n scaleElms[ 10 ] = parseFloat(scaleMat[ 'fract_transf_matrix[3][3]' ])\n\n scaleElms[ 3 ] = parseFloat(scaleMat[ 'fract_transf_vector[1]' ])\n scaleElms[ 7 ] = parseFloat(scaleMat[ 'fract_transf_vector[2]' ])\n scaleElms[ 11 ] = parseFloat(scaleMat[ 'fract_transf_vector[3]' ])\n\n scale.transpose()\n\n unitcellDict.scale = scale\n }\n\n if (unitcellDict.a !== undefined) {\n structure.unitcell = new Unitcell(unitcellDict as UnitcellParams)\n } else {\n structure.unitcell = undefined\n }\n}\n\nfunction processConnections (cif: Cif, structure: Structure, asymIdDict: {[k: string]: string}) {\n // add connections\n var sc = cif.struct_conn\n\n if (sc) {\n ensureArray(sc, 'id')\n\n var reDoubleQuote = /\"/g\n var ap1 = structure.getAtomProxy()\n var ap2 = structure.getAtomProxy()\n var atomIndicesCache: {[k: string]: Uint32Array|undefined} = {}\n\n for (var i = 0, il = sc.id.length; i < il; ++i) {\n // ignore:\n // hydrog - hydrogen bond\n // mismat - mismatched base pairs\n // saltbr - ionic interaction\n\n var connTypeId = sc.conn_type_id[ i ]\n if (connTypeId === 'hydrog' ||\n connTypeId === 'mismat' ||\n connTypeId === 'saltbr') continue\n\n // ignore bonds between symmetry mates\n if (sc.ptnr1_symmetry[ i ] !== '1_555' ||\n sc.ptnr2_symmetry[ i ] !== '1_555') continue\n\n // process:\n // covale - covalent bond\n // covale_base -\n // covalent modification of a nucleotide base\n // covale_phosphate -\n // covalent modification of a nucleotide phosphate\n // covale_sugar -\n // covalent modification of a nucleotide sugar\n // disulf - disulfide bridge\n // metalc - metal coordination\n // modres - covalent residue modification\n\n var inscode1 = sc.pdbx_ptnr1_PDB_ins_code[ i ]\n var altloc1 = sc.pdbx_ptnr1_label_alt_id[ i ]\n var sele1 = (\n sc.ptnr1_auth_seq_id[ i ] +\n (hasValue(inscode1) ? ('^' + inscode1) : '') +\n ':' + asymIdDict[ sc.ptnr1_label_asym_id[ i ] ] +\n '.' + sc.ptnr1_label_atom_id[ i ].replace(reDoubleQuote, '') +\n (hasValue(altloc1) ? ('%' + altloc1) : '')\n )\n var atomIndices1 = atomIndicesCache[ sele1 ]\n if (!atomIndices1) {\n var selection1 = new Selection(sele1)\n if (selection1.selection.error) {\n if (Debug) Log.warn('invalid selection for connection', sele1)\n continue\n }\n atomIndices1 = structure.getAtomIndices(selection1)\n atomIndicesCache[ sele1 ] = atomIndices1\n }\n\n var inscode2 = sc.pdbx_ptnr2_PDB_ins_code[ i ]\n var altloc2 = sc.pdbx_ptnr2_label_alt_id[ i ]\n var sele2 = (\n sc.ptnr2_auth_seq_id[ i ] +\n (hasValue(inscode2) ? ('^' + inscode2) : '') +\n ':' + asymIdDict[ sc.ptnr2_label_asym_id[ i ] ] +\n '.' + sc.ptnr2_label_atom_id[ i ].replace(reDoubleQuote, '') +\n (hasValue(altloc2) ? ('%' + altloc2) : '')\n )\n var atomIndices2 = atomIndicesCache[ sele2 ]\n if (!atomIndices2) {\n var selection2 = new Selection(sele2)\n if (selection2.selection.error) {\n if (Debug) Log.warn('invalid selection for connection', sele2)\n continue\n }\n atomIndices2 = structure.getAtomIndices(selection2)\n atomIndicesCache[ sele2 ] = atomIndices2\n }\n\n // cases with more than one atom per selection\n // - #altloc1 to #altloc2\n // - #model to #model\n // - #altloc1 * #model to #altloc2 * #model\n\n var k = atomIndices1!.length\n var l = atomIndices2!.length\n\n if (k > l) {\n var tmpA = k\n k = l\n l = tmpA\n var tmpB = atomIndices1\n atomIndices1 = atomIndices2\n atomIndices2 = tmpB\n }\n\n // console.log( k, l );\n\n if (k === 0 || l === 0) {\n if (Debug) Log.warn('no atoms found for', sele1, sele2)\n continue\n }\n\n for (var j = 0; j < l; ++j) {\n ap1.index = atomIndices1![ j % k ]\n ap2.index = atomIndices2![ j ]\n\n if (ap1 && ap2) {\n structure.bondStore.addBond(\n ap1, ap2, getBondOrder(sc.pdbx_value_order[ i ])\n )\n } else {\n Log.log('atoms for connection not found')\n }\n }\n }\n }\n}\n\nfunction processEntities (cif: Cif, structure: Structure, chainIndexDict: {[k: string]: Set}) {\n if (cif.entity) {\n ensureArray(cif.entity, 'id')\n var e = cif.entity\n var n = e.id.length\n for (var i = 0; i < n; ++i) {\n var description = e.pdbx_description[ i ]\n var type = e.type[ i ]\n var chainIndexList: number[] = Array.from(chainIndexDict[ e.id[ i ] ])\n structure.entityList[ i ] = new Entity(\n structure, i, description, type, chainIndexList\n )\n }\n }\n}\n\n//\n\nclass CifParser extends StructureParser {\n get type () { return 'cif' }\n\n _parse () {\n // http://mmcif.wwpdb.org/\n\n Log.time('CifParser._parse ' + this.name)\n\n var s = this.structure\n var sb = this.structureBuilder\n\n var firstModelOnly = this.firstModelOnly\n var asTrajectory = this.asTrajectory\n var cAlphaOnly = this.cAlphaOnly\n\n var frames = s.frames\n var currentFrame: NumberArray, currentCoord: number\n\n var rawline, line\n\n //\n\n var cif: Cif = {}\n var asymIdDict: {[k: string]: string} = {}\n var chainIndexDict:{[k: string]: Set} = {}\n\n var pendingString = false\n var currentString: string|null = null\n var pendingValue = false\n var pendingLoop = false\n var pendingName = false\n var loopPointers: string[][] = []\n var currentLoopIndex: number|null = null\n var currentCategory: string|null = null\n var currentName: string|boolean|null = null\n var first: boolean|null = null\n var pointerNames: string[] = []\n\n var authAsymId: number, authSeqId: number, labelSeqId: number,\n labelAtomId: number, labelCompId: number, labelAsymId: number, labelEntityId: number, labelAltId: number,\n groupPDB: number, id: number, typeSymbol: number, pdbxPDBmodelNum: number, pdbxPDBinsCode: number,\n CartnX: number, CartnY: number, CartnZ: number, bIsoOrEquiv: number, occupancy: number\n\n //\n\n var atomMap = s.atomMap\n var atomStore = s.atomStore\n atomStore.resize(this.streamer.data.length / 100)\n\n var idx = 0\n var modelIdx = 0\n var modelNum: number\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (var i = _i; i < _n; ++i) {\n rawline = lines[i]\n line = rawline.trim()\n\n if ((!line && !pendingString && !pendingLoop) || line[0] === '#') {\n // Log.log( \"NEW BLOCK\" );\n\n pendingString = false\n pendingLoop = false\n pendingValue = false\n loopPointers.length = 0\n currentLoopIndex = null\n currentCategory = null\n currentName = null\n first = null\n pointerNames.length = 0\n } else if (line.substring(0, 5) === 'data_') {\n cif.data = line.substring(5).trim()\n\n // Log.log( \"DATA\", data );\n } else if (line[0] === ';') {\n if (pendingString) {\n // Log.log( \"STRING END\", currentString );\n\n if (pendingLoop) {\n if (currentLoopIndex === loopPointers.length) {\n currentLoopIndex = 0\n }\n loopPointers[ currentLoopIndex as number ].push(currentString as string);\n (currentLoopIndex as number) += 1\n } else {\n if (currentName === false) {\n cif[ currentCategory as string ] = currentString\n } else {\n cif[ currentCategory as string ][ currentName as string ] = currentString //TODO currentname can equals null\n }\n }\n\n pendingString = false\n currentString = null\n } else {\n // Log.log( \"STRING START\" );\n\n pendingString = true\n currentString = line.substring(1)\n }\n } else if (line === 'loop_') {\n // Log.log( \"LOOP START\" );\n\n pendingLoop = true\n pendingName = true\n loopPointers.length = 0\n pointerNames.length = 0\n currentLoopIndex = 0\n } else if (line[0] === '_') {\n var keyParts, category, name\n\n if (pendingLoop && !pendingName) {\n pendingLoop = false\n }\n\n if (pendingLoop) {\n // Log.log( \"LOOP KEY\", line );\n\n keyParts = line.split('.')\n category = keyParts[ 0 ].substring(1)\n name = keyParts[ 1 ]\n\n if (keyParts.length === 1) {\n name = false\n if (!cif[ category ]) cif[ category ] = []\n loopPointers.push(cif[ category ])\n } else {\n if (!cif[ category ]) cif[ category ] = {}\n if (cif[ category ][ name ]) {\n if (Debug) Log.warn(category, name, 'already exists')\n } else {\n cif[ category ][ name ] = []\n loopPointers.push(cif[ category ][ name ])\n pointerNames.push(name)\n }\n }\n\n currentCategory = category\n currentName = name\n first = true\n } else {\n var keyValuePair = line.match(reQuotedWhitespace)\n var key = keyValuePair![ 0 ]\n var value = keyValuePair![ 1 ]\n keyParts = key.split('.')\n category = keyParts[ 0 ].substring(1)\n name = keyParts[ 1 ]\n\n if (keyParts.length === 1) {\n name = false\n cif[ category ] = value\n } else {\n if (!cif[ category ]) cif[ category ] = {}\n\n if (cif[ category ][ name ]) {\n if (Debug) Log.warn(category, name, 'already exists')\n } else {\n cif[ category ][ name ] = value\n }\n }\n\n if (!value) pendingValue = true\n\n currentCategory = category\n currentName = name\n }\n } else {\n if (pendingString) {\n // Log.log( \"STRING VALUE\", line );\n\n currentString += rawline\n } else if (pendingLoop) {\n // Log.log( \"LOOP VALUE\", line );\n\n if (!line) {\n continue\n } else if (currentCategory === 'atom_site') {\n const ls = line.split(reWhitespace)\n\n if (first) {\n authAsymId = pointerNames.indexOf('auth_asym_id')\n authSeqId = pointerNames.indexOf('auth_seq_id')\n labelSeqId = pointerNames.indexOf('label_seq_id')\n labelAtomId = pointerNames.indexOf('label_atom_id')\n labelCompId = pointerNames.indexOf('label_comp_id')\n labelAsymId = pointerNames.indexOf('label_asym_id')\n labelEntityId = pointerNames.indexOf('label_entity_id')\n labelAltId = pointerNames.indexOf('label_alt_id')\n CartnX = pointerNames.indexOf('Cartn_x')\n CartnY = pointerNames.indexOf('Cartn_y')\n CartnZ = pointerNames.indexOf('Cartn_z')\n id = pointerNames.indexOf('id')\n typeSymbol = pointerNames.indexOf('type_symbol')\n groupPDB = pointerNames.indexOf('group_PDB')\n bIsoOrEquiv = pointerNames.indexOf('B_iso_or_equiv')\n pdbxPDBmodelNum = pointerNames.indexOf('pdbx_PDB_model_num')\n\n pdbxPDBinsCode = pointerNames.indexOf('pdbx_PDB_ins_code')\n occupancy = pointerNames.indexOf('occupancy')\n\n first = false\n\n modelNum = parseInt(ls[ pdbxPDBmodelNum ])\n\n if (asTrajectory) {\n currentFrame = []\n currentCoord = 0\n }\n }\n\n //\n\n const _modelNum = parseInt(ls[ pdbxPDBmodelNum ])\n\n if (modelNum !== _modelNum) {\n if (asTrajectory) {\n if (modelIdx === 0) {\n frames.push(new Float32Array(currentFrame))\n }\n\n currentFrame = new Float32Array(atomStore.count * 3)\n frames.push(currentFrame)\n currentCoord = 0\n }\n\n modelIdx += 1\n }\n\n modelNum = _modelNum\n\n if (firstModelOnly && modelIdx > 0) continue\n\n //\n\n const atomname = ls[ labelAtomId ].replace(reDoubleQuote, '')\n if (cAlphaOnly && atomname !== 'CA') continue\n\n const x = parseFloat(ls[ CartnX ])\n const y = parseFloat(ls[ CartnY ])\n const z = parseFloat(ls[ CartnZ ])\n\n if (asTrajectory) {\n const frameOffset = currentCoord * 3\n\n currentFrame[ frameOffset + 0 ] = x\n currentFrame[ frameOffset + 1 ] = y\n currentFrame[ frameOffset + 2 ] = z\n\n currentCoord += 1\n\n if (modelIdx > 0) continue\n }\n\n //\n\n const resname = ls[ labelCompId ]\n const resno = parseInt(ls[ authSeqId !== -1 ? authSeqId : labelSeqId ])\n let inscode = ls[ pdbxPDBinsCode ]\n inscode = (inscode === '?') ? '' : inscode\n const chainname = ls[ authAsymId ]\n const chainid = ls[ labelAsymId ]\n const hetero = (ls[ groupPDB ][ 0 ] === 'H')\n\n //\n\n const element = ls[ typeSymbol ]\n const bfactor = parseFloat(ls[ bIsoOrEquiv ])\n const occ = parseFloat(ls[ occupancy ])\n let altloc = ls[ labelAltId ]\n altloc = (altloc === '.') ? '' : altloc\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname, element)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = parseInt(ls[ id ])\n atomStore.bfactor[ idx ] = isNaN(bfactor) ? 0 : bfactor\n atomStore.occupancy[ idx ] = isNaN(occ) ? 0 : occ\n atomStore.altloc[ idx ] = altloc.charCodeAt(0)\n\n sb.addAtom(modelIdx, chainname, chainid, resname, resno, hetero, undefined, inscode)\n\n if (Debug) {\n // check if one-to-many (chainname-asymId) relationship is\n // actually a many-to-many mapping\n const assignedChainname = asymIdDict[ chainid ]\n if (assignedChainname !== undefined && assignedChainname !== chainname) {\n if (Debug) Log.warn(assignedChainname, chainname)\n }\n }\n // chainname mapping: label_asym_id -> auth_asym_id\n asymIdDict[ chainid ] = chainname\n\n // entity mapping: chainIndex -> label_entity_id\n const entityId = ls[ labelEntityId ]\n if (!chainIndexDict[ entityId ]) {\n chainIndexDict[ entityId ] = new Set()\n }\n chainIndexDict[ entityId ].add(s.chainStore.count - 1)\n\n idx += 1\n } else {\n const ls = line.match(reQuotedWhitespace)\n const nn = ls!.length\n\n if (currentLoopIndex === loopPointers.length) {\n currentLoopIndex = 0\n }/* else if( currentLoopIndex + nn > loopPointers.length ){\n Log.warn( \"cif parsing error, wrong number of loop data entries\", nn, loopPointers.length );\n } */\n\n for (let j = 0; j < nn; ++j) {\n loopPointers[ currentLoopIndex + j ].push(ls![ j ])\n }\n\n (currentLoopIndex) += nn\n }\n\n pendingName = false\n } else if (line[0] === \"'\" && line[line.length - 1] === \"'\") {\n // Log.log( \"NEWLINE STRING\", line );\n\n const str = line.substring(1, line.length - 1)\n\n if (currentName === false) {\n cif[ currentCategory as string ] = str\n } else {\n cif[ currentCategory as string ][ currentName as string ] = str\n }\n } else if (pendingValue) {\n // Log.log( \"NEWLINE VALUE\", line );\n\n if (currentName === false) {\n cif[ currentCategory as string ] = line\n } else {\n cif[ currentCategory as string ][ currentName as string ] = line\n }\n } else {\n if (Debug) Log.log('CifParser._parse: unknown state', line)\n }\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n if (cif.chem_comp && cif.chem_comp_atom) {\n parseChemComp(cif, s, sb)\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n assignResidueTypeBonds(s)\n } else if (cif.atom_site_type_symbol && cif.atom_site_label && cif.atom_site_fract_x) {\n parseCore(cif, s, sb)\n sb.finalize()\n s.finalizeAtoms()\n calculateBonds(s)\n s.finalizeBonds()\n // assignResidueTypeBonds( s );\n } else {\n var secStruct = processSecondaryStructure(cif, s, asymIdDict)\n processSymmetry(cif, s, asymIdDict)\n processConnections(cif, s, asymIdDict)\n processEntities(cif, s, chainIndexDict)\n\n if (cif.struct && cif.struct.title) {\n s.title = cif.struct.title.trim().replace(reTrimQuotes, '')\n }\n if (cif.entry && cif.entry.id) {\n s.id = cif.entry.id.trim().replace(reTrimQuotes, '')\n }\n\n // structure header (mimicking biojava)\n if (cif.pdbx_audit_revision_history) {\n if (cif.pdbx_audit_revision_history.revision_date) {\n ensureArray(cif.pdbx_audit_revision_history, 'revision_date')\n const dates = cif.pdbx_audit_revision_history.revision_date.filter(hasValue)\n if (dates.length) {\n s.header.releaseDate = dates[ 0 ]\n }\n }\n if (cif.pdbx_database_status.recvd_initial_deposition_date) {\n ensureArray(cif.pdbx_database_status, 'recvd_initial_deposition_date')\n const depDates = cif.pdbx_database_status.recvd_initial_deposition_date.filter(hasValue)\n if (depDates.length) {\n s.header.depositionDate = depDates[ 0 ]\n }\n }\n } else if (cif.database_PDB_rev) {\n if (cif.database_PDB_rev.date) {\n ensureArray(cif.database_PDB_rev, 'date')\n const dates = cif.database_PDB_rev.date.filter(hasValue)\n if (dates.length) {\n s.header.releaseDate = dates[ 0 ]\n }\n }\n if (cif.database_PDB_rev.date_original) {\n ensureArray(cif.database_PDB_rev, 'date_original')\n const depDates = cif.database_PDB_rev.date_original.filter(hasValue)\n if (depDates.length) {\n s.header.depositionDate = depDates[ 0 ]\n }\n }\n }\n if (cif.reflns && cif.reflns.d_resolution_high) {\n if (hasValue(cif.reflns.d_resolution_high)) {\n s.header.resolution = parseFloat(cif.reflns.d_resolution_high)\n }\n } else if (cif.refine && cif.refine.ls_d_res_high) {\n if (hasValue(cif.refine.ls_d_res_high)) {\n s.header.resolution = parseFloat(cif.refine.ls_d_res_high)\n }\n }\n if (cif.refine && cif.refine.ls_R_factor_R_free) {\n if (hasValue(cif.refine.ls_R_factor_R_free)) {\n s.header.rFree = parseFloat(cif.refine.ls_R_factor_R_free)\n }\n }\n if (cif.refine && cif.refine.ls_R_factor_R_work) {\n if (hasValue(cif.refine.ls_R_factor_R_work)) {\n s.header.rWork = parseFloat(cif.refine.ls_R_factor_R_work)\n }\n }\n if (cif.exptl && cif.exptl.method) {\n ensureArray(cif.exptl, 'method')\n s.header.experimentalMethods = cif.exptl.method.map(function (m: string) {\n return m.replace(reTrimQuotes, '')\n })\n }\n\n sb.finalize()\n s.finalizeAtoms()\n calculateBonds(s)\n s.finalizeBonds()\n\n if (!secStruct) {\n calculateSecondaryStructure(s)\n } else {\n assignSecondaryStructure(s, secStruct)\n }\n buildUnitcellAssembly(s)\n\n s.extraData.cif = cif\n }\n\n if (Debug) Log.timeEnd('CifParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('cif', CifParser)\nParserRegistry.add('mcif', CifParser)\nParserRegistry.add('mmcif', CifParser)\n\nexport default CifParser\n","/**\n * @file Gro Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport {\n calculateBonds, calculateChainnames, calculateSecondaryStructure\n} from '../structure/structure-utils'\n\nclass GroParser extends StructureParser {\n get type () { return 'gro' }\n\n _parse () {\n // http://manual.gromacs.org/current/online/gro.html\n\n if (Debug) Log.time('GroParser._parse ' + this.name)\n\n var s = this.structure\n var sb = this.structureBuilder\n\n var firstModelOnly = this.firstModelOnly\n var asTrajectory = this.asTrajectory\n var cAlphaOnly = this.cAlphaOnly\n\n var frames = s.frames\n var boxes = s.boxes\n var currentFrame: Float32Array, currentCoord: number\n\n var firstLines = this.streamer.peekLines(3)\n\n s.title = firstLines[ 0 ].trim()\n\n // determine number of decimal places\n var ndec = firstLines[ 2 ].length - firstLines[ 2 ].lastIndexOf('.') - 1\n var lpos = 5 + ndec\n var xpos = 20\n var ypos = 20 + lpos\n var zpos = 20 + 2 * lpos\n\n //\n\n var atomname, resname, resno, serial\n\n var atomCount = parseInt(firstLines[ 1 ])\n var modelLineCount = atomCount + 3\n\n var atomMap = s.atomMap\n var atomStore = s.atomStore\n atomStore.resize(atomCount)\n\n var idx = 0\n var modelIdx = 0\n var lineNo = 0\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (var i = _i; i < _n; ++i) {\n ++lineNo\n var l = lineNo - 1\n\n var line = lines[ i ]\n\n if (!line) continue\n\n if (l % modelLineCount === 0) {\n // Log.log( \"title\", line )\n\n if (asTrajectory) {\n currentFrame = new Float32Array(atomCount * 3)\n frames.push(currentFrame)\n currentCoord = 0\n }\n } else if (l % modelLineCount === 1) {\n\n // Log.log( \"atomCount\", line )\n\n } else if (l % modelLineCount === modelLineCount - 1) {\n var str = line.trim().split(/\\s+/)\n var box = new Float32Array(9)\n box[ 0 ] = parseFloat(str[ 0 ]) * 10\n box[ 4 ] = parseFloat(str[ 1 ]) * 10\n box[ 8 ] = parseFloat(str[ 2 ]) * 10\n boxes.push(box)\n\n if (firstModelOnly) {\n return true\n }\n\n modelIdx += 1\n } else {\n atomname = line.substr(10, 5).trim()\n if (cAlphaOnly && atomname !== 'CA') continue\n\n var x = parseFloat(line.substr(xpos, lpos)) * 10\n var y = parseFloat(line.substr(ypos, lpos)) * 10\n var z = parseFloat(line.substr(zpos, lpos)) * 10\n\n if (asTrajectory) {\n var j = currentCoord * 3\n\n currentFrame[ j + 0 ] = x\n currentFrame[ j + 1 ] = y\n currentFrame[ j + 2 ] = z\n\n currentCoord += 1\n\n if (l > modelLineCount) continue\n }\n\n resname = line.substr(5, 5).trim()\n resno = parseInt(line.substr(0, 5))\n serial = parseInt(line.substr(15, 5))\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = serial\n\n sb.addAtom(modelIdx, '', '', resname, resno, false, 'l')\n\n idx += 1\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n sb.finalize()\n s.finalizeAtoms()\n calculateChainnames(s)\n calculateBonds(s)\n s.finalizeBonds()\n\n calculateSecondaryStructure(s)\n\n if (Debug) Log.timeEnd('GroParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('gro', GroParser)\n\nexport default GroParser\n","/**\n * @file utf8-utils\n * @private\n * @author Alexander Rose \n * mostly copied from https://github.com/creationix/msgpack-js-browser\n * by Tim Caswell , MIT License, Copyright (c) 2013\n */\n\n\n// Encode string as utf8 into dataview at offset\nfunction utf8Write(view, offset, string) {\n var byteLength = view.byteLength;\n for(var i = 0, l = string.length; i < l; i++) {\n var codePoint = string.charCodeAt(i);\n\n // One byte of UTF-8\n if (codePoint < 0x80) {\n view.setUint8(offset++, codePoint >>> 0 & 0x7f | 0x00);\n continue;\n }\n\n // Two bytes of UTF-8\n if (codePoint < 0x800) {\n view.setUint8(offset++, codePoint >>> 6 & 0x1f | 0xc0);\n view.setUint8(offset++, codePoint >>> 0 & 0x3f | 0x80);\n continue;\n }\n\n // Three bytes of UTF-8.\n if (codePoint < 0x10000) {\n view.setUint8(offset++, codePoint >>> 12 & 0x0f | 0xe0);\n view.setUint8(offset++, codePoint >>> 6 & 0x3f | 0x80);\n view.setUint8(offset++, codePoint >>> 0 & 0x3f | 0x80);\n continue;\n }\n\n // Four bytes of UTF-8\n if (codePoint < 0x110000) {\n view.setUint8(offset++, codePoint >>> 18 & 0x07 | 0xf0);\n view.setUint8(offset++, codePoint >>> 12 & 0x3f | 0x80);\n view.setUint8(offset++, codePoint >>> 6 & 0x3f | 0x80);\n view.setUint8(offset++, codePoint >>> 0 & 0x3f | 0x80);\n continue;\n }\n throw new Error(\"bad codepoint \" + codePoint);\n }\n}\n\nfunction utf8ByteCount(string) {\n var count = 0;\n for(var i = 0, l = string.length; i < l; i++) {\n var codePoint = string.charCodeAt(i);\n if (codePoint < 0x80) {\n count += 1;\n continue;\n }\n if (codePoint < 0x800) {\n count += 2;\n continue;\n }\n if (codePoint < 0x10000) {\n count += 3;\n continue;\n }\n if (codePoint < 0x110000) {\n count += 4;\n continue;\n }\n throw new Error(\"bad codepoint \" + codePoint);\n }\n return count;\n}\n\n/**\n * encode data value (recursively) into binary encoded MessagePack v5 (http://msgpack.org/)\n * @param {Object|Array|String|Number|Boolean|null} value [description]\n * @param {DataView} view [description]\n * @param {Integer} offset [description]\n * @return {Integer} number of bytes written into view\n */\nfunction encode$1(value, view, offset) {\n var type = typeof value;\n\n // Strings Bytes\n if (type === \"string\") {\n var length = utf8ByteCount(value);\n // fix str\n if (length < 0x20) {\n view.setUint8(offset, length | 0xa0);\n utf8Write(view, offset + 1, value);\n return 1 + length;\n }\n // str 8\n if (length < 0x100) {\n view.setUint8(offset, 0xd9);\n view.setUint8(offset + 1, length);\n utf8Write(view, offset + 2, value);\n return 2 + length;\n }\n // str 16\n if (length < 0x10000) {\n view.setUint8(offset, 0xda);\n view.setUint16(offset + 1, length);\n utf8Write(view, offset + 3, value);\n return 3 + length;\n }\n // str 32\n if (length < 0x100000000) {\n view.setUint8(offset, 0xdb);\n view.setUint32(offset + 1, length);\n utf8Write(view, offset + 5, value);\n return 5 + length;\n }\n }\n\n if (value instanceof Uint8Array) {\n var length = value.byteLength;\n var bytes = new Uint8Array(view.buffer);\n // bin 8\n if (length < 0x100) {\n view.setUint8(offset, 0xc4);\n view.setUint8(offset + 1, length);\n bytes.set(value, offset + 2);\n return 2 + length;\n }\n // bin 16\n if (length < 0x10000) {\n view.setUint8(offset, 0xc5);\n view.setUint16(offset + 1, length);\n bytes.set(value, offset + 3);\n return 3 + length;\n }\n // bin 32\n if (length < 0x100000000) {\n view.setUint8(offset, 0xc6);\n view.setUint32(offset + 1, length);\n bytes.set(value, offset + 5);\n return 5 + length;\n }\n }\n\n if (type === \"number\") {\n if (!isFinite(value)) {\n throw new Error(\"Number not finite: \" + value);\n }\n\n // Floating point\n if (Math.floor(value) !== value) {\n view.setUint8(offset, 0xcb);\n view.setFloat64(offset + 1, value);\n return 9;\n }\n\n // Integers\n if (value >=0) {\n // positive fixnum\n if (value < 0x80) {\n view.setUint8(offset, value);\n return 1;\n }\n // uint 8\n if (value < 0x100) {\n view.setUint8(offset, 0xcc);\n view.setUint8(offset + 1, value);\n return 2;\n }\n // uint 16\n if (value < 0x10000) {\n view.setUint8(offset, 0xcd);\n view.setUint16(offset + 1, value);\n return 3;\n }\n // uint 32\n if (value < 0x100000000) {\n view.setUint8(offset, 0xce);\n view.setUint32(offset + 1, value);\n return 5;\n }\n throw new Error(\"Number too big 0x\" + value.toString(16));\n }\n // negative fixnum\n if (value >= -0x20) {\n view.setInt8(offset, value);\n return 1;\n }\n // int 8\n if (value >= -0x80) {\n view.setUint8(offset, 0xd0);\n view.setInt8(offset + 1, value);\n return 2;\n }\n // int 16\n if (value >= -0x8000) {\n view.setUint8(offset, 0xd1);\n view.setInt16(offset + 1, value);\n return 3;\n }\n // int 32\n if (value >= -0x80000000) {\n view.setUint8(offset, 0xd2);\n view.setInt32(offset + 1, value);\n return 5;\n }\n throw new Error(\"Number too small -0x\" + (-value).toString(16).substr(1));\n }\n\n // null\n if (value === null) {\n view.setUint8(offset, 0xc0);\n return 1;\n }\n\n // Boolean\n if (type === \"boolean\") {\n view.setUint8(offset, value ? 0xc3 : 0xc2);\n return 1;\n }\n\n // Container Types\n if (type === \"object\") {\n var length, size = 0;\n var isArray = Array.isArray(value);\n\n if (isArray) {\n length = value.length;\n }\n else {\n var keys = Object.keys(value);\n length = keys.length;\n }\n\n var size;\n if (length < 0x10) {\n view.setUint8(offset, length | (isArray ? 0x90 : 0x80));\n size = 1;\n }\n else if (length < 0x10000) {\n view.setUint8(offset, isArray ? 0xdc : 0xde);\n view.setUint16(offset + 1, length);\n size = 3;\n }\n else if (length < 0x100000000) {\n view.setUint8(offset, isArray ? 0xdd : 0xdf);\n view.setUint32(offset + 1, length);\n size = 5;\n }\n\n if (isArray) {\n for (var i = 0; i < length; i++) {\n size += encode$1(value[i], view, offset + size);\n }\n }\n else {\n for (var i = 0; i < length; i++) {\n var key = keys[i];\n size += encode$1(key, view, offset + size);\n size += encode$1(value[key], view, offset + size);\n }\n }\n\n return size;\n }\n throw new Error(\"Unknown type \" + type);\n}\n\nfunction encodedSize(value) {\n var type = typeof value;\n\n // Raw Bytes\n if (type === \"string\") {\n var length = utf8ByteCount(value);\n if (length < 0x20) {\n return 1 + length;\n }\n if (length < 0x100) {\n return 2 + length;\n }\n if (length < 0x10000) {\n return 3 + length;\n }\n if (length < 0x100000000) {\n return 5 + length;\n }\n }\n\n if (value instanceof Uint8Array) {\n var length = value.byteLength;\n if (length < 0x100) {\n return 2 + length;\n }\n if (length < 0x10000) {\n return 3 + length;\n }\n if (length < 0x100000000) {\n return 5 + length;\n }\n }\n\n if (type === \"number\") {\n // Floating Point\n // double\n if (Math.floor(value) !== value) return 9;\n\n // Integers\n if (value >=0) {\n // positive fixnum\n if (value < 0x80) return 1;\n // uint 8\n if (value < 0x100) return 2;\n // uint 16\n if (value < 0x10000) return 3;\n // uint 32\n if (value < 0x100000000) return 5;\n throw new Error(\"Number too big 0x\" + value.toString(16));\n }\n // negative fixnum\n if (value >= -0x20) return 1;\n // int 8\n if (value >= -0x80) return 2;\n // int 16\n if (value >= -0x8000) return 3;\n // int 32\n if (value >= -0x80000000) return 5;\n throw new Error(\"Number too small -0x\" + value.toString(16).substr(1));\n }\n\n // Boolean, null\n if (type === \"boolean\" || value === null) return 1;\n\n // Container Types\n if (type === \"object\") {\n var length, size = 0;\n if (Array.isArray(value)) {\n length = value.length;\n for (var i = 0; i < length; i++) {\n size += encodedSize(value[i]);\n }\n }\n else {\n var keys = Object.keys(value);\n length = keys.length;\n for (var i = 0; i < length; i++) {\n var key = keys[i];\n size += encodedSize(key) + encodedSize(value[key]);\n }\n }\n if (length < 0x10) {\n return 1 + size;\n }\n if (length < 0x10000) {\n return 3 + size;\n }\n if (length < 0x100000000) {\n return 5 + size;\n }\n throw new Error(\"Array or object too long 0x\" + length.toString(16));\n }\n throw new Error(\"Unknown type \" + type);\n}\n\nfunction encodeMsgpack(value) {\n var buffer = new ArrayBuffer(encodedSize(value));\n var view = new DataView(buffer);\n encode$1(value, view, 0);\n return new Uint8Array(buffer);\n}\n\n/**\n * @file mmtf-constants\n * @private\n * @author Alexander Rose \n */\n\n\nvar PassThroughFields = [\n \"mmtfVersion\", \"mmtfProducer\",\n \"unitCell\", \"spaceGroup\", \"structureId\", \"title\",\n \"depositionDate\", \"releaseDate\",\n \"experimentalMethods\", \"resolution\", \"rFree\", \"rWork\",\n \"bioAssemblyList\", \"ncsOperatorList\", \"entityList\", \"groupList\",\n \"numBonds\", \"numAtoms\", \"numGroups\", \"numChains\", \"numModels\",\n \"groupsPerChain\", \"chainsPerModel\",\n];\n\nvar EncodedFields = [\n\t// required\n \"xCoordList\", \"yCoordList\", \"zCoordList\",\n \"groupIdList\", \"groupTypeList\",\n \"chainIdList\",\n // optional\n \"bFactorList\", \"atomIdList\", \"altLocList\", \"occupancyList\",\n \"secStructList\", \"insCodeList\", \"sequenceIndexList\",\n \"chainNameList\",\n \"bondAtomList\", \"bondOrderList\"\n];\n\nvar AllFields = PassThroughFields.concat( EncodedFields );\n\n/**\n * @file mmtf-utils\n * @private\n * @author Alexander Rose \n */\n\n/**\n * mmtf utils module.\n * @module MmtfUtils\n */\n\n\nfunction getView( ctor, typedArray, elemSize ){\n return typedArray ? new ctor(\n typedArray.buffer,\n typedArray.byteOffset,\n typedArray.byteLength / ( elemSize || 1 )\n ) : undefined;\n}\n\nfunction getDataView( typedArray ){\n return getView( DataView, typedArray );\n}\n\n/**\n * get an Uint8Array view on the input array memory\n * @static\n * @param {TypedArray} dataArray - input array\n * @return {Uint8Array} new view on the input array memory\n */\nfunction getUint8View( typedArray ){\n return getView( Uint8Array, typedArray );\n}\n\n/**\n * get an Int8Array view on the input array memory\n * @static\n * @param {TypedArray} dataArray - input array\n * @return {Int8Array} new view on the input array memory\n */\nfunction getInt8View( typedArray ){\n return getView( Int8Array, typedArray );\n}\n\n/**\n * get an Int32Array view on the input array memory\n * @static\n * @param {TypedArray} dataArray - input array\n * @return {Int32Array} new view on the input array memory\n */\nfunction getInt32View( typedArray ){\n return getView( Int32Array, typedArray, 4 );\n}\n\nfunction getFloat32View( typedArray ){\n return getView( Float32Array, typedArray, 4 );\n}\n\n\n/**\n * get an Int16Array copy of the the input array data\n * @static\n * @param {TypedArray} view - input data in big endian format\n * @param {Int16Array} [dataArray] - pre-allocated output array\n * @return {Int16Array} copy of the input array data\n */\nfunction decodeInt16( bytes, output ){\n var n = bytes.length / 2;\n if( !output ) output = new Int16Array( n );\n for( var i = 0, i2 = 0; i < n; ++i, i2 += 2 ){\n output[ i ] = bytes[ i2 ] << 8 ^ bytes[ i2 + 1 ] << 0;\n }\n return output;\n}\n\n/**\n * make big endian buffer of an int16 array\n * @static\n * @param {Array|TypedArray} array - array of int16 values\n * @return {ArrayBuffer} big endian buffer\n */\nfunction encodeInt16( array, output ){\n var n = array.length;\n if( !output ) output = new Uint8Array( 2 * n );\n var dv = getDataView( output );\n for( var i = 0; i < n; ++i ){\n dv.setInt16( 2 * i, array[ i ] );\n }\n return getUint8View( output );\n}\n\n/**\n * get an Int32Array copy of the the input array data\n * @static\n * @param {TypedArray} view - input data in big endian format\n * @param {Int32Array} [dataArray] - pre-allocated output array\n * @return {Int32Array} copy of the input array data\n */\nfunction decodeInt32( bytes, output ){\n var n = bytes.length / 4;\n if( !output ) output = new Int32Array( n );\n for( var i = 0, i4 = 0; i < n; ++i, i4 += 4 ){\n output[ i ] = (\n bytes[ i4 ] << 24 ^ bytes[ i4 + 1 ] << 16 ^\n bytes[ i4 + 2 ] << 8 ^ bytes[ i4 + 3 ] << 0\n );\n }\n return output;\n}\n\n/**\n * make big endian buffer of an int32 array\n * @static\n * @param {Array|TypedArray} array - array of int32 values\n * @return {ArrayBuffer} big endian buffer\n */\nfunction encodeInt32( array, output ){\n var n = array.length;\n if( !output ) output = new Uint8Array( 4 * n );\n var dv = getDataView( output );\n for( var i = 0; i < n; ++i ){\n dv.setInt32( 4 * i, array[ i ] );\n }\n return getUint8View( output );\n}\n\nfunction decodeFloat32( bytes, output ){\n var n = bytes.length;\n if( !output ) output = new Float32Array( n / 4 );\n var dvOut = getDataView( output );\n var dvIn = getDataView( bytes );\n for( var i = 0, i4 = 0, il = n / 4; i < il; ++i, i4 += 4 ){\n dvOut.setFloat32( i4, dvIn.getFloat32( i4 ), true );\n }\n return output;\n}\n\n/**\n * decode integers into floats using given divisor\n * example:\n * intArray: [ 12, 34, 543, 687, 2, 0, 4689 ]\n * divisor: 100\n * return: [ 0.12, 0.34, 5.43, 6.87, 0.02, 0.00, 46.89 ]\n * @static\n * @param {TypedArray|Array} intArray - input array containing integers\n * @param {Number} divisor - number to devide the integers to obtain floats\n * @param {Float32Array} [dataArray] - pre-allocated output array\n * @return {Float32Array} decoded array\n */\nfunction decodeInteger( intArray, divisor, output ){\n var n = intArray.length;\n var invDiv = 1/divisor;\n if( !output ) output = new Float32Array( n );\n for( var i = 0; i < n; ++i ){\n // multiply by inverse of the divisor which is faster then division\n output[ i ] = intArray[ i ] * invDiv;\n }\n return output;\n}\n\nfunction encodeInteger( floatArray, factor, output ){\n var n = floatArray.length;\n if( !output ) output = new Int32Array( n );\n for( var i = 0; i < n; ++i ){\n output[ i ] = Math.round( floatArray[ i ] * factor );\n }\n return output;\n}\n\n\n\n/**\n * perform run-length decoding of input array\n * example:\n * array: [ 0, 2, 3, 5 ] // pairs of values and length of a run\n * return: [ 0, 0, 3, 3, 3, 3, 3 ]\n * @static\n * @param {TypedArray|Array} array - run-length encoded input array\n * @param {TypedArray|Array} [dataArray] - pre-allocated output array\n * @return {TypedArray|Array} decoded array\n */\nfunction decodeRun( array, output ){\n var i, il;\n if( !output ){\n // calculate the length the decoded array will have\n var fullLength = 0;\n for( i = 0, il = array.length; i < il; i+=2 ){\n fullLength += array[ i + 1 ];\n }\n // create a new array of the same type of the input array\n output = new array.constructor( fullLength );\n }\n var dataOffset = 0;\n for( i = 0, il = array.length; i < il; i+=2 ){\n var value = array[ i ]; // value to be repeated\n var length = array[ i + 1 ]; // number of repeats\n for( var j = 0; j < length; ++j ){\n output[ dataOffset ] = value;\n ++dataOffset;\n }\n }\n return output;\n}\n\nfunction encodeRun( array ){\n if( array.length === 0 ) return new Int32Array();\n var i, il;\n // calculate output size\n var fullLength = 2;\n for( i = 1, il = array.length; i < il; ++i ){\n if( array[ i - 1 ] !== array[ i ] ){\n fullLength += 2;\n }\n }\n var output = new Int32Array( fullLength );\n var offset = 0;\n var runLength = 1;\n for( i = 1, il = array.length; i < il; ++i ){\n if( array[ i - 1 ] !== array[ i ] ){\n output[ offset ] = array[ i - 1 ];\n output[ offset + 1 ] = runLength;\n runLength = 1;\n offset += 2;\n }else{\n ++runLength;\n }\n }\n output[ offset ] = array[ array.length - 1 ];\n output[ offset + 1 ] = runLength;\n return output;\n}\n\n\n\n/**\n * perform delta decoding of the input array\n * by iterativly adding the ith element's value to the i+1th\n * example:\n * dataArray: [ 0, 2, 1, 2, 1, 1, -4, -2, 9 ]\n * return: [ 0, 2, 3, 5, 6, 7, 3, 1, 10 ]\n * @static\n * @param {TypedArray|Array} dataArray - delta encoded input array\n * @return {TypedArray|Array} decoded array\n */\nfunction decodeDelta( array, output ){\n var n = array.length;\n if( !output ) output = new array.constructor( n );\n if( n ) output[ 0 ] = array[ 0 ];\n for( var i = 1; i < n; ++i ){\n output[ i ] = array[ i ] + output[ i - 1 ];\n }\n return output;\n}\n\nfunction encodeDelta( array, output ){\n var n = array.length;\n if( !output ) output = new array.constructor( n );\n output[ 0 ] = array[ 0 ];\n for( var i = 1; i < n; ++i ){\n output[ i ] = array[ i ] - array[ i - 1 ];\n }\n return output;\n}\n\n\n\n/**\n * [decodePacking description]\n * @param {Int16Array|Int8Array} int16or8 [description]\n * @param {Int32Array} output [description]\n * @return {Int32Array} [description]\n */\nfunction decodePacking( int16or8, output ){\n var upperLimit = int16or8 instanceof Int8Array ? 0x7F : 0x7FFF;\n var lowerLimit = -upperLimit - 1;\n var n = int16or8.length;\n var i, j;\n if( !output ){\n var fullLength = 0;\n for( i = 0; i < n; ++i ){\n if( int16or8[ i ] < upperLimit && int16or8[ i ] > lowerLimit ){\n ++fullLength;\n }\n }\n output = new Int32Array( fullLength );\n }\n i = 0;\n j = 0;\n while( i < n ){\n var value = 0;\n while( int16or8[ i ] === upperLimit || int16or8[ i ] === lowerLimit ){\n value += int16or8[ i ];\n ++i;\n }\n value += int16or8[ i ];\n ++i;\n output[ j ] = value;\n ++j;\n }\n return output;\n}\n\n/**\n * integer packing using recursive indexing\n * @param {Array|TyepedArray} intArray [description]\n * @param {Boolean} useInt8 [description]\n * @return {Int16Array|Int8Array} [description]\n */\nfunction encodePacking( intArray, useInt8 ){\n var upperLimit = useInt8 ? 0x7F : 0x7FFF;\n var lowerLimit = -upperLimit - 1;\n var i;\n var n = intArray.length;\n var size = 0;\n for( i = 0; i < n; ++i ){\n var value = intArray[ i ];\n if( value === 0 ){\n ++size;\n }else if( value === upperLimit || value === lowerLimit ){\n size += 2;\n }else if( value > 0) {\n size += Math.ceil( value / upperLimit );\n }else {\n size += Math.ceil( value / lowerLimit );\n }\n }\n var output = useInt8 ? new Int8Array( size ) : new Int16Array( size );\n var j = 0;\n for( i = 0; i < n; ++i ){\n var value = intArray[ i ];\n if( value >= 0) {\n while( value >= upperLimit ){\n output[ j ] = upperLimit;\n ++j;\n value -= upperLimit;\n }\n }else{\n while( value <= lowerLimit ){\n output[ j ] = lowerLimit;\n ++j;\n value -= lowerLimit;\n }\n }\n output[ j ] = value;\n ++j;\n }\n return output;\n}\n\n\n\nfunction decodeDeltaRun( array, output ){\n return decodeDelta( decodeRun( array ), output );\n}\n\nfunction encodeDeltaRun( array ){\n return encodeRun( encodeDelta( array ) );\n}\n\n\n\n/**\n * perform run-length decoding followed (@see decodeRunLength)\n * by decoding integers into floats using given divisor (@see decodeIntegerToFloat)\n * example:\n * array: [ 320, 3, 100, 2 ]\n * divisor: 100\n * return: [ 3.20, 3.20, 3.20, 1.00, 1.00 ]\n * @static\n * @param {Uint8Array} array - run-length encoded int32 array as bytes in big endian format\n * @param {Integer} divisor - number to devide the integers to obtain floats\n * @param {Float32Array} dataArray - pre-allocated output array\n * @return {Float32Array} decoded array\n */\nfunction decodeIntegerRun( intArray, divisor, output ){\n return decodeInteger(\n decodeRun( intArray, getInt32View( output ) ), divisor, output\n );\n}\n\nfunction encodeIntegerRun( floatArray, factor ){\n return encodeRun( encodeInteger( floatArray, factor ) );\n}\n\n\n\nfunction decodeIntegerDelta( intArray, divisor, output ){\n return decodeInteger(\n decodeDelta( intArray, getInt32View( output ) ), divisor, output\n );\n}\n\nfunction encodeIntegerDelta( floatArray, factor, output ){\n return encodeDelta( encodeInteger( floatArray, factor ), output );\n}\n\n\n\nfunction decodeIntegerPacking( int16or8, divisor, output ){\n return decodeInteger(\n decodePacking( int16or8, getInt32View( output ) ), divisor, output\n );\n}\n\nfunction decodeIntegerDeltaPacking( int16or8, divisor, output ){\n var unpacked = decodePacking( int16or8, getInt32View( output ) );\n return decodeIntegerDelta( unpacked, divisor, getFloat32View( unpacked ) );\n}\n\nfunction encodeIntegerDeltaPacking( floatArray, factor, useInt8 ){\n return encodePacking( encodeIntegerDelta( floatArray, factor ), useInt8 );\n}\n\n\n\nfunction decodeBytes( bytes ){\n var dv = getDataView( bytes );\n var type = dv.getInt32( 0 );\n var size = dv.getInt32( 4 );\n var param = bytes.subarray( 8, 12 );\n var bytes = bytes.subarray( 12 );\n return [ type, bytes, size, param ];\n}\n\nfunction encodeBytes( type, size, param, bytes ){\n var buffer = new ArrayBuffer( 12 + bytes.byteLength );\n var out = new Uint8Array( buffer );\n var dv = new DataView( buffer );\n dv.setInt32( 0, type );\n dv.setInt32( 4, size );\n if( param ) out.set( param, 8 );\n out.set( bytes, 12 );\n return out;\n}\n\nfunction passInt8( int8 ){\n var size = int8.length;\n var bytes = getUint8View( int8 );\n return encodeBytes( 2, size, undefined, bytes );\n}\n\nfunction passInt32( int32 ){\n var size = int32.length;\n var bytes = encodeInt32( int32 );\n return encodeBytes( 4, size, undefined, bytes );\n}\n\nfunction passString( stringBytes, length ){\n var size = stringBytes.length / length;\n var param = encodeInt32([ length ]);\n var bytes = getUint8View( stringBytes );\n return encodeBytes( 5, size, param, bytes );\n}\n\nfunction runChar( charBytes ){\n var size = charBytes.length;\n var bytes = encodeInt32( encodeRun( charBytes ) );\n return encodeBytes( 6, size, undefined, bytes );\n}\n\nfunction deltaRun( int32 ){\n var size = int32.length;\n var bytes = encodeInt32( encodeDeltaRun( int32 ) );\n return encodeBytes( 8, size, undefined, bytes );\n}\n\nfunction integerRun( float32, factor ){\n var size = float32.length;\n var param = encodeInt32([ factor ]);\n var bytes = encodeInt32( encodeIntegerRun( float32, factor ) );\n return encodeBytes( 9, size, param, bytes );\n}\n\nfunction integerDeltaPacking16( float32, factor ){\n var size = float32.length;\n var param = encodeInt32([ factor ]);\n var bytes = encodeInt16( encodeIntegerDeltaPacking( float32, factor ) );\n return encodeBytes( 10, size, param, bytes );\n}\n\nfunction encodeMmtf( inputDict ){\n\n var outputDict = {};\n\n // copy some fields over from the input dict\n PassThroughFields.forEach( function( name ){\n if( inputDict[ name ] !== undefined ){\n outputDict[ name ] = inputDict[ name ];\n }\n } );\n\n //////////////\n // bond data\n\n // encode inter group bond atom indices, i.e. get bytes in big endian order\n if( inputDict.bondAtomList ){\n outputDict.bondAtomList = passInt32( inputDict.bondAtomList );\n }\n\n // encode inter group bond orders, i.e. get bytes\n if( inputDict.bondOrderList ){\n outputDict.bondOrderList = passInt8( inputDict.bondOrderList );\n }\n\n //////////////\n // atom data\n\n // split-list delta & integer encode x, y, z atom coords\n outputDict.xCoordList = integerDeltaPacking16( inputDict.xCoordList, 1000 );\n outputDict.yCoordList = integerDeltaPacking16( inputDict.yCoordList, 1000 );\n outputDict.zCoordList = integerDeltaPacking16( inputDict.zCoordList, 1000 );\n\n // split-list delta & integer encode b-factors\n if( inputDict.bFactorList ){\n outputDict.bFactorList = integerDeltaPacking16( inputDict.bFactorList, 100 );\n }\n\n // delta & run-length encode atom ids\n if( inputDict.atomIdList ){\n outputDict.atomIdList = deltaRun( inputDict.atomIdList );\n }\n\n // run-length encode alternate labels\n if( inputDict.altLocList ){\n outputDict.altLocList = runChar( inputDict.altLocList );\n }\n\n // run-length & integer encode occupancies\n if( inputDict.occupancyList ){\n outputDict.occupancyList = integerRun( inputDict.occupancyList, 100 );\n }\n\n ///////////////\n // group data\n\n // run-length & delta encode group numbers\n outputDict.groupIdList = deltaRun( inputDict.groupIdList );\n\n // encode group types, i.e. get int32 array\n outputDict.groupTypeList = passInt32( inputDict.groupTypeList );\n\n // encode secondary structure, i.e. get bytes\n if( inputDict.secStructList ){\n outputDict.secStructList = passInt8( inputDict.secStructList, 1 );\n }\n\n // run-length encode insertion codes\n if( inputDict.insCodeList ){\n outputDict.insCodeList = runChar( inputDict.insCodeList );\n }\n\n // run-length & delta encode sequence indices\n if( inputDict.sequenceIndexList ){\n outputDict.sequenceIndexList = deltaRun( inputDict.sequenceIndexList );\n }\n\n ///////////////\n // chain data\n\n // encode chain ids, i.e. get bytes\n outputDict.chainIdList = passString( inputDict.chainIdList, 4 );\n\n // encode chain names, i.e. get bytes\n if( inputDict.chainNameList ){\n outputDict.chainNameList = passString( inputDict.chainNameList, 4 );\n }\n\n return outputDict;\n\n}\n\n/**\n * @file msgpack-decode\n * @private\n * @author Alexander Rose \n */\n\n/**\n * msgpack decode module.\n * @module MsgpackDecode\n */\n\n/**\n * decode binary encoded MessagePack v5 (http://msgpack.org/) data\n * @static\n * @param {Uint8Array} buffer - binary encoded MessagePack data\n * @return {Object|Array|String|Number|Boolean|null} decoded Messagepack data\n */\nfunction decodeMsgpack(buffer) {\n // Loosely based on\n // The MIT License (MIT)\n // Copyright (c) 2013 Tim Caswell \n // https://github.com/creationix/msgpack-js\n var offset = 0;\n var dataView = new DataView(buffer.buffer);\n\n /**\n * decode all key-value pairs of a map into an object\n * @param {Integer} length - number of key-value pairs\n * @return {Object} decoded map\n */\n function map(length) {\n var value = {};\n for (var i = 0; i < length; i++) {\n var key = parse();\n value[key] = parse();\n }\n return value;\n }\n\n /**\n * decode binary array\n * @param {Integer} length - number of elements in the array\n * @return {Uint8Array} decoded array\n */\n function bin(length) {\n var value = buffer.subarray(offset, offset + length);\n offset += length;\n return value;\n }\n\n /**\n * decode string\n * @param {Integer} length - number string characters\n * @return {String} decoded string\n */\n function str(length) {\n var array = buffer.subarray(offset, offset + length);\n offset += length;\n // limit number of arguments to String.fromCharCode to something\n // browsers can handle, see http://stackoverflow.com/a/22747272\n var chunkSize = 0xffff;\n if(length > chunkSize){\n var c = [];\n for(var i = 0; i < array.length; i += chunkSize) {\n c.push(String.fromCharCode.apply(\n null, array.subarray(i, i + chunkSize)\n ));\n }\n return c.join(\"\");\n }else{\n return String.fromCharCode.apply(null, array);\n }\n }\n\n /**\n * decode array\n * @param {Integer} length - number of array elements\n * @return {Array} decoded array\n */\n function array(length) {\n var value = new Array(length);\n for (var i = 0; i < length; i++) {\n value[i] = parse();\n }\n return value;\n }\n\n /**\n * recursively parse the MessagePack data\n * @return {Object|Array|String|Number|Boolean|null} decoded MessagePack data\n */\n function parse() {\n var type = buffer[offset];\n var value, length, extType;\n // Positive FixInt\n if ((type & 0x80) === 0x00) {\n offset++;\n return type;\n }\n // FixMap\n if ((type & 0xf0) === 0x80) {\n length = type & 0x0f;\n offset++;\n return map(length);\n }\n // FixArray\n if ((type & 0xf0) === 0x90) {\n length = type & 0x0f;\n offset++;\n return array(length);\n }\n // FixStr\n if ((type & 0xe0) === 0xa0) {\n length = type & 0x1f;\n offset++;\n return str(length);\n }\n // Negative FixInt\n if ((type & 0xe0) === 0xe0) {\n value = dataView.getInt8(offset);\n offset++;\n return value;\n }\n switch (type) {\n // nil\n case 0xc0:\n offset++;\n return null;\n // 0xc1: (never used, could be employed for padding)\n // false\n case 0xc2:\n offset++;\n return false;\n // true\n case 0xc3:\n offset++;\n return true;\n // bin 8\n case 0xc4:\n length = dataView.getUint8(offset + 1);\n offset += 2;\n return bin(length);\n // bin 16\n case 0xc5:\n length = dataView.getUint16(offset + 1);\n offset += 3;\n return bin(length);\n // bin 32\n case 0xc6:\n length = dataView.getUint32(offset + 1);\n offset += 5;\n return bin(length);\n // // ext 8\n // case 0xc7:\n // length = dataView.getUint8(offset + 1);\n // extType = dataView.getUint8(offset + 2);\n // offset += 3;\n // return [extType, bin(length)];\n // // ext 16\n // case 0xc8:\n // length = dataView.getUint16(offset + 1);\n // extType = dataView.getUint8(offset + 3);\n // offset += 4;\n // return [extType, bin(length)];\n // // ext 32\n // case 0xc9:\n // length = dataView.getUint32(offset + 1);\n // extType = dataView.getUint8(offset + 5);\n // offset += 6;\n // return [extType, bin(length)];\n // float 32\n case 0xca:\n value = dataView.getFloat32(offset + 1);\n offset += 5;\n return value;\n // float 64\n case 0xcb:\n value = dataView.getFloat64(offset + 1);\n offset += 9;\n return value;\n // uint8\n case 0xcc:\n value = buffer[offset + 1];\n offset += 2;\n return value;\n // uint 16\n case 0xcd:\n value = dataView.getUint16(offset + 1);\n offset += 3;\n return value;\n // uint 32\n case 0xce:\n value = dataView.getUint32(offset + 1);\n offset += 5;\n return value;\n // // uint64\n // case 0xcf:\n // // FIXME not available/representable in JS\n // // largest possible int in JS is 2^53\n // // value = dataView.getUint64(offset + 1);\n // offset += 9;\n // return 0;\n // int 8\n case 0xd0:\n value = dataView.getInt8(offset + 1);\n offset += 2;\n return value;\n // int 16\n case 0xd1:\n value = dataView.getInt16(offset + 1);\n offset += 3;\n return value;\n // int 32\n case 0xd2:\n value = dataView.getInt32(offset + 1);\n offset += 5;\n return value;\n // // int 64\n // case 0xd3:\n // // FIXME not available/representable in JS\n // // largest possible int in JS is 2^53\n // // value = dataView.getInt64(offset + 1);\n // offset += 9;\n // return 0;\n\n // // fixext 1\n // case 0xd4:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(1)];\n // // fixext 2\n // case 0xd5:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(2)];\n // // fixext 4\n // case 0xd6:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(4)];\n // // fixext 8\n // case 0xd7:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(8)];\n // // fixext 16\n // case 0xd8:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(16)];\n // str 8\n case 0xd9:\n length = dataView.getUint8(offset + 1);\n offset += 2;\n return str(length);\n // str 16\n case 0xda:\n length = dataView.getUint16(offset + 1);\n offset += 3;\n return str(length);\n // str 32\n case 0xdb:\n length = dataView.getUint32(offset + 1);\n offset += 5;\n return str(length);\n // array 16\n case 0xdc:\n length = dataView.getUint16(offset + 1);\n offset += 3;\n return array(length);\n // array 32\n case 0xdd:\n length = dataView.getUint32(offset + 1);\n offset += 5;\n return array(length);\n // map 16:\n case 0xde:\n length = dataView.getUint16(offset + 1);\n offset += 3;\n return map(length);\n // map 32\n case 0xdf:\n length = dataView.getUint32(offset + 1);\n offset += 5;\n return map(length);\n }\n\n throw new Error(\"Unknown type 0x\" + type.toString(16));\n }\n\n // start the recursive parsing\n return parse();\n}\n\n/**\n * Fields shared in encoded and decoded mmtf data objects.\n * @typedef {Object} module:MmtfDecode.SharedMmtfData\n * @property {String} mmtfVersion - MMTF specification version\n * @property {String} mmtfProducer - Program that created the file\n * @property {Float[]} [unitCell] - Crystallographic unit cell\n * @property {Float} unitCell.0 - x length\n * @property {Float} unitCell.1 - y length\n * @property {Float} unitCell.2 - z length\n * @property {Float} unitCell.3 - alpha angle\n * @property {Float} unitCell.4 - beta angle\n * @property {Float} unitCell.5 - gamma angle\n * @property {String} [spaceGroup] - Hermann-Mauguin symbol\n * @property {String} [structureId] - Some reference, e.g. a PDB ID\n * @property {String} [title] - Short description\n * @property {String} [depositionDate] - Deposition date in YYYY-MM-DD format\n * @property {String} [releaseDate] - Release date in YYYY-MM-DD format\n * @property {String[]} [experimentalMethods] - Structure determination methods\n * @property {Float} [resolution] - Resolution in Å\n * @property {Float} [rFree] - R-free value\n * @property {Float} [rWork] - R-work value\n * @property {Integer} numBonds - Number of bonds\n * @property {Integer} numAtoms - Number of atoms\n * @property {Integer} numGroups - Number of groups (residues)\n * @property {Integer} numChains - Number of chains\n * @property {Integer} numModels - Number of models\n * @property {Integer[]} chainsPerModel - List of number of chains in each model\n * @property {Integer[]} groupsPerChain - List of number of groups in each chain\n * @property {Entity[]} [entityList] - List of entity objects\n * @property {Integer[]} entityList.chainIndexList - Pointers into chain data fields\n * @property {String} entityList.description - Description of the entity\n * @property {String} entityList.type - Name of the entity type\n * @property {String} entityList.sequence - One letter code sequence\n * @property {Assembly[]} [bioAssemblyList] - List of assembly objects\n * @property {Transform[]} bioAssemblyList.transformList - List of transform objects\n * @property {Integer[]} bioAssemblyList.transformList.chainIndexList - Pointers into chain data fields\n * @property {Float[]} bioAssemblyList.transformList.matrix - 4x4 transformation matrix\n * @property {Array[]} [ncsOperatorList] - List of ncs operator matrices\n * @property {Float[]} ncsOperatorList. - 4x4 transformation matrix\n * @property {GroupType[]} groupList - List of groupType objects\n * @property {Integer[]} groupList.formalChargeList - List of atom formal charges\n * @property {String[]} groupList.elementList - List of elements\n * @property {String[]} groupList.atomNameList - List of atom names\n * @property {Integer[]} groupList.bondAtomList - List of bonded atom indices\n * @property {Integer[]} groupList.bondOrderList - List of bond orders\n * @property {String} groupList.groupName - The name of the group\n * @property {String} groupList.singleLetterCode - The single letter code\n * @property {String} groupList.chemCompType - The chemical component type\n */\n\n/**\n * Encoded mmtf data object. Also includes the fields from {@link module:MmtfDecode.SharedMmtfData}. See MMTF specification on how they are encoded.\n * @typedef {Object} module:MmtfDecode.EncodedMmtfData\n * @mixes module:MmtfDecode.SharedMmtfData\n * @property {Uint8Array} [bondAtomList] - Encoded bonded atom indices\n * @property {Uint8Array} [bondOrderList] - Encoded bond orders\n * @property {Uint8Array} xCoordBig - Encoded x coordinates in Å, part 1\n * @property {Uint8Array} xCoordSmall - Encoded x coordinates in Å, part 2\n * @property {Uint8Array} yCoordBig - Encoded y coordinates in Å, part 1\n * @property {Uint8Array} yCoordSmall - Encoded y coordinates in Å, part 2\n * @property {Uint8Array} yCoordBig - Encoded y coordinates in Å, part 1\n * @property {Uint8Array} yCoordSmall - Encoded y coordinates in Å, part 2\n * @property {Uint8Array} [bFactorBig] - Encoded B-factors in Å^2, part 1\n * @property {Uint8Array} [bFactorSmall] - Encoded B-factors in Å^2, part 2\n * @property {Uint8Array} [atomIdList] - Encoded atom ids\n * @property {Uint8Array} [altLocList] - Encoded alternate location labels\n * @property {Uint8Array} [occupancyList] - Encoded occupancies\n * @property {Uint8Array} groupIdList - Encoded group ids\n * @property {Uint8Array} groupTypeList - Encoded group types\n * @property {Uint8Array} [secStructList] - Encoded secondary structure codes\n * @property {Uint8Array} [insCodeList] - Encoded insertion codes\n * @property {Uint8Array} [seuenceIdList] - Encoded sequence ids\n * @property {Uint8Array} chainIdList - Encoded chain ids\n * @property {Uint8Array} [chainNameList] - Encoded chain names\n */\n\n/**\n * Decoded mmtf data object. Also includes fields the from {@link module:MmtfDecode.SharedMmtfData}.\n * @typedef {Object} module:MmtfDecode.MmtfData\n * @mixes module:MmtfDecode.SharedMmtfData\n * @property {Int32Array} [bondAtomList] - List of bonded atom indices\n * @property {Uint8Array} [bondOrderList] - List of bond orders\n * @property {Float32Array} xCoordList - List of x coordinates in Å\n * @property {Float32Array} yCoordList - List of y coordinates in Å\n * @property {Float32Array} zCoordList - List of z coordinates in Å\n * @property {Float32Array} [bFactorList] - List of B-factors in Å^2\n * @property {Int32Array} [atomIdList] - List of atom ids\n * @property {Uint8Array} [altLocList] - List of alternate location labels\n * @property {Float32Array} [occupancyList] - List of occupancies\n * @property {Int32Array} groupIdList - List of group ids\n * @property {Int32Array} groupTypeList - List of group types\n * @property {Int8Array} [secStructList] - List of secondary structure codes, encoding\n * 0: pi helix, 1: bend, 2: alpha helix, 3: extended,\n * 4: 3-10 helix, 5: bridge, 6: turn, 7: coil, -1: undefined\n * @property {Uint8Array} [insCodeList] - List of insertion codes\n * @property {Int32Array} [seuenceIdList] - List of sequence ids\n * @property {Uint8Array} chainIdList - List of chain ids\n * @property {Uint8Array} [chainNameList] - List of chain names\n */\n\n\n/**\n * [performDecoding description]\n * @param {Integer} bytes [description]\n * @param {Integer} size [description]\n * @param {Uint8Array} param [description]\n * @return {TypedArray} [description]\n */\nfunction performDecoding( type, bytes, size, param ){\n\n switch( type ){\n case 1:\n return decodeFloat32( bytes );\n case 2:\n return getInt8View( bytes );\n case 3:\n return decodeInt16( bytes );\n case 4:\n return decodeInt32( bytes );\n case 5:\n // var length = decodeInt32( param )[ 0 ];\n return getUint8View( bytes ); // interpret as string array\n case 6:\n // interpret as char array\n return decodeRun( decodeInt32( bytes ), new Uint8Array( size ) );\n case 7:\n return decodeRun( decodeInt32( bytes ) )\n case 8:\n return decodeDeltaRun( decodeInt32( bytes ) );\n case 9:\n return decodeIntegerRun( decodeInt32( bytes ), decodeInt32( param )[ 0 ] );\n case 10:\n return decodeIntegerDeltaPacking( decodeInt16( bytes ), decodeInt32( param )[ 0 ] );\n case 11:\n return decodeInteger( decodeInt16( bytes ), decodeInt32( param )[ 0 ] );\n case 12:\n return decodeIntegerPacking( decodeInt16( bytes ), decodeInt32( param )[ 0 ] );\n case 13:\n return decodeIntegerPacking( getInt8View( bytes ), decodeInt32( param )[ 0 ] );\n case 14:\n return decodePacking( decodeInt16( bytes ) );\n case 15:\n return decodePacking( getInt8View( bytes ) );\n }\n\n};\n\n\n/**\n * Decode MMTF fields\n * @static\n * @param {Object} inputDict - encoded MMTF data\n * @param {Object} [params] - decoding parameters\n * @param {String[]} params.ignoreFields - names of optional fields not to decode\n * @return {module:MmtfDecode.MmtfData} mmtfData\n */\nfunction decodeMmtf( inputDict, params ){\n\n params = params || {};\n var ignoreFields = params.ignoreFields;\n var outputDict = {};\n\n AllFields.forEach( function( name ){\n var ignore = ignoreFields ? ignoreFields.indexOf( name ) !== -1 : false;\n var data = inputDict[ name ];\n if( !ignore && data !== undefined ){\n if( data instanceof Uint8Array ){\n outputDict[ name ] = performDecoding.apply( null, decodeBytes( data ) );\n }else{\n outputDict[ name ] = data;\n }\n }\n } );\n\n return outputDict;\n\n}\n\n/**\n * @file mmtf-traverse\n * @private\n * @author Alexander Rose \n */\n\n/**\n * mmtf traverse module.\n * @module MmtfTraverse\n */\n\n/**\n * Converts an array of ASCII codes trimming '\\0' bytes\n * @private\n * @param {Array} charCodeArray - array of ASCII char codes\n * @return {String} '\\0' trimmed string\n */\nfunction fromCharCode( charCodeArray ){\n return String.fromCharCode.apply( null, charCodeArray ).replace(/\\0/g, '');\n}\n\n\n/**\n * @callback module:MmtfTraverse.onModel\n * @param {Object} modelData\n * @param {Integer} modelData.chainCount - number of chains in the model\n * @param {Integer} modelData.modelIndex - index of the model\n */\n\n/**\n * @callback module:MmtfTraverse.onChain\n * @param {Object} chainData\n * @param {Integer} chainData.groupCount - number of groups in the chain\n * @param {Integer} chainData.chainIndex - index of the chain\n * @param {Integer} chainData.modelIndex - index of the parent model\n * @param {String} chainData.chainId - chain id\n * @param {?String} chainData.chainName - additional chain name\n */\n\n/**\n * @callback module:MmtfTraverse.onGroup\n * @param {Object} groupData\n * @param {Integer} groupData.atomCount - number of atoms in the group\n * @param {Integer} groupData.groupIndex - index of the group\n * @param {Integer} groupData.chainIndex - index of the parent chain\n * @param {Integer} groupData.modelIndex - index of the parent model\n * @param {Integer} groupData.groupId - group id (residue number)\n * @param {Integer} groupData.groupType - index to an entry in {@link module:MmtfDecode.MmtfData}#groupList\n * @param {String} groupData.groupName - name of the group, 0 to 5 characters\n * @param {Char} groupData.singleLetterCode - IUPAC single letter code, otherwise 'X', 1 character\n * @param {String} groupData.chemCompType - chemical component type from the mmCIF dictionary\n * @param {?Integer} groupData.secStruct - sencoded secondary structure |\n * 0: pi helix, 1: bend, 2: alpha helix, 3: extended,\n * 4: 3-10 helix, 5: bridge, 6: turn, 7: coil, -1: undefined\n * @param {?Char} groupData.insCode - insertion code\n * @param {?Integer} groupData.sequenceIndex - index to the `sequence` property of\n * the corresponding entity, -1 when the entity has no sequence\n */\n\n/**\n * @callback module:MmtfTraverse.onAtom\n * @param {Object} atomData\n * @param {Integer} atomData.atomIndex - index of the atom\n * @param {Integer} atomData.groupIndex - index of the parent group\n * @param {Integer} atomData.chainIndex - index of the parent chain\n * @param {Integer} atomData.modelIndex - index of the parent model\n * @param {?Integer} atomData.atomId - atom id\n * @param {String} atomData.element - IUPAC element name, 0 to 3 characters\n * @param {String} atomData.atomName - name of the atom, 0 to 5 characters\n * @param {Integer} atomData.formalCharge - formal charge of the atom\n * @param {Float} atomData.xCoord - x coordinate in Å\n * @param {Float} atomData.yCoord - y coordinate in Å\n * @param {Float} atomData.zCoord - z coordinate in Å\n * @param {?Float} atomData.bFactor - B-factor in in Å^2\n * @param {?Char} atomData.altLoc - alternate location identifier\n * @param {?Float} atomData.occupancy - occupancy of the atom\n */\n\n/**\n * @callback module:MmtfTraverse.onBond\n * @param {Object} bondData\n * @param {Integer} bondData.atomIndex1 - index of the first atom\n * @param {Integer} bondData.atomIndex2 - index of the secound atom\n * @param {Integer} bondData.bondOrder - bond order, allowed values are 1 to 3\n */\n\n\n/**\n * Traverse the MMTF structure data.\n * @static\n * @param {module:MmtfDecode.MmtfData} mmtfData - decoded mmtf data\n * @param {Object} eventCallbacks\n * @param {module:MmtfTraverse.onModel} [eventCallbacks.onModel] - called for each model\n * @param {module:MmtfTraverse.onChain} [eventCallbacks.onChain] - called for each chain\n * @param {module:MmtfTraverse.onGroup} [eventCallbacks.onGroup] - called for each group\n * @param {module:MmtfTraverse.onAtom} [eventCallbacks.onAtom] - called for each atom\n * @param {module:MmtfTraverse.onBond} [eventCallbacks.onBond] - called for each bond\n * @param {Object} [params] - traversal parameters\n * @param {Boolean} [params.firstModelOnly] - traverse only the first model\n */\nfunction traverseMmtf( mmtfData, eventCallbacks, params ){\n\n params = params || {};\n\n var firstModelOnly = params.firstModelOnly;\n\n // setup callbacks\n var onModel = eventCallbacks.onModel;\n var onChain = eventCallbacks.onChain;\n var onGroup = eventCallbacks.onGroup;\n var onAtom = eventCallbacks.onAtom;\n var onBond = eventCallbacks.onBond;\n\n // setup index counters\n var modelIndex = 0;\n var chainIndex = 0;\n var groupIndex = 0;\n var atomIndex = 0;\n\n var modelFirstAtomIndex = 0;\n var modelLastAtomIndex = -1;\n\n // setup optional fields\n var chainNameList = mmtfData.chainNameList;\n var secStructList = mmtfData.secStructList;\n var insCodeList = mmtfData.insCodeList;\n var sequenceIndexList = mmtfData.sequenceIndexList;\n var atomIdList = mmtfData.atomIdList;\n var bFactorList = mmtfData.bFactorList;\n var altLocList = mmtfData.altLocList;\n var occupancyList = mmtfData.occupancyList;\n var bondAtomList = mmtfData.bondAtomList;\n var bondOrderList = mmtfData.bondOrderList;\n\n // hoisted loop variables\n var o, ol, i, j, k, kl;\n\n // loop over all models\n for( o = 0, ol = mmtfData.chainsPerModel.length; o < ol; ++o ){\n\n if( firstModelOnly && modelIndex > 0 ) break;\n\n var modelChainCount = mmtfData.chainsPerModel[ modelIndex ];\n\n if( onModel ){\n onModel({\n chainCount: modelChainCount,\n modelIndex: modelIndex\n });\n }\n\n for( i = 0; i < modelChainCount; ++i ){\n\n var chainGroupCount = mmtfData.groupsPerChain[ chainIndex ];\n if( onChain ){\n var chainId = fromCharCode(\n mmtfData.chainIdList.subarray( chainIndex * 4, chainIndex * 4 + 4 )\n );\n var chainName = null;\n if( chainNameList ){\n chainName = fromCharCode(\n chainNameList.subarray( chainIndex * 4, chainIndex * 4 + 4 )\n );\n }\n onChain({\n groupCount: chainGroupCount,\n chainIndex: chainIndex,\n modelIndex: modelIndex,\n chainId: chainId,\n chainName: chainName\n });\n }\n\n for( j = 0; j < chainGroupCount; ++j ){\n\n var groupData = mmtfData.groupList[ mmtfData.groupTypeList[ groupIndex ] ];\n var groupAtomCount = groupData.atomNameList.length;\n if( onGroup ){\n var secStruct = null;\n if( secStructList ){\n secStruct = secStructList[ groupIndex ];\n }\n var insCode = null;\n if( mmtfData.insCodeList ){\n insCode = String.fromCharCode( insCodeList[ groupIndex ] );\n }\n var sequenceIndex = null;\n if( sequenceIndexList ){\n sequenceIndex = sequenceIndexList[ groupIndex ];\n }\n onGroup({\n atomCount: groupAtomCount,\n groupIndex: groupIndex,\n chainIndex: chainIndex,\n modelIndex: modelIndex,\n groupId: mmtfData.groupIdList[ groupIndex ],\n groupType: mmtfData.groupTypeList[ groupIndex ],\n groupName: groupData.groupName,\n singleLetterCode: groupData.singleLetterCode,\n chemCompType: groupData.chemCompType,\n secStruct: secStruct,\n insCode: insCode,\n sequenceIndex: sequenceIndex\n });\n }\n\n for( k = 0; k < groupAtomCount; ++k ){\n\n if( onAtom ){\n var atomId = null;\n if( atomIdList ){\n atomId = atomIdList[ atomIndex ];\n }\n var bFactor = null;\n if( bFactorList ){\n bFactor = bFactorList[ atomIndex ];\n }\n var altLoc = null;\n if( altLocList ){\n altLoc = String.fromCharCode( altLocList[ atomIndex ] );\n }\n var occupancy = null;\n if( occupancyList ){\n occupancy = occupancyList[ atomIndex ];\n }\n onAtom({\n atomIndex: atomIndex,\n groupIndex: groupIndex,\n chainIndex: chainIndex,\n modelIndex: modelIndex,\n atomId: atomId,\n element: groupData.elementList[ k ],\n atomName: groupData.atomNameList[ k ],\n formalCharge: groupData.formalChargeList[ k ],\n xCoord: mmtfData.xCoordList[ atomIndex ],\n yCoord: mmtfData.yCoordList[ atomIndex ],\n zCoord: mmtfData.zCoordList[ atomIndex ],\n bFactor: bFactor,\n altLoc: altLoc,\n occupancy: occupancy\n });\n }\n\n atomIndex += 1;\n }\n\n if( onBond ){\n // intra group bonds\n var groupBondAtomList = groupData.bondAtomList;\n for( k = 0, kl = groupData.bondOrderList.length; k < kl; ++k ){\n onBond({\n atomIndex1: atomIndex - groupAtomCount + groupBondAtomList[ k * 2 ],\n atomIndex2: atomIndex - groupAtomCount + groupBondAtomList[ k * 2 + 1 ],\n bondOrder: groupData.bondOrderList[ k ]\n });\n }\n }\n\n groupIndex += 1;\n }\n\n chainIndex += 1;\n }\n\n modelFirstAtomIndex = modelLastAtomIndex + 1;\n modelLastAtomIndex = atomIndex - 1; // subtract one as it already has been incremented\n\n if( onBond ){\n // inter group bonds\n if( bondAtomList ){\n for( k = 0, kl = bondAtomList.length; k < kl; k += 2 ){\n var atomIndex1 = bondAtomList[ k ];\n var atomIndex2 = bondAtomList[ k + 1 ];\n if( ( atomIndex1 >= modelFirstAtomIndex && atomIndex1 <= modelLastAtomIndex ) ||\n ( atomIndex2 >= modelFirstAtomIndex && atomIndex2 <= modelLastAtomIndex )\n ){\n onBond({\n atomIndex1: atomIndex1,\n atomIndex2: atomIndex2,\n bondOrder: bondOrderList ? bondOrderList[ k / 2 ] : null\n });\n }\n }\n }\n }\n\n modelIndex += 1;\n }\n\n}\n\n/**\n * Version name\n * @static\n * @type {String}\n */\nvar version = \"v1.1.0dev\";\n\n/**\n * Version name\n * @private\n * @type {String}\n */\nvar baseUrl = \"//mmtf.rcsb.org/v1.0/\";\n\n/**\n * URL of the RCSB webservice to obtain MMTF files\n * @static\n * @type {String}\n */\nvar fetchUrl = baseUrl + \"full/\";\n\n/**\n * URL of the RCSB webservice to obtain reduced MMTF files\n * @static\n * @type {String}\n */\nvar fetchReducedUrl = baseUrl + \"reduced/\";\n\n/**\n * Encode MMTF fields\n * @static\n * @param {module:MmtfDecode.MmtfData} mmtfData - mmtf data\n * @return {Uint8Array} encoded MMTF fields\n */\nfunction encode( mmtfData ){\n return encodeMsgpack( encodeMmtf( mmtfData ) );\n}\n\n/**\n * Decode MMTF fields\n * @static\n * @example\n * // bin is Uint8Array containing the mmtf msgpack\n * var mmtfData = MMTF.decode( bin );\n * console.log( mmtfData.numAtoms );\n *\n * @param {Uint8Array|ArrayBuffer|module:MmtfDecode.EncodedMmtfData} binOrDict - binary MessagePack or encoded MMTF data\n * @param {Object} [params] - decoding parameters\n * @param {String[]} params.ignoreFields - names of optional fields not to decode\n * @return {module:MmtfDecode.MmtfData} mmtfData\n */\nfunction decode( binOrDict, params ){\n\t// make sure binOrDict is not a plain Arraybuffer\n if( binOrDict instanceof ArrayBuffer ){\n binOrDict = new Uint8Array( binOrDict );\n }\n\n var inputDict;\n if( binOrDict instanceof Uint8Array ){\n // get dict from msgpack\n inputDict = decodeMsgpack( binOrDict );\n }else{\n // already a dict\n inputDict = binOrDict;\n }\n\n return decodeMmtf( inputDict, params );\n}\n\n/**\n * @callback module:MMTF.onLoad\n * @param {module:MmtfDecode.MmtfData} mmtfData - decoded mmtf data object\n */\n\n/**\n * helper method to fetch binary files from an URL\n * @private\n * @param {String} pdbid - PDB ID to fetch\n * @param {String} baseUrl - URL to fetch from\n * @param {module:MMTF.onLoad} onLoad - callback( mmtfData )\n * @param {Function} onError - callback( error )\n * @return {undefined}\n */\nfunction _fetch( pdbid, baseUrl, onLoad, onError ){\n var xhr = new XMLHttpRequest();\n function _onLoad(){\n try{\n var mmtfData = decode( xhr.response );\n onLoad( mmtfData );\n }catch( error ){\n onError( error );\n }\n }\n xhr.addEventListener( \"load\", _onLoad, true );\n xhr.addEventListener( \"error\", onError, true );\n xhr.responseType = \"arraybuffer\";\n xhr.open( \"GET\", baseUrl + pdbid.toUpperCase() );\n xhr.send();\n}\n\n/**\n * Fetch MMTF file from RCSB webservice which contains\n * @static\n * @example\n * MMTF.fetch(\n * \"3PQR\",\n * // onLoad callback\n * function( mmtfData ){ console.log( mmtfData ) },\n * // onError callback\n * function( error ){ console.error( error ) }\n * );\n *\n * @param {String} pdbid - PDB ID to fetch\n * @param {module:MMTF.onLoad} onLoad - callback( mmtfData )\n * @param {Function} onError - callback( error )\n * @return {undefined}\n */\nfunction fetch( pdbid, onLoad, onError ){\n _fetch( pdbid, fetchUrl, onLoad, onError );\n}\n\n/**\n * Fetch reduced MMTF file from RCSB webservice which contains\n * protein C-alpha, nucleotide phosphate and ligand atoms\n * @static\n * @example\n * MMTF.fetchReduced(\n * \"3PQR\",\n * // onLoad callback\n * function( mmtfData ){ console.log( mmtfData ) },\n * // onError callback\n * function( error ){ console.error( error ) }\n * );\n *\n * @param {String} pdbid - PDB ID to fetch\n * @param {module:MMTF.onLoad} onLoad - callback( mmtfData )\n * @param {Function} onError - callback( error )\n * @return {undefined}\n */\nfunction fetchReduced( pdbid, onLoad, onError ){\n _fetch( pdbid, fetchReducedUrl, onLoad, onError );\n}\n\nexport { encode, decode, traverseMmtf as traverse, fetch, fetchReduced, version, fetchUrl, fetchReducedUrl, encodeMsgpack, encodeMmtf, decodeMsgpack, decodeMmtf };","/**\n * @file Mmtf Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport {\n buildUnitcellAssembly, calculateBondsBetween, calculateBondsWithin\n} from '../structure/structure-utils'\nimport { ChemCompHetero } from '../structure/structure-constants'\nimport Entity from '../structure/entity'\nimport Unitcell from '../symmetry/unitcell'\nimport Assembly, { AssemblyPart } from '../symmetry/assembly'\n\nimport { decodeMsgpack, decodeMmtf } from '../../lib/mmtf.es6'\n\nconst SstrucMap: {[k: string]: number} = {\n '0': 'i'.charCodeAt(0), // pi helix\n '1': 's'.charCodeAt(0), // bend\n '2': 'h'.charCodeAt(0), // alpha helix\n '3': 'e'.charCodeAt(0), // extended\n '4': 'g'.charCodeAt(0), // 3-10 helix\n '5': 'b'.charCodeAt(0), // bridge\n '6': 't'.charCodeAt(0), // turn\n '7': 'l'.charCodeAt(0), // coil\n '-1': ''.charCodeAt(0) // NA\n}\n\nclass MmtfParser extends StructureParser {\n get type () { return 'mmtf' }\n get isBinary () { return true }\n\n _parse () {\n // https://github.com/rcsb/mmtf\n\n if (Debug) Log.time('MmtfParser._parse ' + this.name)\n\n let i, il, j, jl, groupData\n\n const s = this.structure\n const sd: {[k: string]: any} = decodeMmtf(decodeMsgpack(this.streamer.data))\n\n // structure header\n const headerFields = [\n 'depositionDate', 'releaseDate', 'resolution',\n 'rFree', 'rWork', 'experimentalMethods'\n ]\n headerFields.forEach(function (name) {\n if (sd[ name ] !== undefined) {\n s.header[ name ] = sd[ name ]\n }\n })\n\n let numBonds, numAtoms, numGroups, numChains, numModels\n let chainsPerModel\n\n s.id = sd.structureId\n s.title = sd.title\n\n s.atomStore.addField('formalCharge', 1, 'int8')\n\n if (this.firstModelOnly || this.asTrajectory) {\n numModels = 1\n numChains = sd.chainsPerModel[ 0 ]\n\n numGroups = 0\n for (i = 0, il = numChains; i < il; ++i) {\n numGroups += sd.groupsPerChain[ i ]\n }\n\n numAtoms = 0\n for (i = 0, il = numGroups; i < il; ++i) {\n groupData = sd.groupList[ sd.groupTypeList[ i ] ]\n numAtoms += groupData.atomNameList.length\n }\n\n numBonds = sd.numBonds\n\n chainsPerModel = [ numChains ]\n } else {\n numBonds = sd.numBonds\n numAtoms = sd.numAtoms\n numGroups = sd.numGroups\n numChains = sd.numChains\n numModels = sd.numModels\n\n chainsPerModel = sd.chainsPerModel\n }\n\n numBonds += numGroups // add numGroups to have space for polymer bonds\n\n //\n\n if (this.asTrajectory) {\n for (i = 0, il = sd.numModels; i < il; ++i) {\n const frame = new Float32Array(numAtoms * 3)\n const frameAtomOffset = numAtoms * i\n\n for (j = 0; j < numAtoms; ++j) {\n const j3 = j * 3\n const offset = j + frameAtomOffset\n frame[ j3 ] = sd.xCoordList[ offset ]\n frame[ j3 + 1 ] = sd.yCoordList[ offset ]\n frame[ j3 + 2 ] = sd.zCoordList[ offset ]\n }\n\n s.frames.push(frame)\n }\n }\n\n // bondStore\n const bAtomIndex1 = new Uint32Array(numBonds)\n const bAtomIndex2 = new Uint32Array(numBonds)\n const bBondOrder = new Uint8Array(numBonds)\n\n const aGroupIndex = new Uint32Array(numAtoms)\n const aFormalCharge = new Int8Array(numAtoms)\n\n const gChainIndex = new Uint32Array(numGroups)\n const gAtomOffset = new Uint32Array(numGroups)\n const gAtomCount = new Uint16Array(numGroups)\n\n const cModelIndex = new Uint16Array(numChains)\n const cGroupOffset = new Uint32Array(numChains)\n const cGroupCount = new Uint32Array(numChains)\n\n const mChainOffset = new Uint32Array(numModels)\n const mChainCount = new Uint32Array(numModels)\n\n // set-up model-chain relations\n let chainOffset = 0\n for (i = 0, il = numModels; i < il; ++i) {\n const modelChainCount = chainsPerModel[ i ]\n mChainOffset[ i ] = chainOffset\n mChainCount[ i ] = modelChainCount\n for (j = 0; j < modelChainCount; ++j) {\n cModelIndex[ j + chainOffset ] = i\n }\n chainOffset += modelChainCount\n }\n\n // set-up chain-residue relations\n const groupsPerChain = sd.groupsPerChain\n let groupOffset = 0\n for (i = 0, il = numChains; i < il; ++i) {\n const chainGroupCount = groupsPerChain[ i ]\n cGroupOffset[ i ] = groupOffset\n cGroupCount[ i ] = chainGroupCount\n for (j = 0; j < chainGroupCount; ++j) {\n gChainIndex[ j + groupOffset ] = i\n }\n groupOffset += chainGroupCount\n }\n\n /// ///\n // get data from group map\n\n let atomOffset = 0\n let bondOffset = 0\n\n for (i = 0, il = numGroups; i < il; ++i) {\n groupData = sd.groupList[ sd.groupTypeList[ i ] ]\n const groupAtomCount = groupData.atomNameList.length\n const groupFormalChargeList = groupData.formalChargeList\n\n const groupBondAtomList = groupData.bondAtomList\n const groupBondOrderList = groupData.bondOrderList\n\n for (j = 0, jl = groupBondOrderList.length; j < jl; ++j) {\n bAtomIndex1[ bondOffset ] = atomOffset + groupBondAtomList[ j * 2 ]\n bAtomIndex2[ bondOffset ] = atomOffset + groupBondAtomList[ j * 2 + 1 ]\n bBondOrder[ bondOffset ] = groupBondOrderList[ j ]\n bondOffset += 1\n }\n\n //\n\n gAtomOffset[ i ] = atomOffset\n gAtomCount[ i ] = groupAtomCount\n\n for (j = 0; j < groupAtomCount; ++j) {\n aGroupIndex[ atomOffset ] = i\n aFormalCharge[ atomOffset ] = groupFormalChargeList[ j ]\n atomOffset += 1\n }\n }\n\n // extra bonds\n\n const bondAtomList = sd.bondAtomList\n if (bondAtomList) {\n if (sd.bondOrderList) {\n bBondOrder.set(sd.bondOrderList, bondOffset)\n }\n\n for (i = 0, il = bondAtomList.length; i < il; i += 2) {\n const atomIndex1 = bondAtomList[ i ]\n const atomIndex2 = bondAtomList[ i + 1 ]\n if (atomIndex1 < numAtoms && atomIndex2 < numAtoms) {\n bAtomIndex1[ bondOffset ] = atomIndex1\n bAtomIndex2[ bondOffset ] = atomIndex2\n bondOffset += 1\n }\n }\n }\n\n //\n\n s.bondStore.length = bBondOrder.length\n s.bondStore.count = bondOffset\n s.bondStore.atomIndex1 = bAtomIndex1\n s.bondStore.atomIndex2 = bAtomIndex2\n s.bondStore.bondOrder = bBondOrder\n\n s.atomStore.length = numAtoms\n s.atomStore.count = numAtoms\n s.atomStore.residueIndex = aGroupIndex\n s.atomStore.atomTypeId = new Uint16Array(numAtoms)\n s.atomStore.x = sd.xCoordList.subarray(0, numAtoms)\n s.atomStore.y = sd.yCoordList.subarray(0, numAtoms)\n s.atomStore.z = sd.zCoordList.subarray(0, numAtoms)\n s.atomStore.serial = sd.atomIdList.subarray(0, numAtoms)\n s.atomStore.bfactor = sd.bFactorList.subarray(0, numAtoms)\n s.atomStore.altloc = sd.altLocList.subarray(0, numAtoms)\n s.atomStore.occupancy = sd.occupancyList.subarray(0, numAtoms)\n s.atomStore.formalCharge = aFormalCharge\n\n s.residueStore.length = numGroups\n s.residueStore.count = numGroups\n s.residueStore.chainIndex = gChainIndex\n s.residueStore.residueTypeId = sd.groupTypeList\n s.residueStore.atomOffset = gAtomOffset\n s.residueStore.atomCount = gAtomCount\n s.residueStore.resno = sd.groupIdList.subarray(0, numGroups)\n s.residueStore.sstruc = sd.secStructList.subarray(0, numGroups)\n s.residueStore.inscode = sd.insCodeList.subarray(0, numGroups)\n\n s.chainStore.length = numChains\n s.chainStore.count = numChains\n s.chainStore.entityIndex = new Uint16Array(numChains)\n s.chainStore.modelIndex = cModelIndex\n s.chainStore.residueOffset = cGroupOffset\n s.chainStore.residueCount = cGroupCount\n s.chainStore.chainname = sd.chainNameList.subarray(0, numChains * 4)\n s.chainStore.chainid = sd.chainIdList.subarray(0, numChains * 4)\n\n s.modelStore.length = numModels\n s.modelStore.count = numModels\n s.modelStore.chainOffset = mChainOffset\n s.modelStore.chainCount = mChainCount\n\n //\n\n let groupTypeDict: {[k: number]: any} = {}\n for (i = 0, il = sd.groupList.length; i < il; ++i) {\n const groupType = sd.groupList[ i ]\n const atomTypeIdList: number[] = []\n for (j = 0, jl = groupType.atomNameList.length; j < jl; ++j) {\n const element = groupType.elementList[ j ].toUpperCase()\n const atomname = groupType.atomNameList[ j ]\n atomTypeIdList.push(s.atomMap.add(atomname, element))\n }\n const chemCompType = groupType.chemCompType.toUpperCase()\n const hetFlag = ChemCompHetero.includes(chemCompType)\n\n const numGroupBonds = groupType.bondOrderList.length\n const atomIndices1 = new Array(numGroupBonds)\n const atomIndices2 = new Array(numGroupBonds)\n for (j = 0; j < numGroupBonds; ++j) {\n atomIndices1[ j ] = groupType.bondAtomList[ j * 2 ]\n atomIndices2[ j ] = groupType.bondAtomList[ j * 2 + 1 ]\n }\n const bonds = {\n atomIndices1: atomIndices1,\n atomIndices2: atomIndices2,\n bondOrders: groupType.bondOrderList\n }\n\n groupTypeDict[ i ] = s.residueMap.add(\n groupType.groupName, atomTypeIdList, hetFlag, chemCompType, bonds\n )\n }\n\n for (i = 0, il = numGroups; i < il; ++i) {\n s.residueStore.residueTypeId[ i ] = groupTypeDict[ s.residueStore.residueTypeId[ i ] ]\n }\n\n for (i = 0, il = s.atomStore.count; i < il; ++i) {\n const residueIndex = s.atomStore.residueIndex[ i ]\n const residueType = s.residueMap.list[ s.residueStore.residueTypeId[ residueIndex ] ]\n const resAtomOffset = s.residueStore.atomOffset[ residueIndex ]\n s.atomStore.atomTypeId[ i ] = residueType.atomTypeIdList[ i - resAtomOffset ]\n }\n\n if (sd.secStructList) {\n const secStructLength: number = sd.secStructList.length\n for (i = 0, il = s.residueStore.count; i < il; ++i) {\n // with ( i % secStructLength ) secStruct entries are reused\n const sstruc = SstrucMap[ s.residueStore.sstruc[ i % secStructLength ] ]\n if (sstruc !== undefined) s.residueStore.sstruc[ i ] = sstruc\n }\n }\n\n //\n\n if (sd.entityList) {\n sd.entityList.forEach(function (e: Entity, i: number) {\n s.entityList[ i ] = new Entity(\n s, i, e.description, e.type, e.chainIndexList\n )\n })\n }\n\n if (sd.bioAssemblyList) {\n sd.bioAssemblyList.forEach(function (_assembly: any, k: number) {\n const id = k + 1\n const assembly = new Assembly('' + id)\n s.biomolDict[ 'BU' + id ] = assembly\n let chainToPart: {[k: string]: AssemblyPart} = {}\n _assembly.transformList.forEach(function (_transform: any) {\n const matrix = new Matrix4().fromArray(_transform.matrix).transpose()\n const chainList: string[] = _transform.chainIndexList.map(function (chainIndex: number) {\n let chainname = ''\n for (let k = 0; k < 4; ++k) {\n const code = sd.chainNameList[ chainIndex * 4 + k ]\n if (code) {\n chainname += String.fromCharCode(code)\n } else {\n break\n }\n }\n return chainname\n })\n const part = chainToPart[ chainList.toString() ]\n if (part) {\n part.matrixList.push(matrix)\n } else {\n chainToPart[ chainList.toString() ] = assembly.addPart([ matrix ], chainList)\n }\n })\n })\n }\n\n if (sd.ncsOperatorList) {\n const ncsName = 'NCS'\n const ncsAssembly = new Assembly(ncsName)\n const ncsPart = ncsAssembly.addPart()\n sd.ncsOperatorList.forEach(function (_operator: number[]) {\n const matrix = new Matrix4().fromArray(_operator).transpose()\n ncsPart.matrixList.push(matrix)\n })\n if (ncsPart.matrixList.length > 0) {\n s.biomolDict[ ncsName ] = ncsAssembly\n }\n }\n\n const uc = sd.unitCell\n if (uc && Array.isArray(uc) && uc[ 0 ]) {\n s.unitcell = new Unitcell({\n a: uc[ 0 ],\n b: uc[ 1 ],\n c: uc[ 2 ],\n alpha: uc[ 3 ],\n beta: uc[ 4 ],\n gamma: uc[ 5 ],\n spacegroup: sd.spaceGroup\n })\n } else {\n s.unitcell = undefined\n }\n\n // calculate backbone bonds\n calculateBondsBetween(s, true)\n\n // calculate rung bonds\n calculateBondsWithin(s, true)\n\n s.finalizeAtoms()\n s.finalizeBonds()\n\n buildUnitcellAssembly(s)\n\n if (Debug) Log.timeEnd('MmtfParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('mmtf', MmtfParser)\n\nexport default MmtfParser\n","/**\n * @file Mol2 Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport {\n assignResidueTypeBonds,\n calculateChainnames, calculateSecondaryStructure,\n calculateBondsBetween, calculateBondsWithin\n} from '../structure/structure-utils'\nimport StructureParser from './structure-parser'\n\nconst reWhitespace = /\\s+/\nconst bondTypes: {[k: string]: number} = {\n '1': 1,\n '2': 2,\n '3': 3,\n 'am': 1, // amide\n 'ar': 1, // aromatic\n 'du': 1, // dummy\n 'un': 1, // unknown\n 'nc': 0 // not connected\n}\n\nclass Mol2Parser extends StructureParser {\n get type () { return 'mol2' }\n\n _parse () {\n // http://paulbourke.net/dataformats/mol2/\n\n if (Debug) Log.time('Mol2Parser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n const firstModelOnly = this.firstModelOnly\n const asTrajectory = this.asTrajectory\n\n const frames = s.frames\n let doFrames = false\n let currentFrame: Float32Array, currentCoord: number\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.resize(Math.round(this.streamer.data.length / 60))\n atomStore.addField('partialCharge', 1, 'float32')\n\n let idx = 0\n let moleculeLineNo = 0\n let modelAtomIdxStart = 0\n let modelIdx = -1\n let numAtoms = 0\n\n let currentRecordType = 0\n let moleculeRecordType = 1\n let atomRecordType = 2\n let bondRecordType = 3\n\n const ap1 = s.getAtomProxy()\n const ap2 = s.getAtomProxy()\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ].trim()\n\n if (line === '' || line[ 0 ] === '#') continue\n\n if (line[ 0 ] === '@') {\n if (line === '@MOLECULE') {\n currentRecordType = moleculeRecordType\n moleculeLineNo = 0\n\n ++modelIdx\n } else if (line === '@ATOM') {\n currentRecordType = atomRecordType\n modelAtomIdxStart = atomStore.count\n\n if (asTrajectory) {\n currentCoord = 0\n currentFrame = new Float32Array(numAtoms * 3)\n frames.push(currentFrame)\n\n if (modelIdx > 0) doFrames = true\n }\n } else if (line === '@BOND') {\n currentRecordType = bondRecordType\n } else {\n currentRecordType = 0\n }\n } else if (currentRecordType === moleculeRecordType) {\n if (moleculeLineNo === 0) {\n s.title = line\n s.id = line\n } else if (moleculeLineNo === 1) {\n const ls = line.split(reWhitespace)\n numAtoms = parseInt(ls[ 0 ])\n // num_atoms [num_bonds [num_subst [num_feat [num_sets]]]]\n } else if (moleculeLineNo === 2) {\n\n // const molType = line;\n // SMALL, BIOPOLYMER, PROTEIN, NUCLEIC_ACID, SACCHARIDE\n\n } else if (moleculeLineNo === 3) {\n\n // const chargeType = line;\n // NO_CHARGES, DEL_RE, GASTEIGER, GAST_HUCK, HUCKEL,\n // PULLMAN, GAUSS80_CHARGES, AMPAC_CHARGES,\n // MULLIKEN_CHARGES, DICT_ CHARGES, MMFF94_CHARGES,\n // USER_CHARGES\n\n } else if (moleculeLineNo === 4) {\n\n // const statusBits = line;\n\n } else if (moleculeLineNo === 5) {\n\n // const molComment = line;\n\n }\n\n ++moleculeLineNo\n } else if (currentRecordType === atomRecordType) {\n const ls = line.split(reWhitespace)\n\n if (firstModelOnly && modelIdx > 0) continue\n\n const x = parseFloat(ls[ 2 ])\n const y = parseFloat(ls[ 3 ])\n const z = parseFloat(ls[ 4 ])\n\n if (asTrajectory) {\n const j = currentCoord * 3\n\n currentFrame[ j + 0 ] = x\n currentFrame[ j + 1 ] = y\n currentFrame[ j + 2 ] = z\n\n currentCoord += 1\n\n if (doFrames) continue\n }\n\n const serial = ls[ 0 ]\n const atomname = ls[ 1 ]\n const element = ls[ 5 ].split('.')[ 0 ]\n const resno = ls[ 6 ] ? parseInt(ls[ 6 ]) : 1\n const resname = ls[ 7 ] ? ls[ 7 ] : ''\n const partialCharge = ls[ 8 ] ? parseFloat(ls[ 8 ]) : 0.0\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname, element)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = serial\n atomStore.partialCharge[ idx ] = partialCharge\n\n sb.addAtom(modelIdx, '', '', resname, resno, true)\n\n idx += 1\n } else if (currentRecordType === bondRecordType) {\n if (firstModelOnly && modelIdx > 0) continue\n if (asTrajectory && modelIdx > 0) continue\n\n const ls = line.split(reWhitespace)\n\n // ls[ 0 ] is bond id\n ap1.index = parseInt(ls[ 1 ]) - 1 + modelAtomIdxStart\n ap2.index = parseInt(ls[ 2 ]) - 1 + modelAtomIdxStart\n const order = bondTypes[ ls[ 3 ] ]\n\n s.bondStore.addBond(ap1, ap2, order)\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n sb.finalize()\n s.finalizeAtoms()\n calculateChainnames(s)\n calculateBondsWithin(s, true)\n calculateBondsBetween(s, true)\n s.finalizeBonds()\n assignResidueTypeBonds(s)\n calculateSecondaryStructure(s)\n\n if (Debug) Log.timeEnd('Mol2Parser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('mol2', Mol2Parser)\n\nexport default Mol2Parser\n","/**\n * @file Pdbqt Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport PdbParser from './pdb-parser'\n\n// autodock variant of PDB format with\n// - atom partial charges (empty column in pdb format)\n// - atom types (bfactor column in pdb format)\n// http://autodock.scripps.edu/faqs-help/faq/what-is-the-format-of-a-pdbqt-file\n\nclass PdbqtParser extends PdbParser {\n get type () { return 'pdbqt' }\n}\n\nParserRegistry.add('pdbqt', PdbqtParser)\n\nexport default PdbqtParser\n","/**\n * @file Pqr Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport PdbParser from './pdb-parser'\n\n// http://www.poissonboltzmann.org/docs/file-format-info/\n\nclass PqrParser extends PdbParser {\n get type () { return 'pqr' }\n}\n\nParserRegistry.add('pqr', PqrParser)\n\nexport default PqrParser\n","/**\n * @file Sdf Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { assignResidueTypeBonds } from '../structure/structure-utils'\nimport StructureParser from './structure-parser'\n\nconst reItem = /> +<(.+)>/\n\nclass SdfParser extends StructureParser {\n get type () { return 'sdf' }\n\n _parse () {\n // https://en.wikipedia.org/wiki/Chemical_table_file#SDF\n // http://download.accelrys.com/freeware/ctfile-formats/ctfile-formats.zip\n\n if (Debug) Log.time('SdfParser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n const firstModelOnly = this.firstModelOnly\n const asTrajectory = this.asTrajectory\n\n const headerLines = this.streamer.peekLines(2)\n\n s.id = headerLines[ 0 ].trim()\n s.title = headerLines[ 1 ].trim()\n\n const frames = s.frames\n let doFrames = false\n let currentFrame: Float32Array, currentCoord: number\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.resize(Math.round(this.streamer.data.length / 50))\n atomStore.addField('formalCharge', 1, 'int8')\n\n const ap1 = s.getAtomProxy()\n const ap2 = s.getAtomProxy()\n\n let idx = 0\n let lineNo = 0 // for V2000: current line number in currently parsed Mol file\n let modelIdx = 0\n let modelAtomIdxStart = 0\n\n const sdfData: {[k: string]: string[]}[] = []\n let currentItem: string|boolean = false\n let currentData: {[k: string]: string[]} = {}\n let mItem: RegExpMatchArray | null\n s.extraData.sdf = sdfData\n\n let atomCount, bondCount, atomStart: number, atomEnd: number, bondStart: number, bondEnd: number, x: number, y: number, z: number, atomname: string, element: string, atomindex: number, order: number\n let isV3000 = false, isAtomBlock = false, isBondBlock = false\n let tokens: string[] = [], acc: string[] = []\n const atomindexToStoreindex = new Map()\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n\n if (isV3000 && line) {\n tokens = line.substring(7).split(' ')\n\n // Entity properties may extend over multiple lines (hanging line finishes with '-')\n // Tokens are accumulated to be processed at the same time for a given entity\n if (acc.length) {\n tokens = [...acc, ...tokens]\n acc = []\n }\n if (tokens[tokens.length - 1] === '-') {\n tokens.pop();\n acc = tokens;\n continue;\n }\n }\n\n if (line.substr(0, 4) === '$$$$') {\n lineNo = -1\n ++modelIdx\n modelAtomIdxStart = atomStore.count\n sdfData.push(currentData)\n currentData = {}\n currentItem = false\n isV3000 = false\n } else if (lineNo === 3) {\n isV3000 = line.indexOf(' V3000') > -1\n\n if (isV3000) {\n atomindexToStoreindex.clear()\n } else {\n\n atomCount = parseInt(line.substr(0, 3))\n bondCount = parseInt(line.substr(3, 3))\n\n atomStart = 4\n atomEnd = atomStart + atomCount\n bondStart = atomEnd\n bondEnd = bondStart + bondCount\n\n if (asTrajectory) {\n currentCoord = 0\n currentFrame = new Float32Array(atomCount * 3)\n frames.push(currentFrame)\n\n if (modelIdx > 0) doFrames = true\n }\n }\n } else if (isV3000 && tokens[0] === 'COUNTS') {\n atomCount = parseInt(tokens[1]);\n\n if (asTrajectory) {\n currentCoord = 0\n currentFrame = new Float32Array(atomCount * 3)\n frames.push(currentFrame)\n\n if (modelIdx > 0) doFrames = true\n }\n } else if (isV3000 && tokens.length == 2) {\n if (tokens[1] === 'ATOM') {\n if (tokens[0] === 'BEGIN') isAtomBlock = true\n else if (tokens[0] === 'END') isAtomBlock = false\n } else if (tokens[1] === 'BOND') {\n if (tokens[0] === 'BEGIN') isBondBlock = true\n else if (tokens[0] === 'END') isBondBlock = false\n }\n } else if (\n isAtomBlock \n || (!isV3000 && lineNo >= atomStart && lineNo < atomEnd)\n ) {\n if (firstModelOnly && modelIdx > 0) continue\n\n let charge = 0\n if (isV3000) {\n x = parseFloat(tokens[2])\n y = parseFloat(tokens[3])\n z = parseFloat(tokens[4])\n\n element = tokens[1]\n atomindex = parseInt(tokens[0])\n atomindexToStoreindex.set(atomindex, idx)\n atomname = element + atomindex\n\n if (tokens.length > 6) {\n let chgTok = tokens.slice(6).find(t => t.indexOf('CHG=') === 0);\n if (chgTok) {\n charge = parseInt(chgTok.substring(4))\n }\n }\n } else {\n x = parseFloat(line.substr(0, 10))\n y = parseFloat(line.substr(10, 10))\n z = parseFloat(line.substr(20, 10))\n\n element = line.substr(31, 3).trim()\n atomname = element + (idx - modelAtomIdxStart + 1)\n }\n\n if (asTrajectory) {\n const j = currentCoord * 3\n\n currentFrame[ j + 0 ] = x\n currentFrame[ j + 1 ] = y\n currentFrame[ j + 2 ] = z\n\n currentCoord += 1\n\n if (doFrames) continue\n }\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname, element)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = isV3000 ? atomindex : idx\n atomStore.formalCharge[ idx ] = charge\n\n sb.addAtom(modelIdx, '', '', 'HET', 1, true)\n\n idx += 1\n } else if (\n isBondBlock \n || (!isV3000 && lineNo >= bondStart && lineNo < bondEnd)\n ) {\n if (firstModelOnly && modelIdx > 0) continue\n if (asTrajectory && modelIdx > 0) continue\n\n if (isV3000) {\n ap1.index = atomindexToStoreindex.get(parseInt(tokens[2]))\n ap2.index = atomindexToStoreindex.get(parseInt(tokens[3]))\n order = parseInt(tokens[1])\n } else {\n ap1.index = parseInt(line.substr(0, 3)) - 1 + modelAtomIdxStart\n ap2.index = parseInt(line.substr(3, 3)) - 1 + modelAtomIdxStart\n order = parseInt(line.substr(6, 3))\n }\n\n s.bondStore.addBond(ap1, ap2, order)\n } else if (line.substr(0, 6) === 'M CHG') {\n const chargeCount = parseInt(line.substr(6, 3))\n for (let ci = 0, coffset = 10; ci < chargeCount; ++ci, coffset += 8) {\n const aToken = parseInt(line.substr(coffset, 3))\n const atomIdx = aToken - 1 + modelAtomIdxStart\n const cToken = parseInt(line.substr(coffset + 4, 3))\n atomStore.formalCharge[ atomIdx ] = cToken\n }\n // eslint-disable-next-line no-cond-assign\n } else if (line.charAt(0) === '>' && (mItem = line.match(reItem))) {\n currentItem = mItem[ 1 ]\n currentData[ currentItem ] = []\n } else if (currentItem !== false && line) {\n currentData[ currentItem ].push(line)\n }\n\n ++lineNo\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n assignResidueTypeBonds(s)\n\n if (Debug) Log.timeEnd('SdfParser._parse ' + this.name)\n }\n\n _postProcess () {\n assignResidueTypeBonds(this.structure)\n }\n}\n\nParserRegistry.add('sdf', SdfParser)\nParserRegistry.add('sd', SdfParser)\nParserRegistry.add('mol', SdfParser)\n\nexport default SdfParser\n","/**\n * @file Prmtop Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport {\n assignResidueTypeBonds, calculateBondsBetween,\n calculateBondsWithin, calculateChainnames\n} from '../structure/structure-utils'\n\nconst amberChargeUnitFactor = 18.2223\n\nconst enum Mode {\n Title,\n Pointers,\n AtomName,\n Charge,\n Mass,\n ResidueLabel,\n ResiduePointer,\n BondsIncHydrogen,\n BondsWithoutHydrogen,\n Radii\n}\n\nfunction parseIntSubstr (line: string, start: number, length: number) {\n return parseInt(line.substr(start, length).trim())\n}\n\nclass PrmtopParser extends StructureParser {\n get type () { return 'prmtop' }\n\n _parse () {\n // http://ambermd.org/prmtop.pdf\n // http://ambermd.org/formats.html#topology\n\n if (Debug) Log.time('PrmtopParser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n //\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.addField('partialCharge', 1, 'float32')\n atomStore.addField('radius', 1, 'float32')\n\n const title: string[] = []\n const pointersDict: {[k: string]: number} = {}\n const pointers = [\n 'NATOM', 'NTYPES', 'NBONH', 'MBONA', 'NTHETH', 'MTHETA',\n 'NPHIH', 'MPHIA', 'NHPARM', 'NPARM', 'NNB', 'NRES',\n 'NBONA', 'NTHETA', 'NPHIA', 'NUMBND', 'NUMANG', 'NPTRA',\n 'NATYP', 'NPHB', 'IFPERT', 'NBPER', 'NGPER', 'NDPER',\n 'MBPER', 'MGPER', 'MDPER', 'IFBOX', 'NMXRS', 'IFCAP',\n 'NUMEXTRA', 'NCOPY'\n ]\n pointers.forEach(name => { pointersDict[ name ] = 0 })\n\n let atomNames: string[]\n let charges: Float32Array\n let radii: Float32Array\n let bAtomIndex1: Uint32Array\n let bAtomIndex2: Uint32Array\n let bBondOrder: Uint8Array = new Uint8Array(0)\n let residueLabels: string[]\n let residuePointers: Uint32Array\n\n let mode: number|undefined\n // let currentFormat\n let curIdx: number\n let bondIdx: number\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n const lt = line.trim()\n\n if (!lt) {\n continue\n } else if (line.startsWith('%FORMAT')) {\n // currentFormat = lt.substring(8, lt.length - 1)\n } else if (line.startsWith('%FLAG')) {\n const flag = line.substr(5).trim()\n curIdx = 0\n\n if (flag === 'TITLE') {\n mode = Mode.Title\n } else if (flag === 'POINTERS') {\n mode = Mode.Pointers\n } else if (flag === 'ATOM_NAME') {\n mode = Mode.AtomName\n } else if (flag === 'CHARGE') {\n mode = Mode.Charge\n } else if (flag === 'MASS') {\n mode = Mode.Mass\n } else if (flag === 'RESIDUE_LABEL') {\n mode = Mode.ResidueLabel\n } else if (flag === 'RESIDUE_POINTER') {\n mode = Mode.ResiduePointer\n } else if (flag === 'BONDS_INC_HYDROGEN') {\n bondIdx = 0\n mode = Mode.BondsIncHydrogen\n } else if (flag === 'BONDS_WITHOUT_HYDROGEN') {\n bondIdx = pointersDict['NBONH']\n mode = Mode.BondsWithoutHydrogen\n } else if (flag === 'RADII') {\n mode = Mode.Radii\n } else {\n mode = undefined\n }\n } else if (mode === Mode.Title) {\n title.push(lt)\n } else if (mode === Mode.Pointers) {\n const n = Math.min(curIdx + 10, 32)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n pointersDict[pointers[curIdx]] = parseInt(\n line.substr(i * 8, 8).trim()\n )\n }\n atomNames = new Array(pointersDict.NATOM)\n charges = new Float32Array(pointersDict.NATOM)\n radii = new Float32Array(pointersDict.NATOM)\n atomStore.resize(pointersDict.NATOM)\n const bondCount = pointersDict.NBONH + pointersDict.MBONA\n bAtomIndex1 = new Uint32Array(bondCount)\n bAtomIndex2 = new Uint32Array(bondCount)\n bBondOrder = new Uint8Array(bondCount)\n residueLabels = new Array(pointersDict.NRES)\n residuePointers = new Uint32Array(pointersDict.NRES)\n } else if (mode === Mode.AtomName) {\n const n = Math.min(curIdx + 20, pointersDict.NATOM)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n atomNames[curIdx] = line.substr(i * 4, 4).trim()\n }\n } else if (mode === Mode.Charge) {\n const n = Math.min(curIdx + 5, pointersDict.NATOM)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n charges[curIdx] = parseFloat(line.substr(i * 16, 16)) / amberChargeUnitFactor\n }\n } else if (mode === Mode.Mass) {\n\n // not currently used\n\n } else if (mode === Mode.ResidueLabel) {\n const n = Math.min(curIdx + 20, pointersDict.NRES)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n residueLabels[curIdx] = line.substr(i * 4, 4).trim()\n }\n } else if (mode === Mode.ResiduePointer) {\n const n = Math.min(curIdx + 10, pointersDict.NRES)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n residuePointers[curIdx] = parseIntSubstr(line, i * 8, 8)\n }\n } else if (mode === Mode.BondsIncHydrogen) {\n const n = Math.min(curIdx + 10, pointersDict.NBONH * 3)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n const r = curIdx % 3\n if (r === 0) {\n bAtomIndex1[bondIdx] = parseIntSubstr(line, i * 8, 8) / 3\n } if (r === 1) {\n bAtomIndex2[bondIdx] = parseIntSubstr(line, i * 8, 8) / 3\n bBondOrder[bondIdx] = 1\n ++bondIdx\n }\n }\n } else if (mode === Mode.BondsWithoutHydrogen) {\n const n = Math.min(curIdx + 10, pointersDict.MBONA * 3)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n const r = curIdx % 3\n if (r === 0) {\n bAtomIndex1[bondIdx] = parseIntSubstr(line, i * 8, 8) / 3\n } if (r === 1) {\n bAtomIndex2[bondIdx] = parseIntSubstr(line, i * 8, 8) / 3\n bBondOrder[bondIdx] = 1\n ++bondIdx\n }\n }\n } else if (mode === Mode.Radii) {\n const n = Math.min(curIdx + 5, pointersDict.NATOM)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n radii[curIdx] = parseFloat(line.substr(i * 16, 16))\n }\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n s.title = title.join(' ')\n\n const atomCount = pointersDict.NATOM\n let curResIdx = 0\n let curResname = residueLabels![0]\n let curResno = 1\n for (let i = 0; i < atomCount; ++i) {\n if (i + 1 === residuePointers![curResIdx + 1]) {\n ++curResIdx\n curResname = residueLabels![curResIdx]\n curResno = curResIdx + 1\n }\n atomStore.atomTypeId[i] = atomMap.add(atomNames![i])\n atomStore.serial[i] = i + 1\n sb.addAtom(0, '', '', curResname, curResno, false)\n }\n\n atomStore.partialCharge.set(charges!)\n atomStore.radius.set(radii!)\n\n s.bondStore.length = bBondOrder!.length\n s.bondStore.count = bBondOrder!.length\n s.bondStore.atomIndex1 = bAtomIndex1!\n s.bondStore.atomIndex2 = bAtomIndex2!\n s.bondStore.bondOrder = bBondOrder\n\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n calculateBondsWithin(s, true)\n calculateBondsBetween(s, true, true)\n calculateChainnames(s, true)\n assignResidueTypeBonds(s)\n\n if (Debug) Log.timeEnd('PrmtopParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('prmtop', PrmtopParser)\nParserRegistry.add('parm7', PrmtopParser)\n\nexport default PrmtopParser\n","/**\n * @file Psf Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport {\n assignResidueTypeBonds, calculateBondsBetween,\n calculateBondsWithin, getChainname\n} from '../structure/structure-utils'\n\nconst TitleMode = 1\nconst AtomMode = 2\nconst BondMode = 3\nconst AngleMode = 4\nconst DihedralMode = 5\nconst ImproperMode = 6\n\nconst reWhitespace = /\\s+/\nconst reTitle = /(^\\*|REMARK)*/\n\nclass PsfParser extends StructureParser {\n get type () { return 'psf' }\n\n _parse () {\n // http://www.ks.uiuc.edu/Training/Tutorials/namd/namd-tutorial-unix-html/node23.html\n\n if (Debug) Log.time('PsfParser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n //\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.addField('partialCharge', 1, 'float32')\n\n const title: string[] = []\n\n let mode: number|undefined\n let chainid: string\n let lastSegid: string\n let idx = 0\n let chainIdx = 0\n let bondIdx = 0\n let bAtomIndex1: Uint32Array, bAtomIndex2: Uint32Array, bBondOrder: Uint8Array\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ].trim()\n\n if (!line) {\n mode = undefined\n continue\n }\n\n if (mode === AtomMode) {\n const ls = line.split(reWhitespace)\n\n const serial = parseInt(ls[ 0 ])\n const segid = ls[ 1 ]\n const resno = parseInt(ls[ 2 ])\n const resname = ls[ 3 ]\n const atomname = ls[ 4 ]\n const charge = parseFloat(ls[ 6 ])\n\n if (segid !== lastSegid) {\n chainid = getChainname(chainIdx)\n ++chainIdx\n }\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname)\n\n atomStore.serial[ idx ] = serial\n atomStore.partialCharge[ idx ] = charge\n\n sb.addAtom(0, chainid, chainid, resname, resno, false)\n\n idx += 1\n lastSegid = segid\n } else if (mode === BondMode) {\n const ls = line.split(reWhitespace)\n\n for (let j = 0, m = ls.length; j < m; j += 2) {\n bAtomIndex1[ bondIdx ] = parseInt(ls[ j ]) - 1\n bAtomIndex2[ bondIdx ] = parseInt(ls[ j + 1 ]) - 1\n bBondOrder[ bondIdx ] = 1\n bondIdx += 1\n }\n } else if (mode === TitleMode) {\n title.push(line.replace(reTitle, '').trim())\n } else if (mode === AngleMode) {\n\n // currently not used\n\n } else if (mode === DihedralMode) {\n\n // currently not used\n\n } else if (mode === ImproperMode) {\n\n // currently not used\n\n } else if (line.includes('!NATOM')) {\n mode = AtomMode\n\n const numAtoms = parseInt(line.split(reWhitespace)[ 0 ])\n atomStore.resize(numAtoms)\n } else if (line.includes('!NBOND')) {\n mode = BondMode\n\n const numBonds = parseInt(line.split(reWhitespace)[ 0 ])\n bAtomIndex1 = new Uint32Array(numBonds)\n bAtomIndex2 = new Uint32Array(numBonds)\n bBondOrder = new Uint8Array(numBonds)\n } else if (line.includes('!NTITLE')) {\n mode = TitleMode\n } else if (line.includes('!NTHETA')) {\n mode = AngleMode\n } else if (line.includes('!NPHI')) {\n mode = DihedralMode\n } else if (line.includes('!NIMPHI')) {\n mode = ImproperMode\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n s.title = title.join(' ')\n\n s.bondStore.length = bBondOrder!.length\n s.bondStore.count = bondIdx\n s.bondStore.atomIndex1 = bAtomIndex1!\n s.bondStore.atomIndex2 = bAtomIndex2!\n s.bondStore.bondOrder = bBondOrder!\n\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n calculateBondsWithin(s, true)\n calculateBondsBetween(s, true, true)\n assignResidueTypeBonds(s)\n\n if (Debug) Log.timeEnd('PsfParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('psf', PsfParser)\n\nexport default PsfParser\n","/**\n * @file Top Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport { WaterNames } from '../structure/structure-constants'\nimport {\n assignResidueTypeBonds, calculateBondsBetween,\n calculateBondsWithin, getChainname\n} from '../structure/structure-utils'\n\nconst enum Mode {\n System,\n Molecules,\n Moleculetype,\n Atoms,\n Bonds\n}\n\nconst reField = /\\[ (.+) \\]/\nconst reWhitespace = /\\s+/\n\nclass TopParser extends StructureParser {\n get type () { return 'top' }\n\n _parse () {\n // http://manual.gromacs.org/online/top.html\n\n if (Debug) Log.time('TopParser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n //\n\n const atomMap = s.atomMap\n const bondStore = s.bondStore\n\n const atomStore = s.atomStore\n atomStore.addField('partialCharge', 1, 'float32')\n\n const molecules: [string, number][] = []\n const moleculetypeDict: {[k: string]: {atoms: any[], bonds: any[] }} = {}\n\n let currentMoleculetype: {\n atoms: [number, string, string, number][],\n bonds: [number, number][]\n }\n let mode: number|undefined\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n let lt = line.trim()\n\n if (!lt || lt[0] === '*' || lt[0] === ';') {\n continue\n }\n\n if (lt.startsWith('#include')) {\n throw new Error('TopParser: #include statements not allowed')\n }\n\n const fieldMatch = line.match(reField)\n if (fieldMatch !== null) {\n const name = fieldMatch[1]\n if (name === 'moleculetype') {\n mode = Mode.Moleculetype\n currentMoleculetype = {\n atoms: [],\n bonds: []\n }\n } else if (name === 'atoms') {\n mode = Mode.Atoms\n } else if (name === 'bonds') {\n mode = Mode.Bonds\n } else if (name === 'system') {\n mode = Mode.System\n } else if (name === 'molecules') {\n mode = Mode.Molecules\n } else {\n mode = undefined\n }\n continue\n }\n\n const cIdx = lt.indexOf(';')\n if (cIdx !== -1) {\n lt = lt.substring(0, cIdx).trim()\n }\n if (mode === Mode.Moleculetype) {\n const molName = lt.split(reWhitespace)[0]\n moleculetypeDict[molName] = currentMoleculetype\n } else if (mode === Mode.Atoms) {\n const ls = lt.split(reWhitespace)\n currentMoleculetype.atoms.push([\n parseInt(ls[2]), // resnr\n ls[3], // residue\n ls[4], // atom\n parseFloat(ls[6]) // charge\n ])\n } else if (mode === Mode.Bonds) {\n const ls = lt.split(reWhitespace)\n currentMoleculetype.bonds.push([\n parseInt(ls[0]), // ai\n parseInt(ls[1]) // aj\n ])\n } else if (mode === Mode.System) {\n s.title = lt\n } else if (mode === Mode.Molecules) {\n const ls = lt.split(reWhitespace)\n molecules.push([\n ls[0], // name\n parseInt(ls[1]) // count\n ])\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n let atomCount = 0\n let bondCount = 0\n molecules.forEach(function (val) {\n const [name, molCount] = val\n const molType = moleculetypeDict[name]\n atomCount += molCount * molType.atoms.length\n bondCount += molCount * molType.bonds.length\n })\n\n atomStore.resize(atomCount)\n bondStore.resize(bondCount)\n\n let atomIdx = 0\n let resIdx = 0\n let chainidIdx = 0\n let chainnameIdx = 0\n let bondIdx = 0\n let atomOffset = 0\n let lastResno: number\n\n molecules.forEach(function (val) {\n const [name, molCount] = val\n const molType = moleculetypeDict[name]\n const chainname = getChainname(chainnameIdx)\n for (let i = 0; i < molCount; ++i) {\n lastResno = -1\n const chainid = WaterNames.includes(name) ? chainname : getChainname(chainidIdx)\n molType.atoms.forEach(function (atomData) {\n const [resno, resname, atomname, charge] = atomData\n if (resno !== lastResno) {\n ++resIdx\n }\n atomStore.atomTypeId[atomIdx] = atomMap.add(atomname)\n atomStore.serial[atomIdx] = atomIdx + 1\n atomStore.partialCharge[atomIdx] = charge\n sb.addAtom(0, chainname, chainid, resname, resIdx + 1, false)\n ++atomIdx\n lastResno = resno\n })\n molType.bonds.forEach(function (bondData) {\n bondStore.atomIndex1[bondIdx] = atomOffset + bondData[0] - 1\n bondStore.atomIndex2[bondIdx] = atomOffset + bondData[1] - 1\n ++bondIdx\n })\n ++chainidIdx\n atomOffset += molType.atoms.length\n }\n ++chainnameIdx\n })\n\n bondStore.count = bondCount\n\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n calculateBondsWithin(s, true)\n calculateBondsBetween(s, true, true)\n assignResidueTypeBonds(s)\n\n if (Debug) Log.timeEnd('TopParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('top', TopParser)\n\nexport default TopParser\n","/**\n * @file Trajectory Parser\n * @author Alexander Rose \n * @private\n */\n\nimport Parser, { ParserParameters } from './parser'\nimport Frames from '../trajectory/frames'\nimport Streamer from '../streamer/streamer';\n\nclass TrajectoryParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n super(streamer, params)\n\n this.frames = new Frames(this.name, this.path)\n }\n\n get type () { return 'trajectory' }\n get __objName () { return 'frames' }\n}\n\nexport default TrajectoryParser\n","/**\n * @file Netcdf Reader\n * @author Alexander Rose \n * @private\n *\n * Adapted from https://github.com/cheminfo-js/netcdfjs\n * MIT License, Copyright (c) 2016 cheminfo\n */\n\nimport IOBuffer from './io-buffer'\n\nexport interface NetCDFRecordDimension {\n length: number,\n id?: number,\n name?: string,\n recordStep?: number\n}\n\nexport interface NetCDFHeader {\n recordDimension: NetCDFRecordDimension,\n version: number,\n dimensions: any[],\n globalAttributes: any[],\n variables: any[]\n}\n\nexport interface NetCDFDimension {\n name: string,\n size: number\n}\n\n/**\n * Throws a non-valid NetCDF exception if the statement it's true\n * @ignore\n * @param {boolean} statement - Throws if true\n * @param {string} reason - Reason to throw\n */\nfunction notNetcdf (statement: boolean, reason: string) {\n if (statement) {\n throw new TypeError('Not a valid NetCDF v3.x file: ' + reason)\n }\n}\n\n/**\n * Moves 1, 2, or 3 bytes to next 4-byte boundary\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n */\nfunction padding (buffer: IOBuffer) {\n if ((buffer.offset % 4) !== 0) {\n buffer.skip(4 - (buffer.offset % 4))\n }\n}\n\n/**\n * Reads the name\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @return {string} - Name\n */\nfunction readName (buffer: IOBuffer) {\n // Read name\n const nameLength = buffer.readUint32()\n const name = buffer.readChars(nameLength)\n\n // validate name\n // TODO\n\n // Apply padding\n padding(buffer)\n return name\n}\n\nconst types = {\n BYTE: 1,\n CHAR: 2,\n SHORT: 3,\n INT: 4,\n FLOAT: 5,\n DOUBLE: 6\n}\n\n/**\n * Parse a number into their respective type\n * @ignore\n * @param {number} type - integer that represents the type\n * @return {string} - parsed value of the type\n */\nfunction num2str (type: number) {\n switch (Number(type)) {\n case types.BYTE:\n return 'byte'\n case types.CHAR:\n return 'char'\n case types.SHORT:\n return 'short'\n case types.INT:\n return 'int'\n case types.FLOAT:\n return 'float'\n case types.DOUBLE:\n return 'double'\n default:\n return 'undefined'\n }\n}\n\n/**\n * Parse a number type identifier to his size in bytes\n * @ignore\n * @param {number} type - integer that represents the type\n * @return {number} -size of the type\n */\nfunction num2bytes (type: number) {\n switch (Number(type)) {\n case types.BYTE:\n return 1\n case types.CHAR:\n return 1\n case types.SHORT:\n return 2\n case types.INT:\n return 4\n case types.FLOAT:\n return 4\n case types.DOUBLE:\n return 8\n default:\n return -1\n }\n}\n\n/**\n * Reverse search of num2str\n * @ignore\n * @param {string} type - string that represents the type\n * @return {number} - parsed value of the type\n */\nfunction str2num (type: string) {\n switch (String(type)) {\n case 'byte':\n return types.BYTE\n case 'char':\n return types.CHAR\n case 'short':\n return types.SHORT\n case 'int':\n return types.INT\n case 'float':\n return types.FLOAT\n case 'double':\n return types.DOUBLE\n default:\n return -1\n }\n}\n\n/**\n * Auxiliary function to read numeric data\n * @ignore\n * @param {number} size - Size of the element to read\n * @param {function} bufferReader - Function to read next value\n * @return {Array|number}\n */\nfunction readNumber (size: number, bufferReader: Function) {\n if (size !== 1) {\n const numbers = new Array(size)\n for (let i = 0; i < size; i++) {\n numbers[i] = bufferReader()\n }\n return numbers\n } else {\n return bufferReader()\n }\n}\n\n/**\n * Given a type and a size reads the next element\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {number} type - Type of the data to read\n * @param {number} size - Size of the element to read\n * @return {string|Array|number}\n */\nfunction readType (buffer: IOBuffer, type: number, size: number) {\n switch (type) {\n case types.BYTE:\n return buffer.readBytes(size)\n case types.CHAR:\n return trimNull(buffer.readChars(size))\n case types.SHORT:\n return readNumber(size, buffer.readInt16.bind(buffer))\n case types.INT:\n return readNumber(size, buffer.readInt32.bind(buffer))\n case types.FLOAT:\n return readNumber(size, buffer.readFloat32.bind(buffer))\n case types.DOUBLE:\n return readNumber(size, buffer.readFloat64.bind(buffer))\n default:\n notNetcdf(true, 'non valid type ' + type)\n return undefined\n }\n}\n\n/**\n * Removes null terminate value\n * @ignore\n * @param {string} value - String to trim\n * @return {string} - Trimmed string\n */\nfunction trimNull (value: string) {\n if (value.charCodeAt(value.length - 1) === 0) {\n return value.substring(0, value.length - 1)\n }\n return value\n}\n\n// const STREAMING = 4294967295;\n\n/**\n * Read data for the given non-record variable\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {object} variable - Variable metadata\n * @return {Array} - Data of the element\n */\nfunction nonRecord (buffer: IOBuffer, variable: {type: string, size: number}) {\n // variable type\n const type = str2num(variable.type)\n\n // size of the data\n const size = variable.size / num2bytes(type)\n\n // iterates over the data\n const data = new Array(size)\n for (let i = 0; i < size; i++) {\n data[i] = readType(buffer, type, 1)\n }\n\n return data\n}\n\n/**\n * Read data for the given record variable\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {object} variable - Variable metadata\n * @param {object} recordDimension - Record dimension metadata\n * @return {Array} - Data of the element\n */\nfunction record (buffer:IOBuffer, variable: {type: string, size: number}, recordDimension: NetCDFRecordDimension) {\n // variable type\n const type = str2num(variable.type)\n const width = variable.size ? variable.size / num2bytes(type) : 1\n\n // size of the data\n // TODO streaming data\n const size = recordDimension.length\n\n // iterates over the data\n const data = new Array(size)\n const step = recordDimension.recordStep\n\n for (let i = 0; i < size; i++) {\n const currentOffset = buffer.offset\n data[i] = readType(buffer, type, width)\n buffer.seek(currentOffset + step!)\n }\n\n return data\n}\n\n// Grammar constants\nconst ZERO = 0\nconst NC_DIMENSION = 10\nconst NC_VARIABLE = 11\nconst NC_ATTRIBUTE = 12\n\n/**\n * Read the header of the file\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {number} version - Version of the file\n * @return {object} - Object with the fields:\n * * `recordDimension`: Number with the length of record dimension\n * * `dimensions`: List of dimensions\n * * `globalAttributes`: List of global attributes\n * * `variables`: List of variables\n */\nfunction header (buffer: IOBuffer, version: number) {\n // Length of record dimension\n // sum of the varSize's of all the record variables.\n const header: Partial = {recordDimension: {length: buffer.readUint32()}}\n\n // Version\n header.version = version\n\n // List of dimensions\n const dimList = dimensionsList(buffer) as {dimensions: NetCDFDimension[], recordId: number, recordName: string}\n header.recordDimension!.id = dimList.recordId\n header.recordDimension!.name = dimList.recordName\n header.dimensions = dimList.dimensions\n\n // List of global attributes\n header.globalAttributes = attributesList(buffer)\n\n // List of variables\n const variables = variablesList(buffer, dimList.recordId, version) as {variables: any[], recordStep: number}\n header.variables = variables.variables\n header.recordDimension!.recordStep = variables.recordStep\n\n return header\n}\n\n/**\n * List of dimensions\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @return {object} - List of dimensions and record dimension with:\n * * `name`: String with the name of the dimension\n * * `size`: Number with the size of the dimension\n */\nfunction dimensionsList (buffer: IOBuffer) {\n let dimensions: NetCDFDimension[], recordId, recordName\n const dimList = buffer.readUint32()\n if (dimList === ZERO) {\n notNetcdf((buffer.readUint32() !== ZERO), 'wrong empty tag for list of dimensions')\n return []\n } else {\n notNetcdf((dimList !== NC_DIMENSION), 'wrong tag for list of dimensions')\n\n // Length of dimensions\n const dimensionSize = buffer.readUint32()\n dimensions = new Array(dimensionSize)\n for (let dim = 0; dim < dimensionSize; dim++) {\n // Read name\n const name = readName(buffer)\n\n // Read dimension size\n const size = buffer.readUint32()\n if (size === 0) {\n recordId = dim\n recordName = name\n }\n\n dimensions[dim] = {\n name: name,\n size: size\n }\n }\n return {\n dimensions: dimensions,\n recordId: recordId,\n recordName: recordName\n }\n }\n}\n\n/**\n * List of attributes\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @return {Array} - List of attributes with:\n * * `name`: String with the name of the attribute\n * * `type`: String with the type of the attribute\n * * `value`: A number or string with the value of the attribute\n */\nfunction attributesList (buffer: IOBuffer) {\n let attributes\n const gAttList = buffer.readUint32()\n if (gAttList === ZERO) {\n notNetcdf((buffer.readUint32() !== ZERO), 'wrong empty tag for list of attributes')\n return []\n } else {\n notNetcdf((gAttList !== NC_ATTRIBUTE), 'wrong tag for list of attributes')\n\n // Length of attributes\n const attributeSize = buffer.readUint32()\n attributes = new Array(attributeSize)\n for (let gAtt = 0; gAtt < attributeSize; gAtt++) {\n // Read name\n const name = readName(buffer)\n\n // Read type\n const type = buffer.readUint32()\n notNetcdf(((type < 1) || (type > 6)), 'non valid type ' + type)\n\n // Read attribute\n const size = buffer.readUint32()\n const value = readType(buffer, type, size)\n\n // Apply padding\n padding(buffer)\n\n attributes[gAtt] = {\n name: name,\n type: num2str(type),\n value: value\n }\n }\n }\n return attributes\n}\n\n/**\n * List of variables\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {number} recordId - Id if the record dimension\n * @param {number} version - Version of the file\n * @return {object} - Number of recordStep and list of variables with:\n * * `name`: String with the name of the variable\n * * `dimensions`: Array with the dimension IDs of the variable\n * * `attributes`: Array with the attributes of the variable\n * * `type`: String with the type of the variable\n * * `size`: Number with the size of the variable\n * * `offset`: Number with the offset where of the variable begins\n * * `record`: True if is a record variable, false otherwise\n */\nfunction variablesList (buffer: IOBuffer, recordId: number, version: number) {\n const varList = buffer.readUint32()\n let recordStep = 0\n let variables\n if (varList === ZERO) {\n notNetcdf(\n (buffer.readUint32() !== ZERO),\n 'wrong empty tag for list of variables'\n )\n return []\n } else {\n notNetcdf((varList !== NC_VARIABLE), 'wrong tag for list of variables')\n\n // Length of variables\n const variableSize = buffer.readUint32()\n variables = new Array(variableSize)\n for (let v = 0; v < variableSize; v++) {\n // Read name\n const name = readName(buffer)\n\n // Read dimensionality of the variable\n const dimensionality = buffer.readUint32()\n\n // Index into the list of dimensions\n const dimensionsIds = new Array(dimensionality)\n for (let dim = 0; dim < dimensionality; dim++) {\n dimensionsIds[dim] = buffer.readUint32()\n }\n\n // Read variables size\n const attributes = attributesList(buffer)\n\n // Read type\n const type = buffer.readUint32()\n notNetcdf(((type < 1) && (type > 6)), 'non valid type ' + type)\n\n // Read variable size\n // The 32-bit varSize field is not large enough to contain the\n // size of variables that require more than 2^32 - 4 bytes,\n // so 2^32 - 1 is used in the varSize field for such variables.\n const varSize = buffer.readUint32()\n\n // Read offset\n let offset = buffer.readUint32()\n if (version === 2) {\n notNetcdf((offset > 0), 'offsets larger than 4GB not supported')\n offset = buffer.readUint32()\n }\n\n // Count amount of record variables\n if (dimensionsIds[0] === recordId) {\n recordStep += varSize\n }\n\n variables[v] = {\n name: name,\n dimensions: dimensionsIds,\n attributes: attributes,\n type: num2str(type),\n size: varSize,\n offset: offset,\n record: (dimensionsIds[0] === recordId)\n }\n }\n }\n\n return {\n variables: variables,\n recordStep: recordStep\n }\n}\n\n/**\n * Reads a NetCDF v3.x file\n * https://www.unidata.ucar.edu/software/netcdf/docs/file_format_specifications.html\n */\nclass NetcdfReader {\n header: Partial\n buffer: IOBuffer\n /**\n * @param {ArrayBuffer} data - ArrayBuffer or any Typed Array with the data\n */\n constructor (data: ArrayBuffer) {\n const buffer = new IOBuffer(data)\n buffer.setBigEndian()\n\n // Validate that it's a NetCDF file\n notNetcdf((buffer.readChars(3) !== 'CDF'), 'should start with CDF')\n\n // Check the NetCDF format\n const version = buffer.readByte()\n notNetcdf((version > 2), 'unknown version')\n\n // Read the header\n this.header = header(buffer, version)\n this.buffer = buffer\n }\n\n /**\n * @return {string} - Version for the NetCDF format\n */\n get version () {\n if (this.header.version === 1) {\n return 'classic format'\n } else {\n return '64-bit offset format'\n }\n }\n\n /**\n * @return {object} - Metadata for the record dimension\n * * `length`: Number of elements in the record dimension\n * * `id`: Id number in the list of dimensions for the record dimension\n * * `name`: String with the name of the record dimension\n * * `recordStep`: Number with the record variables step size\n */\n get recordDimension () {\n return this.header.recordDimension\n }\n\n /**\n * @return {Array} - List of dimensions with:\n * * `name`: String with the name of the dimension\n * * `size`: Number with the size of the dimension\n */\n get dimensions () {\n return this.header.dimensions\n }\n\n /**\n * @return {Array} - List of global attributes with:\n * * `name`: String with the name of the attribute\n * * `type`: String with the type of the attribute\n * * `value`: A number or string with the value of the attribute\n */\n get globalAttributes () {\n return this.header.globalAttributes\n }\n\n /**\n * @return {Array} - List of variables with:\n * * `name`: String with the name of the variable\n * * `dimensions`: Array with the dimension IDs of the variable\n * * `attributes`: Array with the attributes of the variable\n * * `type`: String with the type of the variable\n * * `size`: Number with the size of the variable\n * * `offset`: Number with the offset where of the variable begins\n * * `record`: True if is a record variable, false otherwise\n */\n get variables () {\n return this.header.variables\n }\n\n /**\n * Checks if a variable is available\n * @param {string|object} variableName - Name of the variable to check\n * @return {Boolean} - Variable existence\n */\n hasDataVariable (variableName: string) {\n return this.header.variables!.findIndex(function (val) {\n return val.name === variableName\n }) !== -1\n }\n\n /**\n * Retrieves the data for a given variable\n * @param {string|object} variableName - Name of the variable to search or variable object\n * @return {Array} - List with the variable values\n */\n getDataVariable (variableName: string|{}) {\n let variable\n if (typeof variableName === 'string') {\n // search the variable\n variable = this.header.variables!.find(function (val) {\n return val.name === variableName\n })\n } else {\n variable = variableName\n }\n\n // throws if variable not found\n notNetcdf((variable === undefined), 'variable not found')\n\n // go to the offset position\n this.buffer.seek(variable.offset)\n\n if (variable.record) {\n // record variable case\n return record(this.buffer, variable, this.header.recordDimension!)\n } else {\n // non-record variable case\n return nonRecord(this.buffer, variable)\n }\n }\n}\n\nexport default NetcdfReader\n","/**\n * @file Dcd Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { uint8ToString, ensureBuffer } from '../utils'\nimport TrajectoryParser from './trajectory-parser'\n\nconst charmmTimeUnitFactor = 20.45482949774598\n\ninterface DcdHeader {\n NSET: number,\n ISTART: number,\n NSAVC: number,\n NAMNF: number,\n DELTA: number,\n TITLE: string,\n NATOM: number\n}\n\nclass DcdParser extends TrajectoryParser {\n get type () { return 'dcd' }\n get isBinary () { return true }\n\n _parse () {\n // http://www.ks.uiuc.edu/Research/vmd/plugins/molfile/dcdplugin.html\n\n // The DCD format is structured as follows\n // (FORTRAN UNFORMATTED, with Fortran data type descriptions):\n // HDR NSET ISTRT NSAVC 5-ZEROS NATOM-NFREAT DELTA 9-ZEROS\n // `CORD' #files step 1 step zeroes (zero) timestep (zeroes)\n // interval\n // C*4 INT INT INT 5INT INT DOUBLE 9INT\n // ==========================================================================\n // NTITLE TITLE\n // INT (=2) C*MAXTITL\n // (=32)\n // ==========================================================================\n // NATOM\n // #atoms\n // INT\n // ==========================================================================\n // X(I), I=1,NATOM (DOUBLE)\n // Y(I), I=1,NATOM\n // Z(I), I=1,NATOM\n // ==========================================================================\n\n if (Debug) Log.time('DcdParser._parse ' + this.name)\n\n const bin = ensureBuffer(this.streamer.data)\n const dv = new DataView(bin)\n\n const f = this.frames\n const coordinates = f.coordinates\n const boxes = f.boxes\n const header: Partial = {}\n\n let nextPos = 0\n\n // header block\n\n const intView = new Int32Array(bin, 0, 23)\n const ef = intView[ 0 ] !== dv.getInt32(0) // endianess flag\n // swap byte order when big endian (84 indicates little endian)\n if (intView[ 0 ] !== 84) {\n const n = bin.byteLength\n for (let i = 0; i < n; i += 4) {\n dv.setFloat32(i, dv.getFloat32(i), true)\n }\n }\n if (intView[ 0 ] !== 84) {\n Log.error('dcd bad format, header block start')\n }\n // format indicator, should read 'CORD'\n const formatString = String.fromCharCode(\n dv.getUint8(4), dv.getUint8(5),\n dv.getUint8(6), dv.getUint8(7)\n )\n if (formatString !== 'CORD') {\n Log.error('dcd bad format, format string')\n }\n let isCharmm = false\n let extraBlock = false\n let fourDims = false\n // version field in charmm, unused in X-PLOR\n if (intView[ 22 ] !== 0) {\n isCharmm = true\n if (intView[ 12 ] !== 0) extraBlock = true\n if (intView[ 13 ] === 1) fourDims = true\n }\n header.NSET = intView[ 2 ]\n header.ISTART = intView[ 3 ]\n header.NSAVC = intView[ 4 ]\n header.NAMNF = intView[ 10 ]\n if (isCharmm) {\n header.DELTA = dv.getFloat32(44, ef)\n } else {\n header.DELTA = dv.getFloat64(44, ef)\n }\n if (intView[ 22 ] !== 84) {\n Log.error('dcd bad format, header block end')\n }\n nextPos = nextPos + 21 * 4 + 8\n\n // title block\n\n const titleLength = dv.getInt32(nextPos, ef)\n const titlePos = nextPos + 1\n if ((titleLength - 4) % 80 !== 0) {\n Log.error('dcd bad format, title block start')\n }\n header.TITLE = uint8ToString(\n new Uint8Array(bin, titlePos, titleLength)\n )\n if (dv.getInt32(titlePos + titleLength + 4 - 1, ef) !== titleLength) {\n Log.error('dcd bad format, title block end')\n }\n nextPos = nextPos + titleLength + 8\n\n // natom block\n\n if (dv.getInt32(nextPos, ef) !== 4) {\n Log.error('dcd bad format, natom block start')\n }\n header.NATOM = dv.getInt32(nextPos + 4, ef)\n if (dv.getInt32(nextPos + 8, ef) !== 4) {\n Log.error('dcd bad format, natom block end')\n }\n nextPos = nextPos + 4 + 8\n\n // fixed atoms block\n\n if (header.NAMNF > 0) {\n // TODO read coordinates and indices of fixed atoms\n Log.error('dcd format with fixed atoms unsupported, aborting')\n return\n }\n\n // frames\n\n const natom = header.NATOM\n const natom4 = natom * 4\n\n for (let i = 0, n = header.NSET; i < n; ++i) {\n if (extraBlock) {\n nextPos += 4 // block start\n // unitcell: A, alpha, B, beta, gamma, C (doubles)\n const box = new Float32Array(9)\n box[ 0 ] = dv.getFloat64(nextPos, ef)\n box[ 4 ] = dv.getFloat64(nextPos + 2 * 8, ef)\n box[ 8 ] = dv.getFloat64(nextPos + 5 * 8, ef)\n boxes.push(box)\n nextPos += 48\n nextPos += 4 // block end\n }\n\n // xyz coordinates\n const coord = new Float32Array(natom * 3)\n for (let j = 0; j < 3; ++j) {\n if (dv.getInt32(nextPos, ef) !== natom4) {\n Log.error('dcd bad format, coord block start', i, j)\n }\n nextPos += 4 // block start\n const c = new Float32Array(bin, nextPos, natom)\n for (let k = 0; k < natom; ++k) {\n coord[ 3 * k + j ] = c[ k ]\n }\n nextPos += natom4\n if (dv.getInt32(nextPos, ef) !== natom4) {\n Log.error('dcd bad format, coord block end', i, j)\n }\n nextPos += 4 // block end\n }\n coordinates.push(coord)\n\n if (fourDims) {\n const bytes = dv.getInt32(nextPos, ef)\n nextPos += 4 + bytes + 4 // block start + skip + block end\n }\n }\n\n if (header.DELTA) {\n f.deltaTime = header.DELTA * charmmTimeUnitFactor\n }\n if (header.ISTART >= 1) {\n f.timeOffset = (header.ISTART - 1) * f.deltaTime\n }\n\n // console.log(header)\n // console.log(header.TITLE)\n // console.log('isCharmm', isCharmm, 'extraBlock', extraBlock, 'fourDims, fourDims)\n\n if (Debug) Log.timeEnd('DcdParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('dcd', DcdParser)\n\nexport default DcdParser\n","/**\n * @file Nctraj Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport TrajectoryParser from './trajectory-parser'\nimport NetcdfReader from '../utils/netcdf-reader'\n\nclass NctrajParser extends TrajectoryParser {\n get type () { return 'nctraj' }\n get isBinary () { return true }\n\n _parse () {\n // http://ambermd.org/netcdf/nctraj.xhtml\n\n if (Debug) Log.time('NctrajParser._parse ' + this.name)\n\n const netcdfReader = new NetcdfReader(this.streamer.data)\n\n const f = this.frames\n const coordinates = f.coordinates\n const boxes = f.boxes\n const times = f.times\n\n netcdfReader.getDataVariable('coordinates').forEach(function (c) {\n coordinates.push(new Float32Array(c))\n })\n\n if (netcdfReader.hasDataVariable('cell_lengths')) {\n netcdfReader.getDataVariable('cell_lengths').forEach(function (b) {\n boxes.push(new Float32Array(b))\n })\n }\n\n if (netcdfReader.hasDataVariable('time')) {\n netcdfReader.getDataVariable('time').forEach(function (t) {\n times.push(t)\n })\n }\n\n if (times.length >= 1) {\n f.timeOffset = times[0]\n }\n if (times.length >= 2) {\n f.deltaTime = times[1] - times[0]\n }\n\n if (Debug) Log.timeEnd('NctrajParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('nctraj', NctrajParser)\nParserRegistry.add('ncdf', NctrajParser)\nParserRegistry.add('nc', NctrajParser)\n\nexport default NctrajParser\n","/**\n * @file Trr Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { ensureBuffer } from '../utils'\nimport TrajectoryParser from './trajectory-parser'\n\nclass TrrParser extends TrajectoryParser {\n get type () { return 'trr' }\n get isBinary () { return true }\n\n _parse () {\n // https://github.com/gromacs/gromacs/blob/master/src/gromacs/fileio/trrio.cpp\n\n if (Debug) Log.time('TrrParser._parse ' + this.name)\n\n const bin = ensureBuffer(this.streamer.data)\n const dv = new DataView(bin)\n\n const f = this.frames\n const coordinates = f.coordinates\n const boxes = f.boxes\n const times = f.times\n\n let offset = 0\n\n while (true) {\n // const magicnum = dv.getInt32(offset)\n // const i1 = dv.getFloat32(offset + 4)\n offset += 8\n\n const versionSize = dv.getInt32(offset)\n offset += 4\n offset += versionSize\n\n // const irSize = dv.getInt32(offset)\n // const eSize = dv.getInt32(offset + 4)\n const boxSize = dv.getInt32(offset + 8)\n const virSize = dv.getInt32(offset + 12)\n const presSize = dv.getInt32(offset + 16)\n // const topSize = dv.getInt32(offset + 20)\n // const symSize = dv.getInt32(offset + 24)\n const coordSize = dv.getInt32(offset + 28)\n const velocitySize = dv.getInt32(offset + 32)\n const forceSize = dv.getInt32(offset + 36)\n const natoms = dv.getInt32(offset + 40)\n // const step = dv.getInt32(offset + 44)\n // const nre = dv.getInt32(offset + 48)\n offset += 52\n\n const floatSize = boxSize / 9\n const natoms3 = natoms * 3\n\n // let lambda\n if (floatSize === 8) {\n times.push(dv.getFloat64(offset))\n // lambda = dv.getFloat64(offset + 8)\n } else {\n times.push(dv.getFloat32(offset))\n // lambda = dv.getFloat32(offset + 4)\n }\n offset += 2 * floatSize\n\n if (boxSize) {\n const box = new Float32Array(9)\n if (floatSize === 8) {\n for (let i = 0; i < 9; ++i) {\n box[i] = dv.getFloat64(offset) * 10\n offset += 8\n }\n } else {\n for (let i = 0; i < 9; ++i) {\n box[i] = dv.getFloat32(offset) * 10\n offset += 4\n }\n }\n boxes.push(box)\n }\n\n // ignore, unused\n offset += virSize\n\n // ignore, unused\n offset += presSize\n\n if (coordSize) {\n let frameCoords\n if (floatSize === 8) {\n frameCoords = new Float32Array(natoms3)\n for (let i = 0; i < natoms3; ++i) {\n frameCoords[i] = dv.getFloat64(offset) * 10\n offset += 8\n }\n } else {\n const tmp = new Uint32Array(bin, offset, natoms3)\n for (let i = 0; i < natoms3; ++i) {\n const value = tmp[i]\n tmp[i] = (\n ((value & 0xFF) << 24) | ((value & 0xFF00) << 8) |\n ((value >> 8) & 0xFF00) | ((value >> 24) & 0xFF)\n )\n }\n frameCoords = new Float32Array(bin, offset, natoms3)\n for (let i = 0; i < natoms3; ++i) {\n frameCoords[i] *= 10\n offset += 4\n }\n }\n coordinates.push(frameCoords)\n }\n\n // ignore, unused\n offset += velocitySize\n\n // ignore, unused\n offset += forceSize\n\n if (offset >= bin.byteLength) break\n }\n\n if (times.length >= 1) {\n f.timeOffset = times[0]\n }\n if (times.length >= 2) {\n f.deltaTime = times[1] - times[0]\n }\n\n if (Debug) Log.timeEnd('TrrParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('trr', TrrParser)\n\nexport default TrrParser\n","/**\n * @file Xtc Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { ensureBuffer } from '../utils'\nimport TrajectoryParser from './trajectory-parser'\nimport { NumberArray } from '../types';\n\nconst MagicInts = new Uint32Array([\n 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 10, 12, 16, 20, 25, 32, 40, 50, 64,\n 80, 101, 128, 161, 203, 256, 322, 406, 512, 645, 812, 1024, 1290,\n 1625, 2048, 2580, 3250, 4096, 5060, 6501, 8192, 10321, 13003,\n 16384, 20642, 26007, 32768, 41285, 52015, 65536, 82570, 104031,\n 131072, 165140, 208063, 262144, 330280, 416127, 524287, 660561,\n 832255, 1048576, 1321122, 1664510, 2097152, 2642245, 3329021,\n 4194304, 5284491, 6658042, 8388607, 10568983, 13316085, 16777216\n])\nconst FirstIdx = 9\n// const LastIdx = MagicInts.length\n\nfunction sizeOfInt (size: number) {\n let num = 1\n let numOfBits = 0\n while (size >= num && numOfBits < 32) {\n numOfBits++\n num <<= 1\n }\n return numOfBits\n}\n\nconst _tmpBytes = new Uint8Array(32)\n\nfunction sizeOfInts (numOfInts: number, sizes: Int32Array) {\n let numOfBytes = 1\n let numOfBits = 0\n _tmpBytes[0] = 1\n for (let i = 0; i < numOfInts; i++) {\n let bytecnt\n let tmp = 0\n for (bytecnt = 0; bytecnt < numOfBytes; bytecnt++) {\n tmp += _tmpBytes[bytecnt] * sizes[i]\n _tmpBytes[bytecnt] = tmp & 0xff\n tmp >>= 8\n }\n while (tmp !== 0) {\n _tmpBytes[bytecnt++] = tmp & 0xff\n tmp >>= 8\n }\n numOfBytes = bytecnt\n }\n let num = 1\n numOfBytes--\n while (_tmpBytes[numOfBytes] >= num) {\n numOfBits++\n num *= 2\n }\n return numOfBits + numOfBytes * 8\n}\n\nfunction decodeBits (buf: Int32Array, cbuf: Uint8Array, numOfBits: number, buf2: Uint32Array) {\n const mask = (1 << numOfBits) - 1\n let lastBB0 = buf2[1]\n let lastBB1 = buf2[2]\n let cnt = buf[0]\n let num = 0\n\n while (numOfBits >= 8) {\n lastBB1 = (lastBB1 << 8) | cbuf[cnt++]\n num |= (lastBB1 >> lastBB0) << (numOfBits - 8)\n numOfBits -= 8\n }\n\n if (numOfBits > 0) {\n if (lastBB0 < numOfBits) {\n lastBB0 += 8\n lastBB1 = (lastBB1 << 8) | cbuf[cnt++]\n }\n lastBB0 -= numOfBits\n num |= (lastBB1 >> lastBB0) & ((1 << numOfBits) - 1)\n }\n\n num &= mask\n buf[0] = cnt\n buf[1] = lastBB0\n buf[2] = lastBB1\n\n return num\n}\n\nconst _tmpIntBytes = new Int32Array(32)\n\nfunction decodeInts (buf: Int32Array, cbuf: Uint8Array, numOfInts: number, numOfBits: number, sizes: NumberArray, nums: Float32Array, buf2: Uint32Array) {\n let numOfBytes = 0\n _tmpIntBytes[1] = 0\n _tmpIntBytes[2] = 0\n _tmpIntBytes[3] = 0\n\n while (numOfBits > 8) {\n // this is inversed??? why??? because of the endiannness???\n _tmpIntBytes[numOfBytes++] = decodeBits(buf, cbuf, 8, buf2)\n numOfBits -= 8\n }\n\n if (numOfBits > 0) {\n _tmpIntBytes[numOfBytes++] = decodeBits(buf, cbuf, numOfBits, buf2)\n }\n\n for (let i = numOfInts - 1; i > 0; i--) {\n let num = 0\n for (let j = numOfBytes - 1; j >= 0; j--) {\n num = (num << 8) | _tmpIntBytes[j]\n const p = (num / sizes[i]) | 0\n _tmpIntBytes[j] = p\n num = num - p * sizes[i]\n }\n nums[i] = num\n }\n nums[0] = (\n _tmpIntBytes[0] |\n (_tmpIntBytes[1] << 8) |\n (_tmpIntBytes[2] << 16) |\n (_tmpIntBytes[3] << 24)\n )\n}\n\nclass XtcParser extends TrajectoryParser {\n get type () { return 'xtc' }\n get isBinary () { return true }\n\n _parse () {\n // https://github.com/gromacs/gromacs/blob/master/src/gromacs/fileio/xtcio.cpp\n // https://github.com/gromacs/gromacs/blob/master/src/gromacs/fileio/libxdrf.cpp\n\n if (Debug) Log.time('XtcParser._parse ' + this.name)\n\n const bin = ensureBuffer(this.streamer.data)\n const dv = new DataView(bin)\n\n const f = this.frames\n const coordinates = f.coordinates\n const boxes = f.boxes\n const times = f.times\n\n const minMaxInt = new Int32Array(6)\n const sizeint = new Int32Array(3)\n const bitsizeint = new Int32Array(3)\n const sizesmall = new Uint32Array(3)\n const thiscoord = new Float32Array(3)\n const prevcoord = new Float32Array(3)\n\n let offset = 0\n const buf = new Int32Array(3)\n const buf2 = new Uint32Array(buf.buffer)\n\n while (true) {\n let frameCoords: NumberArray\n\n // const magicnum = dv.getInt32(offset)\n const natoms = dv.getInt32(offset + 4)\n // const step = dv.getInt32(offset + 8)\n offset += 12\n\n const natoms3 = natoms * 3\n\n times.push(dv.getFloat32(offset))\n offset += 4\n\n const box = new Float32Array(9)\n for (let i = 0; i < 9; ++i) {\n box[i] = dv.getFloat32(offset) * 10\n offset += 4\n }\n boxes.push(box)\n\n if (natoms <= 9) { // no compression\n frameCoords = new Float32Array(natoms)\n for (let i = 0; i < natoms; ++i) {\n frameCoords[i] = dv.getFloat32(offset)\n offset += 4\n }\n } else {\n buf[0] = buf[1] = buf[2] = 0.0\n sizeint[0] = sizeint[1] = sizeint[2] = 0\n sizesmall[0] = sizesmall[1] = sizesmall[2] = 0\n bitsizeint[0] = bitsizeint[1] = bitsizeint[2] = 0\n thiscoord[0] = thiscoord[1] = thiscoord[2] = 0\n prevcoord[0] = prevcoord[1] = prevcoord[2] = 0\n\n frameCoords = new Float32Array(natoms3)\n let lfp = 0\n\n const lsize = dv.getInt32(offset)\n offset += 4\n const precision = dv.getFloat32(offset)\n offset += 4\n\n minMaxInt[0] = dv.getInt32(offset)\n minMaxInt[1] = dv.getInt32(offset + 4)\n minMaxInt[2] = dv.getInt32(offset + 8)\n minMaxInt[3] = dv.getInt32(offset + 12)\n minMaxInt[4] = dv.getInt32(offset + 16)\n minMaxInt[5] = dv.getInt32(offset + 20)\n sizeint[0] = minMaxInt[3] - minMaxInt[0] + 1\n sizeint[1] = minMaxInt[4] - minMaxInt[1] + 1\n sizeint[2] = minMaxInt[5] - minMaxInt[2] + 1\n offset += 24\n\n let bitsize\n if ((sizeint[0] | sizeint[1] | sizeint[2]) > 0xffffff) {\n bitsizeint[0] = sizeOfInt(sizeint[0])\n bitsizeint[1] = sizeOfInt(sizeint[1])\n bitsizeint[2] = sizeOfInt(sizeint[2])\n bitsize = 0 // flag the use of large sizes\n } else {\n bitsize = sizeOfInts(3, sizeint)\n }\n\n let smallidx = dv.getInt32(offset)\n offset += 4\n // if (smallidx == 0) {alert(\"Undocumented error 1\"); return;}\n\n // let tmpIdx = smallidx + 8\n // const maxidx = (LastIdx < tmpIdx) ? LastIdx : tmpIdx\n // const minidx = maxidx - 8 // often this equal smallidx\n let tmpIdx = smallidx - 1\n tmpIdx = (FirstIdx > tmpIdx) ? FirstIdx : tmpIdx\n let smaller = (MagicInts[tmpIdx] / 2) | 0\n let smallnum = (MagicInts[smallidx] / 2) | 0\n\n sizesmall[0] = sizesmall[1] = sizesmall[2] = MagicInts[smallidx]\n // larger = MagicInts[maxidx]\n\n let adz = Math.ceil(dv.getInt32(offset) / 4) * 4\n offset += 4\n // if (tmpIdx == 0) {alert(\"Undocumented error 2\"); return;}\n\n // buf = new Int32Array(bin, offset);\n // buf8 = new Uint8Array(bin, offset);\n\n // tmpIdx += 3; rndup = tmpIdx%4;\n // for (i=tmpIdx+rndup-1; i>=tmpIdx; i--) buf8[i] = 0;\n\n // now unpack buf2...\n\n const invPrecision = 1.0 / precision\n let run = 0\n let i = 0\n\n const buf8 = new Uint8Array(bin, offset) // 229...\n\n thiscoord[0] = thiscoord[1] = thiscoord[2] = 0\n\n while (i < lsize) {\n if (bitsize === 0) {\n thiscoord[0] = decodeBits(buf, buf8, bitsizeint[0], buf2)\n thiscoord[1] = decodeBits(buf, buf8, bitsizeint[1], buf2)\n thiscoord[2] = decodeBits(buf, buf8, bitsizeint[2], buf2)\n } else {\n decodeInts(buf, buf8, 3, bitsize, sizeint, thiscoord, buf2)\n }\n\n i++\n\n thiscoord[0] += minMaxInt[0]\n thiscoord[1] += minMaxInt[1]\n thiscoord[2] += minMaxInt[2]\n\n prevcoord[0] = thiscoord[0]\n prevcoord[1] = thiscoord[1]\n prevcoord[2] = thiscoord[2]\n\n const flag = decodeBits(buf, buf8, 1, buf2)\n let isSmaller = 0\n\n if (flag === 1) {\n run = decodeBits(buf, buf8, 5, buf2)\n isSmaller = run % 3\n run -= isSmaller\n isSmaller--\n }\n\n // if ((lfp-ptrstart)+run > size3){\n // fprintf(stderr, \"(xdrfile error) Buffer overrun during decompression.\\n\");\n // return 0;\n // }\n\n if (run > 0) {\n thiscoord[0] = thiscoord[1] = thiscoord[2] = 0\n\n for (let k = 0; k < run; k += 3) {\n decodeInts(buf, buf8, 3, smallidx, sizesmall, thiscoord, buf2)\n i++\n\n thiscoord[0] += prevcoord[0] - smallnum\n thiscoord[1] += prevcoord[1] - smallnum\n thiscoord[2] += prevcoord[2] - smallnum\n\n if (k === 0) {\n // interchange first with second atom for\n // better compression of water molecules\n let tmpSwap = thiscoord[0]\n thiscoord[0] = prevcoord[0]\n prevcoord[0] = tmpSwap\n\n tmpSwap = thiscoord[1]\n thiscoord[1] = prevcoord[1]\n prevcoord[1] = tmpSwap\n\n tmpSwap = thiscoord[2]\n thiscoord[2] = prevcoord[2]\n prevcoord[2] = tmpSwap\n\n frameCoords[lfp++] = prevcoord[0] * invPrecision\n frameCoords[lfp++] = prevcoord[1] * invPrecision\n frameCoords[lfp++] = prevcoord[2] * invPrecision\n } else {\n prevcoord[0] = thiscoord[0]\n prevcoord[1] = thiscoord[1]\n prevcoord[2] = thiscoord[2]\n }\n frameCoords[lfp++] = thiscoord[0] * invPrecision\n frameCoords[lfp++] = thiscoord[1] * invPrecision\n frameCoords[lfp++] = thiscoord[2] * invPrecision\n }\n } else {\n frameCoords[lfp++] = thiscoord[0] * invPrecision\n frameCoords[lfp++] = thiscoord[1] * invPrecision\n frameCoords[lfp++] = thiscoord[2] * invPrecision\n }\n\n smallidx += isSmaller\n\n if (isSmaller < 0) {\n smallnum = smaller\n if (smallidx > FirstIdx) {\n smaller = (MagicInts[smallidx - 1] / 2) | 0\n } else {\n smaller = 0\n }\n } else if (isSmaller > 0) {\n smaller = smallnum\n smallnum = (MagicInts[smallidx] / 2) | 0\n }\n sizesmall[0] = sizesmall[1] = sizesmall[2] = MagicInts[smallidx]\n\n if (sizesmall[0] === 0 || sizesmall[1] === 0 || sizesmall[2] === 0) {\n console.error('(xdrfile error) Undefined error.')\n return\n }\n }\n offset += adz\n }\n\n for (let c = 0; c < natoms3; c++) {\n frameCoords[c] *= 10\n }\n\n coordinates.push(frameCoords)\n\n if (offset >= bin.byteLength) break\n }\n\n if (times.length >= 1) {\n f.timeOffset = times[0]\n }\n if (times.length >= 2) {\n f.deltaTime = times[1] - times[0]\n }\n\n if (Debug) Log.timeEnd('XtcParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('xtc', XtcParser)\n\nexport default XtcParser\n","/**\n * @file Volume Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { defaults } from '../utils'\nimport Parser, { ParserParameters } from './parser'\nimport Volume from '../surface/volume'\nimport Streamer from '../streamer/streamer';\n\nexport interface VolumeParserParameters extends ParserParameters {\n voxelSize: number\n}\n\nclass VolumeParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.volume = new Volume(this.name, this.path)\n this.voxelSize = defaults(p.voxelSize, 1)\n }\n\n get type () { return 'volume' }\n get __objName () { return 'volume' }\n\n _afterParse () {\n this.volume.setMatrix(this.getMatrix())\n super._afterParse()\n }\n\n getMatrix () {\n return new Matrix4()\n }\n}\n\nexport default VolumeParser\n","/**\n * @file Cube Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport VolumeParser from './volume-parser'\n\n// @author Johanna Tiemann \n// @author Alexander Rose \n\nconst reWhitespace = /\\s+/\nconst reScientificNotation = /-?\\d+(?:\\.\\d*)?(?:[eE][+-]?\\d+)?/g\nconst bohrToAngstromFactor = 0.529177210859\ninterface Header {\n atomCount: number,\n originX: number,\n originY: number,\n originZ: number,\n NVX: number,\n NVY: number,\n NVZ: number,\n basisX: Vector3,\n basisY: Vector3,\n basisZ: Vector3\n}\n\nclass CubeParser extends VolumeParser {\n get type () { return 'cube' }\n\n _parse () {\n // http://paulbourke.net/dataformats/cube/\n\n if (Debug) Log.time('CubeParser._parse ' + this.name)\n\n const v = this.volume\n const headerLines = this.streamer.peekLines(6)\n const header: Partial
= {}\n\n const scaleFactor = bohrToAngstromFactor * this.voxelSize\n\n function h (k: number, l: number) {\n var field = headerLines[ k ].trim().split(reWhitespace)[ l ]\n return parseFloat(field)\n }\n\n header.atomCount = Math.abs(h(2, 0)) // Number of atoms\n header.originX = h(2, 1) * bohrToAngstromFactor // Position of origin of volumetric data\n header.originY = h(2, 2) * bohrToAngstromFactor\n header.originZ = h(2, 3) * bohrToAngstromFactor\n header.NVX = h(3, 0) // Number of voxels\n header.NVY = h(4, 0)\n header.NVZ = h(5, 0)\n\n header.basisX = new Vector3(h(3, 1), h(3, 2), h(3, 3))\n .multiplyScalar(scaleFactor)\n header.basisY = new Vector3(h(4, 1), h(4, 2), h(4, 3))\n .multiplyScalar(scaleFactor)\n header.basisZ = new Vector3(h(5, 1), h(5, 2), h(5, 3))\n .multiplyScalar(scaleFactor)\n\n const data = new Float32Array(header.NVX * header.NVY * header.NVZ)\n let count = 0\n let lineNo = 0\n const oribitalFlag = h(2, 0) > 0 ? 0 : 1\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ].trim()\n\n if (line !== '' && lineNo >= header.atomCount! + 6 + oribitalFlag) {\n const m = line.match(reScientificNotation) as RegExpMatchArray\n for (let j = 0, lj = m.length; j < lj; ++j) {\n data[ count ] = parseFloat(m[ j ])\n ++count\n }\n }\n\n ++lineNo\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n v.header = header\n v.setData(data, header.NVZ, header.NVY, header.NVX)\n\n if (Debug) Log.timeEnd('CubeParser._parse ' + this.name)\n }\n\n getMatrix () {\n const h = this.volume.header\n const matrix = new Matrix4()\n\n matrix.multiply(\n new Matrix4().makeTranslation(\n h.originX, h.originY, h.originZ\n )\n )\n\n matrix.multiply(\n new Matrix4().makeBasis(\n h.basisZ, h.basisY, h.basisX\n )\n )\n\n return matrix\n }\n}\n\nParserRegistry.add('cub', CubeParser)\nParserRegistry.add('cube', CubeParser)\n\nexport default CubeParser\n","/**\n * @file Dsn6 Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { ensureBuffer } from '../utils'\nimport { degToRad } from '../math/math-utils'\nimport VolumeParser from './volume-parser'\n\ninterface Dsn6Header {\n xStart: number,\n yStart: number,\n zStart: number,\n xExtent: number,\n yExtent: number,\n zExtent: number,\n xRate: number,\n yRate: number,\n zRate: number,\n xlen: number,\n ylen: number,\n zlen: number,\n alpha: number,\n beta: number,\n gamma: number,\n sigma: number\n}\n\nclass Dsn6Parser extends VolumeParser {\n get type () { return 'dsn6' }\n get isBinary () { return true }\n\n _parse () {\n // DSN6 http://www.uoxray.uoregon.edu/tnt/manual/node104.html\n // BRIX http://svn.cgl.ucsf.edu/svn/chimera/trunk/libs/VolumeData/dsn6/brix-1.html\n\n if (Debug) Log.time('Dsn6Parser._parse ' + this.name)\n\n const v = this.volume\n const header: Partial = {}\n let divisor, summand\n\n const bin = ensureBuffer(this.streamer.data)\n const intView = new Int16Array(bin)\n const byteView = new Uint8Array(bin)\n const brixStr = String.fromCharCode.apply(null, byteView.subarray(0, 512))\n\n if (brixStr.startsWith(':-)')) {\n header.xStart = parseInt(brixStr.substr(10, 5)) // NXSTART\n header.yStart = parseInt(brixStr.substr(15, 5))\n header.zStart = parseInt(brixStr.substr(20, 5))\n\n header.xExtent = parseInt(brixStr.substr(32, 5)) // NX\n header.yExtent = parseInt(brixStr.substr(38, 5))\n header.zExtent = parseInt(brixStr.substr(42, 5))\n\n header.xRate = parseInt(brixStr.substr(52, 5)) // MX\n header.yRate = parseInt(brixStr.substr(58, 5))\n header.zRate = parseInt(brixStr.substr(62, 5))\n\n header.xlen = parseFloat(brixStr.substr(73, 10)) * this.voxelSize\n header.ylen = parseFloat(brixStr.substr(83, 10)) * this.voxelSize\n header.zlen = parseFloat(brixStr.substr(93, 10)) * this.voxelSize\n\n header.alpha = parseFloat(brixStr.substr(103, 10))\n header.beta = parseFloat(brixStr.substr(113, 10))\n header.gamma = parseFloat(brixStr.substr(123, 10))\n\n divisor = parseFloat(brixStr.substr(138, 12)) / 100\n summand = parseInt(brixStr.substr(155, 8))\n\n header.sigma = parseFloat(brixStr.substr(170, 12)) * 100\n } else {\n // swap byte order when big endian\n if (intView[ 18 ] !== 100) {\n for (let i = 0, n = intView.length; i < n; ++i) {\n const val = intView[ i ]\n intView[ i ] = ((val & 0xff) << 8) | ((val >> 8) & 0xff)\n }\n }\n\n header.xStart = intView[ 0 ] // NXSTART\n header.yStart = intView[ 1 ]\n header.zStart = intView[ 2 ]\n\n header.xExtent = intView[ 3 ] // NX\n header.yExtent = intView[ 4 ]\n header.zExtent = intView[ 5 ]\n\n header.xRate = intView[ 6 ] // MX\n header.yRate = intView[ 7 ]\n header.zRate = intView[ 8 ]\n\n const factor = 1 / intView[ 17 ]\n const scalingFactor = factor * this.voxelSize\n\n header.xlen = intView[ 9 ] * scalingFactor\n header.ylen = intView[ 10 ] * scalingFactor\n header.zlen = intView[ 11 ] * scalingFactor\n\n header.alpha = intView[ 12 ] * factor\n header.beta = intView[ 13 ] * factor\n header.gamma = intView[ 14 ] * factor\n\n divisor = intView[ 15 ] / 100\n summand = intView[ 16 ]\n header.gamma = intView[ 14 ] * factor\n }\n\n v.header = header\n\n if (Debug) Log.log(header, divisor, summand)\n\n const data = new Float32Array(\n header.xExtent * header.yExtent * header.zExtent\n )\n\n let offset = 512\n const xBlocks = Math.ceil(header.xExtent / 8)\n const yBlocks = Math.ceil(header.yExtent / 8)\n const zBlocks = Math.ceil(header.zExtent / 8)\n\n // loop over blocks\n for (var zz = 0; zz < zBlocks; ++zz) {\n for (var yy = 0; yy < yBlocks; ++yy) {\n for (var xx = 0; xx < xBlocks; ++xx) {\n // loop inside block\n for (var k = 0; k < 8; ++k) {\n var z = 8 * zz + k\n for (var j = 0; j < 8; ++j) {\n var y = 8 * yy + j\n for (var i = 0; i < 8; ++i) {\n var x = 8 * xx + i\n\n // check if remaining slice-part contains data\n if (x < header.xExtent && y < header.yExtent && z < header.zExtent) {\n var idx = ((((x * header.yExtent) + y) * header.zExtent) + z)\n data[ idx ] = (byteView[ offset ] - summand) / divisor\n ++offset\n } else {\n offset += 8 - i\n break\n }\n }\n }\n }\n }\n }\n }\n\n v.setData(data, header.zExtent, header.yExtent, header.xExtent)\n if (header.sigma) {\n v.setStats(undefined, undefined, undefined, header.sigma)\n }\n\n if (Debug) Log.timeEnd('Dsn6Parser._parse ' + this.name)\n }\n\n getMatrix () {\n const h: Dsn6Header = this.volume.header\n\n const basisX = [\n h.xlen as number,\n 0,\n 0\n ]\n\n const basisY = [\n h.ylen * Math.cos(Math.PI / 180.0 * h.gamma),\n h.ylen * Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n\n const basisZ = [\n h.zlen * Math.cos(Math.PI / 180.0 * h.beta),\n h.zlen * (\n Math.cos(Math.PI / 180.0 * h.alpha) -\n Math.cos(Math.PI / 180.0 * h.gamma) *\n Math.cos(Math.PI / 180.0 * h.beta)\n ) / Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n basisZ[ 2 ] = Math.sqrt(\n h.zlen * h.zlen * Math.sin(Math.PI / 180.0 * h.beta) *\n Math.sin(Math.PI / 180.0 * h.beta) - basisZ[ 1 ] * basisZ[ 1 ]\n )\n\n const basis = [ [], basisX, basisY, basisZ ]\n const nxyz = [ 0, h.xRate, h.yRate, h.zRate ]\n const mapcrs = [ 0, 1, 2, 3 ]\n\n const matrix = new Matrix4()\n\n matrix.set(\n basis[ mapcrs[1] ][0] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][0] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][0] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][1] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][1] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][1] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][2] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][2] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][2] / nxyz[ mapcrs[3] ],\n 0,\n 0, 0, 0, 1\n )\n\n matrix.multiply(\n new Matrix4().makeRotationY(degToRad(90))\n )\n\n matrix.multiply(new Matrix4().makeTranslation(\n -h.zStart, h.yStart, h.xStart\n ))\n\n matrix.multiply(new Matrix4().makeScale(\n -1, 1, 1\n ))\n\n return matrix\n }\n}\n\nParserRegistry.add('dsn6', Dsn6Parser)\nParserRegistry.add('brix', Dsn6Parser)\n\nexport default Dsn6Parser\n","/**\n * @file Dx Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { degToRad } from '../math/math-utils'\nimport VolumeParser from './volume-parser'\n\nconst reWhitespace = /\\s+/\n\ninterface DxHeader {\n nx: number,\n ny: number,\n nz: number,\n xmin: number,\n ymin: number,\n zmin: number,\n hx: number,\n hy: number,\n hz: number\n}\n\nclass DxParser extends VolumeParser {\n get type () { return 'dx' }\n\n _parse () {\n // http://apbs.readthedocs.io/en/latest/formats/opendx.html\n\n if (Debug) Log.time('DxParser._parse ' + this.name)\n\n const v = this.volume\n const headerLines = this.streamer.peekLines(30)\n const headerInfo = this.parseHeaderLines(headerLines)\n const header = this.volume.header\n const dataLineStart = headerInfo.dataLineStart\n\n const size = header.nx * header.ny * header.nz\n const data = new Float32Array(size)\n let count = 0\n let lineNo = 0\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string []) {\n for (let i = _i; i < _n; ++i) {\n if (count < size && lineNo > dataLineStart) {\n const line = lines[ i ].trim()\n\n if (line !== '') {\n const ls = line.split(reWhitespace)\n\n for (let j = 0, lj = ls.length; j < lj; ++j) {\n data[ count ] = parseFloat(ls[ j ])\n ++count\n }\n }\n }\n\n ++lineNo\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n v.setData(data, header.nz, header.ny, header.nx)\n\n if (Debug) Log.timeEnd('DxParser._parse ' + this.name)\n }\n\n parseHeaderLines (headerLines: string []) {\n const header: Partial = {}\n const n = headerLines.length\n\n let dataLineStart = 0\n let headerByteCount = 0\n let deltaLineCount = 0\n\n for (let i = 0; i < n; ++i) {\n let ls\n const line = headerLines[ i ]\n\n if (line.startsWith('object 1')) {\n ls = line.split(reWhitespace)\n\n header.nx = parseInt(ls[ 5 ])\n header.ny = parseInt(ls[ 6 ])\n header.nz = parseInt(ls[ 7 ])\n } else if (line.startsWith('origin')) {\n ls = line.split(reWhitespace)\n\n header.xmin = parseFloat(ls[ 1 ])\n header.ymin = parseFloat(ls[ 2 ])\n header.zmin = parseFloat(ls[ 3 ])\n } else if (line.startsWith('delta')) {\n ls = line.split(reWhitespace)\n\n if (deltaLineCount === 0) {\n header.hx = parseFloat(ls[ 1 ]) * this.voxelSize\n } else if (deltaLineCount === 1) {\n header.hy = parseFloat(ls[ 2 ]) * this.voxelSize\n } else if (deltaLineCount === 2) {\n header.hz = parseFloat(ls[ 3 ]) * this.voxelSize\n }\n\n deltaLineCount += 1\n } else if (line.startsWith('object 3')) {\n dataLineStart = i\n headerByteCount += line.length + 1\n break\n }\n\n headerByteCount += line.length + 1\n }\n\n this.volume.header = header\n\n return {\n dataLineStart: dataLineStart,\n headerByteCount: headerByteCount\n }\n }\n\n getMatrix () {\n const h = this.volume.header\n const matrix = new Matrix4()\n\n matrix.multiply(\n new Matrix4().makeRotationY(degToRad(90))\n )\n\n matrix.multiply(\n new Matrix4().makeTranslation(\n -h.zmin, h.ymin, h.xmin\n )\n )\n\n matrix.multiply(\n new Matrix4().makeScale(\n -h.hz, h.hy, h.hx\n )\n )\n\n return matrix\n }\n}\n\nParserRegistry.add('dx', DxParser)\n\nexport default DxParser\n","/**\n * @file Dxbin Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { uint8ToLines, ensureBuffer } from '../utils'\nimport DxParser from './dx-parser'\n\nclass DxbinParser extends DxParser {\n get type () { return 'dxbin' }\n get isBinary () { return true }\n\n _parse () {\n // https://github.com/Electrostatics/apbs-pdb2pqr/issues/216\n\n if (Debug) Log.time('DxbinParser._parse ' + this.name)\n\n const bin = ensureBuffer(this.streamer.data)\n const headerLines = uint8ToLines(new Uint8Array(bin, 0, 1000))\n const headerInfo = this.parseHeaderLines(headerLines)\n const header = this.volume.header\n const headerByteCount = headerInfo.headerByteCount\n\n const size = header.nx * header.ny * header.nz\n const dv = new DataView(bin)\n const data = new Float32Array(size)\n\n for (let i = 0; i < size; ++i) {\n data[ i ] = dv.getFloat64(i * 8 + headerByteCount, true)\n }\n\n this.volume.setData(data, header.nz, header.ny, header.nx)\n\n if (Debug) Log.timeEnd('DxbinParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('dxbin', DxbinParser)\n\nexport default DxbinParser\n","/**\n * @file Mrc Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { ensureBuffer } from '../utils'\nimport VolumeParser from './volume-parser'\n\ninterface MrcHeader {\n MAP: string,\n MACHST: number [],\n NX: number,\n NY: number,\n NZ: number,\n MODE: number,\n NXSTART: number,\n NYSTART: number,\n NZSTART: number,\n MX: number,\n MY: number,\n MZ: number,\n xlen: number,\n ylen: number,\n zlen: number,\n alpha: number,\n beta: number,\n gamma: number,\n MAPC: number,\n MAPR: number,\n MAPS: number,\n DMIN: number,\n DMAX: number,\n DMEAN: number,\n ISPG: number,\n NSYMBT: number,\n LSKFLG: number,\n originX: number,\n originY: number,\n originZ: number,\n ARMS: number\n}\n\nclass MrcParser extends VolumeParser {\n get type () { return 'mrc' }\n get isBinary () { return true }\n\n _parse () {\n // MRC\n // http://ami.scripps.edu/software/mrctools/mrc_specification.php\n // http://www2.mrc-lmb.cam.ac.uk/research/locally-developed-software/image-processing-software/#image\n // http://bio3d.colorado.edu/imod/doc/mrc_format.txt\n\n // CCP4 (MAP)\n // http://www.ccp4.ac.uk/html/maplib.html\n\n // MRC format does not use the skew transformation header records (words 25-37)\n // CCP4 format does not use the ORIGIN header records (words 50-52)\n\n if (Debug) Log.time('MrcParser._parse ' + this.name)\n\n const v = this.volume\n const header: Partial = {}\n\n const bin = ensureBuffer(this.streamer.data)\n const intView = new Int32Array(bin, 0, 56)\n const floatView = new Float32Array(bin, 0, 56)\n const dv = new DataView(bin)\n\n // 53 MAP Character string 'MAP ' to identify file type\n header.MAP = String.fromCharCode(\n dv.getUint8(52 * 4), dv.getUint8(52 * 4 + 1),\n dv.getUint8(52 * 4 + 2), dv.getUint8(52 * 4 + 3)\n )\n\n // 54 MACHST Machine stamp indicating machine type which wrote file\n // 17 and 17 for big-endian or 68 and 65 for little-endian\n header.MACHST = [ dv.getUint8(53 * 4), dv.getUint8(53 * 4 + 1) ]\n\n // swap byte order when big endian\n if (header.MACHST[ 0 ] === 17 && header.MACHST[ 1 ] === 17) {\n const n = bin.byteLength\n for (let i = 0; i < n; i += 4) {\n dv.setFloat32(i, dv.getFloat32(i), true)\n }\n }\n\n header.NX = intView[ 0 ] // NC - columns (fastest changing)\n header.NY = intView[ 1 ] // NR - rows\n header.NZ = intView[ 2 ] // NS - sections (slowest changing)\n\n // mode\n // 0 image : signed 8-bit bytes range -128 to 127\n // 1 image : 16-bit halfwords\n // 2 image : 32-bit reals\n // 3 transform : complex 16-bit integers\n // 4 transform : complex 32-bit reals\n // 6 image : unsigned 16-bit range 0 to 65535\n // 16 image: unsigned char * 3 (for rgb data, non-standard)\n //\n // Note: Mode 2 is the normal mode used in the CCP4 programs.\n // Other modes than 2 and 0 may NOT WORK\n header.MODE = intView[ 3 ]\n\n // start\n header.NXSTART = intView[ 4 ] // NCSTART - first column\n header.NYSTART = intView[ 5 ] // NRSTART - first row\n header.NZSTART = intView[ 6 ] // NSSTART - first section\n\n // intervals\n header.MX = intView[ 7 ] // intervals along x\n header.MY = intView[ 8 ] // intervals along y\n header.MZ = intView[ 9 ] // intervals along z\n\n // cell length (Angstroms in CCP4)\n header.xlen = floatView[ 10 ] * this.voxelSize\n header.ylen = floatView[ 11 ] * this.voxelSize\n header.zlen = floatView[ 12 ] * this.voxelSize\n\n // cell angle (Degrees)\n header.alpha = floatView[ 13 ]\n header.beta = floatView[ 14 ]\n header.gamma = floatView[ 15 ]\n\n // axis correspondence (1,2,3 for X,Y,Z)\n header.MAPC = intView[ 16 ] // column\n header.MAPR = intView[ 17 ] // row\n header.MAPS = intView[ 18 ] // section\n\n // density statistics\n header.DMIN = floatView[ 19 ]\n header.DMAX = floatView[ 20 ]\n header.DMEAN = floatView[ 21 ]\n\n // space group number 0 or 1 (default=0)\n header.ISPG = intView[ 22 ]\n\n // number of bytes used for symmetry data (0 or 80)\n header.NSYMBT = intView[ 23 ]\n\n // Flag for skew transformation, =0 none, =1 if foll\n header.LSKFLG = intView[ 24 ]\n\n // 26-34 SKWMAT Skew matrix S (in order S11, S12, S13, S21 etc) if\n // LSKFLG .ne. 0.\n // 35-37 SKWTRN Skew translation t if LSKFLG != 0.\n // Skew transformation is from standard orthogonal\n // coordinate frame (as used for atoms) to orthogonal\n // map frame, as Xo(map) = S * (Xo(atoms) - t)\n\n // 38 future use (some of these are used by the MSUBSX routines\n // . \" in MAPBRICK, MAPCONT and FRODO)\n // . \" (all set to zero by default)\n // . \"\n // 52 \"\n\n // 50-52 origin in X,Y,Z used for transforms\n header.originX = floatView[ 49 ]\n header.originY = floatView[ 50 ]\n header.originZ = floatView[ 51 ]\n\n // 53 MAP Character string 'MAP ' to identify file type\n // => see top of this parser\n\n // 54 MACHST Machine stamp indicating machine type which wrote file\n // => see top of this parser\n\n // Rms deviation of map from mean density\n header.ARMS = floatView[ 54 ]\n\n // 56 NLABL Number of labels being used\n // 57-256 LABEL(20,10) 10 80 character text labels (ie. A4 format)\n\n v.header = header\n\n // Log.log( header );\n\n let data\n if (header.MODE === 2) {\n data = new Float32Array(\n bin, 256 * 4 + header.NSYMBT,\n header.NX * header.NY * header.NZ\n )\n } else if (header.MODE === 0) {\n data = new Float32Array(new Int8Array(\n bin, 256 * 4 + header.NSYMBT,\n header.NX * header.NY * header.NZ\n ))\n\n // based on uglymol (https://github.com/uglymol/uglymol) by Marcin Wojdyr (wojdyr)\n // if the file was converted by mapmode2to0 - scale the data\n if (intView[ 39 ] === -128 && intView[ 40 ] === 127) {\n // scaling f(x)=b1*x+b0 such that f(-128)=min and f(127)=max\n const b1 = (header.DMAX - header.DMIN) / 255.0\n const b0 = 0.5 * (header.DMIN + header.DMAX + b1)\n for (let j = 0, jl = data.length; j < jl; ++j) {\n data[ j ] = b1 * data[ j ] + b0\n }\n }\n } else {\n Log.error('MrcParser unknown mode', header.MODE)\n }\n\n v.setData(data, header.NX, header.NY, header.NZ)\n if (header.ARMS !== 0) {\n v.setStats(header.DMIN, header.DMAX, header.DMEAN, header.ARMS)\n }\n\n if (Debug) Log.timeEnd('MrcParser._parse ' + this.name)\n }\n\n getMatrix () {\n const h = this.volume.header\n\n const basisX = [\n h.xlen,\n 0,\n 0\n ]\n\n const basisY = [\n h.ylen * Math.cos(Math.PI / 180.0 * h.gamma),\n h.ylen * Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n\n const basisZ = [\n h.zlen * Math.cos(Math.PI / 180.0 * h.beta),\n h.zlen * (\n Math.cos(Math.PI / 180.0 * h.alpha) -\n Math.cos(Math.PI / 180.0 * h.gamma) *\n Math.cos(Math.PI / 180.0 * h.beta)\n ) / Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n basisZ[ 2 ] = Math.sqrt(\n h.zlen * h.zlen * Math.sin(Math.PI / 180.0 * h.beta) *\n Math.sin(Math.PI / 180.0 * h.beta) - basisZ[ 1 ] * basisZ[ 1 ]\n )\n\n const basis = [ [], basisX, basisY, basisZ ]\n const nxyz = [ 0, h.MX, h.MY, h.MZ ]\n const mapcrs = [ 0, h.MAPC, h.MAPR, h.MAPS ]\n\n const matrix = new Matrix4()\n\n matrix.set(\n basis[ mapcrs[1] ][0] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][0] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][0] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][1] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][1] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][1] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][2] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][2] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][2] / nxyz[ mapcrs[3] ],\n 0,\n 0, 0, 0, 1\n )\n\n matrix.setPosition(new Vector3(\n h.originX, h.originY, h.originZ\n ))\n\n matrix.multiply(new Matrix4().makeTranslation(\n h.NXSTART, h.NYSTART, h.NZSTART\n ))\n\n return matrix\n }\n}\n\nParserRegistry.add('mrc', MrcParser)\nParserRegistry.add('ccp4', MrcParser)\nParserRegistry.add('map', MrcParser)\n\nexport default MrcParser\n","/**\n * @file Xplor Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport VolumeParser from './volume-parser'\n\nconst reWhitespace = /\\s+/\n\nfunction parseNumberLine (line: string) {\n return line.trim().split(reWhitespace).map(parseFloat)\n}\n\ninterface XplorHeader {\n NA: number,\n AMIN: number,\n AMAX: number,\n NB: number,\n BMIN: number,\n BMAX: number,\n NC: number,\n CMIN: number,\n CMAX: number,\n a: number,\n b: number,\n c: number,\n alpha: number,\n beta: number,\n gamma: number,\n RAVE: number,\n RSIGMA: number\n}\n\nclass XplorParser extends VolumeParser {\n get type () { return 'xplor' }\n\n _parse () {\n // http://hincklab.uthscsa.edu/html/soft_packs/msi_docs/insight980/xplor/formats.html\n // http://www.mrc-lmb.cam.ac.uk/public/xtal/doc/cns/cns_1.3/tutorial/formats/maps/text.html\n\n if (Debug) Log.time('XplorParser._parse ' + this.name)\n\n const v = this.volume\n const headerLines = this.streamer.peekLines(8)\n const header: Partial = {}\n\n let infoStart\n if (headerLines[ 2 ].startsWith('REMARKS')) {\n infoStart = parseInt(headerLines[ 1 ].substring(0, 8)) + 2\n } else {\n infoStart = 5\n }\n const dataStart = infoStart + 3\n\n const gridInfo = parseNumberLine(headerLines[ infoStart ])\n header.NA = gridInfo[ 0 ]\n header.AMIN = gridInfo[ 1 ]\n header.AMAX = gridInfo[ 2 ]\n header.NB = gridInfo[ 3 ]\n header.BMIN = gridInfo[ 4 ]\n header.BMAX = gridInfo[ 5 ]\n header.NC = gridInfo[ 6 ]\n header.CMIN = gridInfo[ 7 ]\n header.CMAX = gridInfo[ 8 ]\n\n const cellInfo = parseNumberLine(headerLines[ infoStart + 1 ])\n header.a = cellInfo[ 0 ] * this.voxelSize\n header.b = cellInfo[ 1 ] * this.voxelSize\n header.c = cellInfo[ 2 ] * this.voxelSize\n header.alpha = cellInfo[ 3 ]\n header.beta = cellInfo[ 4 ]\n header.gamma = cellInfo[ 5 ]\n\n const na = header.AMAX - header.AMIN + 1\n const nb = header.BMAX - header.BMIN + 1\n const nc = header.CMAX - header.CMIN + 1\n const n = na * nb * nc\n\n const data = new Float32Array(n)\n const lineSection = Math.ceil(1 + (na * nb) / 6)\n let count = 0\n let lineNo = 0\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n\n if (lineNo >= dataStart && (lineNo - dataStart) % lineSection !== 0 && count < n) {\n for (let j = 0, lj = 6; j < lj; ++j) {\n const value = parseFloat(line.substr(12 * j, 12))\n if (isNaN(value)) { break } // Last line of map section\n data[count++] = value\n }\n } else if (count === n) {\n const lt = line.trim()\n if (lt && lt !== '-9999') {\n const ls = parseNumberLine(line)\n header.RAVE = ls[0]\n header.RSIGMA = ls[1]\n }\n }\n\n ++lineNo\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n v.header = header\n v.setData(data, na, nb, nc)\n if (header.RAVE !== 0 && header.RSIGMA !== 1) {\n v.setStats(undefined, undefined, header.RAVE, header.RSIGMA)\n }\n\n if (Debug) Log.timeEnd('XplorParser._parse ' + this.name)\n }\n\n getMatrix () {\n const h = this.volume.header\n\n const basisX = [\n h.a,\n 0,\n 0\n ]\n\n const basisY = [\n h.b * Math.cos(Math.PI / 180.0 * h.gamma),\n h.b * Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n\n const basisZ = [\n h.c * Math.cos(Math.PI / 180.0 * h.beta),\n h.c * (\n Math.cos(Math.PI / 180.0 * h.alpha) -\n Math.cos(Math.PI / 180.0 * h.gamma) *\n Math.cos(Math.PI / 180.0 * h.beta)\n ) / Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n basisZ[ 2 ] = Math.sqrt(\n h.c * h.c * Math.sin(Math.PI / 180.0 * h.beta) *\n Math.sin(Math.PI / 180.0 * h.beta) - basisZ[ 1 ] * basisZ[ 1 ]\n )\n\n const basis = [ [], basisX, basisY, basisZ ]\n const nxyz = [ 0, h.NA, h.NB, h.NC ]\n const mapcrs = [ 0, 1, 2, 3 ]\n\n const matrix = new Matrix4()\n\n matrix.set(\n basis[ mapcrs[1] ][0] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][0] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][0] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][1] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][1] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][1] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][2] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][2] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][2] / nxyz[ mapcrs[3] ],\n 0,\n 0, 0, 0, 1\n )\n\n matrix.multiply(new Matrix4().makeTranslation(\n h.AMIN, h.BMIN, h.CMIN\n ))\n\n return matrix\n }\n}\n\nParserRegistry.add('xplor', XplorParser)\nParserRegistry.add('cns', XplorParser)\n\nexport default XplorParser\n","/**\n * @file Kin Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { Vector3 } from 'three'\nimport Parser from './parser'\n\nfunction hsvToRgb (h: number, s: number, v: number) {\n h /= 360\n s /= 100\n v /= 100\n let r, g, b\n const i = Math.floor(h * 6)\n const f = h * 6 - i\n const p = v * (1 - s)\n const q = v * (1 - f * s)\n const t = v * (1 - (1 - f) * s)\n switch (i % 6) {\n case 0: r = v; g = t; b = p; break\n case 1: r = q; g = v; b = p; break\n case 2: r = p; g = v; b = t; break\n case 3: r = p; g = q; b = v; break\n case 4: r = t; g = p; b = v; break\n case 5: r = v; g = p; b = q; break\n }\n return [ r, g, b ] as number []\n}\n\nconst ColorDict: {[k: string]: number[]} = {\n red: hsvToRgb(0, 100, 100),\n orange: hsvToRgb(20, 100, 100),\n gold: hsvToRgb(40, 100, 100),\n yellow: hsvToRgb(60, 100, 100),\n lime: hsvToRgb(80, 100, 100),\n green: hsvToRgb(120, 80, 100),\n sea: hsvToRgb(150, 100, 100),\n cyan: hsvToRgb(180, 100, 85),\n sky: hsvToRgb(210, 75, 95),\n blue: hsvToRgb(240, 70, 100),\n purple: hsvToRgb(275, 75, 100),\n magenta: hsvToRgb(300, 95, 100),\n hotpink: hsvToRgb(335, 100, 100),\n pink: hsvToRgb(350, 55, 100),\n peach: hsvToRgb(25, 75, 100),\n lilac: hsvToRgb(275, 55, 100),\n pinktint: hsvToRgb(340, 30, 100),\n peachtint: hsvToRgb(25, 50, 100),\n yellowtint: hsvToRgb(60, 50, 100),\n greentint: hsvToRgb(135, 40, 100),\n bluetint: hsvToRgb(220, 40, 100),\n lilactint: hsvToRgb(275, 35, 100),\n white: hsvToRgb(0, 0, 100),\n gray: hsvToRgb(0, 0, 50),\n brown: hsvToRgb(20, 45, 75),\n deadwhite: [ 1, 1, 1 ],\n deadblack: [ 0, 0, 0 ],\n invisible: [ 0, 0, 0 ]\n}\n\nconst reWhitespaceComma = /[\\s,]+/\nconst reCurlyWhitespace = /[^{}\\s]*{[^{}]+}|[^{}\\s]+/g\nconst reTrimCurly = /^{+|}+$/g\nconst reTrimQuotes = /^['\"]+|['\"]+$/g\nconst reCollapseEqual = /\\s*=\\s*/g\n\nfunction parseListDef (line: string) {\n let name\n let defaultColor\n let master = []\n let width\n\n line = line.replace(reCollapseEqual, '=')\n\n const lm = line.match(reCurlyWhitespace) as RegExpMatchArray\n for (let j = 1; j < lm.length; ++j) {\n const e = lm[ j ]\n if (e[ 0 ] === '{') {\n name = e.substring(1, e.length - 1)\n } else {\n const es = e.split('=')\n if (es.length === 2) {\n if (es[ 0 ] === 'color') {\n defaultColor = ColorDict[ es[ 1 ] ]\n } else if (es[ 0 ] === 'width') {\n width = parseInt(es[ 1 ])\n } else if (es[ 0 ] === 'master') {\n master.push(es[ 1 ].replace(reTrimCurly, ''))\n }\n }\n }\n }\n\n return {\n listName: name,\n listColor: defaultColor,\n listMasters: master,\n listWidth: width\n }\n}\n\nfunction parseListElm (line: string) {\n line = line.trim()\n\n const idx1 = line.indexOf('{')\n const idx2 = line.indexOf('}')\n const ls = line.substr(idx2 + 1).split(reWhitespaceComma)\n\n const label = line.substr(idx1 + 1, idx2 - 1)\n const position = [\n parseFloat(ls[ ls.length - 3 ]),\n parseFloat(ls[ ls.length - 2 ]),\n parseFloat(ls[ ls.length - 1 ])\n ]\n let color, width, radius\n let lineBreak = false\n let triangleBreak = false\n for (let lsindex = 4; lsindex <= ls.length; lsindex++) {\n const literal = ls[ ls.length - lsindex ]\n if (literal in ColorDict) {\n color = ColorDict[ ls[ ls.length - lsindex ] ]\n }\n if (literal.startsWith('width')) {\n width = parseInt(literal.substring(5))\n }\n if (literal.startsWith('r=')) {\n radius = parseFloat(literal.split('=')[1])\n }\n if (literal.startsWith('P')) {\n lineBreak = true\n }\n if (literal.startsWith('X')) {\n triangleBreak = true\n }\n }\n // const color = line[ idx2 + 1 ] === ' ' ? undefined : ColorDict[ ls[ 0 ] ]\n\n return {\n label: label,\n position: position,\n color: color,\n radius: radius,\n width: width,\n isLineBreak: lineBreak,\n isTriangleBreak: triangleBreak\n }\n}\n\nfunction parseStr (line: string) {\n const start = line.indexOf('{')\n const end = line.indexOf('}')\n return line.substring(\n start !== -1 ? start + 1 : 0,\n end !== -1 ? end : undefined\n ).trim()\n}\n\nfunction parseFlag (line: string) {\n const end = line.indexOf('}')\n return end === -1 ? undefined : line.substr(end + 1).trim()\n}\n\nfunction parseGroup (line: string) {\n let name:string = ''\n let master:string[] = []\n let flags: {[k: string]: string|boolean} = {}\n\n line = line.replace(reCollapseEqual, '=')\n\n const lm = line.match(reCurlyWhitespace) as RegExpMatchArray\n for (let j = 1; j < lm.length; ++j) {\n const e = lm[ j ]\n if (e[ 0 ] === '{') {\n name = e.substring(1, e.length - 1)\n } else {\n const es = e.split('=')\n if (es.length === 2) {\n if (es[ 0 ] === 'master') {\n master.push(es[ 1 ].replace(reTrimCurly, ''))\n } else {\n flags[ es[ 0 ] ] = es[ 1 ].replace(reTrimCurly, '')\n }\n } else {\n flags[ es[ 0 ] ] = true\n }\n }\n }\n\n return { groupName: name,\n groupFlags: flags,\n groupMasters: master\n }\n}\ninterface RibbonObject {\n labelArray: string[],\n positionArray: number[],\n breakArray: boolean[],\n colorArray: number[],\n name?: string,\n masterArray: any[]\n}\nfunction convertKinTriangleArrays (ribbonObject: RibbonObject) {\n // have to convert ribbons/triangle lists from stripdrawmode to normal drawmode\n // index [ 0 1 2 3 4 5 6 7 8 91011 ]\n // label [ 0 1 2 3 4 5 ] to [ 0 1 2 1 2 3 2 3 4 3 4 5 ]\n // convertedindex [ 0 1 2 3 4 5 6 7 8 91011121314151617181920212223242526 ]\n // index [ 0 1 2 3 4 5 6 7 8 91011121314 ] [ 0 1 2 3 4 5 6 7 8 3 4 5 6 7 8 91011 6 7 8 91011121314 ]\n // position/color [ 0 0 0 1 1 1 2 2 2 3 3 3 4 4 4 ] to [ 0 0 0 1 1 1 2 2 2 1 1 1 2 2 2 3 3 3 2 2 2 3 3 3 4 4 4 ]\n let { labelArray, positionArray, colorArray, breakArray } = ribbonObject\n let convertedLabels = []\n for (let i = 0; i < (labelArray.length - 2) * 3; ++i) {\n convertedLabels[i] = labelArray[i - Math.floor(i / 3) * 2]\n }\n let convertedBreaks = []\n for (let i = 0; i < (breakArray.length - 2) * 3; ++i) {\n convertedBreaks[i] = breakArray[i - Math.floor(i / 3) * 2]\n }\n let convertedPositions = []\n for (let i = 0; i < (positionArray.length / 3 - 2) * 9; ++i) {\n convertedPositions[i] = positionArray[i - Math.floor(i / 9) * 6]\n }\n let convertedColors = []\n for (let i = 0; i < (colorArray.length / 3 - 2) * 9; ++i) {\n convertedColors[i] = colorArray[i - Math.floor(i / 9) * 6]\n }\n let vector3Positions = []\n for (let i = 0; i < (convertedPositions.length) / 3; ++i) {\n vector3Positions.push(new Vector3(convertedPositions[i * 3], convertedPositions[i * 3] + 1, convertedPositions[i * 3] + 2))\n }\n //let normals = []\n //for (let i = 0; i < vector3Positions.length - 1; ++i) {\n // let normalVec3 = vector3Positions[i].cross(vector3Positions[i + 1])\n // normals.push(normalVec3.x)\n // normals.push(normalVec3.y)\n // normals.push(normalVec3.z)\n //}\n return {\n name: ribbonObject.name,\n masterArray: ribbonObject.masterArray,\n labelArray: convertedLabels,\n positionArray: convertedPositions,\n breakArray: convertedBreaks,\n colorArray: convertedColors\n }\n}\n\nfunction removePointBreaksTriangleArrays (convertedRibbonObject: RibbonObject) {\n // after converting ribbon/triangle arrys to drawmode, removed point break triangles\n // label [ 0 1 2 3 4 5 ] to [ 0 1 2 1 2 3 2 3 4 3 4 5 ]\n // position/color [ 0 0 0 1 1 1 2 2 2 3 3 3 4 4 4 ] to [ 0 0 0 1 1 1 2 2 2 1 1 1 2 2 2 3 3 3 2 2 2 3 3 3 4 4 4 ]\n let { labelArray, positionArray, colorArray, breakArray } = convertedRibbonObject\n let editedLabels = []\n let editedPositions = []\n let editedColors = []\n let editedBreaks = []\n for (let i = 0; i < breakArray.length / 3; i++) {\n let breakPointer = i * 3\n let positionPointer = i * 9\n if (!breakArray[breakPointer+1]&&!breakArray[breakPointer+2]) {\n editedLabels.push(labelArray[breakPointer])\n editedLabels.push(labelArray[breakPointer+1])\n editedLabels.push(labelArray[breakPointer+2])\n editedBreaks.push(breakArray[breakPointer])\n editedBreaks.push(breakArray[breakPointer+1])\n editedBreaks.push(breakArray[breakPointer+2])\n editedPositions.push(positionArray[positionPointer])\n editedPositions.push(positionArray[positionPointer+1])\n editedPositions.push(positionArray[positionPointer+2])\n editedPositions.push(positionArray[positionPointer+3])\n editedPositions.push(positionArray[positionPointer+4])\n editedPositions.push(positionArray[positionPointer+5])\n editedPositions.push(positionArray[positionPointer+6])\n editedPositions.push(positionArray[positionPointer+7])\n editedPositions.push(positionArray[positionPointer+8])\n editedColors.push(colorArray[positionPointer])\n editedColors.push(colorArray[positionPointer+1])\n editedColors.push(colorArray[positionPointer+2])\n editedColors.push(colorArray[positionPointer+3])\n editedColors.push(colorArray[positionPointer+4])\n editedColors.push(colorArray[positionPointer+5])\n editedColors.push(colorArray[positionPointer+6])\n editedColors.push(colorArray[positionPointer+7])\n editedColors.push(colorArray[positionPointer+8])\n } else {\n //console.log('X triangle break found')\n //console.log('skipping: '+positionArray[positionPointer]+','+positionArray[positionPointer+1]+','+positionArray[positionPointer+2]+','\n // +positionArray[positionPointer+3]+','+positionArray[positionPointer+4]+','+positionArray[positionPointer+5]+','\n // +positionArray[positionPointer+6]+','+positionArray[positionPointer+7]+','+positionArray[positionPointer+8])\n }\n }\n return {\n name: convertedRibbonObject.name,\n masterArray: convertedRibbonObject.masterArray,\n labelArray: editedLabels,\n positionArray: editedPositions,\n breakArray: editedBreaks,\n colorArray: editedColors\n }\n}\n\ninterface Kinemage {\n kinemage?: number,\n onewidth?: any,\n '1viewid'?: string,\n pdbfile?: string,\n text: string,\n texts: string[],\n captions: string[],\n caption: string,\n groupDict: {[k:string]: {[k:string]: boolean}},\n subgroupDict: {[k: string]: any},\n masterDict: {[k:string]: {indent: boolean, visible: boolean}},\n pointmasterDict: {[k: string]: any},\n dotLists: DotList[],\n vectorLists: VectorList[],\n ballLists: any[],\n ribbonLists: RibbonObject[]\n}\n\ninterface DotList {\n name?: string,\n masterArray: any[],\n labelArray: any[],\n positionArray: any[],\n colorArray: any[]\n}\n\ninterface VectorList {\n name?: string,\n masterArray: any[],\n label1Array: string[],\n label2Array: string[],\n position1Array: number[],\n position2Array: number[],\n color1Array: number[],\n color2Array: number[],\n width: number[]\n}\n\nclass KinParser extends Parser {\n kinemage: Kinemage\n get type () { return 'kin' }\n get __objName () { return 'kinemage' }\n\n _parse () {\n // http://kinemage.biochem.duke.edu/software/king.php\n\n if (Debug) Log.time(`KinParser._parse ${this.name}`)\n\n const kinemage: Kinemage = {\n kinemage: undefined,\n onewidth: undefined,\n '1viewid': undefined,\n pdbfile: undefined,\n texts: [],\n text: '',\n captions: [],\n caption: '',\n groupDict: {},\n subgroupDict: {},\n masterDict: {},\n pointmasterDict: {},\n dotLists: [],\n vectorLists: [],\n ballLists: [],\n ribbonLists: []\n }\n this.kinemage = kinemage\n\n let currentGroupMasters: string[]\n let currentSubgroupMasters: string[]\n\n let isDotList = false\n let prevDotLabel = ''\n let dotDefaultColor: number[]\n let dotLabel: string[], dotPosition: number[], dotColor: number[]\n\n let isVectorList = false\n let prevVecLabel = ''\n let prevVecPosition: number[]|null = null\n let prevVecColor: number[]|null = null\n let vecDefaultColor: number[], vecDefaultWidth: number[]\n let vecLabel1: string[], vecLabel2: string[], vecPosition1: number[], vecPosition2: number[], vecColor1: number[], vecColor2: number[]\n\n let isBallList = false\n let prevBallLabel = ''\n let ballRadius: number[], ballDefaultColor: number[]\n let ballLabel: string[], ballPosition: number[], ballColor: number[]\n\n let isRibbonList = false\n let prevRibbonPointLabel = ''\n\n let ribbonListDefaultColor: number[]\n let ribbonPointLabelArray: string[], ribbonPointPositionArray: number[], ribbonPointBreakArray: boolean[], ribbonPointColorArray: number[]\n\n let isText = false\n let isCaption = false\n\n // @vectorlist {mc} color= white master= {mainchain}\n // { n thr A 1 B13.79 1crnFH} P 17.047, 14.099, 3.625 { n thr A 1 B13.79 1crnFH} L 17.047, 14.099, 3.625\n\n // @dotlist {x} color=white master={vdw contact} master={dots}\n // { CB THR 1 A}sky 'P' 18.915,14.199,5.024\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n\n if (line[ 0 ] === '@') {\n isDotList = false\n isVectorList = false\n isBallList = false\n isRibbonList = false\n isText = false\n isCaption = false\n }\n\n if (!line) {\n isDotList = false\n isVectorList = false\n isBallList = false\n isRibbonList = false\n } else if (line.startsWith('@dotlist')) {\n // @dotlist {x} color=white master={vdw contact} master={dots}\n\n let { listColor, listName, listMasters } = parseListDef(line)\n\n isDotList = true\n prevDotLabel = ''\n dotLabel = []\n dotPosition = []\n dotColor = []\n dotDefaultColor = listColor as number[]\n\n if (currentGroupMasters) {\n listMasters = listMasters.concat(currentGroupMasters)\n }\n if (currentSubgroupMasters) {\n listMasters = listMasters.concat(currentSubgroupMasters)\n }\n\n kinemage.dotLists.push({\n name: listName,\n masterArray: listMasters,\n labelArray: dotLabel,\n positionArray: dotPosition,\n colorArray: dotColor\n })\n } else if (line.startsWith('@vectorlist')) {\n // @vectorlist {x} color=white master={small overlap} master={dots}\n\n let { listMasters, listName, listWidth, listColor } = parseListDef(line)\n\n if (listMasters) {\n listMasters.forEach(function (name: string) {\n if (!kinemage.masterDict[ name ]) {\n kinemage.masterDict[ name ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n\n isVectorList = true\n prevVecLabel = ''\n prevVecPosition = null\n prevVecColor = null\n vecLabel1 = []\n vecLabel2 = []\n vecPosition1 = []\n vecPosition2 = []\n vecColor1 = []\n vecColor2 = []\n vecDefaultColor = listColor as number[]\n vecDefaultWidth = []\n if (listWidth) {\n vecDefaultWidth.push(listWidth)\n }\n\n if (currentGroupMasters) {\n listMasters = listMasters.concat(currentGroupMasters)\n }\n if (currentSubgroupMasters) {\n listMasters = listMasters.concat(currentSubgroupMasters)\n }\n\n kinemage.vectorLists.push({\n name: listName,\n masterArray: listMasters,\n label1Array: vecLabel1,\n label2Array: vecLabel2,\n position1Array: vecPosition1,\n position2Array: vecPosition2,\n color1Array: vecColor1,\n color2Array: vecColor2,\n width: vecDefaultWidth\n })\n } else if (line.startsWith('@balllist')) {\n let { listName, listColor, listMasters } = parseListDef(line)\n\n if (listMasters) {\n listMasters.forEach(function (name: string) {\n if (!kinemage.masterDict[ name ]) {\n kinemage.masterDict[ name ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n\n isBallList = true\n\n prevBallLabel = ''\n ballLabel = []\n ballRadius = []\n ballPosition = []\n ballColor = []\n ballDefaultColor = listColor as number[]\n\n if (currentGroupMasters) {\n listMasters = listMasters.concat(currentGroupMasters)\n }\n if (currentSubgroupMasters) {\n listMasters = listMasters.concat(currentSubgroupMasters)\n }\n\n kinemage.ballLists.push({\n name: listName,\n masterArray: listMasters,\n labelArray: ballLabel,\n radiusArray: ballRadius,\n positionArray: ballPosition,\n colorArray: ballColor\n })\n } else if (line.startsWith('@ribbonlist')||line.startsWith('@trianglelist')) {\n let { listMasters, listName, listColor } = parseListDef(line)\n\n if (listMasters) {\n listMasters.forEach(function (name: string) {\n if (!kinemage.masterDict[ name ]) {\n kinemage.masterDict[ name ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n isRibbonList = true\n prevRibbonPointLabel = ''\n ribbonPointLabelArray = []\n ribbonPointPositionArray = []\n ribbonPointBreakArray = []\n ribbonPointColorArray = []\n ribbonListDefaultColor = listColor as number[]\n\n if (currentGroupMasters) {\n listMasters = listMasters.concat(currentGroupMasters)\n }\n if (currentSubgroupMasters) {\n listMasters = listMasters.concat(currentSubgroupMasters)\n }\n\n kinemage.ribbonLists.push({\n name: listName,\n masterArray: listMasters,\n labelArray: ribbonPointLabelArray,\n positionArray: ribbonPointPositionArray,\n breakArray: ribbonPointBreakArray,\n colorArray: ribbonPointColorArray\n })\n } else if (line.startsWith('@text')) {\n isText = true\n kinemage.texts.push(line.substr(5))\n } else if (line.startsWith('@caption')) {\n isCaption = true\n kinemage.captions.push(line.substr(8))\n } else if (isDotList) {\n // { CB THR 1 A}sky 'P' 18.915,14.199,5.024\n\n let { label, color, position } = parseListElm(line)\n\n if (label === '\"') {\n label = prevDotLabel\n } else {\n prevDotLabel = label\n }\n\n if (color === undefined) {\n color = dotDefaultColor\n }\n\n dotLabel.push(label)\n dotPosition.push(...position)\n dotColor.push(...color)\n } else if (isVectorList) {\n // { n thr A 1 B13.79 1crnFH} P 17.047, 14.099, 3.625 { n thr A 1 B13.79 1crnFH} L 17.047, 14.099, 3.625\n\n let doubleLine = line.replace(/(?!^){/g, '\\n{')\n let splitLine = doubleLine.split(/\\n/)\n\n for (var i2 = 0; i2 < splitLine.length; i2++) {\n let singlePointLine = splitLine[i2]\n let { label, color, width, position, isLineBreak } = parseListElm(singlePointLine)\n\n if (label === '\"') {\n label = prevVecLabel\n } else {\n prevVecLabel = label\n }\n\n if (color === undefined) {\n color = vecDefaultColor\n }\n\n if (!isLineBreak) {\n if (prevVecPosition !== null) {\n if (width) {\n vecDefaultWidth.push(width)\n }\n\n vecLabel1.push(prevVecLabel)\n vecPosition1.push(...prevVecPosition)\n vecColor1.push(...prevVecColor as number[])\n\n vecLabel2.push(label)\n vecPosition2.push(...position)\n vecColor2.push(...color)\n\n }\n }\n\n prevVecLabel = label\n prevVecPosition = position\n prevVecColor = color\n }\n } else if (isBallList) {\n // {cb arg A 1 1.431 -106.80} r=1.431 39.085, 8.083, 22.182\n\n let { label, radius, color, position } = parseListElm(line)\n\n if (label === '\"') {\n label = prevBallLabel\n } else {\n prevBallLabel = label\n }\n\n if (radius === undefined) {\n radius = 1 // temporary default radius\n }\n\n if (color === undefined) {\n color = ballDefaultColor\n }\n\n ballLabel.push(label)\n ballRadius.push(radius)\n ballPosition.push(...position)\n ballColor.push(...color)\n } else if (isRibbonList) {\n let { label, color, position, isTriangleBreak } = parseListElm(line)\n\n if (label === '\"') {\n label = prevRibbonPointLabel\n } else {\n prevRibbonPointLabel = label\n }\n\n if (color === undefined) {\n color = ribbonListDefaultColor\n }\n\n ribbonPointLabelArray.push(label)\n ribbonPointPositionArray.push(...position)\n ribbonPointBreakArray.push(isTriangleBreak)\n ribbonPointColorArray.push(...color)\n } else if (isText) {\n kinemage.texts.push(line)\n } else if (isCaption) {\n kinemage.captions.push(line)\n } else if (line.startsWith('@kinemage')) {\n kinemage.kinemage = parseInt(line.substr(9).trim())\n } else if (line.startsWith('@onewidth')) {\n kinemage.onewidth = true\n } else if (line.startsWith('@1viewid')) {\n kinemage[ '1viewid' ] = parseStr(line)\n } else if (line.startsWith('@pdbfile')) {\n kinemage.pdbfile = parseStr(line)\n } else if (line.startsWith('@group')) {\n let { groupName, groupFlags, groupMasters } = parseGroup(line)\n if (!kinemage.groupDict[ groupName as string ]) {\n kinemage.groupDict[ groupName as string ] = {\n dominant: false,\n animate: false\n }\n currentGroupMasters = groupMasters\n }\n\n if (currentGroupMasters) {\n currentGroupMasters.forEach(function (master) {\n if (!kinemage.masterDict[ master ]) {\n kinemage.masterDict[ master ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n\n for (let key in groupFlags as {[k: string]: boolean}) {\n kinemage.groupDict[ groupName as string ][ key ] = (groupFlags as {[k: string]: boolean})[ key ]\n }\n } else if (line.startsWith('@subgroup')) {\n const { groupName, groupFlags, groupMasters } = parseGroup(line)\n\n if (!kinemage.subgroupDict[ groupName as string ]) {\n kinemage.subgroupDict[ groupName as string ] = {\n dominant: false,\n animate: false\n }\n currentSubgroupMasters = groupMasters\n }\n\n if (currentSubgroupMasters) {\n currentSubgroupMasters.forEach(function (master) {\n if (!kinemage.masterDict[ master ]) {\n kinemage.masterDict[ master ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n\n for (let key in groupFlags as {[k: string]: boolean}) {\n kinemage.subgroupDict[ groupName as string ][ key ] = (groupFlags as {[k: string]: boolean})[ key ]\n }\n } else if (line.startsWith('@master')) {\n const name = parseStr(line)\n const flag = parseFlag(line)\n\n if (!kinemage.masterDict[ name ]) {\n kinemage.masterDict[ name ] = {\n indent: false,\n visible: false\n }\n }\n\n if (flag === 'on') {\n kinemage.masterDict[ name ].visible = true\n } else if (flag === 'off') {\n kinemage.masterDict[ name ].visible = false\n } else if (flag === 'indent') {\n kinemage.masterDict[ name ].indent = true\n } else if (!flag) {\n // nothing to do\n }\n } else if (line.startsWith('@pointmaster')) {\n const { groupName, groupFlags } = parseGroup(line)\n\n kinemage.pointmasterDict[ groupName as string] = {\n id: Object.keys(groupFlags as {[k: string]: boolean})[ 0 ].replace(reTrimQuotes, '')\n }\n } else {\n console.log(line)\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n kinemage.text = kinemage.texts.join('\\n').trim()\n kinemage.caption = kinemage.captions.join('\\n').trim()\n if (kinemage.ribbonLists) {\n let convertedLists: RibbonObject[] = []\n kinemage.ribbonLists.forEach(function (listObject) {\n convertedLists.push(removePointBreaksTriangleArrays(convertKinTriangleArrays(listObject)))\n })\n kinemage.ribbonLists = convertedLists\n }\n\n if (Debug) Log.timeEnd(`KinParser._parse ${this.name}`)\n }\n}\n\nParserRegistry.add('kin', KinParser)\n\nexport default KinParser\n","/**\n * @file Surface Parser\n * @author Alexander Rose \n * @private\n */\n\nimport Parser, { ParserParameters } from './parser'\nimport Surface from '../surface/surface'\nimport Streamer from '../streamer/streamer';\n\nclass SurfaceParser extends Parser {\n constructor (streamer: Streamer, params?:Partial) {\n super(streamer, params)\n\n this.loader = this.getLoader()\n this.surface = new Surface(this.name, this.path)\n }\n\n get type () { return 'surface' }\n get __objName () { return 'surface' }\n\n _parse () {\n var geometry = this.loader.parse(this.streamer.asText())\n\n this.surface.fromGeometry(geometry)\n }\n}\n\nexport default SurfaceParser\n","/**\n * @file Obj Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { BufferGeometry, BufferAttribute } from 'three'\n\nimport { ParserRegistry } from '../globals'\nimport SurfaceParser from './surface-parser'\n\nexport interface _OBJLoader {\n regexp: {[k: string]: RegExp}\n}\n\ninterface _OBJLoaderConstructor {\n (this: _OBJLoader): void\n new(): _OBJLoader\n}\n\ninterface ObjectType {\n name: string,\n fromDeclaration: boolean,\n geometry: {\n vertices: number[],\n normals: number[],\n type?: string\n }\n}\n/**\n * OBJLoader\n * @class\n * @private\n * @author mrdoob / http://mrdoob.com/\n */\nconst OBJLoader = (function OBJLoader (this: _OBJLoader) {\n this.regexp = {\n // v float float float\n vertex_pattern: /^v\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)/,\n // vn float float float\n normal_pattern: /^vn\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)/,\n // vt float float\n uv_pattern: /^vt\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)/,\n // f vertex vertex vertex\n face_vertex: /^f\\s+(-?\\d+)\\s+(-?\\d+)\\s+(-?\\d+)(?:\\s+(-?\\d+))?/,\n // f vertex/uv vertex/uv vertex/uv\n face_vertex_uv: /^f\\s+(-?\\d+)\\/(-?\\d+)\\s+(-?\\d+)\\/(-?\\d+)\\s+(-?\\d+)\\/(-?\\d+)(?:\\s+(-?\\d+)\\/(-?\\d+))?/,\n // f vertex/uv/normal vertex/uv/normal vertex/uv/normal\n face_vertex_uv_normal: /^f\\s+(-?\\d+)\\/(-?\\d+)\\/(-?\\d+)\\s+(-?\\d+)\\/(-?\\d+)\\/(-?\\d+)\\s+(-?\\d+)\\/(-?\\d+)\\/(-?\\d+)(?:\\s+(-?\\d+)\\/(-?\\d+)\\/(-?\\d+))?/,\n // f vertex//normal vertex//normal vertex//normal\n face_vertex_normal: /^f\\s+(-?\\d+)\\/\\/(-?\\d+)\\s+(-?\\d+)\\/\\/(-?\\d+)\\s+(-?\\d+)\\/\\/(-?\\d+)(?:\\s+(-?\\d+)\\/\\/(-?\\d+))?/,\n // o object_name | g group_name\n object_pattern: /^[og]\\s*(.+)?/,\n // s boolean\n smoothing_pattern: /^s\\s+(\\d+|on|off)/,\n // mtllib file_reference\n material_library_pattern: /^mtllib /,\n // usemtl material_name\n material_use_pattern: /^usemtl /\n }\n}) as _OBJLoaderConstructor\n\nOBJLoader.prototype = {\n\n constructor: OBJLoader,\n\n setPath: function (value: string) {\n this.path = value\n },\n\n _createParserState: function () {\n var state = {\n objects: [] as ObjectType[],\n object: {} as ObjectType,\n\n vertices: [],\n normals: [],\n\n startObject: function (name: string, fromDeclaration: boolean) {\n // If the current object (initial from reset) is not from a g/o declaration in the parsed\n // file. We need to use it for the first parsed g/o to keep things in sync.\n if (this.object && this.object.fromDeclaration === false) {\n this.object.name = name\n this.object.fromDeclaration = (fromDeclaration !== false)\n return\n }\n\n this.object = {\n name: name || '',\n geometry: {\n vertices: [],\n normals: []\n },\n fromDeclaration: (fromDeclaration !== false)\n }\n\n this.objects.push(this.object)\n },\n\n parseVertexIndex: function (value: string, len: number) {\n var index = parseInt(value, 10)\n return (index >= 0 ? index - 1 : index + len / 3) * 3\n },\n\n parseNormalIndex: function (value: string, len: number) {\n var index = parseInt(value, 10)\n return (index >= 0 ? index - 1 : index + len / 3) * 3\n },\n\n addVertex: function (a: number, b: number, c: number) {\n var src = this.vertices\n var dst = this.object.geometry.vertices\n\n dst.push(src[ a + 0 ])\n dst.push(src[ a + 1 ])\n dst.push(src[ a + 2 ])\n dst.push(src[ b + 0 ])\n dst.push(src[ b + 1 ])\n dst.push(src[ b + 2 ])\n dst.push(src[ c + 0 ])\n dst.push(src[ c + 1 ])\n dst.push(src[ c + 2 ])\n },\n\n addVertexLine: function (a: number) {\n var src = this.vertices\n var dst = this.object.geometry.vertices\n\n dst.push(src[ a + 0 ])\n dst.push(src[ a + 1 ])\n dst.push(src[ a + 2 ])\n },\n\n addNormal: function (a: number, b: number, c: number) {\n var src = this.normals\n var dst = this.object.geometry.normals\n\n dst.push(src[ a + 0 ])\n dst.push(src[ a + 1 ])\n dst.push(src[ a + 2 ])\n dst.push(src[ b + 0 ])\n dst.push(src[ b + 1 ])\n dst.push(src[ b + 2 ])\n dst.push(src[ c + 0 ])\n dst.push(src[ c + 1 ])\n dst.push(src[ c + 2 ])\n },\n\n addFace: function (a: string, b: string, c: string, d?: string, na?: string, nb?: string, nc?: string, nd?: string) {\n var vLen = this.vertices.length\n\n var ia = this.parseVertexIndex(a, vLen)\n var ib = this.parseVertexIndex(b, vLen)\n var ic = this.parseVertexIndex(c, vLen)\n var id\n\n if (d === undefined) {\n this.addVertex(ia, ib, ic)\n } else {\n id = this.parseVertexIndex(d, vLen)\n\n this.addVertex(ia, ib, id)\n this.addVertex(ib, ic, id)\n }\n\n if (na !== undefined) {\n // Normals are many times the same. If so, skip function call and parseInt.\n var nLen = this.normals.length\n ia = this.parseNormalIndex(na, nLen)\n\n ib = na === nb ? ia : this.parseNormalIndex(nb!, nLen)\n ic = na === nc ? ia : this.parseNormalIndex(nc!, nLen)\n\n if (d === undefined) {\n this.addNormal(ia, ib, ic)\n } else {\n id = this.parseNormalIndex(nd!, nLen)\n\n this.addNormal(ia, ib, id)\n this.addNormal(ib, ic, id)\n }\n }\n },\n\n addLineGeometry: function (vertices: string[]) {\n this.object.geometry.type = 'Line'\n\n var vLen = this.vertices.length\n\n for (var vi = 0, l = vertices.length; vi < l; vi++) {\n this.addVertexLine(this.parseVertexIndex(vertices[ vi ], vLen))\n }\n }\n\n }\n\n state.startObject('', false)\n\n return state\n },\n\n parse: function (text: string) {\n var state = this._createParserState()\n\n if (text.indexOf('\\r\\n') !== -1) {\n // This is faster than String.split with regex that splits on both\n text = text.replace(/\\r\\n/g, '\\n')\n }\n\n if (text.indexOf('\\\\\\n') !== -1) {\n // join lines separated by a line continuation character (\\)\n text = text.replace(/\\\\\\n/g, '')\n }\n\n var i, l\n var lines = text.split('\\n')\n var line = ''\n var lineFirstChar = ''\n var lineSecondChar = ''\n var lineLength = 0\n var result = []\n\n // Faster to just trim left side of the line. Use if available.\n var trimLeft = (typeof ''.trimLeft === 'function')\n\n for (i = 0, l = lines.length; i < l; i++) {\n line = lines[ i ]\n\n line = trimLeft ? line.trimLeft() : line.trim()\n\n lineLength = line.length\n\n if (lineLength === 0) continue\n\n lineFirstChar = line.charAt(0)\n\n // @todo invoke passed in handler if any\n if (lineFirstChar === '#') continue\n\n if (lineFirstChar === 'v') {\n lineSecondChar = line.charAt(1)\n\n if (lineSecondChar === ' ' && (result = this.regexp.vertex_pattern.exec(line)) !== null) {\n // 0 1 2 3\n // [\"v 1.0 2.0 3.0\", \"1.0\", \"2.0\", \"3.0\"]\n\n state.vertices.push(\n parseFloat(result[ 1 ]),\n parseFloat(result[ 2 ]),\n parseFloat(result[ 3 ])\n )\n } else if (lineSecondChar === 'n' && (result = this.regexp.normal_pattern.exec(line)) !== null) {\n // 0 1 2 3\n // [\"vn 1.0 2.0 3.0\", \"1.0\", \"2.0\", \"3.0\"]\n\n state.normals.push(\n parseFloat(result[ 1 ]),\n parseFloat(result[ 2 ]),\n parseFloat(result[ 3 ])\n )\n } else if (lineSecondChar === 't' && this.regexp.uv_pattern.exec(line) !== null) {\n\n // ignore uv line\n\n } else {\n throw new Error(\"Unexpected vertex/normal/uv line: '\" + line + \"'\")\n }\n } else if (lineFirstChar === 'f') {\n if ((result = this.regexp.face_vertex_uv_normal.exec(line)) !== null) {\n // f vertex/uv/normal vertex/uv/normal vertex/uv/normal\n // 0 1 2 3 4 5 6 7 8 9 10 11 12\n // [\"f 1/1/1 2/2/2 3/3/3\", \"1\", \"1\", \"1\", \"2\", \"2\", \"2\", \"3\", \"3\", \"3\", undefined, undefined, undefined]\n\n state.addFace(\n result[ 1 ], result[ 4 ], result[ 7 ], result[ 10 ],\n // result[ 2 ], result[ 5 ], result[ 8 ], result[ 11 ], // ignore uv part\n result[ 3 ], result[ 6 ], result[ 9 ], result[ 12 ]\n )\n } else if (this.regexp.face_vertex_uv.exec(line) !== null) {\n\n // ignore uv line\n\n } else if ((result = this.regexp.face_vertex_normal.exec(line)) !== null) {\n // f vertex//normal vertex//normal vertex//normal\n // 0 1 2 3 4 5 6 7 8\n // [\"f 1//1 2//2 3//3\", \"1\", \"1\", \"2\", \"2\", \"3\", \"3\", undefined, undefined]\n\n state.addFace(\n result[ 1 ], result[ 3 ], result[ 5 ], result[ 7 ],\n result[ 2 ], result[ 4 ], result[ 6 ], result[ 8 ]\n )\n } else if ((result = this.regexp.face_vertex.exec(line)) !== null) {\n // f vertex vertex vertex\n // 0 1 2 3 4\n // [\"f 1 2 3\", \"1\", \"2\", \"3\", undefined]\n\n state.addFace(\n result[ 1 ], result[ 2 ], result[ 3 ], result[ 4 ]\n )\n } else {\n throw new Error(\"Unexpected face line: '\" + line + \"'\")\n }\n } else if (lineFirstChar === 'l') {\n var lineParts = line.substring(1).trim().split(' ')\n var lineVertices = []\n var lineUVs = []\n\n if (line.indexOf('/') === -1) {\n lineVertices = lineParts\n } else {\n for (var li = 0, llen = lineParts.length; li < llen; li++) {\n var parts = lineParts[ li ].split('/')\n\n if (parts[ 0 ] !== '') lineVertices.push(parts[ 0 ])\n if (parts[ 1 ] !== '') lineUVs.push(parts[ 1 ])\n }\n }\n state.addLineGeometry(lineVertices, lineUVs)\n } else if ((result = this.regexp.object_pattern.exec(line)) !== null) {\n // o object_name\n // or\n // g group_name\n\n var name = result[ 0 ].substr(1).trim()\n state.startObject(name)\n\n // ignore material related lines\n // eslint-disable-next-line no-empty\n } else if (this.regexp.material_use_pattern.test(line)) {\n // eslint-disable-next-line no-empty\n } else if (this.regexp.material_library_pattern.test(line)) {\n // eslint-disable-next-line no-empty\n } else if (this.regexp.smoothing_pattern.exec(line) !== null) {\n } else {\n // Handle null terminated files without exception\n if (line === '\\0') continue\n\n throw new Error(\"Unexpected line: '\" + line + \"'\")\n }\n }\n\n var container = []\n\n for (i = 0, l = state.objects.length; i < l; i++) {\n var object = state.objects[ i ]\n var geometry = object.geometry\n\n // Skip o/g line declarations that did not follow with any faces\n if (geometry.vertices.length === 0) continue\n\n var buffergeometry = new BufferGeometry()\n\n buffergeometry.setAttribute('position', new BufferAttribute(new Float32Array(geometry.vertices), 3))\n\n if (geometry.normals.length > 0) {\n buffergeometry.setAttribute('normal', new BufferAttribute(new Float32Array(geometry.normals), 3))\n } else {\n buffergeometry.computeVertexNormals()\n }\n\n container.push(buffergeometry)\n }\n\n return container\n }\n\n}\n\nclass ObjParser extends SurfaceParser {\n get type () { return 'obj' }\n\n getLoader () {\n return new OBJLoader()\n }\n}\n\nParserRegistry.add('obj', ObjParser)\n\nexport default ObjParser\n","/**\n * @file Ply Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Geometry, Vector3, Face3, Color } from 'three'\n\nimport { ParserRegistry } from '../globals'\nimport SurfaceParser from './surface-parser'\n\n/**\n * PLYLoader\n * @class\n * @private\n * @author Wei Meng / http://about.me/menway\n *\n * @description\n * A THREE loader for PLY ASCII files (known as the Polygon File Format or the Stanford Triangle Format).\n *\n * Limitations: ASCII decoding assumes file is UTF-8.\n *\n * @example\n * var loader = new THREE.PLYLoader();\n * loader.load('./models/ply/ascii/dolphins.ply', function (geometry) {\n * scene.add( new THREE.Mesh( geometry ) );\n * } );\n *\n * // If the PLY file uses non standard property names, they can be mapped while\n * // loading. For example, the following maps the properties\n * // “diffuse_(red|green|blue)” in the file to standard color names.\n *\n * loader.setPropertyNameMapping( {\n * diffuse_red: 'red',\n * diffuse_green: 'green',\n * diffuse_blue: 'blue'\n * } );\n *\n */\n\nexport interface _PLYLoader {\n propertyNameMapping: {[k: string]: string}\n}\n\ninterface _PLYLoaderConstructor {\n (this: _PLYLoader): void\n new(): _PLYLoader\n}\n\ninterface PLYProperty {\n type: string,\n name: string,\n countType: string,\n itemType: string\n}\n\ninterface PLYElement {\n name: string,\n count: number,\n properties: PLYProperty[],\n x: number,\n y: number,\n z: number,\n red: number,\n green: number,\n blue: number,\n [k:string]: any\n}\n\ninterface PLYHeader {\n format: string,\n version: string,\n comments: string[],\n elements: PLYElement[],\n headerLength: number\n}\n\ninterface GeometryPLY extends Geometry {\n useColor: boolean\n}\n\nconst PLYLoader = (function PLYLoader (this: _PLYLoader) {\n this.propertyNameMapping = {}\n}) as _PLYLoaderConstructor\n\nPLYLoader.prototype = {\n\n constructor: PLYLoader,\n\n setPropertyNameMapping: function (mapping: {[k: string]: string}) {\n this.propertyNameMapping = mapping\n },\n\n bin2str: function (buf: ArrayBuffer) {\n var arrayBuffer = new Uint8Array(buf)\n var str = ''\n for (var i = 0; i < buf.byteLength; i++) {\n str += String.fromCharCode(arrayBuffer[ i ]) // implicitly assumes little-endian\n }\n\n return str\n },\n\n isASCII: function (data: ArrayBuffer) {\n var header = this.parseHeader(this.bin2str(data))\n\n return header.format === 'ascii'\n },\n\n parse: function (data: string|ArrayBuffer) {\n if (data instanceof ArrayBuffer) {\n return (\n this.isASCII(data)\n ? this.parseASCII(this.bin2str(data))\n : this.parseBinary(data)\n )\n } else {\n return this.parseASCII(data)\n }\n },\n\n parseHeader: function (data: string) {\n var patternHeader = /ply([\\s\\S]*)end_header\\s/\n var headerText = ''\n var headerLength = 0\n var result = patternHeader.exec(data)\n if (result !== null) {\n headerText = result[ 1 ]\n headerLength = result[ 0 ].length\n }\n\n var header: Partial = {\n comments: [],\n elements: [],\n headerLength: headerLength\n }\n\n var lines = headerText.split('\\n')\n var currentElement: PLYElement|undefined, lineType, lineValues\n\n function makePlyElementProperty (propertValues: string[], propertyNameMapping: {[k: string]: string}) {\n var property = {\n type: propertValues[ 0 ]\n } as PLYProperty\n\n if (property.type === 'list') {\n property.name = propertValues[ 3 ]\n property.countType = propertValues[ 1 ]\n property.itemType = propertValues[ 2 ]\n } else {\n property.name = propertValues[ 1 ]\n }\n\n if (property.name in propertyNameMapping) {\n property.name = propertyNameMapping[ property.name ]\n }\n\n return property\n }\n\n for (var i = 0; i < lines.length; i++) {\n var line = lines[ i ]\n line = line.trim()\n if (line === '') {\n continue\n }\n lineValues = line.split(/\\s+/)\n lineType = lineValues.shift()\n line = lineValues.join(' ')\n\n switch (lineType) {\n case 'format':\n\n header.format = lineValues[ 0 ]\n header.version = lineValues[ 1 ]\n\n break\n\n case 'comment':\n\n header.comments!.push(line)\n\n break\n\n case 'element':\n\n if (currentElement !== undefined) {\n header.elements!.push(currentElement as PLYElement)\n }\n\n currentElement = {} as PLYElement\n currentElement.name = lineValues[ 0 ]\n currentElement.count = parseInt(lineValues[ 1 ])\n currentElement.properties = []\n\n break\n\n case 'property':\n\n currentElement!.properties.push(makePlyElementProperty(lineValues, this.propertyNameMapping))\n\n break\n\n default:\n\n console.log('unhandled', lineType, lineValues)\n }\n }\n\n if (currentElement !== undefined) {\n header.elements!.push(currentElement)\n }\n\n return header\n },\n\n parseASCIINumber: function (n: string, type: string) {\n switch (type) {\n case 'char': case 'uchar': case 'short': case 'ushort': case 'int': case 'uint':\n case 'int8': case 'uint8': case 'int16': case 'uint16': case 'int32': case 'uint32':\n\n return parseInt(n)\n\n case 'float': case 'double': case 'float32': case 'float64':\n\n return parseFloat(n)\n }\n },\n\n parseASCIIElement: function (properties: PLYProperty[], line: string) {\n var values = line.split(/\\s+/)\n\n var element = {} as PLYElement\n\n for (var i = 0; i < properties.length; i++) {\n if (properties[ i ].type === 'list') {\n var list = []\n var n = this.parseASCIINumber(values.shift(), properties[ i ].countType)\n\n for (var j = 0; j < n; j++) {\n list.push(this.parseASCIINumber(values.shift(), properties[ i ].itemType))\n }\n\n element[ properties[ i ].name ] = list\n } else {\n element[ properties[ i ].name ] = this.parseASCIINumber(values.shift(), properties[ i ].type)\n }\n }\n\n return element\n },\n\n parseASCII: function (data: string) {\n // PLY ascii format specification, as per http://en.wikipedia.org/wiki/PLY_(file_format)\n\n var geometry = new Geometry() as GeometryPLY\n\n var result\n\n var header = this.parseHeader(data)\n\n var patternBody = /end_header\\s([\\s\\S]*)$/\n var body = ''\n if ((result = patternBody.exec(data)) !== null) {\n body = result[ 1 ]\n }\n\n var lines = body.split('\\n')\n var currentElement = 0\n var currentElementCount = 0\n geometry.useColor = false\n\n for (var i = 0; i < lines.length; i++) {\n var line = lines[ i ]\n line = line.trim()\n if (line === '') {\n continue\n }\n\n if (currentElementCount >= header.elements[ currentElement ].count) {\n currentElement++\n currentElementCount = 0\n }\n\n var element = this.parseASCIIElement(header.elements[ currentElement ].properties, line)\n\n this.handleElement(geometry, header.elements[ currentElement ].name, element)\n\n currentElementCount++\n }\n\n return this.postProcess(geometry)\n },\n\n postProcess: function (geometry: GeometryPLY) {\n if (geometry.useColor) {\n for (var i = 0; i < geometry.faces.length; i++) {\n geometry.faces[ i ].vertexColors = [\n geometry.colors[ geometry.faces[ i ].a ],\n geometry.colors[ geometry.faces[ i ].b ],\n geometry.colors[ geometry.faces[ i ].c ]\n ]\n }\n\n geometry.elementsNeedUpdate = true\n }\n\n geometry.computeBoundingSphere()\n\n return geometry\n },\n\n handleElement: function (geometry: GeometryPLY, elementName: string, element: PLYElement) {\n if (elementName === 'vertex') {\n geometry.vertices.push(\n new Vector3(element.x, element.y, element.z)\n )\n\n if ('red' in element && 'green' in element && 'blue' in element) {\n geometry.useColor = true\n\n var color = new Color()\n color.setRGB(element.red / 255.0, element.green / 255.0, element.blue / 255.0)\n geometry.colors.push(color)\n }\n } else if (elementName === 'face') {\n var vertexIndices = element.vertex_indices\n\n if (vertexIndices.length === 3) {\n geometry.faces.push(\n new Face3(vertexIndices[ 0 ], vertexIndices[ 1 ], vertexIndices[ 2 ])\n )\n } else if (vertexIndices.length === 4) {\n geometry.faces.push(\n new Face3(vertexIndices[ 0 ], vertexIndices[ 1 ], vertexIndices[ 3 ]),\n new Face3(vertexIndices[ 1 ], vertexIndices[ 2 ], vertexIndices[ 3 ])\n )\n }\n }\n },\n\n binaryRead: function (dataview: DataView, at: number, type: string, littleEndian: boolean) {\n switch (type) {\n // corespondences for non-specific length types here match rply:\n case 'int8': case 'char': return [ dataview.getInt8(at), 1 ]\n\n case 'uint8': case 'uchar': return [ dataview.getUint8(at), 1 ]\n\n case 'int16': case 'short': return [ dataview.getInt16(at, littleEndian), 2 ]\n\n case 'uint16': case 'ushort': return [ dataview.getUint16(at, littleEndian), 2 ]\n\n case 'int32': case 'int': return [ dataview.getInt32(at, littleEndian), 4 ]\n\n case 'uint32': case 'uint': return [ dataview.getUint32(at, littleEndian), 4 ]\n\n case 'float32': case 'float': return [ dataview.getFloat32(at, littleEndian), 4 ]\n\n case 'float64': case 'double': return [ dataview.getFloat64(at, littleEndian), 8 ]\n }\n },\n\n binaryReadElement: function (dataview: DataView, at: number, properties: PLYProperty[], littleEndian: boolean) {\n var element = {} as PLYElement\n var result\n var read = 0\n\n for (var i = 0; i < properties.length; i++) {\n if (properties[ i ].type === 'list') {\n var list = []\n\n result = this.binaryRead(dataview, at + read, properties[ i ].countType, littleEndian)\n var n = result[ 0 ]\n read += result[ 1 ]\n\n for (var j = 0; j < n; j++) {\n result = this.binaryRead(dataview, at + read, properties[ i ].itemType, littleEndian)\n list.push(result[ 0 ])\n read += result[ 1 ]\n }\n\n element[ properties[ i ].name ] = list\n } else {\n result = this.binaryRead(dataview, at + read, properties[ i ].type, littleEndian)\n element[ properties[ i ].name ] = result[ 0 ]\n read += result[ 1 ]\n }\n }\n\n return [ element, read ]\n },\n\n parseBinary: function (data: ArrayBuffer) {\n var geometry = new Geometry()\n\n var header = this.parseHeader(this.bin2str(data))\n var littleEndian = (header.format === 'binary_little_endian')\n var body = new DataView(data, header.headerLength)\n var result\n var loc = 0\n\n for (var currentElement = 0; currentElement < header.elements.length; currentElement++) {\n for (var currentElementCount = 0; currentElementCount < header.elements[ currentElement ].count; currentElementCount++) {\n result = this.binaryReadElement(body, loc, header.elements[ currentElement ].properties, littleEndian)\n loc += result[ 1 ]\n var element = result[ 0 ]\n\n this.handleElement(geometry, header.elements[ currentElement ].name, element)\n }\n }\n\n return this.postProcess(geometry)\n }\n\n}\n\nclass PlyParser extends SurfaceParser {\n get type () { return 'ply' }\n\n getLoader () {\n return new PLYLoader()\n }\n}\n\nParserRegistry.add('ply', PlyParser)\n\nexport default PlyParser\n","/**\n * @file Csv Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { ParserRegistry } from '../globals'\nimport Parser, { ParserParameters } from './parser'\nimport Streamer from '../streamer/streamer';\n\nexport interface CsvParserParameters extends ParserParameters {\n delimiter: string\n comment: string\n columnNames: boolean\n}\n/**\n * CSV parser\n */\nclass CsvParser extends Parser {\n /**\n * [constructor description]\n * @param {Streamer} streamer - the streamer object\n * @param {Object} params - parameter object\n * @param {Char} params.delimiter - delimiter character\n * @param {Char} params.comment - comment character\n * @param {Boolean} params.columnNames - use first data line as column names\n */\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.delimiter = defaults(p.delimiter, ',')\n this.comment = defaults(p.comment, '#')\n this.columnNames = defaults(p.columnNames, false)\n\n this.table = {\n name: this.name,\n path: this.path,\n columnNames: [],\n data: []\n }\n }\n\n get type () { return 'csv' }\n get __objName () { return 'table' }\n\n _parse () {\n const data = this.table.data\n const reDelimiter = new RegExp('\\\\s*' + this.delimiter + '\\\\s*')\n\n let j = 0\n\n this.streamer.eachChunkOfLines(chunk => {\n const n = chunk.length\n\n for (let i = 0; i < n; ++i) {\n const line = chunk[ i ].trim()\n if (line.startsWith(this.comment)) continue\n const values = line.split(reDelimiter)\n\n if (j === 0) {\n this.table.columnNames = values\n } else if (line) {\n data.push(values)\n }\n ++j\n }\n })\n }\n}\n\nParserRegistry.add('csv', CsvParser)\n\nexport default CsvParser\n","/**\n * @file Json Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Parser, { ParserParameters } from './parser'\nimport Streamer from '../streamer/streamer';\n\nexport interface JsonParserParameters extends ParserParameters {\n string: boolean\n}\n\nclass JsonParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.string = defaults(p.string, false)\n\n this.json = {\n name: this.name,\n path: this.path,\n data: {}\n }\n }\n\n get type () { return 'json' }\n get __objName () { return 'json' }\n get isJson () { return true }\n\n _parse () {\n if (this.streamer.isBinary() || this.string) {\n this.json.data = JSON.parse(this.streamer.asText())\n } else {\n this.json.data = this.streamer.data\n }\n }\n}\n\nParserRegistry.add('json', JsonParser)\n\nexport default JsonParser\n","/**\n * @file Msgpack Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport Parser, { ParserParameters } from './parser'\n\nimport { decodeMsgpack } from '../../lib/mmtf.es6'\nimport Streamer from '../streamer/streamer';\n\nclass MsgpackParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.msgpack = {\n name: this.name,\n path: this.path,\n data: undefined\n }\n }\n\n get type () { return 'msgpack' }\n get __objName () { return 'msgpack' }\n get isBinary () { return true }\n\n _parse () {\n if (Debug) Log.time('MsgpackParser._parse ' + this.name)\n\n this.msgpack.data = decodeMsgpack(this.streamer.data)\n\n if (Debug) Log.timeEnd('MsgpackParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('msgpack', MsgpackParser)\n\nexport default MsgpackParser\n","/**\n * @file Netcdf Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport Parser, { ParserParameters } from './parser'\nimport NetcdfReader from '../utils/netcdf-reader'\nimport Streamer from '../streamer/streamer';\n\nclass NetcdfParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.netcdf = {\n name: this.name,\n path: this.path,\n data: undefined\n }\n }\n\n get type () { return 'netcdf' }\n get __objName () { return 'netcdf' }\n get isBinary () { return true }\n\n _parse () {\n if (Debug) Log.time('NetcdfParser._parse ' + this.name)\n\n this.netcdf.data = new NetcdfReader(this.streamer.data)\n\n if (Debug) Log.timeEnd('NetcdfParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('netcdf', NetcdfParser)\n\nexport default NetcdfParser\n","/**\n * @file Text Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport Parser, { ParserParameters } from './parser'\nimport Streamer from '../streamer/streamer';\n\nclass TextParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n super(streamer, params)\n\n this.text = {\n\n name: this.name,\n path: this.path,\n data: ''\n\n }\n }\n\n get type () { return 'text' }\n get __objName () { return 'text' }\n\n _parse () {\n this.text.data = this.streamer.asText()\n }\n}\n\nParserRegistry.add('txt', TextParser)\nParserRegistry.add('text', TextParser)\n\nexport default TextParser\n","/**\n * @file Parse Xml\n * @author Alexander Rose \n * @private\n */\n\n// https://github.com/segmentio/xml-parser\n// MIT license\n\nexport type XMLNodeAttributes = { [k: string]: any }\nexport interface XMLNode {\n name?: string\n content?: string\n attributes: XMLNodeAttributes\n children?: XMLNode[]\n}\n\nconst reStrip = /^['\"]|['\"]$/g\nconst reTag = /^<([\\w-:.]+)\\s*/\nconst reContent = /^([^<]*)/\nconst reAttr = /([\\w:-]+)\\s*=\\s*(\"[^\"]*\"|'[^']*'|\\w+)\\s*/\n\nfunction strip (val: string) {\n return val.replace(reStrip, '')\n}\n\nexport function parseXml (xml: string) {\n // trim and strip comments\n xml = xml.trim().replace(//g, '')\n\n return document()\n\n function document () {\n return {\n declaration: declaration(),\n root: tag()\n }\n }\n\n function declaration () {\n const m = match(/^<\\?xml\\s*/)\n if (!m) return\n\n // tag\n const node: XMLNode = {\n attributes: {}\n }\n\n // attributes\n while (!(eos() || is('?>'))) {\n const attr = attribute()\n if (!attr) return node\n node.attributes[attr.name] = attr.value\n }\n match(/\\?>\\s*/)\n return node\n }\n\n function tag () {\n const m = match(reTag)\n if (!m) return\n\n // name\n const node: XMLNode = {\n name: m[1],\n attributes: {},\n children: []\n }\n\n // attributes\n while (!(eos() || is('>') || is('?>') || is('/>'))) {\n const attr = attribute()\n if (!attr) return node\n node.attributes[attr.name] = attr.value\n }\n\n // self closing tag\n if (match(/^\\s*\\/>\\s*/)) {\n return node\n }\n match(/\\??>\\s*/)\n\n // content\n node.content = content()\n\n // children\n let child\n while ((child = tag())) {\n node.children!.push(child)\n }\n\n // closing\n match(/^<\\/[\\w-:.]+>\\s*/)\n return node\n }\n\n function content () {\n const m = match(reContent)\n if (m) return m[1]\n return ''\n }\n\n function attribute () {\n const m = match(reAttr)\n if (!m) return\n return { name: m[1], value: strip(m[2]) }\n }\n\n function match (re: RegExp) {\n const m = xml.match(re)\n if (!m) return\n xml = xml.slice(m[0].length)\n return m\n }\n\n function eos () {\n return xml.length === 0\n }\n\n function is (prefix: string) {\n return xml.indexOf(prefix) === 0\n }\n}\n","/**\n * @file Xml Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { defaults } from '../utils'\n// @ts-ignore: unused import XMLNode required for declaration only\nimport { parseXml, XMLNode } from '../utils/parse-xml'\nimport Parser, { ParserParameters } from './parser'\nimport Streamer from '../streamer/streamer';\n\nexport interface XmlParserParameters extends ParserParameters {\n useDomParser: boolean\n}\n\nclass XmlParser extends Parser {\n xml: {\n name: string\n path: string\n data: any\n }\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.useDomParser = defaults(p.useDomParser, false)\n\n this.xml = {\n name: this.name,\n path: this.path,\n data: {}\n }\n }\n\n get type () { return 'xml' }\n get __objName () { return 'xml' }\n get isXml () { return true }\n\n __xmlParser (xml: string) {\n return parseXml(xml)\n }\n\n __domParser (xml: string) {\n const domParser = new (window as any).DOMParser() as DOMParser\n return domParser.parseFromString(xml, 'text/xml')\n }\n\n _parse () {\n if (Debug) Log.time('XmlParser._parse ' + this.name)\n\n if (this.useDomParser) {\n if (this.streamer.data instanceof Document) { //TS conversion: stripped the window prefix from window.Document\n this.xml.data = this.streamer.data\n } else {\n this.xml.data = this.__domParser(this.streamer.asText())\n }\n } else {\n this.xml.data = this.__xmlParser(this.streamer.asText())\n }\n\n if (Debug) Log.timeEnd('XmlParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('xml', XmlParser)\n\nexport default XmlParser\n","/**\n * @file Validation\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Color } from 'three'\n\nimport { Debug, Log } from '../globals'\nimport { defaults } from '../utils'\nimport { ClashPicker } from '../utils/picker'\nimport { uniformArray3 } from '../math/array-utils'\nimport { guessElement } from '../structure/structure-utils'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Structure from '../structure/structure'\n\nfunction getNamedItem(a: NamedNodeMap, name: string) {\n const item = a.getNamedItem(name)\n return item !== null ? item.value : ''\n}\n\nfunction getSele (a: NamedNodeMap, atomname?: string, useAltcode = false) {\n const icode = getNamedItem(a, 'icode').trim()\n const chain = getNamedItem(a, 'chain').trim()\n const altcode = getNamedItem(a, 'altcode')\n let sele = getNamedItem(a, 'resnum')\n if (icode) sele += '^' + icode\n if (chain) sele += ':' + chain\n if (atomname) sele += '.' + atomname\n if (useAltcode && altcode.trim()) sele += '%' + altcode\n sele += '/' + (parseInt(getNamedItem(a, 'model')) - 1)\n return sele\n}\n\nfunction getResSele (a: NamedNodeMap) {\n const chain = getNamedItem(a, 'chain').trim()\n const rescode = getNamedItem(a, 'rescode')\n const resnum = getNamedItem(a, 'resnum')\n let sele = `[${rescode}]${resnum}`\n if (chain) sele += `:${chain}`\n return sele\n}\n\nfunction setBitDict (dict: { [k: string]: number }, key: string, bit: number) {\n if (dict[ key ] === undefined) {\n dict[ key ] = bit\n } else {\n dict[ key ] |= bit\n }\n}\n\nfunction hasAttrValue (attr: Attr|null, value: string) {\n return attr !== null && attr.value === value\n}\n\nfunction getAtomSele (ap: AtomProxy) {\n const icode = ap.inscode\n const chain = ap.chainname\n const atomname = ap.atomname\n const altcode = ap.altloc\n let sele = ap.resno + ''\n if (icode) sele += '^' + icode\n if (chain) sele += ':' + chain\n if (atomname) sele += '.' + atomname\n if (altcode) sele += '%' + altcode\n sele += '/' + ap.modelIndex\n return sele\n}\n\nfunction getProblemCount (clashDict: { [k: string]: { [k: string]: string } }, g: Element, ga: NamedNodeMap) {\n let geoProblemCount = 0\n\n const clashes = g.getElementsByTagName('clash')\n for (let j = 0, jl = clashes.length; j < jl; ++j) {\n if (clashDict[ getNamedItem(clashes[ j ].attributes, 'cid') ]) {\n geoProblemCount += 1\n break\n }\n }\n\n const angleOutliers = g.getElementsByTagName('angle-outlier')\n if (angleOutliers.length > 0) {\n geoProblemCount += 1\n }\n\n const bondOutliers = g.getElementsByTagName('bond-outlier')\n if (bondOutliers.length > 0) {\n geoProblemCount += 1\n }\n\n const planeOutliers = g.getElementsByTagName('plane-outlier')\n if (planeOutliers.length > 0) {\n geoProblemCount += 1\n }\n\n if (hasAttrValue(ga.getNamedItem('rota'), 'OUTLIER')) {\n geoProblemCount += 1\n }\n\n if (hasAttrValue(ga.getNamedItem('rama'), 'OUTLIER')) {\n geoProblemCount += 1\n }\n\n if (hasAttrValue(ga.getNamedItem('RNApucker'), 'outlier')) {\n geoProblemCount += 1\n }\n\n return geoProblemCount\n}\n\nclass Validation {\n rsrzDict: { [k: string]: number } = {}\n rsccDict: { [k: string]: number } = {}\n /**\n * Random Coil Index (RCI) - evaluates the proximity of residue structural\n * and dynamic properties to the properties of flexible random coil regions\n * from NMR chemical shifts.\n *\n * Mark V. Berjanskii and David S. Wishart (2005)\n * A Simple Method To Predict Protein Flexibility Using Secondary Chemical Shifts\n * J. Am. Chem. Soc., 2005, 127 (43), pp 14970–14971\n * http://pubs.acs.org/doi/abs/10.1021/ja054842f\n *\n * Mark V. Berjanskii and David S. Wishart (2008)\n * Application of the random coil index to studying protein flexibility.\n * J Biomol NMR. 2008 Jan;40(1):31-48. Epub 2007 Nov 6.\n * http://www.springerlink.com/content/2966482w10306126/\n */\n rciDict: { [k: string]: number } = {}\n clashDict: { [k: string]: { [k: string]: string } } = {}\n clashArray: { [k: string]: string }[] = []\n geoDict: { [k: string]: number } = {}\n geoAtomDict: { [k: string]: { [k: string]: number } } = {}\n atomDict: { [k: string]: boolean|number } = {}\n clashSele = 'NONE'\n\n constructor (readonly name: string, readonly path: string) {}\n\n get type () { return 'validation' }\n\n fromXml (xml: XMLDocument) {\n if (Debug) Log.time('Validation.fromXml')\n\n const rsrzDict = this.rsrzDict\n const rsccDict = this.rsccDict\n const rciDict = this.rciDict\n const clashDict = this.clashDict\n const clashArray = this.clashArray\n const geoDict = this.geoDict\n const geoAtomDict = this.geoAtomDict\n const atomDict = this.atomDict\n\n const entries = xml.getElementsByTagName('Entry')\n if (entries.length === 1) {\n const chemicalShiftLists = entries[0].getElementsByTagName('chemical_shift_list')\n if (chemicalShiftLists.length === 1) {\n const randomCoilIndices = chemicalShiftLists[0].getElementsByTagName('random_coil_index')\n for (let j = 0, jl = randomCoilIndices.length; j < jl; ++j) {\n const rcia = randomCoilIndices[ j ].attributes\n const sele = getResSele(rcia)\n rciDict[ sele ] = parseFloat(getNamedItem(rcia, 'value'))\n }\n }\n }\n\n const groups = xml.getElementsByTagName('ModelledSubgroup')\n\n const _clashDict: { [k: string]: { [k: string]: string } } = {}\n const clashList: string[] = []\n\n if (Debug) Log.time('Validation.fromXml#clashDict')\n\n for (let i = 0, il = groups.length; i < il; ++i) {\n const g = groups[ i ]\n const ga = g.attributes\n\n const sele = getSele(ga)\n if (ga.getNamedItem('rsrz') !== null) {\n rsrzDict[ sele ] = parseFloat(getNamedItem(ga, 'rsrz'))\n }\n if (ga.getNamedItem('rscc') !== null) {\n rsccDict[ sele ] = parseFloat(getNamedItem(ga, 'rscc'))\n }\n const seleAttr = xml.createAttribute('sele')\n seleAttr.value = sele\n ga.setNamedItem(seleAttr)\n\n const clashes = g.getElementsByTagName('clash')\n\n for (let j = 0, jl = clashes.length; j < jl; ++j) {\n const ca = clashes[ j ].attributes\n const atom = getNamedItem(ca, 'atom')\n\n if (guessElement(atom) !== 'H') {\n const cid = getNamedItem(ca, 'cid')\n const atomSele = getSele(ga, atom, true)\n atomDict[ atomSele ] = true\n\n if (_clashDict[ cid ] === undefined) {\n _clashDict[ cid ] = {\n sele1: atomSele,\n res1: sele\n }\n } else {\n const c = _clashDict[ cid ]\n if (c.res1 !== sele) {\n c.sele2 = atomSele\n c.res2 = sele\n clashList.push(c.res1, sele)\n clashDict[ cid ] = c\n clashArray.push(c)\n }\n }\n }\n }\n }\n\n if (Debug) Log.timeEnd('Validation.fromXml#clashDict')\n\n for (let i = 0, il = groups.length; i < il; ++i) {\n const g = groups[ i ]\n const ga = g.attributes\n\n const sele = getNamedItem(ga, 'sele')\n const isPolymer = getNamedItem(ga, 'seq') !== '.'\n\n if (isPolymer) {\n const geoProblemCount = getProblemCount(clashDict, g, ga)\n if (geoProblemCount > 0) {\n geoDict[ sele ] = geoProblemCount\n }\n } else {\n const clashes = g.getElementsByTagName('clash')\n const mogBondOutliers = g.getElementsByTagName('mog-bond-outlier')\n const mogAngleOutliers = g.getElementsByTagName('mog-angle-outlier')\n\n if (mogBondOutliers.length > 0 || mogAngleOutliers.length > 0 || clashes.length > 0) {\n const atomDict = {}\n geoAtomDict[ sele ] = atomDict\n\n for (let j = 0, jl = clashes.length; j < jl; ++j) {\n const ca = clashes[ j ].attributes\n if (clashDict[ getNamedItem(ca, 'cid') ]) {\n setBitDict(atomDict, getNamedItem(ca, 'atom'), 1)\n }\n }\n\n for (let j = 0, jl = mogBondOutliers.length; j < jl; ++j) {\n const mbo = mogBondOutliers[ j ].attributes\n getNamedItem(mbo, 'atoms').split(',').forEach(function (atomname) {\n setBitDict(atomDict, atomname, 2)\n })\n }\n\n for (let j = 0, jl = mogAngleOutliers.length; j < jl; ++j) {\n const mao = mogAngleOutliers[ j ].attributes\n getNamedItem(mao, 'atoms').split(',').forEach(function (atomname) {\n setBitDict(atomDict, atomname, 4)\n })\n }\n }\n }\n }\n\n this.clashSele = clashList.length ? clashList.join(' OR ') : 'NONE'\n\n if (Debug) Log.timeEnd('Validation.fromXml')\n }\n\n getClashData (params: { color: number|string|Color, structure: Structure }) {\n if (Debug) Log.time('Validation.getClashData')\n\n const p = params || {}\n\n const s = p.structure\n const atomSet = s.atomSet! // TODO\n const c = new Color(defaults(p.color, '#f0027f'))\n\n const ap1 = s.getAtomProxy()\n const ap2 = s.getAtomProxy()\n const vDir = new Vector3()\n const vPos1 = new Vector3()\n const vPos2 = new Vector3()\n\n const clashArray = this.clashArray\n const n = clashArray.length\n\n const position1 = new Float32Array(n * 3)\n const position2 = new Float32Array(n * 3)\n const color = uniformArray3(n, c.r, c.g, c.b) as Float32Array\n const radius = new Float32Array(n)\n const picking = new Float32Array(n)\n\n if (Debug) Log.time('Validation.getClashData#atomDict')\n\n const atomDict = this.atomDict\n\n s.eachAtom(function (ap) {\n const sele = getAtomSele(ap)\n if (atomDict[ sele ] === true) {\n atomDict[ sele ] = ap.index\n }\n })\n\n if (Debug) Log.timeEnd('Validation.getClashData#atomDict')\n\n let i = 0\n\n clashArray.forEach(function (c, idx) {\n ap1.index = atomDict[ c.sele1 ] as number // TODO\n ap2.index = atomDict[ c.sele2 ] as number // TODO\n\n if (ap1.index === undefined || ap2.index === undefined ||\n !atomSet.isSet(ap1.index, ap2.index)) return\n\n vDir.subVectors(ap2 as any, ap1 as any).setLength(ap1.vdw) // TODO\n vPos1.copy(ap1 as any).add(vDir) // TODO\n\n vDir.subVectors(ap1 as any, ap2 as any).setLength(ap2.vdw) // TODO\n vPos2.copy(ap2 as any).add(vDir) // TODO\n\n const dHalf = ap1.distanceTo(ap2) / 2\n const r1 = Math.sqrt(ap1.vdw * ap1.vdw - dHalf * dHalf)\n const r2 = Math.sqrt(ap2.vdw * ap2.vdw - dHalf * dHalf)\n\n vPos1.toArray(position1 as any, i * 3) // TODO\n vPos2.toArray(position2 as any, i * 3)\n radius[ i ] = (r1 + r2) / 2\n picking[ i ] = idx\n\n ++i\n })\n\n if (Debug) Log.timeEnd('Validation.getClashData')\n\n return {\n position1: position1.subarray(0, i * 3),\n position2: position2.subarray(0, i * 3),\n color: color.subarray(0, i * 3),\n color2: color.subarray(0, i * 3),\n radius: radius.subarray(0, i),\n picking: new ClashPicker(picking.subarray(0, i), this, s)\n }\n }\n}\n\nexport default Validation\n","\n// https://github.com/nodeca/pako\n// MIT License, Copyright (c) 2014 by Vitaly Puzrin\n\n\n// 'use strict';\n\n\n// var TYPED_OK = (typeof Uint8Array !== 'undefined') &&\n// (typeof Uint16Array !== 'undefined') &&\n// (typeof Int32Array !== 'undefined');\n\n\nfunction assign(obj /*from1, from2, from3, ...*/) {\n var sources = Array.prototype.slice.call(arguments, 1);\n while (sources.length) {\n var source = sources.shift();\n if (!source) { continue; }\n\n if (typeof source !== 'object') {\n throw new TypeError(source + 'must be non-object');\n }\n\n for (var p in source) {\n if (source.hasOwnProperty(p)) {\n obj[p] = source[p];\n }\n }\n }\n\n return obj;\n}\n\n\n// reduce buffer size, avoiding mem copy\nfunction shrinkBuf(buf, size) {\n if (buf.length === size) { return buf; }\n if (buf.subarray) { return buf.subarray(0, size); }\n buf.length = size;\n return buf;\n}\n\n\nfunction arraySet(dest, src, src_offs, len, dest_offs) {\n if (src.subarray && dest.subarray) {\n dest.set(src.subarray(src_offs, src_offs + len), dest_offs);\n return;\n }\n // Fallback to ordinary array\n for (var i = 0; i < len; i++) {\n dest[dest_offs + i] = src[src_offs + i];\n }\n}\n\n// Join array of chunks to single array.\nfunction flattenChunks(chunks) {\n var i, l, len, pos, chunk, result;\n\n // calculate data length\n len = 0;\n for (i = 0, l = chunks.length; i < l; i++) {\n len += chunks[i].length;\n }\n\n // join chunks\n result = new Uint8Array(len);\n pos = 0;\n for (i = 0, l = chunks.length; i < l; i++) {\n chunk = chunks[i];\n result.set(chunk, pos);\n pos += chunk.length;\n }\n\n return result;\n}\n\n// 'use strict';\n\n// Note: adler32 takes 12% for level 0 and 2% for level 6.\n// It doesn't worth to make additional optimizationa as in original.\n// Small size is preferable.\n\nfunction adler32(adler, buf, len, pos) {\n var s1 = (adler & 0xffff) |0,\n s2 = ((adler >>> 16) & 0xffff) |0,\n n = 0;\n\n while (len !== 0) {\n // Set limit ~ twice less than 5552, to keep\n // s2 in 31-bits, because we force signed ints.\n // in other case %= will fail.\n n = len > 2000 ? 2000 : len;\n len -= n;\n\n do {\n s1 = (s1 + buf[pos++]) |0;\n s2 = (s2 + s1) |0;\n } while (--n);\n\n s1 %= 65521;\n s2 %= 65521;\n }\n\n return (s1 | (s2 << 16)) |0;\n}\n\n// 'use strict';\n\n// Note: we can't get significant speed boost here.\n// So write code to minimize size - no pregenerated tables\n// and array tools dependencies.\n\n\n// Use ordinary array, since untyped makes no boost here\nfunction makeTable() {\n var c, table = [];\n\n for (var n = 0; n < 256; n++) {\n c = n;\n for (var k = 0; k < 8; k++) {\n c = ((c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));\n }\n table[n] = c;\n }\n\n return table;\n}\n\n// Create table on load. Just 255 signed longs. Not a problem.\nvar crcTable = makeTable();\n\n\nfunction crc32(crc, buf, len, pos) {\n var t = crcTable,\n end = pos + len;\n\n crc ^= -1;\n\n for (var i = pos; i < end; i++) {\n crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF];\n }\n\n return (crc ^ (-1)); // >>> 0;\n}\n\n// 'use strict';\n\n// See state defs from inflate.js\nvar BAD$1 = 30; /* got a data error -- remain here until reset */\nvar TYPE$1 = 12; /* i: waiting for type bits, including last-flag bit */\n\n/*\n Decode literal, length, and distance codes and write out the resulting\n literal and match bytes until either not enough input or output is\n available, an end-of-block is encountered, or a data error is encountered.\n When large enough input and output buffers are supplied to inflate(), for\n example, a 16K input buffer and a 64K output buffer, more than 95% of the\n inflate execution time is spent in this routine.\n\n Entry assumptions:\n\n state.mode === LEN\n strm.avail_in >= 6\n strm.avail_out >= 258\n start >= strm.avail_out\n state.bits < 8\n\n On return, state.mode is one of:\n\n LEN -- ran out of enough output space or enough available input\n TYPE -- reached end of block code, inflate() to interpret next block\n BAD -- error in block data\n\n Notes:\n\n - The maximum input bits used by a length/distance pair is 15 bits for the\n length code, 5 bits for the length extra, 15 bits for the distance code,\n and 13 bits for the distance extra. This totals 48 bits, or six bytes.\n Therefore if strm.avail_in >= 6, then there is enough input to avoid\n checking for available input while decoding.\n\n - The maximum bytes that a single length/distance pair can output is 258\n bytes, which is the maximum length that can be coded. inflate_fast()\n requires strm.avail_out >= 258 for each loop to avoid checking for\n output space.\n */\n// module.exports =\nfunction inflate_fast(strm, start) {\n var state;\n var _in; /* local strm.input */\n var last; /* have enough input while in < last */\n var _out; /* local strm.output */\n var beg; /* inflate()'s initial strm.output */\n var end; /* while out < end, enough space available */\n//#ifdef INFLATE_STRICT\n var dmax; /* maximum distance from zlib header */\n//#endif\n var wsize; /* window size or zero if not using window */\n var whave; /* valid bytes in the window */\n var wnext; /* window write index */\n // Use `s_window` instead `window`, avoid conflict with instrumentation tools\n var s_window; /* allocated sliding window, if wsize != 0 */\n var hold; /* local strm.hold */\n var bits; /* local strm.bits */\n var lcode; /* local strm.lencode */\n var dcode; /* local strm.distcode */\n var lmask; /* mask for first level of length codes */\n var dmask; /* mask for first level of distance codes */\n var here; /* retrieved table entry */\n var op; /* code bits, operation, extra bits, or */\n /* window position, window bytes to copy */\n var len; /* match length, unused bytes */\n var dist; /* match distance */\n var from; /* where to copy match from */\n var from_source;\n\n\n var input, output; // JS specific, because we have no pointers\n\n /* copy state to local variables */\n state = strm.state;\n //here = state.here;\n _in = strm.next_in;\n input = strm.input;\n last = _in + (strm.avail_in - 5);\n _out = strm.next_out;\n output = strm.output;\n beg = _out - (start - strm.avail_out);\n end = _out + (strm.avail_out - 257);\n//#ifdef INFLATE_STRICT\n dmax = state.dmax;\n//#endif\n wsize = state.wsize;\n whave = state.whave;\n wnext = state.wnext;\n s_window = state.window;\n hold = state.hold;\n bits = state.bits;\n lcode = state.lencode;\n dcode = state.distcode;\n lmask = (1 << state.lenbits) - 1;\n dmask = (1 << state.distbits) - 1;\n\n\n /* decode literals and length/distances until end-of-block or not enough\n input data or output space */\n\n top:\n do {\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n\n here = lcode[hold & lmask];\n\n dolen:\n for (;;) { // Goto emulation\n op = here >>> 24/*here.bits*/;\n hold >>>= op;\n bits -= op;\n op = (here >>> 16) & 0xff/*here.op*/;\n if (op === 0) { /* literal */\n //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n // \"inflate: literal '%c'\\n\" :\n // \"inflate: literal 0x%02x\\n\", here.val));\n output[_out++] = here & 0xffff/*here.val*/;\n }\n else if (op & 16) { /* length base */\n len = here & 0xffff/*here.val*/;\n op &= 15; /* number of extra bits */\n if (op) {\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n len += hold & ((1 << op) - 1);\n hold >>>= op;\n bits -= op;\n }\n //Tracevv((stderr, \"inflate: length %u\\n\", len));\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n here = dcode[hold & dmask];\n\n dodist:\n for (;;) { // goto emulation\n op = here >>> 24/*here.bits*/;\n hold >>>= op;\n bits -= op;\n op = (here >>> 16) & 0xff/*here.op*/;\n\n if (op & 16) { /* distance base */\n dist = here & 0xffff/*here.val*/;\n op &= 15; /* number of extra bits */\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n }\n dist += hold & ((1 << op) - 1);\n//#ifdef INFLATE_STRICT\n if (dist > dmax) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD$1;\n break top;\n }\n//#endif\n hold >>>= op;\n bits -= op;\n //Tracevv((stderr, \"inflate: distance %u\\n\", dist));\n op = _out - beg; /* max distance in output */\n if (dist > op) { /* see if copy from window */\n op = dist - op; /* distance back in window */\n if (op > whave) {\n if (state.sane) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD$1;\n break top;\n }\n\n// (!) This block is disabled in zlib defailts,\n// don't enable it for binary compatibility\n//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n// if (len <= op - whave) {\n// do {\n// output[_out++] = 0;\n// } while (--len);\n// continue top;\n// }\n// len -= op - whave;\n// do {\n// output[_out++] = 0;\n// } while (--op > whave);\n// if (op === 0) {\n// from = _out - dist;\n// do {\n// output[_out++] = output[from++];\n// } while (--len);\n// continue top;\n// }\n//#endif\n }\n from = 0; // window index\n from_source = s_window;\n if (wnext === 0) { /* very common case */\n from += wsize - op;\n if (op < len) { /* some from window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n else if (wnext < op) { /* wrap around window */\n from += wsize + wnext - op;\n op -= wnext;\n if (op < len) { /* some from end of window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = 0;\n if (wnext < len) { /* some from start of window */\n op = wnext;\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n }\n else { /* contiguous in window */\n from += wnext - op;\n if (op < len) { /* some from window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n while (len > 2) {\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n len -= 3;\n }\n if (len) {\n output[_out++] = from_source[from++];\n if (len > 1) {\n output[_out++] = from_source[from++];\n }\n }\n }\n else {\n from = _out - dist; /* copy direct from output */\n do { /* minimum length is three */\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n len -= 3;\n } while (len > 2);\n if (len) {\n output[_out++] = output[from++];\n if (len > 1) {\n output[_out++] = output[from++];\n }\n }\n }\n }\n else if ((op & 64) === 0) { /* 2nd level distance code */\n here = dcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n continue dodist;\n }\n else {\n strm.msg = 'invalid distance code';\n state.mode = BAD$1;\n break top;\n }\n\n break; // need to emulate goto via \"continue\"\n }\n }\n else if ((op & 64) === 0) { /* 2nd level length code */\n here = lcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n continue dolen;\n }\n else if (op & 32) { /* end-of-block */\n //Tracevv((stderr, \"inflate: end of block\\n\"));\n state.mode = TYPE$1;\n break top;\n }\n else {\n strm.msg = 'invalid literal/length code';\n state.mode = BAD$1;\n break top;\n }\n\n break; // need to emulate goto via \"continue\"\n }\n } while (_in < last && _out < end);\n\n /* return unused bytes (on entry, bits < 8, so in won't go too far back) */\n len = bits >> 3;\n _in -= len;\n bits -= len << 3;\n hold &= (1 << bits) - 1;\n\n /* update state and return */\n strm.next_in = _in;\n strm.next_out = _out;\n strm.avail_in = (_in < last ? 5 + (last - _in) : 5 - (_in - last));\n strm.avail_out = (_out < end ? 257 + (end - _out) : 257 - (_out - end));\n state.hold = hold;\n state.bits = bits;\n return;\n};\n\n// 'use strict';\n\n\n// var utils = require('../utils/common');\n\nvar MAXBITS = 15;\nvar ENOUGH_LENS$1 = 852;\nvar ENOUGH_DISTS$1 = 592;\n//var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);\n\nvar CODES$1 = 0;\nvar LENS$1 = 1;\nvar DISTS$1 = 2;\n\nvar lbase = [ /* Length codes 257..285 base */\n 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,\n 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0\n];\n\nvar lext = [ /* Length codes 257..285 extra */\n 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,\n 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78\n];\n\nvar dbase = [ /* Distance codes 0..29 base */\n 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,\n 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,\n 8193, 12289, 16385, 24577, 0, 0\n];\n\nvar dext = [ /* Distance codes 0..29 extra */\n 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,\n 23, 23, 24, 24, 25, 25, 26, 26, 27, 27,\n 28, 28, 29, 29, 64, 64\n];\n\n// module.exports =\nfunction inflate_table(type, lens, lens_index, codes, table, table_index, work, opts)\n{\n var bits = opts.bits;\n //here = opts.here; /* table entry for duplication */\n\n var len = 0; /* a code's length in bits */\n var sym = 0; /* index of code symbols */\n var min = 0, max = 0; /* minimum and maximum code lengths */\n var root = 0; /* number of index bits for root table */\n var curr = 0; /* number of index bits for current table */\n var drop = 0; /* code bits to drop for sub-table */\n var left = 0; /* number of prefix codes available */\n var used = 0; /* code entries in table used */\n var huff = 0; /* Huffman code */\n var incr; /* for incrementing code, index */\n var fill; /* index for replicating entries */\n var low; /* low bits for current root entry */\n var mask; /* mask for low root bits */\n var next; /* next available space in table */\n var base = null; /* base value table to use */\n var base_index = 0;\n// var shoextra; /* extra bits table to use */\n var end; /* use base and extra for symbol > end */\n var count = new Uint16Array(MAXBITS + 1); //[MAXBITS+1]; /* number of codes of each length */\n var offs = new Uint16Array(MAXBITS + 1); //[MAXBITS+1]; /* offsets in table for each length */\n var extra = null;\n var extra_index = 0;\n\n var here_bits, here_op, here_val;\n\n /*\n Process a set of code lengths to create a canonical Huffman code. The\n code lengths are lens[0..codes-1]. Each length corresponds to the\n symbols 0..codes-1. The Huffman code is generated by first sorting the\n symbols by length from short to long, and retaining the symbol order\n for codes with equal lengths. Then the code starts with all zero bits\n for the first code of the shortest length, and the codes are integer\n increments for the same length, and zeros are appended as the length\n increases. For the deflate format, these bits are stored backwards\n from their more natural integer increment ordering, and so when the\n decoding tables are built in the large loop below, the integer codes\n are incremented backwards.\n\n This routine assumes, but does not check, that all of the entries in\n lens[] are in the range 0..MAXBITS. The caller must assure this.\n 1..MAXBITS is interpreted as that code length. zero means that that\n symbol does not occur in this code.\n\n The codes are sorted by computing a count of codes for each length,\n creating from that a table of starting indices for each length in the\n sorted table, and then entering the symbols in order in the sorted\n table. The sorted table is work[], with that space being provided by\n the caller.\n\n The length counts are used for other purposes as well, i.e. finding\n the minimum and maximum length codes, determining if there are any\n codes at all, checking for a valid set of lengths, and looking ahead\n at length counts to determine sub-table sizes when building the\n decoding tables.\n */\n\n /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */\n for (len = 0; len <= MAXBITS; len++) {\n count[len] = 0;\n }\n for (sym = 0; sym < codes; sym++) {\n count[lens[lens_index + sym]]++;\n }\n\n /* bound code lengths, force root to be within code lengths */\n root = bits;\n for (max = MAXBITS; max >= 1; max--) {\n if (count[max] !== 0) { break; }\n }\n if (root > max) {\n root = max;\n }\n if (max === 0) { /* no symbols to code at all */\n //table.op[opts.table_index] = 64; //here.op = (var char)64; /* invalid code marker */\n //table.bits[opts.table_index] = 1; //here.bits = (var char)1;\n //table.val[opts.table_index++] = 0; //here.val = (var short)0;\n table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n\n //table.op[opts.table_index] = 64;\n //table.bits[opts.table_index] = 1;\n //table.val[opts.table_index++] = 0;\n table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n opts.bits = 1;\n return 0; /* no symbols, but wait for decoding to report error */\n }\n for (min = 1; min < max; min++) {\n if (count[min] !== 0) { break; }\n }\n if (root < min) {\n root = min;\n }\n\n /* check for an over-subscribed or incomplete set of lengths */\n left = 1;\n for (len = 1; len <= MAXBITS; len++) {\n left <<= 1;\n left -= count[len];\n if (left < 0) {\n return -1;\n } /* over-subscribed */\n }\n if (left > 0 && (type === CODES$1 || max !== 1)) {\n return -1; /* incomplete set */\n }\n\n /* generate offsets into symbol table for each length for sorting */\n offs[1] = 0;\n for (len = 1; len < MAXBITS; len++) {\n offs[len + 1] = offs[len] + count[len];\n }\n\n /* sort symbols by length, by symbol order within each length */\n for (sym = 0; sym < codes; sym++) {\n if (lens[lens_index + sym] !== 0) {\n work[offs[lens[lens_index + sym]]++] = sym;\n }\n }\n\n /*\n Create and fill in decoding tables. In this loop, the table being\n filled is at next and has curr index bits. The code being used is huff\n with length len. That code is converted to an index by dropping drop\n bits off of the bottom. For codes where len is less than drop + curr,\n those top drop + curr - len bits are incremented through all values to\n fill the table with replicated entries.\n\n root is the number of index bits for the root table. When len exceeds\n root, sub-tables are created pointed to by the root entry with an index\n of the low root bits of huff. This is saved in low to check for when a\n new sub-table should be started. drop is zero when the root table is\n being filled, and drop is root when sub-tables are being filled.\n\n When a new sub-table is needed, it is necessary to look ahead in the\n code lengths to determine what size sub-table is needed. The length\n counts are used for this, and so count[] is decremented as codes are\n entered in the tables.\n\n used keeps track of how many table entries have been allocated from the\n provided *table space. It is checked for LENS and DIST tables against\n the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in\n the initial root table size constants. See the comments in inftrees.h\n for more information.\n\n sym increments through all symbols, and the loop terminates when\n all codes of length max, i.e. all codes, have been processed. This\n routine permits incomplete codes, so another loop after this one fills\n in the rest of the decoding tables with invalid code markers.\n */\n\n /* set up for code type */\n // poor man optimization - use if-else instead of switch,\n // to avoid deopts in old v8\n if (type === CODES$1) {\n base = extra = work; /* dummy value--not used */\n end = 19;\n\n } else if (type === LENS$1) {\n base = lbase;\n base_index -= 257;\n extra = lext;\n extra_index -= 257;\n end = 256;\n\n } else { /* DISTS */\n base = dbase;\n extra = dext;\n end = -1;\n }\n\n /* initialize opts for loop */\n huff = 0; /* starting code */\n sym = 0; /* starting code symbol */\n len = min; /* starting code length */\n next = table_index; /* current table to fill in */\n curr = root; /* current table index bits */\n drop = 0; /* current bits to drop from code for index */\n low = -1; /* trigger new sub-table when len > root */\n used = 1 << root; /* use root table entries */\n mask = used - 1; /* mask for comparing low */\n\n /* check available table space */\n if ((type === LENS$1 && used > ENOUGH_LENS$1) ||\n (type === DISTS$1 && used > ENOUGH_DISTS$1)) {\n return 1;\n }\n\n var i = 0;\n /* process all codes and make table entries */\n for (;;) {\n i++;\n /* create table entry */\n here_bits = len - drop;\n if (work[sym] < end) {\n here_op = 0;\n here_val = work[sym];\n }\n else if (work[sym] > end) {\n here_op = extra[extra_index + work[sym]];\n here_val = base[base_index + work[sym]];\n }\n else {\n here_op = 32 + 64; /* end of block */\n here_val = 0;\n }\n\n /* replicate for those indices with low len bits equal to huff */\n incr = 1 << (len - drop);\n fill = 1 << curr;\n min = fill; /* save offset to next table */\n do {\n fill -= incr;\n table[next + (huff >> drop) + fill] = (here_bits << 24) | (here_op << 16) | here_val |0;\n } while (fill !== 0);\n\n /* backwards increment the len-bit code huff */\n incr = 1 << (len - 1);\n while (huff & incr) {\n incr >>= 1;\n }\n if (incr !== 0) {\n huff &= incr - 1;\n huff += incr;\n } else {\n huff = 0;\n }\n\n /* go to next symbol, update count, len */\n sym++;\n if (--count[len] === 0) {\n if (len === max) { break; }\n len = lens[lens_index + work[sym]];\n }\n\n /* create new sub-table if needed */\n if (len > root && (huff & mask) !== low) {\n /* if first time, transition to sub-tables */\n if (drop === 0) {\n drop = root;\n }\n\n /* increment past last table */\n next += min; /* here min is 1 << curr */\n\n /* determine length of next table */\n curr = len - drop;\n left = 1 << curr;\n while (curr + drop < max) {\n left -= count[curr + drop];\n if (left <= 0) { break; }\n curr++;\n left <<= 1;\n }\n\n /* check for enough space */\n used += 1 << curr;\n if ((type === LENS$1 && used > ENOUGH_LENS$1) ||\n (type === DISTS$1 && used > ENOUGH_DISTS$1)) {\n return 1;\n }\n\n /* point entry in root table to sub-table */\n low = huff & mask;\n /*table.op[low] = curr;\n table.bits[low] = root;\n table.val[low] = next - opts.table_index;*/\n table[low] = (root << 24) | (curr << 16) | (next - table_index) |0;\n }\n }\n\n /* fill in remaining table entry if code is incomplete (guaranteed to have\n at most one remaining entry, since if the code is incomplete, the\n maximum code length that was allowed to get this far is one bit) */\n if (huff !== 0) {\n //table.op[next + huff] = 64; /* invalid code marker */\n //table.bits[next + huff] = len - drop;\n //table.val[next + huff] = 0;\n table[next + huff] = ((len - drop) << 24) | (64 << 16) |0;\n }\n\n /* set return parameters */\n //opts.table_index += used;\n opts.bits = root;\n return 0;\n};\n\n// 'use strict';\n\n\n// var utils = require('../utils/common');\n// var adler32 = require('./adler32');\n// var crc32 = require('./crc32');\n// var inflate_fast = require('./inffast');\n// var inflate_table = require('./inftrees');\n\nvar CODES = 0;\nvar LENS = 1;\nvar DISTS = 2;\n\n/* Public constants ==========================================================*/\n/* ===========================================================================*/\n\n\n/* Allowed flush values; see deflate() and inflate() below for details */\n//var Z_NO_FLUSH = 0;\n//var Z_PARTIAL_FLUSH = 1;\n//var Z_SYNC_FLUSH = 2;\n//var Z_FULL_FLUSH = 3;\nvar Z_FINISH = 4;\nvar Z_BLOCK = 5;\nvar Z_TREES = 6;\n\n\n/* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\nvar Z_OK = 0;\nvar Z_STREAM_END = 1;\nvar Z_NEED_DICT = 2;\n//var Z_ERRNO = -1;\nvar Z_STREAM_ERROR = -2;\nvar Z_DATA_ERROR = -3;\nvar Z_MEM_ERROR = -4;\nvar Z_BUF_ERROR = -5;\n//var Z_VERSION_ERROR = -6;\n\n/* The deflate compression method */\nvar Z_DEFLATED = 8;\n\n\n/* STATES ====================================================================*/\n/* ===========================================================================*/\n\n\nvar HEAD = 1; /* i: waiting for magic header */\nvar FLAGS = 2; /* i: waiting for method and flags (gzip) */\nvar TIME = 3; /* i: waiting for modification time (gzip) */\nvar OS = 4; /* i: waiting for extra flags and operating system (gzip) */\nvar EXLEN = 5; /* i: waiting for extra length (gzip) */\nvar EXTRA = 6; /* i: waiting for extra bytes (gzip) */\nvar NAME = 7; /* i: waiting for end of file name (gzip) */\nvar COMMENT = 8; /* i: waiting for end of comment (gzip) */\nvar HCRC = 9; /* i: waiting for header crc (gzip) */\nvar DICTID = 10; /* i: waiting for dictionary check value */\nvar DICT = 11; /* waiting for inflateSetDictionary() call */\nvar TYPE = 12; /* i: waiting for type bits, including last-flag bit */\nvar TYPEDO = 13; /* i: same, but skip check to exit inflate on new block */\nvar STORED = 14; /* i: waiting for stored size (length and complement) */\nvar COPY_ = 15; /* i/o: same as COPY below, but only first time in */\nvar COPY = 16; /* i/o: waiting for input or output to copy stored block */\nvar TABLE = 17; /* i: waiting for dynamic block table lengths */\nvar LENLENS = 18; /* i: waiting for code length code lengths */\nvar CODELENS = 19; /* i: waiting for length/lit and distance code lengths */\nvar LEN_ = 20; /* i: same as LEN below, but only first time in */\nvar LEN = 21; /* i: waiting for length/lit/eob code */\nvar LENEXT = 22; /* i: waiting for length extra bits */\nvar DIST = 23; /* i: waiting for distance code */\nvar DISTEXT = 24; /* i: waiting for distance extra bits */\nvar MATCH = 25; /* o: waiting for output space to copy string */\nvar LIT = 26; /* o: waiting for output space to write literal */\nvar CHECK = 27; /* i: waiting for 32-bit check value */\nvar LENGTH = 28; /* i: waiting for 32-bit length (gzip) */\nvar DONE = 29; /* finished check, done -- remain here until reset */\nvar BAD = 30; /* got a data error -- remain here until reset */\nvar MEM = 31; /* got an inflate() memory error -- remain here until reset */\nvar SYNC = 32; /* looking for synchronization bytes to restart inflate() */\n\n/* ===========================================================================*/\n\n\n\nvar ENOUGH_LENS = 852;\nvar ENOUGH_DISTS = 592;\nfunction zswap32(q) {\n return (((q >>> 24) & 0xff) +\n ((q >>> 8) & 0xff00) +\n ((q & 0xff00) << 8) +\n ((q & 0xff) << 24));\n}\n\n\nfunction InflateState() {\n this.mode = 0; /* current inflate mode */\n this.last = false; /* true if processing last block */\n this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip */\n this.havedict = false; /* true if dictionary provided */\n this.flags = 0; /* gzip header method and flags (0 if zlib) */\n this.dmax = 0; /* zlib header max distance (INFLATE_STRICT) */\n this.check = 0; /* protected copy of check value */\n this.total = 0; /* protected copy of output count */\n // TODO: may be {}\n this.head = null; /* where to save gzip header information */\n\n /* sliding window */\n this.wbits = 0; /* log base 2 of requested window size */\n this.wsize = 0; /* window size or zero if not using window */\n this.whave = 0; /* valid bytes in the window */\n this.wnext = 0; /* window write index */\n this.window = null; /* allocated sliding window, if needed */\n\n /* bit accumulator */\n this.hold = 0; /* input bit accumulator */\n this.bits = 0; /* number of bits in \"in\" */\n\n /* for string and stored block copying */\n this.length = 0; /* literal or length of data to copy */\n this.offset = 0; /* distance back to copy string from */\n\n /* for table and code decoding */\n this.extra = 0; /* extra bits needed */\n\n /* fixed and dynamic code tables */\n this.lencode = null; /* starting table for length/literal codes */\n this.distcode = null; /* starting table for distance codes */\n this.lenbits = 0; /* index bits for lencode */\n this.distbits = 0; /* index bits for distcode */\n\n /* dynamic table building */\n this.ncode = 0; /* number of code length code lengths */\n this.nlen = 0; /* number of length code lengths */\n this.ndist = 0; /* number of distance code lengths */\n this.have = 0; /* number of code lengths in lens[] */\n this.next = null; /* next available space in codes[] */\n\n this.lens = new Uint16Array(320); /* temporary storage for code lengths */\n this.work = new Uint16Array(288); /* work area for code table building */\n\n /*\n because we don't have pointers in js, we use lencode and distcode directly\n as buffers so we don't need codes\n */\n //this.codes = new Buf32(ENOUGH); /* space for code tables */\n this.lendyn = null; /* dynamic table for length/literal codes (JS specific) */\n this.distdyn = null; /* dynamic table for distance codes (JS specific) */\n this.sane = 0; /* if false, allow invalid distance too far */\n this.back = 0; /* bits back of last unprocessed length/lit */\n this.was = 0; /* initial length of match */\n}\n\nfunction inflateResetKeep(strm) {\n var state;\n\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n strm.total_in = strm.total_out = state.total = 0;\n strm.msg = ''; /*Z_NULL*/\n if (state.wrap) { /* to support ill-conceived Java test suite */\n strm.adler = state.wrap & 1;\n }\n state.mode = HEAD;\n state.last = 0;\n state.havedict = 0;\n state.dmax = 32768;\n state.head = null/*Z_NULL*/;\n state.hold = 0;\n state.bits = 0;\n //state.lencode = state.distcode = state.next = state.codes;\n state.lencode = state.lendyn = new Int32Array(ENOUGH_LENS);\n state.distcode = state.distdyn = new Int32Array(ENOUGH_DISTS);\n\n state.sane = 1;\n state.back = -1;\n //Tracev((stderr, \"inflate: reset\\n\"));\n return Z_OK;\n}\n\nfunction inflateReset(strm) {\n var state;\n\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n state.wsize = 0;\n state.whave = 0;\n state.wnext = 0;\n return inflateResetKeep(strm);\n\n}\n\nfunction inflateReset2(strm, windowBits) {\n var wrap;\n var state;\n\n /* get the state */\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n\n /* extract wrap request from windowBits parameter */\n if (windowBits < 0) {\n wrap = 0;\n windowBits = -windowBits;\n }\n else {\n wrap = (windowBits >> 4) + 1;\n if (windowBits < 48) {\n windowBits &= 15;\n }\n }\n\n /* set number of window bits, free window if different */\n if (windowBits && (windowBits < 8 || windowBits > 15)) {\n return Z_STREAM_ERROR;\n }\n if (state.window !== null && state.wbits !== windowBits) {\n state.window = null;\n }\n\n /* update state and reset the rest of it */\n state.wrap = wrap;\n state.wbits = windowBits;\n return inflateReset(strm);\n}\n\nfunction inflateInit2(strm, windowBits) {\n var ret;\n var state;\n\n if (!strm) { return Z_STREAM_ERROR; }\n //strm.msg = Z_NULL; /* in case we return an error */\n\n state = new InflateState();\n\n //if (state === Z_NULL) return Z_MEM_ERROR;\n //Tracev((stderr, \"inflate: allocated\\n\"));\n strm.state = state;\n state.window = null/*Z_NULL*/;\n ret = inflateReset2(strm, windowBits);\n if (ret !== Z_OK) {\n strm.state = null/*Z_NULL*/;\n }\n return ret;\n}\n\n/*\n Return state with length and distance decoding tables and index sizes set to\n fixed code decoding. Normally this returns fixed tables from inffixed.h.\n If BUILDFIXED is defined, then instead this routine builds the tables the\n first time it's called, and returns those tables the first time and\n thereafter. This reduces the size of the code by about 2K bytes, in\n exchange for a little execution time. However, BUILDFIXED should not be\n used for threaded applications, since the rewriting of the tables and virgin\n may not be thread-safe.\n */\nvar virgin = true;\n\nvar lenfix;\nvar distfix;\n// We have no pointers in JS, so keep tables separate\n\nfunction fixedtables(state) {\n /* build fixed huffman tables if first call (may not be thread safe) */\n if (virgin) {\n var sym;\n\n lenfix = new Int32Array(512);\n distfix = new Int32Array(32);\n\n /* literal/length table */\n sym = 0;\n while (sym < 144) { state.lens[sym++] = 8; }\n while (sym < 256) { state.lens[sym++] = 9; }\n while (sym < 280) { state.lens[sym++] = 7; }\n while (sym < 288) { state.lens[sym++] = 8; }\n\n inflate_table(LENS, state.lens, 0, 288, lenfix, 0, state.work, { bits: 9 });\n\n /* distance table */\n sym = 0;\n while (sym < 32) { state.lens[sym++] = 5; }\n\n inflate_table(DISTS, state.lens, 0, 32, distfix, 0, state.work, { bits: 5 });\n\n /* do this just once */\n virgin = false;\n }\n\n state.lencode = lenfix;\n state.lenbits = 9;\n state.distcode = distfix;\n state.distbits = 5;\n}\n\n\n/*\n Update the window with the last wsize (normally 32K) bytes written before\n returning. If window does not exist yet, create it. This is only called\n when a window is already in use, or when output has been written during this\n inflate call, but the end of the deflate stream has not been reached yet.\n It is also called to create a window for dictionary data when a dictionary\n is loaded.\n\n Providing output buffers larger than 32K to inflate() should provide a speed\n advantage, since only the last 32K of output is copied to the sliding window\n upon return from inflate(), and since all distances after the first 32K of\n output will fall in the output data, making match copies simpler and faster.\n The advantage may be dependent on the size of the processor's data caches.\n */\nfunction updatewindow(strm, src, end, copy) {\n var dist;\n var state = strm.state;\n\n /* if it hasn't been done already, allocate space for the window */\n if (state.window === null) {\n state.wsize = 1 << state.wbits;\n state.wnext = 0;\n state.whave = 0;\n\n state.window = new Uint8Array(state.wsize);\n }\n\n /* copy state->wsize or less output bytes into the circular window */\n if (copy >= state.wsize) {\n arraySet(state.window, src, end - state.wsize, state.wsize, 0);\n state.wnext = 0;\n state.whave = state.wsize;\n }\n else {\n dist = state.wsize - state.wnext;\n if (dist > copy) {\n dist = copy;\n }\n //zmemcpy(state->window + state->wnext, end - copy, dist);\n arraySet(state.window, src, end - copy, dist, state.wnext);\n copy -= dist;\n if (copy) {\n //zmemcpy(state->window, end - copy, copy);\n arraySet(state.window, src, end - copy, copy, 0);\n state.wnext = copy;\n state.whave = state.wsize;\n }\n else {\n state.wnext += dist;\n if (state.wnext === state.wsize) { state.wnext = 0; }\n if (state.whave < state.wsize) { state.whave += dist; }\n }\n }\n return 0;\n}\n\nfunction inflate(strm, flush) {\n var state;\n var input, output; // input/output buffers\n var next; /* next input INDEX */\n var put; /* next output INDEX */\n var have, left; /* available input and output */\n var hold; /* bit buffer */\n var bits; /* bits in bit buffer */\n var _in, _out; /* save starting available input and output */\n var copy; /* number of stored or match bytes to copy */\n var from; /* where to copy match bytes from */\n var from_source;\n var here = 0; /* current decoding table entry */\n var here_bits, here_op, here_val; // paked \"here\" denormalized (JS specific)\n //var last; /* parent table entry */\n var last_bits, last_op, last_val; // paked \"last\" denormalized (JS specific)\n var len; /* length to copy for repeats, bits to drop */\n var ret; /* return code */\n var hbuf = new Uint8Array(4); /* buffer for gzip header crc calculation */\n var opts;\n\n var n; // temporary var for NEED_BITS\n\n var order = /* permutation of code lengths */\n [ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ];\n\n\n if (!strm || !strm.state || !strm.output ||\n (!strm.input && strm.avail_in !== 0)) {\n return Z_STREAM_ERROR;\n }\n\n state = strm.state;\n if (state.mode === TYPE) { state.mode = TYPEDO; } /* skip check */\n\n\n //--- LOAD() ---\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n //---\n\n _in = have;\n _out = left;\n ret = Z_OK;\n\n inf_leave: // goto emulation\n for (;;) {\n switch (state.mode) {\n case HEAD:\n if (state.wrap === 0) {\n state.mode = TYPEDO;\n break;\n }\n //=== NEEDBITS(16);\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if ((state.wrap & 2) && hold === 0x8b1f) { /* gzip header */\n state.check = 0/*crc32(0L, Z_NULL, 0)*/;\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = FLAGS;\n break;\n }\n state.flags = 0; /* expect zlib header */\n if (state.head) {\n state.head.done = false;\n }\n if (!(state.wrap & 1) || /* check if zlib header allowed */\n (((hold & 0xff)/*BITS(8)*/ << 8) + (hold >> 8)) % 31) {\n strm.msg = 'incorrect header check';\n state.mode = BAD;\n break;\n }\n if ((hold & 0x0f)/*BITS(4)*/ !== Z_DEFLATED) {\n strm.msg = 'unknown compression method';\n state.mode = BAD;\n break;\n }\n //--- DROPBITS(4) ---//\n hold >>>= 4;\n bits -= 4;\n //---//\n len = (hold & 0x0f)/*BITS(4)*/ + 8;\n if (state.wbits === 0) {\n state.wbits = len;\n }\n else if (len > state.wbits) {\n strm.msg = 'invalid window size';\n state.mode = BAD;\n break;\n }\n state.dmax = 1 << len;\n //Tracev((stderr, \"inflate: zlib header ok\\n\"));\n strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n state.mode = hold & 0x200 ? DICTID : TYPE;\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n break;\n case FLAGS:\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.flags = hold;\n if ((state.flags & 0xff) !== Z_DEFLATED) {\n strm.msg = 'unknown compression method';\n state.mode = BAD;\n break;\n }\n if (state.flags & 0xe000) {\n strm.msg = 'unknown header flags set';\n state.mode = BAD;\n break;\n }\n if (state.head) {\n state.head.text = ((hold >> 8) & 1);\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = TIME;\n /* falls through */\n case TIME:\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (state.head) {\n state.head.time = hold;\n }\n if (state.flags & 0x0200) {\n //=== CRC4(state.check, hold)\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n hbuf[2] = (hold >>> 16) & 0xff;\n hbuf[3] = (hold >>> 24) & 0xff;\n state.check = crc32(state.check, hbuf, 4, 0);\n //===\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = OS;\n /* falls through */\n case OS:\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (state.head) {\n state.head.xflags = (hold & 0xff);\n state.head.os = (hold >> 8);\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = EXLEN;\n /* falls through */\n case EXLEN:\n if (state.flags & 0x0400) {\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.length = hold;\n if (state.head) {\n state.head.extra_len = hold;\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n }\n else if (state.head) {\n state.head.extra = null/*Z_NULL*/;\n }\n state.mode = EXTRA;\n /* falls through */\n case EXTRA:\n if (state.flags & 0x0400) {\n copy = state.length;\n if (copy > have) { copy = have; }\n if (copy) {\n if (state.head) {\n len = state.head.extra_len - state.length;\n if (!state.head.extra) {\n // Use untyped array for more conveniend processing later\n state.head.extra = new Array(state.head.extra_len);\n }\n arraySet(\n state.head.extra,\n input,\n next,\n // extra field is limited to 65536 bytes\n // - no need for additional size check\n copy,\n /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/\n len\n );\n //zmemcpy(state.head.extra + len, next,\n // len + copy > state.head.extra_max ?\n // state.head.extra_max - len : copy);\n }\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n state.length -= copy;\n }\n if (state.length) { break inf_leave; }\n }\n state.length = 0;\n state.mode = NAME;\n /* falls through */\n case NAME:\n if (state.flags & 0x0800) {\n if (have === 0) { break inf_leave; }\n copy = 0;\n do {\n // TODO: 2 or 1 bytes?\n len = input[next + copy++];\n /* use constant limit because in js we should not preallocate memory */\n if (state.head && len &&\n (state.length < 65536 /*state.head.name_max*/)) {\n state.head.name += String.fromCharCode(len);\n }\n } while (len && copy < have);\n\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) { break inf_leave; }\n }\n else if (state.head) {\n state.head.name = null;\n }\n state.length = 0;\n state.mode = COMMENT;\n /* falls through */\n case COMMENT:\n if (state.flags & 0x1000) {\n if (have === 0) { break inf_leave; }\n copy = 0;\n do {\n len = input[next + copy++];\n /* use constant limit because in js we should not preallocate memory */\n if (state.head && len &&\n (state.length < 65536 /*state.head.comm_max*/)) {\n state.head.comment += String.fromCharCode(len);\n }\n } while (len && copy < have);\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) { break inf_leave; }\n }\n else if (state.head) {\n state.head.comment = null;\n }\n state.mode = HCRC;\n /* falls through */\n case HCRC:\n if (state.flags & 0x0200) {\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (hold !== (state.check & 0xffff)) {\n strm.msg = 'header crc mismatch';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n }\n if (state.head) {\n state.head.hcrc = ((state.flags >> 9) & 1);\n state.head.done = true;\n }\n strm.adler = state.check = 0;\n state.mode = TYPE;\n break;\n case DICTID:\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n strm.adler = state.check = zswap32(hold);\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = DICT;\n /* falls through */\n case DICT:\n if (state.havedict === 0) {\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n return Z_NEED_DICT;\n }\n strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n state.mode = TYPE;\n /* falls through */\n case TYPE:\n if (flush === Z_BLOCK || flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case TYPEDO:\n if (state.last) {\n //--- BYTEBITS() ---//\n hold >>>= bits & 7;\n bits -= bits & 7;\n //---//\n state.mode = CHECK;\n break;\n }\n //=== NEEDBITS(3); */\n while (bits < 3) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.last = (hold & 0x01)/*BITS(1)*/;\n //--- DROPBITS(1) ---//\n hold >>>= 1;\n bits -= 1;\n //---//\n\n switch ((hold & 0x03)/*BITS(2)*/) {\n case 0: /* stored block */\n //Tracev((stderr, \"inflate: stored block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = STORED;\n break;\n case 1: /* fixed block */\n fixedtables(state);\n //Tracev((stderr, \"inflate: fixed codes block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = LEN_; /* decode codes */\n if (flush === Z_TREES) {\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n break inf_leave;\n }\n break;\n case 2: /* dynamic block */\n //Tracev((stderr, \"inflate: dynamic codes block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = TABLE;\n break;\n case 3:\n strm.msg = 'invalid block type';\n state.mode = BAD;\n }\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n break;\n case STORED:\n //--- BYTEBITS() ---// /* go to byte boundary */\n hold >>>= bits & 7;\n bits -= bits & 7;\n //---//\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if ((hold & 0xffff) !== ((hold >>> 16) ^ 0xffff)) {\n strm.msg = 'invalid stored block lengths';\n state.mode = BAD;\n break;\n }\n state.length = hold & 0xffff;\n //Tracev((stderr, \"inflate: stored length %u\\n\",\n // state.length));\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = COPY_;\n if (flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case COPY_:\n state.mode = COPY;\n /* falls through */\n case COPY:\n copy = state.length;\n if (copy) {\n if (copy > have) { copy = have; }\n if (copy > left) { copy = left; }\n if (copy === 0) { break inf_leave; }\n //--- zmemcpy(put, next, copy); ---\n arraySet(output, input, next, copy, put);\n //---//\n have -= copy;\n next += copy;\n left -= copy;\n put += copy;\n state.length -= copy;\n break;\n }\n //Tracev((stderr, \"inflate: stored end\\n\"));\n state.mode = TYPE;\n break;\n case TABLE:\n //=== NEEDBITS(14); */\n while (bits < 14) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.nlen = (hold & 0x1f)/*BITS(5)*/ + 257;\n //--- DROPBITS(5) ---//\n hold >>>= 5;\n bits -= 5;\n //---//\n state.ndist = (hold & 0x1f)/*BITS(5)*/ + 1;\n //--- DROPBITS(5) ---//\n hold >>>= 5;\n bits -= 5;\n //---//\n state.ncode = (hold & 0x0f)/*BITS(4)*/ + 4;\n //--- DROPBITS(4) ---//\n hold >>>= 4;\n bits -= 4;\n //---//\n//#ifndef PKZIP_BUG_WORKAROUND\n if (state.nlen > 286 || state.ndist > 30) {\n strm.msg = 'too many length or distance symbols';\n state.mode = BAD;\n break;\n }\n//#endif\n //Tracev((stderr, \"inflate: table sizes ok\\n\"));\n state.have = 0;\n state.mode = LENLENS;\n /* falls through */\n case LENLENS:\n while (state.have < state.ncode) {\n //=== NEEDBITS(3);\n while (bits < 3) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.lens[order[state.have++]] = (hold & 0x07);//BITS(3);\n //--- DROPBITS(3) ---//\n hold >>>= 3;\n bits -= 3;\n //---//\n }\n while (state.have < 19) {\n state.lens[order[state.have++]] = 0;\n }\n // We have separate tables & no pointers. 2 commented lines below not needed.\n //state.next = state.codes;\n //state.lencode = state.next;\n // Switch to use dynamic table\n state.lencode = state.lendyn;\n state.lenbits = 7;\n\n opts = { bits: state.lenbits };\n ret = inflate_table(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts);\n state.lenbits = opts.bits;\n\n if (ret) {\n strm.msg = 'invalid code lengths set';\n state.mode = BAD;\n break;\n }\n //Tracev((stderr, \"inflate: code lengths ok\\n\"));\n state.have = 0;\n state.mode = CODELENS;\n /* falls through */\n case CODELENS:\n while (state.have < state.nlen + state.ndist) {\n for (;;) {\n here = state.lencode[hold & ((1 << state.lenbits) - 1)];/*BITS(state.lenbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if (here_val < 16) {\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.lens[state.have++] = here_val;\n }\n else {\n if (here_val === 16) {\n //=== NEEDBITS(here.bits + 2);\n n = here_bits + 2;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n if (state.have === 0) {\n strm.msg = 'invalid bit length repeat';\n state.mode = BAD;\n break;\n }\n len = state.lens[state.have - 1];\n copy = 3 + (hold & 0x03);//BITS(2);\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n }\n else if (here_val === 17) {\n //=== NEEDBITS(here.bits + 3);\n n = here_bits + 3;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n len = 0;\n copy = 3 + (hold & 0x07);//BITS(3);\n //--- DROPBITS(3) ---//\n hold >>>= 3;\n bits -= 3;\n //---//\n }\n else {\n //=== NEEDBITS(here.bits + 7);\n n = here_bits + 7;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n len = 0;\n copy = 11 + (hold & 0x7f);//BITS(7);\n //--- DROPBITS(7) ---//\n hold >>>= 7;\n bits -= 7;\n //---//\n }\n if (state.have + copy > state.nlen + state.ndist) {\n strm.msg = 'invalid bit length repeat';\n state.mode = BAD;\n break;\n }\n while (copy--) {\n state.lens[state.have++] = len;\n }\n }\n }\n\n /* handle error breaks in while */\n if (state.mode === BAD) { break; }\n\n /* check for end-of-block code (better have one) */\n if (state.lens[256] === 0) {\n strm.msg = 'invalid code -- missing end-of-block';\n state.mode = BAD;\n break;\n }\n\n /* build code tables -- note: do not change the lenbits or distbits\n values here (9 and 6) without reading the comments in inftrees.h\n concerning the ENOUGH constants, which depend on those values */\n state.lenbits = 9;\n\n opts = { bits: state.lenbits };\n ret = inflate_table(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts);\n // We have separate tables & no pointers. 2 commented lines below not needed.\n // state.next_index = opts.table_index;\n state.lenbits = opts.bits;\n // state.lencode = state.next;\n\n if (ret) {\n strm.msg = 'invalid literal/lengths set';\n state.mode = BAD;\n break;\n }\n\n state.distbits = 6;\n //state.distcode.copy(state.codes);\n // Switch to use dynamic table\n state.distcode = state.distdyn;\n opts = { bits: state.distbits };\n ret = inflate_table(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts);\n // We have separate tables & no pointers. 2 commented lines below not needed.\n // state.next_index = opts.table_index;\n state.distbits = opts.bits;\n // state.distcode = state.next;\n\n if (ret) {\n strm.msg = 'invalid distances set';\n state.mode = BAD;\n break;\n }\n //Tracev((stderr, 'inflate: codes ok\\n'));\n state.mode = LEN_;\n if (flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case LEN_:\n state.mode = LEN;\n /* falls through */\n case LEN:\n if (have >= 6 && left >= 258) {\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n inflate_fast(strm, _out);\n //--- LOAD() ---\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n //---\n\n if (state.mode === TYPE) {\n state.back = -1;\n }\n break;\n }\n state.back = 0;\n for (;;) {\n here = state.lencode[hold & ((1 << state.lenbits) - 1)]; /*BITS(state.lenbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if (here_bits <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if (here_op && (here_op & 0xf0) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (;;) {\n here = state.lencode[last_val +\n ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((last_bits + here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n //--- DROPBITS(last.bits) ---//\n hold >>>= last_bits;\n bits -= last_bits;\n //---//\n state.back += last_bits;\n }\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.back += here_bits;\n state.length = here_val;\n if (here_op === 0) {\n //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n // \"inflate: literal '%c'\\n\" :\n // \"inflate: literal 0x%02x\\n\", here.val));\n state.mode = LIT;\n break;\n }\n if (here_op & 32) {\n //Tracevv((stderr, \"inflate: end of block\\n\"));\n state.back = -1;\n state.mode = TYPE;\n break;\n }\n if (here_op & 64) {\n strm.msg = 'invalid literal/length code';\n state.mode = BAD;\n break;\n }\n state.extra = here_op & 15;\n state.mode = LENEXT;\n /* falls through */\n case LENEXT:\n if (state.extra) {\n //=== NEEDBITS(state.extra);\n n = state.extra;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.length += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n //--- DROPBITS(state.extra) ---//\n hold >>>= state.extra;\n bits -= state.extra;\n //---//\n state.back += state.extra;\n }\n //Tracevv((stderr, \"inflate: length %u\\n\", state.length));\n state.was = state.length;\n state.mode = DIST;\n /* falls through */\n case DIST:\n for (;;) {\n here = state.distcode[hold & ((1 << state.distbits) - 1)];/*BITS(state.distbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if ((here_op & 0xf0) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (;;) {\n here = state.distcode[last_val +\n ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((last_bits + here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n //--- DROPBITS(last.bits) ---//\n hold >>>= last_bits;\n bits -= last_bits;\n //---//\n state.back += last_bits;\n }\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.back += here_bits;\n if (here_op & 64) {\n strm.msg = 'invalid distance code';\n state.mode = BAD;\n break;\n }\n state.offset = here_val;\n state.extra = (here_op) & 15;\n state.mode = DISTEXT;\n /* falls through */\n case DISTEXT:\n if (state.extra) {\n //=== NEEDBITS(state.extra);\n n = state.extra;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.offset += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n //--- DROPBITS(state.extra) ---//\n hold >>>= state.extra;\n bits -= state.extra;\n //---//\n state.back += state.extra;\n }\n//#ifdef INFLATE_STRICT\n if (state.offset > state.dmax) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break;\n }\n//#endif\n //Tracevv((stderr, \"inflate: distance %u\\n\", state.offset));\n state.mode = MATCH;\n /* falls through */\n case MATCH:\n if (left === 0) { break inf_leave; }\n copy = _out - left;\n if (state.offset > copy) { /* copy from window */\n copy = state.offset - copy;\n if (copy > state.whave) {\n if (state.sane) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break;\n }\n// (!) This block is disabled in zlib defailts,\n// don't enable it for binary compatibility\n//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n// Trace((stderr, \"inflate.c too far\\n\"));\n// copy -= state.whave;\n// if (copy > state.length) { copy = state.length; }\n// if (copy > left) { copy = left; }\n// left -= copy;\n// state.length -= copy;\n// do {\n// output[put++] = 0;\n// } while (--copy);\n// if (state.length === 0) { state.mode = LEN; }\n// break;\n//#endif\n }\n if (copy > state.wnext) {\n copy -= state.wnext;\n from = state.wsize - copy;\n }\n else {\n from = state.wnext - copy;\n }\n if (copy > state.length) { copy = state.length; }\n from_source = state.window;\n }\n else { /* copy from output */\n from_source = output;\n from = put - state.offset;\n copy = state.length;\n }\n if (copy > left) { copy = left; }\n left -= copy;\n state.length -= copy;\n do {\n output[put++] = from_source[from++];\n } while (--copy);\n if (state.length === 0) { state.mode = LEN; }\n break;\n case LIT:\n if (left === 0) { break inf_leave; }\n output[put++] = state.length;\n left--;\n state.mode = LEN;\n break;\n case CHECK:\n if (state.wrap) {\n //=== NEEDBITS(32);\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n // Use '|' insdead of '+' to make sure that result is signed\n hold |= input[next++] << bits;\n bits += 8;\n }\n //===//\n _out -= left;\n strm.total_out += _out;\n state.total += _out;\n if (_out) {\n strm.adler = state.check =\n /*UPDATE(state.check, put - _out, _out);*/\n (state.flags ? crc32(state.check, output, _out, put - _out) : adler32(state.check, output, _out, put - _out));\n\n }\n _out = left;\n // NB: crc32 stored as signed 32-bit int, zswap32 returns signed too\n if ((state.flags ? hold : zswap32(hold)) !== state.check) {\n strm.msg = 'incorrect data check';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n //Tracev((stderr, \"inflate: check matches trailer\\n\"));\n }\n state.mode = LENGTH;\n /* falls through */\n case LENGTH:\n if (state.wrap && state.flags) {\n //=== NEEDBITS(32);\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (hold !== (state.total & 0xffffffff)) {\n strm.msg = 'incorrect length check';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n //Tracev((stderr, \"inflate: length matches trailer\\n\"));\n }\n state.mode = DONE;\n /* falls through */\n case DONE:\n ret = Z_STREAM_END;\n break inf_leave;\n case BAD:\n ret = Z_DATA_ERROR;\n break inf_leave;\n case MEM:\n return Z_MEM_ERROR;\n case SYNC:\n /* falls through */\n default:\n return Z_STREAM_ERROR;\n }\n }\n\n // inf_leave <- here is real place for \"goto inf_leave\", emulated via \"break inf_leave\"\n\n /*\n Return from inflate(), updating the total counts and the check value.\n If there was no progress during the inflate() call, return a buffer\n error. Call updatewindow() to create and/or update the window state.\n Note: a memory error from inflate() is non-recoverable.\n */\n\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n\n if (state.wsize || (_out !== strm.avail_out && state.mode < BAD &&\n (state.mode < CHECK || flush !== Z_FINISH))) {\n if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) {\n state.mode = MEM;\n return Z_MEM_ERROR;\n }\n }\n _in -= strm.avail_in;\n _out -= strm.avail_out;\n strm.total_in += _in;\n strm.total_out += _out;\n state.total += _out;\n if (state.wrap && _out) {\n strm.adler = state.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/\n (state.flags ? crc32(state.check, output, _out, strm.next_out - _out) : adler32(state.check, output, _out, strm.next_out - _out));\n }\n strm.data_type = state.bits + (state.last ? 64 : 0) +\n (state.mode === TYPE ? 128 : 0) +\n (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);\n if (((_in === 0 && _out === 0) || flush === Z_FINISH) && ret === Z_OK) {\n ret = Z_BUF_ERROR;\n }\n return ret;\n}\n\nfunction inflateEnd(strm) {\n\n if (!strm || !strm.state /*|| strm->zfree == (free_func)0*/) {\n return Z_STREAM_ERROR;\n }\n\n var state = strm.state;\n if (state.window) {\n state.window = null;\n }\n strm.state = null;\n return Z_OK;\n}\n\nfunction inflateGetHeader(strm, head) {\n var state;\n\n /* check state */\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n if ((state.wrap & 2) === 0) { return Z_STREAM_ERROR; }\n\n /* save header structure */\n state.head = head;\n head.done = false;\n return Z_OK;\n}\n\nfunction inflateSetDictionary(strm, dictionary) {\n var dictLength = dictionary.length;\n\n var state;\n var dictid;\n var ret;\n\n /* check state */\n if (!strm /* == Z_NULL */ || !strm.state /* == Z_NULL */) { return Z_STREAM_ERROR; }\n state = strm.state;\n\n if (state.wrap !== 0 && state.mode !== DICT) {\n return Z_STREAM_ERROR;\n }\n\n /* check for correct dictionary identifier */\n if (state.mode === DICT) {\n dictid = 1; /* adler32(0, null, 0)*/\n /* dictid = adler32(dictid, dictionary, dictLength); */\n dictid = adler32(dictid, dictionary, dictLength, 0);\n if (dictid !== state.check) {\n return Z_DATA_ERROR;\n }\n }\n /* copy dictionary to window using updatewindow(), which will amend the\n existing dictionary if appropriate */\n ret = updatewindow(strm, dictionary, dictLength, dictLength);\n if (ret) {\n state.mode = MEM;\n return Z_MEM_ERROR;\n }\n state.havedict = 1;\n // Tracev((stderr, \"inflate: dictionary set\\n\"));\n return Z_OK;\n}\n\n// String encode/decode helpers\n// 'use strict';\n\n\n// var utils = require('./common');\n\n\n// Quick check if we can use fast array to bin string conversion\n//\n// - apply(Array) can fail on Android 2.2\n// - apply(Uint8Array) can fail on iOS 5.1 Safary\n//\nvar STR_APPLY_OK = true;\nvar STR_APPLY_UIA_OK = true;\n\ntry { String.fromCharCode.apply(null, [ 0 ]); } catch (__) { STR_APPLY_OK = false; }\ntry { String.fromCharCode.apply(null, new Uint8Array(1)); } catch (__) { STR_APPLY_UIA_OK = false; }\n\n\n// Table with utf8 lengths (calculated by first byte of sequence)\n// Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS,\n// because max possible codepoint is 0x10ffff\nvar _utf8len = new Uint8Array(256);\nfor (var q = 0; q < 256; q++) {\n _utf8len[q] = (q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1);\n}\n_utf8len[254] = _utf8len[254] = 1; // Invalid sequence start\n\n\n// convert string to array (typed, when possible)\nfunction string2buf(str) {\n var buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;\n\n // count binary size\n for (m_pos = 0; m_pos < str_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n m_pos++;\n }\n }\n buf_len += c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4;\n }\n\n // allocate buffer\n buf = new Uint8Array(buf_len);\n\n // convert\n for (i = 0, m_pos = 0; i < buf_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n m_pos++;\n }\n }\n if (c < 0x80) {\n /* one byte */\n buf[i++] = c;\n } else if (c < 0x800) {\n /* two bytes */\n buf[i++] = 0xC0 | (c >>> 6);\n buf[i++] = 0x80 | (c & 0x3f);\n } else if (c < 0x10000) {\n /* three bytes */\n buf[i++] = 0xE0 | (c >>> 12);\n buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n buf[i++] = 0x80 | (c & 0x3f);\n } else {\n /* four bytes */\n buf[i++] = 0xf0 | (c >>> 18);\n buf[i++] = 0x80 | (c >>> 12 & 0x3f);\n buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n buf[i++] = 0x80 | (c & 0x3f);\n }\n }\n\n return buf;\n}\n\n// Helper (used in 2 places)\nfunction _buf2binstring(buf, len) {\n // use fallback for big arrays to avoid stack overflow\n if (len < 65537) {\n if ((buf.subarray && STR_APPLY_UIA_OK) || (!buf.subarray && STR_APPLY_OK)) {\n return String.fromCharCode.apply(null, shrinkBuf(buf, len));\n }\n }\n\n var result = '';\n for (var i = 0; i < len; i++) {\n result += String.fromCharCode(buf[i]);\n }\n return result;\n}\n\n\n// Convert binary string (typed, when possible)\nfunction binstring2buf(str) {\n var buf = new Uint8Array(str.length);\n for (var i = 0, len = buf.length; i < len; i++) {\n buf[i] = str.charCodeAt(i);\n }\n return buf;\n}\n\n\n// convert array to string\nfunction buf2string(buf, max) {\n var i, out, c, c_len;\n var len = max || buf.length;\n\n // Reserve max possible length (2 words per char)\n // NB: by unknown reasons, Array is significantly faster for\n // String.fromCharCode.apply than Uint16Array.\n var utf16buf = new Array(len * 2);\n\n for (out = 0, i = 0; i < len;) {\n c = buf[i++];\n // quick process ascii\n if (c < 0x80) { utf16buf[out++] = c; continue; }\n\n c_len = _utf8len[c];\n // skip 5 & 6 byte codes\n if (c_len > 4) { utf16buf[out++] = 0xfffd; i += c_len - 1; continue; }\n\n // apply mask on first byte\n c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07;\n // join the rest\n while (c_len > 1 && i < len) {\n c = (c << 6) | (buf[i++] & 0x3f);\n c_len--;\n }\n\n // terminated by end of string?\n if (c_len > 1) { utf16buf[out++] = 0xfffd; continue; }\n\n if (c < 0x10000) {\n utf16buf[out++] = c;\n } else {\n c -= 0x10000;\n utf16buf[out++] = 0xd800 | ((c >> 10) & 0x3ff);\n utf16buf[out++] = 0xdc00 | (c & 0x3ff);\n }\n }\n\n return _buf2binstring(utf16buf, out);\n}\n\n\n// Calculate max possible position in utf8 buffer,\n// that will not break sequence. If that's not possible\n// - (very small limits) return max size as is.\n//\n// buf[] - utf8 bytes array\n// max - length limit (mandatory);\nfunction utf8border(buf, max) {\n var pos;\n\n max = max || buf.length;\n if (max > buf.length) { max = buf.length; }\n\n // go back from last position, until start of sequence found\n pos = max - 1;\n while (pos >= 0 && (buf[pos] & 0xC0) === 0x80) { pos--; }\n\n // Fuckup - very small and broken sequence,\n // return max, because we should return something anyway.\n if (pos < 0) { return max; }\n\n // If we came to start of buffer - that means vuffer is too small,\n // return max too.\n if (pos === 0) { return max; }\n\n return (pos + _utf8len[buf[pos]] > max) ? pos : max;\n}\n\n/* Allowed flush values; see deflate() and inflate() below for details */\nvar Z_NO_FLUSH = 0;\nvar Z_SYNC_FLUSH = 2;\nvar Z_FINISH$1 = 4;\n/* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\nvar Z_OK$1 = 0;\nvar Z_STREAM_END$1 = 1;\nvar Z_NEED_DICT$1 = 2;\n//export var Z_MEM_ERROR = -4;\nvar Z_BUF_ERROR$1 = -5;\n\n// 'use strict';\n\nvar messages = {\n 2: 'need dictionary', /* Z_NEED_DICT 2 */\n 1: 'stream end', /* Z_STREAM_END 1 */\n 0: '', /* Z_OK 0 */\n '-1': 'file error', /* Z_ERRNO (-1) */\n '-2': 'stream error', /* Z_STREAM_ERROR (-2) */\n '-3': 'data error', /* Z_DATA_ERROR (-3) */\n '-4': 'insufficient memory', /* Z_MEM_ERROR (-4) */\n '-5': 'buffer error', /* Z_BUF_ERROR (-5) */\n '-6': 'incompatible version' /* Z_VERSION_ERROR (-6) */\n};\n\n// 'use strict';\n\n\nfunction ZStream() {\n /* next input byte */\n this.input = null; // JS specific, because we have no pointers\n this.next_in = 0;\n /* number of bytes available at input */\n this.avail_in = 0;\n /* total number of input bytes read so far */\n this.total_in = 0;\n /* next output byte should be put there */\n this.output = null; // JS specific, because we have no pointers\n this.next_out = 0;\n /* remaining free space at output */\n this.avail_out = 0;\n /* total number of bytes output so far */\n this.total_out = 0;\n /* last error message, NULL if no error */\n this.msg = ''/*Z_NULL*/;\n /* not visible by applications */\n this.state = null;\n /* best guess about the data type: binary or text */\n this.data_type = 2/*Z_UNKNOWN*/;\n /* adler32 value of the uncompressed data */\n this.adler = 0;\n}\n\n// 'use strict';\n\n\nfunction GZheader() {\n /* true if compressed data believed to be text */\n this.text = 0;\n /* modification time */\n this.time = 0;\n /* extra flags (not used when writing a gzip file) */\n this.xflags = 0;\n /* operating system */\n this.os = 0;\n /* pointer to extra field or Z_NULL if none */\n this.extra = null;\n /* extra field length (valid if extra != Z_NULL) */\n this.extra_len = 0; // Actually, we don't need it in JS,\n // but leave for few code modifications\n\n //\n // Setup limits is not necessary because in js we should not preallocate memory\n // for inflate use constant limit in 65536 bytes\n //\n\n /* space at extra (only when reading header) */\n // this.extra_max = 0;\n /* pointer to zero-terminated file name or Z_NULL */\n this.name = '';\n /* space at name (only when reading header) */\n // this.name_max = 0;\n /* pointer to zero-terminated comment or Z_NULL */\n this.comment = '';\n /* space at comment (only when reading header) */\n // this.comm_max = 0;\n /* true if there was or will be a header crc */\n this.hcrc = 0;\n /* true when done reading gzip header (not used when writing a gzip file) */\n this.done = false;\n}\n\n// 'use strict';\n\n\n// var zlib_inflate = require('./zlib/inflate');\n// var utils = require('./utils/common');\n// var strings = require('./utils/strings');\n// var c = require('./zlib/constants');\n// var msg = require('./zlib/messages');\n// var ZStream = require('./zlib/zstream');\n// var GZheader = require('./zlib/gzheader');\n\nvar toString = Object.prototype.toString;\n\n/**\n * class Inflate\n *\n * Generic JS-style wrapper for zlib calls. If you don't need\n * streaming behaviour - use more simple functions: [[inflate]]\n * and [[inflateRaw]].\n **/\n\n/* internal\n * inflate.chunks -> Array\n *\n * Chunks of output data, if [[Inflate#onData]] not overriden.\n **/\n\n/**\n * Inflate.result -> Uint8Array|Array|String\n *\n * Uncompressed result, generated by default [[Inflate#onData]]\n * and [[Inflate#onEnd]] handlers. Filled after you push last chunk\n * (call [[Inflate#push]] with `Z_FINISH` / `true` param) or if you\n * push a chunk with explicit flush (call [[Inflate#push]] with\n * `Z_SYNC_FLUSH` param).\n **/\n\n/**\n * Inflate.err -> Number\n *\n * Error code after inflate finished. 0 (Z_OK) on success.\n * Should be checked if broken data possible.\n **/\n\n/**\n * Inflate.msg -> String\n *\n * Error message, if [[Inflate.err]] != 0\n **/\n\n\n/**\n * new Inflate(options)\n * - options (Object): zlib inflate options.\n *\n * Creates new inflator instance with specified params. Throws exception\n * on bad params. Supported options:\n *\n * - `windowBits`\n * - `dictionary`\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information on these.\n *\n * Additional options, for internal needs:\n *\n * - `chunkSize` - size of generated data chunks (16K by default)\n * - `raw` (Boolean) - do raw inflate\n * - `to` (String) - if equal to 'string', then result will be converted\n * from utf8 to utf16 (javascript) string. When string output requested,\n * chunk length can differ from `chunkSize`, depending on content.\n *\n * By default, when no options set, autodetect deflate/gzip data format via\n * wrapper header.\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , chunk1 = Uint8Array([1,2,3,4,5,6,7,8,9])\n * , chunk2 = Uint8Array([10,11,12,13,14,15,16,17,18,19]);\n *\n * var inflate = new pako.Inflate({ level: 3});\n *\n * inflate.push(chunk1, false);\n * inflate.push(chunk2, true); // true -> last chunk\n *\n * if (inflate.err) { throw new Error(inflate.err); }\n *\n * console.log(inflate.result);\n * ```\n **/\nfunction Inflate(options) {\n if (!(this instanceof Inflate)) return new Inflate(options);\n\n this.options = assign({\n chunkSize: 16384,\n windowBits: 0,\n to: ''\n }, options || {});\n\n var opt = this.options;\n\n // Force window size for `raw` data, if not set directly,\n // because we have no header for autodetect.\n if (opt.raw && (opt.windowBits >= 0) && (opt.windowBits < 16)) {\n opt.windowBits = -opt.windowBits;\n if (opt.windowBits === 0) { opt.windowBits = -15; }\n }\n\n // If `windowBits` not defined (and mode not raw) - set autodetect flag for gzip/deflate\n if ((opt.windowBits >= 0) && (opt.windowBits < 16) &&\n !(options && options.windowBits)) {\n opt.windowBits += 32;\n }\n\n // Gzip header has no info about windows size, we can do autodetect only\n // for deflate. So, if window size not set, force it to max when gzip possible\n if ((opt.windowBits > 15) && (opt.windowBits < 48)) {\n // bit 3 (16) -> gzipped data\n // bit 4 (32) -> autodetect gzip/deflate\n if ((opt.windowBits & 15) === 0) {\n opt.windowBits |= 15;\n }\n }\n\n this.err = 0; // error code, if happens (0 = Z_OK)\n this.msg = ''; // error message\n this.ended = false; // used to avoid multiple onEnd() calls\n this.chunks = []; // chunks of compressed data\n\n this.strm = new ZStream();\n this.strm.avail_out = 0;\n\n var status = inflateInit2(\n this.strm,\n opt.windowBits\n );\n\n if (status !== Z_OK$1) {\n throw new Error(messages[status]);\n }\n\n this.header = new GZheader();\n\n inflateGetHeader(this.strm, this.header);\n}\n\n/**\n * Inflate#push(data[, mode]) -> Boolean\n * - data (Uint8Array|Array|ArrayBuffer|String): input data\n * - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.\n * See constants. Skipped or `false` means Z_NO_FLUSH, `true` meansh Z_FINISH.\n *\n * Sends input data to inflate pipe, generating [[Inflate#onData]] calls with\n * new output chunks. Returns `true` on success. The last data block must have\n * mode Z_FINISH (or `true`). That will flush internal pending buffers and call\n * [[Inflate#onEnd]]. For interim explicit flushes (without ending the stream) you\n * can use mode Z_SYNC_FLUSH, keeping the decompression context.\n *\n * On fail call [[Inflate#onEnd]] with error code and return false.\n *\n * We strongly recommend to use `Uint8Array` on input for best speed (output\n * format is detected automatically). Also, don't skip last param and always\n * use the same type in your code (boolean or number). That will improve JS speed.\n *\n * For regular `Array`-s make sure all elements are [0..255].\n *\n * ##### Example\n *\n * ```javascript\n * push(chunk, false); // push one of data chunks\n * ...\n * push(chunk, true); // push last chunk\n * ```\n **/\nInflate.prototype.push = function (data, mode) {\n var strm = this.strm;\n var chunkSize = this.options.chunkSize;\n var dictionary = this.options.dictionary;\n var status, _mode;\n var next_out_utf8, tail, utf8str;\n var dict;\n\n // Flag to properly process Z_BUF_ERROR on testing inflate call\n // when we check that all output data was flushed.\n var allowBufError = false;\n\n if (this.ended) { return false; }\n _mode = (mode === ~~mode) ? mode : ((mode === true) ? Z_FINISH$1 : Z_NO_FLUSH);\n\n // Convert data if needed\n if (typeof data === 'string') {\n // Only binary strings can be decompressed on practice\n strm.input = binstring2buf(data);\n } else if (toString.call(data) === '[object ArrayBuffer]') {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\n\n do {\n if (strm.avail_out === 0) {\n strm.output = new Uint8Array(chunkSize);\n strm.next_out = 0;\n strm.avail_out = chunkSize;\n }\n\n status = inflate(strm, Z_NO_FLUSH); /* no bad return value */\n\n if (status === Z_NEED_DICT$1 && dictionary) {\n // Convert data if needed\n if (typeof dictionary === 'string') {\n dict = string2buf(dictionary);\n } else if (toString.call(dictionary) === '[object ArrayBuffer]') {\n dict = new Uint8Array(dictionary);\n } else {\n dict = dictionary;\n }\n\n status = inflateSetDictionary(this.strm, dict);\n\n }\n\n if (status === Z_BUF_ERROR$1 && allowBufError === true) {\n status = Z_OK$1;\n allowBufError = false;\n }\n\n if (status !== Z_STREAM_END$1 && status !== Z_OK$1) {\n this.onEnd(status);\n this.ended = true;\n return false;\n }\n\n if (strm.next_out) {\n if (strm.avail_out === 0 || status === Z_STREAM_END$1 || (strm.avail_in === 0 && (_mode === Z_FINISH$1 || _mode === Z_SYNC_FLUSH))) {\n\n if (this.options.to === 'string') {\n\n next_out_utf8 = utf8border(strm.output, strm.next_out);\n\n tail = strm.next_out - next_out_utf8;\n utf8str = buf2string(strm.output, next_out_utf8);\n\n // move tail\n strm.next_out = tail;\n strm.avail_out = chunkSize - tail;\n if (tail) { arraySet(strm.output, strm.output, next_out_utf8, tail, 0); }\n\n this.onData(utf8str);\n\n } else {\n this.onData(shrinkBuf(strm.output, strm.next_out));\n }\n }\n }\n\n // When no more input data, we should check that internal inflate buffers\n // are flushed. The only way to do it when avail_out = 0 - run one more\n // inflate pass. But if output data not exists, inflate return Z_BUF_ERROR.\n // Here we set flag to process this error properly.\n //\n // NOTE. Deflate does not return error in this case and does not needs such\n // logic.\n if (strm.avail_in === 0 && strm.avail_out === 0) {\n allowBufError = true;\n }\n\n } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== Z_STREAM_END$1);\n\n if (status === Z_STREAM_END$1) {\n _mode = Z_FINISH$1;\n }\n\n // Finalize on the last chunk.\n if (_mode === Z_FINISH$1) {\n status = inflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return status === Z_OK$1;\n }\n\n // callback interim results if Z_SYNC_FLUSH.\n if (_mode === Z_SYNC_FLUSH) {\n this.onEnd(Z_OK$1);\n strm.avail_out = 0;\n return true;\n }\n\n return true;\n};\n\n\n/**\n * Inflate#onData(chunk) -> Void\n * - chunk (Uint8Array|Array|String): ouput data. Type of array depends\n * on js engine support. When string output requested, each chunk\n * will be string.\n *\n * By default, stores data blocks in `chunks[]` property and glue\n * those in `onEnd`. Override this handler, if you need another behaviour.\n **/\nInflate.prototype.onData = function (chunk) {\n this.chunks.push(chunk);\n};\n\n\n/**\n * Inflate#onEnd(status) -> Void\n * - status (Number): inflate status. 0 (Z_OK) on success,\n * other if not.\n *\n * Called either after you tell inflate that the input stream is\n * complete (Z_FINISH) or should be flushed (Z_SYNC_FLUSH)\n * or if an error happened. By default - join collected chunks,\n * free memory and fill `results` / `err` properties.\n **/\nInflate.prototype.onEnd = function (status) {\n // On success - join\n if (status === Z_OK$1) {\n if (this.options.to === 'string') {\n // Glue & convert here, until we teach pako to send\n // utf8 alligned strings to onData\n this.result = this.chunks.join('');\n } else {\n this.result = flattenChunks(this.chunks);\n }\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n};\n\n\n/**\n * inflate(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * Decompress `data` with inflate/ungzip and `options`. Autodetect\n * format via wrapper header by default. That's why we don't provide\n * separate `ungzip` method.\n *\n * Supported options are:\n *\n * - windowBits\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information.\n *\n * Sugar (options):\n *\n * - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify\n * negative windowBits implicitly.\n * - `to` (String) - if equal to 'string', then result will be converted\n * from utf8 to utf16 (javascript) string. When string output requested,\n * chunk length can differ from `chunkSize`, depending on content.\n *\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , input = pako.deflate([1,2,3,4,5,6,7,8,9])\n * , output;\n *\n * try {\n * output = pako.inflate(input);\n * } catch (err)\n * console.log(err);\n * }\n * ```\n **/\nfunction doInflate(input, options) {\n var inflator = new Inflate(options);\n\n inflator.push(input, true);\n\n // That will never happens, if you don't cheat with options :)\n if (inflator.err) { throw inflator.msg; }\n\n return inflator.result;\n}\n\nexport { doInflate as ungzip };","/**\n * @file Validation Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport XmlParser, { XmlParserParameters } from './xml-parser'\nimport Validation from '../structure/validation'\nimport Streamer from '../streamer/streamer';\n\nclass ValidationParser extends XmlParser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.useDomParser = true\n this.validation = new Validation(this.name, this.path)\n }\n\n get __objName () { return 'validation' }\n get isXml () { return true }\n\n _parse () {\n super._parse()\n\n if (Debug) Log.time('ValidationParser._parse ' + this.name)\n\n this.validation.fromXml(this.xml.data)\n\n if (Debug) Log.timeEnd('ValidationParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('validation', ValidationParser)\n\nexport default ValidationParser\n","/**\n * @file Gzip Decompressor\n * @author Alexander Rose \n * @private\n */\n\nimport { ungzip } from '../../lib/pako_inflate.es6'\n\nimport { DecompressorRegistry } from '../globals'\n\nfunction gzipDecompress (data: ArrayBuffer|Uint8Array) {\n let decompressedData\n\n if (data instanceof ArrayBuffer) {\n data = new Uint8Array(data)\n }\n\n try {\n decompressedData = ungzip(data as Uint8Array)\n } catch (e) {\n decompressedData = data // assume it is already uncompressed\n }\n\n return decompressedData\n}\n\nDecompressorRegistry.add('gz', gzipDecompress)\n","/**\n * @file Datasource\n * @author Alexander Rose \n * @private\n */\n\n/**\n * Datasource base class\n * @interface\n */\nabstract class Datasource {\n /**\n * Get full url\n * @abstract\n * @param {String} path - datasource string\n * @return {String} - url\n */\n abstract getUrl (path: string): string\n\n /**\n * Get file extension\n * @abstract\n * @param {String} path - datasource string\n * @return {String} - extension\n */\n abstract getExt (path: string): string\n}\n\nexport default Datasource\n","/**\n * @file RCSB Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { Log, DatasourceRegistry } from '../globals'\nimport { getProtocol } from '../utils'\nimport { getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nconst baseUrl = '//files.rcsb.org/download/'\nconst mmtfBaseUrl = '//mmtf.rcsb.org/v1.0/'\nconst mmtfFullUrl = mmtfBaseUrl + 'full/'\nconst mmtfReducedUrl = mmtfBaseUrl + 'reduced/'\n\nclass RcsbDatasource extends Datasource {\n getUrl (src: string) {\n // valid path are\n // XXXX.pdb, XXXX.pdb.gz, XXXX.cif, XXXX.cif.gz, XXXX.mmtf, XXXX.bb.mmtf\n // XXXX defaults to XXXX.cif\n const info = getFileInfo(src)\n const pdbid = info.name.substr(0, 4)\n let url\n if ([ 'pdb', 'cif' ].includes(info.ext) &&\n (info.compressed === false || info.compressed === 'gz')\n ) {\n url = baseUrl + info.path\n } else if (info.ext === 'mmtf') {\n if (info.base.endsWith('.bb')) {\n url = mmtfReducedUrl + pdbid\n } else {\n url = mmtfFullUrl + pdbid\n }\n } else if (!info.ext) {\n url = mmtfFullUrl + pdbid\n } else {\n Log.warn('unsupported ext', info.ext)\n url = mmtfFullUrl + pdbid\n }\n return getProtocol() + url\n }\n\n getExt (src: string) {\n const ext = getFileInfo(src).ext\n return ext ? ext : 'mmtf'\n }\n}\n\nDatasourceRegistry.add('rcsb', new RcsbDatasource())\n\nexport default RcsbDatasource\n","/**\n * @file PubChem Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { Log, DatasourceRegistry } from '../globals'\nimport { getProtocol } from '../utils'\nimport { getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nconst baseUrl = '//pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/'\nconst suffixUrl = '/SDF?record_type=3d'\n\nclass PubchemDatasource extends Datasource {\n getUrl (src: string) {\n const info = getFileInfo(src)\n const cid = info.name\n let url\n if (!info.ext || info.ext === 'sdf') {\n url = baseUrl + cid + suffixUrl\n } else {\n Log.warn('unsupported ext', info.ext)\n url = baseUrl + cid + suffixUrl\n }\n return getProtocol() + url\n }\n\n getExt (src: string) {\n const ext = getFileInfo(src).ext\n return ext ? ext : 'sdf'\n }\n}\n\nDatasourceRegistry.add('pubchem', new PubchemDatasource())\n\nexport default PubchemDatasource\n","/**\n * @file Pass Through Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { DatasourceRegistry } from '../globals'\nimport { getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nclass PassThroughDatasource extends Datasource {\n getUrl (path: string) {\n return path\n }\n\n getExt (path: string) {\n return getFileInfo(path).ext\n }\n}\n\nDatasourceRegistry.add('ftp', new PassThroughDatasource())\nDatasourceRegistry.add('http', new PassThroughDatasource())\nDatasourceRegistry.add('https', new PassThroughDatasource())\n\nexport default PassThroughDatasource\n","/**\r\n * @file Alphafold Datasource\r\n * @author Fredric Johansson \r\n * @private\r\n */\r\n\r\nimport { Log, DatasourceRegistry } from '../globals'\r\nimport { getProtocol } from '../utils'\r\nimport { getFileInfo } from '../loader/loader-utils'\r\nimport Datasource from './datasource'\r\n\r\nconst baseUrl = '//alphafold.ebi.ac.uk/files/AF-'\r\nconst suffixURL = '-F1-model_v2.pdb'\r\n\r\nclass AlphafoldDatasource extends Datasource {\r\n getUrl (src: string) {\r\n const info = getFileInfo(src)\r\n const uniprotid = info.name\r\n let url\r\n if (!info.ext || info.ext === 'pdb') {\r\n url = baseUrl + uniprotid + suffixURL\r\n } else {\r\n Log.warn('unsupported AF ext', info.ext)\r\n url = baseUrl + uniprotid + suffixURL\r\n }\r\n return getProtocol() + url\r\n }\r\n\r\n getExt (src: string) {\r\n const ext = getFileInfo(src).ext\r\n return ext ? ext : 'pdb'\r\n }\r\n}\r\n\r\nDatasourceRegistry.add('alphafold', new AlphafoldDatasource())\r\n\r\nexport default AlphafoldDatasource\r\n","/**\n * @file Static Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { getAbsolutePath } from '../utils'\nimport { getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nconst reProtocol = /^((http|https|ftp):)*\\/\\//\n\nclass StaticDatasource extends Datasource {\n baseUrl: string\n\n constructor (baseUrl: string = '') {\n super()\n this.baseUrl = baseUrl\n }\n\n getUrl (src: string) {\n const info = getFileInfo(src)\n let url = this.baseUrl + info.path\n if (!reProtocol.test(this.baseUrl)) {\n url = getAbsolutePath(url)\n }\n return url\n }\n\n getExt (src: string) {\n return getFileInfo(src).ext\n }\n}\n\nexport default StaticDatasource\n","/**\n * @file UI Parameters\n * @author Alexander Rose \n */\n\nimport { StageParameters } from '../stage/stage'\nimport { MouseActionPresets } from '../controls/mouse-actions'\n\nexport type BooleanParam = { type: 'boolean' }\nfunction BooleanParam () { return { type: 'boolean' } as BooleanParam }\n\nexport type ColorParam = { type: 'color' }\nfunction ColorParam () { return { type: 'color' } as ColorParam }\n\nexport type IntegerParam = { type: 'integer', max: number, min: number }\nfunction IntegerParam (max: number, min: number) {\n return { type: 'integer', max, min } as IntegerParam\n}\n\nexport type NumberParam = { type: 'number', precision: number, max: number, min: number }\nfunction NumberParam (precision: number, max: number, min: number) {\n return { type: 'number', precision, max, min } as NumberParam\n}\n\nexport type RangeParam = { type: 'range', step: number, max: number, min: number }\nfunction RangeParam (step: number, max: number, min: number) {\n return { type: 'range', step, max, min } as RangeParam\n}\n\nexport type SelectParam = { type: 'select', options: { [k: string]: string } }\nfunction SelectParam (...options: string[]) {\n return { type: 'select', options: options.reduce((o, k) => ({ ...o, [k]: k}), {}) } as SelectParam\n}\n\nexport type ParamType = BooleanParam|ColorParam|IntegerParam|NumberParam|RangeParam|SelectParam\n\nexport const UIStageParameters: { [k in keyof StageParameters]: ParamType } = {\n backgroundColor: ColorParam(),\n quality: SelectParam('auto', 'low', 'medium', 'high'),\n sampleLevel: RangeParam(1, 5, -1),\n impostor: BooleanParam(),\n workerDefault: BooleanParam(),\n rotateSpeed: NumberParam(1, 10, 0),\n zoomSpeed: NumberParam(1, 10, 0),\n panSpeed: NumberParam(1, 10, 0),\n clipNear: RangeParam(1, 100, 0),\n clipFar: RangeParam(1, 100, 0),\n clipDist: IntegerParam(200, 0),\n clipMode: SelectParam('scene', 'camera'),\n clipScale: SelectParam('relative', 'absolute'),\n fogNear: RangeParam(1, 100, 0),\n fogFar: RangeParam(1, 100, 0),\n cameraType: SelectParam('perspective', 'orthographic', 'stereo'),\n cameraEyeSep: NumberParam(3, 1.0, 0.01),\n cameraFov: RangeParam(1, 120, 15),\n lightColor: ColorParam(),\n lightIntensity: NumberParam(2, 10, 0),\n ambientColor: ColorParam(),\n ambientIntensity: NumberParam(2, 10, 0),\n hoverTimeout: IntegerParam(10000, -1),\n tooltip: BooleanParam(),\n mousePreset: SelectParam(...Object.keys(MouseActionPresets))\n}\n","/**\n * @file MDsrv Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { autoLoad, getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nclass MdsrvDatasource extends Datasource {\n baseUrl: string\n\n constructor (baseUrl: string = '') {\n super()\n this.baseUrl = baseUrl\n }\n\n getListing (path: string = '') {\n let url = `${this.baseUrl}dir/${path}`\n if (url[url.length - 1] !== '/') url += '/'\n return autoLoad(url, {\n ext: 'json'\n }).then((jsonData: any) => ({\n path: path,\n data: jsonData.data\n }))\n }\n\n getUrl (src: string) {\n const info = getFileInfo(src)\n return `${this.baseUrl}file/${info.path}${info.query}`\n }\n\n getCountUrl (src: string) {\n const info = getFileInfo(src)\n return `${this.baseUrl}traj/numframes/${info.path}${info.query}`\n }\n\n getFrameUrl (src: string, frameIndex: number|string) {\n const info = getFileInfo(src)\n return `${this.baseUrl}traj/frame/${frameIndex}/${info.path}${info.query}`\n }\n\n getFrameParams (src: string, atomIndices: (number|string)[]) {\n return `atomIndices=${atomIndices.join(';')}`\n }\n\n getPathUrl (src: string, atomIndex: number|string) {\n const info = getFileInfo(src)\n return `${this.baseUrl}traj/path/${atomIndex}/${info.path}${info.query}`\n }\n\n getExt (src: string) {\n return getFileInfo(src).ext\n }\n}\n\nexport default MdsrvDatasource\n","/**\n * @file Pdb Writer\n * @author Alexander Rose \n * @private\n */\n\nimport { sprintf } from 'sprintf-js'\n\nimport Writer from './writer'\nimport { defaults, ensureArray } from '../utils'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\n\n// http://www.wwpdb.org/documentation/file-format\n\n// Sample PDB line, the coords X,Y,Z are fields 5,6,7 on each line.\n// ATOM 1 N ARG 1 29.292 13.212 -12.751 1.00 33.78 1BPT 108\n\nconst AtomFormat =\n 'ATOM %5d %-4s %3s %1s%4d %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%1s%1s'\n\nconst HetatmFormat =\n 'HETATM%5d %-4s %3s %1s%4d %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%1s%1s'\n\nexport interface PdbWriterParams {\n renumberSerial: boolean\n remarks: string[]\n}\n\n/**\n * Create a PDB file from a Structure object\n */\nexport default class PdbWriter extends Writer {\n readonly mimeType = 'text/plain'\n readonly defaultName = 'structure'\n readonly defaultExt = 'pdb'\n\n renumberSerial: boolean\n remarks: string[]\n\n structure: Structure\n private _records: string[]\n\n /**\n * @param {Structure} structure - the structure object\n * @param {Object} params - parameters]\n */\n constructor (structure: Structure, params?: PdbWriterParams) {\n super()\n\n const p = Object.assign({}, params)\n\n this.renumberSerial = defaults(p.renumberSerial, true)\n this.remarks = ensureArray(defaults(p.remarks, []))\n\n this.structure = structure\n this._records = []\n }\n\n private _writeRecords () {\n this._records.length = 0\n\n this._writeTitle()\n this._writeRemarks()\n this._writeAtoms()\n }\n\n private _writeTitle () {\n // FIXME multiline if title line longer than 80 chars\n this._records.push(sprintf('TITLE %-74s', this.structure.name))\n }\n\n private _writeRemarks () {\n this.remarks.forEach(str => {\n this._records.push(sprintf('REMARK %-73s', str))\n })\n\n if (this.structure.trajectory) {\n this._records.push(sprintf(\n 'REMARK %-73s',\n \"Trajectory '\" + this.structure.trajectory.name + \"'\"\n ))\n this._records.push(sprintf(\n 'REMARK %-73s',\n `Frame ${(this.structure.trajectory as any).frame}` // TODO\n ))\n }\n }\n\n private _writeAtoms () {\n let ia = 1\n let im = 1\n let charge = \" \"\n let chargeSign = \" \"\n const hasModels = this.structure.modelStore.count > 1\n\n this.structure.eachModel(m => {\n if (hasModels) this._records.push(sprintf('MODEL %4d%-66s', im++, ''))\n\n m.eachAtom((a: AtomProxy) => {\n const formatString = a.hetero ? HetatmFormat : AtomFormat\n const serial = this.renumberSerial ? ia : a.serial\n\n // Formal PDB spec\n // Alignment of one-letter atom name such as C starts at column 14,\n // while two-letter atom name such as FE starts at column 13.\n\n // This, however, leaves Calcium and C-alpha ambiguous\n // The convention (from earlier versions of the spec, see 1992, and also: \n // https://www.cgl.ucsf.edu/chimera/docs/UsersGuide/tutorials/pdbintro.html#misalignment)\n // is that element is right-justified in 13-14, modifiers are left justified in columns 15-16\n // A single-character element symmbol should not appear in column 13 unless the atom name has four characters\n let atomname = a.atomname\n\n if (atomname.length === 1) {\n // Simple case\n atomname = ' ' + atomname\n } else if (atomname.length < 4) {\n // 2 or 3-letter name, if element symbol is single char and matches name, add a space\n if (a.element.length === 1 && atomname[0] === a.element) {\n atomname = ' ' + atomname\n }\n }\n\n if (a.formalCharge) { // Skip nulls and zeros\n charge = Math.abs(a.formalCharge).toPrecision(1)\n chargeSign = (a.formalCharge > 0) ? \"+\" : \"-\"\n } else {\n charge = \" \"\n chargeSign = \" \"\n }\n\n this._records.push(sprintf(\n formatString,\n\n serial,\n atomname,\n a.resname,\n defaults(a.chainname, ' '),\n a.resno,\n a.x, a.y, a.z,\n defaults(a.occupancy, 1.0),\n defaults(a.bfactor, 0.0),\n '', // segid\n defaults(a.element, ''),\n charge,\n chargeSign\n ))\n ia += 1\n }, this.structure.getSelection())\n\n if (hasModels) this._records.push(sprintf('%-80s', 'ENDMDL'))\n })\n\n this._records.push(sprintf('%-80s', 'END'))\n }\n\n getString () {\n console.warn('PdbWriter.getString() is deprecated, use .getData instead')\n return this.getData()\n }\n\n /**\n * Get string containing the PDB file data\n * @return {String} PDB file\n */\n getData () {\n this._writeRecords()\n return this._records.join('\\n')\n }\n}\n","/**\n * Writer class for sdf/mol files.\n */\n\nimport { sprintf } from 'sprintf-js'\n\nimport Writer from './writer'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\nimport BondProxy from '../proxy/bond-proxy'\n\n// Hard-coded chiral as false as we don't specify it any atoms\nconst CountFormat = '%3i%3i 0 0 0 0 0 0 0 0999 V2000'\nconst AtomLine = '%10.4f%10.4f%10.4f %-3s 0%3i 0 0 0'\nconst BondFormat = '%3i%3i%3i 0 0 0'\n\nclass SdfWriter extends Writer {\n readonly mimeType = 'text/plain'\n readonly defaultName = 'structure'\n readonly defaultExt = 'sdf'\n\n structure: Structure\n private _records: string[]\n\n /**\n * @param {Structure} structure - structure to write\n * @param {Object} params - parameters\n */\n constructor (structure: Structure) {\n super()\n\n this.structure = structure\n // Follow the pdb-writer example:\n this._records = []\n }\n\n get idString () {\n return this.structure.id\n }\n\n get titleString () {\n return ' ' + this.structure.title\n }\n\n get countsString () {\n return sprintf(\n CountFormat,\n this.structure.atomCount,\n this.structure.bondCount\n )\n }\n\n get chargeLines () {\n const pairs: [number, number][] = []\n this.structure.eachAtom(ap => {\n if (ap.formalCharge != null && ap.formalCharge !== 0) {\n pairs.push([ap.index, ap.formalCharge])\n }\n })\n const lines = []\n for (let i = 0; i < pairs.length; i += 8) {\n const nCharges = Math.min(8, pairs.length - i)\n let s = sprintf('M CHG%3i', nCharges)\n for (let j = i; j < i + nCharges; j++) {\n s += sprintf(' %3i %3i', pairs[j][0] + 1, pairs[j][1])\n }\n lines.push(s)\n }\n return lines\n }\n\n formatAtom (ap: AtomProxy) {\n let charge = 0\n if (ap.formalCharge != null && ap.formalCharge !== 0) {\n charge = 4 - ap.formalCharge\n }\n const line = sprintf(\n AtomLine, ap.x, ap.y, ap.z, ap.element, charge\n )\n if (line.length !== 48) { throw new Error('Incompatible atom for sdf format') }\n\n return line\n }\n\n formatBond (bp: BondProxy) {\n return sprintf(\n BondFormat,\n bp.atomIndex1 + 1,\n bp.atomIndex2 + 1,\n bp.bondOrder)\n }\n\n _writeRecords () {\n this._records.length = 0\n this._writeHeader()\n this._writeCTab()\n this._writeFooter()\n }\n\n _writeHeader () {\n this._records.push(this.idString, this.titleString, '')\n }\n\n _writeCTab () {\n this._records.push(this.countsString)\n this.structure.eachAtom(ap => {\n this._records.push(this.formatAtom(ap))\n })\n this.structure.eachBond(bp => {\n this._records.push(this.formatBond(bp))\n })\n this.chargeLines.forEach(line => {\n this._records.push(line)\n })\n this._records.push('M END')\n }\n\n _writeFooter () {\n this._records.push('$$$$')\n }\n\n getData () {\n this._writeRecords()\n return this._records.join('\\n')\n }\n}\n\nexport default SdfWriter\n","/**\n * @file STL Writer\n * @author Paul Pillot \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport Writer from './writer'\nimport IOBuffer from '../utils/io-buffer'\nimport Surface from '../surface/surface'\n\n// https://en.wikipedia.org/wiki/STL_(file_format)#ASCII_STL\n\n/**\n * Create an STL File from a surface Object (e.g. for 3D printing)\n *\n * @example\n * molsurf = new MolecularSurface(structure)\n * surf = molsurf.getSurface({type: 'av', probeRadius: 1.4})\n * stl = new StlWriter(surf)\n * stl.download('myFileName')\n */\nexport default class StlWriter extends Writer {\n readonly mimeType = 'application/vnd.ms-pki.stl'\n readonly defaultName = 'surface'\n readonly defaultExt = 'stl'\n\n surface: any // TODO\n\n /**\n * @param {Surface} surface - the surface to write out\n */\n constructor (surface: Surface) {\n super()\n\n this.surface = surface\n }\n\n /*\n * Get STL Binary data\n *\n * Adapted from: https://github.com/mrdoob/three.js/blob/master/examples/js/exporters/STLBinaryExporter.js\n * see https://en.wikipedia.org/wiki/STL_(file_format)#Binary_STL for the file format description\n *\n * @return {DataView} the data\n */\n getData () {\n const triangles = this.surface.index.length / 3\n const bufferLength = triangles * 2 + triangles * 3 * 4 * 4 + 80 + 4\n const output = new IOBuffer(bufferLength)\n\n output.skip(80) // skip header\n output.writeUint32(triangles)\n\n const vector = new Vector3()\n const vectorNorm1 = new Vector3()\n const vectorNorm2 = new Vector3()\n const vectorNorm3 = new Vector3()\n\n // traversing vertices\n for (let i = 0; i < triangles; i++) {\n const indices = [\n this.surface.index[i * 3],\n this.surface.index[i * 3 + 1],\n this.surface.index[i * 3 + 2]\n ]\n\n vectorNorm1.fromArray(this.surface.normal, indices[0] * 3)\n vectorNorm2.fromArray(this.surface.normal, indices[1] * 3)\n vectorNorm3.fromArray(this.surface.normal, indices[2] * 3)\n\n vector.addVectors(vectorNorm1, vectorNorm2).add(vectorNorm3).normalize()\n\n output.writeFloat32(vector.x)\n output.writeFloat32(vector.y)\n output.writeFloat32(vector.z)\n\n for (let j = 0; j < 3; j++) {\n vector.fromArray(this.surface.position, indices[j] * 3)\n\n output.writeFloat32(vector.x) // vertices\n output.writeFloat32(vector.y)\n output.writeFloat32(vector.z)\n }\n\n output.writeUint16(0) // attribute byte count\n }\n\n return new DataView(output.buffer)\n }\n}"],"names":["CullFaceNone","CullFaceBack","CullFaceFront","PCFShadowMap","PCFSoftShadowMap","VSMShadowMap","FrontSide","BackSide","DoubleSide","NoBlending","NormalBlending","AdditiveBlending","SubtractiveBlending","MultiplyBlending","CustomBlending","AddEquation","SubtractEquation","ReverseSubtractEquation","MinEquation","MaxEquation","ZeroFactor","OneFactor","SrcColorFactor","OneMinusSrcColorFactor","SrcAlphaFactor","OneMinusSrcAlphaFactor","DstAlphaFactor","OneMinusDstAlphaFactor","DstColorFactor","OneMinusDstColorFactor","SrcAlphaSaturateFactor","NeverDepth","AlwaysDepth","LessDepth","LessEqualDepth","EqualDepth","GreaterEqualDepth","GreaterDepth","NotEqualDepth","MultiplyOperation","MixOperation","AddOperation","NoToneMapping","LinearToneMapping","ReinhardToneMapping","CineonToneMapping","ACESFilmicToneMapping","CustomToneMapping","CubeReflectionMapping","CubeRefractionMapping","EquirectangularReflectionMapping","EquirectangularRefractionMapping","CubeUVReflectionMapping","CubeUVRefractionMapping","RepeatWrapping","ClampToEdgeWrapping","MirroredRepeatWrapping","NearestFilter","NearestMipmapNearestFilter","NearestMipmapLinearFilter","LinearFilter","LinearMipmapNearestFilter","LinearMipmapLinearFilter","UnsignedByteType","ByteType","ShortType","UnsignedShortType","IntType","UnsignedIntType","FloatType","HalfFloatType","UnsignedShort4444Type","UnsignedShort5551Type","UnsignedShort565Type","UnsignedInt248Type","AlphaFormat","RGBFormat","RGBAFormat","LuminanceFormat","LuminanceAlphaFormat","DepthFormat","DepthStencilFormat","RedFormat","RedIntegerFormat","RGFormat","RGIntegerFormat","RGBIntegerFormat","RGBAIntegerFormat","RGB_S3TC_DXT1_Format","RGBA_S3TC_DXT1_Format","RGBA_S3TC_DXT3_Format","RGBA_S3TC_DXT5_Format","RGB_PVRTC_4BPPV1_Format","RGB_PVRTC_2BPPV1_Format","RGBA_PVRTC_4BPPV1_Format","RGBA_PVRTC_2BPPV1_Format","RGB_ETC1_Format","RGB_ETC2_Format","RGBA_ETC2_EAC_Format","RGBA_ASTC_4x4_Format","RGBA_ASTC_5x4_Format","RGBA_ASTC_5x5_Format","RGBA_ASTC_6x5_Format","RGBA_ASTC_6x6_Format","RGBA_ASTC_8x5_Format","RGBA_ASTC_8x6_Format","RGBA_ASTC_8x8_Format","RGBA_ASTC_10x5_Format","RGBA_ASTC_10x6_Format","RGBA_ASTC_10x8_Format","RGBA_ASTC_10x10_Format","RGBA_ASTC_12x10_Format","RGBA_ASTC_12x12_Format","RGBA_BPTC_Format","SRGB8_ALPHA8_ASTC_4x4_Format","SRGB8_ALPHA8_ASTC_5x4_Format","SRGB8_ALPHA8_ASTC_5x5_Format","SRGB8_ALPHA8_ASTC_6x5_Format","SRGB8_ALPHA8_ASTC_6x6_Format","SRGB8_ALPHA8_ASTC_8x5_Format","SRGB8_ALPHA8_ASTC_8x6_Format","SRGB8_ALPHA8_ASTC_8x8_Format","SRGB8_ALPHA8_ASTC_10x5_Format","SRGB8_ALPHA8_ASTC_10x6_Format","SRGB8_ALPHA8_ASTC_10x8_Format","SRGB8_ALPHA8_ASTC_10x10_Format","SRGB8_ALPHA8_ASTC_12x10_Format","SRGB8_ALPHA8_ASTC_12x12_Format","LinearEncoding","sRGBEncoding","GammaEncoding","RGBEEncoding","LogLuvEncoding","RGBM7Encoding","RGBM16Encoding","RGBDEncoding","BasicDepthPacking","RGBADepthPacking","TangentSpaceNormalMap","ObjectSpaceNormalMap","KeepStencilOp","AlwaysStencilFunc","StaticDrawUsage","EventDispatcher","Object","assign","prototype","addEventListener","type","listener","undefined","this","_listeners","listeners","indexOf","push","hasEventListener","removeEventListener","listenerArray","index","splice","dispatchEvent","event","target","array","slice","i","l","length","call","_lut","toString","MathUtils","DEG2RAD","Math","PI","RAD2DEG","generateUUID","d0","random","d1","d2","d3","toUpperCase","clamp","value","min","max","euclideanModulo","n","m","mapLinear","x","a1","a2","b1","b2","lerp","y","t","smoothstep","smootherstep","randInt","low","high","floor","randFloat","randFloatSpread","range","degToRad","degrees","radToDeg","radians","isPowerOfTwo","ceilPowerOfTwo","pow","ceil","log","LN2","floorPowerOfTwo","setQuaternionFromProperEuler","q","a","b","c","order","cos","sin","c2","s2","c13","s13","c1_3","s1_3","c3_1","s3_1","set","console","warn","Vector2","Matrix3","elements","arguments","error","_canvas","defineProperties","width","get","height","isVector2","setScalar","scalar","setX","setY","setComponent","Error","getComponent","clone","constructor","copy","v","add","w","addVectors","addScalar","s","addScaledVector","sub","subVectors","subScalar","multiply","multiplyScalar","divide","divideScalar","applyMatrix3","e","clampScalar","minVal","maxVal","clampLength","round","roundToZero","negate","dot","cross","lengthSq","sqrt","manhattanLength","abs","normalize","angle","atan2","distanceTo","distanceToSquared","dx","dy","manhattanDistanceTo","setLength","alpha","lerpVectors","v1","v2","equals","fromArray","offset","toArray","fromBufferAttribute","attribute","getX","getY","rotateAround","center","isMatrix3","n11","n12","n13","n21","n22","n23","n31","n32","n33","te","identity","me","extractBasis","xAxis","yAxis","zAxis","setFromMatrix3Column","setFromMatrix4","multiplyMatrices","premultiply","ae","be","a11","a12","a13","a21","a22","a23","a31","a32","a33","b11","b12","b13","b21","b22","b23","b31","b32","b33","determinant","d","f","g","h","getInverse","matrix","throwOnDegenerate","t11","t12","t13","det","detInv","transpose","tmp","getNormalMatrix","matrix4","transposeIntoArray","r","setUvTransform","tx","ty","sx","sy","rotation","cx","cy","scale","rotate","theta","translate","ImageUtils","image","test","src","HTMLCanvasElement","canvas","document","createElementNS","context","getContext","ImageData","putImageData","drawImage","toDataURL","textureId","Texture","mapping","wrapS","wrapT","magFilter","minFilter","format","anisotropy","encoding","defineProperty","uuid","name","DEFAULT_IMAGE","mipmaps","DEFAULT_MAPPING","internalFormat","repeat","matrixAutoUpdate","generateMipmaps","premultiplyAlpha","flipY","unpackAlignment","version","onUpdate","Vector4","z","WebGLRenderTarget","options","scissor","scissorTest","viewport","texture","depthBuffer","stencilBuffer","depthTexture","Quaternion","_x","_y","_z","_w","create","isTexture","updateMatrix","source","toJSON","meta","isRootObject","textures","output","metadata","generator","wrap","images","url","Array","isArray","dispose","transformUv","uv","isVector4","setZ","setW","applyMatrix4","setAxisAngleFromQuaternion","acos","setAxisAngleFromRotationMatrix","epsilon","epsilon2","m11","m12","m13","m21","m22","m23","m31","m32","m33","xx","yy","zz","xy","xz","yz","getZ","getW","isWebGLRenderTarget","setSize","slerp","qa","qb","qm","slerpFlat","dst","dstOffset","src0","srcOffset0","src1","srcOffset1","x0","y0","z0","w0","x1","y1","z1","w1","dir","sqrSin","Number","EPSILON","len","tDir","multiplyQuaternionsFlat","_onChangeCallback","isQuaternion","quaternion","setFromEuler","euler","update","isEuler","c1","c3","s1","s3","setFromAxisAngle","axis","halfAngle","setFromRotationMatrix","trace","setFromUnitVectors","vFrom","vTo","angleTo","rotateTowards","step","inverse","conjugate","p","multiplyQuaternions","qax","qay","qaz","qaw","qbx","qby","qbz","qbw","cosHalfTheta","sqrSinHalfTheta","sinHalfTheta","halfTheta","ratioA","ratioB","_onChange","callback","_vector","Vector3","_quaternion","isVector3","multiplyVectors","applyEuler","applyQuaternion","applyAxisAngle","applyNormalMatrix","qx","qy","qz","qw","ix","iy","iz","iw","project","camera","matrixWorldInverse","projectionMatrix","unproject","projectionMatrixInverse","matrixWorld","transformDirection","crossVectors","ax","ay","az","bx","by","bz","projectOnVector","denominator","projectOnPlane","planeNormal","reflect","normal","dz","setFromSpherical","setFromSphericalCoords","radius","phi","sinPhiRadius","setFromCylindrical","setFromCylindricalCoords","setFromMatrixPosition","setFromMatrixScale","setFromMatrixColumn","sz","_v1","_m1","Matrix4","_zero","_one","isMatrix4","n14","n24","n34","n41","n42","n43","n44","copyPosition","makeBasis","extractRotation","scaleX","scaleY","scaleZ","makeRotationFromEuler","af","bf","ce","cf","de","df","ac","ad","bc","bd","makeRotationFromQuaternion","compose","lookAt","eye","up","a14","a24","a34","a41","a42","a43","a44","b14","b24","b34","b41","b42","b43","b44","setPosition","t14","getMaxScaleOnAxis","scaleXSq","scaleYSq","scaleZSq","makeTranslation","makeRotationX","makeRotationY","makeRotationZ","makeRotationAxis","makeScale","makeShear","position","x2","y2","z2","wx","wy","wz","decompose","invSX","invSY","invSZ","makePerspective","left","right","top","bottom","near","far","makeOrthographic","_matrix","Euler","DefaultOrder","_order","Layers","mask","RotationOrders","asin","setFromQuaternion","setFromVector3","reorder","newOrder","toVector3","optionalResult","channel","enable","enableAll","toggle","disable","disableAll","layers","_object3DId","_q1","_target","_position","_scale","_xAxis","_yAxis","_zAxis","_addedEvent","_removedEvent","Object3D","parent","children","DefaultUp","configurable","enumerable","modelViewMatrix","normalMatrix","DefaultMatrixAutoUpdate","matrixWorldNeedsUpdate","visible","castShadow","receiveShadow","frustumCulled","renderOrder","userData","Scene","background","environment","fog","overrideMaterial","autoUpdate","__THREE_DEVTOOLS__","CustomEvent","detail","isObject3D","onBeforeRender","onAfterRender","setRotationFromAxisAngle","setRotationFromEuler","setRotationFromMatrix","setRotationFromQuaternion","rotateOnAxis","rotateOnWorldAxis","rotateX","rotateY","rotateZ","translateOnAxis","distance","translateX","translateY","translateZ","localToWorld","vector","worldToLocal","updateWorldMatrix","isCamera","isLight","object","remove","attach","getObjectById","id","getObjectByProperty","getObjectByName","getWorldPosition","updateMatrixWorld","getWorldQuaternion","getWorldScale","getWorldDirection","raycast","traverse","traverseVisible","traverseAncestors","force","updateParents","updateChildren","geometries","materials","shapes","serialize","library","element","JSON","stringify","isInstancedMesh","count","instanceMatrix","isMesh","isLine","isPoints","geometry","parameters","shape","material","uuids","extractFromCache","cache","values","key","data","recursive","parse","child","isScene","_points","_box","Box3","_v0","_v2","_f0","_f1","_f2","_center","_extents","_triangleNormal","_testAxis","Infinity","satForAxes","axes","v0","extents","j","p0","p1","p2","isBox3","setFromArray","minX","minY","minZ","maxX","maxY","maxZ","setFromBufferAttribute","setFromPoints","points","makeEmpty","il","expandByPoint","setFromCenterAndSize","size","halfSize","setFromObject","expandByObject","box","isEmpty","getCenter","getSize","point","expandByVector","expandByScalar","boundingBox","computeBoundingBox","union","containsPoint","containsBox","getParameter","intersectsBox","intersectsSphere","sphere","clampPoint","intersectsPlane","plane","constant","intersectsTriangle","triangle","distanceToPoint","getBoundingSphere","intersect","Sphere","optionalCenter","maxRadiusSq","radiusSum","deltaLengthSq","getBoundingBox","_segCenter","_segDir","_diff","_edge1","_edge2","_normal","Ray","origin","direction","ray","at","recast","closestPointToPoint","directionDistance","distanceSqToPoint","distanceSqToSegment","optionalPointOnRay","optionalPointOnSegment","segExtent","a01","b0","s0","sqrDist","extDet","invDet","intersectSphere","tca","radius2","thc","t0","t1","distanceToPlane","intersectPlane","distToPoint","intersectBox","tmin","tmax","tymin","tymax","tzmin","tzmax","invdirx","invdiry","invdirz","intersectTriangle","backfaceCulling","sign","DdN","DdQxE2","DdE1xQ","QdN","_vector1","_vector2","_normalMatrix","Plane","isPlane","setComponents","setFromNormalAndCoplanarPoint","setFromCoplanarPoints","inverseNormalLength","distanceToSphere","projectPoint","intersectLine","line","delta","start","intersectsLine","startSign","endSign","end","coplanarPoint","optionalNormalMatrix","referencePoint","_v3","_vab","_vac","_vbc","_vap","_vbp","_vcp","Triangle","getNormal","targetLengthSq","getBarycoord","dot00","dot01","dot02","dot11","dot12","denom","invDenom","u","getUV","p3","uv1","uv2","uv3","isFrontFacing","setFromPointsAndIndices","i0","i1","i2","getArea","getMidpoint","getPlane","d4","vc","d5","d6","vb","va","_colorKeywords","aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen","_hslA","_hslB","Color","setRGB","hue2rgb","SRGBToLinear","LinearToSRGB","Face3","color","materialIndex","vertexNormals","isColor","vertexColors","setHex","setStyle","hex","setHSL","style","handleAlpha","string","parseFloat","exec","components","parseInt","charAt","setColorName","copyGammaToLinear","gammaFactor","copyLinearToGamma","safeInverse","convertGammaToLinear","convertLinearToGamma","copySRGBToLinear","copyLinearToSRGB","convertSRGBToLinear","convertLinearToSRGB","getHex","getHexString","getHSL","hue","saturation","lightness","getStyle","offsetHSL","addColors","color1","color2","lerpHSL","normalized","NAMES","materialId","Material","blending","side","flatShading","opacity","transparent","blendSrc","blendDst","blendEquation","blendSrcAlpha","blendDstAlpha","blendEquationAlpha","depthFunc","depthTest","depthWrite","stencilWriteMask","stencilFunc","stencilRef","stencilFuncMask","stencilFail","stencilZFail","stencilZPass","stencilWrite","clippingPlanes","clipIntersection","clipShadows","shadowSide","colorWrite","precision","polygonOffset","polygonOffsetFactor","polygonOffsetUnits","dithering","alphaTest","premultipliedAlpha","toneMapped","MeshBasicMaterial","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","specularMap","alphaMap","envMap","combine","reflectivity","refractionRatio","wireframe","wireframeLinewidth","wireframeLinecap","wireframeLinejoin","skinning","morphTargets","setValues","isMaterial","onBeforeCompile","customProgramCacheKey","newValue","currentValue","isRoot","roughness","metalness","sheen","emissive","emissiveIntensity","specular","shininess","clearcoat","clearcoatRoughness","clearcoatMap","clearcoatRoughnessMap","clearcoatNormalMap","clearcoatNormalScale","matcap","bumpMap","bumpScale","normalMap","normalMapType","normalScale","displacementMap","displacementScale","displacementBias","roughnessMap","metalnessMap","emissiveMap","envMapIntensity","gradientMap","sizeAttenuation","linewidth","dashSize","gapSize","morphNormals","srcPlanes","dstPlanes","isMeshBasicMaterial","BufferAttribute","itemSize","TypeError","usage","updateRange","Int8BufferAttribute","Int8Array","Uint8BufferAttribute","Uint8Array","Uint8ClampedBufferAttribute","Uint8ClampedArray","Int16BufferAttribute","Int16Array","Uint16BufferAttribute","Uint16Array","Int32BufferAttribute","Int32Array","Uint32BufferAttribute","Uint32Array","Float32BufferAttribute","Float32Array","Float64BufferAttribute","Float64Array","DirectGeometry","vertices","normals","colors","uvs","uvs2","groups","skinWeights","skinIndices","boundingSphere","verticesNeedUpdate","normalsNeedUpdate","colorsNeedUpdate","uvsNeedUpdate","groupsNeedUpdate","arrayMax","isBufferAttribute","onUploadCallback","setUsage","copyAt","index1","index2","copyArray","copyColorsArray","copyVector2sArray","vectors","copyVector3sArray","copyVector4sArray","setXY","setXYZ","setXYZW","onUpload","computeGroups","group","faces","face","fromGeometry","faceVertexUvs","hasFaceVertexUv","hasFaceVertexUv2","morphTargetsLength","morphTargetsPosition","morphNormalsLength","morphTargetsNormal","hasSkinIndices","hasSkinWeights","vertexUvs","morphTarget","morphNormal","_bufferGeometryId","_obj","_offset","_boxMorphTargets","BufferGeometry","attributes","morphAttributes","morphTargetsRelative","drawRange","isBufferGeometry","getIndex","setIndex","getAttribute","setAttribute","deleteAttribute","addGroup","clearGroups","setDrawRange","needsUpdate","tangent","computeBoundingSphere","positions","lineDistances","isGeometry","updateFromObject","direct","__directGeometry","elementsNeedUpdate","lineDistancesNeedUpdate","lineDistance","fromDirectGeometry","morphAttributesPosition","morphAttribute","isNaN","jl","computeFaceNormals","computeVertexNormals","positionAttribute","normalAttribute","pA","pB","pC","nA","nB","nC","cb","ab","vA","vB","vC","normalizeNormals","merge","attributeArray1","attribute2","attributeArray2","attributeOffset","toNonIndexed","convertBufferAttribute","indices","array2","geometry2","newAttribute","morphArray","keys","attributeData","hasMorphAttributes","attributeArray","_inverseMatrix","_ray","_sphere","_vA","_vB","_vC","_tempA","_tempB","_tempC","_morphA","_morphB","_morphC","_uvA","_uvB","_uvC","_intersectionPoint","_intersectionPointWorld","Mesh","updateMorphTargets","checkIntersection","raycaster","checkBufferGeometryIntersection","morphPosition","morphInfluences","morphTargetInfluences","influence","isSkinnedMesh","boneTransform","intersection","morphTargetDictionary","ml","String","intersects","groupMaterial","faceIndex","isMultiMaterial","fl","faceMaterial","fvA","fvB","fvC","uvs_f","_geometryId","Geometry","fromBufferGeometry","scope","addFace","areaWeighted","vl","computeFlatVertexNormals","computeMorphNormals","__originalFaceNormal","__originalVertexNormals","tmpGeo","faceNormals","dstNormalsFace","dstNormalsVertex","faceNormal","materialIndexOffset","vertexOffset","vertices1","vertices2","faces1","faces2","colors1","colors2","vertexCopy","faceCopy","faceVertexNormals","faceVertexColors","faceVertexUvs2","uvsCopy","k","kl","mergeMesh","mesh","mergeVertices","verticesMap","unique","changes","faceIndicesToRemove","idx","diff","sortFacesByMaterialIndex","_id","sort","uvs1","newUvs1","newUvs2","vertex","normalsHash","colorsHash","uvsHash","hasMaterial","hasFaceUv","hasFaceNormal","hasFaceVertexNormal","hasFaceColor","hasFaceVertexColor","faceType","setBit","getUvIndex","getNormalIndex","getColorIndex","enabled","hash","srcVertexNormal","destVertexNormal","BoxBufferGeometry","depth","widthSegments","heightSegments","depthSegments","super","numberOfVertices","groupStart","buildPlane","udir","vdir","gridX","gridY","segmentWidth","segmentHeight","widthHalf","heightHalf","depthHalf","gridX1","gridY1","vertexCounter","groupCount","cloneUniforms","property","mergeUniforms","uniforms","merged","UniformsUtils","default_vertex","default_fragment","ShaderMaterial","defines","vertexShader","fragmentShader","lights","clipping","extensions","derivatives","fragDepth","drawBuffers","shaderTextureLOD","defaultAttributeValues","index0AttributeName","uniformsNeedUpdate","Camera","PerspectiveCamera","fov","aspect","zoom","focus","view","filmGauge","filmOffset","updateProjectionMatrix","DataTexture","isShaderMaterial","isPerspectiveCamera","setFocalLength","focalLength","vExtentSlope","getFilmHeight","atan","getFocalLength","getEffectiveFOV","getFilmWidth","setViewOffset","fullWidth","fullHeight","offsetX","offsetY","clearViewOffset","skew","isDataTexture","Frustum","p4","p5","planes","frustum","setFromProjectionMatrix","me0","me1","me2","me3","me4","me5","me6","me7","me8","me9","me10","me11","me12","me13","me14","me15","intersectsObject","intersectsSprite","sprite","negRadius","UniformsLib","common","diffuse","uvTransform","uv2Transform","specularmap","envmap","flipEnvMap","maxMipLevel","aomap","lightmap","emissivemap","bumpmap","normalmap","displacementmap","roughnessmap","metalnessmap","gradientmap","fogDensity","fogNear","fogFar","fogColor","ambientLightColor","lightProbe","directionalLights","properties","directionalLightShadows","shadowBias","shadowNormalBias","shadowRadius","shadowMapSize","directionalShadowMap","directionalShadowMatrix","spotLights","coneCos","penumbraCos","decay","spotLightShadows","spotShadowMap","spotShadowMatrix","pointLights","pointLightShadows","shadowCameraNear","shadowCameraFar","pointShadowMap","pointShadowMatrix","hemisphereLights","skyColor","groundColor","rectAreaLights","WebGLAnimation","isAnimating","animationLoop","requestId","onAnimationFrame","time","frame","requestAnimationFrame","stop","cancelAnimationFrame","setAnimationLoop","setContext","WebGLAttributes","gl","capabilities","isWebGL2","buffers","WeakMap","isInterleavedBufferAttribute","deleteBuffer","buffer","delete","bufferType","createBuffer","bindBuffer","bufferData","bytesPerElement","BYTES_PER_ELEMENT","bufferSubData","subarray","updateBuffer","PlaneGeometry","PlaneBufferGeometry","width_half","height_half","segment_width","segment_height","ShaderChunk","alphamap_fragment","alphamap_pars_fragment","alphatest_fragment","aomap_fragment","aomap_pars_fragment","begin_vertex","beginnormal_vertex","bsdfs","bumpmap_pars_fragment","clipping_planes_fragment","clipping_planes_pars_fragment","clipping_planes_pars_vertex","clipping_planes_vertex","color_fragment","color_pars_fragment","color_pars_vertex","color_vertex","cube_uv_reflection_fragment","defaultnormal_vertex","displacementmap_pars_vertex","displacementmap_vertex","emissivemap_fragment","emissivemap_pars_fragment","encodings_fragment","encodings_pars_fragment","envmap_fragment","envmap_common_pars_fragment","envmap_pars_fragment","envmap_pars_vertex","envmap_physical_pars_fragment","envmap_vertex","fog_vertex","fog_pars_vertex","fog_fragment","fog_pars_fragment","gradientmap_pars_fragment","lightmap_fragment","lightmap_pars_fragment","lights_lambert_vertex","lights_pars_begin","lights_toon_fragment","lights_toon_pars_fragment","lights_phong_fragment","lights_phong_pars_fragment","lights_physical_fragment","lights_physical_pars_fragment","lights_fragment_begin","lights_fragment_maps","lights_fragment_end","logdepthbuf_fragment","logdepthbuf_pars_fragment","logdepthbuf_pars_vertex","logdepthbuf_vertex","map_fragment","map_pars_fragment","map_particle_fragment","map_particle_pars_fragment","metalnessmap_fragment","metalnessmap_pars_fragment","morphnormal_vertex","morphtarget_pars_vertex","morphtarget_vertex","normal_fragment_begin","normal_fragment_maps","normalmap_pars_fragment","clearcoat_normal_fragment_begin","clearcoat_normal_fragment_maps","clearcoat_pars_fragment","packing","premultiplied_alpha_fragment","project_vertex","dithering_fragment","dithering_pars_fragment","roughnessmap_fragment","roughnessmap_pars_fragment","shadowmap_pars_fragment","shadowmap_pars_vertex","shadowmap_vertex","shadowmask_pars_fragment","skinbase_vertex","skinning_pars_vertex","skinning_vertex","skinnormal_vertex","specularmap_fragment","specularmap_pars_fragment","tonemapping_fragment","tonemapping_pars_fragment","uv_pars_fragment","uv_pars_vertex","uv_vertex","uv2_pars_fragment","uv2_pars_vertex","uv2_vertex","worldpos_vertex","background_frag","background_vert","cube_frag","cube_vert","depth_frag","depth_vert","distanceRGBA_frag","distanceRGBA_vert","equirect_frag","equirect_vert","linedashed_frag","linedashed_vert","meshbasic_frag","meshbasic_vert","meshlambert_frag","meshlambert_vert","meshmatcap_frag","meshmatcap_vert","meshtoon_frag","meshtoon_vert","meshphong_frag","meshphong_vert","meshphysical_frag","meshphysical_vert","normal_frag","normal_vert","points_frag","points_vert","shadow_frag","shadow_vert","sprite_frag","sprite_vert","ShaderLib","basic","lambert","phong","standard","toon","dashed","totalSize","t2D","cube","equirect","tEquirect","distanceRGBA","referencePosition","nearDistance","farDistance","shadow","WebGLBackground","renderer","state","objects","clearColor","planeMesh","boxMesh","clearAlpha","currentBackground","currentBackgroundVersion","currentTonemapping","setClear","getClearColor","setClearColor","getClearAlpha","setClearAlpha","render","renderList","scene","forceClear","xr","session","getSession","environmentBlendMode","autoClear","clear","autoClearColor","autoClearDepth","autoClearStencil","isCubeTexture","isWebGLCubeRenderTarget","toneMapping","unshift","WebGLBindingStates","maxVertexAttributes","extension","vaoAvailable","bindingStates","defaultState","createBindingState","currentState","bindVertexArrayObject","vao","bindVertexArray","bindVertexArrayOES","deleteVertexArrayObject","deleteVertexArray","deleteVertexArrayOES","newAttributes","enabledAttributes","attributeDivisors","program","initAttributes","enableAttribute","enableAttributeAndDivisor","meshPerAttribute","enableVertexAttribArray","disableUnusedAttributes","disableVertexAttribArray","vertexAttribPointer","stride","vertexAttribIPointer","reset","resetDefaultState","setup","updateBuffers","programMap","stateMap","createVertexArray","createVertexArrayOES","getBindingState","cachedAttributes","geometryAttributes","cachedAttribute","geometryAttribute","saveCache","isInstancedBufferGeometry","programAttributes","getAttributes","materialDefaultAttributeValues","programAttribute","isInstancedInterleavedBuffer","_maxInstanceCount","isInstancedBufferAttribute","vertexAttrib2fv","vertexAttrib3fv","vertexAttrib4fv","vertexAttrib1fv","setupVertexAttributes","geometryId","programId","releaseStatesOfGeometry","releaseStatesOfProgram","WebGLBufferRenderer","info","mode","setMode","drawArrays","renderInstances","primcount","methodName","WebGLCapabilities","maxAnisotropy","getMaxPrecision","getShaderPrecisionFormat","WebGL2RenderingContext","WebGL2ComputeRenderingContext","maxPrecision","logarithmicDepthBuffer","maxTextures","maxVertexTextures","maxTextureSize","maxCubemapSize","maxAttributes","maxVertexUniforms","maxVaryings","maxFragmentUniforms","vertexTextures","floatFragmentTextures","getMaxAnisotropy","MAX_TEXTURE_MAX_ANISOTROPY_EXT","floatVertexTextures","maxSamples","WebGLClipping","globalState","numGlobalPlanes","localClippingEnabled","renderingShadows","viewNormalMatrix","uniform","resetGlobalState","numPlanes","numIntersection","projectPlanes","skipTransform","nPlanes","dstArray","flatSize","viewMatrix","i4","init","enableLocalClipping","beginShadows","endShadows","setState","fromCache","nGlobal","lGlobal","clippingState","WebGLExtensions","getExtension","WebGLGeometries","wireframeAttributes","onGeometryDispose","buffergeometry","memory","updateWireframeAttribute","geometryIndex","geometryPosition","previousAttribute","_bufferGeometry","getWireframeAttribute","currentAttribute","WebGLIndexedBufferRenderer","drawElements","WebGLInfo","calls","triangles","lines","programs","autoReset","instanceCount","numericalSort","absNumericalSort","WebGLMorphtargets","influencesList","workInfluences","objectInfluences","influences","MAX_SAFE_INTEGER","morphInfluencesSum","morphBaseInfluence","getUniforms","setValue","WebGLObjects","updateMap","CubeTexture","DataTexture2DArray","wrapR","DataTexture3D","physical","transparency","isDataTexture2DArray","isDataTexture3D","emptyTexture","emptyTexture2dArray","emptyTexture3d","emptyCubeTexture","arrayCacheF32","arrayCacheI32","mat4array","mat3array","mat2array","flatten","nBlocks","blockSize","firstElem","arraysEqual","allocTexUnits","allocateTextureUnit","setValueV1f","uniform1f","addr","setValueV2f","uniform2f","uniform2fv","setValueV3f","uniform3f","uniform3fv","setValueV4f","uniform4f","uniform4fv","setValueM2","uniformMatrix2fv","setValueM3","uniformMatrix3fv","setValueM4","uniformMatrix4fv","setValueT1","unit","uniform1i","safeSetTexture2D","setValueT2DArray1","setTexture2DArray","setValueT3D1","setTexture3D","setValueT6","safeSetTextureCube","setValueV1i","setValueV2i","uniform2iv","setValueV3i","uniform3iv","setValueV4i","uniform4iv","setValueV1ui","uniform1ui","setValueV1fArray","uniform1fv","setValueV1iArray","uniform1iv","setValueV2iArray","setValueV3iArray","setValueV4iArray","setValueV2fArray","setValueV3fArray","setValueV4fArray","setValueM2Array","setValueM3Array","setValueM4Array","setValueT1Array","units","setValueT6Array","SingleUniform","activeInfo","getSingularSetter","PureArrayUniform","getPureArraySetter","StructuredUniform","seq","updateCache","RePathPart","addUniform","container","uniformObject","parseUniform","path","pathLength","lastIndex","match","matchEnd","idIsIndex","subscript","next","WebGLUniforms","getProgramParameter","getActiveUniform","getUniformLocation","WebGLShader","shader","createShader","shaderSource","compileShader","setOptional","upload","seqWithValue","programIdCount","getEncodingComponents","getShaderErrors","status","getShaderParameter","getShaderInfoLog","trim","split","join","addLineNumbers","getShaderSource","getTexelDecodingFunction","functionName","getTexelEncodingFunction","getToneMappingFunction","toneMappingName","filterEmptyLine","replaceLightNums","replace","numDirLights","numSpotLights","numRectAreaLights","numPointLights","numHemiLights","numDirLightShadows","numSpotLightShadows","numPointLightShadows","replaceClippingPlaneNums","numClippingPlanes","numClipIntersection","includePattern","resolveIncludes","includeReplacer","include","deprecatedUnrollLoopPattern","unrollLoopPattern","unrollLoops","loopReplacer","deprecatedLoopReplacer","snippet","generatePrecision","precisionstring","WebGLProgram","cacheKey","shadowMapTypeDefine","shadowMapType","generateShadowMapTypeDefine","envMapTypeDefine","envMapMode","generateEnvMapTypeDefine","envMapModeDefine","generateEnvMapModeDefine","envMapBlendingDefine","generateEnvMapBlendingDefine","gammaFactorDefine","customExtensions","extensionDerivatives","envMapCubeUV","tangentSpaceNormalMap","shaderID","extensionFragDepth","rendererExtensionFragDepth","extensionDrawBuffers","rendererExtensionDrawBuffers","extensionShaderTextureLOD","rendererExtensionShaderTextureLod","filter","generateExtensions","customDefines","chunks","generateDefines","createProgram","prefixVertex","prefixFragment","isRawShaderMaterial","shaderName","instancing","supportsVertexTextures","maxBones","useFog","fogExp2","objectSpaceNormalMap","vertexTangents","uvsVertexOnly","useVertexTexture","doubleSided","flipSided","shadowMapEnabled","physicallyCorrectLights","mapEncoding","matcapEncoding","envMapEncoding","emissiveMapEncoding","lightMapEncoding","outputEncoding","depthPacking","isGLSL3ShaderMaterial","versionRegex","fragmentGlsl","glVertexShader","glFragmentShader","attachShader","bindAttribLocation","linkProgram","debug","checkShaderErrors","programLog","getProgramInfoLog","vertexLog","fragmentLog","runnable","haveDiagnostics","vertexErrors","fragmentErrors","getError","diagnostics","prefix","cachedUniforms","deleteShader","getActiveAttrib","getAttribLocation","fetchAttributeLocations","destroy","deleteProgram","usedTimes","WebGLPrograms","shaderIDs","MeshDepthMaterial","MeshDistanceMaterial","MeshNormalMaterial","MeshLambertMaterial","MeshPhongMaterial","MeshToonMaterial","MeshStandardMaterial","MeshPhysicalMaterial","MeshMatcapMaterial","LineBasicMaterial","LineDashedMaterial","PointsMaterial","ShadowMaterial","SpriteMaterial","parameterNames","getTextureEncodingFromMap","getParameters","shadows","nClipPlanes","nClipIntersection","isMeshStandardMaterial","bones","skeleton","nVertexUniforms","nVertexMatrices","allocateBones","shaderobject","getShaderObject","currentRenderTarget","getRenderTarget","isFogExp2","maxMorphTargets","maxMorphNormals","directional","spot","rectArea","hemi","shadowMap","getProgramCacheKey","acquireProgram","pl","preexistingProgram","releaseProgram","pop","WebGLProperties","painterSortStable","groupOrder","reversePainterSortStable","WebGLRenderList","renderItems","renderItemsIndex","opaque","defaultProgram","getNextRenderItem","renderItem","finish","customOpaqueSort","customTransparentSort","WebGLRenderLists","lists","onSceneDispose","cameras","list","UniformsCache","light","halfWidth","halfHeight","nextVersion","shadowCastingLightsFirst","lightA","lightB","WebGLLights","shadowCache","ShadowUniformsCache","directionalLength","pointLength","spotLength","rectAreaLength","hemiLength","numDirectionalShadows","numPointShadows","numSpotShadows","ambient","probe","directionalShadow","spotShadow","pointShadow","vector3","matrix42","intensity","isAmbientLight","isLightProbe","sh","coefficients","isDirectionalLight","shadowUniforms","bias","normalBias","mapSize","isSpotLight","penumbra","isRectAreaLight","isPointLight","isHemisphereLight","WebGLRenderState","lightsArray","shadowsArray","setupLights","pushLight","pushShadow","shadowLight","WebGLRenderStates","renderStates","renderState","has","isMeshDepthMaterial","isMeshDistanceMaterial","vsm_frag","vsm_vert","WebGLShadowMap","_renderer","_objects","_frustum","_shadowMapSize","_viewportSize","_viewport","_depthMaterials","_distanceMaterials","_materialCache","shadowMaterialVertical","SAMPLE_RATE","HALF_SAMPLE_RATE","shadow_pass","resolution","shadowMaterialHorizonal","HORIZONAL_PASS","fullScreenTri","fullScreenMesh","VSMPass","setRenderTarget","mapPass","renderBufferDirect","getDepthMaterialVariant","useMorphing","useSkinning","useInstancing","getDistanceMaterialVariant","getDepthMaterial","result","getMaterialVariant","customMaterial","customDepthMaterial","customDistanceMaterial","keyA","keyB","materialsForVariant","cachedMaterial","renderObject","shadowCamera","depthMaterial","activeCubeFace","getActiveCubeFace","activeMipmapLevel","getActiveMipmapLevel","_state","setBlending","setTest","setScissorTest","shadowFrameExtents","getFrameExtents","isPointLightShadow","pars","viewportCount","getViewportCount","vp","getViewport","updateMatrices","getFrustum","WebGLState","colorBuffer","locked","currentColorMask","currentColorClear","setMask","colorMask","setLocked","lock","currentDepthMask","currentDepthFunc","currentDepthClear","depthMask","setFunc","clearDepth","currentStencilMask","currentStencilFunc","currentStencilRef","currentStencilFuncMask","currentStencilFail","currentStencilZFail","currentStencilZPass","currentStencilClear","stencilTest","stencilMask","setOp","stencilOp","stencil","clearStencil","enabledCapabilities","currentProgram","currentBlendingEnabled","currentBlending","currentBlendEquation","currentBlendSrc","currentBlendDst","currentBlendEquationAlpha","currentBlendSrcAlpha","currentBlendDstAlpha","currentPremultipledAlpha","currentFlipSided","currentCullFace","currentLineWidth","currentPolygonOffsetFactor","currentPolygonOffsetUnits","lineWidthAvailable","glVersion","currentTextureSlot","currentBoundTextures","currentScissor","currentViewport","createTexture","bindTexture","texParameteri","texImage2D","emptyTextures","setFlipSided","setCullFace","equationToGL","MIN_EXT","MAX_EXT","factorToGL","blendEquationSeparate","blendFuncSeparate","blendFunc","frontFace","cullFace","setPolygonOffset","factor","activeTexture","webglSlot","useProgram","setMaterial","frontFaceCW","setLineWidth","lineWidth","webglType","webglTexture","boundTexture","unbindTexture","compressedTexImage2D","apply","texImage3D","WebGLTextures","_gl","utils","_videoTextures","useOffscreenCanvas","OffscreenCanvas","err","createCanvas","resizeImage","needsPowerOfTwo","needsNewCanvas","maxSize","HTMLImageElement","ImageBitmap","textureNeedsGenerateMipmaps","supportsMips","generateMipmap","__maxMipLevel","LOG2E","getInternalFormat","internalFormatName","glFormat","glType","filterFallback","onTextureDispose","textureProperties","__webglInit","deleteTexture","__webglTexture","deallocateTexture","isVideoTexture","onRenderTargetDispose","renderTarget","renderTargetProperties","deleteFramebuffer","__webglFramebuffer","__webglDepthbuffer","deleteRenderbuffer","__webglMultisampledFramebuffer","__webglColorRenderbuffer","__webglDepthRenderbuffer","deallocateRenderTarget","textureUnits","setTexture2D","slot","updateVideoTexture","__version","complete","uploadTexture","setTextureCube","initTexture","pixelStorei","isCompressed","isCompressedTexture","cubeImage","convert","glInternalFormat","setTextureParameters","mipmap","mipmapImage","setTextureCubeDynamic","wrappingToGL","filterToGL","textureType","__currentAnisotropy","texParameterf","TEXTURE_MAX_ANISOTROPY_EXT","textureNeedsPowerOfTwo","isDepthTexture","setupFrameBufferTexture","framebuffer","attachment","textureTarget","bindFramebuffer","framebufferTexture2D","setupRenderBufferStorage","renderbuffer","isMultisample","bindRenderbuffer","samples","getRenderTargetSamples","renderbufferStorageMultisample","renderbufferStorage","framebufferRenderbuffer","setupDepthRenderbuffer","isCube","webglDepthTexture","setupDepthTexture","createRenderbuffer","isWebGLMultisampleRenderTarget","warnedTexture2D","warnedTextureCube","textureUnit","resetTextureUnits","setupRenderTarget","createFramebuffer","updateRenderTargetMipmap","updateMultisampleRenderTarget","blitFramebuffer","WebGLUtils","HALF_FLOAT_OES","COMPRESSED_RGB_S3TC_DXT1_EXT","COMPRESSED_RGBA_S3TC_DXT1_EXT","COMPRESSED_RGBA_S3TC_DXT3_EXT","COMPRESSED_RGBA_S3TC_DXT5_EXT","COMPRESSED_RGB_PVRTC_4BPPV1_IMG","COMPRESSED_RGB_PVRTC_2BPPV1_IMG","COMPRESSED_RGBA_PVRTC_4BPPV1_IMG","COMPRESSED_RGBA_PVRTC_2BPPV1_IMG","COMPRESSED_RGB_ETC1_WEBGL","COMPRESSED_RGB8_ETC2","COMPRESSED_RGBA8_ETC2_EAC","UNSIGNED_INT_24_8_WEBGL","ArrayCamera","Group","WebXRController","_targetRay","_grip","WebXRManager","framebufferScaleFactor","referenceSpace","referenceSpaceType","pose","controllers","inputSourcesMap","Map","cameraL","cameraR","cameraVR","_currentDepthNear","_currentDepthFar","onSessionEvent","controller","inputSource","onSessionEnd","forEach","disconnect","setFramebuffer","animation","isPresenting","onRequestReferenceSpace","updateInputSources","inputSources","removed","added","getController","getTargetRaySpace","getControllerGrip","getGripSpace","setFramebufferScaleFactor","setReferenceSpaceType","getReferenceSpace","setSession","getContextAttributes","xrCompatible","makeXRCompatible","layerInit","antialias","baseLayer","XRWebGLLayer","updateRenderState","requestReferenceSpace","then","cameraLPos","cameraRPos","updateCamera","getCamera","depthNear","depthFar","ipd","projL","projR","topFov","bottomFov","leftFov","rightFov","zOffset","xOffset","near2","far2","left2","right2","top2","bottom2","setProjectionFromUnion","onAnimationFrameCallback","getViewerPose","views","cameraVRNeedsUpdate","transform","WebGLMaterials","refreshUniformsCommon","uvScaleMap","uv2ScaleMap","refreshUniformsStandard","refreshFogUniforms","isFog","density","refreshMaterialUniforms","pixelRatio","isMeshLambertMaterial","refreshUniformsLambert","isMeshToonMaterial","refreshUniformsToon","isMeshPhongMaterial","refreshUniformsPhong","isMeshPhysicalMaterial","refreshUniformsPhysical","isMeshMatcapMaterial","refreshUniformsMatcap","refreshUniformsDepth","refreshUniformsDistance","isMeshNormalMaterial","refreshUniformsNormal","isLineBasicMaterial","refreshUniformsLine","isLineDashedMaterial","refreshUniformsDash","isPointsMaterial","refreshUniformsPoints","isSpriteMaterial","refreshUniformsSprites","isShadowMaterial","WebGLRenderer","_context","_alpha","_depth","_stencil","_antialias","_premultipliedAlpha","_preserveDrawingBuffer","preserveDrawingBuffer","_powerPreference","powerPreference","_failIfMajorPerformanceCaveat","failIfMajorPerformanceCaveat","currentRenderList","currentRenderState","domElement","sortObjects","toneMappingExposure","_this","_isContextLost","_framebuffer","_currentActiveCubeFace","_currentActiveMipmapLevel","_currentRenderTarget","_currentFramebuffer","_currentMaterialId","_currentCamera","_currentArrayCamera","_currentViewport","_currentScissor","_currentScissorTest","_width","_height","_pixelRatio","_opaqueSort","_transparentSort","_scissor","_scissorTest","_clipping","_clippingEnabled","_localClippingEnabled","_projScreenMatrix","_vector3","_emptyScene","getTargetPixelRatio","programCache","renderLists","morphtargets","bufferRenderer","indexedBufferRenderer","contextNames","contextAttributes","contextName","onContextLost","onContextRestore","isWebGL1Renderer","shift","rangeMin","rangeMax","message","initGLContext","preventDefault","onMaterialDispose","releaseMaterialProgramReference","deallocateMaterial","programInfo","forceContextLoss","loseContext","forceContextRestore","restoreContext","getPixelRatio","setPixelRatio","updateStyle","setViewport","getDrawingBufferSize","setDrawingBufferSize","getCurrentViewport","getScissor","setScissor","getScissorTest","boolean","setOpaqueSort","method","setTransparentSort","bits","renderBufferImmediate","hasPositions","hasNormals","hasUvs","hasColors","setProgram","rangeFactor","dataCount","rangeStart","rangeCount","drawStart","drawEnd","drawCount","isLineSegments","isLineLoop","isSprite","compile","compiled","material2","initMaterial","projectObject","isGroup","isLOD","isImmediateRenderObject","renderObjects","isArrayCamera","camera2","renderObjectImmediate","materialProperties","lightsStateVersion","programCacheKey","programChange","numSupportedMorphTargets","numSupportedMorphNormals","needsLights","materialNeedsLights","progUniforms","uniformsList","useCache","refreshProgram","refreshMaterial","refreshLights","p_uniforms","m_uniforms","uCamPos","cameraPosition","isOrthographicCamera","boneTexture","boneMatrices","boneTextureSize","ltc_1","LTC_1","ltc_2","LTC_2","window","opaqueObjects","transparentObjects","readRenderTargetPixels","activeCubeFaceIndex","restore","textureFormat","checkFramebufferStatus","readPixels","copyFramebufferToTexture","level","levelScale","copyTexImage2D","copyTextureToTexture","srcTexture","dstTexture","texSubImage2D","compressedTexSubImage2D","Fog","linecap","linejoin","inputPose","gripPose","targetRay","grip","getPose","targetRaySpace","gripSpace","_start","_end","Line","computeLineDistances","threshold","params","localThreshold","localThresholdSq","vStart","vEnd","interSegment","interRay","nbVertices","LineSegments","Points","testPoint","rayPointDistanceSq","intersectPoint","distanceToRay","CanvasTexture","PolyhedronGeometry","PolyhedronBufferGeometry","vertexBuffer","uvBuffer","subdivideFace","cols","aj","bj","rows","pushVertex","getVertexByIndex","correctUV","azimuth","subdivide","applyRadius","centroid","uvA","uvB","uvC","azi","correctUVs","correctSeam","generateUVs","TetrahedronGeometry","TetrahedronBufferGeometry","OctahedronGeometry","OctahedronBufferGeometry","IcosahedronGeometry","IcosahedronBufferGeometry","TorusGeometry","tube","radialSegments","tubularSegments","arc","TorusBufferGeometry","CylinderGeometry","radiusTop","radiusBottom","openEnded","thetaStart","thetaLength","CylinderBufferGeometry","indexArray","generateCap","centerIndexStart","centerIndexEnd","cosTheta","sinTheta","slope","indexRow","generateTorso","ConeGeometry","ConeBufferGeometry","Light","LightShadow","_frameExtents","_viewportCount","_viewports","SpotLightShadow","SpotLight","power","OrthographicCamera","AmbientLight","isCanvasTexture","_lightPositionWorld","_lookTarget","shadowMatrix","projScreenMatrix","lookTarget","lightPositionWorld","viewportIndex","isSpotLightShadow","scaleW","scaleH","_eyeRight","_eyeLeft","StereoCamera","eyeSep","_cache","Uniform","getQuery","RegExp","location","search","decodeURIComponent","defaults","defaultValue","createParams","defaultParams","o","updateParams","newParams","getProtocol","protocol","getBrowser","ua","navigator","userAgent","openUrl","open","href","download","downloadName","isSafari","isChromeIos","createElement","str","msSaveOrOpenBlob","FileReader","Blob","reader","onloadend","readAsDataURL","objectUrlCreated","URL","createObjectURL","display","body","appendChild","click","removeChild","revokeObjectURL","lexicographicCompare","elm1","elm2","binarySearchIndexOf","compareFunction","mid","cmp","rangeInSortedArray","indexLeft","leftRange","binarySearchForLeftRange","indexRight","rightRange","binarySearchForRightRange","uniqueArray","sorted","uint8ToString","u8a","chunkSize","fromCharCode","getTypedArray","arrayType","arraySize","getUintArray","sizeOrArray","maxUint","ensureBuffer","ArrayBuffer","_ensureClassFromArray","ensureVector3","ensureMatrix4","ensureQuaternion","ensureFloat32Array","arg","toLowerCaseString","toLowerCase","eyeSepHalf","eyeSepOnProjection","ymax","xmin","xmax","Registry","_dict","names","deg","chars","rnd","spline","tension","t2","LAB_CONSTANTS","PITHIRD","TWOPI","_average_lrgb","_guess_formats","_guess_formats_sorted","_input","_interpolators","bezier","blend","blend_f","brewer","burn","chroma","clip_rgb","cmyk2rgb","css2rgb","darken","dodge","each","hcg2rgb","hex2rgb","hsi2rgb","hsl2css","hsl2rgb","hsv2rgb","interpolate","interpolate_hsx","interpolate_lab","interpolate_lrgb","interpolate_num","interpolate_rgb","lab2lch","lab2rgb","lab_xyz","lch2lab","lch2rgb","lighten","limit","luminance_x","num2rgb","overlay","rgb2cmyk","rgb2css","rgb2hcg","rgb2hex","rgb2hsi","rgb2hsl","rgb2hsv","rgb2lab","rgb2lch","rgb2luminance","rgb2num","rgb2temperature","rgb2xyz","rgb_xyz","screen","temperature2rgb","unpack","w3cx11","xyz_lab","xyz_rgb","classToType","ref","obj","strType","args","rgb","_clipped","_unclipped","func","ctor","module","exports","chk","len1","_rgb","OrRd","PuBu","BuPu","Oranges","BuGn","YlOrBr","YlGn","Reds","RdPu","Greens","YlGnBu","Purples","GnBu","Greys","YlOrRd","PuRd","Blues","PuBuGn","Viridis","Spectral","RdYlGn","RdBu","PiYG","PRGn","RdYlBu","BrBG","RdGy","PuOr","Set2","Accent","Set1","Set3","Dark2","Paired","Pastel2","Pastel1","results","cornflower","laserlemon","lightgoldenrod","maroon2","maroon3","purple2","purple3","Yn","Xn","Zn","Kn","t3","ref1","lab","concat","I","I0","I1","lab0","lab1","lab2","lab3","ref2","cubehelix","rotations","gamma","dh","dl","fract","amp","cos_a","sin_a","code","col1","col2","interpol","res","mix","rgba","lrgb","xyz0","xyz1","xyz","average","A","cnt","first","xyz2","substr","css","channels","hxa","NaN","hsl","ref3","ref4","ref5","hsv","num","_c","_g","hcg","aa","named","L","lch","hcl","reverse","cmyk","luminance","lum","cur_lum","max_iter","lm","kelvin","temp","maxTemp","minTemp","temperature","K","contrast","l1","l2","sum_sq","deltaE","C","L1","L2","c4","delA","delB","delC","h1","sc","sl","v3","modechan","clipped","amount","brighten","darker","brighter","saturate","desaturate","c0","out","analyze","val","MAX_VALUE","sum","domain","limits","_classes","_colorCache","_colors","_correctLightness","_domain","_gamma","_max","_min","_mode","_nacol","_out","_padding","_pos","_spread","_useCache","getClass","getColor","resetCache","setColors","tmap","col","bypassMap","classes","_m","_o","spread","correctLightness","L0","L_actual","L_diff","L_ideal","pol","padding","numColors","dd","dm","nodata","scales","cool","hot","visit","ag","ah","ai","ak","al","am","assignments","best","centroids","cluster","clusterSizes","dist","kClusters","max_log","min_log","mindist","nb_iters","newCentroids","pb","pr","ref10","ref11","ref12","ref13","ref14","ref6","ref7","ref8","ref9","tmpKMeansBreaks","LOG10E","hsi","hue0","hue1","lbv0","lbv1","sat","sat0","sat1","n1","n2","colorSpace","ScaleDefaultParameters","tmpColor","manageColor","_name","descriptor","originalMethod","fromTo","bind","Colormaker","structure","atomProxy","getAtomProxy","getScale","chroma\n .scale","colorToArray","atomColorToArray","atom","atomColor","bondColor","bond","atomIndex1","atomIndex2","bondColorToArray","volumeColorToArray","volumeColor","positionColorToArray","coords","positionColor","kwd","global","SignalBinding","signal","isOnce","listenerContext","priority","_listener","_isOnce","_signal","_priority","validateListener","fnName","Signal","_bindings","_prevParams","self","dispatch","active","execute","paramsArr","handlerReturn","detach","isBound","getListener","getSignal","_destroy","VERSION","memorize","_shouldPropagate","_registerListener","binding","prevIndex","_indexOfListener","_addBinding","cur","addOnce","removeAll","getNumListeners","halt","bindings","forget","signals","SelectAllKeyword","SelectNoneKeyword","AtomOnlyKeywords","BACKBONE","SIDECHAIN","BONDED","RING","AROMATICRING","METAL","POLARH","ChainKeywords","POLYMER","WATER","SmallResname","NucleophilicResname","HydrophobicResname","AromaticResname","AmideResname","AcidicResname","BasicResname","ChargedResname","PolarResname","NonpolarResname","CyclicResname","AliphaticResname","atomTestFn","atomname","altloc","atomindex","keyword","inscode","resname","sstruc","resno","chainname","model","isBackbone","isSidechain","isBonded","isRing","isAromatic","HETERO","isHetero","PROTEIN","isProtein","NUCLEIC","isNucleic","RNA","isRna","DNA","isDna","isPolymer","isWater","HELIX","isHelix","SHEET","isSheet","TURN","isTurn","ION","isIon","SACCHARIDE","isSaccharide","isMetal","isPolarHydrogen","includes","modelIndex","residueTestFn","atomOffset","atomEnd","chainTestFn","entity","modelTestFn","makeTest","selection","fn","rules","subTests","hasOwnProperty","and","operator","na","ret","ALL","NONE","filtered","fs","makeAtomTest","atomOnly","filteredSelection","makeResidueTest","residueOnly","makeChainTest","chainOnly","makeModelTest","modelOnly","Selection","stringChanged","setString","silent","retSelection","newSelection","oldSelection","selectionStack","createNewContext","getPrevContext","pushRule","rule","not","cu","lastRule","indexList","resnameList","sele","substring","chain","negate2","resi","resiSingle","resiRange","parseSele","residueTest","chainTest","modelTest","atomOnlyTest","residueOnlyTest","chainOnlyTest","modelOnlyTest","isAllSelection","isNoneSelection","SelectionColormaker","colormakerList","selectionList","dataList","scheme","ColormakerRegistry","hasScheme","getScheme","ColormakerScales","rainbow","rwb","ColormakerModes","getWorkerDeps","vars","deps","sym","__deps","makeWorkerString","onmessage","__name","postId","__postId","aMessage","transferList","postMessage","makeWorkerBlob","Browser","SupportsPassiveEventHandler","opts","Mobile","orientation","SupportsReadPixelsFloat","setSupportsReadPixelsFloat","ExtensionFragDepth","setExtensionFragDepth","Log","Function","timeEnd","MeasurementDefaultParams","labelColor","labelAttachment","labelSize","labelZOffset","labelYOffset","labelBorder","labelBorderColor","labelBorderWidth","lineOpacity","labelUnit","arcVisible","planeVisible","Debug","ScriptExtensions","WorkerRegistry","activeWorkerCount","_funcDict","_depsDict","_blobDict","schemes","userSchemes","SchemeClass","getSchemes","types","getScales","getModes","addScheme","label","_createScheme","_addUserScheme","removeScheme","_Colormaker","addSelectionScheme","DatasourceRegistry","RepresentationRegistry","ParserRegistry","__hasObjName","objName","parser","__objName","isTrajectory","isStructure","isVolume","isSurface","isBinary","isXml","isJson","getTrajectoryExtensions","getStructureExtensions","getVolumeExtensions","getSurfaceExtensions","ShaderRegistry","DecompressorRegistry","ComponentRegistry","BufferRegistry","PickerRegistry","ListingDatasource","TrajectoryDatasource","Streamer","newline","__pointer","__partialLine","compressed","binary","json","xml","read","_read","decompressFn","_chunk","chunk","peekLines","charCodeAt","chunkToLines","chunkCount","asText","partialLine","isLast","lastIndexOf","str2","nextChunk","nextChunkOfLines","eachChunk","eachChunkOfLines","chunkNo","FileStreamer","Promise","resolve","reject","file","onload","onerror","readAsArrayBuffer","readAsText","NetworkStreamer","xhr","XMLHttpRequest","response","statusText","responseType","send","Loader","ext","streamerParams","File","streamer","ParserLoader","parserParams","voxelSize","firstModelOnly","asTrajectory","cAlphaOnly","delimiter","comment","columnNames","inferBonds","load","Script","functionBody","elementAdded","elementRemoved","nameChanged","run","stage","ScriptLoader","getFileInfo","compressedExtList","queryIndex","query","base","nameSplit","protocolMatch","getDataInfo","datasource","getUrl","getExt","autoLoad","loader","re","not_string","not_bool","not_type","not_primitive","number","numeric_arg","not_json","text","modulo","placeholder","key_access","index_access","sprintf","parse_tree","argv","ph","pad","pad_character","pad_length","is_positive","cursor","tree_length","param_no","toExponential","toFixed","toPrecision","valueOf","pad_char","align","sprintf_format","fmt","sprintf_cache","_fmt","arg_names","SyntaxError","field_list","replacement_field","field_match","sprintf_parse","vsprintf","Writer","getBlob","getData","mimeType","defaultName","defaultExt","charArray","IOBuffer","_mark","_marks","littleEndian","dataIsGiven","byteLength","dvOffset","byteOffset","_lastWrittenByte","_data","DataView","available","isLittleEndian","setLittleEndian","isBigEndian","setBigEndian","skip","seek","mark","pushMark","popMark","rewind","ensureAvailable","newLength","newArray","readBoolean","readUint8","readInt8","getInt8","getUint8","readByte","readBytes","bytes","readInt16","getInt16","readUint16","getUint16","readInt32","getInt32","readUint32","getUint32","readFloat32","getFloat32","readFloat64","getFloat64","readChar","readChars","writeBoolean","writeUint8","writeInt8","setInt8","_updateLastWrittenByte","setUint8","writeByte","writeBytes","writeInt16","setInt16","writeUint16","setUint16","writeInt32","setInt32","writeUint32","setUint32","writeFloat32","setFloat32","writeFloat64","setFloat64","writeChar","writeChars","Counter","countChanged","signalsWrapper.Signal","change","increment","decrement","listen","counter","unlisten","onZeroOnce","Stats","updated","maxDuration","minDuration","avgDuration","lastDuration","prevFpsTime","lastFps","lastFrames","frames","begin","startTime","currentTime","performance","now","reInclude","shaderCache","getShader","definesText","getDefines","shaderText","WebGLRenderingContext","wrcp","_getShaderParameter","_getShaderInfoLog","_getProgramParameter","pname","LINK_STATUS","_getProgramInfoLog","JitterVectors","offsetList","TiledRenderer","viewer","_viewer","_factor","_onProgress","onProgress","_onFinish","onFinish","_n","_ctx","_viewerSampleLevel","sampleLevel","setSampling","_renderTile","_finalize","renderAsync","setTimeout","TwoPI","circularMean","cosMean","sinMean","calculateCenterArray","array1","calculateDirectionArray","uniformArray","optionalTarget","uniformArray3","serialArray","serialBlockArray","replicateArrayEntries","repArr","srcOffset","copyWithin","arrayMin","arraySum","arrayMean","ImageDefaultParameters","makeImage","originalClearAlpha","backgroundColor","setLineWidthAndPixelSize","invert","__seen","trimCanvas","bg","canvasHeight","canvasWidth","pixels","getImageData","doBreak","off","topY","topX","bottomY","bottomX","trimedCanvas","_trimCanvas","finished","tiledRenderer","toBlob","blob","requestRender","modelViewProjectionMatrix","projectionMatrixTranspose","updateCameraUniforms","loadShader","shaderType","COMPILE_STATUS","TextureTestTexCoords","testTextureSupport","vertShader","VERTEX_SHADER","fragShader","FRAGMENT_SHADER","shaders","attribs","locations","attrib","positionLocation","colorLoc","positionBuffer","ARRAY_BUFFER","STATIC_DRAW","FLOAT","whiteTex","whiteData","TEXTURE_2D","RGBA","UNSIGNED_BYTE","tex","TEXTURE_MIN_FILTER","NEAREST","TEXTURE_MAG_FILTER","fb","FRAMEBUFFER","COLOR_ATTACHMENT0","FRAMEBUFFER_COMPLETE","TRIANGLES","COLOR_BUFFER_BIT","pixel","floatPixel","NO_ERROR","INVALID_ENUM","INVALID_VALUE","INVALID_OPERATION","INVALID_FRAMEBUFFER_OPERATION","OUT_OF_MEMORY","CONTEXT_LOST_WEBGL","getErrorDescription","pixelBufferFloat","pixelBufferUint","pixelOrder","tmpMatrix","updateList","objectId","modelViewMatrixInverse","modelViewMatrixInverseTranspose","modelViewProjectionMatrixInverse","pu","Viewer","idOrElement","boundingBoxSize","boundingBoxLength","distVector","ticked","rendered","elm","getElementById","HTMLElement","innerWidth","innerHeight","getBoundingClientRect","overflow","wrapper","_initParams","_initStats","_initCamera","_initScene","_initRenderer","_initHelper","setBackground","setFog","animate","cameraType","cameraFov","cameraEyeSep","cameraZ","clipNear","clipFar","clipDist","clipMode","clipScale","lightColor","lightIntensity","ambientColor","ambientIntensity","rendererEncoding","perspectiveCamera","orthographicCamera","stereoCamera","stats","rotationGroup","translationGroup","modelGroup","pickingGroup","backgroundGroup","helperGroup","spotLight","ambientLight","dpr","devicePixelRatio","innerHTML","supportsHalfFloat","dprWidth","dprHeight","OES_texture_float","OES_texture_half_float","WEBGL_color_buffer_float","pickingTarget","sampleTarget","holdTarget","compositeUniforms","tForeground","compositeMaterial","compositeCamera","compositeScene","bbGeometry","bbMaterial","uColor","boundingBoxMesh","updateHelper","cameraDistance","instanceList","instance","addBuffer","wireframeGroup","pickable","setUserData","getMesh","wireframeMesh","getWireframeMesh","pickingMesh","getPickingMesh","_updateBoundingBox","updateBoundingBox","updateGeometry","geoBoundingBox","updateNode","node","getPickingPixels","imgBuffer","getImage","picking","imgBuffer2","ctx","imgData","setLight","setOutputEncoding","setColorWorkflow","setCamera","updateZoom","setClip","handleResize","updateInfo","rInfo","rMemory","rRender","isStill","currentSampleLevel","renderPending","frameRequest","pick","pid","picker","pixelBuffer","oid","absoluteToRelative","bRadius","relativeToAbsolute","__updateClipping","isFinite","cDist","nearFactor","farFactor","fogNearFactor","fogFarFactor","__updateCamera","ortho","nearClip","updateMaterialUniforms","sortParticles","sortData","sortArray","zArray","cmpFn","indexSrc","indexDst","tmpTab","__zArray","__sortArray","__cmpFn","bi","arr","stack","sp","swap","tmp2","quicksortCmp","attr","sortProjectedPosition","__setVisibility","helper","__updateLights","__renderPickingGroup","__renderModelGroup","__renderSuperSample","baseSampleWeight","sampleWeight","__renderStereo","_renderTarget","__render","lastRenderedPicking","rendering","getTouchDistance","touches","pageX","pageY","MouseObserver","moved","scrolled","dragged","dropped","clicked","hovered","doubleClicked","prevPosition","down","canvasPosition","prevClickCP","moving","hovering","lastMoved","which","buttons","pressed","altKey","ctrlKey","metaKey","shiftKey","touchAction","hoverTimeout","handleScroll","doubleClickSpeed","_listen","_onMousewheel","_onMousemove","_onMousedown","_onMouseup","_onContextmenu","_onTouchstart","_onTouchend","_onTouchmove","opt","passive","setParameters","cp","doubleClickPending","lastClicked","overElement","_setKeys","deltaY","deltaMode","WheelEvent","DOM_DELTA_PIXEL","DOM_DELTA_LINE","wheelDelta","wheelDeltaY","clientX","clientY","_setCanvasPosition","button","getMouseButtons","_distance","lastTouchDistance","touchDistance","tmpRotateXMatrix","tmpRotateYMatrix","tmpRotateZMatrix","tmpRotateMatrix","tmpRotateCameraMatrix","tmpRotateVector","tmpRotateQuaternion","tmpRotateQuaternion2","tmpPanMatrix","tmpPanVector","tmpAtomVector","TrackballControls","rotateSpeed","zoomSpeed","panSpeed","mouse","mouseObserver","controls","viewerControls","component","transformComponent","transformAtom","_setPanVector","scaleFactor","getCanvasScaleFactor","_getRotateXY","_getCameraRotation","_transformPanVector","pan","panComponent","panAtom","positionToVector3","positionAdd","updateRepresentations","applyMatrix","zRotate","rotateComponent","tmpVec","PickingProxy","pickingData","getComponentsByObject","getObject","getPosition","closestBondAtom","atom1","atom2","acp1","getPositionOnCanvas","acp2","closeAtom","ca","acp","getMaxRepresentationRadius","arrow","_objectIfType","cone","clash","contact","cylinder","ellipsoid","octahedron","tetrahedron","torus","surface","unitcell","unknown","volume","wideline","getLabel","msg","qualifiedName","sele1","sele2","serial","spacegroup","PickingControls","pickerArray","tmpQ","tmpP","tmpS","tmpCanvasVector","tmpScaleVector","tmpAlignMatrix","ViewerControls","changed","getCameraDistance","getOrientation","orient","spin","basis","Animation","duration","pausedTime","elapsedDuration","pausedDuration","ignoreGlobalToggle","_paused","_resolveList","_init","done","paused","tick","_tick","pause","hold","_hold","resume","releaseHold","SpinAnimation","RockAnimation","angleSum","angleStep","angleEnd","MoveAnimation","moveFrom","moveTo","ZoomAnimation","zoomFrom","zoomTo","RotateAnimation","_currentRotation","rotateFrom","rotateTo","ValueAnimation","valueFrom","valueTo","TimeoutAnimation","AnimationList","_list","every","AnimationControls","animationList","finishedList","rock","move","zoomMove","orientTo","timeout","spinComponent","rockComponent","moveComponent","Queue","argList","queue","pending","kill","Representation","lazy","clipRadius","clipCenter","flatShaded","front","back","double","colorData","colorScheme","colorScale","colorReverse","colorValue","colorDomain","colorMode","diffuseInterior","useInteriorColor","interiorColor","interiorDarkening","disablePicking","rebuild","tasks","make","bufferList","toBePrepared","setColor","quality","lazyProps","build","bufferParams","what","tp","sphereDetail","disableImpostor","getColorParams","getBufferParams","prepare","updateWhat","_make","manualAttach","disposed","setVisibility","noRenderRequest","updateParameters","int","float","_Worker","postCount","onmessageDict","onerrorDict","blobUrl","worker","Worker","post","__debug","terminate","WorkerPool","maxCount","pool","getNextWorker","nextWorker","minPending","calculateMeanVector3","projectPointOnVector","v3new","applyMatrix4toVector3array","applyMatrix3toVector3array","normalizeVector3array","len2","v3cross","v3dot","v3sub","v3add","v3fromArray","v3toArray","input","v3length2","v3length","v3divideScalar","v3multiplyScalar","v3normalize","length2","v3subScalar","v3addScalar","v3floor","v3ceil","v3negate","v3angle","cz","getFixedCountDashData","segmentCount","position1","sn3","position2","i3","j3","f1","f2","replicateArray3Entries","primitiveId","getFixedLengthDashData","segmentLength","pos1","pos2","rad","getFixedLengthWrappedDashData","remaining","drawing","k3","kprev","inv","Primitive","Picker","Buffer","static","_primitiveData","getShapeKey","fields","valueToShape","expandBoundingBox","valueFromShape","arrayFromShape","dataFromShape","SpherePrimitive","BoxPrimitive","heightAxis","depthAxis","OctahedronPrimitive","TetrahedronPrimitive","CylinderPrimitive","dashedCylinder","ArrowPrimitive","ConePrimitive","EllipsoidPrimitive","majorAxis","minorAxis","TorusPrimitive","TextPrimitive","PointPrimitive","WidelinePrimitive","SpatialHash","exp","bb","createBoundingBox","boundX","boundY","boundZ","an","xArray","yArray","grid","bucketIndex","bucketCount","bucketOffset","bucketFill","bucketArray","bucketIdx","within","eachWithin","atomIndex","rSq","loX","loY","loZ","hiX","hiY","hiZ","dSq","Store","_fields","_defaultFields","_initField","addField","resize","tmpArray","growIfFull","copyFrom","other","thisOffset","otherOffset","thisField","otherField","thisIndex","otherIndex","offsetTarget","offsetSource","targetIndex","sourceIndex","thisStore","tmpStore","quicksort","pivot","leftNew","rightNew","ContactStore","addContact","hammingWeight","BitArray","setAll","_words","flip","_assignRange","words","wordValue","wordStart","wordEnd","startWord","endWord","setRange","clearRange","setBits","clearBits","clearAll","flipAll","bs","_isRangeValue","isRangeSet","isRangeClear","isAllSet","isAllClear","isSet","isClear","isEqualTo","otherBitarray","words1","words2","difference","getIntersectionSize","makeIntersection","wordsA","answer","pos","toSeleString","createAdjacencyList","edges","edgeCount","nodeCount","nodeArray1","nodeArray2","countArray","offsetArray","bondCount2","idx1","idx2","j1","j2","createFeatureState","atomSet","addAtom","addFeature","features","centers","atomSets","UnknownBackboneType","ChemCompProtein","ChemCompRna","ChemCompDna","ChemCompSaccharide","ChemCompHetero","SecStrucHelix","SecStrucSheet","SecStrucTurn","AtomicNumbers","H","D","T","HE","LI","BE","B","N","O","F","NE","NA","MG","AL","SI","P","S","CL","AR","CA","SC","TI","V","CR","MN","FE","CO","NI","CU","ZN","GA","GE","AS","SE","BR","KR","RB","SR","Y","ZR","NB","MO","TC","RU","RH","PD","AG","CD","IN","SN","SB","TE","XE","CS","BA","LA","CE","PR","ND","PM","SM","EU","GD","TB","DY","HO","ER","TM","YB","LU","HF","TA","W","RE","OS","IR","PT","AU","HG","TL","PB","BI","PO","AT","RN","FR","RA","AC","TH","PA","U","NP","PU","AM","CM","BK","CF","ES","FM","MD","NO","LR","RF","DB","SG","BH","HS","MT","DS","RG","CN","NH","FL","MC","LV","TS","OG","VdwRadii","CovalentRadii","Valences","OuterShellElectronCounts","ResidueHydrophobicity","ALA","ARG","ASN","ASP","ASH","CYS","GLN","GLU","GLH","GLY","HIS","ILE","LEU","LYS","MET","PHE","PRO","SER","THR","TRP","TYR","VAL","DefaultResidueHydrophobicity","AA1","SEC","PYL","AA3","RnaBases","DnaBases","PurinBases","Bases","WaterNames","IonNames","SaccharideNames","ProteinBackboneAtoms","NucleicBackboneAtoms","ResidueTypeAtoms","direction1","direction2","backboneStart","backboneEnd","PDBQTSpecialElements","HD","NS","OA","SA","G0","G1","G2","G3","CG0","CG1","CG2","CG3","assignGeometry","totalCoordination","Angles","calcAngles","ap1","ap2","angles","eachBondedAtom","calcPlaneAngle","v12","neighbours","ni","ValenceModel","atomCount","charge","implicitH","totalH","idealGeometry","eachAtom","chg","implH","totH","geom","hydrogenCount","bondToElementCount","formalCharge","assignCharge","assignH","degree","bondCount","valence","eachBond","bondOrder","explicitValence","conjugated","_bp","getBondProxy","atomicNumber","hetero","flag","getOtherAtom","atomicNumber2","isConjugated","multiBond","implicitHCount","ba","oa","calculateHydrogensCharge","valenceModel","isPhosphate","PositvelyCharged","NegativelyCharged","isIonicInteraction","ti","tj","isPiStacking","isCationPi","isHistidineNitrogen","ap","isHydrogenBond","isWeakHydrogenBond","IonicTypeMetals","isMetalComplex","halBondElements","X","OptimalHalogenAngle","OptimalAcceptorAngle","invalidAtomContact","masterIdx","isMasterContact","ContactDefaultParams","maxHydrophobicDist","maxHbondDist","maxHbondSulfurDist","maxHbondAccAngle","maxHbondDonAngle","maxHbondAccPlaneAngle","maxHbondDonPlaneAngle","maxPiStackingDist","maxPiStackingOffset","maxPiStackingAngle","maxCationPiDist","maxCationPiOffset","maxIonicDist","maxHalogenBondDist","maxHalogenBondAngle","maxMetalDist","refineSaltBridges","masterModelIndex","lineOfSightDistFactor","residueIndex","calculateFeatures","atomInGroupDict","eachResidue","terminalNitrogenCount","isGuanidine","isAcetamidine","addPositiveCharges","isSulfonicAcid","isSulfate","terminalOxygenCount","isCarboxylate","addNegativeCharges","rings","getAromaticRings","ring","addAromaticRings","totalBonds","ig","addHydrogenAcceptors","addHydrogenDonors","ringData","residueType","getRings","hasElement","some","residueAtomOffset","atomTypeId","atomTypeIdList","atomMap","inAromaticRingWithElectronNegativeElement","addWeakHydrogenDonors","dative","ionic","isStandardAminoacid","isStandardBase","isHalogen","addMetalBinding","isTransitionMetal","addMetals","addHydrophobic","addHalogenAcceptors","addHalogenDonors","calculateContacts","contacts","spatialHash","contactStore","featureSet","createContacts","maxDistance","maxPiStackingDistSq","maxCationPiDistSq","atomStore","areAtomSetsWithinDist","atomSet1","atomSet2","maxDist","sn","sm","si","sj","atoms","getOffset","ct","addChargedContacts","maxHbondDistSq","donor","acceptor","isWeak","connectedTo","donorAngles","idealDonorAngle","donorAngle","outOfPlane","acceptorAngles","idealAcceptorAngle","acceptorAngle","bondType","isWaterHydrogenBond","isBackboneHydrogenBond","addHydrogenBonds","m1","m2","addMetalComplexation","addHydrophobicContacts","halogen","halogenAngles","addHalogenBonds","frozenContacts","adjacencyList","contactSet","createFrozenContacts","ac1","ac2","aw","lineOfSightDist","lineOfSightDistFactorSq","as1","as2","vdw","refineLineOfSight","residueContactDict","handleResidueContact","minDist","minIndex","refineHydrophobicContacts","ionicInteractionDict","isHydrogenBondType","iil1","iil2","piStackingDict","pil1","pil2","refinePiStacking","refineMetalCoordination","contactTypeName","ContactDataDefaultParams","hydrogenBond","hydrophobic","halogenBond","ionicInteraction","metalCoordination","cationPi","piStacking","weakHydrogenBond","waterHydrogenBond","backboneHydrogenBond","filterSele","getContactData","filterSet","getAtomSet","contactColor","ContactPicker","_applyTransformations","_getPosition","ShapePicker","primitive","objectFromShape","positionFromShape","AtomPicker","AxesPicker","BondPicker","bondStore","bp","center1","center2","ClashPicker","validation","clashArray","_getAtomProxyFromSele","getAtomIndices","DistancePicker","IgnorePicker","MeshPicker","__position","SurfacePicker","UnitcellPicker","VolumePicker","vol","dp","SlicePicker","getEdgeTable","getTriTable","MarchingCubes","field","nx","ny","nz","normalCache","vertexIndex","icount","mx","my","mz","allowedContours","isolevel","noNormals","contour","isNegativeIso","normalFactor","yd","zd","ilist","positionArray","normalArray","atomindexArray","edgeTable","triTable","VIntX","valp1","valp2","_q","mu","nc","q3","VIntY","q6","VIntZ","compNorm","polygonize","fx","fy","fz","edgeFilter","q1","q1y","q1z","qyz","q1yz","cubeindex","field0","field1","field2","field3","field4","field5","field6","field7","fx2","fy2","fz2","e1","e2","e3","triIndex","triangulate","xBeg","yBeg","zBeg","xEnd","yEnd","zEnd","yOffset","xBeg2","yBeg2","zBeg2","xEnd2","yEnd2","zEnd2","__break","__xBeg","__yBeg","__zBeg","__xEnd","__yEnd","__zEnd","_isolevel","_noNormals","_contour","_wrap","vIndexLength","Matrix","copyTo","At","nrows","ncols","Ai","Ati","pAt","atd","multiplyABt","Ap","Cp","mrows","cd","multiply3x3","Cd","Ad","Bd","m10","m14","m15","m16","m17","m18","m20","m24","m25","m26","m27","m28","meanRows","mean","subRows","row","hypot","FLT_MIN","svd","amt","wmt","vmt","astep","_W","Vt","vstep","eps","minval","iter","maxIter","Aj","Vi","Vj","sd","beta","seed","val0","asum","JacobiSVDImpl","m4new","m4set","m4multiply","m4makeScale","m4makeTranslation","m4makeRotationY","m3new","m3makeNormal","m4","r0","r1","r2","laplacianSmooth","verts","numiter","inflate","nv","nf","norms","tps","vertdeg","flagvert","ao","bo","co","vi3","vdi","wtvi","wt2vi","wt2","outwt","nv3","ci","getRadiusDict","radiusList","radiusDict","getSurfaceGrid","maxRadius","extraMargin","margin","dim","tmpSize","tran","mroty","mscale","mtrans","Surface","geo","colormaker","tc","getPicking","getFilteredIndex","filteredIndex","elementSize","getAtomindex","VolumeSurface","mc","getSurface","smooth","volsurf","Volume","inverseMatrix","setData","setAtomindex","_mean","_rms","setStats","rms","setMatrix","ne","getBox","_getBox","__box","_makeSurface","getValueForSigma","getSurfaceWorker","workerPool","sigma","getSigmaForValue","getDataAtomindex","getDataPosition","getDataColor","getDataPicking","getDataSize","_sum","sumSq","di","arrayRms","header","getThreeSide","setObjectMatrix","BufferDefaultParameters","opaqueBack","forceTransparent","BufferParameterTypes","updateShader","updateVisibility","parameterTypes","indexVersion","wireframeIndexVersion","isImpostor","isText","isPoint","dynamic","wireframeIndexCount","defaultParameters","pickingUniforms","_positionDataSize","addAttributes","initIndex","makeWireframeGeometry","attributeSize","nindex","DYNAMIC_DRAW","makeMaterial","wm","pm","wireframeMaterial","pickingMaterial","makeWireframeIndex","wireframeIndex","wireframeGeometry","checkEdge","updateWireframeIndex","getRenderOrder","_getMesh","materialName","getVertexShader","getFragmentShader","NEAR_CLIP","RADIUS_CLIP","PICKING","NOLIGHT","FLAT_SHADED","OPAQUE_BACK","DIFFUSE_INTERIOR","USE_INTERIOR_COLOR","addUniforms","buf","updateRenderOrder","setRenderOrder","pt","pv","propertyData","uniformData","doShaderUpdate","doVisibilityUpdate","setProperties","setUniforms","setAttributes","wu","MeshBuffer","SurfaceBuffer","setVisibilityTrue","setVisibilityFalse","DoubleSidedBuffer","frontMeshes","backMeshes","frontBuffer","backBuffer","ContourBuffer","SurfaceRepresentation","isolevelType","negateIsolevel","isolevelScroll","boxSize","colorVolume","useWorker","boxCenter","__boxCenter","setBox","__isolevel","__smooth","__contour","__wrap","__boxSize","onSurfaceFinish","surfaceBuffer","dullInterior","surfaceData","MouseActions","trackballControls","getFocus","almostIdentity","setFocus","eachRepresentation","reprElem","comp","repr","pickingProxy","animationControls","tt","tooltip","mp","innerText","measurePick","measureClear","MouseActionPresets","default","zoomScroll","focusScroll","zoomFocusScroll","rotateDrag","panDrag","zRotateDrag","zoomDrag","zoomFocusDrag","panComponentDrag","rotateComponentDrag","movePick","tooltipPick","pymol","coot","astexviewer","triggerFromString","tokens","MouseControls","actionList","disabled","preset","triggerStr","wildcard","action","KeyActions","autoView","toggleRock","toggleSpin","KeyActionPresets","toggleAnimations","toggleAntialiasing","KeyControls","char","PickingBehavior","mouseControls","_onClick","_onHover","pickingControls","MouseBehavior","_onMove","_onScroll","_onDrag","_onDblclick","AnimationBehavior","_onTick","KeyBehavior","keyControls","outline","_focusDomElement","_onKeydown","_onKeyup","_onKeypress","pressedKey","KeyboardEvent","keyCode","Annotation","content","_viewerPosition","_updateViewerPosition","_canvasPosition","_cameraPosition","pointerEvents","whiteSpace","setContent","_update","matrixChanged","displayValue","fontFamily","_clientRect","getVisibility","cr","zIndex","ComponentControls","RadiusFactoryTypes","covalent","bfactor","explicit","RadiusFactory","atomRadius","negateVector","PrincipalAxes","n3","pointsT","vm","van","vbn","vcn","begA","endA","begB","endB","begC","endC","vecA","vecB","vecC","normVecA","normVecB","normVecC","getBasisMatrix","getRotationQuaternion","getProjectedScaleForAtoms","d1a","d1b","d2a","d2b","d3a","d3b","ax1","ax2","ax3","dp1","dt1","dp2","dt2","dp3","dt3","FilteredVolume","minValue","maxValue","outside","setFilter","_getFilterHash","DMEAN","ARMS","filterHash","_filterHash","_dataBuffer","_positionBuffer","_atomindexBuffer","filteredData","filteredPosition","filteredAtomindex","BondHash","BondStore","addBond","ai1","ai2","addBondIfConnected","AtomStore","setAltloc","getAltloc","ResidueStore","setSstruc","getSstruc","setInscode","getInscode","ChainStore","setChainname","getChainname","setChainid","chainid","getChainid","ModelStore","Helixorient","polymer","residueCount","getCenterIterator","idx3","residueIndexStart","rp","getResidueProxy","traceAtomIndex","radiusFactory","rise","twist","resdir","r12","r23","r34","diff13","diff24","vt","_axis","_prevAxis","_resdir","getAtomIndexByType","a3","a4","diff13Length","diff24Length","resRadius","resTwist","resRise","resBending","resAxis","bending","Helixbundle","helixorient","getAxis","localAngle","centerDist","ssBorder","colorParams","radiusParams","beg","residueOffset","tmpAxis","tmpCenter","_beg","rp1","rp2","BinaryHeap","scoreFunction","bubbleUp","sinkDown","peek","parentN","elemScore","child1Score","child2Score","child2N","child1N","child1","child2","Kdtree","metric","maxDepth","currentNode","nodes","rootIndex","buildTree","arrBegin","arrEnd","plength","nodeIndex","arrMedian","currentDim","pivotIndex","pivotValue","storeIndex","getNodeDepth","parentIndex","nearest","maxNodes","bestNodes","nearestSearch","bestChild","otherChild","dimension","pointIndex","ownPoint","ownDistance","saveNode","leftIndex","rightIndex","linearPoint","linearDistance","verify","AtomProxy","chainStore","residueStore","residueMap","bondHash","entityList","entityIndex","chainIndex","residue","residueTypeId","atomType","occupancy","partialCharge","aromatic","_ap","hasBondTo","bap","hasBondToElement","backboneIndexList","moleculeType","isCg","backboneType","isTrace","atomRings","isNonmetal","isMetalloid","isDiatomicNonmetal","isPolyatomicNonmetal","isAlkaliMetal","isAlkalineEarthMetal","isNobleGas","isPostTransitionMetal","isLanthanide","isActinide","getDefaultValence","getValenceList","getOuterShellElectronCount","taa","aaa","distSquared","ta","positionFromArray","positionToArray","positionFromVector3","positionSub","getResidueBonds","firstOnly","relativeIndex","bonds","getBonds","atomIndices1","atomIndices2","connectedAtomIndex","connectedAtomIndices","noResname","modelStore","toObject","euclideanDistSq","euclideanDist","pointArray","useSquaredDist","atomIndices","kdtree","_Kdtree","nodeList","resultList","SymOpCode","$","E","G","J","M","Q","R","Z","_","EncodedSymOp","reInteger","selectionFromChains","chainList","Assembly","partList","addPart","matrixList","part","AssemblyPart","getAtomCount","reduce","getResidueCount","getInstanceCount","isIdentity","structureChainList","eachChain","partBox","getSelection","_getCount","propertyName","instanceBox","structureBox","getView","getInstanceList","StructureBuilder","currentModelindex","currentChainid","currentResname","currentResno","currentInscode","currentHetero","previousResname","previousHetero","ri","mi","addResidueType","modelindex","addModel","addChain","addResidue","chainOffset","chainCount","finalize","assignSecondaryStructure","secStruct","chainnames","eachModel","chainnamesSorted","chainnamesIndex","helices","h2","helix","helixRun","chainChange","sheets","strandCharCode","sheet","sheetRun","calculateSecondaryStructure","zhangSkolnickSS","distances","isHelical","eachPolymer","cgPolymer","proteinPolymer","prevSstruc","sstrucCount","ChainnameAlphabet","calculateChainnames","useExistingBonds","doAutoChainName","mIndex","rOffset","rCount","rStart","rEnd","chainData","eachResidueN","newChain","bbType1","bbType2","bbTypeUnk","backboneEndAtomIndex","backboneStartAtomIndex","fill","calculateBonds","calculateBondsWithin","calculateBondsBetween","BondOrderTable","getBondOrderFromTable","atomname1","atomname2","onlyAddRung","rungBondStore","rungAtomSet","atomBondMap","calculateAtomBondMap","bondedAtoms","Set","rai","bondOrders","nn","rai1","rai2","getBondIndex","rungEndAtomIndex","atomSetDict","rung","onlyAddBackbone","backboneBondStore","backboneAtomSet","needsBond","needsBackbone","backbone","buildUnitcellAssembly","uc","structureCenterFrac","cartToFrac","centerFrac","symopDict","encodedSymopList","matrixDict","symopList","symop","integer","getSymmetryOperations","centerFracSymop","positionFracSymop","getMatrixList","fracToCart","unitcellAssembly","unitcellMatrixList","ncsMatrixList","biomolDict","NCS","ncsUnitcellMatrixList","nm","vec","supercellAssembly","supercellMatrixList","ncsSupercellMatrixList","UNITCELL","SUPERCELL","guessElement","atomName","assignResidueTypeBonds","bondDict","nextAtomOffset","AlkaliMetals","AlkalineEarthMetals","PolyatomicNonmetals","DiatomicNonmetals","NobleGases","PostTransitionMetals","Metalloids","Halogens","AtomType","no","AtomMap","dict","getHash","ResidueType","chemCompType","bondReferenceAtomIndices","getMoleculeType","getBackboneType","backboneEndType","backboneStartType","getBackboneIndexList","atomnames","atomnamesStart","atomnamesEnd","traceIndex","getAtomIndexByName","dir1Index","direction1AtomIndex","dir2Index","direction2AtomIndex","bbStartIndex","bbEndIndex","rungEndIndex","atomnameList","hasProteinBackbone","hasRnaBackbone","hasDnaBackbone","hasCgProteinBackbone","hasCgRnaBackbone","hasCgDnaBackbone","hasAtomWithName","hasBackboneAtoms","hasBackbone","end1","maxd","nearestAtoms","calculateResidueBonds","calculateRings","getBondGraph","bondGraph","calculateBondGraph","getAromatic","aromaticAtoms","calculateAromatic","aromaticRings","nb","capacity","visited","pred","RingFinderMaxDepth","currentColor","RingFinderState","findRings","aromaticRingFlags","AromaticRingElements","AromaticRingPlanarityThreshold","isRingAromatic","assignBondReferenceAtomIndices","refRing","rings1","rings2","ri1","ai3","_idx2","getBondReferenceAtomIndex","bondIndex","addRing","current","leftOffset","rightOffset","found","rn","ringOffset","from","head","ResidueMap","BondProxy","_v12","_v13","_ap1","_ap2","_ap3","getOtherAtomIndex","getReferenceAtomIndex","typeAtomIndex1","typeAtomIndex2","calculateShiftDir","ap3","v13","ResidueProxy","getChainProxy","getAtomType","getResname1","getAtomnameList","rNext","bbAtomEnd","bbAtomStart","getNextConnectedResidue","nextIndex","rpNext","rpFirst","getPreviousConnectedResidue","residueProxy","rpPrev","rpLast","Polymer","residueIndexEnd","rpStart","rpEnd","isPrevConnected","isNextConnected","isNextNextConnected","isCyclic","__residueProxy","aIndex","eachAtomN","rStartIndex","ChainProxy","getModelProxy","residueEnd","_rp","rNextIndex","ModelProxy","chainEnd","_cp","Structure","refreshed","title","extraData","atomSetCache","boxes","bondSet","finalizeAtoms","finalizeBonds","getBondSet","getBackboneBondSet","backboneBondSet","__backbone","getRungBondSet","rungBondSet","__rung","seleString","getAtomSetWithinSelection","getAtomSetWithinPoint","getAtomSetWithinVolume","fv","getAtomSetWithinGroup","atomResidueIndex","getStructure","eachEntity","getEntityType","mn","cn","getAtomData","atomData","getBondData","multipleBond","isMulti","isOffset","bondScale","bondSpacing","bondData","storeBondOrder","absOffset","multiRadius","vShortening","vShift","getBackboneAtomData","getBackboneBondData","getRungAtomData","getRungBondData","getPrincipalAxes","atomCenter","hasCoords","_hasCoords","getSequence","getChainnameCount","updatePosition","refresh","refreshPosition","tmpBox","Primitives","ShapeDefaultParameters","aspectRatio","labelParams","pointSize","useTexture","Shape","meshCount","addMesh","meshBuffer","addSphere","objectToShape","addEllipsoid","addTorus","addCylinder","addCone","addArrow","addBox","addOctahedron","addTetrahedron","addText","addPoint","addWideline","addLabel","getBufferList","bufferFromShape","BufferRepresentation","GeometryBuffer","geoPosition","geoIndex","meshPosition","meshNormal","meshColor","meshIndex","updateNormals","geoNormal","positionCount","geoPositionCount","transformedGeoPosition","transformedGeoNormal","makeIndex","initNormals","applyPositionTransform","o3","SphereGeometryBufferDefaultParameters","SphereGeometryBuffer","_radius","MappedBuffer","mappingType","indexSize","mappingSize","mappingIndicesSize","nullValueAttributes","getAttributeIndex","dataIndex","makeMapping","mappingItemSize","aMapping","mappingIndices","it","MappedQuadBuffer","SphereImpostorBuffer","SphereBuffer","PointBufferDefaultParameters","edgeBleach","PointBufferParameterTypes","PointBuffer","makeTexture","makePointTexture","USE_SIZEATTENUATION","USE_MAP","ALPHATEST","DotRepresentation","thresholdType","thresholdMin","thresholdMax","thresholdOut","dotType","radiusType","deviation","dotData","dotBuffer","quadIndices","quadUvs","ImageBufferDefaultParameters","ImageBufferParameterTypes","ImageBuffer","alwaysTransparent","hasWireframe","imageData","pickingTex","pickingMap","startsWith","CUBIC_INTERPOLATION","endsWith","BSPLINE_FILTER","CATMULROM_FILTER","MITCHELL_FILTER","updateTexture","VolumeSlice","positionType","getPositionFromCoordinate","coord","ms","vn","dimLen","setVec","pickingArray","tMin","tMax","SliceRepresentation","linear","percent","coordinate","volumeSlice","sliceBuffer","logReprUnknown","ElementDefaultParameters","Element","statusChanged","setStatus","setName","RepresentationElementDefaultParameters","RepresentationElement","visibilityChanged","parametersChanged","setRepresentation","getType","_disposeRepresentation","hasRepresentation","removeRepresentation","toggleVisibility","setSelection","_v","ComponentDefaultParameters","Component","representationAdded","representationRemoved","reprList","annotationList","setRotation","setScale","setTransform","getCenterUntransformed","updateRepresentationMatrices","addAnnotation","annotation","eachAnnotation","removeAnnotation","removeAllAnnotations","_addRepresentation","hidden","impostor","workerDefault","ReprClass","makeRepresentation","addBufferRepresentation","removeAllRepresentations","getBoxUntransformed","getZoom","getZoomForBox","Collection","_remove","RepresentationCollection","TrajectoryElementDefaultParameters","defaultStep","defaultTimeout","defaultInterpolateType","defaultInterpolateStep","defaultMode","defaultDirection","initialFrame","TrajectoryElement","trajectory","frameChanged","playerChanged","player","setFrame","Frames","coordinates","times","timeOffset","deltaTime","Superposition","atoms1","atoms2","VH","coords1","coords2","coords1t","coords2t","transformationMatrix","prepCoords","_superpose","mean1","mean2","to","invA","t4","t5","t8","t9","t15","t17","t18","t20","t21","t23","t26","invert3x3","md","mat3x3determinant","transformMat_","tmp_1","tmp_2","mult","M1","M2","is4X4","tCoords","_pB","mcols","invertTrasform","mat","n4","TrajectoryPlayerDefaultParameters","interpolateType","interpolateStep","TrajectoryPlayer","traj","startedRunning","haltedRunning","_run","_previousTime","_currentTime","_currentStep","frameCount","_currentFrame","_direction","_animate","isRunning","dt","inProgress","_nextInterpolated","hasFrame","ip","ipp","ippp","setFrameInterpolated","loadFrame","_next","currentFrame","play","setPlayer","Trajectory","trajPath","frameCache","loadQueue","boxCache","pathCache","frameCacheSize","_frameCount","_disposed","centerPbc","removePbc","removePeriodicity","superpose","selectionIndices","_resetCache","_saveInitialCoords","setStructure","_loadFrameCount","backboneIndices","_getIndices","_makeAtomIndices","_saveStructureCoords","initialCoords","structureCoords","_makeSuperposeCoords","_updateStructure","_interpolate","fc","cpp","cppp","j0","interpolateSpline","interpolateLerp","iList","_loadFrame","_doSuperpose","_process","_setFrameCount","box2","circMean","circularMean3","arrayMean3","getFrameTime","FramesTrajectory","StructureTrajectory","RemoteTrajectory","request","getFrameUrl","getFrameParams","setRequestHeader","arrayBuffer","getCountUrl","CallbackTrajectory","requestCallback","StructureView","seleList","parentSelection","ignoreView","blosum62x","prepareMatrix","cellNames","matDict","rowDict","SubstitutionMatrices","blosum62","Alignment","seq1","seq2","gapPenalty","gapExtensionPenalty","substMatrix","initMatrices","score","ali","gap","makeScoreFn","calc","gap0","scoreFn","Vi1","Si1","Hi","Si","ali1","ali2","_s1","_s2","_i","_j","aliIdx1","aliIdx2","_atoms1","_atoms2","StructureComponentDefaultParameters","defaultAssembly","StructureComponent","trajList","trajectoryAdded","trajectoryRemoved","defaultAssemblyChanged","initSelection","pickBuffer","pointer","item","createRingBuffer","pickDict","del","createSimpleDict","spacefillRepresentation","addRepresentation","distanceRepresentation","angleRepresentation","dihedralRepresentation","measureRepresentations","setDefaultAssembly","structureView","rebuildRepresentations","rebuildTrajectories","reprParams","trajComp","reprComp","measureUpdate","addTrajectory","trajSrc","makeTrajectory","removeTrajectory","getAtomRadius","pickCount","lastPick","atomList","atomListSorted","atomPair","atomTriple","atomQuad","measureBuild","measureData","dihedral","pickData","radiusData","removeAllMeasurements","pd","removeMeasurement","addMeasurement","SurfaceComponent","VolumeComponent","ComponentCollection","matchName","tmpZoomVector","StageDefaultParameters","mousePreset","ShapeComponent","__decorate","decorators","desc","getOwnPropertyDescriptor","Reflect","decorate","AtomindexColormaker","scalePerModel","BfactorColormaker","bfactorScale","ChainidColormaker","chainidDictPerModel","chainidDict","ChainindexColormaker","ChainnameColormaker","chainnameDictPerModel","chainnameDict","DensityfitColormaker","rsrzDict","rsccDict","rsrzScale","rsccScale","rsrz","rscc","partialCharges","CZ","CG","OD1","CB","OD2","OE1","OE2","CD2","CE1","ND1","NE2","NZ","SD","PTR","O1P","O2P","O3P","OG1","SEP","TPO","CD1","CE2","CE3","NE1","OH","ElectrostaticColormaker","hCharges","charges","hPositions","hPos","backboneNHPosition","bbox","hStore","buildStoreLike","hHash","ElementColors","UUT","UUP","UUH","ElementColormaker","EntityindexColormaker","entityindexScale","EntitytypeColormaker","entityType","GeoqualityColormaker","geoAtomDict","geoDict","geoProblemCount","geoAtom","atomProblems","HydrophobicityColormaker","resHF","defaultResidueHydrophobicity","hfScale","ModelindexColormaker","modelindexScale","MoleculetypeColormaker","OccupancyColormaker","occupancyScale","PartialchargeColormaker","partialchargeScale","randomColor","RandomColormaker","RandomcoilindexColormaker","rciDict","rciScale","rci","ResidueindexColormaker","scalePerChain","ResidueColors","ASX","GLX","DA","DG","DI","DX","DC","DT","DU","DD","ResnameColormaker","StructureColors","SstrucColormaker","StructuredataColormaker","_a","_b","UniformColormaker","valueColor","ValueColormaker","valueScale","VolumeColormaker","nxy","i1y","i1z","iyz","i1yz","vy","vz","v1y","v1z","vyz","v1yz","xd","c00","c01","c10","c11","StructureRepresentation","radiusSize","radiusScale","assembly","biomolOptions","defaultScale","setRadius","getQuality","getAssembly","needsBuild","sview","createData","updateData","getRadiusParams","param","getAtomParams","getBondParams","MeasurementRepresentation","labelVisible","labelFontFamily","monospace","serif","labelFontStyle","italic","labelFontWeight","bold","labelsdf","labelXOffset","labelBackground","labelBackgroundColor","labelBackgroundMargin","labelBackgroundOpacity","labelFixedSize","labelFontstyle","textData","textBuffer","getLabelBufferParams","fontStyle","fontWeight","sdf","showBorder","borderColor","borderWidth","showBackground","backgroundMargin","backgroundOpacity","fixedSize","parseNestedAtoms","nSets","selected","_break","isInteger","calcArcPoint","edt","edt1d","MIN_SAFE_INTEGER","TextAtlasCache","TextAtlasDefaultParams","font","variant","weight","TextAtlas","mapped","scratchW","scratchH","currentX","currentY","cutoff","lineHeight","maxWidth","fillStyle","textAlign","textBaseline","lineJoin","gridOuter","gridInner","canvas2","context2","draw","measureText","clearRect","fillText","TextBufferDefaultParameters","fontSize","TextBufferParameterTypes","getCharCount","charCount","TextBuffer","fontTexture","inputTexCoord","inputSize","aPosition","aColor","txt","iChar","nChar","iCharAll","textAtlas","getTextAtlas","inputMapping","xadvance","xShift","yShift","texWidth","texHeight","texCoords","FIXED_SIZE","WideLineBufferDefaultParameters","WideLineBufferParameterTypes","WideLineBuffer","AngleRepresentation","vectorVisible","sectorVisible","atomPosition","okay","outPosition","outIdx","validatePositions","atomTriplePositions","angleData","labelPosition","labelText","vectorPosition1","vectorPosition2","arcPositionTmp1","arcPositionTmp2","sectorPositionTmp","totalSegments","v21","v23","cross2","labelTmp","arcPoint","crossLength","nSegments","sectorVertices","arcVertices1","arcVertices2","appendArcSection","arcSize","sectorSize","arcPosition1","arcPosition2","sectorPosition","sectorOffset","arcOffset","getAngleData","vectorBuffer","arcLength","arcBuffer","sectorLength","sectorBuffer","vectorData","arcData","sectorData","CylinderGeometryBufferDefaultParameters","getGeo","CylinderGeometryBuffer","geoLength","__center","_color","_from","_to","meshData","MappedAlignedBoxBuffer","CylinderImpostorBufferDefaultParameters","CylinderImpostorBufferParameterTypes","CylinderImpostorBuffer","CAP","CylinderBuffer","AxesRepresentation","showAxes","showBox","getAxesData","pa","en","vertexPosition","vertexColor","vertexRadius","edgePosition1","edgePosition2","edgeColor","edgeRadius","addAxis","offset2","addCorner","edgeOffset","addEdge","edge","axesData","sphereBuffer","cylinderBuffer","sphereData","cylinderData","BallAndStickRepresentation","lineOnly","cylinderOnly","symmetric","lineBuffer","lineData","BackboneRepresentation","BaseRepresentation","Interpolator","vec1","vec2","vDir","vTan","vNorm","vBin","interpolateToArr","interpolateToVec","interpolatePosition","interpolateTangent","vectorSubdivide","interpolationFn","iterator","getTangent","interpolateNormalDir","u0","u1","u2","u3","norm","bin","interpolateNormal","getNormalDir","iterDir1","iterDir2","vSub1","vSub2","vSub3","vSub4","d1v1","d1v2","d1v3","d1v4","d2v1","d2v2","d2v3","d2v4","interpolateColor","item1","item2","colFn","interpolatePicking","pickFn","interpolateSize","sizeFn","Spline","positionIterator","subdiv","smoothSheet","interpolator","getAtomIterator","cache2","apPrev","apNext","getSubdividedColor","nCol","getSubdividedPicking","getSubdividedPosition","getSubdividedOrientation","getNormals","binormal","getSubdividedSize","nSize","nPos","nTan","nNorm","vTangent","vMeshNormal","TubeMeshBufferDefaultParameters","capped","TubeMeshBuffer","capVertices","capTriangles","xi","size2","meshPrimitiveId","normX","normY","normZ","biX","biY","biZ","posX","posY","posZ","cxArr","cyArr","cx1Arr","cy1Arr","cx2Arr","cy2Arr","cx1","cy1","cx2","cy2","radialSegments1","irs","irs1","strip","CartoonRepresentation","getSplineParams","getSpline","getAspectRatio","polymerList","subPos","subOri","subCol","subPick","subSize","ContactRepresentation","angstrom","dataParams","contactData","getLabelData","DihedralRepresentation","extendLine","lineVisible","dihedralData","lineTmp1","lineTmp2","sectorTmp","planeTmp","totalLines","totalPlanes","v34","inPlane1","inPlane2","improperStart","improperEnd","nLines","line1","line2","sector","li","nSuccess","linePosition1","linePosition2","planePosition","lineOffset","planeOffset","lp1","lp2","pp","getDihedralData","lineLength","lineColor","planeLength","planeBuffer","planeData","createUpdatedObject","updateSource","hasKey","createColorArray","arrayLength","targetArray","DihedralHistogramRepresentation","histogramsData","histogramBinBorderVisible","scaleBinToSectorArea","histogramBinBorderColor","adjacentBondArrowColor","distantBondArrowColor","frontHistogramColor","backHistogramColor","opaqueMiddleDiscColor","histogramOpacity","opaqueMiddleDiscVisible","opaqueMiddleDiscOpacity","histogramBinBorderWidth","histogramBinBorderOpacity","bondArrowVisible","bondArrowWidth","bondArrowOpacity","specificColorData","getHistogramBinBorderBufferParameters","getBondArrowsBufferParameters","getOpaqueMiddleDiscBufferParameters","getHistogramBufferParameters","atomPositions","scaleData","Float32Concat","arrays","lengths","accumulatedOffset","createWideLineBuffer","linesList","startPoints","endPoints","startColors","endColors","createMeshBuffer","triangleColors","histogram360Scaled","histogram360","dihedralDataArray","currentHistogramData","calculateDihedralHistogram","frontHistogramBinBordersBuffer","frontHistogramBinBorders","backHistogramBinBordersBuffer","backHistogramBinBorders","adjacentBondArrowsBuffer","adjacentBondArrows","distantBondArrowsBuffer","distantBondArrows","opaqueMiddleDiscBuffer","opaqueMiddleDisc","frontHistogramBuffer","frontHistogram","backHistogramBuffer","backHistogram","histogramData","positionOfDihedralAtoms","histogram","totalSectorTrianglesInOpaqueMiddleDisc","frontAndBack","v32","cross1","dihedralAtomVectors","absAngle","maxHist","histBinAngleStep","setHistogramBinCoordinates","ind","zeroDegreeVector","crossVector","startOffset","scalingFactor","setOneSideHistogram","discHistogram","binBorders","sectionIndex","opaqueCircleSectorAngleStep","DistanceRepresentation","useCylinder","getDistanceData","pair","distanceData","bondParams","distanceBuffer","VectorBufferDefaultParameters","VectorBuffer","HelixorientRepresentation","LicoriceRepresentation","MappedBoxBuffer","HyperballStickImpostorBufferDefaultParameters","shrink","HyperballStickImpostorBufferParameterTypes","HyperballStickImpostorBuffer","HyperballStickBuffer","calculateMinArray","HyperballRepresentation","stickData","LabelFactory","errorLogged","atomLabel","aa1","qualified","LabelRepresentation","labelType","labelFormat","labelGrouping","getTextData","labelFactory","positionN","sizeN","colorN","getLoneAtomSet","LineRepresentation","crosses","lone","all","crossSize","_crossData","crossData","attrSize","cPosition1","cPosition2","cColor","cColor2","cOffset","cimax","crossBuffer","bufferIdx","lineAttributes","crossAttributes","makeGrid","DataCtor","elemSize","EDTSurface","coordList","probeRadius","pLength","pWidth","pHeight","ptran","depty","widxz","cutRadius","setAtomID","vpBits","vpDistance","vpAtomID","btype","_probeRadius","_scaleFactor","_cutoff","_setAtomID","boundingatom","INOUT","ISDONE","ISBOUND","txz","tdept","sradius","tradius","widxzR","deptyName","indx","fillatom","ox","oy","oz","mj","mk","sk","ii","jj","kk","deptyAtNind","deptyAt","nind","pWH","ci2","fillvoxels","fillAtomWaals","fastdistancemap","boundPoint","cutRSq","totalsurfacevox","inarray","positin","outarray","positout","fastoneshell","cutoffSq","tz","square","nbj","tnvix","tnviy","tnviz","getVolume","tk","buildboundary","fillvoxelswaals","stype","marchingcubeinit","vd","makeAVHash","atomsX","atomsY","atomsZ","atomsR","nAtoms","hashFunc","minW","iDim","jDim","kDim","nCells","jkDim","preHash","cid","cellOffsets","cellLengths","maxCellLength","subArray","cellLength","neighbourListLength","withinRadii","rExtra","nearI","nearJ","nearK","loI","loJ","loK","hiI","hiJ","hiK","iOffset","jOffset","cellStart","cellEnd","rSum","AVSurface","probePositions","gridx","gridy","gridz","sinTable","cosTable","lastClip","atob","ngTorus","_probePositions","rExt","surfGrid","fillGridDim","initializeGrid","initializeAngleTables","obscured","singleAtomObscures","ra2","projectPoints","ar","ar2","ng","iax","iay","iaz","minx","miny","minz","maxx","maxy","maxz","xoffset","dxy2","xyoffset","spx","spy","spz","projectTorus","dmp","normalToLine","rInt","cost","sint","px","py","pz","ia","projectTorii","fixNegatives","fixAtomIDs","MolecularSurface","_getAtomData","MolecularSurfaceRepresentation","surfaceType","vws","sas","ses","av","__infoList","__forceNewMolsurf","prepareData","molsurf","sviewFilter","bbSize","maxDim","asWithin","getSurfaceParams","__sele","__surfaceParams","after","contourBuffer","doubleSidedBuffer","PointRepresentation","pointData","RibbonBuffer","aNormal","aSize","aDir","aPrimitiveId","currSize","prevSize","RibbonRepresentation","RocketRepresentation","axisList","helixbundleList","helixbundle","axisData","RopeRepresentation","SpacefillRepresentation","TraceBuffer","linePosition","TraceRepresentation","TubeRepresentation","UnitcellRepresentation","defaultRadius","cbrt","getUnitcellData","unitcellData","ValidationRepresentation","clashData","getClashData","ConeBufferDefaultParameters","ConeBuffer","_position1","_position2","GeometryGroup","geometryList","empty","ArrowBufferDefaultParameters","ArrowBuffer","splitPosition","cylinderRadius","makeAttributes","coneBuffer","vSplit","fullLength","coneLength","BoxBuffer","_heightAxis","_depthAxis","_size","EllipsoidBufferDefaultParameters","EllipsoidBuffer","_majorAxis","_minorAxis","OctahedronBuffer","TetrahedronBuffer","TorusBufferDefaultParameters","radiusRatio","TorusBuffer","Parser","_beforeParse","_parse","_afterParse","StructureParser","structureBuilder","Entity","description","chainIndexList","entityTypeFromString","entityFromType","isNonPolymer","isMacrolide","DefaultBoxParams","Unitcell","alphaRad","betaRad","gammaRad","cosAlpha","cosBeta","cosGamma","sinBeta","sinGamma","cStar","cosAlphaStar","cornerOffset","centerArray3","HelixTypes","dAminoAcids","entityKeyList","reWhitespace","getModresId","PdbParser","isLegacy","headerLine","headerId","legacyId","isPqr","isPdbqt","sb","serialRadix","resnoRadix","currentCoord","doFrames","currentBiomol","currentPart","currentMatrix","recordName","startChain","startResi","startIcode","endChain","endResi","endIcode","serialDict","unitcellDict","entityDataList","currentEntityData","currentEntityKey","hetnameDict","modresDict","chainDict","chainIdx","currentChainname","seqresDict","currentSeqresChainname","modelIdx","pendingStart","ls","modresId","fromIdx","toIdx","helixType","seqresChainname","keyEnd","biomt","biomtElms","ncsName","ncs","ncsRow","ncsElms","origx","orgix","origxRow","origxElms","scaleRow","scaleElms","aLength","bLength","cLength","sGroup","_parseChunkOfLines","ei","residueDict","reQuotedWhitespace","reDoubleQuote","reTrimQuotes","trimQuotes","ensureArray","hasValue","cifDefaults","getBondOrder","valueOrder","CifParser","rawline","authAsymId","authSeqId","labelSeqId","labelAtomId","labelCompId","labelAsymId","labelEntityId","labelAltId","groupPDB","typeSymbol","pdbxPDBmodelNum","pdbxPDBinsCode","CartnX","CartnY","CartnZ","bIsoOrEquiv","cif","asymIdDict","chainIndexDict","pendingString","currentString","pendingValue","pendingLoop","pendingName","loopPointers","currentLoopIndex","currentCategory","currentName","pointerNames","modelNum","keyParts","category","keyValuePair","_modelNum","frameOffset","occ","assignedChainname","entityId","chem_comp","chem_comp_atom","cc","cca","ccb","chem_comp_bond","atomnameDict","comp_id","atom_id","type_symbol","model_Cartn_x","model_Cartn_y","model_Cartn_z","pdbx_component_comp_id","pdbx_residue_numbering","pdbx_model_Cartn_x_ideal","pdbx_model_Cartn_y_ideal","pdbx_model_Cartn_z_ideal","atom_id_1","atom_id_2","value_order","parseChemComp","atom_site_type_symbol","atom_site_label","atom_site_fract_x","cell_length_a","cell_length_b","cell_length_c","cell_angle_alpha","cell_angle_beta","cell_angle_gamma","atom_site_fract_y","atom_site_fract_z","atom_site_occupancy","identityMatrix","covalentI","parseCore","begIcode","struct_conf","pdbx_PDB_helix_class","beg_auth_seq_id","pdbx_beg_PDB_ins_code","pdbx_end_PDB_ins_code","beg_label_asym_id","end_label_asym_id","end_auth_seq_id","ssr","struct_sheet_range","processSecondaryStructure","operDict","pdbx_struct_oper_list","biomolOp","elms","pdbx_struct_assembly_gen","gen","getMatrixDict","expr","es","assembly_id","oe","oper_expression","md1","md2","k1","k2","asym_id_list","struct_ncs_oper","ncsOp","ncsPart","cell","length_a","length_b","length_c","angle_alpha","angle_beta","angle_gamma","symmetry","database_PDB_matrix","origxMat","atom_sites","scaleMat","processSymmetry","struct_conn","atomIndicesCache","connTypeId","conn_type_id","ptnr1_symmetry","ptnr2_symmetry","inscode1","pdbx_ptnr1_PDB_ins_code","altloc1","pdbx_ptnr1_label_alt_id","ptnr1_auth_seq_id","ptnr1_label_asym_id","ptnr1_label_atom_id","selection1","inscode2","pdbx_ptnr2_PDB_ins_code","altloc2","pdbx_ptnr2_label_alt_id","ptnr2_auth_seq_id","ptnr2_label_asym_id","ptnr2_label_atom_id","selection2","tmpA","tmpB","pdbx_value_order","processConnections","pdbx_description","processEntities","struct","entry","pdbx_audit_revision_history","revision_date","dates","releaseDate","pdbx_database_status","recvd_initial_deposition_date","depDates","depositionDate","database_PDB_rev","date","date_original","reflns","d_resolution_high","refine","ls_d_res_high","ls_R_factor_R_free","rFree","ls_R_factor_R_work","rWork","exptl","experimentalMethods","firstLines","lpos","ypos","zpos","modelLineCount","lineNo","AllFields","typedArray","getDataView","getInt8View","getInt32View","decodeInt16","decodeInt32","decodeInteger","intArray","divisor","invDiv","decodeRun","dataOffset","decodeDelta","decodePacking","int16or8","upperLimit","lowerLimit","decodeIntegerPacking","decodeIntegerDeltaPacking","unpacked","decodeIntegerDelta","decodeMsgpack","dataView","performDecoding","dvOut","dvIn","decodeFloat32","decodeIntegerRun","decodeMmtf","inputDict","ignoreFields","outputDict","dv","ignore","SstrucMap","groupData","numBonds","numAtoms","numGroups","numChains","numModels","chainsPerModel","structureId","groupsPerChain","groupList","groupTypeList","atomNameList","frameAtomOffset","xCoordList","yCoordList","zCoordList","bAtomIndex1","bAtomIndex2","bBondOrder","aGroupIndex","aFormalCharge","gChainIndex","gAtomOffset","gAtomCount","cModelIndex","cGroupOffset","cGroupCount","mChainOffset","mChainCount","modelChainCount","groupOffset","chainGroupCount","bondOffset","groupAtomCount","groupFormalChargeList","formalChargeList","groupBondAtomList","bondAtomList","groupBondOrderList","bondOrderList","atomIdList","bFactorList","altLocList","occupancyList","groupIdList","secStructList","insCodeList","chainNameList","chainIdList","groupTypeDict","groupType","elementList","hetFlag","numGroupBonds","groupName","resAtomOffset","secStructLength","bioAssemblyList","_assembly","chainToPart","transformList","_transform","ncsOperatorList","ncsAssembly","_operator","unitCell","spaceGroup","bondTypes","du","un","moleculeLineNo","modelAtomIdxStart","currentRecordType","reItem","SdfParser","headerLines","sdfData","mItem","atomStart","bondStart","bondEnd","currentItem","currentData","isV3000","isAtomBlock","isBondBlock","acc","atomindexToStoreindex","chgTok","find","chargeCount","coffset","atomIdx","cToken","_postProcess","parseIntSubstr","PrmtopParser","pointersDict","pointers","atomNames","radii","residueLabels","residuePointers","curIdx","bondIdx","lt","NATOM","NBONH","MBONA","NRES","curResIdx","curResname","curResno","reTitle","lastSegid","segid","reField","molecules","moleculetypeDict","currentMoleculetype","fieldMatch","cIdx","molName","molCount","molType","lastResno","resIdx","chainidIdx","chainnameIdx","TrajectoryParser","notNetcdf","statement","reason","readName","nameLength","nextPos","intView","ef","isCharmm","extraBlock","fourDims","NSET","ISTART","NSAVC","NAMNF","DELTA","titleLength","titlePos","TITLE","natom","natom4","BYTE","CHAR","SHORT","INT","DOUBLE","num2str","num2bytes","str2num","readNumber","bufferReader","numbers","readType","trimNull","ZERO","NC_DIMENSION","NC_VARIABLE","NC_ATTRIBUTE","recordDimension","dimList","dimensions","recordId","dimensionSize","dimensionsList","globalAttributes","attributesList","variables","varList","recordStep","variableSize","dimensionality","dimensionsIds","varSize","record","variablesList","gAttList","gAtt","NetcdfReader","hasDataVariable","variableName","findIndex","getDataVariable","variable","currentOffset","nonRecord","NctrajParser","netcdfReader","versionSize","virSize","presSize","coordSize","velocitySize","forceSize","natoms","floatSize","natoms3","frameCoords","MagicInts","sizeOfInt","numOfBits","_tmpBytes","sizeOfInts","numOfInts","sizes","numOfBytes","bytecnt","decodeBits","cbuf","buf2","lastBB0","lastBB1","_tmpIntBytes","decodeInts","nums","minMaxInt","sizeint","bitsizeint","sizesmall","thiscoord","prevcoord","lfp","lsize","bitsize","smallidx","tmpIdx","smaller","smallnum","adz","invPrecision","buf8","isSmaller","tmpSwap","VolumeParser","getMatrix","reScientificNotation","bohrToAngstromFactor","CubeParser","originX","originY","originZ","NVX","NVY","NVZ","basisX","basisY","basisZ","oribitalFlag","lj","Dsn6Parser","summand","byteView","brixStr","xStart","yStart","zStart","xExtent","yExtent","zExtent","xRate","yRate","zRate","xlen","ylen","zlen","xBlocks","yBlocks","zBlocks","nxyz","mapcrs","DxParser","headerInfo","parseHeaderLines","dataLineStart","headerByteCount","deltaLineCount","ymin","zmin","hx","hy","hz","uint8ToLines","MrcParser","floatView","MAP","MACHST","NX","NY","MODE","NXSTART","NYSTART","NZSTART","MX","MY","MZ","MAPC","MAPR","MAPS","DMIN","DMAX","ISPG","NSYMBT","LSKFLG","parseNumberLine","XplorParser","infoStart","dataStart","gridInfo","AMIN","AMAX","BMIN","BMAX","NC","CMIN","CMAX","cellInfo","lineSection","RAVE","RSIGMA","hsvToRgb","ColorDict","sea","sky","peach","lilac","pinktint","peachtint","yellowtint","greentint","bluetint","lilactint","deadwhite","deadblack","invisible","reWhitespaceComma","reCurlyWhitespace","reTrimCurly","reCollapseEqual","parseListDef","defaultColor","master","listName","listColor","listMasters","listWidth","parseListElm","lineBreak","triangleBreak","lsindex","literal","isLineBreak","isTriangleBreak","parseStr","parseFlag","parseGroup","flags","groupFlags","groupMasters","kinemage","onewidth","pdbfile","texts","captions","caption","groupDict","subgroupDict","masterDict","pointmasterDict","dotLists","vectorLists","ballLists","ribbonLists","currentGroupMasters","currentSubgroupMasters","dotDefaultColor","dotLabel","dotPosition","dotColor","vecDefaultColor","vecDefaultWidth","vecLabel1","vecLabel2","vecPosition1","vecPosition2","vecColor1","vecColor2","ballRadius","ballDefaultColor","ballLabel","ballPosition","ballColor","ribbonListDefaultColor","ribbonPointLabelArray","ribbonPointPositionArray","ribbonPointBreakArray","ribbonPointColorArray","isDotList","prevDotLabel","isVectorList","prevVecLabel","prevVecPosition","prevVecColor","isBallList","prevBallLabel","isRibbonList","prevRibbonPointLabel","isCaption","masterArray","labelArray","colorArray","indent","label1Array","label2Array","position1Array","position2Array","color1Array","color2Array","radiusArray","breakArray","splitLine","singlePointLine","dominant","convertedLists","listObject","convertedRibbonObject","editedLabels","editedPositions","editedColors","editedBreaks","breakPointer","positionPointer","removePointBreaksTriangleArrays","ribbonObject","convertedLabels","convertedBreaks","convertedPositions","convertedColors","vector3Positions","convertKinTriangleArrays","SurfaceParser","getLoader","OBJLoader","regexp","vertex_pattern","normal_pattern","uv_pattern","face_vertex","face_vertex_uv","face_vertex_uv_normal","face_vertex_normal","object_pattern","smoothing_pattern","material_library_pattern","material_use_pattern","setPath","_createParserState","startObject","fromDeclaration","parseVertexIndex","parseNormalIndex","addVertex","addVertexLine","addNormal","nd","vLen","ib","ic","nLen","addLineGeometry","vi","lineFirstChar","lineSecondChar","trimLeft","lineParts","lineVertices","lineUVs","llen","parts","PLYLoader","propertyNameMapping","setPropertyNameMapping","bin2str","isASCII","parseHeader","parseASCII","parseBinary","headerText","headerLength","currentElement","lineType","lineValues","propertValues","comments","countType","itemType","parseASCIINumber","parseASCIIElement","currentElementCount","useColor","handleElement","postProcess","elementName","vertexIndices","vertex_indices","binaryRead","dataview","binaryReadElement","loc","table","reDelimiter","msgpack","netcdf","TextParser","reStrip","reTag","reContent","reAttr","parseXml","declaration","root","tag","eos","is","XmlParser","useDomParser","__xmlParser","__domParser","DOMParser","parseFromString","Document","getNamedItem","getSele","useAltcode","icode","altcode","getResSele","setBitDict","bit","hasAttrValue","getProblemCount","clashDict","ga","clashes","getElementsByTagName","Validation","atomDict","clashSele","fromXml","entries","chemicalShiftLists","randomCoilIndices","rcia","_clashDict","clashList","seleAttr","createAttribute","setNamedItem","atomSele","res1","res2","mogBondOutliers","mogAngleOutliers","vPos1","vPos2","getAtomSele","dHalf","shrinkBuf","arraySet","dest","src_offs","dest_offs","adler32","adler","crcTable","makeTable","crc32","crc","BAD$1","TYPE$1","inflate_fast","strm","_in","last","dmax","wsize","whave","wnext","s_window","lcode","dcode","lmask","dmask","here","op","from_source","next_in","avail_in","next_out","avail_out","lencode","distcode","lenbits","distbits","dolen","dodist","sane","MAXBITS","ENOUGH_LENS$1","ENOUGH_DISTS$1","CODES$1","LENS$1","DISTS$1","lbase","lext","dbase","dext","inflate_table","lens","lens_index","codes","table_index","work","incr","here_bits","here_op","here_val","curr","drop","used","huff","base_index","offs","extra","extra_index","LENS","DISTS","Z_OK","Z_STREAM_ERROR","HEAD","TYPE","BAD","ENOUGH_LENS","ENOUGH_DISTS","zswap32","InflateState","havedict","check","total","wbits","ncode","nlen","ndist","have","lendyn","distdyn","was","inflateReset","total_in","total_out","inflateResetKeep","inflateInit2","windowBits","inflateReset2","lenfix","distfix","virgin","fixedtables","updatewindow","flush","put","last_bits","last_op","last_val","hbuf","inf_leave","xflags","os","extra_len","hcrc","data_type","inflateSetDictionary","dictionary","dictLength","STR_APPLY_OK","STR_APPLY_UIA_OK","__","_utf8len","string2buf","m_pos","str_len","buf_len","buf2string","c_len","utf16buf","_buf2binstring","utf8border","Z_OK$1","messages","ZStream","GZheader","Inflate","sources","raw","ended","next_out_utf8","tail","utf8str","allowBufError","binstring2buf","onEnd","onData","inflateEnd","flattenChunks","decompressedData","inflator","ungzip","Datasource","mmtfBaseUrl","mmtfFullUrl","mmtfReducedUrl","pdbid","baseUrl","suffixUrl","PassThroughDatasource","suffixURL","uniprotid","reProtocol","IntegerParam","NumberParam","RangeParam","SelectParam","UIStageParameters","getListing","jsonData","frameIndex","getPathUrl","renumberSerial","remarks","_records","_writeRecords","_writeTitle","_writeRemarks","_writeAtoms","im","chargeSign","hasModels","formatString","getString","idString","titleString","countsString","chargeLines","pairs","nCharges","formatAtom","formatBond","_writeHeader","_writeCTab","_writeFooter","fullscreenChanged","componentAdded","componentRemoved","compList","defaultFileParams","logList","pickingBehavior","mouseBehavior","animationBehavior","keyBehavior","spinAnimation","rockAnimation","setQuality","setImpostor","defaultFileRepresentation","BU1","sizeScore","backboneOnly","loadFile","promise","addComponentFromObject","defaultRepresentation","errorMsg","loadScript","script","addComponent","CompClass","removeComponent","removeAllComponents","toggleFullscreen","fullscreenEnabled","mozFullScreenEnabled","webkitFullscreenEnabled","msFullscreenEnabled","getFullscreenElement","fullscreenElement","mozFullScreenElement","webkitFullscreenElement","msFullscreenElement","resizeElement","lastFullscreenElement","dataset","normalWidth","normalHeight","exitFullscreen","msExitFullscreen","mozCancelFullScreen","webkitExitFullscreen","requestFullscreen","msRequestFullscreen","mozRequestFullScreen","webkitRequestFullscreen","setSpin","setRock","pclamp","minSize","aspectFactor","catch","impostorTypes","eachComponent","getComponentsByName","getRepresentationsByName","relativePath","pn","pathname","basePath","getAbsolutePath","vectorNorm1","vectorNorm2","vectorNorm3","structures","atomIndexDict","modelCount","wait","previous","later","leading","Date","clearTimeout","trailing"],"mappings":"2OAGA,MAAAA,EAAA,EACAC,EAAA,EACAC,EAAA,EAKAC,EAAA,EACAC,EAAA,EACAC,EAAA,EACAC,EAAA,EACAC,EAAA,EACAC,EAAA,EAGAC,EAAA,EACAC,EAAA,EACAC,EAAA,EACAC,EAAA,EACAC,EAAA,EACAC,EAAA,EACAC,EAAA,IACAC,EAAA,IACAC,EAAA,IACAC,EAAA,IACAC,EAAA,IACAC,EAAA,IACAC,EAAA,IACAC,EAAA,IACAC,EAAA,IACAC,EAAA,IACAC,EAAA,IACAC,EAAA,IACAC,EAAA,IACAC,EAAA,IACAC,EAAA,IACAC,EAAA,IACAC,EAAA,EACAC,EAAA,EACAC,EAAA,EACAC,EAAA,EACAC,EAAA,EACAC,EAAA,EACAC,EAAA,EACAC,EAAA,EACAC,EAAA,EACAC,EAAA,EACAC,EAAA,EACAC,EAAA,EACAC,EAAA,EACAC,EAAA,EAC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4+P,UAAmBF,EAAW5hJ,GACvD,IAAIsmB,EAAYq7H,GAAQ3hJ,EAAM4hJ,GAe9B,OAdA5gQ,EAAUjP,KACVu+F,EAAO54F,UACH4uI,GAAa,GAAKA,EAAYq7H,GAC5BxiI,IACF6iI,aAAa7iI,GACbA,EAAU,MAEZyiI,EAAW5hJ,EACXn/C,EAAS6vB,EAAK9oB,MAAM5mE,EAASsvF,GACxB6uC,IAASn+H,EAAUsvF,EAAO,OACrB6uC,IAAgC,IAArBj8H,EAAQ++P,WAC7B9iI,EAAUld,WAAW4/I,EAAOv7H,IAGvBzlE,CACT,CACF"} \ No newline at end of file +{"version":3,"file":"ngl.js","sources":["../node_modules/three/src/constants.js","../node_modules/three/src/core/EventDispatcher.js","../node_modules/three/src/math/MathUtils.js","../node_modules/three/src/math/Vector2.js","../node_modules/three/src/math/Matrix3.js","../node_modules/three/src/extras/ImageUtils.js","../node_modules/three/src/textures/Texture.js","../node_modules/three/src/math/Vector4.js","../node_modules/three/src/renderers/WebGLRenderTarget.js","../node_modules/three/src/math/Quaternion.js","../node_modules/three/src/math/Vector3.js","../node_modules/three/src/math/Matrix4.js","../node_modules/three/src/math/Euler.js","../node_modules/three/src/core/Layers.js","../node_modules/three/src/core/Object3D.js","../node_modules/three/src/scenes/Scene.js","../node_modules/three/src/math/Box3.js","../node_modules/three/src/math/Sphere.js","../node_modules/three/src/math/Ray.js","../node_modules/three/src/math/Plane.js","../node_modules/three/src/math/Triangle.js","../node_modules/three/src/math/Color.js","../node_modules/three/src/core/Face3.js","../node_modules/three/src/materials/Material.js","../node_modules/three/src/materials/MeshBasicMaterial.js","../node_modules/three/src/core/BufferAttribute.js","../node_modules/three/src/core/DirectGeometry.js","../node_modules/three/src/utils.js","../node_modules/three/src/core/BufferGeometry.js","../node_modules/three/src/objects/Mesh.js","../node_modules/three/src/core/Geometry.js","../node_modules/three/src/geometries/BoxGeometry.js","../node_modules/three/src/renderers/shaders/UniformsUtils.js","../node_modules/three/src/renderers/shaders/ShaderChunk/default_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/default_fragment.glsl.js","../node_modules/three/src/materials/ShaderMaterial.js","../node_modules/three/src/cameras/Camera.js","../node_modules/three/src/cameras/PerspectiveCamera.js","../node_modules/three/src/textures/DataTexture.js","../node_modules/three/src/math/Frustum.js","../node_modules/three/src/renderers/shaders/UniformsLib.js","../node_modules/three/src/renderers/webgl/WebGLAnimation.js","../node_modules/three/src/renderers/webgl/WebGLAttributes.js","../node_modules/three/src/geometries/PlaneGeometry.js","../node_modules/three/src/renderers/shaders/ShaderChunk.js","../node_modules/three/src/renderers/shaders/ShaderChunk/alphamap_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/alphamap_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/alphatest_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/aomap_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/aomap_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/begin_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/beginnormal_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/bsdfs.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/bumpmap_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/clipping_planes_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/clipping_planes_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/clipping_planes_pars_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/clipping_planes_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/color_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/color_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/color_pars_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/color_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/common.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/cube_uv_reflection_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/defaultnormal_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/displacementmap_pars_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/displacementmap_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/emissivemap_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/emissivemap_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/encodings_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/encodings_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/envmap_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/envmap_common_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/envmap_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/envmap_pars_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/envmap_physical_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/envmap_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/fog_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/fog_pars_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/fog_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/fog_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/gradientmap_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/lightmap_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/lightmap_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/lights_lambert_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/lights_pars_begin.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/lights_toon_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/lights_toon_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/lights_phong_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/lights_phong_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/lights_physical_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/lights_physical_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/lights_fragment_begin.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/lights_fragment_maps.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/lights_fragment_end.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/logdepthbuf_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/logdepthbuf_pars_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/logdepthbuf_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/map_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/map_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/map_particle_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/map_particle_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/metalnessmap_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/metalnessmap_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/morphnormal_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/morphtarget_pars_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/morphtarget_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/normal_fragment_begin.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/normal_fragment_maps.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/normalmap_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_begin.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/clearcoat_normal_fragment_maps.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/clearcoat_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/packing.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/premultiplied_alpha_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/project_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/dithering_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/dithering_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/roughnessmap_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/roughnessmap_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/shadowmap_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/shadowmap_pars_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/shadowmap_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/shadowmask_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/skinbase_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/skinning_pars_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/skinning_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/skinnormal_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/specularmap_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/specularmap_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/tonemapping_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/tonemapping_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/uv_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/uv_pars_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/uv_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/uv2_pars_fragment.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/uv2_pars_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/uv2_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderChunk/worldpos_vertex.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/background_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/background_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/cube_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/cube_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/depth_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/depth_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/distanceRGBA_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/distanceRGBA_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/equirect_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/equirect_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/linedashed_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/linedashed_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/meshbasic_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/meshbasic_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/meshlambert_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/meshlambert_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/meshmatcap_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/meshmatcap_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/meshtoon_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/meshtoon_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/meshphong_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/meshphong_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/meshphysical_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/meshphysical_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/normal_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/normal_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/points_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/points_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/shadow_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/shadow_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/sprite_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/sprite_vert.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib.js","../node_modules/three/src/renderers/webgl/WebGLBackground.js","../node_modules/three/src/renderers/webgl/WebGLBindingStates.js","../node_modules/three/src/renderers/webgl/WebGLBufferRenderer.js","../node_modules/three/src/renderers/webgl/WebGLCapabilities.js","../node_modules/three/src/renderers/webgl/WebGLClipping.js","../node_modules/three/src/renderers/webgl/WebGLExtensions.js","../node_modules/three/src/renderers/webgl/WebGLGeometries.js","../node_modules/three/src/renderers/webgl/WebGLIndexedBufferRenderer.js","../node_modules/three/src/renderers/webgl/WebGLInfo.js","../node_modules/three/src/renderers/webgl/WebGLMorphtargets.js","../node_modules/three/src/renderers/webgl/WebGLObjects.js","../node_modules/three/src/textures/CubeTexture.js","../node_modules/three/src/textures/DataTexture2DArray.js","../node_modules/three/src/textures/DataTexture3D.js","../node_modules/three/src/renderers/webgl/WebGLUniforms.js","../node_modules/three/src/renderers/webgl/WebGLShader.js","../node_modules/three/src/renderers/webgl/WebGLProgram.js","../node_modules/three/src/renderers/webgl/WebGLPrograms.js","../node_modules/three/src/renderers/webgl/WebGLProperties.js","../node_modules/three/src/renderers/webgl/WebGLRenderLists.js","../node_modules/three/src/renderers/webgl/WebGLLights.js","../node_modules/three/src/renderers/webgl/WebGLRenderStates.js","../node_modules/three/src/materials/MeshDepthMaterial.js","../node_modules/three/src/materials/MeshDistanceMaterial.js","../node_modules/three/src/renderers/shaders/ShaderLib/vsm_frag.glsl.js","../node_modules/three/src/renderers/shaders/ShaderLib/vsm_vert.glsl.js","../node_modules/three/src/renderers/webgl/WebGLShadowMap.js","../node_modules/three/src/renderers/webgl/WebGLState.js","../node_modules/three/src/renderers/webgl/WebGLTextures.js","../node_modules/three/src/renderers/webgl/WebGLUtils.js","../node_modules/three/src/cameras/ArrayCamera.js","../node_modules/three/src/objects/Group.js","../node_modules/three/src/renderers/webxr/WebXRController.js","../node_modules/three/src/renderers/webxr/WebXRManager.js","../node_modules/three/src/renderers/webgl/WebGLMaterials.js","../node_modules/three/src/renderers/WebGLRenderer.js","../node_modules/three/src/scenes/Fog.js","../node_modules/three/src/materials/LineBasicMaterial.js","../node_modules/three/src/objects/Line.js","../node_modules/three/src/objects/LineSegments.js","../node_modules/three/src/materials/PointsMaterial.js","../node_modules/three/src/objects/Points.js","../node_modules/three/src/textures/CanvasTexture.js","../node_modules/three/src/geometries/PolyhedronGeometry.js","../node_modules/three/src/geometries/TetrahedronGeometry.js","../node_modules/three/src/geometries/OctahedronGeometry.js","../node_modules/three/src/geometries/IcosahedronGeometry.js","../node_modules/three/src/geometries/TorusGeometry.js","../node_modules/three/src/geometries/CylinderGeometry.js","../node_modules/three/src/geometries/ConeGeometry.js","../node_modules/three/src/lights/Light.js","../node_modules/three/src/lights/LightShadow.js","../node_modules/three/src/lights/SpotLightShadow.js","../node_modules/three/src/lights/SpotLight.js","../node_modules/three/src/cameras/OrthographicCamera.js","../node_modules/three/src/lights/AmbientLight.js","../node_modules/three/src/cameras/StereoCamera.js","../node_modules/three/src/core/Uniform.js","../src/utils.ts","../src/utils/registry.ts","../src/math/math-utils.ts","../node_modules/chroma-js/chroma.js","../src/color/colormaker.ts","../src/selection/selection-constants.ts","../node_modules/signals/dist/signals.js","../src/selection/selection-test.ts","../src/selection/selection.ts","../src/selection/selection-parser.ts","../src/color/selection-colormaker.ts","../src/color/colormaker-registry.ts","../src/worker/worker-utils.ts","../src/globals.ts","../src/worker/worker-registry.ts","../src/parser/parser-registry.ts","../src/streamer/streamer.ts","../src/streamer/file-streamer.ts","../src/streamer/network-streamer.ts","../src/loader/loader.ts","../src/loader/parser-loader.ts","../src/script.ts","../src/loader/script-loader.ts","../src/loader/loader-utils.ts","../node_modules/sprintf-js/src/sprintf.js","../src/writer/writer.ts","../src/utils/io-buffer.ts","../src/utils/counter.ts","../src/viewer/stats.ts","../src/shader/shader-utils.ts","../src/viewer/viewer-constants.ts","../src/viewer/tiled-renderer.ts","../src/math/math-constants.ts","../src/math/array-utils.ts","../src/viewer/viewer-utils.ts","../src/viewer/gl-utils.ts","../src/viewer/viewer.ts","../src/stage/mouse-observer.ts","../src/constants.ts","../src/controls/trackball-controls.ts","../src/controls/picking-proxy.ts","../src/controls/picking-controls.ts","../src/controls/viewer-controls.ts","../src/animation/animation.ts","../src/controls/animation-controls.ts","../src/utils/queue.ts","../src/representation/representation.ts","../src/worker/worker.ts","../src/worker/worker-pool.ts","../src/math/vector-utils.ts","../src/geometry/dash.ts","../src/geometry/primitive.ts","../src/geometry/spatial-hash.ts","../src/store/store.ts","../src/store/contact-store.ts","../src/utils/bitarray.ts","../src/utils/adjacency-list.ts","../src/chemistry/interactions/features.ts","../src/structure/structure-constants.ts","../src/chemistry/geometry.ts","../src/chemistry/valence-model.ts","../src/structure/data.ts","../src/chemistry/functional-groups.ts","../src/chemistry/interactions/charged.ts","../src/chemistry/interactions/hydrogen-bonds.ts","../src/chemistry/interactions/metal-binding.ts","../src/chemistry/interactions/halogen-bonds.ts","../src/chemistry/interactions/refine-contacts.ts","../src/chemistry/interactions/contact.ts","../src/chemistry/interactions/hydrophobic.ts","../src/utils/picker.ts","../src/surface/marching-cubes.ts","../src/math/matrix-utils.ts","../src/surface/surface-utils.ts","../src/surface/surface.ts","../src/surface/volume.ts","../src/buffer/buffer.ts","../src/buffer/mesh-buffer.ts","../src/buffer/surface-buffer.ts","../src/buffer/doublesided-buffer.ts","../src/buffer/contour-buffer.ts","../src/representation/surface-representation.ts","../src/controls/mouse-actions.ts","../src/controls/mouse-controls.ts","../src/controls/key-actions.ts","../src/controls/key-controls.ts","../src/stage/picking-behavior.ts","../src/stage/mouse-behavior.ts","../src/stage/animation-behavior.ts","../src/stage/key-behavior.ts","../src/component/annotation.ts","../src/controls/component-controls.ts","../src/utils/radius-factory.ts","../src/math/principal-axes.ts","../src/surface/filtered-volume.ts","../src/store/bond-hash.ts","../src/store/bond-store.ts","../src/store/atom-store.ts","../src/store/residue-store.ts","../src/store/chain-store.ts","../src/store/model-store.ts","../src/geometry/helixorient.ts","../src/geometry/helixbundle.ts","../src/utils/binary-heap.ts","../src/utils/kdtree.ts","../src/proxy/atom-proxy.ts","../src/geometry/kdtree.ts","../src/symmetry/symmetry-constants.ts","../src/symmetry/symmetry-utils.ts","../src/symmetry/assembly.ts","../src/structure/structure-builder.ts","../src/structure/structure-utils.ts","../src/store/atom-type.ts","../src/store/atom-map.ts","../src/store/residue-type.ts","../src/store/residue-map.ts","../src/proxy/bond-proxy.ts","../src/proxy/residue-proxy.ts","../src/proxy/polymer.ts","../src/proxy/chain-proxy.ts","../src/proxy/model-proxy.ts","../src/structure/structure.ts","../src/geometry/shape.ts","../src/representation/buffer-representation.ts","../src/buffer/geometry-buffer.ts","../src/buffer/spheregeometry-buffer.ts","../src/buffer/mapped-buffer.ts","../src/buffer/mappedquad-buffer.ts","../src/buffer/sphereimpostor-buffer.ts","../src/buffer/sphere-buffer.ts","../src/buffer/point-buffer.ts","../src/representation/dot-representation.ts","../src/buffer/image-buffer.ts","../src/surface/volume-slice.ts","../src/representation/slice-representation.ts","../src/representation/representation-utils.ts","../src/component/element.ts","../src/component/representation-element.ts","../src/component/component.ts","../src/component/collection.ts","../src/component/representation-collection.ts","../src/component/trajectory-element.ts","../src/trajectory/frames.ts","../src/align/superposition.ts","../src/trajectory/trajectory-player.ts","../src/trajectory/trajectory.ts","../src/trajectory/frames-trajectory.ts","../src/trajectory/structure-trajectory.ts","../src/trajectory/remote-trajectory.ts","../src/trajectory/callback-trajectory.ts","../src/structure/structure-view.ts","../src/align/alignment.ts","../src/align/align-utils.ts","../src/component/structure-component.ts","../src/trajectory/trajectory-utils.ts","../src/component/surface-component.ts","../src/component/volume-component.ts","../src/component/component-collection.ts","../src/stage/stage.ts","../src/component/shape-component.ts","../node_modules/tslib/tslib.es6.js","../src/color/atomindex-colormaker.ts","../src/color/bfactor-colormaker.ts","../src/color/chainid-colormaker.ts","../src/color/chainindex-colormaker.ts","../src/color/chainname-colormaker.ts","../src/color/densityfit-colormaker.ts","../src/color/electrostatic-colormaker.ts","../src/color/element-colormaker.ts","../src/color/entityindex-colormaker.ts","../src/color/entitytype-colormaker.ts","../src/color/geoquality-colormaker.ts","../src/color/hydrophobicity-colormaker.ts","../src/color/modelindex-colormaker.ts","../src/color/moleculetype-colormaker.ts","../src/color/occupancy-colormaker.ts","../src/color/partialcharge-colormaker.ts","../src/color/random-colormaker.ts","../src/color/randomcoilindex-colormaker.ts","../src/color/residueindex-colormaker.ts","../src/color/resname-colormaker.ts","../src/color/sstruc-colormaker.ts","../src/color/structuredata-colormaker.ts","../src/color/uniform-colormaker.ts","../src/color/value-colormaker.ts","../src/color/volume-colormaker.ts","../src/representation/structure-representation.ts","../src/representation/measurement-representation.ts","../src/utils/edt.ts","../src/buffer/text-buffer.ts","../src/buffer/wideline-buffer.ts","../src/representation/angle-representation.ts","../src/buffer/cylindergeometry-buffer.ts","../src/buffer/mappedalignedbox-buffer.ts","../src/buffer/cylinderimpostor-buffer.ts","../src/buffer/cylinder-buffer.ts","../src/representation/axes-representation.ts","../src/representation/ballandstick-representation.ts","../src/representation/backbone-representation.ts","../src/representation/base-representation.ts","../src/geometry/spline.ts","../src/buffer/tubemesh-buffer.ts","../src/representation/cartoon-representation.ts","../src/representation/contact-representation.ts","../src/representation/dihedral-representation.ts","../src/representation/dihedral-histogram-representation.ts","../src/representation/distance-representation.ts","../src/buffer/vector-buffer.ts","../src/representation/helixorient-representation.ts","../src/representation/licorice-representation.ts","../src/buffer/mappedbox-buffer.ts","../src/buffer/hyperballstickimpostor-buffer.ts","../src/buffer/hyperballstick-buffer.ts","../src/representation/hyperball-representation.ts","../src/utils/label-factory.ts","../src/representation/label-representation.ts","../src/representation/line-representation.ts","../src/geometry/grid.ts","../src/surface/edt-surface.ts","../src/surface/av-surface.ts","../src/surface/molecular-surface.ts","../src/representation/molecularsurface-representation.ts","../src/representation/point-representation.ts","../src/buffer/ribbon-buffer.ts","../src/representation/ribbon-representation.ts","../src/representation/rocket-representation.ts","../src/representation/rope-representation.ts","../src/representation/spacefill-representation.ts","../src/buffer/trace-buffer.ts","../src/representation/trace-representation.ts","../src/representation/tube-representation.ts","../src/representation/unitcell-representation.ts","../src/representation/validation-representation.ts","../src/buffer/cone-buffer.ts","../src/viewer/geometry-group.ts","../src/buffer/arrow-buffer.ts","../src/buffer/box-buffer.ts","../src/buffer/ellipsoid-buffer.ts","../src/buffer/octahedron-buffer.ts","../src/buffer/tetrahedron-buffer.ts","../src/buffer/torus-buffer.ts","../src/parser/parser.ts","../src/parser/structure-parser.ts","../src/structure/entity.ts","../src/symmetry/unitcell.ts","../src/parser/pdb-parser.ts","../src/parser/cif-parser.ts","../src/parser/gro-parser.ts","../lib/mmtf.es6.js","../src/parser/mmtf-parser.ts","../src/parser/mol2-parser.ts","../src/parser/pdbqt-parser.ts","../src/parser/pqr-parser.ts","../src/parser/sdf-parser.ts","../src/parser/prmtop-parser.ts","../src/parser/psf-parser.ts","../src/parser/top-parser.ts","../src/parser/trajectory-parser.ts","../src/utils/netcdf-reader.ts","../src/parser/dcd-parser.ts","../src/parser/nctraj-parser.ts","../src/parser/trr-parser.ts","../src/parser/xtc-parser.ts","../src/parser/volume-parser.ts","../src/parser/cube-parser.ts","../src/parser/dsn6-parser.ts","../src/parser/dx-parser.ts","../src/parser/dxbin-parser.ts","../src/parser/mrc-parser.ts","../src/parser/xplor-parser.ts","../src/parser/kin-parser.ts","../src/parser/surface-parser.ts","../src/parser/obj-parser.ts","../src/parser/ply-parser.ts","../src/parser/csv-parser.ts","../src/parser/json-parser.ts","../src/parser/msgpack-parser.ts","../src/parser/netcdf-parser.ts","../src/parser/text-parser.ts","../src/utils/parse-xml.ts","../src/parser/xml-parser.ts","../src/structure/validation.ts","../lib/pako_inflate.es6.js","../src/parser/validation-parser.ts","../src/utils/gzip-decompressor.ts","../src/datasource/datasource.ts","../src/datasource/rcsb-datasource.ts","../src/datasource/pubchem-datasource.ts","../src/datasource/passthrough-datasource.ts","../src/datasource/alphafold-datasource.ts","../src/datasource/static-datasource.ts","../src/ui/parameters.ts","../src/datasource/mdsrv-datasource.ts","../src/writer/pdb-writer.ts","../src/writer/sdf-writer.ts","../src/writer/stl-writer.ts"],"sourcesContent":["export const REVISION = '118';\nexport const MOUSE = { LEFT: 0, MIDDLE: 1, RIGHT: 2, ROTATE: 0, DOLLY: 1, PAN: 2 };\nexport const TOUCH = { ROTATE: 0, PAN: 1, DOLLY_PAN: 2, DOLLY_ROTATE: 3 };\nexport const CullFaceNone = 0;\nexport const CullFaceBack = 1;\nexport const CullFaceFront = 2;\nexport const CullFaceFrontBack = 3;\nexport const FrontFaceDirectionCW = 0;\nexport const FrontFaceDirectionCCW = 1;\nexport const BasicShadowMap = 0;\nexport const PCFShadowMap = 1;\nexport const PCFSoftShadowMap = 2;\nexport const VSMShadowMap = 3;\nexport const FrontSide = 0;\nexport const BackSide = 1;\nexport const DoubleSide = 2;\nexport const FlatShading = 1;\nexport const SmoothShading = 2;\nexport const NoBlending = 0;\nexport const NormalBlending = 1;\nexport const AdditiveBlending = 2;\nexport const SubtractiveBlending = 3;\nexport const MultiplyBlending = 4;\nexport const CustomBlending = 5;\nexport const AddEquation = 100;\nexport const SubtractEquation = 101;\nexport const ReverseSubtractEquation = 102;\nexport const MinEquation = 103;\nexport const MaxEquation = 104;\nexport const ZeroFactor = 200;\nexport const OneFactor = 201;\nexport const SrcColorFactor = 202;\nexport const OneMinusSrcColorFactor = 203;\nexport const SrcAlphaFactor = 204;\nexport const OneMinusSrcAlphaFactor = 205;\nexport const DstAlphaFactor = 206;\nexport const OneMinusDstAlphaFactor = 207;\nexport const DstColorFactor = 208;\nexport const OneMinusDstColorFactor = 209;\nexport const SrcAlphaSaturateFactor = 210;\nexport const NeverDepth = 0;\nexport const AlwaysDepth = 1;\nexport const LessDepth = 2;\nexport const LessEqualDepth = 3;\nexport const EqualDepth = 4;\nexport const GreaterEqualDepth = 5;\nexport const GreaterDepth = 6;\nexport const NotEqualDepth = 7;\nexport const MultiplyOperation = 0;\nexport const MixOperation = 1;\nexport const AddOperation = 2;\nexport const NoToneMapping = 0;\nexport const LinearToneMapping = 1;\nexport const ReinhardToneMapping = 2;\nexport const CineonToneMapping = 3;\nexport const ACESFilmicToneMapping = 4;\nexport const CustomToneMapping = 5;\n\nexport const UVMapping = 300;\nexport const CubeReflectionMapping = 301;\nexport const CubeRefractionMapping = 302;\nexport const EquirectangularReflectionMapping = 303;\nexport const EquirectangularRefractionMapping = 304;\nexport const CubeUVReflectionMapping = 306;\nexport const CubeUVRefractionMapping = 307;\nexport const RepeatWrapping = 1000;\nexport const ClampToEdgeWrapping = 1001;\nexport const MirroredRepeatWrapping = 1002;\nexport const NearestFilter = 1003;\nexport const NearestMipmapNearestFilter = 1004;\nexport const NearestMipMapNearestFilter = 1004;\nexport const NearestMipmapLinearFilter = 1005;\nexport const NearestMipMapLinearFilter = 1005;\nexport const LinearFilter = 1006;\nexport const LinearMipmapNearestFilter = 1007;\nexport const LinearMipMapNearestFilter = 1007;\nexport const LinearMipmapLinearFilter = 1008;\nexport const LinearMipMapLinearFilter = 1008;\nexport const UnsignedByteType = 1009;\nexport const ByteType = 1010;\nexport const ShortType = 1011;\nexport const UnsignedShortType = 1012;\nexport const IntType = 1013;\nexport const UnsignedIntType = 1014;\nexport const FloatType = 1015;\nexport const HalfFloatType = 1016;\nexport const UnsignedShort4444Type = 1017;\nexport const UnsignedShort5551Type = 1018;\nexport const UnsignedShort565Type = 1019;\nexport const UnsignedInt248Type = 1020;\nexport const AlphaFormat = 1021;\nexport const RGBFormat = 1022;\nexport const RGBAFormat = 1023;\nexport const LuminanceFormat = 1024;\nexport const LuminanceAlphaFormat = 1025;\nexport const RGBEFormat = RGBAFormat;\nexport const DepthFormat = 1026;\nexport const DepthStencilFormat = 1027;\nexport const RedFormat = 1028;\nexport const RedIntegerFormat = 1029;\nexport const RGFormat = 1030;\nexport const RGIntegerFormat = 1031;\nexport const RGBIntegerFormat = 1032;\nexport const RGBAIntegerFormat = 1033;\n\nexport const RGB_S3TC_DXT1_Format = 33776;\nexport const RGBA_S3TC_DXT1_Format = 33777;\nexport const RGBA_S3TC_DXT3_Format = 33778;\nexport const RGBA_S3TC_DXT5_Format = 33779;\nexport const RGB_PVRTC_4BPPV1_Format = 35840;\nexport const RGB_PVRTC_2BPPV1_Format = 35841;\nexport const RGBA_PVRTC_4BPPV1_Format = 35842;\nexport const RGBA_PVRTC_2BPPV1_Format = 35843;\nexport const RGB_ETC1_Format = 36196;\nexport const RGB_ETC2_Format = 37492;\nexport const RGBA_ETC2_EAC_Format = 37496;\nexport const RGBA_ASTC_4x4_Format = 37808;\nexport const RGBA_ASTC_5x4_Format = 37809;\nexport const RGBA_ASTC_5x5_Format = 37810;\nexport const RGBA_ASTC_6x5_Format = 37811;\nexport const RGBA_ASTC_6x6_Format = 37812;\nexport const RGBA_ASTC_8x5_Format = 37813;\nexport const RGBA_ASTC_8x6_Format = 37814;\nexport const RGBA_ASTC_8x8_Format = 37815;\nexport const RGBA_ASTC_10x5_Format = 37816;\nexport const RGBA_ASTC_10x6_Format = 37817;\nexport const RGBA_ASTC_10x8_Format = 37818;\nexport const RGBA_ASTC_10x10_Format = 37819;\nexport const RGBA_ASTC_12x10_Format = 37820;\nexport const RGBA_ASTC_12x12_Format = 37821;\nexport const RGBA_BPTC_Format = 36492;\nexport const SRGB8_ALPHA8_ASTC_4x4_Format = 37840;\nexport const SRGB8_ALPHA8_ASTC_5x4_Format = 37841;\nexport const SRGB8_ALPHA8_ASTC_5x5_Format = 37842;\nexport const SRGB8_ALPHA8_ASTC_6x5_Format = 37843;\nexport const SRGB8_ALPHA8_ASTC_6x6_Format = 37844;\nexport const SRGB8_ALPHA8_ASTC_8x5_Format = 37845;\nexport const SRGB8_ALPHA8_ASTC_8x6_Format = 37846;\nexport const SRGB8_ALPHA8_ASTC_8x8_Format = 37847;\nexport const SRGB8_ALPHA8_ASTC_10x5_Format = 37848;\nexport const SRGB8_ALPHA8_ASTC_10x6_Format = 37849;\nexport const SRGB8_ALPHA8_ASTC_10x8_Format = 37850;\nexport const SRGB8_ALPHA8_ASTC_10x10_Format = 37851;\nexport const SRGB8_ALPHA8_ASTC_12x10_Format = 37852;\nexport const SRGB8_ALPHA8_ASTC_12x12_Format = 37853;\nexport const LoopOnce = 2200;\nexport const LoopRepeat = 2201;\nexport const LoopPingPong = 2202;\nexport const InterpolateDiscrete = 2300;\nexport const InterpolateLinear = 2301;\nexport const InterpolateSmooth = 2302;\nexport const ZeroCurvatureEnding = 2400;\nexport const ZeroSlopeEnding = 2401;\nexport const WrapAroundEnding = 2402;\nexport const NormalAnimationBlendMode = 2500;\nexport const AdditiveAnimationBlendMode = 2501;\nexport const TrianglesDrawMode = 0;\nexport const TriangleStripDrawMode = 1;\nexport const TriangleFanDrawMode = 2;\nexport const LinearEncoding = 3000;\nexport const sRGBEncoding = 3001;\nexport const GammaEncoding = 3007;\nexport const RGBEEncoding = 3002;\nexport const LogLuvEncoding = 3003;\nexport const RGBM7Encoding = 3004;\nexport const RGBM16Encoding = 3005;\nexport const RGBDEncoding = 3006;\nexport const BasicDepthPacking = 3200;\nexport const RGBADepthPacking = 3201;\nexport const TangentSpaceNormalMap = 0;\nexport const ObjectSpaceNormalMap = 1;\n\nexport const ZeroStencilOp = 0;\nexport const KeepStencilOp = 7680;\nexport const ReplaceStencilOp = 7681;\nexport const IncrementStencilOp = 7682;\nexport const DecrementStencilOp = 7683;\nexport const IncrementWrapStencilOp = 34055;\nexport const DecrementWrapStencilOp = 34056;\nexport const InvertStencilOp = 5386;\n\nexport const NeverStencilFunc = 512;\nexport const LessStencilFunc = 513;\nexport const EqualStencilFunc = 514;\nexport const LessEqualStencilFunc = 515;\nexport const GreaterStencilFunc = 516;\nexport const NotEqualStencilFunc = 517;\nexport const GreaterEqualStencilFunc = 518;\nexport const AlwaysStencilFunc = 519;\n\nexport const StaticDrawUsage = 35044;\nexport const DynamicDrawUsage = 35048;\nexport const StreamDrawUsage = 35040;\nexport const StaticReadUsage = 35045;\nexport const DynamicReadUsage = 35049;\nexport const StreamReadUsage = 35041;\nexport const StaticCopyUsage = 35046;\nexport const DynamicCopyUsage = 35050;\nexport const StreamCopyUsage = 35042;\n","/**\n * https://github.com/mrdoob/eventdispatcher.js/\n */\n\nfunction EventDispatcher() {}\n\nObject.assign( EventDispatcher.prototype, {\n\n\taddEventListener: function ( type, listener ) {\n\n\t\tif ( this._listeners === undefined ) this._listeners = {};\n\n\t\tconst listeners = this._listeners;\n\n\t\tif ( listeners[ type ] === undefined ) {\n\n\t\t\tlisteners[ type ] = [];\n\n\t\t}\n\n\t\tif ( listeners[ type ].indexOf( listener ) === - 1 ) {\n\n\t\t\tlisteners[ type ].push( listener );\n\n\t\t}\n\n\t},\n\n\thasEventListener: function ( type, listener ) {\n\n\t\tif ( this._listeners === undefined ) return false;\n\n\t\tconst listeners = this._listeners;\n\n\t\treturn listeners[ type ] !== undefined && listeners[ type ].indexOf( listener ) !== - 1;\n\n\t},\n\n\tremoveEventListener: function ( type, listener ) {\n\n\t\tif ( this._listeners === undefined ) return;\n\n\t\tconst listeners = this._listeners;\n\t\tconst listenerArray = listeners[ type ];\n\n\t\tif ( listenerArray !== undefined ) {\n\n\t\t\tconst index = listenerArray.indexOf( listener );\n\n\t\t\tif ( index !== - 1 ) {\n\n\t\t\t\tlistenerArray.splice( index, 1 );\n\n\t\t\t}\n\n\t\t}\n\n\t},\n\n\tdispatchEvent: function ( event ) {\n\n\t\tif ( this._listeners === undefined ) return;\n\n\t\tconst listeners = this._listeners;\n\t\tconst listenerArray = listeners[ event.type ];\n\n\t\tif ( listenerArray !== undefined ) {\n\n\t\t\tevent.target = this;\n\n\t\t\t// Make a copy, in case listeners are removed while iterating.\n\t\t\tconst array = listenerArray.slice( 0 );\n\n\t\t\tfor ( let i = 0, l = array.length; i < l; i ++ ) {\n\n\t\t\t\tarray[ i ].call( this, event );\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n} );\n\n\nexport { EventDispatcher };\n","/**\n * @author alteredq / http://alteredqualia.com/\n * @author mrdoob / http://mrdoob.com/\n * @author WestLangley / http://github.com/WestLangley\n * @author thezwap\n */\n\nconst _lut = [];\n\nfor ( let i = 0; i < 256; i ++ ) {\n\n\t_lut[ i ] = ( i < 16 ? '0' : '' ) + ( i ).toString( 16 );\n\n}\n\nconst MathUtils = {\n\n\tDEG2RAD: Math.PI / 180,\n\tRAD2DEG: 180 / Math.PI,\n\n\tgenerateUUID: function () {\n\n\t\t// http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/21963136#21963136\n\n\t\tconst d0 = Math.random() * 0xffffffff | 0;\n\t\tconst d1 = Math.random() * 0xffffffff | 0;\n\t\tconst d2 = Math.random() * 0xffffffff | 0;\n\t\tconst d3 = Math.random() * 0xffffffff | 0;\n\t\tconst uuid = _lut[ d0 & 0xff ] + _lut[ d0 >> 8 & 0xff ] + _lut[ d0 >> 16 & 0xff ] + _lut[ d0 >> 24 & 0xff ] + '-' +\n\t\t\t_lut[ d1 & 0xff ] + _lut[ d1 >> 8 & 0xff ] + '-' + _lut[ d1 >> 16 & 0x0f | 0x40 ] + _lut[ d1 >> 24 & 0xff ] + '-' +\n\t\t\t_lut[ d2 & 0x3f | 0x80 ] + _lut[ d2 >> 8 & 0xff ] + '-' + _lut[ d2 >> 16 & 0xff ] + _lut[ d2 >> 24 & 0xff ] +\n\t\t\t_lut[ d3 & 0xff ] + _lut[ d3 >> 8 & 0xff ] + _lut[ d3 >> 16 & 0xff ] + _lut[ d3 >> 24 & 0xff ];\n\n\t\t// .toUpperCase() here flattens concatenated strings to save heap memory space.\n\t\treturn uuid.toUpperCase();\n\n\t},\n\n\tclamp: function ( value, min, max ) {\n\n\t\treturn Math.max( min, Math.min( max, value ) );\n\n\t},\n\n\t// compute euclidian modulo of m % n\n\t// https://en.wikipedia.org/wiki/Modulo_operation\n\n\teuclideanModulo: function ( n, m ) {\n\n\t\treturn ( ( n % m ) + m ) % m;\n\n\t},\n\n\t// Linear mapping from range to range \n\n\tmapLinear: function ( x, a1, a2, b1, b2 ) {\n\n\t\treturn b1 + ( x - a1 ) * ( b2 - b1 ) / ( a2 - a1 );\n\n\t},\n\n\t// https://en.wikipedia.org/wiki/Linear_interpolation\n\n\tlerp: function ( x, y, t ) {\n\n\t\treturn ( 1 - t ) * x + t * y;\n\n\t},\n\n\t// http://en.wikipedia.org/wiki/Smoothstep\n\n\tsmoothstep: function ( x, min, max ) {\n\n\t\tif ( x <= min ) return 0;\n\t\tif ( x >= max ) return 1;\n\n\t\tx = ( x - min ) / ( max - min );\n\n\t\treturn x * x * ( 3 - 2 * x );\n\n\t},\n\n\tsmootherstep: function ( x, min, max ) {\n\n\t\tif ( x <= min ) return 0;\n\t\tif ( x >= max ) return 1;\n\n\t\tx = ( x - min ) / ( max - min );\n\n\t\treturn x * x * x * ( x * ( x * 6 - 15 ) + 10 );\n\n\t},\n\n\t// Random integer from interval\n\n\trandInt: function ( low, high ) {\n\n\t\treturn low + Math.floor( Math.random() * ( high - low + 1 ) );\n\n\t},\n\n\t// Random float from interval\n\n\trandFloat: function ( low, high ) {\n\n\t\treturn low + Math.random() * ( high - low );\n\n\t},\n\n\t// Random float from <-range/2, range/2> interval\n\n\trandFloatSpread: function ( range ) {\n\n\t\treturn range * ( 0.5 - Math.random() );\n\n\t},\n\n\tdegToRad: function ( degrees ) {\n\n\t\treturn degrees * MathUtils.DEG2RAD;\n\n\t},\n\n\tradToDeg: function ( radians ) {\n\n\t\treturn radians * MathUtils.RAD2DEG;\n\n\t},\n\n\tisPowerOfTwo: function ( value ) {\n\n\t\treturn ( value & ( value - 1 ) ) === 0 && value !== 0;\n\n\t},\n\n\tceilPowerOfTwo: function ( value ) {\n\n\t\treturn Math.pow( 2, Math.ceil( Math.log( value ) / Math.LN2 ) );\n\n\t},\n\n\tfloorPowerOfTwo: function ( value ) {\n\n\t\treturn Math.pow( 2, Math.floor( Math.log( value ) / Math.LN2 ) );\n\n\t},\n\n\tsetQuaternionFromProperEuler: function ( q, a, b, c, order ) {\n\n\t\t// Intrinsic Proper Euler Angles - see https://en.wikipedia.org/wiki/Euler_angles\n\n\t\t// rotations are applied to the axes in the order specified by 'order'\n\t\t// rotation by angle 'a' is applied first, then by angle 'b', then by angle 'c'\n\t\t// angles are in radians\n\n\t\tconst cos = Math.cos;\n\t\tconst sin = Math.sin;\n\n\t\tconst c2 = cos( b / 2 );\n\t\tconst s2 = sin( b / 2 );\n\n\t\tconst c13 = cos( ( a + c ) / 2 );\n\t\tconst s13 = sin( ( a + c ) / 2 );\n\n\t\tconst c1_3 = cos( ( a - c ) / 2 );\n\t\tconst s1_3 = sin( ( a - c ) / 2 );\n\n\t\tconst c3_1 = cos( ( c - a ) / 2 );\n\t\tconst s3_1 = sin( ( c - a ) / 2 );\n\n\t\tswitch ( order ) {\n\n\t\t\tcase 'XYX':\n\t\t\t\tq.set( c2 * s13, s2 * c1_3, s2 * s1_3, c2 * c13 );\n\t\t\t\tbreak;\n\n\t\t\tcase 'YZY':\n\t\t\t\tq.set( s2 * s1_3, c2 * s13, s2 * c1_3, c2 * c13 );\n\t\t\t\tbreak;\n\n\t\t\tcase 'ZXZ':\n\t\t\t\tq.set( s2 * c1_3, s2 * s1_3, c2 * s13, c2 * c13 );\n\t\t\t\tbreak;\n\n\t\t\tcase 'XZX':\n\t\t\t\tq.set( c2 * s13, s2 * s3_1, s2 * c3_1, c2 * c13 );\n\t\t\t\tbreak;\n\n\t\t\tcase 'YXY':\n\t\t\t\tq.set( s2 * c3_1, c2 * s13, s2 * s3_1, c2 * c13 );\n\t\t\t\tbreak;\n\n\t\t\tcase 'ZYZ':\n\t\t\t\tq.set( s2 * s3_1, s2 * c3_1, c2 * s13, c2 * c13 );\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tconsole.warn( 'THREE.MathUtils: .setQuaternionFromProperEuler() encountered an unknown order: ' + order );\n\n\t\t}\n\n\t}\n\n};\n\n\nexport { MathUtils };\n","/**\n * @author mrdoob / http://mrdoob.com/\n * @author philogb / http://blog.thejit.org/\n * @author egraether / http://egraether.com/\n * @author zz85 / http://www.lab4games.net/zz85/blog\n */\n\nfunction Vector2( x = 0, y = 0 ) {\n\n\tthis.x = x;\n\tthis.y = y;\n\n}\n\nObject.defineProperties( Vector2.prototype, {\n\n\t\"width\": {\n\n\t\tget: function () {\n\n\t\t\treturn this.x;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tthis.x = value;\n\n\t\t}\n\n\t},\n\n\t\"height\": {\n\n\t\tget: function () {\n\n\t\t\treturn this.y;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tthis.y = value;\n\n\t\t}\n\n\t}\n\n} );\n\nObject.assign( Vector2.prototype, {\n\n\tisVector2: true,\n\n\tset: function ( x, y ) {\n\n\t\tthis.x = x;\n\t\tthis.y = y;\n\n\t\treturn this;\n\n\t},\n\n\tsetScalar: function ( scalar ) {\n\n\t\tthis.x = scalar;\n\t\tthis.y = scalar;\n\n\t\treturn this;\n\n\t},\n\n\tsetX: function ( x ) {\n\n\t\tthis.x = x;\n\n\t\treturn this;\n\n\t},\n\n\tsetY: function ( y ) {\n\n\t\tthis.y = y;\n\n\t\treturn this;\n\n\t},\n\n\tsetComponent: function ( index, value ) {\n\n\t\tswitch ( index ) {\n\n\t\t\tcase 0: this.x = value; break;\n\t\t\tcase 1: this.y = value; break;\n\t\t\tdefault: throw new Error( 'index is out of range: ' + index );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tgetComponent: function ( index ) {\n\n\t\tswitch ( index ) {\n\n\t\t\tcase 0: return this.x;\n\t\t\tcase 1: return this.y;\n\t\t\tdefault: throw new Error( 'index is out of range: ' + index );\n\n\t\t}\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor( this.x, this.y );\n\n\t},\n\n\tcopy: function ( v ) {\n\n\t\tthis.x = v.x;\n\t\tthis.y = v.y;\n\n\t\treturn this;\n\n\t},\n\n\tadd: function ( v, w ) {\n\n\t\tif ( w !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead.' );\n\t\t\treturn this.addVectors( v, w );\n\n\t\t}\n\n\t\tthis.x += v.x;\n\t\tthis.y += v.y;\n\n\t\treturn this;\n\n\t},\n\n\taddScalar: function ( s ) {\n\n\t\tthis.x += s;\n\t\tthis.y += s;\n\n\t\treturn this;\n\n\t},\n\n\taddVectors: function ( a, b ) {\n\n\t\tthis.x = a.x + b.x;\n\t\tthis.y = a.y + b.y;\n\n\t\treturn this;\n\n\t},\n\n\taddScaledVector: function ( v, s ) {\n\n\t\tthis.x += v.x * s;\n\t\tthis.y += v.y * s;\n\n\t\treturn this;\n\n\t},\n\n\tsub: function ( v, w ) {\n\n\t\tif ( w !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.' );\n\t\t\treturn this.subVectors( v, w );\n\n\t\t}\n\n\t\tthis.x -= v.x;\n\t\tthis.y -= v.y;\n\n\t\treturn this;\n\n\t},\n\n\tsubScalar: function ( s ) {\n\n\t\tthis.x -= s;\n\t\tthis.y -= s;\n\n\t\treturn this;\n\n\t},\n\n\tsubVectors: function ( a, b ) {\n\n\t\tthis.x = a.x - b.x;\n\t\tthis.y = a.y - b.y;\n\n\t\treturn this;\n\n\t},\n\n\tmultiply: function ( v ) {\n\n\t\tthis.x *= v.x;\n\t\tthis.y *= v.y;\n\n\t\treturn this;\n\n\t},\n\n\tmultiplyScalar: function ( scalar ) {\n\n\t\tthis.x *= scalar;\n\t\tthis.y *= scalar;\n\n\t\treturn this;\n\n\t},\n\n\tdivide: function ( v ) {\n\n\t\tthis.x /= v.x;\n\t\tthis.y /= v.y;\n\n\t\treturn this;\n\n\t},\n\n\tdivideScalar: function ( scalar ) {\n\n\t\treturn this.multiplyScalar( 1 / scalar );\n\n\t},\n\n\tapplyMatrix3: function ( m ) {\n\n\t\tconst x = this.x, y = this.y;\n\t\tconst e = m.elements;\n\n\t\tthis.x = e[ 0 ] * x + e[ 3 ] * y + e[ 6 ];\n\t\tthis.y = e[ 1 ] * x + e[ 4 ] * y + e[ 7 ];\n\n\t\treturn this;\n\n\t},\n\n\tmin: function ( v ) {\n\n\t\tthis.x = Math.min( this.x, v.x );\n\t\tthis.y = Math.min( this.y, v.y );\n\n\t\treturn this;\n\n\t},\n\n\tmax: function ( v ) {\n\n\t\tthis.x = Math.max( this.x, v.x );\n\t\tthis.y = Math.max( this.y, v.y );\n\n\t\treturn this;\n\n\t},\n\n\tclamp: function ( min, max ) {\n\n\t\t// assumes min < max, componentwise\n\n\t\tthis.x = Math.max( min.x, Math.min( max.x, this.x ) );\n\t\tthis.y = Math.max( min.y, Math.min( max.y, this.y ) );\n\n\t\treturn this;\n\n\t},\n\n\tclampScalar: function ( minVal, maxVal ) {\n\n\t\tthis.x = Math.max( minVal, Math.min( maxVal, this.x ) );\n\t\tthis.y = Math.max( minVal, Math.min( maxVal, this.y ) );\n\n\t\treturn this;\n\n\t},\n\n\tclampLength: function ( min, max ) {\n\n\t\tconst length = this.length();\n\n\t\treturn this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) );\n\n\t},\n\n\tfloor: function () {\n\n\t\tthis.x = Math.floor( this.x );\n\t\tthis.y = Math.floor( this.y );\n\n\t\treturn this;\n\n\t},\n\n\tceil: function () {\n\n\t\tthis.x = Math.ceil( this.x );\n\t\tthis.y = Math.ceil( this.y );\n\n\t\treturn this;\n\n\t},\n\n\tround: function () {\n\n\t\tthis.x = Math.round( this.x );\n\t\tthis.y = Math.round( this.y );\n\n\t\treturn this;\n\n\t},\n\n\troundToZero: function () {\n\n\t\tthis.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x );\n\t\tthis.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y );\n\n\t\treturn this;\n\n\t},\n\n\tnegate: function () {\n\n\t\tthis.x = - this.x;\n\t\tthis.y = - this.y;\n\n\t\treturn this;\n\n\t},\n\n\tdot: function ( v ) {\n\n\t\treturn this.x * v.x + this.y * v.y;\n\n\t},\n\n\tcross: function ( v ) {\n\n\t\treturn this.x * v.y - this.y * v.x;\n\n\t},\n\n\tlengthSq: function () {\n\n\t\treturn this.x * this.x + this.y * this.y;\n\n\t},\n\n\tlength: function () {\n\n\t\treturn Math.sqrt( this.x * this.x + this.y * this.y );\n\n\t},\n\n\tmanhattanLength: function () {\n\n\t\treturn Math.abs( this.x ) + Math.abs( this.y );\n\n\t},\n\n\tnormalize: function () {\n\n\t\treturn this.divideScalar( this.length() || 1 );\n\n\t},\n\n\tangle: function () {\n\n\t\t// computes the angle in radians with respect to the positive x-axis\n\n\t\tconst angle = Math.atan2( - this.y, - this.x ) + Math.PI;\n\n\t\treturn angle;\n\n\t},\n\n\tdistanceTo: function ( v ) {\n\n\t\treturn Math.sqrt( this.distanceToSquared( v ) );\n\n\t},\n\n\tdistanceToSquared: function ( v ) {\n\n\t\tconst dx = this.x - v.x, dy = this.y - v.y;\n\t\treturn dx * dx + dy * dy;\n\n\t},\n\n\tmanhattanDistanceTo: function ( v ) {\n\n\t\treturn Math.abs( this.x - v.x ) + Math.abs( this.y - v.y );\n\n\t},\n\n\tsetLength: function ( length ) {\n\n\t\treturn this.normalize().multiplyScalar( length );\n\n\t},\n\n\tlerp: function ( v, alpha ) {\n\n\t\tthis.x += ( v.x - this.x ) * alpha;\n\t\tthis.y += ( v.y - this.y ) * alpha;\n\n\t\treturn this;\n\n\t},\n\n\tlerpVectors: function ( v1, v2, alpha ) {\n\n\t\tthis.x = v1.x + ( v2.x - v1.x ) * alpha;\n\t\tthis.y = v1.y + ( v2.y - v1.y ) * alpha;\n\n\t\treturn this;\n\n\t},\n\n\tequals: function ( v ) {\n\n\t\treturn ( ( v.x === this.x ) && ( v.y === this.y ) );\n\n\t},\n\n\tfromArray: function ( array, offset ) {\n\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tthis.x = array[ offset ];\n\t\tthis.y = array[ offset + 1 ];\n\n\t\treturn this;\n\n\t},\n\n\ttoArray: function ( array, offset ) {\n\n\t\tif ( array === undefined ) array = [];\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tarray[ offset ] = this.x;\n\t\tarray[ offset + 1 ] = this.y;\n\n\t\treturn array;\n\n\t},\n\n\tfromBufferAttribute: function ( attribute, index, offset ) {\n\n\t\tif ( offset !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Vector2: offset has been removed from .fromBufferAttribute().' );\n\n\t\t}\n\n\t\tthis.x = attribute.getX( index );\n\t\tthis.y = attribute.getY( index );\n\n\t\treturn this;\n\n\t},\n\n\trotateAround: function ( center, angle ) {\n\n\t\tconst c = Math.cos( angle ), s = Math.sin( angle );\n\n\t\tconst x = this.x - center.x;\n\t\tconst y = this.y - center.y;\n\n\t\tthis.x = x * c - y * s + center.x;\n\t\tthis.y = x * s + y * c + center.y;\n\n\t\treturn this;\n\n\t},\n\n\trandom: function () {\n\n\t\tthis.x = Math.random();\n\t\tthis.y = Math.random();\n\n\t\treturn this;\n\n\t}\n\n} );\n\n\nexport { Vector2 };\n","/**\n * @author alteredq / http://alteredqualia.com/\n * @author WestLangley / http://github.com/WestLangley\n * @author bhouston / http://clara.io\n * @author tschw\n */\n\nfunction Matrix3() {\n\n\tthis.elements = [\n\n\t\t1, 0, 0,\n\t\t0, 1, 0,\n\t\t0, 0, 1\n\n\t];\n\n\tif ( arguments.length > 0 ) {\n\n\t\tconsole.error( 'THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.' );\n\n\t}\n\n}\n\nObject.assign( Matrix3.prototype, {\n\n\tisMatrix3: true,\n\n\tset: function ( n11, n12, n13, n21, n22, n23, n31, n32, n33 ) {\n\n\t\tconst te = this.elements;\n\n\t\tte[ 0 ] = n11; te[ 1 ] = n21; te[ 2 ] = n31;\n\t\tte[ 3 ] = n12; te[ 4 ] = n22; te[ 5 ] = n32;\n\t\tte[ 6 ] = n13; te[ 7 ] = n23; te[ 8 ] = n33;\n\n\t\treturn this;\n\n\t},\n\n\tidentity: function () {\n\n\t\tthis.set(\n\n\t\t\t1, 0, 0,\n\t\t\t0, 1, 0,\n\t\t\t0, 0, 1\n\n\t\t);\n\n\t\treturn this;\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor().fromArray( this.elements );\n\n\t},\n\n\tcopy: function ( m ) {\n\n\t\tconst te = this.elements;\n\t\tconst me = m.elements;\n\n\t\tte[ 0 ] = me[ 0 ]; te[ 1 ] = me[ 1 ]; te[ 2 ] = me[ 2 ];\n\t\tte[ 3 ] = me[ 3 ]; te[ 4 ] = me[ 4 ]; te[ 5 ] = me[ 5 ];\n\t\tte[ 6 ] = me[ 6 ]; te[ 7 ] = me[ 7 ]; te[ 8 ] = me[ 8 ];\n\n\t\treturn this;\n\n\t},\n\n\textractBasis: function ( xAxis, yAxis, zAxis ) {\n\n\t\txAxis.setFromMatrix3Column( this, 0 );\n\t\tyAxis.setFromMatrix3Column( this, 1 );\n\t\tzAxis.setFromMatrix3Column( this, 2 );\n\n\t\treturn this;\n\n\t},\n\n\tsetFromMatrix4: function ( m ) {\n\n\t\tconst me = m.elements;\n\n\t\tthis.set(\n\n\t\t\tme[ 0 ], me[ 4 ], me[ 8 ],\n\t\t\tme[ 1 ], me[ 5 ], me[ 9 ],\n\t\t\tme[ 2 ], me[ 6 ], me[ 10 ]\n\n\t\t);\n\n\t\treturn this;\n\n\t},\n\n\tmultiply: function ( m ) {\n\n\t\treturn this.multiplyMatrices( this, m );\n\n\t},\n\n\tpremultiply: function ( m ) {\n\n\t\treturn this.multiplyMatrices( m, this );\n\n\t},\n\n\tmultiplyMatrices: function ( a, b ) {\n\n\t\tconst ae = a.elements;\n\t\tconst be = b.elements;\n\t\tconst te = this.elements;\n\n\t\tconst a11 = ae[ 0 ], a12 = ae[ 3 ], a13 = ae[ 6 ];\n\t\tconst a21 = ae[ 1 ], a22 = ae[ 4 ], a23 = ae[ 7 ];\n\t\tconst a31 = ae[ 2 ], a32 = ae[ 5 ], a33 = ae[ 8 ];\n\n\t\tconst b11 = be[ 0 ], b12 = be[ 3 ], b13 = be[ 6 ];\n\t\tconst b21 = be[ 1 ], b22 = be[ 4 ], b23 = be[ 7 ];\n\t\tconst b31 = be[ 2 ], b32 = be[ 5 ], b33 = be[ 8 ];\n\n\t\tte[ 0 ] = a11 * b11 + a12 * b21 + a13 * b31;\n\t\tte[ 3 ] = a11 * b12 + a12 * b22 + a13 * b32;\n\t\tte[ 6 ] = a11 * b13 + a12 * b23 + a13 * b33;\n\n\t\tte[ 1 ] = a21 * b11 + a22 * b21 + a23 * b31;\n\t\tte[ 4 ] = a21 * b12 + a22 * b22 + a23 * b32;\n\t\tte[ 7 ] = a21 * b13 + a22 * b23 + a23 * b33;\n\n\t\tte[ 2 ] = a31 * b11 + a32 * b21 + a33 * b31;\n\t\tte[ 5 ] = a31 * b12 + a32 * b22 + a33 * b32;\n\t\tte[ 8 ] = a31 * b13 + a32 * b23 + a33 * b33;\n\n\t\treturn this;\n\n\t},\n\n\tmultiplyScalar: function ( s ) {\n\n\t\tconst te = this.elements;\n\n\t\tte[ 0 ] *= s; te[ 3 ] *= s; te[ 6 ] *= s;\n\t\tte[ 1 ] *= s; te[ 4 ] *= s; te[ 7 ] *= s;\n\t\tte[ 2 ] *= s; te[ 5 ] *= s; te[ 8 ] *= s;\n\n\t\treturn this;\n\n\t},\n\n\tdeterminant: function () {\n\n\t\tconst te = this.elements;\n\n\t\tconst a = te[ 0 ], b = te[ 1 ], c = te[ 2 ],\n\t\t\td = te[ 3 ], e = te[ 4 ], f = te[ 5 ],\n\t\t\tg = te[ 6 ], h = te[ 7 ], i = te[ 8 ];\n\n\t\treturn a * e * i - a * f * h - b * d * i + b * f * g + c * d * h - c * e * g;\n\n\t},\n\n\tgetInverse: function ( matrix, throwOnDegenerate ) {\n\n\t\tif ( throwOnDegenerate !== undefined ) {\n\n\t\t\tconsole.warn( \"THREE.Matrix3: .getInverse() can no longer be configured to throw on degenerate.\" );\n\n\t\t}\n\n\t\tconst me = matrix.elements,\n\t\t\tte = this.elements,\n\n\t\t\tn11 = me[ 0 ], n21 = me[ 1 ], n31 = me[ 2 ],\n\t\t\tn12 = me[ 3 ], n22 = me[ 4 ], n32 = me[ 5 ],\n\t\t\tn13 = me[ 6 ], n23 = me[ 7 ], n33 = me[ 8 ],\n\n\t\t\tt11 = n33 * n22 - n32 * n23,\n\t\t\tt12 = n32 * n13 - n33 * n12,\n\t\t\tt13 = n23 * n12 - n22 * n13,\n\n\t\t\tdet = n11 * t11 + n21 * t12 + n31 * t13;\n\n\t\tif ( det === 0 ) return this.set( 0, 0, 0, 0, 0, 0, 0, 0, 0 );\n\n\t\tconst detInv = 1 / det;\n\n\t\tte[ 0 ] = t11 * detInv;\n\t\tte[ 1 ] = ( n31 * n23 - n33 * n21 ) * detInv;\n\t\tte[ 2 ] = ( n32 * n21 - n31 * n22 ) * detInv;\n\n\t\tte[ 3 ] = t12 * detInv;\n\t\tte[ 4 ] = ( n33 * n11 - n31 * n13 ) * detInv;\n\t\tte[ 5 ] = ( n31 * n12 - n32 * n11 ) * detInv;\n\n\t\tte[ 6 ] = t13 * detInv;\n\t\tte[ 7 ] = ( n21 * n13 - n23 * n11 ) * detInv;\n\t\tte[ 8 ] = ( n22 * n11 - n21 * n12 ) * detInv;\n\n\t\treturn this;\n\n\t},\n\n\ttranspose: function () {\n\n\t\tlet tmp;\n\t\tconst m = this.elements;\n\n\t\ttmp = m[ 1 ]; m[ 1 ] = m[ 3 ]; m[ 3 ] = tmp;\n\t\ttmp = m[ 2 ]; m[ 2 ] = m[ 6 ]; m[ 6 ] = tmp;\n\t\ttmp = m[ 5 ]; m[ 5 ] = m[ 7 ]; m[ 7 ] = tmp;\n\n\t\treturn this;\n\n\t},\n\n\tgetNormalMatrix: function ( matrix4 ) {\n\n\t\treturn this.setFromMatrix4( matrix4 ).getInverse( this ).transpose();\n\n\t},\n\n\ttransposeIntoArray: function ( r ) {\n\n\t\tconst m = this.elements;\n\n\t\tr[ 0 ] = m[ 0 ];\n\t\tr[ 1 ] = m[ 3 ];\n\t\tr[ 2 ] = m[ 6 ];\n\t\tr[ 3 ] = m[ 1 ];\n\t\tr[ 4 ] = m[ 4 ];\n\t\tr[ 5 ] = m[ 7 ];\n\t\tr[ 6 ] = m[ 2 ];\n\t\tr[ 7 ] = m[ 5 ];\n\t\tr[ 8 ] = m[ 8 ];\n\n\t\treturn this;\n\n\t},\n\n\tsetUvTransform: function ( tx, ty, sx, sy, rotation, cx, cy ) {\n\n\t\tconst c = Math.cos( rotation );\n\t\tconst s = Math.sin( rotation );\n\n\t\tthis.set(\n\t\t\tsx * c, sx * s, - sx * ( c * cx + s * cy ) + cx + tx,\n\t\t\t- sy * s, sy * c, - sy * ( - s * cx + c * cy ) + cy + ty,\n\t\t\t0, 0, 1\n\t\t);\n\n\t},\n\n\tscale: function ( sx, sy ) {\n\n\t\tconst te = this.elements;\n\n\t\tte[ 0 ] *= sx; te[ 3 ] *= sx; te[ 6 ] *= sx;\n\t\tte[ 1 ] *= sy; te[ 4 ] *= sy; te[ 7 ] *= sy;\n\n\t\treturn this;\n\n\t},\n\n\trotate: function ( theta ) {\n\n\t\tconst c = Math.cos( theta );\n\t\tconst s = Math.sin( theta );\n\n\t\tconst te = this.elements;\n\n\t\tconst a11 = te[ 0 ], a12 = te[ 3 ], a13 = te[ 6 ];\n\t\tconst a21 = te[ 1 ], a22 = te[ 4 ], a23 = te[ 7 ];\n\n\t\tte[ 0 ] = c * a11 + s * a21;\n\t\tte[ 3 ] = c * a12 + s * a22;\n\t\tte[ 6 ] = c * a13 + s * a23;\n\n\t\tte[ 1 ] = - s * a11 + c * a21;\n\t\tte[ 4 ] = - s * a12 + c * a22;\n\t\tte[ 7 ] = - s * a13 + c * a23;\n\n\t\treturn this;\n\n\t},\n\n\ttranslate: function ( tx, ty ) {\n\n\t\tconst te = this.elements;\n\n\t\tte[ 0 ] += tx * te[ 2 ]; te[ 3 ] += tx * te[ 5 ]; te[ 6 ] += tx * te[ 8 ];\n\t\tte[ 1 ] += ty * te[ 2 ]; te[ 4 ] += ty * te[ 5 ]; te[ 7 ] += ty * te[ 8 ];\n\n\t\treturn this;\n\n\t},\n\n\tequals: function ( matrix ) {\n\n\t\tconst te = this.elements;\n\t\tconst me = matrix.elements;\n\n\t\tfor ( let i = 0; i < 9; i ++ ) {\n\n\t\t\tif ( te[ i ] !== me[ i ] ) return false;\n\n\t\t}\n\n\t\treturn true;\n\n\t},\n\n\tfromArray: function ( array, offset ) {\n\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tfor ( let i = 0; i < 9; i ++ ) {\n\n\t\t\tthis.elements[ i ] = array[ i + offset ];\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\ttoArray: function ( array, offset ) {\n\n\t\tif ( array === undefined ) array = [];\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tconst te = this.elements;\n\n\t\tarray[ offset ] = te[ 0 ];\n\t\tarray[ offset + 1 ] = te[ 1 ];\n\t\tarray[ offset + 2 ] = te[ 2 ];\n\n\t\tarray[ offset + 3 ] = te[ 3 ];\n\t\tarray[ offset + 4 ] = te[ 4 ];\n\t\tarray[ offset + 5 ] = te[ 5 ];\n\n\t\tarray[ offset + 6 ] = te[ 6 ];\n\t\tarray[ offset + 7 ] = te[ 7 ];\n\t\tarray[ offset + 8 ] = te[ 8 ];\n\n\t\treturn array;\n\n\t}\n\n} );\n\n\nexport { Matrix3 };\n","/**\n * @author mrdoob / http://mrdoob.com/\n * @author alteredq / http://alteredqualia.com/\n * @author szimek / https://github.com/szimek/\n */\n\nlet _canvas;\n\nconst ImageUtils = {\n\n\tgetDataURL: function ( image ) {\n\n\t\tif ( /^data:/i.test( image.src ) ) {\n\n\t\t\treturn image.src;\n\n\t\t}\n\n\t\tif ( typeof HTMLCanvasElement == 'undefined' ) {\n\n\t\t\treturn image.src;\n\n\t\t}\n\n\t\tlet canvas;\n\n\t\tif ( image instanceof HTMLCanvasElement ) {\n\n\t\t\tcanvas = image;\n\n\t\t} else {\n\n\t\t\tif ( _canvas === undefined ) _canvas = document.createElementNS( 'http://www.w3.org/1999/xhtml', 'canvas' );\n\n\t\t\t_canvas.width = image.width;\n\t\t\t_canvas.height = image.height;\n\n\t\t\tconst context = _canvas.getContext( '2d' );\n\n\t\t\tif ( image instanceof ImageData ) {\n\n\t\t\t\tcontext.putImageData( image, 0, 0 );\n\n\t\t\t} else {\n\n\t\t\t\tcontext.drawImage( image, 0, 0, image.width, image.height );\n\n\t\t\t}\n\n\t\t\tcanvas = _canvas;\n\n\t\t}\n\n\t\tif ( canvas.width > 2048 || canvas.height > 2048 ) {\n\n\t\t\treturn canvas.toDataURL( 'image/jpeg', 0.6 );\n\n\t\t} else {\n\n\t\t\treturn canvas.toDataURL( 'image/png' );\n\n\t\t}\n\n\t}\n\n};\n\nexport { ImageUtils };\n","/**\n * @author mrdoob / http://mrdoob.com/\n * @author alteredq / http://alteredqualia.com/\n * @author szimek / https://github.com/szimek/\n */\n\nimport { EventDispatcher } from '../core/EventDispatcher.js';\nimport {\n\tMirroredRepeatWrapping,\n\tClampToEdgeWrapping,\n\tRepeatWrapping,\n\tLinearEncoding,\n\tUnsignedByteType,\n\tRGBAFormat,\n\tLinearMipmapLinearFilter,\n\tLinearFilter,\n\tUVMapping\n} from '../constants.js';\nimport { MathUtils } from '../math/MathUtils.js';\nimport { Vector2 } from '../math/Vector2.js';\nimport { Matrix3 } from '../math/Matrix3.js';\nimport { ImageUtils } from '../extras/ImageUtils.js';\n\nlet textureId = 0;\n\nfunction Texture( image, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ) {\n\n\tObject.defineProperty( this, 'id', { value: textureId ++ } );\n\n\tthis.uuid = MathUtils.generateUUID();\n\n\tthis.name = '';\n\n\tthis.image = image !== undefined ? image : Texture.DEFAULT_IMAGE;\n\tthis.mipmaps = [];\n\n\tthis.mapping = mapping !== undefined ? mapping : Texture.DEFAULT_MAPPING;\n\n\tthis.wrapS = wrapS !== undefined ? wrapS : ClampToEdgeWrapping;\n\tthis.wrapT = wrapT !== undefined ? wrapT : ClampToEdgeWrapping;\n\n\tthis.magFilter = magFilter !== undefined ? magFilter : LinearFilter;\n\tthis.minFilter = minFilter !== undefined ? minFilter : LinearMipmapLinearFilter;\n\n\tthis.anisotropy = anisotropy !== undefined ? anisotropy : 1;\n\n\tthis.format = format !== undefined ? format : RGBAFormat;\n\tthis.internalFormat = null;\n\tthis.type = type !== undefined ? type : UnsignedByteType;\n\n\tthis.offset = new Vector2( 0, 0 );\n\tthis.repeat = new Vector2( 1, 1 );\n\tthis.center = new Vector2( 0, 0 );\n\tthis.rotation = 0;\n\n\tthis.matrixAutoUpdate = true;\n\tthis.matrix = new Matrix3();\n\n\tthis.generateMipmaps = true;\n\tthis.premultiplyAlpha = false;\n\tthis.flipY = true;\n\tthis.unpackAlignment = 4;\t// valid values: 1, 2, 4, 8 (see http://www.khronos.org/opengles/sdk/docs/man/xhtml/glPixelStorei.xml)\n\n\t// Values of encoding !== THREE.LinearEncoding only supported on map, envMap and emissiveMap.\n\t//\n\t// Also changing the encoding after already used by a Material will not automatically make the Material\n\t// update. You need to explicitly call Material.needsUpdate to trigger it to recompile.\n\tthis.encoding = encoding !== undefined ? encoding : LinearEncoding;\n\n\tthis.version = 0;\n\tthis.onUpdate = null;\n\n}\n\nTexture.DEFAULT_IMAGE = undefined;\nTexture.DEFAULT_MAPPING = UVMapping;\n\nTexture.prototype = Object.assign( Object.create( EventDispatcher.prototype ), {\n\n\tconstructor: Texture,\n\n\tisTexture: true,\n\n\tupdateMatrix: function () {\n\n\t\tthis.matrix.setUvTransform( this.offset.x, this.offset.y, this.repeat.x, this.repeat.y, this.rotation, this.center.x, this.center.y );\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor().copy( this );\n\n\t},\n\n\tcopy: function ( source ) {\n\n\t\tthis.name = source.name;\n\n\t\tthis.image = source.image;\n\t\tthis.mipmaps = source.mipmaps.slice( 0 );\n\n\t\tthis.mapping = source.mapping;\n\n\t\tthis.wrapS = source.wrapS;\n\t\tthis.wrapT = source.wrapT;\n\n\t\tthis.magFilter = source.magFilter;\n\t\tthis.minFilter = source.minFilter;\n\n\t\tthis.anisotropy = source.anisotropy;\n\n\t\tthis.format = source.format;\n\t\tthis.internalFormat = source.internalFormat;\n\t\tthis.type = source.type;\n\n\t\tthis.offset.copy( source.offset );\n\t\tthis.repeat.copy( source.repeat );\n\t\tthis.center.copy( source.center );\n\t\tthis.rotation = source.rotation;\n\n\t\tthis.matrixAutoUpdate = source.matrixAutoUpdate;\n\t\tthis.matrix.copy( source.matrix );\n\n\t\tthis.generateMipmaps = source.generateMipmaps;\n\t\tthis.premultiplyAlpha = source.premultiplyAlpha;\n\t\tthis.flipY = source.flipY;\n\t\tthis.unpackAlignment = source.unpackAlignment;\n\t\tthis.encoding = source.encoding;\n\n\t\treturn this;\n\n\t},\n\n\ttoJSON: function ( meta ) {\n\n\t\tconst isRootObject = ( meta === undefined || typeof meta === 'string' );\n\n\t\tif ( ! isRootObject && meta.textures[ this.uuid ] !== undefined ) {\n\n\t\t\treturn meta.textures[ this.uuid ];\n\n\t\t}\n\n\t\tconst output = {\n\n\t\t\tmetadata: {\n\t\t\t\tversion: 4.5,\n\t\t\t\ttype: 'Texture',\n\t\t\t\tgenerator: 'Texture.toJSON'\n\t\t\t},\n\n\t\t\tuuid: this.uuid,\n\t\t\tname: this.name,\n\n\t\t\tmapping: this.mapping,\n\n\t\t\trepeat: [ this.repeat.x, this.repeat.y ],\n\t\t\toffset: [ this.offset.x, this.offset.y ],\n\t\t\tcenter: [ this.center.x, this.center.y ],\n\t\t\trotation: this.rotation,\n\n\t\t\twrap: [ this.wrapS, this.wrapT ],\n\n\t\t\tformat: this.format,\n\t\t\ttype: this.type,\n\t\t\tencoding: this.encoding,\n\n\t\t\tminFilter: this.minFilter,\n\t\t\tmagFilter: this.magFilter,\n\t\t\tanisotropy: this.anisotropy,\n\n\t\t\tflipY: this.flipY,\n\n\t\t\tpremultiplyAlpha: this.premultiplyAlpha,\n\t\t\tunpackAlignment: this.unpackAlignment\n\n\t\t};\n\n\t\tif ( this.image !== undefined ) {\n\n\t\t\t// TODO: Move to THREE.Image\n\n\t\t\tconst image = this.image;\n\n\t\t\tif ( image.uuid === undefined ) {\n\n\t\t\t\timage.uuid = MathUtils.generateUUID(); // UGH\n\n\t\t\t}\n\n\t\t\tif ( ! isRootObject && meta.images[ image.uuid ] === undefined ) {\n\n\t\t\t\tlet url;\n\n\t\t\t\tif ( Array.isArray( image ) ) {\n\n\t\t\t\t\t// process array of images e.g. CubeTexture\n\n\t\t\t\t\turl = [];\n\n\t\t\t\t\tfor ( let i = 0, l = image.length; i < l; i ++ ) {\n\n\t\t\t\t\t\turl.push( ImageUtils.getDataURL( image[ i ] ) );\n\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\n\t\t\t\t\t// process single image\n\n\t\t\t\t\turl = ImageUtils.getDataURL( image );\n\n\t\t\t\t}\n\n\t\t\t\tmeta.images[ image.uuid ] = {\n\t\t\t\t\tuuid: image.uuid,\n\t\t\t\t\turl: url\n\t\t\t\t};\n\n\t\t\t}\n\n\t\t\toutput.image = image.uuid;\n\n\t\t}\n\n\t\tif ( ! isRootObject ) {\n\n\t\t\tmeta.textures[ this.uuid ] = output;\n\n\t\t}\n\n\t\treturn output;\n\n\t},\n\n\tdispose: function () {\n\n\t\tthis.dispatchEvent( { type: 'dispose' } );\n\n\t},\n\n\ttransformUv: function ( uv ) {\n\n\t\tif ( this.mapping !== UVMapping ) return uv;\n\n\t\tuv.applyMatrix3( this.matrix );\n\n\t\tif ( uv.x < 0 || uv.x > 1 ) {\n\n\t\t\tswitch ( this.wrapS ) {\n\n\t\t\t\tcase RepeatWrapping:\n\n\t\t\t\t\tuv.x = uv.x - Math.floor( uv.x );\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase ClampToEdgeWrapping:\n\n\t\t\t\t\tuv.x = uv.x < 0 ? 0 : 1;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase MirroredRepeatWrapping:\n\n\t\t\t\t\tif ( Math.abs( Math.floor( uv.x ) % 2 ) === 1 ) {\n\n\t\t\t\t\t\tuv.x = Math.ceil( uv.x ) - uv.x;\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tuv.x = uv.x - Math.floor( uv.x );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( uv.y < 0 || uv.y > 1 ) {\n\n\t\t\tswitch ( this.wrapT ) {\n\n\t\t\t\tcase RepeatWrapping:\n\n\t\t\t\t\tuv.y = uv.y - Math.floor( uv.y );\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase ClampToEdgeWrapping:\n\n\t\t\t\t\tuv.y = uv.y < 0 ? 0 : 1;\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase MirroredRepeatWrapping:\n\n\t\t\t\t\tif ( Math.abs( Math.floor( uv.y ) % 2 ) === 1 ) {\n\n\t\t\t\t\t\tuv.y = Math.ceil( uv.y ) - uv.y;\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tuv.y = uv.y - Math.floor( uv.y );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( this.flipY ) {\n\n\t\t\tuv.y = 1 - uv.y;\n\n\t\t}\n\n\t\treturn uv;\n\n\t}\n\n} );\n\nObject.defineProperty( Texture.prototype, \"needsUpdate\", {\n\n\tset: function ( value ) {\n\n\t\tif ( value === true ) this.version ++;\n\n\t}\n\n} );\n\n\nexport { Texture };\n","/**\n * @author supereggbert / http://www.paulbrunt.co.uk/\n * @author philogb / http://blog.thejit.org/\n * @author mikael emtinger / http://gomo.se/\n * @author egraether / http://egraether.com/\n * @author WestLangley / http://github.com/WestLangley\n */\n\nfunction Vector4( x = 0, y = 0, z = 0, w = 1 ) {\n\n\tthis.x = x;\n\tthis.y = y;\n\tthis.z = z;\n\tthis.w = w;\n\n}\n\nObject.defineProperties( Vector4.prototype, {\n\n\t\"width\": {\n\n\t\tget: function () {\n\n\t\t\treturn this.z;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tthis.z = value;\n\n\t\t}\n\n\t},\n\n\t\"height\": {\n\n\t\tget: function () {\n\n\t\t\treturn this.w;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tthis.w = value;\n\n\t\t}\n\n\t}\n\n} );\n\nObject.assign( Vector4.prototype, {\n\n\tisVector4: true,\n\n\tset: function ( x, y, z, w ) {\n\n\t\tthis.x = x;\n\t\tthis.y = y;\n\t\tthis.z = z;\n\t\tthis.w = w;\n\n\t\treturn this;\n\n\t},\n\n\tsetScalar: function ( scalar ) {\n\n\t\tthis.x = scalar;\n\t\tthis.y = scalar;\n\t\tthis.z = scalar;\n\t\tthis.w = scalar;\n\n\t\treturn this;\n\n\t},\n\n\tsetX: function ( x ) {\n\n\t\tthis.x = x;\n\n\t\treturn this;\n\n\t},\n\n\tsetY: function ( y ) {\n\n\t\tthis.y = y;\n\n\t\treturn this;\n\n\t},\n\n\tsetZ: function ( z ) {\n\n\t\tthis.z = z;\n\n\t\treturn this;\n\n\t},\n\n\tsetW: function ( w ) {\n\n\t\tthis.w = w;\n\n\t\treturn this;\n\n\t},\n\n\tsetComponent: function ( index, value ) {\n\n\t\tswitch ( index ) {\n\n\t\t\tcase 0: this.x = value; break;\n\t\t\tcase 1: this.y = value; break;\n\t\t\tcase 2: this.z = value; break;\n\t\t\tcase 3: this.w = value; break;\n\t\t\tdefault: throw new Error( 'index is out of range: ' + index );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tgetComponent: function ( index ) {\n\n\t\tswitch ( index ) {\n\n\t\t\tcase 0: return this.x;\n\t\t\tcase 1: return this.y;\n\t\t\tcase 2: return this.z;\n\t\t\tcase 3: return this.w;\n\t\t\tdefault: throw new Error( 'index is out of range: ' + index );\n\n\t\t}\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor( this.x, this.y, this.z, this.w );\n\n\t},\n\n\tcopy: function ( v ) {\n\n\t\tthis.x = v.x;\n\t\tthis.y = v.y;\n\t\tthis.z = v.z;\n\t\tthis.w = ( v.w !== undefined ) ? v.w : 1;\n\n\t\treturn this;\n\n\t},\n\n\tadd: function ( v, w ) {\n\n\t\tif ( w !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead.' );\n\t\t\treturn this.addVectors( v, w );\n\n\t\t}\n\n\t\tthis.x += v.x;\n\t\tthis.y += v.y;\n\t\tthis.z += v.z;\n\t\tthis.w += v.w;\n\n\t\treturn this;\n\n\t},\n\n\taddScalar: function ( s ) {\n\n\t\tthis.x += s;\n\t\tthis.y += s;\n\t\tthis.z += s;\n\t\tthis.w += s;\n\n\t\treturn this;\n\n\t},\n\n\taddVectors: function ( a, b ) {\n\n\t\tthis.x = a.x + b.x;\n\t\tthis.y = a.y + b.y;\n\t\tthis.z = a.z + b.z;\n\t\tthis.w = a.w + b.w;\n\n\t\treturn this;\n\n\t},\n\n\taddScaledVector: function ( v, s ) {\n\n\t\tthis.x += v.x * s;\n\t\tthis.y += v.y * s;\n\t\tthis.z += v.z * s;\n\t\tthis.w += v.w * s;\n\n\t\treturn this;\n\n\t},\n\n\tsub: function ( v, w ) {\n\n\t\tif ( w !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.' );\n\t\t\treturn this.subVectors( v, w );\n\n\t\t}\n\n\t\tthis.x -= v.x;\n\t\tthis.y -= v.y;\n\t\tthis.z -= v.z;\n\t\tthis.w -= v.w;\n\n\t\treturn this;\n\n\t},\n\n\tsubScalar: function ( s ) {\n\n\t\tthis.x -= s;\n\t\tthis.y -= s;\n\t\tthis.z -= s;\n\t\tthis.w -= s;\n\n\t\treturn this;\n\n\t},\n\n\tsubVectors: function ( a, b ) {\n\n\t\tthis.x = a.x - b.x;\n\t\tthis.y = a.y - b.y;\n\t\tthis.z = a.z - b.z;\n\t\tthis.w = a.w - b.w;\n\n\t\treturn this;\n\n\t},\n\n\tmultiplyScalar: function ( scalar ) {\n\n\t\tthis.x *= scalar;\n\t\tthis.y *= scalar;\n\t\tthis.z *= scalar;\n\t\tthis.w *= scalar;\n\n\t\treturn this;\n\n\t},\n\n\tapplyMatrix4: function ( m ) {\n\n\t\tconst x = this.x, y = this.y, z = this.z, w = this.w;\n\t\tconst e = m.elements;\n\n\t\tthis.x = e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z + e[ 12 ] * w;\n\t\tthis.y = e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z + e[ 13 ] * w;\n\t\tthis.z = e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z + e[ 14 ] * w;\n\t\tthis.w = e[ 3 ] * x + e[ 7 ] * y + e[ 11 ] * z + e[ 15 ] * w;\n\n\t\treturn this;\n\n\t},\n\n\tdivideScalar: function ( scalar ) {\n\n\t\treturn this.multiplyScalar( 1 / scalar );\n\n\t},\n\n\tsetAxisAngleFromQuaternion: function ( q ) {\n\n\t\t// http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToAngle/index.htm\n\n\t\t// q is assumed to be normalized\n\n\t\tthis.w = 2 * Math.acos( q.w );\n\n\t\tconst s = Math.sqrt( 1 - q.w * q.w );\n\n\t\tif ( s < 0.0001 ) {\n\n\t\t\tthis.x = 1;\n\t\t\tthis.y = 0;\n\t\t\tthis.z = 0;\n\n\t\t} else {\n\n\t\t\tthis.x = q.x / s;\n\t\t\tthis.y = q.y / s;\n\t\t\tthis.z = q.z / s;\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tsetAxisAngleFromRotationMatrix: function ( m ) {\n\n\t\t// http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToAngle/index.htm\n\n\t\t// assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)\n\n\t\tlet angle, x, y, z; // variables for result\n\t\tconst epsilon = 0.01,\t\t// margin to allow for rounding errors\n\t\t\tepsilon2 = 0.1,\t\t// margin to distinguish between 0 and 180 degrees\n\n\t\t\tte = m.elements,\n\n\t\t\tm11 = te[ 0 ], m12 = te[ 4 ], m13 = te[ 8 ],\n\t\t\tm21 = te[ 1 ], m22 = te[ 5 ], m23 = te[ 9 ],\n\t\t\tm31 = te[ 2 ], m32 = te[ 6 ], m33 = te[ 10 ];\n\n\t\tif ( ( Math.abs( m12 - m21 ) < epsilon ) &&\n\t\t ( Math.abs( m13 - m31 ) < epsilon ) &&\n\t\t ( Math.abs( m23 - m32 ) < epsilon ) ) {\n\n\t\t\t// singularity found\n\t\t\t// first check for identity matrix which must have +1 for all terms\n\t\t\t// in leading diagonal and zero in other terms\n\n\t\t\tif ( ( Math.abs( m12 + m21 ) < epsilon2 ) &&\n\t\t\t ( Math.abs( m13 + m31 ) < epsilon2 ) &&\n\t\t\t ( Math.abs( m23 + m32 ) < epsilon2 ) &&\n\t\t\t ( Math.abs( m11 + m22 + m33 - 3 ) < epsilon2 ) ) {\n\n\t\t\t\t// this singularity is identity matrix so angle = 0\n\n\t\t\t\tthis.set( 1, 0, 0, 0 );\n\n\t\t\t\treturn this; // zero angle, arbitrary axis\n\n\t\t\t}\n\n\t\t\t// otherwise this singularity is angle = 180\n\n\t\t\tangle = Math.PI;\n\n\t\t\tconst xx = ( m11 + 1 ) / 2;\n\t\t\tconst yy = ( m22 + 1 ) / 2;\n\t\t\tconst zz = ( m33 + 1 ) / 2;\n\t\t\tconst xy = ( m12 + m21 ) / 4;\n\t\t\tconst xz = ( m13 + m31 ) / 4;\n\t\t\tconst yz = ( m23 + m32 ) / 4;\n\n\t\t\tif ( ( xx > yy ) && ( xx > zz ) ) {\n\n\t\t\t\t// m11 is the largest diagonal term\n\n\t\t\t\tif ( xx < epsilon ) {\n\n\t\t\t\t\tx = 0;\n\t\t\t\t\ty = 0.707106781;\n\t\t\t\t\tz = 0.707106781;\n\n\t\t\t\t} else {\n\n\t\t\t\t\tx = Math.sqrt( xx );\n\t\t\t\t\ty = xy / x;\n\t\t\t\t\tz = xz / x;\n\n\t\t\t\t}\n\n\t\t\t} else if ( yy > zz ) {\n\n\t\t\t\t// m22 is the largest diagonal term\n\n\t\t\t\tif ( yy < epsilon ) {\n\n\t\t\t\t\tx = 0.707106781;\n\t\t\t\t\ty = 0;\n\t\t\t\t\tz = 0.707106781;\n\n\t\t\t\t} else {\n\n\t\t\t\t\ty = Math.sqrt( yy );\n\t\t\t\t\tx = xy / y;\n\t\t\t\t\tz = yz / y;\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\t// m33 is the largest diagonal term so base result on this\n\n\t\t\t\tif ( zz < epsilon ) {\n\n\t\t\t\t\tx = 0.707106781;\n\t\t\t\t\ty = 0.707106781;\n\t\t\t\t\tz = 0;\n\n\t\t\t\t} else {\n\n\t\t\t\t\tz = Math.sqrt( zz );\n\t\t\t\t\tx = xz / z;\n\t\t\t\t\ty = yz / z;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tthis.set( x, y, z, angle );\n\n\t\t\treturn this; // return 180 deg rotation\n\n\t\t}\n\n\t\t// as we have reached here there are no singularities so we can handle normally\n\n\t\tlet s = Math.sqrt( ( m32 - m23 ) * ( m32 - m23 ) +\n\t\t\t( m13 - m31 ) * ( m13 - m31 ) +\n\t\t\t( m21 - m12 ) * ( m21 - m12 ) ); // used to normalize\n\n\t\tif ( Math.abs( s ) < 0.001 ) s = 1;\n\n\t\t// prevent divide by zero, should not happen if matrix is orthogonal and should be\n\t\t// caught by singularity test above, but I've left it in just in case\n\n\t\tthis.x = ( m32 - m23 ) / s;\n\t\tthis.y = ( m13 - m31 ) / s;\n\t\tthis.z = ( m21 - m12 ) / s;\n\t\tthis.w = Math.acos( ( m11 + m22 + m33 - 1 ) / 2 );\n\n\t\treturn this;\n\n\t},\n\n\tmin: function ( v ) {\n\n\t\tthis.x = Math.min( this.x, v.x );\n\t\tthis.y = Math.min( this.y, v.y );\n\t\tthis.z = Math.min( this.z, v.z );\n\t\tthis.w = Math.min( this.w, v.w );\n\n\t\treturn this;\n\n\t},\n\n\tmax: function ( v ) {\n\n\t\tthis.x = Math.max( this.x, v.x );\n\t\tthis.y = Math.max( this.y, v.y );\n\t\tthis.z = Math.max( this.z, v.z );\n\t\tthis.w = Math.max( this.w, v.w );\n\n\t\treturn this;\n\n\t},\n\n\tclamp: function ( min, max ) {\n\n\t\t// assumes min < max, componentwise\n\n\t\tthis.x = Math.max( min.x, Math.min( max.x, this.x ) );\n\t\tthis.y = Math.max( min.y, Math.min( max.y, this.y ) );\n\t\tthis.z = Math.max( min.z, Math.min( max.z, this.z ) );\n\t\tthis.w = Math.max( min.w, Math.min( max.w, this.w ) );\n\n\t\treturn this;\n\n\t},\n\n\tclampScalar: function ( minVal, maxVal ) {\n\n\t\tthis.x = Math.max( minVal, Math.min( maxVal, this.x ) );\n\t\tthis.y = Math.max( minVal, Math.min( maxVal, this.y ) );\n\t\tthis.z = Math.max( minVal, Math.min( maxVal, this.z ) );\n\t\tthis.w = Math.max( minVal, Math.min( maxVal, this.w ) );\n\n\t\treturn this;\n\n\t},\n\n\tclampLength: function ( min, max ) {\n\n\t\tconst length = this.length();\n\n\t\treturn this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) );\n\n\t},\n\n\tfloor: function () {\n\n\t\tthis.x = Math.floor( this.x );\n\t\tthis.y = Math.floor( this.y );\n\t\tthis.z = Math.floor( this.z );\n\t\tthis.w = Math.floor( this.w );\n\n\t\treturn this;\n\n\t},\n\n\tceil: function () {\n\n\t\tthis.x = Math.ceil( this.x );\n\t\tthis.y = Math.ceil( this.y );\n\t\tthis.z = Math.ceil( this.z );\n\t\tthis.w = Math.ceil( this.w );\n\n\t\treturn this;\n\n\t},\n\n\tround: function () {\n\n\t\tthis.x = Math.round( this.x );\n\t\tthis.y = Math.round( this.y );\n\t\tthis.z = Math.round( this.z );\n\t\tthis.w = Math.round( this.w );\n\n\t\treturn this;\n\n\t},\n\n\troundToZero: function () {\n\n\t\tthis.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x );\n\t\tthis.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y );\n\t\tthis.z = ( this.z < 0 ) ? Math.ceil( this.z ) : Math.floor( this.z );\n\t\tthis.w = ( this.w < 0 ) ? Math.ceil( this.w ) : Math.floor( this.w );\n\n\t\treturn this;\n\n\t},\n\n\tnegate: function () {\n\n\t\tthis.x = - this.x;\n\t\tthis.y = - this.y;\n\t\tthis.z = - this.z;\n\t\tthis.w = - this.w;\n\n\t\treturn this;\n\n\t},\n\n\tdot: function ( v ) {\n\n\t\treturn this.x * v.x + this.y * v.y + this.z * v.z + this.w * v.w;\n\n\t},\n\n\tlengthSq: function () {\n\n\t\treturn this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w;\n\n\t},\n\n\tlength: function () {\n\n\t\treturn Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w );\n\n\t},\n\n\tmanhattanLength: function () {\n\n\t\treturn Math.abs( this.x ) + Math.abs( this.y ) + Math.abs( this.z ) + Math.abs( this.w );\n\n\t},\n\n\tnormalize: function () {\n\n\t\treturn this.divideScalar( this.length() || 1 );\n\n\t},\n\n\tsetLength: function ( length ) {\n\n\t\treturn this.normalize().multiplyScalar( length );\n\n\t},\n\n\tlerp: function ( v, alpha ) {\n\n\t\tthis.x += ( v.x - this.x ) * alpha;\n\t\tthis.y += ( v.y - this.y ) * alpha;\n\t\tthis.z += ( v.z - this.z ) * alpha;\n\t\tthis.w += ( v.w - this.w ) * alpha;\n\n\t\treturn this;\n\n\t},\n\n\tlerpVectors: function ( v1, v2, alpha ) {\n\n\t\tthis.x = v1.x + ( v2.x - v1.x ) * alpha;\n\t\tthis.y = v1.y + ( v2.y - v1.y ) * alpha;\n\t\tthis.z = v1.z + ( v2.z - v1.z ) * alpha;\n\t\tthis.w = v1.w + ( v2.w - v1.w ) * alpha;\n\n\t\treturn this;\n\n\t},\n\n\tequals: function ( v ) {\n\n\t\treturn ( ( v.x === this.x ) && ( v.y === this.y ) && ( v.z === this.z ) && ( v.w === this.w ) );\n\n\t},\n\n\tfromArray: function ( array, offset ) {\n\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tthis.x = array[ offset ];\n\t\tthis.y = array[ offset + 1 ];\n\t\tthis.z = array[ offset + 2 ];\n\t\tthis.w = array[ offset + 3 ];\n\n\t\treturn this;\n\n\t},\n\n\ttoArray: function ( array, offset ) {\n\n\t\tif ( array === undefined ) array = [];\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tarray[ offset ] = this.x;\n\t\tarray[ offset + 1 ] = this.y;\n\t\tarray[ offset + 2 ] = this.z;\n\t\tarray[ offset + 3 ] = this.w;\n\n\t\treturn array;\n\n\t},\n\n\tfromBufferAttribute: function ( attribute, index, offset ) {\n\n\t\tif ( offset !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Vector4: offset has been removed from .fromBufferAttribute().' );\n\n\t\t}\n\n\t\tthis.x = attribute.getX( index );\n\t\tthis.y = attribute.getY( index );\n\t\tthis.z = attribute.getZ( index );\n\t\tthis.w = attribute.getW( index );\n\n\t\treturn this;\n\n\t},\n\n\trandom: function () {\n\n\t\tthis.x = Math.random();\n\t\tthis.y = Math.random();\n\t\tthis.z = Math.random();\n\t\tthis.w = Math.random();\n\n\t\treturn this;\n\n\t}\n\n} );\n\n\nexport { Vector4 };\n","import { EventDispatcher } from '../core/EventDispatcher.js';\nimport { Texture } from '../textures/Texture.js';\nimport { LinearFilter } from '../constants.js';\nimport { Vector4 } from '../math/Vector4.js';\n\n/**\n * @author szimek / https://github.com/szimek/\n * @author alteredq / http://alteredqualia.com/\n * @author Marius Kintel / https://github.com/kintel\n */\n\n/*\n In options, we can specify:\n * Texture parameters for an auto-generated target texture\n * depthBuffer/stencilBuffer: Booleans to indicate if we should generate these buffers\n*/\nfunction WebGLRenderTarget( width, height, options ) {\n\n\tthis.width = width;\n\tthis.height = height;\n\n\tthis.scissor = new Vector4( 0, 0, width, height );\n\tthis.scissorTest = false;\n\n\tthis.viewport = new Vector4( 0, 0, width, height );\n\n\toptions = options || {};\n\n\tthis.texture = new Texture( undefined, options.mapping, options.wrapS, options.wrapT, options.magFilter, options.minFilter, options.format, options.type, options.anisotropy, options.encoding );\n\n\tthis.texture.image = {};\n\tthis.texture.image.width = width;\n\tthis.texture.image.height = height;\n\n\tthis.texture.generateMipmaps = options.generateMipmaps !== undefined ? options.generateMipmaps : false;\n\tthis.texture.minFilter = options.minFilter !== undefined ? options.minFilter : LinearFilter;\n\n\tthis.depthBuffer = options.depthBuffer !== undefined ? options.depthBuffer : true;\n\tthis.stencilBuffer = options.stencilBuffer !== undefined ? options.stencilBuffer : true;\n\tthis.depthTexture = options.depthTexture !== undefined ? options.depthTexture : null;\n\n}\n\nWebGLRenderTarget.prototype = Object.assign( Object.create( EventDispatcher.prototype ), {\n\n\tconstructor: WebGLRenderTarget,\n\n\tisWebGLRenderTarget: true,\n\n\tsetSize: function ( width, height ) {\n\n\t\tif ( this.width !== width || this.height !== height ) {\n\n\t\t\tthis.width = width;\n\t\t\tthis.height = height;\n\n\t\t\tthis.texture.image.width = width;\n\t\t\tthis.texture.image.height = height;\n\n\t\t\tthis.dispose();\n\n\t\t}\n\n\t\tthis.viewport.set( 0, 0, width, height );\n\t\tthis.scissor.set( 0, 0, width, height );\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor().copy( this );\n\n\t},\n\n\tcopy: function ( source ) {\n\n\t\tthis.width = source.width;\n\t\tthis.height = source.height;\n\n\t\tthis.viewport.copy( source.viewport );\n\n\t\tthis.texture = source.texture.clone();\n\n\t\tthis.depthBuffer = source.depthBuffer;\n\t\tthis.stencilBuffer = source.stencilBuffer;\n\t\tthis.depthTexture = source.depthTexture;\n\n\t\treturn this;\n\n\t},\n\n\tdispose: function () {\n\n\t\tthis.dispatchEvent( { type: 'dispose' } );\n\n\t}\n\n} );\n\n\nexport { WebGLRenderTarget };\n","/**\n * @author mikael emtinger / http://gomo.se/\n * @author alteredq / http://alteredqualia.com/\n * @author WestLangley / http://github.com/WestLangley\n * @author bhouston / http://clara.io\n */\n\nimport { MathUtils } from './MathUtils.js';\n\nfunction Quaternion( x = 0, y = 0, z = 0, w = 1 ) {\n\n\tthis._x = x;\n\tthis._y = y;\n\tthis._z = z;\n\tthis._w = w;\n\n}\n\nObject.assign( Quaternion, {\n\n\tslerp: function ( qa, qb, qm, t ) {\n\n\t\treturn qm.copy( qa ).slerp( qb, t );\n\n\t},\n\n\tslerpFlat: function ( dst, dstOffset, src0, srcOffset0, src1, srcOffset1, t ) {\n\n\t\t// fuzz-free, array-based Quaternion SLERP operation\n\n\t\tlet x0 = src0[ srcOffset0 + 0 ],\n\t\t\ty0 = src0[ srcOffset0 + 1 ],\n\t\t\tz0 = src0[ srcOffset0 + 2 ],\n\t\t\tw0 = src0[ srcOffset0 + 3 ];\n\n\t\tconst x1 = src1[ srcOffset1 + 0 ],\n\t\t\ty1 = src1[ srcOffset1 + 1 ],\n\t\t\tz1 = src1[ srcOffset1 + 2 ],\n\t\t\tw1 = src1[ srcOffset1 + 3 ];\n\n\t\tif ( w0 !== w1 || x0 !== x1 || y0 !== y1 || z0 !== z1 ) {\n\n\t\t\tlet s = 1 - t,\n\n\t\t\t\tcos = x0 * x1 + y0 * y1 + z0 * z1 + w0 * w1,\n\n\t\t\t\tdir = ( cos >= 0 ? 1 : - 1 ),\n\t\t\t\tsqrSin = 1 - cos * cos;\n\n\t\t\t// Skip the Slerp for tiny steps to avoid numeric problems:\n\t\t\tif ( sqrSin > Number.EPSILON ) {\n\n\t\t\t\tconst sin = Math.sqrt( sqrSin ),\n\t\t\t\t\tlen = Math.atan2( sin, cos * dir );\n\n\t\t\t\ts = Math.sin( s * len ) / sin;\n\t\t\t\tt = Math.sin( t * len ) / sin;\n\n\t\t\t}\n\n\t\t\tconst tDir = t * dir;\n\n\t\t\tx0 = x0 * s + x1 * tDir;\n\t\t\ty0 = y0 * s + y1 * tDir;\n\t\t\tz0 = z0 * s + z1 * tDir;\n\t\t\tw0 = w0 * s + w1 * tDir;\n\n\t\t\t// Normalize in case we just did a lerp:\n\t\t\tif ( s === 1 - t ) {\n\n\t\t\t\tconst f = 1 / Math.sqrt( x0 * x0 + y0 * y0 + z0 * z0 + w0 * w0 );\n\n\t\t\t\tx0 *= f;\n\t\t\t\ty0 *= f;\n\t\t\t\tz0 *= f;\n\t\t\t\tw0 *= f;\n\n\t\t\t}\n\n\t\t}\n\n\t\tdst[ dstOffset ] = x0;\n\t\tdst[ dstOffset + 1 ] = y0;\n\t\tdst[ dstOffset + 2 ] = z0;\n\t\tdst[ dstOffset + 3 ] = w0;\n\n\t},\n\n\tmultiplyQuaternionsFlat: function ( dst, dstOffset, src0, srcOffset0, src1, srcOffset1 ) {\n\n\t\tconst x0 = src0[ srcOffset0 ];\n\t\tconst y0 = src0[ srcOffset0 + 1 ];\n\t\tconst z0 = src0[ srcOffset0 + 2 ];\n\t\tconst w0 = src0[ srcOffset0 + 3 ];\n\n\t\tconst x1 = src1[ srcOffset1 ];\n\t\tconst y1 = src1[ srcOffset1 + 1 ];\n\t\tconst z1 = src1[ srcOffset1 + 2 ];\n\t\tconst w1 = src1[ srcOffset1 + 3 ];\n\n\t\tdst[ dstOffset ] = x0 * w1 + w0 * x1 + y0 * z1 - z0 * y1;\n\t\tdst[ dstOffset + 1 ] = y0 * w1 + w0 * y1 + z0 * x1 - x0 * z1;\n\t\tdst[ dstOffset + 2 ] = z0 * w1 + w0 * z1 + x0 * y1 - y0 * x1;\n\t\tdst[ dstOffset + 3 ] = w0 * w1 - x0 * x1 - y0 * y1 - z0 * z1;\n\n\t\treturn dst;\n\n\t}\n\n} );\n\nObject.defineProperties( Quaternion.prototype, {\n\n\tx: {\n\n\t\tget: function () {\n\n\t\t\treturn this._x;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tthis._x = value;\n\t\t\tthis._onChangeCallback();\n\n\t\t}\n\n\t},\n\n\ty: {\n\n\t\tget: function () {\n\n\t\t\treturn this._y;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tthis._y = value;\n\t\t\tthis._onChangeCallback();\n\n\t\t}\n\n\t},\n\n\tz: {\n\n\t\tget: function () {\n\n\t\t\treturn this._z;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tthis._z = value;\n\t\t\tthis._onChangeCallback();\n\n\t\t}\n\n\t},\n\n\tw: {\n\n\t\tget: function () {\n\n\t\t\treturn this._w;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tthis._w = value;\n\t\t\tthis._onChangeCallback();\n\n\t\t}\n\n\t}\n\n} );\n\nObject.assign( Quaternion.prototype, {\n\n\tisQuaternion: true,\n\n\tset: function ( x, y, z, w ) {\n\n\t\tthis._x = x;\n\t\tthis._y = y;\n\t\tthis._z = z;\n\t\tthis._w = w;\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor( this._x, this._y, this._z, this._w );\n\n\t},\n\n\tcopy: function ( quaternion ) {\n\n\t\tthis._x = quaternion.x;\n\t\tthis._y = quaternion.y;\n\t\tthis._z = quaternion.z;\n\t\tthis._w = quaternion.w;\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\tsetFromEuler: function ( euler, update ) {\n\n\t\tif ( ! ( euler && euler.isEuler ) ) {\n\n\t\t\tthrow new Error( 'THREE.Quaternion: .setFromEuler() now expects an Euler rotation rather than a Vector3 and order.' );\n\n\t\t}\n\n\t\tconst x = euler._x, y = euler._y, z = euler._z, order = euler.order;\n\n\t\t// http://www.mathworks.com/matlabcentral/fileexchange/\n\t\t// \t20696-function-to-convert-between-dcm-euler-angles-quaternions-and-euler-vectors/\n\t\t//\tcontent/SpinCalc.m\n\n\t\tconst cos = Math.cos;\n\t\tconst sin = Math.sin;\n\n\t\tconst c1 = cos( x / 2 );\n\t\tconst c2 = cos( y / 2 );\n\t\tconst c3 = cos( z / 2 );\n\n\t\tconst s1 = sin( x / 2 );\n\t\tconst s2 = sin( y / 2 );\n\t\tconst s3 = sin( z / 2 );\n\n\t\tswitch ( order ) {\n\n\t\t\tcase 'XYZ':\n\t\t\t\tthis._x = s1 * c2 * c3 + c1 * s2 * s3;\n\t\t\t\tthis._y = c1 * s2 * c3 - s1 * c2 * s3;\n\t\t\t\tthis._z = c1 * c2 * s3 + s1 * s2 * c3;\n\t\t\t\tthis._w = c1 * c2 * c3 - s1 * s2 * s3;\n\t\t\t\tbreak;\n\n\t\t\tcase 'YXZ':\n\t\t\t\tthis._x = s1 * c2 * c3 + c1 * s2 * s3;\n\t\t\t\tthis._y = c1 * s2 * c3 - s1 * c2 * s3;\n\t\t\t\tthis._z = c1 * c2 * s3 - s1 * s2 * c3;\n\t\t\t\tthis._w = c1 * c2 * c3 + s1 * s2 * s3;\n\t\t\t\tbreak;\n\n\t\t\tcase 'ZXY':\n\t\t\t\tthis._x = s1 * c2 * c3 - c1 * s2 * s3;\n\t\t\t\tthis._y = c1 * s2 * c3 + s1 * c2 * s3;\n\t\t\t\tthis._z = c1 * c2 * s3 + s1 * s2 * c3;\n\t\t\t\tthis._w = c1 * c2 * c3 - s1 * s2 * s3;\n\t\t\t\tbreak;\n\n\t\t\tcase 'ZYX':\n\t\t\t\tthis._x = s1 * c2 * c3 - c1 * s2 * s3;\n\t\t\t\tthis._y = c1 * s2 * c3 + s1 * c2 * s3;\n\t\t\t\tthis._z = c1 * c2 * s3 - s1 * s2 * c3;\n\t\t\t\tthis._w = c1 * c2 * c3 + s1 * s2 * s3;\n\t\t\t\tbreak;\n\n\t\t\tcase 'YZX':\n\t\t\t\tthis._x = s1 * c2 * c3 + c1 * s2 * s3;\n\t\t\t\tthis._y = c1 * s2 * c3 + s1 * c2 * s3;\n\t\t\t\tthis._z = c1 * c2 * s3 - s1 * s2 * c3;\n\t\t\t\tthis._w = c1 * c2 * c3 - s1 * s2 * s3;\n\t\t\t\tbreak;\n\n\t\t\tcase 'XZY':\n\t\t\t\tthis._x = s1 * c2 * c3 - c1 * s2 * s3;\n\t\t\t\tthis._y = c1 * s2 * c3 - s1 * c2 * s3;\n\t\t\t\tthis._z = c1 * c2 * s3 + s1 * s2 * c3;\n\t\t\t\tthis._w = c1 * c2 * c3 + s1 * s2 * s3;\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tconsole.warn( 'THREE.Quaternion: .setFromEuler() encountered an unknown order: ' + order );\n\n\t\t}\n\n\t\tif ( update !== false ) this._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\tsetFromAxisAngle: function ( axis, angle ) {\n\n\t\t// http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm\n\n\t\t// assumes axis is normalized\n\n\t\tconst halfAngle = angle / 2, s = Math.sin( halfAngle );\n\n\t\tthis._x = axis.x * s;\n\t\tthis._y = axis.y * s;\n\t\tthis._z = axis.z * s;\n\t\tthis._w = Math.cos( halfAngle );\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\tsetFromRotationMatrix: function ( m ) {\n\n\t\t// http://www.euclideanspace.com/maths/geometry/rotations/conversions/matrixToQuaternion/index.htm\n\n\t\t// assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)\n\n\t\tconst te = m.elements,\n\n\t\t\tm11 = te[ 0 ], m12 = te[ 4 ], m13 = te[ 8 ],\n\t\t\tm21 = te[ 1 ], m22 = te[ 5 ], m23 = te[ 9 ],\n\t\t\tm31 = te[ 2 ], m32 = te[ 6 ], m33 = te[ 10 ],\n\n\t\t\ttrace = m11 + m22 + m33;\n\n\t\tif ( trace > 0 ) {\n\n\t\t\tconst s = 0.5 / Math.sqrt( trace + 1.0 );\n\n\t\t\tthis._w = 0.25 / s;\n\t\t\tthis._x = ( m32 - m23 ) * s;\n\t\t\tthis._y = ( m13 - m31 ) * s;\n\t\t\tthis._z = ( m21 - m12 ) * s;\n\n\t\t} else if ( m11 > m22 && m11 > m33 ) {\n\n\t\t\tconst s = 2.0 * Math.sqrt( 1.0 + m11 - m22 - m33 );\n\n\t\t\tthis._w = ( m32 - m23 ) / s;\n\t\t\tthis._x = 0.25 * s;\n\t\t\tthis._y = ( m12 + m21 ) / s;\n\t\t\tthis._z = ( m13 + m31 ) / s;\n\n\t\t} else if ( m22 > m33 ) {\n\n\t\t\tconst s = 2.0 * Math.sqrt( 1.0 + m22 - m11 - m33 );\n\n\t\t\tthis._w = ( m13 - m31 ) / s;\n\t\t\tthis._x = ( m12 + m21 ) / s;\n\t\t\tthis._y = 0.25 * s;\n\t\t\tthis._z = ( m23 + m32 ) / s;\n\n\t\t} else {\n\n\t\t\tconst s = 2.0 * Math.sqrt( 1.0 + m33 - m11 - m22 );\n\n\t\t\tthis._w = ( m21 - m12 ) / s;\n\t\t\tthis._x = ( m13 + m31 ) / s;\n\t\t\tthis._y = ( m23 + m32 ) / s;\n\t\t\tthis._z = 0.25 * s;\n\n\t\t}\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\tsetFromUnitVectors: function ( vFrom, vTo ) {\n\n\t\t// assumes direction vectors vFrom and vTo are normalized\n\n\t\tconst EPS = 0.000001;\n\n\t\tlet r = vFrom.dot( vTo ) + 1;\n\n\t\tif ( r < EPS ) {\n\n\t\t\tr = 0;\n\n\t\t\tif ( Math.abs( vFrom.x ) > Math.abs( vFrom.z ) ) {\n\n\t\t\t\tthis._x = - vFrom.y;\n\t\t\t\tthis._y = vFrom.x;\n\t\t\t\tthis._z = 0;\n\t\t\t\tthis._w = r;\n\n\t\t\t} else {\n\n\t\t\t\tthis._x = 0;\n\t\t\t\tthis._y = - vFrom.z;\n\t\t\t\tthis._z = vFrom.y;\n\t\t\t\tthis._w = r;\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\t// crossVectors( vFrom, vTo ); // inlined to avoid cyclic dependency on Vector3\n\n\t\t\tthis._x = vFrom.y * vTo.z - vFrom.z * vTo.y;\n\t\t\tthis._y = vFrom.z * vTo.x - vFrom.x * vTo.z;\n\t\t\tthis._z = vFrom.x * vTo.y - vFrom.y * vTo.x;\n\t\t\tthis._w = r;\n\n\t\t}\n\n\t\treturn this.normalize();\n\n\t},\n\n\tangleTo: function ( q ) {\n\n\t\treturn 2 * Math.acos( Math.abs( MathUtils.clamp( this.dot( q ), - 1, 1 ) ) );\n\n\t},\n\n\trotateTowards: function ( q, step ) {\n\n\t\tconst angle = this.angleTo( q );\n\n\t\tif ( angle === 0 ) return this;\n\n\t\tconst t = Math.min( 1, step / angle );\n\n\t\tthis.slerp( q, t );\n\n\t\treturn this;\n\n\t},\n\n\tinverse: function () {\n\n\t\t// quaternion is assumed to have unit length\n\n\t\treturn this.conjugate();\n\n\t},\n\n\tconjugate: function () {\n\n\t\tthis._x *= - 1;\n\t\tthis._y *= - 1;\n\t\tthis._z *= - 1;\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\tdot: function ( v ) {\n\n\t\treturn this._x * v._x + this._y * v._y + this._z * v._z + this._w * v._w;\n\n\t},\n\n\tlengthSq: function () {\n\n\t\treturn this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w;\n\n\t},\n\n\tlength: function () {\n\n\t\treturn Math.sqrt( this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w );\n\n\t},\n\n\tnormalize: function () {\n\n\t\tlet l = this.length();\n\n\t\tif ( l === 0 ) {\n\n\t\t\tthis._x = 0;\n\t\t\tthis._y = 0;\n\t\t\tthis._z = 0;\n\t\t\tthis._w = 1;\n\n\t\t} else {\n\n\t\t\tl = 1 / l;\n\n\t\t\tthis._x = this._x * l;\n\t\t\tthis._y = this._y * l;\n\t\t\tthis._z = this._z * l;\n\t\t\tthis._w = this._w * l;\n\n\t\t}\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\tmultiply: function ( q, p ) {\n\n\t\tif ( p !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead.' );\n\t\t\treturn this.multiplyQuaternions( q, p );\n\n\t\t}\n\n\t\treturn this.multiplyQuaternions( this, q );\n\n\t},\n\n\tpremultiply: function ( q ) {\n\n\t\treturn this.multiplyQuaternions( q, this );\n\n\t},\n\n\tmultiplyQuaternions: function ( a, b ) {\n\n\t\t// from http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/code/index.htm\n\n\t\tconst qax = a._x, qay = a._y, qaz = a._z, qaw = a._w;\n\t\tconst qbx = b._x, qby = b._y, qbz = b._z, qbw = b._w;\n\n\t\tthis._x = qax * qbw + qaw * qbx + qay * qbz - qaz * qby;\n\t\tthis._y = qay * qbw + qaw * qby + qaz * qbx - qax * qbz;\n\t\tthis._z = qaz * qbw + qaw * qbz + qax * qby - qay * qbx;\n\t\tthis._w = qaw * qbw - qax * qbx - qay * qby - qaz * qbz;\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\tslerp: function ( qb, t ) {\n\n\t\tif ( t === 0 ) return this;\n\t\tif ( t === 1 ) return this.copy( qb );\n\n\t\tconst x = this._x, y = this._y, z = this._z, w = this._w;\n\n\t\t// http://www.euclideanspace.com/maths/algebra/realNormedAlgebra/quaternions/slerp/\n\n\t\tlet cosHalfTheta = w * qb._w + x * qb._x + y * qb._y + z * qb._z;\n\n\t\tif ( cosHalfTheta < 0 ) {\n\n\t\t\tthis._w = - qb._w;\n\t\t\tthis._x = - qb._x;\n\t\t\tthis._y = - qb._y;\n\t\t\tthis._z = - qb._z;\n\n\t\t\tcosHalfTheta = - cosHalfTheta;\n\n\t\t} else {\n\n\t\t\tthis.copy( qb );\n\n\t\t}\n\n\t\tif ( cosHalfTheta >= 1.0 ) {\n\n\t\t\tthis._w = w;\n\t\t\tthis._x = x;\n\t\t\tthis._y = y;\n\t\t\tthis._z = z;\n\n\t\t\treturn this;\n\n\t\t}\n\n\t\tconst sqrSinHalfTheta = 1.0 - cosHalfTheta * cosHalfTheta;\n\n\t\tif ( sqrSinHalfTheta <= Number.EPSILON ) {\n\n\t\t\tconst s = 1 - t;\n\t\t\tthis._w = s * w + t * this._w;\n\t\t\tthis._x = s * x + t * this._x;\n\t\t\tthis._y = s * y + t * this._y;\n\t\t\tthis._z = s * z + t * this._z;\n\n\t\t\tthis.normalize();\n\t\t\tthis._onChangeCallback();\n\n\t\t\treturn this;\n\n\t\t}\n\n\t\tconst sinHalfTheta = Math.sqrt( sqrSinHalfTheta );\n\t\tconst halfTheta = Math.atan2( sinHalfTheta, cosHalfTheta );\n\t\tconst ratioA = Math.sin( ( 1 - t ) * halfTheta ) / sinHalfTheta,\n\t\t\tratioB = Math.sin( t * halfTheta ) / sinHalfTheta;\n\n\t\tthis._w = ( w * ratioA + this._w * ratioB );\n\t\tthis._x = ( x * ratioA + this._x * ratioB );\n\t\tthis._y = ( y * ratioA + this._y * ratioB );\n\t\tthis._z = ( z * ratioA + this._z * ratioB );\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\tequals: function ( quaternion ) {\n\n\t\treturn ( quaternion._x === this._x ) && ( quaternion._y === this._y ) && ( quaternion._z === this._z ) && ( quaternion._w === this._w );\n\n\t},\n\n\tfromArray: function ( array, offset ) {\n\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tthis._x = array[ offset ];\n\t\tthis._y = array[ offset + 1 ];\n\t\tthis._z = array[ offset + 2 ];\n\t\tthis._w = array[ offset + 3 ];\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\ttoArray: function ( array, offset ) {\n\n\t\tif ( array === undefined ) array = [];\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tarray[ offset ] = this._x;\n\t\tarray[ offset + 1 ] = this._y;\n\t\tarray[ offset + 2 ] = this._z;\n\t\tarray[ offset + 3 ] = this._w;\n\n\t\treturn array;\n\n\t},\n\n\tfromBufferAttribute: function ( attribute, index ) {\n\n\t\tthis._x = attribute.getX( index );\n\t\tthis._y = attribute.getY( index );\n\t\tthis._z = attribute.getZ( index );\n\t\tthis._w = attribute.getW( index );\n\n\t\treturn this;\n\n\t},\n\n\t_onChange: function ( callback ) {\n\n\t\tthis._onChangeCallback = callback;\n\n\t\treturn this;\n\n\t},\n\n\t_onChangeCallback: function () {}\n\n} );\n\n\nexport { Quaternion };\n","import { MathUtils } from './MathUtils.js';\nimport { Quaternion } from './Quaternion.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author kile / http://kile.stravaganza.org/\n * @author philogb / http://blog.thejit.org/\n * @author mikael emtinger / http://gomo.se/\n * @author egraether / http://egraether.com/\n * @author WestLangley / http://github.com/WestLangley\n */\n\nconst _vector = new Vector3();\nconst _quaternion = new Quaternion();\n\nfunction Vector3( x = 0, y = 0, z = 0 ) {\n\n\tthis.x = x;\n\tthis.y = y;\n\tthis.z = z;\n\n}\n\nObject.assign( Vector3.prototype, {\n\n\tisVector3: true,\n\n\tset: function ( x, y, z ) {\n\n\t\tthis.x = x;\n\t\tthis.y = y;\n\t\tthis.z = z;\n\n\t\treturn this;\n\n\t},\n\n\tsetScalar: function ( scalar ) {\n\n\t\tthis.x = scalar;\n\t\tthis.y = scalar;\n\t\tthis.z = scalar;\n\n\t\treturn this;\n\n\t},\n\n\tsetX: function ( x ) {\n\n\t\tthis.x = x;\n\n\t\treturn this;\n\n\t},\n\n\tsetY: function ( y ) {\n\n\t\tthis.y = y;\n\n\t\treturn this;\n\n\t},\n\n\tsetZ: function ( z ) {\n\n\t\tthis.z = z;\n\n\t\treturn this;\n\n\t},\n\n\tsetComponent: function ( index, value ) {\n\n\t\tswitch ( index ) {\n\n\t\t\tcase 0: this.x = value; break;\n\t\t\tcase 1: this.y = value; break;\n\t\t\tcase 2: this.z = value; break;\n\t\t\tdefault: throw new Error( 'index is out of range: ' + index );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tgetComponent: function ( index ) {\n\n\t\tswitch ( index ) {\n\n\t\t\tcase 0: return this.x;\n\t\t\tcase 1: return this.y;\n\t\t\tcase 2: return this.z;\n\t\t\tdefault: throw new Error( 'index is out of range: ' + index );\n\n\t\t}\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor( this.x, this.y, this.z );\n\n\t},\n\n\tcopy: function ( v ) {\n\n\t\tthis.x = v.x;\n\t\tthis.y = v.y;\n\t\tthis.z = v.z;\n\n\t\treturn this;\n\n\t},\n\n\tadd: function ( v, w ) {\n\n\t\tif ( w !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead.' );\n\t\t\treturn this.addVectors( v, w );\n\n\t\t}\n\n\t\tthis.x += v.x;\n\t\tthis.y += v.y;\n\t\tthis.z += v.z;\n\n\t\treturn this;\n\n\t},\n\n\taddScalar: function ( s ) {\n\n\t\tthis.x += s;\n\t\tthis.y += s;\n\t\tthis.z += s;\n\n\t\treturn this;\n\n\t},\n\n\taddVectors: function ( a, b ) {\n\n\t\tthis.x = a.x + b.x;\n\t\tthis.y = a.y + b.y;\n\t\tthis.z = a.z + b.z;\n\n\t\treturn this;\n\n\t},\n\n\taddScaledVector: function ( v, s ) {\n\n\t\tthis.x += v.x * s;\n\t\tthis.y += v.y * s;\n\t\tthis.z += v.z * s;\n\n\t\treturn this;\n\n\t},\n\n\tsub: function ( v, w ) {\n\n\t\tif ( w !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead.' );\n\t\t\treturn this.subVectors( v, w );\n\n\t\t}\n\n\t\tthis.x -= v.x;\n\t\tthis.y -= v.y;\n\t\tthis.z -= v.z;\n\n\t\treturn this;\n\n\t},\n\n\tsubScalar: function ( s ) {\n\n\t\tthis.x -= s;\n\t\tthis.y -= s;\n\t\tthis.z -= s;\n\n\t\treturn this;\n\n\t},\n\n\tsubVectors: function ( a, b ) {\n\n\t\tthis.x = a.x - b.x;\n\t\tthis.y = a.y - b.y;\n\t\tthis.z = a.z - b.z;\n\n\t\treturn this;\n\n\t},\n\n\tmultiply: function ( v, w ) {\n\n\t\tif ( w !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead.' );\n\t\t\treturn this.multiplyVectors( v, w );\n\n\t\t}\n\n\t\tthis.x *= v.x;\n\t\tthis.y *= v.y;\n\t\tthis.z *= v.z;\n\n\t\treturn this;\n\n\t},\n\n\tmultiplyScalar: function ( scalar ) {\n\n\t\tthis.x *= scalar;\n\t\tthis.y *= scalar;\n\t\tthis.z *= scalar;\n\n\t\treturn this;\n\n\t},\n\n\tmultiplyVectors: function ( a, b ) {\n\n\t\tthis.x = a.x * b.x;\n\t\tthis.y = a.y * b.y;\n\t\tthis.z = a.z * b.z;\n\n\t\treturn this;\n\n\t},\n\n\tapplyEuler: function ( euler ) {\n\n\t\tif ( ! ( euler && euler.isEuler ) ) {\n\n\t\t\tconsole.error( 'THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.' );\n\n\t\t}\n\n\t\treturn this.applyQuaternion( _quaternion.setFromEuler( euler ) );\n\n\t},\n\n\tapplyAxisAngle: function ( axis, angle ) {\n\n\t\treturn this.applyQuaternion( _quaternion.setFromAxisAngle( axis, angle ) );\n\n\t},\n\n\tapplyMatrix3: function ( m ) {\n\n\t\tconst x = this.x, y = this.y, z = this.z;\n\t\tconst e = m.elements;\n\n\t\tthis.x = e[ 0 ] * x + e[ 3 ] * y + e[ 6 ] * z;\n\t\tthis.y = e[ 1 ] * x + e[ 4 ] * y + e[ 7 ] * z;\n\t\tthis.z = e[ 2 ] * x + e[ 5 ] * y + e[ 8 ] * z;\n\n\t\treturn this;\n\n\t},\n\n\tapplyNormalMatrix: function ( m ) {\n\n\t\treturn this.applyMatrix3( m ).normalize();\n\n\t},\n\n\tapplyMatrix4: function ( m ) {\n\n\t\tconst x = this.x, y = this.y, z = this.z;\n\t\tconst e = m.elements;\n\n\t\tconst w = 1 / ( e[ 3 ] * x + e[ 7 ] * y + e[ 11 ] * z + e[ 15 ] );\n\n\t\tthis.x = ( e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z + e[ 12 ] ) * w;\n\t\tthis.y = ( e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z + e[ 13 ] ) * w;\n\t\tthis.z = ( e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z + e[ 14 ] ) * w;\n\n\t\treturn this;\n\n\t},\n\n\tapplyQuaternion: function ( q ) {\n\n\t\tconst x = this.x, y = this.y, z = this.z;\n\t\tconst qx = q.x, qy = q.y, qz = q.z, qw = q.w;\n\n\t\t// calculate quat * vector\n\n\t\tconst ix = qw * x + qy * z - qz * y;\n\t\tconst iy = qw * y + qz * x - qx * z;\n\t\tconst iz = qw * z + qx * y - qy * x;\n\t\tconst iw = - qx * x - qy * y - qz * z;\n\n\t\t// calculate result * inverse quat\n\n\t\tthis.x = ix * qw + iw * - qx + iy * - qz - iz * - qy;\n\t\tthis.y = iy * qw + iw * - qy + iz * - qx - ix * - qz;\n\t\tthis.z = iz * qw + iw * - qz + ix * - qy - iy * - qx;\n\n\t\treturn this;\n\n\t},\n\n\tproject: function ( camera ) {\n\n\t\treturn this.applyMatrix4( camera.matrixWorldInverse ).applyMatrix4( camera.projectionMatrix );\n\n\t},\n\n\tunproject: function ( camera ) {\n\n\t\treturn this.applyMatrix4( camera.projectionMatrixInverse ).applyMatrix4( camera.matrixWorld );\n\n\t},\n\n\ttransformDirection: function ( m ) {\n\n\t\t// input: THREE.Matrix4 affine matrix\n\t\t// vector interpreted as a direction\n\n\t\tconst x = this.x, y = this.y, z = this.z;\n\t\tconst e = m.elements;\n\n\t\tthis.x = e[ 0 ] * x + e[ 4 ] * y + e[ 8 ] * z;\n\t\tthis.y = e[ 1 ] * x + e[ 5 ] * y + e[ 9 ] * z;\n\t\tthis.z = e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z;\n\n\t\treturn this.normalize();\n\n\t},\n\n\tdivide: function ( v ) {\n\n\t\tthis.x /= v.x;\n\t\tthis.y /= v.y;\n\t\tthis.z /= v.z;\n\n\t\treturn this;\n\n\t},\n\n\tdivideScalar: function ( scalar ) {\n\n\t\treturn this.multiplyScalar( 1 / scalar );\n\n\t},\n\n\tmin: function ( v ) {\n\n\t\tthis.x = Math.min( this.x, v.x );\n\t\tthis.y = Math.min( this.y, v.y );\n\t\tthis.z = Math.min( this.z, v.z );\n\n\t\treturn this;\n\n\t},\n\n\tmax: function ( v ) {\n\n\t\tthis.x = Math.max( this.x, v.x );\n\t\tthis.y = Math.max( this.y, v.y );\n\t\tthis.z = Math.max( this.z, v.z );\n\n\t\treturn this;\n\n\t},\n\n\tclamp: function ( min, max ) {\n\n\t\t// assumes min < max, componentwise\n\n\t\tthis.x = Math.max( min.x, Math.min( max.x, this.x ) );\n\t\tthis.y = Math.max( min.y, Math.min( max.y, this.y ) );\n\t\tthis.z = Math.max( min.z, Math.min( max.z, this.z ) );\n\n\t\treturn this;\n\n\t},\n\n\tclampScalar: function ( minVal, maxVal ) {\n\n\t\tthis.x = Math.max( minVal, Math.min( maxVal, this.x ) );\n\t\tthis.y = Math.max( minVal, Math.min( maxVal, this.y ) );\n\t\tthis.z = Math.max( minVal, Math.min( maxVal, this.z ) );\n\n\t\treturn this;\n\n\t},\n\n\tclampLength: function ( min, max ) {\n\n\t\tconst length = this.length();\n\n\t\treturn this.divideScalar( length || 1 ).multiplyScalar( Math.max( min, Math.min( max, length ) ) );\n\n\t},\n\n\tfloor: function () {\n\n\t\tthis.x = Math.floor( this.x );\n\t\tthis.y = Math.floor( this.y );\n\t\tthis.z = Math.floor( this.z );\n\n\t\treturn this;\n\n\t},\n\n\tceil: function () {\n\n\t\tthis.x = Math.ceil( this.x );\n\t\tthis.y = Math.ceil( this.y );\n\t\tthis.z = Math.ceil( this.z );\n\n\t\treturn this;\n\n\t},\n\n\tround: function () {\n\n\t\tthis.x = Math.round( this.x );\n\t\tthis.y = Math.round( this.y );\n\t\tthis.z = Math.round( this.z );\n\n\t\treturn this;\n\n\t},\n\n\troundToZero: function () {\n\n\t\tthis.x = ( this.x < 0 ) ? Math.ceil( this.x ) : Math.floor( this.x );\n\t\tthis.y = ( this.y < 0 ) ? Math.ceil( this.y ) : Math.floor( this.y );\n\t\tthis.z = ( this.z < 0 ) ? Math.ceil( this.z ) : Math.floor( this.z );\n\n\t\treturn this;\n\n\t},\n\n\tnegate: function () {\n\n\t\tthis.x = - this.x;\n\t\tthis.y = - this.y;\n\t\tthis.z = - this.z;\n\n\t\treturn this;\n\n\t},\n\n\tdot: function ( v ) {\n\n\t\treturn this.x * v.x + this.y * v.y + this.z * v.z;\n\n\t},\n\n\t// TODO lengthSquared?\n\n\tlengthSq: function () {\n\n\t\treturn this.x * this.x + this.y * this.y + this.z * this.z;\n\n\t},\n\n\tlength: function () {\n\n\t\treturn Math.sqrt( this.x * this.x + this.y * this.y + this.z * this.z );\n\n\t},\n\n\tmanhattanLength: function () {\n\n\t\treturn Math.abs( this.x ) + Math.abs( this.y ) + Math.abs( this.z );\n\n\t},\n\n\tnormalize: function () {\n\n\t\treturn this.divideScalar( this.length() || 1 );\n\n\t},\n\n\tsetLength: function ( length ) {\n\n\t\treturn this.normalize().multiplyScalar( length );\n\n\t},\n\n\tlerp: function ( v, alpha ) {\n\n\t\tthis.x += ( v.x - this.x ) * alpha;\n\t\tthis.y += ( v.y - this.y ) * alpha;\n\t\tthis.z += ( v.z - this.z ) * alpha;\n\n\t\treturn this;\n\n\t},\n\n\tlerpVectors: function ( v1, v2, alpha ) {\n\n\t\tthis.x = v1.x + ( v2.x - v1.x ) * alpha;\n\t\tthis.y = v1.y + ( v2.y - v1.y ) * alpha;\n\t\tthis.z = v1.z + ( v2.z - v1.z ) * alpha;\n\n\t\treturn this;\n\n\t},\n\n\tcross: function ( v, w ) {\n\n\t\tif ( w !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead.' );\n\t\t\treturn this.crossVectors( v, w );\n\n\t\t}\n\n\t\treturn this.crossVectors( this, v );\n\n\t},\n\n\tcrossVectors: function ( a, b ) {\n\n\t\tconst ax = a.x, ay = a.y, az = a.z;\n\t\tconst bx = b.x, by = b.y, bz = b.z;\n\n\t\tthis.x = ay * bz - az * by;\n\t\tthis.y = az * bx - ax * bz;\n\t\tthis.z = ax * by - ay * bx;\n\n\t\treturn this;\n\n\t},\n\n\tprojectOnVector: function ( v ) {\n\n\t\tconst denominator = v.lengthSq();\n\n\t\tif ( denominator === 0 ) return this.set( 0, 0, 0 );\n\n\t\tconst scalar = v.dot( this ) / denominator;\n\n\t\treturn this.copy( v ).multiplyScalar( scalar );\n\n\t},\n\n\tprojectOnPlane: function ( planeNormal ) {\n\n\t\t_vector.copy( this ).projectOnVector( planeNormal );\n\n\t\treturn this.sub( _vector );\n\n\t},\n\n\treflect: function ( normal ) {\n\n\t\t// reflect incident vector off plane orthogonal to normal\n\t\t// normal is assumed to have unit length\n\n\t\treturn this.sub( _vector.copy( normal ).multiplyScalar( 2 * this.dot( normal ) ) );\n\n\t},\n\n\tangleTo: function ( v ) {\n\n\t\tconst denominator = Math.sqrt( this.lengthSq() * v.lengthSq() );\n\n\t\tif ( denominator === 0 ) return Math.PI / 2;\n\n\t\tconst theta = this.dot( v ) / denominator;\n\n\t\t// clamp, to handle numerical problems\n\n\t\treturn Math.acos( MathUtils.clamp( theta, - 1, 1 ) );\n\n\t},\n\n\tdistanceTo: function ( v ) {\n\n\t\treturn Math.sqrt( this.distanceToSquared( v ) );\n\n\t},\n\n\tdistanceToSquared: function ( v ) {\n\n\t\tconst dx = this.x - v.x, dy = this.y - v.y, dz = this.z - v.z;\n\n\t\treturn dx * dx + dy * dy + dz * dz;\n\n\t},\n\n\tmanhattanDistanceTo: function ( v ) {\n\n\t\treturn Math.abs( this.x - v.x ) + Math.abs( this.y - v.y ) + Math.abs( this.z - v.z );\n\n\t},\n\n\tsetFromSpherical: function ( s ) {\n\n\t\treturn this.setFromSphericalCoords( s.radius, s.phi, s.theta );\n\n\t},\n\n\tsetFromSphericalCoords: function ( radius, phi, theta ) {\n\n\t\tconst sinPhiRadius = Math.sin( phi ) * radius;\n\n\t\tthis.x = sinPhiRadius * Math.sin( theta );\n\t\tthis.y = Math.cos( phi ) * radius;\n\t\tthis.z = sinPhiRadius * Math.cos( theta );\n\n\t\treturn this;\n\n\t},\n\n\tsetFromCylindrical: function ( c ) {\n\n\t\treturn this.setFromCylindricalCoords( c.radius, c.theta, c.y );\n\n\t},\n\n\tsetFromCylindricalCoords: function ( radius, theta, y ) {\n\n\t\tthis.x = radius * Math.sin( theta );\n\t\tthis.y = y;\n\t\tthis.z = radius * Math.cos( theta );\n\n\t\treturn this;\n\n\t},\n\n\tsetFromMatrixPosition: function ( m ) {\n\n\t\tconst e = m.elements;\n\n\t\tthis.x = e[ 12 ];\n\t\tthis.y = e[ 13 ];\n\t\tthis.z = e[ 14 ];\n\n\t\treturn this;\n\n\t},\n\n\tsetFromMatrixScale: function ( m ) {\n\n\t\tconst sx = this.setFromMatrixColumn( m, 0 ).length();\n\t\tconst sy = this.setFromMatrixColumn( m, 1 ).length();\n\t\tconst sz = this.setFromMatrixColumn( m, 2 ).length();\n\n\t\tthis.x = sx;\n\t\tthis.y = sy;\n\t\tthis.z = sz;\n\n\t\treturn this;\n\n\t},\n\n\tsetFromMatrixColumn: function ( m, index ) {\n\n\t\treturn this.fromArray( m.elements, index * 4 );\n\n\t},\n\n\tsetFromMatrix3Column: function ( m, index ) {\n\n\t\treturn this.fromArray( m.elements, index * 3 );\n\n\t},\n\n\tequals: function ( v ) {\n\n\t\treturn ( ( v.x === this.x ) && ( v.y === this.y ) && ( v.z === this.z ) );\n\n\t},\n\n\tfromArray: function ( array, offset ) {\n\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tthis.x = array[ offset ];\n\t\tthis.y = array[ offset + 1 ];\n\t\tthis.z = array[ offset + 2 ];\n\n\t\treturn this;\n\n\t},\n\n\ttoArray: function ( array, offset ) {\n\n\t\tif ( array === undefined ) array = [];\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tarray[ offset ] = this.x;\n\t\tarray[ offset + 1 ] = this.y;\n\t\tarray[ offset + 2 ] = this.z;\n\n\t\treturn array;\n\n\t},\n\n\tfromBufferAttribute: function ( attribute, index, offset ) {\n\n\t\tif ( offset !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Vector3: offset has been removed from .fromBufferAttribute().' );\n\n\t\t}\n\n\t\tthis.x = attribute.getX( index );\n\t\tthis.y = attribute.getY( index );\n\t\tthis.z = attribute.getZ( index );\n\n\t\treturn this;\n\n\t},\n\n\trandom: function () {\n\n\t\tthis.x = Math.random();\n\t\tthis.y = Math.random();\n\t\tthis.z = Math.random();\n\n\t\treturn this;\n\n\t}\n\n} );\n\n\nexport { Vector3 };\n","import { Vector3 } from './Vector3.js';\n\nconst _v1 = new Vector3();\nconst _m1 = new Matrix4();\nconst _zero = new Vector3( 0, 0, 0 );\nconst _one = new Vector3( 1, 1, 1 );\nconst _x = new Vector3();\nconst _y = new Vector3();\nconst _z = new Vector3();\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author supereggbert / http://www.paulbrunt.co.uk/\n * @author philogb / http://blog.thejit.org/\n * @author jordi_ros / http://plattsoft.com\n * @author D1plo1d / http://github.com/D1plo1d\n * @author alteredq / http://alteredqualia.com/\n * @author mikael emtinger / http://gomo.se/\n * @author timknip / http://www.floorplanner.com/\n * @author bhouston / http://clara.io\n * @author WestLangley / http://github.com/WestLangley\n */\n\nfunction Matrix4() {\n\n\tthis.elements = [\n\n\t\t1, 0, 0, 0,\n\t\t0, 1, 0, 0,\n\t\t0, 0, 1, 0,\n\t\t0, 0, 0, 1\n\n\t];\n\n\tif ( arguments.length > 0 ) {\n\n\t\tconsole.error( 'THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.' );\n\n\t}\n\n}\n\nObject.assign( Matrix4.prototype, {\n\n\tisMatrix4: true,\n\n\tset: function ( n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44 ) {\n\n\t\tconst te = this.elements;\n\n\t\tte[ 0 ] = n11; te[ 4 ] = n12; te[ 8 ] = n13; te[ 12 ] = n14;\n\t\tte[ 1 ] = n21; te[ 5 ] = n22; te[ 9 ] = n23; te[ 13 ] = n24;\n\t\tte[ 2 ] = n31; te[ 6 ] = n32; te[ 10 ] = n33; te[ 14 ] = n34;\n\t\tte[ 3 ] = n41; te[ 7 ] = n42; te[ 11 ] = n43; te[ 15 ] = n44;\n\n\t\treturn this;\n\n\t},\n\n\tidentity: function () {\n\n\t\tthis.set(\n\n\t\t\t1, 0, 0, 0,\n\t\t\t0, 1, 0, 0,\n\t\t\t0, 0, 1, 0,\n\t\t\t0, 0, 0, 1\n\n\t\t);\n\n\t\treturn this;\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new Matrix4().fromArray( this.elements );\n\n\t},\n\n\tcopy: function ( m ) {\n\n\t\tconst te = this.elements;\n\t\tconst me = m.elements;\n\n\t\tte[ 0 ] = me[ 0 ]; te[ 1 ] = me[ 1 ]; te[ 2 ] = me[ 2 ]; te[ 3 ] = me[ 3 ];\n\t\tte[ 4 ] = me[ 4 ]; te[ 5 ] = me[ 5 ]; te[ 6 ] = me[ 6 ]; te[ 7 ] = me[ 7 ];\n\t\tte[ 8 ] = me[ 8 ]; te[ 9 ] = me[ 9 ]; te[ 10 ] = me[ 10 ]; te[ 11 ] = me[ 11 ];\n\t\tte[ 12 ] = me[ 12 ]; te[ 13 ] = me[ 13 ]; te[ 14 ] = me[ 14 ]; te[ 15 ] = me[ 15 ];\n\n\t\treturn this;\n\n\t},\n\n\tcopyPosition: function ( m ) {\n\n\t\tconst te = this.elements, me = m.elements;\n\n\t\tte[ 12 ] = me[ 12 ];\n\t\tte[ 13 ] = me[ 13 ];\n\t\tte[ 14 ] = me[ 14 ];\n\n\t\treturn this;\n\n\t},\n\n\textractBasis: function ( xAxis, yAxis, zAxis ) {\n\n\t\txAxis.setFromMatrixColumn( this, 0 );\n\t\tyAxis.setFromMatrixColumn( this, 1 );\n\t\tzAxis.setFromMatrixColumn( this, 2 );\n\n\t\treturn this;\n\n\t},\n\n\tmakeBasis: function ( xAxis, yAxis, zAxis ) {\n\n\t\tthis.set(\n\t\t\txAxis.x, yAxis.x, zAxis.x, 0,\n\t\t\txAxis.y, yAxis.y, zAxis.y, 0,\n\t\t\txAxis.z, yAxis.z, zAxis.z, 0,\n\t\t\t0, 0, 0, 1\n\t\t);\n\n\t\treturn this;\n\n\t},\n\n\textractRotation: function ( m ) {\n\n\t\t// this method does not support reflection matrices\n\n\t\tconst te = this.elements;\n\t\tconst me = m.elements;\n\n\t\tconst scaleX = 1 / _v1.setFromMatrixColumn( m, 0 ).length();\n\t\tconst scaleY = 1 / _v1.setFromMatrixColumn( m, 1 ).length();\n\t\tconst scaleZ = 1 / _v1.setFromMatrixColumn( m, 2 ).length();\n\n\t\tte[ 0 ] = me[ 0 ] * scaleX;\n\t\tte[ 1 ] = me[ 1 ] * scaleX;\n\t\tte[ 2 ] = me[ 2 ] * scaleX;\n\t\tte[ 3 ] = 0;\n\n\t\tte[ 4 ] = me[ 4 ] * scaleY;\n\t\tte[ 5 ] = me[ 5 ] * scaleY;\n\t\tte[ 6 ] = me[ 6 ] * scaleY;\n\t\tte[ 7 ] = 0;\n\n\t\tte[ 8 ] = me[ 8 ] * scaleZ;\n\t\tte[ 9 ] = me[ 9 ] * scaleZ;\n\t\tte[ 10 ] = me[ 10 ] * scaleZ;\n\t\tte[ 11 ] = 0;\n\n\t\tte[ 12 ] = 0;\n\t\tte[ 13 ] = 0;\n\t\tte[ 14 ] = 0;\n\t\tte[ 15 ] = 1;\n\n\t\treturn this;\n\n\t},\n\n\tmakeRotationFromEuler: function ( euler ) {\n\n\t\tif ( ! ( euler && euler.isEuler ) ) {\n\n\t\t\tconsole.error( 'THREE.Matrix4: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.' );\n\n\t\t}\n\n\t\tconst te = this.elements;\n\n\t\tconst x = euler.x, y = euler.y, z = euler.z;\n\t\tconst a = Math.cos( x ), b = Math.sin( x );\n\t\tconst c = Math.cos( y ), d = Math.sin( y );\n\t\tconst e = Math.cos( z ), f = Math.sin( z );\n\n\t\tif ( euler.order === 'XYZ' ) {\n\n\t\t\tconst ae = a * e, af = a * f, be = b * e, bf = b * f;\n\n\t\t\tte[ 0 ] = c * e;\n\t\t\tte[ 4 ] = - c * f;\n\t\t\tte[ 8 ] = d;\n\n\t\t\tte[ 1 ] = af + be * d;\n\t\t\tte[ 5 ] = ae - bf * d;\n\t\t\tte[ 9 ] = - b * c;\n\n\t\t\tte[ 2 ] = bf - ae * d;\n\t\t\tte[ 6 ] = be + af * d;\n\t\t\tte[ 10 ] = a * c;\n\n\t\t} else if ( euler.order === 'YXZ' ) {\n\n\t\t\tconst ce = c * e, cf = c * f, de = d * e, df = d * f;\n\n\t\t\tte[ 0 ] = ce + df * b;\n\t\t\tte[ 4 ] = de * b - cf;\n\t\t\tte[ 8 ] = a * d;\n\n\t\t\tte[ 1 ] = a * f;\n\t\t\tte[ 5 ] = a * e;\n\t\t\tte[ 9 ] = - b;\n\n\t\t\tte[ 2 ] = cf * b - de;\n\t\t\tte[ 6 ] = df + ce * b;\n\t\t\tte[ 10 ] = a * c;\n\n\t\t} else if ( euler.order === 'ZXY' ) {\n\n\t\t\tconst ce = c * e, cf = c * f, de = d * e, df = d * f;\n\n\t\t\tte[ 0 ] = ce - df * b;\n\t\t\tte[ 4 ] = - a * f;\n\t\t\tte[ 8 ] = de + cf * b;\n\n\t\t\tte[ 1 ] = cf + de * b;\n\t\t\tte[ 5 ] = a * e;\n\t\t\tte[ 9 ] = df - ce * b;\n\n\t\t\tte[ 2 ] = - a * d;\n\t\t\tte[ 6 ] = b;\n\t\t\tte[ 10 ] = a * c;\n\n\t\t} else if ( euler.order === 'ZYX' ) {\n\n\t\t\tconst ae = a * e, af = a * f, be = b * e, bf = b * f;\n\n\t\t\tte[ 0 ] = c * e;\n\t\t\tte[ 4 ] = be * d - af;\n\t\t\tte[ 8 ] = ae * d + bf;\n\n\t\t\tte[ 1 ] = c * f;\n\t\t\tte[ 5 ] = bf * d + ae;\n\t\t\tte[ 9 ] = af * d - be;\n\n\t\t\tte[ 2 ] = - d;\n\t\t\tte[ 6 ] = b * c;\n\t\t\tte[ 10 ] = a * c;\n\n\t\t} else if ( euler.order === 'YZX' ) {\n\n\t\t\tconst ac = a * c, ad = a * d, bc = b * c, bd = b * d;\n\n\t\t\tte[ 0 ] = c * e;\n\t\t\tte[ 4 ] = bd - ac * f;\n\t\t\tte[ 8 ] = bc * f + ad;\n\n\t\t\tte[ 1 ] = f;\n\t\t\tte[ 5 ] = a * e;\n\t\t\tte[ 9 ] = - b * e;\n\n\t\t\tte[ 2 ] = - d * e;\n\t\t\tte[ 6 ] = ad * f + bc;\n\t\t\tte[ 10 ] = ac - bd * f;\n\n\t\t} else if ( euler.order === 'XZY' ) {\n\n\t\t\tconst ac = a * c, ad = a * d, bc = b * c, bd = b * d;\n\n\t\t\tte[ 0 ] = c * e;\n\t\t\tte[ 4 ] = - f;\n\t\t\tte[ 8 ] = d * e;\n\n\t\t\tte[ 1 ] = ac * f + bd;\n\t\t\tte[ 5 ] = a * e;\n\t\t\tte[ 9 ] = ad * f - bc;\n\n\t\t\tte[ 2 ] = bc * f - ad;\n\t\t\tte[ 6 ] = b * e;\n\t\t\tte[ 10 ] = bd * f + ac;\n\n\t\t}\n\n\t\t// bottom row\n\t\tte[ 3 ] = 0;\n\t\tte[ 7 ] = 0;\n\t\tte[ 11 ] = 0;\n\n\t\t// last column\n\t\tte[ 12 ] = 0;\n\t\tte[ 13 ] = 0;\n\t\tte[ 14 ] = 0;\n\t\tte[ 15 ] = 1;\n\n\t\treturn this;\n\n\t},\n\n\tmakeRotationFromQuaternion: function ( q ) {\n\n\t\treturn this.compose( _zero, q, _one );\n\n\t},\n\n\tlookAt: function ( eye, target, up ) {\n\n\t\tconst te = this.elements;\n\n\t\t_z.subVectors( eye, target );\n\n\t\tif ( _z.lengthSq() === 0 ) {\n\n\t\t\t// eye and target are in the same position\n\n\t\t\t_z.z = 1;\n\n\t\t}\n\n\t\t_z.normalize();\n\t\t_x.crossVectors( up, _z );\n\n\t\tif ( _x.lengthSq() === 0 ) {\n\n\t\t\t// up and z are parallel\n\n\t\t\tif ( Math.abs( up.z ) === 1 ) {\n\n\t\t\t\t_z.x += 0.0001;\n\n\t\t\t} else {\n\n\t\t\t\t_z.z += 0.0001;\n\n\t\t\t}\n\n\t\t\t_z.normalize();\n\t\t\t_x.crossVectors( up, _z );\n\n\t\t}\n\n\t\t_x.normalize();\n\t\t_y.crossVectors( _z, _x );\n\n\t\tte[ 0 ] = _x.x; te[ 4 ] = _y.x; te[ 8 ] = _z.x;\n\t\tte[ 1 ] = _x.y; te[ 5 ] = _y.y; te[ 9 ] = _z.y;\n\t\tte[ 2 ] = _x.z; te[ 6 ] = _y.z; te[ 10 ] = _z.z;\n\n\t\treturn this;\n\n\t},\n\n\tmultiply: function ( m, n ) {\n\n\t\tif ( n !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead.' );\n\t\t\treturn this.multiplyMatrices( m, n );\n\n\t\t}\n\n\t\treturn this.multiplyMatrices( this, m );\n\n\t},\n\n\tpremultiply: function ( m ) {\n\n\t\treturn this.multiplyMatrices( m, this );\n\n\t},\n\n\tmultiplyMatrices: function ( a, b ) {\n\n\t\tconst ae = a.elements;\n\t\tconst be = b.elements;\n\t\tconst te = this.elements;\n\n\t\tconst a11 = ae[ 0 ], a12 = ae[ 4 ], a13 = ae[ 8 ], a14 = ae[ 12 ];\n\t\tconst a21 = ae[ 1 ], a22 = ae[ 5 ], a23 = ae[ 9 ], a24 = ae[ 13 ];\n\t\tconst a31 = ae[ 2 ], a32 = ae[ 6 ], a33 = ae[ 10 ], a34 = ae[ 14 ];\n\t\tconst a41 = ae[ 3 ], a42 = ae[ 7 ], a43 = ae[ 11 ], a44 = ae[ 15 ];\n\n\t\tconst b11 = be[ 0 ], b12 = be[ 4 ], b13 = be[ 8 ], b14 = be[ 12 ];\n\t\tconst b21 = be[ 1 ], b22 = be[ 5 ], b23 = be[ 9 ], b24 = be[ 13 ];\n\t\tconst b31 = be[ 2 ], b32 = be[ 6 ], b33 = be[ 10 ], b34 = be[ 14 ];\n\t\tconst b41 = be[ 3 ], b42 = be[ 7 ], b43 = be[ 11 ], b44 = be[ 15 ];\n\n\t\tte[ 0 ] = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41;\n\t\tte[ 4 ] = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42;\n\t\tte[ 8 ] = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43;\n\t\tte[ 12 ] = a11 * b14 + a12 * b24 + a13 * b34 + a14 * b44;\n\n\t\tte[ 1 ] = a21 * b11 + a22 * b21 + a23 * b31 + a24 * b41;\n\t\tte[ 5 ] = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42;\n\t\tte[ 9 ] = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43;\n\t\tte[ 13 ] = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44;\n\n\t\tte[ 2 ] = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41;\n\t\tte[ 6 ] = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42;\n\t\tte[ 10 ] = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43;\n\t\tte[ 14 ] = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44;\n\n\t\tte[ 3 ] = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41;\n\t\tte[ 7 ] = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42;\n\t\tte[ 11 ] = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43;\n\t\tte[ 15 ] = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44;\n\n\t\treturn this;\n\n\t},\n\n\tmultiplyScalar: function ( s ) {\n\n\t\tconst te = this.elements;\n\n\t\tte[ 0 ] *= s; te[ 4 ] *= s; te[ 8 ] *= s; te[ 12 ] *= s;\n\t\tte[ 1 ] *= s; te[ 5 ] *= s; te[ 9 ] *= s; te[ 13 ] *= s;\n\t\tte[ 2 ] *= s; te[ 6 ] *= s; te[ 10 ] *= s; te[ 14 ] *= s;\n\t\tte[ 3 ] *= s; te[ 7 ] *= s; te[ 11 ] *= s; te[ 15 ] *= s;\n\n\t\treturn this;\n\n\t},\n\n\tdeterminant: function () {\n\n\t\tconst te = this.elements;\n\n\t\tconst n11 = te[ 0 ], n12 = te[ 4 ], n13 = te[ 8 ], n14 = te[ 12 ];\n\t\tconst n21 = te[ 1 ], n22 = te[ 5 ], n23 = te[ 9 ], n24 = te[ 13 ];\n\t\tconst n31 = te[ 2 ], n32 = te[ 6 ], n33 = te[ 10 ], n34 = te[ 14 ];\n\t\tconst n41 = te[ 3 ], n42 = te[ 7 ], n43 = te[ 11 ], n44 = te[ 15 ];\n\n\t\t//TODO: make this more efficient\n\t\t//( based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm )\n\n\t\treturn (\n\t\t\tn41 * (\n\t\t\t\t+ n14 * n23 * n32\n\t\t\t\t - n13 * n24 * n32\n\t\t\t\t - n14 * n22 * n33\n\t\t\t\t + n12 * n24 * n33\n\t\t\t\t + n13 * n22 * n34\n\t\t\t\t - n12 * n23 * n34\n\t\t\t) +\n\t\t\tn42 * (\n\t\t\t\t+ n11 * n23 * n34\n\t\t\t\t - n11 * n24 * n33\n\t\t\t\t + n14 * n21 * n33\n\t\t\t\t - n13 * n21 * n34\n\t\t\t\t + n13 * n24 * n31\n\t\t\t\t - n14 * n23 * n31\n\t\t\t) +\n\t\t\tn43 * (\n\t\t\t\t+ n11 * n24 * n32\n\t\t\t\t - n11 * n22 * n34\n\t\t\t\t - n14 * n21 * n32\n\t\t\t\t + n12 * n21 * n34\n\t\t\t\t + n14 * n22 * n31\n\t\t\t\t - n12 * n24 * n31\n\t\t\t) +\n\t\t\tn44 * (\n\t\t\t\t- n13 * n22 * n31\n\t\t\t\t - n11 * n23 * n32\n\t\t\t\t + n11 * n22 * n33\n\t\t\t\t + n13 * n21 * n32\n\t\t\t\t - n12 * n21 * n33\n\t\t\t\t + n12 * n23 * n31\n\t\t\t)\n\n\t\t);\n\n\t},\n\n\ttranspose: function () {\n\n\t\tconst te = this.elements;\n\t\tlet tmp;\n\n\t\ttmp = te[ 1 ]; te[ 1 ] = te[ 4 ]; te[ 4 ] = tmp;\n\t\ttmp = te[ 2 ]; te[ 2 ] = te[ 8 ]; te[ 8 ] = tmp;\n\t\ttmp = te[ 6 ]; te[ 6 ] = te[ 9 ]; te[ 9 ] = tmp;\n\n\t\ttmp = te[ 3 ]; te[ 3 ] = te[ 12 ]; te[ 12 ] = tmp;\n\t\ttmp = te[ 7 ]; te[ 7 ] = te[ 13 ]; te[ 13 ] = tmp;\n\t\ttmp = te[ 11 ]; te[ 11 ] = te[ 14 ]; te[ 14 ] = tmp;\n\n\t\treturn this;\n\n\t},\n\n\tsetPosition: function ( x, y, z ) {\n\n\t\tconst te = this.elements;\n\n\t\tif ( x.isVector3 ) {\n\n\t\t\tte[ 12 ] = x.x;\n\t\t\tte[ 13 ] = x.y;\n\t\t\tte[ 14 ] = x.z;\n\n\t\t} else {\n\n\t\t\tte[ 12 ] = x;\n\t\t\tte[ 13 ] = y;\n\t\t\tte[ 14 ] = z;\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tgetInverse: function ( m, throwOnDegenerate ) {\n\n\t\tif ( throwOnDegenerate !== undefined ) {\n\n\t\t\tconsole.warn( \"THREE.Matrix4: .getInverse() can no longer be configured to throw on degenerate.\" );\n\n\t\t}\n\n\t\t// based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm\n\t\tconst te = this.elements,\n\t\t\tme = m.elements,\n\n\t\t\tn11 = me[ 0 ], n21 = me[ 1 ], n31 = me[ 2 ], n41 = me[ 3 ],\n\t\t\tn12 = me[ 4 ], n22 = me[ 5 ], n32 = me[ 6 ], n42 = me[ 7 ],\n\t\t\tn13 = me[ 8 ], n23 = me[ 9 ], n33 = me[ 10 ], n43 = me[ 11 ],\n\t\t\tn14 = me[ 12 ], n24 = me[ 13 ], n34 = me[ 14 ], n44 = me[ 15 ],\n\n\t\t\tt11 = n23 * n34 * n42 - n24 * n33 * n42 + n24 * n32 * n43 - n22 * n34 * n43 - n23 * n32 * n44 + n22 * n33 * n44,\n\t\t\tt12 = n14 * n33 * n42 - n13 * n34 * n42 - n14 * n32 * n43 + n12 * n34 * n43 + n13 * n32 * n44 - n12 * n33 * n44,\n\t\t\tt13 = n13 * n24 * n42 - n14 * n23 * n42 + n14 * n22 * n43 - n12 * n24 * n43 - n13 * n22 * n44 + n12 * n23 * n44,\n\t\t\tt14 = n14 * n23 * n32 - n13 * n24 * n32 - n14 * n22 * n33 + n12 * n24 * n33 + n13 * n22 * n34 - n12 * n23 * n34;\n\n\t\tconst det = n11 * t11 + n21 * t12 + n31 * t13 + n41 * t14;\n\n\t\tif ( det === 0 ) return this.set( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 );\n\n\t\tconst detInv = 1 / det;\n\n\t\tte[ 0 ] = t11 * detInv;\n\t\tte[ 1 ] = ( n24 * n33 * n41 - n23 * n34 * n41 - n24 * n31 * n43 + n21 * n34 * n43 + n23 * n31 * n44 - n21 * n33 * n44 ) * detInv;\n\t\tte[ 2 ] = ( n22 * n34 * n41 - n24 * n32 * n41 + n24 * n31 * n42 - n21 * n34 * n42 - n22 * n31 * n44 + n21 * n32 * n44 ) * detInv;\n\t\tte[ 3 ] = ( n23 * n32 * n41 - n22 * n33 * n41 - n23 * n31 * n42 + n21 * n33 * n42 + n22 * n31 * n43 - n21 * n32 * n43 ) * detInv;\n\n\t\tte[ 4 ] = t12 * detInv;\n\t\tte[ 5 ] = ( n13 * n34 * n41 - n14 * n33 * n41 + n14 * n31 * n43 - n11 * n34 * n43 - n13 * n31 * n44 + n11 * n33 * n44 ) * detInv;\n\t\tte[ 6 ] = ( n14 * n32 * n41 - n12 * n34 * n41 - n14 * n31 * n42 + n11 * n34 * n42 + n12 * n31 * n44 - n11 * n32 * n44 ) * detInv;\n\t\tte[ 7 ] = ( n12 * n33 * n41 - n13 * n32 * n41 + n13 * n31 * n42 - n11 * n33 * n42 - n12 * n31 * n43 + n11 * n32 * n43 ) * detInv;\n\n\t\tte[ 8 ] = t13 * detInv;\n\t\tte[ 9 ] = ( n14 * n23 * n41 - n13 * n24 * n41 - n14 * n21 * n43 + n11 * n24 * n43 + n13 * n21 * n44 - n11 * n23 * n44 ) * detInv;\n\t\tte[ 10 ] = ( n12 * n24 * n41 - n14 * n22 * n41 + n14 * n21 * n42 - n11 * n24 * n42 - n12 * n21 * n44 + n11 * n22 * n44 ) * detInv;\n\t\tte[ 11 ] = ( n13 * n22 * n41 - n12 * n23 * n41 - n13 * n21 * n42 + n11 * n23 * n42 + n12 * n21 * n43 - n11 * n22 * n43 ) * detInv;\n\n\t\tte[ 12 ] = t14 * detInv;\n\t\tte[ 13 ] = ( n13 * n24 * n31 - n14 * n23 * n31 + n14 * n21 * n33 - n11 * n24 * n33 - n13 * n21 * n34 + n11 * n23 * n34 ) * detInv;\n\t\tte[ 14 ] = ( n14 * n22 * n31 - n12 * n24 * n31 - n14 * n21 * n32 + n11 * n24 * n32 + n12 * n21 * n34 - n11 * n22 * n34 ) * detInv;\n\t\tte[ 15 ] = ( n12 * n23 * n31 - n13 * n22 * n31 + n13 * n21 * n32 - n11 * n23 * n32 - n12 * n21 * n33 + n11 * n22 * n33 ) * detInv;\n\n\t\treturn this;\n\n\t},\n\n\tscale: function ( v ) {\n\n\t\tconst te = this.elements;\n\t\tconst x = v.x, y = v.y, z = v.z;\n\n\t\tte[ 0 ] *= x; te[ 4 ] *= y; te[ 8 ] *= z;\n\t\tte[ 1 ] *= x; te[ 5 ] *= y; te[ 9 ] *= z;\n\t\tte[ 2 ] *= x; te[ 6 ] *= y; te[ 10 ] *= z;\n\t\tte[ 3 ] *= x; te[ 7 ] *= y; te[ 11 ] *= z;\n\n\t\treturn this;\n\n\t},\n\n\tgetMaxScaleOnAxis: function () {\n\n\t\tconst te = this.elements;\n\n\t\tconst scaleXSq = te[ 0 ] * te[ 0 ] + te[ 1 ] * te[ 1 ] + te[ 2 ] * te[ 2 ];\n\t\tconst scaleYSq = te[ 4 ] * te[ 4 ] + te[ 5 ] * te[ 5 ] + te[ 6 ] * te[ 6 ];\n\t\tconst scaleZSq = te[ 8 ] * te[ 8 ] + te[ 9 ] * te[ 9 ] + te[ 10 ] * te[ 10 ];\n\n\t\treturn Math.sqrt( Math.max( scaleXSq, scaleYSq, scaleZSq ) );\n\n\t},\n\n\tmakeTranslation: function ( x, y, z ) {\n\n\t\tthis.set(\n\n\t\t\t1, 0, 0, x,\n\t\t\t0, 1, 0, y,\n\t\t\t0, 0, 1, z,\n\t\t\t0, 0, 0, 1\n\n\t\t);\n\n\t\treturn this;\n\n\t},\n\n\tmakeRotationX: function ( theta ) {\n\n\t\tconst c = Math.cos( theta ), s = Math.sin( theta );\n\n\t\tthis.set(\n\n\t\t\t1, 0, 0, 0,\n\t\t\t0, c, - s, 0,\n\t\t\t0, s, c, 0,\n\t\t\t0, 0, 0, 1\n\n\t\t);\n\n\t\treturn this;\n\n\t},\n\n\tmakeRotationY: function ( theta ) {\n\n\t\tconst c = Math.cos( theta ), s = Math.sin( theta );\n\n\t\tthis.set(\n\n\t\t\t c, 0, s, 0,\n\t\t\t 0, 1, 0, 0,\n\t\t\t- s, 0, c, 0,\n\t\t\t 0, 0, 0, 1\n\n\t\t);\n\n\t\treturn this;\n\n\t},\n\n\tmakeRotationZ: function ( theta ) {\n\n\t\tconst c = Math.cos( theta ), s = Math.sin( theta );\n\n\t\tthis.set(\n\n\t\t\tc, - s, 0, 0,\n\t\t\ts, c, 0, 0,\n\t\t\t0, 0, 1, 0,\n\t\t\t0, 0, 0, 1\n\n\t\t);\n\n\t\treturn this;\n\n\t},\n\n\tmakeRotationAxis: function ( axis, angle ) {\n\n\t\t// Based on http://www.gamedev.net/reference/articles/article1199.asp\n\n\t\tconst c = Math.cos( angle );\n\t\tconst s = Math.sin( angle );\n\t\tconst t = 1 - c;\n\t\tconst x = axis.x, y = axis.y, z = axis.z;\n\t\tconst tx = t * x, ty = t * y;\n\n\t\tthis.set(\n\n\t\t\ttx * x + c, tx * y - s * z, tx * z + s * y, 0,\n\t\t\ttx * y + s * z, ty * y + c, ty * z - s * x, 0,\n\t\t\ttx * z - s * y, ty * z + s * x, t * z * z + c, 0,\n\t\t\t0, 0, 0, 1\n\n\t\t);\n\n\t\t return this;\n\n\t},\n\n\tmakeScale: function ( x, y, z ) {\n\n\t\tthis.set(\n\n\t\t\tx, 0, 0, 0,\n\t\t\t0, y, 0, 0,\n\t\t\t0, 0, z, 0,\n\t\t\t0, 0, 0, 1\n\n\t\t);\n\n\t\treturn this;\n\n\t},\n\n\tmakeShear: function ( x, y, z ) {\n\n\t\tthis.set(\n\n\t\t\t1, y, z, 0,\n\t\t\tx, 1, z, 0,\n\t\t\tx, y, 1, 0,\n\t\t\t0, 0, 0, 1\n\n\t\t);\n\n\t\treturn this;\n\n\t},\n\n\tcompose: function ( position, quaternion, scale ) {\n\n\t\tconst te = this.elements;\n\n\t\tconst x = quaternion._x, y = quaternion._y, z = quaternion._z, w = quaternion._w;\n\t\tconst x2 = x + x,\ty2 = y + y, z2 = z + z;\n\t\tconst xx = x * x2, xy = x * y2, xz = x * z2;\n\t\tconst yy = y * y2, yz = y * z2, zz = z * z2;\n\t\tconst wx = w * x2, wy = w * y2, wz = w * z2;\n\n\t\tconst sx = scale.x, sy = scale.y, sz = scale.z;\n\n\t\tte[ 0 ] = ( 1 - ( yy + zz ) ) * sx;\n\t\tte[ 1 ] = ( xy + wz ) * sx;\n\t\tte[ 2 ] = ( xz - wy ) * sx;\n\t\tte[ 3 ] = 0;\n\n\t\tte[ 4 ] = ( xy - wz ) * sy;\n\t\tte[ 5 ] = ( 1 - ( xx + zz ) ) * sy;\n\t\tte[ 6 ] = ( yz + wx ) * sy;\n\t\tte[ 7 ] = 0;\n\n\t\tte[ 8 ] = ( xz + wy ) * sz;\n\t\tte[ 9 ] = ( yz - wx ) * sz;\n\t\tte[ 10 ] = ( 1 - ( xx + yy ) ) * sz;\n\t\tte[ 11 ] = 0;\n\n\t\tte[ 12 ] = position.x;\n\t\tte[ 13 ] = position.y;\n\t\tte[ 14 ] = position.z;\n\t\tte[ 15 ] = 1;\n\n\t\treturn this;\n\n\t},\n\n\tdecompose: function ( position, quaternion, scale ) {\n\n\t\tconst te = this.elements;\n\n\t\tlet sx = _v1.set( te[ 0 ], te[ 1 ], te[ 2 ] ).length();\n\t\tlet sy = _v1.set( te[ 4 ], te[ 5 ], te[ 6 ] ).length();\n\t\tlet sz = _v1.set( te[ 8 ], te[ 9 ], te[ 10 ] ).length();\n\n\t\t// if determine is negative, we need to invert one scale\n\t\tconst det = this.determinant();\n\t\tif ( det < 0 ) sx = - sx;\n\n\t\tposition.x = te[ 12 ];\n\t\tposition.y = te[ 13 ];\n\t\tposition.z = te[ 14 ];\n\n\t\t// scale the rotation part\n\t\t_m1.copy( this );\n\n\t\tconst invSX = 1 / sx;\n\t\tconst invSY = 1 / sy;\n\t\tconst invSZ = 1 / sz;\n\n\t\t_m1.elements[ 0 ] *= invSX;\n\t\t_m1.elements[ 1 ] *= invSX;\n\t\t_m1.elements[ 2 ] *= invSX;\n\n\t\t_m1.elements[ 4 ] *= invSY;\n\t\t_m1.elements[ 5 ] *= invSY;\n\t\t_m1.elements[ 6 ] *= invSY;\n\n\t\t_m1.elements[ 8 ] *= invSZ;\n\t\t_m1.elements[ 9 ] *= invSZ;\n\t\t_m1.elements[ 10 ] *= invSZ;\n\n\t\tquaternion.setFromRotationMatrix( _m1 );\n\n\t\tscale.x = sx;\n\t\tscale.y = sy;\n\t\tscale.z = sz;\n\n\t\treturn this;\n\n\t},\n\n\tmakePerspective: function ( left, right, top, bottom, near, far ) {\n\n\t\tif ( far === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Matrix4: .makePerspective() has been redefined and has a new signature. Please check the docs.' );\n\n\t\t}\n\n\t\tconst te = this.elements;\n\t\tconst x = 2 * near / ( right - left );\n\t\tconst y = 2 * near / ( top - bottom );\n\n\t\tconst a = ( right + left ) / ( right - left );\n\t\tconst b = ( top + bottom ) / ( top - bottom );\n\t\tconst c = - ( far + near ) / ( far - near );\n\t\tconst d = - 2 * far * near / ( far - near );\n\n\t\tte[ 0 ] = x;\tte[ 4 ] = 0;\tte[ 8 ] = a;\tte[ 12 ] = 0;\n\t\tte[ 1 ] = 0;\tte[ 5 ] = y;\tte[ 9 ] = b;\tte[ 13 ] = 0;\n\t\tte[ 2 ] = 0;\tte[ 6 ] = 0;\tte[ 10 ] = c;\tte[ 14 ] = d;\n\t\tte[ 3 ] = 0;\tte[ 7 ] = 0;\tte[ 11 ] = - 1;\tte[ 15 ] = 0;\n\n\t\treturn this;\n\n\t},\n\n\tmakeOrthographic: function ( left, right, top, bottom, near, far ) {\n\n\t\tconst te = this.elements;\n\t\tconst w = 1.0 / ( right - left );\n\t\tconst h = 1.0 / ( top - bottom );\n\t\tconst p = 1.0 / ( far - near );\n\n\t\tconst x = ( right + left ) * w;\n\t\tconst y = ( top + bottom ) * h;\n\t\tconst z = ( far + near ) * p;\n\n\t\tte[ 0 ] = 2 * w;\tte[ 4 ] = 0;\tte[ 8 ] = 0;\tte[ 12 ] = - x;\n\t\tte[ 1 ] = 0;\tte[ 5 ] = 2 * h;\tte[ 9 ] = 0;\tte[ 13 ] = - y;\n\t\tte[ 2 ] = 0;\tte[ 6 ] = 0;\tte[ 10 ] = - 2 * p;\tte[ 14 ] = - z;\n\t\tte[ 3 ] = 0;\tte[ 7 ] = 0;\tte[ 11 ] = 0;\tte[ 15 ] = 1;\n\n\t\treturn this;\n\n\t},\n\n\tequals: function ( matrix ) {\n\n\t\tconst te = this.elements;\n\t\tconst me = matrix.elements;\n\n\t\tfor ( let i = 0; i < 16; i ++ ) {\n\n\t\t\tif ( te[ i ] !== me[ i ] ) return false;\n\n\t\t}\n\n\t\treturn true;\n\n\t},\n\n\tfromArray: function ( array, offset ) {\n\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tfor ( let i = 0; i < 16; i ++ ) {\n\n\t\t\tthis.elements[ i ] = array[ i + offset ];\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\ttoArray: function ( array, offset ) {\n\n\t\tif ( array === undefined ) array = [];\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tconst te = this.elements;\n\n\t\tarray[ offset ] = te[ 0 ];\n\t\tarray[ offset + 1 ] = te[ 1 ];\n\t\tarray[ offset + 2 ] = te[ 2 ];\n\t\tarray[ offset + 3 ] = te[ 3 ];\n\n\t\tarray[ offset + 4 ] = te[ 4 ];\n\t\tarray[ offset + 5 ] = te[ 5 ];\n\t\tarray[ offset + 6 ] = te[ 6 ];\n\t\tarray[ offset + 7 ] = te[ 7 ];\n\n\t\tarray[ offset + 8 ] = te[ 8 ];\n\t\tarray[ offset + 9 ] = te[ 9 ];\n\t\tarray[ offset + 10 ] = te[ 10 ];\n\t\tarray[ offset + 11 ] = te[ 11 ];\n\n\t\tarray[ offset + 12 ] = te[ 12 ];\n\t\tarray[ offset + 13 ] = te[ 13 ];\n\t\tarray[ offset + 14 ] = te[ 14 ];\n\t\tarray[ offset + 15 ] = te[ 15 ];\n\n\t\treturn array;\n\n\t}\n\n} );\n\n\nexport { Matrix4 };\n","import { Quaternion } from './Quaternion.js';\nimport { Vector3 } from './Vector3.js';\nimport { Matrix4 } from './Matrix4.js';\nimport { MathUtils } from './MathUtils.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author WestLangley / http://github.com/WestLangley\n * @author bhouston / http://clara.io\n */\n\nconst _matrix = new Matrix4();\nconst _quaternion = new Quaternion();\n\nfunction Euler( x = 0, y = 0, z = 0, order = Euler.DefaultOrder ) {\n\n\tthis._x = x;\n\tthis._y = y;\n\tthis._z = z;\n\tthis._order = order;\n\n}\n\nEuler.RotationOrders = [ 'XYZ', 'YZX', 'ZXY', 'XZY', 'YXZ', 'ZYX' ];\n\nEuler.DefaultOrder = 'XYZ';\n\nObject.defineProperties( Euler.prototype, {\n\n\tx: {\n\n\t\tget: function () {\n\n\t\t\treturn this._x;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tthis._x = value;\n\t\t\tthis._onChangeCallback();\n\n\t\t}\n\n\t},\n\n\ty: {\n\n\t\tget: function () {\n\n\t\t\treturn this._y;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tthis._y = value;\n\t\t\tthis._onChangeCallback();\n\n\t\t}\n\n\t},\n\n\tz: {\n\n\t\tget: function () {\n\n\t\t\treturn this._z;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tthis._z = value;\n\t\t\tthis._onChangeCallback();\n\n\t\t}\n\n\t},\n\n\torder: {\n\n\t\tget: function () {\n\n\t\t\treturn this._order;\n\n\t\t},\n\n\t\tset: function ( value ) {\n\n\t\t\tthis._order = value;\n\t\t\tthis._onChangeCallback();\n\n\t\t}\n\n\t}\n\n} );\n\nObject.assign( Euler.prototype, {\n\n\tisEuler: true,\n\n\tset: function ( x, y, z, order ) {\n\n\t\tthis._x = x;\n\t\tthis._y = y;\n\t\tthis._z = z;\n\t\tthis._order = order || this._order;\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor( this._x, this._y, this._z, this._order );\n\n\t},\n\n\tcopy: function ( euler ) {\n\n\t\tthis._x = euler._x;\n\t\tthis._y = euler._y;\n\t\tthis._z = euler._z;\n\t\tthis._order = euler._order;\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\tsetFromRotationMatrix: function ( m, order, update ) {\n\n\t\tconst clamp = MathUtils.clamp;\n\n\t\t// assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)\n\n\t\tconst te = m.elements;\n\t\tconst m11 = te[ 0 ], m12 = te[ 4 ], m13 = te[ 8 ];\n\t\tconst m21 = te[ 1 ], m22 = te[ 5 ], m23 = te[ 9 ];\n\t\tconst m31 = te[ 2 ], m32 = te[ 6 ], m33 = te[ 10 ];\n\n\t\torder = order || this._order;\n\n\t\tswitch ( order ) {\n\n\t\t\tcase 'XYZ':\n\n\t\t\t\tthis._y = Math.asin( clamp( m13, - 1, 1 ) );\n\n\t\t\t\tif ( Math.abs( m13 ) < 0.9999999 ) {\n\n\t\t\t\t\tthis._x = Math.atan2( - m23, m33 );\n\t\t\t\t\tthis._z = Math.atan2( - m12, m11 );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tthis._x = Math.atan2( m32, m22 );\n\t\t\t\t\tthis._z = 0;\n\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\n\t\t\tcase 'YXZ':\n\n\t\t\t\tthis._x = Math.asin( - clamp( m23, - 1, 1 ) );\n\n\t\t\t\tif ( Math.abs( m23 ) < 0.9999999 ) {\n\n\t\t\t\t\tthis._y = Math.atan2( m13, m33 );\n\t\t\t\t\tthis._z = Math.atan2( m21, m22 );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tthis._y = Math.atan2( - m31, m11 );\n\t\t\t\t\tthis._z = 0;\n\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\n\t\t\tcase 'ZXY':\n\n\t\t\t\tthis._x = Math.asin( clamp( m32, - 1, 1 ) );\n\n\t\t\t\tif ( Math.abs( m32 ) < 0.9999999 ) {\n\n\t\t\t\t\tthis._y = Math.atan2( - m31, m33 );\n\t\t\t\t\tthis._z = Math.atan2( - m12, m22 );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tthis._y = 0;\n\t\t\t\t\tthis._z = Math.atan2( m21, m11 );\n\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\n\t\t\tcase 'ZYX':\n\n\t\t\t\tthis._y = Math.asin( - clamp( m31, - 1, 1 ) );\n\n\t\t\t\tif ( Math.abs( m31 ) < 0.9999999 ) {\n\n\t\t\t\t\tthis._x = Math.atan2( m32, m33 );\n\t\t\t\t\tthis._z = Math.atan2( m21, m11 );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tthis._x = 0;\n\t\t\t\t\tthis._z = Math.atan2( - m12, m22 );\n\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\n\t\t\tcase 'YZX':\n\n\t\t\t\tthis._z = Math.asin( clamp( m21, - 1, 1 ) );\n\n\t\t\t\tif ( Math.abs( m21 ) < 0.9999999 ) {\n\n\t\t\t\t\tthis._x = Math.atan2( - m23, m22 );\n\t\t\t\t\tthis._y = Math.atan2( - m31, m11 );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tthis._x = 0;\n\t\t\t\t\tthis._y = Math.atan2( m13, m33 );\n\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\n\t\t\tcase 'XZY':\n\n\t\t\t\tthis._z = Math.asin( - clamp( m12, - 1, 1 ) );\n\n\t\t\t\tif ( Math.abs( m12 ) < 0.9999999 ) {\n\n\t\t\t\t\tthis._x = Math.atan2( m32, m22 );\n\t\t\t\t\tthis._y = Math.atan2( m13, m11 );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tthis._x = Math.atan2( - m23, m33 );\n\t\t\t\t\tthis._y = 0;\n\n\t\t\t\t}\n\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\n\t\t\t\tconsole.warn( 'THREE.Euler: .setFromRotationMatrix() encountered an unknown order: ' + order );\n\n\t\t}\n\n\t\tthis._order = order;\n\n\t\tif ( update !== false ) this._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\tsetFromQuaternion: function ( q, order, update ) {\n\n\t\t_matrix.makeRotationFromQuaternion( q );\n\n\t\treturn this.setFromRotationMatrix( _matrix, order, update );\n\n\t},\n\n\tsetFromVector3: function ( v, order ) {\n\n\t\treturn this.set( v.x, v.y, v.z, order || this._order );\n\n\t},\n\n\treorder: function ( newOrder ) {\n\n\t\t// WARNING: this discards revolution information -bhouston\n\n\t\t_quaternion.setFromEuler( this );\n\n\t\treturn this.setFromQuaternion( _quaternion, newOrder );\n\n\t},\n\n\tequals: function ( euler ) {\n\n\t\treturn ( euler._x === this._x ) && ( euler._y === this._y ) && ( euler._z === this._z ) && ( euler._order === this._order );\n\n\t},\n\n\tfromArray: function ( array ) {\n\n\t\tthis._x = array[ 0 ];\n\t\tthis._y = array[ 1 ];\n\t\tthis._z = array[ 2 ];\n\t\tif ( array[ 3 ] !== undefined ) this._order = array[ 3 ];\n\n\t\tthis._onChangeCallback();\n\n\t\treturn this;\n\n\t},\n\n\ttoArray: function ( array, offset ) {\n\n\t\tif ( array === undefined ) array = [];\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tarray[ offset ] = this._x;\n\t\tarray[ offset + 1 ] = this._y;\n\t\tarray[ offset + 2 ] = this._z;\n\t\tarray[ offset + 3 ] = this._order;\n\n\t\treturn array;\n\n\t},\n\n\ttoVector3: function ( optionalResult ) {\n\n\t\tif ( optionalResult ) {\n\n\t\t\treturn optionalResult.set( this._x, this._y, this._z );\n\n\t\t} else {\n\n\t\t\treturn new Vector3( this._x, this._y, this._z );\n\n\t\t}\n\n\t},\n\n\t_onChange: function ( callback ) {\n\n\t\tthis._onChangeCallback = callback;\n\n\t\treturn this;\n\n\t},\n\n\t_onChangeCallback: function () {}\n\n} );\n\n\nexport { Euler };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction Layers() {\n\n\tthis.mask = 1 | 0;\n\n}\n\nObject.assign( Layers.prototype, {\n\n\tset: function ( channel ) {\n\n\t\tthis.mask = 1 << channel | 0;\n\n\t},\n\n\tenable: function ( channel ) {\n\n\t\tthis.mask |= 1 << channel | 0;\n\n\t},\n\n\tenableAll: function () {\n\n\t\tthis.mask = 0xffffffff | 0;\n\n\t},\n\n\ttoggle: function ( channel ) {\n\n\t\tthis.mask ^= 1 << channel | 0;\n\n\t},\n\n\tdisable: function ( channel ) {\n\n\t\tthis.mask &= ~ ( 1 << channel | 0 );\n\n\t},\n\n\tdisableAll: function () {\n\n\t\tthis.mask = 0;\n\n\t},\n\n\ttest: function ( layers ) {\n\n\t\treturn ( this.mask & layers.mask ) !== 0;\n\n\t}\n\n} );\n\n\nexport { Layers };\n","import { Quaternion } from '../math/Quaternion.js';\nimport { Vector3 } from '../math/Vector3.js';\nimport { Matrix4 } from '../math/Matrix4.js';\nimport { EventDispatcher } from './EventDispatcher.js';\nimport { Euler } from '../math/Euler.js';\nimport { Layers } from './Layers.js';\nimport { Matrix3 } from '../math/Matrix3.js';\nimport { MathUtils } from '../math/MathUtils.js';\n\nlet _object3DId = 0;\n\nconst _v1 = new Vector3();\nconst _q1 = new Quaternion();\nconst _m1 = new Matrix4();\nconst _target = new Vector3();\n\nconst _position = new Vector3();\nconst _scale = new Vector3();\nconst _quaternion = new Quaternion();\n\nconst _xAxis = new Vector3( 1, 0, 0 );\nconst _yAxis = new Vector3( 0, 1, 0 );\nconst _zAxis = new Vector3( 0, 0, 1 );\n\nconst _addedEvent = { type: 'added' };\nconst _removedEvent = { type: 'removed' };\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author mikael emtinger / http://gomo.se/\n * @author alteredq / http://alteredqualia.com/\n * @author WestLangley / http://github.com/WestLangley\n * @author elephantatwork / www.elephantatwork.ch\n */\n\nfunction Object3D() {\n\n\tObject.defineProperty( this, 'id', { value: _object3DId ++ } );\n\n\tthis.uuid = MathUtils.generateUUID();\n\n\tthis.name = '';\n\tthis.type = 'Object3D';\n\n\tthis.parent = null;\n\tthis.children = [];\n\n\tthis.up = Object3D.DefaultUp.clone();\n\n\tconst position = new Vector3();\n\tconst rotation = new Euler();\n\tconst quaternion = new Quaternion();\n\tconst scale = new Vector3( 1, 1, 1 );\n\n\tfunction onRotationChange() {\n\n\t\tquaternion.setFromEuler( rotation, false );\n\n\t}\n\n\tfunction onQuaternionChange() {\n\n\t\trotation.setFromQuaternion( quaternion, undefined, false );\n\n\t}\n\n\trotation._onChange( onRotationChange );\n\tquaternion._onChange( onQuaternionChange );\n\n\tObject.defineProperties( this, {\n\t\tposition: {\n\t\t\tconfigurable: true,\n\t\t\tenumerable: true,\n\t\t\tvalue: position\n\t\t},\n\t\trotation: {\n\t\t\tconfigurable: true,\n\t\t\tenumerable: true,\n\t\t\tvalue: rotation\n\t\t},\n\t\tquaternion: {\n\t\t\tconfigurable: true,\n\t\t\tenumerable: true,\n\t\t\tvalue: quaternion\n\t\t},\n\t\tscale: {\n\t\t\tconfigurable: true,\n\t\t\tenumerable: true,\n\t\t\tvalue: scale\n\t\t},\n\t\tmodelViewMatrix: {\n\t\t\tvalue: new Matrix4()\n\t\t},\n\t\tnormalMatrix: {\n\t\t\tvalue: new Matrix3()\n\t\t}\n\t} );\n\n\tthis.matrix = new Matrix4();\n\tthis.matrixWorld = new Matrix4();\n\n\tthis.matrixAutoUpdate = Object3D.DefaultMatrixAutoUpdate;\n\tthis.matrixWorldNeedsUpdate = false;\n\n\tthis.layers = new Layers();\n\tthis.visible = true;\n\n\tthis.castShadow = false;\n\tthis.receiveShadow = false;\n\n\tthis.frustumCulled = true;\n\tthis.renderOrder = 0;\n\n\tthis.userData = {};\n\n}\n\nObject3D.DefaultUp = new Vector3( 0, 1, 0 );\nObject3D.DefaultMatrixAutoUpdate = true;\n\nObject3D.prototype = Object.assign( Object.create( EventDispatcher.prototype ), {\n\n\tconstructor: Object3D,\n\n\tisObject3D: true,\n\n\tonBeforeRender: function () {},\n\tonAfterRender: function () {},\n\n\tapplyMatrix4: function ( matrix ) {\n\n\t\tif ( this.matrixAutoUpdate ) this.updateMatrix();\n\n\t\tthis.matrix.premultiply( matrix );\n\n\t\tthis.matrix.decompose( this.position, this.quaternion, this.scale );\n\n\t},\n\n\tapplyQuaternion: function ( q ) {\n\n\t\tthis.quaternion.premultiply( q );\n\n\t\treturn this;\n\n\t},\n\n\tsetRotationFromAxisAngle: function ( axis, angle ) {\n\n\t\t// assumes axis is normalized\n\n\t\tthis.quaternion.setFromAxisAngle( axis, angle );\n\n\t},\n\n\tsetRotationFromEuler: function ( euler ) {\n\n\t\tthis.quaternion.setFromEuler( euler, true );\n\n\t},\n\n\tsetRotationFromMatrix: function ( m ) {\n\n\t\t// assumes the upper 3x3 of m is a pure rotation matrix (i.e, unscaled)\n\n\t\tthis.quaternion.setFromRotationMatrix( m );\n\n\t},\n\n\tsetRotationFromQuaternion: function ( q ) {\n\n\t\t// assumes q is normalized\n\n\t\tthis.quaternion.copy( q );\n\n\t},\n\n\trotateOnAxis: function ( axis, angle ) {\n\n\t\t// rotate object on axis in object space\n\t\t// axis is assumed to be normalized\n\n\t\t_q1.setFromAxisAngle( axis, angle );\n\n\t\tthis.quaternion.multiply( _q1 );\n\n\t\treturn this;\n\n\t},\n\n\trotateOnWorldAxis: function ( axis, angle ) {\n\n\t\t// rotate object on axis in world space\n\t\t// axis is assumed to be normalized\n\t\t// method assumes no rotated parent\n\n\t\t_q1.setFromAxisAngle( axis, angle );\n\n\t\tthis.quaternion.premultiply( _q1 );\n\n\t\treturn this;\n\n\t},\n\n\trotateX: function ( angle ) {\n\n\t\treturn this.rotateOnAxis( _xAxis, angle );\n\n\t},\n\n\trotateY: function ( angle ) {\n\n\t\treturn this.rotateOnAxis( _yAxis, angle );\n\n\t},\n\n\trotateZ: function ( angle ) {\n\n\t\treturn this.rotateOnAxis( _zAxis, angle );\n\n\t},\n\n\ttranslateOnAxis: function ( axis, distance ) {\n\n\t\t// translate object by distance along axis in object space\n\t\t// axis is assumed to be normalized\n\n\t\t_v1.copy( axis ).applyQuaternion( this.quaternion );\n\n\t\tthis.position.add( _v1.multiplyScalar( distance ) );\n\n\t\treturn this;\n\n\t},\n\n\ttranslateX: function ( distance ) {\n\n\t\treturn this.translateOnAxis( _xAxis, distance );\n\n\t},\n\n\ttranslateY: function ( distance ) {\n\n\t\treturn this.translateOnAxis( _yAxis, distance );\n\n\t},\n\n\ttranslateZ: function ( distance ) {\n\n\t\treturn this.translateOnAxis( _zAxis, distance );\n\n\t},\n\n\tlocalToWorld: function ( vector ) {\n\n\t\treturn vector.applyMatrix4( this.matrixWorld );\n\n\t},\n\n\tworldToLocal: function ( vector ) {\n\n\t\treturn vector.applyMatrix4( _m1.getInverse( this.matrixWorld ) );\n\n\t},\n\n\tlookAt: function ( x, y, z ) {\n\n\t\t// This method does not support objects having non-uniformly-scaled parent(s)\n\n\t\tif ( x.isVector3 ) {\n\n\t\t\t_target.copy( x );\n\n\t\t} else {\n\n\t\t\t_target.set( x, y, z );\n\n\t\t}\n\n\t\tconst parent = this.parent;\n\n\t\tthis.updateWorldMatrix( true, false );\n\n\t\t_position.setFromMatrixPosition( this.matrixWorld );\n\n\t\tif ( this.isCamera || this.isLight ) {\n\n\t\t\t_m1.lookAt( _position, _target, this.up );\n\n\t\t} else {\n\n\t\t\t_m1.lookAt( _target, _position, this.up );\n\n\t\t}\n\n\t\tthis.quaternion.setFromRotationMatrix( _m1 );\n\n\t\tif ( parent ) {\n\n\t\t\t_m1.extractRotation( parent.matrixWorld );\n\t\t\t_q1.setFromRotationMatrix( _m1 );\n\t\t\tthis.quaternion.premultiply( _q1.inverse() );\n\n\t\t}\n\n\t},\n\n\tadd: function ( object ) {\n\n\t\tif ( arguments.length > 1 ) {\n\n\t\t\tfor ( let i = 0; i < arguments.length; i ++ ) {\n\n\t\t\t\tthis.add( arguments[ i ] );\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t}\n\n\t\tif ( object === this ) {\n\n\t\t\tconsole.error( \"THREE.Object3D.add: object can't be added as a child of itself.\", object );\n\t\t\treturn this;\n\n\t\t}\n\n\t\tif ( ( object && object.isObject3D ) ) {\n\n\t\t\tif ( object.parent !== null ) {\n\n\t\t\t\tobject.parent.remove( object );\n\n\t\t\t}\n\n\t\t\tobject.parent = this;\n\t\t\tthis.children.push( object );\n\n\t\t\tobject.dispatchEvent( _addedEvent );\n\n\t\t} else {\n\n\t\t\tconsole.error( \"THREE.Object3D.add: object not an instance of THREE.Object3D.\", object );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tremove: function ( object ) {\n\n\t\tif ( arguments.length > 1 ) {\n\n\t\t\tfor ( let i = 0; i < arguments.length; i ++ ) {\n\n\t\t\t\tthis.remove( arguments[ i ] );\n\n\t\t\t}\n\n\t\t\treturn this;\n\n\t\t}\n\n\t\tconst index = this.children.indexOf( object );\n\n\t\tif ( index !== - 1 ) {\n\n\t\t\tobject.parent = null;\n\t\t\tthis.children.splice( index, 1 );\n\n\t\t\tobject.dispatchEvent( _removedEvent );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tattach: function ( object ) {\n\n\t\t// adds object as a child of this, while maintaining the object's world transform\n\n\t\tthis.updateWorldMatrix( true, false );\n\n\t\t_m1.getInverse( this.matrixWorld );\n\n\t\tif ( object.parent !== null ) {\n\n\t\t\tobject.parent.updateWorldMatrix( true, false );\n\n\t\t\t_m1.multiply( object.parent.matrixWorld );\n\n\t\t}\n\n\t\tobject.applyMatrix4( _m1 );\n\n\t\tobject.updateWorldMatrix( false, false );\n\n\t\tthis.add( object );\n\n\t\treturn this;\n\n\t},\n\n\tgetObjectById: function ( id ) {\n\n\t\treturn this.getObjectByProperty( 'id', id );\n\n\t},\n\n\tgetObjectByName: function ( name ) {\n\n\t\treturn this.getObjectByProperty( 'name', name );\n\n\t},\n\n\tgetObjectByProperty: function ( name, value ) {\n\n\t\tif ( this[ name ] === value ) return this;\n\n\t\tfor ( let i = 0, l = this.children.length; i < l; i ++ ) {\n\n\t\t\tconst child = this.children[ i ];\n\t\t\tconst object = child.getObjectByProperty( name, value );\n\n\t\t\tif ( object !== undefined ) {\n\n\t\t\t\treturn object;\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn undefined;\n\n\t},\n\n\tgetWorldPosition: function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Object3D: .getWorldPosition() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\tthis.updateMatrixWorld( true );\n\n\t\treturn target.setFromMatrixPosition( this.matrixWorld );\n\n\t},\n\n\tgetWorldQuaternion: function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Object3D: .getWorldQuaternion() target is now required' );\n\t\t\ttarget = new Quaternion();\n\n\t\t}\n\n\t\tthis.updateMatrixWorld( true );\n\n\t\tthis.matrixWorld.decompose( _position, target, _scale );\n\n\t\treturn target;\n\n\t},\n\n\tgetWorldScale: function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Object3D: .getWorldScale() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\tthis.updateMatrixWorld( true );\n\n\t\tthis.matrixWorld.decompose( _position, _quaternion, target );\n\n\t\treturn target;\n\n\t},\n\n\tgetWorldDirection: function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Object3D: .getWorldDirection() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\tthis.updateMatrixWorld( true );\n\n\t\tconst e = this.matrixWorld.elements;\n\n\t\treturn target.set( e[ 8 ], e[ 9 ], e[ 10 ] ).normalize();\n\n\t},\n\n\traycast: function () {},\n\n\ttraverse: function ( callback ) {\n\n\t\tcallback( this );\n\n\t\tconst children = this.children;\n\n\t\tfor ( let i = 0, l = children.length; i < l; i ++ ) {\n\n\t\t\tchildren[ i ].traverse( callback );\n\n\t\t}\n\n\t},\n\n\ttraverseVisible: function ( callback ) {\n\n\t\tif ( this.visible === false ) return;\n\n\t\tcallback( this );\n\n\t\tconst children = this.children;\n\n\t\tfor ( let i = 0, l = children.length; i < l; i ++ ) {\n\n\t\t\tchildren[ i ].traverseVisible( callback );\n\n\t\t}\n\n\t},\n\n\ttraverseAncestors: function ( callback ) {\n\n\t\tconst parent = this.parent;\n\n\t\tif ( parent !== null ) {\n\n\t\t\tcallback( parent );\n\n\t\t\tparent.traverseAncestors( callback );\n\n\t\t}\n\n\t},\n\n\tupdateMatrix: function () {\n\n\t\tthis.matrix.compose( this.position, this.quaternion, this.scale );\n\n\t\tthis.matrixWorldNeedsUpdate = true;\n\n\t},\n\n\tupdateMatrixWorld: function ( force ) {\n\n\t\tif ( this.matrixAutoUpdate ) this.updateMatrix();\n\n\t\tif ( this.matrixWorldNeedsUpdate || force ) {\n\n\t\t\tif ( this.parent === null ) {\n\n\t\t\t\tthis.matrixWorld.copy( this.matrix );\n\n\t\t\t} else {\n\n\t\t\t\tthis.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix );\n\n\t\t\t}\n\n\t\t\tthis.matrixWorldNeedsUpdate = false;\n\n\t\t\tforce = true;\n\n\t\t}\n\n\t\t// update children\n\n\t\tconst children = this.children;\n\n\t\tfor ( let i = 0, l = children.length; i < l; i ++ ) {\n\n\t\t\tchildren[ i ].updateMatrixWorld( force );\n\n\t\t}\n\n\t},\n\n\tupdateWorldMatrix: function ( updateParents, updateChildren ) {\n\n\t\tconst parent = this.parent;\n\n\t\tif ( updateParents === true && parent !== null ) {\n\n\t\t\tparent.updateWorldMatrix( true, false );\n\n\t\t}\n\n\t\tif ( this.matrixAutoUpdate ) this.updateMatrix();\n\n\t\tif ( this.parent === null ) {\n\n\t\t\tthis.matrixWorld.copy( this.matrix );\n\n\t\t} else {\n\n\t\t\tthis.matrixWorld.multiplyMatrices( this.parent.matrixWorld, this.matrix );\n\n\t\t}\n\n\t\t// update children\n\n\t\tif ( updateChildren === true ) {\n\n\t\t\tconst children = this.children;\n\n\t\t\tfor ( let i = 0, l = children.length; i < l; i ++ ) {\n\n\t\t\t\tchildren[ i ].updateWorldMatrix( false, true );\n\n\t\t\t}\n\n\t\t}\n\n\t},\n\n\ttoJSON: function ( meta ) {\n\n\t\t// meta is a string when called from JSON.stringify\n\t\tconst isRootObject = ( meta === undefined || typeof meta === 'string' );\n\n\t\tconst output = {};\n\n\t\t// meta is a hash used to collect geometries, materials.\n\t\t// not providing it implies that this is the root object\n\t\t// being serialized.\n\t\tif ( isRootObject ) {\n\n\t\t\t// initialize meta obj\n\t\t\tmeta = {\n\t\t\t\tgeometries: {},\n\t\t\t\tmaterials: {},\n\t\t\t\ttextures: {},\n\t\t\t\timages: {},\n\t\t\t\tshapes: {}\n\t\t\t};\n\n\t\t\toutput.metadata = {\n\t\t\t\tversion: 4.5,\n\t\t\t\ttype: 'Object',\n\t\t\t\tgenerator: 'Object3D.toJSON'\n\t\t\t};\n\n\t\t}\n\n\t\t// standard Object3D serialization\n\n\t\tconst object = {};\n\n\t\tobject.uuid = this.uuid;\n\t\tobject.type = this.type;\n\n\t\tif ( this.name !== '' ) object.name = this.name;\n\t\tif ( this.castShadow === true ) object.castShadow = true;\n\t\tif ( this.receiveShadow === true ) object.receiveShadow = true;\n\t\tif ( this.visible === false ) object.visible = false;\n\t\tif ( this.frustumCulled === false ) object.frustumCulled = false;\n\t\tif ( this.renderOrder !== 0 ) object.renderOrder = this.renderOrder;\n\t\tif ( JSON.stringify( this.userData ) !== '{}' ) object.userData = this.userData;\n\n\t\tobject.layers = this.layers.mask;\n\t\tobject.matrix = this.matrix.toArray();\n\n\t\tif ( this.matrixAutoUpdate === false ) object.matrixAutoUpdate = false;\n\n\t\t// object specific properties\n\n\t\tif ( this.isInstancedMesh ) {\n\n\t\t\tobject.type = 'InstancedMesh';\n\t\t\tobject.count = this.count;\n\t\t\tobject.instanceMatrix = this.instanceMatrix.toJSON();\n\n\t\t}\n\n\t\t//\n\n\t\tfunction serialize( library, element ) {\n\n\t\t\tif ( library[ element.uuid ] === undefined ) {\n\n\t\t\t\tlibrary[ element.uuid ] = element.toJSON( meta );\n\n\t\t\t}\n\n\t\t\treturn element.uuid;\n\n\t\t}\n\n\t\tif ( this.isMesh || this.isLine || this.isPoints ) {\n\n\t\t\tobject.geometry = serialize( meta.geometries, this.geometry );\n\n\t\t\tconst parameters = this.geometry.parameters;\n\n\t\t\tif ( parameters !== undefined && parameters.shapes !== undefined ) {\n\n\t\t\t\tconst shapes = parameters.shapes;\n\n\t\t\t\tif ( Array.isArray( shapes ) ) {\n\n\t\t\t\t\tfor ( let i = 0, l = shapes.length; i < l; i ++ ) {\n\n\t\t\t\t\t\tconst shape = shapes[ i ];\n\n\t\t\t\t\t\tserialize( meta.shapes, shape );\n\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\n\t\t\t\t\tserialize( meta.shapes, shapes );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( this.material !== undefined ) {\n\n\t\t\tif ( Array.isArray( this.material ) ) {\n\n\t\t\t\tconst uuids = [];\n\n\t\t\t\tfor ( let i = 0, l = this.material.length; i < l; i ++ ) {\n\n\t\t\t\t\tuuids.push( serialize( meta.materials, this.material[ i ] ) );\n\n\t\t\t\t}\n\n\t\t\t\tobject.material = uuids;\n\n\t\t\t} else {\n\n\t\t\t\tobject.material = serialize( meta.materials, this.material );\n\n\t\t\t}\n\n\t\t}\n\n\t\t//\n\n\t\tif ( this.children.length > 0 ) {\n\n\t\t\tobject.children = [];\n\n\t\t\tfor ( let i = 0; i < this.children.length; i ++ ) {\n\n\t\t\t\tobject.children.push( this.children[ i ].toJSON( meta ).object );\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( isRootObject ) {\n\n\t\t\tconst geometries = extractFromCache( meta.geometries );\n\t\t\tconst materials = extractFromCache( meta.materials );\n\t\t\tconst textures = extractFromCache( meta.textures );\n\t\t\tconst images = extractFromCache( meta.images );\n\t\t\tconst shapes = extractFromCache( meta.shapes );\n\n\t\t\tif ( geometries.length > 0 ) output.geometries = geometries;\n\t\t\tif ( materials.length > 0 ) output.materials = materials;\n\t\t\tif ( textures.length > 0 ) output.textures = textures;\n\t\t\tif ( images.length > 0 ) output.images = images;\n\t\t\tif ( shapes.length > 0 ) output.shapes = shapes;\n\n\t\t}\n\n\t\toutput.object = object;\n\n\t\treturn output;\n\n\t\t// extract data from the cache hash\n\t\t// remove metadata on each item\n\t\t// and return as array\n\t\tfunction extractFromCache( cache ) {\n\n\t\t\tconst values = [];\n\t\t\tfor ( const key in cache ) {\n\n\t\t\t\tconst data = cache[ key ];\n\t\t\t\tdelete data.metadata;\n\t\t\t\tvalues.push( data );\n\n\t\t\t}\n\n\t\t\treturn values;\n\n\t\t}\n\n\t},\n\n\tclone: function ( recursive ) {\n\n\t\treturn new this.constructor().copy( this, recursive );\n\n\t},\n\n\tcopy: function ( source, recursive ) {\n\n\t\tif ( recursive === undefined ) recursive = true;\n\n\t\tthis.name = source.name;\n\n\t\tthis.up.copy( source.up );\n\n\t\tthis.position.copy( source.position );\n\t\tthis.quaternion.copy( source.quaternion );\n\t\tthis.scale.copy( source.scale );\n\n\t\tthis.matrix.copy( source.matrix );\n\t\tthis.matrixWorld.copy( source.matrixWorld );\n\n\t\tthis.matrixAutoUpdate = source.matrixAutoUpdate;\n\t\tthis.matrixWorldNeedsUpdate = source.matrixWorldNeedsUpdate;\n\n\t\tthis.layers.mask = source.layers.mask;\n\t\tthis.visible = source.visible;\n\n\t\tthis.castShadow = source.castShadow;\n\t\tthis.receiveShadow = source.receiveShadow;\n\n\t\tthis.frustumCulled = source.frustumCulled;\n\t\tthis.renderOrder = source.renderOrder;\n\n\t\tthis.userData = JSON.parse( JSON.stringify( source.userData ) );\n\n\t\tif ( recursive === true ) {\n\n\t\t\tfor ( let i = 0; i < source.children.length; i ++ ) {\n\n\t\t\t\tconst child = source.children[ i ];\n\t\t\t\tthis.add( child.clone() );\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn this;\n\n\t}\n\n} );\n\n\nexport { Object3D };\n","import { Object3D } from '../core/Object3D.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction Scene() {\n\n\tObject3D.call( this );\n\n\tthis.type = 'Scene';\n\n\tthis.background = null;\n\tthis.environment = null;\n\tthis.fog = null;\n\n\tthis.overrideMaterial = null;\n\n\tthis.autoUpdate = true; // checked by the renderer\n\n\tif ( typeof __THREE_DEVTOOLS__ !== 'undefined' ) {\n\n\t\t__THREE_DEVTOOLS__.dispatchEvent( new CustomEvent( 'observe', { detail: this } ) ); // eslint-disable-line no-undef\n\n\t}\n\n}\n\nScene.prototype = Object.assign( Object.create( Object3D.prototype ), {\n\n\tconstructor: Scene,\n\n\tisScene: true,\n\n\tcopy: function ( source, recursive ) {\n\n\t\tObject3D.prototype.copy.call( this, source, recursive );\n\n\t\tif ( source.background !== null ) this.background = source.background.clone();\n\t\tif ( source.environment !== null ) this.environment = source.environment.clone();\n\t\tif ( source.fog !== null ) this.fog = source.fog.clone();\n\n\t\tif ( source.overrideMaterial !== null ) this.overrideMaterial = source.overrideMaterial.clone();\n\n\t\tthis.autoUpdate = source.autoUpdate;\n\t\tthis.matrixAutoUpdate = source.matrixAutoUpdate;\n\n\t\treturn this;\n\n\t},\n\n\ttoJSON: function ( meta ) {\n\n\t\tconst data = Object3D.prototype.toJSON.call( this, meta );\n\n\t\tif ( this.background !== null ) data.object.background = this.background.toJSON( meta );\n\t\tif ( this.environment !== null ) data.object.environment = this.environment.toJSON( meta );\n\t\tif ( this.fog !== null ) data.object.fog = this.fog.toJSON();\n\n\t\treturn data;\n\n\t},\n\n\tdispose: function () {\n\n\t\tthis.dispatchEvent( { type: 'dispose' } );\n\n\t}\n\n} );\n\n\n\nexport { Scene };\n","import { Vector3 } from './Vector3.js';\n\nconst _points = [\n\tnew Vector3(),\n\tnew Vector3(),\n\tnew Vector3(),\n\tnew Vector3(),\n\tnew Vector3(),\n\tnew Vector3(),\n\tnew Vector3(),\n\tnew Vector3()\n];\n\nconst _vector = new Vector3();\n\nconst _box = new Box3();\n\n// triangle centered vertices\n\nconst _v0 = new Vector3();\nconst _v1 = new Vector3();\nconst _v2 = new Vector3();\n\n// triangle edge vectors\n\nconst _f0 = new Vector3();\nconst _f1 = new Vector3();\nconst _f2 = new Vector3();\n\nconst _center = new Vector3();\nconst _extents = new Vector3();\nconst _triangleNormal = new Vector3();\nconst _testAxis = new Vector3();\n\n/**\n * @author bhouston / http://clara.io\n * @author WestLangley / http://github.com/WestLangley\n */\n\nfunction Box3( min, max ) {\n\n\tthis.min = ( min !== undefined ) ? min : new Vector3( + Infinity, + Infinity, + Infinity );\n\tthis.max = ( max !== undefined ) ? max : new Vector3( - Infinity, - Infinity, - Infinity );\n\n}\n\n\nObject.assign( Box3.prototype, {\n\n\tisBox3: true,\n\n\tset: function ( min, max ) {\n\n\t\tthis.min.copy( min );\n\t\tthis.max.copy( max );\n\n\t\treturn this;\n\n\t},\n\n\tsetFromArray: function ( array ) {\n\n\t\tlet minX = + Infinity;\n\t\tlet minY = + Infinity;\n\t\tlet minZ = + Infinity;\n\n\t\tlet maxX = - Infinity;\n\t\tlet maxY = - Infinity;\n\t\tlet maxZ = - Infinity;\n\n\t\tfor ( let i = 0, l = array.length; i < l; i += 3 ) {\n\n\t\t\tconst x = array[ i ];\n\t\t\tconst y = array[ i + 1 ];\n\t\t\tconst z = array[ i + 2 ];\n\n\t\t\tif ( x < minX ) minX = x;\n\t\t\tif ( y < minY ) minY = y;\n\t\t\tif ( z < minZ ) minZ = z;\n\n\t\t\tif ( x > maxX ) maxX = x;\n\t\t\tif ( y > maxY ) maxY = y;\n\t\t\tif ( z > maxZ ) maxZ = z;\n\n\t\t}\n\n\t\tthis.min.set( minX, minY, minZ );\n\t\tthis.max.set( maxX, maxY, maxZ );\n\n\t\treturn this;\n\n\t},\n\n\tsetFromBufferAttribute: function ( attribute ) {\n\n\t\tlet minX = + Infinity;\n\t\tlet minY = + Infinity;\n\t\tlet minZ = + Infinity;\n\n\t\tlet maxX = - Infinity;\n\t\tlet maxY = - Infinity;\n\t\tlet maxZ = - Infinity;\n\n\t\tfor ( let i = 0, l = attribute.count; i < l; i ++ ) {\n\n\t\t\tconst x = attribute.getX( i );\n\t\t\tconst y = attribute.getY( i );\n\t\t\tconst z = attribute.getZ( i );\n\n\t\t\tif ( x < minX ) minX = x;\n\t\t\tif ( y < minY ) minY = y;\n\t\t\tif ( z < minZ ) minZ = z;\n\n\t\t\tif ( x > maxX ) maxX = x;\n\t\t\tif ( y > maxY ) maxY = y;\n\t\t\tif ( z > maxZ ) maxZ = z;\n\n\t\t}\n\n\t\tthis.min.set( minX, minY, minZ );\n\t\tthis.max.set( maxX, maxY, maxZ );\n\n\t\treturn this;\n\n\t},\n\n\tsetFromPoints: function ( points ) {\n\n\t\tthis.makeEmpty();\n\n\t\tfor ( let i = 0, il = points.length; i < il; i ++ ) {\n\n\t\t\tthis.expandByPoint( points[ i ] );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tsetFromCenterAndSize: function ( center, size ) {\n\n\t\tconst halfSize = _vector.copy( size ).multiplyScalar( 0.5 );\n\n\t\tthis.min.copy( center ).sub( halfSize );\n\t\tthis.max.copy( center ).add( halfSize );\n\n\t\treturn this;\n\n\t},\n\n\tsetFromObject: function ( object ) {\n\n\t\tthis.makeEmpty();\n\n\t\treturn this.expandByObject( object );\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor().copy( this );\n\n\t},\n\n\tcopy: function ( box ) {\n\n\t\tthis.min.copy( box.min );\n\t\tthis.max.copy( box.max );\n\n\t\treturn this;\n\n\t},\n\n\tmakeEmpty: function () {\n\n\t\tthis.min.x = this.min.y = this.min.z = + Infinity;\n\t\tthis.max.x = this.max.y = this.max.z = - Infinity;\n\n\t\treturn this;\n\n\t},\n\n\tisEmpty: function () {\n\n\t\t// this is a more robust check for empty than ( volume <= 0 ) because volume can get positive with two negative axes\n\n\t\treturn ( this.max.x < this.min.x ) || ( this.max.y < this.min.y ) || ( this.max.z < this.min.z );\n\n\t},\n\n\tgetCenter: function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Box3: .getCenter() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\treturn this.isEmpty() ? target.set( 0, 0, 0 ) : target.addVectors( this.min, this.max ).multiplyScalar( 0.5 );\n\n\t},\n\n\tgetSize: function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Box3: .getSize() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\treturn this.isEmpty() ? target.set( 0, 0, 0 ) : target.subVectors( this.max, this.min );\n\n\t},\n\n\texpandByPoint: function ( point ) {\n\n\t\tthis.min.min( point );\n\t\tthis.max.max( point );\n\n\t\treturn this;\n\n\t},\n\n\texpandByVector: function ( vector ) {\n\n\t\tthis.min.sub( vector );\n\t\tthis.max.add( vector );\n\n\t\treturn this;\n\n\t},\n\n\texpandByScalar: function ( scalar ) {\n\n\t\tthis.min.addScalar( - scalar );\n\t\tthis.max.addScalar( scalar );\n\n\t\treturn this;\n\n\t},\n\n\texpandByObject: function ( object ) {\n\n\t\t// Computes the world-axis-aligned bounding box of an object (including its children),\n\t\t// accounting for both the object's, and children's, world transforms\n\n\t\tobject.updateWorldMatrix( false, false );\n\n\t\tconst geometry = object.geometry;\n\n\t\tif ( geometry !== undefined ) {\n\n\t\t\tif ( geometry.boundingBox === null ) {\n\n\t\t\t\tgeometry.computeBoundingBox();\n\n\t\t\t}\n\n\t\t\t_box.copy( geometry.boundingBox );\n\t\t\t_box.applyMatrix4( object.matrixWorld );\n\n\t\t\tthis.union( _box );\n\n\t\t}\n\n\t\tconst children = object.children;\n\n\t\tfor ( let i = 0, l = children.length; i < l; i ++ ) {\n\n\t\t\tthis.expandByObject( children[ i ] );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tcontainsPoint: function ( point ) {\n\n\t\treturn point.x < this.min.x || point.x > this.max.x ||\n\t\t\tpoint.y < this.min.y || point.y > this.max.y ||\n\t\t\tpoint.z < this.min.z || point.z > this.max.z ? false : true;\n\n\t},\n\n\tcontainsBox: function ( box ) {\n\n\t\treturn this.min.x <= box.min.x && box.max.x <= this.max.x &&\n\t\t\tthis.min.y <= box.min.y && box.max.y <= this.max.y &&\n\t\t\tthis.min.z <= box.min.z && box.max.z <= this.max.z;\n\n\t},\n\n\tgetParameter: function ( point, target ) {\n\n\t\t// This can potentially have a divide by zero if the box\n\t\t// has a size dimension of 0.\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Box3: .getParameter() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\treturn target.set(\n\t\t\t( point.x - this.min.x ) / ( this.max.x - this.min.x ),\n\t\t\t( point.y - this.min.y ) / ( this.max.y - this.min.y ),\n\t\t\t( point.z - this.min.z ) / ( this.max.z - this.min.z )\n\t\t);\n\n\t},\n\n\tintersectsBox: function ( box ) {\n\n\t\t// using 6 splitting planes to rule out intersections.\n\t\treturn box.max.x < this.min.x || box.min.x > this.max.x ||\n\t\t\tbox.max.y < this.min.y || box.min.y > this.max.y ||\n\t\t\tbox.max.z < this.min.z || box.min.z > this.max.z ? false : true;\n\n\t},\n\n\tintersectsSphere: function ( sphere ) {\n\n\t\t// Find the point on the AABB closest to the sphere center.\n\t\tthis.clampPoint( sphere.center, _vector );\n\n\t\t// If that point is inside the sphere, the AABB and sphere intersect.\n\t\treturn _vector.distanceToSquared( sphere.center ) <= ( sphere.radius * sphere.radius );\n\n\t},\n\n\tintersectsPlane: function ( plane ) {\n\n\t\t// We compute the minimum and maximum dot product values. If those values\n\t\t// are on the same side (back or front) of the plane, then there is no intersection.\n\n\t\tlet min, max;\n\n\t\tif ( plane.normal.x > 0 ) {\n\n\t\t\tmin = plane.normal.x * this.min.x;\n\t\t\tmax = plane.normal.x * this.max.x;\n\n\t\t} else {\n\n\t\t\tmin = plane.normal.x * this.max.x;\n\t\t\tmax = plane.normal.x * this.min.x;\n\n\t\t}\n\n\t\tif ( plane.normal.y > 0 ) {\n\n\t\t\tmin += plane.normal.y * this.min.y;\n\t\t\tmax += plane.normal.y * this.max.y;\n\n\t\t} else {\n\n\t\t\tmin += plane.normal.y * this.max.y;\n\t\t\tmax += plane.normal.y * this.min.y;\n\n\t\t}\n\n\t\tif ( plane.normal.z > 0 ) {\n\n\t\t\tmin += plane.normal.z * this.min.z;\n\t\t\tmax += plane.normal.z * this.max.z;\n\n\t\t} else {\n\n\t\t\tmin += plane.normal.z * this.max.z;\n\t\t\tmax += plane.normal.z * this.min.z;\n\n\t\t}\n\n\t\treturn ( min <= - plane.constant && max >= - plane.constant );\n\n\t},\n\n\tintersectsTriangle: function ( triangle ) {\n\n\t\tif ( this.isEmpty() ) {\n\n\t\t\treturn false;\n\n\t\t}\n\n\t\t// compute box center and extents\n\t\tthis.getCenter( _center );\n\t\t_extents.subVectors( this.max, _center );\n\n\t\t// translate triangle to aabb origin\n\t\t_v0.subVectors( triangle.a, _center );\n\t\t_v1.subVectors( triangle.b, _center );\n\t\t_v2.subVectors( triangle.c, _center );\n\n\t\t// compute edge vectors for triangle\n\t\t_f0.subVectors( _v1, _v0 );\n\t\t_f1.subVectors( _v2, _v1 );\n\t\t_f2.subVectors( _v0, _v2 );\n\n\t\t// test against axes that are given by cross product combinations of the edges of the triangle and the edges of the aabb\n\t\t// make an axis testing of each of the 3 sides of the aabb against each of the 3 sides of the triangle = 9 axis of separation\n\t\t// axis_ij = u_i x f_j (u0, u1, u2 = face normals of aabb = x,y,z axes vectors since aabb is axis aligned)\n\t\tlet axes = [\n\t\t\t0, - _f0.z, _f0.y, 0, - _f1.z, _f1.y, 0, - _f2.z, _f2.y,\n\t\t\t_f0.z, 0, - _f0.x, _f1.z, 0, - _f1.x, _f2.z, 0, - _f2.x,\n\t\t\t- _f0.y, _f0.x, 0, - _f1.y, _f1.x, 0, - _f2.y, _f2.x, 0\n\t\t];\n\t\tif ( ! satForAxes( axes, _v0, _v1, _v2, _extents ) ) {\n\n\t\t\treturn false;\n\n\t\t}\n\n\t\t// test 3 face normals from the aabb\n\t\taxes = [ 1, 0, 0, 0, 1, 0, 0, 0, 1 ];\n\t\tif ( ! satForAxes( axes, _v0, _v1, _v2, _extents ) ) {\n\n\t\t\treturn false;\n\n\t\t}\n\n\t\t// finally testing the face normal of the triangle\n\t\t// use already existing triangle edge vectors here\n\t\t_triangleNormal.crossVectors( _f0, _f1 );\n\t\taxes = [ _triangleNormal.x, _triangleNormal.y, _triangleNormal.z ];\n\n\t\treturn satForAxes( axes, _v0, _v1, _v2, _extents );\n\n\t},\n\n\tclampPoint: function ( point, target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Box3: .clampPoint() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\treturn target.copy( point ).clamp( this.min, this.max );\n\n\t},\n\n\tdistanceToPoint: function ( point ) {\n\n\t\tconst clampedPoint = _vector.copy( point ).clamp( this.min, this.max );\n\n\t\treturn clampedPoint.sub( point ).length();\n\n\t},\n\n\tgetBoundingSphere: function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.error( 'THREE.Box3: .getBoundingSphere() target is now required' );\n\t\t\t//target = new Sphere(); // removed to avoid cyclic dependency\n\n\t\t}\n\n\t\tthis.getCenter( target.center );\n\n\t\ttarget.radius = this.getSize( _vector ).length() * 0.5;\n\n\t\treturn target;\n\n\t},\n\n\tintersect: function ( box ) {\n\n\t\tthis.min.max( box.min );\n\t\tthis.max.min( box.max );\n\n\t\t// ensure that if there is no overlap, the result is fully empty, not slightly empty with non-inf/+inf values that will cause subsequence intersects to erroneously return valid values.\n\t\tif ( this.isEmpty() ) this.makeEmpty();\n\n\t\treturn this;\n\n\t},\n\n\tunion: function ( box ) {\n\n\t\tthis.min.min( box.min );\n\t\tthis.max.max( box.max );\n\n\t\treturn this;\n\n\t},\n\n\tapplyMatrix4: function ( matrix ) {\n\n\t\t// transform of empty box is an empty box.\n\t\tif ( this.isEmpty() ) return this;\n\n\t\t// NOTE: I am using a binary pattern to specify all 2^3 combinations below\n\t\t_points[ 0 ].set( this.min.x, this.min.y, this.min.z ).applyMatrix4( matrix ); // 000\n\t\t_points[ 1 ].set( this.min.x, this.min.y, this.max.z ).applyMatrix4( matrix ); // 001\n\t\t_points[ 2 ].set( this.min.x, this.max.y, this.min.z ).applyMatrix4( matrix ); // 010\n\t\t_points[ 3 ].set( this.min.x, this.max.y, this.max.z ).applyMatrix4( matrix ); // 011\n\t\t_points[ 4 ].set( this.max.x, this.min.y, this.min.z ).applyMatrix4( matrix ); // 100\n\t\t_points[ 5 ].set( this.max.x, this.min.y, this.max.z ).applyMatrix4( matrix ); // 101\n\t\t_points[ 6 ].set( this.max.x, this.max.y, this.min.z ).applyMatrix4( matrix ); // 110\n\t\t_points[ 7 ].set( this.max.x, this.max.y, this.max.z ).applyMatrix4( matrix ); // 111\n\n\t\tthis.setFromPoints( _points );\n\n\t\treturn this;\n\n\t},\n\n\ttranslate: function ( offset ) {\n\n\t\tthis.min.add( offset );\n\t\tthis.max.add( offset );\n\n\t\treturn this;\n\n\t},\n\n\tequals: function ( box ) {\n\n\t\treturn box.min.equals( this.min ) && box.max.equals( this.max );\n\n\t}\n\n} );\n\nfunction satForAxes( axes, v0, v1, v2, extents ) {\n\n\tfor ( let i = 0, j = axes.length - 3; i <= j; i += 3 ) {\n\n\t\t_testAxis.fromArray( axes, i );\n\t\t// project the aabb onto the seperating axis\n\t\tconst r = extents.x * Math.abs( _testAxis.x ) + extents.y * Math.abs( _testAxis.y ) + extents.z * Math.abs( _testAxis.z );\n\t\t// project all 3 vertices of the triangle onto the seperating axis\n\t\tconst p0 = v0.dot( _testAxis );\n\t\tconst p1 = v1.dot( _testAxis );\n\t\tconst p2 = v2.dot( _testAxis );\n\t\t// actual test, basically see if either of the most extreme of the triangle points intersects r\n\t\tif ( Math.max( - Math.max( p0, p1, p2 ), Math.min( p0, p1, p2 ) ) > r ) {\n\n\t\t\t// points of the projected triangle are outside the projected half-length of the aabb\n\t\t\t// the axis is seperating and we can exit\n\t\t\treturn false;\n\n\t\t}\n\n\t}\n\n\treturn true;\n\n}\n\nexport { Box3 };\n","import { Box3 } from './Box3.js';\nimport { Vector3 } from './Vector3.js';\n\nconst _box = new Box3();\n\n/**\n * @author bhouston / http://clara.io\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction Sphere( center, radius ) {\n\n\tthis.center = ( center !== undefined ) ? center : new Vector3();\n\tthis.radius = ( radius !== undefined ) ? radius : - 1;\n\n}\n\nObject.assign( Sphere.prototype, {\n\n\tset: function ( center, radius ) {\n\n\t\tthis.center.copy( center );\n\t\tthis.radius = radius;\n\n\t\treturn this;\n\n\t},\n\n\tsetFromPoints: function ( points, optionalCenter ) {\n\n\t\tconst center = this.center;\n\n\t\tif ( optionalCenter !== undefined ) {\n\n\t\t\tcenter.copy( optionalCenter );\n\n\t\t} else {\n\n\t\t\t_box.setFromPoints( points ).getCenter( center );\n\n\t\t}\n\n\t\tlet maxRadiusSq = 0;\n\n\t\tfor ( let i = 0, il = points.length; i < il; i ++ ) {\n\n\t\t\tmaxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( points[ i ] ) );\n\n\t\t}\n\n\t\tthis.radius = Math.sqrt( maxRadiusSq );\n\n\t\treturn this;\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor().copy( this );\n\n\t},\n\n\tcopy: function ( sphere ) {\n\n\t\tthis.center.copy( sphere.center );\n\t\tthis.radius = sphere.radius;\n\n\t\treturn this;\n\n\t},\n\n\tisEmpty: function () {\n\n\t\treturn ( this.radius < 0 );\n\n\t},\n\n\tmakeEmpty: function () {\n\n\t\tthis.center.set( 0, 0, 0 );\n\t\tthis.radius = - 1;\n\n\t\treturn this;\n\n\t},\n\n\tcontainsPoint: function ( point ) {\n\n\t\treturn ( point.distanceToSquared( this.center ) <= ( this.radius * this.radius ) );\n\n\t},\n\n\tdistanceToPoint: function ( point ) {\n\n\t\treturn ( point.distanceTo( this.center ) - this.radius );\n\n\t},\n\n\tintersectsSphere: function ( sphere ) {\n\n\t\tconst radiusSum = this.radius + sphere.radius;\n\n\t\treturn sphere.center.distanceToSquared( this.center ) <= ( radiusSum * radiusSum );\n\n\t},\n\n\tintersectsBox: function ( box ) {\n\n\t\treturn box.intersectsSphere( this );\n\n\t},\n\n\tintersectsPlane: function ( plane ) {\n\n\t\treturn Math.abs( plane.distanceToPoint( this.center ) ) <= this.radius;\n\n\t},\n\n\tclampPoint: function ( point, target ) {\n\n\t\tconst deltaLengthSq = this.center.distanceToSquared( point );\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Sphere: .clampPoint() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\ttarget.copy( point );\n\n\t\tif ( deltaLengthSq > ( this.radius * this.radius ) ) {\n\n\t\t\ttarget.sub( this.center ).normalize();\n\t\t\ttarget.multiplyScalar( this.radius ).add( this.center );\n\n\t\t}\n\n\t\treturn target;\n\n\t},\n\n\tgetBoundingBox: function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Sphere: .getBoundingBox() target is now required' );\n\t\t\ttarget = new Box3();\n\n\t\t}\n\n\t\tif ( this.isEmpty() ) {\n\n\t\t\t// Empty sphere produces empty bounding box\n\t\t\ttarget.makeEmpty();\n\t\t\treturn target;\n\n\t\t}\n\n\t\ttarget.set( this.center, this.center );\n\t\ttarget.expandByScalar( this.radius );\n\n\t\treturn target;\n\n\t},\n\n\tapplyMatrix4: function ( matrix ) {\n\n\t\tthis.center.applyMatrix4( matrix );\n\t\tthis.radius = this.radius * matrix.getMaxScaleOnAxis();\n\n\t\treturn this;\n\n\t},\n\n\ttranslate: function ( offset ) {\n\n\t\tthis.center.add( offset );\n\n\t\treturn this;\n\n\t},\n\n\tequals: function ( sphere ) {\n\n\t\treturn sphere.center.equals( this.center ) && ( sphere.radius === this.radius );\n\n\t}\n\n} );\n\n\nexport { Sphere };\n","import { Vector3 } from './Vector3.js';\n\nconst _vector = new Vector3();\nconst _segCenter = new Vector3();\nconst _segDir = new Vector3();\nconst _diff = new Vector3();\n\nconst _edge1 = new Vector3();\nconst _edge2 = new Vector3();\nconst _normal = new Vector3();\n\n/**\n * @author bhouston / http://clara.io\n */\n\nfunction Ray( origin, direction ) {\n\n\tthis.origin = ( origin !== undefined ) ? origin : new Vector3();\n\tthis.direction = ( direction !== undefined ) ? direction : new Vector3( 0, 0, - 1 );\n\n}\n\nObject.assign( Ray.prototype, {\n\n\tset: function ( origin, direction ) {\n\n\t\tthis.origin.copy( origin );\n\t\tthis.direction.copy( direction );\n\n\t\treturn this;\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor().copy( this );\n\n\t},\n\n\tcopy: function ( ray ) {\n\n\t\tthis.origin.copy( ray.origin );\n\t\tthis.direction.copy( ray.direction );\n\n\t\treturn this;\n\n\t},\n\n\tat: function ( t, target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Ray: .at() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\treturn target.copy( this.direction ).multiplyScalar( t ).add( this.origin );\n\n\t},\n\n\tlookAt: function ( v ) {\n\n\t\tthis.direction.copy( v ).sub( this.origin ).normalize();\n\n\t\treturn this;\n\n\t},\n\n\trecast: function ( t ) {\n\n\t\tthis.origin.copy( this.at( t, _vector ) );\n\n\t\treturn this;\n\n\t},\n\n\tclosestPointToPoint: function ( point, target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Ray: .closestPointToPoint() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\ttarget.subVectors( point, this.origin );\n\n\t\tconst directionDistance = target.dot( this.direction );\n\n\t\tif ( directionDistance < 0 ) {\n\n\t\t\treturn target.copy( this.origin );\n\n\t\t}\n\n\t\treturn target.copy( this.direction ).multiplyScalar( directionDistance ).add( this.origin );\n\n\t},\n\n\tdistanceToPoint: function ( point ) {\n\n\t\treturn Math.sqrt( this.distanceSqToPoint( point ) );\n\n\t},\n\n\tdistanceSqToPoint: function ( point ) {\n\n\t\tconst directionDistance = _vector.subVectors( point, this.origin ).dot( this.direction );\n\n\t\t// point behind the ray\n\n\t\tif ( directionDistance < 0 ) {\n\n\t\t\treturn this.origin.distanceToSquared( point );\n\n\t\t}\n\n\t\t_vector.copy( this.direction ).multiplyScalar( directionDistance ).add( this.origin );\n\n\t\treturn _vector.distanceToSquared( point );\n\n\t},\n\n\tdistanceSqToSegment: function ( v0, v1, optionalPointOnRay, optionalPointOnSegment ) {\n\n\t\t// from http://www.geometrictools.com/GTEngine/Include/Mathematics/GteDistRaySegment.h\n\t\t// It returns the min distance between the ray and the segment\n\t\t// defined by v0 and v1\n\t\t// It can also set two optional targets :\n\t\t// - The closest point on the ray\n\t\t// - The closest point on the segment\n\n\t\t_segCenter.copy( v0 ).add( v1 ).multiplyScalar( 0.5 );\n\t\t_segDir.copy( v1 ).sub( v0 ).normalize();\n\t\t_diff.copy( this.origin ).sub( _segCenter );\n\n\t\tconst segExtent = v0.distanceTo( v1 ) * 0.5;\n\t\tconst a01 = - this.direction.dot( _segDir );\n\t\tconst b0 = _diff.dot( this.direction );\n\t\tconst b1 = - _diff.dot( _segDir );\n\t\tconst c = _diff.lengthSq();\n\t\tconst det = Math.abs( 1 - a01 * a01 );\n\t\tlet s0, s1, sqrDist, extDet;\n\n\t\tif ( det > 0 ) {\n\n\t\t\t// The ray and segment are not parallel.\n\n\t\t\ts0 = a01 * b1 - b0;\n\t\t\ts1 = a01 * b0 - b1;\n\t\t\textDet = segExtent * det;\n\n\t\t\tif ( s0 >= 0 ) {\n\n\t\t\t\tif ( s1 >= - extDet ) {\n\n\t\t\t\t\tif ( s1 <= extDet ) {\n\n\t\t\t\t\t\t// region 0\n\t\t\t\t\t\t// Minimum at interior points of ray and segment.\n\n\t\t\t\t\t\tconst invDet = 1 / det;\n\t\t\t\t\t\ts0 *= invDet;\n\t\t\t\t\t\ts1 *= invDet;\n\t\t\t\t\t\tsqrDist = s0 * ( s0 + a01 * s1 + 2 * b0 ) + s1 * ( a01 * s0 + s1 + 2 * b1 ) + c;\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\t// region 1\n\n\t\t\t\t\t\ts1 = segExtent;\n\t\t\t\t\t\ts0 = Math.max( 0, - ( a01 * s1 + b0 ) );\n\t\t\t\t\t\tsqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;\n\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\n\t\t\t\t\t// region 5\n\n\t\t\t\t\ts1 = - segExtent;\n\t\t\t\t\ts0 = Math.max( 0, - ( a01 * s1 + b0 ) );\n\t\t\t\t\tsqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\tif ( s1 <= - extDet ) {\n\n\t\t\t\t\t// region 4\n\n\t\t\t\t\ts0 = Math.max( 0, - ( - a01 * segExtent + b0 ) );\n\t\t\t\t\ts1 = ( s0 > 0 ) ? - segExtent : Math.min( Math.max( - segExtent, - b1 ), segExtent );\n\t\t\t\t\tsqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;\n\n\t\t\t\t} else if ( s1 <= extDet ) {\n\n\t\t\t\t\t// region 3\n\n\t\t\t\t\ts0 = 0;\n\t\t\t\t\ts1 = Math.min( Math.max( - segExtent, - b1 ), segExtent );\n\t\t\t\t\tsqrDist = s1 * ( s1 + 2 * b1 ) + c;\n\n\t\t\t\t} else {\n\n\t\t\t\t\t// region 2\n\n\t\t\t\t\ts0 = Math.max( 0, - ( a01 * segExtent + b0 ) );\n\t\t\t\t\ts1 = ( s0 > 0 ) ? segExtent : Math.min( Math.max( - segExtent, - b1 ), segExtent );\n\t\t\t\t\tsqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\t// Ray and segment are parallel.\n\n\t\t\ts1 = ( a01 > 0 ) ? - segExtent : segExtent;\n\t\t\ts0 = Math.max( 0, - ( a01 * s1 + b0 ) );\n\t\t\tsqrDist = - s0 * s0 + s1 * ( s1 + 2 * b1 ) + c;\n\n\t\t}\n\n\t\tif ( optionalPointOnRay ) {\n\n\t\t\toptionalPointOnRay.copy( this.direction ).multiplyScalar( s0 ).add( this.origin );\n\n\t\t}\n\n\t\tif ( optionalPointOnSegment ) {\n\n\t\t\toptionalPointOnSegment.copy( _segDir ).multiplyScalar( s1 ).add( _segCenter );\n\n\t\t}\n\n\t\treturn sqrDist;\n\n\t},\n\n\tintersectSphere: function ( sphere, target ) {\n\n\t\t_vector.subVectors( sphere.center, this.origin );\n\t\tconst tca = _vector.dot( this.direction );\n\t\tconst d2 = _vector.dot( _vector ) - tca * tca;\n\t\tconst radius2 = sphere.radius * sphere.radius;\n\n\t\tif ( d2 > radius2 ) return null;\n\n\t\tconst thc = Math.sqrt( radius2 - d2 );\n\n\t\t// t0 = first intersect point - entrance on front of sphere\n\t\tconst t0 = tca - thc;\n\n\t\t// t1 = second intersect point - exit point on back of sphere\n\t\tconst t1 = tca + thc;\n\n\t\t// test to see if both t0 and t1 are behind the ray - if so, return null\n\t\tif ( t0 < 0 && t1 < 0 ) return null;\n\n\t\t// test to see if t0 is behind the ray:\n\t\t// if it is, the ray is inside the sphere, so return the second exit point scaled by t1,\n\t\t// in order to always return an intersect point that is in front of the ray.\n\t\tif ( t0 < 0 ) return this.at( t1, target );\n\n\t\t// else t0 is in front of the ray, so return the first collision point scaled by t0\n\t\treturn this.at( t0, target );\n\n\t},\n\n\tintersectsSphere: function ( sphere ) {\n\n\t\treturn this.distanceSqToPoint( sphere.center ) <= ( sphere.radius * sphere.radius );\n\n\t},\n\n\tdistanceToPlane: function ( plane ) {\n\n\t\tconst denominator = plane.normal.dot( this.direction );\n\n\t\tif ( denominator === 0 ) {\n\n\t\t\t// line is coplanar, return origin\n\t\t\tif ( plane.distanceToPoint( this.origin ) === 0 ) {\n\n\t\t\t\treturn 0;\n\n\t\t\t}\n\n\t\t\t// Null is preferable to undefined since undefined means.... it is undefined\n\n\t\t\treturn null;\n\n\t\t}\n\n\t\tconst t = - ( this.origin.dot( plane.normal ) + plane.constant ) / denominator;\n\n\t\t// Return if the ray never intersects the plane\n\n\t\treturn t >= 0 ? t : null;\n\n\t},\n\n\tintersectPlane: function ( plane, target ) {\n\n\t\tconst t = this.distanceToPlane( plane );\n\n\t\tif ( t === null ) {\n\n\t\t\treturn null;\n\n\t\t}\n\n\t\treturn this.at( t, target );\n\n\t},\n\n\tintersectsPlane: function ( plane ) {\n\n\t\t// check if the ray lies on the plane first\n\n\t\tconst distToPoint = plane.distanceToPoint( this.origin );\n\n\t\tif ( distToPoint === 0 ) {\n\n\t\t\treturn true;\n\n\t\t}\n\n\t\tconst denominator = plane.normal.dot( this.direction );\n\n\t\tif ( denominator * distToPoint < 0 ) {\n\n\t\t\treturn true;\n\n\t\t}\n\n\t\t// ray origin is behind the plane (and is pointing behind it)\n\n\t\treturn false;\n\n\t},\n\n\tintersectBox: function ( box, target ) {\n\n\t\tlet tmin, tmax, tymin, tymax, tzmin, tzmax;\n\n\t\tconst invdirx = 1 / this.direction.x,\n\t\t\tinvdiry = 1 / this.direction.y,\n\t\t\tinvdirz = 1 / this.direction.z;\n\n\t\tconst origin = this.origin;\n\n\t\tif ( invdirx >= 0 ) {\n\n\t\t\ttmin = ( box.min.x - origin.x ) * invdirx;\n\t\t\ttmax = ( box.max.x - origin.x ) * invdirx;\n\n\t\t} else {\n\n\t\t\ttmin = ( box.max.x - origin.x ) * invdirx;\n\t\t\ttmax = ( box.min.x - origin.x ) * invdirx;\n\n\t\t}\n\n\t\tif ( invdiry >= 0 ) {\n\n\t\t\ttymin = ( box.min.y - origin.y ) * invdiry;\n\t\t\ttymax = ( box.max.y - origin.y ) * invdiry;\n\n\t\t} else {\n\n\t\t\ttymin = ( box.max.y - origin.y ) * invdiry;\n\t\t\ttymax = ( box.min.y - origin.y ) * invdiry;\n\n\t\t}\n\n\t\tif ( ( tmin > tymax ) || ( tymin > tmax ) ) return null;\n\n\t\t// These lines also handle the case where tmin or tmax is NaN\n\t\t// (result of 0 * Infinity). x !== x returns true if x is NaN\n\n\t\tif ( tymin > tmin || tmin !== tmin ) tmin = tymin;\n\n\t\tif ( tymax < tmax || tmax !== tmax ) tmax = tymax;\n\n\t\tif ( invdirz >= 0 ) {\n\n\t\t\ttzmin = ( box.min.z - origin.z ) * invdirz;\n\t\t\ttzmax = ( box.max.z - origin.z ) * invdirz;\n\n\t\t} else {\n\n\t\t\ttzmin = ( box.max.z - origin.z ) * invdirz;\n\t\t\ttzmax = ( box.min.z - origin.z ) * invdirz;\n\n\t\t}\n\n\t\tif ( ( tmin > tzmax ) || ( tzmin > tmax ) ) return null;\n\n\t\tif ( tzmin > tmin || tmin !== tmin ) tmin = tzmin;\n\n\t\tif ( tzmax < tmax || tmax !== tmax ) tmax = tzmax;\n\n\t\t//return point closest to the ray (positive side)\n\n\t\tif ( tmax < 0 ) return null;\n\n\t\treturn this.at( tmin >= 0 ? tmin : tmax, target );\n\n\t},\n\n\tintersectsBox: function ( box ) {\n\n\t\treturn this.intersectBox( box, _vector ) !== null;\n\n\t},\n\n\tintersectTriangle: function ( a, b, c, backfaceCulling, target ) {\n\n\t\t// Compute the offset origin, edges, and normal.\n\n\t\t// from http://www.geometrictools.com/GTEngine/Include/Mathematics/GteIntrRay3Triangle3.h\n\n\t\t_edge1.subVectors( b, a );\n\t\t_edge2.subVectors( c, a );\n\t\t_normal.crossVectors( _edge1, _edge2 );\n\n\t\t// Solve Q + t*D = b1*E1 + b2*E2 (Q = kDiff, D = ray direction,\n\t\t// E1 = kEdge1, E2 = kEdge2, N = Cross(E1,E2)) by\n\t\t// |Dot(D,N)|*b1 = sign(Dot(D,N))*Dot(D,Cross(Q,E2))\n\t\t// |Dot(D,N)|*b2 = sign(Dot(D,N))*Dot(D,Cross(E1,Q))\n\t\t// |Dot(D,N)|*t = -sign(Dot(D,N))*Dot(Q,N)\n\t\tlet DdN = this.direction.dot( _normal );\n\t\tlet sign;\n\n\t\tif ( DdN > 0 ) {\n\n\t\t\tif ( backfaceCulling ) return null;\n\t\t\tsign = 1;\n\n\t\t} else if ( DdN < 0 ) {\n\n\t\t\tsign = - 1;\n\t\t\tDdN = - DdN;\n\n\t\t} else {\n\n\t\t\treturn null;\n\n\t\t}\n\n\t\t_diff.subVectors( this.origin, a );\n\t\tconst DdQxE2 = sign * this.direction.dot( _edge2.crossVectors( _diff, _edge2 ) );\n\n\t\t// b1 < 0, no intersection\n\t\tif ( DdQxE2 < 0 ) {\n\n\t\t\treturn null;\n\n\t\t}\n\n\t\tconst DdE1xQ = sign * this.direction.dot( _edge1.cross( _diff ) );\n\n\t\t// b2 < 0, no intersection\n\t\tif ( DdE1xQ < 0 ) {\n\n\t\t\treturn null;\n\n\t\t}\n\n\t\t// b1+b2 > 1, no intersection\n\t\tif ( DdQxE2 + DdE1xQ > DdN ) {\n\n\t\t\treturn null;\n\n\t\t}\n\n\t\t// Line intersects triangle, check if ray does.\n\t\tconst QdN = - sign * _diff.dot( _normal );\n\n\t\t// t < 0, no intersection\n\t\tif ( QdN < 0 ) {\n\n\t\t\treturn null;\n\n\t\t}\n\n\t\t// Ray intersects triangle.\n\t\treturn this.at( QdN / DdN, target );\n\n\t},\n\n\tapplyMatrix4: function ( matrix4 ) {\n\n\t\tthis.origin.applyMatrix4( matrix4 );\n\t\tthis.direction.transformDirection( matrix4 );\n\n\t\treturn this;\n\n\t},\n\n\tequals: function ( ray ) {\n\n\t\treturn ray.origin.equals( this.origin ) && ray.direction.equals( this.direction );\n\n\t}\n\n} );\n\n\nexport { Ray };\n","import { Matrix3 } from './Matrix3.js';\nimport { Vector3 } from './Vector3.js';\n\n/**\n * @author bhouston / http://clara.io\n */\n\nconst _vector1 = new Vector3();\nconst _vector2 = new Vector3();\nconst _normalMatrix = new Matrix3();\n\nfunction Plane( normal, constant ) {\n\n\t// normal is assumed to be normalized\n\n\tthis.normal = ( normal !== undefined ) ? normal : new Vector3( 1, 0, 0 );\n\tthis.constant = ( constant !== undefined ) ? constant : 0;\n\n}\n\nObject.assign( Plane.prototype, {\n\n\tisPlane: true,\n\n\tset: function ( normal, constant ) {\n\n\t\tthis.normal.copy( normal );\n\t\tthis.constant = constant;\n\n\t\treturn this;\n\n\t},\n\n\tsetComponents: function ( x, y, z, w ) {\n\n\t\tthis.normal.set( x, y, z );\n\t\tthis.constant = w;\n\n\t\treturn this;\n\n\t},\n\n\tsetFromNormalAndCoplanarPoint: function ( normal, point ) {\n\n\t\tthis.normal.copy( normal );\n\t\tthis.constant = - point.dot( this.normal );\n\n\t\treturn this;\n\n\t},\n\n\tsetFromCoplanarPoints: function ( a, b, c ) {\n\n\t\tconst normal = _vector1.subVectors( c, b ).cross( _vector2.subVectors( a, b ) ).normalize();\n\n\t\t// Q: should an error be thrown if normal is zero (e.g. degenerate plane)?\n\n\t\tthis.setFromNormalAndCoplanarPoint( normal, a );\n\n\t\treturn this;\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor().copy( this );\n\n\t},\n\n\tcopy: function ( plane ) {\n\n\t\tthis.normal.copy( plane.normal );\n\t\tthis.constant = plane.constant;\n\n\t\treturn this;\n\n\t},\n\n\tnormalize: function () {\n\n\t\t// Note: will lead to a divide by zero if the plane is invalid.\n\n\t\tconst inverseNormalLength = 1.0 / this.normal.length();\n\t\tthis.normal.multiplyScalar( inverseNormalLength );\n\t\tthis.constant *= inverseNormalLength;\n\n\t\treturn this;\n\n\t},\n\n\tnegate: function () {\n\n\t\tthis.constant *= - 1;\n\t\tthis.normal.negate();\n\n\t\treturn this;\n\n\t},\n\n\tdistanceToPoint: function ( point ) {\n\n\t\treturn this.normal.dot( point ) + this.constant;\n\n\t},\n\n\tdistanceToSphere: function ( sphere ) {\n\n\t\treturn this.distanceToPoint( sphere.center ) - sphere.radius;\n\n\t},\n\n\tprojectPoint: function ( point, target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Plane: .projectPoint() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\treturn target.copy( this.normal ).multiplyScalar( - this.distanceToPoint( point ) ).add( point );\n\n\t},\n\n\tintersectLine: function ( line, target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Plane: .intersectLine() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\tconst direction = line.delta( _vector1 );\n\n\t\tconst denominator = this.normal.dot( direction );\n\n\t\tif ( denominator === 0 ) {\n\n\t\t\t// line is coplanar, return origin\n\t\t\tif ( this.distanceToPoint( line.start ) === 0 ) {\n\n\t\t\t\treturn target.copy( line.start );\n\n\t\t\t}\n\n\t\t\t// Unsure if this is the correct method to handle this case.\n\t\t\treturn undefined;\n\n\t\t}\n\n\t\tconst t = - ( line.start.dot( this.normal ) + this.constant ) / denominator;\n\n\t\tif ( t < 0 || t > 1 ) {\n\n\t\t\treturn undefined;\n\n\t\t}\n\n\t\treturn target.copy( direction ).multiplyScalar( t ).add( line.start );\n\n\t},\n\n\tintersectsLine: function ( line ) {\n\n\t\t// Note: this tests if a line intersects the plane, not whether it (or its end-points) are coplanar with it.\n\n\t\tconst startSign = this.distanceToPoint( line.start );\n\t\tconst endSign = this.distanceToPoint( line.end );\n\n\t\treturn ( startSign < 0 && endSign > 0 ) || ( endSign < 0 && startSign > 0 );\n\n\t},\n\n\tintersectsBox: function ( box ) {\n\n\t\treturn box.intersectsPlane( this );\n\n\t},\n\n\tintersectsSphere: function ( sphere ) {\n\n\t\treturn sphere.intersectsPlane( this );\n\n\t},\n\n\tcoplanarPoint: function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Plane: .coplanarPoint() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\treturn target.copy( this.normal ).multiplyScalar( - this.constant );\n\n\t},\n\n\tapplyMatrix4: function ( matrix, optionalNormalMatrix ) {\n\n\t\tconst normalMatrix = optionalNormalMatrix || _normalMatrix.getNormalMatrix( matrix );\n\n\t\tconst referencePoint = this.coplanarPoint( _vector1 ).applyMatrix4( matrix );\n\n\t\tconst normal = this.normal.applyMatrix3( normalMatrix ).normalize();\n\n\t\tthis.constant = - referencePoint.dot( normal );\n\n\t\treturn this;\n\n\t},\n\n\ttranslate: function ( offset ) {\n\n\t\tthis.constant -= offset.dot( this.normal );\n\n\t\treturn this;\n\n\t},\n\n\tequals: function ( plane ) {\n\n\t\treturn plane.normal.equals( this.normal ) && ( plane.constant === this.constant );\n\n\t}\n\n} );\n\n\nexport { Plane };\n","import { Vector3 } from './Vector3.js';\nimport { Plane } from './Plane.js';\n\n/**\n * @author bhouston / http://clara.io\n * @author mrdoob / http://mrdoob.com/\n */\n\nconst _v0 = new Vector3();\nconst _v1 = new Vector3();\nconst _v2 = new Vector3();\nconst _v3 = new Vector3();\n\nconst _vab = new Vector3();\nconst _vac = new Vector3();\nconst _vbc = new Vector3();\nconst _vap = new Vector3();\nconst _vbp = new Vector3();\nconst _vcp = new Vector3();\n\nfunction Triangle( a, b, c ) {\n\n\tthis.a = ( a !== undefined ) ? a : new Vector3();\n\tthis.b = ( b !== undefined ) ? b : new Vector3();\n\tthis.c = ( c !== undefined ) ? c : new Vector3();\n\n}\n\nObject.assign( Triangle, {\n\n\tgetNormal: function ( a, b, c, target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Triangle: .getNormal() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\ttarget.subVectors( c, b );\n\t\t_v0.subVectors( a, b );\n\t\ttarget.cross( _v0 );\n\n\t\tconst targetLengthSq = target.lengthSq();\n\t\tif ( targetLengthSq > 0 ) {\n\n\t\t\treturn target.multiplyScalar( 1 / Math.sqrt( targetLengthSq ) );\n\n\t\t}\n\n\t\treturn target.set( 0, 0, 0 );\n\n\t},\n\n\t// static/instance method to calculate barycentric coordinates\n\t// based on: http://www.blackpawn.com/texts/pointinpoly/default.html\n\tgetBarycoord: function ( point, a, b, c, target ) {\n\n\t\t_v0.subVectors( c, a );\n\t\t_v1.subVectors( b, a );\n\t\t_v2.subVectors( point, a );\n\n\t\tconst dot00 = _v0.dot( _v0 );\n\t\tconst dot01 = _v0.dot( _v1 );\n\t\tconst dot02 = _v0.dot( _v2 );\n\t\tconst dot11 = _v1.dot( _v1 );\n\t\tconst dot12 = _v1.dot( _v2 );\n\n\t\tconst denom = ( dot00 * dot11 - dot01 * dot01 );\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Triangle: .getBarycoord() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\t// collinear or singular triangle\n\t\tif ( denom === 0 ) {\n\n\t\t\t// arbitrary location outside of triangle?\n\t\t\t// not sure if this is the best idea, maybe should be returning undefined\n\t\t\treturn target.set( - 2, - 1, - 1 );\n\n\t\t}\n\n\t\tconst invDenom = 1 / denom;\n\t\tconst u = ( dot11 * dot02 - dot01 * dot12 ) * invDenom;\n\t\tconst v = ( dot00 * dot12 - dot01 * dot02 ) * invDenom;\n\n\t\t// barycentric coordinates must always sum to 1\n\t\treturn target.set( 1 - u - v, v, u );\n\n\t},\n\n\tcontainsPoint: function ( point, a, b, c ) {\n\n\t\tTriangle.getBarycoord( point, a, b, c, _v3 );\n\n\t\treturn ( _v3.x >= 0 ) && ( _v3.y >= 0 ) && ( ( _v3.x + _v3.y ) <= 1 );\n\n\t},\n\n\tgetUV: function ( point, p1, p2, p3, uv1, uv2, uv3, target ) {\n\n\t\tthis.getBarycoord( point, p1, p2, p3, _v3 );\n\n\t\ttarget.set( 0, 0 );\n\t\ttarget.addScaledVector( uv1, _v3.x );\n\t\ttarget.addScaledVector( uv2, _v3.y );\n\t\ttarget.addScaledVector( uv3, _v3.z );\n\n\t\treturn target;\n\n\t},\n\n\tisFrontFacing: function ( a, b, c, direction ) {\n\n\t\t_v0.subVectors( c, b );\n\t\t_v1.subVectors( a, b );\n\n\t\t// strictly front facing\n\t\treturn ( _v0.cross( _v1 ).dot( direction ) < 0 ) ? true : false;\n\n\t}\n\n} );\n\nObject.assign( Triangle.prototype, {\n\n\tset: function ( a, b, c ) {\n\n\t\tthis.a.copy( a );\n\t\tthis.b.copy( b );\n\t\tthis.c.copy( c );\n\n\t\treturn this;\n\n\t},\n\n\tsetFromPointsAndIndices: function ( points, i0, i1, i2 ) {\n\n\t\tthis.a.copy( points[ i0 ] );\n\t\tthis.b.copy( points[ i1 ] );\n\t\tthis.c.copy( points[ i2 ] );\n\n\t\treturn this;\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor().copy( this );\n\n\t},\n\n\tcopy: function ( triangle ) {\n\n\t\tthis.a.copy( triangle.a );\n\t\tthis.b.copy( triangle.b );\n\t\tthis.c.copy( triangle.c );\n\n\t\treturn this;\n\n\t},\n\n\tgetArea: function () {\n\n\t\t_v0.subVectors( this.c, this.b );\n\t\t_v1.subVectors( this.a, this.b );\n\n\t\treturn _v0.cross( _v1 ).length() * 0.5;\n\n\t},\n\n\tgetMidpoint: function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Triangle: .getMidpoint() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\treturn target.addVectors( this.a, this.b ).add( this.c ).multiplyScalar( 1 / 3 );\n\n\t},\n\n\tgetNormal: function ( target ) {\n\n\t\treturn Triangle.getNormal( this.a, this.b, this.c, target );\n\n\t},\n\n\tgetPlane: function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Triangle: .getPlane() target is now required' );\n\t\t\ttarget = new Plane();\n\n\t\t}\n\n\t\treturn target.setFromCoplanarPoints( this.a, this.b, this.c );\n\n\t},\n\n\tgetBarycoord: function ( point, target ) {\n\n\t\treturn Triangle.getBarycoord( point, this.a, this.b, this.c, target );\n\n\t},\n\n\tgetUV: function ( point, uv1, uv2, uv3, target ) {\n\n\t\treturn Triangle.getUV( point, this.a, this.b, this.c, uv1, uv2, uv3, target );\n\n\t},\n\n\tcontainsPoint: function ( point ) {\n\n\t\treturn Triangle.containsPoint( point, this.a, this.b, this.c );\n\n\t},\n\n\tisFrontFacing: function ( direction ) {\n\n\t\treturn Triangle.isFrontFacing( this.a, this.b, this.c, direction );\n\n\t},\n\n\tintersectsBox: function ( box ) {\n\n\t\treturn box.intersectsTriangle( this );\n\n\t},\n\n\tclosestPointToPoint: function ( p, target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Triangle: .closestPointToPoint() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\tconst a = this.a, b = this.b, c = this.c;\n\t\tlet v, w;\n\n\t\t// algorithm thanks to Real-Time Collision Detection by Christer Ericson,\n\t\t// published by Morgan Kaufmann Publishers, (c) 2005 Elsevier Inc.,\n\t\t// under the accompanying license; see chapter 5.1.5 for detailed explanation.\n\t\t// basically, we're distinguishing which of the voronoi regions of the triangle\n\t\t// the point lies in with the minimum amount of redundant computation.\n\n\t\t_vab.subVectors( b, a );\n\t\t_vac.subVectors( c, a );\n\t\t_vap.subVectors( p, a );\n\t\tconst d1 = _vab.dot( _vap );\n\t\tconst d2 = _vac.dot( _vap );\n\t\tif ( d1 <= 0 && d2 <= 0 ) {\n\n\t\t\t// vertex region of A; barycentric coords (1, 0, 0)\n\t\t\treturn target.copy( a );\n\n\t\t}\n\n\t\t_vbp.subVectors( p, b );\n\t\tconst d3 = _vab.dot( _vbp );\n\t\tconst d4 = _vac.dot( _vbp );\n\t\tif ( d3 >= 0 && d4 <= d3 ) {\n\n\t\t\t// vertex region of B; barycentric coords (0, 1, 0)\n\t\t\treturn target.copy( b );\n\n\t\t}\n\n\t\tconst vc = d1 * d4 - d3 * d2;\n\t\tif ( vc <= 0 && d1 >= 0 && d3 <= 0 ) {\n\n\t\t\tv = d1 / ( d1 - d3 );\n\t\t\t// edge region of AB; barycentric coords (1-v, v, 0)\n\t\t\treturn target.copy( a ).addScaledVector( _vab, v );\n\n\t\t}\n\n\t\t_vcp.subVectors( p, c );\n\t\tconst d5 = _vab.dot( _vcp );\n\t\tconst d6 = _vac.dot( _vcp );\n\t\tif ( d6 >= 0 && d5 <= d6 ) {\n\n\t\t\t// vertex region of C; barycentric coords (0, 0, 1)\n\t\t\treturn target.copy( c );\n\n\t\t}\n\n\t\tconst vb = d5 * d2 - d1 * d6;\n\t\tif ( vb <= 0 && d2 >= 0 && d6 <= 0 ) {\n\n\t\t\tw = d2 / ( d2 - d6 );\n\t\t\t// edge region of AC; barycentric coords (1-w, 0, w)\n\t\t\treturn target.copy( a ).addScaledVector( _vac, w );\n\n\t\t}\n\n\t\tconst va = d3 * d6 - d5 * d4;\n\t\tif ( va <= 0 && ( d4 - d3 ) >= 0 && ( d5 - d6 ) >= 0 ) {\n\n\t\t\t_vbc.subVectors( c, b );\n\t\t\tw = ( d4 - d3 ) / ( ( d4 - d3 ) + ( d5 - d6 ) );\n\t\t\t// edge region of BC; barycentric coords (0, 1-w, w)\n\t\t\treturn target.copy( b ).addScaledVector( _vbc, w ); // edge region of BC\n\n\t\t}\n\n\t\t// face region\n\t\tconst denom = 1 / ( va + vb + vc );\n\t\t// u = va * denom\n\t\tv = vb * denom;\n\t\tw = vc * denom;\n\n\t\treturn target.copy( a ).addScaledVector( _vab, v ).addScaledVector( _vac, w );\n\n\t},\n\n\tequals: function ( triangle ) {\n\n\t\treturn triangle.a.equals( this.a ) && triangle.b.equals( this.b ) && triangle.c.equals( this.c );\n\n\t}\n\n} );\n\n\nexport { Triangle };\n","import { MathUtils } from './MathUtils.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nconst _colorKeywords = { 'aliceblue': 0xF0F8FF, 'antiquewhite': 0xFAEBD7, 'aqua': 0x00FFFF, 'aquamarine': 0x7FFFD4, 'azure': 0xF0FFFF,\n\t'beige': 0xF5F5DC, 'bisque': 0xFFE4C4, 'black': 0x000000, 'blanchedalmond': 0xFFEBCD, 'blue': 0x0000FF, 'blueviolet': 0x8A2BE2,\n\t'brown': 0xA52A2A, 'burlywood': 0xDEB887, 'cadetblue': 0x5F9EA0, 'chartreuse': 0x7FFF00, 'chocolate': 0xD2691E, 'coral': 0xFF7F50,\n\t'cornflowerblue': 0x6495ED, 'cornsilk': 0xFFF8DC, 'crimson': 0xDC143C, 'cyan': 0x00FFFF, 'darkblue': 0x00008B, 'darkcyan': 0x008B8B,\n\t'darkgoldenrod': 0xB8860B, 'darkgray': 0xA9A9A9, 'darkgreen': 0x006400, 'darkgrey': 0xA9A9A9, 'darkkhaki': 0xBDB76B, 'darkmagenta': 0x8B008B,\n\t'darkolivegreen': 0x556B2F, 'darkorange': 0xFF8C00, 'darkorchid': 0x9932CC, 'darkred': 0x8B0000, 'darksalmon': 0xE9967A, 'darkseagreen': 0x8FBC8F,\n\t'darkslateblue': 0x483D8B, 'darkslategray': 0x2F4F4F, 'darkslategrey': 0x2F4F4F, 'darkturquoise': 0x00CED1, 'darkviolet': 0x9400D3,\n\t'deeppink': 0xFF1493, 'deepskyblue': 0x00BFFF, 'dimgray': 0x696969, 'dimgrey': 0x696969, 'dodgerblue': 0x1E90FF, 'firebrick': 0xB22222,\n\t'floralwhite': 0xFFFAF0, 'forestgreen': 0x228B22, 'fuchsia': 0xFF00FF, 'gainsboro': 0xDCDCDC, 'ghostwhite': 0xF8F8FF, 'gold': 0xFFD700,\n\t'goldenrod': 0xDAA520, 'gray': 0x808080, 'green': 0x008000, 'greenyellow': 0xADFF2F, 'grey': 0x808080, 'honeydew': 0xF0FFF0, 'hotpink': 0xFF69B4,\n\t'indianred': 0xCD5C5C, 'indigo': 0x4B0082, 'ivory': 0xFFFFF0, 'khaki': 0xF0E68C, 'lavender': 0xE6E6FA, 'lavenderblush': 0xFFF0F5, 'lawngreen': 0x7CFC00,\n\t'lemonchiffon': 0xFFFACD, 'lightblue': 0xADD8E6, 'lightcoral': 0xF08080, 'lightcyan': 0xE0FFFF, 'lightgoldenrodyellow': 0xFAFAD2, 'lightgray': 0xD3D3D3,\n\t'lightgreen': 0x90EE90, 'lightgrey': 0xD3D3D3, 'lightpink': 0xFFB6C1, 'lightsalmon': 0xFFA07A, 'lightseagreen': 0x20B2AA, 'lightskyblue': 0x87CEFA,\n\t'lightslategray': 0x778899, 'lightslategrey': 0x778899, 'lightsteelblue': 0xB0C4DE, 'lightyellow': 0xFFFFE0, 'lime': 0x00FF00, 'limegreen': 0x32CD32,\n\t'linen': 0xFAF0E6, 'magenta': 0xFF00FF, 'maroon': 0x800000, 'mediumaquamarine': 0x66CDAA, 'mediumblue': 0x0000CD, 'mediumorchid': 0xBA55D3,\n\t'mediumpurple': 0x9370DB, 'mediumseagreen': 0x3CB371, 'mediumslateblue': 0x7B68EE, 'mediumspringgreen': 0x00FA9A, 'mediumturquoise': 0x48D1CC,\n\t'mediumvioletred': 0xC71585, 'midnightblue': 0x191970, 'mintcream': 0xF5FFFA, 'mistyrose': 0xFFE4E1, 'moccasin': 0xFFE4B5, 'navajowhite': 0xFFDEAD,\n\t'navy': 0x000080, 'oldlace': 0xFDF5E6, 'olive': 0x808000, 'olivedrab': 0x6B8E23, 'orange': 0xFFA500, 'orangered': 0xFF4500, 'orchid': 0xDA70D6,\n\t'palegoldenrod': 0xEEE8AA, 'palegreen': 0x98FB98, 'paleturquoise': 0xAFEEEE, 'palevioletred': 0xDB7093, 'papayawhip': 0xFFEFD5, 'peachpuff': 0xFFDAB9,\n\t'peru': 0xCD853F, 'pink': 0xFFC0CB, 'plum': 0xDDA0DD, 'powderblue': 0xB0E0E6, 'purple': 0x800080, 'rebeccapurple': 0x663399, 'red': 0xFF0000, 'rosybrown': 0xBC8F8F,\n\t'royalblue': 0x4169E1, 'saddlebrown': 0x8B4513, 'salmon': 0xFA8072, 'sandybrown': 0xF4A460, 'seagreen': 0x2E8B57, 'seashell': 0xFFF5EE,\n\t'sienna': 0xA0522D, 'silver': 0xC0C0C0, 'skyblue': 0x87CEEB, 'slateblue': 0x6A5ACD, 'slategray': 0x708090, 'slategrey': 0x708090, 'snow': 0xFFFAFA,\n\t'springgreen': 0x00FF7F, 'steelblue': 0x4682B4, 'tan': 0xD2B48C, 'teal': 0x008080, 'thistle': 0xD8BFD8, 'tomato': 0xFF6347, 'turquoise': 0x40E0D0,\n\t'violet': 0xEE82EE, 'wheat': 0xF5DEB3, 'white': 0xFFFFFF, 'whitesmoke': 0xF5F5F5, 'yellow': 0xFFFF00, 'yellowgreen': 0x9ACD32 };\n\nconst _hslA = { h: 0, s: 0, l: 0 };\nconst _hslB = { h: 0, s: 0, l: 0 };\n\nfunction Color( r, g, b ) {\n\n\tif ( g === undefined && b === undefined ) {\n\n\t\t// r is THREE.Color, hex or string\n\t\treturn this.set( r );\n\n\t}\n\n\treturn this.setRGB( r, g, b );\n\n}\n\nfunction hue2rgb( p, q, t ) {\n\n\tif ( t < 0 ) t += 1;\n\tif ( t > 1 ) t -= 1;\n\tif ( t < 1 / 6 ) return p + ( q - p ) * 6 * t;\n\tif ( t < 1 / 2 ) return q;\n\tif ( t < 2 / 3 ) return p + ( q - p ) * 6 * ( 2 / 3 - t );\n\treturn p;\n\n}\n\nfunction SRGBToLinear( c ) {\n\n\treturn ( c < 0.04045 ) ? c * 0.0773993808 : Math.pow( c * 0.9478672986 + 0.0521327014, 2.4 );\n\n}\n\nfunction LinearToSRGB( c ) {\n\n\treturn ( c < 0.0031308 ) ? c * 12.92 : 1.055 * ( Math.pow( c, 0.41666 ) ) - 0.055;\n\n}\n\nObject.assign( Color.prototype, {\n\n\tisColor: true,\n\n\tr: 1, g: 1, b: 1,\n\n\tset: function ( value ) {\n\n\t\tif ( value && value.isColor ) {\n\n\t\t\tthis.copy( value );\n\n\t\t} else if ( typeof value === 'number' ) {\n\n\t\t\tthis.setHex( value );\n\n\t\t} else if ( typeof value === 'string' ) {\n\n\t\t\tthis.setStyle( value );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tsetScalar: function ( scalar ) {\n\n\t\tthis.r = scalar;\n\t\tthis.g = scalar;\n\t\tthis.b = scalar;\n\n\t\treturn this;\n\n\t},\n\n\tsetHex: function ( hex ) {\n\n\t\thex = Math.floor( hex );\n\n\t\tthis.r = ( hex >> 16 & 255 ) / 255;\n\t\tthis.g = ( hex >> 8 & 255 ) / 255;\n\t\tthis.b = ( hex & 255 ) / 255;\n\n\t\treturn this;\n\n\t},\n\n\tsetRGB: function ( r, g, b ) {\n\n\t\tthis.r = r;\n\t\tthis.g = g;\n\t\tthis.b = b;\n\n\t\treturn this;\n\n\t},\n\n\tsetHSL: function ( h, s, l ) {\n\n\t\t// h,s,l ranges are in 0.0 - 1.0\n\t\th = MathUtils.euclideanModulo( h, 1 );\n\t\ts = MathUtils.clamp( s, 0, 1 );\n\t\tl = MathUtils.clamp( l, 0, 1 );\n\n\t\tif ( s === 0 ) {\n\n\t\t\tthis.r = this.g = this.b = l;\n\n\t\t} else {\n\n\t\t\tconst p = l <= 0.5 ? l * ( 1 + s ) : l + s - ( l * s );\n\t\t\tconst q = ( 2 * l ) - p;\n\n\t\t\tthis.r = hue2rgb( q, p, h + 1 / 3 );\n\t\t\tthis.g = hue2rgb( q, p, h );\n\t\t\tthis.b = hue2rgb( q, p, h - 1 / 3 );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tsetStyle: function ( style ) {\n\n\t\tfunction handleAlpha( string ) {\n\n\t\t\tif ( string === undefined ) return;\n\n\t\t\tif ( parseFloat( string ) < 1 ) {\n\n\t\t\t\tconsole.warn( 'THREE.Color: Alpha component of ' + style + ' will be ignored.' );\n\n\t\t\t}\n\n\t\t}\n\n\n\t\tlet m;\n\n\t\tif ( m = /^((?:rgb|hsl)a?)\\(\\s*([^\\)]*)\\)/.exec( style ) ) {\n\n\t\t\t// rgb / hsl\n\n\t\t\tlet color;\n\t\t\tconst name = m[ 1 ];\n\t\t\tconst components = m[ 2 ];\n\n\t\t\tswitch ( name ) {\n\n\t\t\t\tcase 'rgb':\n\t\t\t\tcase 'rgba':\n\n\t\t\t\t\tif ( color = /^(\\d+)\\s*,\\s*(\\d+)\\s*,\\s*(\\d+)\\s*(,\\s*([0-9]*\\.?[0-9]+)\\s*)?$/.exec( components ) ) {\n\n\t\t\t\t\t\t// rgb(255,0,0) rgba(255,0,0,0.5)\n\t\t\t\t\t\tthis.r = Math.min( 255, parseInt( color[ 1 ], 10 ) ) / 255;\n\t\t\t\t\t\tthis.g = Math.min( 255, parseInt( color[ 2 ], 10 ) ) / 255;\n\t\t\t\t\t\tthis.b = Math.min( 255, parseInt( color[ 3 ], 10 ) ) / 255;\n\n\t\t\t\t\t\thandleAlpha( color[ 5 ] );\n\n\t\t\t\t\t\treturn this;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tif ( color = /^(\\d+)\\%\\s*,\\s*(\\d+)\\%\\s*,\\s*(\\d+)\\%\\s*(,\\s*([0-9]*\\.?[0-9]+)\\s*)?$/.exec( components ) ) {\n\n\t\t\t\t\t\t// rgb(100%,0%,0%) rgba(100%,0%,0%,0.5)\n\t\t\t\t\t\tthis.r = Math.min( 100, parseInt( color[ 1 ], 10 ) ) / 100;\n\t\t\t\t\t\tthis.g = Math.min( 100, parseInt( color[ 2 ], 10 ) ) / 100;\n\t\t\t\t\t\tthis.b = Math.min( 100, parseInt( color[ 3 ], 10 ) ) / 100;\n\n\t\t\t\t\t\thandleAlpha( color[ 5 ] );\n\n\t\t\t\t\t\treturn this;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'hsl':\n\t\t\t\tcase 'hsla':\n\n\t\t\t\t\tif ( color = /^([0-9]*\\.?[0-9]+)\\s*,\\s*(\\d+)\\%\\s*,\\s*(\\d+)\\%\\s*(,\\s*([0-9]*\\.?[0-9]+)\\s*)?$/.exec( components ) ) {\n\n\t\t\t\t\t\t// hsl(120,50%,50%) hsla(120,50%,50%,0.5)\n\t\t\t\t\t\tconst h = parseFloat( color[ 1 ] ) / 360;\n\t\t\t\t\t\tconst s = parseInt( color[ 2 ], 10 ) / 100;\n\t\t\t\t\t\tconst l = parseInt( color[ 3 ], 10 ) / 100;\n\n\t\t\t\t\t\thandleAlpha( color[ 5 ] );\n\n\t\t\t\t\t\treturn this.setHSL( h, s, l );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tbreak;\n\n\t\t\t}\n\n\t\t} else if ( m = /^\\#([A-Fa-f0-9]+)$/.exec( style ) ) {\n\n\t\t\t// hex color\n\n\t\t\tconst hex = m[ 1 ];\n\t\t\tconst size = hex.length;\n\n\t\t\tif ( size === 3 ) {\n\n\t\t\t\t// #ff0\n\t\t\t\tthis.r = parseInt( hex.charAt( 0 ) + hex.charAt( 0 ), 16 ) / 255;\n\t\t\t\tthis.g = parseInt( hex.charAt( 1 ) + hex.charAt( 1 ), 16 ) / 255;\n\t\t\t\tthis.b = parseInt( hex.charAt( 2 ) + hex.charAt( 2 ), 16 ) / 255;\n\n\t\t\t\treturn this;\n\n\t\t\t} else if ( size === 6 ) {\n\n\t\t\t\t// #ff0000\n\t\t\t\tthis.r = parseInt( hex.charAt( 0 ) + hex.charAt( 1 ), 16 ) / 255;\n\t\t\t\tthis.g = parseInt( hex.charAt( 2 ) + hex.charAt( 3 ), 16 ) / 255;\n\t\t\t\tthis.b = parseInt( hex.charAt( 4 ) + hex.charAt( 5 ), 16 ) / 255;\n\n\t\t\t\treturn this;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( style && style.length > 0 ) {\n\n\t\t\treturn this.setColorName( style );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tsetColorName: function ( style ) {\n\n\t\t// color keywords\n\t\tconst hex = _colorKeywords[ style ];\n\n\t\tif ( hex !== undefined ) {\n\n\t\t\t// red\n\t\t\tthis.setHex( hex );\n\n\t\t} else {\n\n\t\t\t// unknown color\n\t\t\tconsole.warn( 'THREE.Color: Unknown color ' + style );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor( this.r, this.g, this.b );\n\n\t},\n\n\tcopy: function ( color ) {\n\n\t\tthis.r = color.r;\n\t\tthis.g = color.g;\n\t\tthis.b = color.b;\n\n\t\treturn this;\n\n\t},\n\n\tcopyGammaToLinear: function ( color, gammaFactor ) {\n\n\t\tif ( gammaFactor === undefined ) gammaFactor = 2.0;\n\n\t\tthis.r = Math.pow( color.r, gammaFactor );\n\t\tthis.g = Math.pow( color.g, gammaFactor );\n\t\tthis.b = Math.pow( color.b, gammaFactor );\n\n\t\treturn this;\n\n\t},\n\n\tcopyLinearToGamma: function ( color, gammaFactor ) {\n\n\t\tif ( gammaFactor === undefined ) gammaFactor = 2.0;\n\n\t\tconst safeInverse = ( gammaFactor > 0 ) ? ( 1.0 / gammaFactor ) : 1.0;\n\n\t\tthis.r = Math.pow( color.r, safeInverse );\n\t\tthis.g = Math.pow( color.g, safeInverse );\n\t\tthis.b = Math.pow( color.b, safeInverse );\n\n\t\treturn this;\n\n\t},\n\n\tconvertGammaToLinear: function ( gammaFactor ) {\n\n\t\tthis.copyGammaToLinear( this, gammaFactor );\n\n\t\treturn this;\n\n\t},\n\n\tconvertLinearToGamma: function ( gammaFactor ) {\n\n\t\tthis.copyLinearToGamma( this, gammaFactor );\n\n\t\treturn this;\n\n\t},\n\n\tcopySRGBToLinear: function ( color ) {\n\n\t\tthis.r = SRGBToLinear( color.r );\n\t\tthis.g = SRGBToLinear( color.g );\n\t\tthis.b = SRGBToLinear( color.b );\n\n\t\treturn this;\n\n\t},\n\n\tcopyLinearToSRGB: function ( color ) {\n\n\t\tthis.r = LinearToSRGB( color.r );\n\t\tthis.g = LinearToSRGB( color.g );\n\t\tthis.b = LinearToSRGB( color.b );\n\n\t\treturn this;\n\n\t},\n\n\tconvertSRGBToLinear: function () {\n\n\t\tthis.copySRGBToLinear( this );\n\n\t\treturn this;\n\n\t},\n\n\tconvertLinearToSRGB: function () {\n\n\t\tthis.copyLinearToSRGB( this );\n\n\t\treturn this;\n\n\t},\n\n\tgetHex: function () {\n\n\t\treturn ( this.r * 255 ) << 16 ^ ( this.g * 255 ) << 8 ^ ( this.b * 255 ) << 0;\n\n\t},\n\n\tgetHexString: function () {\n\n\t\treturn ( '000000' + this.getHex().toString( 16 ) ).slice( - 6 );\n\n\t},\n\n\tgetHSL: function ( target ) {\n\n\t\t// h,s,l ranges are in 0.0 - 1.0\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Color: .getHSL() target is now required' );\n\t\t\ttarget = { h: 0, s: 0, l: 0 };\n\n\t\t}\n\n\t\tconst r = this.r, g = this.g, b = this.b;\n\n\t\tconst max = Math.max( r, g, b );\n\t\tconst min = Math.min( r, g, b );\n\n\t\tlet hue, saturation;\n\t\tconst lightness = ( min + max ) / 2.0;\n\n\t\tif ( min === max ) {\n\n\t\t\thue = 0;\n\t\t\tsaturation = 0;\n\n\t\t} else {\n\n\t\t\tconst delta = max - min;\n\n\t\t\tsaturation = lightness <= 0.5 ? delta / ( max + min ) : delta / ( 2 - max - min );\n\n\t\t\tswitch ( max ) {\n\n\t\t\t\tcase r: hue = ( g - b ) / delta + ( g < b ? 6 : 0 ); break;\n\t\t\t\tcase g: hue = ( b - r ) / delta + 2; break;\n\t\t\t\tcase b: hue = ( r - g ) / delta + 4; break;\n\n\t\t\t}\n\n\t\t\thue /= 6;\n\n\t\t}\n\n\t\ttarget.h = hue;\n\t\ttarget.s = saturation;\n\t\ttarget.l = lightness;\n\n\t\treturn target;\n\n\t},\n\n\tgetStyle: function () {\n\n\t\treturn 'rgb(' + ( ( this.r * 255 ) | 0 ) + ',' + ( ( this.g * 255 ) | 0 ) + ',' + ( ( this.b * 255 ) | 0 ) + ')';\n\n\t},\n\n\toffsetHSL: function ( h, s, l ) {\n\n\t\tthis.getHSL( _hslA );\n\n\t\t_hslA.h += h; _hslA.s += s; _hslA.l += l;\n\n\t\tthis.setHSL( _hslA.h, _hslA.s, _hslA.l );\n\n\t\treturn this;\n\n\t},\n\n\tadd: function ( color ) {\n\n\t\tthis.r += color.r;\n\t\tthis.g += color.g;\n\t\tthis.b += color.b;\n\n\t\treturn this;\n\n\t},\n\n\taddColors: function ( color1, color2 ) {\n\n\t\tthis.r = color1.r + color2.r;\n\t\tthis.g = color1.g + color2.g;\n\t\tthis.b = color1.b + color2.b;\n\n\t\treturn this;\n\n\t},\n\n\taddScalar: function ( s ) {\n\n\t\tthis.r += s;\n\t\tthis.g += s;\n\t\tthis.b += s;\n\n\t\treturn this;\n\n\t},\n\n\tsub: function ( color ) {\n\n\t\tthis.r = Math.max( 0, this.r - color.r );\n\t\tthis.g = Math.max( 0, this.g - color.g );\n\t\tthis.b = Math.max( 0, this.b - color.b );\n\n\t\treturn this;\n\n\t},\n\n\tmultiply: function ( color ) {\n\n\t\tthis.r *= color.r;\n\t\tthis.g *= color.g;\n\t\tthis.b *= color.b;\n\n\t\treturn this;\n\n\t},\n\n\tmultiplyScalar: function ( s ) {\n\n\t\tthis.r *= s;\n\t\tthis.g *= s;\n\t\tthis.b *= s;\n\n\t\treturn this;\n\n\t},\n\n\tlerp: function ( color, alpha ) {\n\n\t\tthis.r += ( color.r - this.r ) * alpha;\n\t\tthis.g += ( color.g - this.g ) * alpha;\n\t\tthis.b += ( color.b - this.b ) * alpha;\n\n\t\treturn this;\n\n\t},\n\n\tlerpHSL: function ( color, alpha ) {\n\n\t\tthis.getHSL( _hslA );\n\t\tcolor.getHSL( _hslB );\n\n\t\tconst h = MathUtils.lerp( _hslA.h, _hslB.h, alpha );\n\t\tconst s = MathUtils.lerp( _hslA.s, _hslB.s, alpha );\n\t\tconst l = MathUtils.lerp( _hslA.l, _hslB.l, alpha );\n\n\t\tthis.setHSL( h, s, l );\n\n\t\treturn this;\n\n\t},\n\n\tequals: function ( c ) {\n\n\t\treturn ( c.r === this.r ) && ( c.g === this.g ) && ( c.b === this.b );\n\n\t},\n\n\tfromArray: function ( array, offset ) {\n\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tthis.r = array[ offset ];\n\t\tthis.g = array[ offset + 1 ];\n\t\tthis.b = array[ offset + 2 ];\n\n\t\treturn this;\n\n\t},\n\n\ttoArray: function ( array, offset ) {\n\n\t\tif ( array === undefined ) array = [];\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tarray[ offset ] = this.r;\n\t\tarray[ offset + 1 ] = this.g;\n\t\tarray[ offset + 2 ] = this.b;\n\n\t\treturn array;\n\n\t},\n\n\tfromBufferAttribute: function ( attribute, index ) {\n\n\t\tthis.r = attribute.getX( index );\n\t\tthis.g = attribute.getY( index );\n\t\tthis.b = attribute.getZ( index );\n\n\t\tif ( attribute.normalized === true ) {\n\n\t\t\t// assuming Uint8Array\n\n\t\t\tthis.r /= 255;\n\t\t\tthis.g /= 255;\n\t\t\tthis.b /= 255;\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\ttoJSON: function () {\n\n\t\treturn this.getHex();\n\n\t}\n\n} );\n\nColor.NAMES = _colorKeywords;\n\nexport { Color };\n","import { Color } from '../math/Color.js';\nimport { Vector3 } from '../math/Vector3.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author alteredq / http://alteredqualia.com/\n */\n\nfunction Face3( a, b, c, normal, color, materialIndex ) {\n\n\tthis.a = a;\n\tthis.b = b;\n\tthis.c = c;\n\n\tthis.normal = ( normal && normal.isVector3 ) ? normal : new Vector3();\n\tthis.vertexNormals = Array.isArray( normal ) ? normal : [];\n\n\tthis.color = ( color && color.isColor ) ? color : new Color();\n\tthis.vertexColors = Array.isArray( color ) ? color : [];\n\n\tthis.materialIndex = materialIndex !== undefined ? materialIndex : 0;\n\n}\n\nObject.assign( Face3.prototype, {\n\n\tclone: function () {\n\n\t\treturn new this.constructor().copy( this );\n\n\t},\n\n\tcopy: function ( source ) {\n\n\t\tthis.a = source.a;\n\t\tthis.b = source.b;\n\t\tthis.c = source.c;\n\n\t\tthis.normal.copy( source.normal );\n\t\tthis.color.copy( source.color );\n\n\t\tthis.materialIndex = source.materialIndex;\n\n\t\tfor ( let i = 0, il = source.vertexNormals.length; i < il; i ++ ) {\n\n\t\t\tthis.vertexNormals[ i ] = source.vertexNormals[ i ].clone();\n\n\t\t}\n\n\t\tfor ( let i = 0, il = source.vertexColors.length; i < il; i ++ ) {\n\n\t\t\tthis.vertexColors[ i ] = source.vertexColors[ i ].clone();\n\n\t\t}\n\n\t\treturn this;\n\n\t}\n\n} );\n\n\nexport { Face3 };\n","import { EventDispatcher } from '../core/EventDispatcher.js';\nimport { FrontSide, FlatShading, NormalBlending, LessEqualDepth, AddEquation, OneMinusSrcAlphaFactor, SrcAlphaFactor, AlwaysStencilFunc, KeepStencilOp } from '../constants.js';\nimport { MathUtils } from '../math/MathUtils.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author alteredq / http://alteredqualia.com/\n */\n\nlet materialId = 0;\n\nfunction Material() {\n\n\tObject.defineProperty( this, 'id', { value: materialId ++ } );\n\n\tthis.uuid = MathUtils.generateUUID();\n\n\tthis.name = '';\n\tthis.type = 'Material';\n\n\tthis.fog = true;\n\n\tthis.blending = NormalBlending;\n\tthis.side = FrontSide;\n\tthis.flatShading = false;\n\tthis.vertexColors = false;\n\n\tthis.opacity = 1;\n\tthis.transparent = false;\n\n\tthis.blendSrc = SrcAlphaFactor;\n\tthis.blendDst = OneMinusSrcAlphaFactor;\n\tthis.blendEquation = AddEquation;\n\tthis.blendSrcAlpha = null;\n\tthis.blendDstAlpha = null;\n\tthis.blendEquationAlpha = null;\n\n\tthis.depthFunc = LessEqualDepth;\n\tthis.depthTest = true;\n\tthis.depthWrite = true;\n\n\tthis.stencilWriteMask = 0xff;\n\tthis.stencilFunc = AlwaysStencilFunc;\n\tthis.stencilRef = 0;\n\tthis.stencilFuncMask = 0xff;\n\tthis.stencilFail = KeepStencilOp;\n\tthis.stencilZFail = KeepStencilOp;\n\tthis.stencilZPass = KeepStencilOp;\n\tthis.stencilWrite = false;\n\n\tthis.clippingPlanes = null;\n\tthis.clipIntersection = false;\n\tthis.clipShadows = false;\n\n\tthis.shadowSide = null;\n\n\tthis.colorWrite = true;\n\n\tthis.precision = null; // override the renderer's default precision for this material\n\n\tthis.polygonOffset = false;\n\tthis.polygonOffsetFactor = 0;\n\tthis.polygonOffsetUnits = 0;\n\n\tthis.dithering = false;\n\n\tthis.alphaTest = 0;\n\tthis.premultipliedAlpha = false;\n\n\tthis.visible = true;\n\n\tthis.toneMapped = true;\n\n\tthis.userData = {};\n\n\tthis.version = 0;\n\n}\n\nMaterial.prototype = Object.assign( Object.create( EventDispatcher.prototype ), {\n\n\tconstructor: Material,\n\n\tisMaterial: true,\n\n\tonBeforeCompile: function ( /* shaderobject, renderer */ ) {},\n\n\tcustomProgramCacheKey: function () {\n\n\t\treturn this.onBeforeCompile.toString();\n\n\t},\n\n\tsetValues: function ( values ) {\n\n\t\tif ( values === undefined ) return;\n\n\t\tfor ( const key in values ) {\n\n\t\t\tconst newValue = values[ key ];\n\n\t\t\tif ( newValue === undefined ) {\n\n\t\t\t\tconsole.warn( \"THREE.Material: '\" + key + \"' parameter is undefined.\" );\n\t\t\t\tcontinue;\n\n\t\t\t}\n\n\t\t\t// for backward compatability if shading is set in the constructor\n\t\t\tif ( key === 'shading' ) {\n\n\t\t\t\tconsole.warn( 'THREE.' + this.type + ': .shading has been removed. Use the boolean .flatShading instead.' );\n\t\t\t\tthis.flatShading = ( newValue === FlatShading ) ? true : false;\n\t\t\t\tcontinue;\n\n\t\t\t}\n\n\t\t\tconst currentValue = this[ key ];\n\n\t\t\tif ( currentValue === undefined ) {\n\n\t\t\t\tconsole.warn( \"THREE.\" + this.type + \": '\" + key + \"' is not a property of this material.\" );\n\t\t\t\tcontinue;\n\n\t\t\t}\n\n\t\t\tif ( currentValue && currentValue.isColor ) {\n\n\t\t\t\tcurrentValue.set( newValue );\n\n\t\t\t} else if ( ( currentValue && currentValue.isVector3 ) && ( newValue && newValue.isVector3 ) ) {\n\n\t\t\t\tcurrentValue.copy( newValue );\n\n\t\t\t} else {\n\n\t\t\t\tthis[ key ] = newValue;\n\n\t\t\t}\n\n\t\t}\n\n\t},\n\n\ttoJSON: function ( meta ) {\n\n\t\tconst isRoot = ( meta === undefined || typeof meta === 'string' );\n\n\t\tif ( isRoot ) {\n\n\t\t\tmeta = {\n\t\t\t\ttextures: {},\n\t\t\t\timages: {}\n\t\t\t};\n\n\t\t}\n\n\t\tconst data = {\n\t\t\tmetadata: {\n\t\t\t\tversion: 4.5,\n\t\t\t\ttype: 'Material',\n\t\t\t\tgenerator: 'Material.toJSON'\n\t\t\t}\n\t\t};\n\n\t\t// standard Material serialization\n\t\tdata.uuid = this.uuid;\n\t\tdata.type = this.type;\n\n\t\tif ( this.name !== '' ) data.name = this.name;\n\n\t\tif ( this.color && this.color.isColor ) data.color = this.color.getHex();\n\n\t\tif ( this.roughness !== undefined ) data.roughness = this.roughness;\n\t\tif ( this.metalness !== undefined ) data.metalness = this.metalness;\n\n\t\tif ( this.sheen && this.sheen.isColor ) data.sheen = this.sheen.getHex();\n\t\tif ( this.emissive && this.emissive.isColor ) data.emissive = this.emissive.getHex();\n\t\tif ( this.emissiveIntensity && this.emissiveIntensity !== 1 ) data.emissiveIntensity = this.emissiveIntensity;\n\n\t\tif ( this.specular && this.specular.isColor ) data.specular = this.specular.getHex();\n\t\tif ( this.shininess !== undefined ) data.shininess = this.shininess;\n\t\tif ( this.clearcoat !== undefined ) data.clearcoat = this.clearcoat;\n\t\tif ( this.clearcoatRoughness !== undefined ) data.clearcoatRoughness = this.clearcoatRoughness;\n\n\t\tif ( this.clearcoatMap && this.clearcoatMap.isTexture ) {\n\n\t\t\tdata.clearcoatMap = this.clearcoatMap.toJSON( meta ).uuid;\n\n\t\t}\n\n\t\tif ( this.clearcoatRoughnessMap && this.clearcoatRoughnessMap.isTexture ) {\n\n\t\t\tdata.clearcoatRoughnessMap = this.clearcoatRoughnessMap.toJSON( meta ).uuid;\n\n\t\t}\n\n\t\tif ( this.clearcoatNormalMap && this.clearcoatNormalMap.isTexture ) {\n\n\t\t\tdata.clearcoatNormalMap = this.clearcoatNormalMap.toJSON( meta ).uuid;\n\t\t\tdata.clearcoatNormalScale = this.clearcoatNormalScale.toArray();\n\n\t\t}\n\n\t\tif ( this.map && this.map.isTexture ) data.map = this.map.toJSON( meta ).uuid;\n\t\tif ( this.matcap && this.matcap.isTexture ) data.matcap = this.matcap.toJSON( meta ).uuid;\n\t\tif ( this.alphaMap && this.alphaMap.isTexture ) data.alphaMap = this.alphaMap.toJSON( meta ).uuid;\n\t\tif ( this.lightMap && this.lightMap.isTexture ) data.lightMap = this.lightMap.toJSON( meta ).uuid;\n\n\t\tif ( this.aoMap && this.aoMap.isTexture ) {\n\n\t\t\tdata.aoMap = this.aoMap.toJSON( meta ).uuid;\n\t\t\tdata.aoMapIntensity = this.aoMapIntensity;\n\n\t\t}\n\n\t\tif ( this.bumpMap && this.bumpMap.isTexture ) {\n\n\t\t\tdata.bumpMap = this.bumpMap.toJSON( meta ).uuid;\n\t\t\tdata.bumpScale = this.bumpScale;\n\n\t\t}\n\n\t\tif ( this.normalMap && this.normalMap.isTexture ) {\n\n\t\t\tdata.normalMap = this.normalMap.toJSON( meta ).uuid;\n\t\t\tdata.normalMapType = this.normalMapType;\n\t\t\tdata.normalScale = this.normalScale.toArray();\n\n\t\t}\n\n\t\tif ( this.displacementMap && this.displacementMap.isTexture ) {\n\n\t\t\tdata.displacementMap = this.displacementMap.toJSON( meta ).uuid;\n\t\t\tdata.displacementScale = this.displacementScale;\n\t\t\tdata.displacementBias = this.displacementBias;\n\n\t\t}\n\n\t\tif ( this.roughnessMap && this.roughnessMap.isTexture ) data.roughnessMap = this.roughnessMap.toJSON( meta ).uuid;\n\t\tif ( this.metalnessMap && this.metalnessMap.isTexture ) data.metalnessMap = this.metalnessMap.toJSON( meta ).uuid;\n\n\t\tif ( this.emissiveMap && this.emissiveMap.isTexture ) data.emissiveMap = this.emissiveMap.toJSON( meta ).uuid;\n\t\tif ( this.specularMap && this.specularMap.isTexture ) data.specularMap = this.specularMap.toJSON( meta ).uuid;\n\n\t\tif ( this.envMap && this.envMap.isTexture ) {\n\n\t\t\tdata.envMap = this.envMap.toJSON( meta ).uuid;\n\t\t\tdata.reflectivity = this.reflectivity; // Scale behind envMap\n\t\t\tdata.refractionRatio = this.refractionRatio;\n\n\t\t\tif ( this.combine !== undefined ) data.combine = this.combine;\n\t\t\tif ( this.envMapIntensity !== undefined ) data.envMapIntensity = this.envMapIntensity;\n\n\t\t}\n\n\t\tif ( this.gradientMap && this.gradientMap.isTexture ) {\n\n\t\t\tdata.gradientMap = this.gradientMap.toJSON( meta ).uuid;\n\n\t\t}\n\n\t\tif ( this.size !== undefined ) data.size = this.size;\n\t\tif ( this.sizeAttenuation !== undefined ) data.sizeAttenuation = this.sizeAttenuation;\n\n\t\tif ( this.blending !== NormalBlending ) data.blending = this.blending;\n\t\tif ( this.flatShading === true ) data.flatShading = this.flatShading;\n\t\tif ( this.side !== FrontSide ) data.side = this.side;\n\t\tif ( this.vertexColors ) data.vertexColors = true;\n\n\t\tif ( this.opacity < 1 ) data.opacity = this.opacity;\n\t\tif ( this.transparent === true ) data.transparent = this.transparent;\n\n\t\tdata.depthFunc = this.depthFunc;\n\t\tdata.depthTest = this.depthTest;\n\t\tdata.depthWrite = this.depthWrite;\n\n\t\tdata.stencilWrite = this.stencilWrite;\n\t\tdata.stencilWriteMask = this.stencilWriteMask;\n\t\tdata.stencilFunc = this.stencilFunc;\n\t\tdata.stencilRef = this.stencilRef;\n\t\tdata.stencilFuncMask = this.stencilFuncMask;\n\t\tdata.stencilFail = this.stencilFail;\n\t\tdata.stencilZFail = this.stencilZFail;\n\t\tdata.stencilZPass = this.stencilZPass;\n\n\t\t// rotation (SpriteMaterial)\n\t\tif ( this.rotation && this.rotation !== 0 ) data.rotation = this.rotation;\n\n\t\tif ( this.polygonOffset === true ) data.polygonOffset = true;\n\t\tif ( this.polygonOffsetFactor !== 0 ) data.polygonOffsetFactor = this.polygonOffsetFactor;\n\t\tif ( this.polygonOffsetUnits !== 0 ) data.polygonOffsetUnits = this.polygonOffsetUnits;\n\n\t\tif ( this.linewidth && this.linewidth !== 1 ) data.linewidth = this.linewidth;\n\t\tif ( this.dashSize !== undefined ) data.dashSize = this.dashSize;\n\t\tif ( this.gapSize !== undefined ) data.gapSize = this.gapSize;\n\t\tif ( this.scale !== undefined ) data.scale = this.scale;\n\n\t\tif ( this.dithering === true ) data.dithering = true;\n\n\t\tif ( this.alphaTest > 0 ) data.alphaTest = this.alphaTest;\n\t\tif ( this.premultipliedAlpha === true ) data.premultipliedAlpha = this.premultipliedAlpha;\n\n\t\tif ( this.wireframe === true ) data.wireframe = this.wireframe;\n\t\tif ( this.wireframeLinewidth > 1 ) data.wireframeLinewidth = this.wireframeLinewidth;\n\t\tif ( this.wireframeLinecap !== 'round' ) data.wireframeLinecap = this.wireframeLinecap;\n\t\tif ( this.wireframeLinejoin !== 'round' ) data.wireframeLinejoin = this.wireframeLinejoin;\n\n\t\tif ( this.morphTargets === true ) data.morphTargets = true;\n\t\tif ( this.morphNormals === true ) data.morphNormals = true;\n\t\tif ( this.skinning === true ) data.skinning = true;\n\n\t\tif ( this.visible === false ) data.visible = false;\n\n\t\tif ( this.toneMapped === false ) data.toneMapped = false;\n\n\t\tif ( JSON.stringify( this.userData ) !== '{}' ) data.userData = this.userData;\n\n\t\t// TODO: Copied from Object3D.toJSON\n\n\t\tfunction extractFromCache( cache ) {\n\n\t\t\tconst values = [];\n\n\t\t\tfor ( const key in cache ) {\n\n\t\t\t\tconst data = cache[ key ];\n\t\t\t\tdelete data.metadata;\n\t\t\t\tvalues.push( data );\n\n\t\t\t}\n\n\t\t\treturn values;\n\n\t\t}\n\n\t\tif ( isRoot ) {\n\n\t\t\tconst textures = extractFromCache( meta.textures );\n\t\t\tconst images = extractFromCache( meta.images );\n\n\t\t\tif ( textures.length > 0 ) data.textures = textures;\n\t\t\tif ( images.length > 0 ) data.images = images;\n\n\t\t}\n\n\t\treturn data;\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor().copy( this );\n\n\t},\n\n\tcopy: function ( source ) {\n\n\t\tthis.name = source.name;\n\n\t\tthis.fog = source.fog;\n\n\t\tthis.blending = source.blending;\n\t\tthis.side = source.side;\n\t\tthis.flatShading = source.flatShading;\n\t\tthis.vertexColors = source.vertexColors;\n\n\t\tthis.opacity = source.opacity;\n\t\tthis.transparent = source.transparent;\n\n\t\tthis.blendSrc = source.blendSrc;\n\t\tthis.blendDst = source.blendDst;\n\t\tthis.blendEquation = source.blendEquation;\n\t\tthis.blendSrcAlpha = source.blendSrcAlpha;\n\t\tthis.blendDstAlpha = source.blendDstAlpha;\n\t\tthis.blendEquationAlpha = source.blendEquationAlpha;\n\n\t\tthis.depthFunc = source.depthFunc;\n\t\tthis.depthTest = source.depthTest;\n\t\tthis.depthWrite = source.depthWrite;\n\n\t\tthis.stencilWriteMask = source.stencilWriteMask;\n\t\tthis.stencilFunc = source.stencilFunc;\n\t\tthis.stencilRef = source.stencilRef;\n\t\tthis.stencilFuncMask = source.stencilFuncMask;\n\t\tthis.stencilFail = source.stencilFail;\n\t\tthis.stencilZFail = source.stencilZFail;\n\t\tthis.stencilZPass = source.stencilZPass;\n\t\tthis.stencilWrite = source.stencilWrite;\n\n\t\tconst srcPlanes = source.clippingPlanes;\n\t\tlet dstPlanes = null;\n\n\t\tif ( srcPlanes !== null ) {\n\n\t\t\tconst n = srcPlanes.length;\n\t\t\tdstPlanes = new Array( n );\n\n\t\t\tfor ( let i = 0; i !== n; ++ i ) {\n\n\t\t\t\tdstPlanes[ i ] = srcPlanes[ i ].clone();\n\n\t\t\t}\n\n\t\t}\n\n\t\tthis.clippingPlanes = dstPlanes;\n\t\tthis.clipIntersection = source.clipIntersection;\n\t\tthis.clipShadows = source.clipShadows;\n\n\t\tthis.shadowSide = source.shadowSide;\n\n\t\tthis.colorWrite = source.colorWrite;\n\n\t\tthis.precision = source.precision;\n\n\t\tthis.polygonOffset = source.polygonOffset;\n\t\tthis.polygonOffsetFactor = source.polygonOffsetFactor;\n\t\tthis.polygonOffsetUnits = source.polygonOffsetUnits;\n\n\t\tthis.dithering = source.dithering;\n\n\t\tthis.alphaTest = source.alphaTest;\n\t\tthis.premultipliedAlpha = source.premultipliedAlpha;\n\n\t\tthis.visible = source.visible;\n\n\t\tthis.toneMapped = source.toneMapped;\n\n\t\tthis.userData = JSON.parse( JSON.stringify( source.userData ) );\n\n\t\treturn this;\n\n\t},\n\n\tdispose: function () {\n\n\t\tthis.dispatchEvent( { type: 'dispose' } );\n\n\t}\n\n} );\n\nObject.defineProperty( Material.prototype, 'needsUpdate', {\n\n\tset: function ( value ) {\n\n\t\tif ( value === true ) this.version ++;\n\n\t}\n\n} );\n\nexport { Material };\n","import { Material } from './Material.js';\nimport { MultiplyOperation } from '../constants.js';\nimport { Color } from '../math/Color.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author alteredq / http://alteredqualia.com/\n *\n * parameters = {\n * color: ,\n * opacity: ,\n * map: new THREE.Texture( ),\n *\n * lightMap: new THREE.Texture( ),\n * lightMapIntensity: \n *\n * aoMap: new THREE.Texture( ),\n * aoMapIntensity: \n *\n * specularMap: new THREE.Texture( ),\n *\n * alphaMap: new THREE.Texture( ),\n *\n * envMap: new THREE.CubeTexture( [posx, negx, posy, negy, posz, negz] ),\n * combine: THREE.Multiply,\n * reflectivity: ,\n * refractionRatio: ,\n *\n * depthTest: ,\n * depthWrite: ,\n *\n * wireframe: ,\n * wireframeLinewidth: ,\n *\n * skinning: ,\n * morphTargets: \n * }\n */\n\nfunction MeshBasicMaterial( parameters ) {\n\n\tMaterial.call( this );\n\n\tthis.type = 'MeshBasicMaterial';\n\n\tthis.color = new Color( 0xffffff ); // emissive\n\n\tthis.map = null;\n\n\tthis.lightMap = null;\n\tthis.lightMapIntensity = 1.0;\n\n\tthis.aoMap = null;\n\tthis.aoMapIntensity = 1.0;\n\n\tthis.specularMap = null;\n\n\tthis.alphaMap = null;\n\n\tthis.envMap = null;\n\tthis.combine = MultiplyOperation;\n\tthis.reflectivity = 1;\n\tthis.refractionRatio = 0.98;\n\n\tthis.wireframe = false;\n\tthis.wireframeLinewidth = 1;\n\tthis.wireframeLinecap = 'round';\n\tthis.wireframeLinejoin = 'round';\n\n\tthis.skinning = false;\n\tthis.morphTargets = false;\n\n\tthis.setValues( parameters );\n\n}\n\nMeshBasicMaterial.prototype = Object.create( Material.prototype );\nMeshBasicMaterial.prototype.constructor = MeshBasicMaterial;\n\nMeshBasicMaterial.prototype.isMeshBasicMaterial = true;\n\nMeshBasicMaterial.prototype.copy = function ( source ) {\n\n\tMaterial.prototype.copy.call( this, source );\n\n\tthis.color.copy( source.color );\n\n\tthis.map = source.map;\n\n\tthis.lightMap = source.lightMap;\n\tthis.lightMapIntensity = source.lightMapIntensity;\n\n\tthis.aoMap = source.aoMap;\n\tthis.aoMapIntensity = source.aoMapIntensity;\n\n\tthis.specularMap = source.specularMap;\n\n\tthis.alphaMap = source.alphaMap;\n\n\tthis.envMap = source.envMap;\n\tthis.combine = source.combine;\n\tthis.reflectivity = source.reflectivity;\n\tthis.refractionRatio = source.refractionRatio;\n\n\tthis.wireframe = source.wireframe;\n\tthis.wireframeLinewidth = source.wireframeLinewidth;\n\tthis.wireframeLinecap = source.wireframeLinecap;\n\tthis.wireframeLinejoin = source.wireframeLinejoin;\n\n\tthis.skinning = source.skinning;\n\tthis.morphTargets = source.morphTargets;\n\n\treturn this;\n\n};\n\n\nexport { MeshBasicMaterial };\n","import { Vector4 } from '../math/Vector4.js';\nimport { Vector3 } from '../math/Vector3.js';\nimport { Vector2 } from '../math/Vector2.js';\nimport { Color } from '../math/Color.js';\nimport { StaticDrawUsage } from '../constants.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nconst _vector = new Vector3();\nconst _vector2 = new Vector2();\n\nfunction BufferAttribute( array, itemSize, normalized ) {\n\n\tif ( Array.isArray( array ) ) {\n\n\t\tthrow new TypeError( 'THREE.BufferAttribute: array should be a Typed Array.' );\n\n\t}\n\n\tthis.name = '';\n\n\tthis.array = array;\n\tthis.itemSize = itemSize;\n\tthis.count = array !== undefined ? array.length / itemSize : 0;\n\tthis.normalized = normalized === true;\n\n\tthis.usage = StaticDrawUsage;\n\tthis.updateRange = { offset: 0, count: - 1 };\n\n\tthis.version = 0;\n\n}\n\nObject.defineProperty( BufferAttribute.prototype, 'needsUpdate', {\n\n\tset: function ( value ) {\n\n\t\tif ( value === true ) this.version ++;\n\n\t}\n\n} );\n\nObject.assign( BufferAttribute.prototype, {\n\n\tisBufferAttribute: true,\n\n\tonUploadCallback: function () {},\n\n\tsetUsage: function ( value ) {\n\n\t\tthis.usage = value;\n\n\t\treturn this;\n\n\t},\n\n\tcopy: function ( source ) {\n\n\t\tthis.name = source.name;\n\t\tthis.array = new source.array.constructor( source.array );\n\t\tthis.itemSize = source.itemSize;\n\t\tthis.count = source.count;\n\t\tthis.normalized = source.normalized;\n\n\t\tthis.usage = source.usage;\n\n\t\treturn this;\n\n\t},\n\n\tcopyAt: function ( index1, attribute, index2 ) {\n\n\t\tindex1 *= this.itemSize;\n\t\tindex2 *= attribute.itemSize;\n\n\t\tfor ( let i = 0, l = this.itemSize; i < l; i ++ ) {\n\n\t\t\tthis.array[ index1 + i ] = attribute.array[ index2 + i ];\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tcopyArray: function ( array ) {\n\n\t\tthis.array.set( array );\n\n\t\treturn this;\n\n\t},\n\n\tcopyColorsArray: function ( colors ) {\n\n\t\tconst array = this.array;\n\t\tlet offset = 0;\n\n\t\tfor ( let i = 0, l = colors.length; i < l; i ++ ) {\n\n\t\t\tlet color = colors[ i ];\n\n\t\t\tif ( color === undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.BufferAttribute.copyColorsArray(): color is undefined', i );\n\t\t\t\tcolor = new Color();\n\n\t\t\t}\n\n\t\t\tarray[ offset ++ ] = color.r;\n\t\t\tarray[ offset ++ ] = color.g;\n\t\t\tarray[ offset ++ ] = color.b;\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tcopyVector2sArray: function ( vectors ) {\n\n\t\tconst array = this.array;\n\t\tlet offset = 0;\n\n\t\tfor ( let i = 0, l = vectors.length; i < l; i ++ ) {\n\n\t\t\tlet vector = vectors[ i ];\n\n\t\t\tif ( vector === undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.BufferAttribute.copyVector2sArray(): vector is undefined', i );\n\t\t\t\tvector = new Vector2();\n\n\t\t\t}\n\n\t\t\tarray[ offset ++ ] = vector.x;\n\t\t\tarray[ offset ++ ] = vector.y;\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tcopyVector3sArray: function ( vectors ) {\n\n\t\tconst array = this.array;\n\t\tlet offset = 0;\n\n\t\tfor ( let i = 0, l = vectors.length; i < l; i ++ ) {\n\n\t\t\tlet vector = vectors[ i ];\n\n\t\t\tif ( vector === undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.BufferAttribute.copyVector3sArray(): vector is undefined', i );\n\t\t\t\tvector = new Vector3();\n\n\t\t\t}\n\n\t\t\tarray[ offset ++ ] = vector.x;\n\t\t\tarray[ offset ++ ] = vector.y;\n\t\t\tarray[ offset ++ ] = vector.z;\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tcopyVector4sArray: function ( vectors ) {\n\n\t\tconst array = this.array;\n\t\tlet offset = 0;\n\n\t\tfor ( let i = 0, l = vectors.length; i < l; i ++ ) {\n\n\t\t\tlet vector = vectors[ i ];\n\n\t\t\tif ( vector === undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.BufferAttribute.copyVector4sArray(): vector is undefined', i );\n\t\t\t\tvector = new Vector4();\n\n\t\t\t}\n\n\t\t\tarray[ offset ++ ] = vector.x;\n\t\t\tarray[ offset ++ ] = vector.y;\n\t\t\tarray[ offset ++ ] = vector.z;\n\t\t\tarray[ offset ++ ] = vector.w;\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tapplyMatrix3: function ( m ) {\n\n\t\tif ( this.itemSize === 2 ) {\n\n\t\t\tfor ( let i = 0, l = this.count; i < l; i ++ ) {\n\n\t\t\t\t_vector2.fromBufferAttribute( this, i );\n\t\t\t\t_vector2.applyMatrix3( m );\n\n\t\t\t\tthis.setXY( i, _vector2.x, _vector2.y, );\n\n\t\t\t}\n\n\t\t} else if ( this.itemSize === 3 ) {\n\n\t\t\tfor ( let i = 0, l = this.count; i < l; i ++ ) {\n\n\t\t\t\t_vector.fromBufferAttribute( this, i );\n\t\t\t\t_vector.applyMatrix3( m );\n\n\t\t\t\tthis.setXYZ( i, _vector.x, _vector.y, _vector.z );\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tapplyMatrix4: function ( m ) {\n\n\t\tfor ( let i = 0, l = this.count; i < l; i ++ ) {\n\n\t\t\t_vector.x = this.getX( i );\n\t\t\t_vector.y = this.getY( i );\n\t\t\t_vector.z = this.getZ( i );\n\n\t\t\t_vector.applyMatrix4( m );\n\n\t\t\tthis.setXYZ( i, _vector.x, _vector.y, _vector.z );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tapplyNormalMatrix: function ( m ) {\n\n\t\tfor ( let i = 0, l = this.count; i < l; i ++ ) {\n\n\t\t\t_vector.x = this.getX( i );\n\t\t\t_vector.y = this.getY( i );\n\t\t\t_vector.z = this.getZ( i );\n\n\t\t\t_vector.applyNormalMatrix( m );\n\n\t\t\tthis.setXYZ( i, _vector.x, _vector.y, _vector.z );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\ttransformDirection: function ( m ) {\n\n\t\tfor ( let i = 0, l = this.count; i < l; i ++ ) {\n\n\t\t\t_vector.x = this.getX( i );\n\t\t\t_vector.y = this.getY( i );\n\t\t\t_vector.z = this.getZ( i );\n\n\t\t\t_vector.transformDirection( m );\n\n\t\t\tthis.setXYZ( i, _vector.x, _vector.y, _vector.z );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tset: function ( value, offset ) {\n\n\t\tif ( offset === undefined ) offset = 0;\n\n\t\tthis.array.set( value, offset );\n\n\t\treturn this;\n\n\t},\n\n\tgetX: function ( index ) {\n\n\t\treturn this.array[ index * this.itemSize ];\n\n\t},\n\n\tsetX: function ( index, x ) {\n\n\t\tthis.array[ index * this.itemSize ] = x;\n\n\t\treturn this;\n\n\t},\n\n\tgetY: function ( index ) {\n\n\t\treturn this.array[ index * this.itemSize + 1 ];\n\n\t},\n\n\tsetY: function ( index, y ) {\n\n\t\tthis.array[ index * this.itemSize + 1 ] = y;\n\n\t\treturn this;\n\n\t},\n\n\tgetZ: function ( index ) {\n\n\t\treturn this.array[ index * this.itemSize + 2 ];\n\n\t},\n\n\tsetZ: function ( index, z ) {\n\n\t\tthis.array[ index * this.itemSize + 2 ] = z;\n\n\t\treturn this;\n\n\t},\n\n\tgetW: function ( index ) {\n\n\t\treturn this.array[ index * this.itemSize + 3 ];\n\n\t},\n\n\tsetW: function ( index, w ) {\n\n\t\tthis.array[ index * this.itemSize + 3 ] = w;\n\n\t\treturn this;\n\n\t},\n\n\tsetXY: function ( index, x, y ) {\n\n\t\tindex *= this.itemSize;\n\n\t\tthis.array[ index + 0 ] = x;\n\t\tthis.array[ index + 1 ] = y;\n\n\t\treturn this;\n\n\t},\n\n\tsetXYZ: function ( index, x, y, z ) {\n\n\t\tindex *= this.itemSize;\n\n\t\tthis.array[ index + 0 ] = x;\n\t\tthis.array[ index + 1 ] = y;\n\t\tthis.array[ index + 2 ] = z;\n\n\t\treturn this;\n\n\t},\n\n\tsetXYZW: function ( index, x, y, z, w ) {\n\n\t\tindex *= this.itemSize;\n\n\t\tthis.array[ index + 0 ] = x;\n\t\tthis.array[ index + 1 ] = y;\n\t\tthis.array[ index + 2 ] = z;\n\t\tthis.array[ index + 3 ] = w;\n\n\t\treturn this;\n\n\t},\n\n\tonUpload: function ( callback ) {\n\n\t\tthis.onUploadCallback = callback;\n\n\t\treturn this;\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor( this.array, this.itemSize ).copy( this );\n\n\t},\n\n\ttoJSON: function () {\n\n\t\treturn {\n\t\t\titemSize: this.itemSize,\n\t\t\ttype: this.array.constructor.name,\n\t\t\tarray: Array.prototype.slice.call( this.array ),\n\t\t\tnormalized: this.normalized\n\t\t};\n\n\t}\n\n} );\n\n//\n\nfunction Int8BufferAttribute( array, itemSize, normalized ) {\n\n\tBufferAttribute.call( this, new Int8Array( array ), itemSize, normalized );\n\n}\n\nInt8BufferAttribute.prototype = Object.create( BufferAttribute.prototype );\nInt8BufferAttribute.prototype.constructor = Int8BufferAttribute;\n\n\nfunction Uint8BufferAttribute( array, itemSize, normalized ) {\n\n\tBufferAttribute.call( this, new Uint8Array( array ), itemSize, normalized );\n\n}\n\nUint8BufferAttribute.prototype = Object.create( BufferAttribute.prototype );\nUint8BufferAttribute.prototype.constructor = Uint8BufferAttribute;\n\n\nfunction Uint8ClampedBufferAttribute( array, itemSize, normalized ) {\n\n\tBufferAttribute.call( this, new Uint8ClampedArray( array ), itemSize, normalized );\n\n}\n\nUint8ClampedBufferAttribute.prototype = Object.create( BufferAttribute.prototype );\nUint8ClampedBufferAttribute.prototype.constructor = Uint8ClampedBufferAttribute;\n\n\nfunction Int16BufferAttribute( array, itemSize, normalized ) {\n\n\tBufferAttribute.call( this, new Int16Array( array ), itemSize, normalized );\n\n}\n\nInt16BufferAttribute.prototype = Object.create( BufferAttribute.prototype );\nInt16BufferAttribute.prototype.constructor = Int16BufferAttribute;\n\n\nfunction Uint16BufferAttribute( array, itemSize, normalized ) {\n\n\tBufferAttribute.call( this, new Uint16Array( array ), itemSize, normalized );\n\n}\n\nUint16BufferAttribute.prototype = Object.create( BufferAttribute.prototype );\nUint16BufferAttribute.prototype.constructor = Uint16BufferAttribute;\n\n\nfunction Int32BufferAttribute( array, itemSize, normalized ) {\n\n\tBufferAttribute.call( this, new Int32Array( array ), itemSize, normalized );\n\n}\n\nInt32BufferAttribute.prototype = Object.create( BufferAttribute.prototype );\nInt32BufferAttribute.prototype.constructor = Int32BufferAttribute;\n\n\nfunction Uint32BufferAttribute( array, itemSize, normalized ) {\n\n\tBufferAttribute.call( this, new Uint32Array( array ), itemSize, normalized );\n\n}\n\nUint32BufferAttribute.prototype = Object.create( BufferAttribute.prototype );\nUint32BufferAttribute.prototype.constructor = Uint32BufferAttribute;\n\n\nfunction Float32BufferAttribute( array, itemSize, normalized ) {\n\n\tBufferAttribute.call( this, new Float32Array( array ), itemSize, normalized );\n\n}\n\nFloat32BufferAttribute.prototype = Object.create( BufferAttribute.prototype );\nFloat32BufferAttribute.prototype.constructor = Float32BufferAttribute;\n\n\nfunction Float64BufferAttribute( array, itemSize, normalized ) {\n\n\tBufferAttribute.call( this, new Float64Array( array ), itemSize, normalized );\n\n}\n\nFloat64BufferAttribute.prototype = Object.create( BufferAttribute.prototype );\nFloat64BufferAttribute.prototype.constructor = Float64BufferAttribute;\n\n//\n\nexport {\n\tFloat64BufferAttribute,\n\tFloat32BufferAttribute,\n\tUint32BufferAttribute,\n\tInt32BufferAttribute,\n\tUint16BufferAttribute,\n\tInt16BufferAttribute,\n\tUint8ClampedBufferAttribute,\n\tUint8BufferAttribute,\n\tInt8BufferAttribute,\n\tBufferAttribute\n};\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { Vector2 } from '../math/Vector2.js';\n\nfunction DirectGeometry() {\n\n\tthis.vertices = [];\n\tthis.normals = [];\n\tthis.colors = [];\n\tthis.uvs = [];\n\tthis.uvs2 = [];\n\n\tthis.groups = [];\n\n\tthis.morphTargets = {};\n\n\tthis.skinWeights = [];\n\tthis.skinIndices = [];\n\n\t// this.lineDistances = [];\n\n\tthis.boundingBox = null;\n\tthis.boundingSphere = null;\n\n\t// update flags\n\n\tthis.verticesNeedUpdate = false;\n\tthis.normalsNeedUpdate = false;\n\tthis.colorsNeedUpdate = false;\n\tthis.uvsNeedUpdate = false;\n\tthis.groupsNeedUpdate = false;\n\n}\n\nObject.assign( DirectGeometry.prototype, {\n\n\tcomputeGroups: function ( geometry ) {\n\n\t\tconst groups = [];\n\n\t\tlet group, i;\n\t\tlet materialIndex = undefined;\n\n\t\tconst faces = geometry.faces;\n\n\t\tfor ( i = 0; i < faces.length; i ++ ) {\n\n\t\t\tconst face = faces[ i ];\n\n\t\t\t// materials\n\n\t\t\tif ( face.materialIndex !== materialIndex ) {\n\n\t\t\t\tmaterialIndex = face.materialIndex;\n\n\t\t\t\tif ( group !== undefined ) {\n\n\t\t\t\t\tgroup.count = ( i * 3 ) - group.start;\n\t\t\t\t\tgroups.push( group );\n\n\t\t\t\t}\n\n\t\t\t\tgroup = {\n\t\t\t\t\tstart: i * 3,\n\t\t\t\t\tmaterialIndex: materialIndex\n\t\t\t\t};\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( group !== undefined ) {\n\n\t\t\tgroup.count = ( i * 3 ) - group.start;\n\t\t\tgroups.push( group );\n\n\t\t}\n\n\t\tthis.groups = groups;\n\n\t},\n\n\tfromGeometry: function ( geometry ) {\n\n\t\tconst faces = geometry.faces;\n\t\tconst vertices = geometry.vertices;\n\t\tconst faceVertexUvs = geometry.faceVertexUvs;\n\n\t\tconst hasFaceVertexUv = faceVertexUvs[ 0 ] && faceVertexUvs[ 0 ].length > 0;\n\t\tconst hasFaceVertexUv2 = faceVertexUvs[ 1 ] && faceVertexUvs[ 1 ].length > 0;\n\n\t\t// morphs\n\n\t\tconst morphTargets = geometry.morphTargets;\n\t\tconst morphTargetsLength = morphTargets.length;\n\n\t\tlet morphTargetsPosition;\n\n\t\tif ( morphTargetsLength > 0 ) {\n\n\t\t\tmorphTargetsPosition = [];\n\n\t\t\tfor ( let i = 0; i < morphTargetsLength; i ++ ) {\n\n\t\t\t\tmorphTargetsPosition[ i ] = {\n\t\t\t\t\tname: morphTargets[ i ].name,\n\t\t\t\t \tdata: []\n\t\t\t\t};\n\n\t\t\t}\n\n\t\t\tthis.morphTargets.position = morphTargetsPosition;\n\n\t\t}\n\n\t\tconst morphNormals = geometry.morphNormals;\n\t\tconst morphNormalsLength = morphNormals.length;\n\n\t\tlet morphTargetsNormal;\n\n\t\tif ( morphNormalsLength > 0 ) {\n\n\t\t\tmorphTargetsNormal = [];\n\n\t\t\tfor ( let i = 0; i < morphNormalsLength; i ++ ) {\n\n\t\t\t\tmorphTargetsNormal[ i ] = {\n\t\t\t\t\tname: morphNormals[ i ].name,\n\t\t\t\t \tdata: []\n\t\t\t\t};\n\n\t\t\t}\n\n\t\t\tthis.morphTargets.normal = morphTargetsNormal;\n\n\t\t}\n\n\t\t// skins\n\n\t\tconst skinIndices = geometry.skinIndices;\n\t\tconst skinWeights = geometry.skinWeights;\n\n\t\tconst hasSkinIndices = skinIndices.length === vertices.length;\n\t\tconst hasSkinWeights = skinWeights.length === vertices.length;\n\n\t\t//\n\n\t\tif ( vertices.length > 0 && faces.length === 0 ) {\n\n\t\t\tconsole.error( 'THREE.DirectGeometry: Faceless geometries are not supported.' );\n\n\t\t}\n\n\t\tfor ( let i = 0; i < faces.length; i ++ ) {\n\n\t\t\tconst face = faces[ i ];\n\n\t\t\tthis.vertices.push( vertices[ face.a ], vertices[ face.b ], vertices[ face.c ] );\n\n\t\t\tconst vertexNormals = face.vertexNormals;\n\n\t\t\tif ( vertexNormals.length === 3 ) {\n\n\t\t\t\tthis.normals.push( vertexNormals[ 0 ], vertexNormals[ 1 ], vertexNormals[ 2 ] );\n\n\t\t\t} else {\n\n\t\t\t\tconst normal = face.normal;\n\n\t\t\t\tthis.normals.push( normal, normal, normal );\n\n\t\t\t}\n\n\t\t\tconst vertexColors = face.vertexColors;\n\n\t\t\tif ( vertexColors.length === 3 ) {\n\n\t\t\t\tthis.colors.push( vertexColors[ 0 ], vertexColors[ 1 ], vertexColors[ 2 ] );\n\n\t\t\t} else {\n\n\t\t\t\tconst color = face.color;\n\n\t\t\t\tthis.colors.push( color, color, color );\n\n\t\t\t}\n\n\t\t\tif ( hasFaceVertexUv === true ) {\n\n\t\t\t\tconst vertexUvs = faceVertexUvs[ 0 ][ i ];\n\n\t\t\t\tif ( vertexUvs !== undefined ) {\n\n\t\t\t\t\tthis.uvs.push( vertexUvs[ 0 ], vertexUvs[ 1 ], vertexUvs[ 2 ] );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tconsole.warn( 'THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ', i );\n\n\t\t\t\t\tthis.uvs.push( new Vector2(), new Vector2(), new Vector2() );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif ( hasFaceVertexUv2 === true ) {\n\n\t\t\t\tconst vertexUvs = faceVertexUvs[ 1 ][ i ];\n\n\t\t\t\tif ( vertexUvs !== undefined ) {\n\n\t\t\t\t\tthis.uvs2.push( vertexUvs[ 0 ], vertexUvs[ 1 ], vertexUvs[ 2 ] );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tconsole.warn( 'THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ', i );\n\n\t\t\t\t\tthis.uvs2.push( new Vector2(), new Vector2(), new Vector2() );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// morphs\n\n\t\t\tfor ( let j = 0; j < morphTargetsLength; j ++ ) {\n\n\t\t\t\tconst morphTarget = morphTargets[ j ].vertices;\n\n\t\t\t\tmorphTargetsPosition[ j ].data.push( morphTarget[ face.a ], morphTarget[ face.b ], morphTarget[ face.c ] );\n\n\t\t\t}\n\n\t\t\tfor ( let j = 0; j < morphNormalsLength; j ++ ) {\n\n\t\t\t\tconst morphNormal = morphNormals[ j ].vertexNormals[ i ];\n\n\t\t\t\tmorphTargetsNormal[ j ].data.push( morphNormal.a, morphNormal.b, morphNormal.c );\n\n\t\t\t}\n\n\t\t\t// skins\n\n\t\t\tif ( hasSkinIndices ) {\n\n\t\t\t\tthis.skinIndices.push( skinIndices[ face.a ], skinIndices[ face.b ], skinIndices[ face.c ] );\n\n\t\t\t}\n\n\t\t\tif ( hasSkinWeights ) {\n\n\t\t\t\tthis.skinWeights.push( skinWeights[ face.a ], skinWeights[ face.b ], skinWeights[ face.c ] );\n\n\t\t\t}\n\n\t\t}\n\n\t\tthis.computeGroups( geometry );\n\n\t\tthis.verticesNeedUpdate = geometry.verticesNeedUpdate;\n\t\tthis.normalsNeedUpdate = geometry.normalsNeedUpdate;\n\t\tthis.colorsNeedUpdate = geometry.colorsNeedUpdate;\n\t\tthis.uvsNeedUpdate = geometry.uvsNeedUpdate;\n\t\tthis.groupsNeedUpdate = geometry.groupsNeedUpdate;\n\n\t\tif ( geometry.boundingSphere !== null ) {\n\n\t\t\tthis.boundingSphere = geometry.boundingSphere.clone();\n\n\t\t}\n\n\t\tif ( geometry.boundingBox !== null ) {\n\n\t\t\tthis.boundingBox = geometry.boundingBox.clone();\n\n\t\t}\n\n\t\treturn this;\n\n\t}\n\n} );\n\n\nexport { DirectGeometry };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction arrayMin( array ) {\n\n\tif ( array.length === 0 ) return Infinity;\n\n\tlet min = array[ 0 ];\n\n\tfor ( let i = 1, l = array.length; i < l; ++ i ) {\n\n\t\tif ( array[ i ] < min ) min = array[ i ];\n\n\t}\n\n\treturn min;\n\n}\n\nfunction arrayMax( array ) {\n\n\tif ( array.length === 0 ) return - Infinity;\n\n\tlet max = array[ 0 ];\n\n\tfor ( let i = 1, l = array.length; i < l; ++ i ) {\n\n\t\tif ( array[ i ] > max ) max = array[ i ];\n\n\t}\n\n\treturn max;\n\n}\n\nexport { arrayMin, arrayMax };\n","import { Vector3 } from '../math/Vector3.js';\nimport { Box3 } from '../math/Box3.js';\nimport { EventDispatcher } from './EventDispatcher.js';\nimport { BufferAttribute, Float32BufferAttribute, Uint16BufferAttribute, Uint32BufferAttribute } from './BufferAttribute.js';\nimport { Sphere } from '../math/Sphere.js';\nimport { DirectGeometry } from './DirectGeometry.js';\nimport { Object3D } from './Object3D.js';\nimport { Matrix4 } from '../math/Matrix4.js';\nimport { Matrix3 } from '../math/Matrix3.js';\nimport { MathUtils } from '../math/MathUtils.js';\nimport { arrayMax } from '../utils.js';\n\n/**\n * @author alteredq / http://alteredqualia.com/\n * @author mrdoob / http://mrdoob.com/\n */\n\nlet _bufferGeometryId = 1; // BufferGeometry uses odd numbers as Id\n\nconst _m1 = new Matrix4();\nconst _obj = new Object3D();\nconst _offset = new Vector3();\nconst _box = new Box3();\nconst _boxMorphTargets = new Box3();\nconst _vector = new Vector3();\n\nfunction BufferGeometry() {\n\n\tObject.defineProperty( this, 'id', { value: _bufferGeometryId += 2 } );\n\n\tthis.uuid = MathUtils.generateUUID();\n\n\tthis.name = '';\n\tthis.type = 'BufferGeometry';\n\n\tthis.index = null;\n\tthis.attributes = {};\n\n\tthis.morphAttributes = {};\n\tthis.morphTargetsRelative = false;\n\n\tthis.groups = [];\n\n\tthis.boundingBox = null;\n\tthis.boundingSphere = null;\n\n\tthis.drawRange = { start: 0, count: Infinity };\n\n\tthis.userData = {};\n\n}\n\nBufferGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ), {\n\n\tconstructor: BufferGeometry,\n\n\tisBufferGeometry: true,\n\n\tgetIndex: function () {\n\n\t\treturn this.index;\n\n\t},\n\n\tsetIndex: function ( index ) {\n\n\t\tif ( Array.isArray( index ) ) {\n\n\t\t\tthis.index = new ( arrayMax( index ) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute )( index, 1 );\n\n\t\t} else {\n\n\t\t\tthis.index = index;\n\n\t\t}\n\n\t},\n\n\tgetAttribute: function ( name ) {\n\n\t\treturn this.attributes[ name ];\n\n\t},\n\n\tsetAttribute: function ( name, attribute ) {\n\n\t\tthis.attributes[ name ] = attribute;\n\n\t\treturn this;\n\n\t},\n\n\tdeleteAttribute: function ( name ) {\n\n\t\tdelete this.attributes[ name ];\n\n\t\treturn this;\n\n\t},\n\n\taddGroup: function ( start, count, materialIndex ) {\n\n\t\tthis.groups.push( {\n\n\t\t\tstart: start,\n\t\t\tcount: count,\n\t\t\tmaterialIndex: materialIndex !== undefined ? materialIndex : 0\n\n\t\t} );\n\n\t},\n\n\tclearGroups: function () {\n\n\t\tthis.groups = [];\n\n\t},\n\n\tsetDrawRange: function ( start, count ) {\n\n\t\tthis.drawRange.start = start;\n\t\tthis.drawRange.count = count;\n\n\t},\n\n\tapplyMatrix4: function ( matrix ) {\n\n\t\tconst position = this.attributes.position;\n\n\t\tif ( position !== undefined ) {\n\n\t\t\tposition.applyMatrix4( matrix );\n\n\t\t\tposition.needsUpdate = true;\n\n\t\t}\n\n\t\tconst normal = this.attributes.normal;\n\n\t\tif ( normal !== undefined ) {\n\n\t\t\tconst normalMatrix = new Matrix3().getNormalMatrix( matrix );\n\n\t\t\tnormal.applyNormalMatrix( normalMatrix );\n\n\t\t\tnormal.needsUpdate = true;\n\n\t\t}\n\n\t\tconst tangent = this.attributes.tangent;\n\n\t\tif ( tangent !== undefined ) {\n\n\t\t\ttangent.transformDirection( matrix );\n\n\t\t\ttangent.needsUpdate = true;\n\n\t\t}\n\n\t\tif ( this.boundingBox !== null ) {\n\n\t\t\tthis.computeBoundingBox();\n\n\t\t}\n\n\t\tif ( this.boundingSphere !== null ) {\n\n\t\t\tthis.computeBoundingSphere();\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\trotateX: function ( angle ) {\n\n\t\t// rotate geometry around world x-axis\n\n\t\t_m1.makeRotationX( angle );\n\n\t\tthis.applyMatrix4( _m1 );\n\n\t\treturn this;\n\n\t},\n\n\trotateY: function ( angle ) {\n\n\t\t// rotate geometry around world y-axis\n\n\t\t_m1.makeRotationY( angle );\n\n\t\tthis.applyMatrix4( _m1 );\n\n\t\treturn this;\n\n\t},\n\n\trotateZ: function ( angle ) {\n\n\t\t// rotate geometry around world z-axis\n\n\t\t_m1.makeRotationZ( angle );\n\n\t\tthis.applyMatrix4( _m1 );\n\n\t\treturn this;\n\n\t},\n\n\ttranslate: function ( x, y, z ) {\n\n\t\t// translate geometry\n\n\t\t_m1.makeTranslation( x, y, z );\n\n\t\tthis.applyMatrix4( _m1 );\n\n\t\treturn this;\n\n\t},\n\n\tscale: function ( x, y, z ) {\n\n\t\t// scale geometry\n\n\t\t_m1.makeScale( x, y, z );\n\n\t\tthis.applyMatrix4( _m1 );\n\n\t\treturn this;\n\n\t},\n\n\tlookAt: function ( vector ) {\n\n\t\t_obj.lookAt( vector );\n\n\t\t_obj.updateMatrix();\n\n\t\tthis.applyMatrix4( _obj.matrix );\n\n\t\treturn this;\n\n\t},\n\n\tcenter: function () {\n\n\t\tthis.computeBoundingBox();\n\n\t\tthis.boundingBox.getCenter( _offset ).negate();\n\n\t\tthis.translate( _offset.x, _offset.y, _offset.z );\n\n\t\treturn this;\n\n\t},\n\n\tsetFromObject: function ( object ) {\n\n\t\t// console.log( 'THREE.BufferGeometry.setFromObject(). Converting', object, this );\n\n\t\tconst geometry = object.geometry;\n\n\t\tif ( object.isPoints || object.isLine ) {\n\n\t\t\tconst positions = new Float32BufferAttribute( geometry.vertices.length * 3, 3 );\n\t\t\tconst colors = new Float32BufferAttribute( geometry.colors.length * 3, 3 );\n\n\t\t\tthis.setAttribute( 'position', positions.copyVector3sArray( geometry.vertices ) );\n\t\t\tthis.setAttribute( 'color', colors.copyColorsArray( geometry.colors ) );\n\n\t\t\tif ( geometry.lineDistances && geometry.lineDistances.length === geometry.vertices.length ) {\n\n\t\t\t\tconst lineDistances = new Float32BufferAttribute( geometry.lineDistances.length, 1 );\n\n\t\t\t\tthis.setAttribute( 'lineDistance', lineDistances.copyArray( geometry.lineDistances ) );\n\n\t\t\t}\n\n\t\t\tif ( geometry.boundingSphere !== null ) {\n\n\t\t\t\tthis.boundingSphere = geometry.boundingSphere.clone();\n\n\t\t\t}\n\n\t\t\tif ( geometry.boundingBox !== null ) {\n\n\t\t\t\tthis.boundingBox = geometry.boundingBox.clone();\n\n\t\t\t}\n\n\t\t} else if ( object.isMesh ) {\n\n\t\t\tif ( geometry && geometry.isGeometry ) {\n\n\t\t\t\tthis.fromGeometry( geometry );\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tsetFromPoints: function ( points ) {\n\n\t\tconst position = [];\n\n\t\tfor ( let i = 0, l = points.length; i < l; i ++ ) {\n\n\t\t\tconst point = points[ i ];\n\t\t\tposition.push( point.x, point.y, point.z || 0 );\n\n\t\t}\n\n\t\tthis.setAttribute( 'position', new Float32BufferAttribute( position, 3 ) );\n\n\t\treturn this;\n\n\t},\n\n\tupdateFromObject: function ( object ) {\n\n\t\tlet geometry = object.geometry;\n\n\t\tif ( object.isMesh ) {\n\n\t\t\tlet direct = geometry.__directGeometry;\n\n\t\t\tif ( geometry.elementsNeedUpdate === true ) {\n\n\t\t\t\tdirect = undefined;\n\t\t\t\tgeometry.elementsNeedUpdate = false;\n\n\t\t\t}\n\n\t\t\tif ( direct === undefined ) {\n\n\t\t\t\treturn this.fromGeometry( geometry );\n\n\t\t\t}\n\n\t\t\tdirect.verticesNeedUpdate = geometry.verticesNeedUpdate;\n\t\t\tdirect.normalsNeedUpdate = geometry.normalsNeedUpdate;\n\t\t\tdirect.colorsNeedUpdate = geometry.colorsNeedUpdate;\n\t\t\tdirect.uvsNeedUpdate = geometry.uvsNeedUpdate;\n\t\t\tdirect.groupsNeedUpdate = geometry.groupsNeedUpdate;\n\n\t\t\tgeometry.verticesNeedUpdate = false;\n\t\t\tgeometry.normalsNeedUpdate = false;\n\t\t\tgeometry.colorsNeedUpdate = false;\n\t\t\tgeometry.uvsNeedUpdate = false;\n\t\t\tgeometry.groupsNeedUpdate = false;\n\n\t\t\tgeometry = direct;\n\n\t\t}\n\n\t\tif ( geometry.verticesNeedUpdate === true ) {\n\n\t\t\tconst attribute = this.attributes.position;\n\n\t\t\tif ( attribute !== undefined ) {\n\n\t\t\t\tattribute.copyVector3sArray( geometry.vertices );\n\t\t\t\tattribute.needsUpdate = true;\n\n\t\t\t}\n\n\t\t\tgeometry.verticesNeedUpdate = false;\n\n\t\t}\n\n\t\tif ( geometry.normalsNeedUpdate === true ) {\n\n\t\t\tconst attribute = this.attributes.normal;\n\n\t\t\tif ( attribute !== undefined ) {\n\n\t\t\t\tattribute.copyVector3sArray( geometry.normals );\n\t\t\t\tattribute.needsUpdate = true;\n\n\t\t\t}\n\n\t\t\tgeometry.normalsNeedUpdate = false;\n\n\t\t}\n\n\t\tif ( geometry.colorsNeedUpdate === true ) {\n\n\t\t\tconst attribute = this.attributes.color;\n\n\t\t\tif ( attribute !== undefined ) {\n\n\t\t\t\tattribute.copyColorsArray( geometry.colors );\n\t\t\t\tattribute.needsUpdate = true;\n\n\t\t\t}\n\n\t\t\tgeometry.colorsNeedUpdate = false;\n\n\t\t}\n\n\t\tif ( geometry.uvsNeedUpdate ) {\n\n\t\t\tconst attribute = this.attributes.uv;\n\n\t\t\tif ( attribute !== undefined ) {\n\n\t\t\t\tattribute.copyVector2sArray( geometry.uvs );\n\t\t\t\tattribute.needsUpdate = true;\n\n\t\t\t}\n\n\t\t\tgeometry.uvsNeedUpdate = false;\n\n\t\t}\n\n\t\tif ( geometry.lineDistancesNeedUpdate ) {\n\n\t\t\tconst attribute = this.attributes.lineDistance;\n\n\t\t\tif ( attribute !== undefined ) {\n\n\t\t\t\tattribute.copyArray( geometry.lineDistances );\n\t\t\t\tattribute.needsUpdate = true;\n\n\t\t\t}\n\n\t\t\tgeometry.lineDistancesNeedUpdate = false;\n\n\t\t}\n\n\t\tif ( geometry.groupsNeedUpdate ) {\n\n\t\t\tgeometry.computeGroups( object.geometry );\n\t\t\tthis.groups = geometry.groups;\n\n\t\t\tgeometry.groupsNeedUpdate = false;\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tfromGeometry: function ( geometry ) {\n\n\t\tgeometry.__directGeometry = new DirectGeometry().fromGeometry( geometry );\n\n\t\treturn this.fromDirectGeometry( geometry.__directGeometry );\n\n\t},\n\n\tfromDirectGeometry: function ( geometry ) {\n\n\t\tconst positions = new Float32Array( geometry.vertices.length * 3 );\n\t\tthis.setAttribute( 'position', new BufferAttribute( positions, 3 ).copyVector3sArray( geometry.vertices ) );\n\n\t\tif ( geometry.normals.length > 0 ) {\n\n\t\t\tconst normals = new Float32Array( geometry.normals.length * 3 );\n\t\t\tthis.setAttribute( 'normal', new BufferAttribute( normals, 3 ).copyVector3sArray( geometry.normals ) );\n\n\t\t}\n\n\t\tif ( geometry.colors.length > 0 ) {\n\n\t\t\tconst colors = new Float32Array( geometry.colors.length * 3 );\n\t\t\tthis.setAttribute( 'color', new BufferAttribute( colors, 3 ).copyColorsArray( geometry.colors ) );\n\n\t\t}\n\n\t\tif ( geometry.uvs.length > 0 ) {\n\n\t\t\tconst uvs = new Float32Array( geometry.uvs.length * 2 );\n\t\t\tthis.setAttribute( 'uv', new BufferAttribute( uvs, 2 ).copyVector2sArray( geometry.uvs ) );\n\n\t\t}\n\n\t\tif ( geometry.uvs2.length > 0 ) {\n\n\t\t\tconst uvs2 = new Float32Array( geometry.uvs2.length * 2 );\n\t\t\tthis.setAttribute( 'uv2', new BufferAttribute( uvs2, 2 ).copyVector2sArray( geometry.uvs2 ) );\n\n\t\t}\n\n\t\t// groups\n\n\t\tthis.groups = geometry.groups;\n\n\t\t// morphs\n\n\t\tfor ( const name in geometry.morphTargets ) {\n\n\t\t\tconst array = [];\n\t\t\tconst morphTargets = geometry.morphTargets[ name ];\n\n\t\t\tfor ( let i = 0, l = morphTargets.length; i < l; i ++ ) {\n\n\t\t\t\tconst morphTarget = morphTargets[ i ];\n\n\t\t\t\tconst attribute = new Float32BufferAttribute( morphTarget.data.length * 3, 3 );\n\t\t\t\tattribute.name = morphTarget.name;\n\n\t\t\t\tarray.push( attribute.copyVector3sArray( morphTarget.data ) );\n\n\t\t\t}\n\n\t\t\tthis.morphAttributes[ name ] = array;\n\n\t\t}\n\n\t\t// skinning\n\n\t\tif ( geometry.skinIndices.length > 0 ) {\n\n\t\t\tconst skinIndices = new Float32BufferAttribute( geometry.skinIndices.length * 4, 4 );\n\t\t\tthis.setAttribute( 'skinIndex', skinIndices.copyVector4sArray( geometry.skinIndices ) );\n\n\t\t}\n\n\t\tif ( geometry.skinWeights.length > 0 ) {\n\n\t\t\tconst skinWeights = new Float32BufferAttribute( geometry.skinWeights.length * 4, 4 );\n\t\t\tthis.setAttribute( 'skinWeight', skinWeights.copyVector4sArray( geometry.skinWeights ) );\n\n\t\t}\n\n\t\t//\n\n\t\tif ( geometry.boundingSphere !== null ) {\n\n\t\t\tthis.boundingSphere = geometry.boundingSphere.clone();\n\n\t\t}\n\n\t\tif ( geometry.boundingBox !== null ) {\n\n\t\t\tthis.boundingBox = geometry.boundingBox.clone();\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tcomputeBoundingBox: function () {\n\n\t\tif ( this.boundingBox === null ) {\n\n\t\t\tthis.boundingBox = new Box3();\n\n\t\t}\n\n\t\tconst position = this.attributes.position;\n\t\tconst morphAttributesPosition = this.morphAttributes.position;\n\n\t\tif ( position !== undefined ) {\n\n\t\t\tthis.boundingBox.setFromBufferAttribute( position );\n\n\t\t\t// process morph attributes if present\n\n\t\t\tif ( morphAttributesPosition ) {\n\n\t\t\t\tfor ( let i = 0, il = morphAttributesPosition.length; i < il; i ++ ) {\n\n\t\t\t\t\tconst morphAttribute = morphAttributesPosition[ i ];\n\t\t\t\t\t_box.setFromBufferAttribute( morphAttribute );\n\n\t\t\t\t\tif ( this.morphTargetsRelative ) {\n\n\t\t\t\t\t\t_vector.addVectors( this.boundingBox.min, _box.min );\n\t\t\t\t\t\tthis.boundingBox.expandByPoint( _vector );\n\n\t\t\t\t\t\t_vector.addVectors( this.boundingBox.max, _box.max );\n\t\t\t\t\t\tthis.boundingBox.expandByPoint( _vector );\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tthis.boundingBox.expandByPoint( _box.min );\n\t\t\t\t\t\tthis.boundingBox.expandByPoint( _box.max );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tthis.boundingBox.makeEmpty();\n\n\t\t}\n\n\t\tif ( isNaN( this.boundingBox.min.x ) || isNaN( this.boundingBox.min.y ) || isNaN( this.boundingBox.min.z ) ) {\n\n\t\t\tconsole.error( 'THREE.BufferGeometry.computeBoundingBox: Computed min/max have NaN values. The \"position\" attribute is likely to have NaN values.', this );\n\n\t\t}\n\n\t},\n\n\tcomputeBoundingSphere: function () {\n\n\t\tif ( this.boundingSphere === null ) {\n\n\t\t\tthis.boundingSphere = new Sphere();\n\n\t\t}\n\n\t\tconst position = this.attributes.position;\n\t\tconst morphAttributesPosition = this.morphAttributes.position;\n\n\t\tif ( position ) {\n\n\t\t\t// first, find the center of the bounding sphere\n\n\t\t\tconst center = this.boundingSphere.center;\n\n\t\t\t_box.setFromBufferAttribute( position );\n\n\t\t\t// process morph attributes if present\n\n\t\t\tif ( morphAttributesPosition ) {\n\n\t\t\t\tfor ( let i = 0, il = morphAttributesPosition.length; i < il; i ++ ) {\n\n\t\t\t\t\tconst morphAttribute = morphAttributesPosition[ i ];\n\t\t\t\t\t_boxMorphTargets.setFromBufferAttribute( morphAttribute );\n\n\t\t\t\t\tif ( this.morphTargetsRelative ) {\n\n\t\t\t\t\t\t_vector.addVectors( _box.min, _boxMorphTargets.min );\n\t\t\t\t\t\t_box.expandByPoint( _vector );\n\n\t\t\t\t\t\t_vector.addVectors( _box.max, _boxMorphTargets.max );\n\t\t\t\t\t\t_box.expandByPoint( _vector );\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\t_box.expandByPoint( _boxMorphTargets.min );\n\t\t\t\t\t\t_box.expandByPoint( _boxMorphTargets.max );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t_box.getCenter( center );\n\n\t\t\t// second, try to find a boundingSphere with a radius smaller than the\n\t\t\t// boundingSphere of the boundingBox: sqrt(3) smaller in the best case\n\n\t\t\tlet maxRadiusSq = 0;\n\n\t\t\tfor ( let i = 0, il = position.count; i < il; i ++ ) {\n\n\t\t\t\t_vector.fromBufferAttribute( position, i );\n\n\t\t\t\tmaxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector ) );\n\n\t\t\t}\n\n\t\t\t// process morph attributes if present\n\n\t\t\tif ( morphAttributesPosition ) {\n\n\t\t\t\tfor ( let i = 0, il = morphAttributesPosition.length; i < il; i ++ ) {\n\n\t\t\t\t\tconst morphAttribute = morphAttributesPosition[ i ];\n\t\t\t\t\tconst morphTargetsRelative = this.morphTargetsRelative;\n\n\t\t\t\t\tfor ( let j = 0, jl = morphAttribute.count; j < jl; j ++ ) {\n\n\t\t\t\t\t\t_vector.fromBufferAttribute( morphAttribute, j );\n\n\t\t\t\t\t\tif ( morphTargetsRelative ) {\n\n\t\t\t\t\t\t\t_offset.fromBufferAttribute( position, j );\n\t\t\t\t\t\t\t_vector.add( _offset );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tmaxRadiusSq = Math.max( maxRadiusSq, center.distanceToSquared( _vector ) );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tthis.boundingSphere.radius = Math.sqrt( maxRadiusSq );\n\n\t\t\tif ( isNaN( this.boundingSphere.radius ) ) {\n\n\t\t\t\tconsole.error( 'THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The \"position\" attribute is likely to have NaN values.', this );\n\n\t\t\t}\n\n\t\t}\n\n\t},\n\n\tcomputeFaceNormals: function () {\n\n\t\t// backwards compatibility\n\n\t},\n\n\tcomputeVertexNormals: function () {\n\n\t\tconst index = this.index;\n\t\tconst positionAttribute = this.getAttribute( 'position' );\n\n\t\tif ( positionAttribute !== undefined ) {\n\n\t\t\tlet normalAttribute = this.getAttribute( 'normal' );\n\n\t\t\tif ( normalAttribute === undefined ) {\n\n\t\t\t\tnormalAttribute = new BufferAttribute( new Float32Array( positionAttribute.count * 3 ), 3 );\n\t\t\t\tthis.setAttribute( 'normal', normalAttribute );\n\n\t\t\t} else {\n\n\t\t\t\t// reset existing normals to zero\n\n\t\t\t\tfor ( let i = 0, il = normalAttribute.count; i < il; i ++ ) {\n\n\t\t\t\t\tnormalAttribute.setXYZ( i, 0, 0, 0 );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tconst pA = new Vector3(), pB = new Vector3(), pC = new Vector3();\n\t\t\tconst nA = new Vector3(), nB = new Vector3(), nC = new Vector3();\n\t\t\tconst cb = new Vector3(), ab = new Vector3();\n\n\t\t\t// indexed elements\n\n\t\t\tif ( index ) {\n\n\t\t\t\tfor ( let i = 0, il = index.count; i < il; i += 3 ) {\n\n\t\t\t\t\tconst vA = index.getX( i + 0 );\n\t\t\t\t\tconst vB = index.getX( i + 1 );\n\t\t\t\t\tconst vC = index.getX( i + 2 );\n\n\t\t\t\t\tpA.fromBufferAttribute( positionAttribute, vA );\n\t\t\t\t\tpB.fromBufferAttribute( positionAttribute, vB );\n\t\t\t\t\tpC.fromBufferAttribute( positionAttribute, vC );\n\n\t\t\t\t\tcb.subVectors( pC, pB );\n\t\t\t\t\tab.subVectors( pA, pB );\n\t\t\t\t\tcb.cross( ab );\n\n\t\t\t\t\tnA.fromBufferAttribute( normalAttribute, vA );\n\t\t\t\t\tnB.fromBufferAttribute( normalAttribute, vB );\n\t\t\t\t\tnC.fromBufferAttribute( normalAttribute, vC );\n\n\t\t\t\t\tnA.add( cb );\n\t\t\t\t\tnB.add( cb );\n\t\t\t\t\tnC.add( cb );\n\n\t\t\t\t\tnormalAttribute.setXYZ( vA, nA.x, nA.y, nA.z );\n\t\t\t\t\tnormalAttribute.setXYZ( vB, nB.x, nB.y, nB.z );\n\t\t\t\t\tnormalAttribute.setXYZ( vC, nC.x, nC.y, nC.z );\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\t// non-indexed elements (unconnected triangle soup)\n\n\t\t\t\tfor ( let i = 0, il = positionAttribute.count; i < il; i += 3 ) {\n\n\t\t\t\t\tpA.fromBufferAttribute( positionAttribute, i + 0 );\n\t\t\t\t\tpB.fromBufferAttribute( positionAttribute, i + 1 );\n\t\t\t\t\tpC.fromBufferAttribute( positionAttribute, i + 2 );\n\n\t\t\t\t\tcb.subVectors( pC, pB );\n\t\t\t\t\tab.subVectors( pA, pB );\n\t\t\t\t\tcb.cross( ab );\n\n\t\t\t\t\tnormalAttribute.setXYZ( i + 0, cb.x, cb.y, cb.z );\n\t\t\t\t\tnormalAttribute.setXYZ( i + 1, cb.x, cb.y, cb.z );\n\t\t\t\t\tnormalAttribute.setXYZ( i + 2, cb.x, cb.y, cb.z );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tthis.normalizeNormals();\n\n\t\t\tnormalAttribute.needsUpdate = true;\n\n\t\t}\n\n\t},\n\n\tmerge: function ( geometry, offset ) {\n\n\t\tif ( ! ( geometry && geometry.isBufferGeometry ) ) {\n\n\t\t\tconsole.error( 'THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.', geometry );\n\t\t\treturn;\n\n\t\t}\n\n\t\tif ( offset === undefined ) {\n\n\t\t\toffset = 0;\n\n\t\t\tconsole.warn(\n\t\t\t\t'THREE.BufferGeometry.merge(): Overwriting original geometry, starting at offset=0. '\n\t\t\t\t+ 'Use BufferGeometryUtils.mergeBufferGeometries() for lossless merge.'\n\t\t\t);\n\n\t\t}\n\n\t\tconst attributes = this.attributes;\n\n\t\tfor ( const key in attributes ) {\n\n\t\t\tif ( geometry.attributes[ key ] === undefined ) continue;\n\n\t\t\tconst attribute1 = attributes[ key ];\n\t\t\tconst attributeArray1 = attribute1.array;\n\n\t\t\tconst attribute2 = geometry.attributes[ key ];\n\t\t\tconst attributeArray2 = attribute2.array;\n\n\t\t\tconst attributeOffset = attribute2.itemSize * offset;\n\t\t\tconst length = Math.min( attributeArray2.length, attributeArray1.length - attributeOffset );\n\n\t\t\tfor ( let i = 0, j = attributeOffset; i < length; i ++, j ++ ) {\n\n\t\t\t\tattributeArray1[ j ] = attributeArray2[ i ];\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tnormalizeNormals: function () {\n\n\t\tconst normals = this.attributes.normal;\n\n\t\tfor ( let i = 0, il = normals.count; i < il; i ++ ) {\n\n\t\t\t_vector.fromBufferAttribute( normals, i );\n\n\t\t\t_vector.normalize();\n\n\t\t\tnormals.setXYZ( i, _vector.x, _vector.y, _vector.z );\n\n\t\t}\n\n\t},\n\n\ttoNonIndexed: function () {\n\n\t\tfunction convertBufferAttribute( attribute, indices ) {\n\n\t\t\tconst array = attribute.array;\n\t\t\tconst itemSize = attribute.itemSize;\n\t\t\tconst normalized = attribute.normalized;\n\n\t\t\tconst array2 = new array.constructor( indices.length * itemSize );\n\n\t\t\tlet index = 0, index2 = 0;\n\n\t\t\tfor ( let i = 0, l = indices.length; i < l; i ++ ) {\n\n\t\t\t\tindex = indices[ i ] * itemSize;\n\n\t\t\t\tfor ( let j = 0; j < itemSize; j ++ ) {\n\n\t\t\t\t\tarray2[ index2 ++ ] = array[ index ++ ];\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\treturn new BufferAttribute( array2, itemSize, normalized );\n\n\t\t}\n\n\t\t//\n\n\t\tif ( this.index === null ) {\n\n\t\t\tconsole.warn( 'THREE.BufferGeometry.toNonIndexed(): Geometry is already non-indexed.' );\n\t\t\treturn this;\n\n\t\t}\n\n\t\tconst geometry2 = new BufferGeometry();\n\n\t\tconst indices = this.index.array;\n\t\tconst attributes = this.attributes;\n\n\t\t// attributes\n\n\t\tfor ( const name in attributes ) {\n\n\t\t\tconst attribute = attributes[ name ];\n\n\t\t\tconst newAttribute = convertBufferAttribute( attribute, indices );\n\n\t\t\tgeometry2.setAttribute( name, newAttribute );\n\n\t\t}\n\n\t\t// morph attributes\n\n\t\tconst morphAttributes = this.morphAttributes;\n\n\t\tfor ( const name in morphAttributes ) {\n\n\t\t\tconst morphArray = [];\n\t\t\tconst morphAttribute = morphAttributes[ name ]; // morphAttribute: array of Float32BufferAttributes\n\n\t\t\tfor ( let i = 0, il = morphAttribute.length; i < il; i ++ ) {\n\n\t\t\t\tconst attribute = morphAttribute[ i ];\n\n\t\t\t\tconst newAttribute = convertBufferAttribute( attribute, indices );\n\n\t\t\t\tmorphArray.push( newAttribute );\n\n\t\t\t}\n\n\t\t\tgeometry2.morphAttributes[ name ] = morphArray;\n\n\t\t}\n\n\t\tgeometry2.morphTargetsRelative = this.morphTargetsRelative;\n\n\t\t// groups\n\n\t\tconst groups = this.groups;\n\n\t\tfor ( let i = 0, l = groups.length; i < l; i ++ ) {\n\n\t\t\tconst group = groups[ i ];\n\t\t\tgeometry2.addGroup( group.start, group.count, group.materialIndex );\n\n\t\t}\n\n\t\treturn geometry2;\n\n\t},\n\n\ttoJSON: function () {\n\n\t\tconst data = {\n\t\t\tmetadata: {\n\t\t\t\tversion: 4.5,\n\t\t\t\ttype: 'BufferGeometry',\n\t\t\t\tgenerator: 'BufferGeometry.toJSON'\n\t\t\t}\n\t\t};\n\n\t\t// standard BufferGeometry serialization\n\n\t\tdata.uuid = this.uuid;\n\t\tdata.type = this.type;\n\t\tif ( this.name !== '' ) data.name = this.name;\n\t\tif ( Object.keys( this.userData ).length > 0 ) data.userData = this.userData;\n\n\t\tif ( this.parameters !== undefined ) {\n\n\t\t\tconst parameters = this.parameters;\n\n\t\t\tfor ( const key in parameters ) {\n\n\t\t\t\tif ( parameters[ key ] !== undefined ) data[ key ] = parameters[ key ];\n\n\t\t\t}\n\n\t\t\treturn data;\n\n\t\t}\n\n\t\tdata.data = { attributes: {} };\n\n\t\tconst index = this.index;\n\n\t\tif ( index !== null ) {\n\n\t\t\tdata.data.index = {\n\t\t\t\ttype: index.array.constructor.name,\n\t\t\t\tarray: Array.prototype.slice.call( index.array )\n\t\t\t};\n\n\t\t}\n\n\t\tconst attributes = this.attributes;\n\n\t\tfor ( const key in attributes ) {\n\n\t\t\tconst attribute = attributes[ key ];\n\n\t\t\tconst attributeData = attribute.toJSON( data.data );\n\n\t\t\tif ( attribute.name !== '' ) attributeData.name = attribute.name;\n\n\t\t\tdata.data.attributes[ key ] = attributeData;\n\n\t\t}\n\n\t\tconst morphAttributes = {};\n\t\tlet hasMorphAttributes = false;\n\n\t\tfor ( const key in this.morphAttributes ) {\n\n\t\t\tconst attributeArray = this.morphAttributes[ key ];\n\n\t\t\tconst array = [];\n\n\t\t\tfor ( let i = 0, il = attributeArray.length; i < il; i ++ ) {\n\n\t\t\t\tconst attribute = attributeArray[ i ];\n\n\t\t\t\tconst attributeData = attribute.toJSON( data.data );\n\n\t\t\t\tif ( attribute.name !== '' ) attributeData.name = attribute.name;\n\n\t\t\t\tarray.push( attributeData );\n\n\t\t\t}\n\n\t\t\tif ( array.length > 0 ) {\n\n\t\t\t\tmorphAttributes[ key ] = array;\n\n\t\t\t\thasMorphAttributes = true;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( hasMorphAttributes ) {\n\n\t\t\tdata.data.morphAttributes = morphAttributes;\n\t\t\tdata.data.morphTargetsRelative = this.morphTargetsRelative;\n\n\t\t}\n\n\t\tconst groups = this.groups;\n\n\t\tif ( groups.length > 0 ) {\n\n\t\t\tdata.data.groups = JSON.parse( JSON.stringify( groups ) );\n\n\t\t}\n\n\t\tconst boundingSphere = this.boundingSphere;\n\n\t\tif ( boundingSphere !== null ) {\n\n\t\t\tdata.data.boundingSphere = {\n\t\t\t\tcenter: boundingSphere.center.toArray(),\n\t\t\t\tradius: boundingSphere.radius\n\t\t\t};\n\n\t\t}\n\n\t\treturn data;\n\n\t},\n\n\tclone: function () {\n\n\t\t/*\n\t\t // Handle primitives\n\n\t\t const parameters = this.parameters;\n\n\t\t if ( parameters !== undefined ) {\n\n\t\t const values = [];\n\n\t\t for ( const key in parameters ) {\n\n\t\t values.push( parameters[ key ] );\n\n\t\t }\n\n\t\t const geometry = Object.create( this.constructor.prototype );\n\t\t this.constructor.apply( geometry, values );\n\t\t return geometry;\n\n\t\t }\n\n\t\t return new this.constructor().copy( this );\n\t\t */\n\n\t\treturn new BufferGeometry().copy( this );\n\n\t},\n\n\tcopy: function ( source ) {\n\n\t\t// reset\n\n\t\tthis.index = null;\n\t\tthis.attributes = {};\n\t\tthis.morphAttributes = {};\n\t\tthis.groups = [];\n\t\tthis.boundingBox = null;\n\t\tthis.boundingSphere = null;\n\n\t\t// used for storing cloned, shared data\n\n\t\tconst data = {};\n\n\t\t// name\n\n\t\tthis.name = source.name;\n\n\t\t// index\n\n\t\tconst index = source.index;\n\n\t\tif ( index !== null ) {\n\n\t\t\tthis.setIndex( index.clone( data ) );\n\n\t\t}\n\n\t\t// attributes\n\n\t\tconst attributes = source.attributes;\n\n\t\tfor ( const name in attributes ) {\n\n\t\t\tconst attribute = attributes[ name ];\n\t\t\tthis.setAttribute( name, attribute.clone( data ) );\n\n\t\t}\n\n\t\t// morph attributes\n\n\t\tconst morphAttributes = source.morphAttributes;\n\n\t\tfor ( const name in morphAttributes ) {\n\n\t\t\tconst array = [];\n\t\t\tconst morphAttribute = morphAttributes[ name ]; // morphAttribute: array of Float32BufferAttributes\n\n\t\t\tfor ( let i = 0, l = morphAttribute.length; i < l; i ++ ) {\n\n\t\t\t\tarray.push( morphAttribute[ i ].clone( data ) );\n\n\t\t\t}\n\n\t\t\tthis.morphAttributes[ name ] = array;\n\n\t\t}\n\n\t\tthis.morphTargetsRelative = source.morphTargetsRelative;\n\n\t\t// groups\n\n\t\tconst groups = source.groups;\n\n\t\tfor ( let i = 0, l = groups.length; i < l; i ++ ) {\n\n\t\t\tconst group = groups[ i ];\n\t\t\tthis.addGroup( group.start, group.count, group.materialIndex );\n\n\t\t}\n\n\t\t// bounding box\n\n\t\tconst boundingBox = source.boundingBox;\n\n\t\tif ( boundingBox !== null ) {\n\n\t\t\tthis.boundingBox = boundingBox.clone();\n\n\t\t}\n\n\t\t// bounding sphere\n\n\t\tconst boundingSphere = source.boundingSphere;\n\n\t\tif ( boundingSphere !== null ) {\n\n\t\t\tthis.boundingSphere = boundingSphere.clone();\n\n\t\t}\n\n\t\t// draw range\n\n\t\tthis.drawRange.start = source.drawRange.start;\n\t\tthis.drawRange.count = source.drawRange.count;\n\n\t\t// user data\n\n\t\tthis.userData = source.userData;\n\n\t\treturn this;\n\n\t},\n\n\tdispose: function () {\n\n\t\tthis.dispatchEvent( { type: 'dispose' } );\n\n\t}\n\n} );\n\n\nexport { BufferGeometry };\n","import { Vector3 } from '../math/Vector3.js';\nimport { Vector2 } from '../math/Vector2.js';\nimport { Sphere } from '../math/Sphere.js';\nimport { Ray } from '../math/Ray.js';\nimport { Matrix4 } from '../math/Matrix4.js';\nimport { Object3D } from '../core/Object3D.js';\nimport { Triangle } from '../math/Triangle.js';\nimport { Face3 } from '../core/Face3.js';\nimport { DoubleSide, BackSide } from '../constants.js';\nimport { MeshBasicMaterial } from '../materials/MeshBasicMaterial.js';\nimport { BufferGeometry } from '../core/BufferGeometry.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author alteredq / http://alteredqualia.com/\n * @author mikael emtinger / http://gomo.se/\n * @author jonobr1 / http://jonobr1.com/\n */\n\nconst _inverseMatrix = new Matrix4();\nconst _ray = new Ray();\nconst _sphere = new Sphere();\n\nconst _vA = new Vector3();\nconst _vB = new Vector3();\nconst _vC = new Vector3();\n\nconst _tempA = new Vector3();\nconst _tempB = new Vector3();\nconst _tempC = new Vector3();\n\nconst _morphA = new Vector3();\nconst _morphB = new Vector3();\nconst _morphC = new Vector3();\n\nconst _uvA = new Vector2();\nconst _uvB = new Vector2();\nconst _uvC = new Vector2();\n\nconst _intersectionPoint = new Vector3();\nconst _intersectionPointWorld = new Vector3();\n\nfunction Mesh( geometry, material ) {\n\n\tObject3D.call( this );\n\n\tthis.type = 'Mesh';\n\n\tthis.geometry = geometry !== undefined ? geometry : new BufferGeometry();\n\tthis.material = material !== undefined ? material : new MeshBasicMaterial();\n\n\tthis.updateMorphTargets();\n\n}\n\nMesh.prototype = Object.assign( Object.create( Object3D.prototype ), {\n\n\tconstructor: Mesh,\n\n\tisMesh: true,\n\n\tcopy: function ( source ) {\n\n\t\tObject3D.prototype.copy.call( this, source );\n\n\t\tif ( source.morphTargetInfluences !== undefined ) {\n\n\t\t\tthis.morphTargetInfluences = source.morphTargetInfluences.slice();\n\n\t\t}\n\n\t\tif ( source.morphTargetDictionary !== undefined ) {\n\n\t\t\tthis.morphTargetDictionary = Object.assign( {}, source.morphTargetDictionary );\n\n\t\t}\n\n\t\tthis.material = source.material;\n\t\tthis.geometry = source.geometry;\n\n\t\treturn this;\n\n\t},\n\n\tupdateMorphTargets: function () {\n\n\t\tconst geometry = this.geometry;\n\n\t\tif ( geometry.isBufferGeometry ) {\n\n\t\t\tconst morphAttributes = geometry.morphAttributes;\n\t\t\tconst keys = Object.keys( morphAttributes );\n\n\t\t\tif ( keys.length > 0 ) {\n\n\t\t\t\tconst morphAttribute = morphAttributes[ keys[ 0 ] ];\n\n\t\t\t\tif ( morphAttribute !== undefined ) {\n\n\t\t\t\t\tthis.morphTargetInfluences = [];\n\t\t\t\t\tthis.morphTargetDictionary = {};\n\n\t\t\t\t\tfor ( let m = 0, ml = morphAttribute.length; m < ml; m ++ ) {\n\n\t\t\t\t\t\tconst name = morphAttribute[ m ].name || String( m );\n\n\t\t\t\t\t\tthis.morphTargetInfluences.push( 0 );\n\t\t\t\t\t\tthis.morphTargetDictionary[ name ] = m;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tconst morphTargets = geometry.morphTargets;\n\n\t\t\tif ( morphTargets !== undefined && morphTargets.length > 0 ) {\n\n\t\t\t\tconsole.error( 'THREE.Mesh.updateMorphTargets() no longer supports THREE.Geometry. Use THREE.BufferGeometry instead.' );\n\n\t\t\t}\n\n\t\t}\n\n\t},\n\n\traycast: function ( raycaster, intersects ) {\n\n\t\tconst geometry = this.geometry;\n\t\tconst material = this.material;\n\t\tconst matrixWorld = this.matrixWorld;\n\n\t\tif ( material === undefined ) return;\n\n\t\t// Checking boundingSphere distance to ray\n\n\t\tif ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();\n\n\t\t_sphere.copy( geometry.boundingSphere );\n\t\t_sphere.applyMatrix4( matrixWorld );\n\n\t\tif ( raycaster.ray.intersectsSphere( _sphere ) === false ) return;\n\n\t\t//\n\n\t\t_inverseMatrix.getInverse( matrixWorld );\n\t\t_ray.copy( raycaster.ray ).applyMatrix4( _inverseMatrix );\n\n\t\t// Check boundingBox before continuing\n\n\t\tif ( geometry.boundingBox !== null ) {\n\n\t\t\tif ( _ray.intersectsBox( geometry.boundingBox ) === false ) return;\n\n\t\t}\n\n\t\tlet intersection;\n\n\t\tif ( geometry.isBufferGeometry ) {\n\n\t\t\tconst index = geometry.index;\n\t\t\tconst position = geometry.attributes.position;\n\t\t\tconst morphPosition = geometry.morphAttributes.position;\n\t\t\tconst morphTargetsRelative = geometry.morphTargetsRelative;\n\t\t\tconst uv = geometry.attributes.uv;\n\t\t\tconst uv2 = geometry.attributes.uv2;\n\t\t\tconst groups = geometry.groups;\n\t\t\tconst drawRange = geometry.drawRange;\n\n\t\t\tif ( index !== null ) {\n\n\t\t\t\t// indexed buffer geometry\n\n\t\t\t\tif ( Array.isArray( material ) ) {\n\n\t\t\t\t\tfor ( let i = 0, il = groups.length; i < il; i ++ ) {\n\n\t\t\t\t\t\tconst group = groups[ i ];\n\t\t\t\t\t\tconst groupMaterial = material[ group.materialIndex ];\n\n\t\t\t\t\t\tconst start = Math.max( group.start, drawRange.start );\n\t\t\t\t\t\tconst end = Math.min( ( group.start + group.count ), ( drawRange.start + drawRange.count ) );\n\n\t\t\t\t\t\tfor ( let j = start, jl = end; j < jl; j += 3 ) {\n\n\t\t\t\t\t\t\tconst a = index.getX( j );\n\t\t\t\t\t\t\tconst b = index.getX( j + 1 );\n\t\t\t\t\t\t\tconst c = index.getX( j + 2 );\n\n\t\t\t\t\t\t\tintersection = checkBufferGeometryIntersection( this, groupMaterial, raycaster, _ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c );\n\n\t\t\t\t\t\t\tif ( intersection ) {\n\n\t\t\t\t\t\t\t\tintersection.faceIndex = Math.floor( j / 3 ); // triangle number in indexed buffer semantics\n\t\t\t\t\t\t\t\tintersection.face.materialIndex = group.materialIndex;\n\t\t\t\t\t\t\t\tintersects.push( intersection );\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\n\t\t\t\t\tconst start = Math.max( 0, drawRange.start );\n\t\t\t\t\tconst end = Math.min( index.count, ( drawRange.start + drawRange.count ) );\n\n\t\t\t\t\tfor ( let i = start, il = end; i < il; i += 3 ) {\n\n\t\t\t\t\t\tconst a = index.getX( i );\n\t\t\t\t\t\tconst b = index.getX( i + 1 );\n\t\t\t\t\t\tconst c = index.getX( i + 2 );\n\n\t\t\t\t\t\tintersection = checkBufferGeometryIntersection( this, material, raycaster, _ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c );\n\n\t\t\t\t\t\tif ( intersection ) {\n\n\t\t\t\t\t\t\tintersection.faceIndex = Math.floor( i / 3 ); // triangle number in indexed buffer semantics\n\t\t\t\t\t\t\tintersects.push( intersection );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t} else if ( position !== undefined ) {\n\n\t\t\t\t// non-indexed buffer geometry\n\n\t\t\t\tif ( Array.isArray( material ) ) {\n\n\t\t\t\t\tfor ( let i = 0, il = groups.length; i < il; i ++ ) {\n\n\t\t\t\t\t\tconst group = groups[ i ];\n\t\t\t\t\t\tconst groupMaterial = material[ group.materialIndex ];\n\n\t\t\t\t\t\tconst start = Math.max( group.start, drawRange.start );\n\t\t\t\t\t\tconst end = Math.min( ( group.start + group.count ), ( drawRange.start + drawRange.count ) );\n\n\t\t\t\t\t\tfor ( let j = start, jl = end; j < jl; j += 3 ) {\n\n\t\t\t\t\t\t\tconst a = j;\n\t\t\t\t\t\t\tconst b = j + 1;\n\t\t\t\t\t\t\tconst c = j + 2;\n\n\t\t\t\t\t\t\tintersection = checkBufferGeometryIntersection( this, groupMaterial, raycaster, _ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c );\n\n\t\t\t\t\t\t\tif ( intersection ) {\n\n\t\t\t\t\t\t\t\tintersection.faceIndex = Math.floor( j / 3 ); // triangle number in non-indexed buffer semantics\n\t\t\t\t\t\t\t\tintersection.face.materialIndex = group.materialIndex;\n\t\t\t\t\t\t\t\tintersects.push( intersection );\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\n\t\t\t\t\tconst start = Math.max( 0, drawRange.start );\n\t\t\t\t\tconst end = Math.min( position.count, ( drawRange.start + drawRange.count ) );\n\n\t\t\t\t\tfor ( let i = start, il = end; i < il; i += 3 ) {\n\n\t\t\t\t\t\tconst a = i;\n\t\t\t\t\t\tconst b = i + 1;\n\t\t\t\t\t\tconst c = i + 2;\n\n\t\t\t\t\t\tintersection = checkBufferGeometryIntersection( this, material, raycaster, _ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c );\n\n\t\t\t\t\t\tif ( intersection ) {\n\n\t\t\t\t\t\t\tintersection.faceIndex = Math.floor( i / 3 ); // triangle number in non-indexed buffer semantics\n\t\t\t\t\t\t\tintersects.push( intersection );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} else if ( geometry.isGeometry ) {\n\n\t\t\tconst isMultiMaterial = Array.isArray( material );\n\n\t\t\tconst vertices = geometry.vertices;\n\t\t\tconst faces = geometry.faces;\n\t\t\tlet uvs;\n\n\t\t\tconst faceVertexUvs = geometry.faceVertexUvs[ 0 ];\n\t\t\tif ( faceVertexUvs.length > 0 ) uvs = faceVertexUvs;\n\n\t\t\tfor ( let f = 0, fl = faces.length; f < fl; f ++ ) {\n\n\t\t\t\tconst face = faces[ f ];\n\t\t\t\tconst faceMaterial = isMultiMaterial ? material[ face.materialIndex ] : material;\n\n\t\t\t\tif ( faceMaterial === undefined ) continue;\n\n\t\t\t\tconst fvA = vertices[ face.a ];\n\t\t\t\tconst fvB = vertices[ face.b ];\n\t\t\t\tconst fvC = vertices[ face.c ];\n\n\t\t\t\tintersection = checkIntersection( this, faceMaterial, raycaster, _ray, fvA, fvB, fvC, _intersectionPoint );\n\n\t\t\t\tif ( intersection ) {\n\n\t\t\t\t\tif ( uvs && uvs[ f ] ) {\n\n\t\t\t\t\t\tconst uvs_f = uvs[ f ];\n\t\t\t\t\t\t_uvA.copy( uvs_f[ 0 ] );\n\t\t\t\t\t\t_uvB.copy( uvs_f[ 1 ] );\n\t\t\t\t\t\t_uvC.copy( uvs_f[ 2 ] );\n\n\t\t\t\t\t\tintersection.uv = Triangle.getUV( _intersectionPoint, fvA, fvB, fvC, _uvA, _uvB, _uvC, new Vector2() );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tintersection.face = face;\n\t\t\t\t\tintersection.faceIndex = f;\n\t\t\t\t\tintersects.push( intersection );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n} );\n\nfunction checkIntersection( object, material, raycaster, ray, pA, pB, pC, point ) {\n\n\tlet intersect;\n\n\tif ( material.side === BackSide ) {\n\n\t\tintersect = ray.intersectTriangle( pC, pB, pA, true, point );\n\n\t} else {\n\n\t\tintersect = ray.intersectTriangle( pA, pB, pC, material.side !== DoubleSide, point );\n\n\t}\n\n\tif ( intersect === null ) return null;\n\n\t_intersectionPointWorld.copy( point );\n\t_intersectionPointWorld.applyMatrix4( object.matrixWorld );\n\n\tconst distance = raycaster.ray.origin.distanceTo( _intersectionPointWorld );\n\n\tif ( distance < raycaster.near || distance > raycaster.far ) return null;\n\n\treturn {\n\t\tdistance: distance,\n\t\tpoint: _intersectionPointWorld.clone(),\n\t\tobject: object\n\t};\n\n}\n\nfunction checkBufferGeometryIntersection( object, material, raycaster, ray, position, morphPosition, morphTargetsRelative, uv, uv2, a, b, c ) {\n\n\t_vA.fromBufferAttribute( position, a );\n\t_vB.fromBufferAttribute( position, b );\n\t_vC.fromBufferAttribute( position, c );\n\n\tconst morphInfluences = object.morphTargetInfluences;\n\n\tif ( material.morphTargets && morphPosition && morphInfluences ) {\n\n\t\t_morphA.set( 0, 0, 0 );\n\t\t_morphB.set( 0, 0, 0 );\n\t\t_morphC.set( 0, 0, 0 );\n\n\t\tfor ( let i = 0, il = morphPosition.length; i < il; i ++ ) {\n\n\t\t\tconst influence = morphInfluences[ i ];\n\t\t\tconst morphAttribute = morphPosition[ i ];\n\n\t\t\tif ( influence === 0 ) continue;\n\n\t\t\t_tempA.fromBufferAttribute( morphAttribute, a );\n\t\t\t_tempB.fromBufferAttribute( morphAttribute, b );\n\t\t\t_tempC.fromBufferAttribute( morphAttribute, c );\n\n\t\t\tif ( morphTargetsRelative ) {\n\n\t\t\t\t_morphA.addScaledVector( _tempA, influence );\n\t\t\t\t_morphB.addScaledVector( _tempB, influence );\n\t\t\t\t_morphC.addScaledVector( _tempC, influence );\n\n\t\t\t} else {\n\n\t\t\t\t_morphA.addScaledVector( _tempA.sub( _vA ), influence );\n\t\t\t\t_morphB.addScaledVector( _tempB.sub( _vB ), influence );\n\t\t\t\t_morphC.addScaledVector( _tempC.sub( _vC ), influence );\n\n\t\t\t}\n\n\t\t}\n\n\t\t_vA.add( _morphA );\n\t\t_vB.add( _morphB );\n\t\t_vC.add( _morphC );\n\n\t}\n\n\tif ( object.isSkinnedMesh ) {\n\n\t\tobject.boneTransform( a, _vA );\n\t\tobject.boneTransform( b, _vB );\n\t\tobject.boneTransform( c, _vC );\n\n\t}\n\n\tconst intersection = checkIntersection( object, material, raycaster, ray, _vA, _vB, _vC, _intersectionPoint );\n\n\tif ( intersection ) {\n\n\t\tif ( uv ) {\n\n\t\t\t_uvA.fromBufferAttribute( uv, a );\n\t\t\t_uvB.fromBufferAttribute( uv, b );\n\t\t\t_uvC.fromBufferAttribute( uv, c );\n\n\t\t\tintersection.uv = Triangle.getUV( _intersectionPoint, _vA, _vB, _vC, _uvA, _uvB, _uvC, new Vector2() );\n\n\t\t}\n\n\t\tif ( uv2 ) {\n\n\t\t\t_uvA.fromBufferAttribute( uv2, a );\n\t\t\t_uvB.fromBufferAttribute( uv2, b );\n\t\t\t_uvC.fromBufferAttribute( uv2, c );\n\n\t\t\tintersection.uv2 = Triangle.getUV( _intersectionPoint, _vA, _vB, _vC, _uvA, _uvB, _uvC, new Vector2() );\n\n\t\t}\n\n\t\tconst face = new Face3( a, b, c );\n\t\tTriangle.getNormal( _vA, _vB, _vC, face.normal );\n\n\t\tintersection.face = face;\n\n\t}\n\n\treturn intersection;\n\n}\n\nexport { Mesh };\n","import { EventDispatcher } from './EventDispatcher.js';\nimport { Face3 } from './Face3.js';\nimport { Matrix3 } from '../math/Matrix3.js';\nimport { Sphere } from '../math/Sphere.js';\nimport { Box3 } from '../math/Box3.js';\nimport { Vector3 } from '../math/Vector3.js';\nimport { Matrix4 } from '../math/Matrix4.js';\nimport { Vector2 } from '../math/Vector2.js';\nimport { Color } from '../math/Color.js';\nimport { Object3D } from './Object3D.js';\nimport { MathUtils } from '../math/MathUtils.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author kile / http://kile.stravaganza.org/\n * @author alteredq / http://alteredqualia.com/\n * @author mikael emtinger / http://gomo.se/\n * @author zz85 / http://www.lab4games.net/zz85/blog\n * @author bhouston / http://clara.io\n */\n\nlet _geometryId = 0; // Geometry uses even numbers as Id\nconst _m1 = new Matrix4();\nconst _obj = new Object3D();\nconst _offset = new Vector3();\n\nfunction Geometry() {\n\n\tObject.defineProperty( this, 'id', { value: _geometryId += 2 } );\n\n\tthis.uuid = MathUtils.generateUUID();\n\n\tthis.name = '';\n\tthis.type = 'Geometry';\n\n\tthis.vertices = [];\n\tthis.colors = [];\n\tthis.faces = [];\n\tthis.faceVertexUvs = [[]];\n\n\tthis.morphTargets = [];\n\tthis.morphNormals = [];\n\n\tthis.skinWeights = [];\n\tthis.skinIndices = [];\n\n\tthis.lineDistances = [];\n\n\tthis.boundingBox = null;\n\tthis.boundingSphere = null;\n\n\t// update flags\n\n\tthis.elementsNeedUpdate = false;\n\tthis.verticesNeedUpdate = false;\n\tthis.uvsNeedUpdate = false;\n\tthis.normalsNeedUpdate = false;\n\tthis.colorsNeedUpdate = false;\n\tthis.lineDistancesNeedUpdate = false;\n\tthis.groupsNeedUpdate = false;\n\n}\n\nGeometry.prototype = Object.assign( Object.create( EventDispatcher.prototype ), {\n\n\tconstructor: Geometry,\n\n\tisGeometry: true,\n\n\tapplyMatrix4: function ( matrix ) {\n\n\t\tconst normalMatrix = new Matrix3().getNormalMatrix( matrix );\n\n\t\tfor ( let i = 0, il = this.vertices.length; i < il; i ++ ) {\n\n\t\t\tconst vertex = this.vertices[ i ];\n\t\t\tvertex.applyMatrix4( matrix );\n\n\t\t}\n\n\t\tfor ( let i = 0, il = this.faces.length; i < il; i ++ ) {\n\n\t\t\tconst face = this.faces[ i ];\n\t\t\tface.normal.applyMatrix3( normalMatrix ).normalize();\n\n\t\t\tfor ( let j = 0, jl = face.vertexNormals.length; j < jl; j ++ ) {\n\n\t\t\t\tface.vertexNormals[ j ].applyMatrix3( normalMatrix ).normalize();\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( this.boundingBox !== null ) {\n\n\t\t\tthis.computeBoundingBox();\n\n\t\t}\n\n\t\tif ( this.boundingSphere !== null ) {\n\n\t\t\tthis.computeBoundingSphere();\n\n\t\t}\n\n\t\tthis.verticesNeedUpdate = true;\n\t\tthis.normalsNeedUpdate = true;\n\n\t\treturn this;\n\n\t},\n\n\trotateX: function ( angle ) {\n\n\t\t// rotate geometry around world x-axis\n\n\t\t_m1.makeRotationX( angle );\n\n\t\tthis.applyMatrix4( _m1 );\n\n\t\treturn this;\n\n\t},\n\n\trotateY: function ( angle ) {\n\n\t\t// rotate geometry around world y-axis\n\n\t\t_m1.makeRotationY( angle );\n\n\t\tthis.applyMatrix4( _m1 );\n\n\t\treturn this;\n\n\t},\n\n\trotateZ: function ( angle ) {\n\n\t\t// rotate geometry around world z-axis\n\n\t\t_m1.makeRotationZ( angle );\n\n\t\tthis.applyMatrix4( _m1 );\n\n\t\treturn this;\n\n\t},\n\n\ttranslate: function ( x, y, z ) {\n\n\t\t// translate geometry\n\n\t\t_m1.makeTranslation( x, y, z );\n\n\t\tthis.applyMatrix4( _m1 );\n\n\t\treturn this;\n\n\t},\n\n\tscale: function ( x, y, z ) {\n\n\t\t// scale geometry\n\n\t\t_m1.makeScale( x, y, z );\n\n\t\tthis.applyMatrix4( _m1 );\n\n\t\treturn this;\n\n\t},\n\n\tlookAt: function ( vector ) {\n\n\t\t_obj.lookAt( vector );\n\n\t\t_obj.updateMatrix();\n\n\t\tthis.applyMatrix4( _obj.matrix );\n\n\t\treturn this;\n\n\t},\n\n\tfromBufferGeometry: function ( geometry ) {\n\n\t\tconst scope = this;\n\n\t\tconst index = geometry.index !== null ? geometry.index : undefined;\n\t\tconst attributes = geometry.attributes;\n\n\t\tif ( attributes.position === undefined ) {\n\n\t\t\tconsole.error( 'THREE.Geometry.fromBufferGeometry(): Position attribute required for conversion.' );\n\t\t\treturn this;\n\n\t\t}\n\n\t\tconst position = attributes.position;\n\t\tconst normal = attributes.normal;\n\t\tconst color = attributes.color;\n\t\tconst uv = attributes.uv;\n\t\tconst uv2 = attributes.uv2;\n\n\t\tif ( uv2 !== undefined ) this.faceVertexUvs[ 1 ] = [];\n\n\t\tfor ( let i = 0; i < position.count; i ++ ) {\n\n\t\t\tscope.vertices.push( new Vector3().fromBufferAttribute( position, i ) );\n\n\t\t\tif ( color !== undefined ) {\n\n\t\t\t\tscope.colors.push( new Color().fromBufferAttribute( color, i ) );\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction addFace( a, b, c, materialIndex ) {\n\n\t\t\tconst vertexColors = ( color === undefined ) ? [] : [\n\t\t\t\tscope.colors[ a ].clone(),\n\t\t\t\tscope.colors[ b ].clone(),\n\t\t\t\tscope.colors[ c ].clone()\n\t\t\t];\n\n\t\t\tconst vertexNormals = ( normal === undefined ) ? [] : [\n\t\t\t\tnew Vector3().fromBufferAttribute( normal, a ),\n\t\t\t\tnew Vector3().fromBufferAttribute( normal, b ),\n\t\t\t\tnew Vector3().fromBufferAttribute( normal, c )\n\t\t\t];\n\n\t\t\tconst face = new Face3( a, b, c, vertexNormals, vertexColors, materialIndex );\n\n\t\t\tscope.faces.push( face );\n\n\t\t\tif ( uv !== undefined ) {\n\n\t\t\t\tscope.faceVertexUvs[ 0 ].push( [\n\t\t\t\t\tnew Vector2().fromBufferAttribute( uv, a ),\n\t\t\t\t\tnew Vector2().fromBufferAttribute( uv, b ),\n\t\t\t\t\tnew Vector2().fromBufferAttribute( uv, c )\n\t\t\t\t] );\n\n\t\t\t}\n\n\t\t\tif ( uv2 !== undefined ) {\n\n\t\t\t\tscope.faceVertexUvs[ 1 ].push( [\n\t\t\t\t\tnew Vector2().fromBufferAttribute( uv2, a ),\n\t\t\t\t\tnew Vector2().fromBufferAttribute( uv2, b ),\n\t\t\t\t\tnew Vector2().fromBufferAttribute( uv2, c )\n\t\t\t\t] );\n\n\t\t\t}\n\n\t\t}\n\n\t\tconst groups = geometry.groups;\n\n\t\tif ( groups.length > 0 ) {\n\n\t\t\tfor ( let i = 0; i < groups.length; i ++ ) {\n\n\t\t\t\tconst group = groups[ i ];\n\n\t\t\t\tconst start = group.start;\n\t\t\t\tconst count = group.count;\n\n\t\t\t\tfor ( let j = start, jl = start + count; j < jl; j += 3 ) {\n\n\t\t\t\t\tif ( index !== undefined ) {\n\n\t\t\t\t\t\taddFace( index.getX( j ), index.getX( j + 1 ), index.getX( j + 2 ), group.materialIndex );\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\taddFace( j, j + 1, j + 2, group.materialIndex );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tif ( index !== undefined ) {\n\n\t\t\t\tfor ( let i = 0; i < index.count; i += 3 ) {\n\n\t\t\t\t\taddFace( index.getX( i ), index.getX( i + 1 ), index.getX( i + 2 ) );\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\tfor ( let i = 0; i < position.count; i += 3 ) {\n\n\t\t\t\t\taddFace( i, i + 1, i + 2 );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tthis.computeFaceNormals();\n\n\t\tif ( geometry.boundingBox !== null ) {\n\n\t\t\tthis.boundingBox = geometry.boundingBox.clone();\n\n\t\t}\n\n\t\tif ( geometry.boundingSphere !== null ) {\n\n\t\t\tthis.boundingSphere = geometry.boundingSphere.clone();\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tcenter: function () {\n\n\t\tthis.computeBoundingBox();\n\n\t\tthis.boundingBox.getCenter( _offset ).negate();\n\n\t\tthis.translate( _offset.x, _offset.y, _offset.z );\n\n\t\treturn this;\n\n\t},\n\n\tnormalize: function () {\n\n\t\tthis.computeBoundingSphere();\n\n\t\tconst center = this.boundingSphere.center;\n\t\tconst radius = this.boundingSphere.radius;\n\n\t\tconst s = radius === 0 ? 1 : 1.0 / radius;\n\n\t\tconst matrix = new Matrix4();\n\t\tmatrix.set(\n\t\t\ts, 0, 0, - s * center.x,\n\t\t\t0, s, 0, - s * center.y,\n\t\t\t0, 0, s, - s * center.z,\n\t\t\t0, 0, 0, 1\n\t\t);\n\n\t\tthis.applyMatrix4( matrix );\n\n\t\treturn this;\n\n\t},\n\n\tcomputeFaceNormals: function () {\n\n\t\tconst cb = new Vector3(), ab = new Vector3();\n\n\t\tfor ( let f = 0, fl = this.faces.length; f < fl; f ++ ) {\n\n\t\t\tconst face = this.faces[ f ];\n\n\t\t\tconst vA = this.vertices[ face.a ];\n\t\t\tconst vB = this.vertices[ face.b ];\n\t\t\tconst vC = this.vertices[ face.c ];\n\n\t\t\tcb.subVectors( vC, vB );\n\t\t\tab.subVectors( vA, vB );\n\t\t\tcb.cross( ab );\n\n\t\t\tcb.normalize();\n\n\t\t\tface.normal.copy( cb );\n\n\t\t}\n\n\t},\n\n\tcomputeVertexNormals: function ( areaWeighted ) {\n\n\t\tif ( areaWeighted === undefined ) areaWeighted = true;\n\n\t\tconst vertices = new Array( this.vertices.length );\n\n\t\tfor ( let v = 0, vl = this.vertices.length; v < vl; v ++ ) {\n\n\t\t\tvertices[ v ] = new Vector3();\n\n\t\t}\n\n\t\tif ( areaWeighted ) {\n\n\t\t\t// vertex normals weighted by triangle areas\n\t\t\t// http://www.iquilezles.org/www/articles/normals/normals.htm\n\n\t\t\tconst cb = new Vector3(), ab = new Vector3();\n\n\t\t\tfor ( let f = 0, fl = this.faces.length; f < fl; f ++ ) {\n\n\t\t\t\tconst face = this.faces[ f ];\n\n\t\t\t\tconst vA = this.vertices[ face.a ];\n\t\t\t\tconst vB = this.vertices[ face.b ];\n\t\t\t\tconst vC = this.vertices[ face.c ];\n\n\t\t\t\tcb.subVectors( vC, vB );\n\t\t\t\tab.subVectors( vA, vB );\n\t\t\t\tcb.cross( ab );\n\n\t\t\t\tvertices[ face.a ].add( cb );\n\t\t\t\tvertices[ face.b ].add( cb );\n\t\t\t\tvertices[ face.c ].add( cb );\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tthis.computeFaceNormals();\n\n\t\t\tfor ( let f = 0, fl = this.faces.length; f < fl; f ++ ) {\n\n\t\t\t\tconst face = this.faces[ f ];\n\n\t\t\t\tvertices[ face.a ].add( face.normal );\n\t\t\t\tvertices[ face.b ].add( face.normal );\n\t\t\t\tvertices[ face.c ].add( face.normal );\n\n\t\t\t}\n\n\t\t}\n\n\t\tfor ( let v = 0, vl = this.vertices.length; v < vl; v ++ ) {\n\n\t\t\tvertices[ v ].normalize();\n\n\t\t}\n\n\t\tfor ( let f = 0, fl = this.faces.length; f < fl; f ++ ) {\n\n\t\t\tconst face = this.faces[ f ];\n\n\t\t\tconst vertexNormals = face.vertexNormals;\n\n\t\t\tif ( vertexNormals.length === 3 ) {\n\n\t\t\t\tvertexNormals[ 0 ].copy( vertices[ face.a ] );\n\t\t\t\tvertexNormals[ 1 ].copy( vertices[ face.b ] );\n\t\t\t\tvertexNormals[ 2 ].copy( vertices[ face.c ] );\n\n\t\t\t} else {\n\n\t\t\t\tvertexNormals[ 0 ] = vertices[ face.a ].clone();\n\t\t\t\tvertexNormals[ 1 ] = vertices[ face.b ].clone();\n\t\t\t\tvertexNormals[ 2 ] = vertices[ face.c ].clone();\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( this.faces.length > 0 ) {\n\n\t\t\tthis.normalsNeedUpdate = true;\n\n\t\t}\n\n\t},\n\n\tcomputeFlatVertexNormals: function () {\n\n\t\tthis.computeFaceNormals();\n\n\t\tfor ( let f = 0, fl = this.faces.length; f < fl; f ++ ) {\n\n\t\t\tconst face = this.faces[ f ];\n\n\t\t\tconst vertexNormals = face.vertexNormals;\n\n\t\t\tif ( vertexNormals.length === 3 ) {\n\n\t\t\t\tvertexNormals[ 0 ].copy( face.normal );\n\t\t\t\tvertexNormals[ 1 ].copy( face.normal );\n\t\t\t\tvertexNormals[ 2 ].copy( face.normal );\n\n\t\t\t} else {\n\n\t\t\t\tvertexNormals[ 0 ] = face.normal.clone();\n\t\t\t\tvertexNormals[ 1 ] = face.normal.clone();\n\t\t\t\tvertexNormals[ 2 ] = face.normal.clone();\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( this.faces.length > 0 ) {\n\n\t\t\tthis.normalsNeedUpdate = true;\n\n\t\t}\n\n\t},\n\n\tcomputeMorphNormals: function () {\n\n\t\t// save original normals\n\t\t// - create temp variables on first access\n\t\t// otherwise just copy (for faster repeated calls)\n\n\t\tfor ( let f = 0, fl = this.faces.length; f < fl; f ++ ) {\n\n\t\t\tconst face = this.faces[ f ];\n\n\t\t\tif ( ! face.__originalFaceNormal ) {\n\n\t\t\t\tface.__originalFaceNormal = face.normal.clone();\n\n\t\t\t} else {\n\n\t\t\t\tface.__originalFaceNormal.copy( face.normal );\n\n\t\t\t}\n\n\t\t\tif ( ! face.__originalVertexNormals ) face.__originalVertexNormals = [];\n\n\t\t\tfor ( let i = 0, il = face.vertexNormals.length; i < il; i ++ ) {\n\n\t\t\t\tif ( ! face.__originalVertexNormals[ i ] ) {\n\n\t\t\t\t\tface.__originalVertexNormals[ i ] = face.vertexNormals[ i ].clone();\n\n\t\t\t\t} else {\n\n\t\t\t\t\tface.__originalVertexNormals[ i ].copy( face.vertexNormals[ i ] );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\t// use temp geometry to compute face and vertex normals for each morph\n\n\t\tconst tmpGeo = new Geometry();\n\t\ttmpGeo.faces = this.faces;\n\n\t\tfor ( let i = 0, il = this.morphTargets.length; i < il; i ++ ) {\n\n\t\t\t// create on first access\n\n\t\t\tif ( ! this.morphNormals[ i ] ) {\n\n\t\t\t\tthis.morphNormals[ i ] = {};\n\t\t\t\tthis.morphNormals[ i ].faceNormals = [];\n\t\t\t\tthis.morphNormals[ i ].vertexNormals = [];\n\n\t\t\t\tconst dstNormalsFace = this.morphNormals[ i ].faceNormals;\n\t\t\t\tconst dstNormalsVertex = this.morphNormals[ i ].vertexNormals;\n\n\t\t\t\tfor ( let f = 0, fl = this.faces.length; f < fl; f ++ ) {\n\n\t\t\t\t\tconst faceNormal = new Vector3();\n\t\t\t\t\tconst vertexNormals = { a: new Vector3(), b: new Vector3(), c: new Vector3() };\n\n\t\t\t\t\tdstNormalsFace.push( faceNormal );\n\t\t\t\t\tdstNormalsVertex.push( vertexNormals );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tconst morphNormals = this.morphNormals[ i ];\n\n\t\t\t// set vertices to morph target\n\n\t\t\ttmpGeo.vertices = this.morphTargets[ i ].vertices;\n\n\t\t\t// compute morph normals\n\n\t\t\ttmpGeo.computeFaceNormals();\n\t\t\ttmpGeo.computeVertexNormals();\n\n\t\t\t// store morph normals\n\n\t\t\tfor ( let f = 0, fl = this.faces.length; f < fl; f ++ ) {\n\n\t\t\t\tconst face = this.faces[ f ];\n\n\t\t\t\tconst faceNormal = morphNormals.faceNormals[ f ];\n\t\t\t\tconst vertexNormals = morphNormals.vertexNormals[ f ];\n\n\t\t\t\tfaceNormal.copy( face.normal );\n\n\t\t\t\tvertexNormals.a.copy( face.vertexNormals[ 0 ] );\n\t\t\t\tvertexNormals.b.copy( face.vertexNormals[ 1 ] );\n\t\t\t\tvertexNormals.c.copy( face.vertexNormals[ 2 ] );\n\n\t\t\t}\n\n\t\t}\n\n\t\t// restore original normals\n\n\t\tfor ( let f = 0, fl = this.faces.length; f < fl; f ++ ) {\n\n\t\t\tconst face = this.faces[ f ];\n\n\t\t\tface.normal = face.__originalFaceNormal;\n\t\t\tface.vertexNormals = face.__originalVertexNormals;\n\n\t\t}\n\n\t},\n\n\tcomputeBoundingBox: function () {\n\n\t\tif ( this.boundingBox === null ) {\n\n\t\t\tthis.boundingBox = new Box3();\n\n\t\t}\n\n\t\tthis.boundingBox.setFromPoints( this.vertices );\n\n\t},\n\n\tcomputeBoundingSphere: function () {\n\n\t\tif ( this.boundingSphere === null ) {\n\n\t\t\tthis.boundingSphere = new Sphere();\n\n\t\t}\n\n\t\tthis.boundingSphere.setFromPoints( this.vertices );\n\n\t},\n\n\tmerge: function ( geometry, matrix, materialIndexOffset ) {\n\n\t\tif ( ! ( geometry && geometry.isGeometry ) ) {\n\n\t\t\tconsole.error( 'THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.', geometry );\n\t\t\treturn;\n\n\t\t}\n\n\t\tlet normalMatrix,\n\t\t\tvertexOffset = this.vertices.length,\n\t\t\tvertices1 = this.vertices,\n\t\t\tvertices2 = geometry.vertices,\n\t\t\tfaces1 = this.faces,\n\t\t\tfaces2 = geometry.faces,\n\t\t\tcolors1 = this.colors,\n\t\t\tcolors2 = geometry.colors;\n\n\t\tif ( materialIndexOffset === undefined ) materialIndexOffset = 0;\n\n\t\tif ( matrix !== undefined ) {\n\n\t\t\tnormalMatrix = new Matrix3().getNormalMatrix( matrix );\n\n\t\t}\n\n\t\t// vertices\n\n\t\tfor ( let i = 0, il = vertices2.length; i < il; i ++ ) {\n\n\t\t\tconst vertex = vertices2[ i ];\n\n\t\t\tconst vertexCopy = vertex.clone();\n\n\t\t\tif ( matrix !== undefined ) vertexCopy.applyMatrix4( matrix );\n\n\t\t\tvertices1.push( vertexCopy );\n\n\t\t}\n\n\t\t// colors\n\n\t\tfor ( let i = 0, il = colors2.length; i < il; i ++ ) {\n\n\t\t\tcolors1.push( colors2[ i ].clone() );\n\n\t\t}\n\n\t\t// faces\n\n\t\tfor ( let i = 0, il = faces2.length; i < il; i ++ ) {\n\n\t\t\tlet face = faces2[ i ], faceCopy, normal, color,\n\t\t\t\tfaceVertexNormals = face.vertexNormals,\n\t\t\t\tfaceVertexColors = face.vertexColors;\n\n\t\t\tfaceCopy = new Face3( face.a + vertexOffset, face.b + vertexOffset, face.c + vertexOffset );\n\t\t\tfaceCopy.normal.copy( face.normal );\n\n\t\t\tif ( normalMatrix !== undefined ) {\n\n\t\t\t\tfaceCopy.normal.applyMatrix3( normalMatrix ).normalize();\n\n\t\t\t}\n\n\t\t\tfor ( let j = 0, jl = faceVertexNormals.length; j < jl; j ++ ) {\n\n\t\t\t\tnormal = faceVertexNormals[ j ].clone();\n\n\t\t\t\tif ( normalMatrix !== undefined ) {\n\n\t\t\t\t\tnormal.applyMatrix3( normalMatrix ).normalize();\n\n\t\t\t\t}\n\n\t\t\t\tfaceCopy.vertexNormals.push( normal );\n\n\t\t\t}\n\n\t\t\tfaceCopy.color.copy( face.color );\n\n\t\t\tfor ( let j = 0, jl = faceVertexColors.length; j < jl; j ++ ) {\n\n\t\t\t\tcolor = faceVertexColors[ j ];\n\t\t\t\tfaceCopy.vertexColors.push( color.clone() );\n\n\t\t\t}\n\n\t\t\tfaceCopy.materialIndex = face.materialIndex + materialIndexOffset;\n\n\t\t\tfaces1.push( faceCopy );\n\n\t\t}\n\n\t\t// uvs\n\n\t\tfor ( let i = 0, il = geometry.faceVertexUvs.length; i < il; i ++ ) {\n\n\t\t\tconst faceVertexUvs2 = geometry.faceVertexUvs[ i ];\n\n\t\t\tif ( this.faceVertexUvs[ i ] === undefined ) this.faceVertexUvs[ i ] = [];\n\n\t\t\tfor ( let j = 0, jl = faceVertexUvs2.length; j < jl; j ++ ) {\n\n\t\t\t\tconst uvs2 = faceVertexUvs2[ j ], uvsCopy = [];\n\n\t\t\t\tfor ( let k = 0, kl = uvs2.length; k < kl; k ++ ) {\n\n\t\t\t\t\tuvsCopy.push( uvs2[ k ].clone() );\n\n\t\t\t\t}\n\n\t\t\t\tthis.faceVertexUvs[ i ].push( uvsCopy );\n\n\t\t\t}\n\n\t\t}\n\n\t},\n\n\tmergeMesh: function ( mesh ) {\n\n\t\tif ( ! ( mesh && mesh.isMesh ) ) {\n\n\t\t\tconsole.error( 'THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.', mesh );\n\t\t\treturn;\n\n\t\t}\n\n\t\tif ( mesh.matrixAutoUpdate ) mesh.updateMatrix();\n\n\t\tthis.merge( mesh.geometry, mesh.matrix );\n\n\t},\n\n\t/*\n\t * Checks for duplicate vertices with hashmap.\n\t * Duplicated vertices are removed\n\t * and faces' vertices are updated.\n\t */\n\n\tmergeVertices: function () {\n\n\t\tconst verticesMap = {}; // Hashmap for looking up vertices by position coordinates (and making sure they are unique)\n\t\tconst unique = [], changes = [];\n\n\t\tconst precisionPoints = 4; // number of decimal points, e.g. 4 for epsilon of 0.0001\n\t\tconst precision = Math.pow( 10, precisionPoints );\n\n\t\tfor ( let i = 0, il = this.vertices.length; i < il; i ++ ) {\n\n\t\t\tconst v = this.vertices[ i ];\n\t\t\tconst key = Math.round( v.x * precision ) + '_' + Math.round( v.y * precision ) + '_' + Math.round( v.z * precision );\n\n\t\t\tif ( verticesMap[ key ] === undefined ) {\n\n\t\t\t\tverticesMap[ key ] = i;\n\t\t\t\tunique.push( this.vertices[ i ] );\n\t\t\t\tchanges[ i ] = unique.length - 1;\n\n\t\t\t} else {\n\n\t\t\t\t//console.log('Duplicate vertex found. ', i, ' could be using ', verticesMap[key]);\n\t\t\t\tchanges[ i ] = changes[ verticesMap[ key ] ];\n\n\t\t\t}\n\n\t\t}\n\n\n\t\t// if faces are completely degenerate after merging vertices, we\n\t\t// have to remove them from the geometry.\n\t\tconst faceIndicesToRemove = [];\n\n\t\tfor ( let i = 0, il = this.faces.length; i < il; i ++ ) {\n\n\t\t\tconst face = this.faces[ i ];\n\n\t\t\tface.a = changes[ face.a ];\n\t\t\tface.b = changes[ face.b ];\n\t\t\tface.c = changes[ face.c ];\n\n\t\t\tconst indices = [ face.a, face.b, face.c ];\n\n\t\t\t// if any duplicate vertices are found in a Face3\n\t\t\t// we have to remove the face as nothing can be saved\n\t\t\tfor ( let n = 0; n < 3; n ++ ) {\n\n\t\t\t\tif ( indices[ n ] === indices[ ( n + 1 ) % 3 ] ) {\n\n\t\t\t\t\tfaceIndicesToRemove.push( i );\n\t\t\t\t\tbreak;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tfor ( let i = faceIndicesToRemove.length - 1; i >= 0; i -- ) {\n\n\t\t\tconst idx = faceIndicesToRemove[ i ];\n\n\t\t\tthis.faces.splice( idx, 1 );\n\n\t\t\tfor ( let j = 0, jl = this.faceVertexUvs.length; j < jl; j ++ ) {\n\n\t\t\t\tthis.faceVertexUvs[ j ].splice( idx, 1 );\n\n\t\t\t}\n\n\t\t}\n\n\t\t// Use unique set of vertices\n\n\t\tconst diff = this.vertices.length - unique.length;\n\t\tthis.vertices = unique;\n\t\treturn diff;\n\n\t},\n\n\tsetFromPoints: function ( points ) {\n\n\t\tthis.vertices = [];\n\n\t\tfor ( let i = 0, l = points.length; i < l; i ++ ) {\n\n\t\t\tconst point = points[ i ];\n\t\t\tthis.vertices.push( new Vector3( point.x, point.y, point.z || 0 ) );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tsortFacesByMaterialIndex: function () {\n\n\t\tconst faces = this.faces;\n\t\tconst length = faces.length;\n\n\t\t// tag faces\n\n\t\tfor ( let i = 0; i < length; i ++ ) {\n\n\t\t\tfaces[ i ]._id = i;\n\n\t\t}\n\n\t\t// sort faces\n\n\t\tfunction materialIndexSort( a, b ) {\n\n\t\t\treturn a.materialIndex - b.materialIndex;\n\n\t\t}\n\n\t\tfaces.sort( materialIndexSort );\n\n\t\t// sort uvs\n\n\t\tconst uvs1 = this.faceVertexUvs[ 0 ];\n\t\tconst uvs2 = this.faceVertexUvs[ 1 ];\n\n\t\tlet newUvs1, newUvs2;\n\n\t\tif ( uvs1 && uvs1.length === length ) newUvs1 = [];\n\t\tif ( uvs2 && uvs2.length === length ) newUvs2 = [];\n\n\t\tfor ( let i = 0; i < length; i ++ ) {\n\n\t\t\tconst id = faces[ i ]._id;\n\n\t\t\tif ( newUvs1 ) newUvs1.push( uvs1[ id ] );\n\t\t\tif ( newUvs2 ) newUvs2.push( uvs2[ id ] );\n\n\t\t}\n\n\t\tif ( newUvs1 ) this.faceVertexUvs[ 0 ] = newUvs1;\n\t\tif ( newUvs2 ) this.faceVertexUvs[ 1 ] = newUvs2;\n\n\t},\n\n\ttoJSON: function () {\n\n\t\tconst data = {\n\t\t\tmetadata: {\n\t\t\t\tversion: 4.5,\n\t\t\t\ttype: 'Geometry',\n\t\t\t\tgenerator: 'Geometry.toJSON'\n\t\t\t}\n\t\t};\n\n\t\t// standard Geometry serialization\n\n\t\tdata.uuid = this.uuid;\n\t\tdata.type = this.type;\n\t\tif ( this.name !== '' ) data.name = this.name;\n\n\t\tif ( this.parameters !== undefined ) {\n\n\t\t\tconst parameters = this.parameters;\n\n\t\t\tfor ( const key in parameters ) {\n\n\t\t\t\tif ( parameters[ key ] !== undefined ) data[ key ] = parameters[ key ];\n\n\t\t\t}\n\n\t\t\treturn data;\n\n\t\t}\n\n\t\tconst vertices = [];\n\n\t\tfor ( let i = 0; i < this.vertices.length; i ++ ) {\n\n\t\t\tconst vertex = this.vertices[ i ];\n\t\t\tvertices.push( vertex.x, vertex.y, vertex.z );\n\n\t\t}\n\n\t\tconst faces = [];\n\t\tconst normals = [];\n\t\tconst normalsHash = {};\n\t\tconst colors = [];\n\t\tconst colorsHash = {};\n\t\tconst uvs = [];\n\t\tconst uvsHash = {};\n\n\t\tfor ( let i = 0; i < this.faces.length; i ++ ) {\n\n\t\t\tconst face = this.faces[ i ];\n\n\t\t\tconst hasMaterial = true;\n\t\t\tconst hasFaceUv = false; // deprecated\n\t\t\tconst hasFaceVertexUv = this.faceVertexUvs[ 0 ][ i ] !== undefined;\n\t\t\tconst hasFaceNormal = face.normal.length() > 0;\n\t\t\tconst hasFaceVertexNormal = face.vertexNormals.length > 0;\n\t\t\tconst hasFaceColor = face.color.r !== 1 || face.color.g !== 1 || face.color.b !== 1;\n\t\t\tconst hasFaceVertexColor = face.vertexColors.length > 0;\n\n\t\t\tlet faceType = 0;\n\n\t\t\tfaceType = setBit( faceType, 0, 0 ); // isQuad\n\t\t\tfaceType = setBit( faceType, 1, hasMaterial );\n\t\t\tfaceType = setBit( faceType, 2, hasFaceUv );\n\t\t\tfaceType = setBit( faceType, 3, hasFaceVertexUv );\n\t\t\tfaceType = setBit( faceType, 4, hasFaceNormal );\n\t\t\tfaceType = setBit( faceType, 5, hasFaceVertexNormal );\n\t\t\tfaceType = setBit( faceType, 6, hasFaceColor );\n\t\t\tfaceType = setBit( faceType, 7, hasFaceVertexColor );\n\n\t\t\tfaces.push( faceType );\n\t\t\tfaces.push( face.a, face.b, face.c );\n\t\t\tfaces.push( face.materialIndex );\n\n\t\t\tif ( hasFaceVertexUv ) {\n\n\t\t\t\tconst faceVertexUvs = this.faceVertexUvs[ 0 ][ i ];\n\n\t\t\t\tfaces.push(\n\t\t\t\t\tgetUvIndex( faceVertexUvs[ 0 ] ),\n\t\t\t\t\tgetUvIndex( faceVertexUvs[ 1 ] ),\n\t\t\t\t\tgetUvIndex( faceVertexUvs[ 2 ] )\n\t\t\t\t);\n\n\t\t\t}\n\n\t\t\tif ( hasFaceNormal ) {\n\n\t\t\t\tfaces.push( getNormalIndex( face.normal ) );\n\n\t\t\t}\n\n\t\t\tif ( hasFaceVertexNormal ) {\n\n\t\t\t\tconst vertexNormals = face.vertexNormals;\n\n\t\t\t\tfaces.push(\n\t\t\t\t\tgetNormalIndex( vertexNormals[ 0 ] ),\n\t\t\t\t\tgetNormalIndex( vertexNormals[ 1 ] ),\n\t\t\t\t\tgetNormalIndex( vertexNormals[ 2 ] )\n\t\t\t\t);\n\n\t\t\t}\n\n\t\t\tif ( hasFaceColor ) {\n\n\t\t\t\tfaces.push( getColorIndex( face.color ) );\n\n\t\t\t}\n\n\t\t\tif ( hasFaceVertexColor ) {\n\n\t\t\t\tconst vertexColors = face.vertexColors;\n\n\t\t\t\tfaces.push(\n\t\t\t\t\tgetColorIndex( vertexColors[ 0 ] ),\n\t\t\t\t\tgetColorIndex( vertexColors[ 1 ] ),\n\t\t\t\t\tgetColorIndex( vertexColors[ 2 ] )\n\t\t\t\t);\n\n\t\t\t}\n\n\t\t}\n\n\t\tfunction setBit( value, position, enabled ) {\n\n\t\t\treturn enabled ? value | ( 1 << position ) : value & ( ~ ( 1 << position ) );\n\n\t\t}\n\n\t\tfunction getNormalIndex( normal ) {\n\n\t\t\tconst hash = normal.x.toString() + normal.y.toString() + normal.z.toString();\n\n\t\t\tif ( normalsHash[ hash ] !== undefined ) {\n\n\t\t\t\treturn normalsHash[ hash ];\n\n\t\t\t}\n\n\t\t\tnormalsHash[ hash ] = normals.length / 3;\n\t\t\tnormals.push( normal.x, normal.y, normal.z );\n\n\t\t\treturn normalsHash[ hash ];\n\n\t\t}\n\n\t\tfunction getColorIndex( color ) {\n\n\t\t\tconst hash = color.r.toString() + color.g.toString() + color.b.toString();\n\n\t\t\tif ( colorsHash[ hash ] !== undefined ) {\n\n\t\t\t\treturn colorsHash[ hash ];\n\n\t\t\t}\n\n\t\t\tcolorsHash[ hash ] = colors.length;\n\t\t\tcolors.push( color.getHex() );\n\n\t\t\treturn colorsHash[ hash ];\n\n\t\t}\n\n\t\tfunction getUvIndex( uv ) {\n\n\t\t\tconst hash = uv.x.toString() + uv.y.toString();\n\n\t\t\tif ( uvsHash[ hash ] !== undefined ) {\n\n\t\t\t\treturn uvsHash[ hash ];\n\n\t\t\t}\n\n\t\t\tuvsHash[ hash ] = uvs.length / 2;\n\t\t\tuvs.push( uv.x, uv.y );\n\n\t\t\treturn uvsHash[ hash ];\n\n\t\t}\n\n\t\tdata.data = {};\n\n\t\tdata.data.vertices = vertices;\n\t\tdata.data.normals = normals;\n\t\tif ( colors.length > 0 ) data.data.colors = colors;\n\t\tif ( uvs.length > 0 ) data.data.uvs = [ uvs ]; // temporal backward compatibility\n\t\tdata.data.faces = faces;\n\n\t\treturn data;\n\n\t},\n\n\tclone: function () {\n\n\t\t/*\n\t\t // Handle primitives\n\n\t\t const parameters = this.parameters;\n\n\t\t if ( parameters !== undefined ) {\n\n\t\t const values = [];\n\n\t\t for ( const key in parameters ) {\n\n\t\t values.push( parameters[ key ] );\n\n\t\t }\n\n\t\t const geometry = Object.create( this.constructor.prototype );\n\t\t this.constructor.apply( geometry, values );\n\t\t return geometry;\n\n\t\t }\n\n\t\t return new this.constructor().copy( this );\n\t\t */\n\n\t\treturn new Geometry().copy( this );\n\n\t},\n\n\tcopy: function ( source ) {\n\n\t\t// reset\n\n\t\tthis.vertices = [];\n\t\tthis.colors = [];\n\t\tthis.faces = [];\n\t\tthis.faceVertexUvs = [[]];\n\t\tthis.morphTargets = [];\n\t\tthis.morphNormals = [];\n\t\tthis.skinWeights = [];\n\t\tthis.skinIndices = [];\n\t\tthis.lineDistances = [];\n\t\tthis.boundingBox = null;\n\t\tthis.boundingSphere = null;\n\n\t\t// name\n\n\t\tthis.name = source.name;\n\n\t\t// vertices\n\n\t\tconst vertices = source.vertices;\n\n\t\tfor ( let i = 0, il = vertices.length; i < il; i ++ ) {\n\n\t\t\tthis.vertices.push( vertices[ i ].clone() );\n\n\t\t}\n\n\t\t// colors\n\n\t\tconst colors = source.colors;\n\n\t\tfor ( let i = 0, il = colors.length; i < il; i ++ ) {\n\n\t\t\tthis.colors.push( colors[ i ].clone() );\n\n\t\t}\n\n\t\t// faces\n\n\t\tconst faces = source.faces;\n\n\t\tfor ( let i = 0, il = faces.length; i < il; i ++ ) {\n\n\t\t\tthis.faces.push( faces[ i ].clone() );\n\n\t\t}\n\n\t\t// face vertex uvs\n\n\t\tfor ( let i = 0, il = source.faceVertexUvs.length; i < il; i ++ ) {\n\n\t\t\tconst faceVertexUvs = source.faceVertexUvs[ i ];\n\n\t\t\tif ( this.faceVertexUvs[ i ] === undefined ) {\n\n\t\t\t\tthis.faceVertexUvs[ i ] = [];\n\n\t\t\t}\n\n\t\t\tfor ( let j = 0, jl = faceVertexUvs.length; j < jl; j ++ ) {\n\n\t\t\t\tconst uvs = faceVertexUvs[ j ], uvsCopy = [];\n\n\t\t\t\tfor ( let k = 0, kl = uvs.length; k < kl; k ++ ) {\n\n\t\t\t\t\tconst uv = uvs[ k ];\n\n\t\t\t\t\tuvsCopy.push( uv.clone() );\n\n\t\t\t\t}\n\n\t\t\t\tthis.faceVertexUvs[ i ].push( uvsCopy );\n\n\t\t\t}\n\n\t\t}\n\n\t\t// morph targets\n\n\t\tconst morphTargets = source.morphTargets;\n\n\t\tfor ( let i = 0, il = morphTargets.length; i < il; i ++ ) {\n\n\t\t\tconst morphTarget = {};\n\t\t\tmorphTarget.name = morphTargets[ i ].name;\n\n\t\t\t// vertices\n\n\t\t\tif ( morphTargets[ i ].vertices !== undefined ) {\n\n\t\t\t\tmorphTarget.vertices = [];\n\n\t\t\t\tfor ( let j = 0, jl = morphTargets[ i ].vertices.length; j < jl; j ++ ) {\n\n\t\t\t\t\tmorphTarget.vertices.push( morphTargets[ i ].vertices[ j ].clone() );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// normals\n\n\t\t\tif ( morphTargets[ i ].normals !== undefined ) {\n\n\t\t\t\tmorphTarget.normals = [];\n\n\t\t\t\tfor ( let j = 0, jl = morphTargets[ i ].normals.length; j < jl; j ++ ) {\n\n\t\t\t\t\tmorphTarget.normals.push( morphTargets[ i ].normals[ j ].clone() );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tthis.morphTargets.push( morphTarget );\n\n\t\t}\n\n\t\t// morph normals\n\n\t\tconst morphNormals = source.morphNormals;\n\n\t\tfor ( let i = 0, il = morphNormals.length; i < il; i ++ ) {\n\n\t\t\tconst morphNormal = {};\n\n\t\t\t// vertex normals\n\n\t\t\tif ( morphNormals[ i ].vertexNormals !== undefined ) {\n\n\t\t\t\tmorphNormal.vertexNormals = [];\n\n\t\t\t\tfor ( let j = 0, jl = morphNormals[ i ].vertexNormals.length; j < jl; j ++ ) {\n\n\t\t\t\t\tconst srcVertexNormal = morphNormals[ i ].vertexNormals[ j ];\n\t\t\t\t\tconst destVertexNormal = {};\n\n\t\t\t\t\tdestVertexNormal.a = srcVertexNormal.a.clone();\n\t\t\t\t\tdestVertexNormal.b = srcVertexNormal.b.clone();\n\t\t\t\t\tdestVertexNormal.c = srcVertexNormal.c.clone();\n\n\t\t\t\t\tmorphNormal.vertexNormals.push( destVertexNormal );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// face normals\n\n\t\t\tif ( morphNormals[ i ].faceNormals !== undefined ) {\n\n\t\t\t\tmorphNormal.faceNormals = [];\n\n\t\t\t\tfor ( let j = 0, jl = morphNormals[ i ].faceNormals.length; j < jl; j ++ ) {\n\n\t\t\t\t\tmorphNormal.faceNormals.push( morphNormals[ i ].faceNormals[ j ].clone() );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tthis.morphNormals.push( morphNormal );\n\n\t\t}\n\n\t\t// skin weights\n\n\t\tconst skinWeights = source.skinWeights;\n\n\t\tfor ( let i = 0, il = skinWeights.length; i < il; i ++ ) {\n\n\t\t\tthis.skinWeights.push( skinWeights[ i ].clone() );\n\n\t\t}\n\n\t\t// skin indices\n\n\t\tconst skinIndices = source.skinIndices;\n\n\t\tfor ( let i = 0, il = skinIndices.length; i < il; i ++ ) {\n\n\t\t\tthis.skinIndices.push( skinIndices[ i ].clone() );\n\n\t\t}\n\n\t\t// line distances\n\n\t\tconst lineDistances = source.lineDistances;\n\n\t\tfor ( let i = 0, il = lineDistances.length; i < il; i ++ ) {\n\n\t\t\tthis.lineDistances.push( lineDistances[ i ] );\n\n\t\t}\n\n\t\t// bounding box\n\n\t\tconst boundingBox = source.boundingBox;\n\n\t\tif ( boundingBox !== null ) {\n\n\t\t\tthis.boundingBox = boundingBox.clone();\n\n\t\t}\n\n\t\t// bounding sphere\n\n\t\tconst boundingSphere = source.boundingSphere;\n\n\t\tif ( boundingSphere !== null ) {\n\n\t\t\tthis.boundingSphere = boundingSphere.clone();\n\n\t\t}\n\n\t\t// update flags\n\n\t\tthis.elementsNeedUpdate = source.elementsNeedUpdate;\n\t\tthis.verticesNeedUpdate = source.verticesNeedUpdate;\n\t\tthis.uvsNeedUpdate = source.uvsNeedUpdate;\n\t\tthis.normalsNeedUpdate = source.normalsNeedUpdate;\n\t\tthis.colorsNeedUpdate = source.colorsNeedUpdate;\n\t\tthis.lineDistancesNeedUpdate = source.lineDistancesNeedUpdate;\n\t\tthis.groupsNeedUpdate = source.groupsNeedUpdate;\n\n\t\treturn this;\n\n\t},\n\n\tdispose: function () {\n\n\t\tthis.dispatchEvent( { type: 'dispose' } );\n\n\t}\n\n} );\n\n\nexport { Geometry };\n","/**\n * @author mrdoob / http://mrdoob.com/\n * @author Mugen87 / https://github.com/Mugen87\n */\n\nimport { Geometry } from '../core/Geometry.js';\nimport { BufferGeometry } from '../core/BufferGeometry.js';\nimport { Float32BufferAttribute } from '../core/BufferAttribute.js';\nimport { Vector3 } from '../math/Vector3.js';\n\n// BoxGeometry\n\nclass BoxGeometry extends Geometry {\n\n\tconstructor( width, height, depth, widthSegments, heightSegments, depthSegments ) {\n\n\t\tsuper();\n\n\t\tthis.type = 'BoxGeometry';\n\n\t\tthis.parameters = {\n\t\t\twidth: width,\n\t\t\theight: height,\n\t\t\tdepth: depth,\n\t\t\twidthSegments: widthSegments,\n\t\t\theightSegments: heightSegments,\n\t\t\tdepthSegments: depthSegments\n\t\t};\n\n\t\tthis.fromBufferGeometry( new BoxBufferGeometry( width, height, depth, widthSegments, heightSegments, depthSegments ) );\n\t\tthis.mergeVertices();\n\n\t}\n\n}\n\n// BoxBufferGeometry\n\nclass BoxBufferGeometry extends BufferGeometry {\n\n\tconstructor( width, height, depth, widthSegments, heightSegments, depthSegments ) {\n\n\t\tsuper();\n\n\t\tthis.type = 'BoxBufferGeometry';\n\n\t\tthis.parameters = {\n\t\t\twidth: width,\n\t\t\theight: height,\n\t\t\tdepth: depth,\n\t\t\twidthSegments: widthSegments,\n\t\t\theightSegments: heightSegments,\n\t\t\tdepthSegments: depthSegments\n\t\t};\n\n\t\tconst scope = this;\n\n\t\twidth = width || 1;\n\t\theight = height || 1;\n\t\tdepth = depth || 1;\n\n\t\t// segments\n\n\t\twidthSegments = Math.floor( widthSegments ) || 1;\n\t\theightSegments = Math.floor( heightSegments ) || 1;\n\t\tdepthSegments = Math.floor( depthSegments ) || 1;\n\n\t\t// buffers\n\n\t\tconst indices = [];\n\t\tconst vertices = [];\n\t\tconst normals = [];\n\t\tconst uvs = [];\n\n\t\t// helper variables\n\n\t\tlet numberOfVertices = 0;\n\t\tlet groupStart = 0;\n\n\t\t// build each side of the box geometry\n\n\t\tbuildPlane( 'z', 'y', 'x', - 1, - 1, depth, height, width, depthSegments, heightSegments, 0 ); // px\n\t\tbuildPlane( 'z', 'y', 'x', 1, - 1, depth, height, - width, depthSegments, heightSegments, 1 ); // nx\n\t\tbuildPlane( 'x', 'z', 'y', 1, 1, width, depth, height, widthSegments, depthSegments, 2 ); // py\n\t\tbuildPlane( 'x', 'z', 'y', 1, - 1, width, depth, - height, widthSegments, depthSegments, 3 ); // ny\n\t\tbuildPlane( 'x', 'y', 'z', 1, - 1, width, height, depth, widthSegments, heightSegments, 4 ); // pz\n\t\tbuildPlane( 'x', 'y', 'z', - 1, - 1, width, height, - depth, widthSegments, heightSegments, 5 ); // nz\n\n\t\t// build geometry\n\n\t\tthis.setIndex( indices );\n\t\tthis.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );\n\t\tthis.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );\n\t\tthis.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );\n\n\t\tfunction buildPlane( u, v, w, udir, vdir, width, height, depth, gridX, gridY, materialIndex ) {\n\n\t\t\tconst segmentWidth = width / gridX;\n\t\t\tconst segmentHeight = height / gridY;\n\n\t\t\tconst widthHalf = width / 2;\n\t\t\tconst heightHalf = height / 2;\n\t\t\tconst depthHalf = depth / 2;\n\n\t\t\tconst gridX1 = gridX + 1;\n\t\t\tconst gridY1 = gridY + 1;\n\n\t\t\tlet vertexCounter = 0;\n\t\t\tlet groupCount = 0;\n\n\t\t\tconst vector = new Vector3();\n\n\t\t\t// generate vertices, normals and uvs\n\n\t\t\tfor ( let iy = 0; iy < gridY1; iy ++ ) {\n\n\t\t\t\tconst y = iy * segmentHeight - heightHalf;\n\n\t\t\t\tfor ( let ix = 0; ix < gridX1; ix ++ ) {\n\n\t\t\t\t\tconst x = ix * segmentWidth - widthHalf;\n\n\t\t\t\t\t// set values to correct vector component\n\n\t\t\t\t\tvector[ u ] = x * udir;\n\t\t\t\t\tvector[ v ] = y * vdir;\n\t\t\t\t\tvector[ w ] = depthHalf;\n\n\t\t\t\t\t// now apply vector to vertex buffer\n\n\t\t\t\t\tvertices.push( vector.x, vector.y, vector.z );\n\n\t\t\t\t\t// set values to correct vector component\n\n\t\t\t\t\tvector[ u ] = 0;\n\t\t\t\t\tvector[ v ] = 0;\n\t\t\t\t\tvector[ w ] = depth > 0 ? 1 : - 1;\n\n\t\t\t\t\t// now apply vector to normal buffer\n\n\t\t\t\t\tnormals.push( vector.x, vector.y, vector.z );\n\n\t\t\t\t\t// uvs\n\n\t\t\t\t\tuvs.push( ix / gridX );\n\t\t\t\t\tuvs.push( 1 - ( iy / gridY ) );\n\n\t\t\t\t\t// counters\n\n\t\t\t\t\tvertexCounter += 1;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// indices\n\n\t\t\t// 1. you need three indices to draw a single face\n\t\t\t// 2. a single segment consists of two faces\n\t\t\t// 3. so we need to generate six (2*3) indices per segment\n\n\t\t\tfor ( let iy = 0; iy < gridY; iy ++ ) {\n\n\t\t\t\tfor ( let ix = 0; ix < gridX; ix ++ ) {\n\n\t\t\t\t\tconst a = numberOfVertices + ix + gridX1 * iy;\n\t\t\t\t\tconst b = numberOfVertices + ix + gridX1 * ( iy + 1 );\n\t\t\t\t\tconst c = numberOfVertices + ( ix + 1 ) + gridX1 * ( iy + 1 );\n\t\t\t\t\tconst d = numberOfVertices + ( ix + 1 ) + gridX1 * iy;\n\n\t\t\t\t\t// faces\n\n\t\t\t\t\tindices.push( a, b, d );\n\t\t\t\t\tindices.push( b, c, d );\n\n\t\t\t\t\t// increase counter\n\n\t\t\t\t\tgroupCount += 6;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// add a group to the geometry. this will ensure multi material support\n\n\t\t\tscope.addGroup( groupStart, groupCount, materialIndex );\n\n\t\t\t// calculate new start value for groups\n\n\t\t\tgroupStart += groupCount;\n\n\t\t\t// update total number of vertices\n\n\t\t\tnumberOfVertices += vertexCounter;\n\n\t\t}\n\n\t}\n\n}\n\nexport { BoxGeometry, BoxBufferGeometry };\n","/**\n * Uniform Utilities\n */\n\nexport function cloneUniforms( src ) {\n\n\tconst dst = {};\n\n\tfor ( const u in src ) {\n\n\t\tdst[ u ] = {};\n\n\t\tfor ( const p in src[ u ] ) {\n\n\t\t\tconst property = src[ u ][ p ];\n\n\t\t\tif ( property && ( property.isColor ||\n\t\t\t\tproperty.isMatrix3 || property.isMatrix4 ||\n\t\t\t\tproperty.isVector2 || property.isVector3 || property.isVector4 ||\n\t\t\t\tproperty.isTexture ) ) {\n\n\t\t\t\tdst[ u ][ p ] = property.clone();\n\n\t\t\t} else if ( Array.isArray( property ) ) {\n\n\t\t\t\tdst[ u ][ p ] = property.slice();\n\n\t\t\t} else {\n\n\t\t\t\tdst[ u ][ p ] = property;\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\treturn dst;\n\n}\n\nexport function mergeUniforms( uniforms ) {\n\n\tconst merged = {};\n\n\tfor ( let u = 0; u < uniforms.length; u ++ ) {\n\n\t\tconst tmp = cloneUniforms( uniforms[ u ] );\n\n\t\tfor ( const p in tmp ) {\n\n\t\t\tmerged[ p ] = tmp[ p ];\n\n\t\t}\n\n\t}\n\n\treturn merged;\n\n}\n\n// Legacy\n\nconst UniformsUtils = { clone: cloneUniforms, merge: mergeUniforms };\n\nexport { UniformsUtils };\n","export default /* glsl */`\nvoid main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}\n`;\n","export default /* glsl */`\nvoid main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}\n`;\n","/**\n * @author alteredq / http://alteredqualia.com/\n *\n * parameters = {\n * defines: { \"label\" : \"value\" },\n * uniforms: { \"parameter1\": { value: 1.0 }, \"parameter2\": { value2: 2 } },\n *\n * fragmentShader: ,\n * vertexShader: ,\n *\n * wireframe: ,\n * wireframeLinewidth: ,\n *\n * lights: ,\n *\n * skinning: ,\n * morphTargets: ,\n * morphNormals: \n * }\n */\n\nimport { Material } from './Material.js';\nimport { cloneUniforms } from '../renderers/shaders/UniformsUtils.js';\n\nimport default_vertex from '../renderers/shaders/ShaderChunk/default_vertex.glsl.js';\nimport default_fragment from '../renderers/shaders/ShaderChunk/default_fragment.glsl.js';\n\nfunction ShaderMaterial( parameters ) {\n\n\tMaterial.call( this );\n\n\tthis.type = 'ShaderMaterial';\n\n\tthis.defines = {};\n\tthis.uniforms = {};\n\n\tthis.vertexShader = default_vertex;\n\tthis.fragmentShader = default_fragment;\n\n\tthis.linewidth = 1;\n\n\tthis.wireframe = false;\n\tthis.wireframeLinewidth = 1;\n\n\tthis.fog = false; // set to use scene fog\n\tthis.lights = false; // set to use scene lights\n\tthis.clipping = false; // set to use user-defined clipping planes\n\n\tthis.skinning = false; // set to use skinning attribute streams\n\tthis.morphTargets = false; // set to use morph targets\n\tthis.morphNormals = false; // set to use morph normals\n\n\tthis.extensions = {\n\t\tderivatives: false, // set to use derivatives\n\t\tfragDepth: false, // set to use fragment depth values\n\t\tdrawBuffers: false, // set to use draw buffers\n\t\tshaderTextureLOD: false // set to use shader texture LOD\n\t};\n\n\t// When rendered geometry doesn't include these attributes but the material does,\n\t// use these default values in WebGL. This avoids errors when buffer data is missing.\n\tthis.defaultAttributeValues = {\n\t\t'color': [ 1, 1, 1 ],\n\t\t'uv': [ 0, 0 ],\n\t\t'uv2': [ 0, 0 ]\n\t};\n\n\tthis.index0AttributeName = undefined;\n\tthis.uniformsNeedUpdate = false;\n\n\tif ( parameters !== undefined ) {\n\n\t\tif ( parameters.attributes !== undefined ) {\n\n\t\t\tconsole.error( 'THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead.' );\n\n\t\t}\n\n\t\tthis.setValues( parameters );\n\n\t}\n\n}\n\nShaderMaterial.prototype = Object.create( Material.prototype );\nShaderMaterial.prototype.constructor = ShaderMaterial;\n\nShaderMaterial.prototype.isShaderMaterial = true;\n\nShaderMaterial.prototype.copy = function ( source ) {\n\n\tMaterial.prototype.copy.call( this, source );\n\n\tthis.fragmentShader = source.fragmentShader;\n\tthis.vertexShader = source.vertexShader;\n\n\tthis.uniforms = cloneUniforms( source.uniforms );\n\n\tthis.defines = Object.assign( {}, source.defines );\n\n\tthis.wireframe = source.wireframe;\n\tthis.wireframeLinewidth = source.wireframeLinewidth;\n\n\tthis.lights = source.lights;\n\tthis.clipping = source.clipping;\n\n\tthis.skinning = source.skinning;\n\n\tthis.morphTargets = source.morphTargets;\n\tthis.morphNormals = source.morphNormals;\n\n\tthis.extensions = Object.assign( {}, source.extensions );\n\n\treturn this;\n\n};\n\nShaderMaterial.prototype.toJSON = function ( meta ) {\n\n\tconst data = Material.prototype.toJSON.call( this, meta );\n\n\tdata.uniforms = {};\n\n\tfor ( const name in this.uniforms ) {\n\n\t\tconst uniform = this.uniforms[ name ];\n\t\tconst value = uniform.value;\n\n\t\tif ( value && value.isTexture ) {\n\n\t\t\tdata.uniforms[ name ] = {\n\t\t\t\ttype: 't',\n\t\t\t\tvalue: value.toJSON( meta ).uuid\n\t\t\t};\n\n\t\t} else if ( value && value.isColor ) {\n\n\t\t\tdata.uniforms[ name ] = {\n\t\t\t\ttype: 'c',\n\t\t\t\tvalue: value.getHex()\n\t\t\t};\n\n\t\t} else if ( value && value.isVector2 ) {\n\n\t\t\tdata.uniforms[ name ] = {\n\t\t\t\ttype: 'v2',\n\t\t\t\tvalue: value.toArray()\n\t\t\t};\n\n\t\t} else if ( value && value.isVector3 ) {\n\n\t\t\tdata.uniforms[ name ] = {\n\t\t\t\ttype: 'v3',\n\t\t\t\tvalue: value.toArray()\n\t\t\t};\n\n\t\t} else if ( value && value.isVector4 ) {\n\n\t\t\tdata.uniforms[ name ] = {\n\t\t\t\ttype: 'v4',\n\t\t\t\tvalue: value.toArray()\n\t\t\t};\n\n\t\t} else if ( value && value.isMatrix3 ) {\n\n\t\t\tdata.uniforms[ name ] = {\n\t\t\t\ttype: 'm3',\n\t\t\t\tvalue: value.toArray()\n\t\t\t};\n\n\t\t} else if ( value && value.isMatrix4 ) {\n\n\t\t\tdata.uniforms[ name ] = {\n\t\t\t\ttype: 'm4',\n\t\t\t\tvalue: value.toArray()\n\t\t\t};\n\n\t\t} else {\n\n\t\t\tdata.uniforms[ name ] = {\n\t\t\t\tvalue: value\n\t\t\t};\n\n\t\t\t// note: the array variants v2v, v3v, v4v, m4v and tv are not supported so far\n\n\t\t}\n\n\t}\n\n\tif ( Object.keys( this.defines ).length > 0 ) data.defines = this.defines;\n\n\tdata.vertexShader = this.vertexShader;\n\tdata.fragmentShader = this.fragmentShader;\n\n\tconst extensions = {};\n\n\tfor ( const key in this.extensions ) {\n\n\t\tif ( this.extensions[ key ] === true ) extensions[ key ] = true;\n\n\t}\n\n\tif ( Object.keys( extensions ).length > 0 ) data.extensions = extensions;\n\n\treturn data;\n\n};\n\n\nexport { ShaderMaterial };\n","/**\n * @author mrdoob / http://mrdoob.com/\n * @author mikael emtinger / http://gomo.se/\n * @author WestLangley / http://github.com/WestLangley\n*/\n\nimport { Matrix4 } from '../math/Matrix4.js';\nimport { Object3D } from '../core/Object3D.js';\nimport { Vector3 } from '../math/Vector3.js';\n\nfunction Camera() {\n\n\tObject3D.call( this );\n\n\tthis.type = 'Camera';\n\n\tthis.matrixWorldInverse = new Matrix4();\n\n\tthis.projectionMatrix = new Matrix4();\n\tthis.projectionMatrixInverse = new Matrix4();\n\n}\n\nCamera.prototype = Object.assign( Object.create( Object3D.prototype ), {\n\n\tconstructor: Camera,\n\n\tisCamera: true,\n\n\tcopy: function ( source, recursive ) {\n\n\t\tObject3D.prototype.copy.call( this, source, recursive );\n\n\t\tthis.matrixWorldInverse.copy( source.matrixWorldInverse );\n\n\t\tthis.projectionMatrix.copy( source.projectionMatrix );\n\t\tthis.projectionMatrixInverse.copy( source.projectionMatrixInverse );\n\n\t\treturn this;\n\n\t},\n\n\tgetWorldDirection: function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'THREE.Camera: .getWorldDirection() target is now required' );\n\t\t\ttarget = new Vector3();\n\n\t\t}\n\n\t\tthis.updateMatrixWorld( true );\n\n\t\tconst e = this.matrixWorld.elements;\n\n\t\treturn target.set( - e[ 8 ], - e[ 9 ], - e[ 10 ] ).normalize();\n\n\t},\n\n\tupdateMatrixWorld: function ( force ) {\n\n\t\tObject3D.prototype.updateMatrixWorld.call( this, force );\n\n\t\tthis.matrixWorldInverse.getInverse( this.matrixWorld );\n\n\t},\n\n\tupdateWorldMatrix: function ( updateParents, updateChildren ) {\n\n\t\tObject3D.prototype.updateWorldMatrix.call( this, updateParents, updateChildren );\n\n\t\tthis.matrixWorldInverse.getInverse( this.matrixWorld );\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor().copy( this );\n\n\t}\n\n} );\n\nexport { Camera };\n","import { Camera } from './Camera.js';\nimport { Object3D } from '../core/Object3D.js';\nimport { MathUtils } from '../math/MathUtils.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author greggman / http://games.greggman.com/\n * @author zz85 / http://www.lab4games.net/zz85/blog\n * @author tschw\n */\n\nfunction PerspectiveCamera( fov, aspect, near, far ) {\n\n\tCamera.call( this );\n\n\tthis.type = 'PerspectiveCamera';\n\n\tthis.fov = fov !== undefined ? fov : 50;\n\tthis.zoom = 1;\n\n\tthis.near = near !== undefined ? near : 0.1;\n\tthis.far = far !== undefined ? far : 2000;\n\tthis.focus = 10;\n\n\tthis.aspect = aspect !== undefined ? aspect : 1;\n\tthis.view = null;\n\n\tthis.filmGauge = 35;\t// width of the film (default in millimeters)\n\tthis.filmOffset = 0;\t// horizontal film offset (same unit as gauge)\n\n\tthis.updateProjectionMatrix();\n\n}\n\nPerspectiveCamera.prototype = Object.assign( Object.create( Camera.prototype ), {\n\n\tconstructor: PerspectiveCamera,\n\n\tisPerspectiveCamera: true,\n\n\tcopy: function ( source, recursive ) {\n\n\t\tCamera.prototype.copy.call( this, source, recursive );\n\n\t\tthis.fov = source.fov;\n\t\tthis.zoom = source.zoom;\n\n\t\tthis.near = source.near;\n\t\tthis.far = source.far;\n\t\tthis.focus = source.focus;\n\n\t\tthis.aspect = source.aspect;\n\t\tthis.view = source.view === null ? null : Object.assign( {}, source.view );\n\n\t\tthis.filmGauge = source.filmGauge;\n\t\tthis.filmOffset = source.filmOffset;\n\n\t\treturn this;\n\n\t},\n\n\t/**\n\t * Sets the FOV by focal length in respect to the current .filmGauge.\n\t *\n\t * The default film gauge is 35, so that the focal length can be specified for\n\t * a 35mm (full frame) camera.\n\t *\n\t * Values for focal length and film gauge must have the same unit.\n\t */\n\tsetFocalLength: function ( focalLength ) {\n\n\t\t// see http://www.bobatkins.com/photography/technical/field_of_view.html\n\t\tconst vExtentSlope = 0.5 * this.getFilmHeight() / focalLength;\n\n\t\tthis.fov = MathUtils.RAD2DEG * 2 * Math.atan( vExtentSlope );\n\t\tthis.updateProjectionMatrix();\n\n\t},\n\n\t/**\n\t * Calculates the focal length from the current .fov and .filmGauge.\n\t */\n\tgetFocalLength: function () {\n\n\t\tconst vExtentSlope = Math.tan( MathUtils.DEG2RAD * 0.5 * this.fov );\n\n\t\treturn 0.5 * this.getFilmHeight() / vExtentSlope;\n\n\t},\n\n\tgetEffectiveFOV: function () {\n\n\t\treturn MathUtils.RAD2DEG * 2 * Math.atan(\n\t\t\tMath.tan( MathUtils.DEG2RAD * 0.5 * this.fov ) / this.zoom );\n\n\t},\n\n\tgetFilmWidth: function () {\n\n\t\t// film not completely covered in portrait format (aspect < 1)\n\t\treturn this.filmGauge * Math.min( this.aspect, 1 );\n\n\t},\n\n\tgetFilmHeight: function () {\n\n\t\t// film not completely covered in landscape format (aspect > 1)\n\t\treturn this.filmGauge / Math.max( this.aspect, 1 );\n\n\t},\n\n\t/**\n\t * Sets an offset in a larger frustum. This is useful for multi-window or\n\t * multi-monitor/multi-machine setups.\n\t *\n\t * For example, if you have 3x2 monitors and each monitor is 1920x1080 and\n\t * the monitors are in grid like this\n\t *\n\t * +---+---+---+\n\t * | A | B | C |\n\t * +---+---+---+\n\t * | D | E | F |\n\t * +---+---+---+\n\t *\n\t * then for each monitor you would call it like this\n\t *\n\t * const w = 1920;\n\t * const h = 1080;\n\t * const fullWidth = w * 3;\n\t * const fullHeight = h * 2;\n\t *\n\t * --A--\n\t * camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 0, w, h );\n\t * --B--\n\t * camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 0, w, h );\n\t * --C--\n\t * camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 0, w, h );\n\t * --D--\n\t * camera.setViewOffset( fullWidth, fullHeight, w * 0, h * 1, w, h );\n\t * --E--\n\t * camera.setViewOffset( fullWidth, fullHeight, w * 1, h * 1, w, h );\n\t * --F--\n\t * camera.setViewOffset( fullWidth, fullHeight, w * 2, h * 1, w, h );\n\t *\n\t * Note there is no reason monitors have to be the same size or in a grid.\n\t */\n\tsetViewOffset: function ( fullWidth, fullHeight, x, y, width, height ) {\n\n\t\tthis.aspect = fullWidth / fullHeight;\n\n\t\tif ( this.view === null ) {\n\n\t\t\tthis.view = {\n\t\t\t\tenabled: true,\n\t\t\t\tfullWidth: 1,\n\t\t\t\tfullHeight: 1,\n\t\t\t\toffsetX: 0,\n\t\t\t\toffsetY: 0,\n\t\t\t\twidth: 1,\n\t\t\t\theight: 1\n\t\t\t};\n\n\t\t}\n\n\t\tthis.view.enabled = true;\n\t\tthis.view.fullWidth = fullWidth;\n\t\tthis.view.fullHeight = fullHeight;\n\t\tthis.view.offsetX = x;\n\t\tthis.view.offsetY = y;\n\t\tthis.view.width = width;\n\t\tthis.view.height = height;\n\n\t\tthis.updateProjectionMatrix();\n\n\t},\n\n\tclearViewOffset: function () {\n\n\t\tif ( this.view !== null ) {\n\n\t\t\tthis.view.enabled = false;\n\n\t\t}\n\n\t\tthis.updateProjectionMatrix();\n\n\t},\n\n\tupdateProjectionMatrix: function () {\n\n\t\tlet near = this.near,\n\t\t\ttop = near * Math.tan( MathUtils.DEG2RAD * 0.5 * this.fov ) / this.zoom,\n\t\t\theight = 2 * top,\n\t\t\twidth = this.aspect * height,\n\t\t\tleft = - 0.5 * width,\n\t\t\tview = this.view;\n\n\t\tif ( this.view !== null && this.view.enabled ) {\n\n\t\t\tconst fullWidth = view.fullWidth,\n\t\t\t\tfullHeight = view.fullHeight;\n\n\t\t\tleft += view.offsetX * width / fullWidth;\n\t\t\ttop -= view.offsetY * height / fullHeight;\n\t\t\twidth *= view.width / fullWidth;\n\t\t\theight *= view.height / fullHeight;\n\n\t\t}\n\n\t\tconst skew = this.filmOffset;\n\t\tif ( skew !== 0 ) left += near * skew / this.getFilmWidth();\n\n\t\tthis.projectionMatrix.makePerspective( left, left + width, top, top - height, near, this.far );\n\n\t\tthis.projectionMatrixInverse.getInverse( this.projectionMatrix );\n\n\t},\n\n\ttoJSON: function ( meta ) {\n\n\t\tconst data = Object3D.prototype.toJSON.call( this, meta );\n\n\t\tdata.object.fov = this.fov;\n\t\tdata.object.zoom = this.zoom;\n\n\t\tdata.object.near = this.near;\n\t\tdata.object.far = this.far;\n\t\tdata.object.focus = this.focus;\n\n\t\tdata.object.aspect = this.aspect;\n\n\t\tif ( this.view !== null ) data.object.view = Object.assign( {}, this.view );\n\n\t\tdata.object.filmGauge = this.filmGauge;\n\t\tdata.object.filmOffset = this.filmOffset;\n\n\t\treturn data;\n\n\t}\n\n} );\n\n\nexport { PerspectiveCamera };\n","/**\n * @author alteredq / http://alteredqualia.com/\n */\n\nimport { Texture } from './Texture.js';\nimport { NearestFilter } from '../constants.js';\n\nfunction DataTexture( data, width, height, format, type, mapping, wrapS, wrapT, magFilter, minFilter, anisotropy, encoding ) {\n\n\tTexture.call( this, null, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding );\n\n\tthis.image = { data: data || null, width: width || 1, height: height || 1 };\n\n\tthis.magFilter = magFilter !== undefined ? magFilter : NearestFilter;\n\tthis.minFilter = minFilter !== undefined ? minFilter : NearestFilter;\n\n\tthis.generateMipmaps = false;\n\tthis.flipY = false;\n\tthis.unpackAlignment = 1;\n\n\tthis.needsUpdate = true;\n\n}\n\nDataTexture.prototype = Object.create( Texture.prototype );\nDataTexture.prototype.constructor = DataTexture;\n\nDataTexture.prototype.isDataTexture = true;\n\n\nexport { DataTexture };\n","import { Vector3 } from './Vector3.js';\nimport { Sphere } from './Sphere.js';\nimport { Plane } from './Plane.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author alteredq / http://alteredqualia.com/\n * @author bhouston / http://clara.io\n */\n\nconst _sphere = new Sphere();\nconst _vector = new Vector3();\n\nfunction Frustum( p0, p1, p2, p3, p4, p5 ) {\n\n\tthis.planes = [\n\n\t\t( p0 !== undefined ) ? p0 : new Plane(),\n\t\t( p1 !== undefined ) ? p1 : new Plane(),\n\t\t( p2 !== undefined ) ? p2 : new Plane(),\n\t\t( p3 !== undefined ) ? p3 : new Plane(),\n\t\t( p4 !== undefined ) ? p4 : new Plane(),\n\t\t( p5 !== undefined ) ? p5 : new Plane()\n\n\t];\n\n}\n\nObject.assign( Frustum.prototype, {\n\n\tset: function ( p0, p1, p2, p3, p4, p5 ) {\n\n\t\tconst planes = this.planes;\n\n\t\tplanes[ 0 ].copy( p0 );\n\t\tplanes[ 1 ].copy( p1 );\n\t\tplanes[ 2 ].copy( p2 );\n\t\tplanes[ 3 ].copy( p3 );\n\t\tplanes[ 4 ].copy( p4 );\n\t\tplanes[ 5 ].copy( p5 );\n\n\t\treturn this;\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor().copy( this );\n\n\t},\n\n\tcopy: function ( frustum ) {\n\n\t\tconst planes = this.planes;\n\n\t\tfor ( let i = 0; i < 6; i ++ ) {\n\n\t\t\tplanes[ i ].copy( frustum.planes[ i ] );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tsetFromProjectionMatrix: function ( m ) {\n\n\t\tconst planes = this.planes;\n\t\tconst me = m.elements;\n\t\tconst me0 = me[ 0 ], me1 = me[ 1 ], me2 = me[ 2 ], me3 = me[ 3 ];\n\t\tconst me4 = me[ 4 ], me5 = me[ 5 ], me6 = me[ 6 ], me7 = me[ 7 ];\n\t\tconst me8 = me[ 8 ], me9 = me[ 9 ], me10 = me[ 10 ], me11 = me[ 11 ];\n\t\tconst me12 = me[ 12 ], me13 = me[ 13 ], me14 = me[ 14 ], me15 = me[ 15 ];\n\n\t\tplanes[ 0 ].setComponents( me3 - me0, me7 - me4, me11 - me8, me15 - me12 ).normalize();\n\t\tplanes[ 1 ].setComponents( me3 + me0, me7 + me4, me11 + me8, me15 + me12 ).normalize();\n\t\tplanes[ 2 ].setComponents( me3 + me1, me7 + me5, me11 + me9, me15 + me13 ).normalize();\n\t\tplanes[ 3 ].setComponents( me3 - me1, me7 - me5, me11 - me9, me15 - me13 ).normalize();\n\t\tplanes[ 4 ].setComponents( me3 - me2, me7 - me6, me11 - me10, me15 - me14 ).normalize();\n\t\tplanes[ 5 ].setComponents( me3 + me2, me7 + me6, me11 + me10, me15 + me14 ).normalize();\n\n\t\treturn this;\n\n\t},\n\n\tintersectsObject: function ( object ) {\n\n\t\tconst geometry = object.geometry;\n\n\t\tif ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();\n\n\t\t_sphere.copy( geometry.boundingSphere ).applyMatrix4( object.matrixWorld );\n\n\t\treturn this.intersectsSphere( _sphere );\n\n\t},\n\n\tintersectsSprite: function ( sprite ) {\n\n\t\t_sphere.center.set( 0, 0, 0 );\n\t\t_sphere.radius = 0.7071067811865476;\n\t\t_sphere.applyMatrix4( sprite.matrixWorld );\n\n\t\treturn this.intersectsSphere( _sphere );\n\n\t},\n\n\tintersectsSphere: function ( sphere ) {\n\n\t\tconst planes = this.planes;\n\t\tconst center = sphere.center;\n\t\tconst negRadius = - sphere.radius;\n\n\t\tfor ( let i = 0; i < 6; i ++ ) {\n\n\t\t\tconst distance = planes[ i ].distanceToPoint( center );\n\n\t\t\tif ( distance < negRadius ) {\n\n\t\t\t\treturn false;\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn true;\n\n\t},\n\n\tintersectsBox: function ( box ) {\n\n\t\tconst planes = this.planes;\n\n\t\tfor ( let i = 0; i < 6; i ++ ) {\n\n\t\t\tconst plane = planes[ i ];\n\n\t\t\t// corner at max distance\n\n\t\t\t_vector.x = plane.normal.x > 0 ? box.max.x : box.min.x;\n\t\t\t_vector.y = plane.normal.y > 0 ? box.max.y : box.min.y;\n\t\t\t_vector.z = plane.normal.z > 0 ? box.max.z : box.min.z;\n\n\t\t\tif ( plane.distanceToPoint( _vector ) < 0 ) {\n\n\t\t\t\treturn false;\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn true;\n\n\t},\n\n\tcontainsPoint: function ( point ) {\n\n\t\tconst planes = this.planes;\n\n\t\tfor ( let i = 0; i < 6; i ++ ) {\n\n\t\t\tif ( planes[ i ].distanceToPoint( point ) < 0 ) {\n\n\t\t\t\treturn false;\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn true;\n\n\t}\n\n} );\n\n\nexport { Frustum };\n","import { Color } from '../../math/Color.js';\nimport { Vector2 } from '../../math/Vector2.js';\nimport { Matrix3 } from '../../math/Matrix3.js';\n\n/**\n * Uniforms library for shared webgl shaders\n */\n\nconst UniformsLib = {\n\n\tcommon: {\n\n\t\tdiffuse: { value: new Color( 0xeeeeee ) },\n\t\topacity: { value: 1.0 },\n\n\t\tmap: { value: null },\n\t\tuvTransform: { value: new Matrix3() },\n\t\tuv2Transform: { value: new Matrix3() },\n\n\t\talphaMap: { value: null },\n\n\t},\n\n\tspecularmap: {\n\n\t\tspecularMap: { value: null },\n\n\t},\n\n\tenvmap: {\n\n\t\tenvMap: { value: null },\n\t\tflipEnvMap: { value: - 1 },\n\t\treflectivity: { value: 1.0 },\n\t\trefractionRatio: { value: 0.98 },\n\t\tmaxMipLevel: { value: 0 }\n\n\t},\n\n\taomap: {\n\n\t\taoMap: { value: null },\n\t\taoMapIntensity: { value: 1 }\n\n\t},\n\n\tlightmap: {\n\n\t\tlightMap: { value: null },\n\t\tlightMapIntensity: { value: 1 }\n\n\t},\n\n\temissivemap: {\n\n\t\temissiveMap: { value: null }\n\n\t},\n\n\tbumpmap: {\n\n\t\tbumpMap: { value: null },\n\t\tbumpScale: { value: 1 }\n\n\t},\n\n\tnormalmap: {\n\n\t\tnormalMap: { value: null },\n\t\tnormalScale: { value: new Vector2( 1, 1 ) }\n\n\t},\n\n\tdisplacementmap: {\n\n\t\tdisplacementMap: { value: null },\n\t\tdisplacementScale: { value: 1 },\n\t\tdisplacementBias: { value: 0 }\n\n\t},\n\n\troughnessmap: {\n\n\t\troughnessMap: { value: null }\n\n\t},\n\n\tmetalnessmap: {\n\n\t\tmetalnessMap: { value: null }\n\n\t},\n\n\tgradientmap: {\n\n\t\tgradientMap: { value: null }\n\n\t},\n\n\tfog: {\n\n\t\tfogDensity: { value: 0.00025 },\n\t\tfogNear: { value: 1 },\n\t\tfogFar: { value: 2000 },\n\t\tfogColor: { value: new Color( 0xffffff ) }\n\n\t},\n\n\tlights: {\n\n\t\tambientLightColor: { value: [] },\n\n\t\tlightProbe: { value: [] },\n\n\t\tdirectionalLights: { value: [], properties: {\n\t\t\tdirection: {},\n\t\t\tcolor: {}\n\t\t} },\n\n\t\tdirectionalLightShadows: { value: [], properties: {\n\t\t\tshadowBias: {},\n\t\t\tshadowNormalBias: {},\n\t\t\tshadowRadius: {},\n\t\t\tshadowMapSize: {}\n\t\t} },\n\n\t\tdirectionalShadowMap: { value: [] },\n\t\tdirectionalShadowMatrix: { value: [] },\n\n\t\tspotLights: { value: [], properties: {\n\t\t\tcolor: {},\n\t\t\tposition: {},\n\t\t\tdirection: {},\n\t\t\tdistance: {},\n\t\t\tconeCos: {},\n\t\t\tpenumbraCos: {},\n\t\t\tdecay: {}\n\t\t} },\n\n\t\tspotLightShadows: { value: [], properties: {\n\t\t\tshadowBias: {},\n\t\t\tshadowNormalBias: {},\n\t\t\tshadowRadius: {},\n\t\t\tshadowMapSize: {}\n\t\t} },\n\n\t\tspotShadowMap: { value: [] },\n\t\tspotShadowMatrix: { value: [] },\n\n\t\tpointLights: { value: [], properties: {\n\t\t\tcolor: {},\n\t\t\tposition: {},\n\t\t\tdecay: {},\n\t\t\tdistance: {}\n\t\t} },\n\n\t\tpointLightShadows: { value: [], properties: {\n\t\t\tshadowBias: {},\n\t\t\tshadowNormalBias: {},\n\t\t\tshadowRadius: {},\n\t\t\tshadowMapSize: {},\n\t\t\tshadowCameraNear: {},\n\t\t\tshadowCameraFar: {}\n\t\t} },\n\n\t\tpointShadowMap: { value: [] },\n\t\tpointShadowMatrix: { value: [] },\n\n\t\themisphereLights: { value: [], properties: {\n\t\t\tdirection: {},\n\t\t\tskyColor: {},\n\t\t\tgroundColor: {}\n\t\t} },\n\n\t\t// TODO (abelnation): RectAreaLight BRDF data needs to be moved from example to main src\n\t\trectAreaLights: { value: [], properties: {\n\t\t\tcolor: {},\n\t\t\tposition: {},\n\t\t\twidth: {},\n\t\t\theight: {}\n\t\t} }\n\n\t},\n\n\tpoints: {\n\n\t\tdiffuse: { value: new Color( 0xeeeeee ) },\n\t\topacity: { value: 1.0 },\n\t\tsize: { value: 1.0 },\n\t\tscale: { value: 1.0 },\n\t\tmap: { value: null },\n\t\talphaMap: { value: null },\n\t\tuvTransform: { value: new Matrix3() }\n\n\t},\n\n\tsprite: {\n\n\t\tdiffuse: { value: new Color( 0xeeeeee ) },\n\t\topacity: { value: 1.0 },\n\t\tcenter: { value: new Vector2( 0.5, 0.5 ) },\n\t\trotation: { value: 0.0 },\n\t\tmap: { value: null },\n\t\talphaMap: { value: null },\n\t\tuvTransform: { value: new Matrix3() }\n\n\t}\n\n};\n\nexport { UniformsLib };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction WebGLAnimation() {\n\n\tlet context = null;\n\tlet isAnimating = false;\n\tlet animationLoop = null;\n\tlet requestId = null;\n\n\tfunction onAnimationFrame( time, frame ) {\n\n\t\tanimationLoop( time, frame );\n\n\t\trequestId = context.requestAnimationFrame( onAnimationFrame );\n\n\t}\n\n\treturn {\n\n\t\tstart: function () {\n\n\t\t\tif ( isAnimating === true ) return;\n\t\t\tif ( animationLoop === null ) return;\n\n\t\t\trequestId = context.requestAnimationFrame( onAnimationFrame );\n\n\t\t\tisAnimating = true;\n\n\t\t},\n\n\t\tstop: function () {\n\n\t\t\tcontext.cancelAnimationFrame( requestId );\n\n\t\t\tisAnimating = false;\n\n\t\t},\n\n\t\tsetAnimationLoop: function ( callback ) {\n\n\t\t\tanimationLoop = callback;\n\n\t\t},\n\n\t\tsetContext: function ( value ) {\n\n\t\t\tcontext = value;\n\n\t\t}\n\n\t};\n\n}\n\nexport { WebGLAnimation };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction WebGLAttributes( gl, capabilities ) {\n\n\tconst isWebGL2 = capabilities.isWebGL2;\n\n\tconst buffers = new WeakMap();\n\n\tfunction createBuffer( attribute, bufferType ) {\n\n\t\tconst array = attribute.array;\n\t\tconst usage = attribute.usage;\n\n\t\tconst buffer = gl.createBuffer();\n\n\t\tgl.bindBuffer( bufferType, buffer );\n\t\tgl.bufferData( bufferType, array, usage );\n\n\t\tattribute.onUploadCallback();\n\n\t\tlet type = gl.FLOAT;\n\n\t\tif ( array instanceof Float32Array ) {\n\n\t\t\ttype = gl.FLOAT;\n\n\t\t} else if ( array instanceof Float64Array ) {\n\n\t\t\tconsole.warn( 'THREE.WebGLAttributes: Unsupported data buffer format: Float64Array.' );\n\n\t\t} else if ( array instanceof Uint16Array ) {\n\n\t\t\ttype = gl.UNSIGNED_SHORT;\n\n\t\t} else if ( array instanceof Int16Array ) {\n\n\t\t\ttype = gl.SHORT;\n\n\t\t} else if ( array instanceof Uint32Array ) {\n\n\t\t\ttype = gl.UNSIGNED_INT;\n\n\t\t} else if ( array instanceof Int32Array ) {\n\n\t\t\ttype = gl.INT;\n\n\t\t} else if ( array instanceof Int8Array ) {\n\n\t\t\ttype = gl.BYTE;\n\n\t\t} else if ( array instanceof Uint8Array ) {\n\n\t\t\ttype = gl.UNSIGNED_BYTE;\n\n\t\t}\n\n\t\treturn {\n\t\t\tbuffer: buffer,\n\t\t\ttype: type,\n\t\t\tbytesPerElement: array.BYTES_PER_ELEMENT,\n\t\t\tversion: attribute.version\n\t\t};\n\n\t}\n\n\tfunction updateBuffer( buffer, attribute, bufferType ) {\n\n\t\tconst array = attribute.array;\n\t\tconst updateRange = attribute.updateRange;\n\n\t\tgl.bindBuffer( bufferType, buffer );\n\n\t\tif ( updateRange.count === - 1 ) {\n\n\t\t\t// Not using update ranges\n\n\t\t\tgl.bufferSubData( bufferType, 0, array );\n\n\t\t} else {\n\n\t\t\tif ( isWebGL2 ) {\n\n\t\t\t\tgl.bufferSubData( bufferType, updateRange.offset * array.BYTES_PER_ELEMENT,\n\t\t\t\t\tarray, updateRange.offset, updateRange.count );\n\n\t\t\t} else {\n\n\t\t\t\tgl.bufferSubData( bufferType, updateRange.offset * array.BYTES_PER_ELEMENT,\n\t\t\t\t\tarray.subarray( updateRange.offset, updateRange.offset + updateRange.count ) );\n\n\t\t\t}\n\n\t\t\tupdateRange.count = - 1; // reset range\n\n\t\t}\n\n\t}\n\n\t//\n\n\tfunction get( attribute ) {\n\n\t\tif ( attribute.isInterleavedBufferAttribute ) attribute = attribute.data;\n\n\t\treturn buffers.get( attribute );\n\n\t}\n\n\tfunction remove( attribute ) {\n\n\t\tif ( attribute.isInterleavedBufferAttribute ) attribute = attribute.data;\n\n\t\tconst data = buffers.get( attribute );\n\n\t\tif ( data ) {\n\n\t\t\tgl.deleteBuffer( data.buffer );\n\n\t\t\tbuffers.delete( attribute );\n\n\t\t}\n\n\t}\n\n\tfunction update( attribute, bufferType ) {\n\n\t\tif ( attribute.isInterleavedBufferAttribute ) attribute = attribute.data;\n\n\t\tconst data = buffers.get( attribute );\n\n\t\tif ( data === undefined ) {\n\n\t\t\tbuffers.set( attribute, createBuffer( attribute, bufferType ) );\n\n\t\t} else if ( data.version < attribute.version ) {\n\n\t\t\tupdateBuffer( data.buffer, attribute, bufferType );\n\n\t\t\tdata.version = attribute.version;\n\n\t\t}\n\n\t}\n\n\treturn {\n\n\t\tget: get,\n\t\tremove: remove,\n\t\tupdate: update\n\n\t};\n\n}\n\n\nexport { WebGLAttributes };\n","/**\n * @author mrdoob / http://mrdoob.com/\n * @author Mugen87 / https://github.com/Mugen87\n */\n\nimport { Geometry } from '../core/Geometry.js';\nimport { BufferGeometry } from '../core/BufferGeometry.js';\nimport { Float32BufferAttribute } from '../core/BufferAttribute.js';\n\n// PlaneGeometry\n\nfunction PlaneGeometry( width, height, widthSegments, heightSegments ) {\n\n\tGeometry.call( this );\n\n\tthis.type = 'PlaneGeometry';\n\n\tthis.parameters = {\n\t\twidth: width,\n\t\theight: height,\n\t\twidthSegments: widthSegments,\n\t\theightSegments: heightSegments\n\t};\n\n\tthis.fromBufferGeometry( new PlaneBufferGeometry( width, height, widthSegments, heightSegments ) );\n\tthis.mergeVertices();\n\n}\n\nPlaneGeometry.prototype = Object.create( Geometry.prototype );\nPlaneGeometry.prototype.constructor = PlaneGeometry;\n\n// PlaneBufferGeometry\n\nfunction PlaneBufferGeometry( width, height, widthSegments, heightSegments ) {\n\n\tBufferGeometry.call( this );\n\n\tthis.type = 'PlaneBufferGeometry';\n\n\tthis.parameters = {\n\t\twidth: width,\n\t\theight: height,\n\t\twidthSegments: widthSegments,\n\t\theightSegments: heightSegments\n\t};\n\n\twidth = width || 1;\n\theight = height || 1;\n\n\tconst width_half = width / 2;\n\tconst height_half = height / 2;\n\n\tconst gridX = Math.floor( widthSegments ) || 1;\n\tconst gridY = Math.floor( heightSegments ) || 1;\n\n\tconst gridX1 = gridX + 1;\n\tconst gridY1 = gridY + 1;\n\n\tconst segment_width = width / gridX;\n\tconst segment_height = height / gridY;\n\n\t// buffers\n\n\tconst indices = [];\n\tconst vertices = [];\n\tconst normals = [];\n\tconst uvs = [];\n\n\t// generate vertices, normals and uvs\n\n\tfor ( let iy = 0; iy < gridY1; iy ++ ) {\n\n\t\tconst y = iy * segment_height - height_half;\n\n\t\tfor ( let ix = 0; ix < gridX1; ix ++ ) {\n\n\t\t\tconst x = ix * segment_width - width_half;\n\n\t\t\tvertices.push( x, - y, 0 );\n\n\t\t\tnormals.push( 0, 0, 1 );\n\n\t\t\tuvs.push( ix / gridX );\n\t\t\tuvs.push( 1 - ( iy / gridY ) );\n\n\t\t}\n\n\t}\n\n\t// indices\n\n\tfor ( let iy = 0; iy < gridY; iy ++ ) {\n\n\t\tfor ( let ix = 0; ix < gridX; ix ++ ) {\n\n\t\t\tconst a = ix + gridX1 * iy;\n\t\t\tconst b = ix + gridX1 * ( iy + 1 );\n\t\t\tconst c = ( ix + 1 ) + gridX1 * ( iy + 1 );\n\t\t\tconst d = ( ix + 1 ) + gridX1 * iy;\n\n\t\t\t// faces\n\n\t\t\tindices.push( a, b, d );\n\t\t\tindices.push( b, c, d );\n\n\t\t}\n\n\t}\n\n\t// build geometry\n\n\tthis.setIndex( indices );\n\tthis.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );\n\tthis.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );\n\tthis.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );\n\n}\n\nPlaneBufferGeometry.prototype = Object.create( BufferGeometry.prototype );\nPlaneBufferGeometry.prototype.constructor = PlaneBufferGeometry;\n\n\nexport { PlaneGeometry, PlaneBufferGeometry };\n","import alphamap_fragment from './ShaderChunk/alphamap_fragment.glsl.js';\nimport alphamap_pars_fragment from './ShaderChunk/alphamap_pars_fragment.glsl.js';\nimport alphatest_fragment from './ShaderChunk/alphatest_fragment.glsl.js';\nimport aomap_fragment from './ShaderChunk/aomap_fragment.glsl.js';\nimport aomap_pars_fragment from './ShaderChunk/aomap_pars_fragment.glsl.js';\nimport begin_vertex from './ShaderChunk/begin_vertex.glsl.js';\nimport beginnormal_vertex from './ShaderChunk/beginnormal_vertex.glsl.js';\nimport bsdfs from './ShaderChunk/bsdfs.glsl.js';\nimport bumpmap_pars_fragment from './ShaderChunk/bumpmap_pars_fragment.glsl.js';\nimport clipping_planes_fragment from './ShaderChunk/clipping_planes_fragment.glsl.js';\nimport clipping_planes_pars_fragment from './ShaderChunk/clipping_planes_pars_fragment.glsl.js';\nimport clipping_planes_pars_vertex from './ShaderChunk/clipping_planes_pars_vertex.glsl.js';\nimport clipping_planes_vertex from './ShaderChunk/clipping_planes_vertex.glsl.js';\nimport color_fragment from './ShaderChunk/color_fragment.glsl.js';\nimport color_pars_fragment from './ShaderChunk/color_pars_fragment.glsl.js';\nimport color_pars_vertex from './ShaderChunk/color_pars_vertex.glsl.js';\nimport color_vertex from './ShaderChunk/color_vertex.glsl.js';\nimport common from './ShaderChunk/common.glsl.js';\nimport cube_uv_reflection_fragment from './ShaderChunk/cube_uv_reflection_fragment.glsl.js';\nimport defaultnormal_vertex from './ShaderChunk/defaultnormal_vertex.glsl.js';\nimport displacementmap_pars_vertex from './ShaderChunk/displacementmap_pars_vertex.glsl.js';\nimport displacementmap_vertex from './ShaderChunk/displacementmap_vertex.glsl.js';\nimport emissivemap_fragment from './ShaderChunk/emissivemap_fragment.glsl.js';\nimport emissivemap_pars_fragment from './ShaderChunk/emissivemap_pars_fragment.glsl.js';\nimport encodings_fragment from './ShaderChunk/encodings_fragment.glsl.js';\nimport encodings_pars_fragment from './ShaderChunk/encodings_pars_fragment.glsl.js';\nimport envmap_fragment from './ShaderChunk/envmap_fragment.glsl.js';\nimport envmap_common_pars_fragment from './ShaderChunk/envmap_common_pars_fragment.glsl.js';\nimport envmap_pars_fragment from './ShaderChunk/envmap_pars_fragment.glsl.js';\nimport envmap_pars_vertex from './ShaderChunk/envmap_pars_vertex.glsl.js';\nimport envmap_vertex from './ShaderChunk/envmap_vertex.glsl.js';\nimport fog_vertex from './ShaderChunk/fog_vertex.glsl.js';\nimport fog_pars_vertex from './ShaderChunk/fog_pars_vertex.glsl.js';\nimport fog_fragment from './ShaderChunk/fog_fragment.glsl.js';\nimport fog_pars_fragment from './ShaderChunk/fog_pars_fragment.glsl.js';\nimport gradientmap_pars_fragment from './ShaderChunk/gradientmap_pars_fragment.glsl.js';\nimport lightmap_fragment from './ShaderChunk/lightmap_fragment.glsl.js';\nimport lightmap_pars_fragment from './ShaderChunk/lightmap_pars_fragment.glsl.js';\nimport lights_lambert_vertex from './ShaderChunk/lights_lambert_vertex.glsl.js';\nimport lights_pars_begin from './ShaderChunk/lights_pars_begin.glsl.js';\nimport envmap_physical_pars_fragment from './ShaderChunk/envmap_physical_pars_fragment.glsl.js';\nimport lights_toon_fragment from './ShaderChunk/lights_toon_fragment.glsl.js';\nimport lights_toon_pars_fragment from './ShaderChunk/lights_toon_pars_fragment.glsl.js';\nimport lights_phong_fragment from './ShaderChunk/lights_phong_fragment.glsl.js';\nimport lights_phong_pars_fragment from './ShaderChunk/lights_phong_pars_fragment.glsl.js';\nimport lights_physical_fragment from './ShaderChunk/lights_physical_fragment.glsl.js';\nimport lights_physical_pars_fragment from './ShaderChunk/lights_physical_pars_fragment.glsl.js';\nimport lights_fragment_begin from './ShaderChunk/lights_fragment_begin.glsl.js';\nimport lights_fragment_maps from './ShaderChunk/lights_fragment_maps.glsl.js';\nimport lights_fragment_end from './ShaderChunk/lights_fragment_end.glsl.js';\nimport logdepthbuf_fragment from './ShaderChunk/logdepthbuf_fragment.glsl.js';\nimport logdepthbuf_pars_fragment from './ShaderChunk/logdepthbuf_pars_fragment.glsl.js';\nimport logdepthbuf_pars_vertex from './ShaderChunk/logdepthbuf_pars_vertex.glsl.js';\nimport logdepthbuf_vertex from './ShaderChunk/logdepthbuf_vertex.glsl.js';\nimport map_fragment from './ShaderChunk/map_fragment.glsl.js';\nimport map_pars_fragment from './ShaderChunk/map_pars_fragment.glsl.js';\nimport map_particle_fragment from './ShaderChunk/map_particle_fragment.glsl.js';\nimport map_particle_pars_fragment from './ShaderChunk/map_particle_pars_fragment.glsl.js';\nimport metalnessmap_fragment from './ShaderChunk/metalnessmap_fragment.glsl.js';\nimport metalnessmap_pars_fragment from './ShaderChunk/metalnessmap_pars_fragment.glsl.js';\nimport morphnormal_vertex from './ShaderChunk/morphnormal_vertex.glsl.js';\nimport morphtarget_pars_vertex from './ShaderChunk/morphtarget_pars_vertex.glsl.js';\nimport morphtarget_vertex from './ShaderChunk/morphtarget_vertex.glsl.js';\nimport normal_fragment_begin from './ShaderChunk/normal_fragment_begin.glsl.js';\nimport normal_fragment_maps from './ShaderChunk/normal_fragment_maps.glsl.js';\nimport normalmap_pars_fragment from './ShaderChunk/normalmap_pars_fragment.glsl.js';\nimport clearcoat_normal_fragment_begin from './ShaderChunk/clearcoat_normal_fragment_begin.glsl.js';\nimport clearcoat_normal_fragment_maps from './ShaderChunk/clearcoat_normal_fragment_maps.glsl.js';\nimport clearcoat_pars_fragment from './ShaderChunk/clearcoat_pars_fragment.glsl.js';\nimport packing from './ShaderChunk/packing.glsl.js';\nimport premultiplied_alpha_fragment from './ShaderChunk/premultiplied_alpha_fragment.glsl.js';\nimport project_vertex from './ShaderChunk/project_vertex.glsl.js';\nimport dithering_fragment from './ShaderChunk/dithering_fragment.glsl.js';\nimport dithering_pars_fragment from './ShaderChunk/dithering_pars_fragment.glsl.js';\nimport roughnessmap_fragment from './ShaderChunk/roughnessmap_fragment.glsl.js';\nimport roughnessmap_pars_fragment from './ShaderChunk/roughnessmap_pars_fragment.glsl.js';\nimport shadowmap_pars_fragment from './ShaderChunk/shadowmap_pars_fragment.glsl.js';\nimport shadowmap_pars_vertex from './ShaderChunk/shadowmap_pars_vertex.glsl.js';\nimport shadowmap_vertex from './ShaderChunk/shadowmap_vertex.glsl.js';\nimport shadowmask_pars_fragment from './ShaderChunk/shadowmask_pars_fragment.glsl.js';\nimport skinbase_vertex from './ShaderChunk/skinbase_vertex.glsl.js';\nimport skinning_pars_vertex from './ShaderChunk/skinning_pars_vertex.glsl.js';\nimport skinning_vertex from './ShaderChunk/skinning_vertex.glsl.js';\nimport skinnormal_vertex from './ShaderChunk/skinnormal_vertex.glsl.js';\nimport specularmap_fragment from './ShaderChunk/specularmap_fragment.glsl.js';\nimport specularmap_pars_fragment from './ShaderChunk/specularmap_pars_fragment.glsl.js';\nimport tonemapping_fragment from './ShaderChunk/tonemapping_fragment.glsl.js';\nimport tonemapping_pars_fragment from './ShaderChunk/tonemapping_pars_fragment.glsl.js';\nimport uv_pars_fragment from './ShaderChunk/uv_pars_fragment.glsl.js';\nimport uv_pars_vertex from './ShaderChunk/uv_pars_vertex.glsl.js';\nimport uv_vertex from './ShaderChunk/uv_vertex.glsl.js';\nimport uv2_pars_fragment from './ShaderChunk/uv2_pars_fragment.glsl.js';\nimport uv2_pars_vertex from './ShaderChunk/uv2_pars_vertex.glsl.js';\nimport uv2_vertex from './ShaderChunk/uv2_vertex.glsl.js';\nimport worldpos_vertex from './ShaderChunk/worldpos_vertex.glsl.js';\n\nimport background_frag from './ShaderLib/background_frag.glsl.js';\nimport background_vert from './ShaderLib/background_vert.glsl.js';\nimport cube_frag from './ShaderLib/cube_frag.glsl.js';\nimport cube_vert from './ShaderLib/cube_vert.glsl.js';\nimport depth_frag from './ShaderLib/depth_frag.glsl.js';\nimport depth_vert from './ShaderLib/depth_vert.glsl.js';\nimport distanceRGBA_frag from './ShaderLib/distanceRGBA_frag.glsl.js';\nimport distanceRGBA_vert from './ShaderLib/distanceRGBA_vert.glsl.js';\nimport equirect_frag from './ShaderLib/equirect_frag.glsl.js';\nimport equirect_vert from './ShaderLib/equirect_vert.glsl.js';\nimport linedashed_frag from './ShaderLib/linedashed_frag.glsl.js';\nimport linedashed_vert from './ShaderLib/linedashed_vert.glsl.js';\nimport meshbasic_frag from './ShaderLib/meshbasic_frag.glsl.js';\nimport meshbasic_vert from './ShaderLib/meshbasic_vert.glsl.js';\nimport meshlambert_frag from './ShaderLib/meshlambert_frag.glsl.js';\nimport meshlambert_vert from './ShaderLib/meshlambert_vert.glsl.js';\nimport meshmatcap_frag from './ShaderLib/meshmatcap_frag.glsl.js';\nimport meshmatcap_vert from './ShaderLib/meshmatcap_vert.glsl.js';\nimport meshtoon_frag from './ShaderLib/meshtoon_frag.glsl.js';\nimport meshtoon_vert from './ShaderLib/meshtoon_vert.glsl.js';\nimport meshphong_frag from './ShaderLib/meshphong_frag.glsl.js';\nimport meshphong_vert from './ShaderLib/meshphong_vert.glsl.js';\nimport meshphysical_frag from './ShaderLib/meshphysical_frag.glsl.js';\nimport meshphysical_vert from './ShaderLib/meshphysical_vert.glsl.js';\nimport normal_frag from './ShaderLib/normal_frag.glsl.js';\nimport normal_vert from './ShaderLib/normal_vert.glsl.js';\nimport points_frag from './ShaderLib/points_frag.glsl.js';\nimport points_vert from './ShaderLib/points_vert.glsl.js';\nimport shadow_frag from './ShaderLib/shadow_frag.glsl.js';\nimport shadow_vert from './ShaderLib/shadow_vert.glsl.js';\nimport sprite_frag from './ShaderLib/sprite_frag.glsl.js';\nimport sprite_vert from './ShaderLib/sprite_vert.glsl.js';\n\nexport const ShaderChunk = {\n\talphamap_fragment: alphamap_fragment,\n\talphamap_pars_fragment: alphamap_pars_fragment,\n\talphatest_fragment: alphatest_fragment,\n\taomap_fragment: aomap_fragment,\n\taomap_pars_fragment: aomap_pars_fragment,\n\tbegin_vertex: begin_vertex,\n\tbeginnormal_vertex: beginnormal_vertex,\n\tbsdfs: bsdfs,\n\tbumpmap_pars_fragment: bumpmap_pars_fragment,\n\tclipping_planes_fragment: clipping_planes_fragment,\n\tclipping_planes_pars_fragment: clipping_planes_pars_fragment,\n\tclipping_planes_pars_vertex: clipping_planes_pars_vertex,\n\tclipping_planes_vertex: clipping_planes_vertex,\n\tcolor_fragment: color_fragment,\n\tcolor_pars_fragment: color_pars_fragment,\n\tcolor_pars_vertex: color_pars_vertex,\n\tcolor_vertex: color_vertex,\n\tcommon: common,\n\tcube_uv_reflection_fragment: cube_uv_reflection_fragment,\n\tdefaultnormal_vertex: defaultnormal_vertex,\n\tdisplacementmap_pars_vertex: displacementmap_pars_vertex,\n\tdisplacementmap_vertex: displacementmap_vertex,\n\temissivemap_fragment: emissivemap_fragment,\n\temissivemap_pars_fragment: emissivemap_pars_fragment,\n\tencodings_fragment: encodings_fragment,\n\tencodings_pars_fragment: encodings_pars_fragment,\n\tenvmap_fragment: envmap_fragment,\n\tenvmap_common_pars_fragment: envmap_common_pars_fragment,\n\tenvmap_pars_fragment: envmap_pars_fragment,\n\tenvmap_pars_vertex: envmap_pars_vertex,\n\tenvmap_physical_pars_fragment: envmap_physical_pars_fragment,\n\tenvmap_vertex: envmap_vertex,\n\tfog_vertex: fog_vertex,\n\tfog_pars_vertex: fog_pars_vertex,\n\tfog_fragment: fog_fragment,\n\tfog_pars_fragment: fog_pars_fragment,\n\tgradientmap_pars_fragment: gradientmap_pars_fragment,\n\tlightmap_fragment: lightmap_fragment,\n\tlightmap_pars_fragment: lightmap_pars_fragment,\n\tlights_lambert_vertex: lights_lambert_vertex,\n\tlights_pars_begin: lights_pars_begin,\n\tlights_toon_fragment: lights_toon_fragment,\n\tlights_toon_pars_fragment: lights_toon_pars_fragment,\n\tlights_phong_fragment: lights_phong_fragment,\n\tlights_phong_pars_fragment: lights_phong_pars_fragment,\n\tlights_physical_fragment: lights_physical_fragment,\n\tlights_physical_pars_fragment: lights_physical_pars_fragment,\n\tlights_fragment_begin: lights_fragment_begin,\n\tlights_fragment_maps: lights_fragment_maps,\n\tlights_fragment_end: lights_fragment_end,\n\tlogdepthbuf_fragment: logdepthbuf_fragment,\n\tlogdepthbuf_pars_fragment: logdepthbuf_pars_fragment,\n\tlogdepthbuf_pars_vertex: logdepthbuf_pars_vertex,\n\tlogdepthbuf_vertex: logdepthbuf_vertex,\n\tmap_fragment: map_fragment,\n\tmap_pars_fragment: map_pars_fragment,\n\tmap_particle_fragment: map_particle_fragment,\n\tmap_particle_pars_fragment: map_particle_pars_fragment,\n\tmetalnessmap_fragment: metalnessmap_fragment,\n\tmetalnessmap_pars_fragment: metalnessmap_pars_fragment,\n\tmorphnormal_vertex: morphnormal_vertex,\n\tmorphtarget_pars_vertex: morphtarget_pars_vertex,\n\tmorphtarget_vertex: morphtarget_vertex,\n\tnormal_fragment_begin: normal_fragment_begin,\n\tnormal_fragment_maps: normal_fragment_maps,\n\tnormalmap_pars_fragment: normalmap_pars_fragment,\n\tclearcoat_normal_fragment_begin: clearcoat_normal_fragment_begin,\n\tclearcoat_normal_fragment_maps: clearcoat_normal_fragment_maps,\n\tclearcoat_pars_fragment: clearcoat_pars_fragment,\n\tpacking: packing,\n\tpremultiplied_alpha_fragment: premultiplied_alpha_fragment,\n\tproject_vertex: project_vertex,\n\tdithering_fragment: dithering_fragment,\n\tdithering_pars_fragment: dithering_pars_fragment,\n\troughnessmap_fragment: roughnessmap_fragment,\n\troughnessmap_pars_fragment: roughnessmap_pars_fragment,\n\tshadowmap_pars_fragment: shadowmap_pars_fragment,\n\tshadowmap_pars_vertex: shadowmap_pars_vertex,\n\tshadowmap_vertex: shadowmap_vertex,\n\tshadowmask_pars_fragment: shadowmask_pars_fragment,\n\tskinbase_vertex: skinbase_vertex,\n\tskinning_pars_vertex: skinning_pars_vertex,\n\tskinning_vertex: skinning_vertex,\n\tskinnormal_vertex: skinnormal_vertex,\n\tspecularmap_fragment: specularmap_fragment,\n\tspecularmap_pars_fragment: specularmap_pars_fragment,\n\ttonemapping_fragment: tonemapping_fragment,\n\ttonemapping_pars_fragment: tonemapping_pars_fragment,\n\tuv_pars_fragment: uv_pars_fragment,\n\tuv_pars_vertex: uv_pars_vertex,\n\tuv_vertex: uv_vertex,\n\tuv2_pars_fragment: uv2_pars_fragment,\n\tuv2_pars_vertex: uv2_pars_vertex,\n\tuv2_vertex: uv2_vertex,\n\tworldpos_vertex: worldpos_vertex,\n\n\tbackground_frag: background_frag,\n\tbackground_vert: background_vert,\n\tcube_frag: cube_frag,\n\tcube_vert: cube_vert,\n\tdepth_frag: depth_frag,\n\tdepth_vert: depth_vert,\n\tdistanceRGBA_frag: distanceRGBA_frag,\n\tdistanceRGBA_vert: distanceRGBA_vert,\n\tequirect_frag: equirect_frag,\n\tequirect_vert: equirect_vert,\n\tlinedashed_frag: linedashed_frag,\n\tlinedashed_vert: linedashed_vert,\n\tmeshbasic_frag: meshbasic_frag,\n\tmeshbasic_vert: meshbasic_vert,\n\tmeshlambert_frag: meshlambert_frag,\n\tmeshlambert_vert: meshlambert_vert,\n\tmeshmatcap_frag: meshmatcap_frag,\n\tmeshmatcap_vert: meshmatcap_vert,\n\tmeshtoon_frag: meshtoon_frag,\n\tmeshtoon_vert: meshtoon_vert,\n\tmeshphong_frag: meshphong_frag,\n\tmeshphong_vert: meshphong_vert,\n\tmeshphysical_frag: meshphysical_frag,\n\tmeshphysical_vert: meshphysical_vert,\n\tnormal_frag: normal_frag,\n\tnormal_vert: normal_vert,\n\tpoints_frag: points_frag,\n\tpoints_vert: points_vert,\n\tshadow_frag: shadow_frag,\n\tshadow_vert: shadow_vert,\n\tsprite_frag: sprite_frag,\n\tsprite_vert: sprite_vert\n};\n","export default /* glsl */`\n#ifdef USE_ALPHAMAP\n\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_ALPHAMAP\n\n\tuniform sampler2D alphaMap;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef ALPHATEST\n\n\tif ( diffuseColor.a < ALPHATEST ) discard;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_AOMAP\n\n\t// reads channel R, compatible with a combined OcclusionRoughnessMetallic (RGB) texture\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\n\t#if defined( USE_ENVMAP ) && defined( STANDARD )\n\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_AOMAP\n\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n\n#endif\n`;\n","export default /* glsl */`\nvec3 transformed = vec3( position );\n`;\n","export default /* glsl */`\nvec3 objectNormal = vec3( normal );\n\n#ifdef USE_TANGENT\n\n\tvec3 objectTangent = vec3( tangent.xyz );\n\n#endif\n`;\n","export default /* glsl */`\n\n// Analytical approximation of the DFG LUT, one half of the\n// split-sum approximation used in indirect specular lighting.\n// via 'environmentBRDF' from \"Physically Based Shading on Mobile\"\n// https://www.unrealengine.com/blog/physically-based-shading-on-mobile - environmentBRDF for GGX on mobile\nvec2 integrateSpecularBRDF( const in float dotNV, const in float roughness ) {\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\n\tvec4 r = roughness * c0 + c1;\n\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\n\treturn vec2( -1.04, 1.04 ) * a004 + r.zw;\n\n}\n\nfloat punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\n\t// based upon Frostbite 3 Moving to Physically-based Rendering\n\t// page 32, equation 26: E[window1]\n\t// https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf\n\t// this is intended to be used on spot and point lights who are represented as luminous intensity\n\t// but who must be converted to luminous irradiance for surface lighting calculation\n\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\n\tif( cutoffDistance > 0.0 ) {\n\n\t\tdistanceFalloff *= pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\n\t}\n\n\treturn distanceFalloff;\n\n#else\n\n\tif( cutoffDistance > 0.0 && decayExponent > 0.0 ) {\n\n\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n\n\t}\n\n\treturn 1.0;\n\n#endif\n\n}\n\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\n\treturn RECIPROCAL_PI * diffuseColor;\n\n} // validated\n\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\n\t// Original approximation by Christophe Schlick '94\n\t// float fresnel = pow( 1.0 - dotLH, 5.0 );\n\n\t// Optimized variant (presented by Epic at SIGGRAPH '13)\n\t// https://cdn2.unrealengine.com/Resources/files/2013SiggraphPresentationsNotes-26915738.pdf\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n\n} // validated\n\nvec3 F_Schlick_RoughnessDependent( const in vec3 F0, const in float dotNV, const in float roughness ) {\n\n\t// See F_Schlick\n\tfloat fresnel = exp2( ( -5.55473 * dotNV - 6.98316 ) * dotNV );\n\tvec3 Fr = max( vec3( 1.0 - roughness ), F0 ) - F0;\n\n\treturn Fr * fresnel + F0;\n\n}\n\n\n// Microfacet Models for Refraction through Rough Surfaces - equation (34)\n// http://graphicrants.blogspot.com/2013/08/specular-brdf-reference.html\n// alpha is \"roughness squared\" in Disney’s reparameterization\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\n\t// geometry term (normalized) = G(l)⋅G(v) / 4(n⋅l)(n⋅v)\n\t// also see #12151\n\n\tfloat a2 = pow2( alpha );\n\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\n\treturn 1.0 / ( gl * gv );\n\n} // validated\n\n// Moving Frostbite to Physically Based Rendering 3.0 - page 12, listing 2\n// https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\n\tfloat a2 = pow2( alpha );\n\n\t// dotNL and dotNV are explicitly swapped. This is not a mistake.\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\n\treturn 0.5 / max( gv + gl, EPSILON );\n\n}\n\n// Microfacet Models for Refraction through Rough Surfaces - equation (33)\n// http://graphicrants.blogspot.com/2013/08/specular-brdf-reference.html\n// alpha is \"roughness squared\" in Disney’s reparameterization\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\n\tfloat a2 = pow2( alpha );\n\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0; // avoid alpha = 0 with dotNH = 1\n\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n\n}\n\n// GGX Distribution, Schlick Fresnel, GGX-Smith Visibility\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\n\tfloat alpha = pow2( roughness ); // UE4's roughness\n\n\tvec3 halfDir = normalize( incidentLight.direction + viewDir );\n\n\tfloat dotNL = saturate( dot( normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\tfloat dotNH = saturate( dot( normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\n\tfloat D = D_GGX( alpha, dotNH );\n\n\treturn F * ( G * D );\n\n} // validated\n\n// Rect Area Light\n\n// Real-Time Polygonal-Light Shading with Linearly Transformed Cosines\n// by Eric Heitz, Jonathan Dupuy, Stephen Hill and David Neubelt\n// code: https://github.com/selfshadow/ltc_code/\n\nvec2 LTC_Uv( const in vec3 N, const in vec3 V, const in float roughness ) {\n\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\n\tfloat dotNV = saturate( dot( N, V ) );\n\n\t// texture parameterized by sqrt( GGX alpha ) and sqrt( 1 - cos( theta ) )\n\tvec2 uv = vec2( roughness, sqrt( 1.0 - dotNV ) );\n\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\n\treturn uv;\n\n}\n\nfloat LTC_ClippedSphereFormFactor( const in vec3 f ) {\n\n\t// Real-Time Area Lighting: a Journey from Research to Production (p.102)\n\t// An approximation of the form factor of a horizon-clipped rectangle.\n\n\tfloat l = length( f );\n\n\treturn max( ( l * l + f.z ) / ( l + 1.0 ), 0.0 );\n\n}\n\nvec3 LTC_EdgeVectorFormFactor( const in vec3 v1, const in vec3 v2 ) {\n\n\tfloat x = dot( v1, v2 );\n\n\tfloat y = abs( x );\n\n\t// rational polynomial approximation to theta / sin( theta ) / 2PI\n\tfloat a = 0.8543985 + ( 0.4965155 + 0.0145206 * y ) * y;\n\tfloat b = 3.4175940 + ( 4.1616724 + y ) * y;\n\tfloat v = a / b;\n\n\tfloat theta_sintheta = ( x > 0.0 ) ? v : 0.5 * inversesqrt( max( 1.0 - x * x, 1e-7 ) ) - v;\n\n\treturn cross( v1, v2 ) * theta_sintheta;\n\n}\n\nvec3 LTC_Evaluate( const in vec3 N, const in vec3 V, const in vec3 P, const in mat3 mInv, const in vec3 rectCoords[ 4 ] ) {\n\n\t// bail if point is on back side of plane of light\n\t// assumes ccw winding order of light vertices\n\tvec3 v1 = rectCoords[ 1 ] - rectCoords[ 0 ];\n\tvec3 v2 = rectCoords[ 3 ] - rectCoords[ 0 ];\n\tvec3 lightNormal = cross( v1, v2 );\n\n\tif( dot( lightNormal, P - rectCoords[ 0 ] ) < 0.0 ) return vec3( 0.0 );\n\n\t// construct orthonormal basis around N\n\tvec3 T1, T2;\n\tT1 = normalize( V - N * dot( V, N ) );\n\tT2 = - cross( N, T1 ); // negated from paper; possibly due to a different handedness of world coordinate system\n\n\t// compute transform\n\tmat3 mat = mInv * transposeMat3( mat3( T1, T2, N ) );\n\n\t// transform rect\n\tvec3 coords[ 4 ];\n\tcoords[ 0 ] = mat * ( rectCoords[ 0 ] - P );\n\tcoords[ 1 ] = mat * ( rectCoords[ 1 ] - P );\n\tcoords[ 2 ] = mat * ( rectCoords[ 2 ] - P );\n\tcoords[ 3 ] = mat * ( rectCoords[ 3 ] - P );\n\n\t// project rect onto sphere\n\tcoords[ 0 ] = normalize( coords[ 0 ] );\n\tcoords[ 1 ] = normalize( coords[ 1 ] );\n\tcoords[ 2 ] = normalize( coords[ 2 ] );\n\tcoords[ 3 ] = normalize( coords[ 3 ] );\n\n\t// calculate vector form factor\n\tvec3 vectorFormFactor = vec3( 0.0 );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 0 ], coords[ 1 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 1 ], coords[ 2 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 2 ], coords[ 3 ] );\n\tvectorFormFactor += LTC_EdgeVectorFormFactor( coords[ 3 ], coords[ 0 ] );\n\n\t// adjust for horizon clipping\n\tfloat result = LTC_ClippedSphereFormFactor( vectorFormFactor );\n\n/*\n\t// alternate method of adjusting for horizon clipping (see referece)\n\t// refactoring required\n\tfloat len = length( vectorFormFactor );\n\tfloat z = vectorFormFactor.z / len;\n\n\tconst float LUT_SIZE = 64.0;\n\tconst float LUT_SCALE = ( LUT_SIZE - 1.0 ) / LUT_SIZE;\n\tconst float LUT_BIAS = 0.5 / LUT_SIZE;\n\n\t// tabulated horizon-clipped sphere, apparently...\n\tvec2 uv = vec2( z * 0.5 + 0.5, len );\n\tuv = uv * LUT_SCALE + LUT_BIAS;\n\n\tfloat scale = texture2D( ltc_2, uv ).w;\n\n\tfloat result = len * scale;\n*/\n\n\treturn vec3( result );\n\n}\n\n// End Rect Area Light\n\n// ref: https://www.unrealengine.com/blog/physically-based-shading-on-mobile - environmentBRDF for GGX on mobile\nvec3 BRDF_Specular_GGX_Environment( const in vec3 viewDir, const in vec3 normal, const in vec3 specularColor, const in float roughness ) {\n\n\tfloat dotNV = saturate( dot( normal, viewDir ) );\n\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\n\treturn specularColor * brdf.x + brdf.y;\n\n} // validated\n\n// Fdez-Agüera's \"Multiple-Scattering Microfacet Model for Real-Time Image Based Lighting\"\n// Approximates multiscattering in order to preserve energy.\n// http://www.jcgt.org/published/0008/01/03/\nvoid BRDF_Specular_Multiscattering_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness, inout vec3 singleScatter, inout vec3 multiScatter ) {\n\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\n\tvec3 F = F_Schlick_RoughnessDependent( specularColor, dotNV, roughness );\n\tvec2 brdf = integrateSpecularBRDF( dotNV, roughness );\n\tvec3 FssEss = F * brdf.x + brdf.y;\n\n\tfloat Ess = brdf.x + brdf.y;\n\tfloat Ems = 1.0 - Ess;\n\n\tvec3 Favg = specularColor + ( 1.0 - specularColor ) * 0.047619; // 1/21\n\tvec3 Fms = FssEss * Favg / ( 1.0 - Ems * Favg );\n\n\tsingleScatter += FssEss;\n\tmultiScatter += Fms * Ems;\n\n}\n\nfloat G_BlinnPhong_Implicit( /* const in float dotNL, const in float dotNV */ ) {\n\n\t// geometry term is (n dot l)(n dot v) / 4(n dot l)(n dot v)\n\treturn 0.25;\n\n}\n\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n\n}\n\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\n\t//float dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\n\t//float dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\n\tfloat G = G_BlinnPhong_Implicit( /* dotNL, dotNV */ );\n\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\n\treturn F * ( G * D );\n\n} // validated\n\n// source: http://simonstechblog.blogspot.ca/2011/12/microfacet-brdf.html\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\n\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n\n#if defined( USE_SHEEN )\n\n// https://github.com/google/filament/blob/master/shaders/src/brdf.fs#L94\nfloat D_Charlie(float roughness, float NoH) {\n\t// Estevez and Kulla 2017, \"Production Friendly Microfacet Sheen BRDF\"\n\tfloat invAlpha = 1.0 / roughness;\n\tfloat cos2h = NoH * NoH;\n\tfloat sin2h = max(1.0 - cos2h, 0.0078125); // 2^(-14/2), so sin2h^2 > 0 in fp16\n\treturn (2.0 + invAlpha) * pow(sin2h, invAlpha * 0.5) / (2.0 * PI);\n}\n\n// https://github.com/google/filament/blob/master/shaders/src/brdf.fs#L136\nfloat V_Neubelt(float NoV, float NoL) {\n\t// Neubelt and Pettineo 2013, \"Crafting a Next-gen Material Pipeline for The Order: 1886\"\n\treturn saturate(1.0 / (4.0 * (NoL + NoV - NoL * NoV)));\n}\n\nvec3 BRDF_Specular_Sheen( const in float roughness, const in vec3 L, const in GeometricContext geometry, vec3 specularColor ) {\n\n\tvec3 N = geometry.normal;\n\tvec3 V = geometry.viewDir;\n\n\tvec3 H = normalize( V + L );\n\tfloat dotNH = saturate( dot( N, H ) );\n\n\treturn specularColor * D_Charlie( roughness, dotNH ) * V_Neubelt( dot(N, V), dot(N, L) );\n\n}\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_BUMPMAP\n\n\tuniform sampler2D bumpMap;\n\tuniform float bumpScale;\n\n\t// Bump Mapping Unparametrized Surfaces on the GPU by Morten S. Mikkelsen\n\t// http://api.unrealengine.com/attachments/Engine/Rendering/LightingAndShadows/BumpMappingWithoutTangentSpace/mm_sfgrad_bump.pdf\n\n\t// Evaluate the derivative of the height w.r.t. screen-space using forward differencing (listing 2)\n\n\tvec2 dHdxy_fwd() {\n\n\t\tvec2 dSTdx = dFdx( vUv );\n\t\tvec2 dSTdy = dFdy( vUv );\n\n\t\tfloat Hll = bumpScale * texture2D( bumpMap, vUv ).x;\n\t\tfloat dBx = bumpScale * texture2D( bumpMap, vUv + dSTdx ).x - Hll;\n\t\tfloat dBy = bumpScale * texture2D( bumpMap, vUv + dSTdy ).x - Hll;\n\n\t\treturn vec2( dBx, dBy );\n\n\t}\n\n\tvec3 perturbNormalArb( vec3 surf_pos, vec3 surf_norm, vec2 dHdxy ) {\n\n\t\t// Workaround for Adreno 3XX dFd*( vec3 ) bug. See #9988\n\n\t\tvec3 vSigmaX = vec3( dFdx( surf_pos.x ), dFdx( surf_pos.y ), dFdx( surf_pos.z ) );\n\t\tvec3 vSigmaY = vec3( dFdy( surf_pos.x ), dFdy( surf_pos.y ), dFdy( surf_pos.z ) );\n\t\tvec3 vN = surf_norm;\t\t// normalized\n\n\t\tvec3 R1 = cross( vSigmaY, vN );\n\t\tvec3 R2 = cross( vN, vSigmaX );\n\n\t\tfloat fDet = dot( vSigmaX, R1 );\n\n\t\tfDet *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\n\t\tvec3 vGrad = sign( fDet ) * ( dHdxy.x * R1 + dHdxy.y * R2 );\n\t\treturn normalize( abs( fDet ) * surf_norm - vGrad );\n\n\t}\n\n#endif\n`;\n","export default /* glsl */`\n#if NUM_CLIPPING_PLANES > 0\n\n\tvec4 plane;\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < UNION_CLIPPING_PLANES; i ++ ) {\n\n\t\tplane = clippingPlanes[ i ];\n\t\tif ( dot( vClipPosition, plane.xyz ) > plane.w ) discard;\n\n\t}\n\t#pragma unroll_loop_end\n\n\t#if UNION_CLIPPING_PLANES < NUM_CLIPPING_PLANES\n\n\t\tbool clipped = true;\n\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = UNION_CLIPPING_PLANES; i < NUM_CLIPPING_PLANES; i ++ ) {\n\n\t\t\tplane = clippingPlanes[ i ];\n\t\t\tclipped = ( dot( vClipPosition, plane.xyz ) > plane.w ) && clipped;\n\n\t\t}\n\t\t#pragma unroll_loop_end\n\n\t\tif ( clipped ) discard;\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n#if NUM_CLIPPING_PLANES > 0\n\n\tvarying vec3 vClipPosition;\n\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n\n#endif\n`;\n","export default /* glsl */`\n#if NUM_CLIPPING_PLANES > 0\n\n\tvarying vec3 vClipPosition;\n\n#endif\n`;\n","export default /* glsl */`\n#if NUM_CLIPPING_PLANES > 0\n\n\tvClipPosition = - mvPosition.xyz;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_COLOR\n\n\tdiffuseColor.rgb *= vColor;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_COLOR\n\n\tvarying vec3 vColor;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_COLOR\n\n\tvarying vec3 vColor;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_COLOR\n\n\tvColor.xyz = color.xyz;\n\n#endif\n`;\n","export default /* glsl */`\n#define PI 3.141592653589793\n#define PI2 6.283185307179586\n#define PI_HALF 1.5707963267948966\n#define RECIPROCAL_PI 0.3183098861837907\n#define RECIPROCAL_PI2 0.15915494309189535\n#define EPSILON 1e-6\n\n#ifndef saturate\n// may have defined saturate() already\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\n#define whiteComplement(a) ( 1.0 - saturate( a ) )\n\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\n// expects values in the range of [0,1]x[0,1], returns values in the [0,1] range.\n// do not collapse into a single function per: http://byteblacksmith.com/improvements-to-the-canonical-one-liner-glsl-rand-for-opengl-es-2-0/\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\n\n#ifdef HIGH_PRECISION\n\tfloat precisionSafeLength( vec3 v ) { return length( v ); }\n#else\n\tfloat max3( vec3 v ) { return max( max( v.x, v.y ), v.z ); }\n\tfloat precisionSafeLength( vec3 v ) {\n\t\tfloat maxComponent = max3( abs( v ) );\n\t\treturn length( v / maxComponent ) * maxComponent;\n\t}\n#endif\n\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\n\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\n\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n#ifdef CLEARCOAT\n\tvec3 clearcoatNormal;\n#endif\n};\n\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n\n}\n\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\n\t// dir can be either a direction vector or a normal vector\n\t// upper-left 3x3 of matrix is assumed to be orthogonal\n\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n\n}\n\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\n\treturn - distance * planeNormal + point;\n\n}\n\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n\n}\n\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n\n}\n\nmat3 transposeMat3( const in mat3 m ) {\n\n\tmat3 tmp;\n\n\ttmp[ 0 ] = vec3( m[ 0 ].x, m[ 1 ].x, m[ 2 ].x );\n\ttmp[ 1 ] = vec3( m[ 0 ].y, m[ 1 ].y, m[ 2 ].y );\n\ttmp[ 2 ] = vec3( m[ 0 ].z, m[ 1 ].z, m[ 2 ].z );\n\n\treturn tmp;\n\n}\n\n// https://en.wikipedia.org/wiki/Relative_luminance\nfloat linearToRelativeLuminance( const in vec3 color ) {\n\n\tvec3 weights = vec3( 0.2126, 0.7152, 0.0722 );\n\n\treturn dot( weights, color.rgb );\n\n}\n\nbool isPerspectiveMatrix( mat4 m ) {\n\n return m[ 2 ][ 3 ] == - 1.0;\n\n}\n\nvec2 equirectUv( in vec3 dir ) {\n\n\t// dir is assumed to be unit length\n\n\tfloat u = atan( dir.z, dir.x ) * RECIPROCAL_PI2 + 0.5;\n\n\tfloat v = asin( clamp( dir.y, - 1.0, 1.0 ) ) * RECIPROCAL_PI + 0.5;\n\n\treturn vec2( u, v );\n\n}\n`;\n","export default /* glsl */`\n#ifdef ENVMAP_TYPE_CUBE_UV\n\n#define cubeUV_maxMipLevel 8.0\n#define cubeUV_minMipLevel 4.0\n#define cubeUV_maxTileSize 256.0\n#define cubeUV_minTileSize 16.0\n\n// These shader functions convert between the UV coordinates of a single face of\n// a cubemap, the 0-5 integer index of a cube face, and the direction vector for\n// sampling a textureCube (not generally normalized).\n\nfloat getFace(vec3 direction) {\n vec3 absDirection = abs(direction);\n float face = -1.0;\n if (absDirection.x > absDirection.z) {\n if (absDirection.x > absDirection.y)\n face = direction.x > 0.0 ? 0.0 : 3.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n } else {\n if (absDirection.z > absDirection.y)\n face = direction.z > 0.0 ? 2.0 : 5.0;\n else\n face = direction.y > 0.0 ? 1.0 : 4.0;\n }\n return face;\n}\n\n// RH coordinate system; PMREM face-indexing convention\nvec2 getUV(vec3 direction, float face) {\n vec2 uv;\n if (face == 0.0) {\n uv = vec2(direction.z, direction.y) / abs(direction.x); // pos x\n } else if (face == 1.0) {\n uv = vec2(-direction.x, -direction.z) / abs(direction.y); // pos y\n } else if (face == 2.0) {\n uv = vec2(-direction.x, direction.y) / abs(direction.z); // pos z\n } else if (face == 3.0) {\n uv = vec2(-direction.z, direction.y) / abs(direction.x); // neg x\n } else if (face == 4.0) {\n uv = vec2(-direction.x, direction.z) / abs(direction.y); // neg y\n } else {\n uv = vec2(direction.x, direction.y) / abs(direction.z); // neg z\n }\n return 0.5 * (uv + 1.0);\n}\n\nvec3 bilinearCubeUV(sampler2D envMap, vec3 direction, float mipInt) {\n float face = getFace(direction);\n float filterInt = max(cubeUV_minMipLevel - mipInt, 0.0);\n mipInt = max(mipInt, cubeUV_minMipLevel);\n float faceSize = exp2(mipInt);\n\n float texelSize = 1.0 / (3.0 * cubeUV_maxTileSize);\n\n vec2 uv = getUV(direction, face) * (faceSize - 1.0);\n vec2 f = fract(uv);\n uv += 0.5 - f;\n if (face > 2.0) {\n uv.y += faceSize;\n face -= 3.0;\n }\n uv.x += face * faceSize;\n if(mipInt < cubeUV_maxMipLevel){\n uv.y += 2.0 * cubeUV_maxTileSize;\n }\n uv.y += filterInt * 2.0 * cubeUV_minTileSize;\n uv.x += 3.0 * max(0.0, cubeUV_maxTileSize - 2.0 * faceSize);\n uv *= texelSize;\n\n vec3 tl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.x += texelSize;\n vec3 tr = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.y += texelSize;\n vec3 br = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n uv.x -= texelSize;\n vec3 bl = envMapTexelToLinear(texture2D(envMap, uv)).rgb;\n vec3 tm = mix(tl, tr, f.x);\n vec3 bm = mix(bl, br, f.x);\n return mix(tm, bm, f.y);\n}\n\n// These defines must match with PMREMGenerator\n\n#define r0 1.0\n#define v0 0.339\n#define m0 -2.0\n#define r1 0.8\n#define v1 0.276\n#define m1 -1.0\n#define r4 0.4\n#define v4 0.046\n#define m4 2.0\n#define r5 0.305\n#define v5 0.016\n#define m5 3.0\n#define r6 0.21\n#define v6 0.0038\n#define m6 4.0\n\nfloat roughnessToMip(float roughness) {\n float mip = 0.0;\n if (roughness >= r1) {\n mip = (r0 - roughness) * (m1 - m0) / (r0 - r1) + m0;\n } else if (roughness >= r4) {\n mip = (r1 - roughness) * (m4 - m1) / (r1 - r4) + m1;\n } else if (roughness >= r5) {\n mip = (r4 - roughness) * (m5 - m4) / (r4 - r5) + m4;\n } else if (roughness >= r6) {\n mip = (r5 - roughness) * (m6 - m5) / (r5 - r6) + m5;\n } else {\n mip = -2.0 * log2(1.16 * roughness);// 1.16 = 1.79^0.25\n }\n return mip;\n}\n\nvec4 textureCubeUV(sampler2D envMap, vec3 sampleDir, float roughness) {\n float mip = clamp(roughnessToMip(roughness), m0, cubeUV_maxMipLevel);\n float mipF = fract(mip);\n float mipInt = floor(mip);\n\n vec3 color0 = bilinearCubeUV(envMap, sampleDir, mipInt);\n if (mipF == 0.0) {\n return vec4(color0, 1.0);\n } else {\n vec3 color1 = bilinearCubeUV(envMap, sampleDir, mipInt + 1.0);\n return vec4(mix(color0, color1, mipF), 1.0);\n }\n}\n#endif\n`;\n","export default /* glsl */`\nvec3 transformedNormal = objectNormal;\n\n#ifdef USE_INSTANCING\n\n\t// this is in lieu of a per-instance normal-matrix\n\t// shear transforms in the instance matrix are not supported\n\n\tmat3 m = mat3( instanceMatrix );\n\n\ttransformedNormal /= vec3( dot( m[ 0 ], m[ 0 ] ), dot( m[ 1 ], m[ 1 ] ), dot( m[ 2 ], m[ 2 ] ) );\n\n\ttransformedNormal = m * transformedNormal;\n\n#endif\n\ntransformedNormal = normalMatrix * transformedNormal;\n\n#ifdef FLIP_SIDED\n\n\ttransformedNormal = - transformedNormal;\n\n#endif\n\n#ifdef USE_TANGENT\n\n\tvec3 transformedTangent = ( modelViewMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\n\t#ifdef FLIP_SIDED\n\n\t\ttransformedTangent = - transformedTangent;\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_DISPLACEMENTMAP\n\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_DISPLACEMENTMAP\n\n\ttransformed += normalize( objectNormal ) * ( texture2D( displacementMap, vUv ).x * displacementScale + displacementBias );\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_EMISSIVEMAP\n\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_EMISSIVEMAP\n\n\tuniform sampler2D emissiveMap;\n\n#endif\n`;\n","export default /* glsl */`\ngl_FragColor = linearToOutputTexel( gl_FragColor );\n`;\n","export default /* glsl */`\n// For a discussion of what this is, please read this: http://lousodrome.net/blog/light/2013/05/26/gamma-correct-and-hdr-rendering-in-a-32-bits-buffer/\n\nvec4 LinearToLinear( in vec4 value ) {\n\treturn value;\n}\n\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( gammaFactor ) ), value.a );\n}\n\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n\treturn vec4( pow( value.rgb, vec3( 1.0 / gammaFactor ) ), value.a );\n}\n\nvec4 sRGBToLinear( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.a );\n}\n\nvec4 LinearTosRGB( in vec4 value ) {\n\treturn vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.a );\n}\n\nvec4 RGBEToLinear( in vec4 value ) {\n\treturn vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\n\nvec4 LinearToRGBE( in vec4 value ) {\n\tfloat maxComponent = max( max( value.r, value.g ), value.b );\n\tfloat fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n\treturn vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n// return vec4( value.brg, ( 3.0 + 128.0 ) / 256.0 );\n}\n\n// reference: http://iwasbeingirony.blogspot.ca/2010/06/difference-between-rgbm-and-rgbd.html\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * value.a * maxRange, 1.0 );\n}\n\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n\tM = ceil( M * 255.0 ) / 255.0;\n\treturn vec4( value.rgb / ( M * maxRange ), M );\n}\n\n// reference: http://iwasbeingirony.blogspot.ca/2010/06/difference-between-rgbm-and-rgbd.html\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n\treturn vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\n\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n\tfloat maxRGB = max( value.r, max( value.g, value.b ) );\n\tfloat D = max( maxRange / maxRGB, 1.0 );\n\t// NOTE: The implementation with min causes the shader to not compile on\n\t// a common Alcatel A502DL in Chrome 78/Android 8.1. Some research suggests \n\t// that the chipset is Mediatek MT6739 w/ IMG PowerVR GE8100 GPU.\n\t// D = min( floor( D ) / 255.0, 1.0 );\n\tD = clamp( floor( D ) / 255.0, 0.0, 1.0 );\n\treturn vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\n\n// LogLuv reference: http://graphicrants.blogspot.ca/2009/04/rgbm-color-encoding.html\n\n// M matrix, for encoding\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n\tvec3 Xp_Y_XYZp = cLogLuvM * value.rgb;\n\tXp_Y_XYZp = max( Xp_Y_XYZp, vec3( 1e-6, 1e-6, 1e-6 ) );\n\tvec4 vResult;\n\tvResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n\tfloat Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n\tvResult.w = fract( Le );\n\tvResult.z = ( Le - ( floor( vResult.w * 255.0 ) ) / 255.0 ) / 255.0;\n\treturn vResult;\n}\n\n// Inverse M matrix, for decoding\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n\tfloat Le = value.z * 255.0 + value.w;\n\tvec3 Xp_Y_XYZp;\n\tXp_Y_XYZp.y = exp2( ( Le - 127.0 ) / 2.0 );\n\tXp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n\tXp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n\tvec3 vRGB = cLogLuvInverseM * Xp_Y_XYZp.rgb;\n\treturn vec4( max( vRGB, 0.0 ), 1.0 );\n}\n`;\n","export default /* glsl */`\n#ifdef USE_ENVMAP\n\n\t#ifdef ENV_WORLDPOS\n\n\t\tvec3 cameraToFrag;\n\t\t\n\t\tif ( isOrthographic ) {\n\n\t\t\tcameraToFrag = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\n\t\t} else {\n\n\t\t\tcameraToFrag = normalize( vWorldPosition - cameraPosition );\n\n\t\t}\n\n\t\t// Transforming Normal Vectors with the Inverse Transformation\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\n\t\t\tvec3 reflectVec = reflect( cameraToFrag, worldNormal );\n\n\t\t#else\n\n\t\t\tvec3 reflectVec = refract( cameraToFrag, worldNormal, refractionRatio );\n\n\t\t#endif\n\n\t#else\n\n\t\tvec3 reflectVec = vReflect;\n\n\t#endif\n\n\t#ifdef ENVMAP_TYPE_CUBE\n\n\t\tvec4 envColor = textureCube( envMap, vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\n\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\n\t\tvec4 envColor = textureCubeUV( envMap, reflectVec, 0.0 );\n\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\n\t\treflectVec = normalize( reflectVec );\n\n\t\tvec2 sampleUV = equirectUv( reflectVec );\n\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\n\t#else\n\n\t\tvec4 envColor = vec4( 0.0 );\n\n\t#endif\n\n\t#ifndef ENVMAP_TYPE_CUBE_UV\n\n\t\tenvColor = envMapTexelToLinear( envColor );\n\n\t#endif\n\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_ENVMAP\n\n\tuniform float envMapIntensity;\n\tuniform float flipEnvMap;\n\tuniform int maxMipLevel;\n\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\t\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_ENVMAP\n\n\tuniform float reflectivity;\n\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\n\t\t#define ENV_WORLDPOS\n\n\t#endif\n\n\t#ifdef ENV_WORLDPOS\n\n\t\tvarying vec3 vWorldPosition;\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_ENVMAP\n\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) ||defined( PHONG )\n\n\t\t#define ENV_WORLDPOS\n\n\t#endif\n\n\t#ifdef ENV_WORLDPOS\n\t\t\n\t\tvarying vec3 vWorldPosition;\n\n\t#else\n\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n#if defined( USE_ENVMAP )\n\n\t#ifdef ENVMAP_MODE_REFRACTION\n\t\tuniform float refractionRatio;\n\t#endif\n\n\tvec3 getLightProbeIndirectIrradiance( /*const in SpecularLightProbe specularLightProbe,*/ const in GeometricContext geometry, const in int maxMIPLevel ) {\n\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\n\t\t\tvec3 queryVec = vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\n\t\t\t// TODO: replace with properly filtered cubemaps and access the irradiance LOD level, be it the last LOD level\n\t\t\t// of a specular cubemap, or just the default level of a specially created irradiance cubemap.\n\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\n\t\t\t#else\n\n\t\t\t\t// force the bias high to get the last LOD level as it is the most blurred.\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\n\t\t\t#endif\n\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, worldNormal, 1.0 );\n\n\t\t#else\n\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\n\t\t#endif\n\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\n\t}\n\n\t// Trowbridge-Reitz distribution to Mip level, following the logic of http://casual-effects.blogspot.ca/2011/08/plausible-environment-lighting-in-two.html\n\tfloat getSpecularMIPLevel( const in float roughness, const in int maxMIPLevel ) {\n\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\n\t\tfloat sigma = PI * roughness * roughness / ( 1.0 + roughness );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar + log2( sigma );\n\n\t\t// clamp to allowable LOD ranges.\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\n\t}\n\n\tvec3 getLightProbeIndirectRadiance( /*const in SpecularLightProbe specularLightProbe,*/ const in vec3 viewDir, const in vec3 normal, const in float roughness, const in int maxMIPLevel ) {\n\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\n\t\t vec3 reflectVec = reflect( -viewDir, normal );\n\n\t\t // Mixing the reflection with the normal is more accurate and keeps rough objects from gathering light from behind their tangent plane.\n\t\t reflectVec = normalize( mix( reflectVec, normal, roughness * roughness) );\n\n\t\t#else\n\n\t\t vec3 reflectVec = refract( -viewDir, normal, refractionRatio );\n\n\t\t#endif\n\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( roughness, maxMIPLevel );\n\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\n\t\t\tvec3 queryReflectVec = vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\n\t\t\t#else\n\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\n\t\t\t#endif\n\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\n\t\t\tvec4 envMapColor = textureCubeUV( envMap, reflectVec, roughness );\n\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\n\t\t\tvec2 sampleUV = equirectUv( reflectVec );\n\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\n\t\t\t#else\n\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\n\t\t\t#endif\n\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\n\t\t#endif\n\n\t\treturn envMapColor.rgb * envMapIntensity;\n\n\t}\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_ENVMAP\n\n\t#ifdef ENV_WORLDPOS\n\n\t\tvWorldPosition = worldPosition.xyz;\n\n\t#else\n\n\t\tvec3 cameraToVertex;\n\n\t\tif ( isOrthographic ) { \n\n\t\t\tcameraToVertex = normalize( vec3( - viewMatrix[ 0 ][ 2 ], - viewMatrix[ 1 ][ 2 ], - viewMatrix[ 2 ][ 2 ] ) );\n\n\t\t} else {\n\n\t\t\tcameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\n\t\t}\n\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\n\t\t#else\n\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\n\t\t#endif\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_FOG\n\n\tfogDepth = -mvPosition.z;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_FOG\n\n\tvarying float fogDepth;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_FOG\n\n\t#ifdef FOG_EXP2\n\n\t\tfloat fogFactor = 1.0 - exp( - fogDensity * fogDensity * fogDepth * fogDepth );\n\n\t#else\n\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, fogDepth );\n\n\t#endif\n\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_FOG\n\n\tuniform vec3 fogColor;\n\tvarying float fogDepth;\n\n\t#ifdef FOG_EXP2\n\n\t\tuniform float fogDensity;\n\n\t#else\n\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n\n#ifdef USE_GRADIENTMAP\n\n\tuniform sampler2D gradientMap;\n\n#endif\n\nvec3 getGradientIrradiance( vec3 normal, vec3 lightDirection ) {\n\n\t// dotNL will be from -1.0 to 1.0\n\tfloat dotNL = dot( normal, lightDirection );\n\tvec2 coord = vec2( dotNL * 0.5 + 0.5, 0.0 );\n\n\t#ifdef USE_GRADIENTMAP\n\n\t\treturn texture2D( gradientMap, coord ).rgb;\n\n\t#else\n\n\t\treturn ( coord.x < 0.7 ) ? vec3( 0.7 ) : vec3( 1.0 );\n\n\t#endif\n\n}\n\n`;\n","export default /* glsl */`\n#ifdef USE_LIGHTMAP\n\n\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\treflectedLight.indirectDiffuse += PI * lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity; // factor of PI should not be present; included here to prevent breakage\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_LIGHTMAP\n\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n\n#endif\n`;\n","export default /* glsl */`\nvec3 diffuse = vec3( 1.0 );\n\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( -mvPosition.xyz );\n\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\n\nvLightFront = vec3( 0.0 );\nvIndirectFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n\tvIndirectBack = vec3( 0.0 );\n#endif\n\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n\nvIndirectFront += getAmbientLightIrradiance( ambientLightColor );\n\nvIndirectFront += getLightProbeIrradiance( lightProbe, geometry );\n\n#ifdef DOUBLE_SIDED\n\n\tvIndirectBack += getAmbientLightIrradiance( ambientLightColor );\n\n\tvIndirectBack += getLightProbeIrradiance( lightProbe, backGeometry );\n\n#endif\n\n#if NUM_POINT_LIGHTS > 0\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\n\t\t#ifdef DOUBLE_SIDED\n\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\n\t\t#endif\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if NUM_SPOT_LIGHTS > 0\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\n\t\t#ifdef DOUBLE_SIDED\n\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\n\t\t#endif\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n/*\n#if NUM_RECT_AREA_LIGHTS > 0\n\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\n\t\t// TODO (abelnation): implement\n\n\t}\n\n#endif\n*/\n\n#if NUM_DIR_LIGHTS > 0\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\n\t\t#ifdef DOUBLE_SIDED\n\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\n\t\t#endif\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if NUM_HEMI_LIGHTS > 0\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\n\t\tvIndirectFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\n\t\t#ifdef DOUBLE_SIDED\n\n\t\t\tvIndirectBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\n\t\t#endif\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n`;\n","export default /* glsl */`\nuniform bool receiveShadow;\nuniform vec3 ambientLightColor;\nuniform vec3 lightProbe[ 9 ];\n\n// get the irradiance (radiance convolved with cosine lobe) at the point 'normal' on the unit sphere\n// source: https://graphics.stanford.edu/papers/envmap/envmap.pdf\nvec3 shGetIrradianceAt( in vec3 normal, in vec3 shCoefficients[ 9 ] ) {\n\n\t// normal is assumed to have unit length\n\n\tfloat x = normal.x, y = normal.y, z = normal.z;\n\n\t// band 0\n\tvec3 result = shCoefficients[ 0 ] * 0.886227;\n\n\t// band 1\n\tresult += shCoefficients[ 1 ] * 2.0 * 0.511664 * y;\n\tresult += shCoefficients[ 2 ] * 2.0 * 0.511664 * z;\n\tresult += shCoefficients[ 3 ] * 2.0 * 0.511664 * x;\n\n\t// band 2\n\tresult += shCoefficients[ 4 ] * 2.0 * 0.429043 * x * y;\n\tresult += shCoefficients[ 5 ] * 2.0 * 0.429043 * y * z;\n\tresult += shCoefficients[ 6 ] * ( 0.743125 * z * z - 0.247708 );\n\tresult += shCoefficients[ 7 ] * 2.0 * 0.429043 * x * z;\n\tresult += shCoefficients[ 8 ] * 0.429043 * ( x * x - y * y );\n\n\treturn result;\n\n}\n\nvec3 getLightProbeIrradiance( const in vec3 lightProbe[ 9 ], const in GeometricContext geometry ) {\n\n\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\n\tvec3 irradiance = shGetIrradianceAt( worldNormal, lightProbe );\n\n\treturn irradiance;\n\n}\n\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\n\tvec3 irradiance = ambientLightColor;\n\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\n\t\tirradiance *= PI;\n\n\t#endif\n\n\treturn irradiance;\n\n}\n\n#if NUM_DIR_LIGHTS > 0\n\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t};\n\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\n\t}\n\n#endif\n\n\n#if NUM_POINT_LIGHTS > 0\n\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t};\n\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\n\t// directLight is an out parameter as having it as a return value caused compiler errors on some devices\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\n\t\tfloat lightDistance = length( lVector );\n\n\t\tdirectLight.color = pointLight.color;\n\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\tdirectLight.visible = ( directLight.color != vec3( 0.0 ) );\n\n\t}\n\n#endif\n\n\n#if NUM_SPOT_LIGHTS > 0\n\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t};\n\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\n\t// directLight is an out parameter as having it as a return value caused compiler errors on some devices\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\n\t\tif ( angleCos > spotLight.coneCos ) {\n\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\n\t\t} else {\n\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\n\t\t}\n\t}\n\n#endif\n\n\n#if NUM_RECT_AREA_LIGHTS > 0\n\n\tstruct RectAreaLight {\n\t\tvec3 color;\n\t\tvec3 position;\n\t\tvec3 halfWidth;\n\t\tvec3 halfHeight;\n\t};\n\n\t// Pre-computed values of LinearTransformedCosine approximation of BRDF\n\t// BRDF approximation Texture is 64x64\n\tuniform sampler2D ltc_1; // RGBA Float\n\tuniform sampler2D ltc_2; // RGBA Float\n\n\tuniform RectAreaLight rectAreaLights[ NUM_RECT_AREA_LIGHTS ];\n\n#endif\n\n\n#if NUM_HEMI_LIGHTS > 0\n\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\n\t\t\tirradiance *= PI;\n\n\t\t#endif\n\n\t\treturn irradiance;\n\n\t}\n\n#endif\n`;\n","export default /* glsl */`\nToonMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\n`;\n","export default /* glsl */`\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n#endif\n\n\nstruct ToonMaterial {\n\n\tvec3\tdiffuseColor;\n\n};\n\nvoid RE_Direct_Toon( const in IncidentLight directLight, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\n\tvec3 irradiance = getGradientIrradiance( geometry.normal, directLight.direction ) * directLight.color;\n\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\n\t\tirradiance *= PI; // punctual light\n\n\t#endif\n\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\n}\n\nvoid RE_IndirectDiffuse_Toon( const in vec3 irradiance, const in GeometricContext geometry, const in ToonMaterial material, inout ReflectedLight reflectedLight ) {\n\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\n}\n\n#define RE_Direct\t\t\t\tRE_Direct_Toon\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Toon\n\n#define Material_LightProbeLOD( material )\t(0)\n`;\n","export default /* glsl */`\nBlinnPhongMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb;\nmaterial.specularColor = specular;\nmaterial.specularShininess = shininess;\nmaterial.specularStrength = specularStrength;\n`;\n","export default /* glsl */`\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n#endif\n\n\nstruct BlinnPhongMaterial {\n\n\tvec3\tdiffuseColor;\n\tvec3\tspecularColor;\n\tfloat\tspecularShininess;\n\tfloat\tspecularStrength;\n\n};\n\nvoid RE_Direct_BlinnPhong( const in IncidentLight directLight, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\tvec3 irradiance = dotNL * directLight.color;\n\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\n\t\tirradiance *= PI; // punctual light\n\n\t#endif\n\n\treflectedLight.directDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\n\treflectedLight.directSpecular += irradiance * BRDF_Specular_BlinnPhong( directLight, geometry, material.specularColor, material.specularShininess ) * material.specularStrength;\n\n}\n\nvoid RE_IndirectDiffuse_BlinnPhong( const in vec3 irradiance, const in GeometricContext geometry, const in BlinnPhongMaterial material, inout ReflectedLight reflectedLight ) {\n\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\n}\n\n#define RE_Direct\t\t\t\tRE_Direct_BlinnPhong\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_BlinnPhong\n\n#define Material_LightProbeLOD( material )\t(0)\n`;\n","export default /* glsl */`\nPhysicalMaterial material;\nmaterial.diffuseColor = diffuseColor.rgb * ( 1.0 - metalnessFactor );\n\nvec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );\nfloat geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );\n\nmaterial.specularRoughness = max( roughnessFactor, 0.0525 );// 0.0525 corresponds to the base mip of a 256 cubemap.\nmaterial.specularRoughness += geometryRoughness;\nmaterial.specularRoughness = min( material.specularRoughness, 1.0 );\n\n#ifdef REFLECTIVITY\n\n\tmaterial.specularColor = mix( vec3( MAXIMUM_SPECULAR_COEFFICIENT * pow2( reflectivity ) ), diffuseColor.rgb, metalnessFactor );\n\n#else\n\n\tmaterial.specularColor = mix( vec3( DEFAULT_SPECULAR_COEFFICIENT ), diffuseColor.rgb, metalnessFactor );\n\n#endif\n\n#ifdef CLEARCOAT\n\n\tmaterial.clearcoat = clearcoat;\n\tmaterial.clearcoatRoughness = clearcoatRoughness;\n\n\t#ifdef USE_CLEARCOATMAP\n\n\t\tmaterial.clearcoat *= texture2D( clearcoatMap, vUv ).x;\n\n\t#endif\n\n\t#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\n\t\tmaterial.clearcoatRoughness *= texture2D( clearcoatRoughnessMap, vUv ).y;\n\n\t#endif\n\n\tmaterial.clearcoat = saturate( material.clearcoat ); // Burley clearcoat model\n\tmaterial.clearcoatRoughness = max( material.clearcoatRoughness, 0.0525 );\n\tmaterial.clearcoatRoughness += geometryRoughness;\n\tmaterial.clearcoatRoughness = min( material.clearcoatRoughness, 1.0 );\n\n#endif\n\n#ifdef USE_SHEEN\n\n\tmaterial.sheenColor = sheen;\n\n#endif\n`;\n","export default /* glsl */`\nstruct PhysicalMaterial {\n\n\tvec3\tdiffuseColor;\n\tfloat\tspecularRoughness;\n\tvec3\tspecularColor;\n\n#ifdef CLEARCOAT\n\tfloat clearcoat;\n\tfloat clearcoatRoughness;\n#endif\n#ifdef USE_SHEEN\n\tvec3 sheenColor;\n#endif\n\n};\n\n#define MAXIMUM_SPECULAR_COEFFICIENT 0.16\n#define DEFAULT_SPECULAR_COEFFICIENT 0.04\n\n// Clear coat directional hemishperical reflectance (this approximation should be improved)\nfloat clearcoatDHRApprox( const in float roughness, const in float dotNL ) {\n\n\treturn DEFAULT_SPECULAR_COEFFICIENT + ( 1.0 - DEFAULT_SPECULAR_COEFFICIENT ) * ( pow( 1.0 - dotNL, 5.0 ) * pow( 1.0 - roughness, 2.0 ) );\n\n}\n\n#if NUM_RECT_AREA_LIGHTS > 0\n\n\tvoid RE_Direct_RectArea_Physical( const in RectAreaLight rectAreaLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\n\t\tvec3 normal = geometry.normal;\n\t\tvec3 viewDir = geometry.viewDir;\n\t\tvec3 position = geometry.position;\n\t\tvec3 lightPos = rectAreaLight.position;\n\t\tvec3 halfWidth = rectAreaLight.halfWidth;\n\t\tvec3 halfHeight = rectAreaLight.halfHeight;\n\t\tvec3 lightColor = rectAreaLight.color;\n\t\tfloat roughness = material.specularRoughness;\n\n\t\tvec3 rectCoords[ 4 ];\n\t\trectCoords[ 0 ] = lightPos + halfWidth - halfHeight; // counterclockwise; light shines in local neg z direction\n\t\trectCoords[ 1 ] = lightPos - halfWidth - halfHeight;\n\t\trectCoords[ 2 ] = lightPos - halfWidth + halfHeight;\n\t\trectCoords[ 3 ] = lightPos + halfWidth + halfHeight;\n\n\t\tvec2 uv = LTC_Uv( normal, viewDir, roughness );\n\n\t\tvec4 t1 = texture2D( ltc_1, uv );\n\t\tvec4 t2 = texture2D( ltc_2, uv );\n\n\t\tmat3 mInv = mat3(\n\t\t\tvec3( t1.x, 0, t1.y ),\n\t\t\tvec3( 0, 1, 0 ),\n\t\t\tvec3( t1.z, 0, t1.w )\n\t\t);\n\n\t\t// LTC Fresnel Approximation by Stephen Hill\n\t\t// http://blog.selfshadow.com/publications/s2016-advances/s2016_ltc_fresnel.pdf\n\t\tvec3 fresnel = ( material.specularColor * t2.x + ( vec3( 1.0 ) - material.specularColor ) * t2.y );\n\n\t\treflectedLight.directSpecular += lightColor * fresnel * LTC_Evaluate( normal, viewDir, position, mInv, rectCoords );\n\n\t\treflectedLight.directDiffuse += lightColor * material.diffuseColor * LTC_Evaluate( normal, viewDir, position, mat3( 1.0 ), rectCoords );\n\n\t}\n\n#endif\n\nvoid RE_Direct_Physical( const in IncidentLight directLight, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\n\tfloat dotNL = saturate( dot( geometry.normal, directLight.direction ) );\n\n\tvec3 irradiance = dotNL * directLight.color;\n\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\n\t\tirradiance *= PI; // punctual light\n\n\t#endif\n\n\t#ifdef CLEARCOAT\n\n\t\tfloat ccDotNL = saturate( dot( geometry.clearcoatNormal, directLight.direction ) );\n\n\t\tvec3 ccIrradiance = ccDotNL * directLight.color;\n\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\n\t\t\tccIrradiance *= PI; // punctual light\n\n\t\t#endif\n\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\n\t\treflectedLight.directSpecular += ccIrradiance * material.clearcoat * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\n\t#else\n\n\t\tfloat clearcoatDHR = 0.0;\n\n\t#endif\n\n\t#ifdef USE_SHEEN\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_Sheen(\n\t\t\tmaterial.specularRoughness,\n\t\t\tdirectLight.direction,\n\t\t\tgeometry,\n\t\t\tmaterial.sheenColor\n\t\t);\n\t#else\n\t\treflectedLight.directSpecular += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Specular_GGX( directLight, geometry.viewDir, geometry.normal, material.specularColor, material.specularRoughness);\n\t#endif\n\n\treflectedLight.directDiffuse += ( 1.0 - clearcoatDHR ) * irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n}\n\nvoid RE_IndirectDiffuse_Physical( const in vec3 irradiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight ) {\n\n\treflectedLight.indirectDiffuse += irradiance * BRDF_Diffuse_Lambert( material.diffuseColor );\n\n}\n\nvoid RE_IndirectSpecular_Physical( const in vec3 radiance, const in vec3 irradiance, const in vec3 clearcoatRadiance, const in GeometricContext geometry, const in PhysicalMaterial material, inout ReflectedLight reflectedLight) {\n\n\t#ifdef CLEARCOAT\n\n\t\tfloat ccDotNV = saturate( dot( geometry.clearcoatNormal, geometry.viewDir ) );\n\n\t\treflectedLight.indirectSpecular += clearcoatRadiance * material.clearcoat * BRDF_Specular_GGX_Environment( geometry.viewDir, geometry.clearcoatNormal, vec3( DEFAULT_SPECULAR_COEFFICIENT ), material.clearcoatRoughness );\n\n\t\tfloat ccDotNL = ccDotNV;\n\t\tfloat clearcoatDHR = material.clearcoat * clearcoatDHRApprox( material.clearcoatRoughness, ccDotNL );\n\n\t#else\n\n\t\tfloat clearcoatDHR = 0.0;\n\n\t#endif\n\n\tfloat clearcoatInv = 1.0 - clearcoatDHR;\n\n\t// Both indirect specular and indirect diffuse light accumulate here\n\n\tvec3 singleScattering = vec3( 0.0 );\n\tvec3 multiScattering = vec3( 0.0 );\n\tvec3 cosineWeightedIrradiance = irradiance * RECIPROCAL_PI;\n\n\tBRDF_Specular_Multiscattering_Environment( geometry, material.specularColor, material.specularRoughness, singleScattering, multiScattering );\n\n\tvec3 diffuse = material.diffuseColor * ( 1.0 - ( singleScattering + multiScattering ) );\n\n\treflectedLight.indirectSpecular += clearcoatInv * radiance * singleScattering;\n\treflectedLight.indirectSpecular += multiScattering * cosineWeightedIrradiance;\n\n\treflectedLight.indirectDiffuse += diffuse * cosineWeightedIrradiance;\n\n}\n\n#define RE_Direct\t\t\t\tRE_Direct_Physical\n#define RE_Direct_RectArea\t\tRE_Direct_RectArea_Physical\n#define RE_IndirectDiffuse\t\tRE_IndirectDiffuse_Physical\n#define RE_IndirectSpecular\t\tRE_IndirectSpecular_Physical\n\n// ref: https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf\nfloat computeSpecularOcclusion( const in float dotNV, const in float ambientOcclusion, const in float roughness ) {\n\n\treturn saturate( pow( dotNV + ambientOcclusion, exp2( - 16.0 * roughness - 1.0 ) ) - 1.0 + ambientOcclusion );\n\n}\n`;\n","export default /* glsl */`\n/**\n * This is a template that can be used to light a material, it uses pluggable\n * RenderEquations (RE)for specific lighting scenarios.\n *\n * Instructions for use:\n * - Ensure that both RE_Direct, RE_IndirectDiffuse and RE_IndirectSpecular are defined\n * - If you have defined an RE_IndirectSpecular, you need to also provide a Material_LightProbeLOD. <---- ???\n * - Create a material parameter that is to be passed as the third parameter to your lighting functions.\n *\n * TODO:\n * - Add area light support.\n * - Add sphere light support.\n * - Add diffuse light probe (irradiance cubemap) support.\n */\n\nGeometricContext geometry;\n\ngeometry.position = - vViewPosition;\ngeometry.normal = normal;\ngeometry.viewDir = ( isOrthographic ) ? vec3( 0, 0, 1 ) : normalize( vViewPosition );\n\n#ifdef CLEARCOAT\n\n\tgeometry.clearcoatNormal = clearcoatNormal;\n\n#endif\n\nIncidentLight directLight;\n\n#if ( NUM_POINT_LIGHTS > 0 ) && defined( RE_Direct )\n\n\tPointLight pointLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_POINT_LIGHT_SHADOWS > 0\n\tPointLightShadow pointLightShadow;\n\t#endif\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\n\t\tpointLight = pointLights[ i ];\n\n\t\tgetPointDirectLightIrradiance( pointLight, geometry, directLight );\n\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_POINT_LIGHT_SHADOWS )\n\t\tpointLightShadow = pointLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getPointShadow( pointShadowMap[ i ], pointLightShadow.shadowMapSize, pointLightShadow.shadowBias, pointLightShadow.shadowRadius, vPointShadowCoord[ i ], pointLightShadow.shadowCameraNear, pointLightShadow.shadowCameraFar ) : 1.0;\n\t\t#endif\n\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if ( NUM_SPOT_LIGHTS > 0 ) && defined( RE_Direct )\n\n\tSpotLight spotLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_SPOT_LIGHT_SHADOWS > 0\n\tSpotLightShadow spotLightShadow;\n\t#endif\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\n\t\tspotLight = spotLights[ i ];\n\n\t\tgetSpotDirectLightIrradiance( spotLight, geometry, directLight );\n\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )\n\t\tspotLightShadow = spotLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if ( NUM_DIR_LIGHTS > 0 ) && defined( RE_Direct )\n\n\tDirectionalLight directionalLight;\n\t#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0\n\tDirectionalLightShadow directionalLightShadow;\n\t#endif\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\n\t\tdirectionalLight = directionalLights[ i ];\n\n\t\tgetDirectionalDirectLightIrradiance( directionalLight, geometry, directLight );\n\n\t\t#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )\n\t\tdirectionalLightShadow = directionalLightShadows[ i ];\n\t\tdirectLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( directionalShadowMap[ i ], directionalLightShadow.shadowMapSize, directionalLightShadow.shadowBias, directionalLightShadow.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t\t#endif\n\n\t\tRE_Direct( directLight, geometry, material, reflectedLight );\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if ( NUM_RECT_AREA_LIGHTS > 0 ) && defined( RE_Direct_RectArea )\n\n\tRectAreaLight rectAreaLight;\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_RECT_AREA_LIGHTS; i ++ ) {\n\n\t\trectAreaLight = rectAreaLights[ i ];\n\t\tRE_Direct_RectArea( rectAreaLight, geometry, material, reflectedLight );\n\n\t}\n\t#pragma unroll_loop_end\n\n#endif\n\n#if defined( RE_IndirectDiffuse )\n\n\tvec3 iblIrradiance = vec3( 0.0 );\n\n\tvec3 irradiance = getAmbientLightIrradiance( ambientLightColor );\n\n\tirradiance += getLightProbeIrradiance( lightProbe, geometry );\n\n\t#if ( NUM_HEMI_LIGHTS > 0 )\n\n\t\t#pragma unroll_loop_start\n\t\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\n\t\t\tirradiance += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\n\t\t}\n\t\t#pragma unroll_loop_end\n\n\t#endif\n\n#endif\n\n#if defined( RE_IndirectSpecular )\n\n\tvec3 radiance = vec3( 0.0 );\n\tvec3 clearcoatRadiance = vec3( 0.0 );\n\n#endif\n`;\n","export default /* glsl */`\n#if defined( RE_IndirectDiffuse )\n\n\t#ifdef USE_LIGHTMAP\n\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\tvec3 lightMapIrradiance = lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\n\t\t\tlightMapIrradiance *= PI; // factor of PI should not be present; included here to prevent breakage\n\n\t\t#endif\n\n\t\tirradiance += lightMapIrradiance;\n\n\t#endif\n\n\t#if defined( USE_ENVMAP ) && defined( STANDARD ) && defined( ENVMAP_TYPE_CUBE_UV )\n\n\t\tiblIrradiance += getLightProbeIndirectIrradiance( /*lightProbe,*/ geometry, maxMipLevel );\n\n\t#endif\n\n#endif\n\n#if defined( USE_ENVMAP ) && defined( RE_IndirectSpecular )\n\n\tradiance += getLightProbeIndirectRadiance( /*specularLightProbe,*/ geometry.viewDir, geometry.normal, material.specularRoughness, maxMipLevel );\n\n\t#ifdef CLEARCOAT\n\n\t\tclearcoatRadiance += getLightProbeIndirectRadiance( /*specularLightProbe,*/ geometry.viewDir, geometry.clearcoatNormal, material.clearcoatRoughness, maxMipLevel );\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n#if defined( RE_IndirectDiffuse )\n\n\tRE_IndirectDiffuse( irradiance, geometry, material, reflectedLight );\n\n#endif\n\n#if defined( RE_IndirectSpecular )\n\n\tRE_IndirectSpecular( radiance, iblIrradiance, clearcoatRadiance, geometry, material, reflectedLight );\n\n#endif\n`;\n","export default /* glsl */`\n#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\n\t// Doing a strict comparison with == 1.0 can cause noise artifacts\n\t// on some platforms. See issue #17623.\n\tgl_FragDepthEXT = vIsPerspective == 0.0 ? gl_FragCoord.z : log2( vFragDepth ) * logDepthBufFC * 0.5;\n\n#endif\n`;\n","export default /* glsl */`\n#if defined( USE_LOGDEPTHBUF ) && defined( USE_LOGDEPTHBUF_EXT )\n\n\tuniform float logDepthBufFC;\n\tvarying float vFragDepth;\n\tvarying float vIsPerspective;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_LOGDEPTHBUF\n\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\n\t\tvarying float vFragDepth;\n\t\tvarying float vIsPerspective;\n\n\t#else\n\n\t\tuniform float logDepthBufFC;\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_LOGDEPTHBUF\n\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t\tvIsPerspective = float( isPerspectiveMatrix( projectionMatrix ) );\n\n\t#else\n\n\t\tif ( isPerspectiveMatrix( projectionMatrix ) ) {\n\n\t\t\tgl_Position.z = log2( max( EPSILON, gl_Position.w + 1.0 ) ) * logDepthBufFC - 1.0;\n\n\t\t\tgl_Position.z *= gl_Position.w;\n\n\t\t}\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_MAP\n\n\tvec4 texelColor = texture2D( map, vUv );\n\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_MAP\n\n\tuniform sampler2D map;\n\n#endif\n`;\n","export default /* glsl */`\n#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\n\tvec2 uv = ( uvTransform * vec3( gl_PointCoord.x, 1.0 - gl_PointCoord.y, 1 ) ).xy;\n\n#endif\n\n#ifdef USE_MAP\n\n\tvec4 mapTexel = texture2D( map, uv );\n\tdiffuseColor *= mapTexelToLinear( mapTexel );\n\n#endif\n\n#ifdef USE_ALPHAMAP\n\n\tdiffuseColor.a *= texture2D( alphaMap, uv ).g;\n\n#endif\n`;\n","export default /* glsl */`\n#if defined( USE_MAP ) || defined( USE_ALPHAMAP )\n\n\tuniform mat3 uvTransform;\n\n#endif\n\n#ifdef USE_MAP\n\n\tuniform sampler2D map;\n\n#endif\n\n#ifdef USE_ALPHAMAP\n\n\tuniform sampler2D alphaMap;\n\n#endif\n`;\n","export default /* glsl */`\nfloat metalnessFactor = metalness;\n\n#ifdef USE_METALNESSMAP\n\n\tvec4 texelMetalness = texture2D( metalnessMap, vUv );\n\n\t// reads channel B, compatible with a combined OcclusionRoughnessMetallic (RGB) texture\n\tmetalnessFactor *= texelMetalness.b;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_METALNESSMAP\n\n\tuniform sampler2D metalnessMap;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_MORPHNORMALS\n\n\t// morphTargetBaseInfluence is set based on BufferGeometry.morphTargetsRelative value:\n\t// When morphTargetsRelative is false, this is set to 1 - sum(influences); this results in normal = sum((target - base) * influence)\n\t// When morphTargetsRelative is true, this is set to 1; as a result, all morph targets are simply added to the base after weighting\n\tobjectNormal *= morphTargetBaseInfluence;\n\tobjectNormal += morphNormal0 * morphTargetInfluences[ 0 ];\n\tobjectNormal += morphNormal1 * morphTargetInfluences[ 1 ];\n\tobjectNormal += morphNormal2 * morphTargetInfluences[ 2 ];\n\tobjectNormal += morphNormal3 * morphTargetInfluences[ 3 ];\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_MORPHTARGETS\n\n\tuniform float morphTargetBaseInfluence;\n\n\t#ifndef USE_MORPHNORMALS\n\n\tuniform float morphTargetInfluences[ 8 ];\n\n\t#else\n\n\tuniform float morphTargetInfluences[ 4 ];\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_MORPHTARGETS\n\n\t// morphTargetBaseInfluence is set based on BufferGeometry.morphTargetsRelative value:\n\t// When morphTargetsRelative is false, this is set to 1 - sum(influences); this results in position = sum((target - base) * influence)\n\t// When morphTargetsRelative is true, this is set to 1; as a result, all morph targets are simply added to the base after weighting\n\ttransformed *= morphTargetBaseInfluence;\n\ttransformed += morphTarget0 * morphTargetInfluences[ 0 ];\n\ttransformed += morphTarget1 * morphTargetInfluences[ 1 ];\n\ttransformed += morphTarget2 * morphTargetInfluences[ 2 ];\n\ttransformed += morphTarget3 * morphTargetInfluences[ 3 ];\n\n\t#ifndef USE_MORPHNORMALS\n\n\ttransformed += morphTarget4 * morphTargetInfluences[ 4 ];\n\ttransformed += morphTarget5 * morphTargetInfluences[ 5 ];\n\ttransformed += morphTarget6 * morphTargetInfluences[ 6 ];\n\ttransformed += morphTarget7 * morphTargetInfluences[ 7 ];\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef FLAT_SHADED\n\n\t// Workaround for Adreno/Nexus5 not able able to do dFdx( vViewPosition ) ...\n\n\tvec3 fdx = vec3( dFdx( vViewPosition.x ), dFdx( vViewPosition.y ), dFdx( vViewPosition.z ) );\n\tvec3 fdy = vec3( dFdy( vViewPosition.x ), dFdy( vViewPosition.y ), dFdy( vViewPosition.z ) );\n\tvec3 normal = normalize( cross( fdx, fdy ) );\n\n#else\n\n\tvec3 normal = normalize( vNormal );\n\n\t#ifdef DOUBLE_SIDED\n\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\n\t#endif\n\n\t#ifdef USE_TANGENT\n\n\t\tvec3 tangent = normalize( vTangent );\n\t\tvec3 bitangent = normalize( vBitangent );\n\n\t\t#ifdef DOUBLE_SIDED\n\n\t\t\ttangent = tangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t\tbitangent = bitangent * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\n\t\t#endif\n\n\t\t#if defined( TANGENTSPACE_NORMALMAP ) || defined( USE_CLEARCOAT_NORMALMAP )\n\n\t\t\tmat3 vTBN = mat3( tangent, bitangent, normal );\n\n\t\t#endif\n\n\t#endif\n\n#endif\n\n// non perturbed normal for clearcoat among others\n\nvec3 geometryNormal = normal;\n\n`;\n","export default /* glsl */`\n\n#ifdef OBJECTSPACE_NORMALMAP\n\n\tnormal = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0; // overrides both flatShading and attribute normals\n\n\t#ifdef FLIP_SIDED\n\n\t\tnormal = - normal;\n\n\t#endif\n\n\t#ifdef DOUBLE_SIDED\n\n\t\tnormal = normal * ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\n\t#endif\n\n\tnormal = normalize( normalMatrix * normal );\n\n#elif defined( TANGENTSPACE_NORMALMAP )\n\n\tvec3 mapN = texture2D( normalMap, vUv ).xyz * 2.0 - 1.0;\n\tmapN.xy *= normalScale;\n\n\t#ifdef USE_TANGENT\n\n\t\tnormal = normalize( vTBN * mapN );\n\n\t#else\n\n\t\tnormal = perturbNormal2Arb( -vViewPosition, normal, mapN );\n\n\t#endif\n\n#elif defined( USE_BUMPMAP )\n\n\tnormal = perturbNormalArb( -vViewPosition, normal, dHdxy_fwd() );\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_NORMALMAP\n\n\tuniform sampler2D normalMap;\n\tuniform vec2 normalScale;\n\n#endif\n\n#ifdef OBJECTSPACE_NORMALMAP\n\n\tuniform mat3 normalMatrix;\n\n#endif\n\n#if ! defined ( USE_TANGENT ) && ( defined ( TANGENTSPACE_NORMALMAP ) || defined ( USE_CLEARCOAT_NORMALMAP ) )\n\n\t// Per-Pixel Tangent Space Normal Mapping\n\t// http://hacksoflife.blogspot.ch/2009/11/per-pixel-tangent-space-normal-mapping.html\n\n\tvec3 perturbNormal2Arb( vec3 eye_pos, vec3 surf_norm, vec3 mapN ) {\n\n\t\t// Workaround for Adreno 3XX dFd*( vec3 ) bug. See #9988\n\n\t\tvec3 q0 = vec3( dFdx( eye_pos.x ), dFdx( eye_pos.y ), dFdx( eye_pos.z ) );\n\t\tvec3 q1 = vec3( dFdy( eye_pos.x ), dFdy( eye_pos.y ), dFdy( eye_pos.z ) );\n\t\tvec2 st0 = dFdx( vUv.st );\n\t\tvec2 st1 = dFdy( vUv.st );\n\n\t\tfloat scale = sign( st1.t * st0.s - st0.t * st1.s ); // we do not care about the magnitude\n\n\t\tvec3 S = normalize( ( q0 * st1.t - q1 * st0.t ) * scale );\n\t\tvec3 T = normalize( ( - q0 * st1.s + q1 * st0.s ) * scale );\n\t\tvec3 N = normalize( surf_norm );\n\n\t\tmat3 tsn = mat3( S, T, N );\n\n\t\tmapN.xy *= ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\n\t\treturn normalize( tsn * mapN );\n\n\t}\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef CLEARCOAT\n\n\tvec3 clearcoatNormal = geometryNormal;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_CLEARCOAT_NORMALMAP\n\n\tvec3 clearcoatMapN = texture2D( clearcoatNormalMap, vUv ).xyz * 2.0 - 1.0;\n\tclearcoatMapN.xy *= clearcoatNormalScale;\n\n\t#ifdef USE_TANGENT\n\n\t\tclearcoatNormal = normalize( vTBN * clearcoatMapN );\n\n\t#else\n\n\t\tclearcoatNormal = perturbNormal2Arb( - vViewPosition, clearcoatNormal, clearcoatMapN );\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n\n#ifdef USE_CLEARCOATMAP\n\n\tuniform sampler2D clearcoatMap;\n\n#endif\n\n#ifdef USE_CLEARCOAT_ROUGHNESSMAP\n\n\tuniform sampler2D clearcoatRoughnessMap;\n\n#endif\n\n#ifdef USE_CLEARCOAT_NORMALMAP\n\n\tuniform sampler2D clearcoatNormalMap;\n\tuniform vec2 clearcoatNormalScale;\n\n#endif\n`;\n","export default /* glsl */`\nvec3 packNormalToRGB( const in vec3 normal ) {\n\treturn normalize( normal ) * 0.5 + 0.5;\n}\n\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n\treturn 2.0 * rgb.xyz - 1.0;\n}\n\nconst float PackUpscale = 256. / 255.; // fraction -> 0..1 (including 1)\nconst float UnpackDownscale = 255. / 256.; // 0..1 -> fraction (excluding 1)\n\nconst vec3 PackFactors = vec3( 256. * 256. * 256., 256. * 256., 256. );\nconst vec4 UnpackFactors = UnpackDownscale / vec4( PackFactors, 1. );\n\nconst float ShiftRight8 = 1. / 256.;\n\nvec4 packDepthToRGBA( const in float v ) {\n\tvec4 r = vec4( fract( v * PackFactors ), v );\n\tr.yzw -= r.xyz * ShiftRight8; // tidy overflow\n\treturn r * PackUpscale;\n}\n\nfloat unpackRGBAToDepth( const in vec4 v ) {\n\treturn dot( v, UnpackFactors );\n}\n\nvec4 pack2HalfToRGBA( vec2 v ) {\n\tvec4 r = vec4( v.x, fract( v.x * 255.0 ), v.y, fract( v.y * 255.0 ));\n\treturn vec4( r.x - r.y / 255.0, r.y, r.z - r.w / 255.0, r.w);\n}\nvec2 unpackRGBATo2Half( vec4 v ) {\n\treturn vec2( v.x + ( v.y / 255.0 ), v.z + ( v.w / 255.0 ) );\n}\n\n// NOTE: viewZ/eyeZ is < 0 when in front of the camera per OpenGL conventions\n\nfloat viewZToOrthographicDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn ( viewZ + near ) / ( near - far );\n}\nfloat orthographicDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n\treturn linearClipZ * ( near - far ) - near;\n}\n\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n\treturn (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n\treturn ( near * far ) / ( ( far - near ) * invClipZ - far );\n}\n`;\n","export default /* glsl */`\n#ifdef PREMULTIPLIED_ALPHA\n\n\t// Get get normal blending with premultipled, use with CustomBlending, OneFactor, OneMinusSrcAlphaFactor, AddEquation.\n\tgl_FragColor.rgb *= gl_FragColor.a;\n\n#endif\n`;\n","export default /* glsl */`\nvec4 mvPosition = vec4( transformed, 1.0 );\n\n#ifdef USE_INSTANCING\n\n\tmvPosition = instanceMatrix * mvPosition;\n\n#endif\n\nmvPosition = modelViewMatrix * mvPosition;\n\ngl_Position = projectionMatrix * mvPosition;\n`;\n","export default /* glsl */`\n#ifdef DITHERING\n\n\tgl_FragColor.rgb = dithering( gl_FragColor.rgb );\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef DITHERING\n\n\t// based on https://www.shadertoy.com/view/MslGR8\n\tvec3 dithering( vec3 color ) {\n\t\t//Calculate grid position\n\t\tfloat grid_position = rand( gl_FragCoord.xy );\n\n\t\t//Shift the individual colors differently, thus making it even harder to see the dithering pattern\n\t\tvec3 dither_shift_RGB = vec3( 0.25 / 255.0, -0.25 / 255.0, 0.25 / 255.0 );\n\n\t\t//modify shift acording to grid position.\n\t\tdither_shift_RGB = mix( 2.0 * dither_shift_RGB, -2.0 * dither_shift_RGB, grid_position );\n\n\t\t//shift the color by dither_shift\n\t\treturn color + dither_shift_RGB;\n\t}\n\n#endif\n`;\n","export default /* glsl */`\nfloat roughnessFactor = roughness;\n\n#ifdef USE_ROUGHNESSMAP\n\n\tvec4 texelRoughness = texture2D( roughnessMap, vUv );\n\n\t// reads channel G, compatible with a combined OcclusionRoughnessMetallic (RGB) texture\n\troughnessFactor *= texelRoughness.g;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_ROUGHNESSMAP\n\n\tuniform sampler2D roughnessMap;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_SHADOWMAP\n\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\n\t#endif\n\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\n\t#endif\n\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\n\t#endif\n\n\t/*\n\t#if NUM_RECT_AREA_LIGHTS > 0\n\n\t\t// TODO (abelnation): create uniforms for area light shadows\n\n\t#endif\n\t*/\n\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\n\t}\n\n\tvec2 texture2DDistribution( sampler2D shadow, vec2 uv ) {\n\n\t\treturn unpackRGBATo2Half( texture2D( shadow, uv ) );\n\n\t}\n\n\tfloat VSMShadow (sampler2D shadow, vec2 uv, float compare ){\n\n\t\tfloat occlusion = 1.0;\n\n\t\tvec2 distribution = texture2DDistribution( shadow, uv );\n\n\t\tfloat hard_shadow = step( compare , distribution.x ); // Hard Shadow\n\n\t\tif (hard_shadow != 1.0 ) {\n\n\t\t\tfloat distance = compare - distribution.x ;\n\t\t\tfloat variance = max( 0.00000, distribution.y * distribution.y );\n\t\t\tfloat softness_probability = variance / (variance + distance * distance ); // Chebeyshevs inequality\n\t\t\tsoftness_probability = clamp( ( softness_probability - 0.3 ) / ( 0.95 - 0.3 ), 0.0, 1.0 ); // 0.3 reduces light bleed\n\t\t\tocclusion = clamp( max( hard_shadow, softness_probability ), 0.0, 1.0 );\n\n\t\t}\n\t\treturn occlusion;\n\n\t}\n\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\n\t\tfloat shadow = 1.0;\n\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\n\t\t// if ( something && something ) breaks ATI OpenGL shader compiler\n\t\t// if ( all( something, something ) ) using this instead\n\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\n\t\tbool frustumTest = all( frustumTestVec );\n\n\t\tif ( frustumTest ) {\n\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\tfloat dx2 = dx0 / 2.0;\n\t\t\tfloat dy2 = dy0 / 2.0;\n\t\t\tfloat dx3 = dx1 / 2.0;\n\t\t\tfloat dy3 = dy1 / 2.0;\n\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy2 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx2, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx3, dy3 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 17.0 );\n\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx = texelSize.x;\n\t\t\tfloat dy = texelSize.y;\n\n\t\t\tvec2 uv = shadowCoord.xy;\n\t\t\tvec2 f = fract( uv * shadowMapSize + 0.5 );\n\t\t\tuv -= f * texelSize;\n\n\t\t\tshadow = (\n\t\t\t\ttexture2DCompare( shadowMap, uv, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( dx, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + vec2( 0.0, dy ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, uv + texelSize, shadowCoord.z ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, 0.0 ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 0.0 ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( -dx, dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, dy ), shadowCoord.z ),\n\t\t\t\t\t f.x ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( 0.0, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 0.0, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( texture2DCompare( shadowMap, uv + vec2( dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t f.y ) +\n\t\t\t\tmix( mix( texture2DCompare( shadowMap, uv + vec2( -dx, -dy ), shadowCoord.z ), \n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, -dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t mix( texture2DCompare( shadowMap, uv + vec2( -dx, 2.0 * dy ), shadowCoord.z ), \n\t\t\t\t\t\t texture2DCompare( shadowMap, uv + vec2( 2.0 * dx, 2.0 * dy ), shadowCoord.z ),\n\t\t\t\t\t\t f.x ),\n\t\t\t\t\t f.y )\n\t\t\t) * ( 1.0 / 9.0 );\n\n\t\t#elif defined( SHADOWMAP_TYPE_VSM )\n\n\t\t\tshadow = VSMShadow( shadowMap, shadowCoord.xy, shadowCoord.z );\n\n\t\t#else // no percentage-closer filtering:\n\n\t\t\tshadow = texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\n\t\t#endif\n\n\t\t}\n\n\t\treturn shadow;\n\n\t}\n\n\t// cubeToUV() maps a 3D direction vector suitable for cube texture mapping to a 2D\n\t// vector suitable for 2D texture mapping. This code uses the following layout for the\n\t// 2D texture:\n\t//\n\t// xzXZ\n\t// y Y\n\t//\n\t// Y - Positive y direction\n\t// y - Negative y direction\n\t// X - Positive x direction\n\t// x - Negative x direction\n\t// Z - Positive z direction\n\t// z - Negative z direction\n\t//\n\t// Source and test bed:\n\t// https://gist.github.com/tschw/da10c43c467ce8afd0c4\n\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\n\t\t// Number of texels to avoid at the edge of each square\n\n\t\tvec3 absV = abs( v );\n\n\t\t// Intersect unit cube\n\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\n\t\t// Apply scale to avoid seams\n\n\t\t// two texels less per square (one texel will do for NEAREST)\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\n\t\t// Unwrap\n\n\t\t// space: -1 ... 1 range for each square\n\t\t//\n\t\t// #X##\t\tdim := ( 4 , 2 )\n\t\t// # #\t\tcenter := ( 1 , 1 )\n\n\t\tvec2 planar = v.xy;\n\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\n\t\tif ( absV.z >= almostOne ) {\n\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\n\t\t} else if ( absV.x >= almostOne ) {\n\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\n\t\t} else if ( absV.y >= almostOne ) {\n\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\n\t\t}\n\n\t\t// Transform to UV space\n\n\t\t// scale := 0.5 / dim\n\t\t// translate := ( center + 0.5 ) / dim\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\n\t}\n\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord, float shadowCameraNear, float shadowCameraFar ) {\n\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\n\t\t// for point lights, the uniform @vShadowCoord is re-purposed to hold\n\t\t// the vector from the light to the world-space position of the fragment.\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\n\t\t// dp = normalized distance from light to fragment position\n\t\tfloat dp = ( length( lightToPosition ) - shadowCameraNear ) / ( shadowCameraFar - shadowCameraNear ); // need to clamp?\n\t\tdp += shadowBias;\n\n\t\t// bd3D = base direction 3D\n\t\tvec3 bd3D = normalize( lightToPosition );\n\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT ) || defined( SHADOWMAP_TYPE_VSM )\n\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\n\t\t#else // no percentage-closer filtering\n\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\n\t\t#endif\n\n\t}\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_SHADOWMAP\n\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHT_SHADOWS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHT_SHADOWS ];\n\n\t\tstruct DirectionalLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\n\t\tuniform DirectionalLightShadow directionalLightShadows[ NUM_DIR_LIGHT_SHADOWS ];\n\n\t#endif\n\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHT_SHADOWS ];\n\n\t\tstruct SpotLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t};\n\n\t\tuniform SpotLightShadow spotLightShadows[ NUM_SPOT_LIGHT_SHADOWS ];\n\n\t#endif\n\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHT_SHADOWS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHT_SHADOWS ];\n\n\t\tstruct PointLightShadow {\n\t\t\tfloat shadowBias;\n\t\t\tfloat shadowNormalBias;\n\t\t\tfloat shadowRadius;\n\t\t\tvec2 shadowMapSize;\n\t\t\tfloat shadowCameraNear;\n\t\t\tfloat shadowCameraFar;\n\t\t};\n\n\t\tuniform PointLightShadow pointLightShadows[ NUM_POINT_LIGHT_SHADOWS ];\n\n\t#endif\n\n\t/*\n\t#if NUM_RECT_AREA_LIGHTS > 0\n\n\t\t// TODO (abelnation): uniforms for area light shadows\n\n\t#endif\n\t*/\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_SHADOWMAP\n\n\t#if NUM_DIR_LIGHT_SHADOWS > 0 || NUM_SPOT_LIGHT_SHADOWS > 0 || NUM_POINT_LIGHT_SHADOWS > 0\n\n\t\t// Offsetting the position used for querying occlusion along the world normal can be used to reduce shadow acne.\n\t\tvec3 shadowWorldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\tvec4 shadowWorldPosition;\n\n\t#endif\n\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * directionalLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * shadowWorldPosition;\n\n\t}\n\t#pragma unroll_loop_end\n\n\t#endif\n\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * spotLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * shadowWorldPosition;\n\n\t}\n\t#pragma unroll_loop_end\n\n\t#endif\n\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\n\t\tshadowWorldPosition = worldPosition + vec4( shadowWorldNormal * pointLightShadows[ i ].shadowNormalBias, 0 );\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * shadowWorldPosition;\n\n\t}\n\t#pragma unroll_loop_end\n\n\t#endif\n\n\t/*\n\t#if NUM_RECT_AREA_LIGHTS > 0\n\n\t\t// TODO (abelnation): update vAreaShadowCoord with area light info\n\n\t#endif\n\t*/\n\n#endif\n`;\n","export default /* glsl */`\nfloat getShadowMask() {\n\n\tfloat shadow = 1.0;\n\n\t#ifdef USE_SHADOWMAP\n\n\t#if NUM_DIR_LIGHT_SHADOWS > 0\n\n\tDirectionalLightShadow directionalLight;\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_DIR_LIGHT_SHADOWS; i ++ ) {\n\n\t\tdirectionalLight = directionalLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\n\t}\n\t#pragma unroll_loop_end\n\n\t#endif\n\n\t#if NUM_SPOT_LIGHT_SHADOWS > 0\n\n\tSpotLightShadow spotLight;\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_SPOT_LIGHT_SHADOWS; i ++ ) {\n\n\t\tspotLight = spotLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\n\t}\n\t#pragma unroll_loop_end\n\n\t#endif\n\n\t#if NUM_POINT_LIGHT_SHADOWS > 0\n\n\tPointLightShadow pointLight;\n\n\t#pragma unroll_loop_start\n\tfor ( int i = 0; i < NUM_POINT_LIGHT_SHADOWS; i ++ ) {\n\n\t\tpointLight = pointLightShadows[ i ];\n\t\tshadow *= receiveShadow ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ], pointLight.shadowCameraNear, pointLight.shadowCameraFar ) : 1.0;\n\n\t}\n\t#pragma unroll_loop_end\n\n\t#endif\n\n\t/*\n\t#if NUM_RECT_AREA_LIGHTS > 0\n\n\t\t// TODO (abelnation): update shadow for Area light\n\n\t#endif\n\t*/\n\n\t#endif\n\n\treturn shadow;\n\n}\n`;\n","export default /* glsl */`\n#ifdef USE_SKINNING\n\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_SKINNING\n\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\n\t#ifdef BONE_TEXTURE\n\n\t\tuniform highp sampler2D boneTexture;\n\t\tuniform int boneTextureSize;\n\n\t\tmat4 getBoneMatrix( const in float i ) {\n\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureSize ) );\n\t\t\tfloat y = floor( j / float( boneTextureSize ) );\n\n\t\t\tfloat dx = 1.0 / float( boneTextureSize );\n\t\t\tfloat dy = 1.0 / float( boneTextureSize );\n\n\t\t\ty = dy * ( y + 0.5 );\n\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\n\t\t\treturn bone;\n\n\t\t}\n\n\t#else\n\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\n\t\tmat4 getBoneMatrix( const in float i ) {\n\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\n\t\t}\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_SKINNING\n\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\n\ttransformed = ( bindMatrixInverse * skinned ).xyz;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_SKINNING\n\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n\n\t#ifdef USE_TANGENT\n\n\t\tobjectTangent = vec4( skinMatrix * vec4( objectTangent, 0.0 ) ).xyz;\n\n\t#endif\n\n#endif\n`;\n","export default /* glsl */`\nfloat specularStrength;\n\n#ifdef USE_SPECULARMAP\n\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n\n#else\n\n\tspecularStrength = 1.0;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_SPECULARMAP\n\n\tuniform sampler2D specularMap;\n\n#endif\n`;\n","export default /* glsl */`\n#if defined( TONE_MAPPING )\n\n\tgl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n\n#endif\n`;\n","export default /* glsl */`\n#ifndef saturate\n// may have defined saturate() already\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#endif\n\nuniform float toneMappingExposure;\n\n// exposure only\nvec3 LinearToneMapping( vec3 color ) {\n\n\treturn toneMappingExposure * color;\n\n}\n\n// source: https://www.cs.utah.edu/~reinhard/cdrom/\nvec3 ReinhardToneMapping( vec3 color ) {\n\n\tcolor *= toneMappingExposure;\n\treturn saturate( color / ( vec3( 1.0 ) + color ) );\n\n}\n\n// source: http://filmicworlds.com/blog/filmic-tonemapping-operators/\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n\n\t// optimized filmic operator by Jim Hejl and Richard Burgess-Dawson\n\tcolor *= toneMappingExposure;\n\tcolor = max( vec3( 0.0 ), color - 0.004 );\n\treturn pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n\n}\n\n// source: https://github.com/selfshadow/ltc_code/blob/master/webgl/shaders/ltc/ltc_blit.fs\nvec3 RRTAndODTFit( vec3 v ) {\n\n\tvec3 a = v * ( v + 0.0245786 ) - 0.000090537;\n\tvec3 b = v * ( 0.983729 * v + 0.4329510 ) + 0.238081;\n\treturn a / b;\n\n}\n\n// this implementation of ACES is modified to accommodate a brighter viewing environment.\n// the scale factor of 1/0.6 is subjective. see discussion in #19621.\n\nvec3 ACESFilmicToneMapping( vec3 color ) {\n\n\t// sRGB => XYZ => D65_2_D60 => AP1 => RRT_SAT\n\tconst mat3 ACESInputMat = mat3(\n\t\tvec3( 0.59719, 0.07600, 0.02840 ), // transposed from source\n\t\tvec3( 0.35458, 0.90834, 0.13383 ),\n\t\tvec3( 0.04823, 0.01566, 0.83777 )\n\t);\n\n\t// ODT_SAT => XYZ => D60_2_D65 => sRGB\n\tconst mat3 ACESOutputMat = mat3(\n\t\tvec3( 1.60475, -0.10208, -0.00327 ), // transposed from source\n\t\tvec3( -0.53108, 1.10813, -0.07276 ),\n\t\tvec3( -0.07367, -0.00605, 1.07602 )\n\t);\n\n\tcolor *= toneMappingExposure / 0.6;\n\n\tcolor = ACESInputMat * color;\n\n\t// Apply RRT and ODT\n\tcolor = RRTAndODTFit( color );\n\n\tcolor = ACESOutputMat * color;\n\n\t// Clamp to [0, 1]\n\treturn saturate( color );\n\n}\n\nvec3 CustomToneMapping( vec3 color ) { return color; }\n`;\n","export default /* glsl */`\n#if ( defined( USE_UV ) && ! defined( UVS_VERTEX_ONLY ) )\n\n\tvarying vec2 vUv;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_UV\n\n\t#ifdef UVS_VERTEX_ONLY\n\n\t\tvec2 vUv;\n\n\t#else\n\n\t\tvarying vec2 vUv;\n\n\t#endif\n\n\tuniform mat3 uvTransform;\n\n#endif\n`;\n","export default /* glsl */`\n#ifdef USE_UV\n\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\n#endif\n`;\n","export default /* glsl */`\n#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\n\tvarying vec2 vUv2;\n\n#endif\n`;\n","export default /* glsl */`\n#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n\n\tuniform mat3 uv2Transform;\n\n#endif\n`;\n","export default /* glsl */`\n#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\n\tvUv2 = ( uv2Transform * vec3( uv2, 1 ) ).xy;\n\n#endif\n`;\n","export default /* glsl */`\n#if defined( USE_ENVMAP ) || defined( DISTANCE ) || defined ( USE_SHADOWMAP )\n\n\tvec4 worldPosition = vec4( transformed, 1.0 );\n\n\t#ifdef USE_INSTANCING\n\n\t\tworldPosition = instanceMatrix * worldPosition;\n\n\t#endif\n\n\tworldPosition = modelMatrix * worldPosition;\n\n#endif\n`;\n","export default /* glsl */`\nuniform sampler2D t2D;\n\nvarying vec2 vUv;\n\nvoid main() {\n\n\tvec4 texColor = texture2D( t2D, vUv );\n\n\tgl_FragColor = mapTexelToLinear( texColor );\n\n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\nvarying vec2 vUv;\nuniform mat3 uvTransform;\n\nvoid main() {\n\n\tvUv = ( uvTransform * vec3( uv, 1 ) ).xy;\n\n\tgl_Position = vec4( position.xy, 1.0, 1.0 );\n\n}\n`;\n","export default /* glsl */`\n#include \nuniform float opacity;\n\nvarying vec3 vWorldDirection;\n\n#include \n\nvoid main() {\n\n\tvec3 vReflect = vWorldDirection;\n\t#include \n\n\tgl_FragColor = envColor;\n\tgl_FragColor.a *= opacity;\n\n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\nvarying vec3 vWorldDirection;\n\n#include \n\nvoid main() {\n\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t#include \n\t#include \n\n\tgl_Position.z = gl_Position.w; // set z to camera.far\n\n}\n`;\n","export default /* glsl */`\n#if DEPTH_PACKING == 3200\n\n\tuniform float opacity;\n\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvarying vec2 vHighPrecisionZW;\n\nvoid main() {\n\n\t#include \n\n\tvec4 diffuseColor = vec4( 1.0 );\n\n\t#if DEPTH_PACKING == 3200\n\n\t\tdiffuseColor.a = opacity;\n\n\t#endif\n\n\t#include \n\t#include \n\t#include \n\n\t#include \n\n\t// Higher precision equivalent of gl_FragCoord.z. This assumes depthRange has been left to its default values.\n\tfloat fragCoordZ = 0.5 * vHighPrecisionZW[0] / vHighPrecisionZW[1] + 0.5;\n\n\t#if DEPTH_PACKING == 3200\n\n\t\tgl_FragColor = vec4( vec3( 1.0 - fragCoordZ ), opacity );\n\n\t#elif DEPTH_PACKING == 3201\n\n\t\tgl_FragColor = packDepthToRGBA( fragCoordZ );\n\n\t#endif\n\n}\n`;\n","export default /* glsl */`\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n// This is used for computing an equivalent of gl_FragCoord.z that is as high precision as possible.\n// Some platforms compute gl_FragCoord at a lower precision which makes the manually computed value better for\n// depth-based postprocessing effects. Reproduced on iPad with A10 processor / iPadOS 13.3.1.\nvarying vec2 vHighPrecisionZW;\n\nvoid main() {\n\n\t#include \n\n\t#include \n\n\t#ifdef USE_DISPLACEMENTMAP\n\n\t\t#include \n\t\t#include \n\t\t#include \n\n\t#endif\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\tvHighPrecisionZW = gl_Position.zw;\n\n}\n`;\n","export default /* glsl */`\n#define DISTANCE\n\nuniform vec3 referencePosition;\nuniform float nearDistance;\nuniform float farDistance;\nvarying vec3 vWorldPosition;\n\n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main () {\n\n\t#include \n\n\tvec4 diffuseColor = vec4( 1.0 );\n\n\t#include \n\t#include \n\t#include \n\n\tfloat dist = length( vWorldPosition - referencePosition );\n\tdist = ( dist - nearDistance ) / ( farDistance - nearDistance );\n\tdist = saturate( dist ); // clamp to [ 0, 1 ]\n\n\tgl_FragColor = packDepthToRGBA( dist );\n\n}\n`;\n","export default /* glsl */`\n#define DISTANCE\n\nvarying vec3 vWorldPosition;\n\n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\t#include \n\n\t#ifdef USE_DISPLACEMENTMAP\n\n\t\t#include \n\t\t#include \n\t\t#include \n\n\t#endif\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\tvWorldPosition = worldPosition.xyz;\n\n}\n`;\n","export default /* glsl */`\nuniform sampler2D tEquirect;\n\nvarying vec3 vWorldDirection;\n\n#include \n\nvoid main() {\n\n\tvec3 direction = normalize( vWorldDirection );\n\n\tvec2 sampleUV = equirectUv( direction );\n\n\tvec4 texColor = texture2D( tEquirect, sampleUV );\n\n\tgl_FragColor = mapTexelToLinear( texColor );\n\n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\nvarying vec3 vWorldDirection;\n\n#include \n\nvoid main() {\n\n\tvWorldDirection = transformDirection( position, modelMatrix );\n\n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\nuniform vec3 diffuse;\nuniform float opacity;\n\nuniform float dashSize;\nuniform float totalSize;\n\nvarying float vLineDistance;\n\n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\n\t\tdiscard;\n\n\t}\n\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\n\t#include \n\t#include \n\n\toutgoingLight = diffuseColor.rgb; // simple shader\n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\nuniform float scale;\nattribute float lineDistance;\n\nvarying float vLineDistance;\n\n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\tvLineDistance = scale * lineDistance;\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\nuniform vec3 diffuse;\nuniform float opacity;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\n\t// accumulation (baked indirect lighting only)\n\t#ifdef USE_LIGHTMAP\n\t\n\t\tvec4 lightMapTexel= texture2D( lightMap, vUv2 );\n\t\treflectedLight.indirectDiffuse += lightMapTexelToLinear( lightMapTexel ).rgb * lightMapIntensity;\n\n\t#else\n\n\t\treflectedLight.indirectDiffuse += vec3( 1.0 );\n\n\t#endif\n\n\t// modulation\n\t#include \n\n\treflectedLight.indirectDiffuse *= diffuseColor.rgb;\n\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\n\t#include \n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\t#include \n\t#include \n\t#include \n\n\t#ifdef USE_ENVMAP\n\n\t#include \n\t#include \n\t#include \n\t#include \n\n\t#endif\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t// accumulation\n\n\t#ifdef DOUBLE_SIDED\n\n\t\treflectedLight.indirectDiffuse += ( gl_FrontFacing ) ? vIndirectFront : vIndirectBack;\n\n\t#else\n\n\t\treflectedLight.indirectDiffuse += vIndirectFront;\n\n\t#endif\n\n\t#include \n\n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\n\t#ifdef DOUBLE_SIDED\n\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\n\t#else\n\n\t\treflectedLight.directDiffuse = vLightFront;\n\n\t#endif\n\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\n\t// modulation\n\n\t#include \n\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\n\t#include \n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n`;\n","export default /* glsl */`\n#define LAMBERT\n\nvarying vec3 vLightFront;\nvarying vec3 vIndirectFront;\n\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n\tvarying vec3 vIndirectBack;\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n}\n`;\n","export default /* glsl */`\n#define MATCAP\n\nuniform vec3 diffuse;\nuniform float opacity;\nuniform sampler2D matcap;\n\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n\n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\tvec3 viewDir = normalize( vViewPosition );\n\tvec3 x = normalize( vec3( viewDir.z, 0.0, - viewDir.x ) );\n\tvec3 y = cross( viewDir, x );\n\tvec2 uv = vec2( dot( x, normal ), dot( y, normal ) ) * 0.495 + 0.5; // 0.495 to remove artifacts caused by undersized matcap disks\n\n\t#ifdef USE_MATCAP\n\n\t\tvec4 matcapColor = texture2D( matcap, uv );\n\t\tmatcapColor = matcapTexelToLinear( matcapColor );\n\n\t#else\n\n\t\tvec4 matcapColor = vec4( 1.0 );\n\n\t#endif\n\n\tvec3 outgoingLight = diffuseColor.rgb * matcapColor.rgb;\n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\n#define MATCAP\n\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\n#include \n#include \n\nvoid main() {\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED\n\n\t\tvNormal = normalize( transformedNormal );\n\n\t#endif\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\t#include \n\n\tvViewPosition = - mvPosition.xyz;\n\n}\n`;\n","export default /* glsl */`\n#define TOON\n\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t// accumulation\n\t#include \n\t#include \n\t#include \n\t#include \n\n\t// modulation\n\t#include \n\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\n#define TOON\n\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED\n\n\tvNormal = normalize( transformedNormal );\n\n#endif\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\tvViewPosition = - mvPosition.xyz;\n\n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\n#define PHONG\n\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t// accumulation\n\t#include \n\t#include \n\t#include \n\t#include \n\n\t// modulation\n\t#include \n\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\n\t#include \n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\n#define PHONG\n\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED\n\n\tvNormal = normalize( transformedNormal );\n\n#endif\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\tvViewPosition = - mvPosition.xyz;\n\n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\n#define STANDARD\n\n#ifdef PHYSICAL\n\t#define REFLECTIVITY\n\t#define CLEARCOAT\n\t#define TRANSPARENCY\n#endif\n\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\n\n#ifdef TRANSPARENCY\n\tuniform float transparency;\n#endif\n\n#ifdef REFLECTIVITY\n\tuniform float reflectivity;\n#endif\n\n#ifdef CLEARCOAT\n\tuniform float clearcoat;\n\tuniform float clearcoatRoughness;\n#endif\n\n#ifdef USE_SHEEN\n\tuniform vec3 sheen;\n#endif\n\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n\t#ifdef USE_TANGENT\n\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\n\t#endif\n\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t// accumulation\n\t#include \n\t#include \n\t#include \n\t#include \n\n\t// modulation\n\t#include \n\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\n\t// this is a stub for the transparency model\n\t#ifdef TRANSPARENCY\n\t\tdiffuseColor.a *= saturate( 1. - transparency + linearToRelativeLuminance( reflectedLight.directSpecular + reflectedLight.indirectSpecular ) );\n\t#endif\n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\n#define STANDARD\n\nvarying vec3 vViewPosition;\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n\t#ifdef USE_TANGENT\n\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\n\t#endif\n\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED\n\n\tvNormal = normalize( transformedNormal );\n\n\t#ifdef USE_TANGENT\n\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\n\t#endif\n\n#endif\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\tvViewPosition = - mvPosition.xyz;\n\n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\n#define NORMAL\n\nuniform float opacity;\n\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\n\tvarying vec3 vViewPosition;\n\n#endif\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n\t#ifdef USE_TANGENT\n\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\n\t#endif\n\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\t#include \n\t#include \n\t#include \n\n\tgl_FragColor = vec4( packNormalToRGB( normal ), opacity );\n\n}\n`;\n","export default /* glsl */`\n#define NORMAL\n\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\n\tvarying vec3 vViewPosition;\n\n#endif\n\n#ifndef FLAT_SHADED\n\n\tvarying vec3 vNormal;\n\n\t#ifdef USE_TANGENT\n\n\t\tvarying vec3 vTangent;\n\t\tvarying vec3 vBitangent;\n\n\t#endif\n\n#endif\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n#ifndef FLAT_SHADED // Normal computed with derivatives when FLAT_SHADED\n\n\tvNormal = normalize( transformedNormal );\n\n\t#ifdef USE_TANGENT\n\n\t\tvTangent = normalize( transformedTangent );\n\t\tvBitangent = normalize( cross( vNormal, vTangent ) * tangent.w );\n\n\t#endif\n\n#endif\n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n#if defined( FLAT_SHADED ) || defined( USE_BUMPMAP ) || defined( TANGENTSPACE_NORMALMAP )\n\n\tvViewPosition = - mvPosition.xyz;\n\n#endif\n\n}\n`;\n","export default /* glsl */`\nuniform vec3 diffuse;\nuniform float opacity;\n\n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\n\toutgoingLight = diffuseColor.rgb;\n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\nuniform float size;\nuniform float scale;\n\n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\t#include \n\t#include \n\t#include \n\n\tgl_PointSize = size;\n\n\t#ifdef USE_SIZEATTENUATION\n\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\n\t\tif ( isPerspective ) gl_PointSize *= ( scale / - mvPosition.z );\n\n\t#endif\n\n\t#include \n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\nuniform vec3 color;\nuniform float opacity;\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\tgl_FragColor = vec4( color, opacity * ( 1.0 - getShadowMask() ) );\n\n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\t#include \n\t#include \n\t#include \n\n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\nuniform vec3 diffuse;\nuniform float opacity;\n\n#include \n#include \n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\n\t#include \n\t#include \n\t#include \n\t#include \n\n\toutgoingLight = diffuseColor.rgb;\n\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\n\t#include \n\t#include \n\t#include \n\n}\n`;\n","export default /* glsl */`\nuniform float rotation;\nuniform vec2 center;\n\n#include \n#include \n#include \n#include \n#include \n\nvoid main() {\n\n\t#include \n\n\tvec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\n\n\tvec2 scale;\n\tscale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );\n\tscale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );\n\n\t#ifndef USE_SIZEATTENUATION\n\n\t\tbool isPerspective = isPerspectiveMatrix( projectionMatrix );\n\n\t\tif ( isPerspective ) scale *= - mvPosition.z;\n\n\t#endif\n\n\tvec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale;\n\n\tvec2 rotatedPosition;\n\trotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\n\trotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\n\n\tmvPosition.xy += rotatedPosition;\n\n\tgl_Position = projectionMatrix * mvPosition;\n\n\t#include \n\t#include \n\t#include \n\n}\n`;\n","import { ShaderChunk } from './ShaderChunk.js';\nimport { mergeUniforms } from './UniformsUtils.js';\nimport { Vector2 } from '../../math/Vector2.js';\nimport { Vector3 } from '../../math/Vector3.js';\nimport { UniformsLib } from './UniformsLib.js';\nimport { Color } from '../../math/Color.js';\nimport { Matrix3 } from '../../math/Matrix3.js';\n\n/**\n * @author alteredq / http://alteredqualia.com/\n * @author mrdoob / http://mrdoob.com/\n * @author mikael emtinger / http://gomo.se/\n */\n\nconst ShaderLib = {\n\n\tbasic: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.common,\n\t\t\tUniformsLib.specularmap,\n\t\t\tUniformsLib.envmap,\n\t\t\tUniformsLib.aomap,\n\t\t\tUniformsLib.lightmap,\n\t\t\tUniformsLib.fog\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.meshbasic_vert,\n\t\tfragmentShader: ShaderChunk.meshbasic_frag\n\n\t},\n\n\tlambert: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.common,\n\t\t\tUniformsLib.specularmap,\n\t\t\tUniformsLib.envmap,\n\t\t\tUniformsLib.aomap,\n\t\t\tUniformsLib.lightmap,\n\t\t\tUniformsLib.emissivemap,\n\t\t\tUniformsLib.fog,\n\t\t\tUniformsLib.lights,\n\t\t\t{\n\t\t\t\temissive: { value: new Color( 0x000000 ) }\n\t\t\t}\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.meshlambert_vert,\n\t\tfragmentShader: ShaderChunk.meshlambert_frag\n\n\t},\n\n\tphong: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.common,\n\t\t\tUniformsLib.specularmap,\n\t\t\tUniformsLib.envmap,\n\t\t\tUniformsLib.aomap,\n\t\t\tUniformsLib.lightmap,\n\t\t\tUniformsLib.emissivemap,\n\t\t\tUniformsLib.bumpmap,\n\t\t\tUniformsLib.normalmap,\n\t\t\tUniformsLib.displacementmap,\n\t\t\tUniformsLib.fog,\n\t\t\tUniformsLib.lights,\n\t\t\t{\n\t\t\t\temissive: { value: new Color( 0x000000 ) },\n\t\t\t\tspecular: { value: new Color( 0x111111 ) },\n\t\t\t\tshininess: { value: 30 }\n\t\t\t}\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.meshphong_vert,\n\t\tfragmentShader: ShaderChunk.meshphong_frag\n\n\t},\n\n\tstandard: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.common,\n\t\t\tUniformsLib.envmap,\n\t\t\tUniformsLib.aomap,\n\t\t\tUniformsLib.lightmap,\n\t\t\tUniformsLib.emissivemap,\n\t\t\tUniformsLib.bumpmap,\n\t\t\tUniformsLib.normalmap,\n\t\t\tUniformsLib.displacementmap,\n\t\t\tUniformsLib.roughnessmap,\n\t\t\tUniformsLib.metalnessmap,\n\t\t\tUniformsLib.fog,\n\t\t\tUniformsLib.lights,\n\t\t\t{\n\t\t\t\temissive: { value: new Color( 0x000000 ) },\n\t\t\t\troughness: { value: 1.0 },\n\t\t\t\tmetalness: { value: 0.0 },\n\t\t\t\tenvMapIntensity: { value: 1 } // temporary\n\t\t\t}\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.meshphysical_vert,\n\t\tfragmentShader: ShaderChunk.meshphysical_frag\n\n\t},\n\n\ttoon: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.common,\n\t\t\tUniformsLib.aomap,\n\t\t\tUniformsLib.lightmap,\n\t\t\tUniformsLib.emissivemap,\n\t\t\tUniformsLib.bumpmap,\n\t\t\tUniformsLib.normalmap,\n\t\t\tUniformsLib.displacementmap,\n\t\t\tUniformsLib.gradientmap,\n\t\t\tUniformsLib.fog,\n\t\t\tUniformsLib.lights,\n\t\t\t{\n\t\t\t\temissive: { value: new Color( 0x000000 ) }\n\t\t\t}\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.meshtoon_vert,\n\t\tfragmentShader: ShaderChunk.meshtoon_frag\n\n\t},\n\n\tmatcap: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.common,\n\t\t\tUniformsLib.bumpmap,\n\t\t\tUniformsLib.normalmap,\n\t\t\tUniformsLib.displacementmap,\n\t\t\tUniformsLib.fog,\n\t\t\t{\n\t\t\t\tmatcap: { value: null }\n\t\t\t}\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.meshmatcap_vert,\n\t\tfragmentShader: ShaderChunk.meshmatcap_frag\n\n\t},\n\n\tpoints: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.points,\n\t\t\tUniformsLib.fog\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.points_vert,\n\t\tfragmentShader: ShaderChunk.points_frag\n\n\t},\n\n\tdashed: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.common,\n\t\t\tUniformsLib.fog,\n\t\t\t{\n\t\t\t\tscale: { value: 1 },\n\t\t\t\tdashSize: { value: 1 },\n\t\t\t\ttotalSize: { value: 2 }\n\t\t\t}\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.linedashed_vert,\n\t\tfragmentShader: ShaderChunk.linedashed_frag\n\n\t},\n\n\tdepth: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.common,\n\t\t\tUniformsLib.displacementmap\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.depth_vert,\n\t\tfragmentShader: ShaderChunk.depth_frag\n\n\t},\n\n\tnormal: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.common,\n\t\t\tUniformsLib.bumpmap,\n\t\t\tUniformsLib.normalmap,\n\t\t\tUniformsLib.displacementmap,\n\t\t\t{\n\t\t\t\topacity: { value: 1.0 }\n\t\t\t}\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.normal_vert,\n\t\tfragmentShader: ShaderChunk.normal_frag\n\n\t},\n\n\tsprite: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.sprite,\n\t\t\tUniformsLib.fog\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.sprite_vert,\n\t\tfragmentShader: ShaderChunk.sprite_frag\n\n\t},\n\n\tbackground: {\n\n\t\tuniforms: {\n\t\t\tuvTransform: { value: new Matrix3() },\n\t\t\tt2D: { value: null },\n\t\t},\n\n\t\tvertexShader: ShaderChunk.background_vert,\n\t\tfragmentShader: ShaderChunk.background_frag\n\n\t},\n\t/* -------------------------------------------------------------------------\n\t//\tCube map shader\n\t ------------------------------------------------------------------------- */\n\n\tcube: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.envmap,\n\t\t\t{\n\t\t\t\topacity: { value: 1.0 }\n\t\t\t}\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.cube_vert,\n\t\tfragmentShader: ShaderChunk.cube_frag\n\n\t},\n\n\tequirect: {\n\n\t\tuniforms: {\n\t\t\ttEquirect: { value: null },\n\t\t},\n\n\t\tvertexShader: ShaderChunk.equirect_vert,\n\t\tfragmentShader: ShaderChunk.equirect_frag\n\n\t},\n\n\tdistanceRGBA: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.common,\n\t\t\tUniformsLib.displacementmap,\n\t\t\t{\n\t\t\t\treferencePosition: { value: new Vector3() },\n\t\t\t\tnearDistance: { value: 1 },\n\t\t\t\tfarDistance: { value: 1000 }\n\t\t\t}\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.distanceRGBA_vert,\n\t\tfragmentShader: ShaderChunk.distanceRGBA_frag\n\n\t},\n\n\tshadow: {\n\n\t\tuniforms: mergeUniforms( [\n\t\t\tUniformsLib.lights,\n\t\t\tUniformsLib.fog,\n\t\t\t{\n\t\t\t\tcolor: { value: new Color( 0x00000 ) },\n\t\t\t\topacity: { value: 1.0 }\n\t\t\t},\n\t\t] ),\n\n\t\tvertexShader: ShaderChunk.shadow_vert,\n\t\tfragmentShader: ShaderChunk.shadow_frag\n\n\t}\n\n};\n\nShaderLib.physical = {\n\n\tuniforms: mergeUniforms( [\n\t\tShaderLib.standard.uniforms,\n\t\t{\n\t\t\tclearcoat: { value: 0 },\n\t\t\tclearcoatMap: { value: null },\n\t\t\tclearcoatRoughness: { value: 0 },\n\t\t\tclearcoatRoughnessMap: { value: null },\n\t\t\tclearcoatNormalScale: { value: new Vector2( 1, 1 ) },\n\t\t\tclearcoatNormalMap: { value: null },\n\t\t\tsheen: { value: new Color( 0x000000 ) },\n\t\t\ttransparency: { value: 0 },\n\t\t}\n\t] ),\n\n\tvertexShader: ShaderChunk.meshphysical_vert,\n\tfragmentShader: ShaderChunk.meshphysical_frag\n\n};\n\n\nexport { ShaderLib };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { BackSide, FrontSide, CubeUVReflectionMapping } from '../../constants.js';\nimport { BoxBufferGeometry } from '../../geometries/BoxGeometry.js';\nimport { PlaneBufferGeometry } from '../../geometries/PlaneGeometry.js';\nimport { ShaderMaterial } from '../../materials/ShaderMaterial.js';\nimport { Color } from '../../math/Color.js';\nimport { Mesh } from '../../objects/Mesh.js';\nimport { ShaderLib } from '../shaders/ShaderLib.js';\nimport { cloneUniforms } from '../shaders/UniformsUtils.js';\n\nfunction WebGLBackground( renderer, state, objects, premultipliedAlpha ) {\n\n\tconst clearColor = new Color( 0x000000 );\n\tlet clearAlpha = 0;\n\n\tlet planeMesh;\n\tlet boxMesh;\n\n\tlet currentBackground = null;\n\tlet currentBackgroundVersion = 0;\n\tlet currentTonemapping = null;\n\n\tfunction render( renderList, scene, camera, forceClear ) {\n\n\t\tlet background = scene.isScene === true ? scene.background : null;\n\n\t\t// Ignore background in AR\n\t\t// TODO: Reconsider this.\n\n\t\tconst xr = renderer.xr;\n\t\tconst session = xr.getSession && xr.getSession();\n\n\t\tif ( session && session.environmentBlendMode === 'additive' ) {\n\n\t\t\tbackground = null;\n\n\t\t}\n\n\t\tif ( background === null ) {\n\n\t\t\tsetClear( clearColor, clearAlpha );\n\n\t\t} else if ( background && background.isColor ) {\n\n\t\t\tsetClear( background, 1 );\n\t\t\tforceClear = true;\n\n\t\t}\n\n\t\tif ( renderer.autoClear || forceClear ) {\n\n\t\t\trenderer.clear( renderer.autoClearColor, renderer.autoClearDepth, renderer.autoClearStencil );\n\n\t\t}\n\n\t\tif ( background && ( background.isCubeTexture || background.isWebGLCubeRenderTarget || background.mapping === CubeUVReflectionMapping ) ) {\n\n\t\t\tif ( boxMesh === undefined ) {\n\n\t\t\t\tboxMesh = new Mesh(\n\t\t\t\t\tnew BoxBufferGeometry( 1, 1, 1 ),\n\t\t\t\t\tnew ShaderMaterial( {\n\t\t\t\t\t\tname: 'BackgroundCubeMaterial',\n\t\t\t\t\t\tuniforms: cloneUniforms( ShaderLib.cube.uniforms ),\n\t\t\t\t\t\tvertexShader: ShaderLib.cube.vertexShader,\n\t\t\t\t\t\tfragmentShader: ShaderLib.cube.fragmentShader,\n\t\t\t\t\t\tside: BackSide,\n\t\t\t\t\t\tdepthTest: false,\n\t\t\t\t\t\tdepthWrite: false,\n\t\t\t\t\t\tfog: false\n\t\t\t\t\t} )\n\t\t\t\t);\n\n\t\t\t\tboxMesh.geometry.deleteAttribute( 'normal' );\n\t\t\t\tboxMesh.geometry.deleteAttribute( 'uv' );\n\n\t\t\t\tboxMesh.onBeforeRender = function ( renderer, scene, camera ) {\n\n\t\t\t\t\tthis.matrixWorld.copyPosition( camera.matrixWorld );\n\n\t\t\t\t};\n\n\t\t\t\t// enable code injection for non-built-in material\n\t\t\t\tObject.defineProperty( boxMesh.material, 'envMap', {\n\n\t\t\t\t\tget: function () {\n\n\t\t\t\t\t\treturn this.uniforms.envMap.value;\n\n\t\t\t\t\t}\n\n\t\t\t\t} );\n\n\t\t\t\tobjects.update( boxMesh );\n\n\t\t\t}\n\n\t\t\tconst texture = background.isWebGLCubeRenderTarget ? background.texture : background;\n\n\t\t\tboxMesh.material.uniforms.envMap.value = texture;\n\t\t\tboxMesh.material.uniforms.flipEnvMap.value = texture.isCubeTexture ? - 1 : 1;\n\n\t\t\tif ( currentBackground !== background ||\n\t\t\t\tcurrentBackgroundVersion !== texture.version ||\n\t\t\t\tcurrentTonemapping !== renderer.toneMapping ) {\n\n\t\t\t\tboxMesh.material.needsUpdate = true;\n\n\t\t\t\tcurrentBackground = background;\n\t\t\t\tcurrentBackgroundVersion = texture.version;\n\t\t\t\tcurrentTonemapping = renderer.toneMapping;\n\n\t\t\t}\n\n\t\t\t// push to the pre-sorted opaque render list\n\t\t\trenderList.unshift( boxMesh, boxMesh.geometry, boxMesh.material, 0, 0, null );\n\n\t\t} else if ( background && background.isTexture ) {\n\n\t\t\tif ( planeMesh === undefined ) {\n\n\t\t\t\tplaneMesh = new Mesh(\n\t\t\t\t\tnew PlaneBufferGeometry( 2, 2 ),\n\t\t\t\t\tnew ShaderMaterial( {\n\t\t\t\t\t\tname: 'BackgroundMaterial',\n\t\t\t\t\t\tuniforms: cloneUniforms( ShaderLib.background.uniforms ),\n\t\t\t\t\t\tvertexShader: ShaderLib.background.vertexShader,\n\t\t\t\t\t\tfragmentShader: ShaderLib.background.fragmentShader,\n\t\t\t\t\t\tside: FrontSide,\n\t\t\t\t\t\tdepthTest: false,\n\t\t\t\t\t\tdepthWrite: false,\n\t\t\t\t\t\tfog: false\n\t\t\t\t\t} )\n\t\t\t\t);\n\n\t\t\t\tplaneMesh.geometry.deleteAttribute( 'normal' );\n\n\t\t\t\t// enable code injection for non-built-in material\n\t\t\t\tObject.defineProperty( planeMesh.material, 'map', {\n\n\t\t\t\t\tget: function () {\n\n\t\t\t\t\t\treturn this.uniforms.t2D.value;\n\n\t\t\t\t\t}\n\n\t\t\t\t} );\n\n\t\t\t\tobjects.update( planeMesh );\n\n\t\t\t}\n\n\t\t\tplaneMesh.material.uniforms.t2D.value = background;\n\n\t\t\tif ( background.matrixAutoUpdate === true ) {\n\n\t\t\t\tbackground.updateMatrix();\n\n\t\t\t}\n\n\t\t\tplaneMesh.material.uniforms.uvTransform.value.copy( background.matrix );\n\n\t\t\tif ( currentBackground !== background ||\n\t\t\t\tcurrentBackgroundVersion !== background.version ||\n\t\t\t\tcurrentTonemapping !== renderer.toneMapping ) {\n\n\t\t\t\tplaneMesh.material.needsUpdate = true;\n\n\t\t\t\tcurrentBackground = background;\n\t\t\t\tcurrentBackgroundVersion = background.version;\n\t\t\t\tcurrentTonemapping = renderer.toneMapping;\n\n\t\t\t}\n\n\n\t\t\t// push to the pre-sorted opaque render list\n\t\t\trenderList.unshift( planeMesh, planeMesh.geometry, planeMesh.material, 0, 0, null );\n\n\t\t}\n\n\t}\n\n\tfunction setClear( color, alpha ) {\n\n\t\tstate.buffers.color.setClear( color.r, color.g, color.b, alpha, premultipliedAlpha );\n\n\t}\n\n\treturn {\n\n\t\tgetClearColor: function () {\n\n\t\t\treturn clearColor;\n\n\t\t},\n\t\tsetClearColor: function ( color, alpha ) {\n\n\t\t\tclearColor.set( color );\n\t\t\tclearAlpha = alpha !== undefined ? alpha : 1;\n\t\t\tsetClear( clearColor, clearAlpha );\n\n\t\t},\n\t\tgetClearAlpha: function () {\n\n\t\t\treturn clearAlpha;\n\n\t\t},\n\t\tsetClearAlpha: function ( alpha ) {\n\n\t\t\tclearAlpha = alpha;\n\t\t\tsetClear( clearColor, clearAlpha );\n\n\t\t},\n\t\trender: render\n\n\t};\n\n}\n\n\nexport { WebGLBackground };\n","/**\n * @author Mugen87 / https://github.com/Mugen87\n * @author Takahiro / https://github.com/takahirox\n */\n\nfunction WebGLBindingStates( gl, extensions, attributes, capabilities ) {\n\n\tconst maxVertexAttributes = gl.getParameter( gl.MAX_VERTEX_ATTRIBS );\n\n\tconst extension = capabilities.isWebGL2 ? null : extensions.get( 'OES_vertex_array_object' );\n\tconst vaoAvailable = capabilities.isWebGL2 || extension !== null;\n\n\tconst bindingStates = {};\n\n\tconst defaultState = createBindingState( null );\n\tlet currentState = defaultState;\n\n\tfunction setup( object, material, program, geometry, index ) {\n\n\t\tlet updateBuffers = false;\n\n\t\tif ( vaoAvailable ) {\n\n\t\t\tconst state = getBindingState( geometry, program, material );\n\n\t\t\tif ( currentState !== state ) {\n\n\t\t\t\tcurrentState = state;\n\t\t\t\tbindVertexArrayObject( currentState.object );\n\n\t\t\t}\n\n\t\t\tupdateBuffers = needsUpdate( geometry );\n\n\t\t\tif ( updateBuffers ) saveCache( geometry );\n\n\t\t} else {\n\n\t\t\tconst wireframe = ( material.wireframe === true );\n\n\t\t\tif ( currentState.geometry !== geometry.id ||\n\t\t\t\tcurrentState.program !== program.id ||\n\t\t\t\tcurrentState.wireframe !== wireframe ) {\n\n\t\t\t\tcurrentState.geometry = geometry.id;\n\t\t\t\tcurrentState.program = program.id;\n\t\t\t\tcurrentState.wireframe = wireframe;\n\n\t\t\t\tupdateBuffers = true;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( object.isInstancedMesh === true ) {\n\n\t\t\tupdateBuffers = true;\n\n\t\t}\n\n\t\tif ( index !== null ) {\n\n\t\t\tattributes.update( index, gl.ELEMENT_ARRAY_BUFFER );\n\n\t\t}\n\n\t\tif ( updateBuffers ) {\n\n\t\t\tsetupVertexAttributes( object, material, program, geometry );\n\n\t\t\tif ( index !== null ) {\n\n\t\t\t\tgl.bindBuffer( gl.ELEMENT_ARRAY_BUFFER, attributes.get( index ).buffer );\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tfunction createVertexArrayObject() {\n\n\t\tif ( capabilities.isWebGL2 ) return gl.createVertexArray();\n\n\t\treturn extension.createVertexArrayOES();\n\n\t}\n\n\tfunction bindVertexArrayObject( vao ) {\n\n\t\tif ( capabilities.isWebGL2 ) return gl.bindVertexArray( vao );\n\n\t\treturn extension.bindVertexArrayOES( vao );\n\n\t}\n\n\tfunction deleteVertexArrayObject( vao ) {\n\n\t\tif ( capabilities.isWebGL2 ) return gl.deleteVertexArray( vao );\n\n\t\treturn extension.deleteVertexArrayOES( vao );\n\n\t}\n\n\tfunction getBindingState( geometry, program, material ) {\n\n\t\tconst wireframe = ( material.wireframe === true );\n\n\t\tlet programMap = bindingStates[ geometry.id ];\n\n\t\tif ( programMap === undefined ) {\n\n\t\t\tprogramMap = {};\n\t\t\tbindingStates[ geometry.id ] = programMap;\n\n\t\t}\n\n\t\tlet stateMap = programMap[ program.id ];\n\n\t\tif ( stateMap === undefined ) {\n\n\t\t\tstateMap = {};\n\t\t\tprogramMap[ program.id ] = stateMap;\n\n\t\t}\n\n\t\tlet state = stateMap[ wireframe ];\n\n\t\tif ( state === undefined ) {\n\n\t\t\tstate = createBindingState( createVertexArrayObject() );\n\t\t\tstateMap[ wireframe ] = state;\n\n\t\t}\n\n\t\treturn state;\n\n\t}\n\n\tfunction createBindingState( vao ) {\n\n\t\tconst newAttributes = [];\n\t\tconst enabledAttributes = [];\n\t\tconst attributeDivisors = [];\n\n\t\tfor ( let i = 0; i < maxVertexAttributes; i ++ ) {\n\n\t\t\tnewAttributes[ i ] = 0;\n\t\t\tenabledAttributes[ i ] = 0;\n\t\t\tattributeDivisors[ i ] = 0;\n\n\t\t}\n\n\t\treturn {\n\n\t\t\t// for backward compatibility on non-VAO support browser\n\t\t\tgeometry: null,\n\t\t\tprogram: null,\n\t\t\twireframe: false,\n\n\t\t\tnewAttributes: newAttributes,\n\t\t\tenabledAttributes: enabledAttributes,\n\t\t\tattributeDivisors: attributeDivisors,\n\t\t\tobject: vao,\n\t\t\tattributes: {}\n\n\t\t};\n\n\t}\n\n\tfunction needsUpdate( geometry ) {\n\n\t\tconst cachedAttributes = currentState.attributes;\n\t\tconst geometryAttributes = geometry.attributes;\n\n\t\tif ( Object.keys( cachedAttributes ).length !== Object.keys( geometryAttributes ).length ) return true;\n\n\t\tfor ( const key in geometryAttributes ) {\n\n\t\t\tconst cachedAttribute = cachedAttributes[ key ];\n\t\t\tconst geometryAttribute = geometryAttributes[ key ];\n\n\t\t\tif ( cachedAttribute.attribute !== geometryAttribute ) return true;\n\n\t\t\tif ( cachedAttribute.data !== geometryAttribute.data ) return true;\n\n\t\t}\n\n\t\treturn false;\n\n\t}\n\n\tfunction saveCache( geometry ) {\n\n\t\tconst cache = {};\n\t\tconst attributes = geometry.attributes;\n\n\t\tfor ( const key in attributes ) {\n\n\t\t\tconst attribute = attributes[ key ];\n\n\t\t\tconst data = {};\n\t\t\tdata.attribute = attribute;\n\n\t\t\tif ( attribute.data ) {\n\n\t\t\t\tdata.data = attribute.data;\n\n\t\t\t}\n\n\t\t\tcache[ key ] = data;\n\n\t\t}\n\n\t\tcurrentState.attributes = cache;\n\n\t}\n\n\tfunction initAttributes() {\n\n\t\tconst newAttributes = currentState.newAttributes;\n\n\t\tfor ( let i = 0, il = newAttributes.length; i < il; i ++ ) {\n\n\t\t\tnewAttributes[ i ] = 0;\n\n\t\t}\n\n\t}\n\n\tfunction enableAttribute( attribute ) {\n\n\t\tenableAttributeAndDivisor( attribute, 0 );\n\n\t}\n\n\tfunction enableAttributeAndDivisor( attribute, meshPerAttribute ) {\n\n\t\tconst newAttributes = currentState.newAttributes;\n\t\tconst enabledAttributes = currentState.enabledAttributes;\n\t\tconst attributeDivisors = currentState.attributeDivisors;\n\n\t\tnewAttributes[ attribute ] = 1;\n\n\t\tif ( enabledAttributes[ attribute ] === 0 ) {\n\n\t\t\tgl.enableVertexAttribArray( attribute );\n\t\t\tenabledAttributes[ attribute ] = 1;\n\n\t\t}\n\n\t\tif ( attributeDivisors[ attribute ] !== meshPerAttribute ) {\n\n\t\t\tconst extension = capabilities.isWebGL2 ? gl : extensions.get( 'ANGLE_instanced_arrays' );\n\n\t\t\textension[ capabilities.isWebGL2 ? 'vertexAttribDivisor' : 'vertexAttribDivisorANGLE' ]( attribute, meshPerAttribute );\n\t\t\tattributeDivisors[ attribute ] = meshPerAttribute;\n\n\t\t}\n\n\t}\n\n\tfunction disableUnusedAttributes() {\n\n\t\tconst newAttributes = currentState.newAttributes;\n\t\tconst enabledAttributes = currentState.enabledAttributes;\n\n\t\tfor ( let i = 0, il = enabledAttributes.length; i < il; i ++ ) {\n\n\t\t\tif ( enabledAttributes[ i ] !== newAttributes[ i ] ) {\n\n\t\t\t\tgl.disableVertexAttribArray( i );\n\t\t\t\tenabledAttributes[ i ] = 0;\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tfunction vertexAttribPointer( index, size, type, normalized, stride, offset ) {\n\n\t\tif ( capabilities.isWebGL2 === true && ( type === gl.INT || type === gl.UNSIGNED_INT ) ) {\n\n\t\t\tgl.vertexAttribIPointer( index, size, type, normalized, stride, offset );\n\n\t\t} else {\n\n\t\t\tgl.vertexAttribPointer( index, size, type, normalized, stride, offset );\n\n\t\t}\n\n\t}\n\n\tfunction setupVertexAttributes( object, material, program, geometry ) {\n\n\t\tif ( capabilities.isWebGL2 === false && ( object.isInstancedMesh || geometry.isInstancedBufferGeometry ) ) {\n\n\t\t\tif ( extensions.get( 'ANGLE_instanced_arrays' ) === null ) return;\n\n\t\t}\n\n\t\tinitAttributes();\n\n\t\tconst geometryAttributes = geometry.attributes;\n\n\t\tconst programAttributes = program.getAttributes();\n\n\t\tconst materialDefaultAttributeValues = material.defaultAttributeValues;\n\n\t\tfor ( const name in programAttributes ) {\n\n\t\t\tconst programAttribute = programAttributes[ name ];\n\n\t\t\tif ( programAttribute >= 0 ) {\n\n\t\t\t\tconst geometryAttribute = geometryAttributes[ name ];\n\n\t\t\t\tif ( geometryAttribute !== undefined ) {\n\n\t\t\t\t\tconst normalized = geometryAttribute.normalized;\n\t\t\t\t\tconst size = geometryAttribute.itemSize;\n\n\t\t\t\t\tconst attribute = attributes.get( geometryAttribute );\n\n\t\t\t\t\t// TODO Attribute may not be available on context restore\n\n\t\t\t\t\tif ( attribute === undefined ) continue;\n\n\t\t\t\t\tconst buffer = attribute.buffer;\n\t\t\t\t\tconst type = attribute.type;\n\t\t\t\t\tconst bytesPerElement = attribute.bytesPerElement;\n\n\t\t\t\t\tif ( geometryAttribute.isInterleavedBufferAttribute ) {\n\n\t\t\t\t\t\tconst data = geometryAttribute.data;\n\t\t\t\t\t\tconst stride = data.stride;\n\t\t\t\t\t\tconst offset = geometryAttribute.offset;\n\n\t\t\t\t\t\tif ( data && data.isInstancedInterleavedBuffer ) {\n\n\t\t\t\t\t\t\tenableAttributeAndDivisor( programAttribute, data.meshPerAttribute );\n\n\t\t\t\t\t\t\tif ( geometry._maxInstanceCount === undefined ) {\n\n\t\t\t\t\t\t\t\tgeometry._maxInstanceCount = data.meshPerAttribute * data.count;\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\tenableAttribute( programAttribute );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tgl.bindBuffer( gl.ARRAY_BUFFER, buffer );\n\t\t\t\t\t\tvertexAttribPointer( programAttribute, size, type, normalized, stride * bytesPerElement, offset * bytesPerElement );\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tif ( geometryAttribute.isInstancedBufferAttribute ) {\n\n\t\t\t\t\t\t\tenableAttributeAndDivisor( programAttribute, geometryAttribute.meshPerAttribute );\n\n\t\t\t\t\t\t\tif ( geometry._maxInstanceCount === undefined ) {\n\n\t\t\t\t\t\t\t\tgeometry._maxInstanceCount = geometryAttribute.meshPerAttribute * geometryAttribute.count;\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\tenableAttribute( programAttribute );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tgl.bindBuffer( gl.ARRAY_BUFFER, buffer );\n\t\t\t\t\t\tvertexAttribPointer( programAttribute, size, type, normalized, 0, 0 );\n\n\t\t\t\t\t}\n\n\t\t\t\t} else if ( name === 'instanceMatrix' ) {\n\n\t\t\t\t\tconst attribute = attributes.get( object.instanceMatrix );\n\n\t\t\t\t\t// TODO Attribute may not be available on context restore\n\n\t\t\t\t\tif ( attribute === undefined ) continue;\n\n\t\t\t\t\tconst buffer = attribute.buffer;\n\t\t\t\t\tconst type = attribute.type;\n\n\t\t\t\t\tenableAttributeAndDivisor( programAttribute + 0, 1 );\n\t\t\t\t\tenableAttributeAndDivisor( programAttribute + 1, 1 );\n\t\t\t\t\tenableAttributeAndDivisor( programAttribute + 2, 1 );\n\t\t\t\t\tenableAttributeAndDivisor( programAttribute + 3, 1 );\n\n\t\t\t\t\tgl.bindBuffer( gl.ARRAY_BUFFER, buffer );\n\n\t\t\t\t\tgl.vertexAttribPointer( programAttribute + 0, 4, type, false, 64, 0 );\n\t\t\t\t\tgl.vertexAttribPointer( programAttribute + 1, 4, type, false, 64, 16 );\n\t\t\t\t\tgl.vertexAttribPointer( programAttribute + 2, 4, type, false, 64, 32 );\n\t\t\t\t\tgl.vertexAttribPointer( programAttribute + 3, 4, type, false, 64, 48 );\n\n\t\t\t\t} else if ( materialDefaultAttributeValues !== undefined ) {\n\n\t\t\t\t\tconst value = materialDefaultAttributeValues[ name ];\n\n\t\t\t\t\tif ( value !== undefined ) {\n\n\t\t\t\t\t\tswitch ( value.length ) {\n\n\t\t\t\t\t\t\tcase 2:\n\t\t\t\t\t\t\t\tgl.vertexAttrib2fv( programAttribute, value );\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase 3:\n\t\t\t\t\t\t\t\tgl.vertexAttrib3fv( programAttribute, value );\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase 4:\n\t\t\t\t\t\t\t\tgl.vertexAttrib4fv( programAttribute, value );\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\t\tgl.vertexAttrib1fv( programAttribute, value );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tdisableUnusedAttributes();\n\n\t}\n\n\tfunction dispose() {\n\n\t\treset();\n\n\t\tfor ( const geometryId in bindingStates ) {\n\n\t\t\tconst programMap = bindingStates[ geometryId ];\n\n\t\t\tfor ( const programId in programMap ) {\n\n\t\t\t\tconst stateMap = programMap[ programId ];\n\n\t\t\t\tfor ( const wireframe in stateMap ) {\n\n\t\t\t\t\tdeleteVertexArrayObject( stateMap[ wireframe ].object );\n\n\t\t\t\t\tdelete stateMap[ wireframe ];\n\n\t\t\t\t}\n\n\t\t\t\tdelete programMap[ programId ];\n\n\t\t\t}\n\n\t\t\tdelete bindingStates[ geometryId ];\n\n\t\t}\n\n\t}\n\n\tfunction releaseStatesOfGeometry( geometry ) {\n\n\t\tif ( bindingStates[ geometry.id ] === undefined ) return;\n\n\t\tconst programMap = bindingStates[ geometry.id ];\n\n\t\tfor ( const programId in programMap ) {\n\n\t\t\tconst stateMap = programMap[ programId ];\n\n\t\t\tfor ( const wireframe in stateMap ) {\n\n\t\t\t\tdeleteVertexArrayObject( stateMap[ wireframe ].object );\n\n\t\t\t\tdelete stateMap[ wireframe ];\n\n\t\t\t}\n\n\t\t\tdelete programMap[ programId ];\n\n\t\t}\n\n\t\tdelete bindingStates[ geometry.id ];\n\n\t}\n\n\tfunction releaseStatesOfProgram( program ) {\n\n\t\tfor ( const geometryId in bindingStates ) {\n\n\t\t\tconst programMap = bindingStates[ geometryId ];\n\n\t\t\tif ( programMap[ program.id ] === undefined ) continue;\n\n\t\t\tconst stateMap = programMap[ program.id ];\n\n\t\t\tfor ( const wireframe in stateMap ) {\n\n\t\t\t\tdeleteVertexArrayObject( stateMap[ wireframe ].object );\n\n\t\t\t\tdelete stateMap[ wireframe ];\n\n\t\t\t}\n\n\t\t\tdelete programMap[ program.id ];\n\n\t\t}\n\n\t}\n\n\tfunction reset() {\n\n\t\tresetDefaultState();\n\n\t\tif ( currentState === defaultState ) return;\n\n\t\tcurrentState = defaultState;\n\t\tbindVertexArrayObject( currentState.object );\n\n\t}\n\n\t// for backward-compatilibity\n\n\tfunction resetDefaultState() {\n\n\t\tdefaultState.geometry = null;\n\t\tdefaultState.program = null;\n\t\tdefaultState.wireframe = false;\n\n\t}\n\n\treturn {\n\n\t\tsetup: setup,\n\t\treset: reset,\n\t\tresetDefaultState: resetDefaultState,\n\t\tdispose: dispose,\n\t\treleaseStatesOfGeometry: releaseStatesOfGeometry,\n\t\treleaseStatesOfProgram: releaseStatesOfProgram,\n\n\t\tinitAttributes: initAttributes,\n\t\tenableAttribute: enableAttribute,\n\t\tdisableUnusedAttributes: disableUnusedAttributes\n\n\t};\n\n}\n\n\nexport { WebGLBindingStates };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction WebGLBufferRenderer( gl, extensions, info, capabilities ) {\n\n\tconst isWebGL2 = capabilities.isWebGL2;\n\n\tlet mode;\n\n\tfunction setMode( value ) {\n\n\t\tmode = value;\n\n\t}\n\n\tfunction render( start, count ) {\n\n\t\tgl.drawArrays( mode, start, count );\n\n\t\tinfo.update( count, mode );\n\n\t}\n\n\tfunction renderInstances( geometry, start, count, primcount ) {\n\n\t\tif ( primcount === 0 ) return;\n\n\t\tlet extension, methodName;\n\n\t\tif ( isWebGL2 ) {\n\n\t\t\textension = gl;\n\t\t\tmethodName = 'drawArraysInstanced';\n\n\t\t} else {\n\n\t\t\textension = extensions.get( 'ANGLE_instanced_arrays' );\n\t\t\tmethodName = 'drawArraysInstancedANGLE';\n\n\t\t\tif ( extension === null ) {\n\n\t\t\t\tconsole.error( 'THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.' );\n\t\t\t\treturn;\n\n\t\t\t}\n\n\t\t}\n\n\t\textension[ methodName ]( mode, start, count, primcount );\n\n\t\tinfo.update( count, mode, primcount );\n\n\t}\n\n\t//\n\n\tthis.setMode = setMode;\n\tthis.render = render;\n\tthis.renderInstances = renderInstances;\n\n}\n\n\nexport { WebGLBufferRenderer };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction WebGLCapabilities( gl, extensions, parameters ) {\n\n\tlet maxAnisotropy;\n\n\tfunction getMaxAnisotropy() {\n\n\t\tif ( maxAnisotropy !== undefined ) return maxAnisotropy;\n\n\t\tconst extension = extensions.get( 'EXT_texture_filter_anisotropic' );\n\n\t\tif ( extension !== null ) {\n\n\t\t\tmaxAnisotropy = gl.getParameter( extension.MAX_TEXTURE_MAX_ANISOTROPY_EXT );\n\n\t\t} else {\n\n\t\t\tmaxAnisotropy = 0;\n\n\t\t}\n\n\t\treturn maxAnisotropy;\n\n\t}\n\n\tfunction getMaxPrecision( precision ) {\n\n\t\tif ( precision === 'highp' ) {\n\n\t\t\tif ( gl.getShaderPrecisionFormat( gl.VERTEX_SHADER, gl.HIGH_FLOAT ).precision > 0 &&\n\t\t\t\tgl.getShaderPrecisionFormat( gl.FRAGMENT_SHADER, gl.HIGH_FLOAT ).precision > 0 ) {\n\n\t\t\t\treturn 'highp';\n\n\t\t\t}\n\n\t\t\tprecision = 'mediump';\n\n\t\t}\n\n\t\tif ( precision === 'mediump' ) {\n\n\t\t\tif ( gl.getShaderPrecisionFormat( gl.VERTEX_SHADER, gl.MEDIUM_FLOAT ).precision > 0 &&\n\t\t\t\tgl.getShaderPrecisionFormat( gl.FRAGMENT_SHADER, gl.MEDIUM_FLOAT ).precision > 0 ) {\n\n\t\t\t\treturn 'mediump';\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn 'lowp';\n\n\t}\n\n\t/* eslint-disable no-undef */\n\tconst isWebGL2 = ( typeof WebGL2RenderingContext !== 'undefined' && gl instanceof WebGL2RenderingContext ) ||\n\t\t( typeof WebGL2ComputeRenderingContext !== 'undefined' && gl instanceof WebGL2ComputeRenderingContext );\n\t/* eslint-enable no-undef */\n\n\tlet precision = parameters.precision !== undefined ? parameters.precision : 'highp';\n\tconst maxPrecision = getMaxPrecision( precision );\n\n\tif ( maxPrecision !== precision ) {\n\n\t\tconsole.warn( 'THREE.WebGLRenderer:', precision, 'not supported, using', maxPrecision, 'instead.' );\n\t\tprecision = maxPrecision;\n\n\t}\n\n\tconst logarithmicDepthBuffer = parameters.logarithmicDepthBuffer === true;\n\n\tconst maxTextures = gl.getParameter( gl.MAX_TEXTURE_IMAGE_UNITS );\n\tconst maxVertexTextures = gl.getParameter( gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS );\n\tconst maxTextureSize = gl.getParameter( gl.MAX_TEXTURE_SIZE );\n\tconst maxCubemapSize = gl.getParameter( gl.MAX_CUBE_MAP_TEXTURE_SIZE );\n\n\tconst maxAttributes = gl.getParameter( gl.MAX_VERTEX_ATTRIBS );\n\tconst maxVertexUniforms = gl.getParameter( gl.MAX_VERTEX_UNIFORM_VECTORS );\n\tconst maxVaryings = gl.getParameter( gl.MAX_VARYING_VECTORS );\n\tconst maxFragmentUniforms = gl.getParameter( gl.MAX_FRAGMENT_UNIFORM_VECTORS );\n\n\tconst vertexTextures = maxVertexTextures > 0;\n\tconst floatFragmentTextures = isWebGL2 || !! extensions.get( 'OES_texture_float' );\n\tconst floatVertexTextures = vertexTextures && floatFragmentTextures;\n\n\tconst maxSamples = isWebGL2 ? gl.getParameter( gl.MAX_SAMPLES ) : 0;\n\n\treturn {\n\n\t\tisWebGL2: isWebGL2,\n\n\t\tgetMaxAnisotropy: getMaxAnisotropy,\n\t\tgetMaxPrecision: getMaxPrecision,\n\n\t\tprecision: precision,\n\t\tlogarithmicDepthBuffer: logarithmicDepthBuffer,\n\n\t\tmaxTextures: maxTextures,\n\t\tmaxVertexTextures: maxVertexTextures,\n\t\tmaxTextureSize: maxTextureSize,\n\t\tmaxCubemapSize: maxCubemapSize,\n\n\t\tmaxAttributes: maxAttributes,\n\t\tmaxVertexUniforms: maxVertexUniforms,\n\t\tmaxVaryings: maxVaryings,\n\t\tmaxFragmentUniforms: maxFragmentUniforms,\n\n\t\tvertexTextures: vertexTextures,\n\t\tfloatFragmentTextures: floatFragmentTextures,\n\t\tfloatVertexTextures: floatVertexTextures,\n\n\t\tmaxSamples: maxSamples\n\n\t};\n\n}\n\n\nexport { WebGLCapabilities };\n","/**\n * @author tschw\n */\n\nimport { Matrix3 } from '../../math/Matrix3.js';\nimport { Plane } from '../../math/Plane.js';\n\nfunction WebGLClipping() {\n\n\tconst scope = this;\n\n\tlet globalState = null,\n\t\tnumGlobalPlanes = 0,\n\t\tlocalClippingEnabled = false,\n\t\trenderingShadows = false;\n\n\tconst plane = new Plane(),\n\t\tviewNormalMatrix = new Matrix3(),\n\n\t\tuniform = { value: null, needsUpdate: false };\n\n\tthis.uniform = uniform;\n\tthis.numPlanes = 0;\n\tthis.numIntersection = 0;\n\n\tthis.init = function ( planes, enableLocalClipping, camera ) {\n\n\t\tconst enabled =\n\t\t\tplanes.length !== 0 ||\n\t\t\tenableLocalClipping ||\n\t\t\t// enable state of previous frame - the clipping code has to\n\t\t\t// run another frame in order to reset the state:\n\t\t\tnumGlobalPlanes !== 0 ||\n\t\t\tlocalClippingEnabled;\n\n\t\tlocalClippingEnabled = enableLocalClipping;\n\n\t\tglobalState = projectPlanes( planes, camera, 0 );\n\t\tnumGlobalPlanes = planes.length;\n\n\t\treturn enabled;\n\n\t};\n\n\tthis.beginShadows = function () {\n\n\t\trenderingShadows = true;\n\t\tprojectPlanes( null );\n\n\t};\n\n\tthis.endShadows = function () {\n\n\t\trenderingShadows = false;\n\t\tresetGlobalState();\n\n\t};\n\n\tthis.setState = function ( planes, clipIntersection, clipShadows, camera, cache, fromCache ) {\n\n\t\tif ( ! localClippingEnabled || planes === null || planes.length === 0 || renderingShadows && ! clipShadows ) {\n\n\t\t\t// there's no local clipping\n\n\t\t\tif ( renderingShadows ) {\n\n\t\t\t\t// there's no global clipping\n\n\t\t\t\tprojectPlanes( null );\n\n\t\t\t} else {\n\n\t\t\t\tresetGlobalState();\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tconst nGlobal = renderingShadows ? 0 : numGlobalPlanes,\n\t\t\t\tlGlobal = nGlobal * 4;\n\n\t\t\tlet dstArray = cache.clippingState || null;\n\n\t\t\tuniform.value = dstArray; // ensure unique state\n\n\t\t\tdstArray = projectPlanes( planes, camera, lGlobal, fromCache );\n\n\t\t\tfor ( let i = 0; i !== lGlobal; ++ i ) {\n\n\t\t\t\tdstArray[ i ] = globalState[ i ];\n\n\t\t\t}\n\n\t\t\tcache.clippingState = dstArray;\n\t\t\tthis.numIntersection = clipIntersection ? this.numPlanes : 0;\n\t\t\tthis.numPlanes += nGlobal;\n\n\t\t}\n\n\n\t};\n\n\tfunction resetGlobalState() {\n\n\t\tif ( uniform.value !== globalState ) {\n\n\t\t\tuniform.value = globalState;\n\t\t\tuniform.needsUpdate = numGlobalPlanes > 0;\n\n\t\t}\n\n\t\tscope.numPlanes = numGlobalPlanes;\n\t\tscope.numIntersection = 0;\n\n\t}\n\n\tfunction projectPlanes( planes, camera, dstOffset, skipTransform ) {\n\n\t\tlet nPlanes = planes !== null ? planes.length : 0,\n\t\t\tdstArray = null;\n\n\t\tif ( nPlanes !== 0 ) {\n\n\t\t\tdstArray = uniform.value;\n\n\t\t\tif ( skipTransform !== true || dstArray === null ) {\n\n\t\t\t\tconst flatSize = dstOffset + nPlanes * 4,\n\t\t\t\t\tviewMatrix = camera.matrixWorldInverse;\n\n\t\t\t\tviewNormalMatrix.getNormalMatrix( viewMatrix );\n\n\t\t\t\tif ( dstArray === null || dstArray.length < flatSize ) {\n\n\t\t\t\t\tdstArray = new Float32Array( flatSize );\n\n\t\t\t\t}\n\n\t\t\t\tfor ( let i = 0, i4 = dstOffset; i !== nPlanes; ++ i, i4 += 4 ) {\n\n\t\t\t\t\tplane.copy( planes[ i ] ).applyMatrix4( viewMatrix, viewNormalMatrix );\n\n\t\t\t\t\tplane.normal.toArray( dstArray, i4 );\n\t\t\t\t\tdstArray[ i4 + 3 ] = plane.constant;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tuniform.value = dstArray;\n\t\t\tuniform.needsUpdate = true;\n\n\t\t}\n\n\t\tscope.numPlanes = nPlanes;\n\t\tscope.numIntersection = 0;\n\n\t\treturn dstArray;\n\n\t}\n\n}\n\n\nexport { WebGLClipping };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction WebGLExtensions( gl ) {\n\n\tconst extensions = {};\n\n\treturn {\n\n\t\tget: function ( name ) {\n\n\t\t\tif ( extensions[ name ] !== undefined ) {\n\n\t\t\t\treturn extensions[ name ];\n\n\t\t\t}\n\n\t\t\tlet extension;\n\n\t\t\tswitch ( name ) {\n\n\t\t\t\tcase 'WEBGL_depth_texture':\n\t\t\t\t\textension = gl.getExtension( 'WEBGL_depth_texture' ) || gl.getExtension( 'MOZ_WEBGL_depth_texture' ) || gl.getExtension( 'WEBKIT_WEBGL_depth_texture' );\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'EXT_texture_filter_anisotropic':\n\t\t\t\t\textension = gl.getExtension( 'EXT_texture_filter_anisotropic' ) || gl.getExtension( 'MOZ_EXT_texture_filter_anisotropic' ) || gl.getExtension( 'WEBKIT_EXT_texture_filter_anisotropic' );\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'WEBGL_compressed_texture_s3tc':\n\t\t\t\t\textension = gl.getExtension( 'WEBGL_compressed_texture_s3tc' ) || gl.getExtension( 'MOZ_WEBGL_compressed_texture_s3tc' ) || gl.getExtension( 'WEBKIT_WEBGL_compressed_texture_s3tc' );\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'WEBGL_compressed_texture_pvrtc':\n\t\t\t\t\textension = gl.getExtension( 'WEBGL_compressed_texture_pvrtc' ) || gl.getExtension( 'WEBKIT_WEBGL_compressed_texture_pvrtc' );\n\t\t\t\t\tbreak;\n\n\t\t\t\tdefault:\n\t\t\t\t\textension = gl.getExtension( name );\n\n\t\t\t}\n\n\t\t\tif ( extension === null ) {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: ' + name + ' extension not supported.' );\n\n\t\t\t}\n\n\t\t\textensions[ name ] = extension;\n\n\t\t\treturn extension;\n\n\t\t}\n\n\t};\n\n}\n\n\nexport { WebGLExtensions };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { Uint16BufferAttribute, Uint32BufferAttribute } from '../../core/BufferAttribute.js';\nimport { BufferGeometry } from '../../core/BufferGeometry.js';\nimport { arrayMax } from '../../utils.js';\n\nfunction WebGLGeometries( gl, attributes, info, bindingStates ) {\n\n\tconst geometries = new WeakMap();\n\tconst wireframeAttributes = new WeakMap();\n\n\tfunction onGeometryDispose( event ) {\n\n\t\tconst geometry = event.target;\n\t\tconst buffergeometry = geometries.get( geometry );\n\n\t\tif ( buffergeometry.index !== null ) {\n\n\t\t\tattributes.remove( buffergeometry.index );\n\n\t\t}\n\n\t\tfor ( const name in buffergeometry.attributes ) {\n\n\t\t\tattributes.remove( buffergeometry.attributes[ name ] );\n\n\t\t}\n\n\t\tgeometry.removeEventListener( 'dispose', onGeometryDispose );\n\n\t\tgeometries.delete( geometry );\n\n\t\tconst attribute = wireframeAttributes.get( buffergeometry );\n\n\t\tif ( attribute ) {\n\n\t\t\tattributes.remove( attribute );\n\t\t\twireframeAttributes.delete( buffergeometry );\n\n\t\t}\n\n\t\tbindingStates.releaseStatesOfGeometry( geometry );\n\n\t\tif ( geometry.isInstancedBufferGeometry === true ) {\n\n\t\t\tdelete geometry._maxInstanceCount;\n\n\t\t}\n\n\t\t//\n\n\t\tinfo.memory.geometries --;\n\n\t}\n\n\tfunction get( object, geometry ) {\n\n\t\tlet buffergeometry = geometries.get( geometry );\n\n\t\tif ( buffergeometry ) return buffergeometry;\n\n\t\tgeometry.addEventListener( 'dispose', onGeometryDispose );\n\n\t\tif ( geometry.isBufferGeometry ) {\n\n\t\t\tbuffergeometry = geometry;\n\n\t\t} else if ( geometry.isGeometry ) {\n\n\t\t\tif ( geometry._bufferGeometry === undefined ) {\n\n\t\t\t\tgeometry._bufferGeometry = new BufferGeometry().setFromObject( object );\n\n\t\t\t}\n\n\t\t\tbuffergeometry = geometry._bufferGeometry;\n\n\t\t}\n\n\t\tgeometries.set( geometry, buffergeometry );\n\n\t\tinfo.memory.geometries ++;\n\n\t\treturn buffergeometry;\n\n\t}\n\n\tfunction update( geometry ) {\n\n\t\tconst geometryAttributes = geometry.attributes;\n\n\t\t// Updating index buffer in VAO now. See WebGLBindingStates.\n\n\t\tfor ( const name in geometryAttributes ) {\n\n\t\t\tattributes.update( geometryAttributes[ name ], gl.ARRAY_BUFFER );\n\n\t\t}\n\n\t\t// morph targets\n\n\t\tconst morphAttributes = geometry.morphAttributes;\n\n\t\tfor ( const name in morphAttributes ) {\n\n\t\t\tconst array = morphAttributes[ name ];\n\n\t\t\tfor ( let i = 0, l = array.length; i < l; i ++ ) {\n\n\t\t\t\tattributes.update( array[ i ], gl.ARRAY_BUFFER );\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tfunction updateWireframeAttribute( geometry ) {\n\n\t\tconst indices = [];\n\n\t\tconst geometryIndex = geometry.index;\n\t\tconst geometryPosition = geometry.attributes.position;\n\t\tlet version = 0;\n\n\t\tif ( geometryIndex !== null ) {\n\n\t\t\tconst array = geometryIndex.array;\n\t\t\tversion = geometryIndex.version;\n\n\t\t\tfor ( let i = 0, l = array.length; i < l; i += 3 ) {\n\n\t\t\t\tconst a = array[ i + 0 ];\n\t\t\t\tconst b = array[ i + 1 ];\n\t\t\t\tconst c = array[ i + 2 ];\n\n\t\t\t\tindices.push( a, b, b, c, c, a );\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tconst array = geometryPosition.array;\n\t\t\tversion = geometryPosition.version;\n\n\t\t\tfor ( let i = 0, l = ( array.length / 3 ) - 1; i < l; i += 3 ) {\n\n\t\t\t\tconst a = i + 0;\n\t\t\t\tconst b = i + 1;\n\t\t\t\tconst c = i + 2;\n\n\t\t\t\tindices.push( a, b, b, c, c, a );\n\n\t\t\t}\n\n\t\t}\n\n\t\tconst attribute = new ( arrayMax( indices ) > 65535 ? Uint32BufferAttribute : Uint16BufferAttribute )( indices, 1 );\n\t\tattribute.version = version;\n\n\t\t// Updating index buffer in VAO now. See WebGLBindingStates\n\n\t\t//\n\n\t\tconst previousAttribute = wireframeAttributes.get( geometry );\n\n\t\tif ( previousAttribute ) attributes.remove( previousAttribute );\n\n\t\t//\n\n\t\twireframeAttributes.set( geometry, attribute );\n\n\t}\n\n\tfunction getWireframeAttribute( geometry ) {\n\n\t\tconst currentAttribute = wireframeAttributes.get( geometry );\n\n\t\tif ( currentAttribute ) {\n\n\t\t\tconst geometryIndex = geometry.index;\n\n\t\t\tif ( geometryIndex !== null ) {\n\n\t\t\t\t// if the attribute is obsolete, create a new one\n\n\t\t\t\tif ( currentAttribute.version < geometryIndex.version ) {\n\n\t\t\t\t\tupdateWireframeAttribute( geometry );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tupdateWireframeAttribute( geometry );\n\n\t\t}\n\n\t\treturn wireframeAttributes.get( geometry );\n\n\t}\n\n\treturn {\n\n\t\tget: get,\n\t\tupdate: update,\n\n\t\tgetWireframeAttribute: getWireframeAttribute\n\n\t};\n\n}\n\n\nexport { WebGLGeometries };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction WebGLIndexedBufferRenderer( gl, extensions, info, capabilities ) {\n\n\tconst isWebGL2 = capabilities.isWebGL2;\n\n\tlet mode;\n\n\tfunction setMode( value ) {\n\n\t\tmode = value;\n\n\t}\n\n\tlet type, bytesPerElement;\n\n\tfunction setIndex( value ) {\n\n\t\ttype = value.type;\n\t\tbytesPerElement = value.bytesPerElement;\n\n\t}\n\n\tfunction render( start, count ) {\n\n\t\tgl.drawElements( mode, count, type, start * bytesPerElement );\n\n\t\tinfo.update( count, mode );\n\n\t}\n\n\tfunction renderInstances( geometry, start, count, primcount ) {\n\n\t\tif ( primcount === 0 ) return;\n\n\t\tlet extension, methodName;\n\n\t\tif ( isWebGL2 ) {\n\n\t\t\textension = gl;\n\t\t\tmethodName = 'drawElementsInstanced';\n\n\t\t} else {\n\n\t\t\textension = extensions.get( 'ANGLE_instanced_arrays' );\n\t\t\tmethodName = 'drawElementsInstancedANGLE';\n\n\t\t\tif ( extension === null ) {\n\n\t\t\t\tconsole.error( 'THREE.WebGLIndexedBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.' );\n\t\t\t\treturn;\n\n\t\t\t}\n\n\t\t}\n\n\t\textension[ methodName ]( mode, count, type, start * bytesPerElement, primcount );\n\n\t\tinfo.update( count, mode, primcount );\n\n\t}\n\n\t//\n\n\tthis.setMode = setMode;\n\tthis.setIndex = setIndex;\n\tthis.render = render;\n\tthis.renderInstances = renderInstances;\n\n}\n\n\nexport { WebGLIndexedBufferRenderer };\n","/**\n * @author Mugen87 / https://github.com/Mugen87\n */\n\nfunction WebGLInfo( gl ) {\n\n\tconst memory = {\n\t\tgeometries: 0,\n\t\ttextures: 0\n\t};\n\n\tconst render = {\n\t\tframe: 0,\n\t\tcalls: 0,\n\t\ttriangles: 0,\n\t\tpoints: 0,\n\t\tlines: 0\n\t};\n\n\tfunction update( count, mode, instanceCount ) {\n\n\t\tinstanceCount = instanceCount || 1;\n\n\t\trender.calls ++;\n\n\t\tswitch ( mode ) {\n\n\t\t\tcase gl.TRIANGLES:\n\t\t\t\trender.triangles += instanceCount * ( count / 3 );\n\t\t\t\tbreak;\n\n\t\t\tcase gl.LINES:\n\t\t\t\trender.lines += instanceCount * ( count / 2 );\n\t\t\t\tbreak;\n\n\t\t\tcase gl.LINE_STRIP:\n\t\t\t\trender.lines += instanceCount * ( count - 1 );\n\t\t\t\tbreak;\n\n\t\t\tcase gl.LINE_LOOP:\n\t\t\t\trender.lines += instanceCount * count;\n\t\t\t\tbreak;\n\n\t\t\tcase gl.POINTS:\n\t\t\t\trender.points += instanceCount * count;\n\t\t\t\tbreak;\n\n\t\t\tdefault:\n\t\t\t\tconsole.error( 'THREE.WebGLInfo: Unknown draw mode:', mode );\n\t\t\t\tbreak;\n\n\t\t}\n\n\t}\n\n\tfunction reset() {\n\n\t\trender.frame ++;\n\t\trender.calls = 0;\n\t\trender.triangles = 0;\n\t\trender.points = 0;\n\t\trender.lines = 0;\n\n\t}\n\n\treturn {\n\t\tmemory: memory,\n\t\trender: render,\n\t\tprograms: null,\n\t\tautoReset: true,\n\t\treset: reset,\n\t\tupdate: update\n\t};\n\n}\n\n\nexport { WebGLInfo };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction numericalSort( a, b ) {\n\n\treturn a[ 0 ] - b[ 0 ];\n\n}\n\nfunction absNumericalSort( a, b ) {\n\n\treturn Math.abs( b[ 1 ] ) - Math.abs( a[ 1 ] );\n\n}\n\nfunction WebGLMorphtargets( gl ) {\n\n\tconst influencesList = {};\n\tconst morphInfluences = new Float32Array( 8 );\n\n\tconst workInfluences = [];\n\n\tfor ( let i = 0; i < 8; i ++ ) {\n\n\t\tworkInfluences[ i ] = [ i, 0 ];\n\n\t}\n\n\tfunction update( object, geometry, material, program ) {\n\n\t\tconst objectInfluences = object.morphTargetInfluences;\n\n\t\t// When object doesn't have morph target influences defined, we treat it as a 0-length array\n\t\t// This is important to make sure we set up morphTargetBaseInfluence / morphTargetInfluences\n\n\t\tconst length = objectInfluences === undefined ? 0 : objectInfluences.length;\n\n\t\tlet influences = influencesList[ geometry.id ];\n\n\t\tif ( influences === undefined ) {\n\n\t\t\t// initialise list\n\n\t\t\tinfluences = [];\n\n\t\t\tfor ( let i = 0; i < length; i ++ ) {\n\n\t\t\t\tinfluences[ i ] = [ i, 0 ];\n\n\t\t\t}\n\n\t\t\tinfluencesList[ geometry.id ] = influences;\n\n\t\t}\n\n\t\t// Collect influences\n\n\t\tfor ( let i = 0; i < length; i ++ ) {\n\n\t\t\tconst influence = influences[ i ];\n\n\t\t\tinfluence[ 0 ] = i;\n\t\t\tinfluence[ 1 ] = objectInfluences[ i ];\n\n\t\t}\n\n\t\tinfluences.sort( absNumericalSort );\n\n\t\tfor ( let i = 0; i < 8; i ++ ) {\n\n\t\t\tif ( i < length && influences[ i ][ 1 ] ) {\n\n\t\t\t\tworkInfluences[ i ][ 0 ] = influences[ i ][ 0 ];\n\t\t\t\tworkInfluences[ i ][ 1 ] = influences[ i ][ 1 ];\n\n\t\t\t} else {\n\n\t\t\t\tworkInfluences[ i ][ 0 ] = Number.MAX_SAFE_INTEGER;\n\t\t\t\tworkInfluences[ i ][ 1 ] = 0;\n\n\t\t\t}\n\n\t\t}\n\n\t\tworkInfluences.sort( numericalSort );\n\n\t\tconst morphTargets = material.morphTargets && geometry.morphAttributes.position;\n\t\tconst morphNormals = material.morphNormals && geometry.morphAttributes.normal;\n\n\t\tlet morphInfluencesSum = 0;\n\n\t\tfor ( let i = 0; i < 8; i ++ ) {\n\n\t\t\tconst influence = workInfluences[ i ];\n\t\t\tconst index = influence[ 0 ];\n\t\t\tconst value = influence[ 1 ];\n\n\t\t\tif ( index !== Number.MAX_SAFE_INTEGER && value ) {\n\n\t\t\t\tif ( morphTargets && geometry.getAttribute( 'morphTarget' + i ) !== morphTargets[ index ] ) {\n\n\t\t\t\t\tgeometry.setAttribute( 'morphTarget' + i, morphTargets[ index ] );\n\n\t\t\t\t}\n\n\t\t\t\tif ( morphNormals && geometry.getAttribute( 'morphNormal' + i ) !== morphNormals[ index ] ) {\n\n\t\t\t\t\tgeometry.setAttribute( 'morphNormal' + i, morphNormals[ index ] );\n\n\t\t\t\t}\n\n\t\t\t\tmorphInfluences[ i ] = value;\n\t\t\t\tmorphInfluencesSum += value;\n\n\t\t\t} else {\n\n\t\t\t\tif ( morphTargets && geometry.getAttribute( 'morphTarget' + i ) !== undefined ) {\n\n\t\t\t\t\tgeometry.deleteAttribute( 'morphTarget' + i );\n\n\t\t\t\t}\n\n\t\t\t\tif ( morphNormals && geometry.getAttribute( 'morphNormal' + i ) !== undefined ) {\n\n\t\t\t\t\tgeometry.deleteAttribute( 'morphNormal' + i );\n\n\t\t\t\t}\n\n\t\t\t\tmorphInfluences[ i ] = 0;\n\n\t\t\t}\n\n\t\t}\n\n\t\t// GLSL shader uses formula baseinfluence * base + sum(target * influence)\n\t\t// This allows us to switch between absolute morphs and relative morphs without changing shader code\n\t\t// When baseinfluence = 1 - sum(influence), the above is equivalent to sum((target - base) * influence)\n\t\tconst morphBaseInfluence = geometry.morphTargetsRelative ? 1 : 1 - morphInfluencesSum;\n\n\t\tprogram.getUniforms().setValue( gl, 'morphTargetBaseInfluence', morphBaseInfluence );\n\t\tprogram.getUniforms().setValue( gl, 'morphTargetInfluences', morphInfluences );\n\n\t}\n\n\treturn {\n\n\t\tupdate: update\n\n\t};\n\n}\n\n\nexport { WebGLMorphtargets };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction WebGLObjects( gl, geometries, attributes, info ) {\n\n\tlet updateMap = new WeakMap();\n\n\tfunction update( object ) {\n\n\t\tconst frame = info.render.frame;\n\n\t\tconst geometry = object.geometry;\n\t\tconst buffergeometry = geometries.get( object, geometry );\n\n\t\t// Update once per frame\n\n\t\tif ( updateMap.get( buffergeometry ) !== frame ) {\n\n\t\t\tif ( geometry.isGeometry ) {\n\n\t\t\t\tbuffergeometry.updateFromObject( object );\n\n\t\t\t}\n\n\t\t\tgeometries.update( buffergeometry );\n\n\t\t\tupdateMap.set( buffergeometry, frame );\n\n\t\t}\n\n\t\tif ( object.isInstancedMesh ) {\n\n\t\t\tattributes.update( object.instanceMatrix, gl.ARRAY_BUFFER );\n\n\t\t}\n\n\t\treturn buffergeometry;\n\n\t}\n\n\tfunction dispose() {\n\n\t\tupdateMap = new WeakMap();\n\n\t}\n\n\treturn {\n\n\t\tupdate: update,\n\t\tdispose: dispose\n\n\t};\n\n}\n\n\nexport { WebGLObjects };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { Texture } from './Texture.js';\nimport { CubeReflectionMapping, RGBFormat } from '../constants.js';\n\nfunction CubeTexture( images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding ) {\n\n\timages = images !== undefined ? images : [];\n\tmapping = mapping !== undefined ? mapping : CubeReflectionMapping;\n\tformat = format !== undefined ? format : RGBFormat;\n\n\tTexture.call( this, images, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy, encoding );\n\n\tthis.flipY = false;\n\n}\n\nCubeTexture.prototype = Object.create( Texture.prototype );\nCubeTexture.prototype.constructor = CubeTexture;\n\nCubeTexture.prototype.isCubeTexture = true;\n\nObject.defineProperty( CubeTexture.prototype, 'images', {\n\n\tget: function () {\n\n\t\treturn this.image;\n\n\t},\n\n\tset: function ( value ) {\n\n\t\tthis.image = value;\n\n\t}\n\n} );\n\n\nexport { CubeTexture };\n","/**\n * @author Takahiro https://github.com/takahirox\n */\n\nimport { Texture } from './Texture.js';\nimport { ClampToEdgeWrapping, NearestFilter } from '../constants.js';\n\nfunction DataTexture2DArray( data, width, height, depth ) {\n\n\tTexture.call( this, null );\n\n\tthis.image = { data: data || null, width: width || 1, height: height || 1, depth: depth || 1 };\n\n\tthis.magFilter = NearestFilter;\n\tthis.minFilter = NearestFilter;\n\n\tthis.wrapR = ClampToEdgeWrapping;\n\n\tthis.generateMipmaps = false;\n\tthis.flipY = false;\n\n\tthis.needsUpdate = true;\n\n}\n\nDataTexture2DArray.prototype = Object.create( Texture.prototype );\nDataTexture2DArray.prototype.constructor = DataTexture2DArray;\nDataTexture2DArray.prototype.isDataTexture2DArray = true;\n\nexport { DataTexture2DArray };\n","/**\n * @author Artur Trzesiok\n */\n\nimport { Texture } from './Texture.js';\nimport { ClampToEdgeWrapping, NearestFilter } from '../constants.js';\n\nfunction DataTexture3D( data, width, height, depth ) {\n\n\t// We're going to add .setXXX() methods for setting properties later.\n\t// Users can still set in DataTexture3D directly.\n\t//\n\t//\tconst texture = new THREE.DataTexture3D( data, width, height, depth );\n\t// \ttexture.anisotropy = 16;\n\t//\n\t// See #14839\n\n\tTexture.call( this, null );\n\n\tthis.image = { data: data || null, width: width || 1, height: height || 1, depth: depth || 1 };\n\n\tthis.magFilter = NearestFilter;\n\tthis.minFilter = NearestFilter;\n\n\tthis.wrapR = ClampToEdgeWrapping;\n\n\tthis.generateMipmaps = false;\n\tthis.flipY = false;\n\n\tthis.needsUpdate = true;\n\n\n}\n\nDataTexture3D.prototype = Object.create( Texture.prototype );\nDataTexture3D.prototype.constructor = DataTexture3D;\nDataTexture3D.prototype.isDataTexture3D = true;\n\nexport { DataTexture3D };\n","/**\n * @author tschw\n * @author Mugen87 / https://github.com/Mugen87\n * @author mrdoob / http://mrdoob.com/\n *\n * Uniforms of a program.\n * Those form a tree structure with a special top-level container for the root,\n * which you get by calling 'new WebGLUniforms( gl, program )'.\n *\n *\n * Properties of inner nodes including the top-level container:\n *\n * .seq - array of nested uniforms\n * .map - nested uniforms by name\n *\n *\n * Methods of all nodes except the top-level container:\n *\n * .setValue( gl, value, [textures] )\n *\n * \t\tuploads a uniform value(s)\n * \tthe 'textures' parameter is needed for sampler uniforms\n *\n *\n * Static methods of the top-level container (textures factorizations):\n *\n * .upload( gl, seq, values, textures )\n *\n * \t\tsets uniforms in 'seq' to 'values[id].value'\n *\n * .seqWithValue( seq, values ) : filteredSeq\n *\n * \t\tfilters 'seq' entries with corresponding entry in values\n *\n *\n * Methods of the top-level container (textures factorizations):\n *\n * .setValue( gl, name, value, textures )\n *\n * \t\tsets uniform with name 'name' to 'value'\n *\n * .setOptional( gl, obj, prop )\n *\n * \t\tlike .set for an optional property of the object\n *\n */\n\nimport { CubeTexture } from '../../textures/CubeTexture.js';\nimport { Texture } from '../../textures/Texture.js';\nimport { DataTexture2DArray } from '../../textures/DataTexture2DArray.js';\nimport { DataTexture3D } from '../../textures/DataTexture3D.js';\n\nconst emptyTexture = new Texture();\nconst emptyTexture2dArray = new DataTexture2DArray();\nconst emptyTexture3d = new DataTexture3D();\nconst emptyCubeTexture = new CubeTexture();\n\n// --- Utilities ---\n\n// Array Caches (provide typed arrays for temporary by size)\n\nconst arrayCacheF32 = [];\nconst arrayCacheI32 = [];\n\n// Float32Array caches used for uploading Matrix uniforms\n\nconst mat4array = new Float32Array( 16 );\nconst mat3array = new Float32Array( 9 );\nconst mat2array = new Float32Array( 4 );\n\n// Flattening for arrays of vectors and matrices\n\nfunction flatten( array, nBlocks, blockSize ) {\n\n\tconst firstElem = array[ 0 ];\n\n\tif ( firstElem <= 0 || firstElem > 0 ) return array;\n\t// unoptimized: ! isNaN( firstElem )\n\t// see http://jacksondunstan.com/articles/983\n\n\tlet n = nBlocks * blockSize,\n\t\tr = arrayCacheF32[ n ];\n\n\tif ( r === undefined ) {\n\n\t\tr = new Float32Array( n );\n\t\tarrayCacheF32[ n ] = r;\n\n\t}\n\n\tif ( nBlocks !== 0 ) {\n\n\t\tfirstElem.toArray( r, 0 );\n\n\t\tfor ( let i = 1, offset = 0; i !== nBlocks; ++ i ) {\n\n\t\t\toffset += blockSize;\n\t\t\tarray[ i ].toArray( r, offset );\n\n\t\t}\n\n\t}\n\n\treturn r;\n\n}\n\nfunction arraysEqual( a, b ) {\n\n\tif ( a.length !== b.length ) return false;\n\n\tfor ( let i = 0, l = a.length; i < l; i ++ ) {\n\n\t\tif ( a[ i ] !== b[ i ] ) return false;\n\n\t}\n\n\treturn true;\n\n}\n\nfunction copyArray( a, b ) {\n\n\tfor ( let i = 0, l = b.length; i < l; i ++ ) {\n\n\t\ta[ i ] = b[ i ];\n\n\t}\n\n}\n\n// Texture unit allocation\n\nfunction allocTexUnits( textures, n ) {\n\n\tlet r = arrayCacheI32[ n ];\n\n\tif ( r === undefined ) {\n\n\t\tr = new Int32Array( n );\n\t\tarrayCacheI32[ n ] = r;\n\n\t}\n\n\tfor ( let i = 0; i !== n; ++ i ) {\n\n\t\tr[ i ] = textures.allocateTextureUnit();\n\n\t}\n\n\treturn r;\n\n}\n\n// --- Setters ---\n\n// Note: Defining these methods externally, because they come in a bunch\n// and this way their names minify.\n\n// Single scalar\n\nfunction setValueV1f( gl, v ) {\n\n\tconst cache = this.cache;\n\n\tif ( cache[ 0 ] === v ) return;\n\n\tgl.uniform1f( this.addr, v );\n\n\tcache[ 0 ] = v;\n\n}\n\n// Single float vector (from flat array or THREE.VectorN)\n\nfunction setValueV2f( gl, v ) {\n\n\tconst cache = this.cache;\n\n\tif ( v.x !== undefined ) {\n\n\t\tif ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y ) {\n\n\t\t\tgl.uniform2f( this.addr, v.x, v.y );\n\n\t\t\tcache[ 0 ] = v.x;\n\t\t\tcache[ 1 ] = v.y;\n\n\t\t}\n\n\t} else {\n\n\t\tif ( arraysEqual( cache, v ) ) return;\n\n\t\tgl.uniform2fv( this.addr, v );\n\n\t\tcopyArray( cache, v );\n\n\t}\n\n}\n\nfunction setValueV3f( gl, v ) {\n\n\tconst cache = this.cache;\n\n\tif ( v.x !== undefined ) {\n\n\t\tif ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y || cache[ 2 ] !== v.z ) {\n\n\t\t\tgl.uniform3f( this.addr, v.x, v.y, v.z );\n\n\t\t\tcache[ 0 ] = v.x;\n\t\t\tcache[ 1 ] = v.y;\n\t\t\tcache[ 2 ] = v.z;\n\n\t\t}\n\n\t} else if ( v.r !== undefined ) {\n\n\t\tif ( cache[ 0 ] !== v.r || cache[ 1 ] !== v.g || cache[ 2 ] !== v.b ) {\n\n\t\t\tgl.uniform3f( this.addr, v.r, v.g, v.b );\n\n\t\t\tcache[ 0 ] = v.r;\n\t\t\tcache[ 1 ] = v.g;\n\t\t\tcache[ 2 ] = v.b;\n\n\t\t}\n\n\t} else {\n\n\t\tif ( arraysEqual( cache, v ) ) return;\n\n\t\tgl.uniform3fv( this.addr, v );\n\n\t\tcopyArray( cache, v );\n\n\t}\n\n}\n\nfunction setValueV4f( gl, v ) {\n\n\tconst cache = this.cache;\n\n\tif ( v.x !== undefined ) {\n\n\t\tif ( cache[ 0 ] !== v.x || cache[ 1 ] !== v.y || cache[ 2 ] !== v.z || cache[ 3 ] !== v.w ) {\n\n\t\t\tgl.uniform4f( this.addr, v.x, v.y, v.z, v.w );\n\n\t\t\tcache[ 0 ] = v.x;\n\t\t\tcache[ 1 ] = v.y;\n\t\t\tcache[ 2 ] = v.z;\n\t\t\tcache[ 3 ] = v.w;\n\n\t\t}\n\n\t} else {\n\n\t\tif ( arraysEqual( cache, v ) ) return;\n\n\t\tgl.uniform4fv( this.addr, v );\n\n\t\tcopyArray( cache, v );\n\n\t}\n\n}\n\n// Single matrix (from flat array or MatrixN)\n\nfunction setValueM2( gl, v ) {\n\n\tconst cache = this.cache;\n\tconst elements = v.elements;\n\n\tif ( elements === undefined ) {\n\n\t\tif ( arraysEqual( cache, v ) ) return;\n\n\t\tgl.uniformMatrix2fv( this.addr, false, v );\n\n\t\tcopyArray( cache, v );\n\n\t} else {\n\n\t\tif ( arraysEqual( cache, elements ) ) return;\n\n\t\tmat2array.set( elements );\n\n\t\tgl.uniformMatrix2fv( this.addr, false, mat2array );\n\n\t\tcopyArray( cache, elements );\n\n\t}\n\n}\n\nfunction setValueM3( gl, v ) {\n\n\tconst cache = this.cache;\n\tconst elements = v.elements;\n\n\tif ( elements === undefined ) {\n\n\t\tif ( arraysEqual( cache, v ) ) return;\n\n\t\tgl.uniformMatrix3fv( this.addr, false, v );\n\n\t\tcopyArray( cache, v );\n\n\t} else {\n\n\t\tif ( arraysEqual( cache, elements ) ) return;\n\n\t\tmat3array.set( elements );\n\n\t\tgl.uniformMatrix3fv( this.addr, false, mat3array );\n\n\t\tcopyArray( cache, elements );\n\n\t}\n\n}\n\nfunction setValueM4( gl, v ) {\n\n\tconst cache = this.cache;\n\tconst elements = v.elements;\n\n\tif ( elements === undefined ) {\n\n\t\tif ( arraysEqual( cache, v ) ) return;\n\n\t\tgl.uniformMatrix4fv( this.addr, false, v );\n\n\t\tcopyArray( cache, v );\n\n\t} else {\n\n\t\tif ( arraysEqual( cache, elements ) ) return;\n\n\t\tmat4array.set( elements );\n\n\t\tgl.uniformMatrix4fv( this.addr, false, mat4array );\n\n\t\tcopyArray( cache, elements );\n\n\t}\n\n}\n\n// Single texture (2D / Cube)\n\nfunction setValueT1( gl, v, textures ) {\n\n\tconst cache = this.cache;\n\tconst unit = textures.allocateTextureUnit();\n\n\tif ( cache[ 0 ] !== unit ) {\n\n\t\tgl.uniform1i( this.addr, unit );\n\t\tcache[ 0 ] = unit;\n\n\t}\n\n\ttextures.safeSetTexture2D( v || emptyTexture, unit );\n\n}\n\nfunction setValueT2DArray1( gl, v, textures ) {\n\n\tconst cache = this.cache;\n\tconst unit = textures.allocateTextureUnit();\n\n\tif ( cache[ 0 ] !== unit ) {\n\n\t\tgl.uniform1i( this.addr, unit );\n\t\tcache[ 0 ] = unit;\n\n\t}\n\n\ttextures.setTexture2DArray( v || emptyTexture2dArray, unit );\n\n}\n\nfunction setValueT3D1( gl, v, textures ) {\n\n\tconst cache = this.cache;\n\tconst unit = textures.allocateTextureUnit();\n\n\tif ( cache[ 0 ] !== unit ) {\n\n\t\tgl.uniform1i( this.addr, unit );\n\t\tcache[ 0 ] = unit;\n\n\t}\n\n\ttextures.setTexture3D( v || emptyTexture3d, unit );\n\n}\n\nfunction setValueT6( gl, v, textures ) {\n\n\tconst cache = this.cache;\n\tconst unit = textures.allocateTextureUnit();\n\n\tif ( cache[ 0 ] !== unit ) {\n\n\t\tgl.uniform1i( this.addr, unit );\n\t\tcache[ 0 ] = unit;\n\n\t}\n\n\ttextures.safeSetTextureCube( v || emptyCubeTexture, unit );\n\n}\n\n// Integer / Boolean vectors or arrays thereof (always flat arrays)\n\nfunction setValueV1i( gl, v ) {\n\n\tconst cache = this.cache;\n\n\tif ( cache[ 0 ] === v ) return;\n\n\tgl.uniform1i( this.addr, v );\n\n\tcache[ 0 ] = v;\n\n}\n\nfunction setValueV2i( gl, v ) {\n\n\tconst cache = this.cache;\n\n\tif ( arraysEqual( cache, v ) ) return;\n\n\tgl.uniform2iv( this.addr, v );\n\n\tcopyArray( cache, v );\n\n}\n\nfunction setValueV3i( gl, v ) {\n\n\tconst cache = this.cache;\n\n\tif ( arraysEqual( cache, v ) ) return;\n\n\tgl.uniform3iv( this.addr, v );\n\n\tcopyArray( cache, v );\n\n}\n\nfunction setValueV4i( gl, v ) {\n\n\tconst cache = this.cache;\n\n\tif ( arraysEqual( cache, v ) ) return;\n\n\tgl.uniform4iv( this.addr, v );\n\n\tcopyArray( cache, v );\n\n}\n\n// uint\n\nfunction setValueV1ui( gl, v ) {\n\n\tconst cache = this.cache;\n\n\tif ( cache[ 0 ] === v ) return;\n\n\tgl.uniform1ui( this.addr, v );\n\n\tcache[ 0 ] = v;\n\n}\n\n// Helper to pick the right setter for the singular case\n\nfunction getSingularSetter( type ) {\n\n\tswitch ( type ) {\n\n\t\tcase 0x1406: return setValueV1f; // FLOAT\n\t\tcase 0x8b50: return setValueV2f; // _VEC2\n\t\tcase 0x8b51: return setValueV3f; // _VEC3\n\t\tcase 0x8b52: return setValueV4f; // _VEC4\n\n\t\tcase 0x8b5a: return setValueM2; // _MAT2\n\t\tcase 0x8b5b: return setValueM3; // _MAT3\n\t\tcase 0x8b5c: return setValueM4; // _MAT4\n\n\t\tcase 0x1404: case 0x8b56: return setValueV1i; // INT, BOOL\n\t\tcase 0x8b53: case 0x8b57: return setValueV2i; // _VEC2\n\t\tcase 0x8b54: case 0x8b58: return setValueV3i; // _VEC3\n\t\tcase 0x8b55: case 0x8b59: return setValueV4i; // _VEC4\n\n\t\tcase 0x1405: return setValueV1ui; // UINT\n\n\t\tcase 0x8b5e: // SAMPLER_2D\n\t\tcase 0x8d66: // SAMPLER_EXTERNAL_OES\n\t\tcase 0x8dca: // INT_SAMPLER_2D\n\t\tcase 0x8dd2: // UNSIGNED_INT_SAMPLER_2D\n\t\tcase 0x8b62: // SAMPLER_2D_SHADOW\n\t\t\treturn setValueT1;\n\n\t\tcase 0x8b5f: // SAMPLER_3D\n\t\tcase 0x8dcb: // INT_SAMPLER_3D\n\t\tcase 0x8dd3: // UNSIGNED_INT_SAMPLER_3D\n\t\t\treturn setValueT3D1;\n\n\t\tcase 0x8b60: // SAMPLER_CUBE\n\t\tcase 0x8dcc: // INT_SAMPLER_CUBE\n\t\tcase 0x8dd4: // UNSIGNED_INT_SAMPLER_CUBE\n\t\tcase 0x8dc5: // SAMPLER_CUBE_SHADOW\n\t\t\treturn setValueT6;\n\n\t\tcase 0x8dc1: // SAMPLER_2D_ARRAY\n\t\tcase 0x8dcf: // INT_SAMPLER_2D_ARRAY\n\t\tcase 0x8dd7: // UNSIGNED_INT_SAMPLER_2D_ARRAY\n\t\tcase 0x8dc4: // SAMPLER_2D_ARRAY_SHADOW\n\t\t\treturn setValueT2DArray1;\n\n\t}\n\n}\n\n// Array of scalars\nfunction setValueV1fArray( gl, v ) {\n\n\tgl.uniform1fv( this.addr, v );\n\n}\n\n// Integer / Boolean vectors or arrays thereof (always flat arrays)\nfunction setValueV1iArray( gl, v ) {\n\n\tgl.uniform1iv( this.addr, v );\n\n}\n\nfunction setValueV2iArray( gl, v ) {\n\n\tgl.uniform2iv( this.addr, v );\n\n}\n\nfunction setValueV3iArray( gl, v ) {\n\n\tgl.uniform3iv( this.addr, v );\n\n}\n\nfunction setValueV4iArray( gl, v ) {\n\n\tgl.uniform4iv( this.addr, v );\n\n}\n\n\n// Array of vectors (flat or from THREE classes)\n\nfunction setValueV2fArray( gl, v ) {\n\n\tconst data = flatten( v, this.size, 2 );\n\n\tgl.uniform2fv( this.addr, data );\n\n}\n\nfunction setValueV3fArray( gl, v ) {\n\n\tconst data = flatten( v, this.size, 3 );\n\n\tgl.uniform3fv( this.addr, data );\n\n}\n\nfunction setValueV4fArray( gl, v ) {\n\n\tconst data = flatten( v, this.size, 4 );\n\n\tgl.uniform4fv( this.addr, data );\n\n}\n\n// Array of matrices (flat or from THREE clases)\n\nfunction setValueM2Array( gl, v ) {\n\n\tconst data = flatten( v, this.size, 4 );\n\n\tgl.uniformMatrix2fv( this.addr, false, data );\n\n}\n\nfunction setValueM3Array( gl, v ) {\n\n\tconst data = flatten( v, this.size, 9 );\n\n\tgl.uniformMatrix3fv( this.addr, false, data );\n\n}\n\nfunction setValueM4Array( gl, v ) {\n\n\tconst data = flatten( v, this.size, 16 );\n\n\tgl.uniformMatrix4fv( this.addr, false, data );\n\n}\n\n// Array of textures (2D / Cube)\n\nfunction setValueT1Array( gl, v, textures ) {\n\n\tconst n = v.length;\n\n\tconst units = allocTexUnits( textures, n );\n\n\tgl.uniform1iv( this.addr, units );\n\n\tfor ( let i = 0; i !== n; ++ i ) {\n\n\t\ttextures.safeSetTexture2D( v[ i ] || emptyTexture, units[ i ] );\n\n\t}\n\n}\n\nfunction setValueT6Array( gl, v, textures ) {\n\n\tconst n = v.length;\n\n\tconst units = allocTexUnits( textures, n );\n\n\tgl.uniform1iv( this.addr, units );\n\n\tfor ( let i = 0; i !== n; ++ i ) {\n\n\t\ttextures.safeSetTextureCube( v[ i ] || emptyCubeTexture, units[ i ] );\n\n\t}\n\n}\n\n// Helper to pick the right setter for a pure (bottom-level) array\n\nfunction getPureArraySetter( type ) {\n\n\tswitch ( type ) {\n\n\t\tcase 0x1406: return setValueV1fArray; // FLOAT\n\t\tcase 0x8b50: return setValueV2fArray; // _VEC2\n\t\tcase 0x8b51: return setValueV3fArray; // _VEC3\n\t\tcase 0x8b52: return setValueV4fArray; // _VEC4\n\n\t\tcase 0x8b5a: return setValueM2Array; // _MAT2\n\t\tcase 0x8b5b: return setValueM3Array; // _MAT3\n\t\tcase 0x8b5c: return setValueM4Array; // _MAT4\n\n\t\tcase 0x1404: case 0x8b56: return setValueV1iArray; // INT, BOOL\n\t\tcase 0x8b53: case 0x8b57: return setValueV2iArray; // _VEC2\n\t\tcase 0x8b54: case 0x8b58: return setValueV3iArray; // _VEC3\n\t\tcase 0x8b55: case 0x8b59: return setValueV4iArray; // _VEC4\n\n\t\tcase 0x8b5e: // SAMPLER_2D\n\t\tcase 0x8d66: // SAMPLER_EXTERNAL_OES\n\t\tcase 0x8dca: // INT_SAMPLER_2D\n\t\tcase 0x8dd2: // UNSIGNED_INT_SAMPLER_2D\n\t\tcase 0x8b62: // SAMPLER_2D_SHADOW\n\t\t\treturn setValueT1Array;\n\n\t\tcase 0x8b60: // SAMPLER_CUBE\n\t\tcase 0x8dcc: // INT_SAMPLER_CUBE\n\t\tcase 0x8dd4: // UNSIGNED_INT_SAMPLER_CUBE\n\t\tcase 0x8dc5: // SAMPLER_CUBE_SHADOW\n\t\t\treturn setValueT6Array;\n\n\t}\n\n}\n\n// --- Uniform Classes ---\n\nfunction SingleUniform( id, activeInfo, addr ) {\n\n\tthis.id = id;\n\tthis.addr = addr;\n\tthis.cache = [];\n\tthis.setValue = getSingularSetter( activeInfo.type );\n\n\t// this.path = activeInfo.name; // DEBUG\n\n}\n\nfunction PureArrayUniform( id, activeInfo, addr ) {\n\n\tthis.id = id;\n\tthis.addr = addr;\n\tthis.cache = [];\n\tthis.size = activeInfo.size;\n\tthis.setValue = getPureArraySetter( activeInfo.type );\n\n\t// this.path = activeInfo.name; // DEBUG\n\n}\n\nPureArrayUniform.prototype.updateCache = function ( data ) {\n\n\tlet cache = this.cache;\n\n\tif ( data instanceof Float32Array && cache.length !== data.length ) {\n\n\t\tthis.cache = new Float32Array( data.length );\n\n\t}\n\n\tcopyArray( cache, data );\n\n};\n\nfunction StructuredUniform( id ) {\n\n\tthis.id = id;\n\n\tthis.seq = [];\n\tthis.map = {};\n\n}\n\nStructuredUniform.prototype.setValue = function ( gl, value, textures ) {\n\n\tconst seq = this.seq;\n\n\tfor ( let i = 0, n = seq.length; i !== n; ++ i ) {\n\n\t\tconst u = seq[ i ];\n\t\tu.setValue( gl, value[ u.id ], textures );\n\n\t}\n\n};\n\n// --- Top-level ---\n\n// Parser - builds up the property tree from the path strings\n\nconst RePathPart = /([\\w\\d_]+)(\\])?(\\[|\\.)?/g;\n\n// extracts\n// \t- the identifier (member name or array index)\n// - followed by an optional right bracket (found when array index)\n// - followed by an optional left bracket or dot (type of subscript)\n//\n// Note: These portions can be read in a non-overlapping fashion and\n// allow straightforward parsing of the hierarchy that WebGL encodes\n// in the uniform names.\n\nfunction addUniform( container, uniformObject ) {\n\n\tcontainer.seq.push( uniformObject );\n\tcontainer.map[ uniformObject.id ] = uniformObject;\n\n}\n\nfunction parseUniform( activeInfo, addr, container ) {\n\n\tconst path = activeInfo.name,\n\t\tpathLength = path.length;\n\n\t// reset RegExp object, because of the early exit of a previous run\n\tRePathPart.lastIndex = 0;\n\n\twhile ( true ) {\n\n\t\tconst match = RePathPart.exec( path ),\n\t\t\tmatchEnd = RePathPart.lastIndex;\n\n\t\tlet id = match[ 1 ],\n\t\t\tidIsIndex = match[ 2 ] === ']',\n\t\t\tsubscript = match[ 3 ];\n\n\t\tif ( idIsIndex ) id = id | 0; // convert to integer\n\n\t\tif ( subscript === undefined || subscript === '[' && matchEnd + 2 === pathLength ) {\n\n\t\t\t// bare name or \"pure\" bottom-level array \"[0]\" suffix\n\n\t\t\taddUniform( container, subscript === undefined ?\n\t\t\t\tnew SingleUniform( id, activeInfo, addr ) :\n\t\t\t\tnew PureArrayUniform( id, activeInfo, addr ) );\n\n\t\t\tbreak;\n\n\t\t} else {\n\n\t\t\t// step into inner node / create it in case it doesn't exist\n\n\t\t\tconst map = container.map;\n\t\t\tlet next = map[ id ];\n\n\t\t\tif ( next === undefined ) {\n\n\t\t\t\tnext = new StructuredUniform( id );\n\t\t\t\taddUniform( container, next );\n\n\t\t\t}\n\n\t\t\tcontainer = next;\n\n\t\t}\n\n\t}\n\n}\n\n// Root Container\n\nfunction WebGLUniforms( gl, program ) {\n\n\tthis.seq = [];\n\tthis.map = {};\n\n\tconst n = gl.getProgramParameter( program, gl.ACTIVE_UNIFORMS );\n\n\tfor ( let i = 0; i < n; ++ i ) {\n\n\t\tconst info = gl.getActiveUniform( program, i ),\n\t\t\taddr = gl.getUniformLocation( program, info.name );\n\n\t\tparseUniform( info, addr, this );\n\n\t}\n\n}\n\nWebGLUniforms.prototype.setValue = function ( gl, name, value, textures ) {\n\n\tconst u = this.map[ name ];\n\n\tif ( u !== undefined ) u.setValue( gl, value, textures );\n\n};\n\nWebGLUniforms.prototype.setOptional = function ( gl, object, name ) {\n\n\tconst v = object[ name ];\n\n\tif ( v !== undefined ) this.setValue( gl, name, v );\n\n};\n\n\n// Static interface\n\nWebGLUniforms.upload = function ( gl, seq, values, textures ) {\n\n\tfor ( let i = 0, n = seq.length; i !== n; ++ i ) {\n\n\t\tconst u = seq[ i ],\n\t\t\tv = values[ u.id ];\n\n\t\tif ( v.needsUpdate !== false ) {\n\n\t\t\t// note: always updating when .needsUpdate is undefined\n\t\t\tu.setValue( gl, v.value, textures );\n\n\t\t}\n\n\t}\n\n};\n\nWebGLUniforms.seqWithValue = function ( seq, values ) {\n\n\tconst r = [];\n\n\tfor ( let i = 0, n = seq.length; i !== n; ++ i ) {\n\n\t\tconst u = seq[ i ];\n\t\tif ( u.id in values ) r.push( u );\n\n\t}\n\n\treturn r;\n\n};\n\nexport { WebGLUniforms };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction WebGLShader( gl, type, string ) {\n\n\tconst shader = gl.createShader( type );\n\n\tgl.shaderSource( shader, string );\n\tgl.compileShader( shader );\n\n\treturn shader;\n\n}\n\nexport { WebGLShader };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { WebGLUniforms } from './WebGLUniforms.js';\nimport { WebGLShader } from './WebGLShader.js';\nimport { ShaderChunk } from '../shaders/ShaderChunk.js';\nimport { NoToneMapping, AddOperation, MixOperation, MultiplyOperation, EquirectangularRefractionMapping, CubeRefractionMapping, EquirectangularReflectionMapping, CubeUVRefractionMapping, CubeUVReflectionMapping, CubeReflectionMapping, PCFSoftShadowMap, PCFShadowMap, VSMShadowMap, ACESFilmicToneMapping, CineonToneMapping, CustomToneMapping, ReinhardToneMapping, LinearToneMapping, GammaEncoding, RGBDEncoding, RGBM16Encoding, RGBM7Encoding, RGBEEncoding, sRGBEncoding, LinearEncoding, LogLuvEncoding } from '../../constants.js';\n\nlet programIdCount = 0;\n\nfunction addLineNumbers( string ) {\n\n\tconst lines = string.split( '\\n' );\n\n\tfor ( let i = 0; i < lines.length; i ++ ) {\n\n\t\tlines[ i ] = ( i + 1 ) + ': ' + lines[ i ];\n\n\t}\n\n\treturn lines.join( '\\n' );\n\n}\n\nfunction getEncodingComponents( encoding ) {\n\n\tswitch ( encoding ) {\n\n\t\tcase LinearEncoding:\n\t\t\treturn [ 'Linear', '( value )' ];\n\t\tcase sRGBEncoding:\n\t\t\treturn [ 'sRGB', '( value )' ];\n\t\tcase RGBEEncoding:\n\t\t\treturn [ 'RGBE', '( value )' ];\n\t\tcase RGBM7Encoding:\n\t\t\treturn [ 'RGBM', '( value, 7.0 )' ];\n\t\tcase RGBM16Encoding:\n\t\t\treturn [ 'RGBM', '( value, 16.0 )' ];\n\t\tcase RGBDEncoding:\n\t\t\treturn [ 'RGBD', '( value, 256.0 )' ];\n\t\tcase GammaEncoding:\n\t\t\treturn [ 'Gamma', '( value, float( GAMMA_FACTOR ) )' ];\n\t\tcase LogLuvEncoding:\n\t\t\treturn [ 'LogLuv', '( value )' ];\n\t\tdefault:\n\t\t\tconsole.warn( 'THREE.WebGLProgram: Unsupported encoding:', encoding );\n\t\t\treturn [ 'Linear', '( value )' ];\n\n\t}\n\n}\n\nfunction getShaderErrors( gl, shader, type ) {\n\n\tconst status = gl.getShaderParameter( shader, gl.COMPILE_STATUS );\n\tconst log = gl.getShaderInfoLog( shader ).trim();\n\n\tif ( status && log === '' ) return '';\n\n\t// --enable-privileged-webgl-extension\n\t// console.log( '**' + type + '**', gl.getExtension( 'WEBGL_debug_shaders' ).getTranslatedShaderSource( shader ) );\n\n\tconst source = gl.getShaderSource( shader );\n\n\treturn 'THREE.WebGLShader: gl.getShaderInfoLog() ' + type + '\\n' + log + addLineNumbers( source );\n\n}\n\nfunction getTexelDecodingFunction( functionName, encoding ) {\n\n\tconst components = getEncodingComponents( encoding );\n\treturn 'vec4 ' + functionName + '( vec4 value ) { return ' + components[ 0 ] + 'ToLinear' + components[ 1 ] + '; }';\n\n}\n\nfunction getTexelEncodingFunction( functionName, encoding ) {\n\n\tconst components = getEncodingComponents( encoding );\n\treturn 'vec4 ' + functionName + '( vec4 value ) { return LinearTo' + components[ 0 ] + components[ 1 ] + '; }';\n\n}\n\nfunction getToneMappingFunction( functionName, toneMapping ) {\n\n\tlet toneMappingName;\n\n\tswitch ( toneMapping ) {\n\n\t\tcase LinearToneMapping:\n\t\t\ttoneMappingName = 'Linear';\n\t\t\tbreak;\n\n\t\tcase ReinhardToneMapping:\n\t\t\ttoneMappingName = 'Reinhard';\n\t\t\tbreak;\n\n\t\tcase CineonToneMapping:\n\t\t\ttoneMappingName = 'OptimizedCineon';\n\t\t\tbreak;\n\n\t\tcase ACESFilmicToneMapping:\n\t\t\ttoneMappingName = 'ACESFilmic';\n\t\t\tbreak;\n\n\t\tcase CustomToneMapping:\n\t\t\ttoneMappingName = 'Custom';\n\t\t\tbreak;\n\n\t\tdefault:\n\t\t\tconsole.warn( 'THREE.WebGLProgram: Unsupported toneMapping:', toneMapping );\n\t\t\ttoneMappingName = 'Linear';\n\n\t}\n\n\treturn 'vec3 ' + functionName + '( vec3 color ) { return ' + toneMappingName + 'ToneMapping( color ); }';\n\n}\n\nfunction generateExtensions( parameters ) {\n\n\tconst chunks = [\n\t\t( parameters.extensionDerivatives || parameters.envMapCubeUV || parameters.bumpMap || parameters.tangentSpaceNormalMap || parameters.clearcoatNormalMap || parameters.flatShading || parameters.shaderID === 'physical' ) ? '#extension GL_OES_standard_derivatives : enable' : '',\n\t\t( parameters.extensionFragDepth || parameters.logarithmicDepthBuffer ) && parameters.rendererExtensionFragDepth ? '#extension GL_EXT_frag_depth : enable' : '',\n\t\t( parameters.extensionDrawBuffers && parameters.rendererExtensionDrawBuffers ) ? '#extension GL_EXT_draw_buffers : require' : '',\n\t\t( parameters.extensionShaderTextureLOD || parameters.envMap ) && parameters.rendererExtensionShaderTextureLod ? '#extension GL_EXT_shader_texture_lod : enable' : ''\n\t];\n\n\treturn chunks.filter( filterEmptyLine ).join( '\\n' );\n\n}\n\nfunction generateDefines( defines ) {\n\n\tconst chunks = [];\n\n\tfor ( const name in defines ) {\n\n\t\tconst value = defines[ name ];\n\n\t\tif ( value === false ) continue;\n\n\t\tchunks.push( '#define ' + name + ' ' + value );\n\n\t}\n\n\treturn chunks.join( '\\n' );\n\n}\n\nfunction fetchAttributeLocations( gl, program ) {\n\n\tconst attributes = {};\n\n\tconst n = gl.getProgramParameter( program, gl.ACTIVE_ATTRIBUTES );\n\n\tfor ( let i = 0; i < n; i ++ ) {\n\n\t\tconst info = gl.getActiveAttrib( program, i );\n\t\tconst name = info.name;\n\n\t\t// console.log( 'THREE.WebGLProgram: ACTIVE VERTEX ATTRIBUTE:', name, i );\n\n\t\tattributes[ name ] = gl.getAttribLocation( program, name );\n\n\t}\n\n\treturn attributes;\n\n}\n\nfunction filterEmptyLine( string ) {\n\n\treturn string !== '';\n\n}\n\nfunction replaceLightNums( string, parameters ) {\n\n\treturn string\n\t\t.replace( /NUM_DIR_LIGHTS/g, parameters.numDirLights )\n\t\t.replace( /NUM_SPOT_LIGHTS/g, parameters.numSpotLights )\n\t\t.replace( /NUM_RECT_AREA_LIGHTS/g, parameters.numRectAreaLights )\n\t\t.replace( /NUM_POINT_LIGHTS/g, parameters.numPointLights )\n\t\t.replace( /NUM_HEMI_LIGHTS/g, parameters.numHemiLights )\n\t\t.replace( /NUM_DIR_LIGHT_SHADOWS/g, parameters.numDirLightShadows )\n\t\t.replace( /NUM_SPOT_LIGHT_SHADOWS/g, parameters.numSpotLightShadows )\n\t\t.replace( /NUM_POINT_LIGHT_SHADOWS/g, parameters.numPointLightShadows );\n\n}\n\nfunction replaceClippingPlaneNums( string, parameters ) {\n\n\treturn string\n\t\t.replace( /NUM_CLIPPING_PLANES/g, parameters.numClippingPlanes )\n\t\t.replace( /UNION_CLIPPING_PLANES/g, ( parameters.numClippingPlanes - parameters.numClipIntersection ) );\n\n}\n\n// Resolve Includes\n\nconst includePattern = /^[ \\t]*#include +<([\\w\\d./]+)>/gm;\n\nfunction resolveIncludes( string ) {\n\n\treturn string.replace( includePattern, includeReplacer );\n\n}\n\nfunction includeReplacer( match, include ) {\n\n\tconst string = ShaderChunk[ include ];\n\n\tif ( string === undefined ) {\n\n\t\tthrow new Error( 'Can not resolve #include <' + include + '>' );\n\n\t}\n\n\treturn resolveIncludes( string );\n\n}\n\n// Unroll Loops\n\nconst deprecatedUnrollLoopPattern = /#pragma unroll_loop[\\s]+?for \\( int i \\= (\\d+)\\; i < (\\d+)\\; i \\+\\+ \\) \\{([\\s\\S]+?)(?=\\})\\}/g;\nconst unrollLoopPattern = /#pragma unroll_loop_start[\\s]+?for \\( int i \\= (\\d+)\\; i < (\\d+)\\; i \\+\\+ \\) \\{([\\s\\S]+?)(?=\\})\\}[\\s]+?#pragma unroll_loop_end/g;\n\nfunction unrollLoops( string ) {\n\n\treturn string\n\t\t.replace( unrollLoopPattern, loopReplacer )\n\t\t.replace( deprecatedUnrollLoopPattern, deprecatedLoopReplacer );\n\n}\n\nfunction deprecatedLoopReplacer( match, start, end, snippet ) {\n\n\tconsole.warn( 'WebGLProgram: #pragma unroll_loop shader syntax is deprecated. Please use #pragma unroll_loop_start syntax instead.' );\n\treturn loopReplacer( match, start, end, snippet );\n\n}\n\nfunction loopReplacer( match, start, end, snippet ) {\n\n\tlet string = '';\n\n\tfor ( let i = parseInt( start ); i < parseInt( end ); i ++ ) {\n\n\t\tstring += snippet\n\t\t\t.replace( /\\[ i \\]/g, '[ ' + i + ' ]' )\n\t\t\t.replace( /UNROLLED_LOOP_INDEX/g, i );\n\n\t}\n\n\treturn string;\n\n}\n\n//\n\nfunction generatePrecision( parameters ) {\n\n\tlet precisionstring = \"precision \" + parameters.precision + \" float;\\nprecision \" + parameters.precision + \" int;\";\n\n\tif ( parameters.precision === \"highp\" ) {\n\n\t\tprecisionstring += \"\\n#define HIGH_PRECISION\";\n\n\t} else if ( parameters.precision === \"mediump\" ) {\n\n\t\tprecisionstring += \"\\n#define MEDIUM_PRECISION\";\n\n\t} else if ( parameters.precision === \"lowp\" ) {\n\n\t\tprecisionstring += \"\\n#define LOW_PRECISION\";\n\n\t}\n\n\treturn precisionstring;\n\n}\n\nfunction generateShadowMapTypeDefine( parameters ) {\n\n\tlet shadowMapTypeDefine = 'SHADOWMAP_TYPE_BASIC';\n\n\tif ( parameters.shadowMapType === PCFShadowMap ) {\n\n\t\tshadowMapTypeDefine = 'SHADOWMAP_TYPE_PCF';\n\n\t} else if ( parameters.shadowMapType === PCFSoftShadowMap ) {\n\n\t\tshadowMapTypeDefine = 'SHADOWMAP_TYPE_PCF_SOFT';\n\n\t} else if ( parameters.shadowMapType === VSMShadowMap ) {\n\n\t\tshadowMapTypeDefine = 'SHADOWMAP_TYPE_VSM';\n\n\t}\n\n\treturn shadowMapTypeDefine;\n\n}\n\nfunction generateEnvMapTypeDefine( parameters ) {\n\n\tlet envMapTypeDefine = 'ENVMAP_TYPE_CUBE';\n\n\tif ( parameters.envMap ) {\n\n\t\tswitch ( parameters.envMapMode ) {\n\n\t\t\tcase CubeReflectionMapping:\n\t\t\tcase CubeRefractionMapping:\n\t\t\t\tenvMapTypeDefine = 'ENVMAP_TYPE_CUBE';\n\t\t\t\tbreak;\n\n\t\t\tcase CubeUVReflectionMapping:\n\t\t\tcase CubeUVRefractionMapping:\n\t\t\t\tenvMapTypeDefine = 'ENVMAP_TYPE_CUBE_UV';\n\t\t\t\tbreak;\n\n\t\t\tcase EquirectangularReflectionMapping:\n\t\t\tcase EquirectangularRefractionMapping:\n\t\t\t\tenvMapTypeDefine = 'ENVMAP_TYPE_EQUIREC';\n\t\t\t\tbreak;\n\n\t\t}\n\n\t}\n\n\treturn envMapTypeDefine;\n\n}\n\nfunction generateEnvMapModeDefine( parameters ) {\n\n\tlet envMapModeDefine = 'ENVMAP_MODE_REFLECTION';\n\n\tif ( parameters.envMap ) {\n\n\t\tswitch ( parameters.envMapMode ) {\n\n\t\t\tcase CubeRefractionMapping:\n\t\t\tcase EquirectangularRefractionMapping:\n\t\t\t\tenvMapModeDefine = 'ENVMAP_MODE_REFRACTION';\n\t\t\t\tbreak;\n\n\t\t}\n\n\t}\n\n\treturn envMapModeDefine;\n\n}\n\nfunction generateEnvMapBlendingDefine( parameters ) {\n\n\tlet envMapBlendingDefine = 'ENVMAP_BLENDING_NONE';\n\n\tif ( parameters.envMap ) {\n\n\t\tswitch ( parameters.combine ) {\n\n\t\t\tcase MultiplyOperation:\n\t\t\t\tenvMapBlendingDefine = 'ENVMAP_BLENDING_MULTIPLY';\n\t\t\t\tbreak;\n\n\t\t\tcase MixOperation:\n\t\t\t\tenvMapBlendingDefine = 'ENVMAP_BLENDING_MIX';\n\t\t\t\tbreak;\n\n\t\t\tcase AddOperation:\n\t\t\t\tenvMapBlendingDefine = 'ENVMAP_BLENDING_ADD';\n\t\t\t\tbreak;\n\n\t\t}\n\n\t}\n\n\treturn envMapBlendingDefine;\n\n}\n\nfunction WebGLProgram( renderer, cacheKey, parameters, bindingStates ) {\n\n\tconst gl = renderer.getContext();\n\n\tconst defines = parameters.defines;\n\n\tlet vertexShader = parameters.vertexShader;\n\tlet fragmentShader = parameters.fragmentShader;\n\n\tconst shadowMapTypeDefine = generateShadowMapTypeDefine( parameters );\n\tconst envMapTypeDefine = generateEnvMapTypeDefine( parameters );\n\tconst envMapModeDefine = generateEnvMapModeDefine( parameters );\n\tconst envMapBlendingDefine = generateEnvMapBlendingDefine( parameters );\n\n\n\tconst gammaFactorDefine = ( renderer.gammaFactor > 0 ) ? renderer.gammaFactor : 1.0;\n\n\tconst customExtensions = parameters.isWebGL2 ? '' : generateExtensions( parameters );\n\n\tconst customDefines = generateDefines( defines );\n\n\tconst program = gl.createProgram();\n\n\tlet prefixVertex, prefixFragment;\n\n\tif ( parameters.isRawShaderMaterial ) {\n\n\t\tprefixVertex = [\n\n\t\t\tcustomDefines\n\n\t\t].filter( filterEmptyLine ).join( '\\n' );\n\n\t\tif ( prefixVertex.length > 0 ) {\n\n\t\t\tprefixVertex += '\\n';\n\n\t\t}\n\n\t\tprefixFragment = [\n\n\t\t\tcustomExtensions,\n\t\t\tcustomDefines\n\n\t\t].filter( filterEmptyLine ).join( '\\n' );\n\n\t\tif ( prefixFragment.length > 0 ) {\n\n\t\t\tprefixFragment += '\\n';\n\n\t\t}\n\n\t} else {\n\n\t\tprefixVertex = [\n\n\t\t\tgeneratePrecision( parameters ),\n\n\t\t\t'#define SHADER_NAME ' + parameters.shaderName,\n\n\t\t\tcustomDefines,\n\n\t\t\tparameters.instancing ? '#define USE_INSTANCING' : '',\n\t\t\tparameters.supportsVertexTextures ? '#define VERTEX_TEXTURES' : '',\n\n\t\t\t'#define GAMMA_FACTOR ' + gammaFactorDefine,\n\n\t\t\t'#define MAX_BONES ' + parameters.maxBones,\n\t\t\t( parameters.useFog && parameters.fog ) ? '#define USE_FOG' : '',\n\t\t\t( parameters.useFog && parameters.fogExp2 ) ? '#define FOG_EXP2' : '',\n\n\t\t\tparameters.map ? '#define USE_MAP' : '',\n\t\t\tparameters.envMap ? '#define USE_ENVMAP' : '',\n\t\t\tparameters.envMap ? '#define ' + envMapModeDefine : '',\n\t\t\tparameters.lightMap ? '#define USE_LIGHTMAP' : '',\n\t\t\tparameters.aoMap ? '#define USE_AOMAP' : '',\n\t\t\tparameters.emissiveMap ? '#define USE_EMISSIVEMAP' : '',\n\t\t\tparameters.bumpMap ? '#define USE_BUMPMAP' : '',\n\t\t\tparameters.normalMap ? '#define USE_NORMALMAP' : '',\n\t\t\t( parameters.normalMap && parameters.objectSpaceNormalMap ) ? '#define OBJECTSPACE_NORMALMAP' : '',\n\t\t\t( parameters.normalMap && parameters.tangentSpaceNormalMap ) ? '#define TANGENTSPACE_NORMALMAP' : '',\n\n\t\t\tparameters.clearcoatMap ? '#define USE_CLEARCOATMAP' : '',\n\t\t\tparameters.clearcoatRoughnessMap ? '#define USE_CLEARCOAT_ROUGHNESSMAP' : '',\n\t\t\tparameters.clearcoatNormalMap ? '#define USE_CLEARCOAT_NORMALMAP' : '',\n\t\t\tparameters.displacementMap && parameters.supportsVertexTextures ? '#define USE_DISPLACEMENTMAP' : '',\n\t\t\tparameters.specularMap ? '#define USE_SPECULARMAP' : '',\n\t\t\tparameters.roughnessMap ? '#define USE_ROUGHNESSMAP' : '',\n\t\t\tparameters.metalnessMap ? '#define USE_METALNESSMAP' : '',\n\t\t\tparameters.alphaMap ? '#define USE_ALPHAMAP' : '',\n\n\t\t\tparameters.vertexTangents ? '#define USE_TANGENT' : '',\n\t\t\tparameters.vertexColors ? '#define USE_COLOR' : '',\n\t\t\tparameters.vertexUvs ? '#define USE_UV' : '',\n\t\t\tparameters.uvsVertexOnly ? '#define UVS_VERTEX_ONLY' : '',\n\n\t\t\tparameters.flatShading ? '#define FLAT_SHADED' : '',\n\n\t\t\tparameters.skinning ? '#define USE_SKINNING' : '',\n\t\t\tparameters.useVertexTexture ? '#define BONE_TEXTURE' : '',\n\n\t\t\tparameters.morphTargets ? '#define USE_MORPHTARGETS' : '',\n\t\t\tparameters.morphNormals && parameters.flatShading === false ? '#define USE_MORPHNORMALS' : '',\n\t\t\tparameters.doubleSided ? '#define DOUBLE_SIDED' : '',\n\t\t\tparameters.flipSided ? '#define FLIP_SIDED' : '',\n\n\t\t\tparameters.shadowMapEnabled ? '#define USE_SHADOWMAP' : '',\n\t\t\tparameters.shadowMapEnabled ? '#define ' + shadowMapTypeDefine : '',\n\n\t\t\tparameters.sizeAttenuation ? '#define USE_SIZEATTENUATION' : '',\n\n\t\t\tparameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',\n\t\t\t( parameters.logarithmicDepthBuffer && parameters.rendererExtensionFragDepth ) ? '#define USE_LOGDEPTHBUF_EXT' : '',\n\n\t\t\t'uniform mat4 modelMatrix;',\n\t\t\t'uniform mat4 modelViewMatrix;',\n\t\t\t'uniform mat4 projectionMatrix;',\n\t\t\t'uniform mat4 viewMatrix;',\n\t\t\t'uniform mat3 normalMatrix;',\n\t\t\t'uniform vec3 cameraPosition;',\n\t\t\t'uniform bool isOrthographic;',\n\n\t\t\t'#ifdef USE_INSTANCING',\n\n\t\t\t' attribute mat4 instanceMatrix;',\n\n\t\t\t'#endif',\n\n\t\t\t'attribute vec3 position;',\n\t\t\t'attribute vec3 normal;',\n\t\t\t'attribute vec2 uv;',\n\n\t\t\t'#ifdef USE_TANGENT',\n\n\t\t\t'\tattribute vec4 tangent;',\n\n\t\t\t'#endif',\n\n\t\t\t'#ifdef USE_COLOR',\n\n\t\t\t'\tattribute vec3 color;',\n\n\t\t\t'#endif',\n\n\t\t\t'#ifdef USE_MORPHTARGETS',\n\n\t\t\t'\tattribute vec3 morphTarget0;',\n\t\t\t'\tattribute vec3 morphTarget1;',\n\t\t\t'\tattribute vec3 morphTarget2;',\n\t\t\t'\tattribute vec3 morphTarget3;',\n\n\t\t\t'\t#ifdef USE_MORPHNORMALS',\n\n\t\t\t'\t\tattribute vec3 morphNormal0;',\n\t\t\t'\t\tattribute vec3 morphNormal1;',\n\t\t\t'\t\tattribute vec3 morphNormal2;',\n\t\t\t'\t\tattribute vec3 morphNormal3;',\n\n\t\t\t'\t#else',\n\n\t\t\t'\t\tattribute vec3 morphTarget4;',\n\t\t\t'\t\tattribute vec3 morphTarget5;',\n\t\t\t'\t\tattribute vec3 morphTarget6;',\n\t\t\t'\t\tattribute vec3 morphTarget7;',\n\n\t\t\t'\t#endif',\n\n\t\t\t'#endif',\n\n\t\t\t'#ifdef USE_SKINNING',\n\n\t\t\t'\tattribute vec4 skinIndex;',\n\t\t\t'\tattribute vec4 skinWeight;',\n\n\t\t\t'#endif',\n\n\t\t\t'\\n'\n\n\t\t].filter( filterEmptyLine ).join( '\\n' );\n\n\t\tprefixFragment = [\n\n\t\t\tcustomExtensions,\n\n\t\t\tgeneratePrecision( parameters ),\n\n\t\t\t'#define SHADER_NAME ' + parameters.shaderName,\n\n\t\t\tcustomDefines,\n\n\t\t\tparameters.alphaTest ? '#define ALPHATEST ' + parameters.alphaTest + ( parameters.alphaTest % 1 ? '' : '.0' ) : '', // add '.0' if integer\n\n\t\t\t'#define GAMMA_FACTOR ' + gammaFactorDefine,\n\n\t\t\t( parameters.useFog && parameters.fog ) ? '#define USE_FOG' : '',\n\t\t\t( parameters.useFog && parameters.fogExp2 ) ? '#define FOG_EXP2' : '',\n\n\t\t\tparameters.map ? '#define USE_MAP' : '',\n\t\t\tparameters.matcap ? '#define USE_MATCAP' : '',\n\t\t\tparameters.envMap ? '#define USE_ENVMAP' : '',\n\t\t\tparameters.envMap ? '#define ' + envMapTypeDefine : '',\n\t\t\tparameters.envMap ? '#define ' + envMapModeDefine : '',\n\t\t\tparameters.envMap ? '#define ' + envMapBlendingDefine : '',\n\t\t\tparameters.lightMap ? '#define USE_LIGHTMAP' : '',\n\t\t\tparameters.aoMap ? '#define USE_AOMAP' : '',\n\t\t\tparameters.emissiveMap ? '#define USE_EMISSIVEMAP' : '',\n\t\t\tparameters.bumpMap ? '#define USE_BUMPMAP' : '',\n\t\t\tparameters.normalMap ? '#define USE_NORMALMAP' : '',\n\t\t\t( parameters.normalMap && parameters.objectSpaceNormalMap ) ? '#define OBJECTSPACE_NORMALMAP' : '',\n\t\t\t( parameters.normalMap && parameters.tangentSpaceNormalMap ) ? '#define TANGENTSPACE_NORMALMAP' : '',\n\t\t\tparameters.clearcoatMap ? '#define USE_CLEARCOATMAP' : '',\n\t\t\tparameters.clearcoatRoughnessMap ? '#define USE_CLEARCOAT_ROUGHNESSMAP' : '',\n\t\t\tparameters.clearcoatNormalMap ? '#define USE_CLEARCOAT_NORMALMAP' : '',\n\t\t\tparameters.specularMap ? '#define USE_SPECULARMAP' : '',\n\t\t\tparameters.roughnessMap ? '#define USE_ROUGHNESSMAP' : '',\n\t\t\tparameters.metalnessMap ? '#define USE_METALNESSMAP' : '',\n\t\t\tparameters.alphaMap ? '#define USE_ALPHAMAP' : '',\n\n\t\t\tparameters.sheen ? '#define USE_SHEEN' : '',\n\n\t\t\tparameters.vertexTangents ? '#define USE_TANGENT' : '',\n\t\t\tparameters.vertexColors ? '#define USE_COLOR' : '',\n\t\t\tparameters.vertexUvs ? '#define USE_UV' : '',\n\t\t\tparameters.uvsVertexOnly ? '#define UVS_VERTEX_ONLY' : '',\n\n\t\t\tparameters.gradientMap ? '#define USE_GRADIENTMAP' : '',\n\n\t\t\tparameters.flatShading ? '#define FLAT_SHADED' : '',\n\n\t\t\tparameters.doubleSided ? '#define DOUBLE_SIDED' : '',\n\t\t\tparameters.flipSided ? '#define FLIP_SIDED' : '',\n\n\t\t\tparameters.shadowMapEnabled ? '#define USE_SHADOWMAP' : '',\n\t\t\tparameters.shadowMapEnabled ? '#define ' + shadowMapTypeDefine : '',\n\n\t\t\tparameters.premultipliedAlpha ? '#define PREMULTIPLIED_ALPHA' : '',\n\n\t\t\tparameters.physicallyCorrectLights ? '#define PHYSICALLY_CORRECT_LIGHTS' : '',\n\n\t\t\tparameters.logarithmicDepthBuffer ? '#define USE_LOGDEPTHBUF' : '',\n\t\t\t( parameters.logarithmicDepthBuffer && parameters.rendererExtensionFragDepth ) ? '#define USE_LOGDEPTHBUF_EXT' : '',\n\n\t\t\t( ( parameters.extensionShaderTextureLOD || parameters.envMap ) && parameters.rendererExtensionShaderTextureLod ) ? '#define TEXTURE_LOD_EXT' : '',\n\n\t\t\t'uniform mat4 viewMatrix;',\n\t\t\t'uniform vec3 cameraPosition;',\n\t\t\t'uniform bool isOrthographic;',\n\n\t\t\t( parameters.toneMapping !== NoToneMapping ) ? '#define TONE_MAPPING' : '',\n\t\t\t( parameters.toneMapping !== NoToneMapping ) ? ShaderChunk[ 'tonemapping_pars_fragment' ] : '', // this code is required here because it is used by the toneMapping() function defined below\n\t\t\t( parameters.toneMapping !== NoToneMapping ) ? getToneMappingFunction( 'toneMapping', parameters.toneMapping ) : '',\n\n\t\t\tparameters.dithering ? '#define DITHERING' : '',\n\n\t\t\tShaderChunk[ 'encodings_pars_fragment' ], // this code is required here because it is used by the various encoding/decoding function defined below\n\t\t\tparameters.map ? getTexelDecodingFunction( 'mapTexelToLinear', parameters.mapEncoding ) : '',\n\t\t\tparameters.matcap ? getTexelDecodingFunction( 'matcapTexelToLinear', parameters.matcapEncoding ) : '',\n\t\t\tparameters.envMap ? getTexelDecodingFunction( 'envMapTexelToLinear', parameters.envMapEncoding ) : '',\n\t\t\tparameters.emissiveMap ? getTexelDecodingFunction( 'emissiveMapTexelToLinear', parameters.emissiveMapEncoding ) : '',\n\t\t\tparameters.lightMap ? getTexelDecodingFunction( 'lightMapTexelToLinear', parameters.lightMapEncoding ) : '',\n\t\t\tgetTexelEncodingFunction( 'linearToOutputTexel', parameters.outputEncoding ),\n\n\t\t\tparameters.depthPacking ? '#define DEPTH_PACKING ' + parameters.depthPacking : '',\n\n\t\t\t'\\n'\n\n\t\t].filter( filterEmptyLine ).join( '\\n' );\n\n\t}\n\n\tvertexShader = resolveIncludes( vertexShader );\n\tvertexShader = replaceLightNums( vertexShader, parameters );\n\tvertexShader = replaceClippingPlaneNums( vertexShader, parameters );\n\n\tfragmentShader = resolveIncludes( fragmentShader );\n\tfragmentShader = replaceLightNums( fragmentShader, parameters );\n\tfragmentShader = replaceClippingPlaneNums( fragmentShader, parameters );\n\n\tvertexShader = unrollLoops( vertexShader );\n\tfragmentShader = unrollLoops( fragmentShader );\n\n\tif ( parameters.isWebGL2 && ! parameters.isRawShaderMaterial ) {\n\n\t\tlet isGLSL3ShaderMaterial = false;\n\n\t\tconst versionRegex = /^\\s*#version\\s+300\\s+es\\s*\\n/;\n\n\t\tif ( parameters.isShaderMaterial &&\n\t\t\tvertexShader.match( versionRegex ) !== null &&\n\t\t\tfragmentShader.match( versionRegex ) !== null ) {\n\n\t\t\tisGLSL3ShaderMaterial = true;\n\n\t\t\tvertexShader = vertexShader.replace( versionRegex, '' );\n\t\t\tfragmentShader = fragmentShader.replace( versionRegex, '' );\n\n\t\t}\n\n\t\t// GLSL 3.0 conversion\n\n\t\tprefixVertex = [\n\t\t\t'#version 300 es\\n',\n\t\t\t'#define attribute in',\n\t\t\t'#define varying out',\n\t\t\t'#define texture2D texture'\n\t\t].join( '\\n' ) + '\\n' + prefixVertex;\n\n\t\tprefixFragment = [\n\t\t\t'#version 300 es\\n',\n\t\t\t'#define varying in',\n\t\t\tisGLSL3ShaderMaterial ? '' : 'out highp vec4 pc_fragColor;',\n\t\t\tisGLSL3ShaderMaterial ? '' : '#define gl_FragColor pc_fragColor',\n\t\t\t'#define gl_FragDepthEXT gl_FragDepth',\n\t\t\t'#define texture2D texture',\n\t\t\t'#define textureCube texture',\n\t\t\t'#define texture2DProj textureProj',\n\t\t\t'#define texture2DLodEXT textureLod',\n\t\t\t'#define texture2DProjLodEXT textureProjLod',\n\t\t\t'#define textureCubeLodEXT textureLod',\n\t\t\t'#define texture2DGradEXT textureGrad',\n\t\t\t'#define texture2DProjGradEXT textureProjGrad',\n\t\t\t'#define textureCubeGradEXT textureGrad'\n\t\t].join( '\\n' ) + '\\n' + prefixFragment;\n\n\t}\n\n\tconst vertexGlsl = prefixVertex + vertexShader;\n\tconst fragmentGlsl = prefixFragment + fragmentShader;\n\n\t// console.log( '*VERTEX*', vertexGlsl );\n\t// console.log( '*FRAGMENT*', fragmentGlsl );\n\n\tconst glVertexShader = WebGLShader( gl, gl.VERTEX_SHADER, vertexGlsl );\n\tconst glFragmentShader = WebGLShader( gl, gl.FRAGMENT_SHADER, fragmentGlsl );\n\n\tgl.attachShader( program, glVertexShader );\n\tgl.attachShader( program, glFragmentShader );\n\n\t// Force a particular attribute to index 0.\n\n\tif ( parameters.index0AttributeName !== undefined ) {\n\n\t\tgl.bindAttribLocation( program, 0, parameters.index0AttributeName );\n\n\t} else if ( parameters.morphTargets === true ) {\n\n\t\t// programs with morphTargets displace position out of attribute 0\n\t\tgl.bindAttribLocation( program, 0, 'position' );\n\n\t}\n\n\tgl.linkProgram( program );\n\n\t// check for link errors\n\tif ( renderer.debug.checkShaderErrors ) {\n\n\t\tconst programLog = gl.getProgramInfoLog( program ).trim();\n\t\tconst vertexLog = gl.getShaderInfoLog( glVertexShader ).trim();\n\t\tconst fragmentLog = gl.getShaderInfoLog( glFragmentShader ).trim();\n\n\t\tlet runnable = true;\n\t\tlet haveDiagnostics = true;\n\n\t\tif ( gl.getProgramParameter( program, gl.LINK_STATUS ) === false ) {\n\n\t\t\trunnable = false;\n\n\t\t\tconst vertexErrors = getShaderErrors( gl, glVertexShader, 'vertex' );\n\t\t\tconst fragmentErrors = getShaderErrors( gl, glFragmentShader, 'fragment' );\n\n\t\t\tconsole.error( 'THREE.WebGLProgram: shader error: ', gl.getError(), 'gl.VALIDATE_STATUS', gl.getProgramParameter( program, gl.VALIDATE_STATUS ), 'gl.getProgramInfoLog', programLog, vertexErrors, fragmentErrors );\n\n\t\t} else if ( programLog !== '' ) {\n\n\t\t\tconsole.warn( 'THREE.WebGLProgram: gl.getProgramInfoLog()', programLog );\n\n\t\t} else if ( vertexLog === '' || fragmentLog === '' ) {\n\n\t\t\thaveDiagnostics = false;\n\n\t\t}\n\n\t\tif ( haveDiagnostics ) {\n\n\t\t\tthis.diagnostics = {\n\n\t\t\t\trunnable: runnable,\n\n\t\t\t\tprogramLog: programLog,\n\n\t\t\t\tvertexShader: {\n\n\t\t\t\t\tlog: vertexLog,\n\t\t\t\t\tprefix: prefixVertex\n\n\t\t\t\t},\n\n\t\t\t\tfragmentShader: {\n\n\t\t\t\t\tlog: fragmentLog,\n\t\t\t\t\tprefix: prefixFragment\n\n\t\t\t\t}\n\n\t\t\t};\n\n\t\t}\n\n\t}\n\n\t// Clean up\n\n\t// Crashes in iOS9 and iOS10. #18402\n\t// gl.detachShader( program, glVertexShader );\n\t// gl.detachShader( program, glFragmentShader );\n\n\tgl.deleteShader( glVertexShader );\n\tgl.deleteShader( glFragmentShader );\n\n\t// set up caching for uniform locations\n\n\tlet cachedUniforms;\n\n\tthis.getUniforms = function () {\n\n\t\tif ( cachedUniforms === undefined ) {\n\n\t\t\tcachedUniforms = new WebGLUniforms( gl, program );\n\n\t\t}\n\n\t\treturn cachedUniforms;\n\n\t};\n\n\t// set up caching for attribute locations\n\n\tlet cachedAttributes;\n\n\tthis.getAttributes = function () {\n\n\t\tif ( cachedAttributes === undefined ) {\n\n\t\t\tcachedAttributes = fetchAttributeLocations( gl, program );\n\n\t\t}\n\n\t\treturn cachedAttributes;\n\n\t};\n\n\t// free resource\n\n\tthis.destroy = function () {\n\n\t\tbindingStates.releaseStatesOfProgram( this );\n\n\t\tgl.deleteProgram( program );\n\t\tthis.program = undefined;\n\n\t};\n\n\t//\n\n\tthis.name = parameters.shaderName;\n\tthis.id = programIdCount ++;\n\tthis.cacheKey = cacheKey;\n\tthis.usedTimes = 1;\n\tthis.program = program;\n\tthis.vertexShader = glVertexShader;\n\tthis.fragmentShader = glFragmentShader;\n\n\treturn this;\n\n}\n\nexport { WebGLProgram };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { BackSide, DoubleSide, CubeUVRefractionMapping, CubeUVReflectionMapping, LinearEncoding, ObjectSpaceNormalMap, TangentSpaceNormalMap, NoToneMapping } from '../../constants.js';\nimport { WebGLProgram } from './WebGLProgram.js';\nimport { ShaderLib } from '../shaders/ShaderLib.js';\nimport { UniformsUtils } from '../shaders/UniformsUtils.js';\n\nfunction WebGLPrograms( renderer, extensions, capabilities, bindingStates ) {\n\n\tconst programs = [];\n\n\tconst isWebGL2 = capabilities.isWebGL2;\n\tconst logarithmicDepthBuffer = capabilities.logarithmicDepthBuffer;\n\tconst floatVertexTextures = capabilities.floatVertexTextures;\n\tconst maxVertexUniforms = capabilities.maxVertexUniforms;\n\tconst vertexTextures = capabilities.vertexTextures;\n\n\tlet precision = capabilities.precision;\n\n\tconst shaderIDs = {\n\t\tMeshDepthMaterial: 'depth',\n\t\tMeshDistanceMaterial: 'distanceRGBA',\n\t\tMeshNormalMaterial: 'normal',\n\t\tMeshBasicMaterial: 'basic',\n\t\tMeshLambertMaterial: 'lambert',\n\t\tMeshPhongMaterial: 'phong',\n\t\tMeshToonMaterial: 'toon',\n\t\tMeshStandardMaterial: 'physical',\n\t\tMeshPhysicalMaterial: 'physical',\n\t\tMeshMatcapMaterial: 'matcap',\n\t\tLineBasicMaterial: 'basic',\n\t\tLineDashedMaterial: 'dashed',\n\t\tPointsMaterial: 'points',\n\t\tShadowMaterial: 'shadow',\n\t\tSpriteMaterial: 'sprite'\n\t};\n\n\tconst parameterNames = [\n\t\t\"precision\", \"isWebGL2\", \"supportsVertexTextures\", \"outputEncoding\", \"instancing\",\n\t\t\"map\", \"mapEncoding\", \"matcap\", \"matcapEncoding\", \"envMap\", \"envMapMode\", \"envMapEncoding\", \"envMapCubeUV\",\n\t\t\"lightMap\", \"lightMapEncoding\", \"aoMap\", \"emissiveMap\", \"emissiveMapEncoding\", \"bumpMap\", \"normalMap\", \"objectSpaceNormalMap\", \"tangentSpaceNormalMap\", \"clearcoatMap\", \"clearcoatRoughnessMap\", \"clearcoatNormalMap\", \"displacementMap\", \"specularMap\",\n\t\t\"roughnessMap\", \"metalnessMap\", \"gradientMap\",\n\t\t\"alphaMap\", \"combine\", \"vertexColors\", \"vertexTangents\", \"vertexUvs\", \"uvsVertexOnly\", \"fog\", \"useFog\", \"fogExp2\",\n\t\t\"flatShading\", \"sizeAttenuation\", \"logarithmicDepthBuffer\", \"skinning\",\n\t\t\"maxBones\", \"useVertexTexture\", \"morphTargets\", \"morphNormals\",\n\t\t\"maxMorphTargets\", \"maxMorphNormals\", \"premultipliedAlpha\",\n\t\t\"numDirLights\", \"numPointLights\", \"numSpotLights\", \"numHemiLights\", \"numRectAreaLights\",\n\t\t\"numDirLightShadows\", \"numPointLightShadows\", \"numSpotLightShadows\",\n\t\t\"shadowMapEnabled\", \"shadowMapType\", \"toneMapping\", 'physicallyCorrectLights',\n\t\t\"alphaTest\", \"doubleSided\", \"flipSided\", \"numClippingPlanes\", \"numClipIntersection\", \"depthPacking\", \"dithering\",\n\t\t\"sheen\"\n\t];\n\n\tfunction getShaderObject( material, shaderID ) {\n\n\t\tlet shaderobject;\n\n\t\tif ( shaderID ) {\n\n\t\t\tconst shader = ShaderLib[ shaderID ];\n\n\t\t\tshaderobject = {\n\t\t\t\tname: material.name || material.type,\n\t\t\t\tuniforms: UniformsUtils.clone( shader.uniforms ),\n\t\t\t\tvertexShader: shader.vertexShader,\n\t\t\t\tfragmentShader: shader.fragmentShader\n\t\t\t};\n\n\t\t} else {\n\n\t\t\tshaderobject = {\n\t\t\t\tname: material.name || material.type,\n\t\t\t\tuniforms: material.uniforms,\n\t\t\t\tvertexShader: material.vertexShader,\n\t\t\t\tfragmentShader: material.fragmentShader\n\t\t\t};\n\n\t\t}\n\n\t\treturn shaderobject;\n\n\t}\n\n\tfunction allocateBones( object ) {\n\n\t\tconst skeleton = object.skeleton;\n\t\tconst bones = skeleton.bones;\n\n\t\tif ( floatVertexTextures ) {\n\n\t\t\treturn 1024;\n\n\t\t} else {\n\n\t\t\t// default for when object is not specified\n\t\t\t// ( for example when prebuilding shader to be used with multiple objects )\n\t\t\t//\n\t\t\t// - leave some extra space for other uniforms\n\t\t\t// - limit here is ANGLE's 254 max uniform vectors\n\t\t\t// (up to 54 should be safe)\n\n\t\t\tconst nVertexUniforms = maxVertexUniforms;\n\t\t\tconst nVertexMatrices = Math.floor( ( nVertexUniforms - 20 ) / 4 );\n\n\t\t\tconst maxBones = Math.min( nVertexMatrices, bones.length );\n\n\t\t\tif ( maxBones < bones.length ) {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Skeleton has ' + bones.length + ' bones. This GPU supports ' + maxBones + '.' );\n\t\t\t\treturn 0;\n\n\t\t\t}\n\n\t\t\treturn maxBones;\n\n\t\t}\n\n\t}\n\n\tfunction getTextureEncodingFromMap( map ) {\n\n\t\tlet encoding;\n\n\t\tif ( ! map ) {\n\n\t\t\tencoding = LinearEncoding;\n\n\t\t} else if ( map.isTexture ) {\n\n\t\t\tencoding = map.encoding;\n\n\t\t} else if ( map.isWebGLRenderTarget ) {\n\n\t\t\tconsole.warn( \"THREE.WebGLPrograms.getTextureEncodingFromMap: don't use render targets as textures. Use their .texture property instead.\" );\n\t\t\tencoding = map.texture.encoding;\n\n\t\t}\n\n\t\treturn encoding;\n\n\t}\n\n\tfunction getParameters( material, lights, shadows, scene, nClipPlanes, nClipIntersection, object ) {\n\n\t\tconst fog = scene.fog;\n\t\tconst environment = material.isMeshStandardMaterial ? scene.environment : null;\n\n\t\tconst envMap = material.envMap || environment;\n\n\t\tconst shaderID = shaderIDs[ material.type ];\n\n\t\t// heuristics to create shader parameters according to lights in the scene\n\t\t// (not to blow over maxLights budget)\n\n\t\tconst maxBones = object.isSkinnedMesh ? allocateBones( object ) : 0;\n\n\t\tif ( material.precision !== null ) {\n\n\t\t\tprecision = capabilities.getMaxPrecision( material.precision );\n\n\t\t\tif ( precision !== material.precision ) {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLProgram.getParameters:', material.precision, 'not supported, using', precision, 'instead.' );\n\n\t\t\t}\n\n\t\t}\n\n\t\tconst shaderobject = getShaderObject( material, shaderID );\n\t\tmaterial.onBeforeCompile( shaderobject, renderer );\n\n\t\tconst currentRenderTarget = renderer.getRenderTarget();\n\n\t\tconst parameters = {\n\n\t\t\tisWebGL2: isWebGL2,\n\n\t\t\tshaderID: shaderID,\n\t\t\tshaderName: shaderobject.name,\n\n\t\t\tuniforms: shaderobject.uniforms,\n\t\t\tvertexShader: shaderobject.vertexShader,\n\t\t\tfragmentShader: shaderobject.fragmentShader,\n\t\t\tdefines: material.defines,\n\n\t\t\tisRawShaderMaterial: material.isRawShaderMaterial,\n\t\t\tisShaderMaterial: material.isShaderMaterial,\n\n\t\t\tprecision: precision,\n\n\t\t\tinstancing: object.isInstancedMesh === true,\n\n\t\t\tsupportsVertexTextures: vertexTextures,\n\t\t\toutputEncoding: ( currentRenderTarget !== null ) ? getTextureEncodingFromMap( currentRenderTarget.texture ) : renderer.outputEncoding,\n\t\t\tmap: !! material.map,\n\t\t\tmapEncoding: getTextureEncodingFromMap( material.map ),\n\t\t\tmatcap: !! material.matcap,\n\t\t\tmatcapEncoding: getTextureEncodingFromMap( material.matcap ),\n\t\t\tenvMap: !! envMap,\n\t\t\tenvMapMode: envMap && envMap.mapping,\n\t\t\tenvMapEncoding: getTextureEncodingFromMap( envMap ),\n\t\t\tenvMapCubeUV: ( !! envMap ) && ( ( envMap.mapping === CubeUVReflectionMapping ) || ( envMap.mapping === CubeUVRefractionMapping ) ),\n\t\t\tlightMap: !! material.lightMap,\n\t\t\tlightMapEncoding: getTextureEncodingFromMap( material.lightMap ),\n\t\t\taoMap: !! material.aoMap,\n\t\t\temissiveMap: !! material.emissiveMap,\n\t\t\temissiveMapEncoding: getTextureEncodingFromMap( material.emissiveMap ),\n\t\t\tbumpMap: !! material.bumpMap,\n\t\t\tnormalMap: !! material.normalMap,\n\t\t\tobjectSpaceNormalMap: material.normalMapType === ObjectSpaceNormalMap,\n\t\t\ttangentSpaceNormalMap: material.normalMapType === TangentSpaceNormalMap,\n\t\t\tclearcoatMap: !! material.clearcoatMap,\n\t\t\tclearcoatRoughnessMap: !! material.clearcoatRoughnessMap,\n\t\t\tclearcoatNormalMap: !! material.clearcoatNormalMap,\n\t\t\tdisplacementMap: !! material.displacementMap,\n\t\t\troughnessMap: !! material.roughnessMap,\n\t\t\tmetalnessMap: !! material.metalnessMap,\n\t\t\tspecularMap: !! material.specularMap,\n\t\t\talphaMap: !! material.alphaMap,\n\n\t\t\tgradientMap: !! material.gradientMap,\n\n\t\t\tsheen: !! material.sheen,\n\n\t\t\tcombine: material.combine,\n\n\t\t\tvertexTangents: ( material.normalMap && material.vertexTangents ),\n\t\t\tvertexColors: material.vertexColors,\n\t\t\tvertexUvs: !! material.map || !! material.bumpMap || !! material.normalMap || !! material.specularMap || !! material.alphaMap || !! material.emissiveMap || !! material.roughnessMap || !! material.metalnessMap || !! material.clearcoatMap || !! material.clearcoatRoughnessMap || !! material.clearcoatNormalMap || !! material.displacementMap,\n\t\t\tuvsVertexOnly: ! ( !! material.map || !! material.bumpMap || !! material.normalMap || !! material.specularMap || !! material.alphaMap || !! material.emissiveMap || !! material.roughnessMap || !! material.metalnessMap || !! material.clearcoatNormalMap ) && !! material.displacementMap,\n\n\t\t\tfog: !! fog,\n\t\t\tuseFog: material.fog,\n\t\t\tfogExp2: ( fog && fog.isFogExp2 ),\n\n\t\t\tflatShading: material.flatShading,\n\n\t\t\tsizeAttenuation: material.sizeAttenuation,\n\t\t\tlogarithmicDepthBuffer: logarithmicDepthBuffer,\n\n\t\t\tskinning: material.skinning && maxBones > 0,\n\t\t\tmaxBones: maxBones,\n\t\t\tuseVertexTexture: floatVertexTextures,\n\n\t\t\tmorphTargets: material.morphTargets,\n\t\t\tmorphNormals: material.morphNormals,\n\t\t\tmaxMorphTargets: renderer.maxMorphTargets,\n\t\t\tmaxMorphNormals: renderer.maxMorphNormals,\n\n\t\t\tnumDirLights: lights.directional.length,\n\t\t\tnumPointLights: lights.point.length,\n\t\t\tnumSpotLights: lights.spot.length,\n\t\t\tnumRectAreaLights: lights.rectArea.length,\n\t\t\tnumHemiLights: lights.hemi.length,\n\n\t\t\tnumDirLightShadows: lights.directionalShadowMap.length,\n\t\t\tnumPointLightShadows: lights.pointShadowMap.length,\n\t\t\tnumSpotLightShadows: lights.spotShadowMap.length,\n\n\t\t\tnumClippingPlanes: nClipPlanes,\n\t\t\tnumClipIntersection: nClipIntersection,\n\n\t\t\tdithering: material.dithering,\n\n\t\t\tshadowMapEnabled: renderer.shadowMap.enabled && shadows.length > 0,\n\t\t\tshadowMapType: renderer.shadowMap.type,\n\n\t\t\ttoneMapping: material.toneMapped ? renderer.toneMapping : NoToneMapping,\n\t\t\tphysicallyCorrectLights: renderer.physicallyCorrectLights,\n\n\t\t\tpremultipliedAlpha: material.premultipliedAlpha,\n\n\t\t\talphaTest: material.alphaTest,\n\t\t\tdoubleSided: material.side === DoubleSide,\n\t\t\tflipSided: material.side === BackSide,\n\n\t\t\tdepthPacking: ( material.depthPacking !== undefined ) ? material.depthPacking : false,\n\n\t\t\tindex0AttributeName: material.index0AttributeName,\n\n\t\t\textensionDerivatives: material.extensions && material.extensions.derivatives,\n\t\t\textensionFragDepth: material.extensions && material.extensions.fragDepth,\n\t\t\textensionDrawBuffers: material.extensions && material.extensions.drawBuffers,\n\t\t\textensionShaderTextureLOD: material.extensions && material.extensions.shaderTextureLOD,\n\n\t\t\trendererExtensionFragDepth: isWebGL2 || extensions.get( 'EXT_frag_depth' ) !== null,\n\t\t\trendererExtensionDrawBuffers: isWebGL2 || extensions.get( 'WEBGL_draw_buffers' ) !== null,\n\t\t\trendererExtensionShaderTextureLod: isWebGL2 || extensions.get( 'EXT_shader_texture_lod' ) !== null,\n\n\t\t\tcustomProgramCacheKey: material.customProgramCacheKey()\n\n\t\t};\n\n\t\treturn parameters;\n\n\t}\n\n\tfunction getProgramCacheKey( parameters ) {\n\n\t\tconst array = [];\n\n\t\tif ( parameters.shaderID ) {\n\n\t\t\tarray.push( parameters.shaderID );\n\n\t\t} else {\n\n\t\t\tarray.push( parameters.fragmentShader );\n\t\t\tarray.push( parameters.vertexShader );\n\n\t\t}\n\n\t\tif ( parameters.defines !== undefined ) {\n\n\t\t\tfor ( const name in parameters.defines ) {\n\n\t\t\t\tarray.push( name );\n\t\t\t\tarray.push( parameters.defines[ name ] );\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( parameters.isRawShaderMaterial === undefined ) {\n\n\t\t\tfor ( let i = 0; i < parameterNames.length; i ++ ) {\n\n\t\t\t\tarray.push( parameters[ parameterNames[ i ] ] );\n\n\t\t\t}\n\n\t\t\tarray.push( renderer.outputEncoding );\n\t\t\tarray.push( renderer.gammaFactor );\n\n\t\t}\n\n\t\tarray.push( parameters.customProgramCacheKey );\n\n\t\treturn array.join();\n\n\t}\n\n\tfunction acquireProgram( parameters, cacheKey ) {\n\n\t\tlet program;\n\n\t\t// Check if code has been already compiled\n\t\tfor ( let p = 0, pl = programs.length; p < pl; p ++ ) {\n\n\t\t\tconst preexistingProgram = programs[ p ];\n\n\t\t\tif ( preexistingProgram.cacheKey === cacheKey ) {\n\n\t\t\t\tprogram = preexistingProgram;\n\t\t\t\t++ program.usedTimes;\n\n\t\t\t\tbreak;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( program === undefined ) {\n\n\t\t\tprogram = new WebGLProgram( renderer, cacheKey, parameters, bindingStates );\n\t\t\tprograms.push( program );\n\n\t\t}\n\n\t\treturn program;\n\n\t}\n\n\tfunction releaseProgram( program ) {\n\n\t\tif ( -- program.usedTimes === 0 ) {\n\n\t\t\t// Remove from unordered set\n\t\t\tconst i = programs.indexOf( program );\n\t\t\tprograms[ i ] = programs[ programs.length - 1 ];\n\t\t\tprograms.pop();\n\n\t\t\t// Free WebGL resources\n\t\t\tprogram.destroy();\n\n\t\t}\n\n\t}\n\n\treturn {\n\t\tgetParameters: getParameters,\n\t\tgetProgramCacheKey: getProgramCacheKey,\n\t\tacquireProgram: acquireProgram,\n\t\treleaseProgram: releaseProgram,\n\t\t// Exposed for resource monitoring & error feedback via renderer.info:\n\t\tprograms: programs\n\t};\n\n}\n\n\nexport { WebGLPrograms };\n","/**\n * @author fordacious / fordacious.github.io\n */\n\nfunction WebGLProperties() {\n\n\tlet properties = new WeakMap();\n\n\tfunction get( object ) {\n\n\t\tlet map = properties.get( object );\n\n\t\tif ( map === undefined ) {\n\n\t\t\tmap = {};\n\t\t\tproperties.set( object, map );\n\n\t\t}\n\n\t\treturn map;\n\n\t}\n\n\tfunction remove( object ) {\n\n\t\tproperties.delete( object );\n\n\t}\n\n\tfunction update( object, key, value ) {\n\n\t\tproperties.get( object )[ key ] = value;\n\n\t}\n\n\tfunction dispose() {\n\n\t\tproperties = new WeakMap();\n\n\t}\n\n\treturn {\n\t\tget: get,\n\t\tremove: remove,\n\t\tupdate: update,\n\t\tdispose: dispose\n\t};\n\n}\n\n\nexport { WebGLProperties };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction painterSortStable( a, b ) {\n\n\tif ( a.groupOrder !== b.groupOrder ) {\n\n\t\treturn a.groupOrder - b.groupOrder;\n\n\t} else if ( a.renderOrder !== b.renderOrder ) {\n\n\t\treturn a.renderOrder - b.renderOrder;\n\n\t} else if ( a.program !== b.program ) {\n\n\t\treturn a.program.id - b.program.id;\n\n\t} else if ( a.material.id !== b.material.id ) {\n\n\t\treturn a.material.id - b.material.id;\n\n\t} else if ( a.z !== b.z ) {\n\n\t\treturn a.z - b.z;\n\n\t} else {\n\n\t\treturn a.id - b.id;\n\n\t}\n\n}\n\nfunction reversePainterSortStable( a, b ) {\n\n\tif ( a.groupOrder !== b.groupOrder ) {\n\n\t\treturn a.groupOrder - b.groupOrder;\n\n\t} else if ( a.renderOrder !== b.renderOrder ) {\n\n\t\treturn a.renderOrder - b.renderOrder;\n\n\t} else if ( a.z !== b.z ) {\n\n\t\treturn b.z - a.z;\n\n\t} else {\n\n\t\treturn a.id - b.id;\n\n\t}\n\n}\n\n\nfunction WebGLRenderList() {\n\n\tconst renderItems = [];\n\tlet renderItemsIndex = 0;\n\n\tconst opaque = [];\n\tconst transparent = [];\n\n\tconst defaultProgram = { id: - 1 };\n\n\tfunction init() {\n\n\t\trenderItemsIndex = 0;\n\n\t\topaque.length = 0;\n\t\ttransparent.length = 0;\n\n\t}\n\n\tfunction getNextRenderItem( object, geometry, material, groupOrder, z, group ) {\n\n\t\tlet renderItem = renderItems[ renderItemsIndex ];\n\n\t\tif ( renderItem === undefined ) {\n\n\t\t\trenderItem = {\n\t\t\t\tid: object.id,\n\t\t\t\tobject: object,\n\t\t\t\tgeometry: geometry,\n\t\t\t\tmaterial: material,\n\t\t\t\tprogram: material.program || defaultProgram,\n\t\t\t\tgroupOrder: groupOrder,\n\t\t\t\trenderOrder: object.renderOrder,\n\t\t\t\tz: z,\n\t\t\t\tgroup: group\n\t\t\t};\n\n\t\t\trenderItems[ renderItemsIndex ] = renderItem;\n\n\t\t} else {\n\n\t\t\trenderItem.id = object.id;\n\t\t\trenderItem.object = object;\n\t\t\trenderItem.geometry = geometry;\n\t\t\trenderItem.material = material;\n\t\t\trenderItem.program = material.program || defaultProgram;\n\t\t\trenderItem.groupOrder = groupOrder;\n\t\t\trenderItem.renderOrder = object.renderOrder;\n\t\t\trenderItem.z = z;\n\t\t\trenderItem.group = group;\n\n\t\t}\n\n\t\trenderItemsIndex ++;\n\n\t\treturn renderItem;\n\n\t}\n\n\tfunction push( object, geometry, material, groupOrder, z, group ) {\n\n\t\tconst renderItem = getNextRenderItem( object, geometry, material, groupOrder, z, group );\n\n\t\t( material.transparent === true ? transparent : opaque ).push( renderItem );\n\n\t}\n\n\tfunction unshift( object, geometry, material, groupOrder, z, group ) {\n\n\t\tconst renderItem = getNextRenderItem( object, geometry, material, groupOrder, z, group );\n\n\t\t( material.transparent === true ? transparent : opaque ).unshift( renderItem );\n\n\t}\n\n\tfunction sort( customOpaqueSort, customTransparentSort ) {\n\n\t\tif ( opaque.length > 1 ) opaque.sort( customOpaqueSort || painterSortStable );\n\t\tif ( transparent.length > 1 ) transparent.sort( customTransparentSort || reversePainterSortStable );\n\n\t}\n\n\tfunction finish() {\n\n\t\t// Clear references from inactive renderItems in the list\n\n\t\tfor ( let i = renderItemsIndex, il = renderItems.length; i < il; i ++ ) {\n\n\t\t\tconst renderItem = renderItems[ i ];\n\n\t\t\tif ( renderItem.id === null ) break;\n\n\t\t\trenderItem.id = null;\n\t\t\trenderItem.object = null;\n\t\t\trenderItem.geometry = null;\n\t\t\trenderItem.material = null;\n\t\t\trenderItem.program = null;\n\t\t\trenderItem.group = null;\n\n\t\t}\n\n\t}\n\n\treturn {\n\t\topaque: opaque,\n\t\ttransparent: transparent,\n\n\t\tinit: init,\n\t\tpush: push,\n\t\tunshift: unshift,\n\t\tfinish: finish,\n\n\t\tsort: sort\n\t};\n\n}\n\nfunction WebGLRenderLists() {\n\n\tlet lists = new WeakMap();\n\n\tfunction onSceneDispose( event ) {\n\n\t\tconst scene = event.target;\n\n\t\tscene.removeEventListener( 'dispose', onSceneDispose );\n\n\t\tlists.delete( scene );\n\n\t}\n\n\tfunction get( scene, camera ) {\n\n\t\tconst cameras = lists.get( scene );\n\t\tlet list;\n\n\t\tif ( cameras === undefined ) {\n\n\t\t\tlist = new WebGLRenderList();\n\t\t\tlists.set( scene, new WeakMap() );\n\t\t\tlists.get( scene ).set( camera, list );\n\n\t\t\tscene.addEventListener( 'dispose', onSceneDispose );\n\n\t\t} else {\n\n\t\t\tlist = cameras.get( camera );\n\t\t\tif ( list === undefined ) {\n\n\t\t\t\tlist = new WebGLRenderList();\n\t\t\t\tcameras.set( camera, list );\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn list;\n\n\t}\n\n\tfunction dispose() {\n\n\t\tlists = new WeakMap();\n\n\t}\n\n\treturn {\n\t\tget: get,\n\t\tdispose: dispose\n\t};\n\n}\n\n\nexport { WebGLRenderLists };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { Color } from '../../math/Color.js';\nimport { Matrix4 } from '../../math/Matrix4.js';\nimport { Vector2 } from '../../math/Vector2.js';\nimport { Vector3 } from '../../math/Vector3.js';\n\nfunction UniformsCache() {\n\n\tconst lights = {};\n\n\treturn {\n\n\t\tget: function ( light ) {\n\n\t\t\tif ( lights[ light.id ] !== undefined ) {\n\n\t\t\t\treturn lights[ light.id ];\n\n\t\t\t}\n\n\t\t\tlet uniforms;\n\n\t\t\tswitch ( light.type ) {\n\n\t\t\t\tcase 'DirectionalLight':\n\t\t\t\t\tuniforms = {\n\t\t\t\t\t\tdirection: new Vector3(),\n\t\t\t\t\t\tcolor: new Color()\n\t\t\t\t\t};\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'SpotLight':\n\t\t\t\t\tuniforms = {\n\t\t\t\t\t\tposition: new Vector3(),\n\t\t\t\t\t\tdirection: new Vector3(),\n\t\t\t\t\t\tcolor: new Color(),\n\t\t\t\t\t\tdistance: 0,\n\t\t\t\t\t\tconeCos: 0,\n\t\t\t\t\t\tpenumbraCos: 0,\n\t\t\t\t\t\tdecay: 0\n\t\t\t\t\t};\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'PointLight':\n\t\t\t\t\tuniforms = {\n\t\t\t\t\t\tposition: new Vector3(),\n\t\t\t\t\t\tcolor: new Color(),\n\t\t\t\t\t\tdistance: 0,\n\t\t\t\t\t\tdecay: 0\n\t\t\t\t\t};\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'HemisphereLight':\n\t\t\t\t\tuniforms = {\n\t\t\t\t\t\tdirection: new Vector3(),\n\t\t\t\t\t\tskyColor: new Color(),\n\t\t\t\t\t\tgroundColor: new Color()\n\t\t\t\t\t};\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'RectAreaLight':\n\t\t\t\t\tuniforms = {\n\t\t\t\t\t\tcolor: new Color(),\n\t\t\t\t\t\tposition: new Vector3(),\n\t\t\t\t\t\thalfWidth: new Vector3(),\n\t\t\t\t\t\thalfHeight: new Vector3()\n\t\t\t\t\t};\n\t\t\t\t\tbreak;\n\n\t\t\t}\n\n\t\t\tlights[ light.id ] = uniforms;\n\n\t\t\treturn uniforms;\n\n\t\t}\n\n\t};\n\n}\n\nfunction ShadowUniformsCache() {\n\n\tconst lights = {};\n\n\treturn {\n\n\t\tget: function ( light ) {\n\n\t\t\tif ( lights[ light.id ] !== undefined ) {\n\n\t\t\t\treturn lights[ light.id ];\n\n\t\t\t}\n\n\t\t\tlet uniforms;\n\n\t\t\tswitch ( light.type ) {\n\n\t\t\t\tcase 'DirectionalLight':\n\t\t\t\t\tuniforms = {\n\t\t\t\t\t\tshadowBias: 0,\n\t\t\t\t\t\tshadowNormalBias: 0,\n\t\t\t\t\t\tshadowRadius: 1,\n\t\t\t\t\t\tshadowMapSize: new Vector2()\n\t\t\t\t\t};\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'SpotLight':\n\t\t\t\t\tuniforms = {\n\t\t\t\t\t\tshadowBias: 0,\n\t\t\t\t\t\tshadowNormalBias: 0,\n\t\t\t\t\t\tshadowRadius: 1,\n\t\t\t\t\t\tshadowMapSize: new Vector2()\n\t\t\t\t\t};\n\t\t\t\t\tbreak;\n\n\t\t\t\tcase 'PointLight':\n\t\t\t\t\tuniforms = {\n\t\t\t\t\t\tshadowBias: 0,\n\t\t\t\t\t\tshadowNormalBias: 0,\n\t\t\t\t\t\tshadowRadius: 1,\n\t\t\t\t\t\tshadowMapSize: new Vector2(),\n\t\t\t\t\t\tshadowCameraNear: 1,\n\t\t\t\t\t\tshadowCameraFar: 1000\n\t\t\t\t\t};\n\t\t\t\t\tbreak;\n\n\t\t\t\t// TODO (abelnation): set RectAreaLight shadow uniforms\n\n\t\t\t}\n\n\t\t\tlights[ light.id ] = uniforms;\n\n\t\t\treturn uniforms;\n\n\t\t}\n\n\t};\n\n}\n\n\n\nlet nextVersion = 0;\n\nfunction shadowCastingLightsFirst( lightA, lightB ) {\n\n\treturn ( lightB.castShadow ? 1 : 0 ) - ( lightA.castShadow ? 1 : 0 );\n\n}\n\nfunction WebGLLights() {\n\n\tconst cache = new UniformsCache();\n\n\tconst shadowCache = ShadowUniformsCache();\n\n\tconst state = {\n\n\t\tversion: 0,\n\n\t\thash: {\n\t\t\tdirectionalLength: - 1,\n\t\t\tpointLength: - 1,\n\t\t\tspotLength: - 1,\n\t\t\trectAreaLength: - 1,\n\t\t\themiLength: - 1,\n\n\t\t\tnumDirectionalShadows: - 1,\n\t\t\tnumPointShadows: - 1,\n\t\t\tnumSpotShadows: - 1\n\t\t},\n\n\t\tambient: [ 0, 0, 0 ],\n\t\tprobe: [],\n\t\tdirectional: [],\n\t\tdirectionalShadow: [],\n\t\tdirectionalShadowMap: [],\n\t\tdirectionalShadowMatrix: [],\n\t\tspot: [],\n\t\tspotShadow: [],\n\t\tspotShadowMap: [],\n\t\tspotShadowMatrix: [],\n\t\trectArea: [],\n\t\tpoint: [],\n\t\tpointShadow: [],\n\t\tpointShadowMap: [],\n\t\tpointShadowMatrix: [],\n\t\themi: []\n\n\t};\n\n\tfor ( let i = 0; i < 9; i ++ ) state.probe.push( new Vector3() );\n\n\tconst vector3 = new Vector3();\n\tconst matrix4 = new Matrix4();\n\tconst matrix42 = new Matrix4();\n\n\tfunction setup( lights, shadows, camera ) {\n\n\t\tlet r = 0, g = 0, b = 0;\n\n\t\tfor ( let i = 0; i < 9; i ++ ) state.probe[ i ].set( 0, 0, 0 );\n\n\t\tlet directionalLength = 0;\n\t\tlet pointLength = 0;\n\t\tlet spotLength = 0;\n\t\tlet rectAreaLength = 0;\n\t\tlet hemiLength = 0;\n\n\t\tlet numDirectionalShadows = 0;\n\t\tlet numPointShadows = 0;\n\t\tlet numSpotShadows = 0;\n\n\t\tconst viewMatrix = camera.matrixWorldInverse;\n\n\t\tlights.sort( shadowCastingLightsFirst );\n\n\t\tfor ( let i = 0, l = lights.length; i < l; i ++ ) {\n\n\t\t\tconst light = lights[ i ];\n\n\t\t\tconst color = light.color;\n\t\t\tconst intensity = light.intensity;\n\t\t\tconst distance = light.distance;\n\n\t\t\tconst shadowMap = ( light.shadow && light.shadow.map ) ? light.shadow.map.texture : null;\n\n\t\t\tif ( light.isAmbientLight ) {\n\n\t\t\t\tr += color.r * intensity;\n\t\t\t\tg += color.g * intensity;\n\t\t\t\tb += color.b * intensity;\n\n\t\t\t} else if ( light.isLightProbe ) {\n\n\t\t\t\tfor ( let j = 0; j < 9; j ++ ) {\n\n\t\t\t\t\tstate.probe[ j ].addScaledVector( light.sh.coefficients[ j ], intensity );\n\n\t\t\t\t}\n\n\t\t\t} else if ( light.isDirectionalLight ) {\n\n\t\t\t\tconst uniforms = cache.get( light );\n\n\t\t\t\tuniforms.color.copy( light.color ).multiplyScalar( light.intensity );\n\t\t\t\tuniforms.direction.setFromMatrixPosition( light.matrixWorld );\n\t\t\t\tvector3.setFromMatrixPosition( light.target.matrixWorld );\n\t\t\t\tuniforms.direction.sub( vector3 );\n\t\t\t\tuniforms.direction.transformDirection( viewMatrix );\n\n\t\t\t\tif ( light.castShadow ) {\n\n\t\t\t\t\tconst shadow = light.shadow;\n\n\t\t\t\t\tconst shadowUniforms = shadowCache.get( light );\n\n\t\t\t\t\tshadowUniforms.shadowBias = shadow.bias;\n\t\t\t\t\tshadowUniforms.shadowNormalBias = shadow.normalBias;\n\t\t\t\t\tshadowUniforms.shadowRadius = shadow.radius;\n\t\t\t\t\tshadowUniforms.shadowMapSize = shadow.mapSize;\n\n\t\t\t\t\tstate.directionalShadow[ directionalLength ] = shadowUniforms;\n\t\t\t\t\tstate.directionalShadowMap[ directionalLength ] = shadowMap;\n\t\t\t\t\tstate.directionalShadowMatrix[ directionalLength ] = light.shadow.matrix;\n\n\t\t\t\t\tnumDirectionalShadows ++;\n\n\t\t\t\t}\n\n\t\t\t\tstate.directional[ directionalLength ] = uniforms;\n\n\t\t\t\tdirectionalLength ++;\n\n\t\t\t} else if ( light.isSpotLight ) {\n\n\t\t\t\tconst uniforms = cache.get( light );\n\n\t\t\t\tuniforms.position.setFromMatrixPosition( light.matrixWorld );\n\t\t\t\tuniforms.position.applyMatrix4( viewMatrix );\n\n\t\t\t\tuniforms.color.copy( color ).multiplyScalar( intensity );\n\t\t\t\tuniforms.distance = distance;\n\n\t\t\t\tuniforms.direction.setFromMatrixPosition( light.matrixWorld );\n\t\t\t\tvector3.setFromMatrixPosition( light.target.matrixWorld );\n\t\t\t\tuniforms.direction.sub( vector3 );\n\t\t\t\tuniforms.direction.transformDirection( viewMatrix );\n\n\t\t\t\tuniforms.coneCos = Math.cos( light.angle );\n\t\t\t\tuniforms.penumbraCos = Math.cos( light.angle * ( 1 - light.penumbra ) );\n\t\t\t\tuniforms.decay = light.decay;\n\n\t\t\t\tif ( light.castShadow ) {\n\n\t\t\t\t\tconst shadow = light.shadow;\n\n\t\t\t\t\tconst shadowUniforms = shadowCache.get( light );\n\n\t\t\t\t\tshadowUniforms.shadowBias = shadow.bias;\n\t\t\t\t\tshadowUniforms.shadowNormalBias = shadow.normalBias;\n\t\t\t\t\tshadowUniforms.shadowRadius = shadow.radius;\n\t\t\t\t\tshadowUniforms.shadowMapSize = shadow.mapSize;\n\n\t\t\t\t\tstate.spotShadow[ spotLength ] = shadowUniforms;\n\t\t\t\t\tstate.spotShadowMap[ spotLength ] = shadowMap;\n\t\t\t\t\tstate.spotShadowMatrix[ spotLength ] = light.shadow.matrix;\n\n\t\t\t\t\tnumSpotShadows ++;\n\n\t\t\t\t}\n\n\t\t\t\tstate.spot[ spotLength ] = uniforms;\n\n\t\t\t\tspotLength ++;\n\n\t\t\t} else if ( light.isRectAreaLight ) {\n\n\t\t\t\tconst uniforms = cache.get( light );\n\n\t\t\t\t// (a) intensity is the total visible light emitted\n\t\t\t\t//uniforms.color.copy( color ).multiplyScalar( intensity / ( light.width * light.height * Math.PI ) );\n\n\t\t\t\t// (b) intensity is the brightness of the light\n\t\t\t\tuniforms.color.copy( color ).multiplyScalar( intensity );\n\n\t\t\t\tuniforms.position.setFromMatrixPosition( light.matrixWorld );\n\t\t\t\tuniforms.position.applyMatrix4( viewMatrix );\n\n\t\t\t\t// extract local rotation of light to derive width/height half vectors\n\t\t\t\tmatrix42.identity();\n\t\t\t\tmatrix4.copy( light.matrixWorld );\n\t\t\t\tmatrix4.premultiply( viewMatrix );\n\t\t\t\tmatrix42.extractRotation( matrix4 );\n\n\t\t\t\tuniforms.halfWidth.set( light.width * 0.5, 0.0, 0.0 );\n\t\t\t\tuniforms.halfHeight.set( 0.0, light.height * 0.5, 0.0 );\n\n\t\t\t\tuniforms.halfWidth.applyMatrix4( matrix42 );\n\t\t\t\tuniforms.halfHeight.applyMatrix4( matrix42 );\n\n\t\t\t\t// TODO (abelnation): RectAreaLight distance?\n\t\t\t\t// uniforms.distance = distance;\n\n\t\t\t\tstate.rectArea[ rectAreaLength ] = uniforms;\n\n\t\t\t\trectAreaLength ++;\n\n\t\t\t} else if ( light.isPointLight ) {\n\n\t\t\t\tconst uniforms = cache.get( light );\n\n\t\t\t\tuniforms.position.setFromMatrixPosition( light.matrixWorld );\n\t\t\t\tuniforms.position.applyMatrix4( viewMatrix );\n\n\t\t\t\tuniforms.color.copy( light.color ).multiplyScalar( light.intensity );\n\t\t\t\tuniforms.distance = light.distance;\n\t\t\t\tuniforms.decay = light.decay;\n\n\t\t\t\tif ( light.castShadow ) {\n\n\t\t\t\t\tconst shadow = light.shadow;\n\n\t\t\t\t\tconst shadowUniforms = shadowCache.get( light );\n\n\t\t\t\t\tshadowUniforms.shadowBias = shadow.bias;\n\t\t\t\t\tshadowUniforms.shadowNormalBias = shadow.normalBias;\n\t\t\t\t\tshadowUniforms.shadowRadius = shadow.radius;\n\t\t\t\t\tshadowUniforms.shadowMapSize = shadow.mapSize;\n\t\t\t\t\tshadowUniforms.shadowCameraNear = shadow.camera.near;\n\t\t\t\t\tshadowUniforms.shadowCameraFar = shadow.camera.far;\n\n\t\t\t\t\tstate.pointShadow[ pointLength ] = shadowUniforms;\n\t\t\t\t\tstate.pointShadowMap[ pointLength ] = shadowMap;\n\t\t\t\t\tstate.pointShadowMatrix[ pointLength ] = light.shadow.matrix;\n\n\t\t\t\t\tnumPointShadows ++;\n\n\t\t\t\t}\n\n\t\t\t\tstate.point[ pointLength ] = uniforms;\n\n\t\t\t\tpointLength ++;\n\n\t\t\t} else if ( light.isHemisphereLight ) {\n\n\t\t\t\tconst uniforms = cache.get( light );\n\n\t\t\t\tuniforms.direction.setFromMatrixPosition( light.matrixWorld );\n\t\t\t\tuniforms.direction.transformDirection( viewMatrix );\n\t\t\t\tuniforms.direction.normalize();\n\n\t\t\t\tuniforms.skyColor.copy( light.color ).multiplyScalar( intensity );\n\t\t\t\tuniforms.groundColor.copy( light.groundColor ).multiplyScalar( intensity );\n\n\t\t\t\tstate.hemi[ hemiLength ] = uniforms;\n\n\t\t\t\themiLength ++;\n\n\t\t\t}\n\n\t\t}\n\n\t\tstate.ambient[ 0 ] = r;\n\t\tstate.ambient[ 1 ] = g;\n\t\tstate.ambient[ 2 ] = b;\n\n\t\tconst hash = state.hash;\n\n\t\tif ( hash.directionalLength !== directionalLength ||\n\t\t\thash.pointLength !== pointLength ||\n\t\t\thash.spotLength !== spotLength ||\n\t\t\thash.rectAreaLength !== rectAreaLength ||\n\t\t\thash.hemiLength !== hemiLength ||\n\t\t\thash.numDirectionalShadows !== numDirectionalShadows ||\n\t\t\thash.numPointShadows !== numPointShadows ||\n\t\t\thash.numSpotShadows !== numSpotShadows ) {\n\n\t\t\tstate.directional.length = directionalLength;\n\t\t\tstate.spot.length = spotLength;\n\t\t\tstate.rectArea.length = rectAreaLength;\n\t\t\tstate.point.length = pointLength;\n\t\t\tstate.hemi.length = hemiLength;\n\n\t\t\tstate.directionalShadow.length = numDirectionalShadows;\n\t\t\tstate.directionalShadowMap.length = numDirectionalShadows;\n\t\t\tstate.pointShadow.length = numPointShadows;\n\t\t\tstate.pointShadowMap.length = numPointShadows;\n\t\t\tstate.spotShadow.length = numSpotShadows;\n\t\t\tstate.spotShadowMap.length = numSpotShadows;\n\t\t\tstate.directionalShadowMatrix.length = numDirectionalShadows;\n\t\t\tstate.pointShadowMatrix.length = numPointShadows;\n\t\t\tstate.spotShadowMatrix.length = numSpotShadows;\n\n\t\t\thash.directionalLength = directionalLength;\n\t\t\thash.pointLength = pointLength;\n\t\t\thash.spotLength = spotLength;\n\t\t\thash.rectAreaLength = rectAreaLength;\n\t\t\thash.hemiLength = hemiLength;\n\n\t\t\thash.numDirectionalShadows = numDirectionalShadows;\n\t\t\thash.numPointShadows = numPointShadows;\n\t\t\thash.numSpotShadows = numSpotShadows;\n\n\t\t\tstate.version = nextVersion ++;\n\n\t\t}\n\n\t}\n\n\treturn {\n\t\tsetup: setup,\n\t\tstate: state\n\t};\n\n}\n\n\nexport { WebGLLights };\n","/**\n * @author Mugen87 / https://github.com/Mugen87\n */\n\nimport { WebGLLights } from './WebGLLights.js';\n\nfunction WebGLRenderState() {\n\n\tconst lights = new WebGLLights();\n\n\tconst lightsArray = [];\n\tconst shadowsArray = [];\n\n\tfunction init() {\n\n\t\tlightsArray.length = 0;\n\t\tshadowsArray.length = 0;\n\n\t}\n\n\tfunction pushLight( light ) {\n\n\t\tlightsArray.push( light );\n\n\t}\n\n\tfunction pushShadow( shadowLight ) {\n\n\t\tshadowsArray.push( shadowLight );\n\n\t}\n\n\tfunction setupLights( camera ) {\n\n\t\tlights.setup( lightsArray, shadowsArray, camera );\n\n\t}\n\n\tconst state = {\n\t\tlightsArray: lightsArray,\n\t\tshadowsArray: shadowsArray,\n\n\t\tlights: lights\n\t};\n\n\treturn {\n\t\tinit: init,\n\t\tstate: state,\n\t\tsetupLights: setupLights,\n\n\t\tpushLight: pushLight,\n\t\tpushShadow: pushShadow\n\t};\n\n}\n\nfunction WebGLRenderStates() {\n\n\tlet renderStates = new WeakMap();\n\n\tfunction onSceneDispose( event ) {\n\n\t\tconst scene = event.target;\n\n\t\tscene.removeEventListener( 'dispose', onSceneDispose );\n\n\t\trenderStates.delete( scene );\n\n\t}\n\n\tfunction get( scene, camera ) {\n\n\t\tlet renderState;\n\n\t\tif ( renderStates.has( scene ) === false ) {\n\n\t\t\trenderState = new WebGLRenderState();\n\t\t\trenderStates.set( scene, new WeakMap() );\n\t\t\trenderStates.get( scene ).set( camera, renderState );\n\n\t\t\tscene.addEventListener( 'dispose', onSceneDispose );\n\n\t\t} else {\n\n\t\t\tif ( renderStates.get( scene ).has( camera ) === false ) {\n\n\t\t\t\trenderState = new WebGLRenderState();\n\t\t\t\trenderStates.get( scene ).set( camera, renderState );\n\n\t\t\t} else {\n\n\t\t\t\trenderState = renderStates.get( scene ).get( camera );\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn renderState;\n\n\t}\n\n\tfunction dispose() {\n\n\t\trenderStates = new WeakMap();\n\n\t}\n\n\treturn {\n\t\tget: get,\n\t\tdispose: dispose\n\t};\n\n}\n\n\nexport { WebGLRenderStates };\n","import { Material } from './Material.js';\nimport { BasicDepthPacking } from '../constants.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author alteredq / http://alteredqualia.com/\n * @author bhouston / https://clara.io\n * @author WestLangley / http://github.com/WestLangley\n *\n * parameters = {\n *\n * opacity: ,\n *\n * map: new THREE.Texture( ),\n *\n * alphaMap: new THREE.Texture( ),\n *\n * displacementMap: new THREE.Texture( ),\n * displacementScale: ,\n * displacementBias: ,\n *\n * wireframe: ,\n * wireframeLinewidth: \n * }\n */\n\nfunction MeshDepthMaterial( parameters ) {\n\n\tMaterial.call( this );\n\n\tthis.type = 'MeshDepthMaterial';\n\n\tthis.depthPacking = BasicDepthPacking;\n\n\tthis.skinning = false;\n\tthis.morphTargets = false;\n\n\tthis.map = null;\n\n\tthis.alphaMap = null;\n\n\tthis.displacementMap = null;\n\tthis.displacementScale = 1;\n\tthis.displacementBias = 0;\n\n\tthis.wireframe = false;\n\tthis.wireframeLinewidth = 1;\n\n\tthis.fog = false;\n\n\tthis.setValues( parameters );\n\n}\n\nMeshDepthMaterial.prototype = Object.create( Material.prototype );\nMeshDepthMaterial.prototype.constructor = MeshDepthMaterial;\n\nMeshDepthMaterial.prototype.isMeshDepthMaterial = true;\n\nMeshDepthMaterial.prototype.copy = function ( source ) {\n\n\tMaterial.prototype.copy.call( this, source );\n\n\tthis.depthPacking = source.depthPacking;\n\n\tthis.skinning = source.skinning;\n\tthis.morphTargets = source.morphTargets;\n\n\tthis.map = source.map;\n\n\tthis.alphaMap = source.alphaMap;\n\n\tthis.displacementMap = source.displacementMap;\n\tthis.displacementScale = source.displacementScale;\n\tthis.displacementBias = source.displacementBias;\n\n\tthis.wireframe = source.wireframe;\n\tthis.wireframeLinewidth = source.wireframeLinewidth;\n\n\treturn this;\n\n};\n\n\nexport { MeshDepthMaterial };\n","import { Material } from './Material.js';\nimport { Vector3 } from '../math/Vector3.js';\n\n/**\n * @author WestLangley / http://github.com/WestLangley\n *\n * parameters = {\n *\n * referencePosition: ,\n * nearDistance: ,\n * farDistance: ,\n *\n * skinning: ,\n * morphTargets: ,\n *\n * map: new THREE.Texture( ),\n *\n * alphaMap: new THREE.Texture( ),\n *\n * displacementMap: new THREE.Texture( ),\n * displacementScale: ,\n * displacementBias: \n *\n * }\n */\n\nfunction MeshDistanceMaterial( parameters ) {\n\n\tMaterial.call( this );\n\n\tthis.type = 'MeshDistanceMaterial';\n\n\tthis.referencePosition = new Vector3();\n\tthis.nearDistance = 1;\n\tthis.farDistance = 1000;\n\n\tthis.skinning = false;\n\tthis.morphTargets = false;\n\n\tthis.map = null;\n\n\tthis.alphaMap = null;\n\n\tthis.displacementMap = null;\n\tthis.displacementScale = 1;\n\tthis.displacementBias = 0;\n\n\tthis.fog = false;\n\n\tthis.setValues( parameters );\n\n}\n\nMeshDistanceMaterial.prototype = Object.create( Material.prototype );\nMeshDistanceMaterial.prototype.constructor = MeshDistanceMaterial;\n\nMeshDistanceMaterial.prototype.isMeshDistanceMaterial = true;\n\nMeshDistanceMaterial.prototype.copy = function ( source ) {\n\n\tMaterial.prototype.copy.call( this, source );\n\n\tthis.referencePosition.copy( source.referencePosition );\n\tthis.nearDistance = source.nearDistance;\n\tthis.farDistance = source.farDistance;\n\n\tthis.skinning = source.skinning;\n\tthis.morphTargets = source.morphTargets;\n\n\tthis.map = source.map;\n\n\tthis.alphaMap = source.alphaMap;\n\n\tthis.displacementMap = source.displacementMap;\n\tthis.displacementScale = source.displacementScale;\n\tthis.displacementBias = source.displacementBias;\n\n\treturn this;\n\n};\n\n\nexport { MeshDistanceMaterial };\n","export default /* glsl */`\nuniform sampler2D shadow_pass;\nuniform vec2 resolution;\nuniform float radius;\n\n#include \n\nvoid main() {\n\n float mean = 0.0;\n float squared_mean = 0.0;\n\n\t// This seems totally useless but it's a crazy work around for a Adreno compiler bug\n\tfloat depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy ) / resolution ) );\n\n for ( float i = -1.0; i < 1.0 ; i += SAMPLE_RATE) {\n\n #ifdef HORIZONAL_PASS\n\n vec2 distribution = unpackRGBATo2Half( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( i, 0.0 ) * radius ) / resolution ) );\n mean += distribution.x;\n squared_mean += distribution.y * distribution.y + distribution.x * distribution.x;\n\n #else\n\n float depth = unpackRGBAToDepth( texture2D( shadow_pass, ( gl_FragCoord.xy + vec2( 0.0, i ) * radius ) / resolution ) );\n mean += depth;\n squared_mean += depth * depth;\n\n #endif\n\n }\n\n mean = mean * HALF_SAMPLE_RATE;\n squared_mean = squared_mean * HALF_SAMPLE_RATE;\n\n float std_dev = sqrt( squared_mean - mean * mean );\n\n gl_FragColor = pack2HalfToRGBA( vec2( mean, std_dev ) );\n\n}\n`;\n","export default /* glsl */`\nvoid main() {\n\n\tgl_Position = vec4( position, 1.0 );\n\n}\n`;\n","/**\n * @author alteredq / http://alteredqualia.com/\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { FrontSide, BackSide, DoubleSide, RGBAFormat, NearestFilter, LinearFilter, PCFShadowMap, VSMShadowMap, RGBADepthPacking, NoBlending } from '../../constants.js';\nimport { WebGLRenderTarget } from '../WebGLRenderTarget.js';\nimport { MeshDepthMaterial } from '../../materials/MeshDepthMaterial.js';\nimport { MeshDistanceMaterial } from '../../materials/MeshDistanceMaterial.js';\nimport { ShaderMaterial } from '../../materials/ShaderMaterial.js';\nimport { BufferAttribute } from '../../core/BufferAttribute.js';\nimport { BufferGeometry } from '../../core/BufferGeometry.js';\nimport { Mesh } from '../../objects/Mesh.js';\nimport { Vector4 } from '../../math/Vector4.js';\nimport { Vector2 } from '../../math/Vector2.js';\nimport { Frustum } from '../../math/Frustum.js';\n\nimport vsm_frag from '../shaders/ShaderLib/vsm_frag.glsl.js';\nimport vsm_vert from '../shaders/ShaderLib/vsm_vert.glsl.js';\n\nfunction WebGLShadowMap( _renderer, _objects, maxTextureSize ) {\n\n\tlet _frustum = new Frustum();\n\n\tconst _shadowMapSize = new Vector2(),\n\t\t_viewportSize = new Vector2(),\n\n\t\t_viewport = new Vector4(),\n\n\t\t_depthMaterials = [],\n\t\t_distanceMaterials = [],\n\n\t\t_materialCache = {};\n\n\tconst shadowSide = { 0: BackSide, 1: FrontSide, 2: DoubleSide };\n\n\tconst shadowMaterialVertical = new ShaderMaterial( {\n\n\t\tdefines: {\n\t\t\tSAMPLE_RATE: 2.0 / 8.0,\n\t\t\tHALF_SAMPLE_RATE: 1.0 / 8.0\n\t\t},\n\n\t\tuniforms: {\n\t\t\tshadow_pass: { value: null },\n\t\t\tresolution: { value: new Vector2() },\n\t\t\tradius: { value: 4.0 }\n\t\t},\n\n\t\tvertexShader: vsm_vert,\n\n\t\tfragmentShader: vsm_frag\n\n\t} );\n\n\tconst shadowMaterialHorizonal = shadowMaterialVertical.clone();\n\tshadowMaterialHorizonal.defines.HORIZONAL_PASS = 1;\n\n\tconst fullScreenTri = new BufferGeometry();\n\tfullScreenTri.setAttribute(\n\t\t\"position\",\n\t\tnew BufferAttribute(\n\t\t\tnew Float32Array( [ - 1, - 1, 0.5, 3, - 1, 0.5, - 1, 3, 0.5 ] ),\n\t\t\t3\n\t\t)\n\t);\n\n\tconst fullScreenMesh = new Mesh( fullScreenTri, shadowMaterialVertical );\n\n\tconst scope = this;\n\n\tthis.enabled = false;\n\n\tthis.autoUpdate = true;\n\tthis.needsUpdate = false;\n\n\tthis.type = PCFShadowMap;\n\n\tthis.render = function ( lights, scene, camera ) {\n\n\t\tif ( scope.enabled === false ) return;\n\t\tif ( scope.autoUpdate === false && scope.needsUpdate === false ) return;\n\n\t\tif ( lights.length === 0 ) return;\n\n\t\tconst currentRenderTarget = _renderer.getRenderTarget();\n\t\tconst activeCubeFace = _renderer.getActiveCubeFace();\n\t\tconst activeMipmapLevel = _renderer.getActiveMipmapLevel();\n\n\t\tconst _state = _renderer.state;\n\n\t\t// Set GL state for depth map.\n\t\t_state.setBlending( NoBlending );\n\t\t_state.buffers.color.setClear( 1, 1, 1, 1 );\n\t\t_state.buffers.depth.setTest( true );\n\t\t_state.setScissorTest( false );\n\n\t\t// render depth map\n\n\t\tfor ( let i = 0, il = lights.length; i < il; i ++ ) {\n\n\t\t\tconst light = lights[ i ];\n\t\t\tconst shadow = light.shadow;\n\n\t\t\tif ( shadow.autoUpdate === false && shadow.needsUpdate === false ) continue;\n\n\t\t\tif ( shadow === undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLShadowMap:', light, 'has no shadow.' );\n\t\t\t\tcontinue;\n\n\t\t\t}\n\n\t\t\t_shadowMapSize.copy( shadow.mapSize );\n\n\t\t\tconst shadowFrameExtents = shadow.getFrameExtents();\n\n\t\t\t_shadowMapSize.multiply( shadowFrameExtents );\n\n\t\t\t_viewportSize.copy( shadow.mapSize );\n\n\t\t\tif ( _shadowMapSize.x > maxTextureSize || _shadowMapSize.y > maxTextureSize ) {\n\n\t\t\t\tif ( _shadowMapSize.x > maxTextureSize ) {\n\n\t\t\t\t\t_viewportSize.x = Math.floor( maxTextureSize / shadowFrameExtents.x );\n\t\t\t\t\t_shadowMapSize.x = _viewportSize.x * shadowFrameExtents.x;\n\t\t\t\t\tshadow.mapSize.x = _viewportSize.x;\n\n\t\t\t\t}\n\n\t\t\t\tif ( _shadowMapSize.y > maxTextureSize ) {\n\n\t\t\t\t\t_viewportSize.y = Math.floor( maxTextureSize / shadowFrameExtents.y );\n\t\t\t\t\t_shadowMapSize.y = _viewportSize.y * shadowFrameExtents.y;\n\t\t\t\t\tshadow.mapSize.y = _viewportSize.y;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif ( shadow.map === null && ! shadow.isPointLightShadow && this.type === VSMShadowMap ) {\n\n\t\t\t\tconst pars = { minFilter: LinearFilter, magFilter: LinearFilter, format: RGBAFormat };\n\n\t\t\t\tshadow.map = new WebGLRenderTarget( _shadowMapSize.x, _shadowMapSize.y, pars );\n\t\t\t\tshadow.map.texture.name = light.name + \".shadowMap\";\n\n\t\t\t\tshadow.mapPass = new WebGLRenderTarget( _shadowMapSize.x, _shadowMapSize.y, pars );\n\n\t\t\t\tshadow.camera.updateProjectionMatrix();\n\n\t\t\t}\n\n\t\t\tif ( shadow.map === null ) {\n\n\t\t\t\tconst pars = { minFilter: NearestFilter, magFilter: NearestFilter, format: RGBAFormat };\n\n\t\t\t\tshadow.map = new WebGLRenderTarget( _shadowMapSize.x, _shadowMapSize.y, pars );\n\t\t\t\tshadow.map.texture.name = light.name + \".shadowMap\";\n\n\t\t\t\tshadow.camera.updateProjectionMatrix();\n\n\t\t\t}\n\n\t\t\t_renderer.setRenderTarget( shadow.map );\n\t\t\t_renderer.clear();\n\n\t\t\tconst viewportCount = shadow.getViewportCount();\n\n\t\t\tfor ( let vp = 0; vp < viewportCount; vp ++ ) {\n\n\t\t\t\tconst viewport = shadow.getViewport( vp );\n\n\t\t\t\t_viewport.set(\n\t\t\t\t\t_viewportSize.x * viewport.x,\n\t\t\t\t\t_viewportSize.y * viewport.y,\n\t\t\t\t\t_viewportSize.x * viewport.z,\n\t\t\t\t\t_viewportSize.y * viewport.w\n\t\t\t\t);\n\n\t\t\t\t_state.viewport( _viewport );\n\n\t\t\t\tshadow.updateMatrices( light, vp );\n\n\t\t\t\t_frustum = shadow.getFrustum();\n\n\t\t\t\trenderObject( scene, camera, shadow.camera, light, this.type );\n\n\t\t\t}\n\n\t\t\t// do blur pass for VSM\n\n\t\t\tif ( ! shadow.isPointLightShadow && this.type === VSMShadowMap ) {\n\n\t\t\t\tVSMPass( shadow, camera );\n\n\t\t\t}\n\n\t\t\tshadow.needsUpdate = false;\n\n\t\t}\n\n\t\tscope.needsUpdate = false;\n\n\t\t_renderer.setRenderTarget( currentRenderTarget, activeCubeFace, activeMipmapLevel );\n\n\t};\n\n\tfunction VSMPass( shadow, camera ) {\n\n\t\tconst geometry = _objects.update( fullScreenMesh );\n\n\t\t// vertical pass\n\n\t\tshadowMaterialVertical.uniforms.shadow_pass.value = shadow.map.texture;\n\t\tshadowMaterialVertical.uniforms.resolution.value = shadow.mapSize;\n\t\tshadowMaterialVertical.uniforms.radius.value = shadow.radius;\n\t\t_renderer.setRenderTarget( shadow.mapPass );\n\t\t_renderer.clear();\n\t\t_renderer.renderBufferDirect( camera, null, geometry, shadowMaterialVertical, fullScreenMesh, null );\n\n\t\t// horizonal pass\n\n\t\tshadowMaterialHorizonal.uniforms.shadow_pass.value = shadow.mapPass.texture;\n\t\tshadowMaterialHorizonal.uniforms.resolution.value = shadow.mapSize;\n\t\tshadowMaterialHorizonal.uniforms.radius.value = shadow.radius;\n\t\t_renderer.setRenderTarget( shadow.map );\n\t\t_renderer.clear();\n\t\t_renderer.renderBufferDirect( camera, null, geometry, shadowMaterialHorizonal, fullScreenMesh, null );\n\n\t}\n\n\tfunction getDepthMaterialVariant( useMorphing, useSkinning, useInstancing ) {\n\n\t\tconst index = useMorphing << 0 | useSkinning << 1 | useInstancing << 2;\n\n\t\tlet material = _depthMaterials[ index ];\n\n\t\tif ( material === undefined ) {\n\n\t\t\tmaterial = new MeshDepthMaterial( {\n\n\t\t\t\tdepthPacking: RGBADepthPacking,\n\n\t\t\t\tmorphTargets: useMorphing,\n\t\t\t\tskinning: useSkinning\n\n\t\t\t} );\n\n\t\t\t_depthMaterials[ index ] = material;\n\n\t\t}\n\n\t\treturn material;\n\n\t}\n\n\tfunction getDistanceMaterialVariant( useMorphing, useSkinning, useInstancing ) {\n\n\t\tconst index = useMorphing << 0 | useSkinning << 1 | useInstancing << 2;\n\n\t\tlet material = _distanceMaterials[ index ];\n\n\t\tif ( material === undefined ) {\n\n\t\t\tmaterial = new MeshDistanceMaterial( {\n\n\t\t\t\tmorphTargets: useMorphing,\n\t\t\t\tskinning: useSkinning\n\n\t\t\t} );\n\n\t\t\t_distanceMaterials[ index ] = material;\n\n\t\t}\n\n\t\treturn material;\n\n\t}\n\n\tfunction getDepthMaterial( object, geometry, material, light, shadowCameraNear, shadowCameraFar, type ) {\n\n\t\tlet result = null;\n\n\t\tlet getMaterialVariant = getDepthMaterialVariant;\n\t\tlet customMaterial = object.customDepthMaterial;\n\n\t\tif ( light.isPointLight === true ) {\n\n\t\t\tgetMaterialVariant = getDistanceMaterialVariant;\n\t\t\tcustomMaterial = object.customDistanceMaterial;\n\n\t\t}\n\n\t\tif ( customMaterial === undefined ) {\n\n\t\t\tlet useMorphing = false;\n\n\t\t\tif ( material.morphTargets === true ) {\n\n\t\t\t\tuseMorphing = geometry.morphAttributes && geometry.morphAttributes.position && geometry.morphAttributes.position.length > 0;\n\n\t\t\t}\n\n\t\t\tlet useSkinning = false;\n\n\t\t\tif ( object.isSkinnedMesh === true ) {\n\n\t\t\t\tif ( material.skinning === true ) {\n\n\t\t\t\t\tuseSkinning = true;\n\n\t\t\t\t} else {\n\n\t\t\t\t\tconsole.warn( 'THREE.WebGLShadowMap: THREE.SkinnedMesh with material.skinning set to false:', object );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tconst useInstancing = object.isInstancedMesh === true;\n\n\t\t\tresult = getMaterialVariant( useMorphing, useSkinning, useInstancing );\n\n\t\t} else {\n\n\t\t\tresult = customMaterial;\n\n\t\t}\n\n\t\tif ( _renderer.localClippingEnabled &&\n\t\t\t\tmaterial.clipShadows === true &&\n\t\t\t\tmaterial.clippingPlanes.length !== 0 ) {\n\n\t\t\t// in this case we need a unique material instance reflecting the\n\t\t\t// appropriate state\n\n\t\t\tconst keyA = result.uuid, keyB = material.uuid;\n\n\t\t\tlet materialsForVariant = _materialCache[ keyA ];\n\n\t\t\tif ( materialsForVariant === undefined ) {\n\n\t\t\t\tmaterialsForVariant = {};\n\t\t\t\t_materialCache[ keyA ] = materialsForVariant;\n\n\t\t\t}\n\n\t\t\tlet cachedMaterial = materialsForVariant[ keyB ];\n\n\t\t\tif ( cachedMaterial === undefined ) {\n\n\t\t\t\tcachedMaterial = result.clone();\n\t\t\t\tmaterialsForVariant[ keyB ] = cachedMaterial;\n\n\t\t\t}\n\n\t\t\tresult = cachedMaterial;\n\n\t\t}\n\n\t\tresult.visible = material.visible;\n\t\tresult.wireframe = material.wireframe;\n\n\t\tif ( type === VSMShadowMap ) {\n\n\t\t\tresult.side = ( material.shadowSide !== null ) ? material.shadowSide : material.side;\n\n\t\t} else {\n\n\t\t\tresult.side = ( material.shadowSide !== null ) ? material.shadowSide : shadowSide[ material.side ];\n\n\t\t}\n\n\t\tresult.clipShadows = material.clipShadows;\n\t\tresult.clippingPlanes = material.clippingPlanes;\n\t\tresult.clipIntersection = material.clipIntersection;\n\n\t\tresult.wireframeLinewidth = material.wireframeLinewidth;\n\t\tresult.linewidth = material.linewidth;\n\n\t\tif ( light.isPointLight === true && result.isMeshDistanceMaterial === true ) {\n\n\t\t\tresult.referencePosition.setFromMatrixPosition( light.matrixWorld );\n\t\t\tresult.nearDistance = shadowCameraNear;\n\t\t\tresult.farDistance = shadowCameraFar;\n\n\t\t}\n\n\t\treturn result;\n\n\t}\n\n\tfunction renderObject( object, camera, shadowCamera, light, type ) {\n\n\t\tif ( object.visible === false ) return;\n\n\t\tconst visible = object.layers.test( camera.layers );\n\n\t\tif ( visible && ( object.isMesh || object.isLine || object.isPoints ) ) {\n\n\t\t\tif ( ( object.castShadow || ( object.receiveShadow && type === VSMShadowMap ) ) && ( ! object.frustumCulled || _frustum.intersectsObject( object ) ) ) {\n\n\t\t\t\tobject.modelViewMatrix.multiplyMatrices( shadowCamera.matrixWorldInverse, object.matrixWorld );\n\n\t\t\t\tconst geometry = _objects.update( object );\n\t\t\t\tconst material = object.material;\n\n\t\t\t\tif ( Array.isArray( material ) ) {\n\n\t\t\t\t\tconst groups = geometry.groups;\n\n\t\t\t\t\tfor ( let k = 0, kl = groups.length; k < kl; k ++ ) {\n\n\t\t\t\t\t\tconst group = groups[ k ];\n\t\t\t\t\t\tconst groupMaterial = material[ group.materialIndex ];\n\n\t\t\t\t\t\tif ( groupMaterial && groupMaterial.visible ) {\n\n\t\t\t\t\t\t\tconst depthMaterial = getDepthMaterial( object, geometry, groupMaterial, light, shadowCamera.near, shadowCamera.far, type );\n\n\t\t\t\t\t\t\t_renderer.renderBufferDirect( shadowCamera, null, geometry, depthMaterial, object, group );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t} else if ( material.visible ) {\n\n\t\t\t\t\tconst depthMaterial = getDepthMaterial( object, geometry, material, light, shadowCamera.near, shadowCamera.far, type );\n\n\t\t\t\t\t_renderer.renderBufferDirect( shadowCamera, null, geometry, depthMaterial, object, null );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tconst children = object.children;\n\n\t\tfor ( let i = 0, l = children.length; i < l; i ++ ) {\n\n\t\t\trenderObject( children[ i ], camera, shadowCamera, light, type );\n\n\t\t}\n\n\t}\n\n}\n\n\nexport { WebGLShadowMap };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { NotEqualDepth, GreaterDepth, GreaterEqualDepth, EqualDepth, LessEqualDepth, LessDepth, AlwaysDepth, NeverDepth, CullFaceFront, CullFaceBack, CullFaceNone, DoubleSide, BackSide, CustomBlending, MultiplyBlending, SubtractiveBlending, AdditiveBlending, NoBlending, NormalBlending, AddEquation, SubtractEquation, ReverseSubtractEquation, MinEquation, MaxEquation, ZeroFactor, OneFactor, SrcColorFactor, SrcAlphaFactor, SrcAlphaSaturateFactor, DstColorFactor, DstAlphaFactor, OneMinusSrcColorFactor, OneMinusSrcAlphaFactor, OneMinusDstColorFactor, OneMinusDstAlphaFactor } from '../../constants.js';\nimport { Vector4 } from '../../math/Vector4.js';\n\nfunction WebGLState( gl, extensions, capabilities ) {\n\n\tconst isWebGL2 = capabilities.isWebGL2;\n\n\tfunction ColorBuffer() {\n\n\t\tlet locked = false;\n\n\t\tconst color = new Vector4();\n\t\tlet currentColorMask = null;\n\t\tconst currentColorClear = new Vector4( 0, 0, 0, 0 );\n\n\t\treturn {\n\n\t\t\tsetMask: function ( colorMask ) {\n\n\t\t\t\tif ( currentColorMask !== colorMask && ! locked ) {\n\n\t\t\t\t\tgl.colorMask( colorMask, colorMask, colorMask, colorMask );\n\t\t\t\t\tcurrentColorMask = colorMask;\n\n\t\t\t\t}\n\n\t\t\t},\n\n\t\t\tsetLocked: function ( lock ) {\n\n\t\t\t\tlocked = lock;\n\n\t\t\t},\n\n\t\t\tsetClear: function ( r, g, b, a, premultipliedAlpha ) {\n\n\t\t\t\tif ( premultipliedAlpha === true ) {\n\n\t\t\t\t\tr *= a; g *= a; b *= a;\n\n\t\t\t\t}\n\n\t\t\t\tcolor.set( r, g, b, a );\n\n\t\t\t\tif ( currentColorClear.equals( color ) === false ) {\n\n\t\t\t\t\tgl.clearColor( r, g, b, a );\n\t\t\t\t\tcurrentColorClear.copy( color );\n\n\t\t\t\t}\n\n\t\t\t},\n\n\t\t\treset: function () {\n\n\t\t\t\tlocked = false;\n\n\t\t\t\tcurrentColorMask = null;\n\t\t\t\tcurrentColorClear.set( - 1, 0, 0, 0 ); // set to invalid state\n\n\t\t\t}\n\n\t\t};\n\n\t}\n\n\tfunction DepthBuffer() {\n\n\t\tlet locked = false;\n\n\t\tlet currentDepthMask = null;\n\t\tlet currentDepthFunc = null;\n\t\tlet currentDepthClear = null;\n\n\t\treturn {\n\n\t\t\tsetTest: function ( depthTest ) {\n\n\t\t\t\tif ( depthTest ) {\n\n\t\t\t\t\tenable( gl.DEPTH_TEST );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tdisable( gl.DEPTH_TEST );\n\n\t\t\t\t}\n\n\t\t\t},\n\n\t\t\tsetMask: function ( depthMask ) {\n\n\t\t\t\tif ( currentDepthMask !== depthMask && ! locked ) {\n\n\t\t\t\t\tgl.depthMask( depthMask );\n\t\t\t\t\tcurrentDepthMask = depthMask;\n\n\t\t\t\t}\n\n\t\t\t},\n\n\t\t\tsetFunc: function ( depthFunc ) {\n\n\t\t\t\tif ( currentDepthFunc !== depthFunc ) {\n\n\t\t\t\t\tif ( depthFunc ) {\n\n\t\t\t\t\t\tswitch ( depthFunc ) {\n\n\t\t\t\t\t\t\tcase NeverDepth:\n\n\t\t\t\t\t\t\t\tgl.depthFunc( gl.NEVER );\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase AlwaysDepth:\n\n\t\t\t\t\t\t\t\tgl.depthFunc( gl.ALWAYS );\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase LessDepth:\n\n\t\t\t\t\t\t\t\tgl.depthFunc( gl.LESS );\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase LessEqualDepth:\n\n\t\t\t\t\t\t\t\tgl.depthFunc( gl.LEQUAL );\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase EqualDepth:\n\n\t\t\t\t\t\t\t\tgl.depthFunc( gl.EQUAL );\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase GreaterEqualDepth:\n\n\t\t\t\t\t\t\t\tgl.depthFunc( gl.GEQUAL );\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase GreaterDepth:\n\n\t\t\t\t\t\t\t\tgl.depthFunc( gl.GREATER );\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tcase NotEqualDepth:\n\n\t\t\t\t\t\t\t\tgl.depthFunc( gl.NOTEQUAL );\n\t\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\t\tdefault:\n\n\t\t\t\t\t\t\t\tgl.depthFunc( gl.LEQUAL );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tgl.depthFunc( gl.LEQUAL );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tcurrentDepthFunc = depthFunc;\n\n\t\t\t\t}\n\n\t\t\t},\n\n\t\t\tsetLocked: function ( lock ) {\n\n\t\t\t\tlocked = lock;\n\n\t\t\t},\n\n\t\t\tsetClear: function ( depth ) {\n\n\t\t\t\tif ( currentDepthClear !== depth ) {\n\n\t\t\t\t\tgl.clearDepth( depth );\n\t\t\t\t\tcurrentDepthClear = depth;\n\n\t\t\t\t}\n\n\t\t\t},\n\n\t\t\treset: function () {\n\n\t\t\t\tlocked = false;\n\n\t\t\t\tcurrentDepthMask = null;\n\t\t\t\tcurrentDepthFunc = null;\n\t\t\t\tcurrentDepthClear = null;\n\n\t\t\t}\n\n\t\t};\n\n\t}\n\n\tfunction StencilBuffer() {\n\n\t\tlet locked = false;\n\n\t\tlet currentStencilMask = null;\n\t\tlet currentStencilFunc = null;\n\t\tlet currentStencilRef = null;\n\t\tlet currentStencilFuncMask = null;\n\t\tlet currentStencilFail = null;\n\t\tlet currentStencilZFail = null;\n\t\tlet currentStencilZPass = null;\n\t\tlet currentStencilClear = null;\n\n\t\treturn {\n\n\t\t\tsetTest: function ( stencilTest ) {\n\n\t\t\t\tif ( ! locked ) {\n\n\t\t\t\t\tif ( stencilTest ) {\n\n\t\t\t\t\t\tenable( gl.STENCIL_TEST );\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tdisable( gl.STENCIL_TEST );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t},\n\n\t\t\tsetMask: function ( stencilMask ) {\n\n\t\t\t\tif ( currentStencilMask !== stencilMask && ! locked ) {\n\n\t\t\t\t\tgl.stencilMask( stencilMask );\n\t\t\t\t\tcurrentStencilMask = stencilMask;\n\n\t\t\t\t}\n\n\t\t\t},\n\n\t\t\tsetFunc: function ( stencilFunc, stencilRef, stencilMask ) {\n\n\t\t\t\tif ( currentStencilFunc !== stencilFunc ||\n\t\t\t\t currentStencilRef \t!== stencilRef \t||\n\t\t\t\t currentStencilFuncMask !== stencilMask ) {\n\n\t\t\t\t\tgl.stencilFunc( stencilFunc, stencilRef, stencilMask );\n\n\t\t\t\t\tcurrentStencilFunc = stencilFunc;\n\t\t\t\t\tcurrentStencilRef = stencilRef;\n\t\t\t\t\tcurrentStencilFuncMask = stencilMask;\n\n\t\t\t\t}\n\n\t\t\t},\n\n\t\t\tsetOp: function ( stencilFail, stencilZFail, stencilZPass ) {\n\n\t\t\t\tif ( currentStencilFail\t !== stencilFail \t||\n\t\t\t\t currentStencilZFail !== stencilZFail ||\n\t\t\t\t currentStencilZPass !== stencilZPass ) {\n\n\t\t\t\t\tgl.stencilOp( stencilFail, stencilZFail, stencilZPass );\n\n\t\t\t\t\tcurrentStencilFail = stencilFail;\n\t\t\t\t\tcurrentStencilZFail = stencilZFail;\n\t\t\t\t\tcurrentStencilZPass = stencilZPass;\n\n\t\t\t\t}\n\n\t\t\t},\n\n\t\t\tsetLocked: function ( lock ) {\n\n\t\t\t\tlocked = lock;\n\n\t\t\t},\n\n\t\t\tsetClear: function ( stencil ) {\n\n\t\t\t\tif ( currentStencilClear !== stencil ) {\n\n\t\t\t\t\tgl.clearStencil( stencil );\n\t\t\t\t\tcurrentStencilClear = stencil;\n\n\t\t\t\t}\n\n\t\t\t},\n\n\t\t\treset: function () {\n\n\t\t\t\tlocked = false;\n\n\t\t\t\tcurrentStencilMask = null;\n\t\t\t\tcurrentStencilFunc = null;\n\t\t\t\tcurrentStencilRef = null;\n\t\t\t\tcurrentStencilFuncMask = null;\n\t\t\t\tcurrentStencilFail = null;\n\t\t\t\tcurrentStencilZFail = null;\n\t\t\t\tcurrentStencilZPass = null;\n\t\t\t\tcurrentStencilClear = null;\n\n\t\t\t}\n\n\t\t};\n\n\t}\n\n\t//\n\n\tconst colorBuffer = new ColorBuffer();\n\tconst depthBuffer = new DepthBuffer();\n\tconst stencilBuffer = new StencilBuffer();\n\n\tlet enabledCapabilities = {};\n\n\tlet currentProgram = null;\n\n\tlet currentBlendingEnabled = null;\n\tlet currentBlending = null;\n\tlet currentBlendEquation = null;\n\tlet currentBlendSrc = null;\n\tlet currentBlendDst = null;\n\tlet currentBlendEquationAlpha = null;\n\tlet currentBlendSrcAlpha = null;\n\tlet currentBlendDstAlpha = null;\n\tlet currentPremultipledAlpha = false;\n\n\tlet currentFlipSided = null;\n\tlet currentCullFace = null;\n\n\tlet currentLineWidth = null;\n\n\tlet currentPolygonOffsetFactor = null;\n\tlet currentPolygonOffsetUnits = null;\n\n\tconst maxTextures = gl.getParameter( gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS );\n\n\tlet lineWidthAvailable = false;\n\tlet version = 0;\n\tconst glVersion = gl.getParameter( gl.VERSION );\n\n\tif ( glVersion.indexOf( 'WebGL' ) !== - 1 ) {\n\n\t\tversion = parseFloat( /^WebGL\\ ([0-9])/.exec( glVersion )[ 1 ] );\n\t\tlineWidthAvailable = ( version >= 1.0 );\n\n\t} else if ( glVersion.indexOf( 'OpenGL ES' ) !== - 1 ) {\n\n\t\tversion = parseFloat( /^OpenGL\\ ES\\ ([0-9])/.exec( glVersion )[ 1 ] );\n\t\tlineWidthAvailable = ( version >= 2.0 );\n\n\t}\n\n\tlet currentTextureSlot = null;\n\tlet currentBoundTextures = {};\n\n\tconst currentScissor = new Vector4();\n\tconst currentViewport = new Vector4();\n\n\tfunction createTexture( type, target, count ) {\n\n\t\tconst data = new Uint8Array( 4 ); // 4 is required to match default unpack alignment of 4.\n\t\tconst texture = gl.createTexture();\n\n\t\tgl.bindTexture( type, texture );\n\t\tgl.texParameteri( type, gl.TEXTURE_MIN_FILTER, gl.NEAREST );\n\t\tgl.texParameteri( type, gl.TEXTURE_MAG_FILTER, gl.NEAREST );\n\n\t\tfor ( let i = 0; i < count; i ++ ) {\n\n\t\t\tgl.texImage2D( target + i, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, data );\n\n\t\t}\n\n\t\treturn texture;\n\n\t}\n\n\tconst emptyTextures = {};\n\temptyTextures[ gl.TEXTURE_2D ] = createTexture( gl.TEXTURE_2D, gl.TEXTURE_2D, 1 );\n\temptyTextures[ gl.TEXTURE_CUBE_MAP ] = createTexture( gl.TEXTURE_CUBE_MAP, gl.TEXTURE_CUBE_MAP_POSITIVE_X, 6 );\n\n\t// init\n\n\tcolorBuffer.setClear( 0, 0, 0, 1 );\n\tdepthBuffer.setClear( 1 );\n\tstencilBuffer.setClear( 0 );\n\n\tenable( gl.DEPTH_TEST );\n\tdepthBuffer.setFunc( LessEqualDepth );\n\n\tsetFlipSided( false );\n\tsetCullFace( CullFaceBack );\n\tenable( gl.CULL_FACE );\n\n\tsetBlending( NoBlending );\n\n\t//\n\n\tfunction enable( id ) {\n\n\t\tif ( enabledCapabilities[ id ] !== true ) {\n\n\t\t\tgl.enable( id );\n\t\t\tenabledCapabilities[ id ] = true;\n\n\t\t}\n\n\t}\n\n\tfunction disable( id ) {\n\n\t\tif ( enabledCapabilities[ id ] !== false ) {\n\n\t\t\tgl.disable( id );\n\t\t\tenabledCapabilities[ id ] = false;\n\n\t\t}\n\n\t}\n\n\tfunction useProgram( program ) {\n\n\t\tif ( currentProgram !== program ) {\n\n\t\t\tgl.useProgram( program );\n\n\t\t\tcurrentProgram = program;\n\n\t\t\treturn true;\n\n\t\t}\n\n\t\treturn false;\n\n\t}\n\n\tconst equationToGL = {\n\t\t[ AddEquation ]: gl.FUNC_ADD,\n\t\t[ SubtractEquation ]: gl.FUNC_SUBTRACT,\n\t\t[ ReverseSubtractEquation ]: gl.FUNC_REVERSE_SUBTRACT\n\t};\n\n\tif ( isWebGL2 ) {\n\n\t\tequationToGL[ MinEquation ] = gl.MIN;\n\t\tequationToGL[ MaxEquation ] = gl.MAX;\n\n\t} else {\n\n\t\tconst extension = extensions.get( 'EXT_blend_minmax' );\n\n\t\tif ( extension !== null ) {\n\n\t\t\tequationToGL[ MinEquation ] = extension.MIN_EXT;\n\t\t\tequationToGL[ MaxEquation ] = extension.MAX_EXT;\n\n\t\t}\n\n\t}\n\n\tconst factorToGL = {\n\t\t[ ZeroFactor ]: gl.ZERO,\n\t\t[ OneFactor ]: gl.ONE,\n\t\t[ SrcColorFactor ]: gl.SRC_COLOR,\n\t\t[ SrcAlphaFactor ]: gl.SRC_ALPHA,\n\t\t[ SrcAlphaSaturateFactor ]: gl.SRC_ALPHA_SATURATE,\n\t\t[ DstColorFactor ]: gl.DST_COLOR,\n\t\t[ DstAlphaFactor ]: gl.DST_ALPHA,\n\t\t[ OneMinusSrcColorFactor ]: gl.ONE_MINUS_SRC_COLOR,\n\t\t[ OneMinusSrcAlphaFactor ]: gl.ONE_MINUS_SRC_ALPHA,\n\t\t[ OneMinusDstColorFactor ]: gl.ONE_MINUS_DST_COLOR,\n\t\t[ OneMinusDstAlphaFactor ]: gl.ONE_MINUS_DST_ALPHA\n\t};\n\n\tfunction setBlending( blending, blendEquation, blendSrc, blendDst, blendEquationAlpha, blendSrcAlpha, blendDstAlpha, premultipliedAlpha ) {\n\n\t\tif ( blending === NoBlending ) {\n\n\t\t\tif ( currentBlendingEnabled ) {\n\n\t\t\t\tdisable( gl.BLEND );\n\t\t\t\tcurrentBlendingEnabled = false;\n\n\t\t\t}\n\n\t\t\treturn;\n\n\t\t}\n\n\t\tif ( ! currentBlendingEnabled ) {\n\n\t\t\tenable( gl.BLEND );\n\t\t\tcurrentBlendingEnabled = true;\n\n\t\t}\n\n\t\tif ( blending !== CustomBlending ) {\n\n\t\t\tif ( blending !== currentBlending || premultipliedAlpha !== currentPremultipledAlpha ) {\n\n\t\t\t\tif ( currentBlendEquation !== AddEquation || currentBlendEquationAlpha !== AddEquation ) {\n\n\t\t\t\t\tgl.blendEquation( gl.FUNC_ADD );\n\n\t\t\t\t\tcurrentBlendEquation = AddEquation;\n\t\t\t\t\tcurrentBlendEquationAlpha = AddEquation;\n\n\t\t\t\t}\n\n\t\t\t\tif ( premultipliedAlpha ) {\n\n\t\t\t\t\tswitch ( blending ) {\n\n\t\t\t\t\t\tcase NormalBlending:\n\t\t\t\t\t\t\tgl.blendFuncSeparate( gl.ONE, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA );\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase AdditiveBlending:\n\t\t\t\t\t\t\tgl.blendFunc( gl.ONE, gl.ONE );\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase SubtractiveBlending:\n\t\t\t\t\t\t\tgl.blendFuncSeparate( gl.ZERO, gl.ZERO, gl.ONE_MINUS_SRC_COLOR, gl.ONE_MINUS_SRC_ALPHA );\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase MultiplyBlending:\n\t\t\t\t\t\t\tgl.blendFuncSeparate( gl.ZERO, gl.SRC_COLOR, gl.ZERO, gl.SRC_ALPHA );\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tconsole.error( 'THREE.WebGLState: Invalid blending: ', blending );\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\n\t\t\t\t\tswitch ( blending ) {\n\n\t\t\t\t\t\tcase NormalBlending:\n\t\t\t\t\t\t\tgl.blendFuncSeparate( gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA, gl.ONE, gl.ONE_MINUS_SRC_ALPHA );\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase AdditiveBlending:\n\t\t\t\t\t\t\tgl.blendFunc( gl.SRC_ALPHA, gl.ONE );\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase SubtractiveBlending:\n\t\t\t\t\t\t\tgl.blendFunc( gl.ZERO, gl.ONE_MINUS_SRC_COLOR );\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tcase MultiplyBlending:\n\t\t\t\t\t\t\tgl.blendFunc( gl.ZERO, gl.SRC_COLOR );\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t\tdefault:\n\t\t\t\t\t\t\tconsole.error( 'THREE.WebGLState: Invalid blending: ', blending );\n\t\t\t\t\t\t\tbreak;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tcurrentBlendSrc = null;\n\t\t\t\tcurrentBlendDst = null;\n\t\t\t\tcurrentBlendSrcAlpha = null;\n\t\t\t\tcurrentBlendDstAlpha = null;\n\n\t\t\t\tcurrentBlending = blending;\n\t\t\t\tcurrentPremultipledAlpha = premultipliedAlpha;\n\n\t\t\t}\n\n\t\t\treturn;\n\n\t\t}\n\n\t\t// custom blending\n\n\t\tblendEquationAlpha = blendEquationAlpha || blendEquation;\n\t\tblendSrcAlpha = blendSrcAlpha || blendSrc;\n\t\tblendDstAlpha = blendDstAlpha || blendDst;\n\n\t\tif ( blendEquation !== currentBlendEquation || blendEquationAlpha !== currentBlendEquationAlpha ) {\n\n\t\t\tgl.blendEquationSeparate( equationToGL[ blendEquation ], equationToGL[ blendEquationAlpha ] );\n\n\t\t\tcurrentBlendEquation = blendEquation;\n\t\t\tcurrentBlendEquationAlpha = blendEquationAlpha;\n\n\t\t}\n\n\t\tif ( blendSrc !== currentBlendSrc || blendDst !== currentBlendDst || blendSrcAlpha !== currentBlendSrcAlpha || blendDstAlpha !== currentBlendDstAlpha ) {\n\n\t\t\tgl.blendFuncSeparate( factorToGL[ blendSrc ], factorToGL[ blendDst ], factorToGL[ blendSrcAlpha ], factorToGL[ blendDstAlpha ] );\n\n\t\t\tcurrentBlendSrc = blendSrc;\n\t\t\tcurrentBlendDst = blendDst;\n\t\t\tcurrentBlendSrcAlpha = blendSrcAlpha;\n\t\t\tcurrentBlendDstAlpha = blendDstAlpha;\n\n\t\t}\n\n\t\tcurrentBlending = blending;\n\t\tcurrentPremultipledAlpha = null;\n\n\t}\n\n\tfunction setMaterial( material, frontFaceCW ) {\n\n\t\tmaterial.side === DoubleSide\n\t\t\t? disable( gl.CULL_FACE )\n\t\t\t: enable( gl.CULL_FACE );\n\n\t\tlet flipSided = ( material.side === BackSide );\n\t\tif ( frontFaceCW ) flipSided = ! flipSided;\n\n\t\tsetFlipSided( flipSided );\n\n\t\t( material.blending === NormalBlending && material.transparent === false )\n\t\t\t? setBlending( NoBlending )\n\t\t\t: setBlending( material.blending, material.blendEquation, material.blendSrc, material.blendDst, material.blendEquationAlpha, material.blendSrcAlpha, material.blendDstAlpha, material.premultipliedAlpha );\n\n\t\tdepthBuffer.setFunc( material.depthFunc );\n\t\tdepthBuffer.setTest( material.depthTest );\n\t\tdepthBuffer.setMask( material.depthWrite );\n\t\tcolorBuffer.setMask( material.colorWrite );\n\n\t\tconst stencilWrite = material.stencilWrite;\n\t\tstencilBuffer.setTest( stencilWrite );\n\t\tif ( stencilWrite ) {\n\n\t\t\tstencilBuffer.setMask( material.stencilWriteMask );\n\t\t\tstencilBuffer.setFunc( material.stencilFunc, material.stencilRef, material.stencilFuncMask );\n\t\t\tstencilBuffer.setOp( material.stencilFail, material.stencilZFail, material.stencilZPass );\n\n\t\t}\n\n\t\tsetPolygonOffset( material.polygonOffset, material.polygonOffsetFactor, material.polygonOffsetUnits );\n\n\t}\n\n\t//\n\n\tfunction setFlipSided( flipSided ) {\n\n\t\tif ( currentFlipSided !== flipSided ) {\n\n\t\t\tif ( flipSided ) {\n\n\t\t\t\tgl.frontFace( gl.CW );\n\n\t\t\t} else {\n\n\t\t\t\tgl.frontFace( gl.CCW );\n\n\t\t\t}\n\n\t\t\tcurrentFlipSided = flipSided;\n\n\t\t}\n\n\t}\n\n\tfunction setCullFace( cullFace ) {\n\n\t\tif ( cullFace !== CullFaceNone ) {\n\n\t\t\tenable( gl.CULL_FACE );\n\n\t\t\tif ( cullFace !== currentCullFace ) {\n\n\t\t\t\tif ( cullFace === CullFaceBack ) {\n\n\t\t\t\t\tgl.cullFace( gl.BACK );\n\n\t\t\t\t} else if ( cullFace === CullFaceFront ) {\n\n\t\t\t\t\tgl.cullFace( gl.FRONT );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tgl.cullFace( gl.FRONT_AND_BACK );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tdisable( gl.CULL_FACE );\n\n\t\t}\n\n\t\tcurrentCullFace = cullFace;\n\n\t}\n\n\tfunction setLineWidth( width ) {\n\n\t\tif ( width !== currentLineWidth ) {\n\n\t\t\tif ( lineWidthAvailable ) gl.lineWidth( width );\n\n\t\t\tcurrentLineWidth = width;\n\n\t\t}\n\n\t}\n\n\tfunction setPolygonOffset( polygonOffset, factor, units ) {\n\n\t\tif ( polygonOffset ) {\n\n\t\t\tenable( gl.POLYGON_OFFSET_FILL );\n\n\t\t\tif ( currentPolygonOffsetFactor !== factor || currentPolygonOffsetUnits !== units ) {\n\n\t\t\t\tgl.polygonOffset( factor, units );\n\n\t\t\t\tcurrentPolygonOffsetFactor = factor;\n\t\t\t\tcurrentPolygonOffsetUnits = units;\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tdisable( gl.POLYGON_OFFSET_FILL );\n\n\t\t}\n\n\t}\n\n\tfunction setScissorTest( scissorTest ) {\n\n\t\tif ( scissorTest ) {\n\n\t\t\tenable( gl.SCISSOR_TEST );\n\n\t\t} else {\n\n\t\t\tdisable( gl.SCISSOR_TEST );\n\n\t\t}\n\n\t}\n\n\t// texture\n\n\tfunction activeTexture( webglSlot ) {\n\n\t\tif ( webglSlot === undefined ) webglSlot = gl.TEXTURE0 + maxTextures - 1;\n\n\t\tif ( currentTextureSlot !== webglSlot ) {\n\n\t\t\tgl.activeTexture( webglSlot );\n\t\t\tcurrentTextureSlot = webglSlot;\n\n\t\t}\n\n\t}\n\n\tfunction bindTexture( webglType, webglTexture ) {\n\n\t\tif ( currentTextureSlot === null ) {\n\n\t\t\tactiveTexture();\n\n\t\t}\n\n\t\tlet boundTexture = currentBoundTextures[ currentTextureSlot ];\n\n\t\tif ( boundTexture === undefined ) {\n\n\t\t\tboundTexture = { type: undefined, texture: undefined };\n\t\t\tcurrentBoundTextures[ currentTextureSlot ] = boundTexture;\n\n\t\t}\n\n\t\tif ( boundTexture.type !== webglType || boundTexture.texture !== webglTexture ) {\n\n\t\t\tgl.bindTexture( webglType, webglTexture || emptyTextures[ webglType ] );\n\n\t\t\tboundTexture.type = webglType;\n\t\t\tboundTexture.texture = webglTexture;\n\n\t\t}\n\n\t}\n\n\tfunction unbindTexture() {\n\n\t\tconst boundTexture = currentBoundTextures[ currentTextureSlot ];\n\n\t\tif ( boundTexture !== undefined && boundTexture.type !== undefined ) {\n\n\t\t\tgl.bindTexture( boundTexture.type, null );\n\n\t\t\tboundTexture.type = undefined;\n\t\t\tboundTexture.texture = undefined;\n\n\t\t}\n\n\t}\n\n\tfunction compressedTexImage2D() {\n\n\t\ttry {\n\n\t\t\tgl.compressedTexImage2D.apply( gl, arguments );\n\n\t\t} catch ( error ) {\n\n\t\t\tconsole.error( 'THREE.WebGLState:', error );\n\n\t\t}\n\n\t}\n\n\tfunction texImage2D() {\n\n\t\ttry {\n\n\t\t\tgl.texImage2D.apply( gl, arguments );\n\n\t\t} catch ( error ) {\n\n\t\t\tconsole.error( 'THREE.WebGLState:', error );\n\n\t\t}\n\n\t}\n\n\tfunction texImage3D() {\n\n\t\ttry {\n\n\t\t\tgl.texImage3D.apply( gl, arguments );\n\n\t\t} catch ( error ) {\n\n\t\t\tconsole.error( 'THREE.WebGLState:', error );\n\n\t\t}\n\n\t}\n\n\t//\n\n\tfunction scissor( scissor ) {\n\n\t\tif ( currentScissor.equals( scissor ) === false ) {\n\n\t\t\tgl.scissor( scissor.x, scissor.y, scissor.z, scissor.w );\n\t\t\tcurrentScissor.copy( scissor );\n\n\t\t}\n\n\t}\n\n\tfunction viewport( viewport ) {\n\n\t\tif ( currentViewport.equals( viewport ) === false ) {\n\n\t\t\tgl.viewport( viewport.x, viewport.y, viewport.z, viewport.w );\n\t\t\tcurrentViewport.copy( viewport );\n\n\t\t}\n\n\t}\n\n\t//\n\n\tfunction reset() {\n\n\t\tenabledCapabilities = {};\n\n\t\tcurrentTextureSlot = null;\n\t\tcurrentBoundTextures = {};\n\n\t\tcurrentProgram = null;\n\n\t\tcurrentBlending = null;\n\n\t\tcurrentFlipSided = null;\n\t\tcurrentCullFace = null;\n\n\t\tcolorBuffer.reset();\n\t\tdepthBuffer.reset();\n\t\tstencilBuffer.reset();\n\n\t}\n\n\treturn {\n\n\t\tbuffers: {\n\t\t\tcolor: colorBuffer,\n\t\t\tdepth: depthBuffer,\n\t\t\tstencil: stencilBuffer\n\t\t},\n\n\t\tenable: enable,\n\t\tdisable: disable,\n\n\t\tuseProgram: useProgram,\n\n\t\tsetBlending: setBlending,\n\t\tsetMaterial: setMaterial,\n\n\t\tsetFlipSided: setFlipSided,\n\t\tsetCullFace: setCullFace,\n\n\t\tsetLineWidth: setLineWidth,\n\t\tsetPolygonOffset: setPolygonOffset,\n\n\t\tsetScissorTest: setScissorTest,\n\n\t\tactiveTexture: activeTexture,\n\t\tbindTexture: bindTexture,\n\t\tunbindTexture: unbindTexture,\n\t\tcompressedTexImage2D: compressedTexImage2D,\n\t\ttexImage2D: texImage2D,\n\t\ttexImage3D: texImage3D,\n\n\t\tscissor: scissor,\n\t\tviewport: viewport,\n\n\t\treset: reset\n\n\t};\n\n}\n\nexport { WebGLState };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { LinearFilter, LinearMipmapLinearFilter, LinearMipmapNearestFilter, NearestFilter, NearestMipmapLinearFilter, NearestMipmapNearestFilter, RGBFormat, RGBAFormat, DepthFormat, DepthStencilFormat, UnsignedShortType, UnsignedIntType, UnsignedInt248Type, FloatType, HalfFloatType, MirroredRepeatWrapping, ClampToEdgeWrapping, RepeatWrapping } from '../../constants.js';\nimport { MathUtils } from '../../math/MathUtils.js';\n\nfunction WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info ) {\n\n\tconst isWebGL2 = capabilities.isWebGL2;\n\tconst maxTextures = capabilities.maxTextures;\n\tconst maxCubemapSize = capabilities.maxCubemapSize;\n\tconst maxTextureSize = capabilities.maxTextureSize;\n\tconst maxSamples = capabilities.maxSamples;\n\n\tconst _videoTextures = new WeakMap();\n\tlet _canvas;\n\n\t// cordova iOS (as of 5.0) still uses UIWebView, which provides OffscreenCanvas,\n\t// also OffscreenCanvas.getContext(\"webgl\"), but not OffscreenCanvas.getContext(\"2d\")!\n\t// Some implementations may only implement OffscreenCanvas partially (e.g. lacking 2d).\n\n\tlet useOffscreenCanvas = false;\n\n\ttry {\n\n\t\tuseOffscreenCanvas = typeof OffscreenCanvas !== 'undefined'\n\t\t\t&& ( new OffscreenCanvas( 1, 1 ).getContext( \"2d\" ) ) !== null;\n\n\t} catch ( err ) {\n\n\t\t// Ignore any errors\n\n\t}\n\n\tfunction createCanvas( width, height ) {\n\n\t\t// Use OffscreenCanvas when available. Specially needed in web workers\n\n\t\treturn useOffscreenCanvas ?\n\t\t\tnew OffscreenCanvas( width, height ) :\n\t\t\tdocument.createElementNS( 'http://www.w3.org/1999/xhtml', 'canvas' );\n\n\t}\n\n\tfunction resizeImage( image, needsPowerOfTwo, needsNewCanvas, maxSize ) {\n\n\t\tlet scale = 1;\n\n\t\t// handle case if texture exceeds max size\n\n\t\tif ( image.width > maxSize || image.height > maxSize ) {\n\n\t\t\tscale = maxSize / Math.max( image.width, image.height );\n\n\t\t}\n\n\t\t// only perform resize if necessary\n\n\t\tif ( scale < 1 || needsPowerOfTwo === true ) {\n\n\t\t\t// only perform resize for certain image types\n\n\t\t\tif ( ( typeof HTMLImageElement !== 'undefined' && image instanceof HTMLImageElement ) ||\n\t\t\t\t( typeof HTMLCanvasElement !== 'undefined' && image instanceof HTMLCanvasElement ) ||\n\t\t\t\t( typeof ImageBitmap !== 'undefined' && image instanceof ImageBitmap ) ) {\n\n\t\t\t\tconst floor = needsPowerOfTwo ? MathUtils.floorPowerOfTwo : Math.floor;\n\n\t\t\t\tconst width = floor( scale * image.width );\n\t\t\t\tconst height = floor( scale * image.height );\n\n\t\t\t\tif ( _canvas === undefined ) _canvas = createCanvas( width, height );\n\n\t\t\t\t// cube textures can't reuse the same canvas\n\n\t\t\t\tconst canvas = needsNewCanvas ? createCanvas( width, height ) : _canvas;\n\n\t\t\t\tcanvas.width = width;\n\t\t\t\tcanvas.height = height;\n\n\t\t\t\tconst context = canvas.getContext( '2d' );\n\t\t\t\tcontext.drawImage( image, 0, 0, width, height );\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Texture has been resized from (' + image.width + 'x' + image.height + ') to (' + width + 'x' + height + ').' );\n\n\t\t\t\treturn canvas;\n\n\t\t\t} else {\n\n\t\t\t\tif ( 'data' in image ) {\n\n\t\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Image in DataTexture is too big (' + image.width + 'x' + image.height + ').' );\n\n\t\t\t\t}\n\n\t\t\t\treturn image;\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn image;\n\n\t}\n\n\tfunction isPowerOfTwo( image ) {\n\n\t\treturn MathUtils.isPowerOfTwo( image.width ) && MathUtils.isPowerOfTwo( image.height );\n\n\t}\n\n\tfunction textureNeedsPowerOfTwo( texture ) {\n\n\t\tif ( isWebGL2 ) return false;\n\n\t\treturn ( texture.wrapS !== ClampToEdgeWrapping || texture.wrapT !== ClampToEdgeWrapping ) ||\n\t\t\t( texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter );\n\n\t}\n\n\tfunction textureNeedsGenerateMipmaps( texture, supportsMips ) {\n\n\t\treturn texture.generateMipmaps && supportsMips &&\n\t\t\ttexture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter;\n\n\t}\n\n\tfunction generateMipmap( target, texture, width, height ) {\n\n\t\t_gl.generateMipmap( target );\n\n\t\tconst textureProperties = properties.get( texture );\n\n\t\t// Note: Math.log( x ) * Math.LOG2E used instead of Math.log2( x ) which is not supported by IE11\n\t\ttextureProperties.__maxMipLevel = Math.log( Math.max( width, height ) ) * Math.LOG2E;\n\n\t}\n\n\tfunction getInternalFormat( internalFormatName, glFormat, glType ) {\n\n\t\tif ( isWebGL2 === false ) return glFormat;\n\n\t\tif ( internalFormatName !== null ) {\n\n\t\t\tif ( _gl[ internalFormatName ] !== undefined ) return _gl[ internalFormatName ];\n\n\t\t\tconsole.warn( 'THREE.WebGLRenderer: Attempt to use non-existing WebGL internal format \\'' + internalFormatName + '\\'' );\n\n\t\t}\n\n\t\tlet internalFormat = glFormat;\n\n\t\tif ( glFormat === _gl.RED ) {\n\n\t\t\tif ( glType === _gl.FLOAT ) internalFormat = _gl.R32F;\n\t\t\tif ( glType === _gl.HALF_FLOAT ) internalFormat = _gl.R16F;\n\t\t\tif ( glType === _gl.UNSIGNED_BYTE ) internalFormat = _gl.R8;\n\n\t\t}\n\n\t\tif ( glFormat === _gl.RGB ) {\n\n\t\t\tif ( glType === _gl.FLOAT ) internalFormat = _gl.RGB32F;\n\t\t\tif ( glType === _gl.HALF_FLOAT ) internalFormat = _gl.RGB16F;\n\t\t\tif ( glType === _gl.UNSIGNED_BYTE ) internalFormat = _gl.RGB8;\n\n\t\t}\n\n\t\tif ( glFormat === _gl.RGBA ) {\n\n\t\t\tif ( glType === _gl.FLOAT ) internalFormat = _gl.RGBA32F;\n\t\t\tif ( glType === _gl.HALF_FLOAT ) internalFormat = _gl.RGBA16F;\n\t\t\tif ( glType === _gl.UNSIGNED_BYTE ) internalFormat = _gl.RGBA8;\n\n\t\t}\n\n\t\tif ( internalFormat === _gl.R16F || internalFormat === _gl.R32F ||\n\t\t\tinternalFormat === _gl.RGBA16F || internalFormat === _gl.RGBA32F ) {\n\n\t\t\textensions.get( 'EXT_color_buffer_float' );\n\n\t\t}\n\n\t\treturn internalFormat;\n\n\t}\n\n\t// Fallback filters for non-power-of-2 textures\n\n\tfunction filterFallback( f ) {\n\n\t\tif ( f === NearestFilter || f === NearestMipmapNearestFilter || f === NearestMipmapLinearFilter ) {\n\n\t\t\treturn _gl.NEAREST;\n\n\t\t}\n\n\t\treturn _gl.LINEAR;\n\n\t}\n\n\t//\n\n\tfunction onTextureDispose( event ) {\n\n\t\tconst texture = event.target;\n\n\t\ttexture.removeEventListener( 'dispose', onTextureDispose );\n\n\t\tdeallocateTexture( texture );\n\n\t\tif ( texture.isVideoTexture ) {\n\n\t\t\t_videoTextures.delete( texture );\n\n\t\t}\n\n\t\tinfo.memory.textures --;\n\n\t}\n\n\tfunction onRenderTargetDispose( event ) {\n\n\t\tconst renderTarget = event.target;\n\n\t\trenderTarget.removeEventListener( 'dispose', onRenderTargetDispose );\n\n\t\tdeallocateRenderTarget( renderTarget );\n\n\t\tinfo.memory.textures --;\n\n\t}\n\n\t//\n\n\tfunction deallocateTexture( texture ) {\n\n\t\tconst textureProperties = properties.get( texture );\n\n\t\tif ( textureProperties.__webglInit === undefined ) return;\n\n\t\t_gl.deleteTexture( textureProperties.__webglTexture );\n\n\t\tproperties.remove( texture );\n\n\t}\n\n\tfunction deallocateRenderTarget( renderTarget ) {\n\n\t\tconst renderTargetProperties = properties.get( renderTarget );\n\t\tconst textureProperties = properties.get( renderTarget.texture );\n\n\t\tif ( ! renderTarget ) return;\n\n\t\tif ( textureProperties.__webglTexture !== undefined ) {\n\n\t\t\t_gl.deleteTexture( textureProperties.__webglTexture );\n\n\t\t}\n\n\t\tif ( renderTarget.depthTexture ) {\n\n\t\t\trenderTarget.depthTexture.dispose();\n\n\t\t}\n\n\t\tif ( renderTarget.isWebGLCubeRenderTarget ) {\n\n\t\t\tfor ( let i = 0; i < 6; i ++ ) {\n\n\t\t\t\t_gl.deleteFramebuffer( renderTargetProperties.__webglFramebuffer[ i ] );\n\t\t\t\tif ( renderTargetProperties.__webglDepthbuffer ) _gl.deleteRenderbuffer( renderTargetProperties.__webglDepthbuffer[ i ] );\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\t_gl.deleteFramebuffer( renderTargetProperties.__webglFramebuffer );\n\t\t\tif ( renderTargetProperties.__webglDepthbuffer ) _gl.deleteRenderbuffer( renderTargetProperties.__webglDepthbuffer );\n\t\t\tif ( renderTargetProperties.__webglMultisampledFramebuffer ) _gl.deleteFramebuffer( renderTargetProperties.__webglMultisampledFramebuffer );\n\t\t\tif ( renderTargetProperties.__webglColorRenderbuffer ) _gl.deleteRenderbuffer( renderTargetProperties.__webglColorRenderbuffer );\n\t\t\tif ( renderTargetProperties.__webglDepthRenderbuffer ) _gl.deleteRenderbuffer( renderTargetProperties.__webglDepthRenderbuffer );\n\n\t\t}\n\n\t\tproperties.remove( renderTarget.texture );\n\t\tproperties.remove( renderTarget );\n\n\t}\n\n\t//\n\n\tlet textureUnits = 0;\n\n\tfunction resetTextureUnits() {\n\n\t\ttextureUnits = 0;\n\n\t}\n\n\tfunction allocateTextureUnit() {\n\n\t\tconst textureUnit = textureUnits;\n\n\t\tif ( textureUnit >= maxTextures ) {\n\n\t\t\tconsole.warn( 'THREE.WebGLTextures: Trying to use ' + textureUnit + ' texture units while this GPU supports only ' + maxTextures );\n\n\t\t}\n\n\t\ttextureUnits += 1;\n\n\t\treturn textureUnit;\n\n\t}\n\n\t//\n\n\tfunction setTexture2D( texture, slot ) {\n\n\t\tconst textureProperties = properties.get( texture );\n\n\t\tif ( texture.isVideoTexture ) updateVideoTexture( texture );\n\n\t\tif ( texture.version > 0 && textureProperties.__version !== texture.version ) {\n\n\t\t\tconst image = texture.image;\n\n\t\t\tif ( image === undefined ) {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Texture marked for update but image is undefined' );\n\n\t\t\t} else if ( image.complete === false ) {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Texture marked for update but image is incomplete' );\n\n\t\t\t} else {\n\n\t\t\t\tuploadTexture( textureProperties, texture, slot );\n\t\t\t\treturn;\n\n\t\t\t}\n\n\t\t}\n\n\t\tstate.activeTexture( _gl.TEXTURE0 + slot );\n\t\tstate.bindTexture( _gl.TEXTURE_2D, textureProperties.__webglTexture );\n\n\t}\n\n\tfunction setTexture2DArray( texture, slot ) {\n\n\t\tconst textureProperties = properties.get( texture );\n\n\t\tif ( texture.version > 0 && textureProperties.__version !== texture.version ) {\n\n\t\t\tuploadTexture( textureProperties, texture, slot );\n\t\t\treturn;\n\n\t\t}\n\n\t\tstate.activeTexture( _gl.TEXTURE0 + slot );\n\t\tstate.bindTexture( _gl.TEXTURE_2D_ARRAY, textureProperties.__webglTexture );\n\n\t}\n\n\tfunction setTexture3D( texture, slot ) {\n\n\t\tconst textureProperties = properties.get( texture );\n\n\t\tif ( texture.version > 0 && textureProperties.__version !== texture.version ) {\n\n\t\t\tuploadTexture( textureProperties, texture, slot );\n\t\t\treturn;\n\n\t\t}\n\n\t\tstate.activeTexture( _gl.TEXTURE0 + slot );\n\t\tstate.bindTexture( _gl.TEXTURE_3D, textureProperties.__webglTexture );\n\n\t}\n\n\tfunction setTextureCube( texture, slot ) {\n\n\t\tif ( texture.image.length !== 6 ) return;\n\n\t\tconst textureProperties = properties.get( texture );\n\n\t\tif ( texture.version > 0 && textureProperties.__version !== texture.version ) {\n\n\t\t\tinitTexture( textureProperties, texture );\n\n\t\t\tstate.activeTexture( _gl.TEXTURE0 + slot );\n\t\t\tstate.bindTexture( _gl.TEXTURE_CUBE_MAP, textureProperties.__webglTexture );\n\n\t\t\t_gl.pixelStorei( _gl.UNPACK_FLIP_Y_WEBGL, texture.flipY );\n\n\t\t\tconst isCompressed = ( texture && ( texture.isCompressedTexture || texture.image[ 0 ].isCompressedTexture ) );\n\t\t\tconst isDataTexture = ( texture.image[ 0 ] && texture.image[ 0 ].isDataTexture );\n\n\t\t\tconst cubeImage = [];\n\n\t\t\tfor ( let i = 0; i < 6; i ++ ) {\n\n\t\t\t\tif ( ! isCompressed && ! isDataTexture ) {\n\n\t\t\t\t\tcubeImage[ i ] = resizeImage( texture.image[ i ], false, true, maxCubemapSize );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tcubeImage[ i ] = isDataTexture ? texture.image[ i ].image : texture.image[ i ];\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tconst image = cubeImage[ 0 ],\n\t\t\t\tsupportsMips = isPowerOfTwo( image ) || isWebGL2,\n\t\t\t\tglFormat = utils.convert( texture.format ),\n\t\t\t\tglType = utils.convert( texture.type ),\n\t\t\t\tglInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType );\n\n\t\t\tsetTextureParameters( _gl.TEXTURE_CUBE_MAP, texture, supportsMips );\n\n\t\t\tlet mipmaps;\n\n\t\t\tif ( isCompressed ) {\n\n\t\t\t\tfor ( let i = 0; i < 6; i ++ ) {\n\n\t\t\t\t\tmipmaps = cubeImage[ i ].mipmaps;\n\n\t\t\t\t\tfor ( let j = 0; j < mipmaps.length; j ++ ) {\n\n\t\t\t\t\t\tconst mipmap = mipmaps[ j ];\n\n\t\t\t\t\t\tif ( texture.format !== RGBAFormat && texture.format !== RGBFormat ) {\n\n\t\t\t\t\t\t\tif ( glFormat !== null ) {\n\n\t\t\t\t\t\t\t\tstate.compressedTexImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data );\n\n\t\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setTextureCube()' );\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t} else {\n\n\t\t\t\t\t\t\tstate.texImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\ttextureProperties.__maxMipLevel = mipmaps.length - 1;\n\n\t\t\t} else {\n\n\t\t\t\tmipmaps = texture.mipmaps;\n\n\t\t\t\tfor ( let i = 0; i < 6; i ++ ) {\n\n\t\t\t\t\tif ( isDataTexture ) {\n\n\t\t\t\t\t\tstate.texImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, glInternalFormat, cubeImage[ i ].width, cubeImage[ i ].height, 0, glFormat, glType, cubeImage[ i ].data );\n\n\t\t\t\t\t\tfor ( let j = 0; j < mipmaps.length; j ++ ) {\n\n\t\t\t\t\t\t\tconst mipmap = mipmaps[ j ];\n\t\t\t\t\t\t\tconst mipmapImage = mipmap.image[ i ].image;\n\n\t\t\t\t\t\t\tstate.texImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j + 1, glInternalFormat, mipmapImage.width, mipmapImage.height, 0, glFormat, glType, mipmapImage.data );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tstate.texImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, 0, glInternalFormat, glFormat, glType, cubeImage[ i ] );\n\n\t\t\t\t\t\tfor ( let j = 0; j < mipmaps.length; j ++ ) {\n\n\t\t\t\t\t\t\tconst mipmap = mipmaps[ j ];\n\n\t\t\t\t\t\t\tstate.texImage2D( _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i, j + 1, glInternalFormat, glFormat, glType, mipmap.image[ i ] );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\ttextureProperties.__maxMipLevel = mipmaps.length;\n\n\t\t\t}\n\n\t\t\tif ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) {\n\n\t\t\t\t// We assume images for cube map have the same size.\n\t\t\t\tgenerateMipmap( _gl.TEXTURE_CUBE_MAP, texture, image.width, image.height );\n\n\t\t\t}\n\n\t\t\ttextureProperties.__version = texture.version;\n\n\t\t\tif ( texture.onUpdate ) texture.onUpdate( texture );\n\n\t\t} else {\n\n\t\t\tstate.activeTexture( _gl.TEXTURE0 + slot );\n\t\t\tstate.bindTexture( _gl.TEXTURE_CUBE_MAP, textureProperties.__webglTexture );\n\n\t\t}\n\n\t}\n\n\tfunction setTextureCubeDynamic( texture, slot ) {\n\n\t\tstate.activeTexture( _gl.TEXTURE0 + slot );\n\t\tstate.bindTexture( _gl.TEXTURE_CUBE_MAP, properties.get( texture ).__webglTexture );\n\n\t}\n\n\tconst wrappingToGL = {\n\t\t[ RepeatWrapping ]: _gl.REPEAT,\n\t\t[ ClampToEdgeWrapping ]: _gl.CLAMP_TO_EDGE,\n\t\t[ MirroredRepeatWrapping ]: _gl.MIRRORED_REPEAT\n\t};\n\n\tconst filterToGL = {\n\t\t[ NearestFilter ]: _gl.NEAREST,\n\t\t[ NearestMipmapNearestFilter ]: _gl.NEAREST_MIPMAP_NEAREST,\n\t\t[ NearestMipmapLinearFilter ]: _gl.NEAREST_MIPMAP_LINEAR,\n\n\t\t[ LinearFilter ]: _gl.LINEAR,\n\t\t[ LinearMipmapNearestFilter ]: _gl.LINEAR_MIPMAP_NEAREST,\n\t\t[ LinearMipmapLinearFilter ]: _gl.LINEAR_MIPMAP_LINEAR\n\t};\n\n\tfunction setTextureParameters( textureType, texture, supportsMips ) {\n\n\t\tif ( supportsMips ) {\n\n\t\t\t_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_S, wrappingToGL[ texture.wrapS ] );\n\t\t\t_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_T, wrappingToGL[ texture.wrapT ] );\n\n\t\t\tif ( textureType === _gl.TEXTURE_3D || textureType === _gl.TEXTURE_2D_ARRAY ) {\n\n\t\t\t\t_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_R, wrappingToGL[ texture.wrapR ] );\n\n\t\t\t}\n\n\t\t\t_gl.texParameteri( textureType, _gl.TEXTURE_MAG_FILTER, filterToGL[ texture.magFilter ] );\n\t\t\t_gl.texParameteri( textureType, _gl.TEXTURE_MIN_FILTER, filterToGL[ texture.minFilter ] );\n\n\t\t} else {\n\n\t\t\t_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_S, _gl.CLAMP_TO_EDGE );\n\t\t\t_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_T, _gl.CLAMP_TO_EDGE );\n\n\t\t\tif ( textureType === _gl.TEXTURE_3D || textureType === _gl.TEXTURE_2D_ARRAY ) {\n\n\t\t\t\t_gl.texParameteri( textureType, _gl.TEXTURE_WRAP_R, _gl.CLAMP_TO_EDGE );\n\n\t\t\t}\n\n\t\t\tif ( texture.wrapS !== ClampToEdgeWrapping || texture.wrapT !== ClampToEdgeWrapping ) {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping.' );\n\n\t\t\t}\n\n\t\t\t_gl.texParameteri( textureType, _gl.TEXTURE_MAG_FILTER, filterFallback( texture.magFilter ) );\n\t\t\t_gl.texParameteri( textureType, _gl.TEXTURE_MIN_FILTER, filterFallback( texture.minFilter ) );\n\n\t\t\tif ( texture.minFilter !== NearestFilter && texture.minFilter !== LinearFilter ) {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.' );\n\n\t\t\t}\n\n\t\t}\n\n\t\tconst extension = extensions.get( 'EXT_texture_filter_anisotropic' );\n\n\t\tif ( extension ) {\n\n\t\t\tif ( texture.type === FloatType && extensions.get( 'OES_texture_float_linear' ) === null ) return;\n\t\t\tif ( texture.type === HalfFloatType && ( isWebGL2 || extensions.get( 'OES_texture_half_float_linear' ) ) === null ) return;\n\n\t\t\tif ( texture.anisotropy > 1 || properties.get( texture ).__currentAnisotropy ) {\n\n\t\t\t\t_gl.texParameterf( textureType, extension.TEXTURE_MAX_ANISOTROPY_EXT, Math.min( texture.anisotropy, capabilities.getMaxAnisotropy() ) );\n\t\t\t\tproperties.get( texture ).__currentAnisotropy = texture.anisotropy;\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tfunction initTexture( textureProperties, texture ) {\n\n\t\tif ( textureProperties.__webglInit === undefined ) {\n\n\t\t\ttextureProperties.__webglInit = true;\n\n\t\t\ttexture.addEventListener( 'dispose', onTextureDispose );\n\n\t\t\ttextureProperties.__webglTexture = _gl.createTexture();\n\n\t\t\tinfo.memory.textures ++;\n\n\t\t}\n\n\t}\n\n\tfunction uploadTexture( textureProperties, texture, slot ) {\n\n\t\tlet textureType = _gl.TEXTURE_2D;\n\n\t\tif ( texture.isDataTexture2DArray ) textureType = _gl.TEXTURE_2D_ARRAY;\n\t\tif ( texture.isDataTexture3D ) textureType = _gl.TEXTURE_3D;\n\n\t\tinitTexture( textureProperties, texture );\n\n\t\tstate.activeTexture( _gl.TEXTURE0 + slot );\n\t\tstate.bindTexture( textureType, textureProperties.__webglTexture );\n\n\t\t_gl.pixelStorei( _gl.UNPACK_FLIP_Y_WEBGL, texture.flipY );\n\t\t_gl.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, texture.premultiplyAlpha );\n\t\t_gl.pixelStorei( _gl.UNPACK_ALIGNMENT, texture.unpackAlignment );\n\n\t\tconst needsPowerOfTwo = textureNeedsPowerOfTwo( texture ) && isPowerOfTwo( texture.image ) === false;\n\t\tconst image = resizeImage( texture.image, needsPowerOfTwo, false, maxTextureSize );\n\n\t\tconst supportsMips = isPowerOfTwo( image ) || isWebGL2,\n\t\t\tglFormat = utils.convert( texture.format );\n\n\t\tlet glType = utils.convert( texture.type ),\n\t\t\tglInternalFormat = getInternalFormat( texture.internalFormat, glFormat, glType );\n\n\t\tsetTextureParameters( textureType, texture, supportsMips );\n\n\t\tlet mipmap;\n\t\tconst mipmaps = texture.mipmaps;\n\n\t\tif ( texture.isDepthTexture ) {\n\n\t\t\t// populate depth texture with dummy data\n\n\t\t\tglInternalFormat = _gl.DEPTH_COMPONENT;\n\n\t\t\tif ( isWebGL2 ) {\n\n\t\t\t\tif ( texture.type === FloatType ) {\n\n\t\t\t\t\tglInternalFormat = _gl.DEPTH_COMPONENT32F;\n\n\t\t\t\t} else if ( texture.type === UnsignedIntType ) {\n\n\t\t\t\t\tglInternalFormat = _gl.DEPTH_COMPONENT24;\n\n\t\t\t\t} else if ( texture.type === UnsignedInt248Type ) {\n\n\t\t\t\t\tglInternalFormat = _gl.DEPTH24_STENCIL8;\n\n\t\t\t\t} else {\n\n\t\t\t\t\tglInternalFormat = _gl.DEPTH_COMPONENT16; // WebGL2 requires sized internalformat for glTexImage2D\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\tif ( texture.type === FloatType ) {\n\n\t\t\t\t\tconsole.error( 'WebGLRenderer: Floating point depth texture requires WebGL2.' );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t// validation checks for WebGL 1\n\n\t\t\tif ( texture.format === DepthFormat && glInternalFormat === _gl.DEPTH_COMPONENT ) {\n\n\t\t\t\t// The error INVALID_OPERATION is generated by texImage2D if format and internalformat are\n\t\t\t\t// DEPTH_COMPONENT and type is not UNSIGNED_SHORT or UNSIGNED_INT\n\t\t\t\t// (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/)\n\t\t\t\tif ( texture.type !== UnsignedShortType && texture.type !== UnsignedIntType ) {\n\n\t\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Use UnsignedShortType or UnsignedIntType for DepthFormat DepthTexture.' );\n\n\t\t\t\t\ttexture.type = UnsignedShortType;\n\t\t\t\t\tglType = utils.convert( texture.type );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif ( texture.format === DepthStencilFormat && glInternalFormat === _gl.DEPTH_COMPONENT ) {\n\n\t\t\t\t// Depth stencil textures need the DEPTH_STENCIL internal format\n\t\t\t\t// (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/)\n\t\t\t\tglInternalFormat = _gl.DEPTH_STENCIL;\n\n\t\t\t\t// The error INVALID_OPERATION is generated by texImage2D if format and internalformat are\n\t\t\t\t// DEPTH_STENCIL and type is not UNSIGNED_INT_24_8_WEBGL.\n\t\t\t\t// (https://www.khronos.org/registry/webgl/extensions/WEBGL_depth_texture/)\n\t\t\t\tif ( texture.type !== UnsignedInt248Type ) {\n\n\t\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Use UnsignedInt248Type for DepthStencilFormat DepthTexture.' );\n\n\t\t\t\t\ttexture.type = UnsignedInt248Type;\n\t\t\t\t\tglType = utils.convert( texture.type );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\t//\n\n\t\t\tstate.texImage2D( _gl.TEXTURE_2D, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, null );\n\n\t\t} else if ( texture.isDataTexture ) {\n\n\t\t\t// use manually created mipmaps if available\n\t\t\t// if there are no manual mipmaps\n\t\t\t// set 0 level mipmap and then use GL to generate other mipmap levels\n\n\t\t\tif ( mipmaps.length > 0 && supportsMips ) {\n\n\t\t\t\tfor ( let i = 0, il = mipmaps.length; i < il; i ++ ) {\n\n\t\t\t\t\tmipmap = mipmaps[ i ];\n\t\t\t\t\tstate.texImage2D( _gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data );\n\n\t\t\t\t}\n\n\t\t\t\ttexture.generateMipmaps = false;\n\t\t\t\ttextureProperties.__maxMipLevel = mipmaps.length - 1;\n\n\t\t\t} else {\n\n\t\t\t\tstate.texImage2D( _gl.TEXTURE_2D, 0, glInternalFormat, image.width, image.height, 0, glFormat, glType, image.data );\n\t\t\t\ttextureProperties.__maxMipLevel = 0;\n\n\t\t\t}\n\n\t\t} else if ( texture.isCompressedTexture ) {\n\n\t\t\tfor ( let i = 0, il = mipmaps.length; i < il; i ++ ) {\n\n\t\t\t\tmipmap = mipmaps[ i ];\n\n\t\t\t\tif ( texture.format !== RGBAFormat && texture.format !== RGBFormat ) {\n\n\t\t\t\t\tif ( glFormat !== null ) {\n\n\t\t\t\t\t\tstate.compressedTexImage2D( _gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, mipmap.data );\n\n\t\t\t\t\t} else {\n\n\t\t\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()' );\n\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\n\t\t\t\t\tstate.texImage2D( _gl.TEXTURE_2D, i, glInternalFormat, mipmap.width, mipmap.height, 0, glFormat, glType, mipmap.data );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\ttextureProperties.__maxMipLevel = mipmaps.length - 1;\n\n\t\t} else if ( texture.isDataTexture2DArray ) {\n\n\t\t\tstate.texImage3D( _gl.TEXTURE_2D_ARRAY, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data );\n\t\t\ttextureProperties.__maxMipLevel = 0;\n\n\t\t} else if ( texture.isDataTexture3D ) {\n\n\t\t\tstate.texImage3D( _gl.TEXTURE_3D, 0, glInternalFormat, image.width, image.height, image.depth, 0, glFormat, glType, image.data );\n\t\t\ttextureProperties.__maxMipLevel = 0;\n\n\t\t} else {\n\n\t\t\t// regular Texture (image, video, canvas)\n\n\t\t\t// use manually created mipmaps if available\n\t\t\t// if there are no manual mipmaps\n\t\t\t// set 0 level mipmap and then use GL to generate other mipmap levels\n\n\t\t\tif ( mipmaps.length > 0 && supportsMips ) {\n\n\t\t\t\tfor ( let i = 0, il = mipmaps.length; i < il; i ++ ) {\n\n\t\t\t\t\tmipmap = mipmaps[ i ];\n\t\t\t\t\tstate.texImage2D( _gl.TEXTURE_2D, i, glInternalFormat, glFormat, glType, mipmap );\n\n\t\t\t\t}\n\n\t\t\t\ttexture.generateMipmaps = false;\n\t\t\t\ttextureProperties.__maxMipLevel = mipmaps.length - 1;\n\n\t\t\t} else {\n\n\t\t\t\tstate.texImage2D( _gl.TEXTURE_2D, 0, glInternalFormat, glFormat, glType, image );\n\t\t\t\ttextureProperties.__maxMipLevel = 0;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) {\n\n\t\t\tgenerateMipmap( textureType, texture, image.width, image.height );\n\n\t\t}\n\n\t\ttextureProperties.__version = texture.version;\n\n\t\tif ( texture.onUpdate ) texture.onUpdate( texture );\n\n\t}\n\n\t// Render targets\n\n\t// Setup storage for target texture and bind it to correct framebuffer\n\tfunction setupFrameBufferTexture( framebuffer, renderTarget, attachment, textureTarget ) {\n\n\t\tconst glFormat = utils.convert( renderTarget.texture.format );\n\t\tconst glType = utils.convert( renderTarget.texture.type );\n\t\tconst glInternalFormat = getInternalFormat( renderTarget.texture.internalFormat, glFormat, glType );\n\t\tstate.texImage2D( textureTarget, 0, glInternalFormat, renderTarget.width, renderTarget.height, 0, glFormat, glType, null );\n\t\t_gl.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );\n\t\t_gl.framebufferTexture2D( _gl.FRAMEBUFFER, attachment, textureTarget, properties.get( renderTarget.texture ).__webglTexture, 0 );\n\t\t_gl.bindFramebuffer( _gl.FRAMEBUFFER, null );\n\n\t}\n\n\t// Setup storage for internal depth/stencil buffers and bind to correct framebuffer\n\tfunction setupRenderBufferStorage( renderbuffer, renderTarget, isMultisample ) {\n\n\t\t_gl.bindRenderbuffer( _gl.RENDERBUFFER, renderbuffer );\n\n\t\tif ( renderTarget.depthBuffer && ! renderTarget.stencilBuffer ) {\n\n\t\t\tlet glInternalFormat = _gl.DEPTH_COMPONENT16;\n\n\t\t\tif ( isMultisample ) {\n\n\t\t\t\tconst depthTexture = renderTarget.depthTexture;\n\n\t\t\t\tif ( depthTexture && depthTexture.isDepthTexture ) {\n\n\t\t\t\t\tif ( depthTexture.type === FloatType ) {\n\n\t\t\t\t\t\tglInternalFormat = _gl.DEPTH_COMPONENT32F;\n\n\t\t\t\t\t} else if ( depthTexture.type === UnsignedIntType ) {\n\n\t\t\t\t\t\tglInternalFormat = _gl.DEPTH_COMPONENT24;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tconst samples = getRenderTargetSamples( renderTarget );\n\n\t\t\t\t_gl.renderbufferStorageMultisample( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );\n\n\t\t\t} else {\n\n\t\t\t\t_gl.renderbufferStorage( _gl.RENDERBUFFER, glInternalFormat, renderTarget.width, renderTarget.height );\n\n\t\t\t}\n\n\t\t\t_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.RENDERBUFFER, renderbuffer );\n\n\t\t} else if ( renderTarget.depthBuffer && renderTarget.stencilBuffer ) {\n\n\t\t\tif ( isMultisample ) {\n\n\t\t\t\tconst samples = getRenderTargetSamples( renderTarget );\n\n\t\t\t\t_gl.renderbufferStorageMultisample( _gl.RENDERBUFFER, samples, _gl.DEPTH24_STENCIL8, renderTarget.width, renderTarget.height );\n\n\t\t\t} else {\n\n\t\t\t\t_gl.renderbufferStorage( _gl.RENDERBUFFER, _gl.DEPTH_STENCIL, renderTarget.width, renderTarget.height );\n\n\t\t\t}\n\n\n\t\t\t_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, _gl.RENDERBUFFER, renderbuffer );\n\n\t\t} else {\n\n\t\t\tconst glFormat = utils.convert( renderTarget.texture.format );\n\t\t\tconst glType = utils.convert( renderTarget.texture.type );\n\t\t\tconst glInternalFormat = getInternalFormat( renderTarget.texture.internalFormat, glFormat, glType );\n\n\t\t\tif ( isMultisample ) {\n\n\t\t\t\tconst samples = getRenderTargetSamples( renderTarget );\n\n\t\t\t\t_gl.renderbufferStorageMultisample( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );\n\n\t\t\t} else {\n\n\t\t\t\t_gl.renderbufferStorage( _gl.RENDERBUFFER, glInternalFormat, renderTarget.width, renderTarget.height );\n\n\t\t\t}\n\n\t\t}\n\n\t\t_gl.bindRenderbuffer( _gl.RENDERBUFFER, null );\n\n\t}\n\n\t// Setup resources for a Depth Texture for a FBO (needs an extension)\n\tfunction setupDepthTexture( framebuffer, renderTarget ) {\n\n\t\tconst isCube = ( renderTarget && renderTarget.isWebGLCubeRenderTarget );\n\t\tif ( isCube ) throw new Error( 'Depth Texture with cube render targets is not supported' );\n\n\t\t_gl.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );\n\n\t\tif ( ! ( renderTarget.depthTexture && renderTarget.depthTexture.isDepthTexture ) ) {\n\n\t\t\tthrow new Error( 'renderTarget.depthTexture must be an instance of THREE.DepthTexture' );\n\n\t\t}\n\n\t\t// upload an empty depth texture with framebuffer size\n\t\tif ( ! properties.get( renderTarget.depthTexture ).__webglTexture ||\n\t\t\t\trenderTarget.depthTexture.image.width !== renderTarget.width ||\n\t\t\t\trenderTarget.depthTexture.image.height !== renderTarget.height ) {\n\n\t\t\trenderTarget.depthTexture.image.width = renderTarget.width;\n\t\t\trenderTarget.depthTexture.image.height = renderTarget.height;\n\t\t\trenderTarget.depthTexture.needsUpdate = true;\n\n\t\t}\n\n\t\tsetTexture2D( renderTarget.depthTexture, 0 );\n\n\t\tconst webglDepthTexture = properties.get( renderTarget.depthTexture ).__webglTexture;\n\n\t\tif ( renderTarget.depthTexture.format === DepthFormat ) {\n\n\t\t\t_gl.framebufferTexture2D( _gl.FRAMEBUFFER, _gl.DEPTH_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0 );\n\n\t\t} else if ( renderTarget.depthTexture.format === DepthStencilFormat ) {\n\n\t\t\t_gl.framebufferTexture2D( _gl.FRAMEBUFFER, _gl.DEPTH_STENCIL_ATTACHMENT, _gl.TEXTURE_2D, webglDepthTexture, 0 );\n\n\t\t} else {\n\n\t\t\tthrow new Error( 'Unknown depthTexture format' );\n\n\t\t}\n\n\t}\n\n\t// Setup GL resources for a non-texture depth buffer\n\tfunction setupDepthRenderbuffer( renderTarget ) {\n\n\t\tconst renderTargetProperties = properties.get( renderTarget );\n\n\t\tconst isCube = ( renderTarget.isWebGLCubeRenderTarget === true );\n\n\t\tif ( renderTarget.depthTexture ) {\n\n\t\t\tif ( isCube ) throw new Error( 'target.depthTexture not supported in Cube render targets' );\n\n\t\t\tsetupDepthTexture( renderTargetProperties.__webglFramebuffer, renderTarget );\n\n\t\t} else {\n\n\t\t\tif ( isCube ) {\n\n\t\t\t\trenderTargetProperties.__webglDepthbuffer = [];\n\n\t\t\t\tfor ( let i = 0; i < 6; i ++ ) {\n\n\t\t\t\t\t_gl.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer[ i ] );\n\t\t\t\t\trenderTargetProperties.__webglDepthbuffer[ i ] = _gl.createRenderbuffer();\n\t\t\t\t\tsetupRenderBufferStorage( renderTargetProperties.__webglDepthbuffer[ i ], renderTarget, false );\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\t_gl.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer );\n\t\t\t\trenderTargetProperties.__webglDepthbuffer = _gl.createRenderbuffer();\n\t\t\t\tsetupRenderBufferStorage( renderTargetProperties.__webglDepthbuffer, renderTarget, false );\n\n\t\t\t}\n\n\t\t}\n\n\t\t_gl.bindFramebuffer( _gl.FRAMEBUFFER, null );\n\n\t}\n\n\t// Set up GL resources for the render target\n\tfunction setupRenderTarget( renderTarget ) {\n\n\t\tconst renderTargetProperties = properties.get( renderTarget );\n\t\tconst textureProperties = properties.get( renderTarget.texture );\n\n\t\trenderTarget.addEventListener( 'dispose', onRenderTargetDispose );\n\n\t\ttextureProperties.__webglTexture = _gl.createTexture();\n\n\t\tinfo.memory.textures ++;\n\n\t\tconst isCube = ( renderTarget.isWebGLCubeRenderTarget === true );\n\t\tconst isMultisample = ( renderTarget.isWebGLMultisampleRenderTarget === true );\n\t\tconst supportsMips = isPowerOfTwo( renderTarget ) || isWebGL2;\n\n\t\t// Handles WebGL2 RGBFormat fallback - #18858\n\n\t\tif ( isWebGL2 && renderTarget.texture.format === RGBFormat && ( renderTarget.texture.type === FloatType || renderTarget.texture.type === HalfFloatType ) ) {\n\n\t\t\trenderTarget.texture.format = RGBAFormat;\n\n\t\t\tconsole.warn( 'THREE.WebGLRenderer: Rendering to textures with RGB format is not supported. Using RGBA format instead.' );\n\n\t\t}\n\n\t\t// Setup framebuffer\n\n\t\tif ( isCube ) {\n\n\t\t\trenderTargetProperties.__webglFramebuffer = [];\n\n\t\t\tfor ( let i = 0; i < 6; i ++ ) {\n\n\t\t\t\trenderTargetProperties.__webglFramebuffer[ i ] = _gl.createFramebuffer();\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\trenderTargetProperties.__webglFramebuffer = _gl.createFramebuffer();\n\n\t\t\tif ( isMultisample ) {\n\n\t\t\t\tif ( isWebGL2 ) {\n\n\t\t\t\t\trenderTargetProperties.__webglMultisampledFramebuffer = _gl.createFramebuffer();\n\t\t\t\t\trenderTargetProperties.__webglColorRenderbuffer = _gl.createRenderbuffer();\n\n\t\t\t\t\t_gl.bindRenderbuffer( _gl.RENDERBUFFER, renderTargetProperties.__webglColorRenderbuffer );\n\n\t\t\t\t\tconst glFormat = utils.convert( renderTarget.texture.format );\n\t\t\t\t\tconst glType = utils.convert( renderTarget.texture.type );\n\t\t\t\t\tconst glInternalFormat = getInternalFormat( renderTarget.texture.internalFormat, glFormat, glType );\n\t\t\t\t\tconst samples = getRenderTargetSamples( renderTarget );\n\t\t\t\t\t_gl.renderbufferStorageMultisample( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );\n\n\t\t\t\t\t_gl.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer );\n\t\t\t\t\t_gl.framebufferRenderbuffer( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, _gl.RENDERBUFFER, renderTargetProperties.__webglColorRenderbuffer );\n\t\t\t\t\t_gl.bindRenderbuffer( _gl.RENDERBUFFER, null );\n\n\t\t\t\t\tif ( renderTarget.depthBuffer ) {\n\n\t\t\t\t\t\trenderTargetProperties.__webglDepthRenderbuffer = _gl.createRenderbuffer();\n\t\t\t\t\t\tsetupRenderBufferStorage( renderTargetProperties.__webglDepthRenderbuffer, renderTarget, true );\n\n\t\t\t\t\t}\n\n\t\t\t\t\t_gl.bindFramebuffer( _gl.FRAMEBUFFER, null );\n\n\n\t\t\t\t} else {\n\n\t\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.' );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\t// Setup color buffer\n\n\t\tif ( isCube ) {\n\n\t\t\tstate.bindTexture( _gl.TEXTURE_CUBE_MAP, textureProperties.__webglTexture );\n\t\t\tsetTextureParameters( _gl.TEXTURE_CUBE_MAP, renderTarget.texture, supportsMips );\n\n\t\t\tfor ( let i = 0; i < 6; i ++ ) {\n\n\t\t\t\tsetupFrameBufferTexture( renderTargetProperties.__webglFramebuffer[ i ], renderTarget, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_CUBE_MAP_POSITIVE_X + i );\n\n\t\t\t}\n\n\t\t\tif ( textureNeedsGenerateMipmaps( renderTarget.texture, supportsMips ) ) {\n\n\t\t\t\tgenerateMipmap( _gl.TEXTURE_CUBE_MAP, renderTarget.texture, renderTarget.width, renderTarget.height );\n\n\t\t\t}\n\n\t\t\tstate.bindTexture( _gl.TEXTURE_CUBE_MAP, null );\n\n\t\t} else {\n\n\t\t\tstate.bindTexture( _gl.TEXTURE_2D, textureProperties.__webglTexture );\n\t\t\tsetTextureParameters( _gl.TEXTURE_2D, renderTarget.texture, supportsMips );\n\t\t\tsetupFrameBufferTexture( renderTargetProperties.__webglFramebuffer, renderTarget, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_2D );\n\n\t\t\tif ( textureNeedsGenerateMipmaps( renderTarget.texture, supportsMips ) ) {\n\n\t\t\t\tgenerateMipmap( _gl.TEXTURE_2D, renderTarget.texture, renderTarget.width, renderTarget.height );\n\n\t\t\t}\n\n\t\t\tstate.bindTexture( _gl.TEXTURE_2D, null );\n\n\t\t}\n\n\t\t// Setup depth and stencil buffers\n\n\t\tif ( renderTarget.depthBuffer ) {\n\n\t\t\tsetupDepthRenderbuffer( renderTarget );\n\n\t\t}\n\n\t}\n\n\tfunction updateRenderTargetMipmap( renderTarget ) {\n\n\t\tconst texture = renderTarget.texture;\n\t\tconst supportsMips = isPowerOfTwo( renderTarget ) || isWebGL2;\n\n\t\tif ( textureNeedsGenerateMipmaps( texture, supportsMips ) ) {\n\n\t\t\tconst target = renderTarget.isWebGLCubeRenderTarget ? _gl.TEXTURE_CUBE_MAP : _gl.TEXTURE_2D;\n\t\t\tconst webglTexture = properties.get( texture ).__webglTexture;\n\n\t\t\tstate.bindTexture( target, webglTexture );\n\t\t\tgenerateMipmap( target, texture, renderTarget.width, renderTarget.height );\n\t\t\tstate.bindTexture( target, null );\n\n\t\t}\n\n\t}\n\n\tfunction updateMultisampleRenderTarget( renderTarget ) {\n\n\t\tif ( renderTarget.isWebGLMultisampleRenderTarget ) {\n\n\t\t\tif ( isWebGL2 ) {\n\n\t\t\t\tconst renderTargetProperties = properties.get( renderTarget );\n\n\t\t\t\t_gl.bindFramebuffer( _gl.READ_FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer );\n\t\t\t\t_gl.bindFramebuffer( _gl.DRAW_FRAMEBUFFER, renderTargetProperties.__webglFramebuffer );\n\n\t\t\t\tconst width = renderTarget.width;\n\t\t\t\tconst height = renderTarget.height;\n\t\t\t\tlet mask = _gl.COLOR_BUFFER_BIT;\n\n\t\t\t\tif ( renderTarget.depthBuffer ) mask |= _gl.DEPTH_BUFFER_BIT;\n\t\t\t\tif ( renderTarget.stencilBuffer ) mask |= _gl.STENCIL_BUFFER_BIT;\n\n\t\t\t\t_gl.blitFramebuffer( 0, 0, width, height, 0, 0, width, height, mask, _gl.NEAREST );\n\n\t\t\t\t_gl.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglMultisampledFramebuffer ); // see #18905\n\n\t\t\t} else {\n\n\t\t\t\tconsole.warn( 'THREE.WebGLRenderer: WebGLMultisampleRenderTarget can only be used with WebGL2.' );\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tfunction getRenderTargetSamples( renderTarget ) {\n\n\t\treturn ( isWebGL2 && renderTarget.isWebGLMultisampleRenderTarget ) ?\n\t\t\tMath.min( maxSamples, renderTarget.samples ) : 0;\n\n\t}\n\n\tfunction updateVideoTexture( texture ) {\n\n\t\tconst frame = info.render.frame;\n\n\t\t// Check the last frame we updated the VideoTexture\n\n\t\tif ( _videoTextures.get( texture ) !== frame ) {\n\n\t\t\t_videoTextures.set( texture, frame );\n\t\t\ttexture.update();\n\n\t\t}\n\n\t}\n\n\t// backwards compatibility\n\n\tlet warnedTexture2D = false;\n\tlet warnedTextureCube = false;\n\n\tfunction safeSetTexture2D( texture, slot ) {\n\n\t\tif ( texture && texture.isWebGLRenderTarget ) {\n\n\t\t\tif ( warnedTexture2D === false ) {\n\n\t\t\t\tconsole.warn( \"THREE.WebGLTextures.safeSetTexture2D: don't use render targets as textures. Use their .texture property instead.\" );\n\t\t\t\twarnedTexture2D = true;\n\n\t\t\t}\n\n\t\t\ttexture = texture.texture;\n\n\t\t}\n\n\t\tsetTexture2D( texture, slot );\n\n\t}\n\n\tfunction safeSetTextureCube( texture, slot ) {\n\n\t\tif ( texture && texture.isWebGLCubeRenderTarget ) {\n\n\t\t\tif ( warnedTextureCube === false ) {\n\n\t\t\t\tconsole.warn( \"THREE.WebGLTextures.safeSetTextureCube: don't use cube render targets as textures. Use their .texture property instead.\" );\n\t\t\t\twarnedTextureCube = true;\n\n\t\t\t}\n\n\t\t\ttexture = texture.texture;\n\n\t\t}\n\n\t\t// currently relying on the fact that WebGLCubeRenderTarget.texture is a Texture and NOT a CubeTexture\n\t\t// TODO: unify these code paths\n\t\tif ( ( texture && texture.isCubeTexture ) ||\n\t\t\t( Array.isArray( texture.image ) && texture.image.length === 6 ) ) {\n\n\t\t\t// CompressedTexture can have Array in image :/\n\n\t\t\t// this function alone should take care of cube textures\n\t\t\tsetTextureCube( texture, slot );\n\n\t\t} else {\n\n\t\t\t// assumed: texture property of THREE.WebGLCubeRenderTarget\n\t\t\tsetTextureCubeDynamic( texture, slot );\n\n\t\t}\n\n\t}\n\n\t//\n\n\tthis.allocateTextureUnit = allocateTextureUnit;\n\tthis.resetTextureUnits = resetTextureUnits;\n\n\tthis.setTexture2D = setTexture2D;\n\tthis.setTexture2DArray = setTexture2DArray;\n\tthis.setTexture3D = setTexture3D;\n\tthis.setTextureCube = setTextureCube;\n\tthis.setTextureCubeDynamic = setTextureCubeDynamic;\n\tthis.setupRenderTarget = setupRenderTarget;\n\tthis.updateRenderTargetMipmap = updateRenderTargetMipmap;\n\tthis.updateMultisampleRenderTarget = updateMultisampleRenderTarget;\n\n\tthis.safeSetTexture2D = safeSetTexture2D;\n\tthis.safeSetTextureCube = safeSetTextureCube;\n\n}\n\nexport { WebGLTextures };\n","/**\n * @author thespite / http://www.twitter.com/thespite\n */\n\nimport { RGBA_ASTC_4x4_Format, RGBA_ASTC_5x4_Format, RGBA_ASTC_5x5_Format, RGBA_ASTC_6x5_Format, RGBA_ASTC_6x6_Format, RGBA_ASTC_8x5_Format, RGBA_ASTC_8x6_Format, RGBA_ASTC_8x8_Format, RGBA_ASTC_10x5_Format, RGBA_ASTC_10x6_Format, RGBA_ASTC_10x8_Format, RGBA_ASTC_10x10_Format, RGBA_ASTC_12x10_Format, RGBA_ASTC_12x12_Format, RGB_ETC1_Format, RGB_ETC2_Format, RGBA_ETC2_EAC_Format, RGBA_PVRTC_2BPPV1_Format, RGBA_PVRTC_4BPPV1_Format, RGB_PVRTC_2BPPV1_Format, RGB_PVRTC_4BPPV1_Format, RGBA_S3TC_DXT5_Format, RGBA_S3TC_DXT3_Format, RGBA_S3TC_DXT1_Format, RGB_S3TC_DXT1_Format, DepthFormat, DepthStencilFormat, LuminanceAlphaFormat, LuminanceFormat, RedFormat, RGBAFormat, RGBFormat, AlphaFormat, RedIntegerFormat, RGFormat, RGIntegerFormat, RGBIntegerFormat, RGBAIntegerFormat, HalfFloatType, FloatType, UnsignedIntType, IntType, UnsignedShortType, ShortType, ByteType, UnsignedInt248Type, UnsignedShort565Type, UnsignedShort5551Type, UnsignedShort4444Type, UnsignedByteType, SRGB8_ALPHA8_ASTC_4x4_Format, SRGB8_ALPHA8_ASTC_5x4_Format, SRGB8_ALPHA8_ASTC_5x5_Format, SRGB8_ALPHA8_ASTC_6x5_Format, SRGB8_ALPHA8_ASTC_6x6_Format, SRGB8_ALPHA8_ASTC_8x5_Format, SRGB8_ALPHA8_ASTC_8x6_Format, SRGB8_ALPHA8_ASTC_8x8_Format, SRGB8_ALPHA8_ASTC_10x5_Format, SRGB8_ALPHA8_ASTC_10x6_Format, SRGB8_ALPHA8_ASTC_10x8_Format, SRGB8_ALPHA8_ASTC_10x10_Format, SRGB8_ALPHA8_ASTC_12x10_Format, SRGB8_ALPHA8_ASTC_12x12_Format, RGBA_BPTC_Format } from '../../constants.js';\n\nfunction WebGLUtils( gl, extensions, capabilities ) {\n\n\tconst isWebGL2 = capabilities.isWebGL2;\n\n\tfunction convert( p ) {\n\n\t\tlet extension;\n\n\t\tif ( p === UnsignedByteType ) return gl.UNSIGNED_BYTE;\n\t\tif ( p === UnsignedShort4444Type ) return gl.UNSIGNED_SHORT_4_4_4_4;\n\t\tif ( p === UnsignedShort5551Type ) return gl.UNSIGNED_SHORT_5_5_5_1;\n\t\tif ( p === UnsignedShort565Type ) return gl.UNSIGNED_SHORT_5_6_5;\n\n\t\tif ( p === ByteType ) return gl.BYTE;\n\t\tif ( p === ShortType ) return gl.SHORT;\n\t\tif ( p === UnsignedShortType ) return gl.UNSIGNED_SHORT;\n\t\tif ( p === IntType ) return gl.INT;\n\t\tif ( p === UnsignedIntType ) return gl.UNSIGNED_INT;\n\t\tif ( p === FloatType ) return gl.FLOAT;\n\n\t\tif ( p === HalfFloatType ) {\n\n\t\t\tif ( isWebGL2 ) return gl.HALF_FLOAT;\n\n\t\t\textension = extensions.get( 'OES_texture_half_float' );\n\n\t\t\tif ( extension !== null ) {\n\n\t\t\t\treturn extension.HALF_FLOAT_OES;\n\n\t\t\t} else {\n\n\t\t\t\treturn null;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( p === AlphaFormat ) return gl.ALPHA;\n\t\tif ( p === RGBFormat ) return gl.RGB;\n\t\tif ( p === RGBAFormat ) return gl.RGBA;\n\t\tif ( p === LuminanceFormat ) return gl.LUMINANCE;\n\t\tif ( p === LuminanceAlphaFormat ) return gl.LUMINANCE_ALPHA;\n\t\tif ( p === DepthFormat ) return gl.DEPTH_COMPONENT;\n\t\tif ( p === DepthStencilFormat ) return gl.DEPTH_STENCIL;\n\t\tif ( p === RedFormat ) return gl.RED;\n\n\t\t// WebGL2 formats.\n\n\t\tif ( p === RedIntegerFormat ) return gl.RED_INTEGER;\n\t\tif ( p === RGFormat ) return gl.RG;\n\t\tif ( p === RGIntegerFormat ) return gl.RG_INTEGER;\n\t\tif ( p === RGBIntegerFormat ) return gl.RGB_INTEGER;\n\t\tif ( p === RGBAIntegerFormat ) return gl.RGBA_INTEGER;\n\n\t\tif ( p === RGB_S3TC_DXT1_Format || p === RGBA_S3TC_DXT1_Format ||\n\t\t\tp === RGBA_S3TC_DXT3_Format || p === RGBA_S3TC_DXT5_Format ) {\n\n\t\t\textension = extensions.get( 'WEBGL_compressed_texture_s3tc' );\n\n\t\t\tif ( extension !== null ) {\n\n\t\t\t\tif ( p === RGB_S3TC_DXT1_Format ) return extension.COMPRESSED_RGB_S3TC_DXT1_EXT;\n\t\t\t\tif ( p === RGBA_S3TC_DXT1_Format ) return extension.COMPRESSED_RGBA_S3TC_DXT1_EXT;\n\t\t\t\tif ( p === RGBA_S3TC_DXT3_Format ) return extension.COMPRESSED_RGBA_S3TC_DXT3_EXT;\n\t\t\t\tif ( p === RGBA_S3TC_DXT5_Format ) return extension.COMPRESSED_RGBA_S3TC_DXT5_EXT;\n\n\t\t\t} else {\n\n\t\t\t\treturn null;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( p === RGB_PVRTC_4BPPV1_Format || p === RGB_PVRTC_2BPPV1_Format ||\n\t\t\tp === RGBA_PVRTC_4BPPV1_Format || p === RGBA_PVRTC_2BPPV1_Format ) {\n\n\t\t\textension = extensions.get( 'WEBGL_compressed_texture_pvrtc' );\n\n\t\t\tif ( extension !== null ) {\n\n\t\t\t\tif ( p === RGB_PVRTC_4BPPV1_Format ) return extension.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;\n\t\t\t\tif ( p === RGB_PVRTC_2BPPV1_Format ) return extension.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;\n\t\t\t\tif ( p === RGBA_PVRTC_4BPPV1_Format ) return extension.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;\n\t\t\t\tif ( p === RGBA_PVRTC_2BPPV1_Format ) return extension.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG;\n\n\t\t\t} else {\n\n\t\t\t\treturn null;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( p === RGB_ETC1_Format ) {\n\n\t\t\textension = extensions.get( 'WEBGL_compressed_texture_etc1' );\n\n\t\t\tif ( extension !== null ) {\n\n\t\t\t\treturn extension.COMPRESSED_RGB_ETC1_WEBGL;\n\n\t\t\t} else {\n\n\t\t\t\treturn null;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( p === RGB_ETC2_Format || p === RGBA_ETC2_EAC_Format ) {\n\n\t\t\textension = extensions.get( 'WEBGL_compressed_texture_etc' );\n\n\t\t\tif ( extension !== null ) {\n\n\t\t\t\tif ( p === RGB_ETC2_Format ) return extension.COMPRESSED_RGB8_ETC2;\n\t\t\t\tif ( p === RGBA_ETC2_EAC_Format ) return extension.COMPRESSED_RGBA8_ETC2_EAC;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( p === RGBA_ASTC_4x4_Format || p === RGBA_ASTC_5x4_Format || p === RGBA_ASTC_5x5_Format ||\n\t\t\tp === RGBA_ASTC_6x5_Format || p === RGBA_ASTC_6x6_Format || p === RGBA_ASTC_8x5_Format ||\n\t\t\tp === RGBA_ASTC_8x6_Format || p === RGBA_ASTC_8x8_Format || p === RGBA_ASTC_10x5_Format ||\n\t\t\tp === RGBA_ASTC_10x6_Format || p === RGBA_ASTC_10x8_Format || p === RGBA_ASTC_10x10_Format ||\n\t\t\tp === RGBA_ASTC_12x10_Format || p === RGBA_ASTC_12x12_Format ||\n\t\t\tp === SRGB8_ALPHA8_ASTC_4x4_Format || p === SRGB8_ALPHA8_ASTC_5x4_Format || p === SRGB8_ALPHA8_ASTC_5x5_Format ||\n\t\t\tp === SRGB8_ALPHA8_ASTC_6x5_Format || p === SRGB8_ALPHA8_ASTC_6x6_Format || p === SRGB8_ALPHA8_ASTC_8x5_Format ||\n\t\t\tp === SRGB8_ALPHA8_ASTC_8x6_Format || p === SRGB8_ALPHA8_ASTC_8x8_Format || p === SRGB8_ALPHA8_ASTC_10x5_Format ||\n\t\t\tp === SRGB8_ALPHA8_ASTC_10x6_Format || p === SRGB8_ALPHA8_ASTC_10x8_Format || p === SRGB8_ALPHA8_ASTC_10x10_Format ||\n\t\t\tp === SRGB8_ALPHA8_ASTC_12x10_Format || p === SRGB8_ALPHA8_ASTC_12x12_Format ) {\n\n\t\t\textension = extensions.get( 'WEBGL_compressed_texture_astc' );\n\n\t\t\tif ( extension !== null ) {\n\n\t\t\t\t// TODO Complete?\n\n\t\t\t\treturn p;\n\n\t\t\t} else {\n\n\t\t\t\treturn null;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( p === RGBA_BPTC_Format ) {\n\n\t\t\textension = extensions.get( 'EXT_texture_compression_bptc' );\n\n\t\t\tif ( extension !== null ) {\n\n\t\t\t\t// TODO Complete?\n\n\t\t\t\treturn p;\n\n\t\t\t} else {\n\n\t\t\t\treturn null;\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( p === UnsignedInt248Type ) {\n\n\t\t\tif ( isWebGL2 ) return gl.UNSIGNED_INT_24_8;\n\n\t\t\textension = extensions.get( 'WEBGL_depth_texture' );\n\n\t\t\tif ( extension !== null ) {\n\n\t\t\t\treturn extension.UNSIGNED_INT_24_8_WEBGL;\n\n\t\t\t} else {\n\n\t\t\t\treturn null;\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\treturn { convert: convert };\n\n}\n\n\nexport { WebGLUtils };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { PerspectiveCamera } from './PerspectiveCamera.js';\n\nfunction ArrayCamera( array ) {\n\n\tPerspectiveCamera.call( this );\n\n\tthis.cameras = array || [];\n\n}\n\nArrayCamera.prototype = Object.assign( Object.create( PerspectiveCamera.prototype ), {\n\n\tconstructor: ArrayCamera,\n\n\tisArrayCamera: true\n\n} );\n\n\nexport { ArrayCamera };\n","import { Object3D } from '../core/Object3D.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction Group() {\n\n\tObject3D.call( this );\n\n\tthis.type = 'Group';\n\n}\n\nGroup.prototype = Object.assign( Object.create( Object3D.prototype ), {\n\n\tconstructor: Group,\n\n\tisGroup: true\n\n} );\n\n\nexport { Group };\n","import { Group } from '../../objects/Group.js';\n\n/**\n * @author Mugen87 / https://github.com/Mugen87\n */\n\nfunction WebXRController() {\n\n\tthis._targetRay = null;\n\tthis._grip = null;\n\n}\n\nObject.assign( WebXRController.prototype, {\n\n\tconstructor: WebXRController,\n\n\tgetTargetRaySpace: function () {\n\n\t\tif ( this._targetRay === null ) {\n\n\t\t\tthis._targetRay = new Group();\n\t\t\tthis._targetRay.matrixAutoUpdate = false;\n\t\t\tthis._targetRay.visible = false;\n\n\t\t}\n\n\t\treturn this._targetRay;\n\n\t},\n\n\tgetGripSpace: function () {\n\n\t\tif ( this._grip === null ) {\n\n\t\t\tthis._grip = new Group();\n\t\t\tthis._grip.matrixAutoUpdate = false;\n\t\t\tthis._grip.visible = false;\n\n\t\t}\n\n\t\treturn this._grip;\n\n\t},\n\n\tdispatchEvent: function ( event ) {\n\n\t\tif ( this._targetRay !== null ) {\n\n\t\t\tthis._targetRay.dispatchEvent( event );\n\n\t\t}\n\n\t\tif ( this._grip !== null ) {\n\n\t\t\tthis._grip.dispatchEvent( event );\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tdisconnect: function ( inputSource ) {\n\n\t\tthis.dispatchEvent( { type: 'disconnected', data: inputSource } );\n\n\t\tif ( this._targetRay !== null ) {\n\n\t\t\tthis._targetRay.visible = false;\n\n\t\t}\n\n\t\tif ( this._grip !== null ) {\n\n\t\t\tthis._grip.visible = false;\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\tupdate: function ( inputSource, frame, referenceSpace ) {\n\n\t\tlet inputPose = null;\n\t\tlet gripPose = null;\n\n\t\tconst targetRay = this._targetRay;\n\t\tconst grip = this._grip;\n\n\t\tif ( inputSource ) {\n\n\t\t\tif ( targetRay !== null ) {\n\n\t\t\t\tinputPose = frame.getPose( inputSource.targetRaySpace, referenceSpace );\n\n\t\t\t\tif ( inputPose !== null ) {\n\n\t\t\t\t\ttargetRay.matrix.fromArray( inputPose.transform.matrix );\n\t\t\t\t\ttargetRay.matrix.decompose( targetRay.position, targetRay.rotation, targetRay.scale );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif ( grip !== null && inputSource.gripSpace ) {\n\n\t\t\t\tgripPose = frame.getPose( inputSource.gripSpace, referenceSpace );\n\n\t\t\t\tif ( gripPose !== null ) {\n\n\t\t\t\t\tgrip.matrix.fromArray( gripPose.transform.matrix );\n\t\t\t\t\tgrip.matrix.decompose( grip.position, grip.rotation, grip.scale );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( targetRay !== null ) {\n\n\t\t\ttargetRay.visible = ( inputPose !== null );\n\n\t\t}\n\n\t\tif ( grip !== null ) {\n\n\t\t\tgrip.visible = ( gripPose !== null );\n\n\t\t}\n\n\t\treturn this;\n\n\t}\n\n} );\n\n\nexport { WebXRController };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { ArrayCamera } from '../../cameras/ArrayCamera.js';\nimport { EventDispatcher } from '../../core/EventDispatcher.js';\nimport { PerspectiveCamera } from '../../cameras/PerspectiveCamera.js';\nimport { Vector3 } from '../../math/Vector3.js';\nimport { Vector4 } from '../../math/Vector4.js';\nimport { WebGLAnimation } from '../webgl/WebGLAnimation.js';\nimport { WebXRController } from './WebXRController.js';\n\nfunction WebXRManager( renderer, gl ) {\n\n\tconst scope = this;\n\n\tlet session = null;\n\n\tlet framebufferScaleFactor = 1.0;\n\n\tlet referenceSpace = null;\n\tlet referenceSpaceType = 'local-floor';\n\n\tlet pose = null;\n\n\tconst controllers = [];\n\tconst inputSourcesMap = new Map();\n\n\t//\n\n\tconst cameraL = new PerspectiveCamera();\n\tcameraL.layers.enable( 1 );\n\tcameraL.viewport = new Vector4();\n\n\tconst cameraR = new PerspectiveCamera();\n\tcameraR.layers.enable( 2 );\n\tcameraR.viewport = new Vector4();\n\n\tconst cameras = [ cameraL, cameraR ];\n\n\tconst cameraVR = new ArrayCamera();\n\tcameraVR.layers.enable( 1 );\n\tcameraVR.layers.enable( 2 );\n\n\tlet _currentDepthNear = null;\n\tlet _currentDepthFar = null;\n\n\t//\n\n\tthis.enabled = false;\n\n\tthis.isPresenting = false;\n\n\tthis.getController = function ( index ) {\n\n\t\tlet controller = controllers[ index ];\n\n\t\tif ( controller === undefined ) {\n\n\t\t\tcontroller = new WebXRController();\n\t\t\tcontrollers[ index ] = controller;\n\n\t\t}\n\n\t\treturn controller.getTargetRaySpace();\n\n\t};\n\n\tthis.getControllerGrip = function ( index ) {\n\n\t\tlet controller = controllers[ index ];\n\n\t\tif ( controller === undefined ) {\n\n\t\t\tcontroller = new WebXRController();\n\t\t\tcontrollers[ index ] = controller;\n\n\t\t}\n\n\t\treturn controller.getGripSpace();\n\n\t};\n\n\t//\n\n\tfunction onSessionEvent( event ) {\n\n\t\tconst controller = inputSourcesMap.get( event.inputSource );\n\n\t\tif ( controller ) {\n\n\t\t\tcontroller.dispatchEvent( { type: event.type } );\n\n\t\t}\n\n\t}\n\n\tfunction onSessionEnd() {\n\n\t\tinputSourcesMap.forEach( function ( controller, inputSource ) {\n\n\t\t\tcontroller.disconnect( inputSource );\n\n\t\t} );\n\n\t\tinputSourcesMap.clear();\n\n\t\t//\n\n\t\trenderer.setFramebuffer( null );\n\t\trenderer.setRenderTarget( renderer.getRenderTarget() ); // Hack #15830\n\t\tanimation.stop();\n\n\t\tscope.isPresenting = false;\n\n\t\tscope.dispatchEvent( { type: 'sessionend' } );\n\n\t}\n\n\tfunction onRequestReferenceSpace( value ) {\n\n\t\treferenceSpace = value;\n\n\t\tanimation.setContext( session );\n\t\tanimation.start();\n\n\t\tscope.isPresenting = true;\n\n\t\tscope.dispatchEvent( { type: 'sessionstart' } );\n\n\t}\n\n\tthis.setFramebufferScaleFactor = function ( value ) {\n\n\t\tframebufferScaleFactor = value;\n\n\t\tif ( scope.isPresenting === true ) {\n\n\t\t\tconsole.warn( 'THREE.WebXRManager: Cannot change framebuffer scale while presenting.' );\n\n\t\t}\n\n\t};\n\n\tthis.setReferenceSpaceType = function ( value ) {\n\n\t\treferenceSpaceType = value;\n\n\t\tif ( scope.isPresenting === true ) {\n\n\t\t\tconsole.warn( 'THREE.WebXRManager: Cannot change reference space type while presenting.' );\n\n\t\t}\n\n\t};\n\n\tthis.getReferenceSpace = function () {\n\n\t\treturn referenceSpace;\n\n\t};\n\n\tthis.getSession = function () {\n\n\t\treturn session;\n\n\t};\n\n\tthis.setSession = function ( value ) {\n\n\t\tsession = value;\n\n\t\tif ( session !== null ) {\n\n\t\t\tsession.addEventListener( 'select', onSessionEvent );\n\t\t\tsession.addEventListener( 'selectstart', onSessionEvent );\n\t\t\tsession.addEventListener( 'selectend', onSessionEvent );\n\t\t\tsession.addEventListener( 'squeeze', onSessionEvent );\n\t\t\tsession.addEventListener( 'squeezestart', onSessionEvent );\n\t\t\tsession.addEventListener( 'squeezeend', onSessionEvent );\n\t\t\tsession.addEventListener( 'end', onSessionEnd );\n\n\t\t\tconst attributes = gl.getContextAttributes();\n\n\t\t\tif ( attributes.xrCompatible !== true ) {\n\n\t\t\t\tgl.makeXRCompatible();\n\n\t\t\t}\n\n\t\t\tconst layerInit = {\n\t\t\t\tantialias: attributes.antialias,\n\t\t\t\talpha: attributes.alpha,\n\t\t\t\tdepth: attributes.depth,\n\t\t\t\tstencil: attributes.stencil,\n\t\t\t\tframebufferScaleFactor: framebufferScaleFactor\n\t\t\t};\n\n\t\t\t// eslint-disable-next-line no-undef\n\t\t\tconst baseLayer = new XRWebGLLayer( session, gl, layerInit );\n\n\t\t\tsession.updateRenderState( { baseLayer: baseLayer } );\n\n\t\t\tsession.requestReferenceSpace( referenceSpaceType ).then( onRequestReferenceSpace );\n\n\t\t\t//\n\n\t\t\tsession.addEventListener( 'inputsourceschange', updateInputSources );\n\n\t\t}\n\n\t};\n\n\tfunction updateInputSources( event ) {\n\n\t\tconst inputSources = session.inputSources;\n\n\t\t// Assign inputSources to available controllers\n\n\t\tfor ( let i = 0; i < controllers.length; i ++ ) {\n\n\t\t\tinputSourcesMap.set( inputSources[ i ], controllers[ i ] );\n\n\t\t}\n\n\t\t// Notify disconnected\n\n\t\tfor ( let i = 0; i < event.removed.length; i ++ ) {\n\n\t\t\tconst inputSource = event.removed[ i ];\n\t\t\tconst controller = inputSourcesMap.get( inputSource );\n\n\t\t\tif ( controller ) {\n\n\t\t\t\tcontroller.dispatchEvent( { type: 'disconnected', data: inputSource } );\n\t\t\t\tinputSourcesMap.delete( inputSource );\n\n\t\t\t}\n\n\t\t}\n\n\t\t// Notify connected\n\n\t\tfor ( let i = 0; i < event.added.length; i ++ ) {\n\n\t\t\tconst inputSource = event.added[ i ];\n\t\t\tconst controller = inputSourcesMap.get( inputSource );\n\n\t\t\tif ( controller ) {\n\n\t\t\t\tcontroller.dispatchEvent( { type: 'connected', data: inputSource } );\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\t//\n\n\tconst cameraLPos = new Vector3();\n\tconst cameraRPos = new Vector3();\n\n\t/**\n\t * @author jsantell / https://www.jsantell.com/\n\t *\n\t * Assumes 2 cameras that are parallel and share an X-axis, and that\n\t * the cameras' projection and world matrices have already been set.\n\t * And that near and far planes are identical for both cameras.\n\t * Visualization of this technique: https://computergraphics.stackexchange.com/a/4765\n\t */\n\tfunction setProjectionFromUnion( camera, cameraL, cameraR ) {\n\n\t\tcameraLPos.setFromMatrixPosition( cameraL.matrixWorld );\n\t\tcameraRPos.setFromMatrixPosition( cameraR.matrixWorld );\n\n\t\tconst ipd = cameraLPos.distanceTo( cameraRPos );\n\n\t\tconst projL = cameraL.projectionMatrix.elements;\n\t\tconst projR = cameraR.projectionMatrix.elements;\n\n\t\t// VR systems will have identical far and near planes, and\n\t\t// most likely identical top and bottom frustum extents.\n\t\t// Use the left camera for these values.\n\t\tconst near = projL[ 14 ] / ( projL[ 10 ] - 1 );\n\t\tconst far = projL[ 14 ] / ( projL[ 10 ] + 1 );\n\t\tconst topFov = ( projL[ 9 ] + 1 ) / projL[ 5 ];\n\t\tconst bottomFov = ( projL[ 9 ] - 1 ) / projL[ 5 ];\n\n\t\tconst leftFov = ( projL[ 8 ] - 1 ) / projL[ 0 ];\n\t\tconst rightFov = ( projR[ 8 ] + 1 ) / projR[ 0 ];\n\t\tconst left = near * leftFov;\n\t\tconst right = near * rightFov;\n\n\t\t// Calculate the new camera's position offset from the\n\t\t// left camera. xOffset should be roughly half `ipd`.\n\t\tconst zOffset = ipd / ( - leftFov + rightFov );\n\t\tconst xOffset = zOffset * - leftFov;\n\n\t\t// TODO: Better way to apply this offset?\n\t\tcameraL.matrixWorld.decompose( camera.position, camera.quaternion, camera.scale );\n\t\tcamera.translateX( xOffset );\n\t\tcamera.translateZ( zOffset );\n\t\tcamera.matrixWorld.compose( camera.position, camera.quaternion, camera.scale );\n\t\tcamera.matrixWorldInverse.getInverse( camera.matrixWorld );\n\n\t\t// Find the union of the frustum values of the cameras and scale\n\t\t// the values so that the near plane's position does not change in world space,\n\t\t// although must now be relative to the new union camera.\n\t\tconst near2 = near + zOffset;\n\t\tconst far2 = far + zOffset;\n\t\tconst left2 = left - xOffset;\n\t\tconst right2 = right + ( ipd - xOffset );\n\t\tconst top2 = topFov * far / far2 * near2;\n\t\tconst bottom2 = bottomFov * far / far2 * near2;\n\n\t\tcamera.projectionMatrix.makePerspective( left2, right2, top2, bottom2, near2, far2 );\n\n\t}\n\n\tfunction updateCamera( camera, parent ) {\n\n\t\tif ( parent === null ) {\n\n\t\t\tcamera.matrixWorld.copy( camera.matrix );\n\n\t\t} else {\n\n\t\t\tcamera.matrixWorld.multiplyMatrices( parent.matrixWorld, camera.matrix );\n\n\t\t}\n\n\t\tcamera.matrixWorldInverse.getInverse( camera.matrixWorld );\n\n\t}\n\n\tthis.getCamera = function ( camera ) {\n\n\t\tcameraVR.near = cameraR.near = cameraL.near = camera.near;\n\t\tcameraVR.far = cameraR.far = cameraL.far = camera.far;\n\n\t\tif ( _currentDepthNear !== cameraVR.near || _currentDepthFar !== cameraVR.far ) {\n\n\t\t\t// Note that the new renderState won't apply until the next frame. See #18320\n\n\t\t\tsession.updateRenderState( {\n\t\t\t\tdepthNear: cameraVR.near,\n\t\t\t\tdepthFar: cameraVR.far\n\t\t\t} );\n\n\t\t\t_currentDepthNear = cameraVR.near;\n\t\t\t_currentDepthFar = cameraVR.far;\n\n\t\t}\n\n\t\tconst parent = camera.parent;\n\t\tconst cameras = cameraVR.cameras;\n\n\t\tupdateCamera( cameraVR, parent );\n\n\t\tfor ( let i = 0; i < cameras.length; i ++ ) {\n\n\t\t\tupdateCamera( cameras[ i ], parent );\n\n\t\t}\n\n\t\t// update camera and its children\n\n\t\tcamera.matrixWorld.copy( cameraVR.matrixWorld );\n\n\t\tconst children = camera.children;\n\n\t\tfor ( let i = 0, l = children.length; i < l; i ++ ) {\n\n\t\t\tchildren[ i ].updateMatrixWorld( true );\n\n\t\t}\n\n\t\t// update projection matrix for proper view frustum culling\n\n\t\tif ( cameras.length === 2 ) {\n\n\t\t\tsetProjectionFromUnion( cameraVR, cameraL, cameraR );\n\n\t\t} else {\n\n\t\t\t// assume single camera setup (AR)\n\n\t\t\tcameraVR.projectionMatrix.copy( cameraL.projectionMatrix );\n\n\t\t}\n\n\t\treturn cameraVR;\n\n\t};\n\n\t// Animation Loop\n\n\tlet onAnimationFrameCallback = null;\n\n\tfunction onAnimationFrame( time, frame ) {\n\n\t\tpose = frame.getViewerPose( referenceSpace );\n\n\t\tif ( pose !== null ) {\n\n\t\t\tconst views = pose.views;\n\t\t\tconst baseLayer = session.renderState.baseLayer;\n\n\t\t\trenderer.setFramebuffer( baseLayer.framebuffer );\n\n\t\t\tlet cameraVRNeedsUpdate = false;\n\n\t\t\t// check if it's necessary to rebuild cameraVR's camera list\n\n\t\t\tif ( views.length !== cameraVR.cameras.length ) {\n\n\t\t\t\tcameraVR.cameras.length = 0;\n\t\t\t\tcameraVRNeedsUpdate = true;\n\n\t\t\t}\n\n\t\t\tfor ( let i = 0; i < views.length; i ++ ) {\n\n\t\t\t\tconst view = views[ i ];\n\t\t\t\tconst viewport = baseLayer.getViewport( view );\n\n\t\t\t\tconst camera = cameras[ i ];\n\t\t\t\tcamera.matrix.fromArray( view.transform.matrix );\n\t\t\t\tcamera.projectionMatrix.fromArray( view.projectionMatrix );\n\t\t\t\tcamera.viewport.set( viewport.x, viewport.y, viewport.width, viewport.height );\n\n\t\t\t\tif ( i === 0 ) {\n\n\t\t\t\t\tcameraVR.matrix.copy( camera.matrix );\n\n\t\t\t\t}\n\n\t\t\t\tif ( cameraVRNeedsUpdate === true ) {\n\n\t\t\t\t\tcameraVR.cameras.push( camera );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\t//\n\n\t\tconst inputSources = session.inputSources;\n\n\t\tfor ( let i = 0; i < controllers.length; i ++ ) {\n\n\t\t\tconst controller = controllers[ i ];\n\t\t\tconst inputSource = inputSources[ i ];\n\n\t\t\tcontroller.update( inputSource, frame, referenceSpace );\n\n\t\t}\n\n\t\tif ( onAnimationFrameCallback ) onAnimationFrameCallback( time, frame );\n\n\t}\n\n\tconst animation = new WebGLAnimation();\n\tanimation.setAnimationLoop( onAnimationFrame );\n\n\tthis.setAnimationLoop = function ( callback ) {\n\n\t\tonAnimationFrameCallback = callback;\n\n\t};\n\n\tthis.dispose = function () {};\n\n}\n\nObject.assign( WebXRManager.prototype, EventDispatcher.prototype );\n\nexport { WebXRManager };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { BackSide } from \"../../constants.js\";\n\nfunction WebGLMaterials( properties ) {\n\n\tfunction refreshFogUniforms( uniforms, fog ) {\n\n\t\tuniforms.fogColor.value.copy( fog.color );\n\n\t\tif ( fog.isFog ) {\n\n\t\t\tuniforms.fogNear.value = fog.near;\n\t\t\tuniforms.fogFar.value = fog.far;\n\n\t\t} else if ( fog.isFogExp2 ) {\n\n\t\t\tuniforms.fogDensity.value = fog.density;\n\n\t\t}\n\n\t}\n\n\tfunction refreshMaterialUniforms( uniforms, material, environment, pixelRatio, height ) {\n\n\t\tif ( material.isMeshBasicMaterial ) {\n\n\t\t\trefreshUniformsCommon( uniforms, material );\n\n\t\t} else if ( material.isMeshLambertMaterial ) {\n\n\t\t\trefreshUniformsCommon( uniforms, material );\n\t\t\trefreshUniformsLambert( uniforms, material );\n\n\t\t} else if ( material.isMeshToonMaterial ) {\n\n\t\t\trefreshUniformsCommon( uniforms, material );\n\t\t\trefreshUniformsToon( uniforms, material );\n\n\t\t} else if ( material.isMeshPhongMaterial ) {\n\n\t\t\trefreshUniformsCommon( uniforms, material );\n\t\t\trefreshUniformsPhong( uniforms, material );\n\n\t\t} else if ( material.isMeshStandardMaterial ) {\n\n\t\t\trefreshUniformsCommon( uniforms, material, environment );\n\n\t\t\tif ( material.isMeshPhysicalMaterial ) {\n\n\t\t\t\trefreshUniformsPhysical( uniforms, material, environment );\n\n\t\t\t} else {\n\n\t\t\t\trefreshUniformsStandard( uniforms, material, environment );\n\n\t\t\t}\n\n\t\t} else if ( material.isMeshMatcapMaterial ) {\n\n\t\t\trefreshUniformsCommon( uniforms, material );\n\t\t\trefreshUniformsMatcap( uniforms, material );\n\n\t\t} else if ( material.isMeshDepthMaterial ) {\n\n\t\t\trefreshUniformsCommon( uniforms, material );\n\t\t\trefreshUniformsDepth( uniforms, material );\n\n\t\t} else if ( material.isMeshDistanceMaterial ) {\n\n\t\t\trefreshUniformsCommon( uniforms, material );\n\t\t\trefreshUniformsDistance( uniforms, material );\n\n\t\t} else if ( material.isMeshNormalMaterial ) {\n\n\t\t\trefreshUniformsCommon( uniforms, material );\n\t\t\trefreshUniformsNormal( uniforms, material );\n\n\t\t} else if ( material.isLineBasicMaterial ) {\n\n\t\t\trefreshUniformsLine( uniforms, material );\n\n\t\t\tif ( material.isLineDashedMaterial ) {\n\n\t\t\t\trefreshUniformsDash( uniforms, material );\n\n\t\t\t}\n\n\t\t} else if ( material.isPointsMaterial ) {\n\n\t\t\trefreshUniformsPoints( uniforms, material, pixelRatio, height );\n\n\t\t} else if ( material.isSpriteMaterial ) {\n\n\t\t\trefreshUniformsSprites( uniforms, material );\n\n\t\t} else if ( material.isShadowMaterial ) {\n\n\t\t\tuniforms.color.value.copy( material.color );\n\t\t\tuniforms.opacity.value = material.opacity;\n\n\t\t} else if ( material.isShaderMaterial ) {\n\n\t\t\tmaterial.uniformsNeedUpdate = false; // #15581\n\n\t\t}\n\n\t}\n\n\tfunction refreshUniformsCommon( uniforms, material, environment ) {\n\n\t\tuniforms.opacity.value = material.opacity;\n\n\t\tif ( material.color ) {\n\n\t\t\tuniforms.diffuse.value.copy( material.color );\n\n\t\t}\n\n\t\tif ( material.emissive ) {\n\n\t\t\tuniforms.emissive.value.copy( material.emissive ).multiplyScalar( material.emissiveIntensity );\n\n\t\t}\n\n\t\tif ( material.map ) {\n\n\t\t\tuniforms.map.value = material.map;\n\n\t\t}\n\n\t\tif ( material.alphaMap ) {\n\n\t\t\tuniforms.alphaMap.value = material.alphaMap;\n\n\t\t}\n\n\t\tif ( material.specularMap ) {\n\n\t\t\tuniforms.specularMap.value = material.specularMap;\n\n\t\t}\n\n\t\tconst envMap = material.envMap || environment;\n\n\t\tif ( envMap ) {\n\n\t\t\tuniforms.envMap.value = envMap;\n\n\t\t\tuniforms.flipEnvMap.value = envMap.isCubeTexture ? - 1 : 1;\n\n\t\t\tuniforms.reflectivity.value = material.reflectivity;\n\t\t\tuniforms.refractionRatio.value = material.refractionRatio;\n\n\t\t\tuniforms.maxMipLevel.value = properties.get( envMap ).__maxMipLevel;\n\n\t\t}\n\n\t\tif ( material.lightMap ) {\n\n\t\t\tuniforms.lightMap.value = material.lightMap;\n\t\t\tuniforms.lightMapIntensity.value = material.lightMapIntensity;\n\n\t\t}\n\n\t\tif ( material.aoMap ) {\n\n\t\t\tuniforms.aoMap.value = material.aoMap;\n\t\t\tuniforms.aoMapIntensity.value = material.aoMapIntensity;\n\n\t\t}\n\n\t\t// uv repeat and offset setting priorities\n\t\t// 1. color map\n\t\t// 2. specular map\n\t\t// 3. normal map\n\t\t// 4. bump map\n\t\t// 5. alpha map\n\t\t// 6. emissive map\n\n\t\tlet uvScaleMap;\n\n\t\tif ( material.map ) {\n\n\t\t\tuvScaleMap = material.map;\n\n\t\t} else if ( material.specularMap ) {\n\n\t\t\tuvScaleMap = material.specularMap;\n\n\t\t} else if ( material.displacementMap ) {\n\n\t\t\tuvScaleMap = material.displacementMap;\n\n\t\t} else if ( material.normalMap ) {\n\n\t\t\tuvScaleMap = material.normalMap;\n\n\t\t} else if ( material.bumpMap ) {\n\n\t\t\tuvScaleMap = material.bumpMap;\n\n\t\t} else if ( material.roughnessMap ) {\n\n\t\t\tuvScaleMap = material.roughnessMap;\n\n\t\t} else if ( material.metalnessMap ) {\n\n\t\t\tuvScaleMap = material.metalnessMap;\n\n\t\t} else if ( material.alphaMap ) {\n\n\t\t\tuvScaleMap = material.alphaMap;\n\n\t\t} else if ( material.emissiveMap ) {\n\n\t\t\tuvScaleMap = material.emissiveMap;\n\n\t\t}\n\n\t\tif ( uvScaleMap !== undefined ) {\n\n\t\t\t// backwards compatibility\n\t\t\tif ( uvScaleMap.isWebGLRenderTarget ) {\n\n\t\t\t\tuvScaleMap = uvScaleMap.texture;\n\n\t\t\t}\n\n\t\t\tif ( uvScaleMap.matrixAutoUpdate === true ) {\n\n\t\t\t\tuvScaleMap.updateMatrix();\n\n\t\t\t}\n\n\t\t\tuniforms.uvTransform.value.copy( uvScaleMap.matrix );\n\n\t\t}\n\n\t\t// uv repeat and offset setting priorities for uv2\n\t\t// 1. ao map\n\t\t// 2. light map\n\n\t\tlet uv2ScaleMap;\n\n\t\tif ( material.aoMap ) {\n\n\t\t\tuv2ScaleMap = material.aoMap;\n\n\t\t} else if ( material.lightMap ) {\n\n\t\t\tuv2ScaleMap = material.lightMap;\n\n\t\t}\n\n\t\tif ( uv2ScaleMap !== undefined ) {\n\n\t\t\t// backwards compatibility\n\t\t\tif ( uv2ScaleMap.isWebGLRenderTarget ) {\n\n\t\t\t\tuv2ScaleMap = uv2ScaleMap.texture;\n\n\t\t\t}\n\n\t\t\tif ( uv2ScaleMap.matrixAutoUpdate === true ) {\n\n\t\t\t\tuv2ScaleMap.updateMatrix();\n\n\t\t\t}\n\n\t\t\tuniforms.uv2Transform.value.copy( uv2ScaleMap.matrix );\n\n\t\t}\n\n\t}\n\n\tfunction refreshUniformsLine( uniforms, material ) {\n\n\t\tuniforms.diffuse.value.copy( material.color );\n\t\tuniforms.opacity.value = material.opacity;\n\n\t}\n\n\tfunction refreshUniformsDash( uniforms, material ) {\n\n\t\tuniforms.dashSize.value = material.dashSize;\n\t\tuniforms.totalSize.value = material.dashSize + material.gapSize;\n\t\tuniforms.scale.value = material.scale;\n\n\t}\n\n\tfunction refreshUniformsPoints( uniforms, material, pixelRatio, height ) {\n\n\t\tuniforms.diffuse.value.copy( material.color );\n\t\tuniforms.opacity.value = material.opacity;\n\t\tuniforms.size.value = material.size * pixelRatio;\n\t\tuniforms.scale.value = height * 0.5;\n\n\t\tif ( material.map ) {\n\n\t\t\tuniforms.map.value = material.map;\n\n\t\t}\n\n\t\tif ( material.alphaMap ) {\n\n\t\t\tuniforms.alphaMap.value = material.alphaMap;\n\n\t\t}\n\n\t\t// uv repeat and offset setting priorities\n\t\t// 1. color map\n\t\t// 2. alpha map\n\n\t\tlet uvScaleMap;\n\n\t\tif ( material.map ) {\n\n\t\t\tuvScaleMap = material.map;\n\n\t\t} else if ( material.alphaMap ) {\n\n\t\t\tuvScaleMap = material.alphaMap;\n\n\t\t}\n\n\t\tif ( uvScaleMap !== undefined ) {\n\n\t\t\tif ( uvScaleMap.matrixAutoUpdate === true ) {\n\n\t\t\t\tuvScaleMap.updateMatrix();\n\n\t\t\t}\n\n\t\t\tuniforms.uvTransform.value.copy( uvScaleMap.matrix );\n\n\t\t}\n\n\t}\n\n\tfunction refreshUniformsSprites( uniforms, material ) {\n\n\t\tuniforms.diffuse.value.copy( material.color );\n\t\tuniforms.opacity.value = material.opacity;\n\t\tuniforms.rotation.value = material.rotation;\n\n\t\tif ( material.map ) {\n\n\t\t\tuniforms.map.value = material.map;\n\n\t\t}\n\n\t\tif ( material.alphaMap ) {\n\n\t\t\tuniforms.alphaMap.value = material.alphaMap;\n\n\t\t}\n\n\t\t// uv repeat and offset setting priorities\n\t\t// 1. color map\n\t\t// 2. alpha map\n\n\t\tlet uvScaleMap;\n\n\t\tif ( material.map ) {\n\n\t\t\tuvScaleMap = material.map;\n\n\t\t} else if ( material.alphaMap ) {\n\n\t\t\tuvScaleMap = material.alphaMap;\n\n\t\t}\n\n\t\tif ( uvScaleMap !== undefined ) {\n\n\t\t\tif ( uvScaleMap.matrixAutoUpdate === true ) {\n\n\t\t\t\tuvScaleMap.updateMatrix();\n\n\t\t\t}\n\n\t\t\tuniforms.uvTransform.value.copy( uvScaleMap.matrix );\n\n\t\t}\n\n\t}\n\n\tfunction refreshUniformsLambert( uniforms, material ) {\n\n\t\tif ( material.emissiveMap ) {\n\n\t\t\tuniforms.emissiveMap.value = material.emissiveMap;\n\n\t\t}\n\n\t}\n\n\tfunction refreshUniformsPhong( uniforms, material ) {\n\n\t\tuniforms.specular.value.copy( material.specular );\n\t\tuniforms.shininess.value = Math.max( material.shininess, 1e-4 ); // to prevent pow( 0.0, 0.0 )\n\n\t\tif ( material.emissiveMap ) {\n\n\t\t\tuniforms.emissiveMap.value = material.emissiveMap;\n\n\t\t}\n\n\t\tif ( material.bumpMap ) {\n\n\t\t\tuniforms.bumpMap.value = material.bumpMap;\n\t\t\tuniforms.bumpScale.value = material.bumpScale;\n\t\t\tif ( material.side === BackSide ) uniforms.bumpScale.value *= - 1;\n\n\t\t}\n\n\t\tif ( material.normalMap ) {\n\n\t\t\tuniforms.normalMap.value = material.normalMap;\n\t\t\tuniforms.normalScale.value.copy( material.normalScale );\n\t\t\tif ( material.side === BackSide ) uniforms.normalScale.value.negate();\n\n\t\t}\n\n\t\tif ( material.displacementMap ) {\n\n\t\t\tuniforms.displacementMap.value = material.displacementMap;\n\t\t\tuniforms.displacementScale.value = material.displacementScale;\n\t\t\tuniforms.displacementBias.value = material.displacementBias;\n\n\t\t}\n\n\t}\n\n\tfunction refreshUniformsToon( uniforms, material ) {\n\n\t\tif ( material.gradientMap ) {\n\n\t\t\tuniforms.gradientMap.value = material.gradientMap;\n\n\t\t}\n\n\t\tif ( material.emissiveMap ) {\n\n\t\t\tuniforms.emissiveMap.value = material.emissiveMap;\n\n\t\t}\n\n\t\tif ( material.bumpMap ) {\n\n\t\t\tuniforms.bumpMap.value = material.bumpMap;\n\t\t\tuniforms.bumpScale.value = material.bumpScale;\n\t\t\tif ( material.side === BackSide ) uniforms.bumpScale.value *= - 1;\n\n\t\t}\n\n\t\tif ( material.normalMap ) {\n\n\t\t\tuniforms.normalMap.value = material.normalMap;\n\t\t\tuniforms.normalScale.value.copy( material.normalScale );\n\t\t\tif ( material.side === BackSide ) uniforms.normalScale.value.negate();\n\n\t\t}\n\n\t\tif ( material.displacementMap ) {\n\n\t\t\tuniforms.displacementMap.value = material.displacementMap;\n\t\t\tuniforms.displacementScale.value = material.displacementScale;\n\t\t\tuniforms.displacementBias.value = material.displacementBias;\n\n\t\t}\n\n\t}\n\n\tfunction refreshUniformsStandard( uniforms, material, environment ) {\n\n\t\tuniforms.roughness.value = material.roughness;\n\t\tuniforms.metalness.value = material.metalness;\n\n\t\tif ( material.roughnessMap ) {\n\n\t\t\tuniforms.roughnessMap.value = material.roughnessMap;\n\n\t\t}\n\n\t\tif ( material.metalnessMap ) {\n\n\t\t\tuniforms.metalnessMap.value = material.metalnessMap;\n\n\t\t}\n\n\t\tif ( material.emissiveMap ) {\n\n\t\t\tuniforms.emissiveMap.value = material.emissiveMap;\n\n\t\t}\n\n\t\tif ( material.bumpMap ) {\n\n\t\t\tuniforms.bumpMap.value = material.bumpMap;\n\t\t\tuniforms.bumpScale.value = material.bumpScale;\n\t\t\tif ( material.side === BackSide ) uniforms.bumpScale.value *= - 1;\n\n\t\t}\n\n\t\tif ( material.normalMap ) {\n\n\t\t\tuniforms.normalMap.value = material.normalMap;\n\t\t\tuniforms.normalScale.value.copy( material.normalScale );\n\t\t\tif ( material.side === BackSide ) uniforms.normalScale.value.negate();\n\n\t\t}\n\n\t\tif ( material.displacementMap ) {\n\n\t\t\tuniforms.displacementMap.value = material.displacementMap;\n\t\t\tuniforms.displacementScale.value = material.displacementScale;\n\t\t\tuniforms.displacementBias.value = material.displacementBias;\n\n\t\t}\n\n\t\tif ( material.envMap || environment ) {\n\n\t\t\t//uniforms.envMap.value = material.envMap; // part of uniforms common\n\t\t\tuniforms.envMapIntensity.value = material.envMapIntensity;\n\n\t\t}\n\n\t}\n\n\tfunction refreshUniformsPhysical( uniforms, material, environment ) {\n\n\t\trefreshUniformsStandard( uniforms, material, environment );\n\n\t\tuniforms.reflectivity.value = material.reflectivity; // also part of uniforms common\n\n\t\tuniforms.clearcoat.value = material.clearcoat;\n\t\tuniforms.clearcoatRoughness.value = material.clearcoatRoughness;\n\t\tif ( material.sheen ) uniforms.sheen.value.copy( material.sheen );\n\n\t\tif ( material.clearcoatMap ) {\n\n\t\t\tuniforms.clearcoatMap.value = material.clearcoatMap;\n\n\t\t}\n\n\t\tif ( material.clearcoatRoughnessMap ) {\n\n\t\t\tuniforms.clearcoatRoughnessMap.value = material.clearcoatRoughnessMap;\n\n\t\t}\n\n\t\tif ( material.clearcoatNormalMap ) {\n\n\t\t\tuniforms.clearcoatNormalScale.value.copy( material.clearcoatNormalScale );\n\t\t\tuniforms.clearcoatNormalMap.value = material.clearcoatNormalMap;\n\n\t\t\tif ( material.side === BackSide ) {\n\n\t\t\t\tuniforms.clearcoatNormalScale.value.negate();\n\n\t\t\t}\n\n\t\t}\n\n\t\tuniforms.transparency.value = material.transparency;\n\n\t}\n\n\tfunction refreshUniformsMatcap( uniforms, material ) {\n\n\t\tif ( material.matcap ) {\n\n\t\t\tuniforms.matcap.value = material.matcap;\n\n\t\t}\n\n\t\tif ( material.bumpMap ) {\n\n\t\t\tuniforms.bumpMap.value = material.bumpMap;\n\t\t\tuniforms.bumpScale.value = material.bumpScale;\n\t\t\tif ( material.side === BackSide ) uniforms.bumpScale.value *= - 1;\n\n\t\t}\n\n\t\tif ( material.normalMap ) {\n\n\t\t\tuniforms.normalMap.value = material.normalMap;\n\t\t\tuniforms.normalScale.value.copy( material.normalScale );\n\t\t\tif ( material.side === BackSide ) uniforms.normalScale.value.negate();\n\n\t\t}\n\n\t\tif ( material.displacementMap ) {\n\n\t\t\tuniforms.displacementMap.value = material.displacementMap;\n\t\t\tuniforms.displacementScale.value = material.displacementScale;\n\t\t\tuniforms.displacementBias.value = material.displacementBias;\n\n\t\t}\n\n\t}\n\n\tfunction refreshUniformsDepth( uniforms, material ) {\n\n\t\tif ( material.displacementMap ) {\n\n\t\t\tuniforms.displacementMap.value = material.displacementMap;\n\t\t\tuniforms.displacementScale.value = material.displacementScale;\n\t\t\tuniforms.displacementBias.value = material.displacementBias;\n\n\t\t}\n\n\t}\n\n\tfunction refreshUniformsDistance( uniforms, material ) {\n\n\t\tif ( material.displacementMap ) {\n\n\t\t\tuniforms.displacementMap.value = material.displacementMap;\n\t\t\tuniforms.displacementScale.value = material.displacementScale;\n\t\t\tuniforms.displacementBias.value = material.displacementBias;\n\n\t\t}\n\n\t\tuniforms.referencePosition.value.copy( material.referencePosition );\n\t\tuniforms.nearDistance.value = material.nearDistance;\n\t\tuniforms.farDistance.value = material.farDistance;\n\n\t}\n\n\tfunction refreshUniformsNormal( uniforms, material ) {\n\n\t\tif ( material.bumpMap ) {\n\n\t\t\tuniforms.bumpMap.value = material.bumpMap;\n\t\t\tuniforms.bumpScale.value = material.bumpScale;\n\t\t\tif ( material.side === BackSide ) uniforms.bumpScale.value *= - 1;\n\n\t\t}\n\n\t\tif ( material.normalMap ) {\n\n\t\t\tuniforms.normalMap.value = material.normalMap;\n\t\t\tuniforms.normalScale.value.copy( material.normalScale );\n\t\t\tif ( material.side === BackSide ) uniforms.normalScale.value.negate();\n\n\t\t}\n\n\t\tif ( material.displacementMap ) {\n\n\t\t\tuniforms.displacementMap.value = material.displacementMap;\n\t\t\tuniforms.displacementScale.value = material.displacementScale;\n\t\t\tuniforms.displacementBias.value = material.displacementBias;\n\n\t\t}\n\n\t}\n\n\treturn {\n\t\trefreshFogUniforms: refreshFogUniforms,\n\t\trefreshMaterialUniforms: refreshMaterialUniforms\n\t};\n\n}\n\nexport { WebGLMaterials };\n","/**\n * @author supereggbert / http://www.paulbrunt.co.uk/\n * @author mrdoob / http://mrdoob.com/\n * @author alteredq / http://alteredqualia.com/\n * @author szimek / https://github.com/szimek/\n * @author tschw\n */\n\nimport {\n\tRGBAFormat,\n\tHalfFloatType,\n\tFloatType,\n\tUnsignedByteType,\n\tLinearEncoding,\n\tNoToneMapping\n} from '../constants.js';\nimport { MathUtils } from '../math/MathUtils.js';\nimport { DataTexture } from '../textures/DataTexture.js';\nimport { Frustum } from '../math/Frustum.js';\nimport { Matrix4 } from '../math/Matrix4.js';\nimport { UniformsLib } from './shaders/UniformsLib.js';\nimport { Vector2 } from '../math/Vector2.js';\nimport { Vector3 } from '../math/Vector3.js';\nimport { Vector4 } from '../math/Vector4.js';\nimport { WebGLAnimation } from './webgl/WebGLAnimation.js';\nimport { WebGLAttributes } from './webgl/WebGLAttributes.js';\nimport { WebGLBackground } from './webgl/WebGLBackground.js';\nimport { WebGLBindingStates } from './webgl/WebGLBindingStates.js';\nimport { WebGLBufferRenderer } from './webgl/WebGLBufferRenderer.js';\nimport { WebGLCapabilities } from './webgl/WebGLCapabilities.js';\nimport { WebGLClipping } from './webgl/WebGLClipping.js';\nimport { WebGLExtensions } from './webgl/WebGLExtensions.js';\nimport { WebGLGeometries } from './webgl/WebGLGeometries.js';\nimport { WebGLIndexedBufferRenderer } from './webgl/WebGLIndexedBufferRenderer.js';\nimport { WebGLInfo } from './webgl/WebGLInfo.js';\nimport { WebGLMorphtargets } from './webgl/WebGLMorphtargets.js';\nimport { WebGLObjects } from './webgl/WebGLObjects.js';\nimport { WebGLPrograms } from './webgl/WebGLPrograms.js';\nimport { WebGLProperties } from './webgl/WebGLProperties.js';\nimport { WebGLRenderLists } from './webgl/WebGLRenderLists.js';\nimport { WebGLRenderStates } from './webgl/WebGLRenderStates.js';\nimport { WebGLShadowMap } from './webgl/WebGLShadowMap.js';\nimport { WebGLState } from './webgl/WebGLState.js';\nimport { WebGLTextures } from './webgl/WebGLTextures.js';\nimport { WebGLUniforms } from './webgl/WebGLUniforms.js';\nimport { WebGLUtils } from './webgl/WebGLUtils.js';\nimport { WebXRManager } from './webxr/WebXRManager.js';\nimport { WebGLMaterials } from \"./webgl/WebGLMaterials.js\";\n\nfunction WebGLRenderer( parameters ) {\n\n\tparameters = parameters || {};\n\n\tconst _canvas = parameters.canvas !== undefined ? parameters.canvas : document.createElementNS( 'http://www.w3.org/1999/xhtml', 'canvas' ),\n\t\t_context = parameters.context !== undefined ? parameters.context : null,\n\n\t\t_alpha = parameters.alpha !== undefined ? parameters.alpha : false,\n\t\t_depth = parameters.depth !== undefined ? parameters.depth : true,\n\t\t_stencil = parameters.stencil !== undefined ? parameters.stencil : true,\n\t\t_antialias = parameters.antialias !== undefined ? parameters.antialias : false,\n\t\t_premultipliedAlpha = parameters.premultipliedAlpha !== undefined ? parameters.premultipliedAlpha : true,\n\t\t_preserveDrawingBuffer = parameters.preserveDrawingBuffer !== undefined ? parameters.preserveDrawingBuffer : false,\n\t\t_powerPreference = parameters.powerPreference !== undefined ? parameters.powerPreference : 'default',\n\t\t_failIfMajorPerformanceCaveat = parameters.failIfMajorPerformanceCaveat !== undefined ? parameters.failIfMajorPerformanceCaveat : false;\n\n\tlet currentRenderList = null;\n\tlet currentRenderState = null;\n\n\t// public properties\n\n\tthis.domElement = _canvas;\n\n\t// Debug configuration container\n\tthis.debug = {\n\n\t\t/**\n\t\t * Enables error checking and reporting when shader programs are being compiled\n\t\t * @type {boolean}\n\t\t */\n\t\tcheckShaderErrors: true\n\t};\n\n\t// clearing\n\n\tthis.autoClear = true;\n\tthis.autoClearColor = true;\n\tthis.autoClearDepth = true;\n\tthis.autoClearStencil = true;\n\n\t// scene graph\n\n\tthis.sortObjects = true;\n\n\t// user-defined clipping\n\n\tthis.clippingPlanes = [];\n\tthis.localClippingEnabled = false;\n\n\t// physically based shading\n\n\tthis.gammaFactor = 2.0;\t// for backwards compatibility\n\tthis.outputEncoding = LinearEncoding;\n\n\t// physical lights\n\n\tthis.physicallyCorrectLights = false;\n\n\t// tone mapping\n\n\tthis.toneMapping = NoToneMapping;\n\tthis.toneMappingExposure = 1.0;\n\n\t// morphs\n\n\tthis.maxMorphTargets = 8;\n\tthis.maxMorphNormals = 4;\n\n\t// internal properties\n\n\tconst _this = this;\n\n\tlet _isContextLost = false;\n\n\t// internal state cache\n\n\tlet _framebuffer = null;\n\n\tlet _currentActiveCubeFace = 0;\n\tlet _currentActiveMipmapLevel = 0;\n\tlet _currentRenderTarget = null;\n\tlet _currentFramebuffer = null;\n\tlet _currentMaterialId = - 1;\n\n\tlet _currentCamera = null;\n\tlet _currentArrayCamera = null;\n\n\tconst _currentViewport = new Vector4();\n\tconst _currentScissor = new Vector4();\n\tlet _currentScissorTest = null;\n\n\t//\n\n\tlet _width = _canvas.width;\n\tlet _height = _canvas.height;\n\n\tlet _pixelRatio = 1;\n\tlet _opaqueSort = null;\n\tlet _transparentSort = null;\n\n\tconst _viewport = new Vector4( 0, 0, _width, _height );\n\tconst _scissor = new Vector4( 0, 0, _width, _height );\n\tlet _scissorTest = false;\n\n\t// frustum\n\n\tconst _frustum = new Frustum();\n\n\t// clipping\n\n\tconst _clipping = new WebGLClipping();\n\tlet _clippingEnabled = false;\n\tlet _localClippingEnabled = false;\n\n\t// camera matrices cache\n\n\tconst _projScreenMatrix = new Matrix4();\n\n\tconst _vector3 = new Vector3();\n\n\tconst _emptyScene = { background: null, fog: null, environment: null, overrideMaterial: null, isScene: true };\n\n\tfunction getTargetPixelRatio() {\n\n\t\treturn _currentRenderTarget === null ? _pixelRatio : 1;\n\n\t}\n\n\t// initialize\n\n\tlet _gl = _context;\n\n\tfunction getContext( contextNames, contextAttributes ) {\n\n\t\tfor ( let i = 0; i < contextNames.length; i ++ ) {\n\n\t\t\tconst contextName = contextNames[ i ];\n\t\t\tconst context = _canvas.getContext( contextName, contextAttributes );\n\t\t\tif ( context !== null ) return context;\n\n\t\t}\n\n\t\treturn null;\n\n\t}\n\n\ttry {\n\n\t\tconst contextAttributes = {\n\t\t\talpha: _alpha,\n\t\t\tdepth: _depth,\n\t\t\tstencil: _stencil,\n\t\t\tantialias: _antialias,\n\t\t\tpremultipliedAlpha: _premultipliedAlpha,\n\t\t\tpreserveDrawingBuffer: _preserveDrawingBuffer,\n\t\t\tpowerPreference: _powerPreference,\n\t\t\tfailIfMajorPerformanceCaveat: _failIfMajorPerformanceCaveat\n\t\t};\n\n\t\t// event listeners must be registered before WebGL context is created, see #12753\n\n\t\t_canvas.addEventListener( 'webglcontextlost', onContextLost, false );\n\t\t_canvas.addEventListener( 'webglcontextrestored', onContextRestore, false );\n\n\t\tif ( _gl === null ) {\n\n\t\t\tconst contextNames = [ 'webgl2', 'webgl', 'experimental-webgl' ];\n\n\t\t\tif ( _this.isWebGL1Renderer === true ) {\n\n\t\t\t\tcontextNames.shift();\n\n\t\t\t}\n\n\t\t\t_gl = getContext( contextNames, contextAttributes );\n\n\t\t\tif ( _gl === null ) {\n\n\t\t\t\tif ( getContext( contextNames ) ) {\n\n\t\t\t\t\tthrow new Error( 'Error creating WebGL context with your selected attributes.' );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tthrow new Error( 'Error creating WebGL context.' );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\t// Some experimental-webgl implementations do not have getShaderPrecisionFormat\n\n\t\tif ( _gl.getShaderPrecisionFormat === undefined ) {\n\n\t\t\t_gl.getShaderPrecisionFormat = function () {\n\n\t\t\t\treturn { 'rangeMin': 1, 'rangeMax': 1, 'precision': 1 };\n\n\t\t\t};\n\n\t\t}\n\n\t} catch ( error ) {\n\n\t\tconsole.error( 'THREE.WebGLRenderer: ' + error.message );\n\t\tthrow error;\n\n\t}\n\n\tlet extensions, capabilities, state, info;\n\tlet properties, textures, attributes, geometries, objects;\n\tlet programCache, materials, renderLists, renderStates;\n\n\tlet background, morphtargets, bufferRenderer, indexedBufferRenderer;\n\n\tlet utils, bindingStates;\n\n\tfunction initGLContext() {\n\n\t\textensions = new WebGLExtensions( _gl );\n\n\t\tcapabilities = new WebGLCapabilities( _gl, extensions, parameters );\n\n\t\tif ( capabilities.isWebGL2 === false ) {\n\n\t\t\textensions.get( 'WEBGL_depth_texture' );\n\t\t\textensions.get( 'OES_texture_float' );\n\t\t\textensions.get( 'OES_texture_half_float' );\n\t\t\textensions.get( 'OES_texture_half_float_linear' );\n\t\t\textensions.get( 'OES_standard_derivatives' );\n\t\t\textensions.get( 'OES_element_index_uint' );\n\t\t\textensions.get( 'OES_vertex_array_object' );\n\t\t\textensions.get( 'ANGLE_instanced_arrays' );\n\n\t\t}\n\n\t\textensions.get( 'OES_texture_float_linear' );\n\n\t\tutils = new WebGLUtils( _gl, extensions, capabilities );\n\n\t\tstate = new WebGLState( _gl, extensions, capabilities );\n\t\tstate.scissor( _currentScissor.copy( _scissor ).multiplyScalar( _pixelRatio ).floor() );\n\t\tstate.viewport( _currentViewport.copy( _viewport ).multiplyScalar( _pixelRatio ).floor() );\n\n\t\tinfo = new WebGLInfo( _gl );\n\t\tproperties = new WebGLProperties();\n\t\ttextures = new WebGLTextures( _gl, extensions, state, properties, capabilities, utils, info );\n\t\tattributes = new WebGLAttributes( _gl, capabilities );\n\t\tbindingStates = new WebGLBindingStates( _gl, extensions, attributes, capabilities );\n\t\tgeometries = new WebGLGeometries( _gl, attributes, info, bindingStates );\n\t\tobjects = new WebGLObjects( _gl, geometries, attributes, info );\n\t\tmorphtargets = new WebGLMorphtargets( _gl );\n\t\tprogramCache = new WebGLPrograms( _this, extensions, capabilities, bindingStates );\n\t\tmaterials = new WebGLMaterials( properties );\n\t\trenderLists = new WebGLRenderLists();\n\t\trenderStates = new WebGLRenderStates();\n\n\t\tbackground = new WebGLBackground( _this, state, objects, _premultipliedAlpha );\n\n\t\tbufferRenderer = new WebGLBufferRenderer( _gl, extensions, info, capabilities );\n\t\tindexedBufferRenderer = new WebGLIndexedBufferRenderer( _gl, extensions, info, capabilities );\n\n\t\tinfo.programs = programCache.programs;\n\n\t\t_this.capabilities = capabilities;\n\t\t_this.extensions = extensions;\n\t\t_this.properties = properties;\n\t\t_this.renderLists = renderLists;\n\t\t_this.state = state;\n\t\t_this.info = info;\n\n\t}\n\n\tinitGLContext();\n\n\t// xr\n\n\tconst xr = new WebXRManager( _this, _gl );\n\n\tthis.xr = xr;\n\n\t// shadow map\n\n\tconst shadowMap = new WebGLShadowMap( _this, objects, capabilities.maxTextureSize );\n\n\tthis.shadowMap = shadowMap;\n\n\t// API\n\n\tthis.getContext = function () {\n\n\t\treturn _gl;\n\n\t};\n\n\tthis.getContextAttributes = function () {\n\n\t\treturn _gl.getContextAttributes();\n\n\t};\n\n\tthis.forceContextLoss = function () {\n\n\t\tconst extension = extensions.get( 'WEBGL_lose_context' );\n\t\tif ( extension ) extension.loseContext();\n\n\t};\n\n\tthis.forceContextRestore = function () {\n\n\t\tconst extension = extensions.get( 'WEBGL_lose_context' );\n\t\tif ( extension ) extension.restoreContext();\n\n\t};\n\n\tthis.getPixelRatio = function () {\n\n\t\treturn _pixelRatio;\n\n\t};\n\n\tthis.setPixelRatio = function ( value ) {\n\n\t\tif ( value === undefined ) return;\n\n\t\t_pixelRatio = value;\n\n\t\tthis.setSize( _width, _height, false );\n\n\t};\n\n\tthis.getSize = function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'WebGLRenderer: .getsize() now requires a Vector2 as an argument' );\n\n\t\t\ttarget = new Vector2();\n\n\t\t}\n\n\t\treturn target.set( _width, _height );\n\n\t};\n\n\tthis.setSize = function ( width, height, updateStyle ) {\n\n\t\tif ( xr.isPresenting ) {\n\n\t\t\tconsole.warn( 'THREE.WebGLRenderer: Can\\'t change size while VR device is presenting.' );\n\t\t\treturn;\n\n\t\t}\n\n\t\t_width = width;\n\t\t_height = height;\n\n\t\t_canvas.width = Math.floor( width * _pixelRatio );\n\t\t_canvas.height = Math.floor( height * _pixelRatio );\n\n\t\tif ( updateStyle !== false ) {\n\n\t\t\t_canvas.style.width = width + 'px';\n\t\t\t_canvas.style.height = height + 'px';\n\n\t\t}\n\n\t\tthis.setViewport( 0, 0, width, height );\n\n\t};\n\n\tthis.getDrawingBufferSize = function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'WebGLRenderer: .getdrawingBufferSize() now requires a Vector2 as an argument' );\n\n\t\t\ttarget = new Vector2();\n\n\t\t}\n\n\t\treturn target.set( _width * _pixelRatio, _height * _pixelRatio ).floor();\n\n\t};\n\n\tthis.setDrawingBufferSize = function ( width, height, pixelRatio ) {\n\n\t\t_width = width;\n\t\t_height = height;\n\n\t\t_pixelRatio = pixelRatio;\n\n\t\t_canvas.width = Math.floor( width * pixelRatio );\n\t\t_canvas.height = Math.floor( height * pixelRatio );\n\n\t\tthis.setViewport( 0, 0, width, height );\n\n\t};\n\n\tthis.getCurrentViewport = function ( target ) {\n\n\t\tif ( target === undefined ) {\n\n\t\t\tconsole.warn( 'WebGLRenderer: .getCurrentViewport() now requires a Vector4 as an argument' );\n\n\t\t\ttarget = new Vector4();\n\n\t\t}\n\n\t\treturn target.copy( _currentViewport );\n\n\t};\n\n\tthis.getViewport = function ( target ) {\n\n\t\treturn target.copy( _viewport );\n\n\t};\n\n\tthis.setViewport = function ( x, y, width, height ) {\n\n\t\tif ( x.isVector4 ) {\n\n\t\t\t_viewport.set( x.x, x.y, x.z, x.w );\n\n\t\t} else {\n\n\t\t\t_viewport.set( x, y, width, height );\n\n\t\t}\n\n\t\tstate.viewport( _currentViewport.copy( _viewport ).multiplyScalar( _pixelRatio ).floor() );\n\n\t};\n\n\tthis.getScissor = function ( target ) {\n\n\t\treturn target.copy( _scissor );\n\n\t};\n\n\tthis.setScissor = function ( x, y, width, height ) {\n\n\t\tif ( x.isVector4 ) {\n\n\t\t\t_scissor.set( x.x, x.y, x.z, x.w );\n\n\t\t} else {\n\n\t\t\t_scissor.set( x, y, width, height );\n\n\t\t}\n\n\t\tstate.scissor( _currentScissor.copy( _scissor ).multiplyScalar( _pixelRatio ).floor() );\n\n\t};\n\n\tthis.getScissorTest = function () {\n\n\t\treturn _scissorTest;\n\n\t};\n\n\tthis.setScissorTest = function ( boolean ) {\n\n\t\tstate.setScissorTest( _scissorTest = boolean );\n\n\t};\n\n\tthis.setOpaqueSort = function ( method ) {\n\n\t\t_opaqueSort = method;\n\n\t};\n\n\tthis.setTransparentSort = function ( method ) {\n\n\t\t_transparentSort = method;\n\n\t};\n\n\t// Clearing\n\n\tthis.getClearColor = function () {\n\n\t\treturn background.getClearColor();\n\n\t};\n\n\tthis.setClearColor = function () {\n\n\t\tbackground.setClearColor.apply( background, arguments );\n\n\t};\n\n\tthis.getClearAlpha = function () {\n\n\t\treturn background.getClearAlpha();\n\n\t};\n\n\tthis.setClearAlpha = function () {\n\n\t\tbackground.setClearAlpha.apply( background, arguments );\n\n\t};\n\n\tthis.clear = function ( color, depth, stencil ) {\n\n\t\tlet bits = 0;\n\n\t\tif ( color === undefined || color ) bits |= _gl.COLOR_BUFFER_BIT;\n\t\tif ( depth === undefined || depth ) bits |= _gl.DEPTH_BUFFER_BIT;\n\t\tif ( stencil === undefined || stencil ) bits |= _gl.STENCIL_BUFFER_BIT;\n\n\t\t_gl.clear( bits );\n\n\t};\n\n\tthis.clearColor = function () {\n\n\t\tthis.clear( true, false, false );\n\n\t};\n\n\tthis.clearDepth = function () {\n\n\t\tthis.clear( false, true, false );\n\n\t};\n\n\tthis.clearStencil = function () {\n\n\t\tthis.clear( false, false, true );\n\n\t};\n\n\t//\n\n\tthis.dispose = function () {\n\n\t\t_canvas.removeEventListener( 'webglcontextlost', onContextLost, false );\n\t\t_canvas.removeEventListener( 'webglcontextrestored', onContextRestore, false );\n\n\t\trenderLists.dispose();\n\t\trenderStates.dispose();\n\t\tproperties.dispose();\n\t\tobjects.dispose();\n\t\tbindingStates.dispose();\n\n\t\txr.dispose();\n\n\t\tanimation.stop();\n\n\t};\n\n\t// Events\n\n\tfunction onContextLost( event ) {\n\n\t\tevent.preventDefault();\n\n\t\tconsole.log( 'THREE.WebGLRenderer: Context Lost.' );\n\n\t\t_isContextLost = true;\n\n\t}\n\n\tfunction onContextRestore( /* event */ ) {\n\n\t\tconsole.log( 'THREE.WebGLRenderer: Context Restored.' );\n\n\t\t_isContextLost = false;\n\n\t\tinitGLContext();\n\n\t}\n\n\tfunction onMaterialDispose( event ) {\n\n\t\tconst material = event.target;\n\n\t\tmaterial.removeEventListener( 'dispose', onMaterialDispose );\n\n\t\tdeallocateMaterial( material );\n\n\t}\n\n\t// Buffer deallocation\n\n\tfunction deallocateMaterial( material ) {\n\n\t\treleaseMaterialProgramReference( material );\n\n\t\tproperties.remove( material );\n\n\t}\n\n\n\tfunction releaseMaterialProgramReference( material ) {\n\n\t\tconst programInfo = properties.get( material ).program;\n\n\t\tmaterial.program = undefined;\n\n\t\tif ( programInfo !== undefined ) {\n\n\t\t\tprogramCache.releaseProgram( programInfo );\n\n\t\t}\n\n\t}\n\n\t// Buffer rendering\n\n\tfunction renderObjectImmediate( object, program ) {\n\n\t\tobject.render( function ( object ) {\n\n\t\t\t_this.renderBufferImmediate( object, program );\n\n\t\t} );\n\n\t}\n\n\tthis.renderBufferImmediate = function ( object, program ) {\n\n\t\tbindingStates.initAttributes();\n\n\t\tconst buffers = properties.get( object );\n\n\t\tif ( object.hasPositions && ! buffers.position ) buffers.position = _gl.createBuffer();\n\t\tif ( object.hasNormals && ! buffers.normal ) buffers.normal = _gl.createBuffer();\n\t\tif ( object.hasUvs && ! buffers.uv ) buffers.uv = _gl.createBuffer();\n\t\tif ( object.hasColors && ! buffers.color ) buffers.color = _gl.createBuffer();\n\n\t\tconst programAttributes = program.getAttributes();\n\n\t\tif ( object.hasPositions ) {\n\n\t\t\t_gl.bindBuffer( _gl.ARRAY_BUFFER, buffers.position );\n\t\t\t_gl.bufferData( _gl.ARRAY_BUFFER, object.positionArray, _gl.DYNAMIC_DRAW );\n\n\t\t\tbindingStates.enableAttribute( programAttributes.position );\n\t\t\t_gl.vertexAttribPointer( programAttributes.position, 3, _gl.FLOAT, false, 0, 0 );\n\n\t\t}\n\n\t\tif ( object.hasNormals ) {\n\n\t\t\t_gl.bindBuffer( _gl.ARRAY_BUFFER, buffers.normal );\n\t\t\t_gl.bufferData( _gl.ARRAY_BUFFER, object.normalArray, _gl.DYNAMIC_DRAW );\n\n\t\t\tbindingStates.enableAttribute( programAttributes.normal );\n\t\t\t_gl.vertexAttribPointer( programAttributes.normal, 3, _gl.FLOAT, false, 0, 0 );\n\n\t\t}\n\n\t\tif ( object.hasUvs ) {\n\n\t\t\t_gl.bindBuffer( _gl.ARRAY_BUFFER, buffers.uv );\n\t\t\t_gl.bufferData( _gl.ARRAY_BUFFER, object.uvArray, _gl.DYNAMIC_DRAW );\n\n\t\t\tbindingStates.enableAttribute( programAttributes.uv );\n\t\t\t_gl.vertexAttribPointer( programAttributes.uv, 2, _gl.FLOAT, false, 0, 0 );\n\n\t\t}\n\n\t\tif ( object.hasColors ) {\n\n\t\t\t_gl.bindBuffer( _gl.ARRAY_BUFFER, buffers.color );\n\t\t\t_gl.bufferData( _gl.ARRAY_BUFFER, object.colorArray, _gl.DYNAMIC_DRAW );\n\n\t\t\tbindingStates.enableAttribute( programAttributes.color );\n\t\t\t_gl.vertexAttribPointer( programAttributes.color, 3, _gl.FLOAT, false, 0, 0 );\n\n\t\t}\n\n\t\tbindingStates.disableUnusedAttributes();\n\n\t\t_gl.drawArrays( _gl.TRIANGLES, 0, object.count );\n\n\t\tobject.count = 0;\n\n\t};\n\n\tthis.renderBufferDirect = function ( camera, scene, geometry, material, object, group ) {\n\n\t\tif ( scene === null ) scene = _emptyScene; // renderBufferDirect second parameter used to be fog (could be null)\n\n\t\tconst frontFaceCW = ( object.isMesh && object.matrixWorld.determinant() < 0 );\n\n\t\tconst program = setProgram( camera, scene, material, object );\n\n\t\tstate.setMaterial( material, frontFaceCW );\n\n\t\t//\n\n\t\tlet index = geometry.index;\n\t\tconst position = geometry.attributes.position;\n\n\t\t//\n\n\t\tif ( index === null ) {\n\n\t\t\tif ( position === undefined || position.count === 0 ) return;\n\n\t\t} else if ( index.count === 0 ) {\n\n\t\t\treturn;\n\n\t\t}\n\n\t\t//\n\n\t\tlet rangeFactor = 1;\n\n\t\tif ( material.wireframe === true ) {\n\n\t\t\tindex = geometries.getWireframeAttribute( geometry );\n\t\t\trangeFactor = 2;\n\n\t\t}\n\n\t\tif ( material.morphTargets || material.morphNormals ) {\n\n\t\t\tmorphtargets.update( object, geometry, material, program );\n\n\t\t}\n\n\t\tbindingStates.setup( object, material, program, geometry, index );\n\n\t\tlet attribute;\n\t\tlet renderer = bufferRenderer;\n\n\t\tif ( index !== null ) {\n\n\t\t\tattribute = attributes.get( index );\n\n\t\t\trenderer = indexedBufferRenderer;\n\t\t\trenderer.setIndex( attribute );\n\n\t\t}\n\n\t\t//\n\n\t\tconst dataCount = ( index !== null ) ? index.count : position.count;\n\n\t\tconst rangeStart = geometry.drawRange.start * rangeFactor;\n\t\tconst rangeCount = geometry.drawRange.count * rangeFactor;\n\n\t\tconst groupStart = group !== null ? group.start * rangeFactor : 0;\n\t\tconst groupCount = group !== null ? group.count * rangeFactor : Infinity;\n\n\t\tconst drawStart = Math.max( rangeStart, groupStart );\n\t\tconst drawEnd = Math.min( dataCount, rangeStart + rangeCount, groupStart + groupCount ) - 1;\n\n\t\tconst drawCount = Math.max( 0, drawEnd - drawStart + 1 );\n\n\t\tif ( drawCount === 0 ) return;\n\n\t\t//\n\n\t\tif ( object.isMesh ) {\n\n\t\t\tif ( material.wireframe === true ) {\n\n\t\t\t\tstate.setLineWidth( material.wireframeLinewidth * getTargetPixelRatio() );\n\t\t\t\trenderer.setMode( _gl.LINES );\n\n\t\t\t} else {\n\n\t\t\t\trenderer.setMode( _gl.TRIANGLES );\n\n\t\t\t}\n\n\t\t} else if ( object.isLine ) {\n\n\t\t\tlet lineWidth = material.linewidth;\n\n\t\t\tif ( lineWidth === undefined ) lineWidth = 1; // Not using Line*Material\n\n\t\t\tstate.setLineWidth( lineWidth * getTargetPixelRatio() );\n\n\t\t\tif ( object.isLineSegments ) {\n\n\t\t\t\trenderer.setMode( _gl.LINES );\n\n\t\t\t} else if ( object.isLineLoop ) {\n\n\t\t\t\trenderer.setMode( _gl.LINE_LOOP );\n\n\t\t\t} else {\n\n\t\t\t\trenderer.setMode( _gl.LINE_STRIP );\n\n\t\t\t}\n\n\t\t} else if ( object.isPoints ) {\n\n\t\t\trenderer.setMode( _gl.POINTS );\n\n\t\t} else if ( object.isSprite ) {\n\n\t\t\trenderer.setMode( _gl.TRIANGLES );\n\n\t\t}\n\n\t\tif ( object.isInstancedMesh ) {\n\n\t\t\trenderer.renderInstances( geometry, drawStart, drawCount, object.count );\n\n\t\t} else if ( geometry.isInstancedBufferGeometry ) {\n\n\t\t\tconst instanceCount = Math.min( geometry.instanceCount, geometry._maxInstanceCount );\n\n\t\t\trenderer.renderInstances( geometry, drawStart, drawCount, instanceCount );\n\n\t\t} else {\n\n\t\t\trenderer.render( drawStart, drawCount );\n\n\t\t}\n\n\t};\n\n\t// Compile\n\n\tthis.compile = function ( scene, camera ) {\n\n\t\tcurrentRenderState = renderStates.get( scene, camera );\n\t\tcurrentRenderState.init();\n\n\t\tscene.traverse( function ( object ) {\n\n\t\t\tif ( object.isLight ) {\n\n\t\t\t\tcurrentRenderState.pushLight( object );\n\n\t\t\t\tif ( object.castShadow ) {\n\n\t\t\t\t\tcurrentRenderState.pushShadow( object );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} );\n\n\t\tcurrentRenderState.setupLights( camera );\n\n\t\tconst compiled = new WeakMap();\n\n\t\tscene.traverse( function ( object ) {\n\n\t\t\tlet material = object.material;\n\n\t\t\tif ( material ) {\n\n\t\t\t\tif ( Array.isArray( material ) ) {\n\n\t\t\t\t\tfor ( let i = 0; i < material.length; i ++ ) {\n\n\t\t\t\t\t\tlet material2 = material[ i ];\n\n\t\t\t\t\t\tif ( compiled.has( material2 ) === false ) {\n\n\t\t\t\t\t\t\tinitMaterial( material2, scene, object );\n\t\t\t\t\t\t\tcompiled.set( material2 );\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t}\n\n\t\t\t\t} else if ( compiled.has( material ) === false ) {\n\n\t\t\t\t\tinitMaterial( material, scene, object );\n\t\t\t\t\tcompiled.set( material );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} );\n\n\t};\n\n\t// Animation Loop\n\n\tlet onAnimationFrameCallback = null;\n\n\tfunction onAnimationFrame( time ) {\n\n\t\tif ( xr.isPresenting ) return;\n\t\tif ( onAnimationFrameCallback ) onAnimationFrameCallback( time );\n\n\t}\n\n\tconst animation = new WebGLAnimation();\n\tanimation.setAnimationLoop( onAnimationFrame );\n\n\tif ( typeof window !== 'undefined' ) animation.setContext( window );\n\n\tthis.setAnimationLoop = function ( callback ) {\n\n\t\tonAnimationFrameCallback = callback;\n\t\txr.setAnimationLoop( callback );\n\n\t\t( callback === null ) ? animation.stop() : animation.start();\n\n\t};\n\n\t// Rendering\n\n\tthis.render = function ( scene, camera ) {\n\n\t\tlet renderTarget, forceClear;\n\n\t\tif ( arguments[ 2 ] !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.WebGLRenderer.render(): the renderTarget argument has been removed. Use .setRenderTarget() instead.' );\n\t\t\trenderTarget = arguments[ 2 ];\n\n\t\t}\n\n\t\tif ( arguments[ 3 ] !== undefined ) {\n\n\t\t\tconsole.warn( 'THREE.WebGLRenderer.render(): the forceClear argument has been removed. Use .clear() instead.' );\n\t\t\tforceClear = arguments[ 3 ];\n\n\t\t}\n\n\t\tif ( camera !== undefined && camera.isCamera !== true ) {\n\n\t\t\tconsole.error( 'THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.' );\n\t\t\treturn;\n\n\t\t}\n\n\t\tif ( _isContextLost === true ) return;\n\n\t\t// reset caching for this frame\n\n\t\tbindingStates.resetDefaultState();\n\t\t_currentMaterialId = - 1;\n\t\t_currentCamera = null;\n\n\t\t// update scene graph\n\n\t\tif ( scene.autoUpdate === true ) scene.updateMatrixWorld();\n\n\t\t// update camera matrices and frustum\n\n\t\tif ( camera.parent === null ) camera.updateMatrixWorld();\n\n\t\tif ( xr.enabled === true && xr.isPresenting === true ) {\n\n\t\t\tcamera = xr.getCamera( camera );\n\n\t\t}\n\n\t\t//\n\t\tif ( scene.isScene === true ) scene.onBeforeRender( _this, scene, camera, renderTarget || _currentRenderTarget );\n\n\t\tcurrentRenderState = renderStates.get( scene, camera );\n\t\tcurrentRenderState.init();\n\n\t\t_projScreenMatrix.multiplyMatrices( camera.projectionMatrix, camera.matrixWorldInverse );\n\t\t_frustum.setFromProjectionMatrix( _projScreenMatrix );\n\n\t\t_localClippingEnabled = this.localClippingEnabled;\n\t\t_clippingEnabled = _clipping.init( this.clippingPlanes, _localClippingEnabled, camera );\n\n\t\tcurrentRenderList = renderLists.get( scene, camera );\n\t\tcurrentRenderList.init();\n\n\t\tprojectObject( scene, camera, 0, _this.sortObjects );\n\n\t\tcurrentRenderList.finish();\n\n\t\tif ( _this.sortObjects === true ) {\n\n\t\t\tcurrentRenderList.sort( _opaqueSort, _transparentSort );\n\n\t\t}\n\n\t\t//\n\n\t\tif ( _clippingEnabled === true ) _clipping.beginShadows();\n\n\t\tconst shadowsArray = currentRenderState.state.shadowsArray;\n\n\t\tshadowMap.render( shadowsArray, scene, camera );\n\n\t\tcurrentRenderState.setupLights( camera );\n\n\t\tif ( _clippingEnabled === true ) _clipping.endShadows();\n\n\t\t//\n\n\t\tif ( this.info.autoReset === true ) this.info.reset();\n\n\t\tif ( renderTarget !== undefined ) {\n\n\t\t\tthis.setRenderTarget( renderTarget );\n\n\t\t}\n\n\t\t//\n\n\t\tbackground.render( currentRenderList, scene, camera, forceClear );\n\n\t\t// render scene\n\n\t\tconst opaqueObjects = currentRenderList.opaque;\n\t\tconst transparentObjects = currentRenderList.transparent;\n\n\t\tif ( opaqueObjects.length > 0 ) renderObjects( opaqueObjects, scene, camera );\n\t\tif ( transparentObjects.length > 0 ) renderObjects( transparentObjects, scene, camera );\n\n\t\t//\n\n\t\tif ( scene.isScene === true ) scene.onAfterRender( _this, scene, camera );\n\n\t\t//\n\n\t\tif ( _currentRenderTarget !== null ) {\n\n\t\t\t// Generate mipmap if we're using any kind of mipmap filtering\n\n\t\t\ttextures.updateRenderTargetMipmap( _currentRenderTarget );\n\n\t\t\t// resolve multisample renderbuffers to a single-sample texture if necessary\n\n\t\t\ttextures.updateMultisampleRenderTarget( _currentRenderTarget );\n\n\t\t}\n\n\t\t// Ensure depth buffer writing is enabled so it can be cleared on next render\n\n\t\tstate.buffers.depth.setTest( true );\n\t\tstate.buffers.depth.setMask( true );\n\t\tstate.buffers.color.setMask( true );\n\n\t\tstate.setPolygonOffset( false );\n\n\t\t// _gl.finish();\n\n\t\tcurrentRenderList = null;\n\t\tcurrentRenderState = null;\n\n\t};\n\n\tfunction projectObject( object, camera, groupOrder, sortObjects ) {\n\n\t\tif ( object.visible === false ) return;\n\n\t\tconst visible = object.layers.test( camera.layers );\n\n\t\tif ( visible ) {\n\n\t\t\tif ( object.isGroup ) {\n\n\t\t\t\tgroupOrder = object.renderOrder;\n\n\t\t\t} else if ( object.isLOD ) {\n\n\t\t\t\tif ( object.autoUpdate === true ) object.update( camera );\n\n\t\t\t} else if ( object.isLight ) {\n\n\t\t\t\tcurrentRenderState.pushLight( object );\n\n\t\t\t\tif ( object.castShadow ) {\n\n\t\t\t\t\tcurrentRenderState.pushShadow( object );\n\n\t\t\t\t}\n\n\t\t\t} else if ( object.isSprite ) {\n\n\t\t\t\tif ( ! object.frustumCulled || _frustum.intersectsSprite( object ) ) {\n\n\t\t\t\t\tif ( sortObjects ) {\n\n\t\t\t\t\t\t_vector3.setFromMatrixPosition( object.matrixWorld )\n\t\t\t\t\t\t\t.applyMatrix4( _projScreenMatrix );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tconst geometry = objects.update( object );\n\t\t\t\t\tconst material = object.material;\n\n\t\t\t\t\tif ( material.visible ) {\n\n\t\t\t\t\t\tcurrentRenderList.push( object, geometry, material, groupOrder, _vector3.z, null );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t} else if ( object.isImmediateRenderObject ) {\n\n\t\t\t\tif ( sortObjects ) {\n\n\t\t\t\t\t_vector3.setFromMatrixPosition( object.matrixWorld )\n\t\t\t\t\t\t.applyMatrix4( _projScreenMatrix );\n\n\t\t\t\t}\n\n\t\t\t\tcurrentRenderList.push( object, null, object.material, groupOrder, _vector3.z, null );\n\n\t\t\t} else if ( object.isMesh || object.isLine || object.isPoints ) {\n\n\t\t\t\tif ( object.isSkinnedMesh ) {\n\n\t\t\t\t\t// update skeleton only once in a frame\n\n\t\t\t\t\tif ( object.skeleton.frame !== info.render.frame ) {\n\n\t\t\t\t\t\tobject.skeleton.update();\n\t\t\t\t\t\tobject.skeleton.frame = info.render.frame;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t\tif ( ! object.frustumCulled || _frustum.intersectsObject( object ) ) {\n\n\t\t\t\t\tif ( sortObjects ) {\n\n\t\t\t\t\t\t_vector3.setFromMatrixPosition( object.matrixWorld )\n\t\t\t\t\t\t\t.applyMatrix4( _projScreenMatrix );\n\n\t\t\t\t\t}\n\n\t\t\t\t\tconst geometry = objects.update( object );\n\t\t\t\t\tconst material = object.material;\n\n\t\t\t\t\tif ( Array.isArray( material ) ) {\n\n\t\t\t\t\t\tconst groups = geometry.groups;\n\n\t\t\t\t\t\tfor ( let i = 0, l = groups.length; i < l; i ++ ) {\n\n\t\t\t\t\t\t\tconst group = groups[ i ];\n\t\t\t\t\t\t\tconst groupMaterial = material[ group.materialIndex ];\n\n\t\t\t\t\t\t\tif ( groupMaterial && groupMaterial.visible ) {\n\n\t\t\t\t\t\t\t\tcurrentRenderList.push( object, geometry, groupMaterial, groupOrder, _vector3.z, group );\n\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t}\n\n\t\t\t\t\t} else if ( material.visible ) {\n\n\t\t\t\t\t\tcurrentRenderList.push( object, geometry, material, groupOrder, _vector3.z, null );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tconst children = object.children;\n\n\t\tfor ( let i = 0, l = children.length; i < l; i ++ ) {\n\n\t\t\tprojectObject( children[ i ], camera, groupOrder, sortObjects );\n\n\t\t}\n\n\t}\n\n\tfunction renderObjects( renderList, scene, camera ) {\n\n\t\tconst overrideMaterial = scene.isScene === true ? scene.overrideMaterial : null;\n\n\t\tfor ( let i = 0, l = renderList.length; i < l; i ++ ) {\n\n\t\t\tconst renderItem = renderList[ i ];\n\n\t\t\tconst object = renderItem.object;\n\t\t\tconst geometry = renderItem.geometry;\n\t\t\tconst material = overrideMaterial === null ? renderItem.material : overrideMaterial;\n\t\t\tconst group = renderItem.group;\n\n\t\t\tif ( camera.isArrayCamera ) {\n\n\t\t\t\t_currentArrayCamera = camera;\n\n\t\t\t\tconst cameras = camera.cameras;\n\n\t\t\t\tfor ( let j = 0, jl = cameras.length; j < jl; j ++ ) {\n\n\t\t\t\t\tconst camera2 = cameras[ j ];\n\n\t\t\t\t\tif ( object.layers.test( camera2.layers ) ) {\n\n\t\t\t\t\t\tstate.viewport( _currentViewport.copy( camera2.viewport ) );\n\n\t\t\t\t\t\tcurrentRenderState.setupLights( camera2 );\n\n\t\t\t\t\t\trenderObject( object, scene, camera2, geometry, material, group );\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\t_currentArrayCamera = null;\n\n\t\t\t\trenderObject( object, scene, camera, geometry, material, group );\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tfunction renderObject( object, scene, camera, geometry, material, group ) {\n\n\t\tobject.onBeforeRender( _this, scene, camera, geometry, material, group );\n\t\tcurrentRenderState = renderStates.get( scene, _currentArrayCamera || camera );\n\n\t\tobject.modelViewMatrix.multiplyMatrices( camera.matrixWorldInverse, object.matrixWorld );\n\t\tobject.normalMatrix.getNormalMatrix( object.modelViewMatrix );\n\n\t\tif ( object.isImmediateRenderObject ) {\n\n\t\t\tconst program = setProgram( camera, scene, material, object );\n\n\t\t\tstate.setMaterial( material );\n\n\t\t\tbindingStates.reset();\n\n\t\t\trenderObjectImmediate( object, program );\n\n\t\t} else {\n\n\t\t\t_this.renderBufferDirect( camera, scene, geometry, material, object, group );\n\n\t\t}\n\n\t\tobject.onAfterRender( _this, scene, camera, geometry, material, group );\n\t\tcurrentRenderState = renderStates.get( scene, _currentArrayCamera || camera );\n\n\t}\n\n\tfunction initMaterial( material, scene, object ) {\n\n\t\tif ( scene.isScene !== true ) scene = _emptyScene; // scene could be a Mesh, Line, Points, ...\n\n\t\tconst materialProperties = properties.get( material );\n\n\t\tconst lights = currentRenderState.state.lights;\n\t\tconst shadowsArray = currentRenderState.state.shadowsArray;\n\n\t\tconst lightsStateVersion = lights.state.version;\n\n\t\tconst parameters = programCache.getParameters( material, lights.state, shadowsArray, scene, _clipping.numPlanes, _clipping.numIntersection, object );\n\t\tconst programCacheKey = programCache.getProgramCacheKey( parameters );\n\n\t\tlet program = materialProperties.program;\n\t\tlet programChange = true;\n\n\t\tif ( program === undefined ) {\n\n\t\t\t// new material\n\t\t\tmaterial.addEventListener( 'dispose', onMaterialDispose );\n\n\t\t} else if ( program.cacheKey !== programCacheKey ) {\n\n\t\t\t// changed glsl or parameters\n\t\t\treleaseMaterialProgramReference( material );\n\n\t\t} else if ( materialProperties.lightsStateVersion !== lightsStateVersion ) {\n\n\t\t\tmaterialProperties.lightsStateVersion = lightsStateVersion;\n\n\t\t\tprogramChange = false;\n\n\t\t} else if ( parameters.shaderID !== undefined ) {\n\n\t\t\t// same glsl and uniform list\n\t\t\treturn;\n\n\t\t} else {\n\n\t\t\t// only rebuild uniform list\n\t\t\tprogramChange = false;\n\n\t\t}\n\n\t\tif ( programChange ) {\n\n\t\t\tprogram = programCache.acquireProgram( parameters, programCacheKey );\n\n\t\t\tmaterialProperties.program = program;\n\t\t\tmaterialProperties.uniforms = parameters.uniforms;\n\t\t\tmaterialProperties.outputEncoding = parameters.outputEncoding;\n\t\t\tmaterial.program = program;\n\n\t\t}\n\n\t\tconst programAttributes = program.getAttributes();\n\n\t\tif ( material.morphTargets ) {\n\n\t\t\tmaterial.numSupportedMorphTargets = 0;\n\n\t\t\tfor ( let i = 0; i < _this.maxMorphTargets; i ++ ) {\n\n\t\t\t\tif ( programAttributes[ 'morphTarget' + i ] >= 0 ) {\n\n\t\t\t\t\tmaterial.numSupportedMorphTargets ++;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( material.morphNormals ) {\n\n\t\t\tmaterial.numSupportedMorphNormals = 0;\n\n\t\t\tfor ( let i = 0; i < _this.maxMorphNormals; i ++ ) {\n\n\t\t\t\tif ( programAttributes[ 'morphNormal' + i ] >= 0 ) {\n\n\t\t\t\t\tmaterial.numSupportedMorphNormals ++;\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tconst uniforms = materialProperties.uniforms;\n\n\t\tif ( ! material.isShaderMaterial &&\n\t\t\t! material.isRawShaderMaterial ||\n\t\t\tmaterial.clipping === true ) {\n\n\t\t\tmaterialProperties.numClippingPlanes = _clipping.numPlanes;\n\t\t\tmaterialProperties.numIntersection = _clipping.numIntersection;\n\t\t\tuniforms.clippingPlanes = _clipping.uniform;\n\n\t\t}\n\n\t\tmaterialProperties.environment = material.isMeshStandardMaterial ? scene.environment : null;\n\t\tmaterialProperties.fog = scene.fog;\n\n\t\t// store the light setup it was created for\n\n\t\tmaterialProperties.needsLights = materialNeedsLights( material );\n\t\tmaterialProperties.lightsStateVersion = lightsStateVersion;\n\n\t\tif ( materialProperties.needsLights ) {\n\n\t\t\t// wire up the material to this renderer's lighting state\n\n\t\t\tuniforms.ambientLightColor.value = lights.state.ambient;\n\t\t\tuniforms.lightProbe.value = lights.state.probe;\n\t\t\tuniforms.directionalLights.value = lights.state.directional;\n\t\t\tuniforms.directionalLightShadows.value = lights.state.directionalShadow;\n\t\t\tuniforms.spotLights.value = lights.state.spot;\n\t\t\tuniforms.spotLightShadows.value = lights.state.spotShadow;\n\t\t\tuniforms.rectAreaLights.value = lights.state.rectArea;\n\t\t\tuniforms.pointLights.value = lights.state.point;\n\t\t\tuniforms.pointLightShadows.value = lights.state.pointShadow;\n\t\t\tuniforms.hemisphereLights.value = lights.state.hemi;\n\n\t\t\tuniforms.directionalShadowMap.value = lights.state.directionalShadowMap;\n\t\t\tuniforms.directionalShadowMatrix.value = lights.state.directionalShadowMatrix;\n\t\t\tuniforms.spotShadowMap.value = lights.state.spotShadowMap;\n\t\t\tuniforms.spotShadowMatrix.value = lights.state.spotShadowMatrix;\n\t\t\tuniforms.pointShadowMap.value = lights.state.pointShadowMap;\n\t\t\tuniforms.pointShadowMatrix.value = lights.state.pointShadowMatrix;\n\t\t\t// TODO (abelnation): add area lights shadow info to uniforms\n\n\t\t}\n\n\t\tconst progUniforms = materialProperties.program.getUniforms(),\n\t\t\tuniformsList =\n\t\t\t\tWebGLUniforms.seqWithValue( progUniforms.seq, uniforms );\n\n\t\tmaterialProperties.uniformsList = uniformsList;\n\n\t}\n\n\tfunction setProgram( camera, scene, material, object ) {\n\n\t\tif ( scene.isScene !== true ) scene = _emptyScene; // scene could be a Mesh, Line, Points, ...\n\n\t\ttextures.resetTextureUnits();\n\n\t\tconst fog = scene.fog;\n\t\tconst environment = material.isMeshStandardMaterial ? scene.environment : null;\n\t\tconst encoding = ( _currentRenderTarget === null ) ? _this.outputEncoding : _currentRenderTarget.texture.encoding;\n\n\t\tconst materialProperties = properties.get( material );\n\t\tconst lights = currentRenderState.state.lights;\n\n\t\tif ( _clippingEnabled === true ) {\n\n\t\t\tif ( _localClippingEnabled === true || camera !== _currentCamera ) {\n\n\t\t\t\tconst useCache =\n\t\t\t\t\tcamera === _currentCamera &&\n\t\t\t\t\tmaterial.id === _currentMaterialId;\n\n\t\t\t\t// we might want to call this function with some ClippingGroup\n\t\t\t\t// object instead of the material, once it becomes feasible\n\t\t\t\t// (#8465, #8379)\n\t\t\t\t_clipping.setState(\n\t\t\t\t\tmaterial.clippingPlanes, material.clipIntersection, material.clipShadows,\n\t\t\t\t\tcamera, materialProperties, useCache );\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( material.version === materialProperties.__version ) {\n\n\t\t\tif ( materialProperties.program === undefined ) {\n\n\t\t\t\tinitMaterial( material, scene, object );\n\n\t\t\t} else if ( material.fog && materialProperties.fog !== fog ) {\n\n\t\t\t\tinitMaterial( material, scene, object );\n\n\t\t\t} else if ( materialProperties.environment !== environment ) {\n\n\t\t\t\tinitMaterial( material, scene, object );\n\n\t\t\t} else if ( materialProperties.needsLights && ( materialProperties.lightsStateVersion !== lights.state.version ) ) {\n\n\t\t\t\tinitMaterial( material, scene, object );\n\n\t\t\t} else if ( materialProperties.numClippingPlanes !== undefined &&\n\t\t\t\t( materialProperties.numClippingPlanes !== _clipping.numPlanes ||\n\t\t\t\tmaterialProperties.numIntersection !== _clipping.numIntersection ) ) {\n\n\t\t\t\tinitMaterial( material, scene, object );\n\n\t\t\t} else if ( materialProperties.outputEncoding !== encoding ) {\n\n\t\t\t\tinitMaterial( material, scene, object );\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tinitMaterial( material, scene, object );\n\t\t\tmaterialProperties.__version = material.version;\n\n\t\t}\n\n\t\tlet refreshProgram = false;\n\t\tlet refreshMaterial = false;\n\t\tlet refreshLights = false;\n\n\t\tconst program = materialProperties.program,\n\t\t\tp_uniforms = program.getUniforms(),\n\t\t\tm_uniforms = materialProperties.uniforms;\n\n\t\tif ( state.useProgram( program.program ) ) {\n\n\t\t\trefreshProgram = true;\n\t\t\trefreshMaterial = true;\n\t\t\trefreshLights = true;\n\n\t\t}\n\n\t\tif ( material.id !== _currentMaterialId ) {\n\n\t\t\t_currentMaterialId = material.id;\n\n\t\t\trefreshMaterial = true;\n\n\t\t}\n\n\t\tif ( refreshProgram || _currentCamera !== camera ) {\n\n\t\t\tp_uniforms.setValue( _gl, 'projectionMatrix', camera.projectionMatrix );\n\n\t\t\tif ( capabilities.logarithmicDepthBuffer ) {\n\n\t\t\t\tp_uniforms.setValue( _gl, 'logDepthBufFC',\n\t\t\t\t\t2.0 / ( Math.log( camera.far + 1.0 ) / Math.LN2 ) );\n\n\t\t\t}\n\n\t\t\tif ( _currentCamera !== camera ) {\n\n\t\t\t\t_currentCamera = camera;\n\n\t\t\t\t// lighting uniforms depend on the camera so enforce an update\n\t\t\t\t// now, in case this material supports lights - or later, when\n\t\t\t\t// the next material that does gets activated:\n\n\t\t\t\trefreshMaterial = true;\t\t// set to true on material change\n\t\t\t\trefreshLights = true;\t\t// remains set until update done\n\n\t\t\t}\n\n\t\t\t// load material specific uniforms\n\t\t\t// (shader material also gets them for the sake of genericity)\n\n\t\t\tif ( material.isShaderMaterial ||\n\t\t\t\tmaterial.isMeshPhongMaterial ||\n\t\t\t\tmaterial.isMeshToonMaterial ||\n\t\t\t\tmaterial.isMeshStandardMaterial ||\n\t\t\t\tmaterial.envMap ) {\n\n\t\t\t\tconst uCamPos = p_uniforms.map.cameraPosition;\n\n\t\t\t\tif ( uCamPos !== undefined ) {\n\n\t\t\t\t\tuCamPos.setValue( _gl,\n\t\t\t\t\t\t_vector3.setFromMatrixPosition( camera.matrixWorld ) );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t\tif ( material.isMeshPhongMaterial ||\n\t\t\t\tmaterial.isMeshToonMaterial ||\n\t\t\t\tmaterial.isMeshLambertMaterial ||\n\t\t\t\tmaterial.isMeshBasicMaterial ||\n\t\t\t\tmaterial.isMeshStandardMaterial ||\n\t\t\t\tmaterial.isShaderMaterial ) {\n\n\t\t\t\tp_uniforms.setValue( _gl, 'isOrthographic', camera.isOrthographicCamera === true );\n\n\t\t\t}\n\n\t\t\tif ( material.isMeshPhongMaterial ||\n\t\t\t\tmaterial.isMeshToonMaterial ||\n\t\t\t\tmaterial.isMeshLambertMaterial ||\n\t\t\t\tmaterial.isMeshBasicMaterial ||\n\t\t\t\tmaterial.isMeshStandardMaterial ||\n\t\t\t\tmaterial.isShaderMaterial ||\n\t\t\t\tmaterial.isShadowMaterial ||\n\t\t\t\tmaterial.skinning ) {\n\n\t\t\t\tp_uniforms.setValue( _gl, 'viewMatrix', camera.matrixWorldInverse );\n\n\t\t\t}\n\n\t\t}\n\n\t\t// skinning uniforms must be set even if material didn't change\n\t\t// auto-setting of texture unit for bone texture must go before other textures\n\t\t// otherwise textures used for skinning can take over texture units reserved for other material textures\n\n\t\tif ( material.skinning ) {\n\n\t\t\tp_uniforms.setOptional( _gl, object, 'bindMatrix' );\n\t\t\tp_uniforms.setOptional( _gl, object, 'bindMatrixInverse' );\n\n\t\t\tconst skeleton = object.skeleton;\n\n\t\t\tif ( skeleton ) {\n\n\t\t\t\tconst bones = skeleton.bones;\n\n\t\t\t\tif ( capabilities.floatVertexTextures ) {\n\n\t\t\t\t\tif ( skeleton.boneTexture === undefined ) {\n\n\t\t\t\t\t\t// layout (1 matrix = 4 pixels)\n\t\t\t\t\t\t// RGBA RGBA RGBA RGBA (=> column1, column2, column3, column4)\n\t\t\t\t\t\t// with 8x8 pixel texture max 16 bones * 4 pixels = (8 * 8)\n\t\t\t\t\t\t// 16x16 pixel texture max 64 bones * 4 pixels = (16 * 16)\n\t\t\t\t\t\t// 32x32 pixel texture max 256 bones * 4 pixels = (32 * 32)\n\t\t\t\t\t\t// 64x64 pixel texture max 1024 bones * 4 pixels = (64 * 64)\n\n\n\t\t\t\t\t\tlet size = Math.sqrt( bones.length * 4 ); // 4 pixels needed for 1 matrix\n\t\t\t\t\t\tsize = MathUtils.ceilPowerOfTwo( size );\n\t\t\t\t\t\tsize = Math.max( size, 4 );\n\n\t\t\t\t\t\tconst boneMatrices = new Float32Array( size * size * 4 ); // 4 floats per RGBA pixel\n\t\t\t\t\t\tboneMatrices.set( skeleton.boneMatrices ); // copy current values\n\n\t\t\t\t\t\tconst boneTexture = new DataTexture( boneMatrices, size, size, RGBAFormat, FloatType );\n\n\t\t\t\t\t\tskeleton.boneMatrices = boneMatrices;\n\t\t\t\t\t\tskeleton.boneTexture = boneTexture;\n\t\t\t\t\t\tskeleton.boneTextureSize = size;\n\n\t\t\t\t\t}\n\n\t\t\t\t\tp_uniforms.setValue( _gl, 'boneTexture', skeleton.boneTexture, textures );\n\t\t\t\t\tp_uniforms.setValue( _gl, 'boneTextureSize', skeleton.boneTextureSize );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tp_uniforms.setOptional( _gl, skeleton, 'boneMatrices' );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\tif ( refreshMaterial || materialProperties.receiveShadow !== object.receiveShadow ) {\n\n\t\t\tmaterialProperties.receiveShadow = object.receiveShadow;\n\t\t\tp_uniforms.setValue( _gl, 'receiveShadow', object.receiveShadow );\n\n\t\t}\n\n\t\tif ( refreshMaterial ) {\n\n\t\t\tp_uniforms.setValue( _gl, 'toneMappingExposure', _this.toneMappingExposure );\n\n\t\t\tif ( materialProperties.needsLights ) {\n\n\t\t\t\t// the current material requires lighting info\n\n\t\t\t\t// note: all lighting uniforms are always set correctly\n\t\t\t\t// they simply reference the renderer's state for their\n\t\t\t\t// values\n\t\t\t\t//\n\t\t\t\t// use the current material's .needsUpdate flags to set\n\t\t\t\t// the GL state when required\n\n\t\t\t\tmarkUniformsLightsNeedsUpdate( m_uniforms, refreshLights );\n\n\t\t\t}\n\n\t\t\t// refresh uniforms common to several materials\n\n\t\t\tif ( fog && material.fog ) {\n\n\t\t\t\tmaterials.refreshFogUniforms( m_uniforms, fog );\n\n\t\t\t}\n\n\t\t\tmaterials.refreshMaterialUniforms( m_uniforms, material, environment, _pixelRatio, _height );\n\n\t\t\t// RectAreaLight Texture\n\t\t\t// TODO (mrdoob): Find a nicer implementation\n\n\t\t\tif ( m_uniforms.ltc_1 !== undefined ) m_uniforms.ltc_1.value = UniformsLib.LTC_1;\n\t\t\tif ( m_uniforms.ltc_2 !== undefined ) m_uniforms.ltc_2.value = UniformsLib.LTC_2;\n\n\t\t\tWebGLUniforms.upload( _gl, materialProperties.uniformsList, m_uniforms, textures );\n\n\t\t}\n\n\t\tif ( material.isShaderMaterial && material.uniformsNeedUpdate === true ) {\n\n\t\t\tWebGLUniforms.upload( _gl, materialProperties.uniformsList, m_uniforms, textures );\n\t\t\tmaterial.uniformsNeedUpdate = false;\n\n\t\t}\n\n\t\tif ( material.isSpriteMaterial ) {\n\n\t\t\tp_uniforms.setValue( _gl, 'center', object.center );\n\n\t\t}\n\n\t\t// common matrices\n\n\t\tp_uniforms.setValue( _gl, 'modelViewMatrix', object.modelViewMatrix );\n\t\tp_uniforms.setValue( _gl, 'normalMatrix', object.normalMatrix );\n\t\tp_uniforms.setValue( _gl, 'modelMatrix', object.matrixWorld );\n\n\t\treturn program;\n\n\t}\n\n\t// If uniforms are marked as clean, they don't need to be loaded to the GPU.\n\n\tfunction markUniformsLightsNeedsUpdate( uniforms, value ) {\n\n\t\tuniforms.ambientLightColor.needsUpdate = value;\n\t\tuniforms.lightProbe.needsUpdate = value;\n\n\t\tuniforms.directionalLights.needsUpdate = value;\n\t\tuniforms.directionalLightShadows.needsUpdate = value;\n\t\tuniforms.pointLights.needsUpdate = value;\n\t\tuniforms.pointLightShadows.needsUpdate = value;\n\t\tuniforms.spotLights.needsUpdate = value;\n\t\tuniforms.spotLightShadows.needsUpdate = value;\n\t\tuniforms.rectAreaLights.needsUpdate = value;\n\t\tuniforms.hemisphereLights.needsUpdate = value;\n\n\t}\n\n\tfunction materialNeedsLights( material ) {\n\n\t\treturn material.isMeshLambertMaterial || material.isMeshToonMaterial || material.isMeshPhongMaterial ||\n\t\t\tmaterial.isMeshStandardMaterial || material.isShadowMaterial ||\n\t\t\t( material.isShaderMaterial && material.lights === true );\n\n\t}\n\n\t//\n\tthis.setFramebuffer = function ( value ) {\n\n\t\tif ( _framebuffer !== value && _currentRenderTarget === null ) _gl.bindFramebuffer( _gl.FRAMEBUFFER, value );\n\n\t\t_framebuffer = value;\n\n\t};\n\n\tthis.getActiveCubeFace = function () {\n\n\t\treturn _currentActiveCubeFace;\n\n\t};\n\n\tthis.getActiveMipmapLevel = function () {\n\n\t\treturn _currentActiveMipmapLevel;\n\n\t};\n\n\tthis.getRenderTarget = function () {\n\n\t\treturn _currentRenderTarget;\n\n\t};\n\n\tthis.setRenderTarget = function ( renderTarget, activeCubeFace, activeMipmapLevel ) {\n\n\t\t_currentRenderTarget = renderTarget;\n\t\t_currentActiveCubeFace = activeCubeFace;\n\t\t_currentActiveMipmapLevel = activeMipmapLevel;\n\n\t\tif ( renderTarget && properties.get( renderTarget ).__webglFramebuffer === undefined ) {\n\n\t\t\ttextures.setupRenderTarget( renderTarget );\n\n\t\t}\n\n\t\tlet framebuffer = _framebuffer;\n\t\tlet isCube = false;\n\n\t\tif ( renderTarget ) {\n\n\t\t\tconst __webglFramebuffer = properties.get( renderTarget ).__webglFramebuffer;\n\n\t\t\tif ( renderTarget.isWebGLCubeRenderTarget ) {\n\n\t\t\t\tframebuffer = __webglFramebuffer[ activeCubeFace || 0 ];\n\t\t\t\tisCube = true;\n\n\t\t\t} else if ( renderTarget.isWebGLMultisampleRenderTarget ) {\n\n\t\t\t\tframebuffer = properties.get( renderTarget ).__webglMultisampledFramebuffer;\n\n\t\t\t} else {\n\n\t\t\t\tframebuffer = __webglFramebuffer;\n\n\t\t\t}\n\n\t\t\t_currentViewport.copy( renderTarget.viewport );\n\t\t\t_currentScissor.copy( renderTarget.scissor );\n\t\t\t_currentScissorTest = renderTarget.scissorTest;\n\n\t\t} else {\n\n\t\t\t_currentViewport.copy( _viewport ).multiplyScalar( _pixelRatio ).floor();\n\t\t\t_currentScissor.copy( _scissor ).multiplyScalar( _pixelRatio ).floor();\n\t\t\t_currentScissorTest = _scissorTest;\n\n\t\t}\n\n\t\tif ( _currentFramebuffer !== framebuffer ) {\n\n\t\t\t_gl.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );\n\t\t\t_currentFramebuffer = framebuffer;\n\n\t\t}\n\n\t\tstate.viewport( _currentViewport );\n\t\tstate.scissor( _currentScissor );\n\t\tstate.setScissorTest( _currentScissorTest );\n\n\t\tif ( isCube ) {\n\n\t\t\tconst textureProperties = properties.get( renderTarget.texture );\n\t\t\t_gl.framebufferTexture2D( _gl.FRAMEBUFFER, _gl.COLOR_ATTACHMENT0, _gl.TEXTURE_CUBE_MAP_POSITIVE_X + ( activeCubeFace || 0 ), textureProperties.__webglTexture, activeMipmapLevel || 0 );\n\n\t\t}\n\n\t};\n\n\tthis.readRenderTargetPixels = function ( renderTarget, x, y, width, height, buffer, activeCubeFaceIndex ) {\n\n\t\tif ( ! ( renderTarget && renderTarget.isWebGLRenderTarget ) ) {\n\n\t\t\tconsole.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.' );\n\t\t\treturn;\n\n\t\t}\n\n\t\tlet framebuffer = properties.get( renderTarget ).__webglFramebuffer;\n\n\t\tif ( renderTarget.isWebGLCubeRenderTarget && activeCubeFaceIndex !== undefined ) {\n\n\t\t\tframebuffer = framebuffer[ activeCubeFaceIndex ];\n\n\t\t}\n\n\t\tif ( framebuffer ) {\n\n\t\t\tlet restore = false;\n\n\t\t\tif ( framebuffer !== _currentFramebuffer ) {\n\n\t\t\t\t_gl.bindFramebuffer( _gl.FRAMEBUFFER, framebuffer );\n\n\t\t\t\trestore = true;\n\n\t\t\t}\n\n\t\t\ttry {\n\n\t\t\t\tconst texture = renderTarget.texture;\n\t\t\t\tconst textureFormat = texture.format;\n\t\t\t\tconst textureType = texture.type;\n\n\t\t\t\tif ( textureFormat !== RGBAFormat && utils.convert( textureFormat ) !== _gl.getParameter( _gl.IMPLEMENTATION_COLOR_READ_FORMAT ) ) {\n\n\t\t\t\t\tconsole.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format.' );\n\t\t\t\t\treturn;\n\n\t\t\t\t}\n\n\t\t\t\tif ( textureType !== UnsignedByteType && utils.convert( textureType ) !== _gl.getParameter( _gl.IMPLEMENTATION_COLOR_READ_TYPE ) && // IE11, Edge and Chrome Mac < 52 (#9513)\n\t\t\t\t\t! ( textureType === FloatType && ( capabilities.isWebGL2 || extensions.get( 'OES_texture_float' ) || extensions.get( 'WEBGL_color_buffer_float' ) ) ) && // Chrome Mac >= 52 and Firefox\n\t\t\t\t\t! ( textureType === HalfFloatType && ( capabilities.isWebGL2 ? extensions.get( 'EXT_color_buffer_float' ) : extensions.get( 'EXT_color_buffer_half_float' ) ) ) ) {\n\n\t\t\t\t\tconsole.error( 'THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.' );\n\t\t\t\t\treturn;\n\n\t\t\t\t}\n\n\t\t\t\tif ( _gl.checkFramebufferStatus( _gl.FRAMEBUFFER ) === _gl.FRAMEBUFFER_COMPLETE ) {\n\n\t\t\t\t\t// the following if statement ensures valid read requests (no out-of-bounds pixels, see #8604)\n\n\t\t\t\t\tif ( ( x >= 0 && x <= ( renderTarget.width - width ) ) && ( y >= 0 && y <= ( renderTarget.height - height ) ) ) {\n\n\t\t\t\t\t\t_gl.readPixels( x, y, width, height, utils.convert( textureFormat ), utils.convert( textureType ), buffer );\n\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\n\t\t\t\t\tconsole.error( 'THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete.' );\n\n\t\t\t\t}\n\n\t\t\t} finally {\n\n\t\t\t\tif ( restore ) {\n\n\t\t\t\t\t_gl.bindFramebuffer( _gl.FRAMEBUFFER, _currentFramebuffer );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t};\n\n\tthis.copyFramebufferToTexture = function ( position, texture, level ) {\n\n\t\tif ( level === undefined ) level = 0;\n\n\t\tconst levelScale = Math.pow( 2, - level );\n\t\tconst width = Math.floor( texture.image.width * levelScale );\n\t\tconst height = Math.floor( texture.image.height * levelScale );\n\t\tconst glFormat = utils.convert( texture.format );\n\n\t\ttextures.setTexture2D( texture, 0 );\n\n\t\t_gl.copyTexImage2D( _gl.TEXTURE_2D, level, glFormat, position.x, position.y, width, height, 0 );\n\n\t\tstate.unbindTexture();\n\n\t};\n\n\tthis.copyTextureToTexture = function ( position, srcTexture, dstTexture, level ) {\n\n\t\tif ( level === undefined ) level = 0;\n\n\t\tconst width = srcTexture.image.width;\n\t\tconst height = srcTexture.image.height;\n\t\tconst glFormat = utils.convert( dstTexture.format );\n\t\tconst glType = utils.convert( dstTexture.type );\n\n\t\ttextures.setTexture2D( dstTexture, 0 );\n\n\t\t// As another texture upload may have changed pixelStorei\n\t\t// parameters, make sure they are correct for the dstTexture\n\t\t_gl.pixelStorei( _gl.UNPACK_FLIP_Y_WEBGL, dstTexture.flipY );\n\t\t_gl.pixelStorei( _gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, dstTexture.premultiplyAlpha );\n\t\t_gl.pixelStorei( _gl.UNPACK_ALIGNMENT, dstTexture.unpackAlignment );\n\n\t\tif ( srcTexture.isDataTexture ) {\n\n\t\t\t_gl.texSubImage2D( _gl.TEXTURE_2D, level, position.x, position.y, width, height, glFormat, glType, srcTexture.image.data );\n\n\t\t} else {\n\n\t\t\tif ( srcTexture.isCompressedTexture ) {\n\n\t\t\t\t_gl.compressedTexSubImage2D( _gl.TEXTURE_2D, level, position.x, position.y, srcTexture.mipmaps[ 0 ].width, srcTexture.mipmaps[ 0 ].height, glFormat, srcTexture.mipmaps[ 0 ].data );\n\n\t\t\t} else {\n\n\t\t\t\t_gl.texSubImage2D( _gl.TEXTURE_2D, level, position.x, position.y, glFormat, glType, srcTexture.image );\n\n\t\t\t}\n\n\t\t}\n\n\t\t// Generate mipmaps only when copying level 0\n\t\tif ( level === 0 && dstTexture.generateMipmaps ) _gl.generateMipmap( _gl.TEXTURE_2D );\n\n\t\tstate.unbindTexture();\n\n\t};\n\n\tthis.initTexture = function ( texture ) {\n\n\t\ttextures.setTexture2D( texture, 0 );\n\n\t\tstate.unbindTexture();\n\n\t};\n\n\tif ( typeof __THREE_DEVTOOLS__ !== 'undefined' ) {\n\n\t\t__THREE_DEVTOOLS__.dispatchEvent( new CustomEvent( 'observe', { detail: this } ) ); // eslint-disable-line no-undef\n\n\t}\n\n}\n\nexport { WebGLRenderer };\n","/**\n * @author mrdoob / http://mrdoob.com/\n * @author alteredq / http://alteredqualia.com/\n */\n\nimport { Color } from '../math/Color.js';\n\nfunction Fog( color, near, far ) {\n\n\tthis.name = '';\n\n\tthis.color = new Color( color );\n\n\tthis.near = ( near !== undefined ) ? near : 1;\n\tthis.far = ( far !== undefined ) ? far : 1000;\n\n}\n\nObject.assign( Fog.prototype, {\n\n\tisFog: true,\n\n\tclone: function () {\n\n\t\treturn new Fog( this.color, this.near, this.far );\n\n\t},\n\n\ttoJSON: function ( /* meta */ ) {\n\n\t\treturn {\n\t\t\ttype: 'Fog',\n\t\t\tcolor: this.color.getHex(),\n\t\t\tnear: this.near,\n\t\t\tfar: this.far\n\t\t};\n\n\t}\n\n} );\n\nexport { Fog };\n","import { Material } from './Material.js';\nimport { Color } from '../math/Color.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author alteredq / http://alteredqualia.com/\n *\n * parameters = {\n * color: ,\n * opacity: ,\n *\n * linewidth: ,\n * linecap: \"round\",\n * linejoin: \"round\"\n * }\n */\n\nfunction LineBasicMaterial( parameters ) {\n\n\tMaterial.call( this );\n\n\tthis.type = 'LineBasicMaterial';\n\n\tthis.color = new Color( 0xffffff );\n\n\tthis.linewidth = 1;\n\tthis.linecap = 'round';\n\tthis.linejoin = 'round';\n\n\tthis.morphTargets = false;\n\n\tthis.setValues( parameters );\n\n}\n\nLineBasicMaterial.prototype = Object.create( Material.prototype );\nLineBasicMaterial.prototype.constructor = LineBasicMaterial;\n\nLineBasicMaterial.prototype.isLineBasicMaterial = true;\n\nLineBasicMaterial.prototype.copy = function ( source ) {\n\n\tMaterial.prototype.copy.call( this, source );\n\n\tthis.color.copy( source.color );\n\n\tthis.linewidth = source.linewidth;\n\tthis.linecap = source.linecap;\n\tthis.linejoin = source.linejoin;\n\n\tthis.morphTargets = source.morphTargets;\n\n\treturn this;\n\n};\n\n\nexport { LineBasicMaterial };\n","import { Sphere } from '../math/Sphere.js';\nimport { Ray } from '../math/Ray.js';\nimport { Matrix4 } from '../math/Matrix4.js';\nimport { Object3D } from '../core/Object3D.js';\nimport { Vector3 } from '../math/Vector3.js';\nimport { LineBasicMaterial } from '../materials/LineBasicMaterial.js';\nimport { BufferGeometry } from '../core/BufferGeometry.js';\nimport { Float32BufferAttribute } from '../core/BufferAttribute.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nconst _start = new Vector3();\nconst _end = new Vector3();\nconst _inverseMatrix = new Matrix4();\nconst _ray = new Ray();\nconst _sphere = new Sphere();\n\nfunction Line( geometry, material, mode ) {\n\n\tif ( mode === 1 ) {\n\n\t\tconsole.error( 'THREE.Line: parameter THREE.LinePieces no longer supported. Use THREE.LineSegments instead.' );\n\n\t}\n\n\tObject3D.call( this );\n\n\tthis.type = 'Line';\n\n\tthis.geometry = geometry !== undefined ? geometry : new BufferGeometry();\n\tthis.material = material !== undefined ? material : new LineBasicMaterial();\n\n\tthis.updateMorphTargets();\n\n}\n\nLine.prototype = Object.assign( Object.create( Object3D.prototype ), {\n\n\tconstructor: Line,\n\n\tisLine: true,\n\n\tcopy: function ( source ) {\n\n\t\tObject3D.prototype.copy.call( this, source );\n\n\t\tthis.material = source.material;\n\t\tthis.geometry = source.geometry;\n\n\t\treturn this;\n\n\t},\n\n\tcomputeLineDistances: function () {\n\n\t\tconst geometry = this.geometry;\n\n\t\tif ( geometry.isBufferGeometry ) {\n\n\t\t\t// we assume non-indexed geometry\n\n\t\t\tif ( geometry.index === null ) {\n\n\t\t\t\tconst positionAttribute = geometry.attributes.position;\n\t\t\t\tconst lineDistances = [ 0 ];\n\n\t\t\t\tfor ( let i = 1, l = positionAttribute.count; i < l; i ++ ) {\n\n\t\t\t\t\t_start.fromBufferAttribute( positionAttribute, i - 1 );\n\t\t\t\t\t_end.fromBufferAttribute( positionAttribute, i );\n\n\t\t\t\t\tlineDistances[ i ] = lineDistances[ i - 1 ];\n\t\t\t\t\tlineDistances[ i ] += _start.distanceTo( _end );\n\n\t\t\t\t}\n\n\t\t\t\tgeometry.setAttribute( 'lineDistance', new Float32BufferAttribute( lineDistances, 1 ) );\n\n\t\t\t} else {\n\n\t\t\t\tconsole.warn( 'THREE.Line.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.' );\n\n\t\t\t}\n\n\t\t} else if ( geometry.isGeometry ) {\n\n\t\t\tconst vertices = geometry.vertices;\n\t\t\tconst lineDistances = geometry.lineDistances;\n\n\t\t\tlineDistances[ 0 ] = 0;\n\n\t\t\tfor ( let i = 1, l = vertices.length; i < l; i ++ ) {\n\n\t\t\t\tlineDistances[ i ] = lineDistances[ i - 1 ];\n\t\t\t\tlineDistances[ i ] += vertices[ i - 1 ].distanceTo( vertices[ i ] );\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn this;\n\n\t},\n\n\traycast: function ( raycaster, intersects ) {\n\n\t\tconst geometry = this.geometry;\n\t\tconst matrixWorld = this.matrixWorld;\n\t\tconst threshold = raycaster.params.Line.threshold;\n\n\t\t// Checking boundingSphere distance to ray\n\n\t\tif ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();\n\n\t\t_sphere.copy( geometry.boundingSphere );\n\t\t_sphere.applyMatrix4( matrixWorld );\n\t\t_sphere.radius += threshold;\n\n\t\tif ( raycaster.ray.intersectsSphere( _sphere ) === false ) return;\n\n\t\t//\n\n\t\t_inverseMatrix.getInverse( matrixWorld );\n\t\t_ray.copy( raycaster.ray ).applyMatrix4( _inverseMatrix );\n\n\t\tconst localThreshold = threshold / ( ( this.scale.x + this.scale.y + this.scale.z ) / 3 );\n\t\tconst localThresholdSq = localThreshold * localThreshold;\n\n\t\tconst vStart = new Vector3();\n\t\tconst vEnd = new Vector3();\n\t\tconst interSegment = new Vector3();\n\t\tconst interRay = new Vector3();\n\t\tconst step = ( this && this.isLineSegments ) ? 2 : 1;\n\n\t\tif ( geometry.isBufferGeometry ) {\n\n\t\t\tconst index = geometry.index;\n\t\t\tconst attributes = geometry.attributes;\n\t\t\tconst positions = attributes.position.array;\n\n\t\t\tif ( index !== null ) {\n\n\t\t\t\tconst indices = index.array;\n\n\t\t\t\tfor ( let i = 0, l = indices.length - 1; i < l; i += step ) {\n\n\t\t\t\t\tconst a = indices[ i ];\n\t\t\t\t\tconst b = indices[ i + 1 ];\n\n\t\t\t\t\tvStart.fromArray( positions, a * 3 );\n\t\t\t\t\tvEnd.fromArray( positions, b * 3 );\n\n\t\t\t\t\tconst distSq = _ray.distanceSqToSegment( vStart, vEnd, interRay, interSegment );\n\n\t\t\t\t\tif ( distSq > localThresholdSq ) continue;\n\n\t\t\t\t\tinterRay.applyMatrix4( this.matrixWorld ); //Move back to world space for distance calculation\n\n\t\t\t\t\tconst distance = raycaster.ray.origin.distanceTo( interRay );\n\n\t\t\t\t\tif ( distance < raycaster.near || distance > raycaster.far ) continue;\n\n\t\t\t\t\tintersects.push( {\n\n\t\t\t\t\t\tdistance: distance,\n\t\t\t\t\t\t// What do we want? intersection point on the ray or on the segment??\n\t\t\t\t\t\t// point: raycaster.ray.at( distance ),\n\t\t\t\t\t\tpoint: interSegment.clone().applyMatrix4( this.matrixWorld ),\n\t\t\t\t\t\tindex: i,\n\t\t\t\t\t\tface: null,\n\t\t\t\t\t\tfaceIndex: null,\n\t\t\t\t\t\tobject: this\n\n\t\t\t\t\t} );\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\tfor ( let i = 0, l = positions.length / 3 - 1; i < l; i += step ) {\n\n\t\t\t\t\tvStart.fromArray( positions, 3 * i );\n\t\t\t\t\tvEnd.fromArray( positions, 3 * i + 3 );\n\n\t\t\t\t\tconst distSq = _ray.distanceSqToSegment( vStart, vEnd, interRay, interSegment );\n\n\t\t\t\t\tif ( distSq > localThresholdSq ) continue;\n\n\t\t\t\t\tinterRay.applyMatrix4( this.matrixWorld ); //Move back to world space for distance calculation\n\n\t\t\t\t\tconst distance = raycaster.ray.origin.distanceTo( interRay );\n\n\t\t\t\t\tif ( distance < raycaster.near || distance > raycaster.far ) continue;\n\n\t\t\t\t\tintersects.push( {\n\n\t\t\t\t\t\tdistance: distance,\n\t\t\t\t\t\t// What do we want? intersection point on the ray or on the segment??\n\t\t\t\t\t\t// point: raycaster.ray.at( distance ),\n\t\t\t\t\t\tpoint: interSegment.clone().applyMatrix4( this.matrixWorld ),\n\t\t\t\t\t\tindex: i,\n\t\t\t\t\t\tface: null,\n\t\t\t\t\t\tfaceIndex: null,\n\t\t\t\t\t\tobject: this\n\n\t\t\t\t\t} );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} else if ( geometry.isGeometry ) {\n\n\t\t\tconst vertices = geometry.vertices;\n\t\t\tconst nbVertices = vertices.length;\n\n\t\t\tfor ( let i = 0; i < nbVertices - 1; i += step ) {\n\n\t\t\t\tconst distSq = _ray.distanceSqToSegment( vertices[ i ], vertices[ i + 1 ], interRay, interSegment );\n\n\t\t\t\tif ( distSq > localThresholdSq ) continue;\n\n\t\t\t\tinterRay.applyMatrix4( this.matrixWorld ); //Move back to world space for distance calculation\n\n\t\t\t\tconst distance = raycaster.ray.origin.distanceTo( interRay );\n\n\t\t\t\tif ( distance < raycaster.near || distance > raycaster.far ) continue;\n\n\t\t\t\tintersects.push( {\n\n\t\t\t\t\tdistance: distance,\n\t\t\t\t\t// What do we want? intersection point on the ray or on the segment??\n\t\t\t\t\t// point: raycaster.ray.at( distance ),\n\t\t\t\t\tpoint: interSegment.clone().applyMatrix4( this.matrixWorld ),\n\t\t\t\t\tindex: i,\n\t\t\t\t\tface: null,\n\t\t\t\t\tfaceIndex: null,\n\t\t\t\t\tobject: this\n\n\t\t\t\t} );\n\n\t\t\t}\n\n\t\t}\n\n\t},\n\n\tupdateMorphTargets: function () {\n\n\t\tconst geometry = this.geometry;\n\n\t\tif ( geometry.isBufferGeometry ) {\n\n\t\t\tconst morphAttributes = geometry.morphAttributes;\n\t\t\tconst keys = Object.keys( morphAttributes );\n\n\t\t\tif ( keys.length > 0 ) {\n\n\t\t\t\tconst morphAttribute = morphAttributes[ keys[ 0 ] ];\n\n\t\t\t\tif ( morphAttribute !== undefined ) {\n\n\t\t\t\t\tthis.morphTargetInfluences = [];\n\t\t\t\t\tthis.morphTargetDictionary = {};\n\n\t\t\t\t\tfor ( let m = 0, ml = morphAttribute.length; m < ml; m ++ ) {\n\n\t\t\t\t\t\tconst name = morphAttribute[ m ].name || String( m );\n\n\t\t\t\t\t\tthis.morphTargetInfluences.push( 0 );\n\t\t\t\t\t\tthis.morphTargetDictionary[ name ] = m;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tconst morphTargets = geometry.morphTargets;\n\n\t\t\tif ( morphTargets !== undefined && morphTargets.length > 0 ) {\n\n\t\t\t\tconsole.error( 'THREE.Line.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.' );\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n} );\n\n\nexport { Line };\n","import { Line } from './Line.js';\nimport { Vector3 } from '../math/Vector3.js';\nimport { Float32BufferAttribute } from '../core/BufferAttribute.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nconst _start = new Vector3();\nconst _end = new Vector3();\n\nfunction LineSegments( geometry, material ) {\n\n\tLine.call( this, geometry, material );\n\n\tthis.type = 'LineSegments';\n\n}\n\nLineSegments.prototype = Object.assign( Object.create( Line.prototype ), {\n\n\tconstructor: LineSegments,\n\n\tisLineSegments: true,\n\n\tcomputeLineDistances: function () {\n\n\t\tconst geometry = this.geometry;\n\n\t\tif ( geometry.isBufferGeometry ) {\n\n\t\t\t// we assume non-indexed geometry\n\n\t\t\tif ( geometry.index === null ) {\n\n\t\t\t\tconst positionAttribute = geometry.attributes.position;\n\t\t\t\tconst lineDistances = [];\n\n\t\t\t\tfor ( let i = 0, l = positionAttribute.count; i < l; i += 2 ) {\n\n\t\t\t\t\t_start.fromBufferAttribute( positionAttribute, i );\n\t\t\t\t\t_end.fromBufferAttribute( positionAttribute, i + 1 );\n\n\t\t\t\t\tlineDistances[ i ] = ( i === 0 ) ? 0 : lineDistances[ i - 1 ];\n\t\t\t\t\tlineDistances[ i + 1 ] = lineDistances[ i ] + _start.distanceTo( _end );\n\n\t\t\t\t}\n\n\t\t\t\tgeometry.setAttribute( 'lineDistance', new Float32BufferAttribute( lineDistances, 1 ) );\n\n\t\t\t} else {\n\n\t\t\t\tconsole.warn( 'THREE.LineSegments.computeLineDistances(): Computation only possible with non-indexed BufferGeometry.' );\n\n\t\t\t}\n\n\t\t} else if ( geometry.isGeometry ) {\n\n\t\t\tconst vertices = geometry.vertices;\n\t\t\tconst lineDistances = geometry.lineDistances;\n\n\t\t\tfor ( let i = 0, l = vertices.length; i < l; i += 2 ) {\n\n\t\t\t\t_start.copy( vertices[ i ] );\n\t\t\t\t_end.copy( vertices[ i + 1 ] );\n\n\t\t\t\tlineDistances[ i ] = ( i === 0 ) ? 0 : lineDistances[ i - 1 ];\n\t\t\t\tlineDistances[ i + 1 ] = lineDistances[ i ] + _start.distanceTo( _end );\n\n\t\t\t}\n\n\t\t}\n\n\t\treturn this;\n\n\t}\n\n} );\n\n\nexport { LineSegments };\n","import { Material } from './Material.js';\nimport { Color } from '../math/Color.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author alteredq / http://alteredqualia.com/\n *\n * parameters = {\n * color: ,\n * opacity: ,\n * map: new THREE.Texture( ),\n * alphaMap: new THREE.Texture( ),\n *\n * size: ,\n * sizeAttenuation: \n *\n * morphTargets: \n * }\n */\n\nfunction PointsMaterial( parameters ) {\n\n\tMaterial.call( this );\n\n\tthis.type = 'PointsMaterial';\n\n\tthis.color = new Color( 0xffffff );\n\n\tthis.map = null;\n\n\tthis.alphaMap = null;\n\n\tthis.size = 1;\n\tthis.sizeAttenuation = true;\n\n\tthis.morphTargets = false;\n\n\tthis.setValues( parameters );\n\n}\n\nPointsMaterial.prototype = Object.create( Material.prototype );\nPointsMaterial.prototype.constructor = PointsMaterial;\n\nPointsMaterial.prototype.isPointsMaterial = true;\n\nPointsMaterial.prototype.copy = function ( source ) {\n\n\tMaterial.prototype.copy.call( this, source );\n\n\tthis.color.copy( source.color );\n\n\tthis.map = source.map;\n\n\tthis.alphaMap = source.alphaMap;\n\n\tthis.size = source.size;\n\tthis.sizeAttenuation = source.sizeAttenuation;\n\n\tthis.morphTargets = source.morphTargets;\n\n\treturn this;\n\n};\n\n\nexport { PointsMaterial };\n","import { Sphere } from '../math/Sphere.js';\nimport { Ray } from '../math/Ray.js';\nimport { Matrix4 } from '../math/Matrix4.js';\nimport { Object3D } from '../core/Object3D.js';\nimport { Vector3 } from '../math/Vector3.js';\nimport { PointsMaterial } from '../materials/PointsMaterial.js';\nimport { BufferGeometry } from '../core/BufferGeometry.js';\n\n/**\n * @author alteredq / http://alteredqualia.com/\n */\n\nconst _inverseMatrix = new Matrix4();\nconst _ray = new Ray();\nconst _sphere = new Sphere();\nconst _position = new Vector3();\n\nfunction Points( geometry, material ) {\n\n\tObject3D.call( this );\n\n\tthis.type = 'Points';\n\n\tthis.geometry = geometry !== undefined ? geometry : new BufferGeometry();\n\tthis.material = material !== undefined ? material : new PointsMaterial();\n\n\tthis.updateMorphTargets();\n\n}\n\nPoints.prototype = Object.assign( Object.create( Object3D.prototype ), {\n\n\tconstructor: Points,\n\n\tisPoints: true,\n\n\tcopy: function ( source ) {\n\n\t\tObject3D.prototype.copy.call( this, source );\n\n\t\tthis.material = source.material;\n\t\tthis.geometry = source.geometry;\n\n\t\treturn this;\n\n\t},\n\n\traycast: function ( raycaster, intersects ) {\n\n\t\tconst geometry = this.geometry;\n\t\tconst matrixWorld = this.matrixWorld;\n\t\tconst threshold = raycaster.params.Points.threshold;\n\n\t\t// Checking boundingSphere distance to ray\n\n\t\tif ( geometry.boundingSphere === null ) geometry.computeBoundingSphere();\n\n\t\t_sphere.copy( geometry.boundingSphere );\n\t\t_sphere.applyMatrix4( matrixWorld );\n\t\t_sphere.radius += threshold;\n\n\t\tif ( raycaster.ray.intersectsSphere( _sphere ) === false ) return;\n\n\t\t//\n\n\t\t_inverseMatrix.getInverse( matrixWorld );\n\t\t_ray.copy( raycaster.ray ).applyMatrix4( _inverseMatrix );\n\n\t\tconst localThreshold = threshold / ( ( this.scale.x + this.scale.y + this.scale.z ) / 3 );\n\t\tconst localThresholdSq = localThreshold * localThreshold;\n\n\t\tif ( geometry.isBufferGeometry ) {\n\n\t\t\tconst index = geometry.index;\n\t\t\tconst attributes = geometry.attributes;\n\t\t\tconst positions = attributes.position.array;\n\n\t\t\tif ( index !== null ) {\n\n\t\t\t\tconst indices = index.array;\n\n\t\t\t\tfor ( let i = 0, il = indices.length; i < il; i ++ ) {\n\n\t\t\t\t\tconst a = indices[ i ];\n\n\t\t\t\t\t_position.fromArray( positions, a * 3 );\n\n\t\t\t\t\ttestPoint( _position, a, localThresholdSq, matrixWorld, raycaster, intersects, this );\n\n\t\t\t\t}\n\n\t\t\t} else {\n\n\t\t\t\tfor ( let i = 0, l = positions.length / 3; i < l; i ++ ) {\n\n\t\t\t\t\t_position.fromArray( positions, i * 3 );\n\n\t\t\t\t\ttestPoint( _position, i, localThresholdSq, matrixWorld, raycaster, intersects, this );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tconst vertices = geometry.vertices;\n\n\t\t\tfor ( let i = 0, l = vertices.length; i < l; i ++ ) {\n\n\t\t\t\ttestPoint( vertices[ i ], i, localThresholdSq, matrixWorld, raycaster, intersects, this );\n\n\t\t\t}\n\n\t\t}\n\n\t},\n\n\tupdateMorphTargets: function () {\n\n\t\tconst geometry = this.geometry;\n\n\t\tif ( geometry.isBufferGeometry ) {\n\n\t\t\tconst morphAttributes = geometry.morphAttributes;\n\t\t\tconst keys = Object.keys( morphAttributes );\n\n\t\t\tif ( keys.length > 0 ) {\n\n\t\t\t\tconst morphAttribute = morphAttributes[ keys[ 0 ] ];\n\n\t\t\t\tif ( morphAttribute !== undefined ) {\n\n\t\t\t\t\tthis.morphTargetInfluences = [];\n\t\t\t\t\tthis.morphTargetDictionary = {};\n\n\t\t\t\t\tfor ( let m = 0, ml = morphAttribute.length; m < ml; m ++ ) {\n\n\t\t\t\t\t\tconst name = morphAttribute[ m ].name || String( m );\n\n\t\t\t\t\t\tthis.morphTargetInfluences.push( 0 );\n\t\t\t\t\t\tthis.morphTargetDictionary[ name ] = m;\n\n\t\t\t\t\t}\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t} else {\n\n\t\t\tconst morphTargets = geometry.morphTargets;\n\n\t\t\tif ( morphTargets !== undefined && morphTargets.length > 0 ) {\n\n\t\t\t\tconsole.error( 'THREE.Points.updateMorphTargets() does not support THREE.Geometry. Use THREE.BufferGeometry instead.' );\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n} );\n\nfunction testPoint( point, index, localThresholdSq, matrixWorld, raycaster, intersects, object ) {\n\n\tconst rayPointDistanceSq = _ray.distanceSqToPoint( point );\n\n\tif ( rayPointDistanceSq < localThresholdSq ) {\n\n\t\tconst intersectPoint = new Vector3();\n\n\t\t_ray.closestPointToPoint( point, intersectPoint );\n\t\tintersectPoint.applyMatrix4( matrixWorld );\n\n\t\tconst distance = raycaster.ray.origin.distanceTo( intersectPoint );\n\n\t\tif ( distance < raycaster.near || distance > raycaster.far ) return;\n\n\t\tintersects.push( {\n\n\t\t\tdistance: distance,\n\t\t\tdistanceToRay: Math.sqrt( rayPointDistanceSq ),\n\t\t\tpoint: intersectPoint,\n\t\t\tindex: index,\n\t\t\tface: null,\n\t\t\tobject: object\n\n\t\t} );\n\n\t}\n\n}\n\nexport { Points };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nimport { Texture } from './Texture.js';\n\nfunction CanvasTexture( canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy ) {\n\n\tTexture.call( this, canvas, mapping, wrapS, wrapT, magFilter, minFilter, format, type, anisotropy );\n\n\tthis.needsUpdate = true;\n\n}\n\nCanvasTexture.prototype = Object.create( Texture.prototype );\nCanvasTexture.prototype.constructor = CanvasTexture;\nCanvasTexture.prototype.isCanvasTexture = true;\n\nexport { CanvasTexture };\n","/**\n * @author clockworkgeek / https://github.com/clockworkgeek\n * @author timothypratley / https://github.com/timothypratley\n * @author WestLangley / http://github.com/WestLangley\n * @author Mugen87 / https://github.com/Mugen87\n */\n\nimport { Geometry } from '../core/Geometry.js';\nimport { BufferGeometry } from '../core/BufferGeometry.js';\nimport { Float32BufferAttribute } from '../core/BufferAttribute.js';\nimport { Vector3 } from '../math/Vector3.js';\nimport { Vector2 } from '../math/Vector2.js';\n\n// PolyhedronGeometry\n\nfunction PolyhedronGeometry( vertices, indices, radius, detail ) {\n\n\tGeometry.call( this );\n\n\tthis.type = 'PolyhedronGeometry';\n\n\tthis.parameters = {\n\t\tvertices: vertices,\n\t\tindices: indices,\n\t\tradius: radius,\n\t\tdetail: detail\n\t};\n\n\tthis.fromBufferGeometry( new PolyhedronBufferGeometry( vertices, indices, radius, detail ) );\n\tthis.mergeVertices();\n\n}\n\nPolyhedronGeometry.prototype = Object.create( Geometry.prototype );\nPolyhedronGeometry.prototype.constructor = PolyhedronGeometry;\n\n// PolyhedronBufferGeometry\n\nfunction PolyhedronBufferGeometry( vertices, indices, radius, detail ) {\n\n\tBufferGeometry.call( this );\n\n\tthis.type = 'PolyhedronBufferGeometry';\n\n\tthis.parameters = {\n\t\tvertices: vertices,\n\t\tindices: indices,\n\t\tradius: radius,\n\t\tdetail: detail\n\t};\n\n\tradius = radius || 1;\n\tdetail = detail || 0;\n\n\t// default buffer data\n\n\tconst vertexBuffer = [];\n\tconst uvBuffer = [];\n\n\t// the subdivision creates the vertex buffer data\n\n\tsubdivide( detail );\n\n\t// all vertices should lie on a conceptual sphere with a given radius\n\n\tapplyRadius( radius );\n\n\t// finally, create the uv data\n\n\tgenerateUVs();\n\n\t// build non-indexed geometry\n\n\tthis.setAttribute( 'position', new Float32BufferAttribute( vertexBuffer, 3 ) );\n\tthis.setAttribute( 'normal', new Float32BufferAttribute( vertexBuffer.slice(), 3 ) );\n\tthis.setAttribute( 'uv', new Float32BufferAttribute( uvBuffer, 2 ) );\n\n\tif ( detail === 0 ) {\n\n\t\tthis.computeVertexNormals(); // flat normals\n\n\t} else {\n\n\t\tthis.normalizeNormals(); // smooth normals\n\n\t}\n\n\t// helper functions\n\n\tfunction subdivide( detail ) {\n\n\t\tconst a = new Vector3();\n\t\tconst b = new Vector3();\n\t\tconst c = new Vector3();\n\n\t\t// iterate over all faces and apply a subdivison with the given detail value\n\n\t\tfor ( let i = 0; i < indices.length; i += 3 ) {\n\n\t\t\t// get the vertices of the face\n\n\t\t\tgetVertexByIndex( indices[ i + 0 ], a );\n\t\t\tgetVertexByIndex( indices[ i + 1 ], b );\n\t\t\tgetVertexByIndex( indices[ i + 2 ], c );\n\n\t\t\t// perform subdivision\n\n\t\t\tsubdivideFace( a, b, c, detail );\n\n\t\t}\n\n\t}\n\n\tfunction subdivideFace( a, b, c, detail ) {\n\n\t\tconst cols = Math.pow( 2, detail );\n\n\t\t// we use this multidimensional array as a data structure for creating the subdivision\n\n\t\tconst v = [];\n\n\t\t// construct all of the vertices for this subdivision\n\n\t\tfor ( let i = 0; i <= cols; i ++ ) {\n\n\t\t\tv[ i ] = [];\n\n\t\t\tconst aj = a.clone().lerp( c, i / cols );\n\t\t\tconst bj = b.clone().lerp( c, i / cols );\n\n\t\t\tconst rows = cols - i;\n\n\t\t\tfor ( let j = 0; j <= rows; j ++ ) {\n\n\t\t\t\tif ( j === 0 && i === cols ) {\n\n\t\t\t\t\tv[ i ][ j ] = aj;\n\n\t\t\t\t} else {\n\n\t\t\t\t\tv[ i ][ j ] = aj.clone().lerp( bj, j / rows );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t\t// construct all of the faces\n\n\t\tfor ( let i = 0; i < cols; i ++ ) {\n\n\t\t\tfor ( let j = 0; j < 2 * ( cols - i ) - 1; j ++ ) {\n\n\t\t\t\tconst k = Math.floor( j / 2 );\n\n\t\t\t\tif ( j % 2 === 0 ) {\n\n\t\t\t\t\tpushVertex( v[ i ][ k + 1 ] );\n\t\t\t\t\tpushVertex( v[ i + 1 ][ k ] );\n\t\t\t\t\tpushVertex( v[ i ][ k ] );\n\n\t\t\t\t} else {\n\n\t\t\t\t\tpushVertex( v[ i ][ k + 1 ] );\n\t\t\t\t\tpushVertex( v[ i + 1 ][ k + 1 ] );\n\t\t\t\t\tpushVertex( v[ i + 1 ][ k ] );\n\n\t\t\t\t}\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tfunction applyRadius( radius ) {\n\n\t\tconst vertex = new Vector3();\n\n\t\t// iterate over the entire buffer and apply the radius to each vertex\n\n\t\tfor ( let i = 0; i < vertexBuffer.length; i += 3 ) {\n\n\t\t\tvertex.x = vertexBuffer[ i + 0 ];\n\t\t\tvertex.y = vertexBuffer[ i + 1 ];\n\t\t\tvertex.z = vertexBuffer[ i + 2 ];\n\n\t\t\tvertex.normalize().multiplyScalar( radius );\n\n\t\t\tvertexBuffer[ i + 0 ] = vertex.x;\n\t\t\tvertexBuffer[ i + 1 ] = vertex.y;\n\t\t\tvertexBuffer[ i + 2 ] = vertex.z;\n\n\t\t}\n\n\t}\n\n\tfunction generateUVs() {\n\n\t\tconst vertex = new Vector3();\n\n\t\tfor ( let i = 0; i < vertexBuffer.length; i += 3 ) {\n\n\t\t\tvertex.x = vertexBuffer[ i + 0 ];\n\t\t\tvertex.y = vertexBuffer[ i + 1 ];\n\t\t\tvertex.z = vertexBuffer[ i + 2 ];\n\n\t\t\tconst u = azimuth( vertex ) / 2 / Math.PI + 0.5;\n\t\t\tconst v = inclination( vertex ) / Math.PI + 0.5;\n\t\t\tuvBuffer.push( u, 1 - v );\n\n\t\t}\n\n\t\tcorrectUVs();\n\n\t\tcorrectSeam();\n\n\t}\n\n\tfunction correctSeam() {\n\n\t\t// handle case when face straddles the seam, see #3269\n\n\t\tfor ( let i = 0; i < uvBuffer.length; i += 6 ) {\n\n\t\t\t// uv data of a single face\n\n\t\t\tconst x0 = uvBuffer[ i + 0 ];\n\t\t\tconst x1 = uvBuffer[ i + 2 ];\n\t\t\tconst x2 = uvBuffer[ i + 4 ];\n\n\t\t\tconst max = Math.max( x0, x1, x2 );\n\t\t\tconst min = Math.min( x0, x1, x2 );\n\n\t\t\t// 0.9 is somewhat arbitrary\n\n\t\t\tif ( max > 0.9 && min < 0.1 ) {\n\n\t\t\t\tif ( x0 < 0.2 ) uvBuffer[ i + 0 ] += 1;\n\t\t\t\tif ( x1 < 0.2 ) uvBuffer[ i + 2 ] += 1;\n\t\t\t\tif ( x2 < 0.2 ) uvBuffer[ i + 4 ] += 1;\n\n\t\t\t}\n\n\t\t}\n\n\t}\n\n\tfunction pushVertex( vertex ) {\n\n\t\tvertexBuffer.push( vertex.x, vertex.y, vertex.z );\n\n\t}\n\n\tfunction getVertexByIndex( index, vertex ) {\n\n\t\tconst stride = index * 3;\n\n\t\tvertex.x = vertices[ stride + 0 ];\n\t\tvertex.y = vertices[ stride + 1 ];\n\t\tvertex.z = vertices[ stride + 2 ];\n\n\t}\n\n\tfunction correctUVs() {\n\n\t\tconst a = new Vector3();\n\t\tconst b = new Vector3();\n\t\tconst c = new Vector3();\n\n\t\tconst centroid = new Vector3();\n\n\t\tconst uvA = new Vector2();\n\t\tconst uvB = new Vector2();\n\t\tconst uvC = new Vector2();\n\n\t\tfor ( let i = 0, j = 0; i < vertexBuffer.length; i += 9, j += 6 ) {\n\n\t\t\ta.set( vertexBuffer[ i + 0 ], vertexBuffer[ i + 1 ], vertexBuffer[ i + 2 ] );\n\t\t\tb.set( vertexBuffer[ i + 3 ], vertexBuffer[ i + 4 ], vertexBuffer[ i + 5 ] );\n\t\t\tc.set( vertexBuffer[ i + 6 ], vertexBuffer[ i + 7 ], vertexBuffer[ i + 8 ] );\n\n\t\t\tuvA.set( uvBuffer[ j + 0 ], uvBuffer[ j + 1 ] );\n\t\t\tuvB.set( uvBuffer[ j + 2 ], uvBuffer[ j + 3 ] );\n\t\t\tuvC.set( uvBuffer[ j + 4 ], uvBuffer[ j + 5 ] );\n\n\t\t\tcentroid.copy( a ).add( b ).add( c ).divideScalar( 3 );\n\n\t\t\tconst azi = azimuth( centroid );\n\n\t\t\tcorrectUV( uvA, j + 0, a, azi );\n\t\t\tcorrectUV( uvB, j + 2, b, azi );\n\t\t\tcorrectUV( uvC, j + 4, c, azi );\n\n\t\t}\n\n\t}\n\n\tfunction correctUV( uv, stride, vector, azimuth ) {\n\n\t\tif ( ( azimuth < 0 ) && ( uv.x === 1 ) ) {\n\n\t\t\tuvBuffer[ stride ] = uv.x - 1;\n\n\t\t}\n\n\t\tif ( ( vector.x === 0 ) && ( vector.z === 0 ) ) {\n\n\t\t\tuvBuffer[ stride ] = azimuth / 2 / Math.PI + 0.5;\n\n\t\t}\n\n\t}\n\n\t// Angle around the Y axis, counter-clockwise when looking from above.\n\n\tfunction azimuth( vector ) {\n\n\t\treturn Math.atan2( vector.z, - vector.x );\n\n\t}\n\n\n\t// Angle above the XZ plane.\n\n\tfunction inclination( vector ) {\n\n\t\treturn Math.atan2( - vector.y, Math.sqrt( ( vector.x * vector.x ) + ( vector.z * vector.z ) ) );\n\n\t}\n\n}\n\nPolyhedronBufferGeometry.prototype = Object.create( BufferGeometry.prototype );\nPolyhedronBufferGeometry.prototype.constructor = PolyhedronBufferGeometry;\n\n\nexport { PolyhedronGeometry, PolyhedronBufferGeometry };\n","/**\n * @author timothypratley / https://github.com/timothypratley\n * @author Mugen87 / https://github.com/Mugen87\n */\n\nimport { Geometry } from '../core/Geometry.js';\nimport { PolyhedronBufferGeometry } from './PolyhedronGeometry.js';\n\n// TetrahedronGeometry\n\nfunction TetrahedronGeometry( radius, detail ) {\n\n\tGeometry.call( this );\n\n\tthis.type = 'TetrahedronGeometry';\n\n\tthis.parameters = {\n\t\tradius: radius,\n\t\tdetail: detail\n\t};\n\n\tthis.fromBufferGeometry( new TetrahedronBufferGeometry( radius, detail ) );\n\tthis.mergeVertices();\n\n}\n\nTetrahedronGeometry.prototype = Object.create( Geometry.prototype );\nTetrahedronGeometry.prototype.constructor = TetrahedronGeometry;\n\n// TetrahedronBufferGeometry\n\nfunction TetrahedronBufferGeometry( radius, detail ) {\n\n\tconst vertices = [\n\t\t1, 1, 1, \t- 1, - 1, 1, \t- 1, 1, - 1, \t1, - 1, - 1\n\t];\n\n\tconst indices = [\n\t\t2, 1, 0, \t0, 3, 2,\t1, 3, 0,\t2, 3, 1\n\t];\n\n\tPolyhedronBufferGeometry.call( this, vertices, indices, radius, detail );\n\n\tthis.type = 'TetrahedronBufferGeometry';\n\n\tthis.parameters = {\n\t\tradius: radius,\n\t\tdetail: detail\n\t};\n\n}\n\nTetrahedronBufferGeometry.prototype = Object.create( PolyhedronBufferGeometry.prototype );\nTetrahedronBufferGeometry.prototype.constructor = TetrahedronBufferGeometry;\n\n\nexport { TetrahedronGeometry, TetrahedronBufferGeometry };\n","/**\n * @author timothypratley / https://github.com/timothypratley\n * @author Mugen87 / https://github.com/Mugen87\n */\n\nimport { Geometry } from '../core/Geometry.js';\nimport { PolyhedronBufferGeometry } from './PolyhedronGeometry.js';\n\n// OctahedronGeometry\n\nfunction OctahedronGeometry( radius, detail ) {\n\n\tGeometry.call( this );\n\n\tthis.type = 'OctahedronGeometry';\n\n\tthis.parameters = {\n\t\tradius: radius,\n\t\tdetail: detail\n\t};\n\n\tthis.fromBufferGeometry( new OctahedronBufferGeometry( radius, detail ) );\n\tthis.mergeVertices();\n\n}\n\nOctahedronGeometry.prototype = Object.create( Geometry.prototype );\nOctahedronGeometry.prototype.constructor = OctahedronGeometry;\n\n// OctahedronBufferGeometry\n\nfunction OctahedronBufferGeometry( radius, detail ) {\n\n\tconst vertices = [\n\t\t1, 0, 0, \t- 1, 0, 0,\t0, 1, 0,\n\t\t0, - 1, 0, \t0, 0, 1,\t0, 0, - 1\n\t];\n\n\tconst indices = [\n\t\t0, 2, 4,\t0, 4, 3,\t0, 3, 5,\n\t\t0, 5, 2,\t1, 2, 5,\t1, 5, 3,\n\t\t1, 3, 4,\t1, 4, 2\n\t];\n\n\tPolyhedronBufferGeometry.call( this, vertices, indices, radius, detail );\n\n\tthis.type = 'OctahedronBufferGeometry';\n\n\tthis.parameters = {\n\t\tradius: radius,\n\t\tdetail: detail\n\t};\n\n}\n\nOctahedronBufferGeometry.prototype = Object.create( PolyhedronBufferGeometry.prototype );\nOctahedronBufferGeometry.prototype.constructor = OctahedronBufferGeometry;\n\n\nexport { OctahedronGeometry, OctahedronBufferGeometry };\n","/**\n * @author timothypratley / https://github.com/timothypratley\n * @author Mugen87 / https://github.com/Mugen87\n */\n\nimport { Geometry } from '../core/Geometry.js';\nimport { PolyhedronBufferGeometry } from './PolyhedronGeometry.js';\n\n// IcosahedronGeometry\n\nfunction IcosahedronGeometry( radius, detail ) {\n\n\tGeometry.call( this );\n\n\tthis.type = 'IcosahedronGeometry';\n\n\tthis.parameters = {\n\t\tradius: radius,\n\t\tdetail: detail\n\t};\n\n\tthis.fromBufferGeometry( new IcosahedronBufferGeometry( radius, detail ) );\n\tthis.mergeVertices();\n\n}\n\nIcosahedronGeometry.prototype = Object.create( Geometry.prototype );\nIcosahedronGeometry.prototype.constructor = IcosahedronGeometry;\n\n// IcosahedronBufferGeometry\n\nfunction IcosahedronBufferGeometry( radius, detail ) {\n\n\tconst t = ( 1 + Math.sqrt( 5 ) ) / 2;\n\n\tconst vertices = [\n\t\t- 1, t, 0, \t1, t, 0, \t- 1, - t, 0, \t1, - t, 0,\n\t\t 0, - 1, t, \t0, 1, t,\t0, - 1, - t, \t0, 1, - t,\n\t\t t, 0, - 1, \tt, 0, 1, \t- t, 0, - 1, \t- t, 0, 1\n\t];\n\n\tconst indices = [\n\t\t 0, 11, 5, \t0, 5, 1, \t0, 1, 7, \t0, 7, 10, \t0, 10, 11,\n\t\t 1, 5, 9, \t5, 11, 4,\t11, 10, 2,\t10, 7, 6,\t7, 1, 8,\n\t\t 3, 9, 4, \t3, 4, 2,\t3, 2, 6,\t3, 6, 8,\t3, 8, 9,\n\t\t 4, 9, 5, \t2, 4, 11,\t6, 2, 10,\t8, 6, 7,\t9, 8, 1\n\t];\n\n\tPolyhedronBufferGeometry.call( this, vertices, indices, radius, detail );\n\n\tthis.type = 'IcosahedronBufferGeometry';\n\n\tthis.parameters = {\n\t\tradius: radius,\n\t\tdetail: detail\n\t};\n\n}\n\nIcosahedronBufferGeometry.prototype = Object.create( PolyhedronBufferGeometry.prototype );\nIcosahedronBufferGeometry.prototype.constructor = IcosahedronBufferGeometry;\n\n\nexport { IcosahedronGeometry, IcosahedronBufferGeometry };\n","/**\n * @author oosmoxiecode\n * @author mrdoob / http://mrdoob.com/\n * @author Mugen87 / https://github.com/Mugen87\n */\n\nimport { Geometry } from '../core/Geometry.js';\nimport { BufferGeometry } from '../core/BufferGeometry.js';\nimport { Float32BufferAttribute } from '../core/BufferAttribute.js';\nimport { Vector3 } from '../math/Vector3.js';\n\n// TorusGeometry\n\nfunction TorusGeometry( radius, tube, radialSegments, tubularSegments, arc ) {\n\n\tGeometry.call( this );\n\n\tthis.type = 'TorusGeometry';\n\n\tthis.parameters = {\n\t\tradius: radius,\n\t\ttube: tube,\n\t\tradialSegments: radialSegments,\n\t\ttubularSegments: tubularSegments,\n\t\tarc: arc\n\t};\n\n\tthis.fromBufferGeometry( new TorusBufferGeometry( radius, tube, radialSegments, tubularSegments, arc ) );\n\tthis.mergeVertices();\n\n}\n\nTorusGeometry.prototype = Object.create( Geometry.prototype );\nTorusGeometry.prototype.constructor = TorusGeometry;\n\n// TorusBufferGeometry\n\nfunction TorusBufferGeometry( radius, tube, radialSegments, tubularSegments, arc ) {\n\n\tBufferGeometry.call( this );\n\n\tthis.type = 'TorusBufferGeometry';\n\n\tthis.parameters = {\n\t\tradius: radius,\n\t\ttube: tube,\n\t\tradialSegments: radialSegments,\n\t\ttubularSegments: tubularSegments,\n\t\tarc: arc\n\t};\n\n\tradius = radius || 1;\n\ttube = tube || 0.4;\n\tradialSegments = Math.floor( radialSegments ) || 8;\n\ttubularSegments = Math.floor( tubularSegments ) || 6;\n\tarc = arc || Math.PI * 2;\n\n\t// buffers\n\n\tconst indices = [];\n\tconst vertices = [];\n\tconst normals = [];\n\tconst uvs = [];\n\n\t// helper variables\n\n\tconst center = new Vector3();\n\tconst vertex = new Vector3();\n\tconst normal = new Vector3();\n\n\t// generate vertices, normals and uvs\n\n\tfor ( let j = 0; j <= radialSegments; j ++ ) {\n\n\t\tfor ( let i = 0; i <= tubularSegments; i ++ ) {\n\n\t\t\tconst u = i / tubularSegments * arc;\n\t\t\tconst v = j / radialSegments * Math.PI * 2;\n\n\t\t\t// vertex\n\n\t\t\tvertex.x = ( radius + tube * Math.cos( v ) ) * Math.cos( u );\n\t\t\tvertex.y = ( radius + tube * Math.cos( v ) ) * Math.sin( u );\n\t\t\tvertex.z = tube * Math.sin( v );\n\n\t\t\tvertices.push( vertex.x, vertex.y, vertex.z );\n\n\t\t\t// normal\n\n\t\t\tcenter.x = radius * Math.cos( u );\n\t\t\tcenter.y = radius * Math.sin( u );\n\t\t\tnormal.subVectors( vertex, center ).normalize();\n\n\t\t\tnormals.push( normal.x, normal.y, normal.z );\n\n\t\t\t// uv\n\n\t\t\tuvs.push( i / tubularSegments );\n\t\t\tuvs.push( j / radialSegments );\n\n\t\t}\n\n\t}\n\n\t// generate indices\n\n\tfor ( let j = 1; j <= radialSegments; j ++ ) {\n\n\t\tfor ( let i = 1; i <= tubularSegments; i ++ ) {\n\n\t\t\t// indices\n\n\t\t\tconst a = ( tubularSegments + 1 ) * j + i - 1;\n\t\t\tconst b = ( tubularSegments + 1 ) * ( j - 1 ) + i - 1;\n\t\t\tconst c = ( tubularSegments + 1 ) * ( j - 1 ) + i;\n\t\t\tconst d = ( tubularSegments + 1 ) * j + i;\n\n\t\t\t// faces\n\n\t\t\tindices.push( a, b, d );\n\t\t\tindices.push( b, c, d );\n\n\t\t}\n\n\t}\n\n\t// build geometry\n\n\tthis.setIndex( indices );\n\tthis.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );\n\tthis.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );\n\tthis.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );\n\n}\n\nTorusBufferGeometry.prototype = Object.create( BufferGeometry.prototype );\nTorusBufferGeometry.prototype.constructor = TorusBufferGeometry;\n\n\nexport { TorusGeometry, TorusBufferGeometry };\n","/**\n * @author mrdoob / http://mrdoob.com/\n * @author Mugen87 / https://github.com/Mugen87\n */\n\nimport { Geometry } from '../core/Geometry.js';\nimport { BufferGeometry } from '../core/BufferGeometry.js';\nimport { Float32BufferAttribute } from '../core/BufferAttribute.js';\nimport { Vector3 } from '../math/Vector3.js';\nimport { Vector2 } from '../math/Vector2.js';\n\n// CylinderGeometry\n\nfunction CylinderGeometry( radiusTop, radiusBottom, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength ) {\n\n\tGeometry.call( this );\n\n\tthis.type = 'CylinderGeometry';\n\n\tthis.parameters = {\n\t\tradiusTop: radiusTop,\n\t\tradiusBottom: radiusBottom,\n\t\theight: height,\n\t\tradialSegments: radialSegments,\n\t\theightSegments: heightSegments,\n\t\topenEnded: openEnded,\n\t\tthetaStart: thetaStart,\n\t\tthetaLength: thetaLength\n\t};\n\n\tthis.fromBufferGeometry( new CylinderBufferGeometry( radiusTop, radiusBottom, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength ) );\n\tthis.mergeVertices();\n\n}\n\nCylinderGeometry.prototype = Object.create( Geometry.prototype );\nCylinderGeometry.prototype.constructor = CylinderGeometry;\n\n// CylinderBufferGeometry\n\nfunction CylinderBufferGeometry( radiusTop, radiusBottom, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength ) {\n\n\tBufferGeometry.call( this );\n\n\tthis.type = 'CylinderBufferGeometry';\n\n\tthis.parameters = {\n\t\tradiusTop: radiusTop,\n\t\tradiusBottom: radiusBottom,\n\t\theight: height,\n\t\tradialSegments: radialSegments,\n\t\theightSegments: heightSegments,\n\t\topenEnded: openEnded,\n\t\tthetaStart: thetaStart,\n\t\tthetaLength: thetaLength\n\t};\n\n\tconst scope = this;\n\n\tradiusTop = radiusTop !== undefined ? radiusTop : 1;\n\tradiusBottom = radiusBottom !== undefined ? radiusBottom : 1;\n\theight = height || 1;\n\n\tradialSegments = Math.floor( radialSegments ) || 8;\n\theightSegments = Math.floor( heightSegments ) || 1;\n\n\topenEnded = openEnded !== undefined ? openEnded : false;\n\tthetaStart = thetaStart !== undefined ? thetaStart : 0.0;\n\tthetaLength = thetaLength !== undefined ? thetaLength : Math.PI * 2;\n\n\t// buffers\n\n\tconst indices = [];\n\tconst vertices = [];\n\tconst normals = [];\n\tconst uvs = [];\n\n\t// helper variables\n\n\tlet index = 0;\n\tconst indexArray = [];\n\tconst halfHeight = height / 2;\n\tlet groupStart = 0;\n\n\t// generate geometry\n\n\tgenerateTorso();\n\n\tif ( openEnded === false ) {\n\n\t\tif ( radiusTop > 0 ) generateCap( true );\n\t\tif ( radiusBottom > 0 ) generateCap( false );\n\n\t}\n\n\t// build geometry\n\n\tthis.setIndex( indices );\n\tthis.setAttribute( 'position', new Float32BufferAttribute( vertices, 3 ) );\n\tthis.setAttribute( 'normal', new Float32BufferAttribute( normals, 3 ) );\n\tthis.setAttribute( 'uv', new Float32BufferAttribute( uvs, 2 ) );\n\n\tfunction generateTorso() {\n\n\t\tconst normal = new Vector3();\n\t\tconst vertex = new Vector3();\n\n\t\tlet groupCount = 0;\n\n\t\t// this will be used to calculate the normal\n\t\tconst slope = ( radiusBottom - radiusTop ) / height;\n\n\t\t// generate vertices, normals and uvs\n\n\t\tfor ( let y = 0; y <= heightSegments; y ++ ) {\n\n\t\t\tconst indexRow = [];\n\n\t\t\tconst v = y / heightSegments;\n\n\t\t\t// calculate the radius of the current row\n\n\t\t\tconst radius = v * ( radiusBottom - radiusTop ) + radiusTop;\n\n\t\t\tfor ( let x = 0; x <= radialSegments; x ++ ) {\n\n\t\t\t\tconst u = x / radialSegments;\n\n\t\t\t\tconst theta = u * thetaLength + thetaStart;\n\n\t\t\t\tconst sinTheta = Math.sin( theta );\n\t\t\t\tconst cosTheta = Math.cos( theta );\n\n\t\t\t\t// vertex\n\n\t\t\t\tvertex.x = radius * sinTheta;\n\t\t\t\tvertex.y = - v * height + halfHeight;\n\t\t\t\tvertex.z = radius * cosTheta;\n\t\t\t\tvertices.push( vertex.x, vertex.y, vertex.z );\n\n\t\t\t\t// normal\n\n\t\t\t\tnormal.set( sinTheta, slope, cosTheta ).normalize();\n\t\t\t\tnormals.push( normal.x, normal.y, normal.z );\n\n\t\t\t\t// uv\n\n\t\t\t\tuvs.push( u, 1 - v );\n\n\t\t\t\t// save index of vertex in respective row\n\n\t\t\t\tindexRow.push( index ++ );\n\n\t\t\t}\n\n\t\t\t// now save vertices of the row in our index array\n\n\t\t\tindexArray.push( indexRow );\n\n\t\t}\n\n\t\t// generate indices\n\n\t\tfor ( let x = 0; x < radialSegments; x ++ ) {\n\n\t\t\tfor ( let y = 0; y < heightSegments; y ++ ) {\n\n\t\t\t\t// we use the index array to access the correct indices\n\n\t\t\t\tconst a = indexArray[ y ][ x ];\n\t\t\t\tconst b = indexArray[ y + 1 ][ x ];\n\t\t\t\tconst c = indexArray[ y + 1 ][ x + 1 ];\n\t\t\t\tconst d = indexArray[ y ][ x + 1 ];\n\n\t\t\t\t// faces\n\n\t\t\t\tindices.push( a, b, d );\n\t\t\t\tindices.push( b, c, d );\n\n\t\t\t\t// update group counter\n\n\t\t\t\tgroupCount += 6;\n\n\t\t\t}\n\n\t\t}\n\n\t\t// add a group to the geometry. this will ensure multi material support\n\n\t\tscope.addGroup( groupStart, groupCount, 0 );\n\n\t\t// calculate new start value for groups\n\n\t\tgroupStart += groupCount;\n\n\t}\n\n\tfunction generateCap( top ) {\n\n\t\tlet centerIndexStart, centerIndexEnd;\n\n\t\tconst uv = new Vector2();\n\t\tconst vertex = new Vector3();\n\n\t\tlet groupCount = 0;\n\n\t\tconst radius = ( top === true ) ? radiusTop : radiusBottom;\n\t\tconst sign = ( top === true ) ? 1 : - 1;\n\n\t\t// save the index of the first center vertex\n\t\tcenterIndexStart = index;\n\n\t\t// first we generate the center vertex data of the cap.\n\t\t// because the geometry needs one set of uvs per face,\n\t\t// we must generate a center vertex per face/segment\n\n\t\tfor ( let x = 1; x <= radialSegments; x ++ ) {\n\n\t\t\t// vertex\n\n\t\t\tvertices.push( 0, halfHeight * sign, 0 );\n\n\t\t\t// normal\n\n\t\t\tnormals.push( 0, sign, 0 );\n\n\t\t\t// uv\n\n\t\t\tuvs.push( 0.5, 0.5 );\n\n\t\t\t// increase index\n\n\t\t\tindex ++;\n\n\t\t}\n\n\t\t// save the index of the last center vertex\n\n\t\tcenterIndexEnd = index;\n\n\t\t// now we generate the surrounding vertices, normals and uvs\n\n\t\tfor ( let x = 0; x <= radialSegments; x ++ ) {\n\n\t\t\tconst u = x / radialSegments;\n\t\t\tconst theta = u * thetaLength + thetaStart;\n\n\t\t\tconst cosTheta = Math.cos( theta );\n\t\t\tconst sinTheta = Math.sin( theta );\n\n\t\t\t// vertex\n\n\t\t\tvertex.x = radius * sinTheta;\n\t\t\tvertex.y = halfHeight * sign;\n\t\t\tvertex.z = radius * cosTheta;\n\t\t\tvertices.push( vertex.x, vertex.y, vertex.z );\n\n\t\t\t// normal\n\n\t\t\tnormals.push( 0, sign, 0 );\n\n\t\t\t// uv\n\n\t\t\tuv.x = ( cosTheta * 0.5 ) + 0.5;\n\t\t\tuv.y = ( sinTheta * 0.5 * sign ) + 0.5;\n\t\t\tuvs.push( uv.x, uv.y );\n\n\t\t\t// increase index\n\n\t\t\tindex ++;\n\n\t\t}\n\n\t\t// generate indices\n\n\t\tfor ( let x = 0; x < radialSegments; x ++ ) {\n\n\t\t\tconst c = centerIndexStart + x;\n\t\t\tconst i = centerIndexEnd + x;\n\n\t\t\tif ( top === true ) {\n\n\t\t\t\t// face top\n\n\t\t\t\tindices.push( i, i + 1, c );\n\n\t\t\t} else {\n\n\t\t\t\t// face bottom\n\n\t\t\t\tindices.push( i + 1, i, c );\n\n\t\t\t}\n\n\t\t\tgroupCount += 3;\n\n\t\t}\n\n\t\t// add a group to the geometry. this will ensure multi material support\n\n\t\tscope.addGroup( groupStart, groupCount, top === true ? 1 : 2 );\n\n\t\t// calculate new start value for groups\n\n\t\tgroupStart += groupCount;\n\n\t}\n\n}\n\nCylinderBufferGeometry.prototype = Object.create( BufferGeometry.prototype );\nCylinderBufferGeometry.prototype.constructor = CylinderBufferGeometry;\n\n\nexport { CylinderGeometry, CylinderBufferGeometry };\n","/**\n * @author abelnation / http://github.com/abelnation\n */\n\nimport { CylinderGeometry } from './CylinderGeometry.js';\nimport { CylinderBufferGeometry } from './CylinderGeometry.js';\n\n// ConeGeometry\n\nfunction ConeGeometry( radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength ) {\n\n\tCylinderGeometry.call( this, 0, radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength );\n\n\tthis.type = 'ConeGeometry';\n\n\tthis.parameters = {\n\t\tradius: radius,\n\t\theight: height,\n\t\tradialSegments: radialSegments,\n\t\theightSegments: heightSegments,\n\t\topenEnded: openEnded,\n\t\tthetaStart: thetaStart,\n\t\tthetaLength: thetaLength\n\t};\n\n}\n\nConeGeometry.prototype = Object.create( CylinderGeometry.prototype );\nConeGeometry.prototype.constructor = ConeGeometry;\n\n// ConeBufferGeometry\n\nfunction ConeBufferGeometry( radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength ) {\n\n\tCylinderBufferGeometry.call( this, 0, radius, height, radialSegments, heightSegments, openEnded, thetaStart, thetaLength );\n\n\tthis.type = 'ConeBufferGeometry';\n\n\tthis.parameters = {\n\t\tradius: radius,\n\t\theight: height,\n\t\tradialSegments: radialSegments,\n\t\theightSegments: heightSegments,\n\t\topenEnded: openEnded,\n\t\tthetaStart: thetaStart,\n\t\tthetaLength: thetaLength\n\t};\n\n}\n\nConeBufferGeometry.prototype = Object.create( CylinderBufferGeometry.prototype );\nConeBufferGeometry.prototype.constructor = ConeBufferGeometry;\n\n\nexport { ConeGeometry, ConeBufferGeometry };\n","import { Object3D } from '../core/Object3D.js';\nimport { Color } from '../math/Color.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n * @author alteredq / http://alteredqualia.com/\n */\n\nfunction Light( color, intensity ) {\n\n\tObject3D.call( this );\n\n\tthis.type = 'Light';\n\n\tthis.color = new Color( color );\n\tthis.intensity = intensity !== undefined ? intensity : 1;\n\n\tthis.receiveShadow = undefined;\n\n}\n\nLight.prototype = Object.assign( Object.create( Object3D.prototype ), {\n\n\tconstructor: Light,\n\n\tisLight: true,\n\n\tcopy: function ( source ) {\n\n\t\tObject3D.prototype.copy.call( this, source );\n\n\t\tthis.color.copy( source.color );\n\t\tthis.intensity = source.intensity;\n\n\t\treturn this;\n\n\t},\n\n\ttoJSON: function ( meta ) {\n\n\t\tconst data = Object3D.prototype.toJSON.call( this, meta );\n\n\t\tdata.object.color = this.color.getHex();\n\t\tdata.object.intensity = this.intensity;\n\n\t\tif ( this.groundColor !== undefined ) data.object.groundColor = this.groundColor.getHex();\n\n\t\tif ( this.distance !== undefined ) data.object.distance = this.distance;\n\t\tif ( this.angle !== undefined ) data.object.angle = this.angle;\n\t\tif ( this.decay !== undefined ) data.object.decay = this.decay;\n\t\tif ( this.penumbra !== undefined ) data.object.penumbra = this.penumbra;\n\n\t\tif ( this.shadow !== undefined ) data.object.shadow = this.shadow.toJSON();\n\n\t\treturn data;\n\n\t}\n\n} );\n\n\nexport { Light };\n","import { Matrix4 } from '../math/Matrix4.js';\nimport { Vector2 } from '../math/Vector2.js';\nimport { Vector3 } from '../math/Vector3.js';\nimport { Vector4 } from '../math/Vector4.js';\nimport { Frustum } from '../math/Frustum.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction LightShadow( camera ) {\n\n\tthis.camera = camera;\n\n\tthis.bias = 0;\n\tthis.normalBias = 0;\n\tthis.radius = 1;\n\n\tthis.mapSize = new Vector2( 512, 512 );\n\n\tthis.map = null;\n\tthis.mapPass = null;\n\tthis.matrix = new Matrix4();\n\n\tthis.autoUpdate = true;\n\tthis.needsUpdate = false;\n\n\tthis._frustum = new Frustum();\n\tthis._frameExtents = new Vector2( 1, 1 );\n\n\tthis._viewportCount = 1;\n\n\tthis._viewports = [\n\n\t\tnew Vector4( 0, 0, 1, 1 )\n\n\t];\n\n}\n\nObject.assign( LightShadow.prototype, {\n\n\t_projScreenMatrix: new Matrix4(),\n\n\t_lightPositionWorld: new Vector3(),\n\n\t_lookTarget: new Vector3(),\n\n\tgetViewportCount: function () {\n\n\t\treturn this._viewportCount;\n\n\t},\n\n\tgetFrustum: function () {\n\n\t\treturn this._frustum;\n\n\t},\n\n\tupdateMatrices: function ( light ) {\n\n\t\tconst shadowCamera = this.camera,\n\t\t\tshadowMatrix = this.matrix,\n\t\t\tprojScreenMatrix = this._projScreenMatrix,\n\t\t\tlookTarget = this._lookTarget,\n\t\t\tlightPositionWorld = this._lightPositionWorld;\n\n\t\tlightPositionWorld.setFromMatrixPosition( light.matrixWorld );\n\t\tshadowCamera.position.copy( lightPositionWorld );\n\n\t\tlookTarget.setFromMatrixPosition( light.target.matrixWorld );\n\t\tshadowCamera.lookAt( lookTarget );\n\t\tshadowCamera.updateMatrixWorld();\n\n\t\tprojScreenMatrix.multiplyMatrices( shadowCamera.projectionMatrix, shadowCamera.matrixWorldInverse );\n\t\tthis._frustum.setFromProjectionMatrix( projScreenMatrix );\n\n\t\tshadowMatrix.set(\n\t\t\t0.5, 0.0, 0.0, 0.5,\n\t\t\t0.0, 0.5, 0.0, 0.5,\n\t\t\t0.0, 0.0, 0.5, 0.5,\n\t\t\t0.0, 0.0, 0.0, 1.0\n\t\t);\n\n\t\tshadowMatrix.multiply( shadowCamera.projectionMatrix );\n\t\tshadowMatrix.multiply( shadowCamera.matrixWorldInverse );\n\n\t},\n\n\tgetViewport: function ( viewportIndex ) {\n\n\t\treturn this._viewports[ viewportIndex ];\n\n\t},\n\n\tgetFrameExtents: function () {\n\n\t\treturn this._frameExtents;\n\n\t},\n\n\tcopy: function ( source ) {\n\n\t\tthis.camera = source.camera.clone();\n\n\t\tthis.bias = source.bias;\n\t\tthis.radius = source.radius;\n\n\t\tthis.mapSize.copy( source.mapSize );\n\n\t\treturn this;\n\n\t},\n\n\tclone: function () {\n\n\t\treturn new this.constructor().copy( this );\n\n\t},\n\n\ttoJSON: function () {\n\n\t\tconst object = {};\n\n\t\tif ( this.bias !== 0 ) object.bias = this.bias;\n\t\tif ( this.normalBias !== 0 ) object.normalBias = this.normalBias;\n\t\tif ( this.radius !== 1 ) object.radius = this.radius;\n\t\tif ( this.mapSize.x !== 512 || this.mapSize.y !== 512 ) object.mapSize = this.mapSize.toArray();\n\n\t\tobject.camera = this.camera.toJSON( false ).object;\n\t\tdelete object.camera.matrix;\n\n\t\treturn object;\n\n\t}\n\n} );\n\n\nexport { LightShadow };\n","import { LightShadow } from './LightShadow.js';\nimport { MathUtils } from '../math/MathUtils.js';\nimport { PerspectiveCamera } from '../cameras/PerspectiveCamera.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction SpotLightShadow() {\n\n\tLightShadow.call( this, new PerspectiveCamera( 50, 1, 0.5, 500 ) );\n\n}\n\nSpotLightShadow.prototype = Object.assign( Object.create( LightShadow.prototype ), {\n\n\tconstructor: SpotLightShadow,\n\n\tisSpotLightShadow: true,\n\n\tupdateMatrices: function ( light ) {\n\n\t\tconst camera = this.camera;\n\n\t\tconst fov = MathUtils.RAD2DEG * 2 * light.angle;\n\t\tconst aspect = this.mapSize.width / this.mapSize.height;\n\t\tconst far = light.distance || camera.far;\n\n\t\tif ( fov !== camera.fov || aspect !== camera.aspect || far !== camera.far ) {\n\n\t\t\tcamera.fov = fov;\n\t\t\tcamera.aspect = aspect;\n\t\t\tcamera.far = far;\n\t\t\tcamera.updateProjectionMatrix();\n\n\t\t}\n\n\t\tLightShadow.prototype.updateMatrices.call( this, light );\n\n\t}\n\n} );\n\n\nexport { SpotLightShadow };\n","import { Light } from './Light.js';\nimport { SpotLightShadow } from './SpotLightShadow.js';\nimport { Object3D } from '../core/Object3D.js';\n\n/**\n * @author alteredq / http://alteredqualia.com/\n */\n\nfunction SpotLight( color, intensity, distance, angle, penumbra, decay ) {\n\n\tLight.call( this, color, intensity );\n\n\tthis.type = 'SpotLight';\n\n\tthis.position.copy( Object3D.DefaultUp );\n\tthis.updateMatrix();\n\n\tthis.target = new Object3D();\n\n\tObject.defineProperty( this, 'power', {\n\t\tget: function () {\n\n\t\t\t// intensity = power per solid angle.\n\t\t\t// ref: equation (17) from https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf\n\t\t\treturn this.intensity * Math.PI;\n\n\t\t},\n\t\tset: function ( power ) {\n\n\t\t\t// intensity = power per solid angle.\n\t\t\t// ref: equation (17) from https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf\n\t\t\tthis.intensity = power / Math.PI;\n\n\t\t}\n\t} );\n\n\tthis.distance = ( distance !== undefined ) ? distance : 0;\n\tthis.angle = ( angle !== undefined ) ? angle : Math.PI / 3;\n\tthis.penumbra = ( penumbra !== undefined ) ? penumbra : 0;\n\tthis.decay = ( decay !== undefined ) ? decay : 1;\t// for physically correct lights, should be 2.\n\n\tthis.shadow = new SpotLightShadow();\n\n}\n\nSpotLight.prototype = Object.assign( Object.create( Light.prototype ), {\n\n\tconstructor: SpotLight,\n\n\tisSpotLight: true,\n\n\tcopy: function ( source ) {\n\n\t\tLight.prototype.copy.call( this, source );\n\n\t\tthis.distance = source.distance;\n\t\tthis.angle = source.angle;\n\t\tthis.penumbra = source.penumbra;\n\t\tthis.decay = source.decay;\n\n\t\tthis.target = source.target.clone();\n\n\t\tthis.shadow = source.shadow.clone();\n\n\t\treturn this;\n\n\t}\n\n} );\n\n\nexport { SpotLight };\n","import { Camera } from './Camera.js';\nimport { Object3D } from '../core/Object3D.js';\n\n/**\n * @author alteredq / http://alteredqualia.com/\n * @author arose / http://github.com/arose\n */\n\nfunction OrthographicCamera( left, right, top, bottom, near, far ) {\n\n\tCamera.call( this );\n\n\tthis.type = 'OrthographicCamera';\n\n\tthis.zoom = 1;\n\tthis.view = null;\n\n\tthis.left = ( left !== undefined ) ? left : - 1;\n\tthis.right = ( right !== undefined ) ? right : 1;\n\tthis.top = ( top !== undefined ) ? top : 1;\n\tthis.bottom = ( bottom !== undefined ) ? bottom : - 1;\n\n\tthis.near = ( near !== undefined ) ? near : 0.1;\n\tthis.far = ( far !== undefined ) ? far : 2000;\n\n\tthis.updateProjectionMatrix();\n\n}\n\nOrthographicCamera.prototype = Object.assign( Object.create( Camera.prototype ), {\n\n\tconstructor: OrthographicCamera,\n\n\tisOrthographicCamera: true,\n\n\tcopy: function ( source, recursive ) {\n\n\t\tCamera.prototype.copy.call( this, source, recursive );\n\n\t\tthis.left = source.left;\n\t\tthis.right = source.right;\n\t\tthis.top = source.top;\n\t\tthis.bottom = source.bottom;\n\t\tthis.near = source.near;\n\t\tthis.far = source.far;\n\n\t\tthis.zoom = source.zoom;\n\t\tthis.view = source.view === null ? null : Object.assign( {}, source.view );\n\n\t\treturn this;\n\n\t},\n\n\tsetViewOffset: function ( fullWidth, fullHeight, x, y, width, height ) {\n\n\t\tif ( this.view === null ) {\n\n\t\t\tthis.view = {\n\t\t\t\tenabled: true,\n\t\t\t\tfullWidth: 1,\n\t\t\t\tfullHeight: 1,\n\t\t\t\toffsetX: 0,\n\t\t\t\toffsetY: 0,\n\t\t\t\twidth: 1,\n\t\t\t\theight: 1\n\t\t\t};\n\n\t\t}\n\n\t\tthis.view.enabled = true;\n\t\tthis.view.fullWidth = fullWidth;\n\t\tthis.view.fullHeight = fullHeight;\n\t\tthis.view.offsetX = x;\n\t\tthis.view.offsetY = y;\n\t\tthis.view.width = width;\n\t\tthis.view.height = height;\n\n\t\tthis.updateProjectionMatrix();\n\n\t},\n\n\tclearViewOffset: function () {\n\n\t\tif ( this.view !== null ) {\n\n\t\t\tthis.view.enabled = false;\n\n\t\t}\n\n\t\tthis.updateProjectionMatrix();\n\n\t},\n\n\tupdateProjectionMatrix: function () {\n\n\t\tconst dx = ( this.right - this.left ) / ( 2 * this.zoom );\n\t\tconst dy = ( this.top - this.bottom ) / ( 2 * this.zoom );\n\t\tconst cx = ( this.right + this.left ) / 2;\n\t\tconst cy = ( this.top + this.bottom ) / 2;\n\n\t\tlet left = cx - dx;\n\t\tlet right = cx + dx;\n\t\tlet top = cy + dy;\n\t\tlet bottom = cy - dy;\n\n\t\tif ( this.view !== null && this.view.enabled ) {\n\n\t\t\tconst scaleW = ( this.right - this.left ) / this.view.fullWidth / this.zoom;\n\t\t\tconst scaleH = ( this.top - this.bottom ) / this.view.fullHeight / this.zoom;\n\n\t\t\tleft += scaleW * this.view.offsetX;\n\t\t\tright = left + scaleW * this.view.width;\n\t\t\ttop -= scaleH * this.view.offsetY;\n\t\t\tbottom = top - scaleH * this.view.height;\n\n\t\t}\n\n\t\tthis.projectionMatrix.makeOrthographic( left, right, top, bottom, this.near, this.far );\n\n\t\tthis.projectionMatrixInverse.getInverse( this.projectionMatrix );\n\n\t},\n\n\ttoJSON: function ( meta ) {\n\n\t\tconst data = Object3D.prototype.toJSON.call( this, meta );\n\n\t\tdata.object.zoom = this.zoom;\n\t\tdata.object.left = this.left;\n\t\tdata.object.right = this.right;\n\t\tdata.object.top = this.top;\n\t\tdata.object.bottom = this.bottom;\n\t\tdata.object.near = this.near;\n\t\tdata.object.far = this.far;\n\n\t\tif ( this.view !== null ) data.object.view = Object.assign( {}, this.view );\n\n\t\treturn data;\n\n\t}\n\n} );\n\n\nexport { OrthographicCamera };\n","import { Light } from './Light.js';\n\n/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction AmbientLight( color, intensity ) {\n\n\tLight.call( this, color, intensity );\n\n\tthis.type = 'AmbientLight';\n\n\tthis.castShadow = undefined;\n\n}\n\nAmbientLight.prototype = Object.assign( Object.create( Light.prototype ), {\n\n\tconstructor: AmbientLight,\n\n\tisAmbientLight: true\n\n} );\n\n\nexport { AmbientLight };\n","import { Matrix4 } from '../math/Matrix4.js';\nimport { MathUtils } from '../math/MathUtils.js';\nimport { PerspectiveCamera } from './PerspectiveCamera.js';\n\nconst _eyeRight = new Matrix4();\nconst _eyeLeft = new Matrix4();\n\n/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction StereoCamera() {\n\n\tthis.type = 'StereoCamera';\n\n\tthis.aspect = 1;\n\n\tthis.eyeSep = 0.064;\n\n\tthis.cameraL = new PerspectiveCamera();\n\tthis.cameraL.layers.enable( 1 );\n\tthis.cameraL.matrixAutoUpdate = false;\n\n\tthis.cameraR = new PerspectiveCamera();\n\tthis.cameraR.layers.enable( 2 );\n\tthis.cameraR.matrixAutoUpdate = false;\n\n\tthis._cache = {\n\t\tfocus: null,\n\t\tfov: null,\n\t\taspect: null,\n\t\tnear: null,\n\t\tfar: null,\n\t\tzoom: null,\n\t\teyeSep: null\n\t};\n\n}\n\nObject.assign( StereoCamera.prototype, {\n\n\tupdate: function ( camera ) {\n\n\t\tconst cache = this._cache;\n\n\t\tconst needsUpdate = cache.focus !== camera.focus || cache.fov !== camera.fov ||\n\t\t\tcache.aspect !== camera.aspect * this.aspect || cache.near !== camera.near ||\n\t\t\tcache.far !== camera.far || cache.zoom !== camera.zoom || cache.eyeSep !== this.eyeSep;\n\n\t\tif ( needsUpdate ) {\n\n\t\t\tcache.focus = camera.focus;\n\t\t\tcache.fov = camera.fov;\n\t\t\tcache.aspect = camera.aspect * this.aspect;\n\t\t\tcache.near = camera.near;\n\t\t\tcache.far = camera.far;\n\t\t\tcache.zoom = camera.zoom;\n\t\t\tcache.eyeSep = this.eyeSep;\n\n\t\t\t// Off-axis stereoscopic effect based on\n\t\t\t// http://paulbourke.net/stereographics/stereorender/\n\n\t\t\tconst projectionMatrix = camera.projectionMatrix.clone();\n\t\t\tconst eyeSepHalf = cache.eyeSep / 2;\n\t\t\tconst eyeSepOnProjection = eyeSepHalf * cache.near / cache.focus;\n\t\t\tconst ymax = ( cache.near * Math.tan( MathUtils.DEG2RAD * cache.fov * 0.5 ) ) / cache.zoom;\n\t\t\tlet xmin, xmax;\n\n\t\t\t// translate xOffset\n\n\t\t\t_eyeLeft.elements[ 12 ] = - eyeSepHalf;\n\t\t\t_eyeRight.elements[ 12 ] = eyeSepHalf;\n\n\t\t\t// for left eye\n\n\t\t\txmin = - ymax * cache.aspect + eyeSepOnProjection;\n\t\t\txmax = ymax * cache.aspect + eyeSepOnProjection;\n\n\t\t\tprojectionMatrix.elements[ 0 ] = 2 * cache.near / ( xmax - xmin );\n\t\t\tprojectionMatrix.elements[ 8 ] = ( xmax + xmin ) / ( xmax - xmin );\n\n\t\t\tthis.cameraL.projectionMatrix.copy( projectionMatrix );\n\n\t\t\t// for right eye\n\n\t\t\txmin = - ymax * cache.aspect - eyeSepOnProjection;\n\t\t\txmax = ymax * cache.aspect - eyeSepOnProjection;\n\n\t\t\tprojectionMatrix.elements[ 0 ] = 2 * cache.near / ( xmax - xmin );\n\t\t\tprojectionMatrix.elements[ 8 ] = ( xmax + xmin ) / ( xmax - xmin );\n\n\t\t\tthis.cameraR.projectionMatrix.copy( projectionMatrix );\n\n\t\t}\n\n\t\tthis.cameraL.matrixWorld.copy( camera.matrixWorld ).multiply( _eyeLeft );\n\t\tthis.cameraR.matrixWorld.copy( camera.matrixWorld ).multiply( _eyeRight );\n\n\t}\n\n} );\n\n\nexport { StereoCamera };\n","/**\n * @author mrdoob / http://mrdoob.com/\n */\n\nfunction Uniform( value ) {\n\n\tif ( typeof value === 'string' ) {\n\n\t\tconsole.warn( 'THREE.Uniform: Type parameter is no longer needed.' );\n\t\tvalue = arguments[ 1 ];\n\n\t}\n\n\tthis.value = value;\n\n}\n\nUniform.prototype.clone = function () {\n\n\treturn new Uniform( this.value.clone === undefined ? this.value : this.value.clone() );\n\n};\n\nexport { Uniform };\n","/**\n * @file Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector2, Vector3, Matrix4, Quaternion } from 'three'\n\nexport function getQuery (id: string) {\n if (typeof window === 'undefined') return undefined\n\n const a = new RegExp(`${id}=([^&#=]*)`)\n const m = a.exec(window.location.search)\n\n if (m) {\n return decodeURIComponent(m[1])\n } else {\n return undefined\n }\n}\n\nexport function boolean (value: any) {\n if (!value) {\n return false\n }\n\n if (typeof value === 'string') {\n return /^1|true|t|yes|y$/i.test(value)\n }\n\n return true\n}\n\nexport function defaults (value: any, defaultValue: any) {\n return value !== undefined ? value : defaultValue\n}\n\nexport function createParams (params: {[k in keyof T]?: any}, defaultParams: T) {\n const o: any = Object.assign({}, params)\n for (const k in defaultParams) {\n const value = params[k]\n if (value === undefined) o[k] = defaultParams[k]\n }\n return o as T\n}\n\nexport function updateParams (params: T, newParams: {[k in keyof T]?: any}) {\n for (const k in newParams) {\n const value = newParams[k]\n if (value !== undefined) params[k] = value\n }\n return params as T\n}\n\nexport function pick (object: { [index: string]: any }) {\n const properties = [].slice.call(arguments, 1)\n return properties.reduce((a: { [index: string]: any }, e: any) => {\n a[ e ] = object[ e ]\n return a\n }, {})\n}\n\nexport function flatten (array: any[], ret: any[]) {\n ret = defaults(ret, [])\n for (let i = 0; i < array.length; i++) {\n if (Array.isArray(array[i])) {\n flatten(array[i], ret)\n } else {\n ret.push(array[i])\n }\n }\n return ret\n}\n\nexport function getProtocol () {\n const protocol = window.location.protocol\n return protocol.match(/http(s)?:/gi) === null ? 'http:' : protocol\n}\n\nexport function getBrowser () {\n if (typeof window === 'undefined') return false\n\n const ua = window.navigator.userAgent\n\n if (/Opera|OPR/.test(ua)) {\n return 'Opera'\n } else if (/Chrome/i.test(ua)) {\n return 'Chrome'\n } else if (/Firefox/i.test(ua)) {\n return 'Firefox'\n } else if (/Mobile(\\/.*)? Safari/i.test(ua)) {\n return 'Mobile Safari'\n } else if (/MSIE/i.test(ua)) {\n return 'Internet Explorer'\n } else if (/Safari/i.test(ua)) {\n return 'Safari'\n }\n\n return false\n}\n\nexport function getAbsolutePath (relativePath: string) {\n const loc = window.location\n const pn = loc.pathname\n const basePath = pn.substring(0, pn.lastIndexOf('/') + 1)\n\n return loc.origin + basePath + relativePath\n}\n\nexport function deepCopy (src: any) {\n if (typeof src !== 'object') {\n return src\n }\n\n const dst: { [index: string]: any } = Array.isArray(src) ? [] : {}\n\n for (let key in src) {\n dst[ key ] = deepCopy(src[ key ])\n }\n\n return dst\n}\n\nexport function deepEqual(a: any, b: any) {\n // from https://github.com/epoberezkin/fast-deep-equal MIT\n if (a === b) return true;\n\n const arrA = Array.isArray(a)\n const arrB = Array.isArray(b)\n\n if (arrA && arrB) {\n if (a.length !== b.length) return false\n for (let i = 0; i < a.length; i++) {\n if (!deepEqual(a[i], b[i])) return false\n }\n return true\n }\n\n if (arrA !== arrB) return false\n\n if (a && b && typeof a === 'object' && typeof b === 'object') {\n const keys = Object.keys(a)\n if (keys.length !== Object.keys(b).length) return false;\n\n const dateA = a instanceof Date\n const dateB = b instanceof Date\n if (dateA && dateB) return a.getTime() === b.getTime()\n if (dateA !== dateB) return false\n\n const regexpA = a instanceof RegExp\n const regexpB = b instanceof RegExp\n if (regexpA && regexpB) return a.toString() === b.toString()\n if (regexpA !== regexpB) return false\n\n for (let i = 0; i < keys.length; i++) {\n if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false\n }\n\n for (let i = 0; i < keys.length; i++) {\n if(!deepEqual(a[keys[i]], b[keys[i]])) return false\n }\n\n return true\n }\n\n return false\n}\n\nfunction openUrl (url: string) {\n const opened = window.open(url, '_blank')\n if (!opened) {\n window.location.href = url\n }\n}\n\nexport function download (data: Blob|string, downloadName = 'download') {\n // using ideas from https://github.com/eligrey/FileSaver.js/blob/master/FileSaver.js\n\n if (!data) return\n\n const isSafari = getBrowser() === 'Safari'\n const isChromeIos = /CriOS\\/[\\d]+/.test(window.navigator.userAgent)\n\n const a = document.createElement('a')\n\n function open (str: string) {\n openUrl(isChromeIos ? str : str.replace(/^data:[^;]*;/, 'data:attachment/file;'))\n }\n\n if (typeof navigator !== 'undefined' && (navigator as any).msSaveOrOpenBlob) {\n // native saveAs in IE 10+\n (navigator as any).msSaveOrOpenBlob(data, downloadName)\n } else if ((isSafari || isChromeIos) && FileReader) {\n if (data instanceof Blob) {\n // no downloading of blob urls in Safari\n var reader = new FileReader()\n reader.onloadend = function () {\n open(reader.result as string)\n }\n reader.readAsDataURL(data)\n } else {\n open(data)\n }\n } else {\n let objectUrlCreated = false\n if (data instanceof Blob) {\n data = URL.createObjectURL(data)\n objectUrlCreated = true\n }\n\n if ('download' in a) {\n // download link available\n a.style.display = 'hidden'\n document.body.appendChild(a)\n a.href = data\n a.download = downloadName\n a.target = '_blank'\n a.click()\n document.body.removeChild(a)\n } else {\n openUrl(data)\n }\n\n if (objectUrlCreated) {\n window.URL.revokeObjectURL(data)\n }\n }\n}\n\nexport function submit (url: string, data: FormData, callback: Function, onerror: Function) {\n const xhr = new XMLHttpRequest()\n xhr.open('POST', url)\n\n xhr.addEventListener('load', function () {\n if (xhr.status === 200 || xhr.status === 304) {\n callback(xhr.response)\n } else {\n if (typeof onerror === 'function') {\n onerror(xhr.status)\n }\n }\n }, false)\n\n xhr.send(data)\n}\n\ninterface HTMLInputEvent extends Event {\n target: HTMLInputElement & EventTarget\n}\n\nexport function open (callback: Function, extensionList = ['*']) {\n const fileInput = document.createElement('input')\n fileInput.type = 'file'\n fileInput.multiple = true\n fileInput.style.display = 'hidden'\n document.body.appendChild(fileInput)\n fileInput.accept = '.' + extensionList.join(',.')\n fileInput.addEventListener('change', function (e: HTMLInputEvent) {\n callback(e.target.files)\n }, false)\n\n fileInput.click()\n}\n\nexport function throttle (func: Function, wait: number, options: { leading?: boolean, trailing?: boolean }) {\n // from http://underscorejs.org/docs/underscore.html\n\n let context: any\n let args: any\n let result: any\n let timeout: any = null\n let previous = 0\n\n if (!options) options = {}\n\n function later () {\n previous = options.leading === false ? 0 : Date.now()\n timeout = null\n result = func.apply(context, args)\n if (!timeout) context = args = null\n }\n\n return function throttle (this: any) {\n var now = Date.now()\n if (!previous && options.leading === false) previous = now\n var remaining = wait - (now - previous)\n context = this\n args = arguments\n if (remaining <= 0 || remaining > wait) {\n if (timeout) {\n clearTimeout(timeout)\n timeout = null\n }\n previous = now\n result = func.apply(context, args)\n if (!timeout) context = args = null\n } else if (!timeout && options.trailing !== false) {\n timeout = setTimeout(later, remaining)\n }\n\n return result\n }\n}\n\nexport function lexicographicCompare (elm1: T, elm2: T) {\n if (elm1 < elm2) return -1\n if (elm1 > elm2) return 1\n return 0\n}\n\n/**\n * Does a binary search to get the index of an element in the input array\n * @function\n * @example\n * var array = [ 1, 2, 3, 4, 5, 6 ];\n * var element = 4;\n * binarySearchIndexOf( array, element ); // returns 3\n *\n * @param {Array} array - sorted array\n * @param {Anything} element - element to search for in the array\n * @param {Function} [compareFunction] - compare function\n * @return {Number} the index of the element or -1 if not in the array\n */\nexport function binarySearchIndexOf (array: T[], element: T, compareFunction = lexicographicCompare) {\n let low = 0\n let high = array.length - 1\n while (low <= high) {\n const mid = (low + high) >> 1\n const cmp = compareFunction(element, array[ mid ])\n if (cmp > 0) {\n low = mid + 1\n } else if (cmp < 0) {\n high = mid - 1\n } else {\n return mid\n }\n }\n return -low - 1\n}\n\nexport function binarySearchForLeftRange (array: number[], leftRange: number) {\n let high = array.length - 1\n if (array[ high ] < leftRange) return -1\n let low = 0\n while (low <= high) {\n const mid = (low + high) >> 1\n if (array[ mid ] >= leftRange) {\n high = mid - 1\n } else {\n low = mid + 1\n }\n }\n return high + 1\n}\n\nexport function binarySearchForRightRange (array: number[], rightRange: number) {\n if (array[ 0 ] > rightRange) return -1\n let low = 0\n let high = array.length - 1\n while (low <= high) {\n const mid = (low + high) >> 1\n if (array[ mid ] > rightRange) {\n high = mid - 1\n } else {\n low = mid + 1\n }\n }\n return low - 1\n}\n\nexport function rangeInSortedArray (array: number[], min: number, max: number) {\n const indexLeft = binarySearchForLeftRange(array, min)\n const indexRight = binarySearchForRightRange(array, max)\n if (indexLeft === -1 || indexRight === -1 || indexLeft > indexRight) {\n return 0\n } else {\n return indexRight - indexLeft + 1\n }\n}\n\nexport function dataURItoImage (dataURI: string) {\n const img = document.createElement('img')\n img.src = dataURI\n return img\n}\n\nexport function uniqueArray (array: any[]) {\n return array.sort().filter(function (value, index, sorted) {\n return (index === 0) || (value !== sorted[ index - 1 ])\n })\n}\n\n// String/arraybuffer conversion\n\nexport function uint8ToString (u8a: Uint8Array) {\n const chunkSize = 0x7000\n\n if (u8a.length > chunkSize) {\n const c = []\n\n for (let i = 0; i < u8a.length; i += chunkSize) {\n c.push(String.fromCharCode.apply(\n null, u8a.subarray(i, i + chunkSize)\n ))\n }\n\n return c.join('')\n } else {\n return String.fromCharCode.apply(null, u8a)\n }\n}\n\nexport function uint8ToLines (u8a: Uint8Array, chunkSize = 1024 * 1024 * 10, newline = '\\n') {\n let partialLine = ''\n let lines: string[] = []\n\n for (let i = 0; i < u8a.length; i += chunkSize) {\n const str = uint8ToString(u8a.subarray(i, i + chunkSize))\n const idx = str.lastIndexOf(newline)\n\n if (idx === -1) {\n partialLine += str\n } else {\n const str2 = partialLine + str.substr(0, idx)\n lines = lines.concat(str2.split(newline))\n\n if (idx === str.length - newline.length) {\n partialLine = ''\n } else {\n partialLine = str.substr(idx + newline.length)\n }\n }\n }\n\n if (partialLine !== '') {\n lines.push(partialLine)\n }\n\n return lines\n}\n\nexport type TypedArrayString = 'int8'|'int16'|'int32'|'uint8'|'uint16'|'uint32'|'float32'\nexport function getTypedArray (arrayType: TypedArrayString, arraySize: number) {\n switch (arrayType) {\n case 'int8':\n return new Int8Array(arraySize)\n case 'int16':\n return new Int16Array(arraySize)\n case 'int32':\n return new Int32Array(arraySize)\n case 'uint8':\n return new Uint8Array(arraySize)\n case 'uint16':\n return new Uint16Array(arraySize)\n case 'uint32':\n return new Uint32Array(arraySize)\n case 'float32':\n return new Float32Array(arraySize)\n default:\n throw new Error('arrayType unknown: ' + arrayType)\n }\n}\n\nexport function getUintArray (sizeOrArray: any, maxUint: number) { // TODO\n const TypedArray = maxUint > 65535 ? Uint32Array : Uint16Array\n return new TypedArray(sizeOrArray)\n}\n\nexport function ensureArray (value: any) {\n return Array.isArray(value) ? value : [value]\n}\n\nexport function ensureBuffer (a: any) { // TODO\n return (a.buffer && a.buffer instanceof ArrayBuffer) ? a.buffer : a\n}\n\nfunction _ensureClassFromArg (arg: any, constructor: { new (arg: any): any }) {\n return arg instanceof constructor ? arg : new constructor(arg)\n}\n\nfunction _ensureClassFromArray (array: any, constructor: { new (): any }) {\n if (array === undefined) {\n array = new constructor()\n } else if (Array.isArray(array)) {\n array = new constructor().fromArray(array)\n }\n return array\n}\n\nexport function ensureVector2 (v?: number[]|Vector2) {\n return _ensureClassFromArray(v, Vector2)\n}\n\nexport function ensureVector3 (v?: number[]|Vector3) {\n return _ensureClassFromArray(v, Vector3)\n}\n\nexport function ensureMatrix4 (m?: number[]|Matrix4) {\n return _ensureClassFromArray(m, Matrix4)\n}\n\nexport function ensureQuaternion (q?: number[]|Quaternion) {\n return _ensureClassFromArray(q, Quaternion)\n}\n\nexport function ensureFloat32Array (a?: number[]|Float32Array) {\n return _ensureClassFromArg(a, Float32Array)\n}\n\nexport interface RingBuffer {\n has: (value: T) => boolean\n get: (value: number) => T\n push: (value: T) => void\n count: number\n data: T[]\n clear: () => void\n}\n\nexport function createRingBuffer (length: number): RingBuffer {\n let pointer = 0\n let count = 0\n const buffer: T[] = []\n\n return {\n has: function (value: any) { return buffer.indexOf(value) !== -1 },\n get: function (idx: number) { return buffer[idx] },\n push: function (item: any) {\n buffer[pointer] = item\n pointer = (length + pointer + 1) % length\n ++count\n },\n get count () { return count },\n get data () { return buffer.slice(0, Math.min(count, length)) },\n clear: function () {\n count = 0\n pointer = 0\n buffer.length = 0\n }\n }\n}\n\nexport interface SimpleDict {\n has: (k: K) => boolean\n add: (k: K, v: V) => void\n del: (k: K) => void\n values: V[]\n}\n\nexport function createSimpleDict (): SimpleDict {\n const set: { [k: string]: V } = {}\n\n return {\n has: function (k: K) { return set[JSON.stringify(k)] !== undefined },\n add: function (k: K, v: V) { set[JSON.stringify(k)] = v },\n del: function (k: K) { delete set[JSON.stringify(k)] },\n get values () { return Object.keys(set).map(k => set[k]) }\n }\n}\n\nexport interface SimpleSet {\n has: (value: T) => boolean\n add: (value: T) => void\n del: (value: T) => void\n list: T[]\n}\n\nexport function createSimpleSet (): SimpleSet {\n const set: { [k: string]: T } = {}\n\n return {\n has: function (v: T) { return set[JSON.stringify(v)] !== undefined },\n add: function (v: T) { set[JSON.stringify(v)] = v },\n del: function (v: T) { delete set[JSON.stringify(v)] },\n get list () { return Object.keys(set).map(k => set[k]) },\n }\n}\n","/**\n * @file Registry\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\n\nfunction toLowerCaseString (value: string) {\n return defaults(value, '').toString().toLowerCase()\n}\n\nexport default class Registry {\n name: string\n private _dict: {[k: string]: any}\n\n constructor (name: string) {\n this.name = name\n this._dict = {}\n }\n\n add (key: string, value: any) {\n this._dict[ toLowerCaseString(key) ] = value\n }\n\n get (key: string) {\n return this._dict[ toLowerCaseString(key) ]\n }\n\n get names () {\n return Object.keys(this._dict)\n }\n}","/**\n * @file Math Utils\n * @author Alexander Rose \n * @private\n */\n\nexport function degToRad (deg: number) {\n return deg * 0.01745 // deg * Math.PI / 180\n}\n\nexport function radToDeg (rad: number) {\n return rad * 57.29578 // rad * 180 / Math.PI\n}\n\n// http://www.broofa.com/Tools/Math.uuid.htm\nconst chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('')\nconst uuid = new Array(36)\n\nexport function generateUUID () {\n let rnd = 0\n let r\n\n for (let i = 0; i < 36; i++) {\n if (i === 8 || i === 13 || i === 18 || i === 23) {\n uuid[ i ] = '-'\n } else if (i === 14) {\n uuid[ i ] = '4'\n } else {\n if (rnd <= 0x02) rnd = 0x2000000 + (Math.random() * 0x1000000) | 0\n r = rnd & 0xf\n rnd = rnd >> 4\n uuid[ i ] = chars[ (i === 19) ? (r & 0x3) | 0x8 : r ]\n }\n }\n\n return uuid.join('')\n}\n\nexport function countSetBits (i: number) {\n i = i - ((i >> 1) & 0x55555555)\n i = (i & 0x33333333) + ((i >> 2) & 0x33333333)\n return (((i + (i >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24\n}\n\nexport function normalize (value: number, min: number, max: number) {\n return (value - min) / (max - min)\n}\n\nexport function clamp (value: number, min: number, max: number) {\n return Math.max(min, Math.min(max, value))\n}\n\nexport function pclamp (value: number) {\n return clamp(value, 0, 100)\n}\n\nexport function saturate (value: number) {\n return clamp(value, 0, 1)\n}\n\nexport function lerp (start: number, stop: number, alpha: number) {\n return start + (stop - start) * alpha\n}\n\nexport function spline (p0: number, p1: number, p2: number, p3: number, t: number, tension: number) {\n const v0 = (p2 - p0) * tension\n const v1 = (p3 - p1) * tension\n const t2 = t * t\n const t3 = t * t2\n return (2 * p1 - 2 * p2 + v0 + v1) * t3 +\n (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 +\n v0 * t + p1\n}\n\nexport function smoothstep (min: number, max: number, x: number) {\n x = saturate(normalize(x, min, max))\n return x * x * (3 - 2 * x)\n}\n\nexport function smootherstep (min: number, max: number, x: number) {\n x = saturate(normalize(x, min, max))\n return x * x * x * (x * (x * 6 - 15) + 10)\n}\n\nexport function smootheststep (min: number, max: number, x: number) {\n x = saturate(normalize(x, min, max))\n return (\n -20 * Math.pow(x, 7) +\n 70 * Math.pow(x, 6) -\n 84 * Math.pow(x, 5) +\n 35 * Math.pow(x, 4)\n )\n}\n\nexport function almostIdentity (value: number, start: number, stop: number) {\n if (value > start) return value\n const a = 2 * stop - start\n const b = 2 * start - 3 * stop\n const t = value / start\n return (a * t + b) * t * t + stop\n}","\n/**\n * @license\n *\n * chroma.js - JavaScript library for color conversions\n * \n * Copyright (c) 2011-2017, Gregor Aisch\n * All rights reserved.\n * \n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n * \n * 1. Redistributions of source code must retain the above copyright notice, this\n * list of conditions and the following disclaimer.\n * \n * 2. Redistributions in binary form must reproduce the above copyright notice,\n * this list of conditions and the following disclaimer in the documentation\n * and/or other materials provided with the distribution.\n * \n * 3. The name Gregor Aisch may not be used to endorse or promote products\n * derived from this software without specific prior written permission.\n * \n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n * DISCLAIMED. IN NO EVENT SHALL GREGOR AISCH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,\n * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,\n * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\n * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY\n * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\n * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n *\n */\n\n(function() {\n var Color, DEG2RAD, LAB_CONSTANTS, PI, PITHIRD, RAD2DEG, TWOPI, _average_lrgb, _guess_formats, _guess_formats_sorted, _input, _interpolators, abs, atan2, bezier, blend, blend_f, brewer, burn, chroma, clip_rgb, cmyk2rgb, colors, cos, css2rgb, darken, dodge, each, floor, hcg2rgb, hex2rgb, hsi2rgb, hsl2css, hsl2rgb, hsv2rgb, interpolate, interpolate_hsx, interpolate_lab, interpolate_lrgb, interpolate_num, interpolate_rgb, lab2lch, lab2rgb, lab_xyz, lch2lab, lch2rgb, lighten, limit, log, luminance_x, m, max, multiply, normal, num2rgb, overlay, pow, rgb2cmyk, rgb2css, rgb2hcg, rgb2hex, rgb2hsi, rgb2hsl, rgb2hsv, rgb2lab, rgb2lch, rgb2luminance, rgb2num, rgb2temperature, rgb2xyz, rgb_xyz, rnd, root, round, screen, sin, sqrt, temperature2rgb, type, unpack, w3cx11, xyz_lab, xyz_rgb,\n slice = [].slice;\n\n type = (function() {\n\n /*\n for browser-safe type checking+\n ported from jQuery's $.type\n */\n var classToType, len, name, o, ref;\n classToType = {};\n ref = \"Boolean Number String Function Array Date RegExp Undefined Null\".split(\" \");\n for (o = 0, len = ref.length; o < len; o++) {\n name = ref[o];\n classToType[\"[object \" + name + \"]\"] = name.toLowerCase();\n }\n return function(obj) {\n var strType;\n strType = Object.prototype.toString.call(obj);\n return classToType[strType] || \"object\";\n };\n })();\n\n limit = function(x, min, max) {\n if (min == null) {\n min = 0;\n }\n if (max == null) {\n max = 1;\n }\n if (x < min) {\n x = min;\n }\n if (x > max) {\n x = max;\n }\n return x;\n };\n\n unpack = function(args) {\n if (args.length >= 3) {\n return Array.prototype.slice.call(args);\n } else {\n return args[0];\n }\n };\n\n clip_rgb = function(rgb) {\n var i, o;\n rgb._clipped = false;\n rgb._unclipped = rgb.slice(0);\n for (i = o = 0; o < 3; i = ++o) {\n if (i < 3) {\n if (rgb[i] < 0 || rgb[i] > 255) {\n rgb._clipped = true;\n }\n if (rgb[i] < 0) {\n rgb[i] = 0;\n }\n if (rgb[i] > 255) {\n rgb[i] = 255;\n }\n } else if (i === 3) {\n if (rgb[i] < 0) {\n rgb[i] = 0;\n }\n if (rgb[i] > 1) {\n rgb[i] = 1;\n }\n }\n }\n if (!rgb._clipped) {\n delete rgb._unclipped;\n }\n return rgb;\n };\n\n PI = Math.PI, round = Math.round, cos = Math.cos, floor = Math.floor, pow = Math.pow, log = Math.log, sin = Math.sin, sqrt = Math.sqrt, atan2 = Math.atan2, max = Math.max, abs = Math.abs;\n\n TWOPI = PI * 2;\n\n PITHIRD = PI / 3;\n\n DEG2RAD = PI / 180;\n\n RAD2DEG = 180 / PI;\n\n chroma = function() {\n if (arguments[0] instanceof Color) {\n return arguments[0];\n }\n return (function(func, args, ctor) {\n ctor.prototype = func.prototype;\n var child = new ctor, result = func.apply(child, args);\n return Object(result) === result ? result : child;\n })(Color, arguments, function(){});\n };\n\n chroma[\"default\"] = chroma;\n\n _interpolators = [];\n\n if ((typeof module !== \"undefined\" && module !== null) && (module.exports != null)) {\n module.exports = chroma;\n }\n\n if (typeof define === 'function' && define.amd) {\n define([], function() {\n return chroma;\n });\n } else {\n root = typeof exports !== \"undefined\" && exports !== null ? exports : this;\n root.chroma = chroma;\n }\n\n chroma.version = '1.4.1';\n\n _input = {};\n\n _guess_formats = [];\n\n _guess_formats_sorted = false;\n\n Color = (function() {\n function Color() {\n var arg, args, chk, len, len1, me, mode, o, w;\n me = this;\n args = [];\n for (o = 0, len = arguments.length; o < len; o++) {\n arg = arguments[o];\n if (arg != null) {\n args.push(arg);\n }\n }\n if (args.length > 1) {\n mode = args[args.length - 1];\n }\n if (_input[mode] != null) {\n me._rgb = clip_rgb(_input[mode](unpack(args.slice(0, -1))));\n } else {\n if (!_guess_formats_sorted) {\n _guess_formats = _guess_formats.sort(function(a, b) {\n return b.p - a.p;\n });\n _guess_formats_sorted = true;\n }\n for (w = 0, len1 = _guess_formats.length; w < len1; w++) {\n chk = _guess_formats[w];\n mode = chk.test.apply(chk, args);\n if (mode) {\n break;\n }\n }\n if (mode) {\n me._rgb = clip_rgb(_input[mode].apply(_input, args));\n }\n }\n if (me._rgb == null) {\n console.warn('unknown format: ' + args);\n }\n if (me._rgb == null) {\n me._rgb = [0, 0, 0];\n }\n if (me._rgb.length === 3) {\n me._rgb.push(1);\n }\n }\n\n Color.prototype.toString = function() {\n return this.hex();\n };\n\n return Color;\n\n })();\n\n chroma._input = _input;\n\n\n /**\n \tColorBrewer colors for chroma.js\n \n \tCopyright (c) 2002 Cynthia Brewer, Mark Harrower, and The \n \tPennsylvania State University.\n \n \tLicensed under the Apache License, Version 2.0 (the \"License\"); \n \tyou may not use this file except in compliance with the License.\n \tYou may obtain a copy of the License at\t\n \thttp://www.apache.org/licenses/LICENSE-2.0\n \n \tUnless required by applicable law or agreed to in writing, software distributed\n \tunder the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR\n \tCONDITIONS OF ANY KIND, either express or implied. See the License for the\n \tspecific language governing permissions and limitations under the License.\n \n @preserve\n */\n\n chroma.brewer = brewer = {\n OrRd: ['#fff7ec', '#fee8c8', '#fdd49e', '#fdbb84', '#fc8d59', '#ef6548', '#d7301f', '#b30000', '#7f0000'],\n PuBu: ['#fff7fb', '#ece7f2', '#d0d1e6', '#a6bddb', '#74a9cf', '#3690c0', '#0570b0', '#045a8d', '#023858'],\n BuPu: ['#f7fcfd', '#e0ecf4', '#bfd3e6', '#9ebcda', '#8c96c6', '#8c6bb1', '#88419d', '#810f7c', '#4d004b'],\n Oranges: ['#fff5eb', '#fee6ce', '#fdd0a2', '#fdae6b', '#fd8d3c', '#f16913', '#d94801', '#a63603', '#7f2704'],\n BuGn: ['#f7fcfd', '#e5f5f9', '#ccece6', '#99d8c9', '#66c2a4', '#41ae76', '#238b45', '#006d2c', '#00441b'],\n YlOrBr: ['#ffffe5', '#fff7bc', '#fee391', '#fec44f', '#fe9929', '#ec7014', '#cc4c02', '#993404', '#662506'],\n YlGn: ['#ffffe5', '#f7fcb9', '#d9f0a3', '#addd8e', '#78c679', '#41ab5d', '#238443', '#006837', '#004529'],\n Reds: ['#fff5f0', '#fee0d2', '#fcbba1', '#fc9272', '#fb6a4a', '#ef3b2c', '#cb181d', '#a50f15', '#67000d'],\n RdPu: ['#fff7f3', '#fde0dd', '#fcc5c0', '#fa9fb5', '#f768a1', '#dd3497', '#ae017e', '#7a0177', '#49006a'],\n Greens: ['#f7fcf5', '#e5f5e0', '#c7e9c0', '#a1d99b', '#74c476', '#41ab5d', '#238b45', '#006d2c', '#00441b'],\n YlGnBu: ['#ffffd9', '#edf8b1', '#c7e9b4', '#7fcdbb', '#41b6c4', '#1d91c0', '#225ea8', '#253494', '#081d58'],\n Purples: ['#fcfbfd', '#efedf5', '#dadaeb', '#bcbddc', '#9e9ac8', '#807dba', '#6a51a3', '#54278f', '#3f007d'],\n GnBu: ['#f7fcf0', '#e0f3db', '#ccebc5', '#a8ddb5', '#7bccc4', '#4eb3d3', '#2b8cbe', '#0868ac', '#084081'],\n Greys: ['#ffffff', '#f0f0f0', '#d9d9d9', '#bdbdbd', '#969696', '#737373', '#525252', '#252525', '#000000'],\n YlOrRd: ['#ffffcc', '#ffeda0', '#fed976', '#feb24c', '#fd8d3c', '#fc4e2a', '#e31a1c', '#bd0026', '#800026'],\n PuRd: ['#f7f4f9', '#e7e1ef', '#d4b9da', '#c994c7', '#df65b0', '#e7298a', '#ce1256', '#980043', '#67001f'],\n Blues: ['#f7fbff', '#deebf7', '#c6dbef', '#9ecae1', '#6baed6', '#4292c6', '#2171b5', '#08519c', '#08306b'],\n PuBuGn: ['#fff7fb', '#ece2f0', '#d0d1e6', '#a6bddb', '#67a9cf', '#3690c0', '#02818a', '#016c59', '#014636'],\n Viridis: ['#440154', '#482777', '#3f4a8a', '#31678e', '#26838f', '#1f9d8a', '#6cce5a', '#b6de2b', '#fee825'],\n Spectral: ['#9e0142', '#d53e4f', '#f46d43', '#fdae61', '#fee08b', '#ffffbf', '#e6f598', '#abdda4', '#66c2a5', '#3288bd', '#5e4fa2'],\n RdYlGn: ['#a50026', '#d73027', '#f46d43', '#fdae61', '#fee08b', '#ffffbf', '#d9ef8b', '#a6d96a', '#66bd63', '#1a9850', '#006837'],\n RdBu: ['#67001f', '#b2182b', '#d6604d', '#f4a582', '#fddbc7', '#f7f7f7', '#d1e5f0', '#92c5de', '#4393c3', '#2166ac', '#053061'],\n PiYG: ['#8e0152', '#c51b7d', '#de77ae', '#f1b6da', '#fde0ef', '#f7f7f7', '#e6f5d0', '#b8e186', '#7fbc41', '#4d9221', '#276419'],\n PRGn: ['#40004b', '#762a83', '#9970ab', '#c2a5cf', '#e7d4e8', '#f7f7f7', '#d9f0d3', '#a6dba0', '#5aae61', '#1b7837', '#00441b'],\n RdYlBu: ['#a50026', '#d73027', '#f46d43', '#fdae61', '#fee090', '#ffffbf', '#e0f3f8', '#abd9e9', '#74add1', '#4575b4', '#313695'],\n BrBG: ['#543005', '#8c510a', '#bf812d', '#dfc27d', '#f6e8c3', '#f5f5f5', '#c7eae5', '#80cdc1', '#35978f', '#01665e', '#003c30'],\n RdGy: ['#67001f', '#b2182b', '#d6604d', '#f4a582', '#fddbc7', '#ffffff', '#e0e0e0', '#bababa', '#878787', '#4d4d4d', '#1a1a1a'],\n PuOr: ['#7f3b08', '#b35806', '#e08214', '#fdb863', '#fee0b6', '#f7f7f7', '#d8daeb', '#b2abd2', '#8073ac', '#542788', '#2d004b'],\n Set2: ['#66c2a5', '#fc8d62', '#8da0cb', '#e78ac3', '#a6d854', '#ffd92f', '#e5c494', '#b3b3b3'],\n Accent: ['#7fc97f', '#beaed4', '#fdc086', '#ffff99', '#386cb0', '#f0027f', '#bf5b17', '#666666'],\n Set1: ['#e41a1c', '#377eb8', '#4daf4a', '#984ea3', '#ff7f00', '#ffff33', '#a65628', '#f781bf', '#999999'],\n Set3: ['#8dd3c7', '#ffffb3', '#bebada', '#fb8072', '#80b1d3', '#fdb462', '#b3de69', '#fccde5', '#d9d9d9', '#bc80bd', '#ccebc5', '#ffed6f'],\n Dark2: ['#1b9e77', '#d95f02', '#7570b3', '#e7298a', '#66a61e', '#e6ab02', '#a6761d', '#666666'],\n Paired: ['#a6cee3', '#1f78b4', '#b2df8a', '#33a02c', '#fb9a99', '#e31a1c', '#fdbf6f', '#ff7f00', '#cab2d6', '#6a3d9a', '#ffff99', '#b15928'],\n Pastel2: ['#b3e2cd', '#fdcdac', '#cbd5e8', '#f4cae4', '#e6f5c9', '#fff2ae', '#f1e2cc', '#cccccc'],\n Pastel1: ['#fbb4ae', '#b3cde3', '#ccebc5', '#decbe4', '#fed9a6', '#ffffcc', '#e5d8bd', '#fddaec', '#f2f2f2']\n };\n\n (function() {\n var key, results;\n results = [];\n for (key in brewer) {\n results.push(brewer[key.toLowerCase()] = brewer[key]);\n }\n return results;\n })();\n\n\n /**\n \tX11 color names\n \n \thttp://www.w3.org/TR/css3-color/#svg-color\n */\n\n w3cx11 = {\n aliceblue: '#f0f8ff',\n antiquewhite: '#faebd7',\n aqua: '#00ffff',\n aquamarine: '#7fffd4',\n azure: '#f0ffff',\n beige: '#f5f5dc',\n bisque: '#ffe4c4',\n black: '#000000',\n blanchedalmond: '#ffebcd',\n blue: '#0000ff',\n blueviolet: '#8a2be2',\n brown: '#a52a2a',\n burlywood: '#deb887',\n cadetblue: '#5f9ea0',\n chartreuse: '#7fff00',\n chocolate: '#d2691e',\n coral: '#ff7f50',\n cornflower: '#6495ed',\n cornflowerblue: '#6495ed',\n cornsilk: '#fff8dc',\n crimson: '#dc143c',\n cyan: '#00ffff',\n darkblue: '#00008b',\n darkcyan: '#008b8b',\n darkgoldenrod: '#b8860b',\n darkgray: '#a9a9a9',\n darkgreen: '#006400',\n darkgrey: '#a9a9a9',\n darkkhaki: '#bdb76b',\n darkmagenta: '#8b008b',\n darkolivegreen: '#556b2f',\n darkorange: '#ff8c00',\n darkorchid: '#9932cc',\n darkred: '#8b0000',\n darksalmon: '#e9967a',\n darkseagreen: '#8fbc8f',\n darkslateblue: '#483d8b',\n darkslategray: '#2f4f4f',\n darkslategrey: '#2f4f4f',\n darkturquoise: '#00ced1',\n darkviolet: '#9400d3',\n deeppink: '#ff1493',\n deepskyblue: '#00bfff',\n dimgray: '#696969',\n dimgrey: '#696969',\n dodgerblue: '#1e90ff',\n firebrick: '#b22222',\n floralwhite: '#fffaf0',\n forestgreen: '#228b22',\n fuchsia: '#ff00ff',\n gainsboro: '#dcdcdc',\n ghostwhite: '#f8f8ff',\n gold: '#ffd700',\n goldenrod: '#daa520',\n gray: '#808080',\n green: '#008000',\n greenyellow: '#adff2f',\n grey: '#808080',\n honeydew: '#f0fff0',\n hotpink: '#ff69b4',\n indianred: '#cd5c5c',\n indigo: '#4b0082',\n ivory: '#fffff0',\n khaki: '#f0e68c',\n laserlemon: '#ffff54',\n lavender: '#e6e6fa',\n lavenderblush: '#fff0f5',\n lawngreen: '#7cfc00',\n lemonchiffon: '#fffacd',\n lightblue: '#add8e6',\n lightcoral: '#f08080',\n lightcyan: '#e0ffff',\n lightgoldenrod: '#fafad2',\n lightgoldenrodyellow: '#fafad2',\n lightgray: '#d3d3d3',\n lightgreen: '#90ee90',\n lightgrey: '#d3d3d3',\n lightpink: '#ffb6c1',\n lightsalmon: '#ffa07a',\n lightseagreen: '#20b2aa',\n lightskyblue: '#87cefa',\n lightslategray: '#778899',\n lightslategrey: '#778899',\n lightsteelblue: '#b0c4de',\n lightyellow: '#ffffe0',\n lime: '#00ff00',\n limegreen: '#32cd32',\n linen: '#faf0e6',\n magenta: '#ff00ff',\n maroon: '#800000',\n maroon2: '#7f0000',\n maroon3: '#b03060',\n mediumaquamarine: '#66cdaa',\n mediumblue: '#0000cd',\n mediumorchid: '#ba55d3',\n mediumpurple: '#9370db',\n mediumseagreen: '#3cb371',\n mediumslateblue: '#7b68ee',\n mediumspringgreen: '#00fa9a',\n mediumturquoise: '#48d1cc',\n mediumvioletred: '#c71585',\n midnightblue: '#191970',\n mintcream: '#f5fffa',\n mistyrose: '#ffe4e1',\n moccasin: '#ffe4b5',\n navajowhite: '#ffdead',\n navy: '#000080',\n oldlace: '#fdf5e6',\n olive: '#808000',\n olivedrab: '#6b8e23',\n orange: '#ffa500',\n orangered: '#ff4500',\n orchid: '#da70d6',\n palegoldenrod: '#eee8aa',\n palegreen: '#98fb98',\n paleturquoise: '#afeeee',\n palevioletred: '#db7093',\n papayawhip: '#ffefd5',\n peachpuff: '#ffdab9',\n peru: '#cd853f',\n pink: '#ffc0cb',\n plum: '#dda0dd',\n powderblue: '#b0e0e6',\n purple: '#800080',\n purple2: '#7f007f',\n purple3: '#a020f0',\n rebeccapurple: '#663399',\n red: '#ff0000',\n rosybrown: '#bc8f8f',\n royalblue: '#4169e1',\n saddlebrown: '#8b4513',\n salmon: '#fa8072',\n sandybrown: '#f4a460',\n seagreen: '#2e8b57',\n seashell: '#fff5ee',\n sienna: '#a0522d',\n silver: '#c0c0c0',\n skyblue: '#87ceeb',\n slateblue: '#6a5acd',\n slategray: '#708090',\n slategrey: '#708090',\n snow: '#fffafa',\n springgreen: '#00ff7f',\n steelblue: '#4682b4',\n tan: '#d2b48c',\n teal: '#008080',\n thistle: '#d8bfd8',\n tomato: '#ff6347',\n turquoise: '#40e0d0',\n violet: '#ee82ee',\n wheat: '#f5deb3',\n white: '#ffffff',\n whitesmoke: '#f5f5f5',\n yellow: '#ffff00',\n yellowgreen: '#9acd32'\n };\n\n chroma.colors = colors = w3cx11;\n\n lab2rgb = function() {\n var a, args, b, g, l, r, x, y, z;\n args = unpack(arguments);\n l = args[0], a = args[1], b = args[2];\n y = (l + 16) / 116;\n x = isNaN(a) ? y : y + a / 500;\n z = isNaN(b) ? y : y - b / 200;\n y = LAB_CONSTANTS.Yn * lab_xyz(y);\n x = LAB_CONSTANTS.Xn * lab_xyz(x);\n z = LAB_CONSTANTS.Zn * lab_xyz(z);\n r = xyz_rgb(3.2404542 * x - 1.5371385 * y - 0.4985314 * z);\n g = xyz_rgb(-0.9692660 * x + 1.8760108 * y + 0.0415560 * z);\n b = xyz_rgb(0.0556434 * x - 0.2040259 * y + 1.0572252 * z);\n return [r, g, b, args.length > 3 ? args[3] : 1];\n };\n\n xyz_rgb = function(r) {\n return 255 * (r <= 0.00304 ? 12.92 * r : 1.055 * pow(r, 1 / 2.4) - 0.055);\n };\n\n lab_xyz = function(t) {\n if (t > LAB_CONSTANTS.t1) {\n return t * t * t;\n } else {\n return LAB_CONSTANTS.t2 * (t - LAB_CONSTANTS.t0);\n }\n };\n\n LAB_CONSTANTS = {\n Kn: 18,\n Xn: 0.950470,\n Yn: 1,\n Zn: 1.088830,\n t0: 0.137931034,\n t1: 0.206896552,\n t2: 0.12841855,\n t3: 0.008856452\n };\n\n rgb2lab = function() {\n var b, g, r, ref, ref1, x, y, z;\n ref = unpack(arguments), r = ref[0], g = ref[1], b = ref[2];\n ref1 = rgb2xyz(r, g, b), x = ref1[0], y = ref1[1], z = ref1[2];\n return [116 * y - 16, 500 * (x - y), 200 * (y - z)];\n };\n\n rgb_xyz = function(r) {\n if ((r /= 255) <= 0.04045) {\n return r / 12.92;\n } else {\n return pow((r + 0.055) / 1.055, 2.4);\n }\n };\n\n xyz_lab = function(t) {\n if (t > LAB_CONSTANTS.t3) {\n return pow(t, 1 / 3);\n } else {\n return t / LAB_CONSTANTS.t2 + LAB_CONSTANTS.t0;\n }\n };\n\n rgb2xyz = function() {\n var b, g, r, ref, x, y, z;\n ref = unpack(arguments), r = ref[0], g = ref[1], b = ref[2];\n r = rgb_xyz(r);\n g = rgb_xyz(g);\n b = rgb_xyz(b);\n x = xyz_lab((0.4124564 * r + 0.3575761 * g + 0.1804375 * b) / LAB_CONSTANTS.Xn);\n y = xyz_lab((0.2126729 * r + 0.7151522 * g + 0.0721750 * b) / LAB_CONSTANTS.Yn);\n z = xyz_lab((0.0193339 * r + 0.1191920 * g + 0.9503041 * b) / LAB_CONSTANTS.Zn);\n return [x, y, z];\n };\n\n chroma.lab = function() {\n return (function(func, args, ctor) {\n ctor.prototype = func.prototype;\n var child = new ctor, result = func.apply(child, args);\n return Object(result) === result ? result : child;\n })(Color, slice.call(arguments).concat(['lab']), function(){});\n };\n\n _input.lab = lab2rgb;\n\n Color.prototype.lab = function() {\n return rgb2lab(this._rgb);\n };\n\n bezier = function(colors) {\n var I, I0, I1, c, lab0, lab1, lab2, lab3, ref, ref1, ref2;\n colors = (function() {\n var len, o, results;\n results = [];\n for (o = 0, len = colors.length; o < len; o++) {\n c = colors[o];\n results.push(chroma(c));\n }\n return results;\n })();\n if (colors.length === 2) {\n ref = (function() {\n var len, o, results;\n results = [];\n for (o = 0, len = colors.length; o < len; o++) {\n c = colors[o];\n results.push(c.lab());\n }\n return results;\n })(), lab0 = ref[0], lab1 = ref[1];\n I = function(t) {\n var i, lab;\n lab = (function() {\n var o, results;\n results = [];\n for (i = o = 0; o <= 2; i = ++o) {\n results.push(lab0[i] + t * (lab1[i] - lab0[i]));\n }\n return results;\n })();\n return chroma.lab.apply(chroma, lab);\n };\n } else if (colors.length === 3) {\n ref1 = (function() {\n var len, o, results;\n results = [];\n for (o = 0, len = colors.length; o < len; o++) {\n c = colors[o];\n results.push(c.lab());\n }\n return results;\n })(), lab0 = ref1[0], lab1 = ref1[1], lab2 = ref1[2];\n I = function(t) {\n var i, lab;\n lab = (function() {\n var o, results;\n results = [];\n for (i = o = 0; o <= 2; i = ++o) {\n results.push((1 - t) * (1 - t) * lab0[i] + 2 * (1 - t) * t * lab1[i] + t * t * lab2[i]);\n }\n return results;\n })();\n return chroma.lab.apply(chroma, lab);\n };\n } else if (colors.length === 4) {\n ref2 = (function() {\n var len, o, results;\n results = [];\n for (o = 0, len = colors.length; o < len; o++) {\n c = colors[o];\n results.push(c.lab());\n }\n return results;\n })(), lab0 = ref2[0], lab1 = ref2[1], lab2 = ref2[2], lab3 = ref2[3];\n I = function(t) {\n var i, lab;\n lab = (function() {\n var o, results;\n results = [];\n for (i = o = 0; o <= 2; i = ++o) {\n results.push((1 - t) * (1 - t) * (1 - t) * lab0[i] + 3 * (1 - t) * (1 - t) * t * lab1[i] + 3 * (1 - t) * t * t * lab2[i] + t * t * t * lab3[i]);\n }\n return results;\n })();\n return chroma.lab.apply(chroma, lab);\n };\n } else if (colors.length === 5) {\n I0 = bezier(colors.slice(0, 3));\n I1 = bezier(colors.slice(2, 5));\n I = function(t) {\n if (t < 0.5) {\n return I0(t * 2);\n } else {\n return I1((t - 0.5) * 2);\n }\n };\n }\n return I;\n };\n\n chroma.bezier = function(colors) {\n var f;\n f = bezier(colors);\n f.scale = function() {\n return chroma.scale(f);\n };\n return f;\n };\n\n chroma.cubehelix = function(start, rotations, hue, gamma, lightness) {\n var dh, dl, f;\n if (start == null) {\n start = 300;\n }\n if (rotations == null) {\n rotations = -1.5;\n }\n if (hue == null) {\n hue = 1;\n }\n if (gamma == null) {\n gamma = 1;\n }\n if (lightness == null) {\n lightness = [0, 1];\n }\n dh = 0;\n if (type(lightness) === 'array') {\n dl = lightness[1] - lightness[0];\n } else {\n dl = 0;\n lightness = [lightness, lightness];\n }\n f = function(fract) {\n var a, amp, b, cos_a, g, h, l, r, sin_a;\n a = TWOPI * ((start + 120) / 360 + rotations * fract);\n l = pow(lightness[0] + dl * fract, gamma);\n h = dh !== 0 ? hue[0] + fract * dh : hue;\n amp = h * l * (1 - l) / 2;\n cos_a = cos(a);\n sin_a = sin(a);\n r = l + amp * (-0.14861 * cos_a + 1.78277 * sin_a);\n g = l + amp * (-0.29227 * cos_a - 0.90649 * sin_a);\n b = l + amp * (+1.97294 * cos_a);\n return chroma(clip_rgb([r * 255, g * 255, b * 255, 1]));\n };\n f.start = function(s) {\n if (s == null) {\n return start;\n }\n start = s;\n return f;\n };\n f.rotations = function(r) {\n if (r == null) {\n return rotations;\n }\n rotations = r;\n return f;\n };\n f.gamma = function(g) {\n if (g == null) {\n return gamma;\n }\n gamma = g;\n return f;\n };\n f.hue = function(h) {\n if (h == null) {\n return hue;\n }\n hue = h;\n if (type(hue) === 'array') {\n dh = hue[1] - hue[0];\n if (dh === 0) {\n hue = hue[1];\n }\n } else {\n dh = 0;\n }\n return f;\n };\n f.lightness = function(h) {\n if (h == null) {\n return lightness;\n }\n if (type(h) === 'array') {\n lightness = h;\n dl = h[1] - h[0];\n } else {\n lightness = [h, h];\n dl = 0;\n }\n return f;\n };\n f.scale = function() {\n return chroma.scale(f);\n };\n f.hue(hue);\n return f;\n };\n\n chroma.random = function() {\n var code, digits, i, o;\n digits = '0123456789abcdef';\n code = '#';\n for (i = o = 0; o < 6; i = ++o) {\n code += digits.charAt(floor(Math.random() * 16));\n }\n return new Color(code);\n };\n\n _interpolators = [];\n\n interpolate = function(col1, col2, f, m) {\n var interpol, len, o, res;\n if (f == null) {\n f = 0.5;\n }\n if (m == null) {\n m = 'rgb';\n }\n\n /*\n interpolates between colors\n f = 0 --> me\n f = 1 --> col\n */\n if (type(col1) !== 'object') {\n col1 = chroma(col1);\n }\n if (type(col2) !== 'object') {\n col2 = chroma(col2);\n }\n for (o = 0, len = _interpolators.length; o < len; o++) {\n interpol = _interpolators[o];\n if (m === interpol[0]) {\n res = interpol[1](col1, col2, f, m);\n break;\n }\n }\n if (res == null) {\n throw \"color mode \" + m + \" is not supported\";\n }\n return res.alpha(col1.alpha() + f * (col2.alpha() - col1.alpha()));\n };\n\n chroma.interpolate = interpolate;\n\n Color.prototype.interpolate = function(col2, f, m) {\n return interpolate(this, col2, f, m);\n };\n\n chroma.mix = interpolate;\n\n Color.prototype.mix = Color.prototype.interpolate;\n\n _input.rgb = function() {\n var k, ref, results, v;\n ref = unpack(arguments);\n results = [];\n for (k in ref) {\n v = ref[k];\n results.push(v);\n }\n return results;\n };\n\n chroma.rgb = function() {\n return (function(func, args, ctor) {\n ctor.prototype = func.prototype;\n var child = new ctor, result = func.apply(child, args);\n return Object(result) === result ? result : child;\n })(Color, slice.call(arguments).concat(['rgb']), function(){});\n };\n\n Color.prototype.rgb = function(round) {\n if (round == null) {\n round = true;\n }\n if (round) {\n return this._rgb.map(Math.round).slice(0, 3);\n } else {\n return this._rgb.slice(0, 3);\n }\n };\n\n Color.prototype.rgba = function(round) {\n if (round == null) {\n round = true;\n }\n if (!round) {\n return this._rgb.slice(0);\n }\n return [Math.round(this._rgb[0]), Math.round(this._rgb[1]), Math.round(this._rgb[2]), this._rgb[3]];\n };\n\n _guess_formats.push({\n p: 3,\n test: function(n) {\n var a;\n a = unpack(arguments);\n if (type(a) === 'array' && a.length === 3) {\n return 'rgb';\n }\n if (a.length === 4 && type(a[3]) === \"number\" && a[3] >= 0 && a[3] <= 1) {\n return 'rgb';\n }\n }\n });\n\n _input.lrgb = _input.rgb;\n\n interpolate_lrgb = function(col1, col2, f, m) {\n var xyz0, xyz1;\n xyz0 = col1._rgb;\n xyz1 = col2._rgb;\n return new Color(sqrt(pow(xyz0[0], 2) * (1 - f) + pow(xyz1[0], 2) * f), sqrt(pow(xyz0[1], 2) * (1 - f) + pow(xyz1[1], 2) * f), sqrt(pow(xyz0[2], 2) * (1 - f) + pow(xyz1[2], 2) * f), m);\n };\n\n _average_lrgb = function(colors) {\n var col, f, len, o, rgb, xyz;\n f = 1 / colors.length;\n xyz = [0, 0, 0, 0];\n for (o = 0, len = colors.length; o < len; o++) {\n col = colors[o];\n rgb = col._rgb;\n xyz[0] += pow(rgb[0], 2) * f;\n xyz[1] += pow(rgb[1], 2) * f;\n xyz[2] += pow(rgb[2], 2) * f;\n xyz[3] += rgb[3] * f;\n }\n xyz[0] = sqrt(xyz[0]);\n xyz[1] = sqrt(xyz[1]);\n xyz[2] = sqrt(xyz[2]);\n if (xyz[3] > 1) {\n xyz[3] = 1;\n }\n return new Color(clip_rgb(xyz));\n };\n\n _interpolators.push(['lrgb', interpolate_lrgb]);\n\n chroma.average = function(colors, mode) {\n var A, alpha, c, cnt, dx, dy, first, i, l, len, o, xyz, xyz2;\n if (mode == null) {\n mode = 'rgb';\n }\n l = colors.length;\n colors = colors.map(function(c) {\n return chroma(c);\n });\n first = colors.splice(0, 1)[0];\n if (mode === 'lrgb') {\n return _average_lrgb(colors);\n }\n xyz = first.get(mode);\n cnt = [];\n dx = 0;\n dy = 0;\n for (i in xyz) {\n xyz[i] = xyz[i] || 0;\n cnt.push(isNaN(xyz[i]) ? 0 : 1);\n if (mode.charAt(i) === 'h' && !isNaN(xyz[i])) {\n A = xyz[i] / 180 * PI;\n dx += cos(A);\n dy += sin(A);\n }\n }\n alpha = first.alpha();\n for (o = 0, len = colors.length; o < len; o++) {\n c = colors[o];\n xyz2 = c.get(mode);\n alpha += c.alpha();\n for (i in xyz) {\n if (!isNaN(xyz2[i])) {\n cnt[i] += 1;\n if (mode.charAt(i) === 'h') {\n A = xyz2[i] / 180 * PI;\n dx += cos(A);\n dy += sin(A);\n } else {\n xyz[i] += xyz2[i];\n }\n }\n }\n }\n for (i in xyz) {\n if (mode.charAt(i) === 'h') {\n A = atan2(dy / cnt[i], dx / cnt[i]) / PI * 180;\n while (A < 0) {\n A += 360;\n }\n while (A >= 360) {\n A -= 360;\n }\n xyz[i] = A;\n } else {\n xyz[i] = xyz[i] / cnt[i];\n }\n }\n return chroma(xyz, mode).alpha(alpha / l);\n };\n\n hex2rgb = function(hex) {\n var a, b, g, r, rgb, u;\n if (hex.match(/^#?([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/)) {\n if (hex.length === 4 || hex.length === 7) {\n hex = hex.substr(1);\n }\n if (hex.length === 3) {\n hex = hex.split(\"\");\n hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2];\n }\n u = parseInt(hex, 16);\n r = u >> 16;\n g = u >> 8 & 0xFF;\n b = u & 0xFF;\n return [r, g, b, 1];\n }\n if (hex.match(/^#?([A-Fa-f0-9]{8})$/)) {\n if (hex.length === 9) {\n hex = hex.substr(1);\n }\n u = parseInt(hex, 16);\n r = u >> 24 & 0xFF;\n g = u >> 16 & 0xFF;\n b = u >> 8 & 0xFF;\n a = round((u & 0xFF) / 0xFF * 100) / 100;\n return [r, g, b, a];\n }\n if ((_input.css != null) && (rgb = _input.css(hex))) {\n return rgb;\n }\n throw \"unknown color: \" + hex;\n };\n\n rgb2hex = function(channels, mode) {\n var a, b, g, hxa, r, str, u;\n if (mode == null) {\n mode = 'auto';\n }\n r = channels[0], g = channels[1], b = channels[2], a = channels[3];\n if (mode === 'auto') {\n mode = a < 1 ? 'rgba' : 'rgb';\n }\n r = Math.round(r);\n g = Math.round(g);\n b = Math.round(b);\n u = r << 16 | g << 8 | b;\n str = \"000000\" + u.toString(16);\n str = str.substr(str.length - 6);\n hxa = '0' + round(a * 255).toString(16);\n hxa = hxa.substr(hxa.length - 2);\n return \"#\" + (function() {\n switch (mode.toLowerCase()) {\n case 'rgba':\n return str + hxa;\n case 'argb':\n return hxa + str;\n default:\n return str;\n }\n })();\n };\n\n _input.hex = function(h) {\n return hex2rgb(h);\n };\n\n chroma.hex = function() {\n return (function(func, args, ctor) {\n ctor.prototype = func.prototype;\n var child = new ctor, result = func.apply(child, args);\n return Object(result) === result ? result : child;\n })(Color, slice.call(arguments).concat(['hex']), function(){});\n };\n\n Color.prototype.hex = function(mode) {\n if (mode == null) {\n mode = 'auto';\n }\n return rgb2hex(this._rgb, mode);\n };\n\n _guess_formats.push({\n p: 4,\n test: function(n) {\n if (arguments.length === 1 && type(n) === \"string\") {\n return 'hex';\n }\n }\n });\n\n hsl2rgb = function() {\n var args, b, c, g, h, i, l, o, r, ref, s, t1, t2, t3;\n args = unpack(arguments);\n h = args[0], s = args[1], l = args[2];\n if (s === 0) {\n r = g = b = l * 255;\n } else {\n t3 = [0, 0, 0];\n c = [0, 0, 0];\n t2 = l < 0.5 ? l * (1 + s) : l + s - l * s;\n t1 = 2 * l - t2;\n h /= 360;\n t3[0] = h + 1 / 3;\n t3[1] = h;\n t3[2] = h - 1 / 3;\n for (i = o = 0; o <= 2; i = ++o) {\n if (t3[i] < 0) {\n t3[i] += 1;\n }\n if (t3[i] > 1) {\n t3[i] -= 1;\n }\n if (6 * t3[i] < 1) {\n c[i] = t1 + (t2 - t1) * 6 * t3[i];\n } else if (2 * t3[i] < 1) {\n c[i] = t2;\n } else if (3 * t3[i] < 2) {\n c[i] = t1 + (t2 - t1) * ((2 / 3) - t3[i]) * 6;\n } else {\n c[i] = t1;\n }\n }\n ref = [round(c[0] * 255), round(c[1] * 255), round(c[2] * 255)], r = ref[0], g = ref[1], b = ref[2];\n }\n if (args.length > 3) {\n return [r, g, b, args[3]];\n } else {\n return [r, g, b];\n }\n };\n\n rgb2hsl = function(r, g, b) {\n var h, l, min, ref, s;\n if (r !== void 0 && r.length >= 3) {\n ref = r, r = ref[0], g = ref[1], b = ref[2];\n }\n r /= 255;\n g /= 255;\n b /= 255;\n min = Math.min(r, g, b);\n max = Math.max(r, g, b);\n l = (max + min) / 2;\n if (max === min) {\n s = 0;\n h = Number.NaN;\n } else {\n s = l < 0.5 ? (max - min) / (max + min) : (max - min) / (2 - max - min);\n }\n if (r === max) {\n h = (g - b) / (max - min);\n } else if (g === max) {\n h = 2 + (b - r) / (max - min);\n } else if (b === max) {\n h = 4 + (r - g) / (max - min);\n }\n h *= 60;\n if (h < 0) {\n h += 360;\n }\n return [h, s, l];\n };\n\n chroma.hsl = function() {\n return (function(func, args, ctor) {\n ctor.prototype = func.prototype;\n var child = new ctor, result = func.apply(child, args);\n return Object(result) === result ? result : child;\n })(Color, slice.call(arguments).concat(['hsl']), function(){});\n };\n\n _input.hsl = hsl2rgb;\n\n Color.prototype.hsl = function() {\n return rgb2hsl(this._rgb);\n };\n\n hsv2rgb = function() {\n var args, b, f, g, h, i, p, q, r, ref, ref1, ref2, ref3, ref4, ref5, s, t, v;\n args = unpack(arguments);\n h = args[0], s = args[1], v = args[2];\n v *= 255;\n if (s === 0) {\n r = g = b = v;\n } else {\n if (h === 360) {\n h = 0;\n }\n if (h > 360) {\n h -= 360;\n }\n if (h < 0) {\n h += 360;\n }\n h /= 60;\n i = floor(h);\n f = h - i;\n p = v * (1 - s);\n q = v * (1 - s * f);\n t = v * (1 - s * (1 - f));\n switch (i) {\n case 0:\n ref = [v, t, p], r = ref[0], g = ref[1], b = ref[2];\n break;\n case 1:\n ref1 = [q, v, p], r = ref1[0], g = ref1[1], b = ref1[2];\n break;\n case 2:\n ref2 = [p, v, t], r = ref2[0], g = ref2[1], b = ref2[2];\n break;\n case 3:\n ref3 = [p, q, v], r = ref3[0], g = ref3[1], b = ref3[2];\n break;\n case 4:\n ref4 = [t, p, v], r = ref4[0], g = ref4[1], b = ref4[2];\n break;\n case 5:\n ref5 = [v, p, q], r = ref5[0], g = ref5[1], b = ref5[2];\n }\n }\n return [r, g, b, args.length > 3 ? args[3] : 1];\n };\n\n rgb2hsv = function() {\n var b, delta, g, h, min, r, ref, s, v;\n ref = unpack(arguments), r = ref[0], g = ref[1], b = ref[2];\n min = Math.min(r, g, b);\n max = Math.max(r, g, b);\n delta = max - min;\n v = max / 255.0;\n if (max === 0) {\n h = Number.NaN;\n s = 0;\n } else {\n s = delta / max;\n if (r === max) {\n h = (g - b) / delta;\n }\n if (g === max) {\n h = 2 + (b - r) / delta;\n }\n if (b === max) {\n h = 4 + (r - g) / delta;\n }\n h *= 60;\n if (h < 0) {\n h += 360;\n }\n }\n return [h, s, v];\n };\n\n chroma.hsv = function() {\n return (function(func, args, ctor) {\n ctor.prototype = func.prototype;\n var child = new ctor, result = func.apply(child, args);\n return Object(result) === result ? result : child;\n })(Color, slice.call(arguments).concat(['hsv']), function(){});\n };\n\n _input.hsv = hsv2rgb;\n\n Color.prototype.hsv = function() {\n return rgb2hsv(this._rgb);\n };\n\n num2rgb = function(num) {\n var b, g, r;\n if (type(num) === \"number\" && num >= 0 && num <= 0xFFFFFF) {\n r = num >> 16;\n g = (num >> 8) & 0xFF;\n b = num & 0xFF;\n return [r, g, b, 1];\n }\n console.warn(\"unknown num color: \" + num);\n return [0, 0, 0, 1];\n };\n\n rgb2num = function() {\n var b, g, r, ref;\n ref = unpack(arguments), r = ref[0], g = ref[1], b = ref[2];\n return (r << 16) + (g << 8) + b;\n };\n\n chroma.num = function(num) {\n return new Color(num, 'num');\n };\n\n Color.prototype.num = function(mode) {\n if (mode == null) {\n mode = 'rgb';\n }\n return rgb2num(this._rgb, mode);\n };\n\n _input.num = num2rgb;\n\n _guess_formats.push({\n p: 1,\n test: function(n) {\n if (arguments.length === 1 && type(n) === \"number\" && n >= 0 && n <= 0xFFFFFF) {\n return 'num';\n }\n }\n });\n\n hcg2rgb = function() {\n var _c, _g, args, b, c, f, g, h, i, p, q, r, ref, ref1, ref2, ref3, ref4, ref5, t, v;\n args = unpack(arguments);\n h = args[0], c = args[1], _g = args[2];\n c = c / 100;\n g = g / 100 * 255;\n _c = c * 255;\n if (c === 0) {\n r = g = b = _g;\n } else {\n if (h === 360) {\n h = 0;\n }\n if (h > 360) {\n h -= 360;\n }\n if (h < 0) {\n h += 360;\n }\n h /= 60;\n i = floor(h);\n f = h - i;\n p = _g * (1 - c);\n q = p + _c * (1 - f);\n t = p + _c * f;\n v = p + _c;\n switch (i) {\n case 0:\n ref = [v, t, p], r = ref[0], g = ref[1], b = ref[2];\n break;\n case 1:\n ref1 = [q, v, p], r = ref1[0], g = ref1[1], b = ref1[2];\n break;\n case 2:\n ref2 = [p, v, t], r = ref2[0], g = ref2[1], b = ref2[2];\n break;\n case 3:\n ref3 = [p, q, v], r = ref3[0], g = ref3[1], b = ref3[2];\n break;\n case 4:\n ref4 = [t, p, v], r = ref4[0], g = ref4[1], b = ref4[2];\n break;\n case 5:\n ref5 = [v, p, q], r = ref5[0], g = ref5[1], b = ref5[2];\n }\n }\n return [r, g, b, args.length > 3 ? args[3] : 1];\n };\n\n rgb2hcg = function() {\n var _g, b, c, delta, g, h, min, r, ref;\n ref = unpack(arguments), r = ref[0], g = ref[1], b = ref[2];\n min = Math.min(r, g, b);\n max = Math.max(r, g, b);\n delta = max - min;\n c = delta * 100 / 255;\n _g = min / (255 - delta) * 100;\n if (delta === 0) {\n h = Number.NaN;\n } else {\n if (r === max) {\n h = (g - b) / delta;\n }\n if (g === max) {\n h = 2 + (b - r) / delta;\n }\n if (b === max) {\n h = 4 + (r - g) / delta;\n }\n h *= 60;\n if (h < 0) {\n h += 360;\n }\n }\n return [h, c, _g];\n };\n\n chroma.hcg = function() {\n return (function(func, args, ctor) {\n ctor.prototype = func.prototype;\n var child = new ctor, result = func.apply(child, args);\n return Object(result) === result ? result : child;\n })(Color, slice.call(arguments).concat(['hcg']), function(){});\n };\n\n _input.hcg = hcg2rgb;\n\n Color.prototype.hcg = function() {\n return rgb2hcg(this._rgb);\n };\n\n css2rgb = function(css) {\n var aa, ab, hsl, i, m, o, rgb, w;\n css = css.toLowerCase();\n if ((chroma.colors != null) && chroma.colors[css]) {\n return hex2rgb(chroma.colors[css]);\n }\n if (m = css.match(/rgb\\(\\s*(\\-?\\d+),\\s*(\\-?\\d+)\\s*,\\s*(\\-?\\d+)\\s*\\)/)) {\n rgb = m.slice(1, 4);\n for (i = o = 0; o <= 2; i = ++o) {\n rgb[i] = +rgb[i];\n }\n rgb[3] = 1;\n } else if (m = css.match(/rgba\\(\\s*(\\-?\\d+),\\s*(\\-?\\d+)\\s*,\\s*(\\-?\\d+)\\s*,\\s*([01]|[01]?\\.\\d+)\\)/)) {\n rgb = m.slice(1, 5);\n for (i = w = 0; w <= 3; i = ++w) {\n rgb[i] = +rgb[i];\n }\n } else if (m = css.match(/rgb\\(\\s*(\\-?\\d+(?:\\.\\d+)?)%,\\s*(\\-?\\d+(?:\\.\\d+)?)%\\s*,\\s*(\\-?\\d+(?:\\.\\d+)?)%\\s*\\)/)) {\n rgb = m.slice(1, 4);\n for (i = aa = 0; aa <= 2; i = ++aa) {\n rgb[i] = round(rgb[i] * 2.55);\n }\n rgb[3] = 1;\n } else if (m = css.match(/rgba\\(\\s*(\\-?\\d+(?:\\.\\d+)?)%,\\s*(\\-?\\d+(?:\\.\\d+)?)%\\s*,\\s*(\\-?\\d+(?:\\.\\d+)?)%\\s*,\\s*([01]|[01]?\\.\\d+)\\)/)) {\n rgb = m.slice(1, 5);\n for (i = ab = 0; ab <= 2; i = ++ab) {\n rgb[i] = round(rgb[i] * 2.55);\n }\n rgb[3] = +rgb[3];\n } else if (m = css.match(/hsl\\(\\s*(\\-?\\d+(?:\\.\\d+)?),\\s*(\\-?\\d+(?:\\.\\d+)?)%\\s*,\\s*(\\-?\\d+(?:\\.\\d+)?)%\\s*\\)/)) {\n hsl = m.slice(1, 4);\n hsl[1] *= 0.01;\n hsl[2] *= 0.01;\n rgb = hsl2rgb(hsl);\n rgb[3] = 1;\n } else if (m = css.match(/hsla\\(\\s*(\\-?\\d+(?:\\.\\d+)?),\\s*(\\-?\\d+(?:\\.\\d+)?)%\\s*,\\s*(\\-?\\d+(?:\\.\\d+)?)%\\s*,\\s*([01]|[01]?\\.\\d+)\\)/)) {\n hsl = m.slice(1, 4);\n hsl[1] *= 0.01;\n hsl[2] *= 0.01;\n rgb = hsl2rgb(hsl);\n rgb[3] = +m[4];\n }\n return rgb;\n };\n\n rgb2css = function(rgba) {\n var mode;\n mode = rgba[3] < 1 ? 'rgba' : 'rgb';\n if (mode === 'rgb') {\n return mode + '(' + rgba.slice(0, 3).map(round).join(',') + ')';\n } else if (mode === 'rgba') {\n return mode + '(' + rgba.slice(0, 3).map(round).join(',') + ',' + rgba[3] + ')';\n } else {\n\n }\n };\n\n rnd = function(a) {\n return round(a * 100) / 100;\n };\n\n hsl2css = function(hsl, alpha) {\n var mode;\n mode = alpha < 1 ? 'hsla' : 'hsl';\n hsl[0] = rnd(hsl[0] || 0);\n hsl[1] = rnd(hsl[1] * 100) + '%';\n hsl[2] = rnd(hsl[2] * 100) + '%';\n if (mode === 'hsla') {\n hsl[3] = alpha;\n }\n return mode + '(' + hsl.join(',') + ')';\n };\n\n _input.css = function(h) {\n return css2rgb(h);\n };\n\n chroma.css = function() {\n return (function(func, args, ctor) {\n ctor.prototype = func.prototype;\n var child = new ctor, result = func.apply(child, args);\n return Object(result) === result ? result : child;\n })(Color, slice.call(arguments).concat(['css']), function(){});\n };\n\n Color.prototype.css = function(mode) {\n if (mode == null) {\n mode = 'rgb';\n }\n if (mode.slice(0, 3) === 'rgb') {\n return rgb2css(this._rgb);\n } else if (mode.slice(0, 3) === 'hsl') {\n return hsl2css(this.hsl(), this.alpha());\n }\n };\n\n _input.named = function(name) {\n return hex2rgb(w3cx11[name]);\n };\n\n _guess_formats.push({\n p: 5,\n test: function(n) {\n if (arguments.length === 1 && (w3cx11[n] != null)) {\n return 'named';\n }\n }\n });\n\n Color.prototype.name = function(n) {\n var h, k;\n if (arguments.length) {\n if (w3cx11[n]) {\n this._rgb = hex2rgb(w3cx11[n]);\n }\n this._rgb[3] = 1;\n this;\n }\n h = this.hex('rgb');\n for (k in w3cx11) {\n if (h === w3cx11[k]) {\n return k;\n }\n }\n return h;\n };\n\n lch2lab = function() {\n\n /*\n Convert from a qualitative parameter h and a quantitative parameter l to a 24-bit pixel.\n These formulas were invented by David Dalrymple to obtain maximum contrast without going\n out of gamut if the parameters are in the range 0-1.\n \n A saturation multiplier was added by Gregor Aisch\n */\n var c, h, l, ref;\n ref = unpack(arguments), l = ref[0], c = ref[1], h = ref[2];\n h = h * DEG2RAD;\n return [l, cos(h) * c, sin(h) * c];\n };\n\n lch2rgb = function() {\n var L, a, args, b, c, g, h, l, r, ref, ref1;\n args = unpack(arguments);\n l = args[0], c = args[1], h = args[2];\n ref = lch2lab(l, c, h), L = ref[0], a = ref[1], b = ref[2];\n ref1 = lab2rgb(L, a, b), r = ref1[0], g = ref1[1], b = ref1[2];\n return [r, g, b, args.length > 3 ? args[3] : 1];\n };\n\n lab2lch = function() {\n var a, b, c, h, l, ref;\n ref = unpack(arguments), l = ref[0], a = ref[1], b = ref[2];\n c = sqrt(a * a + b * b);\n h = (atan2(b, a) * RAD2DEG + 360) % 360;\n if (round(c * 10000) === 0) {\n h = Number.NaN;\n }\n return [l, c, h];\n };\n\n rgb2lch = function() {\n var a, b, g, l, r, ref, ref1;\n ref = unpack(arguments), r = ref[0], g = ref[1], b = ref[2];\n ref1 = rgb2lab(r, g, b), l = ref1[0], a = ref1[1], b = ref1[2];\n return lab2lch(l, a, b);\n };\n\n chroma.lch = function() {\n var args;\n args = unpack(arguments);\n return new Color(args, 'lch');\n };\n\n chroma.hcl = function() {\n var args;\n args = unpack(arguments);\n return new Color(args, 'hcl');\n };\n\n _input.lch = lch2rgb;\n\n _input.hcl = function() {\n var c, h, l, ref;\n ref = unpack(arguments), h = ref[0], c = ref[1], l = ref[2];\n return lch2rgb([l, c, h]);\n };\n\n Color.prototype.lch = function() {\n return rgb2lch(this._rgb);\n };\n\n Color.prototype.hcl = function() {\n return rgb2lch(this._rgb).reverse();\n };\n\n rgb2cmyk = function(mode) {\n var b, c, f, g, k, m, r, ref, y;\n if (mode == null) {\n mode = 'rgb';\n }\n ref = unpack(arguments), r = ref[0], g = ref[1], b = ref[2];\n r = r / 255;\n g = g / 255;\n b = b / 255;\n k = 1 - Math.max(r, Math.max(g, b));\n f = k < 1 ? 1 / (1 - k) : 0;\n c = (1 - r - k) * f;\n m = (1 - g - k) * f;\n y = (1 - b - k) * f;\n return [c, m, y, k];\n };\n\n cmyk2rgb = function() {\n var alpha, args, b, c, g, k, m, r, y;\n args = unpack(arguments);\n c = args[0], m = args[1], y = args[2], k = args[3];\n alpha = args.length > 4 ? args[4] : 1;\n if (k === 1) {\n return [0, 0, 0, alpha];\n }\n r = c >= 1 ? 0 : 255 * (1 - c) * (1 - k);\n g = m >= 1 ? 0 : 255 * (1 - m) * (1 - k);\n b = y >= 1 ? 0 : 255 * (1 - y) * (1 - k);\n return [r, g, b, alpha];\n };\n\n _input.cmyk = function() {\n return cmyk2rgb(unpack(arguments));\n };\n\n chroma.cmyk = function() {\n return (function(func, args, ctor) {\n ctor.prototype = func.prototype;\n var child = new ctor, result = func.apply(child, args);\n return Object(result) === result ? result : child;\n })(Color, slice.call(arguments).concat(['cmyk']), function(){});\n };\n\n Color.prototype.cmyk = function() {\n return rgb2cmyk(this._rgb);\n };\n\n _input.gl = function() {\n var i, k, o, rgb, v;\n rgb = (function() {\n var ref, results;\n ref = unpack(arguments);\n results = [];\n for (k in ref) {\n v = ref[k];\n results.push(v);\n }\n return results;\n }).apply(this, arguments);\n for (i = o = 0; o <= 2; i = ++o) {\n rgb[i] *= 255;\n }\n return rgb;\n };\n\n chroma.gl = function() {\n return (function(func, args, ctor) {\n ctor.prototype = func.prototype;\n var child = new ctor, result = func.apply(child, args);\n return Object(result) === result ? result : child;\n })(Color, slice.call(arguments).concat(['gl']), function(){});\n };\n\n Color.prototype.gl = function() {\n var rgb;\n rgb = this._rgb;\n return [rgb[0] / 255, rgb[1] / 255, rgb[2] / 255, rgb[3]];\n };\n\n rgb2luminance = function(r, g, b) {\n var ref;\n ref = unpack(arguments), r = ref[0], g = ref[1], b = ref[2];\n r = luminance_x(r);\n g = luminance_x(g);\n b = luminance_x(b);\n return 0.2126 * r + 0.7152 * g + 0.0722 * b;\n };\n\n luminance_x = function(x) {\n x /= 255;\n if (x <= 0.03928) {\n return x / 12.92;\n } else {\n return pow((x + 0.055) / 1.055, 2.4);\n }\n };\n\n interpolate_rgb = function(col1, col2, f, m) {\n var xyz0, xyz1;\n xyz0 = col1._rgb;\n xyz1 = col2._rgb;\n return new Color(xyz0[0] + f * (xyz1[0] - xyz0[0]), xyz0[1] + f * (xyz1[1] - xyz0[1]), xyz0[2] + f * (xyz1[2] - xyz0[2]), m);\n };\n\n _interpolators.push(['rgb', interpolate_rgb]);\n\n Color.prototype.luminance = function(lum, mode) {\n var cur_lum, eps, max_iter, rgba, test;\n if (mode == null) {\n mode = 'rgb';\n }\n if (!arguments.length) {\n return rgb2luminance(this._rgb);\n }\n rgba = this._rgb;\n if (lum === 0) {\n rgba = [0, 0, 0, this._rgb[3]];\n } else if (lum === 1) {\n rgba = [255, 255, 255, this[3]];\n } else {\n cur_lum = rgb2luminance(this._rgb);\n eps = 1e-7;\n max_iter = 20;\n test = function(l, h) {\n var lm, m;\n m = l.interpolate(h, 0.5, mode);\n lm = m.luminance();\n if (Math.abs(lum - lm) < eps || !max_iter--) {\n return m;\n }\n if (lm > lum) {\n return test(l, m);\n }\n return test(m, h);\n };\n if (cur_lum > lum) {\n rgba = test(chroma('black'), this).rgba();\n } else {\n rgba = test(this, chroma('white')).rgba();\n }\n }\n return chroma(rgba).alpha(this.alpha());\n };\n\n temperature2rgb = function(kelvin) {\n var b, g, r, temp;\n temp = kelvin / 100;\n if (temp < 66) {\n r = 255;\n g = -155.25485562709179 - 0.44596950469579133 * (g = temp - 2) + 104.49216199393888 * log(g);\n b = temp < 20 ? 0 : -254.76935184120902 + 0.8274096064007395 * (b = temp - 10) + 115.67994401066147 * log(b);\n } else {\n r = 351.97690566805693 + 0.114206453784165 * (r = temp - 55) - 40.25366309332127 * log(r);\n g = 325.4494125711974 + 0.07943456536662342 * (g = temp - 50) - 28.0852963507957 * log(g);\n b = 255;\n }\n return [r, g, b];\n };\n\n rgb2temperature = function() {\n var b, eps, g, maxTemp, minTemp, r, ref, rgb, temp;\n ref = unpack(arguments), r = ref[0], g = ref[1], b = ref[2];\n minTemp = 1000;\n maxTemp = 40000;\n eps = 0.4;\n while (maxTemp - minTemp > eps) {\n temp = (maxTemp + minTemp) * 0.5;\n rgb = temperature2rgb(temp);\n if ((rgb[2] / rgb[0]) >= (b / r)) {\n maxTemp = temp;\n } else {\n minTemp = temp;\n }\n }\n return round(temp);\n };\n\n chroma.temperature = chroma.kelvin = function() {\n return (function(func, args, ctor) {\n ctor.prototype = func.prototype;\n var child = new ctor, result = func.apply(child, args);\n return Object(result) === result ? result : child;\n })(Color, slice.call(arguments).concat(['temperature']), function(){});\n };\n\n _input.temperature = _input.kelvin = _input.K = temperature2rgb;\n\n Color.prototype.temperature = function() {\n return rgb2temperature(this._rgb);\n };\n\n Color.prototype.kelvin = Color.prototype.temperature;\n\n chroma.contrast = function(a, b) {\n var l1, l2, ref, ref1;\n if ((ref = type(a)) === 'string' || ref === 'number') {\n a = new Color(a);\n }\n if ((ref1 = type(b)) === 'string' || ref1 === 'number') {\n b = new Color(b);\n }\n l1 = a.luminance();\n l2 = b.luminance();\n if (l1 > l2) {\n return (l1 + 0.05) / (l2 + 0.05);\n } else {\n return (l2 + 0.05) / (l1 + 0.05);\n }\n };\n\n chroma.distance = function(a, b, mode) {\n var d, i, l1, l2, ref, ref1, sum_sq;\n if (mode == null) {\n mode = 'lab';\n }\n if ((ref = type(a)) === 'string' || ref === 'number') {\n a = new Color(a);\n }\n if ((ref1 = type(b)) === 'string' || ref1 === 'number') {\n b = new Color(b);\n }\n l1 = a.get(mode);\n l2 = b.get(mode);\n sum_sq = 0;\n for (i in l1) {\n d = (l1[i] || 0) - (l2[i] || 0);\n sum_sq += d * d;\n }\n return Math.sqrt(sum_sq);\n };\n\n chroma.deltaE = function(a, b, L, C) {\n var L1, L2, a1, a2, b1, b2, c1, c2, c4, dH2, delA, delB, delC, delL, f, h1, ref, ref1, ref2, ref3, sc, sh, sl, t, v1, v2, v3;\n if (L == null) {\n L = 1;\n }\n if (C == null) {\n C = 1;\n }\n if ((ref = type(a)) === 'string' || ref === 'number') {\n a = new Color(a);\n }\n if ((ref1 = type(b)) === 'string' || ref1 === 'number') {\n b = new Color(b);\n }\n ref2 = a.lab(), L1 = ref2[0], a1 = ref2[1], b1 = ref2[2];\n ref3 = b.lab(), L2 = ref3[0], a2 = ref3[1], b2 = ref3[2];\n c1 = sqrt(a1 * a1 + b1 * b1);\n c2 = sqrt(a2 * a2 + b2 * b2);\n sl = L1 < 16.0 ? 0.511 : (0.040975 * L1) / (1.0 + 0.01765 * L1);\n sc = (0.0638 * c1) / (1.0 + 0.0131 * c1) + 0.638;\n h1 = c1 < 0.000001 ? 0.0 : (atan2(b1, a1) * 180.0) / PI;\n while (h1 < 0) {\n h1 += 360;\n }\n while (h1 >= 360) {\n h1 -= 360;\n }\n t = (h1 >= 164.0) && (h1 <= 345.0) ? 0.56 + abs(0.2 * cos((PI * (h1 + 168.0)) / 180.0)) : 0.36 + abs(0.4 * cos((PI * (h1 + 35.0)) / 180.0));\n c4 = c1 * c1 * c1 * c1;\n f = sqrt(c4 / (c4 + 1900.0));\n sh = sc * (f * t + 1.0 - f);\n delL = L1 - L2;\n delC = c1 - c2;\n delA = a1 - a2;\n delB = b1 - b2;\n dH2 = delA * delA + delB * delB - delC * delC;\n v1 = delL / (L * sl);\n v2 = delC / (C * sc);\n v3 = sh;\n return sqrt(v1 * v1 + v2 * v2 + (dH2 / (v3 * v3)));\n };\n\n Color.prototype.get = function(modechan) {\n var channel, i, me, mode, ref, src;\n me = this;\n ref = modechan.split('.'), mode = ref[0], channel = ref[1];\n src = me[mode]();\n if (channel) {\n i = mode.indexOf(channel);\n if (i > -1) {\n return src[i];\n } else {\n return console.warn('unknown channel ' + channel + ' in mode ' + mode);\n }\n } else {\n return src;\n }\n };\n\n Color.prototype.set = function(modechan, value) {\n var channel, i, me, mode, ref, src;\n me = this;\n ref = modechan.split('.'), mode = ref[0], channel = ref[1];\n if (channel) {\n src = me[mode]();\n i = mode.indexOf(channel);\n if (i > -1) {\n if (type(value) === 'string') {\n switch (value.charAt(0)) {\n case '+':\n src[i] += +value;\n break;\n case '-':\n src[i] += +value;\n break;\n case '*':\n src[i] *= +(value.substr(1));\n break;\n case '/':\n src[i] /= +(value.substr(1));\n break;\n default:\n src[i] = +value;\n }\n } else {\n src[i] = value;\n }\n } else {\n console.warn('unknown channel ' + channel + ' in mode ' + mode);\n }\n } else {\n src = value;\n }\n return chroma(src, mode).alpha(me.alpha());\n };\n\n Color.prototype.clipped = function() {\n return this._rgb._clipped || false;\n };\n\n Color.prototype.alpha = function(a) {\n if (arguments.length) {\n return chroma.rgb([this._rgb[0], this._rgb[1], this._rgb[2], a]);\n }\n return this._rgb[3];\n };\n\n Color.prototype.darken = function(amount) {\n var lab, me;\n if (amount == null) {\n amount = 1;\n }\n me = this;\n lab = me.lab();\n lab[0] -= LAB_CONSTANTS.Kn * amount;\n return chroma.lab(lab).alpha(me.alpha());\n };\n\n Color.prototype.brighten = function(amount) {\n if (amount == null) {\n amount = 1;\n }\n return this.darken(-amount);\n };\n\n Color.prototype.darker = Color.prototype.darken;\n\n Color.prototype.brighter = Color.prototype.brighten;\n\n Color.prototype.saturate = function(amount) {\n var lch, me;\n if (amount == null) {\n amount = 1;\n }\n me = this;\n lch = me.lch();\n lch[1] += amount * LAB_CONSTANTS.Kn;\n if (lch[1] < 0) {\n lch[1] = 0;\n }\n return chroma.lch(lch).alpha(me.alpha());\n };\n\n Color.prototype.desaturate = function(amount) {\n if (amount == null) {\n amount = 1;\n }\n return this.saturate(-amount);\n };\n\n Color.prototype.premultiply = function() {\n var a, rgb;\n rgb = this.rgb();\n a = this.alpha();\n return chroma(rgb[0] * a, rgb[1] * a, rgb[2] * a, a);\n };\n\n blend = function(bottom, top, mode) {\n if (!blend[mode]) {\n throw 'unknown blend mode ' + mode;\n }\n return blend[mode](bottom, top);\n };\n\n blend_f = function(f) {\n return function(bottom, top) {\n var c0, c1;\n c0 = chroma(top).rgb();\n c1 = chroma(bottom).rgb();\n return chroma(f(c0, c1), 'rgb');\n };\n };\n\n each = function(f) {\n return function(c0, c1) {\n var i, o, out;\n out = [];\n for (i = o = 0; o <= 3; i = ++o) {\n out[i] = f(c0[i], c1[i]);\n }\n return out;\n };\n };\n\n normal = function(a, b) {\n return a;\n };\n\n multiply = function(a, b) {\n return a * b / 255;\n };\n\n darken = function(a, b) {\n if (a > b) {\n return b;\n } else {\n return a;\n }\n };\n\n lighten = function(a, b) {\n if (a > b) {\n return a;\n } else {\n return b;\n }\n };\n\n screen = function(a, b) {\n return 255 * (1 - (1 - a / 255) * (1 - b / 255));\n };\n\n overlay = function(a, b) {\n if (b < 128) {\n return 2 * a * b / 255;\n } else {\n return 255 * (1 - 2 * (1 - a / 255) * (1 - b / 255));\n }\n };\n\n burn = function(a, b) {\n return 255 * (1 - (1 - b / 255) / (a / 255));\n };\n\n dodge = function(a, b) {\n if (a === 255) {\n return 255;\n }\n a = 255 * (b / 255) / (1 - a / 255);\n if (a > 255) {\n return 255;\n } else {\n return a;\n }\n };\n\n blend.normal = blend_f(each(normal));\n\n blend.multiply = blend_f(each(multiply));\n\n blend.screen = blend_f(each(screen));\n\n blend.overlay = blend_f(each(overlay));\n\n blend.darken = blend_f(each(darken));\n\n blend.lighten = blend_f(each(lighten));\n\n blend.dodge = blend_f(each(dodge));\n\n blend.burn = blend_f(each(burn));\n\n chroma.blend = blend;\n\n chroma.analyze = function(data) {\n var len, o, r, val;\n r = {\n min: Number.MAX_VALUE,\n max: Number.MAX_VALUE * -1,\n sum: 0,\n values: [],\n count: 0\n };\n for (o = 0, len = data.length; o < len; o++) {\n val = data[o];\n if ((val != null) && !isNaN(val)) {\n r.values.push(val);\n r.sum += val;\n if (val < r.min) {\n r.min = val;\n }\n if (val > r.max) {\n r.max = val;\n }\n r.count += 1;\n }\n }\n r.domain = [r.min, r.max];\n r.limits = function(mode, num) {\n return chroma.limits(r, mode, num);\n };\n return r;\n };\n\n chroma.scale = function(colors, positions) {\n var _classes, _colorCache, _colors, _correctLightness, _domain, _fixed, _gamma, _max, _min, _mode, _nacol, _out, _padding, _pos, _spread, _useCache, classifyValue, f, getClass, getColor, resetCache, setColors, tmap;\n _mode = 'rgb';\n _nacol = chroma('#ccc');\n _spread = 0;\n _fixed = false;\n _domain = [0, 1];\n _pos = [];\n _padding = [0, 0];\n _classes = false;\n _colors = [];\n _out = false;\n _min = 0;\n _max = 1;\n _correctLightness = false;\n _colorCache = {};\n _useCache = true;\n _gamma = 1;\n setColors = function(colors) {\n var c, col, o, ref, ref1, w;\n if (colors == null) {\n colors = ['#fff', '#000'];\n }\n if ((colors != null) && type(colors) === 'string' && (chroma.brewer != null)) {\n colors = chroma.brewer[colors] || chroma.brewer[colors.toLowerCase()] || colors;\n }\n if (type(colors) === 'array') {\n if (colors.length === 1) {\n colors = [colors[0], colors[0]];\n }\n colors = colors.slice(0);\n for (c = o = 0, ref = colors.length - 1; 0 <= ref ? o <= ref : o >= ref; c = 0 <= ref ? ++o : --o) {\n col = colors[c];\n if (type(col) === \"string\") {\n colors[c] = chroma(col);\n }\n }\n _pos.length = 0;\n for (c = w = 0, ref1 = colors.length - 1; 0 <= ref1 ? w <= ref1 : w >= ref1; c = 0 <= ref1 ? ++w : --w) {\n _pos.push(c / (colors.length - 1));\n }\n }\n resetCache();\n return _colors = colors;\n };\n getClass = function(value) {\n var i, n;\n if (_classes != null) {\n n = _classes.length - 1;\n i = 0;\n while (i < n && value >= _classes[i]) {\n i++;\n }\n return i - 1;\n }\n return 0;\n };\n tmap = function(t) {\n return t;\n };\n classifyValue = function(value) {\n var i, maxc, minc, n, val;\n val = value;\n if (_classes.length > 2) {\n n = _classes.length - 1;\n i = getClass(value);\n minc = _classes[0] + (_classes[1] - _classes[0]) * (0 + _spread * 0.5);\n maxc = _classes[n - 1] + (_classes[n] - _classes[n - 1]) * (1 - _spread * 0.5);\n val = _min + ((_classes[i] + (_classes[i + 1] - _classes[i]) * 0.5 - minc) / (maxc - minc)) * (_max - _min);\n }\n return val;\n };\n getColor = function(val, bypassMap) {\n var c, col, i, k, o, p, ref, t;\n if (bypassMap == null) {\n bypassMap = false;\n }\n if (isNaN(val) || val === null) {\n return _nacol;\n }\n if (!bypassMap) {\n if (_classes && _classes.length > 2) {\n c = getClass(val);\n t = c / (_classes.length - 2);\n } else if (_max !== _min) {\n t = (val - _min) / (_max - _min);\n } else {\n t = 1;\n }\n } else {\n t = val;\n }\n if (!bypassMap) {\n t = tmap(t);\n }\n if (_gamma !== 1) {\n t = pow(t, _gamma);\n }\n t = _padding[0] + (t * (1 - _padding[0] - _padding[1]));\n t = Math.min(1, Math.max(0, t));\n k = Math.floor(t * 10000);\n if (_useCache && _colorCache[k]) {\n col = _colorCache[k];\n } else {\n if (type(_colors) === 'array') {\n for (i = o = 0, ref = _pos.length - 1; 0 <= ref ? o <= ref : o >= ref; i = 0 <= ref ? ++o : --o) {\n p = _pos[i];\n if (t <= p) {\n col = _colors[i];\n break;\n }\n if (t >= p && i === _pos.length - 1) {\n col = _colors[i];\n break;\n }\n if (t > p && t < _pos[i + 1]) {\n t = (t - p) / (_pos[i + 1] - p);\n col = chroma.interpolate(_colors[i], _colors[i + 1], t, _mode);\n break;\n }\n }\n } else if (type(_colors) === 'function') {\n col = _colors(t);\n }\n if (_useCache) {\n _colorCache[k] = col;\n }\n }\n return col;\n };\n resetCache = function() {\n return _colorCache = {};\n };\n setColors(colors);\n f = function(v) {\n var c;\n c = chroma(getColor(v));\n if (_out && c[_out]) {\n return c[_out]();\n } else {\n return c;\n }\n };\n f.classes = function(classes) {\n var d;\n if (classes != null) {\n if (type(classes) === 'array') {\n _classes = classes;\n _domain = [classes[0], classes[classes.length - 1]];\n } else {\n d = chroma.analyze(_domain);\n if (classes === 0) {\n _classes = [d.min, d.max];\n } else {\n _classes = chroma.limits(d, 'e', classes);\n }\n }\n return f;\n }\n return _classes;\n };\n f.domain = function(domain) {\n var c, d, k, len, o, ref, w;\n if (!arguments.length) {\n return _domain;\n }\n _min = domain[0];\n _max = domain[domain.length - 1];\n _pos = [];\n k = _colors.length;\n if (domain.length === k && _min !== _max) {\n for (o = 0, len = domain.length; o < len; o++) {\n d = domain[o];\n _pos.push((d - _min) / (_max - _min));\n }\n } else {\n for (c = w = 0, ref = k - 1; 0 <= ref ? w <= ref : w >= ref; c = 0 <= ref ? ++w : --w) {\n _pos.push(c / (k - 1));\n }\n }\n _domain = [_min, _max];\n return f;\n };\n f.mode = function(_m) {\n if (!arguments.length) {\n return _mode;\n }\n _mode = _m;\n resetCache();\n return f;\n };\n f.range = function(colors, _pos) {\n setColors(colors, _pos);\n return f;\n };\n f.out = function(_o) {\n _out = _o;\n return f;\n };\n f.spread = function(val) {\n if (!arguments.length) {\n return _spread;\n }\n _spread = val;\n return f;\n };\n f.correctLightness = function(v) {\n if (v == null) {\n v = true;\n }\n _correctLightness = v;\n resetCache();\n if (_correctLightness) {\n tmap = function(t) {\n var L0, L1, L_actual, L_diff, L_ideal, max_iter, pol, t0, t1;\n L0 = getColor(0, true).lab()[0];\n L1 = getColor(1, true).lab()[0];\n pol = L0 > L1;\n L_actual = getColor(t, true).lab()[0];\n L_ideal = L0 + (L1 - L0) * t;\n L_diff = L_actual - L_ideal;\n t0 = 0;\n t1 = 1;\n max_iter = 20;\n while (Math.abs(L_diff) > 1e-2 && max_iter-- > 0) {\n (function() {\n if (pol) {\n L_diff *= -1;\n }\n if (L_diff < 0) {\n t0 = t;\n t += (t1 - t) * 0.5;\n } else {\n t1 = t;\n t += (t0 - t) * 0.5;\n }\n L_actual = getColor(t, true).lab()[0];\n return L_diff = L_actual - L_ideal;\n })();\n }\n return t;\n };\n } else {\n tmap = function(t) {\n return t;\n };\n }\n return f;\n };\n f.padding = function(p) {\n if (p != null) {\n if (type(p) === 'number') {\n p = [p, p];\n }\n _padding = p;\n return f;\n } else {\n return _padding;\n }\n };\n f.colors = function(numColors, out) {\n var dd, dm, i, o, ref, result, results, samples, w;\n if (arguments.length < 2) {\n out = 'hex';\n }\n result = [];\n if (arguments.length === 0) {\n result = _colors.slice(0);\n } else if (numColors === 1) {\n result = [f(0.5)];\n } else if (numColors > 1) {\n dm = _domain[0];\n dd = _domain[1] - dm;\n result = (function() {\n results = [];\n for (var o = 0; 0 <= numColors ? o < numColors : o > numColors; 0 <= numColors ? o++ : o--){ results.push(o); }\n return results;\n }).apply(this).map(function(i) {\n return f(dm + i / (numColors - 1) * dd);\n });\n } else {\n colors = [];\n samples = [];\n if (_classes && _classes.length > 2) {\n for (i = w = 1, ref = _classes.length; 1 <= ref ? w < ref : w > ref; i = 1 <= ref ? ++w : --w) {\n samples.push((_classes[i - 1] + _classes[i]) * 0.5);\n }\n } else {\n samples = _domain;\n }\n result = samples.map(function(v) {\n return f(v);\n });\n }\n if (chroma[out]) {\n result = result.map(function(c) {\n return c[out]();\n });\n }\n return result;\n };\n f.cache = function(c) {\n if (c != null) {\n _useCache = c;\n return f;\n } else {\n return _useCache;\n }\n };\n f.gamma = function(g) {\n if (g != null) {\n _gamma = g;\n return f;\n } else {\n return _gamma;\n }\n };\n f.nodata = function(d) {\n if (d != null) {\n _nacol = chroma(d);\n return f;\n } else {\n return _nacol;\n }\n };\n return f;\n };\n\n if (chroma.scales == null) {\n chroma.scales = {};\n }\n\n chroma.scales.cool = function() {\n return chroma.scale([chroma.hsl(180, 1, .9), chroma.hsl(250, .7, .4)]);\n };\n\n chroma.scales.hot = function() {\n return chroma.scale(['#000', '#f00', '#ff0', '#fff'], [0, .25, .75, 1]).mode('rgb');\n };\n\n chroma.analyze = function(data, key, filter) {\n var add, k, len, o, r, val, visit;\n r = {\n min: Number.MAX_VALUE,\n max: Number.MAX_VALUE * -1,\n sum: 0,\n values: [],\n count: 0\n };\n if (filter == null) {\n filter = function() {\n return true;\n };\n }\n add = function(val) {\n if ((val != null) && !isNaN(val)) {\n r.values.push(val);\n r.sum += val;\n if (val < r.min) {\n r.min = val;\n }\n if (val > r.max) {\n r.max = val;\n }\n r.count += 1;\n }\n };\n visit = function(val, k) {\n if (filter(val, k)) {\n if ((key != null) && type(key) === 'function') {\n return add(key(val));\n } else if ((key != null) && type(key) === 'string' || type(key) === 'number') {\n return add(val[key]);\n } else {\n return add(val);\n }\n }\n };\n if (type(data) === 'array') {\n for (o = 0, len = data.length; o < len; o++) {\n val = data[o];\n visit(val);\n }\n } else {\n for (k in data) {\n val = data[k];\n visit(val, k);\n }\n }\n r.domain = [r.min, r.max];\n r.limits = function(mode, num) {\n return chroma.limits(r, mode, num);\n };\n return r;\n };\n\n chroma.limits = function(data, mode, num) {\n var aa, ab, ac, ad, ae, af, ag, ah, ai, aj, ak, al, am, assignments, best, centroids, cluster, clusterSizes, dist, i, j, kClusters, limits, max_log, min, min_log, mindist, n, nb_iters, newCentroids, o, p, pb, pr, ref, ref1, ref10, ref11, ref12, ref13, ref14, ref2, ref3, ref4, ref5, ref6, ref7, ref8, ref9, repeat, sum, tmpKMeansBreaks, v, value, values, w;\n if (mode == null) {\n mode = 'equal';\n }\n if (num == null) {\n num = 7;\n }\n if (type(data) === 'array') {\n data = chroma.analyze(data);\n }\n min = data.min;\n max = data.max;\n sum = data.sum;\n values = data.values.sort(function(a, b) {\n return a - b;\n });\n if (num === 1) {\n return [min, max];\n }\n limits = [];\n if (mode.substr(0, 1) === 'c') {\n limits.push(min);\n limits.push(max);\n }\n if (mode.substr(0, 1) === 'e') {\n limits.push(min);\n for (i = o = 1, ref = num - 1; 1 <= ref ? o <= ref : o >= ref; i = 1 <= ref ? ++o : --o) {\n limits.push(min + (i / num) * (max - min));\n }\n limits.push(max);\n } else if (mode.substr(0, 1) === 'l') {\n if (min <= 0) {\n throw 'Logarithmic scales are only possible for values > 0';\n }\n min_log = Math.LOG10E * log(min);\n max_log = Math.LOG10E * log(max);\n limits.push(min);\n for (i = w = 1, ref1 = num - 1; 1 <= ref1 ? w <= ref1 : w >= ref1; i = 1 <= ref1 ? ++w : --w) {\n limits.push(pow(10, min_log + (i / num) * (max_log - min_log)));\n }\n limits.push(max);\n } else if (mode.substr(0, 1) === 'q') {\n limits.push(min);\n for (i = aa = 1, ref2 = num - 1; 1 <= ref2 ? aa <= ref2 : aa >= ref2; i = 1 <= ref2 ? ++aa : --aa) {\n p = (values.length - 1) * i / num;\n pb = floor(p);\n if (pb === p) {\n limits.push(values[pb]);\n } else {\n pr = p - pb;\n limits.push(values[pb] * (1 - pr) + values[pb + 1] * pr);\n }\n }\n limits.push(max);\n } else if (mode.substr(0, 1) === 'k') {\n\n /*\n implementation based on\n http://code.google.com/p/figue/source/browse/trunk/figue.js#336\n simplified for 1-d input values\n */\n n = values.length;\n assignments = new Array(n);\n clusterSizes = new Array(num);\n repeat = true;\n nb_iters = 0;\n centroids = null;\n centroids = [];\n centroids.push(min);\n for (i = ab = 1, ref3 = num - 1; 1 <= ref3 ? ab <= ref3 : ab >= ref3; i = 1 <= ref3 ? ++ab : --ab) {\n centroids.push(min + (i / num) * (max - min));\n }\n centroids.push(max);\n while (repeat) {\n for (j = ac = 0, ref4 = num - 1; 0 <= ref4 ? ac <= ref4 : ac >= ref4; j = 0 <= ref4 ? ++ac : --ac) {\n clusterSizes[j] = 0;\n }\n for (i = ad = 0, ref5 = n - 1; 0 <= ref5 ? ad <= ref5 : ad >= ref5; i = 0 <= ref5 ? ++ad : --ad) {\n value = values[i];\n mindist = Number.MAX_VALUE;\n for (j = ae = 0, ref6 = num - 1; 0 <= ref6 ? ae <= ref6 : ae >= ref6; j = 0 <= ref6 ? ++ae : --ae) {\n dist = abs(centroids[j] - value);\n if (dist < mindist) {\n mindist = dist;\n best = j;\n }\n }\n clusterSizes[best]++;\n assignments[i] = best;\n }\n newCentroids = new Array(num);\n for (j = af = 0, ref7 = num - 1; 0 <= ref7 ? af <= ref7 : af >= ref7; j = 0 <= ref7 ? ++af : --af) {\n newCentroids[j] = null;\n }\n for (i = ag = 0, ref8 = n - 1; 0 <= ref8 ? ag <= ref8 : ag >= ref8; i = 0 <= ref8 ? ++ag : --ag) {\n cluster = assignments[i];\n if (newCentroids[cluster] === null) {\n newCentroids[cluster] = values[i];\n } else {\n newCentroids[cluster] += values[i];\n }\n }\n for (j = ah = 0, ref9 = num - 1; 0 <= ref9 ? ah <= ref9 : ah >= ref9; j = 0 <= ref9 ? ++ah : --ah) {\n newCentroids[j] *= 1 / clusterSizes[j];\n }\n repeat = false;\n for (j = ai = 0, ref10 = num - 1; 0 <= ref10 ? ai <= ref10 : ai >= ref10; j = 0 <= ref10 ? ++ai : --ai) {\n if (newCentroids[j] !== centroids[i]) {\n repeat = true;\n break;\n }\n }\n centroids = newCentroids;\n nb_iters++;\n if (nb_iters > 200) {\n repeat = false;\n }\n }\n kClusters = {};\n for (j = aj = 0, ref11 = num - 1; 0 <= ref11 ? aj <= ref11 : aj >= ref11; j = 0 <= ref11 ? ++aj : --aj) {\n kClusters[j] = [];\n }\n for (i = ak = 0, ref12 = n - 1; 0 <= ref12 ? ak <= ref12 : ak >= ref12; i = 0 <= ref12 ? ++ak : --ak) {\n cluster = assignments[i];\n kClusters[cluster].push(values[i]);\n }\n tmpKMeansBreaks = [];\n for (j = al = 0, ref13 = num - 1; 0 <= ref13 ? al <= ref13 : al >= ref13; j = 0 <= ref13 ? ++al : --al) {\n tmpKMeansBreaks.push(kClusters[j][0]);\n tmpKMeansBreaks.push(kClusters[j][kClusters[j].length - 1]);\n }\n tmpKMeansBreaks = tmpKMeansBreaks.sort(function(a, b) {\n return a - b;\n });\n limits.push(tmpKMeansBreaks[0]);\n for (i = am = 1, ref14 = tmpKMeansBreaks.length - 1; am <= ref14; i = am += 2) {\n v = tmpKMeansBreaks[i];\n if (!isNaN(v) && limits.indexOf(v) === -1) {\n limits.push(v);\n }\n }\n }\n return limits;\n };\n\n hsi2rgb = function(h, s, i) {\n\n /*\n borrowed from here:\n http://hummer.stanford.edu/museinfo/doc/examples/humdrum/keyscape2/hsi2rgb.cpp\n */\n var args, b, g, r;\n args = unpack(arguments);\n h = args[0], s = args[1], i = args[2];\n if (isNaN(h)) {\n h = 0;\n }\n h /= 360;\n if (h < 1 / 3) {\n b = (1 - s) / 3;\n r = (1 + s * cos(TWOPI * h) / cos(PITHIRD - TWOPI * h)) / 3;\n g = 1 - (b + r);\n } else if (h < 2 / 3) {\n h -= 1 / 3;\n r = (1 - s) / 3;\n g = (1 + s * cos(TWOPI * h) / cos(PITHIRD - TWOPI * h)) / 3;\n b = 1 - (r + g);\n } else {\n h -= 2 / 3;\n g = (1 - s) / 3;\n b = (1 + s * cos(TWOPI * h) / cos(PITHIRD - TWOPI * h)) / 3;\n r = 1 - (g + b);\n }\n r = limit(i * r * 3);\n g = limit(i * g * 3);\n b = limit(i * b * 3);\n return [r * 255, g * 255, b * 255, args.length > 3 ? args[3] : 1];\n };\n\n rgb2hsi = function() {\n\n /*\n borrowed from here:\n http://hummer.stanford.edu/museinfo/doc/examples/humdrum/keyscape2/rgb2hsi.cpp\n */\n var b, g, h, i, min, r, ref, s;\n ref = unpack(arguments), r = ref[0], g = ref[1], b = ref[2];\n TWOPI = Math.PI * 2;\n r /= 255;\n g /= 255;\n b /= 255;\n min = Math.min(r, g, b);\n i = (r + g + b) / 3;\n s = 1 - min / i;\n if (s === 0) {\n h = 0;\n } else {\n h = ((r - g) + (r - b)) / 2;\n h /= Math.sqrt((r - g) * (r - g) + (r - b) * (g - b));\n h = Math.acos(h);\n if (b > g) {\n h = TWOPI - h;\n }\n h /= TWOPI;\n }\n return [h * 360, s, i];\n };\n\n chroma.hsi = function() {\n return (function(func, args, ctor) {\n ctor.prototype = func.prototype;\n var child = new ctor, result = func.apply(child, args);\n return Object(result) === result ? result : child;\n })(Color, slice.call(arguments).concat(['hsi']), function(){});\n };\n\n _input.hsi = hsi2rgb;\n\n Color.prototype.hsi = function() {\n return rgb2hsi(this._rgb);\n };\n\n interpolate_hsx = function(col1, col2, f, m) {\n var dh, hue, hue0, hue1, lbv, lbv0, lbv1, res, sat, sat0, sat1, xyz0, xyz1;\n if (m === 'hsl') {\n xyz0 = col1.hsl();\n xyz1 = col2.hsl();\n } else if (m === 'hsv') {\n xyz0 = col1.hsv();\n xyz1 = col2.hsv();\n } else if (m === 'hcg') {\n xyz0 = col1.hcg();\n xyz1 = col2.hcg();\n } else if (m === 'hsi') {\n xyz0 = col1.hsi();\n xyz1 = col2.hsi();\n } else if (m === 'lch' || m === 'hcl') {\n m = 'hcl';\n xyz0 = col1.hcl();\n xyz1 = col2.hcl();\n }\n if (m.substr(0, 1) === 'h') {\n hue0 = xyz0[0], sat0 = xyz0[1], lbv0 = xyz0[2];\n hue1 = xyz1[0], sat1 = xyz1[1], lbv1 = xyz1[2];\n }\n if (!isNaN(hue0) && !isNaN(hue1)) {\n if (hue1 > hue0 && hue1 - hue0 > 180) {\n dh = hue1 - (hue0 + 360);\n } else if (hue1 < hue0 && hue0 - hue1 > 180) {\n dh = hue1 + 360 - hue0;\n } else {\n dh = hue1 - hue0;\n }\n hue = hue0 + f * dh;\n } else if (!isNaN(hue0)) {\n hue = hue0;\n if ((lbv1 === 1 || lbv1 === 0) && m !== 'hsv') {\n sat = sat0;\n }\n } else if (!isNaN(hue1)) {\n hue = hue1;\n if ((lbv0 === 1 || lbv0 === 0) && m !== 'hsv') {\n sat = sat1;\n }\n } else {\n hue = Number.NaN;\n }\n if (sat == null) {\n sat = sat0 + f * (sat1 - sat0);\n }\n lbv = lbv0 + f * (lbv1 - lbv0);\n return res = chroma[m](hue, sat, lbv);\n };\n\n _interpolators = _interpolators.concat((function() {\n var len, o, ref, results;\n ref = ['hsv', 'hsl', 'hsi', 'hcl', 'lch', 'hcg'];\n results = [];\n for (o = 0, len = ref.length; o < len; o++) {\n m = ref[o];\n results.push([m, interpolate_hsx]);\n }\n return results;\n })());\n\n interpolate_num = function(col1, col2, f, m) {\n var n1, n2;\n n1 = col1.num();\n n2 = col2.num();\n return chroma.num(n1 + (n2 - n1) * f, 'num');\n };\n\n _interpolators.push(['num', interpolate_num]);\n\n interpolate_lab = function(col1, col2, f, m) {\n var res, xyz0, xyz1;\n xyz0 = col1.lab();\n xyz1 = col2.lab();\n return res = new Color(xyz0[0] + f * (xyz1[0] - xyz0[0]), xyz0[1] + f * (xyz1[1] - xyz0[1]), xyz0[2] + f * (xyz1[2] - xyz0[2]), m);\n };\n\n _interpolators.push(['lab', interpolate_lab]);\n\n}).call(this);\n","/**\n * @file Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Color } from 'three'\nimport * as chroma from 'chroma-js'\n\nimport { createParams } from '../utils'\nimport { NumberArray } from '../types'\nimport Structure from '../structure/structure'\nimport Surface from '../surface/surface'\nimport Volume from '../surface/volume'\nimport AtomProxy from '../proxy/atom-proxy'\nimport BondProxy from '../proxy/bond-proxy'\n\nexport type ColorMode = 'rgb'|'hsv'|'hsl'|'hsi'|'lab'|'hcl'\nexport type ColorSpace = 'sRGB' | 'linear'\n\n/**\n * Internal color space for all colors (global).\n * Colors are always specified as sRGB; if this is set to\n * 'linear' then colors get linearized when used internally\n * as vertex or texture colors.\n * @see setColorSpace/getColorSpace.\n */\nvar colorSpace: ColorSpace = 'sRGB' // default: don't linearize\n\n/** Set the global internal color space for colormakers */\nexport function setColorSpace(space: ColorSpace) {\n colorSpace = space\n}\n\n/** Get the global internal color space for colormakers */\nexport function getColorSpace() {\n return colorSpace\n}\n\nexport const ScaleDefaultParameters = {\n scale: 'uniform' as string|string[],\n mode: 'hcl' as ColorMode,\n domain: [ 0, 1 ] as number[],\n value: 0xFFFFFF,\n reverse: false,\n}\nexport type ScaleParameters = typeof ScaleDefaultParameters\n\nexport interface ColorData {\n atomData?: number[],\n bondData?: number[]\n}\n\nexport interface ColormakerParameters extends ScaleParameters {\n structure?: Structure\n volume?: Volume\n surface?: Surface\n data?: ColorData\n}\n\nexport type StuctureColormakerParams = { structure: Structure } & Partial\nexport type VolumeColormakerParams = { volume: Volume } & Partial\nexport type ColormakerScale = (v: number) => number\n\nconst tmpColor = new Color()\n\n/** Decorator for optionally linearizing a numeric color */\ntype colorFuncType = (value: any, fromTo?: boolean) => number // decorator applies to functions with this shape\nexport function manageColor\n (_target: Object,\n _name: string | symbol,\n descriptor: TypedPropertyDescriptor): PropertyDescriptor {\n const originalMethod = descriptor.value\n const linearize: colorFuncType = function (this: T, value: any, fromTo?: boolean) {\n let result = originalMethod!.bind(this, value, fromTo)()\n if (colorSpace == 'linear') {\n tmpColor.set(result)\n tmpColor.convertSRGBToLinear()\n return tmpColor.getHex()\n } else {\n return result\n }\n }\n descriptor.value = linearize\n return descriptor\n }\n\n/**\n * Class for making colors.\n * @interface\n */\nabstract class Colormaker {\n parameters: ColormakerParameters\n atomProxy?: AtomProxy\n\n /**\n * Create a colormaker instance\n * @param {ColormakerParameters} params - colormaker parameter\n */\n constructor (params: Partial = {}) {\n this.parameters = createParams(params, ScaleDefaultParameters)\n\n if (typeof this.parameters.value === 'string') {\n this.parameters.value = tmpColor.set(this.parameters.value).getHex()\n }\n\n if (this.parameters.structure) {\n this.atomProxy = this.parameters.structure.getAtomProxy()\n }\n }\n\n getScale (params: Partial = {}) {\n const p = createParams(params, this.parameters)\n\n if (p.scale === 'rainbow') {\n p.scale = [ 'red', 'orange', 'yellow', 'green', 'blue' ]\n } else if (p.scale === 'rwb') {\n p.scale = [ 'red', 'white', 'blue' ]\n }\n\n if (p.reverse) {\n p.domain = p.domain.slice().reverse()\n }\n return chroma\n .scale(p.scale as any) // TODO\n .mode(p.mode)\n .domain(p.domain)\n .out('num' as any) // returns RGB color as numeric (not string \"#ffffff\")\n }\n\n /**\n * save a color to an array\n * @param {Integer} color - hex color value\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n colorToArray (color: number, array: NumberArray = [], offset = 0) {\n array[ offset ] = (color >> 16 & 255) / 255\n array[ offset + 1 ] = (color >> 8 & 255) / 255\n array[ offset + 2 ] = (color & 255) / 255\n\n return array\n }\n\n atomColor? (atom: AtomProxy): number\n\n /**\n * save an atom color to an array\n * @param {AtomProxy} atom - atom to get color for\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n atomColorToArray (atom: AtomProxy, array: NumberArray, offset: number) {\n return this.colorToArray(\n this.atomColor ? this.atomColor(atom) : 0x000000, array, offset\n )\n }\n\n /**\n * return the color for an bond\n * @param {BondProxy} bond - bond to get color for\n * @param {Boolean} fromTo - whether to use the first or second atom of the bond\n * @return {Integer} hex bond color\n */\n bondColor (bond: BondProxy, fromTo: boolean) {\n if (this.atomProxy && this.atomColor) {\n this.atomProxy.index = fromTo ? bond.atomIndex1 : bond.atomIndex2\n return this.atomColor(this.atomProxy)\n } else {\n return 0x000000\n }\n }\n\n /**\n * safe a bond color to an array\n * @param {BondProxy} bond - bond to get color for\n * @param {Boolean} fromTo - whether to use the first or second atom of the bond\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n bondColorToArray (bond: BondProxy, fromTo: boolean, array: NumberArray, offset: number) {\n return this.colorToArray(\n this.bondColor(bond, fromTo), array, offset\n )\n }\n\n volumeColor? (index: number): number\n\n /**\n * safe a volume cell color to an array\n * @param {Integer} index - volume cell index\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n volumeColorToArray (index: number, array: NumberArray, offset: number) {\n return this.colorToArray(\n this.volumeColor ? this.volumeColor(index) : 0x000000, array, offset\n )\n }\n\n positionColor? (position: Vector3): number\n\n /**\n * safe a color for coordinates in space to an array\n * @param {Vector3} coords - xyz coordinates\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n positionColorToArray (coords: Vector3, array: NumberArray, offset: number) {\n return this.colorToArray(\n this.positionColor ? this.positionColor(coords) : 0x000000, array, offset\n )\n }\n}\n\nexport default Colormaker\n","/**\n * @file Selection Constants\n * @author Alexander Rose \n * @private\n */\n\nexport enum kwd {\n PROTEIN = 1,\n NUCLEIC = 2,\n RNA = 3,\n DNA = 4,\n POLYMER = 5,\n WATER = 6,\n HELIX = 7,\n SHEET = 8,\n TURN = 9,\n BACKBONE = 10,\n SIDECHAIN = 11,\n ALL = 12,\n HETERO = 13,\n ION = 14,\n SACCHARIDE = 15,\n SUGAR = 15,\n BONDED = 16,\n RING = 17,\n AROMATICRING = 18,\n METAL = 19,\n POLARH = 20,\n NONE = 21\n}\n\nexport const SelectAllKeyword = [ '*', '', 'ALL' ]\nexport const SelectNoneKeyword = [ 'NONE' ]\n\nexport const AtomOnlyKeywords = [\n kwd.BACKBONE, kwd.SIDECHAIN, kwd.BONDED, kwd.RING, kwd.AROMATICRING, kwd.METAL, kwd.POLARH\n]\n\nexport const ChainKeywords = [\n kwd.POLYMER, kwd.WATER\n]\n\nexport const SmallResname = [ 'ALA', 'GLY', 'SER' ]\nexport const NucleophilicResname = [ 'CYS', 'SER', 'THR' ]\nexport const HydrophobicResname = [ 'ALA', 'ILE', 'LEU', 'MET', 'PHE', 'PRO', 'TRP', 'VAL' ]\nexport const AromaticResname = [ 'PHE', 'TRP', 'TYR', 'HIS' ]\nexport const AmideResname = [ 'ASN', 'GLN' ]\nexport const AcidicResname = [ 'ASP', 'GLU' ]\nexport const BasicResname = [ 'ARG', 'HIS', 'LYS' ]\nexport const ChargedResname = [ 'ARG', 'ASP', 'GLU', 'HIS', 'LYS' ]\nexport const PolarResname = [ 'ASN', 'ARG', 'ASP', 'CYS', 'GLY', 'GLN', 'GLU', 'HIS', 'LYS', 'SER', 'THR', 'TYR' ]\nexport const NonpolarResname = [ 'ALA', 'ILE', 'LEU', 'MET', 'PHE', 'PRO', 'TRP', 'VAL' ]\nexport const CyclicResname = [ 'HIS', 'PHE', 'PRO', 'TRP', 'TYR' ]\nexport const AliphaticResname = [ 'ALA', 'GLY', 'ILE', 'LEU', 'VAL' ]\n","/*jslint onevar:true, undef:true, newcap:true, regexp:true, bitwise:true, maxerr:50, indent:4, white:false, nomen:false, plusplus:false */\n/*global define:false, require:false, exports:false, module:false, signals:false */\n\n/** @license\n * JS Signals \n * Released under the MIT license\n * Author: Miller Medeiros\n * Version: 1.0.0 - Build: 268 (2012/11/29 05:48 PM)\n */\n\n(function(global){\n\n // SignalBinding -------------------------------------------------\n //================================================================\n\n /**\n * Object that represents a binding between a Signal and a listener function.\n *
- This is an internal constructor and shouldn't be called by regular users.\n *
- inspired by Joa Ebert AS3 SignalBinding and Robert Penner's Slot classes.\n * @author Miller Medeiros\n * @constructor\n * @internal\n * @name SignalBinding\n * @param {Signal} signal Reference to Signal object that listener is currently bound to.\n * @param {Function} listener Handler function bound to the signal.\n * @param {boolean} isOnce If binding should be executed just once.\n * @param {Object} [listenerContext] Context on which listener will be executed (object that should represent the `this` variable inside listener function).\n * @param {Number} [priority] The priority level of the event listener. (default = 0).\n */\n function SignalBinding(signal, listener, isOnce, listenerContext, priority) {\n\n /**\n * Handler function bound to the signal.\n * @type Function\n * @private\n */\n this._listener = listener;\n\n /**\n * If binding should be executed just once.\n * @type boolean\n * @private\n */\n this._isOnce = isOnce;\n\n /**\n * Context on which listener will be executed (object that should represent the `this` variable inside listener function).\n * @memberOf SignalBinding.prototype\n * @name context\n * @type Object|undefined|null\n */\n this.context = listenerContext;\n\n /**\n * Reference to Signal object that listener is currently bound to.\n * @type Signal\n * @private\n */\n this._signal = signal;\n\n /**\n * Listener priority\n * @type Number\n * @private\n */\n this._priority = priority || 0;\n }\n\n SignalBinding.prototype = {\n\n /**\n * If binding is active and should be executed.\n * @type boolean\n */\n active : true,\n\n /**\n * Default parameters passed to listener during `Signal.dispatch` and `SignalBinding.execute`. (curried parameters)\n * @type Array|null\n */\n params : null,\n\n /**\n * Call listener passing arbitrary parameters.\n *

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

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

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

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

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

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

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

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

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

Find out how to get it here.

'\n\n/**\n * List of file extensions to be recognized as scripts\n */\nexport const ScriptExtensions = [ 'ngl', 'js' ]\n\nexport const WorkerRegistry = new _WorkerRegistry()\nexport const ColormakerRegistry = new _ColormakerRegistry()\nexport const DatasourceRegistry = new Registry('datasource')\nexport const RepresentationRegistry = new Registry('representatation')\nexport const ParserRegistry = new _ParserRegistry()\nexport const ShaderRegistry = new Registry('shader')\nexport const DecompressorRegistry = new Registry('decompressor')\nexport const ComponentRegistry = new Registry('component')\nexport const BufferRegistry = new Registry('buffer')\nexport const PickerRegistry = new Registry('picker')\n\nexport let ListingDatasource: any\nexport function setListingDatasource (value: any) {\n ListingDatasource = value\n}\n\nexport let TrajectoryDatasource: any // TODO should accept mdsrvDatasource\nexport function setTrajectoryDatasource (value: any) {\n TrajectoryDatasource = value\n}\n","/**\n * @file Worker Registry\n * @author Alexander Rose \n * @private\n */\n\nimport { makeWorkerBlob } from './worker-utils'\n\nclass WorkerRegistry {\n activeWorkerCount = 0\n\n private _funcDict: { [k: string]: Function } = {}\n private _depsDict: { [k: string]: Function[] } = {}\n private _blobDict: { [k: string]: Blob } = {}\n\n add (name: string, func: Function, deps: Function[]) {\n this._funcDict[ name ] = func\n this._depsDict[ name ] = deps\n }\n\n get (name: string) {\n if (!this._blobDict[ name ]) {\n this._blobDict[ name ] = makeWorkerBlob(\n this._funcDict[ name ], this._depsDict[ name ]\n )\n }\n return this._blobDict[ name ]\n }\n}\n\nexport default WorkerRegistry\n","/**\n * @file Parser Registry\n * @author Alexander Rose \n * @private\n */\n\nimport Registry from '../utils/registry'\n\nclass ParserRegistry extends Registry {\n constructor () {\n super('parser')\n }\n\n __hasObjName (key: string, objName: string) {\n const parser = this.get(key)\n return parser && parser.prototype.__objName === objName\n }\n\n isTrajectory (key: string) {\n return this.__hasObjName(key, 'frames')\n }\n\n isStructure (key: string) {\n return this.__hasObjName(key, 'structure')\n }\n\n isVolume (key: string) {\n return this.__hasObjName(key, 'volume')\n }\n\n isSurface (key: string) {\n return this.__hasObjName(key, 'surface')\n }\n\n isBinary (key: string) {\n const parser = this.get(key)\n return parser && parser.prototype.isBinary\n }\n\n isXml (key: string) {\n const parser = this.get(key)\n return parser && parser.prototype.isXml\n }\n\n isJson (key: string) {\n const parser = this.get(key)\n return parser && parser.prototype.isJson\n }\n\n getTrajectoryExtensions () {\n return this.names.filter(name => this.isTrajectory(name))\n }\n\n getStructureExtensions () {\n return this.names.filter(name => this.isStructure(name))\n }\n\n getVolumeExtensions () {\n return this.names.filter(name => this.isVolume(name))\n }\n\n getSurfaceExtensions () {\n return this.names.filter(name => this.isSurface(name))\n }\n}\n\nexport default ParserRegistry\n","/**\n * @file Streamer\n * @author Alexander Rose \n * @private\n */\n\nimport { DecompressorRegistry } from '../globals'\nimport { uint8ToString, defaults } from '../utils'\n\nexport interface StreamerParams {\n compressed?: string|false\n binary?: boolean\n json?: boolean\n xml?: boolean\n}\n\nabstract class Streamer {\n src: any\n data: any\n\n compressed: string|false\n binary: boolean\n json: boolean\n xml: boolean\n\n chunkSize = 1024 * 1024 * 10\n newline = '\\n'\n\n protected __pointer = 0\n protected __partialLine = ''\n\n constructor (src: any, params: StreamerParams = {}) {\n this.compressed = defaults(params.compressed, false)\n this.binary = defaults(params.binary, false)\n this.json = defaults(params.json, false)\n this.xml = defaults(params.xml, false)\n\n this.src = src\n }\n\n isBinary () {\n return this.binary || this.compressed\n }\n\n read () {\n return this._read().then(data => {\n const decompressFn = this.compressed ? DecompressorRegistry.get(this.compressed) : undefined\n\n if (this.compressed && decompressFn) {\n this.data = decompressFn(data)\n } else {\n if ((this.binary || this.compressed) && data instanceof ArrayBuffer) {\n data = new Uint8Array(data)\n }\n this.data = data\n }\n\n return this.data\n })\n }\n\n protected abstract _read (): Promise\n\n protected _chunk (start: number, end: number) {\n end = Math.min(this.data.length, end)\n\n if (start === 0 && this.data.length === end) {\n return this.data\n } else {\n if (this.isBinary()) {\n return this.data.subarray(start, end)\n } else {\n return this.data.substring(start, end)\n }\n }\n }\n\n chunk (start: number) {\n const end = start + this.chunkSize\n\n return this._chunk(start, end)\n }\n\n peekLines (m: number) {\n const data = this.data\n const n = data.length\n\n // FIXME does not work for multi-char newline\n const newline = this.isBinary() ? this.newline.charCodeAt(0) : this.newline\n\n let i\n let count = 0\n for (i = 0; i < n; ++i) {\n if (data[ i ] === newline) ++count\n if (count === m) break\n }\n\n const chunk = this._chunk(0, i + 1)\n const d = this.chunkToLines(chunk, '', i > n)\n\n return d.lines\n }\n\n chunkCount () {\n return Math.floor(this.data.length / this.chunkSize) + 1\n }\n\n asText () {\n return this.isBinary() ? uint8ToString(this.data) : this.data\n }\n\n chunkToLines (chunk: string|Uint8Array, partialLine: string, isLast: boolean) {\n const newline = this.newline\n\n if (!this.isBinary() && chunk.length === this.data.length) {\n return {\n lines: (chunk as string).split(newline),\n partialLine: ''\n }\n }\n\n let lines: string[] = []\n const str = this.isBinary() ? uint8ToString(chunk as Uint8Array) : chunk\n const idx = str.lastIndexOf(newline)\n\n if (idx === -1) {\n partialLine += str\n } else {\n const str2 = partialLine + str.substr(0, idx)\n lines = lines.concat(str2.split(newline))\n\n if (idx === str.length - newline.length) {\n partialLine = ''\n } else {\n partialLine = str.substr(idx + newline.length)\n }\n }\n\n if (isLast && partialLine !== '') {\n lines.push(partialLine)\n }\n\n return {\n lines: lines,\n partialLine: partialLine\n }\n }\n\n nextChunk () {\n const start = this.__pointer\n\n if (start > this.data.length) {\n return undefined\n }\n\n this.__pointer += this.chunkSize\n return this.chunk(start)\n }\n\n nextChunkOfLines () {\n const chunk = this.nextChunk()\n\n if (chunk === undefined) {\n return undefined\n }\n\n const isLast = this.__pointer > this.data.length\n const d = this.chunkToLines(chunk, this.__partialLine, isLast)\n\n this.__partialLine = d.partialLine\n\n return d.lines\n }\n\n eachChunk (callback: (chunk: string|Uint8Array, chunkNo: number, chunkCount: number) => void) {\n const chunkSize = this.chunkSize\n const n = this.data.length\n const chunkCount = this.chunkCount()\n\n for (let i = 0; i < n; i += chunkSize) {\n const chunk = this.chunk(i)\n const chunkNo = Math.round(i / chunkSize)\n\n callback(chunk, chunkNo, chunkCount)\n }\n }\n\n eachChunkOfLines (callback: (chunk: string[], chunkNo: number, chunkCount: number) => void) {\n this.eachChunk((chunk, chunkNo, chunkCount) => {\n const isLast = chunkNo === chunkCount + 1\n const d = this.chunkToLines(chunk, this.__partialLine, isLast)\n\n this.__partialLine = d.partialLine\n\n callback(d.lines, chunkNo, chunkCount)\n })\n }\n\n dispose () {\n delete this.src\n }\n}\n\nexport default Streamer\n","/**\n * @file File Streamer\n * @author Alexander Rose \n * @private\n */\n\nimport Streamer from './streamer'\n\ninterface FileReaderEventTarget extends EventTarget {\n result:string | ArrayBuffer | null\n}\n\ninterface FileReaderEvent extends ProgressEvent {\n target: FileReaderEventTarget | null;\n}\n\nclass FileStreamer extends Streamer {\n _read () {\n return new Promise((resolve, reject) => {\n const file = this.src\n const reader = new FileReader()\n\n reader.onload = (event: FileReaderEvent) => {\n if(event.target) resolve(event.target.result)\n }\n\n // if (typeof this.onprogress === 'function') {\n // reader.onprogress = event => this.onprogress(event)\n // }\n\n reader.onerror = event => reject(event)\n\n if (this.binary || this.compressed) {\n reader.readAsArrayBuffer(file)\n } else {\n reader.readAsText(file)\n }\n })\n }\n}\n\nexport default FileStreamer\n","/**\n * @file Network Streamer\n * @author Alexander Rose \n * @private\n */\n\nimport Streamer from './streamer'\n\nclass NetworkStreamer extends Streamer {\n _read () {\n return new Promise((resolve, reject) => {\n const url = this.src\n const xhr = new XMLHttpRequest()\n\n xhr.open('GET', url, true)\n\n xhr.addEventListener('load', () => {\n if (xhr.status === 200 || xhr.status === 304 ||\n // when requesting from local file system\n // the status in Google Chrome/Chromium is 0\n xhr.status === 0\n ) {\n try {\n resolve(xhr.response)\n } catch (e) {\n reject(e)\n }\n } else {\n reject(xhr.statusText)\n }\n }, false)\n\n // if (typeof this.onprogress === 'function') {\n // xhr.addEventListener('progress', event => this.onprogress(event), false);\n // }\n\n xhr.addEventListener('error', event => reject('network error'), false)\n\n if (this.isBinary()) {\n xhr.responseType = 'arraybuffer'\n } else if (this.json) {\n xhr.responseType = 'json'\n } else if (this.xml) {\n xhr.responseType = 'document'\n } else {\n xhr.responseType = 'text'\n }\n // xhr.crossOrigin = true;\n\n xhr.send()\n })\n }\n}\n\nexport default NetworkStreamer\n","/**\n * @file Loader\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport { createParams } from '../utils'\nimport FileStreamer from '../streamer/file-streamer'\nimport NetworkStreamer from '../streamer/network-streamer'\nimport { LoaderParameters, LoaderInput } from './loader-utils'\n\n/**\n * Loader parameter object.\n * @typedef {Object} LoaderParameters - loader parameters\n * @property {String} ext - file extension, determines file type\n * @property {Boolean} compressed - flag data as compressed\n * @property {Boolean} binary - flag data as binary\n * @property {String} name - set data name\n */\n\n/**\n * Loader base class\n */\nabstract class Loader {\n parameters: LoaderParameters\n streamer: FileStreamer | NetworkStreamer\n\n /**\n * Construct a loader object\n * @param {String|File|Blob} src - data source, string is interpreted as an URL\n * @param {LoaderParameters} params - parameters object\n */\n constructor (src: LoaderInput, params: Partial = {}) {\n this.parameters = createParams(params, {\n ext: '',\n compressed: false,\n binary: ParserRegistry.isBinary(params.ext || ''),\n name: '',\n\n dir: '',\n path: '',\n protocol: ''\n } as LoaderParameters)\n\n const streamerParams = {\n compressed: this.parameters.compressed as string|false,\n binary: this.parameters.binary,\n json: ParserRegistry.isJson(this.parameters.ext),\n xml: ParserRegistry.isXml(this.parameters.ext)\n }\n\n if ((typeof File !== 'undefined' && src instanceof File) ||\n (typeof Blob !== 'undefined' && src instanceof Blob)\n ) {\n this.streamer = new FileStreamer(src, streamerParams)\n } else {\n this.streamer = new NetworkStreamer(src, streamerParams)\n }\n }\n\n /**\n * Load data\n * @abstract\n * @return {Promise} resolves to the loaded data {@link Object}\n */\n abstract load (): Promise\n}\n\nexport default Loader\n","/**\n * @file Parser Loader\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport type { InferBondsOptions } from '../structure/structure-utils'\nimport Loader from './loader'\nimport { LoaderParameters, LoaderInput } from './loader-utils'\n\nexport interface ParserParams {\n voxelSize?: number\n firstModelOnly?: boolean\n asTrajectory?: boolean\n cAlphaOnly?: boolean\n name?: string\n path?: string\n delimiter?: string\n comment?: string\n columnNames?: string\n inferBonds?: InferBondsOptions\n}\n\n/**\n * Parser loader class\n * @extends Loader\n */\nclass ParserLoader extends Loader {\n parserParams: ParserParams\n\n constructor (src: LoaderInput, params: Partial & ParserParams = {}) {\n super(src, params)\n this.parserParams = {\n voxelSize: params.voxelSize,\n firstModelOnly: params.firstModelOnly,\n asTrajectory: params.asTrajectory,\n cAlphaOnly: params.cAlphaOnly,\n delimiter: params.delimiter,\n comment: params.comment,\n columnNames: params.columnNames,\n inferBonds: params.inferBonds,\n name: this.parameters.name,\n path: this.parameters.path\n }\n }\n\n /**\n * Load parsed object\n * @return {Promise} resolves to the loaded & parsed {@link Structure},\n * {@link Volume}, {@link Surface} or data object\n */\n load () {\n var ParserClass = ParserRegistry.get(this.parameters.ext)\n var parser = new ParserClass(this.streamer, this.parserParams)\n\n return parser.parse()\n }\n}\n\nexport default ParserLoader\n","/**\n * @file Script\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { Log } from './globals'\nimport Stage from './stage/stage'\n\nexport interface ScriptSignals {\n elementAdded: Signal\n elementRemoved: Signal\n nameChanged: Signal\n}\n\n/**\n * Script class\n */\nclass Script {\n readonly signals: ScriptSignals = {\n elementAdded: new Signal(),\n elementRemoved: new Signal(),\n nameChanged: new Signal()\n }\n\n readonly dir: string\n readonly fn: Function\n\n readonly type = 'Script'\n\n /**\n * Create a script instance\n * @param {String} functionBody - the function source\n * @param {String} name - name of the script\n * @param {String} path - path of the script\n */\n constructor (functionBody: string, readonly name: string, readonly path: string) {\n this.dir = path.substring(0, path.lastIndexOf('/') + 1)\n\n try {\n /* eslint-disable no-new-func */\n this.fn = new Function('stage', '__name', '__path', '__dir', functionBody)\n } catch (e) {\n Log.error('Script compilation failed', e)\n this.fn = function () {}\n }\n }\n\n /**\n * Execute the script\n * @param {Stage} stage - the stage context\n * @return {Promise} - resolve when script finished running\n */\n run (stage: Stage): Promise {\n return new Promise((resolve, reject) => {\n try {\n this.fn.apply(null, [ stage, this.name, this.path, this.dir ])\n resolve()\n } catch (e) {\n Log.error('Script.fn', e)\n reject(e)\n }\n })\n }\n}\n\nexport default Script\n","/**\n * @file Script Loader\n * @author Alexander Rose \n * @private\n */\n\nimport Loader from './loader'\nimport Script from '../script'\n\n/**\n * Script loader class\n * @extends Loader\n */\nclass ScriptLoader extends Loader {\n /**\n * Load script\n * @return {Promise} resolves to the loaded {@link Script}\n */\n load () {\n return this.streamer.read().then(() => {\n return new Script(\n this.streamer.asText(), this.parameters.name, this.parameters.path\n )\n })\n }\n}\n\nexport default ScriptLoader\n","/**\n * @file Loader Utils\n * @author Alexander Rose \n * @private\n */\n\nimport {\n DatasourceRegistry, DecompressorRegistry, ParserRegistry, ScriptExtensions\n} from '../globals'\nimport ParserLoader, { ParserParams } from './parser-loader'\nimport ScriptLoader from './script-loader'\n\nexport interface LoaderParameters {\n ext: string // file extension, determines file type\n compressed: string|false // flag data as compressed\n binary: boolean // flag data as binary\n name: string // set data name\n\n dir: string\n path: string\n protocol: string\n}\n\nexport type LoaderInput = File|Blob|string\n\nexport function getFileInfo (file: LoaderInput) {\n const compressedExtList = DecompressorRegistry.names\n\n let path: string\n let compressed: string|false\n let protocol = ''\n\n if (file instanceof File) {\n path = file.name\n } else if (file instanceof Blob) {\n path = ''\n } else {\n path = file\n }\n const queryIndex = path.lastIndexOf('?')\n const query = queryIndex !== -1 ? path.substring(queryIndex) : ''\n path = path.substring(0, queryIndex === -1 ? path.length : queryIndex)\n\n const name = path.replace(/^.*[\\\\/]/, '')\n let base = name.substring(0, name.lastIndexOf('.'))\n\n const nameSplit = name.split('.')\n let ext = nameSplit.length > 1 ? (nameSplit.pop() || '').toLowerCase() : ''\n\n const protocolMatch = path.match(/^(.+):\\/\\/(.+)$/)\n if (protocolMatch) {\n protocol = protocolMatch[ 1 ].toLowerCase()\n path = protocolMatch[ 2 ] || ''\n }\n\n const dir = path.substring(0, path.lastIndexOf('/') + 1)\n\n if (compressedExtList.includes(ext)) {\n compressed = ext\n const n = path.length - ext.length - 1\n ext = (path.substr(0, n).split('.').pop() || '').toLowerCase()\n const m = base.length - ext.length - 1\n base = base.substr(0, m)\n } else {\n compressed = false\n }\n\n return { path, name, ext, base, dir, compressed, protocol, query, 'src': file }\n}\n\nexport function getDataInfo (src: LoaderInput) {\n let info = getFileInfo(src)\n const datasource = DatasourceRegistry.get(info.protocol)\n if (datasource) {\n info = getFileInfo(datasource.getUrl(info.src))\n if (!info.ext && datasource.getExt) {\n info.ext = datasource.getExt(src)\n }\n }\n return info\n}\n\n/**\n * Load a file\n *\n * @example\n * // load from URL\n * NGL.autoLoad( \"http://files.rcsb.org/download/5IOS.cif\" );\n *\n * @example\n * // load binary data in CCP4 format via a Blob\n * var binaryBlob = new Blob( [ ccp4Data ], { type: 'application/octet-binary'} );\n * NGL.autoLoad( binaryBlob, { ext: \"ccp4\" } );\n *\n * @example\n * // load string data in PDB format via a Blob\n * var stringBlob = new Blob( [ pdbData ], { type: 'text/plain'} );\n * NGL.autoLoad( stringBlob, { ext: \"pdb\" } );\n *\n * @example\n * // load a File object\n * NGL.autoLoad( file );\n *\n * @param {String|File|Blob} file - either a URL or an object containing the file data\n * @param {LoaderParameters} params - loading parameters\n * @return {Promise} Promise resolves to the loaded data\n */\nexport function autoLoad (file: LoaderInput, params: Partial = {}) {\n const p = Object.assign(getDataInfo(file), params)\n\n let loader\n if (ParserRegistry.names.includes(p.ext)) {\n loader = new ParserLoader(p.src, p)\n } else if (ScriptExtensions.includes(p.ext)) {\n loader = new ScriptLoader(p.src, p)\n }\n\n if (loader) {\n return loader.load()\n } else {\n return Promise.reject(new Error(`autoLoad: ext '${p.ext}' unknown`))\n }\n}\n","/* global window, exports, define */\n\n!function() {\n 'use strict'\n\n var re = {\n not_string: /[^s]/,\n not_bool: /[^t]/,\n not_type: /[^T]/,\n not_primitive: /[^v]/,\n number: /[diefg]/,\n numeric_arg: /[bcdiefguxX]/,\n json: /[j]/,\n not_json: /[^j]/,\n text: /^[^\\x25]+/,\n modulo: /^\\x25{2}/,\n placeholder: /^\\x25(?:([1-9]\\d*)\\$|\\(([^)]+)\\))?(\\+)?(0|'[^$])?(-)?(\\d+)?(?:\\.(\\d+))?([b-gijostTuvxX])/,\n key: /^([a-z_][a-z_\\d]*)/i,\n key_access: /^\\.([a-z_][a-z_\\d]*)/i,\n index_access: /^\\[(\\d+)\\]/,\n sign: /^[+-]/\n }\n\n function sprintf(key) {\n // `arguments` is not an array, but should be fine for this call\n return sprintf_format(sprintf_parse(key), arguments)\n }\n\n function vsprintf(fmt, argv) {\n return sprintf.apply(null, [fmt].concat(argv || []))\n }\n\n function sprintf_format(parse_tree, argv) {\n var cursor = 1, tree_length = parse_tree.length, arg, output = '', i, k, ph, pad, pad_character, pad_length, is_positive, sign\n for (i = 0; i < tree_length; i++) {\n if (typeof parse_tree[i] === 'string') {\n output += parse_tree[i]\n }\n else if (typeof parse_tree[i] === 'object') {\n ph = parse_tree[i] // convenience purposes only\n if (ph.keys) { // keyword argument\n arg = argv[cursor]\n for (k = 0; k < ph.keys.length; k++) {\n if (arg == undefined) {\n throw new Error(sprintf('[sprintf] Cannot access property \"%s\" of undefined value \"%s\"', ph.keys[k], ph.keys[k-1]))\n }\n arg = arg[ph.keys[k]]\n }\n }\n else if (ph.param_no) { // positional argument (explicit)\n arg = argv[ph.param_no]\n }\n else { // positional argument (implicit)\n arg = argv[cursor++]\n }\n\n if (re.not_type.test(ph.type) && re.not_primitive.test(ph.type) && arg instanceof Function) {\n arg = arg()\n }\n\n if (re.numeric_arg.test(ph.type) && (typeof arg !== 'number' && isNaN(arg))) {\n throw new TypeError(sprintf('[sprintf] expecting number but found %T', arg))\n }\n\n if (re.number.test(ph.type)) {\n is_positive = arg >= 0\n }\n\n switch (ph.type) {\n case 'b':\n arg = parseInt(arg, 10).toString(2)\n break\n case 'c':\n arg = String.fromCharCode(parseInt(arg, 10))\n break\n case 'd':\n case 'i':\n arg = parseInt(arg, 10)\n break\n case 'j':\n arg = JSON.stringify(arg, null, ph.width ? parseInt(ph.width) : 0)\n break\n case 'e':\n arg = ph.precision ? parseFloat(arg).toExponential(ph.precision) : parseFloat(arg).toExponential()\n break\n case 'f':\n arg = ph.precision ? parseFloat(arg).toFixed(ph.precision) : parseFloat(arg)\n break\n case 'g':\n arg = ph.precision ? String(Number(arg.toPrecision(ph.precision))) : parseFloat(arg)\n break\n case 'o':\n arg = (parseInt(arg, 10) >>> 0).toString(8)\n break\n case 's':\n arg = String(arg)\n arg = (ph.precision ? arg.substring(0, ph.precision) : arg)\n break\n case 't':\n arg = String(!!arg)\n arg = (ph.precision ? arg.substring(0, ph.precision) : arg)\n break\n case 'T':\n arg = Object.prototype.toString.call(arg).slice(8, -1).toLowerCase()\n arg = (ph.precision ? arg.substring(0, ph.precision) : arg)\n break\n case 'u':\n arg = parseInt(arg, 10) >>> 0\n break\n case 'v':\n arg = arg.valueOf()\n arg = (ph.precision ? arg.substring(0, ph.precision) : arg)\n break\n case 'x':\n arg = (parseInt(arg, 10) >>> 0).toString(16)\n break\n case 'X':\n arg = (parseInt(arg, 10) >>> 0).toString(16).toUpperCase()\n break\n }\n if (re.json.test(ph.type)) {\n output += arg\n }\n else {\n if (re.number.test(ph.type) && (!is_positive || ph.sign)) {\n sign = is_positive ? '+' : '-'\n arg = arg.toString().replace(re.sign, '')\n }\n else {\n sign = ''\n }\n pad_character = ph.pad_char ? ph.pad_char === '0' ? '0' : ph.pad_char.charAt(1) : ' '\n pad_length = ph.width - (sign + arg).length\n pad = ph.width ? (pad_length > 0 ? pad_character.repeat(pad_length) : '') : ''\n output += ph.align ? sign + arg + pad : (pad_character === '0' ? sign + pad + arg : pad + sign + arg)\n }\n }\n }\n return output\n }\n\n var sprintf_cache = Object.create(null)\n\n function sprintf_parse(fmt) {\n if (sprintf_cache[fmt]) {\n return sprintf_cache[fmt]\n }\n\n var _fmt = fmt, match, parse_tree = [], arg_names = 0\n while (_fmt) {\n if ((match = re.text.exec(_fmt)) !== null) {\n parse_tree.push(match[0])\n }\n else if ((match = re.modulo.exec(_fmt)) !== null) {\n parse_tree.push('%')\n }\n else if ((match = re.placeholder.exec(_fmt)) !== null) {\n if (match[2]) {\n arg_names |= 1\n var field_list = [], replacement_field = match[2], field_match = []\n if ((field_match = re.key.exec(replacement_field)) !== null) {\n field_list.push(field_match[1])\n while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') {\n if ((field_match = re.key_access.exec(replacement_field)) !== null) {\n field_list.push(field_match[1])\n }\n else if ((field_match = re.index_access.exec(replacement_field)) !== null) {\n field_list.push(field_match[1])\n }\n else {\n throw new SyntaxError('[sprintf] failed to parse named argument key')\n }\n }\n }\n else {\n throw new SyntaxError('[sprintf] failed to parse named argument key')\n }\n match[2] = field_list\n }\n else {\n arg_names |= 2\n }\n if (arg_names === 3) {\n throw new Error('[sprintf] mixing positional and named placeholders is not (yet) supported')\n }\n\n parse_tree.push(\n {\n placeholder: match[0],\n param_no: match[1],\n keys: match[2],\n sign: match[3],\n pad_char: match[4],\n align: match[5],\n width: match[6],\n precision: match[7],\n type: match[8]\n }\n )\n }\n else {\n throw new SyntaxError('[sprintf] unexpected placeholder')\n }\n _fmt = _fmt.substring(match[0].length)\n }\n return sprintf_cache[fmt] = parse_tree\n }\n\n /**\n * export to either browser or node.js\n */\n /* eslint-disable quote-props */\n if (typeof exports !== 'undefined') {\n exports['sprintf'] = sprintf\n exports['vsprintf'] = vsprintf\n }\n if (typeof window !== 'undefined') {\n window['sprintf'] = sprintf\n window['vsprintf'] = vsprintf\n\n if (typeof define === 'function' && define['amd']) {\n define(function() {\n return {\n 'sprintf': sprintf,\n 'vsprintf': vsprintf\n }\n })\n }\n }\n /* eslint-enable quote-props */\n}(); // eslint-disable-line\n","/**\n * @file Writer\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults, download } from '../utils'\n\n/**\n * Base class for writers\n * @interface\n */\nabstract class Writer {\n readonly mimeType: string\n readonly defaultName: string\n readonly defaultExt: string\n\n /**\n * @abstract\n * @return {Anything} the data to be written\n */\n abstract getData (): any\n\n /**\n * Get a blob with the written data\n * @return {Blob} the blob\n */\n getBlob () {\n return new Blob([ this.getData() ], { type: this.mimeType })\n }\n\n /**\n * Trigger a download of the\n * @param {[type]} name [description]\n * @param {[type]} ext [description]\n * @return {[type]} [description]\n */\n download (name?: string, ext?: string) {\n name = defaults(name, this.defaultName)\n ext = defaults(ext, this.defaultExt)\n\n download(this.getBlob(), `${name}.${ext}`)\n }\n}\n\nexport default Writer","/**\n * @file IO Buffer\n * @author Alexander Rose \n * @private\n *\n * Adapted and converted to TypeScript from https://github.com/image-js/iobuffer\n * MIT License, Copyright (c) 2015 Michaël Zasso\n */\n\nimport { TypedArray } from '../types'\n\nconst defaultByteLength = 1024 * 8\nconst charArray: string[] = []\n\nexport interface IOBufferParameters {\n offset?: number // Ignore the first n bytes of the ArrayBuffer\n}\n\n/**\n * Class for writing and reading binary data\n */\nclass IOBuffer {\n private _lastWrittenByte: number\n private _mark = 0\n private _marks: number[] = []\n private _data: DataView\n\n offset = 0 // The current offset of the buffer's pointer\n littleEndian = true\n buffer: ArrayBuffer // Reference to the internal ArrayBuffer object\n length: number // Byte length of the internal ArrayBuffer\n byteLength: number // Byte length of the internal ArrayBuffer\n byteOffset: number // Byte offset of the internal ArrayBuffer\n\n /**\n * If it's a number, it will initialize the buffer with the number as\n * the buffer's length. If it's undefined, it will initialize the buffer\n * with a default length of 8 Kb. If its an ArrayBuffer, a TypedArray,\n * it will create a view over the underlying ArrayBuffer.\n */\n constructor (data: number|ArrayBuffer|TypedArray, params: IOBufferParameters = {}) {\n let dataIsGiven = false\n if (data === undefined) {\n data = defaultByteLength\n }\n if (typeof data === 'number') {\n data = new ArrayBuffer(data)\n } else {\n dataIsGiven = true\n }\n\n const offset = params.offset ? params.offset >>> 0 : 0\n let byteLength = data.byteLength - offset\n let dvOffset = offset\n if (!(data instanceof ArrayBuffer)) {\n if (data.byteLength !== data.buffer.byteLength) {\n dvOffset = data.byteOffset + offset\n }\n data = data.buffer\n }\n if (dataIsGiven) {\n this._lastWrittenByte = byteLength\n } else {\n this._lastWrittenByte = 0\n }\n\n this.buffer = data\n this.length = byteLength\n this.byteLength = byteLength\n this.byteOffset = dvOffset\n\n this._data = new DataView(this.buffer, dvOffset, byteLength)\n }\n\n /**\n * Checks if the memory allocated to the buffer is sufficient to store more bytes after the offset\n * @param {number} [byteLength=1] The needed memory in bytes\n * @return {boolean} Returns true if there is sufficient space and false otherwise\n */\n available (byteLength: number) {\n if (byteLength === undefined) byteLength = 1\n return (this.offset + byteLength) <= this.length\n }\n\n /**\n * Check if little-endian mode is used for reading and writing multi-byte values\n * @return {boolean} Returns true if little-endian mode is used, false otherwise\n */\n isLittleEndian () {\n return this.littleEndian\n }\n\n /**\n * Set little-endian mode for reading and writing multi-byte values\n * @return {IOBuffer}\n */\n setLittleEndian () {\n this.littleEndian = true\n return this\n }\n\n /**\n * Check if big-endian mode is used for reading and writing multi-byte values\n * @return {boolean} Returns true if big-endian mode is used, false otherwise\n */\n isBigEndian () {\n return !this.littleEndian\n }\n\n /**\n * Switches to big-endian mode for reading and writing multi-byte values\n * @return {IOBuffer}\n */\n setBigEndian () {\n this.littleEndian = false\n return this\n }\n\n /**\n * Move the pointer n bytes forward\n * @param {number} n\n * @return {IOBuffer}\n */\n skip (n: number) {\n if (n === undefined) n = 1\n this.offset += n\n return this\n }\n\n /**\n * Move the pointer to the given offset\n * @param {number} offset\n * @return {IOBuffer}\n */\n seek (offset: number) {\n this.offset = offset\n return this\n }\n\n /**\n * Store the current pointer offset.\n * @see {@link IOBuffer#reset}\n * @return {IOBuffer}\n */\n mark () {\n this._mark = this.offset\n return this\n }\n\n /**\n * Move the pointer back to the last pointer offset set by mark\n * @see {@link IOBuffer#mark}\n * @return {IOBuffer}\n */\n reset () {\n this.offset = this._mark\n return this\n }\n\n /**\n * Push the current pointer offset to the mark stack\n * @see {@link IOBuffer#popMark}\n * @return {IOBuffer}\n */\n pushMark () {\n this._marks.push(this.offset)\n return this\n }\n\n /**\n * Pop the last pointer offset from the mark stack, and set the current pointer offset to the popped value\n * @see {@link IOBuffer#pushMark}\n * @return {IOBuffer}\n */\n popMark () {\n const offset = this._marks.pop()\n if (offset === undefined) throw new Error('Mark stack empty')\n this.seek(offset)\n return this\n }\n\n /**\n * Move the pointer offset back to 0\n * @return {IOBuffer}\n */\n rewind () {\n this.offset = 0\n return this\n }\n\n /**\n * Make sure the buffer has sufficient memory to write a given byteLength at the current pointer offset\n * If the buffer's memory is insufficient, this method will create a new buffer (a copy) with a length\n * that is twice (byteLength + current offset)\n * @param {number} [byteLength = 1]\n * @return {IOBuffer}\n */\n ensureAvailable (byteLength: number) {\n if (byteLength === undefined) byteLength = 1\n if (!this.available(byteLength)) {\n const lengthNeeded = this.offset + byteLength\n const newLength = lengthNeeded * 2\n const newArray = new Uint8Array(newLength)\n newArray.set(new Uint8Array(this.buffer))\n this.buffer = newArray.buffer\n this.length = this.byteLength = newLength\n this._data = new DataView(this.buffer)\n }\n return this\n }\n\n /**\n * Read a byte and return false if the byte's value is 0, or true otherwise\n * Moves pointer forward\n * @return {boolean}\n */\n readBoolean () {\n return this.readUint8() !== 0\n }\n\n /**\n * Read a signed 8-bit integer and move pointer forward\n * @return {number}\n */\n readInt8 () {\n return this._data.getInt8(this.offset++)\n }\n\n /**\n * Read an unsigned 8-bit integer and move pointer forward\n * @return {number}\n */\n readUint8 () {\n return this._data.getUint8(this.offset++)\n }\n\n /**\n * Alias for {@link IOBuffer#readUint8}\n * @return {number}\n */\n readByte () {\n return this.readUint8()\n }\n\n /**\n * Read n bytes and move pointer forward.\n * @param {number} n\n * @return {Uint8Array}\n */\n readBytes (n: number) {\n if (n === undefined) n = 1\n var bytes = new Uint8Array(n)\n for (var i = 0; i < n; i++) {\n bytes[i] = this.readByte()\n }\n return bytes\n }\n\n /**\n * Read a 16-bit signed integer and move pointer forward\n * @return {number}\n */\n readInt16 () {\n var value = this._data.getInt16(this.offset, this.littleEndian)\n this.offset += 2\n return value\n }\n\n /**\n * Read a 16-bit unsigned integer and move pointer forward\n * @return {number}\n */\n readUint16 () {\n var value = this._data.getUint16(this.offset, this.littleEndian)\n this.offset += 2\n return value\n }\n\n /**\n * Read a 32-bit signed integer and move pointer forward\n * @return {number}\n */\n readInt32 () {\n var value = this._data.getInt32(this.offset, this.littleEndian)\n this.offset += 4\n return value\n }\n\n /**\n * Read a 32-bit unsigned integer and move pointer forward\n * @return {number}\n */\n readUint32 () {\n var value = this._data.getUint32(this.offset, this.littleEndian)\n this.offset += 4\n return value\n }\n\n /**\n * Read a 32-bit floating number and move pointer forward\n * @return {number}\n */\n readFloat32 () {\n var value = this._data.getFloat32(this.offset, this.littleEndian)\n this.offset += 4\n return value\n }\n\n /**\n * Read a 64-bit floating number and move pointer forward\n * @return {number}\n */\n readFloat64 () {\n var value = this._data.getFloat64(this.offset, this.littleEndian)\n this.offset += 8\n return value\n }\n\n /**\n * Read 1-byte ascii character and move pointer forward\n * @return {string}\n */\n readChar () {\n return String.fromCharCode(this.readInt8())\n }\n\n /**\n * Read n 1-byte ascii characters and move pointer forward\n * @param {number} n\n * @return {string}\n */\n readChars (n = 1) {\n charArray.length = n\n for (var i = 0; i < n; i++) {\n charArray[i] = this.readChar()\n }\n return charArray.join('')\n }\n\n /**\n * Write 0xff if the passed value is truthy, 0x00 otherwise\n * @param {any} value\n * @return {IOBuffer}\n */\n writeBoolean (value = false) {\n this.writeUint8(value ? 0xff : 0x00)\n return this\n }\n\n /**\n * Write value as an 8-bit signed integer\n * @param {number} value\n * @return {IOBuffer}\n */\n writeInt8 (value: number) {\n this.ensureAvailable(1)\n this._data.setInt8(this.offset++, value)\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write value as a 8-bit unsigned integer\n * @param {number} value\n * @return {IOBuffer}\n */\n writeUint8 (value: number) {\n this.ensureAvailable(1)\n this._data.setUint8(this.offset++, value)\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * An alias for {@link IOBuffer#writeUint8}\n * @param {number} value\n * @return {IOBuffer}\n */\n writeByte (value: number) {\n return this.writeUint8(value)\n }\n\n /**\n * Write bytes\n * @param {Array|Uint8Array} bytes\n * @return {IOBuffer}\n */\n writeBytes (bytes: number[]|Uint8Array) {\n this.ensureAvailable(bytes.length)\n for (var i = 0; i < bytes.length; i++) {\n this._data.setUint8(this.offset++, bytes[i])\n }\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write value as an 16-bit signed integer\n * @param {number} value\n * @return {IOBuffer}\n */\n writeInt16 (value: number) {\n this.ensureAvailable(2)\n this._data.setInt16(this.offset, value, this.littleEndian)\n this.offset += 2\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write value as a 16-bit unsigned integer\n * @param {number} value\n * @return {IOBuffer}\n */\n writeUint16 (value: number) {\n this.ensureAvailable(2)\n this._data.setUint16(this.offset, value, this.littleEndian)\n this.offset += 2\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write a 32-bit signed integer at the current pointer offset\n * @param {number} value\n * @return {IOBuffer}\n */\n writeInt32 (value: number) {\n this.ensureAvailable(4)\n this._data.setInt32(this.offset, value, this.littleEndian)\n this.offset += 4\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write a 32-bit unsigned integer at the current pointer offset\n * @param {number} value - The value to set\n * @return {IOBuffer}\n */\n writeUint32 (value: number) {\n this.ensureAvailable(4)\n this._data.setUint32(this.offset, value, this.littleEndian)\n this.offset += 4\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write a 32-bit floating number at the current pointer offset\n * @param {number} value - The value to set\n * @return {IOBuffer}\n */\n writeFloat32 (value: number) {\n this.ensureAvailable(4)\n this._data.setFloat32(this.offset, value, this.littleEndian)\n this.offset += 4\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write a 64-bit floating number at the current pointer offset\n * @param {number} value\n * @return {IOBuffer}\n */\n writeFloat64 (value: number) {\n this.ensureAvailable(8)\n this._data.setFloat64(this.offset, value, this.littleEndian)\n this.offset += 8\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write the charCode of the passed string's first character to the current pointer offset\n * @param {string} str - The character to set\n * @return {IOBuffer}\n */\n writeChar (str: string) {\n return this.writeUint8(str.charCodeAt(0))\n }\n\n /**\n * Write the charCodes of the passed string's characters to the current pointer offset\n * @param {string} str\n * @return {IOBuffer}\n */\n writeChars (str: string) {\n for (var i = 0; i < str.length; i++) {\n this.writeUint8(str.charCodeAt(i))\n }\n return this\n }\n\n /**\n * Export a Uint8Array view of the internal buffer.\n * The view starts at the byte offset and its length\n * is calculated to stop at the last written byte or the original length.\n * @return {Uint8Array}\n */\n toArray () {\n return new Uint8Array(this.buffer, this.byteOffset, this._lastWrittenByte)\n }\n\n /**\n * Update the last written byte offset\n * @private\n */\n _updateLastWrittenByte () {\n if (this.offset > this._lastWrittenByte) {\n this._lastWrittenByte = this.offset\n }\n }\n}\n\nexport default IOBuffer\n","/**\n * @file Counter\n * @author Alexander Rose \n * @private\n */\n\nimport { Log } from '../globals'\n\nimport * as signalsWrapper from 'signals'\n\n/**\n * {@link Signal}, dispatched when the `count` changes\n * @example\n * counter.signals.countChanged.add( function( delta ){ ... } );\n * @event Counter#countChanged\n * @type {Integer}\n */\n\nexport interface CounterSignals {\n countChanged: signalsWrapper.Signal\n}\n\n/**\n * Counter class for keeping track of counts\n */\nclass Counter {\n count = 0\n\n signals: CounterSignals = {\n countChanged: new signalsWrapper.Signal()\n }\n\n /**\n * Set the `count` to zero\n * @return {undefined}\n */\n clear () {\n this.change(-this.count)\n }\n\n /**\n * Change the `count`\n * @fires Counter#countChanged\n * @param {Integer} delta - count change\n * @return {undefined}\n */\n change (delta: number) {\n this.count += delta\n this.signals.countChanged.dispatch(delta, this.count)\n\n if (this.count < 0) {\n Log.warn('Counter.count below zero', this.count)\n }\n }\n\n /**\n * Increments the `count` by one.\n * @return {undefined}\n */\n increment () {\n this.change(1)\n }\n\n /**\n * Decrements the `count` by one.\n * @return {undefined}\n */\n decrement () {\n this.change(-1)\n }\n\n /**\n * Listen to another counter object and change this `count` by the\n * same amount\n * @param {Counter} counter - the counter object to listen to\n * @return {undefined}\n */\n listen (counter: Counter) {\n this.change(counter.count)\n counter.signals.countChanged.add(this.change, this)\n }\n\n /**\n * Stop listening to the other counter object\n * @param {Counter} counter - the counter object to stop listening to\n * @return {undefined}\n */\n unlisten (counter: Counter) {\n const countChanged = counter.signals.countChanged\n if (countChanged.has(this.change, this)) {\n countChanged.remove(this.change, this)\n }\n }\n\n /**\n * Invole the callback function once, when the `count` becomes zero\n * @param {Function} callback - the callback function\n * @param {Object} context - the context for the callback function\n * @return {undefined}\n */\n onZeroOnce (callback: () => void, context?: any) {\n if (this.count === 0) {\n callback.call(context)\n } else {\n const fn = () => {\n if (this.count === 0) {\n this.signals.countChanged.remove(fn, this)\n callback.call(context)\n }\n }\n this.signals.countChanged.add(fn, this)\n }\n }\n\n dispose () {\n this.clear()\n this.signals.countChanged.dispose()\n }\n}\n\nexport default Counter\n","/**\n * @file Stats\n * @author Alexander Rose \n * @private\n */\n\nimport * as signalsWrapper from 'signals'\n\nexport default class Stats {\n signals = {\n updated: new signalsWrapper.Signal()\n }\n\n maxDuration = -Infinity\n minDuration = Infinity\n avgDuration = 14\n lastDuration = Infinity\n\n prevFpsTime = 0\n lastFps = Infinity\n lastFrames = 1\n frames = 0\n count = 0\n\n startTime: number\n currentTime: number\n\n constructor () {\n this.begin()\n }\n\n update () {\n this.startTime = this.end()\n this.currentTime = this.startTime\n this.signals.updated.dispatch()\n }\n\n begin () {\n this.startTime = window.performance.now()\n this.lastFrames = this.frames\n }\n\n end () {\n const time = window.performance.now()\n\n this.count += 1\n this.frames += 1\n\n this.lastDuration = time - this.startTime\n this.minDuration = Math.min(this.minDuration, this.lastDuration)\n this.maxDuration = Math.max(this.maxDuration, this.lastDuration)\n this.avgDuration -= this.avgDuration / 30\n this.avgDuration += this.lastDuration / 30\n\n if (time > this.prevFpsTime + 1000) {\n this.lastFps = this.frames\n this.prevFpsTime = time\n this.frames = 0\n }\n\n return time\n }\n}","/**\n * @file Shader Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { ShaderChunk } from 'three'\n\nimport './chunk/fog_fragment.glsl'\nimport './chunk/interior_fragment.glsl'\nimport './chunk/matrix_scale.glsl'\nimport './chunk/nearclip_vertex.glsl'\nimport './chunk/nearclip_fragment.glsl'\nimport './chunk/opaque_back_fragment.glsl'\nimport './chunk/radiusclip_vertex.glsl'\nimport './chunk/radiusclip_fragment.glsl'\nimport './chunk/unpack_color.glsl'\n\nimport { ShaderRegistry } from '../globals'\n\nexport type ShaderDefine = (\n 'NEAR_CLIP'|'RADIUS_CLIP'|'PICKING'|'NOLIGHT'|'FLAT_SHADED'|'OPAQUE_BACK'|\n 'DIFFUSE_INTERIOR'|'USE_INTERIOR_COLOR'|\n 'USE_SIZEATTENUATION'|'USE_MAP'|'ALPHATEST'|'SDF'|'FIXED_SIZE'|\n 'CUBIC_INTERPOLATION'|'BSPLINE_FILTER'|'CATMULROM_FILTER'|'MITCHELL_FILTER'\n)\nexport type ShaderDefines = {\n [k in ShaderDefine]?: number|string\n}\n\nfunction getDefines (defines: ShaderDefines) {\n if (defines === undefined) return ''\n\n const lines = []\n\n for (const name in defines) {\n const value = defines[ name as keyof ShaderDefines ]\n\n if (!value) continue\n\n lines.push(`#define ${name} ${value}`)\n }\n\n return lines.join('\\n') + '\\n'\n}\n\nconst reInclude = /^(?!\\/\\/)\\s*#include\\s+(\\S+)/gmi\nconst shaderCache: { [k: string]: string } = {}\n\nexport function getShader (name: string, defines: ShaderDefines = {}) {\n let hash = name + '|'\n for (const key in defines) {\n hash += key + ':' + defines[ key as keyof ShaderDefines ]\n }\n\n if (!shaderCache[ hash ]) {\n const definesText = getDefines(defines)\n\n let shaderText = ShaderRegistry.get(`shader/${name}`) as string\n if (!shaderText) {\n throw new Error(`empty shader, '${name}'`)\n }\n shaderText = shaderText.replace(reInclude, function (match, p1) {\n const path = `shader/chunk/${p1}.glsl`\n const chunk = ShaderRegistry.get(path) || ShaderChunk[ p1 ]\n if (!chunk) {\n throw new Error(`empty chunk, '${p1}'`)\n }\n return chunk\n })\n\n shaderCache[ hash ] = definesText + shaderText\n }\n\n return shaderCache[ hash ]\n}\n","/**\n * @file Viewer Constants\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug } from '../globals'\n\nif (typeof WebGLRenderingContext !== 'undefined') {\n const wrcp = WebGLRenderingContext.prototype\n\n // wrap WebGL debug function used by three.js and\n // ignore calls to them when the debug flag is not set\n\n const _getShaderParameter = wrcp.getShaderParameter\n wrcp.getShaderParameter = function getShaderParameter (this: WebGLRenderingContext) {\n if (Debug) {\n return _getShaderParameter.apply(this, arguments)\n } else {\n return true\n }\n }\n\n const _getShaderInfoLog = wrcp.getShaderInfoLog\n wrcp.getShaderInfoLog = function getShaderInfoLog (this: WebGLRenderingContext) {\n if (Debug) {\n return _getShaderInfoLog.apply(this, arguments)\n } else {\n return ''\n }\n }\n\n const _getProgramParameter = wrcp.getProgramParameter\n wrcp.getProgramParameter = function getProgramParameter (this: WebGLRenderingContext, program, pname) {\n if (Debug || pname !== wrcp.LINK_STATUS) {\n return _getProgramParameter.apply(this, arguments)\n } else {\n return true\n }\n }\n\n const _getProgramInfoLog = wrcp.getProgramInfoLog\n wrcp.getProgramInfoLog = function getProgramInfoLog (this: WebGLRenderingContext) {\n if (Debug) {\n return _getProgramInfoLog.apply(this, arguments)\n } else {\n return ''\n }\n }\n}\n\nexport const JitterVectors = [\n [\n [ 0, 0 ]\n ],\n [\n [ 4, 4 ], [ -4, -4 ]\n ],\n [\n [ -2, -6 ], [ 6, -2 ], [ -6, 2 ], [ 2, 6 ]\n ],\n [\n [ 1, -3 ], [ -1, 3 ], [ 5, 1 ], [ -3, -5 ],\n [ -5, 5 ], [ -7, -1 ], [ 3, 7 ], [ 7, -7 ]\n ],\n [\n [ 1, 1 ], [ -1, -3 ], [ -3, 2 ], [ 4, -1 ],\n [ -5, -2 ], [ 2, 5 ], [ 5, 3 ], [ 3, -5 ],\n [ -2, 6 ], [ 0, -7 ], [ -4, -6 ], [ -6, 4 ],\n [ -8, 0 ], [ 7, -4 ], [ 6, 7 ], [ -7, -8 ]\n ],\n [\n [ -4, -7 ], [ -7, -5 ], [ -3, -5 ], [ -5, -4 ],\n [ -1, -4 ], [ -2, -2 ], [ -6, -1 ], [ -4, 0 ],\n [ -7, 1 ], [ -1, 2 ], [ -6, 3 ], [ -3, 3 ],\n [ -7, 6 ], [ -3, 6 ], [ -5, 7 ], [ -1, 7 ],\n [ 5, -7 ], [ 1, -6 ], [ 6, -5 ], [ 4, -4 ],\n [ 2, -3 ], [ 7, -2 ], [ 1, -1 ], [ 4, -1 ],\n [ 2, 1 ], [ 6, 2 ], [ 0, 4 ], [ 4, 4 ],\n [ 2, 5 ], [ 7, 5 ], [ 5, 6 ], [ 3, 7 ]\n ]\n]\n\nJitterVectors.forEach(offsetList => {\n offsetList.forEach(offset => {\n // 0.0625 = 1 / 16\n offset[ 0 ] *= 0.0625\n offset[ 1 ] *= 0.0625\n })\n})\n","/**\n * @file Tiled Renderer\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { Camera, WebGLRenderer } from 'three'\nimport Viewer from './viewer'\n\nexport interface TiledRendererParams {\n factor?: number\n antialias?: boolean\n onProgress?: Function\n onFinish?: Function\n}\n\nclass TiledRenderer {\n canvas = document.createElement('canvas')\n\n private _width: number\n private _height: number\n private _n: number\n private _factor: number\n private _antialias: boolean\n private _viewerSampleLevel: number\n\n private _viewer: Viewer\n private _onProgress?: Function\n private _onFinish?: Function\n private _ctx: CanvasRenderingContext2D\n\n constructor(renderer: WebGLRenderer, camera: Camera, viewer: Viewer, params: TiledRendererParams) {\n this._viewer = viewer\n\n this._factor = defaults(params.factor, 2)\n this._antialias = defaults(params.antialias, false)\n\n this._onProgress = params.onProgress\n this._onFinish = params.onFinish\n\n if (this._antialias) this._factor *= 2\n this._n = this._factor * this._factor\n\n // canvas\n\n this._width = this._viewer.width\n this._height = this._viewer.height\n\n if (this._antialias) {\n this.canvas.width = this._width * this._factor / 2\n this.canvas.height = this._height * this._factor / 2\n } else {\n this.canvas.width = this._width * this._factor\n this.canvas.height = this._height * this._factor\n }\n\n this._ctx = this.canvas.getContext('2d')!\n\n this._viewerSampleLevel = viewer.sampleLevel\n this._viewer.setSampling(-1)\n }\n\n private _renderTile (i: number) {\n const viewer = this._viewer\n const width = this._width\n const height = this._height\n const factor = this._factor\n\n const x = i % factor\n const y = Math.floor(i / factor)\n\n const offsetX = x * width\n const offsetY = y * height\n\n viewer.camera.setViewOffset(\n width * factor,\n height * factor,\n offsetX,\n offsetY,\n width,\n height\n )\n\n viewer.render()\n\n if (this._antialias) {\n const w = Math.round((offsetX + width) / 2) - Math.round (offsetX / 2);\n const h = Math.round((offsetY + height) / 2) - Math.round (offsetY / 2);\n this._ctx.drawImage(\n viewer.renderer.domElement,\n Math.round(offsetX / 2),\n Math.round(offsetY / 2),\n w,\n h\n )\n } else {\n this._ctx.drawImage(\n viewer.renderer.domElement,\n Math.floor(offsetX),\n Math.floor(offsetY),\n Math.ceil(width),\n Math.ceil(height)\n )\n }\n\n if (typeof this._onProgress === 'function') {\n this._onProgress(i + 1, this._n, false)\n }\n }\n\n private _finalize () {\n this._viewer.setSampling(this._viewerSampleLevel)\n this._viewer.camera.view = null! // TODO\n\n if (typeof this._onFinish === 'function') {\n this._onFinish(this._n + 1, this._n, false)\n }\n }\n\n render () {\n for (let i = 0; i <= this._n; ++i) {\n if (i === this._n) {\n this._finalize()\n } else {\n this._renderTile(i)\n }\n }\n }\n\n renderAsync () {\n let count = 0\n const n = this._n\n\n const fn = () => {\n if (count === n) {\n this._finalize()\n } else {\n this._renderTile(count)\n }\n count += 1\n }\n\n for (let i = 0; i <= n; ++i) {\n setTimeout(fn, 0)\n }\n }\n}\n\nexport default TiledRenderer\n","/**\n * @file Math Constants\n * @author Alexander Rose \n * @private\n */\n\nexport const EPS = 0.0000001\nexport const TwoPI = 2 * Math.PI\n\nexport const DEG2RAD = Math.PI / 180\nexport const RAD2DEG = 180 / Math.PI\n","/**\n * @file Array Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { NumberArray } from '../types'\nimport { TwoPI } from './math-constants'\n\nexport function circularMean (array: NumberArray, max: number, stride = 1, offset = 0, indices?: NumberArray) {\n // http://en.wikipedia.org/wiki/Center_of_mass#Systems_with_periodic_boundary_conditions\n\n // Bai, Linge; Breen, David (2008). Calculating Center of Mass in an Unbounded 2D Environment. Journal of Graphics, GPU, and Game Tools 13 (4): 53–60.\n\n // http://stackoverflow.com/questions/18166507/using-fft-to-find-the-center-of-mass-under-periodic-boundary-conditions\n\n const n = indices ? indices.length : array.length / stride\n\n let cosMean = 0\n let sinMean = 0\n\n if (indices) {\n for (let i = 0; i < n; ++i) {\n const c = (array[ indices[ i ] * stride + offset ] + max) % max\n const angle = (c / max) * TwoPI - Math.PI\n\n cosMean += Math.cos(angle)\n sinMean += Math.sin(angle)\n }\n } else {\n for (let i = offset; i < n; i += stride) {\n const c = (array[ i ] + max) % max\n const angle = (c / max) * TwoPI - Math.PI\n\n cosMean += Math.cos(angle)\n sinMean += Math.sin(angle)\n }\n }\n\n cosMean /= n\n sinMean /= n\n\n const meanAngle = Math.atan2(sinMean, cosMean)\n const mean = (meanAngle + Math.PI) / TwoPI * max\n\n return mean\n}\n\nexport function calculateCenterArray (array1: NumberArray, array2: NumberArray, center?: T, offset = 0): T {\n const n = array1.length\n const c = center || new Float32Array(n)\n\n for (let i = 0; i < n; i += 3) {\n c[ offset + i + 0 ] = (array1[ i + 0 ] + array2[ i + 0 ]) / 2.0\n c[ offset + i + 1 ] = (array1[ i + 1 ] + array2[ i + 1 ]) / 2.0\n c[ offset + i + 2 ] = (array1[ i + 2 ] + array2[ i + 2 ]) / 2.0\n }\n\n return c as T\n}\n\nexport function calculateDirectionArray (array1: NumberArray, array2: NumberArray) {\n const n = array1.length\n const direction = new Float32Array(n)\n\n for (let i = 0; i < n; i += 3) {\n direction[ i + 0 ] = array2[ i + 0 ] - array1[ i + 0 ]\n direction[ i + 1 ] = array2[ i + 1 ] - array1[ i + 1 ]\n direction[ i + 2 ] = array2[ i + 2 ] - array1[ i + 2 ]\n }\n\n return direction\n}\n\nexport function uniformArray (n: number, a: number, optionalTarget?: T): T {\n const array = optionalTarget || new Float32Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = a\n }\n\n return array as T\n}\n\nexport function uniformArray3 (n: number, a: number, b: number, c: number, optionalTarget?: NumberArray) {\n const array = optionalTarget || new Float32Array(n * 3)\n\n for (let i = 0; i < n; ++i) {\n const j = i * 3\n\n array[ j + 0 ] = a\n array[ j + 1 ] = b\n array[ j + 2 ] = c\n }\n\n return array\n}\n\nexport function centerArray3 (array: NumberArray, center = new Vector3()) {\n const n = array.length\n\n for (let i = 0; i < n; i += 3) {\n center.x += array[ i ]\n center.y += array[ i + 1 ]\n center.z += array[ i + 2 ]\n }\n\n center.divideScalar(n / 3)\n\n return center\n}\n\nexport function serialArray (n: number) {\n const array = new Float32Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = i\n }\n\n return array\n}\n\nexport function serialBlockArray (n: number, b: number, offset = 0, optionalTarget?: NumberArray) {\n const array = optionalTarget || new Float32Array(n * b)\n\n for (let i = 0; i < n; ++i) {\n const k = offset + i * b\n\n for (let j = 0; j < b; ++j) {\n array[ k + j ] = i\n }\n }\n\n return array\n}\n\nexport function randomColorArray (n: number) {\n const array = new Float32Array(n * 3)\n\n for (let i = 0; i < n; ++i) {\n const j = i * 3\n\n array[ j + 0 ] = Math.random()\n array[ j + 1 ] = Math.random()\n array[ j + 2 ] = Math.random()\n }\n\n return array\n}\n\nexport function replicateArrayEntries (array: NumberArray, m: number) {\n const n = array.length\n const repArr = new Float32Array(n * m)\n\n for (let i = 0; i < n; ++i) {\n const k = i * m\n const a = array[ i ]\n\n for (let j = 0; j < m; ++j) {\n repArr[ k + j ] = a\n }\n }\n\n return repArr\n}\n\nexport function replicateArray3Entries (array: NumberArray, m: number) {\n const n = array.length / 3\n const repArr = new Float32Array(n * m * 3)\n\n for (let i = 0; i < n; ++i) {\n const v = i * 3\n const k = i * m * 3\n\n const a = array[ v + 0 ]\n const b = array[ v + 1 ]\n const c = array[ v + 2 ]\n\n for (let j = 0; j < m; ++j) {\n const l = k + j * 3\n\n repArr[ l + 0 ] = a\n repArr[ l + 1 ] = b\n repArr[ l + 2 ] = c\n }\n }\n\n return repArr\n}\n\nexport function calculateMeanArray (array1: NumberArray, array2: NumberArray) {\n const n = array1.length\n const mean = new Float32Array(n)\n\n for (let i = 0; i < n; i++) {\n mean[ i ] = (array1[ i ] + array2[ i ]) / 2.0\n }\n\n return mean\n}\n\nexport function calculateMinArray (array1: NumberArray, array2: NumberArray) {\n const n = array1.length\n const min = new Float32Array(n)\n\n for (let i = 0; i < n; i++) {\n min[ i ] = Math.min(array1[ i ], array2[ i ])\n }\n\n return min\n}\n\nexport function copyArray (src: T, dst: T, srcOffset: number, dstOffset: number, length: number) {\n for (let i = 0; i < length; ++i) {\n dst[ dstOffset + i ] = src[ srcOffset + i ]\n }\n}\n\nexport function copyWithin (array: NumberArray|any[], srcOffset: number, dstOffset: number, length: number) {\n copyArray(array, array, srcOffset, dstOffset, length)\n}\n\nconst swap = new Float32Array(4)\nconst temp = new Float32Array(4)\n/**\n * quicksortIP\n * @function\n * @author Roman Bolzern , 2013\n * @author I4DS http://www.fhnw.ch/i4ds, 2013\n * @license MIT License \n * @description\n * In-place quicksort for typed arrays (e.g. for Float32Array)\n * provides fast sorting\n * useful e.g. for a custom shader and/or BufferGeometry\n * Complexity: http://bigocheatsheet.com/ see Quicksort\n *\n * @example\n * points: [x, y, z, x, y, z, x, y, z, ...]\n * eleSize: 3 //because of (x, y, z)\n * orderElement: 0 //order according to x\n *\n * @param {TypedArray} arr - array to be sorted\n * @param {Integer} eleSize - element size\n * @param {Integer} orderElement - index of element used for sorting, < eleSize\n * @param {Integer} [begin] - start index for range to be sorted\n * @param {Integer} [end] - end index for range to be sorted\n * @return {TypedArray} the input array\n */\nexport function quicksortIP (arr: NumberArray, eleSize: number, orderElement: number, begin = 0, end?: number) {\n end = (end || (arr.length / eleSize)) - 1\n\n const stack = []\n let sp = -1\n let left = begin\n let right = end\n let tmp = 0.0\n let x = 0\n let y = 0\n\n const swapF = function (a: number, b: number) {\n a *= eleSize; b *= eleSize\n for (y = 0; y < eleSize; y++) {\n tmp = arr[ a + y ]\n arr[ a + y ] = arr[ b + y ]\n arr[ b + y ] = tmp\n }\n }\n\n let i, j\n\n while (true) {\n if (right - left <= 25) {\n for (j = left + 1; j <= right; j++) {\n for (x = 0; x < eleSize; x++) {\n swap[ x ] = arr[ j * eleSize + x ]\n }\n\n i = j - 1\n\n while (i >= left && arr[ i * eleSize + orderElement ] > swap[ orderElement ]) {\n for (x = 0; x < eleSize; x++) {\n arr[ (i + 1) * eleSize + x ] = arr[ i * eleSize + x ]\n }\n i--\n }\n\n for (x = 0; x < eleSize; x++) {\n arr[ (i + 1) * eleSize + x ] = swap[ x ]\n }\n }\n\n if (sp === -1) break\n\n right = stack[ sp-- ] // ?\n left = stack[ sp-- ]\n } else {\n const median = (left + right) >> 1\n\n i = left + 1\n j = right\n\n swapF(median, i)\n\n if (arr[ left * eleSize + orderElement ] > arr[ right * eleSize + orderElement ]) {\n swapF(left, right)\n }\n\n if (arr[ i * eleSize + orderElement ] > arr[ right * eleSize + orderElement ]) {\n swapF(i, right)\n }\n\n if (arr[ left * eleSize + orderElement ] > arr[ i * eleSize + orderElement ]) {\n swapF(left, i)\n }\n\n for (x = 0; x < eleSize; x++) {\n temp[ x ] = arr[ i * eleSize + x ]\n }\n\n while (true) {\n do i++; while (arr[ i * eleSize + orderElement ] < temp[ orderElement ])\n do j--; while (arr[ j * eleSize + orderElement ] > temp[ orderElement ])\n if (j < i) break\n swapF(i, j)\n }\n\n for (x = 0; x < eleSize; x++) {\n arr[ (left + 1) * eleSize + x ] = arr[ j * eleSize + x ]\n arr[ j * eleSize + x ] = temp[ x ]\n }\n\n if (right - i + 1 >= j - left) {\n stack[ ++sp ] = i\n stack[ ++sp ] = right\n right = j - 1\n } else {\n stack[ ++sp ] = left\n stack[ ++sp ] = j - 1\n left = i\n }\n }\n }\n\n return arr\n}\n\nexport function quicksortCmp (arr: NumberArray|T[], cmp?: (a: number|T, b: number|T) => number, begin = 0, end?: number) {\n cmp = cmp || function cmp (a, b) {\n if (a > b) return 1\n if (a < b) return -1\n return 0\n }\n end = (end || arr.length) - 1\n\n const stack = []\n let sp = -1\n let left = begin\n let right = end\n let tmp: number|T\n\n function swap (a: number, b: number) {\n const tmp2 = arr[ a ]\n arr[ a ] = arr[ b ]\n arr[ b ] = tmp2\n }\n\n let i, j\n\n while (true) {\n if (right - left <= 25) {\n for (let k = left + 1; k <= right; ++k) {\n tmp = arr[ k ]\n i = k - 1\n\n while (i >= left && cmp(arr[ i ], tmp) > 0) {\n arr[ i + 1 ] = arr[ i ]\n --i\n }\n\n arr[ i + 1 ] = tmp\n }\n\n if (sp === -1) break\n\n right = stack[ sp-- ] // ?\n left = stack[ sp-- ]\n } else {\n const median = (left + right) >> 1\n\n i = left + 1\n j = right\n\n swap(median, i)\n\n if (cmp(arr[ left ], arr[ right ]) > 0) {\n swap(left, right)\n }\n\n if (cmp(arr[ i ], arr[ right ]) > 0) {\n swap(i, right)\n }\n\n if (cmp(arr[ left ], arr[ i ]) > 0) {\n swap(left, i)\n }\n\n tmp = arr[ i ]\n\n while (true) {\n do i++; while (cmp(arr[ i ], tmp) < 0)\n do j--; while (cmp(arr[ j ], tmp) > 0)\n if (j < i) break\n swap(i, j)\n }\n\n arr[ left + 1 ] = arr[ j ]\n arr[ j ] = tmp\n\n if (right - i + 1 >= j - left) {\n stack[ ++sp ] = i\n stack[ ++sp ] = right\n right = j - 1\n } else {\n stack[ ++sp ] = left\n stack[ ++sp ] = j - 1\n left = i\n }\n }\n }\n\n return arr\n}\n\nexport function quickselectCmp (arr: NumberArray|T[], n: number, cmp?: (a: number|T, b: number|T) => number, left = 0, right?: number) {\n cmp = cmp || function cmp (a, b) {\n if (a > b) return 1\n if (a < b) return -1\n return 0\n }\n right = (right || arr.length) - 1\n\n let pivotIndex, pivotValue, storeIndex\n\n function swap (a: number, b: number) {\n const tmp = arr[ a ]\n arr[ a ] = arr[ b ]\n arr[ b ] = tmp\n }\n\n while (true) {\n if (left === right) {\n return arr[ left ]\n }\n pivotIndex = (left + right) >> 1\n pivotValue = arr[ pivotIndex ]\n swap(pivotIndex, right)\n storeIndex = left\n for (let i = left; i < right; ++i) {\n if (cmp(arr[ i ], pivotValue) < 0) {\n swap(storeIndex, i)\n ++storeIndex\n }\n }\n swap(right, storeIndex)\n pivotIndex = storeIndex\n if (n === pivotIndex) {\n return arr[ n ]\n } else if (n < pivotIndex) {\n right = pivotIndex - 1\n } else {\n left = pivotIndex + 1\n }\n }\n}\n\nexport function arrayMax (array: NumberArray) {\n let max = -Infinity\n for (let i = 0, il = array.length; i < il; ++i) {\n if (array[ i ] > max) max = array[ i ]\n }\n return max\n}\n\nexport function arrayMin (array: NumberArray) {\n let min = Infinity\n for (let i = 0, il = array.length; i < il; ++i) {\n if (array[ i ] < min) min = array[ i ]\n }\n return min\n}\n\nexport function arraySum (array: NumberArray, stride = 1, offset = 0) {\n const n = array.length\n let sum = 0\n for (let i = offset; i < n; i += stride) {\n sum += array[ i ]\n }\n return sum\n}\n\nexport function arrayMean (array: NumberArray, stride = 1, offset = 0) {\n return arraySum(array, stride, offset) / (array.length / stride)\n}\n\nexport function arrayRms (array: NumberArray) {\n const n = array.length\n let sumSq = 0\n for (let i = 0; i < n; ++i) {\n const di = array[ i ]\n sumSq += di * di\n }\n return Math.sqrt(sumSq / n)\n}\n\nexport function arraySorted (array: NumberArray) {\n for (let i = 1, il = array.length; i < il; ++i) {\n if (array[ i - 1 ] > array[ i ]) return false\n }\n return true\n}\n\nexport function arraySortedCmp (array: NumberArray|T[], cmp: (a: number|T, b: number|T) => number) {\n for (let i = 1, il = array.length; i < il; ++i) {\n if (cmp(array[ i - 1 ], array[ i ]) > 0) return false\n }\n return true\n}\n","/**\n * @file Viewer Utils\n * @author Alexander Rose \n * @private\n */\n\nimport {\n Vector2, Vector3, Matrix4, Points, Scene, Camera,\n Object3D, WebGLRenderer\n} from 'three'\n\nimport { createParams } from '../utils'\nimport TiledRenderer from './tiled-renderer'\nimport { quicksortCmp } from '../math/array-utils'\nimport Viewer from './viewer'\n\nfunction _trimCanvas (canvas: HTMLCanvasElement, r: number, g: number, b: number, a: number) {\n const canvasHeight = canvas.height\n const canvasWidth = canvas.width\n\n const ctx = canvas.getContext('2d')!\n const pixels = ctx.getImageData(0, 0, canvasWidth, canvasHeight).data\n\n let x, y, doBreak, off\n\n doBreak = false\n for (y = 0; y < canvasHeight; y++) {\n for (x = 0; x < canvasWidth; x++) {\n off = (y * canvasWidth + x) * 4\n if (pixels[ off ] !== r || pixels[ off + 1 ] !== g ||\n pixels[ off + 2 ] !== b || pixels[ off + 3 ] !== a\n ) {\n doBreak = true\n break\n }\n }\n if (doBreak) {\n break\n }\n }\n const topY = y\n\n doBreak = false\n for (x = 0; x < canvasWidth; x++) {\n for (y = 0; y < canvasHeight; y++) {\n off = (y * canvasWidth + x) * 4\n if (pixels[ off ] !== r || pixels[ off + 1 ] !== g ||\n pixels[ off + 2 ] !== b || pixels[ off + 3 ] !== a\n ) {\n doBreak = true\n break\n }\n }\n if (doBreak) {\n break\n }\n }\n const topX = x\n\n doBreak = false\n for (y = canvasHeight - 1; y >= 0; y--) {\n for (x = canvasWidth - 1; x >= 0; x--) {\n off = (y * canvasWidth + x) * 4\n if (pixels[ off ] !== r || pixels[ off + 1 ] !== g ||\n pixels[ off + 2 ] !== b || pixels[ off + 3 ] !== a\n ) {\n doBreak = true\n break\n }\n }\n if (doBreak) {\n break\n }\n }\n const bottomY = y\n\n doBreak = false\n for (x = canvasWidth - 1; x >= 0; x--) {\n for (y = canvasHeight - 1; y >= 0; y--) {\n off = (y * canvasWidth + x) * 4\n if (pixels[ off ] !== r || pixels[ off + 1 ] !== g ||\n pixels[ off + 2 ] !== b || pixels[ off + 3 ] !== a\n ) {\n doBreak = true\n break\n }\n }\n if (doBreak) {\n break\n }\n }\n const bottomX = x\n\n const trimedCanvas = document.createElement('canvas')\n trimedCanvas.width = bottomX - topX\n trimedCanvas.height = bottomY - topY\n\n const trimedCtx = trimedCanvas.getContext('2d')!\n trimedCtx.drawImage(\n canvas,\n topX, topY,\n trimedCanvas.width, trimedCanvas.height,\n 0, 0,\n trimedCanvas.width, trimedCanvas.height\n )\n\n return trimedCanvas\n}\n\n/**\n * Image parameter object.\n * @typedef {Object} ImageParameters - image generation parameters\n * @property {Boolean} trim - trim the image\n * @property {Integer} factor - scaling factor to apply to the viewer canvas\n * @property {Boolean} antialias - antialias the image\n * @property {Boolean} transparent - transparent image background\n */\n\nexport const ImageDefaultParameters = {\n trim: false,\n factor: 1,\n antialias: false,\n transparent: false,\n onProgress: undefined as Function|undefined\n}\nexport type ImageParameters = typeof ImageDefaultParameters\n\n/**\n * Make image from what is shown in a viewer canvas\n * @param {Viewer} viewer - the viewer\n * @param {ImageParameters} params - parameters object\n * @return {Promise} A Promise object that resolves to an image {@link Blob}.\n */\nexport function makeImage (viewer: Viewer, params: Partial = {}) {\n const {trim, factor, antialias, transparent} = createParams(params, ImageDefaultParameters)\n\n const renderer = viewer.renderer\n const camera = viewer.camera\n\n const originalClearAlpha = renderer.getClearAlpha()\n const backgroundColor = renderer.getClearColor()\n\n function setLineWidthAndPixelSize (invert = false) {\n let _factor = factor\n if (antialias) _factor *= 2\n if (invert) _factor = 1 / _factor\n viewer.scene.traverse(function (o: any) { // TODO\n const m = o.material\n if (m && m.linewidth) {\n m.linewidth *= _factor\n }\n if (m && m.uniforms && m.uniforms.size) {\n if (m.uniforms.size.__seen === undefined) {\n m.uniforms.size.value *= _factor\n m.uniforms.size.__seen = true\n }\n }\n if (m && m.uniforms && m.uniforms.linewidth) {\n if (m.uniforms.linewidth.__seen === undefined) {\n m.uniforms.linewidth.value *= _factor\n m.uniforms.linewidth.__seen = true\n }\n }\n })\n viewer.scene.traverse(function (o: any) { // TODO\n const m = o.material\n if (m && m.uniforms && m.uniforms.size) {\n delete m.uniforms.size.__seen\n }\n if (m && m.uniforms && m.uniforms.linewidth) {\n delete m.uniforms.linewidth.__seen\n }\n })\n }\n\n function trimCanvas (canvas: HTMLCanvasElement) {\n if (trim) {\n const bg = backgroundColor\n const r = transparent ? 0 : bg.r * 255\n const g = transparent ? 0 : bg.g * 255\n const b = transparent ? 0 : bg.b * 255\n const a = transparent ? 0 : 255\n return _trimCanvas(canvas, r, g, b, a)\n } else {\n return canvas\n }\n }\n\n function onProgress (i: number, n: number, finished: boolean) {\n if (typeof params.onProgress === 'function') {\n params.onProgress(i, n, finished)\n }\n }\n\n return new Promise(function (resolve, reject) {\n const tiledRenderer = new TiledRenderer(\n renderer, camera, viewer,\n { factor, antialias, onProgress, onFinish }\n )\n\n renderer.setClearAlpha(transparent ? 0 : 1)\n setLineWidthAndPixelSize()\n tiledRenderer.renderAsync()\n\n function onFinish (i: number, n: number) {\n const canvas = trimCanvas(tiledRenderer.canvas)\n canvas.toBlob(\n function (blob) {\n renderer.setClearAlpha(originalClearAlpha)\n setLineWidthAndPixelSize(true)\n viewer.requestRender()\n onProgress(n, n, true)\n if (blob) {\n resolve(blob)\n } else {\n reject('error creating image')\n }\n },\n 'image/png'\n )\n }\n })\n}\n\nconst vertex = new Vector3()\nconst matrix = new Matrix4()\nconst modelViewProjectionMatrix = new Matrix4()\n\nexport function sortProjectedPosition (scene: Scene, camera: Camera) {\n // console.time( \"sort\" );\n\n scene.traverseVisible(function (o) {\n if (!(o instanceof Points) || !o.userData.buffer.parameters.sortParticles) {\n return\n }\n\n const attributes = (o.geometry as any).attributes // TODO\n const n = attributes.position.count\n\n if (n === 0) return\n\n matrix.multiplyMatrices(\n camera.matrixWorldInverse, o.matrixWorld\n )\n modelViewProjectionMatrix.multiplyMatrices(\n camera.projectionMatrix, matrix\n )\n\n let sortData, sortArray, zArray: Float32Array, cmpFn\n\n if (!o.userData.sortData) {\n zArray = new Float32Array(n)\n sortArray = new Uint32Array(n)\n cmpFn = function (ai: number, bi: number) {\n const a = zArray[ ai ]\n const b = zArray[ bi ]\n if (a > b) return 1\n if (a < b) return -1\n return 0\n }\n\n sortData = {\n __zArray: zArray,\n __sortArray: sortArray,\n __cmpFn: cmpFn\n }\n\n o.userData.sortData = sortData\n } else {\n sortData = o.userData.sortData\n zArray = sortData.__zArray\n sortArray = sortData.__sortArray\n cmpFn = sortData.__cmpFn\n }\n\n for (let i = 0; i < n; ++i) {\n vertex.fromArray(attributes.position.array, i * 3)\n vertex.applyMatrix4(modelViewProjectionMatrix)\n\n // negate, so that sorting order is reversed\n zArray[ i ] = -vertex.z\n sortArray[ i ] = i\n }\n\n quicksortCmp(sortArray, cmpFn)\n\n let index, indexSrc, indexDst, tmpTab\n\n for (let name in attributes) {\n const attr = attributes[ name ]\n const array = attr.array\n const itemSize = attr.itemSize\n\n if (!sortData[ name ]) {\n sortData[ name ] = new Float32Array(itemSize * n)\n }\n\n tmpTab = sortData[ name ]\n sortData[ name ] = array\n\n for (let i = 0; i < n; ++i) {\n index = sortArray[ i ]\n\n for (let j = 0; j < itemSize; ++j) {\n indexSrc = index * itemSize + j\n indexDst = i * itemSize + j\n tmpTab[ indexDst ] = array[ indexSrc ]\n }\n }\n\n attributes[ name ].array = tmpTab\n attributes[ name ].needsUpdate = true\n }\n })\n\n // console.timeEnd( \"sort\" );\n}\n\nconst resolution = new Vector2()\nconst projectionMatrixInverse = new Matrix4()\nconst projectionMatrixTranspose = new Matrix4()\n\nexport function updateMaterialUniforms (group: Object3D, camera: Camera, renderer: WebGLRenderer, cDist: number, bRadius: number) {\n let size = new Vector2()\n renderer.getSize(size)\n const canvasHeight = size.height\n const pixelRatio = renderer.getPixelRatio()\n const ortho = camera.type === 'OrthographicCamera'\n\n resolution.set(size.width, size.height)\n projectionMatrixInverse.getInverse(camera.projectionMatrix)\n projectionMatrixTranspose.copy(camera.projectionMatrix).transpose()\n\n group.traverse(function (o: any) {\n const m = o.material\n if (!m) return\n\n const u = m.uniforms\n if (!u) return\n\n if (m.clipNear) {\n const nearFactor = (50 - m.clipNear) / 50\n const nearClip = cDist - (bRadius * nearFactor)\n u.clipNear.value = nearClip\n }\n\n if (u.canvasHeight) {\n u.canvasHeight.value = canvasHeight\n }\n\n if (u.resolution) {\n u.resolution.value.copy(resolution)\n }\n\n if (u.pixelRatio) {\n u.pixelRatio.value = pixelRatio\n }\n\n if (u.projectionMatrixInverse) {\n u.projectionMatrixInverse.value.copy(projectionMatrixInverse)\n }\n\n if (u.projectionMatrixTranspose) {\n u.projectionMatrixTranspose.value.copy(projectionMatrixTranspose)\n }\n\n if (u.ortho) {\n u.ortho.value = ortho\n }\n })\n}\n\nexport function updateCameraUniforms (group: Object3D, camera: Camera) {\n projectionMatrixInverse.getInverse(camera.projectionMatrix)\n projectionMatrixTranspose.copy(camera.projectionMatrix).transpose()\n\n group.traverse(function (o: any) {\n const m = o.material\n if (!m) return\n\n const u = m.uniforms\n if (!u) return\n\n if (u.projectionMatrixInverse) {\n u.projectionMatrixInverse.value.copy(projectionMatrixInverse)\n }\n\n if (u.projectionMatrixTranspose) {\n u.projectionMatrixTranspose.value.copy(projectionMatrixTranspose)\n }\n })\n}\n","/**\n * @file Viewer\n * @author Alexander Rose \n * @private\n */\n\n// adapted from https://webglfundamentals.org/webgl/resources/webgl-utils.js\n// Copyright 2012, Gregg Tavares. Modified BSD License\n\nexport function createProgram(gl: WebGLRenderingContext, shaders: WebGLShader[], attribs?: string[], locations?: number[]) {\n const program = gl.createProgram()\n if (!program) {\n console.log(`error creating WebGL program`)\n return\n }\n shaders.forEach(shader => gl.attachShader(program, shader))\n if (attribs) {\n attribs.forEach((attrib, i) => {\n gl.bindAttribLocation(program, locations ? locations[i] : i, attrib)\n })\n }\n gl.linkProgram(program);\n\n // Check the link status\n const linked = gl.getProgramParameter(program, gl.LINK_STATUS)\n if (!linked) {\n console.log(`error linking program: ${gl.getProgramInfoLog(program)}`)\n gl.deleteProgram(program)\n return null\n }\n return program\n}\n\nexport function loadShader(gl: WebGLRenderingContext, shaderSource: string, shaderType: number) {\n const shader = gl.createShader(shaderType)\n if (!shader) {\n console.log(`error creating WebGL shader ${shaderType}`)\n return // can't create shader\n }\n gl.shaderSource(shader, shaderSource)\n gl.compileShader(shader)\n\n // Check the compile status\n const compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS)\n if (!compiled) {\n console.log(`error compiling shader ${shader}: ${gl.getShaderInfoLog(shader)}`)\n gl.deleteShader(shader)\n return null\n }\n\n return shader\n}\n\n//\n\nexport function getErrorDescription(gl: WebGLRenderingContext, error: number) {\n switch (error) {\n case gl.NO_ERROR: return 'no error'\n case gl.INVALID_ENUM: return 'invalid enum'\n case gl.INVALID_VALUE: return 'invalid value'\n case gl.INVALID_OPERATION: return 'invalid operation'\n case gl.INVALID_FRAMEBUFFER_OPERATION: return 'invalid framebuffer operation'\n case gl.OUT_OF_MEMORY: return 'out of memory'\n case gl.CONTEXT_LOST_WEBGL: return 'context lost'\n }\n return 'unknown error'\n}\n\nexport function getExtension (gl: WebGLRenderingContext, name: string) {\n const ext = gl.getExtension(name)\n if (!ext) console.log(`extension '${name}' not available`)\n return ext\n}\n\nconst TextureTestVertShader = `\nattribute vec4 a_position;\n\nvoid main() {\n gl_Position = a_position;\n}`\n\nconst TextureTestFragShader = `\nprecision mediump float;\nuniform vec4 u_color;\nuniform sampler2D u_texture;\n\nvoid main() {\n gl_FragColor = texture2D(u_texture, vec2(0.5, 0.5)) * u_color;\n}`\n\nconst TextureTestTexCoords = new Float32Array([\n -1.0, -1.0, 1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0\n])\n\nexport function testTextureSupport (type: number) {\n // adapted from\n // https://stackoverflow.com/questions/28827511/webgl-ios-render-to-floating-point-texture\n\n // Get A WebGL context\n const canvas = document.createElement('canvas')\n canvas.width = 16\n canvas.height = 16\n canvas.style.width = 16 + 'px'\n canvas.style.height = 16 + 'px'\n const gl = canvas.getContext(\"webgl\") || canvas.getContext(\"experimental-webgl\");\n if (!gl) {\n console.log(`error creating webgl context for ${type}`)\n return false\n }\n if (!(gl instanceof WebGLRenderingContext)) {\n console.log(`Got unexpected type for WebGL rendering context`)\n return false\n }\n\n getExtension(gl, 'OES_texture_float')\n getExtension(gl, 'OES_texture_half_float')\n getExtension(gl, 'WEBGL_color_buffer_float')\n\n // setup shaders\n const vertShader = loadShader(gl, TextureTestVertShader, gl.VERTEX_SHADER)\n const fragShader = loadShader(gl, TextureTestFragShader, gl.FRAGMENT_SHADER)\n if (!vertShader || !fragShader) return false\n\n // setup program\n const program = createProgram(gl, [ vertShader, fragShader ])\n if (!program) {\n console.log(`error creating WebGL program`)\n return false\n }\n gl.useProgram(program);\n\n // look up where the vertex data needs to go.\n const positionLocation = gl.getAttribLocation(program, \"a_position\");\n const colorLoc = gl.getUniformLocation(program, \"u_color\");\n if (!colorLoc) {\n console.log(`error getting 'u_color' uniform location`)\n return false\n }\n\n // provide texture coordinates for the rectangle.\n const positionBuffer = gl.createBuffer()\n gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer)\n gl.bufferData(gl.ARRAY_BUFFER, TextureTestTexCoords, gl.STATIC_DRAW)\n gl.enableVertexAttribArray(positionLocation)\n gl.vertexAttribPointer(positionLocation, 2, gl.FLOAT, false, 0, 0)\n\n const whiteTex = gl.createTexture()\n const whiteData = new Uint8Array([255, 255, 255, 255])\n gl.bindTexture(gl.TEXTURE_2D, whiteTex)\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, whiteData)\n\n const tex = gl.createTexture()\n gl.bindTexture(gl.TEXTURE_2D, tex)\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, type, null)\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST)\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST)\n\n const fb = gl.createFramebuffer()\n gl.bindFramebuffer(gl.FRAMEBUFFER, fb)\n gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, tex, 0)\n const status = gl.checkFramebufferStatus(gl.FRAMEBUFFER)\n if (status !== gl.FRAMEBUFFER_COMPLETE) {\n console.log(`error creating framebuffer for ${type}`)\n return false\n }\n\n // Draw the rectangle.\n gl.bindTexture(gl.TEXTURE_2D, whiteTex)\n gl.uniform4fv(colorLoc, [0, 10, 20, 1])\n gl.drawArrays(gl.TRIANGLES, 0, 6)\n\n gl.bindTexture(gl.TEXTURE_2D, tex)\n gl.bindFramebuffer(gl.FRAMEBUFFER, null)\n gl.clearColor(1, 0, 0, 1)\n gl.clear(gl.COLOR_BUFFER_BIT)\n gl.uniform4fv(colorLoc, [0, 1/10, 1/20, 1])\n gl.drawArrays(gl.TRIANGLES, 0, 6)\n\n // Check if rendered correctly\n const pixel = new Uint8Array(4)\n gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, pixel)\n if (pixel[0] !== 0 || pixel[1] < 248 || pixel[2] < 248 || pixel[3] < 254) {\n console.log(`not able to actually render to ${type} texture`)\n return false\n }\n\n // Check reading from float texture\n if (type === gl.FLOAT) {\n gl.bindFramebuffer(gl.FRAMEBUFFER, fb)\n const floatPixel = new Float32Array(4)\n gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.FLOAT, floatPixel)\n const error = gl.getError()\n if (error) {\n console.log(`error reading pixels as float: '${getErrorDescription(gl, error)}'`)\n return false\n }\n }\n\n return true\n}\n","/**\n * @file Viewer\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\nimport {\n PerspectiveCamera, OrthographicCamera, StereoCamera,\n Vector2, Box3, Vector3, Matrix4, Color,\n WebGLRenderer, WebGLRenderTarget,\n NearestFilter, LinearFilter, AdditiveBlending,\n RGBAFormat, FloatType, /*HalfFloatType, */UnsignedByteType,\n ShaderMaterial,\n PlaneGeometry, Geometry,\n Scene, Mesh, Group, Object3D, Uniform,\n Fog, SpotLight, AmbientLight,\n BufferGeometry, BufferAttribute,\n LineSegments,\n LinearEncoding, sRGBEncoding, TextureEncoding\n} from 'three'\nimport '../shader/BasicLine.vert'\nimport '../shader/BasicLine.frag'\nimport '../shader/Quad.vert'\nimport '../shader/Quad.frag'\n\nimport {\n Debug, Log, WebglErrorMessage, Browser,\n setExtensionFragDepth, SupportsReadPixelsFloat, setSupportsReadPixelsFloat\n} from '../globals'\nimport { degToRad } from '../math/math-utils'\nimport Stats from './stats'\nimport { getShader } from '../shader/shader-utils'\nimport { setColorSpace } from '../color/colormaker'\nimport { JitterVectors } from './viewer-constants'\nimport {\n makeImage, ImageParameters,\n sortProjectedPosition, updateMaterialUniforms, updateCameraUniforms\n} from './viewer-utils'\nimport { testTextureSupport } from './gl-utils'\n\nimport Buffer from '../buffer/buffer'\n\nconst pixelBufferFloat = new Float32Array(4 * 25)\nconst pixelBufferUint = new Uint8Array(4 * 25)\n\n// When picking, we read a 25 pixel (5x5) array (readRenderTargetPixels)\n// We read the pixels in the order below to find what was picked.\n// This starts at the center and tries successively further points.\n// (Many points will be at equal distance to the center, their order\n// is arbitrary).\nconst pixelOrder = [12,7,13,17,11,6,8,18,16,2,14,22,10,1,3,9,19,23,21,15,5,0,4,24,20]\n\n\nconst tmpMatrix = new Matrix4()\n\nfunction onBeforeRender (this: Object3D, renderer: WebGLRenderer, scene: Scene, camera: PerspectiveCamera|OrthographicCamera, geometry: Geometry, material: ShaderMaterial/*, group */) {\n const u = material.uniforms\n const updateList = []\n\n if (!u) return // See #908 - some materials may not have uniforms, ignore these\n\n if (u.objectId) {\n u.objectId.value = SupportsReadPixelsFloat ? this.id : this.id / 255\n updateList.push('objectId')\n }\n\n if (u.modelViewMatrixInverse || u.modelViewMatrixInverseTranspose ||\n u.modelViewProjectionMatrix || u.modelViewProjectionMatrixInverse\n ) {\n this.modelViewMatrix.multiplyMatrices(camera.matrixWorldInverse, this.matrixWorld)\n }\n\n if (u.modelViewMatrixInverse) {\n u.modelViewMatrixInverse.value.getInverse(this.modelViewMatrix)\n updateList.push('modelViewMatrixInverse')\n }\n\n if (u.modelViewMatrixInverseTranspose) {\n if (u.modelViewMatrixInverse) {\n u.modelViewMatrixInverseTranspose.value.copy(\n u.modelViewMatrixInverse.value\n ).transpose()\n } else {\n u.modelViewMatrixInverseTranspose.value\n .getInverse(this.modelViewMatrix)\n .transpose()\n }\n updateList.push('modelViewMatrixInverseTranspose')\n }\n\n if (u.modelViewProjectionMatrix) {\n u.modelViewProjectionMatrix.value.multiplyMatrices(\n camera.projectionMatrix, this.modelViewMatrix\n )\n updateList.push('modelViewProjectionMatrix')\n }\n\n if (u.modelViewProjectionMatrixInverse) {\n if (u.modelViewProjectionMatrix) {\n tmpMatrix.copy(\n u.modelViewProjectionMatrix.value\n )\n u.modelViewProjectionMatrixInverse.value.getInverse(\n tmpMatrix\n )\n } else {\n tmpMatrix.multiplyMatrices(\n camera.projectionMatrix, this.modelViewMatrix\n )\n u.modelViewProjectionMatrixInverse.value.getInverse(\n tmpMatrix\n )\n }\n updateList.push('modelViewProjectionMatrixInverse')\n }\n\n if (updateList.length) {\n const materialProperties = renderer.properties.get(material)\n\n if (materialProperties.program) {\n const gl = renderer.getContext()\n const p = materialProperties.program\n gl.useProgram(p.program)\n const pu = p.getUniforms()\n\n updateList.forEach(function (name) {\n pu.setValue(gl, name, u[ name ].value)\n })\n }\n }\n}\n\nexport type CameraType = 'perspective'|'orthographic'|'stereo'\nexport type ColorWorkflow = 'linear' | 'sRGB'\n\nexport interface ViewerSignals {\n ticked: Signal,\n rendered: Signal\n}\n\nexport interface ViewerParameters {\n fogColor: Color\n fogNear: number\n fogFar: number\n\n backgroundColor: Color\n\n cameraType: CameraType\n cameraFov: number\n cameraEyeSep: number\n cameraZ: number\n\n clipNear: number\n clipFar: number\n clipDist: number\n clipMode: string // \"scene\" or \"camera\"\n clipScale: string // \"relative\" or \"absolute\"\n\n lightColor: Color\n lightIntensity: number\n ambientColor: Color\n ambientIntensity: number\n\n sampleLevel: number\n\n rendererEncoding: TextureEncoding // default is three.LinearEncoding; three.sRGBEncoding gives more correct results\n}\n\nexport interface BufferInstance {\n matrix: Matrix4\n}\n\n/**\n * Viewer class\n * @class\n * @param {String|Element} [idOrElement] - dom id or element\n */\nexport default class Viewer {\n signals: ViewerSignals\n\n container: HTMLElement\n wrapper: HTMLElement\n\n private rendering: boolean\n private renderPending: boolean\n private lastRenderedPicking: boolean\n private isStill: boolean\n private frameRequest: number\n\n sampleLevel: number\n private cDist: number\n private bRadius: number\n\n private parameters: ViewerParameters\n stats: Stats\n\n perspectiveCamera: PerspectiveCamera\n private orthographicCamera: OrthographicCamera\n private stereoCamera: StereoCamera\n camera: PerspectiveCamera|OrthographicCamera\n\n width: number\n height: number\n\n scene: Scene\n private spotLight: SpotLight\n private ambientLight: AmbientLight\n rotationGroup: Group\n translationGroup: Group\n private modelGroup: Group\n private pickingGroup: Group\n private backgroundGroup: Group\n private helperGroup: Group\n\n renderer: WebGLRenderer\n private supportsHalfFloat: boolean\n\n private pickingTarget: WebGLRenderTarget\n private sampleTarget: WebGLRenderTarget\n private holdTarget: WebGLRenderTarget\n\n private compositeUniforms: {\n tForeground: Uniform\n scale: Uniform\n }\n private compositeMaterial: ShaderMaterial\n private compositeCamera: OrthographicCamera\n private compositeScene: Scene\n\n private boundingBoxMesh: LineSegments\n boundingBox = new Box3()\n private boundingBoxSize = new Vector3()\n private boundingBoxLength = 0\n\n private info = {\n memory: {\n programs: 0,\n geometries: 0,\n textures: 0\n },\n render: {\n calls: 0,\n vertices: 0,\n faces: 0,\n points: 0\n }\n }\n\n private distVector = new Vector3()\n\n constructor (idOrElement: string|HTMLElement) {\n this.signals = {\n ticked: new Signal(),\n rendered: new Signal()\n }\n\n if (typeof idOrElement === 'string') {\n const elm = document.getElementById(idOrElement)\n if (elm === null) {\n this.container = document.createElement('div')\n }else {\n this.container = elm\n }\n } else if (idOrElement instanceof HTMLElement) {\n this.container = idOrElement\n } else {\n this.container = document.createElement('div')\n }\n\n if (this.container === document.body) {\n this.width = window.innerWidth || 1\n this.height = window.innerHeight || 1\n } else {\n const box = this.container.getBoundingClientRect()\n this.width = box.width || 1\n this.height = box.height || 1\n this.container.style.overflow = 'hidden'\n }\n\n this.wrapper = document.createElement('div')\n this.wrapper.style.position = 'relative'\n this.container.appendChild(this.wrapper)\n\n this._initParams()\n this._initStats()\n this._initCamera()\n this._initScene()\n\n if (this._initRenderer() === false) {\n Log.error('Viewer: could not initialize renderer')\n return\n }\n\n this._initHelper()\n\n // fog & background\n this.setBackground()\n this.setFog()\n\n this.animate = this.animate.bind(this)\n }\n\n private _initParams () {\n this.parameters = {\n fogColor: new Color(0x000000),\n fogNear: 50,\n fogFar: 100,\n\n backgroundColor: new Color(0x000000),\n\n cameraType: 'perspective',\n cameraFov: 40,\n cameraEyeSep: 0.3,\n cameraZ: -80, // FIXME initial value should be automatically determined\n\n clipNear: 0,\n clipFar: 100,\n clipDist: 10,\n clipMode: 'scene',\n clipScale: 'relative',\n\n lightColor: new Color(0xdddddd),\n lightIntensity: 1.0,\n ambientColor: new Color(0xdddddd),\n ambientIntensity: 0.2,\n\n sampleLevel: 0,\n\n // output encoding: use sRGB for a linear internal workflow, linear for traditional sRGB workflow.\n rendererEncoding: LinearEncoding,\n }\n }\n\n private _initCamera () {\n const lookAt = new Vector3(0, 0, 0)\n const {width, height} = this\n\n this.perspectiveCamera = new PerspectiveCamera(\n this.parameters.cameraFov, width / height\n )\n this.perspectiveCamera.position.z = this.parameters.cameraZ\n this.perspectiveCamera.lookAt(lookAt)\n\n this.orthographicCamera = new OrthographicCamera(\n width / -2, width / 2, height / 2, height / -2\n )\n this.orthographicCamera.position.z = this.parameters.cameraZ\n this.orthographicCamera.lookAt(lookAt)\n\n this.stereoCamera = new StereoCamera()\n this.stereoCamera.aspect = 0.5\n this.stereoCamera.eyeSep = this.parameters.cameraEyeSep\n\n const cameraType = this.parameters.cameraType\n if (cameraType === 'orthographic') {\n this.camera = this.orthographicCamera\n } else if(cameraType === 'perspective' || cameraType === 'stereo') {\n this.camera = this.perspectiveCamera\n } else {\n throw new Error(`Unknown cameraType '${cameraType}'`)\n }\n this.camera.updateProjectionMatrix()\n }\n\n private _initStats () {\n this.stats = new Stats()\n }\n\n private _initScene () {\n if (!this.scene) {\n this.scene = new Scene()\n this.scene.name = 'scene'\n }\n\n this.rotationGroup = new Group()\n this.rotationGroup.name = 'rotationGroup'\n this.scene.add(this.rotationGroup)\n\n this.translationGroup = new Group()\n this.translationGroup.name = 'translationGroup'\n this.rotationGroup.add(this.translationGroup)\n\n this.modelGroup = new Group()\n this.modelGroup.name = 'modelGroup'\n this.translationGroup.add(this.modelGroup)\n\n this.pickingGroup = new Group()\n this.pickingGroup.name = 'pickingGroup'\n this.translationGroup.add(this.pickingGroup)\n\n this.backgroundGroup = new Group()\n this.backgroundGroup.name = 'backgroundGroup'\n this.translationGroup.add(this.backgroundGroup)\n\n this.helperGroup = new Group()\n this.helperGroup.name = 'helperGroup'\n this.translationGroup.add(this.helperGroup)\n\n // fog\n\n this.scene.fog = new Fog(this.parameters.fogColor.getHex())\n\n // light\n\n this.spotLight = new SpotLight(\n this.parameters.lightColor.getHex(), this.parameters.lightIntensity\n )\n this.scene.add(this.spotLight)\n\n this.ambientLight = new AmbientLight(\n this.parameters.ambientColor.getHex(), this.parameters.ambientIntensity\n )\n this.scene.add(this.ambientLight)\n }\n\n private _initRenderer () {\n const dpr = window.devicePixelRatio\n const {width, height} = this\n\n try {\n this.renderer = new WebGLRenderer({\n preserveDrawingBuffer: true,\n alpha: true,\n antialias: true\n })\n } catch (e) {\n this.wrapper.innerHTML = WebglErrorMessage\n return false\n }\n this.renderer.setPixelRatio(dpr)\n this.renderer.setSize(width, height)\n this.renderer.autoClear = false\n this.renderer.sortObjects = true\n this.renderer.outputEncoding = this.parameters.rendererEncoding\n\n const gl = this.renderer.getContext()\n // console.log(gl.getContextAttributes().antialias)\n // console.log(gl.getParameter(gl.SAMPLES))\n\n // For WebGL1, extensions must be explicitly enabled.\n // The following are builtin to WebGL2 (and don't appear as\n // extensions)\n // EXT_frag_depth, OES_element_index_uint, OES_texture_float\n // OES_texture_half_float\n\n // The WEBGL_color_buffer_float extension is replaced by\n // EXT_color_buffer_float\n\n // If not webgl2 context, explicitly check for these\n if (!this.renderer.capabilities.isWebGL2) {\n setExtensionFragDepth(this.renderer.extensions.get('EXT_frag_depth'))\n this.renderer.extensions.get('OES_element_index_uint')\n\n setSupportsReadPixelsFloat(\n (this.renderer.extensions.get('OES_texture_float') &&\n this.renderer.extensions.get('WEBGL_color_buffer_float')) ||\n (this.renderer.extensions.get('OES_texture_float') &&\n testTextureSupport(gl.FLOAT))\n )\n // picking texture\n\n this.renderer.extensions.get('OES_texture_float')\n\n this.supportsHalfFloat = (\n this.renderer.extensions.get('OES_texture_half_float') &&\n testTextureSupport(0x8D61)\n )\n\n } else {\n setExtensionFragDepth(true)\n setSupportsReadPixelsFloat(\n this.renderer.extensions.get('EXT_color_buffer_float')\n )\n this.supportsHalfFloat = true\n }\n\n this.wrapper.appendChild(this.renderer.domElement)\n\n const dprWidth = width * dpr\n const dprHeight = height * dpr\n\n\n if (Debug) {\n console.log(JSON.stringify({\n 'Browser': Browser,\n 'OES_texture_float': !!this.renderer.extensions.get('OES_texture_float'),\n 'OES_texture_half_float': !!this.renderer.extensions.get('OES_texture_half_float'),\n 'WEBGL_color_buffer_float': !!this.renderer.extensions.get('WEBGL_color_buffer_float'),\n 'testTextureSupport Float': testTextureSupport(gl.FLOAT),\n 'testTextureSupport HalfFloat': testTextureSupport(0x8D61),\n 'this.supportsHalfFloat': this.supportsHalfFloat,\n 'SupportsReadPixelsFloat': SupportsReadPixelsFloat\n }, null, 2))\n }\n\n this.pickingTarget = new WebGLRenderTarget(\n dprWidth, dprHeight,\n {\n minFilter: NearestFilter,\n magFilter: NearestFilter,\n stencilBuffer: false,\n format: RGBAFormat,\n type: SupportsReadPixelsFloat ? FloatType : UnsignedByteType\n }\n )\n this.pickingTarget.texture.generateMipmaps = false\n this.pickingTarget.texture.encoding = this.parameters.rendererEncoding\n\n // workaround to reset the gl state after using testTextureSupport\n // fixes some bug where nothing is rendered to the canvas\n // when animations are started on page load\n this.renderer.setRenderTarget(this.pickingTarget)\n this.renderer.clear()\n this.renderer.setRenderTarget(null!)\n\n // ssaa textures\n\n this.sampleTarget = new WebGLRenderTarget(\n dprWidth, dprHeight,\n {\n minFilter: LinearFilter,\n magFilter: LinearFilter,\n format: RGBAFormat\n }\n )\n this.sampleTarget.texture.encoding = this.parameters.rendererEncoding\n\n this.holdTarget = new WebGLRenderTarget(\n dprWidth, dprHeight,\n {\n minFilter: NearestFilter,\n magFilter: NearestFilter,\n format: RGBAFormat,\n type: UnsignedByteType\n // using HalfFloatType or FloatType does not work on some Chrome 61 installations\n // type: this.supportsHalfFloat ? HalfFloatType : (\n // SupportsReadPixelsFloat ? FloatType : UnsignedByteType\n // )\n }\n )\n this.holdTarget.texture.encoding = this.parameters.rendererEncoding\n\n this.compositeUniforms = {\n 'tForeground': new Uniform(this.sampleTarget.texture),\n 'scale': new Uniform(1.0)\n }\n\n this.compositeMaterial = new ShaderMaterial({\n uniforms: this.compositeUniforms,\n vertexShader: getShader('Quad.vert'),\n fragmentShader: getShader('Quad.frag'),\n premultipliedAlpha: true,\n transparent: true,\n blending: AdditiveBlending,\n depthTest: false,\n depthWrite: false\n })\n\n this.compositeCamera = new OrthographicCamera(-1, 1, 1, -1, 0, 1)\n this.compositeScene = new Scene()\n this.compositeScene.name = 'compositeScene'\n this.compositeScene.add(new Mesh(\n new PlaneGeometry(2, 2), this.compositeMaterial\n ))\n }\n\n private _initHelper () {\n const indices = new Uint16Array([\n 0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6,\n 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7\n ])\n const positions = new Float32Array(8 * 3)\n\n const bbGeometry = new BufferGeometry()\n bbGeometry.setIndex(new BufferAttribute(indices, 1))\n bbGeometry.setAttribute('position', new BufferAttribute(positions, 3))\n const bbMaterial = new ShaderMaterial({\n uniforms: { 'uColor': { value: new Color('skyblue') } },\n vertexShader: getShader('BasicLine.vert'),\n fragmentShader: getShader('BasicLine.frag')\n })\n\n this.boundingBoxMesh = new LineSegments(bbGeometry, bbMaterial)\n this.helperGroup.add(this.boundingBoxMesh)\n }\n\n updateHelper () {\n const position = ((this.boundingBoxMesh.geometry as BufferGeometry).attributes as any).position // TODO\n const array = position.array\n const {min, max} = this.boundingBox\n\n array[ 0 ] = max.x; array[ 1 ] = max.y; array[ 2 ] = max.z\n array[ 3 ] = min.x; array[ 4 ] = max.y; array[ 5 ] = max.z\n array[ 6 ] = min.x; array[ 7 ] = min.y; array[ 8 ] = max.z\n array[ 9 ] = max.x; array[ 10 ] = min.y; array[ 11 ] = max.z\n array[ 12 ] = max.x; array[ 13 ] = max.y; array[ 14 ] = min.z\n array[ 15 ] = min.x; array[ 16 ] = max.y; array[ 17 ] = min.z\n array[ 18 ] = min.x; array[ 19 ] = min.y; array[ 20 ] = min.z\n array[ 21 ] = max.x; array[ 22 ] = min.y; array[ 23 ] = min.z\n\n position.needsUpdate = true\n\n if (!this.boundingBox.isEmpty()) {\n this.boundingBoxMesh.geometry.computeBoundingSphere()\n }\n }\n\n /** Distance from origin (lookAt point) */\n get cameraDistance(): number {\n return Math.abs(this.camera.position.z)\n }\n\n /** Set distance from origin (lookAt point); along the -z axis */\n set cameraDistance(d: number) {\n this.camera.position.z = -d\n }\n\n add (buffer: Buffer, instanceList?: BufferInstance[]) {\n // Log.time( \"Viewer.add\" );\n\n if (instanceList) {\n instanceList.forEach(instance => this.addBuffer(buffer, instance))\n } else {\n this.addBuffer(buffer)\n }\n\n buffer.group.name = 'meshGroup'\n buffer.wireframeGroup.name = 'wireframeGroup'\n if (buffer.parameters.background) {\n this.backgroundGroup.add(buffer.group)\n this.backgroundGroup.add(buffer.wireframeGroup)\n } else {\n this.modelGroup.add(buffer.group)\n this.modelGroup.add(buffer.wireframeGroup)\n }\n\n if (buffer.pickable) {\n this.pickingGroup.add(buffer.pickingGroup)\n }\n\n if (Debug) this.updateHelper()\n\n // Log.timeEnd( \"Viewer.add\" );\n }\n\n addBuffer (buffer: Buffer, instance?: BufferInstance) {\n // Log.time( \"Viewer.addBuffer\" );\n\n function setUserData (object: Object3D) {\n if (object instanceof Group) {\n object.children.forEach(setUserData)\n } else {\n object.userData.buffer = buffer\n object.userData.instance = instance\n object.onBeforeRender = onBeforeRender\n }\n }\n\n const mesh = buffer.getMesh()\n if (instance) {\n mesh.applyMatrix4(instance.matrix)\n }\n setUserData(mesh)\n buffer.group.add(mesh)\n\n const wireframeMesh = buffer.getWireframeMesh()\n if (instance) {\n // wireframeMesh.applyMatrix( instance.matrix );\n wireframeMesh.matrix.copy(mesh.matrix)\n wireframeMesh.position.copy(mesh.position)\n wireframeMesh.quaternion.copy(mesh.quaternion)\n wireframeMesh.scale.copy(mesh.scale)\n }\n setUserData(wireframeMesh)\n buffer.wireframeGroup.add(wireframeMesh)\n\n if (buffer.pickable) {\n const pickingMesh = buffer.getPickingMesh()\n if (instance) {\n // pickingMesh.applyMatrix( instance.matrix );\n pickingMesh.matrix.copy(mesh.matrix)\n pickingMesh.position.copy(mesh.position)\n pickingMesh.quaternion.copy(mesh.quaternion)\n pickingMesh.scale.copy(mesh.scale)\n }\n setUserData(pickingMesh)\n buffer.pickingGroup.add(pickingMesh)\n }\n\n if (instance) {\n this._updateBoundingBox(buffer.geometry, buffer.matrix, instance.matrix)\n } else {\n this._updateBoundingBox(buffer.geometry, buffer.matrix)\n }\n\n // Log.timeEnd( \"Viewer.addBuffer\" );\n }\n\n remove (buffer: Buffer) {\n this.translationGroup.children.forEach(function (group) {\n group.remove(buffer.group)\n group.remove(buffer.wireframeGroup)\n })\n\n if (buffer.pickable) {\n this.pickingGroup.remove(buffer.pickingGroup)\n }\n\n this.updateBoundingBox()\n if (Debug) this.updateHelper()\n\n // this.requestRender();\n }\n\n private _updateBoundingBox (geometry?: BufferGeometry, matrix?: Matrix4, instanceMatrix?: Matrix4) {\n const boundingBox = this.boundingBox\n\n function updateGeometry (geometry: BufferGeometry, matrix?: Matrix4, instanceMatrix?: Matrix4) {\n if (geometry.boundingBox == null) {\n geometry.computeBoundingBox()\n }\n\n const geoBoundingBox = (geometry.boundingBox as Box3).clone()\n\n if (matrix) {\n geoBoundingBox.applyMatrix4(matrix)\n }\n if (instanceMatrix) {\n geoBoundingBox.applyMatrix4(instanceMatrix)\n }\n\n if (geoBoundingBox.min.equals(geoBoundingBox.max)) {\n // mainly to give a single impostor geometry some volume\n // as it is only expanded in the shader on the GPU\n geoBoundingBox.expandByScalar(5)\n }\n\n boundingBox.union(geoBoundingBox)\n }\n\n function updateNode (node: Mesh) {\n if (node.geometry !== undefined) {\n let matrix, instanceMatrix\n if (node.userData.buffer) {\n matrix = node.userData.buffer.matrix\n }\n if (node.userData.instance) {\n instanceMatrix = node.userData.instance.matrix\n }\n updateGeometry(node.geometry as BufferGeometry, matrix, instanceMatrix) // TODO\n }\n }\n\n if (geometry) {\n updateGeometry(geometry, matrix, instanceMatrix)\n } else {\n boundingBox.makeEmpty()\n this.modelGroup.traverse(updateNode)\n this.backgroundGroup.traverse(updateNode)\n }\n\n boundingBox.getSize(this.boundingBoxSize)\n this.boundingBoxLength = this.boundingBoxSize.length()\n }\n\n updateBoundingBox () {\n this._updateBoundingBox()\n if (Debug) this.updateHelper()\n }\n\n getPickingPixels () {\n const {width, height} = this\n\n const n = width * height * 4\n const imgBuffer = SupportsReadPixelsFloat ? new Float32Array(n) : new Uint8Array(n)\n\n this.render(true)\n this.renderer.readRenderTargetPixels(\n this.pickingTarget, 0, 0, width, height, imgBuffer\n )\n\n return imgBuffer\n }\n\n getImage (picking: boolean) {\n return new Promise(resolve => {\n if (picking) {\n const {width, height} = this\n const n = width * height * 4\n let imgBuffer = this.getPickingPixels()\n\n if (SupportsReadPixelsFloat) {\n const imgBuffer2 = new Uint8Array(n)\n for (let i = 0; i < n; ++i) {\n imgBuffer2[ i ] = Math.round(imgBuffer[ i ] * 255)\n }\n imgBuffer = imgBuffer2\n }\n\n const canvas = document.createElement('canvas')\n canvas.width = width\n canvas.height = height\n const ctx = canvas.getContext('2d')! // TODO\n const imgData = ctx.getImageData(0, 0, width, height)\n imgData.data.set(imgBuffer as any) // TODO\n ctx.putImageData(imgData, 0, 0)\n canvas.toBlob(resolve as any, 'image/png') // TODO\n } else {\n this.renderer.domElement.toBlob(resolve as any, 'image/png') // TODO\n }\n })\n }\n\n makeImage (params: Partial = {}) {\n return makeImage(this, params)\n }\n\n setLight (color: Color|number|string, intensity: number, ambientColor: Color|number|string, ambientIntensity: number) {\n const p = this.parameters\n\n if (color !== undefined) p.lightColor.set(color as string) // TODO\n if (intensity !== undefined) p.lightIntensity = intensity\n if (ambientColor !== undefined) p.ambientColor.set(ambientColor as string) // TODO\n if (ambientIntensity !== undefined) p.ambientIntensity = ambientIntensity\n\n this.requestRender()\n }\n\n setFog (color?: Color|number|string, near?: number, far?: number) {\n const p = this.parameters\n\n if (color !== undefined) p.fogColor.set(color as string) // TODO\n if (near !== undefined) p.fogNear = near\n if (far !== undefined) p.fogFar = far\n\n this.requestRender()\n }\n\n setBackground (color?: Color|number|string) {\n const p = this.parameters\n\n if (color) p.backgroundColor.set(color as string) // TODO\n\n this.setFog(p.backgroundColor)\n this.renderer.setClearColor(p.backgroundColor, 0)\n this.renderer.domElement.style.backgroundColor = p.backgroundColor.getStyle()\n\n this.requestRender()\n }\n\n setSampling (level: number) {\n if (level !== undefined) {\n this.parameters.sampleLevel = level\n this.sampleLevel = level\n }\n\n this.requestRender()\n }\n\n /**\n * Set the output color encoding, i.e. how the renderer translates\n * colorspaces as it renders to the screen.\n\n * The default is LinearEncoding, because the internals of NGL are\n * already sRGB so no translation is needed to show sRGB colors.\n * Set to sRGBEncoding to create a linear workflow, and also call\n * `setColorEncoding(LinearEncoding)` to linearize colors on input.\n * @see setColorEncoding\n */\n private setOutputEncoding (encoding: TextureEncoding) {\n this.parameters.rendererEncoding = encoding\n this.renderer.outputEncoding = encoding\n this.pickingTarget.texture.encoding = encoding\n this.sampleTarget.texture.encoding = encoding\n this.holdTarget.texture.encoding = encoding\n }\n\n /**\n * Set the internal color workflow, linear or sRGB.\n * sRGB, the default, is more \"vibrant\" at the cost of accuracy.\n * Linear gives more accurate results, especially for transparent objects.\n * In all cases, the output is always sRGB; this just affects how colors are computed internally.\n * Call this just after creating the viewer, before loading any models.\n */\n setColorWorkflow (encoding: ColorWorkflow) {\n if (encoding != 'linear' && encoding != 'sRGB')\n throw new Error(`setColorWorkflow: invalid color workflow ${encoding}`)\n setColorSpace(encoding == 'linear' ? 'linear' : 'sRGB')\n this.setOutputEncoding(encoding == 'linear' ? sRGBEncoding : LinearEncoding)\n // Note: this doesn't rebuild models, so existing geometry will have\n // the old color encoding.\n this.requestRender()\n }\n\n setCamera (type: CameraType, fov?: number, eyeSep?: number) {\n const p = this.parameters\n\n if (type) p.cameraType = type\n if (fov) p.cameraFov = fov\n if (eyeSep) p.cameraEyeSep = eyeSep\n\n if (p.cameraType === 'orthographic') {\n if (this.camera !== this.orthographicCamera) {\n this.camera = this.orthographicCamera\n this.camera.position.copy(this.perspectiveCamera.position)\n this.camera.up.copy(this.perspectiveCamera.up)\n this.updateZoom()\n }\n } else if (p.cameraType === 'perspective' || p.cameraType === 'stereo') {\n if (this.camera !== this.perspectiveCamera) {\n this.camera = this.perspectiveCamera\n this.camera.position.copy(this.orthographicCamera.position)\n this.camera.up.copy(this.orthographicCamera.up)\n }\n } else {\n throw new Error(`Unknown cameraType '${p.cameraType}'`)\n }\n\n this.perspectiveCamera.fov = p.cameraFov\n this.stereoCamera.eyeSep = p.cameraEyeSep\n this.camera.updateProjectionMatrix()\n\n this.requestRender()\n }\n\n setClip (near: number, far: number, dist: number, clipMode?: string, clipScale?: string) {\n const p = this.parameters\n\n if (near !== undefined) p.clipNear = near\n if (far !== undefined) p.clipFar = far\n if (dist !== undefined) p.clipDist = dist\n if (clipMode !== undefined) p.clipMode = clipMode\n if (clipScale !== undefined) p.clipScale = clipScale\n\n this.requestRender()\n }\n\n setSize (width: number, height: number) {\n this.width = width || 1\n this.height = height || 1\n\n this.perspectiveCamera.aspect = this.width / this.height\n this.orthographicCamera.left = -this.width / 2\n this.orthographicCamera.right = this.width / 2\n this.orthographicCamera.top = this.height / 2\n this.orthographicCamera.bottom = -this.height / 2\n this.camera.updateProjectionMatrix()\n\n const dpr = window.devicePixelRatio\n\n this.renderer.setPixelRatio(dpr)\n this.renderer.setSize(width, height)\n\n const dprWidth = this.width * dpr\n const dprHeight = this.height * dpr\n\n this.pickingTarget.setSize(dprWidth, dprHeight)\n this.sampleTarget.setSize(dprWidth, dprHeight)\n this.holdTarget.setSize(dprWidth, dprHeight)\n\n this.requestRender()\n }\n\n handleResize () {\n if (this.container === document.body) {\n this.setSize(window.innerWidth, window.innerHeight)\n } else {\n const box = this.container.getBoundingClientRect()\n this.setSize(box.width, box.height)\n }\n }\n\n updateInfo (reset?: boolean) {\n const { memory, render } = this.info\n\n if (reset) {\n memory.programs = 0\n memory.geometries = 0\n memory.textures = 0\n\n render.calls = 0\n render.vertices = 0\n render.points = 0\n } else {\n const rInfo = this.renderer.info\n const rMemory = rInfo.memory\n const rRender = rInfo.render\n\n memory.geometries = rMemory.geometries\n memory.textures = rMemory.textures\n\n render.calls += rRender.calls\n render.faces += rRender.triangles\n render.points += rRender.points\n }\n }\n\n animate () {\n this.signals.ticked.dispatch(this.stats)\n const delta = window.performance.now() - this.stats.startTime\n\n if (delta > 500 && !this.isStill && this.sampleLevel < 3 && this.sampleLevel !== -1) {\n const currentSampleLevel = this.sampleLevel\n this.sampleLevel = 3\n this.renderPending = true\n this.render()\n this.isStill = true\n this.sampleLevel = currentSampleLevel\n if (Debug) Log.log('rendered still frame')\n }\n\n this.frameRequest = window.requestAnimationFrame(this.animate)\n }\n\n pick (x: number, y: number) {\n if (this.parameters.cameraType === 'stereo') {\n // TODO picking broken for stereo camera\n return {\n 'pid': 0,\n 'instance': undefined,\n 'picker': undefined\n }\n }\n\n x *= window.devicePixelRatio\n y *= window.devicePixelRatio\n\n x = Math.max(x - 2, 0)\n y = Math.max(y - 2, 0)\n\n let pid = 0, instance, picker\n const pixelBuffer = SupportsReadPixelsFloat ? pixelBufferFloat : pixelBufferUint\n\n this.render(true)\n this.renderer.readRenderTargetPixels(\n this.pickingTarget, x, y, 5, 5, pixelBuffer\n )\n\n for (let i = 0; i < pixelOrder.length; i++) {\n\n const offset = pixelOrder[i] * 4\n\n const oid = Math.round(pixelBuffer[ offset + 3 ])\n const object = this.pickingGroup.getObjectById(oid)\n if (object) {\n instance = object.userData.instance\n picker = object.userData.buffer.picking\n } else {\n continue\n }\n\n if (SupportsReadPixelsFloat) {\n pid =\n ((Math.round(pixelBuffer[offset] * 255) << 16) & 0xFF0000) |\n ((Math.round(pixelBuffer[offset + 1] * 255) << 8) & 0x00FF00) |\n ((Math.round(pixelBuffer[offset + 2] * 255)) & 0x0000FF)\n } else {\n pid =\n (pixelBuffer[offset] << 16) |\n (pixelBuffer[offset + 1] << 8) |\n (pixelBuffer[offset + 2])\n }\n }\n // if( Debug ){\n // const rgba = Array.apply( [], pixelBuffer );\n // Log.log( pixelBuffer );\n // Log.log(\n // \"picked color\",\n // rgba.map( c => { return c.toPrecision( 2 ) } )\n // );\n // Log.log( \"picked pid\", pid );\n // Log.log( \"picked oid\", oid );\n // Log.log( \"picked object\", object );\n // Log.log( \"picked instance\", instance );\n // Log.log( \"picked position\", x, y );\n // Log.log( \"devicePixelRatio\", window.devicePixelRatio );\n // }\n\n return { pid, instance, picker }\n }\n\n requestRender () {\n if (this.renderPending) {\n // Log.info(\"there is still a 'render' call pending\")\n return\n }\n\n // start gathering stats anew after inactivity\n if (window.performance.now() - this.stats.startTime > 22) {\n this.stats.begin()\n this.isStill = false\n }\n\n this.renderPending = true\n\n window.requestAnimationFrame(() => {\n this.render()\n this.stats.update()\n })\n }\n\n updateZoom () {\n const fov = degToRad(this.perspectiveCamera.fov)\n const height = 2 * Math.tan(fov / 2) * this.cameraDistance\n this.orthographicCamera.zoom = this.height / height\n }\n\n /**\n * Convert an absolute clip value to a relative one using bRadius.\n *\n * 0.0 -> 50.0\n * bRadius -> 0.0\n */\n absoluteToRelative (d: number) :number {\n return 50 * (1 - d / this.bRadius)\n }\n\n /**\n * Convert a relative clip value to an absolute one using bRadius\n *\n * 0.0 -> bRadius\n * 50.0 -> 0.0\n */\n relativeToAbsolute (d: number) : number {\n return this.bRadius * (1 - d / 50)\n }\n\n /**\n * Intepret clipMode, clipScale and set the camera and fog clipping.\n * Also ensures bRadius and cDist are valid\n */\n private __updateClipping () {\n const p = this.parameters\n\n // bRadius must always be updated for material-based clipping\n // and for focus calculations\n this.bRadius = Math.max(10, this.boundingBoxLength * 0.5)\n\n // FL: Removed below, but leaving commented as I don't understand intention\n // this.bRadius += this.boundingBox.getCenter(this.distVector).length()\n\n if (!isFinite(this.bRadius)) {\n this.bRadius = 50\n }\n\n this.camera.getWorldPosition(this.distVector)\n this.cDist = this.distVector.length()\n if (!this.cDist) {\n // recover from a broken (NaN) camera position\n this.cameraDistance = Math.abs(p.cameraZ)\n this.cDist = Math.abs(p.cameraZ)\n }\n\n // fog\n const fog = this.scene.fog as Fog\n fog.color.set(p.fogColor)\n\n if (p.clipMode === 'camera') {\n // Always interpret clipScale as absolute for clipMode camera\n\n this.camera.near = p.clipNear\n this.camera.far = p.clipFar\n fog.near = p.fogNear\n fog.far = p.fogFar\n\n } else {\n // scene mode\n\n if (p.clipScale === 'absolute') {\n // absolute scene mode; offset clip planes from scene center\n // (note: positive values move near plane towards camera and rear plane away)\n\n this.camera.near = this.cDist - p.clipNear\n this.camera.far = this.cDist + p.clipFar\n fog.near = this.cDist - p.fogNear\n fog.far = this.cDist + p.fogFar\n\n } else {\n // relative scene mode (default): convert pecentages to Angstroms\n\n const nearFactor = (50 - p.clipNear) / 50\n const farFactor = -(50 - p.clipFar) / 50\n this.camera.near = this.cDist - (this.bRadius * nearFactor)\n this.camera.far = this.cDist + (this.bRadius * farFactor)\n\n const fogNearFactor = (50 - p.fogNear) / 50\n const fogFarFactor = -(50 - p.fogFar) / 50\n fog.near = this.cDist - (this.bRadius * fogNearFactor)\n fog.far = this.cDist + (this.bRadius * fogFarFactor)\n }\n }\n\n if (p.clipMode !== 'camera') {\n\n if (this.camera.type === 'PerspectiveCamera') {\n\n this.camera.near = Math.max(0.1, p.clipDist, this.camera.near)\n this.camera.far = Math.max(1, this.camera.far)\n fog.near = Math.max(0.1, fog.near)\n fog.far = Math.max(1, fog.far)\n } else if (this.camera.type === 'OrthographicCamera') {\n\n if (p.clipDist > 0) {\n this.camera.near = Math.max(p.clipDist, this.camera.near)\n }\n }\n }\n }\n\n private __updateCamera () {\n const camera = this.camera\n camera.updateMatrix()\n camera.updateMatrixWorld(true)\n camera.updateProjectionMatrix()\n\n updateMaterialUniforms(this.scene, camera, this.renderer, this.cDist, this.bRadius)\n sortProjectedPosition(this.scene, camera)\n }\n\n private __setVisibility (model: boolean, picking: boolean, background: boolean, helper: boolean) {\n this.modelGroup.visible = model\n this.pickingGroup.visible = picking\n this.backgroundGroup.visible = background\n this.helperGroup.visible = helper\n }\n\n private __updateLights () {\n this.spotLight.color.set(this.parameters.lightColor)\n this.spotLight.intensity = this.parameters.lightIntensity\n\n this.distVector.copy(this.camera.position).setLength(this.boundingBoxLength * 100)\n this.spotLight.position.copy(this.camera.position).add(this.distVector)\n\n this.ambientLight.color.set(this.parameters.ambientColor)\n this.ambientLight.intensity = this.parameters.ambientIntensity\n }\n\n private __renderPickingGroup (camera: PerspectiveCamera|OrthographicCamera) {\n this.renderer.setRenderTarget(this.pickingTarget || null)\n this.renderer.clear()\n this.__setVisibility(false, true, false, false)\n this.renderer.render(this.scene, camera)\n // back to standard render target\n this.renderer.setRenderTarget(null)\n this.updateInfo()\n\n // if (Debug) {\n // this.__setVisibility(false, true, false, true);\n\n // this.renderer.clear();\n // this.renderer.render(this.scene, camera);\n // }\n }\n\n private __renderModelGroup (camera: PerspectiveCamera|OrthographicCamera, renderTarget?: WebGLRenderTarget) {\n this.renderer.setRenderTarget(renderTarget || null)\n this.renderer.clear()\n this.__setVisibility(false, false, true, false)\n this.renderer.render(this.scene, camera)\n this.renderer.clear(false, true, true)\n this.updateInfo()\n\n this.__setVisibility(true, false, false, Debug)\n this.renderer.render(this.scene, camera)\n this.renderer.setRenderTarget(null) // set back to default canvas\n this.updateInfo()\n }\n\n private __renderSuperSample (camera: PerspectiveCamera|OrthographicCamera, renderTarget?: WebGLRenderTarget) {\n // based on the Supersample Anti-Aliasing Render Pass\n // contributed to three.js by bhouston / http://clara.io/\n //\n // This manual approach to SSAA re-renders the scene ones for\n // each sample with camera jitter and accumulates the results.\n // References: https://en.wikipedia.org/wiki/Supersampling\n const offsetList = JitterVectors[ Math.max(0, Math.min(this.sampleLevel, 5)) ]\n\n const baseSampleWeight = 1.0 / offsetList.length\n const roundingRange = 1 / 32\n\n this.compositeUniforms.tForeground.value = this.sampleTarget.texture\n\n let width = this.sampleTarget.width\n const height = this.sampleTarget.height\n if (this.parameters.cameraType === 'stereo') {\n width /= 2\n }\n\n // render the scene multiple times, each slightly jitter offset\n // from the last and accumulate the results.\n for (let i = 0; i < offsetList.length; ++i) {\n const offset = offsetList[ i ]\n camera.setViewOffset(\n width, height, offset[ 0 ], offset[ 1 ], width, height\n )\n camera.updateProjectionMatrix()\n updateCameraUniforms(this.scene, camera)\n\n let sampleWeight = baseSampleWeight\n // the theory is that equal weights for each sample lead to an\n // accumulation of rounding errors.\n // The following equation varies the sampleWeight per sample\n // so that it is uniformly distributed across a range of values\n // whose rounding errors cancel each other out.\n const uniformCenteredDistribution = -0.5 + (i + 0.5) / offsetList.length\n sampleWeight += roundingRange * uniformCenteredDistribution\n this.compositeUniforms.scale.value = sampleWeight\n\n this.__renderModelGroup(camera, this.sampleTarget)\n this.renderer.setRenderTarget(this.holdTarget)\n if (i === 0) {\n this.renderer.clear()\n }\n\n this.renderer.render(this.compositeScene, this.compositeCamera)\n }\n\n this.compositeUniforms.scale.value = 1.0\n this.compositeUniforms.tForeground.value = this.holdTarget.texture\n\n camera.clearViewOffset()\n this.renderer.setRenderTarget(renderTarget || null)\n this.renderer.clear()\n this.renderer.render(this.compositeScene, this.compositeCamera)\n }\n\n private __renderStereo (picking = false, _renderTarget?: WebGLRenderTarget) {\n const stereoCamera = this.stereoCamera\n stereoCamera.update(this.perspectiveCamera);\n\n const renderer = this.renderer\n let size = new Vector2()\n renderer.getSize(size)\n\n renderer.setScissorTest(true)\n\n renderer.setScissor(0, 0, size.width / 2, size.height)\n renderer.setViewport(0, 0, size.width / 2, size.height)\n updateCameraUniforms(this.scene, stereoCamera.cameraL)\n this.__render(picking, stereoCamera.cameraL)\n\n renderer.setScissor(size.width / 2, 0, size.width / 2, size.height)\n renderer.setViewport(size.width / 2, 0, size.width / 2, size.height)\n updateCameraUniforms(this.scene, stereoCamera.cameraR)\n this.__render(picking, stereoCamera.cameraR)\n\n renderer.setScissorTest(false)\n renderer.setViewport(0, 0, size.width, size.height)\n }\n\n private __render(picking = false, camera: PerspectiveCamera|OrthographicCamera, renderTarget?: WebGLRenderTarget) {\n if (picking) {\n if (!this.lastRenderedPicking) this.__renderPickingGroup(camera)\n } else if (this.sampleLevel > 0 && this.parameters.cameraType !== 'stereo') {\n // TODO super sample broken for stereo camera\n this.__renderSuperSample(camera, renderTarget)\n } else {\n this.__renderModelGroup(camera, renderTarget)\n }\n }\n\n render (picking = false, renderTarget?: WebGLRenderTarget) {\n if (this.rendering) {\n Log.warn(\"'tried to call 'render' from within 'render'\")\n return\n }\n\n // Log.time('Viewer.render')\n\n this.rendering = true\n\n try {\n this.__updateClipping()\n this.__updateCamera()\n this.__updateLights()\n this.updateInfo(true)\n\n // render\n if (this.parameters.cameraType === 'stereo') {\n this.__renderStereo(picking, renderTarget)\n } else {\n this.__render(picking, this.camera, renderTarget)\n }\n this.lastRenderedPicking = picking\n } finally {\n this.rendering = false\n this.renderPending = false\n }\n this.signals.rendered.dispatch()\n\n // Log.timeEnd('Viewer.render')\n // Log.log(this.info.memory, this.info.render)\n }\n\n clear () {\n Log.log('scene cleared')\n this.scene.remove(this.rotationGroup)\n this._initScene()\n this.renderer.clear()\n }\n\n dispose () {\n this.renderer.dispose()\n window.cancelAnimationFrame(this.frameRequest)\n }\n}\n","/**\n * @file Mouse Observer\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector2 } from 'three'\nimport { Signal } from 'signals'\n\nimport { LeftMouseButton, RightMouseButton } from '../constants'\nimport { defaults } from '../utils'\nimport Viewer from '../viewer/viewer'\nimport MouseControls from '../controls/mouse-controls'\n\ntype Optional = Pick, K> & Omit;\n\n/**\n * @example\n * mouseObserver.signals.scrolled.add( function( delta ){ ... } );\n *\n * @typedef {Object} MouseSignals\n * @property {Signal} moved - on move: deltaX, deltaY\n * @property {Signal} scrolled - on scroll: delta\n * @property {Signal} dragged - on drag: deltaX, deltaY\n * @property {Signal} dropped - on drop\n * @property {Signal} clicked - on click\n * @property {Signal} hovered - on hover\n */\n\nfunction getTouchDistance (event: TouchEvent) {\n const dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX\n const dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY\n return Math.sqrt(dx * dx + dy * dy)\n}\n\nfunction getMouseButtons (event: MouseEvent) {\n if (typeof event === 'object') {\n if ('buttons' in event) {\n return event.buttons\n } else if ('which' in event as any) {\n const b = (event as any).which\n if (b === 2) {\n return 4\n } else if (b === 3) {\n return 2\n } else if (b > 0) {\n return 1 << (b - 1)\n }\n } else if ('button' in event as any) {\n const b = (event as any).button\n if (b === 1) {\n return 4\n } else if (b === 2) {\n return 2\n } else if (b >= 0) {\n return 1 << b\n }\n }\n }\n return 0\n}\n\nexport interface MouseSignals {\n moved: Signal // on move: deltaX, deltaY\n scrolled: Signal // on scroll: delta\n dragged: Signal // on drag: deltaX, deltaY\n dropped: Signal // on drop\n clicked: Signal // on click\n hovered: Signal // on hover\n doubleClicked: Signal\n}\n\nexport interface MouseParams {\n hoverTimeout?: number\n handleScroll?:boolean\n doubleClickSpeed?: number\n}\n\n/**\n * Mouse observer\n *\n * @example\n * // listen to mouse moving (and touch-moving) events\n * mouseObserver.moved.moved.add( function( deltaX, deltaY ){ ... } );\n *\n * @example\n * // listen to scrolling (and pinching) events\n * mouseObserver.signals.scrolled.add( function( delta ){ ... } );\n *\n * @example\n * // listen to dragging (and touch-dragging) events\n * mouseObserver.signals.dragged.add( function( deltaX, deltaY ){ ... } );\n *\n * @example\n * // listen to clicking (and tapping) events\n * mouseObserver.signals.clicked.add( function(){ ... } );\n *\n * @example\n * // listen to double clicking (and double tapping) events\n * mouseObserver.signals.doubleClicked.add( function(){ ... } );\n *\n * @example\n * // listen to hovering events\n * mouseObserver.signals.hovered.add( function(){ ... } );\n */\nclass MouseObserver {\n signals: MouseSignals = {\n moved: new Signal(),\n scrolled: new Signal(),\n dragged: new Signal(),\n dropped: new Signal(),\n clicked: new Signal(),\n hovered: new Signal(),\n doubleClicked: new Signal()\n }\n\n hoverTimeout: number\n handleScroll:boolean\n doubleClickSpeed: number\n\n viewer: Viewer\n mouse: MouseObserver\n controls: MouseControls\n\n position = new Vector2() // Position on page\n prevPosition = new Vector2() // Previous position on page\n down = new Vector2() // Position on page when clicked\n canvasPosition = new Vector2() // Position on dom element\n prevClickCP = new Vector2()\n\n moving = false // Flag indicating if the mouse is moving\n hovering = true // Flag indicating if the mouse is hovering\n scrolled = false // Flag indicating if there was a scolling event since the last mouse move\n lastMoved = Infinity // Timestamp of last mouse move\n which? = 0 // 0: No button; 1: Left button; 2: Middle button; 3: Right button\n buttons? = 0 // 0: No button; 1: Left button; 2: Right button; 4: Middle button\n pressed? = false // Flag indicating if the mouse is pressed down\n altKey = false // Flag indicating if the alt key is pressed\n ctrlKey = false // Flag indicating if the ctrl key is pressed\n metaKey = false // Flag indicating if the meta key is pressed\n shiftKey = false // Flag indicating if the shift key is pressed\n\n doubleClickPending: boolean\n lastClicked: number\n overElement: boolean\n lastTouchDistance: number\n private frameRequest: number\n\n /**\n * @param {Element} domElement - the dom element to observe mouse events in\n * @param {Object} params - parameters object\n * @param {Integer} params.hoverTimeout - timeout in ms until the {@link MouseSignals.hovered}\n * signal is fired, set to -1 to ignore hovering\n * @param {Boolean} params.handleScroll - whether or not to handle scroll events\n * @param {Integer} params.doubleClickSpeed - max time in ms to trigger double click\n */\n constructor (readonly domElement: HTMLCanvasElement, params: MouseParams = {}) {\n this.domElement.style.touchAction = 'none'\n\n this.hoverTimeout = defaults(params.hoverTimeout, 50)\n this.handleScroll = defaults(params.handleScroll, true)\n this.doubleClickSpeed = defaults(params.doubleClickSpeed, 500)\n\n this._listen = this._listen.bind(this)\n this._onMousewheel = this._onMousewheel.bind(this)\n this._onMousemove = this._onMousemove.bind(this)\n this._onMousedown = this._onMousedown.bind(this)\n this._onMouseup = this._onMouseup.bind(this)\n this._onContextmenu = this._onContextmenu.bind(this)\n this._onTouchstart = this._onTouchstart.bind(this)\n this._onTouchend = this._onTouchend.bind(this)\n this._onTouchmove = this._onTouchmove.bind(this)\n\n this._listen()\n\n const opt = { passive: false } // treat as 'passive' so preventDefault can be called\n document.addEventListener('mousewheel', this._onMousewheel, opt)\n document.addEventListener('wheel', this._onMousewheel, opt)\n document.addEventListener('MozMousePixelScroll', this._onMousewheel, opt)\n document.addEventListener('mousemove', this._onMousemove, opt)\n document.addEventListener('mousedown', this._onMousedown, opt)\n document.addEventListener('mouseup', this._onMouseup, opt)\n document.addEventListener('contextmenu', this._onContextmenu, opt)\n document.addEventListener('touchstart', this._onTouchstart, opt)\n document.addEventListener('touchend', this._onTouchend, opt)\n document.addEventListener('touchmove', this._onTouchmove, opt)\n }\n\n get key () {\n let key = 0\n if (this.altKey) key += 1\n if (this.ctrlKey) key += 2\n if (this.metaKey) key += 4\n if (this.shiftKey) key += 8\n return key\n }\n\n setParameters (params: MouseParams = {}) {\n this.hoverTimeout = defaults(params.hoverTimeout, this.hoverTimeout)\n }\n\n /**\n * listen to mouse actions\n * @emits {MouseSignals.clicked} when clicked\n * @emits {MouseSignals.hovered} when hovered\n * @return {undefined}\n */\n _listen () {\n const now = window.performance.now()\n const cp = this.canvasPosition\n if (this.doubleClickPending && now - this.lastClicked > this.doubleClickSpeed) {\n this.doubleClickPending = false\n }\n if (now - this.lastMoved > this.hoverTimeout) {\n this.moving = false\n }\n if (this.scrolled || (!this.moving && !this.hovering)) {\n this.scrolled = false\n if (this.hoverTimeout !== -1 && this.overElement) {\n this.hovering = true\n this.signals.hovered.dispatch(cp.x, cp.y)\n }\n }\n this.frameRequest = window.requestAnimationFrame(this._listen)\n }\n\n /**\n * handle mouse scroll\n * @emits {MouseSignals.scrolled} when scrolled\n * @param {Event} event - mouse event\n * @return {undefined}\n */\n _onMousewheel(event: Optional & { wheelDelta?: number, wheelDeltaY?: number }) {\n if (event.target !== this.domElement || !this.handleScroll) {\n return\n }\n event.preventDefault()\n this._setKeys(event as any)\n\n let delta = 0\n // This has to be written in a particular way to handle old browsers that\n // all send events with different properties set in different ways.\n if ('deltaY' in event && 'deltaMode' in event &&\n event.deltaY !== undefined && event.deltaMode !== undefined) {\n // all modern browsers, using WheelEvent; deltaY + down (toward user)\n if (event.deltaMode === WheelEvent.DOM_DELTA_PIXEL)\n // everything except Firefox: normally 100 per wheel click\n delta = -event.deltaY * (2.5 / 100.0)\n else if (event.deltaMode === WheelEvent.DOM_DELTA_LINE)\n // Firefox in line mode, normally 3 per wheel click\n delta = -event.deltaY * (2.5 / 3.0)\n else // page mode: 1 per wheel click\n delta = -event.deltaY * 2.5\n } else if ('deltaY' in event && !('detail' in event)) {\n // Old Firefox or IE 11: deltaY but no deltaMode; treat as pixels\n delta = -event.deltaY * (2.5 / 100.0)\n } else if (event.wheelDelta !== undefined) {\n delta = -event.wheelDelta * (2.5 / 100)\n } else if (event.wheelDeltaY !== undefined) {\n delta = -event.wheelDeltaY * (2.5 / 100)\n } else if (event.detail !== undefined){\n // Old Firefox, MouseWheelEvent\n delta = -event.detail / 3\n }\n this.signals.scrolled.dispatch(delta)\n\n setTimeout(() => {\n this.scrolled = true\n }, this.hoverTimeout)\n }\n\n /**\n * handle mouse move\n * @emits {MouseSignals.moved} when moved\n * @emits {MouseSignals.dragged} when dragged\n * @param {Event} event - mouse event\n * @return {undefined}\n */\n _onMousemove (event: MouseEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n this.overElement = true\n } else {\n this.overElement = false\n }\n this._setKeys(event)\n this.moving = true\n this.hovering = false\n this.lastMoved = window.performance.now()\n this.prevPosition.copy(this.position)\n this.position.set(event.clientX, event.clientY)\n this._setCanvasPosition(event)\n const dx = this.prevPosition.x - this.position.x\n const dy = this.prevPosition.y - this.position.y\n this.signals.moved.dispatch(dx, dy)\n if (this.pressed) {\n this.signals.dragged.dispatch(dx, dy)\n }\n }\n\n _onMousedown (event: MouseEvent) {\n if (event.target !== this.domElement) {\n return\n }\n event.preventDefault()\n this._setKeys(event)\n this.moving = false\n this.hovering = false\n this.down.set(event.clientX, event.clientY)\n this.position.set(event.clientX, event.clientY)\n this.which = event.which\n this.buttons = getMouseButtons(event)\n this.pressed = true\n this._setCanvasPosition(event)\n }\n\n /**\n * handle mouse up\n * @emits {MouseSignals.doubleClicked} when double clicked\n * @emits {MouseSignals.dropped} when dropped\n * @param {Event} event - mouse event\n * @return {undefined}\n */\n _onMouseup (event: MouseEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n }\n this._setKeys(event)\n const cp = this.canvasPosition\n if (this._distance() < 4) {\n this.lastClicked = window.performance.now()\n if (this.doubleClickPending && this.prevClickCP.distanceTo(cp) < 4) {\n this.signals.doubleClicked.dispatch(cp.x, cp.y)\n this.doubleClickPending = false\n }\n this.signals.clicked.dispatch(cp.x, cp.y)\n this.doubleClickPending = true\n this.prevClickCP.copy(cp)\n }\n this.which = undefined\n this.buttons = undefined\n this.pressed = undefined\n // if (this._distance() > 3 || event.which === RightMouseButton) {\n // this.signals.dropped.dispatch();\n // }\n }\n\n _onContextmenu (event: MouseEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n }\n }\n\n _onTouchstart (event: TouchEvent) {\n if (event.target !== this.domElement) {\n return\n }\n event.preventDefault()\n this.pressed = true\n switch (event.touches.length) {\n case 1: {\n this.moving = false\n this.hovering = false\n this.down.set(\n event.touches[ 0 ].pageX,\n event.touches[ 0 ].pageY\n )\n this.position.set(\n event.touches[ 0 ].pageX,\n event.touches[ 0 ].pageY\n )\n this._setCanvasPosition(event.touches[ 0 ])\n break\n }\n\n case 2: {\n this.down.set(\n (event.touches[ 0 ].pageX + event.touches[ 1 ].pageX) / 2,\n (event.touches[ 0 ].pageY + event.touches[ 1 ].pageY) / 2\n )\n this.position.set(\n (event.touches[ 0 ].pageX + event.touches[ 1 ].pageX) / 2,\n (event.touches[ 0 ].pageY + event.touches[ 1 ].pageY) / 2\n )\n this.lastTouchDistance = getTouchDistance(event)\n }\n }\n }\n\n _onTouchend (event: TouchEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n }\n this.which = undefined\n this.buttons = undefined\n this.pressed = undefined\n }\n\n _onTouchmove (event: TouchEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n this.overElement = true\n } else {\n this.overElement = false\n }\n switch (event.touches.length) {\n case 1: {\n this._setKeys(event)\n this.which = LeftMouseButton\n this.buttons = 1\n this.moving = true\n this.hovering = false\n this.lastMoved = window.performance.now()\n this.prevPosition.copy(this.position)\n this.position.set(\n event.touches[ 0 ].pageX,\n event.touches[ 0 ].pageY\n )\n this._setCanvasPosition(event.touches[ 0 ])\n const dx = this.prevPosition.x - this.position.x\n const dy = this.prevPosition.y - this.position.y\n this.signals.moved.dispatch(dx, dy)\n if (this.pressed) {\n this.signals.dragged.dispatch(dx, dy)\n }\n break\n }\n\n case 2: {\n const touchDistance = getTouchDistance(event)\n const delta = touchDistance - this.lastTouchDistance\n this.lastTouchDistance = touchDistance\n this.prevPosition.copy(this.position)\n this.position.set(\n (event.touches[ 0 ].pageX + event.touches[ 1 ].pageX) / 2,\n (event.touches[ 0 ].pageY + event.touches[ 1 ].pageY) / 2\n )\n if (Math.abs(delta) > 2 && this.handleScroll &&\n this.position.distanceTo(this.prevPosition) < 2\n ) {\n this.which = 0\n this.buttons = 0\n this.signals.scrolled.dispatch(delta / 2)\n } else {\n this.which = RightMouseButton\n this.buttons = 2\n const dx = this.prevPosition.x - this.position.x\n const dy = this.prevPosition.y - this.position.y\n this.signals.moved.dispatch(dx, dy)\n if (this.pressed) {\n this.signals.dragged.dispatch(dx, dy)\n }\n }\n }\n }\n }\n\n _distance () {\n return this.position.distanceTo(this.down)\n }\n\n _setCanvasPosition (event: any) { // TODO\n const box = this.domElement.getBoundingClientRect()\n let offsetX, offsetY;\n if ('clientX' in event && 'clientY' in event) {\n offsetX = event.clientX - box.left\n offsetY = event.clientY - box.top\n } else {\n offsetX = event.offsetX\n offsetY = event.offsetY\n }\n this.canvasPosition.set(offsetX, box.height - offsetY)\n }\n\n _setKeys (event: MouseEvent|TouchEvent) {\n this.altKey = event.altKey\n this.ctrlKey = event.ctrlKey\n this.metaKey = event.metaKey\n this.shiftKey = event.shiftKey\n }\n\n dispose () {\n document.removeEventListener('mousewheel', this._onMousewheel)\n document.removeEventListener('wheel', this._onMousewheel)\n document.removeEventListener('MozMousePixelScroll', this._onMousewheel)\n document.removeEventListener('mousemove', this._onMousemove)\n document.removeEventListener('mousedown', this._onMousedown)\n document.removeEventListener('mouseup', this._onMouseup)\n document.removeEventListener('contextmenu', this._onContextmenu)\n document.removeEventListener('touchstart', this._onTouchstart)\n document.removeEventListener('touchend', this._onTouchend)\n document.removeEventListener('touchmove', this._onTouchmove)\n window.cancelAnimationFrame(this.frameRequest)\n }\n}\n\nexport default MouseObserver\n","/**\n * @file Constants\n * @author Alexander Rose \n * @private\n */\n\nexport const LeftMouseButton = 1\nexport const MiddleMouseButton = 2\nexport const RightMouseButton = 3\n","/**\n * @file Trackball Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4, Quaternion } from 'three'\n\nimport { defaults } from '../utils'\nimport Stage from '../stage/stage'\nimport MouseObserver from '../stage/mouse-observer'\nimport Viewer from '../viewer/viewer'\nimport ViewerControls from './viewer-controls'\nimport AtomProxy from '../proxy/atom-proxy';\nimport Component from '../component/component';\n\nconst tmpRotateXMatrix = new Matrix4()\nconst tmpRotateYMatrix = new Matrix4()\nconst tmpRotateZMatrix = new Matrix4()\nconst tmpRotateMatrix = new Matrix4()\nconst tmpRotateCameraMatrix = new Matrix4()\nconst tmpRotateVector = new Vector3()\nconst tmpRotateQuaternion = new Quaternion()\nconst tmpRotateQuaternion2 = new Quaternion()\nconst tmpPanMatrix = new Matrix4()\nconst tmpPanVector = new Vector3()\nconst tmpAtomVector = new Vector3()\n\nexport interface TrackballControlsParams {\n rotateSpeed?: number\n zoomSpeed?: number\n panSpeed?: number\n}\n\n/**\n * Trackball controls\n */\nclass TrackballControls {\n viewer: Viewer\n mouse: MouseObserver\n controls: ViewerControls\n\n rotateSpeed: number\n zoomSpeed: number\n panSpeed: number\n\n constructor (readonly stage: Stage, params: TrackballControlsParams = {}) {\n this.rotateSpeed = defaults(params.rotateSpeed, 2.0)\n this.zoomSpeed = defaults(params.zoomSpeed, 1.2)\n this.panSpeed = defaults(params.panSpeed, 1.0)\n\n this.viewer = stage.viewer\n this.mouse = stage.mouseObserver\n this.controls = stage.viewerControls\n }\n\n get component (): Component|undefined {\n return this.stage.transformComponent\n }\n\n get atom (): AtomProxy|undefined {\n return this.stage.transformAtom\n }\n\n private _setPanVector (x: number, y: number, z = 0) {\n const scaleFactor = this.controls.getCanvasScaleFactor(z)\n tmpPanVector.set(x, y, 0)\n tmpPanVector.multiplyScalar(this.panSpeed * scaleFactor)\n }\n\n private _getRotateXY (x: number, y: number) {\n return [\n this.rotateSpeed * -x * 0.01,\n this.rotateSpeed * y * 0.01\n ]\n }\n\n private _getCameraRotation(m: Matrix4) {\n m.extractRotation(this.viewer.camera.matrixWorld)\n m.multiply(tmpRotateYMatrix.makeRotationY(Math.PI))\n\n return m\n }\n\n private _transformPanVector () {\n if (!this.component) return\n\n // Adjust for component and scene rotation\n tmpPanMatrix.extractRotation(this.component.transform)\n tmpPanMatrix.premultiply(this.viewer.rotationGroup.matrix)\n tmpPanMatrix.getInverse(tmpPanMatrix)\n\n // Adjust for camera rotation\n tmpPanMatrix.multiply(this._getCameraRotation(tmpRotateMatrix))\n\n tmpPanVector.applyMatrix4(tmpPanMatrix)\n }\n\n zoom (delta: number) {\n this.controls.zoom(this.zoomSpeed * delta * 0.02)\n }\n\n pan (x: number, y: number) {\n this._setPanVector(x, y)\n\n // Adjust for scene rotation\n tmpPanMatrix.getInverse(this.viewer.rotationGroup.matrix)\n\n // Adjust for camera rotation\n tmpPanMatrix.multiply(this._getCameraRotation(tmpRotateMatrix))\n\n tmpPanVector.applyMatrix4(tmpPanMatrix)\n this.controls.translate(tmpPanVector)\n }\n\n panComponent (x: number, y: number) {\n if (!this.component) return\n\n this._setPanVector(x, y)\n this._transformPanVector()\n\n this.component.position.add(tmpPanVector)\n this.component.updateMatrix()\n }\n\n panAtom (x: number, y: number) {\n if (!this.atom || !this.component) return\n\n this.atom.positionToVector3(tmpAtomVector)\n tmpAtomVector.add(this.viewer.translationGroup.position)\n tmpAtomVector.applyMatrix4(this.viewer.rotationGroup.matrix)\n\n this._setPanVector(x, y, tmpAtomVector.z)\n this._transformPanVector()\n\n this.atom.positionAdd(tmpPanVector)\n this.component.updateRepresentations({ 'position': true })\n }\n\n rotate (x: number, y: number) {\n const [ dx, dy ] = this._getRotateXY(x, y)\n\n // rotate around screen X then screen Y\n this._getCameraRotation(tmpRotateMatrix)\n tmpRotateVector.set(1, 0, 0) // X axis\n tmpRotateVector.applyMatrix4(tmpRotateMatrix) // screen X\n tmpRotateQuaternion.setFromAxisAngle(tmpRotateVector, dy)\n\n tmpRotateVector.set(0, 1, 0) // Y axis\n tmpRotateVector.applyMatrix4(tmpRotateMatrix) // screen Y\n tmpRotateQuaternion2.setFromAxisAngle(tmpRotateVector, dx)\n\n tmpRotateQuaternion.multiply(tmpRotateQuaternion2)\n tmpRotateMatrix.makeRotationFromQuaternion(tmpRotateQuaternion)\n this.controls.applyMatrix(tmpRotateMatrix)\n }\n\n zRotate (x: number, y: number) {\n const dz = this.rotateSpeed * ((-x + y) / -2) * 0.01\n\n tmpRotateZMatrix.makeRotationZ(dz)\n this.controls.applyMatrix(tmpRotateZMatrix)\n }\n\n rotateComponent (x: number, y: number) {\n if (!this.component) return\n\n const [ dx, dy ] = this._getRotateXY(x, y)\n\n this._getCameraRotation(tmpRotateCameraMatrix)\n\n tmpRotateMatrix.extractRotation(this.component.transform)\n tmpRotateMatrix.premultiply(this.viewer.rotationGroup.matrix)\n tmpRotateMatrix.getInverse(tmpRotateMatrix)\n tmpRotateMatrix.premultiply(tmpRotateCameraMatrix)\n\n tmpRotateVector.set(1, 0, 0)\n tmpRotateVector.applyMatrix4(tmpRotateMatrix)\n tmpRotateXMatrix.makeRotationAxis(tmpRotateVector, dy)\n\n tmpRotateVector.set(0, 1, 0)\n tmpRotateVector.applyMatrix4(tmpRotateMatrix)\n tmpRotateYMatrix.makeRotationAxis(tmpRotateVector, dx)\n\n tmpRotateXMatrix.multiply(tmpRotateYMatrix)\n tmpRotateQuaternion.setFromRotationMatrix(tmpRotateXMatrix)\n this.component.quaternion.premultiply(tmpRotateQuaternion)\n this.component.quaternion.normalize()\n this.component.updateMatrix()\n }\n}\n\nexport default TrackballControls\n","/**\n * @file Picking Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4, Vector2 } from 'three'\n\nimport Stage from '../stage/stage'\nimport StructureComponent from '../component/structure-component'\nimport MouseObserver from '../stage/mouse-observer'\nimport { Picker } from '../utils/picker'\nimport ViewerControls from './viewer-controls'\nimport Shape from '../geometry/shape'\nimport Structure from '../structure/structure'\nimport BondProxy from '../proxy/bond-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Surface from '../surface/surface'\nimport Volume from '../surface/volume'\nimport Unitcell from '../symmetry/unitcell'\nimport Component from '../component/component';\n\nconst tmpVec = new Vector3()\n\nexport interface ShapePrimitive {\n name: string\n shape: Shape\n}\n\nfunction closer (x: Vector3, a: Vector3, b: Vector3) {\n return x.distanceTo(a) < x.distanceTo(b)\n}\n\n/**\n * Picking data object.\n * @typedef {Object} PickingData - picking data\n * @property {Number} [pid] - picking id\n * @property {Object} [instance] - instance data\n * @property {Integer} instance.id - instance id\n * @property {String|Integer} instance.name - instance name\n * @property {Matrix4} instance.matrix - transformation matrix of the instance\n * @property {Picker} [picker] - picker object\n */\n\nexport interface InstanceData {\n id: number\n name: number|string\n matrix: Matrix4\n}\n\nexport interface PickingData {\n pid: number\n instance: InstanceData\n picker: Picker\n}\n\n/**\n * Picking proxy class.\n */\nclass PickingProxy {\n pid: number\n picker: Picker\n instance: InstanceData\n controls: ViewerControls\n mouse: MouseObserver\n\n /**\n * Create picking proxy object\n * @param {PickingData} pickingData - picking data\n * @param {Stage} stage - stage object\n */\n constructor (pickingData: PickingData, readonly stage: Stage) {\n this.pid = pickingData.pid\n this.picker = pickingData.picker\n\n /**\n * @type {Object}\n */\n this.instance = pickingData.instance\n\n /**\n * @type {Stage}\n */\n this.stage = stage\n /**\n * @type {ViewerControls}\n */\n this.controls = stage.viewerControls\n /**\n * @type {MouseObserver}\n */\n this.mouse = stage.mouseObserver\n }\n\n /**\n * Kind of the picked data\n * @type {String}\n */\n get type () { return this.picker.type }\n\n /**\n * If the `alt` key was pressed\n * @type {Boolean}\n */\n get altKey () { return this.mouse.altKey }\n /**\n * If the `ctrl` key was pressed\n * @type {Boolean}\n */\n get ctrlKey () { return this.mouse.ctrlKey }\n /**\n * If the `meta` key was pressed\n * @type {Boolean}\n */\n get metaKey () { return this.mouse.metaKey }\n /**\n * If the `shift` key was pressed\n * @type {Boolean}\n */\n get shiftKey () { return this.mouse.shiftKey }\n\n /**\n * Position of the mouse on the canvas\n * @type {Vector2}\n */\n get canvasPosition (): Vector2 { return this.mouse.canvasPosition }\n\n /**\n * The component the picked data is part of\n * @type {Component}\n */\n get component (): Component {\n return this.stage.getComponentsByObject(this.picker.data as any).list[ 0 ] // TODO\n }\n\n /**\n * The picked object data\n * @type {Object}\n */\n get object () {\n return this.picker.getObject(this.pid)\n }\n\n /**\n * The 3d position in the scene of the picked object\n * @type {Vector3}\n */\n get position () {\n return this.picker.getPosition(this.pid, this.instance, this.component)\n }\n\n /**\n * The atom of a picked bond that is closest to the mouse\n * @type {AtomProxy}\n */\n get closestBondAtom (): AtomProxy|undefined {\n if (this.type !== 'bond' || !this.bond) return undefined\n\n const bond = this.bond\n const controls = this.controls\n const cp = this.canvasPosition\n\n const v1 = bond.atom1.positionToVector3()\n const v2 = bond.atom2.positionToVector3()\n\n v1.applyMatrix4(this.component.matrix)\n v2.applyMatrix4(this.component.matrix)\n\n const acp1 = controls.getPositionOnCanvas(v1)\n const acp2 = controls.getPositionOnCanvas(v2)\n\n return closer(cp as any, acp1, acp2) ? bond.atom1 : bond.atom2\n }\n\n /**\n * Close-by atom\n * @type {AtomProxy}\n */\n get closeAtom (): AtomProxy|undefined {\n const cp = this.canvasPosition\n const ca = this.closestBondAtom\n if (!ca) return undefined\n\n const v = ca.positionToVector3().applyMatrix4(this.component.matrix)\n\n const acp = this.controls.getPositionOnCanvas(v)\n\n ca.positionToVector3(tmpVec)\n if (this.instance) tmpVec.applyMatrix4(this.instance.matrix)\n tmpVec.applyMatrix4(this.component.matrix)\n const viewer = this.controls.viewer\n tmpVec.add(viewer.translationGroup.position)\n tmpVec.applyMatrix4(viewer.rotationGroup.matrix)\n\n const scaleFactor = this.controls.getCanvasScaleFactor(tmpVec.z)\n const sc = this.component as StructureComponent\n const radius = sc.getMaxRepresentationRadius(ca.index)\n //console.log(scaleFactor, cp.distanceTo(acp), radius/scaleFactor, radius)\n\n if (cp.distanceTo(acp) <= radius/scaleFactor) {\n return ca\n } else {\n return undefined\n }\n }\n\n /**\n * @type {Object}\n */\n get arrow () { return this._objectIfType('arrow') as ShapePrimitive }\n /**\n * @type {AtomProxy}\n */\n get atom () { return this._objectIfType('atom') as AtomProxy }\n /**\n * @type {Object}\n */\n get axes () { return this._objectIfType('axes') }\n /**\n * @type {BondProxy}\n */\n get bond () { return this._objectIfType('bond') as BondProxy }\n /**\n * @type {Object}\n */\n get box () { return this._objectIfType('box') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get cone () { return this._objectIfType('cone') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get clash () { return this._objectIfType('clash') as { clash: { sele1: string, sele2: string } } }\n /**\n * @type {BondProxy}\n */\n get contact () { return this._objectIfType('contact') as { type: string, atom1: AtomProxy, atom2: AtomProxy } }\n /**\n * @type {Object}\n */\n get cylinder () { return this._objectIfType('cylinder') as ShapePrimitive }\n /**\n * @type {BondProxy}\n */\n get distance () { return this._objectIfType('distance') as BondProxy }\n /**\n * @type {Object}\n */\n get ellipsoid () { return this._objectIfType('ellipsoid') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get octahedron () { return this._objectIfType('octahedron') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get point () { return this._objectIfType('point') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get mesh () { return this._objectIfType('mesh') as { name: string, shape: Shape, serial: number } }\n /**\n * @type {Object}\n */\n get slice () { return this._objectIfType('slice') as { volume: Volume, value: number } }\n /**\n * @type {Object}\n */\n get sphere () { return this._objectIfType('sphere') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get tetrahedron () { return this._objectIfType('tetrahedron') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get torus () { return this._objectIfType('torus') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get surface () { return this._objectIfType('surface') as { surface: Surface, index: number } }\n /**\n * @type {Object}\n */\n get unitcell () { return this._objectIfType('unitcell') as { unitcell: Unitcell, structure: Structure } }\n /**\n * @type {Object}\n */\n get unknown () { return this._objectIfType('unknown') }\n /**\n * @type {Object}\n */\n get volume () { return this._objectIfType('volume') as { volume: Volume, value: number } }\n /**\n * @type {Object}\n */\n get wideline () { return this._objectIfType('wideline') as ShapePrimitive }\n\n _objectIfType (type: string) {\n return this.type === type ? this.object : undefined\n }\n\n getLabel () {\n const atom = this.atom || this.closeAtom\n let msg = 'nothing'\n if (this.arrow) {\n msg = this.arrow.name\n } else if (atom) {\n msg = `atom: ${atom.qualifiedName()} (${atom.structure.name})`\n } else if (this.axes) {\n msg = 'axes'\n } else if (this.bond) {\n msg = `bond: ${this.bond.atom1.qualifiedName()} - ${this.bond.atom2.qualifiedName()} (${this.bond.structure.name})`\n } else if (this.box) {\n msg = this.box.name\n } else if (this.cone) {\n msg = this.cone.name\n } else if (this.clash) {\n msg = `clash: ${this.clash.clash.sele1} - ${this.clash.clash.sele2}`\n } else if (this.contact) {\n msg = `${this.contact.type}: ${this.contact.atom1.qualifiedName()} - ${this.contact.atom2.qualifiedName()} (${this.contact.atom1.structure.name})`\n } else if (this.cylinder) {\n msg = this.cylinder.name\n } else if (this.distance) {\n msg = `distance: ${this.distance.atom1.qualifiedName()} - ${this.distance.atom2.qualifiedName()} (${this.distance.structure.name})`\n } else if (this.ellipsoid) {\n msg = this.ellipsoid.name\n } else if (this.octahedron) {\n msg = this.octahedron.name\n } else if (this.point) {\n msg = this.point.name\n } else if (this.mesh) {\n msg = `mesh: ${this.mesh.name || this.mesh.serial} (${this.mesh.shape.name})`\n } else if (this.slice) {\n msg = `slice: ${this.slice.value.toPrecision(3)} (${this.slice.volume.name})`\n } else if (this.sphere) {\n msg = this.sphere.name\n } else if (this.surface) {\n msg = `surface: ${this.surface.surface.name}`\n } else if (this.tetrahedron) {\n msg = this.tetrahedron.name\n } else if (this.torus) {\n msg = this.torus.name\n } else if (this.unitcell) {\n msg = `unitcell: ${this.unitcell.unitcell.spacegroup} (${this.unitcell.structure.name})`\n } else if (this.unknown) {\n msg = 'unknown'\n } else if (this.volume) {\n msg = `volume: ${this.volume.value.toPrecision(3)} (${this.volume.volume.name})`\n } else if (this.wideline) {\n msg = this.wideline.name\n }\n return msg\n }\n}\n\nexport default PickingProxy\n","/**\n * @file Picking Controls\n * @author Alexander Rose \n * @private\n */\n\nimport PickingProxy from './picking-proxy'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\n\n/**\n * Picking controls\n */\nclass PickingControls {\n viewer: Viewer\n\n constructor (readonly stage: Stage) {\n this.viewer = stage.viewer\n }\n\n /**\n * get picking data\n * @param {Number} x - canvas x coordinate\n * @param {Number} y - canvas y coordinate\n * @return {PickingProxy|undefined} picking proxy\n */\n pick (x: number, y: number) {\n const pickingData = this.viewer.pick(x, y)\n\n if (pickingData.picker &&\n pickingData.picker.type !== 'ignore' &&\n pickingData.pid !== undefined\n ) {\n const pickerArray = pickingData.picker.array\n if (pickerArray && pickingData.pid >= pickerArray.length) {\n console.error('pid >= picker.array.length')\n } else {\n return new PickingProxy(pickingData, this.stage)\n }\n }\n }\n}\n\nexport default PickingControls\n","/**\n * @file Viewer Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector2, Vector3, Matrix4, Quaternion, OrthographicCamera } from 'three'\nimport * as signalsWrapper from 'signals'\n\nimport {\n ensureVector2, ensureVector3, ensureMatrix4, ensureQuaternion\n} from '../utils'\nimport { degToRad } from '../math/math-utils'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\n\n/**\n * Orientation matrix, a 4x4 transformation matrix with rotation part\n * used for scene rotation, scale part for scene camera distance and\n * position part for scene translation\n * @typedef {Matrix4} OrientationMatrix - orientation matrix\n */\n\nconst tmpQ = new Quaternion()\nconst tmpP = new Vector3()\nconst tmpS = new Vector3()\n\nconst tmpCanvasVector = new Vector3()\nconst tmpScaleVector = new Vector3()\nconst tmpRotateMatrix = new Matrix4()\nconst tmpRotateVector = new Vector3()\nconst tmpAlignMatrix = new Matrix4()\n\n/**\n * Viewer controls\n */\nclass ViewerControls {\n signals = {\n changed: new signalsWrapper.Signal()\n }\n\n viewer: Viewer\n\n /**\n * @param {Stage} stage - the stage object\n */\n constructor (readonly stage: Stage) {\n this.viewer = stage.viewer\n }\n\n /**\n * scene center position\n * @type {Vector3}\n */\n get position () {\n return this.viewer.translationGroup.position\n }\n\n /**\n * scene rotation\n * @type {Quaternion}\n */\n get rotation () {\n return this.viewer.rotationGroup.quaternion\n }\n\n /**\n * Trigger render and emit changed event\n * @emits {ViewerControls.signals.changed}\n * @return {undefined}\n */\n changed () {\n this.viewer.requestRender()\n this.signals.changed.dispatch()\n }\n\n getPositionOnCanvas (position: Vector3, optionalTarget?: Vector2) {\n const canvasPosition = ensureVector2(optionalTarget)\n const viewer = this.viewer\n\n tmpCanvasVector.copy(position)\n .add(viewer.translationGroup.position)\n .applyMatrix4(viewer.rotationGroup.matrix)\n .project(viewer.camera)\n\n return canvasPosition.set(\n (tmpCanvasVector.x + 1) * viewer.width / 2,\n (tmpCanvasVector.y + 1) * viewer.height / 2\n )\n }\n\n getCanvasScaleFactor (z = 0) {\n const camera = this.viewer.camera\n if (camera instanceof OrthographicCamera) {\n return 1 / camera.zoom\n } else {\n z = Math.abs(z)\n z += this.getCameraDistance()\n const fov = degToRad(camera.fov)\n const unitHeight = 2.0 * z * Math.tan(fov / 2)\n return unitHeight / this.viewer.height\n }\n }\n\n /**\n * get scene orientation\n * @param {Matrix4} optionalTarget - pre-allocated target matrix\n * @return {OrientationMatrix} scene orientation\n */\n getOrientation (optionalTarget?: Matrix4) {\n const m = ensureMatrix4(optionalTarget)\n\n m.copy(this.viewer.rotationGroup.matrix)\n const z = this.getCameraDistance()\n m.scale(tmpScaleVector.set(z, z, z))\n m.setPosition(this.viewer.translationGroup.position)\n\n return m\n }\n\n /**\n * set scene orientation\n * @param {OrientationMatrix|Array} orientation - scene orientation\n * @return {undefined}\n */\n orient (orientation?: Matrix4) {\n ensureMatrix4(orientation).decompose(tmpP, tmpQ, tmpS)\n\n const v = this.viewer\n v.rotationGroup.setRotationFromQuaternion(tmpQ)\n v.translationGroup.position.copy(tmpP)\n v.cameraDistance = tmpS.z\n v.updateZoom()\n this.changed()\n }\n\n /**\n * translate scene\n * @param {Vector3|Array} vector - translation vector\n * @return {undefined}\n */\n translate (vector: Vector3|number[]) {\n this.viewer.translationGroup.position\n .add(ensureVector3(vector))\n this.changed()\n }\n\n /**\n * center scene\n * @param {Vector3|Array} position - center position\n * @return {undefined}\n */\n center (position: Vector3|number[]) {\n this.viewer.translationGroup.position\n .copy(ensureVector3(position)).negate()\n this.changed()\n }\n\n /**\n * \"zoom\" scene by moving camera closer to origin\n * @param {Number} delta - zoom change\n * @return {undefined}\n */\n zoom (delta: number) {\n this.distance(this.getCameraDistance() * (1 - delta))\n }\n\n /**\n * get camera distance\n */\n getCameraDistance(): number {\n return this.viewer.cameraDistance\n }\n\n /**\n * camera distance\n * @param {Number} z - distance\n * @return {undefined}\n */\n distance (distance: number) {\n // Math.abs because distance used to be \"z\", normally negative.\n // Math.max to prevent us from getting _too_ close.\n this.viewer.cameraDistance = Math.max(Math.abs(distance), 0.2)\n this.viewer.updateZoom()\n this.changed()\n }\n\n /**\n * spin scene on axis\n * @param {Vector3|Array} axis - rotation axis\n * @param {Number} angle - amount to spin\n * @return {undefined}\n */\n spin (axis: Vector3|number[], angle: number) {\n tmpRotateMatrix.getInverse(this.viewer.rotationGroup.matrix)\n tmpRotateVector\n .copy(ensureVector3(axis)).applyMatrix4(tmpRotateMatrix)\n\n this.viewer.rotationGroup.rotateOnAxis(tmpRotateVector, angle)\n this.changed()\n }\n\n /**\n * rotate scene\n * @param {Quaternion|Array} quaternion - rotation quaternion\n * @return {undefined}\n */\n rotate (quaternion: Quaternion|number[]) {\n this.viewer.rotationGroup\n .setRotationFromQuaternion(ensureQuaternion(quaternion))\n this.changed()\n }\n\n /**\n * align scene to basis matrix\n * @param {Matrix4|Array} basis - basis matrix\n * @return {undefined}\n */\n align (basis: Matrix4|number[]) {\n tmpAlignMatrix.getInverse(ensureMatrix4(basis))\n\n this.viewer.rotationGroup.setRotationFromMatrix(tmpAlignMatrix)\n this.changed()\n }\n\n /**\n * apply rotation matrix to scene\n * @param {Matrix4|Array} matrix - rotation matrix\n * @return {undefined}\n */\n applyMatrix (matrix: Matrix4|number[]) {\n this.viewer.rotationGroup.applyMatrix4(ensureMatrix4(matrix))\n this.changed()\n }\n}\n\nexport default ViewerControls\n","/**\n * @file Animation\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Quaternion } from 'three'\n\nimport { defaults, ensureVector3, ensureQuaternion } from '../utils'\nimport { lerp, smoothstep } from '../math/math-utils'\nimport ViewerControls from '../controls/viewer-controls'\nimport Stats from '../viewer/stats'\n\n/**\n * Animation. Base animation class.\n * @interface\n */\nabstract class Animation {\n duration: number\n controls: ViewerControls\n\n alpha: number\n startTime: number\n\n pausedTime = -1\n elapsedDuration = 0\n pausedDuration = 0\n ignoreGlobalToggle = false\n\n private _paused = false\n private _resolveList: Function[] = []\n private _hold: boolean\n\n constructor (duration: number|undefined, controls: ViewerControls, ...args: any[]) {\n this.duration = defaults(duration, 1000)\n this.controls = controls\n\n this.startTime = window.performance.now()\n\n this._init(...args)\n }\n\n /**\n * True when animation has finished\n */\n get done () {\n return this.alpha === 1\n }\n\n /**\n * True when animation is paused\n */\n get paused () {\n return this._paused\n }\n\n /**\n * init animation\n */\n abstract _init (...args: any[]): void\n\n /**\n * called on every tick\n */\n abstract _tick (stats?: Stats): void\n\n tick (stats: Stats) {\n if (this._paused) return\n\n this.elapsedDuration = stats.currentTime - this.startTime - this.pausedDuration\n\n if (this.duration === 0) {\n this.alpha = 1\n } else {\n this.alpha = smoothstep(0, 1, this.elapsedDuration / this.duration)\n }\n\n this._tick(stats)\n\n if (this.done) {\n this._resolveList.forEach(resolve => resolve())\n }\n\n return this.done\n }\n\n /**\n * Pause animation\n * @param {boolean} [hold] - put animation on a hold which\n * must be release before it can be resumed\n */\n pause (hold?: boolean) {\n if (hold) this._hold = true\n\n if (this.pausedTime === -1) {\n this.pausedTime = window.performance.now()\n }\n this._paused = true\n }\n\n /**\n * Resume animation\n * @param {Boolean} [releaseHold] - release a hold on the animation\n */\n resume (releaseHold?: boolean) {\n if (!releaseHold && this._hold) return\n\n this.pausedDuration += window.performance.now() - this.pausedTime\n this._paused = false\n this._hold = false\n this.pausedTime = -1\n }\n\n /**\n * Toggle animation\n */\n toggle () {\n if (this._paused) {\n this.resume()\n } else {\n this.pause()\n }\n }\n\n /**\n * Promise-like interface\n */\n then (callback: Function) {\n let p: Promise\n\n if (this.done) {\n p = Promise.resolve()\n } else {\n p = new Promise(resolve => this._resolveList.push(resolve))\n }\n\n return p.then(callback as any)\n }\n}\n\nexport default Animation\n\n/**\n * Spin animation. Spin around an axis.\n */\nexport class SpinAnimation extends Animation {\n axis: Vector3\n angle: number\n\n constructor (duration: number|undefined, controls: ViewerControls, ...args: any[]) {\n super(defaults(duration, Infinity), controls, ...args)\n }\n\n _init (axis: number[]|Vector3, angle: number) {\n if (Array.isArray(axis)) {\n this.axis = new Vector3().fromArray(axis)\n } else {\n this.axis = defaults(axis, new Vector3(0, 1, 0))\n }\n this.angle = defaults(angle, 0.01)\n }\n\n _tick (stats: Stats) {\n if (!this.axis || !this.angle) return\n\n this.controls.spin(\n this.axis, this.angle * stats.lastDuration / 16\n )\n }\n}\n\n/**\n * Rock animation. Rock around an axis.\n */\nexport class RockAnimation extends Animation {\n axis: Vector3\n angleStep: number\n angleEnd: number\n angleSum = 0\n direction = 1\n\n constructor (duration: number|undefined, controls: ViewerControls, ...args: any[]) {\n super(defaults(duration, Infinity), controls, ...args)\n }\n\n _init (axis: number[]|Vector3, angleStep: number, angleEnd: number) {\n if (Array.isArray(axis)) {\n this.axis = new Vector3().fromArray(axis)\n } else {\n this.axis = defaults(axis, new Vector3(0, 1, 0))\n }\n this.angleStep = defaults(angleStep, 0.01)\n this.angleEnd = defaults(angleEnd, 0.2)\n }\n\n _tick (stats: Stats) {\n if (!this.axis || !this.angleStep || !this.angleEnd) return\n\n const alpha = smoothstep(\n 0, 1, Math.abs(this.angleSum) / this.angleEnd\n )\n const angle = this.angleStep * this.direction * (1.1 - alpha)\n\n this.controls.spin(\n this.axis, angle * stats.lastDuration / 16\n )\n\n this.angleSum += this.angleStep\n\n if (this.angleSum >= this.angleEnd) {\n this.direction *= -1\n this.angleSum = -this.angleEnd\n }\n }\n}\n\n/**\n * Move animation. Move from one position to another.\n */\nexport class MoveAnimation extends Animation {\n moveFrom: Vector3\n moveTo: Vector3\n\n _init (moveFrom: number[]|Vector3, moveTo: number[]|Vector3) {\n this.moveFrom = ensureVector3(defaults(moveFrom, new Vector3()))\n this.moveTo = ensureVector3(defaults(moveTo, new Vector3()))\n }\n\n _tick (/* stats */) {\n this.controls.position.lerpVectors(\n this.moveFrom, this.moveTo, this.alpha\n ).negate()\n this.controls.changed()\n }\n}\n\n/**\n * Zoom animation. Gradually change the zoom level.\n */\nexport class ZoomAnimation extends Animation {\n zoomFrom: number\n zoomTo: number\n\n _init (zoomFrom: number, zoomTo: number) {\n this.zoomFrom = zoomFrom\n this.zoomTo = zoomTo\n }\n\n _tick () {\n this.controls.distance(lerp(this.zoomFrom, this.zoomTo, this.alpha))\n }\n}\n\n/**\n * Rotate animation. Rotate from one orientation to another.\n */\nexport class RotateAnimation extends Animation {\n rotateFrom: Quaternion\n rotateTo: Quaternion\n\n private _currentRotation = new Quaternion()\n\n _init (rotateFrom: number[]|Quaternion, rotateTo: number[]|Quaternion) {\n this.rotateFrom = ensureQuaternion(rotateFrom)\n this.rotateTo = ensureQuaternion(rotateTo)\n\n this._currentRotation = new Quaternion()\n }\n\n _tick () {\n this._currentRotation\n .copy(this.rotateFrom)\n .slerp(this.rotateTo, this.alpha)\n\n this.controls.rotate(this._currentRotation)\n }\n}\n\n/**\n * Value animation. Call callback with interpolated value.\n */\nexport class ValueAnimation extends Animation {\n valueFrom: number\n valueTo: number\n callback: Function\n\n _init (valueFrom: number, valueTo: number, callback: Function) {\n this.valueFrom = valueFrom\n this.valueTo = valueTo\n\n this.callback = callback\n }\n\n _tick (/* stats */) {\n this.callback(lerp(this.valueFrom, this.valueTo, this.alpha))\n }\n}\n\n/**\n * Timeout animation. Call callback after duration.\n */\nexport class TimeoutAnimation extends Animation {\n callback: Function\n\n _init (callback: Function) {\n this.callback = callback\n }\n\n _tick () {\n if (this.alpha === 1) this.callback()\n }\n}\n\n/**\n * Animation list.\n */\nexport class AnimationList {\n _list: Animation[]\n _resolveList: Function[] = []\n\n constructor (list: Animation[] = []) {\n this._list = list\n }\n\n /**\n * True when all animations have finished\n */\n get done () {\n return this._list.every(animation => {\n return animation.done\n })\n }\n\n /**\n * Promise-like interface\n */\n then (callback: Function) {\n let p: Promise\n\n if (this.done) {\n p = Promise.resolve()\n } else {\n p = new Promise(resolve => {\n this._resolveList.push(resolve)\n this._list.forEach(animation => {\n animation.then(() => {\n this._resolveList.forEach(callback => {\n callback()\n })\n this._resolveList.length = 0\n })\n })\n })\n }\n\n return p.then(callback as any)\n }\n}\n","/**\n * @file Animation Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Quaternion, Matrix4 } from 'three'\n\nimport { ensureMatrix4 } from '../utils'\nimport Animation, {\n SpinAnimation, RockAnimation, MoveAnimation, ZoomAnimation,\n RotateAnimation, ValueAnimation, TimeoutAnimation, AnimationList\n} from '../animation/animation'\nimport Stage from '../stage/stage'\nimport Component from '../component/component'\nimport Viewer from '../viewer/viewer'\nimport Stats from '../viewer/stats'\nimport ViewerControls from './viewer-controls'\n\n/**\n * Animation controls\n */\nclass AnimationControls {\n viewer: Viewer\n controls: ViewerControls\n\n animationList: Animation[] = []\n finishedList: Animation[] = []\n\n /**\n * Create animation controls\n * @param {Stage} stage - the stage object\n */\n constructor (readonly stage: Stage) {\n this.viewer = stage.viewer\n this.controls = stage.viewerControls\n }\n\n /**\n * True when all animations are paused\n * @type {Boolean}\n */\n get paused () {\n return this.animationList.every((animation: Animation) => animation.paused)\n }\n\n /**\n * Add an animation\n */\n add (animation: Animation) {\n if (animation.duration === 0) {\n animation.tick(this.viewer.stats)\n } else {\n this.animationList.push(animation)\n }\n\n return animation\n }\n\n /**\n * Remove an animation\n */\n remove (animation: Animation) {\n const list = this.animationList\n const index = list.indexOf(animation)\n\n if (index > -1) {\n list.splice(index, 1)\n }\n }\n\n /**\n * Run all animations\n */\n run (stats: Stats) {\n const finishedList = this.finishedList\n const animationList = this.animationList\n\n const n = animationList.length\n for (let i = 0; i < n; ++i) {\n const animation = animationList[ i ]\n // tick returns true when finished\n if (animation.tick(stats)) {\n finishedList.push(animation)\n }\n }\n\n const m = finishedList.length\n if (m) {\n for (let j = 0; j < m; ++j) {\n this.remove(finishedList[ j ])\n }\n finishedList.length = 0\n }\n }\n\n /**\n * Add a spin animation\n * @param {Vector3} axis - axis to spin around\n * @param {Number} angle - amount to spin per frame, radians\n * @param {Number} duration - animation time in milliseconds\n * @return {SpinAnimation} the animation\n */\n spin (axis: Vector3|number[], angle?: number, duration?: number) {\n return this.add(\n new SpinAnimation(duration, this.controls, axis, angle)\n )\n }\n\n /**\n * Add a rock animation\n * @param {Vector3} axis - axis to rock around\n * @param {Number} angle - amount to spin per frame, radians\n * @param {Number} end - maximum extend of motion, radians\n * @param {Number} duration - animation time in milliseconds\n * @return {SpinAnimation} the animation\n */\n rock (axis: Vector3|number[], angle?: number, end?: number, duration?: number) {\n return this.add(\n new RockAnimation(duration, this.controls, axis, angle, end)\n )\n }\n\n /**\n * Add a rotate animation\n * @param {Quaternion} rotateTo - target rotation\n * @param {Number} duration - animation time in milliseconds\n * @return {RotateAnimation} the animation\n */\n rotate (rotateTo: Quaternion|number[], duration?: number) {\n const rotateFrom = this.viewer.rotationGroup.quaternion.clone()\n\n return this.add(\n new RotateAnimation(duration, this.controls, rotateFrom, rotateTo)\n )\n }\n\n /**\n * Add a move animation\n * @param {Vector3} moveTo - target position\n * @param {Number} duration - animation time in milliseconds\n * @return {MoveAnimation} the animation\n */\n move (moveTo: Vector3|number[], duration?: number) {\n const moveFrom = this.controls.position.clone().negate()\n\n return this.add(\n new MoveAnimation(duration, this.controls, moveFrom, moveTo)\n )\n }\n\n /**\n * Add a zoom animation\n * @param {Number} zoomTo - target distance\n * @param {Number} duration - animation time in milliseconds\n * @return {ZoomAnimation} the animation\n */\n zoom (zoomTo: number, duration?: number) {\n const zoomFrom = this.viewer.camera.position.z\n\n return this.add(\n new ZoomAnimation(duration, this.controls, zoomFrom, zoomTo)\n )\n }\n\n /**\n * Add a zoom and a move animation\n * @param {Vector3} moveTo - target position\n * @param {Number} zoomTo - target distance\n * @param {Number} duration - animation time in milliseconds\n * @return {Array} the animations\n */\n zoomMove (moveTo: Vector3, zoomTo: number, duration?: number) {\n return new AnimationList([\n this.move(moveTo, duration),\n this.zoom(zoomTo, duration)\n ])\n }\n\n /**\n * Add an orient animation\n * @param {OrientationMatrix|Array} orientTo - target orientation\n * @param {Number} duration - animation time in milliseconds\n * @return {Array} the animations\n */\n orient (orientTo: Matrix4|number[], duration?: number) {\n const p = new Vector3()\n const q = new Quaternion()\n const s = new Vector3()\n\n ensureMatrix4(orientTo).decompose(p, q, s)\n\n return new AnimationList([\n this.move(p.negate(), duration),\n this.rotate(q, duration),\n this.zoom(-s.x, duration)\n ])\n }\n\n /**\n * Add a value animation\n * @param {Number} valueFrom - start value\n * @param {Number} valueTo - target value\n * @param {Function} callback - called on every tick\n * @param {Number} duration - animation time in milliseconds\n * @return {ValueAnimation} the animation\n */\n value (valueFrom: number, valueTo: number, callback: Function, duration?: number) {\n return this.add(\n new ValueAnimation(duration, this.controls, valueFrom, valueTo, callback)\n )\n }\n\n /**\n * Add a timeout animation\n * @param {Function} callback - called after duration\n * @param {Number} duration - timeout in milliseconds\n * @return {TimeoutAnimation} the animation\n */\n timeout (callback: Function, duration?: number) {\n return this.add(\n new TimeoutAnimation(duration, this.controls, callback)\n )\n }\n\n /**\n * Add a component spin animation\n * @param {Component} component - object to move\n * @param {Vector3} axis - axis to spin around\n * @param {Number} angle - amount to spin per frame, radians\n * @param {Number} duration - animation time in milliseconds\n * @return {SpinAnimation} the animation\n */\n spinComponent (component: Component, axis?: Vector3|number[], angle?: number, duration?: number) {\n return this.add(\n // TODO\n new SpinAnimation(duration, component.controls as any, axis, angle)\n )\n }\n\n /**\n * Add a component rock animation\n * @param {Component} component - object to move\n * @param {Vector3} axis - axis to rock around\n * @param {Number} angle - amount to spin per frame, radians\n * @param {Number} end - maximum extend of motion, radians\n * @param {Number} duration - animation time in milliseconds\n * @return {SpinAnimation} the animation\n */\n rockComponent (component: Component, axis: Vector3|number[], angle?: number, end?: number, duration?: number) {\n return this.add(\n // TODO\n new RockAnimation(duration, component.controls as any, axis, angle, end)\n )\n }\n\n /**\n * Add a component move animation\n * @param {Component} component - object to move\n * @param {Vector3} moveTo - target position\n * @param {Number} duration - animation time in milliseconds\n * @return {MoveAnimation} the animation\n */\n moveComponent (component: Component, moveTo: Vector3|number[], duration?: number) {\n const moveFrom = component.controls.position.clone().negate()\n\n return this.add(\n // TODO\n new MoveAnimation(duration, component.controls as any, moveFrom, moveTo)\n )\n }\n\n /**\n * Pause all animations\n * @return {undefined}\n */\n pause () {\n this.animationList.forEach(animation => animation.pause())\n }\n\n /**\n * Resume all animations\n * @return {undefined}\n */\n resume () {\n this.animationList.forEach(animation => animation.resume())\n }\n\n /**\n * Toggle all animations\n * @return {undefined}\n */\n toggle () {\n if (this.paused) {\n this.resume()\n } else {\n this.pause()\n }\n }\n\n /**\n * Clear all animations\n * @return {undefined}\n */\n clear () {\n this.animationList.length = 0\n }\n\n dispose () {\n this.clear()\n }\n}\n\nexport default AnimationControls\n","/**\n * @file Queue\n * @author Alexander Rose \n * @private\n */\n\nclass Queue {\n queue: T[] = []\n pending = false\n\n constructor(readonly fn: Function, argList?: T[]) {\n this.next = this.next.bind(this)\n\n if (argList) {\n for (let i = 0, il = argList.length; i < il; ++i) {\n this.queue.push(argList[ i ])\n }\n this.next()\n }\n }\n\n private run (arg: any) {\n this.fn(arg, this.next)\n }\n\n private next () {\n const arg = this.queue.shift()\n if (arg !== undefined) {\n this.pending = true\n setTimeout(() => this.run(arg))\n } else {\n this.pending = false\n }\n }\n\n push (arg: T) {\n this.queue.push(arg)\n if (!this.pending) this.next()\n }\n\n kill () {\n this.queue.length = 0\n }\n\n length () {\n return this.queue.length\n }\n}\n\nexport default Queue\n","/**\n * @file Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { Color, Vector3, Matrix4 } from 'three'\n\nimport { Debug, Log, ColormakerRegistry, ExtensionFragDepth } from '../globals'\nimport { defaults } from '../utils'\nimport Queue from '../utils/queue'\nimport Counter from '../utils/counter'\nimport Viewer from '../viewer/viewer'\nimport { BufferParameters, BufferSide, default as Buffer } from '../buffer/buffer';\nimport { ColorData, ColormakerParameters, ColorMode } from '../color/colormaker';\nimport { GenericColor } from '../types'\n\nexport interface RepresentationParameters {\n name: string\n lazy: boolean,\n clipNear: number,\n clipRadius: number,\n clipCenter: Vector3,\n flatShaded: boolean,\n opacity: number,\n depthWrite: boolean,\n side: BufferSide,\n wireframe: boolean,\n colorData: ColorData,\n colorScheme: string,\n colorScale: string | number[],\n colorReverse: boolean,\n colorValue: GenericColor,\n colorDomain: number[],\n colorMode: ColorMode,\n colorSpace: 'sRGB' | 'linear',\n roughness: number,\n metalness: number,\n diffuse: GenericColor,\n diffuseInterior: boolean,\n useInteriorColor: boolean,\n interiorColor: GenericColor,\n interiorDarkening: number,\n disablePicking: boolean,\n matrix: Matrix4\n quality: string,\n visible: boolean,\n color: GenericColor,\n sphereDetail: number,\n radialSegments: number,\n openEnded: boolean\n disableImpostor: boolean\n [key: string]: any//boolean | number | undefined | Color | string | Vector3 | Matrix4 | number[]\n}\n/**\n * Representation parameter object.\n * @typedef {Object} RepresentationParameters - representation parameters\n * @property {Boolean} [lazy] - only build & update the representation when visible\n * otherwise defer changes until set visible again\n * @property {Integer} [clipNear] - position of camera near/front clipping plane\n * in percent of scene bounding box\n * @property {Integer} [clipRadius] - radius of clipping sphere\n * @property {Vector3} [clipCenter] - position of for spherical clipping\n * @property {Boolean} [flatShaded] - render flat shaded\n * @property {Float} [opacity] - translucency: 1 is fully opaque, 0 is fully transparent\n * @property {Boolean} [depthWrite] - depth write\n * @property {String} [side] - which triangle sides to render, \"front\" front-side,\n * \"back\" back-side, \"double\" front- and back-side\n * @property {Boolean} [wireframe] - render as wireframe\n * @property {ColorData} [colorData] - atom or bond indexed data for coloring\n * @property {String} [colorScheme] - color scheme\n * @property {String} [colorScale] - color scale, either a string for a\n * predefined scale or an array of\n * colors to be used as the scale\n * @property {Boolean} [colorReverse] - reverse color scale\n * @property {Color} [colorValue] - color value\n * @property {Integer[]} [colorDomain] - scale value range\n * @property {Integer} colorDomain.0 - min value\n * @property {Integer} colorDomain.1 - max value\n * @property {String} [colorMode] - color mode, one of rgb, hsv, hsl, hsi, lab, hcl\n * @property {Float} [roughness] - how rough the material is, between 0 and 1\n * @property {Float} [metalness] - how metallic the material is, between 0 and 1\n * @property {Color} [diffuse] - diffuse color for lighting\n * @property {Boolean} [diffuseInterior] - diffuse interior, i.e. ignore normal\n * @property {Boolean} [useInteriorColor] - use interior color\n * @property {Color} [interiorColor] - interior color\n * @property {Float} [interiorDarkening] - interior darkening: 0 no darking, 1 fully darkened\n * @property {Boolean} [disablePicking] - disable picking\n */\n\n/**\n * Representation object\n * @interface\n * @param {Object} object - the object to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {RepresentationParameters} [params] - representation parameters\n */\nclass Representation {\n parameters: any\n type: string\n viewer: Viewer\n tasks: Counter\n private queue: Queue\n bufferList: Buffer[]\n\n lazy: boolean\n lazyProps: { build: boolean, bufferParams: BufferParameters | {}, what: {}}\n protected name: string\n protected clipNear: number\n protected clipRadius: number\n protected clipCenter: Vector3\n protected flatShaded: boolean\n protected opacity: number\n protected depthWrite: boolean\n protected side: BufferSide\n protected wireframe: boolean\n protected colorData: ColorData\n protected colorScheme: string\n protected colorScale: string | string[]\n protected colorReverse: boolean\n protected colorValue: number\n protected colorDomain: number[]\n protected colorMode: ColorMode\n protected roughness: number\n protected metalness: number\n protected diffuse: GenericColor\n protected diffuseInterior?: boolean\n protected useInteriorColor?: boolean\n protected interiorColor: GenericColor\n protected interiorDarkening: number\n protected disablePicking: boolean\n protected sphereDetail: number\n protected radialSegments: number\n protected openEnded: boolean\n protected disableImpostor: boolean\n protected disposed: boolean\n\n protected matrix: Matrix4\n\n private quality: string\n visible: boolean\n\n protected manualAttach: ()=> any\n\n protected toBePrepared: boolean\n\n [key: string]: any\n\n constructor (object: any, viewer: Viewer, params: Partial) {\n // eslint-disable-next-line no-unused-vars\n // const p = params || {}\n\n this.type = ''\n\n this.parameters = {\n\n lazy: {\n type: 'boolean'\n },\n\n clipNear: {\n type: 'range', step: 1, max: 100, min: 0, buffer: true\n },\n clipRadius: {\n type: 'number', precision: 1, max: 1000, min: 0, buffer: true\n },\n clipCenter: {\n type: 'vector3', precision: 1, buffer: true\n },\n flatShaded: {\n type: 'boolean', buffer: true\n },\n opacity: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n depthWrite: {\n type: 'boolean', buffer: true\n },\n side: {\n type: 'select',\n buffer: true,\n options: { front: 'front', back: 'back', double: 'double' }\n },\n wireframe: {\n type: 'boolean', buffer: true\n },\n\n colorData: {\n type: 'hidden',\n update: 'color',\n },\n\n colorScheme: {\n type: 'select',\n update: 'color',\n options: {}\n },\n colorScale: {\n type: 'select',\n update: 'color',\n options: ColormakerRegistry.getScales()\n },\n colorReverse: {\n type: 'boolean', update: 'color'\n },\n colorValue: {\n type: 'color', update: 'color'\n },\n colorDomain: {\n type: 'hidden', update: 'color'\n },\n colorMode: {\n type: 'select',\n update: 'color',\n options: ColormakerRegistry.getModes()\n },\n\n roughness: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n metalness: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n diffuse: {\n type: 'color', buffer: true\n },\n\n diffuseInterior: {\n type: 'boolean', buffer: true\n },\n useInteriorColor: {\n type: 'boolean', buffer: true\n },\n interiorColor: {\n type: 'color', buffer: true\n },\n interiorDarkening: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n\n matrix: {\n type: 'hidden', buffer: true\n },\n\n disablePicking: {\n type: 'boolean', rebuild: true\n }\n\n }\n\n /**\n * @type {Viewer}\n */\n this.viewer = viewer\n\n /**\n * Counter that keeps track of tasks related to the creation of\n * the representation, including surface calculations.\n * @type {Counter}\n */\n this.tasks = new Counter()\n\n /**\n * @type {Queue}\n * @private\n */\n this.queue = new Queue(this.make.bind(this))\n\n /**\n * @type {Array}\n * @private\n */\n this.bufferList = []\n\n if (this.parameters.colorScheme) {\n this.parameters.colorScheme.options = ColormakerRegistry.getSchemes()\n }\n\n this.toBePrepared = false\n }\n\n init (params: Partial) {\n const p = params || {}\n\n this.clipNear = defaults(p.clipNear, 0)\n this.clipRadius = defaults(p.clipRadius, 0)\n this.clipCenter = defaults(p.clipCenter, new Vector3())\n this.flatShaded = defaults(p.flatShaded, false)\n this.side = defaults(p.side, 'double')\n this.opacity = defaults(p.opacity, 1.0)\n this.depthWrite = defaults(p.depthWrite, true)\n this.wireframe = defaults(p.wireframe, false)\n\n this.setColor(p.color, p)\n\n this.colorData = defaults(p.colorData, undefined)\n this.colorScheme = defaults(p.colorScheme, 'uniform')\n this.colorScale = defaults(p.colorScale, '')\n this.colorReverse = defaults(p.colorReverse, false)\n this.colorValue = defaults(p.colorValue, 0x909090)\n this.colorDomain = defaults(p.colorDomain, undefined)\n this.colorMode = defaults(p.colorMode, 'hcl')\n\n this.visible = defaults(p.visible, true)\n this.quality = defaults(p.quality, undefined)\n\n this.roughness = defaults(p.roughness, 0.4)\n this.metalness = defaults(p.metalness, 0.0)\n this.diffuse = defaults(p.diffuse, 0xffffff)\n\n this.diffuseInterior = defaults(p.diffuseInterior, false)\n this.useInteriorColor = defaults(p.useInteriorColor, false)\n this.interiorColor = defaults(p.interiorColor, 0x222222)\n this.interiorDarkening = defaults(p.interiorDarkening, 0)\n\n this.lazy = defaults(p.lazy, false)\n this.lazyProps = {\n build: false,\n bufferParams: {},\n what: {}\n }\n\n this.matrix = defaults(p.matrix, new Matrix4())\n\n this.disablePicking = defaults(p.disablePicking, false)\n\n // handle common parameters when applicable\n\n const tp = this.parameters\n\n if (tp.sphereDetail === true) {\n tp.sphereDetail = {\n type: 'integer', max: 3, min: 0, rebuild: 'impostor'\n }\n }\n if (tp.radialSegments === true) {\n tp.radialSegments = {\n type: 'integer', max: 25, min: 5, rebuild: 'impostor'\n }\n }\n if (tp.openEnded === true) {\n tp.openEnded = {\n type: 'boolean', rebuild: 'impostor', buffer: true\n }\n }\n if (tp.disableImpostor === true) {\n tp.disableImpostor = {\n type: 'boolean', rebuild: true\n }\n }\n\n if (p.quality === 'low') {\n if (tp.sphereDetail) this.sphereDetail = 0\n if (tp.radialSegments) this.radialSegments = 5\n } else if (p.quality === 'medium') {\n if (tp.sphereDetail) this.sphereDetail = 1\n if (tp.radialSegments) this.radialSegments = 10\n } else if (p.quality === 'high') {\n if (tp.sphereDetail) this.sphereDetail = 2\n if (tp.radialSegments) this.radialSegments = 20\n } else {\n if (tp.sphereDetail) {\n this.sphereDetail = defaults(p.sphereDetail, 1)\n }\n if (tp.radialSegments) {\n this.radialSegments = defaults(p.radialSegments, 10)\n }\n }\n\n if (tp.openEnded) {\n this.openEnded = defaults(p.openEnded, true)\n }\n\n if (tp.disableImpostor) {\n this.disableImpostor = defaults(p.disableImpostor, false)\n }\n\n }\n\n getColorParams (p?: {[k: string]: any}): { scheme: string, [k: string]: any } & ColormakerParameters {\n return Object.assign({\n\n data: this.colorData,\n scheme: this.colorScheme,\n scale: this.colorScale,\n reverse: this.colorReverse,\n value: this.colorValue,\n domain: this.colorDomain,\n mode: this.colorMode,\n colorSpace: this.colorSpace,\n\n }, p)\n }\n\n getBufferParams (p: {[k: string]: any} = {}) {\n return Object.assign({\n\n clipNear: this.clipNear,\n clipRadius: this.clipRadius,\n clipCenter: this.clipCenter,\n flatShaded: this.flatShaded,\n opacity: this.opacity,\n depthWrite: this.depthWrite,\n side: this.side,\n wireframe: this.wireframe,\n\n roughness: this.roughness,\n metalness: this.metalness,\n diffuse: this.diffuse,\n\n diffuseInterior: this.diffuseInterior,\n useInteriorColor: this.useInteriorColor,\n interiorColor: this.interiorColor,\n interiorDarkening: this.interiorDarkening,\n\n matrix: this.matrix,\n\n disablePicking: this.disablePicking\n\n }, p)\n }\n\n setColor (value: number | string | Color | undefined , p?: Partial) {\n const types = Object.keys(ColormakerRegistry.getSchemes())\n\n if (typeof value === 'string' && types.includes(value.toLowerCase())) {\n if (p) {\n p.colorScheme = value\n } else {\n this.setParameters({ colorScheme: value })\n }\n } else if (value !== undefined) {\n let val = new Color(value as string).getHex() //TODO\n if (p) {\n p.colorScheme = 'uniform'\n p.colorValue = val\n } else {\n this.setParameters({\n colorScheme: 'uniform', colorValue: val\n })\n }\n }\n\n return this\n }\n\n // TODO\n prepare (cb: ()=> void) {\n\n }\n\n create () {\n // this.bufferList.length = 0;\n }\n\n update (what?: any) {\n this.build()\n }\n\n build (updateWhat?: {[k: string]: boolean}) {\n if (this.lazy && (!this.visible || !this.opacity)) {\n this.lazyProps.build = true\n return\n }\n\n if (!this.toBePrepared) {\n this.tasks.increment()\n this.make()\n return\n }\n\n // don't let tasks accumulate\n if (this.queue.length() > 0) {\n this.tasks.change(1 - this.queue.length())\n this.queue.kill()\n } else {\n this.tasks.increment()\n }\n\n this.queue.push(updateWhat || false)\n }\n\n make (updateWhat?: boolean, callback?: () => void) {\n if (Debug) Log.time('Representation.make ' + this.type)\n\n const _make = () => {\n if (updateWhat) {\n this.update(updateWhat)\n this.viewer.requestRender()\n this.tasks.decrement()\n if (callback) callback()\n } else {\n this.clear()\n this.create()\n if (!this.manualAttach && !this.disposed) {\n if (Debug) Log.time('Representation.attach ' + this.type)\n this.attach(() => {\n if (Debug) Log.timeEnd('Representation.attach ' + this.type)\n this.tasks.decrement()\n if (callback) callback()\n })\n }\n }\n\n if (Debug) Log.timeEnd('Representation.make ' + this.type)\n }\n\n if (this.toBePrepared) {\n this.prepare(_make)\n } else {\n _make()\n }\n }\n\n attach (callback: () => void) {\n this.setVisibility(this.visible)\n\n callback()\n }\n\n /**\n * Set the visibility of the representation\n * @param {Boolean} value - visibility flag\n * @param {Boolean} [noRenderRequest] - whether or not to request a re-render from the viewer\n * @return {Representation} this object\n */\n setVisibility (value: boolean, noRenderRequest?: boolean): Representation {\n this.visible = value\n\n if (this.visible && this.opacity) {\n const lazyProps = this.lazyProps\n const bufferParams = lazyProps.bufferParams\n const what = lazyProps.what\n\n if (lazyProps.build) {\n lazyProps.build = false\n this.build()\n return this\n } else if (Object.keys(bufferParams).length || Object.keys(what).length) {\n lazyProps.bufferParams = {}\n lazyProps.what = {}\n this.updateParameters(bufferParams, what)\n }\n }\n\n this.bufferList.forEach(function (buffer) {\n buffer.setVisibility(value)\n })\n\n if (!noRenderRequest) this.viewer.requestRender()\n\n return this\n }\n\n /**\n * Set the visibility of the representation\n * @param {RepresentationParameters} params - parameters object\n * @param {Object} [what] - buffer data attributes to be updated,\n * note that this needs to be implemented in the\n * derived classes. Generally it allows more\n * fine-grained control over updating than\n * forcing a rebuild.\n * @param {Boolean} what.position - update position data\n * @param {Boolean} what.color - update color data\n * @param {Boolean} [rebuild] - whether or not to rebuild the representation\n * @return {Representation} this object\n */\n setParameters (params: Partial, what:{[propName: string]: any} = {}, rebuild = false) {\n const p = params || {}\n const tp = this.parameters\n const bufferParams: BufferParameters = {}\n\n if (!this.opacity && p.opacity !== undefined) {\n if (this.lazyProps.build) {\n this.lazyProps.build = false\n rebuild = true\n } else {\n Object.assign(bufferParams, this.lazyProps.bufferParams)\n Object.assign(what, this.lazyProps.what)\n this.lazyProps.bufferParams = {}\n this.lazyProps.what = {}\n }\n }\n\n this.setColor(p.color, p)\n\n for (let name in p) {\n if (p[ name ] === undefined) continue\n if (tp[ name ] == undefined ) continue // Skip nulls as well as undefined\n\n if (tp[ name ].int) p[ name ] = parseInt(p[ name ] as string)\n if (tp[ name ].float) p[ name ] = parseFloat(p[ name ] as string)\n\n // no value change\n if (p[ name ] === this[ name ] && (\n !p[ name ].equals || p[ name ].equals(this[ name ])\n )) continue\n\n if (this[ name ] && this[ name ].copy && p[ name ].copy) {\n this[ name ].copy(p[ name ])\n } else if (this[ name ] && this[ name ].set) {\n this[ name ].set(p[ name ])\n } else {\n this[ name ] = p[ name ]\n }\n\n // buffer param\n if (tp[ name ].buffer) {\n if (tp[ name ].buffer === true) {\n (bufferParams[ name as keyof BufferParameters ] as any) = p[ name ]\n } else {\n let key: (keyof BufferParameters) = tp[ name ].buffer;\n (bufferParams[ key ] as any) = p[ name ]\n }\n }\n\n // mark for update\n if (tp[ name ].update) {\n what[ tp[ name ].update ] = true\n }\n\n // mark for rebuild\n if (tp[ name ].rebuild &&\n !(tp[ name ].rebuild === 'impostor' &&\n ExtensionFragDepth && !this.disableImpostor)\n ) {\n rebuild = true\n }\n }\n\n //\n\n if (rebuild) {\n this.build()\n } else {\n this.updateParameters(bufferParams, what)\n }\n\n return this\n }\n\n updateParameters (bufferParams: BufferParameters | {} = {}, what?: any) {\n if (this.lazy && (!this.visible || !this.opacity) && bufferParams.hasOwnProperty('opacity') === false) {\n Object.assign(this.lazyProps.bufferParams, bufferParams)\n Object.assign(this.lazyProps.what, what)\n return\n }\n\n this.bufferList.forEach(function (buffer) {\n buffer.setParameters(bufferParams)\n })\n\n if (Object.keys(what).length) {\n this.update(what) // update buffer attribute\n }\n\n this.viewer.requestRender()\n }\n\n getParameters () {\n const params: Partial = {\n lazy: this.lazy,\n visible: this.visible,\n quality: this.quality\n }\n\n Object.keys(this.parameters).forEach(name => {\n if (this.parameters[ name ] !== null) {\n params[ name ] = this[ name ]\n }\n })\n\n return params\n }\n\n clear () {\n this.bufferList.forEach(buffer => {\n this.viewer.remove(buffer)\n buffer.dispose()\n })\n this.bufferList.length = 0\n\n this.viewer.requestRender()\n }\n\n dispose () {\n this.disposed = true\n this.queue.kill()\n this.tasks.dispose()\n this.clear()\n }\n}\n\nexport default Representation\n","/**\n * @file Worker\n * @author Alexander Rose \n * @private\n */\n\nimport { Log, Debug, WorkerRegistry } from '../globals'\n\nexport default class _Worker {\n\n pending = 0\n postCount = 0\n onmessageDict: { [k: number]: Function|undefined } = {}\n onerrorDict: { [k: number]: Function|undefined } = {}\n\n name: string\n blobUrl: string\n worker: Worker\n\n constructor (name: string) {\n\n this.name = name\n this.blobUrl = window.URL.createObjectURL(WorkerRegistry.get(name))\n this.worker = new Worker(this.blobUrl)\n\n WorkerRegistry.activeWorkerCount += 1\n\n this.worker.onmessage = (event: any) => {\n this.pending -= 1\n const postId = event.data.__postId\n\n if (Debug) Log.timeEnd('Worker.postMessage ' + name + ' #' + postId)\n\n const onmessage = this.onmessageDict[ postId ]\n if (onmessage) {\n onmessage.call(this.worker, event)\n } else {\n // Log.debug('No onmessage', postId, name)\n }\n\n delete this.onmessageDict[ postId ]\n delete this.onerrorDict[ postId ]\n }\n\n this.worker.onerror = (event: any) => {\n this.pending -= 1\n if (event.data) {\n const postId = event.data.__postId\n\n const onerror = this.onerrorDict[ postId ]\n if (onerror) {\n onerror.call(this.worker, event)\n } else {\n Log.error('Worker.onerror', postId, name, event)\n }\n\n delete this.onmessageDict[ postId ]\n delete this.onerrorDict[ postId ]\n } else {\n Log.error('Worker.onerror', name, event)\n }\n }\n }\n\n post (aMessage: any = {}, transferList?: any, onmessage?: Function, onerror?: Function) {\n this.onmessageDict[ this.postCount ] = onmessage\n this.onerrorDict[ this.postCount ] = onerror\n\n aMessage.__name = this.name\n aMessage.__postId = this.postCount\n aMessage.__debug = Debug\n\n if (Debug) Log.time(`Worker.postMessage ${this.name} #${this.postCount}`)\n\n try {\n this.worker.postMessage(aMessage, transferList)\n } catch (error) {\n Log.error('worker.post:', error)\n this.worker.postMessage(aMessage)\n }\n\n this.pending += 1\n this.postCount += 1\n\n return this\n }\n\n terminate () {\n if (this.worker) {\n this.worker.terminate()\n window.URL.revokeObjectURL(this.blobUrl)\n WorkerRegistry.activeWorkerCount -= 1\n } else {\n Log.log('no worker to terminate')\n }\n }\n}\n","/**\n * @file Worker Pool\n * @author Alexander Rose \n * @private\n */\n\nimport Worker from './worker'\n\nclass WorkerPool {\n maxCount: number\n pool: Worker[] = []\n count = 0\n name: string\n\n constructor (name: string, maxCount = 2) {\n this.maxCount = Math.min(8, maxCount)\n this.name = name\n }\n\n post (aMessage: any = {}, transferList?: any, onmessage?: Function, onerror?: Function) {\n const worker = this.getNextWorker()\n if (worker) {\n worker.post(aMessage, transferList, onmessage, onerror)\n } else {\n console.error('unable to get worker from pool')\n }\n\n return this\n }\n\n terminate () {\n this.pool.forEach(function (worker) {\n worker.terminate()\n })\n }\n\n getNextWorker () {\n let nextWorker\n let minPending = Infinity\n\n for (let i = 0; i < this.maxCount; ++i) {\n if (i >= this.count) {\n nextWorker = new Worker(this.name)\n this.pool.push(nextWorker)\n this.count += 1\n break\n }\n\n const worker = this.pool[ i ]\n\n if (worker.pending === 0) {\n nextWorker = worker\n break\n } else if (worker.pending < minPending) {\n minPending = worker.pending\n nextWorker = worker\n }\n }\n\n return nextWorker\n }\n}\n\nWorkerPool.prototype.constructor = WorkerPool\n\nexport default WorkerPool\n","/**\n * @file Vector Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { NumberArray } from '../types'\nimport { EPS } from './math-constants'\n\n/**\n * Calculate the two intersection points\n * Converted to JavaScript from\n * {@link http://paulbourke.net/geometry/pointlineplane/lineline.c}\n */\nexport function lineLineIntersect (p1: Vector3, p2: Vector3, p3: Vector3, p4: Vector3) {\n const p13 = new Vector3()\n const p43 = new Vector3()\n const p21 = new Vector3()\n let d1343, d4321, d1321, d4343, d2121\n let denom, numer\n\n p13.x = p1.x - p3.x\n p13.y = p1.y - p3.y\n p13.z = p1.z - p3.z\n p43.x = p4.x - p3.x\n p43.y = p4.y - p3.y\n p43.z = p4.z - p3.z\n if (Math.abs(p43.x) < EPS && Math.abs(p43.y) < EPS && Math.abs(p43.z) < EPS) { return null }\n\n p21.x = p2.x - p1.x\n p21.y = p2.y - p1.y\n p21.z = p2.z - p1.z\n if (Math.abs(p21.x) < EPS && Math.abs(p21.y) < EPS && Math.abs(p21.z) < EPS) { return null }\n\n d1343 = p13.x * p43.x + p13.y * p43.y + p13.z * p43.z\n d4321 = p43.x * p21.x + p43.y * p21.y + p43.z * p21.z\n d1321 = p13.x * p21.x + p13.y * p21.y + p13.z * p21.z\n d4343 = p43.x * p43.x + p43.y * p43.y + p43.z * p43.z\n d2121 = p21.x * p21.x + p21.y * p21.y + p21.z * p21.z\n\n denom = d2121 * d4343 - d4321 * d4321\n if (Math.abs(denom) < EPS) { return null }\n numer = d1343 * d4321 - d1321 * d4343\n\n const mua = numer / denom\n const mub = (d1343 + d4321 * mua) / d4343\n\n const pa = new Vector3(\n p1.x + mua * p21.x,\n p1.y + mua * p21.y,\n p1.z + mua * p21.z\n )\n const pb = new Vector3(\n p3.x + mub * p43.x,\n p3.y + mub * p43.y,\n p3.z + mub * p43.z\n )\n\n return [ pa, pb ]\n}\n\nexport function calculateMeanVector3 (array: NumberArray) {\n const n = array.length\n const m = n / 3\n\n let x = 0\n let y = 0\n let z = 0\n\n for (let i = 0; i < n; i += 3) {\n x += array[ i + 0 ]\n y += array[ i + 1 ]\n z += array[ i + 2 ]\n }\n\n return new Vector3(x / m, y / m, z / m)\n}\n\nexport function isPointOnSegment (p: Vector3, l1: Vector3, l2: Vector3) {\n const len = l1.distanceTo(l2)\n\n return p.distanceTo(l1) <= len && p.distanceTo(l2) <= len\n}\n\nexport function projectPointOnVector (point: Vector3, vector: Vector3, origin?: Vector3) {\n if (origin) {\n point.sub(origin).projectOnVector(vector).add(origin)\n } else {\n point.projectOnVector(vector)\n }\n\n return point\n}\n\nexport function computeBoundingBox (array: NumberArray) {\n let minX = +Infinity\n let minY = +Infinity\n let minZ = +Infinity\n let maxX = -Infinity\n let maxY = -Infinity\n let maxZ = -Infinity\n for (let i = 0, l = array.length; i < l; i += 3) {\n const x = array[ i ]\n const y = array[ i + 1 ]\n const z = array[ i + 2 ]\n if (x < minX) minX = x\n if (y < minY) minY = y\n if (z < minZ) minZ = z\n if (x > maxX) maxX = x\n if (y > maxY) maxY = y\n if (z > maxZ) maxZ = z\n }\n return [\n v3new([ minX, minY, minZ ]),\n v3new([ maxX, maxY, maxZ ])\n ]\n}\n(computeBoundingBox as any).__deps = [ v3new ]\n\nexport function applyMatrix4toVector3array (m: Float32Array, a: Float32Array) {\n for (let i = 0, il = a.length; i < il; i += 3) {\n const x = a[ i ]\n const y = a[ i + 1 ]\n const z = a[ i + 2 ]\n a[ i ] = m[ 0 ] * x + m[ 4 ] * y + m[ 8 ] * z + m[ 12 ]\n a[ i + 1 ] = m[ 1 ] * x + m[ 5 ] * y + m[ 9 ] * z + m[ 13 ]\n a[ i + 2 ] = m[ 2 ] * x + m[ 6 ] * y + m[ 10 ] * z + m[ 14 ]\n }\n}\n\nexport function applyMatrix3toVector3array (m: Float32Array, a: Float32Array) {\n for (let i = 0, il = a.length; i < il; i += 3) {\n const x = a[ i ]\n const y = a[ i + 1 ]\n const z = a[ i + 2 ]\n a[ i ] = m[ 0 ] * x + m[ 3 ] * y + m[ 6 ] * z\n a[ i + 1 ] = m[ 1 ] * x + m[ 4 ] * y + m[ 7 ] * z\n a[ i + 2 ] = m[ 2 ] * x + m[ 5 ] * y + m[ 8 ] * z\n }\n}\n\nexport function normalizeVector3array (a: Float32Array) {\n for (let i = 0, il = a.length; i < il; i += 3) {\n const x = a[ i ]\n const y = a[ i + 1 ]\n const z = a[ i + 2 ]\n const len2 = x * x + y * y + z * z\n if (len2 > 0) { // avoid divide by zero\n const s = 1 / Math.sqrt(len2)\n a[ i ] = x * s\n a[ i + 1 ] = y * s\n a[ i + 2 ] = z * s\n }\n // else leave as all zeros\n }\n}\n\nexport function v3new (array?: NumberArray) {\n return new Float32Array(array as any || 3) // TODO\n}\n\nexport function v3cross (out: Float32Array, a: Float32Array, b: Float32Array) {\n const ax = a[0]\n const ay = a[1]\n const az = a[2]\n const bx = b[0]\n const by = b[1]\n const bz = b[2]\n out[0] = ay * bz - az * by\n out[1] = az * bx - ax * bz\n out[2] = ax * by - ay * bx\n}\n\nexport function v3dot (a: Float32Array, b: Float32Array) {\n return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]\n}\n\nexport function v3sub (out: Float32Array, a: Float32Array, b: Float32Array) {\n out[0] = a[0] - b[0]\n out[1] = a[1] - b[1]\n out[2] = a[2] - b[2]\n}\n\nexport function v3add (out: Float32Array, a: Float32Array, b: Float32Array) {\n out[0] = a[0] + b[0]\n out[1] = a[1] + b[1]\n out[2] = a[2] + b[2]\n}\n\nexport function v3fromArray (out: Float32Array, array: Float32Array, offset = 0) {\n out[0] = array[offset]\n out[1] = array[offset + 1]\n out[2] = array[offset + 2]\n}\n\nexport function v3toArray (input: Float32Array, array: Float32Array, offset = 0) {\n array[offset] = input[0]\n array[offset + 1] = input[1]\n array[offset + 2] = input[2]\n}\n\nexport function v3forEach (array: Float32Array, fn: (i: Float32Array, j: Float32Array, k: Float32Array) => void, b: Float32Array) {\n const a = v3new()\n for (let i = 0, n = array.length; i < n; i += 3) {\n v3fromArray(a, array, i)\n fn(a, a, b)\n v3toArray(a, array, i)\n }\n}\n(v3forEach as any).__deps = [ v3new, v3fromArray, v3toArray ]\n\nexport function v3length2 (a: Float32Array) {\n return a[0] * a[0] + a[1] * a[1] + a[2] * a[2]\n}\n\nexport function v3length (a: Float32Array) {\n return Math.sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2])\n}\n\nexport function v3divide (out: Float32Array, a: Float32Array, b: Float32Array) {\n out[0] = a[0] / b[0]\n out[1] = a[1] / b[1]\n out[2] = a[2] / b[2]\n}\n\nexport function v3multiply (out: Float32Array, a: Float32Array, b: Float32Array) {\n out[0] = a[0] * b[0]\n out[1] = a[1] * b[1]\n out[2] = a[2] * b[2]\n}\n\nexport function v3divideScalar (out: Float32Array, a: Float32Array, s: number) {\n v3multiplyScalar(out, a, 1 / s)\n}\n(v3divideScalar as any).__deps = [ v3multiplyScalar ]\n\nexport function v3multiplyScalar (out: Float32Array, a: Float32Array, s: number) {\n out[0] = a[0] * s\n out[1] = a[1] * s\n out[2] = a[2] * s\n}\n\nexport function v3normalize (out: Float32Array, a: Float32Array) {\n const length2 = v3length2(a)\n if (length2 == 0) {\n out[0] = a[0]\n out[1] = a[1]\n out[2] = a[2]\n } else {\n v3multiplyScalar(out, a, 1 / Math.sqrt(length2))\n }\n}\n(v3normalize as any).__deps = [ v3multiplyScalar, v3length2 ]\n\nexport function v3subScalar (out: Float32Array, a: Float32Array, s: number) {\n out[0] = a[0] - s\n out[1] = a[1] - s\n out[2] = a[2] - s\n}\n\nexport function v3addScalar (out: Float32Array, a: Float32Array, s: number) {\n out[0] = a[0] + s\n out[1] = a[1] + s\n out[2] = a[2] + s\n}\n\nexport function v3floor (out: Float32Array, a: Float32Array) {\n out[0] = Math.floor(a[0])\n out[1] = Math.floor(a[1])\n out[2] = Math.floor(a[2])\n}\n\nexport function v3ceil (out: Float32Array, a: Float32Array) {\n out[0] = Math.ceil(a[0])\n out[1] = Math.ceil(a[1])\n out[2] = Math.ceil(a[2])\n}\n\nexport function v3round (out: Float32Array, a: Float32Array) {\n out[0] = Math.round(a[0])\n out[1] = Math.round(a[1])\n out[2] = Math.round(a[2])\n}\n\nexport function v3negate (out: Float32Array, a: Float32Array) {\n out[0] = -a[0]\n out[1] = -a[1]\n out[2] = -a[2]\n}\n\nexport function v3angle (a: Float32Array, b: Float32Array) {\n const ax = a[0]\n const ay = a[1]\n const az = a[2]\n const bx = b[0]\n const by = b[1]\n const bz = b[2]\n const cx = ay * bz - az * by\n const cy = az * bx - ax * bz\n const cz = ax * by - ay * bx\n const s = Math.sqrt(cx * cx + cy * cy + cz * cz)\n const c = ax * bx + ay * by + az * bz\n return Math.atan2(s, c)\n}\n","/**\n * @file Dash\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport { WideLineBufferData } from '../buffer/wideline-buffer'\nimport {\n calculateDirectionArray, calculateCenterArray,\n replicateArrayEntries, replicateArray3Entries\n} from '../math/array-utils'\n\nexport function getFixedCountDashData (data: T, segmentCount: number = 9) {\n\n const s = Math.floor(segmentCount / 2)\n const n = data.position1.length / 3\n const sn = s * n\n const sn3 = sn * 3\n const step = 1 / segmentCount\n\n const direction = calculateDirectionArray(data.position1, data.position2)\n const position1 = new Float32Array(sn3)\n const position2 = new Float32Array(sn3)\n\n const v = new Vector3()\n\n for (let i = 0; i < n; ++i) {\n const i3 = i * 3\n v.set(direction[ i3 ], direction[ i3 + 1 ], direction[ i3 + 2 ])\n\n const x = data.position1[ i3 ]\n const y = data.position1[ i3 + 1 ]\n const z = data.position1[ i3 + 2 ]\n\n for (let j = 0; j < s; ++j) {\n const j3 = s * i3 + j * 3\n\n const f1 = step * (j * 2 + 1)\n const f2 = step * (j * 2 + 2)\n\n position1[ j3 ] = x + v.x * f1\n position1[ j3 + 1 ] = y + v.y * f1\n position1[ j3 + 2 ] = z + v.z * f1\n\n position2[ j3 ] = x + v.x * f2\n position2[ j3 + 1 ] = y + v.y * f2\n position2[ j3 + 2 ] = z + v.z * f2\n }\n }\n\n const position = calculateCenterArray(position1, position2) as Float32Array\n const color = replicateArray3Entries(data.color!, s) // TODO\n const color2 = color\n\n const d: any = { position, position1, position2, color, color2 }\n\n if ((data as any).radius) { // TODO\n d.radius = replicateArrayEntries((data as any).radius, s) // TODO\n }\n\n if (data.picking && data.picking.array) {\n data.picking.array = replicateArrayEntries(data.picking.array, s)\n d.picking = data.picking\n }\n if (data.primitiveId) {\n d.primitiveId = replicateArrayEntries(data.primitiveId, s)\n }\n\n return d as T\n}\n\nexport function getFixedLengthDashData (data: T, segmentLength: number = 0.1) {\n\n const direction = calculateDirectionArray(data.position1, data.position2)\n const pos1: number[] = []\n const pos2: number[] = []\n const col: number[] = []\n const rad: number[]|undefined = (data as any).radius ? [] : undefined\n const pick: number[]|undefined = (data as any).picking ? [] : undefined\n const id: number[]|undefined = (data as any).primitiveId ? [] : undefined\n\n const v = new Vector3()\n const n = data.position1.length / 3\n\n let k = 0\n\n for (let i = 0; i < n; ++i) {\n const i3 = i * 3\n v.set(direction[ i3 ], direction[ i3 + 1 ], direction[ i3 + 2 ])\n\n const vl = v.length()\n const segmentCount = vl / segmentLength\n const s = Math.floor(segmentCount / 2)\n const step = 1 / segmentCount\n\n const x = data.position1[ i3 ]\n const y = data.position1[ i3 + 1 ]\n const z = data.position1[ i3 + 2 ]\n\n for (let j = 0; j < s; ++j) {\n const j3 = k * 3 + j * 3\n\n const f1 = step * (j * 2 + 1)\n const f2 = step * (j * 2 + 2)\n\n pos1[ j3 ] = x + v.x * f1\n pos1[ j3 + 1 ] = y + v.y * f1\n pos1[ j3 + 2 ] = z + v.z * f1\n\n pos2[ j3 ] = x + v.x * f2\n pos2[ j3 + 1 ] = y + v.y * f2\n pos2[ j3 + 2 ] = z + v.z * f2\n\n if (data.color) {\n col[ j3 ] = data.color[ i3 ]\n col[ j3 + 1 ] = data.color[ i3 + 1 ]\n col[ j3 + 2 ] = data.color[ i3 + 2 ]\n }\n\n if (rad) rad[ k + j ] = (data as any).radius[ i ]\n if (pick) {\n if ((data as any).picking.array) {\n pick[ k + j ] = (data as any).picking.array[ i ]\n } else {\n pick[ k + j ] = i\n }\n }\n if (id) id[ k + j ] = (data as any).primitiveId[ i ]\n }\n\n k += s\n }\n\n const position1 = new Float32Array(pos1)\n const position2 = new Float32Array(pos2)\n const position = calculateCenterArray(position1, position2) as Float32Array\n const color = new Float32Array(col)\n const color2 = color\n\n const d: any = { position, position1, position2, color, color2 }\n\n if (rad) d.radius = new Float32Array(rad)\n if (pick && data.picking) {\n data.picking.array = new Float32Array(pick)\n d.picking = data.picking\n }\n if (id) d.primitiveId = new Float32Array(id)\n\n return d as T\n}\n\nexport function getFixedLengthWrappedDashData (data: T, segmentLength: number = 0.1) {\n\n const direction = calculateDirectionArray(data.position1, data.position2)\n const pos1: number[] = []\n const pos2: number[] = []\n const col: number[] = []\n const rad: number[]|undefined = (data as any).radius ? [] : undefined\n const pick: number[]|undefined = (data as any).picking ? [] : undefined\n const id: number[]|undefined = (data as any).primitiveId ? [] : undefined\n\n const v = new Vector3()\n const n = data.position1.length / 3\n\n let remaining = segmentLength\n let drawing = true\n\n let k = 0\n let k3 = 0\n let kprev = 0\n\n for (let i = 0; i < n; ++i) {\n const i3 = i * 3\n const x = data.position1[ i3 ]\n const y = data.position1[ i3 + 1 ]\n const z = data.position1[ i3 + 2 ]\n\n v.set(direction[ i3 ], direction[ i3 + 1 ], direction[ i3 + 2 ])\n const vl = v.length()\n\n if (drawing) {\n pos1[ k3 ] = x\n pos1[ k3 + 1 ] = y\n pos1[ k3 + 2 ] = z\n }\n\n let dist = remaining\n const inv = 1 / vl\n while (dist < vl) {\n const a = drawing ? pos2 : pos1\n a[ k3 ] = x + v.x * dist * inv\n a[ k3 + 1 ] = y + v.y * dist * inv\n a[ k3 + 2 ] = z + v.z * dist * inv\n if (drawing) {\n k++\n k3 = k * 3\n }\n drawing = !drawing\n remaining = segmentLength\n dist += segmentLength\n }\n\n if (drawing) {\n pos2[ k3 ] = data.position2[ i3 ]\n pos2[ k3 + 1 ] = data.position2[ i3 + 1 ]\n pos2[ k3 + 2 ] = data.position2[ i3 + 2 ]\n k++\n k3 = k * 3\n }\n\n remaining = dist - vl\n\n for (let j = kprev; j < k ; j++){\n if (data.color) {\n const j3 = j * 3\n col[ j3 ] = data.color[ i3 ]\n col[ j3 + 1 ] = data.color[ i3 + 1 ]\n col[ j3 + 2 ] = data.color[ i3 + 2 ]\n }\n\n if (rad) rad[ j ] = (data as any).radius[ i ]\n if (pick) {\n if ((data as any).picking.array) {\n pick[ j ] = (data as any).picking.array[ i ]\n } else {\n pick[ j ] = i\n }\n }\n if (id) id[ j ] = (data as any).primitiveId[ i ]\n }\n\n kprev = k\n\n }\n\n if (!drawing && n > 0) {\n const k3 = k * 3\n pos2[ k3 ] = data.position2[ 3 * n - 3 ]\n pos2[ k3 + 1 ] = data.position2[ 3 * n - 2 ]\n pos2[ k3 + 1 ] = data.position2[ 3 * n - 1 ]\n }\n\n const position1 = new Float32Array(pos1)\n const position2 = new Float32Array(pos2)\n const position = calculateCenterArray(position1, position2) as Float32Array\n const color = new Float32Array(col)\n const color2 = color\n\n const d: any = { position, position1, position2, color, color2 }\n\n if (rad) d.radius = new Float32Array(rad)\n if (pick && data.picking) {\n data.picking.array = new Float32Array(pick)\n d.picking = data.picking\n }\n if (id) d.primitiveId = new Float32Array(id)\n\n return d as T\n}\n","/**\n * @file Primitive\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Color, Box3 } from 'three'\n\nimport { BufferRegistry, PickerRegistry } from '../globals'\nimport Shape from './shape'\nimport { getFixedLengthDashData } from './dash'\n\nfunction addElement (elm: any, array: any[]) {\n if (elm.toArray !== undefined) {\n elm = elm.toArray()\n } else if (elm.x !== undefined) {\n elm = [ elm.x, elm.y, elm.z ]\n } else if (elm.r !== undefined) {\n elm = [ elm.r, elm.g, elm.b ]\n }\n array.push.apply(array, elm)\n}\n\nconst tmpVec = new Vector3()\n\nexport type PrimitiveFields = { [k: string]: string }\n\n/**\n * Base class for geometry primitives\n * @interface\n */\nexport abstract class Primitive {\n static type = ''\n static fields: PrimitiveFields = {}\n\n static get Picker () { return PickerRegistry.get(this.type) }\n static get Buffer () { return BufferRegistry.get(this.type) }\n\n static getShapeKey (name: string) {\n return this.type + name[0].toUpperCase() + name.substr(1)\n }\n\n static expandBoundingBox (box: Box3, data: any) {}\n\n static valueToShape (shape: Shape, name: string, value: any) {\n const data = shape._primitiveData[this.getShapeKey(name)]\n const type = this.fields[name]\n\n switch (type) {\n case 'v3':\n case 'c':\n addElement(value, data)\n break\n default:\n data.push(value)\n }\n }\n\n static objectToShape (shape: Shape, data: any) {\n Object.keys(this.fields).forEach(name => {\n this.valueToShape(shape, name, data[name])\n })\n this.valueToShape(shape, 'name', data.name)\n this.expandBoundingBox(shape.boundingBox, data)\n }\n\n static valueFromShape (shape: Shape, pid: number, name: string) {\n const data = shape._primitiveData[this.getShapeKey(name)]\n const type = this.fields[name]\n\n switch (type) {\n case 'v3':\n return new Vector3().fromArray(data, 3 * pid)\n case 'c':\n return new Color().fromArray(data, 3 * pid)\n default:\n return data[pid]\n }\n }\n\n static objectFromShape (shape: Shape, pid: number) {\n let name = this.valueFromShape(shape, pid, 'name')\n if (name === undefined) {\n name = `${this.type}: ${pid} (${shape.name})`\n }\n const o: any = { shape, name }\n\n Object.keys(this.fields).forEach(name => {\n o[name] = this.valueFromShape(shape, pid, name)\n })\n\n return o\n }\n\n static arrayFromShape (shape: Shape, name: string) {\n const data = shape._primitiveData[this.getShapeKey(name)]\n const type = this.fields[name]\n\n switch (type) {\n case 's':\n return data\n default:\n return new Float32Array(data)\n }\n }\n\n static dataFromShape (shape: Shape) {\n const data: any = {}\n\n if (this.Picker) {\n data.picking = new this.Picker(shape)\n }\n\n Object.keys(this.fields).forEach(name => {\n data[name] = this.arrayFromShape(shape, name)\n })\n\n return data\n }\n\n static bufferFromShape (shape: Shape, params: any) {\n return new this.Buffer(this.dataFromShape(shape), params)\n }\n}\n\n/**\n * Sphere geometry primitive\n */\nexport class SpherePrimitive extends Primitive {\n static type = 'sphere'\n\n static fields = {\n position: 'v3',\n color: 'c',\n radius: 'f'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n return this.valueFromShape(shape, pid, 'position')\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position))\n }\n}\n\n/**\n * Box geometry primitive\n */\nexport class BoxPrimitive extends Primitive {\n static type = 'box'\n\n static fields = {\n position: 'v3',\n color: 'c',\n size: 'f',\n heightAxis: 'v3',\n depthAxis: 'v3'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n return this.valueFromShape(shape, pid, 'position')\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position))\n }\n}\n\n/**\n * Octahedron geometry primitive\n */\nexport class OctahedronPrimitive extends BoxPrimitive {\n static type = 'octahedron'\n}\n\n/**\n * Tetrahedron geometry primitive\n */\nexport class TetrahedronPrimitive extends BoxPrimitive {\n static type = 'tetrahedron'\n}\n\n/**\n * Cylinder geometry primitive\n */\nexport class CylinderPrimitive extends Primitive {\n static type = 'cylinder'\n\n static fields = {\n position1: 'v3',\n position2: 'v3',\n color: 'c',\n radius: 'f'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n const p1 = this.valueFromShape(shape, pid, 'position1')\n const p2 = this.valueFromShape(shape, pid, 'position2')\n return p1.add(p2).multiplyScalar(0.5)\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position1))\n box.expandByPoint(tmpVec.fromArray(data.position2))\n }\n\n static bufferFromShape (shape: Shape, params: any = {}) {\n let data = this.dataFromShape(shape)\n if (this.type === 'cylinder' && params.dashedCylinder) {\n data = getFixedLengthDashData(data)\n }\n return new this.Buffer(data, params)\n }\n}\n\n/**\n * Arrow geometry primitive\n */\nexport class ArrowPrimitive extends CylinderPrimitive {\n static type = 'arrow'\n}\n\n/**\n * Cone geometry primitive\n */\nexport class ConePrimitive extends CylinderPrimitive {\n static type = 'cone'\n}\n\n/**\n * Ellipsoid geometry primitive\n */\nexport class EllipsoidPrimitive extends SpherePrimitive {\n static type = 'ellipsoid'\n\n static fields = {\n position: 'v3',\n color: 'c',\n radius: 'f',\n majorAxis: 'v3',\n minorAxis: 'v3'\n }\n}\n\n/**\n * Torus geometry primitive\n */\nexport class TorusPrimitive extends EllipsoidPrimitive {\n static type = 'torus'\n}\n\n/**\n * Text geometry primitive\n */\nexport class TextPrimitive extends Primitive {\n static type = 'text'\n\n static fields = {\n position: 'v3',\n color: 'c',\n size: 'f',\n text: 's'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n return this.valueFromShape(shape, pid, 'position')\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position))\n }\n}\n\n/**\n * Point primitive\n */\nexport class PointPrimitive extends Primitive {\n static type = 'point'\n\n static fields = {\n position: 'v3',\n color: 'c',\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n return this.valueFromShape(shape, pid, 'position')\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position))\n }\n}\n\n/**\n * Wideline geometry primitive\n */\nexport class WidelinePrimitive extends Primitive {\n static type = 'wideline'\n\n static fields = {\n position1: 'v3',\n position2: 'v3',\n color: 'c'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n const p1 = this.valueFromShape(shape, pid, 'position1')\n const p2 = this.valueFromShape(shape, pid, 'position2')\n return p1.add(p2).multiplyScalar(0.5)\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position1))\n box.expandByPoint(tmpVec.fromArray(data.position2))\n }\n}\n","/**\n * @file Spatial Hash\n * @author Alexander Rose \n * @private\n */\n\nimport { Box3 } from 'three'\n\nexport type Positions = {\n x: ArrayLike,\n y: ArrayLike,\n z: ArrayLike,\n count?:number\n}\n\nfunction createBoundingBox(positions: Positions) {\n const { x, y, z } = positions\n const boundingBox = new Box3()\n const count = x.length\n const { min, max } = boundingBox\n\n for (let i = 0; i < count; i++) {\n min.x = Math.min(x[i], min.x)\n min.y = Math.min(y[i], min.y)\n min.z = Math.min(z[i], min.z)\n max.x = Math.max(x[i], max.x)\n max.y = Math.max(y[i], max.y)\n max.z = Math.max(z[i], max.z)\n }\n\n return boundingBox\n}\n\nexport default class SpatialHash {\n exp = 3\n\n minX: number\n minY: number\n minZ: number\n\n boundX: number\n boundY: number\n boundZ: number\n\n grid: Uint32Array\n bucketCount: Uint16Array\n bucketOffset: Uint32Array\n bucketArray: Int32Array\n\n xArray: ArrayLike\n yArray: ArrayLike\n zArray: ArrayLike\n\n constructor(positions: Positions, boundingBox?: Box3) {\n const bb = boundingBox || createBoundingBox(positions)\n this.minX = bb.min.x\n this.minY = bb.min.y\n this.minZ = bb.min.z\n this.boundX = ((bb.max.x - this.minX) >> this.exp) + 1\n this.boundY = ((bb.max.y - this.minY) >> this.exp) + 1\n this.boundZ = ((bb.max.z - this.minZ) >> this.exp) + 1\n\n const n = this.boundX * this.boundY * this.boundZ\n const an = (positions.count !== undefined) ? positions.count : positions.x.length\n\n const xArray = positions.x\n const yArray = positions.y\n const zArray = positions.z\n\n let count = 0\n const grid = new Uint32Array(n)\n const bucketIndex = new Int32Array(an)\n for (let i = 0; i < an; ++i) {\n const x = (xArray[ i ] - this.minX) >> this.exp\n const y = (yArray[ i ] - this.minY) >> this.exp\n const z = (zArray[ i ] - this.minZ) >> this.exp\n const idx = (((x * this.boundY) + y) * this.boundZ) + z\n if ((grid[ idx ] += 1) === 1) {\n count += 1\n }\n bucketIndex[ i ] = idx\n }\n\n const bucketCount = new Uint16Array(count)\n for (let i = 0, j = 0; i < n; ++i) {\n const c = grid[ i ]\n if (c > 0) {\n grid[ i ] = j + 1\n bucketCount[ j ] = c\n j += 1\n }\n }\n\n const bucketOffset = new Uint32Array(count)\n for (let i = 1; i < count; ++i) {\n bucketOffset[ i ] += bucketOffset[ i - 1 ] + bucketCount[ i - 1 ]\n }\n\n const bucketFill = new Uint16Array(count)\n const bucketArray = new Int32Array(an)\n for (let i = 0; i < an; ++i) {\n const bucketIdx = grid[ bucketIndex[ i ] ]\n if (bucketIdx > 0) {\n const k = bucketIdx - 1\n bucketArray[ bucketOffset[ k ] + bucketFill[ k ] ] = i\n bucketFill[ k ] += 1\n }\n }\n\n this.grid = grid\n this.bucketCount = bucketCount\n this.bucketOffset = bucketOffset\n this.bucketArray = bucketArray\n\n this.xArray = xArray\n this.yArray = yArray\n this.zArray = zArray\n }\n\n within (x: number, y: number, z: number, r: number) {\n const result: number[] = []\n\n this.eachWithin(x, y, z, r, atomIndex => result.push(atomIndex))\n\n return result\n }\n\n eachWithin (x: number, y: number, z: number, r: number, callback: (atomIndex: number, dSq: number) => void) {\n const rSq = r * r\n\n const loX = Math.max(0, (x - r - this.minX) >> this.exp)\n const loY = Math.max(0, (y - r - this.minY) >> this.exp)\n const loZ = Math.max(0, (z - r - this.minZ) >> this.exp)\n\n const hiX = Math.min(this.boundX, ((x + r - this.minX) >> this.exp) + 1)\n const hiY = Math.min(this.boundY, ((y + r - this.minY) >> this.exp) + 1)\n const hiZ = Math.min(this.boundZ, ((z + r - this.minZ) >> this.exp) + 1)\n\n for (let ix = loX; ix < hiX; ++ix) {\n for (let iy = loY; iy < hiY; ++iy) {\n for (let iz = loZ; iz < hiZ; ++iz) {\n const idx = (((ix * this.boundY) + iy) * this.boundZ) + iz\n const bucketIdx = this.grid[ idx ]\n\n if (bucketIdx > 0) {\n const k = bucketIdx - 1\n const offset = this.bucketOffset[ k ]\n const count = this.bucketCount[ k ]\n const end = offset + count\n\n for (let i = offset; i < end; ++i) {\n const atomIndex = this.bucketArray[ i ]\n const dx = this.xArray[ atomIndex ] - x\n const dy = this.yArray[ atomIndex ] - y\n const dz = this.zArray[ atomIndex ] - z\n\n const dSq = dx * dx + dy * dy + dz * dz\n if (dSq <= rSq) callback(atomIndex, dSq)\n }\n }\n }\n }\n }\n }\n}","/**\n * @file Store\n * @author Alexander Rose \n * @private\n */\n\nimport { Log } from '../globals'\nimport { getTypedArray, TypedArrayString } from '../utils'\n\nexport type StoreField = [string, number, TypedArrayString]\n\n/**\n * Store base class\n * @interface\n */\nexport default class Store {\n [k: string]: any\n\n length: number\n count: number\n\n _fields: StoreField[]\n get _defaultFields(): StoreField[] { return [] }\n\n /**\n * @param {Integer} [size] - initial size\n */\n constructor (size = 0) {\n this._fields = this._defaultFields\n this._init(0)\n }\n\n /**\n * Initialize the store\n * @param {Integer} size - size to initialize\n * @return {undefined}\n */\n _init (size: number) {\n this.length = size\n this.count = 0\n\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const [name, size, type]: StoreField = this._fields[ i ]\n this._initField(name, size, type)\n }\n }\n\n /**\n * Initialize a field\n * @param {String} name - field name\n * @param {Integer} size - element size\n * @param {String} type - data type, one of int8, int16, int32,\n * uint8, uint16, uint32, float32\n * @return {undefined}\n */\n _initField (name: string, size: number, type: TypedArrayString) {\n this[ name ] = getTypedArray(type, this.length * size)\n }\n\n /**\n * Add a field\n * @param {String} name - field name\n * @param {Integer} size - element size\n * @param {String} type - data type, one of int8, int16, int32,\n * uint8, uint16, uint32, float32\n * @return {undefined}\n */\n addField (name: string, size: number, type: TypedArrayString) {\n this._fields.push([name, size, type])\n this._initField(name, size, type)\n }\n\n /**\n * Resize the store to the new size\n * @param {Integer} size - new size\n * @return {undefined}\n */\n resize (size?: number) {\n // Log.time( \"Store.resize\" );\n\n this.length = Math.round(size || 0)\n this.count = Math.min(this.count, this.length)\n\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const name = this._fields[ i ][ 0 ]\n const itemSize = this._fields[ i ][ 1 ]\n const arraySize = this.length * itemSize\n const tmpArray = new this[ name ].constructor(arraySize)\n\n if (this[ name ].length > arraySize) {\n tmpArray.set(this[ name ].subarray(0, arraySize))\n } else {\n tmpArray.set(this[ name ])\n }\n this[ name ] = tmpArray\n }\n\n // Log.timeEnd( \"Store.resize\" );\n }\n\n /**\n * Resize the store to 1.5 times its current size if full\n * @return {undefined}\n */\n growIfFull () {\n if (this.count >= this.length) {\n const size = Math.round(this.length * 1.5)\n this.resize(Math.max(256, size))\n }\n }\n\n /**\n * Copy data from one store to another\n * @param {Store} other - store to copy from\n * @param {Integer} thisOffset - offset to start copying to\n * @param {Integer} otherOffset - offset to start copying from\n * @param {Integer} length - number of entries to copy\n * @return {undefined}\n */\n copyFrom (other: Store, thisOffset: number, otherOffset: number, length: number) {\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const name = this._fields[ i ][ 0 ]\n const itemSize = this._fields[ i ][ 1 ]\n const thisField = this[ name ]\n const otherField = other[ name ]\n\n for (let j = 0; j < length; ++j) {\n const thisIndex = itemSize * (thisOffset + j)\n const otherIndex = itemSize * (otherOffset + j)\n for (let k = 0; k < itemSize; ++k) {\n thisField[ thisIndex + k ] = otherField[ otherIndex + k ]\n }\n }\n }\n }\n\n /**\n * Copy data within this store\n * @param {Integer} thisOffset - offset to start copying to\n * @param {Integer} otherOffset - offset to start copying from\n * @param {Integer} length - number of entries to copy\n * @return {undefined}\n */\n copyWithin (offsetTarget: number, offsetSource: number, length: number) {\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const name = this._fields[ i ][ 0 ]\n const itemSize = this._fields[ i ][ 1 ]\n const thisField = this[ name ]\n\n for (let j = 0; j < length; ++j) {\n const targetIndex = itemSize * (offsetTarget + j)\n const sourceIndex = itemSize * (offsetSource + j)\n for (let k = 0; k < itemSize; ++k) {\n thisField[ targetIndex + k ] = thisField[ sourceIndex + k ]\n }\n }\n }\n }\n\n /**\n * Sort entries in the store given the compare function\n * @param {[type]} compareFunction - function to sort by\n * @return {undefined}\n */\n sort (compareFunction: (a: any, b: any) => number) {\n Log.time('Store.sort')\n\n const thisStore = this\n const tmpStore = new (this.constructor as any)(1)\n\n function swap (index1: number, index2: number) {\n if (index1 === index2) return\n tmpStore.copyFrom(thisStore, 0, index1, 1)\n thisStore.copyWithin(index1, index2, 1)\n thisStore.copyFrom(tmpStore, index2, 0, 1)\n }\n\n function quicksort (left: number, right: number) {\n if (left < right) {\n let pivot = Math.floor((left + right) / 2)\n let leftNew = left\n let rightNew = right\n do {\n while (compareFunction(leftNew, pivot) < 0) {\n leftNew += 1\n }\n while (compareFunction(rightNew, pivot) > 0) {\n rightNew -= 1\n }\n if (leftNew <= rightNew) {\n if (leftNew === pivot) {\n pivot = rightNew\n } else if (rightNew === pivot) {\n pivot = leftNew\n }\n swap(leftNew, rightNew)\n leftNew += 1\n rightNew -= 1\n }\n } while (leftNew <= rightNew)\n quicksort(left, rightNew)\n quicksort(leftNew, right)\n }\n }\n\n quicksort(0, this.count - 1)\n\n Log.timeEnd('Store.sort')\n }\n\n /**\n * Empty the store\n * @return {undefined}\n */\n clear () {\n this.count = 0\n }\n\n /**\n * Dispose of the store entries and fields\n * @return {undefined}\n */\n dispose () {\n\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const name = this._fields[ i ][ 0 ]\n delete this[ name ]\n }\n }\n}\n","/**\n * @file Contact Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Bond store\n */\nexport default class ContactStore extends Store {\n index1: Uint32Array\n index2: Uint32Array\n type: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'index1', 1, 'int32' ],\n [ 'index2', 1, 'int32' ],\n [ 'type', 1, 'int8' ]\n ] as StoreField[]\n }\n\n addContact (index1: number, index2: number, type?: number) {\n this.growIfFull()\n\n const i = this.count\n\n if (index1 < index2) {\n this.index1[ i ] = index1\n this.index2[ i ] = index2\n } else {\n this.index2[ i ] = index1\n this.index1[ i ] = index2\n }\n if (type) this.type[ i ] = type\n\n this.count += 1\n }\n}","/**\n * @file Bit array\n * @author Alexander Rose \n * @author Paul Pillot \n * @private\n */\n\n/**\n * Compute the Hamming weight of a 32-bit unsigned integer\n * @param {Integer} v - a 32-bit unsigned integer\n * @return {Integer} the Hamming weight\n */\nfunction hammingWeight (v: number) {\n // works with signed or unsigned shifts\n v -= ((v >>> 1) & 0x55555555)\n v = (v & 0x33333333) + ((v >>> 2) & 0x33333333)\n return ((v + (v >>> 4) & 0xF0F0F0F) * 0x1010101) >>> 24\n}\n\n/**\n * Bit array\n *\n * Based heavily on https://github.com/lemire/FastBitSet.js\n * which is licensed under the Apache License, Version 2.0.\n */\nexport default class BitArray {\n private _words: Uint32Array\n public length: number\n\n /**\n * @param {Integer} length - array length\n * @param {Boolean} [setAll] - initialize with true\n */\n constructor (length: number, setAll?: boolean) {\n this.length = length\n this._words = new Uint32Array((length + 32) >>> 5)\n if (setAll === true) {\n this.setAll()\n }\n }\n\n /**\n * Get value at index\n * @param {Integer} index - the index\n * @return {Boolean} value\n */\n get (index: number) {\n return (this._words[ index >>> 5 ] & (1 << index)) !== 0\n }\n\n /**\n * Set value at index to true\n * @param {Integer} index - the index\n * @return {undefined}\n */\n set (index: number) {\n this._words[ index >>> 5 ] |= 1 << index\n }\n\n /**\n * Set value at index to false\n * @param {Integer} index - the index\n * @return {undefined}\n */\n clear (index: number) {\n this._words[ index >>> 5 ] &= ~(1 << index)\n }\n\n /**\n * Flip value at index\n * @param {Integer} index - the index\n * @return {undefined}\n */\n flip (index: number) {\n this._words[ index >>> 5 ] ^= 1 << index\n }\n\n _assignRange (start: number, end: number, value: boolean) {\n if (end < start) return\n const words = this._words\n const wordValue = value === true ? 0xFFFFFFFF : 0\n const wordStart = start >>> 5\n const wordEnd = end >>> 5\n // set complete words when applicable\n for (let k = wordStart + 1; k < wordEnd; ++k) {\n words[ k ] = wordValue\n }\n // set parts of the range not spanning complete words\n const startWord = wordStart << 5\n const endWord = wordEnd << 5\n if (value === true) {\n if (end - start < 32) {\n for (let i = start, n = end + 1; i < n; ++i) {\n words[ i >>> 5 ] |= 1 << i\n }\n } else {\n for (let i = start, n = startWord + 32; i < n; ++i) {\n words[ i >>> 5 ] |= 1 << i\n }\n for (let i = endWord, n = end + 1; i < n; ++i) {\n words[ i >>> 5 ] |= 1 << i\n }\n }\n } else {\n if (end - start < 32) {\n for (let i = start, n = end + 1; i < n; ++i) {\n words[ i >>> 5 ] &= ~(1 << i)\n }\n } else {\n for (let i = start, n = startWord + 32; i < n; ++i) {\n words[ i >>> 5 ] &= ~(1 << i)\n }\n for (let i = endWord, n = end + 1; i < n; ++i) {\n words[ i >>> 5 ] &= ~(1 << i)\n }\n }\n }\n return this\n }\n\n /**\n * Set bits of the given range\n * @param {Integer} start - start index\n * @param {Integer} end - end index\n * @return {BitArray} this object\n */\n setRange (start: number, end: number) {\n return this._assignRange(start, end, true)\n }\n\n /**\n * Clear bits of the given range\n * @param {Integer} start - start index\n * @param {Integer} end - end index\n * @return {BitArray} this object\n */\n clearRange (start: number, end: number) {\n return this._assignRange(start, end, false)\n }\n\n /**\n * Set bits at all given indices\n * @param {...Integer} arguments - indices\n * @return {Boolean} this object\n */\n setBits (...indices: number[]) {\n const words = this._words\n const n = indices.length\n for (let i = 0; i < n; ++i) {\n const index = indices[ i ]\n words[ index >>> 5 ] |= 1 << index\n }\n return this\n }\n\n /**\n * Clear bits at all given indices\n * @param {...Integer} arguments - indices\n * @return {Boolean} this object\n */\n clearBits (...indices: number[]) {\n const words = this._words\n const n = indices.length\n for (let i = 0; i < n; ++i) {\n const index = indices[ i ]\n words[ index >>> 5 ] &= ~(1 << index)\n }\n return this\n }\n\n /**\n * Set all bits of the array\n * @return {BitArray} this object\n */\n setAll () {\n return this._assignRange(0, this.length - 1, true)\n }\n\n /**\n * Clear all bits of the array\n * @return {BitArray} this object\n */\n clearAll () {\n return this._assignRange(0, this.length - 1, false)\n }\n\n /**\n * Flip all the values in the array\n * @return {BitArray} this object\n */\n flipAll () {\n const count = this._words.length\n const words = this._words\n const bs = 32 - this.length % 32\n for (let k = 0; k < count - 1; ++k) {\n words[k] = ~words[ k ]\n }\n words[ count - 1 ] = (~(words[ count - 1 ] << bs)) >>> bs\n return this\n }\n\n _isRangeValue (start: number, end: number, value: boolean) {\n if (end < start) return\n const words = this._words\n const wordValue = value === true ? 0xFFFFFFFF : 0\n const wordStart = start >>> 5\n const wordEnd = end >>> 5\n // set complete words when applicable\n for (let k = wordStart + 1; k < wordEnd; ++k) {\n if (words[ k ] !== wordValue) return false\n }\n // set parts of the range not spanning complete words\n if (end - start < 32) {\n for (let i = start, n = end + 1; i < n; ++i) {\n if (!!(words[ i >>> 5 ] & (1 << i)) !== value) return false\n }\n } else {\n const startWord = wordStart << 5\n const endWord = wordEnd << 5\n for (let i = start, n = startWord + 32; i < n; ++i) {\n if (!!(words[ i >>> 5 ] & (1 << i)) !== value) return false\n }\n for (let i = endWord, n = end + 1; i < n; ++i) {\n if (!!(words[ i >>> 5 ] & (1 << i)) !== value) return false\n }\n }\n return true\n }\n\n /**\n * Test if bits in given range are set\n * @param {Integer} start - start index\n * @param {Integer} end - end index\n * @return {BitArray} this object\n */\n isRangeSet (start: number, end: number) {\n return this._isRangeValue(start, end, true)\n }\n\n /**\n * Test if bits in given range are clear\n * @param {Integer} start - start index\n * @param {Integer} end - end index\n * @return {BitArray} this object\n */\n isRangeClear (start: number, end: number) {\n return this._isRangeValue(start, end, false)\n }\n\n /**\n * Test if all bits in the array are set\n * @return {Boolean} test result\n */\n isAllSet () {\n return this._isRangeValue(0, this.length - 1, true)\n }\n\n /**\n * Test if all bits in the array are clear\n * @return {Boolean} test result\n */\n isAllClear () {\n return this._isRangeValue(0, this.length - 1, false)\n }\n\n /**\n * Test if bits at all given indices are set\n * @param {...Integer} arguments - indices\n * @return {Boolean} test result\n */\n isSet (...indices: number[]) {\n const words = this._words\n const n = indices.length\n for (let i = 0; i < n; ++i) {\n const index = indices[ i ]\n if ((words[ index >>> 5 ] & (1 << index)) === 0) return false\n }\n return true\n }\n\n /**\n * Test if bits at all given indices are clear\n * @param {...Integer} arguments - indices\n * @return {Boolean} test result\n */\n isClear (...indices: number[]) {\n const words = this._words\n const n = indices.length\n for (let i = 0; i < n; ++i) {\n const index = indices[ i ]\n if ((words[ index >>> 5 ] & (1 << index)) !== 0) return false\n }\n return true\n }\n\n /**\n * Test if two BitArrays are identical in all their values\n * @param {BitArray} otherBitarray - the other BitArray\n * @return {Boolean} test result\n */\n isEqualTo (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n if (words1[ k ] !== words2[ k ]) {\n return false\n }\n }\n return true\n }\n\n /**\n * How many set bits?\n * @return {Integer} number of set bits\n */\n getSize () {\n const count = this._words.length\n const words = this._words\n let size = 0\n for (let i = 0; i < count; ++i) {\n size += hammingWeight(words[ i ])\n }\n return size\n }\n\n /**\n * Calculate difference betwen this and another bit array.\n * Store result in this object.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {BitArray} this object\n */\n difference (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n words1[ k ] = words1[ k ] & ~words2[ k ]\n }\n for (let k = words1.length; k < count; ++k) {\n words1[ k ] = 0\n }\n return this\n }\n\n /**\n * Calculate union betwen this and another bit array.\n * Store result in this object.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {BitArray} this object\n */\n union (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n words1[ k ] |= words2[ k ]\n }\n for (let k = words1.length; k < count; ++k) {\n words1[ k ] = 0\n }\n return this\n }\n\n /**\n * Calculate intersection betwen this and another bit array.\n * Store result in this object.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {BitArray} this object\n */\n intersection (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n words1[ k ] &= words2[ k ]\n }\n for (let k = words1.length; k < count; ++k) {\n words1[ k ] = 0\n }\n return this\n }\n\n /**\n * Test if there is any intersection betwen this and another bit array.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {Boolean} test result\n */\n intersects (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n if ((words1[ k ] & words2[ k ]) !== 0) {\n return true\n }\n }\n return false\n }\n\n /**\n * Calculate the number of bits in common betwen this and another bit array.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {Integer} size\n */\n getIntersectionSize (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n let size = 0\n for (let k = 0; k < count; ++k) {\n size += hammingWeight(words1[ k ] & words2[ k ])\n }\n return size\n }\n\n /**\n * Calculate intersection betwen this and another bit array.\n * Store result in a new bit array.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {BitArray} the new bit array\n */\n makeIntersection (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n const wordsA = new Uint32Array(count)\n const intersection = Object.create(BitArray.prototype)\n intersection._words = wordsA\n intersection.length = Math.min(this.length, otherBitarray.length)\n for (let k = 0; k < count; ++k) {\n wordsA[ k ] = words1[ k ] & words2[ k ]\n }\n return intersection\n }\n\n /**\n * Iterate over all set bits in the array\n * @param {function( index: Integer, i: Integer )} callback - the callback\n * @return {undefined}\n */\n forEach (callback: (index: number, i: number) => any) {\n const count = this._words.length\n const words = this._words\n let i = 0\n for (let k = 0; k < count; ++k) {\n let w = words[ k ]\n while (w !== 0) {\n const t = w & -w\n const index = (k << 5) + hammingWeight(t - 1)\n callback(index, i)\n w ^= t\n ++i\n }\n }\n }\n\n /**\n * Get an array with the set bits\n * @return {Array} bit indices\n */\n toArray () {\n const words = this._words\n const answer = new Array(this.getSize())\n const count = this._words.length\n let pos = 0\n for (let k = 0; k < count; ++k) {\n let w = words[ k ]\n while (w !== 0) {\n const t = w & -w\n answer[ pos++ ] = (k << 5) + hammingWeight(t - 1)\n w ^= t\n }\n }\n return answer\n }\n\n toString () {\n return '{' + this.toArray().join(',') + '}'\n }\n\n toSeleString () {\n const sele = this.toArray().join(',')\n return sele ? '@' + sele : 'NONE'\n }\n\n /**\n * Clone this object\n * @return {BitArray} the cloned object\n */\n clone () {\n const clone = Object.create(BitArray.prototype)\n clone.length = this.length\n clone._words = new Uint32Array(this._words)\n return clone\n }\n}","/**\n * @file Adjacency List\n * @author Alexander Rose \n * @private\n */\n\nexport interface Edges {\n nodeArray1: ArrayLike\n nodeArray2: ArrayLike\n edgeCount: number\n nodeCount: number\n}\n\nexport interface AdjacencyList {\n /* number of edges for each node */\n countArray: Uint8Array\n /* offset into indexArray for each node */\n offsetArray: Int32Array\n /* edge indices, grouped by nodes */\n indexArray: Int32Array\n}\n\nexport function createAdjacencyList (edges: Edges): AdjacencyList {\n const { edgeCount, nodeCount, nodeArray1, nodeArray2 } = edges\n\n const countArray = new Uint8Array(nodeCount)\n const offsetArray = new Int32Array(nodeCount)\n\n // count edges per node\n for (let i = 0; i < edgeCount; ++i) {\n countArray[ nodeArray1[ i ] ] += 1\n countArray[ nodeArray2[ i ] ] += 1\n }\n\n // get offsets to node edges\n for (let i = 1; i < nodeCount; ++i) {\n offsetArray[ i ] += offsetArray[ i - 1 ] + countArray[ i - 1 ]\n }\n\n // prepare index array\n const bondCount2 = edgeCount * 2\n const indexArray = new Int32Array(bondCount2)\n for (let j = 0; j < bondCount2; ++j) {\n indexArray[ j ] = -1\n }\n\n // build index array\n for (let i = 0; i < edgeCount; ++i) {\n const idx1 = nodeArray1[ i ]\n const idx2 = nodeArray2[ i ]\n let j1 = offsetArray[ idx1 ]\n while (indexArray[ j1 ] !== -1 && j1 < bondCount2) {\n j1 += 1\n }\n indexArray[ j1 ] = i\n let j2 = offsetArray[ idx2 ]\n while (indexArray[ j2 ] !== -1 && j2 < bondCount2) {\n j2 += 1\n }\n indexArray[ j2 ] = i\n }\n\n return { countArray, offsetArray, indexArray }\n}\n","/**\n * @file Features\n * @author Alexander Rose \n */\n\nimport AtomProxy from '../../proxy/atom-proxy'\n\nexport interface Features {\n types: FeatureType[]\n groups: FeatureGroup[]\n centers: { x: number[], y: number[], z: number[] }\n atomSets: number[][]\n}\n\nexport const enum FeatureType {\n Unknown = 0,\n PositiveCharge = 1,\n NegativeCharge = 2,\n AromaticRing = 3,\n HydrogenDonor = 4,\n HydrogenAcceptor = 5,\n HalogenDonor = 6,\n HalogenAcceptor = 7,\n Hydrophobic = 8,\n WeakHydrogenDonor = 9,\n IonicTypePartner = 10,\n DativeBondPartner = 11,\n TransitionMetal = 12,\n IonicTypeMetal = 13\n}\n\nexport const enum FeatureGroup {\n Unknown = 0,\n QuaternaryAmine = 1,\n TertiaryAmine = 2,\n Sulfonium = 3,\n SulfonicAcid = 4,\n Sulfate = 5,\n Phosphate = 6,\n Halocarbon = 7,\n Guanidine = 8,\n Acetamidine = 9,\n Carboxylate = 10\n}\n\nexport function createFeatures (): Features {\n return {\n types: [],\n groups: [],\n centers: { x: [], y: [], z: [] },\n atomSets: []\n }\n}\n\nexport interface FeatureState {\n type: FeatureType\n group: FeatureGroup\n x: number\n y: number\n z: number\n atomSet: number[]\n}\n\nexport function createFeatureState(type = FeatureType.Unknown, group = FeatureGroup.Unknown): FeatureState {\n return { type, group, x: 0, y: 0, z: 0, atomSet: [] }\n}\n\nexport function addAtom (state: FeatureState, atom: AtomProxy) {\n state.x += atom.x\n state.y += atom.y\n state.z += atom.z\n state.atomSet.push(atom.index)\n}\n\nexport function addFeature (features: Features, state: FeatureState) {\n const n = state.atomSet.length\n if (n > 0) {\n const { types, groups, centers, atomSets } = features\n types.push(state.type)\n groups.push(state.group)\n centers.x.push(state.x / n)\n centers.y.push(state.y / n)\n centers.z.push(state.z / n)\n atomSets.push(state.atomSet)\n }\n}\n","/**\n * @file Structure Constants\n * @author Alexander Rose \n * @private\n */\n\n// entity types\nexport const UnknownEntity = 0\nexport const PolymerEntity = 1\nexport const NonPolymerEntity = 2\nexport const MacrolideEntity = 3\nexport const WaterEntity = 4\n\n// molecule types\nexport const UnknownType = 0\nexport const WaterType = 1\nexport const IonType = 2\nexport const ProteinType = 3\nexport const RnaType = 4\nexport const DnaType = 5\nexport const SaccharideType = 6\n\n// backbone types\nexport const UnknownBackboneType = 0\nexport const ProteinBackboneType = 1\nexport const RnaBackboneType = 2\nexport const DnaBackboneType = 3\nexport const CgProteinBackboneType = 4\nexport const CgRnaBackboneType = 5\nexport const CgDnaBackboneType = 6\n\n// chemical component types\nexport const ChemCompProtein = [\n 'D-BETA-PEPTIDE, C-GAMMA LINKING', 'D-GAMMA-PEPTIDE, C-DELTA LINKING',\n 'D-PEPTIDE COOH CARBOXY TERMINUS', 'D-PEPTIDE NH3 AMINO TERMINUS', 'D-PEPTIDE LINKING',\n 'L-BETA-PEPTIDE, C-GAMMA LINKING', 'L-GAMMA-PEPTIDE, C-DELTA LINKING',\n 'L-PEPTIDE COOH CARBOXY TERMINUS', 'L-PEPTIDE NH3 AMINO TERMINUS', 'L-PEPTIDE LINKING',\n 'PEPTIDE LINKING', 'PEPTIDE-LIKE'\n]\nexport const ChemCompRna = [\n 'RNA OH 3 PRIME TERMINUS', 'RNA OH 5 PRIME TERMINUS', 'RNA LINKING'\n]\nexport const ChemCompDna = [\n 'DNA OH 3 PRIME TERMINUS', 'DNA OH 5 PRIME TERMINUS', 'DNA LINKING',\n 'L-DNA LINKING', 'L-RNA LINKING'\n]\nexport const ChemCompSaccharide = [\n 'D-SACCHARIDE', 'D-SACCHARIDE 1,4 AND 1,4 LINKING', 'D-SACCHARIDE 1,4 AND 1,6 LINKING',\n 'L-SACCHARIDE', 'L-SACCHARIDE 1,4 AND 1,4 LINKING', 'L-SACCHARIDE 1,4 AND 1,6 LINKING',\n 'SACCHARIDE'\n]\nexport const ChemCompOther = [\n 'OTHER'\n]\nexport const ChemCompNonPolymer = [\n 'NON-POLYMER'\n]\nexport const ChemCompHetero = ChemCompNonPolymer.concat(ChemCompOther, ChemCompSaccharide)\n\n// secondary structure\nexport const SecStrucHelix = [ 'h', 'g', 'i' ]\nexport const SecStrucSheet = [ 'e', 'b' ]\nexport const SecStrucTurn = [ 's', 't', 'l', '' ]\n\nexport const AtomicNumbers: { [e: string]: number | undefined } = {\n 'H': 1, 'D': 1, 'T': 1, 'HE': 2, 'LI': 3, 'BE': 4, 'B': 5, 'C': 6, 'N': 7, 'O': 8, 'F': 9, 'NE': 10, 'NA': 11, 'MG': 12, 'AL': 13, 'SI': 14, 'P': 15, 'S': 16, 'CL': 17, 'AR': 18, 'K': 19, 'CA': 20, 'SC': 21, 'TI': 22, 'V': 23, 'CR': 24, 'MN': 25, 'FE': 26, 'CO': 27, 'NI': 28, 'CU': 29, 'ZN': 30, 'GA': 31, 'GE': 32, 'AS': 33, 'SE': 34, 'BR': 35, 'KR': 36, 'RB': 37, 'SR': 38, 'Y': 39, 'ZR': 40, 'NB': 41, 'MO': 42, 'TC': 43, 'RU': 44, 'RH': 45, 'PD': 46, 'AG': 47, 'CD': 48, 'IN': 49, 'SN': 50, 'SB': 51, 'TE': 52, 'I': 53, 'XE': 54, 'CS': 55, 'BA': 56, 'LA': 57, 'CE': 58, 'PR': 59, 'ND': 60, 'PM': 61, 'SM': 62, 'EU': 63, 'GD': 64, 'TB': 65, 'DY': 66, 'HO': 67, 'ER': 68, 'TM': 69, 'YB': 70, 'LU': 71, 'HF': 72, 'TA': 73, 'W': 74, 'RE': 75, 'OS': 76, 'IR': 77, 'PT': 78, 'AU': 79, 'HG': 80, 'TL': 81, 'PB': 82, 'BI': 83, 'PO': 84, 'AT': 85, 'RN': 86, 'FR': 87, 'RA': 88, 'AC': 89, 'TH': 90, 'PA': 91, 'U': 92, 'NP': 93, 'PU': 94, 'AM': 95, 'CM': 96, 'BK': 97, 'CF': 98, 'ES': 99, 'FM': 100, 'MD': 101, 'NO': 102, 'LR': 103, 'RF': 104, 'DB': 105, 'SG': 106, 'BH': 107, 'HS': 108, 'MT': 109, 'DS': 110, 'RG': 111, 'CN': 112, 'NH': 113, 'FL': 114, 'MC': 115, 'LV': 116, 'TS': 117, 'OG': 118\n}\nexport const DefaultAtomicNumber = 0\n\n/**\n * Enum mapping element to atomic number\n */\nexport const enum Elements {\n H = 1, D = 1, T = 1, HE = 2, LI = 3, BE = 4, B = 5, C = 6, N = 7, O = 8, F = 9, NE = 10, NA = 11, MG = 12, AL = 13, SI = 14, P = 15, S = 16, CL = 17, AR = 18, K = 19, CA = 20, SC = 21, TI = 22, V = 23, CR = 24, MN = 25, FE = 26, CO = 27, NI = 28, CU = 29, ZN = 30, GA = 31, GE = 32, AS = 33, SE = 34, BR = 35, KR = 36, RB = 37, SR = 38, Y = 39, ZR = 40, NB = 41, MO = 42, TC = 43, RU = 44, RH = 45, PD = 46, AG = 47, CD = 48, IN = 49, SN = 50, SB = 51, TE = 52, I = 53, XE = 54, CS = 55, BA = 56, LA = 57, CE = 58, PR = 59, ND = 60, PM = 61, SM = 62, EU = 63, GD = 64, TB = 65, DY = 66, HO = 67, ER = 68, TM = 69, YB = 70, LU = 71, HF = 72, TA = 73, W = 74, RE = 75, OS = 76, IR = 77, PT = 78, AU = 79, HG = 80, TL = 81, PB = 82, BI = 83, PO = 84, AT = 85, RN = 86, FR = 87, RA = 88, AC = 89, TH = 90, PA = 91, U = 92, NP = 93, PU = 94, AM = 95, CM = 96, BK = 97, CF = 98, ES = 99, FM = 100, MD = 101, NO = 102, LR = 103, RF = 104, DB = 105, SG = 106, BH = 107, HS = 108, MT = 109, DS = 110, RG = 111, CN = 112, NH = 113, FL = 114, MC = 115, LV = 116, TS = 117, OG = 118\n}\n\n// https://doi.org/10.1515/pac-2015-0305 (table 2, 3, and 4)\nexport const AtomWeights: { [e: number]: number | undefined } = {\n 1: 1.008, 2: 4.0026, 3: 6.94, 4: 9.0122, 5: 10.81, 6: 10.81, 7: 14.007, 8: 15.999, 9: 18.998, 10: 20.180, 11: 22.990, 12: 24.305, 13: 26.982, 14: 28.085, 15: 30.974, 16: 32.06, 17: 35.45, 18: 39.948, 19: 39.098, 20: 40.078, 21: 44.956, 22: 47.867, 23: 50.942, 24: 51.996, 25: 54.938, 26: 55.845, 27: 58.933, 28: 58.693, 29: 63.546, 30: 65.38, 31: 69.723, 32: 72.630, 33: 74.922, 34: 78.971, 35: 79.904, 36: 83.798, 37: 85.468, 38: 87.62, 39: 88.906, 40: 91.224, 41: 92.906, 42: 95.95, 43: 96.906, 44: 101.07, 45: 102.91, 46: 106.42, 47: 107.87, 48: 112.41, 49: 114.82, 50: 118.71, 51: 121.76, 52: 127.60, 53: 127.60, 54: 131.29, 55: 132.91, 56: 137.33, 57: 138.91, 58: 140.12, 59: 140.91, 60: 144.24, 61: 144.912, 62: 150.36, 63: 151.96, 64: 157.25, 65: 158.93, 66: 162.50, 67: 164.93, 68: 167.26, 69: 168.93, 70: 173.05, 71: 174.97, 72: 178.49, 73: 180.95, 74: 183.84, 75: 186.21, 76: 190.23, 77: 192.22, 78: 195.08, 79: 196.97, 80: 200.59, 81: 204.38, 82: 207.2, 83: 208.98, 84: 1.97, 85: 2.02, 86: 2.2, 87: 3.48, 88: 2.83, 89: 2.0, 90: 232.04, 91: 231.04, 92: 238.03, 93: 237.048, 94: 244.064, 95: 243.061, 96: 247.070, 97: 247.070, 98: 251.079, 99: 252.083, 100: 257.095, 101: 258.098, 102: 259.101, 103: 262.110, 104: 267.122, 105: 270.131, 106: 271.134, 107: 270.133, 108: 270.134, 109: 278.156, 110: 281.165, 111: 281.166, 112: 285.177, 113: 286.182, 114: 289.190, 115: 289.194, 116: 293.204, 117: 293.208, 118: 294.214\n}\nexport const DefaultAtomWeight = 10.81 // C\n\n// http://dx.doi.org/10.1021/jp8111556 (or 2.0)\nexport const VdwRadii: { [e: number]: number | undefined } = {\n 1: 1.1, 2: 1.4, 3: 1.81, 4: 1.53, 5: 1.92, 6: 1.7, 7: 1.55, 8: 1.52, 9: 1.47, 10: 1.54, 11: 2.27, 12: 1.73, 13: 1.84, 14: 2.1, 15: 1.8, 16: 1.8, 17: 1.75, 18: 1.88, 19: 2.75, 20: 2.31, 21: 2.3, 22: 2.15, 23: 2.05, 24: 2.05, 25: 2.05, 26: 2.05, 27: 2.0, 28: 2.0, 29: 2.0, 30: 2.1, 31: 1.87, 32: 2.11, 33: 1.85, 34: 1.9, 35: 1.83, 36: 2.02, 37: 3.03, 38: 2.49, 39: 2.4, 40: 2.3, 41: 2.15, 42: 2.1, 43: 2.05, 44: 2.05, 45: 2.0, 46: 2.05, 47: 2.1, 48: 2.2, 49: 2.2, 50: 1.93, 51: 2.17, 52: 2.06, 53: 1.98, 54: 2.16, 55: 3.43, 56: 2.68, 57: 2.5, 58: 2.48, 59: 2.47, 60: 2.45, 61: 2.43, 62: 2.42, 63: 2.4, 64: 2.38, 65: 2.37, 66: 2.35, 67: 2.33, 68: 2.32, 69: 2.3, 70: 2.28, 71: 2.27, 72: 2.25, 73: 2.2, 74: 2.1, 75: 2.05, 76: 2.0, 77: 2.0, 78: 2.05, 79: 2.1, 80: 2.05, 81: 1.96, 82: 2.02, 83: 2.07, 84: 1.97, 85: 2.02, 86: 2.2, 87: 3.48, 88: 2.83, 89: 2.0, 90: 2.4, 91: 2.0, 92: 2.3, 93: 2.0, 94: 2.0, 95: 2.0, 96: 2.0, 97: 2.0, 98: 2.0, 99: 2.0, 100: 2.0, 101: 2.0, 102: 2.0, 103: 2.0, 104: 2.0, 105: 2.0, 106: 2.0, 107: 2.0, 108: 2.0, 109: 2.0, 110: 2.0, 111: 2.0, 112: 2.0, 113: 2.0, 114: 2.0, 115: 2.0, 116: 2.0, 117: 2.0, 118: 2.0\n}\nexport const DefaultVdwRadius = 2.0 // C\n\n// Peter Rose (peter.rose@rcsb.org), private communication, average accross PDB\nexport const ResidueRadii: { [k: string]: number } = {\n '2QY': 6.58,\n 'CY0': 11.98,\n '2QZ': 2.52,\n 'CY1': 6.59,\n 'HHK': 5.11,\n 'CXM': 4.69,\n 'HHI': 4.58,\n 'CY4': 4.57,\n 'S12': 18.57,\n 'CY3': 2.79,\n 'C5C': 5.35,\n 'PFX': 11.84,\n '2R3': 6.94,\n '2R1': 3.78,\n 'ILX': 4.99,\n '32S': 5.68,\n 'BTK': 8.59,\n '32T': 5.72,\n 'FAK': 9.8,\n 'B27': 2.78,\n 'ILM': 3.84,\n 'C4R': 5.63,\n '32L': 6.75,\n 'SYS': 3.01,\n '1MH': 5.04,\n 'ILE': 3.65,\n 'YNM': 6.39,\n '2RX': 4.91,\n 'B3A': 2.48,\n 'GEE': 4.76,\n '7MN': 7.34,\n 'B3E': 5.4,\n 'ARG': 6.33,\n '200': 6.89,\n 'HIP': 5.47,\n 'HIA': 4.64,\n 'B3K': 5.89,\n 'HIC': 5.76,\n 'B3L': 4.96,\n 'B3M': 5.07,\n 'ARM': 6.86,\n 'ARO': 7.35,\n 'AR4': 8.42,\n 'PG1': 10.67,\n 'YOF': 6.44,\n 'IML': 3.74,\n 'SXE': 6.65,\n 'HIQ': 7.98,\n 'PFF': 6.31,\n 'HIS': 4.52,\n '0TD': 3.62,\n 'C3Y': 5.24,\n '1OP': 11.55,\n '02Y': 4.77,\n '02V': 4.83,\n 'ASB': 5.59,\n '30V': 8.53,\n 'S2P': 4.81,\n 'ASP': 3.55,\n 'ASN': 3.54,\n '2OR': 6.91,\n 'QMM': 6.13,\n '2P0': 8.52,\n 'ASL': 5.36,\n 'HFA': 5.14,\n '5PG': 5.69,\n 'B3X': 4.38,\n 'AS9': 4.1,\n 'ARV': 7.59,\n 'B3U': 6.06,\n 'S2C': 7.54,\n 'B3T': 3.34,\n '175': 5.64,\n 'GFT': 8.18,\n 'HG7': 6.8,\n 'B3Q': 4.48,\n 'ASA': 3.64,\n '02K': 2.94,\n 'B3Y': 7.45,\n 'PHD': 5.35,\n 'C6C': 6.42,\n 'BUC': 5.8,\n 'HGL': 8.07,\n 'PHE': 5.06,\n '03Y': 2.6,\n 'PHA': 5.11,\n 'OCY': 5.0,\n '4PH': 6.79,\n '5OH': 4.7,\n '31Q': 10.46,\n 'BTR': 7.98,\n '3PX': 4.7,\n '1PA': 8.07,\n 'ASX': 3.54,\n 'IOR': 7.23,\n '03E': 3.38,\n 'PHL': 5.17,\n 'KWS': 5.09,\n 'PHI': 7.12,\n 'NAL': 7.22,\n 'S1H': 19.21,\n '2ML': 3.86,\n '2MR': 7.35,\n 'GHG': 4.83,\n 'TYY': 6.54,\n '2MT': 3.67,\n '56A': 13.01,\n 'SVA': 5.46,\n 'TYX': 8.31,\n 'TYS': 8.59,\n 'TYR': 6.38,\n 'TYQ': 6.43,\n 'HLU': 3.99,\n 'MYK': 19.47,\n 'TYO': 7.71,\n 'HLX': 4.98,\n 'TYN': 9.87,\n 'TYJ': 6.25,\n 'TYI': 6.49,\n 'LYH': 5.13,\n 'LYF': 12.19,\n 'SUN': 6.73,\n 'LYR': 18.28,\n 'TYB': 6.46,\n '11W': 14.39,\n 'LYS': 5.54,\n 'LYN': 4.8,\n '11Q': 4.85,\n 'LYO': 4.71,\n 'LYZ': 1.76,\n 'TXY': 6.44,\n 'MYN': 4.71,\n 'TY5': 10.6,\n 'HMR': 5.09,\n '01W': 8.55,\n 'LYX': 13.36,\n 'TY8': 7.22,\n 'TY2': 6.49,\n 'KYN': 6.18,\n 'KYQ': 9.75,\n 'CZZ': 5.14,\n 'IIL': 3.81,\n 'HNC': 10.41,\n 'OIC': 4.62,\n 'LVN': 2.89,\n 'QIL': 3.84,\n 'JJL': 8.3,\n 'VAH': 3.88,\n 'JJJ': 7.5,\n 'JJK': 7.43,\n 'VAD': 2.56,\n 'CYW': 4.65,\n '0QL': 5.72,\n '143': 8.22,\n 'SVX': 7.04,\n 'CYJ': 11.64,\n 'SVY': 7.1,\n 'SVZ': 6.6,\n 'CYG': 8.03,\n 'CYF': 13.54,\n 'SVV': 5.09,\n 'GL3': 2.72,\n '8SP': 14.26,\n 'CYS': 2.78,\n '004': 4.33,\n 'CYR': 10.33,\n 'PLJ': 3.71,\n 'EXY': 7.37,\n 'HL2': 3.75,\n 'A5N': 5.21,\n 'CYQ': 5.67,\n 'CZ2': 5.16,\n 'LWY': 4.12,\n 'PM3': 8.78,\n 'OHS': 6.98,\n 'OHI': 5.35,\n '3TY': 8.42,\n 'CYD': 8.55,\n 'DYS': 7.87,\n 'DAH': 6.47,\n '4IK': 11.81,\n '3EG': 3.66,\n 'AYA': 3.65,\n '4IN': 6.31,\n 'DAB': 3.48,\n '4HT': 6.03,\n 'RGL': 7.03,\n 'DAM': 2.49,\n 'NFA': 5.04,\n 'WFP': 6.07,\n '2JC': 2.97,\n 'HAR': 7.55,\n '2JG': 5.67,\n 'MH6': 1.72,\n '2JF': 9.13,\n '3FG': 4.96,\n 'MGN': 4.84,\n 'AZH': 5.36,\n 'AZK': 6.03,\n 'ZBZ': 7.79,\n 'TBG': 2.58,\n 'VAL': 2.51,\n 'MGG': 7.34,\n 'AZS': 5.61,\n 'FHL': 9.75,\n '2JH': 4.56,\n 'IEL': 7.07,\n 'FHO': 6.75,\n 'DA2': 7.79,\n 'FH7': 6.99,\n 'ME0': 4.52,\n '3GL': 4.84,\n 'MDO': 5.03,\n 'AZY': 7.37,\n 'A8E': 3.76,\n 'ZCL': 6.71,\n 'MDH': 2.58,\n 'LA2': 14.07,\n '4FW': 6.1,\n 'YCM': 5.32,\n 'MDF': 4.95,\n 'YCP': 3.01,\n 'TEF': 8.63,\n 'FGP': 4.34,\n 'UF0': 19.72,\n 'XCN': 4.57,\n 'FGL': 2.56,\n 'MF3': 6.37,\n 'MEQ': 5.13,\n 'LAA': 3.23,\n 'IGL': 5.52,\n 'MET': 4.49,\n 'NIY': 6.81,\n 'QCS': 5.18,\n 'TCQ': 8.56,\n 'MEN': 4.33,\n '4HL': 8.79,\n 'MEA': 4.95,\n 'EFC': 5.28,\n 'LAL': 2.41,\n '2HF': 5.52,\n 'KBE': 5.64,\n 'OCS': 3.94,\n 'CAF': 5.46,\n 'NC1': 11.4,\n 'NBQ': 9.82,\n 'CAB': 4.19,\n 'MBQ': 9.55,\n '193': 7.38,\n '192': 2.44,\n '0WZ': 7.61,\n 'CAS': 5.35,\n 'NB8': 11.98,\n 'OBS': 11.71,\n '1AC': 2.42,\n 'PCA': 3.48,\n 'MCL': 9.73,\n 'LBY': 7.75,\n 'GAU': 4.67,\n 'PBF': 9.75,\n 'MCG': 6.46,\n 'DDE': 6.86,\n '19W': 3.94,\n 'MD5': 9.33,\n 'MD6': 6.44,\n 'MD3': 8.41,\n 'MCS': 7.56,\n 'OBF': 3.64,\n 'UAL': 4.68,\n 'PAT': 6.05,\n 'IAM': 8.88,\n 'PAQ': 8.77,\n 'FDL': 9.49,\n 'NCB': 3.45,\n 'LCK': 9.81,\n 'DDZ': 2.52,\n '2FM': 5.54,\n 'IAR': 6.77,\n 'OAS': 4.8,\n 'HBN': 8.8,\n 'TA4': 5.55,\n '1C3': 7.43,\n 'ECX': 5.51,\n 'PF5': 6.28,\n 'RE3': 5.29,\n 'FCL': 6.25,\n 'ECC': 4.79,\n 'LDH': 7.06,\n 'NCY': 2.91,\n 'CCS': 4.58,\n 'PEC': 6.54,\n '2CO': 4.45,\n 'LE1': 2.72,\n 'HCM': 5.53,\n '07O': 8.05,\n 'HCL': 4.96,\n 'NEP': 6.94,\n 'PE1': 8.01,\n 'LEF': 4.37,\n 'FC0': 5.18,\n 'LED': 4.34,\n 'HCS': 4.09,\n 'DBU': 2.49,\n 'RE0': 5.53,\n 'LEN': 3.82,\n '1E3': 8.71,\n 'BB9': 2.56,\n 'BB8': 5.14,\n 'PCS': 5.05,\n 'BB7': 4.56,\n 'BB6': 2.62,\n 'LEU': 3.83,\n 'DBZ': 7.08,\n 'LET': 11.29,\n 'DBY': 6.46,\n 'ICY': 7.76,\n 'MAA': 2.4,\n 'CGA': 7.91,\n '5CS': 8.34,\n 'UGY': 3.7,\n 'LGY': 11.71,\n 'N10': 8.96,\n 'AAR': 6.39,\n 'FT6': 7.5,\n 'MOD': 12.62,\n '5CW': 7.21,\n 'PVH': 4.58,\n 'BBC': 6.42,\n 'YYA': 7.3,\n 'O12': 14.08,\n 'NOT': 7.15,\n 'KGC': 9.88,\n 'MP4': 5.86,\n '0CS': 4.07,\n 'MP8': 3.75,\n 'VLL': 2.54,\n 'VLM': 2.51,\n 'BCS': 8.03,\n 'MNL': 4.9,\n 'AA4': 4.47,\n 'SAC': 3.49,\n 'BCX': 2.99,\n '3CF': 6.47,\n 'SAH': 11.7,\n 'NNH': 6.86,\n 'CGU': 4.71,\n 'SIB': 12.41,\n 'TLY': 8.78,\n 'SIC': 4.81,\n 'VMS': 8.82,\n 'TMD': 6.76,\n 'MMO': 6.53,\n 'PXU': 2.46,\n '4AW': 6.22,\n 'OTH': 3.6,\n 'DLS': 6.84,\n 'MME': 4.99,\n 'DM0': 6.99,\n '0FL': 2.76,\n 'SBL': 8.96,\n 'CDV': 3.72,\n 'OTY': 6.51,\n 'PYA': 7.75,\n '2AS': 3.57,\n 'DMH': 4.92,\n 'ELY': 7.42,\n 'GVL': 9.6,\n 'FVA': 2.9,\n 'SAR': 2.48,\n '4BF': 6.92,\n 'EME': 4.69,\n 'CDE': 2.51,\n '3AR': 7.86,\n '3AH': 9.11,\n 'AC5': 2.44,\n 'FTR': 6.08,\n 'MLL': 3.76,\n 'NPH': 11.66,\n 'NPI': 6.9,\n 'DMT': 6.67,\n 'PYX': 11.3,\n 'MLE': 3.87,\n 'PYL': 9.67,\n 'ZZU': 6.94,\n 'H5M': 3.61,\n 'SCH': 4.46,\n 'DMK': 3.52,\n 'FTY': 9.07,\n '2AG': 3.7,\n 'ABA': 2.55,\n 'ZZJ': 2.44,\n 'MLZ': 6.8,\n 'MLY': 6.88,\n 'KCX': 7.28,\n 'ZZD': 8.16,\n '3A5': 5.37,\n 'LHC': 7.75,\n '9AT': 2.47,\n 'OZT': 3.4,\n 'THO': 2.62,\n 'THR': 2.5,\n 'DFI': 3.93,\n 'MKD': 6.42,\n '4CY': 4.6,\n 'SDP': 6.07,\n 'DFO': 3.94,\n '0A0': 3.45,\n '4DB': 9.73,\n 'ML3': 6.26,\n 'BG1': 8.02,\n 'SD4': 4.57,\n 'THC': 3.8,\n 'SCS': 5.48,\n 'TH5': 4.65,\n 'BFD': 5.33,\n 'AEI': 6.34,\n 'TH6': 2.85,\n 'SCY': 4.53,\n 'TIS': 4.81,\n 'SEE': 4.53,\n 'BHD': 3.48,\n 'SEB': 8.18,\n 'SEC': 2.96,\n 'SEP': 4.8,\n 'CLH': 7.13,\n 'TIH': 5.02,\n 'CLG': 13.62,\n 'SEN': 6.43,\n 'XXA': 7.34,\n 'SEL': 2.46,\n 'SE7': 4.19,\n '4CF': 7.72,\n 'G8M': 3.57,\n 'BH2': 3.51,\n 'UN2': 3.22,\n 'VR0': 10.51,\n 'MK8': 4.76,\n 'DHA': 2.32,\n 'LMQ': 4.69,\n 'SFE': 5.01,\n 'AHB': 3.47,\n 'OXX': 7.05,\n 'BIF': 9.63,\n 'IZO': 4.47,\n 'NMM': 8.25,\n '0BN': 7.0,\n 'HZP': 3.12,\n 'NMC': 4.23,\n 'DHL': 2.69,\n '9DS': 9.29,\n 'SER': 2.41,\n 'CHG': 4.2,\n 'MIR': 6.54,\n 'AGQ': 7.79,\n 'SET': 2.46,\n 'MIS': 6.32,\n '4FB': 3.08,\n '0AR': 8.46,\n 'LME': 3.99,\n 'FZN': 24.42,\n 'AGT': 9.04,\n 'IYR': 6.46,\n '9DN': 9.31,\n 'CHP': 5.75,\n 'UNK': 1.64,\n 'XX1': 9.92,\n 'AGM': 6.57,\n '0AH': 5.78,\n 'LLP': 10.22,\n '0AF': 6.72,\n '4DP': 9.28,\n 'HYP': 2.25,\n 'DIR': 5.8,\n 'LLY': 8.71,\n '0AK': 6.11,\n 'NLE': 4.67,\n 'OYL': 6.42,\n 'WVL': 4.69,\n '0A8': 8.1,\n 'NLY': 6.37,\n 'MHO': 4.89,\n 'VOL': 2.55,\n '0A1': 7.1,\n 'MHL': 3.92,\n 'NLP': 4.81,\n 'NLQ': 4.65,\n 'MHW': 2.74,\n 'BIL': 4.7,\n 'NLO': 4.8,\n 'MHU': 7.51,\n 'XW1': 9.36,\n 'LLO': 10.13,\n 'SGB': 6.88,\n 'MHV': 3.6,\n 'MHS': 4.51,\n '0A9': 5.17,\n '0LF': 9.96,\n 'HT7': 6.82,\n 'X2W': 6.6,\n 'YPZ': 9.38,\n 'I58': 6.73,\n 'FLA': 2.4,\n 'M0H': 4.83,\n 'HSL': 2.46,\n 'FLE': 6.17,\n 'KOR': 10.1,\n '1VR': 3.89,\n 'HSO': 4.56,\n 'TTS': 9.41,\n 'RVX': 7.01,\n 'TTQ': 7.71,\n 'H14': 5.27,\n 'HTI': 7.8,\n 'ONH': 6.14,\n 'LP6': 8.58,\n 'ONL': 4.83,\n 'AHH': 5.06,\n 'HS8': 7.4,\n 'HS9': 4.71,\n 'BL2': 5.82,\n 'AHP': 5.26,\n '6HN': 7.34,\n 'HRP': 5.46,\n 'POM': 3.6,\n 'WPA': 5.11,\n '2ZC': 4.29,\n 'CPC': 2.65,\n 'AIB': 2.4,\n 'XSN': 3.47,\n 'M2S': 5.28,\n 'GND': 6.67,\n 'GNC': 4.6,\n 'MVA': 2.56,\n 'OLZ': 5.32,\n 'M2L': 6.15,\n 'TRF': 6.69,\n 'NZH': 7.66,\n 'SRZ': 5.27,\n 'OLD': 10.47,\n 'CME': 5.86,\n 'CMH': 5.3,\n 'ALA': 2.38,\n 'TRQ': 7.36,\n 'PPN': 7.24,\n 'TRP': 6.07,\n 'TRO': 5.82,\n 'TRN': 5.95,\n 'NYS': 8.1,\n 'ALC': 5.26,\n 'U3X': 11.7,\n 'HVA': 2.58,\n 'TS9': 3.92,\n 'TRX': 7.27,\n 'TRW': 11.8,\n 'LPL': 7.51,\n 'GMA': 4.4,\n 'OMT': 5.07,\n 'CMT': 3.54,\n 'GME': 4.66,\n 'NYB': 6.07,\n 'PR3': 5.12,\n 'LPD': 2.48,\n 'GLU': 4.49,\n '1X6': 6.84,\n 'LPG': 2.39,\n 'GLX': 4.52,\n 'PR4': 4.52,\n 'CML': 6.16,\n 'FME': 4.52,\n 'HTR': 6.48,\n 'PR7': 4.66,\n 'Z3E': 7.2,\n 'GLZ': 2.39,\n 'BMT': 6.37,\n 'WRP': 8.16,\n 'GLY': 2.37,\n 'OMY': 6.11,\n 'MTY': 5.46,\n 'OMX': 6.15,\n 'GLN': 4.46,\n '2XA': 8.25,\n '28X': 7.84,\n '7JA': 9.46,\n 'FLT': 9.65,\n 'GLJ': 3.7,\n 'OMH': 5.26,\n 'TSY': 4.26,\n 'PRV': 4.28,\n 'CS4': 11.21,\n 'DOA': 12.33,\n '23P': 5.42,\n 'CS3': 8.24,\n '6CL': 6.47,\n 'PRR': 5.58,\n 'KST': 11.58,\n 'CS1': 7.23,\n 'PRS': 2.63,\n 'ZYJ': 11.4,\n 'IT1': 9.75,\n 'UU5': 4.98,\n 'ESB': 6.69,\n 'UU4': 2.49,\n 'ESC': 5.65,\n 'LSO': 10.58,\n 'ZYK': 11.45,\n '9NV': 8.99,\n '23F': 5.27,\n 'ORN': 4.25,\n 'HOX': 6.61,\n 'CSD': 3.95,\n 'FP9': 3.03,\n 'DO2': 4.44,\n 'SLL': 11.53,\n 'P3Q': 9.54,\n 'ORQ': 6.04,\n 'MSL': 5.21,\n 'DNP': 2.45,\n 'CSB': 3.51,\n 'WLU': 4.24,\n 'CSA': 5.7,\n 'MT2': 5.51,\n 'CSO': 3.53,\n 'TPO': 4.73,\n 'MSP': 13.11,\n '23S': 6.09,\n 'MSO': 4.96,\n 'PRO': 2.41,\n 'TPL': 5.41,\n 'DNS': 8.79,\n 'CSK': 3.91,\n 'Z70': 7.4,\n 'CSJ': 7.51,\n 'DNW': 7.97,\n 'PRK': 9.15,\n 'GSU': 11.81,\n 'LTA': 6.57,\n 'HPE': 6.63,\n 'TPQ': 6.48,\n 'PRJ': 5.26,\n 'PSW': 4.65,\n 'L3O': 3.89,\n 'CSU': 4.89,\n 'ALY': 7.38,\n 'M3L': 7.12,\n 'CSW': 3.68,\n 'XPR': 7.68,\n 'D4P': 5.66,\n 'FOE': 8.17,\n 'SLZ': 5.69,\n 'CSP': 5.26,\n 'TQI': 7.68,\n 'ALT': 2.72,\n 'CSR': 5.42,\n 'CSS': 3.61,\n 'M3R': 7.18,\n 'ALO': 2.57,\n 'R4K': 4.67,\n 'SMF': 9.0,\n 'MSA': 2.73,\n 'SMC': 3.39,\n 'CSX': 3.47,\n 'SME': 4.8,\n 'ETA': 2.4,\n 'CSZ': 3.6,\n '22G': 8.8,\n 'MSE': 4.62,\n 'ALN': 6.16,\n 'PSH': 7.26,\n 'CTE': 7.27,\n 'DON': 6.72,\n 'CTH': 3.45,\n 'U2X': 11.54,\n '6CW': 7.56,\n 'TQZ': 6.97,\n '3YM': 6.52,\n 'OSE': 4.49,\n '2VA': 9.82,\n 'TQQ': 7.76,\n 'NRG': 8.35,\n 'BPE': 7.24,\n 'F2F': 6.25,\n '1TQ': 8.58,\n 'I2M': 3.13,\n 'NVA': 3.76,\n 'R1A': 8.2,\n 'QPA': 6.95,\n 'C1X': 11.63,\n 'FRD': 5.05,\n 'HR7': 6.98,\n 'SNC': 3.93,\n 'QPH': 5.15,\n '26B': 8.39,\n 'DPQ': 6.54,\n 'DPP': 2.51,\n '2TY': 8.65,\n 'TNR': 6.88,\n 'PTH': 8.35,\n 'DPL': 3.58,\n 'APK': 8.79,\n '1TY': 8.84,\n 'HRG': 7.36,\n 'PTM': 8.74,\n '1U8': 3.62,\n 'PTR': 8.64,\n 'LVG': 3.01,\n '6FL': 4.85,\n 'SOC': 4.05,\n 'KPI': 9.79,\n 'IPG': 2.91,\n 'P2Y': 2.51,\n 'N2C': 3.55,\n 'T0I': 7.34,\n 'MPH': 5.29,\n 'R2T': 4.71,\n 'TOX': 6.78,\n 'P2Q': 9.8,\n 'GPL': 10.77,\n 'MPJ': 5.07,\n 'F2Y': 6.2,\n 'T11': 8.58,\n '9NR': 9.33,\n 'FPR': 8.85,\n '9NF': 8.93,\n 'KPY': 10.17,\n '9NE': 9.77,\n 'TOQ': 7.5,\n 'MPQ': 4.2,\n 'FPK': 3.08,\n 'HQA': 7.25,\n 'SOY': 10.94\n}\nexport const DefaultResidueRadius = 5.0\n\n// http://dx.doi.org/10.1039/b801115j (or 1.6)\nexport const CovalentRadii: { [e: number]: number | undefined } = {\n 1: 0.31, 2: 0.28, 3: 1.28, 4: 0.96, 5: 0.84, 6: 0.76, 7: 0.71, 8: 0.66, 9: 0.57, 10: 0.58, 11: 1.66, 12: 1.41, 13: 1.21, 14: 1.11, 15: 1.07, 16: 1.05, 17: 1.02, 18: 1.06, 19: 2.03, 20: 1.76, 21: 1.7, 22: 1.6, 23: 1.53, 24: 1.39, 25: 1.39, 26: 1.32, 27: 1.26, 28: 1.24, 29: 1.32, 30: 1.22, 31: 1.22, 32: 1.2, 33: 1.19, 34: 1.2, 35: 1.2, 36: 1.16, 37: 2.2, 38: 1.95, 39: 1.9, 40: 1.75, 41: 1.64, 42: 1.54, 43: 1.47, 44: 1.46, 45: 1.42, 46: 1.39, 47: 1.45, 48: 1.44, 49: 1.42, 50: 1.39, 51: 1.39, 52: 1.38, 53: 1.39, 54: 1.4, 55: 2.44, 56: 2.15, 57: 2.07, 58: 2.04, 59: 2.03, 60: 2.01, 61: 1.99, 62: 1.98, 63: 1.98, 64: 1.96, 65: 1.94, 66: 1.92, 67: 1.92, 68: 1.89, 69: 1.9, 70: 1.87, 71: 1.87, 72: 1.75, 73: 1.7, 74: 1.62, 75: 1.51, 76: 1.44, 77: 1.41, 78: 1.36, 79: 1.36, 80: 1.32, 81: 1.45, 82: 1.46, 83: 1.48, 84: 1.4, 85: 1.5, 86: 1.5, 87: 2.6, 88: 2.21, 89: 2.15, 90: 2.06, 91: 2.0, 92: 1.96, 93: 1.9, 94: 1.87, 95: 1.8, 96: 1.69, 97: 1.6, 98: 1.6, 99: 1.6, 100: 1.6, 101: 1.6, 102: 1.6, 103: 1.6, 104: 1.6, 105: 1.6, 106: 1.6, 107: 1.6, 108: 1.6, 109: 1.6, 110: 1.6, 111: 1.6, 112: 1.6, 113: 1.6, 114: 1.6, 115: 1.6, 116: 1.6, 117: 1.6, 118: 1.6\n}\nexport const DefaultCovalentRadius = 1.6\n\nexport const Valences: { [e: number]: number[] | undefined } = {\n 1: [ 1 ],\n 2: [ 0 ],\n 3: [ 1 ],\n 4: [ 2 ],\n 5: [ 3 ],\n 6: [ 4 ],\n 7: [ 3 ],\n 8: [ 2 ],\n 9: [ 1 ],\n 10: [ 0 ],\n 11: [ 1 ],\n 12: [ 2 ],\n 13: [ 6 ],\n 14: [ 6 ],\n 15: [ 3, 5, 7 ],\n 16: [ 2, 4, 6 ],\n 17: [ 1 ],\n 18: [ 0 ],\n 19: [ 1 ],\n 20: [ 2 ],\n\n 31: [ 3 ],\n 32: [ 4 ],\n 33: [ 3, 5 ],\n 34: [ 2, 4, 6 ],\n 35: [ 1 ],\n 36: [ 0 ],\n 37: [ 1 ],\n 38: [ 2 ],\n\n 49: [ 3 ],\n 50: [ 4 ],\n 51: [ 3, 5 ],\n 52: [ 2 ],\n 53: [ 1, 2, 5 ],\n 54: [ 0, 2 ],\n 55: [ 1 ],\n 56: [ 2 ],\n\n 81: [ 3 ],\n 82: [ 4 ],\n 83: [ 3 ],\n 84: [ 2 ],\n 85: [ 1 ],\n 86: [ 0 ],\n 87: [ 1 ],\n 88: [ 2 ]\n}\nexport const DefaultValence = -1\n\nexport const OuterShellElectronCounts: { [e: number]: number | undefined } = {\n1: 1, 2: 2, 3: 1, 4: 2, 5: 3, 6: 4, 7: 5, 8: 6, 9: 7, 10: 8, 11: 1, 12: 2, 13: 3, 14: 4, 15: 5, 16: 6, 17: 7, 18: 8, 19: 1, 20: 2, 21: 3, 22: 4, 23: 5, 24: 6, 25: 7, 26: 8, 27: 9, 28: 10, 29: 11, 30: 2, 31: 3, 32: 4, 33: 5, 34: 6, 35: 7, 36: 8, 37: 1, 38: 2, 39: 3, 40: 4, 41: 5, 42: 6, 43: 7, 44: 8, 45: 9, 46: 10, 47: 11, 48: 2, 49: 3, 50: 4, 51: 5, 52: 6, 53: 7, 54: 8, 55: 1, 56: 2, 57: 3, 58: 4, 59: 3, 60: 4, 61: 5, 62: 6, 63: 7, 64: 8, 65: 9, 66: 10, 67: 11, 68: 12, 69: 13, 70: 14, 71: 15, 72: 4, 73: 5, 74: 6, 75: 7, 76: 8, 77: 9, 78: 10, 79: 11, 80: 2, 81: 3, 82: 4, 83: 5, 84: 6, 85: 7, 86: 8, 87: 1, 88: 2, 89: 3, 90: 4, 91: 3, 92: 4, 93: 5, 94: 6, 95: 7, 96: 8, 97: 9, 98: 10, 99: 11, 100: 12, 101: 13, 102: 14, 103: 15, 104: 2, 105: 2, 106: 2, 107: 2, 108: 2, 109: 2, 110: 2, 111: 2, 112: 2, 113: 3, 114: 4, 115: 5, 116: 6, 117: 7, 118: 8\n}\nexport const DefaultOuterShellElectronCount = 2\n\n// http://blanco.biomol.uci.edu/Whole_residue_HFscales.txt\n// https://www.nature.com/articles/nsb1096-842\nexport const ResidueHydrophobicity: { [k: string]: [number, number, number] } = {\n // AA DGwif DGwoct Oct-IF\n 'ALA': [ 0.17, 0.50, 0.33 ],\n 'ARG': [ 0.81, 1.81, 1.00 ],\n 'ASN': [ 0.42, 0.85, 0.43 ],\n 'ASP': [ 1.23, 3.64, 2.41 ],\n 'ASH': [ -0.07, 0.43, 0.50 ],\n 'CYS': [ -0.24, -0.02, 0.22 ],\n 'GLN': [ 0.58, 0.77, 0.19 ],\n 'GLU': [ 2.02, 3.63, 1.61 ],\n 'GLH': [ -0.01, 0.11, 0.12 ],\n 'GLY': [ 0.01, 1.15, 1.14 ],\n // \"His+\": [ 0.96, 2.33, 1.37 ],\n 'HIS': [ 0.17, 0.11, -0.06 ],\n 'ILE': [ -0.31, -1.12, -0.81 ],\n 'LEU': [ -0.56, -1.25, -0.69 ],\n 'LYS': [ 0.99, 2.80, 1.81 ],\n 'MET': [ -0.23, -0.67, -0.44 ],\n 'PHE': [ -1.13, -1.71, -0.58 ],\n 'PRO': [ 0.45, 0.14, -0.31 ],\n 'SER': [ 0.13, 0.46, 0.33 ],\n 'THR': [ 0.14, 0.25, 0.11 ],\n 'TRP': [ -1.85, -2.09, -0.24 ],\n 'TYR': [ -0.94, -0.71, 0.23 ],\n 'VAL': [ 0.07, -0.46, -0.53 ]\n}\nexport const DefaultResidueHydrophobicity = [ 0.00, 0.00, 0.00 ]\n\nexport const AA1: { [k: string]: string } = {\n 'HIS': 'H',\n 'ARG': 'R',\n 'LYS': 'K',\n 'ILE': 'I',\n 'PHE': 'F',\n 'LEU': 'L',\n 'TRP': 'W',\n 'ALA': 'A',\n 'MET': 'M',\n 'PRO': 'P',\n 'CYS': 'C',\n 'ASN': 'N',\n 'VAL': 'V',\n 'GLY': 'G',\n 'SER': 'S',\n 'GLN': 'Q',\n 'TYR': 'Y',\n 'ASP': 'D',\n 'GLU': 'E',\n 'THR': 'T',\n\n 'SEC': 'U', // as per IUPAC definition\n 'PYL': 'O', // as per IUPAC definition\n}\n\nexport const AA3 = Object.keys(AA1)\n\nexport const RnaBases = [ 'A', 'C', 'T', 'G', 'U', 'I' ]\n\nexport const DnaBases = [ 'DA', 'DC', 'DT', 'DG', 'DU', 'DI' ]\n\nexport const PurinBases = [ 'A', 'G', 'I', 'DA', 'DG', 'DI' ]\n\nexport const Bases = RnaBases.concat(DnaBases)\n\nexport const WaterNames = [\n 'SOL', 'WAT', 'HOH', 'H2O', 'W', 'DOD', 'D3O', 'TIP3', 'TIP4', 'SPC'\n]\n\n// all chemical components with the word \"ion\" in their name, Sep 2016\n//\n// SET SESSION group_concat_max_len = 1000000;\n// SELECT GROUP_CONCAT(id_ ORDER BY id_ ASC SEPARATOR '\", \"') from\n// (\n// SELECT count(obj_id) as c, id_\n// FROM pdb.chem_comp WHERE name LIKE \"% ION%\"\n// GROUP BY id_\n// ) AS t1;\nexport const IonNames = [\n '118', '119', '1AL', '1CU', '2FK', '2HP', '2OF', '3CO',\n '3MT', '3NI', '3OF', '3P8', '4MO', '4PU', '543', '6MO', 'ACT', 'AG', 'AL',\n 'ALF', 'AM', 'ATH', 'AU', 'AU3', 'AUC', 'AZI', 'BA', 'BCT', 'BEF', 'BF4', 'BO4',\n 'BR', 'BS3', 'BSY', 'CA', 'CAC', 'CD', 'CD1', 'CD3', 'CD5', 'CE', 'CHT', 'CL',\n 'CO', 'CO3', 'CO5', 'CON', 'CR', 'CS', 'CSB', 'CU', 'CU1', 'CU3', 'CUA', 'CUZ',\n 'CYN', 'DME', 'DMI', 'DSC', 'DTI', 'DY', 'E4N', 'EDR', 'EMC', 'ER3', 'EU',\n 'EU3', 'F', 'FE', 'FE2', 'FPO', 'GA', 'GD3', 'GEP', 'HAI', 'HG', 'HGC', 'IN',\n 'IOD', 'IR', 'IR3', 'IRI', 'IUM', 'K', 'KO4', 'LA', 'LCO', 'LCP', 'LI', 'LU',\n 'MAC', 'MG', 'MH2', 'MH3', 'MLI', 'MLT', 'MMC', 'MN', 'MN3', 'MN5', 'MN6',\n 'MO1', 'MO2', 'MO3', 'MO4', 'MO5', 'MO6', 'MOO', 'MOS', 'MOW', 'MW1', 'MW2',\n 'MW3', 'NA', 'NA2', 'NA5', 'NA6', 'NAO', 'NAW', 'NCO', 'NET', 'NH4', 'NI',\n 'NI1', 'NI2', 'NI3', 'NO2', 'NO3', 'NRU', 'O4M', 'OAA', 'OC1', 'OC2', 'OC3',\n 'OC4', 'OC5', 'OC6', 'OC7', 'OC8', 'OCL', 'OCM', 'OCN', 'OCO', 'OF1', 'OF2',\n 'OF3', 'OH', 'OS', 'OS4', 'OXL', 'PB', 'PBM', 'PD', 'PDV', 'PER', 'PI', 'PO3',\n 'PO4', 'PR', 'PT', 'PT4', 'PTN', 'RB', 'RH3', 'RHD', 'RU', 'SB', 'SCN', 'SE4',\n 'SEK', 'SM', 'SMO', 'SO3', 'SO4', 'SR', 'T1A', 'TB', 'TBA', 'TCN', 'TEA', 'TH',\n 'THE', 'TL', 'TMA', 'TRA', 'UNX', 'V', 'VN3', 'VO4', 'W', 'WO5', 'Y1', 'YB',\n 'YB2', 'YH', 'YT3', 'ZCM', 'ZN', 'ZN2', 'ZN3', 'ZNO', 'ZO3',\n // additional ion names\n 'OHX'\n]\n\n// all chemical components with the word \"%saccharide%\" in their type, Sep 2016\n//\n// SET SESSION group_concat_max_len = 1000000;\n// select GROUP_CONCAT(id_ ORDER BY id_ ASC SEPARATOR '\", \"') from\n// (\n// SELECT count(obj_id), id_\n// FROM pdb.chem_comp WHERE type like \"%SACCHARIDE%\"\n// GROUP BY id_\n// ) AS t1;\nexport const SaccharideNames = [\n '045', '0AT', '0BD', '0MK', '0NZ', '0TS', '0V4', '0XY', '0YT', '10M',\n '147', '149', '14T', '15L', '16G', '18T', '18Y', '1AR', '1BW', '1GL', '1GN',\n '1JB', '1LL', '1NA', '1S3', '26M', '26Q', '26R', '26V', '26W', '26Y', '27C',\n '289', '291', '293', '2DG', '2F8', '2FG', '2FL', '2FP', '2GL', '2M4', '2M5',\n '32O', '34V', '3CM', '3DO', '3DY', '3FM', '3LR', '3MF', '3MG', '3SA', '3ZW',\n '46D', '46M', '46Z', '48Z', '4CQ', '4GC', '4NN', '50A', '5DI', '5GF', '5MM',\n '5RP', '5SA', '5SP', '64K', '6PG', '6SA', '7JZ', '7SA', 'A1Q', 'A2G', 'AAB',\n 'AAL', 'AAO', 'ABC', 'ABD', 'ABE', 'ABF', 'ABL', 'ACG', 'ACI', 'ACR', 'ACX',\n 'ADA', 'ADG', 'ADR', 'AF1', 'AFD', 'AFL', 'AFO', 'AFP', 'AFR', 'AGC', 'AGH',\n 'AGL', 'AHR', 'AIG', 'ALL', 'ALX', 'AMU', 'AOG', 'AOS', 'ARA', 'ARB', 'ARE',\n 'ARI', 'ASG', 'ASO', 'AXP', 'AXR', 'B0D', 'B16', 'B2G', 'B4G', 'B6D', 'B8D',\n 'B9D', 'BBK', 'BCD', 'BDG', 'BDP', 'BDR', 'BEM', 'BFP', 'BGC', 'BGL', 'BGP',\n 'BGS', 'BHG', 'BMA', 'BMX', 'BNG', 'BNX', 'BOG', 'BRI', 'BXF', 'BXP', 'BXX',\n 'BXY', 'C3X', 'C4X', 'C5X', 'CAP', 'CBI', 'CBK', 'CBS', 'CDR', 'CEG', 'CGF',\n 'CHO', 'CR1', 'CR6', 'CRA', 'CT3', 'CTO', 'CTR', 'CTT', 'D6G', 'DAF', 'DAG',\n 'DDA', 'DDB', 'DDL', 'DEL', 'DFR', 'DFX', 'DG0', 'DGC', 'DGD', 'DGM', 'DGS',\n 'DIG', 'DLF', 'DLG', 'DMU', 'DNO', 'DOM', 'DP5', 'DQQ', 'DQR', 'DR2', 'DR3',\n 'DR4', 'DRI', 'DSR', 'DT6', 'DVC', 'E4P', 'E5G', 'EAG', 'EBG', 'EBQ', 'EGA',\n 'EJT', 'EPG', 'ERE', 'ERI', 'F1P', 'F1X', 'F6P', 'FBP', 'FCA', 'FCB', 'FCT',\n 'FDP', 'FDQ', 'FFC', 'FIX', 'FMO', 'FRU', 'FSI', 'FU4', 'FUB', 'FUC', 'FUD',\n 'FUL', 'FXP', 'G16', 'G1P', 'G2F', 'G3I', 'G4D', 'G4S', 'G6D', 'G6P', 'G6S',\n 'GAC', 'GAD', 'GAL', 'GC1', 'GC4', 'GCD', 'GCN', 'GCO', 'GCS', 'GCT', 'GCU',\n 'GCV', 'GCW', 'GCX', 'GE1', 'GFG', 'GFP', 'GIV', 'GL0', 'GL2', 'GL5', 'GL6',\n 'GL7', 'GL9', 'GLA', 'GLB', 'GLC', 'GLD', 'GLF', 'GLG', 'GLO', 'GLP', 'GLS',\n 'GLT', 'GLW', 'GMH', 'GN1', 'GNX', 'GP1', 'GP4', 'GPH', 'GPM', 'GQ1', 'GQ2',\n 'GQ4', 'GS1', 'GS4', 'GSA', 'GSD', 'GTE', 'GTH', 'GTK', 'GTR', 'GTZ', 'GU0',\n 'GU1', 'GU2', 'GU3', 'GU4', 'GU5', 'GU6', 'GU8', 'GU9', 'GUF', 'GUP', 'GUZ',\n 'GYP', 'GYV', 'H2P', 'HDL', 'HMS', 'HS2', 'HSD', 'HSG', 'HSH', 'HSJ', 'HSQ',\n 'HSR', 'HSU', 'HSX', 'HSY', 'HSZ', 'IAB', 'IDG', 'IDR', 'IDS', 'IDT', 'IDU',\n 'IDX', 'IDY', 'IMK', 'IN1', 'IPT', 'ISL', 'KBG', 'KD2', 'KDA', 'KDM', 'KDO',\n 'KFN', 'KO1', 'KO2', 'KTU', 'L6S', 'LAG', 'LAI', 'LAK', 'LAO', 'LAT', 'LB2',\n 'LBT', 'LCN', 'LDY', 'LGC', 'LGU', 'LM2', 'LMT', 'LMU', 'LOG', 'LOX', 'LPK',\n 'LSM', 'LTM', 'LVZ', 'LXB', 'LXZ', 'M1F', 'M3M', 'M6P', 'M8C', 'MA1', 'MA2',\n 'MA3', 'MAB', 'MAG', 'MAL', 'MAN', 'MAT', 'MAV', 'MAW', 'MBG', 'MCU', 'MDA',\n 'MDM', 'MDP', 'MFA', 'MFB', 'MFU', 'MG5', 'MGA', 'MGL', 'MLB', 'MMA', 'MMN',\n 'MN0', 'MRP', 'MTT', 'MUG', 'MVP', 'MXY', 'N1L', 'N9S', 'NAA', 'NAG', 'NBG',\n 'NDG', 'NED', 'NG1', 'NG6', 'NGA', 'NGB', 'NGC', 'NGE', 'NGF', 'NGL', 'NGS',\n 'NGY', 'NHF', 'NM6', 'NM9', 'NTF', 'NTO', 'NTP', 'NXD', 'NYT', 'OPG', 'OPM',\n 'ORP', 'OX2', 'P3M', 'P53', 'P6P', 'PA5', 'PNA', 'PNG', 'PNW', 'PRP', 'PSJ',\n 'PSV', 'PTQ', 'QDK', 'QPS', 'QV4', 'R1P', 'R1X', 'R2B', 'R5P', 'RAA', 'RAE',\n 'RAF', 'RAM', 'RAO', 'RAT', 'RB5', 'RBL', 'RCD', 'RDP', 'REL', 'RER', 'RF5',\n 'RG1', 'RGG', 'RHA', 'RIB', 'RIP', 'RNS', 'RNT', 'ROB', 'ROR', 'RPA', 'RST',\n 'RUB', 'RUU', 'RZM', 'S6P', 'S7P', 'SA0', 'SCR', 'SDD', 'SF6', 'SF9', 'SG4',\n 'SG5', 'SG6', 'SG7', 'SGA', 'SGC', 'SGD', 'SGN', 'SGS', 'SHB', 'SHG', 'SI3',\n 'SIO', 'SOE', 'SOL', 'SSG', 'SUC', 'SUP', 'SUS', 'T6P', 'T6T', 'TAG', 'TCB',\n 'TDG', 'TGK', 'TGY', 'TH1', 'TIA', 'TM5', 'TM6', 'TM9', 'TMR', 'TMX', 'TOA',\n 'TOC', 'TRE', 'TYV', 'UCD', 'UDC', 'VG1', 'X0X', 'X1X', 'X2F', 'X4S', 'X5S',\n 'X6X', 'XBP', 'XDN', 'XDP', 'XIF', 'XIM', 'XLF', 'XLS', 'XMM', 'XUL', 'XXR',\n 'XYP', 'XYS', 'YO5', 'Z3Q', 'Z6J', 'Z9M', 'ZDC', 'ZDM'\n]\n\nexport const ProteinBackboneAtoms = [\n 'CA', 'C', 'N', 'O',\n 'O1', 'O2', 'OC1', 'OC2', 'OX1', 'OXT', 'OT1', 'OT2',\n 'H', 'H1', 'H2', 'H3', 'HA', 'HN',\n 'BB'\n]\n\nexport const NucleicBackboneAtoms = [\n 'P', 'OP1', 'OP2', 'HOP2', 'HOP3',\n \"O2'\", \"O3'\", \"O4'\", \"O5'\", \"C1'\", \"C2'\", \"C3'\", \"C4'\", \"C5'\",\n \"H1'\", \"H2'\", \"H2''\", \"HO2'\", \"H3'\", \"H4'\", \"H5'\", \"H5''\", \"HO3'\", \"HO5'\",\n 'O2*', 'O3*', 'O4*', 'O5*', 'C1*', 'C2*', 'C3*', 'C4*', 'C5*'\n]\n\nexport const ResidueTypeAtoms: { [k: number]: { [k: string]: string|string[] } } = {}\n\nResidueTypeAtoms[ ProteinBackboneType ] = {\n trace: 'CA',\n direction1: 'C',\n direction2: [ 'O', 'OC1', 'O1', 'OX1', 'OXT', 'OT1', 'OT2' ],\n backboneStart: 'N',\n backboneEnd: 'C'\n}\n\nResidueTypeAtoms[ RnaBackboneType ] = {\n trace: [ \"C4'\", 'C4*' ],\n direction1: [ \"C1'\", 'C1*' ],\n direction2: [ \"C3'\", 'C3*' ],\n backboneStart: 'P',\n backboneEnd: [ \"O3'\", 'O3*' ]\n}\n\nResidueTypeAtoms[ DnaBackboneType ] = {\n trace: [ \"C3'\", 'C3*' ],\n direction1: [ \"C2'\", 'C2*' ],\n direction2: [ \"O4'\", 'O4*' ],\n backboneStart: 'P',\n backboneEnd: [ \"O3'\", 'O3*' ]\n}\n\nResidueTypeAtoms[ CgProteinBackboneType ] = {\n trace: [ 'CA', 'BB' ],\n backboneStart: [ 'CA', 'BB' ],\n backboneEnd: [ 'CA', 'BB' ]\n}\n\nResidueTypeAtoms[ CgRnaBackboneType ] = {\n trace: [ \"C4'\", 'C4*', 'P' ],\n backboneStart: [ \"C4'\", 'C4*', 'P' ],\n backboneEnd: [ \"C4'\", 'C4*', 'P' ]\n}\n\nResidueTypeAtoms[ CgDnaBackboneType ] = {\n trace: [ \"C3'\", 'C3*', \"C2'\", 'P' ], // C2' is used in martini ff\n backboneStart: [ \"C3'\", 'C3*', \"C2'\", 'P' ],\n backboneEnd: [ \"C3'\", 'C3*', \"C2'\", 'P' ]\n}\n\nResidueTypeAtoms[ UnknownBackboneType ] = {}\n\n// Mappings taken from Meeko: https://github.com/forlilab/Meeko/blob/develop/meeko/utils/autodock4_atom_types_elements.py\nexport const PDBQTSpecialElements = {\n 'HD': 'H',\n 'HS': 'H',\n 'A': 'C',\n 'NA': 'N',\n 'NS': 'N',\n 'OA': 'O',\n 'OS': 'O',\n 'SA': 'S',\n 'G0': 'C',\n 'G1': 'C',\n 'G2': 'C',\n 'G3': 'C',\n 'CG0': 'C',\n 'CG1': 'C',\n 'CG2': 'C',\n 'CG3': 'C',\n 'W': 'O'\n}","/**\n * @file Geometry\n * @author Fred Ludlow \n * @author Alexander Rose \n */\n\nimport { Vector3 } from 'three'\n\nimport { Elements } from '../structure/structure-constants'\nimport { degToRad } from '../math/math-utils'\nimport AtomProxy from '../proxy/atom-proxy'\n\n// Changed numbering so they're mostly inline with coordination number\n// from VSEPR\nexport const enum AtomGeometry {\n Spherical = 0,\n Terminal = 1,\n Linear = 2,\n Trigonal = 3,\n Tetrahedral = 4,\n TrigonalBiPyramidal = 5,\n Octahedral = 6,\n SquarePlanar = 7, // Okay, it breaks down somewhere!\n Unknown = 8\n}\n\nexport function assignGeometry (totalCoordination: number): AtomGeometry {\n switch(totalCoordination){\n case 0:\n return AtomGeometry.Spherical\n case 1:\n return AtomGeometry.Terminal\n case 2:\n return AtomGeometry.Linear\n case 3:\n return AtomGeometry.Trigonal\n case 4:\n return AtomGeometry.Tetrahedral\n default:\n return AtomGeometry.Unknown\n }\n}\n\nexport const Angles = new Map([\n [ AtomGeometry.Linear, degToRad(180) ],\n [ AtomGeometry.Trigonal, degToRad(120) ],\n [ AtomGeometry.Tetrahedral, degToRad(109.4721) ],\n [ AtomGeometry.Octahedral, degToRad(90) ]\n])\n\n/**\n * Calculate the angles x-1-2 for all x where x is a heavy atom bonded to ap1.\n * @param {AtomProxy} ap1 First atom (angle centre)\n * @param {AtomProxy} ap2 Second atom\n * @return {number[]} Angles in radians\n */\nexport function calcAngles (ap1: AtomProxy, ap2: AtomProxy): number[] {\n let angles: number[] = []\n const d1 = new Vector3()\n const d2 = new Vector3()\n d1.subVectors(ap2 as any, ap1 as any)\n ap1.eachBondedAtom( x => {\n if (x.number !== Elements.H) {\n d2.subVectors(x as any, ap1 as any)\n angles.push(d1.angleTo(d2))\n }\n })\n return angles\n}\n\n/**\n * Find two neighbours of ap1 to define a plane (if possible) and\n * measure angle out of plane to ap2\n * @param {AtomProxy} ap1 First atom (angle centre)\n * @param {AtomProxy} ap2 Second atom (out-of-plane)\n * @return {number} Angle from plane to second atom\n */\nexport function calcPlaneAngle (ap1: AtomProxy, ap2: AtomProxy): number | undefined {\n const x1 = ap1.clone()\n\n const v12 = new Vector3()\n v12.subVectors(ap2 as any, ap1 as any)\n\n const neighbours = [new Vector3(), new Vector3()]\n let ni = 0\n ap1.eachBondedAtom( x => {\n if (ni > 1) { return }\n if (x.number !== Elements.H) {\n x1.index = x.index\n neighbours[ni++].subVectors(x as any, ap1 as any)\n }\n })\n if (ni === 1) {\n x1.eachBondedAtom( x => {\n if (ni > 1) { return }\n if (x.number !== Elements.H && x.index !== ap1.index){\n neighbours[ni++].subVectors(x as any, ap1 as any)\n }\n })\n }\n if (ni !== 2) {\n return\n }\n\n const cp = neighbours[0].cross(neighbours[1])\n return Math.abs((Math.PI / 2) - cp.angleTo(v12))\n}\n","/**\n * @file Valence Model\n * @author Fred Ludlow \n * @author Alexander Rose \n */\n\n/**\n * Reworked ValenceModel\n *\n * TODO:\n * Ensure proper treatment of disorder/models. e.g. V257 N in 5vim\n * Formal charge of 255 for SO4 anion (e.g. 5ghl)\n * Have removed a lot of explicit features (as I think they're more\n * generally captured by better VM).\n * Could we instead have a \"delocalised negative/positive\" charge\n * feature and flag these up?\n *\n */\nimport { Data } from '../structure/data'\nimport AtomProxy from '../proxy/atom-proxy'\nimport { AtomGeometry, assignGeometry } from './geometry'\nimport { Elements } from '../structure/structure-constants'\n\n/**\n * Are we involved in some kind of pi system. Either explicitly forming\n * double bond or N, O next to a double bond, except:\n *\n * N,O with degree 4 cannot be conjugated.\n * N,O adjacent to P=O or S=O do not qualify (keeps sulfonamide N sp3 geom)\n */\nfunction isConjugated (a: AtomProxy) {\n const _bp = a.structure.getBondProxy()\n const atomicNumber = a.number\n const hetero = atomicNumber === Elements.O || atomicNumber === Elements.N\n\n if (hetero && a.bondCount === 4) {\n return false\n }\n\n let flag = false\n\n a.eachBond(b => {\n if (b.bondOrder > 1) {\n flag = true\n return\n }\n if (hetero) {\n const a2 = b.getOtherAtom(a)\n\n a2.eachBond(b2 => {\n if (b2.bondOrder > 1) {\n const atomicNumber2 = a2.number\n if (\n (atomicNumber2 === Elements.P || atomicNumber2 === Elements.S) &&\n b2.getOtherAtom(a2).number === Elements.O\n ) {\n return\n }\n flag = true\n }\n }, _bp) // Avoid reuse of structure._bp\n }\n })\n\n return flag\n}\n\n/* function hasExplicitCharge(r: ResidueProxy) {\n let flag = false\n r.eachAtom(a => {\n if (a.formalCharge != null && a.formalCharge !== 0) flag = true\n })\n return flag\n}\n\nfunction hasExplicitHydrogen(r: ResidueProxy) {\n let flag = false\n r.eachAtom(a => {\n if (a.number === Elements.H) flag = true\n })\n return flag\n} */\n\nexport function explicitValence (a: AtomProxy) {\n let v = 0\n a.eachBond(b => v += b.bondOrder)\n return v\n}\n\n/**\n * Attempts to produce a consistent charge and implicit\n * H-count for an atom.\n *\n * If both params.assignCharge and params.assignH, this\n * approximately followsthe rules described in\n * https://docs.eyesopen.com/toolkits/python/oechemtk/valence.html#openeye-hydrogen-count-model\n *\n * If only charge or hydrogens are to be assigned it takes\n * a much simpler view and deduces one from the other\n *\n * @param {AtomProxy} a Atom to analyze\n * @param {assignChargeHParams} params What to assign\n */\nexport function calculateHydrogensCharge (a: AtomProxy, params: ValenceModelParams) {\n const hydrogenCount = a.bondToElementCount(Elements.H)\n let charge = a.formalCharge || 0\n\n const assignCharge = (params.assignCharge === 'always' ||\n (params.assignCharge === 'auto' && charge === 0))\n const assignH = (params.assignH === 'always' ||\n (params.assignH === 'auto' && hydrogenCount === 0))\n\n const degree = a.bondCount\n const valence = explicitValence(a)\n\n const conjugated = isConjugated(a)\n const multiBond = (valence - degree > 0)\n\n\n let implicitHCount = 0\n let geom = AtomGeometry.Unknown\n\n switch (a.number) {\n case Elements.H:\n if (assignCharge){\n if (degree === 0){\n charge = 1\n geom = AtomGeometry.Spherical\n } else if (degree === 1) {\n charge = 0\n geom = AtomGeometry.Terminal\n }\n }\n break\n\n case Elements.C:\n // TODO: Isocyanide?\n if (assignCharge) {\n charge = 0 // Assume carbon always neutral\n }\n if (assignH) {\n // Carbocation/carbanion are 3-valent\n implicitHCount = Math.max(0, 4 - valence - Math.abs(charge))\n }\n // Carbocation is planar, carbanion is tetrahedral\n geom = assignGeometry(degree + implicitHCount + Math.max(0, -charge))\n break\n\n case Elements.N:\n if (assignCharge) {\n if (!assignH) { // Trust input H explicitly:\n charge = valence - 3\n } else if (conjugated && valence < 4) {\n // Neutral unless amidine/guanidine double-bonded N:\n if (degree - hydrogenCount === 1 && valence - hydrogenCount === 2) {\n charge = 1\n } else {\n charge = 0\n }\n } else {\n // Sulfonamide nitrogen and classed as sp3 in conjugation model but\n // they won't be charged\n // Don't assign charge to nitrogens bound to metals\n let flag = false\n a.eachBondedAtom(ba => {\n if (ba.number === Elements.S || ba.isMetal()) flag = true\n })\n if (flag) charge = 0\n else charge = 1\n // TODO: Planarity sanity check?\n }\n\n }\n\n if (assignH) {\n // NH4+ -> 4, 1' amide -> 2, nitro N/N+ depiction -> 0\n implicitHCount = Math.max(0, 3 - valence + charge)\n }\n\n if (conjugated && !multiBond) {\n // Amide, anilinic N etc. cannot consider lone-pair for geometry purposes\n // Anilinic N geometry is depenent on ring electronics, for our purposes we\n // assume it's trigonal!\n geom = assignGeometry(degree + implicitHCount - charge)\n } else {\n // Everything else, pyridine, amine, nitrile, lp plays normal role:\n geom = assignGeometry(degree + implicitHCount + 1 - charge)\n }\n break\n\n case Elements.O:\n if (assignCharge) {\n if (!assignH) {\n charge = valence - 2 //\n }\n if (valence === 1) {\n a.eachBondedAtom(ba => {\n ba.eachBond(b => {\n const oa = b.getOtherAtom(ba)\n if (oa.index !== a.index && oa.number === Elements.O && b.bondOrder === 2){\n charge = -1\n }\n })\n })\n }\n }\n if (assignH) {\n // ethanol -> 1, carboxylate -> -1\n implicitHCount = Math.max(0, 2 - valence + charge)\n }\n if (conjugated && !multiBond){\n // carboxylate OH, phenol OH, one lone-pair taken up with conjugation\n geom = assignGeometry(degree + implicitHCount - charge + 1)\n } else {\n // Carbonyl (trigonal)\n geom = assignGeometry(degree + implicitHCount - charge + 2)\n }\n break\n\n // Only handles thiols/thiolates/thioether/sulfonium. Sulfoxides and higher\n // oxidiation states are assumed neutral S (charge carried on O if required)\n case Elements.S:\n if (assignCharge) {\n if (!assignH) {\n if (valence <= 3 && !a.bondToElementCount(Elements.O)) {\n charge = valence - 2 // e.g. explicitly deprotonated thiol\n } else {\n charge = 0\n }\n }\n }\n if (assignH){\n if (valence < 2){\n implicitHCount = Math.max(0, 2 - valence + charge)\n }\n }\n if (valence <= 3){\n // Thiol, thiolate, tioether -> tetrahedral\n geom = assignGeometry(degree + implicitHCount - charge + 2)\n }\n\n break\n\n case Elements.F:\n case Elements.CL:\n case Elements.BR:\n case Elements.I:\n case Elements.AT:\n // Never implicitly protonate halides\n if (assignCharge) {\n charge = valence - 1\n }\n break\n\n case Elements.LI:\n case Elements.NA:\n case Elements.K:\n case Elements.RB:\n case Elements.CS:\n case Elements.FR:\n if (assignCharge) {\n charge = 1 - valence\n }\n break\n\n case Elements.BE:\n case Elements.MG:\n case Elements.CA:\n case Elements.SR:\n case Elements.BA:\n case Elements.RA:\n if (assignCharge) {\n charge = 2 - valence\n }\n break\n\n default:\n console.warn('Requested charge, protonation for an unhandled element', a.element)\n }\n\n return [ charge, implicitHCount, implicitHCount + hydrogenCount, geom ]\n}\n\n\nexport interface ValenceModel {\n charge: Int8Array,\n implicitH: Int8Array,\n totalH: Int8Array,\n idealGeometry: Int8Array\n}\n\nexport interface ValenceModelParams {\n assignCharge: string,\n assignH: string\n}\n\nexport function ValenceModel (data: Data, params: ValenceModelParams) {\n const structure = data.structure\n const n = structure.atomCount\n\n const charge = new Int8Array(n)\n const implicitH = new Int8Array(n)\n const totalH = new Int8Array(n)\n const idealGeometry = new Int8Array(n)\n\n structure.eachAtom(a => {\n const i = a.index\n const [ chg, implH, totH, geom ] = calculateHydrogensCharge(a, params)\n charge[ i ] = chg\n implicitH[ i ] = implH\n totalH[ i ] = totH\n idealGeometry[ i ] = geom\n })\n\n return { charge, implicitH, totalH, idealGeometry }\n}","\nimport Structure from './structure'\nimport SpatialHash from '../geometry/spatial-hash'\nimport { ValenceModel } from '../chemistry/valence-model'\n\nexport interface Data {\n structure: Structure\n '@spatialLookup': SpatialHash | undefined\n '@valenceModel': ValenceModel | undefined\n}\n\nexport function createData(structure: Structure): Data {\n return {\n structure,\n '@spatialLookup': undefined,\n '@valenceModel': undefined\n }\n}\n\nexport function spatialLookup(data: Data): SpatialHash {\n if (data['@spatialLookup']) return data['@spatialLookup']!\n const lookup = new SpatialHash(data.structure.atomStore, data.structure.boundingBox)\n data['@spatialLookup'] = lookup\n return lookup\n}\n\nexport function valenceModel(data: Data): ValenceModel {\n if (data['@valenceModel']) return data['@valenceModel']!\n const valenceModel = ValenceModel(data, {assignCharge: 'auto', assignH: 'auto'})\n data['@valenceModel'] = valenceModel\n return valenceModel\n}\n","/**\n * @file Functional Groups\n * @author Alexander Rose \n */\n\nimport AtomProxy from '../proxy/atom-proxy'\nimport { Elements } from '../structure/structure-constants'\n\n/**\n * Nitrogen in a quaternary amine\n */\nexport function isQuaternaryAmine (a: AtomProxy) {\n return (\n a.number === 7 &&\n a.bondCount === 4 &&\n a.bondToElementCount(Elements.H) === 0\n )\n}\n\n/**\n * Nitrogen in a tertiary amine\n */\nexport function isTertiaryAmine (a: AtomProxy, idealValence: number) {\n return (\n a.number === 7 &&\n a.bondCount >= 3 &&\n idealValence === 3\n )\n}\n\n/**\n * Nitrogen in an imide\n */\nexport function isImide (a: AtomProxy) {\n let flag = false\n if (a.number === Elements.N && (a.bondCount - a.bondToElementCount(Elements.H)) === 2) {\n let carbonylCount = 0\n a.eachBondedAtom(ba => {\n if (isCarbonyl(ba)) ++carbonylCount\n })\n flag = carbonylCount === 2\n }\n return flag\n}\n\n/**\n * Nitrogen in an amide\n */\nexport function isAmide (a: AtomProxy) {\n let flag = false\n if (a.number === Elements.N && (a.bondCount - a.bondToElementCount(Elements.H)) === 2) {\n let carbonylCount = 0\n a.eachBondedAtom(ba => {\n if (isCarbonyl(ba)) ++carbonylCount\n })\n flag = carbonylCount === 1\n }\n return flag\n}\n\n/**\n * Sulfur in a sulfonium group\n */\nexport function isSulfonium (a: AtomProxy) {\n return (\n a.number === 16 &&\n a.bondCount === 3 &&\n a.bondToElementCount(Elements.H) === 0\n )\n}\n\n/**\n * Sulfur in a sulfonic acid or sulfonate group\n */\nexport function isSulfonicAcid (a: AtomProxy) {\n return (\n a.number === 16 &&\n a.bondToElementCount(Elements.O) === 3\n )\n}\n\n/**\n * Sulfur in a sulfate group\n */\nexport function isSulfate (a: AtomProxy) {\n return (\n a.number === 16 &&\n a.bondToElementCount(Elements.O) === 4\n )\n}\n\n/**\n * Phosphor in a phosphate group\n */\nexport function isPhosphate (a: AtomProxy) {\n return (\n a.number === 15 &&\n a.bondToElementCount(Elements.O) === a.bondCount\n )\n}\n\n/**\n * Halogen with one bond to a carbon\n */\nexport function isHalocarbon (a: AtomProxy) {\n return (\n a.isHalogen() &&\n a.bondCount === 1 &&\n a.bondToElementCount(Elements.C) === 1\n )\n}\n\n/**\n * Carbon in a carbonyl/acyl group\n */\nexport function isCarbonyl (a: AtomProxy) {\n let flag = false\n if (a.number === Elements.C) {\n a.eachBond(b => {\n if (b.bondOrder === 2 && b.getOtherAtom(a).number === Elements.O) {\n flag = true\n }\n })\n }\n return flag\n}\n\n/**\n * Carbon in a carboxylate group\n */\nexport function isCarboxylate (a: AtomProxy) {\n let terminalOxygenCount = 0\n if (\n a.number === 6 &&\n a.bondToElementCount(Elements.O) === 2 &&\n a.bondToElementCount(Elements.C) === 1\n ) {\n a.eachBondedAtom(ba => {\n if (ba.number === 8 && ba.bondCount - ba.bondToElementCount(Elements.H) === 1) {\n ++terminalOxygenCount\n }\n })\n }\n return terminalOxygenCount === 2\n}\n\n/**\n * Carbon in a guanidine group\n */\nexport function isGuanidine (a: AtomProxy) {\n let terminalNitrogenCount = 0\n if (\n a.number === 6 &&\n a.bondCount === 3 &&\n a.bondToElementCount(Elements.N) === 3\n ) {\n a.eachBondedAtom(ba => {\n if (ba.bondCount - ba.bondToElementCount(Elements.H) === 1) {\n ++terminalNitrogenCount\n }\n })\n }\n return terminalNitrogenCount === 2\n}\n\n/**\n * Carbon in a acetamidine group\n */\nexport function isAcetamidine (a: AtomProxy) {\n let terminalNitrogenCount = 0\n if (\n a.number === 6 &&\n a.bondCount === 3 &&\n a.bondToElementCount(Elements.N) === 2 &&\n a.bondToElementCount(Elements.C) === 1\n ) {\n a.eachBondedAtom(ba => {\n if (ba.bondCount - ba.bondToElementCount(Elements.H) === 1) {\n ++terminalNitrogenCount\n }\n })\n }\n return terminalNitrogenCount === 2\n}\n\nconst PolarElements = [\n Elements.N, Elements.O, Elements.S,\n Elements.F, Elements.CL, Elements.BR, Elements.I\n]\n\nexport function isPolar (a: AtomProxy) {\n return PolarElements.includes(a.number)\n}\n\nexport function hasPolarNeighbour (a: AtomProxy) {\n let flag = false\n a.eachBondedAtom(ba => {\n if (isPolar(ba)) flag = true\n })\n return flag\n}\n\nexport function hasAromaticNeighbour (a: AtomProxy) {\n let flag = false\n a.eachBondedAtom(function (bap) {\n if (bap.aromatic) flag = true\n })\n return flag\n}\n","/**\n * @file Charged\n * @author Alexander Rose \n * @author Fred Ludlow \n */\n\nimport { Vector3 } from 'three'\n\nimport { defaults } from '../../utils'\nimport { radToDeg } from '../../math/math-utils'\nimport Structure from '../../structure/structure'\nimport { AA3, Bases, Elements } from '../../structure/structure-constants'\nimport { valenceModel } from '../../structure/data'\nimport {\n isGuanidine, isAcetamidine, isSulfonicAcid, isPhosphate, isSulfate, isCarboxylate\n} from '../functional-groups'\nimport {\n Features, FeatureType, FeatureGroup,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\n\nconst PositvelyCharged = [ 'ARG', 'HIS', 'LYS' ]\nconst NegativelyCharged = [ 'GLU', 'ASP' ]\n\nexport function addPositiveCharges (structure: Structure, features: Features) {\n const { charge } = valenceModel(structure.data)\n const atomInGroupDict: { [atomIndex: number]: true } = {}\n\n structure.eachResidue(r => {\n if (PositvelyCharged.includes(r.resname)) {\n const state = createFeatureState(FeatureType.PositiveCharge)\n r.eachAtom(a => {\n if (a.number === Elements.N && a.isSidechain()) {\n addAtom(state, a)\n }\n })\n addFeature(features, state)\n } else if(!AA3.includes(r.resname) && !r.isNucleic()) {\n r.eachAtom(a => {\n let addGroup = false\n const state = createFeatureState(FeatureType.PositiveCharge)\n if (isGuanidine(a)) {\n state.group = FeatureGroup.Guanidine\n addGroup = true\n } else if (isAcetamidine(a)) {\n state.group = FeatureGroup.Acetamidine\n addGroup = true\n }\n if (addGroup) {\n a.eachBondedAtom(a => {\n if (a.number === Elements.N) {\n atomInGroupDict[a.index] = true\n addAtom(state, a)\n }\n })\n addFeature(features, state)\n }\n })\n r.eachAtom(a => {\n const state = createFeatureState(FeatureType.PositiveCharge)\n if (charge[a.index] > 0) {\n if (!atomInGroupDict[a.index]) {\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n })\n }\n })\n}\n\nexport function addNegativeCharges (structure: Structure, features: Features) {\n const { charge } = valenceModel(structure.data)\n const atomInGroupDict: { [atomIndex: number]: true } = {}\n\n structure.eachResidue(r => {\n if (NegativelyCharged.includes(r.resname)) {\n const state = createFeatureState(FeatureType.NegativeCharge)\n r.eachAtom(a => {\n if (a.number === Elements.O && a.isSidechain()) {\n addAtom(state, a)\n }\n })\n addFeature(features, state)\n } else if (Bases.includes(r.resname)) {\n const state = createFeatureState(FeatureType.NegativeCharge)\n r.eachAtom(a => {\n if (isPhosphate(a)) {\n state.group = FeatureGroup.Phosphate\n a.eachBondedAtom(a => {\n if (a.number === Elements.O) addAtom(state, a)\n })\n addFeature(features, state)\n }\n })\n } else if(!AA3.includes(r.resname) && !Bases.includes(r.resname)) {\n r.eachAtom(a => {\n let addGroup = false\n const state = createFeatureState(FeatureType.NegativeCharge)\n if (isSulfonicAcid(a)) {\n state.group = FeatureGroup.SulfonicAcid\n addGroup = true\n } else if (isPhosphate(a)) {\n state.group = FeatureGroup.Phosphate\n addGroup = true\n } else if (isSulfate(a)) {\n state.group = FeatureGroup.Sulfate\n addGroup = true\n } else if (isCarboxylate(a)) {\n state.group = FeatureGroup.Carboxylate\n addGroup = true\n }\n if (addGroup) {\n a.eachBondedAtom(a => {\n if (a.number === Elements.O) {\n atomInGroupDict[a.index] = true\n addAtom(state, a)\n }\n })\n addFeature(features, state)\n }\n })\n r.eachAtom(a => {\n const state = createFeatureState(FeatureType.NegativeCharge)\n if (charge[a.index] < 0) {\n if (!atomInGroupDict[a.index]) {\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n })\n }\n })\n}\n\nexport function addAromaticRings (structure: Structure, features: Features) {\n const a = structure.getAtomProxy()\n structure.eachResidue(r => {\n const rings = r.getAromaticRings()\n if (rings) {\n const offset = r.atomOffset\n rings.forEach(ring => {\n const state = createFeatureState(FeatureType.AromaticRing)\n ring.forEach(i => {\n a.index = i + offset\n addAtom(state, a)\n })\n addFeature(features, state)\n })\n }\n })\n}\n\nfunction isIonicInteraction (ti: FeatureType, tj: FeatureType) {\n return (\n (ti === FeatureType.NegativeCharge && tj === FeatureType.PositiveCharge) ||\n (ti === FeatureType.PositiveCharge && tj === FeatureType.NegativeCharge)\n )\n}\n\nfunction isPiStacking (ti: FeatureType, tj: FeatureType) {\n return ti === FeatureType.AromaticRing && tj === FeatureType.AromaticRing\n}\n\nfunction isCationPi (ti: FeatureType, tj: FeatureType) {\n return (\n (ti === FeatureType.AromaticRing && tj === FeatureType.PositiveCharge) ||\n (ti === FeatureType.PositiveCharge && tj === FeatureType.AromaticRing)\n )\n}\n\nexport interface ChargedContactsParams {\n maxIonicDist?: number\n maxPiStackingDist?: number\n maxPiStackingOffset?: number\n maxPiStackingAngle?: number\n maxCationPiDist?: number\n maxCationPiOffset?: number\n masterModelIndex?: number\n}\n\nexport function addChargedContacts (structure: Structure, contacts: Contacts, params: ChargedContactsParams = {}) {\n const maxIonicDist = defaults(params.maxIonicDist, ContactDefaultParams.maxIonicDist)\n const maxPiStackingDist = defaults(params.maxPiStackingDist, ContactDefaultParams.maxPiStackingDist)\n const maxPiStackingOffset = defaults(params.maxPiStackingOffset, ContactDefaultParams.maxPiStackingOffset)\n const maxPiStackingAngle = defaults(params.maxPiStackingAngle, ContactDefaultParams.maxPiStackingAngle)\n const maxCationPiDist = defaults(params.maxCationPiDist, ContactDefaultParams.maxCationPiDist)\n const maxCationPiOffset = defaults(params.maxCationPiOffset, ContactDefaultParams.maxCationPiOffset)\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const maxDistance = Math.max(maxIonicDist + 2, maxPiStackingDist, maxCationPiDist)\n // const maxSaltBridgeDistSq = maxSaltBridgeDist * maxSaltBridgeDist\n const maxPiStackingDistSq = maxPiStackingDist * maxPiStackingDist\n const maxCationPiDistSq = maxCationPiDist * maxCationPiDist\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const ax = structure.atomStore.x\n const ay = structure.atomStore.y\n const az = structure.atomStore.z\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n const areAtomSetsWithinDist = function (atomSet1: number[], atomSet2: number[], maxDist: number) {\n const sn = atomSet1.length\n const sm = atomSet2.length\n for (let si = 0; si < sn; ++si) {\n ap1.index = atomSet1[ si ]\n for (let sj = 0; sj < sm; ++sj) {\n ap2.index = atomSet2[ sj ]\n if (ap1.distanceTo(ap2) <= maxDist) {\n return true\n }\n }\n }\n return false\n }\n\n const v1 = new Vector3()\n const v2 = new Vector3()\n const v3 = new Vector3()\n const d1 = new Vector3()\n const d2 = new Vector3()\n const n1 = new Vector3()\n const n2 = new Vector3()\n\n const getNormal = function (atoms: number[], normal: Vector3) {\n v1.set(ax[ atoms[ 0 ] ], ay[ atoms[ 0 ] ], az[ atoms[ 0 ] ])\n v2.set(ax[ atoms[ 1 ] ], ay[ atoms[ 1 ] ], az[ atoms[ 1 ] ])\n v3.set(ax[ atoms[ 2 ] ], ay[ atoms[ 2 ] ], az[ atoms[ 2 ] ])\n d1.subVectors(v1, v2)\n d2.subVectors(v1, v3)\n normal.crossVectors(d1, d2)\n }\n\n const getOffset = function (i: number, j: number, normal: Vector3) {\n v1.set(x[ i ], y[ i ], z[ i ])\n v2.set(x[ j ], y[ j ], z[ j ])\n return v1.sub(v2).projectOnPlane(normal).add(v2).distanceTo(v2)\n }\n\n const add = function (i: number, j: number, ct: ContactType) {\n featureSet.setBits(i, j)\n contactStore.addContact(i, j, ct)\n }\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxDistance, (j, dSq) => {\n if (j <= i) return\n\n ap1.index = atomSets[ i ][ 0 ]\n ap2.index = atomSets[ j ][ 0 ]\n\n if (invalidAtomContact(ap1, ap2, masterIdx)) return\n\n const ti = types[ i ]\n const tj = types[ j ]\n\n if (isIonicInteraction(ti, tj)) {\n if (areAtomSetsWithinDist(atomSets[ i ], atomSets[ j ], maxIonicDist)) {\n add(i, j, ContactType.IonicInteraction)\n }\n } else if (isPiStacking(ti, tj)) {\n if (dSq <= maxPiStackingDistSq) {\n getNormal(atomSets[ i ], n1)\n getNormal(atomSets[ j ], n2)\n\n const angle = radToDeg(n1.angleTo(n2))\n const offset = Math.min(getOffset(i, j, n2), getOffset(j, i, n1))\n if (offset <= maxPiStackingOffset) {\n if (angle <= maxPiStackingAngle || angle >= 180 - maxPiStackingAngle) {\n add(i, j, ContactType.PiStacking) // parallel\n } else if (angle <= maxPiStackingAngle + 90 && angle >= 90 - maxPiStackingAngle) {\n add(i, j, ContactType.PiStacking) // t-shaped\n }\n }\n }\n } else if (isCationPi(ti, tj)) {\n if (dSq <= maxCationPiDistSq) {\n const [ l, k ] = ti === FeatureType.AromaticRing ? [ i, j ] : [ j, i ]\n\n getNormal(atomSets[ l ], n1)\n const offset = getOffset(k, l, n1)\n if (offset <= maxCationPiOffset) {\n add(l, k, ContactType.CationPi)\n }\n }\n }\n })\n }\n}\n","/**\n * @file Hydrogen Bonds\n * @author Alexander Rose \n * @author Fred Ludlow \n */\nimport { defaults } from '../../utils'\nimport { degToRad } from '../../math/math-utils'\nimport Structure from '../../structure/structure'\nimport AtomProxy from '../../proxy/atom-proxy'\nimport { valenceModel } from '../../structure/data'\nimport { Elements } from '../../structure/structure-constants'\nimport { Angles, AtomGeometry, calcAngles, calcPlaneAngle } from '../geometry'\nimport {\n Features, FeatureType,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\n\n\n// Geometric characteristics of hydrogen bonds involving sulfur atoms in proteins\n// https://doi.org/10.1002/prot.22327\n\n// Satisfying Hydrogen Bonding Potential in Proteins (HBPLUS)\n// https://doi.org/10.1006/jmbi.1994.1334\n// http://www.csb.yale.edu/userguides/datamanip/hbplus/hbplus_descrip.html\n\n/**\n * Potential hydrogen donor\n */\nexport function addHydrogenDonors (structure: Structure, features: Features) {\n const { totalH } = valenceModel(structure.data)\n\n structure.eachAtom(a => {\n const state = createFeatureState(FeatureType.HydrogenDonor)\n\n const an = a.number\n if (isHistidineNitrogen(a)) {\n // include both nitrogen atoms in histidine due to\n // their often ambiguous protonation assignment\n addAtom(state, a)\n addFeature(features, state)\n } else if (\n totalH[ a.index ] > 0 &&\n (an === Elements.N || an === Elements.O || an === Elements.S)\n ) {\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\n/**\n * Weak hydrogen donor.\n */\nexport function addWeakHydrogenDonors (structure: Structure, features: Features) {\n const { totalH } = valenceModel(structure.data)\n\n structure.eachAtom(a => {\n if (\n a.number === Elements.C &&\n totalH[ a.index ] > 0 &&\n (\n a.bondToElementCount(Elements.N) > 0 ||\n a.bondToElementCount(Elements.O) > 0 ||\n inAromaticRingWithElectronNegativeElement(a)\n )\n ) {\n const state = createFeatureState(FeatureType.WeakHydrogenDonor)\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\nfunction inAromaticRingWithElectronNegativeElement (a: AtomProxy) {\n if (!a.isAromatic()) return false\n\n const ringData = a.residueType.getRings()\n if (!ringData) return false\n\n let hasElement = false\n const rings = ringData.rings\n rings.forEach(ring => {\n if (hasElement) return // already found one\n if (ring.some(idx => (a.index - a.residueAtomOffset) === idx)) { // in ring\n hasElement = ring.some(idx => {\n const atomTypeId = a.residueType.atomTypeIdList[ idx ]\n const number = a.atomMap.get(atomTypeId).number\n return number === Elements.N || number === Elements.O\n })\n }\n })\n\n return hasElement\n}\n\n/**\n * Potential hydrogen acceptor\n */\nexport function addHydrogenAcceptors (structure: Structure, features: Features) {\n const { charge, implicitH, idealGeometry } = valenceModel(structure.data)\n\n structure.eachAtom(a => {\n const state = createFeatureState(FeatureType.HydrogenAcceptor)\n\n const an = a.number\n if (an === Elements.O) {\n // Basically assume all oxygen atoms are acceptors!\n addAtom(state, a)\n addFeature(features, state)\n }else if (an === Elements.N) {\n if (isHistidineNitrogen(a)) {\n // include both nitrogen atoms in histidine due to\n // their often ambiguous protonation assignment\n addAtom(state, a)\n addFeature(features, state)\n } else if (charge[ a.index ] < 1){\n // Neutral nitrogen might be an acceptor\n // It must have at least one lone pair not conjugated\n const totalBonds = a.bondCount + implicitH[ a.index ]\n const ig = idealGeometry[ a.index ]\n if (\n (ig === AtomGeometry.Tetrahedral && totalBonds < 4) ||\n (ig === AtomGeometry.Trigonal && totalBonds < 3) ||\n (ig === AtomGeometry.Linear && totalBonds < 2)\n ) {\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n }else if (an === 16) { // S\n if (a.resname === 'CYS' || a.resname === 'MET' || a.formalCharge === -1) {\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n })\n}\n\n/**\n * Atom that is only bound to carbon or hydrogen\n */\n// function isHydrocarbon (atom: AtomProxy) {\n// let flag = true\n// atom.eachBondedAtom(ap => {\n// const e = ap.element\n// if (e !== 'C' && e !== 'H') flag = false\n// })\n// return flag\n// }\n\nfunction isHistidineNitrogen (ap: AtomProxy) {\n return ap.resname === 'HIS' && ap.number == Elements.N && ap.isRing()\n}\n\nfunction isBackboneHydrogenBond (ap1: AtomProxy, ap2: AtomProxy) {\n return ap1.isBackbone() && ap2.isBackbone()\n}\n\nfunction isWaterHydrogenBond (ap1: AtomProxy, ap2: AtomProxy) {\n return ap1.isWater() && ap2.isWater()\n}\n\nfunction isHydrogenBond (ti: FeatureType, tj: FeatureType) {\n return (\n (ti === FeatureType.HydrogenAcceptor && tj === FeatureType.HydrogenDonor) ||\n (ti === FeatureType.HydrogenDonor && tj === FeatureType.HydrogenAcceptor)\n )\n}\n\nfunction isWeakHydrogenBond (ti: FeatureType, tj: FeatureType){\n return (\n (ti === FeatureType.WeakHydrogenDonor && tj === FeatureType.HydrogenAcceptor) ||\n (ti === FeatureType.HydrogenAcceptor && tj === FeatureType.WeakHydrogenDonor)\n )\n}\n\nfunction getHydrogenBondType (ap1: AtomProxy, ap2: AtomProxy) {\n if (isWaterHydrogenBond(ap1, ap2)) {\n return ContactType.WaterHydrogenBond\n } else if (isBackboneHydrogenBond(ap1, ap2)) {\n return ContactType.BackboneHydrogenBond\n } else {\n return ContactType.HydrogenBond\n }\n}\n\nexport interface HydrogenBondParams {\n maxHbondDist?: number\n maxHbondSulfurDist?: number\n maxHbondAccAngle?: number\n maxHbondDonAngle?: number\n maxHbondAccPlaneAngle?: number\n maxHbondDonPlaneAngle?: number\n backboneHbond?: boolean\n waterHbond?: boolean\n masterModelIndex?: number\n}\n\n/**\n * All pairs of hydrogen donor and acceptor atoms\n */\nexport function addHydrogenBonds (structure: Structure, contacts: Contacts, params: HydrogenBondParams = {}) {\n const maxHbondDist = defaults(params.maxHbondDist, ContactDefaultParams.maxHbondDist)\n const maxHbondSulfurDist = defaults(params.maxHbondSulfurDist, ContactDefaultParams.maxHbondSulfurDist)\n const maxHbondAccAngle = degToRad(defaults(params.maxHbondAccAngle, ContactDefaultParams.maxHbondAccAngle))\n const maxHbondDonAngle = degToRad(defaults(params.maxHbondDonAngle, ContactDefaultParams.maxHbondDonAngle))\n const maxHbondAccPlaneAngle = degToRad(defaults(params.maxHbondAccPlaneAngle, ContactDefaultParams.maxHbondAccPlaneAngle))\n const maxHbondDonPlaneAngle = degToRad(defaults(params.maxHbondDonPlaneAngle, ContactDefaultParams.maxHbondDonPlaneAngle))\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const maxDist = Math.max(maxHbondDist, maxHbondSulfurDist)\n const maxHbondDistSq = maxHbondDist * maxHbondDist\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const { idealGeometry } = valenceModel(structure.data)\n\n const donor = structure.getAtomProxy()\n const acceptor = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxDist, (j, dSq) => {\n if (j <= i) return\n\n const ti = types[ i ]\n const tj = types[ j ]\n\n const isWeak = isWeakHydrogenBond(ti, tj)\n if (!isWeak && !isHydrogenBond(ti, tj)) return\n\n const [ l, k ] = tj === FeatureType.HydrogenAcceptor ? [ i, j ] : [ j, i ]\n\n donor.index = atomSets[ l ][ 0 ]\n acceptor.index = atomSets[ k ][ 0 ]\n\n if (acceptor.index === donor.index) return // DA to self\n\n if (invalidAtomContact(donor, acceptor, masterIdx)) return\n if (donor.number !== Elements.S && acceptor.number !== Elements.S && dSq > maxHbondDistSq) return\n if (donor.connectedTo(acceptor)) return\n\n const donorAngles = calcAngles(donor, acceptor)\n const idealDonorAngle = Angles.get(idealGeometry[donor.index]) || degToRad(120)\n if (donorAngles.some(donorAngle => {\n return Math.abs(idealDonorAngle - donorAngle) > maxHbondDonAngle\n })) return\n\n if (idealGeometry[donor.index] === AtomGeometry.Trigonal){\n const outOfPlane = calcPlaneAngle(donor, acceptor)\n if (outOfPlane !== undefined && outOfPlane > maxHbondDonPlaneAngle) return\n }\n\n const acceptorAngles = calcAngles(acceptor, donor)\n const idealAcceptorAngle = Angles.get(idealGeometry[acceptor.index]) || degToRad(120)\n if (acceptorAngles.some(acceptorAngle => {\n // Do not limit large acceptor angles\n return idealAcceptorAngle - acceptorAngle > maxHbondAccAngle\n })) return\n\n if (idealGeometry[acceptor.index] === AtomGeometry.Trigonal){\n const outOfPlane = calcPlaneAngle(acceptor, donor)\n if (outOfPlane !== undefined && outOfPlane > maxHbondAccPlaneAngle) return\n }\n\n featureSet.setBits(l, k)\n const bondType = isWeak ? ContactType.WeakHydrogenBond : getHydrogenBondType(donor, acceptor)\n contactStore.addContact(l, k, bondType)\n })\n }\n}\n","/**\n * @file Metal Binding\n * @author Alexander Rose \n */\n\nimport { defaults } from '../../utils'\nimport Structure from '../../structure/structure'\n// import { valenceModel } from '../../structure/data'\nimport { Elements, AA3, Bases } from '../../structure/structure-constants'\n// import { hasAromaticNeighbour } from '../functional-groups'\nimport {\n Features, FeatureType,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\n\nconst IonicTypeMetals = [\n Elements.LI, Elements.NA, Elements.K, Elements.RB, Elements.CS,\n Elements.MG, Elements.CA, Elements.SR, Elements.BA, Elements.AL,\n Elements.GA, Elements.IN, Elements.TL, Elements.SC, Elements.SN,\n Elements.PB, Elements.BI, Elements.SB, Elements.HG\n]\n\n/**\n * Metal binding partners (dative bond or ionic-type interaction)\n */\nexport function addMetalBinding (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n let dative = false\n let ionic = false\n\n const isStandardAminoacid = AA3.includes(a.resname)\n const isStandardBase = Bases.includes(a.resname)\n\n if (!isStandardAminoacid && !isStandardBase) {\n if (a.isHalogen() || a.number === Elements.O || a.number === Elements.S) {\n dative = true\n ionic = true\n } else if (a.number === Elements.N) {\n dative = true\n }\n } else if (isStandardAminoacid){\n // main chain oxygen atom or oxygen, nitrogen and sulfur from specific amino acids\n if (a.number === Elements.O) {\n if(['ASP', 'GLU', 'SER', 'THR', 'TYR', 'ASN', 'GLN'].includes(a.resname) && a.isSidechain()) {\n dative = true\n ionic = true\n } else if (a.isBackbone()) {\n dative = true\n ionic = true\n }\n } else if (a.number === Elements.S && 'CYS' === a.resname) {\n dative = true\n ionic = true\n } else if (a.number === Elements.N) {\n if(a.resname === 'HIS' && a.isSidechain()) {\n dative = true\n }\n }\n } else if (isStandardBase){\n // http://pubs.acs.org/doi/pdf/10.1021/acs.accounts.6b00253\n // http://onlinelibrary.wiley.com/doi/10.1002/anie.200900399/full\n if (a.number === Elements.O && a.isBackbone()) {\n dative = true\n ionic = true\n } else if(['N3', 'N4', 'N7'].includes(a.atomname)) {\n dative = true\n } else if(['O2', 'O4', 'O6'].includes(a.atomname)) {\n dative = true\n ionic = true\n }\n }\n if (dative) {\n const state = createFeatureState(FeatureType.DativeBondPartner)\n addAtom(state, a)\n addFeature(features, state)\n }\n if (ionic) {\n const state = createFeatureState(FeatureType.IonicTypePartner)\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\n/**\n * Metal Pi complexation partner\n */\n// export function addMetalPiPartners (structure: Structure, features: Features) {\n// const { charge } = valenceModel(structure.data)\n\n// structure.eachAtom(a => {\n// const state = createFeatureState(FeatureType.MetalPiPartner)\n\n// const resname = a.resname\n// const element = a.element\n// const atomname = a.atomname\n// if (!a.isPolymer()) {\n// // water oxygen, as well as oxygen from carboxylate, phosphoryl, phenolate, alcohol;\n// // nitrogen from imidazole; sulfur from thiolate\n// if (element === 'O') {\n// // Water oxygen\n// if (a.bondCount === 0 || a.isWater()) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// // Oxygen in alcohol (R-[O]-H)\n// if (a.bondCount === 2 && charge[ a.index ] || a.hasBondToElement('H')) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// // Phenolate oxygen\n// if (hasAromaticNeighbour(a) && !a.aromatic) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// // Carboxylic acid oxygen\n// if (a.bondToElementCount('C') === 1) {\n// let flag = false\n// a.eachBondedAtom(ba => {\n// if (ba.element === 'C' && ba.bondToElementCount('O') === 2 && ba.bondToElementCount('C') === 1) {\n// flag = true\n// }\n// })\n// if (flag) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// }\n// // Phosphoryl oxygen\n// if (a.bondToElementCount('P') === 1) {\n// let flag = false\n// a.eachBondedAtom(ba => {\n// if (ba.element === 'P' && ba.bondToElementCount('O') >= 3) {\n// flag = true\n// }\n// })\n// if (flag) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// }\n// } else if (element === 'N') {\n// // Imidazole/pyrrole or similar\n// if (a.bondToElementCount('C') === 2) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// } else if (element === 'S') {\n// // Thiolate\n// if (hasAromaticNeighbour(a) && !a.aromatic) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// // Sulfur in Iron sulfur cluster\n// const ironCount = a.bondToElementCount('FE')\n// if (ironCount > 0 && ironCount === a.bondCount) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// }\n// }\n// })\n// }\n\nexport function addMetals (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n if (a.isTransitionMetal() || a.number === Elements.ZN || a.number === Elements.CD) {\n const state = createFeatureState(FeatureType.TransitionMetal)\n addAtom(state, a)\n addFeature(features, state)\n } else if (IonicTypeMetals.includes(a.number)) {\n const state = createFeatureState(FeatureType.IonicTypeMetal)\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\nfunction isMetalComplex (ti: FeatureType, tj: FeatureType) {\n if (ti === FeatureType.TransitionMetal) {\n return (\n tj === FeatureType.DativeBondPartner ||\n tj === FeatureType.TransitionMetal\n )\n } else if (ti === FeatureType.IonicTypeMetal) {\n return (\n tj === FeatureType.IonicTypePartner\n )\n }\n}\n\nexport interface MetalComplexationParams {\n maxMetalDist?: number\n masterModelIndex?: number\n}\n\n/**\n * Metal complexes of metals and appropriate groups in protein and ligand, including water\n */\nexport function addMetalComplexation (structure: Structure, contacts: Contacts, params: MetalComplexationParams = {}) {\n const maxMetalDist = defaults(params.maxMetalDist, ContactDefaultParams.maxMetalDist)\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxMetalDist, (j, dSq) => {\n if (j <= i) return\n\n ap1.index = atomSets[ i ][ 0 ]\n ap2.index = atomSets[ j ][ 0 ]\n\n if (invalidAtomContact(ap1, ap2, masterIdx)) return\n\n const m1 = ap1.isMetal()\n const m2 = ap2.isMetal()\n if (!m1 && !m2) return\n\n const [ ti, tj ] = m1 ? [ types[ i ],types[ j ] ] : [ types[ j ],types[ i ] ]\n\n if (isMetalComplex(ti, tj)) {\n featureSet.setBits(i, j)\n contactStore.addContact(i, j, ContactType.MetalCoordination)\n }\n })\n }\n}\n","/**\n * @file Halogen Bonds\n * @author Alexander Rose \n * @author Fred Ludlow \n */\n\nimport { defaults } from '../../utils'\nimport Structure from '../../structure/structure'\nimport { Elements } from '../../structure/structure-constants'\nimport { degToRad } from '../../math/math-utils'\nimport {\n Features, FeatureType,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\nimport { calcAngles } from '../geometry'\n\nconst halBondElements = [17, 35, 53, 85]\n\n/**\n * Halogen bond donors (X-C, with X one of Cl, Br, I or At) not F!\n */\nexport function addHalogenDonors (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n if (halBondElements.includes(a.number) && a.bondToElementCount(Elements.C) === 1) {\n const state = createFeatureState(FeatureType.HalogenDonor)\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\nconst X = [ Elements.N, Elements.O, Elements.S ]\nconst Y = [ Elements.C, Elements.N, Elements.P, Elements.S ]\n\n/**\n * Halogen bond acceptors (Y-{O|N|S}, with Y=C,P,N,S)\n */\nexport function addHalogenAcceptors (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n if (X.includes(a.number)) {\n let flag = false\n a.eachBondedAtom(ba => {\n if (Y.includes(ba.number)) {\n flag = true\n }\n })\n if (flag) {\n const state = createFeatureState(FeatureType.HalogenAcceptor)\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n })\n}\n\nfunction isHalogenBond (ti: FeatureType, tj: FeatureType) {\n return (\n (ti === FeatureType.HalogenAcceptor && tj === FeatureType.HalogenDonor) ||\n (ti === FeatureType.HalogenDonor && tj === FeatureType.HalogenAcceptor)\n )\n}\n\nexport interface HalogenBondsParams {\n maxHalogenBondDist?: number\n maxHalogenBondAngle?: number\n masterModelIndex?: number\n}\n\n// http://www.pnas.org/content/101/48/16789.full\nconst OptimalHalogenAngle = degToRad(180) // adjusted from 165 to account for spherical statistics\nconst OptimalAcceptorAngle = degToRad(120)\n\n/**\n * All pairs of halogen donor and acceptor atoms\n */\nexport function addHalogenBonds (structure: Structure, contacts: Contacts, params: HalogenBondsParams = {}) {\n const maxHalogenBondDist = defaults(params.maxHalogenBondDist, ContactDefaultParams.maxHalogenBondDist)\n const maxHalogenBondAngle = degToRad(defaults(params.maxHalogenBondAngle, ContactDefaultParams.maxHalogenBondAngle))\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxHalogenBondDist, (j, dSq) => {\n if (j <= i) return\n\n ap1.index = atomSets[ i ][ 0 ]\n ap2.index = atomSets[ j ][ 0 ]\n\n if (invalidAtomContact(ap1, ap2, masterIdx)) return\n if (!isHalogenBond(types[ i ], types[ j ])) return\n\n const [ halogen, acceptor ] = types[ i ] === FeatureType.HalogenDonor ? [ ap1, ap2 ] : [ ap2, ap1 ]\n\n const halogenAngles = calcAngles(halogen, acceptor)\n // Singly bonded halogen only (not bromide ion for example)\n if (halogenAngles.length !== 1) return\n if (OptimalHalogenAngle - halogenAngles[0] > maxHalogenBondAngle) return\n\n const acceptorAngles = calcAngles(acceptor, halogen)\n // Angle must be defined. Excludes water as acceptor. Debatable\n if (acceptorAngles.length === 0) return\n if (acceptorAngles.some(acceptorAngle => {\n return (OptimalAcceptorAngle - acceptorAngle > maxHalogenBondAngle)\n })) return\n\n\n featureSet.setBits(i, j)\n contactStore.addContact(i, j, ContactType.HalogenBond)\n\n })\n }\n}\n","/**\n * @file Refine Contacts\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { Debug, Log } from '../../globals'\nimport { defaults } from '../../utils'\nimport Structure from '../../structure/structure'\nimport AtomProxy from '../../proxy/atom-proxy'\nimport { Elements } from '../../structure/structure-constants'\nimport { FrozenContacts, ContactType, ContactDefaultParams, isMasterContact } from './contact'\nimport { FeatureType } from './features'\n\nexport interface LineOfSightParams {\n lineOfSightDistFactor?: number\n masterModelIndex?: number\n}\n\n// also allows intra-residue contacts\nexport function invalidAtomContact (ap1: AtomProxy, ap2: AtomProxy, masterIdx: number) {\n return !isMasterContact(ap1, ap2, masterIdx) && (\n ap1.modelIndex !== ap2.modelIndex ||\n (ap1.altloc && ap2.altloc && ap1.altloc !== ap2.altloc)\n )\n}\n\nexport function refineLineOfSight (structure: Structure, contacts: FrozenContacts, params: LineOfSightParams = {}) {\n if (Debug) Log.time('refineLineOfSight')\n\n const lineOfSightDistFactor = defaults(params.lineOfSightDistFactor, ContactDefaultParams.lineOfSightDistFactor)\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const spatialHash = structure.spatialHash!\n const { contactSet, contactStore, features } = contacts\n const { index1, index2 } = contactStore\n const { centers, atomSets } = features\n const { x, y, z } = centers\n\n const ac1 = structure.getAtomProxy()\n const ac2 = structure.getAtomProxy()\n const aw = structure.getAtomProxy()\n\n const c1 = new Vector3()\n const c2 = new Vector3()\n\n const lineOfSightDist = 3 * lineOfSightDistFactor\n const lineOfSightDistFactorSq = lineOfSightDistFactor * lineOfSightDistFactor\n\n contactSet.forEach(i => {\n c1.set(x[index1[i]], y[index1[i]], z[index1[i]])\n c2.set(x[index2[i]], y[index2[i]], z[index2[i]])\n\n const cx = ( c1.x + c2.x ) / 2\n const cy = ( c1.y + c2.y ) / 2\n const cz = ( c1.z + c2.z ) / 2\n\n const as1 = atomSets[ index1[ i ] ]\n const as2 = atomSets[ index2[ i ] ]\n\n ac1.index = as1[ 0 ]\n ac2.index = as2[ 0 ]\n\n spatialHash.eachWithin(cx, cy, cz, lineOfSightDist, (j, dSq) => {\n aw.index = j\n if (\n aw.number !== Elements.H &&\n (aw.vdw * aw.vdw * lineOfSightDistFactorSq) > dSq &&\n !invalidAtomContact(ac1, aw, masterIdx) &&\n !invalidAtomContact(ac2, aw, masterIdx) &&\n !as1.includes(j) &&\n !as2.includes(j) &&\n // to ignore atoms in the center of functional groups\n c1.distanceToSquared(aw as any) > 1 &&\n c2.distanceToSquared(aw as any) > 1\n ) {\n contactSet.clear(i)\n if (Debug) Log.log('removing', ac1.qualifiedName(), ac2.qualifiedName(), 'because', aw.qualifiedName())\n }\n })\n })\n\n if (Debug) Log.timeEnd('refineLineOfSight')\n}\n\n/**\n * For atoms interacting with several atoms in the same residue\n * only the one with the closest distance is kept.\n */\nexport function refineHydrophobicContacts (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features } = contacts\n const { type, index1, index2 } = contactStore\n const { atomSets } = features\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n const residueContactDict: { [k: string]: number[] } = {}\n\n /* keep only closest contact between residues */\n const handleResidueContact = function (dist: number, i: number, key: string) {\n const [ minDist, minIndex ] = residueContactDict[ key ] || [ Infinity, -1 ]\n if (dist < minDist) {\n if (minIndex !== -1) contactSet.clear(minIndex)\n residueContactDict[ key ] = [ dist, i ]\n } else {\n contactSet.clear(i)\n }\n }\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.Hydrophobic) return\n\n ap1.index = atomSets[ index1[ i ] ][ 0 ]\n ap2.index = atomSets[ index2[ i ] ][ 0 ]\n\n const dist = ap1.distanceTo(ap2)\n handleResidueContact(dist, i, `${ap1.index}|${ap2.residueIndex}`)\n handleResidueContact(dist, i, `${ap2.index}|${ap1.residueIndex}`)\n })\n}\n\nfunction isHydrogenBondType (type: number) {\n return (\n type === ContactType.HydrogenBond ||\n type === ContactType.WaterHydrogenBond ||\n type === ContactType.BackboneHydrogenBond\n )\n}\n\n/**\n * Remove weak hydrogen bonds when the acceptor is involved in\n * a normal/strong hydrogen bond\n */\nexport function refineWeakHydrogenBonds (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features, adjacencyList } = contacts\n const { type, index1, index2 } = contactStore\n const { types } = features\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.WeakHydrogenBond) return\n\n let accFeat: number\n if (types[ index1[ i ] ] === FeatureType.WeakHydrogenDonor) {\n accFeat = index2[ i ]\n } else {\n accFeat = index1[ i ]\n }\n\n const n = adjacencyList.countArray[ accFeat ]\n const offset = adjacencyList.offsetArray[ accFeat ]\n for (let j = 0; j < n; ++j) {\n const ci = adjacencyList.indexArray[ offset + j ]\n if (isHydrogenBondType(type[ ci ])) {\n contactSet.clear(i)\n return\n }\n }\n })\n}\n\n/**\n * Remove hydrogen bonds between groups that also form\n * a salt bridge between each other\n */\nexport function refineSaltBridges (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features } = contacts\n const { type, index1, index2 } = contactStore\n const { atomSets } = features\n\n const ionicInteractionDict: { [atomIndex: number]: number[] } = {}\n\n const add = function(idx: number, i: number) {\n if (!ionicInteractionDict[ idx ]) ionicInteractionDict[ idx ] = []\n ionicInteractionDict[ idx ].push(i)\n }\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.IonicInteraction) return\n atomSets[ index1[ i ] ].forEach(idx => add(idx, i))\n atomSets[ index2[ i ] ].forEach(idx => add(idx, i))\n })\n\n contactSet.forEach(i => {\n if (!isHydrogenBondType(type[ i ])) return\n\n const iil1 = ionicInteractionDict[ atomSets[ index1[ i ] ][ 0 ] ]\n const iil2 = ionicInteractionDict[ atomSets[ index2[ i ] ][ 0 ] ]\n if (!iil1 || !iil2) return\n\n const n = iil1.length\n for (let j = 0; j < n; ++j) {\n if (iil2.includes(iil1[j])) {\n contactSet.clear(i)\n return\n }\n }\n })\n}\n\n/**\n * Remove hydrophobic and cation-pi interactions between groups that also form\n * a pi-stacking interaction between each other\n */\nexport function refinePiStacking (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features } = contacts\n const { type, index1, index2 } = contactStore\n const { atomSets } = features\n\n const piStackingDict: { [atomIndex: number]: number[] } = {}\n\n const add = function(idx: number, i: number) {\n if (!piStackingDict[ idx ]) piStackingDict[ idx ] = []\n piStackingDict[ idx ].push(i)\n }\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.PiStacking) return\n atomSets[ index1[ i ] ].forEach(idx => add(idx, i))\n atomSets[ index2[ i ] ].forEach(idx => add(idx, i))\n })\n\n contactSet.forEach(i => {\n if (\n type[ i ] !== ContactType.Hydrophobic &&\n type[ i ] !== ContactType.CationPi\n ) return\n\n const pil1 = piStackingDict[ atomSets[ index1[ i ] ][ 0 ] ]\n const pil2 = piStackingDict[ atomSets[ index2[ i ] ][ 0 ] ]\n if (!pil1 || !pil2) return\n\n const n = pil1.length\n for (let j = 0; j < n; ++j) {\n if (pil2.includes(pil1[j])) {\n contactSet.clear(i)\n return\n }\n }\n })\n}\n\n/**\n * Remove ionic interactions between groups that also form\n * a metal coordination between each other\n */\nexport function refineMetalCoordination (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features } = contacts\n const { type, index1, index2 } = contactStore\n const { atomSets } = features\n\n const ionicInteractionDict: { [atomIndex: number]: number[] } = {}\n\n const add = function(idx: number, i: number) {\n if (!ionicInteractionDict[ idx ]) ionicInteractionDict[ idx ] = []\n ionicInteractionDict[ idx ].push(i)\n }\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.IonicInteraction) return\n atomSets[ index1[ i ] ].forEach(idx => add(idx, i))\n atomSets[ index2[ i ] ].forEach(idx => add(idx, i))\n })\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.MetalCoordination) return\n\n const iil1 = ionicInteractionDict[ atomSets[ index1[ i ] ][ 0 ] ]\n const iil2 = ionicInteractionDict[ atomSets[ index2[ i ] ][ 0 ] ]\n if (!iil1 || !iil2) return\n\n const n = iil1.length\n for (let j = 0; j < n; ++j) {\n if (iil2.includes(iil1[j])) {\n contactSet.clear(iil1[j])\n return\n }\n }\n })\n}\n\n// TODO: refactor refineSaltBridges, refinePiStacking and refineMetalCoordination to be DRY\n","/**\n * @file Contact\n * @author Alexander Rose \n */\n\nimport { Color } from 'three'\n\nimport { Debug, Log } from '../../globals'\nimport { createParams } from '../../utils'\nimport { TextBufferData } from '../../buffer/text-buffer'\nimport Structure from '../../structure/structure'\nimport AtomProxy from '../../proxy/atom-proxy'\nimport SpatialHash from '../../geometry/spatial-hash'\nimport { calculateCenterArray, calculateDirectionArray, uniformArray } from '../../math/array-utils'\nimport ContactStore from '../../store/contact-store'\nimport BitArray from '../../utils/bitarray'\nimport Selection from '../../selection/selection'\nimport { ContactPicker } from '../../utils/picker'\nimport { createAdjacencyList, AdjacencyList } from '../../utils/adjacency-list'\nimport { createFeatures, Features } from './features'\nimport { addAromaticRings, addNegativeCharges, addPositiveCharges, addChargedContacts } from './charged'\nimport { addHydrogenAcceptors, addHydrogenDonors, addHydrogenBonds, addWeakHydrogenDonors } from './hydrogen-bonds'\nimport { addMetalBinding, addMetals, addMetalComplexation } from './metal-binding'\nimport { addHydrophobic, addHydrophobicContacts } from './hydrophobic'\nimport { addHalogenAcceptors, addHalogenDonors, addHalogenBonds } from './halogen-bonds'\nimport {\n refineLineOfSight,\n refineHydrophobicContacts, refineSaltBridges, refinePiStacking, refineMetalCoordination\n} from './refine-contacts'\n\nexport interface Contacts {\n features: Features\n spatialHash: SpatialHash\n contactStore: ContactStore\n featureSet: BitArray\n}\n\nexport interface FrozenContacts extends Contacts {\n contactSet: BitArray\n adjacencyList: AdjacencyList\n}\n\nexport const enum ContactType {\n Unknown = 0,\n IonicInteraction = 1,\n CationPi = 2,\n PiStacking = 3,\n HydrogenBond = 4,\n HalogenBond = 5,\n Hydrophobic = 6,\n MetalCoordination = 7,\n WeakHydrogenBond = 8,\n WaterHydrogenBond = 9,\n BackboneHydrogenBond = 10\n}\n\nexport const ContactDefaultParams = {\n maxHydrophobicDist: 4.0,\n maxHbondDist: 3.5,\n maxHbondSulfurDist: 4.1,\n maxHbondAccAngle: 45,\n maxHbondDonAngle: 45,\n maxHbondAccPlaneAngle: 90,\n maxHbondDonPlaneAngle: 30,\n maxPiStackingDist: 5.5,\n maxPiStackingOffset: 2.0,\n maxPiStackingAngle: 30,\n maxCationPiDist: 6.0,\n maxCationPiOffset: 2.0,\n maxIonicDist: 5.0,\n maxHalogenBondDist: 4.0,\n maxHalogenBondAngle: 30,\n maxMetalDist: 3.0,\n refineSaltBridges: true,\n masterModelIndex: -1,\n lineOfSightDistFactor: 1.0\n}\n\nexport function isMasterContact (ap1: AtomProxy, ap2: AtomProxy, masterIdx: number) {\n return (\n (ap1.modelIndex === masterIdx && ap2.modelIndex !== masterIdx) ||\n (ap2.modelIndex === masterIdx && ap1.modelIndex !== masterIdx)\n )\n}\n\nexport function invalidAtomContact (ap1: AtomProxy, ap2: AtomProxy, masterIdx: number) {\n return !isMasterContact(ap1, ap2, masterIdx) && (\n ap1.modelIndex !== ap2.modelIndex ||\n ap1.residueIndex === ap2.residueIndex ||\n (ap1.altloc && ap2.altloc && ap1.altloc !== ap2.altloc)\n )\n}\n\nexport function createContacts (features: Features): Contacts {\n const { types, centers } = features\n\n const spatialHash = new SpatialHash(centers)\n const contactStore = new ContactStore()\n const featureSet = new BitArray(types.length, false)\n\n return { features, spatialHash, contactStore, featureSet }\n}\n\nexport function createFrozenContacts (contacts: Contacts): FrozenContacts {\n const { index1, index2, count } = contacts.contactStore\n\n const adjacencyList = createAdjacencyList({\n nodeArray1: index1,\n nodeArray2: index2,\n edgeCount: count,\n nodeCount: contacts.featureSet.length\n })\n const contactSet = new BitArray(contacts.contactStore.count, true)\n\n return Object.assign({ adjacencyList, contactSet }, contacts)\n}\n\nfunction calculateFeatures (structure: Structure) {\n const features = createFeatures()\n\n if (Debug) Log.time('calculateFeatures')\n\n addPositiveCharges(structure, features)\n addNegativeCharges(structure, features)\n addAromaticRings(structure, features)\n\n addHydrogenAcceptors(structure, features)\n addHydrogenDonors(structure, features)\n addWeakHydrogenDonors(structure, features)\n\n addMetalBinding(structure, features)\n addMetals(structure, features)\n\n addHydrophobic(structure, features)\n\n addHalogenAcceptors(structure, features)\n addHalogenDonors(structure, features)\n\n if (Debug) Log.timeEnd('calculateFeatures')\n\n return features\n}\n\nexport function calculateContacts (structure: Structure, params = ContactDefaultParams) {\n const features = calculateFeatures(structure)\n const contacts = createContacts(features)\n\n if (Debug) Log.time('calculateContacts')\n\n addChargedContacts(structure, contacts, params)\n addHydrogenBonds(structure, contacts, params)\n addMetalComplexation(structure, contacts, params)\n addHydrophobicContacts(structure, contacts, params)\n addHalogenBonds(structure, contacts, params)\n\n const frozenContacts = createFrozenContacts(contacts)\n\n refineLineOfSight(structure, frozenContacts, params)\n refineHydrophobicContacts(structure, frozenContacts)\n if (params.refineSaltBridges) refineSaltBridges(structure, frozenContacts)\n refinePiStacking(structure, frozenContacts)\n refineMetalCoordination(structure, frozenContacts)\n\n if (Debug) Log.timeEnd('calculateContacts')\n\n return frozenContacts\n}\n\nexport function contactTypeName (type: ContactType) {\n switch (type) {\n case ContactType.HydrogenBond:\n case ContactType.WaterHydrogenBond:\n case ContactType.BackboneHydrogenBond:\n return 'hydrogen bond'\n case ContactType.Hydrophobic:\n return 'hydrophobic contact'\n case ContactType.HalogenBond:\n return 'halogen bond'\n case ContactType.IonicInteraction:\n return 'ionic interaction'\n case ContactType.MetalCoordination:\n return 'metal coordination'\n case ContactType.CationPi:\n return 'cation-pi interaction'\n case ContactType.PiStacking:\n return 'pi-pi stacking'\n case ContactType.WeakHydrogenBond:\n return 'weak hydrogen bond'\n default:\n return 'unknown contact'\n }\n}\n\nexport const ContactDataDefaultParams = {\n hydrogenBond: true,\n hydrophobic: true,\n halogenBond: true,\n ionicInteraction: true,\n metalCoordination: true,\n cationPi: true,\n piStacking: true,\n weakHydrogenBond: true,\n waterHydrogenBond: true,\n backboneHydrogenBond: true,\n radius: 1,\n filterSele: ''\n}\nexport type ContactDataParams = typeof ContactDataDefaultParams\n | { filterSele: string|[string, string] }\n\nexport const ContactLabelDefaultParams = {\n unit: '',\n size: 2.0\n}\n\nexport type ContactLabelParams = typeof ContactLabelDefaultParams\n\nconst tmpColor = new Color()\nfunction contactColor (type: ContactType) {\n switch (type) {\n case ContactType.HydrogenBond:\n case ContactType.WaterHydrogenBond:\n case ContactType.BackboneHydrogenBond:\n return tmpColor.setHex(0x2B83BA).toArray()\n case ContactType.Hydrophobic:\n return tmpColor.setHex(0x808080).toArray()\n case ContactType.HalogenBond:\n return tmpColor.setHex(0x40FFBF).toArray()\n case ContactType.IonicInteraction:\n return tmpColor.setHex(0xF0C814).toArray()\n case ContactType.MetalCoordination:\n return tmpColor.setHex(0x8C4099).toArray()\n case ContactType.CationPi:\n return tmpColor.setHex(0xFF8000).toArray()\n case ContactType.PiStacking:\n return tmpColor.setHex(0x8CB366).toArray()\n case ContactType.WeakHydrogenBond:\n return tmpColor.setHex(0xC5DDEC).toArray()\n default:\n return tmpColor.setHex(0xCCCCCC).toArray()\n }\n}\n\nexport interface ContactData {\n position1: Float32Array,\n position2: Float32Array,\n color: Float32Array,\n color2: Float32Array,\n radius: Float32Array,\n picking: ContactPicker\n}\n\nexport function getContactData (contacts: FrozenContacts, structure: Structure, params: ContactDataParams): ContactData {\n const p = createParams(params, ContactDataDefaultParams)\n const types: ContactType[] = []\n if (p.hydrogenBond) types.push(ContactType.HydrogenBond)\n if (p.hydrophobic) types.push(ContactType.Hydrophobic)\n if (p.halogenBond) types.push(ContactType.HalogenBond)\n if (p.ionicInteraction) types.push(ContactType.IonicInteraction)\n if (p.metalCoordination) types.push(ContactType.MetalCoordination)\n if (p.cationPi) types.push(ContactType.CationPi)\n if (p.piStacking) types.push(ContactType.PiStacking)\n if (p.weakHydrogenBond) types.push(ContactType.WeakHydrogenBond)\n if (p.waterHydrogenBond) types.push(ContactType.WaterHydrogenBond)\n if (p.backboneHydrogenBond) types.push(ContactType.BackboneHydrogenBond)\n\n const { features, contactSet, contactStore } = contacts\n const { centers, atomSets } = features\n const { x, y, z } = centers\n const { index1, index2, type } = contactStore\n\n const position1: number[] = []\n const position2: number[] = []\n const color: number[] = []\n const radius: number[] = []\n const picking: number[] = []\n\n let filterSet: BitArray | BitArray[] | undefined\n if (p.filterSele) {\n if (Array.isArray(p.filterSele)) {\n filterSet = p.filterSele.map(sele => {\n return structure.getAtomSet(new Selection(sele))\n })\n } else {\n filterSet = structure.getAtomSet(new Selection(p.filterSele))\n }\n }\n\n contactSet.forEach(i => {\n const ti = type[ i ]\n if (!types.includes(ti)) return\n\n if (filterSet) {\n const idx1 = atomSets[index1[i]][0]\n const idx2 = atomSets[index2[i]][0]\n\n if (Array.isArray(filterSet)) {\n if (!(filterSet[0].isSet(idx1) && filterSet[1].isSet(idx2) || (filterSet[1].isSet(idx1) && filterSet[0].isSet(idx2)))) return\n } else {\n if (!filterSet.isSet(idx1) && !filterSet.isSet(idx2)) return\n }\n }\n\n const k = index1[i]\n const l = index2[i]\n position1.push(x[k], y[k], z[k])\n position2.push(x[l], y[l], z[l])\n color.push(...contactColor(ti))\n radius.push(p.radius)\n picking.push(i)\n })\n\n return {\n position1: new Float32Array(position1),\n position2: new Float32Array(position2),\n color: new Float32Array(color),\n color2: new Float32Array(color),\n radius: new Float32Array(radius),\n picking: new ContactPicker(picking, contacts, structure)\n }\n}\n\nexport function getLabelData (contactData: ContactData, params: ContactLabelParams): TextBufferData {\n\n const position = calculateCenterArray(contactData.position1, contactData.position2)\n const text: string[] = []\n\n const direction = calculateDirectionArray(contactData.position1, contactData.position2)\n\n const n = direction.length / 3\n for (let i=0; i\n */\n\nimport { defaults } from '../../utils'\nimport Structure from '../../structure/structure'\nimport { Elements } from '../../structure/structure-constants'\nimport {\n Features, FeatureType,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\n\n/**\n * Hydrophobic carbon (only bonded to carbon or hydrogen); fluorine\n */\nexport function addHydrophobic (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n const state = createFeatureState(FeatureType.Hydrophobic)\n let flag = false\n if (a.number === Elements.C) {\n flag = true\n a.eachBondedAtom(ap => {\n const an = ap.number\n if (an !== Elements.C && an !== Elements.H) flag = false\n })\n } else if (a.number === Elements.F) {\n flag = true\n }\n if (flag) {\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\nfunction isHydrophobicContact (ti: FeatureType, tj: FeatureType) {\n return ti === FeatureType.Hydrophobic && tj === FeatureType.Hydrophobic\n}\n\nexport interface HydrophobicContactsParams {\n maxHydrophobicDist?: number\n masterModelIndex?: number\n}\n\n/**\n * All hydrophobic contacts\n */\nexport function addHydrophobicContacts (structure: Structure, contacts: Contacts, params: HydrophobicContactsParams = {}) {\n const maxHydrophobicDist = defaults(params.maxHydrophobicDist, ContactDefaultParams.maxHydrophobicDist)\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxHydrophobicDist, (j, dSq) => {\n if (j <= i) return\n\n ap1.index = atomSets[ i ][ 0 ]\n ap2.index = atomSets[ j ][ 0 ]\n\n if (invalidAtomContact(ap1, ap2, masterIdx)) return\n if (ap1.number === Elements.F && ap2.number === Elements.F) return\n if (ap1.connectedTo(ap2)) return\n\n if (isHydrophobicContact(types[ i ], types[ j ])) {\n featureSet.setBits(i, j)\n contactStore.addContact(i, j, ContactType.Hydrophobic)\n }\n })\n }\n}\n","/**\n * @file Picker\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { PickerRegistry } from '../globals'\nimport { calculateMeanVector3 } from '../math/vector-utils'\nimport Selection from '../selection/selection'\nimport {\n ArrowPrimitive, BoxPrimitive, ConePrimitive, CylinderPrimitive,\n EllipsoidPrimitive, OctahedronPrimitive, SpherePrimitive,\n TetrahedronPrimitive, TorusPrimitive, PointPrimitive, WidelinePrimitive\n} from '../geometry/primitive'\nimport { contactTypeName, Contacts } from '../chemistry/interactions/contact'\nimport { TypedArray } from '../types';\nimport Component from '../component/component';\nimport { Shape, Structure, Volume } from '../ngl';\nimport BondStore from '../store/bond-store';\nimport Validation from '../structure/validation';\nimport PrincipalAxes from '../math/principal-axes';\nimport Surface from '../surface/surface';\nimport Unitcell from '../symmetry/unitcell';\nimport BondProxy from '../proxy/bond-proxy';\nimport AtomProxy from '../proxy/atom-proxy';\n\n/**\n * Picker class\n * @interface\n */\nclass Picker {\n array: number[]|TypedArray|undefined\n /**\n * @param {Array|TypedArray} [array] - mapping\n */\n constructor (array?: number[]|TypedArray) {\n this.array = array\n }\n\n get type () { return '' }\n get data () { return {} }\n\n /**\n * Get the index for the given picking id\n * @param {Integer} pid - the picking id\n * @return {Integer} the index\n */\n getIndex (pid: number) {\n return this.array ? this.array[ pid ] : pid\n }\n\n /**\n * Get object data\n * @abstract\n * @param {Integer} pid - the picking id\n * @return {Object} the object data\n */\n getObject (pid: number) {\n return {}\n }\n\n _applyTransformations (vector: Vector3, instance: any, component: Component) {\n if (instance) {\n vector.applyMatrix4(instance.matrix)\n }\n if (component) {\n vector.applyMatrix4(component.matrix)\n }\n return vector\n }\n\n /**\n * Get object position\n * @abstract\n * @param {Integer} pid - the picking id\n * @return {Vector3} the object position\n */\n _getPosition (pid: number) {\n return new Vector3()\n }\n\n /**\n * Get position for the given picking id\n * @param {Integer} pid - the picking id\n * @param {Object} instance - the instance that should be applied\n * @param {Component} component - the component of the picked object\n * @return {Vector3} the position\n */\n getPosition (pid: number, instance: any, component: Component) {\n return this._applyTransformations(\n this._getPosition(pid), instance, component\n )\n }\n}\n\n/**\n * Shape picker class\n * @interface\n */\nclass ShapePicker extends Picker {\n shape: Shape\n /**\n * @param {Shape} shape - shape object\n */\n constructor (shape: Shape) {\n super()\n this.shape = shape\n }\n\n get primitive (): any { return }\n\n get data () { return this.shape }\n get type () { return this.primitive.type }\n\n getObject (pid: number) {\n return this.primitive.objectFromShape(this.shape, this.getIndex(pid))\n }\n\n _getPosition (pid: number) {\n return this.primitive.positionFromShape(this.shape, this.getIndex(pid))\n }\n}\n\n//\n\nclass CylinderPicker extends ShapePicker {\n get primitive () { return CylinderPrimitive }\n}\n\nclass ArrowPicker extends ShapePicker {\n get primitive () { return ArrowPrimitive }\n}\n\nclass AtomPicker extends Picker {\n structure: Structure\n constructor (array: Float32Array, structure: Structure) {\n super(array)\n this.structure = structure\n }\n\n get type () { return 'atom' }\n get data () { return this.structure }\n\n getObject (pid: number): AtomProxy {\n return this.structure.getAtomProxy(this.getIndex(pid))\n }\n\n _getPosition (pid: number) {\n return new Vector3().copy(this.getObject(pid) as any)\n }\n}\n\nclass AxesPicker extends Picker {\n axes: PrincipalAxes\n constructor (axes: PrincipalAxes) {\n super()\n this.axes = axes\n }\n\n get type () { return 'axes' }\n get data () { return this.axes }\n\n getObject (/* pid */) {\n return {\n axes: this.axes\n }\n }\n\n _getPosition (/* pid */) {\n return this.axes.center.clone()\n }\n}\n\nclass BondPicker extends Picker {\n structure: Structure\n bondStore: BondStore\n constructor (array: number[]|TypedArray|undefined, structure: Structure, bondStore?: BondStore) {\n super(array)\n this.structure = structure\n this.bondStore = bondStore || structure.bondStore\n }\n\n get type () { return 'bond' }\n get data () { return this.structure }\n\n getObject (pid: number): BondProxy {\n const bp = this.structure.getBondProxy(this.getIndex(pid))\n bp.bondStore = this.bondStore\n return bp\n }\n\n _getPosition (pid: number) {\n const b = this.getObject(pid)\n return new Vector3()\n .copy(b.atom1 as any)\n .add(b.atom2 as any)\n .multiplyScalar(0.5)\n }\n}\n\nclass ContactPicker extends Picker {\n contacts: Contacts\n structure: Structure\n constructor (array: number[]|TypedArray|undefined, contacts: Contacts, structure: Structure) {\n super(array)\n this.contacts = contacts\n this.structure = structure\n }\n\n get type () { return 'contact' }\n get data () { return this.contacts }\n\n getObject (pid: number) {\n const idx = this.getIndex(pid)\n const { features, contactStore } = this.contacts\n const { centers, atomSets } = features\n const { x, y, z } = centers\n const { index1, index2, type } = contactStore\n const k = index1[idx]\n const l = index2[idx]\n return {\n center1: new Vector3(x[k], y[k], z[k]),\n center2: new Vector3(x[l], y[l], z[l]),\n atom1: this.structure.getAtomProxy(atomSets[k][0]),\n atom2: this.structure.getAtomProxy(atomSets[l][0]),\n type: contactTypeName(type[idx])\n }\n }\n\n _getPosition (pid: number) {\n const { center1, center2 } = this.getObject(pid)\n return new Vector3().addVectors(center1, center2).multiplyScalar(0.5)\n }\n}\n\nclass ConePicker extends ShapePicker {\n get primitive () { return ConePrimitive }\n}\n\nclass ClashPicker extends Picker {\n validation: Validation\n structure: Structure\n constructor (array: number[]|TypedArray|undefined, validation: Validation, structure: Structure) {\n super(array)\n this.validation = validation\n this.structure = structure\n }\n\n get type () { return 'clash' }\n get data () { return this.validation }\n\n getObject (pid: number) {\n const val = this.validation\n const idx = this.getIndex(pid)\n return {\n validation: val,\n index: idx,\n clash: val.clashArray[ idx ]\n }\n }\n\n _getAtomProxyFromSele (sele: string) {\n const selection = new Selection(sele)\n const idx = this.structure.getAtomIndices(selection)![ 0 ]\n return this.structure.getAtomProxy(idx)\n }\n\n _getPosition (pid: number) {\n const clash = this.getObject(pid).clash\n const ap1 = this._getAtomProxyFromSele(clash.sele1)\n const ap2 = this._getAtomProxyFromSele(clash.sele2)\n return new Vector3().copy(ap1 as any).add(ap2 as any).multiplyScalar(0.5)\n }\n}\n\nclass DistancePicker extends BondPicker {\n get type () { return 'distance' }\n}\n\nclass EllipsoidPicker extends ShapePicker {\n get primitive () { return EllipsoidPrimitive }\n}\n\nclass OctahedronPicker extends ShapePicker {\n get primitive () { return OctahedronPrimitive }\n}\n\nclass BoxPicker extends ShapePicker {\n get primitive () { return BoxPrimitive }\n}\n\nclass IgnorePicker extends Picker {\n get type () { return 'ignore' }\n}\n\nexport interface MeshData {\n name: string|undefined\n serial: number\n index: Uint32Array|Uint16Array|number[]\n normal?: Float32Array|number[]\n position: Float32Array|number[]\n color: Float32Array|number[]\n}\nclass MeshPicker extends ShapePicker {\n mesh: MeshData\n __position: Vector3\n\n constructor (shape: Shape, mesh: MeshData) {\n super(shape)\n this.mesh = mesh\n }\n\n get type () { return 'mesh' }\n\n getObject (/* pid */) {\n const m = this.mesh\n return {\n shape: this.shape,\n name: m.name,\n serial: m.serial\n }\n }\n\n _getPosition (/* pid */) {\n if (!this.__position) {\n this.__position = calculateMeanVector3(this.mesh.position as any)\n }\n return this.__position\n }\n}\n\nclass SpherePicker extends ShapePicker {\n get primitive () { return SpherePrimitive }\n}\n\nclass SurfacePicker extends Picker {\n surface: Surface\n constructor (array: number[]|TypedArray|undefined, surface: Surface) {\n super(array)\n this.surface = surface\n }\n\n get type () { return 'surface' }\n get data () { return this.surface }\n\n getObject (pid: number) {\n return {\n surface: this.surface,\n index: this.getIndex(pid)\n }\n }\n\n _getPosition (/* pid */) {\n return this.surface.center.clone()\n }\n}\n\nclass TetrahedronPicker extends ShapePicker {\n get primitive () { return TetrahedronPrimitive }\n}\n\nclass TorusPicker extends ShapePicker {\n get primitive () { return TorusPrimitive }\n}\n\nclass UnitcellPicker extends Picker {\n unitcell: Unitcell\n structure: Structure\n\n constructor (unitcell: Unitcell, structure: Structure) {\n super()\n this.unitcell = unitcell\n this.structure = structure\n }\n\n get type () { return 'unitcell' }\n get data () { return this.unitcell }\n\n getObject (/* pid */) {\n return {\n unitcell: this.unitcell,\n structure: this.structure\n }\n }\n\n _getPosition (/* pid */) {\n return this.unitcell.getCenter(this.structure)\n }\n}\n\nclass UnknownPicker extends Picker {\n get type () { return 'unknown' }\n}\n\nclass VolumePicker extends Picker {\n volume: Volume\n constructor (array: TypedArray, volume: Volume) {\n super(array)\n this.volume = volume\n }\n\n get type () { return 'volume' }\n get data () { return this.volume }\n\n getObject (pid: number) {\n const vol = this.volume\n const idx = this.getIndex(pid)\n return {\n volume: vol,\n index: idx,\n value: vol.data[ idx ]\n }\n }\n\n _getPosition (pid: number) {\n const dp = this.volume.position\n const idx = this.getIndex(pid)\n return new Vector3(\n dp[ idx * 3 ],\n dp[ idx * 3 + 1 ],\n dp[ idx * 3 + 2 ]\n )\n }\n}\n\nclass SlicePicker extends VolumePicker {\n get type () { return 'slice' }\n}\n\nclass PointPicker extends ShapePicker {\n get primitive () { return PointPrimitive }\n}\n\nclass WidelinePicker extends ShapePicker {\n get primitive () { return WidelinePrimitive }\n}\n\nPickerRegistry.add('arrow', ArrowPicker)\nPickerRegistry.add('box', BoxPicker)\nPickerRegistry.add('cone', ConePicker)\nPickerRegistry.add('cylinder', CylinderPicker)\nPickerRegistry.add('ellipsoid', EllipsoidPicker)\nPickerRegistry.add('octahedron', OctahedronPicker)\nPickerRegistry.add('sphere', SpherePicker)\nPickerRegistry.add('tetrahedron', TetrahedronPicker)\nPickerRegistry.add('torus', TorusPicker)\nPickerRegistry.add('point', PointPicker)\nPickerRegistry.add('wideline', WidelinePicker)\n\nexport {\n Picker,\n ShapePicker,\n ArrowPicker,\n AtomPicker,\n AxesPicker,\n BondPicker,\n BoxPicker,\n ConePicker,\n ContactPicker,\n CylinderPicker,\n ClashPicker,\n DistancePicker,\n EllipsoidPicker,\n IgnorePicker,\n OctahedronPicker,\n MeshPicker,\n SlicePicker,\n SpherePicker,\n SurfacePicker,\n TetrahedronPicker,\n TorusPicker,\n UnitcellPicker,\n UnknownPicker,\n VolumePicker,\n PointPicker,\n WidelinePicker\n}\n","/**\n * @file Marching Cubes\n * @author Alexander Rose \n * @private\n */\n\nimport { getUintArray } from '../utils'\n\nfunction getEdgeTable () {\n return new Uint32Array([\n 0x0, 0x109, 0x203, 0x30a, 0x406, 0x50f, 0x605, 0x70c,\n 0x80c, 0x905, 0xa0f, 0xb06, 0xc0a, 0xd03, 0xe09, 0xf00,\n 0x190, 0x99, 0x393, 0x29a, 0x596, 0x49f, 0x795, 0x69c,\n 0x99c, 0x895, 0xb9f, 0xa96, 0xd9a, 0xc93, 0xf99, 0xe90,\n 0x230, 0x339, 0x33, 0x13a, 0x636, 0x73f, 0x435, 0x53c,\n 0xa3c, 0xb35, 0x83f, 0x936, 0xe3a, 0xf33, 0xc39, 0xd30,\n 0x3a0, 0x2a9, 0x1a3, 0xaa, 0x7a6, 0x6af, 0x5a5, 0x4ac,\n 0xbac, 0xaa5, 0x9af, 0x8a6, 0xfaa, 0xea3, 0xda9, 0xca0,\n 0x460, 0x569, 0x663, 0x76a, 0x66, 0x16f, 0x265, 0x36c,\n 0xc6c, 0xd65, 0xe6f, 0xf66, 0x86a, 0x963, 0xa69, 0xb60,\n 0x5f0, 0x4f9, 0x7f3, 0x6fa, 0x1f6, 0xff, 0x3f5, 0x2fc,\n 0xdfc, 0xcf5, 0xfff, 0xef6, 0x9fa, 0x8f3, 0xbf9, 0xaf0,\n 0x650, 0x759, 0x453, 0x55a, 0x256, 0x35f, 0x55, 0x15c,\n 0xe5c, 0xf55, 0xc5f, 0xd56, 0xa5a, 0xb53, 0x859, 0x950,\n 0x7c0, 0x6c9, 0x5c3, 0x4ca, 0x3c6, 0x2cf, 0x1c5, 0xcc,\n 0xfcc, 0xec5, 0xdcf, 0xcc6, 0xbca, 0xac3, 0x9c9, 0x8c0,\n 0x8c0, 0x9c9, 0xac3, 0xbca, 0xcc6, 0xdcf, 0xec5, 0xfcc,\n 0xcc, 0x1c5, 0x2cf, 0x3c6, 0x4ca, 0x5c3, 0x6c9, 0x7c0,\n 0x950, 0x859, 0xb53, 0xa5a, 0xd56, 0xc5f, 0xf55, 0xe5c,\n 0x15c, 0x55, 0x35f, 0x256, 0x55a, 0x453, 0x759, 0x650,\n 0xaf0, 0xbf9, 0x8f3, 0x9fa, 0xef6, 0xfff, 0xcf5, 0xdfc,\n 0x2fc, 0x3f5, 0xff, 0x1f6, 0x6fa, 0x7f3, 0x4f9, 0x5f0,\n 0xb60, 0xa69, 0x963, 0x86a, 0xf66, 0xe6f, 0xd65, 0xc6c,\n 0x36c, 0x265, 0x16f, 0x66, 0x76a, 0x663, 0x569, 0x460,\n 0xca0, 0xda9, 0xea3, 0xfaa, 0x8a6, 0x9af, 0xaa5, 0xbac,\n 0x4ac, 0x5a5, 0x6af, 0x7a6, 0xaa, 0x1a3, 0x2a9, 0x3a0,\n 0xd30, 0xc39, 0xf33, 0xe3a, 0x936, 0x83f, 0xb35, 0xa3c,\n 0x53c, 0x435, 0x73f, 0x636, 0x13a, 0x33, 0x339, 0x230,\n 0xe90, 0xf99, 0xc93, 0xd9a, 0xa96, 0xb9f, 0x895, 0x99c,\n 0x69c, 0x795, 0x49f, 0x596, 0x29a, 0x393, 0x99, 0x190,\n 0xf00, 0xe09, 0xd03, 0xc0a, 0xb06, 0xa0f, 0x905, 0x80c,\n 0x70c, 0x605, 0x50f, 0x406, 0x30a, 0x203, 0x109, 0x0\n ])\n}\n\nfunction getTriTable (): Int32Array {\n return new Int32Array([\n -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 8, 3, 9, 8, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 2, 10, 0, 2, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 8, 3, 2, 10, 8, 10, 9, 8, -1, -1, -1, -1, -1, -1, -1,\n 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 11, 2, 8, 11, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 9, 0, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 11, 2, 1, 9, 11, 9, 8, 11, -1, -1, -1, -1, -1, -1, -1,\n 3, 10, 1, 11, 10, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 10, 1, 0, 8, 10, 8, 11, 10, -1, -1, -1, -1, -1, -1, -1,\n 3, 9, 0, 3, 11, 9, 11, 10, 9, -1, -1, -1, -1, -1, -1, -1,\n 9, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 3, 0, 7, 3, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 9, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 1, 9, 4, 7, 1, 7, 3, 1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 4, 7, 3, 0, 4, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1,\n 9, 2, 10, 9, 0, 2, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1,\n 2, 10, 9, 2, 9, 7, 2, 7, 3, 7, 9, 4, -1, -1, -1, -1,\n 8, 4, 7, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 11, 4, 7, 11, 2, 4, 2, 0, 4, -1, -1, -1, -1, -1, -1, -1,\n 9, 0, 1, 8, 4, 7, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1,\n 4, 7, 11, 9, 4, 11, 9, 11, 2, 9, 2, 1, -1, -1, -1, -1,\n 3, 10, 1, 3, 11, 10, 7, 8, 4, -1, -1, -1, -1, -1, -1, -1,\n 1, 11, 10, 1, 4, 11, 1, 0, 4, 7, 11, 4, -1, -1, -1, -1,\n 4, 7, 8, 9, 0, 11, 9, 11, 10, 11, 0, 3, -1, -1, -1, -1,\n 4, 7, 11, 4, 11, 9, 9, 11, 10, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 4, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 5, 4, 1, 5, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 8, 5, 4, 8, 3, 5, 3, 1, 5, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 8, 1, 2, 10, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1,\n 5, 2, 10, 5, 4, 2, 4, 0, 2, -1, -1, -1, -1, -1, -1, -1,\n 2, 10, 5, 3, 2, 5, 3, 5, 4, 3, 4, 8, -1, -1, -1, -1,\n 9, 5, 4, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 11, 2, 0, 8, 11, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1,\n 0, 5, 4, 0, 1, 5, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1,\n 2, 1, 5, 2, 5, 8, 2, 8, 11, 4, 8, 5, -1, -1, -1, -1,\n 10, 3, 11, 10, 1, 3, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1,\n 4, 9, 5, 0, 8, 1, 8, 10, 1, 8, 11, 10, -1, -1, -1, -1,\n 5, 4, 0, 5, 0, 11, 5, 11, 10, 11, 0, 3, -1, -1, -1, -1,\n 5, 4, 8, 5, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1,\n 9, 7, 8, 5, 7, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 3, 0, 9, 5, 3, 5, 7, 3, -1, -1, -1, -1, -1, -1, -1,\n 0, 7, 8, 0, 1, 7, 1, 5, 7, -1, -1, -1, -1, -1, -1, -1,\n 1, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 7, 8, 9, 5, 7, 10, 1, 2, -1, -1, -1, -1, -1, -1, -1,\n 10, 1, 2, 9, 5, 0, 5, 3, 0, 5, 7, 3, -1, -1, -1, -1,\n 8, 0, 2, 8, 2, 5, 8, 5, 7, 10, 5, 2, -1, -1, -1, -1,\n 2, 10, 5, 2, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1,\n 7, 9, 5, 7, 8, 9, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 7, 9, 7, 2, 9, 2, 0, 2, 7, 11, -1, -1, -1, -1,\n 2, 3, 11, 0, 1, 8, 1, 7, 8, 1, 5, 7, -1, -1, -1, -1,\n 11, 2, 1, 11, 1, 7, 7, 1, 5, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 8, 8, 5, 7, 10, 1, 3, 10, 3, 11, -1, -1, -1, -1,\n 5, 7, 0, 5, 0, 9, 7, 11, 0, 1, 0, 10, 11, 10, 0, -1,\n 11, 10, 0, 11, 0, 3, 10, 5, 0, 8, 0, 7, 5, 7, 0, -1,\n 11, 10, 5, 7, 11, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 0, 1, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 8, 3, 1, 9, 8, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1,\n 1, 6, 5, 2, 6, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 6, 5, 1, 2, 6, 3, 0, 8, -1, -1, -1, -1, -1, -1, -1,\n 9, 6, 5, 9, 0, 6, 0, 2, 6, -1, -1, -1, -1, -1, -1, -1,\n 5, 9, 8, 5, 8, 2, 5, 2, 6, 3, 2, 8, -1, -1, -1, -1,\n 2, 3, 11, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 11, 0, 8, 11, 2, 0, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 9, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1,\n 5, 10, 6, 1, 9, 2, 9, 11, 2, 9, 8, 11, -1, -1, -1, -1,\n 6, 3, 11, 6, 5, 3, 5, 1, 3, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 11, 0, 11, 5, 0, 5, 1, 5, 11, 6, -1, -1, -1, -1,\n 3, 11, 6, 0, 3, 6, 0, 6, 5, 0, 5, 9, -1, -1, -1, -1,\n 6, 5, 9, 6, 9, 11, 11, 9, 8, -1, -1, -1, -1, -1, -1, -1,\n 5, 10, 6, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 3, 0, 4, 7, 3, 6, 5, 10, -1, -1, -1, -1, -1, -1, -1,\n 1, 9, 0, 5, 10, 6, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1,\n 10, 6, 5, 1, 9, 7, 1, 7, 3, 7, 9, 4, -1, -1, -1, -1,\n 6, 1, 2, 6, 5, 1, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 5, 5, 2, 6, 3, 0, 4, 3, 4, 7, -1, -1, -1, -1,\n 8, 4, 7, 9, 0, 5, 0, 6, 5, 0, 2, 6, -1, -1, -1, -1,\n 7, 3, 9, 7, 9, 4, 3, 2, 9, 5, 9, 6, 2, 6, 9, -1,\n 3, 11, 2, 7, 8, 4, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1,\n 5, 10, 6, 4, 7, 2, 4, 2, 0, 2, 7, 11, -1, -1, -1, -1,\n 0, 1, 9, 4, 7, 8, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1,\n 9, 2, 1, 9, 11, 2, 9, 4, 11, 7, 11, 4, 5, 10, 6, -1,\n 8, 4, 7, 3, 11, 5, 3, 5, 1, 5, 11, 6, -1, -1, -1, -1,\n 5, 1, 11, 5, 11, 6, 1, 0, 11, 7, 11, 4, 0, 4, 11, -1,\n 0, 5, 9, 0, 6, 5, 0, 3, 6, 11, 6, 3, 8, 4, 7, -1,\n 6, 5, 9, 6, 9, 11, 4, 7, 9, 7, 11, 9, -1, -1, -1, -1,\n 10, 4, 9, 6, 4, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 10, 6, 4, 9, 10, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1,\n 10, 0, 1, 10, 6, 0, 6, 4, 0, -1, -1, -1, -1, -1, -1, -1,\n 8, 3, 1, 8, 1, 6, 8, 6, 4, 6, 1, 10, -1, -1, -1, -1,\n 1, 4, 9, 1, 2, 4, 2, 6, 4, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 8, 1, 2, 9, 2, 4, 9, 2, 6, 4, -1, -1, -1, -1,\n 0, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 8, 3, 2, 8, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1,\n 10, 4, 9, 10, 6, 4, 11, 2, 3, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 2, 2, 8, 11, 4, 9, 10, 4, 10, 6, -1, -1, -1, -1,\n 3, 11, 2, 0, 1, 6, 0, 6, 4, 6, 1, 10, -1, -1, -1, -1,\n 6, 4, 1, 6, 1, 10, 4, 8, 1, 2, 1, 11, 8, 11, 1, -1,\n 9, 6, 4, 9, 3, 6, 9, 1, 3, 11, 6, 3, -1, -1, -1, -1,\n 8, 11, 1, 8, 1, 0, 11, 6, 1, 9, 1, 4, 6, 4, 1, -1,\n 3, 11, 6, 3, 6, 0, 0, 6, 4, -1, -1, -1, -1, -1, -1, -1,\n 6, 4, 8, 11, 6, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 7, 10, 6, 7, 8, 10, 8, 9, 10, -1, -1, -1, -1, -1, -1, -1,\n 0, 7, 3, 0, 10, 7, 0, 9, 10, 6, 7, 10, -1, -1, -1, -1,\n 10, 6, 7, 1, 10, 7, 1, 7, 8, 1, 8, 0, -1, -1, -1, -1,\n 10, 6, 7, 10, 7, 1, 1, 7, 3, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 6, 1, 6, 8, 1, 8, 9, 8, 6, 7, -1, -1, -1, -1,\n 2, 6, 9, 2, 9, 1, 6, 7, 9, 0, 9, 3, 7, 3, 9, -1,\n 7, 8, 0, 7, 0, 6, 6, 0, 2, -1, -1, -1, -1, -1, -1, -1,\n 7, 3, 2, 6, 7, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 3, 11, 10, 6, 8, 10, 8, 9, 8, 6, 7, -1, -1, -1, -1,\n 2, 0, 7, 2, 7, 11, 0, 9, 7, 6, 7, 10, 9, 10, 7, -1,\n 1, 8, 0, 1, 7, 8, 1, 10, 7, 6, 7, 10, 2, 3, 11, -1,\n 11, 2, 1, 11, 1, 7, 10, 6, 1, 6, 7, 1, -1, -1, -1, -1,\n 8, 9, 6, 8, 6, 7, 9, 1, 6, 11, 6, 3, 1, 3, 6, -1,\n 0, 9, 1, 11, 6, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 7, 8, 0, 7, 0, 6, 3, 11, 0, 11, 6, 0, -1, -1, -1, -1,\n 7, 11, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 8, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 9, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 8, 1, 9, 8, 3, 1, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1,\n 10, 1, 2, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 3, 0, 8, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1,\n 2, 9, 0, 2, 10, 9, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1,\n 6, 11, 7, 2, 10, 3, 10, 8, 3, 10, 9, 8, -1, -1, -1, -1,\n 7, 2, 3, 6, 2, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 7, 0, 8, 7, 6, 0, 6, 2, 0, -1, -1, -1, -1, -1, -1, -1,\n 2, 7, 6, 2, 3, 7, 0, 1, 9, -1, -1, -1, -1, -1, -1, -1,\n 1, 6, 2, 1, 8, 6, 1, 9, 8, 8, 7, 6, -1, -1, -1, -1,\n 10, 7, 6, 10, 1, 7, 1, 3, 7, -1, -1, -1, -1, -1, -1, -1,\n 10, 7, 6, 1, 7, 10, 1, 8, 7, 1, 0, 8, -1, -1, -1, -1,\n 0, 3, 7, 0, 7, 10, 0, 10, 9, 6, 10, 7, -1, -1, -1, -1,\n 7, 6, 10, 7, 10, 8, 8, 10, 9, -1, -1, -1, -1, -1, -1, -1,\n 6, 8, 4, 11, 8, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 6, 11, 3, 0, 6, 0, 4, 6, -1, -1, -1, -1, -1, -1, -1,\n 8, 6, 11, 8, 4, 6, 9, 0, 1, -1, -1, -1, -1, -1, -1, -1,\n 9, 4, 6, 9, 6, 3, 9, 3, 1, 11, 3, 6, -1, -1, -1, -1,\n 6, 8, 4, 6, 11, 8, 2, 10, 1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 3, 0, 11, 0, 6, 11, 0, 4, 6, -1, -1, -1, -1,\n 4, 11, 8, 4, 6, 11, 0, 2, 9, 2, 10, 9, -1, -1, -1, -1,\n 10, 9, 3, 10, 3, 2, 9, 4, 3, 11, 3, 6, 4, 6, 3, -1,\n 8, 2, 3, 8, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1,\n 0, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 9, 0, 2, 3, 4, 2, 4, 6, 4, 3, 8, -1, -1, -1, -1,\n 1, 9, 4, 1, 4, 2, 2, 4, 6, -1, -1, -1, -1, -1, -1, -1,\n 8, 1, 3, 8, 6, 1, 8, 4, 6, 6, 10, 1, -1, -1, -1, -1,\n 10, 1, 0, 10, 0, 6, 6, 0, 4, -1, -1, -1, -1, -1, -1, -1,\n 4, 6, 3, 4, 3, 8, 6, 10, 3, 0, 3, 9, 10, 9, 3, -1,\n 10, 9, 4, 6, 10, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 9, 5, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 4, 9, 5, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1,\n 5, 0, 1, 5, 4, 0, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1,\n 11, 7, 6, 8, 3, 4, 3, 5, 4, 3, 1, 5, -1, -1, -1, -1,\n 9, 5, 4, 10, 1, 2, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1,\n 6, 11, 7, 1, 2, 10, 0, 8, 3, 4, 9, 5, -1, -1, -1, -1,\n 7, 6, 11, 5, 4, 10, 4, 2, 10, 4, 0, 2, -1, -1, -1, -1,\n 3, 4, 8, 3, 5, 4, 3, 2, 5, 10, 5, 2, 11, 7, 6, -1,\n 7, 2, 3, 7, 6, 2, 5, 4, 9, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 4, 0, 8, 6, 0, 6, 2, 6, 8, 7, -1, -1, -1, -1,\n 3, 6, 2, 3, 7, 6, 1, 5, 0, 5, 4, 0, -1, -1, -1, -1,\n 6, 2, 8, 6, 8, 7, 2, 1, 8, 4, 8, 5, 1, 5, 8, -1,\n 9, 5, 4, 10, 1, 6, 1, 7, 6, 1, 3, 7, -1, -1, -1, -1,\n 1, 6, 10, 1, 7, 6, 1, 0, 7, 8, 7, 0, 9, 5, 4, -1,\n 4, 0, 10, 4, 10, 5, 0, 3, 10, 6, 10, 7, 3, 7, 10, -1,\n 7, 6, 10, 7, 10, 8, 5, 4, 10, 4, 8, 10, -1, -1, -1, -1,\n 6, 9, 5, 6, 11, 9, 11, 8, 9, -1, -1, -1, -1, -1, -1, -1,\n 3, 6, 11, 0, 6, 3, 0, 5, 6, 0, 9, 5, -1, -1, -1, -1,\n 0, 11, 8, 0, 5, 11, 0, 1, 5, 5, 6, 11, -1, -1, -1, -1,\n 6, 11, 3, 6, 3, 5, 5, 3, 1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 9, 5, 11, 9, 11, 8, 11, 5, 6, -1, -1, -1, -1,\n 0, 11, 3, 0, 6, 11, 0, 9, 6, 5, 6, 9, 1, 2, 10, -1,\n 11, 8, 5, 11, 5, 6, 8, 0, 5, 10, 5, 2, 0, 2, 5, -1,\n 6, 11, 3, 6, 3, 5, 2, 10, 3, 10, 5, 3, -1, -1, -1, -1,\n 5, 8, 9, 5, 2, 8, 5, 6, 2, 3, 8, 2, -1, -1, -1, -1,\n 9, 5, 6, 9, 6, 0, 0, 6, 2, -1, -1, -1, -1, -1, -1, -1,\n 1, 5, 8, 1, 8, 0, 5, 6, 8, 3, 8, 2, 6, 2, 8, -1,\n 1, 5, 6, 2, 1, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 3, 6, 1, 6, 10, 3, 8, 6, 5, 6, 9, 8, 9, 6, -1,\n 10, 1, 0, 10, 0, 6, 9, 5, 0, 5, 6, 0, -1, -1, -1, -1,\n 0, 3, 8, 5, 6, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 10, 5, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 11, 5, 10, 7, 5, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 11, 5, 10, 11, 7, 5, 8, 3, 0, -1, -1, -1, -1, -1, -1, -1,\n 5, 11, 7, 5, 10, 11, 1, 9, 0, -1, -1, -1, -1, -1, -1, -1,\n 10, 7, 5, 10, 11, 7, 9, 8, 1, 8, 3, 1, -1, -1, -1, -1,\n 11, 1, 2, 11, 7, 1, 7, 5, 1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 1, 2, 7, 1, 7, 5, 7, 2, 11, -1, -1, -1, -1,\n 9, 7, 5, 9, 2, 7, 9, 0, 2, 2, 11, 7, -1, -1, -1, -1,\n 7, 5, 2, 7, 2, 11, 5, 9, 2, 3, 2, 8, 9, 8, 2, -1,\n 2, 5, 10, 2, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1,\n 8, 2, 0, 8, 5, 2, 8, 7, 5, 10, 2, 5, -1, -1, -1, -1,\n 9, 0, 1, 5, 10, 3, 5, 3, 7, 3, 10, 2, -1, -1, -1, -1,\n 9, 8, 2, 9, 2, 1, 8, 7, 2, 10, 2, 5, 7, 5, 2, -1,\n 1, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 7, 0, 7, 1, 1, 7, 5, -1, -1, -1, -1, -1, -1, -1,\n 9, 0, 3, 9, 3, 5, 5, 3, 7, -1, -1, -1, -1, -1, -1, -1,\n 9, 8, 7, 5, 9, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 5, 8, 4, 5, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1,\n 5, 0, 4, 5, 11, 0, 5, 10, 11, 11, 3, 0, -1, -1, -1, -1,\n 0, 1, 9, 8, 4, 10, 8, 10, 11, 10, 4, 5, -1, -1, -1, -1,\n 10, 11, 4, 10, 4, 5, 11, 3, 4, 9, 4, 1, 3, 1, 4, -1,\n 2, 5, 1, 2, 8, 5, 2, 11, 8, 4, 5, 8, -1, -1, -1, -1,\n 0, 4, 11, 0, 11, 3, 4, 5, 11, 2, 11, 1, 5, 1, 11, -1,\n 0, 2, 5, 0, 5, 9, 2, 11, 5, 4, 5, 8, 11, 8, 5, -1,\n 9, 4, 5, 2, 11, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 5, 10, 3, 5, 2, 3, 4, 5, 3, 8, 4, -1, -1, -1, -1,\n 5, 10, 2, 5, 2, 4, 4, 2, 0, -1, -1, -1, -1, -1, -1, -1,\n 3, 10, 2, 3, 5, 10, 3, 8, 5, 4, 5, 8, 0, 1, 9, -1,\n 5, 10, 2, 5, 2, 4, 1, 9, 2, 9, 4, 2, -1, -1, -1, -1,\n 8, 4, 5, 8, 5, 3, 3, 5, 1, -1, -1, -1, -1, -1, -1, -1,\n 0, 4, 5, 1, 0, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 8, 4, 5, 8, 5, 3, 9, 0, 5, 0, 3, 5, -1, -1, -1, -1,\n 9, 4, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 11, 7, 4, 9, 11, 9, 10, 11, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 4, 9, 7, 9, 11, 7, 9, 10, 11, -1, -1, -1, -1,\n 1, 10, 11, 1, 11, 4, 1, 4, 0, 7, 4, 11, -1, -1, -1, -1,\n 3, 1, 4, 3, 4, 8, 1, 10, 4, 7, 4, 11, 10, 11, 4, -1,\n 4, 11, 7, 9, 11, 4, 9, 2, 11, 9, 1, 2, -1, -1, -1, -1,\n 9, 7, 4, 9, 11, 7, 9, 1, 11, 2, 11, 1, 0, 8, 3, -1,\n 11, 7, 4, 11, 4, 2, 2, 4, 0, -1, -1, -1, -1, -1, -1, -1,\n 11, 7, 4, 11, 4, 2, 8, 3, 4, 3, 2, 4, -1, -1, -1, -1,\n 2, 9, 10, 2, 7, 9, 2, 3, 7, 7, 4, 9, -1, -1, -1, -1,\n 9, 10, 7, 9, 7, 4, 10, 2, 7, 8, 7, 0, 2, 0, 7, -1,\n 3, 7, 10, 3, 10, 2, 7, 4, 10, 1, 10, 0, 4, 0, 10, -1,\n 1, 10, 2, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 9, 1, 4, 1, 7, 7, 1, 3, -1, -1, -1, -1, -1, -1, -1,\n 4, 9, 1, 4, 1, 7, 0, 8, 1, 8, 7, 1, -1, -1, -1, -1,\n 4, 0, 3, 7, 4, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 8, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 9, 3, 9, 11, 11, 9, 10, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 10, 0, 10, 8, 8, 10, 11, -1, -1, -1, -1, -1, -1, -1,\n 3, 1, 10, 11, 3, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 11, 1, 11, 9, 9, 11, 8, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 9, 3, 9, 11, 1, 2, 9, 2, 11, 9, -1, -1, -1, -1,\n 0, 2, 11, 8, 0, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 2, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 3, 8, 2, 8, 10, 10, 8, 9, -1, -1, -1, -1, -1, -1, -1,\n 9, 10, 2, 0, 9, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 3, 8, 2, 8, 10, 0, 1, 8, 1, 10, 8, -1, -1, -1, -1,\n 1, 10, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 3, 8, 9, 1, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 9, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 3, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1\n ])\n}\n\ninterface MarchingCubes {\n new (field: number[], nx: number, ny: number, nz: number, atomindex: number[]): void\n triangulate: (_isolevel: number, _noNormals: boolean, _box: number[][]|undefined, _contour: boolean, _wrap: boolean) => {\n position: Float32Array\n normal: undefined|Float32Array\n index: Uint32Array|Uint16Array\n atomindex: Int32Array|undefined\n contour: boolean\n }\n}\nfunction MarchingCubes (this: MarchingCubes, field: number[], nx: number, ny: number, nz: number, atomindex: number[]) {\n // Based on alteredq / http://alteredqualia.com/\n // port of greggman's ThreeD version of marching cubes to Three.js\n // http://webglsamples.googlecode.com/hg/blob/blob.html\n //\n // Adapted for NGL by Alexander Rose\n\n // Triangles are constructed between points on cube edges.\n // allowedContours[edge1][edge1] indicates which lines from a given\n // triangle should be shown in line mode.\n\n // Values are bitmasks:\n // In loop over cubes we keep another bitmask indicating whether our current\n // cell is the first x-value (1),\n // first y-value (2) or first z-value (4) of the current loop.\n // We draw all lines on leading faces but only draw trailing face lines the first\n // time through the loop\n // A value of 8 below means the edge is always drawn (leading face)\n\n // E.g. the first row, lines between edge0 and other edges in the bottom\n // x-y plane are only drawn for the first value of z, edges in the\n // x-z plane are only drawn for the first value of y. No other lines\n // are drawn as they're redundant\n // The line between edge 1 and 5 is always drawn as it's on the leading edge\n var allowedContours = [\n\n [ 0, 4, 4, 4, 2, 0, 0, 0, 2, 2, 0, 0 ], // 1 2 3 4 8 9\n [ 4, 0, 4, 4, 0, 8, 0, 0, 0, 8, 8, 0 ], // 0 2 3 5 9 10\n [ 4, 4, 0, 4, 0, 0, 8, 0, 0, 0, 8, 8 ], // 0 1 3 6 10 11\n [ 4, 4, 4, 0, 0, 0, 0, 1, 1, 0, 0, 1 ], // 0 1 2 7 8 11\n [ 2, 0, 0, 0, 0, 8, 8, 8, 2, 2, 0, 0 ], // 0 5 6 7 8 9\n [ 0, 8, 0, 0, 8, 0, 8, 8, 0, 8, 8, 0 ], // And rotate it\n [ 0, 0, 8, 0, 8, 8, 0, 8, 0, 0, 8, 8 ],\n [ 0, 0, 0, 1, 8, 8, 8, 0, 1, 0, 0, 1 ],\n [ 2, 0, 0, 1, 2, 0, 0, 1, 0, 2, 0, 1 ], // 0 3 4 7 9 11\n [ 2, 8, 0, 0, 2, 8, 0, 0, 2, 0, 8, 0 ], // And rotate some more\n [ 0, 8, 8, 0, 0, 8, 8, 0, 0, 8, 0, 8 ],\n [ 0, 0, 8, 1, 0, 0, 8, 1, 1, 0, 8, 0 ]\n\n ]\n\n var isolevel = 0\n var noNormals = false\n var contour = false\n var wrap = false\n var isNegativeIso = false\n var normalFactor = -1\n\n\n var n = nx * ny * nz\n\n // deltas\n var yd = nx\n var zd = nx * ny\n\n var normalCache: Float32Array, vertexIndex: Int32Array\n var count: number, icount: number\n\n var ilist = new Int32Array(12)\n\n var positionArray: number[] = []\n var normalArray: number[] = []\n var indexArray: number[] = []\n var atomindexArray: number[] = []\n\n var edgeTable = getEdgeTable()\n var triTable = getTriTable()\n\n var mx: number, my: number, mz: number\n\n //\n\n this.triangulate = function (_isolevel: number, _noNormals: boolean, _box: number[][]|undefined, _contour: boolean, _wrap: boolean) {\n isolevel = _isolevel\n isNegativeIso = isolevel < 0.0\n contour = _contour\n wrap = _wrap\n // Normals currently disabled in contour mode for performance (unused)\n noNormals = _noNormals || contour\n\n if (!noNormals) {\n normalFactor = isolevel > 0 ? -1.0 : 1.0\n if (!normalCache) {\n normalCache = new Float32Array(n * 3)\n } \n }\n\n var vIndexLength = n * 3\n\n if (!vertexIndex || vertexIndex.length !== vIndexLength) {\n vertexIndex = new Int32Array(vIndexLength)\n }\n\n count = 0\n icount = 0\n\n if (_box !== undefined) {\n var min = _box[ 0 ].map(Math.round)\n var max = _box[ 1 ].map(Math.round)\n\n mx = nx * Math.ceil(Math.abs(min[ 0 ]) / nx)\n my = ny * Math.ceil(Math.abs(min[ 1 ]) / ny)\n mz = nz * Math.ceil(Math.abs(min[ 2 ]) / nz)\n\n triangulate(\n min[ 0 ], min[ 1 ], min[ 2 ],\n max[ 0 ], max[ 1 ], max[ 2 ]\n )\n } else {\n mx = my = mz = 0\n\n triangulate()\n }\n\n positionArray.length = count * 3\n if (!noNormals) normalArray.length = count * 3\n indexArray.length = icount\n if (atomindex) atomindexArray.length = count\n\n return {\n position: new Float32Array(positionArray),\n normal: noNormals ? undefined : new Float32Array(normalArray),\n index: getUintArray(indexArray, positionArray.length / 3),\n atomindex: atomindex ? new Int32Array(atomindexArray) : undefined,\n contour: contour\n }\n }\n\n // polygonization\n\n function lerp (a: number, b: number, t: number) { return a + (b - a) * t }\n\n function index (x: number, y: number, z: number) {\n x = (x + mx) % nx\n y = (y + my) % ny\n z = (z + mz) % nz\n return ((zd * z) + yd * y) + x\n }\n\n function VIntX (q: number, offset: number, x: number, y: number, z: number, valp1: number, valp2: number) {\n var _q = 3 * q\n\n if (vertexIndex[ _q ] < 0) {\n var mu = (isolevel - valp1) / (valp2 - valp1)\n var nc = normalCache\n\n var c = count * 3\n\n positionArray[ c ] = x + mu\n positionArray[ c + 1 ] = y\n positionArray[ c + 2 ] = z\n\n if (!noNormals) {\n var q3 = q * 3\n\n normalArray[ c ] = normalFactor * lerp(nc[ q3 ], nc[ q3 + 3 ], mu)\n normalArray[ c + 1 ] = normalFactor * lerp(nc[ q3 + 1 ], nc[ q3 + 4 ], mu)\n normalArray[ c + 2 ] = normalFactor * lerp(nc[ q3 + 2 ], nc[ q3 + 5 ], mu)\n }\n\n if (atomindex) atomindexArray[ count ] = atomindex[ q + Math.round(mu) ]\n\n vertexIndex[ _q ] = count\n ilist[ offset ] = count\n\n count += 1\n } else {\n ilist[ offset ] = vertexIndex[ _q ]\n }\n }\n\n function VIntY (q: number, offset: number, x: number, y: number, z: number, valp1: number, valp2: number) {\n var _q = 3 * q + 1\n\n if (vertexIndex[ _q ] < 0) {\n var mu = (isolevel - valp1) / (valp2 - valp1)\n var nc = normalCache\n\n var c = count * 3\n\n positionArray[ c ] = x\n positionArray[ c + 1 ] = y + mu\n positionArray[ c + 2 ] = z\n\n if (!noNormals) {\n var q3 = q * 3\n var q6 = q3 + yd * 3\n\n normalArray[ c ] = normalFactor * lerp(nc[ q3 ], nc[ q6 ], mu)\n normalArray[ c + 1 ] = normalFactor * lerp(nc[ q3 + 1 ], nc[ q6 + 1 ], mu)\n normalArray[ c + 2 ] = normalFactor * lerp(nc[ q3 + 2 ], nc[ q6 + 2 ], mu)\n }\n\n if (atomindex) atomindexArray[ count ] = atomindex[ q + Math.round(mu) * yd ]\n\n vertexIndex[ _q ] = count\n ilist[ offset ] = count\n\n count += 1\n } else {\n ilist[ offset ] = vertexIndex[ _q ]\n }\n }\n\n function VIntZ (q: number, offset: number, x: number, y: number, z: number, valp1: number, valp2: number) {\n var _q = 3 * q + 2\n\n if (vertexIndex[ _q ] < 0) {\n var mu = (isolevel - valp1) / (valp2 - valp1)\n var nc = normalCache\n\n var c = count * 3\n\n positionArray[ c ] = x\n positionArray[ c + 1 ] = y\n positionArray[ c + 2 ] = z + mu\n\n if (!noNormals) {\n var q3 = q * 3\n var q6 = q3 + zd * 3\n\n normalArray[ c ] = normalFactor * lerp(nc[ q3 ], nc[ q6 ], mu)\n normalArray[ c + 1 ] = normalFactor * lerp(nc[ q3 + 1 ], nc[ q6 + 1 ], mu)\n normalArray[ c + 2 ] = normalFactor * lerp(nc[ q3 + 2 ], nc[ q6 + 2 ], mu)\n }\n\n if (atomindex) atomindexArray[ count ] = atomindex[ q + Math.round(mu) * zd ]\n\n vertexIndex[ _q ] = count\n ilist[ offset ] = count\n\n count += 1\n } else {\n ilist[ offset ] = vertexIndex[ _q ]\n }\n }\n\n function compNorm (q: number) {\n var q3 = q * 3\n\n if (normalCache[ q3 ] === 0.0) {\n normalCache[ q3 ] = field[ (q - 1 + n) % n ] - field[ (q + 1) % n ]\n normalCache[ q3 + 1 ] = field[ (q - yd + n) % n ] - field[ (q + yd) % n ]\n normalCache[ q3 + 2 ] = field[ (q - zd + n) % n ] - field[ (q + zd) % n ]\n }\n }\n\n function polygonize (fx: number, fy: number, fz: number, q: number, edgeFilter: number) {\n // cache indices\n var q1\n var qy\n var qz\n var q1y\n var q1z\n var qyz\n var q1yz\n if (wrap) {\n q = index(fx, fy, fz)\n q1 = index(fx + 1, fy, fz)\n qy = index(fx, fy + 1, fz)\n qz = index(fx, fy, fz + 1)\n q1y = index(fx + 1, fy + 1, fz)\n q1z = index(fx + 1, fy, fz + 1)\n qyz = index(fx, fy + 1, fz + 1)\n q1yz = index(fx + 1, fy + 1, fz + 1)\n } else {\n q1 = q + 1\n qy = q + yd\n qz = q + zd\n q1y = qy + 1\n q1z = qz + 1\n qyz = qy + zd\n q1yz = qyz + 1\n }\n\n var cubeindex = 0\n var field0 = field[ q ]\n var field1 = field[ q1 ]\n var field2 = field[ qy ]\n var field3 = field[ q1y ]\n var field4 = field[ qz ]\n var field5 = field[ q1z ]\n var field6 = field[ qyz ]\n var field7 = field[ q1yz ]\n\n if (field0 < isolevel) cubeindex |= 1\n if (field1 < isolevel) cubeindex |= 2\n if (field2 < isolevel) cubeindex |= 8\n if (field3 < isolevel) cubeindex |= 4\n if (field4 < isolevel) cubeindex |= 16\n if (field5 < isolevel) cubeindex |= 32\n if (field6 < isolevel) cubeindex |= 128\n if (field7 < isolevel) cubeindex |= 64\n\n // if cube is entirely in/out of the surface - bail, nothing to draw\n\n var bits = edgeTable[ cubeindex ]\n if (bits === 0) return 0\n\n var fx2 = fx + 1\n var fy2 = fy + 1\n var fz2 = fz + 1\n\n // top of the cube\n\n if (bits & 1) {\n if (!noNormals) {\n compNorm(q)\n compNorm(q1)\n }\n VIntX(q, 0, fx, fy, fz, field0, field1)\n }\n\n if (bits & 2) {\n if (!noNormals) {\n compNorm(q1)\n compNorm(q1y)\n }\n VIntY(q1, 1, fx2, fy, fz, field1, field3)\n }\n\n if (bits & 4) {\n if (!noNormals) {\n compNorm(qy)\n compNorm(q1y)\n }\n VIntX(qy, 2, fx, fy2, fz, field2, field3)\n }\n\n if (bits & 8) {\n if (!noNormals) {\n compNorm(q)\n compNorm(qy)\n }\n VIntY(q, 3, fx, fy, fz, field0, field2)\n }\n\n // bottom of the cube\n\n if (bits & 16) {\n if (!noNormals) {\n compNorm(qz)\n compNorm(q1z)\n }\n VIntX(qz, 4, fx, fy, fz2, field4, field5)\n }\n\n if (bits & 32) {\n if (!noNormals) {\n compNorm(q1z)\n compNorm(q1yz)\n }\n VIntY(q1z, 5, fx2, fy, fz2, field5, field7)\n }\n\n if (bits & 64) {\n if (!noNormals) {\n compNorm(qyz)\n compNorm(q1yz)\n }\n VIntX(qyz, 6, fx, fy2, fz2, field6, field7)\n }\n\n if (bits & 128) {\n if (!noNormals) {\n compNorm(qz)\n compNorm(qyz)\n }\n VIntY(qz, 7, fx, fy, fz2, field4, field6)\n }\n\n // vertical lines of the cube\n\n if (bits & 256) {\n if (!noNormals) {\n compNorm(q)\n compNorm(qz)\n }\n VIntZ(q, 8, fx, fy, fz, field0, field4)\n }\n\n if (bits & 512) {\n if (!noNormals) {\n compNorm(q1)\n compNorm(q1z)\n }\n VIntZ(q1, 9, fx2, fy, fz, field1, field5)\n }\n\n if (bits & 1024) {\n if (!noNormals) {\n compNorm(q1y)\n compNorm(q1yz)\n }\n VIntZ(q1y, 10, fx2, fy2, fz, field3, field7)\n }\n\n if (bits & 2048) {\n if (!noNormals) {\n compNorm(qy)\n compNorm(qyz)\n }\n VIntZ(qy, 11, fx, fy2, fz, field2, field6)\n }\n\n var triIndex = cubeindex << 4 // re-purpose cubeindex into an offset into triTable\n\n var e1\n var e2\n var e3\n var i = 0\n\n // here is where triangles are created\n\n while (triTable[ triIndex + i ] !== -1) {\n e1 = triTable[ triIndex + i ]\n e2 = triTable[ triIndex + i + 1 ]\n e3 = triTable[ triIndex + i + 2 ]\n\n if (contour) {\n if (allowedContours[ e1 ][ e2 ] & edgeFilter) {\n indexArray[ icount++ ] = ilist[ e1 ]\n indexArray[ icount++ ] = ilist[ e2 ]\n }\n if (allowedContours[ e2 ][ e3 ] & edgeFilter) {\n indexArray[ icount++ ] = ilist[ e2 ]\n indexArray[ icount++ ] = ilist[ e3 ]\n }\n if (allowedContours[ e1 ][ e3 ] & edgeFilter) {\n indexArray[ icount++ ] = ilist[ e1 ]\n indexArray[ icount++ ] = ilist[ e3 ]\n }\n } else {\n indexArray[ icount++ ] = ilist[ isNegativeIso ? e1 : e2 ]\n indexArray[ icount++ ] = ilist[ isNegativeIso ? e2 : e1 ]\n indexArray[ icount++ ] = ilist[ e3 ]\n }\n\n i += 3\n }\n }\n\n function triangulate (xBeg?: number, yBeg?: number, zBeg?: number, xEnd?: number, yEnd?: number, zEnd?: number) {\n let q\n let q3\n let x\n let y\n let z\n let yOffset\n let zOffset\n\n xBeg = xBeg !== undefined ? xBeg : 0\n yBeg = yBeg !== undefined ? yBeg : 0\n zBeg = zBeg !== undefined ? zBeg : 0\n\n xEnd = xEnd !== undefined ? xEnd : nx - 1\n yEnd = yEnd !== undefined ? yEnd : ny - 1\n zEnd = zEnd !== undefined ? zEnd : nz - 1\n\n if (!wrap) {\n if (noNormals) {\n xBeg = Math.max(0, xBeg)\n yBeg = Math.max(0, yBeg)\n zBeg = Math.max(0, zBeg)\n\n xEnd = Math.min(nx - 1, xEnd)\n yEnd = Math.min(ny - 1, yEnd)\n zEnd = Math.min(nz - 1, zEnd)\n } else {\n xBeg = Math.max(1, xBeg)\n yBeg = Math.max(1, yBeg)\n zBeg = Math.max(1, zBeg)\n\n xEnd = Math.min(nx - 2, xEnd)\n yEnd = Math.min(ny - 2, yEnd)\n zEnd = Math.min(nz - 2, zEnd)\n }\n }\n\n let xBeg2, yBeg2, zBeg2, xEnd2, yEnd2, zEnd2\n\n if (!wrap) {\n // init part of the vertexIndex\n // (takes a significant amount of time to do for all)\n\n xBeg2 = Math.max(0, xBeg - 2)\n yBeg2 = Math.max(0, yBeg - 2)\n zBeg2 = Math.max(0, zBeg - 2)\n\n xEnd2 = Math.min(nx, xEnd + 2)\n yEnd2 = Math.min(ny, yEnd + 2)\n zEnd2 = Math.min(nz, zEnd + 2)\n\n for (z = zBeg2; z < zEnd2; ++z) {\n zOffset = zd * z\n for (y = yBeg2; y < yEnd2; ++y) {\n yOffset = zOffset + yd * y\n for (x = xBeg2; x < xEnd2; ++x) {\n q = 3 * (yOffset + x)\n vertexIndex[ q ] = -1\n vertexIndex[ q + 1 ] = -1\n vertexIndex[ q + 2 ] = -1\n }\n }\n }\n } else {\n xBeg2 = xBeg - 2\n yBeg2 = yBeg - 2\n zBeg2 = zBeg - 2\n\n xEnd2 = xEnd + 2\n yEnd2 = yEnd + 2\n zEnd2 = zEnd + 2\n\n for (z = zBeg2; z < zEnd2; ++z) {\n for (y = yBeg2; y < yEnd2; ++y) {\n for (x = xBeg2; x < xEnd2; ++x) {\n q3 = index(x, y, z) * 3\n vertexIndex[ q3 ] = -1\n vertexIndex[ q3 + 1 ] = -1\n vertexIndex[ q3 + 2 ] = -1\n }\n }\n }\n }\n\n if (!wrap) {\n // clip space where the isovalue is too low\n\n var __break\n var __xBeg = xBeg; var __yBeg = yBeg; var __zBeg = zBeg\n var __xEnd = xEnd; var __yEnd = yEnd; var __zEnd = zEnd\n\n __break = false\n for (z = zBeg; z < zEnd; ++z) {\n for (y = yBeg; y < yEnd; ++y) {\n for (x = xBeg; x < xEnd; ++x) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __zBeg = z\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (y = yBeg; y < yEnd; ++y) {\n for (z = __zBeg; z < zEnd; ++z) {\n for (x = xBeg; x < xEnd; ++x) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __yBeg = y\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (x = xBeg; x < xEnd; ++x) {\n for (y = __yBeg; y < yEnd; ++y) {\n for (z = __zBeg; z < zEnd; ++z) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __xBeg = x\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (z = zEnd; z >= zBeg; --z) {\n for (y = yEnd; y >= yBeg; --y) {\n for (x = xEnd; x >= xBeg; --x) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __zEnd = z\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (y = yEnd; y >= yBeg; --y) {\n for (z = __zEnd; z >= zBeg; --z) {\n for (x = xEnd; x >= xBeg; --x) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __yEnd = y\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (x = xEnd; x >= xBeg; --x) {\n for (y = __yEnd; y >= yBeg; --y) {\n for (z = __zEnd; z >= zBeg; --z) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __xEnd = x\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n //\n\n if (noNormals) {\n xBeg = Math.max(0, __xBeg - 1)\n yBeg = Math.max(0, __yBeg - 1)\n zBeg = Math.max(0, __zBeg - 1)\n\n xEnd = Math.min(nx - 1, __xEnd + 1)\n yEnd = Math.min(ny - 1, __yEnd + 1)\n zEnd = Math.min(nz - 1, __zEnd + 1)\n } else {\n xBeg = Math.max(1, __xBeg - 1)\n yBeg = Math.max(1, __yBeg - 1)\n zBeg = Math.max(1, __zBeg - 1)\n\n xEnd = Math.min(nx - 2, __xEnd + 1)\n yEnd = Math.min(ny - 2, __yEnd + 1)\n zEnd = Math.min(nz - 2, __zEnd + 1)\n }\n }\n\n // polygonize part of the grid\n var edgeFilter = 15\n for (z = zBeg; z < zEnd; ++z, edgeFilter &= ~4) {\n zOffset = zd * z\n edgeFilter |= 2\n for (y = yBeg; y < yEnd; ++y, edgeFilter &= ~2) {\n yOffset = zOffset + yd * y\n edgeFilter |= 1\n for (x = xBeg; x < xEnd; ++x, edgeFilter &= ~1) {\n q = yOffset + x\n polygonize(x, y, z, q, edgeFilter)\n }\n }\n }\n }\n}\nObject.assign(MarchingCubes, {__deps: [ getEdgeTable, getTriTable, getUintArray ]})\n\nexport default MarchingCubes\n","/**\n * @file Matrix Utils\n * @private\n * @author Alexander Rose \n *\n * svd methods from Eugene Zatepyakin / http://inspirit.github.io/jsfeat/\n */\n\nimport { NumberArray } from '../types'\nimport { v3new, v3cross } from './vector-utils'\n\nexport class Matrix {\n size: number\n data: Float32Array\n\n constructor (readonly cols: number, readonly rows: number) {\n this.size = this.cols * this.rows\n this.data = new Float32Array(this.size)\n }\n\n copyTo (matrix: Matrix) {\n matrix.data.set(this.data)\n }\n}\n\nexport function transpose (At: Matrix, A: Matrix) {\n let i = 0\n let j = 0\n const nrows = A.rows\n const ncols = A.cols\n let Ai = 0\n let Ati = 0\n let pAt = 0\n const ad = A.data\n const atd = At.data\n\n for (; i < nrows; Ati += 1, Ai += ncols, i++) {\n pAt = Ati\n for (j = 0; j < ncols; pAt += nrows, j++) atd[pAt] = ad[Ai + j]\n }\n}\n\n// C = A * B\nexport function multiply (C: Matrix, A: Matrix, B: Matrix) {\n let i = 0\n let j = 0\n let k = 0\n let Ap = 0\n let pA = 0\n let pB = 0\n let _pB = 0\n let Cp = 0\n const ncols = A.cols\n const nrows = A.rows\n const mcols = B.cols\n const ad = A.data\n const bd = B.data\n const cd = C.data\n let sum = 0.0\n\n for (; i < nrows; Ap += ncols, i++) {\n for (_pB = 0, j = 0; j < mcols; Cp++, _pB++, j++) {\n pB = _pB\n pA = Ap\n sum = 0.0\n for (k = 0; k < ncols; pA++, pB += mcols, k++) {\n sum += ad[pA] * bd[pB]\n }\n cd[Cp] = sum\n }\n }\n}\n\n// C = A * B'\nexport function multiplyABt (C: Matrix, A: Matrix, B: Matrix) {\n let i = 0\n let j = 0\n let k = 0\n let Ap = 0\n let pA = 0\n let pB = 0\n let Cp = 0\n const ncols = A.cols\n const nrows = A.rows\n const mrows = B.rows\n const ad = A.data\n const bd = B.data\n const cd = C.data\n let sum = 0.0\n\n for (; i < nrows; Ap += ncols, i++) {\n for (pB = 0, j = 0; j < mrows; Cp++, j++) {\n pA = Ap\n sum = 0.0\n for (k = 0; k < ncols; pA++, pB++, k++) {\n sum += ad[pA] * bd[pB]\n }\n cd[Cp] = sum\n }\n }\n}\n\n// C = A' * B\nexport function multiplyAtB (C: Matrix, A: Matrix, B: Matrix) {\n let i = 0\n let j = 0\n let k = 0\n let Ap = 0\n let pA = 0\n let pB = 0\n let _pB = 0\n let Cp = 0\n const ncols = A.cols\n const nrows = A.rows\n const mcols = B.cols\n const ad = A.data\n const bd = B.data\n const cd = C.data\n let sum = 0.0\n\n for (; i < ncols; Ap++, i++) {\n for (_pB = 0, j = 0; j < mcols; Cp++, _pB++, j++) {\n pB = _pB\n pA = Ap\n sum = 0.0\n for (k = 0; k < nrows; pA += ncols, pB += mcols, k++) {\n sum += ad[pA] * bd[pB]\n }\n cd[Cp] = sum\n }\n }\n}\n\nexport function invert3x3 (from: Matrix, to: Matrix) {\n const A = from.data\n const invA = to.data\n const t1 = A[4]\n const t2 = A[8]\n const t4 = A[5]\n const t5 = A[7]\n const t8 = A[0]\n\n const t9 = t8 * t1\n const t11 = t8 * t4\n const t13 = A[3]\n const t14 = A[1]\n const t15 = t13 * t14\n const t17 = A[2]\n const t18 = t13 * t17\n const t20 = A[6]\n const t21 = t20 * t14\n const t23 = t20 * t17\n const t26 = 1.0 / (t9 * t2 - t11 * t5 - t15 * t2 + t18 * t5 + t21 * t4 - t23 * t1)\n invA[0] = (t1 * t2 - t4 * t5) * t26\n invA[1] = -(t14 * t2 - t17 * t5) * t26\n invA[2] = -(-t14 * t4 + t17 * t1) * t26\n invA[3] = -(t13 * t2 - t4 * t20) * t26\n invA[4] = (t8 * t2 - t23) * t26\n invA[5] = -(t11 - t18) * t26\n invA[6] = -(-t13 * t5 + t1 * t20) * t26\n invA[7] = -(t8 * t5 - t21) * t26\n invA[8] = (t9 - t15) * t26\n}\n\nexport function mat3x3determinant (M: Matrix) {\n const md = M.data\n return md[0] * md[4] * md[8] -\n md[0] * md[5] * md[7] -\n md[3] * md[1] * md[8] +\n md[3] * md[2] * md[7] +\n md[6] * md[1] * md[5] -\n md[6] * md[2] * md[4]\n}\n\n// C = A * B\nexport function multiply3x3 (C: Matrix, A: Matrix, B: Matrix) {\n const Cd = C.data\n const Ad = A.data\n const Bd = B.data\n const m10 = Ad[0]\n const m11 = Ad[1]\n const m12 = Ad[2]\n const m13 = Ad[3]\n const m14 = Ad[4]\n const m15 = Ad[5]\n const m16 = Ad[6]\n const m17 = Ad[7]\n const m18 = Ad[8]\n\n const m20 = Bd[0]\n const m21 = Bd[1]\n const m22 = Bd[2]\n const m23 = Bd[3]\n const m24 = Bd[4]\n const m25 = Bd[5]\n const m26 = Bd[6]\n const m27 = Bd[7]\n const m28 = Bd[8]\n\n Cd[0] = m10 * m20 + m11 * m23 + m12 * m26\n Cd[1] = m10 * m21 + m11 * m24 + m12 * m27\n Cd[2] = m10 * m22 + m11 * m25 + m12 * m28\n Cd[3] = m13 * m20 + m14 * m23 + m15 * m26\n Cd[4] = m13 * m21 + m14 * m24 + m15 * m27\n Cd[5] = m13 * m22 + m14 * m25 + m15 * m28\n Cd[6] = m16 * m20 + m17 * m23 + m18 * m26\n Cd[7] = m16 * m21 + m17 * m24 + m18 * m27\n Cd[8] = m16 * m22 + m17 * m25 + m18 * m28\n}\n\nexport function meanRows (A: Matrix) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n const mean = new Array(ncols)\n\n for (let j = 0; j < ncols; ++j) {\n mean[ j ] = 0.0\n }\n\n for (let i = 0, p = 0; i < nrows; ++i) {\n for (let j = 0; j < ncols; ++j, ++p) {\n mean[ j ] += Ad[ p ]\n }\n }\n\n for (let j = 0; j < ncols; ++j) {\n mean[ j ] /= nrows\n }\n\n return mean\n}\n\nexport function meanCols (A: Matrix) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n const mean = new Array(nrows)\n\n for (let j = 0; j < nrows; ++j) {\n mean[ j ] = 0.0\n }\n\n for (let i = 0, p = 0; i < ncols; ++i) {\n for (let j = 0; j < nrows; ++j, ++p) {\n mean[ j ] += Ad[ p ]\n }\n }\n\n for (let j = 0; j < nrows; ++j) {\n mean[ j ] /= ncols\n }\n\n return mean\n}\n\nexport function subRows (A: Matrix, row: number[]) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n\n for (let i = 0, p = 0; i < nrows; ++i) {\n for (let j = 0; j < ncols; ++j, ++p) {\n Ad[ p ] -= row[ j ]\n }\n }\n}\n\nexport function subCols (A: Matrix, col: number[]) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n\n for (let i = 0, p = 0; i < ncols; ++i) {\n for (let j = 0; j < nrows; ++j, ++p) {\n Ad[ p ] -= col[ j ]\n }\n }\n}\n\nexport function addRows (A: Matrix, row: number[]) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n\n for (let i = 0, p = 0; i < nrows; ++i) {\n for (let j = 0; j < ncols; ++j, ++p) {\n Ad[ p ] += row[ j ]\n }\n }\n}\n\nexport function addCols (A: Matrix, col: number[]) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n\n for (let i = 0, p = 0; i < ncols; ++i) {\n for (let j = 0; j < nrows; ++j, ++p) {\n Ad[ p ] += col[ j ]\n }\n }\n}\n\nexport function swap (A: NumberArray, i0: number, i1: number, t: number) {\n t = A[i0]\n A[i0] = A[i1]\n A[i1] = t\n}\n\nexport function hypot (a: number, b: number) {\n a = Math.abs(a)\n b = Math.abs(b)\n if (a > b) {\n b /= a\n return a * Math.sqrt(1.0 + b * b)\n }\n if (b > 0) {\n a /= b\n return b * Math.sqrt(1.0 + a * a)\n }\n return 0.0\n}\n\nconst EPSILON = 0.0000001192092896\nconst FLT_MIN = 1E-37\n\nexport function JacobiSVDImpl (At: NumberArray, astep: number, _W: NumberArray, Vt: NumberArray, vstep: number, m: number, n: number, n1: number) {\n const eps = EPSILON * 2.0\n const minval = FLT_MIN\n let i = 0\n let j = 0\n let k = 0\n let iter = 0\n const maxIter = Math.max(m, 30)\n let Ai = 0\n let Aj = 0\n let Vi = 0\n let Vj = 0\n let changed = 0\n let c = 0.0\n let s = 0.0\n let t = 0.0\n let t0 = 0.0\n let t1 = 0.0\n let sd = 0.0\n let beta = 0.0\n let gamma = 0.0\n let delta = 0.0\n let a = 0.0\n let p = 0.0\n let b = 0.0\n let seed = 0x1234\n let val = 0.0\n let val0 = 0.0\n let asum = 0.0\n\n const W = new Float64Array(n << 3)\n\n for (; i < n; i++) {\n for (k = 0, sd = 0; k < m; k++) {\n t = At[i * astep + k]\n sd += t * t\n }\n W[i] = sd\n\n if (Vt) {\n for (k = 0; k < n; k++) {\n Vt[i * vstep + k] = 0\n }\n Vt[i * vstep + i] = 1\n }\n }\n\n for (; iter < maxIter; iter++) {\n changed = 0\n\n for (i = 0; i < n - 1; i++) {\n for (j = i + 1; j < n; j++) {\n Ai = (i * astep) | 0\n Aj = (j * astep) | 0\n a = W[i]\n p = 0\n b = W[j]\n\n k = 2\n p += At[Ai] * At[Aj]\n p += At[Ai + 1] * At[Aj + 1]\n\n for (; k < m; k++) { p += At[Ai + k] * At[Aj + k] }\n\n if (Math.abs(p) <= eps * Math.sqrt(a * b)) continue\n\n p *= 2.0\n beta = a - b\n gamma = hypot(p, beta)\n if (beta < 0) {\n delta = (gamma - beta) * 0.5\n s = Math.sqrt(delta / gamma)\n c = (p / (gamma * s * 2.0))\n } else {\n c = Math.sqrt((gamma + beta) / (gamma * 2.0))\n s = (p / (gamma * c * 2.0))\n }\n\n a = 0.0\n b = 0.0\n\n k = 2 // unroll\n t0 = c * At[Ai] + s * At[Aj]\n t1 = -s * At[Ai] + c * At[Aj]\n At[Ai] = t0; At[Aj] = t1\n a += t0 * t0; b += t1 * t1\n\n t0 = c * At[Ai + 1] + s * At[Aj + 1]\n t1 = -s * At[Ai + 1] + c * At[Aj + 1]\n At[Ai + 1] = t0; At[Aj + 1] = t1\n a += t0 * t0; b += t1 * t1\n\n for (; k < m; k++) {\n t0 = c * At[Ai + k] + s * At[Aj + k]\n t1 = -s * At[Ai + k] + c * At[Aj + k]\n At[Ai + k] = t0; At[Aj + k] = t1\n\n a += t0 * t0; b += t1 * t1\n }\n\n W[i] = a\n W[j] = b\n\n changed = 1\n\n if (Vt) {\n Vi = (i * vstep) | 0\n Vj = (j * vstep) | 0\n\n k = 2\n t0 = c * Vt[Vi] + s * Vt[Vj]\n t1 = -s * Vt[Vi] + c * Vt[Vj]\n Vt[Vi] = t0; Vt[Vj] = t1\n\n t0 = c * Vt[Vi + 1] + s * Vt[Vj + 1]\n t1 = -s * Vt[Vi + 1] + c * Vt[Vj + 1]\n Vt[Vi + 1] = t0; Vt[Vj + 1] = t1\n\n for (; k < n; k++) {\n t0 = c * Vt[Vi + k] + s * Vt[Vj + k]\n t1 = -s * Vt[Vi + k] + c * Vt[Vj + k]\n Vt[Vi + k] = t0; Vt[Vj + k] = t1\n }\n }\n }\n }\n if (changed === 0) break\n }\n\n for (i = 0; i < n; i++) {\n for (k = 0, sd = 0; k < m; k++) {\n t = At[i * astep + k]\n sd += t * t\n }\n W[i] = Math.sqrt(sd)\n }\n\n for (i = 0; i < n - 1; i++) {\n j = i\n for (k = i + 1; k < n; k++) {\n if (W[j] < W[k]) { j = k }\n }\n if (i !== j) {\n swap(W, i, j, sd)\n if (Vt) {\n for (k = 0; k < m; k++) {\n swap(At, i * astep + k, j * astep + k, t)\n }\n\n for (k = 0; k < n; k++) {\n swap(Vt, i * vstep + k, j * vstep + k, t)\n }\n }\n }\n }\n\n for (i = 0; i < n; i++) {\n _W[i] = W[i]\n }\n\n if (!Vt) {\n return\n }\n\n for (i = 0; i < n1; i++) {\n sd = i < n ? W[i] : 0\n\n while (sd <= minval) {\n // if we got a zero singular value, then in order to get the corresponding left singular vector\n // we generate a random vector, project it to the previously computed left singular vectors,\n // subtract the projection and normalize the difference.\n val0 = (1.0 / m)\n for (k = 0; k < m; k++) {\n seed = (seed * 214013 + 2531011)\n val = (((seed >> 16) & 0x7fff) & 256) !== 0 ? val0 : -val0\n At[i * astep + k] = val\n }\n for (iter = 0; iter < 2; iter++) {\n for (j = 0; j < i; j++) {\n sd = 0\n for (k = 0; k < m; k++) {\n sd += At[i * astep + k] * At[j * astep + k]\n }\n asum = 0.0\n for (k = 0; k < m; k++) {\n t = (At[i * astep + k] - sd * At[j * astep + k])\n At[i * astep + k] = t\n asum += Math.abs(t)\n }\n asum = asum ? 1.0 / asum : 0\n for (k = 0; k < m; k++) {\n At[i * astep + k] *= asum\n }\n }\n }\n sd = 0\n for (k = 0; k < m; k++) {\n t = At[i * astep + k]\n sd += t * t\n }\n sd = Math.sqrt(sd)\n }\n\n s = (1.0 / sd)\n for (k = 0; k < m; k++) {\n At[i * astep + k] *= s\n }\n }\n}\n\nexport function svd (A: Matrix, W: Matrix, U: Matrix, V: Matrix) {\n let at = 0\n let i = 0\n const _m = A.rows\n const _n = A.cols\n let m = _m\n let n = _n\n\n if (m < n) {\n at = 1\n i = m\n m = n\n n = i\n }\n\n const amt = new Matrix(m, m)\n const wmt = new Matrix(1, n)\n const vmt = new Matrix(n, n)\n\n if (at === 0) {\n transpose(amt, A)\n } else {\n for (i = 0; i < _n * _m; i++) {\n amt.data[i] = A.data[i]\n }\n for (; i < n * m; i++) {\n amt.data[i] = 0\n }\n }\n\n JacobiSVDImpl(amt.data, m, wmt.data, vmt.data, n, m, n, m)\n\n if (W) {\n for (i = 0; i < n; i++) {\n W.data[i] = wmt.data[i]\n }\n for (; i < _n; i++) {\n W.data[i] = 0\n }\n }\n\n if (at === 0) {\n if (U) transpose(U, amt)\n if (V) transpose(V, vmt)\n } else {\n if (U) transpose(U, vmt)\n if (V) transpose(V, amt)\n }\n}\n\n//\n\nexport function m4new () {\n return new Float32Array([\n 1, 0, 0, 0,\n 0, 1, 0, 0,\n 0, 0, 1, 0,\n 0, 0, 0, 1\n ])\n}\n\nexport function m4set (out: Float32Array, n11: number, n12: number, n13: number, n14: number, n21: number, n22: number, n23: number, n24: number, n31: number, n32: number, n33: number, n34: number, n41: number, n42: number, n43: number, n44: number) {\n out[ 0 ] = n11; out[ 4 ] = n12; out[ 8 ] = n13; out[ 12 ] = n14\n out[ 1 ] = n21; out[ 5 ] = n22; out[ 9 ] = n23; out[ 13 ] = n24\n out[ 2 ] = n31; out[ 6 ] = n32; out[ 10 ] = n33; out[ 14 ] = n34\n out[ 3 ] = n41; out[ 7 ] = n42; out[ 11 ] = n43; out[ 15 ] = n44\n}\n\nexport function m4identity (out: Float32Array) {\n m4set(out,\n 1, 0, 0, 0,\n 0, 1, 0, 0,\n 0, 0, 1, 0,\n 0, 0, 0, 1\n )\n}\n(m4identity as any).__deps = [ m4set ]\n\nexport function m4multiply (out: Float32Array, a: Float32Array, b: Float32Array) {\n const a11 = a[ 0 ]\n const a12 = a[ 4 ]\n const a13 = a[ 8 ]\n const a14 = a[ 12 ]\n const a21 = a[ 1 ]\n const a22 = a[ 5 ]\n const a23 = a[ 9 ]\n const a24 = a[ 13 ]\n const a31 = a[ 2 ]\n const a32 = a[ 6 ]\n const a33 = a[ 10 ]\n const a34 = a[ 14 ]\n const a41 = a[ 3 ]\n const a42 = a[ 7 ]\n const a43 = a[ 11 ]\n const a44 = a[ 15 ]\n\n const b11 = b[ 0 ]\n const b12 = b[ 4 ]\n const b13 = b[ 8 ]\n const b14 = b[ 12 ]\n const b21 = b[ 1 ]\n const b22 = b[ 5 ]\n const b23 = b[ 9 ]\n const b24 = b[ 13 ]\n const b31 = b[ 2 ]\n const b32 = b[ 6 ]\n const b33 = b[ 10 ]\n const b34 = b[ 14 ]\n const b41 = b[ 3 ]\n const b42 = b[ 7 ]\n const b43 = b[ 11 ]\n const b44 = b[ 15 ]\n\n out[ 0 ] = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41\n out[ 4 ] = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42\n out[ 8 ] = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43\n out[ 12 ] = a11 * b14 + a12 * b24 + a13 * b34 + a14 * b44\n\n out[ 1 ] = a21 * b11 + a22 * b21 + a23 * b31 + a24 * b41\n out[ 5 ] = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42\n out[ 9 ] = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43\n out[ 13 ] = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44\n\n out[ 2 ] = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41\n out[ 6 ] = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42\n out[ 10 ] = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43\n out[ 14 ] = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44\n\n out[ 3 ] = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41\n out[ 7 ] = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42\n out[ 11 ] = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43\n out[ 15 ] = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44\n}\n\nexport function m4makeScale (out: Float32Array, x: number, y: number, z: number) {\n m4set(out,\n x, 0, 0, 0,\n 0, y, 0, 0,\n 0, 0, z, 0,\n 0, 0, 0, 1\n )\n}\n(m4makeScale as any).__deps = [ m4set ]\n\nexport function m4makeTranslation (out: Float32Array, x: number, y: number, z: number) {\n m4set(out,\n 1, 0, 0, x,\n 0, 1, 0, y,\n 0, 0, 1, z,\n 0, 0, 0, 1\n )\n}\n(m4makeTranslation as any).__deps = [ m4set ]\n\nexport function m4makeRotationY (out: Float32Array, theta: number) {\n const c = Math.cos(theta)\n const s = Math.sin(theta)\n m4set(out,\n c, 0, s, 0,\n 0, 1, 0, 0,\n -s, 0, c, 0,\n 0, 0, 0, 1\n )\n}\n(m4makeRotationY as any).__deps = [ m4set ]\n\n//\n\nexport function m3new () {\n return new Float32Array([\n 1, 0, 0,\n 0, 1, 0,\n 0, 0, 1\n ])\n}\n\nexport function m3makeNormal (out: Float32Array, m4: Float32Array) {\n const r0 = v3new([ m4[0], m4[1], m4[2] ])\n const r1 = v3new([ m4[4], m4[5], m4[6] ])\n const r2 = v3new([ m4[8], m4[9], m4[10] ])\n const cp = v3new()\n // [ r0 ] [ r1 x r2 ]\n // M3x3 = [ r1 ] N = [ r2 x r0 ]\n // [ r2 ] [ r0 x r1 ]\n v3cross(cp, r1, r2)\n out[ 0 ] = cp[ 0 ]\n out[ 1 ] = cp[ 1 ]\n out[ 2 ] = cp[ 2 ]\n v3cross(cp, r2, r0)\n out[ 3 ] = cp[ 0 ]\n out[ 4 ] = cp[ 1 ]\n out[ 5 ] = cp[ 2 ]\n v3cross(cp, r0, r1)\n out[ 6 ] = cp[ 0 ]\n out[ 7 ] = cp[ 1 ]\n out[ 8 ] = cp[ 2 ]\n}\n(m3makeNormal as any).__deps = [ v3new, v3cross ]\n","/**\n * @file Surface Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { degToRad } from '../math/math-utils'\nimport {\n m4new, m4multiply, m4makeTranslation, m4makeScale, m4makeRotationY\n} from '../math/matrix-utils'\nimport {\n v3addScalar, v3subScalar, v3divideScalar, v3multiplyScalar,\n v3floor, v3ceil, v3sub, v3negate,\n v3cross, v3fromArray, normalizeVector3array\n} from '../math/vector-utils'\nimport { NumberArray } from '../types'\n\nfunction laplacianSmooth (verts: Float32Array, faces: Float32Array, numiter: number, inflate: boolean) {\n // based on D. Xu, Y. Zhang (2009) Generating Triangulated Macromolecular\n // Surfaces by Euclidean Distance Transform. PLoS ONE 4(12): e8140.\n //\n // Permission to use, copy, modify, and distribute this program for\n // any purpose, with or without fee, is hereby granted, provided that\n // the notices on the head, the reference information, and this\n // copyright notice appear in all copies or substantial portions of\n // the Software. It is provided \"as is\" without express or implied\n // warranty.\n //\n // ported to JavaScript and adapted to NGL by Alexander Rose\n\n numiter = numiter || 1\n inflate = inflate || true\n\n const nv = verts.length / 3\n const nf = faces.length / 3\n let norms: Float32Array | undefined = undefined\n\n if (inflate) {\n norms = new Float32Array(nv * 3)\n }\n\n const tps = new Float32Array(nv * 3)\n\n let i\n const ndeg = 20\n const vertdeg = new Array(ndeg)\n\n for (i = 0; i < ndeg; ++i) {\n vertdeg[ i ] = new Uint32Array(nv)\n }\n\n for (i = 0; i < nv; ++i) {\n vertdeg[ 0 ][ i ] = 0\n }\n\n let j, jl\n let flagvert: boolean\n\n // for each face\n\n for (i = 0; i < nf; ++i) {\n var ao = i * 3\n var bo = i * 3 + 1\n var co = i * 3 + 2\n\n // vertex a\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ao] ]; j < jl; ++j) {\n if (faces[ bo ] === vertdeg[ j + 1 ][ faces[ ao ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ ao ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ ao ] ] ][ faces[ ao ] ] = faces[ bo ]\n }\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ ao ] ]; j < jl; ++j) {\n if (faces[ co ] === vertdeg[ j + 1 ][ faces[ ao ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ ao ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ ao ] ] ][ faces[ ao ] ] = faces[ co ]\n }\n\n // vertex b\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ bo ] ]; j < jl; ++j) {\n if (faces[ ao ] === vertdeg[ j + 1 ][ faces[ bo ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ bo ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ bo ] ] ][ faces[ bo ] ] = faces[ ao ]\n }\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ bo ] ]; j < jl; ++j) {\n if (faces[ co ] === vertdeg[ j + 1 ][ faces[ bo ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ bo ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ bo ] ] ][ faces[ bo ] ] = faces[ co ]\n }\n\n // vertex c\n\n flagvert = true\n for (j = 0; j < vertdeg[ 0 ][ faces[ co ] ]; ++j) {\n if (faces[ ao ] === vertdeg[ j + 1 ][ faces[ co ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ co ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ co ] ] ][ faces[ co ] ] = faces[ ao ]\n }\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ co ] ]; j < jl; ++j) {\n if (faces[ bo ] === vertdeg[ j + 1 ][ faces[ co ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ co ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ co ] ] ][ faces[ co ] ] = faces[ bo ]\n }\n }\n\n var wt = 1.0\n var wt2 = 0.5\n var i3, vi3, vdi, wtvi, wt2vi\n var ssign = -1\n var scaleFactor = 1\n var outwt = 0.75 / (scaleFactor + 3.5) // area-preserving\n\n // smoothing iterations\n\n for (var k = 0; k < numiter; ++k) {\n // for each vertex\n\n for (i = 0; i < nv; ++i) {\n i3 = i * 3\n vdi = vertdeg[ 0 ][ i ]\n\n if (vdi < 3) {\n tps[ i3 ] = verts[ i3 ]\n tps[ i3 + 1 ] = verts[ i3 + 1 ]\n tps[ i3 + 2 ] = verts[ i3 + 2 ]\n } else if (vdi === 3 || vdi === 4) {\n tps[ i3 ] = 0\n tps[ i3 + 1 ] = 0\n tps[ i3 + 2 ] = 0\n\n for (j = 0; j < vdi; ++j) {\n vi3 = vertdeg[ j + 1 ][ i ] * 3\n tps[ i3 ] += verts[ vi3 ]\n tps[ i3 + 1 ] += verts[ vi3 + 1 ]\n tps[ i3 + 2 ] += verts[ vi3 + 2 ]\n }\n\n tps[ i3 ] += wt2 * verts[ i3 ]\n tps[ i3 + 1 ] += wt2 * verts[ i3 + 1 ]\n tps[ i3 + 2 ] += wt2 * verts[ i3 + 2 ]\n\n wt2vi = wt2 + vdi\n tps[ i3 ] /= wt2vi\n tps[ i3 + 1 ] /= wt2vi\n tps[ i3 + 2 ] /= wt2vi\n } else {\n tps[ i3 ] = 0\n tps[ i3 + 1 ] = 0\n tps[ i3 + 2 ] = 0\n\n for (j = 0; j < vdi; ++j) {\n vi3 = vertdeg[ j + 1 ][ i ] * 3\n tps[ i3 ] += verts[ vi3 ]\n tps[ i3 + 1 ] += verts[ vi3 + 1 ]\n tps[ i3 + 2 ] += verts[ vi3 + 2 ]\n }\n\n tps[ i3 ] += wt * verts[ i3 ]\n tps[ i3 + 1 ] += wt * verts[ i3 + 1 ]\n tps[ i3 + 2 ] += wt * verts[ i3 + 2 ]\n\n wtvi = wt + vdi\n tps[ i3 ] /= wtvi\n tps[ i3 + 1 ] /= wtvi\n tps[ i3 + 2 ] /= wtvi\n }\n }\n\n verts.set(tps) // copy smoothed positions\n\n if (inflate) {\n computeVertexNormals(verts, faces, norms)\n var nv3 = nv * 3\n\n for (i3 = 0; i3 < nv3; i3 += 3) {\n // if(verts[i].inout) ssign=1;\n // else ssign=-1;\n\n verts[ i3 ] += ssign * outwt * norms![ i3 ]\n verts[ i3 + 1 ] += ssign * outwt * norms![ i3 + 1 ]\n verts[ i3 + 2 ] += ssign * outwt * norms![ i3 + 2 ]\n }\n }\n }\n}\nObject.assign(laplacianSmooth, {__deps: [ computeVertexNormals ]})\n\nfunction computeVertexNormals (position: Float32Array, index?: NumberArray, normal?: Float32Array) {\n var i, il\n\n if (normal === undefined) {\n normal = new Float32Array(position.length)\n } else {\n // reset existing normals to zero\n for (i = 0, il = normal.length; i < il; i++) {\n normal[ i ] = 0\n }\n }\n\n var a = new Float32Array(3)\n var b = new Float32Array(3)\n var c = new Float32Array(3)\n var cb = new Float32Array(3)\n var ab = new Float32Array(3)\n\n if (index) {\n // indexed elements\n for (i = 0, il = index.length; i < il; i += 3) {\n var ai = index[ i ] * 3\n var bi = index[ i + 1 ] * 3\n var ci = index[ i + 2 ] * 3\n\n v3fromArray(a, position, ai)\n v3fromArray(b, position, bi)\n v3fromArray(c, position, ci)\n\n v3sub(cb, c, b)\n v3sub(ab, a, b)\n v3cross(cb, cb, ab)\n\n normal[ ai ] += cb[ 0 ]\n normal[ ai + 1 ] += cb[ 1 ]\n normal[ ai + 2 ] += cb[ 2 ]\n\n normal[ bi ] += cb[ 0 ]\n normal[ bi + 1 ] += cb[ 1 ]\n normal[ bi + 2 ] += cb[ 2 ]\n\n normal[ ci ] += cb[ 0 ]\n normal[ ci + 1 ] += cb[ 1 ]\n normal[ ci + 2 ] += cb[ 2 ]\n }\n } else {\n // non-indexed elements (unconnected triangle soup)\n for (i = 0, il = position.length; i < il; i += 9) {\n v3fromArray(a, position, i)\n v3fromArray(b, position, i + 3)\n v3fromArray(c, position, i + 6)\n\n v3sub(cb, c, b)\n v3sub(ab, a, b)\n v3cross(cb, cb, ab)\n\n normal[ i ] = cb[ 0 ]\n normal[ i + 1 ] = cb[ 1 ]\n normal[ i + 2 ] = cb[ 2 ]\n\n normal[ i + 3 ] = cb[ 0 ]\n normal[ i + 4 ] = cb[ 1 ]\n normal[ i + 5 ] = cb[ 2 ]\n\n normal[ i + 6 ] = cb[ 0 ]\n normal[ i + 7 ] = cb[ 1 ]\n normal[ i + 8 ] = cb[ 2 ]\n }\n }\n\n normalizeVector3array(normal)\n\n return normal\n}\nObject.assign(computeVertexNormals, {__deps: [\n v3sub, v3cross, v3fromArray, normalizeVector3array\n]})\n\nfunction getRadiusDict (radiusList: number[]) {\n var radiusDict: {[k: number]: boolean} = {}\n for (var i = 0, il = radiusList.length; i < il; ++i) {\n radiusDict[ radiusList[ i ] ] = true\n }\n return radiusDict\n}\n\nfunction getSurfaceGrid (min: Float32Array, max: Float32Array, maxRadius: number, scaleFactor: number, extraMargin: number) {\n // need margin to avoid boundary/round off effects\n var margin = (1 / scaleFactor) * 3\n margin += maxRadius\n\n v3subScalar(min, min, extraMargin + margin)\n v3addScalar(max, max, extraMargin + margin)\n\n v3multiplyScalar(min, min, scaleFactor)\n v3floor(min, min)\n v3divideScalar(min, min, scaleFactor)\n\n v3multiplyScalar(max, max, scaleFactor)\n v3ceil(max, max)\n v3divideScalar(max, max, scaleFactor)\n\n var dim = new Float32Array(3)\n v3sub(dim, max, min)\n v3multiplyScalar(dim, dim, scaleFactor)\n v3ceil(dim, dim)\n v3addScalar(dim, dim, 1)\n\n var maxSize = Math.pow(10, 6) * 256\n var tmpSize = dim[ 0 ] * dim[ 1 ] * dim[ 2 ] * 3\n\n if (maxSize <= tmpSize) {\n scaleFactor *= Math.pow(maxSize / tmpSize, 1 / 3)\n\n v3multiplyScalar(min, min, scaleFactor)\n v3floor(min, min)\n v3divideScalar(min, min, scaleFactor)\n\n v3multiplyScalar(max, max, scaleFactor)\n v3ceil(max, max)\n v3divideScalar(max, max, scaleFactor)\n\n v3sub(dim, max, min)\n v3multiplyScalar(dim, dim, scaleFactor)\n v3ceil(dim, dim)\n v3addScalar(dim, dim, 1)\n }\n\n var tran = new Float32Array(min)\n v3negate(tran, tran)\n\n // coordinate transformation matrix\n var matrix = m4new()\n var mroty = m4new()\n m4makeRotationY(mroty, degToRad(90))\n m4multiply(matrix, matrix, mroty)\n\n var mscale = m4new()\n m4makeScale(\n mscale,\n -1 / scaleFactor,\n 1 / scaleFactor,\n 1 / scaleFactor\n )\n m4multiply(matrix, matrix, mscale)\n\n var mtrans = m4new()\n m4makeTranslation(\n mtrans,\n -scaleFactor * tran[2],\n -scaleFactor * tran[1],\n -scaleFactor * tran[0]\n )\n m4multiply(matrix, matrix, mtrans)\n\n return {\n dim: dim,\n tran: tran,\n matrix: matrix,\n scaleFactor: scaleFactor\n }\n}\nObject.assign(getSurfaceGrid, {__deps: [\n degToRad,\n v3subScalar, v3addScalar, v3divideScalar, v3multiplyScalar,\n v3floor, v3ceil, v3sub, v3negate,\n m4new, m4multiply, m4makeTranslation, m4makeScale, m4makeRotationY\n]})\n\nexport {\n laplacianSmooth,\n computeVertexNormals,\n getRadiusDict,\n getSurfaceGrid\n}\n","/**\n * @file Surface\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3, Geometry, BufferGeometry, Group, Color } from 'three'\n\nimport { Debug, Log, ColormakerRegistry } from '../globals'\nimport { getUintArray } from '../utils'\nimport { AtomPicker, SurfacePicker } from '../utils/picker'\nimport { uniformArray, uniformArray3, serialArray } from '../math/array-utils'\nimport Selection from '../selection/selection'\nimport { ColormakerParameters } from '../color/colormaker';\nimport { Structure, Volume } from '../ngl';\n\nexport interface SurfaceData {\n position: Float32Array\n index: Uint32Array|Uint16Array|undefined\n normal: Float32Array\n color: Float32Array\n atomindex: Int32Array\n contour: boolean\n}\n/**\n * Surface\n */\nclass Surface {\n name: string\n path: string\n position: Float32Array\n index: Uint32Array|Uint16Array|undefined\n normal: Float32Array|undefined\n color: Float32Array|undefined\n atomindex: Int32Array|undefined\n contour: boolean\n center: Vector3\n boundingBox: Box3\n size: number\n info: {\n type?: string\n probeRadius?: number\n scaleFactor?: number\n smooth?: number\n cutoff?: number\n isolevel?: number\n volume?: Volume\n }\n\n /**\n * @param {String} name - surface name\n * @param {String} path - source path\n * @param {Object} data - surface data\n * @param {Float32Array} data.position - surface positions\n * @param {Int32Array} data.index - surface indices\n * @param {Float32Array} data.normal - surface normals\n * @param {Float32Array} data.color - surface colors\n * @param {Int32Array} data.atomindex - atom indices\n * @param {boolean} data.contour - contour mode flag\n */\n constructor (name: string, path: string, data?: SurfaceData) {\n this.name = name || ''\n this.path = path || ''\n this.info = {}\n\n this.center = new Vector3()\n this.boundingBox = new Box3()\n\n if (data instanceof Geometry ||\n data instanceof BufferGeometry ||\n data instanceof Group\n ) {\n // to be removed\n this.fromGeometry(data)\n } else if (data) {\n this.set(\n data.position,\n data.index,\n data.normal,\n data.color,\n data.atomindex,\n data.contour\n )\n\n this.boundingBox.setFromArray(data.position)\n this.boundingBox.getCenter(this.center)\n }\n }\n\n get type () { return 'Surface' }\n\n /**\n * set surface data\n * @param {Float32Array} position - surface positions\n * @param {Int32Array} index - surface indices\n * @param {Float32Array} normal - surface normals\n * @param {Float32Array} color - surface colors\n * @param {Int32Array} atomindex - atom indices\n * @param {boolean} contour - contour mode flag\n * @return {undefined}\n */\n set (position: Float32Array,\n index: Uint32Array|Uint16Array|undefined,\n normal: Float32Array|undefined,\n color: Float32Array|undefined,\n atomindex: Int32Array|undefined,\n contour: boolean = false) {\n /**\n * @type {Float32Array}\n */\n this.position = position\n /**\n * @type {Uint32Array|Uint16Array|undefined}\n */\n this.index = index\n /**\n * @type {Float32Array|undefined}\n */\n this.normal = normal\n /**\n * @type {Float32Array|undefined}\n */\n this.color = color\n /**\n * @type {Int32Array|undefined}\n */\n this.atomindex = atomindex\n\n this.size = position.length / 3\n this.contour = contour\n }\n\n fromGeometry (geometry: Geometry|BufferGeometry|Group) {\n if (Debug) Log.time('GeometrySurface.fromGeometry')\n\n let geo\n\n if (geometry instanceof Geometry) {\n geometry.computeVertexNormals(true)\n geo = new BufferGeometry().fromGeometry(geometry)\n } else if (geometry instanceof BufferGeometry) {\n geo = geometry\n } else {\n geo = (geometry as any)[ 0 ]\n }\n\n if (!geo.boundingBox) geo.computeBoundingBox()\n\n this.boundingBox.copy(geo.boundingBox)\n this.boundingBox.getCenter(this.center)\n\n let position, color, index, normal\n\n if (geo instanceof BufferGeometry) {\n const attr = geo.attributes\n const an = (attr as any).normal ? (attr as any).normal.array : false\n\n // assume there are no normals if the first is zero\n if (!an || (an[ 0 ] === 0 && an[ 1 ] === 0 && an[ 2 ] === 0)) {\n geo.computeVertexNormals()\n }\n\n position = (attr).position.array\n index = (attr).index ? (attr).index.array : null\n normal = (attr).normal.array\n }\n\n this.set(position, index, normal, color, undefined)\n\n if (Debug) Log.timeEnd('GeometrySurface.setGeometry')\n }\n\n getPosition () {\n return this.position\n }\n\n getColor (params: ColormakerParameters&{ scheme: string}) {\n const p = params || {}\n p.surface = this\n\n const n = this.size\n const array = new Float32Array(n * 3)\n const colormaker = ColormakerRegistry.getScheme(p)\n\n if (colormaker.volumeColor || p.scheme === 'random') {\n for (let i = 0; i < n; ++i) {\n colormaker.volumeColorToArray(i, array, i * 3)\n }\n } else if (colormaker.positionColor) {\n const v = new Vector3()\n const pos = this.position\n\n for (let i = 0; i < n; ++i) {\n var i3 = i * 3\n v.set(pos[ i3 ], pos[ i3 + 1 ], pos[ i3 + 2 ])\n colormaker.positionColorToArray(v, array, i3)\n }\n } else if (colormaker.atomColor && this.atomindex) {\n const atomProxy = p.structure!.getAtomProxy()\n const atomindex = this.atomindex\n\n for (let i = 0; i < n; ++i) {\n atomProxy.index = atomindex[ i ]\n colormaker.atomColorToArray(atomProxy, array, i * 3)\n }\n } else {\n const tc = new Color(p.value)\n uniformArray3(n, tc.r, tc.g, tc.b, array)\n }\n\n return array\n }\n\n getPicking (structure?: Structure) {\n if (this.atomindex && structure) {\n return new AtomPicker(this.atomindex as any, structure)\n } else {\n return new SurfacePicker(serialArray(this.size), this)\n }\n }\n\n getNormal () {\n return this.normal\n }\n\n getSize (size: number, scale: number) {\n return uniformArray(this.size, size * scale)\n }\n\n getIndex () {\n return this.index\n }\n\n getFilteredIndex (sele: string, structure: Structure) {\n if (sele && this.atomindex) {\n const selection = new Selection(sele)\n const atomSet = structure.getAtomSet(selection)\n const filteredIndex = []\n\n const atomindex = this.atomindex\n const index = this.index\n const n = index!.length\n const elementSize = this.contour ? 2 : 3\n\n let j = 0\n\n for (let i = 0; i < n; i += elementSize) {\n let include = true\n\n for (let a = 0; a < elementSize; a++) {\n const idx = index![ i + a ]\n const ai = atomindex[ idx ]\n if (!atomSet.get(ai)) {\n include = false\n break\n }\n }\n\n if (!include) { continue }\n\n for (let a = 0; a < elementSize; a++, j++) {\n filteredIndex[ j ] = index![ i + a ]\n }\n }\n\n return getUintArray(filteredIndex, this.position.length / 3)\n } else {\n return this.index\n }\n }\n\n getAtomindex () {\n return this.atomindex\n }\n\n dispose () {\n\n //\n\n }\n}\n\nexport default Surface\n","/**\n * @file Volume\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3, Matrix3, Matrix4 } from 'three'\n\nimport { WorkerRegistry, ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport WorkerPool from '../worker/worker-pool'\nimport { VolumePicker } from '../utils/picker'\nimport {\n uniformArray, serialArray,\n arrayMin, arrayMax, arraySum, arrayMean, arrayRms\n} from '../math/array-utils'\nimport MarchingCubes from './marching-cubes'\nimport { laplacianSmooth, computeVertexNormals } from './surface-utils'\nimport {\n applyMatrix4toVector3array, applyMatrix3toVector3array\n} from '../math/vector-utils'\nimport { m3new, m3makeNormal } from '../math/matrix-utils'\nimport Surface from './surface'\nimport { NumberArray } from '../types';\nimport { ColormakerParameters } from '../color/colormaker';\n\nexport interface VolumeSurface {\n new (data: NumberArray, nx: number, ny: number, nz: number, atomindex: NumberArray): void\n getSurface: (isolevel: number, smooth: boolean|number, box: number[][]|undefined, matrix: Float32Array, contour: boolean, wrap?: boolean) => {\n position: Float32Array\n normal: undefined|Float32Array\n index: Uint32Array|Uint16Array\n atomindex: Int32Array|undefined\n contour: boolean\n }\n}\nexport function VolumeSurface (this: VolumeSurface,data: NumberArray, nx: number, ny: number, nz: number, atomindex: NumberArray) {\n var mc = new (MarchingCubes as any)(data, nx, ny, nz, atomindex) as MarchingCubes\n\n function getSurface (isolevel: number, smooth: boolean|number, box: number[][]|undefined, matrix: Float32Array, contour: boolean, wrap: boolean = false) {\n const sd = mc.triangulate(isolevel, smooth as boolean, box, contour, wrap)\n if (smooth && !contour) {\n laplacianSmooth(sd.position, sd.index as any, smooth as number, true)\n sd.normal = computeVertexNormals(sd.position, sd.index as any)\n }\n if (matrix) {\n applyMatrix4toVector3array(matrix, sd.position)\n if (sd.normal) {\n const normalMatrix = m3new()\n m3makeNormal(normalMatrix, matrix)\n applyMatrix3toVector3array(normalMatrix, sd.normal)\n }\n }\n return sd\n }\n\n this.getSurface = getSurface\n}\nObject.assign(VolumeSurface, {__deps: [\n laplacianSmooth, computeVertexNormals, MarchingCubes,\n applyMatrix4toVector3array, applyMatrix3toVector3array,\n m3new, m3makeNormal\n]})\n\nWorkerRegistry.add('surf', function func (e: any, callback: (data: any, transferList: any) => void) {\n const a = e.data.args\n const p = e.data.params\n if (a) {\n /* global self */\n (self as any).volsurf = new (VolumeSurface as any)(a[0], a[1], a[2], a[3], a[4]) as VolumeSurface\n }\n if (p) {\n const sd = ((self as any).volsurf as VolumeSurface).getSurface(\n p.isolevel, p.smooth, p.box, p.matrix, p.contour, p.wrap\n )\n const transferList = [ sd.position.buffer, sd.index.buffer ]\n if (sd.normal) transferList.push(sd.normal.buffer)\n if (sd.atomindex) transferList.push(sd.atomindex.buffer)\n const data = {\n sd: sd,\n p: p\n }\n callback(data, transferList)\n }\n}, [ VolumeSurface ])\n\nexport type VolumeSize = 'value'|'abs-value'|'value-min'|'deviation'\n/**\n * Volume\n */\nclass Volume {\n name: string\n path: string\n\n matrix: Matrix4\n normalMatrix: Matrix3\n inverseMatrix: Matrix4\n center: Vector3\n boundingBox: Box3\n\n nx: number\n ny: number\n nz: number\n data: Float32Array\n\n worker: Worker\n workerPool: WorkerPool\n _position: Float32Array\n _min: number|undefined\n _max: number|undefined\n _mean: number|undefined\n _rms: number|undefined\n _sum: number|undefined\n __box: Box3|undefined\n\n atomindex: Int32Array|undefined\n volsurf: VolumeSurface|undefined\n header: any\n /**\n * Make Volume instance\n * @param {String} name - volume name\n * @param {String} path - source path\n * @param {Float32array} data - volume 3d grid\n * @param {Integer} nx - x dimension of the 3d volume\n * @param {Integer} ny - y dimension of the 3d volume\n * @param {Integer} nz - z dimension of the 3d volume\n * @param {Int32Array} atomindex - atom indices corresponding to the cells in the 3d grid\n */\n constructor (name: string, path: string, data?: Float32Array, nx?: number, ny?: number, nz?: number, atomindex?: Int32Array) {\n this.name = name\n this.path = path\n\n this.matrix = new Matrix4()\n this.normalMatrix = new Matrix3()\n this.inverseMatrix = new Matrix4()\n this.center = new Vector3()\n this.boundingBox = new Box3()\n\n this.setData(data, nx, ny, nz, atomindex)\n }\n\n get type () { return 'Volume' }\n\n /**\n * set volume data\n * @param {Float32array} data - volume 3d grid\n * @param {Integer} nx - x dimension of the 3d volume\n * @param {Integer} ny - y dimension of the 3d volume\n * @param {Integer} nz - z dimension of the 3d volume\n * @param {Int32Array} atomindex - atom indices corresponding to the cells in the 3d grid\n * @return {undefined}\n */\n setData (data?: Float32Array, nx?: number, ny?: number, nz?: number, atomindex?: Int32Array) {\n this.nx = nx || 1\n this.ny = ny || 1\n this.nz = nz || 1\n\n this.data = data || new Float32Array(1)\n this.setAtomindex(atomindex)\n\n this._position = new Float32Array()\n\n delete this._min\n delete this._max\n delete this._mean\n delete this._rms\n\n if (this.worker) this.worker.terminate()\n }\n\n /**\n * Set statistics, which can be different from the data in this volume,\n * if this volume is a slice of a bigger volume\n * @param {Number|undefined} min - minimum value of the whole data set\n * @param {Number|undefined} max - maximum value of the whole data set\n * @param {Number|undefined} mean - average value of the whole data set\n * @param {Number|undefined} rms - sigma value of the whole data set\n */\n setStats (min: number|undefined, max: number|undefined, mean: number|undefined, rms: number|undefined) {\n this._min = min\n this._max = max\n this._mean = mean\n this._rms = rms\n }\n\n /**\n * set transformation matrix\n * @param {Matrix4} matrix - 4x4 transformation matrix\n * @return {undefined}\n */\n setMatrix (matrix: Matrix4) {\n this.matrix.copy(matrix)\n\n const bb = this.boundingBox\n const v = this.center // temporary re-purposing\n\n const x = this.nx - 1\n const y = this.ny - 1\n const z = this.nz - 1\n\n bb.makeEmpty()\n\n bb.expandByPoint(v.set(x, y, z))\n bb.expandByPoint(v.set(x, y, 0))\n bb.expandByPoint(v.set(x, 0, z))\n bb.expandByPoint(v.set(x, 0, 0))\n bb.expandByPoint(v.set(0, y, z))\n bb.expandByPoint(v.set(0, 0, z))\n bb.expandByPoint(v.set(0, y, 0))\n bb.expandByPoint(v.set(0, 0, 0))\n\n bb.applyMatrix4(this.matrix)\n bb.getCenter(this.center)\n\n // make normal matrix\n\n const me = this.matrix.elements\n const r0 = new Vector3(me[0], me[1], me[2])\n const r1 = new Vector3(me[4], me[5], me[6])\n const r2 = new Vector3(me[8], me[9], me[10])\n const cp = new Vector3()\n // [ r0 ] [ r1 x r2 ]\n // M3x3 = [ r1 ] N = [ r2 x r0 ]\n // [ r2 ] [ r0 x r1 ]\n const ne = this.normalMatrix.elements\n cp.crossVectors(r1, r2)\n ne[ 0 ] = cp.x\n ne[ 1 ] = cp.y\n ne[ 2 ] = cp.z\n cp.crossVectors(r2, r0)\n ne[ 3 ] = cp.x\n ne[ 4 ] = cp.y\n ne[ 5 ] = cp.z\n cp.crossVectors(r0, r1)\n ne[ 6 ] = cp.x\n ne[ 7 ] = cp.y\n ne[ 8 ] = cp.z\n\n this.inverseMatrix.getInverse(this.matrix)\n }\n\n /**\n * set atom indices\n * @param {Int32Array} atomindex - atom indices corresponding to the cells in the 3d grid\n * @return {undefined}\n */\n setAtomindex (atomindex?: Int32Array) {\n this.atomindex = atomindex\n }\n\n getBox (center: Vector3, size: number, target: Box3) {\n if (!target) target = new Box3()\n\n target.set(center, center)\n target.expandByScalar(size)\n target.applyMatrix4(this.inverseMatrix)\n\n target.min.round()\n target.max.round()\n\n return target\n }\n\n _getBox (center: Vector3|undefined, size: number) {\n if (!center || !size) return\n\n if (!this.__box) this.__box = new Box3()\n const box = this.getBox(center, size, this.__box)\n return [ box.min.toArray(), box.max.toArray() ]\n }\n\n _makeSurface (sd: any, isolevel: number, smooth: number) {\n const name = this.name + '@' + isolevel.toPrecision(2)\n const surface = new Surface(name, '', sd)\n surface.info.isolevel = isolevel\n surface.info.smooth = smooth\n surface.info.volume = this\n\n return surface\n }\n\n getSurface (isolevel: number, smooth: number, center: Vector3, size: number, contour: boolean, wrap: boolean = false) {\n isolevel = isNaN(isolevel) ? this.getValueForSigma(2) : isolevel\n smooth = defaults(smooth, 0)\n\n //\n\n if (this.volsurf === undefined) {\n this.volsurf = new (VolumeSurface as any)(\n this.data, this.nx, this.ny, this.nz, this.atomindex\n ) as VolumeSurface\n }\n\n const box = this._getBox(center, size)\n const sd = this.volsurf.getSurface(\n isolevel, smooth, box!, this.matrix.elements as unknown as Float32Array, contour, wrap\n )\n\n return this._makeSurface(sd, isolevel, smooth)\n }\n\n getSurfaceWorker (isolevel: number, smooth: number, center: Vector3, size: number, contour: boolean, wrap: boolean, callback: (s: Surface) => void) {\n isolevel = isNaN(isolevel) ? this.getValueForSigma(2) : isolevel\n smooth = smooth || 0\n\n //\n\n if (window.hasOwnProperty('Worker')) {\n if (this.workerPool === undefined) {\n this.workerPool = new WorkerPool('surf', 2)\n }\n\n const msg = {}\n const worker = this.workerPool.getNextWorker()\n\n if (worker!.postCount === 0) {\n Object.assign(msg, {\n args: [\n this.data, this.nx, this.ny, this.nz, this.atomindex\n ]\n })\n }\n\n Object.assign(msg, {\n params: {\n isolevel: isolevel,\n smooth: smooth,\n box: this._getBox(center, size),\n matrix: this.matrix.elements,\n contour: contour,\n wrap: wrap\n }\n })\n\n worker!.post(msg, undefined,\n (e: any) => {\n const sd = e.data.sd\n const p = e.data.p\n callback(this._makeSurface(sd, p.isolevel, p.smooth))\n },\n (e : string) => {\n console.warn(\n 'Volume.getSurfaceWorker error - trying without worker', e\n )\n const surface = this.getSurface(isolevel, smooth, center, size, contour, wrap)\n callback(surface)\n }\n )\n } else {\n const surface = this.getSurface(isolevel, smooth, center, size, contour, wrap)\n callback(surface)\n }\n }\n\n getValueForSigma (sigma: number) {\n return this.mean + defaults(sigma, 2) * this.rms\n }\n\n getSigmaForValue (value: number) {\n return (defaults(value, 0) - this.mean) / this.rms\n }\n\n get position () {\n if (!this._position) {\n const nz = this.nz\n const ny = this.ny\n const nx = this.nx\n const position = new Float32Array(nx * ny * nz * 3)\n\n let p = 0\n for (let z = 0; z < nz; ++z) {\n for (let y = 0; y < ny; ++y) {\n for (let x = 0; x < nx; ++x) {\n position[ p + 0 ] = x\n position[ p + 1 ] = y\n position[ p + 2 ] = z\n p += 3\n }\n }\n }\n\n applyMatrix4toVector3array(this.matrix.elements as unknown as Float32Array, position)\n this._position = position\n }\n\n return this._position\n }\n\n getDataAtomindex () {\n return this.atomindex\n }\n\n getDataPosition () {\n return this.position\n }\n\n getDataColor (params: ColormakerParameters & {scheme: string}) {\n const p = params || {}\n p.volume = this\n p.scale = p.scale || 'Spectral'\n p.domain = p.domain || [ this.min, this.max ]\n\n const colormaker = ColormakerRegistry.getScheme(p)\n\n const n = this.position.length / 3\n const array = new Float32Array(n * 3)\n\n // var atoms = p.structure.atoms;\n // var atomindex = this.atomindex;\n\n for (let i = 0; i < n; ++i) {\n colormaker.volumeColorToArray(i, array, i * 3)\n // a = atoms[ atomindex[ i ] ];\n // if( a ) colormaker.atomColorToArray( a, array, i * 3 );\n }\n\n return array\n }\n\n getDataPicking () {\n const picking = serialArray(this.position.length / 3)\n return new VolumePicker(picking, this)\n }\n\n getDataSize (size: VolumeSize|number, scale: number) {\n const data = this.data\n const n = this.position.length / 3\n let array\n\n switch (size) {\n case 'value':\n array = new Float32Array(data)\n break\n\n case 'abs-value':\n array = new Float32Array(data)\n for (let i = 0; i < n; ++i) {\n array[ i ] = Math.abs(array[ i ])\n }\n break\n\n case 'value-min': {\n array = new Float32Array(data)\n const min = this.min\n for (let i = 0; i < n; ++i) {\n array[ i ] -= min\n }\n break\n }\n\n case 'deviation':\n array = new Float32Array(data)\n break\n\n default:\n array = uniformArray(n, size)\n break\n }\n\n if (scale !== 1.0) {\n for (let i = 0; i < n; ++i) {\n array[ i ] *= scale\n }\n }\n\n return array\n }\n\n get min () {\n if (this._min === undefined) {\n this._min = arrayMin(this.data)\n }\n return this._min\n }\n\n get max () {\n if (this._max === undefined) {\n this._max = arrayMax(this.data)\n }\n return this._max\n }\n\n get sum () {\n if (this._sum === undefined) {\n this._sum = arraySum(this.data)\n }\n return this._sum\n }\n\n get mean () {\n if (this._mean === undefined) {\n this._mean = arrayMean(this.data)\n }\n return this._mean\n }\n\n get rms () {\n if (this._rms === undefined) {\n this._rms = arrayRms(this.data)\n }\n return this._rms\n }\n\n clone () {\n const vol = new Volume(\n this.name,\n this.path,\n\n this.data,\n\n this.nx,\n this.ny,\n this.nz,\n\n this.atomindex\n )\n\n vol.matrix.copy(this.matrix)\n vol.header = Object.assign({}, this.header)\n\n return vol\n }\n\n dispose () {\n if (this.workerPool) this.workerPool.terminate()\n }\n}\n\nexport default Volume\n","/**\n * @file Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport {\n Color, Vector3, Matrix4,\n FrontSide, BackSide, DoubleSide,\n // VertexColors,\n NoBlending,\n BufferGeometry, BufferAttribute,\n UniformsUtils, UniformsLib, Uniform,\n Group, LineSegments, Points, Mesh, Object3D,\n ShaderMaterial\n} from 'three'\n\nimport { Log } from '../globals'\nimport { createParams, getTypedArray, getUintArray } from '../utils'\nimport { GenericColor, NumberArray } from '../types'\nimport { getShader, ShaderDefines } from '../shader/shader-utils'\nimport { serialArray } from '../math/array-utils'\nimport { Picker } from '../utils/picker'\n\nexport type BufferSide = 'front'|'back'|'double'\n\nfunction getThreeSide (side: BufferSide) {\n if (side === 'front') {\n return FrontSide\n } else if (side === 'back') {\n return BackSide\n } else if (side === 'double') {\n return DoubleSide\n } else {\n return DoubleSide\n }\n}\n\nconst itemSize = {\n 'f': 1, 'v2': 2, 'v3': 3, 'c': 3\n}\n\nfunction setObjectMatrix (object: Object3D, matrix: Matrix4) {\n object.matrix.copy(matrix)\n object.matrix.decompose(object.position, object.quaternion, object.scale)\n object.matrixWorldNeedsUpdate = true\n}\n\nexport type BufferTypes = 'picking'|'background'\nexport type BufferMaterials = 'material'|'wireframeMaterial'|'pickingMaterial'\n\nexport interface _BufferAttribute {\n type: 'f'|'v2'|'v3'|'c'\n value?: NumberArray\n}\n\nexport type Uniforms = { [k: string]: Uniform|{ value: any } }\n\nexport const BufferDefaultParameters = {\n opaqueBack: false,\n side: 'double' as BufferSide, // which triangle sides to render\n opacity: 1.0, // translucency: 1 is fully opaque, 0 is fully transparent\n depthWrite: true,\n clipNear: 0, // position of camera near/front clipping plane in percent of scene bounding box\n clipRadius: 0,\n clipCenter: new Vector3(),\n flatShaded: false, // render flat shaded\n wireframe: false, // render as wireframe\n roughness: 0.4, // how rough the material is, between 0 and 1\n metalness: 0.0, // how metallic the material is, between 0 and 1\n diffuse: 0xffffff, // diffuse color for lighting\n diffuseInterior: false,\n useInteriorColor: false, // render back-side with interior color\n interiorColor: 0xdddddd, // interior color\n interiorDarkening: 0, // interior darkening factor\n forceTransparent: false, // force the material to allow transparency\n matrix: new Matrix4(), // additional transformation matrix\n disablePicking: false, // disable picking\n sortParticles: false,\n background: false\n}\nexport type BufferParameters = Omit & { diffuse: GenericColor; interiorColor: GenericColor }\n\nexport const BufferParameterTypes = {\n opaqueBack: { updateShader: true },\n side: { updateShader: true, property: true },\n opacity: { uniform: true },\n depthWrite: { property: true },\n clipNear: { updateShader: true, property: true },\n clipRadius: { updateShader: true, uniform: true },\n clipCenter: { uniform: true },\n flatShaded: { updateShader: true },\n background: { updateShader: true },\n wireframe: { updateVisibility: true },\n roughness: { uniform: true },\n metalness: { uniform: true },\n diffuse: { uniform: true },\n diffuseInterior: { updateShader: true },\n useInteriorColor: { updateShader: true },\n interiorColor: { uniform: true },\n interiorDarkening: { uniform: true },\n matrix: {}\n}\n\nexport interface BufferData {\n position?: Float32Array\n position1?: Float32Array // TODO\n color?: Float32Array\n index?: Uint32Array|Uint16Array\n normal?: Float32Array\n\n picking?: Picker\n primitiveId?: Float32Array\n}\n\n/**\n * Buffer class. Base class for buffers.\n * @interface\n */\nclass Buffer {\n parameterTypes = BufferParameterTypes\n get defaultParameters() { return BufferDefaultParameters }\n parameters: BufferParameters\n uniforms: Uniforms\n pickingUniforms: Uniforms\n\n private _positionDataSize: number\n\n geometry = new BufferGeometry()\n indexVersion = 0\n wireframeIndexVersion = -1\n group = new Group()\n wireframeGroup = new Group()\n pickingGroup = new Group()\n\n vertexShader = ''\n fragmentShader = ''\n isImpostor = false\n isText = false\n isSurface = false\n isPoint = false\n isLine = false\n dynamic = true\n visible = true\n\n picking?: Picker\n\n material: ShaderMaterial\n wireframeMaterial: ShaderMaterial\n pickingMaterial: ShaderMaterial\n\n wireframeIndex?: Uint32Array|Uint16Array\n wireframeIndexCount = 0\n wireframeGeometry?: BufferGeometry\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Uint32Array|Uint16Array} data.index - triangle indices\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} params - parameters object\n */\n constructor (data: BufferData, params: Partial = {}) {\n this.parameters = createParams(params, this.defaultParameters)\n\n this.uniforms = UniformsUtils.merge([\n UniformsLib.common,\n {\n fogColor: { value: new Color(0x000000) },\n fogNear: { value: 0.0 },\n fogFar: { value: 0.0 },\n opacity: { value: this.parameters.opacity },\n clipNear: { value: 0.0 },\n clipRadius: { value: this.parameters.clipRadius },\n clipCenter: { value: this.parameters.clipCenter }\n },\n {\n emissive: { value: new Color(0x000000) },\n roughness: { value: this.parameters.roughness },\n metalness: { value: this.parameters.metalness },\n interiorColor: { value: new Color(this.parameters.interiorColor) },\n interiorDarkening: { value: this.parameters.interiorDarkening },\n },\n UniformsLib.lights\n ])\n\n this.uniforms.diffuse.value.set(this.parameters.diffuse)\n\n this.pickingUniforms = {\n clipNear: { value: 0.0 },\n objectId: { value: 0 },\n opacity: { value: this.parameters.opacity }\n }\n\n //\n\n const position = data.position || data.position1\n this._positionDataSize = position ? position.length / 3 : 0\n\n if (!data.primitiveId) {\n data.primitiveId = serialArray(this._positionDataSize)\n }\n\n this.addAttributes({\n position: { type: 'v3', value: data.position },\n color: { type: 'c', value: data.color },\n primitiveId: { type: 'f', value: data.primitiveId }\n })\n\n if (params.matrix) {\n this.matrix = params.matrix\n }\n\n if (data.index) {\n this.initIndex(data.index)\n }\n this.picking = data.picking\n\n this.makeWireframeGeometry()\n }\n\n set matrix (m) {\n this.setMatrix(m)\n }\n get matrix () {\n return this.group.matrix.clone()\n }\n\n get transparent () {\n return this.parameters.opacity < 1 || this.parameters.forceTransparent\n }\n\n get size () {\n return this._positionDataSize\n }\n\n get attributeSize () {\n return this.size\n }\n\n get pickable () {\n return !!this.picking && !this.parameters.disablePicking\n }\n\n setMatrix (m: Matrix4) {\n setObjectMatrix(this.group, m)\n setObjectMatrix(this.wireframeGroup, m)\n setObjectMatrix(this.pickingGroup, m)\n }\n\n initIndex (index: Uint32Array|Uint16Array) {\n this.geometry.setIndex(\n new BufferAttribute(index, 1)\n )\n const nindex = this.geometry.getIndex();\n if (!nindex) { Log.error('Index is null'); return; }\n nindex.setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n }\n\n makeMaterial () {\n const side = getThreeSide(this.parameters.side)\n\n const m = new ShaderMaterial({\n uniforms: this.uniforms,\n vertexShader: '',\n fragmentShader: '',\n depthTest: true,\n transparent: this.transparent,\n depthWrite: this.parameters.depthWrite,\n lights: true,\n fog: true,\n side: side\n })\n m.vertexColors = true\n m.extensions.derivatives = true\n m.extensions.fragDepth = this.isImpostor\n\n const wm = new ShaderMaterial({\n uniforms: this.uniforms,\n vertexShader: '',\n fragmentShader: '',\n depthTest: true,\n transparent: this.transparent,\n depthWrite: this.parameters.depthWrite,\n lights: false,\n fog: true,\n side: side\n })\n wm.vertexColors = true\n\n const pm = new ShaderMaterial({\n uniforms: this.pickingUniforms,\n vertexShader: '',\n fragmentShader: '',\n depthTest: true,\n transparent: false,\n depthWrite: this.parameters.depthWrite,\n lights: false,\n fog: false,\n side: side,\n blending: NoBlending\n })\n pm.vertexColors = true\n pm.extensions.fragDepth = this.isImpostor\n\n ;(m as any).clipNear = this.parameters.clipNear\n ;(wm as any).clipNear = this.parameters.clipNear\n ;(pm as any).clipNear = this.parameters.clipNear\n\n this.material = m\n this.wireframeMaterial = wm\n this.pickingMaterial = pm\n\n // also sets vertexShader/fragmentShader\n this.updateShader()\n }\n\n makeWireframeGeometry () {\n this.makeWireframeIndex()\n\n const geometry = this.geometry\n const wireframeIndex = this.wireframeIndex\n const wireframeGeometry = new BufferGeometry()\n\n wireframeGeometry.attributes = geometry.attributes\n if (wireframeIndex) {\n wireframeGeometry.setIndex(\n new BufferAttribute(wireframeIndex, 1).setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n wireframeGeometry.setDrawRange(0, this.wireframeIndexCount)\n }\n\n this.wireframeGeometry = wireframeGeometry\n }\n\n makeWireframeIndex () {\n const edges: number[][] = []\n\n function checkEdge (a: number, b: number) {\n if (a > b) {\n const tmp = a\n a = b\n b = tmp\n }\n\n const list = edges[ a ]\n\n if (list === undefined) {\n edges[ a ] = [ b ]\n return true\n } else if (!list.includes(b)) {\n list.push(b)\n return true\n }\n\n return false\n }\n\n const geometry = this.geometry\n const index = geometry.index\n\n if (!this.parameters.wireframe) {\n this.wireframeIndex = new Uint16Array(0)\n this.wireframeIndexCount = 0\n } else if (index) {\n const array = index.array\n let n = array.length\n if (geometry.drawRange.count !== Infinity) {\n n = geometry.drawRange.count\n }\n let wireframeIndex\n if (this.wireframeIndex && this.wireframeIndex.length > n * 2) {\n wireframeIndex = this.wireframeIndex\n } else {\n const count = (geometry.attributes as any).position.count // TODO\n wireframeIndex = getUintArray(n * 2, count)\n }\n\n let j = 0\n edges.length = 0\n\n for (let i = 0; i < n; i += 3) {\n const a = array[ i + 0 ]\n const b = array[ i + 1 ]\n const c = array[ i + 2 ]\n\n if (checkEdge(a, b)) {\n wireframeIndex[ j + 0 ] = a\n wireframeIndex[ j + 1 ] = b\n j += 2\n }\n if (checkEdge(b, c)) {\n wireframeIndex[ j + 0 ] = b\n wireframeIndex[ j + 1 ] = c\n j += 2\n }\n if (checkEdge(c, a)) {\n wireframeIndex[ j + 0 ] = c\n wireframeIndex[ j + 1 ] = a\n j += 2\n }\n }\n\n this.wireframeIndex = wireframeIndex\n this.wireframeIndexCount = j\n this.wireframeIndexVersion = this.indexVersion\n } else {\n const n = (geometry.attributes as any).position.count // TODO\n\n let wireframeIndex\n if (this.wireframeIndex && this.wireframeIndex.length > n * 2) {\n wireframeIndex = this.wireframeIndex\n } else {\n wireframeIndex = getUintArray(n * 2, n)\n }\n\n for (let i = 0, j = 0; i < n; i += 3) {\n wireframeIndex[ j + 0 ] = i\n wireframeIndex[ j + 1 ] = i + 1\n wireframeIndex[ j + 2 ] = i + 1\n wireframeIndex[ j + 3 ] = i + 2\n wireframeIndex[ j + 4 ] = i + 2\n wireframeIndex[ j + 5 ] = i\n\n j += 6\n }\n\n this.wireframeIndex = wireframeIndex\n this.wireframeIndexCount = n * 2\n this.wireframeIndexVersion = this.indexVersion\n }\n }\n\n updateWireframeIndex () {\n if (!this.wireframeGeometry || !this.wireframeIndex) return\n\n this.wireframeGeometry.setDrawRange(0, Infinity)\n if (this.wireframeIndexVersion < this.indexVersion) this.makeWireframeIndex()\n\n if (this.wireframeGeometry.index &&\n this.wireframeIndex.length > this.wireframeGeometry.index.array.length) {\n this.wireframeGeometry.setIndex(\n new BufferAttribute(this.wireframeIndex, 1).setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n } else {\n const index = this.wireframeGeometry.getIndex()\n if (!index) { Log.error('Index is null'); return; }\n index.set(this.wireframeIndex)\n index.needsUpdate = this.wireframeIndexCount > 0\n index.updateRange.count = this.wireframeIndexCount\n }\n\n this.wireframeGeometry.setDrawRange(0, this.wireframeIndexCount)\n }\n\n getRenderOrder () {\n let renderOrder = 0\n\n if (this.isText) {\n renderOrder = 1\n } else if (this.transparent) {\n if (this.isSurface) {\n renderOrder = 3\n } else {\n renderOrder = 2\n }\n }\n\n return renderOrder\n }\n\n _getMesh (materialName: BufferMaterials) {\n if (!this.material) this.makeMaterial()\n\n const g = this.geometry\n const m = this[ materialName ]\n\n let mesh\n\n if (this.isLine) {\n mesh = new LineSegments(g, m)\n } else if (this.isPoint) {\n mesh = new Points(g, m)\n } else {\n mesh = new Mesh(g, m)\n }\n\n mesh.frustumCulled = false\n mesh.renderOrder = this.getRenderOrder()\n\n return mesh\n }\n\n getMesh () {\n return this._getMesh('material')\n }\n\n getWireframeMesh () {\n let mesh\n\n if (!this.material) this.makeMaterial()\n if (!this.wireframeGeometry) this.makeWireframeGeometry()\n\n mesh = new LineSegments(\n this.wireframeGeometry, this.wireframeMaterial\n )\n\n mesh.frustumCulled = false\n mesh.renderOrder = this.getRenderOrder()\n\n return mesh\n }\n\n getPickingMesh () {\n return this._getMesh('pickingMaterial')\n }\n\n getShader (name: string, type?: BufferTypes) {\n return getShader(name, this.getDefines(type))\n }\n\n getVertexShader (type?: BufferTypes) {\n return this.getShader(this.vertexShader, type)\n }\n\n getFragmentShader (type?: BufferTypes) {\n return this.getShader(this.fragmentShader, type)\n }\n\n getDefines (type?: BufferTypes) {\n const defines: ShaderDefines = {}\n\n if (this.parameters.clipNear) {\n defines.NEAR_CLIP = 1\n }\n\n if (this.parameters.clipRadius) {\n defines.RADIUS_CLIP = 1\n }\n\n if (type === 'picking') {\n defines.PICKING = 1\n } else {\n if (type === 'background' || this.parameters.background) {\n defines.NOLIGHT = 1\n }\n if (this.parameters.flatShaded) {\n defines.FLAT_SHADED = 1\n }\n if (this.parameters.opaqueBack) {\n defines.OPAQUE_BACK = 1\n }\n if (this.parameters.diffuseInterior) {\n defines.DIFFUSE_INTERIOR = 1\n }\n if (this.parameters.useInteriorColor) {\n defines.USE_INTERIOR_COLOR = 1\n }\n }\n\n return defines\n }\n\n getParameters () {\n return this.parameters\n }\n\n addUniforms (uniforms: Uniforms) {\n this.uniforms = UniformsUtils.merge(\n [ this.uniforms, uniforms ]\n )\n\n this.pickingUniforms = UniformsUtils.merge(\n [ this.pickingUniforms, uniforms ]\n )\n }\n\n addAttributes (attributes: { [k: string]: _BufferAttribute }) {\n for (let name in attributes) {\n let buf\n const a = attributes[ name ]\n const arraySize = this.attributeSize * itemSize[ a.type ]\n\n if (a.value) {\n if (arraySize !== a.value.length) {\n Log.error('attribute value has wrong length', name)\n }\n buf = a.value\n } else {\n buf = getTypedArray('float32', arraySize)\n }\n\n this.geometry.setAttribute(\n name,\n new BufferAttribute(buf, itemSize[ a.type ]).setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n }\n }\n\n updateRenderOrder () {\n const renderOrder = this.getRenderOrder()\n function setRenderOrder (mesh: Object3D) {\n mesh.renderOrder = renderOrder\n }\n\n this.group.children.forEach(setRenderOrder)\n if (this.pickingGroup) {\n this.pickingGroup.children.forEach(setRenderOrder)\n }\n }\n\n updateShader () {\n const m = this.material\n const wm = this.wireframeMaterial\n const pm = this.pickingMaterial\n\n m.vertexShader = this.getVertexShader()\n m.fragmentShader = this.getFragmentShader()\n m.needsUpdate = true\n\n wm.vertexShader = this.getShader('Line.vert')\n wm.fragmentShader = this.getShader('Line.frag')\n wm.needsUpdate = true\n\n pm.vertexShader = this.getVertexShader('picking')\n pm.fragmentShader = this.getFragmentShader('picking')\n pm.needsUpdate = true\n }\n\n /**\n * Set buffer parameters\n * @param {BufferParameters} params - buffer parameters object\n * @return {undefined}\n */\n setParameters (params: Partial) {\n const p = params as any\n const pt = this.parameterTypes as any\n const pv = this.parameters as any\n\n const propertyData: { [k: string]: any } = {}\n const uniformData: { [k: string]: any } = {}\n let doShaderUpdate = false\n let doVisibilityUpdate = false\n\n for (const name in p) {\n const value = p[ name ]\n\n if (value === undefined) continue\n pv[ name ] = value\n\n if (pt[ name ] === undefined) continue\n\n if (pt[ name ].property) {\n if (pt[ name ].property !== true) {\n propertyData[ pt[ name ].property as any ] = value\n } else {\n propertyData[ name ] = value\n }\n }\n\n if (pt[ name ].uniform) {\n if (pt[ name ].uniform !== true) {\n uniformData[ pt[ name ].uniform as any ] = value\n } else {\n uniformData[ name ] = value\n }\n }\n\n if (pt[ name ].updateShader) {\n doShaderUpdate = true\n }\n\n if (pt[ name ].updateVisibility) {\n doVisibilityUpdate = true\n }\n\n if (this.dynamic && name === 'wireframe' && value === true) {\n this.updateWireframeIndex()\n }\n\n if (name === 'forceTransparent') {\n propertyData.transparent = this.transparent\n }\n\n if (name === 'matrix') {\n this.matrix = value\n }\n }\n\n this.setProperties(propertyData)\n this.setUniforms(uniformData)\n if (doShaderUpdate) this.updateShader()\n if (doVisibilityUpdate) this.setVisibility(this.visible)\n }\n\n /**\n * Sets buffer attributes\n * @param {Object} data - An object where the keys are the attribute names\n * and the values are the attribute data.\n * @example\n * var buffer = new Buffer();\n * buffer.setAttributes({ attrName: attrData });\n */\n setAttributes (data: any) { // TODO\n const geometry = this.geometry\n const attributes = geometry.attributes as any // TODO\n\n for (const name in data) {\n if (name === 'picking') continue\n\n const array = data[ name ]\n const length = array.length\n\n if (name === 'index') {\n const index = geometry.getIndex()\n if (!index) { Log.error('Index is null'); continue; }\n geometry.setDrawRange(0, Infinity)\n\n if (length > index.array.length) {\n geometry.setIndex(\n new BufferAttribute(array, 1)\n .setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n } else {\n index.set(array)\n index.count = length\n index.needsUpdate = length > 0\n index.updateRange.count = length\n geometry.setDrawRange(0, length)\n }\n\n this.indexVersion++\n if (this.parameters.wireframe) this.updateWireframeIndex()\n } else {\n const attribute = attributes[ name ]\n\n if (length > attribute.array.length) {\n geometry.setAttribute(\n name,\n new BufferAttribute(array, attribute.itemSize)\n .setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n } else {\n attributes[ name ].set(array)\n attributes[ name ].needsUpdate = length > 0\n attributes[ name ].updateRange.count = length\n }\n }\n }\n }\n\n setUniforms (data: any) { // TODO\n if (!data) return\n\n const u = this.material.uniforms\n const wu = this.wireframeMaterial.uniforms\n const pu = this.pickingMaterial.uniforms\n\n for (let name in data) {\n if (name === 'opacity') {\n this.setProperties({ transparent: this.transparent })\n }\n\n if (u[ name ] !== undefined) {\n if (u[ name ].value.isVector3) {\n u[ name ].value.copy(data[ name ])\n } else if (u[ name ].value.set) {\n u[ name ].value.set(data[ name ])\n } else {\n u[ name ].value = data[ name ]\n }\n }\n\n if (wu[ name ] !== undefined) {\n if (wu[ name ].value.isVector3) {\n wu[ name ].value.copy(data[ name ])\n } else if (wu[ name ].value.set) {\n wu[ name ].value.set(data[ name ])\n } else {\n wu[ name ].value = data[ name ]\n }\n }\n\n if (pu[ name ] !== undefined) {\n if (pu[ name ].value.isVector3) {\n pu[ name ].value.copy(data[ name ])\n } else if (pu[ name ].value.set) {\n pu[ name ].value.set(data[ name ])\n } else {\n pu[ name ].value = data[ name ]\n }\n }\n }\n }\n\n setProperties (data: any) { // TODO\n if (!data) return\n\n const m = this.material\n const wm = this.wireframeMaterial\n const pm = this.pickingMaterial\n\n for (const _name in data) {\n const name = _name as 'side'|'transparent' // TODO\n\n let value = data[ name ]\n\n if (name === 'transparent') {\n this.updateRenderOrder()\n } else if (name === 'side') {\n value = getThreeSide(value)\n }\n\n (m[ name ] as any) = value;\n (wm[ name ] as any) = value;\n (pm[ name ] as any) = value\n }\n\n m.needsUpdate = true\n wm.needsUpdate = true\n pm.needsUpdate = true\n }\n\n /**\n * Set buffer visibility\n * @param {Boolean} value - visibility value\n * @return {undefined}\n */\n setVisibility (value: boolean) {\n this.visible = value\n\n if (this.parameters.wireframe) {\n this.group.visible = false\n this.wireframeGroup.visible = value\n if (this.pickable) {\n this.pickingGroup.visible = false\n }\n } else {\n this.group.visible = value\n this.wireframeGroup.visible = false\n if (this.pickable) {\n this.pickingGroup.visible = value\n }\n }\n }\n\n /**\n * Free buffer resources\n * @return {undefined}\n */\n dispose () {\n if (this.material) this.material.dispose()\n if (this.wireframeMaterial) this.wireframeMaterial.dispose()\n if (this.pickingMaterial) this.pickingMaterial.dispose()\n\n this.geometry.dispose()\n if (this.wireframeGeometry) this.wireframeGeometry.dispose()\n }\n\n /**\n * Customize JSON serialization to avoid circular references\n */\n toJSON () {\n var result: any = {};\n for (var x in this) {\n if (x !== \"group\" && x !== \"wireframeGroup\" && x != \"pickingGroup\"\n && x !== \"picking\") {\n result[x] = this[x];\n }\n }\n return result;\n }\n}\n\nexport default Buffer\n","/**\n * @file Mesh Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport '../shader/Mesh.vert'\nimport '../shader/Mesh.frag'\n\nimport Buffer, { BufferParameters, BufferData } from './buffer'\n\n/**\n * Mesh buffer. Draws a triangle mesh.\n *\n * @example\n * var meshBuffer = new MeshBuffer({\n * position: new Float32Array(\n * [ 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1 ]\n * ),\n * color: new Float32Array(\n * [ 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0 ]\n * )\n * });\n */\nclass MeshBuffer extends Buffer {\n vertexShader = 'Mesh.vert'\n fragmentShader = 'Mesh.frag'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} [data.index] - triangle indices\n * @param {Float32Array} [data.normal] - radii\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: BufferData, params: Partial = {}) {\n super(data, params)\n\n this.addAttributes({\n 'normal': { type: 'v3', value: data.normal }\n })\n\n if (data.normal === undefined) {\n this.geometry.computeVertexNormals()\n }\n }\n}\n\nexport default MeshBuffer\n","/**\n * @file Surface Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport MeshBuffer from './mesh-buffer'\n\n/**\n * Surface buffer. Like a {@link MeshBuffer}, but with `.isSurface` set to `true`.\n */\nclass SurfaceBuffer extends MeshBuffer {\n isSurface = true\n}\n\nexport default SurfaceBuffer\n","/**\n * @file Double Sided Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { Group, BufferGeometry, Object3D, Mesh, LineSegments, Vector3, Matrix4 } from 'three'\n\nimport Buffer, { BufferSide } from './buffer'\nimport { Picker } from '../utils/picker'\n\nfunction setVisibilityTrue (m: Object3D) { m.visible = true }\nfunction setVisibilityFalse (m: Object3D) { m.visible = false }\n\n/**\n * A double-sided mesh buffer. Takes a buffer and renders the front and\n * the back as seperate objects to avoid some artifacts when rendering\n * transparent meshes. Also allows to render the back of a mesh opaque\n * while the front is transparent.\n * @implements {Buffer}\n *\n * @example\n * var sphereGeometryBuffer = new SphereGeometryBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n * var doubleSidedBuffer = new DoubleSidedBuffer(sphereGeometryBuffer);\n */\nclass DoubleSidedBuffer {\n size: number\n side: BufferSide\n visible: boolean\n wireframe: boolean\n geometry: BufferGeometry\n\n picking?: Picker\n\n group = new Group()\n wireframeGroup = new Group()\n pickingGroup = new Group()\n\n frontMeshes: (Mesh|LineSegments)[] = []\n backMeshes: (Mesh|LineSegments)[] = []\n\n buffer: Buffer\n frontBuffer: Buffer\n backBuffer: Buffer\n\n /**\n * Create a double sided buffer\n * @param {Buffer} buffer - the buffer to be rendered double-sided\n */\n constructor (buffer: Buffer) {\n this.size = buffer.size\n this.side = buffer.parameters.side\n this.visible = buffer.visible\n this.geometry = buffer.geometry\n this.picking = buffer.picking\n\n this.group = new Group()\n this.wireframeGroup = new Group()\n this.pickingGroup = new Group()\n\n // requires Group objects to be present\n this.matrix = buffer.matrix\n\n const frontBuffer = buffer\n const backBuffer = new (buffer as any).constructor({ // TODO\n position: new Float32Array(0)\n }) as Buffer\n\n frontBuffer.makeMaterial()\n backBuffer.makeMaterial()\n\n backBuffer.picking = buffer.picking\n backBuffer.geometry = buffer.geometry\n backBuffer.wireframeGeometry = buffer.wireframeGeometry\n backBuffer.setParameters(buffer.getParameters())\n backBuffer.updateShader()\n\n frontBuffer.setParameters({\n side: 'front'\n })\n backBuffer.setParameters({\n side: 'back',\n opacity: backBuffer.parameters.opacity\n })\n\n this.buffer = buffer\n this.frontBuffer = frontBuffer\n this.backBuffer = backBuffer\n }\n\n set matrix (m) {\n Buffer.prototype.setMatrix.call(this, m)\n }\n get matrix () {\n return this.group.matrix.clone()\n }\n\n get pickable () {\n return !!this.picking && !this.parameters.disablePicking\n }\n\n get parameters () {\n return this.buffer.parameters\n }\n\n getParameters () {\n const p = Object.assign({}, this.buffer.parameters)\n p.side = this.side\n return p\n }\n\n getMesh (picking: boolean) {\n let front, back\n\n if (picking) {\n back = this.backBuffer.getPickingMesh()\n front = this.frontBuffer.getPickingMesh()\n } else {\n back = this.backBuffer.getMesh()\n front = this.frontBuffer.getMesh()\n }\n\n this.frontMeshes.push(front)\n this.backMeshes.push(back)\n\n this.setParameters({ side: this.side })\n\n return new Group().add(back, front)\n }\n\n getWireframeMesh () {\n return this.buffer.getWireframeMesh()\n }\n\n getPickingMesh () {\n return this.getMesh(true)\n }\n\n setAttributes (data: any) { // TODO\n this.buffer.setAttributes(data)\n }\n\n setParameters (data: any) { // TODO\n data = Object.assign({}, data)\n\n if (data.side === 'front') {\n this.frontMeshes.forEach(setVisibilityTrue)\n this.backMeshes.forEach(setVisibilityFalse)\n } else if (data.side === 'back') {\n this.frontMeshes.forEach(setVisibilityFalse)\n this.backMeshes.forEach(setVisibilityTrue)\n } else if (data.side === 'double') {\n this.frontMeshes.forEach(setVisibilityTrue)\n this.backMeshes.forEach(setVisibilityTrue)\n }\n\n if (data.side !== undefined) {\n this.side = data.side\n }\n delete data.side\n\n if (data.matrix !== undefined) {\n this.matrix = data.matrix\n }\n delete data.matrix\n\n this.frontBuffer.setParameters(data)\n\n if (data.wireframe !== undefined) {\n this.wireframe = data.wireframe\n this.setVisibility(this.visible)\n }\n delete data.wireframe\n\n this.backBuffer.setParameters(data)\n }\n\n setVisibility (value: boolean) {\n this.visible = value\n\n if (this.parameters.wireframe) {\n this.group.visible = false\n this.wireframeGroup.visible = value\n if (this.pickable) {\n this.pickingGroup.visible = false\n }\n } else {\n this.group.visible = value\n this.wireframeGroup.visible = false\n if (this.pickable) {\n this.pickingGroup.visible = value\n }\n }\n }\n\n dispose () {\n this.frontBuffer.dispose()\n this.backBuffer.dispose()\n }\n\n /**\n * Customize JSON serialization to avoid circular references.\n * Only export simple params which could be useful.\n */\n toJSON () {\n var result: any = {};\n for (var x in this) {\n if (['side', 'size', 'visible', 'matrix', 'parameters'].includes(x)) {\n result[x] = this[x];\n }\n }\n return result;\n }\n}\n\nexport default DoubleSidedBuffer\n","/**\n * @file Contour Buffer\n * @author Fred ludlow \n * @private\n */\n\nimport '../shader/Line.vert'\nimport '../shader/Line.frag'\n\nimport Buffer from './buffer'\n\n/**\n * Contour buffer. A buffer that draws lines (instead of triangle meshes).\n */\nclass ContourBuffer extends Buffer {\n isLine = true\n vertexShader = 'Line.vert'\n fragmentShader = 'Line.frag'\n}\n\nexport default ContourBuffer\n","/**\n * @file Surface Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3, Box3 } from 'three'\n\nimport { defaults } from '../utils'\nimport Representation, { RepresentationParameters } from './representation'\nimport Volume from '../surface/volume'\nimport SurfaceBuffer from '../buffer/surface-buffer'\nimport DoubleSidedBuffer from '../buffer/doublesided-buffer'\nimport ContourBuffer from '../buffer/contour-buffer'\nimport Surface from '../surface/surface';\nimport Viewer from '../viewer/viewer';\nimport {SurfaceData} from '../surface/surface'\n// @ts-ignore: unused import ColormakerParameters required for declaration only\nimport { ColormakerParameters } from '../color/colormaker';\nexport type SurfaceDataFields = {position: boolean, color: boolean, index: boolean, normal: boolean, radius: boolean}\n\n/**\n * Surface representation parameter object. Extends {@link RepresentationParameters}\n *\n * @typedef {Object} SurfaceRepresentationParameters - surface representation parameters\n *\n * @property {String} isolevelType - Meaning of the isolevel value. Either *value* for the literal value or *sigma* as a factor of the sigma of the data. For volume data only.\n * @property {Float} isolevel - The value at which to create the isosurface. For volume data only.\n * @property {Boolean} negateIsolevel - For volume data only.\n * @property {Boolean} isolevelScroll - For volume data only\n * @property {Integer} smooth - How many iterations of laplacian smoothing after surface triangulation. For volume data only.\n * @property {Boolean} background - Render the surface in the background, unlit.\n * @property {Boolean} opaqueBack - Render the back-faces (where normals point away from the camera) of the surface opaque, ignoring the transparency parameter.\n * @property {Integer} boxSize - Size of the box to triangulate volume data in. Set to zero to triangulate the whole volume. For volume data only.\n * @property {Boolean} useWorker - Weather or not to triangulate the volume asynchronously in a Web Worker. For volume data only.\n * @property {Boolean} wrap - Wrap volume data around the edges; use in conjuction with boxSize but not larger than the volume dimension. For volume data only.\n */\nexport interface SurfaceRepresentationParameters extends RepresentationParameters {\n isolevelType: 'value'|'sigma'\n isolevel: number\n smooth: number\n background: boolean\n opaqueBack: boolean\n boxSize: number\n useWorker: boolean\n wrap: boolean\n}\n/**\n * Surface representation\n */\n/**\n * Create Surface representation object\n * @param {Surface|Volume} surface - the surface or volume to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {SurfaceRepresentationParameters} params - surface representation parameters\n */\nclass SurfaceRepresentation extends Representation {\n protected surface: Surface|Volume|undefined\n protected volume: Volume|undefined\n protected boxCenter: Vector3\n protected __boxCenter: Vector3\n protected box: Box3\n protected __box: Box3\n protected _position: Vector3\n protected isolevelType: 'value'|'sigma'\n protected isolevel: number\n protected negateIsolevel: boolean\n protected isolevelScroll: boolean\n protected smooth: number\n protected background: boolean\n protected opaqueBack: boolean\n protected boxSize: number\n protected inverseMatrix: Matrix4\n protected colorVolume: Volume\n protected contour: boolean\n protected useWorker: boolean\n protected wrap: boolean\n\n protected __isolevel: number\n protected __smooth: number\n protected __contour: boolean\n protected __wrap: boolean\n protected __boxSize: number\n\n setBox: () => void\n\n constructor (surface: Surface, viewer: Viewer, params: Partial) {\n super(surface, viewer, params)\n\n this.type = 'surface'\n\n this.parameters = Object.assign({\n\n isolevelType: {\n type: 'select',\n options: {\n 'value': 'value', 'sigma': 'sigma'\n }\n },\n isolevel: {\n type: 'number', precision: 2, max: 1000, min: -1000\n },\n negateIsolevel: {\n type: 'boolean'\n },\n isolevelScroll: {\n type: 'boolean'\n },\n smooth: {\n type: 'integer', precision: 1, max: 10, min: 0\n },\n background: {\n type: 'boolean', rebuild: true // FIXME\n },\n opaqueBack: {\n type: 'boolean', buffer: true\n },\n boxSize: {\n type: 'integer', precision: 1, max: 100, min: 0\n },\n colorVolume: {\n type: 'hidden'\n },\n contour: {\n type: 'boolean', rebuild: true\n },\n useWorker: {\n type: 'boolean', rebuild: true\n },\n wrap: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters)\n\n if (surface instanceof Volume) {\n this.surface = undefined\n this.volume = surface\n } else {\n this.surface = surface\n this.volume = undefined\n }\n\n this.boxCenter = new Vector3()\n this.__boxCenter = new Vector3()\n this.box = new Box3()\n this.__box = new Box3()\n\n this._position = new Vector3()\n this.inverseMatrix = new Matrix4()\n\n this.setBox = function setBox () {\n this._position.copy(viewer.translationGroup.position).negate()\n this._position.applyMatrix4(this.inverseMatrix)\n if (!this._position.equals(this.boxCenter)) {\n this.setParameters({ 'boxCenter': this._position })\n }\n }\n\n this.toBePrepared = true\n\n this.viewer.signals.ticked.add(this.setBox, this)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'uniform')\n p.colorValue = defaults(p.colorValue, 0xDDDDDD)\n\n this.isolevelType = defaults(p.isolevelType, 'sigma')\n this.isolevel = defaults(p.isolevel, 2.0)\n this.negateIsolevel = defaults(p.negateIsolevel, false)\n this.isolevelScroll = defaults(p.isolevelScroll, false)\n this.smooth = defaults(p.smooth, 0)\n this.background = defaults(p.background, false)\n this.opaqueBack = defaults(p.opaqueBack, true)\n this.boxSize = defaults(p.boxSize, 0)\n this.colorVolume = defaults(p.colorVolume, undefined)\n this.contour = defaults(p.contour, false)\n this.useWorker = defaults(p.useWorker, true)\n this.wrap = defaults(p.wrap, false)\n\n super.init(p)\n\n this.inverseMatrix.getInverse(this.matrix)\n\n this.build()\n }\n\n attach (callback: () => void) {\n this.bufferList.forEach(buffer => {\n this.viewer.add(buffer)\n })\n\n this.setVisibility(this.visible)\n\n callback()\n }\n\n prepare (callback: () => void) {\n if (this.volume) {\n let isolevel\n\n if (this.isolevelType === 'sigma') {\n isolevel = this.volume.getValueForSigma(this.isolevel)\n } else {\n isolevel = this.isolevel\n }\n if (this.negateIsolevel) isolevel *= -1\n\n if (!this.surface ||\n this.__isolevel !== isolevel ||\n this.__smooth !== this.smooth ||\n this.__contour !== this.contour ||\n this.__wrap !== this.wrap ||\n this.__boxSize !== this.boxSize ||\n (this.boxSize > 0 &&\n !this.__boxCenter.equals(this.boxCenter))\n ) {\n this.__isolevel = isolevel\n this.__smooth = this.smooth\n this.__contour = this.contour\n this.__wrap = this.wrap\n this.__boxSize = this.boxSize\n this.__boxCenter.copy(this.boxCenter)\n this.__box.copy(this.box)\n\n const onSurfaceFinish = (surface: Surface) => {\n this.surface = surface\n callback()\n }\n\n if (this.useWorker) {\n this.volume.getSurfaceWorker(\n isolevel, this.smooth, this.boxCenter, this.boxSize,\n this.contour, this.wrap, onSurfaceFinish\n )\n } else {\n onSurfaceFinish(\n this.volume.getSurface(\n isolevel, this.smooth, this.boxCenter, this.boxSize,\n this.contour, this.wrap\n )\n )\n }\n } else {\n callback()\n }\n } else {\n callback()\n }\n }\n\n create () {\n const sd = {\n position: (this.surface as Surface).getPosition(),\n color: (this.surface as Surface).getColor(this.getColorParams()),\n index: (this.surface as Surface).getIndex()\n }\n\n let buffer\n\n if (this.contour) {\n buffer = new ContourBuffer(\n sd,\n this.getBufferParams({ wireframe: false })\n )\n } else {\n Object.assign(sd, {\n normal: (this.surface as Surface).getNormal(),\n picking: (this.surface as Surface).getPicking()\n })\n\n const surfaceBuffer = new SurfaceBuffer(\n sd,\n this.getBufferParams({\n background: this.background,\n opaqueBack: this.opaqueBack,\n dullInterior: false\n })\n )\n\n buffer = new DoubleSidedBuffer(surfaceBuffer)\n }\n\n this.bufferList.push(buffer as ContourBuffer)\n }\n\n update (what: SurfaceDataFields) {\n if (this.bufferList.length === 0) return\n\n what = what || {}\n\n const surfaceData: Partial = {}\n\n if (what.position) {\n surfaceData.position = (this.surface as Surface).getPosition()\n }\n\n if (what.color) {\n surfaceData.color = (this.surface as Surface).getColor(\n this.getColorParams()\n )\n }\n\n if (what.index) {\n surfaceData.index = (this.surface as Surface).getIndex()\n }\n\n if (what.normal) {\n surfaceData.normal = (this.surface as Surface).getNormal()\n }\n\n this.bufferList.forEach(function (buffer) {\n buffer.setAttributes(surfaceData)\n })\n }\n\n /**\n * Set representation parameters\n * @alias SurfaceRepresentation#setParameters\n * @param {SurfaceRepresentationParameters} params - surface parameter object\n * @param {Object} [what] - buffer data attributes to be updated,\n * note that this needs to be implemented in the\n * derived classes. Generally it allows more\n * fine-grained control over updating than\n * forcing a rebuild.\n * @param {Boolean} what.position - update position data\n * @param {Boolean} what.color - update color data\n * @param {Boolean} [rebuild] - whether or not to rebuild the representation\n * @return {SurfaceRepresentation} this object\n */\n setParameters (params: Partial, what?: SurfaceDataFields, rebuild?: boolean) {\n if (params && params.isolevelType !== undefined &&\n this.volume\n ) {\n if (this.isolevelType === 'value' &&\n params.isolevelType === 'sigma'\n ) {\n this.isolevel = this.volume.getSigmaForValue(this.isolevel)\n } else if (this.isolevelType === 'sigma' &&\n params.isolevelType === 'value'\n ) {\n this.isolevel = this.volume.getValueForSigma(this.isolevel)\n }\n\n this.isolevelType = params.isolevelType\n }\n\n if (params && params.boxCenter) {\n this.boxCenter.copy(params.boxCenter)\n delete params.boxCenter\n }\n\n // Forbid wireframe && contour as in molsurface\n if (params && params.wireframe && (\n params.contour || (params.contour === undefined && this.contour)\n )) {\n params.wireframe = false\n }\n\n super.setParameters(params, what, rebuild)\n\n if (params.matrix) {\n this.inverseMatrix.getInverse(params.matrix)\n }\n\n if (this.volume) {\n this.volume.getBox(this.boxCenter, this.boxSize, this.box)\n }\n\n if (params && params.colorVolume !== undefined) {\n if (what) what.color = true\n }\n\n if (this.surface && (\n params.isolevel !== undefined ||\n params.negateIsolevel !== undefined ||\n params.smooth !== undefined ||\n params.wrap !== undefined ||\n params.boxSize !== undefined ||\n (this.boxSize > 0 &&\n !this.__box.equals(this.box))\n )) {\n this.build({\n 'position': true,\n 'color': true,\n 'index': true,\n 'normal': !this.contour\n })\n }\n\n return this\n }\n\n getColorParams () {\n const p = super.getColorParams()\n\n p.volume = this.colorVolume\n\n return p\n }\n\n dispose () {\n this.viewer.signals.ticked.remove(this.setBox, this)\n\n super.dispose()\n }\n}\n\nexport default SurfaceRepresentation\n","/**\n * @file Mouse Actions\n * @author Alexander Rose \n * @private\n */\n\nimport PickingProxy from './picking-proxy'\nimport { almostIdentity } from '../math/math-utils'\nimport Stage from '../stage/stage'\nimport StructureComponent from '../component/structure-component'\nimport SurfaceRepresentation from '../representation/surface-representation'\n\nexport type ScrollCallback = (stage: Stage, delta: number) => void\nexport type DragCallback = (stage: Stage, dx: number, dy: number) => void\nexport type PickCallback = (stage: Stage, pickingProxy: PickingProxy) => void\nexport type MouseActionCallback = ScrollCallback | DragCallback | PickCallback\n\n/**\n * Mouse actions provided as static methods\n */\nclass MouseActions {\n /**\n * Zoom scene based on scroll-delta\n * @param {Stage} stage - the stage\n * @param {Number} delta - amount to zoom\n * @return {undefined}\n */\n static zoomScroll (stage: Stage, delta: number) {\n stage.trackballControls.zoom(delta)\n }\n\n /**\n * Move near clipping plane based on scroll-delta\n * @param {Stage} stage - the stage\n * @param {Number} delta - amount to move clipping plane\n * @return {undefined}\n */\n static clipNearScroll (stage: Stage, delta: number) {\n const sp = stage.getParameters()\n stage.setParameters({ clipNear: sp.clipNear + delta / 10 })\n }\n\n /**\n * Move clipping planes based on scroll-delta.\n * @param {Stage} stage - the stage\n * @param {Number} delta - direction to move planes\n * @return {undefined}\n */\n static focusScroll (stage: Stage, delta: number) {\n const focus = stage.getFocus()\n const sign = Math.sign(delta)\n const step = sign * almostIdentity((100 - focus) / 10, 5, 0.2)\n stage.setFocus(focus + step)\n }\n\n /**\n * Zoom scene based on scroll-delta and\n * move focus planes based on camera position (zoom)\n * @param {Stage} stage - the stage\n * @param {Number} delta - amount to move focus planes and zoom\n * @return {undefined}\n */\n static zoomFocusScroll (stage: Stage, delta: number) {\n stage.trackballControls.zoom(delta)\n const z = stage.viewer.camera.position.z\n stage.setFocus(100 - Math.abs(z / 8))\n }\n\n /**\n * Change isolevel of volume surfaces based on scroll-delta\n * @param {Stage} stage - the stage\n * @param {Number} delta - amount to change isolevel\n * @return {undefined}\n */\n static isolevelScroll (stage: Stage, delta: number) {\n const d = Math.sign(delta) / 10\n stage.eachRepresentation((reprElem, comp) => {\n if (reprElem.repr instanceof SurfaceRepresentation) {\n const p = reprElem.getParameters() as any // TODO\n if (p.isolevelScroll) {\n reprElem.setParameters({ isolevel: p.isolevel + d })\n }\n }\n })\n }\n\n /**\n * Pan scene based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to pan in x direction\n * @param {Number} dy - amount to pan in y direction\n * @return {undefined}\n */\n static panDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.pan(dx, dy)\n }\n\n /**\n * Rotate scene based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to rotate in x direction\n * @param {Number} dy - amount to rotate in y direction\n * @return {undefined}\n */\n static rotateDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.rotate(dx, dy)\n }\n\n /**\n * Rotate scene around z axis based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to rotate in x direction\n * @param {Number} dy - amount to rotate in y direction\n * @return {undefined}\n */\n static zRotateDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.zRotate(dx, dy)\n }\n\n /**\n * Zoom scene based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to zoom\n * @param {Number} dy - amount to zoom\n * @return {undefined}\n */\n static zoomDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.zoom((dx + dy) / -2)\n }\n\n /**\n * Zoom scene based on mouse coordinate changes and\n * move focus planes based on camera position (zoom)\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to zoom and focus\n * @param {Number} dy - amount to zoom and focus\n * @return {undefined}\n */\n static zoomFocusDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.zoom((dx + dy) / -2)\n const z = stage.viewer.camera.position.z\n stage.setFocus(100 - Math.abs(z / 8))\n }\n\n /**\n * Pan picked component based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to pan in x direction\n * @param {Number} dy - amount to pan in y direction\n * @return {undefined}\n */\n static panComponentDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.panComponent(dx, dy)\n }\n\n /**\n * Pan picked atom based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to pan in x direction\n * @param {Number} dy - amount to pan in y direction\n * @return {undefined}\n */\n static panAtomDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.panAtom(dx, dy)\n }\n\n /**\n * Rotate picked component based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to rotate in x direction\n * @param {Number} dy - amount to rotate in y direction\n * @return {undefined}\n */\n static rotateComponentDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.rotateComponent(dx, dy)\n }\n\n /**\n * Move picked element to the center of the screen\n * @param {Stage} stage - the stage\n * @param {PickingProxy} pickingProxy - the picking data object\n * @return {undefined}\n */\n static movePick (stage: Stage, pickingProxy: PickingProxy) {\n if (pickingProxy) {\n stage.animationControls.move(pickingProxy.position.clone())\n }\n }\n\n /**\n * Show tooltip with information of picked element\n * @param {Stage} stage - the stage\n * @param {PickingProxy} pickingProxy - the picking data object\n * @return {undefined}\n */\n static tooltipPick (stage: Stage, pickingProxy: PickingProxy) {\n const tt = stage.tooltip\n const sp = stage.getParameters() as any\n if (sp.tooltip && pickingProxy) {\n const mp = pickingProxy.mouse.position\n tt.innerText = pickingProxy.getLabel()\n tt.style.bottom = (window.innerHeight - mp.y + 3) + 'px'\n tt.style.left = (mp.x + 3) + 'px'\n tt.style.display = 'block'\n } else {\n tt.style.display = 'none'\n }\n }\n\n static measurePick (stage: Stage, pickingProxy: PickingProxy) {\n if (pickingProxy && (pickingProxy.atom || pickingProxy.bond)) {\n const atom = pickingProxy.atom || pickingProxy.closestBondAtom\n const sc = pickingProxy.component as StructureComponent\n sc.measurePick(atom)\n } else {\n stage.measureClear()\n }\n }\n}\n\ntype MouseActionPreset = [ string, MouseActionCallback ][]\nexport const MouseActionPresets = {\n default: [\n [ 'scroll', MouseActions.zoomScroll ],\n [ 'scroll-shift', MouseActions.focusScroll ],\n [ 'scroll-ctrl', MouseActions.isolevelScroll ],\n [ 'scroll-shift-ctrl', MouseActions.zoomFocusScroll ],\n\n [ 'drag-left', MouseActions.rotateDrag ],\n [ 'drag-right', MouseActions.panDrag ],\n [ 'drag-ctrl-left', MouseActions.panDrag ],\n [ 'drag-ctrl-right', MouseActions.zRotateDrag ],\n [ 'drag-shift-left', MouseActions.zoomDrag ],\n [ 'drag-middle', MouseActions.zoomFocusDrag ],\n\n [ 'drag-ctrl-shift-right', MouseActions.panComponentDrag ],\n [ 'drag-ctrl-shift-left', MouseActions.rotateComponentDrag ],\n\n [ 'clickPick-right', MouseActions.measurePick ],\n [ 'clickPick-ctrl-left', MouseActions.measurePick ],\n [ 'clickPick-middle', MouseActions.movePick ],\n [ 'clickPick-left', MouseActions.movePick ],\n [ 'hoverPick', MouseActions.tooltipPick ]\n ] as MouseActionPreset,\n pymol: [\n [ 'drag-left', MouseActions.rotateDrag ],\n [ 'drag-middle', MouseActions.panDrag ],\n [ 'drag-right', MouseActions.zoomDrag ],\n [ 'scroll', MouseActions.focusScroll ],\n [ 'drag-shift-right', MouseActions.focusScroll ],\n\n [ 'clickPick-ctrl+shift-middle', MouseActions.movePick ],\n [ 'hoverPick', MouseActions.tooltipPick ]\n ] as MouseActionPreset,\n coot: [\n [ 'scroll', MouseActions.isolevelScroll ],\n\n [ 'drag-left', MouseActions.rotateDrag ],\n [ 'drag-middle', MouseActions.panDrag ],\n [ 'drag-ctrl-left', MouseActions.panDrag ],\n [ 'drag-right', MouseActions.zoomFocusDrag ],\n [ 'drag-ctrl-right', MouseActions.focusScroll ],\n\n [ 'clickPick-middle', MouseActions.movePick ],\n [ 'hoverPick', MouseActions.tooltipPick ]\n ] as MouseActionPreset,\n astexviewer: [\n [ 'drag-left', MouseActions.rotateDrag ],\n [ 'drag-ctrl-left', MouseActions.panDrag ],\n [ 'drag-shift-left', MouseActions.zoomDrag ],\n [ 'scroll', MouseActions.focusScroll ],\n [ 'clickPick-middle', MouseActions.movePick ],\n [ 'hoverPick', MouseActions.tooltipPick ]\n ] as MouseActionPreset\n}\n\nexport default MouseActions\n","/**\n * @file Mouse Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { MouseActionPresets, MouseActionCallback } from './mouse-actions'\nimport Stage from '../stage/stage'\nimport MouseObserver from '../stage/mouse-observer'\n\nexport type MouseControlPreset = keyof typeof MouseActionPresets\nexport interface MouseControlsParams {\n preset?: MouseControlPreset\n disabled?: boolean\n}\n\nexport type MouseActionType = ''|'scroll'|'drag'|'click'|'doubleClick'|'hover'|'clickPick'|'hoverPick'\nexport interface MouseAction {\n type: MouseActionType\n key: number\n button: number\n callback: MouseActionCallback\n}\n\n/**\n * Strings to describe mouse events (including optional keyboard modifiers).\n * Must contain an event type: \"scroll\", \"drag\", \"click\", \"doubleClick\",\n * \"hover\", \"clickPick\" or \"hoverPick\". Optionally contain one or more\n * (seperated by plus signs) keyboard modifiers: \"alt\", \"ctrl\", \"meta\" or\n * \"shift\". Can contain the mouse button performing the event: \"left\",\n * \"middle\" or \"right\". The type, key and button parts must be seperated by\n * dashes.\n *\n * @example\n * // triggered on scroll event (no key or button)\n * \"scroll\"\n *\n * @example\n * // triggered on scroll event while shift key is pressed\n * \"scroll-shift\"\n *\n * @example\n * // triggered on drag event with left mouse button\n * \"drag-left\"\n *\n * @example\n * // triggered on drag event with right mouse button\n * // while ctrl and shift keys are pressed\n * \"drag-right-ctrl+shift\"\n *\n * @typedef {String} TriggerString\n */\n\n/**\n * Get event type, key and button\n * @param {TriggerString} str - input trigger string\n * @return {Array} event type, key and button\n */\nfunction triggerFromString (str: string) {\n const tokens = str.split(/[-+]/)\n\n let type = ''\n if (tokens.includes('scroll')) type = 'scroll'\n if (tokens.includes('drag')) type = 'drag'\n if (tokens.includes('click')) type = 'click'\n if (tokens.includes('doubleClick')) type = 'doubleClick'\n if (tokens.includes('hover')) type = 'hover'\n if (tokens.includes('clickPick')) type = 'clickPick'\n if (tokens.includes('hoverPick')) type = 'hoverPick'\n\n let key = 0\n if (tokens.includes('alt')) key += 1\n if (tokens.includes('ctrl')) key += 2\n if (tokens.includes('meta')) key += 4\n if (tokens.includes('shift')) key += 8\n\n let button = 0\n if (tokens.includes('left')) button += 1\n if (tokens.includes('right')) button += 2\n if (tokens.includes('middle')) button += 4\n\n return [ type, key, button ] as [ MouseActionType, number, number ]\n}\n\n/**\n * Mouse controls\n */\nclass MouseControls {\n actionList: MouseAction[] = []\n mouse: MouseObserver\n\n disabled: boolean // Flag to disable all actions\n\n /**\n * @param {Stage} stage - the stage object\n * @param {Object} [params] - the parameters\n * @param {String} params.preset - one of \"default\", \"pymol\", \"coot\"\n * @param {String} params.disabled - flag to disable all actions\n */\n constructor (readonly stage: Stage, params: MouseControlsParams = {}) {\n this.mouse = stage.mouseObserver\n this.disabled = params.disabled || false\n this.preset(params.preset || 'default')\n }\n\n run (type: MouseActionType, ...args: any[]) {\n if (this.disabled) return\n\n const key = this.mouse.key || 0\n const button = this.mouse.buttons || 0\n\n this.actionList.forEach(a => {\n if (a.type === type && a.key === key && a.button === button) {\n (a.callback as any)(this.stage, ...args) // TODO\n }\n })\n }\n\n /**\n * Add a new mouse action triggered by an event, key and button combination.\n * The {@link MouseActions} class provides a number of static methods for\n * use as callback functions.\n *\n * @example\n * // change ambient light intensity on mouse scroll\n * // while the ctrl and shift keys are pressed\n * stage.mouseControls.add( \"scroll-ctrl+shift\", function( stage, delta ){\n * var ai = stage.getParameters().ambientIntensity;\n * stage.setParameters( { ambientIntensity: Math.max( 0, ai + delta / 50 ) } );\n * } );\n *\n * @example\n * // Call the MouseActions.zoomDrag method on mouse drag events\n * // with left and right mouse buttons simultaneous\n * stage.mouseControls.add( \"drag-left+right\", MouseActions.zoomDrag );\n *\n * @param {TriggerString} triggerStr - the trigger for the action\n * @param {function(stage: Stage, ...args: Any)} callback - the callback function for the action\n * @return {undefined}\n */\n add (triggerStr: string, callback: MouseActionCallback) {\n const [ type, key, button ] = triggerFromString(triggerStr)\n\n this.actionList.push({ type, key, button, callback })\n }\n\n /**\n * Remove a mouse action. The trigger string can contain an asterix (*)\n * as a wildcard for any key or mouse button. When the callback function\n * is given, only actions that call that function are removed.\n *\n * @example\n * // remove actions triggered solely by a scroll event\n * stage.mouseControls.remove( \"scroll\" );\n *\n * @example\n * // remove actions triggered by a scroll event, including\n * // those requiring a key pressed or mouse button used\n * stage.mouseControls.remove( \"scroll-*\" );\n *\n * @example\n * // remove actions triggered by a scroll event\n * // while the shift key is pressed\n * stage.mouseControls.remove( \"scroll-shift\" );\n *\n * @param {TriggerString} triggerStr - the trigger for the action\n * @param {Function} [callback] - the callback function for the action\n * @return {undefined}\n */\n remove (triggerStr: string, callback?: MouseActionCallback) {\n const wildcard = triggerStr.includes('*')\n const [ type, key, button ] = triggerFromString(triggerStr)\n\n const actionList = this.actionList.filter(function (a) {\n return !(\n (a.type === type || (wildcard && type === '')) &&\n (a.key === key || (wildcard && key === 0)) &&\n (a.button === button || (wildcard && button === 0)) &&\n (a.callback === callback || callback === undefined)\n )\n })\n\n this.actionList = actionList\n }\n\n /**\n * Set mouse action preset\n * @param {String} name - one of \"default\", \"pymol\", \"coot\"\n * @return {undefined}\n */\n preset (name: MouseControlPreset) {\n this.clear()\n\n const list = MouseActionPresets[ name ] || []\n\n list.forEach(action => this.add(action[0], action[1]))\n }\n\n /**\n * Remove all mouse actions\n * @return {undefined}\n */\n clear () {\n this.actionList.length = 0\n }\n}\n\nexport default MouseControls\n","/**\n * @file Key Actions\n * @author Alexander Rose \n * @private\n */\n\nimport Stage from '../stage/stage'\n\nexport type KeyActionCallback = (stage: Stage) => void\n\n/**\n * Key actions provided as static methods\n */\nclass KeyActions {\n /**\n * Stage auto view\n */\n static autoView (stage: Stage) {\n stage.autoView(1000)\n }\n\n /**\n * Toggle stage animations\n */\n static toggleAnimations (stage: Stage) {\n stage.animationControls.toggle()\n }\n\n /**\n * Toggle stage rocking\n */\n static toggleRock (stage: Stage) {\n stage.toggleRock()\n }\n\n /**\n * Toggle stage spinning\n */\n static toggleSpin (stage: Stage) {\n stage.toggleSpin()\n }\n\n /**\n * Toggle anti-aliasing\n */\n static toggleAntialiasing (stage: Stage) {\n const p = stage.getParameters()\n stage.setParameters({ sampleLevel: p.sampleLevel === -1 ? 0 : -1 })\n }\n}\n\ntype KeyActionPreset = [ string, KeyActionCallback ][]\nexport const KeyActionPresets = {\n default: [\n [ 'i', KeyActions.toggleSpin ],\n [ 'k', KeyActions.toggleRock ],\n [ 'p', KeyActions.toggleAnimations ],\n [ 'a', KeyActions.toggleAntialiasing ],\n [ 'r', KeyActions.autoView ]\n ] as KeyActionPreset\n}\n\nexport default KeyActions\n","/**\n * @file Key Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { KeyActionPresets, KeyActionCallback } from './key-actions'\nimport Stage from '../stage/stage'\n\nexport type KeyControlPreset = keyof typeof KeyActionPresets\nexport interface KeyControlsParams {\n preset?: KeyControlPreset\n disabled?: boolean\n}\n\nexport interface KeyAction {\n key: string,\n callback: KeyActionCallback\n}\n\n/**\n * Mouse controls\n */\nclass KeyControls {\n actionList: KeyAction[] = []\n\n disabled: boolean // Flag to disable all actions\n\n /**\n * @param {Stage} stage - the stage object\n * @param {Object} [params] - the parameters\n * @param {String} params.preset - one of \"default\"\n * @param {String} params.disabled - flag to disable all actions\n */\n constructor (readonly stage: Stage, params: KeyControlsParams = {}) {\n this.disabled = params.disabled || false\n this.preset(params.preset || 'default')\n }\n\n run (key: string) {\n if (this.disabled) return\n\n this.actionList.forEach(a => {\n if (a.key === key) {\n a.callback(this.stage)\n }\n })\n }\n\n /**\n * Add a key action triggered by pressing the given character.\n * The {@link KeyActions} class provides a number of static methods for\n * use as callback functions.\n *\n * @example\n * // call KeyActions.toggleRock when \"k\" is pressed\n * stage.keyControls.remove( \"k\", KeyActions.toggleRock );\n *\n * @param {Char} char - the key/character\n * @param {Function} callback - the callback function for the action\n * @return {undefined}\n */\n add (char: string, callback: KeyActionCallback) {\n this.actionList.push({ key: char, callback })\n }\n\n /**\n * Remove a key action. When the callback function\n * is given, only actions that call that function are removed.\n *\n * @example\n * // remove all actions triggered by pressing \"k\"\n * stage.keyControls.remove( \"k\" );\n *\n * @example\n * // remove action `toggleRock` triggered by pressing \"k\"\n * stage.keyControls.remove( \"k\", toggleRock );\n *\n * @param {Char} char - the key/character\n * @param {Function} [callback] - the callback function for the action\n * @return {undefined}\n */\n remove (char: string, callback: KeyActionCallback) {\n\n const actionList = this.actionList.filter(function (a) {\n return !(\n (a.key === char) &&\n (a.callback === callback || callback === undefined)\n )\n })\n\n this.actionList = actionList\n }\n\n /**\n * Set key action preset\n * @param {String} name - one of \"default\"\n * @return {undefined}\n */\n preset (name: KeyControlPreset) {\n this.clear()\n\n const list = KeyActionPresets[ name ] || []\n\n list.forEach(action => this.add(action[0], action[1]))\n }\n\n /**\n * Remove all key actions\n * @return {undefined}\n */\n clear () {\n this.actionList.length = 0\n }\n}\n\nexport default KeyControls\n","/**\n * @file Picking Behavior\n * @author Alexander Rose \n * @private\n */\n\nimport Stage from './stage'\nimport MouseObserver from './mouse-observer'\nimport Viewer from '../viewer/viewer'\nimport MouseControls from '../controls/mouse-controls'\n\nclass PickingBehavior {\n viewer: Viewer\n mouse: MouseObserver\n controls: MouseControls\n\n constructor (readonly stage: Stage) {\n this.stage = stage\n this.mouse = stage.mouseObserver\n this.controls = stage.mouseControls\n\n this.mouse.signals.clicked.add(this._onClick, this)\n this.mouse.signals.hovered.add(this._onHover, this)\n }\n\n _onClick (x: number, y: number) {\n const pickingProxy = this.stage.pickingControls.pick(x, y)\n this.stage.signals.clicked.dispatch(pickingProxy)\n this.controls.run('clickPick', pickingProxy)\n }\n\n _onHover (x: number, y: number) {\n const pickingProxy = this.stage.pickingControls.pick(x, y)\n if (pickingProxy && this.mouse.down.equals(this.mouse.position)) {\n this.stage.transformComponent = pickingProxy.component\n this.stage.transformAtom = pickingProxy.atom\n }\n this.stage.signals.hovered.dispatch(pickingProxy)\n this.controls.run('hoverPick', pickingProxy)\n }\n\n dispose () {\n this.mouse.signals.clicked.remove(this._onClick, this)\n this.mouse.signals.hovered.remove(this._onHover, this)\n }\n}\n\nexport default PickingBehavior\n","/**\n * @file Mouse Behavior\n * @author Alexander Rose \n * @private\n */\n\nimport Stage from './stage'\nimport MouseObserver from './mouse-observer'\nimport Viewer from '../viewer/viewer'\nimport MouseControls from '../controls/mouse-controls'\n\nclass MouseBehavior {\n viewer: Viewer\n mouse: MouseObserver\n controls: MouseControls\n domElement: HTMLCanvasElement\n\n constructor (readonly stage: Stage) {\n this.stage = stage\n this.mouse = stage.mouseObserver\n this.controls = stage.mouseControls\n\n this.mouse.signals.moved.add(this._onMove, this)\n this.mouse.signals.scrolled.add(this._onScroll, this)\n this.mouse.signals.dragged.add(this._onDrag, this)\n this.mouse.signals.clicked.add(this._onClick, this)\n this.mouse.signals.hovered.add(this._onHover, this)\n this.mouse.signals.doubleClicked.add(this._onDblclick, this)\n }\n\n _onMove (/* x, y */) {\n this.stage.tooltip.style.display = 'none'\n }\n\n _onScroll (delta: number) {\n this.controls.run('scroll', delta)\n }\n\n _onDrag (dx: number, dy: number) {\n this.controls.run('drag', dx, dy)\n }\n\n _onClick (x: number, y: number) {\n this.controls.run('click', x, y)\n }\n\n _onDblclick (x: number, y: number) {\n this.controls.run('doubleClick', x, y)\n }\n\n _onHover (x: number, y: number) {\n this.controls.run('hover', x, y)\n }\n\n dispose () {\n this.mouse.signals.moved.remove(this._onMove, this)\n this.mouse.signals.scrolled.remove(this._onScroll, this)\n this.mouse.signals.dragged.remove(this._onDrag, this)\n this.mouse.signals.clicked.remove(this._onClick, this)\n this.mouse.signals.hovered.remove(this._onHover, this)\n }\n}\n\nexport default MouseBehavior\n","/**\n * @file Animation Behavior\n * @author Alexander Rose \n * @private\n */\n\nimport Stage from './stage'\nimport Viewer from '../viewer/viewer'\nimport Stats from '../viewer/stats'\nimport AnimationControls from '../controls/animation-controls'\n\nclass AnimationBehavior {\n viewer: Viewer\n animationControls: AnimationControls\n\n constructor (readonly stage: Stage) {\n this.viewer = stage.viewer\n this.animationControls = stage.animationControls\n\n this.viewer.signals.ticked.add(this._onTick, this)\n }\n\n _onTick (stats: Stats) {\n this.animationControls.run(stats)\n }\n\n dispose () {\n this.viewer.signals.ticked.remove(this._onTick, this)\n }\n}\n\nexport default AnimationBehavior\n","/**\n * @file Key Behavior\n * @author Alexander Rose \n * @private\n */\n\nimport { SupportsPassiveEventHandler } from '../globals'\nimport Stage from './stage'\nimport Viewer from '../viewer/viewer'\nimport KeyControls from '../controls/key-controls'\n\nconst passive = SupportsPassiveEventHandler ? { passive: true } : false\n\nclass KeyBehavior {\n viewer: Viewer\n controls: KeyControls\n domElement: HTMLCanvasElement\n\n /**\n * @param {Stage} stage - the stage object\n */\n constructor (readonly stage: Stage) {\n this.stage = stage\n this.controls = stage.keyControls\n this.domElement = stage.viewer.renderer.domElement\n\n // ensure the domElement is focusable\n this.domElement.setAttribute('tabIndex', '-1')\n this.domElement.style.outline = 'none'\n\n this._focusDomElement = this._focusDomElement.bind(this)\n this._onKeydown = this._onKeydown.bind(this)\n this._onKeyup = this._onKeyup.bind(this)\n this._onKeypress = this._onKeypress.bind(this)\n\n this.domElement.addEventListener('mousedown', this._focusDomElement)\n this.domElement.addEventListener('touchstart', this._focusDomElement, passive as any) // TODO\n this.domElement.addEventListener('keydown', this._onKeydown)\n this.domElement.addEventListener('keyup', this._onKeyup)\n this.domElement.addEventListener('keypress', this._onKeypress)\n }\n\n /**\n * handle key down\n * @param {Event} event - key event\n * @return {undefined}\n */\n _onKeydown (/* event */) {\n // console.log( \"down\", event.keyCode, String.fromCharCode( event.keyCode ) );\n }\n\n /**\n * handle key up\n * @param {Event} event - key event\n * @return {undefined}\n */\n _onKeyup (/* event */) {\n // console.log( \"up\", event.keyCode, String.fromCharCode( event.keyCode ) );\n }\n\n /**\n * handle key press\n * @param {Event} event - key event\n * @return {undefined}\n */\n _onKeypress (event: KeyboardEvent) {\n // console.log( \"press\", event.keyCode, String.fromCharCode( event.keyCode ) );\n let pressedKey: string;\n if (\"key\" in KeyboardEvent.prototype) {\n pressedKey = event.key;\n // some mobile browsers don't support this attribute\n } else {\n pressedKey = String.fromCharCode(event.which || event.keyCode);\n }\n this.controls.run(pressedKey);\n }\n\n _focusDomElement () {\n this.domElement.focus()\n }\n\n dispose () {\n this.domElement.removeEventListener('mousedown', this._focusDomElement)\n this.domElement.removeEventListener('touchstart', this._focusDomElement, passive as any) // TODO\n this.domElement.removeEventListener('keydown', this._onKeypress)\n this.domElement.removeEventListener('keyup', this._onKeypress)\n this.domElement.removeEventListener('keypress', this._onKeypress)\n }\n}\n\nexport default KeyBehavior\n","/**\n * @file Annotation\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector2, Vector3 } from 'three'\n\nimport { defaults } from '../utils'\nimport { smoothstep } from '../math/math-utils'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\nimport Component from './component'\n\nexport interface AnnotationParams {\n offsetX?: number\n offsetY?: number\n visible?: boolean\n}\n\n/**\n * Annotation HTML element floating on top of a position rendered in 3d\n */\nexport default class Annotation {\n offsetX: number\n offsetY: number\n visible: boolean\n\n stage: Stage\n viewer: Viewer\n element: HTMLElement\n\n private _viewerPosition: Vector3\n private _canvasPosition: Vector2\n private _cameraPosition: Vector3\n private _clientRect: ClientRect\n\n /**\n * @param {Component} component - the associated component\n * @param {Vector3} position - position in 3d\n * @param {String|Element} content - HTML content\n * @param {Object} [params] - parameters\n * @param {Integer} params.offsetX - 2d offset in x direction\n * @param {Integer} params.offsetY - 2d offset in y direction\n * @param {Boolean} params.visible - visibility flag\n */\n constructor (readonly component: Component, readonly position: Vector3, content: string|HTMLElement, params: AnnotationParams = {}) {\n this.offsetX = defaults(params.offsetX, 0)\n this.offsetY = defaults(params.offsetY, 0)\n this.visible = defaults(params.visible, true)\n\n this.stage = component.stage\n this.viewer = component.stage.viewer\n\n this._viewerPosition = new Vector3()\n this._updateViewerPosition()\n this._canvasPosition = new Vector2()\n this._cameraPosition = new Vector3()\n\n this.element = document.createElement('div')\n Object.assign(this.element.style, {\n display: 'block',\n position: 'absolute',\n pointerEvents: 'none',\n whiteSpace: 'nowrap',\n left: '-10000px'\n })\n\n this.viewer.wrapper.appendChild(this.element)\n this.setContent(content)\n this.updateVisibility()\n this.viewer.signals.rendered.add(this._update, this)\n this.component.signals.matrixChanged.add(this._updateViewerPosition, this)\n }\n\n /**\n * Set HTML content of the annotation\n * @param {String|Element} value - HTML content\n * @return {undefined}\n */\n setContent (value: string|HTMLElement) {\n const displayValue = this.element.style.display\n if (displayValue === 'none') {\n this.element.style.left = '-10000px'\n this.element.style.display = 'block'\n }\n\n if (value instanceof HTMLElement) {\n this.element.appendChild(value)\n } else {\n const content = document.createElement('div')\n content.innerText = value\n Object.assign(content.style, {\n backgroundColor: 'rgba( 0, 0, 0, 0.6 )',\n color: 'lightgrey',\n padding: '8px',\n fontFamily: 'sans-serif',\n })\n this.element.appendChild(content)\n }\n\n this._clientRect = this.element.getBoundingClientRect()\n\n if (displayValue === 'none') {\n this.element.style.display = displayValue\n }\n }\n\n /**\n * Set visibility of the annotation\n * @param {Boolean} value - visibility flag\n * @return {undefined}\n */\n setVisibility (value: boolean) {\n this.visible = value\n this.updateVisibility()\n }\n\n getVisibility () {\n return this.visible && this.component.parameters.visible\n }\n\n updateVisibility () {\n this.element.style.display = this.getVisibility() ? 'block' : 'none'\n }\n\n _updateViewerPosition () {\n this._viewerPosition\n .copy(this.position)\n .applyMatrix4(this.component.matrix)\n }\n\n _update () {\n if (!this.getVisibility()) return\n\n const s = this.element.style\n const cp = this._canvasPosition\n const vp = this._viewerPosition\n const cr = this._clientRect\n\n this._cameraPosition.copy(vp)\n .add(this.viewer.translationGroup.position)\n .applyMatrix4(this.viewer.rotationGroup.matrix)\n .sub(this.viewer.camera.position)\n\n if (this._cameraPosition.z < 0) {\n s.display = 'none'\n return\n } else {\n s.display = 'block'\n }\n\n const depth = this._cameraPosition.length()\n const fog = this.viewer.scene.fog as any // TODO\n\n s.opacity = (1 - smoothstep(fog.near, fog.far, depth)).toString()\n s.zIndex = (Math.round((fog.far - depth) * 100)).toString()\n\n this.stage.viewerControls.getPositionOnCanvas(vp, cp)\n\n s.bottom = (this.offsetX + cp.y + cr.height / 2) + 'px'\n s.left = (this.offsetY + cp.x - cr.width / 2) + 'px'\n }\n\n /**\n * Safely remove the annotation\n * @return {undefined}\n */\n dispose () {\n this.viewer.wrapper.removeChild(this.element)\n this.viewer.signals.ticked.remove(this._update, this)\n this.component.signals.matrixChanged.remove(this._updateViewerPosition, this)\n }\n}","/**\n * @file Component Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4, Quaternion } from 'three'\nimport * as signalsWrapper from 'signals'\n\nimport { ensureVector3 } from '../utils'\nimport Component from '../component/component'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\n\nconst tmpRotateMatrix = new Matrix4()\nconst tmpRotateVector = new Vector3()\nconst tmpRotateQuaternion = new Quaternion()\n\n/**\n * Component controls\n */\nclass ComponentControls {\n signals = {\n changed: new signalsWrapper.Signal()\n }\n\n stage: Stage\n viewer: Viewer\n\n /**\n * @param {Component} component - the component object\n */\n constructor (readonly component: Component) {\n this.stage = component.stage\n this.viewer = component.stage.viewer\n }\n\n /**\n * component center position\n * @type {Vector3}\n */\n get position () {\n return this.component.position\n }\n\n /**\n * component rotation\n * @type {Quaternion}\n */\n get rotation () {\n return this.component.quaternion\n }\n\n /**\n * Trigger render and emit changed event\n * @emits {ComponentControls.signals.changed}\n * @return {undefined}\n */\n changed () {\n this.component.updateMatrix()\n this.viewer.requestRender()\n this.signals.changed.dispatch()\n }\n\n /**\n * spin component on axis\n * @param {Vector3|Array} axis - rotation axis\n * @param {Number} angle - amount to spin\n * @return {undefined}\n */\n spin (axis: Vector3, angle: number) {\n tmpRotateMatrix.getInverse(this.viewer.rotationGroup.matrix)\n tmpRotateVector\n .copy(ensureVector3(axis)).applyMatrix4(tmpRotateMatrix)\n\n tmpRotateMatrix.extractRotation(this.component.transform)\n tmpRotateMatrix.premultiply(this.viewer.rotationGroup.matrix)\n tmpRotateMatrix.getInverse(tmpRotateMatrix)\n\n tmpRotateVector.copy(ensureVector3(axis))\n tmpRotateVector.applyMatrix4(tmpRotateMatrix)\n tmpRotateMatrix.makeRotationAxis(tmpRotateVector, angle)\n tmpRotateQuaternion.setFromRotationMatrix(tmpRotateMatrix)\n\n this.component.quaternion.premultiply(tmpRotateQuaternion)\n this.changed()\n }\n}\n\nexport default ComponentControls\n","/**\n * @file Radius Factory\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { NucleicBackboneAtoms } from '../structure/structure-constants'\nimport AtomProxy from '../proxy/atom-proxy'\n\nexport const RadiusFactoryTypes = {\n '': '',\n 'vdw': 'by vdW radius',\n 'covalent': 'by covalent radius',\n 'sstruc': 'by secondary structure',\n 'bfactor': 'by bfactor',\n 'size': 'size',\n 'data': 'data',\n 'explicit' : 'explicit'\n}\nexport type RadiusType = keyof typeof RadiusFactoryTypes\n\nexport interface RadiusParams {\n type?: RadiusType\n scale?: number\n size?: number\n data?: { [k: number]: number }\n}\n\nclass RadiusFactory {\n max = 10\n\n static types = RadiusFactoryTypes\n\n readonly type: RadiusType\n readonly scale: number\n readonly size: number\n readonly data: { [k: number]: number }\n\n constructor (params: RadiusParams = {}) {\n this.type = defaults(params.type, 'size')\n this.scale = defaults(params.scale, 1)\n this.size = defaults(params.size, 1)\n this.data = defaults(params.data, {})\n }\n\n atomRadius (a: AtomProxy) {\n let r\n\n switch (this.type) {\n case 'vdw':\n r = a.vdw\n break\n\n case 'covalent':\n r = a.covalent\n break\n\n case 'bfactor':\n r = a.bfactor || 1.0\n break\n\n case 'sstruc':\n const sstruc = a.sstruc\n if (sstruc === 'h') {\n r = 0.25\n } else if (sstruc === 'g') {\n r = 0.25\n } else if (sstruc === 'i') {\n r = 0.25\n } else if (sstruc === 'e') {\n r = 0.25\n } else if (sstruc === 'b') {\n r = 0.25\n } else if (NucleicBackboneAtoms.includes(a.atomname)) {\n r = 0.4\n } else {\n r = 0.1\n }\n break\n\n case 'data':\n r = defaults(this.data[ a.index ], 1.0)\n break\n\n case 'explicit':\n // defaults is inappropriate as AtomProxy.radius returns\n // null for missing radii\n r = a.radius\n if (r === null) r = this.size\n break\n\n default:\n r = this.size\n break\n }\n\n return Math.min(r * this.scale, this.max)\n }\n\n}\n\nexport default RadiusFactory\n","/**\n * @file Principal Axes\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4, Quaternion } from 'three'\n\nimport {\n Matrix, meanRows, subRows, transpose, multiplyABt, svd\n} from './matrix-utils'\nimport { projectPointOnVector } from './vector-utils'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\n\nconst negateVector = new Vector3(-1, -1, -1)\nconst tmpMatrix = new Matrix4()\n\n/**\n * Principal axes\n */\nclass PrincipalAxes {\n begA: Vector3\n endA: Vector3\n begB: Vector3\n endB: Vector3\n begC: Vector3\n endC: Vector3\n\n center: Vector3\n\n vecA: Vector3\n vecB: Vector3\n vecC: Vector3\n\n normVecA: Vector3\n normVecB: Vector3\n normVecC: Vector3\n\n /**\n * @param {Matrix} points - 3 by N matrix\n */\n constructor (points: Matrix) {\n // console.time( \"PrincipalAxes\" );\n\n const n = points.rows\n const n3 = n / 3\n const pointsT = new Matrix(n, 3)\n const A = new Matrix(3, 3)\n const W = new Matrix(1, 3)\n const U = new Matrix(3, 3)\n const V = new Matrix(3, 3)\n\n // calculate\n const mean = meanRows(points)\n subRows(points, mean)\n transpose(pointsT, points)\n multiplyABt(A, pointsT, pointsT)\n svd(A, W, U, V)\n\n // console.log( points, pointsT, mean )\n // console.log( n, A, W, U, V );\n\n // center\n const vm = new Vector3(mean[0], mean[1], mean[2])\n\n // normalized\n const van = new Vector3(U.data[0], U.data[3], U.data[6])\n const vbn = new Vector3(U.data[1], U.data[4], U.data[7])\n const vcn = new Vector3(U.data[2], U.data[5], U.data[8])\n\n // scaled\n const va = van.clone().multiplyScalar(Math.sqrt(W.data[0] / n3))\n const vb = vbn.clone().multiplyScalar(Math.sqrt(W.data[1] / n3))\n const vc = vcn.clone().multiplyScalar(Math.sqrt(W.data[2] / n3))\n\n // points\n this.begA = vm.clone().sub(va)\n this.endA = vm.clone().add(va)\n this.begB = vm.clone().sub(vb)\n this.endB = vm.clone().add(vb)\n this.begC = vm.clone().sub(vc)\n this.endC = vm.clone().add(vc)\n\n //\n\n this.center = vm\n\n this.vecA = va\n this.vecB = vb\n this.vecC = vc\n\n this.normVecA = van\n this.normVecB = vbn\n this.normVecC = vcn\n\n // console.timeEnd( \"PrincipalAxes\" );\n }\n\n /**\n * Get the basis matrix descriping the axes\n * @param {Matrix4} [optionalTarget] - target object\n * @return {Matrix4} the basis\n */\n getBasisMatrix (optionalTarget = new Matrix4()) {\n const basis = optionalTarget\n\n basis.makeBasis(this.normVecB, this.normVecA, this.normVecC)\n if (basis.determinant() < 0) {\n basis.scale(negateVector)\n }\n\n return basis\n }\n\n /**\n * Get a quaternion descriping the axes rotation\n * @param {Quaternion} [optionalTarget] - target object\n * @return {Quaternion} the rotation\n */\n getRotationQuaternion (optionalTarget = new Quaternion()) {\n const q = optionalTarget\n q.setFromRotationMatrix(this.getBasisMatrix(tmpMatrix))\n\n return q.inverse()\n }\n\n /**\n * Get the scale/length for each dimension for a box around the axes\n * to enclose the atoms of a structure\n * @param {Structure|StructureView} structure - the structure\n * @return {{d1a: Number, d2a: Number, d3a: Number, d1b: Number, d2b: Number, d3b: Number}} scale\n */\n getProjectedScaleForAtoms (structure: Structure) {\n let d1a = -Infinity\n let d1b = -Infinity\n let d2a = -Infinity\n let d2b = -Infinity\n let d3a = -Infinity\n let d3b = -Infinity\n\n const p = new Vector3()\n const t = new Vector3()\n\n const center = this.center\n const ax1 = this.normVecA\n const ax2 = this.normVecB\n const ax3 = this.normVecC\n\n structure.eachAtom(function (ap: AtomProxy) {\n projectPointOnVector(p.copy(ap as any), ax1, center) // TODO\n const dp1 = t.subVectors(p, center).normalize().dot(ax1)\n const dt1 = p.distanceTo(center)\n if (dp1 > 0) {\n if (dt1 > d1a) d1a = dt1\n } else {\n if (dt1 > d1b) d1b = dt1\n }\n\n projectPointOnVector(p.copy(ap as any), ax2, center)\n const dp2 = t.subVectors(p, center).normalize().dot(ax2)\n const dt2 = p.distanceTo(center)\n if (dp2 > 0) {\n if (dt2 > d2a) d2a = dt2\n } else {\n if (dt2 > d2b) d2b = dt2\n }\n\n projectPointOnVector(p.copy(ap as any), ax3, center)\n const dp3 = t.subVectors(p, center).normalize().dot(ax3)\n const dt3 = p.distanceTo(center)\n if (dp3 > 0) {\n if (dt3 > d3a) d3a = dt3\n } else {\n if (dt3 > d3b) d3b = dt3\n }\n })\n\n return {\n d1a: d1a,\n d2a: d2a,\n d3a: d3a,\n d1b: -d1b,\n d2b: -d2b,\n d3b: -d3b\n }\n }\n}\n\nexport default PrincipalAxes\n","/**\n * @file Filtered Volume\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport Volume from './volume'\nimport { Box3, Matrix4, Matrix3, Vector3 } from 'three';\n\nclass FilteredVolume {\n volume: Volume\n data: Float32Array\n position: Float32Array\n atomindex: Int32Array\n _filterHash: string\n _dataBuffer: ArrayBuffer\n _positionBuffer: ArrayBuffer\n _atomindexBuffer: ArrayBuffer\n getValueForSigma: typeof Volume.prototype.getValueForSigma\n getSigmaForValue: typeof Volume.prototype.getSigmaForValue\n getDataAtomindex: typeof Volume.prototype.getDataAtomindex\n getDataPosition: typeof Volume.prototype.getDataPosition\n getDataColor: typeof Volume.prototype.getDataColor\n getDataPicking: typeof Volume.prototype.getDataPicking\n getDataSize: typeof Volume.prototype.getDataSize\n\n\n constructor (volume: Volume, minValue?: number, maxValue?: number, outside?: boolean) {\n this.volume = volume\n this.setFilter(minValue, maxValue, outside)\n }\n\n get header () { return this.volume.header }\n get matrix (): Matrix4 { return this.volume.matrix }\n get normalMatrix (): Matrix3 { return this.volume.normalMatrix }\n get inverseMatrix (): Matrix4 { return this.volume.inverseMatrix }\n get center (): Vector3 { return this.volume.center }\n get boundingBox (): Box3 { return this.volume.boundingBox }\n get min () { return this.volume.min }\n get max () { return this.volume.max }\n get mean () { return this.volume.mean }\n get rms () { return this.volume.rms }\n\n _getFilterHash (minValue: number, maxValue: number, outside: boolean) {\n return JSON.stringify([ minValue, maxValue, outside ])\n }\n\n setFilter (minValue: number|undefined, maxValue: number|undefined, outside: boolean|undefined) {\n if (isNaN(minValue) && this.header) {\n minValue = this.header.DMEAN + 2.0 * this.header.ARMS\n }\n\n minValue = (minValue !== undefined && !isNaN(minValue)) ? minValue : -Infinity\n maxValue = defaults(maxValue, Infinity) as number\n outside = defaults(outside, false) as boolean\n\n const data = this.volume.data\n const position = this.volume.position\n const atomindex = this.volume.atomindex\n\n const filterHash = this._getFilterHash(minValue, maxValue, outside)\n\n if (filterHash === this._filterHash) {\n // already filtered\n return\n } else if (minValue === -Infinity && maxValue === Infinity) {\n this.data = data\n this.position = position\n this.atomindex = atomindex!\n } else {\n const n = data.length\n\n if (!this._dataBuffer) {\n // ArrayBuffer for re-use as Float32Array backend\n\n this._dataBuffer = new ArrayBuffer(n * 4)\n this._positionBuffer = new ArrayBuffer(n * 3 * 4)\n if (atomindex) this._atomindexBuffer = new ArrayBuffer(n * 4)\n }\n\n const filteredData = new Float32Array(this._dataBuffer)\n const filteredPosition = new Float32Array(this._positionBuffer)\n let filteredAtomindex\n if (atomindex) filteredAtomindex = new Uint32Array(this._atomindexBuffer)\n\n let j = 0\n\n for (let i = 0; i < n; ++i) {\n const i3 = i * 3\n const v = data[ i ]\n\n if ((!outside && v >= minValue && v <= maxValue) ||\n (outside && (v < minValue || v > maxValue))\n ) {\n const j3 = j * 3\n\n filteredData[ j ] = v\n\n filteredPosition[ j3 + 0 ] = position[ i3 + 0 ]\n filteredPosition[ j3 + 1 ] = position[ i3 + 1 ]\n filteredPosition[ j3 + 2 ] = position[ i3 + 2 ]\n\n if (atomindex && filteredAtomindex) filteredAtomindex[ j ] = atomindex[ i ]\n\n j += 1\n }\n }\n\n // set views\n\n this.data = new Float32Array(this._dataBuffer, 0, j)\n this.position = new Float32Array(this._positionBuffer, 0, j * 3)\n if (atomindex) this.atomindex = new Int32Array(this._atomindexBuffer, 0, j)\n }\n\n this._filterHash = filterHash\n }\n}\n\nFilteredVolume.prototype.getValueForSigma = Volume.prototype.getValueForSigma\nFilteredVolume.prototype.getSigmaForValue = Volume.prototype.getSigmaForValue\n\nFilteredVolume.prototype.getDataAtomindex = Volume.prototype.getDataAtomindex\nFilteredVolume.prototype.getDataPosition = Volume.prototype.getDataPosition\nFilteredVolume.prototype.getDataColor = Volume.prototype.getDataColor\nFilteredVolume.prototype.getDataPicking = Volume.prototype.getDataPicking\nFilteredVolume.prototype.getDataSize = Volume.prototype.getDataSize\n\nexport default FilteredVolume\n","/**\n * @file Bond Hash\n * @author Alexander Rose \n * @private\n */\n\nimport BondStore from './bond-store'\nimport { createAdjacencyList } from '../utils/adjacency-list'\n\nclass BondHash {\n countArray: Uint8Array\n offsetArray: Int32Array\n indexArray: Int32Array\n\n constructor (bondStore: BondStore, atomCount: number) {\n const al = createAdjacencyList({\n nodeArray1: bondStore.atomIndex1,\n nodeArray2: bondStore.atomIndex2,\n edgeCount: bondStore.count,\n nodeCount: atomCount\n })\n\n this.countArray = al.countArray\n this.offsetArray = al.offsetArray\n this.indexArray = al.indexArray\n }\n}\n\nexport default BondHash\n","/**\n * @file Bond Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Bond store\n */\nexport default class BondStore extends Store {\n atomIndex1: Uint32Array\n atomIndex2: Uint32Array\n bondOrder: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'atomIndex1', 1, 'int32' ],\n [ 'atomIndex2', 1, 'int32' ],\n [ 'bondOrder', 1, 'int8' ]\n ] as StoreField[]\n }\n\n addBond (atom1: AtomProxy, atom2: AtomProxy, bondOrder?: number) {\n this.growIfFull()\n\n const i = this.count\n const ai1 = atom1.index\n const ai2 = atom2.index\n\n if (ai1 < ai2) {\n this.atomIndex1[ i ] = ai1\n this.atomIndex2[ i ] = ai2\n } else {\n this.atomIndex2[ i ] = ai1\n this.atomIndex1[ i ] = ai2\n }\n if (bondOrder) this.bondOrder[ i ] = bondOrder\n\n this.count += 1\n }\n\n addBondIfConnected (atom1: AtomProxy, atom2: AtomProxy, bondOrder?: number) {\n if (atom1.connectedTo(atom2)) {\n this.addBond(atom1, atom2, bondOrder)\n return true\n }\n\n return false\n }\n}","/**\n * @file Atom Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Atom store\n */\nexport default class AtomStore extends Store {\n residueIndex: Uint32Array\n atomTypeId: Uint16Array\n\n x: Float32Array\n y: Float32Array\n z: Float32Array\n serial: Int32Array\n bfactor: Float32Array\n altloc: Uint8Array\n occupancy: Float32Array\n\n partialCharge?: Float32Array\n formalCharge?: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'residueIndex', 1, 'uint32' ],\n [ 'atomTypeId', 1, 'uint16' ],\n\n [ 'x', 1, 'float32' ],\n [ 'y', 1, 'float32' ],\n [ 'z', 1, 'float32' ],\n [ 'serial', 1, 'int32' ],\n [ 'bfactor', 1, 'float32' ],\n [ 'altloc', 1, 'uint8' ],\n [ 'occupancy', 1, 'float32' ]\n ] as StoreField[]\n }\n\n setAltloc (i: number, str: string) {\n this.altloc[ i ] = str.charCodeAt(0)\n }\n\n getAltloc (i: number) {\n const code = this.altloc[ i ]\n return code ? String.fromCharCode(code) : ''\n }\n}","/**\n * @file Residue Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Residue store\n */\nexport default class ResidueStore extends Store {\n chainIndex: Uint32Array\n atomOffset: Uint32Array\n atomCount: Uint32Array\n residueTypeId: Uint16Array\n\n resno: Uint32Array\n sstruc: Uint8Array\n inscode: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'chainIndex', 1, 'uint32' ],\n [ 'atomOffset', 1, 'uint32' ],\n [ 'atomCount', 1, 'uint32' ],\n [ 'residueTypeId', 1, 'uint16' ],\n\n [ 'resno', 1, 'int32' ],\n [ 'sstruc', 1, 'uint8' ],\n [ 'inscode', 1, 'uint8' ]\n ] as StoreField[]\n }\n\n setSstruc (i: number, str: string) {\n this.sstruc[ i ] = str.charCodeAt(0)\n }\n\n getSstruc (i: number) {\n const code = this.sstruc[ i ]\n return code ? String.fromCharCode(code) : ''\n }\n\n setInscode (i: number, str: string) {\n this.inscode[ i ] = str.charCodeAt(0)\n }\n\n getInscode (i: number) {\n const code = this.inscode[ i ]\n return code ? String.fromCharCode(code) : ''\n }\n}","/**\n * @file Chain Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Chain store\n */\nexport default class ChainStore extends Store {\n entityIndex: Uint16Array\n modelIndex: Uint16Array\n residueOffset: Uint32Array\n residueCount: Uint32Array\n\n chainname: Uint8Array\n chainid: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'entityIndex', 1, 'uint16' ],\n [ 'modelIndex', 1, 'uint16' ],\n [ 'residueOffset', 1, 'uint32' ],\n [ 'residueCount', 1, 'uint32' ],\n\n [ 'chainname', 4, 'uint8' ],\n [ 'chainid', 4, 'uint8' ]\n ] as StoreField[]\n }\n\n setChainname (i: number, str: string) {\n const j = 4 * i\n this.chainname[ j ] = str.charCodeAt(0)\n this.chainname[ j + 1 ] = str.charCodeAt(1)\n this.chainname[ j + 2 ] = str.charCodeAt(2)\n this.chainname[ j + 3 ] = str.charCodeAt(3)\n }\n\n getChainname (i: number) {\n let chainname = ''\n for (let k = 0; k < 4; ++k) {\n const code = this.chainname[ 4 * i + k ]\n if (code) {\n chainname += String.fromCharCode(code)\n } else {\n break\n }\n }\n return chainname\n }\n\n setChainid (i: number, str: string) {\n const j = 4 * i\n this.chainid[ j ] = str.charCodeAt(0)\n this.chainid[ j + 1 ] = str.charCodeAt(1)\n this.chainid[ j + 2 ] = str.charCodeAt(2)\n this.chainid[ j + 3 ] = str.charCodeAt(3)\n }\n\n getChainid (i: number) {\n let chainid = ''\n for (let k = 0; k < 4; ++k) {\n const code = this.chainid[ 4 * i + k ]\n if (code) {\n chainid += String.fromCharCode(code)\n } else {\n break\n }\n }\n return chainid\n }\n}\n","/**\n * @file Model Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Model store\n */\nexport default class ModelStore extends Store {\n\tchainOffset: Uint32Array\n\tchainCount: Uint32Array\n\n get _defaultFields () {\n return [\n [ 'chainOffset', 1, 'uint32' ],\n [ 'chainCount', 1, 'uint32' ]\n ] as StoreField[]\n }\n}","/**\n * @file Helixorient\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport { ColormakerParameters } from '../color/colormaker'\nimport { AtomPicker } from '../utils/picker'\nimport RadiusFactory, { RadiusParams } from '../utils/radius-factory'\nimport { copyArray } from '../math/array-utils'\nimport { projectPointOnVector } from '../math/vector-utils'\nimport Polymer from '../proxy/polymer'\n\nexport interface HelixIterator {\n size: number\n next: () => Vector3\n get: (idx: number) => Vector3\n reset: () => void\n}\n\nexport interface HelixPosition {\n center: Float32Array\n axis: Float32Array\n bending: Float32Array\n radius: Float32Array\n rise: Float32Array\n twist: Float32Array\n resdir: Float32Array\n}\n\nclass Helixorient {\n size: number\n\n constructor (readonly polymer: Polymer) {\n this.size = polymer.residueCount\n }\n\n getCenterIterator (smooth = 0): HelixIterator {\n const center = this.getPosition().center\n const size = center.length / 3\n\n let i = 0\n let j = -1\n\n const cache = [\n new Vector3(),\n new Vector3(),\n new Vector3(),\n new Vector3()\n ]\n\n function next (this: HelixIterator) {\n const vector = this.get(j)\n j += 1\n return vector\n }\n\n function get (idx: number) {\n idx = Math.min(size - 1, Math.max(0, idx))\n const v = cache[ i % 4 ]\n const idx3 = 3 * idx\n v.fromArray(center as any, idx3) // TODO\n if (smooth) {\n const w = Math.min(smooth, idx, size - idx - 1)\n for (let k = 1; k <= w; ++k) {\n const l = k * 3\n const t = (w + 1 - k) / (w + 1)\n v.x += t * center[ idx3 - l + 0 ] + t * center[ idx3 + l + 0 ]\n v.y += t * center[ idx3 - l + 1 ] + t * center[ idx3 + l + 1 ]\n v.z += t * center[ idx3 - l + 2 ] + t * center[ idx3 + l + 2 ]\n }\n v.x /= w + 1\n v.y /= w + 1\n v.z /= w + 1\n }\n i += 1\n return v\n }\n\n function reset () {\n i = 0\n j = -1\n }\n\n return { size, next, get, reset }\n }\n\n getColor (params: { scheme: string } & ColormakerParameters) {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const residueIndexStart = polymer.residueIndexStart\n\n const col = new Float32Array(n * 3)\n\n const p = params || {}\n p.structure = structure\n\n const colormaker = ColormakerRegistry.getScheme(p)\n\n const rp = structure.getResidueProxy()\n const ap = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n rp.index = residueIndexStart + i\n ap.index = rp.traceAtomIndex\n\n colormaker.atomColorToArray(ap, col, i * 3)\n }\n\n return {\n 'color': col\n }\n }\n\n getPicking () {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const residueIndexStart = polymer.residueIndexStart\n\n const pick = new Float32Array(n)\n const rp = structure.getResidueProxy()\n\n for (let i = 0; i < n; ++i) {\n rp.index = residueIndexStart + i\n pick[ i ] = rp.traceAtomIndex\n }\n\n return {\n 'picking': new AtomPicker(pick, structure)\n }\n }\n\n getSize (params: RadiusParams) {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const residueIndexStart = polymer.residueIndexStart\n\n const size = new Float32Array(n)\n const radiusFactory = new RadiusFactory(params)\n\n const rp = structure.getResidueProxy()\n const ap = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n rp.index = residueIndexStart + i\n ap.index = rp.traceAtomIndex\n size[ i ] = radiusFactory.atomRadius(ap)\n }\n\n return { size }\n }\n\n getPosition (): HelixPosition {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const n3 = n - 3\n\n const center = new Float32Array(3 * n)\n const axis = new Float32Array(3 * n)\n const diff = new Float32Array(n)\n const radius = new Float32Array(n)\n const rise = new Float32Array(n)\n const twist = new Float32Array(n)\n const resdir = new Float32Array(3 * n)\n\n const r12 = new Vector3()\n const r23 = new Vector3()\n const r34 = new Vector3()\n\n const diff13 = new Vector3()\n const diff24 = new Vector3()\n\n const v1 = new Vector3()\n const v2 = new Vector3()\n const vt = new Vector3()\n\n const _axis = new Vector3()\n const _prevAxis = new Vector3()\n\n const _resdir = new Vector3()\n const _center = new Vector3(0, 0, 0)\n\n const type = 'trace'\n const a1 = structure.getAtomProxy()\n const a2 = structure.getAtomProxy(polymer.getAtomIndexByType(0, type))\n const a3 = structure.getAtomProxy(polymer.getAtomIndexByType(1, type))\n const a4 = structure.getAtomProxy(polymer.getAtomIndexByType(2, type))\n\n for (let i = 0; i < n3; ++i) {\n a1.index = a2.index\n a2.index = a3.index\n a3.index = a4.index\n a4.index = polymer.getAtomIndexByType(i + 3, type)! // TODO\n\n const j = 3 * i\n\n // ported from GROMACS src/tools/gmx_helixorient.c\n\n r12.subVectors(a2 as any, a1 as any) // TODO\n r23.subVectors(a3 as any, a2 as any) // TODO\n r34.subVectors(a4 as any, a3 as any) // TODO\n\n diff13.subVectors(r12, r23)\n diff24.subVectors(r23, r34)\n\n _axis.crossVectors(diff13, diff24).normalize()\n _axis.toArray(axis as any, j) // TODO\n\n if (i > 0) {\n diff[ i ] = _axis.angleTo(_prevAxis)\n }\n\n const tmp = Math.cos(diff13.angleTo(diff24))\n twist[ i ] = 180.0 / Math.PI * Math.acos(tmp)\n\n const diff13Length = diff13.length()\n const diff24Length = diff24.length()\n\n radius[ i ] = (\n Math.sqrt(diff24Length * diff13Length) /\n // clamp, to avoid instabilities for when\n // angle between diff13 and diff24 is near 0\n Math.max(2.0, 2.0 * (1.0 - tmp))\n )\n\n rise[ i ] = Math.abs(r23.dot(_axis))\n\n //\n\n v1.copy(diff13).multiplyScalar(radius[ i ] / diff13Length)\n v2.copy(diff24).multiplyScalar(radius[ i ] / diff24Length)\n\n v1.subVectors(a2 as any, v1) // TODO\n v2.subVectors(a3 as any, v2) // TODO\n\n v1.toArray(center as any, j + 3) // TODO\n v2.toArray(center as any, j + 6) // TODO\n\n //\n\n _resdir.subVectors(a1 as any, _center) // TODO\n _resdir.toArray(resdir as any, j) // TODO\n\n _prevAxis.copy(_axis)\n _center.copy(v1)\n }\n\n //\n\n // calc axis as dir of second and third center pos\n // project first traceAtom onto axis to get first center pos\n v1.fromArray(center as any, 3) // TODO\n v2.fromArray(center as any, 6) // TODO\n _axis.subVectors(v1, v2).normalize()\n // _center.copy( res[ 0 ].getTraceAtom() );\n a1.index = polymer.getAtomIndexByType(0, type)! // TODO\n _center.copy(a1 as any) // TODO\n vt.copy(a1 as any) // TODO\n projectPointOnVector(vt, _axis, v1)\n vt.toArray(center as any, 0) // TODO\n\n // calc first resdir\n _resdir.subVectors(_center, v1)\n _resdir.toArray(resdir as any, 0) // TODO\n\n // calc axis as dir of n-1 and n-2 center pos\n // project last traceAtom onto axis to get last center pos\n v1.fromArray(center as any, 3 * n - 6) // TODO\n v2.fromArray(center as any, 3 * n - 9) // TODO\n _axis.subVectors(v1, v2).normalize()\n // _center.copy( res[ n - 1 ].getTraceAtom() );\n a1.index = polymer.getAtomIndexByType(n - 1, type)! // TODO\n _center.copy(a1 as any) // TODO\n vt.copy(a1 as any) // TODO\n projectPointOnVector(vt, _axis, v1)\n vt.toArray(center as any, 3 * n - 3) // TODO\n\n // calc last three resdir\n for (let i = n - 3; i < n; ++i) {\n v1.fromArray(center as any, 3 * i) // TODO\n // _center.copy( res[ i ].getTraceAtom() );\n a1.index = polymer.getAtomIndexByType(i, type)! // TODO\n _center.copy(a1 as any) // TODO\n\n _resdir.subVectors(_center, v1)\n _resdir.toArray(resdir as any, 3 * i) // TODO\n }\n\n // average measures to define them on the residues\n\n const resRadius = new Float32Array(n)\n const resTwist = new Float32Array(n)\n const resRise = new Float32Array(n)\n const resBending = new Float32Array(n)\n\n resRadius[ 1 ] = radius[ 0 ]\n resTwist[ 1 ] = twist[ 0 ]\n resRise[ 1 ] = radius[ 0 ]\n\n for (let i = 2; i < n - 2; ++i) {\n resRadius[ i ] = 0.5 * (radius[ i - 2 ] + radius[ i - 1 ])\n resTwist[ i ] = 0.5 * (twist[ i - 2 ] + twist[ i - 1 ])\n resRise[ i ] = 0.5 * (rise[ i - 2 ] + rise[ i - 1 ])\n\n v1.fromArray(axis as any, 3 * (i - 2)) // TODO\n v2.fromArray(axis as any, 3 * (i - 1)) // TODO\n resBending[ i ] = 180.0 / Math.PI * Math.acos(Math.cos(v1.angleTo(v2)))\n }\n\n resRadius[ n - 2 ] = radius[ n - 4 ]\n resTwist[ n - 2 ] = twist[ n - 4 ]\n resRise[ n - 2 ] = rise[ n - 4 ]\n\n // average helix axes to define them on the residues\n\n const resAxis = new Float32Array(3 * n)\n\n copyArray(axis, resAxis, 0, 0, 3)\n copyArray(axis, resAxis, 0, 3, 3)\n\n for (let i = 2; i < n - 2; ++i) {\n v1.fromArray(axis as any, 3 * (i - 2)) // TODO\n v2.fromArray(axis as any, 3 * (i - 1)) // TODO\n\n _axis.addVectors(v2, v1).multiplyScalar(0.5).normalize()\n _axis.toArray(resAxis as any, 3 * i) // TODO\n }\n\n copyArray(axis, resAxis, 3 * n - 12, 3 * n - 6, 3)\n copyArray(axis, resAxis, 3 * n - 12, 3 * n - 3, 3)\n\n return {\n center,\n axis: resAxis,\n bending: resBending,\n radius: resRadius,\n rise: resRise,\n twist: resTwist,\n resdir: resdir\n }\n }\n\n}\n\nexport default Helixorient\n","/**\n * @file Helixbundle\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport { AtomPicker } from '../utils/picker'\nimport RadiusFactory, { RadiusParams } from '../utils/radius-factory'\nimport Helixorient, { HelixPosition } from './helixorient'\nimport { calculateMeanVector3, projectPointOnVector } from '../math/vector-utils'\nimport Polymer from '../proxy/polymer'\nimport { ColormakerParameters } from '../color/colormaker';\n\nexport interface Axis {\n axis: Float32Array\n center: Float32Array\n begin: Float32Array\n end: Float32Array\n color: Float32Array\n picking: AtomPicker\n size: Float32Array\n residueOffset: number[]\n residueCount: number[]\n}\n\nclass Helixbundle {\n helixorient: Helixorient;\n position: HelixPosition;\n\n constructor (readonly polymer: Polymer) {\n\n this.helixorient = new Helixorient(polymer)\n this.position = this.helixorient.getPosition()\n }\n\n getAxis (localAngle: number, centerDist: number, ssBorder: boolean, colorParams: { scheme: string} & ColormakerParameters, radiusParams: RadiusParams): Axis {\n localAngle = localAngle || 30\n centerDist = centerDist || 2.5\n ssBorder = ssBorder === undefined ? false : ssBorder\n\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const residueIndexStart = polymer.residueIndexStart\n\n const pos = this.position\n\n const cp = colorParams || {}\n cp.structure = structure\n\n const colormaker = ColormakerRegistry.getScheme(cp)\n\n const radiusFactory = new RadiusFactory(radiusParams)\n\n let j = 0\n let k = 0\n\n const axis: number[] = []\n const center: number[] = []\n const beg: number[] = []\n const end: number[] = []\n const col: number[] = []\n const pick = []\n const size = []\n const residueOffset = []\n const residueCount = []\n\n let tmpAxis = new Float32Array(n * 3)\n let tmpCenter = new Float32Array(n * 3)\n\n let _axis, _center\n const _beg = new Vector3()\n const _end = new Vector3()\n\n const rp1 = structure.getResidueProxy()\n const rp2 = structure.getResidueProxy()\n const ap = structure.getAtomProxy()\n\n const c1 = new Vector3()\n const c2 = new Vector3()\n\n let split = false\n\n for (let i = 0; i < n; ++i) {\n rp1.index = residueIndexStart + i\n c1.fromArray(pos.center as any, i * 3)\n\n if (i === n - 1) {\n split = true\n } else {\n rp2.index = residueIndexStart + i + 1\n c2.fromArray(pos.center as any, i * 3 + 3)\n\n if (ssBorder && rp1.sstruc !== rp2.sstruc) {\n split = true\n } else if (c1.distanceTo(c2) > centerDist) {\n split = true\n } else if (pos.bending[ i ] > localAngle) {\n split = true\n }\n }\n\n if (split) {\n if (i - j < 4) {\n j = i\n split = false\n continue\n }\n\n ap.index = rp1.traceAtomIndex\n\n // ignore first and last axis\n tmpAxis = pos.axis.subarray(j * 3 + 3, i * 3)\n tmpCenter = pos.center.subarray(j * 3, i * 3 + 3)\n\n _axis = calculateMeanVector3(tmpAxis).normalize()\n _center = calculateMeanVector3(tmpCenter)\n\n _beg.fromArray(tmpCenter as any)\n projectPointOnVector(_beg, _axis, _center)\n\n _end.fromArray(tmpCenter as any, tmpCenter.length - 3)\n projectPointOnVector(_end, _axis, _center)\n\n _axis.subVectors(_end, _beg)\n\n _axis.toArray(axis as any, k)\n _center.toArray(center as any, k)\n _beg.toArray(beg as any, k)\n _end.toArray(end as any, k)\n\n colormaker.atomColorToArray(ap, col, k)\n\n pick.push(ap.index)\n\n size.push(radiusFactory.atomRadius(ap))\n\n residueOffset.push(residueIndexStart + j)\n residueCount.push(residueIndexStart + i + 1 - j)\n\n k += 3\n j = i\n split = false\n }\n }\n\n const picking = new Float32Array(pick)\n\n return {\n axis: new Float32Array(axis),\n center: new Float32Array(center),\n begin: new Float32Array(beg),\n end: new Float32Array(end),\n color: new Float32Array(col),\n picking: new AtomPicker(picking, structure),\n size: new Float32Array(size),\n residueOffset: residueOffset,\n residueCount: residueCount\n }\n }\n}\n\nexport default Helixbundle\n","/**\n * @file Binary Heap\n * @author Alexander Rose \n * @private\n */\n\n/**\n * Binary heap implementation\n * @class\n * @author http://eloquentjavascript.net/appendix2.htm\n * @param {Function} scoreFunction - the heap scoring function\n */\nclass BinaryHeap {\n content: T[] = []\n\n constructor(readonly scoreFunction: (x: T) => number) {\n\n this.scoreFunction = scoreFunction\n }\n\n push (element: T) {\n // Add the new element to the end of the array.\n this.content.push(element)\n\n // Allow it to bubble up.\n this.bubbleUp(this.content.length - 1)\n }\n\n pop () {\n // Store the first element so we can return it later.\n const result = this.content[ 0 ]\n\n // Get the element at the end of the array.\n const end = this.content.pop()\n\n // If there are any elements left, put the end element at the\n // start, and let it sink down.\n if (end && this.content.length > 0) {\n this.content[ 0 ] = end\n this.sinkDown(0)\n }\n\n return result\n }\n\n peek () {\n return this.content[ 0 ]\n }\n\n remove (element: T) {\n const len = this.content.length\n\n // To remove a value, we must search through the array to find it.\n for (let i = 0; i < len; i++) {\n if (this.content[ i ] === element) {\n // When it is found, the process seen in 'pop' is repeated\n // to fill up the hole.\n const end = this.content.pop()\n\n if (end && i !== len - 1) {\n this.content[ i ] = end\n\n if (this.scoreFunction(end) < this.scoreFunction(element)) {\n this.bubbleUp(i)\n } else {\n this.sinkDown(i)\n }\n }\n\n return\n }\n }\n\n throw new Error('Node not found.')\n }\n\n size () {\n return this.content.length\n }\n\n bubbleUp (n: number) {\n // Fetch the element that has to be moved.\n const element = this.content[ n ]\n\n // When at 0, an element can not go up any further.\n while (n > 0) {\n // Compute the parent element's index, and fetch it.\n const parentN = Math.floor((n + 1) / 2) - 1\n const parent = this.content[ parentN ]\n\n // Swap the elements if the parent is greater.\n if (this.scoreFunction(element) < this.scoreFunction(parent)) {\n this.content[ parentN ] = element\n this.content[ n ] = parent\n\n // Update 'n' to continue at the new position.\n n = parentN\n } else {\n // Found a parent that is less, no need to move it further.\n break\n }\n }\n }\n\n sinkDown (n: number) {\n // Look up the target element and its score.\n const length = this.content.length\n const element = this.content[ n ]\n const elemScore = this.scoreFunction(element)\n\n let child1Score = 0\n let child2Score = 0\n\n while (true) {\n // Compute the indices of the child elements.\n const child2N = (n + 1) * 2\n const child1N = child2N - 1\n\n // This is used to store the new position of the element, if any.\n let swap = null\n\n // If the first child exists (is inside the array)...\n if (child1N < length) {\n // Look it up and compute its score.\n const child1 = this.content[ child1N ]\n child1Score = this.scoreFunction(child1)\n\n // If the score is less than our element's, we need to swap.\n if (child1Score < elemScore) swap = child1N\n }\n\n // Do the same checks for the other child.\n if (child2N < length) {\n const child2 = this.content[ child2N ]\n child2Score = this.scoreFunction(child2)\n\n if (child2Score < (swap === null ? elemScore : child1Score)) swap = child2N\n }\n\n // If the element needs to be moved, swap it, and continue.\n if (swap !== null) {\n this.content[ n ] = this.content[ swap ]\n this.content[ swap ] = element\n n = swap\n } else {\n // Otherwise, we are done.\n break\n }\n }\n }\n\n}\n\nexport default BinaryHeap\n","/**\n * @file Kdtree\n * @author Alexander Rose \n * @private\n */\n\nimport { NumberArray } from '../types'\nimport BinaryHeap from './binary-heap'\n\n/**\n * Kdtree\n * @class\n * @author Alexander Rose , 2016\n * @author Roman Bolzern , 2013\n * @author I4DS http://www.fhnw.ch/i4ds, 2013\n * @license MIT License \n * @description\n * k-d Tree for typed arrays of 3d points (e.g. for Float32Array), in-place\n * provides fast nearest neighbour search\n *\n * Based on https://github.com/ubilabs/kd-tree-javascript by Ubilabs\n *\n * Further information (including mathematical properties)\n * http://en.wikipedia.org/wiki/Binary_tree\n * http://en.wikipedia.org/wiki/K-d_tree\n *\n * @example\n * points: [x, y, z, x, y, z, x, y, z, ...]\n * metric: function(a, b){\n * return Math.pow(a[0]-b[0], 2) + Math.pow(a[1]-b[1], 2) + Math.pow(a[2]-b[2], 2);\n * }\n *\n * @param {Float32Array} points - points\n * @param {Function} metric - metric\n */\nclass Kdtree {\n indices: Uint32Array\n nodes: Int32Array\n rootIndex: number\n\n maxDepth = 0\n currentNode = 0\n\n constructor(readonly points: NumberArray, readonly metric: (a: NumberArray, b: NumberArray) => number) {\n const n = points.length / 3\n\n const indices = new Uint32Array(n)\n for (let i = 0; i < n; ++i) {\n indices[ i ] = i\n }\n this.indices = indices\n this.nodes = new Int32Array(n * 4)\n this.rootIndex = this.buildTree(0, -1, 0, n)\n }\n\n buildTree (depth: number, parent: number, arrBegin: number, arrEnd: number) {\n if (depth > this.maxDepth) this.maxDepth = depth\n\n const plength = arrEnd - arrBegin\n if (plength === 0) {\n return -1\n }\n\n const nodeIndex = this.currentNode * 4\n const nodes = this.nodes\n\n this.currentNode += 1\n if (plength === 1) {\n nodes[ nodeIndex ] = arrBegin\n nodes[ nodeIndex + 1 ] = -1\n nodes[ nodeIndex + 2 ] = -1\n nodes[ nodeIndex + 3 ] = parent\n return nodeIndex\n }\n // if(plength <= 32){\n // return nodeIndex;\n // }\n\n const indices = this.indices\n const points = this.points\n\n const arrMedian = arrBegin + Math.floor(plength / 2)\n const currentDim = depth % 3\n\n // inlined quickselect function\n let j, tmp, pivotIndex, pivotValue, storeIndex\n let left = arrBegin\n let right = arrEnd - 1\n while (right > left) {\n pivotIndex = (left + right) >> 1\n pivotValue = points[ indices[ pivotIndex ] * 3 + currentDim ]\n // swap( pivotIndex, right );\n tmp = indices[ pivotIndex ]\n indices[ pivotIndex ] = indices[ right ]\n indices[ right ] = tmp\n storeIndex = left\n for (j = left; j < right; ++j) {\n if (points[ indices[ j ] * 3 + currentDim ] < pivotValue) {\n // swap( storeIndex, j );\n tmp = indices[ storeIndex ]\n indices[ storeIndex ] = indices[ j ]\n indices[ j ] = tmp\n ++storeIndex\n }\n }\n // swap( right, storeIndex );\n tmp = indices[ right ]\n indices[ right ] = indices[ storeIndex ]\n indices[ storeIndex ] = tmp\n pivotIndex = storeIndex\n if (arrMedian === pivotIndex) {\n break\n } else if (arrMedian < pivotIndex) {\n right = pivotIndex - 1\n } else {\n left = pivotIndex + 1\n }\n }\n\n nodes[ nodeIndex ] = arrMedian\n nodes[ nodeIndex + 1 ] = this.buildTree(depth + 1, nodeIndex, arrBegin, arrMedian)\n nodes[ nodeIndex + 2 ] = this.buildTree(depth + 1, nodeIndex, arrMedian + 1, arrEnd)\n nodes[ nodeIndex + 3 ] = parent\n\n return nodeIndex\n }\n\n getNodeDepth (nodeIndex: number): number {\n const parentIndex = this.nodes[ nodeIndex + 3 ]\n return (parentIndex === -1) ? 0 : this.getNodeDepth(parentIndex) + 1\n }\n\n // TODO\n // function getNodePos (node) {}\n\n /**\n * find nearest points\n * @param {Array} point - array of size 3\n * @param {Integer} maxNodes - max amount of nodes to return\n * @param {Float} maxDistance - maximum distance of point to result nodes\n * @return {Array} array of point, distance pairs\n */\n nearest (point: NumberArray, maxNodes: number, maxDistance: number) {\n const bestNodes = new BinaryHeap<[number, number]>(e => -e[ 1 ])\n\n const nodes = this.nodes\n const points = this.points\n const indices = this.indices\n\n const nearestSearch = (nodeIndex: number) => {\n let bestChild, otherChild\n const dimension = this.getNodeDepth(nodeIndex) % 3\n const pointIndex = indices[ nodes[ nodeIndex ] ] * 3\n const ownPoint = [\n points[ pointIndex + 0 ],\n points[ pointIndex + 1 ],\n points[ pointIndex + 2 ]\n ]\n const ownDistance = this.metric(point, ownPoint)\n\n function saveNode (nodeIndex: number, distance: number) {\n bestNodes.push([ nodeIndex, distance ])\n if (bestNodes.size() > maxNodes) {\n bestNodes.pop()\n }\n }\n\n const leftIndex = nodes[ nodeIndex + 1 ]\n const rightIndex = nodes[ nodeIndex + 2 ]\n\n // if it's a leaf\n if (rightIndex === -1 && leftIndex === -1) {\n if ((bestNodes.size() < maxNodes || ownDistance < bestNodes.peek()[ 1 ]) &&\n ownDistance <= maxDistance\n ) {\n saveNode(nodeIndex, ownDistance)\n }\n return\n }\n\n if (rightIndex === -1) {\n bestChild = leftIndex\n } else if (leftIndex === -1) {\n bestChild = rightIndex\n } else {\n if (point[ dimension ] <= points[ pointIndex + dimension ]) {\n bestChild = leftIndex\n } else {\n bestChild = rightIndex\n }\n }\n\n // recursive search\n nearestSearch(bestChild)\n\n if ((bestNodes.size() < maxNodes || ownDistance < bestNodes.peek()[ 1 ]) &&\n ownDistance <= maxDistance\n ) {\n saveNode(nodeIndex, ownDistance)\n }\n\n // if there's still room or the current distance is nearer than the best distance\n const linearPoint = []\n for (let i = 0; i < 3; i += 1) {\n if (i === dimension) {\n linearPoint[ i ] = point[ i ]\n } else {\n linearPoint[ i ] = points[ pointIndex + i ]\n }\n }\n const linearDistance = this.metric(linearPoint, ownPoint)\n\n if ((bestNodes.size() < maxNodes || Math.abs(linearDistance) < bestNodes.peek()[ 1 ]) &&\n Math.abs(linearDistance) <= maxDistance\n ) {\n if (bestChild === leftIndex) {\n otherChild = rightIndex\n } else {\n otherChild = leftIndex\n }\n if (otherChild !== -1) {\n nearestSearch(otherChild)\n }\n }\n }\n\n nearestSearch(this.rootIndex)\n\n const result = []\n for (let i = 0, il = Math.min(bestNodes.size(), maxNodes); i < il; i += 1) {\n result.push(bestNodes.content[ i ])\n }\n\n return result\n }\n\n verify (nodeIndex?: number, depth = 0) {\n let count = 1\n\n if (nodeIndex === undefined) {\n nodeIndex = this.rootIndex\n }\n\n if (nodeIndex === -1) {\n throw new Error('node is null')\n }\n\n const dim = depth % 3\n const nodes = this.nodes\n const points = this.points\n const indices = this.indices\n\n const leftIndex = nodes[ nodeIndex + 1 ]\n const rightIndex = nodes[ nodeIndex + 2 ]\n\n if (leftIndex !== -1) {\n if (points[ indices[ nodes[ leftIndex ] ] * 3 + dim ] >\n points[ indices[ nodes[ nodeIndex ] ] * 3 + dim ]\n ) {\n throw new Error('left child is > parent!')\n }\n count += this.verify(leftIndex, depth + 1)\n }\n\n if (rightIndex !== -1) {\n if (points[ indices[ nodes[ rightIndex ] ] * 3 + dim ] <\n points[ indices[ nodes[ nodeIndex ] ] * 3 + dim ]\n ) {\n throw new Error('right child is < parent!')\n }\n count += this.verify(rightIndex, depth + 1)\n }\n\n return count\n }\n}\n\nexport default Kdtree\n","/**\n * @file Atom Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { NumberArray } from '../types'\nimport {\n Elements,\n SecStrucHelix, SecStrucSheet, SecStrucTurn,\n ProteinType, RnaType, DnaType, WaterType, IonType, SaccharideType,\n CgProteinBackboneType, CgRnaBackboneType, CgDnaBackboneType\n} from '../structure/structure-constants'\n\nimport Structure from '../structure/structure'\n\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\nimport AtomStore from '../store/atom-store'\n\nimport AtomMap from '../store/atom-map'\nimport ResidueMap from '../store/residue-map'\n\nimport BondProxy from '../proxy/bond-proxy'\nimport AtomType from '../store/atom-type';\nimport ResidueType from '../store/residue-type';\nimport ResidueProxy from './residue-proxy';\nimport Entity from '../structure/entity';\nimport BondHash from '../store/bond-hash';\n\n/**\n * Atom proxy\n */\nclass AtomProxy {\n index: number\n\n chainStore: ChainStore\n residueStore: ResidueStore\n atomStore: AtomStore\n\n residueMap: ResidueMap\n atomMap: AtomMap\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n this.atomStore = structure.atomStore\n this.residueMap = structure.residueMap\n this.atomMap = structure.atomMap\n }\n\n /**\n * @type {BondHash}\n */\n get bondHash (): BondHash|undefined { return this.structure.bondHash }\n\n /**\n * Molecular enity\n * @type {Entity}\n */\n get entity (): Entity {\n return this.structure.entityList[ this.entityIndex ]\n }\n get entityIndex () {\n return this.chainStore.entityIndex[ this.chainIndex ]\n }\n get modelIndex () {\n return this.chainStore.modelIndex[ this.chainIndex ]\n }\n get chainIndex () {\n return this.residueStore.chainIndex[ this.residueIndex ]\n }\n /**\n * @type {ResidueProxy}\n */\n get residue (): ResidueProxy {\n console.warn('residue - might be expensive')\n return this.structure.getResidueProxy(this.residueIndex)\n }\n\n get residueIndex () {\n return this.atomStore.residueIndex[ this.index ]\n }\n set residueIndex (value) {\n this.atomStore.residueIndex[ this.index ] = value\n }\n\n //\n\n /**\n * Secondary structure code\n * @type {String}\n */\n get sstruc () {\n return this.residueStore.getSstruc(this.residueIndex)\n }\n /**\n * Insertion code\n * @type {String}\n */\n get inscode () {\n return this.residueStore.getInscode(this.residueIndex)\n }\n /**\n * Residue number/label\n * @type {Integer}\n */\n get resno () {\n return this.residueStore.resno[ this.residueIndex ]\n }\n /**\n * Chain name\n * @type {String}\n */\n get chainname () {\n return this.chainStore.getChainname(this.chainIndex)\n }\n /**\n * Chain id\n * @type {String}\n */\n get chainid () {\n return this.chainStore.getChainid(this.chainIndex)\n }\n\n //\n\n /**\n * @type {ResidueType}\n */\n get residueType (): ResidueType {\n return this.residueMap.get(this.residueStore.residueTypeId[ this.residueIndex ])\n }\n /**\n * @type {AtomType}\n */\n get atomType (): AtomType {\n return this.atomMap.get(this.atomStore.atomTypeId[ this.index ])\n }\n get residueAtomOffset () {\n return this.residueStore.atomOffset[ this.residueIndex ]\n }\n\n //\n\n /**\n * Residue name\n */\n get resname () {\n return this.residueType.resname\n }\n /**\n * Hetero flag\n */\n get hetero () {\n return this.residueType.hetero\n }\n\n //\n\n /**\n * Atom name\n */\n get atomname () {\n return this.atomType.atomname\n }\n /**\n * Atomic number\n */\n get number () {\n return this.atomType.number\n }\n /**\n * Element\n */\n get element () {\n return this.atomType.element\n }\n /**\n * Van-der-Waals radius\n */\n get vdw () {\n return this.atomType.vdw\n }\n /**\n * Covalent radius\n */\n get covalent () {\n return this.atomType.covalent\n }\n\n //\n\n /**\n * X coordinate\n */\n get x () {\n return this.atomStore.x[ this.index ]\n }\n set x (value) {\n this.atomStore.x[ this.index ] = value\n }\n\n /**\n * Y coordinate\n */\n get y () {\n return this.atomStore.y[ this.index ]\n }\n set y (value) {\n this.atomStore.y[ this.index ] = value\n }\n\n /**\n * Z coordinate\n */\n get z () {\n return this.atomStore.z[ this.index ]\n }\n set z (value) {\n this.atomStore.z[ this.index ] = value\n }\n\n /**\n * Serial number\n */\n get serial () {\n return this.atomStore.serial[ this.index ]\n }\n set serial (value) {\n this.atomStore.serial[ this.index ] = value\n }\n\n /**\n * B-factor value\n */\n get bfactor () {\n return this.atomStore.bfactor[ this.index ]\n }\n set bfactor (value) {\n this.atomStore.bfactor[ this.index ] = value\n }\n\n /**\n * Occupancy value\n */\n get occupancy () {\n return this.atomStore.occupancy[ this.index ]\n }\n set occupancy (value) {\n this.atomStore.occupancy[ this.index ] = value\n }\n\n /**\n * Alternate location identifier\n */\n get altloc () {\n return this.atomStore.getAltloc(this.index)\n }\n set altloc (value) {\n this.atomStore.setAltloc(this.index, value)\n }\n\n /**\n * Partial charge\n */\n get partialCharge () {\n return this.atomStore.partialCharge ? this.atomStore.partialCharge[ this.index ] : null\n }\n set partialCharge (value) {\n if (this.atomStore.partialCharge) {\n this.atomStore.partialCharge[ this.index ] = value as number\n }\n }\n\n /**\n * Explicit radius\n */\n get radius () {\n return this.atomStore.radius ? this.atomStore.radius[ this.index ] : null\n }\n set radius (value) {\n if (this.atomStore.radius) {\n this.atomStore.radius[ this.index ] = value as number\n }\n }\n\n /**\n * Formal charge\n */\n get formalCharge () {\n return this.atomStore.formalCharge ? this.atomStore.formalCharge[ this.index ] : null\n }\n set formalCharge (value) {\n if (this.atomStore.formalCharge) {\n this.atomStore.formalCharge[ this.index ] = value as number\n }\n }\n\n /**\n * Aromaticity flag\n */\n get aromatic () {\n if (this.atomStore.aromatic) {\n return this.atomStore.aromatic[ this.index ] as number\n } else {\n return this.residueType.isAromatic(this) ? 1 : 0\n }\n }\n set aromatic (value) {\n if (this.atomStore.aromatic) {\n this.atomStore.aromatic[ this.index ] = value as number\n }\n }\n\n //\n\n get bondCount () {\n return this.bondHash!.countArray[ this.index ] // TODO\n }\n\n //\n\n /**\n * Iterate over each bond\n * @param {function(bond: BondProxy)} callback - iterator callback function\n * @param {BondProxy} [bp] - optional target bond proxy for use in the callback\n * @return {undefined}\n */\n eachBond (callback: (bp: BondProxy) => void, bp?: BondProxy) {\n bp = bp || this.structure._bp\n const idx = this.index\n const bondHash = this.bondHash! // TODO\n const indexArray = bondHash.indexArray\n const n = bondHash.countArray[ idx ]\n const offset = bondHash.offsetArray[ idx ]\n\n for (let i = 0; i < n; ++i) {\n bp.index = indexArray[ offset + i ]\n callback(bp)\n }\n }\n\n /**\n * Iterate over each bonded atom\n * @param {function(atom: AtomProxy)} callback - iterator callback function\n * @param {AtomProxy} [ap] - optional target atom proxy for use in the callback\n * @return {undefined}\n */\n eachBondedAtom (callback: (ap: AtomProxy) => void, _ap?: AtomProxy) {\n const ap = _ap ? _ap : this.structure._ap\n const idx = this.index\n\n this.eachBond(function (bp) {\n ap.index = idx !== bp.atomIndex1 ? bp.atomIndex1 : bp.atomIndex2\n callback(ap)\n })\n this.index = idx\n }\n\n /**\n * Check if this atom is bonded to the given atom,\n * assumes both atoms are from the same structure\n * @param {AtomProxy} ap - the given atom\n * @return {Boolean} whether a bond exists or not\n */\n hasBondTo (ap: AtomProxy) {\n let flag = false\n this.eachBondedAtom(function (bap) {\n if (ap.index === bap.index) flag = true\n })\n return flag\n }\n\n bondToElementCount (element: Elements) {\n let count = 0\n const idx = this.index // Avoid reentrancy problems\n this.eachBondedAtom(function (bap) {\n if (bap.number === element) count += 1\n })\n this.index = idx\n return count\n }\n\n hasBondToElement (element: Elements) {\n return this.bondToElementCount(element) > 0\n }\n\n //\n\n /**\n * If atom is part of a backbone\n * @return {Boolean} flag\n */\n isBackbone () {\n const backboneIndexList = this.residueType.backboneIndexList\n if (backboneIndexList.length > 0) {\n return backboneIndexList.includes(this.index - this.residueAtomOffset)\n } else {\n return false\n }\n }\n\n /**\n * If atom is part of a polymer\n * @return {Boolean} flag\n */\n isPolymer () {\n if (this.structure.entityList.length > 0) {\n return this.entity.isPolymer()\n } else {\n const moleculeType = this.residueType.moleculeType\n return (\n moleculeType === ProteinType ||\n moleculeType === RnaType ||\n moleculeType === DnaType\n )\n }\n }\n\n /**\n * If atom is part of a sidechin\n * @return {Boolean} flag\n */\n isSidechain () {\n return this.isPolymer() && !this.isBackbone()\n }\n\n /**\n * If atom is part of a coarse-grain group\n * @return {Boolean} flag\n */\n isCg () {\n const backboneType = this.residueType.backboneType\n return (\n backboneType === CgProteinBackboneType ||\n backboneType === CgRnaBackboneType ||\n backboneType === CgDnaBackboneType\n )\n }\n\n isTrace () {\n return this.index === (this.residueType.traceAtomIndex + this.residueAtomOffset)\n }\n\n /**\n * If atom is part of a hetero group\n * @return {Boolean} flag\n */\n isHetero () {\n return this.residueType.hetero === 1\n }\n\n /**\n * If atom is part of a protein molecule\n * @return {Boolean} flag\n */\n isProtein () {\n return this.residueType.moleculeType === ProteinType\n }\n\n /**\n * If atom is part of a nucleic molecule\n * @return {Boolean} flag\n */\n isNucleic () {\n const moleculeType = this.residueType.moleculeType\n return moleculeType === RnaType || moleculeType === DnaType\n }\n\n /**\n * If atom is part of a rna\n * @return {Boolean} flag\n */\n isRna () {\n return this.residueType.moleculeType === RnaType\n }\n\n /**\n * If atom is part of a dna\n * @return {Boolean} flag\n */\n isDna () {\n return this.residueType.moleculeType === DnaType\n }\n\n /**\n * If atom is part of a water molecule\n * @return {Boolean} flag\n */\n isWater () {\n return this.residueType.moleculeType === WaterType\n }\n\n /**\n * If atom is part of an ion\n * @return {Boolean} flag\n */\n isIon () {\n return this.residueType.moleculeType === IonType\n }\n\n /**\n * If atom is part of a saccharide\n * @return {Boolean} flag\n */\n isSaccharide () {\n return this.residueType.moleculeType === SaccharideType\n }\n\n /**\n * If atom is part of a helix\n * @return {Boolean} flag\n */\n isHelix () {\n return SecStrucHelix.includes(this.sstruc)\n }\n\n /**\n * If atom is part of a sheet\n * @return {Boolean} flag\n */\n isSheet () {\n return SecStrucSheet.includes(this.sstruc)\n }\n\n /**\n * If atom is part of a turn\n * @return {Boolean} flag\n */\n isTurn () {\n return SecStrucTurn.includes(this.sstruc) && this.isProtein()\n }\n\n isBonded () {\n return this.bondHash!.countArray[ this.index ] !== 0 // TODO\n }\n\n /**\n * If atom is part of a ring\n * @return {Boolean} flag\n */\n isRing () {\n const atomRings = this.residueType.getRings()!.atomRings // TODO\n return atomRings[ this.index - this.residueAtomOffset ] !== undefined\n }\n\n isAromatic () {\n return this.aromatic === 1\n }\n\n isPolarHydrogen () {\n let result = false\n\n if (this.number !== 1) return result\n\n result = !this.hasBondToElement(Elements.C)\n\n return result\n }\n\n isMetal () { return this.atomType.isMetal() }\n isNonmetal () { return this.atomType.isNonmetal() }\n isMetalloid () { return this.atomType.isMetalloid() }\n isHalogen () { return this.atomType.isHalogen() }\n isDiatomicNonmetal () { return this.atomType.isDiatomicNonmetal() }\n isPolyatomicNonmetal () { return this.atomType.isPolyatomicNonmetal() }\n isAlkaliMetal () { return this.atomType.isAlkaliMetal() }\n isAlkalineEarthMetal () { return this.atomType.isAlkalineEarthMetal() }\n isNobleGas () { return this.atomType.isNobleGas() }\n isTransitionMetal () { return this.atomType.isTransitionMetal() }\n isPostTransitionMetal () { return this.atomType.isPostTransitionMetal() }\n isLanthanide () { return this.atomType.isLanthanide() }\n isActinide () { return this.atomType.isActinide() }\n\n getDefaultValence () { return this.atomType.getDefaultValence() }\n getValenceList () { return this.atomType.getValenceList() }\n getOuterShellElectronCount () { return this.atomType.getOuterShellElectronCount() }\n\n /**\n * Distance to another atom\n * @param {AtomProxy} atom - the other atom\n * @return {Number} the distance\n */\n distanceTo (atom: AtomProxy) {\n const taa = this.atomStore\n const aaa = atom.atomStore\n const ti = this.index\n const ai = atom.index\n const x = taa.x[ ti ] - aaa.x[ ai ]\n const y = taa.y[ ti ] - aaa.y[ ai ]\n const z = taa.z[ ti ] - aaa.z[ ai ]\n const distSquared = x * x + y * y + z * z\n return Math.sqrt(distSquared)\n }\n\n /**\n * If connected to another atom\n * @param {AtomProxy} atom - the other atom\n * @return {Boolean} flag\n */\n connectedTo (atom: AtomProxy) {\n const taa = this.atomStore\n const aaa = atom.atomStore\n const ti = this.index\n const ai = atom.index\n\n if (taa.altloc && aaa.altloc) {\n const ta = taa.altloc[ ti ] // use Uint8 value to compare\n const aa = aaa.altloc[ ai ] // no need to convert to char\n // 0 is the Null character, 32 is the space character\n if (!(ta === 0 || aa === 0 || ta === 32 || aa === 32 || (ta === aa))) return false\n }\n\n const x = taa.x[ ti ] - aaa.x[ ai ]\n const y = taa.y[ ti ] - aaa.y[ ai ]\n const z = taa.z[ ti ] - aaa.z[ ai ]\n\n const distSquared = x * x + y * y + z * z\n\n // if( this.isCg() ) console.log( this.qualifiedName(), Math.sqrt( distSquared ), distSquared )\n if (distSquared < 48.0 && this.isCg()) return true\n\n if (isNaN(distSquared)) return false\n\n const d = this.covalent + atom.covalent\n const d1 = d + 0.3\n const d2 = d - 0.5\n\n return distSquared < (d1 * d1) && distSquared > (d2 * d2)\n }\n\n /**\n * Set atom position from array\n * @param {Array|TypedArray} array - input array\n * @param {Integer} [offset] - the offset\n * @return {AtomProxy} this object\n */\n positionFromArray (array: NumberArray, offset = 0) {\n this.x = array[ offset + 0 ]\n this.y = array[ offset + 1 ]\n this.z = array[ offset + 2 ]\n\n return this\n }\n\n /**\n * Write atom position to array\n * @param {Array|TypedArray} [array] - target array\n * @param {Integer} [offset] - the offset\n * @return {Array|TypedArray} target array\n */\n positionToArray (array: NumberArray = [], offset = 0) {\n const index = this.index\n const atomStore = this.atomStore\n\n array[ offset + 0 ] = atomStore.x[ index ]\n array[ offset + 1 ] = atomStore.y[ index ]\n array[ offset + 2 ] = atomStore.z[ index ]\n\n return array\n }\n\n /**\n * Write atom position to vector\n * @param {Vector3} [v] - target vector\n * @return {Vector3} target vector\n */\n positionToVector3 (v?: Vector3) {\n if (v === undefined) v = new Vector3()\n\n v.x = this.x\n v.y = this.y\n v.z = this.z\n\n return v\n }\n\n /**\n * Set atom position from vector\n * @param {Vector3} v - input vector\n * @return {AtomProxy} this object\n */\n positionFromVector3 (v: Vector3) {\n this.x = v.x\n this.y = v.y\n this.z = v.z\n\n return this\n }\n\n /**\n * Add vector to atom position\n * @param {Vector3} v - input vector\n * @return {AtomProxy} this object\n */\n positionAdd (v: Vector3|AtomProxy) {\n this.x += v.x\n this.y += v.y\n this.z += v.z\n\n return this\n }\n\n /**\n * Subtract vector from atom position\n * @param {Vector3} v - input vector\n * @return {AtomProxy} this object\n */\n positionSub (v: Vector3|AtomProxy) {\n this.x -= v.x\n this.y -= v.y\n this.z -= v.z\n\n return this\n }\n\n /**\n * Get intra group/residue bonds\n * @param {Boolean} firstOnly - immediately return the first connected atomIndex\n * @return {Integer[]|Integer|undefined} connected atomIndices\n */\n getResidueBonds (firstOnly = false) {\n const residueAtomOffset = this.residueAtomOffset\n const relativeIndex = this.index - this.residueAtomOffset\n const bonds = this.residueType.getBonds()! // TODO\n const atomIndices1 = bonds.atomIndices1\n const atomIndices2 = bonds.atomIndices2\n let idx1, idx2, connectedAtomIndex\n let connectedAtomIndices: number[]|undefined\n\n if (!firstOnly) connectedAtomIndices = []\n\n idx1 = atomIndices1.indexOf(relativeIndex)\n while (idx1 !== -1) {\n connectedAtomIndex = atomIndices2[ idx1 ] + residueAtomOffset\n if (connectedAtomIndices) {\n connectedAtomIndices.push(connectedAtomIndex)\n idx1 = atomIndices1.indexOf(relativeIndex, idx1 + 1)\n } else {\n return connectedAtomIndex\n }\n }\n\n idx2 = atomIndices2.indexOf(relativeIndex)\n while (idx2 !== -1) {\n connectedAtomIndex = atomIndices1[ idx2 ] + residueAtomOffset\n if (connectedAtomIndices) {\n connectedAtomIndices.push(connectedAtomIndex)\n idx2 = atomIndices2.indexOf(relativeIndex, idx2 + 1)\n } else {\n return connectedAtomIndex\n }\n }\n\n return connectedAtomIndices\n }\n\n //\n\n qualifiedName (noResname = false) {\n var name = ''\n if (this.resname && !noResname) name += '[' + this.resname + ']'\n if (this.resno !== undefined) name += this.resno\n if (this.inscode) name += '^' + this.inscode\n if (this.chainname) name += ':' + this.chainname\n if (this.atomname) name += '.' + this.atomname\n if (this.altloc) name += '%' + this.altloc\n if (this.structure.modelStore.count > 1) name += '/' + this.modelIndex\n return name\n }\n\n /**\n * Clone object\n * @return {AtomProxy} cloned atom\n */\n clone () {\n return new AtomProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n index: this.index,\n residueIndex: this.residueIndex,\n\n resname: this.resname,\n x: this.x,\n y: this.y,\n z: this.z,\n element: this.element,\n chainname: this.chainname,\n resno: this.resno,\n serial: this.serial,\n vdw: this.vdw,\n covalent: this.covalent,\n hetero: this.hetero,\n bfactor: this.bfactor,\n altloc: this.altloc,\n atomname: this.atomname,\n modelIndex: this.modelIndex\n }\n }\n}\n\nexport default AtomProxy\n","/**\n * @file Kdtree\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { Debug, Log } from '../globals'\nimport _Kdtree from '../utils/kdtree'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\n\nfunction euclideanDistSq(a: number[], b: number[]) {\n const dx = a[0] - b[0]\n const dy = a[1] - b[1]\n const dz = a[2] - b[2]\n return dx * dx + dy * dy + dz * dz\n}\n\nfunction euclideanDist(a: number[], b: number[]) {\n return Math.sqrt(euclideanDistSq(a, b))\n}\n\nconst pointArray = new Float32Array(3)\n\nclass Kdtree {\n points: Float32Array\n atomIndices: Uint32Array\n kdtree: _Kdtree\n\n constructor(structure: Structure|ResidueProxy, useSquaredDist = false) {\n if (Debug) Log.time('Kdtree build')\n\n const metric = useSquaredDist ? euclideanDistSq : euclideanDist\n\n const points = new Float32Array(structure.atomCount * 3)\n const atomIndices = new Uint32Array(structure.atomCount)\n let i = 0\n\n structure.eachAtom(function (ap) {\n points[ i + 0 ] = ap.x\n points[ i + 1 ] = ap.y\n points[ i + 2 ] = ap.z\n atomIndices[ i / 3 ] = ap.index\n i += 3\n })\n\n this.atomIndices = atomIndices\n this.points = points\n this.kdtree = new _Kdtree(points, metric)\n\n if (Debug) Log.timeEnd('Kdtree build')\n\n // console.log(\"this.kdtree.verify()\", this.kdtree.verify())\n }\n\n nearest (point: number[]|Vector3, maxNodes: number, maxDistance: number) {\n // Log.time( \"Kdtree nearest\" );\n\n if (point instanceof Vector3) {\n point.toArray(pointArray as any)\n } else if (point instanceof AtomProxy) {\n point.positionToArray(pointArray)\n }\n\n const nodeList = this.kdtree.nearest(pointArray, maxNodes, maxDistance)\n\n const indices = this.kdtree.indices\n const nodes = this.kdtree.nodes\n const atomIndices = this.atomIndices\n const resultList = []\n\n for (let i = 0, n = nodeList.length; i < n; ++i) {\n const d = nodeList[ i ]\n const nodeIndex = d[ 0 ]\n const dist = d[ 1 ]\n\n resultList.push({\n index: atomIndices[ indices[ nodes[ nodeIndex ] ] ],\n distance: dist\n })\n }\n\n // Log.timeEnd( \"Kdtree nearest\" );\n\n return resultList\n }\n}\n\nexport default Kdtree\n","/**\n * @file Symmetry Constants\n * @author Alexander Rose \n * @private\n */\n\nexport const SymOpCode: { [k: string]: string } = {\n ' ': 'X',\n '!': 'Y',\n '#': 'Z',\n '$': '-X',\n '%': '-Y',\n '&': '-Z',\n \"'\": 'Y+1/2',\n '(': '1/2+X',\n ')': '1/2+Y',\n '*': '1/2-X',\n '+': '1/2+Z',\n ',': '1/2-Y',\n '-': '1/2-Z',\n '.': 'X+1/2',\n '/': 'Z+1/2',\n '0': '-X+1/2',\n '1': '-Y+1/2',\n '2': '-Z+1/2',\n '3': '1/4+X',\n '4': '1/4-Y',\n '5': '1/4+Z',\n '6': '1/4-X',\n '7': '1/4+Y',\n '8': '3/4-Y',\n '9': '3/4+Z',\n ':': '3/4+Y',\n ';': '3/4+X',\n '<': '3/4-X',\n '=': '1/4-Z',\n '>': '3/4-Z',\n '?': 'X-Y',\n '@': 'Y-X',\n 'A': 'Z+1/3',\n 'B': 'Z+2/3',\n 'C': 'X+2/3',\n 'D': 'Y+1/3',\n 'E': '-Y+2/3',\n 'F': 'X-Y+1/3',\n 'G': 'Y-X+2/3',\n 'H': '-X+1/3',\n 'I': 'X+1/3',\n 'J': 'Y+2/3',\n 'K': '-Y+1/3',\n 'L': 'X-Y+2/3',\n 'M': 'Y-X+1/3',\n 'N': '-X+2/3',\n 'O': '2/3+X',\n 'P': '1/3+Y',\n 'Q': '1/3+Z',\n 'R': '2/3-Y',\n 'S': '1/3+X-Y',\n 'T': '2/3+Y-X',\n 'U': '1/3-X',\n 'V': '2/3-X',\n 'W': '1/3-Y',\n 'X': '1/3-Z',\n 'Y': '2/3+Y',\n 'Z': '1/3+Y-X',\n '[': '2/3+X-Y',\n ']': '1/3+X',\n '^': '2/3+Z',\n '_': '2/3-Z',\n '`': '5/6+Z',\n 'a': '1/6+Z',\n 'b': '5/6-Z',\n 'c': '1/6-Z',\n 'd': 'Z+5/6',\n 'e': 'Z+1/6',\n 'f': 'Z+1/4',\n 'g': '+Y'\n}\n\n// encoded, originally from CCP4 symop.lib\nexport const EncodedSymOp: { [k: string]: string } = {\n 'P 1': ' !#',\n 'P -1': ' !#$%&',\n 'P 1 2 1': ' !#$!&',\n 'P 1 21 1': \" !#$'&\",\n 'C 1 2 1': ' !#$!&()#*)&',\n 'P 1 m 1': ' !# %#',\n 'P 1 c 1': ' !# %+',\n 'C 1 m 1': ' !# %#()#(,#',\n 'C 1 c 1': ' !# %+()#(,+',\n 'P 1 2/m 1': ' !# %#$!&$%&',\n 'P 1 21/m 1': ' !#$)&$%& ,#',\n 'C 1 2/m 1': ' !# %#$!&$%&()#(,#*)&*,&',\n 'P 1 2/c 1': ' !#$!-$%& %+',\n 'P 1 21/c 1': ' !#$%&$)- ,+',\n 'C 1 2/c 1': ' !#$!-$%& %+()#*)-*,&(,+',\n 'P 2 2 2': ' !#$%#$!& %&',\n 'P 2 2 21': ' !#$%+$!- %&',\n 'P 21 21 2': ' !#$%#*)&(,&',\n 'P 21 21 21': ' !#*%+$)-(,&',\n 'C 2 2 21': ' !#$%+$!- %&()#*,+*)-(,&',\n 'C 2 2 2': ' !#$%#$!& %&()#*,#*)&(,&',\n 'F 2 2 2': ' !#$%#$!& %& )+$,+$)- ,-(!+*%+*!-(%-()#*,#*)&(,&',\n 'I 2 2 2': \" !#$%# %&$!&.'/01/.120'2\",\n 'I 21 21 21': ' !#*%+$)-(,&()+$,#*!& %-',\n 'P m m 2': ' !#$%# %#$!#',\n 'P m c 21': ' !#$%+ %+$!#',\n 'P c c 2': ' !#$%# %+$!+',\n 'P m a 2': ' !#$%#(%#*!#',\n 'P c a 21': ' !#$%+(%#*!+',\n 'P n c 2': ' !#$%# ,+$)+',\n 'P m n 21': ' !#*%+(%+$!#',\n 'P b a 2': ' !#$%#(,#*)#',\n 'P n a 21': ' !#$%+(,#*)+',\n 'P n n 2': ' !#$%#(,+*)+',\n 'C m m 2': ' !#$%# %#$!#()#*,#(,#*)#',\n 'C m c 21': ' !#$%+ %+$!#()#*,+(,+*)#',\n 'C c c 2': ' !#$%# %+$!+()#*,#(,+*)+',\n 'A m m 2': ' !#$%# %#$!# )+$,+ ,+$)+',\n 'A b m 2': ' !#$%# ,#$)# )+$,+ %+$!+',\n 'A m a 2': ' !#$%#(%#*!# )+$,+(,+*)+',\n 'A b a 2': ' !#$%#(,#*)# )+$,+(%+*!+',\n 'F m m 2': ' !#$%# %#$!# )+$,+ ,+$)+(!+*%+(%+*!+()#*,#(,#*)#',\n 'F d d 2': ' !#$%#345675 )+$,+3896:9(!+*%+;49<79()#*,#;85<:5',\n 'I m m 2': ' !#$%# %#$!#()+*,+(,+*)+',\n 'I b a 2': ' !#$%#(,#*)#()+*,+ %+$!+',\n 'I m a 2': ' !#$%#(%#*!#()+*,+ ,+$)+',\n 'P 2/m 2/m 2/m': ' !#$%#$!& %&$%& !& %#$!#',\n 'P 2/n 2/n 2/n': ' !#$%#$!& %&*,-()-(,+*)+',\n 'P 2/c 2/c 2/m': ' !#$%#$!- %-$%& !& %+$!+',\n 'P 2/b 2/a 2/n': ' !#$%#$!& %&*,&()&(,#*)#',\n 'P 21/m 2/m 2/a': ' !#*%#$!&(%&$%&(!& %#*!#',\n 'P 2/n 21/n 2/a': ' !#*%#*)- ,-$%&(!&(,+$)+',\n 'P 2/m 2/n 21/a': ' !#*%+*!- %&$%&(!-(%+$!#',\n 'P 21/c 2/c 2/a': ' !#*%#$!-(%-$%&(!& %+*!+',\n 'P 21/b 21/a 2/m': ' !#$%#*)&(,&$%& !&(,#*)#',\n 'P 21/c 21/c 2/n': ' !#*,#$)-(%-$%&()& ,+*!+',\n 'P 2/b 21/c 21/m': ' !#$%+$)- ,&$%& !- ,+$)#',\n 'P 21/n 21/n 2/m': ' !#$%#*)-(,-$%& !&(,+*)+',\n 'P 21/m 21/m 2/n': \" !#$%#*'&.,&*,&.'& %#$!#\",\n 'P 21/b 2/c 21/n': ' !#*,+$!-(,&$%&()- %+*)#',\n 'P 21/b 21/c 21/a': ' !#*%+$)-(,&$%&(!- ,+*)#',\n 'P 21/n 21/m 21/a': \" !#0%/$'&.12$%&.!2 1#0'/\",\n 'C 2/m 2/c 21/m': ' !#$%+$!- %&$%& !- %+$!#()#*,+*)-(,&*,&()-(,+*)#',\n 'C 2/m 2/c 21/a': ' !#$,+$)- %&$%& )- ,+$!#()#*%+*!-(,&*,&(!-(%+*)#',\n 'C 2/m 2/m 2/m': ' !#$%#$!& %&$%& !& %#$!#()#*,#*)&(,&*,&()&(,#*)#',\n 'C 2/c 2/c 2/m': ' !#$%#$!- %-$%& !& %+$!+()#*,#*)-(,-*,&()&(,+*)+',\n 'C 2/m 2/m 2/a': ' !#$,#$)& %&$%& )& ,#$!#()#*%#*!&(,&*,&(!&(%#*)#',\n 'C 2/c 2/c 2/a': ' !#*,#$!&(,&$,-(!- ,+*!+()#$%#*)& %&*%- )-(%+$)+',\n 'F 2/m 2/m 2/m': ' !#$%#$!& %&$%& !& %#$!# )+$,+$)- ,-$,- )- ,+$)+(!+*%+*!-(%-*%-(!-(%+*!+()#*,#*)&(,&*,&()&(,#*)#',\n 'F 2/d 2/d 2/d': ' !#$%#$!& %&64=37=345675 )+$,+$)- ,-68>3:>3896:9(!+*%+*!-(%-<4>;7>;49<79()#*,#*)&(,&<8=;:=;85<:5',\n 'I 2/m 2/m 2/m': ' !#$%#$!& %&$%& !& %#$!#()+*,+*)-(,-*,-()-(,+*)+',\n 'I 2/b 2/a 2/m': ' !#$%#*)&(,&$%& !&(,#*)#()+*,+$!- %-*,-()- %+$!+',\n 'I 21/b 21/c 21/a': ' !#*%+$)-(,&$%&(!- ,+*)#()+$,#*!& %-*,- )&(%#$!+',\n 'I 21/m 21/m 21/a': ' !#$,#$)& %&$%& )& ,#$!#()+*%+*!-(,-*,-(!-(%+*)+',\n 'P 4': ' !#$%#% #!$#',\n 'P 41': ' !#$%+% 5!$9',\n 'P 42': ' !#$%#% +!$+',\n 'P 43': ' !#$%+% 9!$5',\n 'I 4': ' !#$%#% #!$#()+*,+,(+)*+',\n 'I 41': ' !#*,+%(5)$9()+$%#, 9!*5',\n 'P -4': ' !#$%#!$&% &',\n 'I -4': ' !#$%#!$&% &()+*,+)*-,(-',\n 'P 4/m': ' !#$%#% #!$#$%& !&!$&% &',\n 'P 42/m': ' !#$%#% +!$+$%& !&!$-% -',\n 'P 4/n': ' !#$%#,(#)*#*,&()&!$&% &',\n 'P 42/n': ' !#$%#,(+)*+*,-()-!$&% &',\n 'I 4/m': ' !#$%#% #!$#$%& !&!$&% &()+*,+,(+)*+*,-()-)*-,(-',\n 'I 41/a': ' !#*,+%(5)$9$,=(!>!$&,(-()+$%#, 9!*5*%> )=)*-% &',\n 'P 4 2 2': ' !#$%#% #!$#$!& %&! &%$&',\n 'P 4 21 2': ' !#$%#,(#)*#*)&(,&! &%$&',\n 'P 41 2 2': ' !#$%+% 5!$9$!& %-! >%$=',\n 'P 41 21 2': ' !#$%+,(5)*9*)=(,>! &%$-',\n 'P 42 2 2': ' !#$%#% +!$+$!& %&! -%$-',\n 'P 42 21 2': ' !#$%#,(+)*+*)-(,-! &%$&',\n 'P 43 2 2': ' !#$%+% 9!$5$!& %-! =%$>',\n 'P 43 21 2': ' !#$%+,(9)*5*)>(,=! &%$-',\n 'I 4 2 2': ' !#$%#% #!$#$!& %&! &%$&()+*,+,(+)*+*)-(,-)(-,*-',\n 'I 41 2 2': ' !#*,+%(5)$9*!> ,=)(-%$&()+$%#, 9!*5$)=(%>! &,*-',\n 'P 4 m m': ' !#$%#% #!$# %#$!#%$#! #',\n 'P 4 b m': ' !#$%#% #!$#(,#*)#,*#)(#',\n 'P 42 c m': ' !#$%#% +!$+ %+$!+%$#! #',\n 'P 42 n m': ' !#$%#,(+)*+(,+*)+%$#! #',\n 'P 4 c c': ' !#$%#% #!$# %+$!+%$+! +',\n 'P 4 n c': ' !#$%#% #!$#(,+*)+,*+)(+',\n 'P 42 m c': ' !#$%#% +!$+ %#$!#%$+! +',\n 'P 42 b c': ' !#$%#% +!$+(,#*)#,*+)(+',\n 'I 4 m m': ' !#$%#% #!$# %#$!#%$#! #()+*,+,(+)*+(,+*)+,*+)(+',\n 'I 4 c m': ' !#$%#% #!$# %+$!+%$+! +()+*,+,(+)*+(,#*)#,*#)(#',\n 'I 41 m d': ' !#*,+%(5)$9 %#*)+%*5) 9()+$%#, 9!*5(,+$!#,$9!(5',\n 'I 41 c d': ' !#*,+%(5)$9 %+*)#%*9) 5()+$%#, 9!*5(,#$!+,$5!(9',\n 'P -4 2 m': ' !#$%#% &!$&$!& %&%$#! #',\n 'P -4 2 c': ' !#$%#% &!$&$!- %-%$+! +',\n 'P -4 21 m': ' !#$%#% &!$&*)&(,&,*#)(#',\n 'P -4 21 c': ' !#$%#% &!$&*)-(,-,*+)(+',\n 'P -4 m 2': ' !#$%#!$&% & %#$!#! &%$&',\n 'P -4 c 2': ' !#$%#% &!$& %+$!+! -%$-',\n 'P -4 b 2': ' !#$%#% &!$&(,#*)#)(&,*&',\n 'P -4 n 2': ' !#$%#% &!$&(,+*)+)(-,*-',\n 'I -4 m 2': ' !#$%#% &!$& %#$!#! &%$&()+*,+,(-)*-(,+*)+)(-,*-',\n 'I -4 c 2': ' !#$%#% &!$& %+$!+! -%$-()+*,+,(-)*-(,#*)#)(&,*&',\n 'I -4 2 m': ' !#$%#% &!$&$!& %&%$#! #()+*,+,(-)*-*)-(,-,*+)(+',\n 'I -4 2 d': ' !#$%#% &!$&*!>(%>,$9) 9()+*,+,(-)*-$)= ,=%*5!(5',\n 'P 4/m 2/m 2/m': ' !#$%#% #!$#$!& %&! &%$&$%& !&!$&% & %#$!#%$#! #',\n 'P 4/m 2/c 2/c': ' !#$%#% #!$#$!- %-! -%$-$%& !&!$&% & %+$!+%$+! +',\n 'P 4/n 2/b 2/m': ' !#$%#% #!$#$!& %&! &%$&*,&()&)*&,(&(,#*)#,*#)(#',\n 'P 4/n 2/n 2/c': ' !#$%#% #!$#$!& %&! &%$&*,-()-)*-,(-(,+*)+,*+)(+',\n 'P 4/m 21/b 2/m': ' !#$%#% #!$#*)&(,&)(&,*&$%& !&!$&% &(,#*)#,*#)(#',\n 'P 4/m 21/n 2/c': ' !#$%#% #!$#*)-(,-)(-,*-$%& !&!$&% &(,+*)+,*+)(+',\n 'P 4/n 21/m 2/m': ' !#$%#,(#)*#*)&(,&! &%$&*,&()&!$&% & %#$!#,*#)(#',\n 'P 4/n 2/c 2/c': ' !#$%#,(#)*#*)-(,-! -%$-*,&()&!$&% & %+$!+,*+)(+',\n 'P 42/m 2/m 2/c': ' !#$%#% +!$+$!& %&! -%$-$%& !&!$-% - %#$!#%$+! +',\n 'P 42/m 2/c 2/m': ' !#$%#% +!$+$!- %-! &%$&$%& !&!$-% - %+$!+%$#! #',\n 'P 42/n 2/b 2/c': ' !#$%#,(+)*+$!- %-)(&,*&*,-()-!$&% &(,#*)#%$+! +',\n 'P 42/n 2/n 2/m': ' !#$%#,(+)*+$!& %&)(-,*-*,-()-!$&% &(,+*)+%$#! #',\n 'P 42/m 21/b 2/c': ' !#$%#% +!$+*)&(,&)(-,*-$%& !&!$-% -(,#*)#,*+)(+',\n 'P 42/m 21/n 2/m': \" !#$%#,./'*/*'-.,-! &%$&$%& !&'*-,.-.,/*'/%$#! #\",\n 'P 42/n 21/m 2/c': ' !#$%#,(+)*+*)-(,-! &%$&*,-()-!$&% & %#$!#,*+)(+',\n 'P 42/n 21/c 2/m': ' !#$%#,(+)*+*)&(,&! -%$-*,-()-!$&% & %+$!+,*#)(#',\n 'I 4/m 2/m 2/m': ' !#$%#% #!$#$!& %&! &%$&$%& !&!$&% & %#$!#%$#! #()+*,+,(+)*+*)-(,-)(-,*-*,-()-)*-,(-(,+*)+,*+)(+',\n 'I 4/m 2/c 2/m': ' !#$%#% #!$#$!- %-! -%$-$%& !&!$&% & %+$!+%$+! +()+*,+,(+)*+*)&(,&)(&,*&*,-()-)*-,(-(,#*)#,*#)(#',\n 'I 41/a 2/m 2/d': ' !#*,+%(5)$9*!> ,=)(-%$&$,=(!>!$&,(-(,+$!#,$9!(5()+$%#, 9!*5$)=(%>! &,*-*%> )=)*-% & %#*)+%*5) 9',\n 'I 41/a 2/c 2/d': ' !#*,+%(5)$9*!= ,>)(&%$-$,=(!>!$&,(-(,#$!+,$5!(9()+$%#, 9!*5$)>(%=! -,*&*%> )=)*-% & %+*)#%*9) 5',\n 'P 3': ' !#%?#@$#',\n 'P 31': ' !#%?A@$B',\n 'P 32': ' !#%?B@$A',\n 'H 3': ' !#%?#@$#CDAEFAGHAIJBKLBMNB',\n 'R 3': ' !## !!# ',\n 'P -3': ' !#%?#@$#$%&!@&? &',\n 'H -3': ' !#%?#@$#$%&!@&? &OPQRSQTUQ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',\n 'H -3 2/c': ' !#%?#@$#! -?%-$@-$%&!@&? &%$+@!+ ?+OPQRSQTUQY]b[WbVZbVWXYZX[]XRU`TP`OS`]Y^W[^ZV^POcSRcUTcUR_PT_SO_WVaZYa][a',\n 'R -3 2/c': \" !## !!# 102021210$%&&$%%&$'././'/'.\",\n 'P 6': ' !#%?#@$#$%#!@#? #',\n 'P 61': ' !#%?A@$B$%/!@d? e',\n 'P 65': ' !#%?B@$A$%/!@e? d',\n 'P 62': ' !#%?^@$Q$%#!@^? Q',\n 'P 64': ' !#%?Q@$^$%#!@Q? ^',\n 'P 63': ' !#%?#@$#$%+!@+? +',\n 'P -6': ' !#%?#@$# !&%?&@$&',\n 'P 6/m': ' !#%?#@$#$%#!@#? #$%&!@&? & !&%?&@$&',\n 'P 63/m': ' !#%?#@$#$%+!@+? +$%&!@&? & !-%?-@$-',\n 'P 6 2 2': ' !#%?#@$#$%#!@#? #! &?%&$@&%$&@!& ?&',\n 'P 61 2 2': ' !#%?Q@$^$%+!@`? a! X?%&$@_%$b@!- ?c',\n 'P 65 2 2': ' !#%?^@$Q$%+!@a? `! _?%&$@X%$c@!- ?b',\n 'P 62 2 2': ' !#%?^@$Q$%#!@^? Q! _?%&$@X%$_@!& ?X',\n 'P 64 2 2': ' !#%?Q@$^$%#!@Q? ^! X?%&$@_%$X@!& ?_',\n 'P 63 2 2': ' !#%?#@$#$%+!@+? +! &?%&$@&%$-@!- ?-',\n 'P 6 m m': ' !#%?#@$#$%#!@#? #%$#@!# ?#! #?%#$@#',\n 'P 6 c c': ' !#%?#@$#$%#!@#? #%$+@!+ ?+! +?%+$@+',\n 'P 63 c m': ' !#%?#@$#$%+!@+? +%$+@!+ ?+! #?%#$@#',\n 'P 63 m c': ' !#%?#@$#$%+!@+? +%$#@!# ?#! +?%+$@+',\n 'P -6 m 2': ' !#%?#@$# !&%?&@$&%$#@!# ?#%$&@!& ?&',\n 'P -6 c 2': ' !#%?#@$# !-%?-@$-%$+@!+ ?+%$&@!& ?&',\n 'P -6 2 m': ' !#%?#@$# !&%?&@$&! &?%&$@&! #?%#$@#',\n 'P -6 2 c': ' !#%?#@$# !-%?-@$-! &?%&$@&! +?%+$@+',\n 'P 6/m 2/m 2/m': ' !#%?#@$#$%#!@#? #! &?%&$@&%$&@!& ?&$%&!@&? & !&@$&%?&%$#@!# ?#! #?%#$@#',\n 'P 6/m 2/c 2/c': ' !#%?#@$#$%#!@#? #! -?%-$@-%$-@!- ?-$%&!@&? & !&@$&%?&%$+@!+ ?+! +?%+$@+',\n 'P 63/m 2/c 2/m': ' !#%?#@$#$%+!@+? +! -?%-$@-%$&@!& ?&$%&!@&? & !-@$-%?-%$+@!+ ?+! #?%#$@#',\n 'P 63/m 2/m 2/c': ' !#%?#@$#$%+!@+? +! &?%&$@&%$-@!- ?-$%&!@&? & !-@$-%?-%$#@!# ?#! +?%+$@+',\n 'P 2 3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ',\n 'F 2 3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ',\n 'I 2 3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-(',\n 'P 21 3': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(',\n 'I 21 3': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- ',\n 'P 2/m -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$',\n 'P 2/n -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& *,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*',\n 'F 2/m -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$ )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-($,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(*%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- *,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$',\n 'F 2/d -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& 64=37=345675=64=375345674=67=3453756 )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(68>3:>3896:9=<8=;:5;85<:4><7>;49;79<(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(<4>;7>;49<79>68>3:93896:8=<:=;85;:5<()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- <8=;:=;8f<:f><4>;79;49<78>6:>3893:96',\n 'I 2/m -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-(*,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*',\n 'P 21/a -3': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&($%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*',\n 'I 21/a -3': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&($%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*()+$,#*g& %-+()#$,&*!- %)+(,#$!&*%- *,- )&(%#$!+-*,& )#(%+$!,-*)& %#(!+$',\n 'P 4 3 2': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$',\n 'P 42 3 2': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*',\n 'F 4 3 2': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$ )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(-%*-!*+%(+ +,$+)$-, -)#)*#,(&)(&,*(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() -,$-)$+, +(#,*#)*&,(&)+!*+%(-!(-%*()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(&,*&)*#,(#(+%*+!*-%(-!+)$+, -) -,$',\n 'F 41 3 2': ' !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=46 )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<(!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>86',\n 'I 4 3 2': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*',\n 'P 43 3 2': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(7;>46=:<5839398<5:6=4;>75:<983>7;=46',\n 'P 41 3 2': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<',\n 'I 41 3 2': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- 7;>46=:<5839398<5:6=4;>75:<983>7;=46',\n 'P -4 3 m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% ',\n 'F -4 3 m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(+%*+!*-%(- +)$+,$-) -,#)(#,*&)*&,((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() +,$+)$-, -(#)*#,*&)(&,+!(+%*-!*-%(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(#,*#)*&,(&(+!*+%*-!(-%+) +,$-)$-, ',\n 'I -4 3 m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,(',\n 'P -4 3 n': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,(',\n 'F -4 3 c': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,( )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-() #,$#)$&, &(#!*#%*&!(&%+! +%$-!$-% (!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(!(#%*#!*&%(& +!$+%$-! -%#) #,$&)$&, ()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ! +%$+!$-% - #)$#,$&) &,#!(#%*&!*&%(',\n 'I -4 3 d': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(7354<9:6>8;=357<946>:;=857394<>:6=8;()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- :;98657<=43>;9:658<=73>49:;586=7<>43',\n 'P 4/m -3 2/m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ',\n 'P 4/n -3 2/n': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$*,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(',\n 'P 42/m -3 2/n': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(',\n 'P 42/n -3 2/m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,**,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ',\n 'F 4/m -3 2/m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(-%*-!*+%(+ +,$+)$-, -)#)*#,(&)(&,*$,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*%*+!(+%(-!*-$-) -, +)$+,&,(&)*#,*#)((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() -,$-)$+, +(#,*#)*&,(&)+!*+%(-!(-%**%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*,$+) +, -)$-*&)(&,(#)*#,-%(-!*+%*+!(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(&,*&)*#,(#(+%*+!*-%(-!+)$+, -) -,$*,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$,*#)(#,(&)*&*-!(-%(+!*+%-, -)$+,$+) ',\n 'F 4/m -3 2/c': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)( )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-() &,$&)$#, #(#%*#!*&%(&!+!$+% -! -%$$,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*,$#) #, &)$&*&!(&%(#!*#%-% -!$+%$+! (!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(!(&%*&!*#%(# +%$+!$-% -!#)$#, &) &,$*%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*%*#!(#%(&!*&$-! -% +!$+%&, &)$#,$#) ()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ! -%$-!$+% + #,$#)$&, &)#!*#%(&!(&%**,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$%$+! +% -!$-$&) &, #)$#,&%(&!*#%*#!(',\n 'F 41/d -3 2/m': ' !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=4664=3:>;85<79=64>3:5;89<74=6:>385;79<,$+! #%(-)*&*&)(-% #!$+,-%(&)*+,$#! )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<68>37=;49<:5=<8>;753496:4><:=;893756,*#!(+% &)$-*-!(&, +)$#%-, &!$+%*#)((!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<<4>;:=389675>68=379;45<:8=<7>;453:96%$#) +,(&!*-$&! -,(#)*+%&% -)$#,*+!(()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>86<8=;7>3456:9><4=;:9385678>67=349;:5<%*+)(#, -!$&$-) &%(+!*#,&,(-!*#%$+) ',\n 'F 41/d -3 2/c': ' !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=46<8>;7=3496:5><8=;793456:8><7=;493:56%*#)(+, &!$-$-! &,(+)*#%&, -!$#%*+)( )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<<4=;:>385679>64=3:9;85<78=67>345;:9<%$+) #,(-!*&$&) -%(#!*+,&%(-)*#,$+! (!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<68=37>;45<:9=<4>;:5389674>6:=389;75<,*+!(#% -)$&*-)(&% +!$#,-,(&!*+%$#) ()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>8664>3:=;89<75=68>375;49<:4=<:>;853796,$#! +%(&)*-*&!(-, #)$+%-% &)$+,*#!(',\n 'I 4/m -3 2/m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,**,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(',\n 'I 41/a -3 2/d': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<$%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*4<97358;=:6>6>:;=8357<94=8;>:694<573()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- 7;>46=:<5839398<5:6=4;>75:<983>7;=46*,- )&(%#$!+-*,& )#(%+$!,-*)& %#(!+$865:;943>7<=<=73>4;9:658>43=7<5869:;',\n 'P 1 1 2': ' !#$%#',\n 'P 1 1 21': ' !#$%+',\n 'B 1 1 2': ' !#$%#(g+*%+',\n 'A 1 2 1': ' !#$!& )+$)-',\n 'C 1 21 1': ' !#$)&()#*!&',\n 'I 1 2 1': \" !#$!&.'/0'2\",\n 'I 1 21 1': \" !#$)&.'/0!-\",\n 'P 1 1 m': ' !# !&',\n 'P 1 1 b': ' !# )&',\n 'B 1 1 m': ' !# !&(!+(!-',\n 'B 1 1 b': ' !# )&(!+()-',\n 'P 1 1 2/m': ' !# !&$%#$%&',\n 'P 1 1 21/m': ' !#$%+$%& !-',\n 'B 1 1 2/m': ' !# !&$%#$%&(!+(!-*%+*%-',\n 'P 1 1 2/b': ' !#$,#$%& )&',\n 'P 1 1 21/b': ' !#$%&$,+ )-',\n 'B 1 1 2/b': ' !#$,#$%& )&(!+*,+*%-()-',\n 'P 21 2 2': ' !#$!&(%&*%#',\n 'P 2 21 2': ' !# ,&$)&$%#',\n 'P 21 21 2 (a)': \" !#*,#.%&$'&\",\n 'P 21 2 21': ' !#$!&(%-*%+',\n 'P 2 21 21': ' !# %&$)-$,+',\n 'C 2 2 21a)': ' !#*%+(,&$)-()#$,+ %&*!-',\n 'C 2 2 2a': \" !#*,#.%&$'&()#$%# ,&*!&\",\n 'F 2 2 2a': \" !#*,#.%&$'& '/*%/.12$!2.!/$,/ %20'2.'#$%# 1&0!&\",\n 'I 2 2 2a': \" !#*,#.%&$'&()+$%+*!- ,-\",\n 'P 21/m 21/m 2/n a': \" !#*,#$)&(%&$%&.'& ,#*!#\",\n 'P 42 21 2a': \" !#*,#%.+'$+$'&.%&! -,*-\",\n 'I 2 3a': \" !#*,#.%&$'&!# ,- '&$%/$# !-*!/$%&.%()+$%+ ,-*!-)+(%&(!-*,#*+()&$)#*,- ,\"\n}\n","/**\n * @file Symmetry Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Log } from '../globals'\nimport { EncodedSymOp, SymOpCode } from './symmetry-constants'\n\nconst reInteger = /^[1-9]$/\n\nexport function getSymmetryOperations (spacegroup: string) {\n const encodedSymopList = EncodedSymOp[ spacegroup ]\n const matrixDict: { [k: string]: Matrix4 } = {}\n\n if (encodedSymopList === undefined) {\n console.warn(`spacegroup '${spacegroup}' not found in symop library`)\n return matrixDict\n }\n\n const symopList = []\n for (let i = 0, il = encodedSymopList.length; i < il; i += 3) {\n const symop = []\n for (let j = 0; j < 3; ++j) {\n symop.push(SymOpCode[ encodedSymopList[ i + j ] ])\n }\n symopList.push(symop)\n }\n\n symopList.forEach(function (symop) {\n let row = 0\n const matrix = new Matrix4().set(\n 0, 0, 0, 0,\n 0, 0, 0, 0,\n 0, 0, 0, 0,\n 0, 0, 0, 1\n )\n const me = matrix.elements\n\n matrixDict[ symop.toString() ] = matrix\n\n symop.forEach(function (elm) {\n let negate = false\n let denominator = false\n\n for (let i = 0, n = elm.length; i < n; ++i) {\n const c = elm[ i ]\n\n if (c === '-') {\n negate = true\n } else if (c === '+') {\n negate = false\n } else if (c === '/') {\n denominator = true\n } else if (c === 'X') {\n me[ 0 + row ] = negate ? -1 : 1\n } else if (c === 'Y') {\n me[ 4 + row ] = negate ? -1 : 1\n } else if (c === 'Z') {\n me[ 8 + row ] = negate ? -1 : 1\n } else if (reInteger.test(c)) {\n const integer = parseInt(c)\n if (denominator) {\n me[ 12 + row ] /= integer\n } else {\n me[ 12 + row ] = integer\n }\n } else {\n Log.warn(`getSymmetryOperations: unknown token '${c}'`)\n }\n }\n\n row += 1\n })\n })\n\n return matrixDict\n}\n","/**\n * @file Assembly\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Box3, Vector3 } from 'three'\n\nimport { uniqueArray } from '../utils'\nimport Selection from '../selection/selection'\nimport Structure from '../structure/structure'\nimport StructureView from '../structure/structure-view';\n\nfunction selectionFromChains (chainList: string[]) {\n let sele = ''\n if (chainList.length > 0) {\n sele = ':' + uniqueArray(chainList).join(' OR :')\n }\n return new Selection(sele)\n}\n\n/**\n * Assembly of transformed parts of a {@link Structure}\n */\nclass Assembly {\n partList: AssemblyPart[] = []\n\n /**\n * @param {String} name - assembly name\n */\n constructor (readonly name = '') {}\n\n get type () { return 'Assembly' }\n\n /**\n * Add transformed parts to the assembly\n * @example\n * var m1 = new NGL.Matrix4().set( ... );\n * var m2 = new NGL.Matrix4().set( ... );\n * var assembly = new NGL.Assembly( \"myAssembly\" );\n * // add part that transforms chain 'A' and 'B' using matrices `m1` and `m2`\n * assembly.addPart( [ m1, m2 ], [ \"A\", \"B\" ] )\n *\n * @param {Matrix4[]} matrixList - array of 4x4 transformation matrices\n * @param {String[]} chainList - array of chain names\n * @return {AssemblyPart} the added assembly part\n */\n addPart (matrixList?: Matrix4[], chainList?: string[]) {\n const part = new AssemblyPart(matrixList, chainList)\n this.partList.push(part)\n return part\n }\n\n /**\n * Get the number of atom for a given structure\n * @param {Structure} structure - the given structure\n * @return {Integer} number of atoms in the assembly\n */\n getAtomCount (structure: Structure) {\n return this.partList.reduce(\n (count, part) => count + part.getAtomCount(structure), 0\n )\n }\n\n /**\n * Get the number of residues for a given structure\n * @param {Structure} structure - the given structure\n * @return {Integer} number of residues in the assembly\n */\n getResidueCount (structure: Structure) {\n return this.partList.reduce(\n (count, part) => count + part.getResidueCount(structure), 0\n )\n }\n\n /**\n * Get number of instances the assembly will produce, i.e.\n * the number of transformations performed by the assembly\n * @return {Integer} number of instances\n */\n getInstanceCount () {\n let instanceCount = 0\n\n this.partList.forEach(function (part) {\n instanceCount += part.matrixList.length\n })\n\n return instanceCount\n }\n\n /**\n * Determine if the assembly is the full and untransformed structure\n * @param {Structure} structure - the given structure\n * @return {Boolean} whether the assembly is identical to the structure\n */\n isIdentity (structure: Structure) {\n if (this.partList.length !== 1) return false\n\n const part = this.partList[ 0 ]\n if (part.matrixList.length !== 1) return false\n\n const identityMatrix = new Matrix4()\n if (!identityMatrix.equals(part.matrixList[ 0 ])) return false\n\n let structureChainList: string[] = []\n structure.eachChain(function (cp) {\n structureChainList.push(cp.chainname)\n })\n structureChainList = uniqueArray(structureChainList)\n if (part.chainList.length !== structureChainList.length) return false\n\n return true\n }\n\n getBoundingBox (structure: Structure) {\n const boundingBox = new Box3()\n\n this.partList.forEach(function (part) {\n const partBox = part.getBoundingBox(structure)\n boundingBox.expandByPoint(partBox.min)\n boundingBox.expandByPoint(partBox.max)\n })\n\n return boundingBox\n }\n\n getCenter (structure: Structure) {\n return this.getBoundingBox(structure).getCenter(new Vector3())\n }\n\n getSelection () {\n let chainList: string[] = []\n this.partList.forEach(function (part) {\n chainList = chainList.concat(part.chainList)\n })\n return selectionFromChains(chainList)\n }\n}\n\nexport class AssemblyPart {\n constructor (readonly matrixList: Matrix4[] = [], readonly chainList: string[] = []) {}\n\n get type () { return 'AssemblyPart' }\n\n _getCount (structure: Structure, propertyName: 'atomCount'|'residueCount') {\n let count = 0\n\n structure.eachChain(cp => {\n if (this.chainList.length === 0 || this.chainList.includes(cp.chainname)) {\n count += cp[ propertyName ]\n }\n })\n\n return this.matrixList.length * count\n }\n\n getAtomCount (structure: Structure) {\n return this._getCount(structure, 'atomCount')\n }\n\n getResidueCount (structure: Structure) {\n return this._getCount(structure, 'residueCount')\n }\n\n getBoundingBox (structure: Structure) {\n const partBox = new Box3()\n const instanceBox = new Box3()\n\n const selection = this.getSelection()\n const structureBox = structure.getBoundingBox(selection)\n\n this.matrixList.forEach(function (matrix) {\n instanceBox.copy(structureBox).applyMatrix4(matrix)\n partBox.expandByPoint(instanceBox.min)\n partBox.expandByPoint(instanceBox.max)\n })\n\n return partBox\n }\n\n getSelection () {\n return selectionFromChains(this.chainList)\n }\n\n getView (structure: Structure): Structure | StructureView {\n const selection = this.getSelection()\n if (selection) {\n return structure.getView(selection)\n } else {\n return structure\n }\n }\n\n getInstanceList () {\n const instanceList = []\n for (let j = 0, jl = this.matrixList.length; j < jl; ++j) {\n instanceList.push({\n id: j + 1,\n name: j,\n matrix: this.matrixList[ j ]\n })\n }\n return instanceList\n }\n}\n\nexport default Assembly\n","/**\n * @file Structure Builder\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from './structure'\n\nclass StructureBuilder {\n currentModelindex: number|null = null\n currentChainid: string|null = null\n currentResname: string|null = null\n currentResno: number|null = null\n currentInscode: string|undefined = undefined\n currentHetero: boolean|null = null\n\n previousResname: string|null = ''\n previousHetero: boolean|null = null\n\n ai = -1\n ri = -1\n ci = -1\n mi = -1\n\n constructor(readonly structure: Structure) {}\n\n addResidueType (ri: number) {\n const atomStore = this.structure.atomStore\n const residueStore = this.structure.residueStore\n const residueMap = this.structure.residueMap\n\n const count = residueStore.atomCount[ ri ]\n const offset = residueStore.atomOffset[ ri ]\n const atomTypeIdList = new Array(count)\n for (let i = 0; i < count; ++i) {\n atomTypeIdList[ i ] = atomStore.atomTypeId[ offset + i ]\n }\n residueStore.residueTypeId[ ri ] = residueMap.add(\n this.previousResname!, atomTypeIdList, this.previousHetero! // TODO\n )\n }\n\n addAtom (modelindex: number, chainname: string, chainid: string, resname: string, resno: number, hetero: boolean, sstruc?: string|undefined, inscode?: string|undefined) {\n const atomStore = this.structure.atomStore\n const residueStore = this.structure.residueStore\n const chainStore = this.structure.chainStore\n const modelStore = this.structure.modelStore\n\n let addModel = false\n let addChain = false\n let addResidue = false\n\n if (this.currentModelindex !== modelindex) {\n addModel = true\n addChain = true\n addResidue = true\n this.mi += 1\n this.ci += 1\n this.ri += 1\n } else if (this.currentChainid !== chainid) {\n addChain = true\n addResidue = true\n this.ci += 1\n this.ri += 1\n } else if (this.currentResno !== resno || this.currentResname !== resname || this.currentInscode !== inscode) {\n addResidue = true\n this.ri += 1\n }\n this.ai += 1\n\n if (addModel) {\n modelStore.growIfFull()\n modelStore.chainOffset[ this.mi ] = this.ci\n modelStore.chainCount[ this.mi ] = 0\n modelStore.count += 1\n chainStore.modelIndex[ this.ci ] = this.mi\n }\n\n if (addChain) {\n chainStore.growIfFull()\n chainStore.setChainname(this.ci, chainname)\n chainStore.setChainid(this.ci, chainid)\n chainStore.residueOffset[ this.ci ] = this.ri\n chainStore.residueCount[ this.ci ] = 0\n chainStore.count += 1\n chainStore.modelIndex[ this.ci ] = this.mi\n modelStore.chainCount[ this.mi ] += 1\n residueStore.chainIndex[ this.ri ] = this.ci\n }\n\n if (addResidue) {\n this.previousResname = this.currentResname\n this.previousHetero = this.currentHetero\n if (this.ri > 0) this.addResidueType(this.ri - 1)\n residueStore.growIfFull()\n residueStore.resno[ this.ri ] = resno\n if (sstruc !== undefined) {\n residueStore.sstruc[ this.ri ] = sstruc.charCodeAt(0)\n }\n if (inscode !== undefined) {\n residueStore.inscode[ this.ri ] = inscode.charCodeAt(0)\n }\n residueStore.atomOffset[ this.ri ] = this.ai\n residueStore.atomCount[ this.ri ] = 0\n residueStore.count += 1\n residueStore.chainIndex[ this.ri ] = this.ci\n chainStore.residueCount[ this.ci ] += 1\n }\n\n atomStore.count += 1\n atomStore.residueIndex[ this.ai ] = this.ri\n residueStore.atomCount[ this.ri ] += 1\n\n this.currentModelindex = modelindex\n this.currentChainid = chainid\n this.currentResname = resname\n this.currentResno = resno\n this.currentInscode = inscode\n this.currentHetero = hetero\n }\n\n finalize () {\n this.previousResname = this.currentResname\n this.previousHetero = this.currentHetero\n if (this.ri > -1) this.addResidueType(this.ri)\n }\n}\n\nexport default StructureBuilder\n","/**\n * @file Structure Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4 } from 'three'\n\nimport { Debug, Log } from '../globals'\nimport { binarySearchIndexOf } from '../utils'\nimport Helixbundle from '../geometry/helixbundle'\nimport Kdtree from '../geometry/kdtree'\nimport { getSymmetryOperations } from '../symmetry/symmetry-utils'\nimport Assembly from '../symmetry/assembly'\nimport Structure from '../structure/structure'\nimport StructureBuilder from '../structure/structure-builder'\nimport Polymer from '../proxy/polymer'\nimport ResidueProxy from '../proxy/residue-proxy'\n\nimport { UnknownBackboneType, AA3, Bases, AtomicNumbers } from './structure-constants'\n\nexport function reorderAtoms (structure: Structure) {\n if (Debug) Log.time('reorderAtoms')\n\n var ap1 = structure.getAtomProxy()\n var ap2 = structure.getAtomProxy()\n\n function compareModelChainResno (index1: number, index2: number) {\n ap1.index = index1\n ap2.index = index2\n if (ap1.modelIndex < ap2.modelIndex) {\n return -1\n } else if (ap1.modelIndex > ap2.modelIndex) {\n return 1\n } else {\n if (ap1.chainname < ap2.chainname) {\n return -1\n } else if (ap1.chainname > ap2.chainname) {\n return 1\n } else {\n if (ap1.resno < ap2.resno) {\n return -1\n } else if (ap1.resno > ap2.resno) {\n return 1\n } else {\n return 0\n }\n }\n }\n }\n\n structure.atomStore.sort(compareModelChainResno)\n\n if (Debug) Log.timeEnd('reorderAtoms')\n}\n\nexport interface SecStruct {\n helices: [string, number, string, string, number, string, number][]\n sheets: [string, number, string, string, number, string][]\n}\n\nexport function assignSecondaryStructure (structure: Structure, secStruct: SecStruct) {\n if (!secStruct) return\n\n if (Debug) Log.time('assignSecondaryStructure')\n\n const chainnames: string[] = []\n structure.eachModel(function (mp) {\n mp.eachChain(function (cp) {\n chainnames.push(cp.chainname)\n })\n })\n\n const chainnamesSorted = chainnames.slice().sort()\n const chainnamesIndex: number[] = []\n chainnamesSorted.forEach(function (c) {\n chainnamesIndex.push(chainnames.indexOf(c))\n })\n\n // helix assignment\n\n const helices = secStruct.helices.filter(function (h) {\n return binarySearchIndexOf(chainnamesSorted, h[ 0 ]) >= 0\n })\n\n helices.sort(function (h1, h2) {\n const c1 = h1[ 0 ]\n const c2 = h2[ 0 ]\n const r1 = h1[ 1 ]\n const r2 = h2[ 1 ]\n\n if (c1 === c2) {\n if (r1 === r2) {\n return 0\n } else {\n return r1 < r2 ? -1 : 1\n }\n } else {\n const idx1 = binarySearchIndexOf(chainnamesSorted, c1)\n const idx2 = binarySearchIndexOf(chainnamesSorted, c2)\n return chainnamesIndex[ idx1 ] < chainnamesIndex[ idx2 ] ? -1 : 1\n }\n })\n\n const residueStore = structure.residueStore\n\n structure.eachModel(function (mp) {\n let i = 0\n const n = helices.length\n if (n === 0) return\n let helix = helices[ i ]\n let helixRun = false\n let done = false\n\n mp.eachChain(function (cp) {\n let chainChange = false\n\n if (cp.chainname === helix[ 0 ]) {\n const count = cp.residueCount\n const offset = cp.residueOffset\n const end = offset + count\n\n for (let j = offset; j < end; ++j) {\n if (residueStore.resno[ j ] === helix[ 1 ] && // resnoBeg\n residueStore.getInscode(j) === helix[ 2 ] // inscodeBeg\n ) {\n helixRun = true\n }\n\n if (helixRun) {\n residueStore.sstruc[ j ] = helix[ 6 ]\n\n if (residueStore.resno[ j ] === helix[ 4 ] && // resnoEnd\n residueStore.getInscode(j) === helix[ 5 ] // inscodeEnd\n ) {\n helixRun = false\n i += 1\n\n if (i < n) {\n // must look at previous residues as\n // residues may not be ordered by resno\n j = offset - 1\n helix = helices[ i ]\n chainChange = cp.chainname !== helix[ 0 ]\n } else {\n done = true\n }\n }\n }\n\n if (chainChange || done) return\n }\n }\n })\n })\n\n // sheet assignment\n\n const sheets = secStruct.sheets.filter(function (s) {\n return binarySearchIndexOf(chainnamesSorted, s[ 0 ]) >= 0\n })\n\n sheets.sort(function (s1, s2) {\n const c1 = s1[ 0 ]\n const c2 = s2[ 0 ]\n\n if (c1 === c2) return 0\n const idx1 = binarySearchIndexOf(chainnamesSorted, c1)\n const idx2 = binarySearchIndexOf(chainnamesSorted, c2)\n return chainnamesIndex[ idx1 ] < chainnamesIndex[ idx2 ] ? -1 : 1\n })\n\n const strandCharCode = 'e'.charCodeAt(0)\n structure.eachModel(function (mp) {\n let i = 0\n const n = sheets.length\n if (n === 0) return\n let sheet = sheets[ i ]\n let sheetRun = false\n let done = false\n\n mp.eachChain(function (cp) {\n let chainChange = false\n\n if (cp.chainname === sheet[ 0 ]) {\n const count = cp.residueCount\n const offset = cp.residueOffset\n const end = offset + count\n\n for (let j = offset; j < end; ++j) {\n if (residueStore.resno[ j ] === sheet[ 1 ] && // resnoBeg\n residueStore.getInscode(j) === sheet[ 2 ] // inscodeBeg\n ) {\n sheetRun = true\n }\n\n if (sheetRun) {\n residueStore.sstruc[ j ] = strandCharCode\n\n if (residueStore.resno[ j ] === sheet[ 4 ] && // resnoEnd\n residueStore.getInscode(j) === sheet[ 5 ] // inscodeEnd\n ) {\n sheetRun = false\n i += 1\n\n if (i < n) {\n // must look at previous residues as\n // residues may not be ordered by resno\n j = offset - 1\n sheet = sheets[ i ]\n chainChange = cp.chainname !== sheet[ 0 ]\n } else {\n done = true\n }\n }\n }\n\n if (chainChange || done) return\n }\n }\n })\n })\n\n if (Debug) Log.timeEnd('assignSecondaryStructure')\n}\n\nexport const calculateSecondaryStructure = (function () {\n // Implementation for proteins based on \"pv\"\n //\n // assigns secondary structure information based on a simple and very fast\n // algorithm published by Zhang and Skolnick in their TM-align paper.\n // Reference:\n //\n // TM-align: a protein structure alignment algorithm based on the Tm-score\n // (2005) NAR, 33(7) 2302-2309\n\n const zhangSkolnickSS = function (polymer: Polymer, i: number, distances: number[], delta: number) {\n const structure = polymer.structure\n const offset = polymer.residueIndexStart\n const rp1 = structure.getResidueProxy()\n const rp2 = structure.getResidueProxy()\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n for (let j = Math.max(0, i - 2); j <= i; ++j) {\n for (let k = 2; k < 5; ++k) {\n if (j + k >= polymer.residueCount) {\n continue\n }\n\n rp1.index = offset + j\n rp2.index = offset + j + k\n ap1.index = rp1.traceAtomIndex\n ap2.index = rp2.traceAtomIndex\n\n const d = ap1.distanceTo(ap2)\n\n if (Math.abs(d - distances[ k - 2 ]) > delta) {\n return false\n }\n }\n }\n\n return true\n }\n\n const isHelical = function (polymer: Polymer, i: number) {\n const helixDistances = [ 5.45, 5.18, 6.37 ]\n const helixDelta = 2.1\n return zhangSkolnickSS(polymer, i, helixDistances, helixDelta)\n }\n\n const isSheet = function (polymer: Polymer, i: number) {\n const sheetDistances = [ 6.1, 10.4, 13.0 ]\n const sheetDelta = 1.42\n return zhangSkolnickSS(polymer, i, sheetDistances, sheetDelta)\n }\n\n const proteinPolymer = function (p: Polymer) {\n const residueStore = p.residueStore\n const offset = p.residueIndexStart\n for (let i = 0, il = p.residueCount; i < il; ++i) {\n let sstruc = 'c'\n if (isHelical(p, i)) {\n sstruc = 'h'\n } else if (isSheet(p, i)) {\n sstruc = 'e'\n }\n residueStore.sstruc[ offset + i ] = sstruc.charCodeAt(0)\n }\n }\n\n const cgPolymer = function (p: Polymer) {\n const localAngle = 20\n const centerDist = 2.0\n\n const residueStore = p.residueStore\n const offset = p.residueIndexStart\n\n const helixbundle = new Helixbundle(p)\n const pos = helixbundle.position\n\n const c1 = new Vector3()\n const c2 = new Vector3()\n\n for (let i = 0, il = p.residueCount; i < il; ++i) {\n c1.fromArray(pos.center as any, i * 3) // TODO\n c2.fromArray(pos.center as any, i * 3 + 3) // TODO\n const d = c1.distanceTo(c2)\n\n if (d < centerDist && d > 1.0 && pos.bending[ i ] < localAngle) {\n residueStore.sstruc[ offset + i ] = 'h'.charCodeAt(0)\n residueStore.sstruc[ offset + i + 1 ] = 'h'.charCodeAt(0)\n }\n }\n }\n\n return function calculateSecondaryStructure (structure: Structure) {\n if (Debug) Log.time('calculateSecondaryStructure')\n\n structure.eachPolymer(function (p) {\n // assign secondary structure\n if (p.residueCount < 4) return\n if (p.isCg()) {\n cgPolymer(p)\n } else if (p.isProtein()) {\n proteinPolymer(p)\n } else {\n return\n }\n\n // set lone secondary structure assignments to \"c\"\n let prevSstruc: string\n let sstrucCount = 0\n p.eachResidue(function (r: ResidueProxy) {\n if (r.sstruc === prevSstruc) {\n sstrucCount += 1\n } else {\n if (sstrucCount === 1) {\n r.index -= 1\n r.sstruc = 'c'\n }\n sstrucCount = 1\n prevSstruc = r.sstruc\n }\n })\n })\n\n if (Debug) Log.timeEnd('calculateSecondaryStructure')\n }\n}())\n\n// const ChainnameAlphabet = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\" +\n// \"abcdefghijklmnopqrstuvwxyz\" +\n// \"0123456789\";\nconst ChainnameAlphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\n\nexport function getChainname (index: number) {\n const n = ChainnameAlphabet.length\n let j = index\n let k = 0\n let chainname = ChainnameAlphabet[j % n]\n while (j >= n) {\n j = Math.floor(j / n)\n chainname += ChainnameAlphabet[j % n]\n k += 1\n }\n if (k >= 5) {\n Log.warn('chainname overflow')\n }\n return chainname\n}\n\ninterface ChainData {\n mIndex: number\n chainname: string\n rStart: number\n rCount: number\n}\n\n/**\n * When no chain names are set for the given structure, calculates\n * chains based on:\n * - polymer connectivity: when adjacent residues are not bonded, a new chain is created.\n * - non polymer chemical type: adjacent residues which are not polymers but are of the same\n * chemical type (e.g. water molecules) are grouped into the same chain.\n **/\nexport function calculateChainnames (structure: Structure, useExistingBonds = false) {\n if (Debug) Log.time('calculateChainnames')\n\n let doAutoChainName = true\n structure.eachChain(function (c) {\n if (c.chainname) doAutoChainName = false\n })\n\n if (doAutoChainName) {\n const modelStore = structure.modelStore\n const chainStore = structure.chainStore\n const residueStore = structure.residueStore\n\n const addChain = function (mIndex: number, chainname: string, rOffset: number, rCount: number) {\n const ci = chainStore.count\n for (let i = 0; i < rCount; ++i) {\n residueStore.chainIndex[ rOffset + i ] = ci\n }\n chainStore.growIfFull()\n chainStore.modelIndex[ ci ] = mIndex\n chainStore.setChainname(ci, chainname)\n chainStore.setChainid(ci, chainname)\n chainStore.residueOffset[ ci ] = rOffset\n chainStore.residueCount[ ci ] = rCount\n chainStore.count += 1\n modelStore.chainCount[ mIndex ] += 1\n }\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n let i = 0\n let mi = 0\n let rStart = 0\n let rEnd = 0\n const chainData: ChainData[] = []\n\n if (residueStore.count === 1) {\n chainData.push({\n mIndex: 0,\n chainname: 'A',\n rStart: 0,\n rCount: 1\n })\n } else {\n structure.eachResidueN(2, function (rp1: ResidueProxy, rp2: ResidueProxy) {\n let newChain = false\n\n const bbType1 = rp1.backboneType\n const bbType2 = rp2.backboneType\n const bbTypeUnk = UnknownBackboneType\n\n rEnd = rp1.index\n\n if (rp1.modelIndex !== rp2.modelIndex) {\n newChain = true\n } else if (rp1.moleculeType !== rp2.moleculeType) {\n newChain = true\n } else if (bbType1 !== bbTypeUnk && bbType1 === bbType2) {\n ap1.index = rp1.backboneEndAtomIndex\n ap2.index = rp2.backboneStartAtomIndex\n if (useExistingBonds) {\n newChain = !ap1.hasBondTo(ap2)\n } else {\n newChain = !ap1.connectedTo(ap2)\n }\n }\n\n // current chain goes to end of the structure\n if (!newChain && rp2.index === residueStore.count - 1) {\n newChain = true\n rEnd = rp2.index\n }\n\n if (newChain) {\n chainData.push({\n mIndex: mi,\n chainname: getChainname(i),\n rStart: rStart,\n rCount: rEnd - rStart + 1\n })\n\n i += 1\n\n if (rp1.modelIndex !== rp2.modelIndex) {\n i = 0\n mi += 1\n }\n\n // new chain for the last residue of the structure\n if (rp2.index === residueStore.count - 1 && rEnd !== rp2.index) {\n chainData.push({\n mIndex: mi,\n chainname: getChainname(i),\n rStart: residueStore.count - 1,\n rCount: 1\n })\n }\n\n rStart = rp2.index\n rEnd = rp2.index\n }\n })\n }\n\n //\n\n chainStore.count = 0\n modelStore.chainCount.fill(0, 0, modelStore.count)\n modelStore.chainOffset.fill(0, 0, modelStore.count)\n chainData.forEach(function (d) {\n addChain(d.mIndex, d.chainname, d.rStart, d.rCount)\n })\n\n let chainOffset = 0\n structure.eachModel(function (mp) {\n modelStore.chainOffset[ mp.index ] = chainOffset\n chainOffset += modelStore.chainCount[ mp.index ]\n })\n }\n\n if (Debug) Log.timeEnd('calculateChainnames')\n}\n\nexport function calculateBonds (structure: Structure, inferBonds: InferBondsOptions='all') {\n if (inferBonds === 'none') return \n if (Debug) Log.time('calculateBonds')\n\n calculateBondsWithin(structure, false, inferBonds)\n calculateBondsBetween(structure)\n\n if (Debug) Log.timeEnd('calculateBonds')\n}\n\n/**\n * Should Bonds be inferred for `all` atoms, `none` or `auto`\n * If `auto`, any hetgroup residue with at least one CONECT record will \n * not have bonding inferred, and will rely on the CONECT records\n */\nexport type InferBondsOptions = 'all' | 'none' | 'auto'\n\nexport interface ResidueBonds {\n atomIndices1: number[]\n atomIndices2: number[]\n bondOrders: number[]\n}\n\n\nconst BondOrderTable: { [k: string]: number } = {\n 'HIS|CD2|CG': 2,\n 'HIS|CE1|ND1': 2,\n 'ARG|CZ|NH2': 2,\n 'PHE|CE1|CZ': 2,\n 'PHE|CD2|CE2': 2,\n 'PHE|CD1|CG': 2,\n 'TRP|CD1|CG': 2,\n 'TRP|CD2|CE2': 2,\n 'TRP|CE3|CZ3': 2,\n 'TRP|CH2|CZ2': 2,\n 'ASN|CG|OD1': 2,\n 'GLN|CD|OE1': 2,\n 'TYR|CD1|CG': 2,\n 'TYR|CD2|CE2': 2,\n 'TYR|CE1|CZ': 2,\n 'ASP|CG|OD1': 2,\n 'GLU|CD|OE1': 2,\n\n 'G|C8|N7': 2,\n 'G|C4|C5': 2,\n 'G|C2|N3': 2,\n 'G|C6|O6': 2,\n 'C|C4|N3': 2,\n 'C|C5|C6': 2,\n 'C|C2|O2': 2,\n 'A|C2|N3': 2,\n 'A|C6|N1': 2,\n 'A|C4|C5': 2,\n 'A|C8|N7': 2,\n 'U|C5|C6': 2,\n 'U|C2|O2': 2,\n 'U|C4|O4': 2,\n\n 'DG|C8|N7': 2,\n 'DG|C4|C5': 2,\n 'DG|C2|N3': 2,\n 'DG|C6|O6': 2,\n 'DC|C4|N3': 2,\n 'DC|C5|C6': 2,\n 'DC|C2|O2': 2,\n 'DA|C2|N3': 2,\n 'DA|C6|N1': 2,\n 'DA|C4|C5': 2,\n 'DA|C8|N7': 2,\n 'DT|C5|C6': 2,\n 'DT|C2|O2': 2,\n 'DT|C4|O4': 2\n}\nfunction getBondOrderFromTable (resname: string, atomname1: string, atomname2: string) {\n [ atomname1, atomname2 ] = atomname1 < atomname2 ? [ atomname1, atomname2 ] : [ atomname2, atomname1 ]\n if (AA3.includes(resname) && atomname1 === 'C' && atomname2 === 'O') return 2\n if (Bases.includes(resname) && atomname1 === 'OP1' && atomname2 === 'P') return 2\n return BondOrderTable[ `${resname}|${atomname1}|${atomname2}` ] || 1\n}\n\nexport function calculateResidueBonds (r: ResidueProxy) {\n const structure = r.structure\n const a1 = structure.getAtomProxy()\n const a2 = structure.getAtomProxy()\n\n const count = r.atomCount\n const offset = r.atomOffset\n const end = offset + count\n const end1 = end - 1\n\n const atomIndices1 = []\n const atomIndices2 = []\n const bondOrders = []\n\n if (count > 500) {\n if (Debug) Log.warn('more than 500 atoms, skip residue for auto-bonding', r.qualifiedName())\n } else {\n if (count > 50) {\n const kdtree = new Kdtree(r, true)\n const radius = r.isCg() ? 1.2 : 2.3\n\n for (let i = offset; i < end1; ++i) {\n a1.index = i\n const maxd = a1.covalent + radius + 0.3\n const nearestAtoms = kdtree.nearest(a1 as any, Infinity, maxd * maxd) // TODO\n const m = nearestAtoms.length\n for (let j = 0; j < m; ++j) {\n a2.index = nearestAtoms[ j ].index\n if (a1.index < a2.index) {\n if (a1.connectedTo(a2)) {\n atomIndices1.push(a1.index - offset)\n atomIndices2.push(a2.index - offset)\n bondOrders.push(getBondOrderFromTable(a1.resname, a1.atomname, a2.atomname))\n }\n }\n }\n }\n } else {\n for (let i = offset; i < end1; ++i) {\n a1.index = i\n for (let j = i + 1; j <= end1; ++j) {\n a2.index = j\n if (a1.connectedTo(a2)) {\n atomIndices1.push(i - offset)\n atomIndices2.push(j - offset)\n bondOrders.push(getBondOrderFromTable(a1.resname, a1.atomname, a2.atomname))\n }\n }\n }\n }\n }\n\n return {\n atomIndices1: atomIndices1,\n atomIndices2: atomIndices2,\n bondOrders: bondOrders\n }\n}\n\nexport function calculateAtomBondMap (structure: Structure) {\n if (Debug) Log.time('calculateAtomBondMap')\n\n var atomBondMap: number[][] = []\n\n structure.eachBond(function (bp) {\n var ai1 = bp.atomIndex1\n var ai2 = bp.atomIndex2\n if (atomBondMap[ ai1 ] === undefined) atomBondMap[ ai1 ] = []\n atomBondMap[ ai1 ][ ai2 ] = bp.index\n })\n\n if (Debug) Log.timeEnd('calculateAtomBondMap')\n\n return atomBondMap\n}\n\nexport function calculateBondsWithin (structure: Structure, onlyAddRung = false, inferBonds: InferBondsOptions='all') {\n if (Debug) Log.time('calculateBondsWithin')\n\n const bondStore = structure.bondStore\n const rungBondStore = structure.rungBondStore\n const rungAtomSet = structure.getAtomSet(false)\n const a1 = structure.getAtomProxy()\n const a2 = structure.getAtomProxy()\n const bp = structure.getBondProxy()\n const atomBondMap = onlyAddRung ? null : calculateAtomBondMap(structure)\n\n let bondedAtoms: Set\n if (!onlyAddRung && inferBonds === 'auto') {\n bondedAtoms = new Set()\n atomBondMap!.forEach((a, i) => {\n bondedAtoms.add(i)\n a.forEach(j => {bondedAtoms.add(j)})\n })\n }\n\n structure.eachResidue(function (r) {\n if (!onlyAddRung && atomBondMap) {\n const count = r.atomCount\n const offset = r.atomOffset\n\n if (count > 500) {\n Log.warn('more than 500 atoms, skip residue for auto-bonding', r.qualifiedName())\n return\n }\n\n if (inferBonds === 'auto' && r.hetero) {\n // Are bonds present on this residue?\n for (let rai=r.atomOffset; rai {\n ncsMatrixList.forEach(nm => {\n ncsUnitcellMatrixList.push(sm.clone().multiply(nm))\n })\n })\n unitcellAssembly.addPart(ncsUnitcellMatrixList)\n } else {\n unitcellAssembly.addPart(unitcellMatrixList)\n }\n\n const vec = new Vector3()\n const supercellAssembly = new Assembly('SUPERCELL')\n const supercellMatrixList = Array.prototype.concat.call(\n getMatrixList(vec.set(1, 0, 0)), // 655\n getMatrixList(vec.set(0, 1, 0)), // 565\n getMatrixList(vec.set(0, 0, 1)), // 556\n\n getMatrixList(vec.set(-1, 0, 0)), // 455\n getMatrixList(vec.set(0, -1, 0)), // 545\n getMatrixList(vec.set(0, 0, -1)), // 554\n\n getMatrixList(vec.set(1, 1, 0)), // 665\n getMatrixList(vec.set(1, 0, 1)), // 656\n getMatrixList(vec.set(0, 1, 1)), // 566\n\n getMatrixList(vec.set(-1, -1, 0)), // 445\n getMatrixList(vec.set(-1, 0, -1)), // 454\n getMatrixList(vec.set(0, -1, -1)), // 544\n\n getMatrixList(vec.set(1, -1, -1)), // 644\n getMatrixList(vec.set(1, 1, -1)), // 664\n getMatrixList(vec.set(1, -1, 1)), // 646\n getMatrixList(vec.set(-1, 1, 1)), // 466\n getMatrixList(vec.set(-1, -1, 1)), // 446\n getMatrixList(vec.set(-1, 1, -1)), // 464\n\n getMatrixList(vec.set(0, 1, -1)), // 564\n getMatrixList(vec.set(0, -1, 1)), // 546\n getMatrixList(vec.set(1, 0, -1)), // 654\n getMatrixList(vec.set(-1, 0, 1)), // 456\n getMatrixList(vec.set(1, -1, 0)), // 645\n getMatrixList(vec.set(-1, 1, 0)), // 465\n\n getMatrixList(), // 555\n getMatrixList(vec.set(1, 1, 1)), // 666\n getMatrixList(vec.set(-1, -1, -1)) // 444\n )\n if (structure.biomolDict.NCS) {\n const ncsSupercellMatrixList: Matrix4[] = []\n supercellMatrixList.forEach(function (sm: Matrix4) {\n ncsMatrixList.forEach(function (nm) {\n ncsSupercellMatrixList.push(sm.clone().multiply(nm))\n })\n })\n supercellAssembly.addPart(ncsSupercellMatrixList)\n } else {\n supercellAssembly.addPart(supercellMatrixList)\n }\n\n structure.biomolDict.UNITCELL = unitcellAssembly\n structure.biomolDict.SUPERCELL = supercellAssembly\n\n if (Debug) Log.timeEnd('buildUnitcellAssembly')\n}\n\nconst elm1 = [ 'H', 'C', 'O', 'N', 'S', 'P' ]\nconst elm2 = [ 'NA', 'CL', 'FE' ]\n\nexport function guessElement (atomName: string) {\n // Retain first group of letters in atomName\n let at = atomName.toUpperCase()\n let begin = 0, end = 0\n for (let i = 0; i < at.length ; i++) {\n if (at.charCodeAt(i) < 65) {\n if (end > 0) break\n ++begin\n }\n else end = i + 1\n }\n if (begin > 0 || end < at.length) at = at.substring(begin, end)\n \n const n = at.length\n\n if (n === 0) return ''\n if (n === 1) return at\n if (n === 2) {\n if (elm2.indexOf(at) !== -1) return at\n if (elm1.indexOf(at[0]) !== -1) return at[0]\n if (at in AtomicNumbers) return at\n }\n if (n >= 3) {\n if (elm1.indexOf(at[0]) !== -1) return at[0]\n }\n return ''\n}\n\n/**\n * Assigns ResidueType bonds.\n * @param {Structure} structure - the structure object\n * @return {undefined}\n */\nexport function assignResidueTypeBonds (structure: Structure) {\n // if( Debug ) Log.time( \"assignResidueTypeBonds\" )\n\n const bondHash = structure.bondHash! // TODO\n const countArray = bondHash.countArray\n const offsetArray = bondHash.offsetArray\n const indexArray = bondHash.indexArray\n const bp = structure.getBondProxy()\n\n structure.eachResidue(function (rp) {\n const residueType = rp.residueType\n if (residueType.bonds !== undefined) return\n\n var atomOffset = rp.atomOffset\n var atomIndices1: number[] = []\n var atomIndices2: number[] = []\n var bondOrders: number[] = []\n var bondDict: { [k: string]: boolean } = {}\n\n const nextAtomOffset = atomOffset + rp.atomCount\n\n rp.eachAtom(function (ap) {\n const index = ap.index\n const offset = offsetArray[ index ]\n const count = countArray[ index ]\n for (let i = 0, il = count; i < il; ++i) {\n bp.index = indexArray[ offset + i ]\n let idx1 = bp.atomIndex1\n if (idx1 < atomOffset || idx1 >= nextAtomOffset) {\n // Don't add bonds outside of this resiude\n continue\n }\n let idx2 = bp.atomIndex2\n if (idx2 < atomOffset || idx2 >= nextAtomOffset) {\n continue\n }\n\n if (idx1 > idx2) {\n const tmp = idx2\n idx2 = idx1\n idx1 = tmp\n }\n const hash = idx1 + '|' + idx2\n if (bondDict[ hash ] === undefined) {\n bondDict[ hash ] = true\n atomIndices1.push(idx1 - atomOffset)\n atomIndices2.push(idx2 - atomOffset)\n bondOrders.push(bp.bondOrder)\n }\n }\n })\n\n residueType.bonds = {\n atomIndices1: atomIndices1,\n atomIndices2: atomIndices2,\n bondOrders: bondOrders\n }\n })\n\n // if( Debug ) Log.timeEnd( \"assignResidueTypeBonds\" )\n}\n\nexport function concatStructures (name: string, ...structures: Structure[]) {\n if( Debug ) Log.time( \"concatStructures\" )\n\n const s = new Structure(name, '')\n const sb = new StructureBuilder(s)\n\n const atomStore = s.atomStore as any\n const atomMap = s.atomMap\n atomStore.addField('formalCharge', 1, 'int8')\n atomStore.addField('partialCharge', 1, 'float32')\n\n const atomIndexDict: { [k: number]: number } = {}\n\n let idx = 0\n let atomCount = 0\n let modelCount = 0\n structures.forEach(structure => {\n structure.eachAtom(a => {\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(a.atomname, a.element)\n\n atomStore.x[ idx ] = a.x\n atomStore.y[ idx ] = a.y\n atomStore.z[ idx ] = a.z\n atomStore.serial[ idx ] = a.serial\n atomStore.formalCharge[ idx ] = a.formalCharge\n atomStore.partialCharge[ idx ] = a.partialCharge\n atomStore.altloc[ idx ] = a.altloc\n atomStore.occupancy[ idx ] = a.occupancy\n atomStore.bfactor[ idx ] = a.bfactor\n\n sb.addAtom(\n a.modelIndex + modelCount,\n a.chainname,\n a.chainid,\n a.resname,\n a.resno,\n a.hetero === 1,\n a.sstruc,\n a.inscode\n )\n\n atomIndexDict[a.index + atomCount] = idx\n idx += 1\n })\n atomCount += structure.atomStore.count\n modelCount += structure.modelStore.count\n })\n\n const bondStore = s.bondStore\n const a1 = s.getAtomProxy()\n const a2 = s.getAtomProxy()\n\n atomCount = 0\n structures.forEach(structure => {\n structure.eachBond(b => {\n a1.index = atomIndexDict[ b.atomIndex1 + atomCount ]\n a2.index = atomIndexDict[ b.atomIndex2 + atomCount ]\n bondStore.addBond(a1, a2, b.bondOrder)\n })\n atomCount += structure.atomStore.count\n })\n\n sb.finalize()\n\n calculateBondsBetween(s, true) // calculate backbone bonds\n calculateBondsWithin(s, true) // calculate rung bonds\n\n s.finalizeAtoms()\n s.finalizeBonds()\n assignResidueTypeBonds(s)\n\n if( Debug ) Log.timeEnd( \"concatStructures\" )\n\n return s\n}\n","/**\n * @file Atom Type\n * @author Alexander Rose \n * @private\n */\n\nimport { guessElement } from '../structure/structure-utils'\nimport {\n AtomicNumbers, DefaultAtomicNumber,\n VdwRadii, DefaultVdwRadius,\n CovalentRadii, DefaultCovalentRadius,\n Valences, DefaultValence,\n OuterShellElectronCounts, DefaultOuterShellElectronCount\n} from '../structure/structure-constants'\nimport Structure from '../structure/structure'\n\n// Li, Na, K, Rb, Cs Fr\nconst AlkaliMetals = [ 3, 11, 19, 37, 55, 87 ]\n\n// Be, Mg, Ca, Sr, Ba, Ra\nconst AlkalineEarthMetals = [ 4, 12, 20, 38, 56, 88 ]\n\n// C, P, S, Se\nconst PolyatomicNonmetals = [ 6, 15, 16, 34, ]\n\n// H, N, O, F, Cl, Br, I\nconst DiatomicNonmetals = [ 1, 7, 8, 9, 17, 35, 53 ]\n\n// He, Ne, Ar, Kr, Xe, Rn\nconst NobleGases = [ 2, 10, 18, 36, 54, 86 ]\n\n// Zn, Ga, Cd, In, Sn, Hg, Ti, Pb, Bi, Po, Cn\nconst PostTransitionMetals = [ 13, 30, 31, 48, 49, 50, 80, 81, 82, 83, 84, 85, 112 ]\n\n// B, Si, Ge, As, Sb, Te, At\nconst Metalloids = [ 5, 14, 32, 33, 51, 52, 85 ]\n\n// F, Cl, Br, I, At\nconst Halogens = [ 9, 17, 35, 53, 85 ]\n\n/**\n * Atom type\n */\nclass AtomType {\n element: string\n number: number\n vdw: number\n covalent: number\n\n /**\n * @param {Structure} structure - the structure object\n * @param {String} atomname - the name of the atom\n * @param {String} element - the chemical element\n */\n constructor (readonly structure: Structure, readonly atomname: string, element?: string) {\n element = element || guessElement(atomname)\n\n this.element = element\n this.number = AtomicNumbers[ element ] || DefaultAtomicNumber\n this.vdw = VdwRadii[ this.number ] || DefaultVdwRadius\n this.covalent = CovalentRadii[ this.number ] || DefaultCovalentRadius\n }\n\n getDefaultValence() {\n const vl = Valences[ this.number ]\n return vl ? vl[ 0 ] : DefaultValence\n }\n\n getValenceList () {\n return Valences[ this.number ] || []\n }\n\n getOuterShellElectronCount () {\n return OuterShellElectronCounts[ this.number ] || DefaultOuterShellElectronCount\n }\n\n isMetal () {\n return (\n this.isAlkaliMetal() ||\n this.isAlkalineEarthMetal() ||\n this.isLanthanide() ||\n this.isActinide() ||\n this.isTransitionMetal() ||\n this.isPostTransitionMetal()\n )\n }\n\n isNonmetal () {\n return (\n this.isDiatomicNonmetal() ||\n this.isPolyatomicNonmetal() ||\n this.isNobleGas()\n )\n }\n\n isMetalloid () {\n return Metalloids.includes(this.number)\n }\n\n isHalogen () {\n return Halogens.includes(this.number)\n }\n\n isDiatomicNonmetal () {\n return DiatomicNonmetals.includes(this.number)\n }\n\n isPolyatomicNonmetal () {\n return PolyatomicNonmetals.includes(this.number)\n }\n\n isAlkaliMetal () {\n return AlkaliMetals.includes(this.number)\n }\n\n isAlkalineEarthMetal () {\n return AlkalineEarthMetals.includes(this.number)\n }\n\n isNobleGas () {\n return NobleGases.includes(this.number)\n }\n\n isTransitionMetal () {\n const no = this.number\n return (\n (no >= 21 && no <= 29) ||\n (no >= 39 && no <= 47) ||\n (no >= 72 && no <= 79) ||\n (no >= 104 && no <= 108)\n )\n }\n\n isPostTransitionMetal () {\n return PostTransitionMetals.includes(this.number)\n }\n\n isLanthanide () {\n return this.number >= 57 && this.number <= 71\n }\n\n isActinide () {\n return this.number >= 89 && this.number <= 103\n }\n\n}\n\nexport default AtomType","/**\n * @file Atom Map\n * @author Alexander Rose \n * @private\n */\n\nimport AtomType from './atom-type'\nimport { guessElement } from '../structure/structure-utils'\nimport Structure from '../structure/structure'\n\nfunction getHash (atomname: string, element: string) {\n return atomname + '|' + element\n}\n\nclass AtomMap {\n dict: { [k: string]: number } = {}\n list: AtomType[] = []\n\n constructor (readonly structure: Structure) {\n this.structure = structure\n }\n\n add (atomname: string, element?: string) {\n atomname = atomname.toUpperCase()\n if (!element) {\n element = guessElement(atomname)\n } else {\n element = element.toUpperCase()\n }\n const hash = getHash(atomname, element)\n let id = this.dict[ hash ]\n if (id === undefined) {\n const atomType = new AtomType(this.structure, atomname, element)\n id = this.list.length\n this.dict[ hash ] = id\n this.list.push(atomType)\n }\n return id\n }\n\n get (id: number) {\n return this.list[ id ]\n }\n}\n\nexport default AtomMap\n","/**\n * @file Residue Type\n * @author Alexander Rose \n * @author Fred Ludlow\n * @private\n */\n\nimport { defaults } from '../utils'\nimport PrincipalAxes from '../math/principal-axes'\nimport { Matrix } from '../math/matrix-utils'\nimport { calculateResidueBonds, ResidueBonds } from '../structure/structure-utils'\nimport {\n Elements,\n ProteinType, RnaType, DnaType, WaterType, IonType, SaccharideType, UnknownType,\n ProteinBackboneType, RnaBackboneType, DnaBackboneType, UnknownBackboneType,\n CgProteinBackboneType, CgRnaBackboneType, CgDnaBackboneType,\n ChemCompProtein, ChemCompRna, ChemCompDna, ChemCompSaccharide,\n AA3, PurinBases, RnaBases, DnaBases, Bases, IonNames, WaterNames, SaccharideNames,\n ProteinBackboneAtoms, NucleicBackboneAtoms, ResidueTypeAtoms\n} from '../structure/structure-constants'\nimport Structure from '../structure/structure'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\n\nexport interface BondGraph {\n [k: number]: number[]\n}\n\nexport interface RingData {\n atomRings: number[][] // sparse array:\n // atomRings[atomIdx] -> array of ring indices\n rings: number[][] // rings as arrays of indices\n}\n\n/**\n * Residue type\n */\nexport default class ResidueType {\n resname: string\n atomTypeIdList: number[]\n hetero: number\n chemCompType: string\n bonds?: ResidueBonds\n rings?: RingData\n bondGraph?: BondGraph\n aromaticAtoms?: Uint8Array\n aromaticRings?: number[][]\n\n atomCount: number\n\n moleculeType: number\n backboneType: number\n backboneEndType: number\n backboneStartType: number\n backboneIndexList: number[]\n\n traceAtomIndex: number\n direction1AtomIndex: number\n direction2AtomIndex: number\n backboneStartAtomIndex: number\n backboneEndAtomIndex: number\n rungEndAtomIndex: number\n\n // Sparse array containing the reference atom index for each bond.\n bondReferenceAtomIndices: number[] = []\n\n /**\n * @param {Structure} structure - the structure object\n * @param {String} resname - name of the residue\n * @param {Array} atomTypeIdList - list of IDs of {@link AtomType}s corresponding\n * to the atoms of the residue\n * @param {Boolean} hetero - hetero flag\n * @param {String} chemCompType - chemical component type\n * @param {Object} [bonds] - TODO\n */\n constructor (readonly structure: Structure, resname: string, atomTypeIdList: number[], hetero: boolean, chemCompType: string, bonds?: ResidueBonds) {\n this.resname = resname\n this.atomTypeIdList = atomTypeIdList\n this.hetero = hetero ? 1 : 0\n this.chemCompType = chemCompType\n this.bonds = bonds\n this.atomCount = atomTypeIdList.length\n\n this.moleculeType = this.getMoleculeType()\n this.backboneType = this.getBackboneType(0)\n this.backboneEndType = this.getBackboneType(-1)\n this.backboneStartType = this.getBackboneType(1)\n this.backboneIndexList = this.getBackboneIndexList()\n\n const atomnames = ResidueTypeAtoms[ this.backboneType ]\n const atomnamesStart = ResidueTypeAtoms[ this.backboneStartType ]\n const atomnamesEnd = ResidueTypeAtoms[ this.backboneEndType ]\n\n const traceIndex = this.getAtomIndexByName(atomnames.trace)\n this.traceAtomIndex = defaults(traceIndex, -1)\n\n const dir1Index = this.getAtomIndexByName(atomnames.direction1)\n this.direction1AtomIndex = defaults(dir1Index, -1)\n\n const dir2Index = this.getAtomIndexByName(atomnames.direction2)\n this.direction2AtomIndex = defaults(dir2Index, -1)\n\n const bbStartIndex = this.getAtomIndexByName(atomnamesStart.backboneStart)\n this.backboneStartAtomIndex = defaults(bbStartIndex, -1)\n\n const bbEndIndex = this.getAtomIndexByName(atomnamesEnd.backboneEnd)\n this.backboneEndAtomIndex = defaults(bbEndIndex, -1)\n\n let rungEndIndex\n if (PurinBases.includes(resname)) {\n rungEndIndex = this.getAtomIndexByName('N1')\n } else {\n rungEndIndex = this.getAtomIndexByName('N3')\n }\n this.rungEndAtomIndex = defaults(rungEndIndex, -1)\n }\n\n getBackboneIndexList () {\n const backboneIndexList: number[] = []\n let atomnameList\n switch (this.moleculeType) {\n case ProteinType:\n atomnameList = ProteinBackboneAtoms\n break\n case RnaType:\n case DnaType:\n atomnameList = NucleicBackboneAtoms\n break\n default:\n return backboneIndexList\n }\n const atomMap = this.structure.atomMap\n const atomTypeIdList = this.atomTypeIdList\n for (let i = 0, il = this.atomCount; i < il; ++i) {\n const atomType = atomMap.get(atomTypeIdList[ i ])\n if (atomnameList.includes(atomType.atomname)) {\n backboneIndexList.push(i)\n }\n }\n return backboneIndexList\n }\n\n getMoleculeType () {\n if (this.isProtein()) {\n return ProteinType\n } else if (this.isRna()) {\n return RnaType\n } else if (this.isDna()) {\n return DnaType\n } else if (this.isWater()) {\n return WaterType\n } else if (this.isIon()) {\n return IonType\n } else if (this.isSaccharide()) {\n return SaccharideType\n } else {\n return UnknownType\n }\n }\n\n getBackboneType (position: number) {\n if (this.hasProteinBackbone(position)) {\n return ProteinBackboneType\n } else if (this.hasRnaBackbone(position)) {\n return RnaBackboneType\n } else if (this.hasDnaBackbone(position)) {\n return DnaBackboneType\n } else if (this.hasCgProteinBackbone(position)) {\n return CgProteinBackboneType\n } else if (this.hasCgRnaBackbone(position)) {\n return CgRnaBackboneType\n } else if (this.hasCgDnaBackbone(position)) {\n return CgDnaBackboneType\n } else {\n return UnknownBackboneType\n }\n }\n\n isProtein () {\n if (this.chemCompType) {\n return ChemCompProtein.includes(this.chemCompType)\n } else {\n return (\n this.hasAtomWithName('CA', 'C', 'N') ||\n AA3.includes(this.resname)\n )\n }\n }\n\n isCg () {\n const backboneType = this.backboneType\n return (\n backboneType === CgProteinBackboneType ||\n backboneType === CgRnaBackboneType ||\n backboneType === CgDnaBackboneType\n )\n }\n\n isNucleic () {\n return this.isRna() || this.isDna()\n }\n\n isRna () {\n if (this.chemCompType) {\n return ChemCompRna.includes(this.chemCompType)\n } else if (this.hetero === 1) {\n return false\n } else {\n return (\n this.hasAtomWithName(\n [ 'P', \"O3'\", 'O3*' ], [ \"C4'\", 'C4*' ], [ \"O2'\", 'O2*', \"F2'\", 'F2*' ]\n ) ||\n (RnaBases.includes(this.resname) &&\n (this.hasAtomWithName([ \"O2'\", 'O2*', \"F2'\", 'F2*' ])))\n )\n }\n }\n\n isDna () {\n if (this.chemCompType) {\n return ChemCompDna.includes(this.chemCompType)\n } else if (this.hetero === 1) {\n return false\n } else {\n return (\n (this.hasAtomWithName([ 'P', \"O3'\", 'O3*' ], [ \"C3'\", 'C3*' ]) &&\n !this.hasAtomWithName([ \"O2'\", 'O2*', \"F2'\", 'F2*' ])) ||\n DnaBases.includes(this.resname)\n )\n }\n }\n\n isHetero () {\n return this.hetero === 1\n }\n\n isIon () {\n return IonNames.includes(this.resname)\n }\n\n isWater () {\n return WaterNames.includes(this.resname)\n }\n\n isSaccharide () {\n if (this.chemCompType) {\n return ChemCompSaccharide.includes(this.chemCompType)\n } else {\n return SaccharideNames.includes(this.resname)\n }\n }\n\n isStandardAminoacid () {\n return AA3.includes(this.resname)\n }\n\n isStandardBase () {\n return Bases.includes(this.resname)\n }\n\n hasBackboneAtoms (position: number, type: number) {\n const atomnames = ResidueTypeAtoms[ type ]\n if (position === -1) {\n return this.hasAtomWithName(\n atomnames.trace,\n atomnames.backboneEnd,\n atomnames.direction1,\n atomnames.direction2\n )\n } else if (position === 0) {\n return this.hasAtomWithName(\n atomnames.trace,\n atomnames.direction1,\n atomnames.direction2\n )\n } else if (position === 1) {\n return this.hasAtomWithName(\n atomnames.trace,\n atomnames.backboneStart,\n atomnames.direction1,\n atomnames.direction2\n )\n } else {\n return this.hasAtomWithName(\n atomnames.trace,\n atomnames.backboneStart,\n atomnames.backboneEnd,\n atomnames.direction1,\n atomnames.direction2\n )\n }\n }\n\n hasProteinBackbone (position: number) {\n return (\n this.isProtein() &&\n this.hasBackboneAtoms(position, ProteinBackboneType)\n )\n }\n\n hasRnaBackbone (position: number) {\n return (\n this.isRna() &&\n this.hasBackboneAtoms(position, RnaBackboneType)\n )\n }\n\n hasDnaBackbone (position: number) {\n return (\n this.isDna() &&\n this.hasBackboneAtoms(position, DnaBackboneType)\n )\n }\n\n hasCgProteinBackbone (position: number) {\n return (\n this.atomCount < 7 &&\n this.isProtein() &&\n this.hasBackboneAtoms(position, CgProteinBackboneType)\n )\n }\n\n hasCgRnaBackbone (position: number) {\n return (\n this.atomCount < 11 &&\n this.isRna() &&\n this.hasBackboneAtoms(position, CgRnaBackboneType)\n )\n }\n\n hasCgDnaBackbone (position: number) {\n return (\n this.atomCount < 11 &&\n this.isDna() &&\n this.hasBackboneAtoms(position, CgDnaBackboneType)\n )\n }\n\n hasBackbone (position: number) {\n return (\n this.hasProteinBackbone(position) ||\n this.hasRnaBackbone(position) ||\n this.hasDnaBackbone(position) ||\n this.hasCgProteinBackbone(position) ||\n this.hasCgRnaBackbone(position) ||\n this.hasCgDnaBackbone(position)\n )\n }\n\n getAtomIndexByName (atomname: string|string[]) {\n const n = this.atomCount\n const atomMap = this.structure.atomMap\n const atomTypeIdList = this.atomTypeIdList\n if (Array.isArray(atomname)) {\n for (let i = 0; i < n; ++i) {\n const index = atomTypeIdList[ i ]\n if (atomname.includes(atomMap.get(index).atomname)) {\n return i\n }\n }\n } else {\n for (let i = 0; i < n; ++i) {\n const index = atomTypeIdList[ i ]\n if (atomname === atomMap.get(index).atomname) {\n return i\n }\n }\n }\n return undefined\n }\n\n hasAtomWithName (...atomnames: (string|string[])[]) {\n const n = atomnames.length\n for (let i = 0; i < n; ++i) {\n if (atomnames[ i ] === undefined) continue\n if (this.getAtomIndexByName(atomnames[ i ]) === undefined) {\n return false\n }\n }\n return true\n }\n\n getBonds (r?: ResidueProxy) {\n if (this.bonds === undefined) {\n this.bonds = calculateResidueBonds(r!) // TODO\n }\n return this.bonds\n }\n\n getRings () {\n if (this.rings === undefined) {\n this.calculateRings()\n }\n return this.rings\n }\n\n getBondGraph () {\n if (this.bondGraph === undefined) {\n this.calculateBondGraph()\n }\n return this.bondGraph\n }\n\n getAromatic (a?: AtomProxy) {\n if (this.aromaticAtoms === undefined) {\n this.calculateAromatic(this.structure.getResidueProxy((a!).residueIndex)) // TODO\n }\n return this.aromaticAtoms\n }\n\n getAromaticRings (r?: ResidueProxy) {\n if (this.aromaticRings === undefined) {\n this.calculateAromatic(r!) // TODO\n }\n return this.aromaticRings\n }\n\n /**\n * @return {Object} bondGraph - represents the bonding in this\n * residue: { ai1: [ ai2, ai3, ...], ...}\n */\n calculateBondGraph () {\n const bondGraph: BondGraph = this.bondGraph = {}\n const bonds = this.getBonds()\n const nb = bonds.atomIndices1.length\n const atomIndices1 = bonds.atomIndices1\n const atomIndices2 = bonds.atomIndices2\n\n for (let i = 0; i < nb; ++i) {\n const ai1 = atomIndices1[i]\n const ai2 = atomIndices2[i]\n\n const a1 = bondGraph[ ai1 ] = bondGraph[ ai1 ] || []\n a1.push(ai2)\n\n const a2 = bondGraph[ ai2 ] = bondGraph[ ai2 ] || []\n a2.push(ai1)\n }\n }\n\n /**\n * Find all rings up to 2 * RingFinderMaxDepth\n */\n calculateRings () {\n const bondGraph = this.getBondGraph()! // TODO\n const state = RingFinderState(bondGraph, this.atomCount)\n\n for (let i = 0; i < state.count; i++) {\n if (state.visited[i] >= 0) continue\n findRings(state, i)\n }\n\n this.rings = { atomRings: state.atomRings, rings: state.rings }\n }\n\n isAromatic (atom: AtomProxy) {\n this.aromaticAtoms = this.getAromatic(atom)! // TODO\n return this.aromaticAtoms[atom.index - atom.residueAtomOffset] === 1\n }\n\n calculateAromatic (r: ResidueProxy) {\n const aromaticAtoms = this.aromaticAtoms = new Uint8Array(this.atomCount)\n const rings = this.getRings()!.rings\n\n const aromaticRingFlags = rings.map(ring => {\n return isRingAromatic(ring.map(idx => {\n return this.structure.getAtomProxy(idx + r.atomOffset)\n }))\n })\n\n const aromaticRings: number[][] = this.aromaticRings = []\n rings.forEach((ring, i) => {\n if (aromaticRingFlags[i]) {\n aromaticRings.push(ring)\n ring.forEach(idx => aromaticAtoms[idx] = 1)\n }\n })\n }\n\n /**\n * For bonds with order > 1, pick a reference atom\n * @return {undefined}\n */\n assignBondReferenceAtomIndices () {\n const bondGraph = this.getBondGraph()! // TODO\n const rings = this.getRings()! // TODO\n const atomRings = rings.atomRings\n const ringData = rings.rings\n\n const bonds = this.bonds! // TODO\n const atomIndices1 = bonds.atomIndices1\n const atomIndices2 = bonds.atomIndices2\n const bondOrders = bonds.bondOrders\n const bondReferenceAtomIndices = this.bondReferenceAtomIndices\n\n const nb = bonds.atomIndices1.length\n\n bondReferenceAtomIndices.length = 0 // reset array\n\n for (let i = 0; i < nb; ++i) {\n // Not required for single bonds\n if (bondOrders[i] <= 1) continue\n\n let refRing\n\n const ai1 = atomIndices1[i]\n const ai2 = atomIndices2[i]\n\n const rings1 = atomRings[ ai1 ]\n const rings2 = atomRings[ ai2 ]\n // Are both atoms in a ring?\n if (rings1 && rings2) {\n // Are they in the same ring? (If not, ignore ring info)\n for (let ri1 = 0; ri1 < rings1.length; ri1++){\n if (rings2.indexOf(rings1[ ri1 ]) !== -1) {\n refRing = ringData[ rings1[ ri1 ] ]\n break\n }\n }\n }\n\n // Find the first neighbour.\n if (bondGraph[ ai1 ].length > 1) {\n for (let j = 0; j < bondGraph[ ai1 ].length; ++j) {\n const ai3 = bondGraph[ ai1 ][ j ]\n if (ai3 !== ai2) {\n if (refRing === undefined || refRing.indexOf(ai3) !== -1){\n bondReferenceAtomIndices[i] = ai3\n break\n }\n }\n }\n } else if (bondGraph[ ai2 ].length > 1) {\n for (let j = 0; j < bondGraph[ ai2 ].length; ++j) {\n const ai3 = bondGraph[ ai2 ][ j ]\n if (ai3 !== ai1) {\n if (refRing === undefined || refRing.indexOf(ai3) !== -1){\n bondReferenceAtomIndices[i] = ai3\n break\n }\n }\n }\n } // No reference atom could be found (e.g. diatomic molecule/fragment)\n }\n }\n\n getBondIndex (atomIndex1: number, atomIndex2: number) {\n const bonds = this.bonds! // TODO\n const atomIndices1 = bonds.atomIndices1\n const atomIndices2 = bonds.atomIndices2\n let idx1 = atomIndices1.indexOf(atomIndex1)\n let idx2 = atomIndices2.indexOf(atomIndex2)\n const _idx2 = idx2\n while (idx1 !== -1) {\n while (idx2 !== -1) {\n if (idx1 === idx2) return idx1\n idx2 = atomIndices2.indexOf(atomIndex2, idx2 + 1)\n }\n idx1 = atomIndices1.indexOf(atomIndex1, idx1 + 1)\n idx2 = _idx2\n }\n // returns undefined when no bond is found\n }\n\n getBondReferenceAtomIndex (atomIndex1: number, atomIndex2: number) {\n const bondIndex = this.getBondIndex(atomIndex1, atomIndex2)\n if (bondIndex === undefined) return undefined\n if (this.bondReferenceAtomIndices.length === 0) {\n this.assignBondReferenceAtomIndices()\n }\n return this.bondReferenceAtomIndices[ bondIndex ]\n }\n}\n\n//\n\nconst AromaticRingElements = [\n Elements.B, Elements.C, Elements.N, Elements.O,\n Elements.SI, Elements.P, Elements.S,\n Elements.GE, Elements.AS,\n Elements.SN, Elements.SB,\n Elements.BI\n]\nconst AromaticRingPlanarityThreshold = 0.05\n\nfunction isRingAromatic (ring: AtomProxy[]) {\n if (ring.some(a => !AromaticRingElements.includes(a.number))) return false\n\n let i = 0\n const coords = new Matrix(3, ring.length)\n const cd = coords.data\n\n ring.forEach(a => {\n cd[ i + 0 ] = a.x\n cd[ i + 1 ] = a.y\n cd[ i + 2 ] = a.z\n i += 3\n })\n\n const pa = new PrincipalAxes(coords)\n\n return pa.vecC.length() < AromaticRingPlanarityThreshold\n}\n\n//\n\n/**\n * Ring finding code below adapted from MolQL\n * Copyright (c) 2017 MolQL contributors, licensed under MIT\n * @author David Sehnal \n */\n\nfunction addRing(state: RingFinderState, a: number, b: number) {\n // only \"monotonous\" rings\n if (b < a) return\n\n const { pred, color, left, right } = state\n const nc = ++state.currentColor\n\n let current = a\n\n for (let t = 0; t < RingFinderMaxDepth; t++) {\n color[current] = nc\n current = pred[current]\n if (current < 0) break\n }\n\n let leftOffset = 0\n let rightOffset = 0\n\n let found = false\n let target = 0\n current = b\n for (let t = 0; t < RingFinderMaxDepth; t++) {\n if (color[current] === nc) {\n target = current\n found = true\n break\n }\n right[rightOffset++] = current\n current = pred[current]\n if (current < 0) break\n }\n if (!found) return\n\n current = a\n for (let t = 0; t < RingFinderMaxDepth; t++) {\n left[leftOffset++] = current\n if (target === current) break\n current = pred[current]\n if (current < 0) break\n }\n\n const rn = leftOffset + rightOffset\n const ring: number[] = new Array(rn)\n let ringOffset = 0;\n for (let t = 0; t < leftOffset; t++) {\n ring[ringOffset++] = left[t]\n }\n for (let t = rightOffset - 1; t >= 0; t--) {\n ring[ringOffset++] = right[t]\n }\n\n const ri = state.rings.length\n // set atomRing indices:\n for (let i = 0; i < rn; ++i) {\n const ai = ring[i]\n if (state.atomRings[ai]) {\n state.atomRings[ai].push(ri)\n } else {\n state.atomRings[ai] = [ri]\n }\n }\n\n state.rings.push(ring)\n}\n\nfunction findRings(state: RingFinderState, from: number) {\n const { bonds, visited, queue, pred } = state\n\n visited[from] = 1\n queue[0] = from\n\n let head = 0\n let size = 1\n\n while (head < size) {\n const top = queue[head++]\n const start = 0\n if (bonds[top] === undefined) {\n continue\n }\n const end = bonds[top].length\n\n for (let i = start; i < end; i++) {\n const other = bonds[top][i]\n\n if (visited[other] > 0) {\n if (pred[other] !== top && pred[top] !== other) {\n addRing(state, top, other)\n }\n continue\n }\n\n visited[other] = 1\n queue[size++] = other\n pred[other] = top\n }\n }\n}\n\nconst RingFinderMaxDepth = 4\n\ninterface RingFinderState {\n count: number,\n visited: Int32Array,\n queue: Int32Array,\n color: Int32Array,\n pred: Int32Array,\n\n left: Int32Array,\n right: Int32Array,\n\n currentColor: number,\n\n rings: number[][],\n atomRings: number[][],\n\n bonds: BondGraph\n}\n\nfunction RingFinderState(bonds: BondGraph, capacity: number): RingFinderState {\n const state = {\n count: capacity,\n visited: new Int32Array(capacity),\n queue: new Int32Array(capacity),\n pred: new Int32Array(capacity),\n left: new Int32Array(RingFinderMaxDepth),\n right: new Int32Array(RingFinderMaxDepth),\n color: new Int32Array(capacity),\n currentColor: 0,\n rings: [],\n atomRings: [],\n bonds\n }\n for (let i = 0; i < capacity; i++) {\n state.visited[i] = -1\n state.pred[i] = -1\n }\n return state\n}\n","/**\n * @file Residue Map\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport { ResidueBonds } from '../structure/structure-utils'\nimport ResidueType from './residue-type'\n\nfunction getHash (resname: string, atomTypeIdList: number[], hetero: boolean, chemCompType = '') {\n return (\n resname + '|' +\n atomTypeIdList.join(',') + '|' +\n (hetero ? 1 : 0) + '|' +\n chemCompType\n )\n}\n\nclass ResidueMap {\n dict: { [k: string]: number } = {}\n list: ResidueType[] = []\n\n constructor (readonly structure: Structure) {}\n\n add (resname: string, atomTypeIdList: number[], hetero: boolean, chemCompType = '', bonds?: ResidueBonds) {\n resname = resname.toUpperCase()\n const hash = getHash(resname, atomTypeIdList, hetero, chemCompType)\n let id = this.dict[ hash ]\n if (id === undefined) {\n const residueType = new ResidueType(\n this.structure, resname, atomTypeIdList, hetero, chemCompType, bonds\n )\n id = this.list.length\n this.dict[ hash ] = id\n this.list.push(residueType)\n }\n return id\n }\n\n get (id: number) {\n return this.list[ id ]\n }\n}\n\nexport default ResidueMap\n","/**\n * @file Bond Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport Structure from '../structure/structure'\nimport BondStore from '../store/bond-store'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Bond proxy\n */\nclass BondProxy {\n index: number\n\n bondStore: BondStore\n\n private _v12: Vector3\n private _v13: Vector3\n private _ap1: AtomProxy\n private _ap2: AtomProxy\n private _ap3: AtomProxy\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.bondStore = structure.bondStore\n\n this._v12 = new Vector3()\n this._v13 = new Vector3()\n this._ap1 = this.structure.getAtomProxy()\n this._ap2 = this.structure.getAtomProxy()\n this._ap3 = this.structure.getAtomProxy()\n }\n\n /**\n * @type {AtomProxy}\n */\n get atom1 () {\n return this.structure.getAtomProxy(this.atomIndex1)\n }\n\n /**\n * @type {AtomProxy}\n */\n get atom2 () {\n return this.structure.getAtomProxy(this.atomIndex2)\n }\n\n /**\n * @type {Integer}\n */\n get atomIndex1 () {\n return this.bondStore.atomIndex1[ this.index ]\n }\n set atomIndex1 (value) {\n this.bondStore.atomIndex1[ this.index ] = value\n }\n\n /**\n * @type {Integer}\n */\n get atomIndex2 () {\n return this.bondStore.atomIndex2[ this.index ]\n }\n set atomIndex2 (value) {\n this.bondStore.atomIndex2[ this.index ] = value\n }\n\n /**\n * @type {Integer}\n */\n get bondOrder () {\n return this.bondStore.bondOrder[ this.index ]\n }\n set bondOrder (value) {\n this.bondStore.bondOrder[ this.index ] = value\n }\n\n getOtherAtomIndex (atomIndex: number) {\n return atomIndex === this.atomIndex1 ? this.atomIndex2 : this.atomIndex1\n }\n\n getOtherAtom (atom: AtomProxy) {\n return this.structure.getAtomProxy(this.getOtherAtomIndex(atom.index))\n }\n\n /**\n * Get reference atom index for the bond\n * @return {Integer|undefined} atom index, or `undefined` if unavailable\n */\n getReferenceAtomIndex () {\n const ap1 = this._ap1\n const ap2 = this._ap2\n ap1.index = this.atomIndex1\n ap2.index = this.atomIndex2\n if (ap1.residueIndex !== ap2.residueIndex) {\n return undefined // Bond between residues, for now ignore (could detect)\n }\n const typeAtomIndex1 = ap1.index - ap1.residueAtomOffset\n const typeAtomIndex2 = ap2.index - ap2.residueAtomOffset\n const residueType = ap1.residueType\n const ix = residueType.getBondReferenceAtomIndex(typeAtomIndex1, typeAtomIndex2)\n if (ix !== undefined) {\n return ix + ap1.residueAtomOffset\n } else {\n console.warn('No reference atom found', ap1.index, ap2.index)\n }\n }\n\n /**\n * calculate shift direction for displaying double/triple bonds\n * @param {Vector3} [v] pre-allocated output vector\n * @return {Vector3} the shift direction vector\n */\n calculateShiftDir (v = new Vector3()) {\n const ap1 = this._ap1\n const ap2 = this._ap2\n const ap3 = this._ap3\n const v12 = this._v12\n const v13 = this._v13\n\n ap1.index = this.atomIndex1\n ap2.index = this.atomIndex2\n const ai3 = this.getReferenceAtomIndex()\n\n v12.subVectors(ap1 as any, ap2 as any).normalize() // TODO\n if (ai3 !== undefined) {\n ap3.index = ai3\n v13.subVectors(ap1 as any, ap3 as any) // TODO\n } else {\n v13.copy(ap1 as any) // no reference point, use origin // TODO\n }\n v13.normalize()\n\n // make sure v13 and v12 are not colinear\n let dp = v12.dot(v13)\n if (1 - Math.abs(dp) < 1e-5) {\n v13.set(1, 0, 0)\n dp = v12.dot(v13)\n if (1 - Math.abs(dp) < 1e-5) {\n v13.set(0, 1, 0)\n dp = v12.dot(v13)\n }\n }\n\n return v.copy(v13.sub(v12.multiplyScalar(dp))).normalize()\n }\n\n qualifiedName () {\n return this.atomIndex1 + '=' + this.atomIndex2\n }\n\n /**\n * Clone object\n * @return {BondProxy} cloned bond\n */\n clone () {\n return new BondProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n atomIndex1: this.atomIndex1,\n atomIndex2: this.atomIndex2,\n bondOrder: this.bondOrder\n }\n }\n}\n\nexport default BondProxy\n","/**\n * @file Residue Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { NumberArray } from '../types'\nimport { defaults } from '../utils'\nimport {\n SecStrucHelix, SecStrucSheet, SecStrucTurn,\n ProteinType, RnaType, DnaType, WaterType, IonType, SaccharideType,\n CgProteinBackboneType, CgRnaBackboneType, CgDnaBackboneType,\n AA1\n} from '../structure/structure-constants'\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\n\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\nimport AtomStore from '../store/atom-store'\n\nimport AtomMap from '../store/atom-map'\nimport ResidueMap from '../store/residue-map'\n\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueType, { RingData } from '../store/residue-type';\nimport { ResidueBonds } from '../structure/structure-utils';\nimport AtomType from '../store/atom-type';\nimport ChainProxy from './chain-proxy';\nimport Entity from '../structure/entity';\n\n/**\n * Residue proxy\n */\nclass ResidueProxy {\n index: number\n\n chainStore: ChainStore\n residueStore: ResidueStore\n atomStore: AtomStore\n\n residueMap: ResidueMap\n atomMap: AtomMap\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n this.atomStore = structure.atomStore\n this.residueMap = structure.residueMap\n this.atomMap = structure.atomMap\n }\n\n /**\n * Entity\n * @type {Entity}\n */\n get entity (): Entity {\n return this.structure.entityList[ this.entityIndex ]\n }\n get entityIndex () {\n return this.chainStore.entityIndex[ this.chainIndex ]\n }\n /**\n * Chain\n * @type {ChainProxy}\n */\n get chain (): ChainProxy {\n return this.structure.getChainProxy(this.chainIndex)\n }\n\n get chainIndex () {\n return this.residueStore.chainIndex[ this.index ]\n }\n set chainIndex (value) {\n this.residueStore.chainIndex[ this.index ] = value\n }\n\n get atomOffset () {\n return this.residueStore.atomOffset[ this.index ]\n }\n set atomOffset (value) {\n this.residueStore.atomOffset[ this.index ] = value\n }\n\n /**\n * Atom count\n * @type {Integer}\n */\n get atomCount () {\n return this.residueStore.atomCount[ this.index ]\n }\n set atomCount (value) {\n this.residueStore.atomCount[ this.index ] = value\n }\n\n get atomEnd () {\n return this.atomOffset + this.atomCount - 1\n }\n\n //\n\n get modelIndex () {\n return this.chainStore.modelIndex[ this.chainIndex ]\n }\n /**\n * Chain name\n * @type {String}\n */\n get chainname () {\n return this.chainStore.getChainname(this.chainIndex)\n }\n /**\n * Chain id\n * @type {String}\n */\n get chainid () {\n return this.chainStore.getChainid(this.chainIndex)\n }\n\n //\n\n /**\n * Residue number/label\n * @type {Integer}\n */\n get resno () {\n return this.residueStore.resno[ this.index ]\n }\n set resno (value) {\n this.residueStore.resno[ this.index ] = value\n }\n\n /**\n * Secondary structure code\n * @type {String}\n */\n get sstruc () {\n return this.residueStore.getSstruc(this.index)\n }\n set sstruc (value) {\n this.residueStore.setSstruc(this.index, value)\n }\n\n /**\n * Insertion code\n * @type {String}\n */\n get inscode () {\n return this.residueStore.getInscode(this.index)\n }\n set inscode (value) {\n this.residueStore.setInscode(this.index, value)\n }\n\n //\n\n get residueType (): ResidueType {\n return this.residueMap.get(this.residueStore.residueTypeId[ this.index ])\n }\n\n /**\n * Residue name\n * @type {String}\n */\n get resname () {\n return this.residueType.resname\n }\n /**\n * Hetero flag\n * @type {Boolean}\n */\n get hetero () {\n return this.residueType.hetero\n }\n get moleculeType () {\n return this.residueType.moleculeType\n }\n get backboneType () {\n return this.residueType.backboneType\n }\n get backboneStartType () {\n return this.residueType.backboneStartType\n }\n get backboneEndType () {\n return this.residueType.backboneEndType\n }\n get traceAtomIndex () {\n return this.residueType.traceAtomIndex + this.atomOffset\n }\n get direction1AtomIndex () {\n return this.residueType.direction1AtomIndex + this.atomOffset\n }\n get direction2AtomIndex () {\n return this.residueType.direction2AtomIndex + this.atomOffset\n }\n get backboneStartAtomIndex () {\n return this.residueType.backboneStartAtomIndex + this.atomOffset\n }\n get backboneEndAtomIndex () {\n return this.residueType.backboneEndAtomIndex + this.atomOffset\n }\n get rungEndAtomIndex () {\n return this.residueType.rungEndAtomIndex + this.atomOffset\n }\n\n //\n\n get x () {\n let x = 0\n for (let i = this.atomOffset; i <= this.atomEnd; ++i) {\n x += this.atomStore.x[ i ]\n }\n return x / this.atomCount\n }\n\n get y () {\n let y = 0\n for (let i = this.atomOffset; i <= this.atomEnd; ++i) {\n y += this.atomStore.y[ i ]\n }\n return y / this.atomCount\n }\n\n get z () {\n let z = 0\n for (let i = this.atomOffset; i <= this.atomEnd; ++i) {\n z += this.atomStore.z[ i ]\n }\n return z / this.atomCount\n }\n\n //\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (ap: AtomProxy) => void, selection?: Selection) {\n const count = this.atomCount\n const offset = this.atomOffset\n const ap = this.structure._ap\n const end = offset + count\n\n if (selection && selection.atomOnlyTest) {\n const atomOnlyTest = selection.atomOnlyTest\n for (let i = offset; i < end; ++i) {\n ap.index = i\n if (atomOnlyTest(ap)) callback(ap)\n }\n } else {\n for (let i = offset; i < end; ++i) {\n ap.index = i\n callback(ap)\n }\n }\n }\n\n //\n\n /**\n * Write residue center position to array\n * @param {Array|TypedArray} [array] - target array\n * @param {Integer} [offset] - the offset\n * @return {Array|TypedArray} target array\n */\n positionToArray (array: NumberArray = [], offset = 0) {\n array[ offset + 0 ] = this.x\n array[ offset + 1 ] = this.y\n array[ offset + 2 ] = this.z\n\n return array\n }\n\n //\n\n /**\n * If residue is from a protein\n * @return {Boolean} flag\n */\n isProtein () {\n return this.residueType.moleculeType === ProteinType\n }\n\n /**\n * If residue is nucleic\n * @return {Boolean} flag\n */\n isNucleic () {\n const moleculeType = this.residueType.moleculeType\n return moleculeType === RnaType || moleculeType === DnaType\n }\n\n /**\n * If residue is rna\n * @return {Boolean} flag\n */\n isRna () {\n return this.residueType.moleculeType === RnaType\n }\n\n /**\n * If residue is dna\n * @return {Boolean} flag\n */\n isDna () {\n return this.residueType.moleculeType === DnaType\n }\n\n /**\n * If residue is coarse-grain\n * @return {Boolean} flag\n */\n isCg () {\n const backboneType = this.residueType.backboneType\n return (\n backboneType === CgProteinBackboneType ||\n backboneType === CgRnaBackboneType ||\n backboneType === CgDnaBackboneType\n )\n }\n\n /**\n * If residue is from a polymer\n * @return {Boolean} flag\n */\n isPolymer () {\n if (this.structure.entityList.length > 0) {\n return this.entity.isPolymer()\n } else {\n const moleculeType = this.residueType.moleculeType\n return (\n moleculeType === ProteinType ||\n moleculeType === RnaType ||\n moleculeType === DnaType\n )\n }\n }\n\n /**\n * If residue is hetero\n * @return {Boolean} flag\n */\n isHetero () {\n return this.residueType.hetero === 1\n }\n\n /**\n * If residue is a water molecule\n * @return {Boolean} flag\n */\n isWater () {\n return this.residueType.moleculeType === WaterType\n }\n\n /**\n * If residue is an ion\n * @return {Boolean} flag\n */\n isIon () {\n return this.residueType.moleculeType === IonType\n }\n\n /**\n * If residue is a saccharide\n * @return {Boolean} flag\n */\n isSaccharide () {\n return this.residueType.moleculeType === SaccharideType\n }\n\n isStandardAminoacid () {\n return this.residueType.isStandardAminoacid()\n }\n\n isStandardBase () {\n return this.residueType.isStandardBase()\n }\n\n /**\n * If residue is part of a helix\n * @return {Boolean} flag\n */\n isHelix () {\n return SecStrucHelix.includes(this.sstruc)\n }\n\n /**\n * If residue is part of a sheet\n * @return {Boolean} flag\n */\n isSheet () {\n return SecStrucSheet.includes(this.sstruc)\n }\n\n /**\n * If residue is part of a turn\n * @return {Boolean} flag\n */\n isTurn () {\n return SecStrucTurn.includes(this.sstruc) && this.isProtein()\n }\n\n getAtomType (index: number): AtomType {\n return this.atomMap.get(this.atomStore.atomTypeId[ index ])\n }\n\n getResname1 () {\n // FIXME nucleic support\n return AA1[ this.resname.toUpperCase() ] || 'X'\n }\n\n getBackboneType (position: number) {\n switch (position) {\n case -1:\n return this.residueType.backboneStartType\n case 1:\n return this.residueType.backboneEndType\n default:\n return this.residueType.backboneType\n }\n }\n\n getAtomIndexByName (atomname: string) {\n let index = this.residueType.getAtomIndexByName(atomname)\n if (index !== undefined) {\n index += this.atomOffset\n }\n return index\n }\n\n hasAtomWithName (atomname: string) {\n return this.residueType.hasAtomWithName(atomname)\n }\n\n getAtomnameList () {\n console.warn('getAtomnameList - might be expensive')\n\n const n = this.atomCount\n const offset = this.atomOffset\n const list = new Array(n)\n for (let i = 0; i < n; ++i) {\n list[ i ] = this.getAtomType(offset + i).atomname\n }\n return list\n }\n\n /**\n * If residue is connected to another\n * @param {ResidueProxy} rNext - the other residue\n * @return {Boolean} - flag\n */\n connectedTo (rNext: ResidueProxy) {\n const bbAtomEnd = this.structure.getAtomProxy(this.backboneEndAtomIndex)\n const bbAtomStart = this.structure.getAtomProxy(rNext.backboneStartAtomIndex)\n if (bbAtomEnd && bbAtomStart) {\n return bbAtomEnd.connectedTo(bbAtomStart)\n } else {\n return false\n }\n }\n\n getNextConnectedResidue () {\n const rOffset = this.chainStore.residueOffset[ this.chainIndex ]\n const rCount = this.chainStore.residueCount[ this.chainIndex ]\n const nextIndex = this.index + 1\n if (nextIndex < rOffset + rCount) {\n const rpNext = this.structure.getResidueProxy(nextIndex)\n if (this.connectedTo(rpNext)) {\n return rpNext\n }\n } else if (nextIndex === rOffset + rCount) { // cyclic\n const rpFirst = this.structure.getResidueProxy(rOffset)\n if (this.connectedTo(rpFirst)) {\n return rpFirst\n }\n }\n return undefined\n }\n\n getPreviousConnectedResidue (residueProxy?: ResidueProxy) {\n const rOffset = this.chainStore.residueOffset[ this.chainIndex ]\n const prevIndex = this.index - 1\n if (prevIndex >= rOffset) {\n const rpPrev = defaults(residueProxy, this.structure.getResidueProxy())\n rpPrev.index = prevIndex\n if (rpPrev.connectedTo(this)) {\n return rpPrev\n }\n } else if (prevIndex === rOffset - 1) { // cyclic\n const rCount = this.chainStore.residueCount[ this.chainIndex ]\n const rpLast = defaults(residueProxy, this.structure.getResidueProxy())\n rpLast.index = rOffset + rCount - 1\n if (rpLast.connectedTo(this)) {\n return rpLast\n }\n }\n return undefined\n }\n\n getBonds (): ResidueBonds {\n return this.residueType.getBonds(this)\n }\n\n getRings (): RingData|undefined {\n return this.residueType.getRings()\n }\n\n getAromaticRings () {\n return this.residueType.getAromaticRings(this)\n }\n\n qualifiedName (noResname = false) {\n let name = ''\n if (this.resname && !noResname) name += '[' + this.resname + ']'\n if (this.resno !== undefined) name += this.resno\n if (this.inscode) name += '^' + this.inscode\n if (this.chain) name += ':' + this.chainname\n name += '/' + this.modelIndex\n return name\n }\n\n /**\n * Clone object\n * @return {ResidueProxy} cloned residue\n */\n clone () {\n return new ResidueProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n index: this.index,\n chainIndex: this.chainIndex,\n atomOffset: this.atomOffset,\n atomCount: this.atomCount,\n\n resno: this.resno,\n resname: this.resname,\n sstruc: this.sstruc\n }\n }\n}\n\nexport default ResidueProxy\n","/**\n * @file Polymer\n * @author Alexander Rose \n * @private\n */\n\n// import { Log } from '../globals'\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\n\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\nimport AtomStore from '../store/atom-store'\n\nimport ResidueProxy from '../proxy/residue-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Polymer\n */\nclass Polymer {\n chainStore: ChainStore\n residueStore: ResidueStore\n atomStore: AtomStore\n\n residueCount: number\n\n isPrevConnected: boolean\n isNextConnected: boolean\n isNextNextConnected: boolean\n isCyclic: boolean\n\n private __residueProxy: ResidueProxy\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} residueIndexStart - the index of the first residue\n * @param {Integer} residueIndexEnd - the index of the last residue\n */\n constructor (readonly structure: Structure, readonly residueIndexStart: number, readonly residueIndexEnd: number) {\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n this.atomStore = structure.atomStore\n\n /**\n * @type {Integer}\n */\n this.residueCount = residueIndexEnd - residueIndexStart + 1\n\n const rpStart = this.structure.getResidueProxy(this.residueIndexStart)\n const rpEnd = this.structure.getResidueProxy(this.residueIndexEnd)\n this.isPrevConnected = rpStart.getPreviousConnectedResidue() !== undefined\n const rpNext = rpEnd.getNextConnectedResidue()\n this.isNextConnected = rpNext !== undefined\n this.isNextNextConnected = rpNext !== undefined && rpNext.getNextConnectedResidue() !== undefined\n this.isCyclic = rpEnd.connectedTo(rpStart)\n\n this.__residueProxy = this.structure.getResidueProxy()\n\n // console.log( this.qualifiedName(), this );\n }\n\n get chainIndex () {\n return this.residueStore.chainIndex[ this.residueIndexStart ]\n }\n get modelIndex () {\n return this.chainStore.modelIndex[ this.chainIndex ]\n }\n\n /**\n * @type {String}\n */\n get chainname () {\n return this.chainStore.getChainname(this.chainIndex)\n }\n\n //\n\n /**\n * If first residue is from aprotein\n * @return {Boolean} flag\n */\n isProtein () {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.isProtein()\n }\n\n /**\n * If atom is part of a coarse-grain group\n * @return {Boolean} flag\n */\n isCg () {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.isCg()\n }\n\n /**\n * If atom is part of a nucleic molecule\n * @return {Boolean} flag\n */\n isNucleic () {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.isNucleic()\n }\n\n getMoleculeType () {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.moleculeType\n }\n\n getBackboneType (position: number) {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.getBackboneType(position)\n }\n\n getAtomIndexByType (index: number, type: string) {\n // TODO pre-calculate, add to residueStore???\n\n if (this.isCyclic) {\n if (index === -1) {\n index = this.residueCount - 1\n } else if (index === this.residueCount) {\n index = 0\n }\n } else {\n if (index === -1 && !this.isPrevConnected) index += 1\n if (index === this.residueCount && !this.isNextNextConnected) index -= 1\n // if( index === this.residueCount - 1 && !this.isNextConnected ) index -= 1;\n }\n\n const rp = this.__residueProxy\n rp.index = this.residueIndexStart + index\n let aIndex\n\n switch (type) {\n case 'trace':\n aIndex = rp.traceAtomIndex\n break\n case 'direction1':\n aIndex = rp.direction1AtomIndex\n break\n case 'direction2':\n aIndex = rp.direction2AtomIndex\n break\n default:\n aIndex = rp.getAtomIndexByName(type)\n }\n\n // if (!ap){\n // console.log(this, type, rp.residueType)\n // // console.log(rp.qualifiedName(), rp.index, index, this.residueCount - 1)\n // // rp.index = this.residueIndexStart;\n // // console.log(rp.qualifiedName(), this.residueIndexStart)\n // // rp.index = this.residueIndexEnd;\n // // console.log(rp.qualifiedName(), this.residueIndexEnd)\n // }\n\n return aIndex\n }\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (ap: AtomProxy) => void, selection?: Selection) {\n this.eachResidue(function (rp) {\n rp.eachAtom(callback, selection)\n })\n }\n\n eachAtomN (n: number, callback: (...apArray: AtomProxy[]) => void, type: string) {\n const m = this.residueCount\n const array: AtomProxy[] = new Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = this.structure.getAtomProxy(this.getAtomIndexByType(i, type))\n }\n callback.apply(this, array)\n\n for (var j = n; j < m; ++j) {\n for (let i = 1; i < n; ++i) {\n array[ i - 1 ].index = array[ i ].index\n }\n array[ n - 1 ].index = this.getAtomIndexByType(j, type)! // TODO\n callback.apply(this, array)\n }\n }\n\n /**\n * Residue iterator\n * @param {function(residue: ResidueProxy)} callback - the callback\n * @return {undefined}\n */\n eachResidue (callback: (rp: ResidueProxy) => void) {\n const rp = this.structure.getResidueProxy()\n const n = this.residueCount\n const rStartIndex = this.residueIndexStart\n\n for (let i = 0; i < n; ++i) {\n rp.index = rStartIndex + i\n callback(rp)\n }\n }\n\n qualifiedName () {\n const rpStart = this.structure.getResidueProxy(this.residueIndexStart)\n const rpEnd = this.structure.getResidueProxy(this.residueIndexEnd)\n return rpStart.qualifiedName() + ' - ' + rpEnd.qualifiedName()\n }\n}\n\nexport default Polymer\n","/**\n * @file Chain Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { UnknownBackboneType } from '../structure/structure-constants'\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\n\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\n\nimport Polymer from '../proxy/polymer'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ModelProxy from './model-proxy';\nimport Entity from '../structure/entity';\n\n/**\n * Chain proxy\n */\nclass ChainProxy {\n index: number\n\n chainStore: ChainStore\n residueStore: ResidueStore\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n }\n\n /**\n * Entity\n * @type {Entity}\n */\n get entity (): Entity {\n return this.structure.entityList[ this.entityIndex ]\n }\n /**\n * Model\n * @type {ModelProxy}\n */\n get model (): ModelProxy {\n return this.structure.getModelProxy(this.modelIndex)\n }\n\n get entityIndex () {\n return this.chainStore.entityIndex[ this.index ]\n }\n set entityIndex (value) {\n this.chainStore.entityIndex[ this.index ] = value\n }\n\n get modelIndex () {\n return this.chainStore.modelIndex[ this.index ]\n }\n set modelIndex (value) {\n this.chainStore.modelIndex[ this.index ] = value\n }\n\n get residueOffset () {\n return this.chainStore.residueOffset[ this.index ]\n }\n set residueOffset (value) {\n this.chainStore.residueOffset[ this.index ] = value\n }\n\n /**\n * Residue count\n * @type {Integer}\n */\n get residueCount () {\n return this.chainStore.residueCount[ this.index ]\n }\n set residueCount (value) {\n this.chainStore.residueCount[ this.index ] = value\n }\n\n get residueEnd () {\n return this.residueOffset + this.residueCount - 1\n }\n\n get atomOffset () {\n return this.residueStore.atomOffset[ this.residueOffset ]\n }\n get atomEnd () {\n return (\n this.residueStore.atomOffset[ this.residueEnd ] +\n this.residueStore.atomCount[ this.residueEnd ] - 1\n )\n }\n /**\n * Atom count\n * @type {Integer}\n */\n get atomCount () {\n if (this.residueCount === 0) {\n return 0\n } else {\n return this.atomEnd - this.atomOffset + 1\n }\n }\n\n //\n\n /**\n * Chain name\n * @type {String}\n */\n get chainname () {\n return this.chainStore.getChainname(this.index)\n }\n set chainname (value) {\n this.chainStore.setChainname(this.index, value)\n }\n\n /**\n * Chain id\n * @type {String}\n */\n get chainid () {\n return this.chainStore.getChainid(this.index)\n }\n set chainid (value) {\n this.chainStore.setChainid(this.index, value)\n }\n\n //\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (ap: AtomProxy) => void, selection?: Selection) {\n this.eachResidue(function (rp) {\n rp.eachAtom(callback, selection)\n }, selection)\n }\n\n /**\n * Residue iterator\n * @param {function(residue: ResidueProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachResidue (callback: (rp: ResidueProxy) => void, selection?: Selection) {\n const count = this.residueCount\n const offset = this.residueOffset\n const rp = this.structure._rp\n const end = offset + count\n\n if (selection && selection.test) {\n const residueOnlyTest = selection.residueOnlyTest\n if (residueOnlyTest) {\n for (let i = offset; i < end; ++i) {\n rp.index = i\n if (residueOnlyTest(rp)) {\n callback(rp)\n }\n }\n } else {\n for (let i = offset; i < end; ++i) {\n rp.index = i\n callback(rp)\n }\n }\n } else {\n for (let i = offset; i < end; ++i) {\n rp.index = i\n callback(rp)\n }\n }\n }\n\n /**\n * Multi-residue iterator\n * @param {Integer} n - window size\n * @param {function(residueList: ResidueProxy[])} callback - the callback\n * @return {undefined}\n */\n eachResidueN (n: number, callback: (...rpArray: ResidueProxy[]) => void) {\n const count = this.residueCount\n const offset = this.residueOffset\n const end = offset + count\n if (count < n) return\n const array: ResidueProxy[] = new Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = this.structure.getResidueProxy(offset + i)\n }\n callback.apply(this, array)\n\n for (let j = offset + n; j < end; ++j) {\n for (let i = 0; i < n; ++i) {\n array[ i ].index += 1\n }\n callback.apply(this, array)\n }\n }\n\n /**\n * Polymer iterator\n * @param {function(polymer: Polymer)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachPolymer (callback: (p: Polymer) => void, selection?: Selection) {\n let rStartIndex = 0\n let rNextIndex = 0\n const test = selection ? selection.residueOnlyTest : undefined\n const structure = this.model.structure\n\n const count = this.residueCount\n const offset = this.residueOffset\n const end = offset + count\n\n const rp1 = this.structure.getResidueProxy()\n const rp2 = this.structure.getResidueProxy(offset)\n\n const ap1 = this.structure.getAtomProxy()\n const ap2 = this.structure.getAtomProxy()\n\n let first = true\n\n for (let i = offset + 1; i < end; ++i) {\n rp1.index = rp2.index\n rp2.index = i\n\n const bbType1 = first ? rp1.backboneEndType : rp1.backboneType\n const bbType2 = rp2.backboneType\n\n if (first) {\n rStartIndex = rp1.index\n first = false\n }\n rNextIndex = rp2.index\n\n if (bbType1 !== UnknownBackboneType && bbType1 === bbType2) {\n ap1.index = rp1.backboneEndAtomIndex\n ap2.index = rp2.backboneStartAtomIndex\n } else {\n if (bbType1 !== UnknownBackboneType) {\n if (rp1.index - rStartIndex > 1) {\n // console.log(\"FOO1\",rStartIndex, rp1.index)\n callback(new Polymer(structure, rStartIndex, rp1.index))\n }\n }\n rStartIndex = rNextIndex\n\n continue\n }\n\n if (!ap1 || !ap2 || !ap1.connectedTo(ap2) ||\n (test && (!test(rp1) || !test(rp2)))\n ) {\n if (rp1.index - rStartIndex > 1) {\n // console.log(\"FOO2\",rStartIndex, rp1.index)\n callback(new Polymer(structure, rStartIndex, rp1.index))\n }\n rStartIndex = rNextIndex\n }\n }\n\n if (rNextIndex - rStartIndex > 1) {\n if (this.structure.getResidueProxy(rStartIndex).backboneEndType) {\n // console.log(\"FOO3\",rStartIndex, rNextIndex)\n callback(new Polymer(structure, rStartIndex, rNextIndex))\n }\n }\n }\n\n //\n\n qualifiedName () {\n var name = ':' + this.chainname + '/' + this.modelIndex\n return name\n }\n\n /**\n * Clone object\n * @return {ChainProxy} cloned chain\n */\n clone () {\n return new ChainProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n index: this.index,\n residueOffset: this.residueOffset,\n residueCount: this.residueCount,\n\n chainname: this.chainname\n }\n }\n}\n\nexport default ChainProxy\n","/**\n * @file Model Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\n\nimport ModelStore from '../store/model-store'\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\n\nimport ChainProxy from '../proxy/chain-proxy'\nimport Polymer from '../proxy/polymer'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Model proxy\n */\nclass ModelProxy {\n index: number\n\n modelStore: ModelStore\n chainStore: ChainStore\n residueStore: ResidueStore\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.modelStore = structure.modelStore\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n }\n\n get chainOffset () {\n return this.modelStore.chainOffset[ this.index ]\n }\n set chainOffset (value) {\n this.modelStore.chainOffset[ this.index ] = value\n }\n\n get chainCount () {\n return this.modelStore.chainCount[ this.index ]\n }\n set chainCount (value) {\n this.modelStore.chainCount[ this.index ] = value\n }\n\n get residueOffset () {\n return this.chainStore.residueOffset[ this.chainOffset ]\n }\n get atomOffset () {\n return this.residueStore.atomOffset[ this.residueOffset ]\n }\n\n get chainEnd () {\n return this.chainOffset + this.chainCount - 1\n }\n get residueEnd () {\n return (\n this.chainStore.residueOffset[ this.chainEnd ] +\n this.chainStore.residueCount[ this.chainEnd ] - 1\n )\n }\n get atomEnd () {\n return (\n this.residueStore.atomOffset[ this.residueEnd ] +\n this.residueStore.atomCount[ this.residueEnd ] - 1\n )\n }\n\n /**\n * Residue count\n * @type {Integer}\n */\n get residueCount () {\n if (this.chainCount === 0) {\n return 0\n } else {\n return this.residueEnd - this.residueOffset + 1\n }\n }\n\n /**\n * Atom count\n * @type {Integer}\n */\n get atomCount () {\n if (this.residueCount === 0) {\n return 0\n } else {\n return this.atomEnd - this.atomOffset + 1\n }\n }\n\n //\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (ap: AtomProxy) => void, selection?: Selection) {\n this.eachChain(function (cp) {\n cp.eachAtom(callback, selection)\n }, selection)\n }\n\n /**\n * Residue iterator\n * @param {function(residue: ResidueProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachResidue (callback: (rp: ResidueProxy) => void, selection?: Selection) {\n this.eachChain(function (cp) {\n cp.eachResidue(callback, selection)\n }, selection)\n }\n\n /**\n * Polymer iterator\n * @param {function(polymer: Polymer)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachPolymer (callback: (p: Polymer) => void, selection?: Selection) {\n if (selection && selection.chainOnlyTest) {\n const chainOnlyTest = selection.chainOnlyTest\n\n this.eachChain(function (cp) {\n if (chainOnlyTest(cp)) {\n cp.eachPolymer(callback, selection)\n }\n })\n } else {\n this.eachChain(function (cp) {\n cp.eachPolymer(callback, selection)\n })\n }\n }\n\n /**\n * Chain iterator\n * @param {function(chain: ChainProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachChain (callback: (cp: ChainProxy) => void, selection?: Selection) {\n const count = this.chainCount\n const offset = this.chainOffset\n const cp = this.structure._cp\n const end = offset + count\n\n if (selection && selection.test) {\n const chainOnlyTest = selection.chainOnlyTest\n if (chainOnlyTest) {\n for (let i = offset; i < end; ++i) {\n cp.index = i\n if (chainOnlyTest(cp)) {\n callback(cp)\n }\n }\n } else {\n for (let i = offset; i < end; ++i) {\n cp.index = i\n callback(cp)\n }\n }\n } else {\n for (let i = offset; i < end; ++i) {\n cp.index = i\n callback(cp)\n }\n }\n }\n\n //\n\n qualifiedName () {\n const name = '/' + this.index\n return name\n }\n\n /**\n * Clone object\n * @return {ModelProxy} cloned model\n */\n clone () {\n return new ModelProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n index: this.index,\n chainOffset: this.chainOffset,\n chainCount: this.chainCount\n }\n }\n}\n\nexport default ModelProxy\n","/**\n * @file Structure\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3 } from 'three'\nimport { Signal } from 'signals'\n\nimport { Debug, Log, ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { AtomPicker, BondPicker } from '../utils/picker'\nimport { copyWithin, arrayMin, arrayMax } from '../math/array-utils'\nimport BitArray from '../utils/bitarray'\nimport RadiusFactory, { RadiusParams } from '../utils/radius-factory'\nimport { Matrix } from '../math/matrix-utils'\nimport PrincipalAxes from '../math/principal-axes'\nimport SpatialHash from '../geometry/spatial-hash'\nimport FilteredVolume from '../surface/filtered-volume'\nimport StructureView from './structure-view'\nimport { AtomDataParams, AtomData, BondDataParams, BondData } from './structure-data'\nimport { Data, createData } from './data'\n\nimport Entity from './entity'\nimport Unitcell from '../symmetry/unitcell'\nimport Validation from './validation'\nimport Selection from '../selection/selection'\nimport Assembly from '../symmetry/assembly'\nimport Volume from '../surface/volume'\nimport Polymer from '../proxy/polymer'\n\nimport BondHash from '../store/bond-hash'\nimport BondStore from '../store/bond-store'\nimport AtomStore from '../store/atom-store'\nimport ResidueStore from '../store/residue-store'\nimport ChainStore from '../store/chain-store'\nimport ModelStore from '../store/model-store'\n\nimport AtomMap from '../store/atom-map'\nimport ResidueMap from '../store/residue-map'\n\nimport BondProxy from '../proxy/bond-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\ninterface Structure {\n signals: StructureSignals\n\n name: string\n path: string\n title: string\n id: string\n\n data: Data\n\n atomCount: number\n bondCount: number\n\n header: StructureHeader\n extraData: StructureExtraData\n\n atomSetCache: { [k: string]: BitArray }\n atomSetDict: { [k: string]: BitArray }\n biomolDict: { [k: string]: Assembly }\n\n entityList: Entity[]\n unitcell?: Unitcell\n\n frames: Float32Array[]\n boxes: Float32Array[]\n\n validation?: Validation\n\n bondStore: BondStore\n backboneBondStore: BondStore\n rungBondStore: BondStore\n atomStore: AtomStore\n residueStore: ResidueStore\n chainStore: ChainStore\n modelStore: ModelStore\n\n atomMap: AtomMap\n residueMap: ResidueMap\n\n bondHash?: BondHash\n spatialHash?: SpatialHash\n\n atomSet?: BitArray\n bondSet?: BitArray\n\n center: Vector3\n boundingBox: Box3\n\n trajectory?: {\n name: string\n frame: number\n }\n\n getView(selection: Selection): StructureView\n\n _hasCoords?: boolean\n\n _bp: BondProxy\n _ap: AtomProxy\n _rp: ResidueProxy\n _cp: ChainProxy\n}\n\nexport type StructureHeader = {\n releaseDate?: string\n depositionDate?: string\n resolution?: number\n rFree?: number\n rWork?: number\n experimentalMethods?: string[]\n}\n\nexport type StructureExtraData = {\n cif?: object\n sdf?: object[]\n}\n\nexport type StructureSignals = {\n refreshed: Signal\n}\n\n/**\n * Structure\n */\nclass Structure implements Structure{\n signals: StructureSignals = {\n refreshed: new Signal()\n }\n\n /**\n * @param {String} name - structure name\n * @param {String} path - source path\n */\n constructor (name = '', path = '') {\n this.init(name, path)\n }\n\n init (name: string, path: string) {\n this.name = name\n this.path = path\n this.title = ''\n this.id = ''\n\n this.data = createData(this)\n\n this.header = {}\n this.extraData = {}\n\n this.atomSetCache = {}\n this.atomSetDict = {}\n this.biomolDict = {}\n\n this.entityList = []\n this.unitcell = undefined\n\n this.frames = []\n this.boxes = []\n\n this.validation = undefined\n\n this.bondStore = new BondStore(0)\n this.backboneBondStore = new BondStore(0)\n this.rungBondStore = new BondStore(0)\n this.atomStore = new AtomStore(0)\n this.residueStore = new ResidueStore(0)\n this.chainStore = new ChainStore(0)\n this.modelStore = new ModelStore(0)\n\n this.atomMap = new AtomMap(this)\n this.residueMap = new ResidueMap(this)\n\n this.bondHash = undefined\n this.spatialHash = undefined\n\n this.atomSet = undefined\n this.bondSet = undefined\n\n this.center = new Vector3()\n this.boundingBox = new Box3()\n\n this._bp = this.getBondProxy()\n this._ap = this.getAtomProxy()\n this._rp = this.getResidueProxy()\n this._cp = this.getChainProxy()\n }\n\n get type () { return 'Structure' }\n\n finalizeAtoms () {\n this.atomSet = this.getAtomSet()\n this.atomCount = this.atomStore.count\n this.boundingBox = this.getBoundingBox(undefined, this.boundingBox)\n this.center = this.boundingBox.getCenter(new Vector3())\n this.spatialHash = new SpatialHash(this.atomStore, this.boundingBox)\n }\n\n finalizeBonds () {\n this.bondSet = this.getBondSet()\n this.bondCount = this.bondStore.count\n this.bondHash = new BondHash(this.bondStore, this.atomStore.count)\n\n this.atomSetCache = {}\n if (!this.atomSetDict.rung) {\n this.atomSetDict.rung = this.getAtomSet(false)\n }\n\n for (let name in this.atomSetDict) {\n this.atomSetCache[ '__' + name ] = this.atomSetDict[ name ].clone()\n }\n }\n\n //\n\n getBondProxy (index?: number) {\n return new BondProxy(this, index)\n }\n\n getAtomProxy (index?: number) {\n return new AtomProxy(this, index)\n }\n\n getResidueProxy (index?: number) {\n return new ResidueProxy(this, index)\n }\n\n getChainProxy (index?: number) {\n return new ChainProxy(this, index)\n }\n\n getModelProxy (index?: number) {\n return new ModelProxy(this, index)\n }\n\n //\n\n getBondSet (/* selection */) {\n // TODO implement selection parameter\n\n const n = this.bondStore.count\n const bondSet = new BitArray(n)\n const atomSet = this.atomSet\n\n if (atomSet) {\n if (atomSet.isAllSet()) {\n bondSet.setAll()\n } else if (atomSet.isAllClear()) {\n bondSet.clearAll()\n } else {\n const bp = this.getBondProxy()\n\n for (let i = 0; i < n; ++i) {\n bp.index = i\n if (atomSet.isSet(bp.atomIndex1, bp.atomIndex2)) {\n bondSet.set(bp.index)\n }\n }\n }\n } else {\n bondSet.setAll()\n }\n\n return bondSet\n }\n\n getBackboneBondSet (/* selection */) {\n // TODO implement selection parameter\n\n const n = this.backboneBondStore.count\n const backboneBondSet = new BitArray(n)\n const backboneAtomSet = this.atomSetCache.__backbone\n\n if (backboneAtomSet) {\n const bp = this.getBondProxy()\n bp.bondStore = this.backboneBondStore\n\n for (let i = 0; i < n; ++i) {\n bp.index = i\n if (backboneAtomSet.isSet(bp.atomIndex1, bp.atomIndex2)) {\n backboneBondSet.set(bp.index)\n }\n }\n } else {\n backboneBondSet.setAll()\n }\n\n return backboneBondSet\n }\n\n getRungBondSet (/* selection */) {\n // TODO implement selection parameter\n\n const n = this.rungBondStore.count\n const rungBondSet = new BitArray(n)\n const rungAtomSet = this.atomSetCache.__rung\n\n if (rungAtomSet) {\n const bp = this.getBondProxy()\n bp.bondStore = this.rungBondStore\n\n for (let i = 0; i < n; ++i) {\n bp.index = i\n if (rungAtomSet.isSet(bp.atomIndex1, bp.atomIndex2)) {\n rungBondSet.set(bp.index)\n }\n }\n } else {\n rungBondSet.setAll()\n }\n\n return rungBondSet\n }\n\n /**\n * Get a set of atoms\n * @param {Boolean|Selection|BitArray} selection - object defining how to\n * initialize the atom set.\n * Boolean: init with value;\n * Selection: init with selection;\n * BitArray: return bit array\n * @return {BitArray} set of atoms\n */\n getAtomSet (selection?: boolean|Selection|BitArray) {\n const n = this.atomStore.count\n\n if (selection === undefined) {\n return new BitArray(n, true)\n } else if (selection instanceof BitArray) {\n return selection\n } else if (selection === true) {\n return new BitArray(n, true)\n } else if (selection && selection.test) {\n const seleString = selection.string\n if (seleString in this.atomSetCache) {\n return this.atomSetCache[ seleString ]\n } else {\n if (seleString === '') {\n return new BitArray(n, true)\n } else {\n const atomSet = new BitArray(n)\n this.eachAtom(function (ap: AtomProxy) {\n atomSet.set(ap.index)\n }, selection)\n this.atomSetCache[ seleString ] = atomSet\n return atomSet\n }\n }\n } else if (selection === false) {\n return new BitArray(n)\n }\n\n return new BitArray(n, true)\n }\n\n /**\n * Get set of atoms around a set of atoms from a selection\n * @param {Selection} selection - the selection object\n * @param {Number} radius - radius to select within\n * @return {BitArray} set of atoms\n */\n getAtomSetWithinSelection (selection: boolean|Selection|BitArray, radius: number) {\n const spatialHash = this.spatialHash\n const atomSet = this.getAtomSet(false)\n const ap = this.getAtomProxy()\n\n if (!spatialHash) return atomSet\n\n this.getAtomSet(selection).forEach(function (idx: number) {\n ap.index = idx\n spatialHash.within(ap.x, ap.y, ap.z, radius).forEach(function (idx2: number) {\n atomSet.set(idx2)\n })\n })\n\n return atomSet\n }\n\n /**\n * Get set of atoms around a point\n * @param {Vector3|AtomProxy} point - the point\n * @param {Number} radius - radius to select within\n * @return {BitArray} set of atoms\n */\n getAtomSetWithinPoint (point: Vector3|AtomProxy, radius: number) {\n const p = point\n const atomSet = this.getAtomSet(false)\n\n if (!this.spatialHash) return atomSet\n\n this.spatialHash.within(p.x, p.y, p.z, radius).forEach(function (idx: number) {\n atomSet.set(idx)\n })\n\n return atomSet\n }\n\n /**\n * Get set of atoms within a volume\n * @param {Volume} volume - the volume\n * @param {Number} radius - radius to select within\n * @param {[type]} minValue - minimum value to be considered as within the volume\n * @param {[type]} maxValue - maximum value to be considered as within the volume\n * @param {[type]} outside - use only values falling outside of the min/max values\n * @return {BitArray} set of atoms\n */\n getAtomSetWithinVolume (volume: Volume, radius: number, minValue: number, maxValue: number, outside: boolean) {\n const fv = new FilteredVolume(volume, minValue, maxValue, outside) as any // TODO\n\n const dp = fv.getDataPosition()\n const n = dp.length\n const r = fv.matrix.getMaxScaleOnAxis()\n const atomSet = this.getAtomSet(false)\n\n if (!this.spatialHash) return atomSet\n\n for (let i = 0; i < n; i += 3) {\n this.spatialHash.within(dp[ i ], dp[ i + 1 ], dp[ i + 2 ], r).forEach(function (idx) {\n atomSet.set(idx)\n })\n }\n\n return atomSet\n }\n\n /**\n * Get set of all atoms within the groups of a selection\n * @param {Selection} selection - the selection object\n * @return {BitArray} set of atoms\n */\n getAtomSetWithinGroup (selection: boolean|Selection|BitArray) {\n const atomResidueIndex = this.atomStore.residueIndex\n const atomSet = this.getAtomSet(false)\n const rp = this.getResidueProxy()\n\n this.getAtomSet(selection).forEach(function (idx) {\n rp.index = atomResidueIndex[ idx ]\n for (let idx2 = rp.atomOffset; idx2 <= rp.atomEnd; ++idx2) {\n atomSet.set(idx2)\n }\n })\n\n return atomSet\n }\n\n //\n\n getSelection (): undefined|Selection {\n return\n }\n\n getStructure (): Structure|StructureView {\n return this\n }\n\n /**\n * Entity iterator\n * @param {function(entity: Entity)} callback - the callback\n * @param {EntityType} type - entity type\n * @return {undefined}\n */\n eachEntity (callback: (entity: Entity) => void, type: number) {\n this.entityList.forEach(function (entity) {\n if (type === undefined || entity.getEntityType() === type) {\n callback(entity)\n }\n })\n }\n\n /**\n * Bond iterator\n * @param {function(bond: BondProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachBond (callback: (entity: BondProxy) => void, selection?: Selection) {\n const bp = this.getBondProxy()\n let bondSet\n\n if (selection && selection.test) {\n bondSet = this.getBondSet(/*selection*/)\n if (this.bondSet) {\n bondSet.intersection(this.bondSet)\n }\n }\n\n if (bondSet) {\n bondSet.forEach(function (index) {\n bp.index = index\n callback(bp)\n })\n } else {\n const n = this.bondStore.count\n for (let i = 0; i < n; ++i) {\n bp.index = i\n callback(bp)\n }\n }\n }\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (entity: AtomProxy) => void, selection?: Selection) {\n if (selection && selection.test) {\n this.eachModel(function (mp) {\n mp.eachAtom(callback, selection)\n }, selection)\n } else {\n const an = this.atomStore.count\n const ap = this.getAtomProxy()\n for (let i = 0; i < an; ++i) {\n ap.index = i\n callback(ap)\n }\n }\n }\n\n /**\n * Residue iterator\n * @param {function(residue: ResidueProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachResidue (callback: (entity: ResidueProxy) => void, selection?: Selection) {\n if (selection && selection.test) {\n const mn = this.modelStore.count\n const mp = this.getModelProxy()\n const modelOnlyTest = selection.modelOnlyTest\n if (modelOnlyTest) {\n for (let i = 0; i < mn; ++i) {\n mp.index = i\n if (modelOnlyTest(mp)) {\n mp.eachResidue(callback, selection)\n }\n }\n } else {\n for (let i = 0; i < mn; ++i) {\n mp.index = i\n mp.eachResidue(callback, selection)\n }\n }\n } else {\n const rn = this.residueStore.count\n const rp = this.getResidueProxy()\n for (let i = 0; i < rn; ++i) {\n rp.index = i\n callback(rp)\n }\n }\n }\n\n /**\n * Multi-residue iterator\n * @param {Integer} n - window size\n * @param {function(residueList: ResidueProxy[])} callback - the callback\n * @return {undefined}\n */\n eachResidueN (n: number, callback: (...entityArray: ResidueProxy[]) => void) {\n const rn = this.residueStore.count\n if (rn < n) return\n const array: ResidueProxy[] = new Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = this.getResidueProxy(i)\n }\n callback.apply(this, array)\n\n for (let j = n; j < rn; ++j) {\n for (let i = 0; i < n; ++i) {\n array[ i ].index += 1\n }\n callback.apply(this, array)\n }\n }\n\n /**\n * Polymer iterator\n * @param {function(polymer: Polymer)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachPolymer (callback: (entity: Polymer) => void, selection?: Selection) {\n if (selection && selection.modelOnlyTest) {\n const modelOnlyTest = selection.modelOnlyTest\n\n this.eachModel(function (mp) {\n if (modelOnlyTest(mp)) {\n mp.eachPolymer(callback, selection)\n }\n })\n } else {\n this.eachModel(function (mp) {\n mp.eachPolymer(callback, selection)\n })\n }\n }\n\n /**\n * Chain iterator\n * @param {function(chain: ChainProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachChain (callback: (entity: ChainProxy) => void, selection?: Selection) {\n if (selection && selection.test) {\n this.eachModel(function (mp) {\n mp.eachChain(callback, selection)\n })\n } else {\n const cn = this.chainStore.count\n const cp = this.getChainProxy()\n for (let i = 0; i < cn; ++i) {\n cp.index = i\n callback(cp)\n }\n }\n }\n\n /**\n * Model iterator\n * @param {function(model: ModelProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachModel (callback: (entity: ModelProxy) => void, selection?: Selection) {\n const n = this.modelStore.count\n const mp = this.getModelProxy()\n\n if (selection && selection.test) {\n const modelOnlyTest = selection.modelOnlyTest\n if (modelOnlyTest) {\n for (let i = 0; i < n; ++i) {\n mp.index = i\n if (modelOnlyTest(mp)) {\n callback(mp)\n }\n }\n } else {\n for (let i = 0; i < n; ++i) {\n mp.index = i\n callback(mp)\n }\n }\n } else {\n for (let i = 0; i < n; ++i) {\n mp.index = i\n callback(mp)\n }\n }\n }\n\n //\n\n getAtomData (params: AtomDataParams) {\n const p = Object.assign({}, params)\n if (p.colorParams) p.colorParams.structure = this.getStructure()\n\n const what = p.what\n const atomSet = defaults(p.atomSet, this.atomSet)\n\n let radiusFactory: any // TODO\n let colormaker: any // TODO\n\n const atomData: AtomData = {}\n const ap = this.getAtomProxy()\n const atomCount = atomSet.getSize()\n\n if (!what || what.position) {\n atomData.position = new Float32Array(atomCount * 3)\n }\n if ((!what || what.color) && p.colorParams) {\n atomData.color = new Float32Array(atomCount * 3)\n colormaker = ColormakerRegistry.getScheme(p.colorParams)\n }\n if (!what || what.picking) {\n atomData.picking = new AtomPicker(new Float32Array(atomCount), this.getStructure())\n }\n if (!what || what.radius) {\n atomData.radius = new Float32Array(atomCount)\n radiusFactory = new RadiusFactory(p.radiusParams as RadiusParams)\n }\n if (!what || what.index) {\n atomData.index = new Uint32Array(atomCount)\n }\n\n const {position, color, picking, radius, index} = atomData\n\n atomSet.forEach((idx: number, i: number) => {\n const i3 = i * 3\n ap.index = idx\n if (position) {\n ap.positionToArray(position, i3)\n }\n if (color) {\n colormaker.atomColorToArray(ap, color, i3)\n }\n if (picking) {\n picking.array![ i ] = idx\n }\n if (radius) {\n radius[ i ] = radiusFactory.atomRadius(ap)\n }\n if (index) {\n index[ i ] = idx\n }\n })\n return atomData\n }\n\n getBondData (params: BondDataParams) {\n const p = Object.assign({}, params)\n if (p.colorParams) p.colorParams.structure = this.getStructure()\n\n const what = p.what\n const bondSet = defaults(p.bondSet, this.bondSet)\n const multipleBond = defaults(p.multipleBond, 'off')\n const isMulti = multipleBond !== 'off'\n const isOffset = multipleBond === 'offset'\n const bondScale = defaults(p.bondScale, 0.4)\n const bondSpacing = defaults(p.bondSpacing, 1.0)\n\n let radiusFactory: any // TODO\n let colormaker: any // TODO\n\n const bondData: BondData = {}\n const bp = this.getBondProxy()\n if (p.bondStore) bp.bondStore = p.bondStore\n const ap1 = this.getAtomProxy()\n const ap2 = this.getAtomProxy()\n\n let bondCount: number\n if (isMulti) {\n const storeBondOrder = bp.bondStore.bondOrder\n bondCount = 0\n bondSet.forEach(function (index: number) {\n bondCount += storeBondOrder[ index ]\n })\n } else {\n bondCount = bondSet.getSize()\n }\n\n if (!what || what.position) {\n bondData.position1 = new Float32Array(bondCount * 3)\n bondData.position2 = new Float32Array(bondCount * 3)\n }\n if ((!what || what.color) && p.colorParams) {\n bondData.color = new Float32Array(bondCount * 3)\n bondData.color2 = new Float32Array(bondCount * 3)\n colormaker = ColormakerRegistry.getScheme(p.colorParams)\n }\n if (!what || what.picking) {\n bondData.picking = new BondPicker(new Float32Array(bondCount), this.getStructure(), p.bondStore)\n }\n if (!what || what.radius || (isMulti && what.position)) {\n radiusFactory = new RadiusFactory(p.radiusParams as RadiusParams)\n }\n if (!what || what.radius) {\n bondData.radius = new Float32Array(bondCount)\n if (p.radius2) {\n bondData.radius2 = new Float32Array(bondCount)\n }\n }\n\n const {position1, position2, color, color2, picking, radius, radius2} = bondData\n\n let i = 0\n let j, i3, k, bondOrder, absOffset\n let multiRadius\n\n const vt = new Vector3()\n const vShortening = new Vector3()\n const vShift = new Vector3()\n\n bondSet.forEach((index: number) => {\n i3 = i * 3\n bp.index = index\n ap1.index = bp.atomIndex1\n ap2.index = bp.atomIndex2\n bondOrder = bp.bondOrder\n if (position1) {\n if (isMulti && bondOrder > 1) {\n const atomRadius = radiusFactory.atomRadius(ap1)\n multiRadius = atomRadius * bondScale / (0.5 * bondOrder)\n\n bp.calculateShiftDir(vShift)\n\n if (isOffset) {\n absOffset = 2 * bondSpacing * atomRadius\n vShift.multiplyScalar(absOffset)\n vShift.negate()\n\n // Shortening is calculated so that neighbouring double\n // bonds on tetrahedral geometry (e.g. sulphonamide)\n // are not quite touching (arccos(1.9 / 2) ~ 109deg)\n // but don't shorten beyond 10% each end or it looks odd\n vShortening.subVectors(ap2 as any, ap1 as any).multiplyScalar( // TODO\n Math.max(0.1, absOffset / 1.88)\n )\n ap1.positionToArray(position1, i3)\n ap2.positionToArray(position2, i3)\n\n if (bondOrder >= 2) {\n vt.addVectors(ap1 as any, vShift).add(vShortening).toArray(position1 as any, i3 + 3) // TODO\n vt.addVectors(ap2 as any, vShift).sub(vShortening).toArray(position2 as any, i3 + 3) // TODO\n\n if (bondOrder >= 3) {\n vt.subVectors(ap1 as any, vShift).add(vShortening).toArray(position1 as any, i3 + 6) // TODO\n vt.subVectors(ap2 as any, vShift).sub(vShortening).toArray(position2 as any, i3 + 6) // TODO\n }\n }\n } else {\n absOffset = (bondSpacing - bondScale) * atomRadius\n vShift.multiplyScalar(absOffset)\n\n if (bondOrder === 2) {\n vt.addVectors(ap1 as any, vShift).toArray(position1 as any, i3) // TODO\n vt.subVectors(ap1 as any, vShift).toArray(position1 as any, i3 + 3) // TODO\n vt.addVectors(ap2 as any, vShift).toArray(position2 as any, i3) // TODO\n vt.subVectors(ap2 as any, vShift).toArray(position2 as any, i3 + 3) // TODO\n } else if (bondOrder === 3) {\n ap1.positionToArray(position1, i3)\n vt.addVectors(ap1 as any, vShift).toArray(position1 as any, i3 + 3) // TODO\n vt.subVectors(ap1 as any, vShift).toArray(position1 as any, i3 + 6) // TODO\n ap2.positionToArray(position2, i3)\n vt.addVectors(ap2 as any, vShift).toArray(position2 as any, i3 + 3) // TODO\n vt.subVectors(ap2 as any, vShift).toArray(position2 as any, i3 + 6) // TODO\n } else {\n // todo, better fallback\n ap1.positionToArray(position1, i3)\n ap2.positionToArray(position2, i3)\n }\n }\n } else {\n ap1.positionToArray(position1, i3)\n ap2.positionToArray(position2, i3)\n }\n }\n if (color && color2) {\n colormaker.bondColorToArray(bp, 1, color, i3)\n colormaker.bondColorToArray(bp, 0, color2, i3)\n if (isMulti && bondOrder > 1) {\n for (j = 1; j < bondOrder; ++j) {\n k = j * 3 + i3\n copyWithin(color, i3, k, 3)\n copyWithin(color2, i3, k, 3)\n }\n }\n }\n if (picking && picking.array) {\n picking.array[ i ] = index\n if (isMulti && bondOrder > 1) {\n for (j = 1; j < bondOrder; ++j) {\n picking.array[ i + j ] = index\n }\n }\n }\n if (radius) {\n radius[ i ] = radiusFactory.atomRadius(ap1)\n if (isMulti && bondOrder > 1) {\n multiRadius = radius[ i ] * bondScale / (isOffset ? 1 : (0.5 * bondOrder))\n for (j = isOffset ? 1 : 0; j < bondOrder; ++j) {\n radius[ i + j ] = multiRadius\n }\n }\n }\n if (radius2) {\n radius2[ i ] = radiusFactory.atomRadius(ap2)\n if (isMulti && bondOrder > 1) {\n multiRadius = radius2[ i ] * bondScale / (isOffset ? 1 : (0.5 * bondOrder))\n for (j = isOffset ? 1 : 0; j < bondOrder; ++j) {\n radius2[ i + j ] = multiRadius\n }\n }\n }\n i += isMulti ? bondOrder : 1\n })\n\n return bondData\n }\n\n getBackboneAtomData (params: AtomDataParams) {\n params = Object.assign({\n atomSet: this.atomSetCache.__backbone\n }, params)\n\n return this.getAtomData(params)\n }\n\n getBackboneBondData (params: BondDataParams) {\n params = Object.assign({\n bondSet: this.getBackboneBondSet(),\n bondStore: this.backboneBondStore\n }, params)\n\n return this.getBondData(params)\n }\n\n getRungAtomData (params: AtomDataParams) {\n params = Object.assign({\n atomSet: this.atomSetCache.__rung\n }, params)\n\n return this.getAtomData(params)\n }\n\n getRungBondData (params: BondDataParams) {\n params = Object.assign({\n bondSet: this.getRungBondSet(),\n bondStore: this.rungBondStore\n }, params)\n\n return this.getBondData(params)\n }\n\n //\n\n /**\n * Gets the bounding box of the (selected) structure atoms\n * @param {Selection} [selection] - the selection\n * @param {Box3} [box] - optional target\n * @return {Vector3} the box\n */\n getBoundingBox (selection?: Selection, box?: Box3) {\n if (Debug) Log.time('getBoundingBox')\n\n box = box || new Box3()\n\n let minX = +Infinity\n let minY = +Infinity\n let minZ = +Infinity\n\n let maxX = -Infinity\n let maxY = -Infinity\n let maxZ = -Infinity\n\n this.eachAtom(ap => {\n const x = ap.x\n const y = ap.y\n const z = ap.z\n\n if (x < minX) minX = x\n if (y < minY) minY = y\n if (z < minZ) minZ = z\n\n if (x > maxX) maxX = x\n if (y > maxY) maxY = y\n if (z > maxZ) maxZ = z\n }, selection)\n\n box.min.set(minX, minY, minZ)\n box.max.set(maxX, maxY, maxZ)\n\n if (Debug) Log.timeEnd('getBoundingBox')\n\n return box\n }\n\n /**\n * Gets the principal axes of the (selected) structure atoms\n * @param {Selection} [selection] - the selection\n * @return {PrincipalAxes} the principal axes\n */\n getPrincipalAxes (selection?: Selection) {\n if (Debug) Log.time('getPrincipalAxes')\n\n let i = 0\n const coords = new Matrix(3, this.atomCount)\n const cd = coords.data\n\n this.eachAtom(a => {\n cd[ i + 0 ] = a.x\n cd[ i + 1 ] = a.y\n cd[ i + 2 ] = a.z\n i += 3\n }, selection)\n\n if (Debug) Log.timeEnd('getPrincipalAxes')\n\n return new PrincipalAxes(coords)\n }\n\n /**\n * Gets the center of the (selected) structure atoms\n * @param {Selection} [selection] - the selection\n * @return {Vector3} the center\n */\n atomCenter (selection?: Selection) {\n if (selection) {\n return this.getBoundingBox(selection).getCenter(new Vector3())\n } else {\n return this.center.clone()\n }\n }\n\n hasCoords () {\n if (this._hasCoords === undefined) {\n const atomStore = this.atomStore\n this._hasCoords = (\n arrayMin(atomStore.x) !== 0 || arrayMax(atomStore.x) !== 0 ||\n arrayMin(atomStore.y) !== 0 || arrayMax(atomStore.y) !== 0 ||\n arrayMin(atomStore.z) !== 0 || arrayMax(atomStore.z) !== 0\n ) || (\n // allow models with a single atom at the origin\n atomStore.count / this.modelStore.count === 1\n )\n }\n return this._hasCoords;\n }\n\n getSequence (selection?: Selection) {\n const seq: string[] = []\n const rp = this.getResidueProxy()\n\n this.eachAtom(function (ap: AtomProxy) {\n rp.index = ap.residueIndex\n if (ap.index === rp.traceAtomIndex) {\n seq.push(rp.getResname1())\n }\n }, selection)\n\n return seq\n }\n\n getAtomIndices (selection?: Selection) {\n if (selection && selection.string) {\n const indices: number[] = []\n this.eachAtom(function (ap: AtomProxy) {\n indices.push(ap.index)\n }, selection)\n return new Uint32Array(indices)\n } else {\n const p = { what: { index: true } }\n return this.getAtomData(p).index\n }\n }\n\n /**\n * Get number of unique chainnames\n * @param {Selection} selection - limit count to selection\n * @return {Integer} count\n */\n getChainnameCount (selection?: Selection) {\n const chainnames = new Set()\n this.eachChain(function (cp: ChainProxy) {\n if (cp.residueCount) {\n chainnames.add(cp.chainname)\n }\n }, selection)\n\n return chainnames.size\n }\n\n /**\n * Update atomic positions\n * @param position - Array to copy positions from\n * @param refresh - Whether or not to issue a full refresh (automatically\n * triggers re-calculation of bounding boxes, spatial hash,\n * representations etc etc). This provides compatibility with\n * the old behaviour\n */\n updatePosition (position: Float32Array|number[], refresh: boolean = true) {\n let i = 0\n\n this.eachAtom(function (ap: AtomProxy) {\n ap.positionFromArray(position, i)\n i += 3\n }, undefined)\n\n this._hasCoords = undefined // to trigger recalculation (of the _hasCoords value)\n\n if (refresh) { \n this.refreshPosition() // Recalculate bounds - structure-component listener will \n // trigger representation rebuild\n }\n\n }\n\n refreshPosition () {\n this.getBoundingBox(undefined, this.boundingBox)\n this.boundingBox.getCenter(this.center)\n this.spatialHash = new SpatialHash(this.atomStore, this.boundingBox)\n\n this.signals.refreshed.dispatch(this)\n }\n\n /**\n * Calls dispose() method of property objects.\n * Unsets properties to help garbage collection.\n * @return {undefined}\n */\n dispose () {\n if (this.frames) this.frames.length = 0\n if (this.boxes) this.boxes.length = 0\n\n this.bondStore.dispose()\n this.backboneBondStore.dispose()\n this.rungBondStore.dispose()\n this.atomStore.dispose()\n this.residueStore.dispose()\n this.chainStore.dispose()\n this.modelStore.dispose()\n\n // can't delete non-optional properties as of TS 4\n // and since we've already disposed them, don't need to.\n\n delete this.bondSet\n delete this.atomSet\n }\n}\n\nexport default Structure\n","/**\n * @file Shape\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Matrix4 required for declaration only\nimport { Box3, Vector3, Color, Matrix4 } from 'three'\n\nimport { createParams, ensureFloat32Array, getUintArray } from '../utils'\nimport {\n ArrowPrimitive, BoxPrimitive, ConePrimitive, CylinderPrimitive, EllipsoidPrimitive,\n OctahedronPrimitive, SpherePrimitive, TetrahedronPrimitive, TextPrimitive,\n TorusPrimitive, PointPrimitive, WidelinePrimitive\n} from './primitive'\nimport { MeshPicker } from '../utils/picker'\nimport Buffer from '../buffer/buffer'\nimport MeshBuffer from '../buffer/mesh-buffer'\nimport { TextBufferParameters } from '../buffer/text-buffer'\n\nconst tmpBox = new Box3()\n\nconst Primitives = [\n ArrowPrimitive, BoxPrimitive, ConePrimitive, CylinderPrimitive,\n EllipsoidPrimitive, OctahedronPrimitive, SpherePrimitive, TetrahedronPrimitive,\n TextPrimitive, TorusPrimitive, PointPrimitive, WidelinePrimitive\n]\n\nexport const ShapeDefaultParameters = {\n aspectRatio: 1.5,\n sphereDetail: 2,\n radialSegments: 50,\n disableImpostor: false,\n openEnded: false,\n dashedCylinder: false,\n labelParams: {} as Partial,\n pointSize: 2,\n sizeAttenuation: false,\n useTexture: true,\n linewidth: 2\n}\nexport type ShapeParameters = typeof ShapeDefaultParameters\n\n/**\n * Class for building custom shapes.\n *\n * @example\n * var shape = new NGL.Shape('shape', { disableImpostor: true });\n * shape.addSphere([ 0, 0, 9 ], [ 1, 0, 0 ], 1.5 );\n * shape.addEllipsoid([ 6, 0, 0 ], [ 1, 0, 0 ], 1.5, [ 3, 0, 0 ], [ 0, 2, 0 ]);\n * shape.addCylinder([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ], 0.5);\n * shape.addCone([ 0, 2, 7 ], [ 0, 3, 3 ], [ 1, 1, 0 ], 1.5);\n * shape.addArrow([ 1, 2, 7 ], [ 30, 3, 3 ], [ 1, 0, 1 ], 1.0);\n * shape.addBox([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);\n * var shapeComp = stage.addComponentFromObject(shape);\n * geoComp.addRepresentation('buffer');\n */\nclass Shape {\n name: string\n parameters: ShapeParameters\n\n boundingBox = new Box3()\n bufferList: Buffer[] = []\n meshCount = 0\n\n _center?: Vector3\n _primitiveData: { [k: string]: any } = {}\n\n /**\n * @param {String} name - name\n * @param {Object} params - parameter object\n * @param {Integer} params.aspectRatio - arrow aspect ratio, used for cylinder radius and cone length\n * @param {Integer} params.sphereDetail - sphere quality (icosahedron subdivisions)\n * @param {Integer} params.radialSegments - cylinder quality (number of segments)\n * @param {Boolean} params.disableImpostor - disable use of raycasted impostors for rendering\n * @param {Boolean} params.openEnded - capped or not\n * @param {TextBufferParameters} params.labelParams - label parameters\n */\n constructor (name = 'shape', params: Partial = {}) {\n this.name = name\n\n this.parameters = createParams(params, ShapeDefaultParameters)\n\n Primitives.forEach(P => {\n Object.keys(P.fields).forEach(name => {\n this._primitiveData[ P.getShapeKey(name) ] = []\n })\n this._primitiveData[ P.getShapeKey('name') ] = []\n })\n }\n\n /**\n * Add a buffer\n * @param {Buffer} buffer - buffer object\n * @return {Shape} this object\n */\n addBuffer (buffer: Buffer) {\n this.bufferList.push(buffer)\n\n const geometry = (buffer as any).geometry // TODO\n if (!geometry.boundingBox) {\n geometry.computeBoundingBox()\n }\n this.boundingBox.union(geometry.boundingBox)\n\n return this\n }\n\n /**\n * Add a mesh\n * @example\n * shape.addMesh(\n * [ 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1 ],\n * [ 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0 ]\n * );\n *\n * @param {Float32Array|Array} position - positions\n * @param {Float32Array|Array} color - colors\n * @param {Uint32Array|Uint16Array|Array} [index] - indices\n * @param {Float32Array|Array} [normal] - normals\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addMesh (position: Float32Array|number[], color:Float32Array|number[], index: Uint32Array|Uint16Array|number[], normal?: Float32Array|number[], name?: string) {\n position = ensureFloat32Array(position)\n color = ensureFloat32Array(color)\n\n if (Array.isArray(index)) {\n index = getUintArray(index, position.length)\n }\n if (normal) {\n normal = ensureFloat32Array(normal)\n }\n\n let data\n if (normal === undefined || normal.length == 0 ) {\n data = { position, color, index }\n } else {\n data = { position, color, index, normal }\n }\n //const data = { position, color, index, normal }\n const picking = new MeshPicker(\n this, Object.assign({ serial: this.meshCount, name }, data)\n )\n const meshBuffer = new MeshBuffer(\n Object.assign({ picking }, data) as any\n )\n this.bufferList.push(meshBuffer)\n\n tmpBox.setFromArray(position)\n this.boundingBox.union(tmpBox)\n this.meshCount += 1\n\n return this\n }\n\n /**\n * Add a sphere\n * @example\n * shape.addSphere([ 0, 0, 9 ], [ 1, 0, 0 ], 1.5);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addSphere (position: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, name: string) {\n SpherePrimitive.objectToShape(\n this, { position, color, radius, name }\n )\n return this\n }\n\n /**\n * Add an ellipsoid\n * @example\n * shape.addEllipsoid([ 6, 0, 0 ], [ 1, 0, 0 ], 1.5, [ 3, 0, 0 ], [ 0, 2, 0 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {Vector3|Array} majorAxis - major axis vector or array\n * @param {Vector3|Array} minorAxis - minor axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addEllipsoid (position: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, majorAxis: Vector3|[number, number, number], minorAxis: Vector3|[number, number, number], name: string) {\n EllipsoidPrimitive.objectToShape(\n this, { position, color, radius, majorAxis, minorAxis, name }\n )\n return this\n }\n\n /**\n * Add a torus\n * @example\n * shape.addTorus([ 6, 0, 0 ], [ 1, 0, 0 ], 1.5, [ 3, 0, 0 ], [ 0, 2, 0 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {Vector3|Array} majorAxis - major axis vector or array\n * @param {Vector3|Array} minorAxis - minor axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addTorus (position: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, majorAxis: Vector3|[number, number, number], minorAxis: Vector3|[number, number, number], name: string) {\n TorusPrimitive.objectToShape(\n this, { position, color, radius, majorAxis, minorAxis, name }\n )\n return this\n }\n\n /**\n * Add a cylinder\n * @example\n * shape.addCylinder([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ], 0.5);\n *\n * @param {Vector3|Array} position1 - from position vector or array\n * @param {Vector3|Array} position2 - to position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addCylinder (position1: Vector3|[number, number, number], position2: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, name: string) {\n CylinderPrimitive.objectToShape(\n this, { position1, position2, color, radius, name }\n )\n return this\n }\n\n /**\n * Add a cone\n * @example\n * shape.addCone([ 0, 2, 7 ], [ 0, 3, 3 ], [ 1, 1, 0 ], 1.5);\n *\n * @param {Vector3|Array} position1 - from position vector or array\n * @param {Vector3|Array} position2 - to position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addCone (position1: Vector3|[number, number, number], position2: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, name: string) {\n ConePrimitive.objectToShape(\n this, { position1, position2, color, radius, name }\n )\n return this\n }\n\n /**\n * Add an arrow\n * @example\n * shape.addArrow([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ], 0.5);\n *\n * @param {Vector3|Array} position1 - from position vector or array\n * @param {Vector3|Array} position2 - to position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addArrow (position1: Vector3|[number, number, number], position2: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, name: string) {\n ArrowPrimitive.objectToShape(\n this, { position1, position2, color, radius, name }\n )\n return this\n }\n\n /**\n * Add a box\n * @example\n * shape.addBox([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} size - size value\n * @param {Vector3|Array} heightAxis - height axis vector or array\n * @param {Vector3|Array} depthAxis - depth axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addBox (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, heightAxis: Vector3|[number, number, number], depthAxis: Vector3|[number, number, number], name: string) {\n BoxPrimitive.objectToShape(\n this, { position, color, size, heightAxis, depthAxis, name }\n )\n return this\n }\n\n /**\n * Add an octahedron\n * @example\n * shape.addOctahedron([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} size - size value\n * @param {Vector3|Array} heightAxis - height axis vector or array\n * @param {Vector3|Array} depthAxis - depth axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addOctahedron (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, heightAxis: Vector3|[number, number, number], depthAxis: Vector3|[number, number, number], name: string) {\n OctahedronPrimitive.objectToShape(\n this, { position, color, size, heightAxis, depthAxis, name }\n )\n return this\n }\n\n /**\n * Add a tetrahedron\n * @example\n * shape.addTetrahedron([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} size - size value\n * @param {Vector3|Array} heightAxis - height axis vector or array\n * @param {Vector3|Array} depthAxis - depth axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addTetrahedron (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, heightAxis: Vector3|[number, number, number], depthAxis: Vector3|[number, number, number], name: string) {\n TetrahedronPrimitive.objectToShape(\n this, { position, color, size, heightAxis, depthAxis, name }\n )\n return this\n }\n\n /**\n * Add text\n * @example\n * shape.addText([ 10, -2, 4 ], [ 0.2, 0.5, 0.8 ], 0.5, \"Hello\");\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} size - size value\n * @param {String} text - text value\n * @return {Shape} this object\n */\n addText (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, text: string) {\n TextPrimitive.objectToShape(\n this, { position, color, size, text }\n )\n return this\n }\n\n /**\n * Add point\n * @example\n * shape.addPoint([ 10, -2, 4 ], [ 0.2, 0.5, 0.8 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addPoint (position: Vector3|[number, number, number], color: Color|[number, number, number], name: string) {\n PointPrimitive.objectToShape(\n this, { position, color, name }\n )\n return this\n }\n\n /**\n * Add a wideline\n * @example\n * shape.addWideline([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ]);\n *\n * @param {Vector3|Array} position1 - from position vector or array\n * @param {Vector3|Array} position2 - to position vector or array\n * @param {Color|Array} color - color object or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addWideline (position1: Vector3|[number, number, number], position2: Vector3|[number, number, number], color: Color|[number, number, number], linewidth: number, name: string) {\n this.parameters.linewidth = linewidth\n WidelinePrimitive.objectToShape(\n this, { position1, position2, color, name }\n )\n return this\n }\n\n /**\n * Deprecated, use `.addText`\n */\n addLabel (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, text: string) {\n console.warn('Shape.addLabel is deprecated, use .addText instead')\n return this.addText(position, color, size, text)\n }\n\n getBufferList () {\n const buffers: Buffer[] = []\n\n Primitives.forEach(P => {\n if (this._primitiveData[ P.getShapeKey('color') ].length) {\n buffers.push(P.bufferFromShape(this, this.parameters))\n }\n })\n\n return this.bufferList.concat(buffers)\n }\n\n dispose () {\n this.bufferList.forEach(function (buffer) {\n buffer.dispose()\n })\n this.bufferList.length = 0\n\n Primitives.forEach(P => {\n Object.keys(P.fields).forEach(name => {\n this._primitiveData[ P.getShapeKey(name) ].length = 0\n })\n this._primitiveData[ P.getShapeKey('name') ].length = 0\n })\n }\n\n get center () {\n if (!this._center) {\n this._center = this.boundingBox.getCenter(new Vector3())\n }\n return this._center\n }\n\n get type () { return 'Shape' }\n}\n\nexport default Shape\n","/**\n * @file Buffer Representation\n * @author Alexander Rose \n * @private\n */\n\nimport Representation, { RepresentationParameters } from './representation'\nimport Viewer from '../viewer/viewer';\n\n/**\n * Representation for showing buffer objects. Good for efficiently showing\n * large amounts of geometric primitives e.g. spheres via {@link SphereBuffer}.\n * Smaller numbers of geometric primitives are more easily shown with help\n * from the {@link Shape} class.\n *\n * __Name:__ _buffer_\n *\n * @example\n * // add a single red sphere from a buffer to a shape instance\n * var shape = new NGL.Shape( \"shape\" );\n * var sphereBuffer = new NGL.SphereBuffer( {\n * position: new Float32Array( [ 0, 0, 0 ] ),\n * color: new Float32Array( [ 1, 0, 0 ] ),\n * radius: new Float32Array( [ 1 ] )\n * } );\n * shape.addBuffer( sphereBuffer );\n * var shapeComp = stage.addComponentFromObject( shape );\n * shapeComp.addRepresentation( \"buffer\" );\n *\n * @example\n * // add a single red sphere from a buffer to a structure component instance\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * var sphereBuffer = new NGL.SphereBuffer( {\n * position: new Float32Array( [ 0, 0, 0 ] ),\n * color: new Float32Array( [ 1, 0, 0 ] ),\n * radius: new Float32Array( [ 1 ] )\n * } );\n * o.addBufferRepresentation( sphereBuffer, { opacity: 0.5 } );\n * } );\n */\nclass BufferRepresentation extends Representation {\n buffer: Buffer[]\n /**\n * Create Buffer representation\n * @param {Buffer} buffer - a buffer object\n * @param {Viewer} viewer - a viewer object\n * @param {RepresentationParameters} params - representation parameters\n */\n constructor (buffer: Buffer|Buffer[], viewer: Viewer, params: Partial) {\n if (!Array.isArray(buffer)) {\n buffer = [ buffer ]\n }\n\n super(buffer, viewer, params)\n\n this.type = 'buffer'\n\n this.parameters = Object.assign({\n\n }, this.parameters, {\n\n colorScheme: null,\n colorScale: null,\n colorValue: null,\n colorDomain: null,\n colorMode: null\n\n })\n\n this.buffer = buffer\n\n this.init(params)\n }\n\n init (params: Partial) {\n super.init(params)\n\n this.build()\n }\n\n create () {\n this.bufferList.push.apply(this.bufferList, this.buffer)\n }\n\n attach (callback: ()=> void) {\n this.bufferList.forEach(buffer => {\n this.viewer.add(buffer)\n buffer.setParameters(this.getBufferParams())\n })\n this.setVisibility(this.visible)\n\n callback()\n }\n}\n\nexport default BufferRepresentation\n","/**\n * @file Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3 required for declaration only\n import { Vector3, Matrix4, Matrix3, BufferGeometry } from 'three'\n\nimport { getUintArray } from '../utils'\nimport { serialBlockArray } from '../math/array-utils'\nimport { applyMatrix3toVector3array, applyMatrix4toVector3array } from '../math/vector-utils'\nimport MeshBuffer from './mesh-buffer'\nimport { BufferParameters, BufferData } from './buffer'\nimport {Log} from \"../globals\";\n\nconst matrix = new Matrix4()\nconst normalMatrix = new Matrix3()\n\nfunction getData(data: BufferData, geo: BufferGeometry){\n const geoPosition = (geo.attributes as any).position.array\n const geoIndex = geo.index ? geo.index.array : undefined\n\n const n = data.position!.length / 3\n const m = geoPosition.length / 3\n\n const size = n * m\n\n const meshPosition = new Float32Array(size * 3)\n const meshNormal = new Float32Array(size * 3)\n const meshColor = new Float32Array(size * 3)\n\n let meshIndex\n if (geoIndex) {\n meshIndex = getUintArray(n * geoIndex.length, size)\n }\n\n return {\n position: meshPosition,\n color: meshColor,\n index: meshIndex,\n normal: meshNormal,\n primitiveId: data.primitiveId || serialBlockArray(n, m) as Float32Array,\n picking: data.picking\n }\n}\n\n/**\n * Geometry buffer. Base class for geometry-based buffers. Used to draw\n * geometry primitives given a mesh.\n * @interface\n */\nabstract class GeometryBuffer extends MeshBuffer {\n updateNormals = false\n\n geoPosition: Float32Array\n geoNormal: Float32Array\n geoIndex?: Uint32Array|Uint16Array\n\n positionCount: number\n geoPositionCount: number\n\n transformedGeoPosition: Float32Array\n transformedGeoNormal: Float32Array\n\n meshPosition: Float32Array\n meshColor: Float32Array\n meshIndex: Uint32Array|Uint16Array\n meshNormal: Float32Array\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n * @param {BufferGeometry} geo - geometry object\n */\n constructor (data: BufferData, params: Partial = {}, geo: BufferGeometry) {\n super(getData(data, geo), params)\n\n const geoPosition = (geo.attributes as any).position.array\n const geoNormal = (geo.attributes as any).normal.array\n const geoIndex = geo.index ? (geo.index.array as Uint32Array|Uint16Array) : undefined\n\n this.geoPosition = geoPosition\n this.geoNormal = geoNormal\n this.geoIndex = geoIndex\n\n this.positionCount = data.position!.length / 3\n this.geoPositionCount = geoPosition.length / 3\n\n this.transformedGeoPosition = new Float32Array(this.geoPositionCount * 3)\n this.transformedGeoNormal = new Float32Array(this.geoPositionCount * 3)\n\n const attributes = this.geometry.attributes as any // TODO\n this.meshPosition = attributes.position.array\n this.meshColor = attributes.color.array\n this.meshNormal = attributes.normal.array\n\n this.setAttributes(data)\n\n if (geoIndex) {\n const index = this.geometry.getIndex()\n if (!index) { Log.error('Index is null'); return; }\n this.meshIndex = index.array as Uint32Array|Uint16Array\n this.makeIndex()\n }\n }\n\n abstract applyPositionTransform (matrix: Matrix4, i: number, i3?: number): void\n\n setAttributes (data: Partial = {}, initNormals = false) {\n const attributes = this.geometry.attributes as any // TODO\n\n let position, color\n let geoPosition, geoNormal\n let transformedGeoPosition, transformedGeoNormal\n let meshPosition, meshColor, meshNormal\n\n const updateNormals = this.updateNormals\n\n if (data.position) {\n position = data.position\n geoPosition = this.geoPosition\n meshPosition = this.meshPosition\n transformedGeoPosition = this.transformedGeoPosition\n attributes.position.needsUpdate = true\n if (updateNormals || initNormals) {\n geoNormal = this.geoNormal\n meshNormal = this.meshNormal\n transformedGeoNormal = this.transformedGeoNormal\n attributes.normal.needsUpdate = true\n }\n }\n\n if (data.color) {\n color = data.color\n meshColor = this.meshColor\n attributes.color.needsUpdate = true\n }\n\n const n = this.positionCount\n const m = this.geoPositionCount\n\n for (let i = 0; i < n; ++i) {\n let j, l\n const k = i * m * 3\n const i3 = i * 3\n\n if (position && transformedGeoPosition && meshPosition && meshNormal && geoPosition && geoNormal) {\n transformedGeoPosition.set(geoPosition)\n matrix.makeTranslation(\n position[ i3 ], position[ i3 + 1 ], position[ i3 + 2 ]\n )\n this.applyPositionTransform(matrix, i, i3)\n applyMatrix4toVector3array(matrix.elements as unknown as Float32Array,\n transformedGeoPosition)\n\n meshPosition.set(transformedGeoPosition, k)\n\n if (updateNormals && transformedGeoNormal) {\n transformedGeoNormal.set(geoNormal)\n normalMatrix.getNormalMatrix(matrix)\n applyMatrix3toVector3array(normalMatrix.elements as unknown as Float32Array,\n transformedGeoNormal)\n\n meshNormal.set(transformedGeoNormal, k)\n } else if (initNormals) {\n meshNormal.set(geoNormal, k)\n }\n }\n\n if (color && meshColor) {\n for (j = 0; j < m; ++j) {\n l = k + 3 * j\n\n meshColor[ l ] = color[ i3 ]\n meshColor[ l + 1 ] = color[ i3 + 1 ]\n meshColor[ l + 2 ] = color[ i3 + 2 ]\n }\n }\n }\n }\n\n makeIndex () {\n const geoIndex = this.geoIndex\n const meshIndex = this.meshIndex\n\n if (!geoIndex) return\n\n const n = this.positionCount\n const m = this.geoPositionCount\n const o = geoIndex.length / 3\n\n const o3 = o * 3\n\n for (let i = 0; i < n; ++i) {\n const j = i * o3\n const q = j + o3\n\n meshIndex.set(geoIndex, j)\n for (let p = j; p < q; ++p) meshIndex[ p ] += i * m\n }\n }\n}\n\nexport default GeometryBuffer\n","/**\n * @file Sphere Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { IcosahedronBufferGeometry, Vector3, Matrix4 } from 'three'\nimport { defaults } from '../utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { SphereBufferData } from './sphere-buffer'\nimport { BufferDefaultParameters, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\n\nexport const SphereGeometryBufferDefaultParameters = Object.assign({\n sphereDetail: 1\n}, BufferDefaultParameters)\nexport type SphereGeometryBufferParameters = BufferParameters & { sphereDetail: number }\n\n/**\n * Sphere geometry buffer.\n *\n * @example\n * var sphereGeometryBuffer = new SphereGeometryBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass SphereGeometryBuffer extends GeometryBuffer {\n get defaultParameters() { return SphereGeometryBufferDefaultParameters }\n parameters: SphereGeometryBufferParameters\n\n private _radius: Float32Array\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: SphereBufferData, params: Partial = {}) {\n super(data, params, new IcosahedronBufferGeometry(1, defaults(params.sphereDetail, 1)))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number) {\n const r = this._radius[ i ]\n scale.set(r, r, r)\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.radius) this._radius = data.radius\n\n super.setAttributes(data, initNormals)\n }\n}\n\nexport default SphereGeometryBuffer\n","/**\n * @file Mapped Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { getUintArray } from '../utils'\nimport { calculateCenterArray, serialArray } from '../math/array-utils'\nimport Buffer, { BufferParameters, BufferData } from './buffer'\n\nexport type MappingType = 'v2'|'v3'\n\n/**\n * Mapped buffer. Sends mapping attribute to the GPU and repeats data in\n * others attributes. Used to render imposters.\n * @interface\n */\nabstract class MappedBuffer extends Buffer {\n index: Uint32Array|Uint16Array\n\n constructor (mappingType: MappingType, data: BufferData, params: Partial = {}) {\n super(data, params)\n\n this.index = getUintArray(this.indexSize, this.attributeSize)\n this.makeIndex()\n this.initIndex(this.index)\n\n this.addAttributes({\n 'mapping': { type: mappingType, value: null }\n })\n\n this.setAttributes({ primitiveId: serialArray(this.size) })\n }\n\n abstract get mapping (): Float32Array\n abstract get mappingIndices (): Uint32Array|Uint16Array\n abstract get mappingIndicesSize (): number\n abstract get mappingSize (): number\n abstract get mappingItemSize (): number\n\n get attributeSize () {\n return this.size * this.mappingSize\n }\n\n get indexSize () {\n return this.size * this.mappingIndicesSize\n }\n\n addAttributes (attributes: any) {\n const nullValueAttributes: any = {}\n for (const name in attributes) {\n const a = attributes[ name ]\n nullValueAttributes[ name ] = {\n type: a.type,\n value: null\n }\n }\n\n super.addAttributes(nullValueAttributes)\n }\n\n getAttributeIndex (dataIndex: number) {\n return dataIndex * 3 * this.mappingSize\n }\n\n setAttributes (data: any) { // TODO\n if (data && !data.position && data.position1 && data.position2) {\n data.position = calculateCenterArray(data.position1, data.position2)\n }\n\n const size = this.size\n const mappingSize = this.mappingSize\n const attributes = this.geometry.attributes as any // TODO\n\n let a, d, itemSize, array, n, i, j\n\n for (const name in data) {\n if (name === 'index' || name === 'picking') continue\n\n d = data[ name ]\n a = attributes[ name ]\n itemSize = a.itemSize\n array = a.array\n\n for (let k = 0; k < size; ++k) {\n n = k * itemSize\n i = n * mappingSize\n\n for (let l = 0; l < mappingSize; ++l) {\n j = i + (itemSize * l)\n\n for (let m = 0; m < itemSize; ++m) {\n array[ j + m ] = d[ n + m ]\n }\n }\n }\n\n a.needsUpdate = true\n }\n }\n\n makeMapping () {\n const size = this.size\n const mapping = this.mapping\n const mappingSize = this.mappingSize\n const mappingItemSize = this.mappingItemSize\n\n const attributes = this.geometry.attributes as any // TODO\n const aMapping = attributes.mapping.array\n\n for (let v = 0; v < size; v++) {\n aMapping.set(mapping, v * mappingItemSize * mappingSize)\n }\n }\n\n makeIndex () {\n const size = this.size\n const mappingSize = this.mappingSize\n const mappingIndices = this.mappingIndices\n const mappingIndicesSize = this.mappingIndicesSize\n\n const index = this.index\n\n for (let v = 0; v < size; v++) {\n const ix = v * mappingIndicesSize\n const it = v * mappingSize\n\n index.set(mappingIndices, ix)\n\n for (let s = 0; s < mappingIndicesSize; ++s) {\n index[ ix + s ] += it\n }\n }\n }\n}\n\nexport default MappedBuffer\n","/**\n * @file Mapped Quad Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { BufferParameters, BufferData } from './buffer'\nimport MappedBuffer from './mapped-buffer'\n\nconst mapping = new Float32Array([\n -1.0, 1.0,\n -1.0, -1.0,\n 1.0, 1.0,\n 1.0, -1.0\n])\n\nconst mappingIndices = new Uint16Array([\n 0, 1, 2,\n 1, 3, 2\n])\n\n/**\n * Mapped Quad buffer. Draws screen-aligned quads. Used to render impostors.\n * @interface\n */\nclass MappedQuadBuffer extends MappedBuffer {\n constructor(data: BufferData, params: Partial = {}) {\n super('v2', data, params)\n }\n get mapping () { return mapping }\n get mappingIndices () { return mappingIndices }\n get mappingIndicesSize () { return 6 }\n get mappingSize () { return 4 }\n get mappingItemSize () { return 2 }\n}\n\nexport default MappedQuadBuffer\n","/**\n * @file Sphere Impostor Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport '../shader/SphereImpostor.vert'\nimport '../shader/SphereImpostor.frag'\n\nimport MappedQuadBuffer from './mappedquad-buffer'\nimport { SphereBufferData } from './sphere-buffer'\nimport { BufferParameters } from './buffer'\n\n/**\n * Sphere impostor buffer.\n *\n * @example\n * var sphereImpostorBuffer = new SphereImpostorBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass SphereImpostorBuffer extends MappedQuadBuffer {\n isImpostor = true\n vertexShader = 'SphereImpostor.vert'\n fragmentShader = 'SphereImpostor.frag'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: SphereBufferData, params: Partial = {}) {\n super(data, params)\n\n this.addUniforms({\n 'projectionMatrixInverse': { value: new Matrix4() },\n 'ortho': { value: 0.0 }\n })\n\n this.addAttributes({\n 'radius': { type: 'f', value: null }\n })\n\n this.setAttributes(data)\n this.makeMapping()\n }\n}\n\nexport default SphereImpostorBuffer\n","/**\n * @file Sphere Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only \nimport { Vector3, Matrix4 } from 'three'\nimport { BufferRegistry, ExtensionFragDepth } from '../globals'\nimport SphereGeometryBuffer, { SphereGeometryBufferDefaultParameters, SphereGeometryBufferParameters } from './spheregeometry-buffer'\nimport SphereImpostorBuffer from './sphereimpostor-buffer'\nimport { BufferData } from './buffer'\n\nexport interface SphereBufferData extends BufferData {\n radius: Float32Array\n}\n\nexport const SphereBufferDefaultParameters = Object.assign({\n disableImpostor: false\n}, SphereGeometryBufferDefaultParameters)\nexport type SphereBufferParameters = SphereGeometryBufferParameters & { disableImpostor: boolean }\n\nclass SphereBufferImpl {\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} params - parameters object\n * @return {SphereGeometryBuffer|SphereImpostorBuffer} the buffer object\n */\n constructor (data: SphereBufferData, params: SphereBufferParameters) {\n if (!ExtensionFragDepth || (params && params.disableImpostor)) {\n return new SphereGeometryBuffer(data, params)\n } else {\n return new SphereImpostorBuffer(data, params)\n }\n }\n}\n\n/**\n * Sphere buffer. Depending on the value {@link ExtensionFragDepth} and\n * `params.disableImpostor` the constructor returns either a\n * {@link SphereGeometryBuffer} or a {@link SphereImpostorBuffer}\n * @implements {Buffer}\n *\n * @example\n * var sphereBuffer = new SphereBuffer( {\n * position: new Float32Array( [ 0, 0, 0 ] ),\n * color: new Float32Array( [ 1, 0, 0 ] ),\n * radius: new Float32Array( [ 1 ] )\n * } );\n */\n//@ts-expect-error Incompatible constructor signatures\nconst SphereBuffer: {\n new(data: SphereBufferData, params: SphereBufferParameters): SphereGeometryBuffer | SphereImpostorBuffer;\n} = SphereBufferImpl;\n\ntype SphereBuffer = SphereGeometryBuffer | SphereImpostorBuffer;\n\nBufferRegistry.add('sphere', SphereBuffer)\n\nexport default SphereBuffer\n","/**\n * @file Point Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { DataTexture, Vector3, Matrix4 } from 'three'\n\nimport '../shader/Point.vert'\nimport '../shader/Point.frag'\n\nimport { BufferRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { smoothstep } from '../math/math-utils'\nimport Buffer, { BufferDefaultParameters, BufferParameterTypes, BufferData, BufferTypes, BufferParameters } from './buffer'\n\nfunction distance (x0: number, y0: number, x1: number, y1: number) {\n const dx = x1 - x0\n const dy = y1 - y0\n return Math.sqrt(dx * dx + dy * dy)\n}\n\ninterface PointTextureParams {\n width?: number\n height?: number\n delta?: number\n}\n\nfunction makePointTexture (params: PointTextureParams) {\n const p = params || {}\n\n const width = defaults(p.width, 256)\n const height = defaults(p.height, 256)\n const center = [ width / 2, height / 2 ]\n const radius = Math.min(width / 2, height / 2)\n const delta = defaults(p.delta, 1 / (radius + 1)) * radius\n\n let x = 0\n let y = 0\n const data = new Uint8Array(width * height * 4)\n\n for (let i = 0, il = data.length; i < il; i += 4) {\n const dist = distance(x, y, center[ 0 ], center[ 1 ])\n const value = 1 - smoothstep(radius - delta, radius, dist)\n\n data[ i ] = value * 255\n data[ i + 1 ] = value * 255\n data[ i + 2 ] = value * 255\n data[ i + 3 ] = value * 255\n\n if (++x === width) {\n x = 0\n y++\n }\n }\n\n const tex = new DataTexture(data, width, height)\n tex.needsUpdate = true\n\n return tex\n}\n\nexport const PointBufferDefaultParameters = Object.assign({\n pointSize: 1,\n sizeAttenuation: true,\n sortParticles: false,\n alphaTest: 0.5,\n useTexture: false,\n forceTransparent: false,\n edgeBleach: 0.0\n}, BufferDefaultParameters)\nexport type PointBufferParameters = BufferParameters & {\n pointSize: number,\n sizeAttenuation: boolean,\n sortParticles: boolean,\n alphaTest: number,\n useTexture: boolean,\n forceTransparent: boolean,\n edgeBleach: number\n}\n\nconst PointBufferParameterTypes = Object.assign({\n pointSize: { uniform: 'size' },\n sizeAttenuation: { updateShader: true },\n sortParticles: {},\n alphaTest: { updateShader: true },\n useTexture: { updateShader: true },\n forceTransparent: {},\n edgeBleach: { uniform: true }\n}, BufferParameterTypes)\n\n/**\n * Point buffer. Draws points. Optionally textured.\n *\n * @example\n * var pointBuffer = new PointBuffer( {\n * position: new Float32Array( [ 0, 0, 0 ] ),\n * color: new Float32Array( [ 1, 0, 0 ] )\n * } );\n */\nclass PointBuffer extends Buffer {\n parameterTypes = PointBufferParameterTypes\n get defaultParameters() { return PointBufferDefaultParameters }\n parameters: PointBufferParameters\n\n vertexShader = 'Point.vert'\n fragmentShader ='Point.frag'\n\n isPoint = true\n tex: DataTexture\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: BufferData, params: Partial = {}) {\n super(data, params)\n\n this.addUniforms({\n 'size': { value: this.parameters.pointSize },\n 'canvasHeight': { value: 1.0 },\n 'pixelRatio': { value: 1.0 },\n 'map': { value: null }\n })\n }\n\n makeMaterial () {\n super.makeMaterial()\n\n this.makeTexture()\n\n const m = this.material\n const wm = this.wireframeMaterial\n const pm = this.pickingMaterial\n\n m.uniforms.map.value = this.tex\n m.needsUpdate = true\n\n wm.uniforms.map.value = this.tex\n wm.needsUpdate = true\n\n pm.uniforms.map.value = this.tex\n pm.needsUpdate = true\n }\n\n makeTexture () {\n if (this.tex) this.tex.dispose()\n this.tex = makePointTexture({ delta: this.parameters.edgeBleach })\n }\n\n getDefines (type?: BufferTypes) {\n const defines = super.getDefines(type)\n\n if (this.parameters.sizeAttenuation) {\n defines.USE_SIZEATTENUATION = 1\n }\n\n if (this.parameters.useTexture) {\n defines.USE_MAP = 1\n }\n\n if (this.parameters.alphaTest > 0 && this.parameters.alphaTest <= 1) {\n defines.ALPHATEST = this.parameters.alphaTest.toPrecision(2)\n }\n\n return defines\n }\n\n setUniforms (data: any) {\n if (data && data.edgeBleach !== undefined) {\n this.makeTexture()\n data.map = this.tex\n }\n\n super.setUniforms(data)\n }\n\n dispose () {\n super.dispose()\n\n if (this.tex) this.tex.dispose()\n }\n}\n\nBufferRegistry.add('point', PointBuffer)\n\nexport default PointBuffer\n","/**\n * @file Dot Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { ExtensionFragDepth } from '../globals'\nimport { defaults } from '../utils'\nimport Representation, { RepresentationParameters } from './representation'\nimport Volume from '../surface/volume'\nimport FilteredVolume from '../surface/filtered-volume'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport PointBuffer from '../buffer/point-buffer'\nimport Surface from '../surface/surface';\nimport Viewer from '../viewer/viewer';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\n\nexport interface DotDataFields {\n color?: boolean,\n radius?: boolean,\n scale?: boolean\n}\n\n/**\n * Dot representation parameter object. Extends {@link RepresentationParameters}\n *\n * @typedef {Object} DotRepresentationParameters - dot representation parameters\n *\n * @property {String} thresholdType - Meaning of the threshold values. Either *value* for the literal value or *sigma* as a factor of the sigma of the data. For volume data only.\n * @property {Number} thresholdMin - Minimum value to be displayed. For volume data only.\n * @property {Number} thresholdMax - Maximum value to be displayed. For volume data only.\n * @property {Number} thresholdOut - Show only values falling outside of the treshold minumum and maximum. For volume data only.\n */\nexport interface DotRepresentationParameters extends RepresentationParameters {\n thresholdType: 'value'|'value'|'sigma'|'sigma'\n thresholdMin: number\n thresholdMax: number\n thresholdOut: boolean\n dotType: ''|'sphere'|'point'\n radiusType: ''|'value'|'abs-value'|'value-min'|'deviation'|'size'|'radius' //TODO had to add 'radius' because of test in line 333\n radius: number\n scale: number\n sphereDetail: number\n disableImpostor: boolean\n pointSize: number\n sizeAttenuation: boolean\n sortParticles: boolean\n useTexture: boolean\n alphaTest: number\n forceTransparent: boolean\n edgeBleach: number\n}\n/**\n * Dot representation\n */\nclass DotRepresentation extends Representation {\n protected thresholdType: 'value'|'value'|'sigma'|'sigma'\n protected thresholdMin: number\n protected thresholdMax: number\n protected thresholdOut: boolean\n protected dotType: ''|'sphere'|'point'\n protected radiusType: ''|'value'|'abs-value'|'value-min'|'deviation'|'size'|'radius' //TODO had to add 'radius' because of test in line 333\n protected radius: number\n protected scale: number\n protected sphereDetail: number\n protected disableImpostor: boolean\n protected pointSize: number\n protected sizeAttenuation: boolean\n protected sortParticles: boolean\n protected useTexture: boolean\n protected alphaTest: number\n protected forceTransparent: boolean\n protected edgeBleach: number\n\n protected surface: Surface|undefined\n protected volume: FilteredVolume|undefined\n protected dotBuffer: SphereBuffer|PointBuffer\n /**\n * Create Dot representation object\n * @param {Surface|Volume} surface - the surface or volume to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {DotRepresentationParameters} params - dot representation parameters\n */\n constructor (surface: Surface, viewer: Viewer, params: Partial) {\n super(surface, viewer, params)\n\n this.type = 'dot'\n\n this.parameters = Object.assign({\n\n thresholdType: {\n type: 'select',\n rebuild: true,\n options: {\n 'value': 'value', 'sigma': 'sigma'\n }\n },\n thresholdMin: {\n type: 'number', precision: 3, max: Infinity, min: -Infinity, rebuild: true\n },\n thresholdMax: {\n type: 'number', precision: 3, max: Infinity, min: -Infinity, rebuild: true\n },\n thresholdOut: {\n type: 'boolean', rebuild: true\n },\n dotType: {\n type: 'select',\n rebuild: true,\n options: {\n '': '',\n 'sphere': 'sphere',\n 'point': 'point'\n }\n },\n radiusType: {\n type: 'select',\n options: {\n '': '',\n 'value': 'value',\n 'abs-value': 'abs-value',\n 'value-min': 'value-min',\n 'deviation': 'deviation',\n 'size': 'size'\n }\n },\n radius: {\n type: 'number', precision: 3, max: 10.0, min: 0.001, property: 'size'\n },\n scale: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n sphereDetail: true,\n disableImpostor: true,\n\n pointSize: {\n type: 'number', precision: 1, max: 100, min: 0, buffer: true\n },\n sizeAttenuation: {\n type: 'boolean', buffer: true\n },\n sortParticles: {\n type: 'boolean', rebuild: true\n },\n useTexture: {\n type: 'boolean', buffer: true\n },\n alphaTest: {\n type: 'range', step: 0.001, max: 1, min: 0, buffer: true\n },\n forceTransparent: {\n type: 'boolean', buffer: true\n },\n edgeBleach: {\n type: 'range', step: 0.001, max: 1, min: 0, buffer: true\n }\n\n }, this.parameters, {\n\n colorScheme: {\n type: 'select',\n update: 'color',\n options: {\n '': '',\n 'value': 'value',\n 'uniform': 'uniform',\n 'random': 'random'\n }\n }\n\n })\n\n if (surface instanceof Volume) {\n this.surface = undefined\n this.volume = new FilteredVolume(surface)\n } else {\n this.surface = surface\n this.volume = undefined\n }\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'uniform')\n p.colorValue = defaults(p.colorValue, 0xDDDDDD)\n\n this.thresholdType = defaults(p.thresholdType, 'sigma')\n this.thresholdMin = defaults(p.thresholdMin, 2.0)\n this.thresholdMax = defaults(p.thresholdMax, Infinity)\n this.thresholdOut = defaults(p.thresholdOut, false)\n this.dotType = defaults(p.dotType, 'point')\n this.radius = defaults(p.radius, 0.1)\n this.scale = defaults(p.scale, 1.0)\n\n this.pointSize = defaults(p.pointSize, 1)\n this.sizeAttenuation = defaults(p.sizeAttenuation, true)\n this.sortParticles = defaults(p.sortParticles, false)\n this.useTexture = defaults(p.useTexture, false)\n this.alphaTest = defaults(p.alphaTest, 0.5)\n this.forceTransparent = defaults(p.forceTransparent, false)\n this.edgeBleach = defaults(p.edgeBleach, 0.0)\n\n super.init(p)\n\n this.build()\n }\n\n attach (callback: () => void) {\n this.bufferList.forEach(buffer => {\n this.viewer.add(buffer)\n })\n this.setVisibility(this.visible)\n\n callback()\n }\n\n create () {\n var dotData: SphereBufferData|{} = {}\n\n if (this.volume) {\n var volume = this.volume\n var thresholdMin, thresholdMax\n\n if (this.thresholdType === 'sigma') {\n thresholdMin = volume.getValueForSigma(this.thresholdMin)\n thresholdMax = volume.getValueForSigma(this.thresholdMax)\n } else {\n thresholdMin = this.thresholdMin\n thresholdMax = this.thresholdMax\n }\n volume.setFilter(thresholdMin, thresholdMax, this.thresholdOut)\n\n Object.assign(dotData, {\n position: volume.getDataPosition(),\n color: volume.getDataColor(this.getColorParams())\n })\n if (this.dotType === 'sphere') {\n Object.assign(dotData, {\n radius: volume.getDataSize(this.radius, this.scale),\n picking: volume.getDataPicking()\n })\n }\n } else {\n var surface = this.surface\n Object.assign(dotData, {\n position: (surface as Surface).getPosition(),\n color: (surface as Surface).getColor(this.getColorParams())\n })\n if (this.dotType === 'sphere') {\n Object.assign(dotData, {\n radius: (surface as Surface).getSize(this.radius, this.scale),\n picking: (surface as Surface).getPicking()\n })\n }\n }\n\n if (this.dotType === 'sphere') {\n this.dotBuffer = new SphereBuffer(\n dotData as SphereBufferData,\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: false\n }) as SphereBufferParameters\n ) as SphereGeometryBuffer\n } else {\n this.dotBuffer = new PointBuffer(\n dotData,\n this.getBufferParams({\n pointSize: this.pointSize,\n sizeAttenuation: this.sizeAttenuation,\n sortParticles: this.sortParticles,\n useTexture: this.useTexture,\n alphaTest: this.alphaTest,\n forceTransparent: this.forceTransparent,\n edgeBleach: this.edgeBleach\n })\n )\n }\n\n this.bufferList.push(this.dotBuffer as SphereGeometryBuffer)\n }\n\n update (what: DotDataFields = {}) {\n if (this.bufferList.length === 0) return\n\n const dotData: SphereBufferData|{} = {}\n\n if (what.color) {\n if (this.volume) {\n Object.assign(dotData, {\n color: this.volume.getDataColor(\n this.getColorParams()\n )\n })\n } else {\n Object.assign(dotData, {\n color: (this.surface as Surface).getColor(\n this.getColorParams()\n )\n })\n }\n }\n\n if (this.dotType === 'sphere' && (what.radius || what.scale)) {\n if (this.volume) {\n Object.assign(dotData, {\n radius: this.volume.getDataSize(\n this.radius, this.scale\n )\n })\n } else {\n Object.assign(dotData, {\n radius: (this.surface as Surface).getSize(\n this.radius, this.scale\n )\n })\n }\n }\n\n (this.dotBuffer as SphereGeometryBuffer).setAttributes(dotData)\n }\n\n setParameters (params: Partial, what: DotDataFields = {}, rebuild: boolean) {\n \n if (params && params.thresholdType !== undefined &&\n this.volume instanceof Volume\n ) {\n if (this.thresholdType === 'value' &&\n params.thresholdType === 'sigma'\n ) {\n this.thresholdMin = this.volume.getSigmaForValue(\n this.thresholdMin\n )\n this.thresholdMax = this.volume.getSigmaForValue(\n this.thresholdMax\n )\n } else if (this.thresholdType === 'sigma' &&\n params.thresholdType === 'value'\n ) {\n this.thresholdMin = this.volume.getValueForSigma(\n this.thresholdMin\n )\n this.thresholdMax = this.volume.getValueForSigma(\n this.thresholdMax\n )\n }\n\n this.thresholdType = params.thresholdType\n }\n\n if (params && params.radiusType !== undefined) {\n if (params.radiusType === 'radius') {\n this.radius = 0.1\n } else {\n this.radius = parseFloat(params.radiusType)\n }\n what.radius = true\n if (this.dotType === 'sphere' &&\n (!ExtensionFragDepth || this.disableImpostor)\n ) {\n rebuild = true\n }\n }\n\n if (params && params.radius !== undefined) {\n what.radius = true\n if (this.dotType === 'sphere' &&\n (!ExtensionFragDepth || this.disableImpostor)\n ) {\n rebuild = true\n }\n }\n\n if (params && params.scale !== undefined) {\n what.scale = true\n if (this.dotType === 'sphere' &&\n (!ExtensionFragDepth || this.disableImpostor)\n ) {\n rebuild = true\n }\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nexport default DotRepresentation\n","/**\n * @file Image Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport {\n // @ts-ignore: unused import Vector3, Matrix4 required for declaration only\n Vector2, Vector3, Matrix4, BufferAttribute, DataTexture,\n NormalBlending, NearestFilter, LinearFilter\n} from 'three'\n\nimport '../shader/Image.vert'\nimport '../shader/Image.frag'\n\nimport { Picker } from '../utils/picker'\nimport Buffer, { BufferDefaultParameters, BufferParameterTypes, BufferTypes } from './buffer'\n\n\nconst quadIndices = new Uint16Array([\n 0, 1, 2,\n 1, 3, 2\n])\n\nconst quadUvs = new Float32Array([\n 0, 1,\n 0, 0,\n 1, 1,\n 1, 0\n])\n\ntype ImageFilterTypes = 'nearest'|'linear'|'cubic-bspline'|'cubic-catmulrom'|'cubic-mitchell'\n\nexport interface ImageBufferData {\n position: Float32Array\n imageData: Uint8Array\n width: number\n height: number\n\n picking?: Picker\n}\n\nexport const ImageBufferDefaultParameters = Object.assign({\n filter: 'nearest' as ImageFilterTypes,\n forceTransparent: true\n}, BufferDefaultParameters)\nexport type ImageBufferParameters = typeof ImageBufferDefaultParameters\n\nexport const ImageBufferParameterTypes = Object.assign({\n filter: { updateShader: true, uniform: true }\n}, BufferParameterTypes)\n\n/**\n * Image buffer. Draw a single image. Optionally interpolate.\n */\nclass ImageBuffer extends Buffer {\n parameterTypes = ImageBufferParameterTypes\n get defaultParameters() { return ImageBufferDefaultParameters }\n parameters: ImageBufferParameters\n\n alwaysTransparent = true\n hasWireframe = false\n vertexShader = 'Image.vert'\n fragmentShader = 'Image.frag'\n\n tex: DataTexture\n pickingTex: DataTexture\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position - image position\n * @param {Float32Array} data.imageData - image data, rgba channels\n * @param {Float32Array} data.width - image width\n * @param {Float32Array} data.height - image height\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n */\n constructor (data: ImageBufferData, params: ImageBufferParameters) {\n super({\n position: data.position,\n index: quadIndices,\n picking: data.picking\n }, params)\n\n const {imageData, width, height} = data\n\n const tex = new DataTexture(imageData, width, height)\n tex.flipY = true\n this.tex = tex\n\n const n = imageData.length\n const pickingData = new Uint8Array(n)\n for (let i = 0; i < n; i += 4) {\n const j = i / 4\n pickingData[ i ] = j >> 16 & 255\n pickingData[ i + 1 ] = j >> 8 & 255\n pickingData[ i + 2 ] = j & 255\n }\n\n const pickingTex = new DataTexture(pickingData, width, height)\n pickingTex.flipY = true\n pickingTex.minFilter = NearestFilter\n pickingTex.magFilter = NearestFilter\n this.pickingTex = pickingTex\n\n this.addUniforms({\n 'map': { value: tex },\n 'pickingMap': { value: pickingTex },\n 'mapSize': { value: new Vector2(width, height) }\n })\n\n this.geometry.setAttribute('uv', new BufferAttribute(quadUvs, 2))\n }\n\n getDefines (type: BufferTypes) {\n const defines = super.getDefines(type)\n const filter = this.parameters.filter\n\n if (filter.startsWith('cubic')) {\n defines.CUBIC_INTERPOLATION = 1\n if (filter.endsWith('bspline')) {\n defines.BSPLINE_FILTER = 1\n } else if (filter.endsWith('catmulrom')) {\n defines.CATMULROM_FILTER = 1\n } else if (filter.endsWith('mitchell')) {\n defines.MITCHELL_FILTER = 1\n }\n }\n\n return defines\n }\n\n updateTexture () {\n const tex = this.tex\n const filter = this.parameters.filter\n\n if (filter.startsWith('cubic')) {\n tex.minFilter = NearestFilter\n tex.magFilter = NearestFilter\n } else if (filter === 'linear') {\n tex.minFilter = LinearFilter\n tex.magFilter = LinearFilter\n } else { // filter === \"nearest\"\n tex.minFilter = NearestFilter\n tex.magFilter = NearestFilter\n }\n\n tex.needsUpdate = true\n this.pickingTex.needsUpdate = true\n }\n\n makeMaterial () {\n super.makeMaterial()\n this.updateTexture()\n\n const m = this.material\n m.uniforms.map.value = this.tex\n m.blending = NormalBlending\n m.needsUpdate = true\n\n const wm = this.wireframeMaterial\n wm.uniforms.map.value = this.tex\n wm.blending = NormalBlending\n wm.needsUpdate = true\n\n const pm = this.pickingMaterial\n pm.uniforms.map.value = this.tex\n pm.uniforms.pickingMap.value = this.pickingTex\n pm.blending = NormalBlending\n pm.needsUpdate = true\n }\n\n setUniforms (data: any) { // TODO\n if (data && data.filter !== undefined) {\n this.updateTexture()\n data.map = this.tex\n }\n\n super.setUniforms(data)\n }\n}\n\nexport default ImageBuffer\n","/**\n * @file Volume Slice\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { SlicePicker } from '../utils/picker'\nimport { Volume } from '../ngl';\nimport { SliceRepresentationParameters } from '../representation/slice-representation';\n\nclass VolumeSlice {\n dimension: 'x'|'y'|'z'\n positionType: 'percent'|'coordinate'\n position: number\n thresholdType: 'sigma'|'value'\n thresholdMin: number\n thresholdMax: number\n normalize: boolean\n volume: Volume\n\n constructor (volume: Volume, params: Partial) {\n const p = params || {}\n\n this.dimension = defaults(p.dimension, 'x')\n this.positionType = defaults(p.positionType, 'percent')\n this.position = defaults(p.position, 30)\n this.thresholdType = defaults(p.thresholdType, 'sigma')\n this.thresholdMin = defaults(p.thresholdMin, -Infinity)\n this.thresholdMax = defaults(p.thresholdMax, Infinity)\n this.normalize = defaults(p.normalize, false)\n\n this.volume = volume\n }\n\n getPositionFromCoordinate (coord: number) {\n const dim = this.dimension\n const v = this.volume\n const m = v.matrix\n\n const mp = new Vector3().setFromMatrixPosition(m)[ dim ]\n const ms = new Vector3().setFromMatrixScale(m)[ dim ]\n\n let vn\n if (dim === 'x') {\n vn = v.nx\n } else if (dim === 'y') {\n vn = v.ny\n } else {\n vn = v.nz\n }\n\n return Math.round((((coord - mp) / (vn / 100)) + 1) / ms)\n }\n\n getData (params: any) {\n params = params || {}\n\n const v = this.volume\n const d = v.data\n const m = v.matrix\n\n let p: number\n if (this.positionType === 'coordinate') {\n p = this.getPositionFromCoordinate(this.position)\n } else {\n p = this.position\n }\n\n function pos (dimLen: number) {\n return Math.round((dimLen / 100) * (p - 1))\n }\n\n function index (x: number, y: number, z: number, i: number) {\n return (z * v.ny * v.nx + y * v.nx + x) * 3 + i\n }\n\n const position = new Float32Array(4 * 3)\n const vec = new Vector3()\n\n let width, height\n let x\n let y\n let z\n let x0 = 0\n let y0 = 0\n let z0 = 0\n let nx = v.nx\n let ny = v.ny\n let nz = v.nz\n\n function setVec (x: number, y: number, z: number, offset: number) {\n vec.set(x, y, z).applyMatrix4(m).toArray(position as any, offset)\n }\n\n if (this.dimension === 'x') {\n x = pos(v.nx)\n y = v.ny - 1\n z = v.nz - 1\n\n width = v.nz\n height = v.ny\n\n x0 = x\n nx = x0 + 1\n\n setVec(x, 0, 0, 0)\n setVec(x, y, 0, 3)\n setVec(x, 0, z, 6)\n setVec(x, y, z, 9)\n } else if (this.dimension === 'y') {\n x = v.nx - 1\n y = pos(v.ny)\n z = v.nz - 1\n\n width = v.nz\n height = v.nx\n\n y0 = y\n ny = y0 + 1\n\n setVec(0, y, 0, 0)\n setVec(x, y, 0, 3)\n setVec(0, y, z, 6)\n setVec(x, y, z, 9)\n } else if (this.dimension === 'z') {\n x = v.nx - 1\n y = v.ny - 1\n z = pos(v.nz)\n\n width = v.nx\n height = v.ny\n\n z0 = z\n nz = z0 + 1\n\n setVec(0, 0, z, 0)\n setVec(0, y, z, 3)\n setVec(x, 0, z, 6)\n setVec(x, y, z, 9)\n }\n\n let i = 0\n let j = 0\n const imageData = new Uint8Array(width * height * 4)\n const pickingArray = new Float32Array(width * height)\n\n let tMin, tMax\n if (this.thresholdType === 'sigma') {\n tMin = v.getValueForSigma(this.thresholdMin)\n tMax = v.getValueForSigma(this.thresholdMax)\n } else {\n tMin = this.thresholdMin\n tMax = this.thresholdMax\n }\n\n const cp = Object.assign({}, params.colorParams, { volume: v })\n if (this.normalize) {\n cp.domain = [ 0, 1 ]\n }\n const colormaker = ColormakerRegistry.getScheme(cp)\n const tmp = new Float32Array(3)\n const scale = colormaker.getScale()\n\n let min = 0, max, diff = 0\n if (this.normalize) {\n min = +Infinity\n max = -Infinity\n for (let iy = y0; iy < ny; ++iy) {\n for (let ix = x0; ix < nx; ++ix) {\n for (let iz = z0; iz < nz; ++iz) {\n const idx = index(ix, iy, iz, 0) / 3\n const val = d[ idx ]\n if (val < min) min = val\n if (val > max) max = val\n }\n }\n }\n diff = max - min\n }\n\n for (let iy = y0; iy < ny; ++iy) {\n for (let ix = x0; ix < nx; ++ix) {\n for (let iz = z0; iz < nz; ++iz) {\n const idx = index(ix, iy, iz, 0) / 3\n let val = d[ idx ]\n if (this.normalize) {\n val = (val - min) / diff\n }\n\n colormaker.colorToArray(scale(val), tmp)\n imageData[ i ] = Math.round(tmp[ 0 ] * 255)\n imageData[ i + 1 ] = Math.round(tmp[ 1 ] * 255)\n imageData[ i + 2 ] = Math.round(tmp[ 2 ] * 255)\n imageData[ i + 3 ] = (val > tMin && val < tMax) ? 255 : 0\n\n pickingArray[ j ] = idx\n\n ++j\n i += 4\n }\n }\n }\n\n const picking = new SlicePicker(pickingArray, v)\n\n return { position, imageData, width, height, picking }\n }\n}\n\nexport default VolumeSlice\n","/**\n * @file Slice Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport Representation, { RepresentationParameters } from './representation'\nimport ImageBuffer, { ImageBufferParameters, ImageBufferData } from '../buffer/image-buffer'\nimport VolumeSlice from '../surface/volume-slice'\nimport Viewer from '../viewer/viewer';\nimport { Volume } from '../ngl';\n\n/**\n * Slice representation parameter object. Extends {@link RepresentationParameters}\n *\n * @typedef {Object} SliceRepresentationParameters - slice representation parameters\n *\n * @property {String} filter - filter applied to map the volume data on the slice, one of \"nearest\", \"linear\", \"cubic-bspline\", \"cubic-catmulrom\", \"cubic-mitchell\".\n * @property {String} positionType - Meaning of the position value. Either \"percent\" od \"coordinate\".\n * @property {Number} position - position of the slice.\n * @property {String} dimension - one of \"x\", \"y\" or \"z\"\n * @property {String} thresholdType - Meaning of the threshold values. Either *value* for the literal value or *sigma* as a factor of the sigma of the data. For volume data only.\n * @property {Number} thresholdMin - Minimum value to be displayed. For volume data only.\n * @property {Number} thresholdMax - Maximum value to be displayed. For volume data only.\n * @property {Boolean} normalize - Flag indicating wheather to normalize the data in a slice when coloring.\n */\nexport interface SliceRepresentationParameters extends RepresentationParameters {\n filter: 'nearest'|'linear'|'cubic-bspline'|'cubic-catmulrom'|'cubic-mitchell'\n positionType: 'percent'|'coordinate'\n position: number\n dimension: 'x'|'y'|'z'\n thresholdType: 'value'|'sigma'\n thresholdMin: number\n thresholdMax: number\n normalize: boolean\n}\n/**\n * Slice representation\n */\nclass SliceRepresentation extends Representation {\n protected filter: 'nearest'|'linear'|'cubic-bspline'|'cubic-catmulrom'|'cubic-mitchell'\n protected positionType: 'percent'|'coordinate'\n protected position: number\n protected dimension: 'x'|'y'|'z'\n protected thresholdType: 'value'|'sigma'\n protected thresholdMin: number\n protected thresholdMax: number\n protected normalize: boolean\n protected volume: Volume\n /**\n * Create Slice representation object\n * @param {Volume} surface - the volume to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {SliceRepresentationParameters} params - slice representation parameters\n */\n constructor (volume: Volume, viewer: Viewer, params: Partial) {\n super(volume, viewer, params)\n\n this.type = 'slice'\n\n this.parameters = Object.assign({\n\n filter: {\n type: 'select',\n buffer: true,\n options: {\n 'nearest': 'nearest',\n 'linear': 'linear',\n 'cubic-bspline': 'cubic-bspline',\n 'cubic-catmulrom': 'cubic-catmulrom',\n 'cubic-mitchell': 'cubic-mitchell'\n }\n },\n positionType: {\n type: 'select',\n rebuild: true,\n options: {\n 'percent': 'percent', 'coordinate': 'coordinate'\n }\n },\n position: {\n type: 'range',\n step: 0.1,\n max: 100,\n min: 1,\n rebuild: true\n },\n dimension: {\n type: 'select',\n rebuild: true,\n options: {\n 'x': 'x', 'y': 'y', 'z': 'z'\n }\n },\n thresholdType: {\n type: 'select',\n rebuild: true,\n options: {\n 'value': 'value', 'sigma': 'sigma'\n }\n },\n thresholdMin: {\n type: 'number', precision: 3, max: Infinity, min: -Infinity, rebuild: true\n },\n thresholdMax: {\n type: 'number', precision: 3, max: Infinity, min: -Infinity, rebuild: true\n },\n normalize: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n\n flatShaded: null,\n side: null,\n wireframe: null,\n linewidth: null,\n colorScheme: null,\n\n roughness: null,\n metalness: null,\n diffuse: null\n\n })\n\n this.volume = volume\n\n this.init(params)\n }\n\n init (params: Partial) {\n const v = this.volume\n const p = params || {}\n p.colorDomain = defaults(p.colorDomain, [ v.min, v.max ])\n p.colorScheme = defaults(p.colorScheme, 'value')\n p.colorScale = defaults(p.colorScale, 'Spectral')\n\n this.colorScheme = 'value'\n this.dimension = defaults(p.dimension, 'x')\n this.filter = defaults(p.filter, 'cubic-bspline')\n this.positionType = defaults(p.positionType, 'percent')\n this.position = defaults(p.position, 30)\n this.thresholdType = defaults(p.thresholdType, 'sigma')\n this.thresholdMin = defaults(p.thresholdMin, -Infinity)\n this.thresholdMax = defaults(p.thresholdMax, Infinity)\n this.normalize = defaults(p.normalize, false)\n\n super.init(p)\n\n this.build()\n }\n\n attach (callback: () => void) {\n this.bufferList.forEach(buffer => {\n this.viewer.add(buffer)\n })\n this.setVisibility(this.visible)\n\n callback()\n }\n\n create () {\n const volumeSlice = new VolumeSlice(this.volume, {\n positionType: this.positionType,\n position: this.position,\n dimension: this.dimension,\n thresholdType: this.thresholdType,\n thresholdMin: this.thresholdMin,\n thresholdMax: this.thresholdMax,\n normalize: this.normalize\n })\n\n const sliceBuffer = new ImageBuffer(\n volumeSlice.getData({ colorParams: this.getColorParams() }) as ImageBufferData,\n this.getBufferParams({\n filter: this.filter\n }) as ImageBufferParameters\n )\n\n this.bufferList.push(sliceBuffer)\n }\n}\n\nexport default SliceRepresentation\n","/**\n * @file Representation Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, RepresentationRegistry } from '../globals'\n\nimport Viewer from '../viewer/viewer'\nimport Structure from '../structure/structure'\nimport Surface from '../surface/surface'\nimport Volume from '../surface/volume'\nimport Shape from '../geometry/shape'\n\nimport BufferRepresentation from './buffer-representation'\nimport SurfaceRepresentation from './surface-representation'\nimport DotRepresentation from './dot-representation'\nimport SliceRepresentation from './slice-representation'\n\nfunction logReprUnknown (type: string) {\n Log.error(`makeRepresentation: representation type ${type} unknown`)\n}\n\nexport function makeRepresentation (type: string, object: any, viewer: Viewer, params: any) { // TODO\n if (Debug) Log.time('makeRepresentation ' + type)\n\n var ReprClass\n\n if (object instanceof Structure) {\n ReprClass = RepresentationRegistry.get(type)\n\n if (!ReprClass) {\n logReprUnknown(type)\n return\n }\n } else if (object instanceof Surface) {\n if (type === 'surface') {\n ReprClass = SurfaceRepresentation\n } else if (type === 'dot') {\n ReprClass = DotRepresentation\n } else {\n logReprUnknown(type)\n return\n }\n } else if (object instanceof Volume) {\n if (type === 'surface') {\n ReprClass = SurfaceRepresentation\n } else if (type === 'dot') {\n ReprClass = DotRepresentation\n } else if (type === 'slice') {\n ReprClass = SliceRepresentation\n } else {\n logReprUnknown(type)\n return\n }\n } else if (object instanceof Shape) {\n ReprClass = BufferRepresentation\n object = object.getBufferList()\n } else if (type === 'buffer') {\n ReprClass = BufferRepresentation\n } else {\n Log.error('makeRepresentation: object ' + object + ' unknown')\n return\n }\n\n const repr = new ReprClass(object, viewer, params)\n\n if (Debug) Log.timeEnd('makeRepresentation ' + type)\n\n return repr\n}\n","/**\n * @file Element\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { createParams } from '../utils'\nimport { generateUUID } from '../math/math-utils'\nimport Stage from '../stage/stage'\n\nexport const ElementDefaultParameters = {\n name: 'some element',\n status: ''\n}\nexport type ElementParameters = typeof ElementDefaultParameters\n\nexport interface ElementSignals {\n statusChanged: Signal // on status change\n nameChanged: Signal // on name change\n disposed: Signal // on dispose\n}\n\n/**\n * Element base class\n */\nabstract class Element {\n /**\n * Events emitted by the element\n */\n signals: ElementSignals = {\n statusChanged: new Signal(),\n nameChanged: new Signal(),\n disposed: new Signal()\n }\n readonly parameters: ElementParameters\n readonly uuid: string\n\n get defaultParameters() { return ElementDefaultParameters }\n\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {ElementParameters} params - component parameters\n */\n constructor (readonly stage: Stage, params: Partial = {}) {\n this.parameters = createParams(params, this.defaultParameters)\n this.uuid = generateUUID()\n }\n\n abstract get type (): string\n\n get name () { return this.parameters.name }\n\n setStatus (value: string) {\n this.parameters.status = value\n this.signals.statusChanged.dispatch(value)\n\n return this\n }\n\n setName (value: string) {\n this.parameters.name = value\n this.signals.nameChanged.dispatch(value)\n\n return this\n }\n\n dispose () {\n this.signals.disposed.dispatch()\n }\n}\n\nexport default Element\n","/**\n * @file Representation Element\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\nimport { Color } from 'three'\n\nimport Stage from '../stage/stage'\nimport Representation, { RepresentationParameters } from '../representation/representation'\nimport Component from './component'\nimport Element, { ElementDefaultParameters, ElementSignals } from './element'\n\nexport const RepresentationElementDefaultParameters = Object.assign({\n visible: true\n}, ElementDefaultParameters)\nexport type RepresentationElementParameters = typeof RepresentationElementDefaultParameters\n\nexport interface RepresentationElementSignals extends ElementSignals {\n visibilityChanged: Signal // on visibility change\n parametersChanged: Signal // on parameters change\n}\n\n/**\n * Element wrapping a {@link Representation} object\n */\nclass RepresentationElement extends Element {\n signals: RepresentationElementSignals\n parameters: RepresentationElementParameters\n get defaultParameters() { return RepresentationElementDefaultParameters }\n\n repr: Representation\n\n /**\n * Create representation component\n * @param {Stage} stage - stage object the component belongs to\n * @param {Representation} repr - representation object to wrap\n * @param {RepresentationParameters} [params] - component parameters\n * @param {Component} [parent] - parent component\n */\n constructor (stage: Stage, repr: Representation, params: Partial = {}, readonly parent: Component) {\n super(stage, Object.assign({ name: repr.type }, params))\n\n this.signals = Object.assign({\n visibilityChanged: new Signal(),\n parametersChanged: new Signal()\n }, this.signals)\n\n this.setRepresentation(repr)\n }\n\n get visible () { return this.parameters.visible }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'representation' }\n\n getType () {\n return this.repr.type\n }\n\n setRepresentation (repr: Representation) {\n this._disposeRepresentation()\n this.repr = repr\n // this.name = repr.type;\n this.stage.tasks.listen(this.repr.tasks)\n this.updateVisibility()\n }\n\n _disposeRepresentation () {\n if (this.repr) {\n this.stage.tasks.unlisten(this.repr.tasks)\n this.repr.dispose()\n }\n }\n\n dispose () {\n if (this.parent && this.parent.hasRepresentation(this)) {\n this.parent.removeRepresentation(this)\n } else {\n this._disposeRepresentation()\n this.signals.disposed.dispatch()\n }\n }\n\n /**\n * Set the visibility of the component, takes parent visibility into account\n * @param {Boolean} value - visibility flag\n * @return {RepresentationElement} this object\n */\n setVisibility (value: boolean) {\n this.parameters.visible = value\n this.updateVisibility()\n this.signals.visibilityChanged.dispatch(this.parameters.visible)\n\n return this\n }\n\n getVisibility () {\n if (this.parent) {\n return this.parent.parameters.visible && this.parameters.visible\n } else {\n return this.parameters.visible\n }\n }\n\n /**\n * Toggle visibility of the component, takes parent visibility into account\n * @return {RepresentationElement} this object\n */\n toggleVisibility () {\n return this.setVisibility(!this.parameters.visible)\n }\n\n updateVisibility () {\n this.repr.setVisibility(this.getVisibility())\n }\n\n /**\n * Set selection\n * @param {Object} what - flags indicating what attributes to update\n * @param {Boolean} what.position - update position attribute\n * @param {Boolean} what.color - update color attribute\n * @param {Boolean} what.radius - update radius attribute\n * @return {RepresentationElement} this object\n */\n update (what: any) { // TODO\n (this.repr as any).update(what) // TODO\n\n return this\n }\n\n build (params?: any) { // TODO\n this.repr.build(params)\n\n return this\n }\n\n /**\n * Set selection\n * @param {String} string - selection string\n * @return {RepresentationElement} this object\n */\n setSelection (string: string) {\n const repr: any = this.repr // TODO\n\n if (repr.setSelection) {\n repr.setSelection(string)\n }\n\n return this\n }\n\n /**\n * Set representation parameters\n * @param {RepresentationParameters} params - parameter object\n * @return {RepresentationElement} this object\n */\n setParameters (params: any) { // TODO\n this.repr.setParameters(params)\n this.signals.parametersChanged.dispatch(\n this.repr.getParameters()\n )\n\n return this\n }\n\n /**\n * Get representation parameters\n * @return {RepresentationParameters} parameter object\n */\n getParameters (): Partial {\n return this.repr.getParameters()\n }\n\n /**\n * Set color\n * @param {String|Color|Hex} value - color value\n * @return {RepresentationElement} this object\n */\n setColor (value: string|number|Color) {\n this.repr.setColor(value)\n\n return this\n }\n}\n\nexport default RepresentationElement\n","\n/**\n * @file Component\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Quaternion, Matrix4, Euler, Box3 } from 'three'\nimport { Signal } from 'signals'\n\nimport { defaults, createParams } from '../utils'\nimport { generateUUID } from '../math/math-utils'\nimport Annotation, { AnnotationParams } from '../component/annotation'\nimport ComponentControls from '../controls/component-controls'\nimport { makeRepresentation } from '../representation/representation-utils'\nimport RepresentationElement from './representation-element'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\n\nconst _m = new Matrix4()\nconst _v = new Vector3()\n\nexport const ComponentDefaultParameters = {\n name: '',\n status: '',\n visible: true\n}\nexport type ComponentParameters = typeof ComponentDefaultParameters\n\n\nexport interface ComponentSignals {\n representationAdded: Signal // when a representation is added\n representationRemoved: Signal // when a representation is removed\n visibilityChanged: Signal // on visibility change\n matrixChanged: Signal // on matrix change\n statusChanged: Signal // on status change\n nameChanged: Signal // on name change\n disposed: Signal // on dispose\n}\n\n/**\n * Base class for components\n */\nabstract class Component {\n /**\n * Events emitted by the component\n */\n readonly signals: ComponentSignals = {\n representationAdded: new Signal(),\n representationRemoved: new Signal(),\n visibilityChanged: new Signal(),\n matrixChanged: new Signal(),\n statusChanged: new Signal(),\n nameChanged: new Signal(),\n disposed: new Signal()\n }\n\n readonly parameters: ComponentParameters\n get defaultParameters () { return ComponentDefaultParameters }\n\n readonly uuid: string\n readonly viewer: Viewer\n\n reprList: RepresentationElement[] = []\n annotationList: Annotation[] = []\n\n matrix = new Matrix4()\n position = new Vector3()\n quaternion = new Quaternion()\n scale = new Vector3(1, 1, 1)\n transform = new Matrix4()\n\n controls: ComponentControls\n\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {ComponentParameters} params - parameter object\n */\n constructor (readonly stage: Stage, readonly object: any, params: Partial = {}) {\n this.parameters = createParams(params, this.defaultParameters)\n this.uuid = generateUUID()\n this.viewer = stage.viewer\n\n this.controls = new ComponentControls(this)\n }\n\n abstract get type (): string\n\n get name () { return this.parameters.name }\n get status () { return this.parameters.status }\n get visible () { return this.parameters.visible }\n\n /**\n * Set position transform\n *\n * @example\n * // translate by 25 angstrom along x axis\n * component.setPosition([ 25, 0, 0 ]);\n *\n * @param {Vector3|Array} p - the coordinates\n * @return {Component} this object\n */\n setPosition (p: [number, number, number]|Vector3) {\n if (Array.isArray(p)) {\n this.position.fromArray(p)\n } else {\n this.position.copy(p)\n }\n this.updateMatrix()\n\n return this\n }\n\n /**\n * Set local rotation transform\n * (for global rotation use setTransform)\n *\n * @example\n * // rotate by 2 degree radians on x axis\n * component.setRotation( [ 2, 0, 0 ] );\n *\n * @param {Quaternion|Euler|Array} r - the rotation\n * @return {Component} this object\n */\n setRotation (r: [number, number, number]|Euler|Quaternion) {\n if (Array.isArray(r)) {\n if (r.length === 3) {\n const e = new Euler().fromArray(r)\n this.quaternion.setFromEuler(e)\n } else {\n this.quaternion.fromArray(r)\n }\n } else if (r instanceof Euler) {\n this.quaternion.setFromEuler(r)\n } else {\n this.quaternion.copy(r)\n }\n this.updateMatrix()\n\n return this\n }\n\n /**\n * Set scale transform\n *\n * @example\n * // scale by factor of two\n * component.setScale( 2 );\n *\n * @param {Number} s - the scale\n * @return {Component} this object\n */\n setScale (s: number) {\n this.scale.set(s, s, s)\n this.updateMatrix()\n\n return this\n }\n\n /**\n * Set general transform. Is applied before and in addition\n * to the position, rotation and scale transformations\n *\n * @example\n * component.setTransform( matrix );\n *\n * @param {Matrix4} m - the matrix\n * @return {Component} this object\n */\n setTransform (m: Matrix4) {\n this.transform.copy(m)\n this.updateMatrix()\n\n return this\n }\n\n updateMatrix () {\n const c = this.getCenterUntransformed(_v)\n this.matrix.makeTranslation(-c.x, -c.y, -c.z)\n\n _m.makeRotationFromQuaternion(this.quaternion)\n this.matrix.premultiply(_m)\n\n _m.makeScale(this.scale.x, this.scale.y, this.scale.z)\n this.matrix.premultiply(_m)\n\n const p = this.position\n _m.makeTranslation(p.x + c.x, p.y + c.y, p.z + c.z)\n this.matrix.premultiply(_m)\n\n this.matrix.premultiply(this.transform)\n\n this.updateRepresentationMatrices()\n\n this.stage.viewer.updateBoundingBox()\n\n this.signals.matrixChanged.dispatch(this.matrix)\n }\n\n /**\n * Propogates our matrix to each representation\n */\n updateRepresentationMatrices () {\n this.reprList.forEach(repr => {\n repr.setParameters({ matrix: this.matrix })\n })\n }\n\n /**\n * Add an anotation object\n * @param {Vector3} position - the 3d position\n * @param {String|Element} content - the HTML content\n * @param {Object} [params] - parameters\n * @param {Integer} params.offsetX - 2d offset in x direction\n * @param {Integer} params.offsetY - 2d offset in y direction\n * @return {Annotation} the added annotation object\n */\n addAnnotation (position: Vector3, content: string|HTMLElement, params: AnnotationParams) {\n const annotation = new Annotation(this, position, content, params)\n this.annotationList.push(annotation)\n\n return annotation\n }\n\n /**\n * Iterator over each annotation and executing the callback\n * @param {Function} callback - function to execute\n * @return {undefined}\n */\n eachAnnotation (callback: (a: Annotation) => void) {\n this.annotationList.slice().forEach(callback)\n }\n\n /**\n * Remove the give annotation from the component\n * @param {Annotation} annotation - the annotation to remove\n * @return {undefined}\n */\n removeAnnotation (annotation: Annotation) {\n const idx = this.annotationList.indexOf(annotation)\n if (idx !== -1) {\n this.annotationList.splice(idx, 1)\n annotation.dispose()\n }\n }\n\n /**\n * Remove all annotations from the component\n * @return {undefined}\n */\n removeAllAnnotations () {\n this.eachAnnotation(annotation => annotation.dispose())\n this.annotationList.length = 0\n }\n\n /**\n * Add a new representation to the component\n * @param {String} type - the name of the representation\n * @param {Object} object - the object on which the representation should be based\n * @param {RepresentationParameters} [params] - representation parameters\n * @return {RepresentationElement} the created representation wrapped into\n * a representation element object\n */\n protected _addRepresentation (type: string, object: any, params: any, hidden = false) { // TODO\n const p = params || {}\n const sp = this.stage.getParameters() as any // TODO\n p.matrix = this.matrix.clone()\n p.quality = p.quality || sp.quality\n p.disableImpostor = defaults(p.disableImpostor, !sp.impostor)\n p.useWorker = defaults(p.useWorker, sp.workerDefault)\n p.visible = defaults(p.visible, true)\n\n const p2 = Object.assign({}, p, { visible: this.parameters.visible && p.visible })\n const repr = makeRepresentation(type, object, this.viewer, p2)\n const reprElem = new RepresentationElement(this.stage, repr, p, this)\n\n if (!hidden) {\n this.reprList.push(reprElem)\n this.signals.representationAdded.dispatch(reprElem)\n }\n return reprElem\n }\n\n abstract addRepresentation (type: any, params: any): any\n\n addBufferRepresentation (buffer: any, params: any) { // TODO\n return this._addRepresentation.call(this, 'buffer', buffer, params)\n }\n\n hasRepresentation (repr: RepresentationElement) {\n return this.reprList.indexOf(repr) !== -1\n }\n\n /**\n * Iterator over each representation and executing the callback\n * @param {Function} callback - function to execute\n * @return {undefined}\n */\n eachRepresentation (callback: (repr: RepresentationElement) => void) {\n this.reprList.slice().forEach(callback)\n }\n\n /**\n * Removes a representation component\n * @param {RepresentationElement} repr - the representation element\n * @return {undefined}\n */\n removeRepresentation (repr: RepresentationElement) {\n const idx = this.reprList.indexOf(repr)\n if (idx !== -1) {\n this.reprList.splice(idx, 1)\n repr.dispose()\n this.signals.representationRemoved.dispatch(repr)\n }\n }\n\n updateRepresentations (what: any) { // TODO\n this.reprList.forEach(repr => repr.update(what))\n this.stage.viewer.requestRender()\n }\n\n /**\n * Removes all representation components\n * @return {undefined}\n */\n removeAllRepresentations () {\n this.eachRepresentation(repr => repr.dispose())\n }\n\n dispose () {\n this.removeAllAnnotations()\n this.removeAllRepresentations()\n\n this.reprList.length = 0\n\n this.signals.disposed.dispatch()\n }\n\n /**\n * Set the visibility of the component, including added representations\n * @param {Boolean} value - visibility flag\n * @return {Component} this object\n */\n setVisibility (value: boolean) {\n this.parameters.visible = value\n\n this.eachRepresentation((repr: RepresentationElement) => repr.updateVisibility())\n this.eachAnnotation((annotation: Annotation) => annotation.updateVisibility())\n\n this.signals.visibilityChanged.dispatch(value)\n\n return this\n }\n\n setStatus (value: string) {\n this.parameters.status = value\n this.signals.statusChanged.dispatch(value)\n\n return this\n }\n\n setName (value: string) {\n this.parameters.name = value\n this.signals.nameChanged.dispatch(value)\n\n return this\n }\n\n /**\n * @return {Box3} the component's bounding box\n */\n getBox (...args: any[]) {\n return this.getBoxUntransformed(...args)\n .clone().applyMatrix4(this.matrix)\n }\n\n /**\n * @return {Vector3} the component's center position\n */\n getCenter (...args: any[]) {\n return this.getCenterUntransformed(...args)\n .clone().applyMatrix4(this.matrix)\n }\n\n getZoom (...args: any[]) {\n return this.stage.getZoomForBox(this.getBox(...args))\n }\n\n /**\n * @abstract\n * @return {Box3} the untransformed component's bounding box\n */\n getBoxUntransformed (...args: any[]): Box3 {\n return new Box3()\n }\n\n getCenterUntransformed (...args: any[]) {\n return this.getBoxUntransformed().getCenter(new Vector3())\n }\n\n /**\n * Automatically center and zoom the component\n * @param {Integer} [duration] - duration of the animation, defaults to 0\n * @return {undefined}\n */\n autoView (duration?: number) {\n this.stage.animationControls.zoomMove(\n this.getCenter(),\n this.getZoom(),\n defaults(duration, 0)\n )\n }\n}\n\nexport default Component\n","/**\n * @file Collection\n * @author Alexander Rose \n * @private\n */\n\nimport Component from './component'\nimport Element from './element'\n\nclass Collection {\n constructor (readonly list: T[] = []) {\n // remove elements from list when they get disposed\n const n = list.length\n\n for (let i = 0; i < n; ++i) {\n const elm = list[ i ]\n elm.signals.disposed.add(this._remove, this)\n }\n }\n\n _remove (elm: T) {\n const idx = this.list.indexOf(elm)\n\n if (idx !== -1) {\n this.list.splice(idx, 1)\n }\n }\n\n get first () {\n return this.list.length > 0 ? this.list[0] : undefined\n }\n\n forEach (fn: (x: T) => any) {\n this.list.forEach(fn)\n\n return this\n }\n\n dispose () {\n return this.forEach((elm) => elm.dispose())\n }\n}\n\nexport default Collection\n","/**\n * @file Component Collection\n * @author Alexander Rose \n * @private\n */\n\nimport RepresentationElement from './representation-element'\nimport Collection from './collection'\nimport { GenericColor } from '../types'\n\nclass RepresentationCollection extends Collection {\n setParameters (params: any) {\n return this.forEach((repr) => repr.setParameters(params))\n }\n\n setVisibility (value: boolean) {\n return this.forEach((repr) => repr.setVisibility(value))\n }\n\n setSelection (string: string) {\n return this.forEach((repr) => repr.setSelection(string))\n }\n\n setColor (color: GenericColor) {\n return this.forEach((repr) => repr.setColor(color))\n }\n\n update (what: any) {\n return this.forEach((repr) => repr.update(what))\n }\n\n build (params?: any) {\n return this.forEach((repr) => repr.build(params))\n }\n\n dispose (params?: any) {\n return this.forEach((repr) => repr.dispose())\n }\n}\n\nexport default RepresentationCollection\n","/**\n * @file Trajectory Component\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport Element, { ElementSignals, ElementDefaultParameters } from './element'\nimport Stage from '../stage/stage'\nimport Trajectory, { TrajectoryParameters } from '../trajectory/trajectory'\nimport TrajectoryPlayer, {\n TrajectoryPlayerDirection, TrajectoryPlayerMode, TrajectoryPlayerInterpolateType\n} from '../trajectory/trajectory-player'\n\n/**\n * Trajectory component parameter object.\n * @typedef {Object} TrajectoryComponentParameters - component parameters\n *\n * @property {String} name - component name\n * @property {Integer} initialFrame - initial frame the trajectory is set to\n * @property {Integer} defaultStep - default step size to be used by trajectory players\n * @property {Integer} defaultTimeout - default timeout to be used by trajectory players\n * @property {String} defaultInterpolateType - one of \"\" (empty string), \"linear\" or \"spline\"\n * @property {Integer} defaultInterpolateStep - window size used for interpolation\n * @property {String} defaultMode - either \"loop\" or \"once\"\n * @property {String} defaultDirection - either \"forward\" or \"backward\"\n */\n\nexport const TrajectoryElementDefaultParameters = Object.assign({\n defaultStep: 1,\n defaultTimeout: 50,\n defaultInterpolateType: '' as TrajectoryPlayerInterpolateType,\n defaultInterpolateStep: 5,\n defaultMode: 'loop' as TrajectoryPlayerMode,\n defaultDirection: 'forward' as TrajectoryPlayerDirection,\n initialFrame: 0\n}, ElementDefaultParameters)\nexport type TrajectoryElementParameters = typeof TrajectoryElementDefaultParameters\n\nexport interface TrajectoryElementSignals extends ElementSignals {\n frameChanged: Signal // on frame change\n playerChanged: Signal // on player change\n countChanged: Signal // when frame count is available\n parametersChanged: Signal // on parameters change\n}\n\n/**\n * Component wrapping a {@link Trajectory} object\n */\nclass TrajectoryElement extends Element {\n signals: TrajectoryElementSignals\n parameters: TrajectoryElementParameters\n get defaultParameters () { return TrajectoryElementDefaultParameters }\n\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {Trajectory} trajectory - the trajectory object\n * @param {TrajectoryComponentParameters} params - component parameters\n * @param {StructureComponent} parent - the parent structure\n */\n constructor (stage: Stage, readonly trajectory: Trajectory, params: Partial = {}) {\n super(stage, Object.assign({ name: trajectory.name }, params))\n\n this.signals = Object.assign(this.signals, {\n frameChanged: new Signal(),\n playerChanged: new Signal(),\n countChanged: new Signal(),\n parametersChanged: new Signal()\n })\n\n // signals\n\n trajectory.signals.frameChanged.add((i: number) => {\n this.signals.frameChanged.dispatch(i)\n })\n\n trajectory.signals.playerChanged.add((player: TrajectoryPlayer) => {\n this.signals.playerChanged.dispatch(player)\n })\n\n trajectory.signals.countChanged.add((n: number) => {\n this.signals.countChanged.dispatch(n)\n })\n\n //\n\n if (params.initialFrame !== undefined) {\n this.setFrame(params.initialFrame)\n }\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'trajectory' }\n\n /**\n * Set the frame of the trajectory\n * @param {Integer} i - frame number\n * @return {undefined}\n */\n setFrame (i: number) {\n this.trajectory.setFrame(i)\n }\n\n /**\n * Set trajectory parameters\n * @param {TrajectoryParameters} params - trajectory parameters\n * @return {undefined}\n */\n setParameters (params: Partial = {}) {\n this.trajectory.setParameters(params)\n this.signals.parametersChanged.dispatch(params)\n }\n\n dispose () {\n this.trajectory.dispose()\n super.dispose()\n }\n}\n\nexport default TrajectoryElement\n","/**\n * @file Frames\n * @author Alexander Rose \n * @private\n */\n\nexport default class Frames {\n coordinates = []\n boxes = []\n times = []\n\n timeOffset = 0\n deltaTime = 1\n\n constructor (readonly name: string, readonly path: string) {}\n\n get type () { return 'Frames' }\n}\n","/**\n * @file Superposition\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\nimport { Debug, Log } from '../globals'\nimport {\n Matrix, svd, meanRows, subRows, transpose,\n multiplyABt, invert3x3, multiply3x3, mat3x3determinant, multiply\n} from '../math/matrix-utils'\nimport Structure from '../structure/structure'\n\nclass Superposition {\n coords1t: Matrix\n coords2t: Matrix\n\n transformationMatrix: Matrix4\n\n mean1: number[]\n mean2: number[]\n\n A = new Matrix(3, 3)\n W = new Matrix(1, 3)\n U = new Matrix(3, 3)\n V = new Matrix(3, 3)\n VH = new Matrix(3, 3)\n R = new Matrix(3, 3)\n\n private tmp = new Matrix(3, 3)\n private c = new Matrix(3, 3)\n\n constructor (atoms1: Structure|Float32Array, atoms2: Structure|Float32Array) {\n // allocate & init data structures\n\n let n1\n if (atoms1 instanceof Structure) {\n n1 = atoms1.atomCount\n } else if (atoms1 instanceof Float32Array) {\n n1 = atoms1.length / 3\n } else {\n return\n }\n\n let n2\n if (atoms2 instanceof Structure) {\n n2 = atoms2.atomCount\n } else if (atoms2 instanceof Float32Array) {\n n2 = atoms2.length / 3\n } else {\n return\n }\n\n const n = Math.min(n1, n2)\n\n const coords1 = new Matrix(3, n)\n const coords2 = new Matrix(3, n)\n\n this.coords1t = new Matrix(n, 3)\n this.coords2t = new Matrix(n, 3)\n\n this.transformationMatrix = new Matrix4()\n\n this.c.data.set([ 1, 0, 0, 0, 1, 0, 0, 0, -1 ])\n\n // prep coords\n\n this.prepCoords(atoms1, coords1, n, false)\n this.prepCoords(atoms2, coords2, n, false)\n\n // superpose\n\n this._superpose(coords1, coords2)\n }\n\n _superpose (coords1: Matrix, coords2: Matrix) {\n this.mean1 = meanRows(coords1)\n this.mean2 = meanRows(coords2)\n\n subRows(coords1, this.mean1)\n subRows(coords2, this.mean2)\n\n transpose(this.coords1t, coords1)\n transpose(this.coords2t, coords2)\n\n multiplyABt(this.A, this.coords2t, this.coords1t)\n\n svd(this.A, this.W, this.U, this.V)\n\n invert3x3(this.V, this.VH)\n multiply3x3(this.R, this.U, this.VH)\n\n if (mat3x3determinant(this.R) < 0.0) {\n if (Debug) Log.log('R not a right handed system')\n\n multiply3x3(this.tmp, this.c, this.VH)\n multiply3x3(this.R, this.U, this.tmp)\n }\n\n //get the transformation matrix\n\n const transformMat_ = new Matrix(4,4)\n const tmp_1 = new Matrix(4,4)\n const tmp_2 = new Matrix(4,4)\n\n const sub = new Matrix(4,4)\n const mult = new Matrix(4,4)\n const add = new Matrix(4,4)\n\n const R = this.R.data\n const M1 = this.mean1\n const M2 = this.mean2\n\n sub.data.set([ 1, 0, 0, -M1[0],\n 0, 1, 0, -M1[1],\n 0, 0, 1, -M1[2],\n 0, 0, 0, 1 ])\n\n mult.data.set([ R[0], R[1], R[2], 0,\n R[3], R[4], R[5], 0,\n R[6], R[7], R[8], 0,\n 0, 0, 0, 1 ])\n\n add.data.set([ 1, 0, 0, M2[0],\n 0, 1, 0, M2[1],\n 0, 0, 1, M2[2],\n 0, 0, 0, 1 ])\n\n transpose(tmp_1,sub)\n multiplyABt(transformMat_,mult,tmp_1)\n transpose(tmp_2,transformMat_)\n multiplyABt(tmp_1,add,tmp_2)\n\n transpose(transformMat_,tmp_1)\n this.transformationMatrix.elements = transformMat_.data as unknown as number[]\n\n }\n\n prepCoords (atoms: Structure|Float32Array, coords: Matrix, n: number, is4X4: boolean) {\n let i = 0\n const cd = coords.data\n\n let c = 3\n let d = n * 3\n\n if (is4X4) {\n d = n * 4\n c = 4\n }\n if (atoms instanceof Structure) {\n atoms.eachAtom(function (a) {\n if (i < d) {\n cd[ i + 0 ] = a.x\n cd[ i + 1 ] = a.y\n cd[ i + 2 ] = a.z\n if (is4X4) cd[ i + 3 ] = 1\n\n i += c\n }\n })\n } else if (atoms instanceof Float32Array) {\n for (; i < d; i += c){\n if (i < d) {\n cd[ i ] = atoms[ i ]\n cd[ i + 1 ] = atoms[ i + 1 ]\n cd[ i + 2 ] = atoms[ i + 2 ]\n if (is4X4) cd[ i + 3 ] = 1\n }\n }\n } else {\n Log.warn('prepCoords: input type unknown')\n }\n }\n\n transform (atoms: Structure|Float32Array) {\n // allocate data structures\n\n let n\n if (atoms instanceof Structure) {\n n = atoms.atomCount\n } else if (atoms instanceof Float32Array) {\n n = atoms.length / 3\n } else {\n return\n }\n\n const coords = new Matrix(4, n)\n const tCoords = new Matrix(n,4)\n\n // prep coords\n\n this.prepCoords(atoms, coords, n, true)\n\n // check for transformation matrix correctness\n\n const transform = this.transformationMatrix\n const det = transform.determinant()\n if (!det){\n return det\n }\n\n // do transform\n\n const mult = new Matrix(4,4)\n mult.data = transform.elements as unknown as Float32Array\n multiply(tCoords,coords,mult)\n\n let i = 0\n const cd = tCoords.data\n if (atoms instanceof Structure) {\n atoms.eachAtom(function (a) {\n a.x = cd[ i ]\n a.y = cd[ i + 1 ]\n a.z = cd[ i + 2 ]\n i += 4\n })\n\n //update transformation matrices for each assembly\n\n const invertTrasform = new Matrix4()\n invertTrasform.getInverse(transform)\n\n const biomolDict = atoms.biomolDict\n\n for (let key in biomolDict) {\n\n if (biomolDict.hasOwnProperty(key)) {\n let assembly = biomolDict[key]\n\n assembly.partList.forEach(function(part){\n\n part.matrixList.forEach(function(mat){\n\n mat.premultiply(transform)\n mat.multiply(invertTrasform)\n\n })\n })\n }\n }\n } else if (atoms instanceof Float32Array) {\n\n const n4 = n * 4\n for (; i < n4; i += 4){\n\n atoms[ i ] = cd[ i ]\n atoms[ i + 1 ] = cd[ i + 1 ]\n atoms[ i + 2 ] = cd[ i + 2 ]\n\n }\n } else {\n Log.warn('transform: input type unknown')\n }\n\n return this.transformationMatrix\n }\n}\nexport default Superposition\n","/**\n * @file Trajectory Player\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { defaults, createParams, updateParams } from '../utils'\nimport Trajectory from './trajectory'\n\nexport type TrajectoryPlayerInterpolateType = ''|'linear'|'spline'\nexport type TrajectoryPlayerMode = 'loop'|'once'\nexport type TrajectoryPlayerDirection = 'forward'|'backward'|'bounce'\n\nexport const TrajectoryPlayerDefaultParameters = {\n step: 1, // how many frames to advance when playing\n timeout: 50, // how many milliseconds to wait between playing frames\n start: 0, // first frame to play\n end: 0, // last frame to play\n interpolateType: '' as TrajectoryPlayerInterpolateType,\n interpolateStep: 5, // window size used for interpolation\n mode: 'loop' as TrajectoryPlayerMode,\n direction: 'forward' as TrajectoryPlayerDirection\n}\nexport type TrajectoryPlayerParameters = typeof TrajectoryPlayerDefaultParameters\n\nexport interface TrajectoryPlayerSignals {\n startedRunning: Signal\n haltedRunning: Signal\n}\n\n/**\n * Trajectory player for animating coordinate frames\n * @example\n * var player = new TrajectoryPlayer(trajectory, {step: 1, timeout: 50});\n * player.play();\n */\nclass TrajectoryPlayer {\n signals: TrajectoryPlayerSignals = {\n startedRunning: new Signal(),\n haltedRunning: new Signal()\n }\n\n parameters: TrajectoryPlayerParameters\n traj: Trajectory\n\n private _run = false\n private _previousTime = 0\n private _currentTime = 0\n private _currentStep = 1\n private _currentFrame: number|[number, number, number, number]\n private _direction: TrajectoryPlayerDirection\n\n /**\n * make trajectory player\n * @param {Trajectory} traj - the trajectory\n * @param {TrajectoryPlayerParameters} [params] - parameter object\n */\n constructor (traj: Trajectory, params: Partial = {}) {\n traj.signals.playerChanged.add((player: TrajectoryPlayer) => {\n if (player !== this) {\n this.pause()\n }\n }, this)\n\n const n = defaults(traj.frameCount, 1)\n\n this.traj = traj\n this.parameters = createParams(params, TrajectoryPlayerDefaultParameters)\n this.parameters.end = Math.min(defaults(params.end, n - 1), n - 1)\n this.parameters.step = defaults(params.step, Math.ceil((n + 1) / 100))\n\n this._currentFrame = this.parameters.start\n this._direction = this.parameters.direction === 'bounce' ? 'forward' : this.parameters.direction\n\n traj.signals.countChanged.add((n: number) => {\n this.parameters.end = Math.min(defaults(this.parameters.end, n - 1), n - 1)\n }, this)\n\n this._animate = this._animate.bind(this)\n }\n\n get isRunning () { return this._run }\n\n /**\n * set player parameters\n * @param {TrajectoryPlayerParameters} [params] - parameter object\n */\n setParameters (params: Partial = {}) {\n updateParams(this.parameters, params)\n\n if (params.direction !== undefined && this.parameters.direction !== 'bounce') {\n this._direction = this.parameters.direction\n }\n }\n\n _animate () {\n if (!this._run) return\n\n this._currentTime = window.performance.now()\n const dt = this._currentTime - this._previousTime\n const step = this.parameters.interpolateType ? this.parameters.interpolateStep : 1\n const timeout = this.parameters.timeout / step\n const traj = this.traj\n\n if (traj && traj.frameCount && !traj.inProgress && dt >= timeout) {\n if (this.parameters.interpolateType) {\n if (this._currentStep > this.parameters.interpolateStep) {\n this._currentStep = 1\n }\n if (this._currentStep === 1) {\n this._currentFrame = this._nextInterpolated()\n }\n if (traj.hasFrame(this._currentFrame)) {\n this._currentStep += 1\n const t = this._currentStep / (this.parameters.interpolateStep + 1)\n const [i, ip, ipp, ippp] = this._currentFrame as [number, number, number, number]\n traj.setFrameInterpolated(\n i, ip, ipp, ippp, t, this.parameters.interpolateType\n )\n this._previousTime = this._currentTime\n } else {\n traj.loadFrame(this._currentFrame)\n }\n } else {\n const i = this._next()\n if (traj.hasFrame(i)) {\n traj.setFrame(i)\n this._previousTime = this._currentTime\n } else {\n traj.loadFrame(i)\n }\n }\n }\n\n window.requestAnimationFrame(this._animate)\n }\n\n _next () {\n const p = this.parameters\n let i\n\n if (this._direction === 'forward') {\n i = this.traj.currentFrame + p.step\n } else {\n i = this.traj.currentFrame - p.step\n }\n\n if (i > p.end || i < p.start) {\n if (p.direction === 'bounce') {\n if (this._direction === 'forward') {\n this._direction = 'backward'\n } else {\n this._direction = 'forward'\n }\n }\n\n if (p.mode === 'once') {\n this.pause()\n\n if (p.direction === 'forward') {\n i = p.end\n } else if (p.direction === 'backward') {\n i = p.start\n } else {\n if (this._direction === 'forward') {\n i = p.start\n } else {\n i = p.end\n }\n }\n } else {\n if (this._direction === 'forward') {\n i = p.start\n if (p.interpolateType) {\n i = Math.min(p.end, i + p.step)\n }\n } else {\n i = p.end\n if (p.interpolateType) {\n i = Math.max(p.start, i - p.step)\n }\n }\n }\n }\n\n return i\n }\n\n _nextInterpolated () {\n const p = this.parameters\n const i = this._next()\n let ip, ipp, ippp\n\n if (this._direction === 'forward') {\n ip = Math.max(p.start, i - p.step)\n ipp = Math.max(p.start, i - 2 * p.step)\n ippp = Math.max(p.start, i - 3 * p.step)\n } else {\n ip = Math.min(p.end, i + p.step)\n ipp = Math.min(p.end, i + 2 * p.step)\n ippp = Math.min(p.end, i + 3 * p.step)\n }\n\n return [i, ip, ipp, ippp] as [number, number, number, number]\n }\n\n /**\n * toggle between playing and pausing the animation\n * @return {undefined}\n */\n toggle () {\n if (this._run) {\n this.pause()\n } else {\n this.play()\n }\n }\n\n /**\n * start the animation\n * @return {undefined}\n */\n play () {\n if (!this._run) {\n if (this.traj.player !== this) {\n this.traj.setPlayer(this)\n }\n this._currentStep = 1\n\n const p = this.parameters\n const frame = this.traj.currentFrame\n\n // snap to the grid implied by this.step division and multiplication\n // thus minimizing cache misses\n let i = Math.ceil(frame / p.step) * p.step\n // wrap when restarting from the limit (i.e. end or start)\n if (p.direction === 'forward' && frame >= p.end) {\n i = p.start\n } else if (p.direction === 'backward' && frame <= p.start) {\n i = p.end\n }\n\n this.traj.setFrame(i)\n\n this._run = true\n this._animate()\n this.signals.startedRunning.dispatch()\n }\n }\n\n /**\n * pause the animation\n * @return {undefined}\n */\n pause () {\n this._run = false\n this.signals.haltedRunning.dispatch()\n }\n\n /**\n * stop the animation (pause and go to start-frame)\n * @return {undefined}\n */\n stop () {\n this.pause()\n this.traj.setFrame(this.parameters.start)\n }\n}\n\nexport default TrajectoryPlayer\n","/**\n * @file Trajectory\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { Log } from '../globals'\nimport { defaults } from '../utils'\nimport { NumberArray } from '../types'\nimport { circularMean, arrayMean } from '../math/array-utils'\nimport { lerp, spline } from '../math/math-utils'\nimport Selection from '../selection/selection'\nimport Superposition from '../align/superposition'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\nimport TrajectoryPlayer, { TrajectoryPlayerInterpolateType } from './trajectory-player'\n\n\nfunction centerPbc (coords: NumberArray, mean: number[], box: ArrayLike) {\n if (box[ 0 ] === 0 || box[ 8 ] === 0 || box[ 4 ] === 0) {\n return\n }\n\n const n = coords.length\n\n const bx = box[ 0 ]\n const by = box[ 1 ]\n const bz = box[ 2 ]\n const mx = mean[ 0 ]\n const my = mean[ 1 ]\n const mz = mean[ 2 ]\n\n const fx = -mx + bx + bx / 2\n const fy = -my + by + by / 2\n const fz = -mz + bz + bz / 2\n\n for (let i = 0; i < n; i += 3) {\n coords[ i + 0 ] = (coords[ i + 0 ] + fx) % bx\n coords[ i + 1 ] = (coords[ i + 1 ] + fy) % by\n coords[ i + 2 ] = (coords[ i + 2 ] + fz) % bz\n }\n}\n\nfunction removePbc (x: NumberArray, box: ArrayLike) {\n if (box[ 0 ] === 0 || box[ 8 ] === 0 || box[ 4 ] === 0) {\n return\n }\n\n // ported from GROMACS src/gmxlib/rmpbc.c:rm_gropbc()\n // in-place\n\n const n = x.length\n\n for (let i = 3; i < n; i += 3) {\n for (let j = 0; j < 3; ++j) {\n const dist = x[ i + j ] - x[ i - 3 + j ]\n\n if (Math.abs(dist) > 0.9 * box[ j * 3 + j ]) {\n if (dist > 0) {\n for (let d = 0; d < 3; ++d) {\n x[ i + d ] -= box[ j * 3 + d ]\n }\n } else {\n for (let d = 0; d < 3; ++d) {\n x[ i + d ] += box[ j * 3 + d ]\n }\n }\n }\n }\n }\n\n return x\n}\n\nfunction removePeriodicity (x: NumberArray, box: ArrayLike, mean: number[]) {\n if (box[ 0 ] === 0 || box[ 8 ] === 0 || box[ 4 ] === 0) {\n return\n }\n\n const n = x.length\n for (let i = 3; i < n; i += 3) {\n for (let j = 0; j < 3; ++j) {\n const f = (x[ i + j ] - mean[ j ]) / box[ j * 3 + j ]\n if (Math.abs(f) > 0.5) {\n x[ i + j ] -= box[ j * 3 + j ] * Math.round(f)\n }\n }\n }\n\n return x\n}\n\nfunction circularMean3 (indices: NumberArray, coords: NumberArray, box: ArrayLike) {\n return [\n circularMean(coords, box[ 0 ], 3, 0, indices),\n circularMean(coords, box[ 1 ], 3, 1, indices),\n circularMean(coords, box[ 2 ], 3, 2, indices)\n ]\n}\n\nfunction arrayMean3 (coords: NumberArray) {\n return [\n arrayMean(coords, 3, 0),\n arrayMean(coords, 3, 1),\n arrayMean(coords, 3, 2)\n ]\n}\n\nfunction interpolateSpline (c: NumberArray, cp: NumberArray, cpp: NumberArray, cppp: NumberArray, t: number) {\n const m = c.length\n const coords = new Float32Array(m)\n\n for (let j0 = 0; j0 < m; j0 += 3) {\n const j1 = j0 + 1\n const j2 = j0 + 2\n coords[ j0 ] = spline(cppp[ j0 ], cpp[ j0 ], cp[ j0 ], c[ j0 ], t, 1)\n coords[ j1 ] = spline(cppp[ j1 ], cpp[ j1 ], cp[ j1 ], c[ j1 ], t, 1)\n coords[ j2 ] = spline(cppp[ j2 ], cpp[ j2 ], cp[ j2 ], c[ j2 ], t, 1)\n }\n\n return coords\n}\n\nfunction interpolateLerp (c: NumberArray, cp: NumberArray, t: number) {\n const m = c.length\n const coords = new Float32Array(m)\n\n for (let j0 = 0; j0 < m; j0 += 3) {\n const j1 = j0 + 1\n const j2 = j0 + 2\n coords[ j0 ] = lerp(cp[ j0 ], c[ j0 ], t)\n coords[ j1 ] = lerp(cp[ j1 ], c[ j1 ], t)\n coords[ j2 ] = lerp(cp[ j2 ], c[ j2 ], t)\n }\n\n return coords\n}\n\n/**\n * Trajectory parameter object.\n * @typedef {Object} TrajectoryParameters - parameters\n *\n * @property {Number} deltaTime - timestep between frames in picoseconds\n * @property {Number} timeOffset - starting time of frames in picoseconds\n * @property {String} sele - to restrict atoms used for superposition\n * @property {Boolean} centerPbc - center on initial frame\n * @property {Boolean} removePeriodicity - move atoms into the origin box\n * @property {Boolean} remo - try fixing periodic boundary discontinuities\n * @property {Boolean} superpose - superpose on initial frame\n */\n\n/**\n * @example\n * trajectory.signals.frameChanged.add( function(i){ ... } );\n *\n * @typedef {Object} TrajectorySignals\n * @property {Signal} countChanged - when the frame count is changed\n * @property {Signal} frameChanged - when the set frame is changed\n * @property {Signal} playerChanged - when the player is changed\n */\n\nexport interface TrajectoryParameters {\n deltaTime: number // timestep between frames in picoseconds\n timeOffset: number // starting time of frames in picoseconds\n sele: string // to restrict atoms used for superposition\n centerPbc: boolean // center on initial frame\n removePbc: boolean // move atoms into the origin box\n removePeriodicity: boolean // try fixing periodic boundary discontinuities\n superpose: boolean // superpose on initial frame\n}\n\nexport interface TrajectorySignals {\n countChanged: Signal\n frameChanged: Signal\n playerChanged: Signal\n}\n\n/**\n * Base class for trajectories, tying structures and coordinates together\n * @interface\n */\nclass Trajectory {\n signals: TrajectorySignals = {\n countChanged: new Signal(),\n frameChanged: new Signal(),\n playerChanged: new Signal()\n }\n\n deltaTime: number\n timeOffset: number\n sele: string\n centerPbc: boolean\n removePbc: boolean\n removePeriodicity: boolean\n superpose: boolean\n\n name: string\n frame: number\n trajPath: string\n\n initialCoords: Float32Array\n structureCoords: Float32Array\n selectionIndices: NumberArray\n backboneIndices: NumberArray\n\n coords1: Float32Array\n coords2: Float32Array\n\n frameCache: { [k: number]: Float32Array } = {}\n loadQueue: { [k: number]: boolean } = {}\n boxCache: { [k: number]: ArrayLike } = {}\n pathCache = {}\n frameCacheSize = 0\n\n atomCount: number\n inProgress: boolean\n\n selection: Selection // selection to restrict atoms used for superposition\n structure: Structure\n player: TrajectoryPlayer\n\n private _frameCount = 0\n private _currentFrame = -1\n private _disposed = false\n\n /**\n * @param {String} trajPath - trajectory source\n * @param {Structure} structure - the structure object\n * @param {TrajectoryParameters} params - trajectory parameters\n */\n constructor (trajPath: string, structure: Structure, params: Partial = {}) {\n this.deltaTime = defaults(params.deltaTime, 0)\n this.timeOffset = defaults(params.timeOffset, 0)\n this.centerPbc = defaults(params.centerPbc, false)\n this.removePbc = defaults(params.removePbc, false)\n this.removePeriodicity = defaults(params.removePeriodicity, false)\n this.superpose = defaults(params.superpose, false)\n\n this.name = trajPath.replace(/^.*[\\\\/]/, '')\n this.trajPath = trajPath\n\n this.selection = new Selection(\n defaults(params.sele, 'backbone and not hydrogen')\n )\n\n this.selection.signals.stringChanged.add(() => {\n this.selectionIndices = this.structure.getAtomIndices(this.selection)!\n this._resetCache()\n this._saveInitialCoords()\n this.setFrame(this._currentFrame)\n })\n }\n\n /**\n * Number of frames in the trajectory\n */\n get frameCount () {\n return this._frameCount\n }\n\n /**\n * Currently set frame of the trajectory\n */\n get currentFrame () {\n return this._currentFrame\n }\n\n _init (structure: Structure) {\n this.setStructure(structure)\n this._loadFrameCount()\n this.setPlayer(new TrajectoryPlayer(this))\n }\n\n _loadFrameCount () {}\n\n setStructure (structure: Structure) {\n this.structure = structure\n this.atomCount = structure.atomCount\n\n this.backboneIndices = this._getIndices(\n new Selection('backbone and not hydrogen')\n )\n this._makeAtomIndices()\n this._saveStructureCoords()\n\n this.selectionIndices = this._getIndices(this.selection)\n this._resetCache()\n this._saveInitialCoords()\n this.setFrame(this._currentFrame)\n }\n\n _saveInitialCoords () {\n if (this.structure.hasCoords()) {\n this.initialCoords = new Float32Array(this.structureCoords)\n this._makeSuperposeCoords()\n } else if (this.frameCache[0]) {\n this.initialCoords = new Float32Array(this.frameCache[0])\n this._makeSuperposeCoords()\n } else {\n this.loadFrame(0, () => this._saveInitialCoords())\n }\n }\n\n _saveStructureCoords () {\n const p = { what: { position: true } }\n this.structureCoords = this.structure.getAtomData(p).position!\n }\n\n setSelection (string: string) {\n this.selection.setString(string)\n return this\n }\n\n _getIndices (selection: Selection) {\n let i = 0\n const test = selection.test\n const indices: number[] = []\n\n if (test) {\n this.structure.eachAtom((ap: AtomProxy) => {\n if (test(ap)) indices.push(i)\n i += 1\n })\n }\n\n return indices\n }\n\n _makeSuperposeCoords () {\n const n = this.selectionIndices.length * 3\n\n this.coords1 = new Float32Array(n)\n this.coords2 = new Float32Array(n)\n\n const y = this.initialCoords\n const coords2 = this.coords2\n\n for (let i = 0; i < n; i += 3) {\n const j = this.selectionIndices[ i / 3 ] * 3\n\n coords2[ i + 0 ] = y[ j + 0 ]\n coords2[ i + 1 ] = y[ j + 1 ]\n coords2[ i + 2 ] = y[ j + 2 ]\n }\n }\n\n _makeAtomIndices () {\n Log.error('Trajectory._makeAtomIndices not implemented')\n }\n\n _resetCache () {\n this.frameCache = {}\n this.loadQueue = {}\n this.boxCache = {}\n this.pathCache = {}\n this.frameCacheSize = 0\n this.initialCoords = new Float32Array(0)\n }\n\n setParameters (params: Partial = {}) {\n let resetCache = false\n\n if (params.centerPbc !== undefined && params.centerPbc !== this.centerPbc) {\n this.centerPbc = params.centerPbc\n resetCache = true\n }\n\n if (params.removePeriodicity !== undefined && params.removePeriodicity !== this.removePeriodicity) {\n this.removePeriodicity = params.removePeriodicity\n resetCache = true\n }\n\n if (params.removePbc !== undefined && params.removePbc !== this.removePbc) {\n this.removePbc = params.removePbc\n resetCache = true\n }\n\n if (params.superpose !== undefined && params.superpose !== this.superpose) {\n this.superpose = params.superpose\n resetCache = true\n }\n\n this.deltaTime = defaults(params.deltaTime, this.deltaTime)\n this.timeOffset = defaults(params.timeOffset, this.timeOffset)\n\n if (resetCache) {\n this._resetCache()\n this.setFrame(this._currentFrame)\n }\n }\n\n /**\n * Check if a frame is available\n * @param {Integer|Integer[]} i - the frame index\n * @return {Boolean} frame availability\n */\n hasFrame (i: number|number[]) {\n if (Array.isArray(i)) {\n return i.every(j => !!this.frameCache[j])\n } else {\n return !!this.frameCache[i]\n }\n }\n\n /**\n * Set trajectory to a frame index\n * @param {Integer} i - the frame index\n * @param {Function} [callback] - fired when the frame has been set\n */\n setFrame (i: number, callback?: Function) {\n if (i === undefined) return this\n\n this.inProgress = true\n\n // i = parseInt(i) // TODO\n\n if (i === -1 || this.frameCache[ i ]) {\n this._updateStructure(i)\n if (callback) callback()\n } else {\n this.loadFrame(i, () => {\n this._updateStructure(i)\n if (callback) callback()\n })\n }\n\n return this\n }\n\n _interpolate (i: number, ip: number, ipp: number, ippp: number, t: number, type: TrajectoryPlayerInterpolateType) {\n const fc = this.frameCache\n\n let coords\n if (type === 'spline') {\n coords = interpolateSpline(fc[ i ], fc[ ip ], fc[ ipp ], fc[ ippp ], t)\n } else {\n coords = interpolateLerp(fc[ i ], fc[ ip ], t)\n }\n\n this.structure.updatePosition(coords)\n this._currentFrame = i\n this.signals.frameChanged.dispatch(i)\n }\n\n /**\n * Interpolated and set trajectory to frame indices\n * @param {Integer} i - the frame index\n * @param {Integer} ip - one before frame index\n * @param {Integer} ipp - two before frame index\n * @param {Integer} ippp - three before frame index\n * @param {Number} t - interpolation step [0,1]\n * @param {String} type - interpolation type, '', 'spline' or 'linear'\n * @param {Function} callback - fired when the frame has been set\n */\n setFrameInterpolated (i: number, ip: number, ipp: number, ippp: number, t: number, type: TrajectoryPlayerInterpolateType, callback?: Function) {\n if (i === undefined) return this\n\n const fc = this.frameCache\n const iList: number[] = []\n\n if (!fc[ ippp ]) iList.push(ippp)\n if (!fc[ ipp ]) iList.push(ipp)\n if (!fc[ ip ]) iList.push(ip)\n if (!fc[ i ]) iList.push(i)\n\n if (iList.length) {\n this.loadFrame(iList, () => {\n this._interpolate(i, ip, ipp, ippp, t, type)\n if (callback) callback()\n })\n } else {\n this._interpolate(i, ip, ipp, ippp, t, type)\n if (callback) callback()\n }\n\n return this\n }\n\n /**\n * Load frame index\n * @param {Integer|Integer[]} i - the frame index\n * @param {Function} callback - fired when the frame has been loaded\n */\n loadFrame (i: number|number[], callback?: Function) {\n if (Array.isArray(i)) {\n i.forEach(j => {\n if (!this.loadQueue[j] && !this.frameCache[j]) {\n this.loadQueue[j] = true\n this._loadFrame(j, () => {\n delete this.loadQueue[j]\n })\n }\n })\n } else {\n if (!this.loadQueue[i] && !this.frameCache[i]) {\n this.loadQueue[i] = true\n this._loadFrame(i, () => {\n delete this.loadQueue[i]\n if (callback) callback()\n })\n }\n }\n }\n\n /**\n * Load frame index\n * @abstract\n * @param {Integer} i - the frame index\n * @param {Function} callback - fired when the frame has been loaded\n */\n _loadFrame (i: number, callback?: Function) {\n Log.error('Trajectory._loadFrame not implemented', i, callback)\n }\n\n _updateStructure (i: number) {\n if (this._disposed) {\n console.error('updateStructure: traj disposed')\n return\n }\n\n if (i === -1) {\n if (this.structureCoords) {\n this.structure.updatePosition(this.structureCoords)\n }\n } else {\n this.structure.updatePosition(this.frameCache[ i ])\n }\n\n this.structure.trajectory = {\n name: this.trajPath,\n frame: i\n }\n\n this._currentFrame = i\n this.inProgress = false\n this.signals.frameChanged.dispatch(i)\n }\n\n _doSuperpose (x: Float32Array) {\n const n = this.selectionIndices.length * 3\n\n const coords1 = this.coords1\n const coords2 = this.coords2\n\n for (let i = 0; i < n; i += 3) {\n const j = this.selectionIndices[ i / 3 ] * 3\n\n coords1[ i + 0 ] = x[ j + 0 ]\n coords1[ i + 1 ] = x[ j + 1 ]\n coords1[ i + 2 ] = x[ j + 2 ]\n }\n\n // TODO re-use superposition object\n const sp = new Superposition(coords1, coords2)\n sp.transform(x)\n }\n\n _process (i: number, box: ArrayLike, coords: Float32Array, frameCount: number) {\n this._setFrameCount(frameCount)\n\n if (box) {\n if (this.backboneIndices.length > 0 && this.centerPbc) {\n const box2 = [ box[ 0 ], box[ 4 ], box[ 8 ] ]\n const circMean = circularMean3(this.backboneIndices, coords, box2)\n centerPbc(coords, circMean, box2)\n }\n\n if (this.removePeriodicity) {\n const mean = arrayMean3(coords)\n removePeriodicity(coords, box, mean)\n }\n\n if (this.removePbc) {\n removePbc(coords, box)\n }\n }\n\n if (this.selectionIndices.length > 0 && this.coords1 && this.superpose) {\n this._doSuperpose(coords)\n }\n\n this.frameCache[ i ] = coords\n this.boxCache[ i ] = box\n this.frameCacheSize += 1\n }\n\n _setFrameCount (n: number) {\n if (n !== this._frameCount) {\n this._frameCount = n\n this.signals.countChanged.dispatch(n)\n }\n }\n\n /**\n * Dispose of the trajectory object\n * @return {undefined}\n */\n dispose () {\n this._resetCache() // aid GC\n this._disposed = true\n if (this.player) this.player.stop()\n }\n\n /**\n * Set player for this trajectory\n * @param {TrajectoryPlayer} player - the player\n */\n setPlayer (player: TrajectoryPlayer) {\n this.player = player\n this.signals.playerChanged.dispatch(player)\n }\n\n /**\n * Get time for frame\n * @param {Integer} i - frame index\n * @return {Number} time in picoseconds\n */\n getFrameTime (i: number) {\n return this.timeOffset + i * this.deltaTime\n }\n}\n\nexport default Trajectory\n","/**\n * @file Frames Trajectory\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport Structure from '../structure/structure'\nimport Frames from './frames'\nimport Trajectory, { TrajectoryParameters } from './trajectory'\n\n/**\n * Frames trajectory class. Gets data from a frames object.\n */\nclass FramesTrajectory extends Trajectory {\n path: string\n\n frames: ArrayLike[]\n boxes: ArrayLike[]\n\n atomIndices?: ArrayLike\n\n constructor (frames: Frames, structure: Structure, params: TrajectoryParameters) {\n const p = params || {}\n p.timeOffset = defaults(p.timeOffset, frames.timeOffset)\n p.deltaTime = defaults(p.deltaTime, frames.deltaTime)\n\n super('', structure, p)\n\n this.name = frames.name\n this.path = frames.path\n\n this.frames = frames.coordinates\n this.boxes = frames.boxes\n\n this._init(structure)\n }\n\n get type () { return 'frames' }\n\n _makeAtomIndices () {\n if (this.structure.type === 'StructureView') {\n this.atomIndices = this.structure.getAtomIndices()\n } else {\n this.atomIndices = undefined\n }\n }\n\n _loadFrame (i: number, callback?: Function) {\n let coords\n const frame = this.frames[ i ]\n\n if (this.atomIndices) {\n const indices = this.atomIndices\n const m = indices.length\n\n coords = new Float32Array(m * 3)\n\n for (let j = 0; j < m; ++j) {\n const j3 = j * 3\n const idx3 = indices[ j ] * 3\n\n coords[ j3 + 0 ] = frame[ idx3 + 0 ]\n coords[ j3 + 1 ] = frame[ idx3 + 1 ]\n coords[ j3 + 2 ] = frame[ idx3 + 2 ]\n }\n } else {\n coords = new Float32Array(frame)\n }\n\n const box = this.boxes[ i ]\n const frameCount = this.frames.length\n\n this._process(i, box, coords, frameCount)\n\n if (typeof callback === 'function') {\n callback()\n }\n }\n\n _loadFrameCount () {\n if (this.frames) {\n this._setFrameCount(this.frames.length)\n }\n }\n}\n\nexport default FramesTrajectory\n","/**\n * @file Structure Trajectory\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Trajectory, { TrajectoryParameters } from './trajectory'\n\n/**\n * Structure trajectory class. Gets data from a structure object.\n */\nclass StructureTrajectory extends Trajectory {\n atomIndices?: ArrayLike\n\n constructor (trajPath: string, structure: Structure, params: TrajectoryParameters) {\n super('', structure, params)\n this._init(structure)\n }\n\n get type () { return 'structure' }\n\n _makeAtomIndices () {\n if (this.structure.atomSet && this.structure.atomSet.getSize() < this.structure.atomStore.count) {\n this.atomIndices = this.structure.getAtomIndices()\n } else {\n this.atomIndices = undefined\n }\n }\n\n _loadFrame (i: number, callback?: Function) {\n let coords\n const structure = this.structure\n const frame = structure.frames[ i ]\n\n if (this.atomIndices) {\n const indices = this.atomIndices\n const m = indices.length\n\n coords = new Float32Array(m * 3)\n\n for (let j = 0; j < m; ++j) {\n const j3 = j * 3\n const idx3 = indices[ j ] * 3\n\n coords[ j3 + 0 ] = frame[ idx3 + 0 ]\n coords[ j3 + 1 ] = frame[ idx3 + 1 ]\n coords[ j3 + 2 ] = frame[ idx3 + 2 ]\n }\n } else {\n coords = new Float32Array(frame)\n }\n\n const box = structure.boxes[ i ]\n const frameCount = structure.frames.length\n\n this._process(i, box, coords, frameCount)\n\n if (typeof callback === 'function') {\n callback()\n }\n }\n\n _loadFrameCount () {\n this._setFrameCount(this.structure.frames.length)\n }\n}\n\nexport default StructureTrajectory\n","/**\n * @file Remote Trajectory\n * @author Alexander Rose \n * @private\n */\n\nimport { Log, TrajectoryDatasource } from '../globals'\nimport Structure from '../structure/structure'\nimport Trajectory, { TrajectoryParameters } from './trajectory'\n\n/**\n * Remote trajectory class. Gets data from an MDsrv instance.\n */\nclass RemoteTrajectory extends Trajectory {\n atomIndices: number[][]\n\n constructor (trajPath: string, structure: Structure, params: TrajectoryParameters) {\n super(trajPath, structure, params)\n this._init(structure)\n }\n\n get type () { return 'remote' }\n\n _makeAtomIndices () {\n const atomIndices = []\n\n if (this.structure.type === 'StructureView') {\n const indices = this.structure.getAtomIndices()! // TODO\n const n = indices.length\n\n let p = indices[ 0 ]\n let q = indices[ 0 ]\n\n for (let i = 1; i < n; ++i) {\n const r = indices[ i ]\n\n if (q + 1 < r) {\n atomIndices.push([ p, q + 1 ])\n p = r\n }\n\n q = r\n }\n\n atomIndices.push([ p, q + 1 ])\n } else {\n atomIndices.push([ 0, this.atomCount ])\n }\n\n this.atomIndices = atomIndices\n }\n\n _loadFrame (i: number, callback?: Function) {\n // TODO implement max frameCache size, re-use arrays\n\n const request = new XMLHttpRequest()\n\n const url = TrajectoryDatasource.getFrameUrl(this.trajPath, i)\n const params = TrajectoryDatasource.getFrameParams(this.trajPath, this.atomIndices)\n\n request.open('POST', url, true)\n request.responseType = 'arraybuffer'\n request.setRequestHeader(\n 'Content-type', 'application/x-www-form-urlencoded'\n )\n\n request.addEventListener('load', () => {\n const arrayBuffer = request.response\n if (!arrayBuffer) {\n Log.error(`empty arrayBuffer for '${url}'`)\n return\n }\n\n const frameCount = new Int32Array(arrayBuffer, 0, 1)[ 0 ]\n // const time = new Float32Array( arrayBuffer, 1 * 4, 1 )[ 0 ];\n const box = new Float32Array(arrayBuffer, 2 * 4, 9)\n const coords = new Float32Array(arrayBuffer, 11 * 4)\n\n this._process(i, box, coords, frameCount)\n if (typeof callback === 'function') {\n callback()\n }\n }, false)\n\n request.send(params)\n }\n\n _loadFrameCount () {\n const request = new XMLHttpRequest()\n\n const url = TrajectoryDatasource.getCountUrl(this.trajPath)\n\n request.open('GET', url, true)\n request.addEventListener('load', () => {\n this._setFrameCount(parseInt(request.response))\n }, false)\n request.send()\n }\n}\n\nexport default RemoteTrajectory\n","/**\n * @file Callback Trajectory\n * @author Tarn W. Burton \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Trajectory, { TrajectoryParameters } from './trajectory'\n\ntype RequestCallback = (responseCallback: Function, i?: number, atomIndices?: number[][]) => void\n\n/**\n * Callback trajectory class. Gets data from an JavaScript function.\n */\nclass CallbackTrajectory extends Trajectory {\n atomIndices: number[][]\n requestCallback: RequestCallback\n\n constructor (requestCallback: RequestCallback, structure: Structure, params: TrajectoryParameters) {\n super('', structure, params)\n this.requestCallback = requestCallback;\n this._init(structure)\n }\n\n get type () { return 'callback' }\n\n _makeAtomIndices () {\n const atomIndices = []\n\n if (this.structure.type === 'StructureView') {\n const indices = this.structure.getAtomIndices()! // TODO\n const n = indices.length\n\n let p = indices[ 0 ]\n let q = indices[ 0 ]\n\n for (let i = 1; i < n; ++i) {\n const r = indices[ i ]\n\n if (q + 1 < r) {\n atomIndices.push([ p, q + 1 ])\n p = r\n }\n\n q = r\n }\n\n atomIndices.push([ p, q + 1 ])\n } else {\n atomIndices.push([ 0, this.atomCount ])\n }\n\n this.atomIndices = atomIndices\n }\n\n _loadFrame (i: number, callback?: Function) {\n this.requestCallback(\n (i: number, box: ArrayLike, coords: Float32Array, frameCount: number) => {\n this._process(i, box, coords, frameCount)\n if (typeof callback === 'function') {\n callback()\n }\n }, i, this.atomIndices)\n }\n\n _loadFrameCount () {\n this.requestCallback((count: number) => this._setFrameCount(count))\n }\n}\n\nexport default CallbackTrajectory\n\n","/**\n * @file Structure View\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3 } from 'three'\n\nimport { Debug, Log } from '../globals'\nimport Structure from './structure'\nimport Selection from '../selection/selection'\nimport BitArray from '../utils/bitarray'\n\nimport BondProxy from '../proxy/bond-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\nimport SpatialHash from '../geometry/spatial-hash';\nimport BondHash from '../store/bond-hash';\nimport ResidueMap from '../store/residue-map';\nimport AtomMap from '../store/atom-map';\nimport ModelStore from '../store/model-store';\nimport ChainStore from '../store/chain-store';\nimport ResidueStore from '../store/residue-store';\nimport AtomStore from '../store/atom-store';\nimport BondStore from '../store/bond-store';\nimport Validation from './validation';\nimport Unitcell from '../symmetry/unitcell';\nimport Entity from './entity';\nimport Assembly from '../symmetry/assembly';\nimport { Data } from './data';\n\n/**\n * Get view on structure restricted to the selection\n * @param {Selection} selection - the selection\n * @return {StructureView} the view on the structure\n */\nStructure.prototype.getView = function (this: Structure, selection: Selection) {\n // added here to avoid cyclic import dependency\n return new StructureView(this, selection)\n}\n\n/**\n * View on the structure, restricted to the selection\n */\nclass StructureView extends Structure {\n structure: Structure\n selection: Selection\n\n /**\n * @param {Structure} structure - the structure\n * @param {Selection} selection - the selection\n */\n constructor (structure: Structure, selection: Selection) {\n super()\n\n this.structure = structure\n this.selection = selection\n\n this.center = new Vector3()\n this.boundingBox = new Box3()\n\n this._bp = this.getBondProxy()\n this._ap = this.getAtomProxy()\n this._rp = this.getResidueProxy()\n this._cp = this.getChainProxy()\n\n if (this.selection) {\n this.selection.signals.stringChanged.add(this.refresh, this)\n }\n\n this.structure.signals.refreshed.add(this.refresh, this)\n\n this.refresh()\n }\n\n init () {}\n\n get type () { return 'StructureView' }\n\n get name () { return this.structure.name }\n get path () { return this.structure.path }\n get title () { return this.structure.title }\n get id () { return this.structure.id }\n get data (): Data { return this.structure.data }\n get atomSetDict () { return this.structure.atomSetDict }\n get biomolDict (): {[k: string]: Assembly} { return this.structure.biomolDict }\n get entityList (): Entity[] { return this.structure.entityList }\n get unitcell (): Unitcell|undefined { return this.structure.unitcell }\n get frames () { return this.structure.frames }\n get boxes () { return this.structure.boxes }\n get validation (): Validation|undefined { return this.structure.validation }\n get bondStore () { return this.structure.bondStore }\n get backboneBondStore () { return this.structure.backboneBondStore }\n get rungBondStore (): BondStore { return this.structure.rungBondStore }\n get atomStore (): AtomStore { return this.structure.atomStore }\n get residueStore (): ResidueStore { return this.structure.residueStore }\n get chainStore (): ChainStore { return this.structure.chainStore }\n get modelStore (): ModelStore { return this.structure.modelStore }\n get atomMap (): AtomMap { return this.structure.atomMap }\n get residueMap (): ResidueMap { return this.structure.residueMap }\n get bondHash (): BondHash|undefined { return this.structure.bondHash }\n get spatialHash (): SpatialHash|undefined { return this.structure.spatialHash }\n\n get _hasCoords () { return this.structure._hasCoords }\n set _hasCoords (value) { this.structure._hasCoords = value }\n\n /**\n * Updates atomSet, bondSet, atomSetCache, atomCount, bondCount, boundingBox, center.\n * @emits {Structure.signals.refreshed} when refreshed\n * @return {undefined}\n */\n refresh () {\n if (Debug) Log.time('StructureView.refresh')\n\n this.atomSetCache = {}\n const structure = this.structure\n\n if (this.selection.isAllSelection() &&\n structure !== this && structure.atomSet && structure.bondSet\n ) {\n this.atomSet = structure.atomSet.clone()\n this.bondSet = structure.bondSet.clone()\n\n for (let name in this.atomSetDict) {\n const atomSet = this.atomSetDict[ name ]\n this.atomSetCache[ '__' + name ] = atomSet.clone()\n }\n\n this.atomCount = structure.atomCount\n this.bondCount = structure.bondCount\n\n this.boundingBox.copy(structure.boundingBox)\n this.center.copy(structure.center)\n } else if (this.selection.isNoneSelection() &&\n structure !== this && structure.atomSet && structure.bondSet\n ) {\n this.atomSet = new BitArray(structure.atomCount)\n this.bondSet = new BitArray(structure.bondCount)\n\n for (let name in this.atomSetDict) {\n this.atomSetCache[ '__' + name ] = new BitArray(structure.atomCount)\n }\n\n this.atomCount = 0\n this.bondCount = 0\n\n this.boundingBox.makeEmpty()\n this.center.set(0, 0, 0)\n } else {\n this.atomSet = this.getAtomSet(this.selection, true)\n if (structure.atomSet) {\n this.atomSet = this.atomSet.intersection(structure.atomSet)\n }\n\n this.bondSet = this.getBondSet()\n\n for (let name in this.atomSetDict) {\n const atomSet = this.atomSetDict[ name ]\n this.atomSetCache[ '__' + name ] = atomSet.makeIntersection(this.atomSet)\n }\n\n this.atomCount = this.atomSet.getSize()\n this.bondCount = this.bondSet.getSize()\n\n this.boundingBox = this.getBoundingBox()\n this.center = this.boundingBox.getCenter(new Vector3())\n }\n\n if (Debug) Log.timeEnd('StructureView.refresh')\n\n this.signals.refreshed.dispatch()\n }\n\n //\n\n setSelection (selection: Selection) {\n this.selection = selection\n\n this.refresh()\n }\n\n getSelection (selection?: Selection) {\n const seleList: string[] = []\n\n if (selection && selection.string) {\n seleList.push(selection.string)\n }\n\n const parentSelection = this.structure.getSelection()\n if (parentSelection && parentSelection.string) {\n seleList.push(parentSelection.string)\n }\n\n if (this.selection && this.selection.string) {\n seleList.push(this.selection.string)\n }\n\n let sele = ''\n if (seleList.length > 0) {\n sele = `( ${seleList.join(' ) AND ( ')} )`\n }\n\n return new Selection(sele)\n }\n\n getStructure () {\n return this.structure.getStructure()\n }\n\n //\n\n eachBond (callback: (entity: BondProxy) => any, selection?: Selection) {\n this.structure.eachBond(callback, this.getSelection(selection))\n }\n\n eachAtom (callback: (entity: AtomProxy) => any, selection?: Selection) {\n const ap = this.getAtomProxy()\n const atomSet = this.getAtomSet(selection)\n const n = this.atomStore.count\n\n if (atomSet.getSize() < n) {\n atomSet.forEach(function (index) {\n ap.index = index\n callback(ap)\n })\n } else {\n for (let i = 0; i < n; ++i) {\n ap.index = i\n callback(ap)\n }\n }\n }\n\n eachResidue (callback: (entity: ResidueProxy) => any, selection?: Selection) {\n this.structure.eachResidue(callback, this.getSelection(selection))\n }\n\n /**\n * Not implemented\n * @alias StructureView#eachResidueN\n * @return {undefined}\n */\n eachResidueN (n: number, callback: (entity: ResidueProxy) => any) {\n console.error('StructureView.eachResidueN() not implemented')\n }\n\n eachChain (callback: (entity: ChainProxy) => any, selection?: Selection) {\n this.structure.eachChain(callback, this.getSelection(selection))\n }\n\n eachModel (callback: (entity: ModelProxy) => any, selection?: Selection) {\n this.structure.eachModel(callback, this.getSelection(selection))\n }\n\n //\n\n getAtomSet (selection?: boolean|Selection|BitArray, ignoreView = false) {\n let atomSet = this.structure.getAtomSet(selection)\n if (!ignoreView && this.atomSet) {\n atomSet = atomSet.makeIntersection(this.atomSet)\n }\n\n return atomSet\n }\n\n //\n\n getAtomIndices (selection?: Selection) {\n return this.structure.getAtomIndices(this.getSelection(selection))\n }\n\n refreshPosition () {\n return this.structure.refreshPosition()\n }\n\n //\n\n dispose () {\n if (this.selection) {\n this.selection.signals.stringChanged.remove(this.refresh, this)\n }\n\n this.structure.signals.refreshed.remove(this.refresh, this)\n\n this.structure = new Structure() // delete old data\n\n delete this.atomSet\n delete this.bondSet\n\n }\n}\n\nexport default StructureView\n","/**\n * @file Alignment\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log } from '../globals'\n\n// const nucleotides = 'ACTG';\nconst aminoacidsX = 'ACDEFGHIKLMNPQRSTVWY'\nconst aminoacids = 'ARNDCQEGHILKMFPSTWYVBZ?'\n\nconst blosum62x = [\n [4, 0, -2, -1, -2, 0, -2, -1, -1, -1, -1, -2, -1, -1, -1, 1, 0, 0, -3, -2], // A\n [0, 9, -3, -4, -2, -3, -3, -1, -3, -1, -1, -3, -3, -3, -3, -1, -1, -1, -2, -2], // C\n [-2, -3, 6, 2, -3, -1, -1, -3, -1, -4, -3, 1, -1, 0, -2, 0, -1, -3, -4, -3], // D\n [-1, -4, 2, 5, -3, -2, 0, -3, 1, -3, -2, 0, -1, 2, 0, 0, -1, -2, -3, -2], // E\n [-2, -2, -3, -3, 6, -3, -1, 0, -3, 0, 0, -3, -4, -3, -3, -2, -2, -1, 1, 3], // F\n [0, -3, -1, -2, -3, 6, -2, -4, -2, -4, -3, 0, -2, -2, -2, 0, -2, -3, -2, -3], // G\n [-2, -3, -1, 0, -1, -2, 8, -3, -1, -3, -2, 1, -2, 0, 0, -1, -2, -3, -2, 2], // H\n [-1, -1, -3, -3, 0, -4, -3, 4, -3, 2, 1, -3, -3, -3, -3, -2, -1, 3, -3, -1], // I\n [-1, -3, -1, 1, -3, -2, -1, -3, 5, -2, -1, 0, -1, 1, 2, 0, -1, -2, -3, -2], // K\n [-1, -1, -4, -3, 0, -4, -3, 2, -2, 4, 2, -3, -3, -2, -2, -2, -1, 1, -2, -1], // L\n [-1, -1, -3, -2, 0, -3, -2, 1, -1, 2, 5, -2, -2, 0, -1, -1, -1, 1, -1, -1], // M\n [-2, -3, 1, 0, -3, 0, 1, -3, 0, -3, -2, 6, -2, 0, 0, 1, 0, -3, -4, -2], // N\n [-1, -3, -1, -1, -4, -2, -2, -3, -1, -3, -2, -2, 7, -1, -2, -1, -1, -2, -4, -3], // P\n [-1, -3, 0, 2, -3, -2, 0, -3, 1, -2, 0, 0, -1, 5, 1, 0, -1, -2, -2, -1], // Q\n [-1, -3, -2, 0, -3, -2, 0, -3, 2, -2, -1, 0, -2, 1, 5, -1, -1, -3, -3, -2], // R\n [1, -1, 0, 0, -2, 0, -1, -2, 0, -2, -1, 1, -1, 0, -1, 4, 1, -2, -3, -2], // S\n [0, -1, -1, -1, -2, -2, -2, -1, -1, -1, -1, 0, -1, -1, -1, 1, 5, 0, -2, -2], // T\n [0, -1, -3, -2, -1, -3, -3, 3, -2, 1, 1, -3, -2, -2, -3, -2, 0, 4, -3, -1], // V\n [-3, -2, -4, -3, 1, -2, -2, -3, -3, -2, -1, -4, -4, -2, -3, -3, -2, -3, 11, 2], // W\n [-2, -2, -3, -2, 3, -3, 2, -1, -2, -1, -1, -2, -3, -1, -2, -2, -2, -1, 2, 7] // Y\n]\n\nconst blosum62 = [\n // A R N D C Q E G H I L K M F P S T W Y V B Z X\n [4, -1, -2, -2, 0, -1, -1, 0, -2, -1, -1, -1, -1, -2, -1, 1, 0, -3, -2, 0, -2, -1, 0], // A\n [-1, 5, 0, -2, -3, 1, 0, -2, 0, -3, -2, 2, -1, -3, -2, -1, -1, -3, -2, -3, -1, 0, -1], // R\n [-2, 0, 6, 1, -3, 0, 0, 0, 1, -3, -3, 0, -2, -3, -2, 1, 0, -4, -2, -3, 3, 0, -1], // N\n [-2, -2, 1, 6, -3, 0, 2, -1, -1, -3, -4, -1, -3, -3, -1, 0, -1, -4, -3, -3, 4, 1, -1], // D\n [0, -3, -3, -3, 9, -3, -4, -3, -3, -1, -1, -3, -1, -2, -3, -1, -1, -2, -2, -1, -3, -3, -2], // C\n [-1, 1, 0, 0, -3, 5, 2, -2, 0, -3, -2, 1, 0, -3, -1, 0, -1, -2, -1, -2, 0, 3, -1], // Q\n [-1, 0, 0, 2, -4, 2, 5, -2, 0, -3, -3, 1, -2, -3, -1, 0, -1, -3, -2, -2, 1, 4, -1], // E\n [0, -2, 0, -1, -3, -2, -2, 6, -2, -4, -4, -2, -3, -3, -2, 0, -2, -2, -3, -3, -1, -2, -1], // G\n [-2, 0, 1, -1, -3, 0, 0, -2, 8, -3, -3, -1, -2, -1, -2, -1, -2, -2, 2, -3, 0, 0, -1], // H\n [-1, -3, -3, -3, -1, -3, -3, -4, -3, 4, 2, -3, 1, 0, -3, -2, -1, -3, -1, 3, -3, -3, -1], // I\n [-1, -2, -3, -4, -1, -2, -3, -4, -3, 2, 4, -2, 2, 0, -3, -2, -1, -2, -1, 1, -4, -3, -1], // L\n [-1, 2, 0, -1, -3, 1, 1, -2, -1, -3, -2, 5, -1, -3, -1, 0, -1, -3, -2, -2, 0, 1, -1], // K\n [-1, -1, -2, -3, -1, 0, -2, -3, -2, 1, 2, -1, 5, 0, -2, -1, -1, -1, -1, 1, -3, -1, -1], // M\n [-2, -3, -3, -3, -2, -3, -3, -3, -1, 0, 0, -3, 0, 6, -4, -2, -2, 1, 3, -1, -3, -3, -1], // F\n [-1, -2, -2, -1, -3, -1, -1, -2, -2, -3, -3, -1, -2, -4, 7, -1, -1, -4, -3, -2, -2, -1, -2], // P\n [1, -1, 1, 0, -1, 0, 0, 0, -1, -2, -2, 0, -1, -2, -1, 4, 1, -3, -2, -2, 0, 0, 0], // S\n [0, -1, 0, -1, -1, -1, -1, -2, -2, -1, -1, -1, -1, -2, -1, 1, 5, -2, -2, 0, -1, -1, 0], // T\n [-3, -3, -4, -4, -2, -2, -3, -2, -2, -3, -2, -3, -1, 1, -4, -3, -2, 11, 2, -3, -4, -3, -2], // W\n [-2, -2, -2, -3, -2, -1, -2, -3, 2, -1, -1, -2, -1, 3, -3, -2, -2, 2, 7, -1, -3, -2, -1], // Y\n [0, -3, -3, -3, -1, -2, -2, -3, -3, 3, 1, -2, 1, -1, -2, -2, 0, -3, -1, 4, -3, -2, -1], // V\n [-2, -1, 3, 4, -3, 0, 1, -1, 0, -3, -4, 0, -3, -3, -2, 0, -1, -4, -3, -3, 4, 1, -1], // B\n [-1, 0, 0, 1, -3, 3, 4, -2, 0, -3, -3, 1, -1, -3, -1, 0, -1, -3, -2, -2, 1, 4, -1], // Z\n [0, -1, -1, -1, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, 0, 0, -2, -1, -1, -1, -1, -1] // X\n]\n\nfunction prepareMatrix (cellNames: string, mat: number[][]) {\n let j: number\n let i = 0\n const matDict: { [k: string]: { [k: string]: number } } = {}\n mat.forEach(function (row) {\n j = 0\n const rowDict: { [k: string]: number } = {}\n row.forEach(function (elm) {\n rowDict[ cellNames[ j++ ] ] = elm\n })\n matDict[ cellNames[ i++ ] ] = rowDict\n })\n return matDict\n}\n\nconst SubstitutionMatrices = (function () {\n return {\n blosum62: prepareMatrix(aminoacids, blosum62),\n blosum62x: prepareMatrix(aminoacidsX, blosum62x)\n }\n}())\nexport type SubstitutionMatrix = ''|'blosum62'|'blosum62x'\n\nclass Alignment {\n substMatrix: { [k: string]: { [k: string]: number } }\n\n n: number\n m: number\n score?: number\n ali: string\n\n S: number[][]\n V: number[][]\n H: number[][]\n\n ali1: string\n ali2: string\n\n constructor (readonly seq1: string, readonly seq2: string, readonly gapPenalty = -10, readonly gapExtensionPenalty = -1, substMatrix: SubstitutionMatrix = 'blosum62') {\n // TODO try encoding seqs as integers and use array subst matrix, maybe faster\n\n if (substMatrix) {\n this.substMatrix = SubstitutionMatrices[ substMatrix ]\n }\n }\n\n initMatrices () {\n this.n = this.seq1.length\n this.m = this.seq2.length\n\n // Log.log(this.n, this.m);\n\n this.score = undefined\n this.ali = ''\n\n this.S = []\n this.V = []\n this.H = []\n\n for (let i = 0; i <= this.n; ++i) {\n this.S[ i ] = []\n this.V[ i ] = []\n this.H[ i ] = []\n\n for (let j = 0; j <= this.m; ++j) {\n this.S[ i ][ j ] = 0\n this.V[ i ][ j ] = 0\n this.H[ i ][ j ] = 0\n }\n }\n\n for (let i = 0; i <= this.n; ++i) {\n this.S[ i ][ 0 ] = this.gap(0)\n this.H[ i ][ 0 ] = -Infinity\n }\n\n for (let j = 0; j <= this.m; ++j) {\n this.S[ 0 ][ j ] = this.gap(0)\n this.V[ 0 ][ j ] = -Infinity\n }\n\n this.S[ 0 ][ 0 ] = 0\n\n // Log.log(this.S, this.V, this.H);\n }\n\n gap (len: number) {\n return this.gapPenalty + len * this.gapExtensionPenalty\n }\n\n makeScoreFn () {\n const seq1 = this.seq1\n const seq2 = this.seq2\n\n const substMatrix = this.substMatrix\n\n if (substMatrix) {\n return function score (i: number, j: number) {\n const c1 = seq1[ i ]\n const c2 = seq2[ j ]\n\n try {\n return substMatrix[ c1 ][ c2 ]\n } catch (e) {\n return -4\n }\n }\n } else {\n Log.warn('Alignment: no subst matrix')\n\n return function scoreNoSubstMat (i: number, j: number) {\n const c1 = seq1[ i ]\n const c2 = seq2[ j ]\n\n return c1 === c2 ? 5 : -3\n }\n }\n }\n\n calc () {\n if (Debug) Log.time('Alignment.calc')\n\n this.initMatrices()\n\n const gap0 = this.gap(0)\n const scoreFn = this.makeScoreFn()\n const gapExtensionPenalty = this.gapExtensionPenalty\n\n const V = this.V\n const H = this.H\n const S = this.S\n\n const n = this.n\n const m = this.m\n\n let Vi1, Si1, Vi, Hi, Si\n\n for (let i = 1; i <= n; ++i) {\n Si1 = S[ i - 1 ]\n Vi1 = V[ i - 1 ]\n\n Vi = V[ i ]\n Hi = H[ i ]\n Si = S[ i ]\n\n for (let j = 1; j <= m; ++j) {\n Vi[j] = Math.max(\n Si1[ j ] + gap0,\n Vi1[ j ] + gapExtensionPenalty\n )\n\n Hi[j] = Math.max(\n Si[ j - 1 ] + gap0,\n Hi[ j - 1 ] + gapExtensionPenalty\n )\n\n Si[j] = Math.max(\n Si1[ j - 1 ] + scoreFn(i - 1, j - 1), // match\n Vi[ j ], // del\n Hi[ j ] // ins\n )\n }\n }\n\n if (Debug) Log.timeEnd('Alignment.calc')\n\n if (Debug) Log.log(this.S, this.V, this.H)\n }\n\n trace () {\n if (Debug) Log.time('Alignment.trace')\n\n this.ali1 = ''\n this.ali2 = ''\n\n const scoreFn = this.makeScoreFn()\n\n let i = this.n\n let j = this.m\n let mat\n\n if (this.S[i][j] >= this.V[i][j]) {\n mat = 'S'\n this.score = this.S[i][j]\n } else if (this.V[i][j] >= this.H[i][j]) {\n mat = 'V'\n this.score = this.V[i][j]\n } else {\n mat = 'H'\n this.score = this.H[i][j]\n }\n\n if (Debug) Log.log('Alignment: SCORE', this.score)\n if (Debug) Log.log('Alignment: S, V, H', this.S[i][j], this.V[i][j], this.H[i][j])\n\n while (i > 0 && j > 0) {\n if (mat === 'S') {\n if (this.S[i][j] === this.S[i - 1][j - 1] + scoreFn(i - 1, j - 1)) {\n this.ali1 = this.seq1[i - 1] + this.ali1\n this.ali2 = this.seq2[j - 1] + this.ali2\n --i\n --j\n mat = 'S'\n } else if (this.S[i][j] === this.V[i][j]) {\n mat = 'V'\n } else if (this.S[i][j] === this.H[i][j]) {\n mat = 'H'\n } else {\n // Log.debug('Alignment: S');\n --i\n --j\n }\n } else if (mat === 'V') {\n if (this.V[i][j] === this.V[i - 1][j] + this.gapExtensionPenalty) {\n this.ali1 = this.seq1[i - 1] + this.ali1\n this.ali2 = '-' + this.ali2\n --i\n mat = 'V'\n } else if (this.V[i][j] === this.S[i - 1][j] + this.gap(0)) {\n this.ali1 = this.seq1[i - 1] + this.ali1\n this.ali2 = '-' + this.ali2\n --i\n mat = 'S'\n } else {\n // Log.debug('Alignment: V');\n --i\n }\n } else if (mat === 'H') {\n if (this.H[i][j] === this.H[i][j - 1] + this.gapExtensionPenalty) {\n this.ali1 = '-' + this.ali1\n this.ali2 = this.seq2[j - 1] + this.ali2\n --j\n mat = 'H'\n } else if (this.H[i][j] === this.S[i][j - 1] + this.gap(0)) {\n this.ali1 = '-' + this.ali1\n this.ali2 = this.seq2[j - 1] + this.ali2\n --j\n mat = 'S'\n } else {\n // Log.debug('Alignment: H');\n --j\n }\n } else {\n Log.error('Alignment: no matrix')\n }\n }\n\n while (i > 0) {\n this.ali1 = this.seq1[ i - 1 ] + this.ali1\n this.ali2 = '-' + this.ali2\n --i\n }\n\n while (j > 0) {\n this.ali1 = '-' + this.ali1\n this.ali2 = this.seq2[ j - 1 ] + this.ali2\n --j\n }\n\n if (Debug) Log.timeEnd('Alignment.trace')\n\n if (Debug) Log.log([this.ali1, this.ali2])\n }\n}\n\nexport default Alignment\n","/**\n * @file Align Utils\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\nimport Alignment from './alignment'\nimport Superposition from './superposition'\n\n/**\n * Perform structural superposition of two structures,\n * optionally guided by a sequence alignment\n * @param {Structure|StructureView} s1 - structure 1 which is superposed onto structure 2\n * @param {Structure|StructureView} s2 - structure 2 onto which structure 1 is superposed\n * @param {Boolean} [align] - guide the superposition by a sequence alignment\n * @param {String} [sele1] - selection string for structure 1\n * @param {String} [sele2] - selection string for structure 2\n * @return {undefined}\n */\nfunction superpose (s1: Structure, s2: Structure, align = false, sele1 = '', sele2 = '') {\n let i: number\n let j: number\n let n: number\n let atoms1\n let atoms2\n\n if (align) {\n let _s1 = s1\n let _s2 = s2\n\n if (sele1 && sele2) {\n _s1 = s1.getView(new Selection(sele1))\n _s2 = s2.getView(new Selection(sele2))\n }\n\n const seq1 = _s1.getSequence()\n const seq2 = _s2.getSequence()\n\n // Log.log( seq1.join(\"\") );\n // Log.log( seq2.join(\"\") );\n\n const ali = new Alignment(seq1.join(''), seq2.join(''))\n\n ali.calc()\n ali.trace()\n\n // Log.log( \"superpose alignment score\", ali.score );\n\n // Log.log( ali.ali1 );\n // Log.log( ali.ali2 );\n\n let _i, _j\n i = 0\n j = 0\n n = ali.ali1.length\n const aliIdx1: boolean[] = []\n const aliIdx2: boolean[] = []\n\n for (let l = 0; l < n; ++l) {\n const x = ali.ali1[ l ]\n const y = ali.ali2[ l ]\n\n _i = 0\n _j = 0\n\n if (x === '-') {\n aliIdx2[ j ] = false\n } else {\n aliIdx2[ j ] = true\n _i = 1\n }\n\n if (y === '-') {\n aliIdx1[ i ] = false\n } else {\n aliIdx1[ i ] = true\n _j = 1\n }\n\n i += _i\n j += _j\n }\n\n // Log.log( i, j );\n\n // Log.log( aliIdx1 );\n // Log.log( aliIdx2 );\n\n const _atoms1: number[] = []\n const _atoms2: number[] = []\n const ap1 = _s1.getAtomProxy()\n const ap2 = _s2.getAtomProxy()\n\n i = 0\n _s1.eachResidue(function (r) {\n if (r.traceAtomIndex === undefined ||\n r.traceAtomIndex !== r.getAtomIndexByName('CA')) return\n\n if (aliIdx1[ i ]) {\n ap1.index = r.getAtomIndexByName('CA')! // TODO\n _atoms1.push(ap1.x, ap1.y, ap1.z)\n }\n i += 1\n })\n\n i = 0\n _s2.eachResidue(function (r) {\n if (r.traceAtomIndex === undefined ||\n r.traceAtomIndex !== r.getAtomIndexByName('CA')) return\n\n if (aliIdx2[ i ]) {\n ap2.index = r.getAtomIndexByName('CA')! // TODO\n _atoms2.push(ap2.x, ap2.y, ap2.z)\n }\n i += 1\n })\n\n atoms1 = new Float32Array(_atoms1)\n atoms2 = new Float32Array(_atoms2)\n } else {\n const sviewCa1 = s1.getView(new Selection(`${sele1} and .CA`))\n const sviewCa2 = s2.getView(new Selection(`${sele2} and .CA`))\n\n atoms1 = sviewCa1\n atoms2 = sviewCa2\n }\n\n const superpose = new Superposition(atoms1, atoms2)\n const result = superpose.transform(s1)\n s1.refreshPosition()\n return result\n}\n\nexport {\n superpose\n}\n","/**\n * @file Sturucture Component\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { ComponentRegistry, MeasurementDefaultParams } from '../globals'\nimport {\n defaults, /*deepEqual, */createRingBuffer, RingBuffer, createSimpleDict, SimpleDict\n} from '../utils'\nimport { smoothstep } from '../math/math-utils'\nimport Component, { ComponentSignals, ComponentDefaultParameters } from './component'\nimport RepresentationCollection from './representation-collection'\nimport TrajectoryElement from './trajectory-element'\nimport RepresentationElement from './representation-element'\nimport { makeTrajectory } from '../trajectory/trajectory-utils'\nimport { TrajectoryParameters } from '../trajectory/trajectory'\nimport Selection from '../selection/selection'\nimport Structure from '../structure/structure'\nimport StructureView from '../structure/structure-view'\nimport { superpose } from '../align/align-utils'\nimport Stage from '../stage/stage'\nimport StructureRepresentation, { StructureRepresentationParameters } from '../representation/structure-representation'\nimport AtomProxy from '../proxy/atom-proxy'\nimport { Vector3, Box3 } from 'three';\nimport { AngleRepresentationParameters } from '../representation/angle-representation';\nimport { AxesRepresentationParameters } from '../representation/axes-representation';\nimport { BallAndStickRepresentationParameters } from '../representation/ballandstick-representation';\nimport { CartoonRepresentationParameters } from '../representation/cartoon-representation';\nimport { ContactRepresentationParameters } from '../representation/contact-representation';\nimport { DihedralRepresentationParameters } from '../representation/dihedral-representation';\nimport { DihedralHistogramRepresentationParameters } from '../representation/dihedral-histogram-representation';\nimport { DistanceRepresentationParameters } from '../representation/distance-representation';\nimport { HyperballRepresentationParameters } from '../representation/hyperball-representation';\nimport { LabelRepresentationParameters } from '../representation/label-representation';\nimport { LineRepresentationParameters } from '../representation/line-representation';\nimport { PointRepresentationParameters } from '../representation/point-representation';\nimport { SurfaceRepresentationParameters } from '../representation/surface-representation';\nimport { RibbonRepresentationParameters } from '../representation/ribbon-representation';\nimport { RocketRepresentationParameters } from '../representation/rocket-representation';\nimport { TraceRepresentationParameters } from '../representation/trace-representation';\nimport { UnitcellRepresentationParameters } from '../representation/unitcell-representation';\nimport { SliceRepresentationParameters } from '../representation/slice-representation'\nimport { MolecularSurfaceRepresentationParameters } from '../representation/molecularsurface-representation'\nimport { DotRepresentationParameters } from '../representation/dot-representation'\n\nexport type StructureRepresentationType = keyof StructureRepresentationParametersMap\n\ninterface StructureRepresentationParametersMap {\n 'angle': AngleRepresentationParameters,\n 'axes' : AxesRepresentationParameters,\n 'backbone': BallAndStickRepresentationParameters,\n 'ball+stick': BallAndStickRepresentationParameters,\n 'base': BallAndStickRepresentationParameters,\n 'cartoon': CartoonRepresentationParameters,\n 'contact': ContactRepresentationParameters,\n 'dihedral': DihedralRepresentationParameters,\n 'dihedral-histogram': DihedralHistogramRepresentationParameters,\n 'distance': DistanceRepresentationParameters,\n 'dot': DotRepresentationParameters,\n 'helixorient': StructureRepresentationParameters,\n 'hyperball': HyperballRepresentationParameters,\n 'label': LabelRepresentationParameters,\n 'licorice': BallAndStickRepresentationParameters,\n 'line': LineRepresentationParameters,\n 'molecularsurface': MolecularSurfaceRepresentationParameters,\n 'point': PointRepresentationParameters,\n 'ribbon': RibbonRepresentationParameters,\n 'rocket': RocketRepresentationParameters,\n 'rope': CartoonRepresentationParameters,\n 'slice': SliceRepresentationParameters,\n 'spacefill': BallAndStickRepresentationParameters,\n 'surface': SurfaceRepresentationParameters,\n 'trace': TraceRepresentationParameters,\n 'tube': CartoonRepresentationParameters,\n 'unitcell': UnitcellRepresentationParameters,\n 'validation': StructureRepresentationParameters\n}\n\nexport const StructureComponentDefaultParameters = Object.assign({\n sele: '',\n defaultAssembly: ''\n}, ComponentDefaultParameters)\nexport type StructureComponentParameters = typeof StructureComponentDefaultParameters\n\nexport interface StructureComponentSignals extends ComponentSignals {\n trajectoryAdded: Signal // when a trajectory is added\n trajectoryRemoved: Signal // when a trajectory is removed\n defaultAssemblyChanged: Signal // on default assembly change\n}\n\n/**\n * Component wrapping a {@link Structure} object\n *\n * @example\n * // get a structure component by loading a structure file into the stage\n * stage.loadFile( \"rcsb://4opj\" ).then( function( structureComponent ){\n * structureComponent.addRepresentation( \"cartoon\" );\n * structureComponent.autoView();\n * } );\n */\nclass StructureComponent extends Component {\n readonly signals: StructureComponentSignals\n readonly parameters: StructureComponentParameters\n get defaultParameters () { return StructureComponentDefaultParameters }\n\n selection: Selection\n structureView: StructureView\n readonly trajList: TrajectoryElement[] = []\n\n pickBuffer: RingBuffer\n pickDict: SimpleDict\n lastPick?: number\n\n spacefillRepresentation: RepresentationElement\n distanceRepresentation: RepresentationElement\n angleRepresentation: RepresentationElement\n dihedralRepresentation: RepresentationElement\n\n measureRepresentations: RepresentationCollection\n\n constructor (stage: Stage, readonly structure: Structure, params: Partial = {}) {\n super(stage, structure, Object.assign({ name: structure.name }, params))\n\n this.signals = Object.assign(this.signals, {\n trajectoryAdded: new Signal(),\n trajectoryRemoved: new Signal(),\n defaultAssemblyChanged: new Signal()\n })\n\n this.initSelection(this.parameters.sele)\n\n //\n\n this.pickBuffer = createRingBuffer(4)\n this.pickDict = createSimpleDict()\n\n this.spacefillRepresentation = this.addRepresentation('spacefill', {\n sele: 'none',\n opacity: MeasurementDefaultParams.opacity,\n color: MeasurementDefaultParams.color,\n disablePicking: true,\n radiusType: 'data'\n }, true)\n\n this.distanceRepresentation = this.addRepresentation(\n 'distance', MeasurementDefaultParams, true\n )\n this.angleRepresentation = this.addRepresentation(\n 'angle', MeasurementDefaultParams, true\n )\n this.dihedralRepresentation = this.addRepresentation(\n 'dihedral', MeasurementDefaultParams, true\n )\n\n this.measureRepresentations = new RepresentationCollection([\n this.spacefillRepresentation,\n this.distanceRepresentation,\n this.angleRepresentation,\n this.dihedralRepresentation\n ])\n\n //\n\n this.setDefaultAssembly(this.parameters.defaultAssembly)\n\n this.structure.signals.refreshed.add(() => {\n this.updateRepresentations({ position: true })\n })\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'structure' }\n\n /**\n * Initialize selection\n * @private\n * @param {String} sele - selection string\n * @return {undefined}\n */\n initSelection (sele: string) {\n /**\n * Selection for {@link StructureComponent#structureView}\n * @private\n * @type {Selection}\n */\n this.selection = new Selection(sele)\n\n /**\n * View on {@link StructureComponent#structure}.\n * Change its selection via {@link StructureComponent#setSelection}.\n * @type {StructureView}\n */\n this.structureView = new StructureView(\n this.structure, this.selection\n )\n\n this.selection.signals.stringChanged.add(() => {\n this.structureView.setSelection(this.selection)\n\n this.rebuildRepresentations()\n this.rebuildTrajectories()\n })\n }\n\n /**\n * Set selection of {@link StructureComponent#structureView}\n * @param {String} string - selection string\n * @return {StructureComponent} this object\n */\n setSelection (string: string) {\n this.parameters.sele = string\n this.selection.setString(string)\n return this\n }\n\n /**\n * Set the default assembly\n * @param {String} value - assembly name\n * @return {undefined}\n */\n setDefaultAssembly (value:string) {\n // filter out non-exsisting assemblies\n if (this.structure.biomolDict[value] === undefined) value = ''\n // only set default assembly when changed\n if (this.parameters.defaultAssembly !== value) {\n const reprParams = { defaultAssembly: value }\n this.reprList.forEach(repr => repr.setParameters(reprParams))\n this.measureRepresentations.setParameters(reprParams)\n this.parameters.defaultAssembly = value\n this.signals.defaultAssemblyChanged.dispatch(value)\n }\n return this\n }\n\n /**\n * Rebuild all representations\n * @return {undefined}\n */\n rebuildRepresentations () {\n this.reprList.forEach((repr: RepresentationElement) => {\n repr.build()\n })\n this.measureRepresentations.build()\n }\n\n /**\n * Rebuild all trajectories\n * @return {undefined}\n */\n rebuildTrajectories () {\n this.trajList.forEach(trajComp => {\n trajComp.trajectory.setStructure(this.structureView)\n })\n }\n\n updateRepresentations (what: any) {\n super.updateRepresentations(what)\n this.measureRepresentations.update(what)\n }\n\n /**\n * Overrides {@link Component.updateRepresentationMatrices} \n * to also update matrix for measureRepresentations \n */\n updateRepresentationMatrices () {\n super.updateRepresentationMatrices()\n this.measureRepresentations.setParameters({ matrix: this.matrix })\n }\n\n addRepresentation (\n type: K,\n params: Partial|{defaultAssembly: string} = {},\n hidden = false\n ) {\n params.defaultAssembly = this.parameters.defaultAssembly\n\n const reprComp = this._addRepresentation(type, this.structureView, params, hidden)\n if (!hidden) {\n reprComp.signals.parametersChanged.add(() => this.measureUpdate())\n }\n return reprComp\n }\n\n /**\n * Add a new trajectory component to the structure\n */\n addTrajectory (trajPath = '', params: { [k: string]: any } = {}) {\n const traj = makeTrajectory(trajPath, this.structureView, params as TrajectoryParameters)\n\n const trajComp = new TrajectoryElement(this.stage, traj, params)\n this.trajList.push(trajComp)\n this.signals.trajectoryAdded.dispatch(trajComp)\n\n return trajComp\n }\n\n removeTrajectory (traj: TrajectoryElement) {\n const idx = this.trajList.indexOf(traj)\n if (idx !== -1) {\n this.trajList.splice(idx, 1)\n }\n\n traj.dispose()\n\n this.signals.trajectoryRemoved.dispatch(traj)\n }\n\n dispose () {\n // copy via .slice because side effects may change trajList\n this.trajList.slice().forEach(traj => traj.dispose())\n\n this.trajList.length = 0\n this.structure.dispose()\n this.measureRepresentations.dispose()\n\n super.dispose()\n }\n\n /**\n * Automatically center and zoom the component\n * @param {String|Integer} [sele] - selection string or duration if integer\n * @param {Integer} [duration] - duration of the animation, defaults to 0\n * @return {undefined}\n */\n autoView (sele?: string|number, duration?: number) {\n if (typeof sele === 'number') {\n duration = sele\n sele = ''\n }\n\n this.stage.animationControls.zoomMove(\n this.getCenter(sele),\n this.getZoom(sele),\n defaults(duration, 0)\n )\n }\n\n getBoxUntransformed (sele: string): Box3 {\n let bb\n\n if (sele) {\n bb = this.structureView.getBoundingBox(new Selection(sele))\n } else {\n bb = this.structureView.boundingBox\n }\n\n return bb\n }\n\n getCenterUntransformed (sele: string): Vector3 {\n if (sele && typeof sele === 'string') {\n return this.structure.atomCenter(new Selection(sele))\n } else {\n return this.structure.center\n }\n }\n\n superpose (component: StructureComponent, align: boolean, sele1: string, sele2: string) {\n superpose(\n this.structureView, component.structureView, align, sele1, sele2\n )\n\n this.updateRepresentations({ 'position': true })\n\n return this\n }\n\n getMaxRepresentationRadius (atomIndex: number) {\n let maxRadius = 0\n const atom = this.structure.getAtomProxy(atomIndex)\n this.eachRepresentation(reprElem => {\n if (reprElem.getVisibility()) {\n const repr: StructureRepresentation = reprElem.repr as any // TODO\n maxRadius = Math.max(repr.getAtomRadius(atom), maxRadius)\n }\n })\n return maxRadius\n }\n\n measurePick (atom: AtomProxy) {\n const pickCount = this.pickBuffer.count\n\n if (this.lastPick === atom.index && pickCount >= 1) {\n if (pickCount > 1) {\n const atomList = this.pickBuffer.data\n const atomListSorted = this.pickBuffer.data.sort()\n if (this.pickDict.has(atomListSorted)) {\n this.pickDict.del(atomListSorted)\n } else {\n this.pickDict.add(atomListSorted, atomList)\n }\n if (pickCount === 2) {\n this.distanceRepresentation.setParameters({\n atomPair: this.pickDict.values.filter(l => l.length === 2)\n })\n } else if (pickCount === 3) {\n this.angleRepresentation.setParameters({\n atomTriple: this.pickDict.values.filter(l => l.length === 3)\n })\n } else if (pickCount === 4) {\n this.dihedralRepresentation.setParameters({\n atomQuad: this.pickDict.values.filter(l => l.length === 4)\n })\n }\n }\n this.pickBuffer.clear()\n this.lastPick = undefined\n } else {\n if (!this.pickBuffer.has(atom.index)) {\n this.pickBuffer.push(atom.index)\n }\n this.lastPick = atom.index\n }\n\n this.measureUpdate()\n }\n\n measureClear () {\n this.pickBuffer.clear()\n this.lastPick = undefined\n this.spacefillRepresentation.setSelection('none')\n }\n\n measureBuild () {\n const md = this.measureData()\n this.distanceRepresentation.setParameters({ atomPair: md.distance })\n this.angleRepresentation.setParameters({ atomTriple: md.angle })\n this.dihedralRepresentation.setParameters({ atomQuad: md.dihedral })\n }\n\n measureUpdate () {\n const pickData = this.pickBuffer.data\n const radiusData: { [k: number]: number } = {}\n pickData.forEach(ai => {\n const r = Math.max(0.1, this.getMaxRepresentationRadius(ai))\n radiusData[ ai ] = r * (2.3 - smoothstep(0.1, 2, r))\n })\n this.spacefillRepresentation.setSelection(\n pickData.length ? ( '@' + pickData.join(',') ) : 'none'\n )\n if (pickData.length)\n this.spacefillRepresentation.setParameters({ radiusData })\n }\n\n measureData () {\n const pv = this.pickDict.values\n return {\n distance: pv.filter(l => l.length === 2),\n angle: pv.filter(l => l.length === 3),\n dihedral: pv.filter(l => l.length === 4)\n }\n }\n\n /**\n * Remove all measurements, optionally limit to distance, angle or dihedral\n */\n removeAllMeasurements (type?: MeasurementFlags) {\n const pd = this.pickDict\n const pv = pd.values\n const remove = function (len: number) {\n pv.filter(l => l.length === len).forEach(l => pd.del(l.slice().sort()))\n }\n if (!type || type & MeasurementFlags.Distance) remove(2)\n if (!type || type & MeasurementFlags.Angle) remove(3)\n if (!type || type & MeasurementFlags.Dihedral) remove(4)\n this.measureBuild()\n }\n\n /**\n * Remove a measurement given as a pair, triple, quad of atom indices\n */\n removeMeasurement (atomList: number[]) {\n this.pickDict.del(atomList.slice().sort())\n this.measureBuild()\n }\n\n /**\n * Add a measurement given as a pair, triple, quad of atom indices\n */\n addMeasurement (atomList: number[]) {\n if (atomList.length < 2 || atomList.length > 4) return\n const atomListSorted = atomList.slice().sort()\n if (!this.pickDict.has(atomListSorted)) {\n this.pickDict.add(atomListSorted, atomList)\n }\n this.measureBuild()\n }\n}\n\nexport const enum MeasurementFlags {\n Distance = 0x1,\n Angle = 0x2,\n Dihedral = 0x4\n}\n\nComponentRegistry.add('structure', StructureComponent)\nComponentRegistry.add('structureview', StructureComponent)\n\nexport default StructureComponent\n","/**\n * @file Trajectory Utils\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Frames from './frames'\nimport { TrajectoryParameters } from './trajectory'\nimport FramesTrajectory from './frames-trajectory'\nimport StructureTrajectory from './structure-trajectory'\nimport RemoteTrajectory from './remote-trajectory'\nimport CallbackTrajectory from './callback-trajectory'\n\nexport function makeTrajectory (trajSrc: string|Frames, structure: Structure, params: TrajectoryParameters) {\n let traj\n\n if (trajSrc && trajSrc instanceof Frames) {\n traj = new FramesTrajectory(trajSrc, structure, params)\n } else if (!trajSrc && structure.frames) {\n traj = new StructureTrajectory(trajSrc, structure, params)\n } else if (trajSrc && typeof trajSrc === 'function') {\n traj = new CallbackTrajectory(trajSrc, structure, params)\n } else {\n traj = new RemoteTrajectory(trajSrc, structure, params)\n }\n\n return traj\n}\n\n","/**\n * @file Surface Component\n * @author Alexander Rose \n * @private\n */\n\nimport { ComponentRegistry } from '../globals'\nimport Component, { ComponentParameters } from './component'\nimport Stage from '../stage/stage'\nimport Surface from '../surface/surface'\nimport { Vector3, Box3 } from 'three';\nimport RepresentationElement from './representation-element';\n\nexport type SurfaceRepresentationType = 'surface'|'dot'\n\n/**\n * Component wrapping a {@link Surface} object\n *\n * @example\n * // get a surface component by loading a surface file into the stage\n * stage.loadFile( \"url/for/surface\" ).then( function( surfaceComponent ){\n * surfaceComponent.addRepresentation( \"surface\" );\n * surfaceComponent.autoView();\n * } );\n */\nclass SurfaceComponent extends Component {\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {Surface} surface - surface object to wrap\n * @param {ComponentParameters} params - component parameters\n */\n constructor (stage: Stage, readonly surface: Surface, params: Partial = {}) {\n super(stage, surface, Object.assign({ name: surface.name }, params))\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'surface' }\n\n /**\n * Add a new surface representation to the component\n * @param {String} type - the name of the representation, one of:\n * surface, dot.\n * @param {SurfaceRepresentationParameters} params - representation parameters\n * @return {RepresentationComponent} the created representation wrapped into\n * a representation component object\n */\n addRepresentation (type: SurfaceRepresentationType, params: { [k: string]: any } = {}): RepresentationElement {\n return this._addRepresentation(type, this.surface, params)\n }\n\n getBoxUntransformed (): Box3 {\n return this.surface.boundingBox\n }\n\n getCenterUntransformed (): Vector3 {\n return this.surface.center\n }\n\n dispose () {\n this.surface.dispose()\n super.dispose()\n }\n}\n\nComponentRegistry.add('surface', SurfaceComponent)\n\nexport default SurfaceComponent\n","/**\n * @file Volume Component\n * @author Alexander Rose \n * @private\n */\n\nimport { ComponentRegistry } from '../globals'\nimport Component, { ComponentParameters } from './component'\nimport Stage from '../stage/stage'\nimport Volume from '../surface/volume'\nimport { Box3, Vector3 } from 'three';\nimport RepresentationElement from './representation-element';\n\nexport type VolumeRepresentationType = 'surface'|'slice'|'dot'\n\n/**\n * Component wrapping a {@link Volume} object\n *\n * @example\n * // get a volume component by loading a volume file into the stage\n * stage.loadFile( \"url/for/volume\" ).then(function(volumeComponent){\n * volumeComponent.addRepresentation('surface');\n * volumeComponent.autoView();\n * });\n */\nclass VolumeComponent extends Component {\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {Volume} volume - volume object to wrap\n * @param {ComponentParameters} params - component parameters\n */\n constructor (stage: Stage, readonly volume: Volume, params: Partial = {}) {\n super(stage, volume, Object.assign({ name: volume.name }, params))\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'volume' }\n\n /**\n * Add a new volume representation to the component\n */\n addRepresentation (type: VolumeRepresentationType, params: { [k: string]: any } = {}): RepresentationElement {\n return this._addRepresentation(type, this.volume, params)\n }\n\n getBoxUntransformed (): Box3 {\n return this.volume.boundingBox\n }\n\n getCenterUntransformed (): Vector3 {\n return this.volume.center\n }\n\n dispose () {\n this.volume.dispose()\n\n super.dispose()\n }\n}\n\nComponentRegistry.add('volume', VolumeComponent)\n\nexport default VolumeComponent\n","/**\n * @file Component Collection\n * @author Alexander Rose \n * @private\n */\n\nimport Component from './component'\nimport Collection from './collection'\n\nclass ComponentCollection extends Collection {\n addRepresentation (name: string, params: any) {\n \treturn this.forEach((comp) => comp.addRepresentation(name, params))\n }\n\n autoView (duration: number) {\n return this.forEach((comp) => comp.autoView(duration))\n }\n}\n\nexport default ComponentCollection\n","/**\n * @file Stage\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3 } from 'three'\nimport { Signal } from 'signals'\n\nimport {\n Debug, Log, Mobile, ComponentRegistry, ParserRegistry\n} from '../globals'\nimport { defaults, createParams, updateParams } from '../utils'\nimport { degToRad, clamp, pclamp } from '../math/math-utils'\nimport Counter from '../utils/counter'\nimport Viewer from '../viewer/viewer'\nimport { ImageParameters } from '../viewer/viewer-utils'\nimport MouseObserver from './mouse-observer'\n\nimport TrackballControls from '../controls/trackball-controls'\nimport PickingControls from '../controls/picking-controls'\nimport ViewerControls from '../controls/viewer-controls'\nimport AnimationControls from '../controls/animation-controls'\nimport MouseControls, { MouseControlPreset } from '../controls/mouse-controls'\nimport KeyControls from '../controls/key-controls'\n\nimport PickingBehavior from './picking-behavior'\nimport MouseBehavior from './mouse-behavior'\nimport AnimationBehavior from './animation-behavior'\nimport KeyBehavior from './key-behavior'\n\nimport Component, { ComponentParameters } from '../component/component'\nimport RepresentationElement from '../component/representation-element'\nimport StructureComponent from '../component/structure-component'\nimport SurfaceComponent from '../component/surface-component'\nimport VolumeComponent from '../component/volume-component'\nimport ComponentCollection from '../component/component-collection'\nimport RepresentationCollection from '../component/representation-collection'\nimport { autoLoad, getFileInfo, LoaderParameters } from '../loader/loader-utils'\nimport { ParserParams } from '../loader/parser-loader'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Animation from '../animation/animation'\nimport Selection from '../selection/selection'\n\nimport Structure from '../structure/structure'\nimport Surface from '../surface/surface'\nimport Volume from '../surface/volume'\nimport Shape from '../geometry/shape'\nimport Script from '../script'\n\nfunction matchName (name: string|RegExp, object: { name: string }) {\n if (name instanceof RegExp) {\n return object.name.match(name) !== null\n } else {\n return object.name === name\n }\n}\n\nconst tmpZoomVector = new Vector3()\n\ndeclare global {\n interface Document {\n mozFullScreen: boolean\n mozFullScreenEnabled: boolean\n mozFullScreenElement: Element\n mozCancelFullScreen(): void\n\n msFullscreenEnabled: boolean\n msFullscreenElement: Element\n msExitFullscreen(): void\n }\n\n interface Element {\n mozRequestFullScreen(): void\n msRequestFullscreen(): void\n }\n}\n\n/**\n * Stage parameter object.\n * @typedef {Object} StageParameters - stage parameters\n * @property {Color} backgroundColor - background color\n * @property {Integer} sampleLevel - sampling level for antialiasing, between -1 and 5;\n * -1: no sampling, 0: only sampling when not moving\n * @property {Boolean} workerDefault - default value for useWorker parameter of representations\n * @property {Float} rotateSpeed - camera-controls rotation speed, between 0 and 10\n * @property {Float} zoomSpeed - camera-controls zoom speed, between 0 and 10\n * @property {Float} panSpeed - camera-controls pan speed, between 0 and 10\n * @property {Float} clipNear - position of camera near/front clipping plane\n * in percent of scene bounding box\n * @property {Float} clipFar - position of camera far/back clipping plane\n * in percent of scene bounding box\n * @property {Float} clipDist - camera clipping distance in Angstrom\n * @property {String} clipMode - how to interpret clipNear/Far and fogNear/Far values: \"scene\" for scene-relative, \"camera\" for camera-relative\n * @property {String} clipScale - \"relative\" or \"absolute\": interpret clipNear/Far and fogNear/Far as percentage of bounding box or absolute Angstroms (ignored when clipMode==camera)\n * @property {Float} fogNear - position of the start of the fog effect\n * in percent of scene bounding box\n * @property {Float} fogFar - position where the fog is in full effect\n * in percent of scene bounding box\n * @property {String} cameraType - type of camera, either 'persepective' or 'orthographic'\n * @property {Float} cameraFov - perspective camera field of view in degree, between 15 and 120\n * @property {Float} cameraEyeSep - stereo camera eye seperation\n * @property {Color} lightColor - point light color\n * @property {Float} lightIntensity - point light intensity\n * @property {Color} ambientColor - ambient light color\n * @property {Float} ambientIntensity - ambient light intensity\n * @property {Integer} hoverTimeout - timeout for hovering\n */\n\nexport interface StageSignals {\n parametersChanged: Signal\n fullscreenChanged: Signal\n componentAdded: Signal\n componentRemoved: Signal\n clicked: Signal\n hovered: Signal\n}\n\nexport type RenderQualityType = 'auto'|'low'|'medium'|'high'\n\nexport const StageDefaultParameters = {\n impostor: true,\n quality: 'medium' as RenderQualityType,\n workerDefault: true,\n sampleLevel: 0,\n backgroundColor: 'black' as string|number,\n rotateSpeed: 2.0,\n zoomSpeed: 1.2,\n panSpeed: 1.0,\n clipNear: 0,\n clipFar: 100,\n clipDist: 10,\n clipMode: 'scene',\n clipScale: 'relative',\n fogNear: 50,\n fogFar: 100,\n cameraFov: 40,\n cameraEyeSep: 0.3,\n cameraType: 'perspective' as 'perspective'|'orthographic'|'stereo',\n lightColor: 0xdddddd as string|number,\n lightIntensity: 1.0,\n ambientColor: 0xdddddd as string|number,\n ambientIntensity: 0.2,\n hoverTimeout: 0,\n tooltip: true,\n mousePreset: 'default' as MouseControlPreset\n}\nexport type StageParameters = typeof StageDefaultParameters\n\nexport interface StageLoadFileParams extends LoaderParameters {\n defaultRepresentation: boolean,\n assembly: string\n}\n\n/**\n * Stage class, central for creating molecular scenes with NGL.\n *\n * @example\n * var stage = new Stage( \"elementId\", { backgroundColor: \"white\" } );\n */\nclass Stage {\n signals: StageSignals = {\n parametersChanged: new Signal(),\n fullscreenChanged: new Signal(),\n componentAdded: new Signal(),\n componentRemoved: new Signal(),\n clicked: new Signal(),\n hovered: new Signal()\n }\n parameters: StageParameters\n\n /**\n * Counter that keeps track of various potentially long-running tasks,\n * including file loading and surface calculation.\n */\n tasks = new Counter()\n compList: Component[] = []\n defaultFileParams = {}\n logList: string[] = []\n\n transformComponent?: Component\n transformAtom?: AtomProxy\n\n viewer: Viewer\n tooltip: HTMLElement\n lastFullscreenElement: HTMLElement\n\n mouseObserver: MouseObserver\n viewerControls: ViewerControls\n trackballControls: TrackballControls\n pickingControls: PickingControls\n animationControls: AnimationControls\n mouseControls: MouseControls\n keyControls: KeyControls\n\n pickingBehavior: PickingBehavior\n mouseBehavior: MouseBehavior\n animationBehavior: AnimationBehavior\n keyBehavior: KeyBehavior\n\n spinAnimation: Animation\n rockAnimation: Animation\n\n constructor (idOrElement: string|HTMLElement, params: Partial = {}) {\n this.viewer = new Viewer(idOrElement)\n if (!this.viewer.renderer) return\n\n this.tooltip = document.createElement('div')\n Object.assign(this.tooltip.style, {\n display: 'none',\n position: 'fixed',\n zIndex: '1000000',\n pointerEvents: 'none',\n backgroundColor: 'rgba( 0, 0, 0, 0.6 )',\n color: 'lightgrey',\n padding: '8px',\n fontFamily: 'sans-serif'\n })\n this.viewer.container.appendChild(this.tooltip)\n\n this.mouseObserver = new MouseObserver(this.viewer.renderer.domElement)\n this.viewerControls = new ViewerControls(this)\n this.trackballControls = new TrackballControls(this)\n this.pickingControls = new PickingControls(this)\n this.animationControls = new AnimationControls(this)\n this.mouseControls = new MouseControls(this)\n this.keyControls = new KeyControls(this)\n\n this.pickingBehavior = new PickingBehavior(this)\n this.mouseBehavior = new MouseBehavior(this)\n this.animationBehavior = new AnimationBehavior(this)\n this.keyBehavior = new KeyBehavior(this)\n\n this.spinAnimation = this.animationControls.spin([ 0, 1, 0 ], 0.005)\n this.spinAnimation.pause(true)\n this.rockAnimation = this.animationControls.rock([ 0, 1, 0 ], 0.005)\n this.rockAnimation.pause(true)\n\n // must come after the viewer has been instantiated\n this.parameters = createParams(params, StageDefaultParameters)\n this.setParameters(this.parameters)\n\n this.viewer.animate()\n }\n\n /**\n * Set stage parameters\n */\n setParameters (params: Partial = {}) {\n updateParams(this.parameters, params)\n\n const p = params\n const tp = this.parameters\n\n const viewer = this.viewer\n const controls = this.trackballControls\n\n // apply parameters\n if (p.quality !== undefined) this.setQuality(tp.quality)\n if (p.impostor !== undefined) this.setImpostor(tp.impostor)\n if (p.rotateSpeed !== undefined) controls.rotateSpeed = tp.rotateSpeed\n if (p.zoomSpeed !== undefined) controls.zoomSpeed = tp.zoomSpeed\n if (p.panSpeed !== undefined) controls.panSpeed = tp.panSpeed\n if (p.mousePreset !== undefined) this.mouseControls.preset(tp.mousePreset)\n this.mouseObserver.setParameters({ hoverTimeout: tp.hoverTimeout })\n viewer.setClip(tp.clipNear, tp.clipFar, tp.clipDist, tp.clipMode, tp.clipScale)\n viewer.setFog(undefined, tp.fogNear, tp.fogFar)\n viewer.setCamera(tp.cameraType, tp.cameraFov, tp.cameraEyeSep)\n viewer.setSampling(tp.sampleLevel)\n viewer.setBackground(tp.backgroundColor)\n viewer.setLight(tp.lightColor, tp.lightIntensity, tp.ambientColor, tp.ambientIntensity)\n\n this.signals.parametersChanged.dispatch(this.getParameters())\n\n return this\n }\n\n log (msg: string) {\n console.log('STAGE LOG', msg)\n this.logList.push(msg)\n }\n\n /**\n * Get stage parameters\n */\n getParameters () {\n return Object.assign({}, this.parameters)\n }\n\n /**\n * Create default representations for the given component\n * @param {StructureComponent|SurfaceComponent} object - component to create the representations for\n * @return {undefined}\n */\n defaultFileRepresentation (component: Component) {\n if (component instanceof StructureComponent) {\n component.setSelection('/0')\n\n let atomCount, residueCount, instanceCount\n const structure = component.structure\n\n if (structure.biomolDict.BU1) {\n const assembly = structure.biomolDict.BU1\n atomCount = assembly.getAtomCount(structure)\n residueCount = assembly.getResidueCount(structure)\n instanceCount = assembly.getInstanceCount()\n component.setDefaultAssembly('BU1')\n } else {\n atomCount = structure.getModelProxy(0).atomCount\n residueCount = structure.getModelProxy(0).residueCount\n instanceCount = 1\n }\n\n let sizeScore = atomCount\n\n if (Mobile) {\n sizeScore *= 4\n }\n\n const backboneOnly = structure.atomStore.count / structure.residueStore.count < 2\n if (backboneOnly) {\n sizeScore *= 10\n }\n\n let colorScheme = 'chainname'\n let colorScale = 'RdYlBu'\n let colorReverse = false\n if (structure.getChainnameCount(new Selection('polymer and /0')) === 1) {\n colorScheme = 'residueindex'\n colorScale = 'Spectral'\n colorReverse = true\n }\n\n if (Debug) console.log(sizeScore, atomCount, instanceCount, backboneOnly)\n\n if (residueCount / instanceCount < 4) {\n component.addRepresentation('ball+stick', {\n colorScheme: 'element',\n radiusScale: 2.0,\n aspectRatio: 1.5,\n bondScale: 0.3,\n bondSpacing: 0.75,\n quality: 'auto'\n })\n } else if ((instanceCount > 5 && sizeScore > 15000) || sizeScore > 700000) {\n let scaleFactor = (\n Math.min(\n 2.0,\n Math.max(\n 0.1,\n 6000 / (sizeScore / instanceCount)\n )\n )\n )\n if (backboneOnly) scaleFactor = Math.min(scaleFactor, 0.5)\n\n component.addRepresentation('surface', {\n colorScheme, colorScale, colorReverse,\n sele: 'polymer',\n surfaceType: 'av',\n probeRadius: 1.4,\n scaleFactor: scaleFactor,\n useWorker: false\n })\n } else if (sizeScore > 250000) {\n component.addRepresentation('backbone', {\n colorScheme, colorScale, colorReverse,\n lineOnly: true\n })\n } else if (sizeScore > 100000) {\n component.addRepresentation('backbone', {\n colorScheme, colorScale, colorReverse,\n quality: 'low',\n disableImpostor: true,\n radiusScale: 2.0\n })\n } else if (sizeScore > 80000) {\n component.addRepresentation('backbone', {\n colorScheme, colorScale, colorReverse,\n radiusScale: 2.0\n })\n } else {\n component.addRepresentation('cartoon', {\n colorScheme, colorScale, colorReverse,\n radiusScale: 0.7,\n aspectRatio: 5,\n quality: 'auto'\n })\n if (sizeScore < 50000) {\n component.addRepresentation('base', {\n colorScheme, colorScale, colorReverse,\n quality: 'auto'\n })\n }\n component.addRepresentation('ball+stick', {\n sele: 'ligand',\n colorScheme: 'element',\n radiusScale: 2.0,\n aspectRatio: 1.5,\n bondScale: 0.3,\n bondSpacing: 0.75,\n quality: 'auto'\n })\n }\n\n // add frames as trajectory\n if (component.structure.frames.length) {\n component.addTrajectory()\n }\n } else if (component instanceof SurfaceComponent) {\n component.addRepresentation('surface')\n } else if (component instanceof VolumeComponent) {\n component.addRepresentation('surface')\n }\n\n this.tasks.onZeroOnce(this.autoView, this)\n }\n\n /**\n * Load a file onto the stage\n *\n * @example\n * // load from URL\n * stage.loadFile( \"http://files.rcsb.org/download/5IOS.cif\" );\n *\n * @example\n * // load binary data in CCP4 format via a Blob\n * var binaryBlob = new Blob( [ ccp4Data ], { type: 'application/octet-binary'} );\n * stage.loadFile( binaryBlob, { ext: \"ccp4\" } );\n *\n * @example\n * // load string data in PDB format via a Blob\n * var stringBlob = new Blob( [ pdbData ], { type: 'text/plain'} );\n * stage.loadFile( stringBlob, { ext: \"pdb\" } );\n *\n * @example\n * // load a File object\n * stage.loadFile( file );\n *\n * @example\n * // load from URL and add a 'ball+stick' representation with double/triple bonds\n * stage.loadFile( \"http://files.rcsb.org/download/1crn.cif\" ).then( function( comp ){\n * comp.addRepresentation( \"ball+stick\", { multipleBond: true } );\n * } );\n *\n * @param {String|File|Blob} path - either a URL or an object containing the file data\n * @param {LoaderParameters} params - loading parameters\n * @param {Boolean} params.asTrajectory - load multi-model structures as a trajectory\n * @return {Promise} A Promise object that resolves to a {@link StructureComponent},\n * a {@link SurfaceComponent} or a {@link ScriptComponent} object,\n * depending on the type of the loaded file.\n */\n loadFile (path: string|File|Blob, params: Partial = {}) {\n const p = Object.assign({}, this.defaultFileParams, params)\n const name = getFileInfo(path).name\n\n this.tasks.increment()\n this.log(`loading file '${name}'`)\n\n const onLoadFn = (object: Structure|Surface|Volume) => {\n this.log(`loaded '${name}'`)\n\n const component = this.addComponentFromObject(object, p)\n if (p.defaultRepresentation) {\n this.defaultFileRepresentation(component as Component)\n }\n this.tasks.decrement()\n\n return component\n }\n\n const onErrorFn = (e: Error|string) => {\n this.tasks.decrement()\n const errorMsg = `error loading file: '${e}'`\n this.log(errorMsg)\n throw errorMsg // throw so it can be catched\n }\n\n const ext = defaults(p.ext, getFileInfo(path).ext)\n let promise: Promise\n\n if (ParserRegistry.isTrajectory(ext)) {\n promise = Promise.reject(\n new Error(`loadFile: ext '${ext}' is a trajectory and must be loaded into a structure component`)\n )\n } else {\n promise = autoLoad(path, p)\n }\n\n return promise.then(onLoadFn, onErrorFn)\n }\n\n loadScript (path: string|File|Blob) {\n const name = getFileInfo(path).name\n\n this.log(`loading script '${name}'`)\n\n return autoLoad(path).then(\n (script: Script) => {\n this.tasks.increment()\n this.log(`running script '${name}'`)\n script.run(this).then(() => {\n this.tasks.decrement()\n this.log(`finished script '${name}'`)\n })\n this.log(`called script '${name}'`)\n },\n (error: Error|string) => {\n this.tasks.decrement()\n const errorMsg = `errored script '${name}' \"${error}\"`\n this.log(errorMsg)\n throw errorMsg // throw so it can be catched\n }\n )\n }\n\n /**\n * Add the given component to the stage\n * @param {Component} component - the component to add\n * @return {undefined}\n */\n addComponent (component: Component) {\n if (!component) {\n Log.warn('Stage.addComponent: no component given')\n return\n }\n\n this.compList.push(component)\n this.signals.componentAdded.dispatch(component)\n }\n\n /**\n * Create a component from the given object and add to the stage\n */\n addComponentFromObject (object: Structure|Surface|Volume|Shape, params: Partial = {}): void|Component {\n const CompClass = ComponentRegistry.get(object.type)\n\n if (CompClass) {\n const component = new CompClass(this, object, params)\n this.addComponent(component)\n return component\n }\n\n Log.warn('no component for object type', object.type)\n }\n\n /**\n * Remove the given component\n * @param {Component} component - the component to remove\n * @return {undefined}\n */\n removeComponent (component: Component) {\n const idx = this.compList.indexOf(component)\n if (idx !== -1) {\n this.compList.splice(idx, 1)\n component.dispose()\n this.signals.componentRemoved.dispatch(component)\n }\n }\n\n /**\n * Remove all components from the stage\n */\n removeAllComponents () {\n this.compList.slice().forEach(o => this.removeComponent(o))\n }\n\n /**\n * Handle any size-changes of the container element\n * @return {undefined}\n */\n handleResize () {\n this.viewer.handleResize()\n }\n\n /**\n * Set width and height\n * @param {String} width - CSS width value\n * @param {String} height - CSS height value\n * @return {undefined}\n */\n setSize (width: string, height: string) {\n const container = this.viewer.container\n\n if (container !== document.body) {\n if (width !== undefined) container.style.width = width\n if (height !== undefined) container.style.height = height\n this.handleResize()\n }\n }\n\n /**\n * Toggle fullscreen\n * @param {Element} [element] - document element to put into fullscreen,\n * defaults to the viewer container\n * @return {undefined}\n */\n toggleFullscreen (element: HTMLElement) {\n if (!document.fullscreenEnabled && !document.mozFullScreenEnabled &&\n !(document as any).webkitFullscreenEnabled && !document.msFullscreenEnabled\n ) {\n Log.log('fullscreen mode (currently) not possible')\n return\n }\n\n const self = this\n element = element || this.viewer.container\n this.lastFullscreenElement = element\n\n //\n\n function getFullscreenElement () {\n return document.fullscreenElement || document.mozFullScreenElement ||\n (document as any).webkitFullscreenElement || document.msFullscreenElement\n }\n\n function resizeElement () {\n if (!getFullscreenElement() && self.lastFullscreenElement) {\n const element = self.lastFullscreenElement\n element.style.width = element.dataset.normalWidth || ''\n element.style.height = element.dataset.normalHeight || ''\n\n document.removeEventListener('fullscreenchange', resizeElement)\n document.removeEventListener('mozfullscreenchange', resizeElement)\n document.removeEventListener('webkitfullscreenchange', resizeElement)\n document.removeEventListener('MSFullscreenChange', resizeElement)\n\n self.handleResize()\n self.signals.fullscreenChanged.dispatch(false)\n }\n }\n\n //\n\n if (!getFullscreenElement()) {\n element.dataset.normalWidth = element.style.width || ''\n element.dataset.normalHeight = element.style.height || ''\n element.style.width = window.screen.width + 'px'\n element.style.height = window.screen.height + 'px'\n\n if (element.requestFullscreen) {\n element.requestFullscreen()\n } else if (element.msRequestFullscreen) {\n element.msRequestFullscreen()\n } else if (element.mozRequestFullScreen) {\n element.mozRequestFullScreen()\n } else if ((element as any).webkitRequestFullscreen) {\n (element as any).webkitRequestFullscreen()\n }\n\n document.addEventListener('fullscreenchange', resizeElement)\n document.addEventListener('mozfullscreenchange', resizeElement)\n document.addEventListener('webkitfullscreenchange', resizeElement)\n document.addEventListener('MSFullscreenChange', resizeElement)\n\n this.handleResize()\n this.signals.fullscreenChanged.dispatch(true)\n\n // workaround for Safari\n setTimeout(function () { self.handleResize() }, 100)\n } else {\n if (document.exitFullscreen) {\n document.exitFullscreen()\n } else if (document.msExitFullscreen) {\n document.msExitFullscreen()\n } else if (document.mozCancelFullScreen) {\n document.mozCancelFullScreen()\n } else if ((document as any).webkitExitFullscreen) {\n (document as any).webkitExitFullscreen()\n }\n }\n }\n\n /**\n * Set spin\n * @param {Boolean} flag - if true start rocking and stop spinning\n * @return {undefined}\n */\n setSpin (flag: boolean) {\n if (flag) {\n this.spinAnimation.resume(true)\n this.rockAnimation.pause(true)\n } else {\n this.spinAnimation.pause(true)\n }\n }\n\n /**\n * Set rock\n * @param {Boolean} flag - if true start rocking and stop spinning\n * @return {undefined}\n */\n setRock (flag: boolean) {\n if (flag) {\n this.rockAnimation.resume(true)\n this.spinAnimation.pause(true)\n } else {\n this.rockAnimation.pause(true)\n }\n }\n\n /**\n * Toggle spin\n * @return {undefined}\n */\n toggleSpin () {\n this.setSpin(this.spinAnimation.paused)\n }\n\n /**\n * Toggle rock\n * @return {undefined}\n */\n toggleRock () {\n this.setRock(this.rockAnimation.paused)\n }\n\n /**\n * Get the current focus from the current clipNear value expressed\n * as 0 (full view) to 100 (completely clipped)\n * Negative values may be returned in some cases.\n *\n * In 'camera' clipMode focus isn't applicable, this method returns 0.0\n *\n * @return {number} focus\n */\n getFocus () : number {\n const p = this.parameters\n if (p.clipMode !== 'scene') return 0.0\n\n let clipNear = p.clipNear\n if (p.clipScale === 'absolute') {\n clipNear = this.viewer.absoluteToRelative(clipNear)\n }\n return clipNear * 2\n }\n\n\n /**\n * Set the focus, a value of 0 sets clipping planes to show full scene,\n * while a value of 100 will compltely clip the scene.\n *\n * @param {number} value focus\n */\n setFocus (value: number) {\n if (this.parameters.clipMode !== 'scene') return\n\n let clipNear\n let clipFar\n let fogNear\n let fogFar\n\n if (this.parameters.clipScale === 'relative') {\n clipNear = clamp(value / 2.0, 0.0, 49.9)\n clipFar = 100 - clipNear\n fogNear = 50\n fogFar = pclamp(2 * clipFar - 50)\n\n } else {\n clipNear = this.viewer.relativeToAbsolute(value / 2.0)\n clipFar = clipNear\n fogNear = 0\n fogFar = 2 * clipFar\n }\n\n this.setParameters({ clipNear, clipFar, fogNear, fogFar })\n }\n\n getZoomForBox (boundingBox: Box3) {\n const bbSize = boundingBox.getSize(tmpZoomVector)\n const maxSize = Math.max(bbSize.x, bbSize.y, bbSize.z)\n const minSize = Math.min(bbSize.x, bbSize.y, bbSize.z)\n let distance = maxSize + Math.sqrt(minSize)\n\n const fov = degToRad(this.viewer.perspectiveCamera.fov)\n const width = this.viewer.width\n const height = this.viewer.height\n const aspect = width / height\n const aspectFactor = (height < width ? 1 : aspect)\n\n distance = Math.abs(\n ((distance * 0.5) / aspectFactor) / Math.sin(fov / 2)\n )\n distance += this.parameters.clipDist\n return -distance\n }\n\n getBox () {\n return this.viewer.boundingBox\n }\n\n getZoom () {\n return this.getZoomForBox(this.getBox())\n }\n\n getCenter (optionalTarget?: Vector3) {\n return this.getBox().getCenter(optionalTarget || new Vector3())\n }\n\n /**\n * Add a zoom and a move animation with automatic targets\n * @param {Integer} duration - animation time in milliseconds\n * @return {undefined}\n */\n autoView (duration?: number) {\n this.animationControls.zoomMove(\n this.getCenter(),\n this.getZoom(),\n defaults(duration, 0)\n )\n }\n\n /**\n * Make image from what is shown in a viewer canvas\n */\n makeImage (params: Partial = {}) {\n return new Promise((resolve, reject) => {\n this.tasks.onZeroOnce(() => {\n this.tasks.increment()\n this.viewer.makeImage(params).then(blob => {\n this.tasks.decrement()\n resolve(blob)\n }).catch(e => {\n this.tasks.decrement()\n reject(e)\n })\n })\n })\n }\n\n setImpostor (value: boolean) {\n this.parameters.impostor = value\n\n const types = [\n 'spacefill', 'ball+stick', 'licorice', 'hyperball',\n 'backbone', 'rocket', 'helixorient', 'contact', 'distance',\n 'dot'\n ]\n\n this.eachRepresentation(function (reprElem) {\n if (!types.includes(reprElem.getType())) return\n\n const p = reprElem.getParameters() as any // TODO\n p.disableImpostor = !value\n reprElem.build(p)\n })\n }\n\n setQuality (value: RenderQualityType) {\n this.parameters.quality = value\n\n const types = [\n 'tube', 'cartoon', 'ribbon', 'trace', 'rope'\n ]\n\n const impostorTypes = [\n 'spacefill', 'ball+stick', 'licorice', 'hyperball',\n 'backbone', 'rocket', 'helixorient', 'contact', 'distance',\n 'dot'\n ]\n\n this.eachRepresentation(function (repr) {\n const p = repr.getParameters() as any // TODO\n\n if (!types.includes(repr.getType())) {\n if (!impostorTypes.includes(repr.getType())) return\n\n if (!p.disableImpostor) {\n (repr.repr as any).quality = value // TODO\n return\n }\n }\n\n p.quality = value\n repr.build(p)\n })\n }\n\n /**\n * Iterator over each component and executing the callback\n */\n eachComponent (callback: (comp: Component) => void, type?: string) {\n this.compList.slice().forEach(comp => {\n if (type === undefined || type === comp.type) callback(comp)\n })\n }\n\n /**\n * Iterator over each representation and executing the callback\n */\n eachRepresentation (callback: (reprElem: RepresentationElement, comp: Component) => void, type?: string) {\n this.eachComponent(comp => {\n comp.reprList.slice().forEach(reprElem => {\n if (type === undefined || type === reprElem.getType()) callback(reprElem, comp)\n })\n })\n }\n\n /**\n * Get collection of components by name\n */\n getComponentsByName (name: string|RegExp) {\n const compList: Component[] = []\n\n this.eachComponent(comp => {\n if (name === undefined || matchName(name, comp)) compList.push(comp)\n })\n\n return new ComponentCollection(compList)\n }\n\n /**\n * Get collection of components by object\n */\n getComponentsByObject (object: Structure|Surface|Volume|Shape) {\n const compList: Component[] = []\n\n this.eachComponent(comp => {\n if (comp.object === object) compList.push(comp)\n })\n\n return new ComponentCollection(compList)\n }\n\n /**\n * Get collection of representations by name\n */\n getRepresentationsByName (name: string|RegExp) {\n const reprList: RepresentationElement[] = []\n\n this.eachRepresentation((repr, comp) => {\n if (name === undefined || matchName(name, repr)) reprList.push(repr)\n })\n\n return new RepresentationCollection(reprList)\n }\n\n measureClear () {\n this.eachComponent((sc: StructureComponent) => sc.measureClear(), 'structure')\n }\n\n measureUpdate () {\n this.eachComponent((sc: StructureComponent) => sc.measureUpdate(), 'structure')\n }\n\n /**\n * Cleanup when disposing of a stage object\n */\n dispose () {\n this.tasks.dispose()\n this.viewer.dispose()\n this.mouseObserver.dispose()\n }\n}\n\nexport default Stage\n","/**\n * @file Shape Component\n * @author Alexander Rose \n * @private\n */\n\nimport { ComponentRegistry } from '../globals'\nimport Component, { ComponentParameters } from './component'\nimport Stage from '../stage/stage'\nimport Shape from '../geometry/shape'\nimport { Vector3, Box3 } from 'three';\nimport RepresentationElement from './representation-element';\n\nexport type ShapeRepresentationType = 'buffer'\n\n/**\n * Component wrapping a {@link Shape} object\n *\n * @example\n * // get a shape component by adding a shape object to the stage\n * var shape = new NGL.Shape( \"shape\" );\n * shape.addSphere( [ 0, 0, 0 ], [ 1, 0, 0 ], 1.5 );\n * var shapeComponent = stage.addComponentFromObject( shape );\n * shapeComponent.addRepresentation( \"buffer\" );\n */\nclass ShapeComponent extends Component {\n constructor (stage: Stage, readonly shape: Shape, params: Partial = {}) {\n super(stage, shape, Object.assign({ name: shape.name }, params))\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'shape' }\n\n /**\n * Add a new shape representation to the component\n * @param {String} type - the name of the representation, one of:\n * buffer.\n * @param {BufferRepresentationParameters} params - representation parameters\n * @return {RepresentationComponent} the created representation wrapped into\n * a representation component object\n */\n addRepresentation (type: ShapeRepresentationType, params: { [k: string]: any } = {}): RepresentationElement {\n return this._addRepresentation(type, this.shape, params)\n }\n\n getBoxUntransformed (): Box3 {\n return this.shape.boundingBox\n }\n\n getCenterUntransformed (): Vector3 {\n return this.shape.center\n }\n\n dispose () {\n this.shape.dispose()\n super.dispose()\n }\n}\n\nComponentRegistry.add('shape', ShapeComponent)\n\nexport default ShapeComponent\n","/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n}\r\n","/**\n * @file Atomindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\n/**\n * Color by atom index. The {@link AtomProxy.index} property is used for coloring.\n * Each {@link ModelProxy} of a {@link Structure} is colored seperately. The\n * `params.domain` parameter is ignored.\n *\n * __Name:__ _atomindex_\n *\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"ball+stick\", { colorScheme: \"atomindex\" } );\n * o.autoView();\n * } );\n */\nclass AtomindexColormaker extends Colormaker {\n scalePerModel: { [k: number]: ColormakerScale }\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rainbow'\n this.parameters.reverse = defaults(params.reverse, true)\n }\n\n this.scalePerModel = {}\n\n params.structure.eachModel((mp: ModelProxy) => {\n this.parameters.domain = [ mp.atomOffset, mp.atomEnd ]\n this.scalePerModel[ mp.index ] = this.getScale() // TODO\n })\n }\n\n /**\n * get color for an atom\n * @param {AtomProxy} atom - atom to get color for\n * @return {Integer} hex atom color\n */\n @manageColor\n atomColor (atom: AtomProxy) {\n return this.scalePerModel[ atom.modelIndex ](atom.index)\n }\n}\n\nColormakerRegistry.add('atomindex', AtomindexColormaker)\n\nexport default AtomindexColormaker\n","/**\n * @file Bfactor Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Selection from '../selection/selection'\n\n/**\n * Color by b-factor. The {@link AtomProxy.bfactor} property is used for coloring.\n * By default the min and max b-factor values are used for the scale`s domain.\n *\n * __Name:__ _bfactor_\n *\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"ball+stick\", { colorScheme: \"bfactor\" } );\n * o.autoView();\n * } );\n */\nclass BfactorColormaker extends Colormaker {\n bfactorScale: ColormakerScale\n\n constructor (params: { sele?: string } & StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'OrRd'\n }\n\n if (!params.domain) {\n let selection\n let min = Infinity\n let max = -Infinity\n\n if (params.sele) {\n selection = new Selection(params.sele)\n }\n\n params.structure.eachAtom(function (a) {\n const bfactor = a.bfactor\n min = Math.min(min, bfactor)\n max = Math.max(max, bfactor)\n }, selection)\n\n this.parameters.domain = [ min, max ]\n }\n\n this.bfactorScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.bfactorScale(a.bfactor)\n }\n}\n\nColormakerRegistry.add('bfactor', BfactorColormaker)\n\nexport default BfactorColormaker\n","/**\n * @file Chainid Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\nexport type ChainidDict = { [k: string]: number }\n\n/**\n * Color by chain id\n */\nclass ChainidColormaker extends Colormaker {\n chainidDictPerModel: { [k: number]: ChainidDict } = {}\n scalePerModel: { [k: number]: ColormakerScale } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'Spectral'\n }\n\n params.structure.eachModel((mp: ModelProxy) => {\n let i = 0\n const chainidDict: ChainidDict = {}\n mp.eachChain(function (cp: ChainProxy) {\n if (chainidDict[ cp.chainid ] === undefined) {\n chainidDict[ cp.chainid ] = i\n i += 1\n }\n })\n this.parameters.domain = [ 0, i - 1 ]\n this.chainidDictPerModel[ mp.index ] = chainidDict\n this.scalePerModel[ mp.index ] = this.getScale()\n })\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n const chainidDict = this.chainidDictPerModel[ a.modelIndex ]\n return this.scalePerModel[ a.modelIndex ](chainidDict[ a.chainid ])\n }\n}\n\nColormakerRegistry.add('chainid', ChainidColormaker)\n\nexport default ChainidColormaker\n","/**\n * @file Chainindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\n/**\n * Color by chain index\n */\nclass ChainindexColormaker extends Colormaker {\n scalePerModel: { [k: number]: ColormakerScale } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'Spectral'\n }\n\n params.structure.eachModel((mp: ModelProxy) => {\n this.parameters.domain = [ mp.chainOffset, mp.chainEnd ]\n this.scalePerModel[ mp.index ] = this.getScale()\n })\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.scalePerModel[ a.modelIndex ](a.chainIndex)\n }\n}\n\nColormakerRegistry.add('chainindex', ChainindexColormaker)\n\nexport default ChainindexColormaker\n","/**\n * @file Chainname Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\nexport type ChainnameDict = { [k: string]: number }\n\n/**\n * Color by chain name\n */\nclass ChainnameColormaker extends Colormaker {\n chainnameDictPerModel: { [k: number]: ChainnameDict } = {}\n scalePerModel: { [k: number]: ColormakerScale } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'Spectral'\n }\n\n params.structure.eachModel((mp: ModelProxy) => {\n let i = 0\n const chainnameDict: ChainnameDict = {}\n mp.eachChain(function (cp: ChainProxy) {\n if (chainnameDict[ cp.chainname ] === undefined) {\n chainnameDict[ cp.chainname ] = i\n i += 1\n }\n })\n this.parameters.domain = [ 0, i - 1 ]\n this.chainnameDictPerModel[ mp.index ] = chainnameDict\n this.scalePerModel[ mp.index ] = this.getScale()\n })\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n const chainnameDict = this.chainnameDictPerModel[ a.modelIndex ]\n return this.scalePerModel[ a.modelIndex ](chainnameDict[ a.chainname ])\n }\n}\n\nColormakerRegistry.add('chainname', ChainnameColormaker)\n\nexport default ChainnameColormaker\n","/**\n * @file Densityfit Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by validation density fit\n */\nclass DensityfitColormaker extends Colormaker {\n rsrzScale: ColormakerScale\n rsccScale: ColormakerScale\n\n rsrzDict: { [k: string]: number|undefined } = {}\n rsccDict: { [k: string]: number|undefined } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'RdYlBu'\n }\n\n this.rsrzScale = this.getScale({ domain: [ 2, 0 ] })\n this.rsccScale = this.getScale({ domain: [ 0.678, 1.0 ] })\n\n const val = params.structure.validation\n if (val) {\n this.rsrzDict = val.rsrzDict\n this.rsccDict = val.rsccDict\n }\n\n }\n\n @manageColor\n atomColor (atom: AtomProxy) {\n let sele = atom.resno + ''\n if (atom.inscode) sele += '^' + atom.inscode\n if (atom.chainname) sele += ':' + atom.chainname\n sele += '/' + atom.modelIndex\n\n const rsrz = this.rsrzDict[ sele ]\n if (rsrz !== undefined) {\n return this.rsrzScale(rsrz)\n }\n\n const rscc = this.rsccDict[ sele ]\n if (rscc !== undefined) {\n return this.rsccScale(rscc)\n }\n\n return 0x909090\n }\n}\n\nColormakerRegistry.add('densityfit', DensityfitColormaker)\n\nexport default DensityfitColormaker\n","/**\n * @file Atomindex Colormaker\n * @author Fred Ludlow \n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport SpatialHash from '../geometry/spatial-hash'\n\n// from CHARMM\nconst partialCharges: { [k: string]: { [k: string]: number } } = {\n 'ARG': {\n 'CD': 0.1,\n 'CZ': 0.5,\n 'NE': -0.1\n },\n 'ASN': {\n 'CG': 0.55,\n 'OD1': -0.55\n },\n 'ASP': {\n 'CB': -0.16,\n 'CG': 0.36,\n 'OD1': -0.6,\n 'OD2': -0.6\n },\n 'CYS': {\n 'CB': 0.19,\n 'SG': -0.19\n },\n 'GLN': {\n 'CD': 0.55,\n 'OE1': -0.55\n },\n 'GLU': {\n 'CD': 0.36,\n 'CG': -0.16,\n 'OE1': -0.6,\n 'OE2': -0.6\n },\n 'HIS': {\n 'CB': 0.1,\n 'CD2': 0.2,\n 'CE1': 0.45,\n 'CG': 0.15,\n 'ND1': 0.05,\n 'NE2': 0.05\n },\n 'LYS': {\n 'CE': 0.25,\n 'NZ': 0.75\n },\n 'MET': {\n 'CE': 0.06,\n 'CG': 0.06,\n 'SD': -0.12\n },\n 'PTR': {\n 'C': 0.55,\n 'CA': 0.1,\n 'CZ': 0.25,\n 'N': -0.35,\n 'O': -0.55,\n 'O1P': -0.85,\n 'O2P': -0.85,\n 'O3P': -0.85,\n 'OG1': -1.1,\n 'P': 1.4\n },\n 'SEP': {\n 'C': 0.55,\n 'CA': 0.1,\n 'CB': 0.25,\n 'N': -0.35,\n 'O': -0.55,\n 'O1P': -0.85,\n 'O2P': -0.85,\n 'O3P': -0.85,\n 'OG1': -1.1,\n 'P': 1.4\n },\n 'SER': {\n 'CB': 0.25,\n 'OG': -0.25\n },\n 'THR': {\n 'CB': 0.25,\n 'OG1': -0.25\n },\n 'TPO': {\n 'C': 0.55,\n 'CA': 0.1,\n 'CB': 0.25,\n 'N': -0.35,\n 'O': -0.55,\n 'OG1': -1.1,\n 'O1P': -0.85,\n 'O2P': -0.85,\n 'O3P': -0.85,\n 'P': 1.4\n },\n 'TRP': {\n 'CD1': 0.06,\n 'CD2': 0.1,\n 'CE2': -0.04,\n 'CE3': -0.03,\n 'CG': -0.03,\n 'NE1': -0.06\n },\n 'TYR': {\n 'CZ': 0.25,\n 'OH': -0.25\n },\n 'backbone': {\n 'C': 0.55,\n 'O': -0.55,\n 'N': -0.35,\n 'CA': 0.1\n }\n}\n\nconst maxRadius = 12.0\nconst nHBondDistance = 1.04\nconst nHCharge = 0.25\n\n/**\n * Populates position vector with location of implicit or explicit H\n * Returns position or undefined if not able to locate H\n *\n * @param {AtomProxy} ap - the nitrogen atom\n * @param {Vector3} [position] - optional target\n * @return {Vectors|undefined} the hydrogen atom position\n */\nfunction backboneNHPosition (ap: AtomProxy, position = new Vector3()) {\n let h = false\n let ca = false\n let c = false\n position.set(2 * ap.x, 2 * ap.y, 2 * ap.z)\n\n ap.eachBondedAtom(function (a2: AtomProxy) {\n // Any time we detect H, reset position and skip\n // future tests\n if (h) return\n if (a2.atomname === 'H') {\n position.set(a2.x, a2.y, a2.z)\n h = true\n return\n }\n if (!ca && a2.atomname === 'CA') {\n position.sub(a2 as any) // TODO\n ca = true\n } else if (!c && a2.atomname === 'C') {\n c = true\n position.sub(a2 as any) // TODO\n }\n })\n\n if (h) { return position }\n\n if (ca && c) {\n position.normalize()\n position.multiplyScalar(nHBondDistance)\n position.add(ap as any)\n return position\n }\n}\n\n/**\n * Takes an array of Vector3 objects and\n * converts to an object that looks like an AtomStore\n *\n * @param {Vector3[]} positions - array of positions\n * @return {Object} AtomStore-like object\n */\nfunction buildStoreLike (positions: Vector3[]) {\n const n = positions.length\n const x = new Float32Array(n)\n const y = new Float32Array(n)\n const z = new Float32Array(n)\n\n for (let i = 0; i < positions.length; i++) {\n const v = positions[ i ]\n x[ i ] = v.x\n y[ i ] = v.y\n z[ i ] = v.z\n }\n\n return { x: x, y: y, z: z, count: n }\n}\n\nfunction chargeForAtom (a: AtomProxy): number {\n if (a.partialCharge !== null) return a.partialCharge\n if (!a.isProtein()) { return 0.0 }\n return (\n (partialCharges[ a.resname ] &&\n partialCharges[ a.resname ][ a.atomname ]) ||\n partialCharges[ 'backbone' ][ a.atomname ] || 0.0\n )\n}\n\n/**\n * Color a surface by electrostatic charge. This is a highly approximate\n * calculation! The partial charges are CHARMM with hydrogens added to heavy\n * atoms and hydrogen positions generated for amides.\n *\n * __Name:__ _electrostatic_\n *\n * @example\n * stage.loadFile( \"rcsb://3dqb\" ).then( function( o ){\n * o.addRepresentation( \"surface\", { colorScheme: \"electrostatic\" } );\n * o.autoView();\n * } );\n */\nclass ElectrostaticColormaker extends Colormaker {\n scale: ColormakerScale\n hHash: SpatialHash\n hash: SpatialHash\n charges: Float32Array\n hStore: { x: Float32Array, y: Float32Array, z: Float32Array, count: number }\n atomProxy: AtomProxy\n\n delta = new Vector3()\n hCharges: number[] = []\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rwb'\n }\n if (!params.domain) {\n this.parameters.domain = [ -50, 50 ]\n }\n\n this.scale = this.getScale()\n\n this.charges = new Float32Array(params.structure.atomCount)\n const hPositions: Vector3[] = []\n\n params.structure.eachAtom((ap: AtomProxy) => {\n this.charges[ ap.index ] = chargeForAtom(ap) * ap.occupancy\n if (ap.atomname === 'N') {\n\n // In the specific case where N forms two bonds to\n // CA and C, try and place a dummy hydrogen\n\n if (ap.bondCount >= 3) return; // Skip if 3 bonds already (e.g. PRO)\n\n if (ap.bondToElementCount(1)) return; // Skip if any H specificed\n\n const hPos = backboneNHPosition(ap)\n if (hPos !== undefined) {\n hPositions.push(hPos)\n this.hCharges.push(nHCharge * ap.occupancy)\n }\n }\n })\n\n const bbox = params.structure.getBoundingBox()\n bbox.expandByScalar(nHBondDistance) // Worst case\n\n // SpatialHash requires x,y,z and count\n this.hStore = buildStoreLike(hPositions)\n this.hHash = new SpatialHash(this.hStore as any, bbox) // TODO\n this.hash = new SpatialHash(params.structure.atomStore, bbox)\n }\n\n @manageColor\n positionColor (v: Vector3) {\n\n const charges = this.charges\n const hCharges = this.hCharges\n\n let p = 0.0\n this.hash.eachWithin(v.x, v.y, v.z, maxRadius, (atomIndex, dSq) => {\n const charge = charges[atomIndex]\n if (charge === 0.0) return\n p += charge / dSq\n })\n\n this.hHash.eachWithin(v.x, v.y, v.z, maxRadius, (atomIndex, dSq) => {\n const charge = hCharges[atomIndex]\n if (charge === 0.0) return\n p += charge / dSq\n })\n\n return this.scale(p * 332) // 332 to convert to kcal/mol\n }\n}\n\nColormakerRegistry.add('electrostatic', ElectrostaticColormaker)\n\nexport default ElectrostaticColormaker\n","/**\n * @file Element Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Colormaker, { ColormakerParameters, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n// from Jmol http://jmol.sourceforge.net/jscolors/ (or 0xFFFFFF)\nconst ElementColors: { [k: string]: number } = {\n 'H': 0xFFFFFF,\n 'HE': 0xD9FFFF,\n 'LI': 0xCC80FF,\n 'BE': 0xC2FF00,\n 'B': 0xFFB5B5,\n 'C': 0x909090,\n 'N': 0x3050F8,\n 'O': 0xFF0D0D,\n 'F': 0x90E050,\n 'NE': 0xB3E3F5,\n 'NA': 0xAB5CF2,\n 'MG': 0x8AFF00,\n 'AL': 0xBFA6A6,\n 'SI': 0xF0C8A0,\n 'P': 0xFF8000,\n 'S': 0xFFFF30,\n 'CL': 0x1FF01F,\n 'AR': 0x80D1E3,\n 'K': 0x8F40D4,\n 'CA': 0x3DFF00,\n 'SC': 0xE6E6E6,\n 'TI': 0xBFC2C7,\n 'V': 0xA6A6AB,\n 'CR': 0x8A99C7,\n 'MN': 0x9C7AC7,\n 'FE': 0xE06633,\n 'CO': 0xF090A0,\n 'NI': 0x50D050,\n 'CU': 0xC88033,\n 'ZN': 0x7D80B0,\n 'GA': 0xC28F8F,\n 'GE': 0x668F8F,\n 'AS': 0xBD80E3,\n 'SE': 0xFFA100,\n 'BR': 0xA62929,\n 'KR': 0x5CB8D1,\n 'RB': 0x702EB0,\n 'SR': 0x00FF00,\n 'Y': 0x94FFFF,\n 'ZR': 0x94E0E0,\n 'NB': 0x73C2C9,\n 'MO': 0x54B5B5,\n 'TC': 0x3B9E9E,\n 'RU': 0x248F8F,\n 'RH': 0x0A7D8C,\n 'PD': 0x006985,\n 'AG': 0xC0C0C0,\n 'CD': 0xFFD98F,\n 'IN': 0xA67573,\n 'SN': 0x668080,\n 'SB': 0x9E63B5,\n 'TE': 0xD47A00,\n 'I': 0x940094,\n 'XE': 0x940094,\n 'CS': 0x57178F,\n 'BA': 0x00C900,\n 'LA': 0x70D4FF,\n 'CE': 0xFFFFC7,\n 'PR': 0xD9FFC7,\n 'ND': 0xC7FFC7,\n 'PM': 0xA3FFC7,\n 'SM': 0x8FFFC7,\n 'EU': 0x61FFC7,\n 'GD': 0x45FFC7,\n 'TB': 0x30FFC7,\n 'DY': 0x1FFFC7,\n 'HO': 0x00FF9C,\n 'ER': 0x00E675,\n 'TM': 0x00D452,\n 'YB': 0x00BF38,\n 'LU': 0x00AB24,\n 'HF': 0x4DC2FF,\n 'TA': 0x4DA6FF,\n 'W': 0x2194D6,\n 'RE': 0x267DAB,\n 'OS': 0x266696,\n 'IR': 0x175487,\n 'PT': 0xD0D0E0,\n 'AU': 0xFFD123,\n 'HG': 0xB8B8D0,\n 'TL': 0xA6544D,\n 'PB': 0x575961,\n 'BI': 0x9E4FB5,\n 'PO': 0xAB5C00,\n 'AT': 0x754F45,\n 'RN': 0x428296,\n 'FR': 0x420066,\n 'RA': 0x007D00,\n 'AC': 0x70ABFA,\n 'TH': 0x00BAFF,\n 'PA': 0x00A1FF,\n 'U': 0x008FFF,\n 'NP': 0x0080FF,\n 'PU': 0x006BFF,\n 'AM': 0x545CF2,\n 'CM': 0x785CE3,\n 'BK': 0x8A4FE3,\n 'CF': 0xA136D4,\n 'ES': 0xB31FD4,\n 'FM': 0xB31FBA,\n 'MD': 0xB30DA6,\n 'NO': 0xBD0D87,\n 'LR': 0xC70066,\n 'RF': 0xCC0059,\n 'DB': 0xD1004F,\n 'SG': 0xD90045,\n 'BH': 0xE00038,\n 'HS': 0xE6002E,\n 'MT': 0xEB0026,\n 'DS': 0xFFFFFF,\n 'RG': 0xFFFFFF,\n 'CN': 0xFFFFFF,\n 'UUT': 0xFFFFFF,\n 'FL': 0xFFFFFF,\n 'UUP': 0xFFFFFF,\n 'LV': 0xFFFFFF,\n 'UUH': 0xFFFFFF,\n\n 'D': 0xFFFFC0,\n 'T': 0xFFFFA0\n}\nconst DefaultElementColor = 0xFFFFFF\n\n/**\n * Color by element\n */\nclass ElementColormaker extends Colormaker {\n constructor (params: ColormakerParameters) {\n params.value = defaults(params.value, ElementColors.C)\n\n super(params)\n }\n\n\n @manageColor\n atomColor (a: AtomProxy) {\n const element = a.element\n\n if (element === 'C') {\n return this.parameters.value\n } else {\n return ElementColors[ element ] || DefaultElementColor\n }\n }\n}\n\nColormakerRegistry.add('element', ElementColormaker)\n\nexport default ElementColormaker\n","/**\n * @file Entityindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by entity index\n */\nclass EntityindexColormaker extends Colormaker {\n entityindexScale: ColormakerScale\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'Spectral'\n }\n if (!params.domain) {\n this.parameters.domain = [ 0, params.structure.entityList.length - 1 ]\n }\n\n this.entityindexScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.entityindexScale(a.entityIndex)\n }\n}\n\nColormakerRegistry.add('entityindex', EntityindexColormaker)\n\nexport default EntityindexColormaker\n","/**\n * @file Entitytype Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\nimport {\n PolymerEntity, NonPolymerEntity, MacrolideEntity, WaterEntity\n} from '../structure/structure-constants'\n\n/**\n * Color by entity type\n */\nclass EntitytypeColormaker extends Colormaker {\n @manageColor\n atomColor (a: AtomProxy) {\n const e = a.entity\n const et = e ? e.entityType : undefined\n switch (et) {\n case PolymerEntity:\n return 0x7fc97f\n case NonPolymerEntity:\n return 0xfdc086\n case MacrolideEntity:\n return 0xbeaed4\n case WaterEntity:\n return 0x386cb0\n default:\n return 0xffff99\n }\n }\n}\n\nColormakerRegistry.add('entitytype', EntitytypeColormaker)\n\nexport default EntitytypeColormaker\n","/**\n * @file Geoquality Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport { countSetBits } from '../math/math-utils'\n\n/**\n * Color by validation gometry quality\n */\nclass GeoqualityColormaker extends Colormaker {\n geoAtomDict: { [k: string]: { [k: string]: number } } = {}\n geoDict: { [k: string]: number|undefined } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n const val = params.structure.validation\n if (val) {\n this.geoAtomDict = val.geoAtomDict\n this.geoDict = val.geoDict\n }\n }\n\n @manageColor\n atomColor (atom: AtomProxy) {\n let sele = atom.resno + ''\n if (atom.inscode) sele += '^' + atom.inscode\n if (atom.chainname) sele += ':' + atom.chainname\n sele += '/' + atom.modelIndex\n\n let geoProblemCount\n const geoAtom = this.geoAtomDict[ sele ]\n if (geoAtom !== undefined) {\n const atomProblems: number = geoAtom[ atom.atomname ] || 0\n geoProblemCount = countSetBits(atomProblems)\n } else {\n geoProblemCount = this.geoDict[ sele ] || 0\n }\n\n if (geoProblemCount === 0) {\n return 0x2166ac\n } else if (geoProblemCount === 1) {\n return 0xfee08b\n } else if (geoProblemCount === 2) {\n return 0xf46d43\n } else if (geoProblemCount >= 3) {\n return 0xa50026\n }\n return 0x909090\n }\n}\n\nColormakerRegistry.add('geoquality', GeoqualityColormaker)\n\nexport default GeoqualityColormaker\n","/**\n * @file Hydrophobicity Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { ColormakerParameters, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\nimport {\n ResidueHydrophobicity, DefaultResidueHydrophobicity\n} from '../structure/structure-constants'\n\n/**\n * Color by hydrophobicity\n */\nclass HydrophobicityColormaker extends Colormaker {\n hfScale: ColormakerScale\n resHF: { [k: string]: number } = {}\n defaultResidueHydrophobicity: number\n\n constructor (params: ColormakerParameters) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'RdYlGn'\n }\n\n const idx = 0 // 0: DGwif, 1: DGwoct, 2: Oct-IF\n\n for (const name in ResidueHydrophobicity) {\n this.resHF[ name ] = ResidueHydrophobicity[ name ][ idx ]\n }\n this.defaultResidueHydrophobicity = DefaultResidueHydrophobicity[idx]\n\n if (!params.domain) {\n let min = Infinity\n let max = -Infinity\n\n for (const name in this.resHF) {\n const val = this.resHF[ name ]\n min = Math.min(min, val)\n max = Math.max(max, val)\n }\n\n this.parameters.domain = [ min, 0, max ]\n }\n\n this.hfScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.hfScale(this.resHF[ a.resname ] || this.defaultResidueHydrophobicity)\n }\n}\n\nColormakerRegistry.add('hydrophobicity', HydrophobicityColormaker)\n\nexport default HydrophobicityColormaker\n","/**\n * @file Modelindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by model index\n */\nclass ModelindexColormaker extends Colormaker {\n modelindexScale: ColormakerScale\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rainbow'\n }\n if (!params.domain) {\n this.parameters.domain = [ 0, params.structure.modelStore.count ]\n }\n\n this.modelindexScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.modelindexScale(a.modelIndex)\n }\n}\n\nColormakerRegistry.add('modelindex', ModelindexColormaker)\n\nexport default ModelindexColormaker\n","/**\n * @file Moleculetype Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\nimport {\n WaterType, IonType, ProteinType, RnaType, DnaType, SaccharideType\n} from '../structure/structure-constants'\n\n/**\n * Color by molecule type\n */\nclass MoleculetypeColormaker extends Colormaker {\n @manageColor\n atomColor (a: AtomProxy) {\n switch (a.residueType.moleculeType) {\n case WaterType:\n return 0x386cb0\n case IonType:\n return 0xf0027f\n case ProteinType:\n return 0xbeaed4\n case RnaType:\n return 0xfdc086\n case DnaType:\n return 0xbf5b17\n case SaccharideType:\n return 0x7fc97f\n default:\n return 0xffff99\n }\n }\n}\n\nColormakerRegistry.add('moleculetype', MoleculetypeColormaker)\n\nexport default MoleculetypeColormaker\n","/**\n * @file Occupancy Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { ColormakerParameters, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by occupancy\n */\nclass OccupancyColormaker extends Colormaker {\n occupancyScale: ColormakerScale\n\n constructor (params: ColormakerParameters) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'PuBu'\n }\n\n if (!params.domain) {\n this.parameters.domain = [ 0.0, 1.0 ]\n }\n\n this.occupancyScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.occupancyScale(a.occupancy)\n }\n}\n\nColormakerRegistry.add('occupancy', OccupancyColormaker)\n\nexport default OccupancyColormaker\n","/**\n * @file Partialcharge Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { ColormakerParameters, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by partial charge. The {@link AtomProxy.partialCharge} property is used for coloring.\n * The default domain is [-1, 1].\n *\n * __Name:__ _partialCharge_\n *\n * @example\n * stage.loadFile(\"rcsb://1crn\").then(function (o) {\n * o.addRepresentation(\"ball+stick\", {colorScheme: \"partialCharge\"});\n * o.autoView();\n * });\n */\nclass PartialchargeColormaker extends Colormaker {\n partialchargeScale: ColormakerScale\n\n constructor (params: ColormakerParameters) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rwb'\n }\n\n if (!params.domain) {\n this.parameters.domain = [-1, 1]\n }\n\n this.partialchargeScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.partialchargeScale(a.partialCharge || 0)\n }\n}\n\nColormakerRegistry.add('partialcharge', PartialchargeColormaker)\n\nexport default PartialchargeColormaker\n","/**\n * @file Random Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\n\nfunction randomColor () {\n return Math.random() * 0xFFFFFF\n}\n\n/**\n * Class by random color\n */\nclass RandomColormaker extends Colormaker {\n /**\n * get color for an atom\n * @return {Integer} random hex color\n */\n @manageColor\n atomColor () {\n return randomColor()\n }\n\n /**\n * get color for volume cell\n * @return {Integer} random hex color\n */\n @manageColor\n volumeColor () {\n return randomColor()\n }\n\n /**\n * get color for coordinates in space\n * @return {Integer} random hex color\n */\n @manageColor\n positionColor () {\n return randomColor()\n }\n}\n\nColormakerRegistry.add('random', RandomColormaker)\n\nexport default RandomColormaker\n","/**\n * @file Randomcoilindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by random coil index\n */\nclass RandomcoilindexColormaker extends Colormaker {\n rciScale: ColormakerScale\n rciDict: { [k: string]: number|undefined } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'RdYlBu'\n }\n\n this.rciScale = this.getScale({ domain: [ 0.6, 0 ] })\n\n const val = params.structure.validation\n if (val) this.rciDict = val.rciDict\n\n }\n\n @manageColor\n atomColor (atom: AtomProxy) {\n let sele = `[${atom.resname}]${atom.resno}`\n if (atom.chainname) sele += ':' + atom.chainname\n\n const rci = this.rciDict[ sele ]\n return rci !== undefined ? this.rciScale(rci) : 0x909090\n }\n}\n\nColormakerRegistry.add('randomcoilindex', RandomcoilindexColormaker)\n\nexport default RandomcoilindexColormaker\n","/**\n * @file Residueindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\n\n/**\n * Color by residue index\n */\nclass ResidueindexColormaker extends Colormaker {\n scalePerChain: { [k: number]: ColormakerScale } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rainbow'\n this.parameters.reverse = defaults(params.reverse, true)\n }\n\n params.structure.eachChain((cp: ChainProxy) => {\n this.parameters.domain = [ cp.residueOffset, cp.residueEnd ]\n this.scalePerChain[ cp.index ] = this.getScale()\n })\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.scalePerChain[ a.chainIndex ](a.residueIndex)\n }\n}\n\nColormakerRegistry.add('residueindex', ResidueindexColormaker)\n\nexport default ResidueindexColormaker\n","/**\n * @file Resname Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n// protein colors from Jmol http://jmol.sourceforge.net/jscolors/\nconst ResidueColors: { [k: string]: number } = {\n 'ALA': 0x8CFF8C,\n 'ARG': 0x00007C,\n 'ASN': 0xFF7C70,\n 'ASP': 0xA00042,\n 'CYS': 0xFFFF70,\n 'GLN': 0xFF4C4C,\n 'GLU': 0x660000,\n 'GLY': 0xFFFFFF,\n 'HIS': 0x7070FF,\n 'ILE': 0x004C00,\n 'LEU': 0x455E45,\n 'LYS': 0x4747B8,\n 'MET': 0xB8A042,\n 'PHE': 0x534C52,\n 'PRO': 0x525252,\n 'SER': 0xFF7042,\n 'THR': 0xB84C00,\n 'TRP': 0x4F4600,\n 'TYR': 0x8C704C,\n 'VAL': 0xFF8CFF,\n\n 'ASX': 0xFF00FF,\n 'GLX': 0xFF00FF,\n 'ASH': 0xFF00FF,\n 'GLH': 0xFF00FF,\n\n 'A': 0xDC143C, // Crimson Red\n 'G': 0x32CD32, // Lime Green\n 'I': 0x9ACD32, // Yellow Green\n 'X': 0x7CFC00, // Lawn Green\n 'C': 0xFFD700, // Gold Yellow\n 'T': 0x4169E1, // Royal Blue\n 'U': 0x40E0D0, // Turquoise Cyan\n 'D': 0x008B8B, // Dark Cyan\n\n 'DA': 0xDC143C,\n 'DG': 0x32CD32,\n 'DI': 0x9ACD32,\n 'DX': 0x7CFC00,\n 'DC': 0xFFD700,\n 'DT': 0x4169E1,\n 'DU': 0x40E0D0,\n 'DD': 0x008B8B\n}\nconst DefaultResidueColor = 0xFF00FF\n\n/**\n * Color by residue name\n */\nclass ResnameColormaker extends Colormaker {\n @manageColor\n atomColor (a: AtomProxy) {\n return ResidueColors[ a.resname ] || DefaultResidueColor\n }\n}\n\nColormakerRegistry.add('resname', ResnameColormaker)\n\nexport default ResnameColormaker\n","/**\n * @file Sstruc Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\n\n// from Jmol http://jmol.sourceforge.net/jscolors/ (shapely)\nconst StructureColors = {\n 'alphaHelix': 0xFF0080,\n 'threeTenHelix': 0xA00080,\n 'piHelix': 0x600080,\n 'betaStrand': 0xFFC800,\n 'betaTurn': 0x6080FF,\n 'coil': 0xFFFFFF,\n\n 'dna': 0xAE00FE,\n 'rna': 0xFD0162,\n\n 'carbohydrate': 0xA6A6FA\n}\nconst DefaultStructureColor = 0x808080\n\n/**\n * Color by secondary structure\n */\nclass SstrucColormaker extends Colormaker {\n residueProxy: ResidueProxy\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n this.residueProxy = params.structure.getResidueProxy()\n }\n\n @manageColor\n atomColor (ap: AtomProxy) {\n const sstruc = ap.sstruc\n const rp = this.residueProxy\n\n if (sstruc === 'h') {\n return StructureColors.alphaHelix\n } else if (sstruc === 'g') {\n return StructureColors.threeTenHelix\n } else if (sstruc === 'i') {\n return StructureColors.piHelix\n } else if (sstruc === 'e' || sstruc === 'b') {\n return StructureColors.betaStrand\n } else if (sstruc === 't') {\n return StructureColors.betaTurn\n } else {\n rp.index = ap.residueIndex\n if (rp.isDna()) {\n return StructureColors.dna\n } else if (rp.isRna()) {\n return StructureColors.rna\n } else if (rp.isSaccharide()) {\n return StructureColors.carbohydrate\n } else if (rp.isProtein() || sstruc === 's' || sstruc === 'l') {\n return StructureColors.coil\n } else {\n return DefaultStructureColor\n }\n }\n }\n}\n\nColormakerRegistry.add('sstruc', SstrucColormaker)\n\nexport default SstrucColormaker\n","/**\n * @file Colordata Colormaker\n * @author Fred Ludlow \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { ColorData, ColormakerScale, manageColor, StuctureColormakerParams } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport BondProxy from '../proxy/bond-proxy'\n\n\nclass StructuredataColormaker extends Colormaker {\n atomData?: ColorData['atomData']\n bondData?: ColorData['bondData']\n scale: ColormakerScale\n\n constructor(params: StuctureColormakerParams) {\n super(params)\n if (!params.scale) {\n this.parameters.scale = 'rwb'\n }\n this.atomData = this.parameters.data?.atomData\n this.bondData = this.parameters.data?.bondData\n this.scale = this.getScale(this.parameters)\n }\n\n @manageColor\n atomColor(a: AtomProxy) {\n const val = this.atomData?.[a.index]\n return (val !== undefined) ? this.scale(val) : this.parameters.value\n }\n\n @manageColor\n bondColor(bond: BondProxy, fromTo: boolean) {\n const val = this.bondData?.[bond.index]\n \n // Explicit bond data?\n if (val !== undefined) return this.scale(val)\n \n \n if (this.atomProxy) {\n this.atomProxy.index = fromTo ? bond.atomIndex1 : bond.atomIndex2\n return this.atomColor(this.atomProxy)\n } \n \n // Fallback\n return this.parameters.value\n }\n}\n\nColormakerRegistry.add('structuredata', StructuredataColormaker)\n\nexport default StructuredataColormaker","/**\n * @file Uniform Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\n\n/**\n * Color by uniform color\n */\nclass UniformColormaker extends Colormaker {\n @manageColor\n atomColor () {\n return this.parameters.value\n }\n\n @manageColor\n bondColor () {\n return this.parameters.value\n }\n\n @manageColor\n valueColor () {\n return this.parameters.value\n }\n\n @manageColor\n volumeColor () {\n return this.parameters.value\n }\n}\n\nColormakerRegistry.add('uniform', UniformColormaker)\n\nexport default UniformColormaker\n","/**\n * @file Value Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { VolumeColormakerParams, ColormakerScale, manageColor } from './colormaker'\n\n/**\n * Color by volume value\n */\nclass ValueColormaker extends Colormaker {\n valueScale: ColormakerScale\n\n constructor (params: VolumeColormakerParams) {\n super(params)\n this.valueScale = this.getScale()\n }\n\n /**\n * return the color for a volume cell\n * @param {Integer} index - volume cell index\n * @return {Integer} hex cell color\n */\n @manageColor\n volumeColor (index: number) {\n return this.valueScale((this.parameters.volume! as any).data[ index ]) // TODO\n }\n}\n\nColormakerRegistry.add('value', ValueColormaker)\n\nexport default ValueColormaker\n","/**\n * @file Volume Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\nimport { lerp } from '../math/math-utils'\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { VolumeColormakerParams, ColormakerScale, manageColor } from './colormaker'\n\n/**\n * Color by volume position\n */\nclass VolumeColormaker extends Colormaker {\n valueScale: ColormakerScale\n vec = new Vector3()\n\n constructor (params: VolumeColormakerParams) {\n super(params)\n this.valueScale = this.getScale()\n }\n\n /**\n * return the color for coordinates in space\n * @param {Vector3} coords - xyz coordinates\n * @return {Integer} hex coords color\n */\n @manageColor\n positionColor (coords: Vector3) {\n const volume = this.parameters.volume as any // TODO\n\n if (!volume || !volume.inverseMatrix) {\n return this.parameters.value\n }\n\n const vec = this.vec\n const data = volume.data\n const nx = volume.nx\n const ny = volume.ny\n const nxy = nx * ny\n\n vec.copy(coords)\n vec.applyMatrix4(volume.inverseMatrix)\n\n // position of grid cell\n const x0 = Math.floor(vec.x)\n const y0 = Math.floor(vec.y)\n const z0 = Math.floor(vec.z)\n\n // Indices\n const i = ((((z0 * ny) + y0) * nx) + x0)\n const i1 = i + 1\n const iy = i + nx\n const iz = i + nxy\n const i1y = iy + 1\n const i1z = iz + 1\n const iyz = iy + nxy\n const i1yz = iyz + 1\n\n // Values\n const v = data[ i ]\n const v1 = data[ i1 ]\n const vy = data[ iy ]\n const vz = data[ iz ]\n const v1y = data[ i1y ]\n const v1z = data[ i1z ]\n const vyz = data[ iyz ]\n const v1yz = data[ i1yz ]\n\n // Position of point in fraction of grid\n const xd = vec.x - x0\n const yd = vec.y - y0\n const zd = vec.z - z0\n\n // 1st Dimension\n const c00 = lerp(v, v1, xd)\n const c01 = lerp(vz, v1z, xd)\n const c10 = lerp(vy, v1y, xd)\n const c11 = lerp(vyz, v1yz, xd)\n\n // 2nd Dimension\n const c0 = lerp(c00, c10, yd)\n const c1 = lerp(c01, c11, yd)\n\n // 3rd Dimension\n const c = lerp(c0, c1, zd)\n\n return this.valueScale(c)\n }\n}\n\nColormakerRegistry.add('volume', VolumeColormaker)\n\nexport default VolumeColormaker\n","/**\n * @file Structure Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { ExtensionFragDepth, Mobile } from '../globals'\nimport { defaults } from '../utils'\nimport { RepresentationParameters, default as Representation } from './representation'\nimport Selection from '../selection/selection'\nimport RadiusFactory, { RadiusFactoryTypes, RadiusType } from '../utils/radius-factory'\nimport Structure from '../structure/structure'\nimport Viewer from '../viewer/viewer'\n// @ts-ignore: unused import Volume required for declaration only\nimport { Assembly, Volume } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport AtomProxy from '../proxy/atom-proxy';\nimport Polymer from '../proxy/polymer';\nimport Buffer from '../buffer/buffer';\nimport { AtomDataFields, BondDataFields, AtomDataParams, BondDataParams } from '../structure/structure-data';\n// @ts-ignore: unused import Surface required for declaration only\nimport Surface from '../surface/surface'\n\n/**\n * Structure representation parameter object.\n * @typedef {Object} StructureRepresentationParameters - structure representation parameters\n * @mixes RepresentationParameters\n *\n * @property {String} radiusType - A list of possible sources of the radius used for rendering the representation. The radius can be based on the *vdW radius*, the *covalent radius* or the *B-factor* value of the corresponding atom. Additionally the radius can be based on the *secondary structure*. Alternatively, when set to *size*, the value from the *radius* parameter is used for all atoms.\n * @property {Float} radius - A number providing a fixed radius used for rendering the representation.\n * @property {Float} scale - A number that scales the value defined by the *radius* or the *radiusType* parameter.\n * @property {String} assembly - name of an assembly object. Included are the asymmetric unit (*AU*) corresponding to the coordinates given in the structure file, biological assemblies from *PDB*, *mmCIF* or *MMTF* files (*BU1*, *BU2*, ...), a filled (crystallographic) unitcell of a given space group (*UNITCELL*), a supercell consisting of a center unitcell and its 26 direct neighbors (*SUPERCELL*). Set to *default* to use the default asemmbly of the structure object.\n */\nexport interface StructureRepresentationParameters extends RepresentationParameters {\n radiusType: string\n radius: number\n scale: number\n assembly: string\n}\nexport interface StructureRepresentationData {\n bufferList: Buffer[]\n polymerList?: Polymer[]\n sview?: StructureView | Structure\n [k: string]: any\n}\n/**\n * Structure representation\n * @interface\n */\nabstract class StructureRepresentation extends Representation {\n\n protected selection: Selection\n protected dataList: StructureRepresentationData[]\n structure: Structure\n structureView: StructureView\n\n protected radiusType: RadiusType\n protected radiusData: {[k: number]: number}\n protected radiusSize: number\n protected radiusScale: number\n protected assembly: string\n protected defaultAssembly: string\n protected needsBuild: boolean\n\n /**\n * Create Structure representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {StructureRepresentationParameters} params - structure representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n const p = params || {}\n\n super(structure, viewer, p)\n\n this.type = 'structure'\n\n this.parameters = Object.assign({\n radiusType: {\n type: 'select', options: RadiusFactory.types\n },\n radiusData: {\n type: 'hidden'\n },\n radiusSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n radiusScale: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n assembly: null,\n defaultAssembly: {\n type: 'hidden'\n }\n }, this.parameters)\n\n /**\n * @type {Selection}\n * @private\n */\n this.selection = new Selection(p.sele)\n\n /**\n * @type {Array}\n * @private\n */\n this.dataList = []\n\n /**\n * @type {Structure}\n */\n this.structure = structure\n\n /**\n * @type {StructureView}\n */\n this.structureView = this.structure.getView(this.selection)\n\n if (structure.biomolDict) {\n const biomolOptions:{[key: string]: string} = {\n 'default': 'default',\n '': (structure.unitcell ? 'AU' : 'FULL')\n }\n Object.keys(structure.biomolDict).forEach(function (k) {\n biomolOptions[ k ] = k\n })\n this.parameters.assembly = {\n type: 'select',\n options: biomolOptions,\n rebuild: true\n }\n } else {\n this.parameters.assembly = null\n }\n }\n\n get defaultScale () {\n return {\n 'vdw': 1.0,\n 'covalent': 1.0,\n 'bfactor': 0.01,\n 'sstruc': 1.0\n }\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'element')\n\n this.setRadius(p.radius, p)\n\n this.radiusType = defaults(p.radiusType, 'vdw')\n this.radiusData = defaults(p.radiusData, {})\n this.radiusSize = defaults(p.radiusSize, 1.0)\n this.radiusScale = defaults(p.radiusScale, 1.0)\n this.assembly = defaults(p.assembly, 'default')\n this.defaultAssembly = defaults(p.defaultAssembly, '')\n\n if (p.quality === 'auto') {\n p.quality = this.getQuality()\n }\n\n super.init(p)\n\n this.selection.signals.stringChanged.add((/* sele */) => {\n this.build()\n })\n\n this.build()\n }\n\n setRadius (value: string | number | undefined, p: Partial) {\n const types = Object.keys(RadiusFactoryTypes)\n\n if (typeof value === 'string' && types.includes(value.toLowerCase())) {\n p.radiusType = value\n } else if (value !== undefined) {\n p.radiusType = 'size'\n p.radiusSize = value\n }\n\n return this\n }\n\n getAssembly (): Assembly {\n const name = this.assembly === 'default' ? this.defaultAssembly : this.assembly\n return this.structure.biomolDict[ name ]\n }\n\n getQuality () {\n let atomCount\n const s = this.structureView\n const assembly = this.getAssembly()\n if (assembly) {\n atomCount = assembly.getAtomCount(s)\n } else {\n atomCount = s.atomCount\n }\n if (Mobile) {\n atomCount *= 4\n }\n const backboneOnly = s.atomStore.count / s.residueStore.count < 2\n if (backboneOnly) {\n atomCount *= 10\n }\n\n if (atomCount < 15000) {\n return 'high'\n } else if (atomCount < 80000) {\n return 'medium'\n } else {\n return 'low'\n }\n }\n\n create () {\n if (this.structureView.atomCount === 0) return\n\n if (!this.structureView.hasCoords()) {\n this.needsBuild = true\n return\n } else {\n this.needsBuild = false\n }\n\n const assembly = this.getAssembly()\n\n if (assembly) {\n assembly.partList.forEach((part, i) => {\n const sview = part.getView(this.structureView)\n if (sview.atomCount === 0) return\n const data = this.createData(sview, i)\n if (data) {\n data.sview = sview\n data.instanceList = part.getInstanceList()\n this.dataList.push(data)\n }\n })\n } else {\n const data = this.createData(this.structureView, 0)\n if (data) {\n data.sview = this.structureView\n this.dataList.push(data)\n }\n }\n }\n\n abstract createData (sview: StructureView, k?: number): StructureRepresentationData|undefined\n\n update (what: AtomDataFields|BondDataFields) {\n if (this.lazy && !this.visible) {\n Object.assign(this.lazyProps.what, what)\n return\n }\n\n if (this.needsBuild) {\n this.build()\n return\n }\n\n this.dataList.forEach((data) => {\n if (data.bufferList.length > 0) {\n this.updateData(what, data)\n }\n }, this)\n }\n\n updateData (what?: AtomDataFields|BondDataFields, data?: any) {\n this.build()\n }\n\n getColorParams () {\n return {\n ...super.getColorParams(),\n structure: this.structure\n }\n }\n\n getRadiusParams (param?: any) {\n return {\n type: this.radiusType,\n scale: this.radiusScale,\n size: this.radiusSize,\n data: this.radiusData\n }\n }\n\n getAtomParams (what?: AtomDataFields, params?: AtomDataParams) {\n return Object.assign({\n what: what,\n colorParams: this.getColorParams(),\n radiusParams: this.getRadiusParams()\n }, params)\n }\n\n getBondParams (what?: BondDataFields, params?: BondDataParams) {\n return Object.assign({\n what: what,\n colorParams: this.getColorParams(),\n radiusParams: this.getRadiusParams()\n }, params)\n }\n\n getAtomRadius (atom: AtomProxy) {\n if (this.structureView.atomSet!.isSet(atom.index)) {\n const radiusFactory = new RadiusFactory(this.getRadiusParams())\n return radiusFactory.atomRadius(atom)\n }\n return 0\n }\n\n /**\n * Set representation parameters\n * @alias StructureRepresentation#setSelection\n * @param {String} string - selection string, see {@tutorial selection-language}\n * @param {Boolean} [silent] - don't trigger a change event in the selection\n * @return {StructureRepresentation} this object\n */\n setSelection (string: string, silent?: boolean) {\n this.selection.setString(string, silent)\n\n return this\n }\n\n /**\n * Set representation parameters\n * @alias StructureRepresentation#setParameters\n * @param {StructureRepresentationParameters} params - structure parameter object\n * @param {Object} [what] - buffer data attributes to be updated,\n * note that this needs to be implemented in the\n * derived classes. Generally it allows more\n * fine-grained control over updating than\n * forcing a rebuild.\n * @param {Boolean} what.position - update position data\n * @param {Boolean} what.color - update color data\n * @param {Boolean} [rebuild] - whether or not to rebuild the representation\n * @return {StructureRepresentation} this object\n */\n setParameters (params: Partial, what: AtomDataFields = {}, rebuild = false) {\n const p = params || {}\n\n this.setRadius(p.radius, p)\n\n if (p.radiusType !== undefined || p.radiusData !== undefined || p.radiusSize !== undefined || p.radiusScale !== undefined) {\n what.radius = true\n if (!ExtensionFragDepth || this.disableImpostor) {\n rebuild = true\n }\n }\n\n if (p.defaultAssembly !== undefined &&\n p.defaultAssembly !== this.defaultAssembly &&\n ((this.assembly === 'default' && p.assembly === undefined) ||\n p.assembly === 'default')\n ) {\n rebuild = true\n }\n\n super.setParameters(p, what, rebuild)\n\n return this\n }\n\n getParameters () {\n const params = Object.assign(\n super.getParameters(),\n {\n sele: this.selection ? this.selection.string : undefined,\n defaultAssembly: this.defaultAssembly\n }\n )\n\n return params\n }\n\n attach (callback: ()=> void) {\n const viewer = this.viewer\n const bufferList = this.bufferList\n\n this.dataList.forEach(function (data) {\n data.bufferList.forEach(function (buffer) {\n bufferList.push(buffer)\n viewer.add(buffer, data.instanceList)\n })\n })\n\n this.setVisibility(this.visible)\n callback()\n }\n\n clear () {\n this.dataList.length = 0\n\n super.clear()\n }\n\n dispose () {\n this.structureView.dispose()\n\n super.dispose()\n }\n}\n\nexport default StructureRepresentation\n","/**\n * @file Measurement Representation\n * @author Fred Ludlow \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { Color, Vector3, Matrix4 } from 'three'\n\nimport Selection from '../selection/selection'\nimport { Browser } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport { uniformArray, uniformArray3 } from '../math/array-utils'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { LabelRepresentationParameters } from './label-representation';\nimport TextBuffer, { TextBufferData } from '../buffer/text-buffer';\nimport { GenericColor } from '../types'\n\nexport interface LabelDataField {\n position?: boolean\n labelColor?: boolean\n labelSize?: boolean\n radius?: boolean\n labelText?: boolean\n}\n\n/**\n * Measurement representation parameter object.\n * @typedef {Object} MeasurementRepresentationParameters - measurement representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n *\n * @property {Float} labelSize - size of the distance label\n * @property {Color} labelColor - color of the distance label\n * @property {Boolean} labelVisible - visibility of the distance label\n * @property {Float} labelZOffset - offset in z-direction (i.e. in camera direction)\n */\nexport interface MeasurementRepresentationParameters extends StructureRepresentationParameters {\n labelVisible: boolean\n labelSize: number\n labelColor: GenericColor\n labelType: 'atomname'|'atomindex'|'occupancy'|'bfactor'|'serial'|'element'|'atom'|'resname'|'resno'|'res'|'text'|'qualified'\n labelText: string\n labelFormat: string\n labelGrouping: 'atom'|'residue'\n labelFontFamily: 'sans-serif'|'monospace'|'serif'\n labelFontStyle: 'normal'|'italic'\n labelFontWeight: 'normal'|'bold'\n labelsdf: boolean\n labelXOffset: number\n labelYOffset: number\n labelZOffset: number\n labelAttachment: 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n labelBorder: boolean\n labelBorderColor: GenericColor\n labelBorderWidth: number\n labelBackground: boolean\n labelBackgroundColor: GenericColor\n labelBackgroundMargin: number\n labelBackgroundOpacity: number\n labelFixedSize: boolean\n lineOpacity: number\n linewidth: number\n}\n\n/**\n * Measurement representation\n * @interface\n */\nabstract class MeasurementRepresentation extends StructureRepresentation {\n protected n: number\n protected labelVisible: boolean\n protected labelSize: number\n protected labelColor: GenericColor\n protected labelType: 'atomname'|'atomindex'|'occupancy'|'bfactor'|'serial'|'element'|'atom'|'resname'|'resno'|'res'|'text'|'qualified'\n protected labelText: string\n protected labelFormat: string\n protected labelGrouping: 'atom'|'residue'\n protected labelFontFamily: 'sans-serif'|'monospace'|'serif'\n protected labelFontStyle: 'normal'|'italic'\n protected labelFontWeight: 'normal'|'bold'\n protected labelsdf: boolean\n protected labelXOffset: number\n protected labelYOffset: number\n protected labelZOffset: number\n protected labelAttachment: 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n protected labelBorder: boolean\n protected labelBorderColor: GenericColor\n protected labelBorderWidth: number\n protected labelBackground: boolean\n protected labelBackgroundColor: GenericColor\n protected labelBackgroundMargin: number\n protected labelBackgroundOpacity: number\n protected labelFixedSize: boolean\n protected lineOpacity: number\n protected linewidth: number\n protected lineVisible: boolean\n\n protected textBuffer: TextBuffer\n /**\n * Handles common label settings and position logic for\n * distance, angle and dihedral representations\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.n = 0 // Subclass create sets value\n this.parameters = Object.assign({\n labelVisible: {\n type: 'boolean'\n },\n labelSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n labelColor: {\n type: 'color'\n },\n labelFontFamily: {\n type: 'select',\n options: {\n 'sans-serif': 'sans-serif',\n 'monospace': 'monospace',\n 'serif': 'serif'\n },\n buffer: 'fontFamily'\n },\n labelFontStyle: {\n type: 'select',\n options: {\n 'normal': 'normal',\n 'italic': 'italic'\n },\n buffer: 'fontStyle'\n },\n labelFontWeight: {\n type: 'select',\n options: {\n 'normal': 'normal',\n 'bold': 'bold'\n },\n buffer: 'fontWeight'\n },\n labelsdf: {\n type: 'boolean', buffer: 'sdf'\n },\n labelXOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: 'xOffset'\n },\n labelYOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: 'yOffset'\n },\n labelZOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: 'zOffset'\n },\n labelAttachment: {\n type: 'select',\n options: {\n 'bottom-left': 'bottom-left',\n 'bottom-center': 'bottom-center',\n 'bottom-right': 'bottom-right',\n 'middle-left': 'middle-left',\n 'middle-center': 'middle-center',\n 'middle-right': 'middle-right',\n 'top-left': 'top-left',\n 'top-center': 'top-center',\n 'top-right': 'top-right'\n },\n rebuild: true\n },\n labelBorder: {\n type: 'boolean', buffer: 'showBorder'\n },\n labelBorderColor: {\n type: 'color', buffer: 'borderColor'\n },\n labelBorderWidth: {\n type: 'number', precision: 2, max: 0.3, min: 0, buffer: 'borderWidth'\n },\n labelBackground: {\n type: 'boolean', rebuild: true\n },\n labelBackgroundColor: {\n type: 'color', buffer: 'backgroundColor'\n },\n labelBackgroundMargin: {\n type: 'number', precision: 2, max: 2, min: 0, rebuild: true\n },\n labelBackgroundOpacity: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: 'backgroundOpacity'\n },\n labelFixedSize: {\n type: 'boolean', buffer: 'fixedSize'\n },\n lineOpacity: {\n type: 'range', min: 0.0, max: 1.0, step: 0.01\n },\n linewidth: {\n type: 'integer', max: 50, min: 1, buffer: true\n }\n }, this.parameters, {\n flatShaded: null\n })\n }\n\n init (params: Partial) {\n const p = params || {}\n this.labelVisible = defaults(p.labelVisible, true)\n this.labelSize = defaults(p.labelSize, 2.0)\n this.labelColor = defaults(p.labelColor, 0xFFFFFF)\n this.labelFontFamily = defaults(p.labelFontFamily, 'sans-serif')\n this.labelFontStyle = defaults(p.labelFontstyle, 'normal')\n this.labelFontWeight = defaults(p.labelFontWeight, 'bold')\n this.labelsdf = defaults(p.labelsdf, Browser === 'Chrome')\n this.labelXOffset = defaults(p.labelXOffset, 0.0)\n this.labelYOffset = defaults(p.labelYOffset, 0.0)\n this.labelZOffset = defaults(p.labelZOffset, 0.5)\n this.labelAttachment = defaults(p.labelAttachment, 'bottom-left')\n this.labelBorder = defaults(p.labelBorder, false)\n this.labelBorderColor = defaults(p.labelBorderColor, 'lightgrey')\n this.labelBorderWidth = defaults(p.labelBorderWidth, 0.15)\n this.labelBackground = defaults(p.labelBackground, false)\n this.labelBackgroundColor = defaults(p.labelBackgroundColor, 'lightgrey')\n this.labelBackgroundMargin = defaults(p.labelBackgroundMargin, 0.5)\n this.labelBackgroundOpacity = defaults(p.labelBackgroundOpacity, 1.0)\n this.labelFixedSize = defaults(p.labelFixedSize, false)\n this.lineOpacity = defaults(p.lineOpacity, 1.0)\n this.linewidth = defaults(p.linewidth, 2)\n\n super.init(p)\n }\n\n // All measurements need to rebuild on position change\n update (what: LabelDataField) {\n if (what.position) {\n this.build()\n } else {\n super.update(what)\n }\n }\n\n updateData (what: LabelDataField & {[k: string]: any}, data: any) {\n const textData: TextBufferData | {} = {}\n if (!what || what.labelSize) {\n Object.assign(textData, {size: uniformArray(this.n, this.labelSize)})\n }\n\n if (!what || what.labelColor) {\n const c = new Color(this.labelColor)\n Object.assign(textData, {color: uniformArray3(this.n, c.r, c.g, c.b)})\n }\n\n this.textBuffer.setAttributes(textData as TextBufferData)\n }\n\n setParameters (params: Partial, what: LabelDataField = {}, rebuild = false) {\n if (params && params.labelSize) {\n what.labelSize = true\n }\n\n if (params && (params.labelColor || params.labelColor === 0x000000)) {\n what.labelColor = true\n rebuild = true\n }\n\n super.setParameters(params, what, rebuild)\n\n if (params && params.opacity !== undefined) {\n this.textBuffer.setParameters({ opacity: 1.0 }) // only opaque labels\n }\n\n if (params && params.labelVisible !== undefined) {\n this.setVisibility(this.visible)\n }\n\n return this\n }\n\n setVisibility (value: boolean, noRenderRequest?: boolean) {\n super.setVisibility(value, true)\n if (this.textBuffer) {\n this.textBuffer.setVisibility(\n this.labelVisible && this.visible\n )\n }\n\n if (!noRenderRequest) this.viewer.requestRender()\n\n return this\n }\n\n getLabelBufferParams (params: Partial = {}) {\n return super.getBufferParams(Object.assign({\n fontFamily: this.labelFontFamily,\n fontStyle: this.labelFontStyle,\n fontWeight: this.labelFontWeight,\n sdf: this.labelsdf,\n xOffset: this.labelXOffset,\n yOffset: this.labelYOffset,\n zOffset: this.labelZOffset,\n attachment: this.labelAttachment,\n showBorder: this.labelBorder,\n borderColor: this.labelBorderColor,\n borderWidth: this.labelBorderWidth,\n showBackground: this.labelBackground,\n backgroundColor: this.labelBackgroundColor,\n backgroundMargin: this.labelBackgroundMargin,\n backgroundOpacity: this.labelBackgroundOpacity,\n fixedSize: this.labelFixedSize,\n disablePicking: true,\n visible: this.labelVisible\n }, params, {\n opacity: 1.0 // only opaque labels\n }))\n }\n\n getAtomRadius () {\n return 0\n }\n}\n\n/**\n * MeasurementRepresentations take atom[Pair|Triple|Quad] parameters.\n *\n * Parses nested array of either integer atom indices or selection\n * expressions into a flat array of coordinates.\n *\n * @param {Structure} sview The structure to which the atoms refer\n * @param {Array} atoms Nested array of atom pairs|triples|quads as\n * Integer indices or selection expressions\n * @return {Float32Array} Flattened array of position coordinates\n */\nfunction parseNestedAtoms (sview: StructureView, atoms: (number|string)[][]) {\n const ap = sview.getAtomProxy()\n const sele = new Selection()\n\n const nSets = atoms.length\n if (nSets === 0) return new Float32Array(0)\n\n // Peek-ahead at first item to determine order and parse mode\n const order = atoms[ 0 ].length\n const selected = sview.getAtomSet()\n\n const a = new Float32Array(nSets * order * 3)\n\n let p = 0\n atoms.forEach(function (group) {\n let _break = false\n for (let j = 0; j < order; j++) {\n const value = group[ j ]\n if (typeof (value) === 'number' && Number.isInteger(value)) {\n if (selected.get(value)) {\n ap.index = value\n } else {\n _break = true\n break\n }\n } else {\n sele.setString(value as string)\n const atomIndices = sview.getAtomIndices(sele)\n if (atomIndices!.length) {\n ap.index = atomIndices![ 0 ]\n } else {\n _break = true\n break\n }\n }\n\n let offset = p + j * 3\n a[ offset++ ] = ap.x\n a[ offset++ ] = ap.y\n a[ offset++ ] = ap.z\n }\n if (!_break) p += 3 * order\n })\n\n return a.subarray(0, p)\n}\n\n/* out = v1 * cos(angle) + v2 * sin(angle) */\nfunction calcArcPoint (out: Float32Array, center: Float32Array, v1: Float32Array, v2: Float32Array, angle: number) {\n const x = Math.cos(angle)\n const y = Math.sin(angle)\n out[ 0 ] = center[ 0 ] + v1[ 0 ] * x + v2[ 0 ] * y\n out[ 1 ] = center[ 1 ] + v1[ 1 ] * x + v2[ 1 ] * y\n out[ 2 ] = center[ 2 ] + v1[ 2 ] * x + v2[ 2 ] * y\n}\n\nexport {\n MeasurementRepresentation as default,\n calcArcPoint,\n parseNestedAtoms\n}\n","/**\n * @file Edt\n * @author Alexander Rose \n * @private\n */\n\nimport { NumberArray } from '../types'\n\n// 2D Euclidean distance transform by Felzenszwalb & Huttenlocher https://cs.brown.edu/~pff/papers/dt-final.pdf\nexport function edt(data: NumberArray, width: number, height: number, f: NumberArray, d: NumberArray, v: NumberArray, z: NumberArray) {\n for (let x = 0; x < width; x++) {\n for (let y = 0; y < height; y++) {\n f[y] = data[y * width + x]\n }\n edt1d(f, d, v, z, height)\n for (let y = 0; y < height; y++) {\n data[y * width + x] = d[y]\n }\n }\n for (let y = 0; y < height; y++) {\n for (let x = 0; x < width; x++) {\n f[x] = data[y * width + x]\n }\n edt1d(f, d, v, z, width)\n for (let x = 0; x < width; x++) {\n data[y * width + x] = Math.sqrt(d[x])\n }\n }\n}\n\n// 1D squared distance transform\nfunction edt1d(f: NumberArray, d: NumberArray, v: NumberArray, z: NumberArray, n: number) {\n v[0] = 0\n z[0] = Number.MIN_SAFE_INTEGER\n z[1] = Number.MAX_SAFE_INTEGER\n\n for (let q = 1, k = 0; q < n; q++) {\n let s = ((f[q] + q * q) - (f[v[k]] + v[k] * v[k])) / (2 * q - 2 * v[k])\n while (s <= z[k]) {\n k--\n s = ((f[q] + q * q) - (f[v[k]] + v[k] * v[k])) / (2 * q - 2 * v[k])\n }\n k++\n v[k] = q\n z[k] = s\n z[k + 1] = Number.MAX_SAFE_INTEGER\n }\n\n for (let q = 0, k = 0; q < n; q++) {\n while (z[k + 1] < q) k++\n d[q] = (q - v[k]) * (q - v[k]) + f[v[k]]\n }\n}\n","/**\n * @file Text Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { Color, CanvasTexture, Vector3, Matrix4 } from 'three'\n\nimport '../shader/SDFFont.vert'\nimport '../shader/SDFFont.frag'\n\nimport { BufferRegistry } from '../globals'\nimport { createParams } from '../utils'\nimport MappedQuadBuffer from './mappedquad-buffer'\nimport { IgnorePicker } from '../utils/picker'\nimport { edt } from '../utils/edt'\nimport { BufferDefaultParameters, BufferParameterTypes, BufferData, BufferTypes, BufferParameters } from './buffer'\nimport { GenericColor } from '../types'\n\nconst TextAtlasCache: { [k: string]: TextAtlas } = {}\n\nfunction getTextAtlas (params: Partial) {\n const hash = JSON.stringify(params)\n if (TextAtlasCache[ hash ] === undefined) {\n TextAtlasCache[ hash ] = new TextAtlas(params)\n }\n return TextAtlasCache[ hash ]\n}\n\ntype TextFonts = 'sans-serif'|'monospace'|'serif'\ntype TextStyles = 'normal'|'italic'\ntype TextVariants = 'normal'\ntype TextWeights = 'normal'|'bold'\n\nexport const TextAtlasDefaultParams = {\n font: 'sans-serif' as TextFonts,\n size: 36,\n style: 'normal' as TextStyles,\n variant: 'normal' as TextVariants,\n weight: 'normal' as TextWeights,\n outline: 3,\n width: 1024,\n height: 1024\n}\nexport type TextAtlasParams = typeof TextAtlasDefaultParams\n\nexport type TextAtlasMap = { x: number, y: number, w: number, h: number }\n\nexport class TextAtlas {\n parameters: TextAtlasParams\n\n gamma = 1\n mapped: { [k: string]: TextAtlasMap } = {}\n scratchW = 0\n scratchH = 0\n currentX = 0\n currentY = 0\n\n cutoff = 0.25\n padding: number\n radius: number\n\n gridOuter: Float64Array\n gridInner: Float64Array\n f: Float64Array\n d: Float64Array\n z: Float64Array\n v: Int16Array\n\n paddedSize: number\n middle: number\n\n texture: CanvasTexture\n canvas: HTMLCanvasElement\n context: CanvasRenderingContext2D\n\n lineHeight: number\n maxWidth: number\n colors: string[]\n scratch: Uint8Array\n canvas2: HTMLCanvasElement\n context2: CanvasRenderingContext2D\n data: Uint8Array\n\n placeholder: TextAtlasMap\n\n constructor (params: Partial = {}) {\n this.parameters = createParams(params, TextAtlasDefaultParams)\n const p = this.parameters\n\n this.radius = p.size / 8\n this.padding = p.size / 3\n\n // Prepare line-height with room for outline and descenders/ascenders\n const lineHeight = this.lineHeight = p.size + 2 * p.outline + Math.round(p.size / 4)\n const maxWidth = this.maxWidth = p.width / 4\n\n // Prepare scratch canvas\n const canvas = this.canvas = document.createElement('canvas')\n canvas.width = maxWidth\n canvas.height = lineHeight\n\n const ctx = this.context = this.canvas.getContext('2d')!\n ctx.font = `${p.style} ${p.variant} ${p.weight} ${p.size}px ${p.font}`\n ctx.fillStyle = 'black'\n ctx.textAlign = 'left'\n ctx.textBaseline = 'bottom'\n ctx.lineJoin = 'round'\n\n // temporary arrays for the distance transform\n this.gridOuter = new Float64Array(lineHeight * maxWidth)\n this.gridInner = new Float64Array(lineHeight * maxWidth)\n this.f = new Float64Array(Math.max(lineHeight, maxWidth))\n this.d = new Float64Array(Math.max(lineHeight, maxWidth))\n this.z = new Float64Array(Math.max(lineHeight, maxWidth) + 1)\n this.v = new Int16Array(Math.max(lineHeight, maxWidth))\n\n //\n this.data = new Uint8Array(p.width * p.height * 4)\n this.canvas2 = document.createElement('canvas')\n this.canvas2.width = p.width\n this.canvas2.height = p.height\n this.context2 = this.canvas2.getContext('2d')!\n\n // Replacement Character\n this.placeholder = this.map(String.fromCharCode(0xFFFD))\n\n // Basic Latin (subset)\n for (let i = 0x0020; i <= 0x007E; ++i) {\n this.map(String.fromCharCode(i))\n }\n\n // TODO: to slow to always prepare them\n // // Latin-1 Supplement (subset)\n // for (let i = 0x00A1; i <= 0x00FF; ++i) {\n // this.map(String.fromCharCode(i))\n // }\n\n // Degree sign\n this.map(String.fromCharCode(0x00B0))\n\n // // Greek and Coptic (subset)\n // for (let i = 0x0391; i <= 0x03C9; ++i) {\n // this.map(String.fromCharCode(i))\n // }\n\n // // Cyrillic (subset)\n // for (let i = 0x0400; i <= 0x044F; ++i) {\n // this.map(String.fromCharCode(i))\n // }\n\n // Angstrom Sign\n this.map(String.fromCharCode(0x212B))\n\n this.texture = new CanvasTexture(this.canvas2)\n this.texture.flipY = false\n this.texture.needsUpdate = true\n }\n\n map (text: string) {\n const p = this.parameters\n\n if (this.mapped[ text ] === undefined) {\n this.draw(text)\n\n if (this.currentX + this.scratchW > p.width) {\n this.currentX = 0\n this.currentY += this.scratchH\n }\n if (this.currentY + this.scratchH > p.height) {\n console.warn('canvas to small')\n }\n\n this.mapped[ text ] = {\n x: this.currentX,\n y: this.currentY,\n w: this.scratchW,\n h: this.scratchH\n }\n\n this.context2.drawImage(\n this.canvas,\n 0, 0,\n this.scratchW, this.scratchH,\n this.currentX, this.currentY,\n this.scratchW, this.scratchH\n )\n\n this.currentX += this.scratchW\n }\n\n return this.mapped[ text ]\n }\n\n get (text: string) {\n return this.mapped[ text ] || this.placeholder\n }\n\n draw (text: string) {\n const p = this.parameters\n\n const h = this.lineHeight\n const o = p.outline\n const ctx = this.context\n // const dst = this.scratch\n const max = this.maxWidth\n // const colors = this.colors\n\n // Bottom aligned, take outline into account\n const x = o\n const y = h - p.outline\n\n // Measure text\n const m = ctx.measureText(text)\n const w = Math.min(max, Math.ceil(m.width + 2 * x + 1))\n\n const n = w * h\n\n // Clear scratch area\n ctx.clearRect(0, 0, w, h)\n\n // Draw text\n ctx.fillText(text, x, y)\n\n const imageData = ctx.getImageData(0, 0, w, h)\n const data = imageData.data\n\n for (let i = 0; i < n; i++) {\n const a = imageData.data[i * 4 + 3] / 255; // alpha value\n this.gridOuter[i] = a === 1 ? 0 : a === 0 ? Number.MAX_SAFE_INTEGER : Math.pow(Math.max(0, 0.5 - a), 2);\n this.gridInner[i] = a === 1 ? Number.MAX_SAFE_INTEGER : a === 0 ? 0 : Math.pow(Math.max(0, a - 0.5), 2);\n }\n\n edt(this.gridOuter, w, h, this.f, this.d, this.v, this.z);\n edt(this.gridInner, w, h, this.f, this.d, this.v, this.z);\n\n for (let i = 0; i < n; i++) {\n const d = this.gridOuter[i] - this.gridInner[i];\n data[i * 4 + 3] = Math.max(0, Math.min(255, Math.round(255 - 255 * (d / this.radius + this.cutoff))));\n }\n\n ctx.putImageData(imageData, 0, 0)\n this.scratchW = w\n this.scratchH = h\n }\n}\n\n/**\n * Text buffer parameter object.\n * @typedef {Object} TextBufferParameters - text buffer parameters\n *\n * @property {Float} opacity - translucency: 1 is fully opaque, 0 is fully transparent\n * @property {Integer} clipNear - position of camera near/front clipping plane\n * in percent of scene bounding box\n * @property {String} labelType - type of the label, one of:\n * \"atomname\", \"atomindex\", \"occupancy\", \"bfactor\",\n * \"serial\", \"element\", \"atom\", \"resname\", \"resno\",\n * \"res\", \"text\", \"qualified\". When set to \"text\", the\n * `labelText` list is used.\n * @property {String[]} labelText - list of label strings, must set `labelType` to \"text\"\n * to take effect\n * @property {String} fontFamily - font family, one of: \"sans-serif\", \"monospace\", \"serif\"\n * @property {String} fontStyle - font style, \"normal\" or \"italic\"\n * @property {String} fontWeight - font weight, \"normal\" or \"bold\"\n * @property {Float} xOffset - offset in x-direction\n * @property {Float} yOffset - offset in y-direction\n * @property {Float} zOffset - offset in z-direction (i.e. in camera direction)\n * @property {String} attachment - attachment of the label, one of:\n * \"bottom-left\", \"bottom-center\", \"bottom-right\",\n * \"middle-left\", \"middle-center\", \"middle-right\",\n * \"top-left\", \"top-center\", \"top-right\"\n * @property {Boolean} showBorder - show border/outline\n * @property {Color} borderColor - color of the border/outline\n * @property {Float} borderWidth - width of the border/outline\n * @property {Boolean} showBackground - show background rectangle\n * @property {Color} backgroundColor - color of the background\n * @property {Float} backgroundMargin - width of the background\n * @property {Float} backgroundOpacity - opacity of the background\n * @property {Boolean} fixedSize - show text with a fixed pixel size\n */\n\nexport interface TextBufferData extends BufferData {\n size: Float32Array\n text: string[]\n}\n\ntype TextAttachments = 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n\nexport const TextBufferDefaultParameters = Object.assign({\n fontFamily: 'sans-serif' as TextFonts,\n fontStyle: 'normal' as TextStyles,\n fontWeight: 'bold' as TextWeights,\n fontSize: 36,\n xOffset: 0.0,\n yOffset: 0.0,\n zOffset: 0.5,\n attachment: 'bottom-left' as TextAttachments,\n showBorder: false,\n borderColor: 'lightgrey' as number|string,\n borderWidth: 0.15,\n showBackground: false,\n backgroundColor: 'lightgrey' as number|string,\n backgroundMargin: 0.5,\n backgroundOpacity: 1.0,\n forceTransparent: true,\n fixedSize: false\n}, BufferDefaultParameters)\nexport type TextBufferParameters = BufferParameters & {\n fontFamily: TextFonts,\n fontStyle: TextStyles,\n fontWeight: TextWeights,\n fontSize: number,\n xOffset: number,\n yOffset: number,\n zOffset: number,\n attachment: TextAttachments,\n showBorder: boolean,\n borderColor: GenericColor,\n borderWidth: number,\n showBackground: boolean,\n backgroundColor: GenericColor,\n backgroundMargin: number,\n backgroundOpacity: number,\n forceTransparent: boolean,\n fixedSize: boolean\n}\n\nconst TextBufferParameterTypes = Object.assign({\n fontFamily: { uniform: true },\n fontStyle: { uniform: true },\n fontWeight: { uniform: true },\n fontSize: { uniform: true },\n xOffset: { uniform: true },\n yOffset: { uniform: true },\n zOffset: { uniform: true },\n showBorder: { uniform: true },\n borderColor: { uniform: true },\n borderWidth: { uniform: true },\n backgroundColor: { uniform: true },\n backgroundOpacity: { uniform: true },\n fixedSize: { updateShader: true }\n}, BufferParameterTypes)\n\nfunction getCharCount (data: TextBufferData, params: Partial) {\n const n = data.position!.length / 3\n let charCount = 0\n for (let i = 0; i < n; ++i) {\n charCount += data.text[ i ].length\n }\n if (params.showBackground) charCount += n\n\n return charCount\n}\n\n/**\n * Text buffer. Renders screen-aligned text strings.\n *\n * @example\n * var textBuffer = new TextBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * size: new Float32Array([ 2 ]),\n * text: [ \"Hello\" ]\n * });\n */\nclass TextBuffer extends MappedQuadBuffer {\n parameterTypes = TextBufferParameterTypes\n get defaultParameters() { return TextBufferDefaultParameters }\n parameters: TextBufferParameters\n\n alwaysTransparent = true\n hasWireframe = false\n isText = true\n vertexShader = 'SDFFont.vert'\n fragmentShader = 'SDFFont.frag'\n\n text: string[]\n positionCount: number\n texture: CanvasTexture\n textAtlas: TextAtlas\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.size - sizes\n * @param {String[]} data.text - text strings\n * @param {TextBufferParameters} params - parameters object\n */\n constructor (data: TextBufferData, params: Partial = {}) {\n super({\n position: new Float32Array(getCharCount(data, params) * 3),\n color: new Float32Array(getCharCount(data, params) * 3),\n picking: new IgnorePicker()\n }, params)\n\n this.text = data.text\n this.positionCount = data.position!.length / 3\n\n this.addUniforms({\n 'fontTexture': { value: null },\n 'xOffset': { value: this.parameters.xOffset },\n 'yOffset': { value: this.parameters.yOffset },\n 'zOffset': { value: this.parameters.zOffset },\n 'ortho': { value: false },\n 'showBorder': { value: this.parameters.showBorder },\n 'borderColor': { value: new Color(this.parameters.borderColor as number) },\n 'borderWidth': { value: this.parameters.borderWidth },\n 'backgroundColor': { value: new Color(this.parameters.backgroundColor as number) },\n 'backgroundOpacity': { value: this.parameters.backgroundOpacity },\n 'canvasHeight': { value: 1.0 },\n 'pixelRatio': { value: 1.0 }\n })\n\n this.addAttributes({\n 'inputTexCoord': { type: 'v2', value: null },\n 'inputSize': { type: 'f', value: null }\n })\n\n this.setAttributes(data)\n\n this.makeTexture()\n this.makeMapping()\n }\n\n makeMaterial () {\n super.makeMaterial()\n\n const tex = this.texture\n\n const m = this.material\n m.transparent = true\n m.extensions.derivatives = true\n m.lights = false\n m.uniforms.fontTexture.value = tex\n m.needsUpdate = true\n\n const wm = this.wireframeMaterial\n wm.transparent = true\n wm.extensions.derivatives = true\n wm.lights = false\n wm.uniforms.fontTexture.value = tex\n wm.needsUpdate = true\n\n const pm = this.pickingMaterial\n pm.extensions.derivatives = true\n pm.lights = false\n pm.uniforms.fontTexture.value = tex\n pm.needsUpdate = true\n }\n\n setAttributes (data: Partial = {}) {\n let position, size, color\n let aPosition, inputSize, aColor\n\n const text = this.text\n const attributes = this.geometry.attributes as any // TODO\n\n if (data.position) {\n position = data.position\n aPosition = attributes.position.array\n attributes.position.needsUpdate = true\n }\n\n if (data.size) {\n size = data.size\n inputSize = attributes.inputSize.array\n attributes.inputSize.needsUpdate = true\n }\n\n if (data.color) {\n color = data.color\n aColor = attributes.color.array\n attributes.color.needsUpdate = true\n }\n\n const n = this.positionCount\n\n let j, o\n let iCharAll = 0\n let txt, iChar, nChar\n\n for (let v = 0; v < n; ++v) {\n o = 3 * v\n txt = text[ v ]\n nChar = txt.length\n if (this.parameters.showBackground) nChar += 1\n\n for (iChar = 0; iChar < nChar; ++iChar, ++iCharAll) {\n for (let m = 0; m < 4; m++) {\n j = iCharAll * 4 * 3 + (3 * m)\n\n if (position) {\n aPosition[ j ] = position[ o ]\n aPosition[ j + 1 ] = position[ o + 1 ]\n aPosition[ j + 2 ] = position[ o + 2 ]\n }\n\n if (size) {\n inputSize[ (iCharAll * 4) + m ] = size[ v ]\n }\n\n if (color) {\n aColor[ j ] = color[ o ]\n aColor[ j + 1 ] = color[ o + 1 ]\n aColor[ j + 2 ] = color[ o + 2 ]\n }\n }\n }\n }\n }\n\n makeTexture () {\n this.textAtlas = getTextAtlas({\n font: this.parameters.fontFamily,\n style: this.parameters.fontStyle,\n weight: this.parameters.fontWeight,\n size: this.parameters.fontSize\n })\n\n this.texture = this.textAtlas.texture\n }\n\n makeMapping () {\n const ta = this.textAtlas\n const text = this.text\n const attachment = this.parameters.attachment\n const margin = (ta.lineHeight * this.parameters.backgroundMargin * 0.1) - 10\n\n const attribs = this.geometry.attributes as any // TODO\n const inputTexCoord = attribs.inputTexCoord.array\n const inputMapping = attribs.mapping.array\n\n const n = this.positionCount\n let iCharAll = 0\n let c, i, txt, xadvance, iChar, nChar, xShift, yShift\n\n for (let v = 0; v < n; ++v) {\n txt = text[ v ]\n xadvance = 0\n nChar = txt.length\n\n // calculate width\n for (iChar = 0; iChar < nChar; ++iChar) {\n c = ta.get(txt[ iChar ])\n xadvance += c.w - 2 * ta.parameters.outline\n }\n\n // attachment\n if (attachment.startsWith('top')) {\n yShift = ta.lineHeight / 1.25\n } else if (attachment.startsWith('middle')) {\n yShift = ta.lineHeight / 2.5\n } else {\n yShift = 0 // \"bottom\"\n }\n if (attachment.endsWith('right')) {\n xShift = xadvance\n } else if (attachment.endsWith('center')) {\n xShift = xadvance / 2\n } else {\n xShift = 0 // \"left\"\n }\n xShift += ta.parameters.outline\n yShift += ta.parameters.outline\n\n // background\n if (this.parameters.showBackground) {\n i = iCharAll * 2 * 4\n inputMapping[ i + 0 ] = -ta.lineHeight / 6 - xShift - margin // top left\n inputMapping[ i + 1 ] = ta.lineHeight - yShift + margin\n inputMapping[ i + 2 ] = -ta.lineHeight / 6 - xShift - margin // bottom left\n inputMapping[ i + 3 ] = 0 - yShift - margin\n inputMapping[ i + 4 ] = xadvance + ta.lineHeight / 6 - xShift + 2 * ta.parameters.outline + margin // top right\n inputMapping[ i + 5 ] = ta.lineHeight - yShift + margin\n inputMapping[ i + 6 ] = xadvance + ta.lineHeight / 6 - xShift + 2 * ta.parameters.outline + margin // bottom right\n inputMapping[ i + 7 ] = 0 - yShift - margin\n inputTexCoord[ i + 0 ] = 10\n inputTexCoord[ i + 2 ] = 10\n inputTexCoord[ i + 4 ] = 10\n inputTexCoord[ i + 6 ] = 10\n iCharAll += 1\n }\n\n xadvance = 0\n\n for (iChar = 0; iChar < nChar; ++iChar, ++iCharAll) {\n c = ta.get(txt[ iChar ])\n i = iCharAll * 2 * 4\n\n inputMapping[ i + 0 ] = xadvance - xShift // top left\n inputMapping[ i + 1 ] = c.h - yShift\n inputMapping[ i + 2 ] = xadvance - xShift // bottom left\n inputMapping[ i + 3 ] = 0 - yShift\n inputMapping[ i + 4 ] = xadvance + c.w - xShift // top right\n inputMapping[ i + 5 ] = c.h - yShift\n inputMapping[ i + 6 ] = xadvance + c.w - xShift // bottom right\n inputMapping[ i + 7 ] = 0 - yShift\n\n const texWidth = ta.parameters.width\n const texHeight = ta.parameters.height\n\n const texCoords = [\n c.x / texWidth, c.y / texHeight, // top left\n c.x / texWidth, (c.y + c.h) / texHeight, // bottom left\n (c.x + c.w) / texWidth, c.y / texHeight, // top right\n (c.x + c.w) / texWidth, (c.y + c.h) / texHeight // bottom right\n ]\n inputTexCoord.set(texCoords, i)\n\n xadvance += c.w - 2 * ta.parameters.outline\n }\n }\n\n attribs.inputTexCoord.needsUpdate = true\n attribs.mapping.needsUpdate = true\n }\n\n getDefines (type: BufferTypes) {\n const defines = super.getDefines(type)\n\n if (this.parameters.fixedSize) {\n defines.FIXED_SIZE = 1\n }\n\n return defines\n }\n\n setUniforms (data: any) { // TODO\n if (data && (\n data.fontFamily !== undefined ||\n data.fontStyle !== undefined ||\n data.fontWeight !== undefined ||\n data.fontSize !== undefined\n )) {\n this.makeTexture()\n this.makeMapping()\n this.texture.needsUpdate = true\n data.fontTexture = this.texture\n }\n\n super.setUniforms(data)\n }\n}\n\nBufferRegistry.add('text', TextBuffer)\n\nexport default TextBuffer\n","/**\n * @file Wide Line Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3 required for declaration only\nimport { Vector2, Vector3, Matrix4 } from 'three'\n\nimport '../shader/WideLine.vert'\nimport '../shader/WideLine.frag'\n\nimport { BufferRegistry } from '../globals'\nimport MappedQuadBuffer from './mappedquad-buffer'\nimport { BufferDefaultParameters, BufferParameterTypes, BufferData, BufferParameters } from './buffer'\n\nexport interface WideLineBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n color2: Float32Array\n}\n\nexport const WideLineBufferDefaultParameters = Object.assign({\n linewidth: 2\n}, BufferDefaultParameters)\nexport type WideLineBufferParameters = BufferParameters & { linewidth: number }\n\nconst WideLineBufferParameterTypes = Object.assign({\n linewidth: { uniform: true }\n}, BufferParameterTypes)\n\n/**\n * Wide Line buffer. Draws lines with a fixed width in pixels.\n *\n * @example\n * var lineBuffer = new WideLineBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ])\n * });\n */\nclass WideLineBuffer extends MappedQuadBuffer {\n parameterTypes = WideLineBufferParameterTypes\n get defaultParameters() { return WideLineBufferDefaultParameters }\n parameters: WideLineBufferParameters\n\n vertexShader = 'WideLine.vert'\n fragmentShader ='WideLine.frag'\n\n constructor (data: Partial, params: Partial = {}) {\n super(data, params)\n\n if (!data.color2 && data.color) data.color2 = data.color\n\n this.addUniforms({\n 'linewidth': { value: this.parameters.linewidth },\n 'resolution': { value: new Vector2() },\n 'projectionMatrixInverse': { value: new Matrix4() }\n })\n\n this.addAttributes({\n 'position1': { type: 'v3', value: null },\n 'position2': { type: 'v3', value: null },\n 'color2': { type: 'c', value: null }\n })\n\n this.setAttributes(data)\n this.makeMapping()\n }\n\n setParameters (params: Partial) {\n super.setParameters(params)\n }\n}\n\nBufferRegistry.add('wideline', WideLineBuffer)\n\nexport default WideLineBuffer\n","/**\n * @file Angle Representation\n * @author Fred Ludlow \n * @private\n */\nimport { Color } from 'three'\n\nimport { RepresentationRegistry } from '../globals'\nimport MeasurementRepresentation, { parseNestedAtoms, calcArcPoint, MeasurementRepresentationParameters, LabelDataField } from './measurement-representation'\nimport { defaults } from '../utils'\n\nimport MeshBuffer from '../buffer/mesh-buffer'\nimport TextBuffer, { TextBufferData, TextBufferParameters } from '../buffer/text-buffer'\nimport WideLineBuffer, { WideLineBufferData } from '../buffer/wideline-buffer'\n\nimport { v3add, v3cross, v3dot, v3fromArray, v3length, v3new,\n v3normalize, v3sub, v3toArray } from '../math/vector-utils'\nimport { copyArray, uniformArray, uniformArray3 } from '../math/array-utils'\nimport { RAD2DEG } from '../math/math-constants'\nimport { getFixedLengthWrappedDashData } from '../geometry/dash'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { BufferData } from '../buffer/buffer';\nimport { StructureRepresentationData, StructureRepresentationParameters } from './structure-representation';\n\n/**\n * @typedef {Object} AngleRepresentationParameters - angle representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n * @mixes MeasurementRepresentationParameters\n *\n * @property {String} atomTriple - list of triplets of selection strings\n * or atom indices\n * @property {Boolean} vectorVisible - Indicate the 3 points for each angle by drawing lines 1-2-3\n * @property {Boolean} arcVisible - Show the arc outline for each angle\n * @property {Number} lineOpacity - opacity for the line part of the representation\n * @property {Number} linewidth - width for line part of representation\n * @property {Boolean} sectorVisible - Show the filled arc for each angle\n */\n\nexport interface AngleRepresentationParameters extends MeasurementRepresentationParameters {\n atomTriple: (number|string)[][]\n vectorVisible: boolean\n arcVisible: boolean\n lineOpacity: number\n lineWidth: number\n sectorVisible: boolean\n}\n\n/**\n * Angle representation object\n *\n * Reperesentation consists of four parts, visibility can be set for each\n * label - the text label with the angle size\n * vectors - lines joining the three points\n * sector - triangles representing the angle\n * arc - line bordering the sector\n *\n * @param {Structure} structure - the structure to measure angles in\n * @param {Viewer} viewer - a viewer object\n * @param {AngleRepresentationParameters} params - angle representation parameters\n */\nclass AngleRepresentation extends MeasurementRepresentation {\n protected atomTriple: (number|string)[][]\n protected vectorVisible: boolean\n protected arcVisible: boolean\n protected lineOpacity: number\n protected lineWidth: number\n protected sectorVisible: boolean\n protected vectorBuffer: WideLineBuffer\n arcLength: number\n sectorLength: number\n arcBuffer: WideLineBuffer\n sectorBuffer: MeshBuffer\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'angle'\n\n this.parameters = Object.assign({\n atomTriple: {\n type: 'hidden', rebuild: true\n },\n vectorVisible: {\n type: 'boolean', default: true\n },\n arcVisible: {\n type: 'boolean', default: true\n },\n sectorVisible: {\n type: 'boolean', default: true\n }\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.side = defaults(p.side, 'double')\n p.opacity = defaults(p.opacity, 0.5)\n\n this.atomTriple = defaults(p.atomTriple, [])\n this.arcVisible = defaults(p.arcVisible, true)\n this.sectorVisible = defaults(p.sectorVisible, true)\n this.vectorVisible = defaults(p.vectorVisible, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n if (!sview.atomCount || !this.atomTriple.length) return\n\n const atomPosition = atomTriplePositions(sview, this.atomTriple)\n const angleData = getAngleData(atomPosition)\n const n = this.n = angleData.labelPosition.length / 3\n\n const labelColor = new Color(this.labelColor)\n\n // Create buffers\n this.textBuffer = new TextBuffer({\n position: angleData.labelPosition,\n size: uniformArray(n, this.labelSize),\n color: uniformArray3(n, labelColor.r, labelColor.g, labelColor.b),\n text: angleData.labelText\n } as TextBufferData, this.getLabelBufferParams() as TextBufferParameters)\n\n const c = new Color(this.colorValue)\n\n this.vectorBuffer = new WideLineBuffer(\n getFixedLengthWrappedDashData({\n position1: angleData.vectorPosition1,\n position2: angleData.vectorPosition2,\n color: uniformArray3(2 * n, c.r, c.g, c.b),\n color2: uniformArray3(2 * n, c.r, c.g, c.b)\n } as WideLineBufferData),\n this.getBufferParams({\n linewidth: this.linewidth,\n visible: this.vectorVisible,\n opacity: this.lineOpacity\n })\n )\n\n this.arcLength = angleData.arcPosition1.length / 3\n\n this.arcBuffer = new WideLineBuffer(\n getFixedLengthWrappedDashData({\n position1: angleData.arcPosition1,\n position2: angleData.arcPosition2,\n color: uniformArray3(this.arcLength, c.r, c.g, c.b),\n color2: uniformArray3(this.arcLength, c.r, c.g, c.b)\n } as WideLineBufferData), this.getBufferParams({\n linewidth: this.linewidth,\n visible: this.arcVisible,\n opacity: this.lineOpacity\n }))\n\n this.sectorLength = angleData.sectorPosition.length / 3\n\n this.sectorBuffer = new MeshBuffer({\n position: angleData.sectorPosition,\n color: uniformArray3(this.sectorLength, c.r, c.g, c.b)\n } as BufferData, this.getBufferParams({\n visible: this.sectorVisible\n }))\n\n return {\n bufferList: [\n this.textBuffer,\n this.vectorBuffer,\n this.arcBuffer,\n this.sectorBuffer\n ]\n }\n }\n\n updateData (what: LabelDataField & {color?: boolean}, data: StructureRepresentationData) {\n super.updateData(what, data)\n const vectorData = {}\n const arcData = {}\n const sectorData = {}\n\n if (what.color) {\n const c = new Color(this.colorValue)\n Object.assign(vectorData, {\n color: uniformArray3(this.n * 2, c.r, c.g, c.b),\n color2: uniformArray3(this.n * 2, c.r, c.g, c.b)\n })\n Object.assign(arcData, {\n color: uniformArray3(this.arcLength, c.r, c.g, c.b),\n color2: uniformArray3(this.arcLength, c.r, c.g, c.b)\n })\n Object.assign(sectorData, {\n color: uniformArray3(this.sectorLength, c.r, c.g, c.b)\n })\n }\n\n // if (what.sectorOpacity) {\n // this.sectorBuffer.opacity = what.sectorOpacity\n // }\n\n this.vectorBuffer.setAttributes(vectorData)\n this.arcBuffer.setAttributes(arcData)\n this.sectorBuffer.setAttributes(sectorData)\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n super.setParameters(params, what, rebuild)\n\n if (params && (\n params.vectorVisible !== undefined ||\n params.arcVisible !== undefined ||\n params.sectorVisible !== undefined)) {\n this.setVisibility(this.visible)\n }\n\n if (params && params.lineOpacity) {\n this.vectorBuffer.setParameters({ opacity: params.lineOpacity })\n this.arcBuffer.setParameters({ opacity: params.lineOpacity })\n }\n\n if (params && params.opacity !== undefined) {\n this.vectorBuffer.setParameters({ opacity: this.lineOpacity })\n this.arcBuffer.setParameters({ opacity: this.lineOpacity })\n }\n\n if (params && params.linewidth) {\n this.vectorBuffer.setParameters({ linewidth: params.linewidth })\n this.arcBuffer.setParameters({ linewidth: params.linewidth })\n }\n\n return this\n }\n\n setVisibility (value: boolean, noRenderRequest?: boolean) {\n super.setVisibility(value, true)\n\n if (this.vectorBuffer) {\n this.vectorBuffer.setVisibility(this.vectorVisible && this.visible)\n }\n\n if (this.arcBuffer) {\n this.arcBuffer.setVisibility(this.arcVisible && this.visible)\n }\n\n if (this.sectorBuffer) {\n this.sectorBuffer.setVisibility(this.sectorVisible && this.visible)\n }\n\n if (!noRenderRequest) this.viewer.requestRender()\n\n return this\n }\n}\n\n/**\n * Ensure mid point does not coincide with first or second\n * @param {Float32Array} position 9*nAngle array of coordinates\n * @return {Float32Array} Filtered position array, may be shorter\n */\nfunction validatePositions (position: Float32Array) {\n const include = []\n const n = position.length / 9\n for (let i = 0; i < n; i++) {\n // Check that first point not same as second and that second not same as third\n let okay = true\n for (let j = i; j < i + 3; j += 3) {\n if (position[j] === position[j + 3] &&\n position[j + 1] === position[j + 4] &&\n position[j + 2] === position[j + 5]) {\n okay = false\n }\n }\n if (okay) include.push(i)\n }\n const outPosition = new Float32Array(include.length * 9)\n let outIdx = 0\n include.forEach(function (i) {\n copyArray(position, outPosition, i * 9, outIdx * 9, 9)\n outIdx++\n })\n return outPosition\n}\n\nfunction atomTriplePositions (sview: StructureView, atomTriple: (number|string)[][]) {\n return validatePositions(parseNestedAtoms(sview, atomTriple))\n}\n\n/**\n * Converts triple positions into data required to build various buffers.\n */\nfunction getAngleData (position: Float32Array, params: Partial = {}) {\n const angleStep = defaults(params.angleStep, Math.PI / 90)\n const n = position.length / 9\n const angles = new Float32Array(n)\n const labelPosition = new Float32Array(n * 3)\n const labelText = new Array(n)\n\n const vectorPosition1 = new Float32Array(n * 6) // Two lines per angle\n const vectorPosition2 = new Float32Array(n * 6)\n\n const arcPositionTmp1 = new Array(n) // Start points for arc lines\n const arcPositionTmp2 = new Array(n) // End points for arc lines\n const sectorPositionTmp = new Array(n) // Triangle points\n\n let totalSegments = 0\n\n // Re-used vectors etc\n const p1 = v3new() // Positions of points for each angel\n const p2 = v3new()\n const p3 = v3new()\n const v21 = v3new() // Vectors\n const v23 = v3new()\n const cross = v3new() // Cross product v21xv23\n const cross2 = v3new() // In-plane cross product v21 x (v21 x v23)\n const labelTmp = v3new()\n const arcPoint = v3new()\n\n for (var i = 0; i < n; i++) {\n let p = 9 * i\n v3fromArray(p1, position, p)\n v3fromArray(p2, position, p + 3)\n v3fromArray(p3, position, p + 6)\n\n let v = 6 * i\n v3toArray(p1, vectorPosition1, v)\n v3toArray(p2, vectorPosition2, v)\n v3toArray(p2, vectorPosition1, v + 3)\n v3toArray(p3, vectorPosition2, v + 3)\n\n v3sub(v21, p1, p2)\n v3sub(v23, p3, p2)\n\n v3normalize(v21, v21) // validatePositions ensures valid\n v3normalize(v23, v23)\n\n v3cross(cross, v21, v23)\n const crossLength = v3length(cross)\n const dot = v3dot(v21, v23)\n\n const angle = angles[i] = Math.atan2(crossLength, dot)\n labelText[i] = (RAD2DEG * angle).toFixed(1) + String.fromCharCode(0x00B0)\n\n if (v3length(cross) === 0.0) {\n // Angle exactly 0/180, pick an arbitrary direction\n cross[ 0 ] = 1.0\n cross[ 1 ] = 0.0\n cross[ 2 ] = 0.0\n }\n v3cross(cross2, cross, v21)\n v3normalize(cross2, cross2)\n\n calcArcPoint(labelTmp, p2, v21, cross2, angle / 2.0)\n // TODO: Scale label position?\n v3toArray(labelTmp, labelPosition, 3 * i)\n\n // Build the arc and sector\n\n const nSegments = Math.ceil(angle / angleStep)\n const sectorVertices = new Float32Array(nSegments * 9)\n sectorPositionTmp[ i ] = sectorVertices\n const arcVertices1 = new Float32Array(nSegments * 3)\n const arcVertices2 = new Float32Array(nSegments * 3)\n arcPositionTmp1[ i ] = arcVertices1\n arcPositionTmp2[ i ] = arcVertices2\n\n v3add(arcPoint, p2, v21) // Our initial arc point\n\n const appendArcSection = function (a: number, j: number) {\n const si = j * 9\n const ai = j * 3\n v3toArray(p2, sectorVertices, si)\n v3toArray(arcPoint, sectorVertices, si + 3)\n v3toArray(arcPoint, arcVertices1, ai)\n\n calcArcPoint(arcPoint, p2, v21, cross2, a)\n\n v3toArray(arcPoint, sectorVertices, si + 6)\n v3toArray(arcPoint, arcVertices2, ai)\n }\n\n let j = 0\n for (let a = angleStep; a < angle; a += angleStep) {\n appendArcSection(a, j)\n j++\n }\n appendArcSection(angle, j)\n totalSegments += nSegments\n }\n\n // Flatten nested arrays of arc/segment points\n const arcSize = totalSegments * 3\n const sectorSize = totalSegments * 9\n const arcPosition1 = new Float32Array(arcSize)\n const arcPosition2 = new Float32Array(arcSize)\n const sectorPosition = new Float32Array(sectorSize)\n\n let sectorOffset = 0\n let arcOffset = 0\n for (let i = 0; i < n; i++) {\n const ap1 = arcPositionTmp1[ i ]\n const ap2 = arcPositionTmp2[ i ]\n copyArray(ap1, arcPosition1, 0, arcOffset, ap1.length)\n copyArray(ap2, arcPosition2, 0, arcOffset, ap2.length)\n arcOffset += ap1.length // === ap2.length\n\n const sp = sectorPositionTmp[ i ]\n copyArray(sp, sectorPosition, 0, sectorOffset, sp.length)\n sectorOffset += sp.length\n }\n\n return {\n labelPosition,\n labelText,\n vectorPosition1,\n vectorPosition2,\n arcPosition1,\n arcPosition2,\n sectorPosition\n }\n}\n\nRepresentationRegistry.add('angle', AngleRepresentation)\n\nexport default AngleRepresentation\n","/**\n * @file Cylinder Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3, CylinderBufferGeometry } from 'three'\n\nimport { defaults } from '../utils'\nimport { calculateCenterArray, serialBlockArray } from '../math/array-utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { CylinderBufferData } from './cylinder-buffer'\nimport { BufferDefaultParameters, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\nconst eye = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3(0, 1, 0)\n\nexport const CylinderGeometryBufferDefaultParameters = Object.assign({\n radialSegments: 1,\n openEnded: true\n}, BufferDefaultParameters)\nexport type CylinderGeometryBufferParameters = BufferParameters & {radialSegments: number, openEnded: boolean}\n\nfunction getData (data: CylinderBufferData, params: Partial = {}) {\n const geo = getGeo(params)\n\n const n = data.position1.length\n\n const geoLength = (geo.attributes as any).position.array.length / 3\n const count = n / 3\n const primitiveId = new Float32Array(count * 2 * geoLength)\n serialBlockArray(count, geoLength, 0, primitiveId)\n serialBlockArray(count, geoLength, count * geoLength, primitiveId)\n\n const position = new Float32Array(n * 2)\n const color = new Float32Array(n * 2)\n\n return {\n position, color, primitiveId, picking: data.picking\n }\n}\n\nfunction getGeo (params: Partial = {}) {\n const radialSegments = defaults(params.radialSegments, 10)\n const openEnded = defaults(params.openEnded, true)\n const matrix = new Matrix4().makeRotationX(Math.PI / 2)\n\n const geo = new CylinderBufferGeometry(\n 1, // radiusTop,\n 1, // radiusBottom,\n 1, // height,\n radialSegments, // radialSegments,\n 1, // heightSegments,\n openEnded // openEnded\n )\n geo.applyMatrix4(matrix)\n\n return geo\n}\n\n/**\n * Cylinder geometry buffer.\n *\n * @example\n * var cylinderGeometryBuffer = new CylinderGeometryBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass CylinderGeometryBuffer extends GeometryBuffer {\n updateNormals = true\n\n get defaultParameters() { return CylinderGeometryBufferDefaultParameters }\n parameters: CylinderGeometryBufferParameters\n\n __center: Float32Array\n _position: Float32Array\n _color: Float32Array\n _from: Float32Array\n _to: Float32Array\n _radius: Float32Array\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - from colors\n * @param {Float32Array} data.color2 - to colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n */\n constructor (data: CylinderBufferData, params: Partial = {}) {\n super(getData(data, params), params, getGeo(params))\n\n const n = data.position1.length\n const m = data.radius.length\n\n this.__center = new Float32Array(n)\n this._position = new Float32Array(n * 2)\n this._color = new Float32Array(n * 2)\n this._from = new Float32Array(n * 2)\n this._to = new Float32Array(n * 2)\n this._radius = new Float32Array(m * 2)\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n eye.fromArray(this._from as any, i3)\n target.fromArray(this._to as any, i3)\n matrix.lookAt(eye, target, up)\n\n const r = this._radius[ i ]\n scale.set(r, r, eye.distanceTo(target))\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n const meshData: Partial = {}\n\n if (data.position1 && data.position2) {\n calculateCenterArray(\n data.position1, data.position2, this.__center\n )\n calculateCenterArray(\n data.position1, this.__center, this._position\n )\n calculateCenterArray(\n this.__center, data.position2, this._position, data.position1.length\n )\n this._from.set(data.position1)\n this._from.set(this.__center, data.position1.length)\n this._to.set(this.__center)\n this._to.set(data.position2, this.__center.length)\n meshData.position = this._position\n }\n\n if (data.color && data.color2) {\n this._color.set(data.color)\n this._color.set(data.color2, data.color.length)\n meshData.color = this._color\n }\n\n if (data.radius) {\n this._radius.set(data.radius)\n this._radius.set(data.radius, data.radius.length)\n meshData.radius = this._radius\n }\n\n super.setAttributes(meshData, initNormals)\n }\n}\n\nexport default CylinderGeometryBuffer\n","/**\n * @file Mapped Aligned Box Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { BufferParameters, BufferData } from './buffer'\nimport MappedBuffer from './mapped-buffer'\n\n// +Y /\n// 0**********2\n// * | / **\n// * |/ * *\n// -----------3---- +X\n// * /| * *\n// * / | * *\n// 1/**|******4\n// / | * *\n// / | ** \n// +Z | 5 \nconst mapping = new Float32Array([\n -1.0, 1.0, -1.0,\n -1.0, -1.0, -1.0,\n 1.0, 1.0, -1.0,\n 1.0, 1.0, 1.0,\n 1.0, -1.0, -1.0,\n 1.0, -1.0, 1.0\n])\n\nconst mappingIndices = new Uint16Array([\n 0, 1, 2,\n 1, 4, 2,\n 2, 4, 3,\n 4, 5, 3\n])\n\n/**\n * Mapped Aligned box buffer. Draws boxes where one side is always screen-space aligned.\n * Used to render cylinder imposters.\n * @interface\n */\nclass MappedAlignedBoxBuffer extends MappedBuffer {\n constructor(data: BufferData, params: Partial = {}) {\n super('v3', data, params)\n }\n get mapping () { return mapping }\n get mappingIndices () { return mappingIndices }\n get mappingIndicesSize () { return 12 }\n get mappingSize () { return 6 }\n get mappingItemSize () { return 3 }\n}\n\nexport default MappedAlignedBoxBuffer\n","/**\n * @file Cylinder Impostor Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3 required for declaration only\nimport { Matrix4, Vector3 } from 'three'\n\nimport '../shader/CylinderImpostor.vert'\nimport '../shader/CylinderImpostor.frag'\n\nimport MappedAlignedBoxBuffer from './mappedalignedbox-buffer'\nimport { BufferDefaultParameters, BufferParameters, BufferParameterTypes, BufferTypes } from './buffer'\nimport { CylinderBufferData } from './cylinder-buffer'\n\nexport const CylinderImpostorBufferDefaultParameters = Object.assign({\n openEnded: false\n}, BufferDefaultParameters)\nexport type CylinderImpostorBufferParameters = BufferParameters & { openEnded: boolean }\n\nconst CylinderImpostorBufferParameterTypes = Object.assign({\n openEnded: { updateShader: true }\n}, BufferParameterTypes)\n\n/**\n * Cylinder impostor buffer.\n *\n * @example\n * var cylinderimpostorBuffer = new CylinderImpostorBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass CylinderImpostorBuffer extends MappedAlignedBoxBuffer {\n parameterTypes = CylinderImpostorBufferParameterTypes\n get defaultParameters() { return CylinderImpostorBufferDefaultParameters }\n parameters: CylinderImpostorBufferParameters\n\n isImpostor = true\n vertexShader = 'CylinderImpostor.vert'\n fragmentShader = 'CylinderImpostor.frag'\n\n /**\n * make cylinder impostor buffer\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - from colors\n * @param {Float32Array} data.color2 - to colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} data.picking - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: CylinderBufferData, params: Partial = {}) {\n super(data, params)\n\n this.addUniforms({\n 'modelViewMatrixInverse': { value: new Matrix4() },\n 'ortho': { value: 0.0 }\n })\n\n this.addAttributes({\n 'position1': { type: 'v3', value: null },\n 'position2': { type: 'v3', value: null },\n 'color2': { type: 'c', value: null },\n 'radius': { type: 'f', value: null }\n })\n\n this.setAttributes(data)\n this.makeMapping()\n }\n\n getDefines (type?: BufferTypes) {\n const defines = MappedAlignedBoxBuffer.prototype.getDefines.call(this, type)\n\n if (!this.parameters.openEnded) {\n defines.CAP = 1\n }\n\n return defines\n }\n}\n\nexport default CylinderImpostorBuffer\n","/**\n * @file Cylinder Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import required for declaration only\nimport { Vector3, Matrix4 } from 'three'\nimport { BufferRegistry, ExtensionFragDepth } from '../globals'\nimport CylinderGeometryBuffer, { CylinderGeometryBufferDefaultParameters, CylinderGeometryBufferParameters } from './cylindergeometry-buffer'\nimport CylinderImpostorBuffer, { CylinderImpostorBufferDefaultParameters, CylinderImpostorBufferParameters } from './cylinderimpostor-buffer'\nimport { BufferData } from './buffer'\n\nexport interface CylinderBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n color2: Float32Array\n radius: Float32Array\n}\n\nexport const CylinderBufferDefaultParameters = Object.assign({\n disableImpostor: false\n}, CylinderGeometryBufferDefaultParameters, CylinderImpostorBufferDefaultParameters)\nexport type CylinderBufferParameters = (CylinderGeometryBufferParameters & {disableImpostor: boolean}) | (CylinderImpostorBufferParameters & {disableImpostor: boolean})\n\nclass CylinderBufferImpl {\n constructor (data: CylinderBufferData, params: Partial = {}) {\n if (!data.color2 && data.color) data.color2 = data.color\n if (!ExtensionFragDepth || (params && params.disableImpostor)) {\n return new CylinderGeometryBuffer(data, params)\n } else {\n return new CylinderImpostorBuffer(data, params)\n }\n }\n}\n\n/**\n * Cylinder buffer. Depending on the value {@link ExtensionFragDepth} and\n * `params.disableImpostor` the constructor returns either a\n * {@link CylinderGeometryBuffer} or a {@link CylinderImpostorBuffer}\n * @implements {Buffer}\n *\n * @example\n * var cylinderBuffer = new CylinderBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\n//@ts-expect-error Incompatible constructor signatures\nconst CylinderBuffer: {\n new(data: CylinderBufferData, params: Partial): CylinderGeometryBuffer | CylinderImpostorBuffer;\n} = CylinderBufferImpl;\n\ntype CylinderBuffer = CylinderGeometryBuffer | CylinderImpostorBuffer;\n\nBufferRegistry.add('cylinder', CylinderBuffer)\n\nexport default CylinderBuffer\n","/**\n * @file Axes Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { Color, Vector3 } from 'three'\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { AxesPicker } from '../utils/picker'\nimport { uniformArray, uniformArray3 } from '../math/array-utils'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport CylinderBuffer, { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport StructureView from '../structure/structure-view';\nimport Viewer from '../viewer/viewer';\nimport { Structure } from '../ngl';\nimport { AtomDataFields } from '../structure/structure-data';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport PrincipalAxes from '../math/principal-axes';\n\nexport interface AxesRepresentationParameters extends StructureRepresentationParameters {\n showAxes: boolean\n showBox: boolean\n}\n\n/**\n * Axes representation. Show principal axes and/or a box aligned with them\n * that fits the structure or selection.\n *\n * __Name:__ _axes_\n *\n * @example\n * stage.loadFile( \"rcsb://3pqr\", {\n * assembly: \"BU1\"\n * } ).then( function( o ){\n * o.addRepresentation( \"cartoon\" );\n * o.addRepresentation( \"axes\", {\n * sele: \"RET\", showAxes: false, showBox: true, radius: 0.2\n * } );\n * o.addRepresentation( \"ball+stick\", { sele: \"RET\" } );\n * o.addRepresentation( \"axes\", {\n * sele: \":B and backbone\", showAxes: false, showBox: true, radius: 0.2\n * } );\n * stage.autoView();\n * var pa = o.structure.getPrincipalAxes();\n * stage.animationControls.rotate( pa.getRotationQuaternion(), 1500 );\n * } );\n */\nclass AxesRepresentation extends StructureRepresentation {\n \n protected showAxes: boolean\n protected showBox: boolean\n protected sphereBuffer: SphereBuffer\n protected cylinderBuffer: CylinderBuffer\n /**\n * @param {Structure} structure - the structure object\n * @param {Viewer} viewer - the viewer object\n * @param {StructureRepresentationParameters} params - parameters object\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'axes'\n\n this.parameters = Object.assign({\n\n radiusSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n sphereDetail: true,\n radialSegments: true,\n disableImpostor: true,\n showAxes: {\n type: 'boolean', rebuild: true\n },\n showBox: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n assembly: null\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.radiusSize = defaults(p.radiusSize, 0.5)\n p.colorValue = defaults(p.colorValue, 'lightgreen')\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.showAxes = defaults(p.showAxes, true)\n this.showBox = defaults(p.showBox, false)\n\n super.init(p)\n }\n\n getPrincipalAxes (): PrincipalAxes {\n let selection\n const assembly = this.getAssembly()\n\n if (assembly) {\n selection = assembly.partList[ 0 ].getSelection()\n }\n\n return this.structureView.getPrincipalAxes(selection)\n }\n\n getAxesData (sview: StructureView) {\n const pa = this.getPrincipalAxes()\n const c = new Color(this.colorValue)\n\n let vn = 0\n let en = 0\n\n if (this.showAxes) {\n vn += 6\n en += 3\n }\n\n if (this.showBox) {\n vn += 8\n en += 12\n }\n\n const vertexPosition = new Float32Array(3 * vn)\n const vertexColor = uniformArray3(vn, c.r, c.g, c.b)\n const vertexRadius = uniformArray(vn, this.radiusSize)\n\n const edgePosition1 = new Float32Array(3 * en)\n const edgePosition2 = new Float32Array(3 * en)\n const edgeColor = uniformArray3(en, c.r, c.g, c.b)\n const edgeRadius = uniformArray(en, this.radiusSize)\n\n let offset = 0\n\n if (this.showAxes) {\n const addAxis = function (v1: Vector3, v2: Vector3) {\n v1.toArray(vertexPosition as any, offset * 2)\n v2.toArray(vertexPosition as any, offset * 2 + 3)\n v1.toArray(edgePosition1 as any, offset)\n v2.toArray(edgePosition2 as any, offset)\n offset += 3\n }\n\n addAxis(pa.begA, pa.endA)\n addAxis(pa.begB, pa.endB)\n addAxis(pa.begC, pa.endC)\n }\n\n if (this.showBox) {\n const v = new Vector3()\n const { d1a, d2a, d3a, d1b, d2b, d3b } = pa.getProjectedScaleForAtoms(sview)\n\n // console.log(d1a, d2a, d3a, d1b, d2b, d3b)\n\n let offset2 = offset * 2\n const addCorner = function (d1: number, d2: number, d3: number) {\n v.copy(pa.center)\n .addScaledVector(pa.normVecA, d1)\n .addScaledVector(pa.normVecB, d2)\n .addScaledVector(pa.normVecC, d3)\n v.toArray(vertexPosition as any, offset2)\n offset2 += 3\n }\n addCorner(d1a, d2a, d3a)\n addCorner(d1a, d2a, d3b)\n addCorner(d1a, d2b, d3b)\n addCorner(d1a, d2b, d3a)\n addCorner(d1b, d2b, d3b)\n addCorner(d1b, d2b, d3a)\n addCorner(d1b, d2a, d3a)\n addCorner(d1b, d2a, d3b)\n\n let edgeOffset = offset\n const addEdge = function (a: number, b: number) {\n v.fromArray(vertexPosition as any, offset * 2 + a * 3)\n .toArray(edgePosition1 as any, edgeOffset)\n v.fromArray(vertexPosition as any, offset * 2 + b * 3)\n .toArray(edgePosition2 as any, edgeOffset)\n edgeOffset += 3\n }\n addEdge(0, 1)\n addEdge(0, 3)\n addEdge(0, 6)\n addEdge(1, 2)\n addEdge(1, 7)\n addEdge(2, 3)\n addEdge(2, 4)\n addEdge(3, 5)\n addEdge(4, 5)\n addEdge(4, 7)\n addEdge(5, 6)\n addEdge(6, 7)\n }\n\n const picker = new AxesPicker(pa)\n\n return {\n vertex: {\n position: vertexPosition,\n color: vertexColor,\n radius: vertexRadius,\n picking: picker\n },\n edge: {\n position1: edgePosition1,\n position2: edgePosition2,\n color: edgeColor,\n color2: edgeColor,\n radius: edgeRadius,\n picking: picker\n }\n }\n }\n\n create () {\n const axesData = this.getAxesData(this.structureView)\n\n this.sphereBuffer = new SphereBuffer(\n axesData.vertex as SphereBufferData,\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters\n )\n\n this.cylinderBuffer = new CylinderBuffer(\n axesData.edge as CylinderBufferData,\n this.getBufferParams({\n openEnded: true,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n this.dataList.push({\n sview: this.structureView,\n bufferList: [ this.sphereBuffer as SphereGeometryBuffer, this.cylinderBuffer as CylinderGeometryBuffer]\n })\n }\n\n createData (sview: StructureView): undefined {\n return\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n const axesData = this.getAxesData(data.sview as StructureView)\n const sphereData = {}\n const cylinderData = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {\n position: axesData.vertex.position\n })\n Object.assign(cylinderData, {\n position1: axesData.edge.position1,\n position2: axesData.edge.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {\n color: axesData.vertex.color as Float32Array\n })\n Object.assign(cylinderData, {\n color: axesData.edge.color as Float32Array,\n color2: axesData.edge.color as Float32Array\n })\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {\n radius: axesData.vertex.radius as Float32Array\n })\n Object.assign(cylinderData, {\n radius: axesData.edge.radius as Float32Array\n })\n }\n\n (this.sphereBuffer as SphereGeometryBuffer).setAttributes(sphereData);\n (this.cylinderBuffer as CylinderGeometryBuffer).setAttributes(cylinderData)\n }\n}\n\nRepresentationRegistry.add('axes', AxesRepresentation)\n\nexport default AxesRepresentation\n","/**\n * @file Ball And Stick Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { ExtensionFragDepth, RepresentationRegistry } from '../globals'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport CylinderBuffer, { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport WideLineBuffer from '../buffer/wideline-buffer'\nimport Viewer from '../viewer/viewer';\n// @ts-ignore: unused import Volume required for declaration only\nimport { Structure, Volume } from '../ngl';\nimport AtomProxy from '../proxy/atom-proxy';\nimport { AtomDataParams, BondDataParams, BondDataFields, AtomDataFields, BondData, AtomData } from '../structure/structure-data';\nimport StructureView from '../structure/structure-view';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\n// @ts-ignore: unused import Surface required for declaration only\nimport Surface from '../surface/surface';\n\nexport interface BallAndStickRepresentationParameters extends StructureRepresentationParameters {\n sphereDetail: number\n radialSegments: number\n openEnded: boolean\n disableImpostor: boolean\n aspectRatio: number\n lineOnly: boolean\n lineWidth: number\n cylinderOnly: boolean\n multipleBond: 'off' | 'symmetric' | 'offset'\n bondSpacing: number\n bondScale: number\n linewidth: number\n}\n\n/**\n * Ball And Stick representation parameter object. Extends {@link RepresentationParameters} and\n * {@link StructureRepresentationParameters}.\n *\n * @typedef {Object} BallAndStickRepresentationParameters - ball and stick representation parameters\n *\n * @property {Integer} sphereDetail - sphere quality (icosahedron subdivisions)\n * @property {Integer} radialSegments - cylinder quality (number of segments)\n * @property {Boolean} openEnded - capped or not\n * @property {Boolean} disableImpostor - disable use of raycasted impostors for rendering\n * @property {Float} aspectRatio - size difference between atom and bond radii\n * @property {Boolean} lineOnly - render only bonds, and only as lines\n * @property {Integer} linewidth - width of lines\n * @property {Boolean} cylinderOnly - render only bonds (no atoms)\n * @property {String} multipleBond - one off \"off\", \"symmetric\", \"offset\"\n * @property {Float} bondSpacing - spacing for multiple bond rendering\n * @property {Float} bondScale - scale/radius for multiple bond rendering\n */\n\n/**\n * Ball And Stick representation. Show atoms as spheres and bonds as cylinders.\n *\n * __Name:__ _ball+stick_\n *\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"ball+stick\" );\n * o.autoView();\n * } );\n */\nclass BallAndStickRepresentation extends StructureRepresentation {\n protected sphereDetail: number\n protected radialSegments: number\n protected openEnded: boolean\n protected disableImpostor: boolean\n protected aspectRatio: number\n protected lineOnly: boolean\n protected lineWidth: number\n protected cylinderOnly: boolean\n protected multipleBond: 'off' | 'symmetric' | 'offset'\n protected bondSpacing: number\n protected bondScale: number\n protected linewidth: number\n\n protected lineBuffer: WideLineBuffer\n /**\n * Create Ball And Stick representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {BallAndStickRepresentationParameters} params - ball and stick representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'ball+stick'\n\n this.parameters = Object.assign({\n\n sphereDetail: true,\n radialSegments: true,\n openEnded: true,\n disableImpostor: true,\n aspectRatio: {\n type: 'number', precision: 1, max: 10.0, min: 1.0\n },\n lineOnly: {\n type: 'boolean', rebuild: true\n },\n cylinderOnly: {\n type: 'boolean', rebuild: true\n },\n multipleBond: {\n type: 'select',\n rebuild: true,\n options: {\n 'off': 'off',\n 'symmetric': 'symmetric',\n 'offset': 'offset'\n }\n },\n bondScale: {\n type: 'number', precision: 2, max: 1.0, min: 0.01\n },\n bondSpacing: {\n type: 'number', precision: 2, max: 2.0, min: 0.5\n },\n linewidth: {\n type: 'integer', max: 50, min: 1, buffer: true\n }\n\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.radiusType = defaults(p.radiusType, 'size')\n p.radiusSize = defaults(p.radiusSize, 0.15)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.aspectRatio = defaults(p.aspectRatio, 2.0)\n this.lineOnly = defaults(p.lineOnly, false)\n this.cylinderOnly = defaults(p.cylinderOnly, false)\n this.multipleBond = defaults(p.multipleBond, 'off')\n this.bondSpacing = defaults(p.bondSpacing, 1.0)\n this.bondScale = defaults(p.bondScale, 0.4)\n this.linewidth = defaults(p.linewidth, 2)\n\n super.init(p)\n }\n\n getAtomRadius (atom: AtomProxy) {\n return this.aspectRatio * super.getAtomRadius(atom)\n }\n\n getAtomParams (what?: AtomDataFields, params?: Partial) {\n var p = super.getAtomParams(what, params)\n p.radiusParams.scale *= this.aspectRatio\n\n return p\n }\n\n getAtomData (sview: StructureView, what?: AtomDataFields, params?: Partial): AtomData {\n return sview.getAtomData(this.getAtomParams(what, params))\n }\n\n getBondParams (what?: BondDataFields, params?: Partial) {\n params = Object.assign({\n multipleBond: this.multipleBond,\n bondSpacing: this.bondSpacing,\n bondScale: this.bondScale\n }, params)\n\n return super.getBondParams(what, params)\n }\n\n getBondData (sview: StructureView, what?: BondDataFields, params?: Partial): BondData {\n return sview.getBondData(this.getBondParams(what, params))\n }\n\n createData (sview: StructureView) {\n const bufferList: any[] = []\n\n if (this.lineOnly) {\n this.lineBuffer = new WideLineBuffer(\n this.getBondData(sview, { position: true, color: true, picking: true }),\n this.getBufferParams({ linewidth: this.linewidth })\n )\n\n bufferList.push(this.lineBuffer)\n } else {\n const cylinderBuffer = new CylinderBuffer(\n (this.getBondData(sview) as CylinderBufferData),\n this.getBufferParams({\n openEnded: this.openEnded,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n bufferList.push(cylinderBuffer as CylinderGeometryBuffer)\n\n if (!this.cylinderOnly) {\n const sphereBuffer = new SphereBuffer(\n (this.getAtomData(sview) as SphereBufferData),\n (this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters)\n )\n\n bufferList.push(sphereBuffer as SphereGeometryBuffer)\n }\n }\n\n return {\n bufferList: bufferList\n }\n }\n\n updateData (what: BondDataFields | AtomDataFields, data: StructureRepresentationData) {\n if (this.multipleBond !== 'off' && what && what.radius) {\n what.position = true\n }\n\n const bondData = this.getBondData(data.sview as StructureView, what)\n\n if (this.lineOnly) {\n const lineData:Partial = {}\n\n if (!what || what.position) {\n Object.assign(lineData, {\n position1: bondData.position1,\n position2: bondData.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(lineData, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n data.bufferList[ 0 ].setAttributes(lineData)\n } else {\n var cylinderData: Partial = {}\n\n if (!what || what.position) {\n Object.assign(cylinderData, {\n position1: bondData.position1,\n position2: bondData.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(cylinderData, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n if (!what || what.radius) {\n Object.assign(cylinderData, {\n radius: bondData.radius\n })\n }\n\n data.bufferList[ 0 ].setAttributes(cylinderData)\n\n if (!this.cylinderOnly) {\n var atomData = this.getAtomData(data.sview as StructureView, what)\n\n var sphereData: Partial = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {\n position: atomData.position\n })\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {\n color: atomData.color\n })\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {\n radius: atomData.radius\n })\n }\n\n data.bufferList[ 1 ].setAttributes(sphereData)\n }\n }\n }\n\n setParameters (params: Partial = {}) {\n let rebuild = false\n const what: AtomDataFields = {}\n\n if (params.aspectRatio || params.bondSpacing || params.bondScale) {\n Object.assign(what, {radius: true})\n if (!ExtensionFragDepth || this.disableImpostor) {\n rebuild = true\n }\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('ball+stick', BallAndStickRepresentation)\n\nexport default BallAndStickRepresentation\n","/**\n * @file Backbone Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport BallAndStickRepresentation, { BallAndStickRepresentationParameters } from './ballandstick-representation'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport StructureView from '../structure/structure-view';\nimport { AtomDataFields, AtomDataParams, BondDataFields, BondDataParams, BondData, AtomData } from '../structure/structure-data';\n\n/**\n * Backbone representation. Show cylinders (or lines) connecting .CA (protein)\n * or .C4'/.C3' (RNA/DNA) of polymers.\n *\n * __Name:__ _backbone_\n *\n * @example\n * stage.loadFile( \"rcsb://1sfi\" ).then( function( o ){\n * o.addRepresentation( \"backbone\" );\n * o.autoView();\n * } );\n */\nclass BackboneRepresentation extends BallAndStickRepresentation {\n /**\n * @param {Structure} structure - the structure object\n * @param {Viewer} viewer - the viewer object\n * @param {BallAndStickRepresentationParameters} params - parameters object\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'backbone'\n\n this.parameters = Object.assign({\n\n }, this.parameters, {\n\n multipleBond: null,\n bondSpacing: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.aspectRatio = defaults(p.aspectRatio, 1.0)\n p.radiusSize = defaults(p.radiusSize, 0.25)\n\n super.init(p)\n }\n\n getAtomRadius (atom: AtomProxy) {\n return atom.isTrace() ? super.getAtomRadius(atom) : 0\n }\n\n getAtomData (sview: StructureView, what?: AtomDataFields, params?: Partial): AtomData {\n return sview.getBackboneAtomData(this.getAtomParams(what, params))\n }\n\n getBondData (sview: StructureView, what?: BondDataFields, params?: Partial): BondData {\n return sview.getBackboneBondData(this.getBondParams(what, params))\n }\n}\n\nRepresentationRegistry.add('backbone', BackboneRepresentation)\n\nexport default BackboneRepresentation\n","/**\n * @file Base Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport BallAndStickRepresentation, { BallAndStickRepresentationParameters } from './ballandstick-representation'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { AtomDataFields, AtomDataParams, BondDataFields, BondDataParams, BondData, AtomData } from '../structure/structure-data';\n\n/**\n * Base representation. Show cylinders for RNA/DNA ladders.\n *\n * __Name:__ _base_\n *\n * @example\n * stage.loadFile( \"rcsb://1d66\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\", { sele: \"nucleic\" } );\n * o.addRepresentation( \"base\", { color: \"resname\" } );\n * o.autoView( \"nucleic\" );\n * } );\n */\nclass BaseRepresentation extends BallAndStickRepresentation {\n /**\n * @param {Structure} structure - the structure object\n * @param {Viewer} viewer - the viewer object\n * @param {BallAndStickRepresentationParameters} params - parameters object\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'base'\n\n this.parameters = Object.assign({\n\n }, this.parameters, {\n\n multipleBond: null,\n bondSpacing: null\n\n })\n }\n\n init (params: Partial) {\n let p = params || {}\n p.aspectRatio = defaults(p.aspectRatio, 1.0)\n p.radiusSize = defaults(p.radiusSize, 0.3)\n\n super.init(p)\n }\n\n getAtomData (sview: StructureView, what?: AtomDataFields, params?: AtomDataParams): AtomData {\n return sview.getRungAtomData(this.getAtomParams(what, params))\n }\n\n getBondData (sview: StructureView, what?: BondDataFields, params?: BondDataParams): BondData {\n let p = this.getBondParams(what, params)\n Object.assign(p.colorParams, {rung: true})\n\n return sview.getRungBondData(p)\n }\n}\n\nRepresentationRegistry.add('base', BaseRepresentation)\n\nexport default BaseRepresentation\n","/**\n * @file Spline\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport { AtomPicker } from '../utils/picker'\nimport RadiusFactory, { RadiusParams } from '../utils/radius-factory'\nimport { copyArray } from '../math/array-utils'\nimport { spline } from '../math/math-utils'\nimport Polymer from '../proxy/polymer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport { ColormakerParameters } from '../color/colormaker';\nimport { NumberArray } from '../types';\n\nexport class Interpolator {\n \n m: number\n tension: number\n dt: number\n delta: number\n vec1: Vector3\n vec2: Vector3\n vDir: Vector3 \n vTan: Vector3\n vNorm: Vector3\n vBin: Vector3\n m2: number\n\n constructor (m: number, tension: number) {\n this.m = m\n this.tension = tension\n this.dt = 1.0 / this.m\n this.delta = 0.0001\n\n this.vec1 = new Vector3()\n this.vec2 = new Vector3()\n\n this.vDir = new Vector3()\n this.vTan = new Vector3()\n this.vNorm = new Vector3()\n this.vBin = new Vector3()\n \n this.m2 = Math.ceil(this.m / 2)\n }\n\n private interpolateToArr (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, t: number, arr: Float32Array, offset: number) {\n arr[ offset + 0 ] = spline(v0.x, v1.x, v2.x, v3.x, t, this.tension)\n arr[ offset + 1 ] = spline(v0.y, v1.y, v2.y, v3.y, t, this.tension)\n arr[ offset + 2 ] = spline(v0.z, v1.z, v2.z, v3.z, t, this.tension)\n }\n\n private interpolateToVec (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, t: number, vec: Vector3) {\n vec.x = spline(v0.x, v1.x, v2.x, v3.x, t, this.tension)\n vec.y = spline(v0.y, v1.y, v2.y, v3.y, t, this.tension)\n vec.z = spline(v0.z, v1.z, v2.z, v3.z, t, this.tension)\n }\n\n private interpolatePosition (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, pos: Float32Array, offset: number) {\n for (var j = 0; j < this.m; ++j) {\n var l = offset + j * 3\n var d = this.dt * j\n this.interpolateToArr(v0, v1, v2, v3, d, pos, l)\n }\n }\n\n private interpolateTangent (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, tan: Float32Array, offset: number) {\n for (var j = 0; j < this.m; ++j) {\n var d = this.dt * j\n var d1 = d - this.delta\n var d2 = d + this.delta\n var l = offset + j * 3\n // capping as a precaution\n if (d1 < 0) d1 = 0\n if (d2 > 1) d2 = 1\n //\n this.interpolateToVec(v0, v1, v2, v3, d1, this.vec1)\n this.interpolateToVec(v0, v1, v2, v3, d2, this.vec2)\n //\n this.vec2.sub(this.vec1).normalize()\n this.vec2.toArray(tan as any, l)\n }\n }\n\n private vectorSubdivide (interpolationFn: (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, array: Float32Array, offset: number) => void,\n iterator: AtomIterator, array: Float32Array, offset: number, isCyclic: boolean) {\n let v0: Vector3\n let v1 = iterator.next()\n let v2 = iterator.next()\n let v3 = iterator.next()\n //\n const n = iterator.size\n const n1 = n - 1\n let k = offset || 0\n for (let i = 0; i < n1; ++i) {\n v0 = v1\n v1 = v2\n v2 = v3\n v3 = iterator.next()\n interpolationFn.apply(this, [v0, v1, v2, v3, array, k])\n k += 3 * this.m\n }\n if (isCyclic) {\n v0 = iterator.get(n - 2)\n v1 = iterator.get(n - 1)\n v2 = iterator.get(0)\n v3 = iterator.get(1)\n interpolationFn.apply(this, [v0, v1, v2, v3, array, k])\n k += 3 * this.m\n }\n }\n\n //\n\n public getPosition (iterator: AtomIterator, array: Float32Array, offset: number, isCyclic: boolean) {\n iterator.reset()\n this.vectorSubdivide(this.interpolatePosition, iterator, array, offset, isCyclic)\n var n1 = iterator.size - 1\n var k = n1 * this.m * 3\n if (isCyclic) k += this.m * 3\n var v = iterator.get(isCyclic ? 0 : n1)\n array[ k ] = v.x\n array[ k + 1 ] = v.y\n array[ k + 2 ] = v.z\n }\n\n public getTangent (iterator: AtomIterator, array: Float32Array, offset: number, isCyclic: boolean) {\n iterator.reset()\n this.vectorSubdivide(this.interpolateTangent, iterator, array, offset, isCyclic)\n const n1 = iterator.size - 1\n let k = n1 * this.m * 3\n if (isCyclic) k += this.m * 3\n copyArray(array, array, k - 3, k, 3)\n }\n\n private interpolateNormalDir (u0: Vector3, u1: Vector3, u2: Vector3, u3: Vector3,\n v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3,\n tan: Float32Array, norm: Float32Array, bin: Float32Array,\n offset: number, shift: boolean) {\n for (let j = 0; j < this.m; ++j) {\n let l = offset + j * 3\n if (shift) l += this.m2 * 3\n const d = this.dt * j\n this.interpolateToVec(u0, u1, u2, u3, d, this.vec1)\n this.interpolateToVec(v0, v1, v2, v3, d, this.vec2)\n this.vDir.subVectors(this.vec2, this.vec1).normalize()\n this.vTan.fromArray(tan as any, l)\n this.vBin.crossVectors(this.vDir, this.vTan).normalize()\n this.vBin.toArray(bin as any, l)\n this.vNorm.crossVectors(this.vTan, this.vBin).normalize()\n this.vNorm.toArray(norm as any, l)\n }\n }\n\n private interpolateNormal (vDir: Vector3, tan: Float32Array, norm: Float32Array, bin: Float32Array, offset: number) {\n for (var j = 0; j < this.m; ++j) {\n var l = offset + j * 3\n vDir.copy(this.vNorm)\n this.vTan.fromArray(tan as any, l)\n this.vBin.crossVectors(vDir, this.vTan).normalize()\n this.vBin.toArray(bin as any, l)\n this.vNorm.crossVectors(this.vTan, this.vBin).normalize()\n this.vNorm.toArray(norm as any, l)\n }\n }\n\n public getNormal (size: number, tan: Float32Array, norm: Float32Array, bin: Float32Array, offset: number, isCyclic: boolean) {\n this.vNorm.set(0, 0, 1)\n const n = size\n const n1 = n - 1\n let k = offset || 0\n for (var i = 0; i < n1; ++i) {\n this.interpolateNormal(this.vDir, tan, norm, bin, k)\n k += 3 * this.m\n }\n if (isCyclic) {\n this.interpolateNormal(this.vDir, tan, norm, bin, k)\n k += 3 * this.m\n }\n this.vBin.toArray(bin as any, k)\n this.vNorm.toArray(norm as any, k)\n }\n\n public getNormalDir (iterDir1: AtomIterator, iterDir2: AtomIterator, tan: Float32Array, norm: Float32Array, bin: Float32Array, offset: number, isCyclic: boolean, shift: boolean) {\n iterDir1.reset()\n iterDir2.reset()\n //\n const vSub1 = new Vector3()\n const vSub2 = new Vector3()\n const vSub3 = new Vector3()\n const vSub4 = new Vector3()\n //\n const d1v1 = new Vector3()\n const d1v2 = new Vector3().copy(iterDir1.next())\n const d1v3 = new Vector3().copy(iterDir1.next())\n const d1v4 = new Vector3().copy(iterDir1.next())\n const d2v1 = new Vector3()\n const d2v2 = new Vector3().copy(iterDir2.next())\n const d2v3 = new Vector3().copy(iterDir2.next())\n const d2v4 = new Vector3().copy(iterDir2.next())\n //\n this.vNorm.set(0, 0, 1)\n let n = iterDir1.size\n let n1 = n - 1\n let k = offset || 0\n for (var i = 0; i < n1; ++i) {\n d1v1.copy(d1v2)\n d1v2.copy(d1v3)\n d1v3.copy(d1v4)\n d1v4.copy(iterDir1.next())\n d2v1.copy(d2v2)\n d2v2.copy(d2v3)\n d2v3.copy(d2v4)\n d2v4.copy(iterDir2.next())\n //\n if (i === 0) {\n vSub1.subVectors(d2v1, d1v1)\n vSub2.subVectors(d2v2, d1v2)\n if (vSub1.dot(vSub2) < 0) {\n vSub2.multiplyScalar(-1)\n d2v2.addVectors(d1v2, vSub2)\n }\n vSub3.subVectors(d2v3, d1v3)\n if (vSub2.dot(vSub3) < 0) {\n vSub3.multiplyScalar(-1)\n d2v3.addVectors(d1v3, vSub3)\n }\n } else {\n vSub3.copy(vSub4)\n }\n vSub4.subVectors(d2v4, d1v4)\n if (vSub3.dot(vSub4) < 0) {\n vSub4.multiplyScalar(-1)\n d2v4.addVectors(d1v4, vSub4)\n }\n this.interpolateNormalDir(\n d1v1, d1v2, d1v3, d1v4,\n d2v1, d2v2, d2v3, d2v4,\n tan, norm, bin, k, shift\n )\n k += 3 * this.m\n }\n if (isCyclic) {\n d1v1.copy(iterDir1.get(n - 2))\n d1v2.copy(iterDir1.get(n - 1))\n d1v3.copy(iterDir1.get(0))\n d1v4.copy(iterDir1.get(1))\n d2v1.copy(iterDir2.get(n - 2))\n d2v2.copy(iterDir2.get(n - 1))\n d2v3.copy(iterDir2.get(0))\n d2v4.copy(iterDir2.get(1))\n //\n vSub3.copy(vSub4)\n vSub4.subVectors(d2v4, d1v4)\n if (vSub3.dot(vSub4) < 0) {\n vSub4.multiplyScalar(-1)\n d2v4.addVectors(d1v4, vSub4)\n }\n this.interpolateNormalDir(\n d1v1, d1v2, d1v3, d1v4,\n d2v1, d2v2, d2v3, d2v4,\n tan, norm, bin, k, shift\n )\n k += 3 * this.m\n }\n if (shift) {\n // FIXME shift requires data from one this.more preceeding residue\n this.vBin.fromArray(bin as any, this.m2 * 3)\n this.vNorm.fromArray(norm as any, this.m2 * 3)\n for (var j = 0; j < this.m2; ++j) {\n this.vBin.toArray(bin as any, j * 3)\n this.vNorm.toArray(norm as any, j * 3)\n }\n } else {\n this.vBin.toArray(bin as any, k)\n this.vNorm.toArray(norm as any, k)\n }\n }\n\n //\n\n private interpolateColor (item1: AtomProxy, item2: AtomProxy, colFn: (...arg: any[]) => void, col: any, offset: number) {\n var j, l\n for (j = 0; j < this.m2; ++j) {\n l = offset + j * 3\n colFn.apply(this, [item1, col, l]) // itemColorToArray\n }\n for (j = this.m2; j < this.m; ++j) {\n l = offset + j * 3\n colFn.apply(this, [item2, col, l]) // itemColorToArray\n }\n }\n\n public getColor (iterator: AtomIterator, colFn: (...arg: any[]) => void, col: any, offset: number, isCyclic: boolean) {\n iterator.reset()\n iterator.next() // first element not needed\n let i0: AtomProxy\n let i1 = iterator.next()\n //\n var n = iterator.size\n var n1 = n - 1\n var k = offset || 0\n for (var i = 0; i < n1; ++i) {\n i0 = i1\n i1 = iterator.next()\n this.interpolateColor(i0, i1, colFn, col, k)\n k += 3 * this.m\n }\n if (isCyclic) {\n i0 = iterator.get(n - 1)\n i1 = iterator.get(0)\n this.interpolateColor(i0, i1, colFn, col, k)\n k += 3 * this.m\n }\n //\n col[ k ] = col[ k - 3 ]\n col[ k + 1 ] = col[ k - 2 ]\n col[ k + 2 ] = col[ k - 1 ]\n }\n\n //\n\n private interpolatePicking (item1: AtomProxy, item2: AtomProxy, pickFn: (item: AtomProxy) => number, pick: Float32Array, offset: number) {\n var j\n for (j = 0; j < this.m2; ++j) {\n pick[ offset + j ] = pickFn.apply(this, [item1])\n }\n for (j = this.m2; j < this.m; ++j) {\n pick[ offset + j ] = pickFn.apply(this, [item2])\n }\n }\n\n public getPicking (iterator: AtomIterator, pickFn: (item: AtomProxy) => number, pick: Float32Array, offset: number, isCyclic: boolean) {\n iterator.reset()\n iterator.next() // first element not needed\n let i0: AtomProxy\n let i1 = iterator.next()\n //\n const n = iterator.size\n const n1 = n - 1\n let k = offset || 0\n for (var i = 0; i < n1; ++i) {\n i0 = i1\n i1 = iterator.next()\n this.interpolatePicking(i0, i1, pickFn, pick, k)\n k += this.m\n }\n if (isCyclic) {\n i0 = iterator.get(n - 1)\n i1 = iterator.get(0)\n this.interpolatePicking(i0, i1, pickFn, pick, k)\n k += this.m\n }\n //\n pick[ k ] = pick[ k - 1 ]\n }\n\n //\n\n private interpolateSize (item1: AtomProxy, item2: AtomProxy, sizeFn: (item: AtomProxy) => number, size: Float32Array, offset: number) {\n const s1: number = sizeFn.apply(this, [item1])\n const s2: number = sizeFn.apply(this, [item2])\n for (let j = 0; j < this.m; ++j) {\n // linear interpolation\n let t = j / this.m\n size[ offset + j ] = (1 - t) * s1 + t * s2\n }\n }\n\n public getSize (iterator: AtomIterator, sizeFn: (item: AtomProxy) => number, size: Float32Array, offset: number, isCyclic: boolean) {\n iterator.reset()\n iterator.next() // first element not needed\n let i0: AtomProxy\n let i1: AtomProxy = iterator.next()\n //\n const n = iterator.size\n const n1 = n - 1\n let k = offset || 0\n for (var i = 0; i < n1; ++i) {\n i0 = i1\n i1 = iterator.next()\n this.interpolateSize(i0, i1, sizeFn, size, k)\n k += this.m\n }\n if (isCyclic) {\n i0 = iterator.get(n - 1)\n i1 = iterator.get(0)\n this.interpolateSize(i0, i1, sizeFn, size, k)\n k += this.m\n }\n //\n size[ k ] = size[ k - 1 ]\n }\n}\n\nexport interface SplineParameters {\n directional?: boolean\n positionIterator?: boolean\n subdiv?: number\n smoothSheet?: boolean\n tension?: number\n}\nexport interface AtomIterator {\n size: number,\n next: () => AtomProxy | Vector3,\n get: (idx: number) => AtomProxy | Vector3,\n reset: () => void\n}\nclass Spline {\n\n polymer: Polymer\n size: number\n directional: boolean\n positionIterator: any\n subdiv: number\n smoothSheet: boolean\n tension: number\n interpolator: Interpolator\n\n constructor (polymer: Polymer, params?: SplineParameters) {\n this.polymer = polymer\n this.size = polymer.residueCount\n\n var p = params || {}\n this.directional = p.directional || false\n this.positionIterator = p.positionIterator || false\n this.subdiv = p.subdiv || 1\n this.smoothSheet = p.smoothSheet || false\n\n if (!p.tension) {\n this.tension = this.polymer.isNucleic() ? 0.5 : 0.9\n } else {\n this.tension = p.tension\n }\n\n this.interpolator = new Interpolator(this.subdiv, this.tension)\n }\n\n getAtomIterator (type: string, smooth?: boolean): AtomIterator {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n\n let i = 0\n let j = -1\n\n const cache = [\n structure.getAtomProxy(),\n structure.getAtomProxy(),\n structure.getAtomProxy(),\n structure.getAtomProxy()\n ]\n\n const cache2 = [\n new Vector3(),\n new Vector3(),\n new Vector3(),\n new Vector3()\n ]\n\n function next () {\n var atomProxy = get(j)\n j += 1\n return atomProxy\n }\n\n var apPrev = structure.getAtomProxy()\n var apNext = structure.getAtomProxy()\n\n function get (idx: number) {\n var atomProxy = cache[ i % 4 ]\n atomProxy.index = polymer.getAtomIndexByType(idx, type) as number\n if (smooth && idx > 0 && idx < n && atomProxy.sstruc === 'e') {\n var vec = cache2[ i % 4 ]\n apPrev.index = polymer.getAtomIndexByType(idx + 1, type) as number\n apNext.index = polymer.getAtomIndexByType(idx - 1, type) as number\n vec.addVectors(apPrev as any, apNext as any)\n .add(atomProxy as any).add(atomProxy as any)\n .multiplyScalar(0.25)\n i += 1\n return vec\n }\n i += 1\n return atomProxy\n }\n\n function reset () {\n i = 0\n j = -1\n }\n\n return {\n size: n,\n next: next,\n get: get,\n reset: reset\n }\n }\n\n getSubdividedColor (params: {scheme: string, [k: string]: any } & ColormakerParameters) {\n var m = this.subdiv\n var polymer = this.polymer\n var n = polymer.residueCount\n var n1 = n - 1\n var nCol = n1 * m * 3 + 3\n if (polymer.isCyclic) nCol += m * 3\n\n var col = new Float32Array(nCol)\n var iterator = this.getAtomIterator('trace')\n\n var p = params || {}\n p.structure = polymer.structure\n\n var colormaker = ColormakerRegistry.getScheme(p)\n\n function colFn (item: AtomProxy, array: NumberArray, offset: number) {\n colormaker.atomColorToArray(item, array, offset)\n }\n\n this.interpolator.getColor(\n iterator, colFn, col, 0, polymer.isCyclic\n )\n\n return {\n 'color': col\n }\n }\n \n getSubdividedPicking () {\n var m = this.subdiv\n var polymer = this.polymer\n var n = polymer.residueCount\n var n1 = n - 1\n var nCol = n1 * m + 1\n if (polymer.isCyclic) nCol += m\n\n var structure = polymer.structure\n var iterator = this.getAtomIterator('trace')\n var pick = new Float32Array(nCol)\n\n function pickFn (item: AtomProxy) {\n return item.index\n }\n\n this.interpolator.getPicking(\n iterator, pickFn, pick, 0, polymer.isCyclic\n )\n\n return {\n 'picking': new AtomPicker(pick, structure)\n }\n }\n\n getSubdividedPosition () {\n var pos = this.getPosition()\n\n return {\n 'position': pos\n }\n }\n \n getSubdividedOrientation () {\n const tan = this.getTangent()\n const normals = this.getNormals(tan)\n\n return {\n 'tangent': tan,\n 'normal': normals.normal,\n 'binormal': normals.binormal\n }\n }\n\n getSubdividedSize (params: RadiusParams) {\n var m = this.subdiv\n var polymer = this.polymer\n var n = polymer.residueCount\n var n1 = n - 1\n var nSize = n1 * m + 1\n if (polymer.isCyclic) nSize += m\n\n var size = new Float32Array(nSize)\n var iterator = this.getAtomIterator('trace')\n\n var radiusFactory = new RadiusFactory(params)\n\n function sizeFn (item: AtomProxy) {\n return radiusFactory.atomRadius(item)\n }\n\n this.interpolator.getSize(\n iterator, sizeFn, size, 0, polymer.isCyclic\n )\n\n return {\n 'size': size\n }\n }\n\n getPosition () {\n const m = this.subdiv\n const polymer = this.polymer\n const n = polymer.residueCount\n const n1 = n - 1\n let nPos = n1 * m * 3 + 3\n if (polymer.isCyclic) nPos += m * 3\n\n const pos = new Float32Array(nPos)\n const iterator = this.positionIterator || this.getAtomIterator('trace', this.smoothSheet)\n\n this.interpolator.getPosition(iterator, pos, 0, polymer.isCyclic)\n\n return pos\n }\n\n getTangent () {\n const m = this.subdiv\n const polymer = this.polymer\n const n = this.size\n const n1 = n - 1\n let nTan = n1 * m * 3 + 3\n if (polymer.isCyclic) nTan += m * 3\n\n const tan = new Float32Array(nTan)\n const iterator = this.positionIterator || this.getAtomIterator('trace', this.smoothSheet)\n\n this.interpolator.getTangent(iterator, tan, 0, polymer.isCyclic)\n\n return tan\n }\n\n getNormals (tan: Float32Array) {\n const m = this.subdiv\n const polymer = this.polymer\n const isProtein = polymer.isProtein()\n const n = this.size\n const n1 = n - 1\n let nNorm = n1 * m * 3 + 3\n if (polymer.isCyclic) nNorm += m * 3\n\n const norm = new Float32Array(nNorm)\n const bin = new Float32Array(nNorm)\n\n if (this.directional && !this.polymer.isCg()) {\n const iterDir1 = this.getAtomIterator('direction1')\n const iterDir2 = this.getAtomIterator('direction2')\n this.interpolator.getNormalDir(\n iterDir1, iterDir2, tan, norm, bin, 0, polymer.isCyclic, isProtein\n )\n } else {\n this.interpolator.getNormal(\n n, tan, norm, bin, 0, polymer.isCyclic\n )\n }\n\n return {\n 'normal': norm,\n 'binormal': bin\n }\n }\n\n}\n\nexport default Spline\n","/**\n * @file Tube Mesh Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Matrix4 required for declaration only\nimport { Vector3, Matrix4 } from 'three'\n\nimport { defaults, getUintArray } from '../utils'\nimport { serialArray } from '../math/array-utils'\nimport MeshBuffer from './mesh-buffer'\nimport { BufferDefaultParameters, BufferData, BufferParameters } from './buffer'\nimport {Log} from \"../globals\";\n\nconst vTangent = new Vector3()\nconst vMeshNormal = new Vector3()\n\nexport interface TubeMeshBufferData extends BufferData {\n binormal: Float32Array\n tangent: Float32Array\n size: Float32Array\n}\n\nexport const TubeMeshBufferDefaultParameters = Object.assign({\n radialSegments: 4,\n capped: false,\n aspectRatio: 1.0\n}, BufferDefaultParameters)\nexport type TubeMeshBufferParameters = BufferParameters & {\n radialSegments: number,\n capped: boolean,\n aspectRatio: number\n}\n\nfunction getData (data: TubeMeshBufferData, params: Partial = {}) {\n const radialSegments = defaults(params.radialSegments, 4)\n const capped = defaults(params.capped, false)\n\n const capVertices = capped ? radialSegments : 0\n const capTriangles = capped ? radialSegments - 2 : 0\n\n const n = data.position!.length / 3\n const n1 = n - 1\n const x = n * radialSegments * 3 + 2 * capVertices * 3\n const xi = n1 * 2 * radialSegments * 3 + 2 * capTriangles * 3\n\n return {\n position: new Float32Array(x),\n color: new Float32Array(x),\n index: getUintArray(xi, x / 3),\n normal: new Float32Array(x),\n picking: data.picking\n }\n}\n\n/**\n * Tube mesh buffer. Draws a tube.\n */\nclass TubeMeshBuffer extends MeshBuffer {\n get defaultParameters() { return TubeMeshBufferDefaultParameters }\n parameters: TubeMeshBufferParameters\n\n capVertices: number\n capTriangles: number\n size2: number\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.normal - normals\n * @param {Float32Array} data.binormal - binormals\n * @param {Float32Array} data.tangent - tangents\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.size - sizes\n * @param {Picker} data.picking - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: TubeMeshBufferData, params: Partial = {}) {\n super(getData(data, params), params)\n\n this.capVertices = this.parameters.capped ? this.parameters.radialSegments : 0\n this.capTriangles = this.parameters.capped ? this.parameters.radialSegments - 2 : 0\n\n this.size2 = data.position!.length / 3\n data.primitiveId = serialArray(this.size2)\n\n this.setAttributes(data)\n this.makeIndex()\n }\n\n setAttributes (data: Partial = {}) {\n const aspectRatio = this.parameters.aspectRatio\n\n const n = this.size2\n const n1 = n - 1\n const radialSegments = this.parameters.radialSegments\n\n const attributes = this.geometry.attributes as any\n\n let position, normal, binormal, tangent, color, size, primitiveId\n let meshPosition, meshColor, meshNormal, meshPrimitiveId\n\n if (data.position) {\n position = data.position\n normal = data.normal\n binormal = data.binormal\n tangent = data.tangent\n size = data.size\n\n meshPosition = attributes.position.array\n meshNormal = attributes.normal.array\n\n attributes.position.needsUpdate = true\n attributes.normal.needsUpdate = true\n }\n\n if (data.color) {\n color = data.color\n meshColor = attributes.color.array\n attributes.color.needsUpdate = true\n }\n\n if (data.primitiveId) {\n primitiveId = data.primitiveId\n meshPrimitiveId = attributes.primitiveId.array\n attributes.primitiveId.needsUpdate = true\n }\n\n let k, l\n let radius = 0\n\n let normX = 0\n let normY = 0\n let normZ = 0\n let biX = 0\n let biY = 0\n let biZ = 0\n let posX = 0\n let posY = 0\n let posZ = 0\n\n const cxArr = []\n const cyArr = []\n const cx1Arr = []\n const cy1Arr = []\n const cx2Arr = []\n const cy2Arr = []\n\n if (position) {\n for (let j = 0; j < radialSegments; ++j) {\n const v = (j / radialSegments) * 2 * Math.PI\n\n cxArr[ j ] = aspectRatio * Math.cos(v)\n cyArr[ j ] = Math.sin(v)\n\n cx1Arr[ j ] = aspectRatio * Math.cos(v - 0.01)\n cy1Arr[ j ] = Math.sin(v - 0.01)\n cx2Arr[ j ] = aspectRatio * Math.cos(v + 0.01)\n cy2Arr[ j ] = Math.sin(v + 0.01)\n }\n }\n\n for (let i = 0; i < n; ++i) {\n k = i * 3\n l = k * radialSegments\n\n if (position && tangent && normal && binormal && size) {\n vTangent.set(\n tangent[ k ], tangent[ k + 1 ], tangent[ k + 2 ]\n )\n\n normX = normal[ k ]\n normY = normal[ k + 1 ]\n normZ = normal[ k + 2 ]\n\n biX = binormal[ k ]\n biY = binormal[ k + 1 ]\n biZ = binormal[ k + 2 ]\n\n posX = position[ k ]\n posY = position[ k + 1 ]\n posZ = position[ k + 2 ]\n\n radius = size[ i ]\n }\n\n for (let j = 0; j < radialSegments; ++j) {\n const s = l + j * 3\n\n if (position) {\n const cx = -radius * cxArr[ j ] // TODO: Hack: Negating it so it faces outside.\n const cy = radius * cyArr[ j ]\n\n const cx1 = -radius * cx1Arr[ j ]\n const cy1 = radius * cy1Arr[ j ]\n const cx2 = -radius * cx2Arr[ j ]\n const cy2 = radius * cy2Arr[ j ]\n\n meshPosition[ s ] = posX + cx * normX + cy * biX\n meshPosition[ s + 1 ] = posY + cx * normY + cy * biY\n meshPosition[ s + 2 ] = posZ + cx * normZ + cy * biZ\n\n // TODO half of these are symmetric\n vMeshNormal.set(\n // ellipse tangent approximated as vector from/to adjacent points\n (cx2 * normX + cy2 * biX) - (cx1 * normX + cy1 * biX),\n (cx2 * normY + cy2 * biY) - (cx1 * normY + cy1 * biY),\n (cx2 * normZ + cy2 * biZ) - (cx1 * normZ + cy1 * biZ)\n ).cross(vTangent)\n\n meshNormal[ s ] = vMeshNormal.x\n meshNormal[ s + 1 ] = vMeshNormal.y\n meshNormal[ s + 2 ] = vMeshNormal.z\n }\n\n if (color) {\n meshColor[ s ] = color[ k ]\n meshColor[ s + 1 ] = color[ k + 1 ]\n meshColor[ s + 2 ] = color[ k + 2 ]\n }\n\n if (primitiveId) {\n meshPrimitiveId[ i * radialSegments + j ] = primitiveId[ i ]\n }\n }\n }\n\n // front cap\n\n k = 0\n l = n * 3 * radialSegments\n\n for (let j = 0; j < radialSegments; ++j) {\n const s = k + j * 3\n const t = l + j * 3\n\n if (position && tangent) {\n meshPosition[ t ] = meshPosition[ s ]\n meshPosition[ t + 1 ] = meshPosition[ s + 1 ]\n meshPosition[ t + 2 ] = meshPosition[ s + 2 ]\n\n meshNormal[ t ] = tangent[ k ]\n meshNormal[ t + 1 ] = tangent[ k + 1 ]\n meshNormal[ t + 2 ] = tangent[ k + 2 ]\n }\n\n if (color) {\n meshColor[ t ] = meshColor[ s ]\n meshColor[ t + 1 ] = meshColor[ s + 1 ]\n meshColor[ t + 2 ] = meshColor[ s + 2 ]\n }\n\n if (primitiveId) {\n meshPrimitiveId[ n * radialSegments + j ] = meshPrimitiveId[ 0 + j ]\n }\n }\n\n // back cap\n\n k = (n - 1) * 3 * radialSegments\n l = (n + 1) * 3 * radialSegments\n\n for (let j = 0; j < radialSegments; ++j) {\n const s = k + j * 3\n const t = l + j * 3\n\n if (position && tangent) {\n meshPosition[ t ] = meshPosition[ s ]\n meshPosition[ t + 1 ] = meshPosition[ s + 1 ]\n meshPosition[ t + 2 ] = meshPosition[ s + 2 ]\n\n meshNormal[ t ] = tangent[ n1 * 3 ]\n meshNormal[ t + 1 ] = tangent[ n1 * 3 + 1 ]\n meshNormal[ t + 2 ] = tangent[ n1 * 3 + 2 ]\n }\n\n if (color) {\n meshColor[ t ] = meshColor[ s ]\n meshColor[ t + 1 ] = meshColor[ s + 1 ]\n meshColor[ t + 2 ] = meshColor[ s + 2 ]\n }\n\n if (primitiveId) {\n meshPrimitiveId[ (n + 1) * radialSegments + j ] = meshPrimitiveId[ (n - 1) * radialSegments + j ]\n }\n }\n }\n\n makeIndex () {\n const index = this.geometry.getIndex()\n if (!index) { Log.error('Index is null'); return; }\n const meshIndex = index.array as Uint32Array|Uint16Array\n\n const n = this.size2\n const n1 = n - 1\n const capTriangles = this.capTriangles\n const radialSegments = this.parameters.radialSegments\n const radialSegments1 = this.parameters.radialSegments + 1\n\n let k, l\n\n for (let i = 0; i < n1; ++i) {\n const k = i * radialSegments * 3 * 2\n\n const irs = i * radialSegments\n const irs1 = (i + 1) * radialSegments\n\n for (let j = 0; j < radialSegments; ++j) {\n l = k + j * 3 * 2\n\n // meshIndex[ l + 0 ] = irs + ( ( j + 0 ) % radialSegments );\n meshIndex[ l ] = irs + j\n meshIndex[ l + 1 ] = irs + ((j + 1) % radialSegments)\n // meshIndex[ l + 2 ] = irs1 + ( ( j + 0 ) % radialSegments );\n meshIndex[ l + 2 ] = irs1 + j\n\n // meshIndex[ l + 3 ] = irs1 + ( ( j + 0 ) % radialSegments );\n meshIndex[ l + 3 ] = irs1 + j\n meshIndex[ l + 4 ] = irs + ((j + 1) % radialSegments)\n meshIndex[ l + 5 ] = irs1 + ((j + 1) % radialSegments)\n }\n }\n\n // capping\n\n const strip = [ 0 ]\n\n for (let j = 1; j < radialSegments1 / 2; ++j) {\n strip.push(j)\n if (radialSegments - j !== j) {\n strip.push(radialSegments - j)\n }\n }\n\n // front cap\n\n l = n1 * radialSegments * 3 * 2\n k = n * radialSegments\n\n for (let j = 0; j < strip.length - 2; ++j) {\n if (j % 2 === 0) {\n meshIndex[ l + j * 3 + 0 ] = k + strip[ j + 0 ]\n meshIndex[ l + j * 3 + 1 ] = k + strip[ j + 1 ]\n meshIndex[ l + j * 3 + 2 ] = k + strip[ j + 2 ]\n } else {\n meshIndex[ l + j * 3 + 0 ] = k + strip[ j + 2 ]\n meshIndex[ l + j * 3 + 1 ] = k + strip[ j + 1 ]\n meshIndex[ l + j * 3 + 2 ] = k + strip[ j + 0 ]\n }\n }\n\n // back cap\n\n l = n1 * radialSegments * 3 * 2 + 3 * capTriangles\n k = n * radialSegments + radialSegments\n\n for (let j = 0; j < strip.length - 2; ++j) {\n if (j % 2 === 0) {\n meshIndex[ l + j * 3 + 0 ] = k + strip[ j + 0 ]\n meshIndex[ l + j * 3 + 1 ] = k + strip[ j + 1 ]\n meshIndex[ l + j * 3 + 2 ] = k + strip[ j + 2 ]\n } else {\n meshIndex[ l + j * 3 + 0 ] = k + strip[ j + 2 ]\n meshIndex[ l + j * 3 + 1 ] = k + strip[ j + 1 ]\n meshIndex[ l + j * 3 + 2 ] = k + strip[ j + 0 ]\n }\n }\n }\n}\n\nexport default TubeMeshBuffer\n","/**\n * @file Cartoon Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { Debug, Log, RepresentationRegistry } from '../globals'\nimport Spline from '../geometry/spline'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport TubeMeshBuffer from '../buffer/tubemesh-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport Polymer from '../proxy/polymer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport StructureView from '../structure/structure-view';\nimport Buffer from '../buffer/buffer';\n\nexport interface CartoonRepresentationParameters extends StructureRepresentationParameters {\n aspectRatio: number\n subdiv: number\n radialSegments: number\n tension: number\n capped: boolean\n smoothSheet: boolean\n}\n\n/**\n * Cartoon representation. Show a thick ribbon that\n * smoothly connecting backbone atoms in polymers.\n *\n * __Name:__ _cartoon_\n *\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\" );\n * o.autoView();\n * } );\n */\nclass CartoonRepresentation extends StructureRepresentation {\n protected aspectRatio: number\n protected tension: number\n protected capped: boolean\n protected smoothSheet: boolean\n protected subdiv: number\n \n /**\n * Create Cartoon representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {StructureRepresentationParameters} params - representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'cartoon'\n\n this.parameters = Object.assign({\n\n aspectRatio: {\n type: 'number', precision: 1, max: 10.0, min: 1.0, rebuild: true\n },\n subdiv: {\n type: 'integer', max: 50, min: 1, rebuild: true\n },\n radialSegments: {\n type: 'integer', max: 50, min: 1, rebuild: true\n },\n tension: {\n type: 'number', precision: 1, max: 1.0, min: 0.1\n },\n capped: {\n type: 'boolean', rebuild: true\n },\n smoothSheet: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'chainname')\n p.colorScale = defaults(p.colorScale, 'RdYlBu')\n p.radiusType = defaults(p.radiusType, 'sstruc')\n p.radiusScale = defaults(p.radiusScale, 0.7)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.aspectRatio = defaults(p.aspectRatio, 5.0)\n this.tension = defaults(p.tension, NaN)\n this.capped = defaults(p.capped, true)\n this.smoothSheet = defaults(p.smoothSheet, false)\n\n if (p.quality === 'low') {\n this.subdiv = 3\n this.radialSegments = 6\n } else if (p.quality === 'medium') {\n this.subdiv = 6\n } else if (p.quality === 'high') {\n this.subdiv = 12\n } else {\n this.subdiv = defaults(p.subdiv, 6)\n }\n\n super.init(p)\n }\n\n getSplineParams (params?: Partial) {\n return Object.assign({\n subdiv: this.subdiv,\n tension: this.tension,\n directional: this.aspectRatio !== 1.0,\n smoothSheet: this.smoothSheet\n }, params)\n }\n\n getSpline (polymer: Polymer): Spline {\n return new Spline(polymer, this.getSplineParams())\n }\n\n getAspectRatio (polymer: Polymer): number {\n return polymer.isCg() ? 1.0 : this.aspectRatio\n }\n\n getAtomRadius (atom: AtomProxy): number {\n return atom.isTrace() ? super.getAtomRadius(atom) : 0\n }\n\n createData (sview: StructureView) {\n let bufferList: Buffer[] = []\n let polymerList: Polymer[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4) return\n polymerList.push(polymer)\n\n const spline = this.getSpline(polymer)\n const aspectRatio = this.getAspectRatio(polymer)\n\n const subPos = spline.getSubdividedPosition()\n const subOri = spline.getSubdividedOrientation()\n const subCol = spline.getSubdividedColor(this.getColorParams())\n const subPick = spline.getSubdividedPicking()\n const subSize = spline.getSubdividedSize(this.getRadiusParams())\n\n bufferList.push(\n new TubeMeshBuffer(\n Object.assign({}, subPos, subOri, subCol, subPick, subSize),\n this.getBufferParams({\n radialSegments: this.radialSegments,\n aspectRatio: aspectRatio,\n capped: this.capped\n })\n )\n )\n }, sview.getSelection())\n\n return {\n bufferList: bufferList,\n polymerList: polymerList\n }\n }\n\n updateData (what: any, data: StructureRepresentationData) {\n if (Debug) Log.time(this.type + ' repr update')\n\n what = what || {}\n\n for (var i = 0, il = data.polymerList!.length; i < il; ++i) {\n var bufferData: {[key: string]: any} = {}\n var polymer = data.polymerList![ i ]\n var spline = this.getSpline(polymer)\n var aspectRatio = this.getAspectRatio(polymer)\n\n Object.assign(data.bufferList[ i ], {aspectRatio: aspectRatio})\n\n if (what.position || what.radius) {\n var subPos = spline.getSubdividedPosition()\n var subOri = spline.getSubdividedOrientation()\n var subSize = spline.getSubdividedSize(this.getRadiusParams(aspectRatio))\n\n bufferData.position = subPos.position\n bufferData.normal = subOri.normal\n bufferData.binormal = subOri.binormal\n bufferData.tangent = subOri.tangent\n bufferData.size = subSize.size\n }\n\n if (what.color) {\n var subCol = spline.getSubdividedColor(this.getColorParams())\n bufferData.color = subCol.color\n }\n\n if (what.picking) {\n var subPick = spline.getSubdividedPicking()\n bufferData.picking = subPick.picking\n }\n\n data.bufferList[ i ].setAttributes(bufferData)\n }\n\n if (Debug) Log.timeEnd(this.type + ' repr update')\n }\n\n setParameters (params: Partial) {\n const rebuild = false\n var what: {[k: string]: any} = {}\n\n if (params && params.aspectRatio) {\n what.radius = true\n }\n\n if (params && params.tension) {\n what.position = true\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('cartoon', CartoonRepresentation)\n\nexport default CartoonRepresentation\n","/**\n * @file Contact Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { RepresentationRegistry } from '../globals'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport { calculateContacts, getContactData, getLabelData } from '../chemistry/interactions/contact'\nimport CylinderBuffer from '../buffer/cylinder-buffer'\nimport TextBuffer from '../buffer/text-buffer'\nimport { getFixedCountDashData } from '../geometry/dash'\nimport Viewer from '../viewer/viewer';\nimport { Structure } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport CylinderImpostorBuffer from '../buffer/cylinderimpostor-buffer';\n// @ts-ignore: unused import ContactPicker required for declaration only\nimport { ContactPicker } from '../utils/picker';\n\nexport interface ContactRepresentationParameters extends StructureRepresentationParameters {\n hydrogenBond: boolean\n weakHydrogenBond: boolean\n waterHydrogenBond: boolean\n backboneHydrogenBond: boolean\n hydrophobic: boolean\n halogenBond: boolean\n ionicInteraction: boolean\n metalCoordination: boolean\n cationPi: boolean\n piStacking: boolean\n filterSele: string|[string, string]\n maxHydrophobicDist: number\n maxHbondDist: number\n maxHbondSulfurDist: number\n maxHbondAccAngle: number\n maxHbondDonAngle: number\n maxHbondAccPlaneAngle: number\n maxHbondDonPlaneAngle: number\n maxPiStackingDist: number\n maxPiStackingOffset: number\n maxPiStackingAngle: number\n maxCationPiDist: number\n maxCationPiOffset: number\n maxIonicDist: number\n maxHalogenBondDist: number\n maxHalogenBondAngle: number\n maxMetalDist: number\n refineSaltBridges: boolean\n masterModelIndex: number\n lineOfSightDistFactor: number\n}\n\n/**\n * Contact representation.\n */\nclass ContactRepresentation extends StructureRepresentation {\n protected hydrogenBond: boolean\n protected weakHydrogenBond: boolean\n protected waterHydrogenBond: boolean\n protected backboneHydrogenBond: boolean\n protected hydrophobic: boolean\n protected halogenBond: boolean\n protected ionicInteraction: boolean\n protected metalCoordination: boolean\n protected cationPi: boolean\n protected piStacking: boolean\n protected filterSele: string|[string, string]\n protected maxHydrophobicDist: number\n protected maxHbondDist: number\n protected maxHbondSulfurDist: number\n protected maxHbondAccAngle: number\n protected maxHbondDonAngle: number\n protected maxHbondAccPlaneAngle: number\n protected maxHbondDonPlaneAngle: number\n protected maxPiStackingDist: number\n protected maxPiStackingOffset: number\n protected maxPiStackingAngle: number\n protected maxCationPiDist: number\n protected maxCationPiOffset: number\n protected maxIonicDist: number\n protected maxHalogenBondDist: number\n protected maxHalogenBondAngle: number\n protected maxMetalDist: number\n protected refineSaltBridges: boolean\n protected masterModelIndex: number\n protected lineOfSightDistFactor: number\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'contact'\n\n this.parameters = Object.assign({\n hydrogenBond: {\n type: 'boolean', rebuild: true\n },\n weakHydrogenBond: {\n type: 'boolean', rebuild: true\n },\n waterHydrogenBond: {\n type: 'boolean', rebuild: true\n },\n backboneHydrogenBond: {\n type: 'boolean', rebuild: true\n },\n hydrophobic: {\n type: 'boolean', rebuild: true\n },\n halogenBond: {\n type: 'boolean', rebuild: true\n },\n ionicInteraction: {\n type: 'boolean', rebuild: true\n },\n metalCoordination: {\n type: 'boolean', rebuild: true\n },\n cationPi: {\n type: 'boolean', rebuild: true\n },\n piStacking: {\n type: 'boolean', rebuild: true\n },\n\n filterSele: {\n type: 'text', rebuild: true\n },\n\n labelVisible: {\n type: 'boolean', rebuild: true\n },\n\n labelFixedSize: {\n type: 'boolean', buffer: 'fixedSize'\n },\n\n labelSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001, rebuild: true\n },\n\n labelUnit: {\n type: 'select',\n rebuild: true,\n options: { '': '', angstrom: 'angstrom', nm: 'nm' }\n },\n\n maxHydrophobicDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHbondDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHbondSulfurDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHbondAccAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n maxHbondDonAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n maxHbondAccPlaneAngle: {\n type: 'integer', max: 90, min: 0, rebuild: true\n },\n maxHbondDonPlaneAngle: {\n type: 'integer', max: 90, min: 0, rebuild: true\n },\n maxPiStackingDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxPiStackingOffset: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxPiStackingAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n maxCationPiDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxCationPiOffset: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxIonicDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHalogenBondDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHalogenBondAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n maxMetalDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n refineSaltBridges: {\n type: 'boolean', rebuild: true\n },\n masterModelIndex: {\n type: 'integer', max: 1000, min: -1, rebuild: true\n },\n lineOfSightDistFactor: {\n type: 'number', precision: 1, max: 10, min: 0.0, rebuild: true\n },\n\n radialSegments: true,\n disableImpostor: true\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.radiusSize = defaults(p.radiusSize, 0.05)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.hydrogenBond = defaults(p.hydrogenBond, true)\n this.weakHydrogenBond = defaults(p.weakHydrogenBond, false)\n this.waterHydrogenBond = defaults(p.waterHydrogenBond, false)\n this.backboneHydrogenBond = defaults(p.backboneHydrogenBond, false)\n this.hydrophobic = defaults(p.hydrophobic, false)\n this.halogenBond = defaults(p.halogenBond, true)\n this.ionicInteraction = defaults(p.ionicInteraction, true)\n this.metalCoordination = defaults(p.metalCoordination, true)\n this.cationPi = defaults(p.cationPi, true)\n this.piStacking = defaults(p.piStacking, true)\n\n this.filterSele = defaults(p.filterSele, '')\n this.labelVisible = defaults(p.labelVisible, false)\n this.labelFixedSize = defaults(p.labelFixedSize, false)\n this.labelSize = defaults(p.labelSize, 2.0)\n this.labelUnit = defaults(p.labelUnit, '')\n\n this.maxHydrophobicDist = defaults(p.maxHydrophobicDist, 4.0)\n this.maxHbondDist = defaults(p.maxHbondDist, 3.5)\n this.maxHbondSulfurDist = defaults(p.maxHbondSulfurDist, 4.1)\n this.maxHbondAccAngle = defaults(p.maxHbondAccAngle, 45)\n this.maxHbondDonAngle = defaults(p.maxHbondDonAngle, 45)\n this.maxHbondAccPlaneAngle = defaults(p.maxHbondAccPlaneAngle, 90)\n this.maxHbondDonPlaneAngle = defaults(p.maxHbondDonPlaneAngle, 30)\n this.maxPiStackingDist = defaults(p.maxPiStackingDist, 5.5)\n this.maxPiStackingOffset = defaults(p.maxPiStackingOffset, 2.0)\n this.maxPiStackingAngle = defaults(p.maxPiStackingAngle, 30)\n this.maxCationPiDist = defaults(p.maxCationPiDist, 6.0)\n this.maxCationPiOffset = defaults(p.maxCationPiOffset, 2.0)\n this.maxIonicDist = defaults(p.maxIonicDist, 5.0)\n this.maxHalogenBondDist = defaults(p.maxHalogenBondDist, 3.5)\n this.maxHalogenBondAngle = defaults(p.maxHalogenBondAngle, 30)\n this.maxMetalDist = defaults(p.maxMetalDist, 3.0)\n this.refineSaltBridges = defaults(p.refineSaltBridges, true)\n this.masterModelIndex = defaults(p.masterModelIndex, -1)\n this.lineOfSightDistFactor = defaults(p.lineOfSightDistFactor, 1.0)\n\n super.init(p)\n }\n\n getAtomRadius () {\n return 0\n }\n\n getContactData (sview: StructureView) {\n const params = {\n maxHydrophobicDist: this.maxHydrophobicDist,\n maxHbondDist: this.maxHbondDist,\n maxHbondSulfurDist: this.maxHbondSulfurDist,\n maxHbondAccAngle: this.maxHbondAccAngle,\n maxHbondDonAngle: this.maxHbondDonAngle,\n maxHbondAccPlaneAngle: this.maxHbondAccPlaneAngle,\n maxHbondDonPlaneAngle: this.maxHbondDonPlaneAngle,\n maxPiStackingDist: this.maxPiStackingDist,\n maxPiStackingOffset: this.maxPiStackingOffset,\n maxPiStackingAngle: this.maxPiStackingAngle,\n maxCationPiDist: this.maxCationPiDist,\n maxCationPiOffset: this.maxCationPiOffset,\n maxIonicDist: this.maxIonicDist,\n maxHalogenBondDist: this.maxHalogenBondDist,\n maxHalogenBondAngle: this.maxHalogenBondAngle,\n maxMetalDist: this.maxMetalDist,\n refineSaltBridges: this.refineSaltBridges,\n masterModelIndex: this.masterModelIndex,\n lineOfSightDistFactor: this.lineOfSightDistFactor\n }\n\n const dataParams = {\n hydrogenBond: this.hydrogenBond,\n weakHydrogenBond: this.weakHydrogenBond,\n waterHydrogenBond: this.waterHydrogenBond,\n backboneHydrogenBond: this.backboneHydrogenBond,\n hydrophobic: this.hydrophobic,\n halogenBond: this.halogenBond,\n ionicInteraction: this.ionicInteraction,\n metalCoordination: this.metalCoordination,\n cationPi: this.cationPi,\n piStacking: this.piStacking,\n radius: this.radiusSize * this.radiusScale,\n filterSele: this.filterSele\n }\n\n const contacts = calculateContacts(sview, params)\n return getContactData(contacts, sview, dataParams)\n }\n\n createData (sview: StructureView) {\n const contactData = this.getContactData(sview)\n\n const bufferList = [\n new CylinderBuffer(\n getFixedCountDashData(contactData),\n this.getBufferParams({\n sphereDetail: 1,\n dullInterior: true,\n disableImpostor: this.disableImpostor\n })\n ) as (CylinderGeometryBuffer | CylinderImpostorBuffer | TextBuffer)\n ]\n\n if (this.labelVisible) {\n const labelParams = {\n size: this.labelSize,\n unit: this.labelUnit\n }\n bufferList.push(new TextBuffer(\n getLabelData(contactData, labelParams),\n this.getBufferParams({fixedSize: this.labelFixedSize})\n ))\n }\n\n return { bufferList }\n }\n}\n\nRepresentationRegistry.add('contact', ContactRepresentation)\n\nexport default ContactRepresentation\n","/**\n * @file Dihedral Representation\n * @author Fred Ludlow \n * @private\n */\nimport { Color } from 'three'\n\nimport { RepresentationRegistry } from '../globals'\nimport MeasurementRepresentation, { calcArcPoint, parseNestedAtoms, MeasurementRepresentationParameters, LabelDataField } from './measurement-representation'\nimport { defaults } from '../utils'\n\nimport MeshBuffer from '../buffer/mesh-buffer'\nimport TextBuffer, { TextBufferData } from '../buffer/text-buffer'\nimport WideLineBuffer from '../buffer/wideline-buffer'\n\nimport { copyArray, uniformArray, uniformArray3 } from '../math/array-utils'\nimport { v3add, v3angle, v3cross, v3dot, v3multiplyScalar, v3fromArray, v3length,\n v3negate, v3new, v3normalize, v3sub, v3toArray } from '../math/vector-utils'\nimport { RAD2DEG } from '../math/math-constants'\nimport { getFixedLengthWrappedDashData } from '../geometry/dash'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { CylinderBufferData } from '../buffer/cylinder-buffer';\nimport { BufferData } from '../buffer/buffer';\nimport { StructureRepresentationData } from './structure-representation';\n\n/**\n * @typedef {Object} DihedralRepresentationParameters - dihedral representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n * @mixes MeasurementRepresentationParameters\n *\n * @property {String} atomQuad - list of quadruplets of selection strings\n * or atom indices\n * @property {Boolean} extendLine - Extend lines in planes\n * @property {Number} lineOpacity - Opacity for the line part of the representation\n * @property {Boolean} lineVisible - Display the line part of the representation\n * @property {Number} linewidth - width for line part of representation\n * @property {Boolean} planeVisible - Display the two planes corresponding to dihedral\n * @property {Boolean} sectorVisible - Display the filled arc for each angle\n */\n\nexport interface DihedralRepresentationParameters extends MeasurementRepresentationParameters {\n atomQuad: (number|string)[][]\n extendLine: boolean\n lineOpacity: number\n lineVisible: boolean\n linewidth: number\n planeVisible: boolean\n sectorVisible: boolean\n}\n\n/**\n * Dihedral representation object\n *\n * Reperesentation consists of three parts, visibility can be set for each\n * label - text label indicating dihedral angle\n * line - line indicating four positions that define the dihedral\n * sector - filled arc section\n *\n * @param {Structure} structure - the structure to measure angles in\n * @param {Viewer} viewer - a viewer object\n * @param {AngleRepresentationParameters} params - angle representation parameters\n */\nclass DihedralRepresentation extends MeasurementRepresentation {\n protected atomQuad: (number|string)[][]\n protected extendLine: boolean\n protected lineOpacity: number\n protected lineVisible: boolean\n protected linewidth: number\n protected planeVisible: boolean\n protected sectorVisible: boolean\n\n protected lineLength: number\n protected planeLength: number\n protected sectorLength: number\n\n protected lineBuffer: WideLineBuffer\n protected planeBuffer: MeshBuffer\n protected sectorBuffer: MeshBuffer\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'dihedral'\n\n this.parameters = Object.assign({\n atomQuad: {\n type: 'hidden', rebuild: true\n },\n extendLine: {\n type: 'boolean', rebuild: true, default: true\n },\n lineVisible: {\n type: 'boolean', default: true\n },\n planeVisible: {\n type: 'boolean', default: true\n },\n sectorVisible: {\n type: 'boolean', default: true\n }\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.side = defaults(p.side, 'double')\n p.opacity = defaults(p.opacity, 0.5)\n\n this.atomQuad = defaults(p.atomQuad, [])\n this.extendLine = defaults(p.extendLine, true)\n this.lineVisible = defaults(p.lineVisible, true)\n this.planeVisible = defaults(p.planeVisible, true)\n this.sectorVisible = defaults(p.sectorVisible, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n if (!sview.atomCount || !this.atomQuad.length) return\n\n const atomPosition = parseNestedAtoms(sview, this.atomQuad)\n const dihedralData = getDihedralData(\n atomPosition, {\n extendLine: this.extendLine\n }\n )\n\n const n = this.n = dihedralData.labelText.length\n const labelColor = new Color(this.labelColor)\n\n this.textBuffer = new TextBuffer({\n position: dihedralData.labelPosition,\n size: uniformArray(n, this.labelSize),\n color: uniformArray3(n, labelColor.r, labelColor.g, labelColor.b),\n text: dihedralData.labelText\n } as TextBufferData, this.getLabelBufferParams())\n\n const c = new Color(this.colorValue)\n this.lineLength = dihedralData.linePosition1.length / 3\n const lineColor = uniformArray3(this.lineLength, c.r, c.g, c.b)\n\n this.lineBuffer = new WideLineBuffer(\n getFixedLengthWrappedDashData({\n position1: dihedralData.linePosition1,\n position2: dihedralData.linePosition2,\n color: lineColor,\n color2: lineColor\n } as CylinderBufferData) ,\n this.getBufferParams({\n linewidth: this.linewidth,\n visible: this.lineVisible,\n opacity: this.lineOpacity\n })\n )\n\n this.planeLength = dihedralData.planePosition.length / 3\n this.planeBuffer = new MeshBuffer({\n position: dihedralData.planePosition,\n color: uniformArray3(this.planeLength, c.r, c.g, c.b)\n } as BufferData, this.getBufferParams({\n visible: this.planeVisible\n }))\n\n this.sectorLength = dihedralData.sectorPosition.length / 3\n this.sectorBuffer = new MeshBuffer({\n position: dihedralData.sectorPosition,\n color: uniformArray3(this.sectorLength, c.r, c.g, c.b)\n } as BufferData, this.getBufferParams({\n visible: this.sectorVisible\n }))\n\n return {\n bufferList: [\n this.textBuffer,\n this.lineBuffer,\n this.planeBuffer,\n this.sectorBuffer\n ]\n }\n }\n\n updateData (what: LabelDataField & {color?: boolean}, data: StructureRepresentationData) {\n super.updateData(what, data)\n const lineData = {}\n const planeData = {}\n const sectorData = {}\n\n if (what.color) {\n const c = new Color(this.colorValue)\n Object.assign(lineData, {\n color: uniformArray3(this.lineLength, c.r, c.g, c.b),\n color2: uniformArray3(this.lineLength, c.r, c.g, c.b)\n })\n Object.assign(planeData, {\n color: uniformArray3(this.planeLength, c.r, c.g, c.b)\n })\n Object.assign(sectorData, {\n color: uniformArray3(this.sectorLength, c.r, c.g, c.b)\n })\n }\n\n this.lineBuffer.setAttributes(lineData)\n this.planeBuffer.setAttributes(planeData)\n this.sectorBuffer.setAttributes(sectorData)\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n super.setParameters(params, what, rebuild)\n\n if (params && (\n params.lineVisible !== undefined ||\n params.sectorVisible !== undefined ||\n params.planeVisible !== undefined)) {\n this.setVisibility(this.visible)\n }\n\n if (params && params.lineOpacity) {\n this.lineBuffer.setParameters({ opacity: params.lineOpacity })\n }\n\n if (params && params.opacity !== undefined) {\n this.lineBuffer.setParameters({ opacity: this.lineOpacity })\n }\n\n if (params && params.linewidth) {\n this.lineBuffer.setParameters({ linewidth: params.linewidth })\n }\n\n return this\n }\n\n setVisibility (value: boolean, noRenderRequest?: boolean) {\n super.setVisibility(value, true)\n\n if (this.lineBuffer) {\n this.lineBuffer.setVisibility(this.lineVisible && this.visible)\n }\n\n if (this.planeBuffer) {\n this.planeBuffer.setVisibility(this.planeVisible && this.visible)\n }\n\n if (this.sectorBuffer) {\n this.sectorBuffer.setVisibility(this.sectorVisible && this.visible)\n }\n\n if (!noRenderRequest) this.viewer.requestRender()\n\n return this\n }\n}\n\n/**\n * Build the data required to create {Buffer} objects, given positions\n * @param {Float32Array} atomPosition 3*4*nDihedral array of coordinates\n * @return {Object} Arrays for building buffers\n */\nfunction getDihedralData (position: Float32Array, params: Partial = {}) {\n const angleStep = defaults(params.angleStep, Math.PI / 90)\n const nPos = position.length\n const n = position.length / 12\n const angles = new Float32Array(n)\n const labelPosition = new Float32Array(n * 3)\n const labelText = new Array(n)\n\n // Temporary arrays as don't know output length yet\n const lineTmp1 = new Array(n)\n const lineTmp2 = new Array(n)\n const sectorTmp = new Array(n)\n const planeTmp = new Array(n)\n\n // Eventual sizes of output arrays\n let totalLines = 0\n let totalSegments = 0\n let totalPlanes = 0\n\n const p1 = v3new()\n const p2 = v3new()\n const p3 = v3new()\n const p4 = v3new()\n\n const v21 = v3new()\n const v23 = v3new()\n const v34 = v3new()\n\n const tmp = v3new()\n const mid = v3new()\n const inPlane1 = v3new()\n const inPlane2 = v3new()\n const start = v3new()\n const end = v3new()\n\n const cross = v3new()\n const arcPoint = v3new()\n\n let i = 0 // Actual output index (after skipping inappropriate)\n\n for (var p = 0; p < nPos; p += 12) {\n // Set Positions\n v3fromArray(p1, position, p)\n v3fromArray(p2, position, p + 3)\n v3fromArray(p3, position, p + 6)\n v3fromArray(p4, position, p + 9)\n\n // Vectors between points\n v3sub(v21, p1, p2)\n v3sub(v23, p3, p2)\n if (v3length(v23) === 0.0) {\n continue // Can't define axis\n }\n\n v3sub(v34, p4, p3)\n\n v3multiplyScalar(tmp, v23, 0.5)\n v3add(mid, p2, tmp)\n\n v3normalize(v21, v21)\n v3normalize(v23, v23)\n v3normalize(v34, v34)\n\n // Which side of plane are p1, p4 (are we measuring something that\n // looks more like an improper? e.g. C, CA, CB, N)\n v3sub(tmp, p1, mid)\n const improperStart = v3dot(tmp, v23) > 0.0\n v3sub(tmp, p4, mid)\n const improperEnd = v3dot(tmp, v23) < 0.0\n\n // Calculate vectors perp to v23 (lying in plane (1,2,3) and (2,3,4))\n v3multiplyScalar(tmp, v23, v3dot(v23, v21))\n v3sub(inPlane1, v21, tmp)\n\n v3multiplyScalar(tmp, v23, v3dot(v23, v34))\n v3sub(inPlane2, v34, tmp)\n\n if (v3length(inPlane1) === 0.0 || v3length(inPlane2) === 0.0) {\n continue // Indeterminate angle\n }\n\n v3normalize(inPlane1, inPlane1)\n v3normalize(inPlane2, inPlane2)\n\n const angle = angles[ i ] = v3angle(inPlane1, inPlane2)\n labelText[ i ] = (RAD2DEG * angle).toFixed(1) + String.fromCharCode(0x00B0)\n\n v3cross(cross, inPlane1, v23)\n v3normalize(cross, cross)\n if (v3dot(cross, inPlane2) < 0.0) {\n v3negate(cross, cross) // Ensure cp faces correct way\n }\n\n calcArcPoint(tmp, mid, inPlane1, cross, angle / 2.0)\n v3toArray(tmp, labelPosition, 3 * i)\n\n const nSegments = Math.ceil(angle / angleStep)\n // For extended display mode, 4 straight lines plus arc/segment edge\n // For non-extended, 2 straight lines plus segment edge\n const nLines = nSegments + ((params.extendLine) ? 4 : 2)\n\n // Don't draw planes if not extending lines\n const nPlanes = params.extendLine ? 36 : 0\n\n const line1 = new Float32Array(nLines * 3)\n const line2 = new Float32Array(nLines * 3)\n const sector = new Float32Array(nSegments * 9)\n // 2 planes, 2 triangles each per dihedral (2*2*9)\n const plane = new Float32Array(nPlanes)\n\n lineTmp1[ i ] = line1\n lineTmp2[ i ] = line2\n sectorTmp[ i ] = sector\n planeTmp[ i ] = plane\n\n // Start points for lines/planes, only required\n // if extending lines\n if (params.extendLine) {\n if (improperStart) { // We'll start on the v3->1 line (tmp)\n v3sub(tmp, p1, p3)\n v3normalize(tmp, tmp)\n v3multiplyScalar(start, tmp, 1.0 / v3dot(inPlane1, tmp))\n v3add(start, start, p3)\n } else { // start on the 2->1 line\n v3multiplyScalar(start, v21, 1.0 / v3dot(inPlane1, v21))\n v3add(start, start, p2)\n }\n\n if (improperEnd) { // Finish on 2->4 line\n v3sub(tmp, p4, p2)\n v3normalize(tmp, tmp)\n v3multiplyScalar(end, tmp, 1.0 / v3dot(inPlane2, tmp))\n v3add(end, end, p2)\n } else { // end on the 3->4 line\n v3multiplyScalar(end, v34, 1.0 / v3dot(inPlane2, v34))\n v3add(end, end, p3)\n }\n }\n\n v3add(arcPoint, mid, inPlane1)\n\n // index into line1, line2\n let li = 0\n // If extending lines, there's a bit of stuff to do here\n // figuring out start and end positions\n if (params.extendLine) {\n v3toArray(p1, line1, li)\n v3toArray(start, line2, li)\n li += 3\n v3toArray(start, line1, li)\n v3toArray(arcPoint, line2, li)\n li += 3\n\n // Construct plane at start, if not extening lines\n // this is skipped\n v3toArray(start, plane, 0)\n v3toArray(arcPoint, plane, 3)\n v3toArray(improperStart ? p3 : p2, plane, 6)\n v3toArray(improperStart ? p3 : p2, plane, 9)\n v3toArray(arcPoint, plane, 12)\n v3toArray(mid, plane, 15)\n } else {\n // Not extending lines\n v3toArray(mid, line1, li)\n v3toArray(arcPoint, line2, li)\n li += 3\n }\n\n const appendArcSection = function (a: number, j: number) {\n const si = j * 9\n\n v3toArray(mid, sector, si)\n v3toArray(arcPoint, sector, si + 3)\n v3toArray(arcPoint, line1, li)\n\n calcArcPoint(arcPoint, mid, inPlane1, cross, a)\n\n v3toArray(arcPoint, sector, si + 6)\n v3toArray(arcPoint, line2, li)\n li += 3\n }\n\n let j = 0\n for (let a = angleStep; a < angle; a += angleStep) {\n appendArcSection(a, j++)\n }\n appendArcSection(angle, j++)\n\n if (params.extendLine) {\n v3toArray(arcPoint, line1, (nLines - 2) * 3)\n v3toArray(end, line2, (nLines - 2) * 3)\n v3toArray(end, line1, (nLines - 1) * 3)\n v3toArray(p4, line2, (nLines - 1) * 3)\n\n // Construct plane at end\n v3toArray(end, plane, 18)\n v3toArray(arcPoint, plane, 21)\n v3toArray(improperEnd ? p2 : p3, plane, 24)\n v3toArray(improperEnd ? p2 : p3, plane, 27)\n v3toArray(arcPoint, plane, 30)\n v3toArray(mid, plane, 33)\n } else {\n v3toArray(arcPoint, line1, li)\n v3toArray(mid, line2, li)\n li += 3\n }\n\n totalLines += nLines * 3\n totalSegments += nSegments * 9\n totalPlanes += nPlanes\n i += 1\n }\n\n const nSuccess = i\n\n const linePosition1 = new Float32Array(totalLines)\n const linePosition2 = new Float32Array(totalLines)\n const sectorPosition = new Float32Array(totalSegments)\n const planePosition = new Float32Array(totalPlanes)\n\n let lineOffset = 0\n let sectorOffset = 0\n let planeOffset = 0\n\n for (let i = 0; i < nSuccess; i++) {\n const lp1 = lineTmp1[ i ]\n const lp2 = lineTmp2[ i ]\n const sp = sectorTmp[ i ]\n const pp = planeTmp[ i ]\n\n copyArray(lp1, linePosition1, 0, lineOffset, lp1.length)\n copyArray(lp2, linePosition2, 0, lineOffset, lp2.length)\n copyArray(sp, sectorPosition, 0, sectorOffset, sp.length)\n copyArray(pp, planePosition, 0, planeOffset, pp.length)\n\n lineOffset += lp1.length\n sectorOffset += sp.length\n planeOffset += pp.length\n }\n\n return {\n labelPosition: labelPosition.subarray(0, nSuccess * 3),\n labelText: labelText.slice(0, nSuccess),\n linePosition1,\n linePosition2,\n planePosition,\n sectorPosition\n }\n}\n\nRepresentationRegistry.add('dihedral', DihedralRepresentation)\n\nexport default DihedralRepresentation\n","/**\n * @file Dihedral Histogram Representation\n * @author Rudolfs Petrovs \n * @private\n */\nimport { Color } from 'three'\n\nimport { calcArcPoint, parseNestedAtoms } from './measurement-representation'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\n\nimport { RepresentationRegistry } from '../globals'\nimport { Structure } from '../ngl'\nimport { defaults } from '../utils'\n\nimport { BufferData } from '../buffer/buffer'\nimport MeshBuffer from '../buffer/mesh-buffer'\nimport WideLineBuffer, { WideLineBufferData } from '../buffer/wideline-buffer'\n\nimport { copyArray, uniformArray3, arraySum } from '../math/array-utils'\nimport {\n v3add, v3cross, v3dot, v3multiplyScalar, v3fromArray,\n v3negate, v3new, v3normalize, v3sub, v3toArray, v3length\n} from '../math/vector-utils'\n\nimport StructureView from '../structure/structure-view'\n\nimport Viewer from '../viewer/viewer'\n\n\nconst pointLength = 3 // One Point Length (number of coordinates of one point in 3D)\nconst pointsInTriangle = 3\n\ntype ColorDefinition = Color | string | number | undefined\n\ninterface HistogramColorParameters {\n histogramBinBorderColor: ColorDefinition\n adjacentBondArrowColor: ColorDefinition\n distantBondArrowColor: ColorDefinition\n frontHistogramColor: ColorDefinition\n backHistogramColor: ColorDefinition\n opaqueMiddleDiscColor: ColorDefinition\n}\n\ninterface HistogramInputData extends Partial {\n atomQuad: (number | string)[]\n histogram360: number[]\n}\n\ninterface HistogramData extends HistogramInputData {\n atomPositions: Float32Array\n histogram360Scaled: number[]\n}\n\ninterface WideLineData {\n startPoints: Float32Array\n endPoints: Float32Array\n startColors: Float32Array\n endColors: Float32Array\n}\n\ninterface MeshData {\n triangles: Float32Array\n triangleColors: Float32Array\n}\n\nfunction createUpdatedObject(o: Object, updateSource: Object) {\n function hasKey(obj: O, key: keyof any): key is keyof O {\n return key in obj\n }\n\n const result = { ...o } // Shallow copy\n for (const key in result) {\n if (hasKey(result, key) && hasKey(updateSource, key)) {\n result[key] = defaults(updateSource[key], result[key])\n }\n }\n return result\n}\n\nfunction createColorArray(color: ColorDefinition, arrayLength: number) {\n const colorValue = new Color(color)\n const targetArray = new Float32Array(arrayLength * 3)\n uniformArray3(arrayLength, colorValue.r, colorValue.g, colorValue.b, targetArray)\n return targetArray\n}\n\n/**\n * @typedef {Object} DihedralHistogramRepresentationParameters - dihedral representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n *\n * @property {HistogramInputData[]} histogramsData\n * List of HistogramInputData objects, which properties specifies each particular\n * histogram, and can contain particular histogram-specific parameters.\n * Obligatory properties are:\n * atomQuad - Quadruplet of selection strings or atom indices\n * histogram360 - List of values, representing histogram from 0 to 360 degrees.\n * @property {Boolean} histogramBinBorderVisible - Display the lines that separate circular histogram bins\n * @property {Boolean} scaleBinToSectorArea - Should sector-based histogram bins'\n * area be proportional to the bins' value\n */\n\nexport interface DihedralHistogramRepresentationParameters extends StructureRepresentationParameters {\n histogramsData: HistogramInputData[]\n\n histogramBinBorderVisible: boolean\n scaleBinToSectorArea: boolean\n}\n\n/**\n * Dihedral Histogram representation object\n *\n * Reperesentation consists of several parts:\n * opaqueMiddleDisc - opaque disc in the middle of the dihedral between front and back histograms\n * frontHistogram - circular histogram from the adjacent bond viewpoint\n * backHistogram - circular histogram from the distant bond viewpoint\n * histogramBinBorder - lines, which separate histogram bins\n * bondArrows - lines, which show the actual angle on the histogram disc\n *\n * @param {Structure} structure - the structure to measure angles in\n * @param {Viewer} viewer - a viewer object\n * @param {DihedralHistogramRepresentationParameters} params - Dihedral histogram representation parameters\n */\nclass DihedralHistogramRepresentation extends StructureRepresentation {\n protected histogramsData: HistogramData[]\n\n protected histogramBinBorderVisible: boolean\n protected histogramBinBorderWidth: number\n protected histogramBinBorderColor: ColorDefinition\n protected histogramBinBorderOpacity: number\n\n protected bondArrowVisible: boolean\n protected bondArrowWidth: number\n protected bondArrowOpacity: number\n\n protected adjacentBondArrowColor: ColorDefinition\n protected distantBondArrowColor: ColorDefinition\n\n protected histogramOpacity: number\n protected frontHistogramColor: ColorDefinition\n protected backHistogramColor: ColorDefinition\n\n protected opaqueMiddleDiscVisible: boolean\n protected opaqueMiddleDiscColor: ColorDefinition\n protected opaqueMiddleDiscOpacity: number\n\n protected scaleBinToSectorArea: boolean\n\n constructor(structure: Structure, viewer: Viewer, params: DihedralHistogramRepresentationParameters) {\n super(structure, viewer, params)\n\n this.type = 'dihedral-histogram'\n\n this.parameters = Object.assign({\n histogramsData: {\n type: 'hidden', rebuild: true\n },\n histogramBinBorderVisible: {\n type: 'boolean', default: true\n },\n scaleBinToSectorArea: {\n type: 'boolean',\n rebuild: true,\n default: false\n }\n }, this.parameters)\n\n this.init(params)\n }\n\n init(params: Partial) {\n const p = params || {}\n\n const defaultColorData = {\n histogramBinBorderColor: 'grey',\n adjacentBondArrowColor: 'black',\n distantBondArrowColor: 'magenta',\n frontHistogramColor: 'green',\n backHistogramColor: 'blue',\n opaqueMiddleDiscColor: 'white'\n }\n\n const colorData = createUpdatedObject(defaultColorData, p)\n Object.assign(this, colorData)\n\n const defaultParameters = {\n histogramsData: [],\n histogramOpacity: 1.0,\n\n opaqueMiddleDiscVisible: true,\n opaqueMiddleDiscOpacity: 1.0,\n\n histogramBinBorderVisible: true,\n histogramBinBorderWidth: 1,\n histogramBinBorderOpacity: 0.5,\n\n bondArrowVisible: true,\n bondArrowWidth: 2,\n bondArrowOpacity: 1.0,\n\n scaleBinToSectorArea: false,\n }\n const parameters = createUpdatedObject(defaultParameters, p)\n Object.assign(this, parameters)\n\n this.histogramsData.forEach(x => {\n const specificColorData = createUpdatedObject(colorData, x)\n Object.assign(x, specificColorData)\n })\n\n p.side = defaults(p.side, 'double')\n p.opacity = defaults(p.opacity, 0.5)\n p.radiusType = defaults(p.radiusType, 'size')\n p.radiusSize = defaults(p.radiusSize, 0.15)\n\n super.init(p)\n }\n\n getHistogramBinBorderBufferParameters() {\n return this.getBufferParams({\n linewidth: this.histogramBinBorderWidth,\n visible: this.histogramBinBorderVisible,\n opacity: this.histogramBinBorderOpacity,\n })\n }\n\n getBondArrowsBufferParameters() {\n return this.getBufferParams({\n linewidth: this.bondArrowWidth,\n visible: this.bondArrowVisible,\n opacity: this.bondArrowOpacity,\n })\n }\n\n getOpaqueMiddleDiscBufferParameters() {\n return this.getBufferParams({\n visible: this.opaqueMiddleDiscVisible,\n opacity: this.opaqueMiddleDiscOpacity\n })\n }\n\n getHistogramBufferParameters() {\n return this.getBufferParams({\n visible: true,\n opacity: this.histogramOpacity,\n side: \"double\"\n })\n }\n\n createData(sview: StructureView) {\n if (!sview.atomCount || !this.histogramsData.length) return\n this.histogramsData.forEach(x => x.atomPositions = parseNestedAtoms(sview, [x.atomQuad]))\n const scaleData = this.scaleBinToSectorArea ? function (y: number) { return Math.sqrt(y) } : function (y: number) { return y }\n this.histogramsData.forEach(x => x.histogram360Scaled = x.histogram360.map(scaleData))\n function Float32Concat(arrays: Float32Array[]) {\n const lengths = arrays.map(x => x.length)\n const result = new Float32Array(arraySum(lengths))\n let accumulatedOffset = 0\n for (let i = 0; i < arrays.length; i++) {\n result.set(arrays[i], accumulatedOffset)\n accumulatedOffset += arrays[i].length\n }\n return result\n }\n\n function createWideLineBuffer(linesList: WideLineData[], params: {}) {\n return new WideLineBuffer(\n {\n position1: Float32Concat(linesList.map(x => x.startPoints)),\n position2: Float32Concat(linesList.map(x => x.endPoints)),\n color: Float32Concat(linesList.map(x => x.startColors)),\n color2: Float32Concat(linesList.map(x => x.endColors)),\n } as WideLineBufferData,\n params)\n }\n\n function createMeshBuffer(mesh: MeshData[], params: {}) {\n return new MeshBuffer(\n {\n position: Float32Concat(mesh.map(x => x.triangles)),\n color: Float32Concat(mesh.map(x => x.triangleColors))\n } as BufferData,\n params)\n }\n\n const dihedralDataArray = []\n\n for (let i = 0; i < this.histogramsData.length; i++) {\n let dihedralData = undefined\n let currentHistogramData = this.histogramsData[i]\n let currentHistogram360 = currentHistogramData.histogram360\n if (currentHistogram360.length >= 3) {\n dihedralData = calculateDihedralHistogram(currentHistogramData)\n }\n if (typeof dihedralData === \"undefined\") continue\n dihedralDataArray.push(dihedralData)\n }\n\n this.frontHistogramBinBordersBuffer = createWideLineBuffer(\n dihedralDataArray.map(x => x.frontHistogramBinBorders),\n this.getHistogramBinBorderBufferParameters()\n )\n\n this.backHistogramBinBordersBuffer = createWideLineBuffer(\n dihedralDataArray.map(x => x.backHistogramBinBorders),\n this.getHistogramBinBorderBufferParameters()\n )\n\n this.adjacentBondArrowsBuffer = createWideLineBuffer(\n dihedralDataArray.map(x => x.adjacentBondArrows),\n this.getBondArrowsBufferParameters()\n )\n\n this.distantBondArrowsBuffer = createWideLineBuffer(\n dihedralDataArray.map(x => x.distantBondArrows),\n this.getBondArrowsBufferParameters()\n )\n\n this.opaqueMiddleDiscBuffer = createMeshBuffer(\n dihedralDataArray.map(x => x.opaqueMiddleDisc),\n this.getOpaqueMiddleDiscBufferParameters()\n )\n\n this.frontHistogramBuffer = createMeshBuffer(\n dihedralDataArray.map(x => x.frontHistogram),\n this.getHistogramBufferParameters()\n )\n\n this.backHistogramBuffer = createMeshBuffer(\n dihedralDataArray.map(x => x.backHistogram),\n this.getHistogramBufferParameters()\n )\n\n return {\n bufferList: [].concat(\n this.frontHistogramBinBordersBuffer,\n this.backHistogramBinBordersBuffer,\n this.adjacentBondArrowsBuffer,\n this.distantBondArrowsBuffer,\n this.opaqueMiddleDiscBuffer,\n this.frontHistogramBuffer,\n this.backHistogramBuffer\n )\n }\n }\n\n setParameters(params: Partial) {\n const rebuild = false\n const what = {}\n super.setParameters(params, what, rebuild)\n\n if (params && (params.histogramBinBorderVisible !== undefined)) {\n this.setVisibility(this.visible)\n }\n return this\n }\n\n setVisibility(value: boolean, noRenderRequest?: boolean) {\n super.setVisibility(value, true)\n if (this.frontHistogramBinBordersBuffer) {\n this.frontHistogramBinBordersBuffer.setVisibility(this.histogramBinBorderVisible)\n }\n if (this.backHistogramBinBordersBuffer) {\n this.backHistogramBinBordersBuffer.setVisibility(this.histogramBinBorderVisible)\n }\n if (!noRenderRequest) this.viewer.requestRender()\n return this\n }\n}\n\n/**\n * Calculates the data required to create {Buffer} objects for one histogram, given positions\n * @param Float32Array positionOfDihedralAtoms 3*4 array of coordinates\n * @param NumberArray histogram array of coordinates\n * @return Arrays for building buffers\n */\nfunction calculateDihedralHistogram(histogramData: HistogramData) {\n const positionOfDihedralAtoms = histogramData.atomPositions\n const histogram = histogramData.histogram360Scaled;\n const totalSectorTrianglesInOpaqueMiddleDisc = histogram.length <= 180 ? 360 : histogram.length * 2\n const frontAndBack = 2\n\n const opaqueMiddleDisc = {\n triangles: new Float32Array(totalSectorTrianglesInOpaqueMiddleDisc * pointsInTriangle * pointLength),\n triangleColors: createColorArray(histogramData.opaqueMiddleDiscColor, totalSectorTrianglesInOpaqueMiddleDisc * pointsInTriangle)\n }\n\n const frontHistogram = {\n triangles: new Float32Array(histogram.length * pointsInTriangle * pointLength),\n triangleColors: createColorArray(histogramData.frontHistogramColor, histogram.length * pointsInTriangle)\n }\n\n const backHistogram = {\n triangles: new Float32Array(histogram.length * pointsInTriangle * pointLength),\n triangleColors: createColorArray(histogramData.backHistogramColor, histogram.length * pointsInTriangle)\n }\n\n const frontHistogramBinBorders = {\n startPoints: new Float32Array(histogram.length * pointLength),\n endPoints: new Float32Array(histogram.length * pointLength),\n startColors: createColorArray(histogramData.histogramBinBorderColor, histogram.length),\n endColors: createColorArray(histogramData.histogramBinBorderColor, histogram.length)\n }\n\n const backHistogramBinBorders = {\n startPoints: new Float32Array(histogram.length * pointLength),\n endPoints: new Float32Array(histogram.length * pointLength),\n startColors: createColorArray(histogramData.histogramBinBorderColor, histogram.length),\n endColors: createColorArray(histogramData.histogramBinBorderColor, histogram.length)\n }\n\n const adjacentBondArrows = {\n startPoints: new Float32Array(frontAndBack * pointLength),\n endPoints: new Float32Array(frontAndBack * pointLength),\n startColors: createColorArray(histogramData.adjacentBondArrowColor, histogram.length),\n endColors: createColorArray(histogramData.adjacentBondArrowColor, histogram.length)\n }\n const distantBondArrows = {\n startPoints: new Float32Array(frontAndBack * pointLength),\n endPoints: new Float32Array(frontAndBack * pointLength),\n startColors: createColorArray(histogramData.distantBondArrowColor, histogram.length),\n endColors: createColorArray(histogramData.distantBondArrowColor, histogram.length)\n }\n\n const p1 = v3new()\n const p2 = v3new()\n const p3 = v3new()\n const p4 = v3new()\n\n const v21 = v3new()\n const v23 = v3new()\n const v32 = v3new()\n const v34 = v3new()\n\n const mid = v3new()\n const inPlane1 = v3new()\n const inPlane2 = v3new()\n\n const cross1 = v3new()\n const cross2 = v3new()\n\n const arcPoint = v3new()\n const tmp = v3new()\n const tmp2 = v3new()\n\n // Set Atom Coordinates\n const dihedralAtomVectors = [p1, p2, p3, p4]\n\n for (let i = 0; i < dihedralAtomVectors.length; i++) {\n v3fromArray(dihedralAtomVectors[i], positionOfDihedralAtoms, i * pointLength)\n }\n\n // Vectors between points\n v3sub(v21, p1, p2)\n v3sub(v23, p3, p2)\n v3sub(v34, p4, p3)\n if (v3length(v23) === 0.0) {\n return // Can't define axis\n }\n\n v3multiplyScalar(tmp, v23, 0.5)\n v3add(mid, p2, tmp)\n\n v3normalize(v21, v21)\n v3normalize(v23, v23)\n v3normalize(v34, v34)\n\n v3negate(v32, v23)\n // Calculate vectors perp to v23 (lying in plane (1,2,3) and (2,3,4))\n v3multiplyScalar(tmp, v32, v3dot(v32, v21))\n v3sub(inPlane1, v21, tmp)\n\n v3multiplyScalar(tmp, v23, v3dot(v23, v34))\n v3sub(inPlane2, v34, tmp)\n\n if (v3length(inPlane1) === 0.0 || v3length(inPlane2) === 0.0) {\n return // Indeterminate angle\n }\n\n v3normalize(inPlane1, inPlane1)\n v3normalize(inPlane2, inPlane2)\n\n // Can use acos as normalized and non-zero\n const absAngle = Math.acos(v3dot(inPlane1, inPlane2))\n\n v3cross(cross1, v32, inPlane1)\n v3cross(cross2, v23, inPlane2)\n v3normalize(cross1, cross1)\n v3normalize(cross2, cross2)\n\n let angle = absAngle\n if (v3dot(cross1, inPlane2) < 0.0) {\n angle = -absAngle\n }\n\n v3add(arcPoint, mid, inPlane1)\n\n // Calculate necessary constants\n const maxHist = Math.max.apply(null, histogram)\n const histBinAngleStep = (Math.PI * 2) / histogram.length\n\n function setHistogramBinCoordinates(out: Float32Array, ind: number, zeroDegreeVector: Float32Array, crossVector: Float32Array, histBinAngleStep: number) {\n const startOffset = ind * pointsInTriangle * pointLength\n v3toArray(mid, out, startOffset)\n const scalingFactor = Number(histogram[ind]) / maxHist\n v3multiplyScalar(tmp, zeroDegreeVector, scalingFactor)\n v3multiplyScalar(tmp2, crossVector, scalingFactor)\n calcArcPoint(arcPoint, mid, tmp, tmp2, ind * histBinAngleStep)\n v3toArray(arcPoint, out, startOffset + 1 * pointLength)\n calcArcPoint(arcPoint, mid, tmp, tmp2, (ind + 1) * histBinAngleStep)\n v3toArray(arcPoint, out, startOffset + 2 * pointLength)\n }\n\n function setOneSideHistogram(discHistogram: MeshData, binBorders: { startPoints: Float32Array, endPoints: Float32Array }, ind: number, zeroDegreeVector: Float32Array, crossVector: Float32Array) {\n // Set Bond Arrows\n\n copyArray(mid, adjacentBondArrows.startPoints, 0, ind * pointLength, mid.length)\n calcArcPoint(tmp, mid, zeroDegreeVector, crossVector, 0 + histBinAngleStep * 0)\n copyArray(tmp, adjacentBondArrows.endPoints, 0, ind * pointLength, mid.length)\n\n copyArray(mid, distantBondArrows.startPoints, 0, ind * pointLength, mid.length)\n calcArcPoint(tmp, mid, zeroDegreeVector, crossVector, angle)\n copyArray(tmp, distantBondArrows.endPoints, 0, ind * pointLength, mid.length)\n\n // Set Histogram Bin Borders\n\n for (let i = 0; i < histogram.length; i++) {\n copyArray(mid, binBorders.startPoints, 0, i * 3, mid.length)\n calcArcPoint(tmp, mid, zeroDegreeVector, crossVector, 0 + histBinAngleStep * i)\n copyArray(tmp, binBorders.endPoints, 0, i * 3, tmp.length)\n }\n\n // Set Histogram Bins\n\n for (let sectionIndex = 0; sectionIndex < histogram.length; sectionIndex++) {\n setHistogramBinCoordinates(discHistogram.triangles, sectionIndex, zeroDegreeVector, crossVector, histBinAngleStep)\n }\n }\n\n // Opaque disc\n const opaqueCircleSectorAngleStep = Math.PI * 2 / totalSectorTrianglesInOpaqueMiddleDisc\n\n for (let sectionIndex = 0; sectionIndex < totalSectorTrianglesInOpaqueMiddleDisc; sectionIndex++) {\n const startOffset = sectionIndex * pointsInTriangle * pointLength\n v3toArray(mid, opaqueMiddleDisc.triangles, startOffset)\n calcArcPoint(arcPoint, mid, inPlane1, cross1, sectionIndex * opaqueCircleSectorAngleStep)\n v3toArray(arcPoint, opaqueMiddleDisc.triangles, startOffset + 1 * pointLength)\n calcArcPoint(arcPoint, mid, inPlane1, cross1, (sectionIndex + 1) * opaqueCircleSectorAngleStep)\n v3toArray(arcPoint, opaqueMiddleDisc.triangles, startOffset + 2 * pointLength)\n }\n\n // Front Histogram\n const distanceToOpaqueDisc = 0.01\n v3multiplyScalar(tmp, v23, -distanceToOpaqueDisc) // Get a vector to move \"mid\" just a bit from opaque disc\n v3add(mid, mid, tmp)\n setOneSideHistogram(frontHistogram, frontHistogramBinBorders, 0, inPlane1, cross1)\n\n // Back Histogram\n v3multiplyScalar(tmp, v23, 2 * distanceToOpaqueDisc) // Get a vector to move \"mid\" back and plus just a bit from opaque disc the other way\n v3add(mid, mid, tmp)\n setOneSideHistogram(backHistogram, backHistogramBinBorders, 1, inPlane2, cross2)\n\n return {\n opaqueMiddleDisc,\n frontHistogram,\n backHistogram,\n frontHistogramBinBorders,\n backHistogramBinBorders,\n adjacentBondArrows,\n distantBondArrows\n }\n}\n\nRepresentationRegistry.add('dihedral-histogram', DihedralHistogramRepresentation)\n\nexport default DihedralHistogramRepresentation\n","/**\n * @file Distance Representation\n * @author Alexander Rose \n * @author Fred Ludlow \n * @private\n */\n\nimport { Color } from 'three'\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { DistancePicker } from '../utils/picker'\nimport { uniformArray, uniformArray3 } from '../math/array-utils'\nimport BitArray from '../utils/bitarray'\nimport MeasurementRepresentation, { MeasurementRepresentationParameters } from './measurement-representation'\nimport Selection from '../selection/selection'\nimport BondStore from '../store/bond-store'\nimport TextBuffer, { TextBufferData, TextBufferParameters } from '../buffer/text-buffer'\nimport WideLineBuffer from '../buffer/wideline-buffer'\nimport CylinderBuffer, { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport { getFixedLengthDashData } from '../geometry/dash'\nimport Viewer from '../viewer/viewer';\nimport { Structure } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport { BondDataFields, BondDataParams, BondData } from '../structure/structure-data';\nimport { StructureRepresentationData } from './structure-representation';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\n\n/**\n * Distance representation parameter object.\n * @typedef {Object} DistanceRepresentationParameters - distance representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n * @mixes MeasurementRepresentationParameters\n *\n * @property {String} labelUnit - distance unit (e.g. \"angstrom\" or \"nm\"). If set, a distance\n * symbol is appended to the label (i.e. 'nm' or '\\u00C5'). In case of 'nm', the\n * distance value is computed in nanometers instead of Angstroms.\n * @property {Array[]} atomPair - list of pairs of selection strings (see {@link Selection})\n * or pairs of atom indices. Using atom indices is much more\n * efficient when the representation is updated often, e.g. by\n * changing the selection or the atom positions, as there\n * are no selection strings to be evaluated.\n */\nexport interface DistanceRepresentationParameters extends MeasurementRepresentationParameters {\n labelUnit: string\n atomPair: AtomPair\n useCylinder: boolean\n}\nexport type AtomPair = (number|string)[][]\n/**\n * Distance representation\n */\nclass DistanceRepresentation extends MeasurementRepresentation {\n protected labelUnit: string\n protected atomPair: AtomPair\n protected useCylinder: boolean\n protected distanceBuffer: WideLineBuffer|CylinderGeometryBuffer\n /**\n * Create Distance representation object\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\" );\n * // either give selections (uses first selected atom) ...\n * var atomPair = [ [ \"1.CA\", \"4.CA\" ], [ \"7.CA\", \"13.CA\" ] ];\n * // or atom indices\n * var atomPair = [ [ 8, 28 ], [ 173, 121 ] ];\n * o.addRepresentation( \"distance\", { atomPair: atomPair } );\n * stage.autoView();\n * } );\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {DistanceRepresentationParameters} params - distance representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'distance'\n\n this.parameters = Object.assign({\n radialSegments: true,\n openEnded: true,\n disableImpostor: true,\n labelUnit: {\n type: 'select',\n rebuild: true,\n options: { '': '', angstrom: 'angstrom', nm: 'nm' }\n },\n useCylinder: {\n type: 'boolean', rebuild: true\n },\n atomPair: {\n type: 'hidden', rebuild: true\n }\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.linewidth = defaults(p.linewidth, 5.0)\n p.radiusType = defaults(p.radiusType, 'size')\n p.radiusSize = defaults(p.radiusSize, 0.2)\n\n this.labelUnit = defaults(p.labelUnit, '')\n this.useCylinder = defaults(p.useCylinder, false)\n this.atomPair = defaults(p.atomPair, [])\n\n super.init(p)\n }\n\n getDistanceData (sview: StructureView, atomPair: AtomPair) {\n let n = atomPair.length\n const text = new Array(n)\n let position = new Float32Array(n * 3)\n const sele1 = new Selection()\n const sele2 = new Selection()\n\n const bondStore = new BondStore()\n\n const ap1 = sview.getAtomProxy()\n const ap2 = sview.getAtomProxy()\n\n let j = 0 // Skipped pairs\n const selected = sview.getAtomSet()\n\n atomPair.forEach((pair, i) => {\n let v1 = pair[ 0 ]\n let v2 = pair[ 1 ]\n\n if (typeof(v1) === 'number' && Number.isInteger(v1) && typeof(v2) === 'number' && Number.isInteger(v2)) {\n if (selected.get(v1) && selected.get(v2)) {\n ap1.index = v1\n ap2.index = v2\n } else {\n j += 1\n return\n }\n } else {\n sele1.setString(v1 as string)\n sele2.setString(v2 as string)\n\n var atomIndices1 = sview.getAtomIndices(sele1)\n var atomIndices2 = sview.getAtomIndices(sele2)\n\n if (atomIndices1!.length && atomIndices2!.length) {\n ap1.index = atomIndices1![ 0 ]\n ap2.index = atomIndices2![ 0 ]\n } else {\n j += 1\n return\n }\n }\n\n bondStore.addBond(ap1, ap2, 1)\n\n i -= j\n var d = ap1.distanceTo(ap2)\n switch (this.labelUnit) {\n case 'angstrom':\n text[ i ] = d.toFixed(2) + ' ' + String.fromCharCode(0x212B)\n break\n case 'nm':\n text[ i ] = (d / 10).toFixed(2) + ' nm'\n break\n default:\n text[ i ] = d.toFixed(2)\n break\n }\n\n var i3 = i * 3\n position[ i3 + 0 ] = (ap1.x + ap2.x) / 2\n position[ i3 + 1 ] = (ap1.y + ap2.y) / 2\n position[ i3 + 2 ] = (ap1.z + ap2.z) / 2\n })\n\n if (j > 0) {\n n -= j\n position = position.subarray(0, n * 3)\n }\n\n var bondSet = new BitArray(bondStore.count, true)\n\n return {\n text: text,\n position: position,\n bondSet: bondSet,\n bondStore: bondStore\n }\n }\n\n getBondData (sview: StructureView, what: BondDataFields, params: BondDataParams): BondData {\n const bondData = sview.getBondData(this.getBondParams(what, params))\n if (bondData.picking) {\n bondData.picking = new DistancePicker(\n bondData.picking.array,\n bondData.picking.structure,\n params.bondStore!\n ) as any\n }\n return bondData\n }\n\n createData (sview: StructureView) {\n if (!sview.atomCount || !this.atomPair.length) return\n\n const n = this.atomPair.length\n const c = new Color(this.labelColor)\n const distanceData = this.getDistanceData(sview, this.atomPair)\n\n this.textBuffer = new TextBuffer({\n position: distanceData.position,\n size: uniformArray(n, this.labelSize),\n color: uniformArray3(n, c.r, c.g, c.b),\n text: distanceData.text\n } as TextBufferData, this.getLabelBufferParams() as TextBufferParameters)\n\n const bondParams = {\n bondSet: distanceData.bondSet,\n bondStore: distanceData.bondStore\n }\n\n const bondData = this.getBondData(\n sview,\n { position: true, color: true, picking: true, radius: this.useCylinder },\n bondParams\n )\n\n if (this.useCylinder) {\n this.distanceBuffer = new CylinderBuffer(\n bondData as CylinderBufferData,\n this.getBufferParams({\n openEnded: this.openEnded,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) \n ) as CylinderGeometryBuffer\n } else {\n this.distanceBuffer = new WideLineBuffer(\n getFixedLengthDashData(bondData as CylinderBufferData),\n this.getBufferParams({\n linewidth: this.linewidth,\n visible: this.lineVisible,\n opacity: this.lineOpacity\n })\n )\n }\n\n return {\n bondSet: distanceData.bondSet,\n bondStore: distanceData.bondStore,\n position: distanceData.position,\n bufferList: [ this.textBuffer, this.distanceBuffer ]\n }\n }\n\n updateData (what: BondDataFields, data: StructureRepresentationData) {\n super.updateData(what, data)\n\n const bondParams = {\n bondSet: data.bondSet,\n bondStore: data.bondStore\n }\n\n const bondData = this.getBondData(data.sview as StructureView, what, bondParams)\n const distanceData = {}\n\n if (!what || what.color) {\n Object.assign( distanceData, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n if (!what || what.radius) {\n Object.assign( distanceData, {radius: bondData.radius})\n }\n\n (this.distanceBuffer as CylinderGeometryBuffer).setAttributes(distanceData)\n }\n\n setParameters (params: Partial) {\n let rebuild = false\n const what = {}\n\n super.setParameters(params, what, rebuild)\n\n if (!this.useCylinder) {\n if (params && params.lineOpacity) {\n (this.distanceBuffer as WideLineBuffer).setParameters({ opacity: params.lineOpacity })\n }\n if (params && params.opacity !== undefined) {\n (this.distanceBuffer as WideLineBuffer).setParameters({ opacity: this.lineOpacity })\n }\n if (params && params.linewidth) {\n (this.distanceBuffer as WideLineBuffer).setParameters({ linewidth: params.linewidth })\n }\n }\n\n return this\n }\n}\n\nRepresentationRegistry.add('distance', DistanceRepresentation)\n\nexport default DistanceRepresentation\n","/**\n * @file Vector Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { Color, Matrix4, Vector3 } from 'three'\n\nimport '../shader/Line.vert'\nimport '../shader/Line.frag'\n\nimport { uniformArray3 } from '../math/array-utils'\nimport Buffer, { BufferDefaultParameters, BufferData, BufferParameters } from './buffer'\nimport { GenericColor } from '../types'\n\nfunction getSize(data: BufferData){\n const n = data.position!.length / 3\n return n * 2 * 3\n}\n\nexport interface VectorBufferData extends BufferData {\n vector: Float32Array\n}\n\nexport const VectorBufferDefaultParameters = Object.assign({\n scale: 1,\n color: 'grey'\n}, BufferDefaultParameters)\nexport type VectorBufferParameters = BufferParameters & { scale: number, color: GenericColor }\n\n/**\n * Vector buffer. Draws vectors as lines.\n */\nclass VectorBuffer extends Buffer {\n get defaultParameters() { return VectorBufferDefaultParameters }\n parameters: VectorBufferParameters\n\n isLine = true\n vertexShader = 'Line.vert'\n fragmentShader = 'Line.frag'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.vector - vectors\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: VectorBufferData, params: Partial = {}) {\n super({\n position: new Float32Array(getSize(data)),\n color: new Float32Array(getSize(data))\n }, params)\n\n const color = new Color(this.parameters.color)\n const attributes = this.geometry.attributes as any // TODO\n uniformArray3(getSize(data) / 3, color.r, color.g, color.b, attributes.color.array)\n\n this.setAttributes(data)\n }\n\n setAttributes (data: Partial = {}) {\n const attributes = this.geometry.attributes as any // TODO\n\n let position, vector\n let aPosition\n\n if (data.position && data.vector) {\n position = data.position\n vector = data.vector\n aPosition = attributes.position.array\n attributes.position.needsUpdate = true\n }\n\n const n = this.size / 2\n const scale = this.parameters.scale\n\n if (position && vector) {\n for (let v = 0; v < n; v++) {\n const i = v * 2 * 3\n const j = v * 3\n\n aPosition[ i + 0 ] = position[ j + 0 ]\n aPosition[ i + 1 ] = position[ j + 1 ]\n aPosition[ i + 2 ] = position[ j + 2 ]\n aPosition[ i + 3 ] = position[ j + 0 ] + vector[ j + 0 ] * scale\n aPosition[ i + 4 ] = position[ j + 1 ] + vector[ j + 1 ] * scale\n aPosition[ i + 5 ] = position[ j + 2 ] + vector[ j + 2 ] * scale\n }\n }\n }\n}\n\nexport default VectorBuffer\n","/**\n * @file Helixorient Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Helixorient from '../geometry/helixorient'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferParameters } from '../buffer/sphere-buffer'\nimport VectorBuffer from '../buffer/vector-buffer'\nimport Viewer from '../viewer/viewer';\nimport { Structure } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport Polymer from '../proxy/polymer';\nimport { AtomDataFields } from '../structure/structure-data';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\nimport SphereImpostorBuffer from '../buffer/sphereimpostor-buffer';\nimport { BufferData } from '../buffer/buffer';\n\n/**\n * Helixorient Representation\n */\nclass HelixorientRepresentation extends StructureRepresentation {\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'helixorient'\n\n this.parameters = Object.assign({\n sphereDetail: true,\n disableImpostor: true\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'sstruc')\n p.radiusType = defaults(p.radiusType, 'size')\n p.radiusSize = defaults(p.radiusSize, 0.15)\n p.radiusScale = defaults(p.radiusScale, 1.0)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n const bufferList: (SphereBuffer|VectorBuffer)[] = []\n const polymerList: Polymer[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4) return\n polymerList.push(polymer)\n\n const helixorient = new Helixorient(polymer)\n const position = helixorient.getPosition()\n const color = helixorient.getColor(this.getColorParams())\n const size = helixorient.getSize(this.getRadiusParams())\n const picking = helixorient.getPicking()\n\n bufferList.push(\n new SphereBuffer(\n {\n position: position.center,\n color: color.color,\n radius: size.size,\n picking: picking.picking\n },\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters\n ),\n new VectorBuffer(\n {\n position: position.center,\n vector: position.axis\n },\n this.getBufferParams({\n color: 'skyblue',\n scale: 1\n })\n ),\n new VectorBuffer(\n {\n position: position.center,\n vector: position.resdir\n },\n this.getBufferParams({\n color: 'lightgreen',\n scale: 1\n })\n )\n )\n }, sview.getSelection())\n\n return {\n bufferList: bufferList as (SphereGeometryBuffer|SphereImpostorBuffer|VectorBuffer)[],\n polymerList: polymerList\n }\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n if (Debug) Log.time(this.type + ' repr update')\n\n what = what || {}\n\n for (let i = 0, il = data.polymerList!.length; i < il; ++i) {\n const j = i * 3\n\n const bufferData: Partial = {}\n const polymer = data.polymerList![ i ]\n const helixorient = new Helixorient(polymer)\n\n if (what.position) {\n const position = helixorient.getPosition()\n\n Object.assign(bufferData, {position: position.center})\n\n data.bufferList[ j + 1 ].setAttributes({\n 'position': position.center,\n 'vector': position.axis\n })\n data.bufferList[ j + 2 ].setAttributes({\n 'position': position.center,\n 'vector': position.resdir\n })\n }\n\n data.bufferList[ j ].setAttributes(bufferData)\n }\n\n if (Debug) Log.timeEnd(this.type + ' repr update')\n }\n}\n\nRepresentationRegistry.add('helixorient', HelixorientRepresentation)\n\nexport default HelixorientRepresentation\n","/**\n * @file Licorice Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport BallAndStickRepresentation, { BallAndStickRepresentationParameters } from './ballandstick-representation'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\n\n/**\n * Licorice representation object ({@link BallAndStickRepresentation} with `aspectRatio` fixed at 1.0)\n */\nclass LicoriceRepresentation extends BallAndStickRepresentation {\n /**\n * Create Licorice representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {BallAndStickRepresentationParameters} params - ball and stick representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'licorice'\n\n this.parameters = Object.assign(\n {}, this.parameters, { aspectRatio: null }\n )\n }\n\n init (params: Partial) {\n var p = params || {}\n p.aspectRatio = 1.0\n\n super.init(p)\n }\n}\n\nRepresentationRegistry.add('licorice', LicoriceRepresentation)\n\nexport default LicoriceRepresentation\n","/**\n * @file Mapped Box Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { BufferParameters, BufferData } from './buffer'\nimport MappedBuffer from './mapped-buffer'\n\nconst mapping = new Float32Array([\n -1.0, -1.0, -1.0,\n 1.0, -1.0, -1.0,\n 1.0, -1.0, 1.0,\n -1.0, -1.0, 1.0,\n -1.0, 1.0, -1.0,\n 1.0, 1.0, -1.0,\n 1.0, 1.0, 1.0,\n -1.0, 1.0, 1.0\n])\n\nconst mappingIndices = new Uint16Array([\n 0, 1, 2,\n 0, 2, 3,\n 1, 5, 6,\n 1, 6, 2,\n 4, 6, 5,\n 4, 7, 6,\n 0, 7, 4,\n 0, 3, 7,\n 0, 5, 1,\n 0, 4, 5,\n 3, 2, 6,\n 3, 6, 7\n])\n\n/**\n * Mapped Box buffer. Draws boxes. Used to render general imposters.\n * @interface\n */\nclass MappedBoxBuffer extends MappedBuffer {\n constructor(data: BufferData, params: Partial = {}) {\n super('v3', data, params)\n }\n get mapping () { return mapping }\n get mappingIndices () { return mappingIndices }\n get mappingIndicesSize () { return 36 }\n get mappingSize () { return 8 }\n get mappingItemSize () { return 3 }\n}\n\nexport default MappedBoxBuffer\n","/**\n * @file Hyperball Stick Impostor Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3 required for declaration only\nimport { Matrix4, Vector3 } from 'three'\n\nimport '../shader/HyperballStickImpostor.vert'\nimport '../shader/HyperballStickImpostor.frag'\n\nimport MappedBoxBuffer from './mappedbox-buffer'\nimport { BufferDefaultParameters, BufferParameterTypes, BufferData, BufferParameters } from './buffer'\n\nexport interface HyperballStickImpostorBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n color2: Float32Array\n radius: Float32Array\n radius2: Float32Array\n}\n\nexport const HyperballStickImpostorBufferDefaultParameters = Object.assign({\n shrink: 0.14\n}, BufferDefaultParameters)\nexport type HyperballStickImpostorBufferParameters = BufferParameters & { shrink: number }\n\nconst HyperballStickImpostorBufferParameterTypes = Object.assign({\n shrink: { uniform: true }\n}, BufferParameterTypes)\n\n/**\n * Hyperball stick impostor buffer.\n *\n * @example\n * var hyperballStickImpostorBuffer = new HyperballStickImpostorBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 2, 2, 2 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ]),\n * radius2: new Float32Array([ 2 ])\n * });\n */\nclass HyperballStickImpostorBuffer extends MappedBoxBuffer {\n parameterTypes = HyperballStickImpostorBufferParameterTypes\n get defaultParameters() { return HyperballStickImpostorBufferDefaultParameters }\n parameters: HyperballStickImpostorBufferParameters\n\n isImpostor = true\n vertexShader = 'HyperballStickImpostor.vert'\n fragmentShader = 'HyperballStickImpostor.frag'\n\n constructor (data: HyperballStickImpostorBufferData, params: Partial = {}) {\n super(data, params)\n\n this.addUniforms({\n 'modelViewProjectionMatrix': { value: new Matrix4() },\n 'modelViewProjectionMatrixInverse': { value: new Matrix4() },\n 'modelViewMatrixInverseTranspose': { value: new Matrix4() },\n 'shrink': { value: this.parameters.shrink }\n })\n\n this.addAttributes({\n 'position1': { type: 'v3', value: null },\n 'position2': { type: 'v3', value: null },\n 'color2': { type: 'c', value: null },\n 'radius': { type: 'f', value: null },\n 'radius2': { type: 'f', value: null }\n })\n\n this.setAttributes(data)\n this.makeMapping()\n }\n}\n\nexport default HyperballStickImpostorBuffer\n","/**\n * @file Hyperball Stick Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import required for declaration only\nimport { Vector3, Matrix4 } from 'three'\nimport { ExtensionFragDepth } from '../globals'\nimport { calculateMinArray } from '../math/array-utils'\nimport CylinderGeometryBuffer, { CylinderGeometryBufferDefaultParameters, CylinderGeometryBufferParameters } from './cylindergeometry-buffer'\nimport HyperballStickImpostorBuffer, { HyperballStickImpostorBufferDefaultParameters, HyperballStickImpostorBufferParameters } from './hyperballstickimpostor-buffer'\nimport { BufferData } from './buffer'\n\nexport interface HyperballStickBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n color2: Float32Array\n radius: Float32Array\n radius2: Float32Array\n}\n\nexport const HyperballStickBufferDefaultParameters = Object.assign({\n disableImpostor: false\n}, CylinderGeometryBufferDefaultParameters, HyperballStickImpostorBufferDefaultParameters)\nexport type HyperballStickBufferParameters = HyperballStickImpostorBufferParameters & CylinderGeometryBufferParameters & { disableImpostor: boolean }\n\nclass HyperballStickBufferImpl {\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - from colors\n * @param {Float32Array} data.color2 - to colors\n * @param {Float32Array} data.radius - from radii\n * @param {Float32Array} data.radius2 - to radii\n * @param {Float32Array} data.picking - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: HyperballStickBufferData, params: Partial = {}) {\n if (!ExtensionFragDepth || (params && params.disableImpostor)) {\n data.radius = calculateMinArray(data.radius, data.radius2)\n return new CylinderGeometryBuffer(data, params)\n } else {\n return new HyperballStickImpostorBuffer(data, params)\n }\n }\n}\n\n/**\n * Hyperball stick buffer. Depending on the value {@link ExtensionFragDepth} and\n * `params.disableImpostor` the constructor returns either a\n * {@link CylinderGeometryBuffer} or a {@link HyperballStickImpostorBuffer}\n * @implements {Buffer}\n *\n * @example\n * var hyperballStickBuffer = new HyperballStickBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 2, 2, 2 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ]),\n * radius2: new Float32Array([ 2 ])\n * });\n */\n//@ts-expect-error Incompatible constructor signatures\nconst HyperballStickBuffer: {\n new(data: HyperballStickBufferData, params: Partial): CylinderGeometryBuffer | HyperballStickImpostorBuffer;\n} = HyperballStickBufferImpl;\n\ntype HyperballStickBuffer = CylinderGeometryBuffer | HyperballStickImpostorBuffer;\n\nexport default HyperballStickBuffer\n","/**\n * @file Hyperball Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { calculateCenterArray } from '../math/array-utils'\nimport LicoriceRepresentation from './licorice-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport HyperballStickBuffer, { HyperballStickBufferData } from '../buffer/hyperballstick-buffer'\nimport { BallAndStickRepresentationParameters } from './ballandstick-representation';\n// @ts-ignore: unused import Volume required for declaration only\nimport { Structure, Volume } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport { BondDataParams, BondDataFields, AtomDataFields } from '../structure/structure-data';\nimport StructureView from '../structure/structure-view';\nimport { StructureRepresentationData } from './structure-representation';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\n// @ts-ignore: unused import Surface required for declaration only\nimport Surface from '../surface/surface';\n\nexport interface HyperballRepresentationParameters extends BallAndStickRepresentationParameters {\n shrink: number\n}\n\n/**\n * Hyperball Representation\n */\nclass HyperballRepresentation extends LicoriceRepresentation {\n protected shrink: number\n protected __center: Float32Array\n \n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'hyperball'\n\n this.parameters = Object.assign({\n\n shrink: {\n type: 'number', precision: 3, max: 1.0, min: 0.001, buffer: true\n }\n\n }, this.parameters, {\n\n multipleBond: null,\n bondSpacing: null\n\n })\n }\n\n init (params: Partial) {\n var p = params || {}\n p.radiusScale = defaults(p.radiusScale, 0.2)\n p.radiusType = defaults(p.radiusType, 'vdw')\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.shrink = defaults(p.shrink, 0.12)\n\n super.init(p)\n }\n\n getBondParams (what?: BondDataFields, params?: BondDataParams) {\n if (!what || what.radius) {\n params = Object.assign({ radius2: true }, params)\n }\n\n return super.getBondParams(what, params)\n }\n\n createData (sview: StructureView) {\n var sphereBuffer = new SphereBuffer(\n (sview.getAtomData(this.getAtomParams()) as SphereBufferData),\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters\n ) as SphereGeometryBuffer\n\n this.__center = new Float32Array(sview.bondCount * 3)\n\n var stickBuffer = new HyperballStickBuffer(\n sview.getBondData(this.getBondParams()) as HyperballStickBufferData,\n this.getBufferParams({\n shrink: this.shrink,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n return {\n bufferList: [ sphereBuffer, stickBuffer ]\n }\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n var atomData = data.sview!.getAtomData(this.getAtomParams())\n var bondData = data.sview!.getBondData(this.getBondParams())\n var sphereData = {}\n var stickData = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {position: atomData.position})\n var from = bondData.position1\n var to = bondData.position2\n Object.assign(stickData, {\n position: calculateCenterArray(from!, to!, this.__center),\n position1: from,\n position2: to\n })\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {color: atomData.color})\n Object.assign(stickData, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {radius: atomData.radius})\n Object.assign(stickData, {\n radius: bondData.radius,\n radius2: bondData.radius2\n })\n }\n\n data.bufferList[ 0 ].setAttributes(sphereData)\n data.bufferList[ 1 ].setAttributes(stickData)\n }\n}\n\nRepresentationRegistry.add('hyperball', HyperballRepresentation)\n\nexport default HyperballRepresentation\n","/**\n * @file Label Factory\n * @author Alexander Rose \n * @private\n */\n\nimport { AA1 } from '../structure/structure-constants'\nimport AtomProxy from '../proxy/atom-proxy'\nimport { sprintf } from 'sprintf-js'\n\nexport const LabelFactoryTypes = {\n '': '',\n 'atomname': 'atom name',\n 'atomindex': 'atom index',\n 'occupancy': 'occupancy',\n 'bfactor': 'b-factor',\n 'serial': 'serial',\n 'element': 'element',\n 'atom': 'atom name + index',\n 'resname': 'residue name',\n 'resno': 'residue no',\n 'res': 'one letter code + no',\n 'residue': '[residue name] + no + inscode',\n 'text': 'text',\n 'format': 'format',\n 'qualified': 'qualified name'\n}\nexport type LabelType = keyof typeof LabelFactoryTypes\n\nclass LabelFactory {\n\n static types = LabelFactoryTypes\n errorLogged: boolean = false\n\n constructor(readonly type: LabelType, readonly text: { [k: number]: string } = {},\n readonly format: string = '') {}\n\n atomLabel (a: AtomProxy) {\n const type = this.type\n\n let l\n\n switch (type) {\n case 'atomname':\n l = a.atomname\n break\n\n case 'atomindex':\n l = `${a.index}`\n break\n\n case 'occupancy':\n l = a.occupancy.toFixed(2)\n break\n\n case 'bfactor':\n l = a.bfactor.toFixed(2)\n break\n\n case 'serial':\n l = `${a.serial}`\n break\n\n case 'element':\n l = a.element\n break\n\n case 'atom':\n l = `${a.atomname}|${a.index}`\n break\n\n case 'resname':\n l = a.resname\n break\n\n case 'resno':\n l = `${a.resno}`\n break\n\n case 'res':\n l = `${(AA1[ a.resname.toUpperCase() ] || a.resname)}${a.resno}`\n break\n\n case 'residue':\n const aa1 = AA1[ a.resname.toUpperCase() ]\n if (aa1 && !a.inscode) {\n l = `${aa1}${a.resno}`\n } else {\n l = `[${a.resname}]${a.resno}${a.inscode}`\n }\n break\n\n case 'text':\n l = this.text[ a.index ]\n break\n\n case 'format':\n try {\n l = sprintf(this.format, a)\n } catch (e) {\n if (!this.errorLogged) {\n this.errorLogged = true\n console.log(e.message)\n }\n }\n break\n\n // case \"qualified\":\n default:\n l = a.qualifiedName()\n break\n }\n\n return l === undefined ? '' : l\n }\n}\n\nexport default LabelFactory\n","/**\n * @file Label Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry, ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport LabelFactory, { LabelType } from '../utils/label-factory'\nimport RadiusFactory from '../utils/radius-factory'\nimport StructureRepresentation, { StructureRepresentationData } from './structure-representation'\nimport TextBuffer, { TextBufferData } from '../buffer/text-buffer'\nimport { RepresentationParameters } from './representation';\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { GenericColor } from '../types'\n\nexport interface TextDataField {\n position?: boolean\n color?: boolean\n radius?: boolean\n text?: boolean\n}\n\n/**\n * Label representation parameter object. Extends {@link RepresentationParameters} and\n * {@link StructureRepresentationParameters}.\n *\n * @typedef {Object} LabelRepresentationParameters - label representation parameters\n *\n * @property {Integer} clipNear - position of camera near/front clipping plane\n * in percent of scene bounding box\n * @property {Float} opacity - translucency: 1 is fully opaque, 0 is fully transparent\n * @property {String} labelType - type of the label, one of:\n * \"atomname\", \"atomindex\", \"occupancy\", \"bfactor\",\n * \"serial\", \"element\", \"atom\", \"resname\", \"resno\",\n * \"res\", \"text\", \"qualified\". When set to \"text\", the\n * `labelText` list is used.\n * @property {String[]} labelText - list of label strings, must set `labelType` to \"text\"\n * to take effect\n * @property {String} labelFormat - sprintf-js format string, any attribute of\n * {@link AtomProxy} can be used\n * @property {String} labelGrouping - grouping of the label, one of:\n * \"atom\", \"residue\".\n * @property {String} fontFamily - font family, one of: \"sans-serif\", \"monospace\", \"serif\"\n * @property {String} fontStyle - font style, \"normal\" or \"italic\"\n * @property {String} fontWeight - font weight, \"normal\" or \"bold\"\n * @property {Float} xOffset - offset in x-direction\n * @property {Float} yOffset - offset in y-direction\n * @property {Float} zOffset - offset in z-direction (i.e. in camera direction)\n * @property {String} attachment - attachment of the label, one of:\n * \"bottom-left\", \"bottom-center\", \"bottom-right\",\n * \"middle-left\", \"middle-center\", \"middle-right\",\n * \"top-left\", \"top-center\", \"top-right\"\n * @property {Boolean} showBorder - show border/outline\n * @property {Color} borderColor - color of the border/outline\n * @property {Float} borderWidth - width of the border/outline\n * @property {Boolean} showBackground - show background rectangle\n * @property {Color} backgroundColor - color of the background\n * @property {Float} backgroundMargin - width of the background\n * @property {Float} backgroundOpacity - opacity of the background\n * @property {Boolean} fixedSize - show text with a fixed pixel size\n */\nexport interface LabelRepresentationParameters extends RepresentationParameters {\n labelType: LabelType\n labelText: string[]\n labelFormat: string\n labelGrouping: 'atom'|'residue'\n fontFamily: 'sans-serif'|'monospace'|'serif'\n fontStyle: 'normal'|'italic'\n fontWeight: 'normal'|'bold'\n xOffset: number\n yOffset: number\n zOffset: number\n attachment: 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n showBorder: boolean\n borderColor: GenericColor\n borderWidth: number\n showBackground: boolean\n backgroundColor: GenericColor\n backgroundMargin: number\n backgroundOpacity: number\n fixedSize: boolean\n}\n/**\n * Label representation\n */\nclass LabelRepresentation extends StructureRepresentation {\n\n protected labelType: LabelType\n protected labelText: string[]\n protected labelFormat: string\n protected labelGrouping: 'atom'|'residue'\n protected fontFamily: 'sans-serif'|'monospace'|'serif'\n protected fontStyle: 'normal'|'italic'\n protected fontWeight: 'normal'|'bold'\n protected xOffset: number\n protected yOffset: number\n protected zOffset: number\n protected attachment: 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n protected showBorder: boolean\n protected borderColor: GenericColor\n protected borderWidth: number\n protected showBackground: boolean\n protected backgroundColor: GenericColor\n protected backgroundMargin: number\n protected backgroundOpacity: number\n protected fixedSize: boolean\n\n /**\n * Create Label representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {LabelRepresentationParameters} params - label representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'label'\n\n this.parameters = Object.assign({\n\n labelType: {\n type: 'select', options: LabelFactory.types, rebuild: true\n },\n labelText: {\n type: 'hidden', rebuild: true\n },\n labelFormat: {\n type: 'text', rebuild: true\n },\n labelGrouping: {\n type: 'select',\n options: {\n 'atom': 'atom',\n 'residue': 'residue'\n },\n rebuild: true\n },\n fontFamily: {\n type: 'select',\n options: {\n 'sans-serif': 'sans-serif',\n 'monospace': 'monospace',\n 'serif': 'serif'\n },\n buffer: true\n },\n fontStyle: {\n type: 'select',\n options: {\n 'normal': 'normal',\n 'italic': 'italic'\n },\n buffer: true\n },\n fontWeight: {\n type: 'select',\n options: {\n 'normal': 'normal',\n 'bold': 'bold'\n },\n buffer: true\n },\n xOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: true\n },\n yOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: true\n },\n zOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: true\n },\n attachment: {\n type: 'select',\n options: {\n 'bottom-left': 'bottom-left',\n 'bottom-center': 'bottom-center',\n 'bottom-right': 'bottom-right',\n 'middle-left': 'middle-left',\n 'middle-center': 'middle-center',\n 'middle-right': 'middle-right',\n 'top-left': 'top-left',\n 'top-center': 'top-center',\n 'top-right': 'top-right'\n },\n rebuild: true\n },\n showBorder: {\n type: 'boolean', buffer: true\n },\n borderColor: {\n type: 'color', buffer: true\n },\n borderWidth: {\n type: 'number', precision: 2, max: 0.3, min: 0, buffer: true\n },\n showBackground: {\n type: 'boolean', rebuild: true\n },\n backgroundColor: {\n type: 'color', buffer: true\n },\n backgroundMargin: {\n type: 'number', precision: 2, max: 2, min: 0, rebuild: true\n },\n backgroundOpacity: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n fixedSize: {\n type: 'boolean', buffer: true\n }\n\n }, this.parameters, {\n\n side: null,\n flatShaded: null,\n wireframe: null,\n linewidth: null,\n\n roughness: null,\n metalness: null,\n diffuse: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n\n this.labelType = defaults(p.labelType, 'res')\n this.labelText = defaults(p.labelText, {})\n this.labelFormat = defaults(p.labelFormat, '')\n this.labelGrouping = defaults(p.labelGrouping, 'atom')\n this.fontFamily = defaults(p.fontFamily, 'sans-serif')\n this.fontStyle = defaults(p.fontStyle, 'normal')\n this.fontWeight = defaults(p.fontWeight, 'bold')\n this.xOffset = defaults(p.xOffset, 0.0)\n this.yOffset = defaults(p.yOffset, 0.0)\n this.zOffset = defaults(p.zOffset, 0.5)\n this.attachment = defaults(p.attachment, 'bottom-left')\n this.showBorder = defaults(p.showBorder, false)\n this.borderColor = defaults(p.borderColor, 'lightgrey')\n this.borderWidth = defaults(p.borderWidth, 0.15)\n this.showBackground = defaults(p.showBackground, false)\n this.backgroundColor = defaults(p.backgroundColor, 'lightgrey')\n this.backgroundMargin = defaults(p.backgroundMargin, 0.5)\n this.backgroundOpacity = defaults(p.backgroundOpacity, 1.0)\n this.fixedSize = defaults(p.fixedSize, false)\n\n super.init(p)\n }\n\n getTextData (sview: StructureView, what?: TextDataField) {\n const p = this.getAtomParams(what)\n const labelFactory = new LabelFactory(this.labelType, this.labelText, this.labelFormat)\n let position: Float32Array, size: Float32Array, color: Float32Array, text: string[],\n positionN: number[], sizeN: number[], colorN: number[]\n if (this.labelGrouping === 'atom') {\n const atomData = sview.getAtomData(p)\n position = atomData.position as Float32Array\n size = atomData.radius as Float32Array\n color = atomData.color as Float32Array\n if (!what || what.text) {\n text = []\n sview.eachAtom(ap => text.push(labelFactory.atomLabel(ap)))\n }\n } else if (this.labelGrouping === 'residue') {\n if (!what || what.position) positionN = []\n if (!what || what.color) colorN = []\n if (!what || what.radius) sizeN = []\n if (!what || what.text) text = []\n if (p.colorParams) p.colorParams.structure = sview.getStructure()\n const colormaker = ColormakerRegistry.getScheme(p.colorParams)\n const radiusFactory = new RadiusFactory(p.radiusParams)\n const ap1 = sview.getAtomProxy()\n\n let i = 0\n sview.eachResidue(rp => {\n const i3 = i * 3\n if (rp.isProtein() || rp.isNucleic()) {\n ap1.index = rp.traceAtomIndex\n if (!what || what.position) {\n ap1.positionToArray(positionN, i3)\n }\n } else {\n ap1.index = rp.atomOffset\n if (!what || what.position) {\n rp.positionToArray(positionN, i3)\n }\n }\n if (!what || what.color) {\n colormaker.atomColorToArray(ap1, colorN, i3)\n }\n if (!what || what.radius) {\n sizeN[ i ] = radiusFactory.atomRadius(ap1)\n }\n if (!what || what.text) {\n text.push(labelFactory.atomLabel(ap1))\n }\n ++i\n })\n\n if (!what || what.position) position = new Float32Array(positionN!)\n if (!what || what.color) color = new Float32Array(colorN!)\n if (!what || what.radius) size = new Float32Array(sizeN!)\n }\n\n return { position: position!, size: size!, color: color!, text: text! }\n }\n\n createData (sview: StructureView) {\n const what: TextDataField = { position: true, color: true, radius: true, text: true }\n\n const textBuffer = new TextBuffer(\n this.getTextData(sview, what) as TextBufferData,\n this.getBufferParams({\n fontFamily: this.fontFamily,\n fontStyle: this.fontStyle,\n fontWeight: this.fontWeight,\n xOffset: this.xOffset,\n yOffset: this.yOffset,\n zOffset: this.zOffset,\n attachment: this.attachment,\n showBorder: this.showBorder,\n borderColor: this.borderColor,\n borderWidth: this.borderWidth,\n showBackground: this.showBackground,\n backgroundColor: this.backgroundColor,\n backgroundMargin: this.backgroundMargin,\n backgroundOpacity: this.backgroundOpacity,\n fixedSize: this.fixedSize\n })\n )\n\n return { bufferList: [ textBuffer ] }\n }\n\n updateData (what: TextDataField, data: StructureRepresentationData) {\n data.bufferList[ 0 ].setAttributes(this.getTextData(data.sview as StructureView, what))\n }\n\n getAtomRadius () {\n return 0\n }\n}\n\nRepresentationRegistry.add('label', LabelRepresentation)\n\nexport default LabelRepresentation\n","/**\n * @file Line Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { RepresentationRegistry } from '../globals'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport WideLineBuffer from '../buffer/wideline-buffer'\nimport { AtomPicker } from '../utils/picker'\n// @ts-ignore: unused import Volume required for declaration only\nimport { Structure, Volume } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport Viewer from '../viewer/viewer';\nimport AtomProxy from '../proxy/atom-proxy';\n// @ts-ignore: unused import Surface required for declaration only\nimport Surface from '../surface/surface';\n// @ts-ignore: unused import BondDataFields, BondDataParams required for declaration only\nimport { BondDataFields, BondDataParams } from '../structure/structure-data';\n\n/**\n * Determine which atoms in a Structure[View] form no bonds to any other atoms\n * in that Structure.\n *\n * This differs from setting the selection to \"nonbonded\" as it finds atoms\n * that have no bonds within the current selection.\n * @param {Structure} structure - The Structure or StructureView object\n * @return {AtomSet} AtomSet of lone atoms\n */\nfunction getLoneAtomSet (structure: Structure | StructureView) {\n const atomSet = structure.getAtomSet()\n const bondSet = structure.getBondSet()\n const bp = structure.getBondProxy()\n bondSet.forEach(function (idx) {\n bp.index = idx\n atomSet.clear(bp.atomIndex1)\n atomSet.clear(bp.atomIndex2)\n })\n return atomSet\n}\n\nexport interface LineRepresentationParameters extends StructureRepresentationParameters {\n multipleBond: 'off' | 'symmetric' | 'offset'\n bondSpacing: number\n linewidth: number\n lines: boolean\n crosses: 'off' | 'all' | 'lone'\n crossSize: number\n}\n\nexport interface CrossData {\n position1?: Float32Array\n position2?: Float32Array\n color?: Float32Array\n color2?: Float32Array\n picking?: AtomPicker\n}\n\n/**\n * Line representation\n */\nclass LineRepresentation extends StructureRepresentation {\n protected multipleBond: 'off' | 'symmetric' | 'offset'\n protected bondSpacing: number\n protected linewidth: number\n protected lines: boolean\n protected crosses: 'off' | 'all' | 'lone'\n protected crossSize: number\n /**\n * Create Line representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {RepresentationParameters} params - representation parameters, plus the properties listed below\n * @property {String} multipleBond - one off \"off\", \"symmetric\", \"offset\"\n * @param {Float} params.bondSpacing - spacing for multiple bond rendering\n * @param {Integer} params.linewidth - width of lines\n * @param {Boolean} params.lines - render bonds as lines\n * @param {String} params.crosses - render atoms as crosses: \"off\", \"all\" or \"lone\" (default)\n * @param {Float} params.crossSize - size of cross\n * @param {null} params.flatShaded - not available\n * @param {null} params.side - not available\n * @param {null} params.wireframe - not available\n * @param {null} params.roughness - not available\n * @param {null} params.metalness - not available\n * @param {null} params.diffuse - not available\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'line'\n\n this.parameters = Object.assign({\n\n multipleBond: {\n type: 'select',\n rebuild: true,\n options: {\n 'off': 'off',\n 'symmetric': 'symmetric',\n 'offset': 'offset'\n }\n },\n bondSpacing: {\n type: 'number', precision: 2, max: 2.0, min: 0.5\n },\n linewidth: {\n type: 'integer', max: 50, min: 1, buffer: true\n },\n lines: {\n type: 'boolean', rebuild: true\n },\n crosses: {\n type: 'select',\n rebuild: true,\n options: {\n 'off': 'off',\n 'lone': 'lone',\n 'all': 'all'\n }\n },\n crossSize: {\n type: 'number', precision: 2, max: 2.0, min: 0.1\n }\n\n }, this.parameters, {\n\n flatShaded: null,\n side: null,\n wireframe: null,\n\n roughness: null,\n metalness: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n\n this.multipleBond = defaults(p.multipleBond, 'off')\n this.bondSpacing = defaults(p.bondSpacing, 1.0)\n this.linewidth = defaults(p.linewidth, 2)\n this.lines = defaults(p.lines, true)\n this.crosses = defaults(p.crosses, 'lone')\n this.crossSize = defaults(p.crossSize, 0.4)\n\n super.init(p)\n }\n\n getAtomRadius (atom:AtomProxy) {\n return 0.1\n }\n\n getBondParams (what: any, params?: Partial) {\n params = Object.assign({\n multipleBond: this.multipleBond,\n bondSpacing: this.bondSpacing,\n radiusParams: { 'type': 'size', 'size': 0.1, 'scale': 1 }\n }, params)\n\n return super.getBondParams(what, params)\n }\n\n _crossData (what: any, sview: StructureView) {\n if (what) {\n if (!what.position && !what.color) return\n }\n\n const p = {}\n if (this.crosses === 'lone') {\n Object.assign(p, {atomSet : getLoneAtomSet(sview)})\n }\n\n const atomData = sview.getAtomData(this.getAtomParams(what, p))\n const crossData: CrossData = {}\n const position = atomData.position\n const color = atomData.color\n const picking = atomData.picking\n\n const size = (position! || color).length\n const attrSize = size * 3\n\n let cPosition1 = new Float32Array(0)\n let cPosition2 = new Float32Array(0)\n let cColor = new Float32Array(0)\n let cColor2 = new Float32Array(0)\n let cOffset: number = 0\n\n let pickingArray = new Float32Array(0)\n\n if (!what || what.position) {\n cPosition1 = crossData.position1 = new Float32Array(attrSize)\n cPosition2 = crossData.position2 = new Float32Array(attrSize)\n cOffset = this.crossSize / 2\n }\n if (!what || what.color) {\n cColor = crossData.color = new Float32Array(attrSize)\n cColor2 = crossData.color2 = new Float32Array(attrSize)\n }\n if (!what || what.picking) {\n pickingArray = new Float32Array(atomData.picking!.array!.length * 3) // Needs padding??\n }\n\n for (let v = 0; v < size; v++) {\n const j = v * 3\n const i = j * 3\n\n if (!what || what.position) {\n const x = position![ j ]\n const y = position![ j + 1 ]\n const z = position![ j + 2 ]\n\n cPosition1[ i ] = x - cOffset!\n cPosition1[ i + 1 ] = y\n cPosition1[ i + 2 ] = z\n cPosition2[ i ] = x + cOffset\n cPosition2[ i + 1 ] = y\n cPosition2[ i + 2 ] = z\n\n cPosition1[ i + 3 ] = x\n cPosition1[ i + 4 ] = y - cOffset\n cPosition1[ i + 5 ] = z\n cPosition2[ i + 3 ] = x\n cPosition2[ i + 4 ] = y + cOffset\n cPosition2[ i + 5 ] = z\n\n cPosition1[ i + 6 ] = x\n cPosition1[ i + 7 ] = y\n cPosition1[ i + 8 ] = z - cOffset\n cPosition2[ i + 6 ] = x\n cPosition2[ i + 7 ] = y\n cPosition2[ i + 8 ] = z + cOffset\n }\n\n if (!what || what.color) {\n const cimax = i + 9\n for (let ci = i; ci < cimax; ci += 3) {\n cColor[ ci ] = cColor2[ ci ] = color![ j ]\n cColor[ ci + 1 ] = cColor2[ ci + 1 ] = color![ j + 1 ]\n cColor[ ci + 2 ] = cColor2[ ci + 2 ] = color![ j + 2 ]\n }\n }\n\n if (!what || what.picking) {\n pickingArray[ j ] =\n pickingArray[ j + 1 ] =\n pickingArray[ j + 2 ] = picking!.array![ v ]\n }\n }\n\n if (!what || what.picking) {\n crossData.picking = new AtomPicker(\n pickingArray, picking!.structure\n )\n }\n\n return crossData\n }\n\n createData (sview: StructureView) {\n const what = { position: true, color: true, picking: true }\n\n const bufferList = []\n\n if (this.lines) {\n const bondData = sview.getBondData(this.getBondParams(what))\n\n const lineBuffer = new WideLineBuffer(\n bondData, this.getBufferParams({ linewidth: this.linewidth })\n )\n\n bufferList.push(lineBuffer)\n }\n\n if (this.crosses !== 'off') {\n const crossBuffer = new WideLineBuffer(\n (this._crossData(what, sview) as CrossData),\n this.getBufferParams({linewidth: this.linewidth})\n )\n bufferList.push(crossBuffer)\n }\n\n return {\n bufferList: bufferList\n }\n }\n\n updateData (what: any, data: StructureRepresentationData) {\n let bufferIdx = 0\n\n if (this.lines) {\n const bondData = data.sview!.getBondData(this.getBondParams(what))\n const lineAttributes = {}\n\n if (!what || what.position) {\n Object.assign(lineAttributes, {\n position1: bondData.position1,\n position2: bondData.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(lineAttributes, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n data.bufferList[ bufferIdx++ ].setAttributes(lineAttributes)\n }\n\n if (this.crosses !== 'off') {\n const crossData = this._crossData(what, (data.sview as StructureView))\n const crossAttributes = {}\n\n if (!what || what.position) {\n Object.assign(crossAttributes, {\n position1: crossData!.position1,\n position2: crossData!.position2\n })\n }\n if (!what || what.color) {\n Object.assign(crossAttributes, {\n color: crossData!.color,\n color2: crossData!.color2\n })\n }\n\n data.bufferList[ bufferIdx++ ].setAttributes(crossAttributes)\n }\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n if (params && (params.bondSpacing || params.crossSize)) {\n Object.assign(what, { position: true })\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('line', LineRepresentation)\n\nexport default LineRepresentation\n","import { NumberArray, TypedArray } from \"../types\";\n\n/**\n * @file Grid\n * @author Alexander Rose \n * @private\n */\nexport interface iGrid {\n data: TypedArray\n index: (x: number, y: number, z: number) => number\n set: (x: number, y: number, z: number, ...arg: number[]) => void\n toArray: (x: number, y: number, z: number, array?: NumberArray, offset?: number) => void\n fromArray: (x: number, y: number, z: number, array: NumberArray, offset?: number) => void\n copy: (grid: iGrid) => void\n // clone: () => iGrid\n}\n\nfunction makeGrid (length: number, width: number, height: number, DataCtor: any, elemSize: number) : iGrid {\n DataCtor = DataCtor || Int32Array\n elemSize = elemSize || 1\n\n const data = new DataCtor(length * width * height * elemSize)\n\n function index (x: number, y: number, z: number) {\n return ((((x * width) + y) * height) + z) * elemSize\n }\n\n function set (x: number, y: number, z: number, ...args: number[]) {\n const i = index(x, y, z)\n\n for (let j = 0; j < elemSize; ++j) {\n data[ i + j ] = args[ j ]\n }\n }\n\n function toArray (x: number, y: number, z: number, array: NumberArray = [], offset: number = 0) {\n const i = index(x, y, z)\n\n for (let j = 0; j < elemSize; ++j) {\n array[ offset + j ] = data[ i + j ]\n }\n }\n\n function fromArray(x: number, y: number, z: number, array: NumberArray, offset: number = 0) {\n const i = index(x, y, z)\n\n for (let j = 0; j < elemSize; ++j) {\n data[ i + j ] = array[ offset + j ]\n }\n }\n\n function copy(grid: iGrid) {\n data.set(grid.data)\n }\n\n // function clone() {\n // return makeGrid(\n // length, width, height, DataCtor, elemSize\n // ).copy(this)\n // }\n return { data, index, set, toArray, fromArray, copy }\n}\n\nexport { makeGrid }","/**\n * @file EDT Surface\n * @author Alexander Rose \n * @private\n */\n\nimport { VolumeSurface } from './volume'\nimport { iGrid, makeGrid } from '../geometry/grid'\nimport { computeBoundingBox } from '../math/vector-utils'\nimport { getRadiusDict, getSurfaceGrid } from './surface-utils'\nimport { TypedArray } from '../types';\n\ninterface EDTSurface {\n getVolume: (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean) => {\n data: TypedArray\n nx: number\n ny: number\n nz: number\n atomindex: TypedArray\n }\n getSurface: (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean, smooth: number, contour: boolean) => any\n}\n\nfunction EDTSurface (this: EDTSurface, coordList: Float32Array, radiusList: Float32Array, indexList: Uint16Array|Uint32Array) {\n // based on D. Xu, Y. Zhang (2009) Generating Triangulated Macromolecular\n // Surfaces by Euclidean Distance Transform. PLoS ONE 4(12): e8140.\n //\n // Permission to use, copy, modify, and distribute this program for\n // any purpose, with or without fee, is hereby granted, provided that\n // the notices on the head, the reference information, and this\n // copyright notice appear in all copies or substantial portions of\n // the Software. It is provided \"as is\" without express or implied\n // warranty.\n //\n // ported to JavaScript by biochem_fan (http://webglmol.sourceforge.jp/)\n // refactored by dkoes (https://github.com/dkoes)\n //\n // adapted to NGL by Alexander Rose\n\n var radiusDict = getRadiusDict(radiusList as any)\n var bbox = computeBoundingBox(coordList)\n if (coordList.length === 0) {\n bbox[ 0 ].set([ 0, 0, 0 ])\n bbox[ 1 ].set([ 0, 0, 0 ])\n }\n var min = bbox[ 0 ]\n var max = bbox[ 1 ]\n\n var probeRadius: number, scaleFactor: number, cutoff: number\n var pLength: number, pWidth: number, pHeight: number\n var matrix: Float32Array, ptran: Float32Array\n var depty: {[k: string]: TypedArray}, widxz: {[k: string]: number}\n var cutRadius: number\n var setAtomID: boolean\n var vpBits: TypedArray, vpDistance: TypedArray, vpAtomID: TypedArray\n\n function init (btype: boolean, _probeRadius: number, _scaleFactor: number, _cutoff: number, _setAtomID: boolean) {\n probeRadius = _probeRadius || 1.4\n scaleFactor = _scaleFactor || 2.0\n setAtomID = _setAtomID || true\n\n var maxRadius = 0\n for (var radius in radiusDict) {\n maxRadius = Math.max(maxRadius, radius as any)\n }\n\n var grid = getSurfaceGrid(\n min, max, maxRadius, scaleFactor, btype ? probeRadius : 0\n )\n\n pLength = grid.dim[0]\n pWidth = grid.dim[1]\n pHeight = grid.dim[2]\n\n matrix = grid.matrix\n ptran = grid.tran\n scaleFactor = grid.scaleFactor\n\n // boundingatom caches\n depty = {}\n widxz = {}\n boundingatom(btype)\n\n cutRadius = probeRadius * scaleFactor\n\n if (_cutoff) {\n cutoff = _cutoff\n } else {\n // cutoff = Math.max( 0.1, -1.2 + scaleFactor * probeRadius );\n cutoff = probeRadius / scaleFactor\n }\n\n vpBits = new Uint8Array(pLength * pWidth * pHeight)\n if (btype) {\n vpDistance = new Float64Array(pLength * pWidth * pHeight)\n }\n if (setAtomID) {\n vpAtomID = new Int32Array(pLength * pWidth * pHeight)\n }\n }\n\n // constants for vpBits bitmasks\n var INOUT = 1\n var ISDONE = 2\n var ISBOUND = 4\n\n var nb = [\n new Int32Array([ 1, 0, 0 ]), new Int32Array([ -1, 0, 0 ]),\n new Int32Array([ 0, 1, 0 ]), new Int32Array([ 0, -1, 0 ]),\n new Int32Array([ 0, 0, 1 ]), new Int32Array([ 0, 0, -1 ]),\n new Int32Array([ 1, 1, 0 ]), new Int32Array([ 1, -1, 0 ]),\n new Int32Array([ -1, 1, 0 ]), new Int32Array([ -1, -1, 0 ]),\n new Int32Array([ 1, 0, 1 ]), new Int32Array([ 1, 0, -1 ]),\n new Int32Array([ -1, 0, 1 ]), new Int32Array([ -1, 0, -1 ]),\n new Int32Array([ 0, 1, 1 ]), new Int32Array([ 0, 1, -1 ]),\n new Int32Array([ 0, -1, 1 ]), new Int32Array([ 0, -1, -1 ]),\n new Int32Array([ 1, 1, 1 ]), new Int32Array([ 1, 1, -1 ]),\n new Int32Array([ 1, -1, 1 ]), new Int32Array([ -1, 1, 1 ]),\n new Int32Array([ 1, -1, -1 ]), new Int32Array([ -1, -1, 1 ]),\n new Int32Array([ -1, 1, -1 ]), new Int32Array([ -1, -1, -1 ])\n ]\n\n //\n\n this.getVolume = function (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean) {\n console.time('EDTSurface.getVolume')\n\n var btype = type !== 'vws'\n\n init(btype, probeRadius, scaleFactor, cutoff, setAtomID)\n\n fillvoxels(btype)\n buildboundary()\n\n if (type === 'ms' || type === 'ses') {\n fastdistancemap()\n }\n\n if (type === 'ses') {\n boundingatom(false)\n fillvoxelswaals()\n }\n\n marchingcubeinit(type)\n\n // set atomindex in the volume data\n for (var i = 0, il = vpAtomID.length; i < il; ++i) {\n vpAtomID[ i ] = indexList[ vpAtomID[ i ] ]\n }\n\n console.timeEnd('EDTSurface.getVolume')\n\n return {\n data: vpBits,\n nx: pHeight,\n ny: pWidth,\n nz: pLength,\n atomindex: vpAtomID\n }\n }\n\n this.getSurface = function (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean, smooth: number, contour: boolean) {\n var vd = this.getVolume(\n type, probeRadius, scaleFactor, cutoff, setAtomID\n )\n\n var volsurf = new (VolumeSurface as any)(\n vd.data, vd.nx, vd.ny, vd.nz, vd.atomindex\n ) as VolumeSurface\n\n return (volsurf!.getSurface as any)(1, smooth, undefined, matrix, contour)\n }\n\n function boundingatom (btype: boolean) {\n var r\n var j\n var k\n var txz\n var tdept\n var sradius\n var tradius\n var widxzR\n var deptyName\n var indx\n\n for (var name in radiusDict) {\n r = parseFloat(name)\n\n if (depty[ name ]) continue\n\n if (!btype) {\n tradius = r * scaleFactor + 0.5\n } else {\n tradius = (r + probeRadius) * scaleFactor + 0.5\n }\n\n sradius = tradius * tradius\n widxzR = Math.floor(tradius) + 1\n deptyName = new Int32Array(widxzR * widxzR)\n indx = 0\n\n for (j = 0; j < widxzR; ++j) {\n for (k = 0; k < widxzR; ++k) {\n txz = j * j + k * k\n\n if (txz > sradius) {\n deptyName[ indx ] = -1\n } else {\n tdept = Math.sqrt(sradius - txz)\n deptyName[ indx ] = Math.floor(tdept)\n }\n\n ++indx\n }\n }\n\n widxz[ name ] = widxzR\n depty[ name ] = deptyName\n }\n }\n\n function fillatom (idx: number) {\n var ci = idx * 3\n var ri = idx\n\n var cx, cy, cz, ox, oy, oz, mi, mj, mk, i, j, k, si, sj, sk\n var ii, jj, kk\n\n cx = Math.floor(0.5 + scaleFactor * (coordList[ ci ] + ptran[0]))\n cy = Math.floor(0.5 + scaleFactor * (coordList[ ci + 1 ] + ptran[1]))\n cz = Math.floor(0.5 + scaleFactor * (coordList[ ci + 2 ] + ptran[2]))\n\n var at = radiusList[ ri ]\n var deptyAt = depty[ at ]\n var nind = 0\n var pWH = pWidth * pHeight\n var n = widxz[ at ]\n\n var deptyAtNind\n\n for (i = 0; i < n; ++i) {\n for (j = 0; j < n; ++j) {\n deptyAtNind = deptyAt[ nind ]\n\n if (deptyAtNind !== -1) {\n for (ii = -1; ii < 2; ++ii) {\n for (jj = -1; jj < 2; ++jj) {\n for (kk = -1; kk < 2; ++kk) {\n if (ii !== 0 && jj !== 0 && kk !== 0) {\n mi = ii * i\n mk = kk * j\n\n for (k = 0; k <= deptyAtNind; ++k) {\n mj = k * jj\n si = cx + mi\n sj = cy + mj\n sk = cz + mk\n\n if (si < 0 || sj < 0 || sk < 0 ||\n si >= pLength || sj >= pWidth || sk >= pHeight\n ) {\n continue\n }\n\n var index = si * pWH + sj * pHeight + sk\n\n if (!setAtomID) {\n vpBits[ index ] |= INOUT\n } else {\n if (!(vpBits[ index ] & INOUT)) {\n vpBits[ index ] |= INOUT\n vpAtomID[ index ] = idx\n } else if (vpBits[ index ] & INOUT) {\n var ci2 = vpAtomID[ index ]\n\n if (ci2 !== ci) {\n ox = cx + mi - Math.floor(0.5 + scaleFactor * (coordList[ci2] + ptran[0]))\n oy = cy + mj - Math.floor(0.5 + scaleFactor * (coordList[ci2 + 1] + ptran[1]))\n oz = cz + mk - Math.floor(0.5 + scaleFactor * (coordList[ci2 + 2] + ptran[2]))\n\n if (mi * mi + mj * mj + mk * mk < ox * ox + oy * oy + oz * oz) {\n vpAtomID[ index ] = idx\n }\n }\n }\n }\n } // k\n } // if\n } // kk\n } // jj\n } // ii\n } // if\n\n nind++\n } // j\n } // i\n }\n\n function fillvoxels (btype: boolean) {\n console.time('EDTSurface fillvoxels')\n\n var i, il\n\n for (i = 0, il = vpBits.length; i < il; ++i) {\n vpBits[ i ] = 0\n if (btype) vpDistance[ i ] = -1.0\n if (setAtomID) vpAtomID[ i ] = -1\n }\n\n for (i = 0, il = coordList.length / 3; i < il; ++i) {\n fillatom(i)\n }\n\n for (i = 0, il = vpBits.length; i < il; ++i) {\n if (vpBits[ i ] & INOUT) {\n vpBits[ i ] |= ISDONE\n }\n }\n\n console.timeEnd('EDTSurface fillvoxels')\n }\n\n function fillAtomWaals (idx: number) {\n var ci = idx * 3\n var ri = idx\n\n var cx\n var cy\n var cz\n var ox\n var oy\n var oz\n var nind = 0\n\n var mi\n var mj\n var mk\n var si\n var sj\n var sk\n var i\n var j\n var k\n var ii\n var jj\n var kk\n var n\n\n cx = Math.floor(0.5 + scaleFactor * (coordList[ ci ] + ptran[0]))\n cy = Math.floor(0.5 + scaleFactor * (coordList[ ci + 1 ] + ptran[1]))\n cz = Math.floor(0.5 + scaleFactor * (coordList[ ci + 2 ] + ptran[2]))\n\n var at = radiusList[ ri ]\n var pWH = pWidth * pHeight\n\n for (i = 0, n = widxz[at]; i < n; ++i) {\n for (j = 0; j < n; ++j) {\n if (depty[ at ][ nind ] !== -1) {\n for (ii = -1; ii < 2; ++ii) {\n for (jj = -1; jj < 2; ++jj) {\n for (kk = -1; kk < 2; ++kk) {\n if (ii !== 0 && jj !== 0 && kk !== 0) {\n mi = ii * i\n mk = kk * j\n\n for (k = 0; k <= depty[ at ][ nind ]; ++k) {\n mj = k * jj\n si = cx + mi\n sj = cy + mj\n sk = cz + mk\n\n if (si < 0 || sj < 0 || sk < 0 ||\n si >= pLength || sj >= pWidth || sk >= pHeight\n ) {\n continue\n }\n\n var index = si * pWH + sj * pHeight + sk\n\n if (!(vpBits[ index ] & ISDONE)) {\n vpBits[ index ] |= ISDONE\n if (setAtomID) vpAtomID[ index ] = idx\n } else if (setAtomID) {\n var ci2 = vpAtomID[ index ]\n\n ox = Math.floor(0.5 + scaleFactor * (coordList[ ci2 ] + ptran[0]))\n oy = Math.floor(0.5 + scaleFactor * (coordList[ ci2 + 1 ] + ptran[1]))\n oz = Math.floor(0.5 + scaleFactor * (coordList[ ci2 + 2 ] + ptran[2]))\n\n if (mi * mi + mj * mj + mk * mk < ox * ox + oy * oy + oz * oz) {\n vpAtomID[ index ] = idx\n }\n }\n } // k\n } // if\n } // kk\n } // jj\n } // ii\n } // if\n\n nind++\n } // j\n } // i\n }\n\n function fillvoxelswaals () {\n var i, il\n\n for (i = 0, il = vpBits.length; i < il; ++i) {\n vpBits[ i ] &= ~ISDONE // not isdone\n }\n\n for (i = 0, il = coordList.length / 3; i < il; ++i) {\n fillAtomWaals(i)\n }\n }\n\n function buildboundary () {\n var i, j, k\n var pWH = pWidth * pHeight\n\n for (i = 0; i < pLength; ++i) {\n for (j = 0; j < pHeight; ++j) {\n for (k = 0; k < pWidth; ++k) {\n var index = i * pWH + k * pHeight + j\n\n if (vpBits[ index ] & INOUT) {\n // var flagbound = false;\n var ii = 0\n\n // while( !flagbound && ii < 26 ){\n while (ii < 26) {\n var ti = i + nb[ ii ][ 0 ]\n var tj = j + nb[ ii ][ 2 ]\n var tk = k + nb[ ii ][ 1 ]\n\n if (ti > -1 && ti < pLength &&\n tk > -1 && tk < pWidth &&\n tj > -1 && tj < pHeight &&\n !(vpBits[ ti * pWH + tk * pHeight + tj ] & INOUT)\n ) {\n vpBits[ index ] |= ISBOUND\n // flagbound = true;\n break\n } else {\n ii++\n }\n }\n }\n } // k\n } // j\n } // i\n }\n\n function fastdistancemap () {\n console.time('EDTSurface fastdistancemap')\n\n var i, j, k, n\n\n var boundPoint = makeGrid(\n pLength, pWidth, pHeight, Uint16Array, 3\n )\n var pWH = pWidth * pHeight\n var cutRSq = cutRadius * cutRadius\n\n var totalsurfacevox = 0\n // var totalinnervox = 0;\n\n var index\n\n for (i = 0; i < pLength; ++i) {\n for (j = 0; j < pWidth; ++j) {\n for (k = 0; k < pHeight; ++k) {\n index = i * pWH + j * pHeight + k\n\n vpBits[ index ] &= ~ISDONE\n\n if (vpBits[ index ] & INOUT) {\n if (vpBits[ index ] & ISBOUND) {\n boundPoint.set(\n i, j, k,\n i, j, k\n )\n\n vpDistance[ index ] = 0\n vpBits[ index ] |= ISDONE\n\n totalsurfacevox += 1\n }/* else{\n totalinnervox += 1;\n } */\n }\n }\n }\n }\n\n var inarray = new Int32Array(3 * totalsurfacevox)\n var positin = 0\n var outarray = new Int32Array(3 * totalsurfacevox)\n var positout = 0\n\n for (i = 0; i < pLength; ++i) {\n for (j = 0; j < pWidth; ++j) {\n for (k = 0; k < pHeight; ++k) {\n index = i * pWH + j * pHeight + k\n\n if (vpBits[ index ] & ISBOUND) {\n inarray[ positin ] = i\n inarray[ positin + 1 ] = j\n inarray[ positin + 2 ] = k\n positin += 3\n\n vpBits[ index ] &= ~ISBOUND\n }\n }\n }\n }\n\n do {\n positout = fastoneshell(inarray, boundPoint, positin, outarray)\n positin = 0\n\n for (i = 0, n = positout; i < n; i += 3) {\n index = pWH * outarray[ i ] + pHeight * outarray[ i + 1 ] + outarray[ i + 2 ]\n vpBits[ index ] &= ~ISBOUND\n\n if (vpDistance[ index ] <= 1.0404 * cutRSq) {\n // if( vpDistance[ index ] <= 1.02 * cutRadius ){\n\n inarray[ positin ] = outarray[ i ]\n inarray[ positin + 1 ] = outarray[ i + 1 ]\n inarray[ positin + 2 ] = outarray[ i + 2 ]\n positin += 3\n }\n }\n } while (positin > 0)\n\n // var cutsf = Math.max( 0, scaleFactor - 0.5 );\n // cutoff = cutRadius - 0.5 / ( 0.1 + cutsf );\n var cutoffSq = cutoff * cutoff\n\n var index2\n var bp = new Uint16Array(3)\n\n for (i = 0; i < pLength; ++i) {\n for (j = 0; j < pWidth; ++j) {\n for (k = 0; k < pHeight; ++k) {\n index = i * pWH + j * pHeight + k\n vpBits[ index ] &= ~ISBOUND\n\n // ses solid\n\n if (vpBits[ index ] & INOUT) {\n if (!(vpBits[ index ] & ISDONE) ||\n ((vpBits[ index ] & ISDONE) && vpDistance[ index ] >= cutoffSq)\n ) {\n vpBits[ index ] |= ISBOUND\n\n if (setAtomID && (vpBits[ index ] & ISDONE)) {\n boundPoint.toArray(i, j, k, bp)\n index2 = bp[ 0 ] * pWH + bp[ 1 ] * pHeight + bp[ 2 ]\n\n vpAtomID[ index ] = vpAtomID[ index2 ]\n }\n }\n }\n }\n }\n }\n\n console.timeEnd('EDTSurface fastdistancemap')\n }\n\n function fastoneshell (inarray: Int32Array, boundPoint: iGrid, positin: number, outarray: Int32Array) {\n // *allocout,voxel2\n // ***boundPoint, int*\n // outnum, int *elimi)\n var tx, ty, tz\n var dx, dy, dz\n var i, j, n\n var square\n var index\n var nbj\n var bp = new Uint16Array(3)\n var positout = 0\n\n if (positin === 0) {\n return positout\n }\n\n var tnvix = -1\n var tnviy = -1\n var tnviz = -1\n\n var pWH = pWidth * pHeight\n\n for (i = 0, n = positin; i < n; i += 3) {\n tx = inarray[ i ]\n ty = inarray[ i + 1 ]\n tz = inarray[ i + 2 ]\n boundPoint.toArray(tx, ty, tz, bp)\n\n for (j = 0; j < 6; ++j) {\n nbj = nb[ j ]\n tnvix = tx + nbj[ 0 ]\n tnviy = ty + nbj[ 1 ]\n tnviz = tz + nbj[ 2 ]\n\n if (tnvix < pLength && tnvix > -1 &&\n tnviy < pWidth && tnviy > -1 &&\n tnviz < pHeight && tnviz > -1\n ) {\n index = tnvix * pWH + pHeight * tnviy + tnviz\n\n if ((vpBits[ index ] & INOUT) && !(vpBits[ index ] & ISDONE)) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n vpDistance[ index ] = square\n vpBits[ index ] |= ISDONE\n vpBits[ index ] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n } else if ((vpBits[ index ] & INOUT) && (vpBits[ index ] & ISDONE)) {\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n if (square < vpDistance[ index ]) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n vpDistance[ index ] = square\n\n if (!(vpBits[ index ] & ISBOUND)) {\n vpBits[ index ] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n }\n }\n }\n }\n }\n }\n\n for (i = 0, n = positin; i < n; i += 3) {\n tx = inarray[ i ]\n ty = inarray[ i + 1 ]\n tz = inarray[ i + 2 ]\n boundPoint.toArray(tx, ty, tz, bp)\n\n for (j = 6; j < 18; j++) {\n nbj = nb[ j ]\n tnvix = tx + nbj[ 0 ]\n tnviy = ty + nbj[ 1 ]\n tnviz = tz + nbj[ 2 ]\n\n if (tnvix < pLength && tnvix > -1 &&\n tnviy < pWidth && tnviy > -1 &&\n tnviz < pHeight && tnviz > -1\n ) {\n index = tnvix * pWH + pHeight * tnviy + tnviz\n\n if ((vpBits[index] & INOUT) && !(vpBits[index] & ISDONE)) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n vpDistance[index] = square\n vpBits[index] |= ISDONE\n vpBits[index] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n } else if ((vpBits[index] & INOUT) && (vpBits[index] & ISDONE)) {\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n if (square < vpDistance[index]) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n vpDistance[index] = square\n\n if (!(vpBits[index] & ISBOUND)) {\n vpBits[index] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n }\n }\n }\n }\n }\n }\n\n for (i = 0, n = positin; i < n; i += 3) {\n tx = inarray[ i ]\n ty = inarray[ i + 1 ]\n tz = inarray[ i + 2 ]\n boundPoint.toArray(tx, ty, tz, bp)\n\n for (j = 18; j < 26; j++) {\n nbj = nb[ j ]\n tnvix = tx + nbj[ 0 ]\n tnviy = ty + nbj[ 1 ]\n tnviz = tz + nbj[ 2 ]\n\n if (tnvix < pLength && tnvix > -1 &&\n tnviy < pWidth && tnviy > -1 &&\n tnviz < pHeight && tnviz > -1\n ) {\n index = tnvix * pWH + pHeight * tnviy + tnviz\n\n if ((vpBits[index] & INOUT) && !(vpBits[index] & ISDONE)) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n vpDistance[index] = square\n vpBits[index] |= ISDONE\n vpBits[index] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n } else if ((vpBits[index] & INOUT) && (vpBits[index] & ISDONE)) {\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n if (square < vpDistance[index]) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n vpDistance[index] = square\n\n if (!(vpBits[index] & ISBOUND)) {\n vpBits[index] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n }\n }\n }\n }\n }\n }\n\n return positout\n }\n\n function marchingcubeinit (stype: string) {\n var i\n var n = vpBits.length\n\n if (stype === 'vws') {\n for (i = 0; i < n; ++i) {\n vpBits[ i ] &= ~ISBOUND\n vpBits[ i ] = (vpBits[ i ] & ISDONE) ? 1 : 0\n }\n } else if (stype === 'ms') { // ses without vdw => ms\n for (i = 0; i < n; ++i) {\n vpBits[ i ] &= ~ISDONE\n if (vpBits[ i ] & ISBOUND) {\n vpBits[ i ] |= ISDONE\n }\n vpBits[ i ] &= ~ISBOUND\n vpBits[ i ] = (vpBits[ i ] & ISDONE) ? 1 : 0\n }\n } else if (stype === 'ses') {\n for (i = 0; i < n; ++i) {\n if ((vpBits[ i ] & ISBOUND) && (vpBits[ i ] & ISDONE)) {\n vpBits[ i ] &= ~ISBOUND\n } else if ((vpBits[ i ] & ISBOUND) && !(vpBits[ i ] & ISDONE)) {\n vpBits[ i ] |= ISDONE\n }\n vpBits[ i ] = (vpBits[ i ] & ISDONE) ? 1 : 0\n }\n } else if (stype === 'sas') {\n for (i = 0; i < n; ++i) {\n vpBits[ i ] &= ~ISBOUND\n vpBits[ i ] = (vpBits[ i ] & ISDONE) ? 1 : 0\n }\n }\n }\n}\nObject.assign(EDTSurface, {__deps: [\n getSurfaceGrid, getRadiusDict, VolumeSurface, computeBoundingBox, makeGrid\n]})\n\nexport default EDTSurface\n","/**\n * @file AV Surface\n * @author Fred Ludlow \n * @private\n */\n\nimport { getSurfaceGrid } from './surface-utils'\nimport { VolumeSurface } from './volume'\nimport { uniformArray } from '../math/array-utils'\nimport {\n computeBoundingBox, v3multiplyScalar, v3cross, v3normalize\n} from '../math/vector-utils'\nimport { defaults } from '../utils'\nimport { NumberArray } from '../types';\n\n\n/**\n * Modifed from SpatialHash\n *\n * Main differences are:\n * - Optimized grid size to ensure we only ever need to look +/-1 cell\n * - Aware of atomic radii and will only output atoms within rAtom + rExtra\n * (see withinRadii method)\n *\n * (Uses rounding rather than bitshifting as consequence of arbitrary grid size)\n * @class\n * @param {Float32Array} atomsX - x coordinates\n * @param {Float32Array} atomsY - y coordinates\n * @param {Float32Array} atomsZ - z coordinates\n * @param {Float32Array} atomsR - atom radii\n * @param {Float32Array} min - xyz min coordinates\n * @param {Float32Array} max - xyz max coordinates\n * @param {Float} maxDistance - max distance\n */\nexport interface iAVHash {\n neighbourListLength: number\n withinRadii: (x: number, y: number, z: number, rExtra: number, out: Int32Array) => void\n}\n\n\nfunction makeAVHash (atomsX: Float32Array, atomsY: Float32Array, atomsZ: Float32Array, atomsR: Float32Array, min: Float32Array, max: Float32Array, maxDistance: number): iAVHash {\n maxDistance = Math.max(0.1, maxDistance) // Avoid maxDistance of zero, see #802\n var nAtoms = atomsX.length\n\n var minX = min[ 0 ]\n var minY = min[ 1 ]\n var minZ = min[ 2 ]\n\n var maxX = max[ 0 ]\n var maxY = max[ 1 ]\n var maxZ = max[ 2 ]\n\n function hashFunc (w: number, minW: number) {\n return Math.floor((w - minW) / maxDistance)\n }\n\n var iDim = hashFunc(maxX, minX) + 1\n var jDim = hashFunc(maxY, minY) + 1\n var kDim = hashFunc(maxZ, minZ) + 1\n\n var nCells = iDim * jDim * kDim\n\n var jkDim = jDim * kDim\n\n /* Get cellID for cartesian x,y,z */\n var cellID = function (x: number, y: number, z: number) {\n return (((hashFunc(x, minX) * jDim) + hashFunc(y, minY)) * kDim) + hashFunc(z, minZ)\n }\n\n /* Initial building, could probably be optimized further */\n var preHash = [] // preHash[ cellID ] = [ atomId1, atomId2 ];\n\n for (var i = 0; i < nAtoms; i++) {\n var cid = cellID(atomsX[ i ], atomsY[ i ], atomsZ[ i ])\n\n if (preHash[ cid ] === undefined) {\n preHash[ cid ] = [ i ]\n } else {\n preHash[ cid ].push(i)\n }\n }\n\n var cellOffsets = new Uint32Array(nCells)\n var cellLengths = new Uint16Array(nCells)\n var data = new Uint32Array(nAtoms)\n\n var offset = 0\n var maxCellLength = 0\n\n for (i = 0; i < nCells; i++) {\n var start = cellOffsets[ i ] = offset\n\n var subArray = preHash[ i ]\n\n if (subArray !== undefined) {\n for (var j = 0; j < subArray.length; j++) {\n data[ offset ] = subArray[ j ]\n offset++\n }\n }\n\n var cellLength = offset - start\n cellLengths[ i ] = cellLength\n\n if (cellLength > maxCellLength) { maxCellLength = cellLength }\n }\n\n // Maximum number of neighbours we could ever produce (27 adjacent cells of equal population)\n const neighbourListLength = (27 * maxCellLength) + 1\n\n /**\n * Populate the supplied out array with atom indices that are within rAtom + rExtra\n * of x,y,z\n *\n * -1 in out array indicates the end of the list\n *\n * @param {Float} x - x coordinate\n * @param {Float} y - y coordinate\n * @param {Float} z - z coordinate\n * @param {Float} rExtra - additional radius\n * @param {Float32Array} out - pre-allocated output array\n * @return {undefined}\n */\n const withinRadii = function (x: number, y: number, z: number, rExtra: number, out: Int32Array) {\n var outIdx = 0\n\n var nearI = hashFunc(x, minX)\n var nearJ = hashFunc(y, minY)\n var nearK = hashFunc(z, minZ)\n\n var loI = Math.max(0, nearI - 1)\n var loJ = Math.max(0, nearJ - 1)\n var loK = Math.max(0, nearK - 1)\n\n var hiI = Math.min(iDim, nearI + 2)\n var hiJ = Math.min(jDim, nearJ + 2)\n var hiK = Math.min(kDim, nearK + 2)\n\n for (var i = loI; i < hiI; ++i) {\n var iOffset = i * jkDim\n\n for (var j = loJ; j < hiJ; ++j) {\n var jOffset = j * kDim\n\n for (var k = loK; k < hiK; ++k) {\n var cid = iOffset + jOffset + k\n\n var cellStart = cellOffsets[ cid ]\n var cellEnd = cellStart + cellLengths[ cid ]\n\n for (var dataIndex = cellStart; dataIndex < cellEnd; dataIndex++) {\n var atomIndex = data[ dataIndex ]\n var dx = atomsX[ atomIndex ] - x\n var dy = atomsY[ atomIndex ] - y\n var dz = atomsZ[ atomIndex ] - z\n var rSum = atomsR[ atomIndex ] + rExtra\n\n if ((dx * dx + dy * dy + dz * dz) <= (rSum * rSum)) {\n out[ outIdx++ ] = data[ dataIndex ]\n }\n }\n }\n }\n }\n // Add terminator\n out[ outIdx ] = -1\n }\n return {\n neighbourListLength: neighbourListLength,\n withinRadii: withinRadii\n }\n}\n\ninterface AVSurface {\n getSurface: (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean, smooth: number, contour: boolean) => any\n}\nfunction AVSurface (this: AVSurface, coordList: Float32Array, radiusList: Float32Array, indexList: Uint16Array|Uint32Array) {\n // Field generation method adapted from AstexViewer (Mike Hartshorn)\n // by Fred Ludlow.\n // Other parts based heavily on NGL (Alexander Rose) EDT Surface class\n //\n // Should work as a drop-in alternative to EDTSurface (though some of\n // the EDT paramters are not relevant in this method).\n\n const nAtoms = radiusList.length\n\n const x = new Float32Array(nAtoms)\n const y = new Float32Array(nAtoms)\n const z = new Float32Array(nAtoms)\n\n for (let i = 0; i < nAtoms; i++) {\n const ci = 3 * i\n x[ i ] = coordList[ ci ]\n y[ i ] = coordList[ ci + 1 ]\n z[ i ] = coordList[ ci + 2 ]\n }\n\n let bbox = computeBoundingBox(coordList)\n if (coordList.length === 0) {\n bbox[ 0 ].set([ 0, 0, 0 ])\n bbox[ 1 ].set([ 0, 0, 0 ])\n }\n const min = bbox[0]\n const max = bbox[1]\n\n let r: Float32Array, r2: Float32Array // Atom positions, expanded radii (squared)\n let maxRadius: number\n\n // Parameters\n let probeRadius: number, scaleFactor: number, setAtomID: boolean, probePositions: number\n\n // Cache last value for obscured test\n let lastClip = -1\n\n // Grid params\n let dim: Float32Array, matrix: Float32Array, grid: NumberArray, atomIndex: Int32Array\n\n // grid indices -> xyz coords\n let gridx: Float32Array, gridy: Float32Array, gridz: Float32Array\n\n // Lookup tables:\n let sinTable: Float32Array, cosTable: Float32Array\n\n // Spatial Hash\n let hash: iAVHash\n\n // Neighbour array to be filled by hash\n let neighbours: Int32Array\n\n // Vectors for Torus Projection\n const atob = new Float32Array([ 0.0, 0.0, 0.0 ])\n const mid = new Float32Array([ 0.0, 0.0, 0.0 ])\n const n1 = new Float32Array([ 0.0, 0.0, 0.0 ])\n const n2 = new Float32Array([ 0.0, 0.0, 0.0 ])\n\n let ngTorus: number\n\n function init (_probeRadius?: number, _scaleFactor?: number, _setAtomID?: boolean, _probePositions?: number) {\n probeRadius = defaults(_probeRadius, 1.4)\n scaleFactor = defaults(_scaleFactor, 2.0)\n setAtomID = defaults(_setAtomID, true)\n probePositions = defaults(_probePositions, 30)\n\n r = new Float32Array(nAtoms)\n r2 = new Float32Array(nAtoms)\n\n for (let i = 0; i < r.length; ++i) {\n var rExt = radiusList[ i ] + probeRadius\n r[ i ] = rExt\n r2[ i ] = rExt * rExt\n }\n\n maxRadius = 0\n for (let j = 0; j < r.length; ++j) {\n if (r[ j ] > maxRadius) maxRadius = r[ j ]\n }\n\n initializeGrid()\n initializeAngleTables()\n initializeHash()\n\n lastClip = -1\n }\n\n function fillGridDim (a: Float32Array, start: number, step: number) {\n for (let i = 0; i < a.length; i++) {\n a[i] = start + (step * i)\n }\n }\n\n function initializeGrid () {\n const surfGrid = getSurfaceGrid(\n min, max, maxRadius, scaleFactor, 0.0\n )\n\n scaleFactor = surfGrid.scaleFactor\n dim = surfGrid.dim\n matrix = surfGrid.matrix\n\n ngTorus = Math.max(5, 2 + Math.floor(probeRadius * scaleFactor))\n\n grid = uniformArray(dim[0] * dim[1] * dim[2], -1001.0)\n\n atomIndex = new Int32Array(grid.length)\n\n gridx = new Float32Array(dim[0])\n gridy = new Float32Array(dim[1])\n gridz = new Float32Array(dim[2])\n\n fillGridDim(gridx, min[0], 1 / scaleFactor)\n fillGridDim(gridy, min[1], 1 / scaleFactor)\n fillGridDim(gridz, min[2], 1 / scaleFactor)\n }\n\n function initializeAngleTables () {\n var theta = 0.0\n var step = 2 * Math.PI / probePositions\n\n cosTable = new Float32Array(probePositions)\n sinTable = new Float32Array(probePositions)\n for (var i = 0; i < probePositions; i++) {\n cosTable[ i ] = Math.cos(theta)\n sinTable[ i ] = Math.sin(theta)\n theta += step\n }\n }\n\n function initializeHash () {\n hash = makeAVHash(x, y, z, r, min, max, 2.01 * maxRadius)\n neighbours = new Int32Array(hash.neighbourListLength)\n }\n\n function obscured (x: number, y: number, z: number, a: number, b: number) {\n // Is the point at x,y,z obscured by any of the atoms\n // specifeid by indices in neighbours. Ignore indices\n // a and b (these are the relevant atoms in projectPoints/Torii)\n\n // Cache the last clipped atom (as very often the same one in\n // subsequent calls)\n let ai: number\n\n if (lastClip !== -1) {\n ai = lastClip\n if (ai !== a && ai !== b && singleAtomObscures(ai, x, y, z)) {\n return ai\n } else {\n lastClip = -1\n }\n }\n\n var ni = 0\n ai = neighbours[ ni ]\n while (ai >= 0) {\n if (ai !== a && ai !== b && singleAtomObscures(ai, x, y, z)) {\n lastClip = ai\n return ai\n }\n ai = neighbours[ ++ni ]\n }\n\n lastClip = -1\n\n return -1\n }\n\n function singleAtomObscures (ai: number, x: number, y: number, z: number) {\n var ci = 3 * ai\n var ra2 = r2[ ai ]\n var dx = coordList[ ci ] - x\n var dy = coordList[ ci + 1 ] - y\n var dz = coordList[ ci + 2 ] - z\n var d2 = dx * dx + dy * dy + dz * dz\n\n return d2 < ra2\n }\n\n function projectPoints () {\n // For each atom:\n // Iterate over a subsection of the grid, for each point:\n // If current value < 0.0, unvisited, set positive\n //\n // In any case: Project this point onto surface of the atomic sphere\n // If this projected point is not obscured by any other atom\n // Calcualte delta distance and set grid value to minimum of\n // itself and delta\n\n // Should we alias frequently accessed closure variables??\n // Assume JS engine capable of optimizing this\n // anyway...\n\n for (var i = 0; i < nAtoms; i++) {\n var ax = x[ i ]\n var ay = y[ i ]\n var az = z[ i ]\n var ar = r[ i ]\n var ar2 = r2[ i ]\n\n hash.withinRadii(ax, ay, az, ar, neighbours)\n\n // Number of grid points, round this up...\n var ng = Math.ceil(ar * scaleFactor)\n\n // Center of the atom, mapped to grid points (take floor)\n var iax = Math.floor(scaleFactor * (ax - min[ 0 ]))\n var iay = Math.floor(scaleFactor * (ay - min[ 1 ]))\n var iaz = Math.floor(scaleFactor * (az - min[ 2 ]))\n\n // Extents of grid to consider for this atom\n var minx = Math.max(0, iax - ng)\n var miny = Math.max(0, iay - ng)\n var minz = Math.max(0, iaz - ng)\n\n // Add two to these points:\n // - iax are floor'd values so this ensures coverage\n // - these are loop limits (exclusive)\n var maxx = Math.min(dim[ 0 ], iax + ng + 2)\n var maxy = Math.min(dim[ 1 ], iay + ng + 2)\n var maxz = Math.min(dim[ 2 ], iaz + ng + 2)\n\n for (var ix = minx; ix < maxx; ix++) {\n var dx = gridx[ ix ] - ax\n var xoffset = dim[ 1 ] * dim[ 2 ] * ix\n\n for (var iy = miny; iy < maxy; iy++) {\n var dy = gridy[ iy ] - ay\n var dxy2 = dx * dx + dy * dy\n var xyoffset = xoffset + dim[ 2 ] * iy\n\n for (var iz = minz; iz < maxz; iz++) {\n var dz = gridz[ iz ] - az\n var d2 = dxy2 + dz * dz\n\n if (d2 < ar2) {\n var idx = iz + xyoffset\n\n if (grid[idx] < 0.0) {\n // Unvisited, make positive\n grid[ idx ] = -grid[ idx ]\n }\n // Project on to the surface of the sphere\n // sp is the projected point ( dx, dy, dz ) * ( ra / d )\n var d = Math.sqrt(d2)\n var ap = ar / d\n var spx = dx * ap\n var spy = dy * ap\n var spz = dz * ap\n\n spx += ax\n spy += ay\n spz += az\n\n if (obscured(spx, spy, spz, i, -1) === -1) {\n var dd = ar - d\n if (dd < grid[ idx ]) {\n grid[ idx ] = dd\n if (setAtomID) atomIndex[ idx ] = i\n }\n }\n }\n }\n }\n }\n }\n }\n\n function projectTorii () {\n for (var i = 0; i < nAtoms; i++) {\n hash.withinRadii(x[ i ], y[ i ], z[ i ], r[ i ], neighbours)\n var ia = 0\n var ni = neighbours[ ia ]\n while (ni >= 0) {\n if (i < ni) {\n projectTorus(i, ni)\n }\n ni = neighbours[ ++ia ]\n }\n }\n }\n\n function projectTorus (a: number, b: number) {\n var r1 = r[ a ]\n var r2 = r[ b ]\n var dx = atob[ 0 ] = x[ b ] - x[ a ]\n var dy = atob[ 1 ] = y[ b ] - y[ a ]\n var dz = atob[ 2 ] = z[ b ] - z[ a ]\n var d2 = dx * dx + dy * dy + dz * dz\n\n // This check now redundant as already done in AVHash.withinRadii\n // if( d2 > (( r1 + r2 ) * ( r1 + r2 )) ){ return; }\n\n var d = Math.sqrt(d2)\n\n // Find angle between a->b vector and the circle\n // of their intersection by cosine rule\n var cosA = (r1 * r1 + d * d - r2 * r2) / (2.0 * r1 * d)\n\n // distance along a->b at intersection\n var dmp = r1 * cosA\n\n v3normalize(atob, atob)\n\n // Create normal to line\n normalToLine(n1 as any, atob)\n v3normalize(n1, n1)\n\n // Cross together for second normal vector\n v3cross(n2, atob, n1)\n v3normalize(n2, n2)\n\n // r is radius of circle of intersection\n var rInt = Math.sqrt(r1 * r1 - dmp * dmp)\n\n v3multiplyScalar(n1, n1, rInt)\n v3multiplyScalar(n2, n2, rInt)\n v3multiplyScalar(atob, atob, dmp)\n\n mid[ 0 ] = atob[ 0 ] + x[ a ]\n mid[ 1 ] = atob[ 1 ] + y[ a ]\n mid[ 2 ] = atob[ 2 ] + z[ a ]\n\n lastClip = -1\n\n var ng = ngTorus\n\n for (var i = 0; i < probePositions; i++) {\n var cost = cosTable[ i ]\n var sint = sinTable[ i ]\n\n var px = mid[ 0 ] + cost * n1[ 0 ] + sint * n2[ 0 ]\n var py = mid[ 1 ] + cost * n1[ 1 ] + sint * n2[ 1 ]\n var pz = mid[ 2 ] + cost * n1[ 2 ] + sint * n2[ 2 ]\n\n if (obscured(px, py, pz, a, b) === -1) {\n // As above, iterate over our grid...\n // px, py, pz in grid coords\n var iax = Math.floor(scaleFactor * (px - min[ 0 ]))\n var iay = Math.floor(scaleFactor * (py - min[ 1 ]))\n var iaz = Math.floor(scaleFactor * (pz - min[ 2 ]))\n\n var minx = Math.max(0, iax - ng)\n var miny = Math.max(0, iay - ng)\n var minz = Math.max(0, iaz - ng)\n\n var maxx = Math.min(dim[ 0 ], iax + ng + 2)\n var maxy = Math.min(dim[ 1 ], iay + ng + 2)\n var maxz = Math.min(dim[ 2 ], iaz + ng + 2)\n\n for (var ix = minx; ix < maxx; ix++) {\n dx = px - gridx[ ix ]\n var xoffset = dim[ 1 ] * dim[ 2 ] * ix\n\n for (var iy = miny; iy < maxy; iy++) {\n dy = py - gridy[ iy ]\n var dxy2 = dx * dx + dy * dy\n var xyoffset = xoffset + dim[ 2 ] * iy\n\n for (var iz = minz; iz < maxz; iz++) {\n dz = pz - gridz[ iz ]\n d2 = dxy2 + dz * dz\n var idx = iz + xyoffset\n var current = grid[ idx ]\n\n if (current > 0.0 && d2 < (current * current)) {\n grid[ idx ] = Math.sqrt(d2)\n if (setAtomID) {\n // Is this grid point closer to a or b?\n // Take dot product of atob and gridpoint->p (dx, dy, dz)\n const dp = dx * atob[ 0 ] + dy * atob [ 1 ] + dz * atob[ 2 ]\n atomIndex[ idx ] = dp < 0.0 ? b : a\n }\n }\n }\n }\n }\n }\n }\n }\n\n function normalToLine (out: Int32Array, p: Float32Array) {\n out[ 0 ] = out[ 1 ] = out[ 2 ] = 1.0\n if (p[ 0 ] !== 0) {\n out[ 0 ] = (p[ 1 ] + p[ 2 ]) / -p[ 0 ]\n } else if (p[ 1 ] !== 0) {\n out[ 1 ] = (p[ 0 ] + p[ 2 ]) / -p[ 1 ]\n } else if (p[ 2 ] !== 0) {\n out[ 2 ] = (p[ 0 ] + p[ 1 ]) / -p[ 2 ]\n }\n return out\n }\n\n function fixNegatives () {\n for (var i = 0; i < grid.length; i++) {\n if (grid[ i ] < 0) grid[ i ] = 0\n }\n }\n\n function fixAtomIDs () {\n for (var i = 0; i < atomIndex.length; i++) {\n atomIndex[ i ] = indexList[ atomIndex[ i ] ]\n }\n }\n\n function getVolume (probeRadius: number, scaleFactor: number, setAtomID: boolean) {\n // Basic steps are:\n // 1) Initialize\n // 2) Project points\n // 3) Project torii\n\n console.time('AVSurface.getVolume')\n\n console.time('AVSurface.init')\n init(probeRadius, scaleFactor, setAtomID)\n console.timeEnd('AVSurface.init')\n\n console.time('AVSurface.projectPoints')\n projectPoints()\n console.timeEnd('AVSurface.projectPoints')\n\n console.time('AVSurface.projectTorii')\n projectTorii()\n console.timeEnd('AVSurface.projectTorii')\n fixNegatives()\n fixAtomIDs()\n\n console.timeEnd('AVSurface.getVolume')\n }\n\n this.getSurface = function (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean, smooth: number, contour: boolean) {\n // type and cutoff left in for compatibility with EDTSurface.getSurface\n // function signature\n\n getVolume(probeRadius, scaleFactor, setAtomID)\n\n var volsurf = new (VolumeSurface as any)(\n grid, dim[ 2 ], dim[ 1 ], dim[ 0 ], atomIndex\n ) as VolumeSurface\n\n return volsurf.getSurface!(probeRadius, false, undefined, matrix, contour)\n }\n}\nObject.assign(AVSurface, {__deps: [\n getSurfaceGrid, VolumeSurface, uniformArray, computeBoundingBox,\n v3multiplyScalar, v3cross, v3normalize,\n makeAVHash,\n defaults\n]})\n\nexport { AVSurface, makeAVHash }\n","/**\n * @file Molecular Surface\n * @author Alexander Rose \n * @private\n */\n\nimport { WorkerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Worker from '../worker/worker'\nimport EDTSurface from './edt-surface'\nimport { AVSurface } from './av-surface'\nimport Surface, { SurfaceData } from './surface'\nimport { Structure } from '../ngl';\nimport { AtomData, RadiusParams } from '../structure/structure-data';\n\nWorkerRegistry.add('molsurf', function func (e: any, callback: (data: any, buffers: any[])=> void) {\n const a = e.data.args\n const p = e.data.params\n if (a && p) {\n const SurfClass = (p.type === 'av') ? AVSurface : EDTSurface\n const surf = new (SurfClass as any)(a.coordList, a.radiusList, a.indexList) as AVSurface|EDTSurface\n const sd = surf.getSurface(\n p.type, p.probeRadius, p.scaleFactor, p.cutoff, true, p.smooth, p.contour\n ) as SurfaceData\n const transferList = [ sd.position.buffer, sd.index!.buffer ]\n if (sd.normal) transferList.push(sd.normal.buffer)\n if (sd.atomindex) transferList.push(sd.atomindex.buffer)\n const data = {\n sd: sd,\n p: p\n }\n callback(data, transferList)\n }\n}, [ EDTSurface, AVSurface ])\n\n/**\n * Molecular surface parameter object.\n * @typedef {Object} MolecularSurfaceParameters - stage parameters\n * @property {String} type - \"av\" or \"edt\"\n * @property {Number} probeRadius - probe radius\n * @property {Number} scaleFactor - higher for better quality\n * @property {Integer} smooth - number of smoothing cycles to apply\n * @property {String} name - name for created surface\n */\nexport interface MolecularSurfaceParameters {\n type: 'av'|'edt'\n probeRadius: number\n scaleFactor: number\n smooth: number\n name: string\n cutoff: number\n contour: boolean,\n radiusParams: RadiusParams\n}\n/**\n * Create Molecular surfaces\n */\nclass MolecularSurface {\n structure: Structure\n worker: Worker|undefined\n\n constructor (structure: Structure) {\n this.structure = structure\n }\n\n _getAtomData (params: Partial): AtomData {\n return this.structure.getAtomData({\n what: { position: true, radius: true, index: true },\n radiusParams: defaults(params.radiusParams, {\n type: 'vdw', scale: 1.0\n })\n })\n }\n\n _makeSurface (sd: SurfaceData, p: Partial) {\n var surface = new Surface(p.name!, '', sd)\n\n surface.info.type = p.type\n surface.info.probeRadius = p.probeRadius\n surface.info.scaleFactor = p.scaleFactor\n surface.info.smooth = p.smooth\n surface.info.cutoff = p.cutoff\n\n return surface\n }\n\n /**\n * Get molecular surface\n * @param {MolecularSurfaceParameters} params - parameters for surface creation\n * @return {Surface} the surface\n */\n getSurface (params: Partial) {\n const p = params || {}\n\n const atomData = this._getAtomData(params)\n const coordList = atomData.position\n const radiusList = atomData.radius\n const indexList = atomData.index\n\n const SurfClass = (p.type === 'av') ? AVSurface : EDTSurface\n const surf = new (SurfClass as any)(coordList, radiusList, indexList) as AVSurface|EDTSurface\n const sd = surf.getSurface(\n p.type!, p.probeRadius!, p.scaleFactor!, p.cutoff!, true, p.smooth!, p.contour!\n )\n\n return this._makeSurface(sd, p)\n }\n\n /**\n * Get molecular surface asynchronous\n * @param {MolecularSurfaceParameters} params - parameters for surface creation\n * @param {function(surface: Surface)} callback - function to be called after surface is created\n * @return {undefined}\n */\n getSurfaceWorker (params: MolecularSurfaceParameters, callback: (s: Surface) => void) {\n const p = Object.assign({}, params)\n\n if (window.hasOwnProperty('Worker')) {\n if (this.worker === undefined) {\n this.worker = new Worker('molsurf')\n }\n\n const atomData = this._getAtomData(params)\n const coordList = atomData.position\n const radiusList = atomData.radius\n const indexList = atomData.index\n\n const msg = {\n args: {\n coordList: coordList,\n radiusList: radiusList,\n indexList: indexList\n },\n params: p\n }\n\n const transferList = [\n coordList!.buffer, radiusList!.buffer, indexList!.buffer\n ]\n\n this.worker.post(msg, transferList,\n\n (e: any) => {\n callback(this._makeSurface(e.data.sd, p))\n },\n\n (e: string) => {\n console.warn(\n 'MolecularSurface.getSurfaceWorker error - trying without worker', e\n )\n this.worker!.terminate()\n this.worker = undefined\n const surface = this.getSurface(p)\n callback(surface)\n }\n\n )\n } else {\n const surface = this.getSurface(p)\n callback(surface)\n }\n }\n\n /**\n * Cleanup\n * @return {undefined}\n */\n dispose () {\n if (this.worker) this.worker.terminate()\n }\n}\n\nexport default MolecularSurface\n","/**\n * @file Molecular Surface Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport MolecularSurface, { MolecularSurfaceParameters } from '../surface/molecular-surface'\nimport SurfaceBuffer from '../buffer/surface-buffer'\nimport ContourBuffer from '../buffer/contour-buffer'\nimport DoubleSidedBuffer from '../buffer/doublesided-buffer'\nimport Selection from '../selection/selection'\nimport Viewer from '../viewer/viewer';\n// @ts-ignore: unused import Volume required for declaration only\nimport { Structure, Vector3, Volume } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport { SurfaceDataFields } from './surface-representation';\nimport Surface, {SurfaceData} from '../surface/surface';\n\nexport interface MolecularSurfaceRepresentationParameters extends StructureRepresentationParameters {\n surfaceType: 'vws'|'sas'|'ms'|'ses'|'av'\n probeRadius: number\n smooth: number\n scaleFactor: number\n cutoff: number\n contour: boolean\n background: boolean\n opaqueBack: boolean\n filterSele: string\n colorVolume: any\n useWorker: boolean\n}\n\nexport interface MolecularSurfaceInfo {\n molsurf?: MolecularSurface\n sele?: string\n surface?: Surface\n}\n\n/**\n * Molecular Surface Representation\n */\nclass MolecularSurfaceRepresentation extends StructureRepresentation {\n protected surfaceType: 'vws'|'sas'|'ms'|'ses'|'av'\n protected probeRadius: number\n protected smooth: number\n protected scaleFactor: number\n protected cutoff: number\n protected contour: boolean\n protected background: boolean\n protected opaqueBack: boolean\n protected filterSele: string\n protected colorVolume: any\n protected useWorker: boolean\n\n protected __infoList: MolecularSurfaceInfo[]\n protected __forceNewMolsurf: boolean\n protected __sele: string\n protected __surfaceParams: string\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'surface'\n\n this.parameters = Object.assign({\n\n surfaceType: {\n type: 'select',\n rebuild: true,\n options: {\n 'vws': 'vws',\n 'sas': 'sas',\n 'ms': 'ms',\n 'ses': 'ses',\n 'av': 'av'\n }\n },\n probeRadius: {\n type: 'number',\n precision: 1,\n max: 20,\n min: 0,\n rebuild: true\n },\n smooth: {\n type: 'integer',\n precision: 1,\n max: 10,\n min: 0,\n rebuild: true\n },\n scaleFactor: {\n type: 'number',\n precision: 1,\n max: 5,\n min: 0,\n rebuild: true\n },\n cutoff: {\n type: 'number',\n precision: 2,\n max: 50,\n min: 0,\n rebuild: true\n },\n contour: {\n type: 'boolean', rebuild: true\n },\n background: {\n type: 'boolean', rebuild: true // FIXME\n },\n opaqueBack: {\n type: 'boolean', buffer: true\n },\n filterSele: {\n type: 'text', rebuild: true\n },\n colorVolume: {\n type: 'hidden'\n },\n useWorker: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n\n radius: null,\n scale: null\n\n })\n\n this.__infoList = []\n\n // TODO find a more direct way\n this.structure.signals.refreshed.add(() => {\n this.__forceNewMolsurf = true\n })\n\n this.toBePrepared = true\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'uniform')\n p.colorValue = defaults(p.colorValue, 0xDDDDDD)\n p.disablePicking = defaults(p.disablePicking, true)\n\n this.surfaceType = defaults(p.surfaceType, 'ms')\n this.probeRadius = defaults(p.probeRadius, 1.4)\n this.smooth = defaults(p.smooth, 2)\n this.scaleFactor = defaults(p.scaleFactor, 2.0)\n this.cutoff = defaults(p.cutoff, 0.0)\n this.contour = defaults(p.contour, false)\n this.background = defaults(p.background, false)\n this.opaqueBack = defaults(p.opaqueBack, true)\n this.filterSele = defaults(p.filterSele, '')\n this.colorVolume = defaults(p.colorVolume, undefined)\n this.useWorker = defaults(p.useWorker, true)\n\n super.init(params)\n }\n\n prepareData (sview: StructureView, i: number, callback: (i: number) => void) {\n let info: MolecularSurfaceInfo = this.__infoList[ i ]\n if (!info) {\n info = {}\n this.__infoList[ i ] = info\n }\n\n if (!info.molsurf || info.sele !== sview.selection.string) {\n if (this.filterSele) {\n const sviewFilter = sview.structure.getView(new Selection(this.filterSele))\n const bbSize = sviewFilter.boundingBox.getSize(new Vector3())\n const maxDim = Math.max(bbSize.x, bbSize.y, bbSize.z)\n const asWithin = sview.getAtomSetWithinPoint(sviewFilter.center, (maxDim / 2) + 6.0)\n sview = sview.getView(\n new Selection(sview.getAtomSetWithinSelection(asWithin, 3).toSeleString())\n )\n if (sview.atomCount === 0) {\n callback(i)\n return\n }\n }\n\n info.sele = sview.selection.string\n info.molsurf = new MolecularSurface(sview)\n\n const p = this.getSurfaceParams()\n const onSurfaceFinish = (surface: Surface) => {\n info.surface = surface\n callback(i)\n }\n\n if (this.useWorker) {\n info.molsurf.getSurfaceWorker(p as MolecularSurfaceParameters, onSurfaceFinish)\n } else {\n onSurfaceFinish(info.molsurf.getSurface(p as {name: string, type: 'av'|'edt' } & MolecularSurfaceRepresentationParameters))\n }\n } else {\n callback(i)\n }\n }\n\n prepare (callback: () => void) {\n if (this.__forceNewMolsurf || this.__sele !== this.selection.string ||\n this.__surfaceParams !== JSON.stringify(this.getSurfaceParams())) {\n this.__infoList.forEach((info: MolecularSurfaceInfo) => {\n if (info && info.molsurf) {\n info.molsurf.dispose()\n }\n })\n this.__infoList.length = 0\n }\n\n if (this.structureView.atomCount === 0) {\n callback()\n return\n }\n\n const after = () => {\n this.__sele = this.selection.string\n this.__surfaceParams = JSON.stringify(this.getSurfaceParams())\n this.__forceNewMolsurf = false\n callback()\n }\n\n const name = this.assembly === 'default' ? this.defaultAssembly : this.assembly\n const assembly = this.structure.biomolDict[ name ]\n\n if (assembly) {\n assembly.partList.forEach((part, i) => {\n const sview = part.getView(this.structureView)\n this.prepareData(sview as StructureView, i, (_i) => {\n if (_i === assembly.partList.length - 1) after()\n })\n })\n } else {\n this.prepareData(this.structureView, 0, after)\n }\n }\n\n createData (sview: StructureView, i: number) {\n const info = this.__infoList[ i ]\n const surface = info.surface\n\n if (!surface) {\n // Surface creation bailed (no surface generated for this sview)\n return\n }\n\n const surfaceData = {\n position: surface!.getPosition(),\n color: surface!.getColor(this.getColorParams()),\n index: surface!.getFilteredIndex(this.filterSele, sview)\n }\n\n const bufferList = []\n\n if (surface.contour) {\n const contourBuffer = new ContourBuffer(\n surfaceData,\n this.getBufferParams({\n wireframe: false\n })\n )\n\n bufferList.push(contourBuffer)\n } else {\n Object.assign(surfaceData, {\n normal: surface.getNormal(),\n picking: surface.getPicking(sview.getStructure())\n })\n\n const surfaceBuffer = new SurfaceBuffer(\n surfaceData,\n this.getBufferParams({\n background: this.background,\n opaqueBack: this.opaqueBack,\n dullInterior: false\n })\n )\n\n if (this.getBufferParams().side == 'double') {\n const doubleSidedBuffer = new DoubleSidedBuffer(surfaceBuffer)\n bufferList.push(doubleSidedBuffer)\n }\n else {\n bufferList.push(surfaceBuffer)\n }\n }\n\n return { bufferList, info } as StructureRepresentationData\n }\n\n updateData (what: SurfaceDataFields, data: StructureRepresentationData) {\n const surfaceData: Partial = {}\n\n if (what.position || what.radius) {\n this.__forceNewMolsurf = true\n this.build()\n return\n }\n\n if (what.color) {\n surfaceData.color = data.info.surface.getColor(this.getColorParams())\n }\n\n if (what.index) {\n surfaceData.index = data.info.surface.getFilteredIndex(this.filterSele, data.sview)\n }\n\n data.bufferList[ 0 ].setAttributes(surfaceData)\n }\n\n setParameters (params: Partial, what: Partial = {}, rebuild?: boolean) {\n if (params && params.filterSele) {\n what.index = true\n }\n\n if (params && params.colorVolume !== undefined) {\n what.color = true\n }\n\n // forbid setting wireframe to true when contour is true\n if (params && params.wireframe && (\n params.contour || (params.contour === undefined && this.contour)\n )\n ) {\n params.wireframe = false\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n\n getSurfaceParams (params: Partial = {}) {\n const p = Object.assign({\n type: this.surfaceType as string,\n probeRadius: this.probeRadius as number,\n scaleFactor: this.scaleFactor as number,\n smooth: this.smooth && !this.contour,\n cutoff: this.cutoff as number,\n contour: this.contour as boolean,\n useWorker: this.useWorker as boolean,\n radiusParams: this.getRadiusParams()\n }, params)\n\n return p\n }\n\n getColorParams () {\n const p = super.getColorParams()\n\n p.volume = this.colorVolume\n\n return p\n }\n\n getAtomRadius () {\n return 0\n }\n\n clear () {\n super.clear()\n }\n\n dispose () {\n this.__infoList.forEach((info: MolecularSurfaceInfo) => {\n if (info && info.molsurf) {\n info.molsurf.dispose()\n }\n })\n this.__infoList.length = 0\n\n super.dispose()\n }\n}\n\nRepresentationRegistry.add('surface', MolecularSurfaceRepresentation)\n\nexport default MolecularSurfaceRepresentation\n","/**\n * @file Point Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport PointBuffer from '../buffer/point-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { AtomDataFields } from '../structure/structure-data';\n\nexport interface PointRepresentationParameters extends StructureRepresentationParameters {\n pointSize: number\n sizeAttenuation: boolean\n sortParticles: boolean\n useTexture: boolean\n alphaTest: number\n forceTransparent: boolean\n edgeBleach: number\n}\n\n/**\n * Point Representation\n */\nclass PointRepresentation extends StructureRepresentation {\n protected pointSize: number\n protected sizeAttenuation: boolean\n protected sortParticles: boolean\n protected useTexture: boolean\n protected alphaTest: number\n protected forceTransparent: boolean\n protected edgeBleach: number\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'point'\n\n this.parameters = Object.assign({\n\n pointSize: {\n type: 'number', precision: 1, max: 100, min: 0, buffer: true\n },\n sizeAttenuation: {\n type: 'boolean', buffer: true\n },\n sortParticles: {\n type: 'boolean', rebuild: true\n },\n useTexture: {\n type: 'boolean', buffer: true\n },\n alphaTest: {\n type: 'range', step: 0.001, max: 1, min: 0, buffer: true\n },\n forceTransparent: {\n type: 'boolean', buffer: true\n },\n edgeBleach: {\n type: 'range', step: 0.001, max: 1, min: 0, buffer: true\n }\n\n }, this.parameters, {\n\n flatShaded: null,\n wireframe: null,\n linewidth: null,\n side: null,\n\n roughness: null,\n metalness: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n\n this.pointSize = defaults(p.pointSize, 1)\n this.sizeAttenuation = defaults(p.sizeAttenuation, true)\n this.sortParticles = defaults(p.sortParticles, false)\n this.useTexture = defaults(p.useTexture, false)\n this.alphaTest = defaults(p.alphaTest, 0.5)\n this.forceTransparent = defaults(p.forceTransparent, false)\n this.edgeBleach = defaults(p.edgeBleach, 0.0)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n var what = { position: true, color: true, picking: true }\n var atomData = sview.getAtomData(this.getAtomParams(what))\n\n var pointBuffer = new PointBuffer(\n atomData,\n this.getBufferParams({\n pointSize: this.pointSize,\n sizeAttenuation: this.sizeAttenuation,\n sortParticles: this.sortParticles,\n useTexture: this.useTexture,\n alphaTest: this.alphaTest,\n forceTransparent: this.forceTransparent,\n edgeBleach: this.edgeBleach\n })\n )\n\n return {\n bufferList: [ pointBuffer ]\n }\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n var atomData = data.sview!.getAtomData(this.getAtomParams(what))\n var pointData = {}\n\n if (!what || what.position) {\n Object.assign(pointData, {position: atomData.position})\n }\n\n if (!what || what.color) {\n Object.assign(pointData, {color: atomData.color})\n }\n\n data.bufferList[ 0 ].setAttributes(pointData)\n }\n\n getAtomRadius () {\n return 0.1\n }\n}\n\nRepresentationRegistry.add('point', PointRepresentation)\n\nexport default PointRepresentation\n","/**\n * @file Ribbon Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport '../shader/Ribbon.vert'\n\nimport { getUintArray } from '../utils'\nimport { serialArray } from '../math/array-utils'\nimport MeshBuffer from './mesh-buffer'\nimport { BufferParameters, BufferData } from './buffer'\nimport {Log} from \"../globals\";\n\nconst quadIndices = new Uint16Array([\n 0, 1, 2,\n 1, 3, 2\n])\n\nexport interface RibbonBufferData extends BufferData {\n normal: Float32Array\n dir: Float32Array\n size: Float32Array\n}\n\nfunction getSize(data: RibbonBufferData){\n const n = (data.position!.length / 3) - 1\n const n4 = n * 4\n const x = n4 * 3\n return x\n}\n\n/**\n * Ribbon buffer. Draws a thin ribbon.\n */\nclass RibbonBuffer extends MeshBuffer {\n vertexShader = 'Ribbon.vert'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.normal - normals\n * @param {Float32Array} data.dir - binormals\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.size - sizes\n * @param {Picker} data.picking - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: RibbonBufferData, params: Partial = {}) {\n super({\n position: new Float32Array(getSize(data)),\n color: new Float32Array(getSize(data)),\n index: getUintArray(getSize(data), getSize(data) / 3),\n normal: new Float32Array(getSize(data)),\n picking: data.picking\n }, params)\n\n const n = (data.position!.length / 3) - 1\n const n4 = n * 4\n const x = n4 * 3\n\n this.addAttributes({\n 'dir': { type: 'v3', value: new Float32Array(x) }\n })\n this.addAttributes({\n 'size': { type: 'f', value: new Float32Array(n4) }\n })\n\n data.primitiveId = serialArray(n)\n this.setAttributes(data)\n\n this.makeIndex()\n }\n\n setAttributes (data: Partial = {}) {\n const n4 = this.size\n const n = n4 / 4\n\n const attributes = this.geometry.attributes as any // TODO\n\n let position, normal, size, dir, color, primitiveId\n let aPosition, aNormal, aSize, aDir, aColor, aPrimitiveId\n\n if (data.position) {\n position = data.position\n aPosition = attributes.position.array\n attributes.position.needsUpdate = true\n }\n\n if (data.normal) {\n normal = data.normal\n aNormal = attributes.normal.array\n attributes.normal.needsUpdate = true\n }\n\n if (data.size) {\n size = data.size\n aSize = attributes.size.array\n attributes.size.needsUpdate = true\n }\n\n if (data.dir) {\n dir = data.dir\n aDir = attributes.dir.array\n attributes.dir.needsUpdate = true\n }\n\n if (data.color) {\n color = data.color\n aColor = attributes.color.array\n attributes.color.needsUpdate = true\n }\n\n if (data.primitiveId) {\n primitiveId = data.primitiveId\n aPrimitiveId = attributes.primitiveId.array\n attributes.primitiveId.needsUpdate = true\n }\n\n let v, i, k, p, l, v3\n let currSize\n let prevSize = size ? size[ 0 ] : null\n\n for (v = 0; v < n; ++v) {\n v3 = v * 3\n k = v * 3 * 4\n l = v * 4\n\n if (position) {\n aPosition[ k ] = aPosition[ k + 3 ] = position[ v3 ]\n aPosition[ k + 1 ] = aPosition[ k + 4 ] = position[ v3 + 1 ]\n aPosition[ k + 2 ] = aPosition[ k + 5 ] = position[ v3 + 2 ]\n\n aPosition[ k + 6 ] = aPosition[ k + 9 ] = position[ v3 + 3 ]\n aPosition[ k + 7 ] = aPosition[ k + 10 ] = position[ v3 + 4 ]\n aPosition[ k + 8 ] = aPosition[ k + 11 ] = position[ v3 + 5 ]\n }\n\n if (normal) {\n aNormal[ k ] = aNormal[ k + 3 ] = -normal[ v3 ]\n aNormal[ k + 1 ] = aNormal[ k + 4 ] = -normal[ v3 + 1 ]\n aNormal[ k + 2 ] = aNormal[ k + 5 ] = -normal[ v3 + 2 ]\n\n aNormal[ k + 6 ] = aNormal[ k + 9 ] = -normal[ v3 + 3 ]\n aNormal[ k + 7 ] = aNormal[ k + 10 ] = -normal[ v3 + 4 ]\n aNormal[ k + 8 ] = aNormal[ k + 11 ] = -normal[ v3 + 5 ]\n }\n\n for (i = 0; i < 4; ++i) {\n p = k + 3 * i\n\n if (color) {\n aColor[ p ] = color[ v3 ]\n aColor[ p + 1 ] = color[ v3 + 1 ]\n aColor[ p + 2 ] = color[ v3 + 2 ]\n }\n\n if (primitiveId) {\n aPrimitiveId[ l + i ] = primitiveId[ v ]\n }\n }\n\n if (size) {\n currSize = size[ v ]\n\n if (prevSize !== size[ v ]) {\n aSize[ l ] = prevSize\n aSize[ l + 1 ] = prevSize\n aSize[ l + 2 ] = currSize\n aSize[ l + 3 ] = currSize\n } else {\n aSize[ l ] = currSize\n aSize[ l + 1 ] = currSize\n aSize[ l + 2 ] = currSize\n aSize[ l + 3 ] = currSize\n }\n\n prevSize = currSize\n }\n\n if (dir) {\n aDir[ k ] = dir[ v3 ]\n aDir[ k + 1 ] = dir[ v3 + 1 ]\n aDir[ k + 2 ] = dir[ v3 + 2 ]\n\n aDir[ k + 3 ] = -dir[ v3 ]\n aDir[ k + 4 ] = -dir[ v3 + 1 ]\n aDir[ k + 5 ] = -dir[ v3 + 2 ]\n\n aDir[ k + 6 ] = dir[ v3 + 3 ]\n aDir[ k + 7 ] = dir[ v3 + 4 ]\n aDir[ k + 8 ] = dir[ v3 + 5 ]\n\n aDir[ k + 9 ] = -dir[ v3 + 3 ]\n aDir[ k + 10 ] = -dir[ v3 + 4 ]\n aDir[ k + 11 ] = -dir[ v3 + 5 ]\n }\n }\n }\n\n makeIndex () {\n const index = this.geometry.getIndex()\n if (!index) { Log.error('Index is null'); return; }\n const meshIndex = index.array as Uint32Array|Uint16Array\n const n = meshIndex.length / 4 / 3\n\n for (let v = 0; v < n; ++v) {\n const ix = v * 6\n const it = v * 4\n\n meshIndex.set(quadIndices, ix)\n for (let s = 0; s < 6; ++s) {\n meshIndex[ ix + s ] += it\n }\n }\n }\n}\n\nexport default RibbonBuffer\n","/**\n * @file Ribbon Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Spline, { SplineParameters } from '../geometry/spline'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport RibbonBuffer from '../buffer/ribbon-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport StructureView from '../structure/structure-view';\nimport Polymer from '../proxy/polymer';\n\nexport interface RibbonRepresentationParameters extends StructureRepresentationParameters {\n subdiv: number\n tension: number\n smoothSheet: boolean\n}\n\n/**\n * Ribbon Representation\n */\nclass RibbonRepresentation extends StructureRepresentation {\n protected subdiv: number\n protected tension: number\n protected smoothSheet: boolean\n \n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'ribbon'\n\n this.parameters = Object.assign({\n\n subdiv: {\n type: 'integer', max: 50, min: 1, rebuild: true\n },\n tension: {\n type: 'number', precision: 1, max: 1.0, min: 0.1\n },\n smoothSheet: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n\n side: null,\n wireframe: null,\n linewidth: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'chainname')\n p.colorScale = defaults(p.colorScale, 'RdYlBu')\n p.radiusType = defaults(p.radiusType, 'sstruc')\n p.radiusScale = defaults(p.radiusScale, 4.0)\n\n if (p.quality === 'low') {\n this.subdiv = 3\n } else if (p.quality === 'medium') {\n this.subdiv = 6\n } else if (p.quality === 'high') {\n this.subdiv = 12\n } else {\n this.subdiv = defaults(p.subdiv, 6)\n }\n\n this.tension = defaults(p.tension, NaN)\n this.smoothSheet = defaults(p.smoothSheet, false)\n\n super.init(p)\n }\n\n getSplineParams (params?: Partial) {\n return Object.assign({\n subdiv: this.subdiv,\n tension: this.tension,\n directional: true,\n smoothSheet: this.smoothSheet\n }, params)\n }\n\n getAtomRadius (atom: AtomProxy) {\n return atom.isTrace() ? super.getAtomRadius(atom) : 0\n }\n\n createData (sview: StructureView) {\n var bufferList: RibbonBuffer[] = []\n var polymerList: Polymer[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4) return\n polymerList.push(polymer)\n\n var spline = new Spline(polymer, this.getSplineParams())\n var subPos = spline.getSubdividedPosition()\n var subOri = spline.getSubdividedOrientation()\n var subCol = spline.getSubdividedColor(this.getColorParams())\n var subPick = spline.getSubdividedPicking()\n var subSize = spline.getSubdividedSize(this.getRadiusParams())\n\n bufferList.push(\n new RibbonBuffer(\n ({\n position: subPos.position,\n normal: subOri.binormal,\n dir: subOri.normal,\n color: subCol.color,\n size: subSize.size,\n picking: subPick.picking\n }),\n this.getBufferParams()\n )\n )\n }, sview.getSelection())\n\n return {\n bufferList: bufferList,\n polymerList: polymerList\n }\n }\n\n updateData (what: {position?: boolean, radius?: boolean, scale?: boolean, color?: boolean}, data: {polymerList: Polymer[], bufferList: RibbonBuffer[]}) {\n what = what || {}\n\n var i = 0\n var n = data.polymerList.length\n\n for (i = 0; i < n; ++i) {\n var bufferData = {}\n var spline = new Spline(data.polymerList[ i ], this.getSplineParams())\n\n if (what.position) {\n var subPos = spline.getSubdividedPosition()\n var subOri = spline.getSubdividedOrientation()\n Object.assign(bufferData, {\n position: subPos.position,\n normal: subOri.binormal,\n dir: subOri.normal\n })\n }\n\n if (what.radius || what.scale) {\n var subSize = spline.getSubdividedSize(this.getRadiusParams())\n Object.assign(bufferData, {size: subSize.size})\n }\n\n if (what.color) {\n var subCol = spline.getSubdividedColor(this.getColorParams())\n Object.assign(bufferData, {color: subCol.color})\n }\n\n data.bufferList[ i ].setAttributes(bufferData)\n }\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n if (params && params.tension) {\n Object.assign(what, {position: true})\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('ribbon', RibbonRepresentation)\n\nexport default RibbonRepresentation\n","/**\n * @file Rocket Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { AtomPicker } from '../utils/picker'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport Helixbundle, { Axis } from '../geometry/helixbundle'\nimport CylinderBuffer from '../buffer/cylinder-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport CylinderImpostorBuffer from '../buffer/cylinderimpostor-buffer';\n\nexport interface RocketRepresentationParameters extends StructureRepresentationParameters {\n localAngle: number\n centerDist: number\n ssBorder: boolean\n radialSegments: number\n openEnded: boolean\n disableImpostor: boolean\n}\n\nexport interface AxisData {\n begin: Float32Array\n end: Float32Array\n size: Float32Array\n color: Float32Array\n picking: AtomPicker\n}\n\n/**\n * Rocket Representation\n */\nclass RocketRepresentation extends StructureRepresentation {\n\n protected localAngle: number\n protected centerDist: number\n protected ssBorder: boolean\n protected radialSegments: number\n protected openEnded: boolean\n protected disableImpostor: boolean\n // protected helixbundleList: Helixbundle[]\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'rocket'\n\n this.parameters = Object.assign({\n\n localAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n centerDist: {\n type: 'number', precision: 1, max: 10, min: 0, rebuild: true\n },\n ssBorder: {\n type: 'boolean', rebuild: true\n },\n radialSegments: true,\n openEnded: true,\n disableImpostor: true\n\n }, this.parameters)\n\n // this.helixbundleList = []\n\n this.init(params)\n }\n\n init (params: Partial) {\n let p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'sstruc')\n p.radiusSize = defaults(p.radiusSize, 1.5)\n p.radiusScale = defaults(p.radiusScale, 1.0)\n p.openEnded = defaults(p.openEnded, false)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.localAngle = defaults(p.localAngle, 30)\n this.centerDist = defaults(p.centerDist, 2.5)\n this.ssBorder = defaults(p.ssBorder, false)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n let length = 0\n const axisList:Axis[] = []\n const helixbundleList:Helixbundle[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4 || polymer.isNucleic()) return\n\n const helixbundle = new Helixbundle(polymer)\n const axis = helixbundle.getAxis(\n this.localAngle, this.centerDist, this.ssBorder,\n this.getColorParams(), this.getRadiusParams()\n )\n\n length += axis.size.length\n axisList.push(axis)\n helixbundleList.push(helixbundle)\n }, sview.getSelection())\n\n const axisData = {\n begin: new Float32Array(length * 3),\n end: new Float32Array(length * 3),\n size: new Float32Array(length),\n color: new Float32Array(length * 3),\n picking: {}\n }\n\n let picking = new Float32Array(length)\n\n let offset = 0\n\n axisList.forEach(function (axis) {\n axisData.begin.set(axis.begin, offset * 3)\n axisData.end.set(axis.end, offset * 3)\n axisData.size.set(axis.size, offset)\n axisData.color.set(axis.color, offset * 3)\n picking.set(axis.picking.array!, offset)\n offset += axis.size.length\n })\n\n if (length) {\n axisData.picking = new AtomPicker(\n picking, sview.getStructure()\n )\n }\n\n const cylinderBuffer = new CylinderBuffer(\n {\n position1: axisData.begin,\n position2: axisData.end,\n color: axisData.color,\n color2: axisData.color,\n radius: axisData.size,\n picking: axisData.picking\n },\n this.getBufferParams({\n openEnded: this.openEnded,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n return {\n bufferList: [ cylinderBuffer as CylinderGeometryBuffer|CylinderImpostorBuffer ],\n axisList: axisList,\n helixbundleList: helixbundleList,\n axisData: axisData\n }\n }\n\n \n updateData (what: any, data: {bufferList: CylinderBuffer[], helixbundleList: Helixbundle[], axisList: Axis[], axisData: AxisData}) {\n what = what || {}\n\n if (what.position) {\n this.build()\n return\n }\n\n var cylinderData = {}\n\n if (what.color || what.radius) {\n var offset = 0\n\n data.helixbundleList.forEach((helixbundle) => {\n var axis = helixbundle.getAxis(\n this.localAngle, this.centerDist, this.ssBorder,\n this.getColorParams(), this.getRadiusParams()\n )\n if (what.color) {\n data.axisData.color.set(axis.color, offset * 3)\n }\n if (what.radius || what.scale) {\n data.axisData.size.set(axis.size, offset)\n }\n offset += axis.size.length\n })\n\n if (what.color) {\n Object.assign(cylinderData, {\n color: data.axisData.color,\n color2: data.axisData.color\n })\n }\n\n if (what.radius || what.scale) {\n Object.assign(cylinderData, {\n radius: data.axisData.size\n })\n }\n }\n\n (data.bufferList[ 0 ] as CylinderGeometryBuffer).setAttributes(cylinderData)\n }\n}\n\nRepresentationRegistry.add('rocket', RocketRepresentation)\n\nexport default RocketRepresentation\n","/**\n * @file Rope Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport CartoonRepresentation, { CartoonRepresentationParameters } from './cartoon-representation'\nimport Helixorient from '../geometry/helixorient'\nimport Spline from '../geometry/spline'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport Polymer from '../proxy/polymer';\n\n/**\n * Rope Representation\n */\nclass RopeRepresentation extends CartoonRepresentation {\n protected smooth: number\n \n constructor (structure: Structure, viewer: Viewer, params: Partial&{smooth: number}) {\n super(structure, viewer, params)\n\n this.type = 'rope'\n\n this.parameters = Object.assign({\n\n smooth: {\n type: 'integer', max: 15, min: 0, rebuild: true\n }\n\n }, this.parameters, {\n aspectRatio: null,\n smoothSheet: null\n })\n }\n\n init (params: Partial) {\n var p = params || {}\n p.aspectRatio = 1.0\n p.tension = defaults(p.tension, 0.5)\n p.radiusScale = defaults(p.radiusScale, 5.0)\n p.smoothSheet = false\n\n this.smooth = defaults(p.smooth, 2)\n\n super.init(p)\n }\n\n getSpline (polymer: Polymer) {\n var helixorient = new Helixorient(polymer)\n\n return new Spline(polymer, this.getSplineParams({\n directional: false,\n positionIterator: helixorient.getCenterIterator(this.smooth)\n }))\n }\n}\n\nRepresentationRegistry.add('rope', RopeRepresentation)\n\nexport default RopeRepresentation\n","/**\n * @file Spacefill Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { RepresentationRegistry } from '../globals'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\nimport { AtomDataFields } from '../structure/structure-data';\nimport SphereImpostorBuffer from '../buffer/sphereimpostor-buffer';\n\n/**\n * Spacefill Representation\n */\nclass SpacefillRepresentation extends StructureRepresentation {\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'spacefill'\n\n this.parameters = Object.assign({\n sphereDetail: true,\n disableImpostor: true\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n var sphereBuffer = new SphereBuffer(\n (sview.getAtomData(this.getAtomParams()) as SphereBufferData),\n (this.getBufferParams({\n sphereDetail: this.sphereDetail,\n dullInterior: true,\n disableImpostor: this.disableImpostor\n }) as SphereBufferParameters)\n )\n\n return {\n bufferList: [ sphereBuffer as SphereGeometryBuffer|SphereImpostorBuffer ]\n }\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n var atomData = data.sview!.getAtomData(this.getAtomParams(what))\n var sphereData: Partial = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {position: atomData.position})\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {color: atomData.color})\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {radius: atomData.radius})\n }\n\n data.bufferList[ 0 ].setAttributes(sphereData)\n }\n}\n\nRepresentationRegistry.add('spacefill', SpacefillRepresentation)\n\nexport default SpacefillRepresentation\n","/**\n * @file Trace Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport '../shader/Line.vert'\nimport '../shader/Line.frag'\n\nimport { Log } from '../globals'\nimport Buffer, { BufferParameters, BufferData } from './buffer'\n\nfunction getSize(data: BufferData){\n const n = data.position!.length / 3\n const n1 = n - 1\n return n1 * 3 * 2\n}\n\n/**\n * Trace buffer. Draws a series of lines.\n */\nclass TraceBuffer extends Buffer {\n isLine = true\n vertexShader = 'Line.vert'\n fragmentShader = 'Line.frag'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: BufferData, params: Partial = {}) {\n super({\n position: new Float32Array(getSize(data)),\n color: new Float32Array(getSize(data))\n }, params)\n\n this.setAttributes(data)\n }\n\n setAttributes (data: Partial) {\n let position, color\n let linePosition, lineColor\n\n const attributes = this.geometry.attributes as any // TODO\n\n if (data.position) {\n position = data.position\n linePosition = attributes.position.array\n attributes.position.needsUpdate = true\n }\n\n if (data.color) {\n color = data.color\n lineColor = attributes.color.array\n attributes.color.needsUpdate = true\n }\n\n if (!position && !color) {\n Log.warn('TraceBuffer.prototype.setAttributes no data')\n return\n }\n\n let v, v2\n const n = this.size\n const n1 = n - 1\n\n for (let i = 0; i < n1; ++i) {\n v = 3 * i\n v2 = 3 * i * 2\n\n if (position) {\n linePosition[ v2 ] = position[ v ]\n linePosition[ v2 + 1 ] = position[ v + 1 ]\n linePosition[ v2 + 2 ] = position[ v + 2 ]\n\n linePosition[ v2 + 3 ] = position[ v + 3 ]\n linePosition[ v2 + 4 ] = position[ v + 4 ]\n linePosition[ v2 + 5 ] = position[ v + 5 ]\n }\n\n if (color) {\n lineColor[ v2 ] = color[ v ]\n lineColor[ v2 + 1 ] = color[ v + 1 ]\n lineColor[ v2 + 2 ] = color[ v + 2 ]\n\n lineColor[ v2 + 3 ] = color[ v + 3 ]\n lineColor[ v2 + 4 ] = color[ v + 4 ]\n lineColor[ v2 + 5 ] = color[ v + 5 ]\n }\n }\n }\n}\n\nexport default TraceBuffer\n","/**\n * @file Trace Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Spline from '../geometry/spline'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport TraceBuffer from '../buffer/trace-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport StructureView from '../structure/structure-view';\nimport Polymer from '../proxy/polymer';\n\nexport interface TraceRepresentationParameters extends StructureRepresentationParameters {\n subdiv: number\n tension: number\n smoothSheet: boolean\n}\n/**\n * Trace Representation\n */\nclass TraceRepresentation extends StructureRepresentation {\n protected subdiv: number\n protected tension: number\n protected smoothSheet: boolean\n \n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'trace'\n\n this.parameters = Object.assign({\n\n subdiv: {\n type: 'integer', max: 50, min: 1, rebuild: true\n },\n tension: {\n type: 'number', precision: 1, max: 1.0, min: 0.1\n },\n smoothSheet: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n\n flatShaded: null,\n side: null,\n wireframe: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'chainname')\n p.colorScale = defaults(p.colorScale, 'RdYlBu')\n\n if (p.quality === 'low') {\n this.subdiv = 3\n } else if (p.quality === 'medium') {\n this.subdiv = 6\n } else if (p.quality === 'high') {\n this.subdiv = 12\n } else {\n this.subdiv = defaults(p.subdiv, 6)\n }\n\n this.tension = defaults(p.tension, NaN)\n this.smoothSheet = defaults(p.smoothSheet, false)\n\n super.init(p)\n }\n\n getSplineParams (params?: {[k:string]: any}) {\n return Object.assign({\n subdiv: this.subdiv,\n tension: this.tension,\n directional: false,\n smoothSheet: this.smoothSheet\n }, params)\n }\n\n getAtomRadius (atom: AtomProxy) {\n return atom.isTrace() ? 0.1 : 0\n }\n\n createData (sview: StructureView) {\n var bufferList: TraceBuffer[] = []\n var polymerList: Polymer[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4) return\n polymerList.push(polymer)\n\n var spline = new Spline(polymer, this.getSplineParams())\n var subPos = spline.getSubdividedPosition()\n var subCol = spline.getSubdividedColor(this.getColorParams())\n\n bufferList.push(\n new TraceBuffer(\n Object.assign({}, subPos, subCol),\n this.getBufferParams()\n )\n )\n }, sview.getSelection())\n\n return {\n bufferList: bufferList,\n polymerList: polymerList\n }\n }\n\n updateData (what: any, data: StructureRepresentationData) {\n what = what || {}\n\n var i = 0\n var n = data.polymerList!.length\n\n for (i = 0; i < n; ++i) {\n var bufferData = {}\n var spline = new Spline(data.polymerList![ i ], this.getSplineParams())\n\n if (what.position) {\n var subPos = spline.getSubdividedPosition()\n Object.assign(bufferData, { position: subPos.position })\n }\n\n if (what.color) {\n var subCol = spline.getSubdividedColor(this.getColorParams())\n Object.assign(bufferData, { color: subCol.color })\n }\n\n data.bufferList[ i ].setAttributes(bufferData)\n }\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n if (params && params.tension) {\n Object.assign(what, {position: true})\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('trace', TraceRepresentation)\n\nexport default TraceRepresentation\n","/**\n * @file Tube Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport CartoonRepresentation, {CartoonRepresentationParameters} from './cartoon-representation'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\n\n/**\n * Tube Representation\n */\nclass TubeRepresentation extends CartoonRepresentation {\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'tube'\n\n this.parameters = Object.assign(\n {}, this.parameters, { aspectRatio: null }\n )\n }\n\n init (params: Partial) {\n var p = params || {}\n p.aspectRatio = 1.0\n p.radiusScale = defaults(p.radiusScale, 2.0)\n\n if (p.quality === 'low') {\n this.radialSegments = 5\n }\n\n super.init(p)\n }\n\n getSplineParams (/* params */) {\n return super.getSplineParams({\n directional: false\n })\n }\n}\n\nRepresentationRegistry.add('tube', TubeRepresentation)\n\nexport default TubeRepresentation\n","/**\n * @file Unitcell Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport CylinderBuffer, { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport { AtomDataFields } from '../structure/structure-data';\nimport StructureView from '../structure/structure-view';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\n// @ts-ignore: unused import UnitcellPicker required for declaration only\nimport { UnitcellPicker } from '../utils/picker';\n\nexport interface UnitcellRepresentationParameters extends StructureRepresentationParameters {\n radiusSize: number\n sphereDetail: number\n radialSegments: number\n disableImpostor: boolean\n}\n\n/**\n * Unitcell Representation\n */\nclass UnitcellRepresentation extends StructureRepresentation {\n sphereBuffer: SphereBuffer\n cylinderBuffer: CylinderBuffer\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'unitcell'\n\n this.parameters = Object.assign({\n\n radiusSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n sphereDetail: true,\n radialSegments: true,\n disableImpostor: true\n\n }, this.parameters, {\n assembly: null\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n\n let defaultRadius = 0.5\n if (this.structure.unitcell) {\n defaultRadius = Math.cbrt(this.structure.unitcell.volume) / 200\n }\n\n p.radiusSize = defaults(p.radiusSize, defaultRadius)\n p.colorValue = defaults(p.colorValue, 'orange')\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n super.init(p)\n }\n\n getUnitcellData (structure: Structure) {\n return structure.unitcell!.getData(structure)\n }\n\n create () {\n const structure = this.structureView.getStructure()\n if (!structure.unitcell) return\n const unitcellData = this.getUnitcellData(structure)\n\n this.sphereBuffer = new SphereBuffer(\n unitcellData.vertex as SphereBufferData,\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters\n )\n\n this.cylinderBuffer = new CylinderBuffer(\n unitcellData.edge as CylinderBufferData,\n this.getBufferParams({\n openEnded: true,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n this.dataList.push({\n sview: this.structureView,\n bufferList: [ this.sphereBuffer as SphereGeometryBuffer, this.cylinderBuffer as CylinderGeometryBuffer ]\n })\n }\n\n createData (sview: StructureView): undefined {\n return\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n const structure = data.sview!.getStructure()\n if (!structure.unitcell) return\n const unitcellData = this.getUnitcellData(structure)\n const sphereData: Partial = {}\n const cylinderData: Partial = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {position: unitcellData.vertex.position})\n Object.assign(cylinderData, {\n position1: unitcellData.edge.position1,\n position2: unitcellData.edge.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {color: unitcellData.vertex.color})\n Object.assign(cylinderData, {\n color: unitcellData.edge.color,\n color2: unitcellData.edge.color2\n })\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {radius: unitcellData.vertex.radius})\n Object.assign(cylinderData, {radius: unitcellData.edge.radius})\n }\n\n (this.sphereBuffer as SphereGeometryBuffer).setAttributes(sphereData);\n (this.cylinderBuffer as CylinderGeometryBuffer).setAttributes(cylinderData)\n }\n}\n\nRepresentationRegistry.add('unitcell', UnitcellRepresentation)\n\nexport default UnitcellRepresentation\n","/**\n * @file Validation Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport CylinderBuffer from '../buffer/cylinder-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport CylinderImpostorBuffer from '../buffer/cylinderimpostor-buffer';\n\n/**\n * Validation representation\n */\nclass ValidationRepresentation extends StructureRepresentation {\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'validation'\n\n this.parameters = Object.assign({\n\n }, this.parameters, {\n radiusType: null,\n radiusSize: null,\n radiusScale: null\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorValue = defaults(p.colorValue, '#f0027f')\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n if (!sview.validation) return\n\n const clashData = sview.validation.getClashData({\n structure: sview,\n color: this.colorValue\n })\n\n const cylinderBuffer = new CylinderBuffer(\n clashData, this.getBufferParams({ openEnded: false })\n )\n\n return {\n bufferList: [ cylinderBuffer as CylinderGeometryBuffer|CylinderImpostorBuffer ]\n }\n }\n}\n\nRepresentationRegistry.add('validation', ValidationRepresentation)\n\nexport default ValidationRepresentation\n","/**\n * @file Cone Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3, ConeBufferGeometry } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { calculateCenterArray } from '../math/array-utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferDefaultParameters } from './buffer'\n\nconst scale = new Vector3()\nconst eye = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3(0, 1, 0)\n\nfunction getGeo (params: Partial = {}) {\n const geo = new ConeBufferGeometry(\n 1, // radius\n 1, // height\n defaults(params.radialSegments, 60), // radialSegments\n 1, // heightSegments\n defaults(params.openEnded, false) // openEnded\n )\n geo.applyMatrix4(new Matrix4().makeRotationX(-Math.PI / 2))\n\n return geo\n}\n\nexport interface ConeBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n radius: Float32Array\n}\n\nexport const ConeBufferDefaultParameters = Object.assign({\n radialSegments: 60,\n openEnded: false\n}, BufferDefaultParameters)\nexport type ConeBufferParameters = typeof ConeBufferDefaultParameters\n\n\n/**\n * Cone geometry buffer.\n *\n * @example\n * var coneBuffer = new ConeBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass ConeBuffer extends GeometryBuffer {\n updateNormals = true\n\n get defaultParameters() { return ConeBufferDefaultParameters }\n parameters: ConeBufferParameters\n\n _position: Float32Array\n _position1: Float32Array\n _position2: Float32Array\n _radius: Float32Array\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n */\n constructor (data: ConeBufferData, params: Partial = {}) {\n super({\n position: new Float32Array(data.position1.length),\n color: data.color,\n picking: data.picking\n }, params, getGeo(params))\n\n this._position = new Float32Array(data.position1.length)\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n eye.fromArray(this._position1 as any, i3)\n target.fromArray(this._position2 as any, i3)\n matrix.lookAt(eye, target, up)\n\n const r = this._radius[ i ]\n scale.set(r, r, eye.distanceTo(target))\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.position1 && data.position2) {\n calculateCenterArray(data.position1, data.position2, this._position)\n this._position1 = data.position1\n this._position2 = data.position2\n data.position = this._position\n }\n if (data.radius) this._radius = data.radius\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('cone', ConeBuffer)\n\nexport default ConeBuffer\n","/**\n * @file Geometry Group\n * @author Alexander Rose \n * @private\n */\n\nimport { Box3, BufferGeometry } from 'three'\n\nclass GeometryGroup {\n geometryList: BufferGeometry[]\n boundingBox: Box3\n\n constructor (geometryList: BufferGeometry[] = []) {\n this.geometryList = geometryList\n }\n\n computeBoundingBox () {\n if (!this.boundingBox) {\n this.boundingBox = new Box3()\n } else {\n this.boundingBox.empty()\n }\n\n this.geometryList.forEach(geo => {\n if (!geo.boundingBox) geo.computeBoundingBox()\n this.boundingBox.union(geo.boundingBox as Box3)\n })\n }\n}\n\nexport default GeometryGroup\n","/**\n * @file Arrow Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3, Group } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport { createParams, defaults } from '../utils'\nimport { Picker } from '../utils/picker'\nimport Buffer from './buffer'\nimport CylinderBuffer, { CylinderBufferData } from './cylinder-buffer'\nimport CylinderGeometryBuffer from './cylindergeometry-buffer'\nimport ConeBuffer, { ConeBufferData } from './cone-buffer'\nimport GeometryGroup from '../viewer/geometry-group'\nimport { BufferData, BufferDefaultParameters } from './buffer'\n\nexport interface ArrowBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n radius: Float32Array\n}\n\nexport const ArrowBufferDefaultParameters = Object.assign({\n aspectRatio: 1.5,\n radialSegments: 50,\n openEnded: false,\n disableImpostor: false\n}, BufferDefaultParameters)\nexport type ArrowBufferParameters = typeof ArrowBufferDefaultParameters\n\n/**\n * Arrow buffer. Draws arrows made from a cylinder and a cone.\n * @implements {Buffer}\n *\n * @example\n * var arrowBuffer = new ArrowBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 10, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass ArrowBuffer {\n parameters: ArrowBufferParameters\n get defaultParameters() { return ArrowBufferDefaultParameters }\n\n cylinderBuffer: CylinderGeometryBuffer\n coneBuffer: ConeBuffer\n\n splitPosition: Float32Array\n cylinderRadius: Float32Array\n\n geometry: GeometryGroup\n picking?: Picker\n\n group = new Group()\n wireframeGroup = new Group()\n pickingGroup = new Group()\n\n visible = true\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n */\n constructor (data: ArrowBufferData, params: Partial = {}) {\n this.parameters = createParams(params, this.defaultParameters)\n\n this.splitPosition = new Float32Array(data.position1.length)\n this.cylinderRadius = new Float32Array(data.radius.length)\n\n const attr = this.makeAttributes(data)\n const bufferParams = {\n radialSegments: this.parameters.radialSegments,\n openEnded: this.parameters.openEnded,\n disableImpostor: this.parameters.disableImpostor\n }\n\n this.cylinderBuffer = new CylinderBuffer(\n attr.cylinder as CylinderBufferData, bufferParams\n ) as CylinderGeometryBuffer\n this.coneBuffer = new ConeBuffer(\n attr.cone as ConeBufferData, bufferParams\n )\n\n this.geometry = new GeometryGroup([\n this.cylinderBuffer.geometry,\n this.coneBuffer.geometry\n ])\n\n // requires Group objects to be present\n this.matrix = defaults(params.matrix, new Matrix4())\n\n this.picking = data.picking\n }\n\n set matrix (m) {\n Buffer.prototype.setMatrix.call(this, m)\n }\n get matrix () {\n return this.group.matrix.clone()\n }\n\n get pickable () {\n return !!this.picking\n }\n\n makeAttributes (data: Partial = {}) {\n const splitPosition = this.splitPosition\n const cylinderRadius = this.cylinderRadius\n\n const aspectRatio = this.parameters.aspectRatio\n\n let i, il\n const cylinder: Partial = {}\n const cone: Partial = {}\n\n if (data.radius) {\n for (i = 0, il = cylinderRadius.length; i < il; ++i) {\n cylinderRadius[ i ] = data.radius[ i ] / aspectRatio\n }\n cylinder.radius = cylinderRadius\n cone.radius = data.radius\n }\n\n if (data.position1 && data.position2) {\n const vFrom = new Vector3()\n const vTo = new Vector3()\n const vDir = new Vector3()\n const vSplit = new Vector3()\n for (i = 0, il = splitPosition.length; i < il; i += 3) {\n vFrom.fromArray(data.position1 as any, i)\n vTo.fromArray(data.position2 as any, i)\n vDir.subVectors(vFrom, vTo)\n const fullLength = vDir.length()\n const coneLength = cylinderRadius[ i / 3 ] * aspectRatio * 2\n const length = Math.min(fullLength, coneLength)\n vDir.setLength(length)\n vSplit.copy(vTo).add(vDir)\n vSplit.toArray(splitPosition as any, i)\n }\n cylinder.position1 = data.position1\n cylinder.position2 = splitPosition\n cone.position1 = splitPosition\n cone.position2 = data.position2\n }\n\n if (data.color) {\n cylinder.color = data.color\n cylinder.color2 = data.color\n cone.color = data.color\n }\n\n return {\n cylinder: cylinder,\n cone: cone\n }\n }\n\n getMesh () {\n return new Group().add(\n this.cylinderBuffer.getMesh(),\n this.coneBuffer.getMesh()\n )\n }\n\n getWireframeMesh () {\n return new Group().add(\n this.cylinderBuffer.getWireframeMesh(),\n this.coneBuffer.getWireframeMesh()\n )\n }\n\n getPickingMesh () {\n return new Group().add(\n this.cylinderBuffer.getPickingMesh(),\n this.coneBuffer.getPickingMesh()\n )\n }\n\n setAttributes (data: Partial = {}) {\n const attr = this.makeAttributes(data)\n\n this.cylinderBuffer.setAttributes(attr.cylinder)\n this.coneBuffer.setAttributes(attr.cone)\n }\n\n /**\n * Set buffer parameters\n * @param {BufferParameters} params - buffer parameters object\n * @return {undefined}\n */\n setParameters (params: Partial = {}) {\n params = Object.assign({}, params)\n\n if (params && params.matrix !== undefined) {\n this.matrix = params.matrix\n }\n delete params.matrix\n\n if (params && params.wireframe !== undefined) {\n this.parameters.wireframe = params.wireframe\n this.setVisibility(this.visible)\n }\n\n this.cylinderBuffer.setParameters(params)\n this.coneBuffer.setParameters(params)\n }\n\n setVisibility (value: boolean) {\n Buffer.prototype.setVisibility.call(this, value)\n }\n\n dispose () {\n this.cylinderBuffer.dispose()\n this.coneBuffer.dispose()\n }\n}\n\nBufferRegistry.add('arrow', ArrowBuffer)\n\nexport default ArrowBuffer\n","/**\n * @file Box Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { BoxBufferGeometry, Vector3, Matrix4 } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface BoxBufferData extends BufferData {\n heightAxis: Float32Array\n depthAxis: Float32Array\n size: Float32Array\n}\n\n/**\n * Box buffer. Draws boxes.\n *\n * @example\n * var boxBuffer = new BoxBuffer({\n * position: new Float32Array([ 0, 3, 0, -2, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 1, 0, 1, 0 ]),\n * size: new Float32Array([ 2, 1.5 ]),\n * heightAxis: new Float32Array([ 0, 1, 1, 0, 2, 0 ]),\n * depthAxis: new Float32Array([ 1, 0, 1, 0, 0, 2 ])\n * })\n */\nclass BoxBuffer extends GeometryBuffer {\n updateNormals = true\n\n _heightAxis: Float32Array\n _depthAxis: Float32Array\n _size: Float32Array\n\n constructor (data: BoxBufferData, params: Partial = {}) {\n super(data, params, new BoxBufferGeometry(1, 1, 1))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._heightAxis as any, i3)\n up.fromArray(this._depthAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n scale.set(this._size[ i ], up.length(), target.length())\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.size) this._size = data.size\n if (data.heightAxis) this._heightAxis = data.heightAxis\n if (data.depthAxis) this._depthAxis = data.depthAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('box', BoxBuffer)\n\nexport default BoxBuffer\n","/**\n * @file Ellipsoid Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { IcosahedronBufferGeometry, Vector3, Matrix4 } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferDefaultParameters } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface EllipsoidBufferData extends BufferData {\n majorAxis: Float32Array\n minorAxis: Float32Array\n radius: Float32Array\n}\n\nexport const EllipsoidBufferDefaultParameters = Object.assign({\n sphereDetail: 2,\n}, BufferDefaultParameters)\nexport type EllipsoidBufferParameters = typeof EllipsoidBufferDefaultParameters\n\n/**\n * Ellipsoid buffer. Draws ellipsoids.\n *\n * @example\n * var ellipsoidBuffer = new EllipsoidBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ]),\n * majorAxis: new Float32Array([ 1, 1, 0 ]),\n * minorAxis: new Float32Array([ 0.5, 0, 0.5 ]),\n * });\n */\nclass EllipsoidBuffer extends GeometryBuffer {\n updateNormals = true\n\n get defaultParameters() { return EllipsoidBufferDefaultParameters }\n parameters: EllipsoidBufferParameters\n\n _majorAxis: Float32Array\n _minorAxis: Float32Array\n _radius: Float32Array\n\n constructor (data: EllipsoidBufferData, params: Partial = {}) {\n super(data, params, new IcosahedronBufferGeometry(1, defaults(params.sphereDetail, 2)))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._majorAxis as any, i3)\n up.fromArray(this._minorAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n scale.set(this._radius[ i ], up.length(), target.length())\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.radius) this._radius = data.radius\n if (data.majorAxis) this._majorAxis = data.majorAxis\n if (data.minorAxis) this._minorAxis = data.minorAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('ellipsoid', EllipsoidBuffer)\n\nexport default EllipsoidBuffer\n","/**\n * @file Octahedron Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { OctahedronBufferGeometry, Vector3, Matrix4 } from 'three'\nimport { BufferRegistry } from '../globals'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface OctahedronBufferData extends BufferData {\n heightAxis: Float32Array\n depthAxis: Float32Array\n size: Float32Array\n}\n\n/**\n * Octahedron buffer. Draws octahedrons.\n *\n * @example\n * var octahedronBuffer = new OctahedronBuffer({\n * position: new Float32Array([ 0, 3, 0, -2, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 1, 0, 1, 0 ]),\n * size: new Float32Array([ 2, 1.5 ]),\n * heightAxis: new Float32Array([ 0, 1, 1, 0, 2, 0 ]),\n * depthAxis: new Float32Array([ 1, 0, 1, 0, 0, 2 ])\n * })\n */\nclass OctahedronBuffer extends GeometryBuffer {\n updateNormals = true\n\n _heightAxis: Float32Array\n _depthAxis: Float32Array\n _size: Float32Array\n\n constructor (data: OctahedronBufferData, params: Partial = {}) {\n super(data, params, new OctahedronBufferGeometry(1, 0))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._heightAxis as any, i3)\n up.fromArray(this._depthAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n scale.set(this._size[ i ], up.length(), target.length())\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.size) this._size = data.size\n if (data.heightAxis) this._heightAxis = data.heightAxis\n if (data.depthAxis) this._depthAxis = data.depthAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('octahedron', OctahedronBuffer)\n\nexport default OctahedronBuffer\n","/**\n * @file Tetrahedron Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { TetrahedronBufferGeometry, Vector3, Matrix4 } from 'three'\nimport { BufferRegistry } from '../globals'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface TetrahedronBufferData extends BufferData {\n heightAxis: Float32Array\n depthAxis: Float32Array\n size: Float32Array\n}\n\n/**\n * Tetrahedron buffer. Draws tetrahedrons.\n *\n * @example\n * var tetrahedronBuffer = new TetrahedronBuffer({\n * position: new Float32Array([ 0, 3, 0, -2, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 1, 0, 1, 0 ]),\n * size: new Float32Array([ 2, 1.5 ]),\n * heightAxis: new Float32Array([ 0, 1, 1, 0, 2, 0 ]),\n * depthAxis: new Float32Array([ 1, 0, 1, 0, 0, 2 ])\n * })\n */\nclass TetrahedronBuffer extends GeometryBuffer {\n updateNormals = true\n\n _heightAxis: Float32Array\n _depthAxis: Float32Array\n _size: Float32Array\n\n constructor (data: TetrahedronBufferData, params: Partial = {}) {\n super(data, params, new TetrahedronBufferGeometry(1, 0))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._heightAxis as any, i3)\n up.fromArray(this._depthAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n scale.set(this._size[ i ], up.length(), target.length())\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.size) this._size = data.size\n if (data.heightAxis) this._heightAxis = data.heightAxis\n if (data.depthAxis) this._depthAxis = data.depthAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('tetrahedron', TetrahedronBuffer)\n\nexport default TetrahedronBuffer\n","/**\n * @file Tetrahedron Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { TorusBufferGeometry, Vector3, Matrix4 } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferDefaultParameters, BufferData } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface TorusBufferData extends BufferData {\n majorAxis: Float32Array\n minorAxis: Float32Array\n radius: Float32Array\n}\n\nexport const TorusBufferDefaultParameters = Object.assign({\n radiusRatio: 0.2,\n radialSegments: 16,\n tubularSegments: 32\n}, BufferDefaultParameters)\nexport type TorusBufferParameters = typeof TorusBufferDefaultParameters\n\n/**\n * Torus geometry buffer. Draws torii.\n *\n * @example\n * var torusBuffer = new TorusBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ]),\n * majorAxis: new Float32Array([ 1, 1, 0 ]),\n * minorAxis: new Float32Array([ 0.5, 0, 0.5 ]),\n * });\n */\nclass TorusBuffer extends GeometryBuffer {\n updateNormals = true\n\n get defaultParameters() { return TorusBufferDefaultParameters }\n parameters: TorusBufferParameters\n\n _majorAxis: Float32Array\n _minorAxis: Float32Array\n _radius: Float32Array\n\n constructor (data: TorusBufferData, params: Partial = {}) {\n super(data, params, new TorusBufferGeometry(\n 1,\n defaults(params.radiusRatio, 0.2),\n defaults(params.radialSegments, 16),\n defaults(params.tubularSegments, 32)\n ))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._majorAxis as any, i3)\n up.fromArray(this._minorAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n const r = this._radius[ i ]\n scale.set(r, r, r)\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.radius) this._radius = data.radius\n if (data.majorAxis) this._majorAxis = data.majorAxis\n if (data.minorAxis) this._minorAxis = data.minorAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('torus', TorusBuffer)\n\nexport default TorusBuffer\n","/**\n * @file Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log } from '../globals'\nimport { defaults } from '../utils'\nimport Streamer from '../streamer/streamer';\n\nexport interface ParserParameters {\n name: string\n path: string\n}\n\nclass Parser {\n streamer: Streamer\n name: string\n path: string\n [k: string]: any\n \n constructor (streamer: Streamer, params?: Partial) {\n var p = params || {}\n\n this.streamer = streamer\n\n this.name = defaults(p.name, '')\n this.path = defaults(p.path, '')\n }\n\n get type () { return '' }\n get __objName () { return '' }\n get isBinary () { return false }\n get isJson () { return false }\n get isXml () { return false }\n\n parse () {\n return this.streamer.read().then(() => {\n this._beforeParse()\n this._parse()\n this._afterParse()\n return this[ this.__objName ]\n })\n }\n\n _parse () {}\n\n _beforeParse () {}\n\n _afterParse () {\n if (Debug) Log.log(this[ this.__objName ])\n }\n}\n\nexport default Parser\n","/**\n * @file Structure Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport Parser, { ParserParameters } from './parser'\nimport Structure from '../structure/structure'\nimport StructureBuilder from '../structure/structure-builder'\nimport Streamer from '../streamer/streamer';\n\nexport interface StructureParserParameters extends ParserParameters {\n firstModelOnly: boolean\n asTrajectory: boolean\n cAlphaOnly: boolean\n}\nclass StructureParser extends Parser {\n\n structureBuilder: StructureBuilder\n\n constructor (streamer: Streamer, params?: Partial) {\n var p = params || {}\n\n super(streamer, p)\n\n this.firstModelOnly = defaults(p.firstModelOnly, false)\n this.asTrajectory = defaults(p.asTrajectory, false)\n this.cAlphaOnly = defaults(p.cAlphaOnly, false)\n\n this.structure = new Structure(this.name, this.path)\n this.structureBuilder = new StructureBuilder(this.structure)\n }\n\n get type () { return 'structure' }\n get __objName () { return 'structure' }\n}\n\nexport default StructureParser\n","/**\n * @file Entity\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from './structure'\nimport {\n UnknownEntity, PolymerEntity, NonPolymerEntity, MacrolideEntity, WaterEntity\n} from './structure-constants'\nimport ChainProxy from '../proxy/chain-proxy'\n\nfunction entityTypeFromString (string: string) {\n string = string.toLowerCase()\n switch (string) {\n case 'polymer':\n return PolymerEntity\n case 'non-polymer':\n return NonPolymerEntity\n case 'macrolide':\n return MacrolideEntity\n case 'water':\n return WaterEntity\n default:\n return UnknownEntity\n }\n}\n\nfunction entityFromType (type: number) {\n switch (type) {\n case PolymerEntity:\n return 'polymer'\n case NonPolymerEntity:\n return 'non-polymer'\n case MacrolideEntity:\n return 'macrolide'\n case WaterEntity:\n return 'water'\n default:\n return undefined\n }\n}\n\nexport const EntityTypeString = {\n 'polymer': PolymerEntity,\n 'non-polymer': NonPolymerEntity,\n 'macrolide': MacrolideEntity,\n 'water': WaterEntity,\n}\nexport type EntityTypeString = keyof typeof EntityTypeString\n\n/**\n * Entity of a {@link Structure}\n */\nexport default class Entity {\n structure: Structure\n index: number\n description: string\n entityType: number\n chainIndexList: number[]\n\n /**\n * @param {Structure} structure - structure the entity belongs to\n * @param {Integer} index - index within structure.entityList\n * @param {String} description - entity description\n * @param {String} type - entity type\n * @param {Array} chainIndexList - entity chainIndexList\n */\n constructor (structure: Structure, index: number, description = '', type?: EntityTypeString, chainIndexList: number[] = []) {\n this.structure = structure\n this.index = index\n this.description = description\n this.entityType = entityTypeFromString(type || '')\n this.chainIndexList = chainIndexList\n\n chainIndexList.forEach(function (ci: number) {\n structure.chainStore.entityIndex[ ci ] = index\n })\n }\n\n get type () { return entityFromType(this.entityType) }\n\n getEntityType () {\n return this.entityType\n }\n\n isPolymer () {\n return this.entityType === PolymerEntity\n }\n\n isNonPolymer () {\n return this.entityType === NonPolymerEntity\n }\n\n isMacrolide () {\n return this.entityType === MacrolideEntity\n }\n\n isWater () {\n return this.entityType === WaterEntity\n }\n\n eachChain (callback: (cp: ChainProxy) => any) {\n const cp = this.structure.getChainProxy()\n\n this.chainIndexList.forEach(function (index) {\n cp.index = index\n callback(cp)\n })\n }\n}","/**\n * @file Unitcell\n * @author Alexander Rose \n * @private\n */\n\nimport { Color, Vector3, Matrix4 } from 'three'\n\nimport { defaults } from '../utils'\nimport { degToRad } from '../math/math-utils'\nimport {\n uniformArray, uniformArray3, centerArray3\n} from '../math/array-utils'\nimport { UnitcellPicker } from '../utils/picker'\nimport Structure from '../structure/structure'\n\nexport interface UnitcellParams {\n a: number\n b: number\n c: number\n alpha: number\n beta: number\n gamma: number\n spacegroup: string\n cartToFrac?: Matrix4\n}\n\nconst DefaultBoxParams = {\n a: 1,\n b: 1,\n c: 1,\n alpha: 90,\n beta: 90,\n gamma: 90,\n spacegroup: 'P 1'\n}\n\nexport interface UnitcellDataParams {\n colorValue?: string|number,\n radius?: number\n}\n\n/**\n * Unitcell class\n */\nclass Unitcell {\n a: number\n b: number\n c: number\n alpha: number\n beta: number\n gamma: number\n\n spacegroup: string\n\n cartToFrac = new Matrix4()\n fracToCart = new Matrix4()\n\n volume: number\n\n /**\n * @param {Object} params - unitcell parameters\n * @param {Number} params.a - length a\n * @param {Number} params.b - length b\n * @param {Number} params.c - length c\n * @param {Number} params.alpha - angle alpha\n * @param {Number} params.beta - angle beta\n * @param {Number} params.gamma - angle gamma\n * @param {String} params.spacegroup - spacegroup\n * @param {Matrix4} [params.cartToFrac] - transformation matrix from\n * cartesian to fractional coordinates\n * @param {Matrix4} [params.scale] - alias for `params.cartToFrac`\n */\n constructor (params: UnitcellParams = DefaultBoxParams) {\n this.a = params.a\n this.b = params.b\n this.c = params.c\n this.alpha = params.alpha\n this.beta = params.beta\n this.gamma = params.gamma\n this.spacegroup = params.spacegroup\n\n const alphaRad = degToRad(this.alpha)\n const betaRad = degToRad(this.beta)\n const gammaRad = degToRad(this.gamma)\n const cosAlpha = Math.cos(alphaRad)\n const cosBeta = Math.cos(betaRad)\n const cosGamma = Math.cos(gammaRad)\n const sinBeta = Math.sin(betaRad)\n const sinGamma = Math.sin(gammaRad)\n\n this.volume = (\n this.a * this.b * this.c *\n Math.sqrt(\n 1 - cosAlpha * cosAlpha - cosBeta * cosBeta - cosGamma * cosGamma +\n 2.0 * cosAlpha * cosBeta * cosGamma\n )\n )\n\n if (params.cartToFrac === undefined) {\n // https://github.com/biojava/biojava/blob/master/biojava-structure/src/main/java/org/biojava/nbio/structure/xtal/CrystalCell.java\n\n const cStar = (this.a * this.b * sinGamma) / this.volume\n const cosAlphaStar = (\n (cosBeta * cosGamma - cosAlpha) / (sinBeta * sinGamma)\n )\n\n this.fracToCart.set(\n this.a, 0, 0, 0,\n this.b * cosGamma, this.b * sinGamma, 0, 0,\n this.c * cosBeta, -this.c * sinBeta * cosAlphaStar, 1.0 / cStar, 0,\n 0, 0, 0, 1\n ).transpose()\n this.cartToFrac.getInverse(this.fracToCart)\n } else {\n this.cartToFrac.copy(params.cartToFrac)\n this.fracToCart.getInverse(this.cartToFrac)\n }\n }\n\n getPosition (structure: Structure): Float32Array {\n const vertexPosition = new Float32Array(3 * 8)\n\n if (structure.unitcell) {\n const uc = structure.unitcell\n const centerFrac = structure.center.clone().applyMatrix4(uc.cartToFrac).floor()\n const v = new Vector3()\n\n let cornerOffset = 0\n const addCorner = function (x: number, y: number, z: number) {\n v.set(x, y, z)\n .add(centerFrac)\n .applyMatrix4(uc.fracToCart)\n .toArray(vertexPosition as any, cornerOffset)\n cornerOffset += 3\n }\n addCorner(0, 0, 0)\n addCorner(1, 0, 0)\n addCorner(0, 1, 0)\n addCorner(0, 0, 1)\n addCorner(1, 1, 0)\n addCorner(1, 0, 1)\n addCorner(0, 1, 1)\n addCorner(1, 1, 1)\n }\n\n return vertexPosition\n }\n\n getCenter (structure: Structure) {\n return centerArray3(this.getPosition(structure))\n }\n\n getData (structure: Structure, params: UnitcellDataParams = {}) {\n const colorValue = defaults(params.colorValue, 'orange')\n const radius = defaults(params.radius, Math.cbrt(this.volume) / 200)\n\n const c = new Color(colorValue)\n const v = new Vector3()\n\n const vertexPosition = this.getPosition(structure)\n const vertexColor = uniformArray3(8, c.r, c.g, c.b)\n const vertexRadius = uniformArray(8, radius)\n\n const edgePosition1 = new Float32Array(3 * 12)\n const edgePosition2 = new Float32Array(3 * 12)\n const edgeColor = uniformArray3(12, c.r, c.g, c.b)\n const edgeRadius = uniformArray(12, radius)\n\n let edgeOffset = 0\n function addEdge (a: number, b: number) {\n v.fromArray(vertexPosition as any, a * 3)\n .toArray(edgePosition1 as any, edgeOffset)\n v.fromArray(vertexPosition as any, b * 3)\n .toArray(edgePosition2 as any, edgeOffset)\n edgeOffset += 3\n }\n addEdge(0, 1)\n addEdge(0, 2)\n addEdge(0, 3)\n addEdge(1, 4)\n addEdge(1, 5)\n addEdge(2, 6)\n addEdge(3, 5)\n addEdge(4, 7)\n addEdge(5, 7)\n addEdge(2, 4)\n addEdge(7, 6)\n addEdge(3, 6)\n\n const picker = new UnitcellPicker(this, structure)\n\n return {\n vertex: {\n position: vertexPosition,\n color: vertexColor,\n radius: vertexRadius,\n picking: picker\n },\n edge: {\n position1: edgePosition1,\n position2: edgePosition2,\n color: edgeColor,\n color2: edgeColor,\n radius: edgeRadius,\n picking: picker\n }\n }\n }\n}\n\nexport default Unitcell\n","/**\n * @file Pdb Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureParser from './structure-parser'\nimport Entity, { EntityTypeString } from '../structure/entity'\nimport Unitcell, { UnitcellParams } from '../symmetry/unitcell'\nimport Assembly, { AssemblyPart } from '../symmetry/assembly'\nimport { PDBQTSpecialElements, WaterNames } from '../structure/structure-constants'\nimport {\n assignSecondaryStructure, InferBondsOptions, buildUnitcellAssembly,\n calculateBonds, calculateChainnames, calculateSecondaryStructure\n} from '../structure/structure-utils'\nimport Streamer from '../streamer/streamer';\nimport { ParserParameters } from './parser';\nimport { NumberArray } from '../types';\nimport { Structure } from '../ngl';\n\n// PDB helix record encoding\nconst HelixTypes: {[k: number]: string} = {\n 1: 'h', // Right-handed alpha (default)\n 2: 'h', // Right-handed omega\n 3: 'i', // Right-handed pi\n 4: 'h', // Right-handed gamma\n 5: 'g', // Right-handed 310\n 6: 'h', // Left-handed alpha\n 7: 'h', // Left-handed omega\n 8: 'h', // Left-handed gamma\n 9: 'h', // 27 ribbon/helix\n 10: 'h', // Polyproline\n 0: 'h' //Used to be ''\n}\n\nconst dAminoAcids = [\n 'DAL', // D-ALANINE\n 'DAR', // D-ARGININE\n 'DSG', // D-ASPARAGINE\n 'DAS', // D-ASPARTIC ACID\n 'DCY', // D-CYSTEINE\n 'DGL', // D-GLUTAMIC ACID\n 'DGN', // D-GLUTAMINE\n 'DHI', // D-HISTIDINE\n 'DIL', // D-ISOLEUCINE\n 'DLE', // D-LEUCINE\n 'DLY', // D-LYSINE\n 'MED', // D-METHIONINE\n 'DPN', // D-PHENYLALANINE\n 'DPR', // D-PROLINE\n 'DSN', // D-SERINE\n 'DTH', // D-THREONINE\n 'DTR', // D-TRYPTOPHAN\n 'DTY', // D-TYROSINE\n 'DVA', // D-VALINE\n\n 'DNE' // D-NORLEUCINE\n\n // ??? // D-SELENOCYSTEINE\n]\n\nconst entityKeyList = [\n 'MOL_ID', 'MOLECULE', 'CHAIN', 'FRAGMENT', 'SYNONYM',\n 'EC', 'ENGINEERED', 'MUTATION', 'OTHER_DETAILS'\n]\n\nconst reWhitespace = /\\s+/\n\nfunction getModresId (resno: number, chainname?: string, inscode?: string) {\n let id = `${resno}`\n if (chainname) id += `:${chainname}`\n if (inscode) id += `^${inscode}`\n return id\n}\n\nexport interface PdbParserParameters extends ParserParameters {\n hex: boolean\n inferBonds: InferBondsOptions\n}\n\nclass PdbParser extends StructureParser {\n\n hex: boolean\n inferBonds: InferBondsOptions\n\n /**\n * Create a pdb parser\n * @param {Streamer} streamer - streamer object\n * @param {Object} params - params object\n * @param {Boolean} params.hex - hexadecimal parsing of\n * atom numbers >99.999 and\n * residue numbers >9.999\n * @param {InferBondsOptions} params.inferBonds: 'all': use explicit bonds and detect by distance\n * 'auto': If a hetgroup residue has explicit bonds, don't auto-detect\n * 'none': Don't add any bonds automatically\n * @return {undefined}\n */\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.hex = defaults(p.hex, false)\n this.inferBonds = defaults(p.inferBonds, 'all')\n }\n\n get type () { return 'pdb' }\n\n _parse () {\n // http://www.wwpdb.org/documentation/file-format.php\n\n if (Debug) Log.time('PdbParser._parse ' + this.name)\n\n let isLegacy = false\n const headerLine = this.streamer.peekLines(1)[ 0 ]\n const headerId = headerLine.substr(62, 4)\n const legacyId = headerLine.substr(72, 4)\n if (headerId === legacyId && legacyId.trim()) {\n isLegacy = true\n }\n\n const isPqr = this.type === 'pqr'\n const isPdbqt = this.type === 'pdbqt'\n\n const s: Structure = this.structure\n const sb = this.structureBuilder\n\n const hex = this.hex\n let serialRadix = 10\n let resnoRadix = 10\n\n const firstModelOnly = this.firstModelOnly\n const asTrajectory = this.asTrajectory\n const cAlphaOnly = this.cAlphaOnly\n\n const frames = s.frames\n const boxes = s.boxes\n let doFrames = false\n let currentFrame: NumberArray, currentCoord: number\n\n const biomolDict = s.biomolDict\n let currentBiomol: Assembly\n let currentPart: AssemblyPart\n let currentMatrix: Matrix4\n\n let line, recordName\n let serial, chainname: string, resno: number, resname: string, occupancy: number\n let inscode: string, atomname, hetero: boolean, bfactor: number, altloc\n let formalCharge: number\n\n let startChain, startResi, startIcode\n let endChain, endResi, endIcode\n\n let serialDict: {[k: number]: number} = {}\n const unitcellDict: Partial<{\n origx: Matrix4\n scale: Matrix4\n a: number\n b: number\n c: number\n alpha: number\n beta: number\n gamma: number\n spacegroup: string\n }> = {}\n const bondDict: {[k: string]: boolean} = {}\n\n const entityDataList: {chainList: string[], name: string}[] = []\n let currentEntityData: {chainList: string[], name: string}\n let currentEntityKey: 'MOL_ID'|'MOLECULE'|'CHAIN'|'FRAGMENT'|'SYNONYM'|'EC'|'ENGINEERED'|'MUTATION'|'OTHER_DETAILS'\n // MOL_ID Numbers each component; also used in SOURCE to associate\n // the information.\n // MOLECULE Name of the macromolecule.\n // CHAIN Comma-separated list of chain identifier(s).\n // FRAGMENT Specifies a domain or region of the molecule.\n // SYNONYM Comma-separated list of synonyms for the MOLECULE.\n // EC The Enzyme Commission number associated with the molecule.\n // If there is more than one EC number, they are presented\n // as a comma-separated list.\n // ENGINEERED Indicates that the molecule was produced using\n // recombinant technology or by purely chemical synthesis.\n // MUTATION Indicates if there is a mutation.\n // OTHER_DETAILS Additional comments.\n\n const hetnameDict: {[k: string]: string} = {}\n const modresDict: {[k: string]: any} = {}\n\n const chainDict: {[k: string]: number} = {}\n let chainIdx: number, chainid: string, newChain: boolean\n let currentChainname: string, currentResno: number, currentResname: string, currentInscode: string\n\n const seqresDict: {[k: string]: string[]} = {}\n let currentSeqresChainname: string\n\n const secStruct = {\n helices: [] as any[],\n sheets: [] as any[]\n }\n const helices = secStruct.helices\n const sheets = secStruct.sheets\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.resize(Math.round(this.streamer.data.length / 80))\n if (isPqr || isPdbqt) atomStore.addField('partialCharge', 1, 'float32')\n if (isPqr) atomStore.addField('radius', 1, 'float32')\n\n const ap1 = s.getAtomProxy()\n const ap2 = s.getAtomProxy()\n\n let idx = 0\n let modelIdx = 0\n let pendingStart = true\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n line = lines[ i ]\n recordName = line.substr(0, 6)\n\n if (recordName === 'ATOM ' || recordName === 'HETATM') {\n // http://www.wwpdb.org/documentation/file-format-content/format33/sect9.html#ATOM\n // PQR: Field_name Atom_number Atom_name Residue_name Chain_ID Residue_number X Y Z Charge Radius\n\n if (pendingStart) {\n if (asTrajectory) {\n if (doFrames) {\n currentFrame = new Float32Array(atomStore.count * 3)\n frames.push(currentFrame)\n } else {\n currentFrame = []\n }\n currentCoord = 0\n } else {\n if (!firstModelOnly) serialDict = {}\n }\n\n chainIdx = 1\n chainid = chainIdx.toString()\n newChain = true\n\n pendingStart = false\n }\n\n if (firstModelOnly && modelIdx > 0) continue\n\n let x, y, z, ls: string[], dd = 0\n\n if (isPqr) {\n ls = line.split(reWhitespace)\n dd = ls.length === 10 ? 1 : 0\n\n atomname = ls[ 2 ]\n if (cAlphaOnly && atomname !== 'CA') continue\n\n x = parseFloat(ls[ 6 - dd ])\n y = parseFloat(ls[ 7 - dd ])\n z = parseFloat(ls[ 8 - dd ])\n } else {\n atomname = line.substr(12, 4).trim()\n if (cAlphaOnly && atomname !== 'CA') continue\n\n x = parseFloat(line.substr(30, 8))\n y = parseFloat(line.substr(38, 8))\n z = parseFloat(line.substr(46, 8))\n }\n\n if (asTrajectory) {\n const j = currentCoord * 3\n\n currentFrame[ j + 0 ] = x\n currentFrame[ j + 1 ] = y\n currentFrame[ j + 2 ] = z\n\n currentCoord += 1\n\n if (doFrames) continue\n }\n\n let element\n\n if (isPqr) {\n serial = parseInt(ls![ 1 ])\n element = ''\n hetero = (line[ 0 ] === 'H')\n chainname = dd ? '' : ls![ 4 ]\n resno = parseInt(ls![ 5 - dd! ])\n inscode = ''\n resname = ls![ 3 ]\n altloc = ''\n occupancy = 1.0\n } else {\n serial = parseInt(line.substr(6, 5), serialRadix)\n if (hex && serial === 99999) {\n serialRadix = 16\n }\n hetero = (line[ 0 ] === 'H')\n chainname = line[ 21 ].trim()\n resno = parseInt(line.substr(22, 4), resnoRadix)\n if (hex && resno === 9999) {\n resnoRadix = 16\n }\n inscode = line[ 26 ].trim()\n resname = line.substr(17, 4).trim() || 'MOL'\n bfactor = parseFloat(line.substr(60, 6))\n altloc = line[ 16 ].trim()\n occupancy = parseFloat(line.substr(54, 6))\n\n if (!isLegacy) {\n if (isPdbqt) {\n element = line.substr(76, 3).trim()\n // @ts-expect-error TS limitation on narrowing indexes types with `in`\n if (element in PDBQTSpecialElements) element = PDBQTSpecialElements[element]\n } else {\n element = line.substr(76, 2).trim()\n if (!chainname) {\n chainname = line.substr(72, 4).trim() // segid\n }\n }\n // Where specified, formalCharge is of form \"2-\" or \"1+\"\n formalCharge = parseInt((line.substr(79,1) + line.substr(78, 1)).trim())\n }\n }\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname, element)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = serial\n atomStore.altloc[ idx ] = altloc.charCodeAt(0)\n atomStore.occupancy[ idx ] = isNaN(occupancy) ? 0 : occupancy\n\n if (isPqr) {\n atomStore.partialCharge![ idx ] = parseFloat(ls![ 9 - dd! ])\n atomStore.radius[ idx ] = parseFloat(ls![ 10 - dd! ])\n } else {\n atomStore.bfactor[ idx ] = isNaN(bfactor) ? 0 : bfactor\n if (isPdbqt) {\n atomStore.partialCharge![ idx ] = parseFloat(line.substr(70, 6))\n }\n // isFinite check will reject undefined (in legacy case) and NaN values\n if (isFinite(formalCharge)) {\n if (!atomStore.formalCharge) {\n atomStore.addField('formalCharge', 1, 'int8')\n }\n atomStore.formalCharge![ idx ] = formalCharge\n }\n }\n\n const modresId = getModresId(resno, chainname, inscode)\n\n // TODO instead of looking at MODRES look at SEQRES and\n // missing residues in REMARK 465\n if (hetero && !modresDict[modresId] && !dAminoAcids.includes(resname)) {\n if (currentChainname !== chainname || currentResname !== resname ||\n (!WaterNames.includes(resname) &&\n (currentResno !== resno || currentInscode !== inscode))\n ) {\n chainIdx += 1\n chainid = chainIdx.toString()\n\n currentResno = resno\n currentResname = resname\n currentInscode = inscode\n }\n } else if (!newChain && currentChainname !== chainname) {\n chainIdx += 1\n chainid = chainIdx.toString()\n }\n\n sb.addAtom(modelIdx, chainname, chainid, resname, resno, hetero, undefined, inscode)\n\n serialDict[ serial ] = idx\n idx += 1\n newChain = false\n currentChainname = chainname\n } else if (recordName === 'CONECT') {\n const fromIdx = serialDict[ parseInt(line.substr(6, 5)) ]\n const pos = [ 11, 16, 21, 26 ]\n const bondIndex: {[k: number]: number} = {}\n\n if (fromIdx === undefined) {\n // Log.log( \"missing CONNECT serial\" );\n continue\n }\n\n for (let j = 0; j < 4; ++j) {\n let toIdx = parseInt(line.substr(pos[ j ], 5))\n if (Number.isNaN(toIdx)) continue\n toIdx = serialDict[ toIdx ]\n if (toIdx === undefined) {\n // Log.log( \"missing CONNECT serial\" );\n continue\n }/* else if( toIdx < fromIdx ){\n // likely a duplicate in standard PDB format\n // but not necessarily, so better remove duplicates\n // in a pass after parsing (and auto bonding)\n continue;\n } */\n\n if (fromIdx < toIdx) {\n ap1.index = fromIdx\n ap2.index = toIdx\n } else {\n ap1.index = toIdx\n ap2.index = fromIdx\n }\n\n // interpret records where a 'toIdx' atom is given multiple times\n // as double/triple bonds, e.g. CONECT 1529 1528 1528 is a double bond\n if (bondIndex[ toIdx ] !== undefined) {\n s.bondStore.bondOrder[ bondIndex[ toIdx ] ] += 1\n } else {\n const hash = ap1.index + '|' + ap2.index\n if (bondDict[ hash ] === undefined) {\n bondDict[ hash ] = true\n bondIndex[ toIdx ] = s.bondStore.count\n s.bondStore.addBond(ap1, ap2, 1) // start/assume with single bond\n }\n }\n }\n } else if (recordName === 'HELIX ') {\n startChain = line[ 19 ].trim()\n startResi = parseInt(line.substr(21, 4))\n startIcode = line[ 25 ].trim()\n endChain = line[ 31 ].trim()\n endResi = parseInt(line.substr(33, 4))\n endIcode = line[ 37 ].trim()\n let helixType = parseInt(line.substr(39, 1))\n helixType = (HelixTypes[ helixType ] || HelixTypes[0]).charCodeAt(0)\n helices.push([\n startChain, startResi, startIcode,\n endChain, endResi, endIcode,\n helixType\n ])\n } else if (recordName === 'SHEET ') {\n startChain = line[ 21 ].trim()\n startResi = parseInt(line.substr(22, 4))\n startIcode = line[ 26 ].trim()\n endChain = line[ 32 ].trim()\n endResi = parseInt(line.substr(33, 4))\n endIcode = line[ 37 ].trim()\n sheets.push([\n startChain, startResi, startIcode,\n endChain, endResi, endIcode\n ])\n } else if (recordName === 'HETNAM') {\n hetnameDict[ line.substr(11, 3) ] = line.substr(15).trim()\n } else if (recordName === 'SEQRES') {\n const seqresChainname = line[11].trim()\n if (seqresChainname !== currentSeqresChainname) {\n seqresDict[ seqresChainname ] = []\n currentSeqresChainname = seqresChainname\n }\n seqresDict[ seqresChainname ].push(\n ...line.substr(19).trim().split(reWhitespace)\n )\n } else if (recordName === 'MODRES') {\n // MODRES 2SRC PTR A 527 TYR O-PHOSPHOTYROSINE\n const resname = line.substr(12, 3).trim()\n const chainname = line[16].trim()\n const inscode = line[22].trim()\n const resno = parseInt(line.substr(18, 4).trim())\n const id = getModresId(resno, chainname, inscode)\n modresDict[ id ] = { resname, chainname, inscode, resno }\n } else if (recordName === 'COMPND') {\n const comp = line.substr(10, 70).trim()\n const keyEnd = comp.indexOf(':')\n const key = comp.substring(0, keyEnd)\n let value\n\n if (entityKeyList.includes(key)) {\n currentEntityKey = key as 'MOL_ID'|'MOLECULE'|'CHAIN'|'FRAGMENT'|'SYNONYM'|'EC'|'ENGINEERED'|'MUTATION'|'OTHER_DETAILS'\n value = comp.substring(keyEnd + 2)\n } else {\n value = comp\n }\n value = value.replace(/;$/, '')\n\n if (currentEntityKey === 'MOL_ID') {\n currentEntityData = {\n chainList: [],\n name: ''\n }\n entityDataList.push(currentEntityData)\n } else if (currentEntityKey === 'MOLECULE') {\n if (currentEntityData.name) currentEntityData.name += ' '\n currentEntityData.name += value\n } else if (currentEntityKey === 'CHAIN') {\n Array.prototype.push.apply(\n currentEntityData.chainList,\n value.split(/\\s*,\\s*/)\n )\n }\n } else if (line.startsWith('TER')) {\n const cp = s.getChainProxy(s.chainStore.count - 1)\n chainDict[ cp.chainname ] = cp.index\n chainIdx += 1\n chainid = chainIdx.toString()\n newChain = true\n } else if (recordName === 'REMARK' && line.substr(7, 3) === '350') {\n if (line.substr(11, 12) === 'BIOMOLECULE:') {\n let name = line.substr(23).trim()\n if (/^(0|[1-9][0-9]*)$/.test(name)) name = 'BU' + name\n\n currentBiomol = new Assembly(name)\n biomolDict[ name ] = currentBiomol\n } else if (line.substr(13, 5) === 'BIOMT') {\n const biomt = line.split(/\\s+/)\n const row = parseInt(line[ 18 ]) - 1\n\n if (row === 0) {\n currentMatrix = new Matrix4()\n currentPart.matrixList.push(currentMatrix)\n }\n\n const biomtElms = currentMatrix.elements\n\n biomtElms[ 4 * 0 + row ] = parseFloat(biomt[ 4 ])\n biomtElms[ 4 * 1 + row ] = parseFloat(biomt[ 5 ])\n biomtElms[ 4 * 2 + row ] = parseFloat(biomt[ 6 ])\n biomtElms[ 4 * 3 + row ] = parseFloat(biomt[ 7 ])\n } else if (\n line.substr(11, 30) === 'APPLY THE FOLLOWING TO CHAINS:' ||\n line.substr(11, 30) === ' AND CHAINS:'\n ) {\n if (line.substr(11, 5) === 'APPLY') {\n currentPart = currentBiomol.addPart()\n }\n\n const chainList = line.substr(41, 30).split(',')\n for (let j = 0, jl = chainList.length; j < jl; ++j) {\n const c = chainList[ j ].trim()\n if (c) currentPart.chainList.push(c)\n }\n }\n } else if (recordName === 'HEADER') {\n s.id = line.substr(62, 4)\n } else if (recordName === 'TITLE ') {\n s.title += (s.title ? ' ' : '') + line.substr(10, 70).trim()\n } else if (recordName === 'MODEL ') {\n pendingStart = true\n } else if (recordName === 'ENDMDL' || line.trim() === 'END') {\n if (pendingStart) continue\n\n if (asTrajectory && !doFrames) {\n frames.push(new Float32Array(currentFrame))\n doFrames = true\n }\n\n modelIdx += 1\n pendingStart = true\n } else if (line.substr(0, 5) === 'MTRIX') {\n // ignore 'given' operators\n if (line[ 59 ] === '1') continue\n\n if (!currentBiomol || currentBiomol.name !== 'NCS') {\n const ncsName = 'NCS'\n currentBiomol = new Assembly(ncsName)\n biomolDict[ ncsName ] = currentBiomol\n currentPart = currentBiomol.addPart()\n }\n\n const ncs = line.split(/\\s+/)\n const ncsRow = parseInt(line[ 5 ]) - 1\n\n if (ncsRow === 0) {\n currentMatrix = new Matrix4()\n currentPart.matrixList.push(currentMatrix)\n }\n\n const ncsElms = currentMatrix.elements\n\n ncsElms[ 4 * 0 + ncsRow ] = parseFloat(ncs[ 2 ])\n ncsElms[ 4 * 1 + ncsRow ] = parseFloat(ncs[ 3 ])\n ncsElms[ 4 * 2 + ncsRow ] = parseFloat(ncs[ 4 ])\n ncsElms[ 4 * 3 + ncsRow ] = parseFloat(ncs[ 5 ])\n } else if (line.substr(0, 5) === 'ORIGX') {\n if (!unitcellDict.origx) {\n unitcellDict.origx = new Matrix4()\n }\n\n const orgix = line.split(/\\s+/)\n const origxRow = parseInt(line[ 5 ]) - 1\n const origxElms = unitcellDict.origx.elements\n\n origxElms[ 4 * 0 + origxRow ] = parseFloat(orgix[ 1 ])\n origxElms[ 4 * 1 + origxRow ] = parseFloat(orgix[ 2 ])\n origxElms[ 4 * 2 + origxRow ] = parseFloat(orgix[ 3 ])\n origxElms[ 4 * 3 + origxRow ] = parseFloat(orgix[ 4 ])\n } else if (line.substr(0, 5) === 'SCALE') {\n if (!unitcellDict.scale) {\n unitcellDict.scale = new Matrix4()\n }\n\n const scale = line.split(/\\s+/)\n const scaleRow = parseInt(line[ 5 ]) - 1\n const scaleElms = unitcellDict.scale.elements\n\n scaleElms[ 4 * 0 + scaleRow ] = parseFloat(scale[ 1 ])\n scaleElms[ 4 * 1 + scaleRow ] = parseFloat(scale[ 2 ])\n scaleElms[ 4 * 2 + scaleRow ] = parseFloat(scale[ 3 ])\n scaleElms[ 4 * 3 + scaleRow ] = parseFloat(scale[ 4 ])\n } else if (recordName === 'CRYST1') {\n // CRYST1 55.989 55.989 55.989 90.00 90.00 90.00 P 1 1\n // 7 - 15 Real(9.3) a (Angstroms)\n // 16 - 24 Real(9.3) b (Angstroms)\n // 25 - 33 Real(9.3) c (Angstroms)\n // 34 - 40 Real(7.2) alpha alpha (degrees).\n // 41 - 47 Real(7.2) beta beta (degrees).\n // 48 - 54 Real(7.2) gamma gamma (degrees).\n // 56 - 66 LString sGroup Space group.\n // 67 - 70 Integer z Z value.\n\n const aLength = parseFloat(line.substr(6, 9))\n const bLength = parseFloat(line.substr(15, 9))\n const cLength = parseFloat(line.substr(24, 9))\n\n const alpha = parseFloat(line.substr(33, 7))\n const beta = parseFloat(line.substr(40, 7))\n const gamma = parseFloat(line.substr(47, 7))\n\n const sGroup = line.substr(55, 11).trim()\n // const zValue = parseInt( line.substr( 66, 4 ) );\n\n const box = new Float32Array(9)\n box[ 0 ] = aLength\n box[ 4 ] = bLength\n box[ 8 ] = cLength\n boxes.push(box)\n\n if (modelIdx === 0) {\n unitcellDict.a = aLength\n unitcellDict.b = bLength\n unitcellDict.c = cLength\n unitcellDict.alpha = alpha\n unitcellDict.beta = beta\n unitcellDict.gamma = gamma\n unitcellDict.spacegroup = sGroup\n }\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n\n // finalize ensures resname will be defined for all rp.resname\n // (required in entity handling below)\n sb.finalize()\n\n //\n\n const en = entityDataList.length\n\n if (en) {\n s.eachChain(function (cp) {\n cp.entityIndex = en\n })\n\n entityDataList.forEach(function (e, i) {\n const chainIndexList = e.chainList.map(function (chainname) {\n return chainDict[ chainname ]\n })\n s.entityList.push(new Entity(\n s, i, e.name, 'polymer', chainIndexList\n ))\n })\n\n let ei = entityDataList.length\n const rp = s.getResidueProxy()\n const residueDict: {[k: string]: number[]} = {}\n\n s.eachChain(function (cp) {\n if (cp.entityIndex === en) {\n rp.index = cp.residueOffset\n if (!residueDict[ rp.resname ]) {\n residueDict[ rp.resname ] = []\n }\n residueDict[ rp.resname ].push(cp.index)\n }\n })\n\n Object.keys(residueDict).forEach(function (resname) {\n const chainList = residueDict[ resname ]\n let type: EntityTypeString = 'non-polymer'\n let name = hetnameDict[ resname ] || resname\n if (WaterNames.includes(resname)) {\n name = 'water'\n type = 'water'\n }\n s.entityList.push(new Entity(\n s, ei, name, type, chainList\n ))\n ei += 1\n })\n }\n\n //\n\n if (unitcellDict.a !== undefined) {\n s.unitcell = new Unitcell(unitcellDict as UnitcellParams)\n } else {\n s.unitcell = undefined\n }\n\n if (helices.length || sheets.length) {\n assignSecondaryStructure(s, secStruct)\n }\n\n s.finalizeAtoms()\n if (!isLegacy) calculateChainnames(s)\n calculateBonds(s, this.inferBonds)\n s.finalizeBonds()\n\n if (!helices.length && !sheets.length) {\n calculateSecondaryStructure(s)\n }\n buildUnitcellAssembly(s)\n\n if (Debug) Log.timeEnd('PdbParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('pdb', PdbParser)\nParserRegistry.add('pdb1', PdbParser)\nParserRegistry.add('ent', PdbParser)\n\nexport default PdbParser\n\nexport {\n HelixTypes\n}\n","/**\n * @file Cif Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport { HelixTypes } from './pdb-parser'\nimport Entity from '../structure/entity'\nimport Unitcell, { UnitcellParams } from '../symmetry/unitcell'\nimport Assembly from '../symmetry/assembly'\nimport Selection from '../selection/selection'\nimport {\n assignResidueTypeBonds, assignSecondaryStructure, buildUnitcellAssembly,\n calculateBonds, calculateSecondaryStructure\n} from '../structure/structure-utils'\nimport { Structure } from '../ngl';\nimport StructureBuilder from '../structure/structure-builder';\nimport { NumberArray } from '../types';\n\nconst reWhitespace = /\\s+/\nconst reQuotedWhitespace = /'((?:(?!'\\s).)*)'|\"((?:(?!\"\\s).)*)\"|(\\S+)/g\nconst reDoubleQuote = /\"/g\nconst reTrimQuotes = /^['\"]+|['\"]+$/g\nconst reAtomSymbol = /^\\D{1,2}/ // atom symbol in atom_site_label\n\ninterface Cif {[k: string]: any}\n\nfunction trimQuotes (str: string) {\n if (str && str[0] === str[ str.length - 1 ] && (str[0] === \"'\" || str[0] === '\"')) {\n return str.substring(1, str.length - 1)\n } else {\n return str\n }\n}\n\nfunction ensureArray (dict: {[k: string]: any[]}, field: string) {\n if (!Array.isArray(dict[ field ])) {\n Object.keys(dict).forEach(function (key) {\n dict[ key ] = [ dict[ key ] ]\n })\n }\n}\n\nfunction hasValue (d: string) {\n return d !== '?'\n}\n\nfunction cifDefaults (value: string, defaultValue: string) {\n return hasValue(value) ? value : defaultValue\n}\n\nfunction getBondOrder (valueOrder: string) {\n switch (valueOrder.toLowerCase()) {\n case '?': // assume single bond\n case 'sing':\n return 1\n case 'doub':\n return 2\n case 'trip':\n return 3\n case 'quad':\n return 4\n }\n return 0\n}\n\nfunction parseChemComp (cif: Cif, structure: Structure, structureBuilder: StructureBuilder) {\n const atomStore = structure.atomStore\n const atomMap = structure.atomMap\n\n let i, n\n const cc = cif.chem_comp\n const cca = cif.chem_comp_atom\n const ccb = cif.chem_comp_bond\n\n if (cc) {\n if (cc.name) {\n structure.title = cc.name.trim().replace(reTrimQuotes, '')\n }\n if (cc.id) {\n structure.id = cc.id.trim().replace(reTrimQuotes, '')\n }\n }\n\n var atomnameDict: {[k: string]: number} = {}\n\n if (cca) {\n ensureArray(cca, 'comp_id')\n\n var atomname, element, resname, resno\n n = cca.comp_id.length\n\n for (i = 0; i < n; ++i) {\n atomStore.growIfFull()\n\n atomname = cca.atom_id[ i ].replace(reDoubleQuote, '')\n element = cca.type_symbol[ i ]\n\n atomnameDict[ atomname ] = i\n atomStore.atomTypeId[ i ] = atomMap.add(atomname, element)\n\n atomStore.x[ i ] = cca.model_Cartn_x[ i ]\n atomStore.y[ i ] = cca.model_Cartn_y[ i ]\n atomStore.z[ i ] = cca.model_Cartn_z[ i ]\n atomStore.serial[ i ] = i\n\n resname = cca.pdbx_component_comp_id[ i ]\n resno = cca.pdbx_residue_numbering ? cca.pdbx_residue_numbering[ i ] : 1\n\n structureBuilder.addAtom(0, '', '', resname, resno, true)\n }\n\n for (i = 0; i < n; ++i) {\n var j = i + n\n\n atomStore.growIfFull()\n\n atomname = cca.atom_id[ i ].replace(reDoubleQuote, '')\n element = cca.type_symbol[ i ]\n\n atomStore.atomTypeId[ j ] = atomMap.add(atomname, element)\n\n atomStore.x[ j ] = cca.pdbx_model_Cartn_x_ideal[ i ]\n atomStore.y[ j ] = cca.pdbx_model_Cartn_y_ideal[ i ]\n atomStore.z[ j ] = cca.pdbx_model_Cartn_z_ideal[ i ]\n atomStore.serial[ j ] = j\n\n resname = cca.pdbx_component_comp_id[ i ]\n resno = cca.pdbx_residue_numbering ? cca.pdbx_residue_numbering[ i ] : 1\n\n structureBuilder.addAtom(1, '', '', resname, resno, true)\n }\n }\n\n if (cca && ccb) {\n ensureArray(ccb, 'comp_id')\n\n var atomname1, atomname2, bondOrder\n n = ccb.comp_id.length\n var na = cca.comp_id.length\n\n var ap1 = structure.getAtomProxy()\n var ap2 = structure.getAtomProxy()\n\n for (i = 0; i < n; ++i) {\n atomname1 = ccb.atom_id_1[ i ].replace(reDoubleQuote, '')\n atomname2 = ccb.atom_id_2[ i ].replace(reDoubleQuote, '')\n bondOrder = getBondOrder(ccb.value_order[ i ])\n\n ap1.index = atomnameDict[ atomname1 ]\n ap2.index = atomnameDict[ atomname2 ]\n structure.bondStore.growIfFull()\n structure.bondStore.addBond(ap1, ap2, bondOrder)\n\n ap1.index += na\n ap2.index += na\n structure.bondStore.growIfFull()\n structure.bondStore.addBond(ap1, ap2, bondOrder)\n }\n }\n}\n\nfunction parseCore (cif: Cif, structure: Structure, structureBuilder: StructureBuilder) {\n var atomStore = structure.atomStore\n var atomMap = structure.atomMap\n\n if (cif.data) {\n structure.id = cif.data\n structure.name = cif.data\n }\n\n structure.unitcell = new Unitcell({\n a: parseFloat(cif.cell_length_a),\n b: parseFloat(cif.cell_length_b),\n c: parseFloat(cif.cell_length_c),\n alpha: parseFloat(cif.cell_angle_alpha),\n beta: parseFloat(cif.cell_angle_beta),\n gamma: parseFloat(cif.cell_angle_gamma),\n spacegroup: trimQuotes(cif['symmetry_space_group_name_H-M'])\n })\n\n const v = new Vector3()\n const c = new Vector3()\n const n = cif.atom_site_type_symbol.length\n\n const typeSymbolMap: Record = {}\n\n for (let i = 0; i < n; ++i) {\n atomStore.growIfFull()\n\n const atomname = cif.atom_site_label[ i ]\n const typeSymbol = cif.atom_site_type_symbol[ i ]\n\n // typeSymbol can be like `Al2.5+`. Retain element symbol only.\n let element = typeSymbolMap[typeSymbol]\n if (!element) {\n const match = typeSymbol.match(reAtomSymbol)\n typeSymbolMap[typeSymbol] = element = match?.[0] ?? typeSymbol\n }\n\n atomStore.atomTypeId[ i ] = atomMap.add(atomname, element)\n\n v.set(\n cif.atom_site_fract_x[ i ],\n cif.atom_site_fract_y[ i ],\n cif.atom_site_fract_z[ i ]\n )\n v.applyMatrix4(structure.unitcell.fracToCart)\n c.add(v)\n\n atomStore.x[ i ] = v.x\n atomStore.y[ i ] = v.y\n atomStore.z[ i ] = v.z\n if (cif.atom_site_occupancy) {\n atomStore.occupancy[ i ] = parseFloat(cif.atom_site_occupancy[ i ])\n }\n atomStore.serial[ i ] = i\n\n structureBuilder.addAtom(0, '', '', 'HET', 1, true)\n }\n\n c.divideScalar(n)\n structure.center = c\n buildUnitcellAssembly(structure)\n\n const v2 = new Vector3()\n const v3 = new Vector3()\n const ml = structure.biomolDict.SUPERCELL.partList[ 0 ].matrixList\n\n let k = n\n\n function covalent (idx: number) {\n return atomMap.get(atomStore.atomTypeId[ idx ]).covalent\n }\n const identityMatrix = new Matrix4()\n\n for (let i = 0; i < n; ++i) {\n const covalentI = covalent(i)\n\n v.set(\n atomStore.x[ i ],\n atomStore.y[ i ],\n atomStore.z[ i ]\n )\n\n ml.forEach(function (m) {\n if (identityMatrix.equals(m)) return\n\n v2.copy(v)\n v2.applyMatrix4(m)\n\n for (let j = 0; j < n; ++j) {\n v3.set(\n atomStore.x[ j ],\n atomStore.y[ j ],\n atomStore.z[ j ]\n )\n\n const distSquared = v2.distanceToSquared(v3)\n const d = covalent(j) + covalentI\n const d1 = d + 0.3\n const d2 = d - 0.5\n\n if (distSquared < (d1 * d1) && distSquared > (d2 * d2)) {\n atomStore.growIfFull()\n\n atomStore.atomTypeId[ k ] = atomStore.atomTypeId[ i ]\n atomStore.x[ k ] = v2.x\n atomStore.y[ k ] = v2.y\n atomStore.z[ k ] = v2.z\n atomStore.occupancy[ k ] = atomStore.occupancy[ i ]\n atomStore.serial[ k ] = k\n atomStore.altloc[ k ] = 'A'.charCodeAt(0)\n\n structureBuilder.addAtom(0, '', '', 'HET', 1, true)\n\n k += 1\n return\n }\n }\n })\n }\n}\n\nfunction processSecondaryStructure (cif: Cif, structure: Structure, asymIdDict: {[k: string]: string}) {\n var helices: [string, number, string, string, number, string, number][] = []\n var sheets: [string, number, string, string, number, string][] = []\n\n var i, il, begIcode, endIcode\n\n // get helices\n var sc = cif.struct_conf\n\n if (sc?.pdbx_PDB_helix_class) {\n ensureArray(sc, 'id')\n\n for (i = 0, il = sc.beg_auth_seq_id.length; i < il; ++i) {\n var helixType = parseInt(sc.pdbx_PDB_helix_class[ i ])\n if (!Number.isNaN(helixType)) {\n begIcode = sc.pdbx_beg_PDB_ins_code[ i ]\n endIcode = sc.pdbx_end_PDB_ins_code[ i ]\n helices.push([\n asymIdDict[ sc.beg_label_asym_id[ i ] ],\n parseInt(sc.beg_auth_seq_id[ i ]),\n cifDefaults(begIcode, ''),\n asymIdDict[ sc.end_label_asym_id[ i ] ],\n parseInt(sc.end_auth_seq_id[ i ]),\n cifDefaults(endIcode, ''),\n (HelixTypes[ helixType ] || HelixTypes[0]).charCodeAt(0)\n ])\n }\n }\n }\n\n // get sheets\n var ssr = cif.struct_sheet_range\n\n if (ssr) {\n ensureArray(ssr, 'id')\n\n for (i = 0, il = ssr.beg_auth_seq_id.length; i < il; ++i) {\n begIcode = ssr.pdbx_beg_PDB_ins_code[ i ]\n endIcode = ssr.pdbx_end_PDB_ins_code[ i ]\n sheets.push([\n asymIdDict[ ssr.beg_label_asym_id[ i ] ],\n parseInt(ssr.beg_auth_seq_id[ i ]),\n cifDefaults(begIcode, ''),\n asymIdDict[ ssr.end_label_asym_id[ i ] ],\n parseInt(ssr.end_auth_seq_id[ i ]),\n cifDefaults(endIcode, '')\n ])\n }\n }\n\n if (sc || ssr) {\n return {\n helices: helices,\n sheets: sheets\n }\n } else {\n return false\n }\n}\n\nfunction processSymmetry (cif: Cif, structure: Structure, asymIdDict: {[k: string]: string}) {\n // biomol & ncs processing\n var operDict: {[k: string]: Matrix4} = {}\n var biomolDict = structure.biomolDict\n\n if (cif.pdbx_struct_oper_list) {\n var biomolOp = cif.pdbx_struct_oper_list\n ensureArray(biomolOp, 'id')\n\n biomolOp.id.forEach(function (id: number, i: number) {\n var m = new Matrix4()\n var elms = m.elements\n\n elms[ 0 ] = parseFloat(biomolOp[ 'matrix[1][1]' ][ i ])\n elms[ 1 ] = parseFloat(biomolOp[ 'matrix[1][2]' ][ i ])\n elms[ 2 ] = parseFloat(biomolOp[ 'matrix[1][3]' ][ i ])\n\n elms[ 4 ] = parseFloat(biomolOp[ 'matrix[2][1]' ][ i ])\n elms[ 5 ] = parseFloat(biomolOp[ 'matrix[2][2]' ][ i ])\n elms[ 6 ] = parseFloat(biomolOp[ 'matrix[2][3]' ][ i ])\n\n elms[ 8 ] = parseFloat(biomolOp[ 'matrix[3][1]' ][ i ])\n elms[ 9 ] = parseFloat(biomolOp[ 'matrix[3][2]' ][ i ])\n elms[ 10 ] = parseFloat(biomolOp[ 'matrix[3][3]' ][ i ])\n\n elms[ 3 ] = parseFloat(biomolOp[ 'vector[1]' ][ i ])\n elms[ 7 ] = parseFloat(biomolOp[ 'vector[2]' ][ i ])\n elms[ 11 ] = parseFloat(biomolOp[ 'vector[3]' ][ i ])\n\n m.transpose()\n\n operDict[ id ] = m\n })\n }\n\n if (cif.pdbx_struct_assembly_gen) {\n var gen = cif.pdbx_struct_assembly_gen\n ensureArray(gen, 'assembly_id')\n\n var getMatrixDict = function (expr: string) {\n var matDict: {[k: string]: Matrix4} = {}\n\n var l = expr.replace(/[()']/g, '').split(',')\n\n l.forEach(function (e) {\n if (e.includes('-')) {\n var es = e.split('-')\n\n var j = parseInt(es[ 0 ])\n var m = parseInt(es[ 1 ])\n\n for (; j <= m; ++j) {\n matDict[ j ] = operDict[ j ]\n }\n } else {\n matDict[ e ] = operDict[ e ]\n }\n })\n\n return matDict\n }\n\n gen.assembly_id.forEach(function (id: string, i: number) {\n var md:{[k: string]: Matrix4} = {}\n var oe = gen.oper_expression[ i ].replace(/['\"]\\(|['\"]/g, '')\n\n if (oe.includes(')(') || oe.indexOf('(') > 0) {\n oe = oe.split('(')\n\n var md1 = getMatrixDict(oe[ 0 ])\n var md2 = getMatrixDict(oe[ 1 ])\n\n Object.keys(md1).forEach(function (k1) {\n Object.keys(md2).forEach(function (k2) {\n var mat = new Matrix4()\n\n mat.multiplyMatrices(md1[ k1 ], md2[ k2 ])\n md[ k1 + 'x' + k2 ] = mat\n })\n })\n } else {\n md = getMatrixDict(oe)\n }\n\n var matrixList = []\n for (var k in md) {\n matrixList.push(md[ k ])\n }\n\n var name = id\n if (/^(0|[1-9][0-9]*)$/.test(name)) name = 'BU' + name\n\n var chainList = gen.asym_id_list[ i ].split(',')\n for (var j = 0, jl = chainList.length; j < jl; ++j) {\n chainList[ j ] = asymIdDict[ chainList[ j ] ]\n }\n\n if (biomolDict[ name ] === undefined) {\n biomolDict[ name ] = new Assembly(name)\n }\n biomolDict[ name ].addPart(matrixList, chainList)\n })\n }\n\n // non-crystallographic symmetry operations\n if (cif.struct_ncs_oper) {\n var ncsOp = cif.struct_ncs_oper\n ensureArray(ncsOp, 'id')\n\n var ncsName = 'NCS'\n biomolDict[ ncsName ] = new Assembly(ncsName)\n var ncsPart = biomolDict[ ncsName ].addPart()\n\n ncsOp.id.forEach(function (id: string, i: number) {\n // ignore 'given' operators\n if (ncsOp.code[ i ] === 'given') return\n\n var m = new Matrix4()\n var elms = m.elements\n\n elms[ 0 ] = parseFloat(ncsOp[ 'matrix[1][1]' ][ i ])\n elms[ 1 ] = parseFloat(ncsOp[ 'matrix[1][2]' ][ i ])\n elms[ 2 ] = parseFloat(ncsOp[ 'matrix[1][3]' ][ i ])\n\n elms[ 4 ] = parseFloat(ncsOp[ 'matrix[2][1]' ][ i ])\n elms[ 5 ] = parseFloat(ncsOp[ 'matrix[2][2]' ][ i ])\n elms[ 6 ] = parseFloat(ncsOp[ 'matrix[2][3]' ][ i ])\n\n elms[ 8 ] = parseFloat(ncsOp[ 'matrix[3][1]' ][ i ])\n elms[ 9 ] = parseFloat(ncsOp[ 'matrix[3][2]' ][ i ])\n elms[ 10 ] = parseFloat(ncsOp[ 'matrix[3][3]' ][ i ])\n\n elms[ 3 ] = parseFloat(ncsOp[ 'vector[1]' ][ i ])\n elms[ 7 ] = parseFloat(ncsOp[ 'vector[2]' ][ i ])\n elms[ 11 ] = parseFloat(ncsOp[ 'vector[3]' ][ i ])\n\n m.transpose()\n\n ncsPart.matrixList.push(m)\n })\n\n if (ncsPart.matrixList.length === 0) {\n delete biomolDict[ ncsName ]\n }\n }\n\n // cell & symmetry\n const unitcellDict: {\n a?: number\n b?: number\n c?: number\n alpha?: number\n beta?: number\n gamma?: number\n spacegroup?: string\n origx?: Matrix4\n scale?: Matrix4\n } = {}\n\n if (cif.cell) {\n const cell = cif.cell\n\n const a = parseFloat(cell.length_a)\n const b = parseFloat(cell.length_b)\n const c = parseFloat(cell.length_c)\n\n const box = new Float32Array(9)\n box[ 0 ] = a\n box[ 4 ] = b\n box[ 8 ] = c\n structure.boxes.push(box)\n\n unitcellDict.a = a\n unitcellDict.b = b\n unitcellDict.c = c\n unitcellDict.alpha = parseFloat(cell.angle_alpha)\n unitcellDict.beta = parseFloat(cell.angle_beta)\n unitcellDict.gamma = parseFloat(cell.angle_gamma)\n }\n\n if (cif.symmetry) {\n unitcellDict.spacegroup = trimQuotes(\n cif.symmetry[ 'space_group_name_H-M' ]\n )\n }\n\n // origx\n var origx = new Matrix4()\n\n if (cif.database_PDB_matrix) {\n var origxMat = cif.database_PDB_matrix\n var origxElms = origx.elements\n\n origxElms[ 0 ] = parseFloat(origxMat[ 'origx[1][1]' ])\n origxElms[ 1 ] = parseFloat(origxMat[ 'origx[1][2]' ])\n origxElms[ 2 ] = parseFloat(origxMat[ 'origx[1][3]' ])\n\n origxElms[ 4 ] = parseFloat(origxMat[ 'origx[2][1]' ])\n origxElms[ 5 ] = parseFloat(origxMat[ 'origx[2][2]' ])\n origxElms[ 6 ] = parseFloat(origxMat[ 'origx[2][3]' ])\n\n origxElms[ 8 ] = parseFloat(origxMat[ 'origx[3][1]' ])\n origxElms[ 9 ] = parseFloat(origxMat[ 'origx[3][2]' ])\n origxElms[ 10 ] = parseFloat(origxMat[ 'origx[3][3]' ])\n\n origxElms[ 3 ] = parseFloat(origxMat[ 'origx_vector[1]' ])\n origxElms[ 7 ] = parseFloat(origxMat[ 'origx_vector[2]' ])\n origxElms[ 11 ] = parseFloat(origxMat[ 'origx_vector[3]' ])\n\n origx.transpose()\n\n unitcellDict.origx = origx\n }\n\n // scale\n var scale = new Matrix4()\n\n if (cif.atom_sites) {\n var scaleMat = cif.atom_sites\n var scaleElms = scale.elements\n\n scaleElms[ 0 ] = parseFloat(scaleMat[ 'fract_transf_matrix[1][1]' ])\n scaleElms[ 1 ] = parseFloat(scaleMat[ 'fract_transf_matrix[1][2]' ])\n scaleElms[ 2 ] = parseFloat(scaleMat[ 'fract_transf_matrix[1][3]' ])\n\n scaleElms[ 4 ] = parseFloat(scaleMat[ 'fract_transf_matrix[2][1]' ])\n scaleElms[ 5 ] = parseFloat(scaleMat[ 'fract_transf_matrix[2][2]' ])\n scaleElms[ 6 ] = parseFloat(scaleMat[ 'fract_transf_matrix[2][3]' ])\n\n scaleElms[ 8 ] = parseFloat(scaleMat[ 'fract_transf_matrix[3][1]' ])\n scaleElms[ 9 ] = parseFloat(scaleMat[ 'fract_transf_matrix[3][2]' ])\n scaleElms[ 10 ] = parseFloat(scaleMat[ 'fract_transf_matrix[3][3]' ])\n\n scaleElms[ 3 ] = parseFloat(scaleMat[ 'fract_transf_vector[1]' ])\n scaleElms[ 7 ] = parseFloat(scaleMat[ 'fract_transf_vector[2]' ])\n scaleElms[ 11 ] = parseFloat(scaleMat[ 'fract_transf_vector[3]' ])\n\n scale.transpose()\n\n unitcellDict.scale = scale\n }\n\n if (unitcellDict.a !== undefined) {\n structure.unitcell = new Unitcell(unitcellDict as UnitcellParams)\n } else {\n structure.unitcell = undefined\n }\n}\n\nfunction processConnections (cif: Cif, structure: Structure, asymIdDict: {[k: string]: string}) {\n // add connections\n var sc = cif.struct_conn\n\n if (sc) {\n ensureArray(sc, 'id')\n\n var reDoubleQuote = /\"/g\n var ap1 = structure.getAtomProxy()\n var ap2 = structure.getAtomProxy()\n var atomIndicesCache: {[k: string]: Uint32Array|undefined} = {}\n\n for (var i = 0, il = sc.id.length; i < il; ++i) {\n // ignore:\n // hydrog - hydrogen bond\n // mismat - mismatched base pairs\n // saltbr - ionic interaction\n\n var connTypeId = sc.conn_type_id[ i ]\n if (connTypeId === 'hydrog' ||\n connTypeId === 'mismat' ||\n connTypeId === 'saltbr') continue\n\n // ignore bonds between symmetry mates\n if (sc.ptnr1_symmetry[ i ] !== '1_555' ||\n sc.ptnr2_symmetry[ i ] !== '1_555') continue\n\n // process:\n // covale - covalent bond\n // covale_base -\n // covalent modification of a nucleotide base\n // covale_phosphate -\n // covalent modification of a nucleotide phosphate\n // covale_sugar -\n // covalent modification of a nucleotide sugar\n // disulf - disulfide bridge\n // metalc - metal coordination\n // modres - covalent residue modification\n\n var inscode1 = sc.pdbx_ptnr1_PDB_ins_code[ i ]\n var altloc1 = sc.pdbx_ptnr1_label_alt_id[ i ]\n var sele1 = (\n sc.ptnr1_auth_seq_id[ i ] +\n (hasValue(inscode1) ? ('^' + inscode1) : '') +\n ':' + asymIdDict[ sc.ptnr1_label_asym_id[ i ] ] +\n '.' + sc.ptnr1_label_atom_id[ i ].replace(reDoubleQuote, '') +\n (hasValue(altloc1) ? ('%' + altloc1) : '')\n )\n var atomIndices1 = atomIndicesCache[ sele1 ]\n if (!atomIndices1) {\n var selection1 = new Selection(sele1)\n if (selection1.selection.error) {\n if (Debug) Log.warn('invalid selection for connection', sele1)\n continue\n }\n atomIndices1 = structure.getAtomIndices(selection1)\n atomIndicesCache[ sele1 ] = atomIndices1\n }\n\n var inscode2 = sc.pdbx_ptnr2_PDB_ins_code[ i ]\n var altloc2 = sc.pdbx_ptnr2_label_alt_id[ i ]\n var sele2 = (\n sc.ptnr2_auth_seq_id[ i ] +\n (hasValue(inscode2) ? ('^' + inscode2) : '') +\n ':' + asymIdDict[ sc.ptnr2_label_asym_id[ i ] ] +\n '.' + sc.ptnr2_label_atom_id[ i ].replace(reDoubleQuote, '') +\n (hasValue(altloc2) ? ('%' + altloc2) : '')\n )\n var atomIndices2 = atomIndicesCache[ sele2 ]\n if (!atomIndices2) {\n var selection2 = new Selection(sele2)\n if (selection2.selection.error) {\n if (Debug) Log.warn('invalid selection for connection', sele2)\n continue\n }\n atomIndices2 = structure.getAtomIndices(selection2)\n atomIndicesCache[ sele2 ] = atomIndices2\n }\n\n // cases with more than one atom per selection\n // - #altloc1 to #altloc2\n // - #model to #model\n // - #altloc1 * #model to #altloc2 * #model\n\n var k = atomIndices1!.length\n var l = atomIndices2!.length\n\n if (k > l) {\n var tmpA = k\n k = l\n l = tmpA\n var tmpB = atomIndices1\n atomIndices1 = atomIndices2\n atomIndices2 = tmpB\n }\n\n // console.log( k, l );\n\n if (k === 0 || l === 0) {\n if (Debug) Log.warn('no atoms found for', sele1, sele2)\n continue\n }\n\n for (var j = 0; j < l; ++j) {\n ap1.index = atomIndices1![ j % k ]\n ap2.index = atomIndices2![ j ]\n\n if (ap1 && ap2) {\n structure.bondStore.addBond(\n ap1, ap2, getBondOrder(sc.pdbx_value_order[ i ])\n )\n } else {\n Log.log('atoms for connection not found')\n }\n }\n }\n }\n}\n\nfunction processEntities (cif: Cif, structure: Structure, chainIndexDict: {[k: string]: Set}) {\n if (cif.entity) {\n ensureArray(cif.entity, 'id')\n var e = cif.entity\n var n = e.id.length\n for (var i = 0; i < n; ++i) {\n var description = e.pdbx_description[ i ]\n var type = e.type[ i ]\n var chainIndexList: number[] = Array.from(chainIndexDict[ e.id[ i ] ])\n structure.entityList[ i ] = new Entity(\n structure, i, description, type, chainIndexList\n )\n }\n }\n}\n\n//\n\nclass CifParser extends StructureParser {\n get type () { return 'cif' }\n\n _parse () {\n // http://mmcif.wwpdb.org/\n\n Log.time('CifParser._parse ' + this.name)\n\n var s = this.structure\n var sb = this.structureBuilder\n\n var firstModelOnly = this.firstModelOnly\n var asTrajectory = this.asTrajectory\n var cAlphaOnly = this.cAlphaOnly\n\n var frames = s.frames\n var currentFrame: NumberArray, currentCoord: number\n\n var rawline, line\n\n //\n\n var cif: Cif = {}\n var asymIdDict: {[k: string]: string} = {}\n var chainIndexDict:{[k: string]: Set} = {}\n\n var pendingString = false\n var currentString: string|null = null\n var pendingValue = false\n var pendingLoop = false\n var pendingName = false\n var loopPointers: string[][] = []\n var currentLoopIndex: number|null = null\n var currentCategory: string|null = null\n var currentName: string|boolean|null = null\n var first: boolean|null = null\n var pointerNames: string[] = []\n\n var authAsymId: number, authSeqId: number, labelSeqId: number,\n labelAtomId: number, labelCompId: number, labelAsymId: number, labelEntityId: number, labelAltId: number,\n groupPDB: number, id: number, typeSymbol: number, pdbxPDBmodelNum: number, pdbxPDBinsCode: number,\n CartnX: number, CartnY: number, CartnZ: number, bIsoOrEquiv: number, occupancy: number\n\n //\n\n var atomMap = s.atomMap\n var atomStore = s.atomStore\n atomStore.resize(this.streamer.data.length / 100)\n\n var idx = 0\n var modelIdx = 0\n var modelNum: number\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (var i = _i; i < _n; ++i) {\n rawline = lines[i]\n line = rawline.trim()\n\n if ((!line && !pendingString && !pendingLoop) || line[0] === '#') {\n // Log.log( \"NEW BLOCK\" );\n\n pendingString = false\n pendingLoop = false\n pendingValue = false\n loopPointers.length = 0\n currentLoopIndex = null\n currentCategory = null\n currentName = null\n first = null\n pointerNames.length = 0\n } else if (line.substring(0, 5) === 'data_') {\n cif.data = line.substring(5).trim()\n\n // Log.log( \"DATA\", data );\n } else if (line[0] === ';') {\n if (pendingString) {\n // Log.log( \"STRING END\", currentString );\n\n if (pendingLoop) {\n if (currentLoopIndex === loopPointers.length) {\n currentLoopIndex = 0\n }\n loopPointers[ currentLoopIndex as number ].push(currentString as string);\n (currentLoopIndex as number) += 1\n } else {\n if (currentName === false) {\n cif[ currentCategory as string ] = currentString\n } else {\n cif[ currentCategory as string ][ currentName as string ] = currentString //TODO currentname can equals null\n }\n }\n\n pendingString = false\n currentString = null\n } else {\n // Log.log( \"STRING START\" );\n\n pendingString = true\n currentString = line.substring(1)\n }\n } else if (line === 'loop_') {\n // Log.log( \"LOOP START\" );\n\n pendingLoop = true\n pendingName = true\n loopPointers.length = 0\n pointerNames.length = 0\n currentLoopIndex = 0\n } else if (line[0] === '_') {\n var keyParts, category, name\n\n if (pendingLoop && !pendingName) {\n pendingLoop = false\n }\n\n if (pendingLoop) {\n // Log.log( \"LOOP KEY\", line );\n\n keyParts = line.split('.')\n category = keyParts[ 0 ].substring(1)\n name = keyParts[ 1 ]\n\n if (keyParts.length === 1) {\n name = false\n if (!cif[ category ]) cif[ category ] = []\n loopPointers.push(cif[ category ])\n } else {\n if (!cif[ category ]) cif[ category ] = {}\n if (cif[ category ][ name ]) {\n if (Debug) Log.warn(category, name, 'already exists')\n } else {\n cif[ category ][ name ] = []\n loopPointers.push(cif[ category ][ name ])\n pointerNames.push(name)\n }\n }\n\n currentCategory = category\n currentName = name\n first = true\n } else {\n var keyValuePair = line.match(reQuotedWhitespace)\n var key = keyValuePair![ 0 ]\n var value = keyValuePair![ 1 ]\n keyParts = key.split('.')\n category = keyParts[ 0 ].substring(1)\n name = keyParts[ 1 ]\n\n if (keyParts.length === 1) {\n name = false\n cif[ category ] = value\n } else {\n if (!cif[ category ]) cif[ category ] = {}\n\n if (cif[ category ][ name ]) {\n if (Debug) Log.warn(category, name, 'already exists')\n } else {\n cif[ category ][ name ] = value\n }\n }\n\n if (!value) pendingValue = true\n\n currentCategory = category\n currentName = name\n }\n } else {\n if (pendingString) {\n // Log.log( \"STRING VALUE\", line );\n\n currentString += rawline\n } else if (pendingLoop) {\n // Log.log( \"LOOP VALUE\", line );\n\n if (!line) {\n continue\n } else if (currentCategory === 'atom_site') {\n const ls = line.split(reWhitespace)\n\n if (first) {\n authAsymId = pointerNames.indexOf('auth_asym_id')\n authSeqId = pointerNames.indexOf('auth_seq_id')\n labelSeqId = pointerNames.indexOf('label_seq_id')\n labelAtomId = pointerNames.indexOf('label_atom_id')\n labelCompId = pointerNames.indexOf('label_comp_id')\n labelAsymId = pointerNames.indexOf('label_asym_id')\n labelEntityId = pointerNames.indexOf('label_entity_id')\n labelAltId = pointerNames.indexOf('label_alt_id')\n CartnX = pointerNames.indexOf('Cartn_x')\n CartnY = pointerNames.indexOf('Cartn_y')\n CartnZ = pointerNames.indexOf('Cartn_z')\n id = pointerNames.indexOf('id')\n typeSymbol = pointerNames.indexOf('type_symbol')\n groupPDB = pointerNames.indexOf('group_PDB')\n bIsoOrEquiv = pointerNames.indexOf('B_iso_or_equiv')\n pdbxPDBmodelNum = pointerNames.indexOf('pdbx_PDB_model_num')\n\n pdbxPDBinsCode = pointerNames.indexOf('pdbx_PDB_ins_code')\n occupancy = pointerNames.indexOf('occupancy')\n\n first = false\n\n modelNum = parseInt(ls[ pdbxPDBmodelNum ])\n\n if (asTrajectory) {\n currentFrame = []\n currentCoord = 0\n }\n }\n\n //\n\n const _modelNum = parseInt(ls[ pdbxPDBmodelNum ])\n\n if (modelNum !== _modelNum) {\n if (asTrajectory) {\n if (modelIdx === 0) {\n frames.push(new Float32Array(currentFrame))\n }\n\n currentFrame = new Float32Array(atomStore.count * 3)\n frames.push(currentFrame)\n currentCoord = 0\n }\n\n modelIdx += 1\n }\n\n modelNum = _modelNum\n\n if (firstModelOnly && modelIdx > 0) continue\n\n //\n\n const atomname = ls[ labelAtomId ].replace(reDoubleQuote, '')\n if (cAlphaOnly && atomname !== 'CA') continue\n\n const x = parseFloat(ls[ CartnX ])\n const y = parseFloat(ls[ CartnY ])\n const z = parseFloat(ls[ CartnZ ])\n\n if (asTrajectory) {\n const frameOffset = currentCoord * 3\n\n currentFrame[ frameOffset + 0 ] = x\n currentFrame[ frameOffset + 1 ] = y\n currentFrame[ frameOffset + 2 ] = z\n\n currentCoord += 1\n\n if (modelIdx > 0) continue\n }\n\n //\n\n const resname = ls[ labelCompId ]\n const resno = parseInt(ls[ authSeqId !== -1 ? authSeqId : labelSeqId ])\n let inscode = ls[ pdbxPDBinsCode ]\n inscode = (inscode === '?') ? '' : inscode\n const chainname = ls[ authAsymId ]\n const chainid = ls[ labelAsymId ]\n const hetero = (ls[ groupPDB ][ 0 ] === 'H')\n\n //\n\n const element = ls[ typeSymbol ]\n const bfactor = parseFloat(ls[ bIsoOrEquiv ])\n const occ = parseFloat(ls[ occupancy ])\n let altloc = ls[ labelAltId ]\n altloc = (altloc === '.') ? '' : altloc\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname, element)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = parseInt(ls[ id ])\n atomStore.bfactor[ idx ] = isNaN(bfactor) ? 0 : bfactor\n atomStore.occupancy[ idx ] = isNaN(occ) ? 0 : occ\n atomStore.altloc[ idx ] = altloc.charCodeAt(0)\n\n sb.addAtom(modelIdx, chainname, chainid, resname, resno, hetero, undefined, inscode)\n\n if (Debug) {\n // check if one-to-many (chainname-asymId) relationship is\n // actually a many-to-many mapping\n const assignedChainname = asymIdDict[ chainid ]\n if (assignedChainname !== undefined && assignedChainname !== chainname) {\n if (Debug) Log.warn(assignedChainname, chainname)\n }\n }\n // chainname mapping: label_asym_id -> auth_asym_id\n asymIdDict[ chainid ] = chainname\n\n // entity mapping: chainIndex -> label_entity_id\n const entityId = ls[ labelEntityId ]\n if (!chainIndexDict[ entityId ]) {\n chainIndexDict[ entityId ] = new Set()\n }\n chainIndexDict[ entityId ].add(s.chainStore.count - 1)\n\n idx += 1\n } else {\n const ls = line.match(reQuotedWhitespace)\n const nn = ls!.length\n\n if (currentLoopIndex === loopPointers.length) {\n currentLoopIndex = 0\n }/* else if( currentLoopIndex + nn > loopPointers.length ){\n Log.warn( \"cif parsing error, wrong number of loop data entries\", nn, loopPointers.length );\n } */\n\n for (let j = 0; j < nn; ++j) {\n loopPointers[ currentLoopIndex + j ].push(ls![ j ])\n }\n\n (currentLoopIndex) += nn\n }\n\n pendingName = false\n } else if (line[0] === \"'\" && line[line.length - 1] === \"'\") {\n // Log.log( \"NEWLINE STRING\", line );\n\n const str = line.substring(1, line.length - 1)\n\n if (currentName === false) {\n cif[ currentCategory as string ] = str\n } else {\n cif[ currentCategory as string ][ currentName as string ] = str\n }\n } else if (pendingValue) {\n // Log.log( \"NEWLINE VALUE\", line );\n\n if (currentName === false) {\n cif[ currentCategory as string ] = line\n } else {\n cif[ currentCategory as string ][ currentName as string ] = line\n }\n } else {\n if (Debug) Log.log('CifParser._parse: unknown state', line)\n }\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n if (cif.chem_comp && cif.chem_comp_atom && !cif.struct) {\n parseChemComp(cif, s, sb)\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n assignResidueTypeBonds(s)\n } else if (cif.atom_site_type_symbol && cif.atom_site_label && cif.atom_site_fract_x) {\n parseCore(cif, s, sb)\n sb.finalize()\n s.finalizeAtoms()\n calculateBonds(s)\n s.finalizeBonds()\n // assignResidueTypeBonds( s );\n } else {\n var secStruct = processSecondaryStructure(cif, s, asymIdDict)\n processSymmetry(cif, s, asymIdDict)\n processConnections(cif, s, asymIdDict)\n processEntities(cif, s, chainIndexDict)\n\n if (cif.struct && cif.struct.title) {\n s.title = cif.struct.title.trim().replace(reTrimQuotes, '')\n }\n if (cif.entry && cif.entry.id) {\n s.id = cif.entry.id.trim().replace(reTrimQuotes, '')\n }\n\n // structure header (mimicking biojava)\n if (cif.pdbx_audit_revision_history) {\n if (cif.pdbx_audit_revision_history.revision_date) {\n ensureArray(cif.pdbx_audit_revision_history, 'revision_date')\n const dates = cif.pdbx_audit_revision_history.revision_date.filter(hasValue)\n if (dates.length) {\n s.header.releaseDate = dates[ 0 ]\n }\n }\n if (cif.pdbx_database_status.recvd_initial_deposition_date) {\n ensureArray(cif.pdbx_database_status, 'recvd_initial_deposition_date')\n const depDates = cif.pdbx_database_status.recvd_initial_deposition_date.filter(hasValue)\n if (depDates.length) {\n s.header.depositionDate = depDates[ 0 ]\n }\n }\n } else if (cif.database_PDB_rev) {\n if (cif.database_PDB_rev.date) {\n ensureArray(cif.database_PDB_rev, 'date')\n const dates = cif.database_PDB_rev.date.filter(hasValue)\n if (dates.length) {\n s.header.releaseDate = dates[ 0 ]\n }\n }\n if (cif.database_PDB_rev.date_original) {\n ensureArray(cif.database_PDB_rev, 'date_original')\n const depDates = cif.database_PDB_rev.date_original.filter(hasValue)\n if (depDates.length) {\n s.header.depositionDate = depDates[ 0 ]\n }\n }\n }\n if (cif.reflns && cif.reflns.d_resolution_high) {\n if (hasValue(cif.reflns.d_resolution_high)) {\n s.header.resolution = parseFloat(cif.reflns.d_resolution_high)\n }\n } else if (cif.refine && cif.refine.ls_d_res_high) {\n if (hasValue(cif.refine.ls_d_res_high)) {\n s.header.resolution = parseFloat(cif.refine.ls_d_res_high)\n }\n }\n if (cif.refine && cif.refine.ls_R_factor_R_free) {\n if (hasValue(cif.refine.ls_R_factor_R_free)) {\n s.header.rFree = parseFloat(cif.refine.ls_R_factor_R_free)\n }\n }\n if (cif.refine && cif.refine.ls_R_factor_R_work) {\n if (hasValue(cif.refine.ls_R_factor_R_work)) {\n s.header.rWork = parseFloat(cif.refine.ls_R_factor_R_work)\n }\n }\n if (cif.exptl && cif.exptl.method) {\n ensureArray(cif.exptl, 'method')\n s.header.experimentalMethods = cif.exptl.method.map(function (m: string) {\n return m.replace(reTrimQuotes, '')\n })\n }\n\n sb.finalize()\n s.finalizeAtoms()\n calculateBonds(s)\n s.finalizeBonds()\n\n if (!secStruct) {\n calculateSecondaryStructure(s)\n } else {\n assignSecondaryStructure(s, secStruct)\n }\n buildUnitcellAssembly(s)\n\n s.extraData.cif = cif\n }\n\n if (Debug) Log.timeEnd('CifParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('cif', CifParser)\nParserRegistry.add('mcif', CifParser)\nParserRegistry.add('mmcif', CifParser)\n\nexport default CifParser\n","/**\n * @file Gro Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport {\n calculateBonds, calculateChainnames, calculateSecondaryStructure\n} from '../structure/structure-utils'\n\nclass GroParser extends StructureParser {\n get type () { return 'gro' }\n\n _parse () {\n // http://manual.gromacs.org/current/online/gro.html\n\n if (Debug) Log.time('GroParser._parse ' + this.name)\n\n var s = this.structure\n var sb = this.structureBuilder\n\n var firstModelOnly = this.firstModelOnly\n var asTrajectory = this.asTrajectory\n var cAlphaOnly = this.cAlphaOnly\n\n var frames = s.frames\n var boxes = s.boxes\n var currentFrame: Float32Array, currentCoord: number\n\n var firstLines = this.streamer.peekLines(3)\n\n s.title = firstLines[ 0 ].trim()\n\n // determine number of decimal places\n var ndec = firstLines[ 2 ].length - firstLines[ 2 ].lastIndexOf('.') - 1\n var lpos = 5 + ndec\n var xpos = 20\n var ypos = 20 + lpos\n var zpos = 20 + 2 * lpos\n\n //\n\n var atomname, resname, resno, serial\n\n var atomCount = parseInt(firstLines[ 1 ])\n var modelLineCount = atomCount + 3\n\n var atomMap = s.atomMap\n var atomStore = s.atomStore\n atomStore.resize(atomCount)\n\n var idx = 0\n var modelIdx = 0\n var lineNo = 0\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (var i = _i; i < _n; ++i) {\n ++lineNo\n var l = lineNo - 1\n\n var line = lines[ i ]\n\n if (!line) continue\n\n if (l % modelLineCount === 0) {\n // Log.log( \"title\", line )\n\n if (asTrajectory) {\n currentFrame = new Float32Array(atomCount * 3)\n frames.push(currentFrame)\n currentCoord = 0\n }\n } else if (l % modelLineCount === 1) {\n\n // Log.log( \"atomCount\", line )\n\n } else if (l % modelLineCount === modelLineCount - 1) {\n var str = line.trim().split(/\\s+/)\n var box = new Float32Array(9)\n box[ 0 ] = parseFloat(str[ 0 ]) * 10\n box[ 4 ] = parseFloat(str[ 1 ]) * 10\n box[ 8 ] = parseFloat(str[ 2 ]) * 10\n boxes.push(box)\n\n if (firstModelOnly) {\n return true\n }\n\n modelIdx += 1\n } else {\n atomname = line.substr(10, 5).trim()\n if (cAlphaOnly && atomname !== 'CA') continue\n\n var x = parseFloat(line.substr(xpos, lpos)) * 10\n var y = parseFloat(line.substr(ypos, lpos)) * 10\n var z = parseFloat(line.substr(zpos, lpos)) * 10\n\n if (asTrajectory) {\n var j = currentCoord * 3\n\n currentFrame[ j + 0 ] = x\n currentFrame[ j + 1 ] = y\n currentFrame[ j + 2 ] = z\n\n currentCoord += 1\n\n if (l > modelLineCount) continue\n }\n\n resname = line.substr(5, 5).trim()\n resno = parseInt(line.substr(0, 5))\n serial = parseInt(line.substr(15, 5))\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = serial\n\n sb.addAtom(modelIdx, '', '', resname, resno, false, 'l')\n\n idx += 1\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n sb.finalize()\n s.finalizeAtoms()\n calculateChainnames(s)\n calculateBonds(s)\n s.finalizeBonds()\n\n calculateSecondaryStructure(s)\n\n if (Debug) Log.timeEnd('GroParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('gro', GroParser)\n\nexport default GroParser\n","/**\n * @file utf8-utils\n * @private\n * @author Alexander Rose \n * mostly copied from https://github.com/creationix/msgpack-js-browser\n * by Tim Caswell , MIT License, Copyright (c) 2013\n */\n\n\n// Encode string as utf8 into dataview at offset\nfunction utf8Write(view, offset, string) {\n var byteLength = view.byteLength;\n for(var i = 0, l = string.length; i < l; i++) {\n var codePoint = string.charCodeAt(i);\n\n // One byte of UTF-8\n if (codePoint < 0x80) {\n view.setUint8(offset++, codePoint >>> 0 & 0x7f | 0x00);\n continue;\n }\n\n // Two bytes of UTF-8\n if (codePoint < 0x800) {\n view.setUint8(offset++, codePoint >>> 6 & 0x1f | 0xc0);\n view.setUint8(offset++, codePoint >>> 0 & 0x3f | 0x80);\n continue;\n }\n\n // Three bytes of UTF-8.\n if (codePoint < 0x10000) {\n view.setUint8(offset++, codePoint >>> 12 & 0x0f | 0xe0);\n view.setUint8(offset++, codePoint >>> 6 & 0x3f | 0x80);\n view.setUint8(offset++, codePoint >>> 0 & 0x3f | 0x80);\n continue;\n }\n\n // Four bytes of UTF-8\n if (codePoint < 0x110000) {\n view.setUint8(offset++, codePoint >>> 18 & 0x07 | 0xf0);\n view.setUint8(offset++, codePoint >>> 12 & 0x3f | 0x80);\n view.setUint8(offset++, codePoint >>> 6 & 0x3f | 0x80);\n view.setUint8(offset++, codePoint >>> 0 & 0x3f | 0x80);\n continue;\n }\n throw new Error(\"bad codepoint \" + codePoint);\n }\n}\n\nfunction utf8ByteCount(string) {\n var count = 0;\n for(var i = 0, l = string.length; i < l; i++) {\n var codePoint = string.charCodeAt(i);\n if (codePoint < 0x80) {\n count += 1;\n continue;\n }\n if (codePoint < 0x800) {\n count += 2;\n continue;\n }\n if (codePoint < 0x10000) {\n count += 3;\n continue;\n }\n if (codePoint < 0x110000) {\n count += 4;\n continue;\n }\n throw new Error(\"bad codepoint \" + codePoint);\n }\n return count;\n}\n\n/**\n * encode data value (recursively) into binary encoded MessagePack v5 (http://msgpack.org/)\n * @param {Object|Array|String|Number|Boolean|null} value [description]\n * @param {DataView} view [description]\n * @param {Integer} offset [description]\n * @return {Integer} number of bytes written into view\n */\nfunction encode$1(value, view, offset) {\n var type = typeof value;\n\n // Strings Bytes\n if (type === \"string\") {\n var length = utf8ByteCount(value);\n // fix str\n if (length < 0x20) {\n view.setUint8(offset, length | 0xa0);\n utf8Write(view, offset + 1, value);\n return 1 + length;\n }\n // str 8\n if (length < 0x100) {\n view.setUint8(offset, 0xd9);\n view.setUint8(offset + 1, length);\n utf8Write(view, offset + 2, value);\n return 2 + length;\n }\n // str 16\n if (length < 0x10000) {\n view.setUint8(offset, 0xda);\n view.setUint16(offset + 1, length);\n utf8Write(view, offset + 3, value);\n return 3 + length;\n }\n // str 32\n if (length < 0x100000000) {\n view.setUint8(offset, 0xdb);\n view.setUint32(offset + 1, length);\n utf8Write(view, offset + 5, value);\n return 5 + length;\n }\n }\n\n if (value instanceof Uint8Array) {\n var length = value.byteLength;\n var bytes = new Uint8Array(view.buffer);\n // bin 8\n if (length < 0x100) {\n view.setUint8(offset, 0xc4);\n view.setUint8(offset + 1, length);\n bytes.set(value, offset + 2);\n return 2 + length;\n }\n // bin 16\n if (length < 0x10000) {\n view.setUint8(offset, 0xc5);\n view.setUint16(offset + 1, length);\n bytes.set(value, offset + 3);\n return 3 + length;\n }\n // bin 32\n if (length < 0x100000000) {\n view.setUint8(offset, 0xc6);\n view.setUint32(offset + 1, length);\n bytes.set(value, offset + 5);\n return 5 + length;\n }\n }\n\n if (type === \"number\") {\n if (!isFinite(value)) {\n throw new Error(\"Number not finite: \" + value);\n }\n\n // Floating point\n if (Math.floor(value) !== value) {\n view.setUint8(offset, 0xcb);\n view.setFloat64(offset + 1, value);\n return 9;\n }\n\n // Integers\n if (value >=0) {\n // positive fixnum\n if (value < 0x80) {\n view.setUint8(offset, value);\n return 1;\n }\n // uint 8\n if (value < 0x100) {\n view.setUint8(offset, 0xcc);\n view.setUint8(offset + 1, value);\n return 2;\n }\n // uint 16\n if (value < 0x10000) {\n view.setUint8(offset, 0xcd);\n view.setUint16(offset + 1, value);\n return 3;\n }\n // uint 32\n if (value < 0x100000000) {\n view.setUint8(offset, 0xce);\n view.setUint32(offset + 1, value);\n return 5;\n }\n throw new Error(\"Number too big 0x\" + value.toString(16));\n }\n // negative fixnum\n if (value >= -0x20) {\n view.setInt8(offset, value);\n return 1;\n }\n // int 8\n if (value >= -0x80) {\n view.setUint8(offset, 0xd0);\n view.setInt8(offset + 1, value);\n return 2;\n }\n // int 16\n if (value >= -0x8000) {\n view.setUint8(offset, 0xd1);\n view.setInt16(offset + 1, value);\n return 3;\n }\n // int 32\n if (value >= -0x80000000) {\n view.setUint8(offset, 0xd2);\n view.setInt32(offset + 1, value);\n return 5;\n }\n throw new Error(\"Number too small -0x\" + (-value).toString(16).substr(1));\n }\n\n // null\n if (value === null) {\n view.setUint8(offset, 0xc0);\n return 1;\n }\n\n // Boolean\n if (type === \"boolean\") {\n view.setUint8(offset, value ? 0xc3 : 0xc2);\n return 1;\n }\n\n // Container Types\n if (type === \"object\") {\n var length, size = 0;\n var isArray = Array.isArray(value);\n\n if (isArray) {\n length = value.length;\n }\n else {\n var keys = Object.keys(value);\n length = keys.length;\n }\n\n var size;\n if (length < 0x10) {\n view.setUint8(offset, length | (isArray ? 0x90 : 0x80));\n size = 1;\n }\n else if (length < 0x10000) {\n view.setUint8(offset, isArray ? 0xdc : 0xde);\n view.setUint16(offset + 1, length);\n size = 3;\n }\n else if (length < 0x100000000) {\n view.setUint8(offset, isArray ? 0xdd : 0xdf);\n view.setUint32(offset + 1, length);\n size = 5;\n }\n\n if (isArray) {\n for (var i = 0; i < length; i++) {\n size += encode$1(value[i], view, offset + size);\n }\n }\n else {\n for (var i = 0; i < length; i++) {\n var key = keys[i];\n size += encode$1(key, view, offset + size);\n size += encode$1(value[key], view, offset + size);\n }\n }\n\n return size;\n }\n throw new Error(\"Unknown type \" + type);\n}\n\nfunction encodedSize(value) {\n var type = typeof value;\n\n // Raw Bytes\n if (type === \"string\") {\n var length = utf8ByteCount(value);\n if (length < 0x20) {\n return 1 + length;\n }\n if (length < 0x100) {\n return 2 + length;\n }\n if (length < 0x10000) {\n return 3 + length;\n }\n if (length < 0x100000000) {\n return 5 + length;\n }\n }\n\n if (value instanceof Uint8Array) {\n var length = value.byteLength;\n if (length < 0x100) {\n return 2 + length;\n }\n if (length < 0x10000) {\n return 3 + length;\n }\n if (length < 0x100000000) {\n return 5 + length;\n }\n }\n\n if (type === \"number\") {\n // Floating Point\n // double\n if (Math.floor(value) !== value) return 9;\n\n // Integers\n if (value >=0) {\n // positive fixnum\n if (value < 0x80) return 1;\n // uint 8\n if (value < 0x100) return 2;\n // uint 16\n if (value < 0x10000) return 3;\n // uint 32\n if (value < 0x100000000) return 5;\n throw new Error(\"Number too big 0x\" + value.toString(16));\n }\n // negative fixnum\n if (value >= -0x20) return 1;\n // int 8\n if (value >= -0x80) return 2;\n // int 16\n if (value >= -0x8000) return 3;\n // int 32\n if (value >= -0x80000000) return 5;\n throw new Error(\"Number too small -0x\" + value.toString(16).substr(1));\n }\n\n // Boolean, null\n if (type === \"boolean\" || value === null) return 1;\n\n // Container Types\n if (type === \"object\") {\n var length, size = 0;\n if (Array.isArray(value)) {\n length = value.length;\n for (var i = 0; i < length; i++) {\n size += encodedSize(value[i]);\n }\n }\n else {\n var keys = Object.keys(value);\n length = keys.length;\n for (var i = 0; i < length; i++) {\n var key = keys[i];\n size += encodedSize(key) + encodedSize(value[key]);\n }\n }\n if (length < 0x10) {\n return 1 + size;\n }\n if (length < 0x10000) {\n return 3 + size;\n }\n if (length < 0x100000000) {\n return 5 + size;\n }\n throw new Error(\"Array or object too long 0x\" + length.toString(16));\n }\n throw new Error(\"Unknown type \" + type);\n}\n\nfunction encodeMsgpack(value) {\n var buffer = new ArrayBuffer(encodedSize(value));\n var view = new DataView(buffer);\n encode$1(value, view, 0);\n return new Uint8Array(buffer);\n}\n\n/**\n * @file mmtf-constants\n * @private\n * @author Alexander Rose \n */\n\n\nvar PassThroughFields = [\n \"mmtfVersion\", \"mmtfProducer\",\n \"unitCell\", \"spaceGroup\", \"structureId\", \"title\",\n \"depositionDate\", \"releaseDate\",\n \"experimentalMethods\", \"resolution\", \"rFree\", \"rWork\",\n \"bioAssemblyList\", \"ncsOperatorList\", \"entityList\", \"groupList\",\n \"numBonds\", \"numAtoms\", \"numGroups\", \"numChains\", \"numModels\",\n \"groupsPerChain\", \"chainsPerModel\",\n];\n\nvar EncodedFields = [\n\t// required\n \"xCoordList\", \"yCoordList\", \"zCoordList\",\n \"groupIdList\", \"groupTypeList\",\n \"chainIdList\",\n // optional\n \"bFactorList\", \"atomIdList\", \"altLocList\", \"occupancyList\",\n \"secStructList\", \"insCodeList\", \"sequenceIndexList\",\n \"chainNameList\",\n \"bondAtomList\", \"bondOrderList\"\n];\n\nvar AllFields = PassThroughFields.concat( EncodedFields );\n\n/**\n * @file mmtf-utils\n * @private\n * @author Alexander Rose \n */\n\n/**\n * mmtf utils module.\n * @module MmtfUtils\n */\n\n\nfunction getView( ctor, typedArray, elemSize ){\n return typedArray ? new ctor(\n typedArray.buffer,\n typedArray.byteOffset,\n typedArray.byteLength / ( elemSize || 1 )\n ) : undefined;\n}\n\nfunction getDataView( typedArray ){\n return getView( DataView, typedArray );\n}\n\n/**\n * get an Uint8Array view on the input array memory\n * @static\n * @param {TypedArray} dataArray - input array\n * @return {Uint8Array} new view on the input array memory\n */\nfunction getUint8View( typedArray ){\n return getView( Uint8Array, typedArray );\n}\n\n/**\n * get an Int8Array view on the input array memory\n * @static\n * @param {TypedArray} dataArray - input array\n * @return {Int8Array} new view on the input array memory\n */\nfunction getInt8View( typedArray ){\n return getView( Int8Array, typedArray );\n}\n\n/**\n * get an Int32Array view on the input array memory\n * @static\n * @param {TypedArray} dataArray - input array\n * @return {Int32Array} new view on the input array memory\n */\nfunction getInt32View( typedArray ){\n return getView( Int32Array, typedArray, 4 );\n}\n\nfunction getFloat32View( typedArray ){\n return getView( Float32Array, typedArray, 4 );\n}\n\n\n/**\n * get an Int16Array copy of the the input array data\n * @static\n * @param {TypedArray} view - input data in big endian format\n * @param {Int16Array} [dataArray] - pre-allocated output array\n * @return {Int16Array} copy of the input array data\n */\nfunction decodeInt16( bytes, output ){\n var n = bytes.length / 2;\n if( !output ) output = new Int16Array( n );\n for( var i = 0, i2 = 0; i < n; ++i, i2 += 2 ){\n output[ i ] = bytes[ i2 ] << 8 ^ bytes[ i2 + 1 ] << 0;\n }\n return output;\n}\n\n/**\n * make big endian buffer of an int16 array\n * @static\n * @param {Array|TypedArray} array - array of int16 values\n * @return {ArrayBuffer} big endian buffer\n */\nfunction encodeInt16( array, output ){\n var n = array.length;\n if( !output ) output = new Uint8Array( 2 * n );\n var dv = getDataView( output );\n for( var i = 0; i < n; ++i ){\n dv.setInt16( 2 * i, array[ i ] );\n }\n return getUint8View( output );\n}\n\n/**\n * get an Int32Array copy of the the input array data\n * @static\n * @param {TypedArray} view - input data in big endian format\n * @param {Int32Array} [dataArray] - pre-allocated output array\n * @return {Int32Array} copy of the input array data\n */\nfunction decodeInt32( bytes, output ){\n var n = bytes.length / 4;\n if( !output ) output = new Int32Array( n );\n for( var i = 0, i4 = 0; i < n; ++i, i4 += 4 ){\n output[ i ] = (\n bytes[ i4 ] << 24 ^ bytes[ i4 + 1 ] << 16 ^\n bytes[ i4 + 2 ] << 8 ^ bytes[ i4 + 3 ] << 0\n );\n }\n return output;\n}\n\n/**\n * make big endian buffer of an int32 array\n * @static\n * @param {Array|TypedArray} array - array of int32 values\n * @return {ArrayBuffer} big endian buffer\n */\nfunction encodeInt32( array, output ){\n var n = array.length;\n if( !output ) output = new Uint8Array( 4 * n );\n var dv = getDataView( output );\n for( var i = 0; i < n; ++i ){\n dv.setInt32( 4 * i, array[ i ] );\n }\n return getUint8View( output );\n}\n\nfunction decodeFloat32( bytes, output ){\n var n = bytes.length;\n if( !output ) output = new Float32Array( n / 4 );\n var dvOut = getDataView( output );\n var dvIn = getDataView( bytes );\n for( var i = 0, i4 = 0, il = n / 4; i < il; ++i, i4 += 4 ){\n dvOut.setFloat32( i4, dvIn.getFloat32( i4 ), true );\n }\n return output;\n}\n\n/**\n * decode integers into floats using given divisor\n * example:\n * intArray: [ 12, 34, 543, 687, 2, 0, 4689 ]\n * divisor: 100\n * return: [ 0.12, 0.34, 5.43, 6.87, 0.02, 0.00, 46.89 ]\n * @static\n * @param {TypedArray|Array} intArray - input array containing integers\n * @param {Number} divisor - number to devide the integers to obtain floats\n * @param {Float32Array} [dataArray] - pre-allocated output array\n * @return {Float32Array} decoded array\n */\nfunction decodeInteger( intArray, divisor, output ){\n var n = intArray.length;\n var invDiv = 1/divisor;\n if( !output ) output = new Float32Array( n );\n for( var i = 0; i < n; ++i ){\n // multiply by inverse of the divisor which is faster then division\n output[ i ] = intArray[ i ] * invDiv;\n }\n return output;\n}\n\nfunction encodeInteger( floatArray, factor, output ){\n var n = floatArray.length;\n if( !output ) output = new Int32Array( n );\n for( var i = 0; i < n; ++i ){\n output[ i ] = Math.round( floatArray[ i ] * factor );\n }\n return output;\n}\n\n\n\n/**\n * perform run-length decoding of input array\n * example:\n * array: [ 0, 2, 3, 5 ] // pairs of values and length of a run\n * return: [ 0, 0, 3, 3, 3, 3, 3 ]\n * @static\n * @param {TypedArray|Array} array - run-length encoded input array\n * @param {TypedArray|Array} [dataArray] - pre-allocated output array\n * @return {TypedArray|Array} decoded array\n */\nfunction decodeRun( array, output ){\n var i, il;\n if( !output ){\n // calculate the length the decoded array will have\n var fullLength = 0;\n for( i = 0, il = array.length; i < il; i+=2 ){\n fullLength += array[ i + 1 ];\n }\n // create a new array of the same type of the input array\n output = new array.constructor( fullLength );\n }\n var dataOffset = 0;\n for( i = 0, il = array.length; i < il; i+=2 ){\n var value = array[ i ]; // value to be repeated\n var length = array[ i + 1 ]; // number of repeats\n for( var j = 0; j < length; ++j ){\n output[ dataOffset ] = value;\n ++dataOffset;\n }\n }\n return output;\n}\n\nfunction encodeRun( array ){\n if( array.length === 0 ) return new Int32Array();\n var i, il;\n // calculate output size\n var fullLength = 2;\n for( i = 1, il = array.length; i < il; ++i ){\n if( array[ i - 1 ] !== array[ i ] ){\n fullLength += 2;\n }\n }\n var output = new Int32Array( fullLength );\n var offset = 0;\n var runLength = 1;\n for( i = 1, il = array.length; i < il; ++i ){\n if( array[ i - 1 ] !== array[ i ] ){\n output[ offset ] = array[ i - 1 ];\n output[ offset + 1 ] = runLength;\n runLength = 1;\n offset += 2;\n }else{\n ++runLength;\n }\n }\n output[ offset ] = array[ array.length - 1 ];\n output[ offset + 1 ] = runLength;\n return output;\n}\n\n\n\n/**\n * perform delta decoding of the input array\n * by iterativly adding the ith element's value to the i+1th\n * example:\n * dataArray: [ 0, 2, 1, 2, 1, 1, -4, -2, 9 ]\n * return: [ 0, 2, 3, 5, 6, 7, 3, 1, 10 ]\n * @static\n * @param {TypedArray|Array} dataArray - delta encoded input array\n * @return {TypedArray|Array} decoded array\n */\nfunction decodeDelta( array, output ){\n var n = array.length;\n if( !output ) output = new array.constructor( n );\n if( n ) output[ 0 ] = array[ 0 ];\n for( var i = 1; i < n; ++i ){\n output[ i ] = array[ i ] + output[ i - 1 ];\n }\n return output;\n}\n\nfunction encodeDelta( array, output ){\n var n = array.length;\n if( !output ) output = new array.constructor( n );\n output[ 0 ] = array[ 0 ];\n for( var i = 1; i < n; ++i ){\n output[ i ] = array[ i ] - array[ i - 1 ];\n }\n return output;\n}\n\n\n\n/**\n * [decodePacking description]\n * @param {Int16Array|Int8Array} int16or8 [description]\n * @param {Int32Array} output [description]\n * @return {Int32Array} [description]\n */\nfunction decodePacking( int16or8, output ){\n var upperLimit = int16or8 instanceof Int8Array ? 0x7F : 0x7FFF;\n var lowerLimit = -upperLimit - 1;\n var n = int16or8.length;\n var i, j;\n if( !output ){\n var fullLength = 0;\n for( i = 0; i < n; ++i ){\n if( int16or8[ i ] < upperLimit && int16or8[ i ] > lowerLimit ){\n ++fullLength;\n }\n }\n output = new Int32Array( fullLength );\n }\n i = 0;\n j = 0;\n while( i < n ){\n var value = 0;\n while( int16or8[ i ] === upperLimit || int16or8[ i ] === lowerLimit ){\n value += int16or8[ i ];\n ++i;\n }\n value += int16or8[ i ];\n ++i;\n output[ j ] = value;\n ++j;\n }\n return output;\n}\n\n/**\n * integer packing using recursive indexing\n * @param {Array|TyepedArray} intArray [description]\n * @param {Boolean} useInt8 [description]\n * @return {Int16Array|Int8Array} [description]\n */\nfunction encodePacking( intArray, useInt8 ){\n var upperLimit = useInt8 ? 0x7F : 0x7FFF;\n var lowerLimit = -upperLimit - 1;\n var i;\n var n = intArray.length;\n var size = 0;\n for( i = 0; i < n; ++i ){\n var value = intArray[ i ];\n if( value === 0 ){\n ++size;\n }else if( value === upperLimit || value === lowerLimit ){\n size += 2;\n }else if( value > 0) {\n size += Math.ceil( value / upperLimit );\n }else {\n size += Math.ceil( value / lowerLimit );\n }\n }\n var output = useInt8 ? new Int8Array( size ) : new Int16Array( size );\n var j = 0;\n for( i = 0; i < n; ++i ){\n var value = intArray[ i ];\n if( value >= 0) {\n while( value >= upperLimit ){\n output[ j ] = upperLimit;\n ++j;\n value -= upperLimit;\n }\n }else{\n while( value <= lowerLimit ){\n output[ j ] = lowerLimit;\n ++j;\n value -= lowerLimit;\n }\n }\n output[ j ] = value;\n ++j;\n }\n return output;\n}\n\n\n\nfunction decodeDeltaRun( array, output ){\n return decodeDelta( decodeRun( array ), output );\n}\n\nfunction encodeDeltaRun( array ){\n return encodeRun( encodeDelta( array ) );\n}\n\n\n\n/**\n * perform run-length decoding followed (@see decodeRunLength)\n * by decoding integers into floats using given divisor (@see decodeIntegerToFloat)\n * example:\n * array: [ 320, 3, 100, 2 ]\n * divisor: 100\n * return: [ 3.20, 3.20, 3.20, 1.00, 1.00 ]\n * @static\n * @param {Uint8Array} array - run-length encoded int32 array as bytes in big endian format\n * @param {Integer} divisor - number to devide the integers to obtain floats\n * @param {Float32Array} dataArray - pre-allocated output array\n * @return {Float32Array} decoded array\n */\nfunction decodeIntegerRun( intArray, divisor, output ){\n return decodeInteger(\n decodeRun( intArray, getInt32View( output ) ), divisor, output\n );\n}\n\nfunction encodeIntegerRun( floatArray, factor ){\n return encodeRun( encodeInteger( floatArray, factor ) );\n}\n\n\n\nfunction decodeIntegerDelta( intArray, divisor, output ){\n return decodeInteger(\n decodeDelta( intArray, getInt32View( output ) ), divisor, output\n );\n}\n\nfunction encodeIntegerDelta( floatArray, factor, output ){\n return encodeDelta( encodeInteger( floatArray, factor ), output );\n}\n\n\n\nfunction decodeIntegerPacking( int16or8, divisor, output ){\n return decodeInteger(\n decodePacking( int16or8, getInt32View( output ) ), divisor, output\n );\n}\n\nfunction decodeIntegerDeltaPacking( int16or8, divisor, output ){\n var unpacked = decodePacking( int16or8, getInt32View( output ) );\n return decodeIntegerDelta( unpacked, divisor, getFloat32View( unpacked ) );\n}\n\nfunction encodeIntegerDeltaPacking( floatArray, factor, useInt8 ){\n return encodePacking( encodeIntegerDelta( floatArray, factor ), useInt8 );\n}\n\n\n\nfunction decodeBytes( bytes ){\n var dv = getDataView( bytes );\n var type = dv.getInt32( 0 );\n var size = dv.getInt32( 4 );\n var param = bytes.subarray( 8, 12 );\n var bytes = bytes.subarray( 12 );\n return [ type, bytes, size, param ];\n}\n\nfunction encodeBytes( type, size, param, bytes ){\n var buffer = new ArrayBuffer( 12 + bytes.byteLength );\n var out = new Uint8Array( buffer );\n var dv = new DataView( buffer );\n dv.setInt32( 0, type );\n dv.setInt32( 4, size );\n if( param ) out.set( param, 8 );\n out.set( bytes, 12 );\n return out;\n}\n\nfunction passInt8( int8 ){\n var size = int8.length;\n var bytes = getUint8View( int8 );\n return encodeBytes( 2, size, undefined, bytes );\n}\n\nfunction passInt32( int32 ){\n var size = int32.length;\n var bytes = encodeInt32( int32 );\n return encodeBytes( 4, size, undefined, bytes );\n}\n\nfunction passString( stringBytes, length ){\n var size = stringBytes.length / length;\n var param = encodeInt32([ length ]);\n var bytes = getUint8View( stringBytes );\n return encodeBytes( 5, size, param, bytes );\n}\n\nfunction runChar( charBytes ){\n var size = charBytes.length;\n var bytes = encodeInt32( encodeRun( charBytes ) );\n return encodeBytes( 6, size, undefined, bytes );\n}\n\nfunction deltaRun( int32 ){\n var size = int32.length;\n var bytes = encodeInt32( encodeDeltaRun( int32 ) );\n return encodeBytes( 8, size, undefined, bytes );\n}\n\nfunction integerRun( float32, factor ){\n var size = float32.length;\n var param = encodeInt32([ factor ]);\n var bytes = encodeInt32( encodeIntegerRun( float32, factor ) );\n return encodeBytes( 9, size, param, bytes );\n}\n\nfunction integerDeltaPacking16( float32, factor ){\n var size = float32.length;\n var param = encodeInt32([ factor ]);\n var bytes = encodeInt16( encodeIntegerDeltaPacking( float32, factor ) );\n return encodeBytes( 10, size, param, bytes );\n}\n\nfunction encodeMmtf( inputDict ){\n\n var outputDict = {};\n\n // copy some fields over from the input dict\n PassThroughFields.forEach( function( name ){\n if( inputDict[ name ] !== undefined ){\n outputDict[ name ] = inputDict[ name ];\n }\n } );\n\n //////////////\n // bond data\n\n // encode inter group bond atom indices, i.e. get bytes in big endian order\n if( inputDict.bondAtomList ){\n outputDict.bondAtomList = passInt32( inputDict.bondAtomList );\n }\n\n // encode inter group bond orders, i.e. get bytes\n if( inputDict.bondOrderList ){\n outputDict.bondOrderList = passInt8( inputDict.bondOrderList );\n }\n\n //////////////\n // atom data\n\n // split-list delta & integer encode x, y, z atom coords\n outputDict.xCoordList = integerDeltaPacking16( inputDict.xCoordList, 1000 );\n outputDict.yCoordList = integerDeltaPacking16( inputDict.yCoordList, 1000 );\n outputDict.zCoordList = integerDeltaPacking16( inputDict.zCoordList, 1000 );\n\n // split-list delta & integer encode b-factors\n if( inputDict.bFactorList ){\n outputDict.bFactorList = integerDeltaPacking16( inputDict.bFactorList, 100 );\n }\n\n // delta & run-length encode atom ids\n if( inputDict.atomIdList ){\n outputDict.atomIdList = deltaRun( inputDict.atomIdList );\n }\n\n // run-length encode alternate labels\n if( inputDict.altLocList ){\n outputDict.altLocList = runChar( inputDict.altLocList );\n }\n\n // run-length & integer encode occupancies\n if( inputDict.occupancyList ){\n outputDict.occupancyList = integerRun( inputDict.occupancyList, 100 );\n }\n\n ///////////////\n // group data\n\n // run-length & delta encode group numbers\n outputDict.groupIdList = deltaRun( inputDict.groupIdList );\n\n // encode group types, i.e. get int32 array\n outputDict.groupTypeList = passInt32( inputDict.groupTypeList );\n\n // encode secondary structure, i.e. get bytes\n if( inputDict.secStructList ){\n outputDict.secStructList = passInt8( inputDict.secStructList, 1 );\n }\n\n // run-length encode insertion codes\n if( inputDict.insCodeList ){\n outputDict.insCodeList = runChar( inputDict.insCodeList );\n }\n\n // run-length & delta encode sequence indices\n if( inputDict.sequenceIndexList ){\n outputDict.sequenceIndexList = deltaRun( inputDict.sequenceIndexList );\n }\n\n ///////////////\n // chain data\n\n // encode chain ids, i.e. get bytes\n outputDict.chainIdList = passString( inputDict.chainIdList, 4 );\n\n // encode chain names, i.e. get bytes\n if( inputDict.chainNameList ){\n outputDict.chainNameList = passString( inputDict.chainNameList, 4 );\n }\n\n return outputDict;\n\n}\n\n/**\n * @file msgpack-decode\n * @private\n * @author Alexander Rose \n */\n\n/**\n * msgpack decode module.\n * @module MsgpackDecode\n */\n\n/**\n * decode binary encoded MessagePack v5 (http://msgpack.org/) data\n * @static\n * @param {Uint8Array} buffer - binary encoded MessagePack data\n * @return {Object|Array|String|Number|Boolean|null} decoded Messagepack data\n */\nfunction decodeMsgpack(buffer) {\n // Loosely based on\n // The MIT License (MIT)\n // Copyright (c) 2013 Tim Caswell \n // https://github.com/creationix/msgpack-js\n var offset = 0;\n var dataView = new DataView(buffer.buffer);\n\n /**\n * decode all key-value pairs of a map into an object\n * @param {Integer} length - number of key-value pairs\n * @return {Object} decoded map\n */\n function map(length) {\n var value = {};\n for (var i = 0; i < length; i++) {\n var key = parse();\n value[key] = parse();\n }\n return value;\n }\n\n /**\n * decode binary array\n * @param {Integer} length - number of elements in the array\n * @return {Uint8Array} decoded array\n */\n function bin(length) {\n var value = buffer.subarray(offset, offset + length);\n offset += length;\n return value;\n }\n\n /**\n * decode string\n * @param {Integer} length - number string characters\n * @return {String} decoded string\n */\n function str(length) {\n var array = buffer.subarray(offset, offset + length);\n offset += length;\n // limit number of arguments to String.fromCharCode to something\n // browsers can handle, see http://stackoverflow.com/a/22747272\n var chunkSize = 0xffff;\n if(length > chunkSize){\n var c = [];\n for(var i = 0; i < array.length; i += chunkSize) {\n c.push(String.fromCharCode.apply(\n null, array.subarray(i, i + chunkSize)\n ));\n }\n return c.join(\"\");\n }else{\n return String.fromCharCode.apply(null, array);\n }\n }\n\n /**\n * decode array\n * @param {Integer} length - number of array elements\n * @return {Array} decoded array\n */\n function array(length) {\n var value = new Array(length);\n for (var i = 0; i < length; i++) {\n value[i] = parse();\n }\n return value;\n }\n\n /**\n * recursively parse the MessagePack data\n * @return {Object|Array|String|Number|Boolean|null} decoded MessagePack data\n */\n function parse() {\n var type = buffer[offset];\n var value, length, extType;\n // Positive FixInt\n if ((type & 0x80) === 0x00) {\n offset++;\n return type;\n }\n // FixMap\n if ((type & 0xf0) === 0x80) {\n length = type & 0x0f;\n offset++;\n return map(length);\n }\n // FixArray\n if ((type & 0xf0) === 0x90) {\n length = type & 0x0f;\n offset++;\n return array(length);\n }\n // FixStr\n if ((type & 0xe0) === 0xa0) {\n length = type & 0x1f;\n offset++;\n return str(length);\n }\n // Negative FixInt\n if ((type & 0xe0) === 0xe0) {\n value = dataView.getInt8(offset);\n offset++;\n return value;\n }\n switch (type) {\n // nil\n case 0xc0:\n offset++;\n return null;\n // 0xc1: (never used, could be employed for padding)\n // false\n case 0xc2:\n offset++;\n return false;\n // true\n case 0xc3:\n offset++;\n return true;\n // bin 8\n case 0xc4:\n length = dataView.getUint8(offset + 1);\n offset += 2;\n return bin(length);\n // bin 16\n case 0xc5:\n length = dataView.getUint16(offset + 1);\n offset += 3;\n return bin(length);\n // bin 32\n case 0xc6:\n length = dataView.getUint32(offset + 1);\n offset += 5;\n return bin(length);\n // // ext 8\n // case 0xc7:\n // length = dataView.getUint8(offset + 1);\n // extType = dataView.getUint8(offset + 2);\n // offset += 3;\n // return [extType, bin(length)];\n // // ext 16\n // case 0xc8:\n // length = dataView.getUint16(offset + 1);\n // extType = dataView.getUint8(offset + 3);\n // offset += 4;\n // return [extType, bin(length)];\n // // ext 32\n // case 0xc9:\n // length = dataView.getUint32(offset + 1);\n // extType = dataView.getUint8(offset + 5);\n // offset += 6;\n // return [extType, bin(length)];\n // float 32\n case 0xca:\n value = dataView.getFloat32(offset + 1);\n offset += 5;\n return value;\n // float 64\n case 0xcb:\n value = dataView.getFloat64(offset + 1);\n offset += 9;\n return value;\n // uint8\n case 0xcc:\n value = buffer[offset + 1];\n offset += 2;\n return value;\n // uint 16\n case 0xcd:\n value = dataView.getUint16(offset + 1);\n offset += 3;\n return value;\n // uint 32\n case 0xce:\n value = dataView.getUint32(offset + 1);\n offset += 5;\n return value;\n // // uint64\n // case 0xcf:\n // // FIXME not available/representable in JS\n // // largest possible int in JS is 2^53\n // // value = dataView.getUint64(offset + 1);\n // offset += 9;\n // return 0;\n // int 8\n case 0xd0:\n value = dataView.getInt8(offset + 1);\n offset += 2;\n return value;\n // int 16\n case 0xd1:\n value = dataView.getInt16(offset + 1);\n offset += 3;\n return value;\n // int 32\n case 0xd2:\n value = dataView.getInt32(offset + 1);\n offset += 5;\n return value;\n // // int 64\n // case 0xd3:\n // // FIXME not available/representable in JS\n // // largest possible int in JS is 2^53\n // // value = dataView.getInt64(offset + 1);\n // offset += 9;\n // return 0;\n\n // // fixext 1\n // case 0xd4:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(1)];\n // // fixext 2\n // case 0xd5:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(2)];\n // // fixext 4\n // case 0xd6:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(4)];\n // // fixext 8\n // case 0xd7:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(8)];\n // // fixext 16\n // case 0xd8:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(16)];\n // str 8\n case 0xd9:\n length = dataView.getUint8(offset + 1);\n offset += 2;\n return str(length);\n // str 16\n case 0xda:\n length = dataView.getUint16(offset + 1);\n offset += 3;\n return str(length);\n // str 32\n case 0xdb:\n length = dataView.getUint32(offset + 1);\n offset += 5;\n return str(length);\n // array 16\n case 0xdc:\n length = dataView.getUint16(offset + 1);\n offset += 3;\n return array(length);\n // array 32\n case 0xdd:\n length = dataView.getUint32(offset + 1);\n offset += 5;\n return array(length);\n // map 16:\n case 0xde:\n length = dataView.getUint16(offset + 1);\n offset += 3;\n return map(length);\n // map 32\n case 0xdf:\n length = dataView.getUint32(offset + 1);\n offset += 5;\n return map(length);\n }\n\n throw new Error(\"Unknown type 0x\" + type.toString(16));\n }\n\n // start the recursive parsing\n return parse();\n}\n\n/**\n * Fields shared in encoded and decoded mmtf data objects.\n * @typedef {Object} module:MmtfDecode.SharedMmtfData\n * @property {String} mmtfVersion - MMTF specification version\n * @property {String} mmtfProducer - Program that created the file\n * @property {Float[]} [unitCell] - Crystallographic unit cell\n * @property {Float} unitCell.0 - x length\n * @property {Float} unitCell.1 - y length\n * @property {Float} unitCell.2 - z length\n * @property {Float} unitCell.3 - alpha angle\n * @property {Float} unitCell.4 - beta angle\n * @property {Float} unitCell.5 - gamma angle\n * @property {String} [spaceGroup] - Hermann-Mauguin symbol\n * @property {String} [structureId] - Some reference, e.g. a PDB ID\n * @property {String} [title] - Short description\n * @property {String} [depositionDate] - Deposition date in YYYY-MM-DD format\n * @property {String} [releaseDate] - Release date in YYYY-MM-DD format\n * @property {String[]} [experimentalMethods] - Structure determination methods\n * @property {Float} [resolution] - Resolution in Å\n * @property {Float} [rFree] - R-free value\n * @property {Float} [rWork] - R-work value\n * @property {Integer} numBonds - Number of bonds\n * @property {Integer} numAtoms - Number of atoms\n * @property {Integer} numGroups - Number of groups (residues)\n * @property {Integer} numChains - Number of chains\n * @property {Integer} numModels - Number of models\n * @property {Integer[]} chainsPerModel - List of number of chains in each model\n * @property {Integer[]} groupsPerChain - List of number of groups in each chain\n * @property {Entity[]} [entityList] - List of entity objects\n * @property {Integer[]} entityList.chainIndexList - Pointers into chain data fields\n * @property {String} entityList.description - Description of the entity\n * @property {String} entityList.type - Name of the entity type\n * @property {String} entityList.sequence - One letter code sequence\n * @property {Assembly[]} [bioAssemblyList] - List of assembly objects\n * @property {Transform[]} bioAssemblyList.transformList - List of transform objects\n * @property {Integer[]} bioAssemblyList.transformList.chainIndexList - Pointers into chain data fields\n * @property {Float[]} bioAssemblyList.transformList.matrix - 4x4 transformation matrix\n * @property {Array[]} [ncsOperatorList] - List of ncs operator matrices\n * @property {Float[]} ncsOperatorList. - 4x4 transformation matrix\n * @property {GroupType[]} groupList - List of groupType objects\n * @property {Integer[]} groupList.formalChargeList - List of atom formal charges\n * @property {String[]} groupList.elementList - List of elements\n * @property {String[]} groupList.atomNameList - List of atom names\n * @property {Integer[]} groupList.bondAtomList - List of bonded atom indices\n * @property {Integer[]} groupList.bondOrderList - List of bond orders\n * @property {String} groupList.groupName - The name of the group\n * @property {String} groupList.singleLetterCode - The single letter code\n * @property {String} groupList.chemCompType - The chemical component type\n */\n\n/**\n * Encoded mmtf data object. Also includes the fields from {@link module:MmtfDecode.SharedMmtfData}. See MMTF specification on how they are encoded.\n * @typedef {Object} module:MmtfDecode.EncodedMmtfData\n * @mixes module:MmtfDecode.SharedMmtfData\n * @property {Uint8Array} [bondAtomList] - Encoded bonded atom indices\n * @property {Uint8Array} [bondOrderList] - Encoded bond orders\n * @property {Uint8Array} xCoordBig - Encoded x coordinates in Å, part 1\n * @property {Uint8Array} xCoordSmall - Encoded x coordinates in Å, part 2\n * @property {Uint8Array} yCoordBig - Encoded y coordinates in Å, part 1\n * @property {Uint8Array} yCoordSmall - Encoded y coordinates in Å, part 2\n * @property {Uint8Array} yCoordBig - Encoded y coordinates in Å, part 1\n * @property {Uint8Array} yCoordSmall - Encoded y coordinates in Å, part 2\n * @property {Uint8Array} [bFactorBig] - Encoded B-factors in Å^2, part 1\n * @property {Uint8Array} [bFactorSmall] - Encoded B-factors in Å^2, part 2\n * @property {Uint8Array} [atomIdList] - Encoded atom ids\n * @property {Uint8Array} [altLocList] - Encoded alternate location labels\n * @property {Uint8Array} [occupancyList] - Encoded occupancies\n * @property {Uint8Array} groupIdList - Encoded group ids\n * @property {Uint8Array} groupTypeList - Encoded group types\n * @property {Uint8Array} [secStructList] - Encoded secondary structure codes\n * @property {Uint8Array} [insCodeList] - Encoded insertion codes\n * @property {Uint8Array} [seuenceIdList] - Encoded sequence ids\n * @property {Uint8Array} chainIdList - Encoded chain ids\n * @property {Uint8Array} [chainNameList] - Encoded chain names\n */\n\n/**\n * Decoded mmtf data object. Also includes fields the from {@link module:MmtfDecode.SharedMmtfData}.\n * @typedef {Object} module:MmtfDecode.MmtfData\n * @mixes module:MmtfDecode.SharedMmtfData\n * @property {Int32Array} [bondAtomList] - List of bonded atom indices\n * @property {Uint8Array} [bondOrderList] - List of bond orders\n * @property {Float32Array} xCoordList - List of x coordinates in Å\n * @property {Float32Array} yCoordList - List of y coordinates in Å\n * @property {Float32Array} zCoordList - List of z coordinates in Å\n * @property {Float32Array} [bFactorList] - List of B-factors in Å^2\n * @property {Int32Array} [atomIdList] - List of atom ids\n * @property {Uint8Array} [altLocList] - List of alternate location labels\n * @property {Float32Array} [occupancyList] - List of occupancies\n * @property {Int32Array} groupIdList - List of group ids\n * @property {Int32Array} groupTypeList - List of group types\n * @property {Int8Array} [secStructList] - List of secondary structure codes, encoding\n * 0: pi helix, 1: bend, 2: alpha helix, 3: extended,\n * 4: 3-10 helix, 5: bridge, 6: turn, 7: coil, -1: undefined\n * @property {Uint8Array} [insCodeList] - List of insertion codes\n * @property {Int32Array} [seuenceIdList] - List of sequence ids\n * @property {Uint8Array} chainIdList - List of chain ids\n * @property {Uint8Array} [chainNameList] - List of chain names\n */\n\n\n/**\n * [performDecoding description]\n * @param {Integer} bytes [description]\n * @param {Integer} size [description]\n * @param {Uint8Array} param [description]\n * @return {TypedArray} [description]\n */\nfunction performDecoding( type, bytes, size, param ){\n\n switch( type ){\n case 1:\n return decodeFloat32( bytes );\n case 2:\n return getInt8View( bytes );\n case 3:\n return decodeInt16( bytes );\n case 4:\n return decodeInt32( bytes );\n case 5:\n // var length = decodeInt32( param )[ 0 ];\n return getUint8View( bytes ); // interpret as string array\n case 6:\n // interpret as char array\n return decodeRun( decodeInt32( bytes ), new Uint8Array( size ) );\n case 7:\n return decodeRun( decodeInt32( bytes ) )\n case 8:\n return decodeDeltaRun( decodeInt32( bytes ) );\n case 9:\n return decodeIntegerRun( decodeInt32( bytes ), decodeInt32( param )[ 0 ] );\n case 10:\n return decodeIntegerDeltaPacking( decodeInt16( bytes ), decodeInt32( param )[ 0 ] );\n case 11:\n return decodeInteger( decodeInt16( bytes ), decodeInt32( param )[ 0 ] );\n case 12:\n return decodeIntegerPacking( decodeInt16( bytes ), decodeInt32( param )[ 0 ] );\n case 13:\n return decodeIntegerPacking( getInt8View( bytes ), decodeInt32( param )[ 0 ] );\n case 14:\n return decodePacking( decodeInt16( bytes ) );\n case 15:\n return decodePacking( getInt8View( bytes ) );\n }\n\n};\n\n\n/**\n * Decode MMTF fields\n * @static\n * @param {Object} inputDict - encoded MMTF data\n * @param {Object} [params] - decoding parameters\n * @param {String[]} params.ignoreFields - names of optional fields not to decode\n * @return {module:MmtfDecode.MmtfData} mmtfData\n */\nfunction decodeMmtf( inputDict, params ){\n\n params = params || {};\n var ignoreFields = params.ignoreFields;\n var outputDict = {};\n\n AllFields.forEach( function( name ){\n var ignore = ignoreFields ? ignoreFields.indexOf( name ) !== -1 : false;\n var data = inputDict[ name ];\n if( !ignore && data !== undefined ){\n if( data instanceof Uint8Array ){\n outputDict[ name ] = performDecoding.apply( null, decodeBytes( data ) );\n }else{\n outputDict[ name ] = data;\n }\n }\n } );\n\n return outputDict;\n\n}\n\n/**\n * @file mmtf-traverse\n * @private\n * @author Alexander Rose \n */\n\n/**\n * mmtf traverse module.\n * @module MmtfTraverse\n */\n\n/**\n * Converts an array of ASCII codes trimming '\\0' bytes\n * @private\n * @param {Array} charCodeArray - array of ASCII char codes\n * @return {String} '\\0' trimmed string\n */\nfunction fromCharCode( charCodeArray ){\n return String.fromCharCode.apply( null, charCodeArray ).replace(/\\0/g, '');\n}\n\n\n/**\n * @callback module:MmtfTraverse.onModel\n * @param {Object} modelData\n * @param {Integer} modelData.chainCount - number of chains in the model\n * @param {Integer} modelData.modelIndex - index of the model\n */\n\n/**\n * @callback module:MmtfTraverse.onChain\n * @param {Object} chainData\n * @param {Integer} chainData.groupCount - number of groups in the chain\n * @param {Integer} chainData.chainIndex - index of the chain\n * @param {Integer} chainData.modelIndex - index of the parent model\n * @param {String} chainData.chainId - chain id\n * @param {?String} chainData.chainName - additional chain name\n */\n\n/**\n * @callback module:MmtfTraverse.onGroup\n * @param {Object} groupData\n * @param {Integer} groupData.atomCount - number of atoms in the group\n * @param {Integer} groupData.groupIndex - index of the group\n * @param {Integer} groupData.chainIndex - index of the parent chain\n * @param {Integer} groupData.modelIndex - index of the parent model\n * @param {Integer} groupData.groupId - group id (residue number)\n * @param {Integer} groupData.groupType - index to an entry in {@link module:MmtfDecode.MmtfData}#groupList\n * @param {String} groupData.groupName - name of the group, 0 to 5 characters\n * @param {Char} groupData.singleLetterCode - IUPAC single letter code, otherwise 'X', 1 character\n * @param {String} groupData.chemCompType - chemical component type from the mmCIF dictionary\n * @param {?Integer} groupData.secStruct - sencoded secondary structure |\n * 0: pi helix, 1: bend, 2: alpha helix, 3: extended,\n * 4: 3-10 helix, 5: bridge, 6: turn, 7: coil, -1: undefined\n * @param {?Char} groupData.insCode - insertion code\n * @param {?Integer} groupData.sequenceIndex - index to the `sequence` property of\n * the corresponding entity, -1 when the entity has no sequence\n */\n\n/**\n * @callback module:MmtfTraverse.onAtom\n * @param {Object} atomData\n * @param {Integer} atomData.atomIndex - index of the atom\n * @param {Integer} atomData.groupIndex - index of the parent group\n * @param {Integer} atomData.chainIndex - index of the parent chain\n * @param {Integer} atomData.modelIndex - index of the parent model\n * @param {?Integer} atomData.atomId - atom id\n * @param {String} atomData.element - IUPAC element name, 0 to 3 characters\n * @param {String} atomData.atomName - name of the atom, 0 to 5 characters\n * @param {Integer} atomData.formalCharge - formal charge of the atom\n * @param {Float} atomData.xCoord - x coordinate in Å\n * @param {Float} atomData.yCoord - y coordinate in Å\n * @param {Float} atomData.zCoord - z coordinate in Å\n * @param {?Float} atomData.bFactor - B-factor in in Å^2\n * @param {?Char} atomData.altLoc - alternate location identifier\n * @param {?Float} atomData.occupancy - occupancy of the atom\n */\n\n/**\n * @callback module:MmtfTraverse.onBond\n * @param {Object} bondData\n * @param {Integer} bondData.atomIndex1 - index of the first atom\n * @param {Integer} bondData.atomIndex2 - index of the secound atom\n * @param {Integer} bondData.bondOrder - bond order, allowed values are 1 to 3\n */\n\n\n/**\n * Traverse the MMTF structure data.\n * @static\n * @param {module:MmtfDecode.MmtfData} mmtfData - decoded mmtf data\n * @param {Object} eventCallbacks\n * @param {module:MmtfTraverse.onModel} [eventCallbacks.onModel] - called for each model\n * @param {module:MmtfTraverse.onChain} [eventCallbacks.onChain] - called for each chain\n * @param {module:MmtfTraverse.onGroup} [eventCallbacks.onGroup] - called for each group\n * @param {module:MmtfTraverse.onAtom} [eventCallbacks.onAtom] - called for each atom\n * @param {module:MmtfTraverse.onBond} [eventCallbacks.onBond] - called for each bond\n * @param {Object} [params] - traversal parameters\n * @param {Boolean} [params.firstModelOnly] - traverse only the first model\n */\nfunction traverseMmtf( mmtfData, eventCallbacks, params ){\n\n params = params || {};\n\n var firstModelOnly = params.firstModelOnly;\n\n // setup callbacks\n var onModel = eventCallbacks.onModel;\n var onChain = eventCallbacks.onChain;\n var onGroup = eventCallbacks.onGroup;\n var onAtom = eventCallbacks.onAtom;\n var onBond = eventCallbacks.onBond;\n\n // setup index counters\n var modelIndex = 0;\n var chainIndex = 0;\n var groupIndex = 0;\n var atomIndex = 0;\n\n var modelFirstAtomIndex = 0;\n var modelLastAtomIndex = -1;\n\n // setup optional fields\n var chainNameList = mmtfData.chainNameList;\n var secStructList = mmtfData.secStructList;\n var insCodeList = mmtfData.insCodeList;\n var sequenceIndexList = mmtfData.sequenceIndexList;\n var atomIdList = mmtfData.atomIdList;\n var bFactorList = mmtfData.bFactorList;\n var altLocList = mmtfData.altLocList;\n var occupancyList = mmtfData.occupancyList;\n var bondAtomList = mmtfData.bondAtomList;\n var bondOrderList = mmtfData.bondOrderList;\n\n // hoisted loop variables\n var o, ol, i, j, k, kl;\n\n // loop over all models\n for( o = 0, ol = mmtfData.chainsPerModel.length; o < ol; ++o ){\n\n if( firstModelOnly && modelIndex > 0 ) break;\n\n var modelChainCount = mmtfData.chainsPerModel[ modelIndex ];\n\n if( onModel ){\n onModel({\n chainCount: modelChainCount,\n modelIndex: modelIndex\n });\n }\n\n for( i = 0; i < modelChainCount; ++i ){\n\n var chainGroupCount = mmtfData.groupsPerChain[ chainIndex ];\n if( onChain ){\n var chainId = fromCharCode(\n mmtfData.chainIdList.subarray( chainIndex * 4, chainIndex * 4 + 4 )\n );\n var chainName = null;\n if( chainNameList ){\n chainName = fromCharCode(\n chainNameList.subarray( chainIndex * 4, chainIndex * 4 + 4 )\n );\n }\n onChain({\n groupCount: chainGroupCount,\n chainIndex: chainIndex,\n modelIndex: modelIndex,\n chainId: chainId,\n chainName: chainName\n });\n }\n\n for( j = 0; j < chainGroupCount; ++j ){\n\n var groupData = mmtfData.groupList[ mmtfData.groupTypeList[ groupIndex ] ];\n var groupAtomCount = groupData.atomNameList.length;\n if( onGroup ){\n var secStruct = null;\n if( secStructList ){\n secStruct = secStructList[ groupIndex ];\n }\n var insCode = null;\n if( mmtfData.insCodeList ){\n insCode = String.fromCharCode( insCodeList[ groupIndex ] );\n }\n var sequenceIndex = null;\n if( sequenceIndexList ){\n sequenceIndex = sequenceIndexList[ groupIndex ];\n }\n onGroup({\n atomCount: groupAtomCount,\n groupIndex: groupIndex,\n chainIndex: chainIndex,\n modelIndex: modelIndex,\n groupId: mmtfData.groupIdList[ groupIndex ],\n groupType: mmtfData.groupTypeList[ groupIndex ],\n groupName: groupData.groupName,\n singleLetterCode: groupData.singleLetterCode,\n chemCompType: groupData.chemCompType,\n secStruct: secStruct,\n insCode: insCode,\n sequenceIndex: sequenceIndex\n });\n }\n\n for( k = 0; k < groupAtomCount; ++k ){\n\n if( onAtom ){\n var atomId = null;\n if( atomIdList ){\n atomId = atomIdList[ atomIndex ];\n }\n var bFactor = null;\n if( bFactorList ){\n bFactor = bFactorList[ atomIndex ];\n }\n var altLoc = null;\n if( altLocList ){\n altLoc = String.fromCharCode( altLocList[ atomIndex ] );\n }\n var occupancy = null;\n if( occupancyList ){\n occupancy = occupancyList[ atomIndex ];\n }\n onAtom({\n atomIndex: atomIndex,\n groupIndex: groupIndex,\n chainIndex: chainIndex,\n modelIndex: modelIndex,\n atomId: atomId,\n element: groupData.elementList[ k ],\n atomName: groupData.atomNameList[ k ],\n formalCharge: groupData.formalChargeList[ k ],\n xCoord: mmtfData.xCoordList[ atomIndex ],\n yCoord: mmtfData.yCoordList[ atomIndex ],\n zCoord: mmtfData.zCoordList[ atomIndex ],\n bFactor: bFactor,\n altLoc: altLoc,\n occupancy: occupancy\n });\n }\n\n atomIndex += 1;\n }\n\n if( onBond ){\n // intra group bonds\n var groupBondAtomList = groupData.bondAtomList;\n for( k = 0, kl = groupData.bondOrderList.length; k < kl; ++k ){\n onBond({\n atomIndex1: atomIndex - groupAtomCount + groupBondAtomList[ k * 2 ],\n atomIndex2: atomIndex - groupAtomCount + groupBondAtomList[ k * 2 + 1 ],\n bondOrder: groupData.bondOrderList[ k ]\n });\n }\n }\n\n groupIndex += 1;\n }\n\n chainIndex += 1;\n }\n\n modelFirstAtomIndex = modelLastAtomIndex + 1;\n modelLastAtomIndex = atomIndex - 1; // subtract one as it already has been incremented\n\n if( onBond ){\n // inter group bonds\n if( bondAtomList ){\n for( k = 0, kl = bondAtomList.length; k < kl; k += 2 ){\n var atomIndex1 = bondAtomList[ k ];\n var atomIndex2 = bondAtomList[ k + 1 ];\n if( ( atomIndex1 >= modelFirstAtomIndex && atomIndex1 <= modelLastAtomIndex ) ||\n ( atomIndex2 >= modelFirstAtomIndex && atomIndex2 <= modelLastAtomIndex )\n ){\n onBond({\n atomIndex1: atomIndex1,\n atomIndex2: atomIndex2,\n bondOrder: bondOrderList ? bondOrderList[ k / 2 ] : null\n });\n }\n }\n }\n }\n\n modelIndex += 1;\n }\n\n}\n\n/**\n * Version name\n * @static\n * @type {String}\n */\nvar version = \"v1.1.0dev\";\n\n/**\n * Version name\n * @private\n * @type {String}\n */\nvar baseUrl = \"//mmtf.rcsb.org/v1.0/\";\n\n/**\n * URL of the RCSB webservice to obtain MMTF files\n * @static\n * @type {String}\n */\nvar fetchUrl = baseUrl + \"full/\";\n\n/**\n * URL of the RCSB webservice to obtain reduced MMTF files\n * @static\n * @type {String}\n */\nvar fetchReducedUrl = baseUrl + \"reduced/\";\n\n/**\n * Encode MMTF fields\n * @static\n * @param {module:MmtfDecode.MmtfData} mmtfData - mmtf data\n * @return {Uint8Array} encoded MMTF fields\n */\nfunction encode( mmtfData ){\n return encodeMsgpack( encodeMmtf( mmtfData ) );\n}\n\n/**\n * Decode MMTF fields\n * @static\n * @example\n * // bin is Uint8Array containing the mmtf msgpack\n * var mmtfData = MMTF.decode( bin );\n * console.log( mmtfData.numAtoms );\n *\n * @param {Uint8Array|ArrayBuffer|module:MmtfDecode.EncodedMmtfData} binOrDict - binary MessagePack or encoded MMTF data\n * @param {Object} [params] - decoding parameters\n * @param {String[]} params.ignoreFields - names of optional fields not to decode\n * @return {module:MmtfDecode.MmtfData} mmtfData\n */\nfunction decode( binOrDict, params ){\n\t// make sure binOrDict is not a plain Arraybuffer\n if( binOrDict instanceof ArrayBuffer ){\n binOrDict = new Uint8Array( binOrDict );\n }\n\n var inputDict;\n if( binOrDict instanceof Uint8Array ){\n // get dict from msgpack\n inputDict = decodeMsgpack( binOrDict );\n }else{\n // already a dict\n inputDict = binOrDict;\n }\n\n return decodeMmtf( inputDict, params );\n}\n\n/**\n * @callback module:MMTF.onLoad\n * @param {module:MmtfDecode.MmtfData} mmtfData - decoded mmtf data object\n */\n\n/**\n * helper method to fetch binary files from an URL\n * @private\n * @param {String} pdbid - PDB ID to fetch\n * @param {String} baseUrl - URL to fetch from\n * @param {module:MMTF.onLoad} onLoad - callback( mmtfData )\n * @param {Function} onError - callback( error )\n * @return {undefined}\n */\nfunction _fetch( pdbid, baseUrl, onLoad, onError ){\n var xhr = new XMLHttpRequest();\n function _onLoad(){\n try{\n var mmtfData = decode( xhr.response );\n onLoad( mmtfData );\n }catch( error ){\n onError( error );\n }\n }\n xhr.addEventListener( \"load\", _onLoad, true );\n xhr.addEventListener( \"error\", onError, true );\n xhr.responseType = \"arraybuffer\";\n xhr.open( \"GET\", baseUrl + pdbid.toUpperCase() );\n xhr.send();\n}\n\n/**\n * Fetch MMTF file from RCSB webservice which contains\n * @static\n * @example\n * MMTF.fetch(\n * \"3PQR\",\n * // onLoad callback\n * function( mmtfData ){ console.log( mmtfData ) },\n * // onError callback\n * function( error ){ console.error( error ) }\n * );\n *\n * @param {String} pdbid - PDB ID to fetch\n * @param {module:MMTF.onLoad} onLoad - callback( mmtfData )\n * @param {Function} onError - callback( error )\n * @return {undefined}\n */\nfunction fetch( pdbid, onLoad, onError ){\n _fetch( pdbid, fetchUrl, onLoad, onError );\n}\n\n/**\n * Fetch reduced MMTF file from RCSB webservice which contains\n * protein C-alpha, nucleotide phosphate and ligand atoms\n * @static\n * @example\n * MMTF.fetchReduced(\n * \"3PQR\",\n * // onLoad callback\n * function( mmtfData ){ console.log( mmtfData ) },\n * // onError callback\n * function( error ){ console.error( error ) }\n * );\n *\n * @param {String} pdbid - PDB ID to fetch\n * @param {module:MMTF.onLoad} onLoad - callback( mmtfData )\n * @param {Function} onError - callback( error )\n * @return {undefined}\n */\nfunction fetchReduced( pdbid, onLoad, onError ){\n _fetch( pdbid, fetchReducedUrl, onLoad, onError );\n}\n\nexport { encode, decode, traverseMmtf as traverse, fetch, fetchReduced, version, fetchUrl, fetchReducedUrl, encodeMsgpack, encodeMmtf, decodeMsgpack, decodeMmtf };","/**\n * @file Mmtf Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport {\n buildUnitcellAssembly, calculateBondsBetween, calculateBondsWithin\n} from '../structure/structure-utils'\nimport { ChemCompHetero } from '../structure/structure-constants'\nimport Entity from '../structure/entity'\nimport Unitcell from '../symmetry/unitcell'\nimport Assembly, { AssemblyPart } from '../symmetry/assembly'\n\nimport { decodeMsgpack, decodeMmtf } from '../../lib/mmtf.es6'\n\nconst SstrucMap: {[k: string]: number} = {\n '0': 'i'.charCodeAt(0), // pi helix\n '1': 's'.charCodeAt(0), // bend\n '2': 'h'.charCodeAt(0), // alpha helix\n '3': 'e'.charCodeAt(0), // extended\n '4': 'g'.charCodeAt(0), // 3-10 helix\n '5': 'b'.charCodeAt(0), // bridge\n '6': 't'.charCodeAt(0), // turn\n '7': 'l'.charCodeAt(0), // coil\n '-1': ''.charCodeAt(0) // NA\n}\n\nclass MmtfParser extends StructureParser {\n get type () { return 'mmtf' }\n get isBinary () { return true }\n\n _parse () {\n // https://github.com/rcsb/mmtf\n\n if (Debug) Log.time('MmtfParser._parse ' + this.name)\n\n let i, il, j, jl, groupData\n\n const s = this.structure\n const sd: {[k: string]: any} = decodeMmtf(decodeMsgpack(this.streamer.data))\n\n // structure header\n const headerFields = [\n 'depositionDate', 'releaseDate', 'resolution',\n 'rFree', 'rWork', 'experimentalMethods'\n ]\n headerFields.forEach(function (name) {\n if (sd[ name ] !== undefined) {\n s.header[ name ] = sd[ name ]\n }\n })\n\n let numBonds, numAtoms, numGroups, numChains, numModels\n let chainsPerModel\n\n s.id = sd.structureId\n s.title = sd.title\n\n s.atomStore.addField('formalCharge', 1, 'int8')\n\n if (this.firstModelOnly || this.asTrajectory) {\n numModels = 1\n numChains = sd.chainsPerModel[ 0 ]\n\n numGroups = 0\n for (i = 0, il = numChains; i < il; ++i) {\n numGroups += sd.groupsPerChain[ i ]\n }\n\n numAtoms = 0\n for (i = 0, il = numGroups; i < il; ++i) {\n groupData = sd.groupList[ sd.groupTypeList[ i ] ]\n numAtoms += groupData.atomNameList.length\n }\n\n numBonds = sd.numBonds\n\n chainsPerModel = [ numChains ]\n } else {\n numBonds = sd.numBonds\n numAtoms = sd.numAtoms\n numGroups = sd.numGroups\n numChains = sd.numChains\n numModels = sd.numModels\n\n chainsPerModel = sd.chainsPerModel\n }\n\n numBonds += numGroups // add numGroups to have space for polymer bonds\n\n //\n\n if (this.asTrajectory) {\n for (i = 0, il = sd.numModels; i < il; ++i) {\n const frame = new Float32Array(numAtoms * 3)\n const frameAtomOffset = numAtoms * i\n\n for (j = 0; j < numAtoms; ++j) {\n const j3 = j * 3\n const offset = j + frameAtomOffset\n frame[ j3 ] = sd.xCoordList[ offset ]\n frame[ j3 + 1 ] = sd.yCoordList[ offset ]\n frame[ j3 + 2 ] = sd.zCoordList[ offset ]\n }\n\n s.frames.push(frame)\n }\n }\n\n // bondStore\n const bAtomIndex1 = new Uint32Array(numBonds)\n const bAtomIndex2 = new Uint32Array(numBonds)\n const bBondOrder = new Uint8Array(numBonds)\n\n const aGroupIndex = new Uint32Array(numAtoms)\n const aFormalCharge = new Int8Array(numAtoms)\n\n const gChainIndex = new Uint32Array(numGroups)\n const gAtomOffset = new Uint32Array(numGroups)\n const gAtomCount = new Uint16Array(numGroups)\n\n const cModelIndex = new Uint16Array(numChains)\n const cGroupOffset = new Uint32Array(numChains)\n const cGroupCount = new Uint32Array(numChains)\n\n const mChainOffset = new Uint32Array(numModels)\n const mChainCount = new Uint32Array(numModels)\n\n // set-up model-chain relations\n let chainOffset = 0\n for (i = 0, il = numModels; i < il; ++i) {\n const modelChainCount = chainsPerModel[ i ]\n mChainOffset[ i ] = chainOffset\n mChainCount[ i ] = modelChainCount\n for (j = 0; j < modelChainCount; ++j) {\n cModelIndex[ j + chainOffset ] = i\n }\n chainOffset += modelChainCount\n }\n\n // set-up chain-residue relations\n const groupsPerChain = sd.groupsPerChain\n let groupOffset = 0\n for (i = 0, il = numChains; i < il; ++i) {\n const chainGroupCount = groupsPerChain[ i ]\n cGroupOffset[ i ] = groupOffset\n cGroupCount[ i ] = chainGroupCount\n for (j = 0; j < chainGroupCount; ++j) {\n gChainIndex[ j + groupOffset ] = i\n }\n groupOffset += chainGroupCount\n }\n\n /// ///\n // get data from group map\n\n let atomOffset = 0\n let bondOffset = 0\n\n for (i = 0, il = numGroups; i < il; ++i) {\n groupData = sd.groupList[ sd.groupTypeList[ i ] ]\n const groupAtomCount = groupData.atomNameList.length\n const groupFormalChargeList = groupData.formalChargeList\n\n const groupBondAtomList = groupData.bondAtomList\n const groupBondOrderList = groupData.bondOrderList\n\n for (j = 0, jl = groupBondOrderList.length; j < jl; ++j) {\n bAtomIndex1[ bondOffset ] = atomOffset + groupBondAtomList[ j * 2 ]\n bAtomIndex2[ bondOffset ] = atomOffset + groupBondAtomList[ j * 2 + 1 ]\n bBondOrder[ bondOffset ] = groupBondOrderList[ j ]\n bondOffset += 1\n }\n\n //\n\n gAtomOffset[ i ] = atomOffset\n gAtomCount[ i ] = groupAtomCount\n\n for (j = 0; j < groupAtomCount; ++j) {\n aGroupIndex[ atomOffset ] = i\n aFormalCharge[ atomOffset ] = groupFormalChargeList[ j ]\n atomOffset += 1\n }\n }\n\n // extra bonds\n\n const bondAtomList = sd.bondAtomList\n if (bondAtomList) {\n if (sd.bondOrderList) {\n bBondOrder.set(sd.bondOrderList, bondOffset)\n }\n\n for (i = 0, il = bondAtomList.length; i < il; i += 2) {\n const atomIndex1 = bondAtomList[ i ]\n const atomIndex2 = bondAtomList[ i + 1 ]\n if (atomIndex1 < numAtoms && atomIndex2 < numAtoms) {\n bAtomIndex1[ bondOffset ] = atomIndex1\n bAtomIndex2[ bondOffset ] = atomIndex2\n bondOffset += 1\n }\n }\n }\n\n //\n\n s.bondStore.length = bBondOrder.length\n s.bondStore.count = bondOffset\n s.bondStore.atomIndex1 = bAtomIndex1\n s.bondStore.atomIndex2 = bAtomIndex2\n s.bondStore.bondOrder = bBondOrder\n\n s.atomStore.length = numAtoms\n s.atomStore.count = numAtoms\n s.atomStore.residueIndex = aGroupIndex\n s.atomStore.atomTypeId = new Uint16Array(numAtoms)\n s.atomStore.x = sd.xCoordList.subarray(0, numAtoms)\n s.atomStore.y = sd.yCoordList.subarray(0, numAtoms)\n s.atomStore.z = sd.zCoordList.subarray(0, numAtoms)\n s.atomStore.serial = sd.atomIdList.subarray(0, numAtoms)\n s.atomStore.bfactor = sd.bFactorList.subarray(0, numAtoms)\n s.atomStore.altloc = sd.altLocList.subarray(0, numAtoms)\n s.atomStore.occupancy = sd.occupancyList.subarray(0, numAtoms)\n s.atomStore.formalCharge = aFormalCharge\n\n s.residueStore.length = numGroups\n s.residueStore.count = numGroups\n s.residueStore.chainIndex = gChainIndex\n s.residueStore.residueTypeId = sd.groupTypeList\n s.residueStore.atomOffset = gAtomOffset\n s.residueStore.atomCount = gAtomCount\n s.residueStore.resno = sd.groupIdList.subarray(0, numGroups)\n s.residueStore.sstruc = sd.secStructList.subarray(0, numGroups)\n s.residueStore.inscode = sd.insCodeList.subarray(0, numGroups)\n\n s.chainStore.length = numChains\n s.chainStore.count = numChains\n s.chainStore.entityIndex = new Uint16Array(numChains)\n s.chainStore.modelIndex = cModelIndex\n s.chainStore.residueOffset = cGroupOffset\n s.chainStore.residueCount = cGroupCount\n s.chainStore.chainname = sd.chainNameList.subarray(0, numChains * 4)\n s.chainStore.chainid = sd.chainIdList.subarray(0, numChains * 4)\n\n s.modelStore.length = numModels\n s.modelStore.count = numModels\n s.modelStore.chainOffset = mChainOffset\n s.modelStore.chainCount = mChainCount\n\n //\n\n let groupTypeDict: {[k: number]: any} = {}\n for (i = 0, il = sd.groupList.length; i < il; ++i) {\n const groupType = sd.groupList[ i ]\n const atomTypeIdList: number[] = []\n for (j = 0, jl = groupType.atomNameList.length; j < jl; ++j) {\n const element = groupType.elementList[ j ].toUpperCase()\n const atomname = groupType.atomNameList[ j ]\n atomTypeIdList.push(s.atomMap.add(atomname, element))\n }\n const chemCompType = groupType.chemCompType.toUpperCase()\n const hetFlag = ChemCompHetero.includes(chemCompType)\n\n const numGroupBonds = groupType.bondOrderList.length\n const atomIndices1 = new Array(numGroupBonds)\n const atomIndices2 = new Array(numGroupBonds)\n for (j = 0; j < numGroupBonds; ++j) {\n atomIndices1[ j ] = groupType.bondAtomList[ j * 2 ]\n atomIndices2[ j ] = groupType.bondAtomList[ j * 2 + 1 ]\n }\n const bonds = {\n atomIndices1: atomIndices1,\n atomIndices2: atomIndices2,\n bondOrders: groupType.bondOrderList\n }\n\n groupTypeDict[ i ] = s.residueMap.add(\n groupType.groupName, atomTypeIdList, hetFlag, chemCompType, bonds\n )\n }\n\n for (i = 0, il = numGroups; i < il; ++i) {\n s.residueStore.residueTypeId[ i ] = groupTypeDict[ s.residueStore.residueTypeId[ i ] ]\n }\n\n for (i = 0, il = s.atomStore.count; i < il; ++i) {\n const residueIndex = s.atomStore.residueIndex[ i ]\n const residueType = s.residueMap.list[ s.residueStore.residueTypeId[ residueIndex ] ]\n const resAtomOffset = s.residueStore.atomOffset[ residueIndex ]\n s.atomStore.atomTypeId[ i ] = residueType.atomTypeIdList[ i - resAtomOffset ]\n }\n\n if (sd.secStructList) {\n const secStructLength: number = sd.secStructList.length\n for (i = 0, il = s.residueStore.count; i < il; ++i) {\n // with ( i % secStructLength ) secStruct entries are reused\n const sstruc = SstrucMap[ s.residueStore.sstruc[ i % secStructLength ] ]\n if (sstruc !== undefined) s.residueStore.sstruc[ i ] = sstruc\n }\n }\n\n //\n\n if (sd.entityList) {\n sd.entityList.forEach(function (e: Entity, i: number) {\n s.entityList[ i ] = new Entity(\n s, i, e.description, e.type, e.chainIndexList\n )\n })\n }\n\n if (sd.bioAssemblyList) {\n sd.bioAssemblyList.forEach(function (_assembly: any, k: number) {\n const id = k + 1\n const assembly = new Assembly('' + id)\n s.biomolDict[ 'BU' + id ] = assembly\n let chainToPart: {[k: string]: AssemblyPart} = {}\n _assembly.transformList.forEach(function (_transform: any) {\n const matrix = new Matrix4().fromArray(_transform.matrix).transpose()\n const chainList: string[] = _transform.chainIndexList.map(function (chainIndex: number) {\n let chainname = ''\n for (let k = 0; k < 4; ++k) {\n const code = sd.chainNameList[ chainIndex * 4 + k ]\n if (code) {\n chainname += String.fromCharCode(code)\n } else {\n break\n }\n }\n return chainname\n })\n const part = chainToPart[ chainList.toString() ]\n if (part) {\n part.matrixList.push(matrix)\n } else {\n chainToPart[ chainList.toString() ] = assembly.addPart([ matrix ], chainList)\n }\n })\n })\n }\n\n if (sd.ncsOperatorList) {\n const ncsName = 'NCS'\n const ncsAssembly = new Assembly(ncsName)\n const ncsPart = ncsAssembly.addPart()\n sd.ncsOperatorList.forEach(function (_operator: number[]) {\n const matrix = new Matrix4().fromArray(_operator).transpose()\n ncsPart.matrixList.push(matrix)\n })\n if (ncsPart.matrixList.length > 0) {\n s.biomolDict[ ncsName ] = ncsAssembly\n }\n }\n\n const uc = sd.unitCell\n if (uc && Array.isArray(uc) && uc[ 0 ]) {\n s.unitcell = new Unitcell({\n a: uc[ 0 ],\n b: uc[ 1 ],\n c: uc[ 2 ],\n alpha: uc[ 3 ],\n beta: uc[ 4 ],\n gamma: uc[ 5 ],\n spacegroup: sd.spaceGroup\n })\n } else {\n s.unitcell = undefined\n }\n\n // calculate backbone bonds\n calculateBondsBetween(s, true)\n\n // calculate rung bonds\n calculateBondsWithin(s, true)\n\n s.finalizeAtoms()\n s.finalizeBonds()\n\n buildUnitcellAssembly(s)\n\n if (Debug) Log.timeEnd('MmtfParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('mmtf', MmtfParser)\n\nexport default MmtfParser\n","/**\n * @file Mol2 Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport {\n assignResidueTypeBonds,\n calculateChainnames, calculateSecondaryStructure,\n calculateBondsBetween, calculateBondsWithin\n} from '../structure/structure-utils'\nimport StructureParser from './structure-parser'\n\nconst reWhitespace = /\\s+/\nconst bondTypes: {[k: string]: number} = {\n '1': 1,\n '2': 2,\n '3': 3,\n 'am': 1, // amide\n 'ar': 1, // aromatic\n 'du': 1, // dummy\n 'un': 1, // unknown\n 'nc': 0 // not connected\n}\n\nclass Mol2Parser extends StructureParser {\n get type () { return 'mol2' }\n\n _parse () {\n // http://paulbourke.net/dataformats/mol2/\n\n if (Debug) Log.time('Mol2Parser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n const firstModelOnly = this.firstModelOnly\n const asTrajectory = this.asTrajectory\n\n const frames = s.frames\n let doFrames = false\n let currentFrame: Float32Array, currentCoord: number\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.resize(Math.round(this.streamer.data.length / 60))\n atomStore.addField('partialCharge', 1, 'float32')\n\n let idx = 0\n let moleculeLineNo = 0\n let modelAtomIdxStart = 0\n let modelIdx = -1\n let numAtoms = 0\n\n let currentRecordType = 0\n let moleculeRecordType = 1\n let atomRecordType = 2\n let bondRecordType = 3\n\n const ap1 = s.getAtomProxy()\n const ap2 = s.getAtomProxy()\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ].trim()\n\n if (line === '' || line[ 0 ] === '#') continue\n\n if (line[ 0 ] === '@') {\n if (line === '@MOLECULE') {\n currentRecordType = moleculeRecordType\n moleculeLineNo = 0\n\n ++modelIdx\n } else if (line === '@ATOM') {\n currentRecordType = atomRecordType\n modelAtomIdxStart = atomStore.count\n\n if (asTrajectory) {\n currentCoord = 0\n currentFrame = new Float32Array(numAtoms * 3)\n frames.push(currentFrame)\n\n if (modelIdx > 0) doFrames = true\n }\n } else if (line === '@BOND') {\n currentRecordType = bondRecordType\n } else {\n currentRecordType = 0\n }\n } else if (currentRecordType === moleculeRecordType) {\n if (moleculeLineNo === 0) {\n s.title = line\n s.id = line\n } else if (moleculeLineNo === 1) {\n const ls = line.split(reWhitespace)\n numAtoms = parseInt(ls[ 0 ])\n // num_atoms [num_bonds [num_subst [num_feat [num_sets]]]]\n } else if (moleculeLineNo === 2) {\n\n // const molType = line;\n // SMALL, BIOPOLYMER, PROTEIN, NUCLEIC_ACID, SACCHARIDE\n\n } else if (moleculeLineNo === 3) {\n\n // const chargeType = line;\n // NO_CHARGES, DEL_RE, GASTEIGER, GAST_HUCK, HUCKEL,\n // PULLMAN, GAUSS80_CHARGES, AMPAC_CHARGES,\n // MULLIKEN_CHARGES, DICT_ CHARGES, MMFF94_CHARGES,\n // USER_CHARGES\n\n } else if (moleculeLineNo === 4) {\n\n // const statusBits = line;\n\n } else if (moleculeLineNo === 5) {\n\n // const molComment = line;\n\n }\n\n ++moleculeLineNo\n } else if (currentRecordType === atomRecordType) {\n const ls = line.split(reWhitespace)\n\n if (firstModelOnly && modelIdx > 0) continue\n\n const x = parseFloat(ls[ 2 ])\n const y = parseFloat(ls[ 3 ])\n const z = parseFloat(ls[ 4 ])\n\n if (asTrajectory) {\n const j = currentCoord * 3\n\n currentFrame[ j + 0 ] = x\n currentFrame[ j + 1 ] = y\n currentFrame[ j + 2 ] = z\n\n currentCoord += 1\n\n if (doFrames) continue\n }\n\n const serial = ls[ 0 ]\n const atomname = ls[ 1 ]\n const element = ls[ 5 ].split('.')[ 0 ]\n const resno = ls[ 6 ] ? parseInt(ls[ 6 ]) : 1\n const resname = ls[ 7 ] ? ls[ 7 ] : ''\n const partialCharge = ls[ 8 ] ? parseFloat(ls[ 8 ]) : 0.0\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname, element)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = serial\n atomStore.partialCharge[ idx ] = partialCharge\n\n sb.addAtom(modelIdx, '', '', resname, resno, true)\n\n idx += 1\n } else if (currentRecordType === bondRecordType) {\n if (firstModelOnly && modelIdx > 0) continue\n if (asTrajectory && modelIdx > 0) continue\n\n const ls = line.split(reWhitespace)\n\n // ls[ 0 ] is bond id\n ap1.index = parseInt(ls[ 1 ]) - 1 + modelAtomIdxStart\n ap2.index = parseInt(ls[ 2 ]) - 1 + modelAtomIdxStart\n const order = bondTypes[ ls[ 3 ] ]\n\n s.bondStore.addBond(ap1, ap2, order)\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n sb.finalize()\n s.finalizeAtoms()\n calculateChainnames(s)\n calculateBondsWithin(s, true)\n calculateBondsBetween(s, true)\n s.finalizeBonds()\n assignResidueTypeBonds(s)\n calculateSecondaryStructure(s)\n\n if (Debug) Log.timeEnd('Mol2Parser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('mol2', Mol2Parser)\n\nexport default Mol2Parser\n","/**\n * @file Pdbqt Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport PdbParser from './pdb-parser'\n\n// autodock variant of PDB format with\n// - atom partial charges (empty column in pdb format)\n// - atom types (bfactor column in pdb format)\n// http://autodock.scripps.edu/faqs-help/faq/what-is-the-format-of-a-pdbqt-file\n\nclass PdbqtParser extends PdbParser {\n get type () { return 'pdbqt' }\n}\n\nParserRegistry.add('pdbqt', PdbqtParser)\n\nexport default PdbqtParser\n","/**\n * @file Pqr Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport PdbParser from './pdb-parser'\n\n// http://www.poissonboltzmann.org/docs/file-format-info/\n\nclass PqrParser extends PdbParser {\n get type () { return 'pqr' }\n}\n\nParserRegistry.add('pqr', PqrParser)\n\nexport default PqrParser\n","/**\n * @file Sdf Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { assignResidueTypeBonds } from '../structure/structure-utils'\nimport StructureParser from './structure-parser'\n\nconst reItem = /> +<(.+)>/\n\nclass SdfParser extends StructureParser {\n get type () { return 'sdf' }\n\n _parse () {\n // https://en.wikipedia.org/wiki/Chemical_table_file#SDF\n // http://download.accelrys.com/freeware/ctfile-formats/ctfile-formats.zip\n\n if (Debug) Log.time('SdfParser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n const firstModelOnly = this.firstModelOnly\n const asTrajectory = this.asTrajectory\n\n const headerLines = this.streamer.peekLines(2)\n\n s.id = headerLines[ 0 ].trim()\n s.title = headerLines[ 1 ].trim()\n\n const frames = s.frames\n let doFrames = false\n let currentFrame: Float32Array, currentCoord: number\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.resize(Math.round(this.streamer.data.length / 50))\n atomStore.addField('formalCharge', 1, 'int8')\n\n const ap1 = s.getAtomProxy()\n const ap2 = s.getAtomProxy()\n\n let idx = 0\n let lineNo = 0 // for V2000: current line number in currently parsed Mol file\n let modelIdx = 0\n let modelAtomIdxStart = 0\n\n const sdfData: {[k: string]: string[]}[] = []\n let currentItem: string|boolean = false\n let currentData: {[k: string]: string[]} = {}\n let mItem: RegExpMatchArray | null\n s.extraData.sdf = sdfData\n\n let atomCount, bondCount, atomStart: number, atomEnd: number, bondStart: number, bondEnd: number, x: number, y: number, z: number, atomname: string, element: string, atomindex: number, order: number\n let isV3000 = false, isAtomBlock = false, isBondBlock = false\n let tokens: string[] = [], acc: string[] = []\n const atomindexToStoreindex = new Map()\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n\n if (isV3000 && line) {\n tokens = line.substring(7).split(' ')\n\n // Entity properties may extend over multiple lines (hanging line finishes with '-')\n // Tokens are accumulated to be processed at the same time for a given entity\n if (acc.length) {\n tokens = [...acc, ...tokens]\n acc = []\n }\n if (tokens[tokens.length - 1] === '-') {\n tokens.pop();\n acc = tokens;\n continue;\n }\n }\n\n if (line.substr(0, 4) === '$$$$') {\n lineNo = -1\n ++modelIdx\n modelAtomIdxStart = atomStore.count\n sdfData.push(currentData)\n currentData = {}\n currentItem = false\n isV3000 = false\n } else if (lineNo === 3) {\n isV3000 = line.indexOf(' V3000') > -1\n\n if (isV3000) {\n atomindexToStoreindex.clear()\n } else {\n\n atomCount = parseInt(line.substr(0, 3))\n bondCount = parseInt(line.substr(3, 3))\n\n atomStart = 4\n atomEnd = atomStart + atomCount\n bondStart = atomEnd\n bondEnd = bondStart + bondCount\n\n if (asTrajectory) {\n currentCoord = 0\n currentFrame = new Float32Array(atomCount * 3)\n frames.push(currentFrame)\n\n if (modelIdx > 0) doFrames = true\n }\n }\n } else if (isV3000 && tokens[0] === 'COUNTS') {\n atomCount = parseInt(tokens[1]);\n\n if (asTrajectory) {\n currentCoord = 0\n currentFrame = new Float32Array(atomCount * 3)\n frames.push(currentFrame)\n\n if (modelIdx > 0) doFrames = true\n }\n } else if (isV3000 && tokens.length == 2) {\n if (tokens[1] === 'ATOM') {\n if (tokens[0] === 'BEGIN') isAtomBlock = true\n else if (tokens[0] === 'END') isAtomBlock = false\n } else if (tokens[1] === 'BOND') {\n if (tokens[0] === 'BEGIN') isBondBlock = true\n else if (tokens[0] === 'END') isBondBlock = false\n }\n } else if (\n isAtomBlock \n || (!isV3000 && lineNo >= atomStart && lineNo < atomEnd)\n ) {\n if (firstModelOnly && modelIdx > 0) continue\n\n let charge = 0\n if (isV3000) {\n x = parseFloat(tokens[2])\n y = parseFloat(tokens[3])\n z = parseFloat(tokens[4])\n\n element = tokens[1]\n atomindex = parseInt(tokens[0])\n atomindexToStoreindex.set(atomindex, idx)\n atomname = element + atomindex\n\n if (tokens.length > 6) {\n let chgTok = tokens.slice(6).find(t => t.indexOf('CHG=') === 0);\n if (chgTok) {\n charge = parseInt(chgTok.substring(4))\n }\n }\n } else {\n x = parseFloat(line.substr(0, 10))\n y = parseFloat(line.substr(10, 10))\n z = parseFloat(line.substr(20, 10))\n\n element = line.substr(31, 3).trim()\n atomname = element + (idx - modelAtomIdxStart + 1)\n }\n\n if (asTrajectory) {\n const j = currentCoord * 3\n\n currentFrame[ j + 0 ] = x\n currentFrame[ j + 1 ] = y\n currentFrame[ j + 2 ] = z\n\n currentCoord += 1\n\n if (doFrames) continue\n }\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname, element)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = isV3000 ? atomindex : idx\n atomStore.formalCharge[ idx ] = charge\n\n sb.addAtom(modelIdx, '', '', 'HET', 1, true)\n\n idx += 1\n } else if (\n isBondBlock \n || (!isV3000 && lineNo >= bondStart && lineNo < bondEnd)\n ) {\n if (firstModelOnly && modelIdx > 0) continue\n if (asTrajectory && modelIdx > 0) continue\n\n if (isV3000) {\n ap1.index = atomindexToStoreindex.get(parseInt(tokens[2]))\n ap2.index = atomindexToStoreindex.get(parseInt(tokens[3]))\n order = parseInt(tokens[1])\n } else {\n ap1.index = parseInt(line.substr(0, 3)) - 1 + modelAtomIdxStart\n ap2.index = parseInt(line.substr(3, 3)) - 1 + modelAtomIdxStart\n order = parseInt(line.substr(6, 3))\n }\n\n s.bondStore.addBond(ap1, ap2, order)\n } else if (line.substr(0, 6) === 'M CHG') {\n const chargeCount = parseInt(line.substr(6, 3))\n for (let ci = 0, coffset = 10; ci < chargeCount; ++ci, coffset += 8) {\n const aToken = parseInt(line.substr(coffset, 3))\n const atomIdx = aToken - 1 + modelAtomIdxStart\n const cToken = parseInt(line.substr(coffset + 4, 3))\n atomStore.formalCharge[ atomIdx ] = cToken\n }\n // eslint-disable-next-line no-cond-assign\n } else if (line.charAt(0) === '>' && (mItem = line.match(reItem))) {\n currentItem = mItem[ 1 ]\n currentData[ currentItem ] = []\n } else if (currentItem !== false && line) {\n currentData[ currentItem ].push(line)\n }\n\n ++lineNo\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n assignResidueTypeBonds(s)\n\n if (Debug) Log.timeEnd('SdfParser._parse ' + this.name)\n }\n\n _postProcess () {\n assignResidueTypeBonds(this.structure)\n }\n}\n\nParserRegistry.add('sdf', SdfParser)\nParserRegistry.add('sd', SdfParser)\nParserRegistry.add('mol', SdfParser)\n\nexport default SdfParser\n","/**\n * @file Prmtop Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport {\n assignResidueTypeBonds, calculateBondsBetween,\n calculateBondsWithin, calculateChainnames\n} from '../structure/structure-utils'\n\nconst amberChargeUnitFactor = 18.2223\n\nconst enum Mode {\n Title,\n Pointers,\n AtomName,\n Charge,\n Mass,\n ResidueLabel,\n ResiduePointer,\n BondsIncHydrogen,\n BondsWithoutHydrogen,\n Radii\n}\n\nfunction parseIntSubstr (line: string, start: number, length: number) {\n return parseInt(line.substr(start, length).trim())\n}\n\nclass PrmtopParser extends StructureParser {\n get type () { return 'prmtop' }\n\n _parse () {\n // http://ambermd.org/prmtop.pdf\n // http://ambermd.org/formats.html#topology\n\n if (Debug) Log.time('PrmtopParser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n //\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.addField('partialCharge', 1, 'float32')\n atomStore.addField('radius', 1, 'float32')\n\n const title: string[] = []\n const pointersDict: {[k: string]: number} = {}\n const pointers = [\n 'NATOM', 'NTYPES', 'NBONH', 'MBONA', 'NTHETH', 'MTHETA',\n 'NPHIH', 'MPHIA', 'NHPARM', 'NPARM', 'NNB', 'NRES',\n 'NBONA', 'NTHETA', 'NPHIA', 'NUMBND', 'NUMANG', 'NPTRA',\n 'NATYP', 'NPHB', 'IFPERT', 'NBPER', 'NGPER', 'NDPER',\n 'MBPER', 'MGPER', 'MDPER', 'IFBOX', 'NMXRS', 'IFCAP',\n 'NUMEXTRA', 'NCOPY'\n ]\n pointers.forEach(name => { pointersDict[ name ] = 0 })\n\n let atomNames: string[]\n let charges: Float32Array\n let radii: Float32Array\n let bAtomIndex1: Uint32Array\n let bAtomIndex2: Uint32Array\n let bBondOrder: Uint8Array = new Uint8Array(0)\n let residueLabels: string[]\n let residuePointers: Uint32Array\n\n let mode: number|undefined\n // let currentFormat\n let curIdx: number\n let bondIdx: number\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n const lt = line.trim()\n\n if (!lt) {\n continue\n } else if (line.startsWith('%FORMAT')) {\n // currentFormat = lt.substring(8, lt.length - 1)\n } else if (line.startsWith('%FLAG')) {\n const flag = line.substr(5).trim()\n curIdx = 0\n\n if (flag === 'TITLE') {\n mode = Mode.Title\n } else if (flag === 'POINTERS') {\n mode = Mode.Pointers\n } else if (flag === 'ATOM_NAME') {\n mode = Mode.AtomName\n } else if (flag === 'CHARGE') {\n mode = Mode.Charge\n } else if (flag === 'MASS') {\n mode = Mode.Mass\n } else if (flag === 'RESIDUE_LABEL') {\n mode = Mode.ResidueLabel\n } else if (flag === 'RESIDUE_POINTER') {\n mode = Mode.ResiduePointer\n } else if (flag === 'BONDS_INC_HYDROGEN') {\n bondIdx = 0\n mode = Mode.BondsIncHydrogen\n } else if (flag === 'BONDS_WITHOUT_HYDROGEN') {\n bondIdx = pointersDict['NBONH']\n mode = Mode.BondsWithoutHydrogen\n } else if (flag === 'RADII') {\n mode = Mode.Radii\n } else {\n mode = undefined\n }\n } else if (mode === Mode.Title) {\n title.push(lt)\n } else if (mode === Mode.Pointers) {\n const n = Math.min(curIdx + 10, 32)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n pointersDict[pointers[curIdx]] = parseInt(\n line.substr(i * 8, 8).trim()\n )\n }\n atomNames = new Array(pointersDict.NATOM)\n charges = new Float32Array(pointersDict.NATOM)\n radii = new Float32Array(pointersDict.NATOM)\n atomStore.resize(pointersDict.NATOM)\n const bondCount = pointersDict.NBONH + pointersDict.MBONA\n bAtomIndex1 = new Uint32Array(bondCount)\n bAtomIndex2 = new Uint32Array(bondCount)\n bBondOrder = new Uint8Array(bondCount)\n residueLabels = new Array(pointersDict.NRES)\n residuePointers = new Uint32Array(pointersDict.NRES)\n } else if (mode === Mode.AtomName) {\n const n = Math.min(curIdx + 20, pointersDict.NATOM)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n atomNames[curIdx] = line.substr(i * 4, 4).trim()\n }\n } else if (mode === Mode.Charge) {\n const n = Math.min(curIdx + 5, pointersDict.NATOM)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n charges[curIdx] = parseFloat(line.substr(i * 16, 16)) / amberChargeUnitFactor\n }\n } else if (mode === Mode.Mass) {\n\n // not currently used\n\n } else if (mode === Mode.ResidueLabel) {\n const n = Math.min(curIdx + 20, pointersDict.NRES)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n residueLabels[curIdx] = line.substr(i * 4, 4).trim()\n }\n } else if (mode === Mode.ResiduePointer) {\n const n = Math.min(curIdx + 10, pointersDict.NRES)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n residuePointers[curIdx] = parseIntSubstr(line, i * 8, 8)\n }\n } else if (mode === Mode.BondsIncHydrogen) {\n const n = Math.min(curIdx + 10, pointersDict.NBONH * 3)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n const r = curIdx % 3\n if (r === 0) {\n bAtomIndex1[bondIdx] = parseIntSubstr(line, i * 8, 8) / 3\n } if (r === 1) {\n bAtomIndex2[bondIdx] = parseIntSubstr(line, i * 8, 8) / 3\n bBondOrder[bondIdx] = 1\n ++bondIdx\n }\n }\n } else if (mode === Mode.BondsWithoutHydrogen) {\n const n = Math.min(curIdx + 10, pointersDict.MBONA * 3)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n const r = curIdx % 3\n if (r === 0) {\n bAtomIndex1[bondIdx] = parseIntSubstr(line, i * 8, 8) / 3\n } if (r === 1) {\n bAtomIndex2[bondIdx] = parseIntSubstr(line, i * 8, 8) / 3\n bBondOrder[bondIdx] = 1\n ++bondIdx\n }\n }\n } else if (mode === Mode.Radii) {\n const n = Math.min(curIdx + 5, pointersDict.NATOM)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n radii[curIdx] = parseFloat(line.substr(i * 16, 16))\n }\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n s.title = title.join(' ')\n\n const atomCount = pointersDict.NATOM\n let curResIdx = 0\n let curResname = residueLabels![0]\n let curResno = 1\n for (let i = 0; i < atomCount; ++i) {\n if (i + 1 === residuePointers![curResIdx + 1]) {\n ++curResIdx\n curResname = residueLabels![curResIdx]\n curResno = curResIdx + 1\n }\n atomStore.atomTypeId[i] = atomMap.add(atomNames![i])\n atomStore.serial[i] = i + 1\n sb.addAtom(0, '', '', curResname, curResno, false)\n }\n\n atomStore.partialCharge.set(charges!)\n atomStore.radius.set(radii!)\n\n s.bondStore.length = bBondOrder!.length\n s.bondStore.count = bBondOrder!.length\n s.bondStore.atomIndex1 = bAtomIndex1!\n s.bondStore.atomIndex2 = bAtomIndex2!\n s.bondStore.bondOrder = bBondOrder\n\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n calculateBondsWithin(s, true)\n calculateBondsBetween(s, true, true)\n calculateChainnames(s, true)\n assignResidueTypeBonds(s)\n\n if (Debug) Log.timeEnd('PrmtopParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('prmtop', PrmtopParser)\nParserRegistry.add('parm7', PrmtopParser)\n\nexport default PrmtopParser\n","/**\n * @file Psf Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport {\n assignResidueTypeBonds, calculateBondsBetween,\n calculateBondsWithin, getChainname\n} from '../structure/structure-utils'\n\nconst TitleMode = 1\nconst AtomMode = 2\nconst BondMode = 3\nconst AngleMode = 4\nconst DihedralMode = 5\nconst ImproperMode = 6\n\nconst reWhitespace = /\\s+/\nconst reTitle = /(^\\*|REMARK)*/\n\nclass PsfParser extends StructureParser {\n get type () { return 'psf' }\n\n _parse () {\n // http://www.ks.uiuc.edu/Training/Tutorials/namd/namd-tutorial-unix-html/node23.html\n\n if (Debug) Log.time('PsfParser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n //\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.addField('partialCharge', 1, 'float32')\n\n const title: string[] = []\n\n let mode: number|undefined\n let chainid: string\n let lastSegid: string\n let idx = 0\n let chainIdx = 0\n let bondIdx = 0\n let bAtomIndex1: Uint32Array, bAtomIndex2: Uint32Array, bBondOrder: Uint8Array\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ].trim()\n\n if (!line) {\n mode = undefined\n continue\n }\n\n if (mode === AtomMode) {\n const ls = line.split(reWhitespace)\n\n const serial = parseInt(ls[ 0 ])\n const segid = ls[ 1 ]\n const resno = parseInt(ls[ 2 ])\n const resname = ls[ 3 ]\n const atomname = ls[ 4 ]\n const charge = parseFloat(ls[ 6 ])\n\n if (segid !== lastSegid) {\n chainid = getChainname(chainIdx)\n ++chainIdx\n }\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname)\n\n atomStore.serial[ idx ] = serial\n atomStore.partialCharge[ idx ] = charge\n\n sb.addAtom(0, chainid, chainid, resname, resno, false)\n\n idx += 1\n lastSegid = segid\n } else if (mode === BondMode) {\n const ls = line.split(reWhitespace)\n\n for (let j = 0, m = ls.length; j < m; j += 2) {\n bAtomIndex1[ bondIdx ] = parseInt(ls[ j ]) - 1\n bAtomIndex2[ bondIdx ] = parseInt(ls[ j + 1 ]) - 1\n bBondOrder[ bondIdx ] = 1\n bondIdx += 1\n }\n } else if (mode === TitleMode) {\n title.push(line.replace(reTitle, '').trim())\n } else if (mode === AngleMode) {\n\n // currently not used\n\n } else if (mode === DihedralMode) {\n\n // currently not used\n\n } else if (mode === ImproperMode) {\n\n // currently not used\n\n } else if (line.includes('!NATOM')) {\n mode = AtomMode\n\n const numAtoms = parseInt(line.split(reWhitespace)[ 0 ])\n atomStore.resize(numAtoms)\n } else if (line.includes('!NBOND')) {\n mode = BondMode\n\n const numBonds = parseInt(line.split(reWhitespace)[ 0 ])\n bAtomIndex1 = new Uint32Array(numBonds)\n bAtomIndex2 = new Uint32Array(numBonds)\n bBondOrder = new Uint8Array(numBonds)\n } else if (line.includes('!NTITLE')) {\n mode = TitleMode\n } else if (line.includes('!NTHETA')) {\n mode = AngleMode\n } else if (line.includes('!NPHI')) {\n mode = DihedralMode\n } else if (line.includes('!NIMPHI')) {\n mode = ImproperMode\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n s.title = title.join(' ')\n\n s.bondStore.length = bBondOrder!.length\n s.bondStore.count = bondIdx\n s.bondStore.atomIndex1 = bAtomIndex1!\n s.bondStore.atomIndex2 = bAtomIndex2!\n s.bondStore.bondOrder = bBondOrder!\n\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n calculateBondsWithin(s, true)\n calculateBondsBetween(s, true, true)\n assignResidueTypeBonds(s)\n\n if (Debug) Log.timeEnd('PsfParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('psf', PsfParser)\n\nexport default PsfParser\n","/**\n * @file Top Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport { WaterNames } from '../structure/structure-constants'\nimport {\n assignResidueTypeBonds, calculateBondsBetween,\n calculateBondsWithin, getChainname\n} from '../structure/structure-utils'\n\nconst enum Mode {\n System,\n Molecules,\n Moleculetype,\n Atoms,\n Bonds\n}\n\nconst reField = /\\[ (.+) \\]/\nconst reWhitespace = /\\s+/\n\nclass TopParser extends StructureParser {\n get type () { return 'top' }\n\n _parse () {\n // http://manual.gromacs.org/online/top.html\n\n if (Debug) Log.time('TopParser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n //\n\n const atomMap = s.atomMap\n const bondStore = s.bondStore\n\n const atomStore = s.atomStore\n atomStore.addField('partialCharge', 1, 'float32')\n\n const molecules: [string, number][] = []\n const moleculetypeDict: {[k: string]: {atoms: any[], bonds: any[] }} = {}\n\n let currentMoleculetype: {\n atoms: [number, string, string, number][],\n bonds: [number, number][]\n }\n let mode: number|undefined\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n let lt = line.trim()\n\n if (!lt || lt[0] === '*' || lt[0] === ';') {\n continue\n }\n\n if (lt.startsWith('#include')) {\n throw new Error('TopParser: #include statements not allowed')\n }\n\n const fieldMatch = line.match(reField)\n if (fieldMatch !== null) {\n const name = fieldMatch[1]\n if (name === 'moleculetype') {\n mode = Mode.Moleculetype\n currentMoleculetype = {\n atoms: [],\n bonds: []\n }\n } else if (name === 'atoms') {\n mode = Mode.Atoms\n } else if (name === 'bonds') {\n mode = Mode.Bonds\n } else if (name === 'system') {\n mode = Mode.System\n } else if (name === 'molecules') {\n mode = Mode.Molecules\n } else {\n mode = undefined\n }\n continue\n }\n\n const cIdx = lt.indexOf(';')\n if (cIdx !== -1) {\n lt = lt.substring(0, cIdx).trim()\n }\n if (mode === Mode.Moleculetype) {\n const molName = lt.split(reWhitespace)[0]\n moleculetypeDict[molName] = currentMoleculetype\n } else if (mode === Mode.Atoms) {\n const ls = lt.split(reWhitespace)\n currentMoleculetype.atoms.push([\n parseInt(ls[2]), // resnr\n ls[3], // residue\n ls[4], // atom\n parseFloat(ls[6]) // charge\n ])\n } else if (mode === Mode.Bonds) {\n const ls = lt.split(reWhitespace)\n currentMoleculetype.bonds.push([\n parseInt(ls[0]), // ai\n parseInt(ls[1]) // aj\n ])\n } else if (mode === Mode.System) {\n s.title = lt\n } else if (mode === Mode.Molecules) {\n const ls = lt.split(reWhitespace)\n molecules.push([\n ls[0], // name\n parseInt(ls[1]) // count\n ])\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n let atomCount = 0\n let bondCount = 0\n molecules.forEach(function (val) {\n const [name, molCount] = val\n const molType = moleculetypeDict[name]\n atomCount += molCount * molType.atoms.length\n bondCount += molCount * molType.bonds.length\n })\n\n atomStore.resize(atomCount)\n bondStore.resize(bondCount)\n\n let atomIdx = 0\n let resIdx = 0\n let chainidIdx = 0\n let chainnameIdx = 0\n let bondIdx = 0\n let atomOffset = 0\n let lastResno: number\n\n molecules.forEach(function (val) {\n const [name, molCount] = val\n const molType = moleculetypeDict[name]\n const chainname = getChainname(chainnameIdx)\n for (let i = 0; i < molCount; ++i) {\n lastResno = -1\n const chainid = WaterNames.includes(name) ? chainname : getChainname(chainidIdx)\n molType.atoms.forEach(function (atomData) {\n const [resno, resname, atomname, charge] = atomData\n if (resno !== lastResno) {\n ++resIdx\n }\n atomStore.atomTypeId[atomIdx] = atomMap.add(atomname)\n atomStore.serial[atomIdx] = atomIdx + 1\n atomStore.partialCharge[atomIdx] = charge\n sb.addAtom(0, chainname, chainid, resname, resIdx + 1, false)\n ++atomIdx\n lastResno = resno\n })\n molType.bonds.forEach(function (bondData) {\n bondStore.atomIndex1[bondIdx] = atomOffset + bondData[0] - 1\n bondStore.atomIndex2[bondIdx] = atomOffset + bondData[1] - 1\n ++bondIdx\n })\n ++chainidIdx\n atomOffset += molType.atoms.length\n }\n ++chainnameIdx\n })\n\n bondStore.count = bondCount\n\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n calculateBondsWithin(s, true)\n calculateBondsBetween(s, true, true)\n assignResidueTypeBonds(s)\n\n if (Debug) Log.timeEnd('TopParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('top', TopParser)\n\nexport default TopParser\n","/**\n * @file Trajectory Parser\n * @author Alexander Rose \n * @private\n */\n\nimport Parser, { ParserParameters } from './parser'\nimport Frames from '../trajectory/frames'\nimport Streamer from '../streamer/streamer';\n\nclass TrajectoryParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n super(streamer, params)\n\n this.frames = new Frames(this.name, this.path)\n }\n\n get type () { return 'trajectory' }\n get __objName () { return 'frames' }\n}\n\nexport default TrajectoryParser\n","/**\n * @file Netcdf Reader\n * @author Alexander Rose \n * @private\n *\n * Adapted from https://github.com/cheminfo-js/netcdfjs\n * MIT License, Copyright (c) 2016 cheminfo\n */\n\nimport IOBuffer from './io-buffer'\n\nexport interface NetCDFRecordDimension {\n length: number,\n id?: number,\n name?: string,\n recordStep?: number\n}\n\nexport interface NetCDFHeader {\n recordDimension: NetCDFRecordDimension,\n version: number,\n dimensions: any[],\n globalAttributes: any[],\n variables: any[]\n}\n\nexport interface NetCDFDimension {\n name: string,\n size: number\n}\n\n/**\n * Throws a non-valid NetCDF exception if the statement it's true\n * @ignore\n * @param {boolean} statement - Throws if true\n * @param {string} reason - Reason to throw\n */\nfunction notNetcdf (statement: boolean, reason: string) {\n if (statement) {\n throw new TypeError('Not a valid NetCDF v3.x file: ' + reason)\n }\n}\n\n/**\n * Moves 1, 2, or 3 bytes to next 4-byte boundary\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n */\nfunction padding (buffer: IOBuffer) {\n if ((buffer.offset % 4) !== 0) {\n buffer.skip(4 - (buffer.offset % 4))\n }\n}\n\n/**\n * Reads the name\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @return {string} - Name\n */\nfunction readName (buffer: IOBuffer) {\n // Read name\n const nameLength = buffer.readUint32()\n const name = buffer.readChars(nameLength)\n\n // validate name\n // TODO\n\n // Apply padding\n padding(buffer)\n return name\n}\n\nconst types = {\n BYTE: 1,\n CHAR: 2,\n SHORT: 3,\n INT: 4,\n FLOAT: 5,\n DOUBLE: 6\n}\n\n/**\n * Parse a number into their respective type\n * @ignore\n * @param {number} type - integer that represents the type\n * @return {string} - parsed value of the type\n */\nfunction num2str (type: number) {\n switch (Number(type)) {\n case types.BYTE:\n return 'byte'\n case types.CHAR:\n return 'char'\n case types.SHORT:\n return 'short'\n case types.INT:\n return 'int'\n case types.FLOAT:\n return 'float'\n case types.DOUBLE:\n return 'double'\n default:\n return 'undefined'\n }\n}\n\n/**\n * Parse a number type identifier to his size in bytes\n * @ignore\n * @param {number} type - integer that represents the type\n * @return {number} -size of the type\n */\nfunction num2bytes (type: number) {\n switch (Number(type)) {\n case types.BYTE:\n return 1\n case types.CHAR:\n return 1\n case types.SHORT:\n return 2\n case types.INT:\n return 4\n case types.FLOAT:\n return 4\n case types.DOUBLE:\n return 8\n default:\n return -1\n }\n}\n\n/**\n * Reverse search of num2str\n * @ignore\n * @param {string} type - string that represents the type\n * @return {number} - parsed value of the type\n */\nfunction str2num (type: string) {\n switch (String(type)) {\n case 'byte':\n return types.BYTE\n case 'char':\n return types.CHAR\n case 'short':\n return types.SHORT\n case 'int':\n return types.INT\n case 'float':\n return types.FLOAT\n case 'double':\n return types.DOUBLE\n default:\n return -1\n }\n}\n\n/**\n * Auxiliary function to read numeric data\n * @ignore\n * @param {number} size - Size of the element to read\n * @param {function} bufferReader - Function to read next value\n * @return {Array|number}\n */\nfunction readNumber (size: number, bufferReader: Function) {\n if (size !== 1) {\n const numbers = new Array(size)\n for (let i = 0; i < size; i++) {\n numbers[i] = bufferReader()\n }\n return numbers\n } else {\n return bufferReader()\n }\n}\n\n/**\n * Given a type and a size reads the next element\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {number} type - Type of the data to read\n * @param {number} size - Size of the element to read\n * @return {string|Array|number}\n */\nfunction readType (buffer: IOBuffer, type: number, size: number) {\n switch (type) {\n case types.BYTE:\n return buffer.readBytes(size)\n case types.CHAR:\n return trimNull(buffer.readChars(size))\n case types.SHORT:\n return readNumber(size, buffer.readInt16.bind(buffer))\n case types.INT:\n return readNumber(size, buffer.readInt32.bind(buffer))\n case types.FLOAT:\n return readNumber(size, buffer.readFloat32.bind(buffer))\n case types.DOUBLE:\n return readNumber(size, buffer.readFloat64.bind(buffer))\n default:\n notNetcdf(true, 'non valid type ' + type)\n return undefined\n }\n}\n\n/**\n * Removes null terminate value\n * @ignore\n * @param {string} value - String to trim\n * @return {string} - Trimmed string\n */\nfunction trimNull (value: string) {\n if (value.charCodeAt(value.length - 1) === 0) {\n return value.substring(0, value.length - 1)\n }\n return value\n}\n\n// const STREAMING = 4294967295;\n\n/**\n * Read data for the given non-record variable\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {object} variable - Variable metadata\n * @return {Array} - Data of the element\n */\nfunction nonRecord (buffer: IOBuffer, variable: {type: string, size: number}) {\n // variable type\n const type = str2num(variable.type)\n\n // size of the data\n const size = variable.size / num2bytes(type)\n\n // iterates over the data\n const data = new Array(size)\n for (let i = 0; i < size; i++) {\n data[i] = readType(buffer, type, 1)\n }\n\n return data\n}\n\n/**\n * Read data for the given record variable\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {object} variable - Variable metadata\n * @param {object} recordDimension - Record dimension metadata\n * @return {Array} - Data of the element\n */\nfunction record (buffer:IOBuffer, variable: {type: string, size: number}, recordDimension: NetCDFRecordDimension) {\n // variable type\n const type = str2num(variable.type)\n const width = variable.size ? variable.size / num2bytes(type) : 1\n\n // size of the data\n // TODO streaming data\n const size = recordDimension.length\n\n // iterates over the data\n const data = new Array(size)\n const step = recordDimension.recordStep\n\n for (let i = 0; i < size; i++) {\n const currentOffset = buffer.offset\n data[i] = readType(buffer, type, width)\n buffer.seek(currentOffset + step!)\n }\n\n return data\n}\n\n// Grammar constants\nconst ZERO = 0\nconst NC_DIMENSION = 10\nconst NC_VARIABLE = 11\nconst NC_ATTRIBUTE = 12\n\n/**\n * Read the header of the file\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {number} version - Version of the file\n * @return {object} - Object with the fields:\n * * `recordDimension`: Number with the length of record dimension\n * * `dimensions`: List of dimensions\n * * `globalAttributes`: List of global attributes\n * * `variables`: List of variables\n */\nfunction header (buffer: IOBuffer, version: number) {\n // Length of record dimension\n // sum of the varSize's of all the record variables.\n const header: Partial = {recordDimension: {length: buffer.readUint32()}}\n\n // Version\n header.version = version\n\n // List of dimensions\n const dimList = dimensionsList(buffer) as {dimensions: NetCDFDimension[], recordId: number, recordName: string}\n header.recordDimension!.id = dimList.recordId\n header.recordDimension!.name = dimList.recordName\n header.dimensions = dimList.dimensions\n\n // List of global attributes\n header.globalAttributes = attributesList(buffer)\n\n // List of variables\n const variables = variablesList(buffer, dimList.recordId, version) as {variables: any[], recordStep: number}\n header.variables = variables.variables\n header.recordDimension!.recordStep = variables.recordStep\n\n return header\n}\n\n/**\n * List of dimensions\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @return {object} - List of dimensions and record dimension with:\n * * `name`: String with the name of the dimension\n * * `size`: Number with the size of the dimension\n */\nfunction dimensionsList (buffer: IOBuffer) {\n let dimensions: NetCDFDimension[], recordId, recordName\n const dimList = buffer.readUint32()\n if (dimList === ZERO) {\n notNetcdf((buffer.readUint32() !== ZERO), 'wrong empty tag for list of dimensions')\n return []\n } else {\n notNetcdf((dimList !== NC_DIMENSION), 'wrong tag for list of dimensions')\n\n // Length of dimensions\n const dimensionSize = buffer.readUint32()\n dimensions = new Array(dimensionSize)\n for (let dim = 0; dim < dimensionSize; dim++) {\n // Read name\n const name = readName(buffer)\n\n // Read dimension size\n const size = buffer.readUint32()\n if (size === 0) {\n recordId = dim\n recordName = name\n }\n\n dimensions[dim] = {\n name: name,\n size: size\n }\n }\n return {\n dimensions: dimensions,\n recordId: recordId,\n recordName: recordName\n }\n }\n}\n\n/**\n * List of attributes\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @return {Array} - List of attributes with:\n * * `name`: String with the name of the attribute\n * * `type`: String with the type of the attribute\n * * `value`: A number or string with the value of the attribute\n */\nfunction attributesList (buffer: IOBuffer) {\n let attributes\n const gAttList = buffer.readUint32()\n if (gAttList === ZERO) {\n notNetcdf((buffer.readUint32() !== ZERO), 'wrong empty tag for list of attributes')\n return []\n } else {\n notNetcdf((gAttList !== NC_ATTRIBUTE), 'wrong tag for list of attributes')\n\n // Length of attributes\n const attributeSize = buffer.readUint32()\n attributes = new Array(attributeSize)\n for (let gAtt = 0; gAtt < attributeSize; gAtt++) {\n // Read name\n const name = readName(buffer)\n\n // Read type\n const type = buffer.readUint32()\n notNetcdf(((type < 1) || (type > 6)), 'non valid type ' + type)\n\n // Read attribute\n const size = buffer.readUint32()\n const value = readType(buffer, type, size)\n\n // Apply padding\n padding(buffer)\n\n attributes[gAtt] = {\n name: name,\n type: num2str(type),\n value: value\n }\n }\n }\n return attributes\n}\n\n/**\n * List of variables\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {number} recordId - Id if the record dimension\n * @param {number} version - Version of the file\n * @return {object} - Number of recordStep and list of variables with:\n * * `name`: String with the name of the variable\n * * `dimensions`: Array with the dimension IDs of the variable\n * * `attributes`: Array with the attributes of the variable\n * * `type`: String with the type of the variable\n * * `size`: Number with the size of the variable\n * * `offset`: Number with the offset where of the variable begins\n * * `record`: True if is a record variable, false otherwise\n */\nfunction variablesList (buffer: IOBuffer, recordId: number, version: number) {\n const varList = buffer.readUint32()\n let recordStep = 0\n let variables\n if (varList === ZERO) {\n notNetcdf(\n (buffer.readUint32() !== ZERO),\n 'wrong empty tag for list of variables'\n )\n return []\n } else {\n notNetcdf((varList !== NC_VARIABLE), 'wrong tag for list of variables')\n\n // Length of variables\n const variableSize = buffer.readUint32()\n variables = new Array(variableSize)\n for (let v = 0; v < variableSize; v++) {\n // Read name\n const name = readName(buffer)\n\n // Read dimensionality of the variable\n const dimensionality = buffer.readUint32()\n\n // Index into the list of dimensions\n const dimensionsIds = new Array(dimensionality)\n for (let dim = 0; dim < dimensionality; dim++) {\n dimensionsIds[dim] = buffer.readUint32()\n }\n\n // Read variables size\n const attributes = attributesList(buffer)\n\n // Read type\n const type = buffer.readUint32()\n notNetcdf(((type < 1) && (type > 6)), 'non valid type ' + type)\n\n // Read variable size\n // The 32-bit varSize field is not large enough to contain the\n // size of variables that require more than 2^32 - 4 bytes,\n // so 2^32 - 1 is used in the varSize field for such variables.\n const varSize = buffer.readUint32()\n\n // Read offset\n let offset = buffer.readUint32()\n if (version === 2) {\n notNetcdf((offset > 0), 'offsets larger than 4GB not supported')\n offset = buffer.readUint32()\n }\n\n // Count amount of record variables\n if (dimensionsIds[0] === recordId) {\n recordStep += varSize\n }\n\n variables[v] = {\n name: name,\n dimensions: dimensionsIds,\n attributes: attributes,\n type: num2str(type),\n size: varSize,\n offset: offset,\n record: (dimensionsIds[0] === recordId)\n }\n }\n }\n\n return {\n variables: variables,\n recordStep: recordStep\n }\n}\n\n/**\n * Reads a NetCDF v3.x file\n * https://www.unidata.ucar.edu/software/netcdf/docs/file_format_specifications.html\n */\nclass NetcdfReader {\n header: Partial\n buffer: IOBuffer\n /**\n * @param {ArrayBuffer} data - ArrayBuffer or any Typed Array with the data\n */\n constructor (data: ArrayBuffer) {\n const buffer = new IOBuffer(data)\n buffer.setBigEndian()\n\n // Validate that it's a NetCDF file\n notNetcdf((buffer.readChars(3) !== 'CDF'), 'should start with CDF')\n\n // Check the NetCDF format\n const version = buffer.readByte()\n notNetcdf((version > 2), 'unknown version')\n\n // Read the header\n this.header = header(buffer, version)\n this.buffer = buffer\n }\n\n /**\n * @return {string} - Version for the NetCDF format\n */\n get version () {\n if (this.header.version === 1) {\n return 'classic format'\n } else {\n return '64-bit offset format'\n }\n }\n\n /**\n * @return {object} - Metadata for the record dimension\n * * `length`: Number of elements in the record dimension\n * * `id`: Id number in the list of dimensions for the record dimension\n * * `name`: String with the name of the record dimension\n * * `recordStep`: Number with the record variables step size\n */\n get recordDimension () {\n return this.header.recordDimension\n }\n\n /**\n * @return {Array} - List of dimensions with:\n * * `name`: String with the name of the dimension\n * * `size`: Number with the size of the dimension\n */\n get dimensions () {\n return this.header.dimensions\n }\n\n /**\n * @return {Array} - List of global attributes with:\n * * `name`: String with the name of the attribute\n * * `type`: String with the type of the attribute\n * * `value`: A number or string with the value of the attribute\n */\n get globalAttributes () {\n return this.header.globalAttributes\n }\n\n /**\n * @return {Array} - List of variables with:\n * * `name`: String with the name of the variable\n * * `dimensions`: Array with the dimension IDs of the variable\n * * `attributes`: Array with the attributes of the variable\n * * `type`: String with the type of the variable\n * * `size`: Number with the size of the variable\n * * `offset`: Number with the offset where of the variable begins\n * * `record`: True if is a record variable, false otherwise\n */\n get variables () {\n return this.header.variables\n }\n\n /**\n * Checks if a variable is available\n * @param {string|object} variableName - Name of the variable to check\n * @return {Boolean} - Variable existence\n */\n hasDataVariable (variableName: string) {\n return this.header.variables!.findIndex(function (val) {\n return val.name === variableName\n }) !== -1\n }\n\n /**\n * Retrieves the data for a given variable\n * @param {string|object} variableName - Name of the variable to search or variable object\n * @return {Array} - List with the variable values\n */\n getDataVariable (variableName: string|{}) {\n let variable\n if (typeof variableName === 'string') {\n // search the variable\n variable = this.header.variables!.find(function (val) {\n return val.name === variableName\n })\n } else {\n variable = variableName\n }\n\n // throws if variable not found\n notNetcdf((variable === undefined), 'variable not found')\n\n // go to the offset position\n this.buffer.seek(variable.offset)\n\n if (variable.record) {\n // record variable case\n return record(this.buffer, variable, this.header.recordDimension!)\n } else {\n // non-record variable case\n return nonRecord(this.buffer, variable)\n }\n }\n}\n\nexport default NetcdfReader\n","/**\n * @file Dcd Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { uint8ToString, ensureBuffer } from '../utils'\nimport TrajectoryParser from './trajectory-parser'\n\nconst charmmTimeUnitFactor = 20.45482949774598\n\ninterface DcdHeader {\n NSET: number,\n ISTART: number,\n NSAVC: number,\n NAMNF: number,\n DELTA: number,\n TITLE: string,\n NATOM: number\n}\n\nclass DcdParser extends TrajectoryParser {\n get type () { return 'dcd' }\n get isBinary () { return true }\n\n _parse () {\n // http://www.ks.uiuc.edu/Research/vmd/plugins/molfile/dcdplugin.html\n\n // The DCD format is structured as follows\n // (FORTRAN UNFORMATTED, with Fortran data type descriptions):\n // HDR NSET ISTRT NSAVC 5-ZEROS NATOM-NFREAT DELTA 9-ZEROS\n // `CORD' #files step 1 step zeroes (zero) timestep (zeroes)\n // interval\n // C*4 INT INT INT 5INT INT DOUBLE 9INT\n // ==========================================================================\n // NTITLE TITLE\n // INT (=2) C*MAXTITL\n // (=32)\n // ==========================================================================\n // NATOM\n // #atoms\n // INT\n // ==========================================================================\n // X(I), I=1,NATOM (DOUBLE)\n // Y(I), I=1,NATOM\n // Z(I), I=1,NATOM\n // ==========================================================================\n\n if (Debug) Log.time('DcdParser._parse ' + this.name)\n\n const bin = ensureBuffer(this.streamer.data)\n const dv = new DataView(bin)\n\n const f = this.frames\n const coordinates = f.coordinates\n const boxes = f.boxes\n const header: Partial = {}\n\n let nextPos = 0\n\n // header block\n\n const intView = new Int32Array(bin, 0, 23)\n const ef = intView[ 0 ] !== dv.getInt32(0) // endianess flag\n // swap byte order when big endian (84 indicates little endian)\n if (intView[ 0 ] !== 84) {\n const n = bin.byteLength\n for (let i = 0; i < n; i += 4) {\n dv.setFloat32(i, dv.getFloat32(i), true)\n }\n }\n if (intView[ 0 ] !== 84) {\n Log.error('dcd bad format, header block start')\n }\n // format indicator, should read 'CORD'\n const formatString = String.fromCharCode(\n dv.getUint8(4), dv.getUint8(5),\n dv.getUint8(6), dv.getUint8(7)\n )\n if (formatString !== 'CORD') {\n Log.error('dcd bad format, format string')\n }\n let isCharmm = false\n let extraBlock = false\n let fourDims = false\n // version field in charmm, unused in X-PLOR\n if (intView[ 22 ] !== 0) {\n isCharmm = true\n if (intView[ 12 ] !== 0) extraBlock = true\n if (intView[ 13 ] === 1) fourDims = true\n }\n header.NSET = intView[ 2 ]\n header.ISTART = intView[ 3 ]\n header.NSAVC = intView[ 4 ]\n header.NAMNF = intView[ 10 ]\n if (isCharmm) {\n header.DELTA = dv.getFloat32(44, ef)\n } else {\n header.DELTA = dv.getFloat64(44, ef)\n }\n if (intView[ 22 ] !== 84) {\n Log.error('dcd bad format, header block end')\n }\n nextPos = nextPos + 21 * 4 + 8\n\n // title block\n\n const titleLength = dv.getInt32(nextPos, ef)\n const titlePos = nextPos + 1\n if ((titleLength - 4) % 80 !== 0) {\n Log.error('dcd bad format, title block start')\n }\n header.TITLE = uint8ToString(\n new Uint8Array(bin, titlePos, titleLength)\n )\n if (dv.getInt32(titlePos + titleLength + 4 - 1, ef) !== titleLength) {\n Log.error('dcd bad format, title block end')\n }\n nextPos = nextPos + titleLength + 8\n\n // natom block\n\n if (dv.getInt32(nextPos, ef) !== 4) {\n Log.error('dcd bad format, natom block start')\n }\n header.NATOM = dv.getInt32(nextPos + 4, ef)\n if (dv.getInt32(nextPos + 8, ef) !== 4) {\n Log.error('dcd bad format, natom block end')\n }\n nextPos = nextPos + 4 + 8\n\n // fixed atoms block\n\n if (header.NAMNF > 0) {\n // TODO read coordinates and indices of fixed atoms\n Log.error('dcd format with fixed atoms unsupported, aborting')\n return\n }\n\n // frames\n\n const natom = header.NATOM\n const natom4 = natom * 4\n\n for (let i = 0, n = header.NSET; i < n; ++i) {\n if (extraBlock) {\n nextPos += 4 // block start\n // unitcell: A, alpha, B, beta, gamma, C (doubles)\n const box = new Float32Array(9)\n box[ 0 ] = dv.getFloat64(nextPos, ef)\n box[ 4 ] = dv.getFloat64(nextPos + 2 * 8, ef)\n box[ 8 ] = dv.getFloat64(nextPos + 5 * 8, ef)\n boxes.push(box)\n nextPos += 48\n nextPos += 4 // block end\n }\n\n // xyz coordinates\n const coord = new Float32Array(natom * 3)\n for (let j = 0; j < 3; ++j) {\n if (dv.getInt32(nextPos, ef) !== natom4) {\n Log.error('dcd bad format, coord block start', i, j)\n }\n nextPos += 4 // block start\n const c = new Float32Array(bin, nextPos, natom)\n for (let k = 0; k < natom; ++k) {\n coord[ 3 * k + j ] = c[ k ]\n }\n nextPos += natom4\n if (dv.getInt32(nextPos, ef) !== natom4) {\n Log.error('dcd bad format, coord block end', i, j)\n }\n nextPos += 4 // block end\n }\n coordinates.push(coord)\n\n if (fourDims) {\n const bytes = dv.getInt32(nextPos, ef)\n nextPos += 4 + bytes + 4 // block start + skip + block end\n }\n }\n\n if (header.DELTA) {\n f.deltaTime = header.DELTA * charmmTimeUnitFactor\n }\n if (header.ISTART >= 1) {\n f.timeOffset = (header.ISTART - 1) * f.deltaTime\n }\n\n // console.log(header)\n // console.log(header.TITLE)\n // console.log('isCharmm', isCharmm, 'extraBlock', extraBlock, 'fourDims, fourDims)\n\n if (Debug) Log.timeEnd('DcdParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('dcd', DcdParser)\n\nexport default DcdParser\n","/**\n * @file Nctraj Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport TrajectoryParser from './trajectory-parser'\nimport NetcdfReader from '../utils/netcdf-reader'\n\nclass NctrajParser extends TrajectoryParser {\n get type () { return 'nctraj' }\n get isBinary () { return true }\n\n _parse () {\n // http://ambermd.org/netcdf/nctraj.xhtml\n\n if (Debug) Log.time('NctrajParser._parse ' + this.name)\n\n const netcdfReader = new NetcdfReader(this.streamer.data)\n\n const f = this.frames\n const coordinates = f.coordinates\n const boxes = f.boxes\n const times = f.times\n\n netcdfReader.getDataVariable('coordinates').forEach(function (c) {\n coordinates.push(new Float32Array(c))\n })\n\n if (netcdfReader.hasDataVariable('cell_lengths')) {\n netcdfReader.getDataVariable('cell_lengths').forEach(function (b) {\n boxes.push(new Float32Array(b))\n })\n }\n\n if (netcdfReader.hasDataVariable('time')) {\n netcdfReader.getDataVariable('time').forEach(function (t) {\n times.push(t)\n })\n }\n\n if (times.length >= 1) {\n f.timeOffset = times[0]\n }\n if (times.length >= 2) {\n f.deltaTime = times[1] - times[0]\n }\n\n if (Debug) Log.timeEnd('NctrajParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('nctraj', NctrajParser)\nParserRegistry.add('ncdf', NctrajParser)\nParserRegistry.add('nc', NctrajParser)\n\nexport default NctrajParser\n","/**\n * @file Trr Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { ensureBuffer } from '../utils'\nimport TrajectoryParser from './trajectory-parser'\n\nclass TrrParser extends TrajectoryParser {\n get type () { return 'trr' }\n get isBinary () { return true }\n\n _parse () {\n // https://github.com/gromacs/gromacs/blob/master/src/gromacs/fileio/trrio.cpp\n\n if (Debug) Log.time('TrrParser._parse ' + this.name)\n\n const bin = ensureBuffer(this.streamer.data)\n const dv = new DataView(bin)\n\n const f = this.frames\n const coordinates = f.coordinates\n const boxes = f.boxes\n const times = f.times\n\n let offset = 0\n\n while (true) {\n // const magicnum = dv.getInt32(offset)\n // const i1 = dv.getFloat32(offset + 4)\n offset += 8\n\n const versionSize = dv.getInt32(offset)\n offset += 4\n offset += versionSize\n\n // const irSize = dv.getInt32(offset)\n // const eSize = dv.getInt32(offset + 4)\n const boxSize = dv.getInt32(offset + 8)\n const virSize = dv.getInt32(offset + 12)\n const presSize = dv.getInt32(offset + 16)\n // const topSize = dv.getInt32(offset + 20)\n // const symSize = dv.getInt32(offset + 24)\n const coordSize = dv.getInt32(offset + 28)\n const velocitySize = dv.getInt32(offset + 32)\n const forceSize = dv.getInt32(offset + 36)\n const natoms = dv.getInt32(offset + 40)\n // const step = dv.getInt32(offset + 44)\n // const nre = dv.getInt32(offset + 48)\n offset += 52\n\n const floatSize = boxSize / 9\n const natoms3 = natoms * 3\n\n // let lambda\n if (floatSize === 8) {\n times.push(dv.getFloat64(offset))\n // lambda = dv.getFloat64(offset + 8)\n } else {\n times.push(dv.getFloat32(offset))\n // lambda = dv.getFloat32(offset + 4)\n }\n offset += 2 * floatSize\n\n if (boxSize) {\n const box = new Float32Array(9)\n if (floatSize === 8) {\n for (let i = 0; i < 9; ++i) {\n box[i] = dv.getFloat64(offset) * 10\n offset += 8\n }\n } else {\n for (let i = 0; i < 9; ++i) {\n box[i] = dv.getFloat32(offset) * 10\n offset += 4\n }\n }\n boxes.push(box)\n }\n\n // ignore, unused\n offset += virSize\n\n // ignore, unused\n offset += presSize\n\n if (coordSize) {\n let frameCoords\n if (floatSize === 8) {\n frameCoords = new Float32Array(natoms3)\n for (let i = 0; i < natoms3; ++i) {\n frameCoords[i] = dv.getFloat64(offset) * 10\n offset += 8\n }\n } else {\n const tmp = new Uint32Array(bin, offset, natoms3)\n for (let i = 0; i < natoms3; ++i) {\n const value = tmp[i]\n tmp[i] = (\n ((value & 0xFF) << 24) | ((value & 0xFF00) << 8) |\n ((value >> 8) & 0xFF00) | ((value >> 24) & 0xFF)\n )\n }\n frameCoords = new Float32Array(bin, offset, natoms3)\n for (let i = 0; i < natoms3; ++i) {\n frameCoords[i] *= 10\n offset += 4\n }\n }\n coordinates.push(frameCoords)\n }\n\n // ignore, unused\n offset += velocitySize\n\n // ignore, unused\n offset += forceSize\n\n if (offset >= bin.byteLength) break\n }\n\n if (times.length >= 1) {\n f.timeOffset = times[0]\n }\n if (times.length >= 2) {\n f.deltaTime = times[1] - times[0]\n }\n\n if (Debug) Log.timeEnd('TrrParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('trr', TrrParser)\n\nexport default TrrParser\n","/**\n * @file Xtc Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { ensureBuffer } from '../utils'\nimport TrajectoryParser from './trajectory-parser'\nimport { NumberArray } from '../types';\n\nconst MagicInts = new Uint32Array([\n 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 10, 12, 16, 20, 25, 32, 40, 50, 64,\n 80, 101, 128, 161, 203, 256, 322, 406, 512, 645, 812, 1024, 1290,\n 1625, 2048, 2580, 3250, 4096, 5060, 6501, 8192, 10321, 13003,\n 16384, 20642, 26007, 32768, 41285, 52015, 65536, 82570, 104031,\n 131072, 165140, 208063, 262144, 330280, 416127, 524287, 660561,\n 832255, 1048576, 1321122, 1664510, 2097152, 2642245, 3329021,\n 4194304, 5284491, 6658042, 8388607, 10568983, 13316085, 16777216\n])\nconst FirstIdx = 9\n// const LastIdx = MagicInts.length\n\nfunction sizeOfInt (size: number) {\n let num = 1\n let numOfBits = 0\n while (size >= num && numOfBits < 32) {\n numOfBits++\n num <<= 1\n }\n return numOfBits\n}\n\nconst _tmpBytes = new Uint8Array(32)\n\nfunction sizeOfInts (numOfInts: number, sizes: Int32Array) {\n let numOfBytes = 1\n let numOfBits = 0\n _tmpBytes[0] = 1\n for (let i = 0; i < numOfInts; i++) {\n let bytecnt\n let tmp = 0\n for (bytecnt = 0; bytecnt < numOfBytes; bytecnt++) {\n tmp += _tmpBytes[bytecnt] * sizes[i]\n _tmpBytes[bytecnt] = tmp & 0xff\n tmp >>= 8\n }\n while (tmp !== 0) {\n _tmpBytes[bytecnt++] = tmp & 0xff\n tmp >>= 8\n }\n numOfBytes = bytecnt\n }\n let num = 1\n numOfBytes--\n while (_tmpBytes[numOfBytes] >= num) {\n numOfBits++\n num *= 2\n }\n return numOfBits + numOfBytes * 8\n}\n\nfunction decodeBits (buf: Int32Array, cbuf: Uint8Array, numOfBits: number, buf2: Uint32Array) {\n const mask = (1 << numOfBits) - 1\n let lastBB0 = buf2[1]\n let lastBB1 = buf2[2]\n let cnt = buf[0]\n let num = 0\n\n while (numOfBits >= 8) {\n lastBB1 = (lastBB1 << 8) | cbuf[cnt++]\n num |= (lastBB1 >> lastBB0) << (numOfBits - 8)\n numOfBits -= 8\n }\n\n if (numOfBits > 0) {\n if (lastBB0 < numOfBits) {\n lastBB0 += 8\n lastBB1 = (lastBB1 << 8) | cbuf[cnt++]\n }\n lastBB0 -= numOfBits\n num |= (lastBB1 >> lastBB0) & ((1 << numOfBits) - 1)\n }\n\n num &= mask\n buf[0] = cnt\n buf[1] = lastBB0\n buf[2] = lastBB1\n\n return num\n}\n\nconst _tmpIntBytes = new Int32Array(32)\n\nfunction decodeInts (buf: Int32Array, cbuf: Uint8Array, numOfInts: number, numOfBits: number, sizes: NumberArray, nums: Float32Array, buf2: Uint32Array) {\n let numOfBytes = 0\n _tmpIntBytes[1] = 0\n _tmpIntBytes[2] = 0\n _tmpIntBytes[3] = 0\n\n while (numOfBits > 8) {\n // this is inversed??? why??? because of the endiannness???\n _tmpIntBytes[numOfBytes++] = decodeBits(buf, cbuf, 8, buf2)\n numOfBits -= 8\n }\n\n if (numOfBits > 0) {\n _tmpIntBytes[numOfBytes++] = decodeBits(buf, cbuf, numOfBits, buf2)\n }\n\n for (let i = numOfInts - 1; i > 0; i--) {\n let num = 0\n for (let j = numOfBytes - 1; j >= 0; j--) {\n num = (num << 8) | _tmpIntBytes[j]\n const p = (num / sizes[i]) | 0\n _tmpIntBytes[j] = p\n num = num - p * sizes[i]\n }\n nums[i] = num\n }\n nums[0] = (\n _tmpIntBytes[0] |\n (_tmpIntBytes[1] << 8) |\n (_tmpIntBytes[2] << 16) |\n (_tmpIntBytes[3] << 24)\n )\n}\n\nclass XtcParser extends TrajectoryParser {\n get type () { return 'xtc' }\n get isBinary () { return true }\n\n _parse () {\n // https://github.com/gromacs/gromacs/blob/master/src/gromacs/fileio/xtcio.cpp\n // https://github.com/gromacs/gromacs/blob/master/src/gromacs/fileio/libxdrf.cpp\n\n if (Debug) Log.time('XtcParser._parse ' + this.name)\n\n const bin = ensureBuffer(this.streamer.data)\n const dv = new DataView(bin)\n\n const f = this.frames\n const coordinates = f.coordinates\n const boxes = f.boxes\n const times = f.times\n\n const minMaxInt = new Int32Array(6)\n const sizeint = new Int32Array(3)\n const bitsizeint = new Int32Array(3)\n const sizesmall = new Uint32Array(3)\n const thiscoord = new Float32Array(3)\n const prevcoord = new Float32Array(3)\n\n let offset = 0\n const buf = new Int32Array(3)\n const buf2 = new Uint32Array(buf.buffer)\n\n while (true) {\n let frameCoords: NumberArray\n\n // const magicnum = dv.getInt32(offset)\n const natoms = dv.getInt32(offset + 4)\n // const step = dv.getInt32(offset + 8)\n offset += 12\n\n const natoms3 = natoms * 3\n\n times.push(dv.getFloat32(offset))\n offset += 4\n\n const box = new Float32Array(9)\n for (let i = 0; i < 9; ++i) {\n box[i] = dv.getFloat32(offset) * 10\n offset += 4\n }\n boxes.push(box)\n\n if (natoms <= 9) { // no compression\n frameCoords = new Float32Array(natoms)\n for (let i = 0; i < natoms; ++i) {\n frameCoords[i] = dv.getFloat32(offset)\n offset += 4\n }\n } else {\n buf[0] = buf[1] = buf[2] = 0.0\n sizeint[0] = sizeint[1] = sizeint[2] = 0\n sizesmall[0] = sizesmall[1] = sizesmall[2] = 0\n bitsizeint[0] = bitsizeint[1] = bitsizeint[2] = 0\n thiscoord[0] = thiscoord[1] = thiscoord[2] = 0\n prevcoord[0] = prevcoord[1] = prevcoord[2] = 0\n\n frameCoords = new Float32Array(natoms3)\n let lfp = 0\n\n const lsize = dv.getInt32(offset)\n offset += 4\n const precision = dv.getFloat32(offset)\n offset += 4\n\n minMaxInt[0] = dv.getInt32(offset)\n minMaxInt[1] = dv.getInt32(offset + 4)\n minMaxInt[2] = dv.getInt32(offset + 8)\n minMaxInt[3] = dv.getInt32(offset + 12)\n minMaxInt[4] = dv.getInt32(offset + 16)\n minMaxInt[5] = dv.getInt32(offset + 20)\n sizeint[0] = minMaxInt[3] - minMaxInt[0] + 1\n sizeint[1] = minMaxInt[4] - minMaxInt[1] + 1\n sizeint[2] = minMaxInt[5] - minMaxInt[2] + 1\n offset += 24\n\n let bitsize\n if ((sizeint[0] | sizeint[1] | sizeint[2]) > 0xffffff) {\n bitsizeint[0] = sizeOfInt(sizeint[0])\n bitsizeint[1] = sizeOfInt(sizeint[1])\n bitsizeint[2] = sizeOfInt(sizeint[2])\n bitsize = 0 // flag the use of large sizes\n } else {\n bitsize = sizeOfInts(3, sizeint)\n }\n\n let smallidx = dv.getInt32(offset)\n offset += 4\n // if (smallidx == 0) {alert(\"Undocumented error 1\"); return;}\n\n // let tmpIdx = smallidx + 8\n // const maxidx = (LastIdx < tmpIdx) ? LastIdx : tmpIdx\n // const minidx = maxidx - 8 // often this equal smallidx\n let tmpIdx = smallidx - 1\n tmpIdx = (FirstIdx > tmpIdx) ? FirstIdx : tmpIdx\n let smaller = (MagicInts[tmpIdx] / 2) | 0\n let smallnum = (MagicInts[smallidx] / 2) | 0\n\n sizesmall[0] = sizesmall[1] = sizesmall[2] = MagicInts[smallidx]\n // larger = MagicInts[maxidx]\n\n let adz = Math.ceil(dv.getInt32(offset) / 4) * 4\n offset += 4\n // if (tmpIdx == 0) {alert(\"Undocumented error 2\"); return;}\n\n // buf = new Int32Array(bin, offset);\n // buf8 = new Uint8Array(bin, offset);\n\n // tmpIdx += 3; rndup = tmpIdx%4;\n // for (i=tmpIdx+rndup-1; i>=tmpIdx; i--) buf8[i] = 0;\n\n // now unpack buf2...\n\n const invPrecision = 1.0 / precision\n let run = 0\n let i = 0\n\n const buf8 = new Uint8Array(bin, offset) // 229...\n\n thiscoord[0] = thiscoord[1] = thiscoord[2] = 0\n\n while (i < lsize) {\n if (bitsize === 0) {\n thiscoord[0] = decodeBits(buf, buf8, bitsizeint[0], buf2)\n thiscoord[1] = decodeBits(buf, buf8, bitsizeint[1], buf2)\n thiscoord[2] = decodeBits(buf, buf8, bitsizeint[2], buf2)\n } else {\n decodeInts(buf, buf8, 3, bitsize, sizeint, thiscoord, buf2)\n }\n\n i++\n\n thiscoord[0] += minMaxInt[0]\n thiscoord[1] += minMaxInt[1]\n thiscoord[2] += minMaxInt[2]\n\n prevcoord[0] = thiscoord[0]\n prevcoord[1] = thiscoord[1]\n prevcoord[2] = thiscoord[2]\n\n const flag = decodeBits(buf, buf8, 1, buf2)\n let isSmaller = 0\n\n if (flag === 1) {\n run = decodeBits(buf, buf8, 5, buf2)\n isSmaller = run % 3\n run -= isSmaller\n isSmaller--\n }\n\n // if ((lfp-ptrstart)+run > size3){\n // fprintf(stderr, \"(xdrfile error) Buffer overrun during decompression.\\n\");\n // return 0;\n // }\n\n if (run > 0) {\n thiscoord[0] = thiscoord[1] = thiscoord[2] = 0\n\n for (let k = 0; k < run; k += 3) {\n decodeInts(buf, buf8, 3, smallidx, sizesmall, thiscoord, buf2)\n i++\n\n thiscoord[0] += prevcoord[0] - smallnum\n thiscoord[1] += prevcoord[1] - smallnum\n thiscoord[2] += prevcoord[2] - smallnum\n\n if (k === 0) {\n // interchange first with second atom for\n // better compression of water molecules\n let tmpSwap = thiscoord[0]\n thiscoord[0] = prevcoord[0]\n prevcoord[0] = tmpSwap\n\n tmpSwap = thiscoord[1]\n thiscoord[1] = prevcoord[1]\n prevcoord[1] = tmpSwap\n\n tmpSwap = thiscoord[2]\n thiscoord[2] = prevcoord[2]\n prevcoord[2] = tmpSwap\n\n frameCoords[lfp++] = prevcoord[0] * invPrecision\n frameCoords[lfp++] = prevcoord[1] * invPrecision\n frameCoords[lfp++] = prevcoord[2] * invPrecision\n } else {\n prevcoord[0] = thiscoord[0]\n prevcoord[1] = thiscoord[1]\n prevcoord[2] = thiscoord[2]\n }\n frameCoords[lfp++] = thiscoord[0] * invPrecision\n frameCoords[lfp++] = thiscoord[1] * invPrecision\n frameCoords[lfp++] = thiscoord[2] * invPrecision\n }\n } else {\n frameCoords[lfp++] = thiscoord[0] * invPrecision\n frameCoords[lfp++] = thiscoord[1] * invPrecision\n frameCoords[lfp++] = thiscoord[2] * invPrecision\n }\n\n smallidx += isSmaller\n\n if (isSmaller < 0) {\n smallnum = smaller\n if (smallidx > FirstIdx) {\n smaller = (MagicInts[smallidx - 1] / 2) | 0\n } else {\n smaller = 0\n }\n } else if (isSmaller > 0) {\n smaller = smallnum\n smallnum = (MagicInts[smallidx] / 2) | 0\n }\n sizesmall[0] = sizesmall[1] = sizesmall[2] = MagicInts[smallidx]\n\n if (sizesmall[0] === 0 || sizesmall[1] === 0 || sizesmall[2] === 0) {\n console.error('(xdrfile error) Undefined error.')\n return\n }\n }\n offset += adz\n }\n\n for (let c = 0; c < natoms3; c++) {\n frameCoords[c] *= 10\n }\n\n coordinates.push(frameCoords)\n\n if (offset >= bin.byteLength) break\n }\n\n if (times.length >= 1) {\n f.timeOffset = times[0]\n }\n if (times.length >= 2) {\n f.deltaTime = times[1] - times[0]\n }\n\n if (Debug) Log.timeEnd('XtcParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('xtc', XtcParser)\n\nexport default XtcParser\n","/**\n * @file Volume Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { defaults } from '../utils'\nimport Parser, { ParserParameters } from './parser'\nimport Volume from '../surface/volume'\nimport Streamer from '../streamer/streamer';\n\nexport interface VolumeParserParameters extends ParserParameters {\n voxelSize: number\n}\n\nclass VolumeParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.volume = new Volume(this.name, this.path)\n this.voxelSize = defaults(p.voxelSize, 1)\n }\n\n get type () { return 'volume' }\n get __objName () { return 'volume' }\n\n _afterParse () {\n this.volume.setMatrix(this.getMatrix())\n super._afterParse()\n }\n\n getMatrix () {\n return new Matrix4()\n }\n}\n\nexport default VolumeParser\n","/**\n * @file Cube Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport VolumeParser from './volume-parser'\n\n// @author Johanna Tiemann \n// @author Alexander Rose \n\nconst reWhitespace = /\\s+/\nconst reScientificNotation = /-?\\d+(?:\\.\\d*)?(?:[eE][+-]?\\d+)?/g\nconst bohrToAngstromFactor = 0.529177210859\ninterface Header {\n atomCount: number,\n originX: number,\n originY: number,\n originZ: number,\n NVX: number,\n NVY: number,\n NVZ: number,\n basisX: Vector3,\n basisY: Vector3,\n basisZ: Vector3\n}\n\nclass CubeParser extends VolumeParser {\n get type () { return 'cube' }\n\n _parse () {\n // http://paulbourke.net/dataformats/cube/\n\n if (Debug) Log.time('CubeParser._parse ' + this.name)\n\n const v = this.volume\n const headerLines = this.streamer.peekLines(6)\n const header: Partial
= {}\n\n const scaleFactor = bohrToAngstromFactor * this.voxelSize\n\n function h (k: number, l: number) {\n var field = headerLines[ k ].trim().split(reWhitespace)[ l ]\n return parseFloat(field)\n }\n\n header.atomCount = Math.abs(h(2, 0)) // Number of atoms\n header.originX = h(2, 1) * bohrToAngstromFactor // Position of origin of volumetric data\n header.originY = h(2, 2) * bohrToAngstromFactor\n header.originZ = h(2, 3) * bohrToAngstromFactor\n header.NVX = h(3, 0) // Number of voxels\n header.NVY = h(4, 0)\n header.NVZ = h(5, 0)\n\n header.basisX = new Vector3(h(3, 1), h(3, 2), h(3, 3))\n .multiplyScalar(scaleFactor)\n header.basisY = new Vector3(h(4, 1), h(4, 2), h(4, 3))\n .multiplyScalar(scaleFactor)\n header.basisZ = new Vector3(h(5, 1), h(5, 2), h(5, 3))\n .multiplyScalar(scaleFactor)\n\n const data = new Float32Array(header.NVX * header.NVY * header.NVZ)\n let count = 0\n let lineNo = 0\n const oribitalFlag = h(2, 0) > 0 ? 0 : 1\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ].trim()\n\n if (line !== '' && lineNo >= header.atomCount! + 6 + oribitalFlag) {\n const m = line.match(reScientificNotation) as RegExpMatchArray\n for (let j = 0, lj = m.length; j < lj; ++j) {\n data[ count ] = parseFloat(m[ j ])\n ++count\n }\n }\n\n ++lineNo\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n v.header = header\n v.setData(data, header.NVZ, header.NVY, header.NVX)\n\n if (Debug) Log.timeEnd('CubeParser._parse ' + this.name)\n }\n\n getMatrix () {\n const h = this.volume.header\n const matrix = new Matrix4()\n\n matrix.multiply(\n new Matrix4().makeTranslation(\n h.originX, h.originY, h.originZ\n )\n )\n\n matrix.multiply(\n new Matrix4().makeBasis(\n h.basisZ, h.basisY, h.basisX\n )\n )\n\n return matrix\n }\n}\n\nParserRegistry.add('cub', CubeParser)\nParserRegistry.add('cube', CubeParser)\n\nexport default CubeParser\n","/**\n * @file Dsn6 Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { ensureBuffer } from '../utils'\nimport { degToRad } from '../math/math-utils'\nimport VolumeParser from './volume-parser'\n\ninterface Dsn6Header {\n xStart: number,\n yStart: number,\n zStart: number,\n xExtent: number,\n yExtent: number,\n zExtent: number,\n xRate: number,\n yRate: number,\n zRate: number,\n xlen: number,\n ylen: number,\n zlen: number,\n alpha: number,\n beta: number,\n gamma: number,\n sigma: number\n}\n\nclass Dsn6Parser extends VolumeParser {\n get type () { return 'dsn6' }\n get isBinary () { return true }\n\n _parse () {\n // DSN6 http://www.uoxray.uoregon.edu/tnt/manual/node104.html\n // BRIX http://svn.cgl.ucsf.edu/svn/chimera/trunk/libs/VolumeData/dsn6/brix-1.html\n\n if (Debug) Log.time('Dsn6Parser._parse ' + this.name)\n\n const v = this.volume\n const header: Partial = {}\n let divisor, summand\n\n const bin = ensureBuffer(this.streamer.data)\n const intView = new Int16Array(bin)\n const byteView = new Uint8Array(bin)\n const brixStr = String.fromCharCode.apply(null, byteView.subarray(0, 512))\n\n if (brixStr.startsWith(':-)')) {\n header.xStart = parseInt(brixStr.substr(10, 5)) // NXSTART\n header.yStart = parseInt(brixStr.substr(15, 5))\n header.zStart = parseInt(brixStr.substr(20, 5))\n\n header.xExtent = parseInt(brixStr.substr(32, 5)) // NX\n header.yExtent = parseInt(brixStr.substr(38, 5))\n header.zExtent = parseInt(brixStr.substr(42, 5))\n\n header.xRate = parseInt(brixStr.substr(52, 5)) // MX\n header.yRate = parseInt(brixStr.substr(58, 5))\n header.zRate = parseInt(brixStr.substr(62, 5))\n\n header.xlen = parseFloat(brixStr.substr(73, 10)) * this.voxelSize\n header.ylen = parseFloat(brixStr.substr(83, 10)) * this.voxelSize\n header.zlen = parseFloat(brixStr.substr(93, 10)) * this.voxelSize\n\n header.alpha = parseFloat(brixStr.substr(103, 10))\n header.beta = parseFloat(brixStr.substr(113, 10))\n header.gamma = parseFloat(brixStr.substr(123, 10))\n\n divisor = parseFloat(brixStr.substr(138, 12)) / 100\n summand = parseInt(brixStr.substr(155, 8))\n\n header.sigma = parseFloat(brixStr.substr(170, 12)) * 100\n } else {\n // swap byte order when big endian\n if (intView[ 18 ] !== 100) {\n for (let i = 0, n = intView.length; i < n; ++i) {\n const val = intView[ i ]\n intView[ i ] = ((val & 0xff) << 8) | ((val >> 8) & 0xff)\n }\n }\n\n header.xStart = intView[ 0 ] // NXSTART\n header.yStart = intView[ 1 ]\n header.zStart = intView[ 2 ]\n\n header.xExtent = intView[ 3 ] // NX\n header.yExtent = intView[ 4 ]\n header.zExtent = intView[ 5 ]\n\n header.xRate = intView[ 6 ] // MX\n header.yRate = intView[ 7 ]\n header.zRate = intView[ 8 ]\n\n const factor = 1 / intView[ 17 ]\n const scalingFactor = factor * this.voxelSize\n\n header.xlen = intView[ 9 ] * scalingFactor\n header.ylen = intView[ 10 ] * scalingFactor\n header.zlen = intView[ 11 ] * scalingFactor\n\n header.alpha = intView[ 12 ] * factor\n header.beta = intView[ 13 ] * factor\n header.gamma = intView[ 14 ] * factor\n\n divisor = intView[ 15 ] / 100\n summand = intView[ 16 ]\n header.gamma = intView[ 14 ] * factor\n }\n\n v.header = header\n\n if (Debug) Log.log(header, divisor, summand)\n\n const data = new Float32Array(\n header.xExtent * header.yExtent * header.zExtent\n )\n\n let offset = 512\n const xBlocks = Math.ceil(header.xExtent / 8)\n const yBlocks = Math.ceil(header.yExtent / 8)\n const zBlocks = Math.ceil(header.zExtent / 8)\n\n // loop over blocks\n for (var zz = 0; zz < zBlocks; ++zz) {\n for (var yy = 0; yy < yBlocks; ++yy) {\n for (var xx = 0; xx < xBlocks; ++xx) {\n // loop inside block\n for (var k = 0; k < 8; ++k) {\n var z = 8 * zz + k\n for (var j = 0; j < 8; ++j) {\n var y = 8 * yy + j\n for (var i = 0; i < 8; ++i) {\n var x = 8 * xx + i\n\n // check if remaining slice-part contains data\n if (x < header.xExtent && y < header.yExtent && z < header.zExtent) {\n var idx = ((((x * header.yExtent) + y) * header.zExtent) + z)\n data[ idx ] = (byteView[ offset ] - summand) / divisor\n ++offset\n } else {\n offset += 8 - i\n break\n }\n }\n }\n }\n }\n }\n }\n\n v.setData(data, header.zExtent, header.yExtent, header.xExtent)\n if (header.sigma) {\n v.setStats(undefined, undefined, undefined, header.sigma)\n }\n\n if (Debug) Log.timeEnd('Dsn6Parser._parse ' + this.name)\n }\n\n getMatrix () {\n const h: Dsn6Header = this.volume.header\n\n const basisX = [\n h.xlen as number,\n 0,\n 0\n ]\n\n const basisY = [\n h.ylen * Math.cos(Math.PI / 180.0 * h.gamma),\n h.ylen * Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n\n const basisZ = [\n h.zlen * Math.cos(Math.PI / 180.0 * h.beta),\n h.zlen * (\n Math.cos(Math.PI / 180.0 * h.alpha) -\n Math.cos(Math.PI / 180.0 * h.gamma) *\n Math.cos(Math.PI / 180.0 * h.beta)\n ) / Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n basisZ[ 2 ] = Math.sqrt(\n h.zlen * h.zlen * Math.sin(Math.PI / 180.0 * h.beta) *\n Math.sin(Math.PI / 180.0 * h.beta) - basisZ[ 1 ] * basisZ[ 1 ]\n )\n\n const basis = [ [], basisX, basisY, basisZ ]\n const nxyz = [ 0, h.xRate, h.yRate, h.zRate ]\n const mapcrs = [ 0, 1, 2, 3 ]\n\n const matrix = new Matrix4()\n\n matrix.set(\n basis[ mapcrs[1] ][0] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][0] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][0] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][1] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][1] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][1] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][2] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][2] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][2] / nxyz[ mapcrs[3] ],\n 0,\n 0, 0, 0, 1\n )\n\n matrix.multiply(\n new Matrix4().makeRotationY(degToRad(90))\n )\n\n matrix.multiply(new Matrix4().makeTranslation(\n -h.zStart, h.yStart, h.xStart\n ))\n\n matrix.multiply(new Matrix4().makeScale(\n -1, 1, 1\n ))\n\n return matrix\n }\n}\n\nParserRegistry.add('dsn6', Dsn6Parser)\nParserRegistry.add('brix', Dsn6Parser)\n\nexport default Dsn6Parser\n","/**\n * @file Dx Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { degToRad } from '../math/math-utils'\nimport VolumeParser from './volume-parser'\n\nconst reWhitespace = /\\s+/\n\ninterface DxHeader {\n nx: number,\n ny: number,\n nz: number,\n xmin: number,\n ymin: number,\n zmin: number,\n hx: number,\n hy: number,\n hz: number\n}\n\nclass DxParser extends VolumeParser {\n get type () { return 'dx' }\n\n _parse () {\n // http://apbs.readthedocs.io/en/latest/formats/opendx.html\n\n if (Debug) Log.time('DxParser._parse ' + this.name)\n\n const v = this.volume\n const headerLines = this.streamer.peekLines(30)\n const headerInfo = this.parseHeaderLines(headerLines)\n const header = this.volume.header\n const dataLineStart = headerInfo.dataLineStart\n\n const size = header.nx * header.ny * header.nz\n const data = new Float32Array(size)\n let count = 0\n let lineNo = 0\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string []) {\n for (let i = _i; i < _n; ++i) {\n if (count < size && lineNo > dataLineStart) {\n const line = lines[ i ].trim()\n\n if (line !== '') {\n const ls = line.split(reWhitespace)\n\n for (let j = 0, lj = ls.length; j < lj; ++j) {\n data[ count ] = parseFloat(ls[ j ])\n ++count\n }\n }\n }\n\n ++lineNo\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n v.setData(data, header.nz, header.ny, header.nx)\n\n if (Debug) Log.timeEnd('DxParser._parse ' + this.name)\n }\n\n parseHeaderLines (headerLines: string []) {\n const header: Partial = {}\n const n = headerLines.length\n\n let dataLineStart = 0\n let headerByteCount = 0\n let deltaLineCount = 0\n\n for (let i = 0; i < n; ++i) {\n let ls\n const line = headerLines[ i ]\n\n if (line.startsWith('object 1')) {\n ls = line.split(reWhitespace)\n\n header.nx = parseInt(ls[ 5 ])\n header.ny = parseInt(ls[ 6 ])\n header.nz = parseInt(ls[ 7 ])\n } else if (line.startsWith('origin')) {\n ls = line.split(reWhitespace)\n\n header.xmin = parseFloat(ls[ 1 ])\n header.ymin = parseFloat(ls[ 2 ])\n header.zmin = parseFloat(ls[ 3 ])\n } else if (line.startsWith('delta')) {\n ls = line.split(reWhitespace)\n\n if (deltaLineCount === 0) {\n header.hx = parseFloat(ls[ 1 ]) * this.voxelSize\n } else if (deltaLineCount === 1) {\n header.hy = parseFloat(ls[ 2 ]) * this.voxelSize\n } else if (deltaLineCount === 2) {\n header.hz = parseFloat(ls[ 3 ]) * this.voxelSize\n }\n\n deltaLineCount += 1\n } else if (line.startsWith('object 3')) {\n dataLineStart = i\n headerByteCount += line.length + 1\n break\n }\n\n headerByteCount += line.length + 1\n }\n\n this.volume.header = header\n\n return {\n dataLineStart: dataLineStart,\n headerByteCount: headerByteCount\n }\n }\n\n getMatrix () {\n const h = this.volume.header\n const matrix = new Matrix4()\n\n matrix.multiply(\n new Matrix4().makeRotationY(degToRad(90))\n )\n\n matrix.multiply(\n new Matrix4().makeTranslation(\n -h.zmin, h.ymin, h.xmin\n )\n )\n\n matrix.multiply(\n new Matrix4().makeScale(\n -h.hz, h.hy, h.hx\n )\n )\n\n return matrix\n }\n}\n\nParserRegistry.add('dx', DxParser)\n\nexport default DxParser\n","/**\n * @file Dxbin Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { uint8ToLines, ensureBuffer } from '../utils'\nimport DxParser from './dx-parser'\n\nclass DxbinParser extends DxParser {\n get type () { return 'dxbin' }\n get isBinary () { return true }\n\n _parse () {\n // https://github.com/Electrostatics/apbs-pdb2pqr/issues/216\n\n if (Debug) Log.time('DxbinParser._parse ' + this.name)\n\n const bin = ensureBuffer(this.streamer.data)\n const headerLines = uint8ToLines(new Uint8Array(bin, 0, 1000))\n const headerInfo = this.parseHeaderLines(headerLines)\n const header = this.volume.header\n const headerByteCount = headerInfo.headerByteCount\n\n const size = header.nx * header.ny * header.nz\n const dv = new DataView(bin)\n const data = new Float32Array(size)\n\n for (let i = 0; i < size; ++i) {\n data[ i ] = dv.getFloat64(i * 8 + headerByteCount, true)\n }\n\n this.volume.setData(data, header.nz, header.ny, header.nx)\n\n if (Debug) Log.timeEnd('DxbinParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('dxbin', DxbinParser)\n\nexport default DxbinParser\n","/**\n * @file Mrc Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { ensureBuffer } from '../utils'\nimport VolumeParser from './volume-parser'\n\ninterface MrcHeader {\n MAP: string,\n MACHST: number [],\n NX: number,\n NY: number,\n NZ: number,\n MODE: number,\n NXSTART: number,\n NYSTART: number,\n NZSTART: number,\n MX: number,\n MY: number,\n MZ: number,\n xlen: number,\n ylen: number,\n zlen: number,\n alpha: number,\n beta: number,\n gamma: number,\n MAPC: number,\n MAPR: number,\n MAPS: number,\n DMIN: number,\n DMAX: number,\n DMEAN: number,\n ISPG: number,\n NSYMBT: number,\n LSKFLG: number,\n originX: number,\n originY: number,\n originZ: number,\n ARMS: number\n}\n\nclass MrcParser extends VolumeParser {\n get type () { return 'mrc' }\n get isBinary () { return true }\n\n _parse () {\n // MRC\n // http://ami.scripps.edu/software/mrctools/mrc_specification.php\n // http://www2.mrc-lmb.cam.ac.uk/research/locally-developed-software/image-processing-software/#image\n // http://bio3d.colorado.edu/imod/doc/mrc_format.txt\n\n // CCP4 (MAP)\n // http://www.ccp4.ac.uk/html/maplib.html\n\n // MRC format does not use the skew transformation header records (words 25-37)\n // CCP4 format does not use the ORIGIN header records (words 50-52)\n\n if (Debug) Log.time('MrcParser._parse ' + this.name)\n\n const v = this.volume\n const header: Partial = {}\n\n const bin = ensureBuffer(this.streamer.data)\n const intView = new Int32Array(bin, 0, 56)\n const floatView = new Float32Array(bin, 0, 56)\n const dv = new DataView(bin)\n\n // 53 MAP Character string 'MAP ' to identify file type\n header.MAP = String.fromCharCode(\n dv.getUint8(52 * 4), dv.getUint8(52 * 4 + 1),\n dv.getUint8(52 * 4 + 2), dv.getUint8(52 * 4 + 3)\n )\n\n // 54 MACHST Machine stamp indicating machine type which wrote file\n // 17 and 17 for big-endian or 68 and 65 for little-endian\n header.MACHST = [ dv.getUint8(53 * 4), dv.getUint8(53 * 4 + 1) ]\n\n // swap byte order when big endian\n if (header.MACHST[ 0 ] === 17 && header.MACHST[ 1 ] === 17) {\n const n = bin.byteLength\n for (let i = 0; i < n; i += 4) {\n dv.setFloat32(i, dv.getFloat32(i), true)\n }\n }\n\n header.NX = intView[ 0 ] // NC - columns (fastest changing)\n header.NY = intView[ 1 ] // NR - rows\n header.NZ = intView[ 2 ] // NS - sections (slowest changing)\n\n // mode\n // 0 image : signed 8-bit bytes range -128 to 127\n // 1 image : 16-bit halfwords\n // 2 image : 32-bit reals\n // 3 transform : complex 16-bit integers\n // 4 transform : complex 32-bit reals\n // 6 image : unsigned 16-bit range 0 to 65535\n // 16 image: unsigned char * 3 (for rgb data, non-standard)\n //\n // Note: Mode 2 is the normal mode used in the CCP4 programs.\n // Other modes than 2 and 0 may NOT WORK\n header.MODE = intView[ 3 ]\n\n // start\n header.NXSTART = intView[ 4 ] // NCSTART - first column\n header.NYSTART = intView[ 5 ] // NRSTART - first row\n header.NZSTART = intView[ 6 ] // NSSTART - first section\n\n // intervals\n header.MX = intView[ 7 ] // intervals along x\n header.MY = intView[ 8 ] // intervals along y\n header.MZ = intView[ 9 ] // intervals along z\n\n // cell length (Angstroms in CCP4)\n header.xlen = floatView[ 10 ] * this.voxelSize\n header.ylen = floatView[ 11 ] * this.voxelSize\n header.zlen = floatView[ 12 ] * this.voxelSize\n\n // cell angle (Degrees)\n header.alpha = floatView[ 13 ]\n header.beta = floatView[ 14 ]\n header.gamma = floatView[ 15 ]\n\n // axis correspondence (1,2,3 for X,Y,Z)\n header.MAPC = intView[ 16 ] // column\n header.MAPR = intView[ 17 ] // row\n header.MAPS = intView[ 18 ] // section\n\n // density statistics\n header.DMIN = floatView[ 19 ]\n header.DMAX = floatView[ 20 ]\n header.DMEAN = floatView[ 21 ]\n\n // space group number 0 or 1 (default=0)\n header.ISPG = intView[ 22 ]\n\n // number of bytes used for symmetry data (0 or 80)\n header.NSYMBT = intView[ 23 ]\n\n // Flag for skew transformation, =0 none, =1 if foll\n header.LSKFLG = intView[ 24 ]\n\n // 26-34 SKWMAT Skew matrix S (in order S11, S12, S13, S21 etc) if\n // LSKFLG .ne. 0.\n // 35-37 SKWTRN Skew translation t if LSKFLG != 0.\n // Skew transformation is from standard orthogonal\n // coordinate frame (as used for atoms) to orthogonal\n // map frame, as Xo(map) = S * (Xo(atoms) - t)\n\n // 38 future use (some of these are used by the MSUBSX routines\n // . \" in MAPBRICK, MAPCONT and FRODO)\n // . \" (all set to zero by default)\n // . \"\n // 52 \"\n\n // 50-52 origin in X,Y,Z used for transforms\n header.originX = floatView[ 49 ]\n header.originY = floatView[ 50 ]\n header.originZ = floatView[ 51 ]\n\n // 53 MAP Character string 'MAP ' to identify file type\n // => see top of this parser\n\n // 54 MACHST Machine stamp indicating machine type which wrote file\n // => see top of this parser\n\n // Rms deviation of map from mean density\n header.ARMS = floatView[ 54 ]\n\n // 56 NLABL Number of labels being used\n // 57-256 LABEL(20,10) 10 80 character text labels (ie. A4 format)\n\n v.header = header\n\n // Log.log( header );\n\n let data\n if (header.MODE === 2) {\n data = new Float32Array(\n bin, 256 * 4 + header.NSYMBT,\n header.NX * header.NY * header.NZ\n )\n } else if (header.MODE === 0) {\n data = new Float32Array(new Int8Array(\n bin, 256 * 4 + header.NSYMBT,\n header.NX * header.NY * header.NZ\n ))\n\n // based on uglymol (https://github.com/uglymol/uglymol) by Marcin Wojdyr (wojdyr)\n // if the file was converted by mapmode2to0 - scale the data\n if (intView[ 39 ] === -128 && intView[ 40 ] === 127) {\n // scaling f(x)=b1*x+b0 such that f(-128)=min and f(127)=max\n const b1 = (header.DMAX - header.DMIN) / 255.0\n const b0 = 0.5 * (header.DMIN + header.DMAX + b1)\n for (let j = 0, jl = data.length; j < jl; ++j) {\n data[ j ] = b1 * data[ j ] + b0\n }\n }\n } else {\n Log.error('MrcParser unknown mode', header.MODE)\n }\n\n v.setData(data, header.NX, header.NY, header.NZ)\n if (header.ARMS !== 0) {\n v.setStats(header.DMIN, header.DMAX, header.DMEAN, header.ARMS)\n }\n\n if (Debug) Log.timeEnd('MrcParser._parse ' + this.name)\n }\n\n getMatrix () {\n const h = this.volume.header\n\n const basisX = [\n h.xlen,\n 0,\n 0\n ]\n\n const basisY = [\n h.ylen * Math.cos(Math.PI / 180.0 * h.gamma),\n h.ylen * Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n\n const basisZ = [\n h.zlen * Math.cos(Math.PI / 180.0 * h.beta),\n h.zlen * (\n Math.cos(Math.PI / 180.0 * h.alpha) -\n Math.cos(Math.PI / 180.0 * h.gamma) *\n Math.cos(Math.PI / 180.0 * h.beta)\n ) / Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n basisZ[ 2 ] = Math.sqrt(\n h.zlen * h.zlen * Math.sin(Math.PI / 180.0 * h.beta) *\n Math.sin(Math.PI / 180.0 * h.beta) - basisZ[ 1 ] * basisZ[ 1 ]\n )\n\n const basis = [ [], basisX, basisY, basisZ ]\n const nxyz = [ 0, h.MX, h.MY, h.MZ ]\n const mapcrs = [ 0, h.MAPC, h.MAPR, h.MAPS ]\n\n const matrix = new Matrix4()\n\n matrix.set(\n basis[ mapcrs[1] ][0] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][0] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][0] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][1] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][1] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][1] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][2] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][2] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][2] / nxyz[ mapcrs[3] ],\n 0,\n 0, 0, 0, 1\n )\n\n matrix.setPosition(new Vector3(\n h.originX, h.originY, h.originZ\n ))\n\n matrix.multiply(new Matrix4().makeTranslation(\n h.NXSTART, h.NYSTART, h.NZSTART\n ))\n\n return matrix\n }\n}\n\nParserRegistry.add('mrc', MrcParser)\nParserRegistry.add('ccp4', MrcParser)\nParserRegistry.add('map', MrcParser)\n\nexport default MrcParser\n","/**\n * @file Xplor Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport VolumeParser from './volume-parser'\n\nconst reWhitespace = /\\s+/\n\nfunction parseNumberLine (line: string) {\n return line.trim().split(reWhitespace).map(parseFloat)\n}\n\ninterface XplorHeader {\n NA: number,\n AMIN: number,\n AMAX: number,\n NB: number,\n BMIN: number,\n BMAX: number,\n NC: number,\n CMIN: number,\n CMAX: number,\n a: number,\n b: number,\n c: number,\n alpha: number,\n beta: number,\n gamma: number,\n RAVE: number,\n RSIGMA: number\n}\n\nclass XplorParser extends VolumeParser {\n get type () { return 'xplor' }\n\n _parse () {\n // http://hincklab.uthscsa.edu/html/soft_packs/msi_docs/insight980/xplor/formats.html\n // http://www.mrc-lmb.cam.ac.uk/public/xtal/doc/cns/cns_1.3/tutorial/formats/maps/text.html\n\n if (Debug) Log.time('XplorParser._parse ' + this.name)\n\n const v = this.volume\n const headerLines = this.streamer.peekLines(8)\n const header: Partial = {}\n\n let infoStart\n if (headerLines[ 2 ].startsWith('REMARKS')) {\n infoStart = parseInt(headerLines[ 1 ].substring(0, 8)) + 2\n } else {\n infoStart = 5\n }\n const dataStart = infoStart + 3\n\n const gridInfo = parseNumberLine(headerLines[ infoStart ])\n header.NA = gridInfo[ 0 ]\n header.AMIN = gridInfo[ 1 ]\n header.AMAX = gridInfo[ 2 ]\n header.NB = gridInfo[ 3 ]\n header.BMIN = gridInfo[ 4 ]\n header.BMAX = gridInfo[ 5 ]\n header.NC = gridInfo[ 6 ]\n header.CMIN = gridInfo[ 7 ]\n header.CMAX = gridInfo[ 8 ]\n\n const cellInfo = parseNumberLine(headerLines[ infoStart + 1 ])\n header.a = cellInfo[ 0 ] * this.voxelSize\n header.b = cellInfo[ 1 ] * this.voxelSize\n header.c = cellInfo[ 2 ] * this.voxelSize\n header.alpha = cellInfo[ 3 ]\n header.beta = cellInfo[ 4 ]\n header.gamma = cellInfo[ 5 ]\n\n const na = header.AMAX - header.AMIN + 1\n const nb = header.BMAX - header.BMIN + 1\n const nc = header.CMAX - header.CMIN + 1\n const n = na * nb * nc\n\n const data = new Float32Array(n)\n const lineSection = Math.ceil(1 + (na * nb) / 6)\n let count = 0\n let lineNo = 0\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n\n if (lineNo >= dataStart && (lineNo - dataStart) % lineSection !== 0 && count < n) {\n for (let j = 0, lj = 6; j < lj; ++j) {\n const value = parseFloat(line.substr(12 * j, 12))\n if (isNaN(value)) { break } // Last line of map section\n data[count++] = value\n }\n } else if (count === n) {\n const lt = line.trim()\n if (lt && lt !== '-9999') {\n const ls = parseNumberLine(line)\n header.RAVE = ls[0]\n header.RSIGMA = ls[1]\n }\n }\n\n ++lineNo\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n v.header = header\n v.setData(data, na, nb, nc)\n if (header.RAVE !== 0 && header.RSIGMA !== 1) {\n v.setStats(undefined, undefined, header.RAVE, header.RSIGMA)\n }\n\n if (Debug) Log.timeEnd('XplorParser._parse ' + this.name)\n }\n\n getMatrix () {\n const h = this.volume.header\n\n const basisX = [\n h.a,\n 0,\n 0\n ]\n\n const basisY = [\n h.b * Math.cos(Math.PI / 180.0 * h.gamma),\n h.b * Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n\n const basisZ = [\n h.c * Math.cos(Math.PI / 180.0 * h.beta),\n h.c * (\n Math.cos(Math.PI / 180.0 * h.alpha) -\n Math.cos(Math.PI / 180.0 * h.gamma) *\n Math.cos(Math.PI / 180.0 * h.beta)\n ) / Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n basisZ[ 2 ] = Math.sqrt(\n h.c * h.c * Math.sin(Math.PI / 180.0 * h.beta) *\n Math.sin(Math.PI / 180.0 * h.beta) - basisZ[ 1 ] * basisZ[ 1 ]\n )\n\n const basis = [ [], basisX, basisY, basisZ ]\n const nxyz = [ 0, h.NA, h.NB, h.NC ]\n const mapcrs = [ 0, 1, 2, 3 ]\n\n const matrix = new Matrix4()\n\n matrix.set(\n basis[ mapcrs[1] ][0] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][0] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][0] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][1] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][1] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][1] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][2] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][2] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][2] / nxyz[ mapcrs[3] ],\n 0,\n 0, 0, 0, 1\n )\n\n matrix.multiply(new Matrix4().makeTranslation(\n h.AMIN, h.BMIN, h.CMIN\n ))\n\n return matrix\n }\n}\n\nParserRegistry.add('xplor', XplorParser)\nParserRegistry.add('cns', XplorParser)\n\nexport default XplorParser\n","/**\n * @file Kin Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { Vector3 } from 'three'\nimport Parser from './parser'\n\nfunction hsvToRgb (h: number, s: number, v: number) {\n h /= 360\n s /= 100\n v /= 100\n let r, g, b\n const i = Math.floor(h * 6)\n const f = h * 6 - i\n const p = v * (1 - s)\n const q = v * (1 - f * s)\n const t = v * (1 - (1 - f) * s)\n switch (i % 6) {\n case 0: r = v; g = t; b = p; break\n case 1: r = q; g = v; b = p; break\n case 2: r = p; g = v; b = t; break\n case 3: r = p; g = q; b = v; break\n case 4: r = t; g = p; b = v; break\n case 5: r = v; g = p; b = q; break\n }\n return [ r, g, b ] as number []\n}\n\nconst ColorDict: {[k: string]: number[]} = {\n red: hsvToRgb(0, 100, 100),\n orange: hsvToRgb(20, 100, 100),\n gold: hsvToRgb(40, 100, 100),\n yellow: hsvToRgb(60, 100, 100),\n lime: hsvToRgb(80, 100, 100),\n green: hsvToRgb(120, 80, 100),\n sea: hsvToRgb(150, 100, 100),\n cyan: hsvToRgb(180, 100, 85),\n sky: hsvToRgb(210, 75, 95),\n blue: hsvToRgb(240, 70, 100),\n purple: hsvToRgb(275, 75, 100),\n magenta: hsvToRgb(300, 95, 100),\n hotpink: hsvToRgb(335, 100, 100),\n pink: hsvToRgb(350, 55, 100),\n peach: hsvToRgb(25, 75, 100),\n lilac: hsvToRgb(275, 55, 100),\n pinktint: hsvToRgb(340, 30, 100),\n peachtint: hsvToRgb(25, 50, 100),\n yellowtint: hsvToRgb(60, 50, 100),\n greentint: hsvToRgb(135, 40, 100),\n bluetint: hsvToRgb(220, 40, 100),\n lilactint: hsvToRgb(275, 35, 100),\n white: hsvToRgb(0, 0, 100),\n gray: hsvToRgb(0, 0, 50),\n brown: hsvToRgb(20, 45, 75),\n deadwhite: [ 1, 1, 1 ],\n deadblack: [ 0, 0, 0 ],\n invisible: [ 0, 0, 0 ]\n}\n\nconst reWhitespaceComma = /[\\s,]+/\nconst reCurlyWhitespace = /[^{}\\s]*{[^{}]+}|[^{}\\s]+/g\nconst reTrimCurly = /^{+|}+$/g\nconst reTrimQuotes = /^['\"]+|['\"]+$/g\nconst reCollapseEqual = /\\s*=\\s*/g\n\nfunction parseListDef (line: string) {\n let name\n let defaultColor\n let master = []\n let width\n\n line = line.replace(reCollapseEqual, '=')\n\n const lm = line.match(reCurlyWhitespace) as RegExpMatchArray\n for (let j = 1; j < lm.length; ++j) {\n const e = lm[ j ]\n if (e[ 0 ] === '{') {\n name = e.substring(1, e.length - 1)\n } else {\n const es = e.split('=')\n if (es.length === 2) {\n if (es[ 0 ] === 'color') {\n defaultColor = ColorDict[ es[ 1 ] ]\n } else if (es[ 0 ] === 'width') {\n width = parseInt(es[ 1 ])\n } else if (es[ 0 ] === 'master') {\n master.push(es[ 1 ].replace(reTrimCurly, ''))\n }\n }\n }\n }\n\n return {\n listName: name,\n listColor: defaultColor,\n listMasters: master,\n listWidth: width\n }\n}\n\nfunction parseListElm (line: string) {\n line = line.trim()\n\n const idx1 = line.indexOf('{')\n const idx2 = line.indexOf('}')\n const ls = line.substr(idx2 + 1).split(reWhitespaceComma)\n\n const label = line.substr(idx1 + 1, idx2 - 1)\n const position = [\n parseFloat(ls[ ls.length - 3 ]),\n parseFloat(ls[ ls.length - 2 ]),\n parseFloat(ls[ ls.length - 1 ])\n ]\n let color, width, radius\n let lineBreak = false\n let triangleBreak = false\n for (let lsindex = 4; lsindex <= ls.length; lsindex++) {\n const literal = ls[ ls.length - lsindex ]\n if (literal in ColorDict) {\n color = ColorDict[ ls[ ls.length - lsindex ] ]\n }\n if (literal.startsWith('width')) {\n width = parseInt(literal.substring(5))\n }\n if (literal.startsWith('r=')) {\n radius = parseFloat(literal.split('=')[1])\n }\n if (literal.startsWith('P')) {\n lineBreak = true\n }\n if (literal.startsWith('X')) {\n triangleBreak = true\n }\n }\n // const color = line[ idx2 + 1 ] === ' ' ? undefined : ColorDict[ ls[ 0 ] ]\n\n return {\n label: label,\n position: position,\n color: color,\n radius: radius,\n width: width,\n isLineBreak: lineBreak,\n isTriangleBreak: triangleBreak\n }\n}\n\nfunction parseStr (line: string) {\n const start = line.indexOf('{')\n const end = line.indexOf('}')\n return line.substring(\n start !== -1 ? start + 1 : 0,\n end !== -1 ? end : undefined\n ).trim()\n}\n\nfunction parseFlag (line: string) {\n const end = line.indexOf('}')\n return end === -1 ? undefined : line.substr(end + 1).trim()\n}\n\nfunction parseGroup (line: string) {\n let name:string = ''\n let master:string[] = []\n let flags: {[k: string]: string|boolean} = {}\n\n line = line.replace(reCollapseEqual, '=')\n\n const lm = line.match(reCurlyWhitespace) as RegExpMatchArray\n for (let j = 1; j < lm.length; ++j) {\n const e = lm[ j ]\n if (e[ 0 ] === '{') {\n name = e.substring(1, e.length - 1)\n } else {\n const es = e.split('=')\n if (es.length === 2) {\n if (es[ 0 ] === 'master') {\n master.push(es[ 1 ].replace(reTrimCurly, ''))\n } else {\n flags[ es[ 0 ] ] = es[ 1 ].replace(reTrimCurly, '')\n }\n } else {\n flags[ es[ 0 ] ] = true\n }\n }\n }\n\n return { groupName: name,\n groupFlags: flags,\n groupMasters: master\n }\n}\ninterface RibbonObject {\n labelArray: string[],\n positionArray: number[],\n breakArray: boolean[],\n colorArray: number[],\n name?: string,\n masterArray: any[]\n}\nfunction convertKinTriangleArrays (ribbonObject: RibbonObject) {\n // have to convert ribbons/triangle lists from stripdrawmode to normal drawmode\n // index [ 0 1 2 3 4 5 6 7 8 91011 ]\n // label [ 0 1 2 3 4 5 ] to [ 0 1 2 1 2 3 2 3 4 3 4 5 ]\n // convertedindex [ 0 1 2 3 4 5 6 7 8 91011121314151617181920212223242526 ]\n // index [ 0 1 2 3 4 5 6 7 8 91011121314 ] [ 0 1 2 3 4 5 6 7 8 3 4 5 6 7 8 91011 6 7 8 91011121314 ]\n // position/color [ 0 0 0 1 1 1 2 2 2 3 3 3 4 4 4 ] to [ 0 0 0 1 1 1 2 2 2 1 1 1 2 2 2 3 3 3 2 2 2 3 3 3 4 4 4 ]\n let { labelArray, positionArray, colorArray, breakArray } = ribbonObject\n let convertedLabels = []\n for (let i = 0; i < (labelArray.length - 2) * 3; ++i) {\n convertedLabels[i] = labelArray[i - Math.floor(i / 3) * 2]\n }\n let convertedBreaks = []\n for (let i = 0; i < (breakArray.length - 2) * 3; ++i) {\n convertedBreaks[i] = breakArray[i - Math.floor(i / 3) * 2]\n }\n let convertedPositions = []\n for (let i = 0; i < (positionArray.length / 3 - 2) * 9; ++i) {\n convertedPositions[i] = positionArray[i - Math.floor(i / 9) * 6]\n }\n let convertedColors = []\n for (let i = 0; i < (colorArray.length / 3 - 2) * 9; ++i) {\n convertedColors[i] = colorArray[i - Math.floor(i / 9) * 6]\n }\n let vector3Positions = []\n for (let i = 0; i < (convertedPositions.length) / 3; ++i) {\n vector3Positions.push(new Vector3(convertedPositions[i * 3], convertedPositions[i * 3] + 1, convertedPositions[i * 3] + 2))\n }\n //let normals = []\n //for (let i = 0; i < vector3Positions.length - 1; ++i) {\n // let normalVec3 = vector3Positions[i].cross(vector3Positions[i + 1])\n // normals.push(normalVec3.x)\n // normals.push(normalVec3.y)\n // normals.push(normalVec3.z)\n //}\n return {\n name: ribbonObject.name,\n masterArray: ribbonObject.masterArray,\n labelArray: convertedLabels,\n positionArray: convertedPositions,\n breakArray: convertedBreaks,\n colorArray: convertedColors\n }\n}\n\nfunction removePointBreaksTriangleArrays (convertedRibbonObject: RibbonObject) {\n // after converting ribbon/triangle arrys to drawmode, removed point break triangles\n // label [ 0 1 2 3 4 5 ] to [ 0 1 2 1 2 3 2 3 4 3 4 5 ]\n // position/color [ 0 0 0 1 1 1 2 2 2 3 3 3 4 4 4 ] to [ 0 0 0 1 1 1 2 2 2 1 1 1 2 2 2 3 3 3 2 2 2 3 3 3 4 4 4 ]\n let { labelArray, positionArray, colorArray, breakArray } = convertedRibbonObject\n let editedLabels = []\n let editedPositions = []\n let editedColors = []\n let editedBreaks = []\n for (let i = 0; i < breakArray.length / 3; i++) {\n let breakPointer = i * 3\n let positionPointer = i * 9\n if (!breakArray[breakPointer+1]&&!breakArray[breakPointer+2]) {\n editedLabels.push(labelArray[breakPointer])\n editedLabels.push(labelArray[breakPointer+1])\n editedLabels.push(labelArray[breakPointer+2])\n editedBreaks.push(breakArray[breakPointer])\n editedBreaks.push(breakArray[breakPointer+1])\n editedBreaks.push(breakArray[breakPointer+2])\n editedPositions.push(positionArray[positionPointer])\n editedPositions.push(positionArray[positionPointer+1])\n editedPositions.push(positionArray[positionPointer+2])\n editedPositions.push(positionArray[positionPointer+3])\n editedPositions.push(positionArray[positionPointer+4])\n editedPositions.push(positionArray[positionPointer+5])\n editedPositions.push(positionArray[positionPointer+6])\n editedPositions.push(positionArray[positionPointer+7])\n editedPositions.push(positionArray[positionPointer+8])\n editedColors.push(colorArray[positionPointer])\n editedColors.push(colorArray[positionPointer+1])\n editedColors.push(colorArray[positionPointer+2])\n editedColors.push(colorArray[positionPointer+3])\n editedColors.push(colorArray[positionPointer+4])\n editedColors.push(colorArray[positionPointer+5])\n editedColors.push(colorArray[positionPointer+6])\n editedColors.push(colorArray[positionPointer+7])\n editedColors.push(colorArray[positionPointer+8])\n } else {\n //console.log('X triangle break found')\n //console.log('skipping: '+positionArray[positionPointer]+','+positionArray[positionPointer+1]+','+positionArray[positionPointer+2]+','\n // +positionArray[positionPointer+3]+','+positionArray[positionPointer+4]+','+positionArray[positionPointer+5]+','\n // +positionArray[positionPointer+6]+','+positionArray[positionPointer+7]+','+positionArray[positionPointer+8])\n }\n }\n return {\n name: convertedRibbonObject.name,\n masterArray: convertedRibbonObject.masterArray,\n labelArray: editedLabels,\n positionArray: editedPositions,\n breakArray: editedBreaks,\n colorArray: editedColors\n }\n}\n\ninterface Kinemage {\n kinemage?: number,\n onewidth?: any,\n '1viewid'?: string,\n pdbfile?: string,\n text: string,\n texts: string[],\n captions: string[],\n caption: string,\n groupDict: {[k:string]: {[k:string]: boolean}},\n subgroupDict: {[k: string]: any},\n masterDict: {[k:string]: {indent: boolean, visible: boolean}},\n pointmasterDict: {[k: string]: any},\n dotLists: DotList[],\n vectorLists: VectorList[],\n ballLists: any[],\n ribbonLists: RibbonObject[]\n}\n\ninterface DotList {\n name?: string,\n masterArray: any[],\n labelArray: any[],\n positionArray: any[],\n colorArray: any[]\n}\n\ninterface VectorList {\n name?: string,\n masterArray: any[],\n label1Array: string[],\n label2Array: string[],\n position1Array: number[],\n position2Array: number[],\n color1Array: number[],\n color2Array: number[],\n width: number[]\n}\n\nclass KinParser extends Parser {\n kinemage: Kinemage\n get type () { return 'kin' }\n get __objName () { return 'kinemage' }\n\n _parse () {\n // http://kinemage.biochem.duke.edu/software/king.php\n\n if (Debug) Log.time(`KinParser._parse ${this.name}`)\n\n const kinemage: Kinemage = {\n kinemage: undefined,\n onewidth: undefined,\n '1viewid': undefined,\n pdbfile: undefined,\n texts: [],\n text: '',\n captions: [],\n caption: '',\n groupDict: {},\n subgroupDict: {},\n masterDict: {},\n pointmasterDict: {},\n dotLists: [],\n vectorLists: [],\n ballLists: [],\n ribbonLists: []\n }\n this.kinemage = kinemage\n\n let currentGroupMasters: string[]\n let currentSubgroupMasters: string[]\n\n let isDotList = false\n let prevDotLabel = ''\n let dotDefaultColor: number[]\n let dotLabel: string[], dotPosition: number[], dotColor: number[]\n\n let isVectorList = false\n let prevVecLabel = ''\n let prevVecPosition: number[]|null = null\n let prevVecColor: number[]|null = null\n let vecDefaultColor: number[], vecDefaultWidth: number[]\n let vecLabel1: string[], vecLabel2: string[], vecPosition1: number[], vecPosition2: number[], vecColor1: number[], vecColor2: number[]\n\n let isBallList = false\n let prevBallLabel = ''\n let ballRadius: number[], ballDefaultColor: number[]\n let ballLabel: string[], ballPosition: number[], ballColor: number[]\n\n let isRibbonList = false\n let prevRibbonPointLabel = ''\n\n let ribbonListDefaultColor: number[]\n let ribbonPointLabelArray: string[], ribbonPointPositionArray: number[], ribbonPointBreakArray: boolean[], ribbonPointColorArray: number[]\n\n let isText = false\n let isCaption = false\n\n // @vectorlist {mc} color= white master= {mainchain}\n // { n thr A 1 B13.79 1crnFH} P 17.047, 14.099, 3.625 { n thr A 1 B13.79 1crnFH} L 17.047, 14.099, 3.625\n\n // @dotlist {x} color=white master={vdw contact} master={dots}\n // { CB THR 1 A}sky 'P' 18.915,14.199,5.024\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n\n if (line[ 0 ] === '@') {\n isDotList = false\n isVectorList = false\n isBallList = false\n isRibbonList = false\n isText = false\n isCaption = false\n }\n\n if (!line) {\n isDotList = false\n isVectorList = false\n isBallList = false\n isRibbonList = false\n } else if (line.startsWith('@dotlist')) {\n // @dotlist {x} color=white master={vdw contact} master={dots}\n\n let { listColor, listName, listMasters } = parseListDef(line)\n\n isDotList = true\n prevDotLabel = ''\n dotLabel = []\n dotPosition = []\n dotColor = []\n dotDefaultColor = listColor as number[]\n\n if (currentGroupMasters) {\n listMasters = listMasters.concat(currentGroupMasters)\n }\n if (currentSubgroupMasters) {\n listMasters = listMasters.concat(currentSubgroupMasters)\n }\n\n kinemage.dotLists.push({\n name: listName,\n masterArray: listMasters,\n labelArray: dotLabel,\n positionArray: dotPosition,\n colorArray: dotColor\n })\n } else if (line.startsWith('@vectorlist')) {\n // @vectorlist {x} color=white master={small overlap} master={dots}\n\n let { listMasters, listName, listWidth, listColor } = parseListDef(line)\n\n if (listMasters) {\n listMasters.forEach(function (name: string) {\n if (!kinemage.masterDict[ name ]) {\n kinemage.masterDict[ name ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n\n isVectorList = true\n prevVecLabel = ''\n prevVecPosition = null\n prevVecColor = null\n vecLabel1 = []\n vecLabel2 = []\n vecPosition1 = []\n vecPosition2 = []\n vecColor1 = []\n vecColor2 = []\n vecDefaultColor = listColor as number[]\n vecDefaultWidth = []\n if (listWidth) {\n vecDefaultWidth.push(listWidth)\n }\n\n if (currentGroupMasters) {\n listMasters = listMasters.concat(currentGroupMasters)\n }\n if (currentSubgroupMasters) {\n listMasters = listMasters.concat(currentSubgroupMasters)\n }\n\n kinemage.vectorLists.push({\n name: listName,\n masterArray: listMasters,\n label1Array: vecLabel1,\n label2Array: vecLabel2,\n position1Array: vecPosition1,\n position2Array: vecPosition2,\n color1Array: vecColor1,\n color2Array: vecColor2,\n width: vecDefaultWidth\n })\n } else if (line.startsWith('@balllist')) {\n let { listName, listColor, listMasters } = parseListDef(line)\n\n if (listMasters) {\n listMasters.forEach(function (name: string) {\n if (!kinemage.masterDict[ name ]) {\n kinemage.masterDict[ name ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n\n isBallList = true\n\n prevBallLabel = ''\n ballLabel = []\n ballRadius = []\n ballPosition = []\n ballColor = []\n ballDefaultColor = listColor as number[]\n\n if (currentGroupMasters) {\n listMasters = listMasters.concat(currentGroupMasters)\n }\n if (currentSubgroupMasters) {\n listMasters = listMasters.concat(currentSubgroupMasters)\n }\n\n kinemage.ballLists.push({\n name: listName,\n masterArray: listMasters,\n labelArray: ballLabel,\n radiusArray: ballRadius,\n positionArray: ballPosition,\n colorArray: ballColor\n })\n } else if (line.startsWith('@ribbonlist')||line.startsWith('@trianglelist')) {\n let { listMasters, listName, listColor } = parseListDef(line)\n\n if (listMasters) {\n listMasters.forEach(function (name: string) {\n if (!kinemage.masterDict[ name ]) {\n kinemage.masterDict[ name ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n isRibbonList = true\n prevRibbonPointLabel = ''\n ribbonPointLabelArray = []\n ribbonPointPositionArray = []\n ribbonPointBreakArray = []\n ribbonPointColorArray = []\n ribbonListDefaultColor = listColor as number[]\n\n if (currentGroupMasters) {\n listMasters = listMasters.concat(currentGroupMasters)\n }\n if (currentSubgroupMasters) {\n listMasters = listMasters.concat(currentSubgroupMasters)\n }\n\n kinemage.ribbonLists.push({\n name: listName,\n masterArray: listMasters,\n labelArray: ribbonPointLabelArray,\n positionArray: ribbonPointPositionArray,\n breakArray: ribbonPointBreakArray,\n colorArray: ribbonPointColorArray\n })\n } else if (line.startsWith('@text')) {\n isText = true\n kinemage.texts.push(line.substr(5))\n } else if (line.startsWith('@caption')) {\n isCaption = true\n kinemage.captions.push(line.substr(8))\n } else if (isDotList) {\n // { CB THR 1 A}sky 'P' 18.915,14.199,5.024\n\n let { label, color, position } = parseListElm(line)\n\n if (label === '\"') {\n label = prevDotLabel\n } else {\n prevDotLabel = label\n }\n\n if (color === undefined) {\n color = dotDefaultColor\n }\n\n dotLabel.push(label)\n dotPosition.push(...position)\n dotColor.push(...color)\n } else if (isVectorList) {\n // { n thr A 1 B13.79 1crnFH} P 17.047, 14.099, 3.625 { n thr A 1 B13.79 1crnFH} L 17.047, 14.099, 3.625\n\n let doubleLine = line.replace(/(?!^){/g, '\\n{')\n let splitLine = doubleLine.split(/\\n/)\n\n for (var i2 = 0; i2 < splitLine.length; i2++) {\n let singlePointLine = splitLine[i2]\n let { label, color, width, position, isLineBreak } = parseListElm(singlePointLine)\n\n if (label === '\"') {\n label = prevVecLabel\n } else {\n prevVecLabel = label\n }\n\n if (color === undefined) {\n color = vecDefaultColor\n }\n\n if (!isLineBreak) {\n if (prevVecPosition !== null) {\n if (width) {\n vecDefaultWidth.push(width)\n }\n\n vecLabel1.push(prevVecLabel)\n vecPosition1.push(...prevVecPosition)\n vecColor1.push(...prevVecColor as number[])\n\n vecLabel2.push(label)\n vecPosition2.push(...position)\n vecColor2.push(...color)\n\n }\n }\n\n prevVecLabel = label\n prevVecPosition = position\n prevVecColor = color\n }\n } else if (isBallList) {\n // {cb arg A 1 1.431 -106.80} r=1.431 39.085, 8.083, 22.182\n\n let { label, radius, color, position } = parseListElm(line)\n\n if (label === '\"') {\n label = prevBallLabel\n } else {\n prevBallLabel = label\n }\n\n if (radius === undefined) {\n radius = 1 // temporary default radius\n }\n\n if (color === undefined) {\n color = ballDefaultColor\n }\n\n ballLabel.push(label)\n ballRadius.push(radius)\n ballPosition.push(...position)\n ballColor.push(...color)\n } else if (isRibbonList) {\n let { label, color, position, isTriangleBreak } = parseListElm(line)\n\n if (label === '\"') {\n label = prevRibbonPointLabel\n } else {\n prevRibbonPointLabel = label\n }\n\n if (color === undefined) {\n color = ribbonListDefaultColor\n }\n\n ribbonPointLabelArray.push(label)\n ribbonPointPositionArray.push(...position)\n ribbonPointBreakArray.push(isTriangleBreak)\n ribbonPointColorArray.push(...color)\n } else if (isText) {\n kinemage.texts.push(line)\n } else if (isCaption) {\n kinemage.captions.push(line)\n } else if (line.startsWith('@kinemage')) {\n kinemage.kinemage = parseInt(line.substr(9).trim())\n } else if (line.startsWith('@onewidth')) {\n kinemage.onewidth = true\n } else if (line.startsWith('@1viewid')) {\n kinemage[ '1viewid' ] = parseStr(line)\n } else if (line.startsWith('@pdbfile')) {\n kinemage.pdbfile = parseStr(line)\n } else if (line.startsWith('@group')) {\n let { groupName, groupFlags, groupMasters } = parseGroup(line)\n if (!kinemage.groupDict[ groupName as string ]) {\n kinemage.groupDict[ groupName as string ] = {\n dominant: false,\n animate: false\n }\n currentGroupMasters = groupMasters\n }\n\n if (currentGroupMasters) {\n currentGroupMasters.forEach(function (master) {\n if (!kinemage.masterDict[ master ]) {\n kinemage.masterDict[ master ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n\n for (let key in groupFlags as {[k: string]: boolean}) {\n kinemage.groupDict[ groupName as string ][ key ] = (groupFlags as {[k: string]: boolean})[ key ]\n }\n } else if (line.startsWith('@subgroup')) {\n const { groupName, groupFlags, groupMasters } = parseGroup(line)\n\n if (!kinemage.subgroupDict[ groupName as string ]) {\n kinemage.subgroupDict[ groupName as string ] = {\n dominant: false,\n animate: false\n }\n currentSubgroupMasters = groupMasters\n }\n\n if (currentSubgroupMasters) {\n currentSubgroupMasters.forEach(function (master) {\n if (!kinemage.masterDict[ master ]) {\n kinemage.masterDict[ master ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n\n for (let key in groupFlags as {[k: string]: boolean}) {\n kinemage.subgroupDict[ groupName as string ][ key ] = (groupFlags as {[k: string]: boolean})[ key ]\n }\n } else if (line.startsWith('@master')) {\n const name = parseStr(line)\n const flag = parseFlag(line)\n\n if (!kinemage.masterDict[ name ]) {\n kinemage.masterDict[ name ] = {\n indent: false,\n visible: false\n }\n }\n\n if (flag === 'on') {\n kinemage.masterDict[ name ].visible = true\n } else if (flag === 'off') {\n kinemage.masterDict[ name ].visible = false\n } else if (flag === 'indent') {\n kinemage.masterDict[ name ].indent = true\n } else if (!flag) {\n // nothing to do\n }\n } else if (line.startsWith('@pointmaster')) {\n const { groupName, groupFlags } = parseGroup(line)\n\n kinemage.pointmasterDict[ groupName as string] = {\n id: Object.keys(groupFlags as {[k: string]: boolean})[ 0 ].replace(reTrimQuotes, '')\n }\n } else {\n console.log(line)\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n kinemage.text = kinemage.texts.join('\\n').trim()\n kinemage.caption = kinemage.captions.join('\\n').trim()\n if (kinemage.ribbonLists) {\n let convertedLists: RibbonObject[] = []\n kinemage.ribbonLists.forEach(function (listObject) {\n convertedLists.push(removePointBreaksTriangleArrays(convertKinTriangleArrays(listObject)))\n })\n kinemage.ribbonLists = convertedLists\n }\n\n if (Debug) Log.timeEnd(`KinParser._parse ${this.name}`)\n }\n}\n\nParserRegistry.add('kin', KinParser)\n\nexport default KinParser\n","/**\n * @file Surface Parser\n * @author Alexander Rose \n * @private\n */\n\nimport Parser, { ParserParameters } from './parser'\nimport Surface from '../surface/surface'\nimport Streamer from '../streamer/streamer';\n\nclass SurfaceParser extends Parser {\n constructor (streamer: Streamer, params?:Partial) {\n super(streamer, params)\n\n this.loader = this.getLoader()\n this.surface = new Surface(this.name, this.path)\n }\n\n get type () { return 'surface' }\n get __objName () { return 'surface' }\n\n _parse () {\n var geometry = this.loader.parse(this.streamer.asText())\n\n this.surface.fromGeometry(geometry)\n }\n}\n\nexport default SurfaceParser\n","/**\n * @file Obj Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { BufferGeometry, BufferAttribute } from 'three'\n\nimport { ParserRegistry } from '../globals'\nimport SurfaceParser from './surface-parser'\n\nexport interface _OBJLoader {\n regexp: {[k: string]: RegExp}\n}\n\ninterface _OBJLoaderConstructor {\n (this: _OBJLoader): void\n new(): _OBJLoader\n}\n\ninterface ObjectType {\n name: string,\n fromDeclaration: boolean,\n geometry: {\n vertices: number[],\n normals: number[],\n type?: string\n }\n}\n/**\n * OBJLoader\n * @class\n * @private\n * @author mrdoob / http://mrdoob.com/\n */\nconst OBJLoader = (function OBJLoader (this: _OBJLoader) {\n this.regexp = {\n // v float float float\n vertex_pattern: /^v\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)/,\n // vn float float float\n normal_pattern: /^vn\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)/,\n // vt float float\n uv_pattern: /^vt\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)/,\n // f vertex vertex vertex\n face_vertex: /^f\\s+(-?\\d+)\\s+(-?\\d+)\\s+(-?\\d+)(?:\\s+(-?\\d+))?/,\n // f vertex/uv vertex/uv vertex/uv\n face_vertex_uv: /^f\\s+(-?\\d+)\\/(-?\\d+)\\s+(-?\\d+)\\/(-?\\d+)\\s+(-?\\d+)\\/(-?\\d+)(?:\\s+(-?\\d+)\\/(-?\\d+))?/,\n // f vertex/uv/normal vertex/uv/normal vertex/uv/normal\n face_vertex_uv_normal: /^f\\s+(-?\\d+)\\/(-?\\d+)\\/(-?\\d+)\\s+(-?\\d+)\\/(-?\\d+)\\/(-?\\d+)\\s+(-?\\d+)\\/(-?\\d+)\\/(-?\\d+)(?:\\s+(-?\\d+)\\/(-?\\d+)\\/(-?\\d+))?/,\n // f vertex//normal vertex//normal vertex//normal\n face_vertex_normal: /^f\\s+(-?\\d+)\\/\\/(-?\\d+)\\s+(-?\\d+)\\/\\/(-?\\d+)\\s+(-?\\d+)\\/\\/(-?\\d+)(?:\\s+(-?\\d+)\\/\\/(-?\\d+))?/,\n // o object_name | g group_name\n object_pattern: /^[og]\\s*(.+)?/,\n // s boolean\n smoothing_pattern: /^s\\s+(\\d+|on|off)/,\n // mtllib file_reference\n material_library_pattern: /^mtllib /,\n // usemtl material_name\n material_use_pattern: /^usemtl /\n }\n}) as _OBJLoaderConstructor\n\nOBJLoader.prototype = {\n\n constructor: OBJLoader,\n\n setPath: function (value: string) {\n this.path = value\n },\n\n _createParserState: function () {\n var state = {\n objects: [] as ObjectType[],\n object: {} as ObjectType,\n\n vertices: [],\n normals: [],\n\n startObject: function (name: string, fromDeclaration: boolean) {\n // If the current object (initial from reset) is not from a g/o declaration in the parsed\n // file. We need to use it for the first parsed g/o to keep things in sync.\n if (this.object && this.object.fromDeclaration === false) {\n this.object.name = name\n this.object.fromDeclaration = (fromDeclaration !== false)\n return\n }\n\n this.object = {\n name: name || '',\n geometry: {\n vertices: [],\n normals: []\n },\n fromDeclaration: (fromDeclaration !== false)\n }\n\n this.objects.push(this.object)\n },\n\n parseVertexIndex: function (value: string, len: number) {\n var index = parseInt(value, 10)\n return (index >= 0 ? index - 1 : index + len / 3) * 3\n },\n\n parseNormalIndex: function (value: string, len: number) {\n var index = parseInt(value, 10)\n return (index >= 0 ? index - 1 : index + len / 3) * 3\n },\n\n addVertex: function (a: number, b: number, c: number) {\n var src = this.vertices\n var dst = this.object.geometry.vertices\n\n dst.push(src[ a + 0 ])\n dst.push(src[ a + 1 ])\n dst.push(src[ a + 2 ])\n dst.push(src[ b + 0 ])\n dst.push(src[ b + 1 ])\n dst.push(src[ b + 2 ])\n dst.push(src[ c + 0 ])\n dst.push(src[ c + 1 ])\n dst.push(src[ c + 2 ])\n },\n\n addVertexLine: function (a: number) {\n var src = this.vertices\n var dst = this.object.geometry.vertices\n\n dst.push(src[ a + 0 ])\n dst.push(src[ a + 1 ])\n dst.push(src[ a + 2 ])\n },\n\n addNormal: function (a: number, b: number, c: number) {\n var src = this.normals\n var dst = this.object.geometry.normals\n\n dst.push(src[ a + 0 ])\n dst.push(src[ a + 1 ])\n dst.push(src[ a + 2 ])\n dst.push(src[ b + 0 ])\n dst.push(src[ b + 1 ])\n dst.push(src[ b + 2 ])\n dst.push(src[ c + 0 ])\n dst.push(src[ c + 1 ])\n dst.push(src[ c + 2 ])\n },\n\n addFace: function (a: string, b: string, c: string, d?: string, na?: string, nb?: string, nc?: string, nd?: string) {\n var vLen = this.vertices.length\n\n var ia = this.parseVertexIndex(a, vLen)\n var ib = this.parseVertexIndex(b, vLen)\n var ic = this.parseVertexIndex(c, vLen)\n var id\n\n if (d === undefined) {\n this.addVertex(ia, ib, ic)\n } else {\n id = this.parseVertexIndex(d, vLen)\n\n this.addVertex(ia, ib, id)\n this.addVertex(ib, ic, id)\n }\n\n if (na !== undefined) {\n // Normals are many times the same. If so, skip function call and parseInt.\n var nLen = this.normals.length\n ia = this.parseNormalIndex(na, nLen)\n\n ib = na === nb ? ia : this.parseNormalIndex(nb!, nLen)\n ic = na === nc ? ia : this.parseNormalIndex(nc!, nLen)\n\n if (d === undefined) {\n this.addNormal(ia, ib, ic)\n } else {\n id = this.parseNormalIndex(nd!, nLen)\n\n this.addNormal(ia, ib, id)\n this.addNormal(ib, ic, id)\n }\n }\n },\n\n addLineGeometry: function (vertices: string[]) {\n this.object.geometry.type = 'Line'\n\n var vLen = this.vertices.length\n\n for (var vi = 0, l = vertices.length; vi < l; vi++) {\n this.addVertexLine(this.parseVertexIndex(vertices[ vi ], vLen))\n }\n }\n\n }\n\n state.startObject('', false)\n\n return state\n },\n\n parse: function (text: string) {\n var state = this._createParserState()\n\n if (text.indexOf('\\r\\n') !== -1) {\n // This is faster than String.split with regex that splits on both\n text = text.replace(/\\r\\n/g, '\\n')\n }\n\n if (text.indexOf('\\\\\\n') !== -1) {\n // join lines separated by a line continuation character (\\)\n text = text.replace(/\\\\\\n/g, '')\n }\n\n var i, l\n var lines = text.split('\\n')\n var line = ''\n var lineFirstChar = ''\n var lineSecondChar = ''\n var lineLength = 0\n var result = []\n\n // Faster to just trim left side of the line. Use if available.\n var trimLeft = (typeof ''.trimLeft === 'function')\n\n for (i = 0, l = lines.length; i < l; i++) {\n line = lines[ i ]\n\n line = trimLeft ? line.trimLeft() : line.trim()\n\n lineLength = line.length\n\n if (lineLength === 0) continue\n\n lineFirstChar = line.charAt(0)\n\n // @todo invoke passed in handler if any\n if (lineFirstChar === '#') continue\n\n if (lineFirstChar === 'v') {\n lineSecondChar = line.charAt(1)\n\n if (lineSecondChar === ' ' && (result = this.regexp.vertex_pattern.exec(line)) !== null) {\n // 0 1 2 3\n // [\"v 1.0 2.0 3.0\", \"1.0\", \"2.0\", \"3.0\"]\n\n state.vertices.push(\n parseFloat(result[ 1 ]),\n parseFloat(result[ 2 ]),\n parseFloat(result[ 3 ])\n )\n } else if (lineSecondChar === 'n' && (result = this.regexp.normal_pattern.exec(line)) !== null) {\n // 0 1 2 3\n // [\"vn 1.0 2.0 3.0\", \"1.0\", \"2.0\", \"3.0\"]\n\n state.normals.push(\n parseFloat(result[ 1 ]),\n parseFloat(result[ 2 ]),\n parseFloat(result[ 3 ])\n )\n } else if (lineSecondChar === 't' && this.regexp.uv_pattern.exec(line) !== null) {\n\n // ignore uv line\n\n } else {\n throw new Error(\"Unexpected vertex/normal/uv line: '\" + line + \"'\")\n }\n } else if (lineFirstChar === 'f') {\n if ((result = this.regexp.face_vertex_uv_normal.exec(line)) !== null) {\n // f vertex/uv/normal vertex/uv/normal vertex/uv/normal\n // 0 1 2 3 4 5 6 7 8 9 10 11 12\n // [\"f 1/1/1 2/2/2 3/3/3\", \"1\", \"1\", \"1\", \"2\", \"2\", \"2\", \"3\", \"3\", \"3\", undefined, undefined, undefined]\n\n state.addFace(\n result[ 1 ], result[ 4 ], result[ 7 ], result[ 10 ],\n // result[ 2 ], result[ 5 ], result[ 8 ], result[ 11 ], // ignore uv part\n result[ 3 ], result[ 6 ], result[ 9 ], result[ 12 ]\n )\n } else if (this.regexp.face_vertex_uv.exec(line) !== null) {\n\n // ignore uv line\n\n } else if ((result = this.regexp.face_vertex_normal.exec(line)) !== null) {\n // f vertex//normal vertex//normal vertex//normal\n // 0 1 2 3 4 5 6 7 8\n // [\"f 1//1 2//2 3//3\", \"1\", \"1\", \"2\", \"2\", \"3\", \"3\", undefined, undefined]\n\n state.addFace(\n result[ 1 ], result[ 3 ], result[ 5 ], result[ 7 ],\n result[ 2 ], result[ 4 ], result[ 6 ], result[ 8 ]\n )\n } else if ((result = this.regexp.face_vertex.exec(line)) !== null) {\n // f vertex vertex vertex\n // 0 1 2 3 4\n // [\"f 1 2 3\", \"1\", \"2\", \"3\", undefined]\n\n state.addFace(\n result[ 1 ], result[ 2 ], result[ 3 ], result[ 4 ]\n )\n } else {\n throw new Error(\"Unexpected face line: '\" + line + \"'\")\n }\n } else if (lineFirstChar === 'l') {\n var lineParts = line.substring(1).trim().split(' ')\n var lineVertices = []\n var lineUVs = []\n\n if (line.indexOf('/') === -1) {\n lineVertices = lineParts\n } else {\n for (var li = 0, llen = lineParts.length; li < llen; li++) {\n var parts = lineParts[ li ].split('/')\n\n if (parts[ 0 ] !== '') lineVertices.push(parts[ 0 ])\n if (parts[ 1 ] !== '') lineUVs.push(parts[ 1 ])\n }\n }\n state.addLineGeometry(lineVertices, lineUVs)\n } else if ((result = this.regexp.object_pattern.exec(line)) !== null) {\n // o object_name\n // or\n // g group_name\n\n var name = result[ 0 ].substr(1).trim()\n state.startObject(name)\n\n // ignore material related lines\n // eslint-disable-next-line no-empty\n } else if (this.regexp.material_use_pattern.test(line)) {\n // eslint-disable-next-line no-empty\n } else if (this.regexp.material_library_pattern.test(line)) {\n // eslint-disable-next-line no-empty\n } else if (this.regexp.smoothing_pattern.exec(line) !== null) {\n } else {\n // Handle null terminated files without exception\n if (line === '\\0') continue\n\n throw new Error(\"Unexpected line: '\" + line + \"'\")\n }\n }\n\n var container = []\n\n for (i = 0, l = state.objects.length; i < l; i++) {\n var object = state.objects[ i ]\n var geometry = object.geometry\n\n // Skip o/g line declarations that did not follow with any faces\n if (geometry.vertices.length === 0) continue\n\n var buffergeometry = new BufferGeometry()\n\n buffergeometry.setAttribute('position', new BufferAttribute(new Float32Array(geometry.vertices), 3))\n\n if (geometry.normals.length > 0) {\n buffergeometry.setAttribute('normal', new BufferAttribute(new Float32Array(geometry.normals), 3))\n } else {\n buffergeometry.computeVertexNormals()\n }\n\n container.push(buffergeometry)\n }\n\n return container\n }\n\n}\n\nclass ObjParser extends SurfaceParser {\n get type () { return 'obj' }\n\n getLoader () {\n return new OBJLoader()\n }\n}\n\nParserRegistry.add('obj', ObjParser)\n\nexport default ObjParser\n","/**\n * @file Ply Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Geometry, Vector3, Face3, Color } from 'three'\n\nimport { ParserRegistry } from '../globals'\nimport SurfaceParser from './surface-parser'\n\n/**\n * PLYLoader\n * @class\n * @private\n * @author Wei Meng / http://about.me/menway\n *\n * @description\n * A THREE loader for PLY ASCII files (known as the Polygon File Format or the Stanford Triangle Format).\n *\n * Limitations: ASCII decoding assumes file is UTF-8.\n *\n * @example\n * var loader = new THREE.PLYLoader();\n * loader.load('./models/ply/ascii/dolphins.ply', function (geometry) {\n * scene.add( new THREE.Mesh( geometry ) );\n * } );\n *\n * // If the PLY file uses non standard property names, they can be mapped while\n * // loading. For example, the following maps the properties\n * // “diffuse_(red|green|blue)” in the file to standard color names.\n *\n * loader.setPropertyNameMapping( {\n * diffuse_red: 'red',\n * diffuse_green: 'green',\n * diffuse_blue: 'blue'\n * } );\n *\n */\n\nexport interface _PLYLoader {\n propertyNameMapping: {[k: string]: string}\n}\n\ninterface _PLYLoaderConstructor {\n (this: _PLYLoader): void\n new(): _PLYLoader\n}\n\ninterface PLYProperty {\n type: string,\n name: string,\n countType: string,\n itemType: string\n}\n\ninterface PLYElement {\n name: string,\n count: number,\n properties: PLYProperty[],\n x: number,\n y: number,\n z: number,\n red: number,\n green: number,\n blue: number,\n [k:string]: any\n}\n\ninterface PLYHeader {\n format: string,\n version: string,\n comments: string[],\n elements: PLYElement[],\n headerLength: number\n}\n\ninterface GeometryPLY extends Geometry {\n useColor: boolean\n}\n\nconst PLYLoader = (function PLYLoader (this: _PLYLoader) {\n this.propertyNameMapping = {}\n}) as _PLYLoaderConstructor\n\nPLYLoader.prototype = {\n\n constructor: PLYLoader,\n\n setPropertyNameMapping: function (mapping: {[k: string]: string}) {\n this.propertyNameMapping = mapping\n },\n\n bin2str: function (buf: ArrayBuffer) {\n var arrayBuffer = new Uint8Array(buf)\n var str = ''\n for (var i = 0; i < buf.byteLength; i++) {\n str += String.fromCharCode(arrayBuffer[ i ]) // implicitly assumes little-endian\n }\n\n return str\n },\n\n isASCII: function (data: ArrayBuffer) {\n var header = this.parseHeader(this.bin2str(data))\n\n return header.format === 'ascii'\n },\n\n parse: function (data: string|ArrayBuffer) {\n if (data instanceof ArrayBuffer) {\n return (\n this.isASCII(data)\n ? this.parseASCII(this.bin2str(data))\n : this.parseBinary(data)\n )\n } else {\n return this.parseASCII(data)\n }\n },\n\n parseHeader: function (data: string) {\n var patternHeader = /ply([\\s\\S]*)end_header\\s/\n var headerText = ''\n var headerLength = 0\n var result = patternHeader.exec(data)\n if (result !== null) {\n headerText = result[ 1 ]\n headerLength = result[ 0 ].length\n }\n\n var header: Partial = {\n comments: [],\n elements: [],\n headerLength: headerLength\n }\n\n var lines = headerText.split('\\n')\n var currentElement: PLYElement|undefined, lineType, lineValues\n\n function makePlyElementProperty (propertValues: string[], propertyNameMapping: {[k: string]: string}) {\n var property = {\n type: propertValues[ 0 ]\n } as PLYProperty\n\n if (property.type === 'list') {\n property.name = propertValues[ 3 ]\n property.countType = propertValues[ 1 ]\n property.itemType = propertValues[ 2 ]\n } else {\n property.name = propertValues[ 1 ]\n }\n\n if (property.name in propertyNameMapping) {\n property.name = propertyNameMapping[ property.name ]\n }\n\n return property\n }\n\n for (var i = 0; i < lines.length; i++) {\n var line = lines[ i ]\n line = line.trim()\n if (line === '') {\n continue\n }\n lineValues = line.split(/\\s+/)\n lineType = lineValues.shift()\n line = lineValues.join(' ')\n\n switch (lineType) {\n case 'format':\n\n header.format = lineValues[ 0 ]\n header.version = lineValues[ 1 ]\n\n break\n\n case 'comment':\n\n header.comments!.push(line)\n\n break\n\n case 'element':\n\n if (currentElement !== undefined) {\n header.elements!.push(currentElement as PLYElement)\n }\n\n currentElement = {} as PLYElement\n currentElement.name = lineValues[ 0 ]\n currentElement.count = parseInt(lineValues[ 1 ])\n currentElement.properties = []\n\n break\n\n case 'property':\n\n currentElement!.properties.push(makePlyElementProperty(lineValues, this.propertyNameMapping))\n\n break\n\n default:\n\n console.log('unhandled', lineType, lineValues)\n }\n }\n\n if (currentElement !== undefined) {\n header.elements!.push(currentElement)\n }\n\n return header\n },\n\n parseASCIINumber: function (n: string, type: string) {\n switch (type) {\n case 'char': case 'uchar': case 'short': case 'ushort': case 'int': case 'uint':\n case 'int8': case 'uint8': case 'int16': case 'uint16': case 'int32': case 'uint32':\n\n return parseInt(n)\n\n case 'float': case 'double': case 'float32': case 'float64':\n\n return parseFloat(n)\n }\n },\n\n parseASCIIElement: function (properties: PLYProperty[], line: string) {\n var values = line.split(/\\s+/)\n\n var element = {} as PLYElement\n\n for (var i = 0; i < properties.length; i++) {\n if (properties[ i ].type === 'list') {\n var list = []\n var n = this.parseASCIINumber(values.shift(), properties[ i ].countType)\n\n for (var j = 0; j < n; j++) {\n list.push(this.parseASCIINumber(values.shift(), properties[ i ].itemType))\n }\n\n element[ properties[ i ].name ] = list\n } else {\n element[ properties[ i ].name ] = this.parseASCIINumber(values.shift(), properties[ i ].type)\n }\n }\n\n return element\n },\n\n parseASCII: function (data: string) {\n // PLY ascii format specification, as per http://en.wikipedia.org/wiki/PLY_(file_format)\n\n var geometry = new Geometry() as GeometryPLY\n\n var result\n\n var header = this.parseHeader(data)\n\n var patternBody = /end_header\\s([\\s\\S]*)$/\n var body = ''\n if ((result = patternBody.exec(data)) !== null) {\n body = result[ 1 ]\n }\n\n var lines = body.split('\\n')\n var currentElement = 0\n var currentElementCount = 0\n geometry.useColor = false\n\n for (var i = 0; i < lines.length; i++) {\n var line = lines[ i ]\n line = line.trim()\n if (line === '') {\n continue\n }\n\n if (currentElementCount >= header.elements[ currentElement ].count) {\n currentElement++\n currentElementCount = 0\n }\n\n var element = this.parseASCIIElement(header.elements[ currentElement ].properties, line)\n\n this.handleElement(geometry, header.elements[ currentElement ].name, element)\n\n currentElementCount++\n }\n\n return this.postProcess(geometry)\n },\n\n postProcess: function (geometry: GeometryPLY) {\n if (geometry.useColor) {\n for (var i = 0; i < geometry.faces.length; i++) {\n geometry.faces[ i ].vertexColors = [\n geometry.colors[ geometry.faces[ i ].a ],\n geometry.colors[ geometry.faces[ i ].b ],\n geometry.colors[ geometry.faces[ i ].c ]\n ]\n }\n\n geometry.elementsNeedUpdate = true\n }\n\n geometry.computeBoundingSphere()\n\n return geometry\n },\n\n handleElement: function (geometry: GeometryPLY, elementName: string, element: PLYElement) {\n if (elementName === 'vertex') {\n geometry.vertices.push(\n new Vector3(element.x, element.y, element.z)\n )\n\n if ('red' in element && 'green' in element && 'blue' in element) {\n geometry.useColor = true\n\n var color = new Color()\n color.setRGB(element.red / 255.0, element.green / 255.0, element.blue / 255.0)\n geometry.colors.push(color)\n }\n } else if (elementName === 'face') {\n var vertexIndices = element.vertex_indices\n\n if (vertexIndices.length === 3) {\n geometry.faces.push(\n new Face3(vertexIndices[ 0 ], vertexIndices[ 1 ], vertexIndices[ 2 ])\n )\n } else if (vertexIndices.length === 4) {\n geometry.faces.push(\n new Face3(vertexIndices[ 0 ], vertexIndices[ 1 ], vertexIndices[ 3 ]),\n new Face3(vertexIndices[ 1 ], vertexIndices[ 2 ], vertexIndices[ 3 ])\n )\n }\n }\n },\n\n binaryRead: function (dataview: DataView, at: number, type: string, littleEndian: boolean) {\n switch (type) {\n // corespondences for non-specific length types here match rply:\n case 'int8': case 'char': return [ dataview.getInt8(at), 1 ]\n\n case 'uint8': case 'uchar': return [ dataview.getUint8(at), 1 ]\n\n case 'int16': case 'short': return [ dataview.getInt16(at, littleEndian), 2 ]\n\n case 'uint16': case 'ushort': return [ dataview.getUint16(at, littleEndian), 2 ]\n\n case 'int32': case 'int': return [ dataview.getInt32(at, littleEndian), 4 ]\n\n case 'uint32': case 'uint': return [ dataview.getUint32(at, littleEndian), 4 ]\n\n case 'float32': case 'float': return [ dataview.getFloat32(at, littleEndian), 4 ]\n\n case 'float64': case 'double': return [ dataview.getFloat64(at, littleEndian), 8 ]\n }\n },\n\n binaryReadElement: function (dataview: DataView, at: number, properties: PLYProperty[], littleEndian: boolean) {\n var element = {} as PLYElement\n var result\n var read = 0\n\n for (var i = 0; i < properties.length; i++) {\n if (properties[ i ].type === 'list') {\n var list = []\n\n result = this.binaryRead(dataview, at + read, properties[ i ].countType, littleEndian)\n var n = result[ 0 ]\n read += result[ 1 ]\n\n for (var j = 0; j < n; j++) {\n result = this.binaryRead(dataview, at + read, properties[ i ].itemType, littleEndian)\n list.push(result[ 0 ])\n read += result[ 1 ]\n }\n\n element[ properties[ i ].name ] = list\n } else {\n result = this.binaryRead(dataview, at + read, properties[ i ].type, littleEndian)\n element[ properties[ i ].name ] = result[ 0 ]\n read += result[ 1 ]\n }\n }\n\n return [ element, read ]\n },\n\n parseBinary: function (data: ArrayBuffer) {\n var geometry = new Geometry()\n\n var header = this.parseHeader(this.bin2str(data))\n var littleEndian = (header.format === 'binary_little_endian')\n var body = new DataView(data, header.headerLength)\n var result\n var loc = 0\n\n for (var currentElement = 0; currentElement < header.elements.length; currentElement++) {\n for (var currentElementCount = 0; currentElementCount < header.elements[ currentElement ].count; currentElementCount++) {\n result = this.binaryReadElement(body, loc, header.elements[ currentElement ].properties, littleEndian)\n loc += result[ 1 ]\n var element = result[ 0 ]\n\n this.handleElement(geometry, header.elements[ currentElement ].name, element)\n }\n }\n\n return this.postProcess(geometry)\n }\n\n}\n\nclass PlyParser extends SurfaceParser {\n get type () { return 'ply' }\n\n getLoader () {\n return new PLYLoader()\n }\n}\n\nParserRegistry.add('ply', PlyParser)\n\nexport default PlyParser\n","/**\n * @file Csv Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { ParserRegistry } from '../globals'\nimport Parser, { ParserParameters } from './parser'\nimport Streamer from '../streamer/streamer';\n\nexport interface CsvParserParameters extends ParserParameters {\n delimiter: string\n comment: string\n columnNames: boolean\n}\n/**\n * CSV parser\n */\nclass CsvParser extends Parser {\n /**\n * [constructor description]\n * @param {Streamer} streamer - the streamer object\n * @param {Object} params - parameter object\n * @param {Char} params.delimiter - delimiter character\n * @param {Char} params.comment - comment character\n * @param {Boolean} params.columnNames - use first data line as column names\n */\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.delimiter = defaults(p.delimiter, ',')\n this.comment = defaults(p.comment, '#')\n this.columnNames = defaults(p.columnNames, false)\n\n this.table = {\n name: this.name,\n path: this.path,\n columnNames: [],\n data: []\n }\n }\n\n get type () { return 'csv' }\n get __objName () { return 'table' }\n\n _parse () {\n const data = this.table.data\n const reDelimiter = new RegExp('\\\\s*' + this.delimiter + '\\\\s*')\n\n let j = 0\n\n this.streamer.eachChunkOfLines(chunk => {\n const n = chunk.length\n\n for (let i = 0; i < n; ++i) {\n const line = chunk[ i ].trim()\n if (line.startsWith(this.comment)) continue\n const values = line.split(reDelimiter)\n\n if (j === 0) {\n this.table.columnNames = values\n } else if (line) {\n data.push(values)\n }\n ++j\n }\n })\n }\n}\n\nParserRegistry.add('csv', CsvParser)\n\nexport default CsvParser\n","/**\n * @file Json Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Parser, { ParserParameters } from './parser'\nimport Streamer from '../streamer/streamer';\n\nexport interface JsonParserParameters extends ParserParameters {\n string: boolean\n}\n\nclass JsonParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.string = defaults(p.string, false)\n\n this.json = {\n name: this.name,\n path: this.path,\n data: {}\n }\n }\n\n get type () { return 'json' }\n get __objName () { return 'json' }\n get isJson () { return true }\n\n _parse () {\n if (this.streamer.isBinary() || this.string) {\n this.json.data = JSON.parse(this.streamer.asText())\n } else {\n this.json.data = this.streamer.data\n }\n }\n}\n\nParserRegistry.add('json', JsonParser)\n\nexport default JsonParser\n","/**\n * @file Msgpack Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport Parser, { ParserParameters } from './parser'\n\nimport { decodeMsgpack } from '../../lib/mmtf.es6'\nimport Streamer from '../streamer/streamer';\n\nclass MsgpackParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.msgpack = {\n name: this.name,\n path: this.path,\n data: undefined\n }\n }\n\n get type () { return 'msgpack' }\n get __objName () { return 'msgpack' }\n get isBinary () { return true }\n\n _parse () {\n if (Debug) Log.time('MsgpackParser._parse ' + this.name)\n\n this.msgpack.data = decodeMsgpack(this.streamer.data)\n\n if (Debug) Log.timeEnd('MsgpackParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('msgpack', MsgpackParser)\n\nexport default MsgpackParser\n","/**\n * @file Netcdf Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport Parser, { ParserParameters } from './parser'\nimport NetcdfReader from '../utils/netcdf-reader'\nimport Streamer from '../streamer/streamer';\n\nclass NetcdfParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.netcdf = {\n name: this.name,\n path: this.path,\n data: undefined\n }\n }\n\n get type () { return 'netcdf' }\n get __objName () { return 'netcdf' }\n get isBinary () { return true }\n\n _parse () {\n if (Debug) Log.time('NetcdfParser._parse ' + this.name)\n\n this.netcdf.data = new NetcdfReader(this.streamer.data)\n\n if (Debug) Log.timeEnd('NetcdfParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('netcdf', NetcdfParser)\n\nexport default NetcdfParser\n","/**\n * @file Text Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport Parser, { ParserParameters } from './parser'\nimport Streamer from '../streamer/streamer';\n\nclass TextParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n super(streamer, params)\n\n this.text = {\n\n name: this.name,\n path: this.path,\n data: ''\n\n }\n }\n\n get type () { return 'text' }\n get __objName () { return 'text' }\n\n _parse () {\n this.text.data = this.streamer.asText()\n }\n}\n\nParserRegistry.add('txt', TextParser)\nParserRegistry.add('text', TextParser)\n\nexport default TextParser\n","/**\n * @file Parse Xml\n * @author Alexander Rose \n * @private\n */\n\n// https://github.com/segmentio/xml-parser\n// MIT license\n\nexport type XMLNodeAttributes = { [k: string]: any }\nexport interface XMLNode {\n name?: string\n content?: string\n attributes: XMLNodeAttributes\n children?: XMLNode[]\n}\n\nconst reStrip = /^['\"]|['\"]$/g\nconst reTag = /^<([\\w-:.]+)\\s*/\nconst reContent = /^([^<]*)/\nconst reAttr = /([\\w:-]+)\\s*=\\s*(\"[^\"]*\"|'[^']*'|\\w+)\\s*/\n\nfunction strip (val: string) {\n return val.replace(reStrip, '')\n}\n\nexport function parseXml (xml: string) {\n // trim and strip comments\n xml = xml.trim().replace(//g, '')\n\n return document()\n\n function document () {\n return {\n declaration: declaration(),\n root: tag()\n }\n }\n\n function declaration () {\n const m = match(/^<\\?xml\\s*/)\n if (!m) return\n\n // tag\n const node: XMLNode = {\n attributes: {}\n }\n\n // attributes\n while (!(eos() || is('?>'))) {\n const attr = attribute()\n if (!attr) return node\n node.attributes[attr.name] = attr.value\n }\n match(/\\?>\\s*/)\n return node\n }\n\n function tag () {\n const m = match(reTag)\n if (!m) return\n\n // name\n const node: XMLNode = {\n name: m[1],\n attributes: {},\n children: []\n }\n\n // attributes\n while (!(eos() || is('>') || is('?>') || is('/>'))) {\n const attr = attribute()\n if (!attr) return node\n node.attributes[attr.name] = attr.value\n }\n\n // self closing tag\n if (match(/^\\s*\\/>\\s*/)) {\n return node\n }\n match(/\\??>\\s*/)\n\n // content\n node.content = content()\n\n // children\n let child\n while ((child = tag())) {\n node.children!.push(child)\n }\n\n // closing\n match(/^<\\/[\\w-:.]+>\\s*/)\n return node\n }\n\n function content () {\n const m = match(reContent)\n if (m) return m[1]\n return ''\n }\n\n function attribute () {\n const m = match(reAttr)\n if (!m) return\n return { name: m[1], value: strip(m[2]) }\n }\n\n function match (re: RegExp) {\n const m = xml.match(re)\n if (!m) return\n xml = xml.slice(m[0].length)\n return m\n }\n\n function eos () {\n return xml.length === 0\n }\n\n function is (prefix: string) {\n return xml.indexOf(prefix) === 0\n }\n}\n","/**\n * @file Xml Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { defaults } from '../utils'\n// @ts-ignore: unused import XMLNode required for declaration only\nimport { parseXml, XMLNode } from '../utils/parse-xml'\nimport Parser, { ParserParameters } from './parser'\nimport Streamer from '../streamer/streamer';\n\nexport interface XmlParserParameters extends ParserParameters {\n useDomParser: boolean\n}\n\nclass XmlParser extends Parser {\n xml: {\n name: string\n path: string\n data: any\n }\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.useDomParser = defaults(p.useDomParser, false)\n\n this.xml = {\n name: this.name,\n path: this.path,\n data: {}\n }\n }\n\n get type () { return 'xml' }\n get __objName () { return 'xml' }\n get isXml () { return true }\n\n __xmlParser (xml: string) {\n return parseXml(xml)\n }\n\n __domParser (xml: string) {\n const domParser = new (window as any).DOMParser() as DOMParser\n return domParser.parseFromString(xml, 'text/xml')\n }\n\n _parse () {\n if (Debug) Log.time('XmlParser._parse ' + this.name)\n\n if (this.useDomParser) {\n if (this.streamer.data instanceof Document) { //TS conversion: stripped the window prefix from window.Document\n this.xml.data = this.streamer.data\n } else {\n this.xml.data = this.__domParser(this.streamer.asText())\n }\n } else {\n this.xml.data = this.__xmlParser(this.streamer.asText())\n }\n\n if (Debug) Log.timeEnd('XmlParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('xml', XmlParser)\n\nexport default XmlParser\n","/**\n * @file Validation\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Color } from 'three'\n\nimport { Debug, Log } from '../globals'\nimport { defaults } from '../utils'\nimport { ClashPicker } from '../utils/picker'\nimport { uniformArray3 } from '../math/array-utils'\nimport { guessElement } from '../structure/structure-utils'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Structure from '../structure/structure'\n\nfunction getNamedItem(a: NamedNodeMap, name: string) {\n const item = a.getNamedItem(name)\n return item !== null ? item.value : ''\n}\n\nfunction getSele (a: NamedNodeMap, atomname?: string, useAltcode = false) {\n const icode = getNamedItem(a, 'icode').trim()\n const chain = getNamedItem(a, 'chain').trim()\n const altcode = getNamedItem(a, 'altcode')\n let sele = getNamedItem(a, 'resnum')\n if (icode) sele += '^' + icode\n if (chain) sele += ':' + chain\n if (atomname) sele += '.' + atomname\n if (useAltcode && altcode.trim()) sele += '%' + altcode\n sele += '/' + (parseInt(getNamedItem(a, 'model')) - 1)\n return sele\n}\n\nfunction getResSele (a: NamedNodeMap) {\n const chain = getNamedItem(a, 'chain').trim()\n const rescode = getNamedItem(a, 'rescode')\n const resnum = getNamedItem(a, 'resnum')\n let sele = `[${rescode}]${resnum}`\n if (chain) sele += `:${chain}`\n return sele\n}\n\nfunction setBitDict (dict: { [k: string]: number }, key: string, bit: number) {\n if (dict[ key ] === undefined) {\n dict[ key ] = bit\n } else {\n dict[ key ] |= bit\n }\n}\n\nfunction hasAttrValue (attr: Attr|null, value: string) {\n return attr !== null && attr.value === value\n}\n\nfunction getAtomSele (ap: AtomProxy) {\n const icode = ap.inscode\n const chain = ap.chainname\n const atomname = ap.atomname\n const altcode = ap.altloc\n let sele = ap.resno + ''\n if (icode) sele += '^' + icode\n if (chain) sele += ':' + chain\n if (atomname) sele += '.' + atomname\n if (altcode) sele += '%' + altcode\n sele += '/' + ap.modelIndex\n return sele\n}\n\nfunction getProblemCount (clashDict: { [k: string]: { [k: string]: string } }, g: Element, ga: NamedNodeMap) {\n let geoProblemCount = 0\n\n const clashes = g.getElementsByTagName('clash')\n for (let j = 0, jl = clashes.length; j < jl; ++j) {\n if (clashDict[ getNamedItem(clashes[ j ].attributes, 'cid') ]) {\n geoProblemCount += 1\n break\n }\n }\n\n const angleOutliers = g.getElementsByTagName('angle-outlier')\n if (angleOutliers.length > 0) {\n geoProblemCount += 1\n }\n\n const bondOutliers = g.getElementsByTagName('bond-outlier')\n if (bondOutliers.length > 0) {\n geoProblemCount += 1\n }\n\n const planeOutliers = g.getElementsByTagName('plane-outlier')\n if (planeOutliers.length > 0) {\n geoProblemCount += 1\n }\n\n if (hasAttrValue(ga.getNamedItem('rota'), 'OUTLIER')) {\n geoProblemCount += 1\n }\n\n if (hasAttrValue(ga.getNamedItem('rama'), 'OUTLIER')) {\n geoProblemCount += 1\n }\n\n if (hasAttrValue(ga.getNamedItem('RNApucker'), 'outlier')) {\n geoProblemCount += 1\n }\n\n return geoProblemCount\n}\n\nclass Validation {\n rsrzDict: { [k: string]: number } = {}\n rsccDict: { [k: string]: number } = {}\n /**\n * Random Coil Index (RCI) - evaluates the proximity of residue structural\n * and dynamic properties to the properties of flexible random coil regions\n * from NMR chemical shifts.\n *\n * Mark V. Berjanskii and David S. Wishart (2005)\n * A Simple Method To Predict Protein Flexibility Using Secondary Chemical Shifts\n * J. Am. Chem. Soc., 2005, 127 (43), pp 14970–14971\n * http://pubs.acs.org/doi/abs/10.1021/ja054842f\n *\n * Mark V. Berjanskii and David S. Wishart (2008)\n * Application of the random coil index to studying protein flexibility.\n * J Biomol NMR. 2008 Jan;40(1):31-48. Epub 2007 Nov 6.\n * http://www.springerlink.com/content/2966482w10306126/\n */\n rciDict: { [k: string]: number } = {}\n clashDict: { [k: string]: { [k: string]: string } } = {}\n clashArray: { [k: string]: string }[] = []\n geoDict: { [k: string]: number } = {}\n geoAtomDict: { [k: string]: { [k: string]: number } } = {}\n atomDict: { [k: string]: boolean|number } = {}\n clashSele = 'NONE'\n\n constructor (readonly name: string, readonly path: string) {}\n\n get type () { return 'validation' }\n\n fromXml (xml: XMLDocument) {\n if (Debug) Log.time('Validation.fromXml')\n\n const rsrzDict = this.rsrzDict\n const rsccDict = this.rsccDict\n const rciDict = this.rciDict\n const clashDict = this.clashDict\n const clashArray = this.clashArray\n const geoDict = this.geoDict\n const geoAtomDict = this.geoAtomDict\n const atomDict = this.atomDict\n\n const entries = xml.getElementsByTagName('Entry')\n if (entries.length === 1) {\n const chemicalShiftLists = entries[0].getElementsByTagName('chemical_shift_list')\n if (chemicalShiftLists.length === 1) {\n const randomCoilIndices = chemicalShiftLists[0].getElementsByTagName('random_coil_index')\n for (let j = 0, jl = randomCoilIndices.length; j < jl; ++j) {\n const rcia = randomCoilIndices[ j ].attributes\n const sele = getResSele(rcia)\n rciDict[ sele ] = parseFloat(getNamedItem(rcia, 'value'))\n }\n }\n }\n\n const groups = xml.getElementsByTagName('ModelledSubgroup')\n\n const _clashDict: { [k: string]: { [k: string]: string } } = {}\n const clashList: string[] = []\n\n if (Debug) Log.time('Validation.fromXml#clashDict')\n\n for (let i = 0, il = groups.length; i < il; ++i) {\n const g = groups[ i ]\n const ga = g.attributes\n\n const sele = getSele(ga)\n if (ga.getNamedItem('rsrz') !== null) {\n rsrzDict[ sele ] = parseFloat(getNamedItem(ga, 'rsrz'))\n }\n if (ga.getNamedItem('rscc') !== null) {\n rsccDict[ sele ] = parseFloat(getNamedItem(ga, 'rscc'))\n }\n const seleAttr = xml.createAttribute('sele')\n seleAttr.value = sele\n ga.setNamedItem(seleAttr)\n\n const clashes = g.getElementsByTagName('clash')\n\n for (let j = 0, jl = clashes.length; j < jl; ++j) {\n const ca = clashes[ j ].attributes\n const atom = getNamedItem(ca, 'atom')\n\n if (guessElement(atom) !== 'H') {\n const cid = getNamedItem(ca, 'cid')\n const atomSele = getSele(ga, atom, true)\n atomDict[ atomSele ] = true\n\n if (_clashDict[ cid ] === undefined) {\n _clashDict[ cid ] = {\n sele1: atomSele,\n res1: sele\n }\n } else {\n const c = _clashDict[ cid ]\n if (c.res1 !== sele) {\n c.sele2 = atomSele\n c.res2 = sele\n clashList.push(c.res1, sele)\n clashDict[ cid ] = c\n clashArray.push(c)\n }\n }\n }\n }\n }\n\n if (Debug) Log.timeEnd('Validation.fromXml#clashDict')\n\n for (let i = 0, il = groups.length; i < il; ++i) {\n const g = groups[ i ]\n const ga = g.attributes\n\n const sele = getNamedItem(ga, 'sele')\n const isPolymer = getNamedItem(ga, 'seq') !== '.'\n\n if (isPolymer) {\n const geoProblemCount = getProblemCount(clashDict, g, ga)\n if (geoProblemCount > 0) {\n geoDict[ sele ] = geoProblemCount\n }\n } else {\n const clashes = g.getElementsByTagName('clash')\n const mogBondOutliers = g.getElementsByTagName('mog-bond-outlier')\n const mogAngleOutliers = g.getElementsByTagName('mog-angle-outlier')\n\n if (mogBondOutliers.length > 0 || mogAngleOutliers.length > 0 || clashes.length > 0) {\n const atomDict = {}\n geoAtomDict[ sele ] = atomDict\n\n for (let j = 0, jl = clashes.length; j < jl; ++j) {\n const ca = clashes[ j ].attributes\n if (clashDict[ getNamedItem(ca, 'cid') ]) {\n setBitDict(atomDict, getNamedItem(ca, 'atom'), 1)\n }\n }\n\n for (let j = 0, jl = mogBondOutliers.length; j < jl; ++j) {\n const mbo = mogBondOutliers[ j ].attributes\n getNamedItem(mbo, 'atoms').split(',').forEach(function (atomname) {\n setBitDict(atomDict, atomname, 2)\n })\n }\n\n for (let j = 0, jl = mogAngleOutliers.length; j < jl; ++j) {\n const mao = mogAngleOutliers[ j ].attributes\n getNamedItem(mao, 'atoms').split(',').forEach(function (atomname) {\n setBitDict(atomDict, atomname, 4)\n })\n }\n }\n }\n }\n\n this.clashSele = clashList.length ? clashList.join(' OR ') : 'NONE'\n\n if (Debug) Log.timeEnd('Validation.fromXml')\n }\n\n getClashData (params: { color: number|string|Color, structure: Structure }) {\n if (Debug) Log.time('Validation.getClashData')\n\n const p = params || {}\n\n const s = p.structure\n const atomSet = s.atomSet! // TODO\n const c = new Color(defaults(p.color, '#f0027f'))\n\n const ap1 = s.getAtomProxy()\n const ap2 = s.getAtomProxy()\n const vDir = new Vector3()\n const vPos1 = new Vector3()\n const vPos2 = new Vector3()\n\n const clashArray = this.clashArray\n const n = clashArray.length\n\n const position1 = new Float32Array(n * 3)\n const position2 = new Float32Array(n * 3)\n const color = uniformArray3(n, c.r, c.g, c.b) as Float32Array\n const radius = new Float32Array(n)\n const picking = new Float32Array(n)\n\n if (Debug) Log.time('Validation.getClashData#atomDict')\n\n const atomDict = this.atomDict\n\n s.eachAtom(function (ap) {\n const sele = getAtomSele(ap)\n if (atomDict[ sele ] === true) {\n atomDict[ sele ] = ap.index\n }\n })\n\n if (Debug) Log.timeEnd('Validation.getClashData#atomDict')\n\n let i = 0\n\n clashArray.forEach(function (c, idx) {\n ap1.index = atomDict[ c.sele1 ] as number // TODO\n ap2.index = atomDict[ c.sele2 ] as number // TODO\n\n if (ap1.index === undefined || ap2.index === undefined ||\n !atomSet.isSet(ap1.index, ap2.index)) return\n\n vDir.subVectors(ap2 as any, ap1 as any).setLength(ap1.vdw) // TODO\n vPos1.copy(ap1 as any).add(vDir) // TODO\n\n vDir.subVectors(ap1 as any, ap2 as any).setLength(ap2.vdw) // TODO\n vPos2.copy(ap2 as any).add(vDir) // TODO\n\n const dHalf = ap1.distanceTo(ap2) / 2\n const r1 = Math.sqrt(ap1.vdw * ap1.vdw - dHalf * dHalf)\n const r2 = Math.sqrt(ap2.vdw * ap2.vdw - dHalf * dHalf)\n\n vPos1.toArray(position1 as any, i * 3) // TODO\n vPos2.toArray(position2 as any, i * 3)\n radius[ i ] = (r1 + r2) / 2\n picking[ i ] = idx\n\n ++i\n })\n\n if (Debug) Log.timeEnd('Validation.getClashData')\n\n return {\n position1: position1.subarray(0, i * 3),\n position2: position2.subarray(0, i * 3),\n color: color.subarray(0, i * 3),\n color2: color.subarray(0, i * 3),\n radius: radius.subarray(0, i),\n picking: new ClashPicker(picking.subarray(0, i), this, s)\n }\n }\n}\n\nexport default Validation\n","\n// https://github.com/nodeca/pako\n// MIT License, Copyright (c) 2014 by Vitaly Puzrin\n\n\n// 'use strict';\n\n\n// var TYPED_OK = (typeof Uint8Array !== 'undefined') &&\n// (typeof Uint16Array !== 'undefined') &&\n// (typeof Int32Array !== 'undefined');\n\n\nfunction assign(obj /*from1, from2, from3, ...*/) {\n var sources = Array.prototype.slice.call(arguments, 1);\n while (sources.length) {\n var source = sources.shift();\n if (!source) { continue; }\n\n if (typeof source !== 'object') {\n throw new TypeError(source + 'must be non-object');\n }\n\n for (var p in source) {\n if (source.hasOwnProperty(p)) {\n obj[p] = source[p];\n }\n }\n }\n\n return obj;\n}\n\n\n// reduce buffer size, avoiding mem copy\nfunction shrinkBuf(buf, size) {\n if (buf.length === size) { return buf; }\n if (buf.subarray) { return buf.subarray(0, size); }\n buf.length = size;\n return buf;\n}\n\n\nfunction arraySet(dest, src, src_offs, len, dest_offs) {\n if (src.subarray && dest.subarray) {\n dest.set(src.subarray(src_offs, src_offs + len), dest_offs);\n return;\n }\n // Fallback to ordinary array\n for (var i = 0; i < len; i++) {\n dest[dest_offs + i] = src[src_offs + i];\n }\n}\n\n// Join array of chunks to single array.\nfunction flattenChunks(chunks) {\n var i, l, len, pos, chunk, result;\n\n // calculate data length\n len = 0;\n for (i = 0, l = chunks.length; i < l; i++) {\n len += chunks[i].length;\n }\n\n // join chunks\n result = new Uint8Array(len);\n pos = 0;\n for (i = 0, l = chunks.length; i < l; i++) {\n chunk = chunks[i];\n result.set(chunk, pos);\n pos += chunk.length;\n }\n\n return result;\n}\n\n// 'use strict';\n\n// Note: adler32 takes 12% for level 0 and 2% for level 6.\n// It doesn't worth to make additional optimizationa as in original.\n// Small size is preferable.\n\nfunction adler32(adler, buf, len, pos) {\n var s1 = (adler & 0xffff) |0,\n s2 = ((adler >>> 16) & 0xffff) |0,\n n = 0;\n\n while (len !== 0) {\n // Set limit ~ twice less than 5552, to keep\n // s2 in 31-bits, because we force signed ints.\n // in other case %= will fail.\n n = len > 2000 ? 2000 : len;\n len -= n;\n\n do {\n s1 = (s1 + buf[pos++]) |0;\n s2 = (s2 + s1) |0;\n } while (--n);\n\n s1 %= 65521;\n s2 %= 65521;\n }\n\n return (s1 | (s2 << 16)) |0;\n}\n\n// 'use strict';\n\n// Note: we can't get significant speed boost here.\n// So write code to minimize size - no pregenerated tables\n// and array tools dependencies.\n\n\n// Use ordinary array, since untyped makes no boost here\nfunction makeTable() {\n var c, table = [];\n\n for (var n = 0; n < 256; n++) {\n c = n;\n for (var k = 0; k < 8; k++) {\n c = ((c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));\n }\n table[n] = c;\n }\n\n return table;\n}\n\n// Create table on load. Just 255 signed longs. Not a problem.\nvar crcTable = makeTable();\n\n\nfunction crc32(crc, buf, len, pos) {\n var t = crcTable,\n end = pos + len;\n\n crc ^= -1;\n\n for (var i = pos; i < end; i++) {\n crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF];\n }\n\n return (crc ^ (-1)); // >>> 0;\n}\n\n// 'use strict';\n\n// See state defs from inflate.js\nvar BAD$1 = 30; /* got a data error -- remain here until reset */\nvar TYPE$1 = 12; /* i: waiting for type bits, including last-flag bit */\n\n/*\n Decode literal, length, and distance codes and write out the resulting\n literal and match bytes until either not enough input or output is\n available, an end-of-block is encountered, or a data error is encountered.\n When large enough input and output buffers are supplied to inflate(), for\n example, a 16K input buffer and a 64K output buffer, more than 95% of the\n inflate execution time is spent in this routine.\n\n Entry assumptions:\n\n state.mode === LEN\n strm.avail_in >= 6\n strm.avail_out >= 258\n start >= strm.avail_out\n state.bits < 8\n\n On return, state.mode is one of:\n\n LEN -- ran out of enough output space or enough available input\n TYPE -- reached end of block code, inflate() to interpret next block\n BAD -- error in block data\n\n Notes:\n\n - The maximum input bits used by a length/distance pair is 15 bits for the\n length code, 5 bits for the length extra, 15 bits for the distance code,\n and 13 bits for the distance extra. This totals 48 bits, or six bytes.\n Therefore if strm.avail_in >= 6, then there is enough input to avoid\n checking for available input while decoding.\n\n - The maximum bytes that a single length/distance pair can output is 258\n bytes, which is the maximum length that can be coded. inflate_fast()\n requires strm.avail_out >= 258 for each loop to avoid checking for\n output space.\n */\n// module.exports =\nfunction inflate_fast(strm, start) {\n var state;\n var _in; /* local strm.input */\n var last; /* have enough input while in < last */\n var _out; /* local strm.output */\n var beg; /* inflate()'s initial strm.output */\n var end; /* while out < end, enough space available */\n//#ifdef INFLATE_STRICT\n var dmax; /* maximum distance from zlib header */\n//#endif\n var wsize; /* window size or zero if not using window */\n var whave; /* valid bytes in the window */\n var wnext; /* window write index */\n // Use `s_window` instead `window`, avoid conflict with instrumentation tools\n var s_window; /* allocated sliding window, if wsize != 0 */\n var hold; /* local strm.hold */\n var bits; /* local strm.bits */\n var lcode; /* local strm.lencode */\n var dcode; /* local strm.distcode */\n var lmask; /* mask for first level of length codes */\n var dmask; /* mask for first level of distance codes */\n var here; /* retrieved table entry */\n var op; /* code bits, operation, extra bits, or */\n /* window position, window bytes to copy */\n var len; /* match length, unused bytes */\n var dist; /* match distance */\n var from; /* where to copy match from */\n var from_source;\n\n\n var input, output; // JS specific, because we have no pointers\n\n /* copy state to local variables */\n state = strm.state;\n //here = state.here;\n _in = strm.next_in;\n input = strm.input;\n last = _in + (strm.avail_in - 5);\n _out = strm.next_out;\n output = strm.output;\n beg = _out - (start - strm.avail_out);\n end = _out + (strm.avail_out - 257);\n//#ifdef INFLATE_STRICT\n dmax = state.dmax;\n//#endif\n wsize = state.wsize;\n whave = state.whave;\n wnext = state.wnext;\n s_window = state.window;\n hold = state.hold;\n bits = state.bits;\n lcode = state.lencode;\n dcode = state.distcode;\n lmask = (1 << state.lenbits) - 1;\n dmask = (1 << state.distbits) - 1;\n\n\n /* decode literals and length/distances until end-of-block or not enough\n input data or output space */\n\n top:\n do {\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n\n here = lcode[hold & lmask];\n\n dolen:\n for (;;) { // Goto emulation\n op = here >>> 24/*here.bits*/;\n hold >>>= op;\n bits -= op;\n op = (here >>> 16) & 0xff/*here.op*/;\n if (op === 0) { /* literal */\n //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n // \"inflate: literal '%c'\\n\" :\n // \"inflate: literal 0x%02x\\n\", here.val));\n output[_out++] = here & 0xffff/*here.val*/;\n }\n else if (op & 16) { /* length base */\n len = here & 0xffff/*here.val*/;\n op &= 15; /* number of extra bits */\n if (op) {\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n len += hold & ((1 << op) - 1);\n hold >>>= op;\n bits -= op;\n }\n //Tracevv((stderr, \"inflate: length %u\\n\", len));\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n here = dcode[hold & dmask];\n\n dodist:\n for (;;) { // goto emulation\n op = here >>> 24/*here.bits*/;\n hold >>>= op;\n bits -= op;\n op = (here >>> 16) & 0xff/*here.op*/;\n\n if (op & 16) { /* distance base */\n dist = here & 0xffff/*here.val*/;\n op &= 15; /* number of extra bits */\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n }\n dist += hold & ((1 << op) - 1);\n//#ifdef INFLATE_STRICT\n if (dist > dmax) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD$1;\n break top;\n }\n//#endif\n hold >>>= op;\n bits -= op;\n //Tracevv((stderr, \"inflate: distance %u\\n\", dist));\n op = _out - beg; /* max distance in output */\n if (dist > op) { /* see if copy from window */\n op = dist - op; /* distance back in window */\n if (op > whave) {\n if (state.sane) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD$1;\n break top;\n }\n\n// (!) This block is disabled in zlib defailts,\n// don't enable it for binary compatibility\n//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n// if (len <= op - whave) {\n// do {\n// output[_out++] = 0;\n// } while (--len);\n// continue top;\n// }\n// len -= op - whave;\n// do {\n// output[_out++] = 0;\n// } while (--op > whave);\n// if (op === 0) {\n// from = _out - dist;\n// do {\n// output[_out++] = output[from++];\n// } while (--len);\n// continue top;\n// }\n//#endif\n }\n from = 0; // window index\n from_source = s_window;\n if (wnext === 0) { /* very common case */\n from += wsize - op;\n if (op < len) { /* some from window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n else if (wnext < op) { /* wrap around window */\n from += wsize + wnext - op;\n op -= wnext;\n if (op < len) { /* some from end of window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = 0;\n if (wnext < len) { /* some from start of window */\n op = wnext;\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n }\n else { /* contiguous in window */\n from += wnext - op;\n if (op < len) { /* some from window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n while (len > 2) {\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n len -= 3;\n }\n if (len) {\n output[_out++] = from_source[from++];\n if (len > 1) {\n output[_out++] = from_source[from++];\n }\n }\n }\n else {\n from = _out - dist; /* copy direct from output */\n do { /* minimum length is three */\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n len -= 3;\n } while (len > 2);\n if (len) {\n output[_out++] = output[from++];\n if (len > 1) {\n output[_out++] = output[from++];\n }\n }\n }\n }\n else if ((op & 64) === 0) { /* 2nd level distance code */\n here = dcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n continue dodist;\n }\n else {\n strm.msg = 'invalid distance code';\n state.mode = BAD$1;\n break top;\n }\n\n break; // need to emulate goto via \"continue\"\n }\n }\n else if ((op & 64) === 0) { /* 2nd level length code */\n here = lcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n continue dolen;\n }\n else if (op & 32) { /* end-of-block */\n //Tracevv((stderr, \"inflate: end of block\\n\"));\n state.mode = TYPE$1;\n break top;\n }\n else {\n strm.msg = 'invalid literal/length code';\n state.mode = BAD$1;\n break top;\n }\n\n break; // need to emulate goto via \"continue\"\n }\n } while (_in < last && _out < end);\n\n /* return unused bytes (on entry, bits < 8, so in won't go too far back) */\n len = bits >> 3;\n _in -= len;\n bits -= len << 3;\n hold &= (1 << bits) - 1;\n\n /* update state and return */\n strm.next_in = _in;\n strm.next_out = _out;\n strm.avail_in = (_in < last ? 5 + (last - _in) : 5 - (_in - last));\n strm.avail_out = (_out < end ? 257 + (end - _out) : 257 - (_out - end));\n state.hold = hold;\n state.bits = bits;\n return;\n};\n\n// 'use strict';\n\n\n// var utils = require('../utils/common');\n\nvar MAXBITS = 15;\nvar ENOUGH_LENS$1 = 852;\nvar ENOUGH_DISTS$1 = 592;\n//var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);\n\nvar CODES$1 = 0;\nvar LENS$1 = 1;\nvar DISTS$1 = 2;\n\nvar lbase = [ /* Length codes 257..285 base */\n 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,\n 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0\n];\n\nvar lext = [ /* Length codes 257..285 extra */\n 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,\n 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78\n];\n\nvar dbase = [ /* Distance codes 0..29 base */\n 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,\n 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,\n 8193, 12289, 16385, 24577, 0, 0\n];\n\nvar dext = [ /* Distance codes 0..29 extra */\n 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,\n 23, 23, 24, 24, 25, 25, 26, 26, 27, 27,\n 28, 28, 29, 29, 64, 64\n];\n\n// module.exports =\nfunction inflate_table(type, lens, lens_index, codes, table, table_index, work, opts)\n{\n var bits = opts.bits;\n //here = opts.here; /* table entry for duplication */\n\n var len = 0; /* a code's length in bits */\n var sym = 0; /* index of code symbols */\n var min = 0, max = 0; /* minimum and maximum code lengths */\n var root = 0; /* number of index bits for root table */\n var curr = 0; /* number of index bits for current table */\n var drop = 0; /* code bits to drop for sub-table */\n var left = 0; /* number of prefix codes available */\n var used = 0; /* code entries in table used */\n var huff = 0; /* Huffman code */\n var incr; /* for incrementing code, index */\n var fill; /* index for replicating entries */\n var low; /* low bits for current root entry */\n var mask; /* mask for low root bits */\n var next; /* next available space in table */\n var base = null; /* base value table to use */\n var base_index = 0;\n// var shoextra; /* extra bits table to use */\n var end; /* use base and extra for symbol > end */\n var count = new Uint16Array(MAXBITS + 1); //[MAXBITS+1]; /* number of codes of each length */\n var offs = new Uint16Array(MAXBITS + 1); //[MAXBITS+1]; /* offsets in table for each length */\n var extra = null;\n var extra_index = 0;\n\n var here_bits, here_op, here_val;\n\n /*\n Process a set of code lengths to create a canonical Huffman code. The\n code lengths are lens[0..codes-1]. Each length corresponds to the\n symbols 0..codes-1. The Huffman code is generated by first sorting the\n symbols by length from short to long, and retaining the symbol order\n for codes with equal lengths. Then the code starts with all zero bits\n for the first code of the shortest length, and the codes are integer\n increments for the same length, and zeros are appended as the length\n increases. For the deflate format, these bits are stored backwards\n from their more natural integer increment ordering, and so when the\n decoding tables are built in the large loop below, the integer codes\n are incremented backwards.\n\n This routine assumes, but does not check, that all of the entries in\n lens[] are in the range 0..MAXBITS. The caller must assure this.\n 1..MAXBITS is interpreted as that code length. zero means that that\n symbol does not occur in this code.\n\n The codes are sorted by computing a count of codes for each length,\n creating from that a table of starting indices for each length in the\n sorted table, and then entering the symbols in order in the sorted\n table. The sorted table is work[], with that space being provided by\n the caller.\n\n The length counts are used for other purposes as well, i.e. finding\n the minimum and maximum length codes, determining if there are any\n codes at all, checking for a valid set of lengths, and looking ahead\n at length counts to determine sub-table sizes when building the\n decoding tables.\n */\n\n /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */\n for (len = 0; len <= MAXBITS; len++) {\n count[len] = 0;\n }\n for (sym = 0; sym < codes; sym++) {\n count[lens[lens_index + sym]]++;\n }\n\n /* bound code lengths, force root to be within code lengths */\n root = bits;\n for (max = MAXBITS; max >= 1; max--) {\n if (count[max] !== 0) { break; }\n }\n if (root > max) {\n root = max;\n }\n if (max === 0) { /* no symbols to code at all */\n //table.op[opts.table_index] = 64; //here.op = (var char)64; /* invalid code marker */\n //table.bits[opts.table_index] = 1; //here.bits = (var char)1;\n //table.val[opts.table_index++] = 0; //here.val = (var short)0;\n table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n\n //table.op[opts.table_index] = 64;\n //table.bits[opts.table_index] = 1;\n //table.val[opts.table_index++] = 0;\n table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n opts.bits = 1;\n return 0; /* no symbols, but wait for decoding to report error */\n }\n for (min = 1; min < max; min++) {\n if (count[min] !== 0) { break; }\n }\n if (root < min) {\n root = min;\n }\n\n /* check for an over-subscribed or incomplete set of lengths */\n left = 1;\n for (len = 1; len <= MAXBITS; len++) {\n left <<= 1;\n left -= count[len];\n if (left < 0) {\n return -1;\n } /* over-subscribed */\n }\n if (left > 0 && (type === CODES$1 || max !== 1)) {\n return -1; /* incomplete set */\n }\n\n /* generate offsets into symbol table for each length for sorting */\n offs[1] = 0;\n for (len = 1; len < MAXBITS; len++) {\n offs[len + 1] = offs[len] + count[len];\n }\n\n /* sort symbols by length, by symbol order within each length */\n for (sym = 0; sym < codes; sym++) {\n if (lens[lens_index + sym] !== 0) {\n work[offs[lens[lens_index + sym]]++] = sym;\n }\n }\n\n /*\n Create and fill in decoding tables. In this loop, the table being\n filled is at next and has curr index bits. The code being used is huff\n with length len. That code is converted to an index by dropping drop\n bits off of the bottom. For codes where len is less than drop + curr,\n those top drop + curr - len bits are incremented through all values to\n fill the table with replicated entries.\n\n root is the number of index bits for the root table. When len exceeds\n root, sub-tables are created pointed to by the root entry with an index\n of the low root bits of huff. This is saved in low to check for when a\n new sub-table should be started. drop is zero when the root table is\n being filled, and drop is root when sub-tables are being filled.\n\n When a new sub-table is needed, it is necessary to look ahead in the\n code lengths to determine what size sub-table is needed. The length\n counts are used for this, and so count[] is decremented as codes are\n entered in the tables.\n\n used keeps track of how many table entries have been allocated from the\n provided *table space. It is checked for LENS and DIST tables against\n the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in\n the initial root table size constants. See the comments in inftrees.h\n for more information.\n\n sym increments through all symbols, and the loop terminates when\n all codes of length max, i.e. all codes, have been processed. This\n routine permits incomplete codes, so another loop after this one fills\n in the rest of the decoding tables with invalid code markers.\n */\n\n /* set up for code type */\n // poor man optimization - use if-else instead of switch,\n // to avoid deopts in old v8\n if (type === CODES$1) {\n base = extra = work; /* dummy value--not used */\n end = 19;\n\n } else if (type === LENS$1) {\n base = lbase;\n base_index -= 257;\n extra = lext;\n extra_index -= 257;\n end = 256;\n\n } else { /* DISTS */\n base = dbase;\n extra = dext;\n end = -1;\n }\n\n /* initialize opts for loop */\n huff = 0; /* starting code */\n sym = 0; /* starting code symbol */\n len = min; /* starting code length */\n next = table_index; /* current table to fill in */\n curr = root; /* current table index bits */\n drop = 0; /* current bits to drop from code for index */\n low = -1; /* trigger new sub-table when len > root */\n used = 1 << root; /* use root table entries */\n mask = used - 1; /* mask for comparing low */\n\n /* check available table space */\n if ((type === LENS$1 && used > ENOUGH_LENS$1) ||\n (type === DISTS$1 && used > ENOUGH_DISTS$1)) {\n return 1;\n }\n\n var i = 0;\n /* process all codes and make table entries */\n for (;;) {\n i++;\n /* create table entry */\n here_bits = len - drop;\n if (work[sym] < end) {\n here_op = 0;\n here_val = work[sym];\n }\n else if (work[sym] > end) {\n here_op = extra[extra_index + work[sym]];\n here_val = base[base_index + work[sym]];\n }\n else {\n here_op = 32 + 64; /* end of block */\n here_val = 0;\n }\n\n /* replicate for those indices with low len bits equal to huff */\n incr = 1 << (len - drop);\n fill = 1 << curr;\n min = fill; /* save offset to next table */\n do {\n fill -= incr;\n table[next + (huff >> drop) + fill] = (here_bits << 24) | (here_op << 16) | here_val |0;\n } while (fill !== 0);\n\n /* backwards increment the len-bit code huff */\n incr = 1 << (len - 1);\n while (huff & incr) {\n incr >>= 1;\n }\n if (incr !== 0) {\n huff &= incr - 1;\n huff += incr;\n } else {\n huff = 0;\n }\n\n /* go to next symbol, update count, len */\n sym++;\n if (--count[len] === 0) {\n if (len === max) { break; }\n len = lens[lens_index + work[sym]];\n }\n\n /* create new sub-table if needed */\n if (len > root && (huff & mask) !== low) {\n /* if first time, transition to sub-tables */\n if (drop === 0) {\n drop = root;\n }\n\n /* increment past last table */\n next += min; /* here min is 1 << curr */\n\n /* determine length of next table */\n curr = len - drop;\n left = 1 << curr;\n while (curr + drop < max) {\n left -= count[curr + drop];\n if (left <= 0) { break; }\n curr++;\n left <<= 1;\n }\n\n /* check for enough space */\n used += 1 << curr;\n if ((type === LENS$1 && used > ENOUGH_LENS$1) ||\n (type === DISTS$1 && used > ENOUGH_DISTS$1)) {\n return 1;\n }\n\n /* point entry in root table to sub-table */\n low = huff & mask;\n /*table.op[low] = curr;\n table.bits[low] = root;\n table.val[low] = next - opts.table_index;*/\n table[low] = (root << 24) | (curr << 16) | (next - table_index) |0;\n }\n }\n\n /* fill in remaining table entry if code is incomplete (guaranteed to have\n at most one remaining entry, since if the code is incomplete, the\n maximum code length that was allowed to get this far is one bit) */\n if (huff !== 0) {\n //table.op[next + huff] = 64; /* invalid code marker */\n //table.bits[next + huff] = len - drop;\n //table.val[next + huff] = 0;\n table[next + huff] = ((len - drop) << 24) | (64 << 16) |0;\n }\n\n /* set return parameters */\n //opts.table_index += used;\n opts.bits = root;\n return 0;\n};\n\n// 'use strict';\n\n\n// var utils = require('../utils/common');\n// var adler32 = require('./adler32');\n// var crc32 = require('./crc32');\n// var inflate_fast = require('./inffast');\n// var inflate_table = require('./inftrees');\n\nvar CODES = 0;\nvar LENS = 1;\nvar DISTS = 2;\n\n/* Public constants ==========================================================*/\n/* ===========================================================================*/\n\n\n/* Allowed flush values; see deflate() and inflate() below for details */\n//var Z_NO_FLUSH = 0;\n//var Z_PARTIAL_FLUSH = 1;\n//var Z_SYNC_FLUSH = 2;\n//var Z_FULL_FLUSH = 3;\nvar Z_FINISH = 4;\nvar Z_BLOCK = 5;\nvar Z_TREES = 6;\n\n\n/* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\nvar Z_OK = 0;\nvar Z_STREAM_END = 1;\nvar Z_NEED_DICT = 2;\n//var Z_ERRNO = -1;\nvar Z_STREAM_ERROR = -2;\nvar Z_DATA_ERROR = -3;\nvar Z_MEM_ERROR = -4;\nvar Z_BUF_ERROR = -5;\n//var Z_VERSION_ERROR = -6;\n\n/* The deflate compression method */\nvar Z_DEFLATED = 8;\n\n\n/* STATES ====================================================================*/\n/* ===========================================================================*/\n\n\nvar HEAD = 1; /* i: waiting for magic header */\nvar FLAGS = 2; /* i: waiting for method and flags (gzip) */\nvar TIME = 3; /* i: waiting for modification time (gzip) */\nvar OS = 4; /* i: waiting for extra flags and operating system (gzip) */\nvar EXLEN = 5; /* i: waiting for extra length (gzip) */\nvar EXTRA = 6; /* i: waiting for extra bytes (gzip) */\nvar NAME = 7; /* i: waiting for end of file name (gzip) */\nvar COMMENT = 8; /* i: waiting for end of comment (gzip) */\nvar HCRC = 9; /* i: waiting for header crc (gzip) */\nvar DICTID = 10; /* i: waiting for dictionary check value */\nvar DICT = 11; /* waiting for inflateSetDictionary() call */\nvar TYPE = 12; /* i: waiting for type bits, including last-flag bit */\nvar TYPEDO = 13; /* i: same, but skip check to exit inflate on new block */\nvar STORED = 14; /* i: waiting for stored size (length and complement) */\nvar COPY_ = 15; /* i/o: same as COPY below, but only first time in */\nvar COPY = 16; /* i/o: waiting for input or output to copy stored block */\nvar TABLE = 17; /* i: waiting for dynamic block table lengths */\nvar LENLENS = 18; /* i: waiting for code length code lengths */\nvar CODELENS = 19; /* i: waiting for length/lit and distance code lengths */\nvar LEN_ = 20; /* i: same as LEN below, but only first time in */\nvar LEN = 21; /* i: waiting for length/lit/eob code */\nvar LENEXT = 22; /* i: waiting for length extra bits */\nvar DIST = 23; /* i: waiting for distance code */\nvar DISTEXT = 24; /* i: waiting for distance extra bits */\nvar MATCH = 25; /* o: waiting for output space to copy string */\nvar LIT = 26; /* o: waiting for output space to write literal */\nvar CHECK = 27; /* i: waiting for 32-bit check value */\nvar LENGTH = 28; /* i: waiting for 32-bit length (gzip) */\nvar DONE = 29; /* finished check, done -- remain here until reset */\nvar BAD = 30; /* got a data error -- remain here until reset */\nvar MEM = 31; /* got an inflate() memory error -- remain here until reset */\nvar SYNC = 32; /* looking for synchronization bytes to restart inflate() */\n\n/* ===========================================================================*/\n\n\n\nvar ENOUGH_LENS = 852;\nvar ENOUGH_DISTS = 592;\nfunction zswap32(q) {\n return (((q >>> 24) & 0xff) +\n ((q >>> 8) & 0xff00) +\n ((q & 0xff00) << 8) +\n ((q & 0xff) << 24));\n}\n\n\nfunction InflateState() {\n this.mode = 0; /* current inflate mode */\n this.last = false; /* true if processing last block */\n this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip */\n this.havedict = false; /* true if dictionary provided */\n this.flags = 0; /* gzip header method and flags (0 if zlib) */\n this.dmax = 0; /* zlib header max distance (INFLATE_STRICT) */\n this.check = 0; /* protected copy of check value */\n this.total = 0; /* protected copy of output count */\n // TODO: may be {}\n this.head = null; /* where to save gzip header information */\n\n /* sliding window */\n this.wbits = 0; /* log base 2 of requested window size */\n this.wsize = 0; /* window size or zero if not using window */\n this.whave = 0; /* valid bytes in the window */\n this.wnext = 0; /* window write index */\n this.window = null; /* allocated sliding window, if needed */\n\n /* bit accumulator */\n this.hold = 0; /* input bit accumulator */\n this.bits = 0; /* number of bits in \"in\" */\n\n /* for string and stored block copying */\n this.length = 0; /* literal or length of data to copy */\n this.offset = 0; /* distance back to copy string from */\n\n /* for table and code decoding */\n this.extra = 0; /* extra bits needed */\n\n /* fixed and dynamic code tables */\n this.lencode = null; /* starting table for length/literal codes */\n this.distcode = null; /* starting table for distance codes */\n this.lenbits = 0; /* index bits for lencode */\n this.distbits = 0; /* index bits for distcode */\n\n /* dynamic table building */\n this.ncode = 0; /* number of code length code lengths */\n this.nlen = 0; /* number of length code lengths */\n this.ndist = 0; /* number of distance code lengths */\n this.have = 0; /* number of code lengths in lens[] */\n this.next = null; /* next available space in codes[] */\n\n this.lens = new Uint16Array(320); /* temporary storage for code lengths */\n this.work = new Uint16Array(288); /* work area for code table building */\n\n /*\n because we don't have pointers in js, we use lencode and distcode directly\n as buffers so we don't need codes\n */\n //this.codes = new Buf32(ENOUGH); /* space for code tables */\n this.lendyn = null; /* dynamic table for length/literal codes (JS specific) */\n this.distdyn = null; /* dynamic table for distance codes (JS specific) */\n this.sane = 0; /* if false, allow invalid distance too far */\n this.back = 0; /* bits back of last unprocessed length/lit */\n this.was = 0; /* initial length of match */\n}\n\nfunction inflateResetKeep(strm) {\n var state;\n\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n strm.total_in = strm.total_out = state.total = 0;\n strm.msg = ''; /*Z_NULL*/\n if (state.wrap) { /* to support ill-conceived Java test suite */\n strm.adler = state.wrap & 1;\n }\n state.mode = HEAD;\n state.last = 0;\n state.havedict = 0;\n state.dmax = 32768;\n state.head = null/*Z_NULL*/;\n state.hold = 0;\n state.bits = 0;\n //state.lencode = state.distcode = state.next = state.codes;\n state.lencode = state.lendyn = new Int32Array(ENOUGH_LENS);\n state.distcode = state.distdyn = new Int32Array(ENOUGH_DISTS);\n\n state.sane = 1;\n state.back = -1;\n //Tracev((stderr, \"inflate: reset\\n\"));\n return Z_OK;\n}\n\nfunction inflateReset(strm) {\n var state;\n\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n state.wsize = 0;\n state.whave = 0;\n state.wnext = 0;\n return inflateResetKeep(strm);\n\n}\n\nfunction inflateReset2(strm, windowBits) {\n var wrap;\n var state;\n\n /* get the state */\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n\n /* extract wrap request from windowBits parameter */\n if (windowBits < 0) {\n wrap = 0;\n windowBits = -windowBits;\n }\n else {\n wrap = (windowBits >> 4) + 1;\n if (windowBits < 48) {\n windowBits &= 15;\n }\n }\n\n /* set number of window bits, free window if different */\n if (windowBits && (windowBits < 8 || windowBits > 15)) {\n return Z_STREAM_ERROR;\n }\n if (state.window !== null && state.wbits !== windowBits) {\n state.window = null;\n }\n\n /* update state and reset the rest of it */\n state.wrap = wrap;\n state.wbits = windowBits;\n return inflateReset(strm);\n}\n\nfunction inflateInit2(strm, windowBits) {\n var ret;\n var state;\n\n if (!strm) { return Z_STREAM_ERROR; }\n //strm.msg = Z_NULL; /* in case we return an error */\n\n state = new InflateState();\n\n //if (state === Z_NULL) return Z_MEM_ERROR;\n //Tracev((stderr, \"inflate: allocated\\n\"));\n strm.state = state;\n state.window = null/*Z_NULL*/;\n ret = inflateReset2(strm, windowBits);\n if (ret !== Z_OK) {\n strm.state = null/*Z_NULL*/;\n }\n return ret;\n}\n\n/*\n Return state with length and distance decoding tables and index sizes set to\n fixed code decoding. Normally this returns fixed tables from inffixed.h.\n If BUILDFIXED is defined, then instead this routine builds the tables the\n first time it's called, and returns those tables the first time and\n thereafter. This reduces the size of the code by about 2K bytes, in\n exchange for a little execution time. However, BUILDFIXED should not be\n used for threaded applications, since the rewriting of the tables and virgin\n may not be thread-safe.\n */\nvar virgin = true;\n\nvar lenfix;\nvar distfix;\n// We have no pointers in JS, so keep tables separate\n\nfunction fixedtables(state) {\n /* build fixed huffman tables if first call (may not be thread safe) */\n if (virgin) {\n var sym;\n\n lenfix = new Int32Array(512);\n distfix = new Int32Array(32);\n\n /* literal/length table */\n sym = 0;\n while (sym < 144) { state.lens[sym++] = 8; }\n while (sym < 256) { state.lens[sym++] = 9; }\n while (sym < 280) { state.lens[sym++] = 7; }\n while (sym < 288) { state.lens[sym++] = 8; }\n\n inflate_table(LENS, state.lens, 0, 288, lenfix, 0, state.work, { bits: 9 });\n\n /* distance table */\n sym = 0;\n while (sym < 32) { state.lens[sym++] = 5; }\n\n inflate_table(DISTS, state.lens, 0, 32, distfix, 0, state.work, { bits: 5 });\n\n /* do this just once */\n virgin = false;\n }\n\n state.lencode = lenfix;\n state.lenbits = 9;\n state.distcode = distfix;\n state.distbits = 5;\n}\n\n\n/*\n Update the window with the last wsize (normally 32K) bytes written before\n returning. If window does not exist yet, create it. This is only called\n when a window is already in use, or when output has been written during this\n inflate call, but the end of the deflate stream has not been reached yet.\n It is also called to create a window for dictionary data when a dictionary\n is loaded.\n\n Providing output buffers larger than 32K to inflate() should provide a speed\n advantage, since only the last 32K of output is copied to the sliding window\n upon return from inflate(), and since all distances after the first 32K of\n output will fall in the output data, making match copies simpler and faster.\n The advantage may be dependent on the size of the processor's data caches.\n */\nfunction updatewindow(strm, src, end, copy) {\n var dist;\n var state = strm.state;\n\n /* if it hasn't been done already, allocate space for the window */\n if (state.window === null) {\n state.wsize = 1 << state.wbits;\n state.wnext = 0;\n state.whave = 0;\n\n state.window = new Uint8Array(state.wsize);\n }\n\n /* copy state->wsize or less output bytes into the circular window */\n if (copy >= state.wsize) {\n arraySet(state.window, src, end - state.wsize, state.wsize, 0);\n state.wnext = 0;\n state.whave = state.wsize;\n }\n else {\n dist = state.wsize - state.wnext;\n if (dist > copy) {\n dist = copy;\n }\n //zmemcpy(state->window + state->wnext, end - copy, dist);\n arraySet(state.window, src, end - copy, dist, state.wnext);\n copy -= dist;\n if (copy) {\n //zmemcpy(state->window, end - copy, copy);\n arraySet(state.window, src, end - copy, copy, 0);\n state.wnext = copy;\n state.whave = state.wsize;\n }\n else {\n state.wnext += dist;\n if (state.wnext === state.wsize) { state.wnext = 0; }\n if (state.whave < state.wsize) { state.whave += dist; }\n }\n }\n return 0;\n}\n\nfunction inflate(strm, flush) {\n var state;\n var input, output; // input/output buffers\n var next; /* next input INDEX */\n var put; /* next output INDEX */\n var have, left; /* available input and output */\n var hold; /* bit buffer */\n var bits; /* bits in bit buffer */\n var _in, _out; /* save starting available input and output */\n var copy; /* number of stored or match bytes to copy */\n var from; /* where to copy match bytes from */\n var from_source;\n var here = 0; /* current decoding table entry */\n var here_bits, here_op, here_val; // paked \"here\" denormalized (JS specific)\n //var last; /* parent table entry */\n var last_bits, last_op, last_val; // paked \"last\" denormalized (JS specific)\n var len; /* length to copy for repeats, bits to drop */\n var ret; /* return code */\n var hbuf = new Uint8Array(4); /* buffer for gzip header crc calculation */\n var opts;\n\n var n; // temporary var for NEED_BITS\n\n var order = /* permutation of code lengths */\n [ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ];\n\n\n if (!strm || !strm.state || !strm.output ||\n (!strm.input && strm.avail_in !== 0)) {\n return Z_STREAM_ERROR;\n }\n\n state = strm.state;\n if (state.mode === TYPE) { state.mode = TYPEDO; } /* skip check */\n\n\n //--- LOAD() ---\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n //---\n\n _in = have;\n _out = left;\n ret = Z_OK;\n\n inf_leave: // goto emulation\n for (;;) {\n switch (state.mode) {\n case HEAD:\n if (state.wrap === 0) {\n state.mode = TYPEDO;\n break;\n }\n //=== NEEDBITS(16);\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if ((state.wrap & 2) && hold === 0x8b1f) { /* gzip header */\n state.check = 0/*crc32(0L, Z_NULL, 0)*/;\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = FLAGS;\n break;\n }\n state.flags = 0; /* expect zlib header */\n if (state.head) {\n state.head.done = false;\n }\n if (!(state.wrap & 1) || /* check if zlib header allowed */\n (((hold & 0xff)/*BITS(8)*/ << 8) + (hold >> 8)) % 31) {\n strm.msg = 'incorrect header check';\n state.mode = BAD;\n break;\n }\n if ((hold & 0x0f)/*BITS(4)*/ !== Z_DEFLATED) {\n strm.msg = 'unknown compression method';\n state.mode = BAD;\n break;\n }\n //--- DROPBITS(4) ---//\n hold >>>= 4;\n bits -= 4;\n //---//\n len = (hold & 0x0f)/*BITS(4)*/ + 8;\n if (state.wbits === 0) {\n state.wbits = len;\n }\n else if (len > state.wbits) {\n strm.msg = 'invalid window size';\n state.mode = BAD;\n break;\n }\n state.dmax = 1 << len;\n //Tracev((stderr, \"inflate: zlib header ok\\n\"));\n strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n state.mode = hold & 0x200 ? DICTID : TYPE;\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n break;\n case FLAGS:\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.flags = hold;\n if ((state.flags & 0xff) !== Z_DEFLATED) {\n strm.msg = 'unknown compression method';\n state.mode = BAD;\n break;\n }\n if (state.flags & 0xe000) {\n strm.msg = 'unknown header flags set';\n state.mode = BAD;\n break;\n }\n if (state.head) {\n state.head.text = ((hold >> 8) & 1);\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = TIME;\n /* falls through */\n case TIME:\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (state.head) {\n state.head.time = hold;\n }\n if (state.flags & 0x0200) {\n //=== CRC4(state.check, hold)\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n hbuf[2] = (hold >>> 16) & 0xff;\n hbuf[3] = (hold >>> 24) & 0xff;\n state.check = crc32(state.check, hbuf, 4, 0);\n //===\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = OS;\n /* falls through */\n case OS:\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (state.head) {\n state.head.xflags = (hold & 0xff);\n state.head.os = (hold >> 8);\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = EXLEN;\n /* falls through */\n case EXLEN:\n if (state.flags & 0x0400) {\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.length = hold;\n if (state.head) {\n state.head.extra_len = hold;\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n }\n else if (state.head) {\n state.head.extra = null/*Z_NULL*/;\n }\n state.mode = EXTRA;\n /* falls through */\n case EXTRA:\n if (state.flags & 0x0400) {\n copy = state.length;\n if (copy > have) { copy = have; }\n if (copy) {\n if (state.head) {\n len = state.head.extra_len - state.length;\n if (!state.head.extra) {\n // Use untyped array for more conveniend processing later\n state.head.extra = new Array(state.head.extra_len);\n }\n arraySet(\n state.head.extra,\n input,\n next,\n // extra field is limited to 65536 bytes\n // - no need for additional size check\n copy,\n /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/\n len\n );\n //zmemcpy(state.head.extra + len, next,\n // len + copy > state.head.extra_max ?\n // state.head.extra_max - len : copy);\n }\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n state.length -= copy;\n }\n if (state.length) { break inf_leave; }\n }\n state.length = 0;\n state.mode = NAME;\n /* falls through */\n case NAME:\n if (state.flags & 0x0800) {\n if (have === 0) { break inf_leave; }\n copy = 0;\n do {\n // TODO: 2 or 1 bytes?\n len = input[next + copy++];\n /* use constant limit because in js we should not preallocate memory */\n if (state.head && len &&\n (state.length < 65536 /*state.head.name_max*/)) {\n state.head.name += String.fromCharCode(len);\n }\n } while (len && copy < have);\n\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) { break inf_leave; }\n }\n else if (state.head) {\n state.head.name = null;\n }\n state.length = 0;\n state.mode = COMMENT;\n /* falls through */\n case COMMENT:\n if (state.flags & 0x1000) {\n if (have === 0) { break inf_leave; }\n copy = 0;\n do {\n len = input[next + copy++];\n /* use constant limit because in js we should not preallocate memory */\n if (state.head && len &&\n (state.length < 65536 /*state.head.comm_max*/)) {\n state.head.comment += String.fromCharCode(len);\n }\n } while (len && copy < have);\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) { break inf_leave; }\n }\n else if (state.head) {\n state.head.comment = null;\n }\n state.mode = HCRC;\n /* falls through */\n case HCRC:\n if (state.flags & 0x0200) {\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (hold !== (state.check & 0xffff)) {\n strm.msg = 'header crc mismatch';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n }\n if (state.head) {\n state.head.hcrc = ((state.flags >> 9) & 1);\n state.head.done = true;\n }\n strm.adler = state.check = 0;\n state.mode = TYPE;\n break;\n case DICTID:\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n strm.adler = state.check = zswap32(hold);\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = DICT;\n /* falls through */\n case DICT:\n if (state.havedict === 0) {\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n return Z_NEED_DICT;\n }\n strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n state.mode = TYPE;\n /* falls through */\n case TYPE:\n if (flush === Z_BLOCK || flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case TYPEDO:\n if (state.last) {\n //--- BYTEBITS() ---//\n hold >>>= bits & 7;\n bits -= bits & 7;\n //---//\n state.mode = CHECK;\n break;\n }\n //=== NEEDBITS(3); */\n while (bits < 3) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.last = (hold & 0x01)/*BITS(1)*/;\n //--- DROPBITS(1) ---//\n hold >>>= 1;\n bits -= 1;\n //---//\n\n switch ((hold & 0x03)/*BITS(2)*/) {\n case 0: /* stored block */\n //Tracev((stderr, \"inflate: stored block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = STORED;\n break;\n case 1: /* fixed block */\n fixedtables(state);\n //Tracev((stderr, \"inflate: fixed codes block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = LEN_; /* decode codes */\n if (flush === Z_TREES) {\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n break inf_leave;\n }\n break;\n case 2: /* dynamic block */\n //Tracev((stderr, \"inflate: dynamic codes block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = TABLE;\n break;\n case 3:\n strm.msg = 'invalid block type';\n state.mode = BAD;\n }\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n break;\n case STORED:\n //--- BYTEBITS() ---// /* go to byte boundary */\n hold >>>= bits & 7;\n bits -= bits & 7;\n //---//\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if ((hold & 0xffff) !== ((hold >>> 16) ^ 0xffff)) {\n strm.msg = 'invalid stored block lengths';\n state.mode = BAD;\n break;\n }\n state.length = hold & 0xffff;\n //Tracev((stderr, \"inflate: stored length %u\\n\",\n // state.length));\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = COPY_;\n if (flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case COPY_:\n state.mode = COPY;\n /* falls through */\n case COPY:\n copy = state.length;\n if (copy) {\n if (copy > have) { copy = have; }\n if (copy > left) { copy = left; }\n if (copy === 0) { break inf_leave; }\n //--- zmemcpy(put, next, copy); ---\n arraySet(output, input, next, copy, put);\n //---//\n have -= copy;\n next += copy;\n left -= copy;\n put += copy;\n state.length -= copy;\n break;\n }\n //Tracev((stderr, \"inflate: stored end\\n\"));\n state.mode = TYPE;\n break;\n case TABLE:\n //=== NEEDBITS(14); */\n while (bits < 14) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.nlen = (hold & 0x1f)/*BITS(5)*/ + 257;\n //--- DROPBITS(5) ---//\n hold >>>= 5;\n bits -= 5;\n //---//\n state.ndist = (hold & 0x1f)/*BITS(5)*/ + 1;\n //--- DROPBITS(5) ---//\n hold >>>= 5;\n bits -= 5;\n //---//\n state.ncode = (hold & 0x0f)/*BITS(4)*/ + 4;\n //--- DROPBITS(4) ---//\n hold >>>= 4;\n bits -= 4;\n //---//\n//#ifndef PKZIP_BUG_WORKAROUND\n if (state.nlen > 286 || state.ndist > 30) {\n strm.msg = 'too many length or distance symbols';\n state.mode = BAD;\n break;\n }\n//#endif\n //Tracev((stderr, \"inflate: table sizes ok\\n\"));\n state.have = 0;\n state.mode = LENLENS;\n /* falls through */\n case LENLENS:\n while (state.have < state.ncode) {\n //=== NEEDBITS(3);\n while (bits < 3) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.lens[order[state.have++]] = (hold & 0x07);//BITS(3);\n //--- DROPBITS(3) ---//\n hold >>>= 3;\n bits -= 3;\n //---//\n }\n while (state.have < 19) {\n state.lens[order[state.have++]] = 0;\n }\n // We have separate tables & no pointers. 2 commented lines below not needed.\n //state.next = state.codes;\n //state.lencode = state.next;\n // Switch to use dynamic table\n state.lencode = state.lendyn;\n state.lenbits = 7;\n\n opts = { bits: state.lenbits };\n ret = inflate_table(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts);\n state.lenbits = opts.bits;\n\n if (ret) {\n strm.msg = 'invalid code lengths set';\n state.mode = BAD;\n break;\n }\n //Tracev((stderr, \"inflate: code lengths ok\\n\"));\n state.have = 0;\n state.mode = CODELENS;\n /* falls through */\n case CODELENS:\n while (state.have < state.nlen + state.ndist) {\n for (;;) {\n here = state.lencode[hold & ((1 << state.lenbits) - 1)];/*BITS(state.lenbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if (here_val < 16) {\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.lens[state.have++] = here_val;\n }\n else {\n if (here_val === 16) {\n //=== NEEDBITS(here.bits + 2);\n n = here_bits + 2;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n if (state.have === 0) {\n strm.msg = 'invalid bit length repeat';\n state.mode = BAD;\n break;\n }\n len = state.lens[state.have - 1];\n copy = 3 + (hold & 0x03);//BITS(2);\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n }\n else if (here_val === 17) {\n //=== NEEDBITS(here.bits + 3);\n n = here_bits + 3;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n len = 0;\n copy = 3 + (hold & 0x07);//BITS(3);\n //--- DROPBITS(3) ---//\n hold >>>= 3;\n bits -= 3;\n //---//\n }\n else {\n //=== NEEDBITS(here.bits + 7);\n n = here_bits + 7;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n len = 0;\n copy = 11 + (hold & 0x7f);//BITS(7);\n //--- DROPBITS(7) ---//\n hold >>>= 7;\n bits -= 7;\n //---//\n }\n if (state.have + copy > state.nlen + state.ndist) {\n strm.msg = 'invalid bit length repeat';\n state.mode = BAD;\n break;\n }\n while (copy--) {\n state.lens[state.have++] = len;\n }\n }\n }\n\n /* handle error breaks in while */\n if (state.mode === BAD) { break; }\n\n /* check for end-of-block code (better have one) */\n if (state.lens[256] === 0) {\n strm.msg = 'invalid code -- missing end-of-block';\n state.mode = BAD;\n break;\n }\n\n /* build code tables -- note: do not change the lenbits or distbits\n values here (9 and 6) without reading the comments in inftrees.h\n concerning the ENOUGH constants, which depend on those values */\n state.lenbits = 9;\n\n opts = { bits: state.lenbits };\n ret = inflate_table(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts);\n // We have separate tables & no pointers. 2 commented lines below not needed.\n // state.next_index = opts.table_index;\n state.lenbits = opts.bits;\n // state.lencode = state.next;\n\n if (ret) {\n strm.msg = 'invalid literal/lengths set';\n state.mode = BAD;\n break;\n }\n\n state.distbits = 6;\n //state.distcode.copy(state.codes);\n // Switch to use dynamic table\n state.distcode = state.distdyn;\n opts = { bits: state.distbits };\n ret = inflate_table(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts);\n // We have separate tables & no pointers. 2 commented lines below not needed.\n // state.next_index = opts.table_index;\n state.distbits = opts.bits;\n // state.distcode = state.next;\n\n if (ret) {\n strm.msg = 'invalid distances set';\n state.mode = BAD;\n break;\n }\n //Tracev((stderr, 'inflate: codes ok\\n'));\n state.mode = LEN_;\n if (flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case LEN_:\n state.mode = LEN;\n /* falls through */\n case LEN:\n if (have >= 6 && left >= 258) {\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n inflate_fast(strm, _out);\n //--- LOAD() ---\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n //---\n\n if (state.mode === TYPE) {\n state.back = -1;\n }\n break;\n }\n state.back = 0;\n for (;;) {\n here = state.lencode[hold & ((1 << state.lenbits) - 1)]; /*BITS(state.lenbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if (here_bits <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if (here_op && (here_op & 0xf0) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (;;) {\n here = state.lencode[last_val +\n ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((last_bits + here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n //--- DROPBITS(last.bits) ---//\n hold >>>= last_bits;\n bits -= last_bits;\n //---//\n state.back += last_bits;\n }\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.back += here_bits;\n state.length = here_val;\n if (here_op === 0) {\n //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n // \"inflate: literal '%c'\\n\" :\n // \"inflate: literal 0x%02x\\n\", here.val));\n state.mode = LIT;\n break;\n }\n if (here_op & 32) {\n //Tracevv((stderr, \"inflate: end of block\\n\"));\n state.back = -1;\n state.mode = TYPE;\n break;\n }\n if (here_op & 64) {\n strm.msg = 'invalid literal/length code';\n state.mode = BAD;\n break;\n }\n state.extra = here_op & 15;\n state.mode = LENEXT;\n /* falls through */\n case LENEXT:\n if (state.extra) {\n //=== NEEDBITS(state.extra);\n n = state.extra;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.length += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n //--- DROPBITS(state.extra) ---//\n hold >>>= state.extra;\n bits -= state.extra;\n //---//\n state.back += state.extra;\n }\n //Tracevv((stderr, \"inflate: length %u\\n\", state.length));\n state.was = state.length;\n state.mode = DIST;\n /* falls through */\n case DIST:\n for (;;) {\n here = state.distcode[hold & ((1 << state.distbits) - 1)];/*BITS(state.distbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if ((here_op & 0xf0) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (;;) {\n here = state.distcode[last_val +\n ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((last_bits + here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n //--- DROPBITS(last.bits) ---//\n hold >>>= last_bits;\n bits -= last_bits;\n //---//\n state.back += last_bits;\n }\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.back += here_bits;\n if (here_op & 64) {\n strm.msg = 'invalid distance code';\n state.mode = BAD;\n break;\n }\n state.offset = here_val;\n state.extra = (here_op) & 15;\n state.mode = DISTEXT;\n /* falls through */\n case DISTEXT:\n if (state.extra) {\n //=== NEEDBITS(state.extra);\n n = state.extra;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.offset += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n //--- DROPBITS(state.extra) ---//\n hold >>>= state.extra;\n bits -= state.extra;\n //---//\n state.back += state.extra;\n }\n//#ifdef INFLATE_STRICT\n if (state.offset > state.dmax) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break;\n }\n//#endif\n //Tracevv((stderr, \"inflate: distance %u\\n\", state.offset));\n state.mode = MATCH;\n /* falls through */\n case MATCH:\n if (left === 0) { break inf_leave; }\n copy = _out - left;\n if (state.offset > copy) { /* copy from window */\n copy = state.offset - copy;\n if (copy > state.whave) {\n if (state.sane) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break;\n }\n// (!) This block is disabled in zlib defailts,\n// don't enable it for binary compatibility\n//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n// Trace((stderr, \"inflate.c too far\\n\"));\n// copy -= state.whave;\n// if (copy > state.length) { copy = state.length; }\n// if (copy > left) { copy = left; }\n// left -= copy;\n// state.length -= copy;\n// do {\n// output[put++] = 0;\n// } while (--copy);\n// if (state.length === 0) { state.mode = LEN; }\n// break;\n//#endif\n }\n if (copy > state.wnext) {\n copy -= state.wnext;\n from = state.wsize - copy;\n }\n else {\n from = state.wnext - copy;\n }\n if (copy > state.length) { copy = state.length; }\n from_source = state.window;\n }\n else { /* copy from output */\n from_source = output;\n from = put - state.offset;\n copy = state.length;\n }\n if (copy > left) { copy = left; }\n left -= copy;\n state.length -= copy;\n do {\n output[put++] = from_source[from++];\n } while (--copy);\n if (state.length === 0) { state.mode = LEN; }\n break;\n case LIT:\n if (left === 0) { break inf_leave; }\n output[put++] = state.length;\n left--;\n state.mode = LEN;\n break;\n case CHECK:\n if (state.wrap) {\n //=== NEEDBITS(32);\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n // Use '|' insdead of '+' to make sure that result is signed\n hold |= input[next++] << bits;\n bits += 8;\n }\n //===//\n _out -= left;\n strm.total_out += _out;\n state.total += _out;\n if (_out) {\n strm.adler = state.check =\n /*UPDATE(state.check, put - _out, _out);*/\n (state.flags ? crc32(state.check, output, _out, put - _out) : adler32(state.check, output, _out, put - _out));\n\n }\n _out = left;\n // NB: crc32 stored as signed 32-bit int, zswap32 returns signed too\n if ((state.flags ? hold : zswap32(hold)) !== state.check) {\n strm.msg = 'incorrect data check';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n //Tracev((stderr, \"inflate: check matches trailer\\n\"));\n }\n state.mode = LENGTH;\n /* falls through */\n case LENGTH:\n if (state.wrap && state.flags) {\n //=== NEEDBITS(32);\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (hold !== (state.total & 0xffffffff)) {\n strm.msg = 'incorrect length check';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n //Tracev((stderr, \"inflate: length matches trailer\\n\"));\n }\n state.mode = DONE;\n /* falls through */\n case DONE:\n ret = Z_STREAM_END;\n break inf_leave;\n case BAD:\n ret = Z_DATA_ERROR;\n break inf_leave;\n case MEM:\n return Z_MEM_ERROR;\n case SYNC:\n /* falls through */\n default:\n return Z_STREAM_ERROR;\n }\n }\n\n // inf_leave <- here is real place for \"goto inf_leave\", emulated via \"break inf_leave\"\n\n /*\n Return from inflate(), updating the total counts and the check value.\n If there was no progress during the inflate() call, return a buffer\n error. Call updatewindow() to create and/or update the window state.\n Note: a memory error from inflate() is non-recoverable.\n */\n\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n\n if (state.wsize || (_out !== strm.avail_out && state.mode < BAD &&\n (state.mode < CHECK || flush !== Z_FINISH))) {\n if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) {\n state.mode = MEM;\n return Z_MEM_ERROR;\n }\n }\n _in -= strm.avail_in;\n _out -= strm.avail_out;\n strm.total_in += _in;\n strm.total_out += _out;\n state.total += _out;\n if (state.wrap && _out) {\n strm.adler = state.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/\n (state.flags ? crc32(state.check, output, _out, strm.next_out - _out) : adler32(state.check, output, _out, strm.next_out - _out));\n }\n strm.data_type = state.bits + (state.last ? 64 : 0) +\n (state.mode === TYPE ? 128 : 0) +\n (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);\n if (((_in === 0 && _out === 0) || flush === Z_FINISH) && ret === Z_OK) {\n ret = Z_BUF_ERROR;\n }\n return ret;\n}\n\nfunction inflateEnd(strm) {\n\n if (!strm || !strm.state /*|| strm->zfree == (free_func)0*/) {\n return Z_STREAM_ERROR;\n }\n\n var state = strm.state;\n if (state.window) {\n state.window = null;\n }\n strm.state = null;\n return Z_OK;\n}\n\nfunction inflateGetHeader(strm, head) {\n var state;\n\n /* check state */\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n if ((state.wrap & 2) === 0) { return Z_STREAM_ERROR; }\n\n /* save header structure */\n state.head = head;\n head.done = false;\n return Z_OK;\n}\n\nfunction inflateSetDictionary(strm, dictionary) {\n var dictLength = dictionary.length;\n\n var state;\n var dictid;\n var ret;\n\n /* check state */\n if (!strm /* == Z_NULL */ || !strm.state /* == Z_NULL */) { return Z_STREAM_ERROR; }\n state = strm.state;\n\n if (state.wrap !== 0 && state.mode !== DICT) {\n return Z_STREAM_ERROR;\n }\n\n /* check for correct dictionary identifier */\n if (state.mode === DICT) {\n dictid = 1; /* adler32(0, null, 0)*/\n /* dictid = adler32(dictid, dictionary, dictLength); */\n dictid = adler32(dictid, dictionary, dictLength, 0);\n if (dictid !== state.check) {\n return Z_DATA_ERROR;\n }\n }\n /* copy dictionary to window using updatewindow(), which will amend the\n existing dictionary if appropriate */\n ret = updatewindow(strm, dictionary, dictLength, dictLength);\n if (ret) {\n state.mode = MEM;\n return Z_MEM_ERROR;\n }\n state.havedict = 1;\n // Tracev((stderr, \"inflate: dictionary set\\n\"));\n return Z_OK;\n}\n\n// String encode/decode helpers\n// 'use strict';\n\n\n// var utils = require('./common');\n\n\n// Quick check if we can use fast array to bin string conversion\n//\n// - apply(Array) can fail on Android 2.2\n// - apply(Uint8Array) can fail on iOS 5.1 Safary\n//\nvar STR_APPLY_OK = true;\nvar STR_APPLY_UIA_OK = true;\n\ntry { String.fromCharCode.apply(null, [ 0 ]); } catch (__) { STR_APPLY_OK = false; }\ntry { String.fromCharCode.apply(null, new Uint8Array(1)); } catch (__) { STR_APPLY_UIA_OK = false; }\n\n\n// Table with utf8 lengths (calculated by first byte of sequence)\n// Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS,\n// because max possible codepoint is 0x10ffff\nvar _utf8len = new Uint8Array(256);\nfor (var q = 0; q < 256; q++) {\n _utf8len[q] = (q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1);\n}\n_utf8len[254] = _utf8len[254] = 1; // Invalid sequence start\n\n\n// convert string to array (typed, when possible)\nfunction string2buf(str) {\n var buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;\n\n // count binary size\n for (m_pos = 0; m_pos < str_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n m_pos++;\n }\n }\n buf_len += c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4;\n }\n\n // allocate buffer\n buf = new Uint8Array(buf_len);\n\n // convert\n for (i = 0, m_pos = 0; i < buf_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n m_pos++;\n }\n }\n if (c < 0x80) {\n /* one byte */\n buf[i++] = c;\n } else if (c < 0x800) {\n /* two bytes */\n buf[i++] = 0xC0 | (c >>> 6);\n buf[i++] = 0x80 | (c & 0x3f);\n } else if (c < 0x10000) {\n /* three bytes */\n buf[i++] = 0xE0 | (c >>> 12);\n buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n buf[i++] = 0x80 | (c & 0x3f);\n } else {\n /* four bytes */\n buf[i++] = 0xf0 | (c >>> 18);\n buf[i++] = 0x80 | (c >>> 12 & 0x3f);\n buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n buf[i++] = 0x80 | (c & 0x3f);\n }\n }\n\n return buf;\n}\n\n// Helper (used in 2 places)\nfunction _buf2binstring(buf, len) {\n // use fallback for big arrays to avoid stack overflow\n if (len < 65537) {\n if ((buf.subarray && STR_APPLY_UIA_OK) || (!buf.subarray && STR_APPLY_OK)) {\n return String.fromCharCode.apply(null, shrinkBuf(buf, len));\n }\n }\n\n var result = '';\n for (var i = 0; i < len; i++) {\n result += String.fromCharCode(buf[i]);\n }\n return result;\n}\n\n\n// Convert binary string (typed, when possible)\nfunction binstring2buf(str) {\n var buf = new Uint8Array(str.length);\n for (var i = 0, len = buf.length; i < len; i++) {\n buf[i] = str.charCodeAt(i);\n }\n return buf;\n}\n\n\n// convert array to string\nfunction buf2string(buf, max) {\n var i, out, c, c_len;\n var len = max || buf.length;\n\n // Reserve max possible length (2 words per char)\n // NB: by unknown reasons, Array is significantly faster for\n // String.fromCharCode.apply than Uint16Array.\n var utf16buf = new Array(len * 2);\n\n for (out = 0, i = 0; i < len;) {\n c = buf[i++];\n // quick process ascii\n if (c < 0x80) { utf16buf[out++] = c; continue; }\n\n c_len = _utf8len[c];\n // skip 5 & 6 byte codes\n if (c_len > 4) { utf16buf[out++] = 0xfffd; i += c_len - 1; continue; }\n\n // apply mask on first byte\n c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07;\n // join the rest\n while (c_len > 1 && i < len) {\n c = (c << 6) | (buf[i++] & 0x3f);\n c_len--;\n }\n\n // terminated by end of string?\n if (c_len > 1) { utf16buf[out++] = 0xfffd; continue; }\n\n if (c < 0x10000) {\n utf16buf[out++] = c;\n } else {\n c -= 0x10000;\n utf16buf[out++] = 0xd800 | ((c >> 10) & 0x3ff);\n utf16buf[out++] = 0xdc00 | (c & 0x3ff);\n }\n }\n\n return _buf2binstring(utf16buf, out);\n}\n\n\n// Calculate max possible position in utf8 buffer,\n// that will not break sequence. If that's not possible\n// - (very small limits) return max size as is.\n//\n// buf[] - utf8 bytes array\n// max - length limit (mandatory);\nfunction utf8border(buf, max) {\n var pos;\n\n max = max || buf.length;\n if (max > buf.length) { max = buf.length; }\n\n // go back from last position, until start of sequence found\n pos = max - 1;\n while (pos >= 0 && (buf[pos] & 0xC0) === 0x80) { pos--; }\n\n // Fuckup - very small and broken sequence,\n // return max, because we should return something anyway.\n if (pos < 0) { return max; }\n\n // If we came to start of buffer - that means vuffer is too small,\n // return max too.\n if (pos === 0) { return max; }\n\n return (pos + _utf8len[buf[pos]] > max) ? pos : max;\n}\n\n/* Allowed flush values; see deflate() and inflate() below for details */\nvar Z_NO_FLUSH = 0;\nvar Z_SYNC_FLUSH = 2;\nvar Z_FINISH$1 = 4;\n/* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\nvar Z_OK$1 = 0;\nvar Z_STREAM_END$1 = 1;\nvar Z_NEED_DICT$1 = 2;\n//export var Z_MEM_ERROR = -4;\nvar Z_BUF_ERROR$1 = -5;\n\n// 'use strict';\n\nvar messages = {\n 2: 'need dictionary', /* Z_NEED_DICT 2 */\n 1: 'stream end', /* Z_STREAM_END 1 */\n 0: '', /* Z_OK 0 */\n '-1': 'file error', /* Z_ERRNO (-1) */\n '-2': 'stream error', /* Z_STREAM_ERROR (-2) */\n '-3': 'data error', /* Z_DATA_ERROR (-3) */\n '-4': 'insufficient memory', /* Z_MEM_ERROR (-4) */\n '-5': 'buffer error', /* Z_BUF_ERROR (-5) */\n '-6': 'incompatible version' /* Z_VERSION_ERROR (-6) */\n};\n\n// 'use strict';\n\n\nfunction ZStream() {\n /* next input byte */\n this.input = null; // JS specific, because we have no pointers\n this.next_in = 0;\n /* number of bytes available at input */\n this.avail_in = 0;\n /* total number of input bytes read so far */\n this.total_in = 0;\n /* next output byte should be put there */\n this.output = null; // JS specific, because we have no pointers\n this.next_out = 0;\n /* remaining free space at output */\n this.avail_out = 0;\n /* total number of bytes output so far */\n this.total_out = 0;\n /* last error message, NULL if no error */\n this.msg = ''/*Z_NULL*/;\n /* not visible by applications */\n this.state = null;\n /* best guess about the data type: binary or text */\n this.data_type = 2/*Z_UNKNOWN*/;\n /* adler32 value of the uncompressed data */\n this.adler = 0;\n}\n\n// 'use strict';\n\n\nfunction GZheader() {\n /* true if compressed data believed to be text */\n this.text = 0;\n /* modification time */\n this.time = 0;\n /* extra flags (not used when writing a gzip file) */\n this.xflags = 0;\n /* operating system */\n this.os = 0;\n /* pointer to extra field or Z_NULL if none */\n this.extra = null;\n /* extra field length (valid if extra != Z_NULL) */\n this.extra_len = 0; // Actually, we don't need it in JS,\n // but leave for few code modifications\n\n //\n // Setup limits is not necessary because in js we should not preallocate memory\n // for inflate use constant limit in 65536 bytes\n //\n\n /* space at extra (only when reading header) */\n // this.extra_max = 0;\n /* pointer to zero-terminated file name or Z_NULL */\n this.name = '';\n /* space at name (only when reading header) */\n // this.name_max = 0;\n /* pointer to zero-terminated comment or Z_NULL */\n this.comment = '';\n /* space at comment (only when reading header) */\n // this.comm_max = 0;\n /* true if there was or will be a header crc */\n this.hcrc = 0;\n /* true when done reading gzip header (not used when writing a gzip file) */\n this.done = false;\n}\n\n// 'use strict';\n\n\n// var zlib_inflate = require('./zlib/inflate');\n// var utils = require('./utils/common');\n// var strings = require('./utils/strings');\n// var c = require('./zlib/constants');\n// var msg = require('./zlib/messages');\n// var ZStream = require('./zlib/zstream');\n// var GZheader = require('./zlib/gzheader');\n\nvar toString = Object.prototype.toString;\n\n/**\n * class Inflate\n *\n * Generic JS-style wrapper for zlib calls. If you don't need\n * streaming behaviour - use more simple functions: [[inflate]]\n * and [[inflateRaw]].\n **/\n\n/* internal\n * inflate.chunks -> Array\n *\n * Chunks of output data, if [[Inflate#onData]] not overriden.\n **/\n\n/**\n * Inflate.result -> Uint8Array|Array|String\n *\n * Uncompressed result, generated by default [[Inflate#onData]]\n * and [[Inflate#onEnd]] handlers. Filled after you push last chunk\n * (call [[Inflate#push]] with `Z_FINISH` / `true` param) or if you\n * push a chunk with explicit flush (call [[Inflate#push]] with\n * `Z_SYNC_FLUSH` param).\n **/\n\n/**\n * Inflate.err -> Number\n *\n * Error code after inflate finished. 0 (Z_OK) on success.\n * Should be checked if broken data possible.\n **/\n\n/**\n * Inflate.msg -> String\n *\n * Error message, if [[Inflate.err]] != 0\n **/\n\n\n/**\n * new Inflate(options)\n * - options (Object): zlib inflate options.\n *\n * Creates new inflator instance with specified params. Throws exception\n * on bad params. Supported options:\n *\n * - `windowBits`\n * - `dictionary`\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information on these.\n *\n * Additional options, for internal needs:\n *\n * - `chunkSize` - size of generated data chunks (16K by default)\n * - `raw` (Boolean) - do raw inflate\n * - `to` (String) - if equal to 'string', then result will be converted\n * from utf8 to utf16 (javascript) string. When string output requested,\n * chunk length can differ from `chunkSize`, depending on content.\n *\n * By default, when no options set, autodetect deflate/gzip data format via\n * wrapper header.\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , chunk1 = Uint8Array([1,2,3,4,5,6,7,8,9])\n * , chunk2 = Uint8Array([10,11,12,13,14,15,16,17,18,19]);\n *\n * var inflate = new pako.Inflate({ level: 3});\n *\n * inflate.push(chunk1, false);\n * inflate.push(chunk2, true); // true -> last chunk\n *\n * if (inflate.err) { throw new Error(inflate.err); }\n *\n * console.log(inflate.result);\n * ```\n **/\nfunction Inflate(options) {\n if (!(this instanceof Inflate)) return new Inflate(options);\n\n this.options = assign({\n chunkSize: 16384,\n windowBits: 0,\n to: ''\n }, options || {});\n\n var opt = this.options;\n\n // Force window size for `raw` data, if not set directly,\n // because we have no header for autodetect.\n if (opt.raw && (opt.windowBits >= 0) && (opt.windowBits < 16)) {\n opt.windowBits = -opt.windowBits;\n if (opt.windowBits === 0) { opt.windowBits = -15; }\n }\n\n // If `windowBits` not defined (and mode not raw) - set autodetect flag for gzip/deflate\n if ((opt.windowBits >= 0) && (opt.windowBits < 16) &&\n !(options && options.windowBits)) {\n opt.windowBits += 32;\n }\n\n // Gzip header has no info about windows size, we can do autodetect only\n // for deflate. So, if window size not set, force it to max when gzip possible\n if ((opt.windowBits > 15) && (opt.windowBits < 48)) {\n // bit 3 (16) -> gzipped data\n // bit 4 (32) -> autodetect gzip/deflate\n if ((opt.windowBits & 15) === 0) {\n opt.windowBits |= 15;\n }\n }\n\n this.err = 0; // error code, if happens (0 = Z_OK)\n this.msg = ''; // error message\n this.ended = false; // used to avoid multiple onEnd() calls\n this.chunks = []; // chunks of compressed data\n\n this.strm = new ZStream();\n this.strm.avail_out = 0;\n\n var status = inflateInit2(\n this.strm,\n opt.windowBits\n );\n\n if (status !== Z_OK$1) {\n throw new Error(messages[status]);\n }\n\n this.header = new GZheader();\n\n inflateGetHeader(this.strm, this.header);\n}\n\n/**\n * Inflate#push(data[, mode]) -> Boolean\n * - data (Uint8Array|Array|ArrayBuffer|String): input data\n * - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.\n * See constants. Skipped or `false` means Z_NO_FLUSH, `true` meansh Z_FINISH.\n *\n * Sends input data to inflate pipe, generating [[Inflate#onData]] calls with\n * new output chunks. Returns `true` on success. The last data block must have\n * mode Z_FINISH (or `true`). That will flush internal pending buffers and call\n * [[Inflate#onEnd]]. For interim explicit flushes (without ending the stream) you\n * can use mode Z_SYNC_FLUSH, keeping the decompression context.\n *\n * On fail call [[Inflate#onEnd]] with error code and return false.\n *\n * We strongly recommend to use `Uint8Array` on input for best speed (output\n * format is detected automatically). Also, don't skip last param and always\n * use the same type in your code (boolean or number). That will improve JS speed.\n *\n * For regular `Array`-s make sure all elements are [0..255].\n *\n * ##### Example\n *\n * ```javascript\n * push(chunk, false); // push one of data chunks\n * ...\n * push(chunk, true); // push last chunk\n * ```\n **/\nInflate.prototype.push = function (data, mode) {\n var strm = this.strm;\n var chunkSize = this.options.chunkSize;\n var dictionary = this.options.dictionary;\n var status, _mode;\n var next_out_utf8, tail, utf8str;\n var dict;\n\n // Flag to properly process Z_BUF_ERROR on testing inflate call\n // when we check that all output data was flushed.\n var allowBufError = false;\n\n if (this.ended) { return false; }\n _mode = (mode === ~~mode) ? mode : ((mode === true) ? Z_FINISH$1 : Z_NO_FLUSH);\n\n // Convert data if needed\n if (typeof data === 'string') {\n // Only binary strings can be decompressed on practice\n strm.input = binstring2buf(data);\n } else if (toString.call(data) === '[object ArrayBuffer]') {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\n\n do {\n if (strm.avail_out === 0) {\n strm.output = new Uint8Array(chunkSize);\n strm.next_out = 0;\n strm.avail_out = chunkSize;\n }\n\n status = inflate(strm, Z_NO_FLUSH); /* no bad return value */\n\n if (status === Z_NEED_DICT$1 && dictionary) {\n // Convert data if needed\n if (typeof dictionary === 'string') {\n dict = string2buf(dictionary);\n } else if (toString.call(dictionary) === '[object ArrayBuffer]') {\n dict = new Uint8Array(dictionary);\n } else {\n dict = dictionary;\n }\n\n status = inflateSetDictionary(this.strm, dict);\n\n }\n\n if (status === Z_BUF_ERROR$1 && allowBufError === true) {\n status = Z_OK$1;\n allowBufError = false;\n }\n\n if (status !== Z_STREAM_END$1 && status !== Z_OK$1) {\n this.onEnd(status);\n this.ended = true;\n return false;\n }\n\n if (strm.next_out) {\n if (strm.avail_out === 0 || status === Z_STREAM_END$1 || (strm.avail_in === 0 && (_mode === Z_FINISH$1 || _mode === Z_SYNC_FLUSH))) {\n\n if (this.options.to === 'string') {\n\n next_out_utf8 = utf8border(strm.output, strm.next_out);\n\n tail = strm.next_out - next_out_utf8;\n utf8str = buf2string(strm.output, next_out_utf8);\n\n // move tail\n strm.next_out = tail;\n strm.avail_out = chunkSize - tail;\n if (tail) { arraySet(strm.output, strm.output, next_out_utf8, tail, 0); }\n\n this.onData(utf8str);\n\n } else {\n this.onData(shrinkBuf(strm.output, strm.next_out));\n }\n }\n }\n\n // When no more input data, we should check that internal inflate buffers\n // are flushed. The only way to do it when avail_out = 0 - run one more\n // inflate pass. But if output data not exists, inflate return Z_BUF_ERROR.\n // Here we set flag to process this error properly.\n //\n // NOTE. Deflate does not return error in this case and does not needs such\n // logic.\n if (strm.avail_in === 0 && strm.avail_out === 0) {\n allowBufError = true;\n }\n\n } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== Z_STREAM_END$1);\n\n if (status === Z_STREAM_END$1) {\n _mode = Z_FINISH$1;\n }\n\n // Finalize on the last chunk.\n if (_mode === Z_FINISH$1) {\n status = inflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return status === Z_OK$1;\n }\n\n // callback interim results if Z_SYNC_FLUSH.\n if (_mode === Z_SYNC_FLUSH) {\n this.onEnd(Z_OK$1);\n strm.avail_out = 0;\n return true;\n }\n\n return true;\n};\n\n\n/**\n * Inflate#onData(chunk) -> Void\n * - chunk (Uint8Array|Array|String): ouput data. Type of array depends\n * on js engine support. When string output requested, each chunk\n * will be string.\n *\n * By default, stores data blocks in `chunks[]` property and glue\n * those in `onEnd`. Override this handler, if you need another behaviour.\n **/\nInflate.prototype.onData = function (chunk) {\n this.chunks.push(chunk);\n};\n\n\n/**\n * Inflate#onEnd(status) -> Void\n * - status (Number): inflate status. 0 (Z_OK) on success,\n * other if not.\n *\n * Called either after you tell inflate that the input stream is\n * complete (Z_FINISH) or should be flushed (Z_SYNC_FLUSH)\n * or if an error happened. By default - join collected chunks,\n * free memory and fill `results` / `err` properties.\n **/\nInflate.prototype.onEnd = function (status) {\n // On success - join\n if (status === Z_OK$1) {\n if (this.options.to === 'string') {\n // Glue & convert here, until we teach pako to send\n // utf8 alligned strings to onData\n this.result = this.chunks.join('');\n } else {\n this.result = flattenChunks(this.chunks);\n }\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n};\n\n\n/**\n * inflate(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * Decompress `data` with inflate/ungzip and `options`. Autodetect\n * format via wrapper header by default. That's why we don't provide\n * separate `ungzip` method.\n *\n * Supported options are:\n *\n * - windowBits\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information.\n *\n * Sugar (options):\n *\n * - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify\n * negative windowBits implicitly.\n * - `to` (String) - if equal to 'string', then result will be converted\n * from utf8 to utf16 (javascript) string. When string output requested,\n * chunk length can differ from `chunkSize`, depending on content.\n *\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , input = pako.deflate([1,2,3,4,5,6,7,8,9])\n * , output;\n *\n * try {\n * output = pako.inflate(input);\n * } catch (err)\n * console.log(err);\n * }\n * ```\n **/\nfunction doInflate(input, options) {\n var inflator = new Inflate(options);\n\n inflator.push(input, true);\n\n // That will never happens, if you don't cheat with options :)\n if (inflator.err) { throw inflator.msg; }\n\n return inflator.result;\n}\n\nexport { doInflate as ungzip };","/**\n * @file Validation Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport XmlParser, { XmlParserParameters } from './xml-parser'\nimport Validation from '../structure/validation'\nimport Streamer from '../streamer/streamer';\n\nclass ValidationParser extends XmlParser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.useDomParser = true\n this.validation = new Validation(this.name, this.path)\n }\n\n get __objName () { return 'validation' }\n get isXml () { return true }\n\n _parse () {\n super._parse()\n\n if (Debug) Log.time('ValidationParser._parse ' + this.name)\n\n this.validation.fromXml(this.xml.data)\n\n if (Debug) Log.timeEnd('ValidationParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('validation', ValidationParser)\n\nexport default ValidationParser\n","/**\n * @file Gzip Decompressor\n * @author Alexander Rose \n * @private\n */\n\nimport { ungzip } from '../../lib/pako_inflate.es6'\n\nimport { DecompressorRegistry } from '../globals'\n\nfunction gzipDecompress (data: ArrayBuffer|Uint8Array) {\n let decompressedData\n\n if (data instanceof ArrayBuffer) {\n data = new Uint8Array(data)\n }\n\n try {\n decompressedData = ungzip(data as Uint8Array)\n } catch (e) {\n decompressedData = data // assume it is already uncompressed\n }\n\n return decompressedData\n}\n\nDecompressorRegistry.add('gz', gzipDecompress)\n","/**\n * @file Datasource\n * @author Alexander Rose \n * @private\n */\n\n/**\n * Datasource base class\n * @interface\n */\nabstract class Datasource {\n /**\n * Get full url\n * @abstract\n * @param {String} path - datasource string\n * @return {String} - url\n */\n abstract getUrl (path: string): string\n\n /**\n * Get file extension\n * @abstract\n * @param {String} path - datasource string\n * @return {String} - extension\n */\n abstract getExt (path: string): string\n}\n\nexport default Datasource\n","/**\n * @file RCSB Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { Log, DatasourceRegistry } from '../globals'\nimport { getProtocol } from '../utils'\nimport { getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nconst baseUrl = '//files.rcsb.org/download/'\nconst mmtfBaseUrl = '//mmtf.rcsb.org/v1.0/'\nconst mmtfFullUrl = mmtfBaseUrl + 'full/'\nconst mmtfReducedUrl = mmtfBaseUrl + 'reduced/'\n\nclass RcsbDatasource extends Datasource {\n getUrl (src: string) {\n // valid path are\n // XXXX.pdb, XXXX.pdb.gz, XXXX.cif, XXXX.cif.gz, XXXX.mmtf, XXXX.bb.mmtf\n // XXXX defaults to XXXX.cif\n const info = getFileInfo(src)\n const pdbid = info.name.substr(0, 4)\n let url\n if ([ 'pdb', 'cif' ].includes(info.ext) &&\n (info.compressed === false || info.compressed === 'gz')\n ) {\n url = baseUrl + info.path\n } else if (info.ext === 'mmtf') {\n if (info.base.endsWith('.bb')) {\n url = mmtfReducedUrl + pdbid\n } else {\n url = mmtfFullUrl + pdbid\n }\n } else if (!info.ext) {\n url = mmtfFullUrl + pdbid\n } else {\n Log.warn('unsupported ext', info.ext)\n url = mmtfFullUrl + pdbid\n }\n return getProtocol() + url\n }\n\n getExt (src: string) {\n const ext = getFileInfo(src).ext\n return ext ? ext : 'mmtf'\n }\n}\n\nDatasourceRegistry.add('rcsb', new RcsbDatasource())\n\nexport default RcsbDatasource\n","/**\n * @file PubChem Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { Log, DatasourceRegistry } from '../globals'\nimport { getProtocol } from '../utils'\nimport { getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nconst baseUrl = '//pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/'\nconst suffixUrl = '/SDF?record_type=3d'\n\nclass PubchemDatasource extends Datasource {\n getUrl (src: string) {\n const info = getFileInfo(src)\n const cid = info.name\n let url\n if (!info.ext || info.ext === 'sdf') {\n url = baseUrl + cid + suffixUrl\n } else {\n Log.warn('unsupported ext', info.ext)\n url = baseUrl + cid + suffixUrl\n }\n return getProtocol() + url\n }\n\n getExt (src: string) {\n const ext = getFileInfo(src).ext\n return ext ? ext : 'sdf'\n }\n}\n\nDatasourceRegistry.add('pubchem', new PubchemDatasource())\n\nexport default PubchemDatasource\n","/**\n * @file Pass Through Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { DatasourceRegistry } from '../globals'\nimport { getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nclass PassThroughDatasource extends Datasource {\n getUrl (path: string) {\n return path\n }\n\n getExt (path: string) {\n return getFileInfo(path).ext\n }\n}\n\nDatasourceRegistry.add('ftp', new PassThroughDatasource())\nDatasourceRegistry.add('http', new PassThroughDatasource())\nDatasourceRegistry.add('https', new PassThroughDatasource())\n\nexport default PassThroughDatasource\n","/**\r\n * @file Alphafold Datasource\r\n * @author Fredric Johansson \r\n * @private\r\n */\r\n\r\nimport { Log, DatasourceRegistry } from '../globals'\r\nimport { getProtocol } from '../utils'\r\nimport { getFileInfo } from '../loader/loader-utils'\r\nimport Datasource from './datasource'\r\n\r\nconst baseUrl = '//alphafold.ebi.ac.uk/files/AF-'\r\nconst suffixURL = '-F1-model_v2.pdb'\r\n\r\nclass AlphafoldDatasource extends Datasource {\r\n getUrl (src: string) {\r\n const info = getFileInfo(src)\r\n const uniprotid = info.name\r\n let url\r\n if (!info.ext || info.ext === 'pdb') {\r\n url = baseUrl + uniprotid + suffixURL\r\n } else {\r\n Log.warn('unsupported AF ext', info.ext)\r\n url = baseUrl + uniprotid + suffixURL\r\n }\r\n return getProtocol() + url\r\n }\r\n\r\n getExt (src: string) {\r\n const ext = getFileInfo(src).ext\r\n return ext ? ext : 'pdb'\r\n }\r\n}\r\n\r\nDatasourceRegistry.add('alphafold', new AlphafoldDatasource())\r\n\r\nexport default AlphafoldDatasource\r\n","/**\n * @file Static Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { getAbsolutePath } from '../utils'\nimport { getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nconst reProtocol = /^((http|https|ftp):)*\\/\\//\n\nclass StaticDatasource extends Datasource {\n baseUrl: string\n\n constructor (baseUrl: string = '') {\n super()\n this.baseUrl = baseUrl\n }\n\n getUrl (src: string) {\n const info = getFileInfo(src)\n let url = this.baseUrl + info.path\n if (!reProtocol.test(this.baseUrl)) {\n url = getAbsolutePath(url)\n }\n return url\n }\n\n getExt (src: string) {\n return getFileInfo(src).ext\n }\n}\n\nexport default StaticDatasource\n","/**\n * @file UI Parameters\n * @author Alexander Rose \n */\n\nimport { StageParameters } from '../stage/stage'\nimport { MouseActionPresets } from '../controls/mouse-actions'\n\nexport type BooleanParam = { type: 'boolean' }\nfunction BooleanParam () { return { type: 'boolean' } as BooleanParam }\n\nexport type ColorParam = { type: 'color' }\nfunction ColorParam () { return { type: 'color' } as ColorParam }\n\nexport type IntegerParam = { type: 'integer', max: number, min: number }\nfunction IntegerParam (max: number, min: number) {\n return { type: 'integer', max, min } as IntegerParam\n}\n\nexport type NumberParam = { type: 'number', precision: number, max: number, min: number }\nfunction NumberParam (precision: number, max: number, min: number) {\n return { type: 'number', precision, max, min } as NumberParam\n}\n\nexport type RangeParam = { type: 'range', step: number, max: number, min: number }\nfunction RangeParam (step: number, max: number, min: number) {\n return { type: 'range', step, max, min } as RangeParam\n}\n\nexport type SelectParam = { type: 'select', options: { [k: string]: string } }\nfunction SelectParam (...options: string[]) {\n return { type: 'select', options: options.reduce((o, k) => ({ ...o, [k]: k}), {}) } as SelectParam\n}\n\nexport type ParamType = BooleanParam|ColorParam|IntegerParam|NumberParam|RangeParam|SelectParam\n\nexport const UIStageParameters: { [k in keyof StageParameters]: ParamType } = {\n backgroundColor: ColorParam(),\n quality: SelectParam('auto', 'low', 'medium', 'high'),\n sampleLevel: RangeParam(1, 5, -1),\n impostor: BooleanParam(),\n workerDefault: BooleanParam(),\n rotateSpeed: NumberParam(1, 10, 0),\n zoomSpeed: NumberParam(1, 10, 0),\n panSpeed: NumberParam(1, 10, 0),\n clipNear: RangeParam(1, 100, 0),\n clipFar: RangeParam(1, 100, 0),\n clipDist: IntegerParam(200, 0),\n clipMode: SelectParam('scene', 'camera'),\n clipScale: SelectParam('relative', 'absolute'),\n fogNear: RangeParam(1, 100, 0),\n fogFar: RangeParam(1, 100, 0),\n cameraType: SelectParam('perspective', 'orthographic', 'stereo'),\n cameraEyeSep: NumberParam(3, 1.0, 0.01),\n cameraFov: RangeParam(1, 120, 15),\n lightColor: ColorParam(),\n lightIntensity: NumberParam(2, 10, 0),\n ambientColor: ColorParam(),\n ambientIntensity: NumberParam(2, 10, 0),\n hoverTimeout: IntegerParam(10000, -1),\n tooltip: BooleanParam(),\n mousePreset: SelectParam(...Object.keys(MouseActionPresets))\n}\n","/**\n * @file MDsrv Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { autoLoad, getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nclass MdsrvDatasource extends Datasource {\n baseUrl: string\n\n constructor (baseUrl: string = '') {\n super()\n this.baseUrl = baseUrl\n }\n\n getListing (path: string = '') {\n let url = `${this.baseUrl}dir/${path}`\n if (url[url.length - 1] !== '/') url += '/'\n return autoLoad(url, {\n ext: 'json'\n }).then((jsonData: any) => ({\n path: path,\n data: jsonData.data\n }))\n }\n\n getUrl (src: string) {\n const info = getFileInfo(src)\n return `${this.baseUrl}file/${info.path}${info.query}`\n }\n\n getCountUrl (src: string) {\n const info = getFileInfo(src)\n return `${this.baseUrl}traj/numframes/${info.path}${info.query}`\n }\n\n getFrameUrl (src: string, frameIndex: number|string) {\n const info = getFileInfo(src)\n return `${this.baseUrl}traj/frame/${frameIndex}/${info.path}${info.query}`\n }\n\n getFrameParams (src: string, atomIndices: (number|string)[]) {\n return `atomIndices=${atomIndices.join(';')}`\n }\n\n getPathUrl (src: string, atomIndex: number|string) {\n const info = getFileInfo(src)\n return `${this.baseUrl}traj/path/${atomIndex}/${info.path}${info.query}`\n }\n\n getExt (src: string) {\n return getFileInfo(src).ext\n }\n}\n\nexport default MdsrvDatasource\n","/**\n * @file Pdb Writer\n * @author Alexander Rose \n * @private\n */\n\nimport { sprintf } from 'sprintf-js'\n\nimport Writer from './writer'\nimport { defaults, ensureArray } from '../utils'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\n\n// http://www.wwpdb.org/documentation/file-format\n\n// Sample PDB line, the coords X,Y,Z are fields 5,6,7 on each line.\n// ATOM 1 N ARG 1 29.292 13.212 -12.751 1.00 33.78 1BPT 108\n\nconst AtomFormat =\n 'ATOM %5d %-4s %3s %1s%4d %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%1s%1s'\n\nconst HetatmFormat =\n 'HETATM%5d %-4s %3s %1s%4d %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%1s%1s'\n\nexport interface PdbWriterParams {\n renumberSerial: boolean\n remarks: string[]\n}\n\n/**\n * Create a PDB file from a Structure object\n */\nexport default class PdbWriter extends Writer {\n readonly mimeType = 'text/plain'\n readonly defaultName = 'structure'\n readonly defaultExt = 'pdb'\n\n renumberSerial: boolean\n remarks: string[]\n\n structure: Structure\n private _records: string[]\n\n /**\n * @param {Structure} structure - the structure object\n * @param {Object} params - parameters]\n */\n constructor (structure: Structure, params?: PdbWriterParams) {\n super()\n\n const p = Object.assign({}, params)\n\n this.renumberSerial = defaults(p.renumberSerial, true)\n this.remarks = ensureArray(defaults(p.remarks, []))\n\n this.structure = structure\n this._records = []\n }\n\n private _writeRecords () {\n this._records.length = 0\n\n this._writeTitle()\n this._writeRemarks()\n this._writeAtoms()\n }\n\n private _writeTitle () {\n // FIXME multiline if title line longer than 80 chars\n this._records.push(sprintf('TITLE %-74s', this.structure.name))\n }\n\n private _writeRemarks () {\n this.remarks.forEach(str => {\n this._records.push(sprintf('REMARK %-73s', str))\n })\n\n if (this.structure.trajectory) {\n this._records.push(sprintf(\n 'REMARK %-73s',\n \"Trajectory '\" + this.structure.trajectory.name + \"'\"\n ))\n this._records.push(sprintf(\n 'REMARK %-73s',\n `Frame ${(this.structure.trajectory as any).frame}` // TODO\n ))\n }\n }\n\n private _writeAtoms () {\n let ia = 1\n let im = 1\n let charge = \" \"\n let chargeSign = \" \"\n const hasModels = this.structure.modelStore.count > 1\n\n this.structure.eachModel(m => {\n if (hasModels) this._records.push(sprintf('MODEL %4d%-66s', im++, ''))\n\n m.eachAtom((a: AtomProxy) => {\n const formatString = a.hetero ? HetatmFormat : AtomFormat\n const serial = this.renumberSerial ? ia : a.serial\n\n // Formal PDB spec\n // Alignment of one-letter atom name such as C starts at column 14,\n // while two-letter atom name such as FE starts at column 13.\n\n // This, however, leaves Calcium and C-alpha ambiguous\n // The convention (from earlier versions of the spec, see 1992, and also: \n // https://www.cgl.ucsf.edu/chimera/docs/UsersGuide/tutorials/pdbintro.html#misalignment)\n // is that element is right-justified in 13-14, modifiers are left justified in columns 15-16\n // A single-character element symmbol should not appear in column 13 unless the atom name has four characters\n let atomname = a.atomname\n\n if (atomname.length === 1) {\n // Simple case\n atomname = ' ' + atomname\n } else if (atomname.length < 4) {\n // 2 or 3-letter name, if element symbol is single char and matches name, add a space\n if (a.element.length === 1 && atomname[0] === a.element) {\n atomname = ' ' + atomname\n }\n }\n\n if (a.formalCharge) { // Skip nulls and zeros\n charge = Math.abs(a.formalCharge).toPrecision(1)\n chargeSign = (a.formalCharge > 0) ? \"+\" : \"-\"\n } else {\n charge = \" \"\n chargeSign = \" \"\n }\n\n this._records.push(sprintf(\n formatString,\n\n serial,\n atomname,\n a.resname,\n defaults(a.chainname, ' '),\n a.resno,\n a.x, a.y, a.z,\n defaults(a.occupancy, 1.0),\n defaults(a.bfactor, 0.0),\n '', // segid\n defaults(a.element, ''),\n charge,\n chargeSign\n ))\n ia += 1\n }, this.structure.getSelection())\n\n if (hasModels) this._records.push(sprintf('%-80s', 'ENDMDL'))\n })\n\n this._records.push(sprintf('%-80s', 'END'))\n }\n\n getString () {\n console.warn('PdbWriter.getString() is deprecated, use .getData instead')\n return this.getData()\n }\n\n /**\n * Get string containing the PDB file data\n * @return {String} PDB file\n */\n getData () {\n this._writeRecords()\n return this._records.join('\\n')\n }\n}\n","/**\n * Writer class for sdf/mol files.\n */\n\nimport { sprintf } from 'sprintf-js'\n\nimport Writer from './writer'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\nimport BondProxy from '../proxy/bond-proxy'\n\n// Hard-coded chiral as false as we don't specify it any atoms\nconst CountFormat = '%3i%3i 0 0 0 0 0 0 0 0999 V2000'\nconst AtomLine = '%10.4f%10.4f%10.4f %-3s 0%3i 0 0 0'\nconst BondFormat = '%3i%3i%3i 0 0 0'\n\nclass SdfWriter extends Writer {\n readonly mimeType = 'text/plain'\n readonly defaultName = 'structure'\n readonly defaultExt = 'sdf'\n\n structure: Structure\n private _records: string[]\n\n /**\n * @param {Structure} structure - structure to write\n * @param {Object} params - parameters\n */\n constructor (structure: Structure) {\n super()\n\n this.structure = structure\n // Follow the pdb-writer example:\n this._records = []\n }\n\n get idString () {\n return this.structure.id\n }\n\n get titleString () {\n return ' ' + this.structure.title\n }\n\n get countsString () {\n return sprintf(\n CountFormat,\n this.structure.atomCount,\n this.structure.bondCount\n )\n }\n\n get chargeLines () {\n const pairs: [number, number][] = []\n this.structure.eachAtom(ap => {\n if (ap.formalCharge != null && ap.formalCharge !== 0) {\n pairs.push([ap.index, ap.formalCharge])\n }\n })\n const lines = []\n for (let i = 0; i < pairs.length; i += 8) {\n const nCharges = Math.min(8, pairs.length - i)\n let s = sprintf('M CHG%3i', nCharges)\n for (let j = i; j < i + nCharges; j++) {\n s += sprintf(' %3i %3i', pairs[j][0] + 1, pairs[j][1])\n }\n lines.push(s)\n }\n return lines\n }\n\n formatAtom (ap: AtomProxy) {\n let charge = 0\n if (ap.formalCharge != null && ap.formalCharge !== 0) {\n charge = 4 - ap.formalCharge\n }\n const line = sprintf(\n AtomLine, ap.x, ap.y, ap.z, ap.element, charge\n )\n if (line.length !== 48) { throw new Error('Incompatible atom for sdf format') }\n\n return line\n }\n\n formatBond (bp: BondProxy) {\n return sprintf(\n BondFormat,\n bp.atomIndex1 + 1,\n bp.atomIndex2 + 1,\n bp.bondOrder)\n }\n\n _writeRecords () {\n this._records.length = 0\n this._writeHeader()\n this._writeCTab()\n this._writeFooter()\n }\n\n _writeHeader () {\n this._records.push(this.idString, this.titleString, '')\n }\n\n _writeCTab () {\n this._records.push(this.countsString)\n this.structure.eachAtom(ap => {\n this._records.push(this.formatAtom(ap))\n })\n this.structure.eachBond(bp => {\n this._records.push(this.formatBond(bp))\n })\n this.chargeLines.forEach(line => {\n this._records.push(line)\n })\n this._records.push('M END')\n }\n\n _writeFooter () {\n this._records.push('$$$$')\n }\n\n getData () {\n this._writeRecords()\n return this._records.join('\\n')\n }\n}\n\nexport default SdfWriter\n","/**\n * @file STL Writer\n * @author Paul Pillot \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport Writer from './writer'\nimport IOBuffer from '../utils/io-buffer'\nimport Surface from '../surface/surface'\n\n// https://en.wikipedia.org/wiki/STL_(file_format)#ASCII_STL\n\n/**\n * Create an STL File from a surface Object (e.g. for 3D printing)\n *\n * @example\n * molsurf = new MolecularSurface(structure)\n * surf = molsurf.getSurface({type: 'av', probeRadius: 1.4})\n * stl = new StlWriter(surf)\n * stl.download('myFileName')\n */\nexport default class StlWriter extends Writer {\n readonly mimeType = 'application/vnd.ms-pki.stl'\n readonly defaultName = 'surface'\n readonly defaultExt = 'stl'\n\n surface: any // TODO\n\n /**\n * @param {Surface} surface - the surface to write out\n */\n constructor (surface: Surface) {\n super()\n\n this.surface = surface\n }\n\n /*\n * Get STL Binary data\n *\n * Adapted from: https://github.com/mrdoob/three.js/blob/master/examples/js/exporters/STLBinaryExporter.js\n * see https://en.wikipedia.org/wiki/STL_(file_format)#Binary_STL for the file format description\n *\n * @return {DataView} the data\n */\n getData () {\n const triangles = this.surface.index.length / 3\n const bufferLength = triangles * 2 + triangles * 3 * 4 * 4 + 80 + 4\n const output = new IOBuffer(bufferLength)\n\n output.skip(80) // skip header\n output.writeUint32(triangles)\n\n const vector = new Vector3()\n const vectorNorm1 = new Vector3()\n const vectorNorm2 = new Vector3()\n const vectorNorm3 = new Vector3()\n\n // traversing vertices\n for (let i = 0; i < triangles; i++) {\n const indices = [\n this.surface.index[i * 3],\n this.surface.index[i * 3 + 1],\n this.surface.index[i * 3 + 2]\n ]\n\n vectorNorm1.fromArray(this.surface.normal, indices[0] * 3)\n vectorNorm2.fromArray(this.surface.normal, indices[1] * 3)\n vectorNorm3.fromArray(this.surface.normal, indices[2] * 3)\n\n vector.addVectors(vectorNorm1, vectorNorm2).add(vectorNorm3).normalize()\n\n output.writeFloat32(vector.x)\n output.writeFloat32(vector.y)\n output.writeFloat32(vector.z)\n\n for (let j = 0; j < 3; j++) {\n vector.fromArray(this.surface.position, indices[j] * 3)\n\n output.writeFloat32(vector.x) // vertices\n output.writeFloat32(vector.y)\n output.writeFloat32(vector.z)\n }\n\n output.writeUint16(0) // attribute byte count\n }\n\n return new DataView(output.buffer)\n }\n}"],"names":["CullFaceNone","CullFaceBack","CullFaceFront","PCFShadowMap","PCFSoftShadowMap","VSMShadowMap","FrontSide","BackSide","DoubleSide","NoBlending","NormalBlending","AdditiveBlending","SubtractiveBlending","MultiplyBlending","CustomBlending","AddEquation","SubtractEquation","ReverseSubtractEquation","MinEquation","MaxEquation","ZeroFactor","OneFactor","SrcColorFactor","OneMinusSrcColorFactor","SrcAlphaFactor","OneMinusSrcAlphaFactor","DstAlphaFactor","OneMinusDstAlphaFactor","DstColorFactor","OneMinusDstColorFactor","SrcAlphaSaturateFactor","NeverDepth","AlwaysDepth","LessDepth","LessEqualDepth","EqualDepth","GreaterEqualDepth","GreaterDepth","NotEqualDepth","MultiplyOperation","MixOperation","AddOperation","NoToneMapping","LinearToneMapping","ReinhardToneMapping","CineonToneMapping","ACESFilmicToneMapping","CustomToneMapping","CubeReflectionMapping","CubeRefractionMapping","EquirectangularReflectionMapping","EquirectangularRefractionMapping","CubeUVReflectionMapping","CubeUVRefractionMapping","RepeatWrapping","ClampToEdgeWrapping","MirroredRepeatWrapping","NearestFilter","NearestMipmapNearestFilter","NearestMipmapLinearFilter","LinearFilter","LinearMipmapNearestFilter","LinearMipmapLinearFilter","UnsignedByteType","ByteType","ShortType","UnsignedShortType","IntType","UnsignedIntType","FloatType","HalfFloatType","UnsignedShort4444Type","UnsignedShort5551Type","UnsignedShort565Type","UnsignedInt248Type","AlphaFormat","RGBFormat","RGBAFormat","LuminanceFormat","LuminanceAlphaFormat","DepthFormat","DepthStencilFormat","RedFormat","RedIntegerFormat","RGFormat","RGIntegerFormat","RGBIntegerFormat","RGBAIntegerFormat","RGB_S3TC_DXT1_Format","RGBA_S3TC_DXT1_Format","RGBA_S3TC_DXT3_Format","RGBA_S3TC_DXT5_Format","RGB_PVRTC_4BPPV1_Format","RGB_PVRTC_2BPPV1_Format","RGBA_PVRTC_4BPPV1_Format","RGBA_PVRTC_2BPPV1_Format","RGB_ETC1_Format","RGB_ETC2_Format","RGBA_ETC2_EAC_Format","RGBA_ASTC_4x4_Format","RGBA_ASTC_5x4_Format","RGBA_ASTC_5x5_Format","RGBA_ASTC_6x5_Format","RGBA_ASTC_6x6_Format","RGBA_ASTC_8x5_Format","RGBA_ASTC_8x6_Format","RGBA_ASTC_8x8_Format","RGBA_ASTC_10x5_Format","RGBA_ASTC_10x6_Format","RGBA_ASTC_10x8_Format","RGBA_ASTC_10x10_Format","RGBA_ASTC_12x10_Format","RGBA_ASTC_12x12_Format","RGBA_BPTC_Format","SRGB8_ALPHA8_ASTC_4x4_Format","SRGB8_ALPHA8_ASTC_5x4_Format","SRGB8_ALPHA8_ASTC_5x5_Format","SRGB8_ALPHA8_ASTC_6x5_Format","SRGB8_ALPHA8_ASTC_6x6_Format","SRGB8_ALPHA8_ASTC_8x5_Format","SRGB8_ALPHA8_ASTC_8x6_Format","SRGB8_ALPHA8_ASTC_8x8_Format","SRGB8_ALPHA8_ASTC_10x5_Format","SRGB8_ALPHA8_ASTC_10x6_Format","SRGB8_ALPHA8_ASTC_10x8_Format","SRGB8_ALPHA8_ASTC_10x10_Format","SRGB8_ALPHA8_ASTC_12x10_Format","SRGB8_ALPHA8_ASTC_12x12_Format","LinearEncoding","sRGBEncoding","GammaEncoding","RGBEEncoding","LogLuvEncoding","RGBM7Encoding","RGBM16Encoding","RGBDEncoding","BasicDepthPacking","RGBADepthPacking","TangentSpaceNormalMap","ObjectSpaceNormalMap","KeepStencilOp","AlwaysStencilFunc","StaticDrawUsage","EventDispatcher","Object","assign","prototype","addEventListener","type","listener","undefined","this","_listeners","listeners","indexOf","push","hasEventListener","removeEventListener","listenerArray","index","splice","dispatchEvent","event","target","array","slice","i","l","length","call","_lut","toString","MathUtils","DEG2RAD","Math","PI","RAD2DEG","generateUUID","d0","random","d1","d2","d3","toUpperCase","clamp","value","min","max","euclideanModulo","n","m","mapLinear","x","a1","a2","b1","b2","lerp","y","t","smoothstep","smootherstep","randInt","low","high","floor","randFloat","randFloatSpread","range","degToRad","degrees","radToDeg","radians","isPowerOfTwo","ceilPowerOfTwo","pow","ceil","log","LN2","floorPowerOfTwo","setQuaternionFromProperEuler","q","a","b","c","order","cos","sin","c2","s2","c13","s13","c1_3","s1_3","c3_1","s3_1","set","console","warn","Vector2","Matrix3","elements","arguments","error","_canvas","defineProperties","width","get","height","isVector2","setScalar","scalar","setX","setY","setComponent","Error","getComponent","clone","constructor","copy","v","add","w","addVectors","addScalar","s","addScaledVector","sub","subVectors","subScalar","multiply","multiplyScalar","divide","divideScalar","applyMatrix3","e","clampScalar","minVal","maxVal","clampLength","round","roundToZero","negate","dot","cross","lengthSq","sqrt","manhattanLength","abs","normalize","angle","atan2","distanceTo","distanceToSquared","dx","dy","manhattanDistanceTo","setLength","alpha","lerpVectors","v1","v2","equals","fromArray","offset","toArray","fromBufferAttribute","attribute","getX","getY","rotateAround","center","isMatrix3","n11","n12","n13","n21","n22","n23","n31","n32","n33","te","identity","me","extractBasis","xAxis","yAxis","zAxis","setFromMatrix3Column","setFromMatrix4","multiplyMatrices","premultiply","ae","be","a11","a12","a13","a21","a22","a23","a31","a32","a33","b11","b12","b13","b21","b22","b23","b31","b32","b33","determinant","d","f","g","h","getInverse","matrix","throwOnDegenerate","t11","t12","t13","det","detInv","transpose","tmp","getNormalMatrix","matrix4","transposeIntoArray","r","setUvTransform","tx","ty","sx","sy","rotation","cx","cy","scale","rotate","theta","translate","ImageUtils","image","test","src","HTMLCanvasElement","canvas","document","createElementNS","context","getContext","ImageData","putImageData","drawImage","toDataURL","textureId","Texture","mapping","wrapS","wrapT","magFilter","minFilter","format","anisotropy","encoding","defineProperty","uuid","name","DEFAULT_IMAGE","mipmaps","DEFAULT_MAPPING","internalFormat","repeat","matrixAutoUpdate","generateMipmaps","premultiplyAlpha","flipY","unpackAlignment","version","onUpdate","Vector4","z","WebGLRenderTarget","options","scissor","scissorTest","viewport","texture","depthBuffer","stencilBuffer","depthTexture","Quaternion","_x","_y","_z","_w","create","isTexture","updateMatrix","source","toJSON","meta","isRootObject","textures","output","metadata","generator","wrap","images","url","Array","isArray","dispose","transformUv","uv","isVector4","setZ","setW","applyMatrix4","setAxisAngleFromQuaternion","acos","setAxisAngleFromRotationMatrix","epsilon","epsilon2","m11","m12","m13","m21","m22","m23","m31","m32","m33","xx","yy","zz","xy","xz","yz","getZ","getW","isWebGLRenderTarget","setSize","slerp","qa","qb","qm","slerpFlat","dst","dstOffset","src0","srcOffset0","src1","srcOffset1","x0","y0","z0","w0","x1","y1","z1","w1","dir","sqrSin","Number","EPSILON","len","tDir","multiplyQuaternionsFlat","_onChangeCallback","isQuaternion","quaternion","setFromEuler","euler","update","isEuler","c1","c3","s1","s3","setFromAxisAngle","axis","halfAngle","setFromRotationMatrix","trace","setFromUnitVectors","vFrom","vTo","angleTo","rotateTowards","step","inverse","conjugate","p","multiplyQuaternions","qax","qay","qaz","qaw","qbx","qby","qbz","qbw","cosHalfTheta","sqrSinHalfTheta","sinHalfTheta","halfTheta","ratioA","ratioB","_onChange","callback","_vector","Vector3","_quaternion","isVector3","multiplyVectors","applyEuler","applyQuaternion","applyAxisAngle","applyNormalMatrix","qx","qy","qz","qw","ix","iy","iz","iw","project","camera","matrixWorldInverse","projectionMatrix","unproject","projectionMatrixInverse","matrixWorld","transformDirection","crossVectors","ax","ay","az","bx","by","bz","projectOnVector","denominator","projectOnPlane","planeNormal","reflect","normal","dz","setFromSpherical","setFromSphericalCoords","radius","phi","sinPhiRadius","setFromCylindrical","setFromCylindricalCoords","setFromMatrixPosition","setFromMatrixScale","setFromMatrixColumn","sz","_v1","_m1","Matrix4","_zero","_one","isMatrix4","n14","n24","n34","n41","n42","n43","n44","copyPosition","makeBasis","extractRotation","scaleX","scaleY","scaleZ","makeRotationFromEuler","af","bf","ce","cf","de","df","ac","ad","bc","bd","makeRotationFromQuaternion","compose","lookAt","eye","up","a14","a24","a34","a41","a42","a43","a44","b14","b24","b34","b41","b42","b43","b44","setPosition","t14","getMaxScaleOnAxis","scaleXSq","scaleYSq","scaleZSq","makeTranslation","makeRotationX","makeRotationY","makeRotationZ","makeRotationAxis","makeScale","makeShear","position","x2","y2","z2","wx","wy","wz","decompose","invSX","invSY","invSZ","makePerspective","left","right","top","bottom","near","far","makeOrthographic","_matrix","Euler","DefaultOrder","_order","Layers","mask","RotationOrders","asin","setFromQuaternion","setFromVector3","reorder","newOrder","toVector3","optionalResult","channel","enable","enableAll","toggle","disable","disableAll","layers","_object3DId","_q1","_target","_position","_scale","_xAxis","_yAxis","_zAxis","_addedEvent","_removedEvent","Object3D","parent","children","DefaultUp","configurable","enumerable","modelViewMatrix","normalMatrix","DefaultMatrixAutoUpdate","matrixWorldNeedsUpdate","visible","castShadow","receiveShadow","frustumCulled","renderOrder","userData","Scene","background","environment","fog","overrideMaterial","autoUpdate","__THREE_DEVTOOLS__","CustomEvent","detail","isObject3D","onBeforeRender","onAfterRender","setRotationFromAxisAngle","setRotationFromEuler","setRotationFromMatrix","setRotationFromQuaternion","rotateOnAxis","rotateOnWorldAxis","rotateX","rotateY","rotateZ","translateOnAxis","distance","translateX","translateY","translateZ","localToWorld","vector","worldToLocal","updateWorldMatrix","isCamera","isLight","object","remove","attach","getObjectById","id","getObjectByProperty","getObjectByName","getWorldPosition","updateMatrixWorld","getWorldQuaternion","getWorldScale","getWorldDirection","raycast","traverse","traverseVisible","traverseAncestors","force","updateParents","updateChildren","geometries","materials","shapes","serialize","library","element","JSON","stringify","isInstancedMesh","count","instanceMatrix","isMesh","isLine","isPoints","geometry","parameters","shape","material","uuids","extractFromCache","cache","values","key","data","recursive","parse","child","isScene","_points","_box","Box3","_v0","_v2","_f0","_f1","_f2","_center","_extents","_triangleNormal","_testAxis","Infinity","satForAxes","axes","v0","extents","j","p0","p1","p2","isBox3","setFromArray","minX","minY","minZ","maxX","maxY","maxZ","setFromBufferAttribute","setFromPoints","points","makeEmpty","il","expandByPoint","setFromCenterAndSize","size","halfSize","setFromObject","expandByObject","box","isEmpty","getCenter","getSize","point","expandByVector","expandByScalar","boundingBox","computeBoundingBox","union","containsPoint","containsBox","getParameter","intersectsBox","intersectsSphere","sphere","clampPoint","intersectsPlane","plane","constant","intersectsTriangle","triangle","distanceToPoint","getBoundingSphere","intersect","Sphere","optionalCenter","maxRadiusSq","radiusSum","deltaLengthSq","getBoundingBox","_segCenter","_segDir","_diff","_edge1","_edge2","_normal","Ray","origin","direction","ray","at","recast","closestPointToPoint","directionDistance","distanceSqToPoint","distanceSqToSegment","optionalPointOnRay","optionalPointOnSegment","segExtent","a01","b0","s0","sqrDist","extDet","invDet","intersectSphere","tca","radius2","thc","t0","t1","distanceToPlane","intersectPlane","distToPoint","intersectBox","tmin","tmax","tymin","tymax","tzmin","tzmax","invdirx","invdiry","invdirz","intersectTriangle","backfaceCulling","sign","DdN","DdQxE2","DdE1xQ","QdN","_vector1","_vector2","_normalMatrix","Plane","isPlane","setComponents","setFromNormalAndCoplanarPoint","setFromCoplanarPoints","inverseNormalLength","distanceToSphere","projectPoint","intersectLine","line","delta","start","intersectsLine","startSign","endSign","end","coplanarPoint","optionalNormalMatrix","referencePoint","_v3","_vab","_vac","_vbc","_vap","_vbp","_vcp","Triangle","getNormal","targetLengthSq","getBarycoord","dot00","dot01","dot02","dot11","dot12","denom","invDenom","u","getUV","p3","uv1","uv2","uv3","isFrontFacing","setFromPointsAndIndices","i0","i1","i2","getArea","getMidpoint","getPlane","d4","vc","d5","d6","vb","va","_colorKeywords","aliceblue","antiquewhite","aqua","aquamarine","azure","beige","bisque","black","blanchedalmond","blue","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","fuchsia","gainsboro","ghostwhite","gold","goldenrod","gray","green","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","lime","limegreen","linen","magenta","maroon","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","navy","oldlace","olive","olivedrab","orange","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","purple","rebeccapurple","red","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","silver","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","teal","thistle","tomato","turquoise","violet","wheat","white","whitesmoke","yellow","yellowgreen","_hslA","_hslB","Color","setRGB","hue2rgb","SRGBToLinear","LinearToSRGB","Face3","color","materialIndex","vertexNormals","isColor","vertexColors","setHex","setStyle","hex","setHSL","style","handleAlpha","string","parseFloat","exec","components","parseInt","charAt","setColorName","copyGammaToLinear","gammaFactor","copyLinearToGamma","safeInverse","convertGammaToLinear","convertLinearToGamma","copySRGBToLinear","copyLinearToSRGB","convertSRGBToLinear","convertLinearToSRGB","getHex","getHexString","getHSL","hue","saturation","lightness","getStyle","offsetHSL","addColors","color1","color2","lerpHSL","normalized","NAMES","materialId","Material","blending","side","flatShading","opacity","transparent","blendSrc","blendDst","blendEquation","blendSrcAlpha","blendDstAlpha","blendEquationAlpha","depthFunc","depthTest","depthWrite","stencilWriteMask","stencilFunc","stencilRef","stencilFuncMask","stencilFail","stencilZFail","stencilZPass","stencilWrite","clippingPlanes","clipIntersection","clipShadows","shadowSide","colorWrite","precision","polygonOffset","polygonOffsetFactor","polygonOffsetUnits","dithering","alphaTest","premultipliedAlpha","toneMapped","MeshBasicMaterial","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","specularMap","alphaMap","envMap","combine","reflectivity","refractionRatio","wireframe","wireframeLinewidth","wireframeLinecap","wireframeLinejoin","skinning","morphTargets","setValues","isMaterial","onBeforeCompile","customProgramCacheKey","newValue","currentValue","isRoot","roughness","metalness","sheen","emissive","emissiveIntensity","specular","shininess","clearcoat","clearcoatRoughness","clearcoatMap","clearcoatRoughnessMap","clearcoatNormalMap","clearcoatNormalScale","matcap","bumpMap","bumpScale","normalMap","normalMapType","normalScale","displacementMap","displacementScale","displacementBias","roughnessMap","metalnessMap","emissiveMap","envMapIntensity","gradientMap","sizeAttenuation","linewidth","dashSize","gapSize","morphNormals","srcPlanes","dstPlanes","isMeshBasicMaterial","BufferAttribute","itemSize","TypeError","usage","updateRange","Int8BufferAttribute","Int8Array","Uint8BufferAttribute","Uint8Array","Uint8ClampedBufferAttribute","Uint8ClampedArray","Int16BufferAttribute","Int16Array","Uint16BufferAttribute","Uint16Array","Int32BufferAttribute","Int32Array","Uint32BufferAttribute","Uint32Array","Float32BufferAttribute","Float32Array","Float64BufferAttribute","Float64Array","DirectGeometry","vertices","normals","colors","uvs","uvs2","groups","skinWeights","skinIndices","boundingSphere","verticesNeedUpdate","normalsNeedUpdate","colorsNeedUpdate","uvsNeedUpdate","groupsNeedUpdate","arrayMax","isBufferAttribute","onUploadCallback","setUsage","copyAt","index1","index2","copyArray","copyColorsArray","copyVector2sArray","vectors","copyVector3sArray","copyVector4sArray","setXY","setXYZ","setXYZW","onUpload","computeGroups","group","faces","face","fromGeometry","faceVertexUvs","hasFaceVertexUv","hasFaceVertexUv2","morphTargetsLength","morphTargetsPosition","morphNormalsLength","morphTargetsNormal","hasSkinIndices","hasSkinWeights","vertexUvs","morphTarget","morphNormal","_bufferGeometryId","_obj","_offset","_boxMorphTargets","BufferGeometry","attributes","morphAttributes","morphTargetsRelative","drawRange","isBufferGeometry","getIndex","setIndex","getAttribute","setAttribute","deleteAttribute","addGroup","clearGroups","setDrawRange","needsUpdate","tangent","computeBoundingSphere","positions","lineDistances","isGeometry","updateFromObject","direct","__directGeometry","elementsNeedUpdate","lineDistancesNeedUpdate","lineDistance","fromDirectGeometry","morphAttributesPosition","morphAttribute","isNaN","jl","computeFaceNormals","computeVertexNormals","positionAttribute","normalAttribute","pA","pB","pC","nA","nB","nC","cb","ab","vA","vB","vC","normalizeNormals","merge","attributeArray1","attribute2","attributeArray2","attributeOffset","toNonIndexed","convertBufferAttribute","indices","array2","geometry2","newAttribute","morphArray","keys","attributeData","hasMorphAttributes","attributeArray","_inverseMatrix","_ray","_sphere","_vA","_vB","_vC","_tempA","_tempB","_tempC","_morphA","_morphB","_morphC","_uvA","_uvB","_uvC","_intersectionPoint","_intersectionPointWorld","Mesh","updateMorphTargets","checkIntersection","raycaster","checkBufferGeometryIntersection","morphPosition","morphInfluences","morphTargetInfluences","influence","isSkinnedMesh","boneTransform","intersection","morphTargetDictionary","ml","String","intersects","groupMaterial","faceIndex","isMultiMaterial","fl","faceMaterial","fvA","fvB","fvC","uvs_f","_geometryId","Geometry","fromBufferGeometry","scope","addFace","areaWeighted","vl","computeFlatVertexNormals","computeMorphNormals","__originalFaceNormal","__originalVertexNormals","tmpGeo","faceNormals","dstNormalsFace","dstNormalsVertex","faceNormal","materialIndexOffset","vertexOffset","vertices1","vertices2","faces1","faces2","colors1","colors2","vertexCopy","faceCopy","faceVertexNormals","faceVertexColors","faceVertexUvs2","uvsCopy","k","kl","mergeMesh","mesh","mergeVertices","verticesMap","unique","changes","faceIndicesToRemove","idx","diff","sortFacesByMaterialIndex","_id","sort","uvs1","newUvs1","newUvs2","vertex","normalsHash","colorsHash","uvsHash","hasMaterial","hasFaceUv","hasFaceNormal","hasFaceVertexNormal","hasFaceColor","hasFaceVertexColor","faceType","setBit","getUvIndex","getNormalIndex","getColorIndex","enabled","hash","srcVertexNormal","destVertexNormal","BoxBufferGeometry","depth","widthSegments","heightSegments","depthSegments","super","numberOfVertices","groupStart","buildPlane","udir","vdir","gridX","gridY","segmentWidth","segmentHeight","widthHalf","heightHalf","depthHalf","gridX1","gridY1","vertexCounter","groupCount","cloneUniforms","property","mergeUniforms","uniforms","merged","UniformsUtils","default_vertex","default_fragment","ShaderMaterial","defines","vertexShader","fragmentShader","lights","clipping","extensions","derivatives","fragDepth","drawBuffers","shaderTextureLOD","defaultAttributeValues","index0AttributeName","uniformsNeedUpdate","Camera","PerspectiveCamera","fov","aspect","zoom","focus","view","filmGauge","filmOffset","updateProjectionMatrix","DataTexture","isShaderMaterial","isPerspectiveCamera","setFocalLength","focalLength","vExtentSlope","getFilmHeight","atan","getFocalLength","getEffectiveFOV","getFilmWidth","setViewOffset","fullWidth","fullHeight","offsetX","offsetY","clearViewOffset","skew","isDataTexture","Frustum","p4","p5","planes","frustum","setFromProjectionMatrix","me0","me1","me2","me3","me4","me5","me6","me7","me8","me9","me10","me11","me12","me13","me14","me15","intersectsObject","intersectsSprite","sprite","negRadius","UniformsLib","common","diffuse","uvTransform","uv2Transform","specularmap","envmap","flipEnvMap","maxMipLevel","aomap","lightmap","emissivemap","bumpmap","normalmap","displacementmap","roughnessmap","metalnessmap","gradientmap","fogDensity","fogNear","fogFar","fogColor","ambientLightColor","lightProbe","directionalLights","properties","directionalLightShadows","shadowBias","shadowNormalBias","shadowRadius","shadowMapSize","directionalShadowMap","directionalShadowMatrix","spotLights","coneCos","penumbraCos","decay","spotLightShadows","spotShadowMap","spotShadowMatrix","pointLights","pointLightShadows","shadowCameraNear","shadowCameraFar","pointShadowMap","pointShadowMatrix","hemisphereLights","skyColor","groundColor","rectAreaLights","WebGLAnimation","isAnimating","animationLoop","requestId","onAnimationFrame","time","frame","requestAnimationFrame","stop","cancelAnimationFrame","setAnimationLoop","setContext","WebGLAttributes","gl","capabilities","isWebGL2","buffers","WeakMap","isInterleavedBufferAttribute","deleteBuffer","buffer","delete","bufferType","createBuffer","bindBuffer","bufferData","bytesPerElement","BYTES_PER_ELEMENT","bufferSubData","subarray","updateBuffer","PlaneGeometry","PlaneBufferGeometry","width_half","height_half","segment_width","segment_height","ShaderChunk","alphamap_fragment","alphamap_pars_fragment","alphatest_fragment","aomap_fragment","aomap_pars_fragment","begin_vertex","beginnormal_vertex","bsdfs","bumpmap_pars_fragment","clipping_planes_fragment","clipping_planes_pars_fragment","clipping_planes_pars_vertex","clipping_planes_vertex","color_fragment","color_pars_fragment","color_pars_vertex","color_vertex","cube_uv_reflection_fragment","defaultnormal_vertex","displacementmap_pars_vertex","displacementmap_vertex","emissivemap_fragment","emissivemap_pars_fragment","encodings_fragment","encodings_pars_fragment","envmap_fragment","envmap_common_pars_fragment","envmap_pars_fragment","envmap_pars_vertex","envmap_physical_pars_fragment","envmap_vertex","fog_vertex","fog_pars_vertex","fog_fragment","fog_pars_fragment","gradientmap_pars_fragment","lightmap_fragment","lightmap_pars_fragment","lights_lambert_vertex","lights_pars_begin","lights_toon_fragment","lights_toon_pars_fragment","lights_phong_fragment","lights_phong_pars_fragment","lights_physical_fragment","lights_physical_pars_fragment","lights_fragment_begin","lights_fragment_maps","lights_fragment_end","logdepthbuf_fragment","logdepthbuf_pars_fragment","logdepthbuf_pars_vertex","logdepthbuf_vertex","map_fragment","map_pars_fragment","map_particle_fragment","map_particle_pars_fragment","metalnessmap_fragment","metalnessmap_pars_fragment","morphnormal_vertex","morphtarget_pars_vertex","morphtarget_vertex","normal_fragment_begin","normal_fragment_maps","normalmap_pars_fragment","clearcoat_normal_fragment_begin","clearcoat_normal_fragment_maps","clearcoat_pars_fragment","packing","premultiplied_alpha_fragment","project_vertex","dithering_fragment","dithering_pars_fragment","roughnessmap_fragment","roughnessmap_pars_fragment","shadowmap_pars_fragment","shadowmap_pars_vertex","shadowmap_vertex","shadowmask_pars_fragment","skinbase_vertex","skinning_pars_vertex","skinning_vertex","skinnormal_vertex","specularmap_fragment","specularmap_pars_fragment","tonemapping_fragment","tonemapping_pars_fragment","uv_pars_fragment","uv_pars_vertex","uv_vertex","uv2_pars_fragment","uv2_pars_vertex","uv2_vertex","worldpos_vertex","background_frag","background_vert","cube_frag","cube_vert","depth_frag","depth_vert","distanceRGBA_frag","distanceRGBA_vert","equirect_frag","equirect_vert","linedashed_frag","linedashed_vert","meshbasic_frag","meshbasic_vert","meshlambert_frag","meshlambert_vert","meshmatcap_frag","meshmatcap_vert","meshtoon_frag","meshtoon_vert","meshphong_frag","meshphong_vert","meshphysical_frag","meshphysical_vert","normal_frag","normal_vert","points_frag","points_vert","shadow_frag","shadow_vert","sprite_frag","sprite_vert","ShaderLib","basic","lambert","phong","standard","toon","dashed","totalSize","t2D","cube","equirect","tEquirect","distanceRGBA","referencePosition","nearDistance","farDistance","shadow","WebGLBackground","renderer","state","objects","clearColor","planeMesh","boxMesh","clearAlpha","currentBackground","currentBackgroundVersion","currentTonemapping","setClear","getClearColor","setClearColor","getClearAlpha","setClearAlpha","render","renderList","scene","forceClear","xr","session","getSession","environmentBlendMode","autoClear","clear","autoClearColor","autoClearDepth","autoClearStencil","isCubeTexture","isWebGLCubeRenderTarget","toneMapping","unshift","WebGLBindingStates","maxVertexAttributes","extension","vaoAvailable","bindingStates","defaultState","createBindingState","currentState","bindVertexArrayObject","vao","bindVertexArray","bindVertexArrayOES","deleteVertexArrayObject","deleteVertexArray","deleteVertexArrayOES","newAttributes","enabledAttributes","attributeDivisors","program","initAttributes","enableAttribute","enableAttributeAndDivisor","meshPerAttribute","enableVertexAttribArray","disableUnusedAttributes","disableVertexAttribArray","vertexAttribPointer","stride","vertexAttribIPointer","reset","resetDefaultState","setup","updateBuffers","programMap","stateMap","createVertexArray","createVertexArrayOES","getBindingState","cachedAttributes","geometryAttributes","cachedAttribute","geometryAttribute","saveCache","isInstancedBufferGeometry","programAttributes","getAttributes","materialDefaultAttributeValues","programAttribute","isInstancedInterleavedBuffer","_maxInstanceCount","isInstancedBufferAttribute","vertexAttrib2fv","vertexAttrib3fv","vertexAttrib4fv","vertexAttrib1fv","setupVertexAttributes","geometryId","programId","releaseStatesOfGeometry","releaseStatesOfProgram","WebGLBufferRenderer","info","mode","setMode","drawArrays","renderInstances","primcount","methodName","WebGLCapabilities","maxAnisotropy","getMaxPrecision","getShaderPrecisionFormat","WebGL2RenderingContext","WebGL2ComputeRenderingContext","maxPrecision","logarithmicDepthBuffer","maxTextures","maxVertexTextures","maxTextureSize","maxCubemapSize","maxAttributes","maxVertexUniforms","maxVaryings","maxFragmentUniforms","vertexTextures","floatFragmentTextures","getMaxAnisotropy","MAX_TEXTURE_MAX_ANISOTROPY_EXT","floatVertexTextures","maxSamples","WebGLClipping","globalState","numGlobalPlanes","localClippingEnabled","renderingShadows","viewNormalMatrix","uniform","resetGlobalState","numPlanes","numIntersection","projectPlanes","skipTransform","nPlanes","dstArray","flatSize","viewMatrix","i4","init","enableLocalClipping","beginShadows","endShadows","setState","fromCache","nGlobal","lGlobal","clippingState","WebGLExtensions","getExtension","WebGLGeometries","wireframeAttributes","onGeometryDispose","buffergeometry","memory","updateWireframeAttribute","geometryIndex","geometryPosition","previousAttribute","_bufferGeometry","getWireframeAttribute","currentAttribute","WebGLIndexedBufferRenderer","drawElements","WebGLInfo","calls","triangles","lines","programs","autoReset","instanceCount","numericalSort","absNumericalSort","WebGLMorphtargets","influencesList","workInfluences","objectInfluences","influences","MAX_SAFE_INTEGER","morphInfluencesSum","morphBaseInfluence","getUniforms","setValue","WebGLObjects","updateMap","CubeTexture","DataTexture2DArray","wrapR","DataTexture3D","physical","transparency","isDataTexture2DArray","isDataTexture3D","emptyTexture","emptyTexture2dArray","emptyTexture3d","emptyCubeTexture","arrayCacheF32","arrayCacheI32","mat4array","mat3array","mat2array","flatten","nBlocks","blockSize","firstElem","arraysEqual","allocTexUnits","allocateTextureUnit","setValueV1f","uniform1f","addr","setValueV2f","uniform2f","uniform2fv","setValueV3f","uniform3f","uniform3fv","setValueV4f","uniform4f","uniform4fv","setValueM2","uniformMatrix2fv","setValueM3","uniformMatrix3fv","setValueM4","uniformMatrix4fv","setValueT1","unit","uniform1i","safeSetTexture2D","setValueT2DArray1","setTexture2DArray","setValueT3D1","setTexture3D","setValueT6","safeSetTextureCube","setValueV1i","setValueV2i","uniform2iv","setValueV3i","uniform3iv","setValueV4i","uniform4iv","setValueV1ui","uniform1ui","setValueV1fArray","uniform1fv","setValueV1iArray","uniform1iv","setValueV2iArray","setValueV3iArray","setValueV4iArray","setValueV2fArray","setValueV3fArray","setValueV4fArray","setValueM2Array","setValueM3Array","setValueM4Array","setValueT1Array","units","setValueT6Array","SingleUniform","activeInfo","getSingularSetter","PureArrayUniform","getPureArraySetter","StructuredUniform","seq","updateCache","RePathPart","addUniform","container","uniformObject","parseUniform","path","pathLength","lastIndex","match","matchEnd","idIsIndex","subscript","next","WebGLUniforms","getProgramParameter","getActiveUniform","getUniformLocation","WebGLShader","shader","createShader","shaderSource","compileShader","setOptional","upload","seqWithValue","programIdCount","getEncodingComponents","getShaderErrors","status","getShaderParameter","getShaderInfoLog","trim","split","join","addLineNumbers","getShaderSource","getTexelDecodingFunction","functionName","getTexelEncodingFunction","getToneMappingFunction","toneMappingName","filterEmptyLine","replaceLightNums","replace","numDirLights","numSpotLights","numRectAreaLights","numPointLights","numHemiLights","numDirLightShadows","numSpotLightShadows","numPointLightShadows","replaceClippingPlaneNums","numClippingPlanes","numClipIntersection","includePattern","resolveIncludes","includeReplacer","include","deprecatedUnrollLoopPattern","unrollLoopPattern","unrollLoops","loopReplacer","deprecatedLoopReplacer","snippet","generatePrecision","precisionstring","WebGLProgram","cacheKey","shadowMapTypeDefine","shadowMapType","generateShadowMapTypeDefine","envMapTypeDefine","envMapMode","generateEnvMapTypeDefine","envMapModeDefine","generateEnvMapModeDefine","envMapBlendingDefine","generateEnvMapBlendingDefine","gammaFactorDefine","customExtensions","extensionDerivatives","envMapCubeUV","tangentSpaceNormalMap","shaderID","extensionFragDepth","rendererExtensionFragDepth","extensionDrawBuffers","rendererExtensionDrawBuffers","extensionShaderTextureLOD","rendererExtensionShaderTextureLod","filter","generateExtensions","customDefines","chunks","generateDefines","createProgram","prefixVertex","prefixFragment","isRawShaderMaterial","shaderName","instancing","supportsVertexTextures","maxBones","useFog","fogExp2","objectSpaceNormalMap","vertexTangents","uvsVertexOnly","useVertexTexture","doubleSided","flipSided","shadowMapEnabled","physicallyCorrectLights","mapEncoding","matcapEncoding","envMapEncoding","emissiveMapEncoding","lightMapEncoding","outputEncoding","depthPacking","isGLSL3ShaderMaterial","versionRegex","fragmentGlsl","glVertexShader","glFragmentShader","attachShader","bindAttribLocation","linkProgram","debug","checkShaderErrors","programLog","getProgramInfoLog","vertexLog","fragmentLog","runnable","haveDiagnostics","vertexErrors","fragmentErrors","getError","diagnostics","prefix","cachedUniforms","deleteShader","getActiveAttrib","getAttribLocation","fetchAttributeLocations","destroy","deleteProgram","usedTimes","WebGLPrograms","shaderIDs","MeshDepthMaterial","MeshDistanceMaterial","MeshNormalMaterial","MeshLambertMaterial","MeshPhongMaterial","MeshToonMaterial","MeshStandardMaterial","MeshPhysicalMaterial","MeshMatcapMaterial","LineBasicMaterial","LineDashedMaterial","PointsMaterial","ShadowMaterial","SpriteMaterial","parameterNames","getTextureEncodingFromMap","getParameters","shadows","nClipPlanes","nClipIntersection","isMeshStandardMaterial","bones","skeleton","nVertexUniforms","nVertexMatrices","allocateBones","shaderobject","getShaderObject","currentRenderTarget","getRenderTarget","isFogExp2","maxMorphTargets","maxMorphNormals","directional","spot","rectArea","hemi","shadowMap","getProgramCacheKey","acquireProgram","pl","preexistingProgram","releaseProgram","pop","WebGLProperties","painterSortStable","groupOrder","reversePainterSortStable","WebGLRenderList","renderItems","renderItemsIndex","opaque","defaultProgram","getNextRenderItem","renderItem","finish","customOpaqueSort","customTransparentSort","WebGLRenderLists","lists","onSceneDispose","cameras","list","UniformsCache","light","halfWidth","halfHeight","nextVersion","shadowCastingLightsFirst","lightA","lightB","WebGLLights","shadowCache","ShadowUniformsCache","directionalLength","pointLength","spotLength","rectAreaLength","hemiLength","numDirectionalShadows","numPointShadows","numSpotShadows","ambient","probe","directionalShadow","spotShadow","pointShadow","vector3","matrix42","intensity","isAmbientLight","isLightProbe","sh","coefficients","isDirectionalLight","shadowUniforms","bias","normalBias","mapSize","isSpotLight","penumbra","isRectAreaLight","isPointLight","isHemisphereLight","WebGLRenderState","lightsArray","shadowsArray","setupLights","pushLight","pushShadow","shadowLight","WebGLRenderStates","renderStates","renderState","has","isMeshDepthMaterial","isMeshDistanceMaterial","vsm_frag","vsm_vert","WebGLShadowMap","_renderer","_objects","_frustum","_shadowMapSize","_viewportSize","_viewport","_depthMaterials","_distanceMaterials","_materialCache","shadowMaterialVertical","SAMPLE_RATE","HALF_SAMPLE_RATE","shadow_pass","resolution","shadowMaterialHorizonal","HORIZONAL_PASS","fullScreenTri","fullScreenMesh","VSMPass","setRenderTarget","mapPass","renderBufferDirect","getDepthMaterialVariant","useMorphing","useSkinning","useInstancing","getDistanceMaterialVariant","getDepthMaterial","result","getMaterialVariant","customMaterial","customDepthMaterial","customDistanceMaterial","keyA","keyB","materialsForVariant","cachedMaterial","renderObject","shadowCamera","depthMaterial","activeCubeFace","getActiveCubeFace","activeMipmapLevel","getActiveMipmapLevel","_state","setBlending","setTest","setScissorTest","shadowFrameExtents","getFrameExtents","isPointLightShadow","pars","viewportCount","getViewportCount","vp","getViewport","updateMatrices","getFrustum","WebGLState","colorBuffer","locked","currentColorMask","currentColorClear","setMask","colorMask","setLocked","lock","currentDepthMask","currentDepthFunc","currentDepthClear","depthMask","setFunc","clearDepth","currentStencilMask","currentStencilFunc","currentStencilRef","currentStencilFuncMask","currentStencilFail","currentStencilZFail","currentStencilZPass","currentStencilClear","stencilTest","stencilMask","setOp","stencilOp","stencil","clearStencil","enabledCapabilities","currentProgram","currentBlendingEnabled","currentBlending","currentBlendEquation","currentBlendSrc","currentBlendDst","currentBlendEquationAlpha","currentBlendSrcAlpha","currentBlendDstAlpha","currentPremultipledAlpha","currentFlipSided","currentCullFace","currentLineWidth","currentPolygonOffsetFactor","currentPolygonOffsetUnits","lineWidthAvailable","glVersion","currentTextureSlot","currentBoundTextures","currentScissor","currentViewport","createTexture","bindTexture","texParameteri","texImage2D","emptyTextures","setFlipSided","setCullFace","equationToGL","MIN_EXT","MAX_EXT","factorToGL","blendEquationSeparate","blendFuncSeparate","blendFunc","frontFace","cullFace","setPolygonOffset","factor","activeTexture","webglSlot","useProgram","setMaterial","frontFaceCW","setLineWidth","lineWidth","webglType","webglTexture","boundTexture","unbindTexture","compressedTexImage2D","apply","texImage3D","WebGLTextures","_gl","utils","_videoTextures","useOffscreenCanvas","OffscreenCanvas","err","createCanvas","resizeImage","needsPowerOfTwo","needsNewCanvas","maxSize","HTMLImageElement","ImageBitmap","textureNeedsGenerateMipmaps","supportsMips","generateMipmap","__maxMipLevel","LOG2E","getInternalFormat","internalFormatName","glFormat","glType","filterFallback","onTextureDispose","textureProperties","__webglInit","deleteTexture","__webglTexture","deallocateTexture","isVideoTexture","onRenderTargetDispose","renderTarget","renderTargetProperties","deleteFramebuffer","__webglFramebuffer","__webglDepthbuffer","deleteRenderbuffer","__webglMultisampledFramebuffer","__webglColorRenderbuffer","__webglDepthRenderbuffer","deallocateRenderTarget","textureUnits","setTexture2D","slot","updateVideoTexture","__version","complete","uploadTexture","setTextureCube","initTexture","pixelStorei","isCompressed","isCompressedTexture","cubeImage","convert","glInternalFormat","setTextureParameters","mipmap","mipmapImage","setTextureCubeDynamic","wrappingToGL","filterToGL","textureType","__currentAnisotropy","texParameterf","TEXTURE_MAX_ANISOTROPY_EXT","textureNeedsPowerOfTwo","isDepthTexture","setupFrameBufferTexture","framebuffer","attachment","textureTarget","bindFramebuffer","framebufferTexture2D","setupRenderBufferStorage","renderbuffer","isMultisample","bindRenderbuffer","samples","getRenderTargetSamples","renderbufferStorageMultisample","renderbufferStorage","framebufferRenderbuffer","setupDepthRenderbuffer","isCube","webglDepthTexture","setupDepthTexture","createRenderbuffer","isWebGLMultisampleRenderTarget","warnedTexture2D","warnedTextureCube","textureUnit","resetTextureUnits","setupRenderTarget","createFramebuffer","updateRenderTargetMipmap","updateMultisampleRenderTarget","blitFramebuffer","WebGLUtils","HALF_FLOAT_OES","COMPRESSED_RGB_S3TC_DXT1_EXT","COMPRESSED_RGBA_S3TC_DXT1_EXT","COMPRESSED_RGBA_S3TC_DXT3_EXT","COMPRESSED_RGBA_S3TC_DXT5_EXT","COMPRESSED_RGB_PVRTC_4BPPV1_IMG","COMPRESSED_RGB_PVRTC_2BPPV1_IMG","COMPRESSED_RGBA_PVRTC_4BPPV1_IMG","COMPRESSED_RGBA_PVRTC_2BPPV1_IMG","COMPRESSED_RGB_ETC1_WEBGL","COMPRESSED_RGB8_ETC2","COMPRESSED_RGBA8_ETC2_EAC","UNSIGNED_INT_24_8_WEBGL","ArrayCamera","Group","WebXRController","_targetRay","_grip","WebXRManager","framebufferScaleFactor","referenceSpace","referenceSpaceType","pose","controllers","inputSourcesMap","Map","cameraL","cameraR","cameraVR","_currentDepthNear","_currentDepthFar","onSessionEvent","controller","inputSource","onSessionEnd","forEach","disconnect","setFramebuffer","animation","isPresenting","onRequestReferenceSpace","updateInputSources","inputSources","removed","added","getController","getTargetRaySpace","getControllerGrip","getGripSpace","setFramebufferScaleFactor","setReferenceSpaceType","getReferenceSpace","setSession","getContextAttributes","xrCompatible","makeXRCompatible","layerInit","antialias","baseLayer","XRWebGLLayer","updateRenderState","requestReferenceSpace","then","cameraLPos","cameraRPos","updateCamera","getCamera","depthNear","depthFar","ipd","projL","projR","topFov","bottomFov","leftFov","rightFov","zOffset","xOffset","near2","far2","left2","right2","top2","bottom2","setProjectionFromUnion","onAnimationFrameCallback","getViewerPose","views","cameraVRNeedsUpdate","transform","WebGLMaterials","refreshUniformsCommon","uvScaleMap","uv2ScaleMap","refreshUniformsStandard","refreshFogUniforms","isFog","density","refreshMaterialUniforms","pixelRatio","isMeshLambertMaterial","refreshUniformsLambert","isMeshToonMaterial","refreshUniformsToon","isMeshPhongMaterial","refreshUniformsPhong","isMeshPhysicalMaterial","refreshUniformsPhysical","isMeshMatcapMaterial","refreshUniformsMatcap","refreshUniformsDepth","refreshUniformsDistance","isMeshNormalMaterial","refreshUniformsNormal","isLineBasicMaterial","refreshUniformsLine","isLineDashedMaterial","refreshUniformsDash","isPointsMaterial","refreshUniformsPoints","isSpriteMaterial","refreshUniformsSprites","isShadowMaterial","WebGLRenderer","_context","_alpha","_depth","_stencil","_antialias","_premultipliedAlpha","_preserveDrawingBuffer","preserveDrawingBuffer","_powerPreference","powerPreference","_failIfMajorPerformanceCaveat","failIfMajorPerformanceCaveat","currentRenderList","currentRenderState","domElement","sortObjects","toneMappingExposure","_this","_isContextLost","_framebuffer","_currentActiveCubeFace","_currentActiveMipmapLevel","_currentRenderTarget","_currentFramebuffer","_currentMaterialId","_currentCamera","_currentArrayCamera","_currentViewport","_currentScissor","_currentScissorTest","_width","_height","_pixelRatio","_opaqueSort","_transparentSort","_scissor","_scissorTest","_clipping","_clippingEnabled","_localClippingEnabled","_projScreenMatrix","_vector3","_emptyScene","getTargetPixelRatio","programCache","renderLists","morphtargets","bufferRenderer","indexedBufferRenderer","contextNames","contextAttributes","contextName","onContextLost","onContextRestore","isWebGL1Renderer","shift","rangeMin","rangeMax","message","initGLContext","preventDefault","onMaterialDispose","releaseMaterialProgramReference","deallocateMaterial","programInfo","forceContextLoss","loseContext","forceContextRestore","restoreContext","getPixelRatio","setPixelRatio","updateStyle","setViewport","getDrawingBufferSize","setDrawingBufferSize","getCurrentViewport","getScissor","setScissor","getScissorTest","boolean","setOpaqueSort","method","setTransparentSort","bits","renderBufferImmediate","hasPositions","hasNormals","hasUvs","hasColors","setProgram","rangeFactor","dataCount","rangeStart","rangeCount","drawStart","drawEnd","drawCount","isLineSegments","isLineLoop","isSprite","compile","compiled","material2","initMaterial","projectObject","isGroup","isLOD","isImmediateRenderObject","renderObjects","isArrayCamera","camera2","renderObjectImmediate","materialProperties","lightsStateVersion","programCacheKey","programChange","numSupportedMorphTargets","numSupportedMorphNormals","needsLights","materialNeedsLights","progUniforms","uniformsList","useCache","refreshProgram","refreshMaterial","refreshLights","p_uniforms","m_uniforms","uCamPos","cameraPosition","isOrthographicCamera","boneTexture","boneMatrices","boneTextureSize","ltc_1","LTC_1","ltc_2","LTC_2","window","opaqueObjects","transparentObjects","readRenderTargetPixels","activeCubeFaceIndex","restore","textureFormat","checkFramebufferStatus","readPixels","copyFramebufferToTexture","level","levelScale","copyTexImage2D","copyTextureToTexture","srcTexture","dstTexture","texSubImage2D","compressedTexSubImage2D","Fog","linecap","linejoin","inputPose","gripPose","targetRay","grip","getPose","targetRaySpace","gripSpace","_start","_end","Line","computeLineDistances","threshold","params","localThreshold","localThresholdSq","vStart","vEnd","interSegment","interRay","nbVertices","LineSegments","Points","testPoint","rayPointDistanceSq","intersectPoint","distanceToRay","CanvasTexture","PolyhedronGeometry","PolyhedronBufferGeometry","vertexBuffer","uvBuffer","subdivideFace","cols","aj","bj","rows","pushVertex","getVertexByIndex","correctUV","azimuth","subdivide","applyRadius","centroid","uvA","uvB","uvC","azi","correctUVs","correctSeam","generateUVs","TetrahedronGeometry","TetrahedronBufferGeometry","OctahedronGeometry","OctahedronBufferGeometry","IcosahedronGeometry","IcosahedronBufferGeometry","TorusGeometry","tube","radialSegments","tubularSegments","arc","TorusBufferGeometry","CylinderGeometry","radiusTop","radiusBottom","openEnded","thetaStart","thetaLength","CylinderBufferGeometry","indexArray","generateCap","centerIndexStart","centerIndexEnd","cosTheta","sinTheta","slope","indexRow","generateTorso","ConeGeometry","ConeBufferGeometry","Light","LightShadow","_frameExtents","_viewportCount","_viewports","SpotLightShadow","SpotLight","power","OrthographicCamera","AmbientLight","isCanvasTexture","_lightPositionWorld","_lookTarget","shadowMatrix","projScreenMatrix","lookTarget","lightPositionWorld","viewportIndex","isSpotLightShadow","scaleW","scaleH","_eyeRight","_eyeLeft","StereoCamera","eyeSep","_cache","Uniform","getQuery","RegExp","location","search","decodeURIComponent","defaults","defaultValue","createParams","defaultParams","o","updateParams","newParams","getProtocol","protocol","getBrowser","ua","navigator","userAgent","openUrl","open","href","download","downloadName","isSafari","isChromeIos","createElement","str","msSaveOrOpenBlob","FileReader","Blob","reader","onloadend","readAsDataURL","objectUrlCreated","URL","createObjectURL","display","body","appendChild","click","removeChild","revokeObjectURL","lexicographicCompare","elm1","elm2","binarySearchIndexOf","compareFunction","mid","cmp","rangeInSortedArray","indexLeft","leftRange","binarySearchForLeftRange","indexRight","rightRange","binarySearchForRightRange","uniqueArray","sorted","uint8ToString","u8a","chunkSize","fromCharCode","getTypedArray","arrayType","arraySize","getUintArray","sizeOrArray","maxUint","ensureBuffer","ArrayBuffer","_ensureClassFromArray","ensureVector3","ensureMatrix4","ensureQuaternion","ensureFloat32Array","arg","toLowerCaseString","toLowerCase","eyeSepHalf","eyeSepOnProjection","ymax","xmin","xmax","Registry","_dict","names","deg","chars","rnd","spline","tension","t2","LAB_CONSTANTS","PITHIRD","TWOPI","_average_lrgb","_guess_formats","_guess_formats_sorted","_input","_interpolators","bezier","blend","blend_f","brewer","burn","chroma","clip_rgb","cmyk2rgb","css2rgb","darken","dodge","each","hcg2rgb","hex2rgb","hsi2rgb","hsl2css","hsl2rgb","hsv2rgb","interpolate","interpolate_hsx","interpolate_lab","interpolate_lrgb","interpolate_num","interpolate_rgb","lab2lch","lab2rgb","lab_xyz","lch2lab","lch2rgb","lighten","limit","luminance_x","num2rgb","overlay","rgb2cmyk","rgb2css","rgb2hcg","rgb2hex","rgb2hsi","rgb2hsl","rgb2hsv","rgb2lab","rgb2lch","rgb2luminance","rgb2num","rgb2temperature","rgb2xyz","rgb_xyz","screen","temperature2rgb","unpack","w3cx11","xyz_lab","xyz_rgb","classToType","ref","obj","strType","args","rgb","_clipped","_unclipped","func","ctor","module","exports","chk","len1","_rgb","OrRd","PuBu","BuPu","Oranges","BuGn","YlOrBr","YlGn","Reds","RdPu","Greens","YlGnBu","Purples","GnBu","Greys","YlOrRd","PuRd","Blues","PuBuGn","Viridis","Spectral","RdYlGn","RdBu","PiYG","PRGn","RdYlBu","BrBG","RdGy","PuOr","Set2","Accent","Set1","Set3","Dark2","Paired","Pastel2","Pastel1","results","cornflower","laserlemon","lightgoldenrod","maroon2","maroon3","purple2","purple3","Yn","Xn","Zn","Kn","t3","ref1","lab","concat","I","I0","I1","lab0","lab1","lab2","lab3","ref2","cubehelix","rotations","gamma","dh","dl","fract","amp","cos_a","sin_a","code","col1","col2","interpol","res","mix","rgba","lrgb","xyz0","xyz1","xyz","average","A","cnt","first","xyz2","substr","css","channels","hxa","NaN","hsl","ref3","ref4","ref5","hsv","num","_c","_g","hcg","aa","named","L","lch","hcl","reverse","cmyk","luminance","lum","cur_lum","max_iter","lm","kelvin","temp","maxTemp","minTemp","temperature","K","contrast","l1","l2","sum_sq","deltaE","C","L1","L2","c4","delA","delB","delC","h1","sc","sl","v3","modechan","clipped","amount","brighten","darker","brighter","saturate","desaturate","c0","out","analyze","val","MAX_VALUE","sum","domain","limits","_classes","_colorCache","_colors","_correctLightness","_domain","_gamma","_max","_min","_mode","_nacol","_out","_padding","_pos","_spread","_useCache","getClass","getColor","resetCache","setColors","tmap","col","bypassMap","classes","_m","_o","spread","correctLightness","L0","L_actual","L_diff","L_ideal","pol","padding","numColors","dd","dm","nodata","scales","cool","hot","visit","ag","ah","ai","ak","al","am","assignments","best","centroids","cluster","clusterSizes","dist","kClusters","max_log","min_log","mindist","nb_iters","newCentroids","pb","pr","ref10","ref11","ref12","ref13","ref14","ref6","ref7","ref8","ref9","tmpKMeansBreaks","LOG10E","hsi","hue0","hue1","lbv0","lbv1","sat","sat0","sat1","n1","n2","colorSpace","ScaleDefaultParameters","tmpColor","manageColor","_name","descriptor","originalMethod","fromTo","bind","Colormaker","structure","atomProxy","getAtomProxy","getScale","chroma\n .scale","colorToArray","atomColorToArray","atom","atomColor","bondColor","bond","atomIndex1","atomIndex2","bondColorToArray","volumeColorToArray","volumeColor","positionColorToArray","coords","positionColor","kwd","global","SignalBinding","signal","isOnce","listenerContext","priority","_listener","_isOnce","_signal","_priority","validateListener","fnName","Signal","_bindings","_prevParams","self","dispatch","active","execute","paramsArr","handlerReturn","detach","isBound","getListener","getSignal","_destroy","VERSION","memorize","_shouldPropagate","_registerListener","binding","prevIndex","_indexOfListener","_addBinding","cur","addOnce","removeAll","getNumListeners","halt","bindings","forget","signals","SelectAllKeyword","SelectNoneKeyword","AtomOnlyKeywords","BACKBONE","SIDECHAIN","BONDED","RING","AROMATICRING","METAL","POLARH","ChainKeywords","POLYMER","WATER","SmallResname","NucleophilicResname","HydrophobicResname","AromaticResname","AmideResname","AcidicResname","BasicResname","ChargedResname","PolarResname","NonpolarResname","CyclicResname","AliphaticResname","atomTestFn","atomname","altloc","atomindex","keyword","inscode","resname","sstruc","resno","chainname","model","isBackbone","isSidechain","isBonded","isRing","isAromatic","HETERO","isHetero","PROTEIN","isProtein","NUCLEIC","isNucleic","RNA","isRna","DNA","isDna","isPolymer","isWater","HELIX","isHelix","SHEET","isSheet","TURN","isTurn","ION","isIon","SACCHARIDE","isSaccharide","isMetal","isPolarHydrogen","includes","modelIndex","residueTestFn","atomOffset","atomEnd","chainTestFn","entity","modelTestFn","makeTest","selection","fn","rules","subTests","hasOwnProperty","and","operator","na","ret","ALL","NONE","filtered","fs","makeAtomTest","atomOnly","filteredSelection","makeResidueTest","residueOnly","makeChainTest","chainOnly","makeModelTest","modelOnly","Selection","stringChanged","setString","silent","retSelection","newSelection","oldSelection","selectionStack","createNewContext","getPrevContext","pushRule","rule","not","cu","lastRule","indexList","resnameList","sele","substring","chain","negate2","resi","resiSingle","resiRange","parseSele","residueTest","chainTest","modelTest","atomOnlyTest","residueOnlyTest","chainOnlyTest","modelOnlyTest","isAllSelection","isNoneSelection","SelectionColormaker","colormakerList","selectionList","dataList","scheme","ColormakerRegistry","hasScheme","getScheme","ColormakerScales","rainbow","rwb","ColormakerModes","getWorkerDeps","vars","deps","sym","__deps","makeWorkerString","onmessage","__name","postId","__postId","aMessage","transferList","postMessage","makeWorkerBlob","Browser","SupportsPassiveEventHandler","opts","Mobile","orientation","SupportsReadPixelsFloat","setSupportsReadPixelsFloat","ExtensionFragDepth","setExtensionFragDepth","Log","Function","timeEnd","MeasurementDefaultParams","labelColor","labelAttachment","labelSize","labelZOffset","labelYOffset","labelBorder","labelBorderColor","labelBorderWidth","lineOpacity","labelUnit","arcVisible","planeVisible","Debug","ScriptExtensions","WorkerRegistry","activeWorkerCount","_funcDict","_depsDict","_blobDict","schemes","userSchemes","SchemeClass","getSchemes","types","getScales","getModes","addScheme","label","_createScheme","_addUserScheme","removeScheme","_Colormaker","addSelectionScheme","DatasourceRegistry","RepresentationRegistry","ParserRegistry","__hasObjName","objName","parser","__objName","isTrajectory","isStructure","isVolume","isSurface","isBinary","isXml","isJson","getTrajectoryExtensions","getStructureExtensions","getVolumeExtensions","getSurfaceExtensions","ShaderRegistry","DecompressorRegistry","ComponentRegistry","BufferRegistry","PickerRegistry","ListingDatasource","TrajectoryDatasource","Streamer","newline","__pointer","__partialLine","compressed","binary","json","xml","read","_read","decompressFn","_chunk","chunk","peekLines","charCodeAt","chunkToLines","chunkCount","asText","partialLine","isLast","lastIndexOf","str2","nextChunk","nextChunkOfLines","eachChunk","eachChunkOfLines","chunkNo","FileStreamer","Promise","resolve","reject","file","onload","onerror","readAsArrayBuffer","readAsText","NetworkStreamer","xhr","XMLHttpRequest","response","statusText","responseType","send","Loader","ext","streamerParams","File","streamer","ParserLoader","parserParams","voxelSize","firstModelOnly","asTrajectory","cAlphaOnly","delimiter","comment","columnNames","inferBonds","load","Script","functionBody","elementAdded","elementRemoved","nameChanged","run","stage","ScriptLoader","getFileInfo","compressedExtList","queryIndex","query","base","nameSplit","protocolMatch","getDataInfo","datasource","getUrl","getExt","autoLoad","loader","re","not_string","not_bool","not_type","not_primitive","number","numeric_arg","not_json","text","modulo","placeholder","key_access","index_access","sprintf","parse_tree","argv","ph","pad","pad_character","pad_length","is_positive","cursor","tree_length","param_no","toExponential","toFixed","toPrecision","valueOf","pad_char","align","sprintf_format","fmt","sprintf_cache","_fmt","arg_names","SyntaxError","field_list","replacement_field","field_match","sprintf_parse","vsprintf","Writer","getBlob","getData","mimeType","defaultName","defaultExt","charArray","IOBuffer","_mark","_marks","littleEndian","dataIsGiven","byteLength","dvOffset","byteOffset","_lastWrittenByte","_data","DataView","available","isLittleEndian","setLittleEndian","isBigEndian","setBigEndian","skip","seek","mark","pushMark","popMark","rewind","ensureAvailable","newLength","newArray","readBoolean","readUint8","readInt8","getInt8","getUint8","readByte","readBytes","bytes","readInt16","getInt16","readUint16","getUint16","readInt32","getInt32","readUint32","getUint32","readFloat32","getFloat32","readFloat64","getFloat64","readChar","readChars","writeBoolean","writeUint8","writeInt8","setInt8","_updateLastWrittenByte","setUint8","writeByte","writeBytes","writeInt16","setInt16","writeUint16","setUint16","writeInt32","setInt32","writeUint32","setUint32","writeFloat32","setFloat32","writeFloat64","setFloat64","writeChar","writeChars","Counter","countChanged","signalsWrapper.Signal","change","increment","decrement","listen","counter","unlisten","onZeroOnce","Stats","updated","maxDuration","minDuration","avgDuration","lastDuration","prevFpsTime","lastFps","lastFrames","frames","begin","startTime","currentTime","performance","now","reInclude","shaderCache","getShader","definesText","getDefines","shaderText","WebGLRenderingContext","wrcp","_getShaderParameter","_getShaderInfoLog","_getProgramParameter","pname","LINK_STATUS","_getProgramInfoLog","JitterVectors","offsetList","TiledRenderer","viewer","_viewer","_factor","_onProgress","onProgress","_onFinish","onFinish","_n","_ctx","_viewerSampleLevel","sampleLevel","setSampling","_renderTile","_finalize","renderAsync","setTimeout","TwoPI","circularMean","cosMean","sinMean","calculateCenterArray","array1","calculateDirectionArray","uniformArray","optionalTarget","uniformArray3","serialArray","serialBlockArray","replicateArrayEntries","repArr","srcOffset","copyWithin","arrayMin","arraySum","arrayMean","ImageDefaultParameters","makeImage","originalClearAlpha","backgroundColor","setLineWidthAndPixelSize","invert","__seen","trimCanvas","bg","canvasHeight","canvasWidth","pixels","getImageData","doBreak","off","topY","topX","bottomY","bottomX","trimedCanvas","_trimCanvas","finished","tiledRenderer","toBlob","blob","requestRender","modelViewProjectionMatrix","projectionMatrixTranspose","updateCameraUniforms","loadShader","shaderType","COMPILE_STATUS","TextureTestTexCoords","testTextureSupport","vertShader","VERTEX_SHADER","fragShader","FRAGMENT_SHADER","shaders","attribs","locations","attrib","positionLocation","colorLoc","positionBuffer","ARRAY_BUFFER","STATIC_DRAW","FLOAT","whiteTex","whiteData","TEXTURE_2D","RGBA","UNSIGNED_BYTE","tex","TEXTURE_MIN_FILTER","NEAREST","TEXTURE_MAG_FILTER","fb","FRAMEBUFFER","COLOR_ATTACHMENT0","FRAMEBUFFER_COMPLETE","TRIANGLES","COLOR_BUFFER_BIT","pixel","floatPixel","NO_ERROR","INVALID_ENUM","INVALID_VALUE","INVALID_OPERATION","INVALID_FRAMEBUFFER_OPERATION","OUT_OF_MEMORY","CONTEXT_LOST_WEBGL","getErrorDescription","pixelBufferFloat","pixelBufferUint","pixelOrder","tmpMatrix","updateList","objectId","modelViewMatrixInverse","modelViewMatrixInverseTranspose","modelViewProjectionMatrixInverse","pu","Viewer","idOrElement","boundingBoxSize","boundingBoxLength","distVector","ticked","rendered","elm","getElementById","HTMLElement","innerWidth","innerHeight","getBoundingClientRect","overflow","wrapper","_initParams","_initStats","_initCamera","_initScene","_initRenderer","_initHelper","setBackground","setFog","animate","cameraType","cameraFov","cameraEyeSep","cameraZ","clipNear","clipFar","clipDist","clipMode","clipScale","lightColor","lightIntensity","ambientColor","ambientIntensity","rendererEncoding","perspectiveCamera","orthographicCamera","stereoCamera","stats","rotationGroup","translationGroup","modelGroup","pickingGroup","backgroundGroup","helperGroup","spotLight","ambientLight","dpr","devicePixelRatio","innerHTML","supportsHalfFloat","dprWidth","dprHeight","OES_texture_float","OES_texture_half_float","WEBGL_color_buffer_float","pickingTarget","sampleTarget","holdTarget","compositeUniforms","tForeground","compositeMaterial","compositeCamera","compositeScene","bbGeometry","bbMaterial","uColor","boundingBoxMesh","updateHelper","cameraDistance","instanceList","instance","addBuffer","wireframeGroup","pickable","setUserData","getMesh","wireframeMesh","getWireframeMesh","pickingMesh","getPickingMesh","_updateBoundingBox","updateBoundingBox","updateGeometry","geoBoundingBox","updateNode","node","getPickingPixels","imgBuffer","getImage","picking","imgBuffer2","ctx","imgData","setLight","setOutputEncoding","setColorWorkflow","setCamera","updateZoom","setClip","handleResize","updateInfo","rInfo","rMemory","rRender","isStill","currentSampleLevel","renderPending","frameRequest","pick","pid","picker","pixelBuffer","oid","absoluteToRelative","bRadius","relativeToAbsolute","__updateClipping","isFinite","cDist","nearFactor","farFactor","fogNearFactor","fogFarFactor","__updateCamera","ortho","nearClip","updateMaterialUniforms","sortParticles","sortData","sortArray","zArray","cmpFn","indexSrc","indexDst","tmpTab","__zArray","__sortArray","__cmpFn","bi","arr","stack","sp","swap","tmp2","quicksortCmp","attr","sortProjectedPosition","__setVisibility","helper","__updateLights","__renderPickingGroup","__renderModelGroup","__renderSuperSample","baseSampleWeight","sampleWeight","__renderStereo","_renderTarget","__render","lastRenderedPicking","rendering","getTouchDistance","touches","pageX","pageY","MouseObserver","moved","scrolled","dragged","dropped","clicked","hovered","doubleClicked","prevPosition","down","canvasPosition","prevClickCP","moving","hovering","lastMoved","which","buttons","pressed","altKey","ctrlKey","metaKey","shiftKey","touchAction","hoverTimeout","handleScroll","doubleClickSpeed","_listen","_onMousewheel","_onMousemove","_onMousedown","_onMouseup","_onContextmenu","_onTouchstart","_onTouchend","_onTouchmove","opt","passive","setParameters","cp","doubleClickPending","lastClicked","overElement","_setKeys","deltaY","deltaMode","WheelEvent","DOM_DELTA_PIXEL","DOM_DELTA_LINE","wheelDelta","wheelDeltaY","clientX","clientY","_setCanvasPosition","button","getMouseButtons","_distance","lastTouchDistance","touchDistance","tmpRotateXMatrix","tmpRotateYMatrix","tmpRotateZMatrix","tmpRotateMatrix","tmpRotateCameraMatrix","tmpRotateVector","tmpRotateQuaternion","tmpRotateQuaternion2","tmpPanMatrix","tmpPanVector","tmpAtomVector","TrackballControls","rotateSpeed","zoomSpeed","panSpeed","mouse","mouseObserver","controls","viewerControls","component","transformComponent","transformAtom","_setPanVector","scaleFactor","getCanvasScaleFactor","_getRotateXY","_getCameraRotation","_transformPanVector","pan","panComponent","panAtom","positionToVector3","positionAdd","updateRepresentations","applyMatrix","zRotate","rotateComponent","tmpVec","PickingProxy","pickingData","getComponentsByObject","getObject","getPosition","closestBondAtom","atom1","atom2","acp1","getPositionOnCanvas","acp2","closeAtom","ca","acp","getMaxRepresentationRadius","arrow","_objectIfType","cone","clash","contact","cylinder","ellipsoid","octahedron","tetrahedron","torus","surface","unitcell","unknown","volume","wideline","getLabel","msg","qualifiedName","sele1","sele2","serial","spacegroup","PickingControls","pickerArray","tmpQ","tmpP","tmpS","tmpCanvasVector","tmpScaleVector","tmpAlignMatrix","ViewerControls","changed","getCameraDistance","getOrientation","orient","spin","basis","Animation","duration","pausedTime","elapsedDuration","pausedDuration","ignoreGlobalToggle","_paused","_resolveList","_init","done","paused","tick","_tick","pause","hold","_hold","resume","releaseHold","SpinAnimation","RockAnimation","angleSum","angleStep","angleEnd","MoveAnimation","moveFrom","moveTo","ZoomAnimation","zoomFrom","zoomTo","RotateAnimation","_currentRotation","rotateFrom","rotateTo","ValueAnimation","valueFrom","valueTo","TimeoutAnimation","AnimationList","_list","every","AnimationControls","animationList","finishedList","rock","move","zoomMove","orientTo","timeout","spinComponent","rockComponent","moveComponent","Queue","argList","queue","pending","kill","Representation","lazy","clipRadius","clipCenter","flatShaded","front","back","double","colorData","colorScheme","colorScale","colorReverse","colorValue","colorDomain","colorMode","diffuseInterior","useInteriorColor","interiorColor","interiorDarkening","disablePicking","rebuild","tasks","make","bufferList","toBePrepared","setColor","quality","lazyProps","build","bufferParams","what","tp","sphereDetail","disableImpostor","getColorParams","getBufferParams","prepare","updateWhat","_make","manualAttach","disposed","setVisibility","noRenderRequest","updateParameters","int","float","_Worker","postCount","onmessageDict","onerrorDict","blobUrl","worker","Worker","post","__debug","terminate","WorkerPool","maxCount","pool","getNextWorker","nextWorker","minPending","calculateMeanVector3","projectPointOnVector","v3new","applyMatrix4toVector3array","applyMatrix3toVector3array","normalizeVector3array","len2","v3cross","v3dot","v3sub","v3add","v3fromArray","v3toArray","input","v3length2","v3length","v3divideScalar","v3multiplyScalar","v3normalize","length2","v3subScalar","v3addScalar","v3floor","v3ceil","v3negate","v3angle","cz","getFixedCountDashData","segmentCount","position1","sn3","position2","i3","j3","f1","f2","replicateArray3Entries","primitiveId","getFixedLengthDashData","segmentLength","pos1","pos2","rad","getFixedLengthWrappedDashData","remaining","drawing","k3","kprev","inv","Primitive","Picker","Buffer","static","_primitiveData","getShapeKey","fields","valueToShape","expandBoundingBox","valueFromShape","arrayFromShape","dataFromShape","SpherePrimitive","BoxPrimitive","heightAxis","depthAxis","OctahedronPrimitive","TetrahedronPrimitive","CylinderPrimitive","dashedCylinder","ArrowPrimitive","ConePrimitive","EllipsoidPrimitive","majorAxis","minorAxis","TorusPrimitive","TextPrimitive","PointPrimitive","WidelinePrimitive","SpatialHash","exp","bb","createBoundingBox","boundX","boundY","boundZ","an","xArray","yArray","grid","bucketIndex","bucketCount","bucketOffset","bucketFill","bucketArray","bucketIdx","within","eachWithin","atomIndex","rSq","loX","loY","loZ","hiX","hiY","hiZ","dSq","Store","_fields","_defaultFields","_initField","addField","resize","tmpArray","growIfFull","copyFrom","other","thisOffset","otherOffset","thisField","otherField","thisIndex","otherIndex","offsetTarget","offsetSource","targetIndex","sourceIndex","thisStore","tmpStore","quicksort","pivot","leftNew","rightNew","ContactStore","addContact","hammingWeight","BitArray","setAll","_words","flip","_assignRange","words","wordValue","wordStart","wordEnd","startWord","endWord","setRange","clearRange","setBits","clearBits","clearAll","flipAll","bs","_isRangeValue","isRangeSet","isRangeClear","isAllSet","isAllClear","isSet","isClear","isEqualTo","otherBitarray","words1","words2","difference","getIntersectionSize","makeIntersection","wordsA","answer","pos","toSeleString","createAdjacencyList","edges","edgeCount","nodeCount","nodeArray1","nodeArray2","countArray","offsetArray","bondCount2","idx1","idx2","j1","j2","createFeatureState","atomSet","addAtom","addFeature","features","centers","atomSets","UnknownBackboneType","ChemCompProtein","ChemCompRna","ChemCompDna","ChemCompSaccharide","ChemCompHetero","SecStrucHelix","SecStrucSheet","SecStrucTurn","AtomicNumbers","H","D","T","HE","LI","BE","B","N","O","F","NE","NA","MG","AL","SI","P","S","CL","AR","CA","SC","TI","V","CR","MN","FE","CO","NI","CU","ZN","GA","GE","AS","SE","BR","KR","RB","SR","Y","ZR","NB","MO","TC","RU","RH","PD","AG","CD","IN","SN","SB","TE","XE","CS","BA","LA","CE","PR","ND","PM","SM","EU","GD","TB","DY","HO","ER","TM","YB","LU","HF","TA","W","RE","OS","IR","PT","AU","HG","TL","PB","BI","PO","AT","RN","FR","RA","AC","TH","PA","U","NP","PU","AM","CM","BK","CF","ES","FM","MD","NO","LR","RF","DB","SG","BH","HS","MT","DS","RG","CN","NH","FL","MC","LV","TS","OG","VdwRadii","CovalentRadii","Valences","OuterShellElectronCounts","ResidueHydrophobicity","ALA","ARG","ASN","ASP","ASH","CYS","GLN","GLU","GLH","GLY","HIS","ILE","LEU","LYS","MET","PHE","PRO","SER","THR","TRP","TYR","VAL","DefaultResidueHydrophobicity","AA1","SEC","PYL","AA3","RnaBases","DnaBases","PurinBases","Bases","WaterNames","IonNames","SaccharideNames","ProteinBackboneAtoms","NucleicBackboneAtoms","ResidueTypeAtoms","direction1","direction2","backboneStart","backboneEnd","PDBQTSpecialElements","HD","NS","OA","SA","G0","G1","G2","G3","CG0","CG1","CG2","CG3","assignGeometry","totalCoordination","Angles","calcAngles","ap1","ap2","angles","eachBondedAtom","calcPlaneAngle","v12","neighbours","ni","ValenceModel","atomCount","charge","implicitH","totalH","idealGeometry","eachAtom","chg","implH","totH","geom","hydrogenCount","bondToElementCount","formalCharge","assignCharge","assignH","degree","bondCount","valence","eachBond","bondOrder","explicitValence","conjugated","_bp","getBondProxy","atomicNumber","hetero","flag","getOtherAtom","atomicNumber2","isConjugated","multiBond","implicitHCount","ba","oa","calculateHydrogensCharge","valenceModel","isPhosphate","PositvelyCharged","NegativelyCharged","isIonicInteraction","ti","tj","isPiStacking","isCationPi","isHistidineNitrogen","ap","isHydrogenBond","isWeakHydrogenBond","IonicTypeMetals","isMetalComplex","halBondElements","X","OptimalHalogenAngle","OptimalAcceptorAngle","invalidAtomContact","masterIdx","isMasterContact","ContactDefaultParams","maxHydrophobicDist","maxHbondDist","maxHbondSulfurDist","maxHbondAccAngle","maxHbondDonAngle","maxHbondAccPlaneAngle","maxHbondDonPlaneAngle","maxPiStackingDist","maxPiStackingOffset","maxPiStackingAngle","maxCationPiDist","maxCationPiOffset","maxIonicDist","maxHalogenBondDist","maxHalogenBondAngle","maxMetalDist","refineSaltBridges","masterModelIndex","lineOfSightDistFactor","residueIndex","calculateFeatures","atomInGroupDict","eachResidue","terminalNitrogenCount","isGuanidine","isAcetamidine","addPositiveCharges","isSulfonicAcid","isSulfate","terminalOxygenCount","isCarboxylate","addNegativeCharges","rings","getAromaticRings","ring","addAromaticRings","totalBonds","ig","addHydrogenAcceptors","addHydrogenDonors","ringData","residueType","getRings","hasElement","some","residueAtomOffset","atomTypeId","atomTypeIdList","atomMap","inAromaticRingWithElectronNegativeElement","addWeakHydrogenDonors","dative","ionic","isStandardAminoacid","isStandardBase","isHalogen","addMetalBinding","isTransitionMetal","addMetals","addHydrophobic","addHalogenAcceptors","addHalogenDonors","calculateContacts","contacts","spatialHash","contactStore","featureSet","createContacts","maxDistance","maxPiStackingDistSq","maxCationPiDistSq","atomStore","areAtomSetsWithinDist","atomSet1","atomSet2","maxDist","sn","sm","si","sj","atoms","getOffset","ct","addChargedContacts","maxHbondDistSq","donor","acceptor","isWeak","connectedTo","donorAngles","idealDonorAngle","donorAngle","outOfPlane","acceptorAngles","idealAcceptorAngle","acceptorAngle","bondType","isWaterHydrogenBond","isBackboneHydrogenBond","addHydrogenBonds","m1","m2","addMetalComplexation","addHydrophobicContacts","halogen","halogenAngles","addHalogenBonds","frozenContacts","adjacencyList","contactSet","createFrozenContacts","ac1","ac2","aw","lineOfSightDist","lineOfSightDistFactorSq","as1","as2","vdw","refineLineOfSight","residueContactDict","handleResidueContact","minDist","minIndex","refineHydrophobicContacts","ionicInteractionDict","isHydrogenBondType","iil1","iil2","piStackingDict","pil1","pil2","refinePiStacking","refineMetalCoordination","contactTypeName","ContactDataDefaultParams","hydrogenBond","hydrophobic","halogenBond","ionicInteraction","metalCoordination","cationPi","piStacking","weakHydrogenBond","waterHydrogenBond","backboneHydrogenBond","filterSele","getContactData","filterSet","getAtomSet","contactColor","ContactPicker","_applyTransformations","_getPosition","ShapePicker","primitive","objectFromShape","positionFromShape","AtomPicker","AxesPicker","BondPicker","bondStore","bp","center1","center2","ClashPicker","validation","clashArray","_getAtomProxyFromSele","getAtomIndices","DistancePicker","IgnorePicker","MeshPicker","__position","SurfacePicker","UnitcellPicker","VolumePicker","vol","dp","SlicePicker","getEdgeTable","getTriTable","MarchingCubes","field","nx","ny","nz","normalCache","vertexIndex","icount","mx","my","mz","allowedContours","isolevel","noNormals","contour","isNegativeIso","normalFactor","yd","zd","ilist","positionArray","normalArray","atomindexArray","edgeTable","triTable","VIntX","valp1","valp2","_q","mu","nc","q3","VIntY","q6","VIntZ","compNorm","polygonize","fx","fy","fz","edgeFilter","q1","q1y","q1z","qyz","q1yz","cubeindex","field0","field1","field2","field3","field4","field5","field6","field7","fx2","fy2","fz2","e1","e2","e3","triIndex","triangulate","xBeg","yBeg","zBeg","xEnd","yEnd","zEnd","yOffset","xBeg2","yBeg2","zBeg2","xEnd2","yEnd2","zEnd2","__break","__xBeg","__yBeg","__zBeg","__xEnd","__yEnd","__zEnd","_isolevel","_noNormals","_contour","_wrap","vIndexLength","Matrix","copyTo","At","nrows","ncols","Ai","Ati","pAt","atd","multiplyABt","Ap","Cp","mrows","cd","multiply3x3","Cd","Ad","Bd","m10","m14","m15","m16","m17","m18","m20","m24","m25","m26","m27","m28","meanRows","mean","subRows","row","hypot","FLT_MIN","svd","amt","wmt","vmt","astep","_W","Vt","vstep","eps","minval","iter","maxIter","Aj","Vi","Vj","sd","beta","seed","val0","asum","JacobiSVDImpl","m4new","m4set","m4multiply","m4makeScale","m4makeTranslation","m4makeRotationY","m3new","m3makeNormal","m4","r0","r1","r2","laplacianSmooth","verts","numiter","inflate","nv","nf","norms","tps","vertdeg","flagvert","ao","bo","co","vi3","vdi","wtvi","wt2vi","wt2","outwt","nv3","ci","getRadiusDict","radiusList","radiusDict","getSurfaceGrid","maxRadius","extraMargin","margin","dim","tmpSize","tran","mroty","mscale","mtrans","Surface","geo","colormaker","tc","getPicking","getFilteredIndex","filteredIndex","elementSize","getAtomindex","VolumeSurface","mc","getSurface","smooth","volsurf","Volume","inverseMatrix","setData","setAtomindex","_mean","_rms","setStats","rms","setMatrix","ne","getBox","_getBox","__box","_makeSurface","getValueForSigma","getSurfaceWorker","workerPool","sigma","getSigmaForValue","getDataAtomindex","getDataPosition","getDataColor","getDataPicking","getDataSize","_sum","sumSq","di","arrayRms","header","getThreeSide","setObjectMatrix","BufferDefaultParameters","opaqueBack","forceTransparent","BufferParameterTypes","updateShader","updateVisibility","parameterTypes","indexVersion","wireframeIndexVersion","isImpostor","isText","isPoint","dynamic","wireframeIndexCount","defaultParameters","pickingUniforms","_positionDataSize","addAttributes","initIndex","makeWireframeGeometry","attributeSize","nindex","DYNAMIC_DRAW","makeMaterial","wm","pm","wireframeMaterial","pickingMaterial","makeWireframeIndex","wireframeIndex","wireframeGeometry","checkEdge","updateWireframeIndex","getRenderOrder","_getMesh","materialName","getVertexShader","getFragmentShader","NEAR_CLIP","RADIUS_CLIP","PICKING","NOLIGHT","FLAT_SHADED","OPAQUE_BACK","DIFFUSE_INTERIOR","USE_INTERIOR_COLOR","addUniforms","buf","updateRenderOrder","setRenderOrder","pt","pv","propertyData","uniformData","doShaderUpdate","doVisibilityUpdate","setProperties","setUniforms","setAttributes","wu","MeshBuffer","SurfaceBuffer","setVisibilityTrue","setVisibilityFalse","DoubleSidedBuffer","frontMeshes","backMeshes","frontBuffer","backBuffer","ContourBuffer","SurfaceRepresentation","isolevelType","negateIsolevel","isolevelScroll","boxSize","colorVolume","useWorker","boxCenter","__boxCenter","setBox","__isolevel","__smooth","__contour","__wrap","__boxSize","onSurfaceFinish","surfaceBuffer","dullInterior","surfaceData","MouseActions","trackballControls","getFocus","almostIdentity","setFocus","eachRepresentation","reprElem","comp","repr","pickingProxy","animationControls","tt","tooltip","mp","innerText","measurePick","measureClear","MouseActionPresets","default","zoomScroll","focusScroll","zoomFocusScroll","rotateDrag","panDrag","zRotateDrag","zoomDrag","zoomFocusDrag","panComponentDrag","rotateComponentDrag","movePick","tooltipPick","pymol","coot","astexviewer","triggerFromString","tokens","MouseControls","actionList","disabled","preset","triggerStr","wildcard","action","KeyActions","autoView","toggleRock","toggleSpin","KeyActionPresets","toggleAnimations","toggleAntialiasing","KeyControls","char","PickingBehavior","mouseControls","_onClick","_onHover","pickingControls","MouseBehavior","_onMove","_onScroll","_onDrag","_onDblclick","AnimationBehavior","_onTick","KeyBehavior","keyControls","outline","_focusDomElement","_onKeydown","_onKeyup","_onKeypress","pressedKey","KeyboardEvent","keyCode","Annotation","content","_viewerPosition","_updateViewerPosition","_canvasPosition","_cameraPosition","pointerEvents","whiteSpace","setContent","_update","matrixChanged","displayValue","fontFamily","_clientRect","getVisibility","cr","zIndex","ComponentControls","RadiusFactoryTypes","covalent","bfactor","explicit","RadiusFactory","atomRadius","negateVector","PrincipalAxes","n3","pointsT","vm","van","vbn","vcn","begA","endA","begB","endB","begC","endC","vecA","vecB","vecC","normVecA","normVecB","normVecC","getBasisMatrix","getRotationQuaternion","getProjectedScaleForAtoms","d1a","d1b","d2a","d2b","d3a","d3b","ax1","ax2","ax3","dp1","dt1","dp2","dt2","dp3","dt3","FilteredVolume","minValue","maxValue","outside","setFilter","_getFilterHash","DMEAN","ARMS","filterHash","_filterHash","_dataBuffer","_positionBuffer","_atomindexBuffer","filteredData","filteredPosition","filteredAtomindex","BondHash","BondStore","addBond","ai1","ai2","addBondIfConnected","AtomStore","setAltloc","getAltloc","ResidueStore","setSstruc","getSstruc","setInscode","getInscode","ChainStore","setChainname","getChainname","setChainid","chainid","getChainid","ModelStore","Helixorient","polymer","residueCount","getCenterIterator","idx3","residueIndexStart","rp","getResidueProxy","traceAtomIndex","radiusFactory","rise","twist","resdir","r12","r23","r34","diff13","diff24","vt","_axis","_prevAxis","_resdir","getAtomIndexByType","a3","a4","diff13Length","diff24Length","resRadius","resTwist","resRise","resBending","resAxis","bending","Helixbundle","helixorient","getAxis","localAngle","centerDist","ssBorder","colorParams","radiusParams","beg","residueOffset","tmpAxis","tmpCenter","_beg","rp1","rp2","BinaryHeap","scoreFunction","bubbleUp","sinkDown","peek","parentN","elemScore","child1Score","child2Score","child2N","child1N","child1","child2","Kdtree","metric","maxDepth","currentNode","nodes","rootIndex","buildTree","arrBegin","arrEnd","plength","nodeIndex","arrMedian","currentDim","pivotIndex","pivotValue","storeIndex","getNodeDepth","parentIndex","nearest","maxNodes","bestNodes","nearestSearch","bestChild","otherChild","dimension","pointIndex","ownPoint","ownDistance","saveNode","leftIndex","rightIndex","linearPoint","linearDistance","verify","AtomProxy","chainStore","residueStore","residueMap","bondHash","entityList","entityIndex","chainIndex","residue","residueTypeId","atomType","occupancy","partialCharge","aromatic","_ap","hasBondTo","bap","hasBondToElement","backboneIndexList","moleculeType","isCg","backboneType","isTrace","atomRings","isNonmetal","isMetalloid","isDiatomicNonmetal","isPolyatomicNonmetal","isAlkaliMetal","isAlkalineEarthMetal","isNobleGas","isPostTransitionMetal","isLanthanide","isActinide","getDefaultValence","getValenceList","getOuterShellElectronCount","taa","aaa","distSquared","ta","positionFromArray","positionToArray","positionFromVector3","positionSub","getResidueBonds","firstOnly","relativeIndex","bonds","getBonds","atomIndices1","atomIndices2","connectedAtomIndex","connectedAtomIndices","noResname","modelStore","toObject","euclideanDistSq","euclideanDist","pointArray","useSquaredDist","atomIndices","kdtree","_Kdtree","nodeList","resultList","SymOpCode","$","E","G","J","M","Q","R","Z","_","EncodedSymOp","reInteger","selectionFromChains","chainList","Assembly","partList","addPart","matrixList","part","AssemblyPart","getAtomCount","reduce","getResidueCount","getInstanceCount","isIdentity","structureChainList","eachChain","partBox","getSelection","_getCount","propertyName","instanceBox","structureBox","getView","getInstanceList","StructureBuilder","currentModelindex","currentChainid","currentResname","currentResno","currentInscode","currentHetero","previousResname","previousHetero","ri","mi","addResidueType","modelindex","addModel","addChain","addResidue","chainOffset","chainCount","finalize","assignSecondaryStructure","secStruct","chainnames","eachModel","chainnamesSorted","chainnamesIndex","helices","h2","helix","helixRun","chainChange","sheets","strandCharCode","sheet","sheetRun","calculateSecondaryStructure","zhangSkolnickSS","distances","isHelical","eachPolymer","cgPolymer","proteinPolymer","prevSstruc","sstrucCount","ChainnameAlphabet","calculateChainnames","useExistingBonds","doAutoChainName","mIndex","rOffset","rCount","rStart","rEnd","chainData","eachResidueN","newChain","bbType1","bbType2","bbTypeUnk","backboneEndAtomIndex","backboneStartAtomIndex","fill","calculateBonds","calculateBondsWithin","calculateBondsBetween","BondOrderTable","getBondOrderFromTable","atomname1","atomname2","onlyAddRung","rungBondStore","rungAtomSet","atomBondMap","calculateAtomBondMap","bondedAtoms","Set","rai","bondOrders","nn","rai1","rai2","getBondIndex","rungEndAtomIndex","atomSetDict","rung","onlyAddBackbone","backboneBondStore","backboneAtomSet","needsBond","needsBackbone","backbone","buildUnitcellAssembly","uc","structureCenterFrac","cartToFrac","centerFrac","symopDict","encodedSymopList","matrixDict","symopList","symop","integer","getSymmetryOperations","centerFracSymop","positionFracSymop","getMatrixList","fracToCart","unitcellAssembly","unitcellMatrixList","ncsMatrixList","biomolDict","NCS","ncsUnitcellMatrixList","nm","vec","supercellAssembly","supercellMatrixList","ncsSupercellMatrixList","UNITCELL","SUPERCELL","guessElement","atomName","assignResidueTypeBonds","bondDict","nextAtomOffset","AlkaliMetals","AlkalineEarthMetals","PolyatomicNonmetals","DiatomicNonmetals","NobleGases","PostTransitionMetals","Metalloids","Halogens","AtomType","no","AtomMap","dict","getHash","ResidueType","chemCompType","bondReferenceAtomIndices","getMoleculeType","getBackboneType","backboneEndType","backboneStartType","getBackboneIndexList","atomnames","atomnamesStart","atomnamesEnd","traceIndex","getAtomIndexByName","dir1Index","direction1AtomIndex","dir2Index","direction2AtomIndex","bbStartIndex","bbEndIndex","rungEndIndex","atomnameList","hasProteinBackbone","hasRnaBackbone","hasDnaBackbone","hasCgProteinBackbone","hasCgRnaBackbone","hasCgDnaBackbone","hasAtomWithName","hasBackboneAtoms","hasBackbone","end1","maxd","nearestAtoms","calculateResidueBonds","calculateRings","getBondGraph","bondGraph","calculateBondGraph","getAromatic","aromaticAtoms","calculateAromatic","aromaticRings","nb","capacity","visited","pred","RingFinderMaxDepth","currentColor","RingFinderState","findRings","aromaticRingFlags","AromaticRingElements","AromaticRingPlanarityThreshold","isRingAromatic","assignBondReferenceAtomIndices","refRing","rings1","rings2","ri1","ai3","_idx2","getBondReferenceAtomIndex","bondIndex","addRing","current","leftOffset","rightOffset","found","rn","ringOffset","from","head","ResidueMap","BondProxy","_v12","_v13","_ap1","_ap2","_ap3","getOtherAtomIndex","getReferenceAtomIndex","typeAtomIndex1","typeAtomIndex2","calculateShiftDir","ap3","v13","ResidueProxy","getChainProxy","getAtomType","getResname1","getAtomnameList","rNext","bbAtomEnd","bbAtomStart","getNextConnectedResidue","nextIndex","rpNext","rpFirst","getPreviousConnectedResidue","residueProxy","rpPrev","rpLast","Polymer","residueIndexEnd","rpStart","rpEnd","isPrevConnected","isNextConnected","isNextNextConnected","isCyclic","__residueProxy","aIndex","eachAtomN","rStartIndex","ChainProxy","getModelProxy","residueEnd","_rp","rNextIndex","ModelProxy","chainEnd","_cp","Structure","refreshed","title","extraData","atomSetCache","boxes","bondSet","finalizeAtoms","finalizeBonds","getBondSet","getBackboneBondSet","backboneBondSet","__backbone","getRungBondSet","rungBondSet","__rung","seleString","getAtomSetWithinSelection","getAtomSetWithinPoint","getAtomSetWithinVolume","fv","getAtomSetWithinGroup","atomResidueIndex","getStructure","eachEntity","getEntityType","mn","cn","getAtomData","atomData","getBondData","multipleBond","isMulti","isOffset","bondScale","bondSpacing","bondData","storeBondOrder","absOffset","multiRadius","vShortening","vShift","getBackboneAtomData","getBackboneBondData","getRungAtomData","getRungBondData","getPrincipalAxes","atomCenter","hasCoords","_hasCoords","getSequence","getChainnameCount","updatePosition","refresh","refreshPosition","tmpBox","Primitives","ShapeDefaultParameters","aspectRatio","labelParams","pointSize","useTexture","Shape","meshCount","addMesh","meshBuffer","addSphere","objectToShape","addEllipsoid","addTorus","addCylinder","addCone","addArrow","addBox","addOctahedron","addTetrahedron","addText","addPoint","addWideline","addLabel","getBufferList","bufferFromShape","BufferRepresentation","GeometryBuffer","geoPosition","geoIndex","meshPosition","meshNormal","meshColor","meshIndex","updateNormals","geoNormal","positionCount","geoPositionCount","transformedGeoPosition","transformedGeoNormal","makeIndex","initNormals","applyPositionTransform","o3","SphereGeometryBufferDefaultParameters","SphereGeometryBuffer","_radius","MappedBuffer","mappingType","indexSize","mappingSize","mappingIndicesSize","nullValueAttributes","getAttributeIndex","dataIndex","makeMapping","mappingItemSize","aMapping","mappingIndices","it","MappedQuadBuffer","SphereImpostorBuffer","SphereBuffer","PointBufferDefaultParameters","edgeBleach","PointBufferParameterTypes","PointBuffer","makeTexture","makePointTexture","USE_SIZEATTENUATION","USE_MAP","ALPHATEST","DotRepresentation","thresholdType","thresholdMin","thresholdMax","thresholdOut","dotType","radiusType","deviation","dotData","dotBuffer","quadIndices","quadUvs","ImageBufferDefaultParameters","ImageBufferParameterTypes","ImageBuffer","alwaysTransparent","hasWireframe","imageData","pickingTex","pickingMap","startsWith","CUBIC_INTERPOLATION","endsWith","BSPLINE_FILTER","CATMULROM_FILTER","MITCHELL_FILTER","updateTexture","VolumeSlice","positionType","getPositionFromCoordinate","coord","ms","vn","dimLen","setVec","pickingArray","tMin","tMax","SliceRepresentation","linear","percent","coordinate","volumeSlice","sliceBuffer","logReprUnknown","ElementDefaultParameters","Element","statusChanged","setStatus","setName","RepresentationElementDefaultParameters","RepresentationElement","visibilityChanged","parametersChanged","setRepresentation","getType","_disposeRepresentation","hasRepresentation","removeRepresentation","toggleVisibility","setSelection","_v","ComponentDefaultParameters","Component","representationAdded","representationRemoved","reprList","annotationList","setRotation","setScale","setTransform","getCenterUntransformed","updateRepresentationMatrices","addAnnotation","annotation","eachAnnotation","removeAnnotation","removeAllAnnotations","_addRepresentation","hidden","impostor","workerDefault","ReprClass","makeRepresentation","addBufferRepresentation","removeAllRepresentations","getBoxUntransformed","getZoom","getZoomForBox","Collection","_remove","RepresentationCollection","TrajectoryElementDefaultParameters","defaultStep","defaultTimeout","defaultInterpolateType","defaultInterpolateStep","defaultMode","defaultDirection","initialFrame","TrajectoryElement","trajectory","frameChanged","playerChanged","player","setFrame","Frames","coordinates","times","timeOffset","deltaTime","Superposition","atoms1","atoms2","VH","coords1","coords2","coords1t","coords2t","transformationMatrix","prepCoords","_superpose","mean1","mean2","to","invA","t4","t5","t8","t9","t15","t17","t18","t20","t21","t23","t26","invert3x3","md","mat3x3determinant","transformMat_","tmp_1","tmp_2","mult","M1","M2","is4X4","tCoords","_pB","mcols","invertTrasform","mat","n4","TrajectoryPlayerDefaultParameters","interpolateType","interpolateStep","TrajectoryPlayer","traj","startedRunning","haltedRunning","_run","_previousTime","_currentTime","_currentStep","frameCount","_currentFrame","_direction","_animate","isRunning","dt","inProgress","_nextInterpolated","hasFrame","ip","ipp","ippp","setFrameInterpolated","loadFrame","_next","currentFrame","play","setPlayer","Trajectory","trajPath","frameCache","loadQueue","boxCache","pathCache","frameCacheSize","_frameCount","_disposed","centerPbc","removePbc","removePeriodicity","superpose","selectionIndices","_resetCache","_saveInitialCoords","setStructure","_loadFrameCount","backboneIndices","_getIndices","_makeAtomIndices","_saveStructureCoords","initialCoords","structureCoords","_makeSuperposeCoords","_updateStructure","_interpolate","fc","cpp","cppp","j0","interpolateSpline","interpolateLerp","iList","_loadFrame","_doSuperpose","_process","_setFrameCount","box2","circMean","circularMean3","arrayMean3","getFrameTime","FramesTrajectory","StructureTrajectory","RemoteTrajectory","request","getFrameUrl","getFrameParams","setRequestHeader","arrayBuffer","getCountUrl","CallbackTrajectory","requestCallback","StructureView","seleList","parentSelection","ignoreView","blosum62x","prepareMatrix","cellNames","matDict","rowDict","SubstitutionMatrices","blosum62","Alignment","seq1","seq2","gapPenalty","gapExtensionPenalty","substMatrix","initMatrices","score","ali","gap","makeScoreFn","calc","gap0","scoreFn","Vi1","Si1","Hi","Si","ali1","ali2","_s1","_s2","_i","_j","aliIdx1","aliIdx2","_atoms1","_atoms2","StructureComponentDefaultParameters","defaultAssembly","StructureComponent","trajList","trajectoryAdded","trajectoryRemoved","defaultAssemblyChanged","initSelection","pickBuffer","pointer","item","createRingBuffer","pickDict","del","createSimpleDict","spacefillRepresentation","addRepresentation","distanceRepresentation","angleRepresentation","dihedralRepresentation","measureRepresentations","setDefaultAssembly","structureView","rebuildRepresentations","rebuildTrajectories","reprParams","trajComp","reprComp","measureUpdate","addTrajectory","trajSrc","makeTrajectory","removeTrajectory","getAtomRadius","pickCount","lastPick","atomList","atomListSorted","atomPair","atomTriple","atomQuad","measureBuild","measureData","dihedral","pickData","radiusData","removeAllMeasurements","pd","removeMeasurement","addMeasurement","SurfaceComponent","VolumeComponent","ComponentCollection","matchName","tmpZoomVector","StageDefaultParameters","mousePreset","ShapeComponent","__decorate","decorators","desc","getOwnPropertyDescriptor","Reflect","decorate","AtomindexColormaker","scalePerModel","BfactorColormaker","bfactorScale","ChainidColormaker","chainidDictPerModel","chainidDict","ChainindexColormaker","ChainnameColormaker","chainnameDictPerModel","chainnameDict","DensityfitColormaker","rsrzDict","rsccDict","rsrzScale","rsccScale","rsrz","rscc","partialCharges","CZ","CG","OD1","CB","OD2","OE1","OE2","CD2","CE1","ND1","NE2","NZ","SD","PTR","O1P","O2P","O3P","OG1","SEP","TPO","CD1","CE2","CE3","NE1","OH","ElectrostaticColormaker","hCharges","charges","hPositions","hPos","backboneNHPosition","bbox","hStore","buildStoreLike","hHash","ElementColors","UUT","UUP","UUH","ElementColormaker","EntityindexColormaker","entityindexScale","EntitytypeColormaker","entityType","GeoqualityColormaker","geoAtomDict","geoDict","geoProblemCount","geoAtom","atomProblems","HydrophobicityColormaker","resHF","defaultResidueHydrophobicity","hfScale","ModelindexColormaker","modelindexScale","MoleculetypeColormaker","OccupancyColormaker","occupancyScale","PartialchargeColormaker","partialchargeScale","randomColor","RandomColormaker","RandomcoilindexColormaker","rciDict","rciScale","rci","ResidueindexColormaker","scalePerChain","ResidueColors","ASX","GLX","DA","DG","DI","DX","DC","DT","DU","DD","ResnameColormaker","StructureColors","SstrucColormaker","StructuredataColormaker","_a","_b","UniformColormaker","valueColor","ValueColormaker","valueScale","VolumeColormaker","nxy","i1y","i1z","iyz","i1yz","vy","vz","v1y","v1z","vyz","v1yz","xd","c00","c01","c10","c11","StructureRepresentation","radiusSize","radiusScale","assembly","biomolOptions","defaultScale","setRadius","getQuality","getAssembly","needsBuild","sview","createData","updateData","getRadiusParams","param","getAtomParams","getBondParams","MeasurementRepresentation","labelVisible","labelFontFamily","monospace","serif","labelFontStyle","italic","labelFontWeight","bold","labelsdf","labelXOffset","labelBackground","labelBackgroundColor","labelBackgroundMargin","labelBackgroundOpacity","labelFixedSize","labelFontstyle","textData","textBuffer","getLabelBufferParams","fontStyle","fontWeight","sdf","showBorder","borderColor","borderWidth","showBackground","backgroundMargin","backgroundOpacity","fixedSize","parseNestedAtoms","nSets","selected","_break","isInteger","calcArcPoint","edt","edt1d","MIN_SAFE_INTEGER","TextAtlasCache","TextAtlasDefaultParams","font","variant","weight","TextAtlas","mapped","scratchW","scratchH","currentX","currentY","cutoff","lineHeight","maxWidth","fillStyle","textAlign","textBaseline","lineJoin","gridOuter","gridInner","canvas2","context2","draw","measureText","clearRect","fillText","TextBufferDefaultParameters","fontSize","TextBufferParameterTypes","getCharCount","charCount","TextBuffer","fontTexture","inputTexCoord","inputSize","aPosition","aColor","txt","iChar","nChar","iCharAll","textAtlas","getTextAtlas","inputMapping","xadvance","xShift","yShift","texWidth","texHeight","texCoords","FIXED_SIZE","WideLineBufferDefaultParameters","WideLineBufferParameterTypes","WideLineBuffer","AngleRepresentation","vectorVisible","sectorVisible","atomPosition","okay","outPosition","outIdx","validatePositions","atomTriplePositions","angleData","labelPosition","labelText","vectorPosition1","vectorPosition2","arcPositionTmp1","arcPositionTmp2","sectorPositionTmp","totalSegments","v21","v23","cross2","labelTmp","arcPoint","crossLength","nSegments","sectorVertices","arcVertices1","arcVertices2","appendArcSection","arcSize","sectorSize","arcPosition1","arcPosition2","sectorPosition","sectorOffset","arcOffset","getAngleData","vectorBuffer","arcLength","arcBuffer","sectorLength","sectorBuffer","vectorData","arcData","sectorData","CylinderGeometryBufferDefaultParameters","getGeo","CylinderGeometryBuffer","geoLength","__center","_color","_from","_to","meshData","MappedAlignedBoxBuffer","CylinderImpostorBufferDefaultParameters","CylinderImpostorBufferParameterTypes","CylinderImpostorBuffer","CAP","CylinderBuffer","AxesRepresentation","showAxes","showBox","getAxesData","pa","en","vertexPosition","vertexColor","vertexRadius","edgePosition1","edgePosition2","edgeColor","edgeRadius","addAxis","offset2","addCorner","edgeOffset","addEdge","edge","axesData","sphereBuffer","cylinderBuffer","sphereData","cylinderData","BallAndStickRepresentation","lineOnly","cylinderOnly","symmetric","lineBuffer","lineData","BackboneRepresentation","BaseRepresentation","Interpolator","vec1","vec2","vDir","vTan","vNorm","vBin","interpolateToArr","interpolateToVec","interpolatePosition","interpolateTangent","vectorSubdivide","interpolationFn","iterator","getTangent","interpolateNormalDir","u0","u1","u2","u3","norm","bin","interpolateNormal","getNormalDir","iterDir1","iterDir2","vSub1","vSub2","vSub3","vSub4","d1v1","d1v2","d1v3","d1v4","d2v1","d2v2","d2v3","d2v4","interpolateColor","item1","item2","colFn","interpolatePicking","pickFn","interpolateSize","sizeFn","Spline","positionIterator","subdiv","smoothSheet","interpolator","getAtomIterator","cache2","apPrev","apNext","getSubdividedColor","nCol","getSubdividedPicking","getSubdividedPosition","getSubdividedOrientation","getNormals","binormal","getSubdividedSize","nSize","nPos","nTan","nNorm","vTangent","vMeshNormal","TubeMeshBufferDefaultParameters","capped","TubeMeshBuffer","capVertices","capTriangles","xi","size2","meshPrimitiveId","normX","normY","normZ","biX","biY","biZ","posX","posY","posZ","cxArr","cyArr","cx1Arr","cy1Arr","cx2Arr","cy2Arr","cx1","cy1","cx2","cy2","radialSegments1","irs","irs1","strip","CartoonRepresentation","getSplineParams","getSpline","getAspectRatio","polymerList","subPos","subOri","subCol","subPick","subSize","ContactRepresentation","angstrom","dataParams","contactData","getLabelData","DihedralRepresentation","extendLine","lineVisible","dihedralData","lineTmp1","lineTmp2","sectorTmp","planeTmp","totalLines","totalPlanes","v34","inPlane1","inPlane2","improperStart","improperEnd","nLines","line1","line2","sector","li","nSuccess","linePosition1","linePosition2","planePosition","lineOffset","planeOffset","lp1","lp2","pp","getDihedralData","lineLength","lineColor","planeLength","planeBuffer","planeData","createUpdatedObject","updateSource","hasKey","createColorArray","arrayLength","targetArray","DihedralHistogramRepresentation","histogramsData","histogramBinBorderVisible","scaleBinToSectorArea","histogramBinBorderColor","adjacentBondArrowColor","distantBondArrowColor","frontHistogramColor","backHistogramColor","opaqueMiddleDiscColor","histogramOpacity","opaqueMiddleDiscVisible","opaqueMiddleDiscOpacity","histogramBinBorderWidth","histogramBinBorderOpacity","bondArrowVisible","bondArrowWidth","bondArrowOpacity","specificColorData","getHistogramBinBorderBufferParameters","getBondArrowsBufferParameters","getOpaqueMiddleDiscBufferParameters","getHistogramBufferParameters","atomPositions","scaleData","Float32Concat","arrays","lengths","accumulatedOffset","createWideLineBuffer","linesList","startPoints","endPoints","startColors","endColors","createMeshBuffer","triangleColors","histogram360Scaled","histogram360","dihedralDataArray","currentHistogramData","calculateDihedralHistogram","frontHistogramBinBordersBuffer","frontHistogramBinBorders","backHistogramBinBordersBuffer","backHistogramBinBorders","adjacentBondArrowsBuffer","adjacentBondArrows","distantBondArrowsBuffer","distantBondArrows","opaqueMiddleDiscBuffer","opaqueMiddleDisc","frontHistogramBuffer","frontHistogram","backHistogramBuffer","backHistogram","histogramData","positionOfDihedralAtoms","histogram","totalSectorTrianglesInOpaqueMiddleDisc","frontAndBack","v32","cross1","dihedralAtomVectors","absAngle","maxHist","histBinAngleStep","setHistogramBinCoordinates","ind","zeroDegreeVector","crossVector","startOffset","scalingFactor","setOneSideHistogram","discHistogram","binBorders","sectionIndex","opaqueCircleSectorAngleStep","DistanceRepresentation","useCylinder","getDistanceData","pair","distanceData","bondParams","distanceBuffer","VectorBufferDefaultParameters","VectorBuffer","HelixorientRepresentation","LicoriceRepresentation","MappedBoxBuffer","HyperballStickImpostorBufferDefaultParameters","shrink","HyperballStickImpostorBufferParameterTypes","HyperballStickImpostorBuffer","HyperballStickBuffer","calculateMinArray","HyperballRepresentation","stickData","LabelFactory","errorLogged","atomLabel","aa1","qualified","LabelRepresentation","labelType","labelFormat","labelGrouping","getTextData","labelFactory","positionN","sizeN","colorN","getLoneAtomSet","LineRepresentation","crosses","lone","all","crossSize","_crossData","crossData","attrSize","cPosition1","cPosition2","cColor","cColor2","cOffset","cimax","crossBuffer","bufferIdx","lineAttributes","crossAttributes","makeGrid","DataCtor","elemSize","EDTSurface","coordList","probeRadius","pLength","pWidth","pHeight","ptran","depty","widxz","cutRadius","setAtomID","vpBits","vpDistance","vpAtomID","btype","_probeRadius","_scaleFactor","_cutoff","_setAtomID","boundingatom","INOUT","ISDONE","ISBOUND","txz","tdept","sradius","tradius","widxzR","deptyName","indx","fillatom","ox","oy","oz","mj","mk","sk","ii","jj","kk","deptyAtNind","deptyAt","nind","pWH","ci2","fillvoxels","fillAtomWaals","fastdistancemap","boundPoint","cutRSq","totalsurfacevox","inarray","positin","outarray","positout","fastoneshell","cutoffSq","tz","square","nbj","tnvix","tnviy","tnviz","getVolume","tk","buildboundary","fillvoxelswaals","stype","marchingcubeinit","vd","makeAVHash","atomsX","atomsY","atomsZ","atomsR","nAtoms","hashFunc","minW","iDim","jDim","kDim","nCells","jkDim","preHash","cid","cellOffsets","cellLengths","maxCellLength","subArray","cellLength","neighbourListLength","withinRadii","rExtra","nearI","nearJ","nearK","loI","loJ","loK","hiI","hiJ","hiK","iOffset","jOffset","cellStart","cellEnd","rSum","AVSurface","probePositions","gridx","gridy","gridz","sinTable","cosTable","lastClip","atob","ngTorus","_probePositions","rExt","surfGrid","fillGridDim","initializeGrid","initializeAngleTables","obscured","singleAtomObscures","ra2","projectPoints","ar","ar2","ng","iax","iay","iaz","minx","miny","minz","maxx","maxy","maxz","xoffset","dxy2","xyoffset","spx","spy","spz","projectTorus","dmp","normalToLine","rInt","cost","sint","px","py","pz","ia","projectTorii","fixNegatives","fixAtomIDs","MolecularSurface","_getAtomData","MolecularSurfaceRepresentation","surfaceType","vws","sas","ses","av","__infoList","__forceNewMolsurf","prepareData","molsurf","sviewFilter","bbSize","maxDim","asWithin","getSurfaceParams","__sele","__surfaceParams","after","contourBuffer","doubleSidedBuffer","PointRepresentation","pointData","RibbonBuffer","aNormal","aSize","aDir","aPrimitiveId","currSize","prevSize","RibbonRepresentation","RocketRepresentation","axisList","helixbundleList","helixbundle","axisData","RopeRepresentation","SpacefillRepresentation","TraceBuffer","linePosition","TraceRepresentation","TubeRepresentation","UnitcellRepresentation","defaultRadius","cbrt","getUnitcellData","unitcellData","ValidationRepresentation","clashData","getClashData","ConeBufferDefaultParameters","ConeBuffer","_position1","_position2","GeometryGroup","geometryList","empty","ArrowBufferDefaultParameters","ArrowBuffer","splitPosition","cylinderRadius","makeAttributes","coneBuffer","vSplit","fullLength","coneLength","BoxBuffer","_heightAxis","_depthAxis","_size","EllipsoidBufferDefaultParameters","EllipsoidBuffer","_majorAxis","_minorAxis","OctahedronBuffer","TetrahedronBuffer","TorusBufferDefaultParameters","radiusRatio","TorusBuffer","Parser","_beforeParse","_parse","_afterParse","StructureParser","structureBuilder","Entity","description","chainIndexList","entityTypeFromString","entityFromType","isNonPolymer","isMacrolide","DefaultBoxParams","Unitcell","alphaRad","betaRad","gammaRad","cosAlpha","cosBeta","cosGamma","sinBeta","sinGamma","cStar","cosAlphaStar","cornerOffset","centerArray3","HelixTypes","dAminoAcids","entityKeyList","reWhitespace","getModresId","PdbParser","isLegacy","headerLine","headerId","legacyId","isPqr","isPdbqt","sb","serialRadix","resnoRadix","currentCoord","doFrames","currentBiomol","currentPart","currentMatrix","recordName","startChain","startResi","startIcode","endChain","endResi","endIcode","serialDict","unitcellDict","entityDataList","currentEntityData","currentEntityKey","hetnameDict","modresDict","chainDict","chainIdx","currentChainname","seqresDict","currentSeqresChainname","modelIdx","pendingStart","ls","modresId","fromIdx","toIdx","helixType","seqresChainname","keyEnd","biomt","biomtElms","ncsName","ncs","ncsRow","ncsElms","origx","orgix","origxRow","origxElms","scaleRow","scaleElms","aLength","bLength","cLength","sGroup","_parseChunkOfLines","ei","residueDict","reQuotedWhitespace","reDoubleQuote","reTrimQuotes","reAtomSymbol","trimQuotes","ensureArray","hasValue","cifDefaults","getBondOrder","valueOrder","CifParser","rawline","authAsymId","authSeqId","labelSeqId","labelAtomId","labelCompId","labelAsymId","labelEntityId","labelAltId","groupPDB","typeSymbol","pdbxPDBmodelNum","pdbxPDBinsCode","CartnX","CartnY","CartnZ","bIsoOrEquiv","cif","asymIdDict","chainIndexDict","pendingString","currentString","pendingValue","pendingLoop","pendingName","loopPointers","currentLoopIndex","currentCategory","currentName","pointerNames","modelNum","keyParts","category","keyValuePair","_modelNum","frameOffset","occ","assignedChainname","entityId","chem_comp","chem_comp_atom","struct","cc","cca","ccb","chem_comp_bond","atomnameDict","comp_id","atom_id","type_symbol","model_Cartn_x","model_Cartn_y","model_Cartn_z","pdbx_component_comp_id","pdbx_residue_numbering","pdbx_model_Cartn_x_ideal","pdbx_model_Cartn_y_ideal","pdbx_model_Cartn_z_ideal","atom_id_1","atom_id_2","value_order","parseChemComp","atom_site_type_symbol","atom_site_label","atom_site_fract_x","cell_length_a","cell_length_b","cell_length_c","cell_angle_alpha","cell_angle_beta","cell_angle_gamma","typeSymbolMap","atom_site_fract_y","atom_site_fract_z","atom_site_occupancy","identityMatrix","covalentI","parseCore","begIcode","struct_conf","pdbx_PDB_helix_class","beg_auth_seq_id","pdbx_beg_PDB_ins_code","pdbx_end_PDB_ins_code","beg_label_asym_id","end_label_asym_id","end_auth_seq_id","ssr","struct_sheet_range","processSecondaryStructure","operDict","pdbx_struct_oper_list","biomolOp","elms","pdbx_struct_assembly_gen","gen","getMatrixDict","expr","es","assembly_id","oe","oper_expression","md1","md2","k1","k2","asym_id_list","struct_ncs_oper","ncsOp","ncsPart","cell","length_a","length_b","length_c","angle_alpha","angle_beta","angle_gamma","symmetry","database_PDB_matrix","origxMat","atom_sites","scaleMat","processSymmetry","struct_conn","atomIndicesCache","connTypeId","conn_type_id","ptnr1_symmetry","ptnr2_symmetry","inscode1","pdbx_ptnr1_PDB_ins_code","altloc1","pdbx_ptnr1_label_alt_id","ptnr1_auth_seq_id","ptnr1_label_asym_id","ptnr1_label_atom_id","selection1","inscode2","pdbx_ptnr2_PDB_ins_code","altloc2","pdbx_ptnr2_label_alt_id","ptnr2_auth_seq_id","ptnr2_label_asym_id","ptnr2_label_atom_id","selection2","tmpA","tmpB","pdbx_value_order","processConnections","pdbx_description","processEntities","entry","pdbx_audit_revision_history","revision_date","dates","releaseDate","pdbx_database_status","recvd_initial_deposition_date","depDates","depositionDate","database_PDB_rev","date","date_original","reflns","d_resolution_high","refine","ls_d_res_high","ls_R_factor_R_free","rFree","ls_R_factor_R_work","rWork","exptl","experimentalMethods","firstLines","lpos","ypos","zpos","modelLineCount","lineNo","AllFields","typedArray","getDataView","getInt8View","getInt32View","decodeInt16","decodeInt32","decodeInteger","intArray","divisor","invDiv","decodeRun","dataOffset","decodeDelta","decodePacking","int16or8","upperLimit","lowerLimit","decodeIntegerPacking","decodeIntegerDeltaPacking","unpacked","decodeIntegerDelta","decodeMsgpack","dataView","performDecoding","dvOut","dvIn","decodeFloat32","decodeIntegerRun","decodeMmtf","inputDict","ignoreFields","outputDict","dv","ignore","SstrucMap","groupData","numBonds","numAtoms","numGroups","numChains","numModels","chainsPerModel","structureId","groupsPerChain","groupList","groupTypeList","atomNameList","frameAtomOffset","xCoordList","yCoordList","zCoordList","bAtomIndex1","bAtomIndex2","bBondOrder","aGroupIndex","aFormalCharge","gChainIndex","gAtomOffset","gAtomCount","cModelIndex","cGroupOffset","cGroupCount","mChainOffset","mChainCount","modelChainCount","groupOffset","chainGroupCount","bondOffset","groupAtomCount","groupFormalChargeList","formalChargeList","groupBondAtomList","bondAtomList","groupBondOrderList","bondOrderList","atomIdList","bFactorList","altLocList","occupancyList","groupIdList","secStructList","insCodeList","chainNameList","chainIdList","groupTypeDict","groupType","elementList","hetFlag","numGroupBonds","groupName","resAtomOffset","secStructLength","bioAssemblyList","_assembly","chainToPart","transformList","_transform","ncsOperatorList","ncsAssembly","_operator","unitCell","spaceGroup","bondTypes","du","un","moleculeLineNo","modelAtomIdxStart","currentRecordType","reItem","SdfParser","headerLines","sdfData","mItem","atomStart","bondStart","bondEnd","currentItem","currentData","isV3000","isAtomBlock","isBondBlock","acc","atomindexToStoreindex","chgTok","find","chargeCount","coffset","atomIdx","cToken","_postProcess","parseIntSubstr","PrmtopParser","pointersDict","pointers","atomNames","radii","residueLabels","residuePointers","curIdx","bondIdx","lt","NATOM","NBONH","MBONA","NRES","curResIdx","curResname","curResno","reTitle","lastSegid","segid","reField","molecules","moleculetypeDict","currentMoleculetype","fieldMatch","cIdx","molName","molCount","molType","lastResno","resIdx","chainidIdx","chainnameIdx","TrajectoryParser","notNetcdf","statement","reason","readName","nameLength","nextPos","intView","ef","isCharmm","extraBlock","fourDims","NSET","ISTART","NSAVC","NAMNF","DELTA","titleLength","titlePos","TITLE","natom","natom4","BYTE","CHAR","SHORT","INT","DOUBLE","num2str","num2bytes","str2num","readNumber","bufferReader","numbers","readType","trimNull","ZERO","NC_DIMENSION","NC_VARIABLE","NC_ATTRIBUTE","recordDimension","dimList","dimensions","recordId","dimensionSize","dimensionsList","globalAttributes","attributesList","variables","varList","recordStep","variableSize","dimensionality","dimensionsIds","varSize","record","variablesList","gAttList","gAtt","NetcdfReader","hasDataVariable","variableName","findIndex","getDataVariable","variable","currentOffset","nonRecord","NctrajParser","netcdfReader","versionSize","virSize","presSize","coordSize","velocitySize","forceSize","natoms","floatSize","natoms3","frameCoords","MagicInts","sizeOfInt","numOfBits","_tmpBytes","sizeOfInts","numOfInts","sizes","numOfBytes","bytecnt","decodeBits","cbuf","buf2","lastBB0","lastBB1","_tmpIntBytes","decodeInts","nums","minMaxInt","sizeint","bitsizeint","sizesmall","thiscoord","prevcoord","lfp","lsize","bitsize","smallidx","tmpIdx","smaller","smallnum","adz","invPrecision","buf8","isSmaller","tmpSwap","VolumeParser","getMatrix","reScientificNotation","bohrToAngstromFactor","CubeParser","originX","originY","originZ","NVX","NVY","NVZ","basisX","basisY","basisZ","oribitalFlag","lj","Dsn6Parser","summand","byteView","brixStr","xStart","yStart","zStart","xExtent","yExtent","zExtent","xRate","yRate","zRate","xlen","ylen","zlen","xBlocks","yBlocks","zBlocks","nxyz","mapcrs","DxParser","headerInfo","parseHeaderLines","dataLineStart","headerByteCount","deltaLineCount","ymin","zmin","hx","hy","hz","uint8ToLines","MrcParser","floatView","MAP","MACHST","NX","NY","MODE","NXSTART","NYSTART","NZSTART","MX","MY","MZ","MAPC","MAPR","MAPS","DMIN","DMAX","ISPG","NSYMBT","LSKFLG","parseNumberLine","XplorParser","infoStart","dataStart","gridInfo","AMIN","AMAX","BMIN","BMAX","NC","CMIN","CMAX","cellInfo","lineSection","RAVE","RSIGMA","hsvToRgb","ColorDict","sea","sky","peach","lilac","pinktint","peachtint","yellowtint","greentint","bluetint","lilactint","deadwhite","deadblack","invisible","reWhitespaceComma","reCurlyWhitespace","reTrimCurly","reCollapseEqual","parseListDef","defaultColor","master","listName","listColor","listMasters","listWidth","parseListElm","lineBreak","triangleBreak","lsindex","literal","isLineBreak","isTriangleBreak","parseStr","parseFlag","parseGroup","flags","groupFlags","groupMasters","kinemage","onewidth","pdbfile","texts","captions","caption","groupDict","subgroupDict","masterDict","pointmasterDict","dotLists","vectorLists","ballLists","ribbonLists","currentGroupMasters","currentSubgroupMasters","dotDefaultColor","dotLabel","dotPosition","dotColor","vecDefaultColor","vecDefaultWidth","vecLabel1","vecLabel2","vecPosition1","vecPosition2","vecColor1","vecColor2","ballRadius","ballDefaultColor","ballLabel","ballPosition","ballColor","ribbonListDefaultColor","ribbonPointLabelArray","ribbonPointPositionArray","ribbonPointBreakArray","ribbonPointColorArray","isDotList","prevDotLabel","isVectorList","prevVecLabel","prevVecPosition","prevVecColor","isBallList","prevBallLabel","isRibbonList","prevRibbonPointLabel","isCaption","masterArray","labelArray","colorArray","indent","label1Array","label2Array","position1Array","position2Array","color1Array","color2Array","radiusArray","breakArray","splitLine","singlePointLine","dominant","convertedLists","listObject","convertedRibbonObject","editedLabels","editedPositions","editedColors","editedBreaks","breakPointer","positionPointer","removePointBreaksTriangleArrays","ribbonObject","convertedLabels","convertedBreaks","convertedPositions","convertedColors","vector3Positions","convertKinTriangleArrays","SurfaceParser","getLoader","OBJLoader","regexp","vertex_pattern","normal_pattern","uv_pattern","face_vertex","face_vertex_uv","face_vertex_uv_normal","face_vertex_normal","object_pattern","smoothing_pattern","material_library_pattern","material_use_pattern","setPath","_createParserState","startObject","fromDeclaration","parseVertexIndex","parseNormalIndex","addVertex","addVertexLine","addNormal","nd","vLen","ib","ic","nLen","addLineGeometry","vi","lineFirstChar","lineSecondChar","trimLeft","lineParts","lineVertices","lineUVs","llen","parts","PLYLoader","propertyNameMapping","setPropertyNameMapping","bin2str","isASCII","parseHeader","parseASCII","parseBinary","headerText","headerLength","currentElement","lineType","lineValues","propertValues","comments","countType","itemType","parseASCIINumber","parseASCIIElement","currentElementCount","useColor","handleElement","postProcess","elementName","vertexIndices","vertex_indices","binaryRead","dataview","binaryReadElement","loc","table","reDelimiter","msgpack","netcdf","TextParser","reStrip","reTag","reContent","reAttr","parseXml","declaration","root","tag","eos","is","XmlParser","useDomParser","__xmlParser","__domParser","DOMParser","parseFromString","Document","getNamedItem","getSele","useAltcode","icode","altcode","getResSele","setBitDict","bit","hasAttrValue","getProblemCount","clashDict","ga","clashes","getElementsByTagName","Validation","atomDict","clashSele","fromXml","entries","chemicalShiftLists","randomCoilIndices","rcia","_clashDict","clashList","seleAttr","createAttribute","setNamedItem","atomSele","res1","res2","mogBondOutliers","mogAngleOutliers","vPos1","vPos2","getAtomSele","dHalf","shrinkBuf","arraySet","dest","src_offs","dest_offs","adler32","adler","crcTable","makeTable","crc32","crc","BAD$1","TYPE$1","inflate_fast","strm","_in","last","dmax","wsize","whave","wnext","s_window","lcode","dcode","lmask","dmask","here","op","from_source","next_in","avail_in","next_out","avail_out","lencode","distcode","lenbits","distbits","dolen","dodist","sane","MAXBITS","ENOUGH_LENS$1","ENOUGH_DISTS$1","CODES$1","LENS$1","DISTS$1","lbase","lext","dbase","dext","inflate_table","lens","lens_index","codes","table_index","work","incr","here_bits","here_op","here_val","curr","drop","used","huff","base_index","offs","extra","extra_index","LENS","DISTS","Z_OK","Z_STREAM_ERROR","HEAD","TYPE","BAD","ENOUGH_LENS","ENOUGH_DISTS","zswap32","InflateState","havedict","check","total","wbits","ncode","nlen","ndist","have","lendyn","distdyn","was","inflateReset","total_in","total_out","inflateResetKeep","inflateInit2","windowBits","inflateReset2","lenfix","distfix","virgin","fixedtables","updatewindow","flush","put","last_bits","last_op","last_val","hbuf","inf_leave","xflags","os","extra_len","hcrc","data_type","inflateSetDictionary","dictionary","dictLength","STR_APPLY_OK","STR_APPLY_UIA_OK","__","_utf8len","string2buf","m_pos","str_len","buf_len","buf2string","c_len","utf16buf","_buf2binstring","utf8border","Z_OK$1","messages","ZStream","GZheader","Inflate","sources","raw","ended","next_out_utf8","tail","utf8str","allowBufError","binstring2buf","onEnd","onData","inflateEnd","flattenChunks","decompressedData","inflator","ungzip","Datasource","mmtfBaseUrl","mmtfFullUrl","mmtfReducedUrl","pdbid","baseUrl","suffixUrl","PassThroughDatasource","suffixURL","uniprotid","reProtocol","IntegerParam","NumberParam","RangeParam","SelectParam","UIStageParameters","getListing","jsonData","frameIndex","getPathUrl","renumberSerial","remarks","_records","_writeRecords","_writeTitle","_writeRemarks","_writeAtoms","im","chargeSign","hasModels","formatString","getString","idString","titleString","countsString","chargeLines","pairs","nCharges","formatAtom","formatBond","_writeHeader","_writeCTab","_writeFooter","fullscreenChanged","componentAdded","componentRemoved","compList","defaultFileParams","logList","pickingBehavior","mouseBehavior","animationBehavior","keyBehavior","spinAnimation","rockAnimation","setQuality","setImpostor","defaultFileRepresentation","BU1","sizeScore","backboneOnly","loadFile","promise","addComponentFromObject","defaultRepresentation","errorMsg","loadScript","script","addComponent","CompClass","removeComponent","removeAllComponents","toggleFullscreen","fullscreenEnabled","mozFullScreenEnabled","webkitFullscreenEnabled","msFullscreenEnabled","getFullscreenElement","fullscreenElement","mozFullScreenElement","webkitFullscreenElement","msFullscreenElement","resizeElement","lastFullscreenElement","dataset","normalWidth","normalHeight","exitFullscreen","msExitFullscreen","mozCancelFullScreen","webkitExitFullscreen","requestFullscreen","msRequestFullscreen","mozRequestFullScreen","webkitRequestFullscreen","setSpin","setRock","pclamp","minSize","aspectFactor","catch","impostorTypes","eachComponent","getComponentsByName","getRepresentationsByName","relativePath","pn","pathname","basePath","getAbsolutePath","vectorNorm1","vectorNorm2","vectorNorm3","structures","atomIndexDict","modelCount","wait","previous","later","leading","Date","clearTimeout","trailing"],"mappings":"2OAGA,MAAAA,EAAA,EACAC,EAAA,EACAC,EAAA,EAKAC,EAAA,EACAC,EAAA,EACAC,EAAA,EACAC,EAAA,EACAC,EAAA,EACAC,EAAA,EAGAC,EAAA,EACAC,EAAA,EACAC,EAAA,EACAC,EAAA,EACAC,EAAA,EACAC,EAAA,EACAC,EAAA,IACAC,EAAA,IACAC,EAAA,IACAC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A,MAAQp7G,CACV,yBAqBM,SAAgCA,GACpCg+G,EAAAA,kBAAoBh+G,CACtB,gCA9BgB,SAA6BwsF,EAAS,IACpDjvF,OAAOC,OAAO+8G,GAA0B/tB,EAC1C,4BA+BM,SAAmCxsF,GACvCi+G,EAAAA,qBAAuBj+G,CACzB,qCbsJ0By8F,EAAgBmxK,EAAc3+P,GAGtD,IAAIlC,EACAsvF,EACAzvB,EACAs+D,EAAe,KACf2iI,EAAW,EAIf,SAASC,IACPD,GAA+B,IAApB5+P,EAAQ8+P,QAAoB,EAAIC,KAAKjiJ,MAChDmf,EAAU,KACVt+D,EAAS6vB,EAAK9oB,MAAM5mE,EAASsvF,GACxB6uC,IAASn+H,EAAUsvF,EAAO,KAChC,CAED,OATKptF,IAASA,EAAU,CAAA,GASjB,WACL,IAAI88G,EAAMiiJ,KAAKjiJ,MACV8hJ,IAAgC,IAApB5+P,EAAQ8+P,UAAmBF,EAAW9hJ,GACvD,IAAIsmB,EAAYu7H,GAAQ7hJ,EAAM8hJ,GAe9B,OAdA9gQ,EAAUjP,KACVu+F,EAAO54F,UACH4uI,GAAa,GAAKA,EAAYu7H,GAC5B1iI,IACF+iI,aAAa/iI,GACbA,EAAU,MAEZ2iI,EAAW9hJ,EACXn/C,EAAS6vB,EAAK9oB,MAAM5mE,EAASsvF,GACxB6uC,IAASn+H,EAAUsvF,EAAO,OACrB6uC,IAAgC,IAArBj8H,EAAQi/P,WAC7BhjI,EAAUld,WAAW8/I,EAAOz7H,IAGvBzlE,CACT,CACF"} \ No newline at end of file diff --git a/dist/ngl.umd.js b/dist/ngl.umd.js index ea888fdb..ea63c2c9 100644 --- a/dist/ngl.umd.js +++ b/dist/ngl.umd.js @@ -24,5 +24,5 @@ * * @param {Float32Array} points - points * @param {Function} metric - metric - */class bo{constructor(e,t){this.points=e,this.metric=t,this.maxDepth=0,this.currentNode=0;const i=e.length/3,r=new Uint32Array(i);for(let e=0;ethis.maxDepth&&(this.maxDepth=e);const s=r-i;if(0===s)return-1;const n=4*this.currentNode,o=this.nodes;if(this.currentNode+=1,1===s)return o[n]=i,o[n+1]=-1,o[n+2]=-1,o[n+3]=t,n;const a=this.indices,c=this.points,l=i+Math.floor(s/2),h=e%3;let u,d,m,p,f,g=i,y=r-1;for(;y>g;){for(m=g+y>>1,p=c[3*a[m]+h],d=a[m],a[m]=a[y],a[y]=d,f=g,u=g;u-e[1])),s=this.nodes,n=this.points,o=this.indices,a=c=>{let l,h;const u=this.getNodeDepth(c)%3,d=3*o[s[c]],m=[n[d+0],n[d+1],n[d+2]],p=this.metric(e,m);function f(e,i){r.push([e,i]),r.size()>t&&r.pop()}const g=s[c+1],y=s[c+2];if(-1===y&&-1===g)return void((r.size()n[3*o[s[e]]+r])throw new Error("left child is > parent!");i+=this.verify(a,t+1)}if(-1!==c){if(n[3*o[s[c]]+r]0}isBackbone(){const e=this.residueType.backboneIndexList;return e.length>0&&e.includes(this.index-this.residueAtomOffset)}isPolymer(){if(this.structure.entityList.length>0)return this.entity.isPolymer();{const e=this.residueType.moleculeType;return 3===e||4===e||5===e}}isSidechain(){return this.isPolymer()&&!this.isBackbone()}isCg(){const e=this.residueType.backboneType;return 4===e||5===e||6===e}isTrace(){return this.index===this.residueType.traceAtomIndex+this.residueAtomOffset}isHetero(){return 1===this.residueType.hetero}isProtein(){return 3===this.residueType.moleculeType}isNucleic(){const e=this.residueType.moleculeType;return 4===e||5===e}isRna(){return 4===this.residueType.moleculeType}isDna(){return 5===this.residueType.moleculeType}isWater(){return 1===this.residueType.moleculeType}isIon(){return 2===this.residueType.moleculeType}isSaccharide(){return 6===this.residueType.moleculeType}isHelix(){return $r.includes(this.sstruc)}isSheet(){return Fr.includes(this.sstruc)}isTurn(){return Er.includes(this.sstruc)&&this.isProtein()}isBonded(){return 0!==this.bondHash.countArray[this.index]}isRing(){return void 0!==this.residueType.getRings().atomRings[this.index-this.residueAtomOffset]}isAromatic(){return 1===this.aromatic}isPolarHydrogen(){let e=!1;return 1!==this.number||(e=!this.hasBondToElement(6)),e}isMetal(){return this.atomType.isMetal()}isNonmetal(){return this.atomType.isNonmetal()}isMetalloid(){return this.atomType.isMetalloid()}isHalogen(){return this.atomType.isHalogen()}isDiatomicNonmetal(){return this.atomType.isDiatomicNonmetal()}isPolyatomicNonmetal(){return this.atomType.isPolyatomicNonmetal()}isAlkaliMetal(){return this.atomType.isAlkaliMetal()}isAlkalineEarthMetal(){return this.atomType.isAlkalineEarthMetal()}isNobleGas(){return this.atomType.isNobleGas()}isTransitionMetal(){return this.atomType.isTransitionMetal()}isPostTransitionMetal(){return this.atomType.isPostTransitionMetal()}isLanthanide(){return this.atomType.isLanthanide()}isActinide(){return this.atomType.isActinide()}getDefaultValence(){return this.atomType.getDefaultValence()}getValenceList(){return this.atomType.getValenceList()}getOuterShellElectronCount(){return this.atomType.getOuterShellElectronCount()}distanceTo(e){const t=this.atomStore,i=e.atomStore,r=this.index,s=e.index,n=t.x[r]-i.x[s],o=t.y[r]-i.y[s],a=t.z[r]-i.z[s],c=n*n+o*o+a*a;return Math.sqrt(c)}connectedTo(e){const t=this.atomStore,i=e.atomStore,r=this.index,s=e.index;if(t.altloc&&i.altloc){const e=t.altloc[r],n=i.altloc[s];if(0!==e&&0!==n&&32!==e&&32!==n&&e!==n)return!1}const n=t.x[r]-i.x[s],o=t.y[r]-i.y[s],a=t.z[r]-i.z[s],c=n*n+o*o+a*a;if(c<48&&this.isCg())return!0;if(isNaN(c))return!1;const l=this.covalent+e.covalent,h=l+.3,u=l-.5;return cu*u}positionFromArray(e,t=0){return this.x=e[t+0],this.y=e[t+1],this.z=e[t+2],this}positionToArray(e=[],t=0){const i=this.index,r=this.atomStore;return e[t+0]=r.x[i],e[t+1]=r.y[i],e[t+2]=r.z[i],e}positionToVector3(e){return void 0===e&&(e=new t.Vector3),e.x=this.x,e.y=this.y,e.z=this.z,e}positionFromVector3(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}positionAdd(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}positionSub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}getResidueBonds(e=!1){const t=this.residueAtomOffset,i=this.index-this.residueAtomOffset,r=this.residueType.getBonds(),s=r.atomIndices1,n=r.atomIndices2;let o,a,c,l;for(e||(l=[]),o=s.indexOf(i);-1!==o;){if(c=n[o]+t,!l)return c;l.push(c),o=s.indexOf(i,o+1)}for(a=n.indexOf(i);-1!==a;){if(c=s[a]+t,!l)return c;l.push(c),a=n.indexOf(i,a+1)}return l}qualifiedName(e=!1){var t="";return this.resname&&!e&&(t+="["+this.resname+"]"),void 0!==this.resno&&(t+=this.resno),this.inscode&&(t+="^"+this.inscode),this.chainname&&(t+=":"+this.chainname),this.atomname&&(t+="."+this.atomname),this.altloc&&(t+="%"+this.altloc),this.structure.modelStore.count>1&&(t+="/"+this.modelIndex),t}clone(){return new xo(this.structure,this.index)}toObject(){return{index:this.index,residueIndex:this.residueIndex,resname:this.resname,x:this.x,y:this.y,z:this.z,element:this.element,chainname:this.chainname,resno:this.resno,serial:this.serial,vdw:this.vdw,covalent:this.covalent,hetero:this.hetero,bfactor:this.bfactor,altloc:this.altloc,atomname:this.atomname,modelIndex:this.modelIndex}}}function vo(e,t){const i=e[0]-t[0],r=e[1]-t[1],s=e[2]-t[2];return i*i+r*r+s*s}function wo(e,t){return Math.sqrt(vo(e,t))}const Ao=new Float32Array(3);class _o{constructor(t,i=!1){e.Debug&&Be.time("Kdtree build");const r=i?vo:wo,s=new Float32Array(3*t.atomCount),n=new Uint32Array(t.atomCount);let o=0;t.eachAtom((function(e){s[o+0]=e.x,s[o+1]=e.y,s[o+2]=e.z,n[o/3]=e.index,o+=3})),this.atomIndices=n,this.points=s,this.kdtree=new bo(s,r),e.Debug&&Be.timeEnd("Kdtree build")}nearest(e,i,r){e instanceof t.Vector3?e.toArray(Ao):e instanceof xo&&e.positionToArray(Ao);const s=this.kdtree.nearest(Ao,i,r),n=this.kdtree.indices,o=this.kdtree.nodes,a=this.atomIndices,c=[];for(let e=0,t=s.length;e":"3/4-Z","?":"X-Y","@":"Y-X",A:"Z+1/3",B:"Z+2/3",C:"X+2/3",D:"Y+1/3",E:"-Y+2/3",F:"X-Y+1/3",G:"Y-X+2/3",H:"-X+1/3",I:"X+1/3",J:"Y+2/3",K:"-Y+1/3",L:"X-Y+2/3",M:"Y-X+1/3",N:"-X+2/3",O:"2/3+X",P:"1/3+Y",Q:"1/3+Z",R:"2/3-Y",S:"1/3+X-Y",T:"2/3+Y-X",U:"1/3-X",V:"2/3-X",W:"1/3-Y",X:"1/3-Z",Y:"2/3+Y",Z:"1/3+Y-X","[":"2/3+X-Y","]":"1/3+X","^":"2/3+Z",_:"2/3-Z","`":"5/6+Z",a:"1/6+Z",b:"5/6-Z",c:"1/6-Z",d:"Z+5/6",e:"Z+1/6",f:"Z+1/4",g:"+Y"},Co={"P 1":" !#","P -1":" !#$%&","P 1 2 1":" !#$!&","P 1 21 1":" !#$'&","C 1 2 1":" !#$!&()#*)&","P 1 m 1":" !# %#","P 1 c 1":" !# %+","C 1 m 1":" !# %#()#(,#","C 1 c 1":" !# %+()#(,+","P 1 2/m 1":" !# %#$!&$%&","P 1 21/m 1":" !#$)&$%& ,#","C 1 2/m 1":" !# %#$!&$%&()#(,#*)&*,&","P 1 2/c 1":" !#$!-$%& %+","P 1 21/c 1":" !#$%&$)- ,+","C 1 2/c 1":" !#$!-$%& %+()#*)-*,&(,+","P 2 2 2":" !#$%#$!& %&","P 2 2 21":" !#$%+$!- %&","P 21 21 2":" !#$%#*)&(,&","P 21 21 21":" !#*%+$)-(,&","C 2 2 21":" !#$%+$!- %&()#*,+*)-(,&","C 2 2 2":" !#$%#$!& %&()#*,#*)&(,&","F 2 2 2":" !#$%#$!& %& )+$,+$)- ,-(!+*%+*!-(%-()#*,#*)&(,&","I 2 2 2":" !#$%# %&$!&.'/01/.120'2","I 21 21 21":" !#*%+$)-(,&()+$,#*!& %-","P m m 2":" !#$%# %#$!#","P m c 21":" !#$%+ %+$!#","P c c 2":" !#$%# %+$!+","P m a 2":" !#$%#(%#*!#","P c a 21":" !#$%+(%#*!+","P n c 2":" !#$%# ,+$)+","P m n 21":" !#*%+(%+$!#","P b a 2":" !#$%#(,#*)#","P n a 21":" !#$%+(,#*)+","P n n 2":" !#$%#(,+*)+","C m m 2":" !#$%# %#$!#()#*,#(,#*)#","C m c 21":" !#$%+ %+$!#()#*,+(,+*)#","C c c 2":" !#$%# %+$!+()#*,#(,+*)+","A m m 2":" !#$%# %#$!# )+$,+ ,+$)+","A b m 2":" !#$%# ,#$)# )+$,+ %+$!+","A m a 2":" !#$%#(%#*!# )+$,+(,+*)+","A b a 2":" !#$%#(,#*)# )+$,+(%+*!+","F m m 2":" !#$%# %#$!# )+$,+ ,+$)+(!+*%+(%+*!+()#*,#(,#*)#","F d d 2":" !#$%#345675 )+$,+3896:9(!+*%+;49<79()#*,#;85<:5","I m m 2":" !#$%# %#$!#()+*,+(,+*)+","I b a 2":" !#$%#(,#*)#()+*,+ %+$!+","I m a 2":" !#$%#(%#*!#()+*,+ ,+$)+","P 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!#","P 2/n 2/n 2/n":" !#$%#$!& %&*,-()-(,+*)+","P 2/c 2/c 2/m":" !#$%#$!- %-$%& !& %+$!+","P 2/b 2/a 2/n":" !#$%#$!& %&*,&()&(,#*)#","P 21/m 2/m 2/a":" !#*%#$!&(%&$%&(!& %#*!#","P 2/n 21/n 2/a":" !#*%#*)- ,-$%&(!&(,+$)+","P 2/m 2/n 21/a":" !#*%+*!- %&$%&(!-(%+$!#","P 21/c 2/c 2/a":" !#*%#$!-(%-$%&(!& %+*!+","P 21/b 21/a 2/m":" !#$%#*)&(,&$%& !&(,#*)#","P 21/c 21/c 2/n":" !#*,#$)-(%-$%&()& ,+*!+","P 2/b 21/c 21/m":" !#$%+$)- ,&$%& !- ,+$)#","P 21/n 21/n 2/m":" !#$%#*)-(,-$%& !&(,+*)+","P 21/m 21/m 2/n":" !#$%#*'&.,&*,&.'& %#$!#","P 21/b 2/c 21/n":" !#*,+$!-(,&$%&()- %+*)#","P 21/b 21/c 21/a":" !#*%+$)-(,&$%&(!- ,+*)#","P 21/n 21/m 21/a":" !#0%/$'&.12$%&.!2 1#0'/","C 2/m 2/c 21/m":" !#$%+$!- %&$%& !- %+$!#()#*,+*)-(,&*,&()-(,+*)#","C 2/m 2/c 21/a":" !#$,+$)- %&$%& )- ,+$!#()#*%+*!-(,&*,&(!-(%+*)#","C 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!#()#*,#*)&(,&*,&()&(,#*)#","C 2/c 2/c 2/m":" !#$%#$!- %-$%& !& %+$!+()#*,#*)-(,-*,&()&(,+*)+","C 2/m 2/m 2/a":" !#$,#$)& %&$%& )& ,#$!#()#*%#*!&(,&*,&(!&(%#*)#","C 2/c 2/c 2/a":" !#*,#$!&(,&$,-(!- ,+*!+()#$%#*)& %&*%- )-(%+$)+","F 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!# )+$,+$)- ,-$,- )- ,+$)+(!+*%+*!-(%-*%-(!-(%+*!+()#*,#*)&(,&*,&()&(,#*)#","F 2/d 2/d 2/d":" !#$%#$!& %&64=37=345675 )+$,+$)- ,-68>3:>3896:9(!+*%+*!-(%-<4>;7>;49<79()#*,#*)&(,&<8=;:=;85<:5","I 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!#()+*,+*)-(,-*,-()-(,+*)+","I 2/b 2/a 2/m":" !#$%#*)&(,&$%& !&(,#*)#()+*,+$!- %-*,-()- %+$!+","I 21/b 21/c 21/a":" !#*%+$)-(,&$%&(!- ,+*)#()+$,#*!& %-*,- )&(%#$!+","I 21/m 21/m 21/a":" !#$,#$)& %&$%& )& ,#$!#()+*%+*!-(,-*,-(!-(%+*)+","P 4":" !#$%#% #!$#","P 41":" !#$%+% 5!$9","P 42":" !#$%#% +!$+","P 43":" !#$%+% 9!$5","I 4":" !#$%#% #!$#()+*,+,(+)*+","I 41":" !#*,+%(5)$9()+$%#, 9!*5","P -4":" !#$%#!$&% &","I -4":" !#$%#!$&% &()+*,+)*-,(-","P 4/m":" !#$%#% #!$#$%& !&!$&% &","P 42/m":" !#$%#% +!$+$%& !&!$-% -","P 4/n":" !#$%#,(#)*#*,&()&!$&% &","P 42/n":" !#$%#,(+)*+*,-()-!$&% &","I 4/m":" !#$%#% #!$#$%& !&!$&% &()+*,+,(+)*+*,-()-)*-,(-","I 41/a":" !#*,+%(5)$9$,=(!>!$&,(-()+$%#, 9!*5*%> )=)*-% &","P 4 2 2":" !#$%#% #!$#$!& %&! &%$&","P 4 21 2":" !#$%#,(#)*#*)&(,&! &%$&","P 41 2 2":" !#$%+% 5!$9$!& %-! >%$=","P 41 21 2":" !#$%+,(5)*9*)=(,>! &%$-","P 42 2 2":" !#$%#% +!$+$!& %&! -%$-","P 42 21 2":" !#$%#,(+)*+*)-(,-! &%$&","P 43 2 2":" !#$%+% 9!$5$!& %-! =%$>","P 43 21 2":" !#$%+,(9)*5*)>(,=! &%$-","I 4 2 2":" !#$%#% #!$#$!& %&! &%$&()+*,+,(+)*+*)-(,-)(-,*-","I 41 2 2":" !#*,+%(5)$9*!> ,=)(-%$&()+$%#, 9!*5$)=(%>! &,*-","P 4 m m":" !#$%#% #!$# %#$!#%$#! #","P 4 b m":" !#$%#% #!$#(,#*)#,*#)(#","P 42 c m":" !#$%#% +!$+ %+$!+%$#! #","P 42 n m":" !#$%#,(+)*+(,+*)+%$#! #","P 4 c c":" !#$%#% #!$# %+$!+%$+! +","P 4 n c":" !#$%#% #!$#(,+*)+,*+)(+","P 42 m c":" !#$%#% +!$+ %#$!#%$+! +","P 42 b c":" !#$%#% +!$+(,#*)#,*+)(+","I 4 m m":" !#$%#% #!$# %#$!#%$#! #()+*,+,(+)*+(,+*)+,*+)(+","I 4 c m":" !#$%#% #!$# %+$!+%$+! +()+*,+,(+)*+(,#*)#,*#)(#","I 41 m d":" !#*,+%(5)$9 %#*)+%*5) 9()+$%#, 9!*5(,+$!#,$9!(5","I 41 c d":" !#*,+%(5)$9 %+*)#%*9) 5()+$%#, 9!*5(,#$!+,$5!(9","P -4 2 m":" !#$%#% &!$&$!& %&%$#! #","P -4 2 c":" !#$%#% &!$&$!- %-%$+! +","P -4 21 m":" !#$%#% &!$&*)&(,&,*#)(#","P -4 21 c":" !#$%#% &!$&*)-(,-,*+)(+","P -4 m 2":" !#$%#!$&% & %#$!#! &%$&","P -4 c 2":" !#$%#% &!$& %+$!+! -%$-","P -4 b 2":" !#$%#% &!$&(,#*)#)(&,*&","P -4 n 2":" !#$%#% &!$&(,+*)+)(-,*-","I -4 m 2":" !#$%#% &!$& %#$!#! &%$&()+*,+,(-)*-(,+*)+)(-,*-","I -4 c 2":" !#$%#% &!$& %+$!+! -%$-()+*,+,(-)*-(,#*)#)(&,*&","I -4 2 m":" !#$%#% &!$&$!& %&%$#! #()+*,+,(-)*-*)-(,-,*+)(+","I -4 2 d":" !#$%#% &!$&*!>(%>,$9) 9()+*,+,(-)*-$)= ,=%*5!(5","P 4/m 2/m 2/m":" !#$%#% #!$#$!& %&! &%$&$%& !&!$&% & %#$!#%$#! #","P 4/m 2/c 2/c":" !#$%#% #!$#$!- %-! -%$-$%& !&!$&% & %+$!+%$+! +","P 4/n 2/b 2/m":" !#$%#% #!$#$!& %&! &%$&*,&()&)*&,(&(,#*)#,*#)(#","P 4/n 2/n 2/c":" !#$%#% #!$#$!& %&! &%$&*,-()-)*-,(-(,+*)+,*+)(+","P 4/m 21/b 2/m":" !#$%#% #!$#*)&(,&)(&,*&$%& !&!$&% &(,#*)#,*#)(#","P 4/m 21/n 2/c":" !#$%#% #!$#*)-(,-)(-,*-$%& !&!$&% &(,+*)+,*+)(+","P 4/n 21/m 2/m":" !#$%#,(#)*#*)&(,&! &%$&*,&()&!$&% & %#$!#,*#)(#","P 4/n 2/c 2/c":" !#$%#,(#)*#*)-(,-! -%$-*,&()&!$&% & %+$!+,*+)(+","P 42/m 2/m 2/c":" !#$%#% +!$+$!& %&! -%$-$%& !&!$-% - %#$!#%$+! +","P 42/m 2/c 2/m":" !#$%#% +!$+$!- %-! &%$&$%& !&!$-% - %+$!+%$#! #","P 42/n 2/b 2/c":" !#$%#,(+)*+$!- %-)(&,*&*,-()-!$&% &(,#*)#%$+! +","P 42/n 2/n 2/m":" !#$%#,(+)*+$!& %&)(-,*-*,-()-!$&% &(,+*)+%$#! #","P 42/m 21/b 2/c":" !#$%#% +!$+*)&(,&)(-,*-$%& !&!$-% -(,#*)#,*+)(+","P 42/m 21/n 2/m":" !#$%#,./'*/*'-.,-! &%$&$%& !&'*-,.-.,/*'/%$#! #","P 42/n 21/m 2/c":" !#$%#,(+)*+*)-(,-! &%$&*,-()-!$&% & %#$!#,*+)(+","P 42/n 21/c 2/m":" !#$%#,(+)*+*)&(,&! -%$-*,-()-!$&% & %+$!+,*#)(#","I 4/m 2/m 2/m":" !#$%#% #!$#$!& %&! &%$&$%& !&!$&% & %#$!#%$#! #()+*,+,(+)*+*)-(,-)(-,*-*,-()-)*-,(-(,+*)+,*+)(+","I 4/m 2/c 2/m":" !#$%#% #!$#$!- %-! -%$-$%& !&!$&% & %+$!+%$+! +()+*,+,(+)*+*)&(,&)(&,*&*,-()-)*-,(-(,#*)#,*#)(#","I 41/a 2/m 2/d":" !#*,+%(5)$9*!> ,=)(-%$&$,=(!>!$&,(-(,+$!#,$9!(5()+$%#, 9!*5$)=(%>! &,*-*%> )=)*-% & %#*)+%*5) 9","I 41/a 2/c 2/d":" !#*,+%(5)$9*!= ,>)(&%$-$,=(!>!$&,(-(,#$!+,$5!(9()+$%#, 9!*5$)>(%=! -,*&*%> )=)*-% & %+*)#%*9) 5","P 3":" !#%?#@$#","P 31":" !#%?A@$B","P 32":" !#%?B@$A","H 3":" !#%?#@$#CDAEFAGHAIJBKLBMNB","R 3":" !## !!# ","P -3":" !#%?#@$#$%&!@&? &","H -3":" !#%?#@$#$%&!@&? &OPQRSQTUQVWXYZX[]X]Y^W[^ZV^UR_PT_SO_","R -3":" !## !!# $%&&$%%&$","P 3 1 2":" !#%?#@$#%$&@!& ?&","P 3 2 1":" !#%?#@$#! &?%&$@&","P 31 1 2":" !#%?Q@$^%$_@!X ?&","P 31 2 1":" !#%?A@$B! &?%_$@X","P 32 1 2":" !#%?^@$Q%$X@!_ ?&","P 32 2 1":" !#%?B@$A! &?%X$@_","H 3 2":" !#%?#@$#! &?%&$@&OPQRSQTUQY]X[WXVZX]Y^W[^ZV^PO_SR_UT_","R 3 2":" !## !!# %$&$&%&%$","P 3 m 1":" !#%?#@$#%$#@!# ?#","P 3 1 m":" !#%?#@$#! #?%#$@#","P 3 c 1":" !#%?#@$#%$+@!+ ?+","P 3 1 c":" !#%?#@$#! +?%+$@+","H 3 m":" !#%?#@$#%$#@!# ?#OPQRSQTUQRUQTPQOSQ]Y^W[^ZV^WV^ZY^][^","R 3 m":" !## !!# ! # #!#! ","H 3 c":" !#%?#@$#%$+@!+ ?+OPQRSQTUQRU`TP`OS`]Y^W[^ZV^WVaZYa][a","R 3 c":" !## !!# '././'/'.","P -3 1 2/m":" !#%?#@$#%$&@!& ?&$%&!@&? &! #?%#$@#","P -3 1 2/c":" !#%?#@$#%$-@!- ?-$%&!@&? &! +?%+$@+","P -3 2/m 1":" !#%?#@$#! &?%&$@&$%&!@&? &%$#@!# ?#","P -3 2/c 1":" !#%?#@$#! -?%-$@-$%&!@&? &%$+@!+ ?+","H -3 2/m":" !#%?#@$#! &?%&$@&$%&!@&? &%$#@!# ?#OPQRSQTUQY]X[WXVZXVWXYZX[]XRUQTPQOSQ]Y^W[^ZV^PO_SR_UT_UR_PT_SO_WV^ZY^][^","R -3 2/m":" !## !!# %$&$&%&%$$%&&$%%&$! # #!#! ","H -3 2/c":" !#%?#@$#! -?%-$@-$%&!@&? &%$+@!+ ?+OPQRSQTUQY]b[WbVZbVWXYZX[]XRU`TP`OS`]Y^W[^ZV^POcSRcUTcUR_PT_SO_WVaZYa][a","R -3 2/c":" !## !!# 102021210$%&&$%%&$'././'/'.","P 6":" !#%?#@$#$%#!@#? #","P 61":" !#%?A@$B$%/!@d? e","P 65":" !#%?B@$A$%/!@e? d","P 62":" !#%?^@$Q$%#!@^? Q","P 64":" !#%?Q@$^$%#!@Q? ^","P 63":" !#%?#@$#$%+!@+? +","P -6":" !#%?#@$# !&%?&@$&","P 6/m":" !#%?#@$#$%#!@#? #$%&!@&? & !&%?&@$&","P 63/m":" !#%?#@$#$%+!@+? +$%&!@&? & !-%?-@$-","P 6 2 2":" !#%?#@$#$%#!@#? #! &?%&$@&%$&@!& ?&","P 61 2 2":" !#%?Q@$^$%+!@`? a! X?%&$@_%$b@!- ?c","P 65 2 2":" !#%?^@$Q$%+!@a? `! _?%&$@X%$c@!- ?b","P 62 2 2":" !#%?^@$Q$%#!@^? Q! _?%&$@X%$_@!& ?X","P 64 2 2":" !#%?Q@$^$%#!@Q? ^! X?%&$@_%$X@!& ?_","P 63 2 2":" !#%?#@$#$%+!@+? +! &?%&$@&%$-@!- ?-","P 6 m m":" !#%?#@$#$%#!@#? #%$#@!# ?#! #?%#$@#","P 6 c c":" !#%?#@$#$%#!@#? #%$+@!+ ?+! +?%+$@+","P 63 c m":" !#%?#@$#$%+!@+? +%$+@!+ ?+! #?%#$@#","P 63 m c":" !#%?#@$#$%+!@+? +%$#@!# ?#! +?%+$@+","P -6 m 2":" !#%?#@$# !&%?&@$&%$#@!# ?#%$&@!& ?&","P -6 c 2":" !#%?#@$# !-%?-@$-%$+@!+ ?+%$&@!& ?&","P -6 2 m":" !#%?#@$# !&%?&@$&! &?%&$@&! #?%#$@#","P -6 2 c":" !#%?#@$# !-%?-@$-! &?%&$@&! +?%+$@+","P 6/m 2/m 2/m":" !#%?#@$#$%#!@#? #! &?%&$@&%$&@!& ?&$%&!@&? & !&@$&%?&%$#@!# ?#! #?%#$@#","P 6/m 2/c 2/c":" !#%?#@$#$%#!@#? #! -?%-$@-%$-@!- ?-$%&!@&? & !&@$&%?&%$+@!+ ?+! +?%+$@+","P 63/m 2/c 2/m":" !#%?#@$#$%+!@+? +! -?%-$@-%$&@!& ?&$%&!@&? & !-@$-%?-%$+@!+ ?+! #?%#$@#","P 63/m 2/m 2/c":" !#%?#@$#$%+!@+? +! &?%&$@&%$-@!- ?-$%&!@&? & !-@$-%?-%$#@!# ?#! +?%+$@+","P 2 3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ","F 2 3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ","I 2 3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-(","P 21 3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(","I 21 3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- ","P 2/m -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$","P 2/n -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& *,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*","F 2/m -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$ )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-($,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(*%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- *,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$","F 2/d -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& 64=37=345675=64=375345674=67=3453756 )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(68>3:>3896:9=<8=;:5;85<:4><7>;49;79<(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(<4>;7>;49<79>68>3:93896:8=<:=;85;:5<()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- <8=;:=;8f<:f><4>;79;49<78>6:>3893:96","I 2/m -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-(*,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*","P 21/a -3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&($%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*","I 21/a -3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&($%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*()+$,#*g& %-+()#$,&*!- %)+(,#$!&*%- *,- )&(%#$!+-*,& )#(%+$!,-*)& %#(!+$","P 4 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$","P 42 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*","F 4 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$ )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(-%*-!*+%(+ +,$+)$-, -)#)*#,(&)(&,*(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() -,$-)$+, +(#,*#)*&,(&)+!*+%(-!(-%*()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(&,*&)*#,(#(+%*+!*-%(-!+)$+, -) -,$","F 41 3 2":" !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=46 )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<(!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>86","I 4 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*","P 43 3 2":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(7;>46=:<5839398<5:6=4;>75:<983>7;=46","P 41 3 2":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<","I 41 3 2":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- 7;>46=:<5839398<5:6=4;>75:<983>7;=46","P -4 3 m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% ","F -4 3 m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(+%*+!*-%(- +)$+,$-) -,#)(#,*&)*&,((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() +,$+)$-, -(#)*#,*&)(&,+!(+%*-!*-%(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(#,*#)*&,(&(+!*+%*-!(-%+) +,$-)$-, ","I -4 3 m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,(","P -4 3 n":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,(","F -4 3 c":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,( )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-() #,$#)$&, &(#!*#%*&!(&%+! +%$-!$-% (!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(!(#%*#!*&%(& +!$+%$-! -%#) #,$&)$&, ()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ! +%$+!$-% - #)$#,$&) &,#!(#%*&!*&%(","I -4 3 d":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(7354<9:6>8;=357<946>:;=857394<>:6=8;()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- :;98657<=43>;9:658<=73>49:;586=7<>43","P 4/m -3 2/m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ","P 4/n -3 2/n":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$*,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(","P 42/m -3 2/n":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(","P 42/n -3 2/m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(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, &)$#,$#) ()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ! -%$-!$+% + #,$#)$&, &)#!*#%(&!(&%**,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$%$+! +% -!$-$&) &, #)$#,&%(&!*#%*#!(","F 41/d -3 2/m":" !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=4664=3:>;85<79=64>3:5;89<74=6:>385;79<,$+! #%(-)*&*&)(-% #!$+,-%(&)*+,$#! )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<68>37=;49<:5=<8>;753496:4><:=;893756,*#!(+% &)$-*-!(&, +)$#%-, &!$+%*#)((!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<<4>;:=389675>68=379;45<:8=<7>;453:96%$#) +,(&!*-$&! -,(#)*+%&% -)$#,*+!(()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>86<8=;7>3456:9><4=;:9385678>67=349;:5<%*+)(#, -!$&$-) &%(+!*#,&,(-!*#%$+) ","F 41/d -3 2/c":" !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=46<8>;7=3496:5><8=;793456:8><7=;493:56%*#)(+, &!$-$-! &,(+)*#%&, -!$#%*+)( )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<<4=;:>385679>64=3:9;85<78=67>345;:9<%$+) #,(-!*&$&) -%(#!*+,&%(-)*#,$+! (!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<68=37>;45<:9=<4>;:5389674>6:=389;75<,*+!(#% -)$&*-)(&% +!$#,-,(&!*+%$#) ()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>8664>3:=;89<75=68>375;49<:4=<:>;853796,$#! +%(&)*-*&!(-, #)$+%-% &)$+,*#!(","I 4/m -3 2/m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,**,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(","I 41/a -3 2/d":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<$%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*4<97358;=:6>6>:;=8357<94=8;>:694<573()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- 7;>46=:<5839398<5:6=4;>75:<983>7;=46*,- )&(%#$!+-*,& )#(%+$!,-*)& %#(!+$865:;943>7<=<=73>4;9:658>43=7<5869:;","P 1 1 2":" !#$%#","P 1 1 21":" !#$%+","B 1 1 2":" !#$%#(g+*%+","A 1 2 1":" !#$!& )+$)-","C 1 21 1":" !#$)&()#*!&","I 1 2 1":" !#$!&.'/0'2","I 1 21 1":" !#$)&.'/0!-","P 1 1 m":" !# !&","P 1 1 b":" !# )&","B 1 1 m":" !# !&(!+(!-","B 1 1 b":" !# )&(!+()-","P 1 1 2/m":" !# !&$%#$%&","P 1 1 21/m":" !#$%+$%& !-","B 1 1 2/m":" !# !&$%#$%&(!+(!-*%+*%-","P 1 1 2/b":" !#$,#$%& )&","P 1 1 21/b":" !#$%&$,+ )-","B 1 1 2/b":" !#$,#$%& )&(!+*,+*%-()-","P 21 2 2":" !#$!&(%&*%#","P 2 21 2":" !# ,&$)&$%#","P 21 21 2 (a)":" !#*,#.%&$'&","P 21 2 21":" !#$!&(%-*%+","P 2 21 21":" !# %&$)-$,+","C 2 2 21a)":" !#*%+(,&$)-()#$,+ %&*!-","C 2 2 2a":" !#*,#.%&$'&()#$%# ,&*!&","F 2 2 2a":" !#*,#.%&$'& '/*%/.12$!2.!/$,/ %20'2.'#$%# 1&0!&","I 2 2 2a":" !#*,#.%&$'&()+$%+*!- ,-","P 21/m 21/m 2/n a":" !#*,#$)&(%&$%&.'& ,#*!#","P 42 21 2a":" !#*,#%.+'$+$'&.%&! -,*-","I 2 3a":" !#*,#.%&$'&!# ,- '&$%/$# !-*!/$%&.%()+$%+ ,-*!-)+(%&(!-*,#*+()&$)#*,- ,"},Po=/^[1-9]$/;function Io(e){let t="";return e.length>0&&(t=":"+x(e).join(" OR :")),new ye(t)}class ko{constructor(e=""){this.name=e,this.partList=[]}get type(){return"Assembly"}addPart(e,t){const i=new Mo(e,t);return this.partList.push(i),i}getAtomCount(e){return this.partList.reduce(((t,i)=>t+i.getAtomCount(e)),0)}getResidueCount(e){return this.partList.reduce(((t,i)=>t+i.getResidueCount(e)),0)}getInstanceCount(){let e=0;return this.partList.forEach((function(t){e+=t.matrixList.length})),e}isIdentity(e){if(1!==this.partList.length)return!1;const i=this.partList[0];if(1!==i.matrixList.length)return!1;if(!(new t.Matrix4).equals(i.matrixList[0]))return!1;let r=[];return e.eachChain((function(e){r.push(e.chainname)})),r=x(r),i.chainList.length===r.length}getBoundingBox(e){const i=new t.Box3;return this.partList.forEach((function(t){const r=t.getBoundingBox(e);i.expandByPoint(r.min),i.expandByPoint(r.max)})),i}getCenter(e){return this.getBoundingBox(e).getCenter(new t.Vector3)}getSelection(){let e=[];return this.partList.forEach((function(t){e=e.concat(t.chainList)})),Io(e)}}class Mo{constructor(e=[],t=[]){this.matrixList=e,this.chainList=t}get type(){return"AssemblyPart"}_getCount(e,t){let i=0;return e.eachChain((e=>{(0===this.chainList.length||this.chainList.includes(e.chainname))&&(i+=e[t])})),this.matrixList.length*i}getAtomCount(e){return this._getCount(e,"atomCount")}getResidueCount(e){return this._getCount(e,"residueCount")}getBoundingBox(e){const i=new t.Box3,r=new t.Box3,s=this.getSelection(),n=e.getBoundingBox(s);return this.matrixList.forEach((function(e){r.copy(n).applyMatrix4(e),i.expandByPoint(r.min),i.expandByPoint(r.max)})),i}getSelection(){return Io(this.chainList)}getView(e){const t=this.getSelection();return t?e.getView(t):e}getInstanceList(){const e=[];for(let t=0,i=this.matrixList.length;t0&&this.addResidueType(this.ri-1),l.growIfFull(),l.resno[this.ri]=s,void 0!==o&&(l.sstruc[this.ri]=o.charCodeAt(0)),void 0!==a&&(l.inscode[this.ri]=a.charCodeAt(0)),l.atomOffset[this.ri]=this.ai,l.atomCount[this.ri]=0,l.count+=1,l.chainIndex[this.ri]=this.ci,h.residueCount[this.ci]+=1),c.count+=1,c.residueIndex[this.ai]=this.ri,l.atomCount[this.ri]+=1,this.currentModelindex=e,this.currentChainid=i,this.currentResname=r,this.currentResno=s,this.currentInscode=a,this.currentHetero=n}finalize(){this.previousResname=this.currentResname,this.previousHetero=this.currentHetero,this.ri>-1&&this.addResidueType(this.ri)}}function To(t,i){if(!i)return;e.Debug&&Be.time("assignSecondaryStructure");const r=[];t.eachModel((function(e){e.eachChain((function(e){r.push(e.chainname)}))}));const s=r.slice().sort(),n=[];s.forEach((function(e){n.push(r.indexOf(e))}));const o=i.helices.filter((function(e){return y(s,e[0])>=0}));o.sort((function(e,t){const i=e[0],r=t[0],o=e[1],a=t[1];if(i===r)return o===a?0:o=0}));c.sort((function(e,t){const i=e[0],r=t[0];if(i===r)return 0;const o=y(s,i),a=y(s,r);return n[o]=e.residueCount)continue;o.index=n+s,a.index=n+s+t,c.index=o.traceAtomIndex,l.index=a.traceAtomIndex;const h=c.distanceTo(l);if(Math.abs(h-i[t-2])>r)return!1}return!0},r=function(e,t){return i(e,t,[5.45,5.18,6.37],2.1)},s=function(e,t){return i(e,t,[6.1,10.4,13],1.42)};return function(i){e.Debug&&Be.time("calculateSecondaryStructure"),i.eachPolymer((function(e){if(e.residueCount<4)return;if(e.isCg())!function(e){const i=e.residueStore,r=e.residueIndexStart,s=new go(e).position,n=new t.Vector3,o=new t.Vector3;for(let t=0,a=e.residueCount;t1&&s.bending[t]<20&&(i.sstruc[r+t]="h".charCodeAt(0),i.sstruc[r+t+1]="h".charCodeAt(0))}}(e);else{if(!e.isProtein())return;!function(e){const t=e.residueStore,i=e.residueIndexStart;for(let n=0,o=e.residueCount;n=t;)i=Math.floor(i/t),s+=Ro[i%t],r+=1;return r>=5&&Be.warn("chainname overflow"),s}function $o(t,i=!1){e.Debug&&Be.time("calculateChainnames");let r=!0;if(t.eachChain((function(e){e.chainname&&(r=!1)})),r){const e=t.modelStore,r=t.chainStore,s=t.residueStore,n=function(t,i,n,o){const a=r.count;for(let e=0;e{u.add(t),e.forEach((e=>{u.add(e)}))}))),t.eachResidue((function(e){if(!i&&h){const t=e.atomCount,i=e.atomOffset;if(t>500)return void Be.warn("more than 500 atoms, skip residue for auto-bonding",e.qualifiedName());if("auto"===r&&e.hetero)for(let t=e.atomOffset;t{d.forEach((i=>{e.push(t.clone().multiply(i))}))})),h.addPart(e)}else h.addPart(u);const m=new t.Vector3,p=new ko("SUPERCELL"),f=Array.prototype.concat.call(l(m.set(1,0,0)),l(m.set(0,1,0)),l(m.set(0,0,1)),l(m.set(-1,0,0)),l(m.set(0,-1,0)),l(m.set(0,0,-1)),l(m.set(1,1,0)),l(m.set(1,0,1)),l(m.set(0,1,1)),l(m.set(-1,-1,0)),l(m.set(-1,0,-1)),l(m.set(0,-1,-1)),l(m.set(1,-1,-1)),l(m.set(1,1,-1)),l(m.set(1,-1,1)),l(m.set(-1,1,1)),l(m.set(-1,-1,1)),l(m.set(-1,1,-1)),l(m.set(0,1,-1)),l(m.set(0,-1,1)),l(m.set(1,0,-1)),l(m.set(-1,0,1)),l(m.set(1,-1,0)),l(m.set(-1,1,0)),l(),l(m.set(1,1,1)),l(m.set(-1,-1,-1)));if(i.biomolDict.NCS){const e=[];f.forEach((function(t){d.forEach((function(i){e.push(t.clone().multiply(i))}))})),p.addPart(e)}else p.addPart(f);i.biomolDict.UNITCELL=h,i.biomolDict.SUPERCELL=p,e.Debug&&Be.timeEnd("buildUnitcellAssembly")}const Go=["H","C","O","N","S","P"],Uo=["NA","CL","FE"];function jo(e){let t=e.toUpperCase(),i=0,r=0;for(let e=0;e0)break;++i}else r=e+1;(i>0||r=3&&-1!==Go.indexOf(t[0])?t[0]:""}function Ho(e){const t=e.bondHash,i=t.countArray,r=t.offsetArray,s=t.indexArray,n=e.getBondProxy();e.eachResidue((function(e){const t=e.residueType;if(void 0!==t.bonds)return;var o=e.atomOffset,a=[],c=[],l=[],h={};const u=o+e.atomCount;e.eachAtom((function(e){const t=e.index,d=r[t];for(let e=0,r=i[t];e=u)continue;let i=n.atomIndex2;if(i=u)continue;if(t>i){const e=i;i=t,t=e}const r=t+"|"+i;void 0===h[r]&&(h[r]=!0,a.push(t-o),c.push(i-o),l.push(n.bondOrder))}})),t.bonds={atomIndices1:a,atomIndices2:c,bondOrders:l}}))}const Wo=[3,11,19,37,55,87],qo=[4,12,20,38,56,88],Xo=[6,15,16,34],Yo=[1,7,8,9,17,35,53],Ko=[2,10,18,36,54,86],Zo=[13,30,31,48,49,50,80,81,82,83,84,85,112],Qo=[5,14,32,33,51,52,85],Jo=[9,17,35,53,85];class ea{constructor(e,t,i){this.structure=e,this.atomname=t,i=i||jo(t),this.element=i,this.number=Lr[i]||0,this.vdw=Nr[this.number]||2,this.covalent=zr[this.number]||1.6}getDefaultValence(){const e=Vr[this.number];return e?e[0]:-1}getValenceList(){return Vr[this.number]||[]}getOuterShellElectronCount(){return Gr[this.number]||2}isMetal(){return this.isAlkaliMetal()||this.isAlkalineEarthMetal()||this.isLanthanide()||this.isActinide()||this.isTransitionMetal()||this.isPostTransitionMetal()}isNonmetal(){return this.isDiatomicNonmetal()||this.isPolyatomicNonmetal()||this.isNobleGas()}isMetalloid(){return Qo.includes(this.number)}isHalogen(){return Jo.includes(this.number)}isDiatomicNonmetal(){return Yo.includes(this.number)}isPolyatomicNonmetal(){return Xo.includes(this.number)}isAlkaliMetal(){return Wo.includes(this.number)}isAlkalineEarthMetal(){return qo.includes(this.number)}isNobleGas(){return Ko.includes(this.number)}isTransitionMetal(){const e=this.number;return e>=21&&e<=29||e>=39&&e<=47||e>=72&&e<=79||e>=104&&e<=108}isPostTransitionMetal(){return Zo.includes(this.number)}isLanthanide(){return this.number>=57&&this.number<=71}isActinide(){return this.number>=89&&this.number<=103}}class ta{constructor(e){this.structure=e,this.dict={},this.list=[],this.structure=e}add(e,t){const i=function(e,t){return e+"|"+t}(e=e.toUpperCase(),t=t?t.toUpperCase():jo(e));let r=this.dict[i];if(void 0===r){const s=new ea(this.structure,e,t);r=this.list.length,this.dict[i]=r,this.list.push(s)}return r}get(e){return this.list[e]}}class ia{constructor(e,t,i,r,s,n){this.structure=e,this.bondReferenceAtomIndices=[],this.resname=t,this.atomTypeIdList=i,this.hetero=r?1:0,this.chemCompType=s,this.bonds=n,this.atomCount=i.length,this.moleculeType=this.getMoleculeType(),this.backboneType=this.getBackboneType(0),this.backboneEndType=this.getBackboneType(-1),this.backboneStartType=this.getBackboneType(1),this.backboneIndexList=this.getBackboneIndexList();const o=is[this.backboneType],a=is[this.backboneStartType],c=is[this.backboneEndType],h=this.getAtomIndexByName(o.trace);this.traceAtomIndex=l(h,-1);const u=this.getAtomIndexByName(o.direction1);this.direction1AtomIndex=l(u,-1);const d=this.getAtomIndexByName(o.direction2);this.direction2AtomIndex=l(d,-1);const m=this.getAtomIndexByName(a.backboneStart);this.backboneStartAtomIndex=l(m,-1);const p=this.getAtomIndexByName(c.backboneEnd);let f;this.backboneEndAtomIndex=l(p,-1),f=Yr.includes(t)?this.getAtomIndexByName("N1"):this.getAtomIndexByName("N3"),this.rungEndAtomIndex=l(f,-1)}getBackboneIndexList(){const e=[];let t;switch(this.moleculeType){case 3:t=es;break;case 4:case 5:t=ts;break;default:return e}const i=this.structure.atomMap,r=this.atomTypeIdList;for(let s=0,n=this.atomCount;s500)e.Debug&&Be.warn("more than 500 atoms, skip residue for auto-bonding",t.qualifiedName());else if(n>50){const e=new _o(t,!0),i=t.isCg()?1.2:2.3;for(let t=o;t=0||oa(e,t);this.rings={atomRings:e.atomRings,rings:e.rings}}isAromatic(e){return this.aromaticAtoms=this.getAromatic(e),1===this.aromaticAtoms[e.index-e.residueAtomOffset]}calculateAromatic(e){const t=this.aromaticAtoms=new Uint8Array(this.atomCount),i=this.getRings().rings,r=i.map((t=>function(e){if(e.some((e=>!ra.includes(e.number))))return!1;let t=0;const i=new Js(3,e.length),r=i.data;e.forEach((e=>{r[t+0]=e.x,r[t+1]=e.y,r[t+2]=e.z,t+=3}));return new oo(i).vecC.length()this.structure.getAtomProxy(t+e.atomOffset)))))),s=this.aromaticRings=[];i.forEach(((e,i)=>{r[i]&&(s.push(e),e.forEach((e=>t[e]=1)))}))}assignBondReferenceAtomIndices(){const e=this.getBondGraph(),t=this.getRings(),i=t.atomRings,r=t.rings,s=this.bonds,n=s.atomIndices1,o=s.atomIndices2,a=s.bondOrders,c=this.bondReferenceAtomIndices,l=s.atomIndices1.length;c.length=0;for(let t=0;t1)for(let i=0;i1)for(let i=0;i=0;e--)p[f++]=o[e];const g=e.rings.length;for(let t=0;t0?n[c]!==t&&n[t]!==c&&na(e,t,c):(r[c]=1,s[a++]=c,n[c]=t)}}}const aa=4;class ca{constructor(e){this.structure=e,this.dict={},this.list=[]}add(e,t,i,r="",s){const n=function(e,t,i,r=""){return e+"|"+t.join(",")+"|"+(i?1:0)+"|"+r}(e=e.toUpperCase(),t,i,r);let o=this.dict[n];if(void 0===o){const a=new ia(this.structure,e,t,i,r,s);o=this.list.length,this.dict[n]=o,this.list.push(a)}return o}get(e){return this.list[e]}}class la{constructor(e,i=0){this.structure=e,this.index=i,this.bondStore=e.bondStore,this._v12=new t.Vector3,this._v13=new t.Vector3,this._ap1=this.structure.getAtomProxy(),this._ap2=this.structure.getAtomProxy(),this._ap3=this.structure.getAtomProxy()}get atom1(){return this.structure.getAtomProxy(this.atomIndex1)}get atom2(){return this.structure.getAtomProxy(this.atomIndex2)}get atomIndex1(){return this.bondStore.atomIndex1[this.index]}set atomIndex1(e){this.bondStore.atomIndex1[this.index]=e}get atomIndex2(){return this.bondStore.atomIndex2[this.index]}set atomIndex2(e){this.bondStore.atomIndex2[this.index]=e}get bondOrder(){return this.bondStore.bondOrder[this.index]}set bondOrder(e){this.bondStore.bondOrder[this.index]=e}getOtherAtomIndex(e){return e===this.atomIndex1?this.atomIndex2:this.atomIndex1}getOtherAtom(e){return this.structure.getAtomProxy(this.getOtherAtomIndex(e.index))}getReferenceAtomIndex(){const e=this._ap1,t=this._ap2;if(e.index=this.atomIndex1,t.index=this.atomIndex2,e.residueIndex!==t.residueIndex)return;const i=e.index-e.residueAtomOffset,r=t.index-t.residueAtomOffset,s=e.residueType.getBondReferenceAtomIndex(i,r);if(void 0!==s)return s+e.residueAtomOffset;console.warn("No reference atom found",e.index,t.index)}calculateShiftDir(e=new t.Vector3){const i=this._ap1,r=this._ap2,s=this._ap3,n=this._v12,o=this._v13;i.index=this.atomIndex1,r.index=this.atomIndex2;const a=this.getReferenceAtomIndex();n.subVectors(i,r).normalize(),void 0!==a?(s.index=a,o.subVectors(i,s)):o.copy(i),o.normalize();let c=n.dot(o);return 1-Math.abs(c)<1e-5&&(o.set(1,0,0),c=n.dot(o),1-Math.abs(c)<1e-5&&(o.set(0,1,0),c=n.dot(o))),e.copy(o.sub(n.multiplyScalar(c))).normalize()}qualifiedName(){return this.atomIndex1+"="+this.atomIndex2}clone(){return new la(this.structure,this.index)}toObject(){return{atomIndex1:this.atomIndex1,atomIndex2:this.atomIndex2,bondOrder:this.bondOrder}}}class ha{constructor(e,t=0){this.structure=e,this.index=t,this.chainStore=e.chainStore,this.residueStore=e.residueStore,this.atomStore=e.atomStore,this.residueMap=e.residueMap,this.atomMap=e.atomMap}get entity(){return this.structure.entityList[this.entityIndex]}get entityIndex(){return this.chainStore.entityIndex[this.chainIndex]}get chain(){return this.structure.getChainProxy(this.chainIndex)}get chainIndex(){return this.residueStore.chainIndex[this.index]}set chainIndex(e){this.residueStore.chainIndex[this.index]=e}get atomOffset(){return this.residueStore.atomOffset[this.index]}set atomOffset(e){this.residueStore.atomOffset[this.index]=e}get atomCount(){return this.residueStore.atomCount[this.index]}set atomCount(e){this.residueStore.atomCount[this.index]=e}get atomEnd(){return this.atomOffset+this.atomCount-1}get modelIndex(){return this.chainStore.modelIndex[this.chainIndex]}get chainname(){return this.chainStore.getChainname(this.chainIndex)}get chainid(){return this.chainStore.getChainid(this.chainIndex)}get resno(){return this.residueStore.resno[this.index]}set resno(e){this.residueStore.resno[this.index]=e}get sstruc(){return this.residueStore.getSstruc(this.index)}set sstruc(e){this.residueStore.setSstruc(this.index,e)}get inscode(){return this.residueStore.getInscode(this.index)}set inscode(e){this.residueStore.setInscode(this.index,e)}get residueType(){return this.residueMap.get(this.residueStore.residueTypeId[this.index])}get resname(){return this.residueType.resname}get hetero(){return this.residueType.hetero}get moleculeType(){return this.residueType.moleculeType}get backboneType(){return this.residueType.backboneType}get backboneStartType(){return this.residueType.backboneStartType}get backboneEndType(){return this.residueType.backboneEndType}get traceAtomIndex(){return this.residueType.traceAtomIndex+this.atomOffset}get direction1AtomIndex(){return this.residueType.direction1AtomIndex+this.atomOffset}get direction2AtomIndex(){return this.residueType.direction2AtomIndex+this.atomOffset}get backboneStartAtomIndex(){return this.residueType.backboneStartAtomIndex+this.atomOffset}get backboneEndAtomIndex(){return this.residueType.backboneEndAtomIndex+this.atomOffset}get rungEndAtomIndex(){return this.residueType.rungEndAtomIndex+this.atomOffset}get x(){let e=0;for(let t=this.atomOffset;t<=this.atomEnd;++t)e+=this.atomStore.x[t];return e/this.atomCount}get y(){let e=0;for(let t=this.atomOffset;t<=this.atomEnd;++t)e+=this.atomStore.y[t];return e/this.atomCount}get z(){let e=0;for(let t=this.atomOffset;t<=this.atomEnd;++t)e+=this.atomStore.z[t];return e/this.atomCount}eachAtom(e,t){const i=this.atomCount,r=this.atomOffset,s=this.structure._ap,n=r+i;if(t&&t.atomOnlyTest){const i=t.atomOnlyTest;for(let t=r;t0)return this.entity.isPolymer();{const e=this.residueType.moleculeType;return 3===e||4===e||5===e}}isHetero(){return 1===this.residueType.hetero}isWater(){return 1===this.residueType.moleculeType}isIon(){return 2===this.residueType.moleculeType}isSaccharide(){return 6===this.residueType.moleculeType}isStandardAminoacid(){return this.residueType.isStandardAminoacid()}isStandardBase(){return this.residueType.isStandardBase()}isHelix(){return $r.includes(this.sstruc)}isSheet(){return Fr.includes(this.sstruc)}isTurn(){return Er.includes(this.sstruc)&&this.isProtein()}getAtomType(e){return this.atomMap.get(this.atomStore.atomTypeId[e])}getResname1(){return Hr[this.resname.toUpperCase()]||"X"}getBackboneType(e){switch(e){case-1:return this.residueType.backboneStartType;case 1:return this.residueType.backboneEndType;default:return this.residueType.backboneType}}getAtomIndexByName(e){let t=this.residueType.getAtomIndexByName(e);return void 0!==t&&(t+=this.atomOffset),t}hasAtomWithName(e){return this.residueType.hasAtomWithName(e)}getAtomnameList(){console.warn("getAtomnameList - might be expensive");const e=this.atomCount,t=this.atomOffset,i=new Array(e);for(let r=0;r=t){const t=l(e,this.structure.getResidueProxy());if(t.index=i,t.connectedTo(this))return t}else if(i===t-1){const i=this.chainStore.residueCount[this.chainIndex],r=l(e,this.structure.getResidueProxy());if(r.index=t+i-1,r.connectedTo(this))return r}}getBonds(){return this.residueType.getBonds(this)}getRings(){return this.residueType.getRings()}getAromaticRings(){return this.residueType.getAromaticRings(this)}qualifiedName(e=!1){let t="";return this.resname&&!e&&(t+="["+this.resname+"]"),void 0!==this.resno&&(t+=this.resno),this.inscode&&(t+="^"+this.inscode),this.chain&&(t+=":"+this.chainname),t+="/"+this.modelIndex,t}clone(){return new ha(this.structure,this.index)}toObject(){return{index:this.index,chainIndex:this.chainIndex,atomOffset:this.atomOffset,atomCount:this.atomCount,resno:this.resno,resname:this.resname,sstruc:this.sstruc}}}class ua{constructor(e,t,i){this.structure=e,this.residueIndexStart=t,this.residueIndexEnd=i,this.chainStore=e.chainStore,this.residueStore=e.residueStore,this.atomStore=e.atomStore,this.residueCount=i-t+1;const r=this.structure.getResidueProxy(this.residueIndexStart),s=this.structure.getResidueProxy(this.residueIndexEnd);this.isPrevConnected=void 0!==r.getPreviousConnectedResidue();const n=s.getNextConnectedResidue();this.isNextConnected=void 0!==n,this.isNextNextConnected=void 0!==n&&void 0!==n.getNextConnectedResidue(),this.isCyclic=s.connectedTo(r),this.__residueProxy=this.structure.getResidueProxy()}get chainIndex(){return this.residueStore.chainIndex[this.residueIndexStart]}get modelIndex(){return this.chainStore.modelIndex[this.chainIndex]}get chainname(){return this.chainStore.getChainname(this.chainIndex)}isProtein(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isProtein()}isCg(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isCg()}isNucleic(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isNucleic()}getMoleculeType(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.moleculeType}getBackboneType(e){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.getBackboneType(e)}getAtomIndexByType(e,t){this.isCyclic?-1===e?e=this.residueCount-1:e===this.residueCount&&(e=0):(-1!==e||this.isPrevConnected||(e+=1),e!==this.residueCount||this.isNextNextConnected||(e-=1));const i=this.__residueProxy;let r;switch(i.index=this.residueIndexStart+e,t){case"trace":r=i.traceAtomIndex;break;case"direction1":r=i.direction1AtomIndex;break;case"direction2":r=i.direction2AtomIndex;break;default:r=i.getAtomIndexByName(t)}return r}eachAtom(e,t){this.eachResidue((function(i){i.eachAtom(e,t)}))}eachAtomN(e,t,i){const r=this.residueCount,s=new Array(e);for(let t=0;t1&&e(new ua(n,i,l.index)),i=r)):(o!==Mr&&l.index-i>1&&e(new ua(n,i,l.index)),i=r)}r-i>1&&this.structure.getResidueProxy(i).backboneEndType&&e(new ua(n,i,r))}qualifiedName(){return":"+this.chainname+"/"+this.modelIndex}clone(){return new da(this.structure,this.index)}toObject(){return{index:this.index,residueOffset:this.residueOffset,residueCount:this.residueCount,chainname:this.chainname}}}class ma{constructor(e,t=0){this.structure=e,this.index=t,this.modelStore=e.modelStore,this.chainStore=e.chainStore,this.residueStore=e.residueStore}get chainOffset(){return this.modelStore.chainOffset[this.index]}set chainOffset(e){this.modelStore.chainOffset[this.index]=e}get chainCount(){return this.modelStore.chainCount[this.index]}set chainCount(e){this.modelStore.chainCount[this.index]=e}get residueOffset(){return this.chainStore.residueOffset[this.chainOffset]}get atomOffset(){return this.residueStore.atomOffset[this.residueOffset]}get chainEnd(){return this.chainOffset+this.chainCount-1}get residueEnd(){return this.chainStore.residueOffset[this.chainEnd]+this.chainStore.residueCount[this.chainEnd]-1}get atomEnd(){return this.residueStore.atomOffset[this.residueEnd]+this.residueStore.atomCount[this.residueEnd]-1}get residueCount(){return 0===this.chainCount?0:this.residueEnd-this.residueOffset+1}get atomCount(){return 0===this.residueCount?0:this.atomEnd-this.atomOffset+1}eachAtom(e,t){this.eachChain((function(i){i.eachAtom(e,t)}),t)}eachResidue(e,t){this.eachChain((function(i){i.eachResidue(e,t)}),t)}eachPolymer(e,t){if(t&&t.chainOnlyTest){const i=t.chainOnlyTest;this.eachChain((function(r){i(r)&&r.eachPolymer(e,t)}))}else this.eachChain((function(i){i.eachPolymer(e,t)}))}eachChain(e,t){const i=this.chainCount,r=this.chainOffset,s=this.structure._cp,n=r+i;if(t&&t.test){const i=t.chainOnlyTest;if(i)for(let t=r;t{const i=3*t;a.index=e,h&&a.positionToArray(h,i),u&&n.atomColorToArray(a,u,i),d&&(d.array[t]=e),m&&(m[t]=s.atomRadius(a)),p&&(p[t]=e)})),o}getBondData(e){const i=Object.assign({},e);i.colorParams&&(i.colorParams.structure=this.getStructure());const r=i.what,s=l(i.bondSet,this.bondSet),n=l(i.multipleBond,"off"),o="off"!==n,a="offset"===n,c=l(i.bondScale,.4),h=l(i.bondSpacing,1);let u,d;const m={},p=this.getBondProxy();i.bondStore&&(p.bondStore=i.bondStore);const f=this.getAtomProxy(),g=this.getAtomProxy();let y;if(o){const e=p.bondStore.bondOrder;y=0,s.forEach((function(t){y+=e[t]}))}else y=s.getSize();r&&!r.position||(m.position1=new Float32Array(3*y),m.position2=new Float32Array(3*y)),r&&!r.color||!i.colorParams||(m.color=new Float32Array(3*y),m.color2=new Float32Array(3*y),d=Ee.getScheme(i.colorParams)),r&&!r.picking||(m.picking=new zs(new Float32Array(y),this.getStructure(),i.bondStore)),(!r||r.radius||o&&r.position)&&(u=new ro(i.radiusParams)),r&&!r.radius||(m.radius=new Float32Array(y),i.radius2&&(m.radius2=new Float32Array(y)));const{position1:b,position2:x,color:v,color2:w,picking:A,radius:_,radius2:S}=m;let C,P,I,k,M,D,T=0;const B=new t.Vector3,R=new t.Vector3,O=new t.Vector3;return s.forEach((e=>{if(P=3*T,p.index=e,f.index=p.atomIndex1,g.index=p.atomIndex2,k=p.bondOrder,b)if(o&&k>1){const e=u.atomRadius(f);D=e*c/(.5*k),p.calculateShiftDir(O),a?(M=2*h*e,O.multiplyScalar(M),O.negate(),R.subVectors(g,f).multiplyScalar(Math.max(.1,M/1.88)),f.positionToArray(b,P),g.positionToArray(x,P),k>=2&&(B.addVectors(f,O).add(R).toArray(b,P+3),B.addVectors(g,O).sub(R).toArray(x,P+3),k>=3&&(B.subVectors(f,O).add(R).toArray(b,P+6),B.subVectors(g,O).sub(R).toArray(x,P+6)))):(M=(h-c)*e,O.multiplyScalar(M),2===k?(B.addVectors(f,O).toArray(b,P),B.subVectors(f,O).toArray(b,P+3),B.addVectors(g,O).toArray(x,P),B.subVectors(g,O).toArray(x,P+3)):3===k?(f.positionToArray(b,P),B.addVectors(f,O).toArray(b,P+3),B.subVectors(f,O).toArray(b,P+6),g.positionToArray(x,P),B.addVectors(g,O).toArray(x,P+3),B.subVectors(g,O).toArray(x,P+6)):(f.positionToArray(b,P),g.positionToArray(x,P)))}else f.positionToArray(b,P),g.positionToArray(x,P);if(v&&w&&(d.bondColorToArray(p,1,v,P),d.bondColorToArray(p,0,w,P),o&&k>1))for(C=1;C1))for(C=1;C1))for(D=_[T]*c/(a?1:.5*k),C=a?1:0;C1))for(D=S[T]*c/(a?1:.5*k),C=a?1:0;C{const t=e.x,i=e.y,r=e.z;ta&&(a=t),i>c&&(c=i),r>l&&(l=r)}),i),r.min.set(s,n,o),r.max.set(a,c,l),e.Debug&&Be.timeEnd("getBoundingBox"),r}getPrincipalAxes(t){e.Debug&&Be.time("getPrincipalAxes");let i=0;const r=new Js(3,this.atomCount),s=r.data;return this.eachAtom((e=>{s[i+0]=e.x,s[i+1]=e.y,s[i+2]=e.z,i+=3}),t),e.Debug&&Be.timeEnd("getPrincipalAxes"),new oo(r)}atomCenter(e){return e?this.getBoundingBox(e).getCenter(new t.Vector3):this.center.clone()}hasCoords(){if(void 0===this._hasCoords){const e=this.atomStore;this._hasCoords=0!==Ct(e.x)||0!==St(e.x)||0!==Ct(e.y)||0!==St(e.y)||0!==Ct(e.z)||0!==St(e.z)||e.count/this.modelStore.count==1}return this._hasCoords}getSequence(e){const t=[],i=this.getResidueProxy();return this.eachAtom((function(e){i.index=e.residueIndex,e.index===i.traceAtomIndex&&t.push(i.getResname1())}),e),t}getAtomIndices(e){if(e&&e.string){const t=[];return this.eachAtom((function(e){t.push(e.index)}),e),new Uint32Array(t)}{const e={what:{index:!0}};return this.getAtomData(e).index}}getChainnameCount(e){const t=new Set;return this.eachChain((function(e){e.residueCount&&t.add(e.chainname)}),e),t.size}updatePosition(e,t=!0){let i=0;this.eachAtom((function(t){t.positionFromArray(e,i),i+=3}),void 0),this._hasCoords=void 0,t&&this.refreshPosition()}refreshPosition(){this.getBoundingBox(void 0,this.boundingBox),this.boundingBox.getCenter(this.center),this.spatialHash=new vr(this.atomStore,this.boundingBox),this.signals.refreshed.dispatch(this)}dispose(){this.frames&&(this.frames.length=0),this.boxes&&(this.boxes.length=0),this.bondStore.dispose(),this.backboneBondStore.dispose(),this.rungBondStore.dispose(),this.atomStore.dispose(),this.residueStore.dispose(),this.chainStore.dispose(),this.modelStore.dispose(),delete this.bondSet,delete this.atomSet}}const fa=new t.Box3,ga=[mr,lr,pr,dr,fr,hr,cr,ur,yr,gr,br,xr],ya={aspectRatio:1.5,sphereDetail:2,radialSegments:50,disableImpostor:!1,openEnded:!1,dashedCylinder:!1,labelParams:{},pointSize:2,sizeAttenuation:!1,useTexture:!0,linewidth:2};class ba{constructor(e="shape",i={}){this.boundingBox=new t.Box3,this.bufferList=[],this.meshCount=0,this._primitiveData={},this.name=e,this.parameters=h(i,ya),ga.forEach((e=>{Object.keys(e.fields).forEach((t=>{this._primitiveData[e.getShapeKey(t)]=[]})),this._primitiveData[e.getShapeKey("name")]=[]}))}addBuffer(e){this.bufferList.push(e);const t=e.geometry;return t.boundingBox||t.computeBoundingBox(),this.boundingBox.union(t.boundingBox),this}addMesh(e,t,i,r,s){let n;e=k(e),t=k(t),Array.isArray(i)&&(i=A(i,e.length)),r&&(r=k(r)),n=void 0===r||0==r.length?{position:e,color:t,index:i}:{position:e,color:t,index:i,normal:r};const o=new Hs(this,Object.assign({serial:this.meshCount,name:s},n)),a=new Bn(Object.assign({picking:o},n));return this.bufferList.push(a),fa.setFromArray(e),this.boundingBox.union(fa),this.meshCount+=1,this}addSphere(e,t,i,r){return cr.objectToShape(this,{position:e,color:t,radius:i,name:r}),this}addEllipsoid(e,t,i,r,s,n){return fr.objectToShape(this,{position:e,color:t,radius:i,majorAxis:r,minorAxis:s,name:n}),this}addTorus(e,t,i,r,s,n){return gr.objectToShape(this,{position:e,color:t,radius:i,majorAxis:r,minorAxis:s,name:n}),this}addCylinder(e,t,i,r,s){return dr.objectToShape(this,{position1:e,position2:t,color:i,radius:r,name:s}),this}addCone(e,t,i,r,s){return pr.objectToShape(this,{position1:e,position2:t,color:i,radius:r,name:s}),this}addArrow(e,t,i,r,s){return mr.objectToShape(this,{position1:e,position2:t,color:i,radius:r,name:s}),this}addBox(e,t,i,r,s,n){return lr.objectToShape(this,{position:e,color:t,size:i,heightAxis:r,depthAxis:s,name:n}),this}addOctahedron(e,t,i,r,s,n){return hr.objectToShape(this,{position:e,color:t,size:i,heightAxis:r,depthAxis:s,name:n}),this}addTetrahedron(e,t,i,r,s,n){return ur.objectToShape(this,{position:e,color:t,size:i,heightAxis:r,depthAxis:s,name:n}),this}addText(e,t,i,r){return yr.objectToShape(this,{position:e,color:t,size:i,text:r}),this}addPoint(e,t,i){return br.objectToShape(this,{position:e,color:t,name:i}),this}addWideline(e,t,i,r,s){return this.parameters.linewidth=r,xr.objectToShape(this,{position1:e,position2:t,color:i,name:s}),this}addLabel(e,t,i,r){return console.warn("Shape.addLabel is deprecated, use .addText instead"),this.addText(e,t,i,r)}getBufferList(){const e=[];return ga.forEach((t=>{this._primitiveData[t.getShapeKey("color")].length&&e.push(t.bufferFromShape(this,this.parameters))})),this.bufferList.concat(e)}dispose(){this.bufferList.forEach((function(e){e.dispose()})),this.bufferList.length=0,ga.forEach((e=>{Object.keys(e.fields).forEach((t=>{this._primitiveData[e.getShapeKey(t)].length=0})),this._primitiveData[e.getShapeKey("name")].length=0}))}get center(){return this._center||(this._center=this.boundingBox.getCenter(new t.Vector3)),this._center}get type(){return"Shape"}}class xa extends Di{constructor(e,t,i){Array.isArray(e)||(e=[e]),super(e,t,i),this.type="buffer",this.parameters=Object.assign({},this.parameters,{colorScheme:null,colorScale:null,colorValue:null,colorDomain:null,colorMode:null}),this.buffer=e,this.init(i)}init(e){super.init(e),this.build()}create(){this.bufferList.push.apply(this.bufferList,this.buffer)}attach(e){this.bufferList.forEach((e=>{this.viewer.add(e),e.setParameters(this.getBufferParams())})),this.setVisibility(this.visible),e()}}const va=new t.Matrix4,wa=new t.Matrix3;class Aa extends Bn{constructor(e,t={},i){super(function(e,t){const i=t.attributes.position.array,r=t.index?t.index.array:void 0,s=e.position.length/3,n=i.length/3,o=s*n,a=new Float32Array(3*o),c=new Float32Array(3*o),l=new Float32Array(3*o);let h;return r&&(h=A(s*r.length,o)),{position:a,color:l,index:h,normal:c,primitiveId:e.primitiveId||vt(s,n),picking:e.picking}}(e,i),t),this.updateNormals=!1;const r=i.attributes.position.array,s=i.attributes.normal.array,n=i.index?i.index.array:void 0;this.geoPosition=r,this.geoNormal=s,this.geoIndex=n,this.positionCount=e.position.length/3,this.geoPositionCount=r.length/3,this.transformedGeoPosition=new Float32Array(3*this.geoPositionCount),this.transformedGeoNormal=new Float32Array(3*this.geoPositionCount);const o=this.geometry.attributes;if(this.meshPosition=o.position.array,this.meshColor=o.color.array,this.meshNormal=o.normal.array,this.setAttributes(e),n){const e=this.geometry.getIndex();if(!e)return void Be.error("Index is null");this.meshIndex=e.array,this.makeIndex()}}setAttributes(e={},t=!1){const i=this.geometry.attributes;let r,s,n,o,a,c,l,h,u;const d=this.updateNormals;e.position&&(r=e.position,n=this.geoPosition,l=this.meshPosition,a=this.transformedGeoPosition,i.position.needsUpdate=!0,(d||t)&&(o=this.geoNormal,u=this.meshNormal,c=this.transformedGeoNormal,i.normal.needsUpdate=!0)),e.color&&(s=e.color,h=this.meshColor,i.color.needsUpdate=!0);const m=this.positionCount,p=this.geoPositionCount;for(let e=0;e 0.0 ){\ncameraPos = rayDirection * posT + rayOrigin;\ninterior = true;\nflag2 = true;\n}\n#else\nif( calcDepth( cameraPos ) <= 0.0 ){\ncameraPos = rayDirection * posT + rayOrigin;\ninterior = true;\n}\n#endif\ncameraNormal = normalize( cameraPos - cameraSpherePos );\ncameraNormal *= float(!interior) * 2.0 - 1.0;\nreturn !interior;\n}\nvoid main(void){\nbool flag = Impostor( cameraPos, cameraNormal );\n#ifdef NEAR_CLIP\nif( calcClip( cameraPos ) > 0.0 )\ndiscard;\n#endif\ngl_FragDepthEXT = calcDepth( cameraPos );\nif( !flag ){\n#ifdef NEAR_CLIP\nif( flag2 ){\ngl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( clipNear - 0.5 ) ) ) + ( 0.0000001 / vRadius ) );\n}else if( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n#else\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n#endif\n}\nif (gl_FragDepthEXT < 0.0)\ndiscard;\nif (gl_FragDepthEXT > 1.0)\ndiscard;\n#ifdef PICKING\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 vNormal = cameraNormal;\nvec3 vViewPosition = -cameraPos;\nvec4 diffuseColor = vec4( diffuse, opacity );\nReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\nvec3 totalEmissiveLight = emissive;\n#include color_fragment\n#include roughnessmap_fragment\n#include metalnessmap_fragment\n#include normal_fragment_begin\n#include lights_physical_fragment\n#include lights_fragment_begin\n#include lights_fragment_end\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\nif( interior ){\n#ifdef USE_INTERIOR_COLOR\noutgoingLight.xyz = interiorColor;\n#else\n#ifdef DIFFUSE_INTERIOR\noutgoingLight.xyz = vColor;\n#endif\n#endif\noutgoingLight.xyz *= 1.0 - interiorDarkening;\n}\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");class Pa extends Tn{constructor(e,t,i={}){super(t,i),this.index=A(this.indexSize,this.attributeSize),this.makeIndex(),this.initIndex(this.index),this.addAttributes({mapping:{type:e,value:null}}),this.setAttributes({primitiveId:xt(this.size)})}get attributeSize(){return this.size*this.mappingSize}get indexSize(){return this.size*this.mappingIndicesSize}addAttributes(e){const t={};for(const i in e){const r=e[i];t[i]={type:r.type,value:null}}super.addAttributes(t)}getAttributeIndex(e){return 3*e*this.mappingSize}setAttributes(e){e&&!e.position&&e.position1&&e.position2&&(e.position=ft(e.position1,e.position2));const t=this.size,i=this.mappingSize,r=this.geometry.attributes;let s,n,o,a,c,l,h;for(const u in e)if("index"!==u&&"picking"!==u){n=e[u],s=r[u],o=s.itemSize,a=s.array;for(let e=0;e0&&this.parameters.alphaTest<=1&&(t.ALPHATEST=this.parameters.alphaTest.toPrecision(2)),t}setUniforms(e){e&&void 0!==e.edgeBleach&&(this.makeTexture(),e.map=this.tex),super.setUniforms(e)}dispose(){super.dispose(),this.tex&&this.tex.dispose()}}je.add("point",$a);class Fa extends Di{constructor(e,t,i){super(e,t,i),this.type="dot",this.parameters=Object.assign({thresholdType:{type:"select",rebuild:!0,options:{value:"value",sigma:"sigma"}},thresholdMin:{type:"number",precision:3,max:1/0,min:-1/0,rebuild:!0},thresholdMax:{type:"number",precision:3,max:1/0,min:-1/0,rebuild:!0},thresholdOut:{type:"boolean",rebuild:!0},dotType:{type:"select",rebuild:!0,options:{"":"",sphere:"sphere",point:"point"}},radiusType:{type:"select",options:{"":"",value:"value","abs-value":"abs-value","value-min":"value-min",deviation:"deviation",size:"size"}},radius:{type:"number",precision:3,max:10,min:.001,property:"size"},scale:{type:"number",precision:3,max:10,min:.001},sphereDetail:!0,disableImpostor:!0,pointSize:{type:"number",precision:1,max:100,min:0,buffer:!0},sizeAttenuation:{type:"boolean",buffer:!0},sortParticles:{type:"boolean",rebuild:!0},useTexture:{type:"boolean",buffer:!0},alphaTest:{type:"range",step:.001,max:1,min:0,buffer:!0},forceTransparent:{type:"boolean",buffer:!0},edgeBleach:{type:"range",step:.001,max:1,min:0,buffer:!0}},this.parameters,{colorScheme:{type:"select",update:"color",options:{"":"",value:"value",uniform:"uniform",random:"random"}}}),e instanceof Cn?(this.surface=void 0,this.volume=new ao(e)):(this.surface=e,this.volume=void 0),this.init(i)}init(e){var t=e||{};t.colorScheme=l(t.colorScheme,"uniform"),t.colorValue=l(t.colorValue,14540253),this.thresholdType=l(t.thresholdType,"sigma"),this.thresholdMin=l(t.thresholdMin,2),this.thresholdMax=l(t.thresholdMax,1/0),this.thresholdOut=l(t.thresholdOut,!1),this.dotType=l(t.dotType,"point"),this.radius=l(t.radius,.1),this.scale=l(t.scale,1),this.pointSize=l(t.pointSize,1),this.sizeAttenuation=l(t.sizeAttenuation,!0),this.sortParticles=l(t.sortParticles,!1),this.useTexture=l(t.useTexture,!1),this.alphaTest=l(t.alphaTest,.5),this.forceTransparent=l(t.forceTransparent,!1),this.edgeBleach=l(t.edgeBleach,0),super.init(t),this.build()}attach(e){this.bufferList.forEach((e=>{this.viewer.add(e)})),this.setVisibility(this.visible),e()}create(){var e={};if(this.volume){var t,i,r=this.volume;"sigma"===this.thresholdType?(t=r.getValueForSigma(this.thresholdMin),i=r.getValueForSigma(this.thresholdMax)):(t=this.thresholdMin,i=this.thresholdMax),r.setFilter(t,i,this.thresholdOut),Object.assign(e,{position:r.getDataPosition(),color:r.getDataColor(this.getColorParams())}),"sphere"===this.dotType&&Object.assign(e,{radius:r.getDataSize(this.radius,this.scale),picking:r.getDataPicking()})}else{var s=this.surface;Object.assign(e,{position:s.getPosition(),color:s.getColor(this.getColorParams())}),"sphere"===this.dotType&&Object.assign(e,{radius:s.getSize(this.radius,this.scale),picking:s.getPicking()})}"sphere"===this.dotType?this.dotBuffer=new Ta(e,this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!1})):this.dotBuffer=new $a(e,this.getBufferParams({pointSize:this.pointSize,sizeAttenuation:this.sizeAttenuation,sortParticles:this.sortParticles,useTexture:this.useTexture,alphaTest:this.alphaTest,forceTransparent:this.forceTransparent,edgeBleach:this.edgeBleach})),this.bufferList.push(this.dotBuffer)}update(e={}){if(0===this.bufferList.length)return;const t={};e.color&&(this.volume?Object.assign(t,{color:this.volume.getDataColor(this.getColorParams())}):Object.assign(t,{color:this.surface.getColor(this.getColorParams())})),"sphere"===this.dotType&&(e.radius||e.scale)&&(this.volume?Object.assign(t,{radius:this.volume.getDataSize(this.radius,this.scale)}):Object.assign(t,{radius:this.surface.getSize(this.radius,this.scale)})),this.dotBuffer.setAttributes(t)}setParameters(e,t={},i){return e&&void 0!==e.thresholdType&&this.volume instanceof Cn&&("value"===this.thresholdType&&"sigma"===e.thresholdType?(this.thresholdMin=this.volume.getSigmaForValue(this.thresholdMin),this.thresholdMax=this.volume.getSigmaForValue(this.thresholdMax)):"sigma"===this.thresholdType&&"value"===e.thresholdType&&(this.thresholdMin=this.volume.getValueForSigma(this.thresholdMin),this.thresholdMax=this.volume.getValueForSigma(this.thresholdMax)),this.thresholdType=e.thresholdType),e&&void 0!==e.radiusType&&("radius"===e.radiusType?this.radius=.1:this.radius=parseFloat(e.radiusType),t.radius=!0,"sphere"!==this.dotType||De&&!this.disableImpostor||(i=!0)),e&&void 0!==e.radius&&(t.radius=!0,"sphere"!==this.dotType||De&&!this.disableImpostor||(i=!0)),e&&void 0!==e.scale&&(t.scale=!0,"sphere"!==this.dotType||De&&!this.disableImpostor||(i=!0)),super.setParameters(e,t,i),this}}Ve.add("shader/Image.vert","uniform float clipRadius;\nuniform vec3 clipCenter;\nvarying vec2 vUv;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvarying vec3 vViewPosition;\n#endif\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\nvoid main() {\n#include begin_vertex\n#include project_vertex\nvUv = uv;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvViewPosition = -mvPosition.xyz;\n#endif\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n}"),Ve.add("shader/Image.frag","uniform sampler2D map;\nuniform float opacity;\nuniform vec2 mapSize;\nuniform float clipNear;\nuniform float clipRadius;\nvarying vec2 vUv;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvarying vec3 vViewPosition;\n#endif\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#if defined( PICKING )\nuniform sampler2D pickingMap;\nuniform float objectId;\n#else\n#include fog_pars_fragment\n#endif\n#if defined( CUBIC_INTERPOLATION )\n#if defined( CATMULROM_FILTER ) || defined( MITCHELL_FILTER )\n#if defined( CATMULROM_FILTER )\nconst float B = 0.0;\nconst float C = 0.5;\n#elif defined( MITCHELL_FILTER )\nconst float B = 0.333;\nconst float C = 0.333;\n#endif\nfloat filter( float x ){\nfloat f = x;\nif( f < 0.0 ){\nf = -f;\n}\nif( f < 1.0 ){\nreturn ( ( 12.0 - 9.0 * B - 6.0 * C ) * ( f * f * f ) +\n( -18.0 + 12.0 * B + 6.0 *C ) * ( f * f ) +\n( 6.0 - 2.0 * B ) ) / 6.0;\n}else if( f >= 1.0 && f < 2.0 ){\nreturn ( ( -B - 6.0 * C ) * ( f * f * f )\n+ ( 6.0 * B + 30.0 * C ) * ( f *f ) +\n( - ( 12.0 * B ) - 48.0 * C ) * f +\n8.0 * B + 24.0 * C ) / 6.0;\n}else{\nreturn 0.0;\n}\n}\n#elif defined( BSPLINE_FILTER )\nfloat filter( float x ){\nfloat f = x;\nif( f < 0.0 ){\nf = -f;\n}\nif( f >= 0.0 && f <= 1.0 ){\nreturn ( 2.0 / 3.0 ) + ( 0.5 ) * ( f * f * f ) - ( f * f );\n}else if( f > 1.0 && f <= 2.0 ){\nreturn 1.0 / 6.0 * pow( ( 2.0 - f ), 3.0 );\n}\nreturn 1.0;\n}\n#else\nfloat filter( float x ){\nreturn 1.0;\n}\n#endif\nvec4 biCubic( sampler2D tex, vec2 texCoord ){\nvec2 texelSize = 1.0 / mapSize;\ntexCoord -= texelSize / 2.0;\nvec4 nSum = vec4( 0.0 );\nfloat nDenom = 0.0;\nvec2 cell = fract( texCoord * mapSize );\nfor( float m = -1.0; m <= 2.0; ++m ){\nfor( float n = -1.0; n <= 2.0; ++n ){\nvec4 vecData = texture2D(\ntex, texCoord + texelSize * vec2( m, n )\n);\nfloat c = filter( m - cell.x ) * filter( -n + cell.y );\nnSum += vecData * c;\nnDenom += c;\n}\n}\nreturn nSum / nDenom;\n}\n#endif\nvoid main(){\n#include nearclip_fragment\n#include radiusclip_fragment\n#if defined( CUBIC_INTERPOLATION )\ngl_FragColor = biCubic( map, vUv );\n#else\ngl_FragColor = texture2D( map, vUv );\n#endif\n#if defined( PICKING )\nif( gl_FragColor.a < 0.3 )\ndiscard;\ngl_FragColor = vec4( texture2D( pickingMap, vUv ).xyz, objectId );\n#else\nif( gl_FragColor.a < 0.01 )\ndiscard;\ngl_FragColor.a *= opacity;\n#include fog_fragment\n#endif\n}");const Ea=new Uint16Array([0,1,2,1,3,2]),La=new Float32Array([0,1,0,0,1,1,1,0]),Na=Object.assign({filter:"nearest",forceTransparent:!0},Mn),za=Object.assign({filter:{updateShader:!0,uniform:!0}},Dn);class Va extends Tn{constructor(e,i){super({position:e.position,index:Ea,picking:e.picking},i),this.parameterTypes=za,this.alwaysTransparent=!0,this.hasWireframe=!1,this.vertexShader="Image.vert",this.fragmentShader="Image.frag";const{imageData:r,width:s,height:n}=e,o=new t.DataTexture(r,s,n);o.flipY=!0,this.tex=o;const a=r.length,c=new Uint8Array(a);for(let e=0;e>16&255,c[e+1]=t>>8&255,c[e+2]=255&t}const l=new t.DataTexture(c,s,n);l.flipY=!0,l.minFilter=t.NearestFilter,l.magFilter=t.NearestFilter,this.pickingTex=l,this.addUniforms({map:{value:o},pickingMap:{value:l},mapSize:{value:new t.Vector2(s,n)}}),this.geometry.setAttribute("uv",new t.BufferAttribute(La,2))}get defaultParameters(){return Na}getDefines(e){const t=super.getDefines(e),i=this.parameters.filter;return i.startsWith("cubic")&&(t.CUBIC_INTERPOLATION=1,i.endsWith("bspline")?t.BSPLINE_FILTER=1:i.endsWith("catmulrom")?t.CATMULROM_FILTER=1:i.endsWith("mitchell")&&(t.MITCHELL_FILTER=1)),t}updateTexture(){const e=this.tex,i=this.parameters.filter;i.startsWith("cubic")?(e.minFilter=t.NearestFilter,e.magFilter=t.NearestFilter):"linear"===i?(e.minFilter=t.LinearFilter,e.magFilter=t.LinearFilter):(e.minFilter=t.NearestFilter,e.magFilter=t.NearestFilter),e.needsUpdate=!0,this.pickingTex.needsUpdate=!0}makeMaterial(){super.makeMaterial(),this.updateTexture();const e=this.material;e.uniforms.map.value=this.tex,e.blending=t.NormalBlending,e.needsUpdate=!0;const i=this.wireframeMaterial;i.uniforms.map.value=this.tex,i.blending=t.NormalBlending,i.needsUpdate=!0;const r=this.pickingMaterial;r.uniforms.map.value=this.tex,r.uniforms.pickingMap.value=this.pickingTex,r.blending=t.NormalBlending,r.needsUpdate=!0}setUniforms(e){e&&void 0!==e.filter&&(this.updateTexture(),e.map=this.tex),super.setUniforms(e)}}class Ga{constructor(e,t){const i=t||{};this.dimension=l(i.dimension,"x"),this.positionType=l(i.positionType,"percent"),this.position=l(i.position,30),this.thresholdType=l(i.thresholdType,"sigma"),this.thresholdMin=l(i.thresholdMin,-1/0),this.thresholdMax=l(i.thresholdMax,1/0),this.normalize=l(i.normalize,!1),this.volume=e}getPositionFromCoordinate(e){const i=this.dimension,r=this.volume,s=r.matrix,n=(new t.Vector3).setFromMatrixPosition(s)[i],o=(new t.Vector3).setFromMatrixScale(s)[i];let a;return a="x"===i?r.nx:"y"===i?r.ny:r.nz,Math.round(((e-n)/(a/100)+1)/o)}getData(e){e=e||{};const i=this.volume,r=i.data,s=i.matrix;let n;function o(e){return Math.round(e/100*(n-1))}function a(e,t,r,s){return 3*(r*i.ny*i.nx+t*i.nx+e)+s}n="coordinate"===this.positionType?this.getPositionFromCoordinate(this.position):this.position;const c=new Float32Array(12),l=new t.Vector3;let h,u,d,m,p,f=0,g=0,y=0,b=i.nx,x=i.ny,v=i.nz;function w(e,t,i,r){l.set(e,t,i).applyMatrix4(s).toArray(c,r)}"x"===this.dimension?(d=o(i.nx),m=i.ny-1,p=i.nz-1,h=i.nz,u=i.ny,f=d,b=f+1,w(d,0,0,0),w(d,m,0,3),w(d,0,p,6),w(d,m,p,9)):"y"===this.dimension?(d=i.nx-1,m=o(i.ny),p=i.nz-1,h=i.nz,u=i.nx,g=m,x=g+1,w(0,m,0,0),w(d,m,0,3),w(0,m,p,6),w(d,m,p,9)):"z"===this.dimension&&(d=i.nx-1,m=i.ny-1,p=o(i.nz),h=i.nx,u=i.ny,y=p,v=y+1,w(0,0,p,0),w(0,m,p,3),w(d,0,p,6),w(d,m,p,9));let A=0,_=0;const S=new Uint8Array(h*u*4),C=new Float32Array(h*u);let P,I;"sigma"===this.thresholdType?(P=i.getValueForSigma(this.thresholdMin),I=i.getValueForSigma(this.thresholdMax)):(P=this.thresholdMin,I=this.thresholdMax);const k=Object.assign({},e.colorParams,{volume:i});this.normalize&&(k.domain=[0,1]);const M=Ee.getScheme(k),D=new Float32Array(3),T=M.getScale();let B,R=0,O=0;if(this.normalize){R=1/0,B=-1/0;for(let e=g;eB&&(B=s)}O=B-R}for(let e=g;eP&&n{this.viewer.add(e)})),this.setVisibility(this.visible),e()}create(){const e=new Ga(this.volume,{positionType:this.positionType,position:this.position,dimension:this.dimension,thresholdType:this.thresholdType,thresholdMin:this.thresholdMin,thresholdMax:this.thresholdMax,normalize:this.normalize}),t=new Va(e.getData({colorParams:this.getColorParams()}),this.getBufferParams({filter:this.filter}));this.bufferList.push(t)}}function ja(e){Be.error(`makeRepresentation: representation type ${e} unknown`)}const Ha={name:"some element",status:""};class Wa{constructor(e,t={}){this.stage=e,this.signals={statusChanged:new r.Signal,nameChanged:new r.Signal,disposed:new r.Signal},this.parameters=h(t,this.defaultParameters),this.uuid=O()}get defaultParameters(){return Ha}get name(){return this.parameters.name}setStatus(e){return this.parameters.status=e,this.signals.statusChanged.dispatch(e),this}setName(e){return this.parameters.name=e,this.signals.nameChanged.dispatch(e),this}dispose(){this.signals.disposed.dispatch()}}const qa=Object.assign({visible:!0},Ha);class Xa extends Wa{constructor(e,t,i={},s){super(e,Object.assign({name:t.type},i)),this.parent=s,this.signals=Object.assign({visibilityChanged:new r.Signal,parametersChanged:new r.Signal},this.signals),this.setRepresentation(t)}get defaultParameters(){return qa}get visible(){return this.parameters.visible}get type(){return"representation"}getType(){return this.repr.type}setRepresentation(e){this._disposeRepresentation(),this.repr=e,this.stage.tasks.listen(this.repr.tasks),this.updateVisibility()}_disposeRepresentation(){this.repr&&(this.stage.tasks.unlisten(this.repr.tasks),this.repr.dispose())}dispose(){this.parent&&this.parent.hasRepresentation(this)?this.parent.removeRepresentation(this):(this._disposeRepresentation(),this.signals.disposed.dispatch())}setVisibility(e){return this.parameters.visible=e,this.updateVisibility(),this.signals.visibilityChanged.dispatch(this.parameters.visible),this}getVisibility(){return this.parent?this.parent.parameters.visible&&this.parameters.visible:this.parameters.visible}toggleVisibility(){return this.setVisibility(!this.parameters.visible)}updateVisibility(){this.repr.setVisibility(this.getVisibility())}update(e){return this.repr.update(e),this}build(e){return this.repr.build(e),this}setSelection(e){const t=this.repr;return t.setSelection&&t.setSelection(e),this}setParameters(e){return this.repr.setParameters(e),this.signals.parametersChanged.dispatch(this.repr.getParameters()),this}getParameters(){return this.repr.getParameters()}setColor(e){return this.repr.setColor(e),this}}const Ya=new t.Matrix4,Ka=new t.Vector3,Za={name:"",status:"",visible:!0};class Qa{constructor(e,i,s={}){this.stage=e,this.object=i,this.signals={representationAdded:new r.Signal,representationRemoved:new r.Signal,visibilityChanged:new r.Signal,matrixChanged:new r.Signal,statusChanged:new r.Signal,nameChanged:new r.Signal,disposed:new r.Signal},this.reprList=[],this.annotationList=[],this.matrix=new t.Matrix4,this.position=new t.Vector3,this.quaternion=new t.Quaternion,this.scale=new t.Vector3(1,1,1),this.transform=new t.Matrix4,this.parameters=h(s,this.defaultParameters),this.uuid=O(),this.viewer=e.viewer,this.controls=new to(this)}get defaultParameters(){return Za}get name(){return this.parameters.name}get status(){return this.parameters.status}get visible(){return this.parameters.visible}setPosition(e){return Array.isArray(e)?this.position.fromArray(e):this.position.copy(e),this.updateMatrix(),this}setRotation(e){if(Array.isArray(e))if(3===e.length){const i=(new t.Euler).fromArray(e);this.quaternion.setFromEuler(i)}else this.quaternion.fromArray(e);else e instanceof t.Euler?this.quaternion.setFromEuler(e):this.quaternion.copy(e);return this.updateMatrix(),this}setScale(e){return this.scale.set(e,e,e),this.updateMatrix(),this}setTransform(e){return this.transform.copy(e),this.updateMatrix(),this}updateMatrix(){const e=this.getCenterUntransformed(Ka);this.matrix.makeTranslation(-e.x,-e.y,-e.z),Ya.makeRotationFromQuaternion(this.quaternion),this.matrix.premultiply(Ya),Ya.makeScale(this.scale.x,this.scale.y,this.scale.z),this.matrix.premultiply(Ya);const t=this.position;Ya.makeTranslation(t.x+e.x,t.y+e.y,t.z+e.z),this.matrix.premultiply(Ya),this.matrix.premultiply(this.transform),this.updateRepresentationMatrices(),this.stage.viewer.updateBoundingBox(),this.signals.matrixChanged.dispatch(this.matrix)}updateRepresentationMatrices(){this.reprList.forEach((e=>{e.setParameters({matrix:this.matrix})}))}addAnnotation(e,t,i){const r=new Zn(this,e,t,i);return this.annotationList.push(r),r}eachAnnotation(e){this.annotationList.slice().forEach(e)}removeAnnotation(e){const t=this.annotationList.indexOf(e);-1!==t&&(this.annotationList.splice(t,1),e.dispose())}removeAllAnnotations(){this.eachAnnotation((e=>e.dispose())),this.annotationList.length=0}_addRepresentation(t,i,r,s=!1){const n=r||{},o=this.stage.getParameters();n.matrix=this.matrix.clone(),n.quality=n.quality||o.quality,n.disableImpostor=l(n.disableImpostor,!o.impostor),n.useWorker=l(n.useWorker,o.workerDefault),n.visible=l(n.visible,!0);const a=Object.assign({},n,{visible:this.parameters.visible&&n.visible}),c=function(t,i,r,s){var n;if(e.Debug&&Be.time("makeRepresentation "+t),i instanceof pa){if(!(n=Ne.get(t)))return void ja(t)}else if(i instanceof _n)if("surface"===t)n=Ln;else{if("dot"!==t)return void ja(t);n=Fa}else if(i instanceof Cn)if("surface"===t)n=Ln;else if("dot"===t)n=Fa;else{if("slice"!==t)return void ja(t);n=Ua}else if(i instanceof ba)n=xa,i=i.getBufferList();else{if("buffer"!==t)return void Be.error("makeRepresentation: object "+i+" unknown");n=xa}const o=new n(i,r,s);return e.Debug&&Be.timeEnd("makeRepresentation "+t),o}(t,i,this.viewer,a),h=new Xa(this.stage,c,n,this);return s||(this.reprList.push(h),this.signals.representationAdded.dispatch(h)),h}addBufferRepresentation(e,t){return this._addRepresentation.call(this,"buffer",e,t)}hasRepresentation(e){return-1!==this.reprList.indexOf(e)}eachRepresentation(e){this.reprList.slice().forEach(e)}removeRepresentation(e){const t=this.reprList.indexOf(e);-1!==t&&(this.reprList.splice(t,1),e.dispose(),this.signals.representationRemoved.dispatch(e))}updateRepresentations(e){this.reprList.forEach((t=>t.update(e))),this.stage.viewer.requestRender()}removeAllRepresentations(){this.eachRepresentation((e=>e.dispose()))}dispose(){this.removeAllAnnotations(),this.removeAllRepresentations(),this.reprList.length=0,this.signals.disposed.dispatch()}setVisibility(e){return this.parameters.visible=e,this.eachRepresentation((e=>e.updateVisibility())),this.eachAnnotation((e=>e.updateVisibility())),this.signals.visibilityChanged.dispatch(e),this}setStatus(e){return this.parameters.status=e,this.signals.statusChanged.dispatch(e),this}setName(e){return this.parameters.name=e,this.signals.nameChanged.dispatch(e),this}getBox(...e){return this.getBoxUntransformed(...e).clone().applyMatrix4(this.matrix)}getCenter(...e){return this.getCenterUntransformed(...e).clone().applyMatrix4(this.matrix)}getZoom(...e){return this.stage.getZoomForBox(this.getBox(...e))}getBoxUntransformed(...e){return new t.Box3}getCenterUntransformed(...e){return this.getBoxUntransformed().getCenter(new t.Vector3)}autoView(e){this.stage.animationControls.zoomMove(this.getCenter(),this.getZoom(),l(e,0))}}class Ja{constructor(e=[]){this.list=e;const t=e.length;for(let i=0;i0?this.list[0]:void 0}forEach(e){return this.list.forEach(e),this}dispose(){return this.forEach((e=>e.dispose()))}}class ec extends Ja{setParameters(e){return this.forEach((t=>t.setParameters(e)))}setVisibility(e){return this.forEach((t=>t.setVisibility(e)))}setSelection(e){return this.forEach((t=>t.setSelection(e)))}setColor(e){return this.forEach((t=>t.setColor(e)))}update(e){return this.forEach((t=>t.update(e)))}build(e){return this.forEach((t=>t.build(e)))}dispose(e){return this.forEach((e=>e.dispose()))}}const tc=Object.assign({defaultStep:1,defaultTimeout:50,defaultInterpolateType:"",defaultInterpolateStep:5,defaultMode:"loop",defaultDirection:"forward",initialFrame:0},Ha);class ic extends Wa{constructor(e,t,i={}){super(e,Object.assign({name:t.name},i)),this.trajectory=t,this.signals=Object.assign(this.signals,{frameChanged:new r.Signal,playerChanged:new r.Signal,countChanged:new r.Signal,parametersChanged:new r.Signal}),t.signals.frameChanged.add((e=>{this.signals.frameChanged.dispatch(e)})),t.signals.playerChanged.add((e=>{this.signals.playerChanged.dispatch(e)})),t.signals.countChanged.add((e=>{this.signals.countChanged.dispatch(e)})),void 0!==i.initialFrame&&this.setFrame(i.initialFrame)}get defaultParameters(){return tc}get type(){return"trajectory"}setFrame(e){this.trajectory.setFrame(e)}setParameters(e={}){this.trajectory.setParameters(e),this.signals.parametersChanged.dispatch(e)}dispose(){this.trajectory.dispose(),super.dispose()}}class rc{constructor(e,t){this.name=e,this.path=t,this.coordinates=[],this.boxes=[],this.times=[],this.timeOffset=0,this.deltaTime=1}get type(){return"Frames"}}class sc{constructor(e,i){let r,s;if(this.A=new Js(3,3),this.W=new Js(1,3),this.U=new Js(3,3),this.V=new Js(3,3),this.VH=new Js(3,3),this.R=new Js(3,3),this.tmp=new Js(3,3),this.c=new Js(3,3),e instanceof pa)r=e.atomCount;else{if(!(e instanceof Float32Array))return;r=e.length/3}if(i instanceof pa)s=i.atomCount;else{if(!(i instanceof Float32Array))return;s=i.length/3}const n=Math.min(r,s),o=new Js(3,n),a=new Js(3,n);this.coords1t=new Js(n,3),this.coords2t=new Js(n,3),this.transformationMatrix=new t.Matrix4,this.c.data.set([1,0,0,0,1,0,0,0,-1]),this.prepCoords(e,o,n,!1),this.prepCoords(i,a,n,!1),this._superpose(o,a)}_superpose(t,i){this.mean1=sn(t),this.mean2=sn(i),nn(t,this.mean1),nn(i,this.mean2),en(this.coords1t,t),en(this.coords2t,i),tn(this.A,this.coords2t,this.coords1t),hn(this.A,this.W,this.U,this.V),function(e,t){const i=e.data,r=t.data,s=i[4],n=i[8],o=i[5],a=i[7],c=i[0],l=c*s,h=c*o,u=i[3],d=i[1],m=u*d,p=i[2],f=u*p,g=i[6],y=g*d,b=g*p,x=1/(l*n-h*a-m*n+f*a+y*o-b*s);r[0]=(s*n-o*a)*x,r[1]=-(d*n-p*a)*x,r[2]=-(-d*o+p*s)*x,r[3]=-(u*n-o*g)*x,r[4]=(c*n-b)*x,r[5]=-(h-f)*x,r[6]=-(-u*a+s*g)*x,r[7]=-(c*a-y)*x,r[8]=(l-m)*x}(this.V,this.VH),rn(this.R,this.U,this.VH),function(e){const t=e.data;return t[0]*t[4]*t[8]-t[0]*t[5]*t[7]-t[3]*t[1]*t[8]+t[3]*t[2]*t[7]+t[6]*t[1]*t[5]-t[6]*t[2]*t[4]}(this.R)<0&&(e.Debug&&Be.log("R not a right handed system"),rn(this.tmp,this.c,this.VH),rn(this.R,this.U,this.tmp));const r=new Js(4,4),s=new Js(4,4),n=new Js(4,4),o=new Js(4,4),a=new Js(4,4),c=new Js(4,4),l=this.R.data,h=this.mean1,u=this.mean2;o.data.set([1,0,0,-h[0],0,1,0,-h[1],0,0,1,-h[2],0,0,0,1]),a.data.set([l[0],l[1],l[2],0,l[3],l[4],l[5],0,l[6],l[7],l[8],0,0,0,0,1]),c.data.set([1,0,0,u[0],0,1,0,u[1],0,0,1,u[2],0,0,0,1]),en(s,o),tn(r,a,s),en(n,r),tn(s,c,n),en(r,s),this.transformationMatrix.elements=r.data}prepCoords(e,t,i,r){let s=0;const n=t.data;let o=3,a=3*i;if(r&&(a=4*i,o=4),e instanceof pa)e.eachAtom((function(e){s{e!==this&&this.pause()}),this);const i=l(e.frameCount,1);this.traj=e,this.parameters=h(t,nc),this.parameters.end=Math.min(l(t.end,i-1),i-1),this.parameters.step=l(t.step,Math.ceil((i+1)/100)),this._currentFrame=this.parameters.start,this._direction="bounce"===this.parameters.direction?"forward":this.parameters.direction,e.signals.countChanged.add((e=>{this.parameters.end=Math.min(l(this.parameters.end,e-1),e-1)}),this),this._animate=this._animate.bind(this)}get isRunning(){return this._run}setParameters(e={}){u(this.parameters,e),void 0!==e.direction&&"bounce"!==this.parameters.direction&&(this._direction=this.parameters.direction)}_animate(){if(!this._run)return;this._currentTime=window.performance.now();const e=this._currentTime-this._previousTime,t=this.parameters.interpolateType?this.parameters.interpolateStep:1,i=this.parameters.timeout/t,r=this.traj;if(r&&r.frameCount&&!r.inProgress&&e>=i)if(this.parameters.interpolateType)if(this._currentStep>this.parameters.interpolateStep&&(this._currentStep=1),1===this._currentStep&&(this._currentFrame=this._nextInterpolated()),r.hasFrame(this._currentFrame)){this._currentStep+=1;const e=this._currentStep/(this.parameters.interpolateStep+1),[t,i,s,n]=this._currentFrame;r.setFrameInterpolated(t,i,s,n,e,this.parameters.interpolateType),this._previousTime=this._currentTime}else r.loadFrame(this._currentFrame);else{const e=this._next();r.hasFrame(e)?(r.setFrame(e),this._previousTime=this._currentTime):r.loadFrame(e)}window.requestAnimationFrame(this._animate)}_next(){const e=this.parameters;let t;return t="forward"===this._direction?this.traj.currentFrame+e.step:this.traj.currentFrame-e.step,(t>e.end||t=e.end?i=e.start:"backward"===e.direction&&t<=e.start&&(i=e.end),this.traj.setFrame(i),this._run=!0,this._animate(),this.signals.startedRunning.dispatch()}}pause(){this._run=!1,this.signals.haltedRunning.dispatch()}stop(){this.pause(),this.traj.setFrame(this.parameters.start)}}class ac{constructor(e,t,i={}){this.signals={countChanged:new r.Signal,frameChanged:new r.Signal,playerChanged:new r.Signal},this.frameCache={},this.loadQueue={},this.boxCache={},this.pathCache={},this.frameCacheSize=0,this._frameCount=0,this._currentFrame=-1,this._disposed=!1,this.deltaTime=l(i.deltaTime,0),this.timeOffset=l(i.timeOffset,0),this.centerPbc=l(i.centerPbc,!1),this.removePbc=l(i.removePbc,!1),this.removePeriodicity=l(i.removePeriodicity,!1),this.superpose=l(i.superpose,!1),this.name=e.replace(/^.*[\\/]/,""),this.trajPath=e,this.selection=new ye(l(i.sele,"backbone and not hydrogen")),this.selection.signals.stringChanged.add((()=>{this.selectionIndices=this.structure.getAtomIndices(this.selection),this._resetCache(),this._saveInitialCoords(),this.setFrame(this._currentFrame)}))}get frameCount(){return this._frameCount}get currentFrame(){return this._currentFrame}_init(e){this.setStructure(e),this._loadFrameCount(),this.setPlayer(new oc(this))}_loadFrameCount(){}setStructure(e){this.structure=e,this.atomCount=e.atomCount,this.backboneIndices=this._getIndices(new ye("backbone and not hydrogen")),this._makeAtomIndices(),this._saveStructureCoords(),this.selectionIndices=this._getIndices(this.selection),this._resetCache(),this._saveInitialCoords(),this.setFrame(this._currentFrame)}_saveInitialCoords(){this.structure.hasCoords()?(this.initialCoords=new Float32Array(this.structureCoords),this._makeSuperposeCoords()):this.frameCache[0]?(this.initialCoords=new Float32Array(this.frameCache[0]),this._makeSuperposeCoords()):this.loadFrame(0,(()=>this._saveInitialCoords()))}_saveStructureCoords(){this.structureCoords=this.structure.getAtomData({what:{position:!0}}).position}setSelection(e){return this.selection.setString(e),this}_getIndices(e){let t=0;const i=e.test,r=[];return i&&this.structure.eachAtom((e=>{i(e)&&r.push(t),t+=1})),r}_makeSuperposeCoords(){const e=3*this.selectionIndices.length;this.coords1=new Float32Array(e),this.coords2=new Float32Array(e);const t=this.initialCoords,i=this.coords2;for(let r=0;r!!this.frameCache[e])):!!this.frameCache[e]}setFrame(e,t){return void 0===e||(this.inProgress=!0,-1===e||this.frameCache[e]?(this._updateStructure(e),t&&t()):this.loadFrame(e,(()=>{this._updateStructure(e),t&&t()}))),this}_interpolate(e,t,i,r,s,n){const o=this.frameCache;let a;a="spline"===n?function(e,t,i,r,s){const n=e.length,o=new Float32Array(n);for(let a=0;a{this._interpolate(e,t,i,r,s,n),o&&o()})):(this._interpolate(e,t,i,r,s,n),o&&o()),this}loadFrame(e,t){Array.isArray(e)?e.forEach((e=>{this.loadQueue[e]||this.frameCache[e]||(this.loadQueue[e]=!0,this._loadFrame(e,(()=>{delete this.loadQueue[e]})))})):this.loadQueue[e]||this.frameCache[e]||(this.loadQueue[e]=!0,this._loadFrame(e,(()=>{delete this.loadQueue[e],t&&t()})))}_loadFrame(e,t){Be.error("Trajectory._loadFrame not implemented",e,t)}_updateStructure(e){this._disposed?console.error("updateStructure: traj disposed"):(-1===e?this.structureCoords&&this.structure.updatePosition(this.structureCoords):this.structure.updatePosition(this.frameCache[e]),this.structure.trajectory={name:this.trajPath,frame:e},this._currentFrame=e,this.inProgress=!1,this.signals.frameChanged.dispatch(e))}_doSuperpose(e){const t=3*this.selectionIndices.length,i=this.coords1,r=this.coords2;for(let r=0;r0&&this.centerPbc){const e=[t[0],t[4],t[8]],r=function(e,t,i){return[pt(t,i[0],3,0,e),pt(t,i[1],3,1,e),pt(t,i[2],3,2,e)]}(this.backboneIndices,i,e);!function(e,t,i){if(0===i[0]||0===i[8]||0===i[4])return;const r=e.length,s=i[0],n=i[1],o=i[2],a=-t[0]+s+s/2,c=-t[1]+n+n/2,l=-t[2]+o+o/2;for(let t=0;t.5&&(e[s+r]-=t[3*r+r]*Math.round(n))}}(i,t,e)}this.removePbc&&function(e,t){if(0===t[0]||0===t[8]||0===t[4])return;const i=e.length;for(let r=3;r.9*t[3*i+i])if(s>0)for(let s=0;s<3;++s)e[r+s]-=t[3*i+s];else for(let s=0;s<3;++s)e[r+s]+=t[3*i+s]}}(i,t)}this.selectionIndices.length>0&&this.coords1&&this.superpose&&this._doSuperpose(i),this.frameCache[e]=i,this.boxCache[e]=t,this.frameCacheSize+=1}_setFrameCount(e){e!==this._frameCount&&(this._frameCount=e,this.signals.countChanged.dispatch(e))}dispose(){this._resetCache(),this._disposed=!0,this.player&&this.player.stop()}setPlayer(e){this.player=e,this.signals.playerChanged.dispatch(e)}getFrameTime(e){return this.timeOffset+e*this.deltaTime}}class cc extends ac{constructor(e,t,i){const r=i||{};r.timeOffset=l(r.timeOffset,e.timeOffset),r.deltaTime=l(r.deltaTime,e.deltaTime),super("",t,r),this.name=e.name,this.path=e.path,this.frames=e.coordinates,this.boxes=e.boxes,this._init(t)}get type(){return"frames"}_makeAtomIndices(){"StructureView"===this.structure.type?this.atomIndices=this.structure.getAtomIndices():this.atomIndices=void 0}_loadFrame(e,t){let i;const r=this.frames[e];if(this.atomIndices){const e=this.atomIndices,t=e.length;i=new Float32Array(3*t);for(let s=0;s{const e=r.response;if(!e)return void Be.error(`empty arrayBuffer for '${s}'`);const n=new Int32Array(e,0,1)[0],o=new Float32Array(e,8,9),a=new Float32Array(e,44);this._process(t,o,a,n),"function"==typeof i&&i()}),!1),r.send(n)}_loadFrameCount(){const t=new XMLHttpRequest,i=e.TrajectoryDatasource.getCountUrl(this.trajPath);t.open("GET",i,!0),t.addEventListener("load",(()=>{this._setFrameCount(parseInt(t.response))}),!1),t.send()}}class uc extends ac{constructor(e,t,i){super("",t,i),this.requestCallback=e,this._init(t)}get type(){return"callback"}_makeAtomIndices(){const e=[];if("StructureView"===this.structure.type){const t=this.structure.getAtomIndices(),i=t.length;let r=t[0],s=t[0];for(let n=1;n{this._process(e,i,r,s),"function"==typeof t&&t()}),e,this.atomIndices)}_loadFrameCount(){this.requestCallback((e=>this._setFrameCount(e)))}}pa.prototype.getView=function(e){return new dc(this,e)};class dc extends pa{constructor(e,i){super(),this.structure=e,this.selection=i,this.center=new t.Vector3,this.boundingBox=new t.Box3,this._bp=this.getBondProxy(),this._ap=this.getAtomProxy(),this._rp=this.getResidueProxy(),this._cp=this.getChainProxy(),this.selection&&this.selection.signals.stringChanged.add(this.refresh,this),this.structure.signals.refreshed.add(this.refresh,this),this.refresh()}init(){}get type(){return"StructureView"}get name(){return this.structure.name}get path(){return this.structure.path}get title(){return this.structure.title}get id(){return this.structure.id}get data(){return this.structure.data}get atomSetDict(){return this.structure.atomSetDict}get biomolDict(){return this.structure.biomolDict}get entityList(){return this.structure.entityList}get unitcell(){return this.structure.unitcell}get frames(){return this.structure.frames}get boxes(){return this.structure.boxes}get validation(){return this.structure.validation}get bondStore(){return this.structure.bondStore}get backboneBondStore(){return this.structure.backboneBondStore}get rungBondStore(){return this.structure.rungBondStore}get atomStore(){return this.structure.atomStore}get residueStore(){return this.structure.residueStore}get chainStore(){return this.structure.chainStore}get modelStore(){return this.structure.modelStore}get atomMap(){return this.structure.atomMap}get residueMap(){return this.structure.residueMap}get bondHash(){return this.structure.bondHash}get spatialHash(){return this.structure.spatialHash}get _hasCoords(){return this.structure._hasCoords}set _hasCoords(e){this.structure._hasCoords=e}refresh(){e.Debug&&Be.time("StructureView.refresh"),this.atomSetCache={};const i=this.structure;if(this.selection.isAllSelection()&&i!==this&&i.atomSet&&i.bondSet){this.atomSet=i.atomSet.clone(),this.bondSet=i.bondSet.clone();for(let e in this.atomSetDict){const t=this.atomSetDict[e];this.atomSetCache["__"+e]=t.clone()}this.atomCount=i.atomCount,this.bondCount=i.bondCount,this.boundingBox.copy(i.boundingBox),this.center.copy(i.center)}else if(this.selection.isNoneSelection()&&i!==this&&i.atomSet&&i.bondSet){this.atomSet=new Sr(i.atomCount),this.bondSet=new Sr(i.bondCount);for(let e in this.atomSetDict)this.atomSetCache["__"+e]=new Sr(i.atomCount);this.atomCount=0,this.bondCount=0,this.boundingBox.makeEmpty(),this.center.set(0,0,0)}else{this.atomSet=this.getAtomSet(this.selection,!0),i.atomSet&&(this.atomSet=this.atomSet.intersection(i.atomSet)),this.bondSet=this.getBondSet();for(let e in this.atomSetDict){const t=this.atomSetDict[e];this.atomSetCache["__"+e]=t.makeIntersection(this.atomSet)}this.atomCount=this.atomSet.getSize(),this.bondCount=this.bondSet.getSize(),this.boundingBox=this.getBoundingBox(),this.center=this.boundingBox.getCenter(new t.Vector3)}e.Debug&&Be.timeEnd("StructureView.refresh"),this.signals.refreshed.dispatch()}setSelection(e){this.selection=e,this.refresh()}getSelection(e){const t=[];e&&e.string&&t.push(e.string);const i=this.structure.getSelection();i&&i.string&&t.push(i.string),this.selection&&this.selection.string&&t.push(this.selection.string);let r="";return t.length>0&&(r=`( ${t.join(" ) AND ( ")} )`),new ye(r)}getStructure(){return this.structure.getStructure()}eachBond(e,t){this.structure.eachBond(e,this.getSelection(t))}eachAtom(e,t){const i=this.getAtomProxy(),r=this.getAtomSet(t),s=this.atomStore.count;if(r.getSize()=this.V[r][s]?(i="S",this.score=this.S[r][s]):this.V[r][s]>=this.H[r][s]?(i="V",this.score=this.V[r][s]):(i="H",this.score=this.H[r][s]),e.Debug&&Be.log("Alignment: SCORE",this.score),e.Debug&&Be.log("Alignment: S, V, H",this.S[r][s],this.V[r][s],this.H[r][s]);r>0&&s>0;)"S"===i?this.S[r][s]===this.S[r-1][s-1]+t(r-1,s-1)?(this.ali1=this.seq1[r-1]+this.ali1,this.ali2=this.seq2[s-1]+this.ali2,--r,--s,i="S"):this.S[r][s]===this.V[r][s]?i="V":this.S[r][s]===this.H[r][s]?i="H":(--r,--s):"V"===i?this.V[r][s]===this.V[r-1][s]+this.gapExtensionPenalty?(this.ali1=this.seq1[r-1]+this.ali1,this.ali2="-"+this.ali2,--r,i="V"):this.V[r][s]===this.S[r-1][s]+this.gap(0)?(this.ali1=this.seq1[r-1]+this.ali1,this.ali2="-"+this.ali2,--r,i="S"):--r:"H"===i?this.H[r][s]===this.H[r][s-1]+this.gapExtensionPenalty?(this.ali1="-"+this.ali1,this.ali2=this.seq2[s-1]+this.ali2,--s,i="H"):this.H[r][s]===this.S[r][s-1]+this.gap(0)?(this.ali1="-"+this.ali1,this.ali2=this.seq2[s-1]+this.ali2,--s,i="S"):--s:Be.error("Alignment: no matrix");for(;r>0;)this.ali1=this.seq1[r-1]+this.ali1,this.ali2="-"+this.ali2,--r;for(;s>0;)this.ali1="-"+this.ali1,this.ali2=this.seq2[s-1]+this.ali2,--s;e.Debug&&Be.timeEnd("Alignment.trace"),e.Debug&&Be.log([this.ali1,this.ali2])}}function yc(e,t,i=!1,r="",s=""){let n,o,a,c,l;if(i){let i=e,h=t;r&&s&&(i=e.getView(new ye(r)),h=t.getView(new ye(s)));const u=i.getSequence(),d=h.getSequence(),m=new gc(u.join(""),d.join(""));let p,f;m.calc(),m.trace(),n=0,o=0,a=m.ali1.length;const g=[],y=[];for(let e=0;ee[t]))}}}(),this.spacefillRepresentation=this.addRepresentation("spacefill",{sele:"none",opacity:Re.opacity,color:Re.color,disablePicking:!0,radiusType:"data"},!0),this.distanceRepresentation=this.addRepresentation("distance",Re,!0),this.angleRepresentation=this.addRepresentation("angle",Re,!0),this.dihedralRepresentation=this.addRepresentation("dihedral",Re,!0),this.measureRepresentations=new ec([this.spacefillRepresentation,this.distanceRepresentation,this.angleRepresentation,this.dihedralRepresentation]),this.setDefaultAssembly(this.parameters.defaultAssembly),this.structure.signals.refreshed.add((()=>{this.updateRepresentations({position:!0})}))}get defaultParameters(){return bc}get type(){return"structure"}initSelection(e){this.selection=new ye(e),this.structureView=new dc(this.structure,this.selection),this.selection.signals.stringChanged.add((()=>{this.structureView.setSelection(this.selection),this.rebuildRepresentations(),this.rebuildTrajectories()}))}setSelection(e){return this.parameters.sele=e,this.selection.setString(e),this}setDefaultAssembly(e){if(void 0===this.structure.biomolDict[e]&&(e=""),this.parameters.defaultAssembly!==e){const t={defaultAssembly:e};this.reprList.forEach((e=>e.setParameters(t))),this.measureRepresentations.setParameters(t),this.parameters.defaultAssembly=e,this.signals.defaultAssemblyChanged.dispatch(e)}return this}rebuildRepresentations(){this.reprList.forEach((e=>{e.build()})),this.measureRepresentations.build()}rebuildTrajectories(){this.trajList.forEach((e=>{e.trajectory.setStructure(this.structureView)}))}updateRepresentations(e){super.updateRepresentations(e),this.measureRepresentations.update(e)}updateRepresentationMatrices(){super.updateRepresentationMatrices(),this.measureRepresentations.setParameters({matrix:this.matrix})}addRepresentation(e,t={},i=!1){t.defaultAssembly=this.parameters.defaultAssembly;const r=this._addRepresentation(e,this.structureView,t,i);return i||r.signals.parametersChanged.add((()=>this.measureUpdate())),r}addTrajectory(e="",t={}){const i=function(e,t,i){let r;return r=e&&e instanceof rc?new cc(e,t,i):!e&&t.frames?new lc(e,t,i):e&&"function"==typeof e?new uc(e,t,i):new hc(e,t,i),r}(e,this.structureView,t),r=new ic(this.stage,i,t);return this.trajList.push(r),this.signals.trajectoryAdded.dispatch(r),r}removeTrajectory(e){const t=this.trajList.indexOf(e);-1!==t&&this.trajList.splice(t,1),e.dispose(),this.signals.trajectoryRemoved.dispatch(e)}dispose(){this.trajList.slice().forEach((e=>e.dispose())),this.trajList.length=0,this.structure.dispose(),this.measureRepresentations.dispose(),super.dispose()}autoView(e,t){"number"==typeof e&&(t=e,e=""),this.stage.animationControls.zoomMove(this.getCenter(e),this.getZoom(e),l(t,0))}getBoxUntransformed(e){let t;return t=e?this.structureView.getBoundingBox(new ye(e)):this.structureView.boundingBox,t}getCenterUntransformed(e){return e&&"string"==typeof e?this.structure.atomCenter(new ye(e)):this.structure.center}superpose(e,t,i,r){return yc(this.structureView,e.structureView,t,i,r),this.updateRepresentations({position:!0}),this}getMaxRepresentationRadius(e){let t=0;const i=this.structure.getAtomProxy(e);return this.eachRepresentation((e=>{if(e.getVisibility()){const r=e.repr;t=Math.max(r.getAtomRadius(i),t)}})),t}measurePick(e){const t=this.pickBuffer.count;if(this.lastPick===e.index&&t>=1){if(t>1){const e=this.pickBuffer.data,i=this.pickBuffer.data.sort();this.pickDict.has(i)?this.pickDict.del(i):this.pickDict.add(i,e),2===t?this.distanceRepresentation.setParameters({atomPair:this.pickDict.values.filter((e=>2===e.length))}):3===t?this.angleRepresentation.setParameters({atomTriple:this.pickDict.values.filter((e=>3===e.length))}):4===t&&this.dihedralRepresentation.setParameters({atomQuad:this.pickDict.values.filter((e=>4===e.length))})}this.pickBuffer.clear(),this.lastPick=void 0}else this.pickBuffer.has(e.index)||this.pickBuffer.push(e.index),this.lastPick=e.index;this.measureUpdate()}measureClear(){this.pickBuffer.clear(),this.lastPick=void 0,this.spacefillRepresentation.setSelection("none")}measureBuild(){const e=this.measureData();this.distanceRepresentation.setParameters({atomPair:e.distance}),this.angleRepresentation.setParameters({atomTriple:e.angle}),this.dihedralRepresentation.setParameters({atomQuad:e.dihedral})}measureUpdate(){const e=this.pickBuffer.data,t={};e.forEach((e=>{const i=Math.max(.1,this.getMaxRepresentationRadius(e));t[e]=i*(2.3-L(.1,2,i))})),this.spacefillRepresentation.setSelection(e.length?"@"+e.join(","):"none"),e.length&&this.spacefillRepresentation.setParameters({radiusData:t})}measureData(){const e=this.pickDict.values;return{distance:e.filter((e=>2===e.length)),angle:e.filter((e=>3===e.length)),dihedral:e.filter((e=>4===e.length))}}removeAllMeasurements(e){const t=this.pickDict,i=t.values,r=function(e){i.filter((t=>t.length===e)).forEach((e=>t.del(e.slice().sort())))};(!e||1&e)&&r(2),(!e||2&e)&&r(3),(!e||4&e)&&r(4),this.measureBuild()}removeMeasurement(e){this.pickDict.del(e.slice().sort()),this.measureBuild()}addMeasurement(e){if(e.length<2||e.length>4)return;const t=e.slice().sort();this.pickDict.has(t)||this.pickDict.add(t,e),this.measureBuild()}}Ue.add("structure",xc),Ue.add("structureview",xc);class vc extends Qa{constructor(e,t,i={}){super(e,t,Object.assign({name:t.name},i)),this.surface=t}get type(){return"surface"}addRepresentation(e,t={}){return this._addRepresentation(e,this.surface,t)}getBoxUntransformed(){return this.surface.boundingBox}getCenterUntransformed(){return this.surface.center}dispose(){this.surface.dispose(),super.dispose()}}Ue.add("surface",vc);class wc extends Qa{constructor(e,t,i={}){super(e,t,Object.assign({name:t.name},i)),this.volume=t}get type(){return"volume"}addRepresentation(e,t={}){return this._addRepresentation(e,this.volume,t)}getBoxUntransformed(){return this.volume.boundingBox}getCenterUntransformed(){return this.volume.center}dispose(){this.volume.dispose(),super.dispose()}}Ue.add("volume",wc);class Ac extends Ja{addRepresentation(e,t){return this.forEach((i=>i.addRepresentation(e,t)))}autoView(e){return this.forEach((t=>t.autoView(e)))}}function _c(e,t){return e instanceof RegExp?null!==t.name.match(e):t.name===e}const Sc=new t.Vector3,Cc={impostor:!0,quality:"medium",workerDefault:!0,sampleLevel:0,backgroundColor:"black",rotateSpeed:2,zoomSpeed:1.2,panSpeed:1,clipNear:0,clipFar:100,clipDist:10,clipMode:"scene",clipScale:"relative",fogNear:50,fogFar:100,cameraFov:40,cameraEyeSep:.3,cameraType:"perspective",lightColor:14540253,lightIntensity:1,ambientColor:14540253,ambientIntensity:.2,hoverTimeout:0,tooltip:!0,mousePreset:"default"};class Pc extends Qa{constructor(e,t,i={}){super(e,t,Object.assign({name:t.name},i)),this.shape=t}get type(){return"shape"}addRepresentation(e,t={}){return this._addRepresentation(e,this.shape,t)}getBoxUntransformed(){return this.shape.boundingBox}getCenterUntransformed(){return this.shape.center}dispose(){this.shape.dispose(),super.dispose()}}function Ic(e,t,i,r){var s,n=arguments.length,o=n<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,r);else for(var a=e.length-1;a>=0;a--)(s=e[a])&&(o=(n<3?s(o):n>3?s(t,i,o):s(t,i))||o);return n>3&&o&&Object.defineProperty(t,i,o),o}Ue.add("shape",Pc);class kc extends U{constructor(e){super(e),e.scale||(this.parameters.scale="rainbow",this.parameters.reverse=l(e.reverse,!0)),this.scalePerModel={},e.structure.eachModel((e=>{this.parameters.domain=[e.atomOffset,e.atomEnd],this.scalePerModel[e.index]=this.getScale()}))}atomColor(e){return this.scalePerModel[e.modelIndex](e.index)}}Ic([G],kc.prototype,"atomColor",null),Ee.add("atomindex",kc);class Mc extends U{constructor(e){if(super(e),e.scale||(this.parameters.scale="OrRd"),!e.domain){let t,i=1/0,r=-1/0;e.sele&&(t=new ye(e.sele)),e.structure.eachAtom((function(e){const t=e.bfactor;i=Math.min(i,t),r=Math.max(r,t)}),t),this.parameters.domain=[i,r]}this.bfactorScale=this.getScale()}atomColor(e){return this.bfactorScale(e.bfactor)}}Ic([G],Mc.prototype,"atomColor",null),Ee.add("bfactor",Mc);class Dc extends U{constructor(e){super(e),this.chainidDictPerModel={},this.scalePerModel={},e.scale||(this.parameters.scale="Spectral"),e.structure.eachModel((e=>{let t=0;const i={};e.eachChain((function(e){void 0===i[e.chainid]&&(i[e.chainid]=t,t+=1)})),this.parameters.domain=[0,t-1],this.chainidDictPerModel[e.index]=i,this.scalePerModel[e.index]=this.getScale()}))}atomColor(e){const t=this.chainidDictPerModel[e.modelIndex];return this.scalePerModel[e.modelIndex](t[e.chainid])}}Ic([G],Dc.prototype,"atomColor",null),Ee.add("chainid",Dc);class Tc extends U{constructor(e){super(e),this.scalePerModel={},e.scale||(this.parameters.scale="Spectral"),e.structure.eachModel((e=>{this.parameters.domain=[e.chainOffset,e.chainEnd],this.scalePerModel[e.index]=this.getScale()}))}atomColor(e){return this.scalePerModel[e.modelIndex](e.chainIndex)}}Ic([G],Tc.prototype,"atomColor",null),Ee.add("chainindex",Tc);class Bc extends U{constructor(e){super(e),this.chainnameDictPerModel={},this.scalePerModel={},e.scale||(this.parameters.scale="Spectral"),e.structure.eachModel((e=>{let t=0;const i={};e.eachChain((function(e){void 0===i[e.chainname]&&(i[e.chainname]=t,t+=1)})),this.parameters.domain=[0,t-1],this.chainnameDictPerModel[e.index]=i,this.scalePerModel[e.index]=this.getScale()}))}atomColor(e){const t=this.chainnameDictPerModel[e.modelIndex];return this.scalePerModel[e.modelIndex](t[e.chainname])}}Ic([G],Bc.prototype,"atomColor",null),Ee.add("chainname",Bc);class Rc extends U{constructor(e){super(e),this.rsrzDict={},this.rsccDict={},e.scale||(this.parameters.scale="RdYlBu"),this.rsrzScale=this.getScale({domain:[2,0]}),this.rsccScale=this.getScale({domain:[.678,1]});const t=e.structure.validation;t&&(this.rsrzDict=t.rsrzDict,this.rsccDict=t.rsccDict)}atomColor(e){let t=e.resno+"";e.inscode&&(t+="^"+e.inscode),e.chainname&&(t+=":"+e.chainname),t+="/"+e.modelIndex;const i=this.rsrzDict[t];if(void 0!==i)return this.rsrzScale(i);const r=this.rsccDict[t];return void 0!==r?this.rsccScale(r):9474192}}Ic([G],Rc.prototype,"atomColor",null),Ee.add("densityfit",Rc);const Oc={ARG:{CD:.1,CZ:.5,NE:-.1},ASN:{CG:.55,OD1:-.55},ASP:{CB:-.16,CG:.36,OD1:-.6,OD2:-.6},CYS:{CB:.19,SG:-.19},GLN:{CD:.55,OE1:-.55},GLU:{CD:.36,CG:-.16,OE1:-.6,OE2:-.6},HIS:{CB:.1,CD2:.2,CE1:.45,CG:.15,ND1:.05,NE2:.05},LYS:{CE:.25,NZ:.75},MET:{CE:.06,CG:.06,SD:-.12},PTR:{C:.55,CA:.1,CZ:.25,N:-.35,O:-.55,O1P:-.85,O2P:-.85,O3P:-.85,OG1:-1.1,P:1.4},SEP:{C:.55,CA:.1,CB:.25,N:-.35,O:-.55,O1P:-.85,O2P:-.85,O3P:-.85,OG1:-1.1,P:1.4},SER:{CB:.25,OG:-.25},THR:{CB:.25,OG1:-.25},TPO:{C:.55,CA:.1,CB:.25,N:-.35,O:-.55,OG1:-1.1,O1P:-.85,O2P:-.85,O3P:-.85,P:1.4},TRP:{CD1:.06,CD2:.1,CE2:-.04,CE3:-.03,CG:-.03,NE1:-.06},TYR:{CZ:.25,OH:-.25},backbone:{C:.55,O:-.55,N:-.35,CA:.1}};class $c extends U{constructor(e){super(e),this.delta=new t.Vector3,this.hCharges=[],e.scale||(this.parameters.scale="rwb"),e.domain||(this.parameters.domain=[-50,50]),this.scale=this.getScale(),this.charges=new Float32Array(e.structure.atomCount);const i=[];e.structure.eachAtom((e=>{var r;if(this.charges[e.index]=(null!==(r=e).partialCharge?r.partialCharge:r.isProtein()&&(Oc[r.resname]&&Oc[r.resname][r.atomname]||Oc.backbone[r.atomname])||0)*e.occupancy,"N"===e.atomname){if(e.bondCount>=3)return;if(e.bondToElementCount(1))return;const r=function(e,i=new t.Vector3){let r=!1,s=!1,n=!1;return i.set(2*e.x,2*e.y,2*e.z),e.eachBondedAtom((function(e){if(!r)return"H"===e.atomname?(i.set(e.x,e.y,e.z),void(r=!0)):void(s||"CA"!==e.atomname?n||"C"!==e.atomname||(n=!0,i.sub(e)):(i.sub(e),s=!0))})),r?i:s&&n?(i.normalize(),i.multiplyScalar(1.04),i.add(e),i):void 0}(e);void 0!==r&&(i.push(r),this.hCharges.push(.25*e.occupancy))}}));const r=e.structure.getBoundingBox();r.expandByScalar(1.04),this.hStore=function(e){const t=e.length,i=new Float32Array(t),r=new Float32Array(t),s=new Float32Array(t);for(let t=0;t{const s=t[e];0!==s&&(r+=s/i)})),this.hHash.eachWithin(e.x,e.y,e.z,12,((e,t)=>{const s=i[e];0!==s&&(r+=s/t)})),this.scale(332*r)}}Ic([G],$c.prototype,"positionColor",null),Ee.add("electrostatic",$c);const Fc={H:16777215,HE:14286847,LI:13402367,BE:12779264,B:16758197,C:9474192,N:3166456,O:16715021,F:9494608,NE:11789301,NA:11230450,MG:9109248,AL:12560038,SI:1578e4,P:16744448,S:16777008,CL:2093087,AR:8442339,K:9388244,CA:4062976,SC:15132390,TI:12567239,V:10921643,CR:9083335,MN:10255047,FE:14706227,CO:15765664,NI:5296208,CU:13140019,ZN:8224944,GA:12750735,GE:6721423,AS:12419299,SE:16752896,BR:10889513,KR:6076625,RB:7351984,SR:65280,Y:9764863,ZR:9756896,NB:7586505,MO:5551541,TC:3907230,RU:2396047,RH:687500,PD:27013,AG:12632256,CD:16767375,IN:10909043,SN:6717568,SB:10380213,TE:13924864,I:9699476,XE:9699476,CS:5707663,BA:51456,LA:7394559,CE:16777159,PR:14286791,ND:13107143,PM:10747847,SM:9437127,EU:6422471,GD:4587463,TB:3211207,DY:2097095,HO:65436,ER:58997,TM:54354,YB:48952,LU:43812,HF:5096191,TA:5089023,W:2200790,RE:2522539,OS:2516630,IR:1528967,PT:13684960,AU:16765219,HG:12105936,TL:10900557,PB:5724513,BI:10375093,PO:11230208,AT:7688005,RN:4358806,FR:4325478,RA:32e3,AC:7384058,TH:47871,PA:41471,U:36863,NP:33023,PU:27647,AM:5528818,CM:7888099,BK:9064419,CF:10565332,ES:11739092,FM:11739066,MD:11734438,NO:12389767,LR:13041766,RF:13369433,DB:13697103,SG:14221381,BH:14680120,HS:15073326,MT:15400998,DS:16777215,RG:16777215,CN:16777215,UUT:16777215,FL:16777215,UUP:16777215,LV:16777215,UUH:16777215,D:16777152,T:16777120};class Ec extends U{constructor(e){e.value=l(e.value,Fc.C),super(e)}atomColor(e){const t=e.element;return"C"===t?this.parameters.value:Fc[t]||16777215}}Ic([G],Ec.prototype,"atomColor",null),Ee.add("element",Ec);class Lc extends U{constructor(e){super(e),e.scale||(this.parameters.scale="Spectral"),e.domain||(this.parameters.domain=[0,e.structure.entityList.length-1]),this.entityindexScale=this.getScale()}atomColor(e){return this.entityindexScale(e.entityIndex)}}Ic([G],Lc.prototype,"atomColor",null),Ee.add("entityindex",Lc);class Nc extends U{atomColor(e){const t=e.entity;switch(t?t.entityType:void 0){case 1:return 8374655;case 2:return 16629894;case 3:return 12496596;case 4:return 3697840;default:return 16777113}}}Ic([G],Nc.prototype,"atomColor",null),Ee.add("entitytype",Nc);class zc extends U{constructor(e){super(e),this.geoAtomDict={},this.geoDict={};const t=e.structure.validation;t&&(this.geoAtomDict=t.geoAtomDict,this.geoDict=t.geoDict)}atomColor(e){let t,i=e.resno+"";e.inscode&&(i+="^"+e.inscode),e.chainname&&(i+=":"+e.chainname),i+="/"+e.modelIndex;const r=this.geoAtomDict[i];if(void 0!==r){const i=r[e.atomname]||0;s=i,t=16843009*((s=(858993459&(s-=s>>1&1431655765))+(s>>2&858993459))+(s>>4)&252645135)>>24}else t=this.geoDict[i]||0;var s;return 0===t?2188972:1===t?16703627:2===t?16018755:t>=3?10813478:9474192}}Ic([G],zc.prototype,"atomColor",null),Ee.add("geoquality",zc);class Vc extends U{constructor(e){super(e),this.resHF={},e.scale||(this.parameters.scale="RdYlGn");for(const e in Ur)this.resHF[e]=Ur[e][0];if(this.defaultResidueHydrophobicity=jr[0],!e.domain){let e=1/0,t=-1/0;for(const i in this.resHF){const r=this.resHF[i];e=Math.min(e,r),t=Math.max(t,r)}this.parameters.domain=[e,0,t]}this.hfScale=this.getScale()}atomColor(e){return this.hfScale(this.resHF[e.resname]||this.defaultResidueHydrophobicity)}}Ic([G],Vc.prototype,"atomColor",null),Ee.add("hydrophobicity",Vc);class Gc extends U{constructor(e){super(e),e.scale||(this.parameters.scale="rainbow"),e.domain||(this.parameters.domain=[0,e.structure.modelStore.count]),this.modelindexScale=this.getScale()}atomColor(e){return this.modelindexScale(e.modelIndex)}}Ic([G],Gc.prototype,"atomColor",null),Ee.add("modelindex",Gc);class Uc extends U{atomColor(e){switch(e.residueType.moleculeType){case 1:return 3697840;case 2:return 15729279;case 3:return 12496596;case 4:return 16629894;case 5:return 12540695;case 6:return 8374655;default:return 16777113}}}Ic([G],Uc.prototype,"atomColor",null),Ee.add("moleculetype",Uc);class jc extends U{constructor(e){super(e),e.scale||(this.parameters.scale="PuBu"),e.domain||(this.parameters.domain=[0,1]),this.occupancyScale=this.getScale()}atomColor(e){return this.occupancyScale(e.occupancy)}}Ic([G],jc.prototype,"atomColor",null),Ee.add("occupancy",jc);class Hc extends U{constructor(e){super(e),e.scale||(this.parameters.scale="rwb"),e.domain||(this.parameters.domain=[-1,1]),this.partialchargeScale=this.getScale()}atomColor(e){return this.partialchargeScale(e.partialCharge||0)}}function Wc(){return 16777215*Math.random()}Ic([G],Hc.prototype,"atomColor",null),Ee.add("partialcharge",Hc);class qc extends U{atomColor(){return Wc()}volumeColor(){return Wc()}positionColor(){return Wc()}}Ic([G],qc.prototype,"atomColor",null),Ic([G],qc.prototype,"volumeColor",null),Ic([G],qc.prototype,"positionColor",null),Ee.add("random",qc);class Xc extends U{constructor(e){super(e),this.rciDict={},e.scale||(this.parameters.scale="RdYlBu"),this.rciScale=this.getScale({domain:[.6,0]});const t=e.structure.validation;t&&(this.rciDict=t.rciDict)}atomColor(e){let t=`[${e.resname}]${e.resno}`;e.chainname&&(t+=":"+e.chainname);const i=this.rciDict[t];return void 0!==i?this.rciScale(i):9474192}}Ic([G],Xc.prototype,"atomColor",null),Ee.add("randomcoilindex",Xc);class Yc extends U{constructor(e){super(e),this.scalePerChain={},e.scale||(this.parameters.scale="rainbow",this.parameters.reverse=l(e.reverse,!0)),e.structure.eachChain((e=>{this.parameters.domain=[e.residueOffset,e.residueEnd],this.scalePerChain[e.index]=this.getScale()}))}atomColor(e){return this.scalePerChain[e.chainIndex](e.residueIndex)}}Ic([G],Yc.prototype,"atomColor",null),Ee.add("residueindex",Yc);const Kc={ALA:9240460,ARG:124,ASN:16743536,ASP:10485826,CYS:16777072,GLN:16731212,GLU:6684672,GLY:16777215,HIS:7368959,ILE:19456,LEU:4546117,LYS:4671416,MET:12099650,PHE:5459026,PRO:5395026,SER:16740418,THR:12078080,TRP:5195264,TYR:9203788,VAL:16747775,ASX:16711935,GLX:16711935,ASH:16711935,GLH:16711935,A:14423100,G:3329330,I:10145074,X:8190976,C:16766720,T:4286945,U:4251856,D:35723,DA:14423100,DG:3329330,DI:10145074,DX:8190976,DC:16766720,DT:4286945,DU:4251856,DD:35723};class Zc extends U{atomColor(e){return Kc[e.resname]||16711935}}Ic([G],Zc.prototype,"atomColor",null),Ee.add("resname",Zc);const Qc=16711808,Jc=10485888,el=6291584,tl=16762880,il=6324479,rl=16777215,sl=11403518,nl=16580962,ol=10921722;class al extends U{constructor(e){super(e),this.residueProxy=e.structure.getResidueProxy()}atomColor(e){const t=e.sstruc,i=this.residueProxy;return"h"===t?Qc:"g"===t?Jc:"i"===t?el:"e"===t||"b"===t?tl:"t"===t?il:(i.index=e.residueIndex,i.isDna()?sl:i.isRna()?nl:i.isSaccharide()?ol:i.isProtein()||"s"===t||"l"===t?rl:8421504)}}Ic([G],al.prototype,"atomColor",null),Ee.add("sstruc",al);class cl extends U{constructor(e){var t,i;super(e),e.scale||(this.parameters.scale="rwb"),this.atomData=null===(t=this.parameters.data)||void 0===t?void 0:t.atomData,this.bondData=null===(i=this.parameters.data)||void 0===i?void 0:i.bondData,this.scale=this.getScale(this.parameters)}atomColor(e){var t;const i=null===(t=this.atomData)||void 0===t?void 0:t[e.index];return void 0!==i?this.scale(i):this.parameters.value}bondColor(e,t){var i;const r=null===(i=this.bondData)||void 0===i?void 0:i[e.index];return void 0!==r?this.scale(r):this.atomProxy?(this.atomProxy.index=t?e.atomIndex1:e.atomIndex2,this.atomColor(this.atomProxy)):this.parameters.value}}Ic([G],cl.prototype,"atomColor",null),Ic([G],cl.prototype,"bondColor",null),Ee.add("structuredata",cl);class ll extends U{atomColor(){return this.parameters.value}bondColor(){return this.parameters.value}valueColor(){return this.parameters.value}volumeColor(){return this.parameters.value}}Ic([G],ll.prototype,"atomColor",null),Ic([G],ll.prototype,"bondColor",null),Ic([G],ll.prototype,"valueColor",null),Ic([G],ll.prototype,"volumeColor",null),Ee.add("uniform",ll);class hl extends U{constructor(e){super(e),this.valueScale=this.getScale()}volumeColor(e){return this.valueScale(this.parameters.volume.data[e])}}Ic([G],hl.prototype,"volumeColor",null),Ee.add("value",hl);class ul extends U{constructor(e){super(e),this.vec=new t.Vector3,this.valueScale=this.getScale()}positionColor(e){const t=this.parameters.volume;if(!t||!t.inverseMatrix)return this.parameters.value;const i=this.vec,r=t.data,s=t.nx,n=t.ny,o=s*n;i.copy(e),i.applyMatrix4(t.inverseMatrix);const a=Math.floor(i.x),c=Math.floor(i.y),l=Math.floor(i.z),h=(l*n+c)*s+a,u=h+1,d=h+s,m=h+o,p=d+1,f=m+1,g=d+o,y=g+1,b=r[h],x=r[u],v=r[d],w=r[m],A=r[p],_=r[f],S=r[g],C=r[y],P=i.x-a,I=i.y-c,k=i.z-l,M=F(b,x,P),D=F(w,_,P),T=F(v,A,P),B=F(S,C,P),R=F(M,T,I),O=F(D,B,I),$=F(R,O,k);return this.valueScale($)}}Ic([G],ul.prototype,"positionColor",null),Ee.add("volume",ul);class dl extends Di{constructor(e,t,i){const r=i||{};if(super(e,t,r),this.type="structure",this.parameters=Object.assign({radiusType:{type:"select",options:ro.types},radiusData:{type:"hidden"},radiusSize:{type:"number",precision:3,max:10,min:.001},radiusScale:{type:"number",precision:3,max:10,min:.001},assembly:null,defaultAssembly:{type:"hidden"}},this.parameters),this.selection=new ye(r.sele),this.dataList=[],this.structure=e,this.structureView=this.structure.getView(this.selection),e.biomolDict){const t={default:"default","":e.unitcell?"AU":"FULL"};Object.keys(e.biomolDict).forEach((function(e){t[e]=e})),this.parameters.assembly={type:"select",options:t,rebuild:!0}}else this.parameters.assembly=null}get defaultScale(){return{vdw:1,covalent:1,bfactor:.01,sstruc:1}}init(e){const t=e||{};t.colorScheme=l(t.colorScheme,"element"),this.setRadius(t.radius,t),this.radiusType=l(t.radiusType,"vdw"),this.radiusData=l(t.radiusData,{}),this.radiusSize=l(t.radiusSize,1),this.radiusScale=l(t.radiusScale,1),this.assembly=l(t.assembly,"default"),this.defaultAssembly=l(t.defaultAssembly,""),"auto"===t.quality&&(t.quality=this.getQuality()),super.init(t),this.selection.signals.stringChanged.add((()=>{this.build()})),this.build()}setRadius(e,t){const i=Object.keys(io);return"string"==typeof e&&i.includes(e.toLowerCase())?t.radiusType=e:void 0!==e&&(t.radiusType="size",t.radiusSize=e),this}getAssembly(){const e="default"===this.assembly?this.defaultAssembly:this.assembly;return this.structure.biomolDict[e]}getQuality(){let e;const t=this.structureView,i=this.getAssembly();e=i?i.getAtomCount(t):t.atomCount,Ie&&(e*=4);return t.atomStore.count/t.residueStore.count<2&&(e*=10),e<15e3?"high":e<8e4?"medium":"low"}create(){if(0===this.structureView.atomCount)return;if(!this.structureView.hasCoords())return void(this.needsBuild=!0);this.needsBuild=!1;const e=this.getAssembly();if(e)e.partList.forEach(((e,t)=>{const i=e.getView(this.structureView);if(0===i.atomCount)return;const r=this.createData(i,t);r&&(r.sview=i,r.instanceList=e.getInstanceList(),this.dataList.push(r))}));else{const e=this.createData(this.structureView,0);e&&(e.sview=this.structureView,this.dataList.push(e))}}update(e){!this.lazy||this.visible?this.needsBuild?this.build():this.dataList.forEach((t=>{t.bufferList.length>0&&this.updateData(e,t)}),this):Object.assign(this.lazyProps.what,e)}updateData(e,t){this.build()}getColorParams(){return Object.assign(Object.assign({},super.getColorParams()),{structure:this.structure})}getRadiusParams(e){return{type:this.radiusType,scale:this.radiusScale,size:this.radiusSize,data:this.radiusData}}getAtomParams(e,t){return Object.assign({what:e,colorParams:this.getColorParams(),radiusParams:this.getRadiusParams()},t)}getBondParams(e,t){return Object.assign({what:e,colorParams:this.getColorParams(),radiusParams:this.getRadiusParams()},t)}getAtomRadius(e){if(this.structureView.atomSet.isSet(e.index)){return new ro(this.getRadiusParams()).atomRadius(e)}return 0}setSelection(e,t){return this.selection.setString(e,t),this}setParameters(e,t={},i=!1){const r=e||{};return this.setRadius(r.radius,r),void 0===r.radiusType&&void 0===r.radiusData&&void 0===r.radiusSize&&void 0===r.radiusScale||(t.radius=!0,De&&!this.disableImpostor||(i=!0)),void 0!==r.defaultAssembly&&r.defaultAssembly!==this.defaultAssembly&&("default"===this.assembly&&void 0===r.assembly||"default"===r.assembly)&&(i=!0),super.setParameters(r,t,i),this}getParameters(){return Object.assign(super.getParameters(),{sele:this.selection?this.selection.string:void 0,defaultAssembly:this.defaultAssembly})}attach(e){const t=this.viewer,i=this.bufferList;this.dataList.forEach((function(e){e.bufferList.forEach((function(r){i.push(r),t.add(r,e.instanceList)}))})),this.setVisibility(this.visible),e()}clear(){this.dataList.length=0,super.clear()}dispose(){this.structureView.dispose(),super.dispose()}}class ml extends dl{constructor(e,t,i){super(e,t,i),this.n=0,this.parameters=Object.assign({labelVisible:{type:"boolean"},labelSize:{type:"number",precision:3,max:10,min:.001},labelColor:{type:"color"},labelFontFamily:{type:"select",options:{"sans-serif":"sans-serif",monospace:"monospace",serif:"serif"},buffer:"fontFamily"},labelFontStyle:{type:"select",options:{normal:"normal",italic:"italic"},buffer:"fontStyle"},labelFontWeight:{type:"select",options:{normal:"normal",bold:"bold"},buffer:"fontWeight"},labelsdf:{type:"boolean",buffer:"sdf"},labelXOffset:{type:"number",precision:1,max:20,min:-20,buffer:"xOffset"},labelYOffset:{type:"number",precision:1,max:20,min:-20,buffer:"yOffset"},labelZOffset:{type:"number",precision:1,max:20,min:-20,buffer:"zOffset"},labelAttachment:{type:"select",options:{"bottom-left":"bottom-left","bottom-center":"bottom-center","bottom-right":"bottom-right","middle-left":"middle-left","middle-center":"middle-center","middle-right":"middle-right","top-left":"top-left","top-center":"top-center","top-right":"top-right"},rebuild:!0},labelBorder:{type:"boolean",buffer:"showBorder"},labelBorderColor:{type:"color",buffer:"borderColor"},labelBorderWidth:{type:"number",precision:2,max:.3,min:0,buffer:"borderWidth"},labelBackground:{type:"boolean",rebuild:!0},labelBackgroundColor:{type:"color",buffer:"backgroundColor"},labelBackgroundMargin:{type:"number",precision:2,max:2,min:0,rebuild:!0},labelBackgroundOpacity:{type:"range",step:.01,max:1,min:0,buffer:"backgroundOpacity"},labelFixedSize:{type:"boolean",buffer:"fixedSize"},lineOpacity:{type:"range",min:0,max:1,step:.01},linewidth:{type:"integer",max:50,min:1,buffer:!0}},this.parameters,{flatShaded:null})}init(e){const t=e||{};this.labelVisible=l(t.labelVisible,!0),this.labelSize=l(t.labelSize,2),this.labelColor=l(t.labelColor,16777215),this.labelFontFamily=l(t.labelFontFamily,"sans-serif"),this.labelFontStyle=l(t.labelFontstyle,"normal"),this.labelFontWeight=l(t.labelFontWeight,"bold"),this.labelsdf=l(t.labelsdf,"Chrome"===Ce),this.labelXOffset=l(t.labelXOffset,0),this.labelYOffset=l(t.labelYOffset,0),this.labelZOffset=l(t.labelZOffset,.5),this.labelAttachment=l(t.labelAttachment,"bottom-left"),this.labelBorder=l(t.labelBorder,!1),this.labelBorderColor=l(t.labelBorderColor,"lightgrey"),this.labelBorderWidth=l(t.labelBorderWidth,.15),this.labelBackground=l(t.labelBackground,!1),this.labelBackgroundColor=l(t.labelBackgroundColor,"lightgrey"),this.labelBackgroundMargin=l(t.labelBackgroundMargin,.5),this.labelBackgroundOpacity=l(t.labelBackgroundOpacity,1),this.labelFixedSize=l(t.labelFixedSize,!1),this.lineOpacity=l(t.lineOpacity,1),this.linewidth=l(t.linewidth,2),super.init(t)}update(e){e.position?this.build():super.update(e)}updateData(e,i){const r={};if(e&&!e.labelSize||Object.assign(r,{size:yt(this.n,this.labelSize)}),!e||e.labelColor){const e=new t.Color(this.labelColor);Object.assign(r,{color:bt(this.n,e.r,e.g,e.b)})}this.textBuffer.setAttributes(r)}setParameters(e,t={},i=!1){return e&&e.labelSize&&(t.labelSize=!0),e&&(e.labelColor||0===e.labelColor)&&(t.labelColor=!0,i=!0),super.setParameters(e,t,i),e&&void 0!==e.opacity&&this.textBuffer.setParameters({opacity:1}),e&&void 0!==e.labelVisible&&this.setVisibility(this.visible),this}setVisibility(e,t){return super.setVisibility(e,!0),this.textBuffer&&this.textBuffer.setVisibility(this.labelVisible&&this.visible),t||this.viewer.requestRender(),this}getLabelBufferParams(e={}){return super.getBufferParams(Object.assign({fontFamily:this.labelFontFamily,fontStyle:this.labelFontStyle,fontWeight:this.labelFontWeight,sdf:this.labelsdf,xOffset:this.labelXOffset,yOffset:this.labelYOffset,zOffset:this.labelZOffset,attachment:this.labelAttachment,showBorder:this.labelBorder,borderColor:this.labelBorderColor,borderWidth:this.labelBorderWidth,showBackground:this.labelBackground,backgroundColor:this.labelBackgroundColor,backgroundMargin:this.labelBackgroundMargin,backgroundOpacity:this.labelBackgroundOpacity,fixedSize:this.labelFixedSize,disablePicking:!0,visible:this.labelVisible},e,{opacity:1}))}getAtomRadius(){return 0}}function pl(e,t){const i=e.getAtomProxy(),r=new ye,s=t.length;if(0===s)return new Float32Array(0);const n=t[0].length,o=e.getAtomSet(),a=new Float32Array(s*n*3);let c=0;return t.forEach((function(t){let s=!1;for(let l=0;l 1.0 ){\ngl_FragColor = vec4( backgroundColor, backgroundOpacity );\n}else{\nfloat sdf = texture2D( fontTexture, texCoord ).a;\nif( showBorder ) sdf += borderWidth;\nfloat a = smoothstep(padding - gamma, padding + gamma, sdf);\nif( a < 0.2 ) discard;\na *= opacity;\nvec3 outgoingLight = vColor;\nif( showBorder && sdf < ( padding + borderWidth ) ){\noutgoingLight = borderColor;\n}\ngl_FragColor = vec4( outgoingLight, a );\n}\n#if defined( PICKING )\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");const bl={};const xl={font:"sans-serif",size:36,style:"normal",variant:"normal",weight:"normal",outline:3,width:1024,height:1024};class vl{constructor(e={}){this.gamma=1,this.mapped={},this.scratchW=0,this.scratchH=0,this.currentX=0,this.currentY=0,this.cutoff=.25,this.parameters=h(e,xl);const i=this.parameters;this.radius=i.size/8,this.padding=i.size/3;const r=this.lineHeight=i.size+2*i.outline+Math.round(i.size/4),s=this.maxWidth=i.width/4,n=this.canvas=document.createElement("canvas");n.width=s,n.height=r;const o=this.context=this.canvas.getContext("2d");o.font=`${i.style} ${i.variant} ${i.weight} ${i.size}px ${i.font}`,o.fillStyle="black",o.textAlign="left",o.textBaseline="bottom",o.lineJoin="round",this.gridOuter=new Float64Array(r*s),this.gridInner=new Float64Array(r*s),this.f=new Float64Array(Math.max(r,s)),this.d=new Float64Array(Math.max(r,s)),this.z=new Float64Array(Math.max(r,s)+1),this.v=new Int16Array(Math.max(r,s)),this.data=new Uint8Array(i.width*i.height*4),this.canvas2=document.createElement("canvas"),this.canvas2.width=i.width,this.canvas2.height=i.height,this.context2=this.canvas2.getContext("2d"),this.placeholder=this.map(String.fromCharCode(65533));for(let e=32;e<=126;++e)this.map(String.fromCharCode(e));this.map(String.fromCharCode(176)),this.map(String.fromCharCode(8491)),this.texture=new t.CanvasTexture(this.canvas2),this.texture.flipY=!1,this.texture.needsUpdate=!0}map(e){const t=this.parameters;return void 0===this.mapped[e]&&(this.draw(e),this.currentX+this.scratchW>t.width&&(this.currentX=0,this.currentY+=this.scratchH),this.currentY+this.scratchH>t.height&&console.warn("canvas to small"),this.mapped[e]={x:this.currentX,y:this.currentY,w:this.scratchW,h:this.scratchH},this.context2.drawImage(this.canvas,0,0,this.scratchW,this.scratchH,this.currentX,this.currentY,this.scratchW,this.scratchH),this.currentX+=this.scratchW),this.mapped[e]}get(e){return this.mapped[e]||this.placeholder}draw(e){const t=this.parameters,i=this.lineHeight,r=t.outline,s=this.context,n=this.maxWidth,o=r,a=i-t.outline,c=s.measureText(e),l=Math.min(n,Math.ceil(c.width+2*o+1)),h=l*i;s.clearRect(0,0,l,i),s.fillText(e,o,a);const u=s.getImageData(0,0,l,i),d=u.data;for(let e=0;e= 0.0 ) {\ntrimSegment( start, end );\n} else if ( end.z < 0.0 && start.z >= 0.0 ) {\ntrimSegment( end, start );\n}\n}\nvec4 clipStart = projectionMatrix * start;\nvec4 clipEnd = projectionMatrix * end;\nvec2 ndcStart = clipStart.xy / clipStart.w;\nvec2 ndcEnd = clipEnd.xy / clipEnd.w;\nvec2 dir = ndcEnd - ndcStart;\ndir.x *= aspect;\ndir = normalize( dir );\nvec2 offset = vec2( dir.y, - dir.x );\ndir.x /= aspect;\noffset.x /= aspect;\nif ( mapping.x < 0.0 ) offset *= - 1.0;\noffset *= linewidth;\noffset /= resolution.y;\nvec4 clip = ( mapping.y < 0.5 ) ? clipStart : clipEnd;\noffset *= clip.w;\nclip.xy += offset;\ngl_Position = clip;\n#ifndef PICKING\nvViewPosition = ( projectionMatrixInverse * clip ).xyz;\n#endif\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n#include nearclip_vertex\n}"),Ve.add("shader/WideLine.frag","uniform vec3 diffuse;\nuniform float opacity;\nuniform float clipNear;\nuniform float clipRadius;\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#ifdef PICKING\nuniform float objectId;\nvarying vec3 vPickingColor;\n#else\n#include common\n#include fog_pars_fragment\nvarying vec3 vViewPosition;\nvarying vec3 vColor;\nvarying vec3 vColor2;\nvarying float flag;\n#endif\nvoid main() {\n#include nearclip_fragment\n#include radiusclip_fragment\n#if defined( PICKING )\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 outgoingLight = vec3( 0.0 );\nvec4 diffuseColor = vec4( diffuse, 1.0 );\nif ( flag < 0.0 ) {\ndiffuseColor.rgb *= vColor;\n} else {\ndiffuseColor.rgb *= vColor2;\n}\n#include alphatest_fragment\noutgoingLight = diffuseColor.rgb;\ngl_FragColor = vec4( outgoingLight, diffuseColor.a * opacity );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");const Cl=Object.assign({linewidth:2},Mn),Pl=Object.assign({linewidth:{uniform:!0}},Dn);class Il extends Ma{constructor(e,i={}){super(e,i),this.parameterTypes=Pl,this.vertexShader="WideLine.vert",this.fragmentShader="WideLine.frag",!e.color2&&e.color&&(e.color2=e.color),this.addUniforms({linewidth:{value:this.parameters.linewidth},resolution:{value:new t.Vector2},projectionMatrixInverse:{value:new t.Matrix4}}),this.addAttributes({position1:{type:"v3",value:null},position2:{type:"v3",value:null},color2:{type:"c",value:null}}),this.setAttributes(e),this.makeMapping()}get defaultParameters(){return Cl}setParameters(e){super.setParameters(e)}}je.add("wideline",Il);class kl extends ml{constructor(e,t,i){super(e,t,i),this.type="angle",this.parameters=Object.assign({atomTriple:{type:"hidden",rebuild:!0},vectorVisible:{type:"boolean",default:!0},arcVisible:{type:"boolean",default:!0},sectorVisible:{type:"boolean",default:!0}},this.parameters),this.init(i)}init(e){const t=e||{};t.side=l(t.side,"double"),t.opacity=l(t.opacity,.5),this.atomTriple=l(t.atomTriple,[]),this.arcVisible=l(t.arcVisible,!0),this.sectorVisible=l(t.sectorVisible,!0),this.vectorVisible=l(t.vectorVisible,!0),super.init(t)}createData(e){if(!e.atomCount||!this.atomTriple.length)return;const i=function(e,t){return function(e){const t=[],i=e.length/9;for(let r=0;r radius2) {\ndiscard;\n}\n#ifdef CAP\nsurface_point = front_point;\n_normal = axis;\n#else\nsurface_point = ray_target + ( (-a1 - sqrt(d)) / a2 ) * ray_direction;\ndNV = dot(-axis, ray_direction);\nnear = dot(axis, end) / dNV;\nnew_point2 = ray_direction * near + ray_origin;\nif (dot(new_point2 - end, new_point2-base) < radius2) {\ndiscard;\n}\ninterior = true;\n#endif\n}\nif( end_cap_test > 0.0 )\n{\nfloat dNV;\nfloat near;\nvec3 end_point;\nif ( ortho == 1.0 ) {\nend_point = ray_target;\n} else {\ndNV = dot(axis, ray_direction);\nif (dNV < 0.0) {\ndiscard;\n}\nnear = dot(axis, end) / dNV;\nend_point = ray_direction * near + ray_origin;\n}\n\nif( dot(end_point - end, end_point-base) > radius2 ) {\ndiscard;\n}\n#ifdef CAP\nsurface_point = end_point;\n_normal = axis;\n#else\nsurface_point = ray_target + ( (-a1 - sqrt(d)) / a2 ) * ray_direction;\ndNV = dot(-axis, ray_direction);\nnear = dot(-axis, (base)) / dNV;\nnew_point2 = ray_direction * near + ray_origin;\nif (dot(new_point2 - base, new_point2-base) < radius2) {\ndiscard;\n}\ninterior = true;\n#endif\n}\ngl_FragDepthEXT = calcDepth( surface_point );\n\n#ifdef NEAR_CLIP\nif( calcClip( surface_point ) > 0.0 ){\ndist = (-a1 - sqrt(d)) / a2;\nsurface_point = ray_target + dist * ray_direction;\nif( calcClip( surface_point ) > 0.0 ) {\ndiscard;\n}\ninterior = true;\ngl_FragDepthEXT = calcDepth( surface_point );\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( clipNear - 0.5 ) ) ) + ( 0.0000001 / vRadius ) );\n}\n}else if( gl_FragDepthEXT <= 0.0 ){\ndist = (-a1 - sqrt(d)) / a2;\nsurface_point = ray_target + dist * ray_direction;\ninterior = true;\ngl_FragDepthEXT = calcDepth( surface_point );\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n}\n#else\nif( gl_FragDepthEXT <= 0.0 ){\ndist = (-a1 - sqrt(d)) / a2;\nsurface_point = ray_target + dist * ray_direction;\ninterior = true;\ngl_FragDepthEXT = calcDepth( surface_point );\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n}\n#endif\nif (gl_FragDepthEXT < 0.0) {\ndiscard;\n}\nif (gl_FragDepthEXT > 1.0) {\ndiscard;\n}\n#ifdef PICKING\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 vViewPosition = -surface_point;\nvec3 vNormal = _normal;\nvec3 vColor;\nif( distSq3( surface_point, end ) < distSq3( surface_point, base ) ){\nif( b < 0.0 ){\nvColor = vColor1;\n}else{\nvColor = vColor2;\n}\n}else{\nif( b > 0.0 ){\nvColor = vColor1;\n}else{\nvColor = vColor2;\n}\n}\nvec4 diffuseColor = vec4( diffuse, opacity );\nReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\nvec3 totalEmissiveLight = emissive;\n#include color_fragment\n#include roughnessmap_fragment\n#include metalnessmap_fragment\nvec3 normal = normalize( vNormal );\nvec3 geometryNormal = normal;\n#include lights_physical_fragment\n#include lights_fragment_begin\n#include lights_fragment_end\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\nif( interior ){\n#ifdef USE_INTERIOR_COLOR\noutgoingLight.xyz = interiorColor;\n#else\n#ifdef DIFFUSE_INTERIOR\noutgoingLight.xyz = vColor;\n#endif\n#endif\noutgoingLight.xyz *= 1.0 - interiorDarkening;\n}\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");const Fl=new Float32Array([-1,1,-1,-1,-1,-1,1,1,-1,1,1,1,1,-1,-1,1,-1,1]),El=new Uint16Array([0,1,2,1,4,2,2,4,3,4,5,3]);class Ll extends Pa{constructor(e,t={}){super("v3",e,t)}get mapping(){return Fl}get mappingIndices(){return El}get mappingIndicesSize(){return 12}get mappingSize(){return 6}get mappingItemSize(){return 3}}const Nl=Object.assign({openEnded:!1},Mn),zl=Object.assign({openEnded:{updateShader:!0}},Dn);class Vl extends Ll{constructor(e,i={}){super(e,i),this.parameterTypes=zl,this.isImpostor=!0,this.vertexShader="CylinderImpostor.vert",this.fragmentShader="CylinderImpostor.frag",this.addUniforms({modelViewMatrixInverse:{value:new t.Matrix4},ortho:{value:0}}),this.addAttributes({position1:{type:"v3",value:null},position2:{type:"v3",value:null},color2:{type:"c",value:null},radius:{type:"f",value:null}}),this.setAttributes(e),this.makeMapping()}get defaultParameters(){return Nl}getDefines(e){const t=Ll.prototype.getDefines.call(this,e);return this.parameters.openEnded||(t.CAP=1),t}}Object.assign({disableImpostor:!1},Rl,Nl);const Gl=class{constructor(e,t={}){return!e.color2&&e.color&&(e.color2=e.color),!De||t&&t.disableImpostor?new $l(e,t):new Vl(e,t)}};je.add("cylinder",Gl);class Ul extends dl{constructor(e,t,i){super(e,t,i),this.type="axes",this.parameters=Object.assign({radiusSize:{type:"number",precision:3,max:10,min:.001},sphereDetail:!0,radialSegments:!0,disableImpostor:!0,showAxes:{type:"boolean",rebuild:!0},showBox:{type:"boolean",rebuild:!0}},this.parameters,{assembly:null}),this.init(i)}init(e){const t=e||{};t.radiusSize=l(t.radiusSize,.5),t.colorValue=l(t.colorValue,"lightgreen"),t.useInteriorColor=l(t.useInteriorColor,!0),this.showAxes=l(t.showAxes,!0),this.showBox=l(t.showBox,!1),super.init(t)}getPrincipalAxes(){let e;const t=this.getAssembly();return t&&(e=t.partList[0].getSelection()),this.structureView.getPrincipalAxes(e)}getAxesData(e){const i=this.getPrincipalAxes(),r=new t.Color(this.colorValue);let s=0,n=0;this.showAxes&&(s+=6,n+=3),this.showBox&&(s+=8,n+=12);const o=new Float32Array(3*s),a=bt(s,r.r,r.g,r.b),c=yt(s,this.radiusSize),l=new Float32Array(3*n),h=new Float32Array(3*n),u=bt(n,r.r,r.g,r.b),d=yt(n,this.radiusSize);let m=0;if(this.showAxes){const e=function(e,t){e.toArray(o,2*m),t.toArray(o,2*m+3),e.toArray(l,m),t.toArray(h,m),m+=3};e(i.begA,i.endA),e(i.begB,i.endB),e(i.begC,i.endC)}if(this.showBox){const r=new t.Vector3,{d1a:s,d2a:n,d3a:a,d1b:c,d2b:u,d3b:d}=i.getProjectedScaleForAtoms(e);let p=2*m;const f=function(e,t,s){r.copy(i.center).addScaledVector(i.normVecA,e).addScaledVector(i.normVecB,t).addScaledVector(i.normVecC,s),r.toArray(o,p),p+=3};f(s,n,a),f(s,n,d),f(s,u,d),f(s,u,a),f(c,u,d),f(c,u,a),f(c,n,a),f(c,n,d);let g=m;const y=function(e,t){r.fromArray(o,2*m+3*e).toArray(l,g),r.fromArray(o,2*m+3*t).toArray(h,g),g+=3};y(0,1),y(0,3),y(0,6),y(1,2),y(1,7),y(2,3),y(2,4),y(3,5),y(4,5),y(4,7),y(5,6),y(6,7)}const p=new Ns(i);return{vertex:{position:o,color:a,radius:c,picking:p},edge:{position1:l,position2:h,color:u,color2:u,radius:d,picking:p}}}create(){const e=this.getAxesData(this.structureView);this.sphereBuffer=new Ta(e.vertex,this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0})),this.cylinderBuffer=new Gl(e.edge,this.getBufferParams({openEnded:!0,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0})),this.dataList.push({sview:this.structureView,bufferList:[this.sphereBuffer,this.cylinderBuffer]})}createData(e){}updateData(e,t){const i=this.getAxesData(t.sview),r={},s={};e&&!e.position||(Object.assign(r,{position:i.vertex.position}),Object.assign(s,{position1:i.edge.position1,position2:i.edge.position2})),e&&!e.color||(Object.assign(r,{color:i.vertex.color}),Object.assign(s,{color:i.edge.color,color2:i.edge.color})),e&&!e.radius||(Object.assign(r,{radius:i.vertex.radius}),Object.assign(s,{radius:i.edge.radius})),this.sphereBuffer.setAttributes(r),this.cylinderBuffer.setAttributes(s)}}Ne.add("axes",Ul);class jl extends dl{constructor(e,t,i){super(e,t,i),this.type="ball+stick",this.parameters=Object.assign({sphereDetail:!0,radialSegments:!0,openEnded:!0,disableImpostor:!0,aspectRatio:{type:"number",precision:1,max:10,min:1},lineOnly:{type:"boolean",rebuild:!0},cylinderOnly:{type:"boolean",rebuild:!0},multipleBond:{type:"select",rebuild:!0,options:{off:"off",symmetric:"symmetric",offset:"offset"}},bondScale:{type:"number",precision:2,max:1,min:.01},bondSpacing:{type:"number",precision:2,max:2,min:.5},linewidth:{type:"integer",max:50,min:1,buffer:!0}},this.parameters),this.init(i)}init(e){var t=e||{};t.radiusType=l(t.radiusType,"size"),t.radiusSize=l(t.radiusSize,.15),t.useInteriorColor=l(t.useInteriorColor,!0),this.aspectRatio=l(t.aspectRatio,2),this.lineOnly=l(t.lineOnly,!1),this.cylinderOnly=l(t.cylinderOnly,!1),this.multipleBond=l(t.multipleBond,"off"),this.bondSpacing=l(t.bondSpacing,1),this.bondScale=l(t.bondScale,.4),this.linewidth=l(t.linewidth,2),super.init(t)}getAtomRadius(e){return this.aspectRatio*super.getAtomRadius(e)}getAtomParams(e,t){var i=super.getAtomParams(e,t);return i.radiusParams.scale*=this.aspectRatio,i}getAtomData(e,t,i){return e.getAtomData(this.getAtomParams(t,i))}getBondParams(e,t){return t=Object.assign({multipleBond:this.multipleBond,bondSpacing:this.bondSpacing,bondScale:this.bondScale},t),super.getBondParams(e,t)}getBondData(e,t,i){return e.getBondData(this.getBondParams(t,i))}createData(e){const t=[];if(this.lineOnly)this.lineBuffer=new Il(this.getBondData(e,{position:!0,color:!0,picking:!0}),this.getBufferParams({linewidth:this.linewidth})),t.push(this.lineBuffer);else{const i=new Gl(this.getBondData(e),this.getBufferParams({openEnded:this.openEnded,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0}));if(t.push(i),!this.cylinderOnly){const i=new Ta(this.getAtomData(e),this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0}));t.push(i)}}return{bufferList:t}}updateData(e,t){"off"!==this.multipleBond&&e&&e.radius&&(e.position=!0);const i=this.getBondData(t.sview,e);if(this.lineOnly){const r={};e&&!e.position||Object.assign(r,{position1:i.position1,position2:i.position2}),e&&!e.color||Object.assign(r,{color:i.color,color2:i.color2}),t.bufferList[0].setAttributes(r)}else{var r={};if(e&&!e.position||Object.assign(r,{position1:i.position1,position2:i.position2}),e&&!e.color||Object.assign(r,{color:i.color,color2:i.color2}),e&&!e.radius||Object.assign(r,{radius:i.radius}),t.bufferList[0].setAttributes(r),!this.cylinderOnly){var s=this.getAtomData(t.sview,e),n={};e&&!e.position||Object.assign(n,{position:s.position}),e&&!e.color||Object.assign(n,{color:s.color}),e&&!e.radius||Object.assign(n,{radius:s.radius}),t.bufferList[1].setAttributes(n)}}}setParameters(e={}){let t=!1;const i={};return(e.aspectRatio||e.bondSpacing||e.bondScale)&&(Object.assign(i,{radius:!0}),De&&!this.disableImpostor||(t=!0)),super.setParameters(e,i,t),this}}Ne.add("ball+stick",jl);class Hl extends jl{constructor(e,t,i){super(e,t,i),this.type="backbone",this.parameters=Object.assign({},this.parameters,{multipleBond:null,bondSpacing:null}),this.init(i)}init(e){var t=e||{};t.aspectRatio=l(t.aspectRatio,1),t.radiusSize=l(t.radiusSize,.25),super.init(t)}getAtomRadius(e){return e.isTrace()?super.getAtomRadius(e):0}getAtomData(e,t,i){return e.getBackboneAtomData(this.getAtomParams(t,i))}getBondData(e,t,i){return e.getBackboneBondData(this.getBondParams(t,i))}}Ne.add("backbone",Hl);class Wl extends jl{constructor(e,t,i){super(e,t,i),this.type="base",this.parameters=Object.assign({},this.parameters,{multipleBond:null,bondSpacing:null})}init(e){let t=e||{};t.aspectRatio=l(t.aspectRatio,1),t.radiusSize=l(t.radiusSize,.3),super.init(t)}getAtomData(e,t,i){return e.getRungAtomData(this.getAtomParams(t,i))}getBondData(e,t,i){let r=this.getBondParams(t,i);return Object.assign(r.colorParams,{rung:!0}),e.getRungBondData(r)}}Ne.add("base",Wl);class ql{constructor(e,i){this.m=e,this.tension=i,this.dt=1/this.m,this.delta=1e-4,this.vec1=new t.Vector3,this.vec2=new t.Vector3,this.vDir=new t.Vector3,this.vTan=new t.Vector3,this.vNorm=new t.Vector3,this.vBin=new t.Vector3,this.m2=Math.ceil(this.m/2)}interpolateToArr(e,t,i,r,s,n,o){n[o+0]=E(e.x,t.x,i.x,r.x,s,this.tension),n[o+1]=E(e.y,t.y,i.y,r.y,s,this.tension),n[o+2]=E(e.z,t.z,i.z,r.z,s,this.tension)}interpolateToVec(e,t,i,r,s,n){n.x=E(e.x,t.x,i.x,r.x,s,this.tension),n.y=E(e.y,t.y,i.y,r.y,s,this.tension),n.z=E(e.z,t.z,i.z,r.z,s,this.tension)}interpolatePosition(e,t,i,r,s,n){for(var o=0;o1&&(l=1),this.interpolateToVec(e,t,i,r,c,this.vec1),this.interpolateToVec(e,t,i,r,l,this.vec2),this.vec2.sub(this.vec1).normalize(),this.vec2.toArray(s,h)}}vectorSubdivide(e,t,i,r,s){let n,o=t.next(),a=t.next(),c=t.next();const l=t.size,h=l-1;let u=r||0;for(let r=0;r0&&t{if(e.residueCount<4)return;i.push(e);const r=this.getSpline(e),s=this.getAspectRatio(e),n=r.getSubdividedPosition(),o=r.getSubdividedOrientation(),a=r.getSubdividedColor(this.getColorParams()),c=r.getSubdividedPicking(),l=r.getSubdividedSize(this.getRadiusParams());t.push(new Ql(Object.assign({},n,o,a,c,l),this.getBufferParams({radialSegments:this.radialSegments,aspectRatio:s,capped:this.capped})))}),e.getSelection()),{bufferList:t,polymerList:i}}updateData(t,i){e.Debug&&Be.time(this.type+" repr update"),t=t||{};for(var r=0,s=i.polymerList.length;r0;Gi(_,x,S);const s=Vi(_,w)<0;if(Yi(_,w,Vi(w,v)),Gi(C,v,_),Yi(_,w,Vi(w,A)),Gi(P,A,_),0===qi(C)||0===qi(P))continue;Ki(C,C),Ki(P,P);const l=n[T]=ir(C,P);a[T]=(mt*l).toFixed(1)+String.fromCharCode(176),zi(M,C,w),Ki(M,M),Vi(M,P)<0&&tr(M,M),fl(_,S,C,M,l/2),Hi(_,o,3*T);const R=Math.ceil(l/i),O=R+(t.extendLine?4:2),$=t.extendLine?36:0,F=new Float32Array(3*O),E=new Float32Array(3*O),L=new Float32Array(9*R),N=new Float32Array($);c[T]=F,h[T]=E,u[T]=L,d[T]=N,t.extendLine&&(r?(Gi(_,g,b),Ki(_,_),Yi(I,_,1/Vi(C,_)),Ui(I,I,b)):(Yi(I,v,1/Vi(C,v)),Ui(I,I,y)),s?(Gi(_,x,y),Ki(_,_),Yi(k,_,1/Vi(P,_)),Ui(k,k,y)):(Yi(k,A,1/Vi(P,A)),Ui(k,k,b))),Ui(D,S,C);let z=0;t.extendLine?(Hi(g,F,z),Hi(I,E,z),z+=3,Hi(I,F,z),Hi(D,E,z),z+=3,Hi(I,N,0),Hi(D,N,3),Hi(r?b:y,N,6),Hi(r?b:y,N,9),Hi(D,N,12),Hi(S,N,15)):(Hi(S,F,z),Hi(D,E,z),z+=3);const V=function(e,t){const i=9*t;Hi(S,L,i),Hi(D,L,i+3),Hi(D,F,z),fl(D,S,C,M,e),Hi(D,L,i+6),Hi(D,E,z),z+=3};let G=0;for(let e=i;e{const t=ih(i,e);Object.assign(e,t)})),t.side=l(t.side,"double"),t.opacity=l(t.opacity,.5),t.radiusType=l(t.radiusType,"size"),t.radiusSize=l(t.radiusSize,.15),super.init(t)}getHistogramBinBorderBufferParameters(){return this.getBufferParams({linewidth:this.histogramBinBorderWidth,visible:this.histogramBinBorderVisible,opacity:this.histogramBinBorderOpacity})}getBondArrowsBufferParameters(){return this.getBufferParams({linewidth:this.bondArrowWidth,visible:this.bondArrowVisible,opacity:this.bondArrowOpacity})}getOpaqueMiddleDiscBufferParameters(){return this.getBufferParams({visible:this.opaqueMiddleDiscVisible,opacity:this.opaqueMiddleDiscOpacity})}getHistogramBufferParameters(){return this.getBufferParams({visible:!0,opacity:this.histogramOpacity,side:"double"})}createData(e){if(!e.atomCount||!this.histogramsData.length)return;this.histogramsData.forEach((t=>t.atomPositions=pl(e,[t.atomQuad])));const t=this.scaleBinToSectorArea?function(e){return Math.sqrt(e)}:function(e){return e};function i(e){const t=e.map((e=>e.length)),i=new Float32Array(Pt(t));let r=0;for(let t=0;te.startPoints))),position2:i(e.map((e=>e.endPoints))),color:i(e.map((e=>e.startColors))),color2:i(e.map((e=>e.endColors)))},t)}function s(e,t){return new Bn({position:i(e.map((e=>e.triangles))),color:i(e.map((e=>e.triangleColors)))},t)}this.histogramsData.forEach((e=>e.histogram360Scaled=e.histogram360.map(t)));const n=[];for(let e=0;e=3&&(t=nh(i)),void 0!==t&&n.push(t)}return this.frontHistogramBinBordersBuffer=r(n.map((e=>e.frontHistogramBinBorders)),this.getHistogramBinBorderBufferParameters()),this.backHistogramBinBordersBuffer=r(n.map((e=>e.backHistogramBinBorders)),this.getHistogramBinBorderBufferParameters()),this.adjacentBondArrowsBuffer=r(n.map((e=>e.adjacentBondArrows)),this.getBondArrowsBufferParameters()),this.distantBondArrowsBuffer=r(n.map((e=>e.distantBondArrows)),this.getBondArrowsBufferParameters()),this.opaqueMiddleDiscBuffer=s(n.map((e=>e.opaqueMiddleDisc)),this.getOpaqueMiddleDiscBufferParameters()),this.frontHistogramBuffer=s(n.map((e=>e.frontHistogram)),this.getHistogramBufferParameters()),this.backHistogramBuffer=s(n.map((e=>e.backHistogram)),this.getHistogramBufferParameters()),{bufferList:[].concat(this.frontHistogramBinBordersBuffer,this.backHistogramBinBordersBuffer,this.adjacentBondArrowsBuffer,this.distantBondArrowsBuffer,this.opaqueMiddleDiscBuffer,this.frontHistogramBuffer,this.backHistogramBuffer)}}setParameters(e){return super.setParameters(e,{},!1),e&&void 0!==e.histogramBinBorderVisible&&this.setVisibility(this.visible),this}setVisibility(e,t){return super.setVisibility(e,!0),this.frontHistogramBinBordersBuffer&&this.frontHistogramBinBordersBuffer.setVisibility(this.histogramBinBorderVisible),this.backHistogramBinBordersBuffer&&this.backHistogramBinBordersBuffer.setVisibility(this.histogramBinBorderVisible),t||this.viewer.requestRender(),this}}function nh(e){const t=e.atomPositions,i=e.histogram360Scaled,r=i.length<=180?360:2*i.length,s={triangles:new Float32Array(3*r*3),triangleColors:rh(e.opaqueMiddleDiscColor,3*r)},n={triangles:new Float32Array(3*i.length*3),triangleColors:rh(e.frontHistogramColor,3*i.length)},o={triangles:new Float32Array(3*i.length*3),triangleColors:rh(e.backHistogramColor,3*i.length)},a={startPoints:new Float32Array(3*i.length),endPoints:new Float32Array(3*i.length),startColors:rh(e.histogramBinBorderColor,i.length),endColors:rh(e.histogramBinBorderColor,i.length)},c={startPoints:new Float32Array(3*i.length),endPoints:new Float32Array(3*i.length),startColors:rh(e.histogramBinBorderColor,i.length),endColors:rh(e.histogramBinBorderColor,i.length)},l={startPoints:new Float32Array(6),endPoints:new Float32Array(6),startColors:rh(e.adjacentBondArrowColor,i.length),endColors:rh(e.adjacentBondArrowColor,i.length)},h={startPoints:new Float32Array(6),endPoints:new Float32Array(6),startColors:rh(e.distantBondArrowColor,i.length),endColors:rh(e.distantBondArrowColor,i.length)},u=Ni(),d=Ni(),m=Ni(),p=Ni(),f=Ni(),g=Ni(),y=Ni(),b=Ni(),x=Ni(),v=Ni(),w=Ni(),A=Ni(),_=Ni(),S=Ni(),C=Ni(),P=Ni(),I=[u,d,m,p];for(let e=0;e{let d=t[0],m=t[1];if("number"==typeof d&&Number.isInteger(d)&&"number"==typeof m&&Number.isInteger(m)){if(!u.get(d)||!u.get(m))return void(h+=1);c.index=d,l.index=m}else{n.setString(d),o.setString(m);var p=e.getAtomIndices(n),f=e.getAtomIndices(o);if(!p.length||!f.length)return void(h+=1);c.index=p[0],l.index=f[0]}a.addBond(c,l,1),i-=h;var g=c.distanceTo(l);switch(this.labelUnit){case"angstrom":r[i]=g.toFixed(2)+" "+String.fromCharCode(8491);break;case"nm":r[i]=(g/10).toFixed(2)+" nm";break;default:r[i]=g.toFixed(2)}var y=3*i;s[y+0]=(c.x+l.x)/2,s[y+1]=(c.y+l.y)/2,s[y+2]=(c.z+l.z)/2})),h>0&&(i-=h,s=s.subarray(0,3*i));var d=new Sr(a.count,!0);return{text:r,position:s,bondSet:d,bondStore:a}}getBondData(e,t,i){const r=e.getBondData(this.getBondParams(t,i));return r.picking&&(r.picking=new Us(r.picking.array,r.picking.structure,i.bondStore)),r}createData(e){if(!e.atomCount||!this.atomPair.length)return;const i=this.atomPair.length,r=new t.Color(this.labelColor),s=this.getDistanceData(e,this.atomPair);this.textBuffer=new Sl({position:s.position,size:yt(i,this.labelSize),color:bt(i,r.r,r.g,r.b),text:s.text},this.getLabelBufferParams());const n={bondSet:s.bondSet,bondStore:s.bondStore},o=this.getBondData(e,{position:!0,color:!0,picking:!0,radius:this.useCylinder},n);return this.useCylinder?this.distanceBuffer=new Gl(o,this.getBufferParams({openEnded:this.openEnded,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0})):this.distanceBuffer=new Il(sr(o),this.getBufferParams({linewidth:this.linewidth,visible:this.lineVisible,opacity:this.lineOpacity})),{bondSet:s.bondSet,bondStore:s.bondStore,position:s.position,bufferList:[this.textBuffer,this.distanceBuffer]}}updateData(e,t){super.updateData(e,t);const i={bondSet:t.bondSet,bondStore:t.bondStore},r=this.getBondData(t.sview,e,i),s={};e&&!e.color||Object.assign(s,{color:r.color,color2:r.color2}),e&&!e.radius||Object.assign(s,{radius:r.radius}),this.distanceBuffer.setAttributes(s)}setParameters(e){return super.setParameters(e,{},!1),this.useCylinder||(e&&e.lineOpacity&&this.distanceBuffer.setParameters({opacity:e.lineOpacity}),e&&void 0!==e.opacity&&this.distanceBuffer.setParameters({opacity:this.lineOpacity}),e&&e.linewidth&&this.distanceBuffer.setParameters({linewidth:e.linewidth})),this}}function ah(e){return 2*(e.position.length/3)*3}Ne.add("distance",oh);const ch=Object.assign({scale:1,color:"grey"},Mn);class lh extends Tn{constructor(e,i={}){super({position:new Float32Array(ah(e)),color:new Float32Array(ah(e))},i),this.isLine=!0,this.vertexShader="Line.vert",this.fragmentShader="Line.frag";const r=new t.Color(this.parameters.color),s=this.geometry.attributes;bt(ah(e)/3,r.r,r.g,r.b,s.color.array),this.setAttributes(e)}get defaultParameters(){return ch}setAttributes(e={}){const t=this.geometry.attributes;let i,r,s;e.position&&e.vector&&(i=e.position,r=e.vector,s=t.position.array,t.position.needsUpdate=!0);const n=this.size/2,o=this.parameters.scale;if(i&&r)for(let e=0;e{if(e.residueCount<4)return;i.push(e);const r=new fo(e),s=r.getPosition(),n=r.getColor(this.getColorParams()),o=r.getSize(this.getRadiusParams()),a=r.getPicking();t.push(new Ta({position:s.center,color:n.color,radius:o.size,picking:a.picking},this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0})),new lh({position:s.center,vector:s.axis},this.getBufferParams({color:"skyblue",scale:1})),new lh({position:s.center,vector:s.resdir},this.getBufferParams({color:"lightgreen",scale:1})))}),e.getSelection()),{bufferList:t,polymerList:i}}updateData(t,i){e.Debug&&Be.time(this.type+" repr update"),t=t||{};for(let e=0,r=i.polymerList.length;e radius2) {\nspaceposition.y = mapping.y * 1.5 * radius1;\nspaceposition.x = mapping.x * 1.5 * radius1;\n} else {\nspaceposition.y = mapping.y * 1.5 * radius2;\nspaceposition.x = mapping.x * 1.5 * radius2;\n}\nspaceposition.w = 1.0;\nvec4 e3 = vec4( 1.0 );\nvec3 e1, e1_temp, e2, e2_temp;\ne3.xyz = normalize(position_atom1-position_atom2);\nif (e3.z == 0.0) { e3.z = 0.0000000000001;}\nif ( (position_atom1.x - position_atom2.x) == 0.0) { position_atom1.x += 0.001;}\nif ( (position_atom1.y - position_atom2.y) == 0.0) { position_atom1.y += 0.001;}\nif ( (position_atom1.z - position_atom2.z) == 0.0) { position_atom1.z += 0.001;}\nvec4 focus = vec4( 1.0 );\nfocus.x = ( position_atom1.x*position_atom1.x - position_atom2.x*position_atom2.x +\n( radius2*radius2 - radius1*radius1 )*e3.x*e3.x/shrink )/(2.0*(position_atom1.x - position_atom2.x));\nfocus.y = ( position_atom1.y*position_atom1.y - position_atom2.y*position_atom2.y +\n( radius2*radius2 - radius1*radius1 )*e3.y*e3.y/shrink )/(2.0*(position_atom1.y - position_atom2.y));\nfocus.z = ( position_atom1.z*position_atom1.z - position_atom2.z*position_atom2.z +\n( radius2*radius2 - radius1*radius1 )*e3.z*e3.z/shrink )/(2.0*(position_atom1.z - position_atom2.z));\ne1.x = 1.0;\ne1.y = 1.0;\ne1.z = ( (e3.x*focus.x + e3.y*focus.y + e3.z*focus.z) - e1.x*e3.x - e1.y*e3.y)/e3.z;\ne1_temp = e1 - focus.xyz;\ne1 = normalize(e1_temp);\ne2_temp = e1.yzx * e3.zxy - e1.zxy * e3.yzx;\ne2 = normalize(e2_temp);\nmat3 R= mat3( e1.xyz, e2.xyz, e3.xyz );\nvertex_position.xyz = R * spaceposition.xyz;\nvertex_position.w = 1.0;\nvertex_position.x += (position_atom1.x+position_atom2.x) / 2.0;\nvertex_position.y += (position_atom1.y+position_atom2.y) / 2.0;\nvertex_position.z += (position_atom1.z+position_atom2.z) / 2.0;\ngl_Position = modelViewProjectionMatrix * vertex_position;\nvec4 i_near, i_far;\nvec4 near = gl_Position;\nnear.z = 0.0 ;\nnear = modelViewProjectionMatrixInverse * near;\ni_near = near;\nvec4 far = gl_Position;\nfar.z = far.w ;\ni_far = modelViewProjectionMatrixInverse * far;\nprime1 = vec4( position_atom1 - (position_atom1 - focus.xyz)*shrink, 1.0 );\nprime2 = vec4( position_atom2 - (position_atom2 - focus.xyz)*shrink, 1.0 );\nfloat Rsquare = (radius1*radius1/shrink) - (\n(position_atom1.x - focus.x)*(position_atom1.x - focus.x) +\n(position_atom1.y - focus.y)*(position_atom1.y - focus.y) +\n(position_atom1.z - focus.z)*(position_atom1.z - focus.z)\n);\nfocus.w = Rsquare;\nmatrix_near = mat4( i_near, i_far, focus, e3 );\ngl_Position.z = 1.0;\n}"),Ve.add("shader/HyperballStickImpostor.frag","#define STANDARD\n#define IMPOSTOR\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 interiorColor;\nuniform float interiorDarkening;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\nuniform float clipNear;\nuniform float shrink;\nuniform mat4 modelViewMatrix;\nuniform mat4 modelViewProjectionMatrix;\nuniform mat4 modelViewMatrixInverseTranspose;\nuniform mat4 projectionMatrix;\nvarying mat4 matrix_near;\nvarying vec4 prime1;\nvarying vec4 prime2;\nvarying float vRadius;\nvarying float vRadius2;\n#ifdef PICKING\nuniform float objectId;\nvarying vec3 vPickingColor;\n#else\nvarying vec3 vColor1;\nvarying vec3 vColor2;\n#include common\n#include fog_pars_fragment\n#include bsdfs\n#include lights_pars_begin\n#include lights_physical_pars_fragment\n#endif\nbool interior = false;\nfloat calcClip( vec4 cameraPos ){\nreturn dot( cameraPos, vec4( 0.0, 0.0, 1.0, clipNear - 0.5 ) );\n}\nfloat calcClip( vec3 cameraPos ){\nreturn calcClip( vec4( cameraPos, 1.0 ) );\n}\nfloat calcDepth( in vec3 cameraPos ){\nvec2 clipZW = cameraPos.z * projectionMatrix[2].zw + projectionMatrix[3].zw;\nreturn 0.5 + 0.5 * clipZW.x / clipZW.y;\n}\nstruct Ray {\nvec3 origin ;\nvec3 direction ;\n};\nbool cutoff_plane (vec3 M, vec3 cutoff, vec3 x3){\nfloat a = x3.x;\nfloat b = x3.y;\nfloat c = x3.z;\nfloat d = -x3.x*cutoff.x-x3.y*cutoff.y-x3.z*cutoff.z;\nfloat l = a*M.x+b*M.y+c*M.z+d;\nif (l<0.0) {return true;}\nelse{return false;}\n}\nvec3 isect_surf(Ray r, mat4 matrix_coef){\nvec4 direction = vec4(r.direction, 0.0);\nvec4 origin = vec4(r.origin, 1.0);\nfloat a = dot(direction,(matrix_coef*direction));\nfloat b = dot(origin,(matrix_coef*direction));\nfloat c = dot(origin,(matrix_coef*origin));\nfloat delta =b*b-a*c;\ngl_FragColor.a = 1.0;\nif (delta<0.0){\ndiscard;\n}\nfloat t1 =(-b-sqrt(delta))/a;\nreturn r.origin+t1*r.direction;\n}\nvec3 isect_surf2(Ray r, mat4 matrix_coef){\nvec4 direction = vec4(r.direction, 0.0);\nvec4 origin = vec4(r.origin, 1.0);\nfloat a = dot(direction,(matrix_coef*direction));\nfloat b = dot(origin,(matrix_coef*direction));\nfloat c = dot(origin,(matrix_coef*origin));\nfloat delta =b*b-a*c;\ngl_FragColor.a = 1.0;\nif (delta<0.0){\ndiscard;\n}\nfloat t2 =(-b+sqrt(delta))/a;\nreturn r.origin+t2*r.direction;\n}\nRay primary_ray(vec4 near1, vec4 far1){\nvec3 near=near1.xyz/near1.w;\nvec3 far=far1.xyz/far1.w;\nreturn Ray(near,far-near);\n}\nfloat update_z_buffer(vec3 M, mat4 ModelViewP){\nfloat depth1;\nvec4 Ms=(ModelViewP*vec4(M,1.0));\nreturn depth1=(1.0+Ms.z/Ms.w)/2.0;\n}\nvoid main(){\nfloat radius = max( vRadius, vRadius2 );\nvec4 i_near, i_far, focus;\nvec3 e3, e1, e1_temp, e2;\ni_near = vec4(matrix_near[0][0],matrix_near[0][1],matrix_near[0][2],matrix_near[0][3]);\ni_far = vec4(matrix_near[1][0],matrix_near[1][1],matrix_near[1][2],matrix_near[1][3]);\nfocus = vec4(matrix_near[2][0],matrix_near[2][1],matrix_near[2][2],matrix_near[2][3]);\ne3 = vec3(matrix_near[3][0],matrix_near[3][1],matrix_near[3][2]);\ne1.x = 1.0;\ne1.y = 1.0;\ne1.z = ( (e3.x*focus.x + e3.y*focus.y + e3.z*focus.z) - e1.x*e3.x - e1.y*e3.y)/e3.z;\ne1_temp = e1 - focus.xyz;\ne1 = normalize(e1_temp);\ne2 = normalize(cross(e1,e3));\nvec4 equation = focus;\nfloat shrinkfactor = shrink;\nfloat t1 = -1.0/(1.0-shrinkfactor);\nfloat t2 = 1.0/(shrinkfactor);\nvec4 colonne1, colonne2, colonne3, colonne4;\nmat4 mat;\nvec3 equation1 = vec3(t2,t2,t1);\nfloat A1 = - e1.x*equation.x - e1.y*equation.y - e1.z*equation.z;\nfloat A2 = - e2.x*equation.x - e2.y*equation.y - e2.z*equation.z;\nfloat A3 = - e3.x*equation.x - e3.y*equation.y - e3.z*equation.z;\nfloat A11 = equation1.x*e1.x*e1.x + equation1.y*e2.x*e2.x + equation1.z*e3.x*e3.x;\nfloat A21 = equation1.x*e1.x*e1.y + equation1.y*e2.x*e2.y + equation1.z*e3.x*e3.y;\nfloat A31 = equation1.x*e1.x*e1.z + equation1.y*e2.x*e2.z + equation1.z*e3.x*e3.z;\nfloat A41 = equation1.x*e1.x*A1 + equation1.y*e2.x*A2 + equation1.z*e3.x*A3;\nfloat A22 = equation1.x*e1.y*e1.y + equation1.y*e2.y*e2.y + equation1.z*e3.y*e3.y;\nfloat A32 = equation1.x*e1.y*e1.z + equation1.y*e2.y*e2.z + equation1.z*e3.y*e3.z;\nfloat A42 = equation1.x*e1.y*A1 + equation1.y*e2.y*A2 + equation1.z*e3.y*A3;\nfloat A33 = equation1.x*e1.z*e1.z + equation1.y*e2.z*e2.z + equation1.z*e3.z*e3.z;\nfloat A43 = equation1.x*e1.z*A1 + equation1.y*e2.z*A2 + equation1.z*e3.z*A3;\nfloat A44 = equation1.x*A1*A1 + equation1.y*A2*A2 + equation1.z*A3*A3 - equation.w;\ncolonne1 = vec4(A11,A21,A31,A41);\ncolonne2 = vec4(A21,A22,A32,A42);\ncolonne3 = vec4(A31,A32,A33,A43);\ncolonne4 = vec4(A41,A42,A43,A44);\nmat = mat4(colonne1,colonne2,colonne3,colonne4);\nRay ray = primary_ray(i_near,i_far) ;\nvec3 M;\nM = isect_surf(ray, mat);\nif (cutoff_plane(M, prime1.xyz, -e3) || cutoff_plane(M, prime2.xyz, e3)){ discard; }\nvec4 M1 = vec4(M,1.0);\nvec4 M2 = mat*M1;\nvec3 _normal = ( modelViewMatrixInverseTranspose * M2 ).xyz;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix) ;\n#ifdef NEAR_CLIP\nif( calcClip( modelViewMatrix * vec4( M, 1.0 ) ) > 0.0 ){\nM = isect_surf2(ray, mat);\nif( calcClip( modelViewMatrix * vec4( M, 1.0 ) ) > 0.0 )\ndiscard;\ninterior = true;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix) ;\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( clipNear - 0.5 ) ) ) + ( 0.0000001 / radius ) );\n}\n}else if( gl_FragDepthEXT <= 0.0 ){\nM = isect_surf2(ray, mat);\ninterior = true;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix);\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / radius );\n}\n}\n#else\nif( gl_FragDepthEXT <= 0.0 ){\nM = isect_surf2(ray, mat);\ninterior = true;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix) ;\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / radius );\n}\n}\n#endif\nif (cutoff_plane(M, prime1.xyz, -e3) || cutoff_plane(M, prime2.xyz, e3)){ discard; }\nif (gl_FragDepthEXT < 0.0)\ndiscard;\nif (gl_FragDepthEXT > 1.0)\ndiscard;\nfloat distance_ratio = ((M.x-prime2.x)*e3.x + (M.y-prime2.y)*e3.y +(M.z-prime2.z)*e3.z) /\ndistance(prime2.xyz,prime1.xyz);\n#ifdef PICKING\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 vViewPosition = -( modelViewMatrix * vec4( M, 1.0 ) ).xyz;\nvec3 vNormal = _normal;\nvec3 vColor;\nif( distance_ratio>0.5 ){\nvColor = vColor1;\n}else{\nvColor = vColor2;\n}\nvec4 diffuseColor = vec4( diffuse, opacity );\nReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\nvec3 totalEmissiveLight = emissive;\n#include color_fragment\n#include roughnessmap_fragment\n#include metalnessmap_fragment\nvec3 normal = normalize( vNormal );\nvec3 geometryNormal = normal;\n#include lights_physical_fragment\n#include lights_fragment_begin\n#include lights_fragment_end\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\nif( interior ){\n#ifdef USE_INTERIOR_COLOR\noutgoingLight.xyz = interiorColor;\n#else\n#ifdef DIFFUSE_INTERIOR\noutgoingLight.xyz = vColor;\n#endif\n#endif\noutgoingLight.xyz *= 1.0 - interiorDarkening;\n}\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");const dh=new Float32Array([-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,-1,1,-1,1,1,-1,1,1,1,-1,1,1]),mh=new Uint16Array([0,1,2,0,2,3,1,5,6,1,6,2,4,6,5,4,7,6,0,7,4,0,3,7,0,5,1,0,4,5,3,2,6,3,6,7]);class ph extends Pa{constructor(e,t={}){super("v3",e,t)}get mapping(){return dh}get mappingIndices(){return mh}get mappingIndicesSize(){return 36}get mappingSize(){return 8}get mappingItemSize(){return 3}}const fh=Object.assign({shrink:.14},Mn),gh=Object.assign({shrink:{uniform:!0}},Dn);class yh extends ph{constructor(e,i={}){super(e,i),this.parameterTypes=gh,this.isImpostor=!0,this.vertexShader="HyperballStickImpostor.vert",this.fragmentShader="HyperballStickImpostor.frag",this.addUniforms({modelViewProjectionMatrix:{value:new t.Matrix4},modelViewProjectionMatrixInverse:{value:new t.Matrix4},modelViewMatrixInverseTranspose:{value:new t.Matrix4},shrink:{value:this.parameters.shrink}}),this.addAttributes({position1:{type:"v3",value:null},position2:{type:"v3",value:null},color2:{type:"c",value:null},radius:{type:"f",value:null},radius2:{type:"f",value:null}}),this.setAttributes(e),this.makeMapping()}get defaultParameters(){return fh}}Object.assign({disableImpostor:!1},Rl,fh);const bh=class{constructor(e,t={}){return!De||t&&t.disableImpostor?(e.radius=function(e,t){const i=e.length,r=new Float32Array(i);for(let s=0;sa.push(r.atomLabel(e)))))}else if("residue"===this.labelGrouping){t&&!t.position||(c=[]),t&&!t.color||(h=[]),t&&!t.radius||(l=[]),t&&!t.text||(a=[]),i.colorParams&&(i.colorParams.structure=e.getStructure());const u=Ee.getScheme(i.colorParams),d=new ro(i.radiusParams),m=e.getAtomProxy();let p=0;e.eachResidue((e=>{const i=3*p;e.isProtein()||e.isNucleic()?(m.index=e.traceAtomIndex,t&&!t.position||m.positionToArray(c,i)):(m.index=e.atomOffset,t&&!t.position||e.positionToArray(c,i)),t&&!t.color||u.atomColorToArray(m,h,i),t&&!t.radius||(l[p]=d.atomRadius(m)),t&&!t.text||a.push(r.atomLabel(m)),++p})),t&&!t.position||(s=new Float32Array(c)),t&&!t.color||(o=new Float32Array(h)),t&&!t.radius||(n=new Float32Array(l))}return{position:s,size:n,color:o,text:a}}createData(e){return{bufferList:[new Sl(this.getTextData(e,{position:!0,color:!0,radius:!0,text:!0}),this.getBufferParams({fontFamily:this.fontFamily,fontStyle:this.fontStyle,fontWeight:this.fontWeight,xOffset:this.xOffset,yOffset:this.yOffset,zOffset:this.zOffset,attachment:this.attachment,showBorder:this.showBorder,borderColor:this.borderColor,borderWidth:this.borderWidth,showBackground:this.showBackground,backgroundColor:this.backgroundColor,backgroundMargin:this.backgroundMargin,backgroundOpacity:this.backgroundOpacity,fixedSize:this.fixedSize}))]}}updateData(e,t){t.bufferList[0].setAttributes(this.getTextData(t.sview,e))}getAtomRadius(){return 0}}function Ah(e){const t=e.getAtomSet(),i=e.getBondSet(),r=e.getBondProxy();return i.forEach((function(e){r.index=e,t.clear(r.atomIndex1),t.clear(r.atomIndex2)})),t}Ne.add("label",wh);class _h extends dl{constructor(e,t,i){super(e,t,i),this.type="line",this.parameters=Object.assign({multipleBond:{type:"select",rebuild:!0,options:{off:"off",symmetric:"symmetric",offset:"offset"}},bondSpacing:{type:"number",precision:2,max:2,min:.5},linewidth:{type:"integer",max:50,min:1,buffer:!0},lines:{type:"boolean",rebuild:!0},crosses:{type:"select",rebuild:!0,options:{off:"off",lone:"lone",all:"all"}},crossSize:{type:"number",precision:2,max:2,min:.1}},this.parameters,{flatShaded:null,side:null,wireframe:null,roughness:null,metalness:null}),this.init(i)}init(e){var t=e||{};this.multipleBond=l(t.multipleBond,"off"),this.bondSpacing=l(t.bondSpacing,1),this.linewidth=l(t.linewidth,2),this.lines=l(t.lines,!0),this.crosses=l(t.crosses,"lone"),this.crossSize=l(t.crossSize,.4),super.init(t)}getAtomRadius(e){return.1}getBondParams(e,t){return t=Object.assign({multipleBond:this.multipleBond,bondSpacing:this.bondSpacing,radiusParams:{type:"size",size:.1,scale:1}},t),super.getBondParams(e,t)}_crossData(e,t){if(e&&!e.position&&!e.color)return;const i={};"lone"===this.crosses&&Object.assign(i,{atomSet:Ah(t)});const r=t.getAtomData(this.getAtomParams(e,i)),s={},n=r.position,o=r.color,a=r.picking,c=(n||o).length,l=3*c;let h=new Float32Array(0),u=new Float32Array(0),d=new Float32Array(0),m=new Float32Array(0),p=0,f=new Float32Array(0);e&&!e.position||(h=s.position1=new Float32Array(l),u=s.position2=new Float32Array(l),p=this.crossSize/2),e&&!e.color||(d=s.color=new Float32Array(l),m=s.color2=new Float32Array(l)),e&&!e.picking||(f=new Float32Array(3*r.picking.array.length));for(let t=0;tl?d[f]=-1:(c=Math.sqrt(l-a),d[f]=Math.floor(c)),++f;p[g]=u,m[g]=d}}function k(i){var r,s,n,a,u,f,b,v,w,A,S,C,P,I,k,M,D,T,B=3*i,R=i;r=Math.floor(.5+o*(e[B]+d[0])),s=Math.floor(.5+o*(e[B+1]+d[1])),n=Math.floor(.5+o*(e[B+2]+d[2]));var O,$=t[R],F=m[$],E=0,L=l*h,N=p[$];for(A=0;A=c||I>=l||k>=h)){var z=P*L+I*h+k;if(g)if(y[z]&_){if(y[z]&_){var V=x[z];V!==B&&b*b+v*v+w*w<(a=r+b-Math.floor(.5+o*(e[V]+d[0])))*a+(u=s+v-Math.floor(.5+o*(e[V+1]+d[1])))*u+(f=n+w-Math.floor(.5+o*(e[V+2]+d[2])))*f&&(x[z]=i)}}else y[z]|=_,x[z]=i;else y[z]|=_}E++}}function M(t){var i,r;for(console.time("EDTSurface fillvoxels"),i=0,r=y.length;i=c||_>=l||C>=h)){var L=A*E+_*h+C;if(y[L]&S){if(g){var N=x[L];b*b+v*v+w*w<(a=Math.floor(.5+o*(e[N]+d[0])))*a+(u=Math.floor(.5+o*(e[N+1]+d[1])))*u+(f=Math.floor(.5+o*(e[N+2]+d[2])))*f&&(x[L]=i)}}else y[L]|=S,g&&(x[L]=i)}$++}}function T(){var e,t,i,r;console.time("EDTSurface fastdistancemap");var s,n=Sh(c,l,h,Uint16Array,3),o=l*h,u=f*f,d=0;for(e=0;e0);var A,P=a*a,I=new Uint16Array(3);for(e=0;e=P)||(y[s]|=C,g&&y[s]&S&&(n.toArray(e,t,i,I),A=I[0]*o+I[1]*h+I[2],x[s]=x[A])));console.timeEnd("EDTSurface fastdistancemap")}function B(e,t,i,r){var s,n,o,a,u,d,m,p,f,g,x,v,w=new Uint16Array(3),A=0;if(0===i)return A;var I=-1,k=-1,M=-1,D=l*h;for(m=0,f=i;m-1&&k-1&&M-1&&(y[x=I*D+h*k+M]&_&&!(y[x]&S)?(t.fromArray(I,k,M,w),g=(a=I-w[0])*a+(u=k-w[1])*u+(d=M-w[2])*d,b[x]=g,y[x]|=S,y[x]|=C,r[A]=I,r[A+1]=k,r[A+2]=M,A+=3):y[x]&_&&y[x]&S&&(g=(a=I-w[0])*a+(u=k-w[1])*u+(d=M-w[2])*d)-1&&k-1&&M-1&&(y[x=I*D+h*k+M]&_&&!(y[x]&S)?(t.fromArray(I,k,M,w),g=(a=I-w[0])*a+(u=k-w[1])*u+(d=M-w[2])*d,b[x]=g,y[x]|=S,y[x]|=C,r[A]=I,r[A+1]=k,r[A+2]=M,A+=3):y[x]&_&&y[x]&S&&(g=(a=I-w[0])*a+(u=k-w[1])*u+(d=M-w[2])*d)-1&&k-1&&M-1&&(y[x=I*D+h*k+M]&_&&!(y[x]&S)?(t.fromArray(I,k,M,w),g=(a=I-w[0])*a+(u=k-w[1])*u+(d=M-w[2])*d,b[x]=g,y[x]|=S,y[x]|=C,r[A]=I,r[A+1]=k,r[A+2]=M,A+=3):y[x]&_&&y[x]&S&&(g=(a=I-w[0])*a+(u=k-w[1])*u+(d=M-w[2])*d)-1&&o-1&&u-1&&aD&&(D=O)}return{neighbourListLength:27*D+1,withinRadii:function(s,n,o,a,u){for(var d=0,m=p(s,c),f=p(n,l),g=p(o,h),y=Math.max(0,m-1),w=Math.max(0,f-1),_=Math.max(0,g-1),S=Math.min(b,m+2),C=Math.min(x,f+2),M=Math.min(v,g+2),D=y;Dm&&(m=u[e]);!function(){const e=An(c,h,m,f,0);f=e.scaleFactor,b=e.dim,x=e.matrix,O=Math.max(5,2+Math.floor(p*f)),v=yt(b[0]*b[1]*b[2],-1001),w=new Int32Array(v.length),A=new Float32Array(b[0]),_=new Float32Array(b[1]),S=new Float32Array(b[2]),F(A,c[0],1/f),F(_,c[1],1/f),F(S,c[2],1/f)}(),function(){var e=0,t=2*Math.PI/y;P=new Float32Array(y),C=new Float32Array(y);for(var i=0;i=0;){if(n!==r&&n!==s&&L(n,e,t,i))return M=n,n;n=k[++o]}return M=-1,-1}function L(t,i,r,s){var n=3*t,o=d[t],a=e[n]-i,c=e[n+1]-r,l=e[n+2]-s;return a*a+c*c+l*l0&&d=0;)e{t(this._makeSurface(e.data.sd,i))}),(e=>{console.warn("MolecularSurface.getSurfaceWorker error - trying without worker",e),this.worker.terminate(),this.worker=void 0;const r=this.getSurface(i);t(r)}))}else{const e=this.getSurface(i);t(e)}}dispose(){this.worker&&this.worker.terminate()}}class Mh extends dl{constructor(e,t,i){super(e,t,i),this.type="surface",this.parameters=Object.assign({surfaceType:{type:"select",rebuild:!0,options:{vws:"vws",sas:"sas",ms:"ms",ses:"ses",av:"av"}},probeRadius:{type:"number",precision:1,max:20,min:0,rebuild:!0},smooth:{type:"integer",precision:1,max:10,min:0,rebuild:!0},scaleFactor:{type:"number",precision:1,max:5,min:0,rebuild:!0},cutoff:{type:"number",precision:2,max:50,min:0,rebuild:!0},contour:{type:"boolean",rebuild:!0},background:{type:"boolean",rebuild:!0},opaqueBack:{type:"boolean",buffer:!0},filterSele:{type:"text",rebuild:!0},colorVolume:{type:"hidden"},useWorker:{type:"boolean",rebuild:!0}},this.parameters,{radius:null,scale:null}),this.__infoList=[],this.structure.signals.refreshed.add((()=>{this.__forceNewMolsurf=!0})),this.toBePrepared=!0,this.init(i)}init(e){const t=e||{};t.colorScheme=l(t.colorScheme,"uniform"),t.colorValue=l(t.colorValue,14540253),t.disablePicking=l(t.disablePicking,!0),this.surfaceType=l(t.surfaceType,"ms"),this.probeRadius=l(t.probeRadius,1.4),this.smooth=l(t.smooth,2),this.scaleFactor=l(t.scaleFactor,2),this.cutoff=l(t.cutoff,0),this.contour=l(t.contour,!1),this.background=l(t.background,!1),this.opaqueBack=l(t.opaqueBack,!0),this.filterSele=l(t.filterSele,""),this.colorVolume=l(t.colorVolume,void 0),this.useWorker=l(t.useWorker,!0),super.init(e)}prepareData(e,i,r){let s=this.__infoList[i];if(s||(s={},this.__infoList[i]=s),s.molsurf&&s.sele===e.selection.string)r(i);else{if(this.filterSele){const s=e.structure.getView(new ye(this.filterSele)),n=s.boundingBox.getSize(new t.Vector3),o=Math.max(n.x,n.y,n.z),a=e.getAtomSetWithinPoint(s.center,o/2+6);if(0===(e=e.getView(new ye(e.getAtomSetWithinSelection(a,3).toSeleString()))).atomCount)return void r(i)}s.sele=e.selection.string,s.molsurf=new kh(e);const n=this.getSurfaceParams(),o=e=>{s.surface=e,r(i)};this.useWorker?s.molsurf.getSurfaceWorker(n,o):o(s.molsurf.getSurface(n))}}prepare(e){if((this.__forceNewMolsurf||this.__sele!==this.selection.string||this.__surfaceParams!==JSON.stringify(this.getSurfaceParams()))&&(this.__infoList.forEach((e=>{e&&e.molsurf&&e.molsurf.dispose()})),this.__infoList.length=0),0===this.structureView.atomCount)return void e();const t=()=>{this.__sele=this.selection.string,this.__surfaceParams=JSON.stringify(this.getSurfaceParams()),this.__forceNewMolsurf=!1,e()},i="default"===this.assembly?this.defaultAssembly:this.assembly,r=this.structure.biomolDict[i];r?r.partList.forEach(((e,i)=>{const s=e.getView(this.structureView);this.prepareData(s,i,(e=>{e===r.partList.length-1&&t()}))})):this.prepareData(this.structureView,0,t)}createData(e,t){const i=this.__infoList[t],r=i.surface;if(!r)return;const s={position:r.getPosition(),color:r.getColor(this.getColorParams()),index:r.getFilteredIndex(this.filterSele,e)},n=[];if(r.contour){const e=new En(s,this.getBufferParams({wireframe:!1}));n.push(e)}else{Object.assign(s,{normal:r.getNormal(),picking:r.getPicking(e.getStructure())});const t=new Rn(s,this.getBufferParams({background:this.background,opaqueBack:this.opaqueBack,dullInterior:!1}));if("double"==this.getBufferParams().side){const e=new Fn(t);n.push(e)}else n.push(t)}return{bufferList:n,info:i}}updateData(e,t){const i={};if(e.position||e.radius)return this.__forceNewMolsurf=!0,void this.build();e.color&&(i.color=t.info.surface.getColor(this.getColorParams())),e.index&&(i.index=t.info.surface.getFilteredIndex(this.filterSele,t.sview)),t.bufferList[0].setAttributes(i)}setParameters(e,t={},i){return e&&e.filterSele&&(t.index=!0),e&&void 0!==e.colorVolume&&(t.color=!0),e&&e.wireframe&&(e.contour||void 0===e.contour&&this.contour)&&(e.wireframe=!1),super.setParameters(e,t,i),this}getSurfaceParams(e={}){return Object.assign({type:this.surfaceType,probeRadius:this.probeRadius,scaleFactor:this.scaleFactor,smooth:this.smooth&&!this.contour,cutoff:this.cutoff,contour:this.contour,useWorker:this.useWorker,radiusParams:this.getRadiusParams()},e)}getColorParams(){const e=super.getColorParams();return e.volume=this.colorVolume,e}getAtomRadius(){return 0}clear(){super.clear()}dispose(){this.__infoList.forEach((e=>{e&&e.molsurf&&e.molsurf.dispose()})),this.__infoList.length=0,super.dispose()}}Ne.add("surface",Mh);class Dh extends dl{constructor(e,t,i){super(e,t,i),this.type="point",this.parameters=Object.assign({pointSize:{type:"number",precision:1,max:100,min:0,buffer:!0},sizeAttenuation:{type:"boolean",buffer:!0},sortParticles:{type:"boolean",rebuild:!0},useTexture:{type:"boolean",buffer:!0},alphaTest:{type:"range",step:.001,max:1,min:0,buffer:!0},forceTransparent:{type:"boolean",buffer:!0},edgeBleach:{type:"range",step:.001,max:1,min:0,buffer:!0}},this.parameters,{flatShaded:null,wireframe:null,linewidth:null,side:null,roughness:null,metalness:null}),this.init(i)}init(e){var t=e||{};this.pointSize=l(t.pointSize,1),this.sizeAttenuation=l(t.sizeAttenuation,!0),this.sortParticles=l(t.sortParticles,!1),this.useTexture=l(t.useTexture,!1),this.alphaTest=l(t.alphaTest,.5),this.forceTransparent=l(t.forceTransparent,!1),this.edgeBleach=l(t.edgeBleach,0),super.init(t)}createData(e){var t=e.getAtomData(this.getAtomParams({position:!0,color:!0,picking:!0}));return{bufferList:[new $a(t,this.getBufferParams({pointSize:this.pointSize,sizeAttenuation:this.sizeAttenuation,sortParticles:this.sortParticles,useTexture:this.useTexture,alphaTest:this.alphaTest,forceTransparent:this.forceTransparent,edgeBleach:this.edgeBleach}))]}}updateData(e,t){var i=t.sview.getAtomData(this.getAtomParams(e)),r={};e&&!e.position||Object.assign(r,{position:i.position}),e&&!e.color||Object.assign(r,{color:i.color}),t.bufferList[0].setAttributes(r)}getAtomRadius(){return.1}}Ne.add("point",Dh),Ve.add("shader/Ribbon.vert","#define STANDARD\nuniform float clipNear;\nuniform vec3 clipCenter;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvarying vec3 vViewPosition;\n#endif\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\nattribute vec3 dir;\nattribute float size;\n#ifdef PICKING\n#include unpack_color\nattribute float primitiveId;\nvarying vec3 vPickingColor;\n#else\n#include color_pars_vertex\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\n#endif\n#include common\nvoid main(void){\n#ifdef PICKING\nvPickingColor = unpackColor( primitiveId );\n#else\n#include color_vertex\n#include beginnormal_vertex\n#include defaultnormal_vertex\n#ifndef FLAT_SHADED\nvNormal = normalize( transformedNormal );\n#endif\n#endif\n#include begin_vertex\ntransformed += normalize( dir ) * size;\n#include project_vertex\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvViewPosition = -mvPosition.xyz;\n#endif\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n#include nearclip_vertex\n}");const Th=new Uint16Array([0,1,2,1,3,2]);function Bh(e){return 3*(4*(e.position.length/3-1))}class Rh extends Bn{constructor(e,t={}){super({position:new Float32Array(Bh(e)),color:new Float32Array(Bh(e)),index:A(Bh(e),Bh(e)/3),normal:new Float32Array(Bh(e)),picking:e.picking},t),this.vertexShader="Ribbon.vert";const i=e.position.length/3-1,r=4*i,s=3*r;this.addAttributes({dir:{type:"v3",value:new Float32Array(s)}}),this.addAttributes({size:{type:"f",value:new Float32Array(r)}}),e.primitiveId=xt(i),this.setAttributes(e),this.makeIndex()}setAttributes(e={}){const t=this.size/4,i=this.geometry.attributes;let r,s,n,o,a,c,l,h,u,d,m,p,f,g,y,b,x,v,w;e.position&&(r=e.position,l=i.position.array,i.position.needsUpdate=!0),e.normal&&(s=e.normal,h=i.normal.array,i.normal.needsUpdate=!0),e.size&&(n=e.size,u=i.size.array,i.size.needsUpdate=!0),e.dir&&(o=e.dir,d=i.dir.array,i.dir.needsUpdate=!0),e.color&&(a=e.color,m=i.color.array,i.color.needsUpdate=!0),e.primitiveId&&(c=e.primitiveId,p=i.primitiveId.array,i.primitiveId.needsUpdate=!0);let A=n?n[0]:null;for(f=0;f{if(!(e.residueCount<4)){i.push(e);var r=new Xl(e,this.getSplineParams()),s=r.getSubdividedPosition(),n=r.getSubdividedOrientation(),o=r.getSubdividedColor(this.getColorParams()),a=r.getSubdividedPicking(),c=r.getSubdividedSize(this.getRadiusParams());t.push(new Rh({position:s.position,normal:n.binormal,dir:n.normal,color:o.color,size:c.size,picking:a.picking},this.getBufferParams()))}}),e.getSelection()),{bufferList:t,polymerList:i}}updateData(e,t){e=e||{};var i=0,r=t.polymerList.length;for(i=0;i{if(e.residueCount<4||e.isNucleic())return;const s=new go(e),n=s.getAxis(this.localAngle,this.centerDist,this.ssBorder,this.getColorParams(),this.getRadiusParams());t+=n.size.length,i.push(n),r.push(s)}),e.getSelection());const s={begin:new Float32Array(3*t),end:new Float32Array(3*t),size:new Float32Array(t),color:new Float32Array(3*t),picking:{}};let n=new Float32Array(t),o=0;i.forEach((function(e){s.begin.set(e.begin,3*o),s.end.set(e.end,3*o),s.size.set(e.size,o),s.color.set(e.color,3*o),n.set(e.picking.array,o),o+=e.size.length})),t&&(s.picking=new Ls(n,e.getStructure()));return{bufferList:[new Gl({position1:s.begin,position2:s.end,color:s.color,color2:s.color,radius:s.size,picking:s.picking},this.getBufferParams({openEnded:this.openEnded,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0}))],axisList:i,helixbundleList:r,axisData:s}}updateData(e,t){if((e=e||{}).position)this.build();else{var i={};if(e.color||e.radius){var r=0;t.helixbundleList.forEach((i=>{var s=i.getAxis(this.localAngle,this.centerDist,this.ssBorder,this.getColorParams(),this.getRadiusParams());e.color&&t.axisData.color.set(s.color,3*r),(e.radius||e.scale)&&t.axisData.size.set(s.size,r),r+=s.size.length})),e.color&&Object.assign(i,{color:t.axisData.color,color2:t.axisData.color}),(e.radius||e.scale)&&Object.assign(i,{radius:t.axisData.size})}t.bufferList[0].setAttributes(i)}}}Ne.add("rocket",$h);class Fh extends Jl{constructor(e,t,i){super(e,t,i),this.type="rope",this.parameters=Object.assign({smooth:{type:"integer",max:15,min:0,rebuild:!0}},this.parameters,{aspectRatio:null,smoothSheet:null})}init(e){var t=e||{};t.aspectRatio=1,t.tension=l(t.tension,.5),t.radiusScale=l(t.radiusScale,5),t.smoothSheet=!1,this.smooth=l(t.smooth,2),super.init(t)}getSpline(e){var t=new fo(e);return new Xl(e,this.getSplineParams({directional:!1,positionIterator:t.getCenterIterator(this.smooth)}))}}Ne.add("rope",Fh);class Eh extends dl{constructor(e,t,i){super(e,t,i),this.type="spacefill",this.parameters=Object.assign({sphereDetail:!0,disableImpostor:!0},this.parameters),this.init(i)}init(e){var t=e||{};t.useInteriorColor=l(t.useInteriorColor,!0),super.init(t)}createData(e){return{bufferList:[new Ta(e.getAtomData(this.getAtomParams()),this.getBufferParams({sphereDetail:this.sphereDetail,dullInterior:!0,disableImpostor:this.disableImpostor}))]}}updateData(e,t){var i=t.sview.getAtomData(this.getAtomParams(e)),r={};e&&!e.position||Object.assign(r,{position:i.position}),e&&!e.color||Object.assign(r,{color:i.color}),e&&!e.radius||Object.assign(r,{radius:i.radius}),t.bufferList[0].setAttributes(r)}}function Lh(e){return 3*(e.position.length/3-1)*2}Ne.add("spacefill",Eh);class Nh extends Tn{constructor(e,t={}){super({position:new Float32Array(Lh(e)),color:new Float32Array(Lh(e))},t),this.isLine=!0,this.vertexShader="Line.vert",this.fragmentShader="Line.frag",this.setAttributes(e)}setAttributes(e){let t,i,r,s;const n=this.geometry.attributes;if(e.position&&(t=e.position,r=n.position.array,n.position.needsUpdate=!0),e.color&&(i=e.color,s=n.color.array,n.color.needsUpdate=!0),!t&&!i)return void Be.warn("TraceBuffer.prototype.setAttributes no data");let o,a;const c=this.size-1;for(let e=0;e{if(!(e.residueCount<4)){i.push(e);var r=new Xl(e,this.getSplineParams()),s=r.getSubdividedPosition(),n=r.getSubdividedColor(this.getColorParams());t.push(new Nh(Object.assign({},s,n),this.getBufferParams()))}}),e.getSelection()),{bufferList:t,polymerList:i}}updateData(e,t){e=e||{};var i=0,r=t.polymerList.length;for(i=0;i{e.boundingBox||e.computeBoundingBox(),this.boundingBox.union(e.boundingBox)}))}}const Zh=Object.assign({aspectRatio:1.5,radialSegments:50,openEnded:!1,disableImpostor:!1},Mn);class Qh{constructor(e,i={}){this.group=new t.Group,this.wireframeGroup=new t.Group,this.pickingGroup=new t.Group,this.visible=!0,this.parameters=h(i,this.defaultParameters),this.splitPosition=new Float32Array(e.position1.length),this.cylinderRadius=new Float32Array(e.radius.length);const r=this.makeAttributes(e),s={radialSegments:this.parameters.radialSegments,openEnded:this.parameters.openEnded,disableImpostor:this.parameters.disableImpostor};this.cylinderBuffer=new Gl(r.cylinder,s),this.coneBuffer=new Yh(r.cone,s),this.geometry=new Kh([this.cylinderBuffer.geometry,this.coneBuffer.geometry]),this.matrix=l(i.matrix,new t.Matrix4),this.picking=e.picking}get defaultParameters(){return Zh}set matrix(e){Tn.prototype.setMatrix.call(this,e)}get matrix(){return this.group.matrix.clone()}get pickable(){return!!this.picking}makeAttributes(e={}){const i=this.splitPosition,r=this.cylinderRadius,s=this.parameters.aspectRatio;let n,o;const a={},c={};if(e.radius){for(n=0,o=r.length;n(this._beforeParse(),this._parse(),this._afterParse(),this[this.__objName])))}_parse(){}_beforeParse(){}_afterParse(){e.Debug&&Be.log(this[this.__objName])}}class Iu extends Pu{constructor(e,t){var i=t||{};super(e,i),this.firstModelOnly=l(i.firstModelOnly,!1),this.asTrajectory=l(i.asTrajectory,!1),this.cAlphaOnly=l(i.cAlphaOnly,!1),this.structure=new pa(this.name,this.path),this.structureBuilder=new Do(this.structure)}get type(){return"structure"}get __objName(){return"structure"}}class ku{constructor(e,t,i="",r,s=[]){this.structure=e,this.index=t,this.description=i,this.entityType=function(e){switch(e=e.toLowerCase()){case"polymer":return 1;case"non-polymer":return 2;case"macrolide":return 3;case"water":return 4;default:return 0}}(r||""),this.chainIndexList=s,s.forEach((function(i){e.chainStore.entityIndex[i]=t}))}get type(){return function(e){switch(e){case 1:return"polymer";case 2:return"non-polymer";case 3:return"macrolide";case 4:return"water";default:return}}(this.entityType)}getEntityType(){return this.entityType}isPolymer(){return 1===this.entityType}isNonPolymer(){return 2===this.entityType}isMacrolide(){return 3===this.entityType}isWater(){return 4===this.entityType}eachChain(e){const t=this.structure.getChainProxy();this.chainIndexList.forEach((function(i){t.index=i,e(t)}))}}const Mu={a:1,b:1,c:1,alpha:90,beta:90,gamma:90,spacegroup:"P 1"};class Du{constructor(e=Mu){this.cartToFrac=new t.Matrix4,this.fracToCart=new t.Matrix4,this.a=e.a,this.b=e.b,this.c=e.c,this.alpha=e.alpha,this.beta=e.beta,this.gamma=e.gamma,this.spacegroup=e.spacegroup;const i=T(this.alpha),r=T(this.beta),s=T(this.gamma),n=Math.cos(i),o=Math.cos(r),a=Math.cos(s),c=Math.sin(r),l=Math.sin(s);if(this.volume=this.a*this.b*this.c*Math.sqrt(1-n*n-o*o-a*a+2*n*o*a),void 0===e.cartToFrac){const e=this.a*this.b*l/this.volume,t=(o*a-n)/(c*l);this.fracToCart.set(this.a,0,0,0,this.b*a,this.b*l,0,0,this.c*o,-this.c*c*t,1/e,0,0,0,0,1).transpose(),this.cartToFrac.getInverse(this.fracToCart)}else this.cartToFrac.copy(e.cartToFrac),this.fracToCart.getInverse(this.cartToFrac)}getPosition(e){const i=new Float32Array(24);if(e.unitcell){const r=e.unitcell,s=e.center.clone().applyMatrix4(r.cartToFrac).floor(),n=new t.Vector3;let o=0;const a=function(e,t,a){n.set(e,t,a).add(s).applyMatrix4(r.fracToCart).toArray(i,o),o+=3};a(0,0,0),a(1,0,0),a(0,1,0),a(0,0,1),a(1,1,0),a(1,0,1),a(0,1,1),a(1,1,1)}return i}getCenter(e){return function(e,i=new t.Vector3){const r=e.length;for(let t=0;t0)continue;let e,t,r,s,n,c=0;if(o){if(s=C.split(Ou),c=10===s.length?1:0,R=s[2],f&&"CA"!==R)continue;e=parseFloat(s[6-c]),t=parseFloat(s[7-c]),r=parseFloat(s[8-c])}else{if(R=C.substr(12,4).trim(),f&&"CA"!==R)continue;e=parseFloat(C.substr(30,8)),t=parseFloat(C.substr(38,8)),r=parseFloat(C.substr(46,8))}if(p){const i=3*x;if(b[i+0]=e,b[i+1]=t,b[i+2]=r,x+=1,v)continue}o?(I=parseInt(s[1]),n="",O="H"===C[0],k=c?"":s[4],M=parseInt(s[5-c]),B="",D=s[3],F="",T=1):(I=parseInt(C.substr(6,5),u),h&&99999===I&&(u=16),O="H"===C[0],k=C[21].trim(),M=parseInt(C.substr(22,4),d),h&&9999===M&&(d=16),B=C[26].trim(),D=C.substr(17,4).trim()||"MOL",$=parseFloat(C.substr(60,6)),F=C[16].trim(),T=parseFloat(C.substr(54,6)),i||(a?(n=C.substr(76,3).trim(),n in rs&&(n=rs[n])):(n=C.substr(76,2).trim(),k||(k=C.substr(72,4).trim())),E=parseInt((C.substr(79,1)+C.substr(78,1)).trim()))),de.growIfFull(),de.atomTypeId[fe]=ue.add(R,n),de.x[fe]=e,de.y[fe]=t,de.z[fe]=r,de.serial[fe]=I,de.altloc[fe]=F.charCodeAt(0),de.occupancy[fe]=isNaN(T)?0:T,o?(de.partialCharge[fe]=parseFloat(s[9-c]),de.radius[fe]=parseFloat(s[10-c])):(de.bfactor[fe]=isNaN($)?0:$,a&&(de.partialCharge[fe]=parseFloat(C.substr(70,6))),isFinite(E)&&(de.formalCharge||de.addField("formalCharge",1,"int8"),de.formalCharge[fe]=E));const y=$u(M,k,B);!O||Z[y]||Bu.includes(D)?te||ie===k||(J+=1,ee=J.toString()):ie===k&&se===D&&(Zr.includes(D)||re===M&&ne===B)||(J+=1,ee=J.toString(),re=M,se=D,ne=B),l.addAtom(ge,k,ee,D,M,O,void 0,B),j[I]=fe,fe+=1,te=!1,ie=k}else if("CONECT"===P){const e=j[parseInt(C.substr(6,5))],t=[11,16,21,26],i={};if(void 0===e)continue;for(let r=0;r<4;++r){let s=parseInt(C.substr(t[r],5));if(!Number.isNaN(s)&&(s=j[s],void 0!==s))if(e0)continue;const D=t[l].replace(Nu,"");if(k&&"CA"!==D)continue;const R=parseFloat(t[x]),O=parseFloat(t[v]),$=parseFloat(t[w]);if(I){const e=3*r;if(i[e+0]=R,i[e+1]=O,i[e+2]=$,r+=1,X>0)continue}const F=t[h],E=parseInt(t[-1!==a?a:c]);let L=t[b];L="?"===L?"":L;const N=t[o],z=t[u],V="H"===t[p][0],Y=t[g],K=parseFloat(t[A]),Z=parseFloat(t[_]);let Q=t[m];if(Q="."===Q?"":Q,H.growIfFull(),H.atomTypeId[q]=j.add(D,Y),H.x[q]=R,H.y[q]=O,H.z[q]=$,H.serial[q]=parseInt(t[f]),H.bfactor[q]=isNaN(K)?0:K,H.occupancy[q]=isNaN(Z)?0:Z,H.altloc[q]=Q.charCodeAt(0),C.addAtom(X,N,z,F,E,V,void 0,L),e.Debug){const t=T[z];void 0!==t&&t!==N&&e.Debug&&Be.warn(t,N)}T[z]=N;const J=t[d];B[J]||(B[J]=new Set),B[J].add(S.chainStore.count-1),q+=1}else{const e=n.match(Lu),t=e.length;N===L.length&&(N=0);for(let i=0;ic*c)return s.growIfFull(),s.atomTypeId[d]=s.atomTypeId[e],s.x[d]=l.x,s.y[d]=l.y,s.z[d]=l.z,s.occupancy[d]=s.occupancy[e],s.serial[d]=d,s.altloc[d]="A".charCodeAt(0),r.addAtom(0,"","","HET",1,!0),void(d+=1)}}}))}}(D,S,C),C.finalize(),S.finalizeAtoms(),Fo(S),S.finalizeBonds();else{var Y=function(e,t,i){var r,s,n,o,a=[],c=[],l=e.struct_conf;if(null==l?void 0:l.pdbx_PDB_helix_class)for(Gu(l,"id"),r=0,s=l.beg_auth_seq_id.length;r0){o=o.split("(");var l=c(o[0]),h=c(o[1]);Object.keys(l).forEach((function(e){Object.keys(h).forEach((function(i){var r=new t.Matrix4;r.multiplyMatrices(l[e],h[i]),s[e+"x"+i]=r}))}))}else s=c(o);var u=[];for(var d in s)u.push(s[d]);var m=e;/^(0|[1-9][0-9]*)$/.test(m)&&(m="BU"+m);for(var p=a.asym_id_list[i].split(","),f=0,g=p.length;f_){var S=A;A=_,_=S;var C=f;f=v,v=C}if(0!==A&&0!==_)for(var P=0;P<_;++P)o.index=f[P%A],a.index=v[P],o&&a?i.bondStore.addBond(o,a,Hu(s.pdbx_value_order[l])):Be.log("atoms for connection not found");else e.Debug&&Be.warn("no atoms found for",p,x)}}}}(D,S,T),function(e,t,i){if(e.entity){Gu(e.entity,"id");for(var r=e.entity,s=r.id.length,n=0;nx)continue}d=I.substr(5,5).trim(),m=parseInt(I.substr(0,5)),p=parseInt(I.substr(15,5)),w.growIfFull(),w.atomTypeId[A]=v.add(u),w.x[A]=D,w.y[A]=T,w.z[A]=B,w.serial[A]=p,s.addAtom(_,"","",d,m,!1,"l"),A+=1}}}(0,e.length,e)})),s.finalize(),r.finalizeAtoms(),$o(r),Fo(r),r.finalizeBonds(),Bo(r),e.Debug&&Be.timeEnd("GroParser._parse "+this.name)}});var qu=["mmtfVersion","mmtfProducer","unitCell","spaceGroup","structureId","title","depositionDate","releaseDate","experimentalMethods","resolution","rFree","rWork","bioAssemblyList","ncsOperatorList","entityList","groupList","numBonds","numAtoms","numGroups","numChains","numModels","groupsPerChain","chainsPerModel"].concat(["xCoordList","yCoordList","zCoordList","groupIdList","groupTypeList","chainIdList","bFactorList","atomIdList","altLocList","occupancyList","secStructList","insCodeList","sequenceIndexList","chainNameList","bondAtomList","bondOrderList"]);function Xu(e,t,i){return t?new e(t.buffer,t.byteOffset,t.byteLength/(i||1)):void 0}function Yu(e){return Xu(DataView,e)}function Ku(e){return Xu(Int8Array,e)}function Zu(e){return Xu(Int32Array,e,4)}function Qu(e,t){var i=e.length/2;t||(t=new Int16Array(i));for(var r=0,s=0;rn&&++a;t=new Int32Array(a)}for(i=0,r=0;is){for(var n=[],o=0;o0&&(a.biomolDict[e]=i)}const $=c.unitCell;$&&Array.isArray($)&&$[0]?a.unitcell=new Du({a:$[0],b:$[1],c:$[2],alpha:$[3],beta:$[4],gamma:$[5],spacegroup:c.spaceGroup}):a.unitcell=void 0,zo(a,!0),No(a,!0),a.finalizeAtoms(),a.finalizeBonds(),Vo(a),e.Debug&&Be.timeEnd("MmtfParser._parse "+this.name)}});const hd=/\s+/,ud={1:1,2:2,3:3,am:1,ar:1,du:1,un:1,nc:0};ze.add("mol2",class extends Iu{get type(){return"mol2"}_parse(){e.Debug&&Be.time("Mol2Parser._parse "+this.name);const t=this.structure,i=this.structureBuilder,r=this.firstModelOnly,s=this.asTrajectory,n=t.frames;let o,a,c=!1;const l=t.atomMap,h=t.atomStore;h.resize(Math.round(this.streamer.data.length/60)),h.addField("partialCharge",1,"float32");let u=0,d=0,m=0,p=-1,f=0,g=0;const y=t.getAtomProxy(),b=t.getAtomProxy();this.streamer.eachChunkOfLines((function(e){!function(e,x,v){for(let w=e;wMOLECULE"===e?(g=1,d=0,++p):"@ATOM"===e?(g=2,m=h.count,s&&(a=0,o=new Float32Array(3*f),n.push(o),p>0&&(c=!0))):g="@BOND"===e?3:0;else if(1===g){if(0===d)t.title=e,t.id=e;else if(1===d){const t=e.split(hd);f=parseInt(t[0])}++d}else if(2===g){const t=e.split(hd);if(r&&p>0)continue;const n=parseFloat(t[2]),d=parseFloat(t[3]),m=parseFloat(t[4]);if(s){const e=3*a;if(o[e+0]=n,o[e+1]=d,o[e+2]=m,a+=1,c)continue}const f=t[0],g=t[1],y=t[5].split(".")[0],b=t[6]?parseInt(t[6]):1,x=t[7]?t[7]:"",v=t[8]?parseFloat(t[8]):0;h.growIfFull(),h.atomTypeId[u]=l.add(g,y),h.x[u]=n,h.y[u]=d,h.z[u]=m,h.serial[u]=f,h.partialCharge[u]=v,i.addAtom(p,"","",x,b,!0),u+=1}else if(3===g){if(r&&p>0)continue;if(s&&p>0)continue;const i=e.split(hd);y.index=parseInt(i[1])-1+m,b.index=parseInt(i[2])-1+m;const n=ud[i[3]];t.bondStore.addBond(y,b,n)}}}(0,e.length,e)})),i.finalize(),t.finalizeAtoms(),$o(t),No(t,!0),zo(t,!0),t.finalizeBonds(),Ho(t),Bo(t),e.Debug&&Be.timeEnd("Mol2Parser._parse "+this.name)}});ze.add("pdbqt",class extends Fu{get type(){return"pdbqt"}});ze.add("pqr",class extends Fu{get type(){return"pqr"}});const dd=/> +<(.+)>/;class md extends Iu{get type(){return"sdf"}_parse(){e.Debug&&Be.time("SdfParser._parse "+this.name);const t=this.structure,i=this.structureBuilder,r=this.firstModelOnly,s=this.asTrajectory,n=this.streamer.peekLines(2);t.id=n[0].trim(),t.title=n[1].trim();const o=t.frames;let a,c,l=!1;const h=t.atomMap,u=t.atomStore;u.resize(Math.round(this.streamer.data.length/50)),u.addField("formalCharge",1,"int8");const d=t.getAtomProxy(),m=t.getAtomProxy();let p=0,f=0,g=0,y=0;const b=[];let x,v,w,A,_,S,C,P,I,k,M,D,T,B,R=!1,O={};t.extraData.sdf=b;let $=!1,F=!1,E=!1,L=[],N=[];const z=new Map;this.streamer.eachChunkOfLines((function(e){!function(e,n,V){for(let G=e;G-1,$?z.clear():(v=parseInt(e.substr(0,3)),w=parseInt(e.substr(3,3)),A=4,_=A+v,S=_,C=S+w,s&&(c=0,a=new Float32Array(3*v),o.push(a),g>0&&(l=!0)));else if($&&"COUNTS"===L[0])v=parseInt(L[1]),s&&(c=0,a=new Float32Array(3*v),o.push(a),g>0&&(l=!0));else if($&&2==L.length)"ATOM"===L[1]?"BEGIN"===L[0]?F=!0:"END"===L[0]&&(F=!1):"BOND"===L[1]&&("BEGIN"===L[0]?E=!0:"END"===L[0]&&(E=!1));else if(F||!$&&f>=A&&f<_){if(r&&g>0)continue;let t=0;if($){if(P=parseFloat(L[2]),I=parseFloat(L[3]),k=parseFloat(L[4]),D=L[1],T=parseInt(L[0]),z.set(T,p),M=D+T,L.length>6){let e=L.slice(6).find((e=>0===e.indexOf("CHG=")));e&&(t=parseInt(e.substring(4)))}}else P=parseFloat(e.substr(0,10)),I=parseFloat(e.substr(10,10)),k=parseFloat(e.substr(20,10)),D=e.substr(31,3).trim(),M=D+(p-y+1);if(s){const e=3*c;if(a[e+0]=P,a[e+1]=I,a[e+2]=k,c+=1,l)continue}u.growIfFull(),u.atomTypeId[p]=h.add(M,D),u.x[p]=P,u.y[p]=I,u.z[p]=k,u.serial[p]=$?T:p,u.formalCharge[p]=t,i.addAtom(g,"","","HET",1,!0),p+=1}else if(E||!$&&f>=S&&f0)continue;if(s&&g>0)continue;$?(d.index=z.get(parseInt(L[2])),m.index=z.get(parseInt(L[3])),B=parseInt(L[1])):(d.index=parseInt(e.substr(0,3))-1+y,m.index=parseInt(e.substr(3,3))-1+y,B=parseInt(e.substr(6,3))),t.bondStore.addBond(d,m,B)}else if("M CHG"===e.substr(0,6)){const t=parseInt(e.substr(6,3));for(let i=0,r=10;i"===e.charAt(0)&&(x=e.match(dd))?(R=x[1],O[R]=[]):!1!==R&&e&&O[R].push(e);++f}}}(0,e.length,e)})),i.finalize(),t.finalizeAtoms(),t.finalizeBonds(),Ho(t),e.Debug&&Be.timeEnd("SdfParser._parse "+this.name)}_postProcess(){Ho(this.structure)}}ze.add("sdf",md),ze.add("sd",md),ze.add("mol",md);function pd(e,t,i){return parseInt(e.substr(t,i).trim())}class fd extends Iu{get type(){return"prmtop"}_parse(){e.Debug&&Be.time("PrmtopParser._parse "+this.name);const t=this.structure,i=this.structureBuilder,r=t.atomMap,s=t.atomStore;s.addField("partialCharge",1,"float32"),s.addField("radius",1,"float32");const n=[],o={},a=["NATOM","NTYPES","NBONH","MBONA","NTHETH","MTHETA","NPHIH","MPHIA","NHPARM","NPARM","NNB","NRES","NBONA","NTHETA","NPHIA","NUMBND","NUMANG","NPTRA","NATYP","NPHB","IFPERT","NBPER","NGPER","NDPER","MBPER","MGPER","MDPER","IFBOX","NMXRS","IFCAP","NUMEXTRA","NCOPY"];let c,l,h,u,d;a.forEach((e=>{o[e]=0}));let m,p,f,g,y,b=new Uint8Array(0);this.streamer.eachChunkOfLines((function(e){!function(e,t,i){for(let r=e;r0)return void Be.error("dcd format with fixed atoms unsupported, aborting");const f=o.NATOM,g=4*f;for(let e=0,r=o.NSET;e=1&&(r.timeOffset=(o.ISTART-1)*r.deltaTime),e.Debug&&Be.timeEnd("DcdParser._parse "+this.name)}});const Sd={BYTE:1,CHAR:2,SHORT:3,INT:4,FLOAT:5,DOUBLE:6};function Cd(e){switch(Number(e)){case Sd.BYTE:return"byte";case Sd.CHAR:return"char";case Sd.SHORT:return"short";case Sd.INT:return"int";case Sd.FLOAT:return"float";case Sd.DOUBLE:return"double";default:return"undefined"}}function Pd(e){switch(Number(e)){case Sd.BYTE:case Sd.CHAR:return 1;case Sd.SHORT:return 2;case Sd.INT:case Sd.FLOAT:return 4;case Sd.DOUBLE:return 8;default:return-1}}function Id(e){switch(String(e)){case"byte":return Sd.BYTE;case"char":return Sd.CHAR;case"short":return Sd.SHORT;case"int":return Sd.INT;case"float":return Sd.FLOAT;case"double":return Sd.DOUBLE;default:return-1}}function kd(e,t){if(1!==e){const i=new Array(e);for(let r=0;r6,"non valid type "+h);const u=e.readUint32();let d=e.readUint32();2===i&&(wd(d>0,"offsets larger than 4GB not supported"),d=e.readUint32()),c[0]===t&&(n+=u),s[r]={name:o,dimensions:c,attributes:l,type:Cd(h),size:u,offset:d,record:c[0]===t}}}return{variables:s,recordStep:n}}(e,r.recordId,t);return i.variables=s.variables,i.recordDimension.recordStep=s.recordStep,i}function $d(e){let t;const i=e.readUint32();if(i===Dd)return wd(e.readUint32()!==Dd,"wrong empty tag for list of attributes"),[];{wd(i!==Rd,"wrong tag for list of attributes");const r=e.readUint32();t=new Array(r);for(let i=0;i6,"non valid type "+s);const n=e.readUint32(),o=Md(e,s,n);Ad(e),t[i]={name:r,type:Cd(s),value:o}}}return t}class Fd{constructor(e){const t=new st(e);t.setBigEndian(),wd("CDF"!==t.readChars(3),"should start with CDF");const i=t.readByte();wd(i>2,"unknown version"),this.header=Od(t,i),this.buffer=t}get version(){return 1===this.header.version?"classic format":"64-bit offset format"}get recordDimension(){return this.header.recordDimension}get dimensions(){return this.header.dimensions}get globalAttributes(){return this.header.globalAttributes}get variables(){return this.header.variables}hasDataVariable(e){return-1!==this.header.variables.findIndex((function(t){return t.name===e}))}getDataVariable(e){let t;return t="string"==typeof e?this.header.variables.find((function(t){return t.name===e})):e,wd(void 0===t,"variable not found"),this.buffer.seek(t.offset),t.record?function(e,t,i){const r=Id(t.type),s=t.size?t.size/Pd(r):1,n=i.length,o=new Array(n),a=i.recordStep;for(let t=0;t=1&&(i.timeOffset=n[0]),n.length>=2&&(i.deltaTime=n[1]-n[0]),e.Debug&&Be.timeEnd("NctrajParser._parse "+this.name)}}ze.add("nctraj",Ed),ze.add("ncdf",Ed),ze.add("nc",Ed);ze.add("trr",class extends vd{get type(){return"trr"}get isBinary(){return!0}_parse(){e.Debug&&Be.time("TrrParser._parse "+this.name);const t=_(this.streamer.data),i=new DataView(t),r=this.frames,s=r.coordinates,n=r.boxes,o=r.times;let a=0;for(;;){a+=8;const e=i.getInt32(a);a+=4,a+=e;const r=i.getInt32(a+8),c=i.getInt32(a+12),l=i.getInt32(a+16),h=i.getInt32(a+28),u=i.getInt32(a+32),d=i.getInt32(a+36),m=i.getInt32(a+40);a+=52;const p=r/9,f=3*m;if(8===p?o.push(i.getFloat64(a)):o.push(i.getFloat32(a)),a+=2*p,r){const e=new Float32Array(9);if(8===p)for(let t=0;t<9;++t)e[t]=10*i.getFloat64(a),a+=8;else for(let t=0;t<9;++t)e[t]=10*i.getFloat32(a),a+=4;n.push(e)}if(a+=c,a+=l,h){let e;if(8===p){e=new Float32Array(f);for(let t=0;t>8&65280|t>>24&255}e=new Float32Array(t,a,f);for(let t=0;t=t.byteLength)break}o.length>=1&&(r.timeOffset=o[0]),o.length>=2&&(r.deltaTime=o[1]-o[0]),e.Debug&&Be.timeEnd("TrrParser._parse "+this.name)}});const Ld=new Uint32Array([0,0,0,0,0,0,0,0,0,8,10,12,16,20,25,32,40,50,64,80,101,128,161,203,256,322,406,512,645,812,1024,1290,1625,2048,2580,3250,4096,5060,6501,8192,10321,13003,16384,20642,26007,32768,41285,52015,65536,82570,104031,131072,165140,208063,262144,330280,416127,524287,660561,832255,1048576,1321122,1664510,2097152,2642245,3329021,4194304,5284491,6658042,8388607,10568983,13316085,16777216]);function Nd(e){let t=1,i=0;for(;e>=t&&i<32;)i++,t<<=1;return i}const zd=new Uint8Array(32);function Vd(e,t){let i=1,r=0;zd[0]=1;for(let r=0;r>=8;for(;0!==s;)zd[e++]=255&s,s>>=8;i=e}let s=1;for(i--;zd[i]>=s;)r++,s*=2;return r+8*i}function Gd(e,t,i,r){const s=(1<=8;)o=o<<8|t[a++],c|=o>>n<0&&(n>n&(1<8;)Ud[a++]=Gd(e,t,8,o),r-=8;r>0&&(Ud[a++]=Gd(e,t,r,o));for(let e=i-1;e>0;e--){let t=0;for(let i=a-1;i>=0;i--){t=t<<8|Ud[i];const r=t/s[e]|0;Ud[i]=r,t-=r*s[e]}n[e]=t}n[0]=Ud[0]|Ud[1]<<8|Ud[2]<<16|Ud[3]<<24}ze.add("xtc",class extends vd{get type(){return"xtc"}get isBinary(){return!0}_parse(){e.Debug&&Be.time("XtcParser._parse "+this.name);const t=_(this.streamer.data),i=new DataView(t),r=this.frames,s=r.coordinates,n=r.boxes,o=r.times,a=new Int32Array(6),c=new Int32Array(3),l=new Int32Array(3),h=new Uint32Array(3),u=new Float32Array(3),d=new Float32Array(3);let m=0;const p=new Int32Array(3),f=new Uint32Array(p.buffer);for(;;){let e;const r=i.getInt32(m+4);m+=12;const g=3*r;o.push(i.getFloat32(m)),m+=4;const y=new Float32Array(9);for(let e=0;e<9;++e)y[e]=10*i.getFloat32(m),m+=4;if(n.push(y),r<=9){e=new Float32Array(r);for(let t=0;t16777215?(l[0]=Nd(c[0]),l[1]=Nd(c[1]),l[2]=Nd(c[2]),o=0):o=Vd(3,c);let y=i.getInt32(m);m+=4;let b=y-1;b=9>b?9:b;let x=Ld[b]/2|0,v=Ld[y]/2|0;h[0]=h[1]=h[2]=Ld[y];let w=4*Math.ceil(i.getInt32(m)/4);m+=4;const A=1/n;let _=0,S=0;const C=new Uint8Array(t,m);for(u[0]=u[1]=u[2]=0;S0){u[0]=u[1]=u[2]=0;for(let t=0;t<_;t+=3){if(jd(p,C,3,y,h,u,f),S++,u[0]+=d[0]-v,u[1]+=d[1]-v,u[2]+=d[2]-v,0===t){let t=u[0];u[0]=d[0],d[0]=t,t=u[1],u[1]=d[1],d[1]=t,t=u[2],u[2]=d[2],d[2]=t,e[r++]=d[0]*A,e[r++]=d[1]*A,e[r++]=d[2]*A}else d[0]=u[0],d[1]=u[1],d[2]=u[2];e[r++]=u[0]*A,e[r++]=u[1]*A,e[r++]=u[2]*A}}else e[r++]=u[0]*A,e[r++]=u[1]*A,e[r++]=u[2]*A;if(y+=t,t<0?(v=x,x=y>9?Ld[y-1]/2|0:0):t>0&&(x=v,v=Ld[y]/2|0),h[0]=h[1]=h[2]=Ld[y],0===h[0]||0===h[1]||0===h[2])return void console.error("(xdrfile error) Undefined error.")}m+=w}for(let t=0;t=t.byteLength)break}o.length>=1&&(r.timeOffset=o[0]),o.length>=2&&(r.deltaTime=o[1]-o[0]),e.Debug&&Be.timeEnd("XtcParser._parse "+this.name)}});class Hd extends Pu{constructor(e,t){const i=t||{};super(e,i),this.volume=new Cn(this.name,this.path),this.voxelSize=l(i.voxelSize,1)}get type(){return"volume"}get __objName(){return"volume"}_afterParse(){this.volume.setMatrix(this.getMatrix()),super._afterParse()}getMatrix(){return new t.Matrix4}}const Wd=/\s+/,qd=/-?\d+(?:\.\d*)?(?:[eE][+-]?\d+)?/g,Xd=.529177210859;class Yd extends Hd{get type(){return"cube"}_parse(){e.Debug&&Be.time("CubeParser._parse "+this.name);const i=this.volume,r=this.streamer.peekLines(6),s={},n=Xd*this.voxelSize;function o(e,t){var i=r[e].trim().split(Wd)[t];return parseFloat(i)}s.atomCount=Math.abs(o(2,0)),s.originX=o(2,1)*Xd,s.originY=o(2,2)*Xd,s.originZ=o(2,3)*Xd,s.NVX=o(3,0),s.NVY=o(4,0),s.NVZ=o(5,0),s.basisX=new t.Vector3(o(3,1),o(3,2),o(3,3)).multiplyScalar(n),s.basisY=new t.Vector3(o(4,1),o(4,2),o(4,3)).multiplyScalar(n),s.basisZ=new t.Vector3(o(5,1),o(5,2),o(5,3)).multiplyScalar(n);const a=new Float32Array(s.NVX*s.NVY*s.NVZ);let c=0,l=0;const h=o(2,0)>0?0:1;this.streamer.eachChunkOfLines((function(e){!function(e,t,i){for(let r=e;r=s.atomCount+6+h){const t=e.match(qd);for(let e=0,i=t.length;e>8&255}i.xStart=o[0],i.yStart=o[1],i.zStart=o[2],i.xExtent=o[3],i.yExtent=o[4],i.zExtent=o[5],i.xRate=o[6],i.yRate=o[7],i.zRate=o[8];const e=1/o[17],t=e*this.voxelSize;i.xlen=o[9]*t,i.ylen=o[10]*t,i.zlen=o[11]*t,i.alpha=o[12]*e,i.beta=o[13]*e,i.gamma=o[14]*e,r=o[15]/100,s=o[16],i.gamma=o[14]*e}t.header=i,e.Debug&&Be.log(i,r,s);const l=new Float32Array(i.xExtent*i.yExtent*i.zExtent);let h=512;const u=Math.ceil(i.xExtent/8),d=Math.ceil(i.yExtent/8),m=Math.ceil(i.zExtent/8);for(var p=0;pn){const e=i[r].trim();if(""!==e){const t=e.split(Zd);for(let e=0,i=t.length;e=n&&(f-n)%m!=0&&p=0?i-1:i+t/3)},parseNormalIndex:function(e,t){var i=parseInt(e,10);return 3*(i>=0?i-1:i+t/3)},addVertex:function(e,t,i){var r=this.vertices,s=this.object.geometry.vertices;s.push(r[e+0]),s.push(r[e+1]),s.push(r[e+2]),s.push(r[t+0]),s.push(r[t+1]),s.push(r[t+2]),s.push(r[i+0]),s.push(r[i+1]),s.push(r[i+2])},addVertexLine:function(e){var t=this.vertices,i=this.object.geometry.vertices;i.push(t[e+0]),i.push(t[e+1]),i.push(t[e+2])},addNormal:function(e,t,i){var r=this.normals,s=this.object.geometry.normals;s.push(r[e+0]),s.push(r[e+1]),s.push(r[e+2]),s.push(r[t+0]),s.push(r[t+1]),s.push(r[t+2]),s.push(r[i+0]),s.push(r[i+1]),s.push(r[i+2])},addFace:function(e,t,i,r,s,n,o,a){var c,l=this.vertices.length,h=this.parseVertexIndex(e,l),u=this.parseVertexIndex(t,l),d=this.parseVertexIndex(i,l);if(void 0===r?this.addVertex(h,u,d):(c=this.parseVertexIndex(r,l),this.addVertex(h,u,c),this.addVertex(u,d,c)),void 0!==s){var m=this.normals.length;h=this.parseNormalIndex(s,m),u=s===n?h:this.parseNormalIndex(n,m),d=s===o?h:this.parseNormalIndex(o,m),void 0===r?this.addNormal(h,u,d):(c=this.parseNormalIndex(a,m),this.addNormal(h,u,c),this.addNormal(u,d,c))}},addLineGeometry:function(e){this.object.geometry.type="Line";for(var t=this.vertices.length,i=0,r=e.length;i0?v.setAttribute("normal",new t.BufferAttribute(new Float32Array(x.normals),3)):v.computeVertexNormals(),b.push(v)}}return b}};ze.add("obj",class extends fm{get type(){return"obj"}getLoader(){return new gm}});const ym=function(){this.propertyNameMapping={}};ym.prototype={constructor:ym,setPropertyNameMapping:function(e){this.propertyNameMapping=e},bin2str:function(e){for(var t=new Uint8Array(e),i="",r=0;r=s.elements[a].count&&(a++,c=0);var u=this.parseASCIIElement(s.elements[a].properties,h);this.handleElement(r,s.elements[a].name,u),c++}}return this.postProcess(r)},postProcess:function(e){if(e.useColor){for(var t=0;t{const s=r.length;for(let n=0;n/g,""),{declaration:t(),root:i()};function t(){if(!s(/^<\?xml\s*/))return;const e={attributes:{}};for(;!n()&&!o("?>");){const t=r();if(!t)return e;e.attributes[t.name]=t.value}return s(/\?>\s*/),e}function i(){const e=s(vm);if(!e)return;const t={name:e[1],attributes:{},children:[]};for(;!(n()||o(">")||o("?>")||o("/>"));){const e=r();if(!e)return t;t.attributes[e.name]=e.value}if(s(/^\s*\/>\s*/))return t;let a;for(s(/\??>\s*/),t.content=function(){const e=s(wm);return e?e[1]:""}();a=i();)t.children.push(a);return s(/^<\/[\w-:.]+>\s*/),t}function r(){const e=s(Am);var t;if(e)return{name:e[1],value:(t=e[2],t.replace(xm,""))}}function s(t){const i=e.match(t);if(i)return e=e.slice(i[0].length),i}function n(){return 0===e.length}function o(t){return 0===e.indexOf(t)}}class Sm extends Pu{constructor(e,t){const i=t||{};super(e,i),this.useDomParser=l(i.useDomParser,!1),this.xml={name:this.name,path:this.path,data:{}}}get type(){return"xml"}get __objName(){return"xml"}get isXml(){return!0}__xmlParser(e){return _m(e)}__domParser(e){return(new window.DOMParser).parseFromString(e,"text/xml")}_parse(){e.Debug&&Be.time("XmlParser._parse "+this.name),this.useDomParser?this.streamer.data instanceof Document?this.xml.data=this.streamer.data:this.xml.data=this.__domParser(this.streamer.asText()):this.xml.data=this.__xmlParser(this.streamer.asText()),e.Debug&&Be.timeEnd("XmlParser._parse "+this.name)}}function Cm(e,t){const i=e.getNamedItem(t);return null!==i?i.value:""}function Pm(e,t,i=!1){const r=Cm(e,"icode").trim(),s=Cm(e,"chain").trim(),n=Cm(e,"altcode");let o=Cm(e,"resnum");return r&&(o+="^"+r),s&&(o+=":"+s),t&&(o+="."+t),i&&n.trim()&&(o+="%"+n),o+="/"+(parseInt(Cm(e,"model"))-1),o}function Im(e){const t=Cm(e,"chain").trim();let i=`[${Cm(e,"rescode")}]${Cm(e,"resnum")}`;return t&&(i+=`:${t}`),i}function km(e,t,i){void 0===e[t]?e[t]=i:e[t]|=i}function Mm(e,t){return null!==e&&e.value===t}function Dm(e,t,i){let r=0;const s=t.getElementsByTagName("clash");for(let t=0,i=s.length;t0&&(r+=1);t.getElementsByTagName("bond-outlier").length>0&&(r+=1);return t.getElementsByTagName("plane-outlier").length>0&&(r+=1),Mm(i.getNamedItem("rota"),"OUTLIER")&&(r+=1),Mm(i.getNamedItem("rama"),"OUTLIER")&&(r+=1),Mm(i.getNamedItem("RNApucker"),"outlier")&&(r+=1),r}ze.add("xml",Sm);class Tm{constructor(e,t){this.name=e,this.path=t,this.rsrzDict={},this.rsccDict={},this.rciDict={},this.clashDict={},this.clashArray=[],this.geoDict={},this.geoAtomDict={},this.atomDict={},this.clashSele="NONE"}get type(){return"validation"}fromXml(t){e.Debug&&Be.time("Validation.fromXml");const i=this.rsrzDict,r=this.rsccDict,s=this.rciDict,n=this.clashDict,o=this.clashArray,a=this.geoDict,c=this.geoAtomDict,l=this.atomDict,h=t.getElementsByTagName("Entry");if(1===h.length){const e=h[0].getElementsByTagName("chemical_shift_list");if(1===e.length){const t=e[0].getElementsByTagName("random_coil_index");for(let e=0,i=t.length;e0&&(a[r]=e)}else{const e=t.getElementsByTagName("clash"),i=t.getElementsByTagName("mog-bond-outlier"),s=t.getElementsByTagName("mog-angle-outlier");if(i.length>0||s.length>0||e.length>0){const t={};c[r]=t;for(let i=0,r=e.length;i>>16&65535|0,o=0;0!==i;){i-=o=i>2e3?2e3:i;do{n=n+(s=s+t[r++]|0)|0}while(--o);s%=65521,n%=65521}return s|n<<16|0}ze.add("validation",class extends Sm{constructor(e,t){super(e,t||{}),this.useDomParser=!0,this.validation=new Tm(this.name,this.path)}get __objName(){return"validation"}get isXml(){return!0}_parse(){super._parse(),e.Debug&&Be.time("ValidationParser._parse "+this.name),this.validation.fromXml(this.xml.data),e.Debug&&Be.timeEnd("ValidationParser._parse "+this.name)}});var $m=function(){for(var e,t=[],i=0;i<256;i++){e=i;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[i]=e}return t}();function Fm(e,t,i,r){var s=$m,n=r+i;e^=-1;for(var o=r;o>>8^s[255&(e^t[o])];return-1^e}var Em=30,Lm=12;function Nm(e,t){var i,r,s,n,o,a,c,l,h,u,d,m,p,f,g,y,b,x,v,w,A,_,S,C,P;i=e.state,r=e.next_in,C=e.input,s=r+(e.avail_in-5),n=e.next_out,P=e.output,o=n-(t-e.avail_out),a=n+(e.avail_out-257),c=i.dmax,l=i.wsize,h=i.whave,u=i.wnext,d=i.window,m=i.hold,p=i.bits,f=i.lencode,g=i.distcode,y=(1<>>=v=x>>>24,p-=v,0===(v=x>>>16&255))P[n++]=65535&x;else{if(!(16&v)){if(0==(64&v)){x=f[(65535&x)+(m&(1<>>=v,p-=v),p<15&&(m+=C[r++]<>>=v=x>>>24,p-=v,!(16&(v=x>>>16&255))){if(0==(64&v)){x=g[(65535&x)+(m&(1<c){e.msg="invalid distance too far back",i.mode=Em;break e}if(m>>>=v,p-=v,A>(v=n-o)){if((v=A-v)>h&&i.sane){e.msg="invalid distance too far back",i.mode=Em;break e}if(_=0,S=d,0===u){if(_+=l-v,v2;)P[n++]=S[_++],P[n++]=S[_++],P[n++]=S[_++],w-=3;w&&(P[n++]=S[_++],w>1&&(P[n++]=S[_++]))}else{_=n-A;do{P[n++]=P[_++],P[n++]=P[_++],P[n++]=P[_++],w-=3}while(w>2);w&&(P[n++]=P[_++],w>1&&(P[n++]=P[_++]))}break}}break}}while(r>3,m&=(1<<(p-=w<<3))-1,e.next_in=r,e.next_out=n,e.avail_in=r=1&&0===D[w];w--);if(A>w&&(A=w),0===w)return s[n++]=20971520,s[n++]=20971520,a.bits=1,0;for(v=1;v0&&(e===Um||1!==w))return-1;for(T[1]=0,b=1;bVm||e===Hm&&P>Gm)return 1;for(;;){p=b-S,o[x]m?(f=B[R+o[x]],g=k[M+o[x]]):(f=96,g=0),c=1<>S)+(l-=c)]=p<<24|f<<16|g|0}while(0!==l);for(c=1<>=1;if(0!==c?(I&=c-1,I+=c):I=0,x++,0==--D[b]){if(b===w)break;b=t[i+o[x]]}if(b>A&&(I&u)!==h){for(0===S&&(S=A),d+=v,C=1<<(_=b-S);_+SVm||e===Hm&&P>Gm)return 1;s[h=I&u]=A<<24|_<<16|d-n|0}}return 0!==I&&(s[d+I]=b-S<<24|64<<16|0),a.bits=A,0}var Zm=1,Qm=2,Jm=0,ep=-2,tp=1,ip=12,rp=30,sp=852,np=592;function op(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function ap(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function cp(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,function(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=tp,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(sp),t.distcode=t.distdyn=new Int32Array(np),t.sane=1,t.back=-1,Jm):ep}(e)):ep}function lp(e,t){var i,r;return e?(r=new ap,e.state=r,r.window=null,i=function(e,t){var i,r;return e&&e.state?(r=e.state,t<0?(i=0,t=-t):(i=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?ep:(null!==r.window&&r.wbits!==t&&(r.window=null),r.wrap=i,r.wbits=t,cp(e))):ep}(e,t),i!==Jm&&(e.state=null),i):ep}var hp,up,dp=!0;function mp(e){if(dp){var t;for(hp=new Int32Array(512),up=new Int32Array(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(Km(Zm,e.lens,0,288,hp,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Km(Qm,e.lens,0,32,up,0,e.work,{bits:5}),dp=!1}e.lencode=hp,e.lenbits=9,e.distcode=up,e.distbits=5}function pp(e,t,i,r){var s,n=e.state;return null===n.window&&(n.wsize=1<=n.wsize?(Rm(n.window,t,i-n.wsize,n.wsize,0),n.wnext=0,n.whave=n.wsize):((s=n.wsize-n.wnext)>r&&(s=r),Rm(n.window,t,i-r,s,n.wnext),(r-=s)?(Rm(n.window,t,i-r,r,0),n.wnext=r,n.whave=n.wsize):(n.wnext+=s,n.wnext===n.wsize&&(n.wnext=0),n.whave>>8&255,i.check=Fm(i.check,I,2,0),l=0,h=0,i.mode=2;break}if(i.flags=0,i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&l)<<8)+(l>>8))%31){e.msg="incorrect header check",i.mode=rp;break}if(8!=(15&l)){e.msg="unknown compression method",i.mode=rp;break}if(h-=4,A=8+(15&(l>>>=4)),0===i.wbits)i.wbits=A;else if(A>i.wbits){e.msg="invalid window size",i.mode=rp;break}i.dmax=1<>8&1),512&i.flags&&(I[0]=255&l,I[1]=l>>>8&255,i.check=Fm(i.check,I,2,0)),l=0,h=0,i.mode=3;case 3:for(;h<32;){if(0===a)break e;a--,l+=r[n++]<>>8&255,I[2]=l>>>16&255,I[3]=l>>>24&255,i.check=Fm(i.check,I,4,0)),l=0,h=0,i.mode=4;case 4:for(;h<16;){if(0===a)break e;a--,l+=r[n++]<>8),512&i.flags&&(I[0]=255&l,I[1]=l>>>8&255,i.check=Fm(i.check,I,2,0)),l=0,h=0,i.mode=5;case 5:if(1024&i.flags){for(;h<16;){if(0===a)break e;a--,l+=r[n++]<>>8&255,i.check=Fm(i.check,I,2,0)),l=0,h=0}else i.head&&(i.head.extra=null);i.mode=6;case 6:if(1024&i.flags&&((m=i.length)>a&&(m=a),m&&(i.head&&(A=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Array(i.head.extra_len)),Rm(i.head.extra,r,n,m,A)),512&i.flags&&(i.check=Fm(i.check,r,m,n)),a-=m,n+=m,i.length-=m),i.length))break e;i.length=0,i.mode=7;case 7:if(2048&i.flags){if(0===a)break e;m=0;do{A=r[n+m++],i.head&&A&&i.length<65536&&(i.head.name+=String.fromCharCode(A))}while(A&&m>9&1,i.head.done=!0),e.adler=i.check=0,i.mode=ip;break;case 10:for(;h<32;){if(0===a)break e;a--,l+=r[n++]<>>=7&h,h-=7&h,i.mode=27;break}for(;h<3;){if(0===a)break e;a--,l+=r[n++]<>>=1)){case 0:i.mode=14;break;case 1:if(mp(i),i.mode=20,6===t){l>>>=2,h-=2;break e}break;case 2:i.mode=17;break;case 3:e.msg="invalid block type",i.mode=rp}l>>>=2,h-=2;break;case 14:for(l>>>=7&h,h-=7&h;h<32;){if(0===a)break e;a--,l+=r[n++]<>>16^65535)){e.msg="invalid stored block lengths",i.mode=rp;break}if(i.length=65535&l,l=0,h=0,i.mode=15,6===t)break e;case 15:i.mode=16;case 16:if(m=i.length){if(m>a&&(m=a),m>c&&(m=c),0===m)break e;Rm(s,r,n,m,o),a-=m,n+=m,c-=m,o+=m,i.length-=m;break}i.mode=ip;break;case 17:for(;h<14;){if(0===a)break e;a--,l+=r[n++]<>>=5,h-=5,i.ndist=1+(31&l),l>>>=5,h-=5,i.ncode=4+(15&l),l>>>=4,h-=4,i.nlen>286||i.ndist>30){e.msg="too many length or distance symbols",i.mode=rp;break}i.have=0,i.mode=18;case 18:for(;i.have>>=3,h-=3}for(;i.have<19;)i.lens[k[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,S={bits:i.lenbits},_=Km(0,i.lens,0,19,i.lencode,0,i.work,S),i.lenbits=S.bits,_){e.msg="invalid code lengths set",i.mode=rp;break}i.have=0,i.mode=19;case 19:for(;i.have>>16&255,b=65535&P,!((g=P>>>24)<=h);){if(0===a)break e;a--,l+=r[n++]<>>=g,h-=g,i.lens[i.have++]=b;else{if(16===b){for(C=g+2;h>>=g,h-=g,0===i.have){e.msg="invalid bit length repeat",i.mode=rp;break}A=i.lens[i.have-1],m=3+(3&l),l>>>=2,h-=2}else if(17===b){for(C=g+3;h>>=g)),l>>>=3,h-=3}else{for(C=g+7;h>>=g)),l>>>=7,h-=7}if(i.have+m>i.nlen+i.ndist){e.msg="invalid bit length repeat",i.mode=rp;break}for(;m--;)i.lens[i.have++]=A}}if(i.mode===rp)break;if(0===i.lens[256]){e.msg="invalid code -- missing end-of-block",i.mode=rp;break}if(i.lenbits=9,S={bits:i.lenbits},_=Km(Zm,i.lens,0,i.nlen,i.lencode,0,i.work,S),i.lenbits=S.bits,_){e.msg="invalid literal/lengths set",i.mode=rp;break}if(i.distbits=6,i.distcode=i.distdyn,S={bits:i.distbits},_=Km(Qm,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,S),i.distbits=S.bits,_){e.msg="invalid distances set",i.mode=rp;break}if(i.mode=20,6===t)break e;case 20:i.mode=21;case 21:if(a>=6&&c>=258){e.next_out=o,e.avail_out=c,e.next_in=n,e.avail_in=a,i.hold=l,i.bits=h,Nm(e,d),o=e.next_out,s=e.output,c=e.avail_out,n=e.next_in,r=e.input,a=e.avail_in,l=i.hold,h=i.bits,i.mode===ip&&(i.back=-1);break}for(i.back=0;y=(P=i.lencode[l&(1<>>16&255,b=65535&P,!((g=P>>>24)<=h);){if(0===a)break e;a--,l+=r[n++]<>x)])>>>16&255,b=65535&P,!(x+(g=P>>>24)<=h);){if(0===a)break e;a--,l+=r[n++]<>>=x,h-=x,i.back+=x}if(l>>>=g,h-=g,i.back+=g,i.length=b,0===y){i.mode=26;break}if(32&y){i.back=-1,i.mode=ip;break}if(64&y){e.msg="invalid literal/length code",i.mode=rp;break}i.extra=15&y,i.mode=22;case 22:if(i.extra){for(C=i.extra;h>>=i.extra,h-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=23;case 23:for(;y=(P=i.distcode[l&(1<>>16&255,b=65535&P,!((g=P>>>24)<=h);){if(0===a)break e;a--,l+=r[n++]<>x)])>>>16&255,b=65535&P,!(x+(g=P>>>24)<=h);){if(0===a)break e;a--,l+=r[n++]<>>=x,h-=x,i.back+=x}if(l>>>=g,h-=g,i.back+=g,64&y){e.msg="invalid distance code",i.mode=rp;break}i.offset=b,i.extra=15&y,i.mode=24;case 24:if(i.extra){for(C=i.extra;h>>=i.extra,h-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){e.msg="invalid distance too far back",i.mode=rp;break}i.mode=25;case 25:if(0===c)break e;if(m=d-c,i.offset>m){if((m=i.offset-m)>i.whave&&i.sane){e.msg="invalid distance too far back",i.mode=rp;break}m>i.wnext?(m-=i.wnext,p=i.wsize-m):p=i.wnext-m,m>i.length&&(m=i.length),f=i.window}else f=s,p=o-i.offset,m=i.length;m>c&&(m=c),c-=m,i.length-=m;do{s[o++]=f[p++]}while(--m);0===i.length&&(i.mode=21);break;case 26:if(0===c)break e;s[o++]=i.length,c--,i.mode=21;break;case 27:if(i.wrap){for(;h<32;){if(0===a)break e;a--,l|=r[n++]<=252?6:vp>=248?5:vp>=240?4:vp>=224?3:vp>=192?2:1;function wp(e){var t,i,r,s,n,o=e.length,a=0;for(s=0;s>>6,t[n++]=128|63&i):i<65536?(t[n++]=224|i>>>12,t[n++]=128|i>>>6&63,t[n++]=128|63&i):(t[n++]=240|i>>>18,t[n++]=128|i>>>12&63,t[n++]=128|i>>>6&63,t[n++]=128|63&i);return t}function Ap(e,t){var i,r,s,n,o=t||e.length,a=new Array(2*o);for(r=0,i=0;i4)a[r++]=65533,i+=n-1;else{for(s&=2===n?31:3===n?15:7;n>1&&i1?a[r++]=65533:s<65536?a[r++]=s:(s-=65536,a[r++]=55296|s>>10&1023,a[r++]=56320|1023&s)}return function(e,t){if(t<65537&&(e.subarray&&bp||!e.subarray&&yp))return String.fromCharCode.apply(null,Bm(e,t));for(var i="",r=0;re.length&&(t=e.length),i=t-1;i>=0&&128==(192&e[i]);)i--;return i<0||0===i?t:i+xp[e[i]]>t?i:t}xp[254]=xp[254]=1;var Sp=0,Cp={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"};function Pp(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}function Ip(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var kp=Object.prototype.toString;function Mp(e){if(!(this instanceof Mp))return new Mp(e);this.options=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var i=t.shift();if(i){if("object"!=typeof i)throw new TypeError(i+"must be non-object");for(var r in i)i.hasOwnProperty(r)&&(e[r]=i[r])}}return e}({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Pp,this.strm.avail_out=0;var i,r,s,n=lp(this.strm,t.windowBits);if(n!==Sp)throw new Error(Cp[n]);this.header=new Ip,i=this.strm,r=this.header,i&&i.state&&(0==(2&(s=i.state).wrap)||(s.head=r,r.done=!1))}Mp.prototype.push=function(e,t){var i,r,s,n,o,a,c=this.strm,l=this.options.chunkSize,h=this.options.dictionary,u=!1;if(this.ended)return!1;r=t===~~t?t:!0===t?4:0,"string"==typeof e?c.input=function(e){for(var t=new Uint8Array(e.length),i=0,r=t.length;i0||0===c.avail_out)&&1!==i);return 1===i&&(r=4),4===r?(i=function(e){if(!e||!e.state)return ep;var t=e.state;return t.window&&(t.window=null),e.state=null,Jm}(this.strm),this.onEnd(i),this.ended=!0,i===Sp):2!==r||(this.onEnd(Sp),c.avail_out=0,!0)},Mp.prototype.onData=function(e){this.chunks.push(e)},Mp.prototype.onEnd=function(e){e===Sp&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=function(e){var t,i,r,s,n,o;for(r=0,t=0,i=e.length;tObject.assign(Object.assign({},e),{[t]:t})),{})}}const jp={backgroundColor:{type:"color"},quality:Up("auto","low","medium","high"),sampleLevel:Gp(1,5,-1),impostor:{type:"boolean"},workerDefault:{type:"boolean"},rotateSpeed:Vp(1,10,0),zoomSpeed:Vp(1,10,0),panSpeed:Vp(1,10,0),clipNear:Gp(1,100,0),clipFar:Gp(1,100,0),clipDist:zp(200,0),clipMode:Up("scene","camera"),clipScale:Up("relative","absolute"),fogNear:Gp(1,100,0),fogFar:Gp(1,100,0),cameraType:Up("perspective","orthographic","stereo"),cameraEyeSep:Vp(3,1,.01),cameraFov:Gp(1,120,15),lightColor:{type:"color"},lightIntensity:Vp(2,10,0),ambientColor:{type:"color"},ambientIntensity:Vp(2,10,0),hoverTimeout:zp(1e4,-1),tooltip:{type:"boolean"},mousePreset:Up(...Object.keys(zn))};Object.defineProperty(e,"Box3",{enumerable:!0,get:function(){return t.Box3}}),Object.defineProperty(e,"Color",{enumerable:!0,get:function(){return t.Color}}),Object.defineProperty(e,"Euler",{enumerable:!0,get:function(){return t.Euler}}),Object.defineProperty(e,"Matrix3",{enumerable:!0,get:function(){return t.Matrix3}}),Object.defineProperty(e,"Matrix4",{enumerable:!0,get:function(){return t.Matrix4}}),Object.defineProperty(e,"Plane",{enumerable:!0,get:function(){return t.Plane}}),Object.defineProperty(e,"Quaternion",{enumerable:!0,get:function(){return t.Quaternion}}),Object.defineProperty(e,"Vector2",{enumerable:!0,get:function(){return t.Vector2}}),Object.defineProperty(e,"Vector3",{enumerable:!0,get:function(){return t.Vector3}}),Object.defineProperty(e,"Signal",{enumerable:!0,get:function(){return r.Signal}}),e.AngleRepresentation=kl,e.ArrowBuffer=Qh,e.Assembly=ko,e.AxesRepresentation=Ul,e.BackboneRepresentation=Hl,e.BallAndStickRepresentation=jl,e.BaseRepresentation=Wl,e.BoxBuffer=ru,e.BufferRepresentation=xa,e.CartoonRepresentation=Jl,e.Collection=Ja,e.Colormaker=U,e.ColormakerRegistry=Ee,e.Component=Qa,e.ComponentCollection=Ac,e.ConeBuffer=Yh,e.ContactRepresentation=eh,e.Counter=nt,e.CylinderBuffer=Gl,e.DatasourceRegistry=Le,e.DecompressorRegistry=Ge,e.DihedralHistogramRepresentation=sh,e.DihedralRepresentation=th,e.DistanceRepresentation=oh,e.EllipsoidBuffer=lu,e.Frames=rc,e.HelixorientRepresentation=hh,e.HyperballRepresentation=xh,e.Kdtree=_o,e.KeyActions=Un,e.LabelRepresentation=wh,e.LeftMouseButton=1,e.LicoriceRepresentation=uh,e.LineRepresentation=_h,e.MdsrvDatasource=class extends Dp{constructor(e=""){super(),this.baseUrl=e}getListing(e=""){let t=`${this.baseUrl}dir/${e}`;return"/"!==t[t.length-1]&&(t+="/"),tt(t,{ext:"json"}).then((t=>({path:e,data:t.data})))}getUrl(e){const t=Je(e);return`${this.baseUrl}file/${t.path}${t.query}`}getCountUrl(e){const t=Je(e);return`${this.baseUrl}traj/numframes/${t.path}${t.query}`}getFrameUrl(e,t){const i=Je(e);return`${this.baseUrl}traj/frame/${t}/${i.path}${i.query}`}getFrameParams(e,t){return`atomIndices=${t.join(";")}`}getPathUrl(e,t){const i=Je(e);return`${this.baseUrl}traj/path/${t}/${i.path}${i.query}`}getExt(e){return Je(e).ext}},e.MeasurementDefaultParams=Re,e.MeshBuffer=Bn,e.MiddleMouseButton=2,e.MolecularSurface=kh,e.MolecularSurfaceRepresentation=Mh,e.MouseActions=Nn,e.OctahedronBuffer=pu,e.ParserRegistry=ze,e.PdbWriter=class extends it{constructor(e,t){super(),this.mimeType="text/plain",this.defaultName="structure",this.defaultExt="pdb";const i=Object.assign({},t);this.renumberSerial=l(i.renumberSerial,!0),this.remarks=function(e){return Array.isArray(e)?e:[e]}(l(i.remarks,[])),this.structure=e,this._records=[]}_writeRecords(){this._records.length=0,this._writeTitle(),this._writeRemarks(),this._writeAtoms()}_writeTitle(){this._records.push(s.sprintf("TITLE %-74s",this.structure.name))}_writeRemarks(){this.remarks.forEach((e=>{this._records.push(s.sprintf("REMARK %-73s",e))})),this.structure.trajectory&&(this._records.push(s.sprintf("REMARK %-73s","Trajectory '"+this.structure.trajectory.name+"'")),this._records.push(s.sprintf("REMARK %-73s",`Frame ${this.structure.trajectory.frame}`)))}_writeAtoms(){let e=1,t=1,i=" ",r=" ";const n=this.structure.modelStore.count>1;this.structure.eachModel((o=>{n&&this._records.push(s.sprintf("MODEL %4d%-66s",t++,"")),o.eachAtom((t=>{const n=t.hetero?"HETATM%5d %-4s %3s %1s%4d %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%1s%1s":"ATOM %5d %-4s %3s %1s%4d %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%1s%1s",o=this.renumberSerial?e:t.serial;let a=t.atomname;(1===a.length||a.length<4&&1===t.element.length&&a[0]===t.element)&&(a=" "+a),t.formalCharge?(i=Math.abs(t.formalCharge).toPrecision(1),r=t.formalCharge>0?"+":"-"):(i=" ",r=" "),this._records.push(s.sprintf(n,o,a,t.resname,l(t.chainname," "),t.resno,t.x,t.y,t.z,l(t.occupancy,1),l(t.bfactor,0),"",l(t.element,""),i,r)),e+=1}),this.structure.getSelection()),n&&this._records.push(s.sprintf("%-80s","ENDMDL"))})),this._records.push(s.sprintf("%-80s","END"))}getString(){return console.warn("PdbWriter.getString() is deprecated, use .getData instead"),this.getData()}getData(){return this._writeRecords(),this._records.join("\n")}},e.PickingProxy=ci,e.PointBuffer=$a,e.PointRepresentation=Dh,e.Queue=Mi,e.RepresentationCollection=ec,e.RepresentationElement=Xa,e.RepresentationRegistry=Ne,e.RibbonRepresentation=Oh,e.RightMouseButton=3,e.RocketRepresentation=$h,e.RopeRepresentation=Fh,e.ScriptExtensions=$e,e.SdfWriter=class extends it{constructor(e){super(),this.mimeType="text/plain",this.defaultName="structure",this.defaultExt="sdf",this.structure=e,this._records=[]}get idString(){return this.structure.id}get titleString(){return" "+this.structure.title}get countsString(){return s.sprintf("%3i%3i 0 0 0 0 0 0 0 0999 V2000",this.structure.atomCount,this.structure.bondCount)}get chargeLines(){const e=[];this.structure.eachAtom((t=>{null!=t.formalCharge&&0!==t.formalCharge&&e.push([t.index,t.formalCharge])}));const t=[];for(let i=0;i{this._records.push(this.formatAtom(e))})),this.structure.eachBond((e=>{this._records.push(this.formatBond(e))})),this.chargeLines.forEach((e=>{this._records.push(e)})),this._records.push("M END")}_writeFooter(){this._records.push("$$$$")}getData(){return this._writeRecords(),this._records.join("\n")}},e.Selection=ye,e.Shape=ba,e.ShapeComponent=Pc,e.SpacefillRepresentation=Eh,e.SpatialHash=vr,e.SphereBuffer=Ta,e.Stage=class{constructor(e,t={}){this.signals={parametersChanged:new r.Signal,fullscreenChanged:new r.Signal,componentAdded:new r.Signal,componentRemoved:new r.Signal,clicked:new r.Signal,hovered:new r.Signal},this.tasks=new nt,this.compList=[],this.defaultFileParams={},this.logList=[],this.viewer=new Wt(e),this.viewer.renderer&&(this.tooltip=document.createElement("div"),Object.assign(this.tooltip.style,{display:"none",position:"fixed",zIndex:"1000000",pointerEvents:"none",backgroundColor:"rgba( 0, 0, 0, 0.6 )",color:"lightgrey",padding:"8px",fontFamily:"sans-serif"}),this.viewer.container.appendChild(this.tooltip),this.mouseObserver=new Xt(this.viewer.renderer.domElement),this.viewerControls=new bi(this),this.trackballControls=new oi(this),this.pickingControls=new li(this),this.animationControls=new ki(this),this.mouseControls=new Gn(this),this.keyControls=new Hn(this),this.pickingBehavior=new Wn(this),this.mouseBehavior=new qn(this),this.animationBehavior=new Xn(this),this.keyBehavior=new Kn(this),this.spinAnimation=this.animationControls.spin([0,1,0],.005),this.spinAnimation.pause(!0),this.rockAnimation=this.animationControls.rock([0,1,0],.005),this.rockAnimation.pause(!0),this.parameters=h(t,Cc),this.setParameters(this.parameters),this.viewer.animate())}setParameters(e={}){u(this.parameters,e);const t=e,i=this.parameters,r=this.viewer,s=this.trackballControls;return void 0!==t.quality&&this.setQuality(i.quality),void 0!==t.impostor&&this.setImpostor(i.impostor),void 0!==t.rotateSpeed&&(s.rotateSpeed=i.rotateSpeed),void 0!==t.zoomSpeed&&(s.zoomSpeed=i.zoomSpeed),void 0!==t.panSpeed&&(s.panSpeed=i.panSpeed),void 0!==t.mousePreset&&this.mouseControls.preset(i.mousePreset),this.mouseObserver.setParameters({hoverTimeout:i.hoverTimeout}),r.setClip(i.clipNear,i.clipFar,i.clipDist,i.clipMode,i.clipScale),r.setFog(void 0,i.fogNear,i.fogFar),r.setCamera(i.cameraType,i.cameraFov,i.cameraEyeSep),r.setSampling(i.sampleLevel),r.setBackground(i.backgroundColor),r.setLight(i.lightColor,i.lightIntensity,i.ambientColor,i.ambientIntensity),this.signals.parametersChanged.dispatch(this.getParameters()),this}log(e){console.log("STAGE LOG",e),this.logList.push(e)}getParameters(){return Object.assign({},this.parameters)}defaultFileRepresentation(t){if(t instanceof xc){let i,r,s;t.setSelection("/0");const n=t.structure;if(n.biomolDict.BU1){const e=n.biomolDict.BU1;i=e.getAtomCount(n),r=e.getResidueCount(n),s=e.getInstanceCount(),t.setDefaultAssembly("BU1")}else i=n.getModelProxy(0).atomCount,r=n.getModelProxy(0).residueCount,s=1;let o=i;Ie&&(o*=4);const a=n.atomStore.count/n.residueStore.count<2;a&&(o*=10);let c="chainname",l="RdYlBu",h=!1;if(1===n.getChainnameCount(new ye("polymer and /0"))&&(c="residueindex",l="Spectral",h=!0),e.Debug&&console.log(o,i,s,a),r/s<4)t.addRepresentation("ball+stick",{colorScheme:"element",radiusScale:2,aspectRatio:1.5,bondScale:.3,bondSpacing:.75,quality:"auto"});else if(s>5&&o>15e3||o>7e5){let e=Math.min(2,Math.max(.1,6e3/(o/s)));a&&(e=Math.min(e,.5)),t.addRepresentation("surface",{colorScheme:c,colorScale:l,colorReverse:h,sele:"polymer",surfaceType:"av",probeRadius:1.4,scaleFactor:e,useWorker:!1})}else o>25e4?t.addRepresentation("backbone",{colorScheme:c,colorScale:l,colorReverse:h,lineOnly:!0}):o>1e5?t.addRepresentation("backbone",{colorScheme:c,colorScale:l,colorReverse:h,quality:"low",disableImpostor:!0,radiusScale:2}):o>8e4?t.addRepresentation("backbone",{colorScheme:c,colorScale:l,colorReverse:h,radiusScale:2}):(t.addRepresentation("cartoon",{colorScheme:c,colorScale:l,colorReverse:h,radiusScale:.7,aspectRatio:5,quality:"auto"}),o<5e4&&t.addRepresentation("base",{colorScheme:c,colorScale:l,colorReverse:h,quality:"auto"}),t.addRepresentation("ball+stick",{sele:"ligand",colorScheme:"element",radiusScale:2,aspectRatio:1.5,bondScale:.3,bondSpacing:.75,quality:"auto"}));t.structure.frames.length&&t.addTrajectory()}else(t instanceof vc||t instanceof wc)&&t.addRepresentation("surface");this.tasks.onZeroOnce(this.autoView,this)}loadFile(e,t={}){const i=Object.assign({},this.defaultFileParams,t),r=Je(e).name;this.tasks.increment(),this.log(`loading file '${r}'`);const s=l(i.ext,Je(e).ext);let n;return n=ze.isTrajectory(s)?Promise.reject(new Error(`loadFile: ext '${s}' is a trajectory and must be loaded into a structure component`)):tt(e,i),n.then((e=>{this.log(`loaded '${r}'`);const t=this.addComponentFromObject(e,i);return i.defaultRepresentation&&this.defaultFileRepresentation(t),this.tasks.decrement(),t}),(e=>{this.tasks.decrement();const t=`error loading file: '${e}'`;throw this.log(t),t}))}loadScript(e){const t=Je(e).name;return this.log(`loading script '${t}'`),tt(e).then((e=>{this.tasks.increment(),this.log(`running script '${t}'`),e.run(this).then((()=>{this.tasks.decrement(),this.log(`finished script '${t}'`)})),this.log(`called script '${t}'`)}),(e=>{this.tasks.decrement();const i=`errored script '${t}' "${e}"`;throw this.log(i),i}))}addComponent(e){e?(this.compList.push(e),this.signals.componentAdded.dispatch(e)):Be.warn("Stage.addComponent: no component given")}addComponentFromObject(e,t={}){const i=Ue.get(e.type);if(i){const r=new i(this,e,t);return this.addComponent(r),r}Be.warn("no component for object type",e.type)}removeComponent(e){const t=this.compList.indexOf(e);-1!==t&&(this.compList.splice(t,1),e.dispose(),this.signals.componentRemoved.dispatch(e))}removeAllComponents(){this.compList.slice().forEach((e=>this.removeComponent(e)))}handleResize(){this.viewer.handleResize()}setSize(e,t){const i=this.viewer.container;i!==document.body&&(void 0!==e&&(i.style.width=e),void 0!==t&&(i.style.height=t),this.handleResize())}toggleFullscreen(e){if(!(document.fullscreenEnabled||document.mozFullScreenEnabled||document.webkitFullscreenEnabled||document.msFullscreenEnabled))return void Be.log("fullscreen mode (currently) not possible");const t=this;function i(){return document.fullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement||document.msFullscreenElement}function r(){if(!i()&&t.lastFullscreenElement){const e=t.lastFullscreenElement;e.style.width=e.dataset.normalWidth||"",e.style.height=e.dataset.normalHeight||"",document.removeEventListener("fullscreenchange",r),document.removeEventListener("mozfullscreenchange",r),document.removeEventListener("webkitfullscreenchange",r),document.removeEventListener("MSFullscreenChange",r),t.handleResize(),t.signals.fullscreenChanged.dispatch(!1)}}e=e||this.viewer.container,this.lastFullscreenElement=e,i()?document.exitFullscreen?document.exitFullscreen():document.msExitFullscreen?document.msExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen&&document.webkitExitFullscreen():(e.dataset.normalWidth=e.style.width||"",e.dataset.normalHeight=e.style.height||"",e.style.width=window.screen.width+"px",e.style.height=window.screen.height+"px",e.requestFullscreen?e.requestFullscreen():e.msRequestFullscreen?e.msRequestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.webkitRequestFullscreen&&e.webkitRequestFullscreen(),document.addEventListener("fullscreenchange",r),document.addEventListener("mozfullscreenchange",r),document.addEventListener("webkitfullscreenchange",r),document.addEventListener("MSFullscreenChange",r),this.handleResize(),this.signals.fullscreenChanged.dispatch(!0),setTimeout((function(){t.handleResize()}),100))}setSpin(e){e?(this.spinAnimation.resume(!0),this.rockAnimation.pause(!0)):this.spinAnimation.pause(!0)}setRock(e){e?(this.rockAnimation.resume(!0),this.spinAnimation.pause(!0)):this.rockAnimation.pause(!0)}toggleSpin(){this.setSpin(this.spinAnimation.paused)}toggleRock(){this.setRock(this.rockAnimation.paused)}getFocus(){const e=this.parameters;if("scene"!==e.clipMode)return 0;let t=e.clipNear;return"absolute"===e.clipScale&&(t=this.viewer.absoluteToRelative(t)),2*t}setFocus(e){if("scene"!==this.parameters.clipMode)return;let t,i,r,s;"relative"===this.parameters.clipScale?(t=$(e/2,0,49.9),i=100-t,r=50,s=function(e){return $(e,0,100)}(2*i-50)):(t=this.viewer.relativeToAbsolute(e/2),i=t,r=0,s=2*i),this.setParameters({clipNear:t,clipFar:i,fogNear:r,fogFar:s})}getZoomForBox(e){const t=e.getSize(Sc),i=Math.max(t.x,t.y,t.z),r=Math.min(t.x,t.y,t.z);let s=i+Math.sqrt(r);const n=T(this.viewer.perspectiveCamera.fov),o=this.viewer.width,a=this.viewer.height,c=a{this.tasks.onZeroOnce((()=>{this.tasks.increment(),this.viewer.makeImage(e).then((e=>{this.tasks.decrement(),t(e)})).catch((e=>{this.tasks.decrement(),i(e)}))}))}))}setImpostor(e){this.parameters.impostor=e;const t=["spacefill","ball+stick","licorice","hyperball","backbone","rocket","helixorient","contact","distance","dot"];this.eachRepresentation((function(i){if(!t.includes(i.getType()))return;const r=i.getParameters();r.disableImpostor=!e,i.build(r)}))}setQuality(e){this.parameters.quality=e;const t=["tube","cartoon","ribbon","trace","rope"],i=["spacefill","ball+stick","licorice","hyperball","backbone","rocket","helixorient","contact","distance","dot"];this.eachRepresentation((function(r){const s=r.getParameters();if(!t.includes(r.getType())){if(!i.includes(r.getType()))return;if(!s.disableImpostor)return void(r.repr.quality=e)}s.quality=e,r.build(s)}))}eachComponent(e,t){this.compList.slice().forEach((i=>{void 0!==t&&t!==i.type||e(i)}))}eachRepresentation(e,t){this.eachComponent((i=>{i.reprList.slice().forEach((r=>{void 0!==t&&t!==r.getType()||e(r,i)}))}))}getComponentsByName(e){const t=[];return this.eachComponent((i=>{(void 0===e||_c(e,i))&&t.push(i)})),new Ac(t)}getComponentsByObject(e){const t=[];return this.eachComponent((i=>{i.object===e&&t.push(i)})),new Ac(t)}getRepresentationsByName(e){const t=[];return this.eachRepresentation(((i,r)=>{(void 0===e||_c(e,i))&&t.push(i)})),new ec(t)}measureClear(){this.eachComponent((e=>e.measureClear()),"structure")}measureUpdate(){this.eachComponent((e=>e.measureUpdate()),"structure")}dispose(){this.tasks.dispose(),this.viewer.dispose(),this.mouseObserver.dispose()}},e.StaticDatasource=class extends Dp{constructor(e=""){super(),this.baseUrl=e}getUrl(e){const t=Je(e);let i=this.baseUrl+t.path;return Np.test(this.baseUrl)||(i=function(e){const t=window.location,i=t.pathname,r=i.substring(0,i.lastIndexOf("/")+1);return t.origin+r+e}(i)),i}getExt(e){return Je(e).ext}},e.StlWriter=class extends it{constructor(e){super(),this.mimeType="application/vnd.ms-pki.stl",this.defaultName="surface",this.defaultExt="stl",this.surface=e}getData(){const e=this.surface.index.length/3,i=new st(2*e+3*e*4*4+80+4);i.skip(80),i.writeUint32(e);const r=new t.Vector3,s=new t.Vector3,n=new t.Vector3,o=new t.Vector3;for(let t=0;t{e.eachAtom((e=>{n.growIfFull(),n.atomTypeId[c]=o.add(e.atomname,e.element),n.x[c]=e.x,n.y[c]=e.y,n.z[c]=e.z,n.serial[c]=e.serial,n.formalCharge[c]=e.formalCharge,n.partialCharge[c]=e.partialCharge,n.altloc[c]=e.altloc,n.occupancy[c]=e.occupancy,n.bfactor[c]=e.bfactor,s.addAtom(e.modelIndex+h,e.chainname,e.chainid,e.resname,e.resno,1===e.hetero,e.sstruc,e.inscode),a[e.index+l]=c,c+=1})),l+=e.atomStore.count,h+=e.modelStore.count}));const u=r.bondStore,d=r.getAtomProxy(),m=r.getAtomProxy();return l=0,i.forEach((e=>{e.eachBond((e=>{d.index=a[e.atomIndex1+l],m.index=a[e.atomIndex2+l],u.addBond(d,m,e.bondOrder)})),l+=e.atomStore.count})),s.finalize(),zo(r,!0),No(r,!0),r.finalizeAtoms(),r.finalizeBonds(),Ho(r),e.Debug&&Be.timeEnd("concatStructures"),r},e.download=f,e.flatten=function e(t,i){i=l(i,[]);for(let r=0;rt?(o&&(clearTimeout(o),o=null),a=l,n=e.apply(r,s),o||(r=s=null)):o||!1===i.trailing||(o=setTimeout(c,h)),n}},e.uniqueArray=x,Object.defineProperty(e,"__esModule",{value:!0})})); + */class bo{constructor(e,t){this.points=e,this.metric=t,this.maxDepth=0,this.currentNode=0;const i=e.length/3,r=new Uint32Array(i);for(let e=0;ethis.maxDepth&&(this.maxDepth=e);const s=r-i;if(0===s)return-1;const n=4*this.currentNode,o=this.nodes;if(this.currentNode+=1,1===s)return o[n]=i,o[n+1]=-1,o[n+2]=-1,o[n+3]=t,n;const a=this.indices,c=this.points,l=i+Math.floor(s/2),h=e%3;let u,d,m,p,f,g=i,y=r-1;for(;y>g;){for(m=g+y>>1,p=c[3*a[m]+h],d=a[m],a[m]=a[y],a[y]=d,f=g,u=g;u-e[1])),s=this.nodes,n=this.points,o=this.indices,a=c=>{let l,h;const u=this.getNodeDepth(c)%3,d=3*o[s[c]],m=[n[d+0],n[d+1],n[d+2]],p=this.metric(e,m);function f(e,i){r.push([e,i]),r.size()>t&&r.pop()}const g=s[c+1],y=s[c+2];if(-1===y&&-1===g)return void((r.size()n[3*o[s[e]]+r])throw new Error("left child is > parent!");i+=this.verify(a,t+1)}if(-1!==c){if(n[3*o[s[c]]+r]0}isBackbone(){const e=this.residueType.backboneIndexList;return e.length>0&&e.includes(this.index-this.residueAtomOffset)}isPolymer(){if(this.structure.entityList.length>0)return this.entity.isPolymer();{const e=this.residueType.moleculeType;return 3===e||4===e||5===e}}isSidechain(){return this.isPolymer()&&!this.isBackbone()}isCg(){const e=this.residueType.backboneType;return 4===e||5===e||6===e}isTrace(){return this.index===this.residueType.traceAtomIndex+this.residueAtomOffset}isHetero(){return 1===this.residueType.hetero}isProtein(){return 3===this.residueType.moleculeType}isNucleic(){const e=this.residueType.moleculeType;return 4===e||5===e}isRna(){return 4===this.residueType.moleculeType}isDna(){return 5===this.residueType.moleculeType}isWater(){return 1===this.residueType.moleculeType}isIon(){return 2===this.residueType.moleculeType}isSaccharide(){return 6===this.residueType.moleculeType}isHelix(){return $r.includes(this.sstruc)}isSheet(){return Fr.includes(this.sstruc)}isTurn(){return Er.includes(this.sstruc)&&this.isProtein()}isBonded(){return 0!==this.bondHash.countArray[this.index]}isRing(){return void 0!==this.residueType.getRings().atomRings[this.index-this.residueAtomOffset]}isAromatic(){return 1===this.aromatic}isPolarHydrogen(){let e=!1;return 1!==this.number||(e=!this.hasBondToElement(6)),e}isMetal(){return this.atomType.isMetal()}isNonmetal(){return this.atomType.isNonmetal()}isMetalloid(){return this.atomType.isMetalloid()}isHalogen(){return this.atomType.isHalogen()}isDiatomicNonmetal(){return this.atomType.isDiatomicNonmetal()}isPolyatomicNonmetal(){return this.atomType.isPolyatomicNonmetal()}isAlkaliMetal(){return this.atomType.isAlkaliMetal()}isAlkalineEarthMetal(){return this.atomType.isAlkalineEarthMetal()}isNobleGas(){return this.atomType.isNobleGas()}isTransitionMetal(){return this.atomType.isTransitionMetal()}isPostTransitionMetal(){return this.atomType.isPostTransitionMetal()}isLanthanide(){return this.atomType.isLanthanide()}isActinide(){return this.atomType.isActinide()}getDefaultValence(){return this.atomType.getDefaultValence()}getValenceList(){return this.atomType.getValenceList()}getOuterShellElectronCount(){return this.atomType.getOuterShellElectronCount()}distanceTo(e){const t=this.atomStore,i=e.atomStore,r=this.index,s=e.index,n=t.x[r]-i.x[s],o=t.y[r]-i.y[s],a=t.z[r]-i.z[s],c=n*n+o*o+a*a;return Math.sqrt(c)}connectedTo(e){const t=this.atomStore,i=e.atomStore,r=this.index,s=e.index;if(t.altloc&&i.altloc){const e=t.altloc[r],n=i.altloc[s];if(0!==e&&0!==n&&32!==e&&32!==n&&e!==n)return!1}const n=t.x[r]-i.x[s],o=t.y[r]-i.y[s],a=t.z[r]-i.z[s],c=n*n+o*o+a*a;if(c<48&&this.isCg())return!0;if(isNaN(c))return!1;const l=this.covalent+e.covalent,h=l+.3,u=l-.5;return cu*u}positionFromArray(e,t=0){return this.x=e[t+0],this.y=e[t+1],this.z=e[t+2],this}positionToArray(e=[],t=0){const i=this.index,r=this.atomStore;return e[t+0]=r.x[i],e[t+1]=r.y[i],e[t+2]=r.z[i],e}positionToVector3(e){return void 0===e&&(e=new t.Vector3),e.x=this.x,e.y=this.y,e.z=this.z,e}positionFromVector3(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}positionAdd(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}positionSub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}getResidueBonds(e=!1){const t=this.residueAtomOffset,i=this.index-this.residueAtomOffset,r=this.residueType.getBonds(),s=r.atomIndices1,n=r.atomIndices2;let o,a,c,l;for(e||(l=[]),o=s.indexOf(i);-1!==o;){if(c=n[o]+t,!l)return c;l.push(c),o=s.indexOf(i,o+1)}for(a=n.indexOf(i);-1!==a;){if(c=s[a]+t,!l)return c;l.push(c),a=n.indexOf(i,a+1)}return l}qualifiedName(e=!1){var t="";return this.resname&&!e&&(t+="["+this.resname+"]"),void 0!==this.resno&&(t+=this.resno),this.inscode&&(t+="^"+this.inscode),this.chainname&&(t+=":"+this.chainname),this.atomname&&(t+="."+this.atomname),this.altloc&&(t+="%"+this.altloc),this.structure.modelStore.count>1&&(t+="/"+this.modelIndex),t}clone(){return new xo(this.structure,this.index)}toObject(){return{index:this.index,residueIndex:this.residueIndex,resname:this.resname,x:this.x,y:this.y,z:this.z,element:this.element,chainname:this.chainname,resno:this.resno,serial:this.serial,vdw:this.vdw,covalent:this.covalent,hetero:this.hetero,bfactor:this.bfactor,altloc:this.altloc,atomname:this.atomname,modelIndex:this.modelIndex}}}function vo(e,t){const i=e[0]-t[0],r=e[1]-t[1],s=e[2]-t[2];return i*i+r*r+s*s}function wo(e,t){return Math.sqrt(vo(e,t))}const Ao=new Float32Array(3);class _o{constructor(t,i=!1){e.Debug&&Be.time("Kdtree build");const r=i?vo:wo,s=new Float32Array(3*t.atomCount),n=new Uint32Array(t.atomCount);let o=0;t.eachAtom((function(e){s[o+0]=e.x,s[o+1]=e.y,s[o+2]=e.z,n[o/3]=e.index,o+=3})),this.atomIndices=n,this.points=s,this.kdtree=new bo(s,r),e.Debug&&Be.timeEnd("Kdtree build")}nearest(e,i,r){e instanceof t.Vector3?e.toArray(Ao):e instanceof xo&&e.positionToArray(Ao);const s=this.kdtree.nearest(Ao,i,r),n=this.kdtree.indices,o=this.kdtree.nodes,a=this.atomIndices,c=[];for(let e=0,t=s.length;e":"3/4-Z","?":"X-Y","@":"Y-X",A:"Z+1/3",B:"Z+2/3",C:"X+2/3",D:"Y+1/3",E:"-Y+2/3",F:"X-Y+1/3",G:"Y-X+2/3",H:"-X+1/3",I:"X+1/3",J:"Y+2/3",K:"-Y+1/3",L:"X-Y+2/3",M:"Y-X+1/3",N:"-X+2/3",O:"2/3+X",P:"1/3+Y",Q:"1/3+Z",R:"2/3-Y",S:"1/3+X-Y",T:"2/3+Y-X",U:"1/3-X",V:"2/3-X",W:"1/3-Y",X:"1/3-Z",Y:"2/3+Y",Z:"1/3+Y-X","[":"2/3+X-Y","]":"1/3+X","^":"2/3+Z",_:"2/3-Z","`":"5/6+Z",a:"1/6+Z",b:"5/6-Z",c:"1/6-Z",d:"Z+5/6",e:"Z+1/6",f:"Z+1/4",g:"+Y"},Co={"P 1":" !#","P -1":" !#$%&","P 1 2 1":" !#$!&","P 1 21 1":" !#$'&","C 1 2 1":" !#$!&()#*)&","P 1 m 1":" !# %#","P 1 c 1":" !# %+","C 1 m 1":" !# %#()#(,#","C 1 c 1":" !# %+()#(,+","P 1 2/m 1":" !# %#$!&$%&","P 1 21/m 1":" !#$)&$%& ,#","C 1 2/m 1":" !# %#$!&$%&()#(,#*)&*,&","P 1 2/c 1":" !#$!-$%& %+","P 1 21/c 1":" !#$%&$)- ,+","C 1 2/c 1":" !#$!-$%& %+()#*)-*,&(,+","P 2 2 2":" !#$%#$!& %&","P 2 2 21":" !#$%+$!- %&","P 21 21 2":" !#$%#*)&(,&","P 21 21 21":" !#*%+$)-(,&","C 2 2 21":" !#$%+$!- %&()#*,+*)-(,&","C 2 2 2":" !#$%#$!& %&()#*,#*)&(,&","F 2 2 2":" !#$%#$!& %& )+$,+$)- ,-(!+*%+*!-(%-()#*,#*)&(,&","I 2 2 2":" !#$%# %&$!&.'/01/.120'2","I 21 21 21":" !#*%+$)-(,&()+$,#*!& %-","P m m 2":" !#$%# %#$!#","P m c 21":" !#$%+ %+$!#","P c c 2":" !#$%# %+$!+","P m a 2":" !#$%#(%#*!#","P c a 21":" !#$%+(%#*!+","P n c 2":" !#$%# ,+$)+","P m n 21":" !#*%+(%+$!#","P b a 2":" !#$%#(,#*)#","P n a 21":" !#$%+(,#*)+","P n n 2":" !#$%#(,+*)+","C m m 2":" !#$%# %#$!#()#*,#(,#*)#","C m c 21":" !#$%+ %+$!#()#*,+(,+*)#","C c c 2":" !#$%# %+$!+()#*,#(,+*)+","A m m 2":" !#$%# %#$!# )+$,+ ,+$)+","A b m 2":" !#$%# ,#$)# )+$,+ %+$!+","A m a 2":" !#$%#(%#*!# )+$,+(,+*)+","A b a 2":" !#$%#(,#*)# )+$,+(%+*!+","F m m 2":" !#$%# %#$!# )+$,+ ,+$)+(!+*%+(%+*!+()#*,#(,#*)#","F d d 2":" !#$%#345675 )+$,+3896:9(!+*%+;49<79()#*,#;85<:5","I m m 2":" !#$%# %#$!#()+*,+(,+*)+","I b a 2":" !#$%#(,#*)#()+*,+ %+$!+","I m a 2":" !#$%#(%#*!#()+*,+ ,+$)+","P 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!#","P 2/n 2/n 2/n":" !#$%#$!& %&*,-()-(,+*)+","P 2/c 2/c 2/m":" !#$%#$!- %-$%& !& %+$!+","P 2/b 2/a 2/n":" !#$%#$!& %&*,&()&(,#*)#","P 21/m 2/m 2/a":" !#*%#$!&(%&$%&(!& %#*!#","P 2/n 21/n 2/a":" !#*%#*)- ,-$%&(!&(,+$)+","P 2/m 2/n 21/a":" !#*%+*!- %&$%&(!-(%+$!#","P 21/c 2/c 2/a":" !#*%#$!-(%-$%&(!& %+*!+","P 21/b 21/a 2/m":" !#$%#*)&(,&$%& !&(,#*)#","P 21/c 21/c 2/n":" !#*,#$)-(%-$%&()& ,+*!+","P 2/b 21/c 21/m":" !#$%+$)- ,&$%& !- ,+$)#","P 21/n 21/n 2/m":" !#$%#*)-(,-$%& !&(,+*)+","P 21/m 21/m 2/n":" !#$%#*'&.,&*,&.'& %#$!#","P 21/b 2/c 21/n":" !#*,+$!-(,&$%&()- %+*)#","P 21/b 21/c 21/a":" !#*%+$)-(,&$%&(!- ,+*)#","P 21/n 21/m 21/a":" !#0%/$'&.12$%&.!2 1#0'/","C 2/m 2/c 21/m":" !#$%+$!- %&$%& !- %+$!#()#*,+*)-(,&*,&()-(,+*)#","C 2/m 2/c 21/a":" !#$,+$)- %&$%& )- ,+$!#()#*%+*!-(,&*,&(!-(%+*)#","C 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!#()#*,#*)&(,&*,&()&(,#*)#","C 2/c 2/c 2/m":" !#$%#$!- %-$%& !& %+$!+()#*,#*)-(,-*,&()&(,+*)+","C 2/m 2/m 2/a":" !#$,#$)& %&$%& )& ,#$!#()#*%#*!&(,&*,&(!&(%#*)#","C 2/c 2/c 2/a":" !#*,#$!&(,&$,-(!- ,+*!+()#$%#*)& %&*%- )-(%+$)+","F 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!# )+$,+$)- ,-$,- )- ,+$)+(!+*%+*!-(%-*%-(!-(%+*!+()#*,#*)&(,&*,&()&(,#*)#","F 2/d 2/d 2/d":" !#$%#$!& %&64=37=345675 )+$,+$)- ,-68>3:>3896:9(!+*%+*!-(%-<4>;7>;49<79()#*,#*)&(,&<8=;:=;85<:5","I 2/m 2/m 2/m":" !#$%#$!& %&$%& !& %#$!#()+*,+*)-(,-*,-()-(,+*)+","I 2/b 2/a 2/m":" !#$%#*)&(,&$%& !&(,#*)#()+*,+$!- %-*,-()- %+$!+","I 21/b 21/c 21/a":" !#*%+$)-(,&$%&(!- ,+*)#()+$,#*!& %-*,- )&(%#$!+","I 21/m 21/m 21/a":" !#$,#$)& %&$%& )& ,#$!#()+*%+*!-(,-*,-(!-(%+*)+","P 4":" !#$%#% #!$#","P 41":" !#$%+% 5!$9","P 42":" !#$%#% +!$+","P 43":" !#$%+% 9!$5","I 4":" !#$%#% #!$#()+*,+,(+)*+","I 41":" !#*,+%(5)$9()+$%#, 9!*5","P -4":" !#$%#!$&% &","I -4":" !#$%#!$&% &()+*,+)*-,(-","P 4/m":" !#$%#% #!$#$%& !&!$&% &","P 42/m":" !#$%#% +!$+$%& !&!$-% -","P 4/n":" !#$%#,(#)*#*,&()&!$&% &","P 42/n":" !#$%#,(+)*+*,-()-!$&% &","I 4/m":" !#$%#% #!$#$%& !&!$&% &()+*,+,(+)*+*,-()-)*-,(-","I 41/a":" !#*,+%(5)$9$,=(!>!$&,(-()+$%#, 9!*5*%> )=)*-% &","P 4 2 2":" !#$%#% #!$#$!& %&! &%$&","P 4 21 2":" !#$%#,(#)*#*)&(,&! &%$&","P 41 2 2":" !#$%+% 5!$9$!& %-! >%$=","P 41 21 2":" !#$%+,(5)*9*)=(,>! &%$-","P 42 2 2":" !#$%#% +!$+$!& %&! -%$-","P 42 21 2":" !#$%#,(+)*+*)-(,-! &%$&","P 43 2 2":" !#$%+% 9!$5$!& %-! =%$>","P 43 21 2":" !#$%+,(9)*5*)>(,=! &%$-","I 4 2 2":" !#$%#% #!$#$!& %&! &%$&()+*,+,(+)*+*)-(,-)(-,*-","I 41 2 2":" !#*,+%(5)$9*!> ,=)(-%$&()+$%#, 9!*5$)=(%>! &,*-","P 4 m m":" !#$%#% #!$# %#$!#%$#! #","P 4 b m":" !#$%#% #!$#(,#*)#,*#)(#","P 42 c m":" !#$%#% +!$+ %+$!+%$#! #","P 42 n m":" !#$%#,(+)*+(,+*)+%$#! #","P 4 c c":" !#$%#% #!$# %+$!+%$+! +","P 4 n c":" !#$%#% #!$#(,+*)+,*+)(+","P 42 m c":" !#$%#% +!$+ %#$!#%$+! +","P 42 b c":" !#$%#% +!$+(,#*)#,*+)(+","I 4 m m":" !#$%#% #!$# %#$!#%$#! #()+*,+,(+)*+(,+*)+,*+)(+","I 4 c m":" !#$%#% #!$# %+$!+%$+! +()+*,+,(+)*+(,#*)#,*#)(#","I 41 m d":" !#*,+%(5)$9 %#*)+%*5) 9()+$%#, 9!*5(,+$!#,$9!(5","I 41 c d":" !#*,+%(5)$9 %+*)#%*9) 5()+$%#, 9!*5(,#$!+,$5!(9","P -4 2 m":" !#$%#% &!$&$!& %&%$#! #","P -4 2 c":" !#$%#% &!$&$!- %-%$+! +","P -4 21 m":" !#$%#% &!$&*)&(,&,*#)(#","P -4 21 c":" !#$%#% &!$&*)-(,-,*+)(+","P -4 m 2":" !#$%#!$&% & %#$!#! &%$&","P -4 c 2":" !#$%#% &!$& %+$!+! -%$-","P -4 b 2":" !#$%#% &!$&(,#*)#)(&,*&","P -4 n 2":" !#$%#% &!$&(,+*)+)(-,*-","I -4 m 2":" !#$%#% &!$& %#$!#! &%$&()+*,+,(-)*-(,+*)+)(-,*-","I -4 c 2":" !#$%#% &!$& %+$!+! -%$-()+*,+,(-)*-(,#*)#)(&,*&","I -4 2 m":" !#$%#% &!$&$!& %&%$#! #()+*,+,(-)*-*)-(,-,*+)(+","I -4 2 d":" !#$%#% &!$&*!>(%>,$9) 9()+*,+,(-)*-$)= ,=%*5!(5","P 4/m 2/m 2/m":" !#$%#% #!$#$!& %&! &%$&$%& !&!$&% & %#$!#%$#! #","P 4/m 2/c 2/c":" !#$%#% #!$#$!- %-! -%$-$%& !&!$&% & %+$!+%$+! +","P 4/n 2/b 2/m":" !#$%#% #!$#$!& %&! &%$&*,&()&)*&,(&(,#*)#,*#)(#","P 4/n 2/n 2/c":" !#$%#% #!$#$!& %&! &%$&*,-()-)*-,(-(,+*)+,*+)(+","P 4/m 21/b 2/m":" !#$%#% #!$#*)&(,&)(&,*&$%& !&!$&% &(,#*)#,*#)(#","P 4/m 21/n 2/c":" !#$%#% #!$#*)-(,-)(-,*-$%& !&!$&% &(,+*)+,*+)(+","P 4/n 21/m 2/m":" !#$%#,(#)*#*)&(,&! &%$&*,&()&!$&% & %#$!#,*#)(#","P 4/n 2/c 2/c":" !#$%#,(#)*#*)-(,-! -%$-*,&()&!$&% & %+$!+,*+)(+","P 42/m 2/m 2/c":" !#$%#% +!$+$!& %&! -%$-$%& !&!$-% - %#$!#%$+! +","P 42/m 2/c 2/m":" !#$%#% +!$+$!- %-! &%$&$%& !&!$-% - %+$!+%$#! #","P 42/n 2/b 2/c":" !#$%#,(+)*+$!- %-)(&,*&*,-()-!$&% &(,#*)#%$+! +","P 42/n 2/n 2/m":" !#$%#,(+)*+$!& %&)(-,*-*,-()-!$&% &(,+*)+%$#! #","P 42/m 21/b 2/c":" !#$%#% +!$+*)&(,&)(-,*-$%& !&!$-% -(,#*)#,*+)(+","P 42/m 21/n 2/m":" !#$%#,./'*/*'-.,-! &%$&$%& !&'*-,.-.,/*'/%$#! #","P 42/n 21/m 2/c":" !#$%#,(+)*+*)-(,-! &%$&*,-()-!$&% & %#$!#,*+)(+","P 42/n 21/c 2/m":" !#$%#,(+)*+*)&(,&! -%$-*,-()-!$&% & %+$!+,*#)(#","I 4/m 2/m 2/m":" !#$%#% #!$#$!& %&! &%$&$%& !&!$&% & %#$!#%$#! #()+*,+,(+)*+*)-(,-)(-,*-*,-()-)*-,(-(,+*)+,*+)(+","I 4/m 2/c 2/m":" !#$%#% #!$#$!- %-! -%$-$%& !&!$&% & %+$!+%$+! +()+*,+,(+)*+*)&(,&)(&,*&*,-()-)*-,(-(,#*)#,*#)(#","I 41/a 2/m 2/d":" !#*,+%(5)$9*!> ,=)(-%$&$,=(!>!$&,(-(,+$!#,$9!(5()+$%#, 9!*5$)=(%>! &,*-*%> )=)*-% & %#*)+%*5) 9","I 41/a 2/c 2/d":" !#*,+%(5)$9*!= ,>)(&%$-$,=(!>!$&,(-(,#$!+,$5!(9()+$%#, 9!*5$)>(%=! -,*&*%> )=)*-% & %+*)#%*9) 5","P 3":" !#%?#@$#","P 31":" !#%?A@$B","P 32":" !#%?B@$A","H 3":" !#%?#@$#CDAEFAGHAIJBKLBMNB","R 3":" !## !!# ","P -3":" !#%?#@$#$%&!@&? &","H -3":" !#%?#@$#$%&!@&? &OPQRSQTUQVWXYZX[]X]Y^W[^ZV^UR_PT_SO_","R -3":" !## !!# $%&&$%%&$","P 3 1 2":" !#%?#@$#%$&@!& ?&","P 3 2 1":" !#%?#@$#! &?%&$@&","P 31 1 2":" !#%?Q@$^%$_@!X ?&","P 31 2 1":" !#%?A@$B! &?%_$@X","P 32 1 2":" !#%?^@$Q%$X@!_ ?&","P 32 2 1":" !#%?B@$A! &?%X$@_","H 3 2":" !#%?#@$#! &?%&$@&OPQRSQTUQY]X[WXVZX]Y^W[^ZV^PO_SR_UT_","R 3 2":" !## !!# %$&$&%&%$","P 3 m 1":" !#%?#@$#%$#@!# ?#","P 3 1 m":" !#%?#@$#! #?%#$@#","P 3 c 1":" !#%?#@$#%$+@!+ ?+","P 3 1 c":" !#%?#@$#! +?%+$@+","H 3 m":" !#%?#@$#%$#@!# ?#OPQRSQTUQRUQTPQOSQ]Y^W[^ZV^WV^ZY^][^","R 3 m":" !## !!# ! # #!#! ","H 3 c":" !#%?#@$#%$+@!+ ?+OPQRSQTUQRU`TP`OS`]Y^W[^ZV^WVaZYa][a","R 3 c":" !## !!# '././'/'.","P -3 1 2/m":" !#%?#@$#%$&@!& ?&$%&!@&? &! #?%#$@#","P -3 1 2/c":" !#%?#@$#%$-@!- ?-$%&!@&? &! +?%+$@+","P -3 2/m 1":" !#%?#@$#! &?%&$@&$%&!@&? &%$#@!# ?#","P -3 2/c 1":" !#%?#@$#! -?%-$@-$%&!@&? &%$+@!+ ?+","H -3 2/m":" !#%?#@$#! &?%&$@&$%&!@&? &%$#@!# ?#OPQRSQTUQY]X[WXVZXVWXYZX[]XRUQTPQOSQ]Y^W[^ZV^PO_SR_UT_UR_PT_SO_WV^ZY^][^","R -3 2/m":" !## !!# %$&$&%&%$$%&&$%%&$! # #!#! ","H -3 2/c":" !#%?#@$#! -?%-$@-$%&!@&? &%$+@!+ ?+OPQRSQTUQY]b[WbVZbVWXYZX[]XRU`TP`OS`]Y^W[^ZV^POcSRcUTcUR_PT_SO_WVaZYa][a","R -3 2/c":" !## !!# 102021210$%&&$%%&$'././'/'.","P 6":" !#%?#@$#$%#!@#? #","P 61":" !#%?A@$B$%/!@d? e","P 65":" !#%?B@$A$%/!@e? d","P 62":" !#%?^@$Q$%#!@^? Q","P 64":" !#%?Q@$^$%#!@Q? ^","P 63":" !#%?#@$#$%+!@+? +","P -6":" !#%?#@$# !&%?&@$&","P 6/m":" !#%?#@$#$%#!@#? #$%&!@&? & !&%?&@$&","P 63/m":" !#%?#@$#$%+!@+? +$%&!@&? & !-%?-@$-","P 6 2 2":" !#%?#@$#$%#!@#? #! &?%&$@&%$&@!& ?&","P 61 2 2":" !#%?Q@$^$%+!@`? a! X?%&$@_%$b@!- ?c","P 65 2 2":" !#%?^@$Q$%+!@a? `! _?%&$@X%$c@!- ?b","P 62 2 2":" !#%?^@$Q$%#!@^? Q! _?%&$@X%$_@!& ?X","P 64 2 2":" !#%?Q@$^$%#!@Q? ^! X?%&$@_%$X@!& ?_","P 63 2 2":" !#%?#@$#$%+!@+? +! &?%&$@&%$-@!- ?-","P 6 m m":" !#%?#@$#$%#!@#? #%$#@!# ?#! #?%#$@#","P 6 c c":" !#%?#@$#$%#!@#? #%$+@!+ ?+! +?%+$@+","P 63 c m":" !#%?#@$#$%+!@+? +%$+@!+ ?+! #?%#$@#","P 63 m c":" !#%?#@$#$%+!@+? +%$#@!# ?#! +?%+$@+","P -6 m 2":" !#%?#@$# !&%?&@$&%$#@!# ?#%$&@!& ?&","P -6 c 2":" !#%?#@$# !-%?-@$-%$+@!+ ?+%$&@!& ?&","P -6 2 m":" !#%?#@$# !&%?&@$&! &?%&$@&! #?%#$@#","P -6 2 c":" !#%?#@$# !-%?-@$-! &?%&$@&! +?%+$@+","P 6/m 2/m 2/m":" !#%?#@$#$%#!@#? #! &?%&$@&%$&@!& ?&$%&!@&? & !&@$&%?&%$#@!# ?#! #?%#$@#","P 6/m 2/c 2/c":" !#%?#@$#$%#!@#? #! -?%-$@-%$-@!- ?-$%&!@&? & !&@$&%?&%$+@!+ ?+! +?%+$@+","P 63/m 2/c 2/m":" !#%?#@$#$%+!@+? +! -?%-$@-%$&@!& ?&$%&!@&? & !-@$-%?-%$+@!+ ?+! #?%#$@#","P 63/m 2/m 2/c":" !#%?#@$#$%+!@+? +! &?%&$@&%$-@!- ?-$%&!@&? & !-@$-%?-%$#@!# ?#! +?%+$@+","P 2 3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ","F 2 3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ","I 2 3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-(","P 21 3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(","I 21 3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- ","P 2/m -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$","P 2/n -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& *,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*","F 2/m -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$ )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-($,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(*%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- *,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$","F 2/d -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& 64=37=345675=64=375345674=67=3453756 )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(68>3:>3896:9=<8=;:5;85<:4><7>;49;79<(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(<4>;7>;49<79>68>3:93896:8=<:=;85;:5<()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- <8=;:=;8f<:f><4>;79;49<78>6:>3893:96","I 2/m -3":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-(*,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*","P 21/a -3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&($%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*","I 21/a -3":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&($%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*()+$,#*g& %-+()#$,&*!- %)+(,#$!&*%- *,- )&(%#$!+-*,& )#(%+$!,-*)& %#(!+$","P 4 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$","P 42 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*","F 4 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$ )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(-%*-!*+%(+ +,$+)$-, -)#)*#,(&)(&,*(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() -,$-)$+, +(#,*#)*&,(&)+!*+%(-!(-%*()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(&,*&)*#,(#(+%*+!*-%(-!+)$+, -) -,$","F 41 3 2":" !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=46 )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<(!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>86","I 4 3 2":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*","P 43 3 2":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(7;>46=:<5839398<5:6=4;>75:<983>7;=46","P 41 3 2":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<","I 41 3 2":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- 7;>46=:<5839398<5:6=4;>75:<983>7;=46","P -4 3 m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% ","F -4 3 m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(+%*+!*-%(- +)$+,$-) -,#)(#,*&)*&,((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() +,$+)$-, -(#)*#,*&)(&,+!(+%*-!*-%(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(#,*#)*&,(&(+!*+%*-!(-%+) +,$-)$-, ","I -4 3 m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,(","P -4 3 n":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,(","F -4 3 c":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,( )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-() #,$#)$&, &(#!*#%*&!(&%+! +%$-!$-% (!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(!(#%*#!*&%(& +!$+%$-! -%#) #,$&)$&, ()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ! +%$+!$-% - #)$#,$&) &,#!(#%*&!*&%(","I -4 3 d":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(7354<9:6>8;=357<946>:;=857394<>:6=8;()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- :;98657<=43>;9:658<=73>49:;586=7<>43","P 4/m -3 2/m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ","P 4/n -3 2/n":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$*,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(","P 42/m -3 2/n":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(","P 42/n -3 2/m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,**,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ","F 4/m -3 2/m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(-%*-!*+%(+ +,$+)$-, -)#)*#,(&)(&,*$,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*%*+!(+%(-!*-$-) -, +)$+,&,(&)*#,*#)((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() -,$-)$+, +(#,*#)*&,(&)+!*+%(-!(-%**%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*,$+) +, -)$-*&)(&,(#)*#,-%(-!*+%*+!(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(&,*&)*#,(#(+%*+!*-%(-!+)$+, -) -,$*,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$,*#)(#,(&)*&*-!(-%(+!*+%-, -)$+,$+) ","F 4/m -3 2/c":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)( )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-() &,$&)$#, #(#%*#!*&%(&!+!$+% -! -%$$,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*,$#) #, &)$&*&!(&%(#!*#%-% -!$+%$+! (!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(!(&%*&!*#%(# +%$+!$-% -!#)$#, &) &,$*%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*%*#!(#%(&!*&$-! -% +!$+%&, &)$#,$#) ()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ! -%$-!$+% + #,$#)$&, &)#!*#%(&!(&%**,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$%$+! +% -!$-$&) &, #)$#,&%(&!*#%*#!(","F 41/d -3 2/m":" !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=4664=3:>;85<79=64>3:5;89<74=6:>385;79<,$+! #%(-)*&*&)(-% #!$+,-%(&)*+,$#! )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<68>37=;49<:5=<8>;753496:4><:=;893756,*#!(+% &)$-*-!(&, +)$#%-, &!$+%*#)((!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<<4>;:=389675>68=379;45<:8=<7>;453:96%$#) +,(&!*-$&! -,(#)*+%&% -)$#,*+!(()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>86<8=;7>3456:9><4=;:9385678>67=349;:5<%*+)(#, -!$&$-) &%(+!*#,&,(-!*#%$+) ","F 41/d -3 2/c":" !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=46<8>;7=3496:5><8=;793456:8><7=;493:56%*#)(+, &!$-$-! &,(+)*#%&, -!$#%*+)( )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<<4=;:>385679>64=3:9;85<78=67>345;:9<%$+) #,(-!*&$&) -%(#!*+,&%(-)*#,$+! (!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<68=37>;45<:9=<4>;:5389674>6:=389;75<,*+!(#% -)$&*-)(&% +!$#,-,(&!*+%$#) ()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>8664>3:=;89<75=68>375;49<:4=<:>;853796,$#! +%(&)*-*&!(-, #)$+%-% &)$+,*#!(","I 4/m -3 2/m":" !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,**,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(","I 41/a -3 2/d":" !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<$%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*4<97358;=:6>6>:;=8357<94=8;>:694<573()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- 7;>46=:<5839398<5:6=4;>75:<983>7;=46*,- )&(%#$!+-*,& )#(%+$!,-*)& %#(!+$865:;943>7<=<=73>4;9:658>43=7<5869:;","P 1 1 2":" !#$%#","P 1 1 21":" !#$%+","B 1 1 2":" !#$%#(g+*%+","A 1 2 1":" !#$!& )+$)-","C 1 21 1":" !#$)&()#*!&","I 1 2 1":" !#$!&.'/0'2","I 1 21 1":" !#$)&.'/0!-","P 1 1 m":" !# !&","P 1 1 b":" !# )&","B 1 1 m":" !# !&(!+(!-","B 1 1 b":" !# )&(!+()-","P 1 1 2/m":" !# !&$%#$%&","P 1 1 21/m":" !#$%+$%& !-","B 1 1 2/m":" !# !&$%#$%&(!+(!-*%+*%-","P 1 1 2/b":" !#$,#$%& )&","P 1 1 21/b":" !#$%&$,+ )-","B 1 1 2/b":" !#$,#$%& )&(!+*,+*%-()-","P 21 2 2":" !#$!&(%&*%#","P 2 21 2":" !# ,&$)&$%#","P 21 21 2 (a)":" !#*,#.%&$'&","P 21 2 21":" !#$!&(%-*%+","P 2 21 21":" !# %&$)-$,+","C 2 2 21a)":" !#*%+(,&$)-()#$,+ %&*!-","C 2 2 2a":" !#*,#.%&$'&()#$%# ,&*!&","F 2 2 2a":" !#*,#.%&$'& '/*%/.12$!2.!/$,/ %20'2.'#$%# 1&0!&","I 2 2 2a":" !#*,#.%&$'&()+$%+*!- ,-","P 21/m 21/m 2/n a":" !#*,#$)&(%&$%&.'& ,#*!#","P 42 21 2a":" !#*,#%.+'$+$'&.%&! -,*-","I 2 3a":" !#*,#.%&$'&!# ,- '&$%/$# !-*!/$%&.%()+$%+ ,-*!-)+(%&(!-*,#*+()&$)#*,- ,"},Po=/^[1-9]$/;function Io(e){let t="";return e.length>0&&(t=":"+x(e).join(" OR :")),new ye(t)}class ko{constructor(e=""){this.name=e,this.partList=[]}get type(){return"Assembly"}addPart(e,t){const i=new Mo(e,t);return this.partList.push(i),i}getAtomCount(e){return this.partList.reduce(((t,i)=>t+i.getAtomCount(e)),0)}getResidueCount(e){return this.partList.reduce(((t,i)=>t+i.getResidueCount(e)),0)}getInstanceCount(){let e=0;return this.partList.forEach((function(t){e+=t.matrixList.length})),e}isIdentity(e){if(1!==this.partList.length)return!1;const i=this.partList[0];if(1!==i.matrixList.length)return!1;if(!(new t.Matrix4).equals(i.matrixList[0]))return!1;let r=[];return e.eachChain((function(e){r.push(e.chainname)})),r=x(r),i.chainList.length===r.length}getBoundingBox(e){const i=new t.Box3;return this.partList.forEach((function(t){const r=t.getBoundingBox(e);i.expandByPoint(r.min),i.expandByPoint(r.max)})),i}getCenter(e){return this.getBoundingBox(e).getCenter(new t.Vector3)}getSelection(){let e=[];return this.partList.forEach((function(t){e=e.concat(t.chainList)})),Io(e)}}class Mo{constructor(e=[],t=[]){this.matrixList=e,this.chainList=t}get type(){return"AssemblyPart"}_getCount(e,t){let i=0;return e.eachChain((e=>{(0===this.chainList.length||this.chainList.includes(e.chainname))&&(i+=e[t])})),this.matrixList.length*i}getAtomCount(e){return this._getCount(e,"atomCount")}getResidueCount(e){return this._getCount(e,"residueCount")}getBoundingBox(e){const i=new t.Box3,r=new t.Box3,s=this.getSelection(),n=e.getBoundingBox(s);return this.matrixList.forEach((function(e){r.copy(n).applyMatrix4(e),i.expandByPoint(r.min),i.expandByPoint(r.max)})),i}getSelection(){return Io(this.chainList)}getView(e){const t=this.getSelection();return t?e.getView(t):e}getInstanceList(){const e=[];for(let t=0,i=this.matrixList.length;t0&&this.addResidueType(this.ri-1),l.growIfFull(),l.resno[this.ri]=s,void 0!==o&&(l.sstruc[this.ri]=o.charCodeAt(0)),void 0!==a&&(l.inscode[this.ri]=a.charCodeAt(0)),l.atomOffset[this.ri]=this.ai,l.atomCount[this.ri]=0,l.count+=1,l.chainIndex[this.ri]=this.ci,h.residueCount[this.ci]+=1),c.count+=1,c.residueIndex[this.ai]=this.ri,l.atomCount[this.ri]+=1,this.currentModelindex=e,this.currentChainid=i,this.currentResname=r,this.currentResno=s,this.currentInscode=a,this.currentHetero=n}finalize(){this.previousResname=this.currentResname,this.previousHetero=this.currentHetero,this.ri>-1&&this.addResidueType(this.ri)}}function To(t,i){if(!i)return;e.Debug&&Be.time("assignSecondaryStructure");const r=[];t.eachModel((function(e){e.eachChain((function(e){r.push(e.chainname)}))}));const s=r.slice().sort(),n=[];s.forEach((function(e){n.push(r.indexOf(e))}));const o=i.helices.filter((function(e){return y(s,e[0])>=0}));o.sort((function(e,t){const i=e[0],r=t[0],o=e[1],a=t[1];if(i===r)return o===a?0:o=0}));c.sort((function(e,t){const i=e[0],r=t[0];if(i===r)return 0;const o=y(s,i),a=y(s,r);return n[o]=e.residueCount)continue;o.index=n+s,a.index=n+s+t,c.index=o.traceAtomIndex,l.index=a.traceAtomIndex;const h=c.distanceTo(l);if(Math.abs(h-i[t-2])>r)return!1}return!0},r=function(e,t){return i(e,t,[5.45,5.18,6.37],2.1)},s=function(e,t){return i(e,t,[6.1,10.4,13],1.42)};return function(i){e.Debug&&Be.time("calculateSecondaryStructure"),i.eachPolymer((function(e){if(e.residueCount<4)return;if(e.isCg())!function(e){const i=e.residueStore,r=e.residueIndexStart,s=new go(e).position,n=new t.Vector3,o=new t.Vector3;for(let t=0,a=e.residueCount;t1&&s.bending[t]<20&&(i.sstruc[r+t]="h".charCodeAt(0),i.sstruc[r+t+1]="h".charCodeAt(0))}}(e);else{if(!e.isProtein())return;!function(e){const t=e.residueStore,i=e.residueIndexStart;for(let n=0,o=e.residueCount;n=t;)i=Math.floor(i/t),s+=Ro[i%t],r+=1;return r>=5&&Be.warn("chainname overflow"),s}function $o(t,i=!1){e.Debug&&Be.time("calculateChainnames");let r=!0;if(t.eachChain((function(e){e.chainname&&(r=!1)})),r){const e=t.modelStore,r=t.chainStore,s=t.residueStore,n=function(t,i,n,o){const a=r.count;for(let e=0;e{u.add(t),e.forEach((e=>{u.add(e)}))}))),t.eachResidue((function(e){if(!i&&h){const t=e.atomCount,i=e.atomOffset;if(t>500)return void Be.warn("more than 500 atoms, skip residue for auto-bonding",e.qualifiedName());if("auto"===r&&e.hetero)for(let t=e.atomOffset;t{d.forEach((i=>{e.push(t.clone().multiply(i))}))})),h.addPart(e)}else h.addPart(u);const m=new t.Vector3,p=new ko("SUPERCELL"),f=Array.prototype.concat.call(l(m.set(1,0,0)),l(m.set(0,1,0)),l(m.set(0,0,1)),l(m.set(-1,0,0)),l(m.set(0,-1,0)),l(m.set(0,0,-1)),l(m.set(1,1,0)),l(m.set(1,0,1)),l(m.set(0,1,1)),l(m.set(-1,-1,0)),l(m.set(-1,0,-1)),l(m.set(0,-1,-1)),l(m.set(1,-1,-1)),l(m.set(1,1,-1)),l(m.set(1,-1,1)),l(m.set(-1,1,1)),l(m.set(-1,-1,1)),l(m.set(-1,1,-1)),l(m.set(0,1,-1)),l(m.set(0,-1,1)),l(m.set(1,0,-1)),l(m.set(-1,0,1)),l(m.set(1,-1,0)),l(m.set(-1,1,0)),l(),l(m.set(1,1,1)),l(m.set(-1,-1,-1)));if(i.biomolDict.NCS){const e=[];f.forEach((function(t){d.forEach((function(i){e.push(t.clone().multiply(i))}))})),p.addPart(e)}else p.addPart(f);i.biomolDict.UNITCELL=h,i.biomolDict.SUPERCELL=p,e.Debug&&Be.timeEnd("buildUnitcellAssembly")}const Go=["H","C","O","N","S","P"],Uo=["NA","CL","FE"];function jo(e){let t=e.toUpperCase(),i=0,r=0;for(let e=0;e0)break;++i}else r=e+1;(i>0||r=3&&-1!==Go.indexOf(t[0])?t[0]:""}function Ho(e){const t=e.bondHash,i=t.countArray,r=t.offsetArray,s=t.indexArray,n=e.getBondProxy();e.eachResidue((function(e){const t=e.residueType;if(void 0!==t.bonds)return;var o=e.atomOffset,a=[],c=[],l=[],h={};const u=o+e.atomCount;e.eachAtom((function(e){const t=e.index,d=r[t];for(let e=0,r=i[t];e=u)continue;let i=n.atomIndex2;if(i=u)continue;if(t>i){const e=i;i=t,t=e}const r=t+"|"+i;void 0===h[r]&&(h[r]=!0,a.push(t-o),c.push(i-o),l.push(n.bondOrder))}})),t.bonds={atomIndices1:a,atomIndices2:c,bondOrders:l}}))}const Wo=[3,11,19,37,55,87],qo=[4,12,20,38,56,88],Xo=[6,15,16,34],Yo=[1,7,8,9,17,35,53],Ko=[2,10,18,36,54,86],Zo=[13,30,31,48,49,50,80,81,82,83,84,85,112],Qo=[5,14,32,33,51,52,85],Jo=[9,17,35,53,85];class ea{constructor(e,t,i){this.structure=e,this.atomname=t,i=i||jo(t),this.element=i,this.number=Lr[i]||0,this.vdw=Nr[this.number]||2,this.covalent=zr[this.number]||1.6}getDefaultValence(){const e=Vr[this.number];return e?e[0]:-1}getValenceList(){return Vr[this.number]||[]}getOuterShellElectronCount(){return Gr[this.number]||2}isMetal(){return this.isAlkaliMetal()||this.isAlkalineEarthMetal()||this.isLanthanide()||this.isActinide()||this.isTransitionMetal()||this.isPostTransitionMetal()}isNonmetal(){return this.isDiatomicNonmetal()||this.isPolyatomicNonmetal()||this.isNobleGas()}isMetalloid(){return Qo.includes(this.number)}isHalogen(){return Jo.includes(this.number)}isDiatomicNonmetal(){return Yo.includes(this.number)}isPolyatomicNonmetal(){return Xo.includes(this.number)}isAlkaliMetal(){return Wo.includes(this.number)}isAlkalineEarthMetal(){return qo.includes(this.number)}isNobleGas(){return Ko.includes(this.number)}isTransitionMetal(){const e=this.number;return e>=21&&e<=29||e>=39&&e<=47||e>=72&&e<=79||e>=104&&e<=108}isPostTransitionMetal(){return Zo.includes(this.number)}isLanthanide(){return this.number>=57&&this.number<=71}isActinide(){return this.number>=89&&this.number<=103}}class ta{constructor(e){this.structure=e,this.dict={},this.list=[],this.structure=e}add(e,t){const i=function(e,t){return e+"|"+t}(e=e.toUpperCase(),t=t?t.toUpperCase():jo(e));let r=this.dict[i];if(void 0===r){const s=new ea(this.structure,e,t);r=this.list.length,this.dict[i]=r,this.list.push(s)}return r}get(e){return this.list[e]}}class ia{constructor(e,t,i,r,s,n){this.structure=e,this.bondReferenceAtomIndices=[],this.resname=t,this.atomTypeIdList=i,this.hetero=r?1:0,this.chemCompType=s,this.bonds=n,this.atomCount=i.length,this.moleculeType=this.getMoleculeType(),this.backboneType=this.getBackboneType(0),this.backboneEndType=this.getBackboneType(-1),this.backboneStartType=this.getBackboneType(1),this.backboneIndexList=this.getBackboneIndexList();const o=is[this.backboneType],a=is[this.backboneStartType],c=is[this.backboneEndType],h=this.getAtomIndexByName(o.trace);this.traceAtomIndex=l(h,-1);const u=this.getAtomIndexByName(o.direction1);this.direction1AtomIndex=l(u,-1);const d=this.getAtomIndexByName(o.direction2);this.direction2AtomIndex=l(d,-1);const m=this.getAtomIndexByName(a.backboneStart);this.backboneStartAtomIndex=l(m,-1);const p=this.getAtomIndexByName(c.backboneEnd);let f;this.backboneEndAtomIndex=l(p,-1),f=Yr.includes(t)?this.getAtomIndexByName("N1"):this.getAtomIndexByName("N3"),this.rungEndAtomIndex=l(f,-1)}getBackboneIndexList(){const e=[];let t;switch(this.moleculeType){case 3:t=es;break;case 4:case 5:t=ts;break;default:return e}const i=this.structure.atomMap,r=this.atomTypeIdList;for(let s=0,n=this.atomCount;s500)e.Debug&&Be.warn("more than 500 atoms, skip residue for auto-bonding",t.qualifiedName());else if(n>50){const e=new _o(t,!0),i=t.isCg()?1.2:2.3;for(let t=o;t=0||oa(e,t);this.rings={atomRings:e.atomRings,rings:e.rings}}isAromatic(e){return this.aromaticAtoms=this.getAromatic(e),1===this.aromaticAtoms[e.index-e.residueAtomOffset]}calculateAromatic(e){const t=this.aromaticAtoms=new Uint8Array(this.atomCount),i=this.getRings().rings,r=i.map((t=>function(e){if(e.some((e=>!ra.includes(e.number))))return!1;let t=0;const i=new Js(3,e.length),r=i.data;e.forEach((e=>{r[t+0]=e.x,r[t+1]=e.y,r[t+2]=e.z,t+=3}));return new oo(i).vecC.length()this.structure.getAtomProxy(t+e.atomOffset)))))),s=this.aromaticRings=[];i.forEach(((e,i)=>{r[i]&&(s.push(e),e.forEach((e=>t[e]=1)))}))}assignBondReferenceAtomIndices(){const e=this.getBondGraph(),t=this.getRings(),i=t.atomRings,r=t.rings,s=this.bonds,n=s.atomIndices1,o=s.atomIndices2,a=s.bondOrders,c=this.bondReferenceAtomIndices,l=s.atomIndices1.length;c.length=0;for(let t=0;t1)for(let i=0;i1)for(let i=0;i=0;e--)p[f++]=o[e];const g=e.rings.length;for(let t=0;t0?n[c]!==t&&n[t]!==c&&na(e,t,c):(r[c]=1,s[a++]=c,n[c]=t)}}}const aa=4;class ca{constructor(e){this.structure=e,this.dict={},this.list=[]}add(e,t,i,r="",s){const n=function(e,t,i,r=""){return e+"|"+t.join(",")+"|"+(i?1:0)+"|"+r}(e=e.toUpperCase(),t,i,r);let o=this.dict[n];if(void 0===o){const a=new ia(this.structure,e,t,i,r,s);o=this.list.length,this.dict[n]=o,this.list.push(a)}return o}get(e){return this.list[e]}}class la{constructor(e,i=0){this.structure=e,this.index=i,this.bondStore=e.bondStore,this._v12=new t.Vector3,this._v13=new t.Vector3,this._ap1=this.structure.getAtomProxy(),this._ap2=this.structure.getAtomProxy(),this._ap3=this.structure.getAtomProxy()}get atom1(){return this.structure.getAtomProxy(this.atomIndex1)}get atom2(){return this.structure.getAtomProxy(this.atomIndex2)}get atomIndex1(){return this.bondStore.atomIndex1[this.index]}set atomIndex1(e){this.bondStore.atomIndex1[this.index]=e}get atomIndex2(){return this.bondStore.atomIndex2[this.index]}set atomIndex2(e){this.bondStore.atomIndex2[this.index]=e}get bondOrder(){return this.bondStore.bondOrder[this.index]}set bondOrder(e){this.bondStore.bondOrder[this.index]=e}getOtherAtomIndex(e){return e===this.atomIndex1?this.atomIndex2:this.atomIndex1}getOtherAtom(e){return this.structure.getAtomProxy(this.getOtherAtomIndex(e.index))}getReferenceAtomIndex(){const e=this._ap1,t=this._ap2;if(e.index=this.atomIndex1,t.index=this.atomIndex2,e.residueIndex!==t.residueIndex)return;const i=e.index-e.residueAtomOffset,r=t.index-t.residueAtomOffset,s=e.residueType.getBondReferenceAtomIndex(i,r);if(void 0!==s)return s+e.residueAtomOffset;console.warn("No reference atom found",e.index,t.index)}calculateShiftDir(e=new t.Vector3){const i=this._ap1,r=this._ap2,s=this._ap3,n=this._v12,o=this._v13;i.index=this.atomIndex1,r.index=this.atomIndex2;const a=this.getReferenceAtomIndex();n.subVectors(i,r).normalize(),void 0!==a?(s.index=a,o.subVectors(i,s)):o.copy(i),o.normalize();let c=n.dot(o);return 1-Math.abs(c)<1e-5&&(o.set(1,0,0),c=n.dot(o),1-Math.abs(c)<1e-5&&(o.set(0,1,0),c=n.dot(o))),e.copy(o.sub(n.multiplyScalar(c))).normalize()}qualifiedName(){return this.atomIndex1+"="+this.atomIndex2}clone(){return new la(this.structure,this.index)}toObject(){return{atomIndex1:this.atomIndex1,atomIndex2:this.atomIndex2,bondOrder:this.bondOrder}}}class ha{constructor(e,t=0){this.structure=e,this.index=t,this.chainStore=e.chainStore,this.residueStore=e.residueStore,this.atomStore=e.atomStore,this.residueMap=e.residueMap,this.atomMap=e.atomMap}get entity(){return this.structure.entityList[this.entityIndex]}get entityIndex(){return this.chainStore.entityIndex[this.chainIndex]}get chain(){return this.structure.getChainProxy(this.chainIndex)}get chainIndex(){return this.residueStore.chainIndex[this.index]}set chainIndex(e){this.residueStore.chainIndex[this.index]=e}get atomOffset(){return this.residueStore.atomOffset[this.index]}set atomOffset(e){this.residueStore.atomOffset[this.index]=e}get atomCount(){return this.residueStore.atomCount[this.index]}set atomCount(e){this.residueStore.atomCount[this.index]=e}get atomEnd(){return this.atomOffset+this.atomCount-1}get modelIndex(){return this.chainStore.modelIndex[this.chainIndex]}get chainname(){return this.chainStore.getChainname(this.chainIndex)}get chainid(){return this.chainStore.getChainid(this.chainIndex)}get resno(){return this.residueStore.resno[this.index]}set resno(e){this.residueStore.resno[this.index]=e}get sstruc(){return this.residueStore.getSstruc(this.index)}set sstruc(e){this.residueStore.setSstruc(this.index,e)}get inscode(){return this.residueStore.getInscode(this.index)}set inscode(e){this.residueStore.setInscode(this.index,e)}get residueType(){return this.residueMap.get(this.residueStore.residueTypeId[this.index])}get resname(){return this.residueType.resname}get hetero(){return this.residueType.hetero}get moleculeType(){return this.residueType.moleculeType}get backboneType(){return this.residueType.backboneType}get backboneStartType(){return this.residueType.backboneStartType}get backboneEndType(){return this.residueType.backboneEndType}get traceAtomIndex(){return this.residueType.traceAtomIndex+this.atomOffset}get direction1AtomIndex(){return this.residueType.direction1AtomIndex+this.atomOffset}get direction2AtomIndex(){return this.residueType.direction2AtomIndex+this.atomOffset}get backboneStartAtomIndex(){return this.residueType.backboneStartAtomIndex+this.atomOffset}get backboneEndAtomIndex(){return this.residueType.backboneEndAtomIndex+this.atomOffset}get rungEndAtomIndex(){return this.residueType.rungEndAtomIndex+this.atomOffset}get x(){let e=0;for(let t=this.atomOffset;t<=this.atomEnd;++t)e+=this.atomStore.x[t];return e/this.atomCount}get y(){let e=0;for(let t=this.atomOffset;t<=this.atomEnd;++t)e+=this.atomStore.y[t];return e/this.atomCount}get z(){let e=0;for(let t=this.atomOffset;t<=this.atomEnd;++t)e+=this.atomStore.z[t];return e/this.atomCount}eachAtom(e,t){const i=this.atomCount,r=this.atomOffset,s=this.structure._ap,n=r+i;if(t&&t.atomOnlyTest){const i=t.atomOnlyTest;for(let t=r;t0)return this.entity.isPolymer();{const e=this.residueType.moleculeType;return 3===e||4===e||5===e}}isHetero(){return 1===this.residueType.hetero}isWater(){return 1===this.residueType.moleculeType}isIon(){return 2===this.residueType.moleculeType}isSaccharide(){return 6===this.residueType.moleculeType}isStandardAminoacid(){return this.residueType.isStandardAminoacid()}isStandardBase(){return this.residueType.isStandardBase()}isHelix(){return $r.includes(this.sstruc)}isSheet(){return Fr.includes(this.sstruc)}isTurn(){return Er.includes(this.sstruc)&&this.isProtein()}getAtomType(e){return this.atomMap.get(this.atomStore.atomTypeId[e])}getResname1(){return Hr[this.resname.toUpperCase()]||"X"}getBackboneType(e){switch(e){case-1:return this.residueType.backboneStartType;case 1:return this.residueType.backboneEndType;default:return this.residueType.backboneType}}getAtomIndexByName(e){let t=this.residueType.getAtomIndexByName(e);return void 0!==t&&(t+=this.atomOffset),t}hasAtomWithName(e){return this.residueType.hasAtomWithName(e)}getAtomnameList(){console.warn("getAtomnameList - might be expensive");const e=this.atomCount,t=this.atomOffset,i=new Array(e);for(let r=0;r=t){const t=l(e,this.structure.getResidueProxy());if(t.index=i,t.connectedTo(this))return t}else if(i===t-1){const i=this.chainStore.residueCount[this.chainIndex],r=l(e,this.structure.getResidueProxy());if(r.index=t+i-1,r.connectedTo(this))return r}}getBonds(){return this.residueType.getBonds(this)}getRings(){return this.residueType.getRings()}getAromaticRings(){return this.residueType.getAromaticRings(this)}qualifiedName(e=!1){let t="";return this.resname&&!e&&(t+="["+this.resname+"]"),void 0!==this.resno&&(t+=this.resno),this.inscode&&(t+="^"+this.inscode),this.chain&&(t+=":"+this.chainname),t+="/"+this.modelIndex,t}clone(){return new ha(this.structure,this.index)}toObject(){return{index:this.index,chainIndex:this.chainIndex,atomOffset:this.atomOffset,atomCount:this.atomCount,resno:this.resno,resname:this.resname,sstruc:this.sstruc}}}class ua{constructor(e,t,i){this.structure=e,this.residueIndexStart=t,this.residueIndexEnd=i,this.chainStore=e.chainStore,this.residueStore=e.residueStore,this.atomStore=e.atomStore,this.residueCount=i-t+1;const r=this.structure.getResidueProxy(this.residueIndexStart),s=this.structure.getResidueProxy(this.residueIndexEnd);this.isPrevConnected=void 0!==r.getPreviousConnectedResidue();const n=s.getNextConnectedResidue();this.isNextConnected=void 0!==n,this.isNextNextConnected=void 0!==n&&void 0!==n.getNextConnectedResidue(),this.isCyclic=s.connectedTo(r),this.__residueProxy=this.structure.getResidueProxy()}get chainIndex(){return this.residueStore.chainIndex[this.residueIndexStart]}get modelIndex(){return this.chainStore.modelIndex[this.chainIndex]}get chainname(){return this.chainStore.getChainname(this.chainIndex)}isProtein(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isProtein()}isCg(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isCg()}isNucleic(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.isNucleic()}getMoleculeType(){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.moleculeType}getBackboneType(e){return this.__residueProxy.index=this.residueIndexStart,this.__residueProxy.getBackboneType(e)}getAtomIndexByType(e,t){this.isCyclic?-1===e?e=this.residueCount-1:e===this.residueCount&&(e=0):(-1!==e||this.isPrevConnected||(e+=1),e!==this.residueCount||this.isNextNextConnected||(e-=1));const i=this.__residueProxy;let r;switch(i.index=this.residueIndexStart+e,t){case"trace":r=i.traceAtomIndex;break;case"direction1":r=i.direction1AtomIndex;break;case"direction2":r=i.direction2AtomIndex;break;default:r=i.getAtomIndexByName(t)}return r}eachAtom(e,t){this.eachResidue((function(i){i.eachAtom(e,t)}))}eachAtomN(e,t,i){const r=this.residueCount,s=new Array(e);for(let t=0;t1&&e(new ua(n,i,l.index)),i=r)):(o!==Mr&&l.index-i>1&&e(new ua(n,i,l.index)),i=r)}r-i>1&&this.structure.getResidueProxy(i).backboneEndType&&e(new ua(n,i,r))}qualifiedName(){return":"+this.chainname+"/"+this.modelIndex}clone(){return new da(this.structure,this.index)}toObject(){return{index:this.index,residueOffset:this.residueOffset,residueCount:this.residueCount,chainname:this.chainname}}}class ma{constructor(e,t=0){this.structure=e,this.index=t,this.modelStore=e.modelStore,this.chainStore=e.chainStore,this.residueStore=e.residueStore}get chainOffset(){return this.modelStore.chainOffset[this.index]}set chainOffset(e){this.modelStore.chainOffset[this.index]=e}get chainCount(){return this.modelStore.chainCount[this.index]}set chainCount(e){this.modelStore.chainCount[this.index]=e}get residueOffset(){return this.chainStore.residueOffset[this.chainOffset]}get atomOffset(){return this.residueStore.atomOffset[this.residueOffset]}get chainEnd(){return this.chainOffset+this.chainCount-1}get residueEnd(){return this.chainStore.residueOffset[this.chainEnd]+this.chainStore.residueCount[this.chainEnd]-1}get atomEnd(){return this.residueStore.atomOffset[this.residueEnd]+this.residueStore.atomCount[this.residueEnd]-1}get residueCount(){return 0===this.chainCount?0:this.residueEnd-this.residueOffset+1}get atomCount(){return 0===this.residueCount?0:this.atomEnd-this.atomOffset+1}eachAtom(e,t){this.eachChain((function(i){i.eachAtom(e,t)}),t)}eachResidue(e,t){this.eachChain((function(i){i.eachResidue(e,t)}),t)}eachPolymer(e,t){if(t&&t.chainOnlyTest){const i=t.chainOnlyTest;this.eachChain((function(r){i(r)&&r.eachPolymer(e,t)}))}else this.eachChain((function(i){i.eachPolymer(e,t)}))}eachChain(e,t){const i=this.chainCount,r=this.chainOffset,s=this.structure._cp,n=r+i;if(t&&t.test){const i=t.chainOnlyTest;if(i)for(let t=r;t{const i=3*t;a.index=e,h&&a.positionToArray(h,i),u&&n.atomColorToArray(a,u,i),d&&(d.array[t]=e),m&&(m[t]=s.atomRadius(a)),p&&(p[t]=e)})),o}getBondData(e){const i=Object.assign({},e);i.colorParams&&(i.colorParams.structure=this.getStructure());const r=i.what,s=l(i.bondSet,this.bondSet),n=l(i.multipleBond,"off"),o="off"!==n,a="offset"===n,c=l(i.bondScale,.4),h=l(i.bondSpacing,1);let u,d;const m={},p=this.getBondProxy();i.bondStore&&(p.bondStore=i.bondStore);const f=this.getAtomProxy(),g=this.getAtomProxy();let y;if(o){const e=p.bondStore.bondOrder;y=0,s.forEach((function(t){y+=e[t]}))}else y=s.getSize();r&&!r.position||(m.position1=new Float32Array(3*y),m.position2=new Float32Array(3*y)),r&&!r.color||!i.colorParams||(m.color=new Float32Array(3*y),m.color2=new Float32Array(3*y),d=Ee.getScheme(i.colorParams)),r&&!r.picking||(m.picking=new zs(new Float32Array(y),this.getStructure(),i.bondStore)),(!r||r.radius||o&&r.position)&&(u=new ro(i.radiusParams)),r&&!r.radius||(m.radius=new Float32Array(y),i.radius2&&(m.radius2=new Float32Array(y)));const{position1:b,position2:x,color:v,color2:w,picking:A,radius:_,radius2:S}=m;let C,P,I,k,M,D,T=0;const B=new t.Vector3,R=new t.Vector3,O=new t.Vector3;return s.forEach((e=>{if(P=3*T,p.index=e,f.index=p.atomIndex1,g.index=p.atomIndex2,k=p.bondOrder,b)if(o&&k>1){const e=u.atomRadius(f);D=e*c/(.5*k),p.calculateShiftDir(O),a?(M=2*h*e,O.multiplyScalar(M),O.negate(),R.subVectors(g,f).multiplyScalar(Math.max(.1,M/1.88)),f.positionToArray(b,P),g.positionToArray(x,P),k>=2&&(B.addVectors(f,O).add(R).toArray(b,P+3),B.addVectors(g,O).sub(R).toArray(x,P+3),k>=3&&(B.subVectors(f,O).add(R).toArray(b,P+6),B.subVectors(g,O).sub(R).toArray(x,P+6)))):(M=(h-c)*e,O.multiplyScalar(M),2===k?(B.addVectors(f,O).toArray(b,P),B.subVectors(f,O).toArray(b,P+3),B.addVectors(g,O).toArray(x,P),B.subVectors(g,O).toArray(x,P+3)):3===k?(f.positionToArray(b,P),B.addVectors(f,O).toArray(b,P+3),B.subVectors(f,O).toArray(b,P+6),g.positionToArray(x,P),B.addVectors(g,O).toArray(x,P+3),B.subVectors(g,O).toArray(x,P+6)):(f.positionToArray(b,P),g.positionToArray(x,P)))}else f.positionToArray(b,P),g.positionToArray(x,P);if(v&&w&&(d.bondColorToArray(p,1,v,P),d.bondColorToArray(p,0,w,P),o&&k>1))for(C=1;C1))for(C=1;C1))for(D=_[T]*c/(a?1:.5*k),C=a?1:0;C1))for(D=S[T]*c/(a?1:.5*k),C=a?1:0;C{const t=e.x,i=e.y,r=e.z;ta&&(a=t),i>c&&(c=i),r>l&&(l=r)}),i),r.min.set(s,n,o),r.max.set(a,c,l),e.Debug&&Be.timeEnd("getBoundingBox"),r}getPrincipalAxes(t){e.Debug&&Be.time("getPrincipalAxes");let i=0;const r=new Js(3,this.atomCount),s=r.data;return this.eachAtom((e=>{s[i+0]=e.x,s[i+1]=e.y,s[i+2]=e.z,i+=3}),t),e.Debug&&Be.timeEnd("getPrincipalAxes"),new oo(r)}atomCenter(e){return e?this.getBoundingBox(e).getCenter(new t.Vector3):this.center.clone()}hasCoords(){if(void 0===this._hasCoords){const e=this.atomStore;this._hasCoords=0!==Ct(e.x)||0!==St(e.x)||0!==Ct(e.y)||0!==St(e.y)||0!==Ct(e.z)||0!==St(e.z)||e.count/this.modelStore.count==1}return this._hasCoords}getSequence(e){const t=[],i=this.getResidueProxy();return this.eachAtom((function(e){i.index=e.residueIndex,e.index===i.traceAtomIndex&&t.push(i.getResname1())}),e),t}getAtomIndices(e){if(e&&e.string){const t=[];return this.eachAtom((function(e){t.push(e.index)}),e),new Uint32Array(t)}{const e={what:{index:!0}};return this.getAtomData(e).index}}getChainnameCount(e){const t=new Set;return this.eachChain((function(e){e.residueCount&&t.add(e.chainname)}),e),t.size}updatePosition(e,t=!0){let i=0;this.eachAtom((function(t){t.positionFromArray(e,i),i+=3}),void 0),this._hasCoords=void 0,t&&this.refreshPosition()}refreshPosition(){this.getBoundingBox(void 0,this.boundingBox),this.boundingBox.getCenter(this.center),this.spatialHash=new vr(this.atomStore,this.boundingBox),this.signals.refreshed.dispatch(this)}dispose(){this.frames&&(this.frames.length=0),this.boxes&&(this.boxes.length=0),this.bondStore.dispose(),this.backboneBondStore.dispose(),this.rungBondStore.dispose(),this.atomStore.dispose(),this.residueStore.dispose(),this.chainStore.dispose(),this.modelStore.dispose(),delete this.bondSet,delete this.atomSet}}const fa=new t.Box3,ga=[mr,lr,pr,dr,fr,hr,cr,ur,yr,gr,br,xr],ya={aspectRatio:1.5,sphereDetail:2,radialSegments:50,disableImpostor:!1,openEnded:!1,dashedCylinder:!1,labelParams:{},pointSize:2,sizeAttenuation:!1,useTexture:!0,linewidth:2};class ba{constructor(e="shape",i={}){this.boundingBox=new t.Box3,this.bufferList=[],this.meshCount=0,this._primitiveData={},this.name=e,this.parameters=h(i,ya),ga.forEach((e=>{Object.keys(e.fields).forEach((t=>{this._primitiveData[e.getShapeKey(t)]=[]})),this._primitiveData[e.getShapeKey("name")]=[]}))}addBuffer(e){this.bufferList.push(e);const t=e.geometry;return t.boundingBox||t.computeBoundingBox(),this.boundingBox.union(t.boundingBox),this}addMesh(e,t,i,r,s){let n;e=k(e),t=k(t),Array.isArray(i)&&(i=A(i,e.length)),r&&(r=k(r)),n=void 0===r||0==r.length?{position:e,color:t,index:i}:{position:e,color:t,index:i,normal:r};const o=new Hs(this,Object.assign({serial:this.meshCount,name:s},n)),a=new Bn(Object.assign({picking:o},n));return this.bufferList.push(a),fa.setFromArray(e),this.boundingBox.union(fa),this.meshCount+=1,this}addSphere(e,t,i,r){return cr.objectToShape(this,{position:e,color:t,radius:i,name:r}),this}addEllipsoid(e,t,i,r,s,n){return fr.objectToShape(this,{position:e,color:t,radius:i,majorAxis:r,minorAxis:s,name:n}),this}addTorus(e,t,i,r,s,n){return gr.objectToShape(this,{position:e,color:t,radius:i,majorAxis:r,minorAxis:s,name:n}),this}addCylinder(e,t,i,r,s){return dr.objectToShape(this,{position1:e,position2:t,color:i,radius:r,name:s}),this}addCone(e,t,i,r,s){return pr.objectToShape(this,{position1:e,position2:t,color:i,radius:r,name:s}),this}addArrow(e,t,i,r,s){return mr.objectToShape(this,{position1:e,position2:t,color:i,radius:r,name:s}),this}addBox(e,t,i,r,s,n){return lr.objectToShape(this,{position:e,color:t,size:i,heightAxis:r,depthAxis:s,name:n}),this}addOctahedron(e,t,i,r,s,n){return hr.objectToShape(this,{position:e,color:t,size:i,heightAxis:r,depthAxis:s,name:n}),this}addTetrahedron(e,t,i,r,s,n){return ur.objectToShape(this,{position:e,color:t,size:i,heightAxis:r,depthAxis:s,name:n}),this}addText(e,t,i,r){return yr.objectToShape(this,{position:e,color:t,size:i,text:r}),this}addPoint(e,t,i){return br.objectToShape(this,{position:e,color:t,name:i}),this}addWideline(e,t,i,r,s){return this.parameters.linewidth=r,xr.objectToShape(this,{position1:e,position2:t,color:i,name:s}),this}addLabel(e,t,i,r){return console.warn("Shape.addLabel is deprecated, use .addText instead"),this.addText(e,t,i,r)}getBufferList(){const e=[];return ga.forEach((t=>{this._primitiveData[t.getShapeKey("color")].length&&e.push(t.bufferFromShape(this,this.parameters))})),this.bufferList.concat(e)}dispose(){this.bufferList.forEach((function(e){e.dispose()})),this.bufferList.length=0,ga.forEach((e=>{Object.keys(e.fields).forEach((t=>{this._primitiveData[e.getShapeKey(t)].length=0})),this._primitiveData[e.getShapeKey("name")].length=0}))}get center(){return this._center||(this._center=this.boundingBox.getCenter(new t.Vector3)),this._center}get type(){return"Shape"}}class xa extends Di{constructor(e,t,i){Array.isArray(e)||(e=[e]),super(e,t,i),this.type="buffer",this.parameters=Object.assign({},this.parameters,{colorScheme:null,colorScale:null,colorValue:null,colorDomain:null,colorMode:null}),this.buffer=e,this.init(i)}init(e){super.init(e),this.build()}create(){this.bufferList.push.apply(this.bufferList,this.buffer)}attach(e){this.bufferList.forEach((e=>{this.viewer.add(e),e.setParameters(this.getBufferParams())})),this.setVisibility(this.visible),e()}}const va=new t.Matrix4,wa=new t.Matrix3;class Aa extends Bn{constructor(e,t={},i){super(function(e,t){const i=t.attributes.position.array,r=t.index?t.index.array:void 0,s=e.position.length/3,n=i.length/3,o=s*n,a=new Float32Array(3*o),c=new Float32Array(3*o),l=new Float32Array(3*o);let h;return r&&(h=A(s*r.length,o)),{position:a,color:l,index:h,normal:c,primitiveId:e.primitiveId||vt(s,n),picking:e.picking}}(e,i),t),this.updateNormals=!1;const r=i.attributes.position.array,s=i.attributes.normal.array,n=i.index?i.index.array:void 0;this.geoPosition=r,this.geoNormal=s,this.geoIndex=n,this.positionCount=e.position.length/3,this.geoPositionCount=r.length/3,this.transformedGeoPosition=new Float32Array(3*this.geoPositionCount),this.transformedGeoNormal=new Float32Array(3*this.geoPositionCount);const o=this.geometry.attributes;if(this.meshPosition=o.position.array,this.meshColor=o.color.array,this.meshNormal=o.normal.array,this.setAttributes(e),n){const e=this.geometry.getIndex();if(!e)return void Be.error("Index is null");this.meshIndex=e.array,this.makeIndex()}}setAttributes(e={},t=!1){const i=this.geometry.attributes;let r,s,n,o,a,c,l,h,u;const d=this.updateNormals;e.position&&(r=e.position,n=this.geoPosition,l=this.meshPosition,a=this.transformedGeoPosition,i.position.needsUpdate=!0,(d||t)&&(o=this.geoNormal,u=this.meshNormal,c=this.transformedGeoNormal,i.normal.needsUpdate=!0)),e.color&&(s=e.color,h=this.meshColor,i.color.needsUpdate=!0);const m=this.positionCount,p=this.geoPositionCount;for(let e=0;e 0.0 ){\ncameraPos = rayDirection * posT + rayOrigin;\ninterior = true;\nflag2 = true;\n}\n#else\nif( calcDepth( cameraPos ) <= 0.0 ){\ncameraPos = rayDirection * posT + rayOrigin;\ninterior = true;\n}\n#endif\ncameraNormal = normalize( cameraPos - cameraSpherePos );\ncameraNormal *= float(!interior) * 2.0 - 1.0;\nreturn !interior;\n}\nvoid main(void){\nbool flag = Impostor( cameraPos, cameraNormal );\n#ifdef NEAR_CLIP\nif( calcClip( cameraPos ) > 0.0 )\ndiscard;\n#endif\ngl_FragDepthEXT = calcDepth( cameraPos );\nif( !flag ){\n#ifdef NEAR_CLIP\nif( flag2 ){\ngl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( clipNear - 0.5 ) ) ) + ( 0.0000001 / vRadius ) );\n}else if( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n#else\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n#endif\n}\nif (gl_FragDepthEXT < 0.0)\ndiscard;\nif (gl_FragDepthEXT > 1.0)\ndiscard;\n#ifdef PICKING\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 vNormal = cameraNormal;\nvec3 vViewPosition = -cameraPos;\nvec4 diffuseColor = vec4( diffuse, opacity );\nReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\nvec3 totalEmissiveLight = emissive;\n#include color_fragment\n#include roughnessmap_fragment\n#include metalnessmap_fragment\n#include normal_fragment_begin\n#include lights_physical_fragment\n#include lights_fragment_begin\n#include lights_fragment_end\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\nif( interior ){\n#ifdef USE_INTERIOR_COLOR\noutgoingLight.xyz = interiorColor;\n#else\n#ifdef DIFFUSE_INTERIOR\noutgoingLight.xyz = vColor;\n#endif\n#endif\noutgoingLight.xyz *= 1.0 - interiorDarkening;\n}\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");class Pa extends Tn{constructor(e,t,i={}){super(t,i),this.index=A(this.indexSize,this.attributeSize),this.makeIndex(),this.initIndex(this.index),this.addAttributes({mapping:{type:e,value:null}}),this.setAttributes({primitiveId:xt(this.size)})}get attributeSize(){return this.size*this.mappingSize}get indexSize(){return this.size*this.mappingIndicesSize}addAttributes(e){const t={};for(const i in e){const r=e[i];t[i]={type:r.type,value:null}}super.addAttributes(t)}getAttributeIndex(e){return 3*e*this.mappingSize}setAttributes(e){e&&!e.position&&e.position1&&e.position2&&(e.position=ft(e.position1,e.position2));const t=this.size,i=this.mappingSize,r=this.geometry.attributes;let s,n,o,a,c,l,h;for(const u in e)if("index"!==u&&"picking"!==u){n=e[u],s=r[u],o=s.itemSize,a=s.array;for(let e=0;e0&&this.parameters.alphaTest<=1&&(t.ALPHATEST=this.parameters.alphaTest.toPrecision(2)),t}setUniforms(e){e&&void 0!==e.edgeBleach&&(this.makeTexture(),e.map=this.tex),super.setUniforms(e)}dispose(){super.dispose(),this.tex&&this.tex.dispose()}}je.add("point",$a);class Fa extends Di{constructor(e,t,i){super(e,t,i),this.type="dot",this.parameters=Object.assign({thresholdType:{type:"select",rebuild:!0,options:{value:"value",sigma:"sigma"}},thresholdMin:{type:"number",precision:3,max:1/0,min:-1/0,rebuild:!0},thresholdMax:{type:"number",precision:3,max:1/0,min:-1/0,rebuild:!0},thresholdOut:{type:"boolean",rebuild:!0},dotType:{type:"select",rebuild:!0,options:{"":"",sphere:"sphere",point:"point"}},radiusType:{type:"select",options:{"":"",value:"value","abs-value":"abs-value","value-min":"value-min",deviation:"deviation",size:"size"}},radius:{type:"number",precision:3,max:10,min:.001,property:"size"},scale:{type:"number",precision:3,max:10,min:.001},sphereDetail:!0,disableImpostor:!0,pointSize:{type:"number",precision:1,max:100,min:0,buffer:!0},sizeAttenuation:{type:"boolean",buffer:!0},sortParticles:{type:"boolean",rebuild:!0},useTexture:{type:"boolean",buffer:!0},alphaTest:{type:"range",step:.001,max:1,min:0,buffer:!0},forceTransparent:{type:"boolean",buffer:!0},edgeBleach:{type:"range",step:.001,max:1,min:0,buffer:!0}},this.parameters,{colorScheme:{type:"select",update:"color",options:{"":"",value:"value",uniform:"uniform",random:"random"}}}),e instanceof Cn?(this.surface=void 0,this.volume=new ao(e)):(this.surface=e,this.volume=void 0),this.init(i)}init(e){var t=e||{};t.colorScheme=l(t.colorScheme,"uniform"),t.colorValue=l(t.colorValue,14540253),this.thresholdType=l(t.thresholdType,"sigma"),this.thresholdMin=l(t.thresholdMin,2),this.thresholdMax=l(t.thresholdMax,1/0),this.thresholdOut=l(t.thresholdOut,!1),this.dotType=l(t.dotType,"point"),this.radius=l(t.radius,.1),this.scale=l(t.scale,1),this.pointSize=l(t.pointSize,1),this.sizeAttenuation=l(t.sizeAttenuation,!0),this.sortParticles=l(t.sortParticles,!1),this.useTexture=l(t.useTexture,!1),this.alphaTest=l(t.alphaTest,.5),this.forceTransparent=l(t.forceTransparent,!1),this.edgeBleach=l(t.edgeBleach,0),super.init(t),this.build()}attach(e){this.bufferList.forEach((e=>{this.viewer.add(e)})),this.setVisibility(this.visible),e()}create(){var e={};if(this.volume){var t,i,r=this.volume;"sigma"===this.thresholdType?(t=r.getValueForSigma(this.thresholdMin),i=r.getValueForSigma(this.thresholdMax)):(t=this.thresholdMin,i=this.thresholdMax),r.setFilter(t,i,this.thresholdOut),Object.assign(e,{position:r.getDataPosition(),color:r.getDataColor(this.getColorParams())}),"sphere"===this.dotType&&Object.assign(e,{radius:r.getDataSize(this.radius,this.scale),picking:r.getDataPicking()})}else{var s=this.surface;Object.assign(e,{position:s.getPosition(),color:s.getColor(this.getColorParams())}),"sphere"===this.dotType&&Object.assign(e,{radius:s.getSize(this.radius,this.scale),picking:s.getPicking()})}"sphere"===this.dotType?this.dotBuffer=new Ta(e,this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!1})):this.dotBuffer=new $a(e,this.getBufferParams({pointSize:this.pointSize,sizeAttenuation:this.sizeAttenuation,sortParticles:this.sortParticles,useTexture:this.useTexture,alphaTest:this.alphaTest,forceTransparent:this.forceTransparent,edgeBleach:this.edgeBleach})),this.bufferList.push(this.dotBuffer)}update(e={}){if(0===this.bufferList.length)return;const t={};e.color&&(this.volume?Object.assign(t,{color:this.volume.getDataColor(this.getColorParams())}):Object.assign(t,{color:this.surface.getColor(this.getColorParams())})),"sphere"===this.dotType&&(e.radius||e.scale)&&(this.volume?Object.assign(t,{radius:this.volume.getDataSize(this.radius,this.scale)}):Object.assign(t,{radius:this.surface.getSize(this.radius,this.scale)})),this.dotBuffer.setAttributes(t)}setParameters(e,t={},i){return e&&void 0!==e.thresholdType&&this.volume instanceof Cn&&("value"===this.thresholdType&&"sigma"===e.thresholdType?(this.thresholdMin=this.volume.getSigmaForValue(this.thresholdMin),this.thresholdMax=this.volume.getSigmaForValue(this.thresholdMax)):"sigma"===this.thresholdType&&"value"===e.thresholdType&&(this.thresholdMin=this.volume.getValueForSigma(this.thresholdMin),this.thresholdMax=this.volume.getValueForSigma(this.thresholdMax)),this.thresholdType=e.thresholdType),e&&void 0!==e.radiusType&&("radius"===e.radiusType?this.radius=.1:this.radius=parseFloat(e.radiusType),t.radius=!0,"sphere"!==this.dotType||De&&!this.disableImpostor||(i=!0)),e&&void 0!==e.radius&&(t.radius=!0,"sphere"!==this.dotType||De&&!this.disableImpostor||(i=!0)),e&&void 0!==e.scale&&(t.scale=!0,"sphere"!==this.dotType||De&&!this.disableImpostor||(i=!0)),super.setParameters(e,t,i),this}}Ve.add("shader/Image.vert","uniform float clipRadius;\nuniform vec3 clipCenter;\nvarying vec2 vUv;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvarying vec3 vViewPosition;\n#endif\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\nvoid main() {\n#include begin_vertex\n#include project_vertex\nvUv = uv;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvViewPosition = -mvPosition.xyz;\n#endif\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n}"),Ve.add("shader/Image.frag","uniform sampler2D map;\nuniform float opacity;\nuniform vec2 mapSize;\nuniform float clipNear;\nuniform float clipRadius;\nvarying vec2 vUv;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvarying vec3 vViewPosition;\n#endif\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#if defined( PICKING )\nuniform sampler2D pickingMap;\nuniform float objectId;\n#else\n#include fog_pars_fragment\n#endif\n#if defined( CUBIC_INTERPOLATION )\n#if defined( CATMULROM_FILTER ) || defined( MITCHELL_FILTER )\n#if defined( CATMULROM_FILTER )\nconst float B = 0.0;\nconst float C = 0.5;\n#elif defined( MITCHELL_FILTER )\nconst float B = 0.333;\nconst float C = 0.333;\n#endif\nfloat filter( float x ){\nfloat f = x;\nif( f < 0.0 ){\nf = -f;\n}\nif( f < 1.0 ){\nreturn ( ( 12.0 - 9.0 * B - 6.0 * C ) * ( f * f * f ) +\n( -18.0 + 12.0 * B + 6.0 *C ) * ( f * f ) +\n( 6.0 - 2.0 * B ) ) / 6.0;\n}else if( f >= 1.0 && f < 2.0 ){\nreturn ( ( -B - 6.0 * C ) * ( f * f * f )\n+ ( 6.0 * B + 30.0 * C ) * ( f *f ) +\n( - ( 12.0 * B ) - 48.0 * C ) * f +\n8.0 * B + 24.0 * C ) / 6.0;\n}else{\nreturn 0.0;\n}\n}\n#elif defined( BSPLINE_FILTER )\nfloat filter( float x ){\nfloat f = x;\nif( f < 0.0 ){\nf = -f;\n}\nif( f >= 0.0 && f <= 1.0 ){\nreturn ( 2.0 / 3.0 ) + ( 0.5 ) * ( f * f * f ) - ( f * f );\n}else if( f > 1.0 && f <= 2.0 ){\nreturn 1.0 / 6.0 * pow( ( 2.0 - f ), 3.0 );\n}\nreturn 1.0;\n}\n#else\nfloat filter( float x ){\nreturn 1.0;\n}\n#endif\nvec4 biCubic( sampler2D tex, vec2 texCoord ){\nvec2 texelSize = 1.0 / mapSize;\ntexCoord -= texelSize / 2.0;\nvec4 nSum = vec4( 0.0 );\nfloat nDenom = 0.0;\nvec2 cell = fract( texCoord * mapSize );\nfor( float m = -1.0; m <= 2.0; ++m ){\nfor( float n = -1.0; n <= 2.0; ++n ){\nvec4 vecData = texture2D(\ntex, texCoord + texelSize * vec2( m, n )\n);\nfloat c = filter( m - cell.x ) * filter( -n + cell.y );\nnSum += vecData * c;\nnDenom += c;\n}\n}\nreturn nSum / nDenom;\n}\n#endif\nvoid main(){\n#include nearclip_fragment\n#include radiusclip_fragment\n#if defined( CUBIC_INTERPOLATION )\ngl_FragColor = biCubic( map, vUv );\n#else\ngl_FragColor = texture2D( map, vUv );\n#endif\n#if defined( PICKING )\nif( gl_FragColor.a < 0.3 )\ndiscard;\ngl_FragColor = vec4( texture2D( pickingMap, vUv ).xyz, objectId );\n#else\nif( gl_FragColor.a < 0.01 )\ndiscard;\ngl_FragColor.a *= opacity;\n#include fog_fragment\n#endif\n}");const Ea=new Uint16Array([0,1,2,1,3,2]),La=new Float32Array([0,1,0,0,1,1,1,0]),Na=Object.assign({filter:"nearest",forceTransparent:!0},Mn),za=Object.assign({filter:{updateShader:!0,uniform:!0}},Dn);class Va extends Tn{constructor(e,i){super({position:e.position,index:Ea,picking:e.picking},i),this.parameterTypes=za,this.alwaysTransparent=!0,this.hasWireframe=!1,this.vertexShader="Image.vert",this.fragmentShader="Image.frag";const{imageData:r,width:s,height:n}=e,o=new t.DataTexture(r,s,n);o.flipY=!0,this.tex=o;const a=r.length,c=new Uint8Array(a);for(let e=0;e>16&255,c[e+1]=t>>8&255,c[e+2]=255&t}const l=new t.DataTexture(c,s,n);l.flipY=!0,l.minFilter=t.NearestFilter,l.magFilter=t.NearestFilter,this.pickingTex=l,this.addUniforms({map:{value:o},pickingMap:{value:l},mapSize:{value:new t.Vector2(s,n)}}),this.geometry.setAttribute("uv",new t.BufferAttribute(La,2))}get defaultParameters(){return Na}getDefines(e){const t=super.getDefines(e),i=this.parameters.filter;return i.startsWith("cubic")&&(t.CUBIC_INTERPOLATION=1,i.endsWith("bspline")?t.BSPLINE_FILTER=1:i.endsWith("catmulrom")?t.CATMULROM_FILTER=1:i.endsWith("mitchell")&&(t.MITCHELL_FILTER=1)),t}updateTexture(){const e=this.tex,i=this.parameters.filter;i.startsWith("cubic")?(e.minFilter=t.NearestFilter,e.magFilter=t.NearestFilter):"linear"===i?(e.minFilter=t.LinearFilter,e.magFilter=t.LinearFilter):(e.minFilter=t.NearestFilter,e.magFilter=t.NearestFilter),e.needsUpdate=!0,this.pickingTex.needsUpdate=!0}makeMaterial(){super.makeMaterial(),this.updateTexture();const e=this.material;e.uniforms.map.value=this.tex,e.blending=t.NormalBlending,e.needsUpdate=!0;const i=this.wireframeMaterial;i.uniforms.map.value=this.tex,i.blending=t.NormalBlending,i.needsUpdate=!0;const r=this.pickingMaterial;r.uniforms.map.value=this.tex,r.uniforms.pickingMap.value=this.pickingTex,r.blending=t.NormalBlending,r.needsUpdate=!0}setUniforms(e){e&&void 0!==e.filter&&(this.updateTexture(),e.map=this.tex),super.setUniforms(e)}}class Ga{constructor(e,t){const i=t||{};this.dimension=l(i.dimension,"x"),this.positionType=l(i.positionType,"percent"),this.position=l(i.position,30),this.thresholdType=l(i.thresholdType,"sigma"),this.thresholdMin=l(i.thresholdMin,-1/0),this.thresholdMax=l(i.thresholdMax,1/0),this.normalize=l(i.normalize,!1),this.volume=e}getPositionFromCoordinate(e){const i=this.dimension,r=this.volume,s=r.matrix,n=(new t.Vector3).setFromMatrixPosition(s)[i],o=(new t.Vector3).setFromMatrixScale(s)[i];let a;return a="x"===i?r.nx:"y"===i?r.ny:r.nz,Math.round(((e-n)/(a/100)+1)/o)}getData(e){e=e||{};const i=this.volume,r=i.data,s=i.matrix;let n;function o(e){return Math.round(e/100*(n-1))}function a(e,t,r,s){return 3*(r*i.ny*i.nx+t*i.nx+e)+s}n="coordinate"===this.positionType?this.getPositionFromCoordinate(this.position):this.position;const c=new Float32Array(12),l=new t.Vector3;let h,u,d,m,p,f=0,g=0,y=0,b=i.nx,x=i.ny,v=i.nz;function w(e,t,i,r){l.set(e,t,i).applyMatrix4(s).toArray(c,r)}"x"===this.dimension?(d=o(i.nx),m=i.ny-1,p=i.nz-1,h=i.nz,u=i.ny,f=d,b=f+1,w(d,0,0,0),w(d,m,0,3),w(d,0,p,6),w(d,m,p,9)):"y"===this.dimension?(d=i.nx-1,m=o(i.ny),p=i.nz-1,h=i.nz,u=i.nx,g=m,x=g+1,w(0,m,0,0),w(d,m,0,3),w(0,m,p,6),w(d,m,p,9)):"z"===this.dimension&&(d=i.nx-1,m=i.ny-1,p=o(i.nz),h=i.nx,u=i.ny,y=p,v=y+1,w(0,0,p,0),w(0,m,p,3),w(d,0,p,6),w(d,m,p,9));let A=0,_=0;const S=new Uint8Array(h*u*4),C=new Float32Array(h*u);let P,I;"sigma"===this.thresholdType?(P=i.getValueForSigma(this.thresholdMin),I=i.getValueForSigma(this.thresholdMax)):(P=this.thresholdMin,I=this.thresholdMax);const k=Object.assign({},e.colorParams,{volume:i});this.normalize&&(k.domain=[0,1]);const M=Ee.getScheme(k),D=new Float32Array(3),T=M.getScale();let B,R=0,O=0;if(this.normalize){R=1/0,B=-1/0;for(let e=g;eB&&(B=s)}O=B-R}for(let e=g;eP&&n{this.viewer.add(e)})),this.setVisibility(this.visible),e()}create(){const e=new Ga(this.volume,{positionType:this.positionType,position:this.position,dimension:this.dimension,thresholdType:this.thresholdType,thresholdMin:this.thresholdMin,thresholdMax:this.thresholdMax,normalize:this.normalize}),t=new Va(e.getData({colorParams:this.getColorParams()}),this.getBufferParams({filter:this.filter}));this.bufferList.push(t)}}function ja(e){Be.error(`makeRepresentation: representation type ${e} unknown`)}const Ha={name:"some element",status:""};class Wa{constructor(e,t={}){this.stage=e,this.signals={statusChanged:new r.Signal,nameChanged:new r.Signal,disposed:new r.Signal},this.parameters=h(t,this.defaultParameters),this.uuid=O()}get defaultParameters(){return Ha}get name(){return this.parameters.name}setStatus(e){return this.parameters.status=e,this.signals.statusChanged.dispatch(e),this}setName(e){return this.parameters.name=e,this.signals.nameChanged.dispatch(e),this}dispose(){this.signals.disposed.dispatch()}}const qa=Object.assign({visible:!0},Ha);class Xa extends Wa{constructor(e,t,i={},s){super(e,Object.assign({name:t.type},i)),this.parent=s,this.signals=Object.assign({visibilityChanged:new r.Signal,parametersChanged:new r.Signal},this.signals),this.setRepresentation(t)}get defaultParameters(){return qa}get visible(){return this.parameters.visible}get type(){return"representation"}getType(){return this.repr.type}setRepresentation(e){this._disposeRepresentation(),this.repr=e,this.stage.tasks.listen(this.repr.tasks),this.updateVisibility()}_disposeRepresentation(){this.repr&&(this.stage.tasks.unlisten(this.repr.tasks),this.repr.dispose())}dispose(){this.parent&&this.parent.hasRepresentation(this)?this.parent.removeRepresentation(this):(this._disposeRepresentation(),this.signals.disposed.dispatch())}setVisibility(e){return this.parameters.visible=e,this.updateVisibility(),this.signals.visibilityChanged.dispatch(this.parameters.visible),this}getVisibility(){return this.parent?this.parent.parameters.visible&&this.parameters.visible:this.parameters.visible}toggleVisibility(){return this.setVisibility(!this.parameters.visible)}updateVisibility(){this.repr.setVisibility(this.getVisibility())}update(e){return this.repr.update(e),this}build(e){return this.repr.build(e),this}setSelection(e){const t=this.repr;return t.setSelection&&t.setSelection(e),this}setParameters(e){return this.repr.setParameters(e),this.signals.parametersChanged.dispatch(this.repr.getParameters()),this}getParameters(){return this.repr.getParameters()}setColor(e){return this.repr.setColor(e),this}}const Ya=new t.Matrix4,Ka=new t.Vector3,Za={name:"",status:"",visible:!0};class Qa{constructor(e,i,s={}){this.stage=e,this.object=i,this.signals={representationAdded:new r.Signal,representationRemoved:new r.Signal,visibilityChanged:new r.Signal,matrixChanged:new r.Signal,statusChanged:new r.Signal,nameChanged:new r.Signal,disposed:new r.Signal},this.reprList=[],this.annotationList=[],this.matrix=new t.Matrix4,this.position=new t.Vector3,this.quaternion=new t.Quaternion,this.scale=new t.Vector3(1,1,1),this.transform=new t.Matrix4,this.parameters=h(s,this.defaultParameters),this.uuid=O(),this.viewer=e.viewer,this.controls=new to(this)}get defaultParameters(){return Za}get name(){return this.parameters.name}get status(){return this.parameters.status}get visible(){return this.parameters.visible}setPosition(e){return Array.isArray(e)?this.position.fromArray(e):this.position.copy(e),this.updateMatrix(),this}setRotation(e){if(Array.isArray(e))if(3===e.length){const i=(new t.Euler).fromArray(e);this.quaternion.setFromEuler(i)}else this.quaternion.fromArray(e);else e instanceof t.Euler?this.quaternion.setFromEuler(e):this.quaternion.copy(e);return this.updateMatrix(),this}setScale(e){return this.scale.set(e,e,e),this.updateMatrix(),this}setTransform(e){return this.transform.copy(e),this.updateMatrix(),this}updateMatrix(){const e=this.getCenterUntransformed(Ka);this.matrix.makeTranslation(-e.x,-e.y,-e.z),Ya.makeRotationFromQuaternion(this.quaternion),this.matrix.premultiply(Ya),Ya.makeScale(this.scale.x,this.scale.y,this.scale.z),this.matrix.premultiply(Ya);const t=this.position;Ya.makeTranslation(t.x+e.x,t.y+e.y,t.z+e.z),this.matrix.premultiply(Ya),this.matrix.premultiply(this.transform),this.updateRepresentationMatrices(),this.stage.viewer.updateBoundingBox(),this.signals.matrixChanged.dispatch(this.matrix)}updateRepresentationMatrices(){this.reprList.forEach((e=>{e.setParameters({matrix:this.matrix})}))}addAnnotation(e,t,i){const r=new Zn(this,e,t,i);return this.annotationList.push(r),r}eachAnnotation(e){this.annotationList.slice().forEach(e)}removeAnnotation(e){const t=this.annotationList.indexOf(e);-1!==t&&(this.annotationList.splice(t,1),e.dispose())}removeAllAnnotations(){this.eachAnnotation((e=>e.dispose())),this.annotationList.length=0}_addRepresentation(t,i,r,s=!1){const n=r||{},o=this.stage.getParameters();n.matrix=this.matrix.clone(),n.quality=n.quality||o.quality,n.disableImpostor=l(n.disableImpostor,!o.impostor),n.useWorker=l(n.useWorker,o.workerDefault),n.visible=l(n.visible,!0);const a=Object.assign({},n,{visible:this.parameters.visible&&n.visible}),c=function(t,i,r,s){var n;if(e.Debug&&Be.time("makeRepresentation "+t),i instanceof pa){if(!(n=Ne.get(t)))return void ja(t)}else if(i instanceof _n)if("surface"===t)n=Ln;else{if("dot"!==t)return void ja(t);n=Fa}else if(i instanceof Cn)if("surface"===t)n=Ln;else if("dot"===t)n=Fa;else{if("slice"!==t)return void ja(t);n=Ua}else if(i instanceof ba)n=xa,i=i.getBufferList();else{if("buffer"!==t)return void Be.error("makeRepresentation: object "+i+" unknown");n=xa}const o=new n(i,r,s);return e.Debug&&Be.timeEnd("makeRepresentation "+t),o}(t,i,this.viewer,a),h=new Xa(this.stage,c,n,this);return s||(this.reprList.push(h),this.signals.representationAdded.dispatch(h)),h}addBufferRepresentation(e,t){return this._addRepresentation.call(this,"buffer",e,t)}hasRepresentation(e){return-1!==this.reprList.indexOf(e)}eachRepresentation(e){this.reprList.slice().forEach(e)}removeRepresentation(e){const t=this.reprList.indexOf(e);-1!==t&&(this.reprList.splice(t,1),e.dispose(),this.signals.representationRemoved.dispatch(e))}updateRepresentations(e){this.reprList.forEach((t=>t.update(e))),this.stage.viewer.requestRender()}removeAllRepresentations(){this.eachRepresentation((e=>e.dispose()))}dispose(){this.removeAllAnnotations(),this.removeAllRepresentations(),this.reprList.length=0,this.signals.disposed.dispatch()}setVisibility(e){return this.parameters.visible=e,this.eachRepresentation((e=>e.updateVisibility())),this.eachAnnotation((e=>e.updateVisibility())),this.signals.visibilityChanged.dispatch(e),this}setStatus(e){return this.parameters.status=e,this.signals.statusChanged.dispatch(e),this}setName(e){return this.parameters.name=e,this.signals.nameChanged.dispatch(e),this}getBox(...e){return this.getBoxUntransformed(...e).clone().applyMatrix4(this.matrix)}getCenter(...e){return this.getCenterUntransformed(...e).clone().applyMatrix4(this.matrix)}getZoom(...e){return this.stage.getZoomForBox(this.getBox(...e))}getBoxUntransformed(...e){return new t.Box3}getCenterUntransformed(...e){return this.getBoxUntransformed().getCenter(new t.Vector3)}autoView(e){this.stage.animationControls.zoomMove(this.getCenter(),this.getZoom(),l(e,0))}}class Ja{constructor(e=[]){this.list=e;const t=e.length;for(let i=0;i0?this.list[0]:void 0}forEach(e){return this.list.forEach(e),this}dispose(){return this.forEach((e=>e.dispose()))}}class ec extends Ja{setParameters(e){return this.forEach((t=>t.setParameters(e)))}setVisibility(e){return this.forEach((t=>t.setVisibility(e)))}setSelection(e){return this.forEach((t=>t.setSelection(e)))}setColor(e){return this.forEach((t=>t.setColor(e)))}update(e){return this.forEach((t=>t.update(e)))}build(e){return this.forEach((t=>t.build(e)))}dispose(e){return this.forEach((e=>e.dispose()))}}const tc=Object.assign({defaultStep:1,defaultTimeout:50,defaultInterpolateType:"",defaultInterpolateStep:5,defaultMode:"loop",defaultDirection:"forward",initialFrame:0},Ha);class ic extends Wa{constructor(e,t,i={}){super(e,Object.assign({name:t.name},i)),this.trajectory=t,this.signals=Object.assign(this.signals,{frameChanged:new r.Signal,playerChanged:new r.Signal,countChanged:new r.Signal,parametersChanged:new r.Signal}),t.signals.frameChanged.add((e=>{this.signals.frameChanged.dispatch(e)})),t.signals.playerChanged.add((e=>{this.signals.playerChanged.dispatch(e)})),t.signals.countChanged.add((e=>{this.signals.countChanged.dispatch(e)})),void 0!==i.initialFrame&&this.setFrame(i.initialFrame)}get defaultParameters(){return tc}get type(){return"trajectory"}setFrame(e){this.trajectory.setFrame(e)}setParameters(e={}){this.trajectory.setParameters(e),this.signals.parametersChanged.dispatch(e)}dispose(){this.trajectory.dispose(),super.dispose()}}class rc{constructor(e,t){this.name=e,this.path=t,this.coordinates=[],this.boxes=[],this.times=[],this.timeOffset=0,this.deltaTime=1}get type(){return"Frames"}}class sc{constructor(e,i){let r,s;if(this.A=new Js(3,3),this.W=new Js(1,3),this.U=new Js(3,3),this.V=new Js(3,3),this.VH=new Js(3,3),this.R=new Js(3,3),this.tmp=new Js(3,3),this.c=new Js(3,3),e instanceof pa)r=e.atomCount;else{if(!(e instanceof Float32Array))return;r=e.length/3}if(i instanceof pa)s=i.atomCount;else{if(!(i instanceof Float32Array))return;s=i.length/3}const n=Math.min(r,s),o=new Js(3,n),a=new Js(3,n);this.coords1t=new Js(n,3),this.coords2t=new Js(n,3),this.transformationMatrix=new t.Matrix4,this.c.data.set([1,0,0,0,1,0,0,0,-1]),this.prepCoords(e,o,n,!1),this.prepCoords(i,a,n,!1),this._superpose(o,a)}_superpose(t,i){this.mean1=sn(t),this.mean2=sn(i),nn(t,this.mean1),nn(i,this.mean2),en(this.coords1t,t),en(this.coords2t,i),tn(this.A,this.coords2t,this.coords1t),hn(this.A,this.W,this.U,this.V),function(e,t){const i=e.data,r=t.data,s=i[4],n=i[8],o=i[5],a=i[7],c=i[0],l=c*s,h=c*o,u=i[3],d=i[1],m=u*d,p=i[2],f=u*p,g=i[6],y=g*d,b=g*p,x=1/(l*n-h*a-m*n+f*a+y*o-b*s);r[0]=(s*n-o*a)*x,r[1]=-(d*n-p*a)*x,r[2]=-(-d*o+p*s)*x,r[3]=-(u*n-o*g)*x,r[4]=(c*n-b)*x,r[5]=-(h-f)*x,r[6]=-(-u*a+s*g)*x,r[7]=-(c*a-y)*x,r[8]=(l-m)*x}(this.V,this.VH),rn(this.R,this.U,this.VH),function(e){const t=e.data;return t[0]*t[4]*t[8]-t[0]*t[5]*t[7]-t[3]*t[1]*t[8]+t[3]*t[2]*t[7]+t[6]*t[1]*t[5]-t[6]*t[2]*t[4]}(this.R)<0&&(e.Debug&&Be.log("R not a right handed system"),rn(this.tmp,this.c,this.VH),rn(this.R,this.U,this.tmp));const r=new Js(4,4),s=new Js(4,4),n=new Js(4,4),o=new Js(4,4),a=new Js(4,4),c=new Js(4,4),l=this.R.data,h=this.mean1,u=this.mean2;o.data.set([1,0,0,-h[0],0,1,0,-h[1],0,0,1,-h[2],0,0,0,1]),a.data.set([l[0],l[1],l[2],0,l[3],l[4],l[5],0,l[6],l[7],l[8],0,0,0,0,1]),c.data.set([1,0,0,u[0],0,1,0,u[1],0,0,1,u[2],0,0,0,1]),en(s,o),tn(r,a,s),en(n,r),tn(s,c,n),en(r,s),this.transformationMatrix.elements=r.data}prepCoords(e,t,i,r){let s=0;const n=t.data;let o=3,a=3*i;if(r&&(a=4*i,o=4),e instanceof pa)e.eachAtom((function(e){s{e!==this&&this.pause()}),this);const i=l(e.frameCount,1);this.traj=e,this.parameters=h(t,nc),this.parameters.end=Math.min(l(t.end,i-1),i-1),this.parameters.step=l(t.step,Math.ceil((i+1)/100)),this._currentFrame=this.parameters.start,this._direction="bounce"===this.parameters.direction?"forward":this.parameters.direction,e.signals.countChanged.add((e=>{this.parameters.end=Math.min(l(this.parameters.end,e-1),e-1)}),this),this._animate=this._animate.bind(this)}get isRunning(){return this._run}setParameters(e={}){u(this.parameters,e),void 0!==e.direction&&"bounce"!==this.parameters.direction&&(this._direction=this.parameters.direction)}_animate(){if(!this._run)return;this._currentTime=window.performance.now();const e=this._currentTime-this._previousTime,t=this.parameters.interpolateType?this.parameters.interpolateStep:1,i=this.parameters.timeout/t,r=this.traj;if(r&&r.frameCount&&!r.inProgress&&e>=i)if(this.parameters.interpolateType)if(this._currentStep>this.parameters.interpolateStep&&(this._currentStep=1),1===this._currentStep&&(this._currentFrame=this._nextInterpolated()),r.hasFrame(this._currentFrame)){this._currentStep+=1;const e=this._currentStep/(this.parameters.interpolateStep+1),[t,i,s,n]=this._currentFrame;r.setFrameInterpolated(t,i,s,n,e,this.parameters.interpolateType),this._previousTime=this._currentTime}else r.loadFrame(this._currentFrame);else{const e=this._next();r.hasFrame(e)?(r.setFrame(e),this._previousTime=this._currentTime):r.loadFrame(e)}window.requestAnimationFrame(this._animate)}_next(){const e=this.parameters;let t;return t="forward"===this._direction?this.traj.currentFrame+e.step:this.traj.currentFrame-e.step,(t>e.end||t=e.end?i=e.start:"backward"===e.direction&&t<=e.start&&(i=e.end),this.traj.setFrame(i),this._run=!0,this._animate(),this.signals.startedRunning.dispatch()}}pause(){this._run=!1,this.signals.haltedRunning.dispatch()}stop(){this.pause(),this.traj.setFrame(this.parameters.start)}}class ac{constructor(e,t,i={}){this.signals={countChanged:new r.Signal,frameChanged:new r.Signal,playerChanged:new r.Signal},this.frameCache={},this.loadQueue={},this.boxCache={},this.pathCache={},this.frameCacheSize=0,this._frameCount=0,this._currentFrame=-1,this._disposed=!1,this.deltaTime=l(i.deltaTime,0),this.timeOffset=l(i.timeOffset,0),this.centerPbc=l(i.centerPbc,!1),this.removePbc=l(i.removePbc,!1),this.removePeriodicity=l(i.removePeriodicity,!1),this.superpose=l(i.superpose,!1),this.name=e.replace(/^.*[\\/]/,""),this.trajPath=e,this.selection=new ye(l(i.sele,"backbone and not hydrogen")),this.selection.signals.stringChanged.add((()=>{this.selectionIndices=this.structure.getAtomIndices(this.selection),this._resetCache(),this._saveInitialCoords(),this.setFrame(this._currentFrame)}))}get frameCount(){return this._frameCount}get currentFrame(){return this._currentFrame}_init(e){this.setStructure(e),this._loadFrameCount(),this.setPlayer(new oc(this))}_loadFrameCount(){}setStructure(e){this.structure=e,this.atomCount=e.atomCount,this.backboneIndices=this._getIndices(new ye("backbone and not hydrogen")),this._makeAtomIndices(),this._saveStructureCoords(),this.selectionIndices=this._getIndices(this.selection),this._resetCache(),this._saveInitialCoords(),this.setFrame(this._currentFrame)}_saveInitialCoords(){this.structure.hasCoords()?(this.initialCoords=new Float32Array(this.structureCoords),this._makeSuperposeCoords()):this.frameCache[0]?(this.initialCoords=new Float32Array(this.frameCache[0]),this._makeSuperposeCoords()):this.loadFrame(0,(()=>this._saveInitialCoords()))}_saveStructureCoords(){this.structureCoords=this.structure.getAtomData({what:{position:!0}}).position}setSelection(e){return this.selection.setString(e),this}_getIndices(e){let t=0;const i=e.test,r=[];return i&&this.structure.eachAtom((e=>{i(e)&&r.push(t),t+=1})),r}_makeSuperposeCoords(){const e=3*this.selectionIndices.length;this.coords1=new Float32Array(e),this.coords2=new Float32Array(e);const t=this.initialCoords,i=this.coords2;for(let r=0;r!!this.frameCache[e])):!!this.frameCache[e]}setFrame(e,t){return void 0===e||(this.inProgress=!0,-1===e||this.frameCache[e]?(this._updateStructure(e),t&&t()):this.loadFrame(e,(()=>{this._updateStructure(e),t&&t()}))),this}_interpolate(e,t,i,r,s,n){const o=this.frameCache;let a;a="spline"===n?function(e,t,i,r,s){const n=e.length,o=new Float32Array(n);for(let a=0;a{this._interpolate(e,t,i,r,s,n),o&&o()})):(this._interpolate(e,t,i,r,s,n),o&&o()),this}loadFrame(e,t){Array.isArray(e)?e.forEach((e=>{this.loadQueue[e]||this.frameCache[e]||(this.loadQueue[e]=!0,this._loadFrame(e,(()=>{delete this.loadQueue[e]})))})):this.loadQueue[e]||this.frameCache[e]||(this.loadQueue[e]=!0,this._loadFrame(e,(()=>{delete this.loadQueue[e],t&&t()})))}_loadFrame(e,t){Be.error("Trajectory._loadFrame not implemented",e,t)}_updateStructure(e){this._disposed?console.error("updateStructure: traj disposed"):(-1===e?this.structureCoords&&this.structure.updatePosition(this.structureCoords):this.structure.updatePosition(this.frameCache[e]),this.structure.trajectory={name:this.trajPath,frame:e},this._currentFrame=e,this.inProgress=!1,this.signals.frameChanged.dispatch(e))}_doSuperpose(e){const t=3*this.selectionIndices.length,i=this.coords1,r=this.coords2;for(let r=0;r0&&this.centerPbc){const e=[t[0],t[4],t[8]],r=function(e,t,i){return[pt(t,i[0],3,0,e),pt(t,i[1],3,1,e),pt(t,i[2],3,2,e)]}(this.backboneIndices,i,e);!function(e,t,i){if(0===i[0]||0===i[8]||0===i[4])return;const r=e.length,s=i[0],n=i[1],o=i[2],a=-t[0]+s+s/2,c=-t[1]+n+n/2,l=-t[2]+o+o/2;for(let t=0;t.5&&(e[s+r]-=t[3*r+r]*Math.round(n))}}(i,t,e)}this.removePbc&&function(e,t){if(0===t[0]||0===t[8]||0===t[4])return;const i=e.length;for(let r=3;r.9*t[3*i+i])if(s>0)for(let s=0;s<3;++s)e[r+s]-=t[3*i+s];else for(let s=0;s<3;++s)e[r+s]+=t[3*i+s]}}(i,t)}this.selectionIndices.length>0&&this.coords1&&this.superpose&&this._doSuperpose(i),this.frameCache[e]=i,this.boxCache[e]=t,this.frameCacheSize+=1}_setFrameCount(e){e!==this._frameCount&&(this._frameCount=e,this.signals.countChanged.dispatch(e))}dispose(){this._resetCache(),this._disposed=!0,this.player&&this.player.stop()}setPlayer(e){this.player=e,this.signals.playerChanged.dispatch(e)}getFrameTime(e){return this.timeOffset+e*this.deltaTime}}class cc extends ac{constructor(e,t,i){const r=i||{};r.timeOffset=l(r.timeOffset,e.timeOffset),r.deltaTime=l(r.deltaTime,e.deltaTime),super("",t,r),this.name=e.name,this.path=e.path,this.frames=e.coordinates,this.boxes=e.boxes,this._init(t)}get type(){return"frames"}_makeAtomIndices(){"StructureView"===this.structure.type?this.atomIndices=this.structure.getAtomIndices():this.atomIndices=void 0}_loadFrame(e,t){let i;const r=this.frames[e];if(this.atomIndices){const e=this.atomIndices,t=e.length;i=new Float32Array(3*t);for(let s=0;s{const e=r.response;if(!e)return void Be.error(`empty arrayBuffer for '${s}'`);const n=new Int32Array(e,0,1)[0],o=new Float32Array(e,8,9),a=new Float32Array(e,44);this._process(t,o,a,n),"function"==typeof i&&i()}),!1),r.send(n)}_loadFrameCount(){const t=new XMLHttpRequest,i=e.TrajectoryDatasource.getCountUrl(this.trajPath);t.open("GET",i,!0),t.addEventListener("load",(()=>{this._setFrameCount(parseInt(t.response))}),!1),t.send()}}class uc extends ac{constructor(e,t,i){super("",t,i),this.requestCallback=e,this._init(t)}get type(){return"callback"}_makeAtomIndices(){const e=[];if("StructureView"===this.structure.type){const t=this.structure.getAtomIndices(),i=t.length;let r=t[0],s=t[0];for(let n=1;n{this._process(e,i,r,s),"function"==typeof t&&t()}),e,this.atomIndices)}_loadFrameCount(){this.requestCallback((e=>this._setFrameCount(e)))}}pa.prototype.getView=function(e){return new dc(this,e)};class dc extends pa{constructor(e,i){super(),this.structure=e,this.selection=i,this.center=new t.Vector3,this.boundingBox=new t.Box3,this._bp=this.getBondProxy(),this._ap=this.getAtomProxy(),this._rp=this.getResidueProxy(),this._cp=this.getChainProxy(),this.selection&&this.selection.signals.stringChanged.add(this.refresh,this),this.structure.signals.refreshed.add(this.refresh,this),this.refresh()}init(){}get type(){return"StructureView"}get name(){return this.structure.name}get path(){return this.structure.path}get title(){return this.structure.title}get id(){return this.structure.id}get data(){return this.structure.data}get atomSetDict(){return this.structure.atomSetDict}get biomolDict(){return this.structure.biomolDict}get entityList(){return this.structure.entityList}get unitcell(){return this.structure.unitcell}get frames(){return this.structure.frames}get boxes(){return this.structure.boxes}get validation(){return this.structure.validation}get bondStore(){return this.structure.bondStore}get backboneBondStore(){return this.structure.backboneBondStore}get rungBondStore(){return this.structure.rungBondStore}get atomStore(){return this.structure.atomStore}get residueStore(){return this.structure.residueStore}get chainStore(){return this.structure.chainStore}get modelStore(){return this.structure.modelStore}get atomMap(){return this.structure.atomMap}get residueMap(){return this.structure.residueMap}get bondHash(){return this.structure.bondHash}get spatialHash(){return this.structure.spatialHash}get _hasCoords(){return this.structure._hasCoords}set _hasCoords(e){this.structure._hasCoords=e}refresh(){e.Debug&&Be.time("StructureView.refresh"),this.atomSetCache={};const i=this.structure;if(this.selection.isAllSelection()&&i!==this&&i.atomSet&&i.bondSet){this.atomSet=i.atomSet.clone(),this.bondSet=i.bondSet.clone();for(let e in this.atomSetDict){const t=this.atomSetDict[e];this.atomSetCache["__"+e]=t.clone()}this.atomCount=i.atomCount,this.bondCount=i.bondCount,this.boundingBox.copy(i.boundingBox),this.center.copy(i.center)}else if(this.selection.isNoneSelection()&&i!==this&&i.atomSet&&i.bondSet){this.atomSet=new Sr(i.atomCount),this.bondSet=new Sr(i.bondCount);for(let e in this.atomSetDict)this.atomSetCache["__"+e]=new Sr(i.atomCount);this.atomCount=0,this.bondCount=0,this.boundingBox.makeEmpty(),this.center.set(0,0,0)}else{this.atomSet=this.getAtomSet(this.selection,!0),i.atomSet&&(this.atomSet=this.atomSet.intersection(i.atomSet)),this.bondSet=this.getBondSet();for(let e in this.atomSetDict){const t=this.atomSetDict[e];this.atomSetCache["__"+e]=t.makeIntersection(this.atomSet)}this.atomCount=this.atomSet.getSize(),this.bondCount=this.bondSet.getSize(),this.boundingBox=this.getBoundingBox(),this.center=this.boundingBox.getCenter(new t.Vector3)}e.Debug&&Be.timeEnd("StructureView.refresh"),this.signals.refreshed.dispatch()}setSelection(e){this.selection=e,this.refresh()}getSelection(e){const t=[];e&&e.string&&t.push(e.string);const i=this.structure.getSelection();i&&i.string&&t.push(i.string),this.selection&&this.selection.string&&t.push(this.selection.string);let r="";return t.length>0&&(r=`( ${t.join(" ) AND ( ")} )`),new ye(r)}getStructure(){return this.structure.getStructure()}eachBond(e,t){this.structure.eachBond(e,this.getSelection(t))}eachAtom(e,t){const i=this.getAtomProxy(),r=this.getAtomSet(t),s=this.atomStore.count;if(r.getSize()=this.V[r][s]?(i="S",this.score=this.S[r][s]):this.V[r][s]>=this.H[r][s]?(i="V",this.score=this.V[r][s]):(i="H",this.score=this.H[r][s]),e.Debug&&Be.log("Alignment: SCORE",this.score),e.Debug&&Be.log("Alignment: S, V, H",this.S[r][s],this.V[r][s],this.H[r][s]);r>0&&s>0;)"S"===i?this.S[r][s]===this.S[r-1][s-1]+t(r-1,s-1)?(this.ali1=this.seq1[r-1]+this.ali1,this.ali2=this.seq2[s-1]+this.ali2,--r,--s,i="S"):this.S[r][s]===this.V[r][s]?i="V":this.S[r][s]===this.H[r][s]?i="H":(--r,--s):"V"===i?this.V[r][s]===this.V[r-1][s]+this.gapExtensionPenalty?(this.ali1=this.seq1[r-1]+this.ali1,this.ali2="-"+this.ali2,--r,i="V"):this.V[r][s]===this.S[r-1][s]+this.gap(0)?(this.ali1=this.seq1[r-1]+this.ali1,this.ali2="-"+this.ali2,--r,i="S"):--r:"H"===i?this.H[r][s]===this.H[r][s-1]+this.gapExtensionPenalty?(this.ali1="-"+this.ali1,this.ali2=this.seq2[s-1]+this.ali2,--s,i="H"):this.H[r][s]===this.S[r][s-1]+this.gap(0)?(this.ali1="-"+this.ali1,this.ali2=this.seq2[s-1]+this.ali2,--s,i="S"):--s:Be.error("Alignment: no matrix");for(;r>0;)this.ali1=this.seq1[r-1]+this.ali1,this.ali2="-"+this.ali2,--r;for(;s>0;)this.ali1="-"+this.ali1,this.ali2=this.seq2[s-1]+this.ali2,--s;e.Debug&&Be.timeEnd("Alignment.trace"),e.Debug&&Be.log([this.ali1,this.ali2])}}function yc(e,t,i=!1,r="",s=""){let n,o,a,c,l;if(i){let i=e,h=t;r&&s&&(i=e.getView(new ye(r)),h=t.getView(new ye(s)));const u=i.getSequence(),d=h.getSequence(),m=new gc(u.join(""),d.join(""));let p,f;m.calc(),m.trace(),n=0,o=0,a=m.ali1.length;const g=[],y=[];for(let e=0;ee[t]))}}}(),this.spacefillRepresentation=this.addRepresentation("spacefill",{sele:"none",opacity:Re.opacity,color:Re.color,disablePicking:!0,radiusType:"data"},!0),this.distanceRepresentation=this.addRepresentation("distance",Re,!0),this.angleRepresentation=this.addRepresentation("angle",Re,!0),this.dihedralRepresentation=this.addRepresentation("dihedral",Re,!0),this.measureRepresentations=new ec([this.spacefillRepresentation,this.distanceRepresentation,this.angleRepresentation,this.dihedralRepresentation]),this.setDefaultAssembly(this.parameters.defaultAssembly),this.structure.signals.refreshed.add((()=>{this.updateRepresentations({position:!0})}))}get defaultParameters(){return bc}get type(){return"structure"}initSelection(e){this.selection=new ye(e),this.structureView=new dc(this.structure,this.selection),this.selection.signals.stringChanged.add((()=>{this.structureView.setSelection(this.selection),this.rebuildRepresentations(),this.rebuildTrajectories()}))}setSelection(e){return this.parameters.sele=e,this.selection.setString(e),this}setDefaultAssembly(e){if(void 0===this.structure.biomolDict[e]&&(e=""),this.parameters.defaultAssembly!==e){const t={defaultAssembly:e};this.reprList.forEach((e=>e.setParameters(t))),this.measureRepresentations.setParameters(t),this.parameters.defaultAssembly=e,this.signals.defaultAssemblyChanged.dispatch(e)}return this}rebuildRepresentations(){this.reprList.forEach((e=>{e.build()})),this.measureRepresentations.build()}rebuildTrajectories(){this.trajList.forEach((e=>{e.trajectory.setStructure(this.structureView)}))}updateRepresentations(e){super.updateRepresentations(e),this.measureRepresentations.update(e)}updateRepresentationMatrices(){super.updateRepresentationMatrices(),this.measureRepresentations.setParameters({matrix:this.matrix})}addRepresentation(e,t={},i=!1){t.defaultAssembly=this.parameters.defaultAssembly;const r=this._addRepresentation(e,this.structureView,t,i);return i||r.signals.parametersChanged.add((()=>this.measureUpdate())),r}addTrajectory(e="",t={}){const i=function(e,t,i){let r;return r=e&&e instanceof rc?new cc(e,t,i):!e&&t.frames?new lc(e,t,i):e&&"function"==typeof e?new uc(e,t,i):new hc(e,t,i),r}(e,this.structureView,t),r=new ic(this.stage,i,t);return this.trajList.push(r),this.signals.trajectoryAdded.dispatch(r),r}removeTrajectory(e){const t=this.trajList.indexOf(e);-1!==t&&this.trajList.splice(t,1),e.dispose(),this.signals.trajectoryRemoved.dispatch(e)}dispose(){this.trajList.slice().forEach((e=>e.dispose())),this.trajList.length=0,this.structure.dispose(),this.measureRepresentations.dispose(),super.dispose()}autoView(e,t){"number"==typeof e&&(t=e,e=""),this.stage.animationControls.zoomMove(this.getCenter(e),this.getZoom(e),l(t,0))}getBoxUntransformed(e){let t;return t=e?this.structureView.getBoundingBox(new ye(e)):this.structureView.boundingBox,t}getCenterUntransformed(e){return e&&"string"==typeof e?this.structure.atomCenter(new ye(e)):this.structure.center}superpose(e,t,i,r){return yc(this.structureView,e.structureView,t,i,r),this.updateRepresentations({position:!0}),this}getMaxRepresentationRadius(e){let t=0;const i=this.structure.getAtomProxy(e);return this.eachRepresentation((e=>{if(e.getVisibility()){const r=e.repr;t=Math.max(r.getAtomRadius(i),t)}})),t}measurePick(e){const t=this.pickBuffer.count;if(this.lastPick===e.index&&t>=1){if(t>1){const e=this.pickBuffer.data,i=this.pickBuffer.data.sort();this.pickDict.has(i)?this.pickDict.del(i):this.pickDict.add(i,e),2===t?this.distanceRepresentation.setParameters({atomPair:this.pickDict.values.filter((e=>2===e.length))}):3===t?this.angleRepresentation.setParameters({atomTriple:this.pickDict.values.filter((e=>3===e.length))}):4===t&&this.dihedralRepresentation.setParameters({atomQuad:this.pickDict.values.filter((e=>4===e.length))})}this.pickBuffer.clear(),this.lastPick=void 0}else this.pickBuffer.has(e.index)||this.pickBuffer.push(e.index),this.lastPick=e.index;this.measureUpdate()}measureClear(){this.pickBuffer.clear(),this.lastPick=void 0,this.spacefillRepresentation.setSelection("none")}measureBuild(){const e=this.measureData();this.distanceRepresentation.setParameters({atomPair:e.distance}),this.angleRepresentation.setParameters({atomTriple:e.angle}),this.dihedralRepresentation.setParameters({atomQuad:e.dihedral})}measureUpdate(){const e=this.pickBuffer.data,t={};e.forEach((e=>{const i=Math.max(.1,this.getMaxRepresentationRadius(e));t[e]=i*(2.3-L(.1,2,i))})),this.spacefillRepresentation.setSelection(e.length?"@"+e.join(","):"none"),e.length&&this.spacefillRepresentation.setParameters({radiusData:t})}measureData(){const e=this.pickDict.values;return{distance:e.filter((e=>2===e.length)),angle:e.filter((e=>3===e.length)),dihedral:e.filter((e=>4===e.length))}}removeAllMeasurements(e){const t=this.pickDict,i=t.values,r=function(e){i.filter((t=>t.length===e)).forEach((e=>t.del(e.slice().sort())))};(!e||1&e)&&r(2),(!e||2&e)&&r(3),(!e||4&e)&&r(4),this.measureBuild()}removeMeasurement(e){this.pickDict.del(e.slice().sort()),this.measureBuild()}addMeasurement(e){if(e.length<2||e.length>4)return;const t=e.slice().sort();this.pickDict.has(t)||this.pickDict.add(t,e),this.measureBuild()}}Ue.add("structure",xc),Ue.add("structureview",xc);class vc extends Qa{constructor(e,t,i={}){super(e,t,Object.assign({name:t.name},i)),this.surface=t}get type(){return"surface"}addRepresentation(e,t={}){return this._addRepresentation(e,this.surface,t)}getBoxUntransformed(){return this.surface.boundingBox}getCenterUntransformed(){return this.surface.center}dispose(){this.surface.dispose(),super.dispose()}}Ue.add("surface",vc);class wc extends Qa{constructor(e,t,i={}){super(e,t,Object.assign({name:t.name},i)),this.volume=t}get type(){return"volume"}addRepresentation(e,t={}){return this._addRepresentation(e,this.volume,t)}getBoxUntransformed(){return this.volume.boundingBox}getCenterUntransformed(){return this.volume.center}dispose(){this.volume.dispose(),super.dispose()}}Ue.add("volume",wc);class Ac extends Ja{addRepresentation(e,t){return this.forEach((i=>i.addRepresentation(e,t)))}autoView(e){return this.forEach((t=>t.autoView(e)))}}function _c(e,t){return e instanceof RegExp?null!==t.name.match(e):t.name===e}const Sc=new t.Vector3,Cc={impostor:!0,quality:"medium",workerDefault:!0,sampleLevel:0,backgroundColor:"black",rotateSpeed:2,zoomSpeed:1.2,panSpeed:1,clipNear:0,clipFar:100,clipDist:10,clipMode:"scene",clipScale:"relative",fogNear:50,fogFar:100,cameraFov:40,cameraEyeSep:.3,cameraType:"perspective",lightColor:14540253,lightIntensity:1,ambientColor:14540253,ambientIntensity:.2,hoverTimeout:0,tooltip:!0,mousePreset:"default"};class Pc extends Qa{constructor(e,t,i={}){super(e,t,Object.assign({name:t.name},i)),this.shape=t}get type(){return"shape"}addRepresentation(e,t={}){return this._addRepresentation(e,this.shape,t)}getBoxUntransformed(){return this.shape.boundingBox}getCenterUntransformed(){return this.shape.center}dispose(){this.shape.dispose(),super.dispose()}}function Ic(e,t,i,r){var s,n=arguments.length,o=n<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,r);else for(var a=e.length-1;a>=0;a--)(s=e[a])&&(o=(n<3?s(o):n>3?s(t,i,o):s(t,i))||o);return n>3&&o&&Object.defineProperty(t,i,o),o}Ue.add("shape",Pc);class kc extends U{constructor(e){super(e),e.scale||(this.parameters.scale="rainbow",this.parameters.reverse=l(e.reverse,!0)),this.scalePerModel={},e.structure.eachModel((e=>{this.parameters.domain=[e.atomOffset,e.atomEnd],this.scalePerModel[e.index]=this.getScale()}))}atomColor(e){return this.scalePerModel[e.modelIndex](e.index)}}Ic([G],kc.prototype,"atomColor",null),Ee.add("atomindex",kc);class Mc extends U{constructor(e){if(super(e),e.scale||(this.parameters.scale="OrRd"),!e.domain){let t,i=1/0,r=-1/0;e.sele&&(t=new ye(e.sele)),e.structure.eachAtom((function(e){const t=e.bfactor;i=Math.min(i,t),r=Math.max(r,t)}),t),this.parameters.domain=[i,r]}this.bfactorScale=this.getScale()}atomColor(e){return this.bfactorScale(e.bfactor)}}Ic([G],Mc.prototype,"atomColor",null),Ee.add("bfactor",Mc);class Dc extends U{constructor(e){super(e),this.chainidDictPerModel={},this.scalePerModel={},e.scale||(this.parameters.scale="Spectral"),e.structure.eachModel((e=>{let t=0;const i={};e.eachChain((function(e){void 0===i[e.chainid]&&(i[e.chainid]=t,t+=1)})),this.parameters.domain=[0,t-1],this.chainidDictPerModel[e.index]=i,this.scalePerModel[e.index]=this.getScale()}))}atomColor(e){const t=this.chainidDictPerModel[e.modelIndex];return this.scalePerModel[e.modelIndex](t[e.chainid])}}Ic([G],Dc.prototype,"atomColor",null),Ee.add("chainid",Dc);class Tc extends U{constructor(e){super(e),this.scalePerModel={},e.scale||(this.parameters.scale="Spectral"),e.structure.eachModel((e=>{this.parameters.domain=[e.chainOffset,e.chainEnd],this.scalePerModel[e.index]=this.getScale()}))}atomColor(e){return this.scalePerModel[e.modelIndex](e.chainIndex)}}Ic([G],Tc.prototype,"atomColor",null),Ee.add("chainindex",Tc);class Bc extends U{constructor(e){super(e),this.chainnameDictPerModel={},this.scalePerModel={},e.scale||(this.parameters.scale="Spectral"),e.structure.eachModel((e=>{let t=0;const i={};e.eachChain((function(e){void 0===i[e.chainname]&&(i[e.chainname]=t,t+=1)})),this.parameters.domain=[0,t-1],this.chainnameDictPerModel[e.index]=i,this.scalePerModel[e.index]=this.getScale()}))}atomColor(e){const t=this.chainnameDictPerModel[e.modelIndex];return this.scalePerModel[e.modelIndex](t[e.chainname])}}Ic([G],Bc.prototype,"atomColor",null),Ee.add("chainname",Bc);class Rc extends U{constructor(e){super(e),this.rsrzDict={},this.rsccDict={},e.scale||(this.parameters.scale="RdYlBu"),this.rsrzScale=this.getScale({domain:[2,0]}),this.rsccScale=this.getScale({domain:[.678,1]});const t=e.structure.validation;t&&(this.rsrzDict=t.rsrzDict,this.rsccDict=t.rsccDict)}atomColor(e){let t=e.resno+"";e.inscode&&(t+="^"+e.inscode),e.chainname&&(t+=":"+e.chainname),t+="/"+e.modelIndex;const i=this.rsrzDict[t];if(void 0!==i)return this.rsrzScale(i);const r=this.rsccDict[t];return void 0!==r?this.rsccScale(r):9474192}}Ic([G],Rc.prototype,"atomColor",null),Ee.add("densityfit",Rc);const Oc={ARG:{CD:.1,CZ:.5,NE:-.1},ASN:{CG:.55,OD1:-.55},ASP:{CB:-.16,CG:.36,OD1:-.6,OD2:-.6},CYS:{CB:.19,SG:-.19},GLN:{CD:.55,OE1:-.55},GLU:{CD:.36,CG:-.16,OE1:-.6,OE2:-.6},HIS:{CB:.1,CD2:.2,CE1:.45,CG:.15,ND1:.05,NE2:.05},LYS:{CE:.25,NZ:.75},MET:{CE:.06,CG:.06,SD:-.12},PTR:{C:.55,CA:.1,CZ:.25,N:-.35,O:-.55,O1P:-.85,O2P:-.85,O3P:-.85,OG1:-1.1,P:1.4},SEP:{C:.55,CA:.1,CB:.25,N:-.35,O:-.55,O1P:-.85,O2P:-.85,O3P:-.85,OG1:-1.1,P:1.4},SER:{CB:.25,OG:-.25},THR:{CB:.25,OG1:-.25},TPO:{C:.55,CA:.1,CB:.25,N:-.35,O:-.55,OG1:-1.1,O1P:-.85,O2P:-.85,O3P:-.85,P:1.4},TRP:{CD1:.06,CD2:.1,CE2:-.04,CE3:-.03,CG:-.03,NE1:-.06},TYR:{CZ:.25,OH:-.25},backbone:{C:.55,O:-.55,N:-.35,CA:.1}};class $c extends U{constructor(e){super(e),this.delta=new t.Vector3,this.hCharges=[],e.scale||(this.parameters.scale="rwb"),e.domain||(this.parameters.domain=[-50,50]),this.scale=this.getScale(),this.charges=new Float32Array(e.structure.atomCount);const i=[];e.structure.eachAtom((e=>{var r;if(this.charges[e.index]=(null!==(r=e).partialCharge?r.partialCharge:r.isProtein()&&(Oc[r.resname]&&Oc[r.resname][r.atomname]||Oc.backbone[r.atomname])||0)*e.occupancy,"N"===e.atomname){if(e.bondCount>=3)return;if(e.bondToElementCount(1))return;const r=function(e,i=new t.Vector3){let r=!1,s=!1,n=!1;return i.set(2*e.x,2*e.y,2*e.z),e.eachBondedAtom((function(e){if(!r)return"H"===e.atomname?(i.set(e.x,e.y,e.z),void(r=!0)):void(s||"CA"!==e.atomname?n||"C"!==e.atomname||(n=!0,i.sub(e)):(i.sub(e),s=!0))})),r?i:s&&n?(i.normalize(),i.multiplyScalar(1.04),i.add(e),i):void 0}(e);void 0!==r&&(i.push(r),this.hCharges.push(.25*e.occupancy))}}));const r=e.structure.getBoundingBox();r.expandByScalar(1.04),this.hStore=function(e){const t=e.length,i=new Float32Array(t),r=new Float32Array(t),s=new Float32Array(t);for(let t=0;t{const s=t[e];0!==s&&(r+=s/i)})),this.hHash.eachWithin(e.x,e.y,e.z,12,((e,t)=>{const s=i[e];0!==s&&(r+=s/t)})),this.scale(332*r)}}Ic([G],$c.prototype,"positionColor",null),Ee.add("electrostatic",$c);const Fc={H:16777215,HE:14286847,LI:13402367,BE:12779264,B:16758197,C:9474192,N:3166456,O:16715021,F:9494608,NE:11789301,NA:11230450,MG:9109248,AL:12560038,SI:1578e4,P:16744448,S:16777008,CL:2093087,AR:8442339,K:9388244,CA:4062976,SC:15132390,TI:12567239,V:10921643,CR:9083335,MN:10255047,FE:14706227,CO:15765664,NI:5296208,CU:13140019,ZN:8224944,GA:12750735,GE:6721423,AS:12419299,SE:16752896,BR:10889513,KR:6076625,RB:7351984,SR:65280,Y:9764863,ZR:9756896,NB:7586505,MO:5551541,TC:3907230,RU:2396047,RH:687500,PD:27013,AG:12632256,CD:16767375,IN:10909043,SN:6717568,SB:10380213,TE:13924864,I:9699476,XE:9699476,CS:5707663,BA:51456,LA:7394559,CE:16777159,PR:14286791,ND:13107143,PM:10747847,SM:9437127,EU:6422471,GD:4587463,TB:3211207,DY:2097095,HO:65436,ER:58997,TM:54354,YB:48952,LU:43812,HF:5096191,TA:5089023,W:2200790,RE:2522539,OS:2516630,IR:1528967,PT:13684960,AU:16765219,HG:12105936,TL:10900557,PB:5724513,BI:10375093,PO:11230208,AT:7688005,RN:4358806,FR:4325478,RA:32e3,AC:7384058,TH:47871,PA:41471,U:36863,NP:33023,PU:27647,AM:5528818,CM:7888099,BK:9064419,CF:10565332,ES:11739092,FM:11739066,MD:11734438,NO:12389767,LR:13041766,RF:13369433,DB:13697103,SG:14221381,BH:14680120,HS:15073326,MT:15400998,DS:16777215,RG:16777215,CN:16777215,UUT:16777215,FL:16777215,UUP:16777215,LV:16777215,UUH:16777215,D:16777152,T:16777120};class Ec extends U{constructor(e){e.value=l(e.value,Fc.C),super(e)}atomColor(e){const t=e.element;return"C"===t?this.parameters.value:Fc[t]||16777215}}Ic([G],Ec.prototype,"atomColor",null),Ee.add("element",Ec);class Lc extends U{constructor(e){super(e),e.scale||(this.parameters.scale="Spectral"),e.domain||(this.parameters.domain=[0,e.structure.entityList.length-1]),this.entityindexScale=this.getScale()}atomColor(e){return this.entityindexScale(e.entityIndex)}}Ic([G],Lc.prototype,"atomColor",null),Ee.add("entityindex",Lc);class Nc extends U{atomColor(e){const t=e.entity;switch(t?t.entityType:void 0){case 1:return 8374655;case 2:return 16629894;case 3:return 12496596;case 4:return 3697840;default:return 16777113}}}Ic([G],Nc.prototype,"atomColor",null),Ee.add("entitytype",Nc);class zc extends U{constructor(e){super(e),this.geoAtomDict={},this.geoDict={};const t=e.structure.validation;t&&(this.geoAtomDict=t.geoAtomDict,this.geoDict=t.geoDict)}atomColor(e){let t,i=e.resno+"";e.inscode&&(i+="^"+e.inscode),e.chainname&&(i+=":"+e.chainname),i+="/"+e.modelIndex;const r=this.geoAtomDict[i];if(void 0!==r){const i=r[e.atomname]||0;s=i,t=16843009*((s=(858993459&(s-=s>>1&1431655765))+(s>>2&858993459))+(s>>4)&252645135)>>24}else t=this.geoDict[i]||0;var s;return 0===t?2188972:1===t?16703627:2===t?16018755:t>=3?10813478:9474192}}Ic([G],zc.prototype,"atomColor",null),Ee.add("geoquality",zc);class Vc extends U{constructor(e){super(e),this.resHF={},e.scale||(this.parameters.scale="RdYlGn");for(const e in Ur)this.resHF[e]=Ur[e][0];if(this.defaultResidueHydrophobicity=jr[0],!e.domain){let e=1/0,t=-1/0;for(const i in this.resHF){const r=this.resHF[i];e=Math.min(e,r),t=Math.max(t,r)}this.parameters.domain=[e,0,t]}this.hfScale=this.getScale()}atomColor(e){return this.hfScale(this.resHF[e.resname]||this.defaultResidueHydrophobicity)}}Ic([G],Vc.prototype,"atomColor",null),Ee.add("hydrophobicity",Vc);class Gc extends U{constructor(e){super(e),e.scale||(this.parameters.scale="rainbow"),e.domain||(this.parameters.domain=[0,e.structure.modelStore.count]),this.modelindexScale=this.getScale()}atomColor(e){return this.modelindexScale(e.modelIndex)}}Ic([G],Gc.prototype,"atomColor",null),Ee.add("modelindex",Gc);class Uc extends U{atomColor(e){switch(e.residueType.moleculeType){case 1:return 3697840;case 2:return 15729279;case 3:return 12496596;case 4:return 16629894;case 5:return 12540695;case 6:return 8374655;default:return 16777113}}}Ic([G],Uc.prototype,"atomColor",null),Ee.add("moleculetype",Uc);class jc extends U{constructor(e){super(e),e.scale||(this.parameters.scale="PuBu"),e.domain||(this.parameters.domain=[0,1]),this.occupancyScale=this.getScale()}atomColor(e){return this.occupancyScale(e.occupancy)}}Ic([G],jc.prototype,"atomColor",null),Ee.add("occupancy",jc);class Hc extends U{constructor(e){super(e),e.scale||(this.parameters.scale="rwb"),e.domain||(this.parameters.domain=[-1,1]),this.partialchargeScale=this.getScale()}atomColor(e){return this.partialchargeScale(e.partialCharge||0)}}function Wc(){return 16777215*Math.random()}Ic([G],Hc.prototype,"atomColor",null),Ee.add("partialcharge",Hc);class qc extends U{atomColor(){return Wc()}volumeColor(){return Wc()}positionColor(){return Wc()}}Ic([G],qc.prototype,"atomColor",null),Ic([G],qc.prototype,"volumeColor",null),Ic([G],qc.prototype,"positionColor",null),Ee.add("random",qc);class Xc extends U{constructor(e){super(e),this.rciDict={},e.scale||(this.parameters.scale="RdYlBu"),this.rciScale=this.getScale({domain:[.6,0]});const t=e.structure.validation;t&&(this.rciDict=t.rciDict)}atomColor(e){let t=`[${e.resname}]${e.resno}`;e.chainname&&(t+=":"+e.chainname);const i=this.rciDict[t];return void 0!==i?this.rciScale(i):9474192}}Ic([G],Xc.prototype,"atomColor",null),Ee.add("randomcoilindex",Xc);class Yc extends U{constructor(e){super(e),this.scalePerChain={},e.scale||(this.parameters.scale="rainbow",this.parameters.reverse=l(e.reverse,!0)),e.structure.eachChain((e=>{this.parameters.domain=[e.residueOffset,e.residueEnd],this.scalePerChain[e.index]=this.getScale()}))}atomColor(e){return this.scalePerChain[e.chainIndex](e.residueIndex)}}Ic([G],Yc.prototype,"atomColor",null),Ee.add("residueindex",Yc);const Kc={ALA:9240460,ARG:124,ASN:16743536,ASP:10485826,CYS:16777072,GLN:16731212,GLU:6684672,GLY:16777215,HIS:7368959,ILE:19456,LEU:4546117,LYS:4671416,MET:12099650,PHE:5459026,PRO:5395026,SER:16740418,THR:12078080,TRP:5195264,TYR:9203788,VAL:16747775,ASX:16711935,GLX:16711935,ASH:16711935,GLH:16711935,A:14423100,G:3329330,I:10145074,X:8190976,C:16766720,T:4286945,U:4251856,D:35723,DA:14423100,DG:3329330,DI:10145074,DX:8190976,DC:16766720,DT:4286945,DU:4251856,DD:35723};class Zc extends U{atomColor(e){return Kc[e.resname]||16711935}}Ic([G],Zc.prototype,"atomColor",null),Ee.add("resname",Zc);const Qc=16711808,Jc=10485888,el=6291584,tl=16762880,il=6324479,rl=16777215,sl=11403518,nl=16580962,ol=10921722;class al extends U{constructor(e){super(e),this.residueProxy=e.structure.getResidueProxy()}atomColor(e){const t=e.sstruc,i=this.residueProxy;return"h"===t?Qc:"g"===t?Jc:"i"===t?el:"e"===t||"b"===t?tl:"t"===t?il:(i.index=e.residueIndex,i.isDna()?sl:i.isRna()?nl:i.isSaccharide()?ol:i.isProtein()||"s"===t||"l"===t?rl:8421504)}}Ic([G],al.prototype,"atomColor",null),Ee.add("sstruc",al);class cl extends U{constructor(e){var t,i;super(e),e.scale||(this.parameters.scale="rwb"),this.atomData=null===(t=this.parameters.data)||void 0===t?void 0:t.atomData,this.bondData=null===(i=this.parameters.data)||void 0===i?void 0:i.bondData,this.scale=this.getScale(this.parameters)}atomColor(e){var t;const i=null===(t=this.atomData)||void 0===t?void 0:t[e.index];return void 0!==i?this.scale(i):this.parameters.value}bondColor(e,t){var i;const r=null===(i=this.bondData)||void 0===i?void 0:i[e.index];return void 0!==r?this.scale(r):this.atomProxy?(this.atomProxy.index=t?e.atomIndex1:e.atomIndex2,this.atomColor(this.atomProxy)):this.parameters.value}}Ic([G],cl.prototype,"atomColor",null),Ic([G],cl.prototype,"bondColor",null),Ee.add("structuredata",cl);class ll extends U{atomColor(){return this.parameters.value}bondColor(){return this.parameters.value}valueColor(){return this.parameters.value}volumeColor(){return this.parameters.value}}Ic([G],ll.prototype,"atomColor",null),Ic([G],ll.prototype,"bondColor",null),Ic([G],ll.prototype,"valueColor",null),Ic([G],ll.prototype,"volumeColor",null),Ee.add("uniform",ll);class hl extends U{constructor(e){super(e),this.valueScale=this.getScale()}volumeColor(e){return this.valueScale(this.parameters.volume.data[e])}}Ic([G],hl.prototype,"volumeColor",null),Ee.add("value",hl);class ul extends U{constructor(e){super(e),this.vec=new t.Vector3,this.valueScale=this.getScale()}positionColor(e){const t=this.parameters.volume;if(!t||!t.inverseMatrix)return this.parameters.value;const i=this.vec,r=t.data,s=t.nx,n=t.ny,o=s*n;i.copy(e),i.applyMatrix4(t.inverseMatrix);const a=Math.floor(i.x),c=Math.floor(i.y),l=Math.floor(i.z),h=(l*n+c)*s+a,u=h+1,d=h+s,m=h+o,p=d+1,f=m+1,g=d+o,y=g+1,b=r[h],x=r[u],v=r[d],w=r[m],A=r[p],_=r[f],S=r[g],C=r[y],P=i.x-a,I=i.y-c,k=i.z-l,M=F(b,x,P),D=F(w,_,P),T=F(v,A,P),B=F(S,C,P),R=F(M,T,I),O=F(D,B,I),$=F(R,O,k);return this.valueScale($)}}Ic([G],ul.prototype,"positionColor",null),Ee.add("volume",ul);class dl extends Di{constructor(e,t,i){const r=i||{};if(super(e,t,r),this.type="structure",this.parameters=Object.assign({radiusType:{type:"select",options:ro.types},radiusData:{type:"hidden"},radiusSize:{type:"number",precision:3,max:10,min:.001},radiusScale:{type:"number",precision:3,max:10,min:.001},assembly:null,defaultAssembly:{type:"hidden"}},this.parameters),this.selection=new ye(r.sele),this.dataList=[],this.structure=e,this.structureView=this.structure.getView(this.selection),e.biomolDict){const t={default:"default","":e.unitcell?"AU":"FULL"};Object.keys(e.biomolDict).forEach((function(e){t[e]=e})),this.parameters.assembly={type:"select",options:t,rebuild:!0}}else this.parameters.assembly=null}get defaultScale(){return{vdw:1,covalent:1,bfactor:.01,sstruc:1}}init(e){const t=e||{};t.colorScheme=l(t.colorScheme,"element"),this.setRadius(t.radius,t),this.radiusType=l(t.radiusType,"vdw"),this.radiusData=l(t.radiusData,{}),this.radiusSize=l(t.radiusSize,1),this.radiusScale=l(t.radiusScale,1),this.assembly=l(t.assembly,"default"),this.defaultAssembly=l(t.defaultAssembly,""),"auto"===t.quality&&(t.quality=this.getQuality()),super.init(t),this.selection.signals.stringChanged.add((()=>{this.build()})),this.build()}setRadius(e,t){const i=Object.keys(io);return"string"==typeof e&&i.includes(e.toLowerCase())?t.radiusType=e:void 0!==e&&(t.radiusType="size",t.radiusSize=e),this}getAssembly(){const e="default"===this.assembly?this.defaultAssembly:this.assembly;return this.structure.biomolDict[e]}getQuality(){let e;const t=this.structureView,i=this.getAssembly();e=i?i.getAtomCount(t):t.atomCount,Ie&&(e*=4);return t.atomStore.count/t.residueStore.count<2&&(e*=10),e<15e3?"high":e<8e4?"medium":"low"}create(){if(0===this.structureView.atomCount)return;if(!this.structureView.hasCoords())return void(this.needsBuild=!0);this.needsBuild=!1;const e=this.getAssembly();if(e)e.partList.forEach(((e,t)=>{const i=e.getView(this.structureView);if(0===i.atomCount)return;const r=this.createData(i,t);r&&(r.sview=i,r.instanceList=e.getInstanceList(),this.dataList.push(r))}));else{const e=this.createData(this.structureView,0);e&&(e.sview=this.structureView,this.dataList.push(e))}}update(e){!this.lazy||this.visible?this.needsBuild?this.build():this.dataList.forEach((t=>{t.bufferList.length>0&&this.updateData(e,t)}),this):Object.assign(this.lazyProps.what,e)}updateData(e,t){this.build()}getColorParams(){return Object.assign(Object.assign({},super.getColorParams()),{structure:this.structure})}getRadiusParams(e){return{type:this.radiusType,scale:this.radiusScale,size:this.radiusSize,data:this.radiusData}}getAtomParams(e,t){return Object.assign({what:e,colorParams:this.getColorParams(),radiusParams:this.getRadiusParams()},t)}getBondParams(e,t){return Object.assign({what:e,colorParams:this.getColorParams(),radiusParams:this.getRadiusParams()},t)}getAtomRadius(e){if(this.structureView.atomSet.isSet(e.index)){return new ro(this.getRadiusParams()).atomRadius(e)}return 0}setSelection(e,t){return this.selection.setString(e,t),this}setParameters(e,t={},i=!1){const r=e||{};return this.setRadius(r.radius,r),void 0===r.radiusType&&void 0===r.radiusData&&void 0===r.radiusSize&&void 0===r.radiusScale||(t.radius=!0,De&&!this.disableImpostor||(i=!0)),void 0!==r.defaultAssembly&&r.defaultAssembly!==this.defaultAssembly&&("default"===this.assembly&&void 0===r.assembly||"default"===r.assembly)&&(i=!0),super.setParameters(r,t,i),this}getParameters(){return Object.assign(super.getParameters(),{sele:this.selection?this.selection.string:void 0,defaultAssembly:this.defaultAssembly})}attach(e){const t=this.viewer,i=this.bufferList;this.dataList.forEach((function(e){e.bufferList.forEach((function(r){i.push(r),t.add(r,e.instanceList)}))})),this.setVisibility(this.visible),e()}clear(){this.dataList.length=0,super.clear()}dispose(){this.structureView.dispose(),super.dispose()}}class ml extends dl{constructor(e,t,i){super(e,t,i),this.n=0,this.parameters=Object.assign({labelVisible:{type:"boolean"},labelSize:{type:"number",precision:3,max:10,min:.001},labelColor:{type:"color"},labelFontFamily:{type:"select",options:{"sans-serif":"sans-serif",monospace:"monospace",serif:"serif"},buffer:"fontFamily"},labelFontStyle:{type:"select",options:{normal:"normal",italic:"italic"},buffer:"fontStyle"},labelFontWeight:{type:"select",options:{normal:"normal",bold:"bold"},buffer:"fontWeight"},labelsdf:{type:"boolean",buffer:"sdf"},labelXOffset:{type:"number",precision:1,max:20,min:-20,buffer:"xOffset"},labelYOffset:{type:"number",precision:1,max:20,min:-20,buffer:"yOffset"},labelZOffset:{type:"number",precision:1,max:20,min:-20,buffer:"zOffset"},labelAttachment:{type:"select",options:{"bottom-left":"bottom-left","bottom-center":"bottom-center","bottom-right":"bottom-right","middle-left":"middle-left","middle-center":"middle-center","middle-right":"middle-right","top-left":"top-left","top-center":"top-center","top-right":"top-right"},rebuild:!0},labelBorder:{type:"boolean",buffer:"showBorder"},labelBorderColor:{type:"color",buffer:"borderColor"},labelBorderWidth:{type:"number",precision:2,max:.3,min:0,buffer:"borderWidth"},labelBackground:{type:"boolean",rebuild:!0},labelBackgroundColor:{type:"color",buffer:"backgroundColor"},labelBackgroundMargin:{type:"number",precision:2,max:2,min:0,rebuild:!0},labelBackgroundOpacity:{type:"range",step:.01,max:1,min:0,buffer:"backgroundOpacity"},labelFixedSize:{type:"boolean",buffer:"fixedSize"},lineOpacity:{type:"range",min:0,max:1,step:.01},linewidth:{type:"integer",max:50,min:1,buffer:!0}},this.parameters,{flatShaded:null})}init(e){const t=e||{};this.labelVisible=l(t.labelVisible,!0),this.labelSize=l(t.labelSize,2),this.labelColor=l(t.labelColor,16777215),this.labelFontFamily=l(t.labelFontFamily,"sans-serif"),this.labelFontStyle=l(t.labelFontstyle,"normal"),this.labelFontWeight=l(t.labelFontWeight,"bold"),this.labelsdf=l(t.labelsdf,"Chrome"===Ce),this.labelXOffset=l(t.labelXOffset,0),this.labelYOffset=l(t.labelYOffset,0),this.labelZOffset=l(t.labelZOffset,.5),this.labelAttachment=l(t.labelAttachment,"bottom-left"),this.labelBorder=l(t.labelBorder,!1),this.labelBorderColor=l(t.labelBorderColor,"lightgrey"),this.labelBorderWidth=l(t.labelBorderWidth,.15),this.labelBackground=l(t.labelBackground,!1),this.labelBackgroundColor=l(t.labelBackgroundColor,"lightgrey"),this.labelBackgroundMargin=l(t.labelBackgroundMargin,.5),this.labelBackgroundOpacity=l(t.labelBackgroundOpacity,1),this.labelFixedSize=l(t.labelFixedSize,!1),this.lineOpacity=l(t.lineOpacity,1),this.linewidth=l(t.linewidth,2),super.init(t)}update(e){e.position?this.build():super.update(e)}updateData(e,i){const r={};if(e&&!e.labelSize||Object.assign(r,{size:yt(this.n,this.labelSize)}),!e||e.labelColor){const e=new t.Color(this.labelColor);Object.assign(r,{color:bt(this.n,e.r,e.g,e.b)})}this.textBuffer.setAttributes(r)}setParameters(e,t={},i=!1){return e&&e.labelSize&&(t.labelSize=!0),e&&(e.labelColor||0===e.labelColor)&&(t.labelColor=!0,i=!0),super.setParameters(e,t,i),e&&void 0!==e.opacity&&this.textBuffer.setParameters({opacity:1}),e&&void 0!==e.labelVisible&&this.setVisibility(this.visible),this}setVisibility(e,t){return super.setVisibility(e,!0),this.textBuffer&&this.textBuffer.setVisibility(this.labelVisible&&this.visible),t||this.viewer.requestRender(),this}getLabelBufferParams(e={}){return super.getBufferParams(Object.assign({fontFamily:this.labelFontFamily,fontStyle:this.labelFontStyle,fontWeight:this.labelFontWeight,sdf:this.labelsdf,xOffset:this.labelXOffset,yOffset:this.labelYOffset,zOffset:this.labelZOffset,attachment:this.labelAttachment,showBorder:this.labelBorder,borderColor:this.labelBorderColor,borderWidth:this.labelBorderWidth,showBackground:this.labelBackground,backgroundColor:this.labelBackgroundColor,backgroundMargin:this.labelBackgroundMargin,backgroundOpacity:this.labelBackgroundOpacity,fixedSize:this.labelFixedSize,disablePicking:!0,visible:this.labelVisible},e,{opacity:1}))}getAtomRadius(){return 0}}function pl(e,t){const i=e.getAtomProxy(),r=new ye,s=t.length;if(0===s)return new Float32Array(0);const n=t[0].length,o=e.getAtomSet(),a=new Float32Array(s*n*3);let c=0;return t.forEach((function(t){let s=!1;for(let l=0;l 1.0 ){\ngl_FragColor = vec4( backgroundColor, backgroundOpacity );\n}else{\nfloat sdf = texture2D( fontTexture, texCoord ).a;\nif( showBorder ) sdf += borderWidth;\nfloat a = smoothstep(padding - gamma, padding + gamma, sdf);\nif( a < 0.2 ) discard;\na *= opacity;\nvec3 outgoingLight = vColor;\nif( showBorder && sdf < ( padding + borderWidth ) ){\noutgoingLight = borderColor;\n}\ngl_FragColor = vec4( outgoingLight, a );\n}\n#if defined( PICKING )\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");const bl={};const xl={font:"sans-serif",size:36,style:"normal",variant:"normal",weight:"normal",outline:3,width:1024,height:1024};class vl{constructor(e={}){this.gamma=1,this.mapped={},this.scratchW=0,this.scratchH=0,this.currentX=0,this.currentY=0,this.cutoff=.25,this.parameters=h(e,xl);const i=this.parameters;this.radius=i.size/8,this.padding=i.size/3;const r=this.lineHeight=i.size+2*i.outline+Math.round(i.size/4),s=this.maxWidth=i.width/4,n=this.canvas=document.createElement("canvas");n.width=s,n.height=r;const o=this.context=this.canvas.getContext("2d");o.font=`${i.style} ${i.variant} ${i.weight} ${i.size}px ${i.font}`,o.fillStyle="black",o.textAlign="left",o.textBaseline="bottom",o.lineJoin="round",this.gridOuter=new Float64Array(r*s),this.gridInner=new Float64Array(r*s),this.f=new Float64Array(Math.max(r,s)),this.d=new Float64Array(Math.max(r,s)),this.z=new Float64Array(Math.max(r,s)+1),this.v=new Int16Array(Math.max(r,s)),this.data=new Uint8Array(i.width*i.height*4),this.canvas2=document.createElement("canvas"),this.canvas2.width=i.width,this.canvas2.height=i.height,this.context2=this.canvas2.getContext("2d"),this.placeholder=this.map(String.fromCharCode(65533));for(let e=32;e<=126;++e)this.map(String.fromCharCode(e));this.map(String.fromCharCode(176)),this.map(String.fromCharCode(8491)),this.texture=new t.CanvasTexture(this.canvas2),this.texture.flipY=!1,this.texture.needsUpdate=!0}map(e){const t=this.parameters;return void 0===this.mapped[e]&&(this.draw(e),this.currentX+this.scratchW>t.width&&(this.currentX=0,this.currentY+=this.scratchH),this.currentY+this.scratchH>t.height&&console.warn("canvas to small"),this.mapped[e]={x:this.currentX,y:this.currentY,w:this.scratchW,h:this.scratchH},this.context2.drawImage(this.canvas,0,0,this.scratchW,this.scratchH,this.currentX,this.currentY,this.scratchW,this.scratchH),this.currentX+=this.scratchW),this.mapped[e]}get(e){return this.mapped[e]||this.placeholder}draw(e){const t=this.parameters,i=this.lineHeight,r=t.outline,s=this.context,n=this.maxWidth,o=r,a=i-t.outline,c=s.measureText(e),l=Math.min(n,Math.ceil(c.width+2*o+1)),h=l*i;s.clearRect(0,0,l,i),s.fillText(e,o,a);const u=s.getImageData(0,0,l,i),d=u.data;for(let e=0;e= 0.0 ) {\ntrimSegment( start, end );\n} else if ( end.z < 0.0 && start.z >= 0.0 ) {\ntrimSegment( end, start );\n}\n}\nvec4 clipStart = projectionMatrix * start;\nvec4 clipEnd = projectionMatrix * end;\nvec2 ndcStart = clipStart.xy / clipStart.w;\nvec2 ndcEnd = clipEnd.xy / clipEnd.w;\nvec2 dir = ndcEnd - ndcStart;\ndir.x *= aspect;\ndir = normalize( dir );\nvec2 offset = vec2( dir.y, - dir.x );\ndir.x /= aspect;\noffset.x /= aspect;\nif ( mapping.x < 0.0 ) offset *= - 1.0;\noffset *= linewidth;\noffset /= resolution.y;\nvec4 clip = ( mapping.y < 0.5 ) ? clipStart : clipEnd;\noffset *= clip.w;\nclip.xy += offset;\ngl_Position = clip;\n#ifndef PICKING\nvViewPosition = ( projectionMatrixInverse * clip ).xyz;\n#endif\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n#include nearclip_vertex\n}"),Ve.add("shader/WideLine.frag","uniform vec3 diffuse;\nuniform float opacity;\nuniform float clipNear;\nuniform float clipRadius;\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\n#ifdef PICKING\nuniform float objectId;\nvarying vec3 vPickingColor;\n#else\n#include common\n#include fog_pars_fragment\nvarying vec3 vViewPosition;\nvarying vec3 vColor;\nvarying vec3 vColor2;\nvarying float flag;\n#endif\nvoid main() {\n#include nearclip_fragment\n#include radiusclip_fragment\n#if defined( PICKING )\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 outgoingLight = vec3( 0.0 );\nvec4 diffuseColor = vec4( diffuse, 1.0 );\nif ( flag < 0.0 ) {\ndiffuseColor.rgb *= vColor;\n} else {\ndiffuseColor.rgb *= vColor2;\n}\n#include alphatest_fragment\noutgoingLight = diffuseColor.rgb;\ngl_FragColor = vec4( outgoingLight, diffuseColor.a * opacity );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");const Cl=Object.assign({linewidth:2},Mn),Pl=Object.assign({linewidth:{uniform:!0}},Dn);class Il extends Ma{constructor(e,i={}){super(e,i),this.parameterTypes=Pl,this.vertexShader="WideLine.vert",this.fragmentShader="WideLine.frag",!e.color2&&e.color&&(e.color2=e.color),this.addUniforms({linewidth:{value:this.parameters.linewidth},resolution:{value:new t.Vector2},projectionMatrixInverse:{value:new t.Matrix4}}),this.addAttributes({position1:{type:"v3",value:null},position2:{type:"v3",value:null},color2:{type:"c",value:null}}),this.setAttributes(e),this.makeMapping()}get defaultParameters(){return Cl}setParameters(e){super.setParameters(e)}}je.add("wideline",Il);class kl extends ml{constructor(e,t,i){super(e,t,i),this.type="angle",this.parameters=Object.assign({atomTriple:{type:"hidden",rebuild:!0},vectorVisible:{type:"boolean",default:!0},arcVisible:{type:"boolean",default:!0},sectorVisible:{type:"boolean",default:!0}},this.parameters),this.init(i)}init(e){const t=e||{};t.side=l(t.side,"double"),t.opacity=l(t.opacity,.5),this.atomTriple=l(t.atomTriple,[]),this.arcVisible=l(t.arcVisible,!0),this.sectorVisible=l(t.sectorVisible,!0),this.vectorVisible=l(t.vectorVisible,!0),super.init(t)}createData(e){if(!e.atomCount||!this.atomTriple.length)return;const i=function(e,t){return function(e){const t=[],i=e.length/9;for(let r=0;r radius2) {\ndiscard;\n}\n#ifdef CAP\nsurface_point = front_point;\n_normal = axis;\n#else\nsurface_point = ray_target + ( (-a1 - sqrt(d)) / a2 ) * ray_direction;\ndNV = dot(-axis, ray_direction);\nnear = dot(axis, end) / dNV;\nnew_point2 = ray_direction * near + ray_origin;\nif (dot(new_point2 - end, new_point2-base) < radius2) {\ndiscard;\n}\ninterior = true;\n#endif\n}\nif( end_cap_test > 0.0 )\n{\nfloat dNV;\nfloat near;\nvec3 end_point;\nif ( ortho == 1.0 ) {\nend_point = ray_target;\n} else {\ndNV = dot(axis, ray_direction);\nif (dNV < 0.0) {\ndiscard;\n}\nnear = dot(axis, end) / dNV;\nend_point = ray_direction * near + ray_origin;\n}\n\nif( dot(end_point - end, end_point-base) > radius2 ) {\ndiscard;\n}\n#ifdef CAP\nsurface_point = end_point;\n_normal = axis;\n#else\nsurface_point = ray_target + ( (-a1 - sqrt(d)) / a2 ) * ray_direction;\ndNV = dot(-axis, ray_direction);\nnear = dot(-axis, (base)) / dNV;\nnew_point2 = ray_direction * near + ray_origin;\nif (dot(new_point2 - base, new_point2-base) < radius2) {\ndiscard;\n}\ninterior = true;\n#endif\n}\ngl_FragDepthEXT = calcDepth( surface_point );\n\n#ifdef NEAR_CLIP\nif( calcClip( surface_point ) > 0.0 ){\ndist = (-a1 - sqrt(d)) / a2;\nsurface_point = ray_target + dist * ray_direction;\nif( calcClip( surface_point ) > 0.0 ) {\ndiscard;\n}\ninterior = true;\ngl_FragDepthEXT = calcDepth( surface_point );\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( clipNear - 0.5 ) ) ) + ( 0.0000001 / vRadius ) );\n}\n}else if( gl_FragDepthEXT <= 0.0 ){\ndist = (-a1 - sqrt(d)) / a2;\nsurface_point = ray_target + dist * ray_direction;\ninterior = true;\ngl_FragDepthEXT = calcDepth( surface_point );\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n}\n#else\nif( gl_FragDepthEXT <= 0.0 ){\ndist = (-a1 - sqrt(d)) / a2;\nsurface_point = ray_target + dist * ray_direction;\ninterior = true;\ngl_FragDepthEXT = calcDepth( surface_point );\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / vRadius );\n}\n}\n#endif\nif (gl_FragDepthEXT < 0.0) {\ndiscard;\n}\nif (gl_FragDepthEXT > 1.0) {\ndiscard;\n}\n#ifdef PICKING\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 vViewPosition = -surface_point;\nvec3 vNormal = _normal;\nvec3 vColor;\nif( distSq3( surface_point, end ) < distSq3( surface_point, base ) ){\nif( b < 0.0 ){\nvColor = vColor1;\n}else{\nvColor = vColor2;\n}\n}else{\nif( b > 0.0 ){\nvColor = vColor1;\n}else{\nvColor = vColor2;\n}\n}\nvec4 diffuseColor = vec4( diffuse, opacity );\nReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\nvec3 totalEmissiveLight = emissive;\n#include color_fragment\n#include roughnessmap_fragment\n#include metalnessmap_fragment\nvec3 normal = normalize( vNormal );\nvec3 geometryNormal = normal;\n#include lights_physical_fragment\n#include lights_fragment_begin\n#include lights_fragment_end\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\nif( interior ){\n#ifdef USE_INTERIOR_COLOR\noutgoingLight.xyz = interiorColor;\n#else\n#ifdef DIFFUSE_INTERIOR\noutgoingLight.xyz = vColor;\n#endif\n#endif\noutgoingLight.xyz *= 1.0 - interiorDarkening;\n}\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");const Fl=new Float32Array([-1,1,-1,-1,-1,-1,1,1,-1,1,1,1,1,-1,-1,1,-1,1]),El=new Uint16Array([0,1,2,1,4,2,2,4,3,4,5,3]);class Ll extends Pa{constructor(e,t={}){super("v3",e,t)}get mapping(){return Fl}get mappingIndices(){return El}get mappingIndicesSize(){return 12}get mappingSize(){return 6}get mappingItemSize(){return 3}}const Nl=Object.assign({openEnded:!1},Mn),zl=Object.assign({openEnded:{updateShader:!0}},Dn);class Vl extends Ll{constructor(e,i={}){super(e,i),this.parameterTypes=zl,this.isImpostor=!0,this.vertexShader="CylinderImpostor.vert",this.fragmentShader="CylinderImpostor.frag",this.addUniforms({modelViewMatrixInverse:{value:new t.Matrix4},ortho:{value:0}}),this.addAttributes({position1:{type:"v3",value:null},position2:{type:"v3",value:null},color2:{type:"c",value:null},radius:{type:"f",value:null}}),this.setAttributes(e),this.makeMapping()}get defaultParameters(){return Nl}getDefines(e){const t=Ll.prototype.getDefines.call(this,e);return this.parameters.openEnded||(t.CAP=1),t}}Object.assign({disableImpostor:!1},Rl,Nl);const Gl=class{constructor(e,t={}){return!e.color2&&e.color&&(e.color2=e.color),!De||t&&t.disableImpostor?new $l(e,t):new Vl(e,t)}};je.add("cylinder",Gl);class Ul extends dl{constructor(e,t,i){super(e,t,i),this.type="axes",this.parameters=Object.assign({radiusSize:{type:"number",precision:3,max:10,min:.001},sphereDetail:!0,radialSegments:!0,disableImpostor:!0,showAxes:{type:"boolean",rebuild:!0},showBox:{type:"boolean",rebuild:!0}},this.parameters,{assembly:null}),this.init(i)}init(e){const t=e||{};t.radiusSize=l(t.radiusSize,.5),t.colorValue=l(t.colorValue,"lightgreen"),t.useInteriorColor=l(t.useInteriorColor,!0),this.showAxes=l(t.showAxes,!0),this.showBox=l(t.showBox,!1),super.init(t)}getPrincipalAxes(){let e;const t=this.getAssembly();return t&&(e=t.partList[0].getSelection()),this.structureView.getPrincipalAxes(e)}getAxesData(e){const i=this.getPrincipalAxes(),r=new t.Color(this.colorValue);let s=0,n=0;this.showAxes&&(s+=6,n+=3),this.showBox&&(s+=8,n+=12);const o=new Float32Array(3*s),a=bt(s,r.r,r.g,r.b),c=yt(s,this.radiusSize),l=new Float32Array(3*n),h=new Float32Array(3*n),u=bt(n,r.r,r.g,r.b),d=yt(n,this.radiusSize);let m=0;if(this.showAxes){const e=function(e,t){e.toArray(o,2*m),t.toArray(o,2*m+3),e.toArray(l,m),t.toArray(h,m),m+=3};e(i.begA,i.endA),e(i.begB,i.endB),e(i.begC,i.endC)}if(this.showBox){const r=new t.Vector3,{d1a:s,d2a:n,d3a:a,d1b:c,d2b:u,d3b:d}=i.getProjectedScaleForAtoms(e);let p=2*m;const f=function(e,t,s){r.copy(i.center).addScaledVector(i.normVecA,e).addScaledVector(i.normVecB,t).addScaledVector(i.normVecC,s),r.toArray(o,p),p+=3};f(s,n,a),f(s,n,d),f(s,u,d),f(s,u,a),f(c,u,d),f(c,u,a),f(c,n,a),f(c,n,d);let g=m;const y=function(e,t){r.fromArray(o,2*m+3*e).toArray(l,g),r.fromArray(o,2*m+3*t).toArray(h,g),g+=3};y(0,1),y(0,3),y(0,6),y(1,2),y(1,7),y(2,3),y(2,4),y(3,5),y(4,5),y(4,7),y(5,6),y(6,7)}const p=new Ns(i);return{vertex:{position:o,color:a,radius:c,picking:p},edge:{position1:l,position2:h,color:u,color2:u,radius:d,picking:p}}}create(){const e=this.getAxesData(this.structureView);this.sphereBuffer=new Ta(e.vertex,this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0})),this.cylinderBuffer=new Gl(e.edge,this.getBufferParams({openEnded:!0,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0})),this.dataList.push({sview:this.structureView,bufferList:[this.sphereBuffer,this.cylinderBuffer]})}createData(e){}updateData(e,t){const i=this.getAxesData(t.sview),r={},s={};e&&!e.position||(Object.assign(r,{position:i.vertex.position}),Object.assign(s,{position1:i.edge.position1,position2:i.edge.position2})),e&&!e.color||(Object.assign(r,{color:i.vertex.color}),Object.assign(s,{color:i.edge.color,color2:i.edge.color})),e&&!e.radius||(Object.assign(r,{radius:i.vertex.radius}),Object.assign(s,{radius:i.edge.radius})),this.sphereBuffer.setAttributes(r),this.cylinderBuffer.setAttributes(s)}}Ne.add("axes",Ul);class jl extends dl{constructor(e,t,i){super(e,t,i),this.type="ball+stick",this.parameters=Object.assign({sphereDetail:!0,radialSegments:!0,openEnded:!0,disableImpostor:!0,aspectRatio:{type:"number",precision:1,max:10,min:1},lineOnly:{type:"boolean",rebuild:!0},cylinderOnly:{type:"boolean",rebuild:!0},multipleBond:{type:"select",rebuild:!0,options:{off:"off",symmetric:"symmetric",offset:"offset"}},bondScale:{type:"number",precision:2,max:1,min:.01},bondSpacing:{type:"number",precision:2,max:2,min:.5},linewidth:{type:"integer",max:50,min:1,buffer:!0}},this.parameters),this.init(i)}init(e){var t=e||{};t.radiusType=l(t.radiusType,"size"),t.radiusSize=l(t.radiusSize,.15),t.useInteriorColor=l(t.useInteriorColor,!0),this.aspectRatio=l(t.aspectRatio,2),this.lineOnly=l(t.lineOnly,!1),this.cylinderOnly=l(t.cylinderOnly,!1),this.multipleBond=l(t.multipleBond,"off"),this.bondSpacing=l(t.bondSpacing,1),this.bondScale=l(t.bondScale,.4),this.linewidth=l(t.linewidth,2),super.init(t)}getAtomRadius(e){return this.aspectRatio*super.getAtomRadius(e)}getAtomParams(e,t){var i=super.getAtomParams(e,t);return i.radiusParams.scale*=this.aspectRatio,i}getAtomData(e,t,i){return e.getAtomData(this.getAtomParams(t,i))}getBondParams(e,t){return t=Object.assign({multipleBond:this.multipleBond,bondSpacing:this.bondSpacing,bondScale:this.bondScale},t),super.getBondParams(e,t)}getBondData(e,t,i){return e.getBondData(this.getBondParams(t,i))}createData(e){const t=[];if(this.lineOnly)this.lineBuffer=new Il(this.getBondData(e,{position:!0,color:!0,picking:!0}),this.getBufferParams({linewidth:this.linewidth})),t.push(this.lineBuffer);else{const i=new Gl(this.getBondData(e),this.getBufferParams({openEnded:this.openEnded,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0}));if(t.push(i),!this.cylinderOnly){const i=new Ta(this.getAtomData(e),this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0}));t.push(i)}}return{bufferList:t}}updateData(e,t){"off"!==this.multipleBond&&e&&e.radius&&(e.position=!0);const i=this.getBondData(t.sview,e);if(this.lineOnly){const r={};e&&!e.position||Object.assign(r,{position1:i.position1,position2:i.position2}),e&&!e.color||Object.assign(r,{color:i.color,color2:i.color2}),t.bufferList[0].setAttributes(r)}else{var r={};if(e&&!e.position||Object.assign(r,{position1:i.position1,position2:i.position2}),e&&!e.color||Object.assign(r,{color:i.color,color2:i.color2}),e&&!e.radius||Object.assign(r,{radius:i.radius}),t.bufferList[0].setAttributes(r),!this.cylinderOnly){var s=this.getAtomData(t.sview,e),n={};e&&!e.position||Object.assign(n,{position:s.position}),e&&!e.color||Object.assign(n,{color:s.color}),e&&!e.radius||Object.assign(n,{radius:s.radius}),t.bufferList[1].setAttributes(n)}}}setParameters(e={}){let t=!1;const i={};return(e.aspectRatio||e.bondSpacing||e.bondScale)&&(Object.assign(i,{radius:!0}),De&&!this.disableImpostor||(t=!0)),super.setParameters(e,i,t),this}}Ne.add("ball+stick",jl);class Hl extends jl{constructor(e,t,i){super(e,t,i),this.type="backbone",this.parameters=Object.assign({},this.parameters,{multipleBond:null,bondSpacing:null}),this.init(i)}init(e){var t=e||{};t.aspectRatio=l(t.aspectRatio,1),t.radiusSize=l(t.radiusSize,.25),super.init(t)}getAtomRadius(e){return e.isTrace()?super.getAtomRadius(e):0}getAtomData(e,t,i){return e.getBackboneAtomData(this.getAtomParams(t,i))}getBondData(e,t,i){return e.getBackboneBondData(this.getBondParams(t,i))}}Ne.add("backbone",Hl);class Wl extends jl{constructor(e,t,i){super(e,t,i),this.type="base",this.parameters=Object.assign({},this.parameters,{multipleBond:null,bondSpacing:null})}init(e){let t=e||{};t.aspectRatio=l(t.aspectRatio,1),t.radiusSize=l(t.radiusSize,.3),super.init(t)}getAtomData(e,t,i){return e.getRungAtomData(this.getAtomParams(t,i))}getBondData(e,t,i){let r=this.getBondParams(t,i);return Object.assign(r.colorParams,{rung:!0}),e.getRungBondData(r)}}Ne.add("base",Wl);class ql{constructor(e,i){this.m=e,this.tension=i,this.dt=1/this.m,this.delta=1e-4,this.vec1=new t.Vector3,this.vec2=new t.Vector3,this.vDir=new t.Vector3,this.vTan=new t.Vector3,this.vNorm=new t.Vector3,this.vBin=new t.Vector3,this.m2=Math.ceil(this.m/2)}interpolateToArr(e,t,i,r,s,n,o){n[o+0]=E(e.x,t.x,i.x,r.x,s,this.tension),n[o+1]=E(e.y,t.y,i.y,r.y,s,this.tension),n[o+2]=E(e.z,t.z,i.z,r.z,s,this.tension)}interpolateToVec(e,t,i,r,s,n){n.x=E(e.x,t.x,i.x,r.x,s,this.tension),n.y=E(e.y,t.y,i.y,r.y,s,this.tension),n.z=E(e.z,t.z,i.z,r.z,s,this.tension)}interpolatePosition(e,t,i,r,s,n){for(var o=0;o1&&(l=1),this.interpolateToVec(e,t,i,r,c,this.vec1),this.interpolateToVec(e,t,i,r,l,this.vec2),this.vec2.sub(this.vec1).normalize(),this.vec2.toArray(s,h)}}vectorSubdivide(e,t,i,r,s){let n,o=t.next(),a=t.next(),c=t.next();const l=t.size,h=l-1;let u=r||0;for(let r=0;r0&&t{if(e.residueCount<4)return;i.push(e);const r=this.getSpline(e),s=this.getAspectRatio(e),n=r.getSubdividedPosition(),o=r.getSubdividedOrientation(),a=r.getSubdividedColor(this.getColorParams()),c=r.getSubdividedPicking(),l=r.getSubdividedSize(this.getRadiusParams());t.push(new Ql(Object.assign({},n,o,a,c,l),this.getBufferParams({radialSegments:this.radialSegments,aspectRatio:s,capped:this.capped})))}),e.getSelection()),{bufferList:t,polymerList:i}}updateData(t,i){e.Debug&&Be.time(this.type+" repr update"),t=t||{};for(var r=0,s=i.polymerList.length;r0;Gi(_,x,S);const s=Vi(_,w)<0;if(Yi(_,w,Vi(w,v)),Gi(C,v,_),Yi(_,w,Vi(w,A)),Gi(P,A,_),0===qi(C)||0===qi(P))continue;Ki(C,C),Ki(P,P);const l=n[T]=ir(C,P);a[T]=(mt*l).toFixed(1)+String.fromCharCode(176),zi(M,C,w),Ki(M,M),Vi(M,P)<0&&tr(M,M),fl(_,S,C,M,l/2),Hi(_,o,3*T);const R=Math.ceil(l/i),O=R+(t.extendLine?4:2),$=t.extendLine?36:0,F=new Float32Array(3*O),E=new Float32Array(3*O),L=new Float32Array(9*R),N=new Float32Array($);c[T]=F,h[T]=E,u[T]=L,d[T]=N,t.extendLine&&(r?(Gi(_,g,b),Ki(_,_),Yi(I,_,1/Vi(C,_)),Ui(I,I,b)):(Yi(I,v,1/Vi(C,v)),Ui(I,I,y)),s?(Gi(_,x,y),Ki(_,_),Yi(k,_,1/Vi(P,_)),Ui(k,k,y)):(Yi(k,A,1/Vi(P,A)),Ui(k,k,b))),Ui(D,S,C);let z=0;t.extendLine?(Hi(g,F,z),Hi(I,E,z),z+=3,Hi(I,F,z),Hi(D,E,z),z+=3,Hi(I,N,0),Hi(D,N,3),Hi(r?b:y,N,6),Hi(r?b:y,N,9),Hi(D,N,12),Hi(S,N,15)):(Hi(S,F,z),Hi(D,E,z),z+=3);const V=function(e,t){const i=9*t;Hi(S,L,i),Hi(D,L,i+3),Hi(D,F,z),fl(D,S,C,M,e),Hi(D,L,i+6),Hi(D,E,z),z+=3};let G=0;for(let e=i;e{const t=ih(i,e);Object.assign(e,t)})),t.side=l(t.side,"double"),t.opacity=l(t.opacity,.5),t.radiusType=l(t.radiusType,"size"),t.radiusSize=l(t.radiusSize,.15),super.init(t)}getHistogramBinBorderBufferParameters(){return this.getBufferParams({linewidth:this.histogramBinBorderWidth,visible:this.histogramBinBorderVisible,opacity:this.histogramBinBorderOpacity})}getBondArrowsBufferParameters(){return this.getBufferParams({linewidth:this.bondArrowWidth,visible:this.bondArrowVisible,opacity:this.bondArrowOpacity})}getOpaqueMiddleDiscBufferParameters(){return this.getBufferParams({visible:this.opaqueMiddleDiscVisible,opacity:this.opaqueMiddleDiscOpacity})}getHistogramBufferParameters(){return this.getBufferParams({visible:!0,opacity:this.histogramOpacity,side:"double"})}createData(e){if(!e.atomCount||!this.histogramsData.length)return;this.histogramsData.forEach((t=>t.atomPositions=pl(e,[t.atomQuad])));const t=this.scaleBinToSectorArea?function(e){return Math.sqrt(e)}:function(e){return e};function i(e){const t=e.map((e=>e.length)),i=new Float32Array(Pt(t));let r=0;for(let t=0;te.startPoints))),position2:i(e.map((e=>e.endPoints))),color:i(e.map((e=>e.startColors))),color2:i(e.map((e=>e.endColors)))},t)}function s(e,t){return new Bn({position:i(e.map((e=>e.triangles))),color:i(e.map((e=>e.triangleColors)))},t)}this.histogramsData.forEach((e=>e.histogram360Scaled=e.histogram360.map(t)));const n=[];for(let e=0;e=3&&(t=nh(i)),void 0!==t&&n.push(t)}return this.frontHistogramBinBordersBuffer=r(n.map((e=>e.frontHistogramBinBorders)),this.getHistogramBinBorderBufferParameters()),this.backHistogramBinBordersBuffer=r(n.map((e=>e.backHistogramBinBorders)),this.getHistogramBinBorderBufferParameters()),this.adjacentBondArrowsBuffer=r(n.map((e=>e.adjacentBondArrows)),this.getBondArrowsBufferParameters()),this.distantBondArrowsBuffer=r(n.map((e=>e.distantBondArrows)),this.getBondArrowsBufferParameters()),this.opaqueMiddleDiscBuffer=s(n.map((e=>e.opaqueMiddleDisc)),this.getOpaqueMiddleDiscBufferParameters()),this.frontHistogramBuffer=s(n.map((e=>e.frontHistogram)),this.getHistogramBufferParameters()),this.backHistogramBuffer=s(n.map((e=>e.backHistogram)),this.getHistogramBufferParameters()),{bufferList:[].concat(this.frontHistogramBinBordersBuffer,this.backHistogramBinBordersBuffer,this.adjacentBondArrowsBuffer,this.distantBondArrowsBuffer,this.opaqueMiddleDiscBuffer,this.frontHistogramBuffer,this.backHistogramBuffer)}}setParameters(e){return super.setParameters(e,{},!1),e&&void 0!==e.histogramBinBorderVisible&&this.setVisibility(this.visible),this}setVisibility(e,t){return super.setVisibility(e,!0),this.frontHistogramBinBordersBuffer&&this.frontHistogramBinBordersBuffer.setVisibility(this.histogramBinBorderVisible),this.backHistogramBinBordersBuffer&&this.backHistogramBinBordersBuffer.setVisibility(this.histogramBinBorderVisible),t||this.viewer.requestRender(),this}}function nh(e){const t=e.atomPositions,i=e.histogram360Scaled,r=i.length<=180?360:2*i.length,s={triangles:new Float32Array(3*r*3),triangleColors:rh(e.opaqueMiddleDiscColor,3*r)},n={triangles:new Float32Array(3*i.length*3),triangleColors:rh(e.frontHistogramColor,3*i.length)},o={triangles:new Float32Array(3*i.length*3),triangleColors:rh(e.backHistogramColor,3*i.length)},a={startPoints:new Float32Array(3*i.length),endPoints:new Float32Array(3*i.length),startColors:rh(e.histogramBinBorderColor,i.length),endColors:rh(e.histogramBinBorderColor,i.length)},c={startPoints:new Float32Array(3*i.length),endPoints:new Float32Array(3*i.length),startColors:rh(e.histogramBinBorderColor,i.length),endColors:rh(e.histogramBinBorderColor,i.length)},l={startPoints:new Float32Array(6),endPoints:new Float32Array(6),startColors:rh(e.adjacentBondArrowColor,i.length),endColors:rh(e.adjacentBondArrowColor,i.length)},h={startPoints:new Float32Array(6),endPoints:new Float32Array(6),startColors:rh(e.distantBondArrowColor,i.length),endColors:rh(e.distantBondArrowColor,i.length)},u=Ni(),d=Ni(),m=Ni(),p=Ni(),f=Ni(),g=Ni(),y=Ni(),b=Ni(),x=Ni(),v=Ni(),w=Ni(),A=Ni(),_=Ni(),S=Ni(),C=Ni(),P=Ni(),I=[u,d,m,p];for(let e=0;e{let d=t[0],m=t[1];if("number"==typeof d&&Number.isInteger(d)&&"number"==typeof m&&Number.isInteger(m)){if(!u.get(d)||!u.get(m))return void(h+=1);c.index=d,l.index=m}else{n.setString(d),o.setString(m);var p=e.getAtomIndices(n),f=e.getAtomIndices(o);if(!p.length||!f.length)return void(h+=1);c.index=p[0],l.index=f[0]}a.addBond(c,l,1),i-=h;var g=c.distanceTo(l);switch(this.labelUnit){case"angstrom":r[i]=g.toFixed(2)+" "+String.fromCharCode(8491);break;case"nm":r[i]=(g/10).toFixed(2)+" nm";break;default:r[i]=g.toFixed(2)}var y=3*i;s[y+0]=(c.x+l.x)/2,s[y+1]=(c.y+l.y)/2,s[y+2]=(c.z+l.z)/2})),h>0&&(i-=h,s=s.subarray(0,3*i));var d=new Sr(a.count,!0);return{text:r,position:s,bondSet:d,bondStore:a}}getBondData(e,t,i){const r=e.getBondData(this.getBondParams(t,i));return r.picking&&(r.picking=new Us(r.picking.array,r.picking.structure,i.bondStore)),r}createData(e){if(!e.atomCount||!this.atomPair.length)return;const i=this.atomPair.length,r=new t.Color(this.labelColor),s=this.getDistanceData(e,this.atomPair);this.textBuffer=new Sl({position:s.position,size:yt(i,this.labelSize),color:bt(i,r.r,r.g,r.b),text:s.text},this.getLabelBufferParams());const n={bondSet:s.bondSet,bondStore:s.bondStore},o=this.getBondData(e,{position:!0,color:!0,picking:!0,radius:this.useCylinder},n);return this.useCylinder?this.distanceBuffer=new Gl(o,this.getBufferParams({openEnded:this.openEnded,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0})):this.distanceBuffer=new Il(sr(o),this.getBufferParams({linewidth:this.linewidth,visible:this.lineVisible,opacity:this.lineOpacity})),{bondSet:s.bondSet,bondStore:s.bondStore,position:s.position,bufferList:[this.textBuffer,this.distanceBuffer]}}updateData(e,t){super.updateData(e,t);const i={bondSet:t.bondSet,bondStore:t.bondStore},r=this.getBondData(t.sview,e,i),s={};e&&!e.color||Object.assign(s,{color:r.color,color2:r.color2}),e&&!e.radius||Object.assign(s,{radius:r.radius}),this.distanceBuffer.setAttributes(s)}setParameters(e){return super.setParameters(e,{},!1),this.useCylinder||(e&&e.lineOpacity&&this.distanceBuffer.setParameters({opacity:e.lineOpacity}),e&&void 0!==e.opacity&&this.distanceBuffer.setParameters({opacity:this.lineOpacity}),e&&e.linewidth&&this.distanceBuffer.setParameters({linewidth:e.linewidth})),this}}function ah(e){return 2*(e.position.length/3)*3}Ne.add("distance",oh);const ch=Object.assign({scale:1,color:"grey"},Mn);class lh extends Tn{constructor(e,i={}){super({position:new Float32Array(ah(e)),color:new Float32Array(ah(e))},i),this.isLine=!0,this.vertexShader="Line.vert",this.fragmentShader="Line.frag";const r=new t.Color(this.parameters.color),s=this.geometry.attributes;bt(ah(e)/3,r.r,r.g,r.b,s.color.array),this.setAttributes(e)}get defaultParameters(){return ch}setAttributes(e={}){const t=this.geometry.attributes;let i,r,s;e.position&&e.vector&&(i=e.position,r=e.vector,s=t.position.array,t.position.needsUpdate=!0);const n=this.size/2,o=this.parameters.scale;if(i&&r)for(let e=0;e{if(e.residueCount<4)return;i.push(e);const r=new fo(e),s=r.getPosition(),n=r.getColor(this.getColorParams()),o=r.getSize(this.getRadiusParams()),a=r.getPicking();t.push(new Ta({position:s.center,color:n.color,radius:o.size,picking:a.picking},this.getBufferParams({sphereDetail:this.sphereDetail,disableImpostor:this.disableImpostor,dullInterior:!0})),new lh({position:s.center,vector:s.axis},this.getBufferParams({color:"skyblue",scale:1})),new lh({position:s.center,vector:s.resdir},this.getBufferParams({color:"lightgreen",scale:1})))}),e.getSelection()),{bufferList:t,polymerList:i}}updateData(t,i){e.Debug&&Be.time(this.type+" repr update"),t=t||{};for(let e=0,r=i.polymerList.length;e radius2) {\nspaceposition.y = mapping.y * 1.5 * radius1;\nspaceposition.x = mapping.x * 1.5 * radius1;\n} else {\nspaceposition.y = mapping.y * 1.5 * radius2;\nspaceposition.x = mapping.x * 1.5 * radius2;\n}\nspaceposition.w = 1.0;\nvec4 e3 = vec4( 1.0 );\nvec3 e1, e1_temp, e2, e2_temp;\ne3.xyz = normalize(position_atom1-position_atom2);\nif (e3.z == 0.0) { e3.z = 0.0000000000001;}\nif ( (position_atom1.x - position_atom2.x) == 0.0) { position_atom1.x += 0.001;}\nif ( (position_atom1.y - position_atom2.y) == 0.0) { position_atom1.y += 0.001;}\nif ( (position_atom1.z - position_atom2.z) == 0.0) { position_atom1.z += 0.001;}\nvec4 focus = vec4( 1.0 );\nfocus.x = ( position_atom1.x*position_atom1.x - position_atom2.x*position_atom2.x +\n( radius2*radius2 - radius1*radius1 )*e3.x*e3.x/shrink )/(2.0*(position_atom1.x - position_atom2.x));\nfocus.y = ( position_atom1.y*position_atom1.y - position_atom2.y*position_atom2.y +\n( radius2*radius2 - radius1*radius1 )*e3.y*e3.y/shrink )/(2.0*(position_atom1.y - position_atom2.y));\nfocus.z = ( position_atom1.z*position_atom1.z - position_atom2.z*position_atom2.z +\n( radius2*radius2 - radius1*radius1 )*e3.z*e3.z/shrink )/(2.0*(position_atom1.z - position_atom2.z));\ne1.x = 1.0;\ne1.y = 1.0;\ne1.z = ( (e3.x*focus.x + e3.y*focus.y + e3.z*focus.z) - e1.x*e3.x - e1.y*e3.y)/e3.z;\ne1_temp = e1 - focus.xyz;\ne1 = normalize(e1_temp);\ne2_temp = e1.yzx * e3.zxy - e1.zxy * e3.yzx;\ne2 = normalize(e2_temp);\nmat3 R= mat3( e1.xyz, e2.xyz, e3.xyz );\nvertex_position.xyz = R * spaceposition.xyz;\nvertex_position.w = 1.0;\nvertex_position.x += (position_atom1.x+position_atom2.x) / 2.0;\nvertex_position.y += (position_atom1.y+position_atom2.y) / 2.0;\nvertex_position.z += (position_atom1.z+position_atom2.z) / 2.0;\ngl_Position = modelViewProjectionMatrix * vertex_position;\nvec4 i_near, i_far;\nvec4 near = gl_Position;\nnear.z = 0.0 ;\nnear = modelViewProjectionMatrixInverse * near;\ni_near = near;\nvec4 far = gl_Position;\nfar.z = far.w ;\ni_far = modelViewProjectionMatrixInverse * far;\nprime1 = vec4( position_atom1 - (position_atom1 - focus.xyz)*shrink, 1.0 );\nprime2 = vec4( position_atom2 - (position_atom2 - focus.xyz)*shrink, 1.0 );\nfloat Rsquare = (radius1*radius1/shrink) - (\n(position_atom1.x - focus.x)*(position_atom1.x - focus.x) +\n(position_atom1.y - focus.y)*(position_atom1.y - focus.y) +\n(position_atom1.z - focus.z)*(position_atom1.z - focus.z)\n);\nfocus.w = Rsquare;\nmatrix_near = mat4( i_near, i_far, focus, e3 );\ngl_Position.z = 1.0;\n}"),Ve.add("shader/HyperballStickImpostor.frag","#define STANDARD\n#define IMPOSTOR\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 interiorColor;\nuniform float interiorDarkening;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\nuniform float clipNear;\nuniform float shrink;\nuniform mat4 modelViewMatrix;\nuniform mat4 modelViewProjectionMatrix;\nuniform mat4 modelViewMatrixInverseTranspose;\nuniform mat4 projectionMatrix;\nvarying mat4 matrix_near;\nvarying vec4 prime1;\nvarying vec4 prime2;\nvarying float vRadius;\nvarying float vRadius2;\n#ifdef PICKING\nuniform float objectId;\nvarying vec3 vPickingColor;\n#else\nvarying vec3 vColor1;\nvarying vec3 vColor2;\n#include common\n#include fog_pars_fragment\n#include bsdfs\n#include lights_pars_begin\n#include lights_physical_pars_fragment\n#endif\nbool interior = false;\nfloat calcClip( vec4 cameraPos ){\nreturn dot( cameraPos, vec4( 0.0, 0.0, 1.0, clipNear - 0.5 ) );\n}\nfloat calcClip( vec3 cameraPos ){\nreturn calcClip( vec4( cameraPos, 1.0 ) );\n}\nfloat calcDepth( in vec3 cameraPos ){\nvec2 clipZW = cameraPos.z * projectionMatrix[2].zw + projectionMatrix[3].zw;\nreturn 0.5 + 0.5 * clipZW.x / clipZW.y;\n}\nstruct Ray {\nvec3 origin ;\nvec3 direction ;\n};\nbool cutoff_plane (vec3 M, vec3 cutoff, vec3 x3){\nfloat a = x3.x;\nfloat b = x3.y;\nfloat c = x3.z;\nfloat d = -x3.x*cutoff.x-x3.y*cutoff.y-x3.z*cutoff.z;\nfloat l = a*M.x+b*M.y+c*M.z+d;\nif (l<0.0) {return true;}\nelse{return false;}\n}\nvec3 isect_surf(Ray r, mat4 matrix_coef){\nvec4 direction = vec4(r.direction, 0.0);\nvec4 origin = vec4(r.origin, 1.0);\nfloat a = dot(direction,(matrix_coef*direction));\nfloat b = dot(origin,(matrix_coef*direction));\nfloat c = dot(origin,(matrix_coef*origin));\nfloat delta =b*b-a*c;\ngl_FragColor.a = 1.0;\nif (delta<0.0){\ndiscard;\n}\nfloat t1 =(-b-sqrt(delta))/a;\nreturn r.origin+t1*r.direction;\n}\nvec3 isect_surf2(Ray r, mat4 matrix_coef){\nvec4 direction = vec4(r.direction, 0.0);\nvec4 origin = vec4(r.origin, 1.0);\nfloat a = dot(direction,(matrix_coef*direction));\nfloat b = dot(origin,(matrix_coef*direction));\nfloat c = dot(origin,(matrix_coef*origin));\nfloat delta =b*b-a*c;\ngl_FragColor.a = 1.0;\nif (delta<0.0){\ndiscard;\n}\nfloat t2 =(-b+sqrt(delta))/a;\nreturn r.origin+t2*r.direction;\n}\nRay primary_ray(vec4 near1, vec4 far1){\nvec3 near=near1.xyz/near1.w;\nvec3 far=far1.xyz/far1.w;\nreturn Ray(near,far-near);\n}\nfloat update_z_buffer(vec3 M, mat4 ModelViewP){\nfloat depth1;\nvec4 Ms=(ModelViewP*vec4(M,1.0));\nreturn depth1=(1.0+Ms.z/Ms.w)/2.0;\n}\nvoid main(){\nfloat radius = max( vRadius, vRadius2 );\nvec4 i_near, i_far, focus;\nvec3 e3, e1, e1_temp, e2;\ni_near = vec4(matrix_near[0][0],matrix_near[0][1],matrix_near[0][2],matrix_near[0][3]);\ni_far = vec4(matrix_near[1][0],matrix_near[1][1],matrix_near[1][2],matrix_near[1][3]);\nfocus = vec4(matrix_near[2][0],matrix_near[2][1],matrix_near[2][2],matrix_near[2][3]);\ne3 = vec3(matrix_near[3][0],matrix_near[3][1],matrix_near[3][2]);\ne1.x = 1.0;\ne1.y = 1.0;\ne1.z = ( (e3.x*focus.x + e3.y*focus.y + e3.z*focus.z) - e1.x*e3.x - e1.y*e3.y)/e3.z;\ne1_temp = e1 - focus.xyz;\ne1 = normalize(e1_temp);\ne2 = normalize(cross(e1,e3));\nvec4 equation = focus;\nfloat shrinkfactor = shrink;\nfloat t1 = -1.0/(1.0-shrinkfactor);\nfloat t2 = 1.0/(shrinkfactor);\nvec4 colonne1, colonne2, colonne3, colonne4;\nmat4 mat;\nvec3 equation1 = vec3(t2,t2,t1);\nfloat A1 = - e1.x*equation.x - e1.y*equation.y - e1.z*equation.z;\nfloat A2 = - e2.x*equation.x - e2.y*equation.y - e2.z*equation.z;\nfloat A3 = - e3.x*equation.x - e3.y*equation.y - e3.z*equation.z;\nfloat A11 = equation1.x*e1.x*e1.x + equation1.y*e2.x*e2.x + equation1.z*e3.x*e3.x;\nfloat A21 = equation1.x*e1.x*e1.y + equation1.y*e2.x*e2.y + equation1.z*e3.x*e3.y;\nfloat A31 = equation1.x*e1.x*e1.z + equation1.y*e2.x*e2.z + equation1.z*e3.x*e3.z;\nfloat A41 = equation1.x*e1.x*A1 + equation1.y*e2.x*A2 + equation1.z*e3.x*A3;\nfloat A22 = equation1.x*e1.y*e1.y + equation1.y*e2.y*e2.y + equation1.z*e3.y*e3.y;\nfloat A32 = equation1.x*e1.y*e1.z + equation1.y*e2.y*e2.z + equation1.z*e3.y*e3.z;\nfloat A42 = equation1.x*e1.y*A1 + equation1.y*e2.y*A2 + equation1.z*e3.y*A3;\nfloat A33 = equation1.x*e1.z*e1.z + equation1.y*e2.z*e2.z + equation1.z*e3.z*e3.z;\nfloat A43 = equation1.x*e1.z*A1 + equation1.y*e2.z*A2 + equation1.z*e3.z*A3;\nfloat A44 = equation1.x*A1*A1 + equation1.y*A2*A2 + equation1.z*A3*A3 - equation.w;\ncolonne1 = vec4(A11,A21,A31,A41);\ncolonne2 = vec4(A21,A22,A32,A42);\ncolonne3 = vec4(A31,A32,A33,A43);\ncolonne4 = vec4(A41,A42,A43,A44);\nmat = mat4(colonne1,colonne2,colonne3,colonne4);\nRay ray = primary_ray(i_near,i_far) ;\nvec3 M;\nM = isect_surf(ray, mat);\nif (cutoff_plane(M, prime1.xyz, -e3) || cutoff_plane(M, prime2.xyz, e3)){ discard; }\nvec4 M1 = vec4(M,1.0);\nvec4 M2 = mat*M1;\nvec3 _normal = ( modelViewMatrixInverseTranspose * M2 ).xyz;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix) ;\n#ifdef NEAR_CLIP\nif( calcClip( modelViewMatrix * vec4( M, 1.0 ) ) > 0.0 ){\nM = isect_surf2(ray, mat);\nif( calcClip( modelViewMatrix * vec4( M, 1.0 ) ) > 0.0 )\ndiscard;\ninterior = true;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix) ;\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = max( 0.0, calcDepth( vec3( - ( clipNear - 0.5 ) ) ) + ( 0.0000001 / radius ) );\n}\n}else if( gl_FragDepthEXT <= 0.0 ){\nM = isect_surf2(ray, mat);\ninterior = true;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix);\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / radius );\n}\n}\n#else\nif( gl_FragDepthEXT <= 0.0 ){\nM = isect_surf2(ray, mat);\ninterior = true;\ngl_FragDepthEXT = update_z_buffer(M, modelViewProjectionMatrix) ;\nif( gl_FragDepthEXT >= 0.0 ){\ngl_FragDepthEXT = 0.0 + ( 0.0000001 / radius );\n}\n}\n#endif\nif (cutoff_plane(M, prime1.xyz, -e3) || cutoff_plane(M, prime2.xyz, e3)){ discard; }\nif (gl_FragDepthEXT < 0.0)\ndiscard;\nif (gl_FragDepthEXT > 1.0)\ndiscard;\nfloat distance_ratio = ((M.x-prime2.x)*e3.x + (M.y-prime2.y)*e3.y +(M.z-prime2.z)*e3.z) /\ndistance(prime2.xyz,prime1.xyz);\n#ifdef PICKING\nif( opacity < 0.3 )\ndiscard;\ngl_FragColor = vec4( vPickingColor, objectId );\n#else\nvec3 vViewPosition = -( modelViewMatrix * vec4( M, 1.0 ) ).xyz;\nvec3 vNormal = _normal;\nvec3 vColor;\nif( distance_ratio>0.5 ){\nvColor = vColor1;\n}else{\nvColor = vColor2;\n}\nvec4 diffuseColor = vec4( diffuse, opacity );\nReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\nvec3 totalEmissiveLight = emissive;\n#include color_fragment\n#include roughnessmap_fragment\n#include metalnessmap_fragment\nvec3 normal = normalize( vNormal );\nvec3 geometryNormal = normal;\n#include lights_physical_fragment\n#include lights_fragment_begin\n#include lights_fragment_end\nvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveLight;\nif( interior ){\n#ifdef USE_INTERIOR_COLOR\noutgoingLight.xyz = interiorColor;\n#else\n#ifdef DIFFUSE_INTERIOR\noutgoingLight.xyz = vColor;\n#endif\n#endif\noutgoingLight.xyz *= 1.0 - interiorDarkening;\n}\ngl_FragColor = vec4( outgoingLight, diffuseColor.a );\n#include premultiplied_alpha_fragment\n#include tonemapping_fragment\n#include encodings_fragment\n#include fog_fragment\n#endif\n}");const dh=new Float32Array([-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,-1,1,-1,1,1,-1,1,1,1,-1,1,1]),mh=new Uint16Array([0,1,2,0,2,3,1,5,6,1,6,2,4,6,5,4,7,6,0,7,4,0,3,7,0,5,1,0,4,5,3,2,6,3,6,7]);class ph extends Pa{constructor(e,t={}){super("v3",e,t)}get mapping(){return dh}get mappingIndices(){return mh}get mappingIndicesSize(){return 36}get mappingSize(){return 8}get mappingItemSize(){return 3}}const fh=Object.assign({shrink:.14},Mn),gh=Object.assign({shrink:{uniform:!0}},Dn);class yh extends ph{constructor(e,i={}){super(e,i),this.parameterTypes=gh,this.isImpostor=!0,this.vertexShader="HyperballStickImpostor.vert",this.fragmentShader="HyperballStickImpostor.frag",this.addUniforms({modelViewProjectionMatrix:{value:new t.Matrix4},modelViewProjectionMatrixInverse:{value:new t.Matrix4},modelViewMatrixInverseTranspose:{value:new t.Matrix4},shrink:{value:this.parameters.shrink}}),this.addAttributes({position1:{type:"v3",value:null},position2:{type:"v3",value:null},color2:{type:"c",value:null},radius:{type:"f",value:null},radius2:{type:"f",value:null}}),this.setAttributes(e),this.makeMapping()}get defaultParameters(){return fh}}Object.assign({disableImpostor:!1},Rl,fh);const bh=class{constructor(e,t={}){return!De||t&&t.disableImpostor?(e.radius=function(e,t){const i=e.length,r=new Float32Array(i);for(let s=0;sa.push(r.atomLabel(e)))))}else if("residue"===this.labelGrouping){t&&!t.position||(c=[]),t&&!t.color||(h=[]),t&&!t.radius||(l=[]),t&&!t.text||(a=[]),i.colorParams&&(i.colorParams.structure=e.getStructure());const u=Ee.getScheme(i.colorParams),d=new ro(i.radiusParams),m=e.getAtomProxy();let p=0;e.eachResidue((e=>{const i=3*p;e.isProtein()||e.isNucleic()?(m.index=e.traceAtomIndex,t&&!t.position||m.positionToArray(c,i)):(m.index=e.atomOffset,t&&!t.position||e.positionToArray(c,i)),t&&!t.color||u.atomColorToArray(m,h,i),t&&!t.radius||(l[p]=d.atomRadius(m)),t&&!t.text||a.push(r.atomLabel(m)),++p})),t&&!t.position||(s=new Float32Array(c)),t&&!t.color||(o=new Float32Array(h)),t&&!t.radius||(n=new Float32Array(l))}return{position:s,size:n,color:o,text:a}}createData(e){return{bufferList:[new Sl(this.getTextData(e,{position:!0,color:!0,radius:!0,text:!0}),this.getBufferParams({fontFamily:this.fontFamily,fontStyle:this.fontStyle,fontWeight:this.fontWeight,xOffset:this.xOffset,yOffset:this.yOffset,zOffset:this.zOffset,attachment:this.attachment,showBorder:this.showBorder,borderColor:this.borderColor,borderWidth:this.borderWidth,showBackground:this.showBackground,backgroundColor:this.backgroundColor,backgroundMargin:this.backgroundMargin,backgroundOpacity:this.backgroundOpacity,fixedSize:this.fixedSize}))]}}updateData(e,t){t.bufferList[0].setAttributes(this.getTextData(t.sview,e))}getAtomRadius(){return 0}}function Ah(e){const t=e.getAtomSet(),i=e.getBondSet(),r=e.getBondProxy();return i.forEach((function(e){r.index=e,t.clear(r.atomIndex1),t.clear(r.atomIndex2)})),t}Ne.add("label",wh);class _h extends dl{constructor(e,t,i){super(e,t,i),this.type="line",this.parameters=Object.assign({multipleBond:{type:"select",rebuild:!0,options:{off:"off",symmetric:"symmetric",offset:"offset"}},bondSpacing:{type:"number",precision:2,max:2,min:.5},linewidth:{type:"integer",max:50,min:1,buffer:!0},lines:{type:"boolean",rebuild:!0},crosses:{type:"select",rebuild:!0,options:{off:"off",lone:"lone",all:"all"}},crossSize:{type:"number",precision:2,max:2,min:.1}},this.parameters,{flatShaded:null,side:null,wireframe:null,roughness:null,metalness:null}),this.init(i)}init(e){var t=e||{};this.multipleBond=l(t.multipleBond,"off"),this.bondSpacing=l(t.bondSpacing,1),this.linewidth=l(t.linewidth,2),this.lines=l(t.lines,!0),this.crosses=l(t.crosses,"lone"),this.crossSize=l(t.crossSize,.4),super.init(t)}getAtomRadius(e){return.1}getBondParams(e,t){return t=Object.assign({multipleBond:this.multipleBond,bondSpacing:this.bondSpacing,radiusParams:{type:"size",size:.1,scale:1}},t),super.getBondParams(e,t)}_crossData(e,t){if(e&&!e.position&&!e.color)return;const i={};"lone"===this.crosses&&Object.assign(i,{atomSet:Ah(t)});const r=t.getAtomData(this.getAtomParams(e,i)),s={},n=r.position,o=r.color,a=r.picking,c=(n||o).length,l=3*c;let h=new Float32Array(0),u=new Float32Array(0),d=new Float32Array(0),m=new Float32Array(0),p=0,f=new Float32Array(0);e&&!e.position||(h=s.position1=new Float32Array(l),u=s.position2=new Float32Array(l),p=this.crossSize/2),e&&!e.color||(d=s.color=new Float32Array(l),m=s.color2=new Float32Array(l)),e&&!e.picking||(f=new Float32Array(3*r.picking.array.length));for(let t=0;tl?d[f]=-1:(c=Math.sqrt(l-a),d[f]=Math.floor(c)),++f;p[g]=u,m[g]=d}}function k(i){var r,s,n,a,u,f,b,v,w,A,S,C,P,I,k,M,D,T,B=3*i,R=i;r=Math.floor(.5+o*(e[B]+d[0])),s=Math.floor(.5+o*(e[B+1]+d[1])),n=Math.floor(.5+o*(e[B+2]+d[2]));var O,$=t[R],F=m[$],E=0,L=l*h,N=p[$];for(A=0;A=c||I>=l||k>=h)){var z=P*L+I*h+k;if(g)if(y[z]&_){if(y[z]&_){var V=x[z];V!==B&&b*b+v*v+w*w<(a=r+b-Math.floor(.5+o*(e[V]+d[0])))*a+(u=s+v-Math.floor(.5+o*(e[V+1]+d[1])))*u+(f=n+w-Math.floor(.5+o*(e[V+2]+d[2])))*f&&(x[z]=i)}}else y[z]|=_,x[z]=i;else y[z]|=_}E++}}function M(t){var i,r;for(console.time("EDTSurface fillvoxels"),i=0,r=y.length;i=c||_>=l||C>=h)){var L=A*E+_*h+C;if(y[L]&S){if(g){var N=x[L];b*b+v*v+w*w<(a=Math.floor(.5+o*(e[N]+d[0])))*a+(u=Math.floor(.5+o*(e[N+1]+d[1])))*u+(f=Math.floor(.5+o*(e[N+2]+d[2])))*f&&(x[L]=i)}}else y[L]|=S,g&&(x[L]=i)}$++}}function T(){var e,t,i,r;console.time("EDTSurface fastdistancemap");var s,n=Sh(c,l,h,Uint16Array,3),o=l*h,u=f*f,d=0;for(e=0;e0);var A,P=a*a,I=new Uint16Array(3);for(e=0;e=P)||(y[s]|=C,g&&y[s]&S&&(n.toArray(e,t,i,I),A=I[0]*o+I[1]*h+I[2],x[s]=x[A])));console.timeEnd("EDTSurface fastdistancemap")}function B(e,t,i,r){var s,n,o,a,u,d,m,p,f,g,x,v,w=new Uint16Array(3),A=0;if(0===i)return A;var I=-1,k=-1,M=-1,D=l*h;for(m=0,f=i;m-1&&k-1&&M-1&&(y[x=I*D+h*k+M]&_&&!(y[x]&S)?(t.fromArray(I,k,M,w),g=(a=I-w[0])*a+(u=k-w[1])*u+(d=M-w[2])*d,b[x]=g,y[x]|=S,y[x]|=C,r[A]=I,r[A+1]=k,r[A+2]=M,A+=3):y[x]&_&&y[x]&S&&(g=(a=I-w[0])*a+(u=k-w[1])*u+(d=M-w[2])*d)-1&&k-1&&M-1&&(y[x=I*D+h*k+M]&_&&!(y[x]&S)?(t.fromArray(I,k,M,w),g=(a=I-w[0])*a+(u=k-w[1])*u+(d=M-w[2])*d,b[x]=g,y[x]|=S,y[x]|=C,r[A]=I,r[A+1]=k,r[A+2]=M,A+=3):y[x]&_&&y[x]&S&&(g=(a=I-w[0])*a+(u=k-w[1])*u+(d=M-w[2])*d)-1&&k-1&&M-1&&(y[x=I*D+h*k+M]&_&&!(y[x]&S)?(t.fromArray(I,k,M,w),g=(a=I-w[0])*a+(u=k-w[1])*u+(d=M-w[2])*d,b[x]=g,y[x]|=S,y[x]|=C,r[A]=I,r[A+1]=k,r[A+2]=M,A+=3):y[x]&_&&y[x]&S&&(g=(a=I-w[0])*a+(u=k-w[1])*u+(d=M-w[2])*d)-1&&o-1&&u-1&&aD&&(D=O)}return{neighbourListLength:27*D+1,withinRadii:function(s,n,o,a,u){for(var d=0,m=p(s,c),f=p(n,l),g=p(o,h),y=Math.max(0,m-1),w=Math.max(0,f-1),_=Math.max(0,g-1),S=Math.min(b,m+2),C=Math.min(x,f+2),M=Math.min(v,g+2),D=y;Dm&&(m=u[e]);!function(){const e=An(c,h,m,f,0);f=e.scaleFactor,b=e.dim,x=e.matrix,O=Math.max(5,2+Math.floor(p*f)),v=yt(b[0]*b[1]*b[2],-1001),w=new Int32Array(v.length),A=new Float32Array(b[0]),_=new Float32Array(b[1]),S=new Float32Array(b[2]),F(A,c[0],1/f),F(_,c[1],1/f),F(S,c[2],1/f)}(),function(){var e=0,t=2*Math.PI/y;P=new Float32Array(y),C=new Float32Array(y);for(var i=0;i=0;){if(n!==r&&n!==s&&L(n,e,t,i))return M=n,n;n=k[++o]}return M=-1,-1}function L(t,i,r,s){var n=3*t,o=d[t],a=e[n]-i,c=e[n+1]-r,l=e[n+2]-s;return a*a+c*c+l*l0&&d=0;)e{t(this._makeSurface(e.data.sd,i))}),(e=>{console.warn("MolecularSurface.getSurfaceWorker error - trying without worker",e),this.worker.terminate(),this.worker=void 0;const r=this.getSurface(i);t(r)}))}else{const e=this.getSurface(i);t(e)}}dispose(){this.worker&&this.worker.terminate()}}class Mh extends dl{constructor(e,t,i){super(e,t,i),this.type="surface",this.parameters=Object.assign({surfaceType:{type:"select",rebuild:!0,options:{vws:"vws",sas:"sas",ms:"ms",ses:"ses",av:"av"}},probeRadius:{type:"number",precision:1,max:20,min:0,rebuild:!0},smooth:{type:"integer",precision:1,max:10,min:0,rebuild:!0},scaleFactor:{type:"number",precision:1,max:5,min:0,rebuild:!0},cutoff:{type:"number",precision:2,max:50,min:0,rebuild:!0},contour:{type:"boolean",rebuild:!0},background:{type:"boolean",rebuild:!0},opaqueBack:{type:"boolean",buffer:!0},filterSele:{type:"text",rebuild:!0},colorVolume:{type:"hidden"},useWorker:{type:"boolean",rebuild:!0}},this.parameters,{radius:null,scale:null}),this.__infoList=[],this.structure.signals.refreshed.add((()=>{this.__forceNewMolsurf=!0})),this.toBePrepared=!0,this.init(i)}init(e){const t=e||{};t.colorScheme=l(t.colorScheme,"uniform"),t.colorValue=l(t.colorValue,14540253),t.disablePicking=l(t.disablePicking,!0),this.surfaceType=l(t.surfaceType,"ms"),this.probeRadius=l(t.probeRadius,1.4),this.smooth=l(t.smooth,2),this.scaleFactor=l(t.scaleFactor,2),this.cutoff=l(t.cutoff,0),this.contour=l(t.contour,!1),this.background=l(t.background,!1),this.opaqueBack=l(t.opaqueBack,!0),this.filterSele=l(t.filterSele,""),this.colorVolume=l(t.colorVolume,void 0),this.useWorker=l(t.useWorker,!0),super.init(e)}prepareData(e,i,r){let s=this.__infoList[i];if(s||(s={},this.__infoList[i]=s),s.molsurf&&s.sele===e.selection.string)r(i);else{if(this.filterSele){const s=e.structure.getView(new ye(this.filterSele)),n=s.boundingBox.getSize(new t.Vector3),o=Math.max(n.x,n.y,n.z),a=e.getAtomSetWithinPoint(s.center,o/2+6);if(0===(e=e.getView(new ye(e.getAtomSetWithinSelection(a,3).toSeleString()))).atomCount)return void r(i)}s.sele=e.selection.string,s.molsurf=new kh(e);const n=this.getSurfaceParams(),o=e=>{s.surface=e,r(i)};this.useWorker?s.molsurf.getSurfaceWorker(n,o):o(s.molsurf.getSurface(n))}}prepare(e){if((this.__forceNewMolsurf||this.__sele!==this.selection.string||this.__surfaceParams!==JSON.stringify(this.getSurfaceParams()))&&(this.__infoList.forEach((e=>{e&&e.molsurf&&e.molsurf.dispose()})),this.__infoList.length=0),0===this.structureView.atomCount)return void e();const t=()=>{this.__sele=this.selection.string,this.__surfaceParams=JSON.stringify(this.getSurfaceParams()),this.__forceNewMolsurf=!1,e()},i="default"===this.assembly?this.defaultAssembly:this.assembly,r=this.structure.biomolDict[i];r?r.partList.forEach(((e,i)=>{const s=e.getView(this.structureView);this.prepareData(s,i,(e=>{e===r.partList.length-1&&t()}))})):this.prepareData(this.structureView,0,t)}createData(e,t){const i=this.__infoList[t],r=i.surface;if(!r)return;const s={position:r.getPosition(),color:r.getColor(this.getColorParams()),index:r.getFilteredIndex(this.filterSele,e)},n=[];if(r.contour){const e=new En(s,this.getBufferParams({wireframe:!1}));n.push(e)}else{Object.assign(s,{normal:r.getNormal(),picking:r.getPicking(e.getStructure())});const t=new Rn(s,this.getBufferParams({background:this.background,opaqueBack:this.opaqueBack,dullInterior:!1}));if("double"==this.getBufferParams().side){const e=new Fn(t);n.push(e)}else n.push(t)}return{bufferList:n,info:i}}updateData(e,t){const i={};if(e.position||e.radius)return this.__forceNewMolsurf=!0,void this.build();e.color&&(i.color=t.info.surface.getColor(this.getColorParams())),e.index&&(i.index=t.info.surface.getFilteredIndex(this.filterSele,t.sview)),t.bufferList[0].setAttributes(i)}setParameters(e,t={},i){return e&&e.filterSele&&(t.index=!0),e&&void 0!==e.colorVolume&&(t.color=!0),e&&e.wireframe&&(e.contour||void 0===e.contour&&this.contour)&&(e.wireframe=!1),super.setParameters(e,t,i),this}getSurfaceParams(e={}){return Object.assign({type:this.surfaceType,probeRadius:this.probeRadius,scaleFactor:this.scaleFactor,smooth:this.smooth&&!this.contour,cutoff:this.cutoff,contour:this.contour,useWorker:this.useWorker,radiusParams:this.getRadiusParams()},e)}getColorParams(){const e=super.getColorParams();return e.volume=this.colorVolume,e}getAtomRadius(){return 0}clear(){super.clear()}dispose(){this.__infoList.forEach((e=>{e&&e.molsurf&&e.molsurf.dispose()})),this.__infoList.length=0,super.dispose()}}Ne.add("surface",Mh);class Dh extends dl{constructor(e,t,i){super(e,t,i),this.type="point",this.parameters=Object.assign({pointSize:{type:"number",precision:1,max:100,min:0,buffer:!0},sizeAttenuation:{type:"boolean",buffer:!0},sortParticles:{type:"boolean",rebuild:!0},useTexture:{type:"boolean",buffer:!0},alphaTest:{type:"range",step:.001,max:1,min:0,buffer:!0},forceTransparent:{type:"boolean",buffer:!0},edgeBleach:{type:"range",step:.001,max:1,min:0,buffer:!0}},this.parameters,{flatShaded:null,wireframe:null,linewidth:null,side:null,roughness:null,metalness:null}),this.init(i)}init(e){var t=e||{};this.pointSize=l(t.pointSize,1),this.sizeAttenuation=l(t.sizeAttenuation,!0),this.sortParticles=l(t.sortParticles,!1),this.useTexture=l(t.useTexture,!1),this.alphaTest=l(t.alphaTest,.5),this.forceTransparent=l(t.forceTransparent,!1),this.edgeBleach=l(t.edgeBleach,0),super.init(t)}createData(e){var t=e.getAtomData(this.getAtomParams({position:!0,color:!0,picking:!0}));return{bufferList:[new $a(t,this.getBufferParams({pointSize:this.pointSize,sizeAttenuation:this.sizeAttenuation,sortParticles:this.sortParticles,useTexture:this.useTexture,alphaTest:this.alphaTest,forceTransparent:this.forceTransparent,edgeBleach:this.edgeBleach}))]}}updateData(e,t){var i=t.sview.getAtomData(this.getAtomParams(e)),r={};e&&!e.position||Object.assign(r,{position:i.position}),e&&!e.color||Object.assign(r,{color:i.color}),t.bufferList[0].setAttributes(r)}getAtomRadius(){return.1}}Ne.add("point",Dh),Ve.add("shader/Ribbon.vert","#define STANDARD\nuniform float clipNear;\nuniform vec3 clipCenter;\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvarying vec3 vViewPosition;\n#endif\n#if defined( RADIUS_CLIP )\nvarying vec3 vClipCenter;\n#endif\nattribute vec3 dir;\nattribute float size;\n#ifdef PICKING\n#include unpack_color\nattribute float primitiveId;\nvarying vec3 vPickingColor;\n#else\n#include color_pars_vertex\n#ifndef FLAT_SHADED\nvarying vec3 vNormal;\n#endif\n#endif\n#include common\nvoid main(void){\n#ifdef PICKING\nvPickingColor = unpackColor( primitiveId );\n#else\n#include color_vertex\n#include beginnormal_vertex\n#include defaultnormal_vertex\n#ifndef FLAT_SHADED\nvNormal = normalize( transformedNormal );\n#endif\n#endif\n#include begin_vertex\ntransformed += normalize( dir ) * size;\n#include project_vertex\n#if defined( NEAR_CLIP ) || defined( RADIUS_CLIP ) || !defined( PICKING )\nvViewPosition = -mvPosition.xyz;\n#endif\n#if defined( RADIUS_CLIP )\nvClipCenter = -( modelViewMatrix * vec4( clipCenter, 1.0 ) ).xyz;\n#endif\n#include nearclip_vertex\n}");const Th=new Uint16Array([0,1,2,1,3,2]);function Bh(e){return 3*(4*(e.position.length/3-1))}class Rh extends Bn{constructor(e,t={}){super({position:new Float32Array(Bh(e)),color:new Float32Array(Bh(e)),index:A(Bh(e),Bh(e)/3),normal:new Float32Array(Bh(e)),picking:e.picking},t),this.vertexShader="Ribbon.vert";const i=e.position.length/3-1,r=4*i,s=3*r;this.addAttributes({dir:{type:"v3",value:new Float32Array(s)}}),this.addAttributes({size:{type:"f",value:new Float32Array(r)}}),e.primitiveId=xt(i),this.setAttributes(e),this.makeIndex()}setAttributes(e={}){const t=this.size/4,i=this.geometry.attributes;let r,s,n,o,a,c,l,h,u,d,m,p,f,g,y,b,x,v,w;e.position&&(r=e.position,l=i.position.array,i.position.needsUpdate=!0),e.normal&&(s=e.normal,h=i.normal.array,i.normal.needsUpdate=!0),e.size&&(n=e.size,u=i.size.array,i.size.needsUpdate=!0),e.dir&&(o=e.dir,d=i.dir.array,i.dir.needsUpdate=!0),e.color&&(a=e.color,m=i.color.array,i.color.needsUpdate=!0),e.primitiveId&&(c=e.primitiveId,p=i.primitiveId.array,i.primitiveId.needsUpdate=!0);let A=n?n[0]:null;for(f=0;f{if(!(e.residueCount<4)){i.push(e);var r=new Xl(e,this.getSplineParams()),s=r.getSubdividedPosition(),n=r.getSubdividedOrientation(),o=r.getSubdividedColor(this.getColorParams()),a=r.getSubdividedPicking(),c=r.getSubdividedSize(this.getRadiusParams());t.push(new Rh({position:s.position,normal:n.binormal,dir:n.normal,color:o.color,size:c.size,picking:a.picking},this.getBufferParams()))}}),e.getSelection()),{bufferList:t,polymerList:i}}updateData(e,t){e=e||{};var i=0,r=t.polymerList.length;for(i=0;i{if(e.residueCount<4||e.isNucleic())return;const s=new go(e),n=s.getAxis(this.localAngle,this.centerDist,this.ssBorder,this.getColorParams(),this.getRadiusParams());t+=n.size.length,i.push(n),r.push(s)}),e.getSelection());const s={begin:new Float32Array(3*t),end:new Float32Array(3*t),size:new Float32Array(t),color:new Float32Array(3*t),picking:{}};let n=new Float32Array(t),o=0;i.forEach((function(e){s.begin.set(e.begin,3*o),s.end.set(e.end,3*o),s.size.set(e.size,o),s.color.set(e.color,3*o),n.set(e.picking.array,o),o+=e.size.length})),t&&(s.picking=new Ls(n,e.getStructure()));return{bufferList:[new Gl({position1:s.begin,position2:s.end,color:s.color,color2:s.color,radius:s.size,picking:s.picking},this.getBufferParams({openEnded:this.openEnded,radialSegments:this.radialSegments,disableImpostor:this.disableImpostor,dullInterior:!0}))],axisList:i,helixbundleList:r,axisData:s}}updateData(e,t){if((e=e||{}).position)this.build();else{var i={};if(e.color||e.radius){var r=0;t.helixbundleList.forEach((i=>{var s=i.getAxis(this.localAngle,this.centerDist,this.ssBorder,this.getColorParams(),this.getRadiusParams());e.color&&t.axisData.color.set(s.color,3*r),(e.radius||e.scale)&&t.axisData.size.set(s.size,r),r+=s.size.length})),e.color&&Object.assign(i,{color:t.axisData.color,color2:t.axisData.color}),(e.radius||e.scale)&&Object.assign(i,{radius:t.axisData.size})}t.bufferList[0].setAttributes(i)}}}Ne.add("rocket",$h);class Fh extends Jl{constructor(e,t,i){super(e,t,i),this.type="rope",this.parameters=Object.assign({smooth:{type:"integer",max:15,min:0,rebuild:!0}},this.parameters,{aspectRatio:null,smoothSheet:null})}init(e){var t=e||{};t.aspectRatio=1,t.tension=l(t.tension,.5),t.radiusScale=l(t.radiusScale,5),t.smoothSheet=!1,this.smooth=l(t.smooth,2),super.init(t)}getSpline(e){var t=new fo(e);return new Xl(e,this.getSplineParams({directional:!1,positionIterator:t.getCenterIterator(this.smooth)}))}}Ne.add("rope",Fh);class Eh extends dl{constructor(e,t,i){super(e,t,i),this.type="spacefill",this.parameters=Object.assign({sphereDetail:!0,disableImpostor:!0},this.parameters),this.init(i)}init(e){var t=e||{};t.useInteriorColor=l(t.useInteriorColor,!0),super.init(t)}createData(e){return{bufferList:[new Ta(e.getAtomData(this.getAtomParams()),this.getBufferParams({sphereDetail:this.sphereDetail,dullInterior:!0,disableImpostor:this.disableImpostor}))]}}updateData(e,t){var i=t.sview.getAtomData(this.getAtomParams(e)),r={};e&&!e.position||Object.assign(r,{position:i.position}),e&&!e.color||Object.assign(r,{color:i.color}),e&&!e.radius||Object.assign(r,{radius:i.radius}),t.bufferList[0].setAttributes(r)}}function Lh(e){return 3*(e.position.length/3-1)*2}Ne.add("spacefill",Eh);class Nh extends Tn{constructor(e,t={}){super({position:new Float32Array(Lh(e)),color:new Float32Array(Lh(e))},t),this.isLine=!0,this.vertexShader="Line.vert",this.fragmentShader="Line.frag",this.setAttributes(e)}setAttributes(e){let t,i,r,s;const n=this.geometry.attributes;if(e.position&&(t=e.position,r=n.position.array,n.position.needsUpdate=!0),e.color&&(i=e.color,s=n.color.array,n.color.needsUpdate=!0),!t&&!i)return void Be.warn("TraceBuffer.prototype.setAttributes no data");let o,a;const c=this.size-1;for(let e=0;e{if(!(e.residueCount<4)){i.push(e);var r=new Xl(e,this.getSplineParams()),s=r.getSubdividedPosition(),n=r.getSubdividedColor(this.getColorParams());t.push(new Nh(Object.assign({},s,n),this.getBufferParams()))}}),e.getSelection()),{bufferList:t,polymerList:i}}updateData(e,t){e=e||{};var i=0,r=t.polymerList.length;for(i=0;i{e.boundingBox||e.computeBoundingBox(),this.boundingBox.union(e.boundingBox)}))}}const Zh=Object.assign({aspectRatio:1.5,radialSegments:50,openEnded:!1,disableImpostor:!1},Mn);class Qh{constructor(e,i={}){this.group=new t.Group,this.wireframeGroup=new t.Group,this.pickingGroup=new t.Group,this.visible=!0,this.parameters=h(i,this.defaultParameters),this.splitPosition=new Float32Array(e.position1.length),this.cylinderRadius=new Float32Array(e.radius.length);const r=this.makeAttributes(e),s={radialSegments:this.parameters.radialSegments,openEnded:this.parameters.openEnded,disableImpostor:this.parameters.disableImpostor};this.cylinderBuffer=new Gl(r.cylinder,s),this.coneBuffer=new Yh(r.cone,s),this.geometry=new Kh([this.cylinderBuffer.geometry,this.coneBuffer.geometry]),this.matrix=l(i.matrix,new t.Matrix4),this.picking=e.picking}get defaultParameters(){return Zh}set matrix(e){Tn.prototype.setMatrix.call(this,e)}get matrix(){return this.group.matrix.clone()}get pickable(){return!!this.picking}makeAttributes(e={}){const i=this.splitPosition,r=this.cylinderRadius,s=this.parameters.aspectRatio;let n,o;const a={},c={};if(e.radius){for(n=0,o=r.length;n(this._beforeParse(),this._parse(),this._afterParse(),this[this.__objName])))}_parse(){}_beforeParse(){}_afterParse(){e.Debug&&Be.log(this[this.__objName])}}class Iu extends Pu{constructor(e,t){var i=t||{};super(e,i),this.firstModelOnly=l(i.firstModelOnly,!1),this.asTrajectory=l(i.asTrajectory,!1),this.cAlphaOnly=l(i.cAlphaOnly,!1),this.structure=new pa(this.name,this.path),this.structureBuilder=new Do(this.structure)}get type(){return"structure"}get __objName(){return"structure"}}class ku{constructor(e,t,i="",r,s=[]){this.structure=e,this.index=t,this.description=i,this.entityType=function(e){switch(e=e.toLowerCase()){case"polymer":return 1;case"non-polymer":return 2;case"macrolide":return 3;case"water":return 4;default:return 0}}(r||""),this.chainIndexList=s,s.forEach((function(i){e.chainStore.entityIndex[i]=t}))}get type(){return function(e){switch(e){case 1:return"polymer";case 2:return"non-polymer";case 3:return"macrolide";case 4:return"water";default:return}}(this.entityType)}getEntityType(){return this.entityType}isPolymer(){return 1===this.entityType}isNonPolymer(){return 2===this.entityType}isMacrolide(){return 3===this.entityType}isWater(){return 4===this.entityType}eachChain(e){const t=this.structure.getChainProxy();this.chainIndexList.forEach((function(i){t.index=i,e(t)}))}}const Mu={a:1,b:1,c:1,alpha:90,beta:90,gamma:90,spacegroup:"P 1"};class Du{constructor(e=Mu){this.cartToFrac=new t.Matrix4,this.fracToCart=new t.Matrix4,this.a=e.a,this.b=e.b,this.c=e.c,this.alpha=e.alpha,this.beta=e.beta,this.gamma=e.gamma,this.spacegroup=e.spacegroup;const i=T(this.alpha),r=T(this.beta),s=T(this.gamma),n=Math.cos(i),o=Math.cos(r),a=Math.cos(s),c=Math.sin(r),l=Math.sin(s);if(this.volume=this.a*this.b*this.c*Math.sqrt(1-n*n-o*o-a*a+2*n*o*a),void 0===e.cartToFrac){const e=this.a*this.b*l/this.volume,t=(o*a-n)/(c*l);this.fracToCart.set(this.a,0,0,0,this.b*a,this.b*l,0,0,this.c*o,-this.c*c*t,1/e,0,0,0,0,1).transpose(),this.cartToFrac.getInverse(this.fracToCart)}else this.cartToFrac.copy(e.cartToFrac),this.fracToCart.getInverse(this.cartToFrac)}getPosition(e){const i=new Float32Array(24);if(e.unitcell){const r=e.unitcell,s=e.center.clone().applyMatrix4(r.cartToFrac).floor(),n=new t.Vector3;let o=0;const a=function(e,t,a){n.set(e,t,a).add(s).applyMatrix4(r.fracToCart).toArray(i,o),o+=3};a(0,0,0),a(1,0,0),a(0,1,0),a(0,0,1),a(1,1,0),a(1,0,1),a(0,1,1),a(1,1,1)}return i}getCenter(e){return function(e,i=new t.Vector3){const r=e.length;for(let t=0;t0)continue;let e,t,r,s,n,c=0;if(o){if(s=C.split(Ou),c=10===s.length?1:0,R=s[2],f&&"CA"!==R)continue;e=parseFloat(s[6-c]),t=parseFloat(s[7-c]),r=parseFloat(s[8-c])}else{if(R=C.substr(12,4).trim(),f&&"CA"!==R)continue;e=parseFloat(C.substr(30,8)),t=parseFloat(C.substr(38,8)),r=parseFloat(C.substr(46,8))}if(p){const i=3*x;if(b[i+0]=e,b[i+1]=t,b[i+2]=r,x+=1,v)continue}o?(I=parseInt(s[1]),n="",O="H"===C[0],k=c?"":s[4],M=parseInt(s[5-c]),B="",D=s[3],F="",T=1):(I=parseInt(C.substr(6,5),u),h&&99999===I&&(u=16),O="H"===C[0],k=C[21].trim(),M=parseInt(C.substr(22,4),d),h&&9999===M&&(d=16),B=C[26].trim(),D=C.substr(17,4).trim()||"MOL",$=parseFloat(C.substr(60,6)),F=C[16].trim(),T=parseFloat(C.substr(54,6)),i||(a?(n=C.substr(76,3).trim(),n in rs&&(n=rs[n])):(n=C.substr(76,2).trim(),k||(k=C.substr(72,4).trim())),E=parseInt((C.substr(79,1)+C.substr(78,1)).trim()))),de.growIfFull(),de.atomTypeId[fe]=ue.add(R,n),de.x[fe]=e,de.y[fe]=t,de.z[fe]=r,de.serial[fe]=I,de.altloc[fe]=F.charCodeAt(0),de.occupancy[fe]=isNaN(T)?0:T,o?(de.partialCharge[fe]=parseFloat(s[9-c]),de.radius[fe]=parseFloat(s[10-c])):(de.bfactor[fe]=isNaN($)?0:$,a&&(de.partialCharge[fe]=parseFloat(C.substr(70,6))),isFinite(E)&&(de.formalCharge||de.addField("formalCharge",1,"int8"),de.formalCharge[fe]=E));const y=$u(M,k,B);!O||Z[y]||Bu.includes(D)?te||ie===k||(J+=1,ee=J.toString()):ie===k&&se===D&&(Zr.includes(D)||re===M&&ne===B)||(J+=1,ee=J.toString(),re=M,se=D,ne=B),l.addAtom(ge,k,ee,D,M,O,void 0,B),j[I]=fe,fe+=1,te=!1,ie=k}else if("CONECT"===P){const e=j[parseInt(C.substr(6,5))],t=[11,16,21,26],i={};if(void 0===e)continue;for(let r=0;r<4;++r){let s=parseInt(C.substr(t[r],5));if(!Number.isNaN(s)&&(s=j[s],void 0!==s))if(e0)continue;const D=t[l].replace(Nu,"");if(k&&"CA"!==D)continue;const R=parseFloat(t[x]),O=parseFloat(t[v]),$=parseFloat(t[w]);if(I){const e=3*r;if(i[e+0]=R,i[e+1]=O,i[e+2]=$,r+=1,X>0)continue}const F=t[h],E=parseInt(t[-1!==a?a:c]);let L=t[b];L="?"===L?"":L;const N=t[o],z=t[u],V="H"===t[p][0],Y=t[g],K=parseFloat(t[A]),Z=parseFloat(t[_]);let Q=t[m];if(Q="."===Q?"":Q,H.growIfFull(),H.atomTypeId[q]=j.add(D,Y),H.x[q]=R,H.y[q]=O,H.z[q]=$,H.serial[q]=parseInt(t[f]),H.bfactor[q]=isNaN(K)?0:K,H.occupancy[q]=isNaN(Z)?0:Z,H.altloc[q]=Q.charCodeAt(0),C.addAtom(X,N,z,F,E,V,void 0,L),e.Debug){const t=T[z];void 0!==t&&t!==N&&e.Debug&&Be.warn(t,N)}T[z]=N;const J=t[d];B[J]||(B[J]=new Set),B[J].add(S.chainStore.count-1),q+=1}else{const e=n.match(Lu),t=e.length;N===L.length&&(N=0);for(let i=0;ic*c)return n.growIfFull(),n.atomTypeId[p]=n.atomTypeId[e],n.x[p]=u.x,n.y[p]=u.y,n.z[p]=u.z,n.occupancy[p]=n.occupancy[e],n.serial[p]=p,n.altloc[p]="A".charCodeAt(0),r.addAtom(0,"","","HET",1,!0),void(p+=1)}}}))}}(D,S,C),C.finalize(),S.finalizeAtoms(),Fo(S),S.finalizeBonds();else{var Y=function(e,t,i){var r,s,n,o,a=[],c=[],l=e.struct_conf;if(null==l?void 0:l.pdbx_PDB_helix_class)for(Uu(l,"id"),r=0,s=l.beg_auth_seq_id.length;r0){o=o.split("(");var l=c(o[0]),h=c(o[1]);Object.keys(l).forEach((function(e){Object.keys(h).forEach((function(i){var r=new t.Matrix4;r.multiplyMatrices(l[e],h[i]),s[e+"x"+i]=r}))}))}else s=c(o);var u=[];for(var d in s)u.push(s[d]);var m=e;/^(0|[1-9][0-9]*)$/.test(m)&&(m="BU"+m);for(var p=a.asym_id_list[i].split(","),f=0,g=p.length;f_){var S=A;A=_,_=S;var C=f;f=v,v=C}if(0!==A&&0!==_)for(var P=0;P<_;++P)o.index=f[P%A],a.index=v[P],o&&a?i.bondStore.addBond(o,a,Wu(s.pdbx_value_order[l])):Be.log("atoms for connection not found");else e.Debug&&Be.warn("no atoms found for",p,x)}}}}(D,S,T),function(e,t,i){if(e.entity){Uu(e.entity,"id");for(var r=e.entity,s=r.id.length,n=0;nx)continue}d=I.substr(5,5).trim(),m=parseInt(I.substr(0,5)),p=parseInt(I.substr(15,5)),w.growIfFull(),w.atomTypeId[A]=v.add(u),w.x[A]=D,w.y[A]=T,w.z[A]=B,w.serial[A]=p,s.addAtom(_,"","",d,m,!1,"l"),A+=1}}}(0,e.length,e)})),s.finalize(),r.finalizeAtoms(),$o(r),Fo(r),r.finalizeBonds(),Bo(r),e.Debug&&Be.timeEnd("GroParser._parse "+this.name)}});var Xu=["mmtfVersion","mmtfProducer","unitCell","spaceGroup","structureId","title","depositionDate","releaseDate","experimentalMethods","resolution","rFree","rWork","bioAssemblyList","ncsOperatorList","entityList","groupList","numBonds","numAtoms","numGroups","numChains","numModels","groupsPerChain","chainsPerModel"].concat(["xCoordList","yCoordList","zCoordList","groupIdList","groupTypeList","chainIdList","bFactorList","atomIdList","altLocList","occupancyList","secStructList","insCodeList","sequenceIndexList","chainNameList","bondAtomList","bondOrderList"]);function Yu(e,t,i){return t?new e(t.buffer,t.byteOffset,t.byteLength/(i||1)):void 0}function Ku(e){return Yu(DataView,e)}function Zu(e){return Yu(Int8Array,e)}function Qu(e){return Yu(Int32Array,e,4)}function Ju(e,t){var i=e.length/2;t||(t=new Int16Array(i));for(var r=0,s=0;rn&&++a;t=new Int32Array(a)}for(i=0,r=0;is){for(var n=[],o=0;o0&&(a.biomolDict[e]=i)}const $=c.unitCell;$&&Array.isArray($)&&$[0]?a.unitcell=new Du({a:$[0],b:$[1],c:$[2],alpha:$[3],beta:$[4],gamma:$[5],spacegroup:c.spaceGroup}):a.unitcell=void 0,zo(a,!0),No(a,!0),a.finalizeAtoms(),a.finalizeBonds(),Vo(a),e.Debug&&Be.timeEnd("MmtfParser._parse "+this.name)}});const ud=/\s+/,dd={1:1,2:2,3:3,am:1,ar:1,du:1,un:1,nc:0};ze.add("mol2",class extends Iu{get type(){return"mol2"}_parse(){e.Debug&&Be.time("Mol2Parser._parse "+this.name);const t=this.structure,i=this.structureBuilder,r=this.firstModelOnly,s=this.asTrajectory,n=t.frames;let o,a,c=!1;const l=t.atomMap,h=t.atomStore;h.resize(Math.round(this.streamer.data.length/60)),h.addField("partialCharge",1,"float32");let u=0,d=0,m=0,p=-1,f=0,g=0;const y=t.getAtomProxy(),b=t.getAtomProxy();this.streamer.eachChunkOfLines((function(e){!function(e,x,v){for(let w=e;wMOLECULE"===e?(g=1,d=0,++p):"@ATOM"===e?(g=2,m=h.count,s&&(a=0,o=new Float32Array(3*f),n.push(o),p>0&&(c=!0))):g="@BOND"===e?3:0;else if(1===g){if(0===d)t.title=e,t.id=e;else if(1===d){const t=e.split(ud);f=parseInt(t[0])}++d}else if(2===g){const t=e.split(ud);if(r&&p>0)continue;const n=parseFloat(t[2]),d=parseFloat(t[3]),m=parseFloat(t[4]);if(s){const e=3*a;if(o[e+0]=n,o[e+1]=d,o[e+2]=m,a+=1,c)continue}const f=t[0],g=t[1],y=t[5].split(".")[0],b=t[6]?parseInt(t[6]):1,x=t[7]?t[7]:"",v=t[8]?parseFloat(t[8]):0;h.growIfFull(),h.atomTypeId[u]=l.add(g,y),h.x[u]=n,h.y[u]=d,h.z[u]=m,h.serial[u]=f,h.partialCharge[u]=v,i.addAtom(p,"","",x,b,!0),u+=1}else if(3===g){if(r&&p>0)continue;if(s&&p>0)continue;const i=e.split(ud);y.index=parseInt(i[1])-1+m,b.index=parseInt(i[2])-1+m;const n=dd[i[3]];t.bondStore.addBond(y,b,n)}}}(0,e.length,e)})),i.finalize(),t.finalizeAtoms(),$o(t),No(t,!0),zo(t,!0),t.finalizeBonds(),Ho(t),Bo(t),e.Debug&&Be.timeEnd("Mol2Parser._parse "+this.name)}});ze.add("pdbqt",class extends Fu{get type(){return"pdbqt"}});ze.add("pqr",class extends Fu{get type(){return"pqr"}});const md=/> +<(.+)>/;class pd extends Iu{get type(){return"sdf"}_parse(){e.Debug&&Be.time("SdfParser._parse "+this.name);const t=this.structure,i=this.structureBuilder,r=this.firstModelOnly,s=this.asTrajectory,n=this.streamer.peekLines(2);t.id=n[0].trim(),t.title=n[1].trim();const o=t.frames;let a,c,l=!1;const h=t.atomMap,u=t.atomStore;u.resize(Math.round(this.streamer.data.length/50)),u.addField("formalCharge",1,"int8");const d=t.getAtomProxy(),m=t.getAtomProxy();let p=0,f=0,g=0,y=0;const b=[];let x,v,w,A,_,S,C,P,I,k,M,D,T,B,R=!1,O={};t.extraData.sdf=b;let $=!1,F=!1,E=!1,L=[],N=[];const z=new Map;this.streamer.eachChunkOfLines((function(e){!function(e,n,V){for(let G=e;G-1,$?z.clear():(v=parseInt(e.substr(0,3)),w=parseInt(e.substr(3,3)),A=4,_=A+v,S=_,C=S+w,s&&(c=0,a=new Float32Array(3*v),o.push(a),g>0&&(l=!0)));else if($&&"COUNTS"===L[0])v=parseInt(L[1]),s&&(c=0,a=new Float32Array(3*v),o.push(a),g>0&&(l=!0));else if($&&2==L.length)"ATOM"===L[1]?"BEGIN"===L[0]?F=!0:"END"===L[0]&&(F=!1):"BOND"===L[1]&&("BEGIN"===L[0]?E=!0:"END"===L[0]&&(E=!1));else if(F||!$&&f>=A&&f<_){if(r&&g>0)continue;let t=0;if($){if(P=parseFloat(L[2]),I=parseFloat(L[3]),k=parseFloat(L[4]),D=L[1],T=parseInt(L[0]),z.set(T,p),M=D+T,L.length>6){let e=L.slice(6).find((e=>0===e.indexOf("CHG=")));e&&(t=parseInt(e.substring(4)))}}else P=parseFloat(e.substr(0,10)),I=parseFloat(e.substr(10,10)),k=parseFloat(e.substr(20,10)),D=e.substr(31,3).trim(),M=D+(p-y+1);if(s){const e=3*c;if(a[e+0]=P,a[e+1]=I,a[e+2]=k,c+=1,l)continue}u.growIfFull(),u.atomTypeId[p]=h.add(M,D),u.x[p]=P,u.y[p]=I,u.z[p]=k,u.serial[p]=$?T:p,u.formalCharge[p]=t,i.addAtom(g,"","","HET",1,!0),p+=1}else if(E||!$&&f>=S&&f0)continue;if(s&&g>0)continue;$?(d.index=z.get(parseInt(L[2])),m.index=z.get(parseInt(L[3])),B=parseInt(L[1])):(d.index=parseInt(e.substr(0,3))-1+y,m.index=parseInt(e.substr(3,3))-1+y,B=parseInt(e.substr(6,3))),t.bondStore.addBond(d,m,B)}else if("M CHG"===e.substr(0,6)){const t=parseInt(e.substr(6,3));for(let i=0,r=10;i"===e.charAt(0)&&(x=e.match(md))?(R=x[1],O[R]=[]):!1!==R&&e&&O[R].push(e);++f}}}(0,e.length,e)})),i.finalize(),t.finalizeAtoms(),t.finalizeBonds(),Ho(t),e.Debug&&Be.timeEnd("SdfParser._parse "+this.name)}_postProcess(){Ho(this.structure)}}ze.add("sdf",pd),ze.add("sd",pd),ze.add("mol",pd);function fd(e,t,i){return parseInt(e.substr(t,i).trim())}class gd extends Iu{get type(){return"prmtop"}_parse(){e.Debug&&Be.time("PrmtopParser._parse "+this.name);const t=this.structure,i=this.structureBuilder,r=t.atomMap,s=t.atomStore;s.addField("partialCharge",1,"float32"),s.addField("radius",1,"float32");const n=[],o={},a=["NATOM","NTYPES","NBONH","MBONA","NTHETH","MTHETA","NPHIH","MPHIA","NHPARM","NPARM","NNB","NRES","NBONA","NTHETA","NPHIA","NUMBND","NUMANG","NPTRA","NATYP","NPHB","IFPERT","NBPER","NGPER","NDPER","MBPER","MGPER","MDPER","IFBOX","NMXRS","IFCAP","NUMEXTRA","NCOPY"];let c,l,h,u,d;a.forEach((e=>{o[e]=0}));let m,p,f,g,y,b=new Uint8Array(0);this.streamer.eachChunkOfLines((function(e){!function(e,t,i){for(let r=e;r0)return void Be.error("dcd format with fixed atoms unsupported, aborting");const f=o.NATOM,g=4*f;for(let e=0,r=o.NSET;e=1&&(r.timeOffset=(o.ISTART-1)*r.deltaTime),e.Debug&&Be.timeEnd("DcdParser._parse "+this.name)}});const Cd={BYTE:1,CHAR:2,SHORT:3,INT:4,FLOAT:5,DOUBLE:6};function Pd(e){switch(Number(e)){case Cd.BYTE:return"byte";case Cd.CHAR:return"char";case Cd.SHORT:return"short";case Cd.INT:return"int";case Cd.FLOAT:return"float";case Cd.DOUBLE:return"double";default:return"undefined"}}function Id(e){switch(Number(e)){case Cd.BYTE:case Cd.CHAR:return 1;case Cd.SHORT:return 2;case Cd.INT:case Cd.FLOAT:return 4;case Cd.DOUBLE:return 8;default:return-1}}function kd(e){switch(String(e)){case"byte":return Cd.BYTE;case"char":return Cd.CHAR;case"short":return Cd.SHORT;case"int":return Cd.INT;case"float":return Cd.FLOAT;case"double":return Cd.DOUBLE;default:return-1}}function Md(e,t){if(1!==e){const i=new Array(e);for(let r=0;r6,"non valid type "+h);const u=e.readUint32();let d=e.readUint32();2===i&&(Ad(d>0,"offsets larger than 4GB not supported"),d=e.readUint32()),c[0]===t&&(n+=u),s[r]={name:o,dimensions:c,attributes:l,type:Pd(h),size:u,offset:d,record:c[0]===t}}}return{variables:s,recordStep:n}}(e,r.recordId,t);return i.variables=s.variables,i.recordDimension.recordStep=s.recordStep,i}function Fd(e){let t;const i=e.readUint32();if(i===Td)return Ad(e.readUint32()!==Td,"wrong empty tag for list of attributes"),[];{Ad(i!==Od,"wrong tag for list of attributes");const r=e.readUint32();t=new Array(r);for(let i=0;i6,"non valid type "+s);const n=e.readUint32(),o=Dd(e,s,n);_d(e),t[i]={name:r,type:Pd(s),value:o}}}return t}class Ed{constructor(e){const t=new st(e);t.setBigEndian(),Ad("CDF"!==t.readChars(3),"should start with CDF");const i=t.readByte();Ad(i>2,"unknown version"),this.header=$d(t,i),this.buffer=t}get version(){return 1===this.header.version?"classic format":"64-bit offset format"}get recordDimension(){return this.header.recordDimension}get dimensions(){return this.header.dimensions}get globalAttributes(){return this.header.globalAttributes}get variables(){return this.header.variables}hasDataVariable(e){return-1!==this.header.variables.findIndex((function(t){return t.name===e}))}getDataVariable(e){let t;return t="string"==typeof e?this.header.variables.find((function(t){return t.name===e})):e,Ad(void 0===t,"variable not found"),this.buffer.seek(t.offset),t.record?function(e,t,i){const r=kd(t.type),s=t.size?t.size/Id(r):1,n=i.length,o=new Array(n),a=i.recordStep;for(let t=0;t=1&&(i.timeOffset=n[0]),n.length>=2&&(i.deltaTime=n[1]-n[0]),e.Debug&&Be.timeEnd("NctrajParser._parse "+this.name)}}ze.add("nctraj",Ld),ze.add("ncdf",Ld),ze.add("nc",Ld);ze.add("trr",class extends wd{get type(){return"trr"}get isBinary(){return!0}_parse(){e.Debug&&Be.time("TrrParser._parse "+this.name);const t=_(this.streamer.data),i=new DataView(t),r=this.frames,s=r.coordinates,n=r.boxes,o=r.times;let a=0;for(;;){a+=8;const e=i.getInt32(a);a+=4,a+=e;const r=i.getInt32(a+8),c=i.getInt32(a+12),l=i.getInt32(a+16),h=i.getInt32(a+28),u=i.getInt32(a+32),d=i.getInt32(a+36),m=i.getInt32(a+40);a+=52;const p=r/9,f=3*m;if(8===p?o.push(i.getFloat64(a)):o.push(i.getFloat32(a)),a+=2*p,r){const e=new Float32Array(9);if(8===p)for(let t=0;t<9;++t)e[t]=10*i.getFloat64(a),a+=8;else for(let t=0;t<9;++t)e[t]=10*i.getFloat32(a),a+=4;n.push(e)}if(a+=c,a+=l,h){let e;if(8===p){e=new Float32Array(f);for(let t=0;t>8&65280|t>>24&255}e=new Float32Array(t,a,f);for(let t=0;t=t.byteLength)break}o.length>=1&&(r.timeOffset=o[0]),o.length>=2&&(r.deltaTime=o[1]-o[0]),e.Debug&&Be.timeEnd("TrrParser._parse "+this.name)}});const Nd=new Uint32Array([0,0,0,0,0,0,0,0,0,8,10,12,16,20,25,32,40,50,64,80,101,128,161,203,256,322,406,512,645,812,1024,1290,1625,2048,2580,3250,4096,5060,6501,8192,10321,13003,16384,20642,26007,32768,41285,52015,65536,82570,104031,131072,165140,208063,262144,330280,416127,524287,660561,832255,1048576,1321122,1664510,2097152,2642245,3329021,4194304,5284491,6658042,8388607,10568983,13316085,16777216]);function zd(e){let t=1,i=0;for(;e>=t&&i<32;)i++,t<<=1;return i}const Vd=new Uint8Array(32);function Gd(e,t){let i=1,r=0;Vd[0]=1;for(let r=0;r>=8;for(;0!==s;)Vd[e++]=255&s,s>>=8;i=e}let s=1;for(i--;Vd[i]>=s;)r++,s*=2;return r+8*i}function Ud(e,t,i,r){const s=(1<=8;)o=o<<8|t[a++],c|=o>>n<0&&(n>n&(1<8;)jd[a++]=Ud(e,t,8,o),r-=8;r>0&&(jd[a++]=Ud(e,t,r,o));for(let e=i-1;e>0;e--){let t=0;for(let i=a-1;i>=0;i--){t=t<<8|jd[i];const r=t/s[e]|0;jd[i]=r,t-=r*s[e]}n[e]=t}n[0]=jd[0]|jd[1]<<8|jd[2]<<16|jd[3]<<24}ze.add("xtc",class extends wd{get type(){return"xtc"}get isBinary(){return!0}_parse(){e.Debug&&Be.time("XtcParser._parse "+this.name);const t=_(this.streamer.data),i=new DataView(t),r=this.frames,s=r.coordinates,n=r.boxes,o=r.times,a=new Int32Array(6),c=new Int32Array(3),l=new Int32Array(3),h=new Uint32Array(3),u=new Float32Array(3),d=new Float32Array(3);let m=0;const p=new Int32Array(3),f=new Uint32Array(p.buffer);for(;;){let e;const r=i.getInt32(m+4);m+=12;const g=3*r;o.push(i.getFloat32(m)),m+=4;const y=new Float32Array(9);for(let e=0;e<9;++e)y[e]=10*i.getFloat32(m),m+=4;if(n.push(y),r<=9){e=new Float32Array(r);for(let t=0;t16777215?(l[0]=zd(c[0]),l[1]=zd(c[1]),l[2]=zd(c[2]),o=0):o=Gd(3,c);let y=i.getInt32(m);m+=4;let b=y-1;b=9>b?9:b;let x=Nd[b]/2|0,v=Nd[y]/2|0;h[0]=h[1]=h[2]=Nd[y];let w=4*Math.ceil(i.getInt32(m)/4);m+=4;const A=1/n;let _=0,S=0;const C=new Uint8Array(t,m);for(u[0]=u[1]=u[2]=0;S0){u[0]=u[1]=u[2]=0;for(let t=0;t<_;t+=3){if(Hd(p,C,3,y,h,u,f),S++,u[0]+=d[0]-v,u[1]+=d[1]-v,u[2]+=d[2]-v,0===t){let t=u[0];u[0]=d[0],d[0]=t,t=u[1],u[1]=d[1],d[1]=t,t=u[2],u[2]=d[2],d[2]=t,e[r++]=d[0]*A,e[r++]=d[1]*A,e[r++]=d[2]*A}else d[0]=u[0],d[1]=u[1],d[2]=u[2];e[r++]=u[0]*A,e[r++]=u[1]*A,e[r++]=u[2]*A}}else e[r++]=u[0]*A,e[r++]=u[1]*A,e[r++]=u[2]*A;if(y+=t,t<0?(v=x,x=y>9?Nd[y-1]/2|0:0):t>0&&(x=v,v=Nd[y]/2|0),h[0]=h[1]=h[2]=Nd[y],0===h[0]||0===h[1]||0===h[2])return void console.error("(xdrfile error) Undefined error.")}m+=w}for(let t=0;t=t.byteLength)break}o.length>=1&&(r.timeOffset=o[0]),o.length>=2&&(r.deltaTime=o[1]-o[0]),e.Debug&&Be.timeEnd("XtcParser._parse "+this.name)}});class Wd extends Pu{constructor(e,t){const i=t||{};super(e,i),this.volume=new Cn(this.name,this.path),this.voxelSize=l(i.voxelSize,1)}get type(){return"volume"}get __objName(){return"volume"}_afterParse(){this.volume.setMatrix(this.getMatrix()),super._afterParse()}getMatrix(){return new t.Matrix4}}const qd=/\s+/,Xd=/-?\d+(?:\.\d*)?(?:[eE][+-]?\d+)?/g,Yd=.529177210859;class Kd extends Wd{get type(){return"cube"}_parse(){e.Debug&&Be.time("CubeParser._parse "+this.name);const i=this.volume,r=this.streamer.peekLines(6),s={},n=Yd*this.voxelSize;function o(e,t){var i=r[e].trim().split(qd)[t];return parseFloat(i)}s.atomCount=Math.abs(o(2,0)),s.originX=o(2,1)*Yd,s.originY=o(2,2)*Yd,s.originZ=o(2,3)*Yd,s.NVX=o(3,0),s.NVY=o(4,0),s.NVZ=o(5,0),s.basisX=new t.Vector3(o(3,1),o(3,2),o(3,3)).multiplyScalar(n),s.basisY=new t.Vector3(o(4,1),o(4,2),o(4,3)).multiplyScalar(n),s.basisZ=new t.Vector3(o(5,1),o(5,2),o(5,3)).multiplyScalar(n);const a=new Float32Array(s.NVX*s.NVY*s.NVZ);let c=0,l=0;const h=o(2,0)>0?0:1;this.streamer.eachChunkOfLines((function(e){!function(e,t,i){for(let r=e;r=s.atomCount+6+h){const t=e.match(Xd);for(let e=0,i=t.length;e>8&255}i.xStart=o[0],i.yStart=o[1],i.zStart=o[2],i.xExtent=o[3],i.yExtent=o[4],i.zExtent=o[5],i.xRate=o[6],i.yRate=o[7],i.zRate=o[8];const e=1/o[17],t=e*this.voxelSize;i.xlen=o[9]*t,i.ylen=o[10]*t,i.zlen=o[11]*t,i.alpha=o[12]*e,i.beta=o[13]*e,i.gamma=o[14]*e,r=o[15]/100,s=o[16],i.gamma=o[14]*e}t.header=i,e.Debug&&Be.log(i,r,s);const l=new Float32Array(i.xExtent*i.yExtent*i.zExtent);let h=512;const u=Math.ceil(i.xExtent/8),d=Math.ceil(i.yExtent/8),m=Math.ceil(i.zExtent/8);for(var p=0;pn){const e=i[r].trim();if(""!==e){const t=e.split(Qd);for(let e=0,i=t.length;e=n&&(f-n)%m!=0&&p=0?i-1:i+t/3)},parseNormalIndex:function(e,t){var i=parseInt(e,10);return 3*(i>=0?i-1:i+t/3)},addVertex:function(e,t,i){var r=this.vertices,s=this.object.geometry.vertices;s.push(r[e+0]),s.push(r[e+1]),s.push(r[e+2]),s.push(r[t+0]),s.push(r[t+1]),s.push(r[t+2]),s.push(r[i+0]),s.push(r[i+1]),s.push(r[i+2])},addVertexLine:function(e){var t=this.vertices,i=this.object.geometry.vertices;i.push(t[e+0]),i.push(t[e+1]),i.push(t[e+2])},addNormal:function(e,t,i){var r=this.normals,s=this.object.geometry.normals;s.push(r[e+0]),s.push(r[e+1]),s.push(r[e+2]),s.push(r[t+0]),s.push(r[t+1]),s.push(r[t+2]),s.push(r[i+0]),s.push(r[i+1]),s.push(r[i+2])},addFace:function(e,t,i,r,s,n,o,a){var c,l=this.vertices.length,h=this.parseVertexIndex(e,l),u=this.parseVertexIndex(t,l),d=this.parseVertexIndex(i,l);if(void 0===r?this.addVertex(h,u,d):(c=this.parseVertexIndex(r,l),this.addVertex(h,u,c),this.addVertex(u,d,c)),void 0!==s){var m=this.normals.length;h=this.parseNormalIndex(s,m),u=s===n?h:this.parseNormalIndex(n,m),d=s===o?h:this.parseNormalIndex(o,m),void 0===r?this.addNormal(h,u,d):(c=this.parseNormalIndex(a,m),this.addNormal(h,u,c),this.addNormal(u,d,c))}},addLineGeometry:function(e){this.object.geometry.type="Line";for(var t=this.vertices.length,i=0,r=e.length;i0?v.setAttribute("normal",new t.BufferAttribute(new Float32Array(x.normals),3)):v.computeVertexNormals(),b.push(v)}}return b}};ze.add("obj",class extends gm{get type(){return"obj"}getLoader(){return new ym}});const bm=function(){this.propertyNameMapping={}};bm.prototype={constructor:bm,setPropertyNameMapping:function(e){this.propertyNameMapping=e},bin2str:function(e){for(var t=new Uint8Array(e),i="",r=0;r=s.elements[a].count&&(a++,c=0);var u=this.parseASCIIElement(s.elements[a].properties,h);this.handleElement(r,s.elements[a].name,u),c++}}return this.postProcess(r)},postProcess:function(e){if(e.useColor){for(var t=0;t{const s=r.length;for(let n=0;n/g,""),{declaration:t(),root:i()};function t(){if(!s(/^<\?xml\s*/))return;const e={attributes:{}};for(;!n()&&!o("?>");){const t=r();if(!t)return e;e.attributes[t.name]=t.value}return s(/\?>\s*/),e}function i(){const e=s(wm);if(!e)return;const t={name:e[1],attributes:{},children:[]};for(;!(n()||o(">")||o("?>")||o("/>"));){const e=r();if(!e)return t;t.attributes[e.name]=e.value}if(s(/^\s*\/>\s*/))return t;let a;for(s(/\??>\s*/),t.content=function(){const e=s(Am);return e?e[1]:""}();a=i();)t.children.push(a);return s(/^<\/[\w-:.]+>\s*/),t}function r(){const e=s(_m);var t;if(e)return{name:e[1],value:(t=e[2],t.replace(vm,""))}}function s(t){const i=e.match(t);if(i)return e=e.slice(i[0].length),i}function n(){return 0===e.length}function o(t){return 0===e.indexOf(t)}}class Cm extends Pu{constructor(e,t){const i=t||{};super(e,i),this.useDomParser=l(i.useDomParser,!1),this.xml={name:this.name,path:this.path,data:{}}}get type(){return"xml"}get __objName(){return"xml"}get isXml(){return!0}__xmlParser(e){return Sm(e)}__domParser(e){return(new window.DOMParser).parseFromString(e,"text/xml")}_parse(){e.Debug&&Be.time("XmlParser._parse "+this.name),this.useDomParser?this.streamer.data instanceof Document?this.xml.data=this.streamer.data:this.xml.data=this.__domParser(this.streamer.asText()):this.xml.data=this.__xmlParser(this.streamer.asText()),e.Debug&&Be.timeEnd("XmlParser._parse "+this.name)}}function Pm(e,t){const i=e.getNamedItem(t);return null!==i?i.value:""}function Im(e,t,i=!1){const r=Pm(e,"icode").trim(),s=Pm(e,"chain").trim(),n=Pm(e,"altcode");let o=Pm(e,"resnum");return r&&(o+="^"+r),s&&(o+=":"+s),t&&(o+="."+t),i&&n.trim()&&(o+="%"+n),o+="/"+(parseInt(Pm(e,"model"))-1),o}function km(e){const t=Pm(e,"chain").trim();let i=`[${Pm(e,"rescode")}]${Pm(e,"resnum")}`;return t&&(i+=`:${t}`),i}function Mm(e,t,i){void 0===e[t]?e[t]=i:e[t]|=i}function Dm(e,t){return null!==e&&e.value===t}function Tm(e,t,i){let r=0;const s=t.getElementsByTagName("clash");for(let t=0,i=s.length;t0&&(r+=1);t.getElementsByTagName("bond-outlier").length>0&&(r+=1);return t.getElementsByTagName("plane-outlier").length>0&&(r+=1),Dm(i.getNamedItem("rota"),"OUTLIER")&&(r+=1),Dm(i.getNamedItem("rama"),"OUTLIER")&&(r+=1),Dm(i.getNamedItem("RNApucker"),"outlier")&&(r+=1),r}ze.add("xml",Cm);class Bm{constructor(e,t){this.name=e,this.path=t,this.rsrzDict={},this.rsccDict={},this.rciDict={},this.clashDict={},this.clashArray=[],this.geoDict={},this.geoAtomDict={},this.atomDict={},this.clashSele="NONE"}get type(){return"validation"}fromXml(t){e.Debug&&Be.time("Validation.fromXml");const i=this.rsrzDict,r=this.rsccDict,s=this.rciDict,n=this.clashDict,o=this.clashArray,a=this.geoDict,c=this.geoAtomDict,l=this.atomDict,h=t.getElementsByTagName("Entry");if(1===h.length){const e=h[0].getElementsByTagName("chemical_shift_list");if(1===e.length){const t=e[0].getElementsByTagName("random_coil_index");for(let e=0,i=t.length;e0&&(a[r]=e)}else{const e=t.getElementsByTagName("clash"),i=t.getElementsByTagName("mog-bond-outlier"),s=t.getElementsByTagName("mog-angle-outlier");if(i.length>0||s.length>0||e.length>0){const t={};c[r]=t;for(let i=0,r=e.length;i>>16&65535|0,o=0;0!==i;){i-=o=i>2e3?2e3:i;do{n=n+(s=s+t[r++]|0)|0}while(--o);s%=65521,n%=65521}return s|n<<16|0}ze.add("validation",class extends Cm{constructor(e,t){super(e,t||{}),this.useDomParser=!0,this.validation=new Bm(this.name,this.path)}get __objName(){return"validation"}get isXml(){return!0}_parse(){super._parse(),e.Debug&&Be.time("ValidationParser._parse "+this.name),this.validation.fromXml(this.xml.data),e.Debug&&Be.timeEnd("ValidationParser._parse "+this.name)}});var Fm=function(){for(var e,t=[],i=0;i<256;i++){e=i;for(var r=0;r<8;r++)e=1&e?3988292384^e>>>1:e>>>1;t[i]=e}return t}();function Em(e,t,i,r){var s=Fm,n=r+i;e^=-1;for(var o=r;o>>8^s[255&(e^t[o])];return-1^e}var Lm=30,Nm=12;function zm(e,t){var i,r,s,n,o,a,c,l,h,u,d,m,p,f,g,y,b,x,v,w,A,_,S,C,P;i=e.state,r=e.next_in,C=e.input,s=r+(e.avail_in-5),n=e.next_out,P=e.output,o=n-(t-e.avail_out),a=n+(e.avail_out-257),c=i.dmax,l=i.wsize,h=i.whave,u=i.wnext,d=i.window,m=i.hold,p=i.bits,f=i.lencode,g=i.distcode,y=(1<>>=v=x>>>24,p-=v,0===(v=x>>>16&255))P[n++]=65535&x;else{if(!(16&v)){if(0==(64&v)){x=f[(65535&x)+(m&(1<>>=v,p-=v),p<15&&(m+=C[r++]<>>=v=x>>>24,p-=v,!(16&(v=x>>>16&255))){if(0==(64&v)){x=g[(65535&x)+(m&(1<c){e.msg="invalid distance too far back",i.mode=Lm;break e}if(m>>>=v,p-=v,A>(v=n-o)){if((v=A-v)>h&&i.sane){e.msg="invalid distance too far back",i.mode=Lm;break e}if(_=0,S=d,0===u){if(_+=l-v,v2;)P[n++]=S[_++],P[n++]=S[_++],P[n++]=S[_++],w-=3;w&&(P[n++]=S[_++],w>1&&(P[n++]=S[_++]))}else{_=n-A;do{P[n++]=P[_++],P[n++]=P[_++],P[n++]=P[_++],w-=3}while(w>2);w&&(P[n++]=P[_++],w>1&&(P[n++]=P[_++]))}break}}break}}while(r>3,m&=(1<<(p-=w<<3))-1,e.next_in=r,e.next_out=n,e.avail_in=r=1&&0===D[w];w--);if(A>w&&(A=w),0===w)return s[n++]=20971520,s[n++]=20971520,a.bits=1,0;for(v=1;v0&&(e===jm||1!==w))return-1;for(T[1]=0,b=1;bGm||e===Wm&&P>Um)return 1;for(;;){p=b-S,o[x]m?(f=B[R+o[x]],g=k[M+o[x]]):(f=96,g=0),c=1<>S)+(l-=c)]=p<<24|f<<16|g|0}while(0!==l);for(c=1<>=1;if(0!==c?(I&=c-1,I+=c):I=0,x++,0==--D[b]){if(b===w)break;b=t[i+o[x]]}if(b>A&&(I&u)!==h){for(0===S&&(S=A),d+=v,C=1<<(_=b-S);_+SGm||e===Wm&&P>Um)return 1;s[h=I&u]=A<<24|_<<16|d-n|0}}return 0!==I&&(s[d+I]=b-S<<24|64<<16|0),a.bits=A,0}var Qm=1,Jm=2,ep=0,tp=-2,ip=1,rp=12,sp=30,np=852,op=592;function ap(e){return(e>>>24&255)+(e>>>8&65280)+((65280&e)<<8)+((255&e)<<24)}function cp(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function lp(e){var t;return e&&e.state?((t=e.state).wsize=0,t.whave=0,t.wnext=0,function(e){var t;return e&&e.state?(t=e.state,e.total_in=e.total_out=t.total=0,e.msg="",t.wrap&&(e.adler=1&t.wrap),t.mode=ip,t.last=0,t.havedict=0,t.dmax=32768,t.head=null,t.hold=0,t.bits=0,t.lencode=t.lendyn=new Int32Array(np),t.distcode=t.distdyn=new Int32Array(op),t.sane=1,t.back=-1,ep):tp}(e)):tp}function hp(e,t){var i,r;return e?(r=new cp,e.state=r,r.window=null,i=function(e,t){var i,r;return e&&e.state?(r=e.state,t<0?(i=0,t=-t):(i=1+(t>>4),t<48&&(t&=15)),t&&(t<8||t>15)?tp:(null!==r.window&&r.wbits!==t&&(r.window=null),r.wrap=i,r.wbits=t,lp(e))):tp}(e,t),i!==ep&&(e.state=null),i):tp}var up,dp,mp=!0;function pp(e){if(mp){var t;for(up=new Int32Array(512),dp=new Int32Array(32),t=0;t<144;)e.lens[t++]=8;for(;t<256;)e.lens[t++]=9;for(;t<280;)e.lens[t++]=7;for(;t<288;)e.lens[t++]=8;for(Zm(Qm,e.lens,0,288,up,0,e.work,{bits:9}),t=0;t<32;)e.lens[t++]=5;Zm(Jm,e.lens,0,32,dp,0,e.work,{bits:5}),mp=!1}e.lencode=up,e.lenbits=9,e.distcode=dp,e.distbits=5}function fp(e,t,i,r){var s,n=e.state;return null===n.window&&(n.wsize=1<=n.wsize?(Om(n.window,t,i-n.wsize,n.wsize,0),n.wnext=0,n.whave=n.wsize):((s=n.wsize-n.wnext)>r&&(s=r),Om(n.window,t,i-r,s,n.wnext),(r-=s)?(Om(n.window,t,i-r,r,0),n.wnext=r,n.whave=n.wsize):(n.wnext+=s,n.wnext===n.wsize&&(n.wnext=0),n.whave>>8&255,i.check=Em(i.check,I,2,0),l=0,h=0,i.mode=2;break}if(i.flags=0,i.head&&(i.head.done=!1),!(1&i.wrap)||(((255&l)<<8)+(l>>8))%31){e.msg="incorrect header check",i.mode=sp;break}if(8!=(15&l)){e.msg="unknown compression method",i.mode=sp;break}if(h-=4,A=8+(15&(l>>>=4)),0===i.wbits)i.wbits=A;else if(A>i.wbits){e.msg="invalid window size",i.mode=sp;break}i.dmax=1<>8&1),512&i.flags&&(I[0]=255&l,I[1]=l>>>8&255,i.check=Em(i.check,I,2,0)),l=0,h=0,i.mode=3;case 3:for(;h<32;){if(0===a)break e;a--,l+=r[n++]<>>8&255,I[2]=l>>>16&255,I[3]=l>>>24&255,i.check=Em(i.check,I,4,0)),l=0,h=0,i.mode=4;case 4:for(;h<16;){if(0===a)break e;a--,l+=r[n++]<>8),512&i.flags&&(I[0]=255&l,I[1]=l>>>8&255,i.check=Em(i.check,I,2,0)),l=0,h=0,i.mode=5;case 5:if(1024&i.flags){for(;h<16;){if(0===a)break e;a--,l+=r[n++]<>>8&255,i.check=Em(i.check,I,2,0)),l=0,h=0}else i.head&&(i.head.extra=null);i.mode=6;case 6:if(1024&i.flags&&((m=i.length)>a&&(m=a),m&&(i.head&&(A=i.head.extra_len-i.length,i.head.extra||(i.head.extra=new Array(i.head.extra_len)),Om(i.head.extra,r,n,m,A)),512&i.flags&&(i.check=Em(i.check,r,m,n)),a-=m,n+=m,i.length-=m),i.length))break e;i.length=0,i.mode=7;case 7:if(2048&i.flags){if(0===a)break e;m=0;do{A=r[n+m++],i.head&&A&&i.length<65536&&(i.head.name+=String.fromCharCode(A))}while(A&&m>9&1,i.head.done=!0),e.adler=i.check=0,i.mode=rp;break;case 10:for(;h<32;){if(0===a)break e;a--,l+=r[n++]<>>=7&h,h-=7&h,i.mode=27;break}for(;h<3;){if(0===a)break e;a--,l+=r[n++]<>>=1)){case 0:i.mode=14;break;case 1:if(pp(i),i.mode=20,6===t){l>>>=2,h-=2;break e}break;case 2:i.mode=17;break;case 3:e.msg="invalid block type",i.mode=sp}l>>>=2,h-=2;break;case 14:for(l>>>=7&h,h-=7&h;h<32;){if(0===a)break e;a--,l+=r[n++]<>>16^65535)){e.msg="invalid stored block lengths",i.mode=sp;break}if(i.length=65535&l,l=0,h=0,i.mode=15,6===t)break e;case 15:i.mode=16;case 16:if(m=i.length){if(m>a&&(m=a),m>c&&(m=c),0===m)break e;Om(s,r,n,m,o),a-=m,n+=m,c-=m,o+=m,i.length-=m;break}i.mode=rp;break;case 17:for(;h<14;){if(0===a)break e;a--,l+=r[n++]<>>=5,h-=5,i.ndist=1+(31&l),l>>>=5,h-=5,i.ncode=4+(15&l),l>>>=4,h-=4,i.nlen>286||i.ndist>30){e.msg="too many length or distance symbols",i.mode=sp;break}i.have=0,i.mode=18;case 18:for(;i.have>>=3,h-=3}for(;i.have<19;)i.lens[k[i.have++]]=0;if(i.lencode=i.lendyn,i.lenbits=7,S={bits:i.lenbits},_=Zm(0,i.lens,0,19,i.lencode,0,i.work,S),i.lenbits=S.bits,_){e.msg="invalid code lengths set",i.mode=sp;break}i.have=0,i.mode=19;case 19:for(;i.have>>16&255,b=65535&P,!((g=P>>>24)<=h);){if(0===a)break e;a--,l+=r[n++]<>>=g,h-=g,i.lens[i.have++]=b;else{if(16===b){for(C=g+2;h>>=g,h-=g,0===i.have){e.msg="invalid bit length repeat",i.mode=sp;break}A=i.lens[i.have-1],m=3+(3&l),l>>>=2,h-=2}else if(17===b){for(C=g+3;h>>=g)),l>>>=3,h-=3}else{for(C=g+7;h>>=g)),l>>>=7,h-=7}if(i.have+m>i.nlen+i.ndist){e.msg="invalid bit length repeat",i.mode=sp;break}for(;m--;)i.lens[i.have++]=A}}if(i.mode===sp)break;if(0===i.lens[256]){e.msg="invalid code -- missing end-of-block",i.mode=sp;break}if(i.lenbits=9,S={bits:i.lenbits},_=Zm(Qm,i.lens,0,i.nlen,i.lencode,0,i.work,S),i.lenbits=S.bits,_){e.msg="invalid literal/lengths set",i.mode=sp;break}if(i.distbits=6,i.distcode=i.distdyn,S={bits:i.distbits},_=Zm(Jm,i.lens,i.nlen,i.ndist,i.distcode,0,i.work,S),i.distbits=S.bits,_){e.msg="invalid distances set",i.mode=sp;break}if(i.mode=20,6===t)break e;case 20:i.mode=21;case 21:if(a>=6&&c>=258){e.next_out=o,e.avail_out=c,e.next_in=n,e.avail_in=a,i.hold=l,i.bits=h,zm(e,d),o=e.next_out,s=e.output,c=e.avail_out,n=e.next_in,r=e.input,a=e.avail_in,l=i.hold,h=i.bits,i.mode===rp&&(i.back=-1);break}for(i.back=0;y=(P=i.lencode[l&(1<>>16&255,b=65535&P,!((g=P>>>24)<=h);){if(0===a)break e;a--,l+=r[n++]<>x)])>>>16&255,b=65535&P,!(x+(g=P>>>24)<=h);){if(0===a)break e;a--,l+=r[n++]<>>=x,h-=x,i.back+=x}if(l>>>=g,h-=g,i.back+=g,i.length=b,0===y){i.mode=26;break}if(32&y){i.back=-1,i.mode=rp;break}if(64&y){e.msg="invalid literal/length code",i.mode=sp;break}i.extra=15&y,i.mode=22;case 22:if(i.extra){for(C=i.extra;h>>=i.extra,h-=i.extra,i.back+=i.extra}i.was=i.length,i.mode=23;case 23:for(;y=(P=i.distcode[l&(1<>>16&255,b=65535&P,!((g=P>>>24)<=h);){if(0===a)break e;a--,l+=r[n++]<>x)])>>>16&255,b=65535&P,!(x+(g=P>>>24)<=h);){if(0===a)break e;a--,l+=r[n++]<>>=x,h-=x,i.back+=x}if(l>>>=g,h-=g,i.back+=g,64&y){e.msg="invalid distance code",i.mode=sp;break}i.offset=b,i.extra=15&y,i.mode=24;case 24:if(i.extra){for(C=i.extra;h>>=i.extra,h-=i.extra,i.back+=i.extra}if(i.offset>i.dmax){e.msg="invalid distance too far back",i.mode=sp;break}i.mode=25;case 25:if(0===c)break e;if(m=d-c,i.offset>m){if((m=i.offset-m)>i.whave&&i.sane){e.msg="invalid distance too far back",i.mode=sp;break}m>i.wnext?(m-=i.wnext,p=i.wsize-m):p=i.wnext-m,m>i.length&&(m=i.length),f=i.window}else f=s,p=o-i.offset,m=i.length;m>c&&(m=c),c-=m,i.length-=m;do{s[o++]=f[p++]}while(--m);0===i.length&&(i.mode=21);break;case 26:if(0===c)break e;s[o++]=i.length,c--,i.mode=21;break;case 27:if(i.wrap){for(;h<32;){if(0===a)break e;a--,l|=r[n++]<=252?6:wp>=248?5:wp>=240?4:wp>=224?3:wp>=192?2:1;function Ap(e){var t,i,r,s,n,o=e.length,a=0;for(s=0;s>>6,t[n++]=128|63&i):i<65536?(t[n++]=224|i>>>12,t[n++]=128|i>>>6&63,t[n++]=128|63&i):(t[n++]=240|i>>>18,t[n++]=128|i>>>12&63,t[n++]=128|i>>>6&63,t[n++]=128|63&i);return t}function _p(e,t){var i,r,s,n,o=t||e.length,a=new Array(2*o);for(r=0,i=0;i4)a[r++]=65533,i+=n-1;else{for(s&=2===n?31:3===n?15:7;n>1&&i1?a[r++]=65533:s<65536?a[r++]=s:(s-=65536,a[r++]=55296|s>>10&1023,a[r++]=56320|1023&s)}return function(e,t){if(t<65537&&(e.subarray&&xp||!e.subarray&&bp))return String.fromCharCode.apply(null,Rm(e,t));for(var i="",r=0;re.length&&(t=e.length),i=t-1;i>=0&&128==(192&e[i]);)i--;return i<0||0===i?t:i+vp[e[i]]>t?i:t}vp[254]=vp[254]=1;var Cp=0,Pp={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"};function Ip(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}function kp(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1}var Mp=Object.prototype.toString;function Dp(e){if(!(this instanceof Dp))return new Dp(e);this.options=function(e){for(var t=Array.prototype.slice.call(arguments,1);t.length;){var i=t.shift();if(i){if("object"!=typeof i)throw new TypeError(i+"must be non-object");for(var r in i)i.hasOwnProperty(r)&&(e[r]=i[r])}}return e}({chunkSize:16384,windowBits:0,to:""},e||{});var t=this.options;t.raw&&t.windowBits>=0&&t.windowBits<16&&(t.windowBits=-t.windowBits,0===t.windowBits&&(t.windowBits=-15)),!(t.windowBits>=0&&t.windowBits<16)||e&&e.windowBits||(t.windowBits+=32),t.windowBits>15&&t.windowBits<48&&0==(15&t.windowBits)&&(t.windowBits|=15),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Ip,this.strm.avail_out=0;var i,r,s,n=hp(this.strm,t.windowBits);if(n!==Cp)throw new Error(Pp[n]);this.header=new kp,i=this.strm,r=this.header,i&&i.state&&(0==(2&(s=i.state).wrap)||(s.head=r,r.done=!1))}Dp.prototype.push=function(e,t){var i,r,s,n,o,a,c=this.strm,l=this.options.chunkSize,h=this.options.dictionary,u=!1;if(this.ended)return!1;r=t===~~t?t:!0===t?4:0,"string"==typeof e?c.input=function(e){for(var t=new Uint8Array(e.length),i=0,r=t.length;i0||0===c.avail_out)&&1!==i);return 1===i&&(r=4),4===r?(i=function(e){if(!e||!e.state)return tp;var t=e.state;return t.window&&(t.window=null),e.state=null,ep}(this.strm),this.onEnd(i),this.ended=!0,i===Cp):2!==r||(this.onEnd(Cp),c.avail_out=0,!0)},Dp.prototype.onData=function(e){this.chunks.push(e)},Dp.prototype.onEnd=function(e){e===Cp&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=function(e){var t,i,r,s,n,o;for(r=0,t=0,i=e.length;tObject.assign(Object.assign({},e),{[t]:t})),{})}}const Hp={backgroundColor:{type:"color"},quality:jp("auto","low","medium","high"),sampleLevel:Up(1,5,-1),impostor:{type:"boolean"},workerDefault:{type:"boolean"},rotateSpeed:Gp(1,10,0),zoomSpeed:Gp(1,10,0),panSpeed:Gp(1,10,0),clipNear:Up(1,100,0),clipFar:Up(1,100,0),clipDist:Vp(200,0),clipMode:jp("scene","camera"),clipScale:jp("relative","absolute"),fogNear:Up(1,100,0),fogFar:Up(1,100,0),cameraType:jp("perspective","orthographic","stereo"),cameraEyeSep:Gp(3,1,.01),cameraFov:Up(1,120,15),lightColor:{type:"color"},lightIntensity:Gp(2,10,0),ambientColor:{type:"color"},ambientIntensity:Gp(2,10,0),hoverTimeout:Vp(1e4,-1),tooltip:{type:"boolean"},mousePreset:jp(...Object.keys(zn))};Object.defineProperty(e,"Box3",{enumerable:!0,get:function(){return t.Box3}}),Object.defineProperty(e,"Color",{enumerable:!0,get:function(){return t.Color}}),Object.defineProperty(e,"Euler",{enumerable:!0,get:function(){return t.Euler}}),Object.defineProperty(e,"Matrix3",{enumerable:!0,get:function(){return t.Matrix3}}),Object.defineProperty(e,"Matrix4",{enumerable:!0,get:function(){return t.Matrix4}}),Object.defineProperty(e,"Plane",{enumerable:!0,get:function(){return t.Plane}}),Object.defineProperty(e,"Quaternion",{enumerable:!0,get:function(){return t.Quaternion}}),Object.defineProperty(e,"Vector2",{enumerable:!0,get:function(){return t.Vector2}}),Object.defineProperty(e,"Vector3",{enumerable:!0,get:function(){return t.Vector3}}),Object.defineProperty(e,"Signal",{enumerable:!0,get:function(){return r.Signal}}),e.AngleRepresentation=kl,e.ArrowBuffer=Qh,e.Assembly=ko,e.AxesRepresentation=Ul,e.BackboneRepresentation=Hl,e.BallAndStickRepresentation=jl,e.BaseRepresentation=Wl,e.BoxBuffer=ru,e.BufferRepresentation=xa,e.CartoonRepresentation=Jl,e.Collection=Ja,e.Colormaker=U,e.ColormakerRegistry=Ee,e.Component=Qa,e.ComponentCollection=Ac,e.ConeBuffer=Yh,e.ContactRepresentation=eh,e.Counter=nt,e.CylinderBuffer=Gl,e.DatasourceRegistry=Le,e.DecompressorRegistry=Ge,e.DihedralHistogramRepresentation=sh,e.DihedralRepresentation=th,e.DistanceRepresentation=oh,e.EllipsoidBuffer=lu,e.Frames=rc,e.HelixorientRepresentation=hh,e.HyperballRepresentation=xh,e.Kdtree=_o,e.KeyActions=Un,e.LabelRepresentation=wh,e.LeftMouseButton=1,e.LicoriceRepresentation=uh,e.LineRepresentation=_h,e.MdsrvDatasource=class extends Tp{constructor(e=""){super(),this.baseUrl=e}getListing(e=""){let t=`${this.baseUrl}dir/${e}`;return"/"!==t[t.length-1]&&(t+="/"),tt(t,{ext:"json"}).then((t=>({path:e,data:t.data})))}getUrl(e){const t=Je(e);return`${this.baseUrl}file/${t.path}${t.query}`}getCountUrl(e){const t=Je(e);return`${this.baseUrl}traj/numframes/${t.path}${t.query}`}getFrameUrl(e,t){const i=Je(e);return`${this.baseUrl}traj/frame/${t}/${i.path}${i.query}`}getFrameParams(e,t){return`atomIndices=${t.join(";")}`}getPathUrl(e,t){const i=Je(e);return`${this.baseUrl}traj/path/${t}/${i.path}${i.query}`}getExt(e){return Je(e).ext}},e.MeasurementDefaultParams=Re,e.MeshBuffer=Bn,e.MiddleMouseButton=2,e.MolecularSurface=kh,e.MolecularSurfaceRepresentation=Mh,e.MouseActions=Nn,e.OctahedronBuffer=pu,e.ParserRegistry=ze,e.PdbWriter=class extends it{constructor(e,t){super(),this.mimeType="text/plain",this.defaultName="structure",this.defaultExt="pdb";const i=Object.assign({},t);this.renumberSerial=l(i.renumberSerial,!0),this.remarks=function(e){return Array.isArray(e)?e:[e]}(l(i.remarks,[])),this.structure=e,this._records=[]}_writeRecords(){this._records.length=0,this._writeTitle(),this._writeRemarks(),this._writeAtoms()}_writeTitle(){this._records.push(s.sprintf("TITLE %-74s",this.structure.name))}_writeRemarks(){this.remarks.forEach((e=>{this._records.push(s.sprintf("REMARK %-73s",e))})),this.structure.trajectory&&(this._records.push(s.sprintf("REMARK %-73s","Trajectory '"+this.structure.trajectory.name+"'")),this._records.push(s.sprintf("REMARK %-73s",`Frame ${this.structure.trajectory.frame}`)))}_writeAtoms(){let e=1,t=1,i=" ",r=" ";const n=this.structure.modelStore.count>1;this.structure.eachModel((o=>{n&&this._records.push(s.sprintf("MODEL %4d%-66s",t++,"")),o.eachAtom((t=>{const n=t.hetero?"HETATM%5d %-4s %3s %1s%4d %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%1s%1s":"ATOM %5d %-4s %3s %1s%4d %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%1s%1s",o=this.renumberSerial?e:t.serial;let a=t.atomname;(1===a.length||a.length<4&&1===t.element.length&&a[0]===t.element)&&(a=" "+a),t.formalCharge?(i=Math.abs(t.formalCharge).toPrecision(1),r=t.formalCharge>0?"+":"-"):(i=" ",r=" "),this._records.push(s.sprintf(n,o,a,t.resname,l(t.chainname," "),t.resno,t.x,t.y,t.z,l(t.occupancy,1),l(t.bfactor,0),"",l(t.element,""),i,r)),e+=1}),this.structure.getSelection()),n&&this._records.push(s.sprintf("%-80s","ENDMDL"))})),this._records.push(s.sprintf("%-80s","END"))}getString(){return console.warn("PdbWriter.getString() is deprecated, use .getData instead"),this.getData()}getData(){return this._writeRecords(),this._records.join("\n")}},e.PickingProxy=ci,e.PointBuffer=$a,e.PointRepresentation=Dh,e.Queue=Mi,e.RepresentationCollection=ec,e.RepresentationElement=Xa,e.RepresentationRegistry=Ne,e.RibbonRepresentation=Oh,e.RightMouseButton=3,e.RocketRepresentation=$h,e.RopeRepresentation=Fh,e.ScriptExtensions=$e,e.SdfWriter=class extends it{constructor(e){super(),this.mimeType="text/plain",this.defaultName="structure",this.defaultExt="sdf",this.structure=e,this._records=[]}get idString(){return this.structure.id}get titleString(){return" "+this.structure.title}get countsString(){return s.sprintf("%3i%3i 0 0 0 0 0 0 0 0999 V2000",this.structure.atomCount,this.structure.bondCount)}get chargeLines(){const e=[];this.structure.eachAtom((t=>{null!=t.formalCharge&&0!==t.formalCharge&&e.push([t.index,t.formalCharge])}));const t=[];for(let i=0;i{this._records.push(this.formatAtom(e))})),this.structure.eachBond((e=>{this._records.push(this.formatBond(e))})),this.chargeLines.forEach((e=>{this._records.push(e)})),this._records.push("M END")}_writeFooter(){this._records.push("$$$$")}getData(){return this._writeRecords(),this._records.join("\n")}},e.Selection=ye,e.Shape=ba,e.ShapeComponent=Pc,e.SpacefillRepresentation=Eh,e.SpatialHash=vr,e.SphereBuffer=Ta,e.Stage=class{constructor(e,t={}){this.signals={parametersChanged:new r.Signal,fullscreenChanged:new r.Signal,componentAdded:new r.Signal,componentRemoved:new r.Signal,clicked:new r.Signal,hovered:new r.Signal},this.tasks=new nt,this.compList=[],this.defaultFileParams={},this.logList=[],this.viewer=new Wt(e),this.viewer.renderer&&(this.tooltip=document.createElement("div"),Object.assign(this.tooltip.style,{display:"none",position:"fixed",zIndex:"1000000",pointerEvents:"none",backgroundColor:"rgba( 0, 0, 0, 0.6 )",color:"lightgrey",padding:"8px",fontFamily:"sans-serif"}),this.viewer.container.appendChild(this.tooltip),this.mouseObserver=new Xt(this.viewer.renderer.domElement),this.viewerControls=new bi(this),this.trackballControls=new oi(this),this.pickingControls=new li(this),this.animationControls=new ki(this),this.mouseControls=new Gn(this),this.keyControls=new Hn(this),this.pickingBehavior=new Wn(this),this.mouseBehavior=new qn(this),this.animationBehavior=new Xn(this),this.keyBehavior=new Kn(this),this.spinAnimation=this.animationControls.spin([0,1,0],.005),this.spinAnimation.pause(!0),this.rockAnimation=this.animationControls.rock([0,1,0],.005),this.rockAnimation.pause(!0),this.parameters=h(t,Cc),this.setParameters(this.parameters),this.viewer.animate())}setParameters(e={}){u(this.parameters,e);const t=e,i=this.parameters,r=this.viewer,s=this.trackballControls;return void 0!==t.quality&&this.setQuality(i.quality),void 0!==t.impostor&&this.setImpostor(i.impostor),void 0!==t.rotateSpeed&&(s.rotateSpeed=i.rotateSpeed),void 0!==t.zoomSpeed&&(s.zoomSpeed=i.zoomSpeed),void 0!==t.panSpeed&&(s.panSpeed=i.panSpeed),void 0!==t.mousePreset&&this.mouseControls.preset(i.mousePreset),this.mouseObserver.setParameters({hoverTimeout:i.hoverTimeout}),r.setClip(i.clipNear,i.clipFar,i.clipDist,i.clipMode,i.clipScale),r.setFog(void 0,i.fogNear,i.fogFar),r.setCamera(i.cameraType,i.cameraFov,i.cameraEyeSep),r.setSampling(i.sampleLevel),r.setBackground(i.backgroundColor),r.setLight(i.lightColor,i.lightIntensity,i.ambientColor,i.ambientIntensity),this.signals.parametersChanged.dispatch(this.getParameters()),this}log(e){console.log("STAGE LOG",e),this.logList.push(e)}getParameters(){return Object.assign({},this.parameters)}defaultFileRepresentation(t){if(t instanceof xc){let i,r,s;t.setSelection("/0");const n=t.structure;if(n.biomolDict.BU1){const e=n.biomolDict.BU1;i=e.getAtomCount(n),r=e.getResidueCount(n),s=e.getInstanceCount(),t.setDefaultAssembly("BU1")}else i=n.getModelProxy(0).atomCount,r=n.getModelProxy(0).residueCount,s=1;let o=i;Ie&&(o*=4);const a=n.atomStore.count/n.residueStore.count<2;a&&(o*=10);let c="chainname",l="RdYlBu",h=!1;if(1===n.getChainnameCount(new ye("polymer and /0"))&&(c="residueindex",l="Spectral",h=!0),e.Debug&&console.log(o,i,s,a),r/s<4)t.addRepresentation("ball+stick",{colorScheme:"element",radiusScale:2,aspectRatio:1.5,bondScale:.3,bondSpacing:.75,quality:"auto"});else if(s>5&&o>15e3||o>7e5){let e=Math.min(2,Math.max(.1,6e3/(o/s)));a&&(e=Math.min(e,.5)),t.addRepresentation("surface",{colorScheme:c,colorScale:l,colorReverse:h,sele:"polymer",surfaceType:"av",probeRadius:1.4,scaleFactor:e,useWorker:!1})}else o>25e4?t.addRepresentation("backbone",{colorScheme:c,colorScale:l,colorReverse:h,lineOnly:!0}):o>1e5?t.addRepresentation("backbone",{colorScheme:c,colorScale:l,colorReverse:h,quality:"low",disableImpostor:!0,radiusScale:2}):o>8e4?t.addRepresentation("backbone",{colorScheme:c,colorScale:l,colorReverse:h,radiusScale:2}):(t.addRepresentation("cartoon",{colorScheme:c,colorScale:l,colorReverse:h,radiusScale:.7,aspectRatio:5,quality:"auto"}),o<5e4&&t.addRepresentation("base",{colorScheme:c,colorScale:l,colorReverse:h,quality:"auto"}),t.addRepresentation("ball+stick",{sele:"ligand",colorScheme:"element",radiusScale:2,aspectRatio:1.5,bondScale:.3,bondSpacing:.75,quality:"auto"}));t.structure.frames.length&&t.addTrajectory()}else(t instanceof vc||t instanceof wc)&&t.addRepresentation("surface");this.tasks.onZeroOnce(this.autoView,this)}loadFile(e,t={}){const i=Object.assign({},this.defaultFileParams,t),r=Je(e).name;this.tasks.increment(),this.log(`loading file '${r}'`);const s=l(i.ext,Je(e).ext);let n;return n=ze.isTrajectory(s)?Promise.reject(new Error(`loadFile: ext '${s}' is a trajectory and must be loaded into a structure component`)):tt(e,i),n.then((e=>{this.log(`loaded '${r}'`);const t=this.addComponentFromObject(e,i);return i.defaultRepresentation&&this.defaultFileRepresentation(t),this.tasks.decrement(),t}),(e=>{this.tasks.decrement();const t=`error loading file: '${e}'`;throw this.log(t),t}))}loadScript(e){const t=Je(e).name;return this.log(`loading script '${t}'`),tt(e).then((e=>{this.tasks.increment(),this.log(`running script '${t}'`),e.run(this).then((()=>{this.tasks.decrement(),this.log(`finished script '${t}'`)})),this.log(`called script '${t}'`)}),(e=>{this.tasks.decrement();const i=`errored script '${t}' "${e}"`;throw this.log(i),i}))}addComponent(e){e?(this.compList.push(e),this.signals.componentAdded.dispatch(e)):Be.warn("Stage.addComponent: no component given")}addComponentFromObject(e,t={}){const i=Ue.get(e.type);if(i){const r=new i(this,e,t);return this.addComponent(r),r}Be.warn("no component for object type",e.type)}removeComponent(e){const t=this.compList.indexOf(e);-1!==t&&(this.compList.splice(t,1),e.dispose(),this.signals.componentRemoved.dispatch(e))}removeAllComponents(){this.compList.slice().forEach((e=>this.removeComponent(e)))}handleResize(){this.viewer.handleResize()}setSize(e,t){const i=this.viewer.container;i!==document.body&&(void 0!==e&&(i.style.width=e),void 0!==t&&(i.style.height=t),this.handleResize())}toggleFullscreen(e){if(!(document.fullscreenEnabled||document.mozFullScreenEnabled||document.webkitFullscreenEnabled||document.msFullscreenEnabled))return void Be.log("fullscreen mode (currently) not possible");const t=this;function i(){return document.fullscreenElement||document.mozFullScreenElement||document.webkitFullscreenElement||document.msFullscreenElement}function r(){if(!i()&&t.lastFullscreenElement){const e=t.lastFullscreenElement;e.style.width=e.dataset.normalWidth||"",e.style.height=e.dataset.normalHeight||"",document.removeEventListener("fullscreenchange",r),document.removeEventListener("mozfullscreenchange",r),document.removeEventListener("webkitfullscreenchange",r),document.removeEventListener("MSFullscreenChange",r),t.handleResize(),t.signals.fullscreenChanged.dispatch(!1)}}e=e||this.viewer.container,this.lastFullscreenElement=e,i()?document.exitFullscreen?document.exitFullscreen():document.msExitFullscreen?document.msExitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitExitFullscreen&&document.webkitExitFullscreen():(e.dataset.normalWidth=e.style.width||"",e.dataset.normalHeight=e.style.height||"",e.style.width=window.screen.width+"px",e.style.height=window.screen.height+"px",e.requestFullscreen?e.requestFullscreen():e.msRequestFullscreen?e.msRequestFullscreen():e.mozRequestFullScreen?e.mozRequestFullScreen():e.webkitRequestFullscreen&&e.webkitRequestFullscreen(),document.addEventListener("fullscreenchange",r),document.addEventListener("mozfullscreenchange",r),document.addEventListener("webkitfullscreenchange",r),document.addEventListener("MSFullscreenChange",r),this.handleResize(),this.signals.fullscreenChanged.dispatch(!0),setTimeout((function(){t.handleResize()}),100))}setSpin(e){e?(this.spinAnimation.resume(!0),this.rockAnimation.pause(!0)):this.spinAnimation.pause(!0)}setRock(e){e?(this.rockAnimation.resume(!0),this.spinAnimation.pause(!0)):this.rockAnimation.pause(!0)}toggleSpin(){this.setSpin(this.spinAnimation.paused)}toggleRock(){this.setRock(this.rockAnimation.paused)}getFocus(){const e=this.parameters;if("scene"!==e.clipMode)return 0;let t=e.clipNear;return"absolute"===e.clipScale&&(t=this.viewer.absoluteToRelative(t)),2*t}setFocus(e){if("scene"!==this.parameters.clipMode)return;let t,i,r,s;"relative"===this.parameters.clipScale?(t=$(e/2,0,49.9),i=100-t,r=50,s=function(e){return $(e,0,100)}(2*i-50)):(t=this.viewer.relativeToAbsolute(e/2),i=t,r=0,s=2*i),this.setParameters({clipNear:t,clipFar:i,fogNear:r,fogFar:s})}getZoomForBox(e){const t=e.getSize(Sc),i=Math.max(t.x,t.y,t.z),r=Math.min(t.x,t.y,t.z);let s=i+Math.sqrt(r);const n=T(this.viewer.perspectiveCamera.fov),o=this.viewer.width,a=this.viewer.height,c=a{this.tasks.onZeroOnce((()=>{this.tasks.increment(),this.viewer.makeImage(e).then((e=>{this.tasks.decrement(),t(e)})).catch((e=>{this.tasks.decrement(),i(e)}))}))}))}setImpostor(e){this.parameters.impostor=e;const t=["spacefill","ball+stick","licorice","hyperball","backbone","rocket","helixorient","contact","distance","dot"];this.eachRepresentation((function(i){if(!t.includes(i.getType()))return;const r=i.getParameters();r.disableImpostor=!e,i.build(r)}))}setQuality(e){this.parameters.quality=e;const t=["tube","cartoon","ribbon","trace","rope"],i=["spacefill","ball+stick","licorice","hyperball","backbone","rocket","helixorient","contact","distance","dot"];this.eachRepresentation((function(r){const s=r.getParameters();if(!t.includes(r.getType())){if(!i.includes(r.getType()))return;if(!s.disableImpostor)return void(r.repr.quality=e)}s.quality=e,r.build(s)}))}eachComponent(e,t){this.compList.slice().forEach((i=>{void 0!==t&&t!==i.type||e(i)}))}eachRepresentation(e,t){this.eachComponent((i=>{i.reprList.slice().forEach((r=>{void 0!==t&&t!==r.getType()||e(r,i)}))}))}getComponentsByName(e){const t=[];return this.eachComponent((i=>{(void 0===e||_c(e,i))&&t.push(i)})),new Ac(t)}getComponentsByObject(e){const t=[];return this.eachComponent((i=>{i.object===e&&t.push(i)})),new Ac(t)}getRepresentationsByName(e){const t=[];return this.eachRepresentation(((i,r)=>{(void 0===e||_c(e,i))&&t.push(i)})),new ec(t)}measureClear(){this.eachComponent((e=>e.measureClear()),"structure")}measureUpdate(){this.eachComponent((e=>e.measureUpdate()),"structure")}dispose(){this.tasks.dispose(),this.viewer.dispose(),this.mouseObserver.dispose()}},e.StaticDatasource=class extends Tp{constructor(e=""){super(),this.baseUrl=e}getUrl(e){const t=Je(e);let i=this.baseUrl+t.path;return zp.test(this.baseUrl)||(i=function(e){const t=window.location,i=t.pathname,r=i.substring(0,i.lastIndexOf("/")+1);return t.origin+r+e}(i)),i}getExt(e){return Je(e).ext}},e.StlWriter=class extends it{constructor(e){super(),this.mimeType="application/vnd.ms-pki.stl",this.defaultName="surface",this.defaultExt="stl",this.surface=e}getData(){const e=this.surface.index.length/3,i=new st(2*e+3*e*4*4+80+4);i.skip(80),i.writeUint32(e);const r=new t.Vector3,s=new t.Vector3,n=new t.Vector3,o=new t.Vector3;for(let t=0;t{e.eachAtom((e=>{n.growIfFull(),n.atomTypeId[c]=o.add(e.atomname,e.element),n.x[c]=e.x,n.y[c]=e.y,n.z[c]=e.z,n.serial[c]=e.serial,n.formalCharge[c]=e.formalCharge,n.partialCharge[c]=e.partialCharge,n.altloc[c]=e.altloc,n.occupancy[c]=e.occupancy,n.bfactor[c]=e.bfactor,s.addAtom(e.modelIndex+h,e.chainname,e.chainid,e.resname,e.resno,1===e.hetero,e.sstruc,e.inscode),a[e.index+l]=c,c+=1})),l+=e.atomStore.count,h+=e.modelStore.count}));const u=r.bondStore,d=r.getAtomProxy(),m=r.getAtomProxy();return l=0,i.forEach((e=>{e.eachBond((e=>{d.index=a[e.atomIndex1+l],m.index=a[e.atomIndex2+l],u.addBond(d,m,e.bondOrder)})),l+=e.atomStore.count})),s.finalize(),zo(r,!0),No(r,!0),r.finalizeAtoms(),r.finalizeBonds(),Ho(r),e.Debug&&Be.timeEnd("concatStructures"),r},e.download=f,e.flatten=function e(t,i){i=l(i,[]);for(let r=0;rt?(o&&(clearTimeout(o),o=null),a=l,n=e.apply(r,s),o||(r=s=null)):o||!1===i.trailing||(o=setTimeout(c,h)),n}},e.uniqueArray=x,Object.defineProperty(e,"__esModule",{value:!0})})); //# sourceMappingURL=ngl.umd.js.map diff --git a/dist/ngl.umd.js.map b/dist/ngl.umd.js.map index 99f111b0..0d8e60c8 100644 --- a/dist/ngl.umd.js.map +++ b/dist/ngl.umd.js.map @@ -1 +1 @@ -{"version":3,"file":"ngl.umd.js","sources":["../src/utils.ts","../src/utils/registry.ts","../src/math/math-utils.ts","../src/color/colormaker.ts","../src/selection/selection-constants.ts","../src/selection/selection-test.ts","../src/selection/selection.ts","../src/selection/selection-parser.ts","../src/color/selection-colormaker.ts","../src/color/colormaker-registry.ts","../src/worker/worker-utils.ts","../src/globals.ts","../src/worker/worker-registry.ts","../src/parser/parser-registry.ts","../src/streamer/streamer.ts","../src/streamer/file-streamer.ts","../src/streamer/network-streamer.ts","../src/loader/loader.ts","../src/loader/parser-loader.ts","../src/script.ts","../src/loader/script-loader.ts","../src/loader/loader-utils.ts","../src/writer/writer.ts","../src/utils/io-buffer.ts","../src/utils/counter.ts","../src/viewer/stats.ts","../src/shader/shader-utils.ts","../src/viewer/viewer-constants.ts","../src/viewer/tiled-renderer.ts","../src/math/math-constants.ts","../src/math/array-utils.ts","../src/viewer/viewer-utils.ts","../src/viewer/gl-utils.ts","../src/viewer/viewer.ts","../src/stage/mouse-observer.ts","../src/constants.ts","../src/controls/trackball-controls.ts","../src/controls/picking-proxy.ts","../src/controls/picking-controls.ts","../src/controls/viewer-controls.ts","../src/animation/animation.ts","../src/controls/animation-controls.ts","../src/utils/queue.ts","../src/representation/representation.ts","../src/worker/worker.ts","../src/worker/worker-pool.ts","../src/math/vector-utils.ts","../src/geometry/dash.ts","../src/geometry/primitive.ts","../src/geometry/spatial-hash.ts","../src/store/store.ts","../src/store/contact-store.ts","../src/utils/bitarray.ts","../src/utils/adjacency-list.ts","../src/chemistry/interactions/features.ts","../src/structure/structure-constants.ts","../src/chemistry/geometry.ts","../src/chemistry/valence-model.ts","../src/structure/data.ts","../src/chemistry/functional-groups.ts","../src/chemistry/interactions/charged.ts","../src/chemistry/interactions/hydrogen-bonds.ts","../src/chemistry/interactions/metal-binding.ts","../src/chemistry/interactions/halogen-bonds.ts","../src/chemistry/interactions/refine-contacts.ts","../src/chemistry/interactions/contact.ts","../src/chemistry/interactions/hydrophobic.ts","../src/utils/picker.ts","../src/surface/marching-cubes.ts","../src/math/matrix-utils.ts","../src/surface/surface-utils.ts","../src/surface/surface.ts","../src/surface/volume.ts","../src/buffer/buffer.ts","../src/buffer/mesh-buffer.ts","../src/buffer/surface-buffer.ts","../src/buffer/doublesided-buffer.ts","../src/buffer/contour-buffer.ts","../src/representation/surface-representation.ts","../src/controls/mouse-actions.ts","../src/controls/mouse-controls.ts","../src/controls/key-actions.ts","../src/controls/key-controls.ts","../src/stage/picking-behavior.ts","../src/stage/mouse-behavior.ts","../src/stage/animation-behavior.ts","../src/stage/key-behavior.ts","../src/component/annotation.ts","../src/controls/component-controls.ts","../src/utils/radius-factory.ts","../src/math/principal-axes.ts","../src/surface/filtered-volume.ts","../src/store/bond-hash.ts","../src/store/bond-store.ts","../src/store/atom-store.ts","../src/store/residue-store.ts","../src/store/chain-store.ts","../src/store/model-store.ts","../src/geometry/helixorient.ts","../src/geometry/helixbundle.ts","../src/utils/binary-heap.ts","../src/utils/kdtree.ts","../src/proxy/atom-proxy.ts","../src/geometry/kdtree.ts","../src/symmetry/symmetry-constants.ts","../src/symmetry/symmetry-utils.ts","../src/symmetry/assembly.ts","../src/structure/structure-builder.ts","../src/structure/structure-utils.ts","../src/store/atom-type.ts","../src/store/atom-map.ts","../src/store/residue-type.ts","../src/store/residue-map.ts","../src/proxy/bond-proxy.ts","../src/proxy/residue-proxy.ts","../src/proxy/polymer.ts","../src/proxy/chain-proxy.ts","../src/proxy/model-proxy.ts","../src/structure/structure.ts","../src/geometry/shape.ts","../src/representation/buffer-representation.ts","../src/buffer/geometry-buffer.ts","../src/buffer/spheregeometry-buffer.ts","../src/buffer/mapped-buffer.ts","../src/buffer/mappedquad-buffer.ts","../src/buffer/sphereimpostor-buffer.ts","../src/buffer/sphere-buffer.ts","../src/buffer/point-buffer.ts","../src/representation/dot-representation.ts","../src/buffer/image-buffer.ts","../src/surface/volume-slice.ts","../src/representation/slice-representation.ts","../src/representation/representation-utils.ts","../src/component/element.ts","../src/component/representation-element.ts","../src/component/component.ts","../src/component/collection.ts","../src/component/representation-collection.ts","../src/component/trajectory-element.ts","../src/trajectory/frames.ts","../src/align/superposition.ts","../src/trajectory/trajectory-player.ts","../src/trajectory/trajectory.ts","../src/trajectory/frames-trajectory.ts","../src/trajectory/structure-trajectory.ts","../src/trajectory/remote-trajectory.ts","../src/trajectory/callback-trajectory.ts","../src/structure/structure-view.ts","../src/align/alignment.ts","../src/align/align-utils.ts","../src/component/structure-component.ts","../src/trajectory/trajectory-utils.ts","../src/component/surface-component.ts","../src/component/volume-component.ts","../src/component/component-collection.ts","../src/stage/stage.ts","../src/component/shape-component.ts","../node_modules/tslib/tslib.es6.js","../src/color/atomindex-colormaker.ts","../src/color/bfactor-colormaker.ts","../src/color/chainid-colormaker.ts","../src/color/chainindex-colormaker.ts","../src/color/chainname-colormaker.ts","../src/color/densityfit-colormaker.ts","../src/color/electrostatic-colormaker.ts","../src/color/element-colormaker.ts","../src/color/entityindex-colormaker.ts","../src/color/entitytype-colormaker.ts","../src/color/geoquality-colormaker.ts","../src/color/hydrophobicity-colormaker.ts","../src/color/modelindex-colormaker.ts","../src/color/moleculetype-colormaker.ts","../src/color/occupancy-colormaker.ts","../src/color/partialcharge-colormaker.ts","../src/color/random-colormaker.ts","../src/color/randomcoilindex-colormaker.ts","../src/color/residueindex-colormaker.ts","../src/color/resname-colormaker.ts","../src/color/sstruc-colormaker.ts","../src/color/structuredata-colormaker.ts","../src/color/uniform-colormaker.ts","../src/color/value-colormaker.ts","../src/color/volume-colormaker.ts","../src/representation/structure-representation.ts","../src/representation/measurement-representation.ts","../src/utils/edt.ts","../src/buffer/text-buffer.ts","../src/buffer/wideline-buffer.ts","../src/representation/angle-representation.ts","../src/buffer/cylindergeometry-buffer.ts","../src/buffer/mappedalignedbox-buffer.ts","../src/buffer/cylinderimpostor-buffer.ts","../src/buffer/cylinder-buffer.ts","../src/representation/axes-representation.ts","../src/representation/ballandstick-representation.ts","../src/representation/backbone-representation.ts","../src/representation/base-representation.ts","../src/geometry/spline.ts","../src/buffer/tubemesh-buffer.ts","../src/representation/cartoon-representation.ts","../src/representation/contact-representation.ts","../src/representation/dihedral-representation.ts","../src/representation/dihedral-histogram-representation.ts","../src/representation/distance-representation.ts","../src/buffer/vector-buffer.ts","../src/representation/helixorient-representation.ts","../src/representation/licorice-representation.ts","../src/buffer/mappedbox-buffer.ts","../src/buffer/hyperballstickimpostor-buffer.ts","../src/buffer/hyperballstick-buffer.ts","../src/representation/hyperball-representation.ts","../src/utils/label-factory.ts","../src/representation/label-representation.ts","../src/representation/line-representation.ts","../src/geometry/grid.ts","../src/surface/edt-surface.ts","../src/surface/av-surface.ts","../src/surface/molecular-surface.ts","../src/representation/molecularsurface-representation.ts","../src/representation/point-representation.ts","../src/buffer/ribbon-buffer.ts","../src/representation/ribbon-representation.ts","../src/representation/rocket-representation.ts","../src/representation/rope-representation.ts","../src/representation/spacefill-representation.ts","../src/buffer/trace-buffer.ts","../src/representation/trace-representation.ts","../src/representation/tube-representation.ts","../src/representation/unitcell-representation.ts","../src/representation/validation-representation.ts","../src/buffer/cone-buffer.ts","../src/viewer/geometry-group.ts","../src/buffer/arrow-buffer.ts","../src/buffer/box-buffer.ts","../src/buffer/ellipsoid-buffer.ts","../src/buffer/octahedron-buffer.ts","../src/buffer/tetrahedron-buffer.ts","../src/buffer/torus-buffer.ts","../src/parser/parser.ts","../src/parser/structure-parser.ts","../src/structure/entity.ts","../src/symmetry/unitcell.ts","../src/parser/pdb-parser.ts","../src/parser/cif-parser.ts","../src/parser/gro-parser.ts","../lib/mmtf.es6.js","../src/parser/mmtf-parser.ts","../src/parser/mol2-parser.ts","../src/parser/pdbqt-parser.ts","../src/parser/pqr-parser.ts","../src/parser/sdf-parser.ts","../src/parser/prmtop-parser.ts","../src/parser/psf-parser.ts","../src/parser/top-parser.ts","../src/parser/trajectory-parser.ts","../src/utils/netcdf-reader.ts","../src/parser/dcd-parser.ts","../src/parser/nctraj-parser.ts","../src/parser/trr-parser.ts","../src/parser/xtc-parser.ts","../src/parser/volume-parser.ts","../src/parser/cube-parser.ts","../src/parser/dsn6-parser.ts","../src/parser/dx-parser.ts","../src/parser/dxbin-parser.ts","../src/parser/mrc-parser.ts","../src/parser/xplor-parser.ts","../src/parser/kin-parser.ts","../src/parser/surface-parser.ts","../src/parser/obj-parser.ts","../src/parser/ply-parser.ts","../src/parser/csv-parser.ts","../src/parser/json-parser.ts","../src/parser/msgpack-parser.ts","../src/parser/netcdf-parser.ts","../src/parser/text-parser.ts","../src/utils/parse-xml.ts","../src/parser/xml-parser.ts","../src/structure/validation.ts","../lib/pako_inflate.es6.js","../src/parser/validation-parser.ts","../src/utils/gzip-decompressor.ts","../src/datasource/datasource.ts","../src/datasource/rcsb-datasource.ts","../src/datasource/pubchem-datasource.ts","../src/datasource/passthrough-datasource.ts","../src/datasource/alphafold-datasource.ts","../src/datasource/static-datasource.ts","../src/ui/parameters.ts","../src/datasource/mdsrv-datasource.ts","../src/writer/pdb-writer.ts","../src/writer/sdf-writer.ts","../src/writer/stl-writer.ts"],"sourcesContent":["/**\n * @file Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector2, Vector3, Matrix4, Quaternion } from 'three'\n\nexport function getQuery (id: string) {\n if (typeof window === 'undefined') return undefined\n\n const a = new RegExp(`${id}=([^&#=]*)`)\n const m = a.exec(window.location.search)\n\n if (m) {\n return decodeURIComponent(m[1])\n } else {\n return undefined\n }\n}\n\nexport function boolean (value: any) {\n if (!value) {\n return false\n }\n\n if (typeof value === 'string') {\n return /^1|true|t|yes|y$/i.test(value)\n }\n\n return true\n}\n\nexport function defaults (value: any, defaultValue: any) {\n return value !== undefined ? value : defaultValue\n}\n\nexport function createParams (params: {[k in keyof T]?: any}, defaultParams: T) {\n const o: any = Object.assign({}, params)\n for (const k in defaultParams) {\n const value = params[k]\n if (value === undefined) o[k] = defaultParams[k]\n }\n return o as T\n}\n\nexport function updateParams (params: T, newParams: {[k in keyof T]?: any}) {\n for (const k in newParams) {\n const value = newParams[k]\n if (value !== undefined) params[k] = value\n }\n return params as T\n}\n\nexport function pick (object: { [index: string]: any }) {\n const properties = [].slice.call(arguments, 1)\n return properties.reduce((a: { [index: string]: any }, e: any) => {\n a[ e ] = object[ e ]\n return a\n }, {})\n}\n\nexport function flatten (array: any[], ret: any[]) {\n ret = defaults(ret, [])\n for (let i = 0; i < array.length; i++) {\n if (Array.isArray(array[i])) {\n flatten(array[i], ret)\n } else {\n ret.push(array[i])\n }\n }\n return ret\n}\n\nexport function getProtocol () {\n const protocol = window.location.protocol\n return protocol.match(/http(s)?:/gi) === null ? 'http:' : protocol\n}\n\nexport function getBrowser () {\n if (typeof window === 'undefined') return false\n\n const ua = window.navigator.userAgent\n\n if (/Opera|OPR/.test(ua)) {\n return 'Opera'\n } else if (/Chrome/i.test(ua)) {\n return 'Chrome'\n } else if (/Firefox/i.test(ua)) {\n return 'Firefox'\n } else if (/Mobile(\\/.*)? Safari/i.test(ua)) {\n return 'Mobile Safari'\n } else if (/MSIE/i.test(ua)) {\n return 'Internet Explorer'\n } else if (/Safari/i.test(ua)) {\n return 'Safari'\n }\n\n return false\n}\n\nexport function getAbsolutePath (relativePath: string) {\n const loc = window.location\n const pn = loc.pathname\n const basePath = pn.substring(0, pn.lastIndexOf('/') + 1)\n\n return loc.origin + basePath + relativePath\n}\n\nexport function deepCopy (src: any) {\n if (typeof src !== 'object') {\n return src\n }\n\n const dst: { [index: string]: any } = Array.isArray(src) ? [] : {}\n\n for (let key in src) {\n dst[ key ] = deepCopy(src[ key ])\n }\n\n return dst\n}\n\nexport function deepEqual(a: any, b: any) {\n // from https://github.com/epoberezkin/fast-deep-equal MIT\n if (a === b) return true;\n\n const arrA = Array.isArray(a)\n const arrB = Array.isArray(b)\n\n if (arrA && arrB) {\n if (a.length !== b.length) return false\n for (let i = 0; i < a.length; i++) {\n if (!deepEqual(a[i], b[i])) return false\n }\n return true\n }\n\n if (arrA !== arrB) return false\n\n if (a && b && typeof a === 'object' && typeof b === 'object') {\n const keys = Object.keys(a)\n if (keys.length !== Object.keys(b).length) return false;\n\n const dateA = a instanceof Date\n const dateB = b instanceof Date\n if (dateA && dateB) return a.getTime() === b.getTime()\n if (dateA !== dateB) return false\n\n const regexpA = a instanceof RegExp\n const regexpB = b instanceof RegExp\n if (regexpA && regexpB) return a.toString() === b.toString()\n if (regexpA !== regexpB) return false\n\n for (let i = 0; i < keys.length; i++) {\n if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false\n }\n\n for (let i = 0; i < keys.length; i++) {\n if(!deepEqual(a[keys[i]], b[keys[i]])) return false\n }\n\n return true\n }\n\n return false\n}\n\nfunction openUrl (url: string) {\n const opened = window.open(url, '_blank')\n if (!opened) {\n window.location.href = url\n }\n}\n\nexport function download (data: Blob|string, downloadName = 'download') {\n // using ideas from https://github.com/eligrey/FileSaver.js/blob/master/FileSaver.js\n\n if (!data) return\n\n const isSafari = getBrowser() === 'Safari'\n const isChromeIos = /CriOS\\/[\\d]+/.test(window.navigator.userAgent)\n\n const a = document.createElement('a')\n\n function open (str: string) {\n openUrl(isChromeIos ? str : str.replace(/^data:[^;]*;/, 'data:attachment/file;'))\n }\n\n if (typeof navigator !== 'undefined' && (navigator as any).msSaveOrOpenBlob) {\n // native saveAs in IE 10+\n (navigator as any).msSaveOrOpenBlob(data, downloadName)\n } else if ((isSafari || isChromeIos) && FileReader) {\n if (data instanceof Blob) {\n // no downloading of blob urls in Safari\n var reader = new FileReader()\n reader.onloadend = function () {\n open(reader.result as string)\n }\n reader.readAsDataURL(data)\n } else {\n open(data)\n }\n } else {\n let objectUrlCreated = false\n if (data instanceof Blob) {\n data = URL.createObjectURL(data)\n objectUrlCreated = true\n }\n\n if ('download' in a) {\n // download link available\n a.style.display = 'hidden'\n document.body.appendChild(a)\n a.href = data\n a.download = downloadName\n a.target = '_blank'\n a.click()\n document.body.removeChild(a)\n } else {\n openUrl(data)\n }\n\n if (objectUrlCreated) {\n window.URL.revokeObjectURL(data)\n }\n }\n}\n\nexport function submit (url: string, data: FormData, callback: Function, onerror: Function) {\n const xhr = new XMLHttpRequest()\n xhr.open('POST', url)\n\n xhr.addEventListener('load', function () {\n if (xhr.status === 200 || xhr.status === 304) {\n callback(xhr.response)\n } else {\n if (typeof onerror === 'function') {\n onerror(xhr.status)\n }\n }\n }, false)\n\n xhr.send(data)\n}\n\ninterface HTMLInputEvent extends Event {\n target: HTMLInputElement & EventTarget\n}\n\nexport function open (callback: Function, extensionList = ['*']) {\n const fileInput = document.createElement('input')\n fileInput.type = 'file'\n fileInput.multiple = true\n fileInput.style.display = 'hidden'\n document.body.appendChild(fileInput)\n fileInput.accept = '.' + extensionList.join(',.')\n fileInput.addEventListener('change', function (e: HTMLInputEvent) {\n callback(e.target.files)\n }, false)\n\n fileInput.click()\n}\n\nexport function throttle (func: Function, wait: number, options: { leading?: boolean, trailing?: boolean }) {\n // from http://underscorejs.org/docs/underscore.html\n\n let context: any\n let args: any\n let result: any\n let timeout: any = null\n let previous = 0\n\n if (!options) options = {}\n\n function later () {\n previous = options.leading === false ? 0 : Date.now()\n timeout = null\n result = func.apply(context, args)\n if (!timeout) context = args = null\n }\n\n return function throttle (this: any) {\n var now = Date.now()\n if (!previous && options.leading === false) previous = now\n var remaining = wait - (now - previous)\n context = this\n args = arguments\n if (remaining <= 0 || remaining > wait) {\n if (timeout) {\n clearTimeout(timeout)\n timeout = null\n }\n previous = now\n result = func.apply(context, args)\n if (!timeout) context = args = null\n } else if (!timeout && options.trailing !== false) {\n timeout = setTimeout(later, remaining)\n }\n\n return result\n }\n}\n\nexport function lexicographicCompare (elm1: T, elm2: T) {\n if (elm1 < elm2) return -1\n if (elm1 > elm2) return 1\n return 0\n}\n\n/**\n * Does a binary search to get the index of an element in the input array\n * @function\n * @example\n * var array = [ 1, 2, 3, 4, 5, 6 ];\n * var element = 4;\n * binarySearchIndexOf( array, element ); // returns 3\n *\n * @param {Array} array - sorted array\n * @param {Anything} element - element to search for in the array\n * @param {Function} [compareFunction] - compare function\n * @return {Number} the index of the element or -1 if not in the array\n */\nexport function binarySearchIndexOf (array: T[], element: T, compareFunction = lexicographicCompare) {\n let low = 0\n let high = array.length - 1\n while (low <= high) {\n const mid = (low + high) >> 1\n const cmp = compareFunction(element, array[ mid ])\n if (cmp > 0) {\n low = mid + 1\n } else if (cmp < 0) {\n high = mid - 1\n } else {\n return mid\n }\n }\n return -low - 1\n}\n\nexport function binarySearchForLeftRange (array: number[], leftRange: number) {\n let high = array.length - 1\n if (array[ high ] < leftRange) return -1\n let low = 0\n while (low <= high) {\n const mid = (low + high) >> 1\n if (array[ mid ] >= leftRange) {\n high = mid - 1\n } else {\n low = mid + 1\n }\n }\n return high + 1\n}\n\nexport function binarySearchForRightRange (array: number[], rightRange: number) {\n if (array[ 0 ] > rightRange) return -1\n let low = 0\n let high = array.length - 1\n while (low <= high) {\n const mid = (low + high) >> 1\n if (array[ mid ] > rightRange) {\n high = mid - 1\n } else {\n low = mid + 1\n }\n }\n return low - 1\n}\n\nexport function rangeInSortedArray (array: number[], min: number, max: number) {\n const indexLeft = binarySearchForLeftRange(array, min)\n const indexRight = binarySearchForRightRange(array, max)\n if (indexLeft === -1 || indexRight === -1 || indexLeft > indexRight) {\n return 0\n } else {\n return indexRight - indexLeft + 1\n }\n}\n\nexport function dataURItoImage (dataURI: string) {\n const img = document.createElement('img')\n img.src = dataURI\n return img\n}\n\nexport function uniqueArray (array: any[]) {\n return array.sort().filter(function (value, index, sorted) {\n return (index === 0) || (value !== sorted[ index - 1 ])\n })\n}\n\n// String/arraybuffer conversion\n\nexport function uint8ToString (u8a: Uint8Array) {\n const chunkSize = 0x7000\n\n if (u8a.length > chunkSize) {\n const c = []\n\n for (let i = 0; i < u8a.length; i += chunkSize) {\n c.push(String.fromCharCode.apply(\n null, u8a.subarray(i, i + chunkSize)\n ))\n }\n\n return c.join('')\n } else {\n return String.fromCharCode.apply(null, u8a)\n }\n}\n\nexport function uint8ToLines (u8a: Uint8Array, chunkSize = 1024 * 1024 * 10, newline = '\\n') {\n let partialLine = ''\n let lines: string[] = []\n\n for (let i = 0; i < u8a.length; i += chunkSize) {\n const str = uint8ToString(u8a.subarray(i, i + chunkSize))\n const idx = str.lastIndexOf(newline)\n\n if (idx === -1) {\n partialLine += str\n } else {\n const str2 = partialLine + str.substr(0, idx)\n lines = lines.concat(str2.split(newline))\n\n if (idx === str.length - newline.length) {\n partialLine = ''\n } else {\n partialLine = str.substr(idx + newline.length)\n }\n }\n }\n\n if (partialLine !== '') {\n lines.push(partialLine)\n }\n\n return lines\n}\n\nexport type TypedArrayString = 'int8'|'int16'|'int32'|'uint8'|'uint16'|'uint32'|'float32'\nexport function getTypedArray (arrayType: TypedArrayString, arraySize: number) {\n switch (arrayType) {\n case 'int8':\n return new Int8Array(arraySize)\n case 'int16':\n return new Int16Array(arraySize)\n case 'int32':\n return new Int32Array(arraySize)\n case 'uint8':\n return new Uint8Array(arraySize)\n case 'uint16':\n return new Uint16Array(arraySize)\n case 'uint32':\n return new Uint32Array(arraySize)\n case 'float32':\n return new Float32Array(arraySize)\n default:\n throw new Error('arrayType unknown: ' + arrayType)\n }\n}\n\nexport function getUintArray (sizeOrArray: any, maxUint: number) { // TODO\n const TypedArray = maxUint > 65535 ? Uint32Array : Uint16Array\n return new TypedArray(sizeOrArray)\n}\n\nexport function ensureArray (value: any) {\n return Array.isArray(value) ? value : [value]\n}\n\nexport function ensureBuffer (a: any) { // TODO\n return (a.buffer && a.buffer instanceof ArrayBuffer) ? a.buffer : a\n}\n\nfunction _ensureClassFromArg (arg: any, constructor: { new (arg: any): any }) {\n return arg instanceof constructor ? arg : new constructor(arg)\n}\n\nfunction _ensureClassFromArray (array: any, constructor: { new (): any }) {\n if (array === undefined) {\n array = new constructor()\n } else if (Array.isArray(array)) {\n array = new constructor().fromArray(array)\n }\n return array\n}\n\nexport function ensureVector2 (v?: number[]|Vector2) {\n return _ensureClassFromArray(v, Vector2)\n}\n\nexport function ensureVector3 (v?: number[]|Vector3) {\n return _ensureClassFromArray(v, Vector3)\n}\n\nexport function ensureMatrix4 (m?: number[]|Matrix4) {\n return _ensureClassFromArray(m, Matrix4)\n}\n\nexport function ensureQuaternion (q?: number[]|Quaternion) {\n return _ensureClassFromArray(q, Quaternion)\n}\n\nexport function ensureFloat32Array (a?: number[]|Float32Array) {\n return _ensureClassFromArg(a, Float32Array)\n}\n\nexport interface RingBuffer {\n has: (value: T) => boolean\n get: (value: number) => T\n push: (value: T) => void\n count: number\n data: T[]\n clear: () => void\n}\n\nexport function createRingBuffer (length: number): RingBuffer {\n let pointer = 0\n let count = 0\n const buffer: T[] = []\n\n return {\n has: function (value: any) { return buffer.indexOf(value) !== -1 },\n get: function (idx: number) { return buffer[idx] },\n push: function (item: any) {\n buffer[pointer] = item\n pointer = (length + pointer + 1) % length\n ++count\n },\n get count () { return count },\n get data () { return buffer.slice(0, Math.min(count, length)) },\n clear: function () {\n count = 0\n pointer = 0\n buffer.length = 0\n }\n }\n}\n\nexport interface SimpleDict {\n has: (k: K) => boolean\n add: (k: K, v: V) => void\n del: (k: K) => void\n values: V[]\n}\n\nexport function createSimpleDict (): SimpleDict {\n const set: { [k: string]: V } = {}\n\n return {\n has: function (k: K) { return set[JSON.stringify(k)] !== undefined },\n add: function (k: K, v: V) { set[JSON.stringify(k)] = v },\n del: function (k: K) { delete set[JSON.stringify(k)] },\n get values () { return Object.keys(set).map(k => set[k]) }\n }\n}\n\nexport interface SimpleSet {\n has: (value: T) => boolean\n add: (value: T) => void\n del: (value: T) => void\n list: T[]\n}\n\nexport function createSimpleSet (): SimpleSet {\n const set: { [k: string]: T } = {}\n\n return {\n has: function (v: T) { return set[JSON.stringify(v)] !== undefined },\n add: function (v: T) { set[JSON.stringify(v)] = v },\n del: function (v: T) { delete set[JSON.stringify(v)] },\n get list () { return Object.keys(set).map(k => set[k]) },\n }\n}\n","/**\n * @file Registry\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\n\nfunction toLowerCaseString (value: string) {\n return defaults(value, '').toString().toLowerCase()\n}\n\nexport default class Registry {\n name: string\n private _dict: {[k: string]: any}\n\n constructor (name: string) {\n this.name = name\n this._dict = {}\n }\n\n add (key: string, value: any) {\n this._dict[ toLowerCaseString(key) ] = value\n }\n\n get (key: string) {\n return this._dict[ toLowerCaseString(key) ]\n }\n\n get names () {\n return Object.keys(this._dict)\n }\n}","/**\n * @file Math Utils\n * @author Alexander Rose \n * @private\n */\n\nexport function degToRad (deg: number) {\n return deg * 0.01745 // deg * Math.PI / 180\n}\n\nexport function radToDeg (rad: number) {\n return rad * 57.29578 // rad * 180 / Math.PI\n}\n\n// http://www.broofa.com/Tools/Math.uuid.htm\nconst chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('')\nconst uuid = new Array(36)\n\nexport function generateUUID () {\n let rnd = 0\n let r\n\n for (let i = 0; i < 36; i++) {\n if (i === 8 || i === 13 || i === 18 || i === 23) {\n uuid[ i ] = '-'\n } else if (i === 14) {\n uuid[ i ] = '4'\n } else {\n if (rnd <= 0x02) rnd = 0x2000000 + (Math.random() * 0x1000000) | 0\n r = rnd & 0xf\n rnd = rnd >> 4\n uuid[ i ] = chars[ (i === 19) ? (r & 0x3) | 0x8 : r ]\n }\n }\n\n return uuid.join('')\n}\n\nexport function countSetBits (i: number) {\n i = i - ((i >> 1) & 0x55555555)\n i = (i & 0x33333333) + ((i >> 2) & 0x33333333)\n return (((i + (i >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24\n}\n\nexport function normalize (value: number, min: number, max: number) {\n return (value - min) / (max - min)\n}\n\nexport function clamp (value: number, min: number, max: number) {\n return Math.max(min, Math.min(max, value))\n}\n\nexport function pclamp (value: number) {\n return clamp(value, 0, 100)\n}\n\nexport function saturate (value: number) {\n return clamp(value, 0, 1)\n}\n\nexport function lerp (start: number, stop: number, alpha: number) {\n return start + (stop - start) * alpha\n}\n\nexport function spline (p0: number, p1: number, p2: number, p3: number, t: number, tension: number) {\n const v0 = (p2 - p0) * tension\n const v1 = (p3 - p1) * tension\n const t2 = t * t\n const t3 = t * t2\n return (2 * p1 - 2 * p2 + v0 + v1) * t3 +\n (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 +\n v0 * t + p1\n}\n\nexport function smoothstep (min: number, max: number, x: number) {\n x = saturate(normalize(x, min, max))\n return x * x * (3 - 2 * x)\n}\n\nexport function smootherstep (min: number, max: number, x: number) {\n x = saturate(normalize(x, min, max))\n return x * x * x * (x * (x * 6 - 15) + 10)\n}\n\nexport function smootheststep (min: number, max: number, x: number) {\n x = saturate(normalize(x, min, max))\n return (\n -20 * Math.pow(x, 7) +\n 70 * Math.pow(x, 6) -\n 84 * Math.pow(x, 5) +\n 35 * Math.pow(x, 4)\n )\n}\n\nexport function almostIdentity (value: number, start: number, stop: number) {\n if (value > start) return value\n const a = 2 * stop - start\n const b = 2 * start - 3 * stop\n const t = value / start\n return (a * t + b) * t * t + stop\n}","/**\n * @file Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Color } from 'three'\nimport * as chroma from 'chroma-js'\n\nimport { createParams } from '../utils'\nimport { NumberArray } from '../types'\nimport Structure from '../structure/structure'\nimport Surface from '../surface/surface'\nimport Volume from '../surface/volume'\nimport AtomProxy from '../proxy/atom-proxy'\nimport BondProxy from '../proxy/bond-proxy'\n\nexport type ColorMode = 'rgb'|'hsv'|'hsl'|'hsi'|'lab'|'hcl'\nexport type ColorSpace = 'sRGB' | 'linear'\n\n/**\n * Internal color space for all colors (global).\n * Colors are always specified as sRGB; if this is set to\n * 'linear' then colors get linearized when used internally\n * as vertex or texture colors.\n * @see setColorSpace/getColorSpace.\n */\nvar colorSpace: ColorSpace = 'sRGB' // default: don't linearize\n\n/** Set the global internal color space for colormakers */\nexport function setColorSpace(space: ColorSpace) {\n colorSpace = space\n}\n\n/** Get the global internal color space for colormakers */\nexport function getColorSpace() {\n return colorSpace\n}\n\nexport const ScaleDefaultParameters = {\n scale: 'uniform' as string|string[],\n mode: 'hcl' as ColorMode,\n domain: [ 0, 1 ] as number[],\n value: 0xFFFFFF,\n reverse: false,\n}\nexport type ScaleParameters = typeof ScaleDefaultParameters\n\nexport interface ColorData {\n atomData?: number[],\n bondData?: number[]\n}\n\nexport interface ColormakerParameters extends ScaleParameters {\n structure?: Structure\n volume?: Volume\n surface?: Surface\n data?: ColorData\n}\n\nexport type StuctureColormakerParams = { structure: Structure } & Partial\nexport type VolumeColormakerParams = { volume: Volume } & Partial\nexport type ColormakerScale = (v: number) => number\n\nconst tmpColor = new Color()\n\n/** Decorator for optionally linearizing a numeric color */\ntype colorFuncType = (value: any, fromTo?: boolean) => number // decorator applies to functions with this shape\nexport function manageColor\n (_target: Object,\n _name: string | symbol,\n descriptor: TypedPropertyDescriptor): PropertyDescriptor {\n const originalMethod = descriptor.value\n const linearize: colorFuncType = function (this: T, value: any, fromTo?: boolean) {\n let result = originalMethod!.bind(this, value, fromTo)()\n if (colorSpace == 'linear') {\n tmpColor.set(result)\n tmpColor.convertSRGBToLinear()\n return tmpColor.getHex()\n } else {\n return result\n }\n }\n descriptor.value = linearize\n return descriptor\n }\n\n/**\n * Class for making colors.\n * @interface\n */\nabstract class Colormaker {\n parameters: ColormakerParameters\n atomProxy?: AtomProxy\n\n /**\n * Create a colormaker instance\n * @param {ColormakerParameters} params - colormaker parameter\n */\n constructor (params: Partial = {}) {\n this.parameters = createParams(params, ScaleDefaultParameters)\n\n if (typeof this.parameters.value === 'string') {\n this.parameters.value = tmpColor.set(this.parameters.value).getHex()\n }\n\n if (this.parameters.structure) {\n this.atomProxy = this.parameters.structure.getAtomProxy()\n }\n }\n\n getScale (params: Partial = {}) {\n const p = createParams(params, this.parameters)\n\n if (p.scale === 'rainbow') {\n p.scale = [ 'red', 'orange', 'yellow', 'green', 'blue' ]\n } else if (p.scale === 'rwb') {\n p.scale = [ 'red', 'white', 'blue' ]\n }\n\n if (p.reverse) {\n p.domain = p.domain.slice().reverse()\n }\n return chroma\n .scale(p.scale as any) // TODO\n .mode(p.mode)\n .domain(p.domain)\n .out('num' as any) // returns RGB color as numeric (not string \"#ffffff\")\n }\n\n /**\n * save a color to an array\n * @param {Integer} color - hex color value\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n colorToArray (color: number, array: NumberArray = [], offset = 0) {\n array[ offset ] = (color >> 16 & 255) / 255\n array[ offset + 1 ] = (color >> 8 & 255) / 255\n array[ offset + 2 ] = (color & 255) / 255\n\n return array\n }\n\n atomColor? (atom: AtomProxy): number\n\n /**\n * save an atom color to an array\n * @param {AtomProxy} atom - atom to get color for\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n atomColorToArray (atom: AtomProxy, array: NumberArray, offset: number) {\n return this.colorToArray(\n this.atomColor ? this.atomColor(atom) : 0x000000, array, offset\n )\n }\n\n /**\n * return the color for an bond\n * @param {BondProxy} bond - bond to get color for\n * @param {Boolean} fromTo - whether to use the first or second atom of the bond\n * @return {Integer} hex bond color\n */\n bondColor (bond: BondProxy, fromTo: boolean) {\n if (this.atomProxy && this.atomColor) {\n this.atomProxy.index = fromTo ? bond.atomIndex1 : bond.atomIndex2\n return this.atomColor(this.atomProxy)\n } else {\n return 0x000000\n }\n }\n\n /**\n * safe a bond color to an array\n * @param {BondProxy} bond - bond to get color for\n * @param {Boolean} fromTo - whether to use the first or second atom of the bond\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n bondColorToArray (bond: BondProxy, fromTo: boolean, array: NumberArray, offset: number) {\n return this.colorToArray(\n this.bondColor(bond, fromTo), array, offset\n )\n }\n\n volumeColor? (index: number): number\n\n /**\n * safe a volume cell color to an array\n * @param {Integer} index - volume cell index\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n volumeColorToArray (index: number, array: NumberArray, offset: number) {\n return this.colorToArray(\n this.volumeColor ? this.volumeColor(index) : 0x000000, array, offset\n )\n }\n\n positionColor? (position: Vector3): number\n\n /**\n * safe a color for coordinates in space to an array\n * @param {Vector3} coords - xyz coordinates\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n positionColorToArray (coords: Vector3, array: NumberArray, offset: number) {\n return this.colorToArray(\n this.positionColor ? this.positionColor(coords) : 0x000000, array, offset\n )\n }\n}\n\nexport default Colormaker\n","/**\n * @file Selection Constants\n * @author Alexander Rose \n * @private\n */\n\nexport enum kwd {\n PROTEIN = 1,\n NUCLEIC = 2,\n RNA = 3,\n DNA = 4,\n POLYMER = 5,\n WATER = 6,\n HELIX = 7,\n SHEET = 8,\n TURN = 9,\n BACKBONE = 10,\n SIDECHAIN = 11,\n ALL = 12,\n HETERO = 13,\n ION = 14,\n SACCHARIDE = 15,\n SUGAR = 15,\n BONDED = 16,\n RING = 17,\n AROMATICRING = 18,\n METAL = 19,\n POLARH = 20,\n NONE = 21\n}\n\nexport const SelectAllKeyword = [ '*', '', 'ALL' ]\nexport const SelectNoneKeyword = [ 'NONE' ]\n\nexport const AtomOnlyKeywords = [\n kwd.BACKBONE, kwd.SIDECHAIN, kwd.BONDED, kwd.RING, kwd.AROMATICRING, kwd.METAL, kwd.POLARH\n]\n\nexport const ChainKeywords = [\n kwd.POLYMER, kwd.WATER\n]\n\nexport const SmallResname = [ 'ALA', 'GLY', 'SER' ]\nexport const NucleophilicResname = [ 'CYS', 'SER', 'THR' ]\nexport const HydrophobicResname = [ 'ALA', 'ILE', 'LEU', 'MET', 'PHE', 'PRO', 'TRP', 'VAL' ]\nexport const AromaticResname = [ 'PHE', 'TRP', 'TYR', 'HIS' ]\nexport const AmideResname = [ 'ASN', 'GLN' ]\nexport const AcidicResname = [ 'ASP', 'GLU' ]\nexport const BasicResname = [ 'ARG', 'HIS', 'LYS' ]\nexport const ChargedResname = [ 'ARG', 'ASP', 'GLU', 'HIS', 'LYS' ]\nexport const PolarResname = [ 'ASN', 'ARG', 'ASP', 'CYS', 'GLY', 'GLN', 'GLU', 'HIS', 'LYS', 'SER', 'THR', 'TYR' ]\nexport const NonpolarResname = [ 'ALA', 'ILE', 'LEU', 'MET', 'PHE', 'PRO', 'TRP', 'VAL' ]\nexport const CyclicResname = [ 'HIS', 'PHE', 'PRO', 'TRP', 'TYR' ]\nexport const AliphaticResname = [ 'ALA', 'GLY', 'ILE', 'LEU', 'VAL' ]\n","/**\n * @file Selection Test\n * @author Alexander Rose \n * @private\n */\n\nimport { binarySearchIndexOf, rangeInSortedArray } from '../utils'\nimport { kwd, AtomOnlyKeywords, ChainKeywords } from './selection-constants'\n\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\nexport type ProxyEntity = AtomProxy|ResidueProxy|ChainProxy|ModelProxy\ntype TestEntityFn = (e: ProxyEntity, s: SelectionRule) => boolean|-1\ntype FilterFn = (s: SelectionRule) => boolean\nexport type SelectionTest = false|((e: ProxyEntity) => boolean|-1)\n\nexport type SelectionOperator = 'AND'|'OR'\nexport interface SelectionRule {\n keyword?: any\n atomname?: string\n element?: string\n atomindex?: number[]\n altloc?: string\n inscode?: string\n resname?: string|string[]\n sstruc?: string\n resno?: number|[number, number]\n chainname?: string\n model?: number\n\n error?: string\n rules?: SelectionRule[]\n negate?: boolean\n operator?: SelectionOperator\n}\n\nfunction atomTestFn (a: AtomProxy, s: SelectionRule) {\n // returning -1 means the rule is not applicable\n if (s.atomname === undefined && s.element === undefined &&\n s.altloc === undefined && s.atomindex === undefined &&\n s.keyword === undefined && s.inscode === undefined &&\n s.resname === undefined && s.sstruc === undefined &&\n s.resno === undefined && s.chainname === undefined &&\n s.model === undefined\n ) return -1\n\n if (s.keyword !== undefined) {\n if (s.keyword === kwd.BACKBONE && !a.isBackbone()) return false\n if (s.keyword === kwd.SIDECHAIN && !a.isSidechain()) return false\n if (s.keyword === kwd.BONDED && !a.isBonded()) return false\n if (s.keyword === kwd.RING && !a.isRing()) return false\n if (s.keyword === kwd.AROMATICRING && !a.isAromatic()) return false\n\n if (s.keyword === kwd.HETERO && !a.isHetero()) return false\n if (s.keyword === kwd.PROTEIN && !a.isProtein()) return false\n if (s.keyword === kwd.NUCLEIC && !a.isNucleic()) return false\n if (s.keyword === kwd.RNA && !a.isRna()) return false\n if (s.keyword === kwd.DNA && !a.isDna()) return false\n if (s.keyword === kwd.POLYMER && !a.isPolymer()) return false\n if (s.keyword === kwd.WATER && !a.isWater()) return false\n if (s.keyword === kwd.HELIX && !a.isHelix()) return false\n if (s.keyword === kwd.SHEET && !a.isSheet()) return false\n if (s.keyword === kwd.TURN && !a.isTurn()) return false\n if (s.keyword === kwd.ION && !a.isIon()) return false\n if (s.keyword === kwd.SACCHARIDE && !a.isSaccharide()) return false\n if (s.keyword === kwd.METAL && !a.isMetal()) return false\n if (s.keyword === kwd.POLARH && !a.isPolarHydrogen()) return false\n }\n\n if (s.atomname !== undefined && s.atomname !== a.atomname) return false\n if (s.element !== undefined && s.element !== a.element) return false\n if (s.altloc !== undefined && s.altloc !== a.altloc) return false\n\n if (s.atomindex !== undefined &&\n binarySearchIndexOf(s.atomindex, a.index) < 0\n ) return false\n\n if (s.resname !== undefined) {\n if (Array.isArray(s.resname)) {\n if (!s.resname.includes(a.resname)) return false\n } else {\n if (s.resname !== a.resname) return false\n }\n }\n if (s.sstruc !== undefined && s.sstruc !== a.sstruc) return false\n if (s.resno !== undefined) {\n if (Array.isArray(s.resno) && s.resno.length === 2) {\n if (s.resno[0] > a.resno || s.resno[1] < a.resno) return false\n } else {\n if (s.resno !== a.resno) return false\n }\n }\n if (s.inscode !== undefined && s.inscode !== a.inscode) return false\n\n if (s.chainname !== undefined && s.chainname !== a.chainname) return false\n if (s.model !== undefined && s.model !== a.modelIndex) return false\n\n return true\n}\n\nfunction residueTestFn (r: ResidueProxy, s: SelectionRule) {\n // returning -1 means the rule is not applicable\n if (s.resname === undefined && s.resno === undefined && s.inscode === undefined &&\n s.sstruc === undefined && s.model === undefined && s.chainname === undefined &&\n s.atomindex === undefined &&\n (s.keyword === undefined || AtomOnlyKeywords.includes(s.keyword))\n ) return -1\n\n if (s.keyword !== undefined) {\n if (s.keyword === kwd.HETERO && !r.isHetero()) return false\n if (s.keyword === kwd.PROTEIN && !r.isProtein()) return false\n if (s.keyword === kwd.NUCLEIC && !r.isNucleic()) return false\n if (s.keyword === kwd.RNA && !r.isRna()) return false\n if (s.keyword === kwd.DNA && !r.isDna()) return false\n if (s.keyword === kwd.POLYMER && !r.isPolymer()) return false\n if (s.keyword === kwd.WATER && !r.isWater()) return false\n if (s.keyword === kwd.HELIX && !r.isHelix()) return false\n if (s.keyword === kwd.SHEET && !r.isSheet()) return false\n if (s.keyword === kwd.TURN && !r.isTurn()) return false\n if (s.keyword === kwd.ION && !r.isIon()) return false\n if (s.keyword === kwd.SACCHARIDE && !r.isSaccharide()) return false\n }\n\n if (s.atomindex !== undefined &&\n rangeInSortedArray(s.atomindex, r.atomOffset, r.atomEnd) === 0\n ) return false\n\n if (s.resname !== undefined) {\n if (Array.isArray(s.resname)) {\n if (!s.resname.includes(r.resname)) return false\n } else {\n if (s.resname !== r.resname) return false\n }\n }\n if (s.sstruc !== undefined && s.sstruc !== r.sstruc) return false\n if (s.resno !== undefined) {\n if (Array.isArray(s.resno) && s.resno.length === 2) {\n if (s.resno[0] > r.resno || s.resno[1] < r.resno) return false\n } else {\n if (s.resno !== r.resno) return false\n }\n }\n if (s.inscode !== undefined && s.inscode !== r.inscode) return false\n\n if (s.chainname !== undefined && s.chainname !== r.chainname) return false\n if (s.model !== undefined && s.model !== r.modelIndex) return false\n\n return true\n}\n\nfunction chainTestFn (c: ChainProxy, s: SelectionRule) {\n // returning -1 means the rule is not applicable\n if (s.chainname === undefined && s.model === undefined && s.atomindex === undefined &&\n (s.keyword === undefined || !ChainKeywords.includes(s.keyword) || !c.entity)\n ) return -1\n\n if (s.keyword !== undefined) {\n if (s.keyword === kwd.POLYMER && !c.entity.isPolymer()) return false\n if (s.keyword === kwd.WATER && !c.entity.isWater()) return false\n }\n\n if (s.atomindex !== undefined &&\n rangeInSortedArray(s.atomindex, c.atomOffset, c.atomEnd) === 0\n ) return false\n\n if (s.chainname !== undefined && s.chainname !== c.chainname) return false\n\n if (s.model !== undefined && s.model !== c.modelIndex) return false\n\n return true\n}\n\nfunction modelTestFn (m: ModelProxy, s: SelectionRule) {\n // returning -1 means the rule is not applicable\n if (s.model === undefined && s.atomindex === undefined) return -1\n\n if (s.atomindex !== undefined &&\n rangeInSortedArray(s.atomindex, m.atomOffset, m.atomEnd) === 0\n ) return false\n\n if (s.model !== undefined && s.model !== m.index) return false\n\n return true\n}\n\nfunction makeTest (selection: SelectionRule|null, fn: TestEntityFn) {\n if (selection === null) return false\n if (selection.error) return false\n if (!selection.rules || selection.rules.length === 0) return false\n\n const n = selection.rules.length\n\n const t = !selection.negate\n const f = !!selection.negate\n\n const subTests: SelectionTest[] = []\n for (let i = 0; i < n; ++i) {\n const s = selection.rules[ i ]\n if (s.hasOwnProperty('operator')) {\n subTests[ i ] = makeTest(s, fn) as SelectionTest // TODO\n }\n }\n\n // ( x and y ) can short circuit on false\n // ( x or y ) can short circuit on true\n // not ( x and y )\n\n return function test (entity: ProxyEntity) {\n const and = selection.operator === 'AND'\n let na = false\n\n for (let i = 0; i < n; ++i) {\n const s = selection.rules![ i ] // TODO\n let ret\n\n if (s.hasOwnProperty('operator')) {\n const test = subTests[ i ]\n if (test !== false) {\n ret = test(entity)\n } else {\n ret = -1\n }\n\n if (ret === -1) {\n na = true\n continue\n } else if (ret === true) {\n if (and) { continue } else { return t }\n } else {\n if (and) { return f } else { continue }\n }\n } else {\n if (s.keyword === kwd.ALL) {\n if (and) { continue } else { return t }\n } else if (s.keyword === kwd.NONE) {\n if (and) { continue } else { return f }\n }\n\n ret = fn(entity, s)\n\n // console.log( entity.qualifiedName(), ret, s, selection.negate, \"t\", t, \"f\", f )\n\n if (ret === -1) {\n na = true\n continue\n } else if (ret === true) {\n if (and) { continue } else { return t }\n } else {\n if (and) { return f } else { continue }\n }\n }\n }\n\n if (na) {\n return -1\n } else {\n if (and) { return t } else { return f }\n }\n } as SelectionTest\n}\n\nfunction filter (selection: SelectionRule, fn: FilterFn) {\n if (selection.error) return selection\n if (!selection.rules || selection.rules.length === 0) return selection\n\n const n = selection.rules.length\n\n const filtered: SelectionRule = {\n operator: selection.operator,\n rules: []\n }\n if (selection.hasOwnProperty('negate')) {\n filtered.negate = selection.negate\n }\n\n for (let i = 0; i < n; ++i) {\n const s = selection.rules[ i ]\n if (s.hasOwnProperty('operator')) {\n const fs = filter(s, fn)\n if (fs !== null) filtered.rules!.push(fs) // TODO\n } else if (!fn(s)) {\n filtered.rules!.push(s) // TODO\n }\n }\n\n if (filtered.rules!.length > 0) { // TODO\n // TODO maybe the filtered rules could be returned\n // in some case, but the way how tests are applied\n // e.g. when traversing a structure would also need\n // to change\n return selection\n // return filtered;\n } else {\n return null\n }\n}\n\nfunction makeAtomTest (selection: SelectionRule, atomOnly = false) {\n let filteredSelection: SelectionRule|null = selection\n if (atomOnly) {\n filteredSelection = filter(selection, function (s) {\n if (s.keyword !== undefined && !AtomOnlyKeywords.includes(s.keyword)) return true\n if (s.model !== undefined) return true\n if (s.chainname !== undefined) return true\n if (s.resname !== undefined) return true\n if (s.resno !== undefined) return true\n if (s.sstruc !== undefined) return true\n return false\n })\n }\n return makeTest(filteredSelection, atomTestFn)\n}\n\nfunction makeResidueTest (selection: SelectionRule, residueOnly = false) {\n let filteredSelection: SelectionRule|null = selection\n if (residueOnly) {\n filteredSelection = filter(selection, function (s) {\n if (s.keyword !== undefined && AtomOnlyKeywords.includes(s.keyword)) return true\n if (s.model !== undefined) return true\n if (s.chainname !== undefined) return true\n if (s.atomname !== undefined) return true\n if (s.element !== undefined) return true\n if (s.altloc !== undefined) return true\n return false\n })\n }\n return makeTest(filteredSelection, residueTestFn)\n}\n\nfunction makeChainTest (selection: SelectionRule, chainOnly = false) {\n let filteredSelection: SelectionRule|null = selection\n if (chainOnly) {\n filteredSelection = filter(selection, function (s) {\n if (s.keyword !== undefined && !ChainKeywords.includes(s.keyword)) return true\n // if( s.model!==undefined ) return true;\n if (s.resname !== undefined) return true\n if (s.resno !== undefined) return true\n if (s.atomname !== undefined) return true\n if (s.element !== undefined) return true\n if (s.altloc !== undefined) return true\n if (s.sstruc !== undefined) return true\n if (s.inscode !== undefined) return true\n return false\n })\n }\n return makeTest(filteredSelection, chainTestFn)\n}\n\nfunction makeModelTest (selection: SelectionRule, modelOnly = false) {\n let filteredSelection: SelectionRule|null = selection\n if (modelOnly) {\n filteredSelection = filter(selection, function (s) {\n if (s.keyword !== undefined) return true\n if (s.chainname !== undefined) return true\n if (s.resname !== undefined) return true\n if (s.resno !== undefined) return true\n if (s.atomname !== undefined) return true\n if (s.element !== undefined) return true\n if (s.altloc !== undefined) return true\n if (s.sstruc !== undefined) return true\n if (s.inscode !== undefined) return true\n return false\n })\n }\n return makeTest(filteredSelection, modelTestFn)\n}\n\nexport {\n makeAtomTest,\n makeResidueTest,\n makeChainTest,\n makeModelTest\n}\n","/**\n * @file Selection\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { parseSele } from './selection-parser'\nimport {\n SelectionTest, SelectionRule,\n makeAtomTest, makeResidueTest, makeChainTest, makeModelTest\n} from './selection-test'\nimport { SelectAllKeyword, SelectNoneKeyword } from './selection-constants'\n\nexport type SelectionSignals = {\n stringChanged: Signal\n}\n\n/**\n * Selection\n */\nclass Selection {\n signals: SelectionSignals\n string: string\n selection: SelectionRule\n\n test: SelectionTest\n residueTest: SelectionTest\n chainTest: SelectionTest\n modelTest: SelectionTest\n\n atomOnlyTest: SelectionTest\n residueOnlyTest: SelectionTest\n chainOnlyTest: SelectionTest\n modelOnlyTest: SelectionTest\n\n /**\n * Create Selection\n * @param {String} string - selection string, see {@tutorial selection-language}\n */\n constructor (string?: string) {\n this.signals = {\n stringChanged: new Signal()\n }\n\n this.setString(string)\n }\n\n get type () { return 'selection' }\n\n setString (string?: string, silent?: boolean) {\n if (string === undefined) string = this.string || ''\n if (string === this.string) return\n\n try {\n this.selection = parseSele(string)\n } catch (e) {\n // Log.error( e.stack );\n this.selection = { 'error': e.message }\n }\n const selection = this.selection\n\n this.string = string\n\n this.test = makeAtomTest(selection)\n this.residueTest = makeResidueTest(selection)\n this.chainTest = makeChainTest(selection)\n this.modelTest = makeModelTest(selection)\n\n this.atomOnlyTest = makeAtomTest(selection, true)\n this.residueOnlyTest = makeResidueTest(selection, true)\n this.chainOnlyTest = makeChainTest(selection, true)\n this.modelOnlyTest = makeModelTest(selection, true)\n\n if (!silent) {\n this.signals.stringChanged.dispatch(this.string)\n }\n }\n\n isAllSelection () {\n return SelectAllKeyword.includes(this.string.toUpperCase())\n }\n\n isNoneSelection () {\n return SelectNoneKeyword.includes(this.string.toUpperCase())\n }\n}\n\nexport default Selection\n","/**\n * @file Selection Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { SelectionRule, SelectionOperator } from './selection-test'\nimport {\n kwd, SelectAllKeyword,\n SmallResname, NucleophilicResname, HydrophobicResname, AromaticResname,\n AmideResname, AcidicResname, BasicResname, ChargedResname,\n PolarResname, NonpolarResname, CyclicResname, AliphaticResname\n} from './selection-constants'\n\nfunction parseSele (string: string) {\n let retSelection: SelectionRule = {\n operator: undefined,\n rules: []\n }\n\n if (!string) {\n return retSelection\n }\n\n let selection = retSelection\n let newSelection: SelectionRule\n let oldSelection: SelectionRule\n const selectionStack: SelectionRule[] = []\n\n string = string.replace(/\\(/g, ' ( ').replace(/\\)/g, ' ) ').trim()\n if (string.charAt(0) === '(' && string.substr(-1) === ')') {\n string = string.slice(1, -1).trim()\n }\n const chunks = string.split(/\\s+/)\n\n // Log.log( string, chunks )\n\n const createNewContext = (operator?: SelectionOperator) => {\n newSelection = {\n operator,\n rules: []\n }\n if (selection === undefined) {\n selection = newSelection\n retSelection = newSelection\n } else {\n selection.rules!.push(newSelection)\n selectionStack.push(selection)\n selection = newSelection\n }\n }\n\n const getPrevContext = function (operator?: SelectionOperator) {\n oldSelection = selection\n selection = selectionStack.pop()!\n if (selection === undefined) {\n createNewContext(operator)\n pushRule(oldSelection)\n }\n }\n\n const pushRule = function (rule: SelectionRule) {\n selection.rules!.push(rule)\n }\n\n let not: false|0|1|2 = false\n\n for (let i = 0; i < chunks.length; ++i) {\n const c = chunks[ i ]\n const cu = c.toUpperCase()\n\n // handle parens\n\n if (c === '(') {\n // Log.log( \"(\" );\n not = false\n createNewContext()\n continue\n } else if (c === ')') {\n // Log.log( \")\" );\n getPrevContext()\n if (selection.negate) {\n getPrevContext()\n }\n continue\n }\n\n // leave 'not' context\n\n if (not > 0) {\n if (cu === 'NOT') {\n not = 1\n } else if (not === 1) {\n not = 2\n } else if (not === 2) {\n not = false\n getPrevContext()\n } else {\n throw new Error(\"something went wrong with 'not'\")\n }\n }\n\n // handle logic operators\n\n if (cu === 'AND') {\n // Log.log( \"AND\" );\n if (selection.operator === 'OR') {\n const lastRule = selection.rules!.pop()!\n createNewContext('AND')\n pushRule(lastRule)\n } else {\n selection.operator = 'AND'\n }\n continue\n } else if (cu === 'OR') {\n // Log.log( \"OR\" );\n if (selection.operator === 'AND') {\n getPrevContext('OR')\n } else {\n selection.operator = 'OR'\n }\n continue\n } else if (c.toUpperCase() === 'NOT') {\n // Log.log( \"NOT\", j );\n not = 1\n createNewContext()\n selection.negate = true\n continue\n } else {\n // Log.log( \"chunk\", c, j, selection );\n }\n\n // handle keyword attributes\n\n // ensure `cu` is not a number before testing if it is in the\n // kwd enum dictionary which includes the enum numbers as well...\n if (+cu !== +cu) {\n const keyword = (kwd as any)[ cu ]\n if (keyword !== undefined) {\n pushRule({ keyword })\n continue\n }\n }\n\n if (cu === 'HYDROGEN') {\n pushRule({\n operator: 'OR',\n rules: [\n { element: 'H' },\n { element: 'D' }\n ]\n })\n continue\n }\n\n if (cu === 'SMALL') {\n pushRule({ resname: SmallResname })\n continue\n }\n\n if (cu === 'NUCLEOPHILIC') {\n pushRule({ resname: NucleophilicResname })\n continue\n }\n\n if (cu === 'HYDROPHOBIC') {\n pushRule({ resname: HydrophobicResname })\n continue\n }\n\n if (cu === 'AROMATIC') {\n pushRule({ resname: AromaticResname })\n continue\n }\n\n if (cu === 'AMIDE') {\n pushRule({ resname: AmideResname })\n continue\n }\n\n if (cu === 'ACIDIC') {\n pushRule({ resname: AcidicResname })\n continue\n }\n\n if (cu === 'BASIC') {\n pushRule({ resname: BasicResname })\n continue\n }\n\n if (cu === 'CHARGED') {\n pushRule({ resname: ChargedResname })\n continue\n }\n\n if (cu === 'POLAR') {\n pushRule({ resname: PolarResname })\n continue\n }\n\n if (cu === 'NONPOLAR') {\n pushRule({ resname: NonpolarResname })\n continue\n }\n\n if (cu === 'CYCLIC') {\n pushRule({ resname: CyclicResname })\n continue\n }\n\n if (cu === 'ALIPHATIC') {\n pushRule({ resname: AliphaticResname })\n continue\n }\n\n if (cu === 'SIDECHAINATTACHED') {\n pushRule({\n operator: 'OR',\n rules: [\n { keyword: kwd.SIDECHAIN },\n {\n operator: 'AND',\n negate: false,\n rules: [\n { keyword: kwd.PROTEIN },\n {\n operator: 'OR',\n negate: false,\n rules: [\n { atomname: 'CA' },\n { atomname: 'BB' }\n ]\n }\n ]\n },\n {\n operator: 'AND',\n negate: false,\n rules: [\n { resname: 'PRO' },\n { atomname: 'N' }\n ]\n },\n {\n operator: 'AND',\n negate: false,\n rules: [\n { keyword: kwd.NUCLEIC },\n {\n operator: 'OR',\n negate: true,\n rules: [\n { atomname: 'P' },\n { atomname: 'OP1' },\n { atomname: 'OP2' },\n { atomname: \"O3'\" },\n { atomname: 'O3*' },\n { atomname: \"HO3'\"},\n { atomname: \"O5'\" },\n { atomname: 'O5*' },\n { atomname: \"HO5'\"},\n { atomname: \"C5'\" },\n { atomname: 'C5*' },\n { atomname: \"H5'\" },\n { atomname: \"H5''\"}\n ]\n }\n ]\n }\n ]\n })\n continue\n }\n\n if (cu === 'APOLARH') {\n pushRule({\n operator: 'AND',\n negate: false,\n rules: [\n { element: 'H' },\n {\n negate: true,\n operator: undefined,\n rules: [\n { keyword: kwd.POLARH }\n ]\n }\n ]\n })\n continue\n }\n\n if (cu === 'LIGAND') {\n pushRule({\n operator: 'AND',\n rules: [\n {\n operator: 'OR',\n rules: [\n {\n operator: 'AND',\n rules: [\n { keyword: kwd.HETERO },\n {\n negate: true,\n operator: undefined,\n rules: [\n { keyword: kwd.POLYMER }\n ]\n }\n ]\n },\n {\n negate: true,\n operator: undefined,\n rules: [\n { keyword: kwd.POLYMER }\n ]\n }\n ]\n },\n {\n negate: true,\n operator: undefined,\n rules: [\n {\n operator: 'OR',\n rules: [\n { keyword: kwd.WATER },\n { keyword: kwd.ION }\n ]\n }\n ]\n }\n ]\n })\n continue\n }\n\n if (SelectAllKeyword.indexOf(cu) !== -1) {\n pushRule({ keyword: kwd.ALL })\n continue\n }\n\n // handle atom expressions\n\n if (c.charAt(0) === '@') {\n const indexList = c.substr(1).split(',').map(x => parseInt(x))\n indexList.sort(function (a, b) { return a - b })\n pushRule({ atomindex: indexList })\n continue\n }\n\n if (c.charAt(0) === '#') {\n console.error('# for element selection deprecated, use _')\n pushRule({ element: cu.substr(1) })\n continue\n }\n if (c.charAt(0) === '_') {\n pushRule({ element: cu.substr(1) })\n continue\n }\n\n if (c[0] === '[' && c[c.length - 1] === ']') {\n const resnameList = cu.substr(1, c.length - 2).split(',')\n const resname = resnameList.length > 1 ? resnameList : resnameList[ 0 ]\n pushRule({ resname: resname })\n continue\n } else if (\n (c.length >= 1 && c.length <= 4) &&\n c[0] !== '^' && c[0] !== ':' && c[0] !== '.' && c[0] !== '%' && c[0] !== '/' &&\n isNaN(parseInt(c))\n ) {\n pushRule({ resname: cu })\n continue\n }\n\n // there must be only one constraint per rule\n // otherwise a test quickly becomes not applicable\n // e.g. chainTest for chainname when resno is present too\n\n const sele: SelectionRule = {\n operator: 'AND',\n rules: []\n }\n\n const model = c.split('/')\n if (model.length > 1 && model[1]) {\n if (isNaN(parseInt(model[1]))) {\n throw new Error('model must be an integer')\n }\n sele.rules!.push({\n model: parseInt(model[1])\n })\n }\n\n const altloc = model[0].split('%')\n if (altloc.length > 1) {\n sele.rules!.push({\n altloc: altloc[1]\n })\n }\n\n const atomname = altloc[0].split('.')\n if (atomname.length > 1 && atomname[1]) {\n if (atomname[1].length > 4) {\n throw new Error('atomname must be one to four characters')\n }\n sele.rules!.push({\n atomname: atomname[1].substring(0, 4).toUpperCase()\n })\n }\n\n const chain = atomname[0].split(':')\n if (chain.length > 1 && chain[1]) {\n sele.rules!.push({\n chainname: chain[1]\n })\n }\n\n const inscode = chain[0].split('^')\n if (inscode.length > 1) {\n sele.rules!.push({\n inscode: inscode[1]\n })\n }\n\n if (inscode[0]) {\n let negate, negate2\n if (inscode[0][0] === '-') {\n inscode[0] = inscode[0].substr(1)\n negate = true\n }\n if (inscode[0].includes('--')) {\n inscode[0] = inscode[0].replace('--', '-')\n negate2 = true\n }\n let resi = inscode[0].split('-')\n if (resi.length === 1) {\n let resiSingle = parseInt(resi[0])\n if (isNaN(resiSingle)) {\n throw new Error('resi must be an integer')\n }\n if (negate) resiSingle *= -1\n sele.rules!.push({\n resno: resiSingle\n })\n } else if (resi.length === 2) {\n const resiRange = resi.map(x => parseInt(x))\n if (negate) resiRange[0] *= -1\n if (negate2) resiRange[1] *= -1\n sele.rules!.push({\n resno: [resiRange[0], resiRange[1]]\n })\n } else {\n throw new Error(\"resi range must contain one '-'\")\n }\n }\n\n // round up\n\n if (sele.rules!.length === 1) {\n pushRule(sele.rules![ 0 ])\n } else if (sele.rules!.length > 1) {\n pushRule(sele)\n } else {\n throw new Error('empty selection chunk')\n }\n }\n\n // cleanup\n\n if (\n retSelection.operator === undefined &&\n retSelection.rules!.length === 1 &&\n retSelection.rules![ 0 ].hasOwnProperty('operator')\n ) {\n retSelection = retSelection.rules![ 0 ]\n }\n\n return retSelection\n}\n\nexport {\n parseSele\n}\n","/**\n * @file Selection Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { Color } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport Selection from '../selection/selection'\nimport Colormaker, { ColormakerParameters } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Structure from '../structure/structure'\n\nexport type SelectionSchemeData = [ string, string, ColormakerParameters|undefined ]\n\n/**\n * Color based on {@link Selection}\n */\nclass SelectionColormaker extends Colormaker {\n colormakerList: any[] = [] // TODO\n selectionList: Selection[] = []\n\n constructor (params: { structure: Structure, dataList: SelectionSchemeData[] } & Partial) {\n super(params)\n\n const dataList = params.dataList || []\n\n dataList.forEach((data: SelectionSchemeData) => {\n const [ scheme, sele, params = {} ] = data\n\n if (ColormakerRegistry.hasScheme(scheme)) {\n Object.assign(params, {\n scheme: scheme,\n structure: this.parameters.structure\n })\n } else {\n Object.assign(params, {\n scheme: 'uniform',\n value: new Color(scheme).getHex()\n })\n }\n\n this.colormakerList.push(ColormakerRegistry.getScheme(params as { scheme: string } & ColormakerParameters))\n this.selectionList.push(new Selection(sele))\n })\n }\n\n // NOT NEEDED @manageColor\n atomColor (a: AtomProxy) {\n for (let i = 0, n = this.selectionList.length; i < n; ++i) {\n const test = this.selectionList[ i ].test\n if (test && test(a)) {\n return this.colormakerList[ i ].atomColor(a)\n }\n }\n\n return 0xFFFFFF\n }\n}\n\nexport default SelectionColormaker\n","/**\n * @file Colormaker Registry\n * @author Alexander Rose \n * @private\n */\n\nimport { generateUUID } from '../math/math-utils'\nimport Colormaker, { ColormakerParameters } from './colormaker'\nimport SelectionColormaker, { SelectionSchemeData } from './selection-colormaker'\nimport Structure from '../structure/structure'\n\nconst ColormakerScales = {\n '': '',\n\n // Sequential\n OrRd: '[S] Orange-Red',\n PuBu: '[S] Purple-Blue',\n BuPu: '[S] Blue-Purple',\n Oranges: '[S] Oranges',\n BuGn: '[S] Blue-Green',\n YlOrBr: '[S] Yellow-Orange-Brown',\n YlGn: '[S] Yellow-Green',\n Reds: '[S] Reds',\n RdPu: '[S] Red-Purple',\n Greens: '[S] Greens',\n YlGnBu: '[S] Yellow-Green-Blue',\n Purples: '[S] Purples',\n GnBu: '[S] Green-Blue',\n Greys: '[S] Greys',\n YlOrRd: '[S] Yellow-Orange-Red',\n PuRd: '[S] Purple-Red',\n Blues: '[S] Blues',\n PuBuGn: '[S] Purple-Blue-Green',\n\n // Diverging\n Viridis: '[D] Viridis',\n Spectral: '[D] Spectral',\n RdYlGn: '[D] Red-Yellow-Green',\n RdBu: '[D] Red-Blue',\n PiYG: '[D] Pink-Yellowgreen',\n PRGn: '[D] Purplered-Green',\n RdYlBu: '[D] Red-Yellow-Blue',\n BrBG: '[D] Brown-Bluegreen',\n RdGy: '[D] Red-Grey',\n PuOr: '[D] Purple-Orange',\n\n // Qualitative\n Set1: '[Q] Set1',\n Set2: '[Q] Set2',\n Set3: '[Q] Set3',\n Dark2: '[Q] Dark2',\n Paired: '[Q] Paired',\n Pastel1: '[Q] Pastel1',\n Pastel2: '[Q] Pastel2',\n Accent: '[Q] Accent',\n\n // Other\n rainbow: '[?] Rainbow',\n rwb: '[?] Red-White-Blue'\n}\n\nconst ColormakerModes = {\n '': '',\n\n rgb: 'Red Green Blue',\n hsv: 'Hue Saturation Value',\n hsl: 'Hue Saturation Lightness',\n hsi: 'Hue Saturation Intensity',\n lab: 'CIE L*a*b*',\n hcl: 'Hue Chroma Lightness'\n}\n\n/**\n * Class for registering {@link Colormaker}s. Generally use the\n * global {@link src/globals.js~ColormakerRegistry} instance.\n */\nclass ColormakerRegistry {\n schemes: { [k: string]: any }\n userSchemes: { [k: string]: any }\n\n constructor () {\n this.schemes = {}\n this.userSchemes = {}\n }\n\n getScheme (params: Partial<{ scheme: string } & ColormakerParameters>) {\n const p = params || {}\n const id = (p.scheme || '').toLowerCase()\n\n let SchemeClass\n\n if (id in this.schemes) {\n SchemeClass = this.schemes[ id ]\n } else if (id in this.userSchemes) {\n SchemeClass = this.userSchemes[ id ]\n } else {\n SchemeClass = Colormaker\n }\n\n return new SchemeClass(params)\n }\n\n /**\n * Get an description of available schemes as an\n * object with id-label as key-value pairs\n * @return {Object} available schemes\n */\n getSchemes () {\n const types: { [k: string]: any } = {}\n\n Object.keys(this.schemes).forEach(function (k) {\n types[ k ] = k\n })\n\n Object.keys(this.userSchemes).forEach(function (k) {\n types[ k ] = k.split('|')[ 1 ]\n })\n\n return types\n }\n\n /**\n * Get an description of available scales as an\n * object with id-label as key-value pairs\n * @return {Object} available scales\n */\n getScales () {\n return ColormakerScales\n }\n\n getModes () {\n return ColormakerModes\n }\n\n /**\n * Add a scheme with a hardcoded id\n * @param {String} id - the id\n * @param {Colormaker} scheme - the colormaker\n * @return {undefined}\n */\n add (id: string, scheme: typeof Colormaker) {\n id = id.toLowerCase()\n this.schemes[ id ] = scheme\n }\n\n /**\n * Register a custom scheme\n *\n * @example\n * // Create a class with a `atomColor` method that returns a hex color.\n * var schemeId = NGL.ColormakerRegistry.addScheme( function( params ){\n * this.atomColor = function( atom ){\n * if( atom.serial < 1000 ){\n * return 0x0000FF; // blue\n * }else if( atom.serial > 2000 ){\n * return 0xFF0000; // red\n * }else{\n * return 0x00FF00; // green\n * }\n * };\n * } );\n *\n * stage.loadFile( \"rcsb://3dqb.pdb\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\", { color: schemeId } ); // pass schemeId here\n * o.autoView();\n * } );\n *\n * @param {Function|Colormaker} scheme - constructor or {@link Colormaker} instance\n * @param {String} label - scheme label\n * @return {String} id to refer to the registered scheme\n */\n addScheme (scheme: any, label?: string) {\n if (!(scheme instanceof Colormaker)) {\n scheme = this._createScheme(scheme)\n }\n\n return this._addUserScheme(scheme, label)\n }\n\n /**\n * Add a user-defined scheme\n * @param {Colormaker} scheme - the user-defined scheme\n * @param {String} [label] - scheme label\n * @return {String} id to refer to the registered scheme\n */\n _addUserScheme (scheme: any, label?: string) {\n label = label || ''\n const id = `${generateUUID()}|${label}`.toLowerCase()\n this.userSchemes[ id ] = scheme\n\n return id\n }\n\n /**\n * Remove the scheme with the given id\n * @param {String} id - scheme to remove\n * @return {undefined}\n */\n removeScheme (id: string) {\n id = id.toLowerCase()\n delete this.userSchemes[ id ]\n }\n\n _createScheme (constructor: any) {\n const _Colormaker = function (this: any, params: ColormakerParameters) {\n Colormaker.call(this, params)\n constructor.call(this, params)\n }\n\n _Colormaker.prototype = Colormaker.prototype\n _Colormaker.prototype.constructor = Colormaker\n\n return _Colormaker\n }\n\n /**\n * Create and a selection-based coloring scheme. Supply a list with pairs\n * of colorname and selection for coloring by selections. Use the last\n * entry as a default (catch all) coloring definition.\n *\n * @example\n * var schemeId = NGL.ColormakerRegistry.addSelectionScheme( [\n * [ \"red\", \"64-74 or 134-154 or 222-254 or 310-310 or 322-326\" ],\n * [ \"green\", \"311-322\" ],\n * [ \"yellow\", \"40-63 or 75-95 or 112-133 or 155-173 or 202-221 or 255-277 or 289-309\" ],\n * [ \"blue\", \"1-39 or 96-112 or 174-201 or 278-288\" ],\n * [ \"white\", \"*\" ]\n * ], \"Transmembrane 3dqb\" );\n *\n * stage.loadFile( \"rcsb://3dqb.pdb\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\", { color: schemeId } ); // pass schemeId here\n * o.autoView();\n * } );\n *\n * @param {Array} dataList - cloror-selection pairs\n * @param {String} label - scheme name\n * @return {String} id to refer to the registered scheme\n */\n addSelectionScheme (dataList: SelectionSchemeData[], label?: string) {\n class MySelectionColormaker extends SelectionColormaker {\n constructor (params: { structure: Structure } & ColormakerParameters) {\n super(Object.assign({ dataList }, params))\n }\n }\n\n return this._addUserScheme(MySelectionColormaker, label)\n }\n\n /**\n * Check if a scheme with the given id exists\n * @param {String} id - the id to check\n * @return {Boolean} flag indicating if the scheme exists\n */\n hasScheme (id: string) {\n id = id.toLowerCase()\n return id in this.schemes || id in this.userSchemes\n }\n}\n\nexport default ColormakerRegistry\n","/**\n * @file Worker Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { uniqueArray } from '../utils'\n\nexport type FunctionWithDeps = { __deps?: Function[] } & Function\nexport interface WorkerEvent {\n data: {\n __name: string\n __postId: string\n }\n}\n\nfunction getWorkerDeps (vars: FunctionWithDeps[]) {\n const deps = vars\n vars.forEach(function (sym) {\n if (sym.__deps) {\n Array.prototype.push.apply(deps, getWorkerDeps(sym.__deps))\n }\n })\n return deps\n}\n\nfunction makeWorkerString (vars: any) {\n const deps = uniqueArray(getWorkerDeps(vars))\n return deps.map(function (sym) {\n return sym.toString()\n }).join('\\n\\n\\n')\n}\n\nfunction onmessage (e: WorkerEvent) {\n const name = e.data.__name\n const postId = e.data.__postId\n\n /* global self */\n if (name === undefined) {\n console.error('message __name undefined')\n } else if ((self as any).func === undefined) {\n console.error('worker func undefined', name)\n } else {\n const callback = function (aMessage: any, transferList: any[]) {\n aMessage = aMessage || {}\n if (postId !== undefined) aMessage.__postId = postId\n\n try {\n (self as any).postMessage(aMessage, transferList)\n } catch (error) {\n console.error('self.postMessage:', error);\n (self as any).postMessage(aMessage)\n }\n };\n (self as any).func(e, callback)\n }\n}\n\nexport function makeWorkerBlob (func: Function, deps: Function[]) {\n let str = \"'use strict';\\n\\n\" + makeWorkerString(deps)\n str += '\\n\\n\\nself.func = ' + func.toString() + ';'\n str += '\\n\\n\\nself.onmessage = ' + onmessage.toString() + ';'\n // console.log(str);\n return new Blob([ str ], { type: 'application/javascript' })\n}\n","/**\n * @file Globals\n * @author Alexander Rose \n * @private\n */\n\nimport { getBrowser, getQuery, boolean } from './utils'\nimport Registry from './utils/registry'\nimport _ColormakerRegistry from './color/colormaker-registry'\nimport _ParserRegistry from './parser/parser-registry'\nimport _WorkerRegistry from './worker/worker-registry'\nimport { MeasurementRepresentationParameters } from './representation/measurement-representation';\n\n/**\n * The browser name: \"Opera\", \"Chrome\", \"Firefox\", \"Mobile Safari\",\n * \"Internet Explorer\", \"Safari\" or false.\n */\nexport const Browser = getBrowser()\n\n/**\n * Flag indicating support for the 'passive' option for event handler\n */\nexport let SupportsPassiveEventHandler = false\ntry {\n // Test via a getter in the options object to see if the passive property is accessed\n const opts = Object.defineProperty({}, 'passive', {\n get: function () {\n SupportsPassiveEventHandler = true\n }\n })\n window.addEventListener('test', e => {}, opts)\n} catch (e) {}\n\n/**\n * Flag indicating a mobile browser\n */\nexport const Mobile = typeof window !== 'undefined' ? typeof window.orientation !== 'undefined' : false\n\nexport let SupportsReadPixelsFloat = false\nexport function setSupportsReadPixelsFloat (value: boolean) {\n SupportsReadPixelsFloat = value\n}\n\n/**\n * Flag indicating support for the `EXT_frag_depth` WebGL extension\n * (Always present in WebGL2)\n */\nexport let ExtensionFragDepth = false\nexport function setExtensionFragDepth (value: boolean) {\n ExtensionFragDepth = value\n}\n\nexport const Log = {\n log: Function.prototype.bind.call(console.log, console),\n info: Function.prototype.bind.call(console.info, console),\n warn: Function.prototype.bind.call(console.warn, console),\n error: Function.prototype.bind.call(console.error, console),\n time: Function.prototype.bind.call(console.time, console),\n timeEnd: Function.prototype.bind.call(console.timeEnd, console)\n}\n\nexport let MeasurementDefaultParams: Partial = {\n color: 'green',\n labelColor: 0x808080,\n labelAttachment: 'bottom-center',\n labelSize: 0.7,\n labelZOffset: 0.5,\n labelYOffset: 0.1,\n labelBorder: true,\n labelBorderColor: 0xd3d3d3,\n labelBorderWidth: 0.25,\n lineOpacity: 0.8,\n linewidth: 5.0,\n opacity: 0.6,\n\n labelUnit: 'angstrom',\n arcVisible: true,\n planeVisible: false\n}\nexport function setMeasurementDefaultParams (params = {}) {\n Object.assign(MeasurementDefaultParams, params)\n}\n\nexport let Debug = boolean(getQuery('debug'))\nexport function setDebug (value: boolean) {\n Debug = value\n}\n\nexport const WebglErrorMessage = '

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

Find out how to get it here.

'\n\n/**\n * List of file extensions to be recognized as scripts\n */\nexport const ScriptExtensions = [ 'ngl', 'js' ]\n\nexport const WorkerRegistry = new _WorkerRegistry()\nexport const ColormakerRegistry = new _ColormakerRegistry()\nexport const DatasourceRegistry = new Registry('datasource')\nexport const RepresentationRegistry = new Registry('representatation')\nexport const ParserRegistry = new _ParserRegistry()\nexport const ShaderRegistry = new Registry('shader')\nexport const DecompressorRegistry = new Registry('decompressor')\nexport const ComponentRegistry = new Registry('component')\nexport const BufferRegistry = new Registry('buffer')\nexport const PickerRegistry = new Registry('picker')\n\nexport let ListingDatasource: any\nexport function setListingDatasource (value: any) {\n ListingDatasource = value\n}\n\nexport let TrajectoryDatasource: any // TODO should accept mdsrvDatasource\nexport function setTrajectoryDatasource (value: any) {\n TrajectoryDatasource = value\n}\n","/**\n * @file Worker Registry\n * @author Alexander Rose \n * @private\n */\n\nimport { makeWorkerBlob } from './worker-utils'\n\nclass WorkerRegistry {\n activeWorkerCount = 0\n\n private _funcDict: { [k: string]: Function } = {}\n private _depsDict: { [k: string]: Function[] } = {}\n private _blobDict: { [k: string]: Blob } = {}\n\n add (name: string, func: Function, deps: Function[]) {\n this._funcDict[ name ] = func\n this._depsDict[ name ] = deps\n }\n\n get (name: string) {\n if (!this._blobDict[ name ]) {\n this._blobDict[ name ] = makeWorkerBlob(\n this._funcDict[ name ], this._depsDict[ name ]\n )\n }\n return this._blobDict[ name ]\n }\n}\n\nexport default WorkerRegistry\n","/**\n * @file Parser Registry\n * @author Alexander Rose \n * @private\n */\n\nimport Registry from '../utils/registry'\n\nclass ParserRegistry extends Registry {\n constructor () {\n super('parser')\n }\n\n __hasObjName (key: string, objName: string) {\n const parser = this.get(key)\n return parser && parser.prototype.__objName === objName\n }\n\n isTrajectory (key: string) {\n return this.__hasObjName(key, 'frames')\n }\n\n isStructure (key: string) {\n return this.__hasObjName(key, 'structure')\n }\n\n isVolume (key: string) {\n return this.__hasObjName(key, 'volume')\n }\n\n isSurface (key: string) {\n return this.__hasObjName(key, 'surface')\n }\n\n isBinary (key: string) {\n const parser = this.get(key)\n return parser && parser.prototype.isBinary\n }\n\n isXml (key: string) {\n const parser = this.get(key)\n return parser && parser.prototype.isXml\n }\n\n isJson (key: string) {\n const parser = this.get(key)\n return parser && parser.prototype.isJson\n }\n\n getTrajectoryExtensions () {\n return this.names.filter(name => this.isTrajectory(name))\n }\n\n getStructureExtensions () {\n return this.names.filter(name => this.isStructure(name))\n }\n\n getVolumeExtensions () {\n return this.names.filter(name => this.isVolume(name))\n }\n\n getSurfaceExtensions () {\n return this.names.filter(name => this.isSurface(name))\n }\n}\n\nexport default ParserRegistry\n","/**\n * @file Streamer\n * @author Alexander Rose \n * @private\n */\n\nimport { DecompressorRegistry } from '../globals'\nimport { uint8ToString, defaults } from '../utils'\n\nexport interface StreamerParams {\n compressed?: string|false\n binary?: boolean\n json?: boolean\n xml?: boolean\n}\n\nabstract class Streamer {\n src: any\n data: any\n\n compressed: string|false\n binary: boolean\n json: boolean\n xml: boolean\n\n chunkSize = 1024 * 1024 * 10\n newline = '\\n'\n\n protected __pointer = 0\n protected __partialLine = ''\n\n constructor (src: any, params: StreamerParams = {}) {\n this.compressed = defaults(params.compressed, false)\n this.binary = defaults(params.binary, false)\n this.json = defaults(params.json, false)\n this.xml = defaults(params.xml, false)\n\n this.src = src\n }\n\n isBinary () {\n return this.binary || this.compressed\n }\n\n read () {\n return this._read().then(data => {\n const decompressFn = this.compressed ? DecompressorRegistry.get(this.compressed) : undefined\n\n if (this.compressed && decompressFn) {\n this.data = decompressFn(data)\n } else {\n if ((this.binary || this.compressed) && data instanceof ArrayBuffer) {\n data = new Uint8Array(data)\n }\n this.data = data\n }\n\n return this.data\n })\n }\n\n protected abstract _read (): Promise\n\n protected _chunk (start: number, end: number) {\n end = Math.min(this.data.length, end)\n\n if (start === 0 && this.data.length === end) {\n return this.data\n } else {\n if (this.isBinary()) {\n return this.data.subarray(start, end)\n } else {\n return this.data.substring(start, end)\n }\n }\n }\n\n chunk (start: number) {\n const end = start + this.chunkSize\n\n return this._chunk(start, end)\n }\n\n peekLines (m: number) {\n const data = this.data\n const n = data.length\n\n // FIXME does not work for multi-char newline\n const newline = this.isBinary() ? this.newline.charCodeAt(0) : this.newline\n\n let i\n let count = 0\n for (i = 0; i < n; ++i) {\n if (data[ i ] === newline) ++count\n if (count === m) break\n }\n\n const chunk = this._chunk(0, i + 1)\n const d = this.chunkToLines(chunk, '', i > n)\n\n return d.lines\n }\n\n chunkCount () {\n return Math.floor(this.data.length / this.chunkSize) + 1\n }\n\n asText () {\n return this.isBinary() ? uint8ToString(this.data) : this.data\n }\n\n chunkToLines (chunk: string|Uint8Array, partialLine: string, isLast: boolean) {\n const newline = this.newline\n\n if (!this.isBinary() && chunk.length === this.data.length) {\n return {\n lines: (chunk as string).split(newline),\n partialLine: ''\n }\n }\n\n let lines: string[] = []\n const str = this.isBinary() ? uint8ToString(chunk as Uint8Array) : chunk\n const idx = str.lastIndexOf(newline)\n\n if (idx === -1) {\n partialLine += str\n } else {\n const str2 = partialLine + str.substr(0, idx)\n lines = lines.concat(str2.split(newline))\n\n if (idx === str.length - newline.length) {\n partialLine = ''\n } else {\n partialLine = str.substr(idx + newline.length)\n }\n }\n\n if (isLast && partialLine !== '') {\n lines.push(partialLine)\n }\n\n return {\n lines: lines,\n partialLine: partialLine\n }\n }\n\n nextChunk () {\n const start = this.__pointer\n\n if (start > this.data.length) {\n return undefined\n }\n\n this.__pointer += this.chunkSize\n return this.chunk(start)\n }\n\n nextChunkOfLines () {\n const chunk = this.nextChunk()\n\n if (chunk === undefined) {\n return undefined\n }\n\n const isLast = this.__pointer > this.data.length\n const d = this.chunkToLines(chunk, this.__partialLine, isLast)\n\n this.__partialLine = d.partialLine\n\n return d.lines\n }\n\n eachChunk (callback: (chunk: string|Uint8Array, chunkNo: number, chunkCount: number) => void) {\n const chunkSize = this.chunkSize\n const n = this.data.length\n const chunkCount = this.chunkCount()\n\n for (let i = 0; i < n; i += chunkSize) {\n const chunk = this.chunk(i)\n const chunkNo = Math.round(i / chunkSize)\n\n callback(chunk, chunkNo, chunkCount)\n }\n }\n\n eachChunkOfLines (callback: (chunk: string[], chunkNo: number, chunkCount: number) => void) {\n this.eachChunk((chunk, chunkNo, chunkCount) => {\n const isLast = chunkNo === chunkCount + 1\n const d = this.chunkToLines(chunk, this.__partialLine, isLast)\n\n this.__partialLine = d.partialLine\n\n callback(d.lines, chunkNo, chunkCount)\n })\n }\n\n dispose () {\n delete this.src\n }\n}\n\nexport default Streamer\n","/**\n * @file File Streamer\n * @author Alexander Rose \n * @private\n */\n\nimport Streamer from './streamer'\n\ninterface FileReaderEventTarget extends EventTarget {\n result:string | ArrayBuffer | null\n}\n\ninterface FileReaderEvent extends ProgressEvent {\n target: FileReaderEventTarget | null;\n}\n\nclass FileStreamer extends Streamer {\n _read () {\n return new Promise((resolve, reject) => {\n const file = this.src\n const reader = new FileReader()\n\n reader.onload = (event: FileReaderEvent) => {\n if(event.target) resolve(event.target.result)\n }\n\n // if (typeof this.onprogress === 'function') {\n // reader.onprogress = event => this.onprogress(event)\n // }\n\n reader.onerror = event => reject(event)\n\n if (this.binary || this.compressed) {\n reader.readAsArrayBuffer(file)\n } else {\n reader.readAsText(file)\n }\n })\n }\n}\n\nexport default FileStreamer\n","/**\n * @file Network Streamer\n * @author Alexander Rose \n * @private\n */\n\nimport Streamer from './streamer'\n\nclass NetworkStreamer extends Streamer {\n _read () {\n return new Promise((resolve, reject) => {\n const url = this.src\n const xhr = new XMLHttpRequest()\n\n xhr.open('GET', url, true)\n\n xhr.addEventListener('load', () => {\n if (xhr.status === 200 || xhr.status === 304 ||\n // when requesting from local file system\n // the status in Google Chrome/Chromium is 0\n xhr.status === 0\n ) {\n try {\n resolve(xhr.response)\n } catch (e) {\n reject(e)\n }\n } else {\n reject(xhr.statusText)\n }\n }, false)\n\n // if (typeof this.onprogress === 'function') {\n // xhr.addEventListener('progress', event => this.onprogress(event), false);\n // }\n\n xhr.addEventListener('error', event => reject('network error'), false)\n\n if (this.isBinary()) {\n xhr.responseType = 'arraybuffer'\n } else if (this.json) {\n xhr.responseType = 'json'\n } else if (this.xml) {\n xhr.responseType = 'document'\n } else {\n xhr.responseType = 'text'\n }\n // xhr.crossOrigin = true;\n\n xhr.send()\n })\n }\n}\n\nexport default NetworkStreamer\n","/**\n * @file Loader\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport { createParams } from '../utils'\nimport FileStreamer from '../streamer/file-streamer'\nimport NetworkStreamer from '../streamer/network-streamer'\nimport { LoaderParameters, LoaderInput } from './loader-utils'\n\n/**\n * Loader parameter object.\n * @typedef {Object} LoaderParameters - loader parameters\n * @property {String} ext - file extension, determines file type\n * @property {Boolean} compressed - flag data as compressed\n * @property {Boolean} binary - flag data as binary\n * @property {String} name - set data name\n */\n\n/**\n * Loader base class\n */\nabstract class Loader {\n parameters: LoaderParameters\n streamer: FileStreamer | NetworkStreamer\n\n /**\n * Construct a loader object\n * @param {String|File|Blob} src - data source, string is interpreted as an URL\n * @param {LoaderParameters} params - parameters object\n */\n constructor (src: LoaderInput, params: Partial = {}) {\n this.parameters = createParams(params, {\n ext: '',\n compressed: false,\n binary: ParserRegistry.isBinary(params.ext || ''),\n name: '',\n\n dir: '',\n path: '',\n protocol: ''\n } as LoaderParameters)\n\n const streamerParams = {\n compressed: this.parameters.compressed as string|false,\n binary: this.parameters.binary,\n json: ParserRegistry.isJson(this.parameters.ext),\n xml: ParserRegistry.isXml(this.parameters.ext)\n }\n\n if ((typeof File !== 'undefined' && src instanceof File) ||\n (typeof Blob !== 'undefined' && src instanceof Blob)\n ) {\n this.streamer = new FileStreamer(src, streamerParams)\n } else {\n this.streamer = new NetworkStreamer(src, streamerParams)\n }\n }\n\n /**\n * Load data\n * @abstract\n * @return {Promise} resolves to the loaded data {@link Object}\n */\n abstract load (): Promise\n}\n\nexport default Loader\n","/**\n * @file Parser Loader\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport type { InferBondsOptions } from '../structure/structure-utils'\nimport Loader from './loader'\nimport { LoaderParameters, LoaderInput } from './loader-utils'\n\nexport interface ParserParams {\n voxelSize?: number\n firstModelOnly?: boolean\n asTrajectory?: boolean\n cAlphaOnly?: boolean\n name?: string\n path?: string\n delimiter?: string\n comment?: string\n columnNames?: string\n inferBonds?: InferBondsOptions\n}\n\n/**\n * Parser loader class\n * @extends Loader\n */\nclass ParserLoader extends Loader {\n parserParams: ParserParams\n\n constructor (src: LoaderInput, params: Partial & ParserParams = {}) {\n super(src, params)\n this.parserParams = {\n voxelSize: params.voxelSize,\n firstModelOnly: params.firstModelOnly,\n asTrajectory: params.asTrajectory,\n cAlphaOnly: params.cAlphaOnly,\n delimiter: params.delimiter,\n comment: params.comment,\n columnNames: params.columnNames,\n inferBonds: params.inferBonds,\n name: this.parameters.name,\n path: this.parameters.path\n }\n }\n\n /**\n * Load parsed object\n * @return {Promise} resolves to the loaded & parsed {@link Structure},\n * {@link Volume}, {@link Surface} or data object\n */\n load () {\n var ParserClass = ParserRegistry.get(this.parameters.ext)\n var parser = new ParserClass(this.streamer, this.parserParams)\n\n return parser.parse()\n }\n}\n\nexport default ParserLoader\n","/**\n * @file Script\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { Log } from './globals'\nimport Stage from './stage/stage'\n\nexport interface ScriptSignals {\n elementAdded: Signal\n elementRemoved: Signal\n nameChanged: Signal\n}\n\n/**\n * Script class\n */\nclass Script {\n readonly signals: ScriptSignals = {\n elementAdded: new Signal(),\n elementRemoved: new Signal(),\n nameChanged: new Signal()\n }\n\n readonly dir: string\n readonly fn: Function\n\n readonly type = 'Script'\n\n /**\n * Create a script instance\n * @param {String} functionBody - the function source\n * @param {String} name - name of the script\n * @param {String} path - path of the script\n */\n constructor (functionBody: string, readonly name: string, readonly path: string) {\n this.dir = path.substring(0, path.lastIndexOf('/') + 1)\n\n try {\n /* eslint-disable no-new-func */\n this.fn = new Function('stage', '__name', '__path', '__dir', functionBody)\n } catch (e) {\n Log.error('Script compilation failed', e)\n this.fn = function () {}\n }\n }\n\n /**\n * Execute the script\n * @param {Stage} stage - the stage context\n * @return {Promise} - resolve when script finished running\n */\n run (stage: Stage): Promise {\n return new Promise((resolve, reject) => {\n try {\n this.fn.apply(null, [ stage, this.name, this.path, this.dir ])\n resolve()\n } catch (e) {\n Log.error('Script.fn', e)\n reject(e)\n }\n })\n }\n}\n\nexport default Script\n","/**\n * @file Script Loader\n * @author Alexander Rose \n * @private\n */\n\nimport Loader from './loader'\nimport Script from '../script'\n\n/**\n * Script loader class\n * @extends Loader\n */\nclass ScriptLoader extends Loader {\n /**\n * Load script\n * @return {Promise} resolves to the loaded {@link Script}\n */\n load () {\n return this.streamer.read().then(() => {\n return new Script(\n this.streamer.asText(), this.parameters.name, this.parameters.path\n )\n })\n }\n}\n\nexport default ScriptLoader\n","/**\n * @file Loader Utils\n * @author Alexander Rose \n * @private\n */\n\nimport {\n DatasourceRegistry, DecompressorRegistry, ParserRegistry, ScriptExtensions\n} from '../globals'\nimport ParserLoader, { ParserParams } from './parser-loader'\nimport ScriptLoader from './script-loader'\n\nexport interface LoaderParameters {\n ext: string // file extension, determines file type\n compressed: string|false // flag data as compressed\n binary: boolean // flag data as binary\n name: string // set data name\n\n dir: string\n path: string\n protocol: string\n}\n\nexport type LoaderInput = File|Blob|string\n\nexport function getFileInfo (file: LoaderInput) {\n const compressedExtList = DecompressorRegistry.names\n\n let path: string\n let compressed: string|false\n let protocol = ''\n\n if (file instanceof File) {\n path = file.name\n } else if (file instanceof Blob) {\n path = ''\n } else {\n path = file\n }\n const queryIndex = path.lastIndexOf('?')\n const query = queryIndex !== -1 ? path.substring(queryIndex) : ''\n path = path.substring(0, queryIndex === -1 ? path.length : queryIndex)\n\n const name = path.replace(/^.*[\\\\/]/, '')\n let base = name.substring(0, name.lastIndexOf('.'))\n\n const nameSplit = name.split('.')\n let ext = nameSplit.length > 1 ? (nameSplit.pop() || '').toLowerCase() : ''\n\n const protocolMatch = path.match(/^(.+):\\/\\/(.+)$/)\n if (protocolMatch) {\n protocol = protocolMatch[ 1 ].toLowerCase()\n path = protocolMatch[ 2 ] || ''\n }\n\n const dir = path.substring(0, path.lastIndexOf('/') + 1)\n\n if (compressedExtList.includes(ext)) {\n compressed = ext\n const n = path.length - ext.length - 1\n ext = (path.substr(0, n).split('.').pop() || '').toLowerCase()\n const m = base.length - ext.length - 1\n base = base.substr(0, m)\n } else {\n compressed = false\n }\n\n return { path, name, ext, base, dir, compressed, protocol, query, 'src': file }\n}\n\nexport function getDataInfo (src: LoaderInput) {\n let info = getFileInfo(src)\n const datasource = DatasourceRegistry.get(info.protocol)\n if (datasource) {\n info = getFileInfo(datasource.getUrl(info.src))\n if (!info.ext && datasource.getExt) {\n info.ext = datasource.getExt(src)\n }\n }\n return info\n}\n\n/**\n * Load a file\n *\n * @example\n * // load from URL\n * NGL.autoLoad( \"http://files.rcsb.org/download/5IOS.cif\" );\n *\n * @example\n * // load binary data in CCP4 format via a Blob\n * var binaryBlob = new Blob( [ ccp4Data ], { type: 'application/octet-binary'} );\n * NGL.autoLoad( binaryBlob, { ext: \"ccp4\" } );\n *\n * @example\n * // load string data in PDB format via a Blob\n * var stringBlob = new Blob( [ pdbData ], { type: 'text/plain'} );\n * NGL.autoLoad( stringBlob, { ext: \"pdb\" } );\n *\n * @example\n * // load a File object\n * NGL.autoLoad( file );\n *\n * @param {String|File|Blob} file - either a URL or an object containing the file data\n * @param {LoaderParameters} params - loading parameters\n * @return {Promise} Promise resolves to the loaded data\n */\nexport function autoLoad (file: LoaderInput, params: Partial = {}) {\n const p = Object.assign(getDataInfo(file), params)\n\n let loader\n if (ParserRegistry.names.includes(p.ext)) {\n loader = new ParserLoader(p.src, p)\n } else if (ScriptExtensions.includes(p.ext)) {\n loader = new ScriptLoader(p.src, p)\n }\n\n if (loader) {\n return loader.load()\n } else {\n return Promise.reject(new Error(`autoLoad: ext '${p.ext}' unknown`))\n }\n}\n","/**\n * @file Writer\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults, download } from '../utils'\n\n/**\n * Base class for writers\n * @interface\n */\nabstract class Writer {\n readonly mimeType: string\n readonly defaultName: string\n readonly defaultExt: string\n\n /**\n * @abstract\n * @return {Anything} the data to be written\n */\n abstract getData (): any\n\n /**\n * Get a blob with the written data\n * @return {Blob} the blob\n */\n getBlob () {\n return new Blob([ this.getData() ], { type: this.mimeType })\n }\n\n /**\n * Trigger a download of the\n * @param {[type]} name [description]\n * @param {[type]} ext [description]\n * @return {[type]} [description]\n */\n download (name?: string, ext?: string) {\n name = defaults(name, this.defaultName)\n ext = defaults(ext, this.defaultExt)\n\n download(this.getBlob(), `${name}.${ext}`)\n }\n}\n\nexport default Writer","/**\n * @file IO Buffer\n * @author Alexander Rose \n * @private\n *\n * Adapted and converted to TypeScript from https://github.com/image-js/iobuffer\n * MIT License, Copyright (c) 2015 Michaël Zasso\n */\n\nimport { TypedArray } from '../types'\n\nconst defaultByteLength = 1024 * 8\nconst charArray: string[] = []\n\nexport interface IOBufferParameters {\n offset?: number // Ignore the first n bytes of the ArrayBuffer\n}\n\n/**\n * Class for writing and reading binary data\n */\nclass IOBuffer {\n private _lastWrittenByte: number\n private _mark = 0\n private _marks: number[] = []\n private _data: DataView\n\n offset = 0 // The current offset of the buffer's pointer\n littleEndian = true\n buffer: ArrayBuffer // Reference to the internal ArrayBuffer object\n length: number // Byte length of the internal ArrayBuffer\n byteLength: number // Byte length of the internal ArrayBuffer\n byteOffset: number // Byte offset of the internal ArrayBuffer\n\n /**\n * If it's a number, it will initialize the buffer with the number as\n * the buffer's length. If it's undefined, it will initialize the buffer\n * with a default length of 8 Kb. If its an ArrayBuffer, a TypedArray,\n * it will create a view over the underlying ArrayBuffer.\n */\n constructor (data: number|ArrayBuffer|TypedArray, params: IOBufferParameters = {}) {\n let dataIsGiven = false\n if (data === undefined) {\n data = defaultByteLength\n }\n if (typeof data === 'number') {\n data = new ArrayBuffer(data)\n } else {\n dataIsGiven = true\n }\n\n const offset = params.offset ? params.offset >>> 0 : 0\n let byteLength = data.byteLength - offset\n let dvOffset = offset\n if (!(data instanceof ArrayBuffer)) {\n if (data.byteLength !== data.buffer.byteLength) {\n dvOffset = data.byteOffset + offset\n }\n data = data.buffer\n }\n if (dataIsGiven) {\n this._lastWrittenByte = byteLength\n } else {\n this._lastWrittenByte = 0\n }\n\n this.buffer = data\n this.length = byteLength\n this.byteLength = byteLength\n this.byteOffset = dvOffset\n\n this._data = new DataView(this.buffer, dvOffset, byteLength)\n }\n\n /**\n * Checks if the memory allocated to the buffer is sufficient to store more bytes after the offset\n * @param {number} [byteLength=1] The needed memory in bytes\n * @return {boolean} Returns true if there is sufficient space and false otherwise\n */\n available (byteLength: number) {\n if (byteLength === undefined) byteLength = 1\n return (this.offset + byteLength) <= this.length\n }\n\n /**\n * Check if little-endian mode is used for reading and writing multi-byte values\n * @return {boolean} Returns true if little-endian mode is used, false otherwise\n */\n isLittleEndian () {\n return this.littleEndian\n }\n\n /**\n * Set little-endian mode for reading and writing multi-byte values\n * @return {IOBuffer}\n */\n setLittleEndian () {\n this.littleEndian = true\n return this\n }\n\n /**\n * Check if big-endian mode is used for reading and writing multi-byte values\n * @return {boolean} Returns true if big-endian mode is used, false otherwise\n */\n isBigEndian () {\n return !this.littleEndian\n }\n\n /**\n * Switches to big-endian mode for reading and writing multi-byte values\n * @return {IOBuffer}\n */\n setBigEndian () {\n this.littleEndian = false\n return this\n }\n\n /**\n * Move the pointer n bytes forward\n * @param {number} n\n * @return {IOBuffer}\n */\n skip (n: number) {\n if (n === undefined) n = 1\n this.offset += n\n return this\n }\n\n /**\n * Move the pointer to the given offset\n * @param {number} offset\n * @return {IOBuffer}\n */\n seek (offset: number) {\n this.offset = offset\n return this\n }\n\n /**\n * Store the current pointer offset.\n * @see {@link IOBuffer#reset}\n * @return {IOBuffer}\n */\n mark () {\n this._mark = this.offset\n return this\n }\n\n /**\n * Move the pointer back to the last pointer offset set by mark\n * @see {@link IOBuffer#mark}\n * @return {IOBuffer}\n */\n reset () {\n this.offset = this._mark\n return this\n }\n\n /**\n * Push the current pointer offset to the mark stack\n * @see {@link IOBuffer#popMark}\n * @return {IOBuffer}\n */\n pushMark () {\n this._marks.push(this.offset)\n return this\n }\n\n /**\n * Pop the last pointer offset from the mark stack, and set the current pointer offset to the popped value\n * @see {@link IOBuffer#pushMark}\n * @return {IOBuffer}\n */\n popMark () {\n const offset = this._marks.pop()\n if (offset === undefined) throw new Error('Mark stack empty')\n this.seek(offset)\n return this\n }\n\n /**\n * Move the pointer offset back to 0\n * @return {IOBuffer}\n */\n rewind () {\n this.offset = 0\n return this\n }\n\n /**\n * Make sure the buffer has sufficient memory to write a given byteLength at the current pointer offset\n * If the buffer's memory is insufficient, this method will create a new buffer (a copy) with a length\n * that is twice (byteLength + current offset)\n * @param {number} [byteLength = 1]\n * @return {IOBuffer}\n */\n ensureAvailable (byteLength: number) {\n if (byteLength === undefined) byteLength = 1\n if (!this.available(byteLength)) {\n const lengthNeeded = this.offset + byteLength\n const newLength = lengthNeeded * 2\n const newArray = new Uint8Array(newLength)\n newArray.set(new Uint8Array(this.buffer))\n this.buffer = newArray.buffer\n this.length = this.byteLength = newLength\n this._data = new DataView(this.buffer)\n }\n return this\n }\n\n /**\n * Read a byte and return false if the byte's value is 0, or true otherwise\n * Moves pointer forward\n * @return {boolean}\n */\n readBoolean () {\n return this.readUint8() !== 0\n }\n\n /**\n * Read a signed 8-bit integer and move pointer forward\n * @return {number}\n */\n readInt8 () {\n return this._data.getInt8(this.offset++)\n }\n\n /**\n * Read an unsigned 8-bit integer and move pointer forward\n * @return {number}\n */\n readUint8 () {\n return this._data.getUint8(this.offset++)\n }\n\n /**\n * Alias for {@link IOBuffer#readUint8}\n * @return {number}\n */\n readByte () {\n return this.readUint8()\n }\n\n /**\n * Read n bytes and move pointer forward.\n * @param {number} n\n * @return {Uint8Array}\n */\n readBytes (n: number) {\n if (n === undefined) n = 1\n var bytes = new Uint8Array(n)\n for (var i = 0; i < n; i++) {\n bytes[i] = this.readByte()\n }\n return bytes\n }\n\n /**\n * Read a 16-bit signed integer and move pointer forward\n * @return {number}\n */\n readInt16 () {\n var value = this._data.getInt16(this.offset, this.littleEndian)\n this.offset += 2\n return value\n }\n\n /**\n * Read a 16-bit unsigned integer and move pointer forward\n * @return {number}\n */\n readUint16 () {\n var value = this._data.getUint16(this.offset, this.littleEndian)\n this.offset += 2\n return value\n }\n\n /**\n * Read a 32-bit signed integer and move pointer forward\n * @return {number}\n */\n readInt32 () {\n var value = this._data.getInt32(this.offset, this.littleEndian)\n this.offset += 4\n return value\n }\n\n /**\n * Read a 32-bit unsigned integer and move pointer forward\n * @return {number}\n */\n readUint32 () {\n var value = this._data.getUint32(this.offset, this.littleEndian)\n this.offset += 4\n return value\n }\n\n /**\n * Read a 32-bit floating number and move pointer forward\n * @return {number}\n */\n readFloat32 () {\n var value = this._data.getFloat32(this.offset, this.littleEndian)\n this.offset += 4\n return value\n }\n\n /**\n * Read a 64-bit floating number and move pointer forward\n * @return {number}\n */\n readFloat64 () {\n var value = this._data.getFloat64(this.offset, this.littleEndian)\n this.offset += 8\n return value\n }\n\n /**\n * Read 1-byte ascii character and move pointer forward\n * @return {string}\n */\n readChar () {\n return String.fromCharCode(this.readInt8())\n }\n\n /**\n * Read n 1-byte ascii characters and move pointer forward\n * @param {number} n\n * @return {string}\n */\n readChars (n = 1) {\n charArray.length = n\n for (var i = 0; i < n; i++) {\n charArray[i] = this.readChar()\n }\n return charArray.join('')\n }\n\n /**\n * Write 0xff if the passed value is truthy, 0x00 otherwise\n * @param {any} value\n * @return {IOBuffer}\n */\n writeBoolean (value = false) {\n this.writeUint8(value ? 0xff : 0x00)\n return this\n }\n\n /**\n * Write value as an 8-bit signed integer\n * @param {number} value\n * @return {IOBuffer}\n */\n writeInt8 (value: number) {\n this.ensureAvailable(1)\n this._data.setInt8(this.offset++, value)\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write value as a 8-bit unsigned integer\n * @param {number} value\n * @return {IOBuffer}\n */\n writeUint8 (value: number) {\n this.ensureAvailable(1)\n this._data.setUint8(this.offset++, value)\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * An alias for {@link IOBuffer#writeUint8}\n * @param {number} value\n * @return {IOBuffer}\n */\n writeByte (value: number) {\n return this.writeUint8(value)\n }\n\n /**\n * Write bytes\n * @param {Array|Uint8Array} bytes\n * @return {IOBuffer}\n */\n writeBytes (bytes: number[]|Uint8Array) {\n this.ensureAvailable(bytes.length)\n for (var i = 0; i < bytes.length; i++) {\n this._data.setUint8(this.offset++, bytes[i])\n }\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write value as an 16-bit signed integer\n * @param {number} value\n * @return {IOBuffer}\n */\n writeInt16 (value: number) {\n this.ensureAvailable(2)\n this._data.setInt16(this.offset, value, this.littleEndian)\n this.offset += 2\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write value as a 16-bit unsigned integer\n * @param {number} value\n * @return {IOBuffer}\n */\n writeUint16 (value: number) {\n this.ensureAvailable(2)\n this._data.setUint16(this.offset, value, this.littleEndian)\n this.offset += 2\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write a 32-bit signed integer at the current pointer offset\n * @param {number} value\n * @return {IOBuffer}\n */\n writeInt32 (value: number) {\n this.ensureAvailable(4)\n this._data.setInt32(this.offset, value, this.littleEndian)\n this.offset += 4\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write a 32-bit unsigned integer at the current pointer offset\n * @param {number} value - The value to set\n * @return {IOBuffer}\n */\n writeUint32 (value: number) {\n this.ensureAvailable(4)\n this._data.setUint32(this.offset, value, this.littleEndian)\n this.offset += 4\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write a 32-bit floating number at the current pointer offset\n * @param {number} value - The value to set\n * @return {IOBuffer}\n */\n writeFloat32 (value: number) {\n this.ensureAvailable(4)\n this._data.setFloat32(this.offset, value, this.littleEndian)\n this.offset += 4\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write a 64-bit floating number at the current pointer offset\n * @param {number} value\n * @return {IOBuffer}\n */\n writeFloat64 (value: number) {\n this.ensureAvailable(8)\n this._data.setFloat64(this.offset, value, this.littleEndian)\n this.offset += 8\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write the charCode of the passed string's first character to the current pointer offset\n * @param {string} str - The character to set\n * @return {IOBuffer}\n */\n writeChar (str: string) {\n return this.writeUint8(str.charCodeAt(0))\n }\n\n /**\n * Write the charCodes of the passed string's characters to the current pointer offset\n * @param {string} str\n * @return {IOBuffer}\n */\n writeChars (str: string) {\n for (var i = 0; i < str.length; i++) {\n this.writeUint8(str.charCodeAt(i))\n }\n return this\n }\n\n /**\n * Export a Uint8Array view of the internal buffer.\n * The view starts at the byte offset and its length\n * is calculated to stop at the last written byte or the original length.\n * @return {Uint8Array}\n */\n toArray () {\n return new Uint8Array(this.buffer, this.byteOffset, this._lastWrittenByte)\n }\n\n /**\n * Update the last written byte offset\n * @private\n */\n _updateLastWrittenByte () {\n if (this.offset > this._lastWrittenByte) {\n this._lastWrittenByte = this.offset\n }\n }\n}\n\nexport default IOBuffer\n","/**\n * @file Counter\n * @author Alexander Rose \n * @private\n */\n\nimport { Log } from '../globals'\n\nimport * as signalsWrapper from 'signals'\n\n/**\n * {@link Signal}, dispatched when the `count` changes\n * @example\n * counter.signals.countChanged.add( function( delta ){ ... } );\n * @event Counter#countChanged\n * @type {Integer}\n */\n\nexport interface CounterSignals {\n countChanged: signalsWrapper.Signal\n}\n\n/**\n * Counter class for keeping track of counts\n */\nclass Counter {\n count = 0\n\n signals: CounterSignals = {\n countChanged: new signalsWrapper.Signal()\n }\n\n /**\n * Set the `count` to zero\n * @return {undefined}\n */\n clear () {\n this.change(-this.count)\n }\n\n /**\n * Change the `count`\n * @fires Counter#countChanged\n * @param {Integer} delta - count change\n * @return {undefined}\n */\n change (delta: number) {\n this.count += delta\n this.signals.countChanged.dispatch(delta, this.count)\n\n if (this.count < 0) {\n Log.warn('Counter.count below zero', this.count)\n }\n }\n\n /**\n * Increments the `count` by one.\n * @return {undefined}\n */\n increment () {\n this.change(1)\n }\n\n /**\n * Decrements the `count` by one.\n * @return {undefined}\n */\n decrement () {\n this.change(-1)\n }\n\n /**\n * Listen to another counter object and change this `count` by the\n * same amount\n * @param {Counter} counter - the counter object to listen to\n * @return {undefined}\n */\n listen (counter: Counter) {\n this.change(counter.count)\n counter.signals.countChanged.add(this.change, this)\n }\n\n /**\n * Stop listening to the other counter object\n * @param {Counter} counter - the counter object to stop listening to\n * @return {undefined}\n */\n unlisten (counter: Counter) {\n const countChanged = counter.signals.countChanged\n if (countChanged.has(this.change, this)) {\n countChanged.remove(this.change, this)\n }\n }\n\n /**\n * Invole the callback function once, when the `count` becomes zero\n * @param {Function} callback - the callback function\n * @param {Object} context - the context for the callback function\n * @return {undefined}\n */\n onZeroOnce (callback: () => void, context?: any) {\n if (this.count === 0) {\n callback.call(context)\n } else {\n const fn = () => {\n if (this.count === 0) {\n this.signals.countChanged.remove(fn, this)\n callback.call(context)\n }\n }\n this.signals.countChanged.add(fn, this)\n }\n }\n\n dispose () {\n this.clear()\n this.signals.countChanged.dispose()\n }\n}\n\nexport default Counter\n","/**\n * @file Stats\n * @author Alexander Rose \n * @private\n */\n\nimport * as signalsWrapper from 'signals'\n\nexport default class Stats {\n signals = {\n updated: new signalsWrapper.Signal()\n }\n\n maxDuration = -Infinity\n minDuration = Infinity\n avgDuration = 14\n lastDuration = Infinity\n\n prevFpsTime = 0\n lastFps = Infinity\n lastFrames = 1\n frames = 0\n count = 0\n\n startTime: number\n currentTime: number\n\n constructor () {\n this.begin()\n }\n\n update () {\n this.startTime = this.end()\n this.currentTime = this.startTime\n this.signals.updated.dispatch()\n }\n\n begin () {\n this.startTime = window.performance.now()\n this.lastFrames = this.frames\n }\n\n end () {\n const time = window.performance.now()\n\n this.count += 1\n this.frames += 1\n\n this.lastDuration = time - this.startTime\n this.minDuration = Math.min(this.minDuration, this.lastDuration)\n this.maxDuration = Math.max(this.maxDuration, this.lastDuration)\n this.avgDuration -= this.avgDuration / 30\n this.avgDuration += this.lastDuration / 30\n\n if (time > this.prevFpsTime + 1000) {\n this.lastFps = this.frames\n this.prevFpsTime = time\n this.frames = 0\n }\n\n return time\n }\n}","/**\n * @file Shader Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { ShaderChunk } from 'three'\n\nimport './chunk/fog_fragment.glsl'\nimport './chunk/interior_fragment.glsl'\nimport './chunk/matrix_scale.glsl'\nimport './chunk/nearclip_vertex.glsl'\nimport './chunk/nearclip_fragment.glsl'\nimport './chunk/opaque_back_fragment.glsl'\nimport './chunk/radiusclip_vertex.glsl'\nimport './chunk/radiusclip_fragment.glsl'\nimport './chunk/unpack_color.glsl'\n\nimport { ShaderRegistry } from '../globals'\n\nexport type ShaderDefine = (\n 'NEAR_CLIP'|'RADIUS_CLIP'|'PICKING'|'NOLIGHT'|'FLAT_SHADED'|'OPAQUE_BACK'|\n 'DIFFUSE_INTERIOR'|'USE_INTERIOR_COLOR'|\n 'USE_SIZEATTENUATION'|'USE_MAP'|'ALPHATEST'|'SDF'|'FIXED_SIZE'|\n 'CUBIC_INTERPOLATION'|'BSPLINE_FILTER'|'CATMULROM_FILTER'|'MITCHELL_FILTER'\n)\nexport type ShaderDefines = {\n [k in ShaderDefine]?: number|string\n}\n\nfunction getDefines (defines: ShaderDefines) {\n if (defines === undefined) return ''\n\n const lines = []\n\n for (const name in defines) {\n const value = defines[ name as keyof ShaderDefines ]\n\n if (!value) continue\n\n lines.push(`#define ${name} ${value}`)\n }\n\n return lines.join('\\n') + '\\n'\n}\n\nconst reInclude = /^(?!\\/\\/)\\s*#include\\s+(\\S+)/gmi\nconst shaderCache: { [k: string]: string } = {}\n\nexport function getShader (name: string, defines: ShaderDefines = {}) {\n let hash = name + '|'\n for (const key in defines) {\n hash += key + ':' + defines[ key as keyof ShaderDefines ]\n }\n\n if (!shaderCache[ hash ]) {\n const definesText = getDefines(defines)\n\n let shaderText = ShaderRegistry.get(`shader/${name}`) as string\n if (!shaderText) {\n throw new Error(`empty shader, '${name}'`)\n }\n shaderText = shaderText.replace(reInclude, function (match, p1) {\n const path = `shader/chunk/${p1}.glsl`\n const chunk = ShaderRegistry.get(path) || ShaderChunk[ p1 ]\n if (!chunk) {\n throw new Error(`empty chunk, '${p1}'`)\n }\n return chunk\n })\n\n shaderCache[ hash ] = definesText + shaderText\n }\n\n return shaderCache[ hash ]\n}\n","/**\n * @file Viewer Constants\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug } from '../globals'\n\nif (typeof WebGLRenderingContext !== 'undefined') {\n const wrcp = WebGLRenderingContext.prototype\n\n // wrap WebGL debug function used by three.js and\n // ignore calls to them when the debug flag is not set\n\n const _getShaderParameter = wrcp.getShaderParameter\n wrcp.getShaderParameter = function getShaderParameter (this: WebGLRenderingContext) {\n if (Debug) {\n return _getShaderParameter.apply(this, arguments)\n } else {\n return true\n }\n }\n\n const _getShaderInfoLog = wrcp.getShaderInfoLog\n wrcp.getShaderInfoLog = function getShaderInfoLog (this: WebGLRenderingContext) {\n if (Debug) {\n return _getShaderInfoLog.apply(this, arguments)\n } else {\n return ''\n }\n }\n\n const _getProgramParameter = wrcp.getProgramParameter\n wrcp.getProgramParameter = function getProgramParameter (this: WebGLRenderingContext, program, pname) {\n if (Debug || pname !== wrcp.LINK_STATUS) {\n return _getProgramParameter.apply(this, arguments)\n } else {\n return true\n }\n }\n\n const _getProgramInfoLog = wrcp.getProgramInfoLog\n wrcp.getProgramInfoLog = function getProgramInfoLog (this: WebGLRenderingContext) {\n if (Debug) {\n return _getProgramInfoLog.apply(this, arguments)\n } else {\n return ''\n }\n }\n}\n\nexport const JitterVectors = [\n [\n [ 0, 0 ]\n ],\n [\n [ 4, 4 ], [ -4, -4 ]\n ],\n [\n [ -2, -6 ], [ 6, -2 ], [ -6, 2 ], [ 2, 6 ]\n ],\n [\n [ 1, -3 ], [ -1, 3 ], [ 5, 1 ], [ -3, -5 ],\n [ -5, 5 ], [ -7, -1 ], [ 3, 7 ], [ 7, -7 ]\n ],\n [\n [ 1, 1 ], [ -1, -3 ], [ -3, 2 ], [ 4, -1 ],\n [ -5, -2 ], [ 2, 5 ], [ 5, 3 ], [ 3, -5 ],\n [ -2, 6 ], [ 0, -7 ], [ -4, -6 ], [ -6, 4 ],\n [ -8, 0 ], [ 7, -4 ], [ 6, 7 ], [ -7, -8 ]\n ],\n [\n [ -4, -7 ], [ -7, -5 ], [ -3, -5 ], [ -5, -4 ],\n [ -1, -4 ], [ -2, -2 ], [ -6, -1 ], [ -4, 0 ],\n [ -7, 1 ], [ -1, 2 ], [ -6, 3 ], [ -3, 3 ],\n [ -7, 6 ], [ -3, 6 ], [ -5, 7 ], [ -1, 7 ],\n [ 5, -7 ], [ 1, -6 ], [ 6, -5 ], [ 4, -4 ],\n [ 2, -3 ], [ 7, -2 ], [ 1, -1 ], [ 4, -1 ],\n [ 2, 1 ], [ 6, 2 ], [ 0, 4 ], [ 4, 4 ],\n [ 2, 5 ], [ 7, 5 ], [ 5, 6 ], [ 3, 7 ]\n ]\n]\n\nJitterVectors.forEach(offsetList => {\n offsetList.forEach(offset => {\n // 0.0625 = 1 / 16\n offset[ 0 ] *= 0.0625\n offset[ 1 ] *= 0.0625\n })\n})\n","/**\n * @file Tiled Renderer\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { Camera, WebGLRenderer } from 'three'\nimport Viewer from './viewer'\n\nexport interface TiledRendererParams {\n factor?: number\n antialias?: boolean\n onProgress?: Function\n onFinish?: Function\n}\n\nclass TiledRenderer {\n canvas = document.createElement('canvas')\n\n private _width: number\n private _height: number\n private _n: number\n private _factor: number\n private _antialias: boolean\n private _viewerSampleLevel: number\n\n private _viewer: Viewer\n private _onProgress?: Function\n private _onFinish?: Function\n private _ctx: CanvasRenderingContext2D\n\n constructor(renderer: WebGLRenderer, camera: Camera, viewer: Viewer, params: TiledRendererParams) {\n this._viewer = viewer\n\n this._factor = defaults(params.factor, 2)\n this._antialias = defaults(params.antialias, false)\n\n this._onProgress = params.onProgress\n this._onFinish = params.onFinish\n\n if (this._antialias) this._factor *= 2\n this._n = this._factor * this._factor\n\n // canvas\n\n this._width = this._viewer.width\n this._height = this._viewer.height\n\n if (this._antialias) {\n this.canvas.width = this._width * this._factor / 2\n this.canvas.height = this._height * this._factor / 2\n } else {\n this.canvas.width = this._width * this._factor\n this.canvas.height = this._height * this._factor\n }\n\n this._ctx = this.canvas.getContext('2d')!\n\n this._viewerSampleLevel = viewer.sampleLevel\n this._viewer.setSampling(-1)\n }\n\n private _renderTile (i: number) {\n const viewer = this._viewer\n const width = this._width\n const height = this._height\n const factor = this._factor\n\n const x = i % factor\n const y = Math.floor(i / factor)\n\n const offsetX = x * width\n const offsetY = y * height\n\n viewer.camera.setViewOffset(\n width * factor,\n height * factor,\n offsetX,\n offsetY,\n width,\n height\n )\n\n viewer.render()\n\n if (this._antialias) {\n const w = Math.round((offsetX + width) / 2) - Math.round (offsetX / 2);\n const h = Math.round((offsetY + height) / 2) - Math.round (offsetY / 2);\n this._ctx.drawImage(\n viewer.renderer.domElement,\n Math.round(offsetX / 2),\n Math.round(offsetY / 2),\n w,\n h\n )\n } else {\n this._ctx.drawImage(\n viewer.renderer.domElement,\n Math.floor(offsetX),\n Math.floor(offsetY),\n Math.ceil(width),\n Math.ceil(height)\n )\n }\n\n if (typeof this._onProgress === 'function') {\n this._onProgress(i + 1, this._n, false)\n }\n }\n\n private _finalize () {\n this._viewer.setSampling(this._viewerSampleLevel)\n this._viewer.camera.view = null! // TODO\n\n if (typeof this._onFinish === 'function') {\n this._onFinish(this._n + 1, this._n, false)\n }\n }\n\n render () {\n for (let i = 0; i <= this._n; ++i) {\n if (i === this._n) {\n this._finalize()\n } else {\n this._renderTile(i)\n }\n }\n }\n\n renderAsync () {\n let count = 0\n const n = this._n\n\n const fn = () => {\n if (count === n) {\n this._finalize()\n } else {\n this._renderTile(count)\n }\n count += 1\n }\n\n for (let i = 0; i <= n; ++i) {\n setTimeout(fn, 0)\n }\n }\n}\n\nexport default TiledRenderer\n","/**\n * @file Math Constants\n * @author Alexander Rose \n * @private\n */\n\nexport const EPS = 0.0000001\nexport const TwoPI = 2 * Math.PI\n\nexport const DEG2RAD = Math.PI / 180\nexport const RAD2DEG = 180 / Math.PI\n","/**\n * @file Array Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { NumberArray } from '../types'\nimport { TwoPI } from './math-constants'\n\nexport function circularMean (array: NumberArray, max: number, stride = 1, offset = 0, indices?: NumberArray) {\n // http://en.wikipedia.org/wiki/Center_of_mass#Systems_with_periodic_boundary_conditions\n\n // Bai, Linge; Breen, David (2008). Calculating Center of Mass in an Unbounded 2D Environment. Journal of Graphics, GPU, and Game Tools 13 (4): 53–60.\n\n // http://stackoverflow.com/questions/18166507/using-fft-to-find-the-center-of-mass-under-periodic-boundary-conditions\n\n const n = indices ? indices.length : array.length / stride\n\n let cosMean = 0\n let sinMean = 0\n\n if (indices) {\n for (let i = 0; i < n; ++i) {\n const c = (array[ indices[ i ] * stride + offset ] + max) % max\n const angle = (c / max) * TwoPI - Math.PI\n\n cosMean += Math.cos(angle)\n sinMean += Math.sin(angle)\n }\n } else {\n for (let i = offset; i < n; i += stride) {\n const c = (array[ i ] + max) % max\n const angle = (c / max) * TwoPI - Math.PI\n\n cosMean += Math.cos(angle)\n sinMean += Math.sin(angle)\n }\n }\n\n cosMean /= n\n sinMean /= n\n\n const meanAngle = Math.atan2(sinMean, cosMean)\n const mean = (meanAngle + Math.PI) / TwoPI * max\n\n return mean\n}\n\nexport function calculateCenterArray (array1: NumberArray, array2: NumberArray, center?: T, offset = 0): T {\n const n = array1.length\n const c = center || new Float32Array(n)\n\n for (let i = 0; i < n; i += 3) {\n c[ offset + i + 0 ] = (array1[ i + 0 ] + array2[ i + 0 ]) / 2.0\n c[ offset + i + 1 ] = (array1[ i + 1 ] + array2[ i + 1 ]) / 2.0\n c[ offset + i + 2 ] = (array1[ i + 2 ] + array2[ i + 2 ]) / 2.0\n }\n\n return c as T\n}\n\nexport function calculateDirectionArray (array1: NumberArray, array2: NumberArray) {\n const n = array1.length\n const direction = new Float32Array(n)\n\n for (let i = 0; i < n; i += 3) {\n direction[ i + 0 ] = array2[ i + 0 ] - array1[ i + 0 ]\n direction[ i + 1 ] = array2[ i + 1 ] - array1[ i + 1 ]\n direction[ i + 2 ] = array2[ i + 2 ] - array1[ i + 2 ]\n }\n\n return direction\n}\n\nexport function uniformArray (n: number, a: number, optionalTarget?: T): T {\n const array = optionalTarget || new Float32Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = a\n }\n\n return array as T\n}\n\nexport function uniformArray3 (n: number, a: number, b: number, c: number, optionalTarget?: NumberArray) {\n const array = optionalTarget || new Float32Array(n * 3)\n\n for (let i = 0; i < n; ++i) {\n const j = i * 3\n\n array[ j + 0 ] = a\n array[ j + 1 ] = b\n array[ j + 2 ] = c\n }\n\n return array\n}\n\nexport function centerArray3 (array: NumberArray, center = new Vector3()) {\n const n = array.length\n\n for (let i = 0; i < n; i += 3) {\n center.x += array[ i ]\n center.y += array[ i + 1 ]\n center.z += array[ i + 2 ]\n }\n\n center.divideScalar(n / 3)\n\n return center\n}\n\nexport function serialArray (n: number) {\n const array = new Float32Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = i\n }\n\n return array\n}\n\nexport function serialBlockArray (n: number, b: number, offset = 0, optionalTarget?: NumberArray) {\n const array = optionalTarget || new Float32Array(n * b)\n\n for (let i = 0; i < n; ++i) {\n const k = offset + i * b\n\n for (let j = 0; j < b; ++j) {\n array[ k + j ] = i\n }\n }\n\n return array\n}\n\nexport function randomColorArray (n: number) {\n const array = new Float32Array(n * 3)\n\n for (let i = 0; i < n; ++i) {\n const j = i * 3\n\n array[ j + 0 ] = Math.random()\n array[ j + 1 ] = Math.random()\n array[ j + 2 ] = Math.random()\n }\n\n return array\n}\n\nexport function replicateArrayEntries (array: NumberArray, m: number) {\n const n = array.length\n const repArr = new Float32Array(n * m)\n\n for (let i = 0; i < n; ++i) {\n const k = i * m\n const a = array[ i ]\n\n for (let j = 0; j < m; ++j) {\n repArr[ k + j ] = a\n }\n }\n\n return repArr\n}\n\nexport function replicateArray3Entries (array: NumberArray, m: number) {\n const n = array.length / 3\n const repArr = new Float32Array(n * m * 3)\n\n for (let i = 0; i < n; ++i) {\n const v = i * 3\n const k = i * m * 3\n\n const a = array[ v + 0 ]\n const b = array[ v + 1 ]\n const c = array[ v + 2 ]\n\n for (let j = 0; j < m; ++j) {\n const l = k + j * 3\n\n repArr[ l + 0 ] = a\n repArr[ l + 1 ] = b\n repArr[ l + 2 ] = c\n }\n }\n\n return repArr\n}\n\nexport function calculateMeanArray (array1: NumberArray, array2: NumberArray) {\n const n = array1.length\n const mean = new Float32Array(n)\n\n for (let i = 0; i < n; i++) {\n mean[ i ] = (array1[ i ] + array2[ i ]) / 2.0\n }\n\n return mean\n}\n\nexport function calculateMinArray (array1: NumberArray, array2: NumberArray) {\n const n = array1.length\n const min = new Float32Array(n)\n\n for (let i = 0; i < n; i++) {\n min[ i ] = Math.min(array1[ i ], array2[ i ])\n }\n\n return min\n}\n\nexport function copyArray (src: T, dst: T, srcOffset: number, dstOffset: number, length: number) {\n for (let i = 0; i < length; ++i) {\n dst[ dstOffset + i ] = src[ srcOffset + i ]\n }\n}\n\nexport function copyWithin (array: NumberArray|any[], srcOffset: number, dstOffset: number, length: number) {\n copyArray(array, array, srcOffset, dstOffset, length)\n}\n\nconst swap = new Float32Array(4)\nconst temp = new Float32Array(4)\n/**\n * quicksortIP\n * @function\n * @author Roman Bolzern , 2013\n * @author I4DS http://www.fhnw.ch/i4ds, 2013\n * @license MIT License \n * @description\n * In-place quicksort for typed arrays (e.g. for Float32Array)\n * provides fast sorting\n * useful e.g. for a custom shader and/or BufferGeometry\n * Complexity: http://bigocheatsheet.com/ see Quicksort\n *\n * @example\n * points: [x, y, z, x, y, z, x, y, z, ...]\n * eleSize: 3 //because of (x, y, z)\n * orderElement: 0 //order according to x\n *\n * @param {TypedArray} arr - array to be sorted\n * @param {Integer} eleSize - element size\n * @param {Integer} orderElement - index of element used for sorting, < eleSize\n * @param {Integer} [begin] - start index for range to be sorted\n * @param {Integer} [end] - end index for range to be sorted\n * @return {TypedArray} the input array\n */\nexport function quicksortIP (arr: NumberArray, eleSize: number, orderElement: number, begin = 0, end?: number) {\n end = (end || (arr.length / eleSize)) - 1\n\n const stack = []\n let sp = -1\n let left = begin\n let right = end\n let tmp = 0.0\n let x = 0\n let y = 0\n\n const swapF = function (a: number, b: number) {\n a *= eleSize; b *= eleSize\n for (y = 0; y < eleSize; y++) {\n tmp = arr[ a + y ]\n arr[ a + y ] = arr[ b + y ]\n arr[ b + y ] = tmp\n }\n }\n\n let i, j\n\n while (true) {\n if (right - left <= 25) {\n for (j = left + 1; j <= right; j++) {\n for (x = 0; x < eleSize; x++) {\n swap[ x ] = arr[ j * eleSize + x ]\n }\n\n i = j - 1\n\n while (i >= left && arr[ i * eleSize + orderElement ] > swap[ orderElement ]) {\n for (x = 0; x < eleSize; x++) {\n arr[ (i + 1) * eleSize + x ] = arr[ i * eleSize + x ]\n }\n i--\n }\n\n for (x = 0; x < eleSize; x++) {\n arr[ (i + 1) * eleSize + x ] = swap[ x ]\n }\n }\n\n if (sp === -1) break\n\n right = stack[ sp-- ] // ?\n left = stack[ sp-- ]\n } else {\n const median = (left + right) >> 1\n\n i = left + 1\n j = right\n\n swapF(median, i)\n\n if (arr[ left * eleSize + orderElement ] > arr[ right * eleSize + orderElement ]) {\n swapF(left, right)\n }\n\n if (arr[ i * eleSize + orderElement ] > arr[ right * eleSize + orderElement ]) {\n swapF(i, right)\n }\n\n if (arr[ left * eleSize + orderElement ] > arr[ i * eleSize + orderElement ]) {\n swapF(left, i)\n }\n\n for (x = 0; x < eleSize; x++) {\n temp[ x ] = arr[ i * eleSize + x ]\n }\n\n while (true) {\n do i++; while (arr[ i * eleSize + orderElement ] < temp[ orderElement ])\n do j--; while (arr[ j * eleSize + orderElement ] > temp[ orderElement ])\n if (j < i) break\n swapF(i, j)\n }\n\n for (x = 0; x < eleSize; x++) {\n arr[ (left + 1) * eleSize + x ] = arr[ j * eleSize + x ]\n arr[ j * eleSize + x ] = temp[ x ]\n }\n\n if (right - i + 1 >= j - left) {\n stack[ ++sp ] = i\n stack[ ++sp ] = right\n right = j - 1\n } else {\n stack[ ++sp ] = left\n stack[ ++sp ] = j - 1\n left = i\n }\n }\n }\n\n return arr\n}\n\nexport function quicksortCmp (arr: NumberArray|T[], cmp?: (a: number|T, b: number|T) => number, begin = 0, end?: number) {\n cmp = cmp || function cmp (a, b) {\n if (a > b) return 1\n if (a < b) return -1\n return 0\n }\n end = (end || arr.length) - 1\n\n const stack = []\n let sp = -1\n let left = begin\n let right = end\n let tmp: number|T\n\n function swap (a: number, b: number) {\n const tmp2 = arr[ a ]\n arr[ a ] = arr[ b ]\n arr[ b ] = tmp2\n }\n\n let i, j\n\n while (true) {\n if (right - left <= 25) {\n for (let k = left + 1; k <= right; ++k) {\n tmp = arr[ k ]\n i = k - 1\n\n while (i >= left && cmp(arr[ i ], tmp) > 0) {\n arr[ i + 1 ] = arr[ i ]\n --i\n }\n\n arr[ i + 1 ] = tmp\n }\n\n if (sp === -1) break\n\n right = stack[ sp-- ] // ?\n left = stack[ sp-- ]\n } else {\n const median = (left + right) >> 1\n\n i = left + 1\n j = right\n\n swap(median, i)\n\n if (cmp(arr[ left ], arr[ right ]) > 0) {\n swap(left, right)\n }\n\n if (cmp(arr[ i ], arr[ right ]) > 0) {\n swap(i, right)\n }\n\n if (cmp(arr[ left ], arr[ i ]) > 0) {\n swap(left, i)\n }\n\n tmp = arr[ i ]\n\n while (true) {\n do i++; while (cmp(arr[ i ], tmp) < 0)\n do j--; while (cmp(arr[ j ], tmp) > 0)\n if (j < i) break\n swap(i, j)\n }\n\n arr[ left + 1 ] = arr[ j ]\n arr[ j ] = tmp\n\n if (right - i + 1 >= j - left) {\n stack[ ++sp ] = i\n stack[ ++sp ] = right\n right = j - 1\n } else {\n stack[ ++sp ] = left\n stack[ ++sp ] = j - 1\n left = i\n }\n }\n }\n\n return arr\n}\n\nexport function quickselectCmp (arr: NumberArray|T[], n: number, cmp?: (a: number|T, b: number|T) => number, left = 0, right?: number) {\n cmp = cmp || function cmp (a, b) {\n if (a > b) return 1\n if (a < b) return -1\n return 0\n }\n right = (right || arr.length) - 1\n\n let pivotIndex, pivotValue, storeIndex\n\n function swap (a: number, b: number) {\n const tmp = arr[ a ]\n arr[ a ] = arr[ b ]\n arr[ b ] = tmp\n }\n\n while (true) {\n if (left === right) {\n return arr[ left ]\n }\n pivotIndex = (left + right) >> 1\n pivotValue = arr[ pivotIndex ]\n swap(pivotIndex, right)\n storeIndex = left\n for (let i = left; i < right; ++i) {\n if (cmp(arr[ i ], pivotValue) < 0) {\n swap(storeIndex, i)\n ++storeIndex\n }\n }\n swap(right, storeIndex)\n pivotIndex = storeIndex\n if (n === pivotIndex) {\n return arr[ n ]\n } else if (n < pivotIndex) {\n right = pivotIndex - 1\n } else {\n left = pivotIndex + 1\n }\n }\n}\n\nexport function arrayMax (array: NumberArray) {\n let max = -Infinity\n for (let i = 0, il = array.length; i < il; ++i) {\n if (array[ i ] > max) max = array[ i ]\n }\n return max\n}\n\nexport function arrayMin (array: NumberArray) {\n let min = Infinity\n for (let i = 0, il = array.length; i < il; ++i) {\n if (array[ i ] < min) min = array[ i ]\n }\n return min\n}\n\nexport function arraySum (array: NumberArray, stride = 1, offset = 0) {\n const n = array.length\n let sum = 0\n for (let i = offset; i < n; i += stride) {\n sum += array[ i ]\n }\n return sum\n}\n\nexport function arrayMean (array: NumberArray, stride = 1, offset = 0) {\n return arraySum(array, stride, offset) / (array.length / stride)\n}\n\nexport function arrayRms (array: NumberArray) {\n const n = array.length\n let sumSq = 0\n for (let i = 0; i < n; ++i) {\n const di = array[ i ]\n sumSq += di * di\n }\n return Math.sqrt(sumSq / n)\n}\n\nexport function arraySorted (array: NumberArray) {\n for (let i = 1, il = array.length; i < il; ++i) {\n if (array[ i - 1 ] > array[ i ]) return false\n }\n return true\n}\n\nexport function arraySortedCmp (array: NumberArray|T[], cmp: (a: number|T, b: number|T) => number) {\n for (let i = 1, il = array.length; i < il; ++i) {\n if (cmp(array[ i - 1 ], array[ i ]) > 0) return false\n }\n return true\n}\n","/**\n * @file Viewer Utils\n * @author Alexander Rose \n * @private\n */\n\nimport {\n Vector2, Vector3, Matrix4, Points, Scene, Camera,\n Object3D, WebGLRenderer\n} from 'three'\n\nimport { createParams } from '../utils'\nimport TiledRenderer from './tiled-renderer'\nimport { quicksortCmp } from '../math/array-utils'\nimport Viewer from './viewer'\n\nfunction _trimCanvas (canvas: HTMLCanvasElement, r: number, g: number, b: number, a: number) {\n const canvasHeight = canvas.height\n const canvasWidth = canvas.width\n\n const ctx = canvas.getContext('2d')!\n const pixels = ctx.getImageData(0, 0, canvasWidth, canvasHeight).data\n\n let x, y, doBreak, off\n\n doBreak = false\n for (y = 0; y < canvasHeight; y++) {\n for (x = 0; x < canvasWidth; x++) {\n off = (y * canvasWidth + x) * 4\n if (pixels[ off ] !== r || pixels[ off + 1 ] !== g ||\n pixels[ off + 2 ] !== b || pixels[ off + 3 ] !== a\n ) {\n doBreak = true\n break\n }\n }\n if (doBreak) {\n break\n }\n }\n const topY = y\n\n doBreak = false\n for (x = 0; x < canvasWidth; x++) {\n for (y = 0; y < canvasHeight; y++) {\n off = (y * canvasWidth + x) * 4\n if (pixels[ off ] !== r || pixels[ off + 1 ] !== g ||\n pixels[ off + 2 ] !== b || pixels[ off + 3 ] !== a\n ) {\n doBreak = true\n break\n }\n }\n if (doBreak) {\n break\n }\n }\n const topX = x\n\n doBreak = false\n for (y = canvasHeight - 1; y >= 0; y--) {\n for (x = canvasWidth - 1; x >= 0; x--) {\n off = (y * canvasWidth + x) * 4\n if (pixels[ off ] !== r || pixels[ off + 1 ] !== g ||\n pixels[ off + 2 ] !== b || pixels[ off + 3 ] !== a\n ) {\n doBreak = true\n break\n }\n }\n if (doBreak) {\n break\n }\n }\n const bottomY = y\n\n doBreak = false\n for (x = canvasWidth - 1; x >= 0; x--) {\n for (y = canvasHeight - 1; y >= 0; y--) {\n off = (y * canvasWidth + x) * 4\n if (pixels[ off ] !== r || pixels[ off + 1 ] !== g ||\n pixels[ off + 2 ] !== b || pixels[ off + 3 ] !== a\n ) {\n doBreak = true\n break\n }\n }\n if (doBreak) {\n break\n }\n }\n const bottomX = x\n\n const trimedCanvas = document.createElement('canvas')\n trimedCanvas.width = bottomX - topX\n trimedCanvas.height = bottomY - topY\n\n const trimedCtx = trimedCanvas.getContext('2d')!\n trimedCtx.drawImage(\n canvas,\n topX, topY,\n trimedCanvas.width, trimedCanvas.height,\n 0, 0,\n trimedCanvas.width, trimedCanvas.height\n )\n\n return trimedCanvas\n}\n\n/**\n * Image parameter object.\n * @typedef {Object} ImageParameters - image generation parameters\n * @property {Boolean} trim - trim the image\n * @property {Integer} factor - scaling factor to apply to the viewer canvas\n * @property {Boolean} antialias - antialias the image\n * @property {Boolean} transparent - transparent image background\n */\n\nexport const ImageDefaultParameters = {\n trim: false,\n factor: 1,\n antialias: false,\n transparent: false,\n onProgress: undefined as Function|undefined\n}\nexport type ImageParameters = typeof ImageDefaultParameters\n\n/**\n * Make image from what is shown in a viewer canvas\n * @param {Viewer} viewer - the viewer\n * @param {ImageParameters} params - parameters object\n * @return {Promise} A Promise object that resolves to an image {@link Blob}.\n */\nexport function makeImage (viewer: Viewer, params: Partial = {}) {\n const {trim, factor, antialias, transparent} = createParams(params, ImageDefaultParameters)\n\n const renderer = viewer.renderer\n const camera = viewer.camera\n\n const originalClearAlpha = renderer.getClearAlpha()\n const backgroundColor = renderer.getClearColor()\n\n function setLineWidthAndPixelSize (invert = false) {\n let _factor = factor\n if (antialias) _factor *= 2\n if (invert) _factor = 1 / _factor\n viewer.scene.traverse(function (o: any) { // TODO\n const m = o.material\n if (m && m.linewidth) {\n m.linewidth *= _factor\n }\n if (m && m.uniforms && m.uniforms.size) {\n if (m.uniforms.size.__seen === undefined) {\n m.uniforms.size.value *= _factor\n m.uniforms.size.__seen = true\n }\n }\n if (m && m.uniforms && m.uniforms.linewidth) {\n if (m.uniforms.linewidth.__seen === undefined) {\n m.uniforms.linewidth.value *= _factor\n m.uniforms.linewidth.__seen = true\n }\n }\n })\n viewer.scene.traverse(function (o: any) { // TODO\n const m = o.material\n if (m && m.uniforms && m.uniforms.size) {\n delete m.uniforms.size.__seen\n }\n if (m && m.uniforms && m.uniforms.linewidth) {\n delete m.uniforms.linewidth.__seen\n }\n })\n }\n\n function trimCanvas (canvas: HTMLCanvasElement) {\n if (trim) {\n const bg = backgroundColor\n const r = transparent ? 0 : bg.r * 255\n const g = transparent ? 0 : bg.g * 255\n const b = transparent ? 0 : bg.b * 255\n const a = transparent ? 0 : 255\n return _trimCanvas(canvas, r, g, b, a)\n } else {\n return canvas\n }\n }\n\n function onProgress (i: number, n: number, finished: boolean) {\n if (typeof params.onProgress === 'function') {\n params.onProgress(i, n, finished)\n }\n }\n\n return new Promise(function (resolve, reject) {\n const tiledRenderer = new TiledRenderer(\n renderer, camera, viewer,\n { factor, antialias, onProgress, onFinish }\n )\n\n renderer.setClearAlpha(transparent ? 0 : 1)\n setLineWidthAndPixelSize()\n tiledRenderer.renderAsync()\n\n function onFinish (i: number, n: number) {\n const canvas = trimCanvas(tiledRenderer.canvas)\n canvas.toBlob(\n function (blob) {\n renderer.setClearAlpha(originalClearAlpha)\n setLineWidthAndPixelSize(true)\n viewer.requestRender()\n onProgress(n, n, true)\n if (blob) {\n resolve(blob)\n } else {\n reject('error creating image')\n }\n },\n 'image/png'\n )\n }\n })\n}\n\nconst vertex = new Vector3()\nconst matrix = new Matrix4()\nconst modelViewProjectionMatrix = new Matrix4()\n\nexport function sortProjectedPosition (scene: Scene, camera: Camera) {\n // console.time( \"sort\" );\n\n scene.traverseVisible(function (o) {\n if (!(o instanceof Points) || !o.userData.buffer.parameters.sortParticles) {\n return\n }\n\n const attributes = (o.geometry as any).attributes // TODO\n const n = attributes.position.count\n\n if (n === 0) return\n\n matrix.multiplyMatrices(\n camera.matrixWorldInverse, o.matrixWorld\n )\n modelViewProjectionMatrix.multiplyMatrices(\n camera.projectionMatrix, matrix\n )\n\n let sortData, sortArray, zArray: Float32Array, cmpFn\n\n if (!o.userData.sortData) {\n zArray = new Float32Array(n)\n sortArray = new Uint32Array(n)\n cmpFn = function (ai: number, bi: number) {\n const a = zArray[ ai ]\n const b = zArray[ bi ]\n if (a > b) return 1\n if (a < b) return -1\n return 0\n }\n\n sortData = {\n __zArray: zArray,\n __sortArray: sortArray,\n __cmpFn: cmpFn\n }\n\n o.userData.sortData = sortData\n } else {\n sortData = o.userData.sortData\n zArray = sortData.__zArray\n sortArray = sortData.__sortArray\n cmpFn = sortData.__cmpFn\n }\n\n for (let i = 0; i < n; ++i) {\n vertex.fromArray(attributes.position.array, i * 3)\n vertex.applyMatrix4(modelViewProjectionMatrix)\n\n // negate, so that sorting order is reversed\n zArray[ i ] = -vertex.z\n sortArray[ i ] = i\n }\n\n quicksortCmp(sortArray, cmpFn)\n\n let index, indexSrc, indexDst, tmpTab\n\n for (let name in attributes) {\n const attr = attributes[ name ]\n const array = attr.array\n const itemSize = attr.itemSize\n\n if (!sortData[ name ]) {\n sortData[ name ] = new Float32Array(itemSize * n)\n }\n\n tmpTab = sortData[ name ]\n sortData[ name ] = array\n\n for (let i = 0; i < n; ++i) {\n index = sortArray[ i ]\n\n for (let j = 0; j < itemSize; ++j) {\n indexSrc = index * itemSize + j\n indexDst = i * itemSize + j\n tmpTab[ indexDst ] = array[ indexSrc ]\n }\n }\n\n attributes[ name ].array = tmpTab\n attributes[ name ].needsUpdate = true\n }\n })\n\n // console.timeEnd( \"sort\" );\n}\n\nconst resolution = new Vector2()\nconst projectionMatrixInverse = new Matrix4()\nconst projectionMatrixTranspose = new Matrix4()\n\nexport function updateMaterialUniforms (group: Object3D, camera: Camera, renderer: WebGLRenderer, cDist: number, bRadius: number) {\n let size = new Vector2()\n renderer.getSize(size)\n const canvasHeight = size.height\n const pixelRatio = renderer.getPixelRatio()\n const ortho = camera.type === 'OrthographicCamera'\n\n resolution.set(size.width, size.height)\n projectionMatrixInverse.getInverse(camera.projectionMatrix)\n projectionMatrixTranspose.copy(camera.projectionMatrix).transpose()\n\n group.traverse(function (o: any) {\n const m = o.material\n if (!m) return\n\n const u = m.uniforms\n if (!u) return\n\n if (m.clipNear) {\n const nearFactor = (50 - m.clipNear) / 50\n const nearClip = cDist - (bRadius * nearFactor)\n u.clipNear.value = nearClip\n }\n\n if (u.canvasHeight) {\n u.canvasHeight.value = canvasHeight\n }\n\n if (u.resolution) {\n u.resolution.value.copy(resolution)\n }\n\n if (u.pixelRatio) {\n u.pixelRatio.value = pixelRatio\n }\n\n if (u.projectionMatrixInverse) {\n u.projectionMatrixInverse.value.copy(projectionMatrixInverse)\n }\n\n if (u.projectionMatrixTranspose) {\n u.projectionMatrixTranspose.value.copy(projectionMatrixTranspose)\n }\n\n if (u.ortho) {\n u.ortho.value = ortho\n }\n })\n}\n\nexport function updateCameraUniforms (group: Object3D, camera: Camera) {\n projectionMatrixInverse.getInverse(camera.projectionMatrix)\n projectionMatrixTranspose.copy(camera.projectionMatrix).transpose()\n\n group.traverse(function (o: any) {\n const m = o.material\n if (!m) return\n\n const u = m.uniforms\n if (!u) return\n\n if (u.projectionMatrixInverse) {\n u.projectionMatrixInverse.value.copy(projectionMatrixInverse)\n }\n\n if (u.projectionMatrixTranspose) {\n u.projectionMatrixTranspose.value.copy(projectionMatrixTranspose)\n }\n })\n}\n","/**\n * @file Viewer\n * @author Alexander Rose \n * @private\n */\n\n// adapted from https://webglfundamentals.org/webgl/resources/webgl-utils.js\n// Copyright 2012, Gregg Tavares. Modified BSD License\n\nexport function createProgram(gl: WebGLRenderingContext, shaders: WebGLShader[], attribs?: string[], locations?: number[]) {\n const program = gl.createProgram()\n if (!program) {\n console.log(`error creating WebGL program`)\n return\n }\n shaders.forEach(shader => gl.attachShader(program, shader))\n if (attribs) {\n attribs.forEach((attrib, i) => {\n gl.bindAttribLocation(program, locations ? locations[i] : i, attrib)\n })\n }\n gl.linkProgram(program);\n\n // Check the link status\n const linked = gl.getProgramParameter(program, gl.LINK_STATUS)\n if (!linked) {\n console.log(`error linking program: ${gl.getProgramInfoLog(program)}`)\n gl.deleteProgram(program)\n return null\n }\n return program\n}\n\nexport function loadShader(gl: WebGLRenderingContext, shaderSource: string, shaderType: number) {\n const shader = gl.createShader(shaderType)\n if (!shader) {\n console.log(`error creating WebGL shader ${shaderType}`)\n return // can't create shader\n }\n gl.shaderSource(shader, shaderSource)\n gl.compileShader(shader)\n\n // Check the compile status\n const compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS)\n if (!compiled) {\n console.log(`error compiling shader ${shader}: ${gl.getShaderInfoLog(shader)}`)\n gl.deleteShader(shader)\n return null\n }\n\n return shader\n}\n\n//\n\nexport function getErrorDescription(gl: WebGLRenderingContext, error: number) {\n switch (error) {\n case gl.NO_ERROR: return 'no error'\n case gl.INVALID_ENUM: return 'invalid enum'\n case gl.INVALID_VALUE: return 'invalid value'\n case gl.INVALID_OPERATION: return 'invalid operation'\n case gl.INVALID_FRAMEBUFFER_OPERATION: return 'invalid framebuffer operation'\n case gl.OUT_OF_MEMORY: return 'out of memory'\n case gl.CONTEXT_LOST_WEBGL: return 'context lost'\n }\n return 'unknown error'\n}\n\nexport function getExtension (gl: WebGLRenderingContext, name: string) {\n const ext = gl.getExtension(name)\n if (!ext) console.log(`extension '${name}' not available`)\n return ext\n}\n\nconst TextureTestVertShader = `\nattribute vec4 a_position;\n\nvoid main() {\n gl_Position = a_position;\n}`\n\nconst TextureTestFragShader = `\nprecision mediump float;\nuniform vec4 u_color;\nuniform sampler2D u_texture;\n\nvoid main() {\n gl_FragColor = texture2D(u_texture, vec2(0.5, 0.5)) * u_color;\n}`\n\nconst TextureTestTexCoords = new Float32Array([\n -1.0, -1.0, 1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0\n])\n\nexport function testTextureSupport (type: number) {\n // adapted from\n // https://stackoverflow.com/questions/28827511/webgl-ios-render-to-floating-point-texture\n\n // Get A WebGL context\n const canvas = document.createElement('canvas')\n canvas.width = 16\n canvas.height = 16\n canvas.style.width = 16 + 'px'\n canvas.style.height = 16 + 'px'\n const gl = canvas.getContext(\"webgl\") || canvas.getContext(\"experimental-webgl\");\n if (!gl) {\n console.log(`error creating webgl context for ${type}`)\n return false\n }\n if (!(gl instanceof WebGLRenderingContext)) {\n console.log(`Got unexpected type for WebGL rendering context`)\n return false\n }\n\n getExtension(gl, 'OES_texture_float')\n getExtension(gl, 'OES_texture_half_float')\n getExtension(gl, 'WEBGL_color_buffer_float')\n\n // setup shaders\n const vertShader = loadShader(gl, TextureTestVertShader, gl.VERTEX_SHADER)\n const fragShader = loadShader(gl, TextureTestFragShader, gl.FRAGMENT_SHADER)\n if (!vertShader || !fragShader) return false\n\n // setup program\n const program = createProgram(gl, [ vertShader, fragShader ])\n if (!program) {\n console.log(`error creating WebGL program`)\n return false\n }\n gl.useProgram(program);\n\n // look up where the vertex data needs to go.\n const positionLocation = gl.getAttribLocation(program, \"a_position\");\n const colorLoc = gl.getUniformLocation(program, \"u_color\");\n if (!colorLoc) {\n console.log(`error getting 'u_color' uniform location`)\n return false\n }\n\n // provide texture coordinates for the rectangle.\n const positionBuffer = gl.createBuffer()\n gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer)\n gl.bufferData(gl.ARRAY_BUFFER, TextureTestTexCoords, gl.STATIC_DRAW)\n gl.enableVertexAttribArray(positionLocation)\n gl.vertexAttribPointer(positionLocation, 2, gl.FLOAT, false, 0, 0)\n\n const whiteTex = gl.createTexture()\n const whiteData = new Uint8Array([255, 255, 255, 255])\n gl.bindTexture(gl.TEXTURE_2D, whiteTex)\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, whiteData)\n\n const tex = gl.createTexture()\n gl.bindTexture(gl.TEXTURE_2D, tex)\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, type, null)\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST)\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST)\n\n const fb = gl.createFramebuffer()\n gl.bindFramebuffer(gl.FRAMEBUFFER, fb)\n gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, tex, 0)\n const status = gl.checkFramebufferStatus(gl.FRAMEBUFFER)\n if (status !== gl.FRAMEBUFFER_COMPLETE) {\n console.log(`error creating framebuffer for ${type}`)\n return false\n }\n\n // Draw the rectangle.\n gl.bindTexture(gl.TEXTURE_2D, whiteTex)\n gl.uniform4fv(colorLoc, [0, 10, 20, 1])\n gl.drawArrays(gl.TRIANGLES, 0, 6)\n\n gl.bindTexture(gl.TEXTURE_2D, tex)\n gl.bindFramebuffer(gl.FRAMEBUFFER, null)\n gl.clearColor(1, 0, 0, 1)\n gl.clear(gl.COLOR_BUFFER_BIT)\n gl.uniform4fv(colorLoc, [0, 1/10, 1/20, 1])\n gl.drawArrays(gl.TRIANGLES, 0, 6)\n\n // Check if rendered correctly\n const pixel = new Uint8Array(4)\n gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, pixel)\n if (pixel[0] !== 0 || pixel[1] < 248 || pixel[2] < 248 || pixel[3] < 254) {\n console.log(`not able to actually render to ${type} texture`)\n return false\n }\n\n // Check reading from float texture\n if (type === gl.FLOAT) {\n gl.bindFramebuffer(gl.FRAMEBUFFER, fb)\n const floatPixel = new Float32Array(4)\n gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.FLOAT, floatPixel)\n const error = gl.getError()\n if (error) {\n console.log(`error reading pixels as float: '${getErrorDescription(gl, error)}'`)\n return false\n }\n }\n\n return true\n}\n","/**\n * @file Viewer\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\nimport {\n PerspectiveCamera, OrthographicCamera, StereoCamera,\n Vector2, Box3, Vector3, Matrix4, Color,\n WebGLRenderer, WebGLRenderTarget,\n NearestFilter, LinearFilter, AdditiveBlending,\n RGBAFormat, FloatType, /*HalfFloatType, */UnsignedByteType,\n ShaderMaterial,\n PlaneGeometry, Geometry,\n Scene, Mesh, Group, Object3D, Uniform,\n Fog, SpotLight, AmbientLight,\n BufferGeometry, BufferAttribute,\n LineSegments,\n LinearEncoding, sRGBEncoding, TextureEncoding\n} from 'three'\nimport '../shader/BasicLine.vert'\nimport '../shader/BasicLine.frag'\nimport '../shader/Quad.vert'\nimport '../shader/Quad.frag'\n\nimport {\n Debug, Log, WebglErrorMessage, Browser,\n setExtensionFragDepth, SupportsReadPixelsFloat, setSupportsReadPixelsFloat\n} from '../globals'\nimport { degToRad } from '../math/math-utils'\nimport Stats from './stats'\nimport { getShader } from '../shader/shader-utils'\nimport { setColorSpace } from '../color/colormaker'\nimport { JitterVectors } from './viewer-constants'\nimport {\n makeImage, ImageParameters,\n sortProjectedPosition, updateMaterialUniforms, updateCameraUniforms\n} from './viewer-utils'\nimport { testTextureSupport } from './gl-utils'\n\nimport Buffer from '../buffer/buffer'\n\nconst pixelBufferFloat = new Float32Array(4 * 25)\nconst pixelBufferUint = new Uint8Array(4 * 25)\n\n// When picking, we read a 25 pixel (5x5) array (readRenderTargetPixels)\n// We read the pixels in the order below to find what was picked.\n// This starts at the center and tries successively further points.\n// (Many points will be at equal distance to the center, their order\n// is arbitrary).\nconst pixelOrder = [12,7,13,17,11,6,8,18,16,2,14,22,10,1,3,9,19,23,21,15,5,0,4,24,20]\n\n\nconst tmpMatrix = new Matrix4()\n\nfunction onBeforeRender (this: Object3D, renderer: WebGLRenderer, scene: Scene, camera: PerspectiveCamera|OrthographicCamera, geometry: Geometry, material: ShaderMaterial/*, group */) {\n const u = material.uniforms\n const updateList = []\n\n if (!u) return // See #908 - some materials may not have uniforms, ignore these\n\n if (u.objectId) {\n u.objectId.value = SupportsReadPixelsFloat ? this.id : this.id / 255\n updateList.push('objectId')\n }\n\n if (u.modelViewMatrixInverse || u.modelViewMatrixInverseTranspose ||\n u.modelViewProjectionMatrix || u.modelViewProjectionMatrixInverse\n ) {\n this.modelViewMatrix.multiplyMatrices(camera.matrixWorldInverse, this.matrixWorld)\n }\n\n if (u.modelViewMatrixInverse) {\n u.modelViewMatrixInverse.value.getInverse(this.modelViewMatrix)\n updateList.push('modelViewMatrixInverse')\n }\n\n if (u.modelViewMatrixInverseTranspose) {\n if (u.modelViewMatrixInverse) {\n u.modelViewMatrixInverseTranspose.value.copy(\n u.modelViewMatrixInverse.value\n ).transpose()\n } else {\n u.modelViewMatrixInverseTranspose.value\n .getInverse(this.modelViewMatrix)\n .transpose()\n }\n updateList.push('modelViewMatrixInverseTranspose')\n }\n\n if (u.modelViewProjectionMatrix) {\n u.modelViewProjectionMatrix.value.multiplyMatrices(\n camera.projectionMatrix, this.modelViewMatrix\n )\n updateList.push('modelViewProjectionMatrix')\n }\n\n if (u.modelViewProjectionMatrixInverse) {\n if (u.modelViewProjectionMatrix) {\n tmpMatrix.copy(\n u.modelViewProjectionMatrix.value\n )\n u.modelViewProjectionMatrixInverse.value.getInverse(\n tmpMatrix\n )\n } else {\n tmpMatrix.multiplyMatrices(\n camera.projectionMatrix, this.modelViewMatrix\n )\n u.modelViewProjectionMatrixInverse.value.getInverse(\n tmpMatrix\n )\n }\n updateList.push('modelViewProjectionMatrixInverse')\n }\n\n if (updateList.length) {\n const materialProperties = renderer.properties.get(material)\n\n if (materialProperties.program) {\n const gl = renderer.getContext()\n const p = materialProperties.program\n gl.useProgram(p.program)\n const pu = p.getUniforms()\n\n updateList.forEach(function (name) {\n pu.setValue(gl, name, u[ name ].value)\n })\n }\n }\n}\n\nexport type CameraType = 'perspective'|'orthographic'|'stereo'\nexport type ColorWorkflow = 'linear' | 'sRGB'\n\nexport interface ViewerSignals {\n ticked: Signal,\n rendered: Signal\n}\n\nexport interface ViewerParameters {\n fogColor: Color\n fogNear: number\n fogFar: number\n\n backgroundColor: Color\n\n cameraType: CameraType\n cameraFov: number\n cameraEyeSep: number\n cameraZ: number\n\n clipNear: number\n clipFar: number\n clipDist: number\n clipMode: string // \"scene\" or \"camera\"\n clipScale: string // \"relative\" or \"absolute\"\n\n lightColor: Color\n lightIntensity: number\n ambientColor: Color\n ambientIntensity: number\n\n sampleLevel: number\n\n rendererEncoding: TextureEncoding // default is three.LinearEncoding; three.sRGBEncoding gives more correct results\n}\n\nexport interface BufferInstance {\n matrix: Matrix4\n}\n\n/**\n * Viewer class\n * @class\n * @param {String|Element} [idOrElement] - dom id or element\n */\nexport default class Viewer {\n signals: ViewerSignals\n\n container: HTMLElement\n wrapper: HTMLElement\n\n private rendering: boolean\n private renderPending: boolean\n private lastRenderedPicking: boolean\n private isStill: boolean\n private frameRequest: number\n\n sampleLevel: number\n private cDist: number\n private bRadius: number\n\n private parameters: ViewerParameters\n stats: Stats\n\n perspectiveCamera: PerspectiveCamera\n private orthographicCamera: OrthographicCamera\n private stereoCamera: StereoCamera\n camera: PerspectiveCamera|OrthographicCamera\n\n width: number\n height: number\n\n scene: Scene\n private spotLight: SpotLight\n private ambientLight: AmbientLight\n rotationGroup: Group\n translationGroup: Group\n private modelGroup: Group\n private pickingGroup: Group\n private backgroundGroup: Group\n private helperGroup: Group\n\n renderer: WebGLRenderer\n private supportsHalfFloat: boolean\n\n private pickingTarget: WebGLRenderTarget\n private sampleTarget: WebGLRenderTarget\n private holdTarget: WebGLRenderTarget\n\n private compositeUniforms: {\n tForeground: Uniform\n scale: Uniform\n }\n private compositeMaterial: ShaderMaterial\n private compositeCamera: OrthographicCamera\n private compositeScene: Scene\n\n private boundingBoxMesh: LineSegments\n boundingBox = new Box3()\n private boundingBoxSize = new Vector3()\n private boundingBoxLength = 0\n\n private info = {\n memory: {\n programs: 0,\n geometries: 0,\n textures: 0\n },\n render: {\n calls: 0,\n vertices: 0,\n faces: 0,\n points: 0\n }\n }\n\n private distVector = new Vector3()\n\n constructor (idOrElement: string|HTMLElement) {\n this.signals = {\n ticked: new Signal(),\n rendered: new Signal()\n }\n\n if (typeof idOrElement === 'string') {\n const elm = document.getElementById(idOrElement)\n if (elm === null) {\n this.container = document.createElement('div')\n }else {\n this.container = elm\n }\n } else if (idOrElement instanceof HTMLElement) {\n this.container = idOrElement\n } else {\n this.container = document.createElement('div')\n }\n\n if (this.container === document.body) {\n this.width = window.innerWidth || 1\n this.height = window.innerHeight || 1\n } else {\n const box = this.container.getBoundingClientRect()\n this.width = box.width || 1\n this.height = box.height || 1\n this.container.style.overflow = 'hidden'\n }\n\n this.wrapper = document.createElement('div')\n this.wrapper.style.position = 'relative'\n this.container.appendChild(this.wrapper)\n\n this._initParams()\n this._initStats()\n this._initCamera()\n this._initScene()\n\n if (this._initRenderer() === false) {\n Log.error('Viewer: could not initialize renderer')\n return\n }\n\n this._initHelper()\n\n // fog & background\n this.setBackground()\n this.setFog()\n\n this.animate = this.animate.bind(this)\n }\n\n private _initParams () {\n this.parameters = {\n fogColor: new Color(0x000000),\n fogNear: 50,\n fogFar: 100,\n\n backgroundColor: new Color(0x000000),\n\n cameraType: 'perspective',\n cameraFov: 40,\n cameraEyeSep: 0.3,\n cameraZ: -80, // FIXME initial value should be automatically determined\n\n clipNear: 0,\n clipFar: 100,\n clipDist: 10,\n clipMode: 'scene',\n clipScale: 'relative',\n\n lightColor: new Color(0xdddddd),\n lightIntensity: 1.0,\n ambientColor: new Color(0xdddddd),\n ambientIntensity: 0.2,\n\n sampleLevel: 0,\n\n // output encoding: use sRGB for a linear internal workflow, linear for traditional sRGB workflow.\n rendererEncoding: LinearEncoding,\n }\n }\n\n private _initCamera () {\n const lookAt = new Vector3(0, 0, 0)\n const {width, height} = this\n\n this.perspectiveCamera = new PerspectiveCamera(\n this.parameters.cameraFov, width / height\n )\n this.perspectiveCamera.position.z = this.parameters.cameraZ\n this.perspectiveCamera.lookAt(lookAt)\n\n this.orthographicCamera = new OrthographicCamera(\n width / -2, width / 2, height / 2, height / -2\n )\n this.orthographicCamera.position.z = this.parameters.cameraZ\n this.orthographicCamera.lookAt(lookAt)\n\n this.stereoCamera = new StereoCamera()\n this.stereoCamera.aspect = 0.5\n this.stereoCamera.eyeSep = this.parameters.cameraEyeSep\n\n const cameraType = this.parameters.cameraType\n if (cameraType === 'orthographic') {\n this.camera = this.orthographicCamera\n } else if(cameraType === 'perspective' || cameraType === 'stereo') {\n this.camera = this.perspectiveCamera\n } else {\n throw new Error(`Unknown cameraType '${cameraType}'`)\n }\n this.camera.updateProjectionMatrix()\n }\n\n private _initStats () {\n this.stats = new Stats()\n }\n\n private _initScene () {\n if (!this.scene) {\n this.scene = new Scene()\n this.scene.name = 'scene'\n }\n\n this.rotationGroup = new Group()\n this.rotationGroup.name = 'rotationGroup'\n this.scene.add(this.rotationGroup)\n\n this.translationGroup = new Group()\n this.translationGroup.name = 'translationGroup'\n this.rotationGroup.add(this.translationGroup)\n\n this.modelGroup = new Group()\n this.modelGroup.name = 'modelGroup'\n this.translationGroup.add(this.modelGroup)\n\n this.pickingGroup = new Group()\n this.pickingGroup.name = 'pickingGroup'\n this.translationGroup.add(this.pickingGroup)\n\n this.backgroundGroup = new Group()\n this.backgroundGroup.name = 'backgroundGroup'\n this.translationGroup.add(this.backgroundGroup)\n\n this.helperGroup = new Group()\n this.helperGroup.name = 'helperGroup'\n this.translationGroup.add(this.helperGroup)\n\n // fog\n\n this.scene.fog = new Fog(this.parameters.fogColor.getHex())\n\n // light\n\n this.spotLight = new SpotLight(\n this.parameters.lightColor.getHex(), this.parameters.lightIntensity\n )\n this.scene.add(this.spotLight)\n\n this.ambientLight = new AmbientLight(\n this.parameters.ambientColor.getHex(), this.parameters.ambientIntensity\n )\n this.scene.add(this.ambientLight)\n }\n\n private _initRenderer () {\n const dpr = window.devicePixelRatio\n const {width, height} = this\n\n try {\n this.renderer = new WebGLRenderer({\n preserveDrawingBuffer: true,\n alpha: true,\n antialias: true\n })\n } catch (e) {\n this.wrapper.innerHTML = WebglErrorMessage\n return false\n }\n this.renderer.setPixelRatio(dpr)\n this.renderer.setSize(width, height)\n this.renderer.autoClear = false\n this.renderer.sortObjects = true\n this.renderer.outputEncoding = this.parameters.rendererEncoding\n\n const gl = this.renderer.getContext()\n // console.log(gl.getContextAttributes().antialias)\n // console.log(gl.getParameter(gl.SAMPLES))\n\n // For WebGL1, extensions must be explicitly enabled.\n // The following are builtin to WebGL2 (and don't appear as\n // extensions)\n // EXT_frag_depth, OES_element_index_uint, OES_texture_float\n // OES_texture_half_float\n\n // The WEBGL_color_buffer_float extension is replaced by\n // EXT_color_buffer_float\n\n // If not webgl2 context, explicitly check for these\n if (!this.renderer.capabilities.isWebGL2) {\n setExtensionFragDepth(this.renderer.extensions.get('EXT_frag_depth'))\n this.renderer.extensions.get('OES_element_index_uint')\n\n setSupportsReadPixelsFloat(\n (this.renderer.extensions.get('OES_texture_float') &&\n this.renderer.extensions.get('WEBGL_color_buffer_float')) ||\n (this.renderer.extensions.get('OES_texture_float') &&\n testTextureSupport(gl.FLOAT))\n )\n // picking texture\n\n this.renderer.extensions.get('OES_texture_float')\n\n this.supportsHalfFloat = (\n this.renderer.extensions.get('OES_texture_half_float') &&\n testTextureSupport(0x8D61)\n )\n\n } else {\n setExtensionFragDepth(true)\n setSupportsReadPixelsFloat(\n this.renderer.extensions.get('EXT_color_buffer_float')\n )\n this.supportsHalfFloat = true\n }\n\n this.wrapper.appendChild(this.renderer.domElement)\n\n const dprWidth = width * dpr\n const dprHeight = height * dpr\n\n\n if (Debug) {\n console.log(JSON.stringify({\n 'Browser': Browser,\n 'OES_texture_float': !!this.renderer.extensions.get('OES_texture_float'),\n 'OES_texture_half_float': !!this.renderer.extensions.get('OES_texture_half_float'),\n 'WEBGL_color_buffer_float': !!this.renderer.extensions.get('WEBGL_color_buffer_float'),\n 'testTextureSupport Float': testTextureSupport(gl.FLOAT),\n 'testTextureSupport HalfFloat': testTextureSupport(0x8D61),\n 'this.supportsHalfFloat': this.supportsHalfFloat,\n 'SupportsReadPixelsFloat': SupportsReadPixelsFloat\n }, null, 2))\n }\n\n this.pickingTarget = new WebGLRenderTarget(\n dprWidth, dprHeight,\n {\n minFilter: NearestFilter,\n magFilter: NearestFilter,\n stencilBuffer: false,\n format: RGBAFormat,\n type: SupportsReadPixelsFloat ? FloatType : UnsignedByteType\n }\n )\n this.pickingTarget.texture.generateMipmaps = false\n this.pickingTarget.texture.encoding = this.parameters.rendererEncoding\n\n // workaround to reset the gl state after using testTextureSupport\n // fixes some bug where nothing is rendered to the canvas\n // when animations are started on page load\n this.renderer.setRenderTarget(this.pickingTarget)\n this.renderer.clear()\n this.renderer.setRenderTarget(null!)\n\n // ssaa textures\n\n this.sampleTarget = new WebGLRenderTarget(\n dprWidth, dprHeight,\n {\n minFilter: LinearFilter,\n magFilter: LinearFilter,\n format: RGBAFormat\n }\n )\n this.sampleTarget.texture.encoding = this.parameters.rendererEncoding\n\n this.holdTarget = new WebGLRenderTarget(\n dprWidth, dprHeight,\n {\n minFilter: NearestFilter,\n magFilter: NearestFilter,\n format: RGBAFormat,\n type: UnsignedByteType\n // using HalfFloatType or FloatType does not work on some Chrome 61 installations\n // type: this.supportsHalfFloat ? HalfFloatType : (\n // SupportsReadPixelsFloat ? FloatType : UnsignedByteType\n // )\n }\n )\n this.holdTarget.texture.encoding = this.parameters.rendererEncoding\n\n this.compositeUniforms = {\n 'tForeground': new Uniform(this.sampleTarget.texture),\n 'scale': new Uniform(1.0)\n }\n\n this.compositeMaterial = new ShaderMaterial({\n uniforms: this.compositeUniforms,\n vertexShader: getShader('Quad.vert'),\n fragmentShader: getShader('Quad.frag'),\n premultipliedAlpha: true,\n transparent: true,\n blending: AdditiveBlending,\n depthTest: false,\n depthWrite: false\n })\n\n this.compositeCamera = new OrthographicCamera(-1, 1, 1, -1, 0, 1)\n this.compositeScene = new Scene()\n this.compositeScene.name = 'compositeScene'\n this.compositeScene.add(new Mesh(\n new PlaneGeometry(2, 2), this.compositeMaterial\n ))\n }\n\n private _initHelper () {\n const indices = new Uint16Array([\n 0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6,\n 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7\n ])\n const positions = new Float32Array(8 * 3)\n\n const bbGeometry = new BufferGeometry()\n bbGeometry.setIndex(new BufferAttribute(indices, 1))\n bbGeometry.setAttribute('position', new BufferAttribute(positions, 3))\n const bbMaterial = new ShaderMaterial({\n uniforms: { 'uColor': { value: new Color('skyblue') } },\n vertexShader: getShader('BasicLine.vert'),\n fragmentShader: getShader('BasicLine.frag')\n })\n\n this.boundingBoxMesh = new LineSegments(bbGeometry, bbMaterial)\n this.helperGroup.add(this.boundingBoxMesh)\n }\n\n updateHelper () {\n const position = ((this.boundingBoxMesh.geometry as BufferGeometry).attributes as any).position // TODO\n const array = position.array\n const {min, max} = this.boundingBox\n\n array[ 0 ] = max.x; array[ 1 ] = max.y; array[ 2 ] = max.z\n array[ 3 ] = min.x; array[ 4 ] = max.y; array[ 5 ] = max.z\n array[ 6 ] = min.x; array[ 7 ] = min.y; array[ 8 ] = max.z\n array[ 9 ] = max.x; array[ 10 ] = min.y; array[ 11 ] = max.z\n array[ 12 ] = max.x; array[ 13 ] = max.y; array[ 14 ] = min.z\n array[ 15 ] = min.x; array[ 16 ] = max.y; array[ 17 ] = min.z\n array[ 18 ] = min.x; array[ 19 ] = min.y; array[ 20 ] = min.z\n array[ 21 ] = max.x; array[ 22 ] = min.y; array[ 23 ] = min.z\n\n position.needsUpdate = true\n\n if (!this.boundingBox.isEmpty()) {\n this.boundingBoxMesh.geometry.computeBoundingSphere()\n }\n }\n\n /** Distance from origin (lookAt point) */\n get cameraDistance(): number {\n return Math.abs(this.camera.position.z)\n }\n\n /** Set distance from origin (lookAt point); along the -z axis */\n set cameraDistance(d: number) {\n this.camera.position.z = -d\n }\n\n add (buffer: Buffer, instanceList?: BufferInstance[]) {\n // Log.time( \"Viewer.add\" );\n\n if (instanceList) {\n instanceList.forEach(instance => this.addBuffer(buffer, instance))\n } else {\n this.addBuffer(buffer)\n }\n\n buffer.group.name = 'meshGroup'\n buffer.wireframeGroup.name = 'wireframeGroup'\n if (buffer.parameters.background) {\n this.backgroundGroup.add(buffer.group)\n this.backgroundGroup.add(buffer.wireframeGroup)\n } else {\n this.modelGroup.add(buffer.group)\n this.modelGroup.add(buffer.wireframeGroup)\n }\n\n if (buffer.pickable) {\n this.pickingGroup.add(buffer.pickingGroup)\n }\n\n if (Debug) this.updateHelper()\n\n // Log.timeEnd( \"Viewer.add\" );\n }\n\n addBuffer (buffer: Buffer, instance?: BufferInstance) {\n // Log.time( \"Viewer.addBuffer\" );\n\n function setUserData (object: Object3D) {\n if (object instanceof Group) {\n object.children.forEach(setUserData)\n } else {\n object.userData.buffer = buffer\n object.userData.instance = instance\n object.onBeforeRender = onBeforeRender\n }\n }\n\n const mesh = buffer.getMesh()\n if (instance) {\n mesh.applyMatrix4(instance.matrix)\n }\n setUserData(mesh)\n buffer.group.add(mesh)\n\n const wireframeMesh = buffer.getWireframeMesh()\n if (instance) {\n // wireframeMesh.applyMatrix( instance.matrix );\n wireframeMesh.matrix.copy(mesh.matrix)\n wireframeMesh.position.copy(mesh.position)\n wireframeMesh.quaternion.copy(mesh.quaternion)\n wireframeMesh.scale.copy(mesh.scale)\n }\n setUserData(wireframeMesh)\n buffer.wireframeGroup.add(wireframeMesh)\n\n if (buffer.pickable) {\n const pickingMesh = buffer.getPickingMesh()\n if (instance) {\n // pickingMesh.applyMatrix( instance.matrix );\n pickingMesh.matrix.copy(mesh.matrix)\n pickingMesh.position.copy(mesh.position)\n pickingMesh.quaternion.copy(mesh.quaternion)\n pickingMesh.scale.copy(mesh.scale)\n }\n setUserData(pickingMesh)\n buffer.pickingGroup.add(pickingMesh)\n }\n\n if (instance) {\n this._updateBoundingBox(buffer.geometry, buffer.matrix, instance.matrix)\n } else {\n this._updateBoundingBox(buffer.geometry, buffer.matrix)\n }\n\n // Log.timeEnd( \"Viewer.addBuffer\" );\n }\n\n remove (buffer: Buffer) {\n this.translationGroup.children.forEach(function (group) {\n group.remove(buffer.group)\n group.remove(buffer.wireframeGroup)\n })\n\n if (buffer.pickable) {\n this.pickingGroup.remove(buffer.pickingGroup)\n }\n\n this.updateBoundingBox()\n if (Debug) this.updateHelper()\n\n // this.requestRender();\n }\n\n private _updateBoundingBox (geometry?: BufferGeometry, matrix?: Matrix4, instanceMatrix?: Matrix4) {\n const boundingBox = this.boundingBox\n\n function updateGeometry (geometry: BufferGeometry, matrix?: Matrix4, instanceMatrix?: Matrix4) {\n if (geometry.boundingBox == null) {\n geometry.computeBoundingBox()\n }\n\n const geoBoundingBox = (geometry.boundingBox as Box3).clone()\n\n if (matrix) {\n geoBoundingBox.applyMatrix4(matrix)\n }\n if (instanceMatrix) {\n geoBoundingBox.applyMatrix4(instanceMatrix)\n }\n\n if (geoBoundingBox.min.equals(geoBoundingBox.max)) {\n // mainly to give a single impostor geometry some volume\n // as it is only expanded in the shader on the GPU\n geoBoundingBox.expandByScalar(5)\n }\n\n boundingBox.union(geoBoundingBox)\n }\n\n function updateNode (node: Mesh) {\n if (node.geometry !== undefined) {\n let matrix, instanceMatrix\n if (node.userData.buffer) {\n matrix = node.userData.buffer.matrix\n }\n if (node.userData.instance) {\n instanceMatrix = node.userData.instance.matrix\n }\n updateGeometry(node.geometry as BufferGeometry, matrix, instanceMatrix) // TODO\n }\n }\n\n if (geometry) {\n updateGeometry(geometry, matrix, instanceMatrix)\n } else {\n boundingBox.makeEmpty()\n this.modelGroup.traverse(updateNode)\n this.backgroundGroup.traverse(updateNode)\n }\n\n boundingBox.getSize(this.boundingBoxSize)\n this.boundingBoxLength = this.boundingBoxSize.length()\n }\n\n updateBoundingBox () {\n this._updateBoundingBox()\n if (Debug) this.updateHelper()\n }\n\n getPickingPixels () {\n const {width, height} = this\n\n const n = width * height * 4\n const imgBuffer = SupportsReadPixelsFloat ? new Float32Array(n) : new Uint8Array(n)\n\n this.render(true)\n this.renderer.readRenderTargetPixels(\n this.pickingTarget, 0, 0, width, height, imgBuffer\n )\n\n return imgBuffer\n }\n\n getImage (picking: boolean) {\n return new Promise(resolve => {\n if (picking) {\n const {width, height} = this\n const n = width * height * 4\n let imgBuffer = this.getPickingPixels()\n\n if (SupportsReadPixelsFloat) {\n const imgBuffer2 = new Uint8Array(n)\n for (let i = 0; i < n; ++i) {\n imgBuffer2[ i ] = Math.round(imgBuffer[ i ] * 255)\n }\n imgBuffer = imgBuffer2\n }\n\n const canvas = document.createElement('canvas')\n canvas.width = width\n canvas.height = height\n const ctx = canvas.getContext('2d')! // TODO\n const imgData = ctx.getImageData(0, 0, width, height)\n imgData.data.set(imgBuffer as any) // TODO\n ctx.putImageData(imgData, 0, 0)\n canvas.toBlob(resolve as any, 'image/png') // TODO\n } else {\n this.renderer.domElement.toBlob(resolve as any, 'image/png') // TODO\n }\n })\n }\n\n makeImage (params: Partial = {}) {\n return makeImage(this, params)\n }\n\n setLight (color: Color|number|string, intensity: number, ambientColor: Color|number|string, ambientIntensity: number) {\n const p = this.parameters\n\n if (color !== undefined) p.lightColor.set(color as string) // TODO\n if (intensity !== undefined) p.lightIntensity = intensity\n if (ambientColor !== undefined) p.ambientColor.set(ambientColor as string) // TODO\n if (ambientIntensity !== undefined) p.ambientIntensity = ambientIntensity\n\n this.requestRender()\n }\n\n setFog (color?: Color|number|string, near?: number, far?: number) {\n const p = this.parameters\n\n if (color !== undefined) p.fogColor.set(color as string) // TODO\n if (near !== undefined) p.fogNear = near\n if (far !== undefined) p.fogFar = far\n\n this.requestRender()\n }\n\n setBackground (color?: Color|number|string) {\n const p = this.parameters\n\n if (color) p.backgroundColor.set(color as string) // TODO\n\n this.setFog(p.backgroundColor)\n this.renderer.setClearColor(p.backgroundColor, 0)\n this.renderer.domElement.style.backgroundColor = p.backgroundColor.getStyle()\n\n this.requestRender()\n }\n\n setSampling (level: number) {\n if (level !== undefined) {\n this.parameters.sampleLevel = level\n this.sampleLevel = level\n }\n\n this.requestRender()\n }\n\n /**\n * Set the output color encoding, i.e. how the renderer translates\n * colorspaces as it renders to the screen.\n\n * The default is LinearEncoding, because the internals of NGL are\n * already sRGB so no translation is needed to show sRGB colors.\n * Set to sRGBEncoding to create a linear workflow, and also call\n * `setColorEncoding(LinearEncoding)` to linearize colors on input.\n * @see setColorEncoding\n */\n private setOutputEncoding (encoding: TextureEncoding) {\n this.parameters.rendererEncoding = encoding\n this.renderer.outputEncoding = encoding\n this.pickingTarget.texture.encoding = encoding\n this.sampleTarget.texture.encoding = encoding\n this.holdTarget.texture.encoding = encoding\n }\n\n /**\n * Set the internal color workflow, linear or sRGB.\n * sRGB, the default, is more \"vibrant\" at the cost of accuracy.\n * Linear gives more accurate results, especially for transparent objects.\n * In all cases, the output is always sRGB; this just affects how colors are computed internally.\n * Call this just after creating the viewer, before loading any models.\n */\n setColorWorkflow (encoding: ColorWorkflow) {\n if (encoding != 'linear' && encoding != 'sRGB')\n throw new Error(`setColorWorkflow: invalid color workflow ${encoding}`)\n setColorSpace(encoding == 'linear' ? 'linear' : 'sRGB')\n this.setOutputEncoding(encoding == 'linear' ? sRGBEncoding : LinearEncoding)\n // Note: this doesn't rebuild models, so existing geometry will have\n // the old color encoding.\n this.requestRender()\n }\n\n setCamera (type: CameraType, fov?: number, eyeSep?: number) {\n const p = this.parameters\n\n if (type) p.cameraType = type\n if (fov) p.cameraFov = fov\n if (eyeSep) p.cameraEyeSep = eyeSep\n\n if (p.cameraType === 'orthographic') {\n if (this.camera !== this.orthographicCamera) {\n this.camera = this.orthographicCamera\n this.camera.position.copy(this.perspectiveCamera.position)\n this.camera.up.copy(this.perspectiveCamera.up)\n this.updateZoom()\n }\n } else if (p.cameraType === 'perspective' || p.cameraType === 'stereo') {\n if (this.camera !== this.perspectiveCamera) {\n this.camera = this.perspectiveCamera\n this.camera.position.copy(this.orthographicCamera.position)\n this.camera.up.copy(this.orthographicCamera.up)\n }\n } else {\n throw new Error(`Unknown cameraType '${p.cameraType}'`)\n }\n\n this.perspectiveCamera.fov = p.cameraFov\n this.stereoCamera.eyeSep = p.cameraEyeSep\n this.camera.updateProjectionMatrix()\n\n this.requestRender()\n }\n\n setClip (near: number, far: number, dist: number, clipMode?: string, clipScale?: string) {\n const p = this.parameters\n\n if (near !== undefined) p.clipNear = near\n if (far !== undefined) p.clipFar = far\n if (dist !== undefined) p.clipDist = dist\n if (clipMode !== undefined) p.clipMode = clipMode\n if (clipScale !== undefined) p.clipScale = clipScale\n\n this.requestRender()\n }\n\n setSize (width: number, height: number) {\n this.width = width || 1\n this.height = height || 1\n\n this.perspectiveCamera.aspect = this.width / this.height\n this.orthographicCamera.left = -this.width / 2\n this.orthographicCamera.right = this.width / 2\n this.orthographicCamera.top = this.height / 2\n this.orthographicCamera.bottom = -this.height / 2\n this.camera.updateProjectionMatrix()\n\n const dpr = window.devicePixelRatio\n\n this.renderer.setPixelRatio(dpr)\n this.renderer.setSize(width, height)\n\n const dprWidth = this.width * dpr\n const dprHeight = this.height * dpr\n\n this.pickingTarget.setSize(dprWidth, dprHeight)\n this.sampleTarget.setSize(dprWidth, dprHeight)\n this.holdTarget.setSize(dprWidth, dprHeight)\n\n this.requestRender()\n }\n\n handleResize () {\n if (this.container === document.body) {\n this.setSize(window.innerWidth, window.innerHeight)\n } else {\n const box = this.container.getBoundingClientRect()\n this.setSize(box.width, box.height)\n }\n }\n\n updateInfo (reset?: boolean) {\n const { memory, render } = this.info\n\n if (reset) {\n memory.programs = 0\n memory.geometries = 0\n memory.textures = 0\n\n render.calls = 0\n render.vertices = 0\n render.points = 0\n } else {\n const rInfo = this.renderer.info\n const rMemory = rInfo.memory\n const rRender = rInfo.render\n\n memory.geometries = rMemory.geometries\n memory.textures = rMemory.textures\n\n render.calls += rRender.calls\n render.faces += rRender.triangles\n render.points += rRender.points\n }\n }\n\n animate () {\n this.signals.ticked.dispatch(this.stats)\n const delta = window.performance.now() - this.stats.startTime\n\n if (delta > 500 && !this.isStill && this.sampleLevel < 3 && this.sampleLevel !== -1) {\n const currentSampleLevel = this.sampleLevel\n this.sampleLevel = 3\n this.renderPending = true\n this.render()\n this.isStill = true\n this.sampleLevel = currentSampleLevel\n if (Debug) Log.log('rendered still frame')\n }\n\n this.frameRequest = window.requestAnimationFrame(this.animate)\n }\n\n pick (x: number, y: number) {\n if (this.parameters.cameraType === 'stereo') {\n // TODO picking broken for stereo camera\n return {\n 'pid': 0,\n 'instance': undefined,\n 'picker': undefined\n }\n }\n\n x *= window.devicePixelRatio\n y *= window.devicePixelRatio\n\n x = Math.max(x - 2, 0)\n y = Math.max(y - 2, 0)\n\n let pid = 0, instance, picker\n const pixelBuffer = SupportsReadPixelsFloat ? pixelBufferFloat : pixelBufferUint\n\n this.render(true)\n this.renderer.readRenderTargetPixels(\n this.pickingTarget, x, y, 5, 5, pixelBuffer\n )\n\n for (let i = 0; i < pixelOrder.length; i++) {\n\n const offset = pixelOrder[i] * 4\n\n const oid = Math.round(pixelBuffer[ offset + 3 ])\n const object = this.pickingGroup.getObjectById(oid)\n if (object) {\n instance = object.userData.instance\n picker = object.userData.buffer.picking\n } else {\n continue\n }\n\n if (SupportsReadPixelsFloat) {\n pid =\n ((Math.round(pixelBuffer[offset] * 255) << 16) & 0xFF0000) |\n ((Math.round(pixelBuffer[offset + 1] * 255) << 8) & 0x00FF00) |\n ((Math.round(pixelBuffer[offset + 2] * 255)) & 0x0000FF)\n } else {\n pid =\n (pixelBuffer[offset] << 16) |\n (pixelBuffer[offset + 1] << 8) |\n (pixelBuffer[offset + 2])\n }\n }\n // if( Debug ){\n // const rgba = Array.apply( [], pixelBuffer );\n // Log.log( pixelBuffer );\n // Log.log(\n // \"picked color\",\n // rgba.map( c => { return c.toPrecision( 2 ) } )\n // );\n // Log.log( \"picked pid\", pid );\n // Log.log( \"picked oid\", oid );\n // Log.log( \"picked object\", object );\n // Log.log( \"picked instance\", instance );\n // Log.log( \"picked position\", x, y );\n // Log.log( \"devicePixelRatio\", window.devicePixelRatio );\n // }\n\n return { pid, instance, picker }\n }\n\n requestRender () {\n if (this.renderPending) {\n // Log.info(\"there is still a 'render' call pending\")\n return\n }\n\n // start gathering stats anew after inactivity\n if (window.performance.now() - this.stats.startTime > 22) {\n this.stats.begin()\n this.isStill = false\n }\n\n this.renderPending = true\n\n window.requestAnimationFrame(() => {\n this.render()\n this.stats.update()\n })\n }\n\n updateZoom () {\n const fov = degToRad(this.perspectiveCamera.fov)\n const height = 2 * Math.tan(fov / 2) * this.cameraDistance\n this.orthographicCamera.zoom = this.height / height\n }\n\n /**\n * Convert an absolute clip value to a relative one using bRadius.\n *\n * 0.0 -> 50.0\n * bRadius -> 0.0\n */\n absoluteToRelative (d: number) :number {\n return 50 * (1 - d / this.bRadius)\n }\n\n /**\n * Convert a relative clip value to an absolute one using bRadius\n *\n * 0.0 -> bRadius\n * 50.0 -> 0.0\n */\n relativeToAbsolute (d: number) : number {\n return this.bRadius * (1 - d / 50)\n }\n\n /**\n * Intepret clipMode, clipScale and set the camera and fog clipping.\n * Also ensures bRadius and cDist are valid\n */\n private __updateClipping () {\n const p = this.parameters\n\n // bRadius must always be updated for material-based clipping\n // and for focus calculations\n this.bRadius = Math.max(10, this.boundingBoxLength * 0.5)\n\n // FL: Removed below, but leaving commented as I don't understand intention\n // this.bRadius += this.boundingBox.getCenter(this.distVector).length()\n\n if (!isFinite(this.bRadius)) {\n this.bRadius = 50\n }\n\n this.camera.getWorldPosition(this.distVector)\n this.cDist = this.distVector.length()\n if (!this.cDist) {\n // recover from a broken (NaN) camera position\n this.cameraDistance = Math.abs(p.cameraZ)\n this.cDist = Math.abs(p.cameraZ)\n }\n\n // fog\n const fog = this.scene.fog as Fog\n fog.color.set(p.fogColor)\n\n if (p.clipMode === 'camera') {\n // Always interpret clipScale as absolute for clipMode camera\n\n this.camera.near = p.clipNear\n this.camera.far = p.clipFar\n fog.near = p.fogNear\n fog.far = p.fogFar\n\n } else {\n // scene mode\n\n if (p.clipScale === 'absolute') {\n // absolute scene mode; offset clip planes from scene center\n // (note: positive values move near plane towards camera and rear plane away)\n\n this.camera.near = this.cDist - p.clipNear\n this.camera.far = this.cDist + p.clipFar\n fog.near = this.cDist - p.fogNear\n fog.far = this.cDist + p.fogFar\n\n } else {\n // relative scene mode (default): convert pecentages to Angstroms\n\n const nearFactor = (50 - p.clipNear) / 50\n const farFactor = -(50 - p.clipFar) / 50\n this.camera.near = this.cDist - (this.bRadius * nearFactor)\n this.camera.far = this.cDist + (this.bRadius * farFactor)\n\n const fogNearFactor = (50 - p.fogNear) / 50\n const fogFarFactor = -(50 - p.fogFar) / 50\n fog.near = this.cDist - (this.bRadius * fogNearFactor)\n fog.far = this.cDist + (this.bRadius * fogFarFactor)\n }\n }\n\n if (p.clipMode !== 'camera') {\n\n if (this.camera.type === 'PerspectiveCamera') {\n\n this.camera.near = Math.max(0.1, p.clipDist, this.camera.near)\n this.camera.far = Math.max(1, this.camera.far)\n fog.near = Math.max(0.1, fog.near)\n fog.far = Math.max(1, fog.far)\n } else if (this.camera.type === 'OrthographicCamera') {\n\n if (p.clipDist > 0) {\n this.camera.near = Math.max(p.clipDist, this.camera.near)\n }\n }\n }\n }\n\n private __updateCamera () {\n const camera = this.camera\n camera.updateMatrix()\n camera.updateMatrixWorld(true)\n camera.updateProjectionMatrix()\n\n updateMaterialUniforms(this.scene, camera, this.renderer, this.cDist, this.bRadius)\n sortProjectedPosition(this.scene, camera)\n }\n\n private __setVisibility (model: boolean, picking: boolean, background: boolean, helper: boolean) {\n this.modelGroup.visible = model\n this.pickingGroup.visible = picking\n this.backgroundGroup.visible = background\n this.helperGroup.visible = helper\n }\n\n private __updateLights () {\n this.spotLight.color.set(this.parameters.lightColor)\n this.spotLight.intensity = this.parameters.lightIntensity\n\n this.distVector.copy(this.camera.position).setLength(this.boundingBoxLength * 100)\n this.spotLight.position.copy(this.camera.position).add(this.distVector)\n\n this.ambientLight.color.set(this.parameters.ambientColor)\n this.ambientLight.intensity = this.parameters.ambientIntensity\n }\n\n private __renderPickingGroup (camera: PerspectiveCamera|OrthographicCamera) {\n this.renderer.setRenderTarget(this.pickingTarget || null)\n this.renderer.clear()\n this.__setVisibility(false, true, false, false)\n this.renderer.render(this.scene, camera)\n // back to standard render target\n this.renderer.setRenderTarget(null)\n this.updateInfo()\n\n // if (Debug) {\n // this.__setVisibility(false, true, false, true);\n\n // this.renderer.clear();\n // this.renderer.render(this.scene, camera);\n // }\n }\n\n private __renderModelGroup (camera: PerspectiveCamera|OrthographicCamera, renderTarget?: WebGLRenderTarget) {\n this.renderer.setRenderTarget(renderTarget || null)\n this.renderer.clear()\n this.__setVisibility(false, false, true, false)\n this.renderer.render(this.scene, camera)\n this.renderer.clear(false, true, true)\n this.updateInfo()\n\n this.__setVisibility(true, false, false, Debug)\n this.renderer.render(this.scene, camera)\n this.renderer.setRenderTarget(null) // set back to default canvas\n this.updateInfo()\n }\n\n private __renderSuperSample (camera: PerspectiveCamera|OrthographicCamera, renderTarget?: WebGLRenderTarget) {\n // based on the Supersample Anti-Aliasing Render Pass\n // contributed to three.js by bhouston / http://clara.io/\n //\n // This manual approach to SSAA re-renders the scene ones for\n // each sample with camera jitter and accumulates the results.\n // References: https://en.wikipedia.org/wiki/Supersampling\n const offsetList = JitterVectors[ Math.max(0, Math.min(this.sampleLevel, 5)) ]\n\n const baseSampleWeight = 1.0 / offsetList.length\n const roundingRange = 1 / 32\n\n this.compositeUniforms.tForeground.value = this.sampleTarget.texture\n\n let width = this.sampleTarget.width\n const height = this.sampleTarget.height\n if (this.parameters.cameraType === 'stereo') {\n width /= 2\n }\n\n // render the scene multiple times, each slightly jitter offset\n // from the last and accumulate the results.\n for (let i = 0; i < offsetList.length; ++i) {\n const offset = offsetList[ i ]\n camera.setViewOffset(\n width, height, offset[ 0 ], offset[ 1 ], width, height\n )\n camera.updateProjectionMatrix()\n updateCameraUniforms(this.scene, camera)\n\n let sampleWeight = baseSampleWeight\n // the theory is that equal weights for each sample lead to an\n // accumulation of rounding errors.\n // The following equation varies the sampleWeight per sample\n // so that it is uniformly distributed across a range of values\n // whose rounding errors cancel each other out.\n const uniformCenteredDistribution = -0.5 + (i + 0.5) / offsetList.length\n sampleWeight += roundingRange * uniformCenteredDistribution\n this.compositeUniforms.scale.value = sampleWeight\n\n this.__renderModelGroup(camera, this.sampleTarget)\n this.renderer.setRenderTarget(this.holdTarget)\n if (i === 0) {\n this.renderer.clear()\n }\n\n this.renderer.render(this.compositeScene, this.compositeCamera)\n }\n\n this.compositeUniforms.scale.value = 1.0\n this.compositeUniforms.tForeground.value = this.holdTarget.texture\n\n camera.clearViewOffset()\n this.renderer.setRenderTarget(renderTarget || null)\n this.renderer.clear()\n this.renderer.render(this.compositeScene, this.compositeCamera)\n }\n\n private __renderStereo (picking = false, _renderTarget?: WebGLRenderTarget) {\n const stereoCamera = this.stereoCamera\n stereoCamera.update(this.perspectiveCamera);\n\n const renderer = this.renderer\n let size = new Vector2()\n renderer.getSize(size)\n\n renderer.setScissorTest(true)\n\n renderer.setScissor(0, 0, size.width / 2, size.height)\n renderer.setViewport(0, 0, size.width / 2, size.height)\n updateCameraUniforms(this.scene, stereoCamera.cameraL)\n this.__render(picking, stereoCamera.cameraL)\n\n renderer.setScissor(size.width / 2, 0, size.width / 2, size.height)\n renderer.setViewport(size.width / 2, 0, size.width / 2, size.height)\n updateCameraUniforms(this.scene, stereoCamera.cameraR)\n this.__render(picking, stereoCamera.cameraR)\n\n renderer.setScissorTest(false)\n renderer.setViewport(0, 0, size.width, size.height)\n }\n\n private __render(picking = false, camera: PerspectiveCamera|OrthographicCamera, renderTarget?: WebGLRenderTarget) {\n if (picking) {\n if (!this.lastRenderedPicking) this.__renderPickingGroup(camera)\n } else if (this.sampleLevel > 0 && this.parameters.cameraType !== 'stereo') {\n // TODO super sample broken for stereo camera\n this.__renderSuperSample(camera, renderTarget)\n } else {\n this.__renderModelGroup(camera, renderTarget)\n }\n }\n\n render (picking = false, renderTarget?: WebGLRenderTarget) {\n if (this.rendering) {\n Log.warn(\"'tried to call 'render' from within 'render'\")\n return\n }\n\n // Log.time('Viewer.render')\n\n this.rendering = true\n\n try {\n this.__updateClipping()\n this.__updateCamera()\n this.__updateLights()\n this.updateInfo(true)\n\n // render\n if (this.parameters.cameraType === 'stereo') {\n this.__renderStereo(picking, renderTarget)\n } else {\n this.__render(picking, this.camera, renderTarget)\n }\n this.lastRenderedPicking = picking\n } finally {\n this.rendering = false\n this.renderPending = false\n }\n this.signals.rendered.dispatch()\n\n // Log.timeEnd('Viewer.render')\n // Log.log(this.info.memory, this.info.render)\n }\n\n clear () {\n Log.log('scene cleared')\n this.scene.remove(this.rotationGroup)\n this._initScene()\n this.renderer.clear()\n }\n\n dispose () {\n this.renderer.dispose()\n window.cancelAnimationFrame(this.frameRequest)\n }\n}\n","/**\n * @file Mouse Observer\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector2 } from 'three'\nimport { Signal } from 'signals'\n\nimport { LeftMouseButton, RightMouseButton } from '../constants'\nimport { defaults } from '../utils'\nimport Viewer from '../viewer/viewer'\nimport MouseControls from '../controls/mouse-controls'\n\ntype Optional = Pick, K> & Omit;\n\n/**\n * @example\n * mouseObserver.signals.scrolled.add( function( delta ){ ... } );\n *\n * @typedef {Object} MouseSignals\n * @property {Signal} moved - on move: deltaX, deltaY\n * @property {Signal} scrolled - on scroll: delta\n * @property {Signal} dragged - on drag: deltaX, deltaY\n * @property {Signal} dropped - on drop\n * @property {Signal} clicked - on click\n * @property {Signal} hovered - on hover\n */\n\nfunction getTouchDistance (event: TouchEvent) {\n const dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX\n const dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY\n return Math.sqrt(dx * dx + dy * dy)\n}\n\nfunction getMouseButtons (event: MouseEvent) {\n if (typeof event === 'object') {\n if ('buttons' in event) {\n return event.buttons\n } else if ('which' in event as any) {\n const b = (event as any).which\n if (b === 2) {\n return 4\n } else if (b === 3) {\n return 2\n } else if (b > 0) {\n return 1 << (b - 1)\n }\n } else if ('button' in event as any) {\n const b = (event as any).button\n if (b === 1) {\n return 4\n } else if (b === 2) {\n return 2\n } else if (b >= 0) {\n return 1 << b\n }\n }\n }\n return 0\n}\n\nexport interface MouseSignals {\n moved: Signal // on move: deltaX, deltaY\n scrolled: Signal // on scroll: delta\n dragged: Signal // on drag: deltaX, deltaY\n dropped: Signal // on drop\n clicked: Signal // on click\n hovered: Signal // on hover\n doubleClicked: Signal\n}\n\nexport interface MouseParams {\n hoverTimeout?: number\n handleScroll?:boolean\n doubleClickSpeed?: number\n}\n\n/**\n * Mouse observer\n *\n * @example\n * // listen to mouse moving (and touch-moving) events\n * mouseObserver.moved.moved.add( function( deltaX, deltaY ){ ... } );\n *\n * @example\n * // listen to scrolling (and pinching) events\n * mouseObserver.signals.scrolled.add( function( delta ){ ... } );\n *\n * @example\n * // listen to dragging (and touch-dragging) events\n * mouseObserver.signals.dragged.add( function( deltaX, deltaY ){ ... } );\n *\n * @example\n * // listen to clicking (and tapping) events\n * mouseObserver.signals.clicked.add( function(){ ... } );\n *\n * @example\n * // listen to double clicking (and double tapping) events\n * mouseObserver.signals.doubleClicked.add( function(){ ... } );\n *\n * @example\n * // listen to hovering events\n * mouseObserver.signals.hovered.add( function(){ ... } );\n */\nclass MouseObserver {\n signals: MouseSignals = {\n moved: new Signal(),\n scrolled: new Signal(),\n dragged: new Signal(),\n dropped: new Signal(),\n clicked: new Signal(),\n hovered: new Signal(),\n doubleClicked: new Signal()\n }\n\n hoverTimeout: number\n handleScroll:boolean\n doubleClickSpeed: number\n\n viewer: Viewer\n mouse: MouseObserver\n controls: MouseControls\n\n position = new Vector2() // Position on page\n prevPosition = new Vector2() // Previous position on page\n down = new Vector2() // Position on page when clicked\n canvasPosition = new Vector2() // Position on dom element\n prevClickCP = new Vector2()\n\n moving = false // Flag indicating if the mouse is moving\n hovering = true // Flag indicating if the mouse is hovering\n scrolled = false // Flag indicating if there was a scolling event since the last mouse move\n lastMoved = Infinity // Timestamp of last mouse move\n which? = 0 // 0: No button; 1: Left button; 2: Middle button; 3: Right button\n buttons? = 0 // 0: No button; 1: Left button; 2: Right button; 4: Middle button\n pressed? = false // Flag indicating if the mouse is pressed down\n altKey = false // Flag indicating if the alt key is pressed\n ctrlKey = false // Flag indicating if the ctrl key is pressed\n metaKey = false // Flag indicating if the meta key is pressed\n shiftKey = false // Flag indicating if the shift key is pressed\n\n doubleClickPending: boolean\n lastClicked: number\n overElement: boolean\n lastTouchDistance: number\n private frameRequest: number\n\n /**\n * @param {Element} domElement - the dom element to observe mouse events in\n * @param {Object} params - parameters object\n * @param {Integer} params.hoverTimeout - timeout in ms until the {@link MouseSignals.hovered}\n * signal is fired, set to -1 to ignore hovering\n * @param {Boolean} params.handleScroll - whether or not to handle scroll events\n * @param {Integer} params.doubleClickSpeed - max time in ms to trigger double click\n */\n constructor (readonly domElement: HTMLCanvasElement, params: MouseParams = {}) {\n this.domElement.style.touchAction = 'none'\n\n this.hoverTimeout = defaults(params.hoverTimeout, 50)\n this.handleScroll = defaults(params.handleScroll, true)\n this.doubleClickSpeed = defaults(params.doubleClickSpeed, 500)\n\n this._listen = this._listen.bind(this)\n this._onMousewheel = this._onMousewheel.bind(this)\n this._onMousemove = this._onMousemove.bind(this)\n this._onMousedown = this._onMousedown.bind(this)\n this._onMouseup = this._onMouseup.bind(this)\n this._onContextmenu = this._onContextmenu.bind(this)\n this._onTouchstart = this._onTouchstart.bind(this)\n this._onTouchend = this._onTouchend.bind(this)\n this._onTouchmove = this._onTouchmove.bind(this)\n\n this._listen()\n\n const opt = { passive: false } // treat as 'passive' so preventDefault can be called\n document.addEventListener('mousewheel', this._onMousewheel, opt)\n document.addEventListener('wheel', this._onMousewheel, opt)\n document.addEventListener('MozMousePixelScroll', this._onMousewheel, opt)\n document.addEventListener('mousemove', this._onMousemove, opt)\n document.addEventListener('mousedown', this._onMousedown, opt)\n document.addEventListener('mouseup', this._onMouseup, opt)\n document.addEventListener('contextmenu', this._onContextmenu, opt)\n document.addEventListener('touchstart', this._onTouchstart, opt)\n document.addEventListener('touchend', this._onTouchend, opt)\n document.addEventListener('touchmove', this._onTouchmove, opt)\n }\n\n get key () {\n let key = 0\n if (this.altKey) key += 1\n if (this.ctrlKey) key += 2\n if (this.metaKey) key += 4\n if (this.shiftKey) key += 8\n return key\n }\n\n setParameters (params: MouseParams = {}) {\n this.hoverTimeout = defaults(params.hoverTimeout, this.hoverTimeout)\n }\n\n /**\n * listen to mouse actions\n * @emits {MouseSignals.clicked} when clicked\n * @emits {MouseSignals.hovered} when hovered\n * @return {undefined}\n */\n _listen () {\n const now = window.performance.now()\n const cp = this.canvasPosition\n if (this.doubleClickPending && now - this.lastClicked > this.doubleClickSpeed) {\n this.doubleClickPending = false\n }\n if (now - this.lastMoved > this.hoverTimeout) {\n this.moving = false\n }\n if (this.scrolled || (!this.moving && !this.hovering)) {\n this.scrolled = false\n if (this.hoverTimeout !== -1 && this.overElement) {\n this.hovering = true\n this.signals.hovered.dispatch(cp.x, cp.y)\n }\n }\n this.frameRequest = window.requestAnimationFrame(this._listen)\n }\n\n /**\n * handle mouse scroll\n * @emits {MouseSignals.scrolled} when scrolled\n * @param {Event} event - mouse event\n * @return {undefined}\n */\n _onMousewheel(event: Optional & { wheelDelta?: number, wheelDeltaY?: number }) {\n if (event.target !== this.domElement || !this.handleScroll) {\n return\n }\n event.preventDefault()\n this._setKeys(event as any)\n\n let delta = 0\n // This has to be written in a particular way to handle old browsers that\n // all send events with different properties set in different ways.\n if ('deltaY' in event && 'deltaMode' in event &&\n event.deltaY !== undefined && event.deltaMode !== undefined) {\n // all modern browsers, using WheelEvent; deltaY + down (toward user)\n if (event.deltaMode === WheelEvent.DOM_DELTA_PIXEL)\n // everything except Firefox: normally 100 per wheel click\n delta = -event.deltaY * (2.5 / 100.0)\n else if (event.deltaMode === WheelEvent.DOM_DELTA_LINE)\n // Firefox in line mode, normally 3 per wheel click\n delta = -event.deltaY * (2.5 / 3.0)\n else // page mode: 1 per wheel click\n delta = -event.deltaY * 2.5\n } else if ('deltaY' in event && !('detail' in event)) {\n // Old Firefox or IE 11: deltaY but no deltaMode; treat as pixels\n delta = -event.deltaY * (2.5 / 100.0)\n } else if (event.wheelDelta !== undefined) {\n delta = -event.wheelDelta * (2.5 / 100)\n } else if (event.wheelDeltaY !== undefined) {\n delta = -event.wheelDeltaY * (2.5 / 100)\n } else if (event.detail !== undefined){\n // Old Firefox, MouseWheelEvent\n delta = -event.detail / 3\n }\n this.signals.scrolled.dispatch(delta)\n\n setTimeout(() => {\n this.scrolled = true\n }, this.hoverTimeout)\n }\n\n /**\n * handle mouse move\n * @emits {MouseSignals.moved} when moved\n * @emits {MouseSignals.dragged} when dragged\n * @param {Event} event - mouse event\n * @return {undefined}\n */\n _onMousemove (event: MouseEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n this.overElement = true\n } else {\n this.overElement = false\n }\n this._setKeys(event)\n this.moving = true\n this.hovering = false\n this.lastMoved = window.performance.now()\n this.prevPosition.copy(this.position)\n this.position.set(event.clientX, event.clientY)\n this._setCanvasPosition(event)\n const dx = this.prevPosition.x - this.position.x\n const dy = this.prevPosition.y - this.position.y\n this.signals.moved.dispatch(dx, dy)\n if (this.pressed) {\n this.signals.dragged.dispatch(dx, dy)\n }\n }\n\n _onMousedown (event: MouseEvent) {\n if (event.target !== this.domElement) {\n return\n }\n event.preventDefault()\n this._setKeys(event)\n this.moving = false\n this.hovering = false\n this.down.set(event.clientX, event.clientY)\n this.position.set(event.clientX, event.clientY)\n this.which = event.which\n this.buttons = getMouseButtons(event)\n this.pressed = true\n this._setCanvasPosition(event)\n }\n\n /**\n * handle mouse up\n * @emits {MouseSignals.doubleClicked} when double clicked\n * @emits {MouseSignals.dropped} when dropped\n * @param {Event} event - mouse event\n * @return {undefined}\n */\n _onMouseup (event: MouseEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n }\n this._setKeys(event)\n const cp = this.canvasPosition\n if (this._distance() < 4) {\n this.lastClicked = window.performance.now()\n if (this.doubleClickPending && this.prevClickCP.distanceTo(cp) < 4) {\n this.signals.doubleClicked.dispatch(cp.x, cp.y)\n this.doubleClickPending = false\n }\n this.signals.clicked.dispatch(cp.x, cp.y)\n this.doubleClickPending = true\n this.prevClickCP.copy(cp)\n }\n this.which = undefined\n this.buttons = undefined\n this.pressed = undefined\n // if (this._distance() > 3 || event.which === RightMouseButton) {\n // this.signals.dropped.dispatch();\n // }\n }\n\n _onContextmenu (event: MouseEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n }\n }\n\n _onTouchstart (event: TouchEvent) {\n if (event.target !== this.domElement) {\n return\n }\n event.preventDefault()\n this.pressed = true\n switch (event.touches.length) {\n case 1: {\n this.moving = false\n this.hovering = false\n this.down.set(\n event.touches[ 0 ].pageX,\n event.touches[ 0 ].pageY\n )\n this.position.set(\n event.touches[ 0 ].pageX,\n event.touches[ 0 ].pageY\n )\n this._setCanvasPosition(event.touches[ 0 ])\n break\n }\n\n case 2: {\n this.down.set(\n (event.touches[ 0 ].pageX + event.touches[ 1 ].pageX) / 2,\n (event.touches[ 0 ].pageY + event.touches[ 1 ].pageY) / 2\n )\n this.position.set(\n (event.touches[ 0 ].pageX + event.touches[ 1 ].pageX) / 2,\n (event.touches[ 0 ].pageY + event.touches[ 1 ].pageY) / 2\n )\n this.lastTouchDistance = getTouchDistance(event)\n }\n }\n }\n\n _onTouchend (event: TouchEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n }\n this.which = undefined\n this.buttons = undefined\n this.pressed = undefined\n }\n\n _onTouchmove (event: TouchEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n this.overElement = true\n } else {\n this.overElement = false\n }\n switch (event.touches.length) {\n case 1: {\n this._setKeys(event)\n this.which = LeftMouseButton\n this.buttons = 1\n this.moving = true\n this.hovering = false\n this.lastMoved = window.performance.now()\n this.prevPosition.copy(this.position)\n this.position.set(\n event.touches[ 0 ].pageX,\n event.touches[ 0 ].pageY\n )\n this._setCanvasPosition(event.touches[ 0 ])\n const dx = this.prevPosition.x - this.position.x\n const dy = this.prevPosition.y - this.position.y\n this.signals.moved.dispatch(dx, dy)\n if (this.pressed) {\n this.signals.dragged.dispatch(dx, dy)\n }\n break\n }\n\n case 2: {\n const touchDistance = getTouchDistance(event)\n const delta = touchDistance - this.lastTouchDistance\n this.lastTouchDistance = touchDistance\n this.prevPosition.copy(this.position)\n this.position.set(\n (event.touches[ 0 ].pageX + event.touches[ 1 ].pageX) / 2,\n (event.touches[ 0 ].pageY + event.touches[ 1 ].pageY) / 2\n )\n if (Math.abs(delta) > 2 && this.handleScroll &&\n this.position.distanceTo(this.prevPosition) < 2\n ) {\n this.which = 0\n this.buttons = 0\n this.signals.scrolled.dispatch(delta / 2)\n } else {\n this.which = RightMouseButton\n this.buttons = 2\n const dx = this.prevPosition.x - this.position.x\n const dy = this.prevPosition.y - this.position.y\n this.signals.moved.dispatch(dx, dy)\n if (this.pressed) {\n this.signals.dragged.dispatch(dx, dy)\n }\n }\n }\n }\n }\n\n _distance () {\n return this.position.distanceTo(this.down)\n }\n\n _setCanvasPosition (event: any) { // TODO\n const box = this.domElement.getBoundingClientRect()\n let offsetX, offsetY;\n if ('clientX' in event && 'clientY' in event) {\n offsetX = event.clientX - box.left\n offsetY = event.clientY - box.top\n } else {\n offsetX = event.offsetX\n offsetY = event.offsetY\n }\n this.canvasPosition.set(offsetX, box.height - offsetY)\n }\n\n _setKeys (event: MouseEvent|TouchEvent) {\n this.altKey = event.altKey\n this.ctrlKey = event.ctrlKey\n this.metaKey = event.metaKey\n this.shiftKey = event.shiftKey\n }\n\n dispose () {\n document.removeEventListener('mousewheel', this._onMousewheel)\n document.removeEventListener('wheel', this._onMousewheel)\n document.removeEventListener('MozMousePixelScroll', this._onMousewheel)\n document.removeEventListener('mousemove', this._onMousemove)\n document.removeEventListener('mousedown', this._onMousedown)\n document.removeEventListener('mouseup', this._onMouseup)\n document.removeEventListener('contextmenu', this._onContextmenu)\n document.removeEventListener('touchstart', this._onTouchstart)\n document.removeEventListener('touchend', this._onTouchend)\n document.removeEventListener('touchmove', this._onTouchmove)\n window.cancelAnimationFrame(this.frameRequest)\n }\n}\n\nexport default MouseObserver\n","/**\n * @file Constants\n * @author Alexander Rose \n * @private\n */\n\nexport const LeftMouseButton = 1\nexport const MiddleMouseButton = 2\nexport const RightMouseButton = 3\n","/**\n * @file Trackball Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4, Quaternion } from 'three'\n\nimport { defaults } from '../utils'\nimport Stage from '../stage/stage'\nimport MouseObserver from '../stage/mouse-observer'\nimport Viewer from '../viewer/viewer'\nimport ViewerControls from './viewer-controls'\nimport AtomProxy from '../proxy/atom-proxy';\nimport Component from '../component/component';\n\nconst tmpRotateXMatrix = new Matrix4()\nconst tmpRotateYMatrix = new Matrix4()\nconst tmpRotateZMatrix = new Matrix4()\nconst tmpRotateMatrix = new Matrix4()\nconst tmpRotateCameraMatrix = new Matrix4()\nconst tmpRotateVector = new Vector3()\nconst tmpRotateQuaternion = new Quaternion()\nconst tmpRotateQuaternion2 = new Quaternion()\nconst tmpPanMatrix = new Matrix4()\nconst tmpPanVector = new Vector3()\nconst tmpAtomVector = new Vector3()\n\nexport interface TrackballControlsParams {\n rotateSpeed?: number\n zoomSpeed?: number\n panSpeed?: number\n}\n\n/**\n * Trackball controls\n */\nclass TrackballControls {\n viewer: Viewer\n mouse: MouseObserver\n controls: ViewerControls\n\n rotateSpeed: number\n zoomSpeed: number\n panSpeed: number\n\n constructor (readonly stage: Stage, params: TrackballControlsParams = {}) {\n this.rotateSpeed = defaults(params.rotateSpeed, 2.0)\n this.zoomSpeed = defaults(params.zoomSpeed, 1.2)\n this.panSpeed = defaults(params.panSpeed, 1.0)\n\n this.viewer = stage.viewer\n this.mouse = stage.mouseObserver\n this.controls = stage.viewerControls\n }\n\n get component (): Component|undefined {\n return this.stage.transformComponent\n }\n\n get atom (): AtomProxy|undefined {\n return this.stage.transformAtom\n }\n\n private _setPanVector (x: number, y: number, z = 0) {\n const scaleFactor = this.controls.getCanvasScaleFactor(z)\n tmpPanVector.set(x, y, 0)\n tmpPanVector.multiplyScalar(this.panSpeed * scaleFactor)\n }\n\n private _getRotateXY (x: number, y: number) {\n return [\n this.rotateSpeed * -x * 0.01,\n this.rotateSpeed * y * 0.01\n ]\n }\n\n private _getCameraRotation(m: Matrix4) {\n m.extractRotation(this.viewer.camera.matrixWorld)\n m.multiply(tmpRotateYMatrix.makeRotationY(Math.PI))\n\n return m\n }\n\n private _transformPanVector () {\n if (!this.component) return\n\n // Adjust for component and scene rotation\n tmpPanMatrix.extractRotation(this.component.transform)\n tmpPanMatrix.premultiply(this.viewer.rotationGroup.matrix)\n tmpPanMatrix.getInverse(tmpPanMatrix)\n\n // Adjust for camera rotation\n tmpPanMatrix.multiply(this._getCameraRotation(tmpRotateMatrix))\n\n tmpPanVector.applyMatrix4(tmpPanMatrix)\n }\n\n zoom (delta: number) {\n this.controls.zoom(this.zoomSpeed * delta * 0.02)\n }\n\n pan (x: number, y: number) {\n this._setPanVector(x, y)\n\n // Adjust for scene rotation\n tmpPanMatrix.getInverse(this.viewer.rotationGroup.matrix)\n\n // Adjust for camera rotation\n tmpPanMatrix.multiply(this._getCameraRotation(tmpRotateMatrix))\n\n tmpPanVector.applyMatrix4(tmpPanMatrix)\n this.controls.translate(tmpPanVector)\n }\n\n panComponent (x: number, y: number) {\n if (!this.component) return\n\n this._setPanVector(x, y)\n this._transformPanVector()\n\n this.component.position.add(tmpPanVector)\n this.component.updateMatrix()\n }\n\n panAtom (x: number, y: number) {\n if (!this.atom || !this.component) return\n\n this.atom.positionToVector3(tmpAtomVector)\n tmpAtomVector.add(this.viewer.translationGroup.position)\n tmpAtomVector.applyMatrix4(this.viewer.rotationGroup.matrix)\n\n this._setPanVector(x, y, tmpAtomVector.z)\n this._transformPanVector()\n\n this.atom.positionAdd(tmpPanVector)\n this.component.updateRepresentations({ 'position': true })\n }\n\n rotate (x: number, y: number) {\n const [ dx, dy ] = this._getRotateXY(x, y)\n\n // rotate around screen X then screen Y\n this._getCameraRotation(tmpRotateMatrix)\n tmpRotateVector.set(1, 0, 0) // X axis\n tmpRotateVector.applyMatrix4(tmpRotateMatrix) // screen X\n tmpRotateQuaternion.setFromAxisAngle(tmpRotateVector, dy)\n\n tmpRotateVector.set(0, 1, 0) // Y axis\n tmpRotateVector.applyMatrix4(tmpRotateMatrix) // screen Y\n tmpRotateQuaternion2.setFromAxisAngle(tmpRotateVector, dx)\n\n tmpRotateQuaternion.multiply(tmpRotateQuaternion2)\n tmpRotateMatrix.makeRotationFromQuaternion(tmpRotateQuaternion)\n this.controls.applyMatrix(tmpRotateMatrix)\n }\n\n zRotate (x: number, y: number) {\n const dz = this.rotateSpeed * ((-x + y) / -2) * 0.01\n\n tmpRotateZMatrix.makeRotationZ(dz)\n this.controls.applyMatrix(tmpRotateZMatrix)\n }\n\n rotateComponent (x: number, y: number) {\n if (!this.component) return\n\n const [ dx, dy ] = this._getRotateXY(x, y)\n\n this._getCameraRotation(tmpRotateCameraMatrix)\n\n tmpRotateMatrix.extractRotation(this.component.transform)\n tmpRotateMatrix.premultiply(this.viewer.rotationGroup.matrix)\n tmpRotateMatrix.getInverse(tmpRotateMatrix)\n tmpRotateMatrix.premultiply(tmpRotateCameraMatrix)\n\n tmpRotateVector.set(1, 0, 0)\n tmpRotateVector.applyMatrix4(tmpRotateMatrix)\n tmpRotateXMatrix.makeRotationAxis(tmpRotateVector, dy)\n\n tmpRotateVector.set(0, 1, 0)\n tmpRotateVector.applyMatrix4(tmpRotateMatrix)\n tmpRotateYMatrix.makeRotationAxis(tmpRotateVector, dx)\n\n tmpRotateXMatrix.multiply(tmpRotateYMatrix)\n tmpRotateQuaternion.setFromRotationMatrix(tmpRotateXMatrix)\n this.component.quaternion.premultiply(tmpRotateQuaternion)\n this.component.quaternion.normalize()\n this.component.updateMatrix()\n }\n}\n\nexport default TrackballControls\n","/**\n * @file Picking Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4, Vector2 } from 'three'\n\nimport Stage from '../stage/stage'\nimport StructureComponent from '../component/structure-component'\nimport MouseObserver from '../stage/mouse-observer'\nimport { Picker } from '../utils/picker'\nimport ViewerControls from './viewer-controls'\nimport Shape from '../geometry/shape'\nimport Structure from '../structure/structure'\nimport BondProxy from '../proxy/bond-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Surface from '../surface/surface'\nimport Volume from '../surface/volume'\nimport Unitcell from '../symmetry/unitcell'\nimport Component from '../component/component';\n\nconst tmpVec = new Vector3()\n\nexport interface ShapePrimitive {\n name: string\n shape: Shape\n}\n\nfunction closer (x: Vector3, a: Vector3, b: Vector3) {\n return x.distanceTo(a) < x.distanceTo(b)\n}\n\n/**\n * Picking data object.\n * @typedef {Object} PickingData - picking data\n * @property {Number} [pid] - picking id\n * @property {Object} [instance] - instance data\n * @property {Integer} instance.id - instance id\n * @property {String|Integer} instance.name - instance name\n * @property {Matrix4} instance.matrix - transformation matrix of the instance\n * @property {Picker} [picker] - picker object\n */\n\nexport interface InstanceData {\n id: number\n name: number|string\n matrix: Matrix4\n}\n\nexport interface PickingData {\n pid: number\n instance: InstanceData\n picker: Picker\n}\n\n/**\n * Picking proxy class.\n */\nclass PickingProxy {\n pid: number\n picker: Picker\n instance: InstanceData\n controls: ViewerControls\n mouse: MouseObserver\n\n /**\n * Create picking proxy object\n * @param {PickingData} pickingData - picking data\n * @param {Stage} stage - stage object\n */\n constructor (pickingData: PickingData, readonly stage: Stage) {\n this.pid = pickingData.pid\n this.picker = pickingData.picker\n\n /**\n * @type {Object}\n */\n this.instance = pickingData.instance\n\n /**\n * @type {Stage}\n */\n this.stage = stage\n /**\n * @type {ViewerControls}\n */\n this.controls = stage.viewerControls\n /**\n * @type {MouseObserver}\n */\n this.mouse = stage.mouseObserver\n }\n\n /**\n * Kind of the picked data\n * @type {String}\n */\n get type () { return this.picker.type }\n\n /**\n * If the `alt` key was pressed\n * @type {Boolean}\n */\n get altKey () { return this.mouse.altKey }\n /**\n * If the `ctrl` key was pressed\n * @type {Boolean}\n */\n get ctrlKey () { return this.mouse.ctrlKey }\n /**\n * If the `meta` key was pressed\n * @type {Boolean}\n */\n get metaKey () { return this.mouse.metaKey }\n /**\n * If the `shift` key was pressed\n * @type {Boolean}\n */\n get shiftKey () { return this.mouse.shiftKey }\n\n /**\n * Position of the mouse on the canvas\n * @type {Vector2}\n */\n get canvasPosition (): Vector2 { return this.mouse.canvasPosition }\n\n /**\n * The component the picked data is part of\n * @type {Component}\n */\n get component (): Component {\n return this.stage.getComponentsByObject(this.picker.data as any).list[ 0 ] // TODO\n }\n\n /**\n * The picked object data\n * @type {Object}\n */\n get object () {\n return this.picker.getObject(this.pid)\n }\n\n /**\n * The 3d position in the scene of the picked object\n * @type {Vector3}\n */\n get position () {\n return this.picker.getPosition(this.pid, this.instance, this.component)\n }\n\n /**\n * The atom of a picked bond that is closest to the mouse\n * @type {AtomProxy}\n */\n get closestBondAtom (): AtomProxy|undefined {\n if (this.type !== 'bond' || !this.bond) return undefined\n\n const bond = this.bond\n const controls = this.controls\n const cp = this.canvasPosition\n\n const v1 = bond.atom1.positionToVector3()\n const v2 = bond.atom2.positionToVector3()\n\n v1.applyMatrix4(this.component.matrix)\n v2.applyMatrix4(this.component.matrix)\n\n const acp1 = controls.getPositionOnCanvas(v1)\n const acp2 = controls.getPositionOnCanvas(v2)\n\n return closer(cp as any, acp1, acp2) ? bond.atom1 : bond.atom2\n }\n\n /**\n * Close-by atom\n * @type {AtomProxy}\n */\n get closeAtom (): AtomProxy|undefined {\n const cp = this.canvasPosition\n const ca = this.closestBondAtom\n if (!ca) return undefined\n\n const v = ca.positionToVector3().applyMatrix4(this.component.matrix)\n\n const acp = this.controls.getPositionOnCanvas(v)\n\n ca.positionToVector3(tmpVec)\n if (this.instance) tmpVec.applyMatrix4(this.instance.matrix)\n tmpVec.applyMatrix4(this.component.matrix)\n const viewer = this.controls.viewer\n tmpVec.add(viewer.translationGroup.position)\n tmpVec.applyMatrix4(viewer.rotationGroup.matrix)\n\n const scaleFactor = this.controls.getCanvasScaleFactor(tmpVec.z)\n const sc = this.component as StructureComponent\n const radius = sc.getMaxRepresentationRadius(ca.index)\n //console.log(scaleFactor, cp.distanceTo(acp), radius/scaleFactor, radius)\n\n if (cp.distanceTo(acp) <= radius/scaleFactor) {\n return ca\n } else {\n return undefined\n }\n }\n\n /**\n * @type {Object}\n */\n get arrow () { return this._objectIfType('arrow') as ShapePrimitive }\n /**\n * @type {AtomProxy}\n */\n get atom () { return this._objectIfType('atom') as AtomProxy }\n /**\n * @type {Object}\n */\n get axes () { return this._objectIfType('axes') }\n /**\n * @type {BondProxy}\n */\n get bond () { return this._objectIfType('bond') as BondProxy }\n /**\n * @type {Object}\n */\n get box () { return this._objectIfType('box') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get cone () { return this._objectIfType('cone') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get clash () { return this._objectIfType('clash') as { clash: { sele1: string, sele2: string } } }\n /**\n * @type {BondProxy}\n */\n get contact () { return this._objectIfType('contact') as { type: string, atom1: AtomProxy, atom2: AtomProxy } }\n /**\n * @type {Object}\n */\n get cylinder () { return this._objectIfType('cylinder') as ShapePrimitive }\n /**\n * @type {BondProxy}\n */\n get distance () { return this._objectIfType('distance') as BondProxy }\n /**\n * @type {Object}\n */\n get ellipsoid () { return this._objectIfType('ellipsoid') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get octahedron () { return this._objectIfType('octahedron') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get point () { return this._objectIfType('point') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get mesh () { return this._objectIfType('mesh') as { name: string, shape: Shape, serial: number } }\n /**\n * @type {Object}\n */\n get slice () { return this._objectIfType('slice') as { volume: Volume, value: number } }\n /**\n * @type {Object}\n */\n get sphere () { return this._objectIfType('sphere') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get tetrahedron () { return this._objectIfType('tetrahedron') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get torus () { return this._objectIfType('torus') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get surface () { return this._objectIfType('surface') as { surface: Surface, index: number } }\n /**\n * @type {Object}\n */\n get unitcell () { return this._objectIfType('unitcell') as { unitcell: Unitcell, structure: Structure } }\n /**\n * @type {Object}\n */\n get unknown () { return this._objectIfType('unknown') }\n /**\n * @type {Object}\n */\n get volume () { return this._objectIfType('volume') as { volume: Volume, value: number } }\n /**\n * @type {Object}\n */\n get wideline () { return this._objectIfType('wideline') as ShapePrimitive }\n\n _objectIfType (type: string) {\n return this.type === type ? this.object : undefined\n }\n\n getLabel () {\n const atom = this.atom || this.closeAtom\n let msg = 'nothing'\n if (this.arrow) {\n msg = this.arrow.name\n } else if (atom) {\n msg = `atom: ${atom.qualifiedName()} (${atom.structure.name})`\n } else if (this.axes) {\n msg = 'axes'\n } else if (this.bond) {\n msg = `bond: ${this.bond.atom1.qualifiedName()} - ${this.bond.atom2.qualifiedName()} (${this.bond.structure.name})`\n } else if (this.box) {\n msg = this.box.name\n } else if (this.cone) {\n msg = this.cone.name\n } else if (this.clash) {\n msg = `clash: ${this.clash.clash.sele1} - ${this.clash.clash.sele2}`\n } else if (this.contact) {\n msg = `${this.contact.type}: ${this.contact.atom1.qualifiedName()} - ${this.contact.atom2.qualifiedName()} (${this.contact.atom1.structure.name})`\n } else if (this.cylinder) {\n msg = this.cylinder.name\n } else if (this.distance) {\n msg = `distance: ${this.distance.atom1.qualifiedName()} - ${this.distance.atom2.qualifiedName()} (${this.distance.structure.name})`\n } else if (this.ellipsoid) {\n msg = this.ellipsoid.name\n } else if (this.octahedron) {\n msg = this.octahedron.name\n } else if (this.point) {\n msg = this.point.name\n } else if (this.mesh) {\n msg = `mesh: ${this.mesh.name || this.mesh.serial} (${this.mesh.shape.name})`\n } else if (this.slice) {\n msg = `slice: ${this.slice.value.toPrecision(3)} (${this.slice.volume.name})`\n } else if (this.sphere) {\n msg = this.sphere.name\n } else if (this.surface) {\n msg = `surface: ${this.surface.surface.name}`\n } else if (this.tetrahedron) {\n msg = this.tetrahedron.name\n } else if (this.torus) {\n msg = this.torus.name\n } else if (this.unitcell) {\n msg = `unitcell: ${this.unitcell.unitcell.spacegroup} (${this.unitcell.structure.name})`\n } else if (this.unknown) {\n msg = 'unknown'\n } else if (this.volume) {\n msg = `volume: ${this.volume.value.toPrecision(3)} (${this.volume.volume.name})`\n } else if (this.wideline) {\n msg = this.wideline.name\n }\n return msg\n }\n}\n\nexport default PickingProxy\n","/**\n * @file Picking Controls\n * @author Alexander Rose \n * @private\n */\n\nimport PickingProxy from './picking-proxy'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\n\n/**\n * Picking controls\n */\nclass PickingControls {\n viewer: Viewer\n\n constructor (readonly stage: Stage) {\n this.viewer = stage.viewer\n }\n\n /**\n * get picking data\n * @param {Number} x - canvas x coordinate\n * @param {Number} y - canvas y coordinate\n * @return {PickingProxy|undefined} picking proxy\n */\n pick (x: number, y: number) {\n const pickingData = this.viewer.pick(x, y)\n\n if (pickingData.picker &&\n pickingData.picker.type !== 'ignore' &&\n pickingData.pid !== undefined\n ) {\n const pickerArray = pickingData.picker.array\n if (pickerArray && pickingData.pid >= pickerArray.length) {\n console.error('pid >= picker.array.length')\n } else {\n return new PickingProxy(pickingData, this.stage)\n }\n }\n }\n}\n\nexport default PickingControls\n","/**\n * @file Viewer Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector2, Vector3, Matrix4, Quaternion, OrthographicCamera } from 'three'\nimport * as signalsWrapper from 'signals'\n\nimport {\n ensureVector2, ensureVector3, ensureMatrix4, ensureQuaternion\n} from '../utils'\nimport { degToRad } from '../math/math-utils'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\n\n/**\n * Orientation matrix, a 4x4 transformation matrix with rotation part\n * used for scene rotation, scale part for scene camera distance and\n * position part for scene translation\n * @typedef {Matrix4} OrientationMatrix - orientation matrix\n */\n\nconst tmpQ = new Quaternion()\nconst tmpP = new Vector3()\nconst tmpS = new Vector3()\n\nconst tmpCanvasVector = new Vector3()\nconst tmpScaleVector = new Vector3()\nconst tmpRotateMatrix = new Matrix4()\nconst tmpRotateVector = new Vector3()\nconst tmpAlignMatrix = new Matrix4()\n\n/**\n * Viewer controls\n */\nclass ViewerControls {\n signals = {\n changed: new signalsWrapper.Signal()\n }\n\n viewer: Viewer\n\n /**\n * @param {Stage} stage - the stage object\n */\n constructor (readonly stage: Stage) {\n this.viewer = stage.viewer\n }\n\n /**\n * scene center position\n * @type {Vector3}\n */\n get position () {\n return this.viewer.translationGroup.position\n }\n\n /**\n * scene rotation\n * @type {Quaternion}\n */\n get rotation () {\n return this.viewer.rotationGroup.quaternion\n }\n\n /**\n * Trigger render and emit changed event\n * @emits {ViewerControls.signals.changed}\n * @return {undefined}\n */\n changed () {\n this.viewer.requestRender()\n this.signals.changed.dispatch()\n }\n\n getPositionOnCanvas (position: Vector3, optionalTarget?: Vector2) {\n const canvasPosition = ensureVector2(optionalTarget)\n const viewer = this.viewer\n\n tmpCanvasVector.copy(position)\n .add(viewer.translationGroup.position)\n .applyMatrix4(viewer.rotationGroup.matrix)\n .project(viewer.camera)\n\n return canvasPosition.set(\n (tmpCanvasVector.x + 1) * viewer.width / 2,\n (tmpCanvasVector.y + 1) * viewer.height / 2\n )\n }\n\n getCanvasScaleFactor (z = 0) {\n const camera = this.viewer.camera\n if (camera instanceof OrthographicCamera) {\n return 1 / camera.zoom\n } else {\n z = Math.abs(z)\n z += this.getCameraDistance()\n const fov = degToRad(camera.fov)\n const unitHeight = 2.0 * z * Math.tan(fov / 2)\n return unitHeight / this.viewer.height\n }\n }\n\n /**\n * get scene orientation\n * @param {Matrix4} optionalTarget - pre-allocated target matrix\n * @return {OrientationMatrix} scene orientation\n */\n getOrientation (optionalTarget?: Matrix4) {\n const m = ensureMatrix4(optionalTarget)\n\n m.copy(this.viewer.rotationGroup.matrix)\n const z = this.getCameraDistance()\n m.scale(tmpScaleVector.set(z, z, z))\n m.setPosition(this.viewer.translationGroup.position)\n\n return m\n }\n\n /**\n * set scene orientation\n * @param {OrientationMatrix|Array} orientation - scene orientation\n * @return {undefined}\n */\n orient (orientation?: Matrix4) {\n ensureMatrix4(orientation).decompose(tmpP, tmpQ, tmpS)\n\n const v = this.viewer\n v.rotationGroup.setRotationFromQuaternion(tmpQ)\n v.translationGroup.position.copy(tmpP)\n v.cameraDistance = tmpS.z\n v.updateZoom()\n this.changed()\n }\n\n /**\n * translate scene\n * @param {Vector3|Array} vector - translation vector\n * @return {undefined}\n */\n translate (vector: Vector3|number[]) {\n this.viewer.translationGroup.position\n .add(ensureVector3(vector))\n this.changed()\n }\n\n /**\n * center scene\n * @param {Vector3|Array} position - center position\n * @return {undefined}\n */\n center (position: Vector3|number[]) {\n this.viewer.translationGroup.position\n .copy(ensureVector3(position)).negate()\n this.changed()\n }\n\n /**\n * \"zoom\" scene by moving camera closer to origin\n * @param {Number} delta - zoom change\n * @return {undefined}\n */\n zoom (delta: number) {\n this.distance(this.getCameraDistance() * (1 - delta))\n }\n\n /**\n * get camera distance\n */\n getCameraDistance(): number {\n return this.viewer.cameraDistance\n }\n\n /**\n * camera distance\n * @param {Number} z - distance\n * @return {undefined}\n */\n distance (distance: number) {\n // Math.abs because distance used to be \"z\", normally negative.\n // Math.max to prevent us from getting _too_ close.\n this.viewer.cameraDistance = Math.max(Math.abs(distance), 0.2)\n this.viewer.updateZoom()\n this.changed()\n }\n\n /**\n * spin scene on axis\n * @param {Vector3|Array} axis - rotation axis\n * @param {Number} angle - amount to spin\n * @return {undefined}\n */\n spin (axis: Vector3|number[], angle: number) {\n tmpRotateMatrix.getInverse(this.viewer.rotationGroup.matrix)\n tmpRotateVector\n .copy(ensureVector3(axis)).applyMatrix4(tmpRotateMatrix)\n\n this.viewer.rotationGroup.rotateOnAxis(tmpRotateVector, angle)\n this.changed()\n }\n\n /**\n * rotate scene\n * @param {Quaternion|Array} quaternion - rotation quaternion\n * @return {undefined}\n */\n rotate (quaternion: Quaternion|number[]) {\n this.viewer.rotationGroup\n .setRotationFromQuaternion(ensureQuaternion(quaternion))\n this.changed()\n }\n\n /**\n * align scene to basis matrix\n * @param {Matrix4|Array} basis - basis matrix\n * @return {undefined}\n */\n align (basis: Matrix4|number[]) {\n tmpAlignMatrix.getInverse(ensureMatrix4(basis))\n\n this.viewer.rotationGroup.setRotationFromMatrix(tmpAlignMatrix)\n this.changed()\n }\n\n /**\n * apply rotation matrix to scene\n * @param {Matrix4|Array} matrix - rotation matrix\n * @return {undefined}\n */\n applyMatrix (matrix: Matrix4|number[]) {\n this.viewer.rotationGroup.applyMatrix4(ensureMatrix4(matrix))\n this.changed()\n }\n}\n\nexport default ViewerControls\n","/**\n * @file Animation\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Quaternion } from 'three'\n\nimport { defaults, ensureVector3, ensureQuaternion } from '../utils'\nimport { lerp, smoothstep } from '../math/math-utils'\nimport ViewerControls from '../controls/viewer-controls'\nimport Stats from '../viewer/stats'\n\n/**\n * Animation. Base animation class.\n * @interface\n */\nabstract class Animation {\n duration: number\n controls: ViewerControls\n\n alpha: number\n startTime: number\n\n pausedTime = -1\n elapsedDuration = 0\n pausedDuration = 0\n ignoreGlobalToggle = false\n\n private _paused = false\n private _resolveList: Function[] = []\n private _hold: boolean\n\n constructor (duration: number|undefined, controls: ViewerControls, ...args: any[]) {\n this.duration = defaults(duration, 1000)\n this.controls = controls\n\n this.startTime = window.performance.now()\n\n this._init(...args)\n }\n\n /**\n * True when animation has finished\n */\n get done () {\n return this.alpha === 1\n }\n\n /**\n * True when animation is paused\n */\n get paused () {\n return this._paused\n }\n\n /**\n * init animation\n */\n abstract _init (...args: any[]): void\n\n /**\n * called on every tick\n */\n abstract _tick (stats?: Stats): void\n\n tick (stats: Stats) {\n if (this._paused) return\n\n this.elapsedDuration = stats.currentTime - this.startTime - this.pausedDuration\n\n if (this.duration === 0) {\n this.alpha = 1\n } else {\n this.alpha = smoothstep(0, 1, this.elapsedDuration / this.duration)\n }\n\n this._tick(stats)\n\n if (this.done) {\n this._resolveList.forEach(resolve => resolve())\n }\n\n return this.done\n }\n\n /**\n * Pause animation\n * @param {boolean} [hold] - put animation on a hold which\n * must be release before it can be resumed\n */\n pause (hold?: boolean) {\n if (hold) this._hold = true\n\n if (this.pausedTime === -1) {\n this.pausedTime = window.performance.now()\n }\n this._paused = true\n }\n\n /**\n * Resume animation\n * @param {Boolean} [releaseHold] - release a hold on the animation\n */\n resume (releaseHold?: boolean) {\n if (!releaseHold && this._hold) return\n\n this.pausedDuration += window.performance.now() - this.pausedTime\n this._paused = false\n this._hold = false\n this.pausedTime = -1\n }\n\n /**\n * Toggle animation\n */\n toggle () {\n if (this._paused) {\n this.resume()\n } else {\n this.pause()\n }\n }\n\n /**\n * Promise-like interface\n */\n then (callback: Function) {\n let p: Promise\n\n if (this.done) {\n p = Promise.resolve()\n } else {\n p = new Promise(resolve => this._resolveList.push(resolve))\n }\n\n return p.then(callback as any)\n }\n}\n\nexport default Animation\n\n/**\n * Spin animation. Spin around an axis.\n */\nexport class SpinAnimation extends Animation {\n axis: Vector3\n angle: number\n\n constructor (duration: number|undefined, controls: ViewerControls, ...args: any[]) {\n super(defaults(duration, Infinity), controls, ...args)\n }\n\n _init (axis: number[]|Vector3, angle: number) {\n if (Array.isArray(axis)) {\n this.axis = new Vector3().fromArray(axis)\n } else {\n this.axis = defaults(axis, new Vector3(0, 1, 0))\n }\n this.angle = defaults(angle, 0.01)\n }\n\n _tick (stats: Stats) {\n if (!this.axis || !this.angle) return\n\n this.controls.spin(\n this.axis, this.angle * stats.lastDuration / 16\n )\n }\n}\n\n/**\n * Rock animation. Rock around an axis.\n */\nexport class RockAnimation extends Animation {\n axis: Vector3\n angleStep: number\n angleEnd: number\n angleSum = 0\n direction = 1\n\n constructor (duration: number|undefined, controls: ViewerControls, ...args: any[]) {\n super(defaults(duration, Infinity), controls, ...args)\n }\n\n _init (axis: number[]|Vector3, angleStep: number, angleEnd: number) {\n if (Array.isArray(axis)) {\n this.axis = new Vector3().fromArray(axis)\n } else {\n this.axis = defaults(axis, new Vector3(0, 1, 0))\n }\n this.angleStep = defaults(angleStep, 0.01)\n this.angleEnd = defaults(angleEnd, 0.2)\n }\n\n _tick (stats: Stats) {\n if (!this.axis || !this.angleStep || !this.angleEnd) return\n\n const alpha = smoothstep(\n 0, 1, Math.abs(this.angleSum) / this.angleEnd\n )\n const angle = this.angleStep * this.direction * (1.1 - alpha)\n\n this.controls.spin(\n this.axis, angle * stats.lastDuration / 16\n )\n\n this.angleSum += this.angleStep\n\n if (this.angleSum >= this.angleEnd) {\n this.direction *= -1\n this.angleSum = -this.angleEnd\n }\n }\n}\n\n/**\n * Move animation. Move from one position to another.\n */\nexport class MoveAnimation extends Animation {\n moveFrom: Vector3\n moveTo: Vector3\n\n _init (moveFrom: number[]|Vector3, moveTo: number[]|Vector3) {\n this.moveFrom = ensureVector3(defaults(moveFrom, new Vector3()))\n this.moveTo = ensureVector3(defaults(moveTo, new Vector3()))\n }\n\n _tick (/* stats */) {\n this.controls.position.lerpVectors(\n this.moveFrom, this.moveTo, this.alpha\n ).negate()\n this.controls.changed()\n }\n}\n\n/**\n * Zoom animation. Gradually change the zoom level.\n */\nexport class ZoomAnimation extends Animation {\n zoomFrom: number\n zoomTo: number\n\n _init (zoomFrom: number, zoomTo: number) {\n this.zoomFrom = zoomFrom\n this.zoomTo = zoomTo\n }\n\n _tick () {\n this.controls.distance(lerp(this.zoomFrom, this.zoomTo, this.alpha))\n }\n}\n\n/**\n * Rotate animation. Rotate from one orientation to another.\n */\nexport class RotateAnimation extends Animation {\n rotateFrom: Quaternion\n rotateTo: Quaternion\n\n private _currentRotation = new Quaternion()\n\n _init (rotateFrom: number[]|Quaternion, rotateTo: number[]|Quaternion) {\n this.rotateFrom = ensureQuaternion(rotateFrom)\n this.rotateTo = ensureQuaternion(rotateTo)\n\n this._currentRotation = new Quaternion()\n }\n\n _tick () {\n this._currentRotation\n .copy(this.rotateFrom)\n .slerp(this.rotateTo, this.alpha)\n\n this.controls.rotate(this._currentRotation)\n }\n}\n\n/**\n * Value animation. Call callback with interpolated value.\n */\nexport class ValueAnimation extends Animation {\n valueFrom: number\n valueTo: number\n callback: Function\n\n _init (valueFrom: number, valueTo: number, callback: Function) {\n this.valueFrom = valueFrom\n this.valueTo = valueTo\n\n this.callback = callback\n }\n\n _tick (/* stats */) {\n this.callback(lerp(this.valueFrom, this.valueTo, this.alpha))\n }\n}\n\n/**\n * Timeout animation. Call callback after duration.\n */\nexport class TimeoutAnimation extends Animation {\n callback: Function\n\n _init (callback: Function) {\n this.callback = callback\n }\n\n _tick () {\n if (this.alpha === 1) this.callback()\n }\n}\n\n/**\n * Animation list.\n */\nexport class AnimationList {\n _list: Animation[]\n _resolveList: Function[] = []\n\n constructor (list: Animation[] = []) {\n this._list = list\n }\n\n /**\n * True when all animations have finished\n */\n get done () {\n return this._list.every(animation => {\n return animation.done\n })\n }\n\n /**\n * Promise-like interface\n */\n then (callback: Function) {\n let p: Promise\n\n if (this.done) {\n p = Promise.resolve()\n } else {\n p = new Promise(resolve => {\n this._resolveList.push(resolve)\n this._list.forEach(animation => {\n animation.then(() => {\n this._resolveList.forEach(callback => {\n callback()\n })\n this._resolveList.length = 0\n })\n })\n })\n }\n\n return p.then(callback as any)\n }\n}\n","/**\n * @file Animation Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Quaternion, Matrix4 } from 'three'\n\nimport { ensureMatrix4 } from '../utils'\nimport Animation, {\n SpinAnimation, RockAnimation, MoveAnimation, ZoomAnimation,\n RotateAnimation, ValueAnimation, TimeoutAnimation, AnimationList\n} from '../animation/animation'\nimport Stage from '../stage/stage'\nimport Component from '../component/component'\nimport Viewer from '../viewer/viewer'\nimport Stats from '../viewer/stats'\nimport ViewerControls from './viewer-controls'\n\n/**\n * Animation controls\n */\nclass AnimationControls {\n viewer: Viewer\n controls: ViewerControls\n\n animationList: Animation[] = []\n finishedList: Animation[] = []\n\n /**\n * Create animation controls\n * @param {Stage} stage - the stage object\n */\n constructor (readonly stage: Stage) {\n this.viewer = stage.viewer\n this.controls = stage.viewerControls\n }\n\n /**\n * True when all animations are paused\n * @type {Boolean}\n */\n get paused () {\n return this.animationList.every((animation: Animation) => animation.paused)\n }\n\n /**\n * Add an animation\n */\n add (animation: Animation) {\n if (animation.duration === 0) {\n animation.tick(this.viewer.stats)\n } else {\n this.animationList.push(animation)\n }\n\n return animation\n }\n\n /**\n * Remove an animation\n */\n remove (animation: Animation) {\n const list = this.animationList\n const index = list.indexOf(animation)\n\n if (index > -1) {\n list.splice(index, 1)\n }\n }\n\n /**\n * Run all animations\n */\n run (stats: Stats) {\n const finishedList = this.finishedList\n const animationList = this.animationList\n\n const n = animationList.length\n for (let i = 0; i < n; ++i) {\n const animation = animationList[ i ]\n // tick returns true when finished\n if (animation.tick(stats)) {\n finishedList.push(animation)\n }\n }\n\n const m = finishedList.length\n if (m) {\n for (let j = 0; j < m; ++j) {\n this.remove(finishedList[ j ])\n }\n finishedList.length = 0\n }\n }\n\n /**\n * Add a spin animation\n * @param {Vector3} axis - axis to spin around\n * @param {Number} angle - amount to spin per frame, radians\n * @param {Number} duration - animation time in milliseconds\n * @return {SpinAnimation} the animation\n */\n spin (axis: Vector3|number[], angle?: number, duration?: number) {\n return this.add(\n new SpinAnimation(duration, this.controls, axis, angle)\n )\n }\n\n /**\n * Add a rock animation\n * @param {Vector3} axis - axis to rock around\n * @param {Number} angle - amount to spin per frame, radians\n * @param {Number} end - maximum extend of motion, radians\n * @param {Number} duration - animation time in milliseconds\n * @return {SpinAnimation} the animation\n */\n rock (axis: Vector3|number[], angle?: number, end?: number, duration?: number) {\n return this.add(\n new RockAnimation(duration, this.controls, axis, angle, end)\n )\n }\n\n /**\n * Add a rotate animation\n * @param {Quaternion} rotateTo - target rotation\n * @param {Number} duration - animation time in milliseconds\n * @return {RotateAnimation} the animation\n */\n rotate (rotateTo: Quaternion|number[], duration?: number) {\n const rotateFrom = this.viewer.rotationGroup.quaternion.clone()\n\n return this.add(\n new RotateAnimation(duration, this.controls, rotateFrom, rotateTo)\n )\n }\n\n /**\n * Add a move animation\n * @param {Vector3} moveTo - target position\n * @param {Number} duration - animation time in milliseconds\n * @return {MoveAnimation} the animation\n */\n move (moveTo: Vector3|number[], duration?: number) {\n const moveFrom = this.controls.position.clone().negate()\n\n return this.add(\n new MoveAnimation(duration, this.controls, moveFrom, moveTo)\n )\n }\n\n /**\n * Add a zoom animation\n * @param {Number} zoomTo - target distance\n * @param {Number} duration - animation time in milliseconds\n * @return {ZoomAnimation} the animation\n */\n zoom (zoomTo: number, duration?: number) {\n const zoomFrom = this.viewer.camera.position.z\n\n return this.add(\n new ZoomAnimation(duration, this.controls, zoomFrom, zoomTo)\n )\n }\n\n /**\n * Add a zoom and a move animation\n * @param {Vector3} moveTo - target position\n * @param {Number} zoomTo - target distance\n * @param {Number} duration - animation time in milliseconds\n * @return {Array} the animations\n */\n zoomMove (moveTo: Vector3, zoomTo: number, duration?: number) {\n return new AnimationList([\n this.move(moveTo, duration),\n this.zoom(zoomTo, duration)\n ])\n }\n\n /**\n * Add an orient animation\n * @param {OrientationMatrix|Array} orientTo - target orientation\n * @param {Number} duration - animation time in milliseconds\n * @return {Array} the animations\n */\n orient (orientTo: Matrix4|number[], duration?: number) {\n const p = new Vector3()\n const q = new Quaternion()\n const s = new Vector3()\n\n ensureMatrix4(orientTo).decompose(p, q, s)\n\n return new AnimationList([\n this.move(p.negate(), duration),\n this.rotate(q, duration),\n this.zoom(-s.x, duration)\n ])\n }\n\n /**\n * Add a value animation\n * @param {Number} valueFrom - start value\n * @param {Number} valueTo - target value\n * @param {Function} callback - called on every tick\n * @param {Number} duration - animation time in milliseconds\n * @return {ValueAnimation} the animation\n */\n value (valueFrom: number, valueTo: number, callback: Function, duration?: number) {\n return this.add(\n new ValueAnimation(duration, this.controls, valueFrom, valueTo, callback)\n )\n }\n\n /**\n * Add a timeout animation\n * @param {Function} callback - called after duration\n * @param {Number} duration - timeout in milliseconds\n * @return {TimeoutAnimation} the animation\n */\n timeout (callback: Function, duration?: number) {\n return this.add(\n new TimeoutAnimation(duration, this.controls, callback)\n )\n }\n\n /**\n * Add a component spin animation\n * @param {Component} component - object to move\n * @param {Vector3} axis - axis to spin around\n * @param {Number} angle - amount to spin per frame, radians\n * @param {Number} duration - animation time in milliseconds\n * @return {SpinAnimation} the animation\n */\n spinComponent (component: Component, axis?: Vector3|number[], angle?: number, duration?: number) {\n return this.add(\n // TODO\n new SpinAnimation(duration, component.controls as any, axis, angle)\n )\n }\n\n /**\n * Add a component rock animation\n * @param {Component} component - object to move\n * @param {Vector3} axis - axis to rock around\n * @param {Number} angle - amount to spin per frame, radians\n * @param {Number} end - maximum extend of motion, radians\n * @param {Number} duration - animation time in milliseconds\n * @return {SpinAnimation} the animation\n */\n rockComponent (component: Component, axis: Vector3|number[], angle?: number, end?: number, duration?: number) {\n return this.add(\n // TODO\n new RockAnimation(duration, component.controls as any, axis, angle, end)\n )\n }\n\n /**\n * Add a component move animation\n * @param {Component} component - object to move\n * @param {Vector3} moveTo - target position\n * @param {Number} duration - animation time in milliseconds\n * @return {MoveAnimation} the animation\n */\n moveComponent (component: Component, moveTo: Vector3|number[], duration?: number) {\n const moveFrom = component.controls.position.clone().negate()\n\n return this.add(\n // TODO\n new MoveAnimation(duration, component.controls as any, moveFrom, moveTo)\n )\n }\n\n /**\n * Pause all animations\n * @return {undefined}\n */\n pause () {\n this.animationList.forEach(animation => animation.pause())\n }\n\n /**\n * Resume all animations\n * @return {undefined}\n */\n resume () {\n this.animationList.forEach(animation => animation.resume())\n }\n\n /**\n * Toggle all animations\n * @return {undefined}\n */\n toggle () {\n if (this.paused) {\n this.resume()\n } else {\n this.pause()\n }\n }\n\n /**\n * Clear all animations\n * @return {undefined}\n */\n clear () {\n this.animationList.length = 0\n }\n\n dispose () {\n this.clear()\n }\n}\n\nexport default AnimationControls\n","/**\n * @file Queue\n * @author Alexander Rose \n * @private\n */\n\nclass Queue {\n queue: T[] = []\n pending = false\n\n constructor(readonly fn: Function, argList?: T[]) {\n this.next = this.next.bind(this)\n\n if (argList) {\n for (let i = 0, il = argList.length; i < il; ++i) {\n this.queue.push(argList[ i ])\n }\n this.next()\n }\n }\n\n private run (arg: any) {\n this.fn(arg, this.next)\n }\n\n private next () {\n const arg = this.queue.shift()\n if (arg !== undefined) {\n this.pending = true\n setTimeout(() => this.run(arg))\n } else {\n this.pending = false\n }\n }\n\n push (arg: T) {\n this.queue.push(arg)\n if (!this.pending) this.next()\n }\n\n kill () {\n this.queue.length = 0\n }\n\n length () {\n return this.queue.length\n }\n}\n\nexport default Queue\n","/**\n * @file Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { Color, Vector3, Matrix4 } from 'three'\n\nimport { Debug, Log, ColormakerRegistry, ExtensionFragDepth } from '../globals'\nimport { defaults } from '../utils'\nimport Queue from '../utils/queue'\nimport Counter from '../utils/counter'\nimport Viewer from '../viewer/viewer'\nimport { BufferParameters, BufferSide, default as Buffer } from '../buffer/buffer';\nimport { ColorData, ColormakerParameters, ColorMode } from '../color/colormaker';\nimport { GenericColor } from '../types'\n\nexport interface RepresentationParameters {\n name: string\n lazy: boolean,\n clipNear: number,\n clipRadius: number,\n clipCenter: Vector3,\n flatShaded: boolean,\n opacity: number,\n depthWrite: boolean,\n side: BufferSide,\n wireframe: boolean,\n colorData: ColorData,\n colorScheme: string,\n colorScale: string | number[],\n colorReverse: boolean,\n colorValue: GenericColor,\n colorDomain: number[],\n colorMode: ColorMode,\n colorSpace: 'sRGB' | 'linear',\n roughness: number,\n metalness: number,\n diffuse: GenericColor,\n diffuseInterior: boolean,\n useInteriorColor: boolean,\n interiorColor: GenericColor,\n interiorDarkening: number,\n disablePicking: boolean,\n matrix: Matrix4\n quality: string,\n visible: boolean,\n color: GenericColor,\n sphereDetail: number,\n radialSegments: number,\n openEnded: boolean\n disableImpostor: boolean\n [key: string]: any//boolean | number | undefined | Color | string | Vector3 | Matrix4 | number[]\n}\n/**\n * Representation parameter object.\n * @typedef {Object} RepresentationParameters - representation parameters\n * @property {Boolean} [lazy] - only build & update the representation when visible\n * otherwise defer changes until set visible again\n * @property {Integer} [clipNear] - position of camera near/front clipping plane\n * in percent of scene bounding box\n * @property {Integer} [clipRadius] - radius of clipping sphere\n * @property {Vector3} [clipCenter] - position of for spherical clipping\n * @property {Boolean} [flatShaded] - render flat shaded\n * @property {Float} [opacity] - translucency: 1 is fully opaque, 0 is fully transparent\n * @property {Boolean} [depthWrite] - depth write\n * @property {String} [side] - which triangle sides to render, \"front\" front-side,\n * \"back\" back-side, \"double\" front- and back-side\n * @property {Boolean} [wireframe] - render as wireframe\n * @property {ColorData} [colorData] - atom or bond indexed data for coloring\n * @property {String} [colorScheme] - color scheme\n * @property {String} [colorScale] - color scale, either a string for a\n * predefined scale or an array of\n * colors to be used as the scale\n * @property {Boolean} [colorReverse] - reverse color scale\n * @property {Color} [colorValue] - color value\n * @property {Integer[]} [colorDomain] - scale value range\n * @property {Integer} colorDomain.0 - min value\n * @property {Integer} colorDomain.1 - max value\n * @property {String} [colorMode] - color mode, one of rgb, hsv, hsl, hsi, lab, hcl\n * @property {Float} [roughness] - how rough the material is, between 0 and 1\n * @property {Float} [metalness] - how metallic the material is, between 0 and 1\n * @property {Color} [diffuse] - diffuse color for lighting\n * @property {Boolean} [diffuseInterior] - diffuse interior, i.e. ignore normal\n * @property {Boolean} [useInteriorColor] - use interior color\n * @property {Color} [interiorColor] - interior color\n * @property {Float} [interiorDarkening] - interior darkening: 0 no darking, 1 fully darkened\n * @property {Boolean} [disablePicking] - disable picking\n */\n\n/**\n * Representation object\n * @interface\n * @param {Object} object - the object to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {RepresentationParameters} [params] - representation parameters\n */\nclass Representation {\n parameters: any\n type: string\n viewer: Viewer\n tasks: Counter\n private queue: Queue\n bufferList: Buffer[]\n\n lazy: boolean\n lazyProps: { build: boolean, bufferParams: BufferParameters | {}, what: {}}\n protected name: string\n protected clipNear: number\n protected clipRadius: number\n protected clipCenter: Vector3\n protected flatShaded: boolean\n protected opacity: number\n protected depthWrite: boolean\n protected side: BufferSide\n protected wireframe: boolean\n protected colorData: ColorData\n protected colorScheme: string\n protected colorScale: string | string[]\n protected colorReverse: boolean\n protected colorValue: number\n protected colorDomain: number[]\n protected colorMode: ColorMode\n protected roughness: number\n protected metalness: number\n protected diffuse: GenericColor\n protected diffuseInterior?: boolean\n protected useInteriorColor?: boolean\n protected interiorColor: GenericColor\n protected interiorDarkening: number\n protected disablePicking: boolean\n protected sphereDetail: number\n protected radialSegments: number\n protected openEnded: boolean\n protected disableImpostor: boolean\n protected disposed: boolean\n\n protected matrix: Matrix4\n\n private quality: string\n visible: boolean\n\n protected manualAttach: ()=> any\n\n protected toBePrepared: boolean\n\n [key: string]: any\n\n constructor (object: any, viewer: Viewer, params: Partial) {\n // eslint-disable-next-line no-unused-vars\n // const p = params || {}\n\n this.type = ''\n\n this.parameters = {\n\n lazy: {\n type: 'boolean'\n },\n\n clipNear: {\n type: 'range', step: 1, max: 100, min: 0, buffer: true\n },\n clipRadius: {\n type: 'number', precision: 1, max: 1000, min: 0, buffer: true\n },\n clipCenter: {\n type: 'vector3', precision: 1, buffer: true\n },\n flatShaded: {\n type: 'boolean', buffer: true\n },\n opacity: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n depthWrite: {\n type: 'boolean', buffer: true\n },\n side: {\n type: 'select',\n buffer: true,\n options: { front: 'front', back: 'back', double: 'double' }\n },\n wireframe: {\n type: 'boolean', buffer: true\n },\n\n colorData: {\n type: 'hidden',\n update: 'color',\n },\n\n colorScheme: {\n type: 'select',\n update: 'color',\n options: {}\n },\n colorScale: {\n type: 'select',\n update: 'color',\n options: ColormakerRegistry.getScales()\n },\n colorReverse: {\n type: 'boolean', update: 'color'\n },\n colorValue: {\n type: 'color', update: 'color'\n },\n colorDomain: {\n type: 'hidden', update: 'color'\n },\n colorMode: {\n type: 'select',\n update: 'color',\n options: ColormakerRegistry.getModes()\n },\n\n roughness: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n metalness: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n diffuse: {\n type: 'color', buffer: true\n },\n\n diffuseInterior: {\n type: 'boolean', buffer: true\n },\n useInteriorColor: {\n type: 'boolean', buffer: true\n },\n interiorColor: {\n type: 'color', buffer: true\n },\n interiorDarkening: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n\n matrix: {\n type: 'hidden', buffer: true\n },\n\n disablePicking: {\n type: 'boolean', rebuild: true\n }\n\n }\n\n /**\n * @type {Viewer}\n */\n this.viewer = viewer\n\n /**\n * Counter that keeps track of tasks related to the creation of\n * the representation, including surface calculations.\n * @type {Counter}\n */\n this.tasks = new Counter()\n\n /**\n * @type {Queue}\n * @private\n */\n this.queue = new Queue(this.make.bind(this))\n\n /**\n * @type {Array}\n * @private\n */\n this.bufferList = []\n\n if (this.parameters.colorScheme) {\n this.parameters.colorScheme.options = ColormakerRegistry.getSchemes()\n }\n\n this.toBePrepared = false\n }\n\n init (params: Partial) {\n const p = params || {}\n\n this.clipNear = defaults(p.clipNear, 0)\n this.clipRadius = defaults(p.clipRadius, 0)\n this.clipCenter = defaults(p.clipCenter, new Vector3())\n this.flatShaded = defaults(p.flatShaded, false)\n this.side = defaults(p.side, 'double')\n this.opacity = defaults(p.opacity, 1.0)\n this.depthWrite = defaults(p.depthWrite, true)\n this.wireframe = defaults(p.wireframe, false)\n\n this.setColor(p.color, p)\n\n this.colorData = defaults(p.colorData, undefined)\n this.colorScheme = defaults(p.colorScheme, 'uniform')\n this.colorScale = defaults(p.colorScale, '')\n this.colorReverse = defaults(p.colorReverse, false)\n this.colorValue = defaults(p.colorValue, 0x909090)\n this.colorDomain = defaults(p.colorDomain, undefined)\n this.colorMode = defaults(p.colorMode, 'hcl')\n\n this.visible = defaults(p.visible, true)\n this.quality = defaults(p.quality, undefined)\n\n this.roughness = defaults(p.roughness, 0.4)\n this.metalness = defaults(p.metalness, 0.0)\n this.diffuse = defaults(p.diffuse, 0xffffff)\n\n this.diffuseInterior = defaults(p.diffuseInterior, false)\n this.useInteriorColor = defaults(p.useInteriorColor, false)\n this.interiorColor = defaults(p.interiorColor, 0x222222)\n this.interiorDarkening = defaults(p.interiorDarkening, 0)\n\n this.lazy = defaults(p.lazy, false)\n this.lazyProps = {\n build: false,\n bufferParams: {},\n what: {}\n }\n\n this.matrix = defaults(p.matrix, new Matrix4())\n\n this.disablePicking = defaults(p.disablePicking, false)\n\n // handle common parameters when applicable\n\n const tp = this.parameters\n\n if (tp.sphereDetail === true) {\n tp.sphereDetail = {\n type: 'integer', max: 3, min: 0, rebuild: 'impostor'\n }\n }\n if (tp.radialSegments === true) {\n tp.radialSegments = {\n type: 'integer', max: 25, min: 5, rebuild: 'impostor'\n }\n }\n if (tp.openEnded === true) {\n tp.openEnded = {\n type: 'boolean', rebuild: 'impostor', buffer: true\n }\n }\n if (tp.disableImpostor === true) {\n tp.disableImpostor = {\n type: 'boolean', rebuild: true\n }\n }\n\n if (p.quality === 'low') {\n if (tp.sphereDetail) this.sphereDetail = 0\n if (tp.radialSegments) this.radialSegments = 5\n } else if (p.quality === 'medium') {\n if (tp.sphereDetail) this.sphereDetail = 1\n if (tp.radialSegments) this.radialSegments = 10\n } else if (p.quality === 'high') {\n if (tp.sphereDetail) this.sphereDetail = 2\n if (tp.radialSegments) this.radialSegments = 20\n } else {\n if (tp.sphereDetail) {\n this.sphereDetail = defaults(p.sphereDetail, 1)\n }\n if (tp.radialSegments) {\n this.radialSegments = defaults(p.radialSegments, 10)\n }\n }\n\n if (tp.openEnded) {\n this.openEnded = defaults(p.openEnded, true)\n }\n\n if (tp.disableImpostor) {\n this.disableImpostor = defaults(p.disableImpostor, false)\n }\n\n }\n\n getColorParams (p?: {[k: string]: any}): { scheme: string, [k: string]: any } & ColormakerParameters {\n return Object.assign({\n\n data: this.colorData,\n scheme: this.colorScheme,\n scale: this.colorScale,\n reverse: this.colorReverse,\n value: this.colorValue,\n domain: this.colorDomain,\n mode: this.colorMode,\n colorSpace: this.colorSpace,\n\n }, p)\n }\n\n getBufferParams (p: {[k: string]: any} = {}) {\n return Object.assign({\n\n clipNear: this.clipNear,\n clipRadius: this.clipRadius,\n clipCenter: this.clipCenter,\n flatShaded: this.flatShaded,\n opacity: this.opacity,\n depthWrite: this.depthWrite,\n side: this.side,\n wireframe: this.wireframe,\n\n roughness: this.roughness,\n metalness: this.metalness,\n diffuse: this.diffuse,\n\n diffuseInterior: this.diffuseInterior,\n useInteriorColor: this.useInteriorColor,\n interiorColor: this.interiorColor,\n interiorDarkening: this.interiorDarkening,\n\n matrix: this.matrix,\n\n disablePicking: this.disablePicking\n\n }, p)\n }\n\n setColor (value: number | string | Color | undefined , p?: Partial) {\n const types = Object.keys(ColormakerRegistry.getSchemes())\n\n if (typeof value === 'string' && types.includes(value.toLowerCase())) {\n if (p) {\n p.colorScheme = value\n } else {\n this.setParameters({ colorScheme: value })\n }\n } else if (value !== undefined) {\n let val = new Color(value as string).getHex() //TODO\n if (p) {\n p.colorScheme = 'uniform'\n p.colorValue = val\n } else {\n this.setParameters({\n colorScheme: 'uniform', colorValue: val\n })\n }\n }\n\n return this\n }\n\n // TODO\n prepare (cb: ()=> void) {\n\n }\n\n create () {\n // this.bufferList.length = 0;\n }\n\n update (what?: any) {\n this.build()\n }\n\n build (updateWhat?: {[k: string]: boolean}) {\n if (this.lazy && (!this.visible || !this.opacity)) {\n this.lazyProps.build = true\n return\n }\n\n if (!this.toBePrepared) {\n this.tasks.increment()\n this.make()\n return\n }\n\n // don't let tasks accumulate\n if (this.queue.length() > 0) {\n this.tasks.change(1 - this.queue.length())\n this.queue.kill()\n } else {\n this.tasks.increment()\n }\n\n this.queue.push(updateWhat || false)\n }\n\n make (updateWhat?: boolean, callback?: () => void) {\n if (Debug) Log.time('Representation.make ' + this.type)\n\n const _make = () => {\n if (updateWhat) {\n this.update(updateWhat)\n this.viewer.requestRender()\n this.tasks.decrement()\n if (callback) callback()\n } else {\n this.clear()\n this.create()\n if (!this.manualAttach && !this.disposed) {\n if (Debug) Log.time('Representation.attach ' + this.type)\n this.attach(() => {\n if (Debug) Log.timeEnd('Representation.attach ' + this.type)\n this.tasks.decrement()\n if (callback) callback()\n })\n }\n }\n\n if (Debug) Log.timeEnd('Representation.make ' + this.type)\n }\n\n if (this.toBePrepared) {\n this.prepare(_make)\n } else {\n _make()\n }\n }\n\n attach (callback: () => void) {\n this.setVisibility(this.visible)\n\n callback()\n }\n\n /**\n * Set the visibility of the representation\n * @param {Boolean} value - visibility flag\n * @param {Boolean} [noRenderRequest] - whether or not to request a re-render from the viewer\n * @return {Representation} this object\n */\n setVisibility (value: boolean, noRenderRequest?: boolean): Representation {\n this.visible = value\n\n if (this.visible && this.opacity) {\n const lazyProps = this.lazyProps\n const bufferParams = lazyProps.bufferParams\n const what = lazyProps.what\n\n if (lazyProps.build) {\n lazyProps.build = false\n this.build()\n return this\n } else if (Object.keys(bufferParams).length || Object.keys(what).length) {\n lazyProps.bufferParams = {}\n lazyProps.what = {}\n this.updateParameters(bufferParams, what)\n }\n }\n\n this.bufferList.forEach(function (buffer) {\n buffer.setVisibility(value)\n })\n\n if (!noRenderRequest) this.viewer.requestRender()\n\n return this\n }\n\n /**\n * Set the visibility of the representation\n * @param {RepresentationParameters} params - parameters object\n * @param {Object} [what] - buffer data attributes to be updated,\n * note that this needs to be implemented in the\n * derived classes. Generally it allows more\n * fine-grained control over updating than\n * forcing a rebuild.\n * @param {Boolean} what.position - update position data\n * @param {Boolean} what.color - update color data\n * @param {Boolean} [rebuild] - whether or not to rebuild the representation\n * @return {Representation} this object\n */\n setParameters (params: Partial, what:{[propName: string]: any} = {}, rebuild = false) {\n const p = params || {}\n const tp = this.parameters\n const bufferParams: BufferParameters = {}\n\n if (!this.opacity && p.opacity !== undefined) {\n if (this.lazyProps.build) {\n this.lazyProps.build = false\n rebuild = true\n } else {\n Object.assign(bufferParams, this.lazyProps.bufferParams)\n Object.assign(what, this.lazyProps.what)\n this.lazyProps.bufferParams = {}\n this.lazyProps.what = {}\n }\n }\n\n this.setColor(p.color, p)\n\n for (let name in p) {\n if (p[ name ] === undefined) continue\n if (tp[ name ] == undefined ) continue // Skip nulls as well as undefined\n\n if (tp[ name ].int) p[ name ] = parseInt(p[ name ] as string)\n if (tp[ name ].float) p[ name ] = parseFloat(p[ name ] as string)\n\n // no value change\n if (p[ name ] === this[ name ] && (\n !p[ name ].equals || p[ name ].equals(this[ name ])\n )) continue\n\n if (this[ name ] && this[ name ].copy && p[ name ].copy) {\n this[ name ].copy(p[ name ])\n } else if (this[ name ] && this[ name ].set) {\n this[ name ].set(p[ name ])\n } else {\n this[ name ] = p[ name ]\n }\n\n // buffer param\n if (tp[ name ].buffer) {\n if (tp[ name ].buffer === true) {\n (bufferParams[ name as keyof BufferParameters ] as any) = p[ name ]\n } else {\n let key: (keyof BufferParameters) = tp[ name ].buffer;\n (bufferParams[ key ] as any) = p[ name ]\n }\n }\n\n // mark for update\n if (tp[ name ].update) {\n what[ tp[ name ].update ] = true\n }\n\n // mark for rebuild\n if (tp[ name ].rebuild &&\n !(tp[ name ].rebuild === 'impostor' &&\n ExtensionFragDepth && !this.disableImpostor)\n ) {\n rebuild = true\n }\n }\n\n //\n\n if (rebuild) {\n this.build()\n } else {\n this.updateParameters(bufferParams, what)\n }\n\n return this\n }\n\n updateParameters (bufferParams: BufferParameters | {} = {}, what?: any) {\n if (this.lazy && (!this.visible || !this.opacity) && bufferParams.hasOwnProperty('opacity') === false) {\n Object.assign(this.lazyProps.bufferParams, bufferParams)\n Object.assign(this.lazyProps.what, what)\n return\n }\n\n this.bufferList.forEach(function (buffer) {\n buffer.setParameters(bufferParams)\n })\n\n if (Object.keys(what).length) {\n this.update(what) // update buffer attribute\n }\n\n this.viewer.requestRender()\n }\n\n getParameters () {\n const params: Partial = {\n lazy: this.lazy,\n visible: this.visible,\n quality: this.quality\n }\n\n Object.keys(this.parameters).forEach(name => {\n if (this.parameters[ name ] !== null) {\n params[ name ] = this[ name ]\n }\n })\n\n return params\n }\n\n clear () {\n this.bufferList.forEach(buffer => {\n this.viewer.remove(buffer)\n buffer.dispose()\n })\n this.bufferList.length = 0\n\n this.viewer.requestRender()\n }\n\n dispose () {\n this.disposed = true\n this.queue.kill()\n this.tasks.dispose()\n this.clear()\n }\n}\n\nexport default Representation\n","/**\n * @file Worker\n * @author Alexander Rose \n * @private\n */\n\nimport { Log, Debug, WorkerRegistry } from '../globals'\n\nexport default class _Worker {\n\n pending = 0\n postCount = 0\n onmessageDict: { [k: number]: Function|undefined } = {}\n onerrorDict: { [k: number]: Function|undefined } = {}\n\n name: string\n blobUrl: string\n worker: Worker\n\n constructor (name: string) {\n\n this.name = name\n this.blobUrl = window.URL.createObjectURL(WorkerRegistry.get(name))\n this.worker = new Worker(this.blobUrl)\n\n WorkerRegistry.activeWorkerCount += 1\n\n this.worker.onmessage = (event: any) => {\n this.pending -= 1\n const postId = event.data.__postId\n\n if (Debug) Log.timeEnd('Worker.postMessage ' + name + ' #' + postId)\n\n const onmessage = this.onmessageDict[ postId ]\n if (onmessage) {\n onmessage.call(this.worker, event)\n } else {\n // Log.debug('No onmessage', postId, name)\n }\n\n delete this.onmessageDict[ postId ]\n delete this.onerrorDict[ postId ]\n }\n\n this.worker.onerror = (event: any) => {\n this.pending -= 1\n if (event.data) {\n const postId = event.data.__postId\n\n const onerror = this.onerrorDict[ postId ]\n if (onerror) {\n onerror.call(this.worker, event)\n } else {\n Log.error('Worker.onerror', postId, name, event)\n }\n\n delete this.onmessageDict[ postId ]\n delete this.onerrorDict[ postId ]\n } else {\n Log.error('Worker.onerror', name, event)\n }\n }\n }\n\n post (aMessage: any = {}, transferList?: any, onmessage?: Function, onerror?: Function) {\n this.onmessageDict[ this.postCount ] = onmessage\n this.onerrorDict[ this.postCount ] = onerror\n\n aMessage.__name = this.name\n aMessage.__postId = this.postCount\n aMessage.__debug = Debug\n\n if (Debug) Log.time(`Worker.postMessage ${this.name} #${this.postCount}`)\n\n try {\n this.worker.postMessage(aMessage, transferList)\n } catch (error) {\n Log.error('worker.post:', error)\n this.worker.postMessage(aMessage)\n }\n\n this.pending += 1\n this.postCount += 1\n\n return this\n }\n\n terminate () {\n if (this.worker) {\n this.worker.terminate()\n window.URL.revokeObjectURL(this.blobUrl)\n WorkerRegistry.activeWorkerCount -= 1\n } else {\n Log.log('no worker to terminate')\n }\n }\n}\n","/**\n * @file Worker Pool\n * @author Alexander Rose \n * @private\n */\n\nimport Worker from './worker'\n\nclass WorkerPool {\n maxCount: number\n pool: Worker[] = []\n count = 0\n name: string\n\n constructor (name: string, maxCount = 2) {\n this.maxCount = Math.min(8, maxCount)\n this.name = name\n }\n\n post (aMessage: any = {}, transferList?: any, onmessage?: Function, onerror?: Function) {\n const worker = this.getNextWorker()\n if (worker) {\n worker.post(aMessage, transferList, onmessage, onerror)\n } else {\n console.error('unable to get worker from pool')\n }\n\n return this\n }\n\n terminate () {\n this.pool.forEach(function (worker) {\n worker.terminate()\n })\n }\n\n getNextWorker () {\n let nextWorker\n let minPending = Infinity\n\n for (let i = 0; i < this.maxCount; ++i) {\n if (i >= this.count) {\n nextWorker = new Worker(this.name)\n this.pool.push(nextWorker)\n this.count += 1\n break\n }\n\n const worker = this.pool[ i ]\n\n if (worker.pending === 0) {\n nextWorker = worker\n break\n } else if (worker.pending < minPending) {\n minPending = worker.pending\n nextWorker = worker\n }\n }\n\n return nextWorker\n }\n}\n\nWorkerPool.prototype.constructor = WorkerPool\n\nexport default WorkerPool\n","/**\n * @file Vector Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { NumberArray } from '../types'\nimport { EPS } from './math-constants'\n\n/**\n * Calculate the two intersection points\n * Converted to JavaScript from\n * {@link http://paulbourke.net/geometry/pointlineplane/lineline.c}\n */\nexport function lineLineIntersect (p1: Vector3, p2: Vector3, p3: Vector3, p4: Vector3) {\n const p13 = new Vector3()\n const p43 = new Vector3()\n const p21 = new Vector3()\n let d1343, d4321, d1321, d4343, d2121\n let denom, numer\n\n p13.x = p1.x - p3.x\n p13.y = p1.y - p3.y\n p13.z = p1.z - p3.z\n p43.x = p4.x - p3.x\n p43.y = p4.y - p3.y\n p43.z = p4.z - p3.z\n if (Math.abs(p43.x) < EPS && Math.abs(p43.y) < EPS && Math.abs(p43.z) < EPS) { return null }\n\n p21.x = p2.x - p1.x\n p21.y = p2.y - p1.y\n p21.z = p2.z - p1.z\n if (Math.abs(p21.x) < EPS && Math.abs(p21.y) < EPS && Math.abs(p21.z) < EPS) { return null }\n\n d1343 = p13.x * p43.x + p13.y * p43.y + p13.z * p43.z\n d4321 = p43.x * p21.x + p43.y * p21.y + p43.z * p21.z\n d1321 = p13.x * p21.x + p13.y * p21.y + p13.z * p21.z\n d4343 = p43.x * p43.x + p43.y * p43.y + p43.z * p43.z\n d2121 = p21.x * p21.x + p21.y * p21.y + p21.z * p21.z\n\n denom = d2121 * d4343 - d4321 * d4321\n if (Math.abs(denom) < EPS) { return null }\n numer = d1343 * d4321 - d1321 * d4343\n\n const mua = numer / denom\n const mub = (d1343 + d4321 * mua) / d4343\n\n const pa = new Vector3(\n p1.x + mua * p21.x,\n p1.y + mua * p21.y,\n p1.z + mua * p21.z\n )\n const pb = new Vector3(\n p3.x + mub * p43.x,\n p3.y + mub * p43.y,\n p3.z + mub * p43.z\n )\n\n return [ pa, pb ]\n}\n\nexport function calculateMeanVector3 (array: NumberArray) {\n const n = array.length\n const m = n / 3\n\n let x = 0\n let y = 0\n let z = 0\n\n for (let i = 0; i < n; i += 3) {\n x += array[ i + 0 ]\n y += array[ i + 1 ]\n z += array[ i + 2 ]\n }\n\n return new Vector3(x / m, y / m, z / m)\n}\n\nexport function isPointOnSegment (p: Vector3, l1: Vector3, l2: Vector3) {\n const len = l1.distanceTo(l2)\n\n return p.distanceTo(l1) <= len && p.distanceTo(l2) <= len\n}\n\nexport function projectPointOnVector (point: Vector3, vector: Vector3, origin?: Vector3) {\n if (origin) {\n point.sub(origin).projectOnVector(vector).add(origin)\n } else {\n point.projectOnVector(vector)\n }\n\n return point\n}\n\nexport function computeBoundingBox (array: NumberArray) {\n let minX = +Infinity\n let minY = +Infinity\n let minZ = +Infinity\n let maxX = -Infinity\n let maxY = -Infinity\n let maxZ = -Infinity\n for (let i = 0, l = array.length; i < l; i += 3) {\n const x = array[ i ]\n const y = array[ i + 1 ]\n const z = array[ i + 2 ]\n if (x < minX) minX = x\n if (y < minY) minY = y\n if (z < minZ) minZ = z\n if (x > maxX) maxX = x\n if (y > maxY) maxY = y\n if (z > maxZ) maxZ = z\n }\n return [\n v3new([ minX, minY, minZ ]),\n v3new([ maxX, maxY, maxZ ])\n ]\n}\n(computeBoundingBox as any).__deps = [ v3new ]\n\nexport function applyMatrix4toVector3array (m: Float32Array, a: Float32Array) {\n for (let i = 0, il = a.length; i < il; i += 3) {\n const x = a[ i ]\n const y = a[ i + 1 ]\n const z = a[ i + 2 ]\n a[ i ] = m[ 0 ] * x + m[ 4 ] * y + m[ 8 ] * z + m[ 12 ]\n a[ i + 1 ] = m[ 1 ] * x + m[ 5 ] * y + m[ 9 ] * z + m[ 13 ]\n a[ i + 2 ] = m[ 2 ] * x + m[ 6 ] * y + m[ 10 ] * z + m[ 14 ]\n }\n}\n\nexport function applyMatrix3toVector3array (m: Float32Array, a: Float32Array) {\n for (let i = 0, il = a.length; i < il; i += 3) {\n const x = a[ i ]\n const y = a[ i + 1 ]\n const z = a[ i + 2 ]\n a[ i ] = m[ 0 ] * x + m[ 3 ] * y + m[ 6 ] * z\n a[ i + 1 ] = m[ 1 ] * x + m[ 4 ] * y + m[ 7 ] * z\n a[ i + 2 ] = m[ 2 ] * x + m[ 5 ] * y + m[ 8 ] * z\n }\n}\n\nexport function normalizeVector3array (a: Float32Array) {\n for (let i = 0, il = a.length; i < il; i += 3) {\n const x = a[ i ]\n const y = a[ i + 1 ]\n const z = a[ i + 2 ]\n const len2 = x * x + y * y + z * z\n if (len2 > 0) { // avoid divide by zero\n const s = 1 / Math.sqrt(len2)\n a[ i ] = x * s\n a[ i + 1 ] = y * s\n a[ i + 2 ] = z * s\n }\n // else leave as all zeros\n }\n}\n\nexport function v3new (array?: NumberArray) {\n return new Float32Array(array as any || 3) // TODO\n}\n\nexport function v3cross (out: Float32Array, a: Float32Array, b: Float32Array) {\n const ax = a[0]\n const ay = a[1]\n const az = a[2]\n const bx = b[0]\n const by = b[1]\n const bz = b[2]\n out[0] = ay * bz - az * by\n out[1] = az * bx - ax * bz\n out[2] = ax * by - ay * bx\n}\n\nexport function v3dot (a: Float32Array, b: Float32Array) {\n return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]\n}\n\nexport function v3sub (out: Float32Array, a: Float32Array, b: Float32Array) {\n out[0] = a[0] - b[0]\n out[1] = a[1] - b[1]\n out[2] = a[2] - b[2]\n}\n\nexport function v3add (out: Float32Array, a: Float32Array, b: Float32Array) {\n out[0] = a[0] + b[0]\n out[1] = a[1] + b[1]\n out[2] = a[2] + b[2]\n}\n\nexport function v3fromArray (out: Float32Array, array: Float32Array, offset = 0) {\n out[0] = array[offset]\n out[1] = array[offset + 1]\n out[2] = array[offset + 2]\n}\n\nexport function v3toArray (input: Float32Array, array: Float32Array, offset = 0) {\n array[offset] = input[0]\n array[offset + 1] = input[1]\n array[offset + 2] = input[2]\n}\n\nexport function v3forEach (array: Float32Array, fn: (i: Float32Array, j: Float32Array, k: Float32Array) => void, b: Float32Array) {\n const a = v3new()\n for (let i = 0, n = array.length; i < n; i += 3) {\n v3fromArray(a, array, i)\n fn(a, a, b)\n v3toArray(a, array, i)\n }\n}\n(v3forEach as any).__deps = [ v3new, v3fromArray, v3toArray ]\n\nexport function v3length2 (a: Float32Array) {\n return a[0] * a[0] + a[1] * a[1] + a[2] * a[2]\n}\n\nexport function v3length (a: Float32Array) {\n return Math.sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2])\n}\n\nexport function v3divide (out: Float32Array, a: Float32Array, b: Float32Array) {\n out[0] = a[0] / b[0]\n out[1] = a[1] / b[1]\n out[2] = a[2] / b[2]\n}\n\nexport function v3multiply (out: Float32Array, a: Float32Array, b: Float32Array) {\n out[0] = a[0] * b[0]\n out[1] = a[1] * b[1]\n out[2] = a[2] * b[2]\n}\n\nexport function v3divideScalar (out: Float32Array, a: Float32Array, s: number) {\n v3multiplyScalar(out, a, 1 / s)\n}\n(v3divideScalar as any).__deps = [ v3multiplyScalar ]\n\nexport function v3multiplyScalar (out: Float32Array, a: Float32Array, s: number) {\n out[0] = a[0] * s\n out[1] = a[1] * s\n out[2] = a[2] * s\n}\n\nexport function v3normalize (out: Float32Array, a: Float32Array) {\n const length2 = v3length2(a)\n if (length2 == 0) {\n out[0] = a[0]\n out[1] = a[1]\n out[2] = a[2]\n } else {\n v3multiplyScalar(out, a, 1 / Math.sqrt(length2))\n }\n}\n(v3normalize as any).__deps = [ v3multiplyScalar, v3length2 ]\n\nexport function v3subScalar (out: Float32Array, a: Float32Array, s: number) {\n out[0] = a[0] - s\n out[1] = a[1] - s\n out[2] = a[2] - s\n}\n\nexport function v3addScalar (out: Float32Array, a: Float32Array, s: number) {\n out[0] = a[0] + s\n out[1] = a[1] + s\n out[2] = a[2] + s\n}\n\nexport function v3floor (out: Float32Array, a: Float32Array) {\n out[0] = Math.floor(a[0])\n out[1] = Math.floor(a[1])\n out[2] = Math.floor(a[2])\n}\n\nexport function v3ceil (out: Float32Array, a: Float32Array) {\n out[0] = Math.ceil(a[0])\n out[1] = Math.ceil(a[1])\n out[2] = Math.ceil(a[2])\n}\n\nexport function v3round (out: Float32Array, a: Float32Array) {\n out[0] = Math.round(a[0])\n out[1] = Math.round(a[1])\n out[2] = Math.round(a[2])\n}\n\nexport function v3negate (out: Float32Array, a: Float32Array) {\n out[0] = -a[0]\n out[1] = -a[1]\n out[2] = -a[2]\n}\n\nexport function v3angle (a: Float32Array, b: Float32Array) {\n const ax = a[0]\n const ay = a[1]\n const az = a[2]\n const bx = b[0]\n const by = b[1]\n const bz = b[2]\n const cx = ay * bz - az * by\n const cy = az * bx - ax * bz\n const cz = ax * by - ay * bx\n const s = Math.sqrt(cx * cx + cy * cy + cz * cz)\n const c = ax * bx + ay * by + az * bz\n return Math.atan2(s, c)\n}\n","/**\n * @file Dash\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport { WideLineBufferData } from '../buffer/wideline-buffer'\nimport {\n calculateDirectionArray, calculateCenterArray,\n replicateArrayEntries, replicateArray3Entries\n} from '../math/array-utils'\n\nexport function getFixedCountDashData (data: T, segmentCount: number = 9) {\n\n const s = Math.floor(segmentCount / 2)\n const n = data.position1.length / 3\n const sn = s * n\n const sn3 = sn * 3\n const step = 1 / segmentCount\n\n const direction = calculateDirectionArray(data.position1, data.position2)\n const position1 = new Float32Array(sn3)\n const position2 = new Float32Array(sn3)\n\n const v = new Vector3()\n\n for (let i = 0; i < n; ++i) {\n const i3 = i * 3\n v.set(direction[ i3 ], direction[ i3 + 1 ], direction[ i3 + 2 ])\n\n const x = data.position1[ i3 ]\n const y = data.position1[ i3 + 1 ]\n const z = data.position1[ i3 + 2 ]\n\n for (let j = 0; j < s; ++j) {\n const j3 = s * i3 + j * 3\n\n const f1 = step * (j * 2 + 1)\n const f2 = step * (j * 2 + 2)\n\n position1[ j3 ] = x + v.x * f1\n position1[ j3 + 1 ] = y + v.y * f1\n position1[ j3 + 2 ] = z + v.z * f1\n\n position2[ j3 ] = x + v.x * f2\n position2[ j3 + 1 ] = y + v.y * f2\n position2[ j3 + 2 ] = z + v.z * f2\n }\n }\n\n const position = calculateCenterArray(position1, position2) as Float32Array\n const color = replicateArray3Entries(data.color!, s) // TODO\n const color2 = color\n\n const d: any = { position, position1, position2, color, color2 }\n\n if ((data as any).radius) { // TODO\n d.radius = replicateArrayEntries((data as any).radius, s) // TODO\n }\n\n if (data.picking && data.picking.array) {\n data.picking.array = replicateArrayEntries(data.picking.array, s)\n d.picking = data.picking\n }\n if (data.primitiveId) {\n d.primitiveId = replicateArrayEntries(data.primitiveId, s)\n }\n\n return d as T\n}\n\nexport function getFixedLengthDashData (data: T, segmentLength: number = 0.1) {\n\n const direction = calculateDirectionArray(data.position1, data.position2)\n const pos1: number[] = []\n const pos2: number[] = []\n const col: number[] = []\n const rad: number[]|undefined = (data as any).radius ? [] : undefined\n const pick: number[]|undefined = (data as any).picking ? [] : undefined\n const id: number[]|undefined = (data as any).primitiveId ? [] : undefined\n\n const v = new Vector3()\n const n = data.position1.length / 3\n\n let k = 0\n\n for (let i = 0; i < n; ++i) {\n const i3 = i * 3\n v.set(direction[ i3 ], direction[ i3 + 1 ], direction[ i3 + 2 ])\n\n const vl = v.length()\n const segmentCount = vl / segmentLength\n const s = Math.floor(segmentCount / 2)\n const step = 1 / segmentCount\n\n const x = data.position1[ i3 ]\n const y = data.position1[ i3 + 1 ]\n const z = data.position1[ i3 + 2 ]\n\n for (let j = 0; j < s; ++j) {\n const j3 = k * 3 + j * 3\n\n const f1 = step * (j * 2 + 1)\n const f2 = step * (j * 2 + 2)\n\n pos1[ j3 ] = x + v.x * f1\n pos1[ j3 + 1 ] = y + v.y * f1\n pos1[ j3 + 2 ] = z + v.z * f1\n\n pos2[ j3 ] = x + v.x * f2\n pos2[ j3 + 1 ] = y + v.y * f2\n pos2[ j3 + 2 ] = z + v.z * f2\n\n if (data.color) {\n col[ j3 ] = data.color[ i3 ]\n col[ j3 + 1 ] = data.color[ i3 + 1 ]\n col[ j3 + 2 ] = data.color[ i3 + 2 ]\n }\n\n if (rad) rad[ k + j ] = (data as any).radius[ i ]\n if (pick) {\n if ((data as any).picking.array) {\n pick[ k + j ] = (data as any).picking.array[ i ]\n } else {\n pick[ k + j ] = i\n }\n }\n if (id) id[ k + j ] = (data as any).primitiveId[ i ]\n }\n\n k += s\n }\n\n const position1 = new Float32Array(pos1)\n const position2 = new Float32Array(pos2)\n const position = calculateCenterArray(position1, position2) as Float32Array\n const color = new Float32Array(col)\n const color2 = color\n\n const d: any = { position, position1, position2, color, color2 }\n\n if (rad) d.radius = new Float32Array(rad)\n if (pick && data.picking) {\n data.picking.array = new Float32Array(pick)\n d.picking = data.picking\n }\n if (id) d.primitiveId = new Float32Array(id)\n\n return d as T\n}\n\nexport function getFixedLengthWrappedDashData (data: T, segmentLength: number = 0.1) {\n\n const direction = calculateDirectionArray(data.position1, data.position2)\n const pos1: number[] = []\n const pos2: number[] = []\n const col: number[] = []\n const rad: number[]|undefined = (data as any).radius ? [] : undefined\n const pick: number[]|undefined = (data as any).picking ? [] : undefined\n const id: number[]|undefined = (data as any).primitiveId ? [] : undefined\n\n const v = new Vector3()\n const n = data.position1.length / 3\n\n let remaining = segmentLength\n let drawing = true\n\n let k = 0\n let k3 = 0\n let kprev = 0\n\n for (let i = 0; i < n; ++i) {\n const i3 = i * 3\n const x = data.position1[ i3 ]\n const y = data.position1[ i3 + 1 ]\n const z = data.position1[ i3 + 2 ]\n\n v.set(direction[ i3 ], direction[ i3 + 1 ], direction[ i3 + 2 ])\n const vl = v.length()\n\n if (drawing) {\n pos1[ k3 ] = x\n pos1[ k3 + 1 ] = y\n pos1[ k3 + 2 ] = z\n }\n\n let dist = remaining\n const inv = 1 / vl\n while (dist < vl) {\n const a = drawing ? pos2 : pos1\n a[ k3 ] = x + v.x * dist * inv\n a[ k3 + 1 ] = y + v.y * dist * inv\n a[ k3 + 2 ] = z + v.z * dist * inv\n if (drawing) {\n k++\n k3 = k * 3\n }\n drawing = !drawing\n remaining = segmentLength\n dist += segmentLength\n }\n\n if (drawing) {\n pos2[ k3 ] = data.position2[ i3 ]\n pos2[ k3 + 1 ] = data.position2[ i3 + 1 ]\n pos2[ k3 + 2 ] = data.position2[ i3 + 2 ]\n k++\n k3 = k * 3\n }\n\n remaining = dist - vl\n\n for (let j = kprev; j < k ; j++){\n if (data.color) {\n const j3 = j * 3\n col[ j3 ] = data.color[ i3 ]\n col[ j3 + 1 ] = data.color[ i3 + 1 ]\n col[ j3 + 2 ] = data.color[ i3 + 2 ]\n }\n\n if (rad) rad[ j ] = (data as any).radius[ i ]\n if (pick) {\n if ((data as any).picking.array) {\n pick[ j ] = (data as any).picking.array[ i ]\n } else {\n pick[ j ] = i\n }\n }\n if (id) id[ j ] = (data as any).primitiveId[ i ]\n }\n\n kprev = k\n\n }\n\n if (!drawing && n > 0) {\n const k3 = k * 3\n pos2[ k3 ] = data.position2[ 3 * n - 3 ]\n pos2[ k3 + 1 ] = data.position2[ 3 * n - 2 ]\n pos2[ k3 + 1 ] = data.position2[ 3 * n - 1 ]\n }\n\n const position1 = new Float32Array(pos1)\n const position2 = new Float32Array(pos2)\n const position = calculateCenterArray(position1, position2) as Float32Array\n const color = new Float32Array(col)\n const color2 = color\n\n const d: any = { position, position1, position2, color, color2 }\n\n if (rad) d.radius = new Float32Array(rad)\n if (pick && data.picking) {\n data.picking.array = new Float32Array(pick)\n d.picking = data.picking\n }\n if (id) d.primitiveId = new Float32Array(id)\n\n return d as T\n}\n","/**\n * @file Primitive\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Color, Box3 } from 'three'\n\nimport { BufferRegistry, PickerRegistry } from '../globals'\nimport Shape from './shape'\nimport { getFixedLengthDashData } from './dash'\n\nfunction addElement (elm: any, array: any[]) {\n if (elm.toArray !== undefined) {\n elm = elm.toArray()\n } else if (elm.x !== undefined) {\n elm = [ elm.x, elm.y, elm.z ]\n } else if (elm.r !== undefined) {\n elm = [ elm.r, elm.g, elm.b ]\n }\n array.push.apply(array, elm)\n}\n\nconst tmpVec = new Vector3()\n\nexport type PrimitiveFields = { [k: string]: string }\n\n/**\n * Base class for geometry primitives\n * @interface\n */\nexport abstract class Primitive {\n static type = ''\n static fields: PrimitiveFields = {}\n\n static get Picker () { return PickerRegistry.get(this.type) }\n static get Buffer () { return BufferRegistry.get(this.type) }\n\n static getShapeKey (name: string) {\n return this.type + name[0].toUpperCase() + name.substr(1)\n }\n\n static expandBoundingBox (box: Box3, data: any) {}\n\n static valueToShape (shape: Shape, name: string, value: any) {\n const data = shape._primitiveData[this.getShapeKey(name)]\n const type = this.fields[name]\n\n switch (type) {\n case 'v3':\n case 'c':\n addElement(value, data)\n break\n default:\n data.push(value)\n }\n }\n\n static objectToShape (shape: Shape, data: any) {\n Object.keys(this.fields).forEach(name => {\n this.valueToShape(shape, name, data[name])\n })\n this.valueToShape(shape, 'name', data.name)\n this.expandBoundingBox(shape.boundingBox, data)\n }\n\n static valueFromShape (shape: Shape, pid: number, name: string) {\n const data = shape._primitiveData[this.getShapeKey(name)]\n const type = this.fields[name]\n\n switch (type) {\n case 'v3':\n return new Vector3().fromArray(data, 3 * pid)\n case 'c':\n return new Color().fromArray(data, 3 * pid)\n default:\n return data[pid]\n }\n }\n\n static objectFromShape (shape: Shape, pid: number) {\n let name = this.valueFromShape(shape, pid, 'name')\n if (name === undefined) {\n name = `${this.type}: ${pid} (${shape.name})`\n }\n const o: any = { shape, name }\n\n Object.keys(this.fields).forEach(name => {\n o[name] = this.valueFromShape(shape, pid, name)\n })\n\n return o\n }\n\n static arrayFromShape (shape: Shape, name: string) {\n const data = shape._primitiveData[this.getShapeKey(name)]\n const type = this.fields[name]\n\n switch (type) {\n case 's':\n return data\n default:\n return new Float32Array(data)\n }\n }\n\n static dataFromShape (shape: Shape) {\n const data: any = {}\n\n if (this.Picker) {\n data.picking = new this.Picker(shape)\n }\n\n Object.keys(this.fields).forEach(name => {\n data[name] = this.arrayFromShape(shape, name)\n })\n\n return data\n }\n\n static bufferFromShape (shape: Shape, params: any) {\n return new this.Buffer(this.dataFromShape(shape), params)\n }\n}\n\n/**\n * Sphere geometry primitive\n */\nexport class SpherePrimitive extends Primitive {\n static type = 'sphere'\n\n static fields = {\n position: 'v3',\n color: 'c',\n radius: 'f'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n return this.valueFromShape(shape, pid, 'position')\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position))\n }\n}\n\n/**\n * Box geometry primitive\n */\nexport class BoxPrimitive extends Primitive {\n static type = 'box'\n\n static fields = {\n position: 'v3',\n color: 'c',\n size: 'f',\n heightAxis: 'v3',\n depthAxis: 'v3'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n return this.valueFromShape(shape, pid, 'position')\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position))\n }\n}\n\n/**\n * Octahedron geometry primitive\n */\nexport class OctahedronPrimitive extends BoxPrimitive {\n static type = 'octahedron'\n}\n\n/**\n * Tetrahedron geometry primitive\n */\nexport class TetrahedronPrimitive extends BoxPrimitive {\n static type = 'tetrahedron'\n}\n\n/**\n * Cylinder geometry primitive\n */\nexport class CylinderPrimitive extends Primitive {\n static type = 'cylinder'\n\n static fields = {\n position1: 'v3',\n position2: 'v3',\n color: 'c',\n radius: 'f'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n const p1 = this.valueFromShape(shape, pid, 'position1')\n const p2 = this.valueFromShape(shape, pid, 'position2')\n return p1.add(p2).multiplyScalar(0.5)\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position1))\n box.expandByPoint(tmpVec.fromArray(data.position2))\n }\n\n static bufferFromShape (shape: Shape, params: any = {}) {\n let data = this.dataFromShape(shape)\n if (this.type === 'cylinder' && params.dashedCylinder) {\n data = getFixedLengthDashData(data)\n }\n return new this.Buffer(data, params)\n }\n}\n\n/**\n * Arrow geometry primitive\n */\nexport class ArrowPrimitive extends CylinderPrimitive {\n static type = 'arrow'\n}\n\n/**\n * Cone geometry primitive\n */\nexport class ConePrimitive extends CylinderPrimitive {\n static type = 'cone'\n}\n\n/**\n * Ellipsoid geometry primitive\n */\nexport class EllipsoidPrimitive extends SpherePrimitive {\n static type = 'ellipsoid'\n\n static fields = {\n position: 'v3',\n color: 'c',\n radius: 'f',\n majorAxis: 'v3',\n minorAxis: 'v3'\n }\n}\n\n/**\n * Torus geometry primitive\n */\nexport class TorusPrimitive extends EllipsoidPrimitive {\n static type = 'torus'\n}\n\n/**\n * Text geometry primitive\n */\nexport class TextPrimitive extends Primitive {\n static type = 'text'\n\n static fields = {\n position: 'v3',\n color: 'c',\n size: 'f',\n text: 's'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n return this.valueFromShape(shape, pid, 'position')\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position))\n }\n}\n\n/**\n * Point primitive\n */\nexport class PointPrimitive extends Primitive {\n static type = 'point'\n\n static fields = {\n position: 'v3',\n color: 'c',\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n return this.valueFromShape(shape, pid, 'position')\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position))\n }\n}\n\n/**\n * Wideline geometry primitive\n */\nexport class WidelinePrimitive extends Primitive {\n static type = 'wideline'\n\n static fields = {\n position1: 'v3',\n position2: 'v3',\n color: 'c'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n const p1 = this.valueFromShape(shape, pid, 'position1')\n const p2 = this.valueFromShape(shape, pid, 'position2')\n return p1.add(p2).multiplyScalar(0.5)\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position1))\n box.expandByPoint(tmpVec.fromArray(data.position2))\n }\n}\n","/**\n * @file Spatial Hash\n * @author Alexander Rose \n * @private\n */\n\nimport { Box3 } from 'three'\n\nexport type Positions = {\n x: ArrayLike,\n y: ArrayLike,\n z: ArrayLike,\n count?:number\n}\n\nfunction createBoundingBox(positions: Positions) {\n const { x, y, z } = positions\n const boundingBox = new Box3()\n const count = x.length\n const { min, max } = boundingBox\n\n for (let i = 0; i < count; i++) {\n min.x = Math.min(x[i], min.x)\n min.y = Math.min(y[i], min.y)\n min.z = Math.min(z[i], min.z)\n max.x = Math.max(x[i], max.x)\n max.y = Math.max(y[i], max.y)\n max.z = Math.max(z[i], max.z)\n }\n\n return boundingBox\n}\n\nexport default class SpatialHash {\n exp = 3\n\n minX: number\n minY: number\n minZ: number\n\n boundX: number\n boundY: number\n boundZ: number\n\n grid: Uint32Array\n bucketCount: Uint16Array\n bucketOffset: Uint32Array\n bucketArray: Int32Array\n\n xArray: ArrayLike\n yArray: ArrayLike\n zArray: ArrayLike\n\n constructor(positions: Positions, boundingBox?: Box3) {\n const bb = boundingBox || createBoundingBox(positions)\n this.minX = bb.min.x\n this.minY = bb.min.y\n this.minZ = bb.min.z\n this.boundX = ((bb.max.x - this.minX) >> this.exp) + 1\n this.boundY = ((bb.max.y - this.minY) >> this.exp) + 1\n this.boundZ = ((bb.max.z - this.minZ) >> this.exp) + 1\n\n const n = this.boundX * this.boundY * this.boundZ\n const an = (positions.count !== undefined) ? positions.count : positions.x.length\n\n const xArray = positions.x\n const yArray = positions.y\n const zArray = positions.z\n\n let count = 0\n const grid = new Uint32Array(n)\n const bucketIndex = new Int32Array(an)\n for (let i = 0; i < an; ++i) {\n const x = (xArray[ i ] - this.minX) >> this.exp\n const y = (yArray[ i ] - this.minY) >> this.exp\n const z = (zArray[ i ] - this.minZ) >> this.exp\n const idx = (((x * this.boundY) + y) * this.boundZ) + z\n if ((grid[ idx ] += 1) === 1) {\n count += 1\n }\n bucketIndex[ i ] = idx\n }\n\n const bucketCount = new Uint16Array(count)\n for (let i = 0, j = 0; i < n; ++i) {\n const c = grid[ i ]\n if (c > 0) {\n grid[ i ] = j + 1\n bucketCount[ j ] = c\n j += 1\n }\n }\n\n const bucketOffset = new Uint32Array(count)\n for (let i = 1; i < count; ++i) {\n bucketOffset[ i ] += bucketOffset[ i - 1 ] + bucketCount[ i - 1 ]\n }\n\n const bucketFill = new Uint16Array(count)\n const bucketArray = new Int32Array(an)\n for (let i = 0; i < an; ++i) {\n const bucketIdx = grid[ bucketIndex[ i ] ]\n if (bucketIdx > 0) {\n const k = bucketIdx - 1\n bucketArray[ bucketOffset[ k ] + bucketFill[ k ] ] = i\n bucketFill[ k ] += 1\n }\n }\n\n this.grid = grid\n this.bucketCount = bucketCount\n this.bucketOffset = bucketOffset\n this.bucketArray = bucketArray\n\n this.xArray = xArray\n this.yArray = yArray\n this.zArray = zArray\n }\n\n within (x: number, y: number, z: number, r: number) {\n const result: number[] = []\n\n this.eachWithin(x, y, z, r, atomIndex => result.push(atomIndex))\n\n return result\n }\n\n eachWithin (x: number, y: number, z: number, r: number, callback: (atomIndex: number, dSq: number) => void) {\n const rSq = r * r\n\n const loX = Math.max(0, (x - r - this.minX) >> this.exp)\n const loY = Math.max(0, (y - r - this.minY) >> this.exp)\n const loZ = Math.max(0, (z - r - this.minZ) >> this.exp)\n\n const hiX = Math.min(this.boundX, ((x + r - this.minX) >> this.exp) + 1)\n const hiY = Math.min(this.boundY, ((y + r - this.minY) >> this.exp) + 1)\n const hiZ = Math.min(this.boundZ, ((z + r - this.minZ) >> this.exp) + 1)\n\n for (let ix = loX; ix < hiX; ++ix) {\n for (let iy = loY; iy < hiY; ++iy) {\n for (let iz = loZ; iz < hiZ; ++iz) {\n const idx = (((ix * this.boundY) + iy) * this.boundZ) + iz\n const bucketIdx = this.grid[ idx ]\n\n if (bucketIdx > 0) {\n const k = bucketIdx - 1\n const offset = this.bucketOffset[ k ]\n const count = this.bucketCount[ k ]\n const end = offset + count\n\n for (let i = offset; i < end; ++i) {\n const atomIndex = this.bucketArray[ i ]\n const dx = this.xArray[ atomIndex ] - x\n const dy = this.yArray[ atomIndex ] - y\n const dz = this.zArray[ atomIndex ] - z\n\n const dSq = dx * dx + dy * dy + dz * dz\n if (dSq <= rSq) callback(atomIndex, dSq)\n }\n }\n }\n }\n }\n }\n}","/**\n * @file Store\n * @author Alexander Rose \n * @private\n */\n\nimport { Log } from '../globals'\nimport { getTypedArray, TypedArrayString } from '../utils'\n\nexport type StoreField = [string, number, TypedArrayString]\n\n/**\n * Store base class\n * @interface\n */\nexport default class Store {\n [k: string]: any\n\n length: number\n count: number\n\n _fields: StoreField[]\n get _defaultFields(): StoreField[] { return [] }\n\n /**\n * @param {Integer} [size] - initial size\n */\n constructor (size = 0) {\n this._fields = this._defaultFields\n this._init(0)\n }\n\n /**\n * Initialize the store\n * @param {Integer} size - size to initialize\n * @return {undefined}\n */\n _init (size: number) {\n this.length = size\n this.count = 0\n\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const [name, size, type]: StoreField = this._fields[ i ]\n this._initField(name, size, type)\n }\n }\n\n /**\n * Initialize a field\n * @param {String} name - field name\n * @param {Integer} size - element size\n * @param {String} type - data type, one of int8, int16, int32,\n * uint8, uint16, uint32, float32\n * @return {undefined}\n */\n _initField (name: string, size: number, type: TypedArrayString) {\n this[ name ] = getTypedArray(type, this.length * size)\n }\n\n /**\n * Add a field\n * @param {String} name - field name\n * @param {Integer} size - element size\n * @param {String} type - data type, one of int8, int16, int32,\n * uint8, uint16, uint32, float32\n * @return {undefined}\n */\n addField (name: string, size: number, type: TypedArrayString) {\n this._fields.push([name, size, type])\n this._initField(name, size, type)\n }\n\n /**\n * Resize the store to the new size\n * @param {Integer} size - new size\n * @return {undefined}\n */\n resize (size?: number) {\n // Log.time( \"Store.resize\" );\n\n this.length = Math.round(size || 0)\n this.count = Math.min(this.count, this.length)\n\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const name = this._fields[ i ][ 0 ]\n const itemSize = this._fields[ i ][ 1 ]\n const arraySize = this.length * itemSize\n const tmpArray = new this[ name ].constructor(arraySize)\n\n if (this[ name ].length > arraySize) {\n tmpArray.set(this[ name ].subarray(0, arraySize))\n } else {\n tmpArray.set(this[ name ])\n }\n this[ name ] = tmpArray\n }\n\n // Log.timeEnd( \"Store.resize\" );\n }\n\n /**\n * Resize the store to 1.5 times its current size if full\n * @return {undefined}\n */\n growIfFull () {\n if (this.count >= this.length) {\n const size = Math.round(this.length * 1.5)\n this.resize(Math.max(256, size))\n }\n }\n\n /**\n * Copy data from one store to another\n * @param {Store} other - store to copy from\n * @param {Integer} thisOffset - offset to start copying to\n * @param {Integer} otherOffset - offset to start copying from\n * @param {Integer} length - number of entries to copy\n * @return {undefined}\n */\n copyFrom (other: Store, thisOffset: number, otherOffset: number, length: number) {\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const name = this._fields[ i ][ 0 ]\n const itemSize = this._fields[ i ][ 1 ]\n const thisField = this[ name ]\n const otherField = other[ name ]\n\n for (let j = 0; j < length; ++j) {\n const thisIndex = itemSize * (thisOffset + j)\n const otherIndex = itemSize * (otherOffset + j)\n for (let k = 0; k < itemSize; ++k) {\n thisField[ thisIndex + k ] = otherField[ otherIndex + k ]\n }\n }\n }\n }\n\n /**\n * Copy data within this store\n * @param {Integer} thisOffset - offset to start copying to\n * @param {Integer} otherOffset - offset to start copying from\n * @param {Integer} length - number of entries to copy\n * @return {undefined}\n */\n copyWithin (offsetTarget: number, offsetSource: number, length: number) {\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const name = this._fields[ i ][ 0 ]\n const itemSize = this._fields[ i ][ 1 ]\n const thisField = this[ name ]\n\n for (let j = 0; j < length; ++j) {\n const targetIndex = itemSize * (offsetTarget + j)\n const sourceIndex = itemSize * (offsetSource + j)\n for (let k = 0; k < itemSize; ++k) {\n thisField[ targetIndex + k ] = thisField[ sourceIndex + k ]\n }\n }\n }\n }\n\n /**\n * Sort entries in the store given the compare function\n * @param {[type]} compareFunction - function to sort by\n * @return {undefined}\n */\n sort (compareFunction: (a: any, b: any) => number) {\n Log.time('Store.sort')\n\n const thisStore = this\n const tmpStore = new (this.constructor as any)(1)\n\n function swap (index1: number, index2: number) {\n if (index1 === index2) return\n tmpStore.copyFrom(thisStore, 0, index1, 1)\n thisStore.copyWithin(index1, index2, 1)\n thisStore.copyFrom(tmpStore, index2, 0, 1)\n }\n\n function quicksort (left: number, right: number) {\n if (left < right) {\n let pivot = Math.floor((left + right) / 2)\n let leftNew = left\n let rightNew = right\n do {\n while (compareFunction(leftNew, pivot) < 0) {\n leftNew += 1\n }\n while (compareFunction(rightNew, pivot) > 0) {\n rightNew -= 1\n }\n if (leftNew <= rightNew) {\n if (leftNew === pivot) {\n pivot = rightNew\n } else if (rightNew === pivot) {\n pivot = leftNew\n }\n swap(leftNew, rightNew)\n leftNew += 1\n rightNew -= 1\n }\n } while (leftNew <= rightNew)\n quicksort(left, rightNew)\n quicksort(leftNew, right)\n }\n }\n\n quicksort(0, this.count - 1)\n\n Log.timeEnd('Store.sort')\n }\n\n /**\n * Empty the store\n * @return {undefined}\n */\n clear () {\n this.count = 0\n }\n\n /**\n * Dispose of the store entries and fields\n * @return {undefined}\n */\n dispose () {\n\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const name = this._fields[ i ][ 0 ]\n delete this[ name ]\n }\n }\n}\n","/**\n * @file Contact Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Bond store\n */\nexport default class ContactStore extends Store {\n index1: Uint32Array\n index2: Uint32Array\n type: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'index1', 1, 'int32' ],\n [ 'index2', 1, 'int32' ],\n [ 'type', 1, 'int8' ]\n ] as StoreField[]\n }\n\n addContact (index1: number, index2: number, type?: number) {\n this.growIfFull()\n\n const i = this.count\n\n if (index1 < index2) {\n this.index1[ i ] = index1\n this.index2[ i ] = index2\n } else {\n this.index2[ i ] = index1\n this.index1[ i ] = index2\n }\n if (type) this.type[ i ] = type\n\n this.count += 1\n }\n}","/**\n * @file Bit array\n * @author Alexander Rose \n * @author Paul Pillot \n * @private\n */\n\n/**\n * Compute the Hamming weight of a 32-bit unsigned integer\n * @param {Integer} v - a 32-bit unsigned integer\n * @return {Integer} the Hamming weight\n */\nfunction hammingWeight (v: number) {\n // works with signed or unsigned shifts\n v -= ((v >>> 1) & 0x55555555)\n v = (v & 0x33333333) + ((v >>> 2) & 0x33333333)\n return ((v + (v >>> 4) & 0xF0F0F0F) * 0x1010101) >>> 24\n}\n\n/**\n * Bit array\n *\n * Based heavily on https://github.com/lemire/FastBitSet.js\n * which is licensed under the Apache License, Version 2.0.\n */\nexport default class BitArray {\n private _words: Uint32Array\n public length: number\n\n /**\n * @param {Integer} length - array length\n * @param {Boolean} [setAll] - initialize with true\n */\n constructor (length: number, setAll?: boolean) {\n this.length = length\n this._words = new Uint32Array((length + 32) >>> 5)\n if (setAll === true) {\n this.setAll()\n }\n }\n\n /**\n * Get value at index\n * @param {Integer} index - the index\n * @return {Boolean} value\n */\n get (index: number) {\n return (this._words[ index >>> 5 ] & (1 << index)) !== 0\n }\n\n /**\n * Set value at index to true\n * @param {Integer} index - the index\n * @return {undefined}\n */\n set (index: number) {\n this._words[ index >>> 5 ] |= 1 << index\n }\n\n /**\n * Set value at index to false\n * @param {Integer} index - the index\n * @return {undefined}\n */\n clear (index: number) {\n this._words[ index >>> 5 ] &= ~(1 << index)\n }\n\n /**\n * Flip value at index\n * @param {Integer} index - the index\n * @return {undefined}\n */\n flip (index: number) {\n this._words[ index >>> 5 ] ^= 1 << index\n }\n\n _assignRange (start: number, end: number, value: boolean) {\n if (end < start) return\n const words = this._words\n const wordValue = value === true ? 0xFFFFFFFF : 0\n const wordStart = start >>> 5\n const wordEnd = end >>> 5\n // set complete words when applicable\n for (let k = wordStart + 1; k < wordEnd; ++k) {\n words[ k ] = wordValue\n }\n // set parts of the range not spanning complete words\n const startWord = wordStart << 5\n const endWord = wordEnd << 5\n if (value === true) {\n if (end - start < 32) {\n for (let i = start, n = end + 1; i < n; ++i) {\n words[ i >>> 5 ] |= 1 << i\n }\n } else {\n for (let i = start, n = startWord + 32; i < n; ++i) {\n words[ i >>> 5 ] |= 1 << i\n }\n for (let i = endWord, n = end + 1; i < n; ++i) {\n words[ i >>> 5 ] |= 1 << i\n }\n }\n } else {\n if (end - start < 32) {\n for (let i = start, n = end + 1; i < n; ++i) {\n words[ i >>> 5 ] &= ~(1 << i)\n }\n } else {\n for (let i = start, n = startWord + 32; i < n; ++i) {\n words[ i >>> 5 ] &= ~(1 << i)\n }\n for (let i = endWord, n = end + 1; i < n; ++i) {\n words[ i >>> 5 ] &= ~(1 << i)\n }\n }\n }\n return this\n }\n\n /**\n * Set bits of the given range\n * @param {Integer} start - start index\n * @param {Integer} end - end index\n * @return {BitArray} this object\n */\n setRange (start: number, end: number) {\n return this._assignRange(start, end, true)\n }\n\n /**\n * Clear bits of the given range\n * @param {Integer} start - start index\n * @param {Integer} end - end index\n * @return {BitArray} this object\n */\n clearRange (start: number, end: number) {\n return this._assignRange(start, end, false)\n }\n\n /**\n * Set bits at all given indices\n * @param {...Integer} arguments - indices\n * @return {Boolean} this object\n */\n setBits (...indices: number[]) {\n const words = this._words\n const n = indices.length\n for (let i = 0; i < n; ++i) {\n const index = indices[ i ]\n words[ index >>> 5 ] |= 1 << index\n }\n return this\n }\n\n /**\n * Clear bits at all given indices\n * @param {...Integer} arguments - indices\n * @return {Boolean} this object\n */\n clearBits (...indices: number[]) {\n const words = this._words\n const n = indices.length\n for (let i = 0; i < n; ++i) {\n const index = indices[ i ]\n words[ index >>> 5 ] &= ~(1 << index)\n }\n return this\n }\n\n /**\n * Set all bits of the array\n * @return {BitArray} this object\n */\n setAll () {\n return this._assignRange(0, this.length - 1, true)\n }\n\n /**\n * Clear all bits of the array\n * @return {BitArray} this object\n */\n clearAll () {\n return this._assignRange(0, this.length - 1, false)\n }\n\n /**\n * Flip all the values in the array\n * @return {BitArray} this object\n */\n flipAll () {\n const count = this._words.length\n const words = this._words\n const bs = 32 - this.length % 32\n for (let k = 0; k < count - 1; ++k) {\n words[k] = ~words[ k ]\n }\n words[ count - 1 ] = (~(words[ count - 1 ] << bs)) >>> bs\n return this\n }\n\n _isRangeValue (start: number, end: number, value: boolean) {\n if (end < start) return\n const words = this._words\n const wordValue = value === true ? 0xFFFFFFFF : 0\n const wordStart = start >>> 5\n const wordEnd = end >>> 5\n // set complete words when applicable\n for (let k = wordStart + 1; k < wordEnd; ++k) {\n if (words[ k ] !== wordValue) return false\n }\n // set parts of the range not spanning complete words\n if (end - start < 32) {\n for (let i = start, n = end + 1; i < n; ++i) {\n if (!!(words[ i >>> 5 ] & (1 << i)) !== value) return false\n }\n } else {\n const startWord = wordStart << 5\n const endWord = wordEnd << 5\n for (let i = start, n = startWord + 32; i < n; ++i) {\n if (!!(words[ i >>> 5 ] & (1 << i)) !== value) return false\n }\n for (let i = endWord, n = end + 1; i < n; ++i) {\n if (!!(words[ i >>> 5 ] & (1 << i)) !== value) return false\n }\n }\n return true\n }\n\n /**\n * Test if bits in given range are set\n * @param {Integer} start - start index\n * @param {Integer} end - end index\n * @return {BitArray} this object\n */\n isRangeSet (start: number, end: number) {\n return this._isRangeValue(start, end, true)\n }\n\n /**\n * Test if bits in given range are clear\n * @param {Integer} start - start index\n * @param {Integer} end - end index\n * @return {BitArray} this object\n */\n isRangeClear (start: number, end: number) {\n return this._isRangeValue(start, end, false)\n }\n\n /**\n * Test if all bits in the array are set\n * @return {Boolean} test result\n */\n isAllSet () {\n return this._isRangeValue(0, this.length - 1, true)\n }\n\n /**\n * Test if all bits in the array are clear\n * @return {Boolean} test result\n */\n isAllClear () {\n return this._isRangeValue(0, this.length - 1, false)\n }\n\n /**\n * Test if bits at all given indices are set\n * @param {...Integer} arguments - indices\n * @return {Boolean} test result\n */\n isSet (...indices: number[]) {\n const words = this._words\n const n = indices.length\n for (let i = 0; i < n; ++i) {\n const index = indices[ i ]\n if ((words[ index >>> 5 ] & (1 << index)) === 0) return false\n }\n return true\n }\n\n /**\n * Test if bits at all given indices are clear\n * @param {...Integer} arguments - indices\n * @return {Boolean} test result\n */\n isClear (...indices: number[]) {\n const words = this._words\n const n = indices.length\n for (let i = 0; i < n; ++i) {\n const index = indices[ i ]\n if ((words[ index >>> 5 ] & (1 << index)) !== 0) return false\n }\n return true\n }\n\n /**\n * Test if two BitArrays are identical in all their values\n * @param {BitArray} otherBitarray - the other BitArray\n * @return {Boolean} test result\n */\n isEqualTo (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n if (words1[ k ] !== words2[ k ]) {\n return false\n }\n }\n return true\n }\n\n /**\n * How many set bits?\n * @return {Integer} number of set bits\n */\n getSize () {\n const count = this._words.length\n const words = this._words\n let size = 0\n for (let i = 0; i < count; ++i) {\n size += hammingWeight(words[ i ])\n }\n return size\n }\n\n /**\n * Calculate difference betwen this and another bit array.\n * Store result in this object.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {BitArray} this object\n */\n difference (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n words1[ k ] = words1[ k ] & ~words2[ k ]\n }\n for (let k = words1.length; k < count; ++k) {\n words1[ k ] = 0\n }\n return this\n }\n\n /**\n * Calculate union betwen this and another bit array.\n * Store result in this object.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {BitArray} this object\n */\n union (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n words1[ k ] |= words2[ k ]\n }\n for (let k = words1.length; k < count; ++k) {\n words1[ k ] = 0\n }\n return this\n }\n\n /**\n * Calculate intersection betwen this and another bit array.\n * Store result in this object.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {BitArray} this object\n */\n intersection (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n words1[ k ] &= words2[ k ]\n }\n for (let k = words1.length; k < count; ++k) {\n words1[ k ] = 0\n }\n return this\n }\n\n /**\n * Test if there is any intersection betwen this and another bit array.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {Boolean} test result\n */\n intersects (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n if ((words1[ k ] & words2[ k ]) !== 0) {\n return true\n }\n }\n return false\n }\n\n /**\n * Calculate the number of bits in common betwen this and another bit array.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {Integer} size\n */\n getIntersectionSize (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n let size = 0\n for (let k = 0; k < count; ++k) {\n size += hammingWeight(words1[ k ] & words2[ k ])\n }\n return size\n }\n\n /**\n * Calculate intersection betwen this and another bit array.\n * Store result in a new bit array.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {BitArray} the new bit array\n */\n makeIntersection (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n const wordsA = new Uint32Array(count)\n const intersection = Object.create(BitArray.prototype)\n intersection._words = wordsA\n intersection.length = Math.min(this.length, otherBitarray.length)\n for (let k = 0; k < count; ++k) {\n wordsA[ k ] = words1[ k ] & words2[ k ]\n }\n return intersection\n }\n\n /**\n * Iterate over all set bits in the array\n * @param {function( index: Integer, i: Integer )} callback - the callback\n * @return {undefined}\n */\n forEach (callback: (index: number, i: number) => any) {\n const count = this._words.length\n const words = this._words\n let i = 0\n for (let k = 0; k < count; ++k) {\n let w = words[ k ]\n while (w !== 0) {\n const t = w & -w\n const index = (k << 5) + hammingWeight(t - 1)\n callback(index, i)\n w ^= t\n ++i\n }\n }\n }\n\n /**\n * Get an array with the set bits\n * @return {Array} bit indices\n */\n toArray () {\n const words = this._words\n const answer = new Array(this.getSize())\n const count = this._words.length\n let pos = 0\n for (let k = 0; k < count; ++k) {\n let w = words[ k ]\n while (w !== 0) {\n const t = w & -w\n answer[ pos++ ] = (k << 5) + hammingWeight(t - 1)\n w ^= t\n }\n }\n return answer\n }\n\n toString () {\n return '{' + this.toArray().join(',') + '}'\n }\n\n toSeleString () {\n const sele = this.toArray().join(',')\n return sele ? '@' + sele : 'NONE'\n }\n\n /**\n * Clone this object\n * @return {BitArray} the cloned object\n */\n clone () {\n const clone = Object.create(BitArray.prototype)\n clone.length = this.length\n clone._words = new Uint32Array(this._words)\n return clone\n }\n}","/**\n * @file Adjacency List\n * @author Alexander Rose \n * @private\n */\n\nexport interface Edges {\n nodeArray1: ArrayLike\n nodeArray2: ArrayLike\n edgeCount: number\n nodeCount: number\n}\n\nexport interface AdjacencyList {\n /* number of edges for each node */\n countArray: Uint8Array\n /* offset into indexArray for each node */\n offsetArray: Int32Array\n /* edge indices, grouped by nodes */\n indexArray: Int32Array\n}\n\nexport function createAdjacencyList (edges: Edges): AdjacencyList {\n const { edgeCount, nodeCount, nodeArray1, nodeArray2 } = edges\n\n const countArray = new Uint8Array(nodeCount)\n const offsetArray = new Int32Array(nodeCount)\n\n // count edges per node\n for (let i = 0; i < edgeCount; ++i) {\n countArray[ nodeArray1[ i ] ] += 1\n countArray[ nodeArray2[ i ] ] += 1\n }\n\n // get offsets to node edges\n for (let i = 1; i < nodeCount; ++i) {\n offsetArray[ i ] += offsetArray[ i - 1 ] + countArray[ i - 1 ]\n }\n\n // prepare index array\n const bondCount2 = edgeCount * 2\n const indexArray = new Int32Array(bondCount2)\n for (let j = 0; j < bondCount2; ++j) {\n indexArray[ j ] = -1\n }\n\n // build index array\n for (let i = 0; i < edgeCount; ++i) {\n const idx1 = nodeArray1[ i ]\n const idx2 = nodeArray2[ i ]\n let j1 = offsetArray[ idx1 ]\n while (indexArray[ j1 ] !== -1 && j1 < bondCount2) {\n j1 += 1\n }\n indexArray[ j1 ] = i\n let j2 = offsetArray[ idx2 ]\n while (indexArray[ j2 ] !== -1 && j2 < bondCount2) {\n j2 += 1\n }\n indexArray[ j2 ] = i\n }\n\n return { countArray, offsetArray, indexArray }\n}\n","/**\n * @file Features\n * @author Alexander Rose \n */\n\nimport AtomProxy from '../../proxy/atom-proxy'\n\nexport interface Features {\n types: FeatureType[]\n groups: FeatureGroup[]\n centers: { x: number[], y: number[], z: number[] }\n atomSets: number[][]\n}\n\nexport const enum FeatureType {\n Unknown = 0,\n PositiveCharge = 1,\n NegativeCharge = 2,\n AromaticRing = 3,\n HydrogenDonor = 4,\n HydrogenAcceptor = 5,\n HalogenDonor = 6,\n HalogenAcceptor = 7,\n Hydrophobic = 8,\n WeakHydrogenDonor = 9,\n IonicTypePartner = 10,\n DativeBondPartner = 11,\n TransitionMetal = 12,\n IonicTypeMetal = 13\n}\n\nexport const enum FeatureGroup {\n Unknown = 0,\n QuaternaryAmine = 1,\n TertiaryAmine = 2,\n Sulfonium = 3,\n SulfonicAcid = 4,\n Sulfate = 5,\n Phosphate = 6,\n Halocarbon = 7,\n Guanidine = 8,\n Acetamidine = 9,\n Carboxylate = 10\n}\n\nexport function createFeatures (): Features {\n return {\n types: [],\n groups: [],\n centers: { x: [], y: [], z: [] },\n atomSets: []\n }\n}\n\nexport interface FeatureState {\n type: FeatureType\n group: FeatureGroup\n x: number\n y: number\n z: number\n atomSet: number[]\n}\n\nexport function createFeatureState(type = FeatureType.Unknown, group = FeatureGroup.Unknown): FeatureState {\n return { type, group, x: 0, y: 0, z: 0, atomSet: [] }\n}\n\nexport function addAtom (state: FeatureState, atom: AtomProxy) {\n state.x += atom.x\n state.y += atom.y\n state.z += atom.z\n state.atomSet.push(atom.index)\n}\n\nexport function addFeature (features: Features, state: FeatureState) {\n const n = state.atomSet.length\n if (n > 0) {\n const { types, groups, centers, atomSets } = features\n types.push(state.type)\n groups.push(state.group)\n centers.x.push(state.x / n)\n centers.y.push(state.y / n)\n centers.z.push(state.z / n)\n atomSets.push(state.atomSet)\n }\n}\n","/**\n * @file Structure Constants\n * @author Alexander Rose \n * @private\n */\n\n// entity types\nexport const UnknownEntity = 0\nexport const PolymerEntity = 1\nexport const NonPolymerEntity = 2\nexport const MacrolideEntity = 3\nexport const WaterEntity = 4\n\n// molecule types\nexport const UnknownType = 0\nexport const WaterType = 1\nexport const IonType = 2\nexport const ProteinType = 3\nexport const RnaType = 4\nexport const DnaType = 5\nexport const SaccharideType = 6\n\n// backbone types\nexport const UnknownBackboneType = 0\nexport const ProteinBackboneType = 1\nexport const RnaBackboneType = 2\nexport const DnaBackboneType = 3\nexport const CgProteinBackboneType = 4\nexport const CgRnaBackboneType = 5\nexport const CgDnaBackboneType = 6\n\n// chemical component types\nexport const ChemCompProtein = [\n 'D-BETA-PEPTIDE, C-GAMMA LINKING', 'D-GAMMA-PEPTIDE, C-DELTA LINKING',\n 'D-PEPTIDE COOH CARBOXY TERMINUS', 'D-PEPTIDE NH3 AMINO TERMINUS', 'D-PEPTIDE LINKING',\n 'L-BETA-PEPTIDE, C-GAMMA LINKING', 'L-GAMMA-PEPTIDE, C-DELTA LINKING',\n 'L-PEPTIDE COOH CARBOXY TERMINUS', 'L-PEPTIDE NH3 AMINO TERMINUS', 'L-PEPTIDE LINKING',\n 'PEPTIDE LINKING', 'PEPTIDE-LIKE'\n]\nexport const ChemCompRna = [\n 'RNA OH 3 PRIME TERMINUS', 'RNA OH 5 PRIME TERMINUS', 'RNA LINKING'\n]\nexport const ChemCompDna = [\n 'DNA OH 3 PRIME TERMINUS', 'DNA OH 5 PRIME TERMINUS', 'DNA LINKING',\n 'L-DNA LINKING', 'L-RNA LINKING'\n]\nexport const ChemCompSaccharide = [\n 'D-SACCHARIDE', 'D-SACCHARIDE 1,4 AND 1,4 LINKING', 'D-SACCHARIDE 1,4 AND 1,6 LINKING',\n 'L-SACCHARIDE', 'L-SACCHARIDE 1,4 AND 1,4 LINKING', 'L-SACCHARIDE 1,4 AND 1,6 LINKING',\n 'SACCHARIDE'\n]\nexport const ChemCompOther = [\n 'OTHER'\n]\nexport const ChemCompNonPolymer = [\n 'NON-POLYMER'\n]\nexport const ChemCompHetero = ChemCompNonPolymer.concat(ChemCompOther, ChemCompSaccharide)\n\n// secondary structure\nexport const SecStrucHelix = [ 'h', 'g', 'i' ]\nexport const SecStrucSheet = [ 'e', 'b' ]\nexport const SecStrucTurn = [ 's', 't', 'l', '' ]\n\nexport const AtomicNumbers: { [e: string]: number | undefined } = {\n 'H': 1, 'D': 1, 'T': 1, 'HE': 2, 'LI': 3, 'BE': 4, 'B': 5, 'C': 6, 'N': 7, 'O': 8, 'F': 9, 'NE': 10, 'NA': 11, 'MG': 12, 'AL': 13, 'SI': 14, 'P': 15, 'S': 16, 'CL': 17, 'AR': 18, 'K': 19, 'CA': 20, 'SC': 21, 'TI': 22, 'V': 23, 'CR': 24, 'MN': 25, 'FE': 26, 'CO': 27, 'NI': 28, 'CU': 29, 'ZN': 30, 'GA': 31, 'GE': 32, 'AS': 33, 'SE': 34, 'BR': 35, 'KR': 36, 'RB': 37, 'SR': 38, 'Y': 39, 'ZR': 40, 'NB': 41, 'MO': 42, 'TC': 43, 'RU': 44, 'RH': 45, 'PD': 46, 'AG': 47, 'CD': 48, 'IN': 49, 'SN': 50, 'SB': 51, 'TE': 52, 'I': 53, 'XE': 54, 'CS': 55, 'BA': 56, 'LA': 57, 'CE': 58, 'PR': 59, 'ND': 60, 'PM': 61, 'SM': 62, 'EU': 63, 'GD': 64, 'TB': 65, 'DY': 66, 'HO': 67, 'ER': 68, 'TM': 69, 'YB': 70, 'LU': 71, 'HF': 72, 'TA': 73, 'W': 74, 'RE': 75, 'OS': 76, 'IR': 77, 'PT': 78, 'AU': 79, 'HG': 80, 'TL': 81, 'PB': 82, 'BI': 83, 'PO': 84, 'AT': 85, 'RN': 86, 'FR': 87, 'RA': 88, 'AC': 89, 'TH': 90, 'PA': 91, 'U': 92, 'NP': 93, 'PU': 94, 'AM': 95, 'CM': 96, 'BK': 97, 'CF': 98, 'ES': 99, 'FM': 100, 'MD': 101, 'NO': 102, 'LR': 103, 'RF': 104, 'DB': 105, 'SG': 106, 'BH': 107, 'HS': 108, 'MT': 109, 'DS': 110, 'RG': 111, 'CN': 112, 'NH': 113, 'FL': 114, 'MC': 115, 'LV': 116, 'TS': 117, 'OG': 118\n}\nexport const DefaultAtomicNumber = 0\n\n/**\n * Enum mapping element to atomic number\n */\nexport const enum Elements {\n H = 1, D = 1, T = 1, HE = 2, LI = 3, BE = 4, B = 5, C = 6, N = 7, O = 8, F = 9, NE = 10, NA = 11, MG = 12, AL = 13, SI = 14, P = 15, S = 16, CL = 17, AR = 18, K = 19, CA = 20, SC = 21, TI = 22, V = 23, CR = 24, MN = 25, FE = 26, CO = 27, NI = 28, CU = 29, ZN = 30, GA = 31, GE = 32, AS = 33, SE = 34, BR = 35, KR = 36, RB = 37, SR = 38, Y = 39, ZR = 40, NB = 41, MO = 42, TC = 43, RU = 44, RH = 45, PD = 46, AG = 47, CD = 48, IN = 49, SN = 50, SB = 51, TE = 52, I = 53, XE = 54, CS = 55, BA = 56, LA = 57, CE = 58, PR = 59, ND = 60, PM = 61, SM = 62, EU = 63, GD = 64, TB = 65, DY = 66, HO = 67, ER = 68, TM = 69, YB = 70, LU = 71, HF = 72, TA = 73, W = 74, RE = 75, OS = 76, IR = 77, PT = 78, AU = 79, HG = 80, TL = 81, PB = 82, BI = 83, PO = 84, AT = 85, RN = 86, FR = 87, RA = 88, AC = 89, TH = 90, PA = 91, U = 92, NP = 93, PU = 94, AM = 95, CM = 96, BK = 97, CF = 98, ES = 99, FM = 100, MD = 101, NO = 102, LR = 103, RF = 104, DB = 105, SG = 106, BH = 107, HS = 108, MT = 109, DS = 110, RG = 111, CN = 112, NH = 113, FL = 114, MC = 115, LV = 116, TS = 117, OG = 118\n}\n\n// https://doi.org/10.1515/pac-2015-0305 (table 2, 3, and 4)\nexport const AtomWeights: { [e: number]: number | undefined } = {\n 1: 1.008, 2: 4.0026, 3: 6.94, 4: 9.0122, 5: 10.81, 6: 10.81, 7: 14.007, 8: 15.999, 9: 18.998, 10: 20.180, 11: 22.990, 12: 24.305, 13: 26.982, 14: 28.085, 15: 30.974, 16: 32.06, 17: 35.45, 18: 39.948, 19: 39.098, 20: 40.078, 21: 44.956, 22: 47.867, 23: 50.942, 24: 51.996, 25: 54.938, 26: 55.845, 27: 58.933, 28: 58.693, 29: 63.546, 30: 65.38, 31: 69.723, 32: 72.630, 33: 74.922, 34: 78.971, 35: 79.904, 36: 83.798, 37: 85.468, 38: 87.62, 39: 88.906, 40: 91.224, 41: 92.906, 42: 95.95, 43: 96.906, 44: 101.07, 45: 102.91, 46: 106.42, 47: 107.87, 48: 112.41, 49: 114.82, 50: 118.71, 51: 121.76, 52: 127.60, 53: 127.60, 54: 131.29, 55: 132.91, 56: 137.33, 57: 138.91, 58: 140.12, 59: 140.91, 60: 144.24, 61: 144.912, 62: 150.36, 63: 151.96, 64: 157.25, 65: 158.93, 66: 162.50, 67: 164.93, 68: 167.26, 69: 168.93, 70: 173.05, 71: 174.97, 72: 178.49, 73: 180.95, 74: 183.84, 75: 186.21, 76: 190.23, 77: 192.22, 78: 195.08, 79: 196.97, 80: 200.59, 81: 204.38, 82: 207.2, 83: 208.98, 84: 1.97, 85: 2.02, 86: 2.2, 87: 3.48, 88: 2.83, 89: 2.0, 90: 232.04, 91: 231.04, 92: 238.03, 93: 237.048, 94: 244.064, 95: 243.061, 96: 247.070, 97: 247.070, 98: 251.079, 99: 252.083, 100: 257.095, 101: 258.098, 102: 259.101, 103: 262.110, 104: 267.122, 105: 270.131, 106: 271.134, 107: 270.133, 108: 270.134, 109: 278.156, 110: 281.165, 111: 281.166, 112: 285.177, 113: 286.182, 114: 289.190, 115: 289.194, 116: 293.204, 117: 293.208, 118: 294.214\n}\nexport const DefaultAtomWeight = 10.81 // C\n\n// http://dx.doi.org/10.1021/jp8111556 (or 2.0)\nexport const VdwRadii: { [e: number]: number | undefined } = {\n 1: 1.1, 2: 1.4, 3: 1.81, 4: 1.53, 5: 1.92, 6: 1.7, 7: 1.55, 8: 1.52, 9: 1.47, 10: 1.54, 11: 2.27, 12: 1.73, 13: 1.84, 14: 2.1, 15: 1.8, 16: 1.8, 17: 1.75, 18: 1.88, 19: 2.75, 20: 2.31, 21: 2.3, 22: 2.15, 23: 2.05, 24: 2.05, 25: 2.05, 26: 2.05, 27: 2.0, 28: 2.0, 29: 2.0, 30: 2.1, 31: 1.87, 32: 2.11, 33: 1.85, 34: 1.9, 35: 1.83, 36: 2.02, 37: 3.03, 38: 2.49, 39: 2.4, 40: 2.3, 41: 2.15, 42: 2.1, 43: 2.05, 44: 2.05, 45: 2.0, 46: 2.05, 47: 2.1, 48: 2.2, 49: 2.2, 50: 1.93, 51: 2.17, 52: 2.06, 53: 1.98, 54: 2.16, 55: 3.43, 56: 2.68, 57: 2.5, 58: 2.48, 59: 2.47, 60: 2.45, 61: 2.43, 62: 2.42, 63: 2.4, 64: 2.38, 65: 2.37, 66: 2.35, 67: 2.33, 68: 2.32, 69: 2.3, 70: 2.28, 71: 2.27, 72: 2.25, 73: 2.2, 74: 2.1, 75: 2.05, 76: 2.0, 77: 2.0, 78: 2.05, 79: 2.1, 80: 2.05, 81: 1.96, 82: 2.02, 83: 2.07, 84: 1.97, 85: 2.02, 86: 2.2, 87: 3.48, 88: 2.83, 89: 2.0, 90: 2.4, 91: 2.0, 92: 2.3, 93: 2.0, 94: 2.0, 95: 2.0, 96: 2.0, 97: 2.0, 98: 2.0, 99: 2.0, 100: 2.0, 101: 2.0, 102: 2.0, 103: 2.0, 104: 2.0, 105: 2.0, 106: 2.0, 107: 2.0, 108: 2.0, 109: 2.0, 110: 2.0, 111: 2.0, 112: 2.0, 113: 2.0, 114: 2.0, 115: 2.0, 116: 2.0, 117: 2.0, 118: 2.0\n}\nexport const DefaultVdwRadius = 2.0 // C\n\n// Peter Rose (peter.rose@rcsb.org), private communication, average accross PDB\nexport const ResidueRadii: { [k: string]: number } = {\n '2QY': 6.58,\n 'CY0': 11.98,\n '2QZ': 2.52,\n 'CY1': 6.59,\n 'HHK': 5.11,\n 'CXM': 4.69,\n 'HHI': 4.58,\n 'CY4': 4.57,\n 'S12': 18.57,\n 'CY3': 2.79,\n 'C5C': 5.35,\n 'PFX': 11.84,\n '2R3': 6.94,\n '2R1': 3.78,\n 'ILX': 4.99,\n '32S': 5.68,\n 'BTK': 8.59,\n '32T': 5.72,\n 'FAK': 9.8,\n 'B27': 2.78,\n 'ILM': 3.84,\n 'C4R': 5.63,\n '32L': 6.75,\n 'SYS': 3.01,\n '1MH': 5.04,\n 'ILE': 3.65,\n 'YNM': 6.39,\n '2RX': 4.91,\n 'B3A': 2.48,\n 'GEE': 4.76,\n '7MN': 7.34,\n 'B3E': 5.4,\n 'ARG': 6.33,\n '200': 6.89,\n 'HIP': 5.47,\n 'HIA': 4.64,\n 'B3K': 5.89,\n 'HIC': 5.76,\n 'B3L': 4.96,\n 'B3M': 5.07,\n 'ARM': 6.86,\n 'ARO': 7.35,\n 'AR4': 8.42,\n 'PG1': 10.67,\n 'YOF': 6.44,\n 'IML': 3.74,\n 'SXE': 6.65,\n 'HIQ': 7.98,\n 'PFF': 6.31,\n 'HIS': 4.52,\n '0TD': 3.62,\n 'C3Y': 5.24,\n '1OP': 11.55,\n '02Y': 4.77,\n '02V': 4.83,\n 'ASB': 5.59,\n '30V': 8.53,\n 'S2P': 4.81,\n 'ASP': 3.55,\n 'ASN': 3.54,\n '2OR': 6.91,\n 'QMM': 6.13,\n '2P0': 8.52,\n 'ASL': 5.36,\n 'HFA': 5.14,\n '5PG': 5.69,\n 'B3X': 4.38,\n 'AS9': 4.1,\n 'ARV': 7.59,\n 'B3U': 6.06,\n 'S2C': 7.54,\n 'B3T': 3.34,\n '175': 5.64,\n 'GFT': 8.18,\n 'HG7': 6.8,\n 'B3Q': 4.48,\n 'ASA': 3.64,\n '02K': 2.94,\n 'B3Y': 7.45,\n 'PHD': 5.35,\n 'C6C': 6.42,\n 'BUC': 5.8,\n 'HGL': 8.07,\n 'PHE': 5.06,\n '03Y': 2.6,\n 'PHA': 5.11,\n 'OCY': 5.0,\n '4PH': 6.79,\n '5OH': 4.7,\n '31Q': 10.46,\n 'BTR': 7.98,\n '3PX': 4.7,\n '1PA': 8.07,\n 'ASX': 3.54,\n 'IOR': 7.23,\n '03E': 3.38,\n 'PHL': 5.17,\n 'KWS': 5.09,\n 'PHI': 7.12,\n 'NAL': 7.22,\n 'S1H': 19.21,\n '2ML': 3.86,\n '2MR': 7.35,\n 'GHG': 4.83,\n 'TYY': 6.54,\n '2MT': 3.67,\n '56A': 13.01,\n 'SVA': 5.46,\n 'TYX': 8.31,\n 'TYS': 8.59,\n 'TYR': 6.38,\n 'TYQ': 6.43,\n 'HLU': 3.99,\n 'MYK': 19.47,\n 'TYO': 7.71,\n 'HLX': 4.98,\n 'TYN': 9.87,\n 'TYJ': 6.25,\n 'TYI': 6.49,\n 'LYH': 5.13,\n 'LYF': 12.19,\n 'SUN': 6.73,\n 'LYR': 18.28,\n 'TYB': 6.46,\n '11W': 14.39,\n 'LYS': 5.54,\n 'LYN': 4.8,\n '11Q': 4.85,\n 'LYO': 4.71,\n 'LYZ': 1.76,\n 'TXY': 6.44,\n 'MYN': 4.71,\n 'TY5': 10.6,\n 'HMR': 5.09,\n '01W': 8.55,\n 'LYX': 13.36,\n 'TY8': 7.22,\n 'TY2': 6.49,\n 'KYN': 6.18,\n 'KYQ': 9.75,\n 'CZZ': 5.14,\n 'IIL': 3.81,\n 'HNC': 10.41,\n 'OIC': 4.62,\n 'LVN': 2.89,\n 'QIL': 3.84,\n 'JJL': 8.3,\n 'VAH': 3.88,\n 'JJJ': 7.5,\n 'JJK': 7.43,\n 'VAD': 2.56,\n 'CYW': 4.65,\n '0QL': 5.72,\n '143': 8.22,\n 'SVX': 7.04,\n 'CYJ': 11.64,\n 'SVY': 7.1,\n 'SVZ': 6.6,\n 'CYG': 8.03,\n 'CYF': 13.54,\n 'SVV': 5.09,\n 'GL3': 2.72,\n '8SP': 14.26,\n 'CYS': 2.78,\n '004': 4.33,\n 'CYR': 10.33,\n 'PLJ': 3.71,\n 'EXY': 7.37,\n 'HL2': 3.75,\n 'A5N': 5.21,\n 'CYQ': 5.67,\n 'CZ2': 5.16,\n 'LWY': 4.12,\n 'PM3': 8.78,\n 'OHS': 6.98,\n 'OHI': 5.35,\n '3TY': 8.42,\n 'CYD': 8.55,\n 'DYS': 7.87,\n 'DAH': 6.47,\n '4IK': 11.81,\n '3EG': 3.66,\n 'AYA': 3.65,\n '4IN': 6.31,\n 'DAB': 3.48,\n '4HT': 6.03,\n 'RGL': 7.03,\n 'DAM': 2.49,\n 'NFA': 5.04,\n 'WFP': 6.07,\n '2JC': 2.97,\n 'HAR': 7.55,\n '2JG': 5.67,\n 'MH6': 1.72,\n '2JF': 9.13,\n '3FG': 4.96,\n 'MGN': 4.84,\n 'AZH': 5.36,\n 'AZK': 6.03,\n 'ZBZ': 7.79,\n 'TBG': 2.58,\n 'VAL': 2.51,\n 'MGG': 7.34,\n 'AZS': 5.61,\n 'FHL': 9.75,\n '2JH': 4.56,\n 'IEL': 7.07,\n 'FHO': 6.75,\n 'DA2': 7.79,\n 'FH7': 6.99,\n 'ME0': 4.52,\n '3GL': 4.84,\n 'MDO': 5.03,\n 'AZY': 7.37,\n 'A8E': 3.76,\n 'ZCL': 6.71,\n 'MDH': 2.58,\n 'LA2': 14.07,\n '4FW': 6.1,\n 'YCM': 5.32,\n 'MDF': 4.95,\n 'YCP': 3.01,\n 'TEF': 8.63,\n 'FGP': 4.34,\n 'UF0': 19.72,\n 'XCN': 4.57,\n 'FGL': 2.56,\n 'MF3': 6.37,\n 'MEQ': 5.13,\n 'LAA': 3.23,\n 'IGL': 5.52,\n 'MET': 4.49,\n 'NIY': 6.81,\n 'QCS': 5.18,\n 'TCQ': 8.56,\n 'MEN': 4.33,\n '4HL': 8.79,\n 'MEA': 4.95,\n 'EFC': 5.28,\n 'LAL': 2.41,\n '2HF': 5.52,\n 'KBE': 5.64,\n 'OCS': 3.94,\n 'CAF': 5.46,\n 'NC1': 11.4,\n 'NBQ': 9.82,\n 'CAB': 4.19,\n 'MBQ': 9.55,\n '193': 7.38,\n '192': 2.44,\n '0WZ': 7.61,\n 'CAS': 5.35,\n 'NB8': 11.98,\n 'OBS': 11.71,\n '1AC': 2.42,\n 'PCA': 3.48,\n 'MCL': 9.73,\n 'LBY': 7.75,\n 'GAU': 4.67,\n 'PBF': 9.75,\n 'MCG': 6.46,\n 'DDE': 6.86,\n '19W': 3.94,\n 'MD5': 9.33,\n 'MD6': 6.44,\n 'MD3': 8.41,\n 'MCS': 7.56,\n 'OBF': 3.64,\n 'UAL': 4.68,\n 'PAT': 6.05,\n 'IAM': 8.88,\n 'PAQ': 8.77,\n 'FDL': 9.49,\n 'NCB': 3.45,\n 'LCK': 9.81,\n 'DDZ': 2.52,\n '2FM': 5.54,\n 'IAR': 6.77,\n 'OAS': 4.8,\n 'HBN': 8.8,\n 'TA4': 5.55,\n '1C3': 7.43,\n 'ECX': 5.51,\n 'PF5': 6.28,\n 'RE3': 5.29,\n 'FCL': 6.25,\n 'ECC': 4.79,\n 'LDH': 7.06,\n 'NCY': 2.91,\n 'CCS': 4.58,\n 'PEC': 6.54,\n '2CO': 4.45,\n 'LE1': 2.72,\n 'HCM': 5.53,\n '07O': 8.05,\n 'HCL': 4.96,\n 'NEP': 6.94,\n 'PE1': 8.01,\n 'LEF': 4.37,\n 'FC0': 5.18,\n 'LED': 4.34,\n 'HCS': 4.09,\n 'DBU': 2.49,\n 'RE0': 5.53,\n 'LEN': 3.82,\n '1E3': 8.71,\n 'BB9': 2.56,\n 'BB8': 5.14,\n 'PCS': 5.05,\n 'BB7': 4.56,\n 'BB6': 2.62,\n 'LEU': 3.83,\n 'DBZ': 7.08,\n 'LET': 11.29,\n 'DBY': 6.46,\n 'ICY': 7.76,\n 'MAA': 2.4,\n 'CGA': 7.91,\n '5CS': 8.34,\n 'UGY': 3.7,\n 'LGY': 11.71,\n 'N10': 8.96,\n 'AAR': 6.39,\n 'FT6': 7.5,\n 'MOD': 12.62,\n '5CW': 7.21,\n 'PVH': 4.58,\n 'BBC': 6.42,\n 'YYA': 7.3,\n 'O12': 14.08,\n 'NOT': 7.15,\n 'KGC': 9.88,\n 'MP4': 5.86,\n '0CS': 4.07,\n 'MP8': 3.75,\n 'VLL': 2.54,\n 'VLM': 2.51,\n 'BCS': 8.03,\n 'MNL': 4.9,\n 'AA4': 4.47,\n 'SAC': 3.49,\n 'BCX': 2.99,\n '3CF': 6.47,\n 'SAH': 11.7,\n 'NNH': 6.86,\n 'CGU': 4.71,\n 'SIB': 12.41,\n 'TLY': 8.78,\n 'SIC': 4.81,\n 'VMS': 8.82,\n 'TMD': 6.76,\n 'MMO': 6.53,\n 'PXU': 2.46,\n '4AW': 6.22,\n 'OTH': 3.6,\n 'DLS': 6.84,\n 'MME': 4.99,\n 'DM0': 6.99,\n '0FL': 2.76,\n 'SBL': 8.96,\n 'CDV': 3.72,\n 'OTY': 6.51,\n 'PYA': 7.75,\n '2AS': 3.57,\n 'DMH': 4.92,\n 'ELY': 7.42,\n 'GVL': 9.6,\n 'FVA': 2.9,\n 'SAR': 2.48,\n '4BF': 6.92,\n 'EME': 4.69,\n 'CDE': 2.51,\n '3AR': 7.86,\n '3AH': 9.11,\n 'AC5': 2.44,\n 'FTR': 6.08,\n 'MLL': 3.76,\n 'NPH': 11.66,\n 'NPI': 6.9,\n 'DMT': 6.67,\n 'PYX': 11.3,\n 'MLE': 3.87,\n 'PYL': 9.67,\n 'ZZU': 6.94,\n 'H5M': 3.61,\n 'SCH': 4.46,\n 'DMK': 3.52,\n 'FTY': 9.07,\n '2AG': 3.7,\n 'ABA': 2.55,\n 'ZZJ': 2.44,\n 'MLZ': 6.8,\n 'MLY': 6.88,\n 'KCX': 7.28,\n 'ZZD': 8.16,\n '3A5': 5.37,\n 'LHC': 7.75,\n '9AT': 2.47,\n 'OZT': 3.4,\n 'THO': 2.62,\n 'THR': 2.5,\n 'DFI': 3.93,\n 'MKD': 6.42,\n '4CY': 4.6,\n 'SDP': 6.07,\n 'DFO': 3.94,\n '0A0': 3.45,\n '4DB': 9.73,\n 'ML3': 6.26,\n 'BG1': 8.02,\n 'SD4': 4.57,\n 'THC': 3.8,\n 'SCS': 5.48,\n 'TH5': 4.65,\n 'BFD': 5.33,\n 'AEI': 6.34,\n 'TH6': 2.85,\n 'SCY': 4.53,\n 'TIS': 4.81,\n 'SEE': 4.53,\n 'BHD': 3.48,\n 'SEB': 8.18,\n 'SEC': 2.96,\n 'SEP': 4.8,\n 'CLH': 7.13,\n 'TIH': 5.02,\n 'CLG': 13.62,\n 'SEN': 6.43,\n 'XXA': 7.34,\n 'SEL': 2.46,\n 'SE7': 4.19,\n '4CF': 7.72,\n 'G8M': 3.57,\n 'BH2': 3.51,\n 'UN2': 3.22,\n 'VR0': 10.51,\n 'MK8': 4.76,\n 'DHA': 2.32,\n 'LMQ': 4.69,\n 'SFE': 5.01,\n 'AHB': 3.47,\n 'OXX': 7.05,\n 'BIF': 9.63,\n 'IZO': 4.47,\n 'NMM': 8.25,\n '0BN': 7.0,\n 'HZP': 3.12,\n 'NMC': 4.23,\n 'DHL': 2.69,\n '9DS': 9.29,\n 'SER': 2.41,\n 'CHG': 4.2,\n 'MIR': 6.54,\n 'AGQ': 7.79,\n 'SET': 2.46,\n 'MIS': 6.32,\n '4FB': 3.08,\n '0AR': 8.46,\n 'LME': 3.99,\n 'FZN': 24.42,\n 'AGT': 9.04,\n 'IYR': 6.46,\n '9DN': 9.31,\n 'CHP': 5.75,\n 'UNK': 1.64,\n 'XX1': 9.92,\n 'AGM': 6.57,\n '0AH': 5.78,\n 'LLP': 10.22,\n '0AF': 6.72,\n '4DP': 9.28,\n 'HYP': 2.25,\n 'DIR': 5.8,\n 'LLY': 8.71,\n '0AK': 6.11,\n 'NLE': 4.67,\n 'OYL': 6.42,\n 'WVL': 4.69,\n '0A8': 8.1,\n 'NLY': 6.37,\n 'MHO': 4.89,\n 'VOL': 2.55,\n '0A1': 7.1,\n 'MHL': 3.92,\n 'NLP': 4.81,\n 'NLQ': 4.65,\n 'MHW': 2.74,\n 'BIL': 4.7,\n 'NLO': 4.8,\n 'MHU': 7.51,\n 'XW1': 9.36,\n 'LLO': 10.13,\n 'SGB': 6.88,\n 'MHV': 3.6,\n 'MHS': 4.51,\n '0A9': 5.17,\n '0LF': 9.96,\n 'HT7': 6.82,\n 'X2W': 6.6,\n 'YPZ': 9.38,\n 'I58': 6.73,\n 'FLA': 2.4,\n 'M0H': 4.83,\n 'HSL': 2.46,\n 'FLE': 6.17,\n 'KOR': 10.1,\n '1VR': 3.89,\n 'HSO': 4.56,\n 'TTS': 9.41,\n 'RVX': 7.01,\n 'TTQ': 7.71,\n 'H14': 5.27,\n 'HTI': 7.8,\n 'ONH': 6.14,\n 'LP6': 8.58,\n 'ONL': 4.83,\n 'AHH': 5.06,\n 'HS8': 7.4,\n 'HS9': 4.71,\n 'BL2': 5.82,\n 'AHP': 5.26,\n '6HN': 7.34,\n 'HRP': 5.46,\n 'POM': 3.6,\n 'WPA': 5.11,\n '2ZC': 4.29,\n 'CPC': 2.65,\n 'AIB': 2.4,\n 'XSN': 3.47,\n 'M2S': 5.28,\n 'GND': 6.67,\n 'GNC': 4.6,\n 'MVA': 2.56,\n 'OLZ': 5.32,\n 'M2L': 6.15,\n 'TRF': 6.69,\n 'NZH': 7.66,\n 'SRZ': 5.27,\n 'OLD': 10.47,\n 'CME': 5.86,\n 'CMH': 5.3,\n 'ALA': 2.38,\n 'TRQ': 7.36,\n 'PPN': 7.24,\n 'TRP': 6.07,\n 'TRO': 5.82,\n 'TRN': 5.95,\n 'NYS': 8.1,\n 'ALC': 5.26,\n 'U3X': 11.7,\n 'HVA': 2.58,\n 'TS9': 3.92,\n 'TRX': 7.27,\n 'TRW': 11.8,\n 'LPL': 7.51,\n 'GMA': 4.4,\n 'OMT': 5.07,\n 'CMT': 3.54,\n 'GME': 4.66,\n 'NYB': 6.07,\n 'PR3': 5.12,\n 'LPD': 2.48,\n 'GLU': 4.49,\n '1X6': 6.84,\n 'LPG': 2.39,\n 'GLX': 4.52,\n 'PR4': 4.52,\n 'CML': 6.16,\n 'FME': 4.52,\n 'HTR': 6.48,\n 'PR7': 4.66,\n 'Z3E': 7.2,\n 'GLZ': 2.39,\n 'BMT': 6.37,\n 'WRP': 8.16,\n 'GLY': 2.37,\n 'OMY': 6.11,\n 'MTY': 5.46,\n 'OMX': 6.15,\n 'GLN': 4.46,\n '2XA': 8.25,\n '28X': 7.84,\n '7JA': 9.46,\n 'FLT': 9.65,\n 'GLJ': 3.7,\n 'OMH': 5.26,\n 'TSY': 4.26,\n 'PRV': 4.28,\n 'CS4': 11.21,\n 'DOA': 12.33,\n '23P': 5.42,\n 'CS3': 8.24,\n '6CL': 6.47,\n 'PRR': 5.58,\n 'KST': 11.58,\n 'CS1': 7.23,\n 'PRS': 2.63,\n 'ZYJ': 11.4,\n 'IT1': 9.75,\n 'UU5': 4.98,\n 'ESB': 6.69,\n 'UU4': 2.49,\n 'ESC': 5.65,\n 'LSO': 10.58,\n 'ZYK': 11.45,\n '9NV': 8.99,\n '23F': 5.27,\n 'ORN': 4.25,\n 'HOX': 6.61,\n 'CSD': 3.95,\n 'FP9': 3.03,\n 'DO2': 4.44,\n 'SLL': 11.53,\n 'P3Q': 9.54,\n 'ORQ': 6.04,\n 'MSL': 5.21,\n 'DNP': 2.45,\n 'CSB': 3.51,\n 'WLU': 4.24,\n 'CSA': 5.7,\n 'MT2': 5.51,\n 'CSO': 3.53,\n 'TPO': 4.73,\n 'MSP': 13.11,\n '23S': 6.09,\n 'MSO': 4.96,\n 'PRO': 2.41,\n 'TPL': 5.41,\n 'DNS': 8.79,\n 'CSK': 3.91,\n 'Z70': 7.4,\n 'CSJ': 7.51,\n 'DNW': 7.97,\n 'PRK': 9.15,\n 'GSU': 11.81,\n 'LTA': 6.57,\n 'HPE': 6.63,\n 'TPQ': 6.48,\n 'PRJ': 5.26,\n 'PSW': 4.65,\n 'L3O': 3.89,\n 'CSU': 4.89,\n 'ALY': 7.38,\n 'M3L': 7.12,\n 'CSW': 3.68,\n 'XPR': 7.68,\n 'D4P': 5.66,\n 'FOE': 8.17,\n 'SLZ': 5.69,\n 'CSP': 5.26,\n 'TQI': 7.68,\n 'ALT': 2.72,\n 'CSR': 5.42,\n 'CSS': 3.61,\n 'M3R': 7.18,\n 'ALO': 2.57,\n 'R4K': 4.67,\n 'SMF': 9.0,\n 'MSA': 2.73,\n 'SMC': 3.39,\n 'CSX': 3.47,\n 'SME': 4.8,\n 'ETA': 2.4,\n 'CSZ': 3.6,\n '22G': 8.8,\n 'MSE': 4.62,\n 'ALN': 6.16,\n 'PSH': 7.26,\n 'CTE': 7.27,\n 'DON': 6.72,\n 'CTH': 3.45,\n 'U2X': 11.54,\n '6CW': 7.56,\n 'TQZ': 6.97,\n '3YM': 6.52,\n 'OSE': 4.49,\n '2VA': 9.82,\n 'TQQ': 7.76,\n 'NRG': 8.35,\n 'BPE': 7.24,\n 'F2F': 6.25,\n '1TQ': 8.58,\n 'I2M': 3.13,\n 'NVA': 3.76,\n 'R1A': 8.2,\n 'QPA': 6.95,\n 'C1X': 11.63,\n 'FRD': 5.05,\n 'HR7': 6.98,\n 'SNC': 3.93,\n 'QPH': 5.15,\n '26B': 8.39,\n 'DPQ': 6.54,\n 'DPP': 2.51,\n '2TY': 8.65,\n 'TNR': 6.88,\n 'PTH': 8.35,\n 'DPL': 3.58,\n 'APK': 8.79,\n '1TY': 8.84,\n 'HRG': 7.36,\n 'PTM': 8.74,\n '1U8': 3.62,\n 'PTR': 8.64,\n 'LVG': 3.01,\n '6FL': 4.85,\n 'SOC': 4.05,\n 'KPI': 9.79,\n 'IPG': 2.91,\n 'P2Y': 2.51,\n 'N2C': 3.55,\n 'T0I': 7.34,\n 'MPH': 5.29,\n 'R2T': 4.71,\n 'TOX': 6.78,\n 'P2Q': 9.8,\n 'GPL': 10.77,\n 'MPJ': 5.07,\n 'F2Y': 6.2,\n 'T11': 8.58,\n '9NR': 9.33,\n 'FPR': 8.85,\n '9NF': 8.93,\n 'KPY': 10.17,\n '9NE': 9.77,\n 'TOQ': 7.5,\n 'MPQ': 4.2,\n 'FPK': 3.08,\n 'HQA': 7.25,\n 'SOY': 10.94\n}\nexport const DefaultResidueRadius = 5.0\n\n// http://dx.doi.org/10.1039/b801115j (or 1.6)\nexport const CovalentRadii: { [e: number]: number | undefined } = {\n 1: 0.31, 2: 0.28, 3: 1.28, 4: 0.96, 5: 0.84, 6: 0.76, 7: 0.71, 8: 0.66, 9: 0.57, 10: 0.58, 11: 1.66, 12: 1.41, 13: 1.21, 14: 1.11, 15: 1.07, 16: 1.05, 17: 1.02, 18: 1.06, 19: 2.03, 20: 1.76, 21: 1.7, 22: 1.6, 23: 1.53, 24: 1.39, 25: 1.39, 26: 1.32, 27: 1.26, 28: 1.24, 29: 1.32, 30: 1.22, 31: 1.22, 32: 1.2, 33: 1.19, 34: 1.2, 35: 1.2, 36: 1.16, 37: 2.2, 38: 1.95, 39: 1.9, 40: 1.75, 41: 1.64, 42: 1.54, 43: 1.47, 44: 1.46, 45: 1.42, 46: 1.39, 47: 1.45, 48: 1.44, 49: 1.42, 50: 1.39, 51: 1.39, 52: 1.38, 53: 1.39, 54: 1.4, 55: 2.44, 56: 2.15, 57: 2.07, 58: 2.04, 59: 2.03, 60: 2.01, 61: 1.99, 62: 1.98, 63: 1.98, 64: 1.96, 65: 1.94, 66: 1.92, 67: 1.92, 68: 1.89, 69: 1.9, 70: 1.87, 71: 1.87, 72: 1.75, 73: 1.7, 74: 1.62, 75: 1.51, 76: 1.44, 77: 1.41, 78: 1.36, 79: 1.36, 80: 1.32, 81: 1.45, 82: 1.46, 83: 1.48, 84: 1.4, 85: 1.5, 86: 1.5, 87: 2.6, 88: 2.21, 89: 2.15, 90: 2.06, 91: 2.0, 92: 1.96, 93: 1.9, 94: 1.87, 95: 1.8, 96: 1.69, 97: 1.6, 98: 1.6, 99: 1.6, 100: 1.6, 101: 1.6, 102: 1.6, 103: 1.6, 104: 1.6, 105: 1.6, 106: 1.6, 107: 1.6, 108: 1.6, 109: 1.6, 110: 1.6, 111: 1.6, 112: 1.6, 113: 1.6, 114: 1.6, 115: 1.6, 116: 1.6, 117: 1.6, 118: 1.6\n}\nexport const DefaultCovalentRadius = 1.6\n\nexport const Valences: { [e: number]: number[] | undefined } = {\n 1: [ 1 ],\n 2: [ 0 ],\n 3: [ 1 ],\n 4: [ 2 ],\n 5: [ 3 ],\n 6: [ 4 ],\n 7: [ 3 ],\n 8: [ 2 ],\n 9: [ 1 ],\n 10: [ 0 ],\n 11: [ 1 ],\n 12: [ 2 ],\n 13: [ 6 ],\n 14: [ 6 ],\n 15: [ 3, 5, 7 ],\n 16: [ 2, 4, 6 ],\n 17: [ 1 ],\n 18: [ 0 ],\n 19: [ 1 ],\n 20: [ 2 ],\n\n 31: [ 3 ],\n 32: [ 4 ],\n 33: [ 3, 5 ],\n 34: [ 2, 4, 6 ],\n 35: [ 1 ],\n 36: [ 0 ],\n 37: [ 1 ],\n 38: [ 2 ],\n\n 49: [ 3 ],\n 50: [ 4 ],\n 51: [ 3, 5 ],\n 52: [ 2 ],\n 53: [ 1, 2, 5 ],\n 54: [ 0, 2 ],\n 55: [ 1 ],\n 56: [ 2 ],\n\n 81: [ 3 ],\n 82: [ 4 ],\n 83: [ 3 ],\n 84: [ 2 ],\n 85: [ 1 ],\n 86: [ 0 ],\n 87: [ 1 ],\n 88: [ 2 ]\n}\nexport const DefaultValence = -1\n\nexport const OuterShellElectronCounts: { [e: number]: number | undefined } = {\n1: 1, 2: 2, 3: 1, 4: 2, 5: 3, 6: 4, 7: 5, 8: 6, 9: 7, 10: 8, 11: 1, 12: 2, 13: 3, 14: 4, 15: 5, 16: 6, 17: 7, 18: 8, 19: 1, 20: 2, 21: 3, 22: 4, 23: 5, 24: 6, 25: 7, 26: 8, 27: 9, 28: 10, 29: 11, 30: 2, 31: 3, 32: 4, 33: 5, 34: 6, 35: 7, 36: 8, 37: 1, 38: 2, 39: 3, 40: 4, 41: 5, 42: 6, 43: 7, 44: 8, 45: 9, 46: 10, 47: 11, 48: 2, 49: 3, 50: 4, 51: 5, 52: 6, 53: 7, 54: 8, 55: 1, 56: 2, 57: 3, 58: 4, 59: 3, 60: 4, 61: 5, 62: 6, 63: 7, 64: 8, 65: 9, 66: 10, 67: 11, 68: 12, 69: 13, 70: 14, 71: 15, 72: 4, 73: 5, 74: 6, 75: 7, 76: 8, 77: 9, 78: 10, 79: 11, 80: 2, 81: 3, 82: 4, 83: 5, 84: 6, 85: 7, 86: 8, 87: 1, 88: 2, 89: 3, 90: 4, 91: 3, 92: 4, 93: 5, 94: 6, 95: 7, 96: 8, 97: 9, 98: 10, 99: 11, 100: 12, 101: 13, 102: 14, 103: 15, 104: 2, 105: 2, 106: 2, 107: 2, 108: 2, 109: 2, 110: 2, 111: 2, 112: 2, 113: 3, 114: 4, 115: 5, 116: 6, 117: 7, 118: 8\n}\nexport const DefaultOuterShellElectronCount = 2\n\n// http://blanco.biomol.uci.edu/Whole_residue_HFscales.txt\n// https://www.nature.com/articles/nsb1096-842\nexport const ResidueHydrophobicity: { [k: string]: [number, number, number] } = {\n // AA DGwif DGwoct Oct-IF\n 'ALA': [ 0.17, 0.50, 0.33 ],\n 'ARG': [ 0.81, 1.81, 1.00 ],\n 'ASN': [ 0.42, 0.85, 0.43 ],\n 'ASP': [ 1.23, 3.64, 2.41 ],\n 'ASH': [ -0.07, 0.43, 0.50 ],\n 'CYS': [ -0.24, -0.02, 0.22 ],\n 'GLN': [ 0.58, 0.77, 0.19 ],\n 'GLU': [ 2.02, 3.63, 1.61 ],\n 'GLH': [ -0.01, 0.11, 0.12 ],\n 'GLY': [ 0.01, 1.15, 1.14 ],\n // \"His+\": [ 0.96, 2.33, 1.37 ],\n 'HIS': [ 0.17, 0.11, -0.06 ],\n 'ILE': [ -0.31, -1.12, -0.81 ],\n 'LEU': [ -0.56, -1.25, -0.69 ],\n 'LYS': [ 0.99, 2.80, 1.81 ],\n 'MET': [ -0.23, -0.67, -0.44 ],\n 'PHE': [ -1.13, -1.71, -0.58 ],\n 'PRO': [ 0.45, 0.14, -0.31 ],\n 'SER': [ 0.13, 0.46, 0.33 ],\n 'THR': [ 0.14, 0.25, 0.11 ],\n 'TRP': [ -1.85, -2.09, -0.24 ],\n 'TYR': [ -0.94, -0.71, 0.23 ],\n 'VAL': [ 0.07, -0.46, -0.53 ]\n}\nexport const DefaultResidueHydrophobicity = [ 0.00, 0.00, 0.00 ]\n\nexport const AA1: { [k: string]: string } = {\n 'HIS': 'H',\n 'ARG': 'R',\n 'LYS': 'K',\n 'ILE': 'I',\n 'PHE': 'F',\n 'LEU': 'L',\n 'TRP': 'W',\n 'ALA': 'A',\n 'MET': 'M',\n 'PRO': 'P',\n 'CYS': 'C',\n 'ASN': 'N',\n 'VAL': 'V',\n 'GLY': 'G',\n 'SER': 'S',\n 'GLN': 'Q',\n 'TYR': 'Y',\n 'ASP': 'D',\n 'GLU': 'E',\n 'THR': 'T',\n\n 'SEC': 'U', // as per IUPAC definition\n 'PYL': 'O', // as per IUPAC definition\n}\n\nexport const AA3 = Object.keys(AA1)\n\nexport const RnaBases = [ 'A', 'C', 'T', 'G', 'U', 'I' ]\n\nexport const DnaBases = [ 'DA', 'DC', 'DT', 'DG', 'DU', 'DI' ]\n\nexport const PurinBases = [ 'A', 'G', 'I', 'DA', 'DG', 'DI' ]\n\nexport const Bases = RnaBases.concat(DnaBases)\n\nexport const WaterNames = [\n 'SOL', 'WAT', 'HOH', 'H2O', 'W', 'DOD', 'D3O', 'TIP3', 'TIP4', 'SPC'\n]\n\n// all chemical components with the word \"ion\" in their name, Sep 2016\n//\n// SET SESSION group_concat_max_len = 1000000;\n// SELECT GROUP_CONCAT(id_ ORDER BY id_ ASC SEPARATOR '\", \"') from\n// (\n// SELECT count(obj_id) as c, id_\n// FROM pdb.chem_comp WHERE name LIKE \"% ION%\"\n// GROUP BY id_\n// ) AS t1;\nexport const IonNames = [\n '118', '119', '1AL', '1CU', '2FK', '2HP', '2OF', '3CO',\n '3MT', '3NI', '3OF', '3P8', '4MO', '4PU', '543', '6MO', 'ACT', 'AG', 'AL',\n 'ALF', 'AM', 'ATH', 'AU', 'AU3', 'AUC', 'AZI', 'BA', 'BCT', 'BEF', 'BF4', 'BO4',\n 'BR', 'BS3', 'BSY', 'CA', 'CAC', 'CD', 'CD1', 'CD3', 'CD5', 'CE', 'CHT', 'CL',\n 'CO', 'CO3', 'CO5', 'CON', 'CR', 'CS', 'CSB', 'CU', 'CU1', 'CU3', 'CUA', 'CUZ',\n 'CYN', 'DME', 'DMI', 'DSC', 'DTI', 'DY', 'E4N', 'EDR', 'EMC', 'ER3', 'EU',\n 'EU3', 'F', 'FE', 'FE2', 'FPO', 'GA', 'GD3', 'GEP', 'HAI', 'HG', 'HGC', 'IN',\n 'IOD', 'IR', 'IR3', 'IRI', 'IUM', 'K', 'KO4', 'LA', 'LCO', 'LCP', 'LI', 'LU',\n 'MAC', 'MG', 'MH2', 'MH3', 'MLI', 'MLT', 'MMC', 'MN', 'MN3', 'MN5', 'MN6',\n 'MO1', 'MO2', 'MO3', 'MO4', 'MO5', 'MO6', 'MOO', 'MOS', 'MOW', 'MW1', 'MW2',\n 'MW3', 'NA', 'NA2', 'NA5', 'NA6', 'NAO', 'NAW', 'NCO', 'NET', 'NH4', 'NI',\n 'NI1', 'NI2', 'NI3', 'NO2', 'NO3', 'NRU', 'O4M', 'OAA', 'OC1', 'OC2', 'OC3',\n 'OC4', 'OC5', 'OC6', 'OC7', 'OC8', 'OCL', 'OCM', 'OCN', 'OCO', 'OF1', 'OF2',\n 'OF3', 'OH', 'OS', 'OS4', 'OXL', 'PB', 'PBM', 'PD', 'PDV', 'PER', 'PI', 'PO3',\n 'PO4', 'PR', 'PT', 'PT4', 'PTN', 'RB', 'RH3', 'RHD', 'RU', 'SB', 'SCN', 'SE4',\n 'SEK', 'SM', 'SMO', 'SO3', 'SO4', 'SR', 'T1A', 'TB', 'TBA', 'TCN', 'TEA', 'TH',\n 'THE', 'TL', 'TMA', 'TRA', 'UNX', 'V', 'VN3', 'VO4', 'W', 'WO5', 'Y1', 'YB',\n 'YB2', 'YH', 'YT3', 'ZCM', 'ZN', 'ZN2', 'ZN3', 'ZNO', 'ZO3',\n // additional ion names\n 'OHX'\n]\n\n// all chemical components with the word \"%saccharide%\" in their type, Sep 2016\n//\n// SET SESSION group_concat_max_len = 1000000;\n// select GROUP_CONCAT(id_ ORDER BY id_ ASC SEPARATOR '\", \"') from\n// (\n// SELECT count(obj_id), id_\n// FROM pdb.chem_comp WHERE type like \"%SACCHARIDE%\"\n// GROUP BY id_\n// ) AS t1;\nexport const SaccharideNames = [\n '045', '0AT', '0BD', '0MK', '0NZ', '0TS', '0V4', '0XY', '0YT', '10M',\n '147', '149', '14T', '15L', '16G', '18T', '18Y', '1AR', '1BW', '1GL', '1GN',\n '1JB', '1LL', '1NA', '1S3', '26M', '26Q', '26R', '26V', '26W', '26Y', '27C',\n '289', '291', '293', '2DG', '2F8', '2FG', '2FL', '2FP', '2GL', '2M4', '2M5',\n '32O', '34V', '3CM', '3DO', '3DY', '3FM', '3LR', '3MF', '3MG', '3SA', '3ZW',\n '46D', '46M', '46Z', '48Z', '4CQ', '4GC', '4NN', '50A', '5DI', '5GF', '5MM',\n '5RP', '5SA', '5SP', '64K', '6PG', '6SA', '7JZ', '7SA', 'A1Q', 'A2G', 'AAB',\n 'AAL', 'AAO', 'ABC', 'ABD', 'ABE', 'ABF', 'ABL', 'ACG', 'ACI', 'ACR', 'ACX',\n 'ADA', 'ADG', 'ADR', 'AF1', 'AFD', 'AFL', 'AFO', 'AFP', 'AFR', 'AGC', 'AGH',\n 'AGL', 'AHR', 'AIG', 'ALL', 'ALX', 'AMU', 'AOG', 'AOS', 'ARA', 'ARB', 'ARE',\n 'ARI', 'ASG', 'ASO', 'AXP', 'AXR', 'B0D', 'B16', 'B2G', 'B4G', 'B6D', 'B8D',\n 'B9D', 'BBK', 'BCD', 'BDG', 'BDP', 'BDR', 'BEM', 'BFP', 'BGC', 'BGL', 'BGP',\n 'BGS', 'BHG', 'BMA', 'BMX', 'BNG', 'BNX', 'BOG', 'BRI', 'BXF', 'BXP', 'BXX',\n 'BXY', 'C3X', 'C4X', 'C5X', 'CAP', 'CBI', 'CBK', 'CBS', 'CDR', 'CEG', 'CGF',\n 'CHO', 'CR1', 'CR6', 'CRA', 'CT3', 'CTO', 'CTR', 'CTT', 'D6G', 'DAF', 'DAG',\n 'DDA', 'DDB', 'DDL', 'DEL', 'DFR', 'DFX', 'DG0', 'DGC', 'DGD', 'DGM', 'DGS',\n 'DIG', 'DLF', 'DLG', 'DMU', 'DNO', 'DOM', 'DP5', 'DQQ', 'DQR', 'DR2', 'DR3',\n 'DR4', 'DRI', 'DSR', 'DT6', 'DVC', 'E4P', 'E5G', 'EAG', 'EBG', 'EBQ', 'EGA',\n 'EJT', 'EPG', 'ERE', 'ERI', 'F1P', 'F1X', 'F6P', 'FBP', 'FCA', 'FCB', 'FCT',\n 'FDP', 'FDQ', 'FFC', 'FIX', 'FMO', 'FRU', 'FSI', 'FU4', 'FUB', 'FUC', 'FUD',\n 'FUL', 'FXP', 'G16', 'G1P', 'G2F', 'G3I', 'G4D', 'G4S', 'G6D', 'G6P', 'G6S',\n 'GAC', 'GAD', 'GAL', 'GC1', 'GC4', 'GCD', 'GCN', 'GCO', 'GCS', 'GCT', 'GCU',\n 'GCV', 'GCW', 'GCX', 'GE1', 'GFG', 'GFP', 'GIV', 'GL0', 'GL2', 'GL5', 'GL6',\n 'GL7', 'GL9', 'GLA', 'GLB', 'GLC', 'GLD', 'GLF', 'GLG', 'GLO', 'GLP', 'GLS',\n 'GLT', 'GLW', 'GMH', 'GN1', 'GNX', 'GP1', 'GP4', 'GPH', 'GPM', 'GQ1', 'GQ2',\n 'GQ4', 'GS1', 'GS4', 'GSA', 'GSD', 'GTE', 'GTH', 'GTK', 'GTR', 'GTZ', 'GU0',\n 'GU1', 'GU2', 'GU3', 'GU4', 'GU5', 'GU6', 'GU8', 'GU9', 'GUF', 'GUP', 'GUZ',\n 'GYP', 'GYV', 'H2P', 'HDL', 'HMS', 'HS2', 'HSD', 'HSG', 'HSH', 'HSJ', 'HSQ',\n 'HSR', 'HSU', 'HSX', 'HSY', 'HSZ', 'IAB', 'IDG', 'IDR', 'IDS', 'IDT', 'IDU',\n 'IDX', 'IDY', 'IMK', 'IN1', 'IPT', 'ISL', 'KBG', 'KD2', 'KDA', 'KDM', 'KDO',\n 'KFN', 'KO1', 'KO2', 'KTU', 'L6S', 'LAG', 'LAI', 'LAK', 'LAO', 'LAT', 'LB2',\n 'LBT', 'LCN', 'LDY', 'LGC', 'LGU', 'LM2', 'LMT', 'LMU', 'LOG', 'LOX', 'LPK',\n 'LSM', 'LTM', 'LVZ', 'LXB', 'LXZ', 'M1F', 'M3M', 'M6P', 'M8C', 'MA1', 'MA2',\n 'MA3', 'MAB', 'MAG', 'MAL', 'MAN', 'MAT', 'MAV', 'MAW', 'MBG', 'MCU', 'MDA',\n 'MDM', 'MDP', 'MFA', 'MFB', 'MFU', 'MG5', 'MGA', 'MGL', 'MLB', 'MMA', 'MMN',\n 'MN0', 'MRP', 'MTT', 'MUG', 'MVP', 'MXY', 'N1L', 'N9S', 'NAA', 'NAG', 'NBG',\n 'NDG', 'NED', 'NG1', 'NG6', 'NGA', 'NGB', 'NGC', 'NGE', 'NGF', 'NGL', 'NGS',\n 'NGY', 'NHF', 'NM6', 'NM9', 'NTF', 'NTO', 'NTP', 'NXD', 'NYT', 'OPG', 'OPM',\n 'ORP', 'OX2', 'P3M', 'P53', 'P6P', 'PA5', 'PNA', 'PNG', 'PNW', 'PRP', 'PSJ',\n 'PSV', 'PTQ', 'QDK', 'QPS', 'QV4', 'R1P', 'R1X', 'R2B', 'R5P', 'RAA', 'RAE',\n 'RAF', 'RAM', 'RAO', 'RAT', 'RB5', 'RBL', 'RCD', 'RDP', 'REL', 'RER', 'RF5',\n 'RG1', 'RGG', 'RHA', 'RIB', 'RIP', 'RNS', 'RNT', 'ROB', 'ROR', 'RPA', 'RST',\n 'RUB', 'RUU', 'RZM', 'S6P', 'S7P', 'SA0', 'SCR', 'SDD', 'SF6', 'SF9', 'SG4',\n 'SG5', 'SG6', 'SG7', 'SGA', 'SGC', 'SGD', 'SGN', 'SGS', 'SHB', 'SHG', 'SI3',\n 'SIO', 'SOE', 'SOL', 'SSG', 'SUC', 'SUP', 'SUS', 'T6P', 'T6T', 'TAG', 'TCB',\n 'TDG', 'TGK', 'TGY', 'TH1', 'TIA', 'TM5', 'TM6', 'TM9', 'TMR', 'TMX', 'TOA',\n 'TOC', 'TRE', 'TYV', 'UCD', 'UDC', 'VG1', 'X0X', 'X1X', 'X2F', 'X4S', 'X5S',\n 'X6X', 'XBP', 'XDN', 'XDP', 'XIF', 'XIM', 'XLF', 'XLS', 'XMM', 'XUL', 'XXR',\n 'XYP', 'XYS', 'YO5', 'Z3Q', 'Z6J', 'Z9M', 'ZDC', 'ZDM'\n]\n\nexport const ProteinBackboneAtoms = [\n 'CA', 'C', 'N', 'O',\n 'O1', 'O2', 'OC1', 'OC2', 'OX1', 'OXT', 'OT1', 'OT2',\n 'H', 'H1', 'H2', 'H3', 'HA', 'HN',\n 'BB'\n]\n\nexport const NucleicBackboneAtoms = [\n 'P', 'OP1', 'OP2', 'HOP2', 'HOP3',\n \"O2'\", \"O3'\", \"O4'\", \"O5'\", \"C1'\", \"C2'\", \"C3'\", \"C4'\", \"C5'\",\n \"H1'\", \"H2'\", \"H2''\", \"HO2'\", \"H3'\", \"H4'\", \"H5'\", \"H5''\", \"HO3'\", \"HO5'\",\n 'O2*', 'O3*', 'O4*', 'O5*', 'C1*', 'C2*', 'C3*', 'C4*', 'C5*'\n]\n\nexport const ResidueTypeAtoms: { [k: number]: { [k: string]: string|string[] } } = {}\n\nResidueTypeAtoms[ ProteinBackboneType ] = {\n trace: 'CA',\n direction1: 'C',\n direction2: [ 'O', 'OC1', 'O1', 'OX1', 'OXT', 'OT1', 'OT2' ],\n backboneStart: 'N',\n backboneEnd: 'C'\n}\n\nResidueTypeAtoms[ RnaBackboneType ] = {\n trace: [ \"C4'\", 'C4*' ],\n direction1: [ \"C1'\", 'C1*' ],\n direction2: [ \"C3'\", 'C3*' ],\n backboneStart: 'P',\n backboneEnd: [ \"O3'\", 'O3*' ]\n}\n\nResidueTypeAtoms[ DnaBackboneType ] = {\n trace: [ \"C3'\", 'C3*' ],\n direction1: [ \"C2'\", 'C2*' ],\n direction2: [ \"O4'\", 'O4*' ],\n backboneStart: 'P',\n backboneEnd: [ \"O3'\", 'O3*' ]\n}\n\nResidueTypeAtoms[ CgProteinBackboneType ] = {\n trace: [ 'CA', 'BB' ],\n backboneStart: [ 'CA', 'BB' ],\n backboneEnd: [ 'CA', 'BB' ]\n}\n\nResidueTypeAtoms[ CgRnaBackboneType ] = {\n trace: [ \"C4'\", 'C4*', 'P' ],\n backboneStart: [ \"C4'\", 'C4*', 'P' ],\n backboneEnd: [ \"C4'\", 'C4*', 'P' ]\n}\n\nResidueTypeAtoms[ CgDnaBackboneType ] = {\n trace: [ \"C3'\", 'C3*', \"C2'\", 'P' ], // C2' is used in martini ff\n backboneStart: [ \"C3'\", 'C3*', \"C2'\", 'P' ],\n backboneEnd: [ \"C3'\", 'C3*', \"C2'\", 'P' ]\n}\n\nResidueTypeAtoms[ UnknownBackboneType ] = {}\n\n// Mappings taken from Meeko: https://github.com/forlilab/Meeko/blob/develop/meeko/utils/autodock4_atom_types_elements.py\nexport const PDBQTSpecialElements = {\n 'HD': 'H',\n 'HS': 'H',\n 'A': 'C',\n 'NA': 'N',\n 'NS': 'N',\n 'OA': 'O',\n 'OS': 'O',\n 'SA': 'S',\n 'G0': 'C',\n 'G1': 'C',\n 'G2': 'C',\n 'G3': 'C',\n 'CG0': 'C',\n 'CG1': 'C',\n 'CG2': 'C',\n 'CG3': 'C',\n 'W': 'O'\n}","/**\n * @file Geometry\n * @author Fred Ludlow \n * @author Alexander Rose \n */\n\nimport { Vector3 } from 'three'\n\nimport { Elements } from '../structure/structure-constants'\nimport { degToRad } from '../math/math-utils'\nimport AtomProxy from '../proxy/atom-proxy'\n\n// Changed numbering so they're mostly inline with coordination number\n// from VSEPR\nexport const enum AtomGeometry {\n Spherical = 0,\n Terminal = 1,\n Linear = 2,\n Trigonal = 3,\n Tetrahedral = 4,\n TrigonalBiPyramidal = 5,\n Octahedral = 6,\n SquarePlanar = 7, // Okay, it breaks down somewhere!\n Unknown = 8\n}\n\nexport function assignGeometry (totalCoordination: number): AtomGeometry {\n switch(totalCoordination){\n case 0:\n return AtomGeometry.Spherical\n case 1:\n return AtomGeometry.Terminal\n case 2:\n return AtomGeometry.Linear\n case 3:\n return AtomGeometry.Trigonal\n case 4:\n return AtomGeometry.Tetrahedral\n default:\n return AtomGeometry.Unknown\n }\n}\n\nexport const Angles = new Map([\n [ AtomGeometry.Linear, degToRad(180) ],\n [ AtomGeometry.Trigonal, degToRad(120) ],\n [ AtomGeometry.Tetrahedral, degToRad(109.4721) ],\n [ AtomGeometry.Octahedral, degToRad(90) ]\n])\n\n/**\n * Calculate the angles x-1-2 for all x where x is a heavy atom bonded to ap1.\n * @param {AtomProxy} ap1 First atom (angle centre)\n * @param {AtomProxy} ap2 Second atom\n * @return {number[]} Angles in radians\n */\nexport function calcAngles (ap1: AtomProxy, ap2: AtomProxy): number[] {\n let angles: number[] = []\n const d1 = new Vector3()\n const d2 = new Vector3()\n d1.subVectors(ap2 as any, ap1 as any)\n ap1.eachBondedAtom( x => {\n if (x.number !== Elements.H) {\n d2.subVectors(x as any, ap1 as any)\n angles.push(d1.angleTo(d2))\n }\n })\n return angles\n}\n\n/**\n * Find two neighbours of ap1 to define a plane (if possible) and\n * measure angle out of plane to ap2\n * @param {AtomProxy} ap1 First atom (angle centre)\n * @param {AtomProxy} ap2 Second atom (out-of-plane)\n * @return {number} Angle from plane to second atom\n */\nexport function calcPlaneAngle (ap1: AtomProxy, ap2: AtomProxy): number | undefined {\n const x1 = ap1.clone()\n\n const v12 = new Vector3()\n v12.subVectors(ap2 as any, ap1 as any)\n\n const neighbours = [new Vector3(), new Vector3()]\n let ni = 0\n ap1.eachBondedAtom( x => {\n if (ni > 1) { return }\n if (x.number !== Elements.H) {\n x1.index = x.index\n neighbours[ni++].subVectors(x as any, ap1 as any)\n }\n })\n if (ni === 1) {\n x1.eachBondedAtom( x => {\n if (ni > 1) { return }\n if (x.number !== Elements.H && x.index !== ap1.index){\n neighbours[ni++].subVectors(x as any, ap1 as any)\n }\n })\n }\n if (ni !== 2) {\n return\n }\n\n const cp = neighbours[0].cross(neighbours[1])\n return Math.abs((Math.PI / 2) - cp.angleTo(v12))\n}\n","/**\n * @file Valence Model\n * @author Fred Ludlow \n * @author Alexander Rose \n */\n\n/**\n * Reworked ValenceModel\n *\n * TODO:\n * Ensure proper treatment of disorder/models. e.g. V257 N in 5vim\n * Formal charge of 255 for SO4 anion (e.g. 5ghl)\n * Have removed a lot of explicit features (as I think they're more\n * generally captured by better VM).\n * Could we instead have a \"delocalised negative/positive\" charge\n * feature and flag these up?\n *\n */\nimport { Data } from '../structure/data'\nimport AtomProxy from '../proxy/atom-proxy'\nimport { AtomGeometry, assignGeometry } from './geometry'\nimport { Elements } from '../structure/structure-constants'\n\n/**\n * Are we involved in some kind of pi system. Either explicitly forming\n * double bond or N, O next to a double bond, except:\n *\n * N,O with degree 4 cannot be conjugated.\n * N,O adjacent to P=O or S=O do not qualify (keeps sulfonamide N sp3 geom)\n */\nfunction isConjugated (a: AtomProxy) {\n const _bp = a.structure.getBondProxy()\n const atomicNumber = a.number\n const hetero = atomicNumber === Elements.O || atomicNumber === Elements.N\n\n if (hetero && a.bondCount === 4) {\n return false\n }\n\n let flag = false\n\n a.eachBond(b => {\n if (b.bondOrder > 1) {\n flag = true\n return\n }\n if (hetero) {\n const a2 = b.getOtherAtom(a)\n\n a2.eachBond(b2 => {\n if (b2.bondOrder > 1) {\n const atomicNumber2 = a2.number\n if (\n (atomicNumber2 === Elements.P || atomicNumber2 === Elements.S) &&\n b2.getOtherAtom(a2).number === Elements.O\n ) {\n return\n }\n flag = true\n }\n }, _bp) // Avoid reuse of structure._bp\n }\n })\n\n return flag\n}\n\n/* function hasExplicitCharge(r: ResidueProxy) {\n let flag = false\n r.eachAtom(a => {\n if (a.formalCharge != null && a.formalCharge !== 0) flag = true\n })\n return flag\n}\n\nfunction hasExplicitHydrogen(r: ResidueProxy) {\n let flag = false\n r.eachAtom(a => {\n if (a.number === Elements.H) flag = true\n })\n return flag\n} */\n\nexport function explicitValence (a: AtomProxy) {\n let v = 0\n a.eachBond(b => v += b.bondOrder)\n return v\n}\n\n/**\n * Attempts to produce a consistent charge and implicit\n * H-count for an atom.\n *\n * If both params.assignCharge and params.assignH, this\n * approximately followsthe rules described in\n * https://docs.eyesopen.com/toolkits/python/oechemtk/valence.html#openeye-hydrogen-count-model\n *\n * If only charge or hydrogens are to be assigned it takes\n * a much simpler view and deduces one from the other\n *\n * @param {AtomProxy} a Atom to analyze\n * @param {assignChargeHParams} params What to assign\n */\nexport function calculateHydrogensCharge (a: AtomProxy, params: ValenceModelParams) {\n const hydrogenCount = a.bondToElementCount(Elements.H)\n let charge = a.formalCharge || 0\n\n const assignCharge = (params.assignCharge === 'always' ||\n (params.assignCharge === 'auto' && charge === 0))\n const assignH = (params.assignH === 'always' ||\n (params.assignH === 'auto' && hydrogenCount === 0))\n\n const degree = a.bondCount\n const valence = explicitValence(a)\n\n const conjugated = isConjugated(a)\n const multiBond = (valence - degree > 0)\n\n\n let implicitHCount = 0\n let geom = AtomGeometry.Unknown\n\n switch (a.number) {\n case Elements.H:\n if (assignCharge){\n if (degree === 0){\n charge = 1\n geom = AtomGeometry.Spherical\n } else if (degree === 1) {\n charge = 0\n geom = AtomGeometry.Terminal\n }\n }\n break\n\n case Elements.C:\n // TODO: Isocyanide?\n if (assignCharge) {\n charge = 0 // Assume carbon always neutral\n }\n if (assignH) {\n // Carbocation/carbanion are 3-valent\n implicitHCount = Math.max(0, 4 - valence - Math.abs(charge))\n }\n // Carbocation is planar, carbanion is tetrahedral\n geom = assignGeometry(degree + implicitHCount + Math.max(0, -charge))\n break\n\n case Elements.N:\n if (assignCharge) {\n if (!assignH) { // Trust input H explicitly:\n charge = valence - 3\n } else if (conjugated && valence < 4) {\n // Neutral unless amidine/guanidine double-bonded N:\n if (degree - hydrogenCount === 1 && valence - hydrogenCount === 2) {\n charge = 1\n } else {\n charge = 0\n }\n } else {\n // Sulfonamide nitrogen and classed as sp3 in conjugation model but\n // they won't be charged\n // Don't assign charge to nitrogens bound to metals\n let flag = false\n a.eachBondedAtom(ba => {\n if (ba.number === Elements.S || ba.isMetal()) flag = true\n })\n if (flag) charge = 0\n else charge = 1\n // TODO: Planarity sanity check?\n }\n\n }\n\n if (assignH) {\n // NH4+ -> 4, 1' amide -> 2, nitro N/N+ depiction -> 0\n implicitHCount = Math.max(0, 3 - valence + charge)\n }\n\n if (conjugated && !multiBond) {\n // Amide, anilinic N etc. cannot consider lone-pair for geometry purposes\n // Anilinic N geometry is depenent on ring electronics, for our purposes we\n // assume it's trigonal!\n geom = assignGeometry(degree + implicitHCount - charge)\n } else {\n // Everything else, pyridine, amine, nitrile, lp plays normal role:\n geom = assignGeometry(degree + implicitHCount + 1 - charge)\n }\n break\n\n case Elements.O:\n if (assignCharge) {\n if (!assignH) {\n charge = valence - 2 //\n }\n if (valence === 1) {\n a.eachBondedAtom(ba => {\n ba.eachBond(b => {\n const oa = b.getOtherAtom(ba)\n if (oa.index !== a.index && oa.number === Elements.O && b.bondOrder === 2){\n charge = -1\n }\n })\n })\n }\n }\n if (assignH) {\n // ethanol -> 1, carboxylate -> -1\n implicitHCount = Math.max(0, 2 - valence + charge)\n }\n if (conjugated && !multiBond){\n // carboxylate OH, phenol OH, one lone-pair taken up with conjugation\n geom = assignGeometry(degree + implicitHCount - charge + 1)\n } else {\n // Carbonyl (trigonal)\n geom = assignGeometry(degree + implicitHCount - charge + 2)\n }\n break\n\n // Only handles thiols/thiolates/thioether/sulfonium. Sulfoxides and higher\n // oxidiation states are assumed neutral S (charge carried on O if required)\n case Elements.S:\n if (assignCharge) {\n if (!assignH) {\n if (valence <= 3 && !a.bondToElementCount(Elements.O)) {\n charge = valence - 2 // e.g. explicitly deprotonated thiol\n } else {\n charge = 0\n }\n }\n }\n if (assignH){\n if (valence < 2){\n implicitHCount = Math.max(0, 2 - valence + charge)\n }\n }\n if (valence <= 3){\n // Thiol, thiolate, tioether -> tetrahedral\n geom = assignGeometry(degree + implicitHCount - charge + 2)\n }\n\n break\n\n case Elements.F:\n case Elements.CL:\n case Elements.BR:\n case Elements.I:\n case Elements.AT:\n // Never implicitly protonate halides\n if (assignCharge) {\n charge = valence - 1\n }\n break\n\n case Elements.LI:\n case Elements.NA:\n case Elements.K:\n case Elements.RB:\n case Elements.CS:\n case Elements.FR:\n if (assignCharge) {\n charge = 1 - valence\n }\n break\n\n case Elements.BE:\n case Elements.MG:\n case Elements.CA:\n case Elements.SR:\n case Elements.BA:\n case Elements.RA:\n if (assignCharge) {\n charge = 2 - valence\n }\n break\n\n default:\n console.warn('Requested charge, protonation for an unhandled element', a.element)\n }\n\n return [ charge, implicitHCount, implicitHCount + hydrogenCount, geom ]\n}\n\n\nexport interface ValenceModel {\n charge: Int8Array,\n implicitH: Int8Array,\n totalH: Int8Array,\n idealGeometry: Int8Array\n}\n\nexport interface ValenceModelParams {\n assignCharge: string,\n assignH: string\n}\n\nexport function ValenceModel (data: Data, params: ValenceModelParams) {\n const structure = data.structure\n const n = structure.atomCount\n\n const charge = new Int8Array(n)\n const implicitH = new Int8Array(n)\n const totalH = new Int8Array(n)\n const idealGeometry = new Int8Array(n)\n\n structure.eachAtom(a => {\n const i = a.index\n const [ chg, implH, totH, geom ] = calculateHydrogensCharge(a, params)\n charge[ i ] = chg\n implicitH[ i ] = implH\n totalH[ i ] = totH\n idealGeometry[ i ] = geom\n })\n\n return { charge, implicitH, totalH, idealGeometry }\n}","\nimport Structure from './structure'\nimport SpatialHash from '../geometry/spatial-hash'\nimport { ValenceModel } from '../chemistry/valence-model'\n\nexport interface Data {\n structure: Structure\n '@spatialLookup': SpatialHash | undefined\n '@valenceModel': ValenceModel | undefined\n}\n\nexport function createData(structure: Structure): Data {\n return {\n structure,\n '@spatialLookup': undefined,\n '@valenceModel': undefined\n }\n}\n\nexport function spatialLookup(data: Data): SpatialHash {\n if (data['@spatialLookup']) return data['@spatialLookup']!\n const lookup = new SpatialHash(data.structure.atomStore, data.structure.boundingBox)\n data['@spatialLookup'] = lookup\n return lookup\n}\n\nexport function valenceModel(data: Data): ValenceModel {\n if (data['@valenceModel']) return data['@valenceModel']!\n const valenceModel = ValenceModel(data, {assignCharge: 'auto', assignH: 'auto'})\n data['@valenceModel'] = valenceModel\n return valenceModel\n}\n","/**\n * @file Functional Groups\n * @author Alexander Rose \n */\n\nimport AtomProxy from '../proxy/atom-proxy'\nimport { Elements } from '../structure/structure-constants'\n\n/**\n * Nitrogen in a quaternary amine\n */\nexport function isQuaternaryAmine (a: AtomProxy) {\n return (\n a.number === 7 &&\n a.bondCount === 4 &&\n a.bondToElementCount(Elements.H) === 0\n )\n}\n\n/**\n * Nitrogen in a tertiary amine\n */\nexport function isTertiaryAmine (a: AtomProxy, idealValence: number) {\n return (\n a.number === 7 &&\n a.bondCount >= 3 &&\n idealValence === 3\n )\n}\n\n/**\n * Nitrogen in an imide\n */\nexport function isImide (a: AtomProxy) {\n let flag = false\n if (a.number === Elements.N && (a.bondCount - a.bondToElementCount(Elements.H)) === 2) {\n let carbonylCount = 0\n a.eachBondedAtom(ba => {\n if (isCarbonyl(ba)) ++carbonylCount\n })\n flag = carbonylCount === 2\n }\n return flag\n}\n\n/**\n * Nitrogen in an amide\n */\nexport function isAmide (a: AtomProxy) {\n let flag = false\n if (a.number === Elements.N && (a.bondCount - a.bondToElementCount(Elements.H)) === 2) {\n let carbonylCount = 0\n a.eachBondedAtom(ba => {\n if (isCarbonyl(ba)) ++carbonylCount\n })\n flag = carbonylCount === 1\n }\n return flag\n}\n\n/**\n * Sulfur in a sulfonium group\n */\nexport function isSulfonium (a: AtomProxy) {\n return (\n a.number === 16 &&\n a.bondCount === 3 &&\n a.bondToElementCount(Elements.H) === 0\n )\n}\n\n/**\n * Sulfur in a sulfonic acid or sulfonate group\n */\nexport function isSulfonicAcid (a: AtomProxy) {\n return (\n a.number === 16 &&\n a.bondToElementCount(Elements.O) === 3\n )\n}\n\n/**\n * Sulfur in a sulfate group\n */\nexport function isSulfate (a: AtomProxy) {\n return (\n a.number === 16 &&\n a.bondToElementCount(Elements.O) === 4\n )\n}\n\n/**\n * Phosphor in a phosphate group\n */\nexport function isPhosphate (a: AtomProxy) {\n return (\n a.number === 15 &&\n a.bondToElementCount(Elements.O) === a.bondCount\n )\n}\n\n/**\n * Halogen with one bond to a carbon\n */\nexport function isHalocarbon (a: AtomProxy) {\n return (\n a.isHalogen() &&\n a.bondCount === 1 &&\n a.bondToElementCount(Elements.C) === 1\n )\n}\n\n/**\n * Carbon in a carbonyl/acyl group\n */\nexport function isCarbonyl (a: AtomProxy) {\n let flag = false\n if (a.number === Elements.C) {\n a.eachBond(b => {\n if (b.bondOrder === 2 && b.getOtherAtom(a).number === Elements.O) {\n flag = true\n }\n })\n }\n return flag\n}\n\n/**\n * Carbon in a carboxylate group\n */\nexport function isCarboxylate (a: AtomProxy) {\n let terminalOxygenCount = 0\n if (\n a.number === 6 &&\n a.bondToElementCount(Elements.O) === 2 &&\n a.bondToElementCount(Elements.C) === 1\n ) {\n a.eachBondedAtom(ba => {\n if (ba.number === 8 && ba.bondCount - ba.bondToElementCount(Elements.H) === 1) {\n ++terminalOxygenCount\n }\n })\n }\n return terminalOxygenCount === 2\n}\n\n/**\n * Carbon in a guanidine group\n */\nexport function isGuanidine (a: AtomProxy) {\n let terminalNitrogenCount = 0\n if (\n a.number === 6 &&\n a.bondCount === 3 &&\n a.bondToElementCount(Elements.N) === 3\n ) {\n a.eachBondedAtom(ba => {\n if (ba.bondCount - ba.bondToElementCount(Elements.H) === 1) {\n ++terminalNitrogenCount\n }\n })\n }\n return terminalNitrogenCount === 2\n}\n\n/**\n * Carbon in a acetamidine group\n */\nexport function isAcetamidine (a: AtomProxy) {\n let terminalNitrogenCount = 0\n if (\n a.number === 6 &&\n a.bondCount === 3 &&\n a.bondToElementCount(Elements.N) === 2 &&\n a.bondToElementCount(Elements.C) === 1\n ) {\n a.eachBondedAtom(ba => {\n if (ba.bondCount - ba.bondToElementCount(Elements.H) === 1) {\n ++terminalNitrogenCount\n }\n })\n }\n return terminalNitrogenCount === 2\n}\n\nconst PolarElements = [\n Elements.N, Elements.O, Elements.S,\n Elements.F, Elements.CL, Elements.BR, Elements.I\n]\n\nexport function isPolar (a: AtomProxy) {\n return PolarElements.includes(a.number)\n}\n\nexport function hasPolarNeighbour (a: AtomProxy) {\n let flag = false\n a.eachBondedAtom(ba => {\n if (isPolar(ba)) flag = true\n })\n return flag\n}\n\nexport function hasAromaticNeighbour (a: AtomProxy) {\n let flag = false\n a.eachBondedAtom(function (bap) {\n if (bap.aromatic) flag = true\n })\n return flag\n}\n","/**\n * @file Charged\n * @author Alexander Rose \n * @author Fred Ludlow \n */\n\nimport { Vector3 } from 'three'\n\nimport { defaults } from '../../utils'\nimport { radToDeg } from '../../math/math-utils'\nimport Structure from '../../structure/structure'\nimport { AA3, Bases, Elements } from '../../structure/structure-constants'\nimport { valenceModel } from '../../structure/data'\nimport {\n isGuanidine, isAcetamidine, isSulfonicAcid, isPhosphate, isSulfate, isCarboxylate\n} from '../functional-groups'\nimport {\n Features, FeatureType, FeatureGroup,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\n\nconst PositvelyCharged = [ 'ARG', 'HIS', 'LYS' ]\nconst NegativelyCharged = [ 'GLU', 'ASP' ]\n\nexport function addPositiveCharges (structure: Structure, features: Features) {\n const { charge } = valenceModel(structure.data)\n const atomInGroupDict: { [atomIndex: number]: true } = {}\n\n structure.eachResidue(r => {\n if (PositvelyCharged.includes(r.resname)) {\n const state = createFeatureState(FeatureType.PositiveCharge)\n r.eachAtom(a => {\n if (a.number === Elements.N && a.isSidechain()) {\n addAtom(state, a)\n }\n })\n addFeature(features, state)\n } else if(!AA3.includes(r.resname) && !r.isNucleic()) {\n r.eachAtom(a => {\n let addGroup = false\n const state = createFeatureState(FeatureType.PositiveCharge)\n if (isGuanidine(a)) {\n state.group = FeatureGroup.Guanidine\n addGroup = true\n } else if (isAcetamidine(a)) {\n state.group = FeatureGroup.Acetamidine\n addGroup = true\n }\n if (addGroup) {\n a.eachBondedAtom(a => {\n if (a.number === Elements.N) {\n atomInGroupDict[a.index] = true\n addAtom(state, a)\n }\n })\n addFeature(features, state)\n }\n })\n r.eachAtom(a => {\n const state = createFeatureState(FeatureType.PositiveCharge)\n if (charge[a.index] > 0) {\n if (!atomInGroupDict[a.index]) {\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n })\n }\n })\n}\n\nexport function addNegativeCharges (structure: Structure, features: Features) {\n const { charge } = valenceModel(structure.data)\n const atomInGroupDict: { [atomIndex: number]: true } = {}\n\n structure.eachResidue(r => {\n if (NegativelyCharged.includes(r.resname)) {\n const state = createFeatureState(FeatureType.NegativeCharge)\n r.eachAtom(a => {\n if (a.number === Elements.O && a.isSidechain()) {\n addAtom(state, a)\n }\n })\n addFeature(features, state)\n } else if (Bases.includes(r.resname)) {\n const state = createFeatureState(FeatureType.NegativeCharge)\n r.eachAtom(a => {\n if (isPhosphate(a)) {\n state.group = FeatureGroup.Phosphate\n a.eachBondedAtom(a => {\n if (a.number === Elements.O) addAtom(state, a)\n })\n addFeature(features, state)\n }\n })\n } else if(!AA3.includes(r.resname) && !Bases.includes(r.resname)) {\n r.eachAtom(a => {\n let addGroup = false\n const state = createFeatureState(FeatureType.NegativeCharge)\n if (isSulfonicAcid(a)) {\n state.group = FeatureGroup.SulfonicAcid\n addGroup = true\n } else if (isPhosphate(a)) {\n state.group = FeatureGroup.Phosphate\n addGroup = true\n } else if (isSulfate(a)) {\n state.group = FeatureGroup.Sulfate\n addGroup = true\n } else if (isCarboxylate(a)) {\n state.group = FeatureGroup.Carboxylate\n addGroup = true\n }\n if (addGroup) {\n a.eachBondedAtom(a => {\n if (a.number === Elements.O) {\n atomInGroupDict[a.index] = true\n addAtom(state, a)\n }\n })\n addFeature(features, state)\n }\n })\n r.eachAtom(a => {\n const state = createFeatureState(FeatureType.NegativeCharge)\n if (charge[a.index] < 0) {\n if (!atomInGroupDict[a.index]) {\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n })\n }\n })\n}\n\nexport function addAromaticRings (structure: Structure, features: Features) {\n const a = structure.getAtomProxy()\n structure.eachResidue(r => {\n const rings = r.getAromaticRings()\n if (rings) {\n const offset = r.atomOffset\n rings.forEach(ring => {\n const state = createFeatureState(FeatureType.AromaticRing)\n ring.forEach(i => {\n a.index = i + offset\n addAtom(state, a)\n })\n addFeature(features, state)\n })\n }\n })\n}\n\nfunction isIonicInteraction (ti: FeatureType, tj: FeatureType) {\n return (\n (ti === FeatureType.NegativeCharge && tj === FeatureType.PositiveCharge) ||\n (ti === FeatureType.PositiveCharge && tj === FeatureType.NegativeCharge)\n )\n}\n\nfunction isPiStacking (ti: FeatureType, tj: FeatureType) {\n return ti === FeatureType.AromaticRing && tj === FeatureType.AromaticRing\n}\n\nfunction isCationPi (ti: FeatureType, tj: FeatureType) {\n return (\n (ti === FeatureType.AromaticRing && tj === FeatureType.PositiveCharge) ||\n (ti === FeatureType.PositiveCharge && tj === FeatureType.AromaticRing)\n )\n}\n\nexport interface ChargedContactsParams {\n maxIonicDist?: number\n maxPiStackingDist?: number\n maxPiStackingOffset?: number\n maxPiStackingAngle?: number\n maxCationPiDist?: number\n maxCationPiOffset?: number\n masterModelIndex?: number\n}\n\nexport function addChargedContacts (structure: Structure, contacts: Contacts, params: ChargedContactsParams = {}) {\n const maxIonicDist = defaults(params.maxIonicDist, ContactDefaultParams.maxIonicDist)\n const maxPiStackingDist = defaults(params.maxPiStackingDist, ContactDefaultParams.maxPiStackingDist)\n const maxPiStackingOffset = defaults(params.maxPiStackingOffset, ContactDefaultParams.maxPiStackingOffset)\n const maxPiStackingAngle = defaults(params.maxPiStackingAngle, ContactDefaultParams.maxPiStackingAngle)\n const maxCationPiDist = defaults(params.maxCationPiDist, ContactDefaultParams.maxCationPiDist)\n const maxCationPiOffset = defaults(params.maxCationPiOffset, ContactDefaultParams.maxCationPiOffset)\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const maxDistance = Math.max(maxIonicDist + 2, maxPiStackingDist, maxCationPiDist)\n // const maxSaltBridgeDistSq = maxSaltBridgeDist * maxSaltBridgeDist\n const maxPiStackingDistSq = maxPiStackingDist * maxPiStackingDist\n const maxCationPiDistSq = maxCationPiDist * maxCationPiDist\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const ax = structure.atomStore.x\n const ay = structure.atomStore.y\n const az = structure.atomStore.z\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n const areAtomSetsWithinDist = function (atomSet1: number[], atomSet2: number[], maxDist: number) {\n const sn = atomSet1.length\n const sm = atomSet2.length\n for (let si = 0; si < sn; ++si) {\n ap1.index = atomSet1[ si ]\n for (let sj = 0; sj < sm; ++sj) {\n ap2.index = atomSet2[ sj ]\n if (ap1.distanceTo(ap2) <= maxDist) {\n return true\n }\n }\n }\n return false\n }\n\n const v1 = new Vector3()\n const v2 = new Vector3()\n const v3 = new Vector3()\n const d1 = new Vector3()\n const d2 = new Vector3()\n const n1 = new Vector3()\n const n2 = new Vector3()\n\n const getNormal = function (atoms: number[], normal: Vector3) {\n v1.set(ax[ atoms[ 0 ] ], ay[ atoms[ 0 ] ], az[ atoms[ 0 ] ])\n v2.set(ax[ atoms[ 1 ] ], ay[ atoms[ 1 ] ], az[ atoms[ 1 ] ])\n v3.set(ax[ atoms[ 2 ] ], ay[ atoms[ 2 ] ], az[ atoms[ 2 ] ])\n d1.subVectors(v1, v2)\n d2.subVectors(v1, v3)\n normal.crossVectors(d1, d2)\n }\n\n const getOffset = function (i: number, j: number, normal: Vector3) {\n v1.set(x[ i ], y[ i ], z[ i ])\n v2.set(x[ j ], y[ j ], z[ j ])\n return v1.sub(v2).projectOnPlane(normal).add(v2).distanceTo(v2)\n }\n\n const add = function (i: number, j: number, ct: ContactType) {\n featureSet.setBits(i, j)\n contactStore.addContact(i, j, ct)\n }\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxDistance, (j, dSq) => {\n if (j <= i) return\n\n ap1.index = atomSets[ i ][ 0 ]\n ap2.index = atomSets[ j ][ 0 ]\n\n if (invalidAtomContact(ap1, ap2, masterIdx)) return\n\n const ti = types[ i ]\n const tj = types[ j ]\n\n if (isIonicInteraction(ti, tj)) {\n if (areAtomSetsWithinDist(atomSets[ i ], atomSets[ j ], maxIonicDist)) {\n add(i, j, ContactType.IonicInteraction)\n }\n } else if (isPiStacking(ti, tj)) {\n if (dSq <= maxPiStackingDistSq) {\n getNormal(atomSets[ i ], n1)\n getNormal(atomSets[ j ], n2)\n\n const angle = radToDeg(n1.angleTo(n2))\n const offset = Math.min(getOffset(i, j, n2), getOffset(j, i, n1))\n if (offset <= maxPiStackingOffset) {\n if (angle <= maxPiStackingAngle || angle >= 180 - maxPiStackingAngle) {\n add(i, j, ContactType.PiStacking) // parallel\n } else if (angle <= maxPiStackingAngle + 90 && angle >= 90 - maxPiStackingAngle) {\n add(i, j, ContactType.PiStacking) // t-shaped\n }\n }\n }\n } else if (isCationPi(ti, tj)) {\n if (dSq <= maxCationPiDistSq) {\n const [ l, k ] = ti === FeatureType.AromaticRing ? [ i, j ] : [ j, i ]\n\n getNormal(atomSets[ l ], n1)\n const offset = getOffset(k, l, n1)\n if (offset <= maxCationPiOffset) {\n add(l, k, ContactType.CationPi)\n }\n }\n }\n })\n }\n}\n","/**\n * @file Hydrogen Bonds\n * @author Alexander Rose \n * @author Fred Ludlow \n */\nimport { defaults } from '../../utils'\nimport { degToRad } from '../../math/math-utils'\nimport Structure from '../../structure/structure'\nimport AtomProxy from '../../proxy/atom-proxy'\nimport { valenceModel } from '../../structure/data'\nimport { Elements } from '../../structure/structure-constants'\nimport { Angles, AtomGeometry, calcAngles, calcPlaneAngle } from '../geometry'\nimport {\n Features, FeatureType,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\n\n\n// Geometric characteristics of hydrogen bonds involving sulfur atoms in proteins\n// https://doi.org/10.1002/prot.22327\n\n// Satisfying Hydrogen Bonding Potential in Proteins (HBPLUS)\n// https://doi.org/10.1006/jmbi.1994.1334\n// http://www.csb.yale.edu/userguides/datamanip/hbplus/hbplus_descrip.html\n\n/**\n * Potential hydrogen donor\n */\nexport function addHydrogenDonors (structure: Structure, features: Features) {\n const { totalH } = valenceModel(structure.data)\n\n structure.eachAtom(a => {\n const state = createFeatureState(FeatureType.HydrogenDonor)\n\n const an = a.number\n if (isHistidineNitrogen(a)) {\n // include both nitrogen atoms in histidine due to\n // their often ambiguous protonation assignment\n addAtom(state, a)\n addFeature(features, state)\n } else if (\n totalH[ a.index ] > 0 &&\n (an === Elements.N || an === Elements.O || an === Elements.S)\n ) {\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\n/**\n * Weak hydrogen donor.\n */\nexport function addWeakHydrogenDonors (structure: Structure, features: Features) {\n const { totalH } = valenceModel(structure.data)\n\n structure.eachAtom(a => {\n if (\n a.number === Elements.C &&\n totalH[ a.index ] > 0 &&\n (\n a.bondToElementCount(Elements.N) > 0 ||\n a.bondToElementCount(Elements.O) > 0 ||\n inAromaticRingWithElectronNegativeElement(a)\n )\n ) {\n const state = createFeatureState(FeatureType.WeakHydrogenDonor)\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\nfunction inAromaticRingWithElectronNegativeElement (a: AtomProxy) {\n if (!a.isAromatic()) return false\n\n const ringData = a.residueType.getRings()\n if (!ringData) return false\n\n let hasElement = false\n const rings = ringData.rings\n rings.forEach(ring => {\n if (hasElement) return // already found one\n if (ring.some(idx => (a.index - a.residueAtomOffset) === idx)) { // in ring\n hasElement = ring.some(idx => {\n const atomTypeId = a.residueType.atomTypeIdList[ idx ]\n const number = a.atomMap.get(atomTypeId).number\n return number === Elements.N || number === Elements.O\n })\n }\n })\n\n return hasElement\n}\n\n/**\n * Potential hydrogen acceptor\n */\nexport function addHydrogenAcceptors (structure: Structure, features: Features) {\n const { charge, implicitH, idealGeometry } = valenceModel(structure.data)\n\n structure.eachAtom(a => {\n const state = createFeatureState(FeatureType.HydrogenAcceptor)\n\n const an = a.number\n if (an === Elements.O) {\n // Basically assume all oxygen atoms are acceptors!\n addAtom(state, a)\n addFeature(features, state)\n }else if (an === Elements.N) {\n if (isHistidineNitrogen(a)) {\n // include both nitrogen atoms in histidine due to\n // their often ambiguous protonation assignment\n addAtom(state, a)\n addFeature(features, state)\n } else if (charge[ a.index ] < 1){\n // Neutral nitrogen might be an acceptor\n // It must have at least one lone pair not conjugated\n const totalBonds = a.bondCount + implicitH[ a.index ]\n const ig = idealGeometry[ a.index ]\n if (\n (ig === AtomGeometry.Tetrahedral && totalBonds < 4) ||\n (ig === AtomGeometry.Trigonal && totalBonds < 3) ||\n (ig === AtomGeometry.Linear && totalBonds < 2)\n ) {\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n }else if (an === 16) { // S\n if (a.resname === 'CYS' || a.resname === 'MET' || a.formalCharge === -1) {\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n })\n}\n\n/**\n * Atom that is only bound to carbon or hydrogen\n */\n// function isHydrocarbon (atom: AtomProxy) {\n// let flag = true\n// atom.eachBondedAtom(ap => {\n// const e = ap.element\n// if (e !== 'C' && e !== 'H') flag = false\n// })\n// return flag\n// }\n\nfunction isHistidineNitrogen (ap: AtomProxy) {\n return ap.resname === 'HIS' && ap.number == Elements.N && ap.isRing()\n}\n\nfunction isBackboneHydrogenBond (ap1: AtomProxy, ap2: AtomProxy) {\n return ap1.isBackbone() && ap2.isBackbone()\n}\n\nfunction isWaterHydrogenBond (ap1: AtomProxy, ap2: AtomProxy) {\n return ap1.isWater() && ap2.isWater()\n}\n\nfunction isHydrogenBond (ti: FeatureType, tj: FeatureType) {\n return (\n (ti === FeatureType.HydrogenAcceptor && tj === FeatureType.HydrogenDonor) ||\n (ti === FeatureType.HydrogenDonor && tj === FeatureType.HydrogenAcceptor)\n )\n}\n\nfunction isWeakHydrogenBond (ti: FeatureType, tj: FeatureType){\n return (\n (ti === FeatureType.WeakHydrogenDonor && tj === FeatureType.HydrogenAcceptor) ||\n (ti === FeatureType.HydrogenAcceptor && tj === FeatureType.WeakHydrogenDonor)\n )\n}\n\nfunction getHydrogenBondType (ap1: AtomProxy, ap2: AtomProxy) {\n if (isWaterHydrogenBond(ap1, ap2)) {\n return ContactType.WaterHydrogenBond\n } else if (isBackboneHydrogenBond(ap1, ap2)) {\n return ContactType.BackboneHydrogenBond\n } else {\n return ContactType.HydrogenBond\n }\n}\n\nexport interface HydrogenBondParams {\n maxHbondDist?: number\n maxHbondSulfurDist?: number\n maxHbondAccAngle?: number\n maxHbondDonAngle?: number\n maxHbondAccPlaneAngle?: number\n maxHbondDonPlaneAngle?: number\n backboneHbond?: boolean\n waterHbond?: boolean\n masterModelIndex?: number\n}\n\n/**\n * All pairs of hydrogen donor and acceptor atoms\n */\nexport function addHydrogenBonds (structure: Structure, contacts: Contacts, params: HydrogenBondParams = {}) {\n const maxHbondDist = defaults(params.maxHbondDist, ContactDefaultParams.maxHbondDist)\n const maxHbondSulfurDist = defaults(params.maxHbondSulfurDist, ContactDefaultParams.maxHbondSulfurDist)\n const maxHbondAccAngle = degToRad(defaults(params.maxHbondAccAngle, ContactDefaultParams.maxHbondAccAngle))\n const maxHbondDonAngle = degToRad(defaults(params.maxHbondDonAngle, ContactDefaultParams.maxHbondDonAngle))\n const maxHbondAccPlaneAngle = degToRad(defaults(params.maxHbondAccPlaneAngle, ContactDefaultParams.maxHbondAccPlaneAngle))\n const maxHbondDonPlaneAngle = degToRad(defaults(params.maxHbondDonPlaneAngle, ContactDefaultParams.maxHbondDonPlaneAngle))\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const maxDist = Math.max(maxHbondDist, maxHbondSulfurDist)\n const maxHbondDistSq = maxHbondDist * maxHbondDist\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const { idealGeometry } = valenceModel(structure.data)\n\n const donor = structure.getAtomProxy()\n const acceptor = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxDist, (j, dSq) => {\n if (j <= i) return\n\n const ti = types[ i ]\n const tj = types[ j ]\n\n const isWeak = isWeakHydrogenBond(ti, tj)\n if (!isWeak && !isHydrogenBond(ti, tj)) return\n\n const [ l, k ] = tj === FeatureType.HydrogenAcceptor ? [ i, j ] : [ j, i ]\n\n donor.index = atomSets[ l ][ 0 ]\n acceptor.index = atomSets[ k ][ 0 ]\n\n if (acceptor.index === donor.index) return // DA to self\n\n if (invalidAtomContact(donor, acceptor, masterIdx)) return\n if (donor.number !== Elements.S && acceptor.number !== Elements.S && dSq > maxHbondDistSq) return\n if (donor.connectedTo(acceptor)) return\n\n const donorAngles = calcAngles(donor, acceptor)\n const idealDonorAngle = Angles.get(idealGeometry[donor.index]) || degToRad(120)\n if (donorAngles.some(donorAngle => {\n return Math.abs(idealDonorAngle - donorAngle) > maxHbondDonAngle\n })) return\n\n if (idealGeometry[donor.index] === AtomGeometry.Trigonal){\n const outOfPlane = calcPlaneAngle(donor, acceptor)\n if (outOfPlane !== undefined && outOfPlane > maxHbondDonPlaneAngle) return\n }\n\n const acceptorAngles = calcAngles(acceptor, donor)\n const idealAcceptorAngle = Angles.get(idealGeometry[acceptor.index]) || degToRad(120)\n if (acceptorAngles.some(acceptorAngle => {\n // Do not limit large acceptor angles\n return idealAcceptorAngle - acceptorAngle > maxHbondAccAngle\n })) return\n\n if (idealGeometry[acceptor.index] === AtomGeometry.Trigonal){\n const outOfPlane = calcPlaneAngle(acceptor, donor)\n if (outOfPlane !== undefined && outOfPlane > maxHbondAccPlaneAngle) return\n }\n\n featureSet.setBits(l, k)\n const bondType = isWeak ? ContactType.WeakHydrogenBond : getHydrogenBondType(donor, acceptor)\n contactStore.addContact(l, k, bondType)\n })\n }\n}\n","/**\n * @file Metal Binding\n * @author Alexander Rose \n */\n\nimport { defaults } from '../../utils'\nimport Structure from '../../structure/structure'\n// import { valenceModel } from '../../structure/data'\nimport { Elements, AA3, Bases } from '../../structure/structure-constants'\n// import { hasAromaticNeighbour } from '../functional-groups'\nimport {\n Features, FeatureType,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\n\nconst IonicTypeMetals = [\n Elements.LI, Elements.NA, Elements.K, Elements.RB, Elements.CS,\n Elements.MG, Elements.CA, Elements.SR, Elements.BA, Elements.AL,\n Elements.GA, Elements.IN, Elements.TL, Elements.SC, Elements.SN,\n Elements.PB, Elements.BI, Elements.SB, Elements.HG\n]\n\n/**\n * Metal binding partners (dative bond or ionic-type interaction)\n */\nexport function addMetalBinding (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n let dative = false\n let ionic = false\n\n const isStandardAminoacid = AA3.includes(a.resname)\n const isStandardBase = Bases.includes(a.resname)\n\n if (!isStandardAminoacid && !isStandardBase) {\n if (a.isHalogen() || a.number === Elements.O || a.number === Elements.S) {\n dative = true\n ionic = true\n } else if (a.number === Elements.N) {\n dative = true\n }\n } else if (isStandardAminoacid){\n // main chain oxygen atom or oxygen, nitrogen and sulfur from specific amino acids\n if (a.number === Elements.O) {\n if(['ASP', 'GLU', 'SER', 'THR', 'TYR', 'ASN', 'GLN'].includes(a.resname) && a.isSidechain()) {\n dative = true\n ionic = true\n } else if (a.isBackbone()) {\n dative = true\n ionic = true\n }\n } else if (a.number === Elements.S && 'CYS' === a.resname) {\n dative = true\n ionic = true\n } else if (a.number === Elements.N) {\n if(a.resname === 'HIS' && a.isSidechain()) {\n dative = true\n }\n }\n } else if (isStandardBase){\n // http://pubs.acs.org/doi/pdf/10.1021/acs.accounts.6b00253\n // http://onlinelibrary.wiley.com/doi/10.1002/anie.200900399/full\n if (a.number === Elements.O && a.isBackbone()) {\n dative = true\n ionic = true\n } else if(['N3', 'N4', 'N7'].includes(a.atomname)) {\n dative = true\n } else if(['O2', 'O4', 'O6'].includes(a.atomname)) {\n dative = true\n ionic = true\n }\n }\n if (dative) {\n const state = createFeatureState(FeatureType.DativeBondPartner)\n addAtom(state, a)\n addFeature(features, state)\n }\n if (ionic) {\n const state = createFeatureState(FeatureType.IonicTypePartner)\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\n/**\n * Metal Pi complexation partner\n */\n// export function addMetalPiPartners (structure: Structure, features: Features) {\n// const { charge } = valenceModel(structure.data)\n\n// structure.eachAtom(a => {\n// const state = createFeatureState(FeatureType.MetalPiPartner)\n\n// const resname = a.resname\n// const element = a.element\n// const atomname = a.atomname\n// if (!a.isPolymer()) {\n// // water oxygen, as well as oxygen from carboxylate, phosphoryl, phenolate, alcohol;\n// // nitrogen from imidazole; sulfur from thiolate\n// if (element === 'O') {\n// // Water oxygen\n// if (a.bondCount === 0 || a.isWater()) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// // Oxygen in alcohol (R-[O]-H)\n// if (a.bondCount === 2 && charge[ a.index ] || a.hasBondToElement('H')) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// // Phenolate oxygen\n// if (hasAromaticNeighbour(a) && !a.aromatic) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// // Carboxylic acid oxygen\n// if (a.bondToElementCount('C') === 1) {\n// let flag = false\n// a.eachBondedAtom(ba => {\n// if (ba.element === 'C' && ba.bondToElementCount('O') === 2 && ba.bondToElementCount('C') === 1) {\n// flag = true\n// }\n// })\n// if (flag) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// }\n// // Phosphoryl oxygen\n// if (a.bondToElementCount('P') === 1) {\n// let flag = false\n// a.eachBondedAtom(ba => {\n// if (ba.element === 'P' && ba.bondToElementCount('O') >= 3) {\n// flag = true\n// }\n// })\n// if (flag) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// }\n// } else if (element === 'N') {\n// // Imidazole/pyrrole or similar\n// if (a.bondToElementCount('C') === 2) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// } else if (element === 'S') {\n// // Thiolate\n// if (hasAromaticNeighbour(a) && !a.aromatic) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// // Sulfur in Iron sulfur cluster\n// const ironCount = a.bondToElementCount('FE')\n// if (ironCount > 0 && ironCount === a.bondCount) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// }\n// }\n// })\n// }\n\nexport function addMetals (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n if (a.isTransitionMetal() || a.number === Elements.ZN || a.number === Elements.CD) {\n const state = createFeatureState(FeatureType.TransitionMetal)\n addAtom(state, a)\n addFeature(features, state)\n } else if (IonicTypeMetals.includes(a.number)) {\n const state = createFeatureState(FeatureType.IonicTypeMetal)\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\nfunction isMetalComplex (ti: FeatureType, tj: FeatureType) {\n if (ti === FeatureType.TransitionMetal) {\n return (\n tj === FeatureType.DativeBondPartner ||\n tj === FeatureType.TransitionMetal\n )\n } else if (ti === FeatureType.IonicTypeMetal) {\n return (\n tj === FeatureType.IonicTypePartner\n )\n }\n}\n\nexport interface MetalComplexationParams {\n maxMetalDist?: number\n masterModelIndex?: number\n}\n\n/**\n * Metal complexes of metals and appropriate groups in protein and ligand, including water\n */\nexport function addMetalComplexation (structure: Structure, contacts: Contacts, params: MetalComplexationParams = {}) {\n const maxMetalDist = defaults(params.maxMetalDist, ContactDefaultParams.maxMetalDist)\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxMetalDist, (j, dSq) => {\n if (j <= i) return\n\n ap1.index = atomSets[ i ][ 0 ]\n ap2.index = atomSets[ j ][ 0 ]\n\n if (invalidAtomContact(ap1, ap2, masterIdx)) return\n\n const m1 = ap1.isMetal()\n const m2 = ap2.isMetal()\n if (!m1 && !m2) return\n\n const [ ti, tj ] = m1 ? [ types[ i ],types[ j ] ] : [ types[ j ],types[ i ] ]\n\n if (isMetalComplex(ti, tj)) {\n featureSet.setBits(i, j)\n contactStore.addContact(i, j, ContactType.MetalCoordination)\n }\n })\n }\n}\n","/**\n * @file Halogen Bonds\n * @author Alexander Rose \n * @author Fred Ludlow \n */\n\nimport { defaults } from '../../utils'\nimport Structure from '../../structure/structure'\nimport { Elements } from '../../structure/structure-constants'\nimport { degToRad } from '../../math/math-utils'\nimport {\n Features, FeatureType,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\nimport { calcAngles } from '../geometry'\n\nconst halBondElements = [17, 35, 53, 85]\n\n/**\n * Halogen bond donors (X-C, with X one of Cl, Br, I or At) not F!\n */\nexport function addHalogenDonors (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n if (halBondElements.includes(a.number) && a.bondToElementCount(Elements.C) === 1) {\n const state = createFeatureState(FeatureType.HalogenDonor)\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\nconst X = [ Elements.N, Elements.O, Elements.S ]\nconst Y = [ Elements.C, Elements.N, Elements.P, Elements.S ]\n\n/**\n * Halogen bond acceptors (Y-{O|N|S}, with Y=C,P,N,S)\n */\nexport function addHalogenAcceptors (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n if (X.includes(a.number)) {\n let flag = false\n a.eachBondedAtom(ba => {\n if (Y.includes(ba.number)) {\n flag = true\n }\n })\n if (flag) {\n const state = createFeatureState(FeatureType.HalogenAcceptor)\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n })\n}\n\nfunction isHalogenBond (ti: FeatureType, tj: FeatureType) {\n return (\n (ti === FeatureType.HalogenAcceptor && tj === FeatureType.HalogenDonor) ||\n (ti === FeatureType.HalogenDonor && tj === FeatureType.HalogenAcceptor)\n )\n}\n\nexport interface HalogenBondsParams {\n maxHalogenBondDist?: number\n maxHalogenBondAngle?: number\n masterModelIndex?: number\n}\n\n// http://www.pnas.org/content/101/48/16789.full\nconst OptimalHalogenAngle = degToRad(180) // adjusted from 165 to account for spherical statistics\nconst OptimalAcceptorAngle = degToRad(120)\n\n/**\n * All pairs of halogen donor and acceptor atoms\n */\nexport function addHalogenBonds (structure: Structure, contacts: Contacts, params: HalogenBondsParams = {}) {\n const maxHalogenBondDist = defaults(params.maxHalogenBondDist, ContactDefaultParams.maxHalogenBondDist)\n const maxHalogenBondAngle = degToRad(defaults(params.maxHalogenBondAngle, ContactDefaultParams.maxHalogenBondAngle))\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxHalogenBondDist, (j, dSq) => {\n if (j <= i) return\n\n ap1.index = atomSets[ i ][ 0 ]\n ap2.index = atomSets[ j ][ 0 ]\n\n if (invalidAtomContact(ap1, ap2, masterIdx)) return\n if (!isHalogenBond(types[ i ], types[ j ])) return\n\n const [ halogen, acceptor ] = types[ i ] === FeatureType.HalogenDonor ? [ ap1, ap2 ] : [ ap2, ap1 ]\n\n const halogenAngles = calcAngles(halogen, acceptor)\n // Singly bonded halogen only (not bromide ion for example)\n if (halogenAngles.length !== 1) return\n if (OptimalHalogenAngle - halogenAngles[0] > maxHalogenBondAngle) return\n\n const acceptorAngles = calcAngles(acceptor, halogen)\n // Angle must be defined. Excludes water as acceptor. Debatable\n if (acceptorAngles.length === 0) return\n if (acceptorAngles.some(acceptorAngle => {\n return (OptimalAcceptorAngle - acceptorAngle > maxHalogenBondAngle)\n })) return\n\n\n featureSet.setBits(i, j)\n contactStore.addContact(i, j, ContactType.HalogenBond)\n\n })\n }\n}\n","/**\n * @file Refine Contacts\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { Debug, Log } from '../../globals'\nimport { defaults } from '../../utils'\nimport Structure from '../../structure/structure'\nimport AtomProxy from '../../proxy/atom-proxy'\nimport { Elements } from '../../structure/structure-constants'\nimport { FrozenContacts, ContactType, ContactDefaultParams, isMasterContact } from './contact'\nimport { FeatureType } from './features'\n\nexport interface LineOfSightParams {\n lineOfSightDistFactor?: number\n masterModelIndex?: number\n}\n\n// also allows intra-residue contacts\nexport function invalidAtomContact (ap1: AtomProxy, ap2: AtomProxy, masterIdx: number) {\n return !isMasterContact(ap1, ap2, masterIdx) && (\n ap1.modelIndex !== ap2.modelIndex ||\n (ap1.altloc && ap2.altloc && ap1.altloc !== ap2.altloc)\n )\n}\n\nexport function refineLineOfSight (structure: Structure, contacts: FrozenContacts, params: LineOfSightParams = {}) {\n if (Debug) Log.time('refineLineOfSight')\n\n const lineOfSightDistFactor = defaults(params.lineOfSightDistFactor, ContactDefaultParams.lineOfSightDistFactor)\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const spatialHash = structure.spatialHash!\n const { contactSet, contactStore, features } = contacts\n const { index1, index2 } = contactStore\n const { centers, atomSets } = features\n const { x, y, z } = centers\n\n const ac1 = structure.getAtomProxy()\n const ac2 = structure.getAtomProxy()\n const aw = structure.getAtomProxy()\n\n const c1 = new Vector3()\n const c2 = new Vector3()\n\n const lineOfSightDist = 3 * lineOfSightDistFactor\n const lineOfSightDistFactorSq = lineOfSightDistFactor * lineOfSightDistFactor\n\n contactSet.forEach(i => {\n c1.set(x[index1[i]], y[index1[i]], z[index1[i]])\n c2.set(x[index2[i]], y[index2[i]], z[index2[i]])\n\n const cx = ( c1.x + c2.x ) / 2\n const cy = ( c1.y + c2.y ) / 2\n const cz = ( c1.z + c2.z ) / 2\n\n const as1 = atomSets[ index1[ i ] ]\n const as2 = atomSets[ index2[ i ] ]\n\n ac1.index = as1[ 0 ]\n ac2.index = as2[ 0 ]\n\n spatialHash.eachWithin(cx, cy, cz, lineOfSightDist, (j, dSq) => {\n aw.index = j\n if (\n aw.number !== Elements.H &&\n (aw.vdw * aw.vdw * lineOfSightDistFactorSq) > dSq &&\n !invalidAtomContact(ac1, aw, masterIdx) &&\n !invalidAtomContact(ac2, aw, masterIdx) &&\n !as1.includes(j) &&\n !as2.includes(j) &&\n // to ignore atoms in the center of functional groups\n c1.distanceToSquared(aw as any) > 1 &&\n c2.distanceToSquared(aw as any) > 1\n ) {\n contactSet.clear(i)\n if (Debug) Log.log('removing', ac1.qualifiedName(), ac2.qualifiedName(), 'because', aw.qualifiedName())\n }\n })\n })\n\n if (Debug) Log.timeEnd('refineLineOfSight')\n}\n\n/**\n * For atoms interacting with several atoms in the same residue\n * only the one with the closest distance is kept.\n */\nexport function refineHydrophobicContacts (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features } = contacts\n const { type, index1, index2 } = contactStore\n const { atomSets } = features\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n const residueContactDict: { [k: string]: number[] } = {}\n\n /* keep only closest contact between residues */\n const handleResidueContact = function (dist: number, i: number, key: string) {\n const [ minDist, minIndex ] = residueContactDict[ key ] || [ Infinity, -1 ]\n if (dist < minDist) {\n if (minIndex !== -1) contactSet.clear(minIndex)\n residueContactDict[ key ] = [ dist, i ]\n } else {\n contactSet.clear(i)\n }\n }\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.Hydrophobic) return\n\n ap1.index = atomSets[ index1[ i ] ][ 0 ]\n ap2.index = atomSets[ index2[ i ] ][ 0 ]\n\n const dist = ap1.distanceTo(ap2)\n handleResidueContact(dist, i, `${ap1.index}|${ap2.residueIndex}`)\n handleResidueContact(dist, i, `${ap2.index}|${ap1.residueIndex}`)\n })\n}\n\nfunction isHydrogenBondType (type: number) {\n return (\n type === ContactType.HydrogenBond ||\n type === ContactType.WaterHydrogenBond ||\n type === ContactType.BackboneHydrogenBond\n )\n}\n\n/**\n * Remove weak hydrogen bonds when the acceptor is involved in\n * a normal/strong hydrogen bond\n */\nexport function refineWeakHydrogenBonds (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features, adjacencyList } = contacts\n const { type, index1, index2 } = contactStore\n const { types } = features\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.WeakHydrogenBond) return\n\n let accFeat: number\n if (types[ index1[ i ] ] === FeatureType.WeakHydrogenDonor) {\n accFeat = index2[ i ]\n } else {\n accFeat = index1[ i ]\n }\n\n const n = adjacencyList.countArray[ accFeat ]\n const offset = adjacencyList.offsetArray[ accFeat ]\n for (let j = 0; j < n; ++j) {\n const ci = adjacencyList.indexArray[ offset + j ]\n if (isHydrogenBondType(type[ ci ])) {\n contactSet.clear(i)\n return\n }\n }\n })\n}\n\n/**\n * Remove hydrogen bonds between groups that also form\n * a salt bridge between each other\n */\nexport function refineSaltBridges (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features } = contacts\n const { type, index1, index2 } = contactStore\n const { atomSets } = features\n\n const ionicInteractionDict: { [atomIndex: number]: number[] } = {}\n\n const add = function(idx: number, i: number) {\n if (!ionicInteractionDict[ idx ]) ionicInteractionDict[ idx ] = []\n ionicInteractionDict[ idx ].push(i)\n }\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.IonicInteraction) return\n atomSets[ index1[ i ] ].forEach(idx => add(idx, i))\n atomSets[ index2[ i ] ].forEach(idx => add(idx, i))\n })\n\n contactSet.forEach(i => {\n if (!isHydrogenBondType(type[ i ])) return\n\n const iil1 = ionicInteractionDict[ atomSets[ index1[ i ] ][ 0 ] ]\n const iil2 = ionicInteractionDict[ atomSets[ index2[ i ] ][ 0 ] ]\n if (!iil1 || !iil2) return\n\n const n = iil1.length\n for (let j = 0; j < n; ++j) {\n if (iil2.includes(iil1[j])) {\n contactSet.clear(i)\n return\n }\n }\n })\n}\n\n/**\n * Remove hydrophobic and cation-pi interactions between groups that also form\n * a pi-stacking interaction between each other\n */\nexport function refinePiStacking (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features } = contacts\n const { type, index1, index2 } = contactStore\n const { atomSets } = features\n\n const piStackingDict: { [atomIndex: number]: number[] } = {}\n\n const add = function(idx: number, i: number) {\n if (!piStackingDict[ idx ]) piStackingDict[ idx ] = []\n piStackingDict[ idx ].push(i)\n }\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.PiStacking) return\n atomSets[ index1[ i ] ].forEach(idx => add(idx, i))\n atomSets[ index2[ i ] ].forEach(idx => add(idx, i))\n })\n\n contactSet.forEach(i => {\n if (\n type[ i ] !== ContactType.Hydrophobic &&\n type[ i ] !== ContactType.CationPi\n ) return\n\n const pil1 = piStackingDict[ atomSets[ index1[ i ] ][ 0 ] ]\n const pil2 = piStackingDict[ atomSets[ index2[ i ] ][ 0 ] ]\n if (!pil1 || !pil2) return\n\n const n = pil1.length\n for (let j = 0; j < n; ++j) {\n if (pil2.includes(pil1[j])) {\n contactSet.clear(i)\n return\n }\n }\n })\n}\n\n/**\n * Remove ionic interactions between groups that also form\n * a metal coordination between each other\n */\nexport function refineMetalCoordination (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features } = contacts\n const { type, index1, index2 } = contactStore\n const { atomSets } = features\n\n const ionicInteractionDict: { [atomIndex: number]: number[] } = {}\n\n const add = function(idx: number, i: number) {\n if (!ionicInteractionDict[ idx ]) ionicInteractionDict[ idx ] = []\n ionicInteractionDict[ idx ].push(i)\n }\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.IonicInteraction) return\n atomSets[ index1[ i ] ].forEach(idx => add(idx, i))\n atomSets[ index2[ i ] ].forEach(idx => add(idx, i))\n })\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.MetalCoordination) return\n\n const iil1 = ionicInteractionDict[ atomSets[ index1[ i ] ][ 0 ] ]\n const iil2 = ionicInteractionDict[ atomSets[ index2[ i ] ][ 0 ] ]\n if (!iil1 || !iil2) return\n\n const n = iil1.length\n for (let j = 0; j < n; ++j) {\n if (iil2.includes(iil1[j])) {\n contactSet.clear(iil1[j])\n return\n }\n }\n })\n}\n\n// TODO: refactor refineSaltBridges, refinePiStacking and refineMetalCoordination to be DRY\n","/**\n * @file Contact\n * @author Alexander Rose \n */\n\nimport { Color } from 'three'\n\nimport { Debug, Log } from '../../globals'\nimport { createParams } from '../../utils'\nimport { TextBufferData } from '../../buffer/text-buffer'\nimport Structure from '../../structure/structure'\nimport AtomProxy from '../../proxy/atom-proxy'\nimport SpatialHash from '../../geometry/spatial-hash'\nimport { calculateCenterArray, calculateDirectionArray, uniformArray } from '../../math/array-utils'\nimport ContactStore from '../../store/contact-store'\nimport BitArray from '../../utils/bitarray'\nimport Selection from '../../selection/selection'\nimport { ContactPicker } from '../../utils/picker'\nimport { createAdjacencyList, AdjacencyList } from '../../utils/adjacency-list'\nimport { createFeatures, Features } from './features'\nimport { addAromaticRings, addNegativeCharges, addPositiveCharges, addChargedContacts } from './charged'\nimport { addHydrogenAcceptors, addHydrogenDonors, addHydrogenBonds, addWeakHydrogenDonors } from './hydrogen-bonds'\nimport { addMetalBinding, addMetals, addMetalComplexation } from './metal-binding'\nimport { addHydrophobic, addHydrophobicContacts } from './hydrophobic'\nimport { addHalogenAcceptors, addHalogenDonors, addHalogenBonds } from './halogen-bonds'\nimport {\n refineLineOfSight,\n refineHydrophobicContacts, refineSaltBridges, refinePiStacking, refineMetalCoordination\n} from './refine-contacts'\n\nexport interface Contacts {\n features: Features\n spatialHash: SpatialHash\n contactStore: ContactStore\n featureSet: BitArray\n}\n\nexport interface FrozenContacts extends Contacts {\n contactSet: BitArray\n adjacencyList: AdjacencyList\n}\n\nexport const enum ContactType {\n Unknown = 0,\n IonicInteraction = 1,\n CationPi = 2,\n PiStacking = 3,\n HydrogenBond = 4,\n HalogenBond = 5,\n Hydrophobic = 6,\n MetalCoordination = 7,\n WeakHydrogenBond = 8,\n WaterHydrogenBond = 9,\n BackboneHydrogenBond = 10\n}\n\nexport const ContactDefaultParams = {\n maxHydrophobicDist: 4.0,\n maxHbondDist: 3.5,\n maxHbondSulfurDist: 4.1,\n maxHbondAccAngle: 45,\n maxHbondDonAngle: 45,\n maxHbondAccPlaneAngle: 90,\n maxHbondDonPlaneAngle: 30,\n maxPiStackingDist: 5.5,\n maxPiStackingOffset: 2.0,\n maxPiStackingAngle: 30,\n maxCationPiDist: 6.0,\n maxCationPiOffset: 2.0,\n maxIonicDist: 5.0,\n maxHalogenBondDist: 4.0,\n maxHalogenBondAngle: 30,\n maxMetalDist: 3.0,\n refineSaltBridges: true,\n masterModelIndex: -1,\n lineOfSightDistFactor: 1.0\n}\n\nexport function isMasterContact (ap1: AtomProxy, ap2: AtomProxy, masterIdx: number) {\n return (\n (ap1.modelIndex === masterIdx && ap2.modelIndex !== masterIdx) ||\n (ap2.modelIndex === masterIdx && ap1.modelIndex !== masterIdx)\n )\n}\n\nexport function invalidAtomContact (ap1: AtomProxy, ap2: AtomProxy, masterIdx: number) {\n return !isMasterContact(ap1, ap2, masterIdx) && (\n ap1.modelIndex !== ap2.modelIndex ||\n ap1.residueIndex === ap2.residueIndex ||\n (ap1.altloc && ap2.altloc && ap1.altloc !== ap2.altloc)\n )\n}\n\nexport function createContacts (features: Features): Contacts {\n const { types, centers } = features\n\n const spatialHash = new SpatialHash(centers)\n const contactStore = new ContactStore()\n const featureSet = new BitArray(types.length, false)\n\n return { features, spatialHash, contactStore, featureSet }\n}\n\nexport function createFrozenContacts (contacts: Contacts): FrozenContacts {\n const { index1, index2, count } = contacts.contactStore\n\n const adjacencyList = createAdjacencyList({\n nodeArray1: index1,\n nodeArray2: index2,\n edgeCount: count,\n nodeCount: contacts.featureSet.length\n })\n const contactSet = new BitArray(contacts.contactStore.count, true)\n\n return Object.assign({ adjacencyList, contactSet }, contacts)\n}\n\nfunction calculateFeatures (structure: Structure) {\n const features = createFeatures()\n\n if (Debug) Log.time('calculateFeatures')\n\n addPositiveCharges(structure, features)\n addNegativeCharges(structure, features)\n addAromaticRings(structure, features)\n\n addHydrogenAcceptors(structure, features)\n addHydrogenDonors(structure, features)\n addWeakHydrogenDonors(structure, features)\n\n addMetalBinding(structure, features)\n addMetals(structure, features)\n\n addHydrophobic(structure, features)\n\n addHalogenAcceptors(structure, features)\n addHalogenDonors(structure, features)\n\n if (Debug) Log.timeEnd('calculateFeatures')\n\n return features\n}\n\nexport function calculateContacts (structure: Structure, params = ContactDefaultParams) {\n const features = calculateFeatures(structure)\n const contacts = createContacts(features)\n\n if (Debug) Log.time('calculateContacts')\n\n addChargedContacts(structure, contacts, params)\n addHydrogenBonds(structure, contacts, params)\n addMetalComplexation(structure, contacts, params)\n addHydrophobicContacts(structure, contacts, params)\n addHalogenBonds(structure, contacts, params)\n\n const frozenContacts = createFrozenContacts(contacts)\n\n refineLineOfSight(structure, frozenContacts, params)\n refineHydrophobicContacts(structure, frozenContacts)\n if (params.refineSaltBridges) refineSaltBridges(structure, frozenContacts)\n refinePiStacking(structure, frozenContacts)\n refineMetalCoordination(structure, frozenContacts)\n\n if (Debug) Log.timeEnd('calculateContacts')\n\n return frozenContacts\n}\n\nexport function contactTypeName (type: ContactType) {\n switch (type) {\n case ContactType.HydrogenBond:\n case ContactType.WaterHydrogenBond:\n case ContactType.BackboneHydrogenBond:\n return 'hydrogen bond'\n case ContactType.Hydrophobic:\n return 'hydrophobic contact'\n case ContactType.HalogenBond:\n return 'halogen bond'\n case ContactType.IonicInteraction:\n return 'ionic interaction'\n case ContactType.MetalCoordination:\n return 'metal coordination'\n case ContactType.CationPi:\n return 'cation-pi interaction'\n case ContactType.PiStacking:\n return 'pi-pi stacking'\n case ContactType.WeakHydrogenBond:\n return 'weak hydrogen bond'\n default:\n return 'unknown contact'\n }\n}\n\nexport const ContactDataDefaultParams = {\n hydrogenBond: true,\n hydrophobic: true,\n halogenBond: true,\n ionicInteraction: true,\n metalCoordination: true,\n cationPi: true,\n piStacking: true,\n weakHydrogenBond: true,\n waterHydrogenBond: true,\n backboneHydrogenBond: true,\n radius: 1,\n filterSele: ''\n}\nexport type ContactDataParams = typeof ContactDataDefaultParams\n | { filterSele: string|[string, string] }\n\nexport const ContactLabelDefaultParams = {\n unit: '',\n size: 2.0\n}\n\nexport type ContactLabelParams = typeof ContactLabelDefaultParams\n\nconst tmpColor = new Color()\nfunction contactColor (type: ContactType) {\n switch (type) {\n case ContactType.HydrogenBond:\n case ContactType.WaterHydrogenBond:\n case ContactType.BackboneHydrogenBond:\n return tmpColor.setHex(0x2B83BA).toArray()\n case ContactType.Hydrophobic:\n return tmpColor.setHex(0x808080).toArray()\n case ContactType.HalogenBond:\n return tmpColor.setHex(0x40FFBF).toArray()\n case ContactType.IonicInteraction:\n return tmpColor.setHex(0xF0C814).toArray()\n case ContactType.MetalCoordination:\n return tmpColor.setHex(0x8C4099).toArray()\n case ContactType.CationPi:\n return tmpColor.setHex(0xFF8000).toArray()\n case ContactType.PiStacking:\n return tmpColor.setHex(0x8CB366).toArray()\n case ContactType.WeakHydrogenBond:\n return tmpColor.setHex(0xC5DDEC).toArray()\n default:\n return tmpColor.setHex(0xCCCCCC).toArray()\n }\n}\n\nexport interface ContactData {\n position1: Float32Array,\n position2: Float32Array,\n color: Float32Array,\n color2: Float32Array,\n radius: Float32Array,\n picking: ContactPicker\n}\n\nexport function getContactData (contacts: FrozenContacts, structure: Structure, params: ContactDataParams): ContactData {\n const p = createParams(params, ContactDataDefaultParams)\n const types: ContactType[] = []\n if (p.hydrogenBond) types.push(ContactType.HydrogenBond)\n if (p.hydrophobic) types.push(ContactType.Hydrophobic)\n if (p.halogenBond) types.push(ContactType.HalogenBond)\n if (p.ionicInteraction) types.push(ContactType.IonicInteraction)\n if (p.metalCoordination) types.push(ContactType.MetalCoordination)\n if (p.cationPi) types.push(ContactType.CationPi)\n if (p.piStacking) types.push(ContactType.PiStacking)\n if (p.weakHydrogenBond) types.push(ContactType.WeakHydrogenBond)\n if (p.waterHydrogenBond) types.push(ContactType.WaterHydrogenBond)\n if (p.backboneHydrogenBond) types.push(ContactType.BackboneHydrogenBond)\n\n const { features, contactSet, contactStore } = contacts\n const { centers, atomSets } = features\n const { x, y, z } = centers\n const { index1, index2, type } = contactStore\n\n const position1: number[] = []\n const position2: number[] = []\n const color: number[] = []\n const radius: number[] = []\n const picking: number[] = []\n\n let filterSet: BitArray | BitArray[] | undefined\n if (p.filterSele) {\n if (Array.isArray(p.filterSele)) {\n filterSet = p.filterSele.map(sele => {\n return structure.getAtomSet(new Selection(sele))\n })\n } else {\n filterSet = structure.getAtomSet(new Selection(p.filterSele))\n }\n }\n\n contactSet.forEach(i => {\n const ti = type[ i ]\n if (!types.includes(ti)) return\n\n if (filterSet) {\n const idx1 = atomSets[index1[i]][0]\n const idx2 = atomSets[index2[i]][0]\n\n if (Array.isArray(filterSet)) {\n if (!(filterSet[0].isSet(idx1) && filterSet[1].isSet(idx2) || (filterSet[1].isSet(idx1) && filterSet[0].isSet(idx2)))) return\n } else {\n if (!filterSet.isSet(idx1) && !filterSet.isSet(idx2)) return\n }\n }\n\n const k = index1[i]\n const l = index2[i]\n position1.push(x[k], y[k], z[k])\n position2.push(x[l], y[l], z[l])\n color.push(...contactColor(ti))\n radius.push(p.radius)\n picking.push(i)\n })\n\n return {\n position1: new Float32Array(position1),\n position2: new Float32Array(position2),\n color: new Float32Array(color),\n color2: new Float32Array(color),\n radius: new Float32Array(radius),\n picking: new ContactPicker(picking, contacts, structure)\n }\n}\n\nexport function getLabelData (contactData: ContactData, params: ContactLabelParams): TextBufferData {\n\n const position = calculateCenterArray(contactData.position1, contactData.position2)\n const text: string[] = []\n\n const direction = calculateDirectionArray(contactData.position1, contactData.position2)\n\n const n = direction.length / 3\n for (let i=0; i\n */\n\nimport { defaults } from '../../utils'\nimport Structure from '../../structure/structure'\nimport { Elements } from '../../structure/structure-constants'\nimport {\n Features, FeatureType,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\n\n/**\n * Hydrophobic carbon (only bonded to carbon or hydrogen); fluorine\n */\nexport function addHydrophobic (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n const state = createFeatureState(FeatureType.Hydrophobic)\n let flag = false\n if (a.number === Elements.C) {\n flag = true\n a.eachBondedAtom(ap => {\n const an = ap.number\n if (an !== Elements.C && an !== Elements.H) flag = false\n })\n } else if (a.number === Elements.F) {\n flag = true\n }\n if (flag) {\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\nfunction isHydrophobicContact (ti: FeatureType, tj: FeatureType) {\n return ti === FeatureType.Hydrophobic && tj === FeatureType.Hydrophobic\n}\n\nexport interface HydrophobicContactsParams {\n maxHydrophobicDist?: number\n masterModelIndex?: number\n}\n\n/**\n * All hydrophobic contacts\n */\nexport function addHydrophobicContacts (structure: Structure, contacts: Contacts, params: HydrophobicContactsParams = {}) {\n const maxHydrophobicDist = defaults(params.maxHydrophobicDist, ContactDefaultParams.maxHydrophobicDist)\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxHydrophobicDist, (j, dSq) => {\n if (j <= i) return\n\n ap1.index = atomSets[ i ][ 0 ]\n ap2.index = atomSets[ j ][ 0 ]\n\n if (invalidAtomContact(ap1, ap2, masterIdx)) return\n if (ap1.number === Elements.F && ap2.number === Elements.F) return\n if (ap1.connectedTo(ap2)) return\n\n if (isHydrophobicContact(types[ i ], types[ j ])) {\n featureSet.setBits(i, j)\n contactStore.addContact(i, j, ContactType.Hydrophobic)\n }\n })\n }\n}\n","/**\n * @file Picker\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { PickerRegistry } from '../globals'\nimport { calculateMeanVector3 } from '../math/vector-utils'\nimport Selection from '../selection/selection'\nimport {\n ArrowPrimitive, BoxPrimitive, ConePrimitive, CylinderPrimitive,\n EllipsoidPrimitive, OctahedronPrimitive, SpherePrimitive,\n TetrahedronPrimitive, TorusPrimitive, PointPrimitive, WidelinePrimitive\n} from '../geometry/primitive'\nimport { contactTypeName, Contacts } from '../chemistry/interactions/contact'\nimport { TypedArray } from '../types';\nimport Component from '../component/component';\nimport { Shape, Structure, Volume } from '../ngl';\nimport BondStore from '../store/bond-store';\nimport Validation from '../structure/validation';\nimport PrincipalAxes from '../math/principal-axes';\nimport Surface from '../surface/surface';\nimport Unitcell from '../symmetry/unitcell';\nimport BondProxy from '../proxy/bond-proxy';\nimport AtomProxy from '../proxy/atom-proxy';\n\n/**\n * Picker class\n * @interface\n */\nclass Picker {\n array: number[]|TypedArray|undefined\n /**\n * @param {Array|TypedArray} [array] - mapping\n */\n constructor (array?: number[]|TypedArray) {\n this.array = array\n }\n\n get type () { return '' }\n get data () { return {} }\n\n /**\n * Get the index for the given picking id\n * @param {Integer} pid - the picking id\n * @return {Integer} the index\n */\n getIndex (pid: number) {\n return this.array ? this.array[ pid ] : pid\n }\n\n /**\n * Get object data\n * @abstract\n * @param {Integer} pid - the picking id\n * @return {Object} the object data\n */\n getObject (pid: number) {\n return {}\n }\n\n _applyTransformations (vector: Vector3, instance: any, component: Component) {\n if (instance) {\n vector.applyMatrix4(instance.matrix)\n }\n if (component) {\n vector.applyMatrix4(component.matrix)\n }\n return vector\n }\n\n /**\n * Get object position\n * @abstract\n * @param {Integer} pid - the picking id\n * @return {Vector3} the object position\n */\n _getPosition (pid: number) {\n return new Vector3()\n }\n\n /**\n * Get position for the given picking id\n * @param {Integer} pid - the picking id\n * @param {Object} instance - the instance that should be applied\n * @param {Component} component - the component of the picked object\n * @return {Vector3} the position\n */\n getPosition (pid: number, instance: any, component: Component) {\n return this._applyTransformations(\n this._getPosition(pid), instance, component\n )\n }\n}\n\n/**\n * Shape picker class\n * @interface\n */\nclass ShapePicker extends Picker {\n shape: Shape\n /**\n * @param {Shape} shape - shape object\n */\n constructor (shape: Shape) {\n super()\n this.shape = shape\n }\n\n get primitive (): any { return }\n\n get data () { return this.shape }\n get type () { return this.primitive.type }\n\n getObject (pid: number) {\n return this.primitive.objectFromShape(this.shape, this.getIndex(pid))\n }\n\n _getPosition (pid: number) {\n return this.primitive.positionFromShape(this.shape, this.getIndex(pid))\n }\n}\n\n//\n\nclass CylinderPicker extends ShapePicker {\n get primitive () { return CylinderPrimitive }\n}\n\nclass ArrowPicker extends ShapePicker {\n get primitive () { return ArrowPrimitive }\n}\n\nclass AtomPicker extends Picker {\n structure: Structure\n constructor (array: Float32Array, structure: Structure) {\n super(array)\n this.structure = structure\n }\n\n get type () { return 'atom' }\n get data () { return this.structure }\n\n getObject (pid: number): AtomProxy {\n return this.structure.getAtomProxy(this.getIndex(pid))\n }\n\n _getPosition (pid: number) {\n return new Vector3().copy(this.getObject(pid) as any)\n }\n}\n\nclass AxesPicker extends Picker {\n axes: PrincipalAxes\n constructor (axes: PrincipalAxes) {\n super()\n this.axes = axes\n }\n\n get type () { return 'axes' }\n get data () { return this.axes }\n\n getObject (/* pid */) {\n return {\n axes: this.axes\n }\n }\n\n _getPosition (/* pid */) {\n return this.axes.center.clone()\n }\n}\n\nclass BondPicker extends Picker {\n structure: Structure\n bondStore: BondStore\n constructor (array: number[]|TypedArray|undefined, structure: Structure, bondStore?: BondStore) {\n super(array)\n this.structure = structure\n this.bondStore = bondStore || structure.bondStore\n }\n\n get type () { return 'bond' }\n get data () { return this.structure }\n\n getObject (pid: number): BondProxy {\n const bp = this.structure.getBondProxy(this.getIndex(pid))\n bp.bondStore = this.bondStore\n return bp\n }\n\n _getPosition (pid: number) {\n const b = this.getObject(pid)\n return new Vector3()\n .copy(b.atom1 as any)\n .add(b.atom2 as any)\n .multiplyScalar(0.5)\n }\n}\n\nclass ContactPicker extends Picker {\n contacts: Contacts\n structure: Structure\n constructor (array: number[]|TypedArray|undefined, contacts: Contacts, structure: Structure) {\n super(array)\n this.contacts = contacts\n this.structure = structure\n }\n\n get type () { return 'contact' }\n get data () { return this.contacts }\n\n getObject (pid: number) {\n const idx = this.getIndex(pid)\n const { features, contactStore } = this.contacts\n const { centers, atomSets } = features\n const { x, y, z } = centers\n const { index1, index2, type } = contactStore\n const k = index1[idx]\n const l = index2[idx]\n return {\n center1: new Vector3(x[k], y[k], z[k]),\n center2: new Vector3(x[l], y[l], z[l]),\n atom1: this.structure.getAtomProxy(atomSets[k][0]),\n atom2: this.structure.getAtomProxy(atomSets[l][0]),\n type: contactTypeName(type[idx])\n }\n }\n\n _getPosition (pid: number) {\n const { center1, center2 } = this.getObject(pid)\n return new Vector3().addVectors(center1, center2).multiplyScalar(0.5)\n }\n}\n\nclass ConePicker extends ShapePicker {\n get primitive () { return ConePrimitive }\n}\n\nclass ClashPicker extends Picker {\n validation: Validation\n structure: Structure\n constructor (array: number[]|TypedArray|undefined, validation: Validation, structure: Structure) {\n super(array)\n this.validation = validation\n this.structure = structure\n }\n\n get type () { return 'clash' }\n get data () { return this.validation }\n\n getObject (pid: number) {\n const val = this.validation\n const idx = this.getIndex(pid)\n return {\n validation: val,\n index: idx,\n clash: val.clashArray[ idx ]\n }\n }\n\n _getAtomProxyFromSele (sele: string) {\n const selection = new Selection(sele)\n const idx = this.structure.getAtomIndices(selection)![ 0 ]\n return this.structure.getAtomProxy(idx)\n }\n\n _getPosition (pid: number) {\n const clash = this.getObject(pid).clash\n const ap1 = this._getAtomProxyFromSele(clash.sele1)\n const ap2 = this._getAtomProxyFromSele(clash.sele2)\n return new Vector3().copy(ap1 as any).add(ap2 as any).multiplyScalar(0.5)\n }\n}\n\nclass DistancePicker extends BondPicker {\n get type () { return 'distance' }\n}\n\nclass EllipsoidPicker extends ShapePicker {\n get primitive () { return EllipsoidPrimitive }\n}\n\nclass OctahedronPicker extends ShapePicker {\n get primitive () { return OctahedronPrimitive }\n}\n\nclass BoxPicker extends ShapePicker {\n get primitive () { return BoxPrimitive }\n}\n\nclass IgnorePicker extends Picker {\n get type () { return 'ignore' }\n}\n\nexport interface MeshData {\n name: string|undefined\n serial: number\n index: Uint32Array|Uint16Array|number[]\n normal?: Float32Array|number[]\n position: Float32Array|number[]\n color: Float32Array|number[]\n}\nclass MeshPicker extends ShapePicker {\n mesh: MeshData\n __position: Vector3\n\n constructor (shape: Shape, mesh: MeshData) {\n super(shape)\n this.mesh = mesh\n }\n\n get type () { return 'mesh' }\n\n getObject (/* pid */) {\n const m = this.mesh\n return {\n shape: this.shape,\n name: m.name,\n serial: m.serial\n }\n }\n\n _getPosition (/* pid */) {\n if (!this.__position) {\n this.__position = calculateMeanVector3(this.mesh.position as any)\n }\n return this.__position\n }\n}\n\nclass SpherePicker extends ShapePicker {\n get primitive () { return SpherePrimitive }\n}\n\nclass SurfacePicker extends Picker {\n surface: Surface\n constructor (array: number[]|TypedArray|undefined, surface: Surface) {\n super(array)\n this.surface = surface\n }\n\n get type () { return 'surface' }\n get data () { return this.surface }\n\n getObject (pid: number) {\n return {\n surface: this.surface,\n index: this.getIndex(pid)\n }\n }\n\n _getPosition (/* pid */) {\n return this.surface.center.clone()\n }\n}\n\nclass TetrahedronPicker extends ShapePicker {\n get primitive () { return TetrahedronPrimitive }\n}\n\nclass TorusPicker extends ShapePicker {\n get primitive () { return TorusPrimitive }\n}\n\nclass UnitcellPicker extends Picker {\n unitcell: Unitcell\n structure: Structure\n\n constructor (unitcell: Unitcell, structure: Structure) {\n super()\n this.unitcell = unitcell\n this.structure = structure\n }\n\n get type () { return 'unitcell' }\n get data () { return this.unitcell }\n\n getObject (/* pid */) {\n return {\n unitcell: this.unitcell,\n structure: this.structure\n }\n }\n\n _getPosition (/* pid */) {\n return this.unitcell.getCenter(this.structure)\n }\n}\n\nclass UnknownPicker extends Picker {\n get type () { return 'unknown' }\n}\n\nclass VolumePicker extends Picker {\n volume: Volume\n constructor (array: TypedArray, volume: Volume) {\n super(array)\n this.volume = volume\n }\n\n get type () { return 'volume' }\n get data () { return this.volume }\n\n getObject (pid: number) {\n const vol = this.volume\n const idx = this.getIndex(pid)\n return {\n volume: vol,\n index: idx,\n value: vol.data[ idx ]\n }\n }\n\n _getPosition (pid: number) {\n const dp = this.volume.position\n const idx = this.getIndex(pid)\n return new Vector3(\n dp[ idx * 3 ],\n dp[ idx * 3 + 1 ],\n dp[ idx * 3 + 2 ]\n )\n }\n}\n\nclass SlicePicker extends VolumePicker {\n get type () { return 'slice' }\n}\n\nclass PointPicker extends ShapePicker {\n get primitive () { return PointPrimitive }\n}\n\nclass WidelinePicker extends ShapePicker {\n get primitive () { return WidelinePrimitive }\n}\n\nPickerRegistry.add('arrow', ArrowPicker)\nPickerRegistry.add('box', BoxPicker)\nPickerRegistry.add('cone', ConePicker)\nPickerRegistry.add('cylinder', CylinderPicker)\nPickerRegistry.add('ellipsoid', EllipsoidPicker)\nPickerRegistry.add('octahedron', OctahedronPicker)\nPickerRegistry.add('sphere', SpherePicker)\nPickerRegistry.add('tetrahedron', TetrahedronPicker)\nPickerRegistry.add('torus', TorusPicker)\nPickerRegistry.add('point', PointPicker)\nPickerRegistry.add('wideline', WidelinePicker)\n\nexport {\n Picker,\n ShapePicker,\n ArrowPicker,\n AtomPicker,\n AxesPicker,\n BondPicker,\n BoxPicker,\n ConePicker,\n ContactPicker,\n CylinderPicker,\n ClashPicker,\n DistancePicker,\n EllipsoidPicker,\n IgnorePicker,\n OctahedronPicker,\n MeshPicker,\n SlicePicker,\n SpherePicker,\n SurfacePicker,\n TetrahedronPicker,\n TorusPicker,\n UnitcellPicker,\n UnknownPicker,\n VolumePicker,\n PointPicker,\n WidelinePicker\n}\n","/**\n * @file Marching Cubes\n * @author Alexander Rose \n * @private\n */\n\nimport { getUintArray } from '../utils'\n\nfunction getEdgeTable () {\n return new Uint32Array([\n 0x0, 0x109, 0x203, 0x30a, 0x406, 0x50f, 0x605, 0x70c,\n 0x80c, 0x905, 0xa0f, 0xb06, 0xc0a, 0xd03, 0xe09, 0xf00,\n 0x190, 0x99, 0x393, 0x29a, 0x596, 0x49f, 0x795, 0x69c,\n 0x99c, 0x895, 0xb9f, 0xa96, 0xd9a, 0xc93, 0xf99, 0xe90,\n 0x230, 0x339, 0x33, 0x13a, 0x636, 0x73f, 0x435, 0x53c,\n 0xa3c, 0xb35, 0x83f, 0x936, 0xe3a, 0xf33, 0xc39, 0xd30,\n 0x3a0, 0x2a9, 0x1a3, 0xaa, 0x7a6, 0x6af, 0x5a5, 0x4ac,\n 0xbac, 0xaa5, 0x9af, 0x8a6, 0xfaa, 0xea3, 0xda9, 0xca0,\n 0x460, 0x569, 0x663, 0x76a, 0x66, 0x16f, 0x265, 0x36c,\n 0xc6c, 0xd65, 0xe6f, 0xf66, 0x86a, 0x963, 0xa69, 0xb60,\n 0x5f0, 0x4f9, 0x7f3, 0x6fa, 0x1f6, 0xff, 0x3f5, 0x2fc,\n 0xdfc, 0xcf5, 0xfff, 0xef6, 0x9fa, 0x8f3, 0xbf9, 0xaf0,\n 0x650, 0x759, 0x453, 0x55a, 0x256, 0x35f, 0x55, 0x15c,\n 0xe5c, 0xf55, 0xc5f, 0xd56, 0xa5a, 0xb53, 0x859, 0x950,\n 0x7c0, 0x6c9, 0x5c3, 0x4ca, 0x3c6, 0x2cf, 0x1c5, 0xcc,\n 0xfcc, 0xec5, 0xdcf, 0xcc6, 0xbca, 0xac3, 0x9c9, 0x8c0,\n 0x8c0, 0x9c9, 0xac3, 0xbca, 0xcc6, 0xdcf, 0xec5, 0xfcc,\n 0xcc, 0x1c5, 0x2cf, 0x3c6, 0x4ca, 0x5c3, 0x6c9, 0x7c0,\n 0x950, 0x859, 0xb53, 0xa5a, 0xd56, 0xc5f, 0xf55, 0xe5c,\n 0x15c, 0x55, 0x35f, 0x256, 0x55a, 0x453, 0x759, 0x650,\n 0xaf0, 0xbf9, 0x8f3, 0x9fa, 0xef6, 0xfff, 0xcf5, 0xdfc,\n 0x2fc, 0x3f5, 0xff, 0x1f6, 0x6fa, 0x7f3, 0x4f9, 0x5f0,\n 0xb60, 0xa69, 0x963, 0x86a, 0xf66, 0xe6f, 0xd65, 0xc6c,\n 0x36c, 0x265, 0x16f, 0x66, 0x76a, 0x663, 0x569, 0x460,\n 0xca0, 0xda9, 0xea3, 0xfaa, 0x8a6, 0x9af, 0xaa5, 0xbac,\n 0x4ac, 0x5a5, 0x6af, 0x7a6, 0xaa, 0x1a3, 0x2a9, 0x3a0,\n 0xd30, 0xc39, 0xf33, 0xe3a, 0x936, 0x83f, 0xb35, 0xa3c,\n 0x53c, 0x435, 0x73f, 0x636, 0x13a, 0x33, 0x339, 0x230,\n 0xe90, 0xf99, 0xc93, 0xd9a, 0xa96, 0xb9f, 0x895, 0x99c,\n 0x69c, 0x795, 0x49f, 0x596, 0x29a, 0x393, 0x99, 0x190,\n 0xf00, 0xe09, 0xd03, 0xc0a, 0xb06, 0xa0f, 0x905, 0x80c,\n 0x70c, 0x605, 0x50f, 0x406, 0x30a, 0x203, 0x109, 0x0\n ])\n}\n\nfunction getTriTable (): Int32Array {\n return new Int32Array([\n -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 8, 3, 9, 8, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 2, 10, 0, 2, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 8, 3, 2, 10, 8, 10, 9, 8, -1, -1, -1, -1, -1, -1, -1,\n 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 11, 2, 8, 11, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 9, 0, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 11, 2, 1, 9, 11, 9, 8, 11, -1, -1, -1, -1, -1, -1, -1,\n 3, 10, 1, 11, 10, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 10, 1, 0, 8, 10, 8, 11, 10, -1, -1, -1, -1, -1, -1, -1,\n 3, 9, 0, 3, 11, 9, 11, 10, 9, -1, -1, -1, -1, -1, -1, -1,\n 9, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 3, 0, 7, 3, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 9, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 1, 9, 4, 7, 1, 7, 3, 1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 4, 7, 3, 0, 4, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1,\n 9, 2, 10, 9, 0, 2, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1,\n 2, 10, 9, 2, 9, 7, 2, 7, 3, 7, 9, 4, -1, -1, -1, -1,\n 8, 4, 7, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 11, 4, 7, 11, 2, 4, 2, 0, 4, -1, -1, -1, -1, -1, -1, -1,\n 9, 0, 1, 8, 4, 7, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1,\n 4, 7, 11, 9, 4, 11, 9, 11, 2, 9, 2, 1, -1, -1, -1, -1,\n 3, 10, 1, 3, 11, 10, 7, 8, 4, -1, -1, -1, -1, -1, -1, -1,\n 1, 11, 10, 1, 4, 11, 1, 0, 4, 7, 11, 4, -1, -1, -1, -1,\n 4, 7, 8, 9, 0, 11, 9, 11, 10, 11, 0, 3, -1, -1, -1, -1,\n 4, 7, 11, 4, 11, 9, 9, 11, 10, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 4, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 5, 4, 1, 5, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 8, 5, 4, 8, 3, 5, 3, 1, 5, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 8, 1, 2, 10, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1,\n 5, 2, 10, 5, 4, 2, 4, 0, 2, -1, -1, -1, -1, -1, -1, -1,\n 2, 10, 5, 3, 2, 5, 3, 5, 4, 3, 4, 8, -1, -1, -1, -1,\n 9, 5, 4, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 11, 2, 0, 8, 11, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1,\n 0, 5, 4, 0, 1, 5, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1,\n 2, 1, 5, 2, 5, 8, 2, 8, 11, 4, 8, 5, -1, -1, -1, -1,\n 10, 3, 11, 10, 1, 3, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1,\n 4, 9, 5, 0, 8, 1, 8, 10, 1, 8, 11, 10, -1, -1, -1, -1,\n 5, 4, 0, 5, 0, 11, 5, 11, 10, 11, 0, 3, -1, -1, -1, -1,\n 5, 4, 8, 5, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1,\n 9, 7, 8, 5, 7, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 3, 0, 9, 5, 3, 5, 7, 3, -1, -1, -1, -1, -1, -1, -1,\n 0, 7, 8, 0, 1, 7, 1, 5, 7, -1, -1, -1, -1, -1, -1, -1,\n 1, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 7, 8, 9, 5, 7, 10, 1, 2, -1, -1, -1, -1, -1, -1, -1,\n 10, 1, 2, 9, 5, 0, 5, 3, 0, 5, 7, 3, -1, -1, -1, -1,\n 8, 0, 2, 8, 2, 5, 8, 5, 7, 10, 5, 2, -1, -1, -1, -1,\n 2, 10, 5, 2, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1,\n 7, 9, 5, 7, 8, 9, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 7, 9, 7, 2, 9, 2, 0, 2, 7, 11, -1, -1, -1, -1,\n 2, 3, 11, 0, 1, 8, 1, 7, 8, 1, 5, 7, -1, -1, -1, -1,\n 11, 2, 1, 11, 1, 7, 7, 1, 5, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 8, 8, 5, 7, 10, 1, 3, 10, 3, 11, -1, -1, -1, -1,\n 5, 7, 0, 5, 0, 9, 7, 11, 0, 1, 0, 10, 11, 10, 0, -1,\n 11, 10, 0, 11, 0, 3, 10, 5, 0, 8, 0, 7, 5, 7, 0, -1,\n 11, 10, 5, 7, 11, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 0, 1, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 8, 3, 1, 9, 8, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1,\n 1, 6, 5, 2, 6, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 6, 5, 1, 2, 6, 3, 0, 8, -1, -1, -1, -1, -1, -1, -1,\n 9, 6, 5, 9, 0, 6, 0, 2, 6, -1, -1, -1, -1, -1, -1, -1,\n 5, 9, 8, 5, 8, 2, 5, 2, 6, 3, 2, 8, -1, -1, -1, -1,\n 2, 3, 11, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 11, 0, 8, 11, 2, 0, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 9, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1,\n 5, 10, 6, 1, 9, 2, 9, 11, 2, 9, 8, 11, -1, -1, -1, -1,\n 6, 3, 11, 6, 5, 3, 5, 1, 3, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 11, 0, 11, 5, 0, 5, 1, 5, 11, 6, -1, -1, -1, -1,\n 3, 11, 6, 0, 3, 6, 0, 6, 5, 0, 5, 9, -1, -1, -1, -1,\n 6, 5, 9, 6, 9, 11, 11, 9, 8, -1, -1, -1, -1, -1, -1, -1,\n 5, 10, 6, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 3, 0, 4, 7, 3, 6, 5, 10, -1, -1, -1, -1, -1, -1, -1,\n 1, 9, 0, 5, 10, 6, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1,\n 10, 6, 5, 1, 9, 7, 1, 7, 3, 7, 9, 4, -1, -1, -1, -1,\n 6, 1, 2, 6, 5, 1, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 5, 5, 2, 6, 3, 0, 4, 3, 4, 7, -1, -1, -1, -1,\n 8, 4, 7, 9, 0, 5, 0, 6, 5, 0, 2, 6, -1, -1, -1, -1,\n 7, 3, 9, 7, 9, 4, 3, 2, 9, 5, 9, 6, 2, 6, 9, -1,\n 3, 11, 2, 7, 8, 4, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1,\n 5, 10, 6, 4, 7, 2, 4, 2, 0, 2, 7, 11, -1, -1, -1, -1,\n 0, 1, 9, 4, 7, 8, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1,\n 9, 2, 1, 9, 11, 2, 9, 4, 11, 7, 11, 4, 5, 10, 6, -1,\n 8, 4, 7, 3, 11, 5, 3, 5, 1, 5, 11, 6, -1, -1, -1, -1,\n 5, 1, 11, 5, 11, 6, 1, 0, 11, 7, 11, 4, 0, 4, 11, -1,\n 0, 5, 9, 0, 6, 5, 0, 3, 6, 11, 6, 3, 8, 4, 7, -1,\n 6, 5, 9, 6, 9, 11, 4, 7, 9, 7, 11, 9, -1, -1, -1, -1,\n 10, 4, 9, 6, 4, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 10, 6, 4, 9, 10, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1,\n 10, 0, 1, 10, 6, 0, 6, 4, 0, -1, -1, -1, -1, -1, -1, -1,\n 8, 3, 1, 8, 1, 6, 8, 6, 4, 6, 1, 10, -1, -1, -1, -1,\n 1, 4, 9, 1, 2, 4, 2, 6, 4, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 8, 1, 2, 9, 2, 4, 9, 2, 6, 4, -1, -1, -1, -1,\n 0, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 8, 3, 2, 8, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1,\n 10, 4, 9, 10, 6, 4, 11, 2, 3, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 2, 2, 8, 11, 4, 9, 10, 4, 10, 6, -1, -1, -1, -1,\n 3, 11, 2, 0, 1, 6, 0, 6, 4, 6, 1, 10, -1, -1, -1, -1,\n 6, 4, 1, 6, 1, 10, 4, 8, 1, 2, 1, 11, 8, 11, 1, -1,\n 9, 6, 4, 9, 3, 6, 9, 1, 3, 11, 6, 3, -1, -1, -1, -1,\n 8, 11, 1, 8, 1, 0, 11, 6, 1, 9, 1, 4, 6, 4, 1, -1,\n 3, 11, 6, 3, 6, 0, 0, 6, 4, -1, -1, -1, -1, -1, -1, -1,\n 6, 4, 8, 11, 6, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 7, 10, 6, 7, 8, 10, 8, 9, 10, -1, -1, -1, -1, -1, -1, -1,\n 0, 7, 3, 0, 10, 7, 0, 9, 10, 6, 7, 10, -1, -1, -1, -1,\n 10, 6, 7, 1, 10, 7, 1, 7, 8, 1, 8, 0, -1, -1, -1, -1,\n 10, 6, 7, 10, 7, 1, 1, 7, 3, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 6, 1, 6, 8, 1, 8, 9, 8, 6, 7, -1, -1, -1, -1,\n 2, 6, 9, 2, 9, 1, 6, 7, 9, 0, 9, 3, 7, 3, 9, -1,\n 7, 8, 0, 7, 0, 6, 6, 0, 2, -1, -1, -1, -1, -1, -1, -1,\n 7, 3, 2, 6, 7, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 3, 11, 10, 6, 8, 10, 8, 9, 8, 6, 7, -1, -1, -1, -1,\n 2, 0, 7, 2, 7, 11, 0, 9, 7, 6, 7, 10, 9, 10, 7, -1,\n 1, 8, 0, 1, 7, 8, 1, 10, 7, 6, 7, 10, 2, 3, 11, -1,\n 11, 2, 1, 11, 1, 7, 10, 6, 1, 6, 7, 1, -1, -1, -1, -1,\n 8, 9, 6, 8, 6, 7, 9, 1, 6, 11, 6, 3, 1, 3, 6, -1,\n 0, 9, 1, 11, 6, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 7, 8, 0, 7, 0, 6, 3, 11, 0, 11, 6, 0, -1, -1, -1, -1,\n 7, 11, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 8, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 9, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 8, 1, 9, 8, 3, 1, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1,\n 10, 1, 2, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 3, 0, 8, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1,\n 2, 9, 0, 2, 10, 9, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1,\n 6, 11, 7, 2, 10, 3, 10, 8, 3, 10, 9, 8, -1, -1, -1, -1,\n 7, 2, 3, 6, 2, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 7, 0, 8, 7, 6, 0, 6, 2, 0, -1, -1, -1, -1, -1, -1, -1,\n 2, 7, 6, 2, 3, 7, 0, 1, 9, -1, -1, -1, -1, -1, -1, -1,\n 1, 6, 2, 1, 8, 6, 1, 9, 8, 8, 7, 6, -1, -1, -1, -1,\n 10, 7, 6, 10, 1, 7, 1, 3, 7, -1, -1, -1, -1, -1, -1, -1,\n 10, 7, 6, 1, 7, 10, 1, 8, 7, 1, 0, 8, -1, -1, -1, -1,\n 0, 3, 7, 0, 7, 10, 0, 10, 9, 6, 10, 7, -1, -1, -1, -1,\n 7, 6, 10, 7, 10, 8, 8, 10, 9, -1, -1, -1, -1, -1, -1, -1,\n 6, 8, 4, 11, 8, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 6, 11, 3, 0, 6, 0, 4, 6, -1, -1, -1, -1, -1, -1, -1,\n 8, 6, 11, 8, 4, 6, 9, 0, 1, -1, -1, -1, -1, -1, -1, -1,\n 9, 4, 6, 9, 6, 3, 9, 3, 1, 11, 3, 6, -1, -1, -1, -1,\n 6, 8, 4, 6, 11, 8, 2, 10, 1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 3, 0, 11, 0, 6, 11, 0, 4, 6, -1, -1, -1, -1,\n 4, 11, 8, 4, 6, 11, 0, 2, 9, 2, 10, 9, -1, -1, -1, -1,\n 10, 9, 3, 10, 3, 2, 9, 4, 3, 11, 3, 6, 4, 6, 3, -1,\n 8, 2, 3, 8, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1,\n 0, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 9, 0, 2, 3, 4, 2, 4, 6, 4, 3, 8, -1, -1, -1, -1,\n 1, 9, 4, 1, 4, 2, 2, 4, 6, -1, -1, -1, -1, -1, -1, -1,\n 8, 1, 3, 8, 6, 1, 8, 4, 6, 6, 10, 1, -1, -1, -1, -1,\n 10, 1, 0, 10, 0, 6, 6, 0, 4, -1, -1, -1, -1, -1, -1, -1,\n 4, 6, 3, 4, 3, 8, 6, 10, 3, 0, 3, 9, 10, 9, 3, -1,\n 10, 9, 4, 6, 10, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 9, 5, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 4, 9, 5, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1,\n 5, 0, 1, 5, 4, 0, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1,\n 11, 7, 6, 8, 3, 4, 3, 5, 4, 3, 1, 5, -1, -1, -1, -1,\n 9, 5, 4, 10, 1, 2, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1,\n 6, 11, 7, 1, 2, 10, 0, 8, 3, 4, 9, 5, -1, -1, -1, -1,\n 7, 6, 11, 5, 4, 10, 4, 2, 10, 4, 0, 2, -1, -1, -1, -1,\n 3, 4, 8, 3, 5, 4, 3, 2, 5, 10, 5, 2, 11, 7, 6, -1,\n 7, 2, 3, 7, 6, 2, 5, 4, 9, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 4, 0, 8, 6, 0, 6, 2, 6, 8, 7, -1, -1, -1, -1,\n 3, 6, 2, 3, 7, 6, 1, 5, 0, 5, 4, 0, -1, -1, -1, -1,\n 6, 2, 8, 6, 8, 7, 2, 1, 8, 4, 8, 5, 1, 5, 8, -1,\n 9, 5, 4, 10, 1, 6, 1, 7, 6, 1, 3, 7, -1, -1, -1, -1,\n 1, 6, 10, 1, 7, 6, 1, 0, 7, 8, 7, 0, 9, 5, 4, -1,\n 4, 0, 10, 4, 10, 5, 0, 3, 10, 6, 10, 7, 3, 7, 10, -1,\n 7, 6, 10, 7, 10, 8, 5, 4, 10, 4, 8, 10, -1, -1, -1, -1,\n 6, 9, 5, 6, 11, 9, 11, 8, 9, -1, -1, -1, -1, -1, -1, -1,\n 3, 6, 11, 0, 6, 3, 0, 5, 6, 0, 9, 5, -1, -1, -1, -1,\n 0, 11, 8, 0, 5, 11, 0, 1, 5, 5, 6, 11, -1, -1, -1, -1,\n 6, 11, 3, 6, 3, 5, 5, 3, 1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 9, 5, 11, 9, 11, 8, 11, 5, 6, -1, -1, -1, -1,\n 0, 11, 3, 0, 6, 11, 0, 9, 6, 5, 6, 9, 1, 2, 10, -1,\n 11, 8, 5, 11, 5, 6, 8, 0, 5, 10, 5, 2, 0, 2, 5, -1,\n 6, 11, 3, 6, 3, 5, 2, 10, 3, 10, 5, 3, -1, -1, -1, -1,\n 5, 8, 9, 5, 2, 8, 5, 6, 2, 3, 8, 2, -1, -1, -1, -1,\n 9, 5, 6, 9, 6, 0, 0, 6, 2, -1, -1, -1, -1, -1, -1, -1,\n 1, 5, 8, 1, 8, 0, 5, 6, 8, 3, 8, 2, 6, 2, 8, -1,\n 1, 5, 6, 2, 1, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 3, 6, 1, 6, 10, 3, 8, 6, 5, 6, 9, 8, 9, 6, -1,\n 10, 1, 0, 10, 0, 6, 9, 5, 0, 5, 6, 0, -1, -1, -1, -1,\n 0, 3, 8, 5, 6, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 10, 5, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 11, 5, 10, 7, 5, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 11, 5, 10, 11, 7, 5, 8, 3, 0, -1, -1, -1, -1, -1, -1, -1,\n 5, 11, 7, 5, 10, 11, 1, 9, 0, -1, -1, -1, -1, -1, -1, -1,\n 10, 7, 5, 10, 11, 7, 9, 8, 1, 8, 3, 1, -1, -1, -1, -1,\n 11, 1, 2, 11, 7, 1, 7, 5, 1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 1, 2, 7, 1, 7, 5, 7, 2, 11, -1, -1, -1, -1,\n 9, 7, 5, 9, 2, 7, 9, 0, 2, 2, 11, 7, -1, -1, -1, -1,\n 7, 5, 2, 7, 2, 11, 5, 9, 2, 3, 2, 8, 9, 8, 2, -1,\n 2, 5, 10, 2, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1,\n 8, 2, 0, 8, 5, 2, 8, 7, 5, 10, 2, 5, -1, -1, -1, -1,\n 9, 0, 1, 5, 10, 3, 5, 3, 7, 3, 10, 2, -1, -1, -1, -1,\n 9, 8, 2, 9, 2, 1, 8, 7, 2, 10, 2, 5, 7, 5, 2, -1,\n 1, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 7, 0, 7, 1, 1, 7, 5, -1, -1, -1, -1, -1, -1, -1,\n 9, 0, 3, 9, 3, 5, 5, 3, 7, -1, -1, -1, -1, -1, -1, -1,\n 9, 8, 7, 5, 9, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 5, 8, 4, 5, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1,\n 5, 0, 4, 5, 11, 0, 5, 10, 11, 11, 3, 0, -1, -1, -1, -1,\n 0, 1, 9, 8, 4, 10, 8, 10, 11, 10, 4, 5, -1, -1, -1, -1,\n 10, 11, 4, 10, 4, 5, 11, 3, 4, 9, 4, 1, 3, 1, 4, -1,\n 2, 5, 1, 2, 8, 5, 2, 11, 8, 4, 5, 8, -1, -1, -1, -1,\n 0, 4, 11, 0, 11, 3, 4, 5, 11, 2, 11, 1, 5, 1, 11, -1,\n 0, 2, 5, 0, 5, 9, 2, 11, 5, 4, 5, 8, 11, 8, 5, -1,\n 9, 4, 5, 2, 11, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 5, 10, 3, 5, 2, 3, 4, 5, 3, 8, 4, -1, -1, -1, -1,\n 5, 10, 2, 5, 2, 4, 4, 2, 0, -1, -1, -1, -1, -1, -1, -1,\n 3, 10, 2, 3, 5, 10, 3, 8, 5, 4, 5, 8, 0, 1, 9, -1,\n 5, 10, 2, 5, 2, 4, 1, 9, 2, 9, 4, 2, -1, -1, -1, -1,\n 8, 4, 5, 8, 5, 3, 3, 5, 1, -1, -1, -1, -1, -1, -1, -1,\n 0, 4, 5, 1, 0, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 8, 4, 5, 8, 5, 3, 9, 0, 5, 0, 3, 5, -1, -1, -1, -1,\n 9, 4, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 11, 7, 4, 9, 11, 9, 10, 11, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 4, 9, 7, 9, 11, 7, 9, 10, 11, -1, -1, -1, -1,\n 1, 10, 11, 1, 11, 4, 1, 4, 0, 7, 4, 11, -1, -1, -1, -1,\n 3, 1, 4, 3, 4, 8, 1, 10, 4, 7, 4, 11, 10, 11, 4, -1,\n 4, 11, 7, 9, 11, 4, 9, 2, 11, 9, 1, 2, -1, -1, -1, -1,\n 9, 7, 4, 9, 11, 7, 9, 1, 11, 2, 11, 1, 0, 8, 3, -1,\n 11, 7, 4, 11, 4, 2, 2, 4, 0, -1, -1, -1, -1, -1, -1, -1,\n 11, 7, 4, 11, 4, 2, 8, 3, 4, 3, 2, 4, -1, -1, -1, -1,\n 2, 9, 10, 2, 7, 9, 2, 3, 7, 7, 4, 9, -1, -1, -1, -1,\n 9, 10, 7, 9, 7, 4, 10, 2, 7, 8, 7, 0, 2, 0, 7, -1,\n 3, 7, 10, 3, 10, 2, 7, 4, 10, 1, 10, 0, 4, 0, 10, -1,\n 1, 10, 2, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 9, 1, 4, 1, 7, 7, 1, 3, -1, -1, -1, -1, -1, -1, -1,\n 4, 9, 1, 4, 1, 7, 0, 8, 1, 8, 7, 1, -1, -1, -1, -1,\n 4, 0, 3, 7, 4, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 8, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 9, 3, 9, 11, 11, 9, 10, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 10, 0, 10, 8, 8, 10, 11, -1, -1, -1, -1, -1, -1, -1,\n 3, 1, 10, 11, 3, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 11, 1, 11, 9, 9, 11, 8, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 9, 3, 9, 11, 1, 2, 9, 2, 11, 9, -1, -1, -1, -1,\n 0, 2, 11, 8, 0, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 2, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 3, 8, 2, 8, 10, 10, 8, 9, -1, -1, -1, -1, -1, -1, -1,\n 9, 10, 2, 0, 9, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 3, 8, 2, 8, 10, 0, 1, 8, 1, 10, 8, -1, -1, -1, -1,\n 1, 10, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 3, 8, 9, 1, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 9, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 3, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1\n ])\n}\n\ninterface MarchingCubes {\n new (field: number[], nx: number, ny: number, nz: number, atomindex: number[]): void\n triangulate: (_isolevel: number, _noNormals: boolean, _box: number[][]|undefined, _contour: boolean, _wrap: boolean) => {\n position: Float32Array\n normal: undefined|Float32Array\n index: Uint32Array|Uint16Array\n atomindex: Int32Array|undefined\n contour: boolean\n }\n}\nfunction MarchingCubes (this: MarchingCubes, field: number[], nx: number, ny: number, nz: number, atomindex: number[]) {\n // Based on alteredq / http://alteredqualia.com/\n // port of greggman's ThreeD version of marching cubes to Three.js\n // http://webglsamples.googlecode.com/hg/blob/blob.html\n //\n // Adapted for NGL by Alexander Rose\n\n // Triangles are constructed between points on cube edges.\n // allowedContours[edge1][edge1] indicates which lines from a given\n // triangle should be shown in line mode.\n\n // Values are bitmasks:\n // In loop over cubes we keep another bitmask indicating whether our current\n // cell is the first x-value (1),\n // first y-value (2) or first z-value (4) of the current loop.\n // We draw all lines on leading faces but only draw trailing face lines the first\n // time through the loop\n // A value of 8 below means the edge is always drawn (leading face)\n\n // E.g. the first row, lines between edge0 and other edges in the bottom\n // x-y plane are only drawn for the first value of z, edges in the\n // x-z plane are only drawn for the first value of y. No other lines\n // are drawn as they're redundant\n // The line between edge 1 and 5 is always drawn as it's on the leading edge\n var allowedContours = [\n\n [ 0, 4, 4, 4, 2, 0, 0, 0, 2, 2, 0, 0 ], // 1 2 3 4 8 9\n [ 4, 0, 4, 4, 0, 8, 0, 0, 0, 8, 8, 0 ], // 0 2 3 5 9 10\n [ 4, 4, 0, 4, 0, 0, 8, 0, 0, 0, 8, 8 ], // 0 1 3 6 10 11\n [ 4, 4, 4, 0, 0, 0, 0, 1, 1, 0, 0, 1 ], // 0 1 2 7 8 11\n [ 2, 0, 0, 0, 0, 8, 8, 8, 2, 2, 0, 0 ], // 0 5 6 7 8 9\n [ 0, 8, 0, 0, 8, 0, 8, 8, 0, 8, 8, 0 ], // And rotate it\n [ 0, 0, 8, 0, 8, 8, 0, 8, 0, 0, 8, 8 ],\n [ 0, 0, 0, 1, 8, 8, 8, 0, 1, 0, 0, 1 ],\n [ 2, 0, 0, 1, 2, 0, 0, 1, 0, 2, 0, 1 ], // 0 3 4 7 9 11\n [ 2, 8, 0, 0, 2, 8, 0, 0, 2, 0, 8, 0 ], // And rotate some more\n [ 0, 8, 8, 0, 0, 8, 8, 0, 0, 8, 0, 8 ],\n [ 0, 0, 8, 1, 0, 0, 8, 1, 1, 0, 8, 0 ]\n\n ]\n\n var isolevel = 0\n var noNormals = false\n var contour = false\n var wrap = false\n var isNegativeIso = false\n var normalFactor = -1\n\n\n var n = nx * ny * nz\n\n // deltas\n var yd = nx\n var zd = nx * ny\n\n var normalCache: Float32Array, vertexIndex: Int32Array\n var count: number, icount: number\n\n var ilist = new Int32Array(12)\n\n var positionArray: number[] = []\n var normalArray: number[] = []\n var indexArray: number[] = []\n var atomindexArray: number[] = []\n\n var edgeTable = getEdgeTable()\n var triTable = getTriTable()\n\n var mx: number, my: number, mz: number\n\n //\n\n this.triangulate = function (_isolevel: number, _noNormals: boolean, _box: number[][]|undefined, _contour: boolean, _wrap: boolean) {\n isolevel = _isolevel\n isNegativeIso = isolevel < 0.0\n contour = _contour\n wrap = _wrap\n // Normals currently disabled in contour mode for performance (unused)\n noNormals = _noNormals || contour\n\n if (!noNormals) {\n normalFactor = isolevel > 0 ? -1.0 : 1.0\n if (!normalCache) {\n normalCache = new Float32Array(n * 3)\n } \n }\n\n var vIndexLength = n * 3\n\n if (!vertexIndex || vertexIndex.length !== vIndexLength) {\n vertexIndex = new Int32Array(vIndexLength)\n }\n\n count = 0\n icount = 0\n\n if (_box !== undefined) {\n var min = _box[ 0 ].map(Math.round)\n var max = _box[ 1 ].map(Math.round)\n\n mx = nx * Math.ceil(Math.abs(min[ 0 ]) / nx)\n my = ny * Math.ceil(Math.abs(min[ 1 ]) / ny)\n mz = nz * Math.ceil(Math.abs(min[ 2 ]) / nz)\n\n triangulate(\n min[ 0 ], min[ 1 ], min[ 2 ],\n max[ 0 ], max[ 1 ], max[ 2 ]\n )\n } else {\n mx = my = mz = 0\n\n triangulate()\n }\n\n positionArray.length = count * 3\n if (!noNormals) normalArray.length = count * 3\n indexArray.length = icount\n if (atomindex) atomindexArray.length = count\n\n return {\n position: new Float32Array(positionArray),\n normal: noNormals ? undefined : new Float32Array(normalArray),\n index: getUintArray(indexArray, positionArray.length / 3),\n atomindex: atomindex ? new Int32Array(atomindexArray) : undefined,\n contour: contour\n }\n }\n\n // polygonization\n\n function lerp (a: number, b: number, t: number) { return a + (b - a) * t }\n\n function index (x: number, y: number, z: number) {\n x = (x + mx) % nx\n y = (y + my) % ny\n z = (z + mz) % nz\n return ((zd * z) + yd * y) + x\n }\n\n function VIntX (q: number, offset: number, x: number, y: number, z: number, valp1: number, valp2: number) {\n var _q = 3 * q\n\n if (vertexIndex[ _q ] < 0) {\n var mu = (isolevel - valp1) / (valp2 - valp1)\n var nc = normalCache\n\n var c = count * 3\n\n positionArray[ c ] = x + mu\n positionArray[ c + 1 ] = y\n positionArray[ c + 2 ] = z\n\n if (!noNormals) {\n var q3 = q * 3\n\n normalArray[ c ] = normalFactor * lerp(nc[ q3 ], nc[ q3 + 3 ], mu)\n normalArray[ c + 1 ] = normalFactor * lerp(nc[ q3 + 1 ], nc[ q3 + 4 ], mu)\n normalArray[ c + 2 ] = normalFactor * lerp(nc[ q3 + 2 ], nc[ q3 + 5 ], mu)\n }\n\n if (atomindex) atomindexArray[ count ] = atomindex[ q + Math.round(mu) ]\n\n vertexIndex[ _q ] = count\n ilist[ offset ] = count\n\n count += 1\n } else {\n ilist[ offset ] = vertexIndex[ _q ]\n }\n }\n\n function VIntY (q: number, offset: number, x: number, y: number, z: number, valp1: number, valp2: number) {\n var _q = 3 * q + 1\n\n if (vertexIndex[ _q ] < 0) {\n var mu = (isolevel - valp1) / (valp2 - valp1)\n var nc = normalCache\n\n var c = count * 3\n\n positionArray[ c ] = x\n positionArray[ c + 1 ] = y + mu\n positionArray[ c + 2 ] = z\n\n if (!noNormals) {\n var q3 = q * 3\n var q6 = q3 + yd * 3\n\n normalArray[ c ] = normalFactor * lerp(nc[ q3 ], nc[ q6 ], mu)\n normalArray[ c + 1 ] = normalFactor * lerp(nc[ q3 + 1 ], nc[ q6 + 1 ], mu)\n normalArray[ c + 2 ] = normalFactor * lerp(nc[ q3 + 2 ], nc[ q6 + 2 ], mu)\n }\n\n if (atomindex) atomindexArray[ count ] = atomindex[ q + Math.round(mu) * yd ]\n\n vertexIndex[ _q ] = count\n ilist[ offset ] = count\n\n count += 1\n } else {\n ilist[ offset ] = vertexIndex[ _q ]\n }\n }\n\n function VIntZ (q: number, offset: number, x: number, y: number, z: number, valp1: number, valp2: number) {\n var _q = 3 * q + 2\n\n if (vertexIndex[ _q ] < 0) {\n var mu = (isolevel - valp1) / (valp2 - valp1)\n var nc = normalCache\n\n var c = count * 3\n\n positionArray[ c ] = x\n positionArray[ c + 1 ] = y\n positionArray[ c + 2 ] = z + mu\n\n if (!noNormals) {\n var q3 = q * 3\n var q6 = q3 + zd * 3\n\n normalArray[ c ] = normalFactor * lerp(nc[ q3 ], nc[ q6 ], mu)\n normalArray[ c + 1 ] = normalFactor * lerp(nc[ q3 + 1 ], nc[ q6 + 1 ], mu)\n normalArray[ c + 2 ] = normalFactor * lerp(nc[ q3 + 2 ], nc[ q6 + 2 ], mu)\n }\n\n if (atomindex) atomindexArray[ count ] = atomindex[ q + Math.round(mu) * zd ]\n\n vertexIndex[ _q ] = count\n ilist[ offset ] = count\n\n count += 1\n } else {\n ilist[ offset ] = vertexIndex[ _q ]\n }\n }\n\n function compNorm (q: number) {\n var q3 = q * 3\n\n if (normalCache[ q3 ] === 0.0) {\n normalCache[ q3 ] = field[ (q - 1 + n) % n ] - field[ (q + 1) % n ]\n normalCache[ q3 + 1 ] = field[ (q - yd + n) % n ] - field[ (q + yd) % n ]\n normalCache[ q3 + 2 ] = field[ (q - zd + n) % n ] - field[ (q + zd) % n ]\n }\n }\n\n function polygonize (fx: number, fy: number, fz: number, q: number, edgeFilter: number) {\n // cache indices\n var q1\n var qy\n var qz\n var q1y\n var q1z\n var qyz\n var q1yz\n if (wrap) {\n q = index(fx, fy, fz)\n q1 = index(fx + 1, fy, fz)\n qy = index(fx, fy + 1, fz)\n qz = index(fx, fy, fz + 1)\n q1y = index(fx + 1, fy + 1, fz)\n q1z = index(fx + 1, fy, fz + 1)\n qyz = index(fx, fy + 1, fz + 1)\n q1yz = index(fx + 1, fy + 1, fz + 1)\n } else {\n q1 = q + 1\n qy = q + yd\n qz = q + zd\n q1y = qy + 1\n q1z = qz + 1\n qyz = qy + zd\n q1yz = qyz + 1\n }\n\n var cubeindex = 0\n var field0 = field[ q ]\n var field1 = field[ q1 ]\n var field2 = field[ qy ]\n var field3 = field[ q1y ]\n var field4 = field[ qz ]\n var field5 = field[ q1z ]\n var field6 = field[ qyz ]\n var field7 = field[ q1yz ]\n\n if (field0 < isolevel) cubeindex |= 1\n if (field1 < isolevel) cubeindex |= 2\n if (field2 < isolevel) cubeindex |= 8\n if (field3 < isolevel) cubeindex |= 4\n if (field4 < isolevel) cubeindex |= 16\n if (field5 < isolevel) cubeindex |= 32\n if (field6 < isolevel) cubeindex |= 128\n if (field7 < isolevel) cubeindex |= 64\n\n // if cube is entirely in/out of the surface - bail, nothing to draw\n\n var bits = edgeTable[ cubeindex ]\n if (bits === 0) return 0\n\n var fx2 = fx + 1\n var fy2 = fy + 1\n var fz2 = fz + 1\n\n // top of the cube\n\n if (bits & 1) {\n if (!noNormals) {\n compNorm(q)\n compNorm(q1)\n }\n VIntX(q, 0, fx, fy, fz, field0, field1)\n }\n\n if (bits & 2) {\n if (!noNormals) {\n compNorm(q1)\n compNorm(q1y)\n }\n VIntY(q1, 1, fx2, fy, fz, field1, field3)\n }\n\n if (bits & 4) {\n if (!noNormals) {\n compNorm(qy)\n compNorm(q1y)\n }\n VIntX(qy, 2, fx, fy2, fz, field2, field3)\n }\n\n if (bits & 8) {\n if (!noNormals) {\n compNorm(q)\n compNorm(qy)\n }\n VIntY(q, 3, fx, fy, fz, field0, field2)\n }\n\n // bottom of the cube\n\n if (bits & 16) {\n if (!noNormals) {\n compNorm(qz)\n compNorm(q1z)\n }\n VIntX(qz, 4, fx, fy, fz2, field4, field5)\n }\n\n if (bits & 32) {\n if (!noNormals) {\n compNorm(q1z)\n compNorm(q1yz)\n }\n VIntY(q1z, 5, fx2, fy, fz2, field5, field7)\n }\n\n if (bits & 64) {\n if (!noNormals) {\n compNorm(qyz)\n compNorm(q1yz)\n }\n VIntX(qyz, 6, fx, fy2, fz2, field6, field7)\n }\n\n if (bits & 128) {\n if (!noNormals) {\n compNorm(qz)\n compNorm(qyz)\n }\n VIntY(qz, 7, fx, fy, fz2, field4, field6)\n }\n\n // vertical lines of the cube\n\n if (bits & 256) {\n if (!noNormals) {\n compNorm(q)\n compNorm(qz)\n }\n VIntZ(q, 8, fx, fy, fz, field0, field4)\n }\n\n if (bits & 512) {\n if (!noNormals) {\n compNorm(q1)\n compNorm(q1z)\n }\n VIntZ(q1, 9, fx2, fy, fz, field1, field5)\n }\n\n if (bits & 1024) {\n if (!noNormals) {\n compNorm(q1y)\n compNorm(q1yz)\n }\n VIntZ(q1y, 10, fx2, fy2, fz, field3, field7)\n }\n\n if (bits & 2048) {\n if (!noNormals) {\n compNorm(qy)\n compNorm(qyz)\n }\n VIntZ(qy, 11, fx, fy2, fz, field2, field6)\n }\n\n var triIndex = cubeindex << 4 // re-purpose cubeindex into an offset into triTable\n\n var e1\n var e2\n var e3\n var i = 0\n\n // here is where triangles are created\n\n while (triTable[ triIndex + i ] !== -1) {\n e1 = triTable[ triIndex + i ]\n e2 = triTable[ triIndex + i + 1 ]\n e3 = triTable[ triIndex + i + 2 ]\n\n if (contour) {\n if (allowedContours[ e1 ][ e2 ] & edgeFilter) {\n indexArray[ icount++ ] = ilist[ e1 ]\n indexArray[ icount++ ] = ilist[ e2 ]\n }\n if (allowedContours[ e2 ][ e3 ] & edgeFilter) {\n indexArray[ icount++ ] = ilist[ e2 ]\n indexArray[ icount++ ] = ilist[ e3 ]\n }\n if (allowedContours[ e1 ][ e3 ] & edgeFilter) {\n indexArray[ icount++ ] = ilist[ e1 ]\n indexArray[ icount++ ] = ilist[ e3 ]\n }\n } else {\n indexArray[ icount++ ] = ilist[ isNegativeIso ? e1 : e2 ]\n indexArray[ icount++ ] = ilist[ isNegativeIso ? e2 : e1 ]\n indexArray[ icount++ ] = ilist[ e3 ]\n }\n\n i += 3\n }\n }\n\n function triangulate (xBeg?: number, yBeg?: number, zBeg?: number, xEnd?: number, yEnd?: number, zEnd?: number) {\n let q\n let q3\n let x\n let y\n let z\n let yOffset\n let zOffset\n\n xBeg = xBeg !== undefined ? xBeg : 0\n yBeg = yBeg !== undefined ? yBeg : 0\n zBeg = zBeg !== undefined ? zBeg : 0\n\n xEnd = xEnd !== undefined ? xEnd : nx - 1\n yEnd = yEnd !== undefined ? yEnd : ny - 1\n zEnd = zEnd !== undefined ? zEnd : nz - 1\n\n if (!wrap) {\n if (noNormals) {\n xBeg = Math.max(0, xBeg)\n yBeg = Math.max(0, yBeg)\n zBeg = Math.max(0, zBeg)\n\n xEnd = Math.min(nx - 1, xEnd)\n yEnd = Math.min(ny - 1, yEnd)\n zEnd = Math.min(nz - 1, zEnd)\n } else {\n xBeg = Math.max(1, xBeg)\n yBeg = Math.max(1, yBeg)\n zBeg = Math.max(1, zBeg)\n\n xEnd = Math.min(nx - 2, xEnd)\n yEnd = Math.min(ny - 2, yEnd)\n zEnd = Math.min(nz - 2, zEnd)\n }\n }\n\n let xBeg2, yBeg2, zBeg2, xEnd2, yEnd2, zEnd2\n\n if (!wrap) {\n // init part of the vertexIndex\n // (takes a significant amount of time to do for all)\n\n xBeg2 = Math.max(0, xBeg - 2)\n yBeg2 = Math.max(0, yBeg - 2)\n zBeg2 = Math.max(0, zBeg - 2)\n\n xEnd2 = Math.min(nx, xEnd + 2)\n yEnd2 = Math.min(ny, yEnd + 2)\n zEnd2 = Math.min(nz, zEnd + 2)\n\n for (z = zBeg2; z < zEnd2; ++z) {\n zOffset = zd * z\n for (y = yBeg2; y < yEnd2; ++y) {\n yOffset = zOffset + yd * y\n for (x = xBeg2; x < xEnd2; ++x) {\n q = 3 * (yOffset + x)\n vertexIndex[ q ] = -1\n vertexIndex[ q + 1 ] = -1\n vertexIndex[ q + 2 ] = -1\n }\n }\n }\n } else {\n xBeg2 = xBeg - 2\n yBeg2 = yBeg - 2\n zBeg2 = zBeg - 2\n\n xEnd2 = xEnd + 2\n yEnd2 = yEnd + 2\n zEnd2 = zEnd + 2\n\n for (z = zBeg2; z < zEnd2; ++z) {\n for (y = yBeg2; y < yEnd2; ++y) {\n for (x = xBeg2; x < xEnd2; ++x) {\n q3 = index(x, y, z) * 3\n vertexIndex[ q3 ] = -1\n vertexIndex[ q3 + 1 ] = -1\n vertexIndex[ q3 + 2 ] = -1\n }\n }\n }\n }\n\n if (!wrap) {\n // clip space where the isovalue is too low\n\n var __break\n var __xBeg = xBeg; var __yBeg = yBeg; var __zBeg = zBeg\n var __xEnd = xEnd; var __yEnd = yEnd; var __zEnd = zEnd\n\n __break = false\n for (z = zBeg; z < zEnd; ++z) {\n for (y = yBeg; y < yEnd; ++y) {\n for (x = xBeg; x < xEnd; ++x) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __zBeg = z\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (y = yBeg; y < yEnd; ++y) {\n for (z = __zBeg; z < zEnd; ++z) {\n for (x = xBeg; x < xEnd; ++x) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __yBeg = y\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (x = xBeg; x < xEnd; ++x) {\n for (y = __yBeg; y < yEnd; ++y) {\n for (z = __zBeg; z < zEnd; ++z) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __xBeg = x\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (z = zEnd; z >= zBeg; --z) {\n for (y = yEnd; y >= yBeg; --y) {\n for (x = xEnd; x >= xBeg; --x) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __zEnd = z\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (y = yEnd; y >= yBeg; --y) {\n for (z = __zEnd; z >= zBeg; --z) {\n for (x = xEnd; x >= xBeg; --x) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __yEnd = y\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (x = xEnd; x >= xBeg; --x) {\n for (y = __yEnd; y >= yBeg; --y) {\n for (z = __zEnd; z >= zBeg; --z) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __xEnd = x\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n //\n\n if (noNormals) {\n xBeg = Math.max(0, __xBeg - 1)\n yBeg = Math.max(0, __yBeg - 1)\n zBeg = Math.max(0, __zBeg - 1)\n\n xEnd = Math.min(nx - 1, __xEnd + 1)\n yEnd = Math.min(ny - 1, __yEnd + 1)\n zEnd = Math.min(nz - 1, __zEnd + 1)\n } else {\n xBeg = Math.max(1, __xBeg - 1)\n yBeg = Math.max(1, __yBeg - 1)\n zBeg = Math.max(1, __zBeg - 1)\n\n xEnd = Math.min(nx - 2, __xEnd + 1)\n yEnd = Math.min(ny - 2, __yEnd + 1)\n zEnd = Math.min(nz - 2, __zEnd + 1)\n }\n }\n\n // polygonize part of the grid\n var edgeFilter = 15\n for (z = zBeg; z < zEnd; ++z, edgeFilter &= ~4) {\n zOffset = zd * z\n edgeFilter |= 2\n for (y = yBeg; y < yEnd; ++y, edgeFilter &= ~2) {\n yOffset = zOffset + yd * y\n edgeFilter |= 1\n for (x = xBeg; x < xEnd; ++x, edgeFilter &= ~1) {\n q = yOffset + x\n polygonize(x, y, z, q, edgeFilter)\n }\n }\n }\n }\n}\nObject.assign(MarchingCubes, {__deps: [ getEdgeTable, getTriTable, getUintArray ]})\n\nexport default MarchingCubes\n","/**\n * @file Matrix Utils\n * @private\n * @author Alexander Rose \n *\n * svd methods from Eugene Zatepyakin / http://inspirit.github.io/jsfeat/\n */\n\nimport { NumberArray } from '../types'\nimport { v3new, v3cross } from './vector-utils'\n\nexport class Matrix {\n size: number\n data: Float32Array\n\n constructor (readonly cols: number, readonly rows: number) {\n this.size = this.cols * this.rows\n this.data = new Float32Array(this.size)\n }\n\n copyTo (matrix: Matrix) {\n matrix.data.set(this.data)\n }\n}\n\nexport function transpose (At: Matrix, A: Matrix) {\n let i = 0\n let j = 0\n const nrows = A.rows\n const ncols = A.cols\n let Ai = 0\n let Ati = 0\n let pAt = 0\n const ad = A.data\n const atd = At.data\n\n for (; i < nrows; Ati += 1, Ai += ncols, i++) {\n pAt = Ati\n for (j = 0; j < ncols; pAt += nrows, j++) atd[pAt] = ad[Ai + j]\n }\n}\n\n// C = A * B\nexport function multiply (C: Matrix, A: Matrix, B: Matrix) {\n let i = 0\n let j = 0\n let k = 0\n let Ap = 0\n let pA = 0\n let pB = 0\n let _pB = 0\n let Cp = 0\n const ncols = A.cols\n const nrows = A.rows\n const mcols = B.cols\n const ad = A.data\n const bd = B.data\n const cd = C.data\n let sum = 0.0\n\n for (; i < nrows; Ap += ncols, i++) {\n for (_pB = 0, j = 0; j < mcols; Cp++, _pB++, j++) {\n pB = _pB\n pA = Ap\n sum = 0.0\n for (k = 0; k < ncols; pA++, pB += mcols, k++) {\n sum += ad[pA] * bd[pB]\n }\n cd[Cp] = sum\n }\n }\n}\n\n// C = A * B'\nexport function multiplyABt (C: Matrix, A: Matrix, B: Matrix) {\n let i = 0\n let j = 0\n let k = 0\n let Ap = 0\n let pA = 0\n let pB = 0\n let Cp = 0\n const ncols = A.cols\n const nrows = A.rows\n const mrows = B.rows\n const ad = A.data\n const bd = B.data\n const cd = C.data\n let sum = 0.0\n\n for (; i < nrows; Ap += ncols, i++) {\n for (pB = 0, j = 0; j < mrows; Cp++, j++) {\n pA = Ap\n sum = 0.0\n for (k = 0; k < ncols; pA++, pB++, k++) {\n sum += ad[pA] * bd[pB]\n }\n cd[Cp] = sum\n }\n }\n}\n\n// C = A' * B\nexport function multiplyAtB (C: Matrix, A: Matrix, B: Matrix) {\n let i = 0\n let j = 0\n let k = 0\n let Ap = 0\n let pA = 0\n let pB = 0\n let _pB = 0\n let Cp = 0\n const ncols = A.cols\n const nrows = A.rows\n const mcols = B.cols\n const ad = A.data\n const bd = B.data\n const cd = C.data\n let sum = 0.0\n\n for (; i < ncols; Ap++, i++) {\n for (_pB = 0, j = 0; j < mcols; Cp++, _pB++, j++) {\n pB = _pB\n pA = Ap\n sum = 0.0\n for (k = 0; k < nrows; pA += ncols, pB += mcols, k++) {\n sum += ad[pA] * bd[pB]\n }\n cd[Cp] = sum\n }\n }\n}\n\nexport function invert3x3 (from: Matrix, to: Matrix) {\n const A = from.data\n const invA = to.data\n const t1 = A[4]\n const t2 = A[8]\n const t4 = A[5]\n const t5 = A[7]\n const t8 = A[0]\n\n const t9 = t8 * t1\n const t11 = t8 * t4\n const t13 = A[3]\n const t14 = A[1]\n const t15 = t13 * t14\n const t17 = A[2]\n const t18 = t13 * t17\n const t20 = A[6]\n const t21 = t20 * t14\n const t23 = t20 * t17\n const t26 = 1.0 / (t9 * t2 - t11 * t5 - t15 * t2 + t18 * t5 + t21 * t4 - t23 * t1)\n invA[0] = (t1 * t2 - t4 * t5) * t26\n invA[1] = -(t14 * t2 - t17 * t5) * t26\n invA[2] = -(-t14 * t4 + t17 * t1) * t26\n invA[3] = -(t13 * t2 - t4 * t20) * t26\n invA[4] = (t8 * t2 - t23) * t26\n invA[5] = -(t11 - t18) * t26\n invA[6] = -(-t13 * t5 + t1 * t20) * t26\n invA[7] = -(t8 * t5 - t21) * t26\n invA[8] = (t9 - t15) * t26\n}\n\nexport function mat3x3determinant (M: Matrix) {\n const md = M.data\n return md[0] * md[4] * md[8] -\n md[0] * md[5] * md[7] -\n md[3] * md[1] * md[8] +\n md[3] * md[2] * md[7] +\n md[6] * md[1] * md[5] -\n md[6] * md[2] * md[4]\n}\n\n// C = A * B\nexport function multiply3x3 (C: Matrix, A: Matrix, B: Matrix) {\n const Cd = C.data\n const Ad = A.data\n const Bd = B.data\n const m10 = Ad[0]\n const m11 = Ad[1]\n const m12 = Ad[2]\n const m13 = Ad[3]\n const m14 = Ad[4]\n const m15 = Ad[5]\n const m16 = Ad[6]\n const m17 = Ad[7]\n const m18 = Ad[8]\n\n const m20 = Bd[0]\n const m21 = Bd[1]\n const m22 = Bd[2]\n const m23 = Bd[3]\n const m24 = Bd[4]\n const m25 = Bd[5]\n const m26 = Bd[6]\n const m27 = Bd[7]\n const m28 = Bd[8]\n\n Cd[0] = m10 * m20 + m11 * m23 + m12 * m26\n Cd[1] = m10 * m21 + m11 * m24 + m12 * m27\n Cd[2] = m10 * m22 + m11 * m25 + m12 * m28\n Cd[3] = m13 * m20 + m14 * m23 + m15 * m26\n Cd[4] = m13 * m21 + m14 * m24 + m15 * m27\n Cd[5] = m13 * m22 + m14 * m25 + m15 * m28\n Cd[6] = m16 * m20 + m17 * m23 + m18 * m26\n Cd[7] = m16 * m21 + m17 * m24 + m18 * m27\n Cd[8] = m16 * m22 + m17 * m25 + m18 * m28\n}\n\nexport function meanRows (A: Matrix) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n const mean = new Array(ncols)\n\n for (let j = 0; j < ncols; ++j) {\n mean[ j ] = 0.0\n }\n\n for (let i = 0, p = 0; i < nrows; ++i) {\n for (let j = 0; j < ncols; ++j, ++p) {\n mean[ j ] += Ad[ p ]\n }\n }\n\n for (let j = 0; j < ncols; ++j) {\n mean[ j ] /= nrows\n }\n\n return mean\n}\n\nexport function meanCols (A: Matrix) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n const mean = new Array(nrows)\n\n for (let j = 0; j < nrows; ++j) {\n mean[ j ] = 0.0\n }\n\n for (let i = 0, p = 0; i < ncols; ++i) {\n for (let j = 0; j < nrows; ++j, ++p) {\n mean[ j ] += Ad[ p ]\n }\n }\n\n for (let j = 0; j < nrows; ++j) {\n mean[ j ] /= ncols\n }\n\n return mean\n}\n\nexport function subRows (A: Matrix, row: number[]) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n\n for (let i = 0, p = 0; i < nrows; ++i) {\n for (let j = 0; j < ncols; ++j, ++p) {\n Ad[ p ] -= row[ j ]\n }\n }\n}\n\nexport function subCols (A: Matrix, col: number[]) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n\n for (let i = 0, p = 0; i < ncols; ++i) {\n for (let j = 0; j < nrows; ++j, ++p) {\n Ad[ p ] -= col[ j ]\n }\n }\n}\n\nexport function addRows (A: Matrix, row: number[]) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n\n for (let i = 0, p = 0; i < nrows; ++i) {\n for (let j = 0; j < ncols; ++j, ++p) {\n Ad[ p ] += row[ j ]\n }\n }\n}\n\nexport function addCols (A: Matrix, col: number[]) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n\n for (let i = 0, p = 0; i < ncols; ++i) {\n for (let j = 0; j < nrows; ++j, ++p) {\n Ad[ p ] += col[ j ]\n }\n }\n}\n\nexport function swap (A: NumberArray, i0: number, i1: number, t: number) {\n t = A[i0]\n A[i0] = A[i1]\n A[i1] = t\n}\n\nexport function hypot (a: number, b: number) {\n a = Math.abs(a)\n b = Math.abs(b)\n if (a > b) {\n b /= a\n return a * Math.sqrt(1.0 + b * b)\n }\n if (b > 0) {\n a /= b\n return b * Math.sqrt(1.0 + a * a)\n }\n return 0.0\n}\n\nconst EPSILON = 0.0000001192092896\nconst FLT_MIN = 1E-37\n\nexport function JacobiSVDImpl (At: NumberArray, astep: number, _W: NumberArray, Vt: NumberArray, vstep: number, m: number, n: number, n1: number) {\n const eps = EPSILON * 2.0\n const minval = FLT_MIN\n let i = 0\n let j = 0\n let k = 0\n let iter = 0\n const maxIter = Math.max(m, 30)\n let Ai = 0\n let Aj = 0\n let Vi = 0\n let Vj = 0\n let changed = 0\n let c = 0.0\n let s = 0.0\n let t = 0.0\n let t0 = 0.0\n let t1 = 0.0\n let sd = 0.0\n let beta = 0.0\n let gamma = 0.0\n let delta = 0.0\n let a = 0.0\n let p = 0.0\n let b = 0.0\n let seed = 0x1234\n let val = 0.0\n let val0 = 0.0\n let asum = 0.0\n\n const W = new Float64Array(n << 3)\n\n for (; i < n; i++) {\n for (k = 0, sd = 0; k < m; k++) {\n t = At[i * astep + k]\n sd += t * t\n }\n W[i] = sd\n\n if (Vt) {\n for (k = 0; k < n; k++) {\n Vt[i * vstep + k] = 0\n }\n Vt[i * vstep + i] = 1\n }\n }\n\n for (; iter < maxIter; iter++) {\n changed = 0\n\n for (i = 0; i < n - 1; i++) {\n for (j = i + 1; j < n; j++) {\n Ai = (i * astep) | 0\n Aj = (j * astep) | 0\n a = W[i]\n p = 0\n b = W[j]\n\n k = 2\n p += At[Ai] * At[Aj]\n p += At[Ai + 1] * At[Aj + 1]\n\n for (; k < m; k++) { p += At[Ai + k] * At[Aj + k] }\n\n if (Math.abs(p) <= eps * Math.sqrt(a * b)) continue\n\n p *= 2.0\n beta = a - b\n gamma = hypot(p, beta)\n if (beta < 0) {\n delta = (gamma - beta) * 0.5\n s = Math.sqrt(delta / gamma)\n c = (p / (gamma * s * 2.0))\n } else {\n c = Math.sqrt((gamma + beta) / (gamma * 2.0))\n s = (p / (gamma * c * 2.0))\n }\n\n a = 0.0\n b = 0.0\n\n k = 2 // unroll\n t0 = c * At[Ai] + s * At[Aj]\n t1 = -s * At[Ai] + c * At[Aj]\n At[Ai] = t0; At[Aj] = t1\n a += t0 * t0; b += t1 * t1\n\n t0 = c * At[Ai + 1] + s * At[Aj + 1]\n t1 = -s * At[Ai + 1] + c * At[Aj + 1]\n At[Ai + 1] = t0; At[Aj + 1] = t1\n a += t0 * t0; b += t1 * t1\n\n for (; k < m; k++) {\n t0 = c * At[Ai + k] + s * At[Aj + k]\n t1 = -s * At[Ai + k] + c * At[Aj + k]\n At[Ai + k] = t0; At[Aj + k] = t1\n\n a += t0 * t0; b += t1 * t1\n }\n\n W[i] = a\n W[j] = b\n\n changed = 1\n\n if (Vt) {\n Vi = (i * vstep) | 0\n Vj = (j * vstep) | 0\n\n k = 2\n t0 = c * Vt[Vi] + s * Vt[Vj]\n t1 = -s * Vt[Vi] + c * Vt[Vj]\n Vt[Vi] = t0; Vt[Vj] = t1\n\n t0 = c * Vt[Vi + 1] + s * Vt[Vj + 1]\n t1 = -s * Vt[Vi + 1] + c * Vt[Vj + 1]\n Vt[Vi + 1] = t0; Vt[Vj + 1] = t1\n\n for (; k < n; k++) {\n t0 = c * Vt[Vi + k] + s * Vt[Vj + k]\n t1 = -s * Vt[Vi + k] + c * Vt[Vj + k]\n Vt[Vi + k] = t0; Vt[Vj + k] = t1\n }\n }\n }\n }\n if (changed === 0) break\n }\n\n for (i = 0; i < n; i++) {\n for (k = 0, sd = 0; k < m; k++) {\n t = At[i * astep + k]\n sd += t * t\n }\n W[i] = Math.sqrt(sd)\n }\n\n for (i = 0; i < n - 1; i++) {\n j = i\n for (k = i + 1; k < n; k++) {\n if (W[j] < W[k]) { j = k }\n }\n if (i !== j) {\n swap(W, i, j, sd)\n if (Vt) {\n for (k = 0; k < m; k++) {\n swap(At, i * astep + k, j * astep + k, t)\n }\n\n for (k = 0; k < n; k++) {\n swap(Vt, i * vstep + k, j * vstep + k, t)\n }\n }\n }\n }\n\n for (i = 0; i < n; i++) {\n _W[i] = W[i]\n }\n\n if (!Vt) {\n return\n }\n\n for (i = 0; i < n1; i++) {\n sd = i < n ? W[i] : 0\n\n while (sd <= minval) {\n // if we got a zero singular value, then in order to get the corresponding left singular vector\n // we generate a random vector, project it to the previously computed left singular vectors,\n // subtract the projection and normalize the difference.\n val0 = (1.0 / m)\n for (k = 0; k < m; k++) {\n seed = (seed * 214013 + 2531011)\n val = (((seed >> 16) & 0x7fff) & 256) !== 0 ? val0 : -val0\n At[i * astep + k] = val\n }\n for (iter = 0; iter < 2; iter++) {\n for (j = 0; j < i; j++) {\n sd = 0\n for (k = 0; k < m; k++) {\n sd += At[i * astep + k] * At[j * astep + k]\n }\n asum = 0.0\n for (k = 0; k < m; k++) {\n t = (At[i * astep + k] - sd * At[j * astep + k])\n At[i * astep + k] = t\n asum += Math.abs(t)\n }\n asum = asum ? 1.0 / asum : 0\n for (k = 0; k < m; k++) {\n At[i * astep + k] *= asum\n }\n }\n }\n sd = 0\n for (k = 0; k < m; k++) {\n t = At[i * astep + k]\n sd += t * t\n }\n sd = Math.sqrt(sd)\n }\n\n s = (1.0 / sd)\n for (k = 0; k < m; k++) {\n At[i * astep + k] *= s\n }\n }\n}\n\nexport function svd (A: Matrix, W: Matrix, U: Matrix, V: Matrix) {\n let at = 0\n let i = 0\n const _m = A.rows\n const _n = A.cols\n let m = _m\n let n = _n\n\n if (m < n) {\n at = 1\n i = m\n m = n\n n = i\n }\n\n const amt = new Matrix(m, m)\n const wmt = new Matrix(1, n)\n const vmt = new Matrix(n, n)\n\n if (at === 0) {\n transpose(amt, A)\n } else {\n for (i = 0; i < _n * _m; i++) {\n amt.data[i] = A.data[i]\n }\n for (; i < n * m; i++) {\n amt.data[i] = 0\n }\n }\n\n JacobiSVDImpl(amt.data, m, wmt.data, vmt.data, n, m, n, m)\n\n if (W) {\n for (i = 0; i < n; i++) {\n W.data[i] = wmt.data[i]\n }\n for (; i < _n; i++) {\n W.data[i] = 0\n }\n }\n\n if (at === 0) {\n if (U) transpose(U, amt)\n if (V) transpose(V, vmt)\n } else {\n if (U) transpose(U, vmt)\n if (V) transpose(V, amt)\n }\n}\n\n//\n\nexport function m4new () {\n return new Float32Array([\n 1, 0, 0, 0,\n 0, 1, 0, 0,\n 0, 0, 1, 0,\n 0, 0, 0, 1\n ])\n}\n\nexport function m4set (out: Float32Array, n11: number, n12: number, n13: number, n14: number, n21: number, n22: number, n23: number, n24: number, n31: number, n32: number, n33: number, n34: number, n41: number, n42: number, n43: number, n44: number) {\n out[ 0 ] = n11; out[ 4 ] = n12; out[ 8 ] = n13; out[ 12 ] = n14\n out[ 1 ] = n21; out[ 5 ] = n22; out[ 9 ] = n23; out[ 13 ] = n24\n out[ 2 ] = n31; out[ 6 ] = n32; out[ 10 ] = n33; out[ 14 ] = n34\n out[ 3 ] = n41; out[ 7 ] = n42; out[ 11 ] = n43; out[ 15 ] = n44\n}\n\nexport function m4identity (out: Float32Array) {\n m4set(out,\n 1, 0, 0, 0,\n 0, 1, 0, 0,\n 0, 0, 1, 0,\n 0, 0, 0, 1\n )\n}\n(m4identity as any).__deps = [ m4set ]\n\nexport function m4multiply (out: Float32Array, a: Float32Array, b: Float32Array) {\n const a11 = a[ 0 ]\n const a12 = a[ 4 ]\n const a13 = a[ 8 ]\n const a14 = a[ 12 ]\n const a21 = a[ 1 ]\n const a22 = a[ 5 ]\n const a23 = a[ 9 ]\n const a24 = a[ 13 ]\n const a31 = a[ 2 ]\n const a32 = a[ 6 ]\n const a33 = a[ 10 ]\n const a34 = a[ 14 ]\n const a41 = a[ 3 ]\n const a42 = a[ 7 ]\n const a43 = a[ 11 ]\n const a44 = a[ 15 ]\n\n const b11 = b[ 0 ]\n const b12 = b[ 4 ]\n const b13 = b[ 8 ]\n const b14 = b[ 12 ]\n const b21 = b[ 1 ]\n const b22 = b[ 5 ]\n const b23 = b[ 9 ]\n const b24 = b[ 13 ]\n const b31 = b[ 2 ]\n const b32 = b[ 6 ]\n const b33 = b[ 10 ]\n const b34 = b[ 14 ]\n const b41 = b[ 3 ]\n const b42 = b[ 7 ]\n const b43 = b[ 11 ]\n const b44 = b[ 15 ]\n\n out[ 0 ] = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41\n out[ 4 ] = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42\n out[ 8 ] = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43\n out[ 12 ] = a11 * b14 + a12 * b24 + a13 * b34 + a14 * b44\n\n out[ 1 ] = a21 * b11 + a22 * b21 + a23 * b31 + a24 * b41\n out[ 5 ] = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42\n out[ 9 ] = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43\n out[ 13 ] = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44\n\n out[ 2 ] = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41\n out[ 6 ] = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42\n out[ 10 ] = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43\n out[ 14 ] = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44\n\n out[ 3 ] = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41\n out[ 7 ] = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42\n out[ 11 ] = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43\n out[ 15 ] = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44\n}\n\nexport function m4makeScale (out: Float32Array, x: number, y: number, z: number) {\n m4set(out,\n x, 0, 0, 0,\n 0, y, 0, 0,\n 0, 0, z, 0,\n 0, 0, 0, 1\n )\n}\n(m4makeScale as any).__deps = [ m4set ]\n\nexport function m4makeTranslation (out: Float32Array, x: number, y: number, z: number) {\n m4set(out,\n 1, 0, 0, x,\n 0, 1, 0, y,\n 0, 0, 1, z,\n 0, 0, 0, 1\n )\n}\n(m4makeTranslation as any).__deps = [ m4set ]\n\nexport function m4makeRotationY (out: Float32Array, theta: number) {\n const c = Math.cos(theta)\n const s = Math.sin(theta)\n m4set(out,\n c, 0, s, 0,\n 0, 1, 0, 0,\n -s, 0, c, 0,\n 0, 0, 0, 1\n )\n}\n(m4makeRotationY as any).__deps = [ m4set ]\n\n//\n\nexport function m3new () {\n return new Float32Array([\n 1, 0, 0,\n 0, 1, 0,\n 0, 0, 1\n ])\n}\n\nexport function m3makeNormal (out: Float32Array, m4: Float32Array) {\n const r0 = v3new([ m4[0], m4[1], m4[2] ])\n const r1 = v3new([ m4[4], m4[5], m4[6] ])\n const r2 = v3new([ m4[8], m4[9], m4[10] ])\n const cp = v3new()\n // [ r0 ] [ r1 x r2 ]\n // M3x3 = [ r1 ] N = [ r2 x r0 ]\n // [ r2 ] [ r0 x r1 ]\n v3cross(cp, r1, r2)\n out[ 0 ] = cp[ 0 ]\n out[ 1 ] = cp[ 1 ]\n out[ 2 ] = cp[ 2 ]\n v3cross(cp, r2, r0)\n out[ 3 ] = cp[ 0 ]\n out[ 4 ] = cp[ 1 ]\n out[ 5 ] = cp[ 2 ]\n v3cross(cp, r0, r1)\n out[ 6 ] = cp[ 0 ]\n out[ 7 ] = cp[ 1 ]\n out[ 8 ] = cp[ 2 ]\n}\n(m3makeNormal as any).__deps = [ v3new, v3cross ]\n","/**\n * @file Surface Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { degToRad } from '../math/math-utils'\nimport {\n m4new, m4multiply, m4makeTranslation, m4makeScale, m4makeRotationY\n} from '../math/matrix-utils'\nimport {\n v3addScalar, v3subScalar, v3divideScalar, v3multiplyScalar,\n v3floor, v3ceil, v3sub, v3negate,\n v3cross, v3fromArray, normalizeVector3array\n} from '../math/vector-utils'\nimport { NumberArray } from '../types'\n\nfunction laplacianSmooth (verts: Float32Array, faces: Float32Array, numiter: number, inflate: boolean) {\n // based on D. Xu, Y. Zhang (2009) Generating Triangulated Macromolecular\n // Surfaces by Euclidean Distance Transform. PLoS ONE 4(12): e8140.\n //\n // Permission to use, copy, modify, and distribute this program for\n // any purpose, with or without fee, is hereby granted, provided that\n // the notices on the head, the reference information, and this\n // copyright notice appear in all copies or substantial portions of\n // the Software. It is provided \"as is\" without express or implied\n // warranty.\n //\n // ported to JavaScript and adapted to NGL by Alexander Rose\n\n numiter = numiter || 1\n inflate = inflate || true\n\n const nv = verts.length / 3\n const nf = faces.length / 3\n let norms: Float32Array | undefined = undefined\n\n if (inflate) {\n norms = new Float32Array(nv * 3)\n }\n\n const tps = new Float32Array(nv * 3)\n\n let i\n const ndeg = 20\n const vertdeg = new Array(ndeg)\n\n for (i = 0; i < ndeg; ++i) {\n vertdeg[ i ] = new Uint32Array(nv)\n }\n\n for (i = 0; i < nv; ++i) {\n vertdeg[ 0 ][ i ] = 0\n }\n\n let j, jl\n let flagvert: boolean\n\n // for each face\n\n for (i = 0; i < nf; ++i) {\n var ao = i * 3\n var bo = i * 3 + 1\n var co = i * 3 + 2\n\n // vertex a\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ao] ]; j < jl; ++j) {\n if (faces[ bo ] === vertdeg[ j + 1 ][ faces[ ao ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ ao ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ ao ] ] ][ faces[ ao ] ] = faces[ bo ]\n }\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ ao ] ]; j < jl; ++j) {\n if (faces[ co ] === vertdeg[ j + 1 ][ faces[ ao ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ ao ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ ao ] ] ][ faces[ ao ] ] = faces[ co ]\n }\n\n // vertex b\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ bo ] ]; j < jl; ++j) {\n if (faces[ ao ] === vertdeg[ j + 1 ][ faces[ bo ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ bo ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ bo ] ] ][ faces[ bo ] ] = faces[ ao ]\n }\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ bo ] ]; j < jl; ++j) {\n if (faces[ co ] === vertdeg[ j + 1 ][ faces[ bo ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ bo ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ bo ] ] ][ faces[ bo ] ] = faces[ co ]\n }\n\n // vertex c\n\n flagvert = true\n for (j = 0; j < vertdeg[ 0 ][ faces[ co ] ]; ++j) {\n if (faces[ ao ] === vertdeg[ j + 1 ][ faces[ co ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ co ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ co ] ] ][ faces[ co ] ] = faces[ ao ]\n }\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ co ] ]; j < jl; ++j) {\n if (faces[ bo ] === vertdeg[ j + 1 ][ faces[ co ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ co ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ co ] ] ][ faces[ co ] ] = faces[ bo ]\n }\n }\n\n var wt = 1.0\n var wt2 = 0.5\n var i3, vi3, vdi, wtvi, wt2vi\n var ssign = -1\n var scaleFactor = 1\n var outwt = 0.75 / (scaleFactor + 3.5) // area-preserving\n\n // smoothing iterations\n\n for (var k = 0; k < numiter; ++k) {\n // for each vertex\n\n for (i = 0; i < nv; ++i) {\n i3 = i * 3\n vdi = vertdeg[ 0 ][ i ]\n\n if (vdi < 3) {\n tps[ i3 ] = verts[ i3 ]\n tps[ i3 + 1 ] = verts[ i3 + 1 ]\n tps[ i3 + 2 ] = verts[ i3 + 2 ]\n } else if (vdi === 3 || vdi === 4) {\n tps[ i3 ] = 0\n tps[ i3 + 1 ] = 0\n tps[ i3 + 2 ] = 0\n\n for (j = 0; j < vdi; ++j) {\n vi3 = vertdeg[ j + 1 ][ i ] * 3\n tps[ i3 ] += verts[ vi3 ]\n tps[ i3 + 1 ] += verts[ vi3 + 1 ]\n tps[ i3 + 2 ] += verts[ vi3 + 2 ]\n }\n\n tps[ i3 ] += wt2 * verts[ i3 ]\n tps[ i3 + 1 ] += wt2 * verts[ i3 + 1 ]\n tps[ i3 + 2 ] += wt2 * verts[ i3 + 2 ]\n\n wt2vi = wt2 + vdi\n tps[ i3 ] /= wt2vi\n tps[ i3 + 1 ] /= wt2vi\n tps[ i3 + 2 ] /= wt2vi\n } else {\n tps[ i3 ] = 0\n tps[ i3 + 1 ] = 0\n tps[ i3 + 2 ] = 0\n\n for (j = 0; j < vdi; ++j) {\n vi3 = vertdeg[ j + 1 ][ i ] * 3\n tps[ i3 ] += verts[ vi3 ]\n tps[ i3 + 1 ] += verts[ vi3 + 1 ]\n tps[ i3 + 2 ] += verts[ vi3 + 2 ]\n }\n\n tps[ i3 ] += wt * verts[ i3 ]\n tps[ i3 + 1 ] += wt * verts[ i3 + 1 ]\n tps[ i3 + 2 ] += wt * verts[ i3 + 2 ]\n\n wtvi = wt + vdi\n tps[ i3 ] /= wtvi\n tps[ i3 + 1 ] /= wtvi\n tps[ i3 + 2 ] /= wtvi\n }\n }\n\n verts.set(tps) // copy smoothed positions\n\n if (inflate) {\n computeVertexNormals(verts, faces, norms)\n var nv3 = nv * 3\n\n for (i3 = 0; i3 < nv3; i3 += 3) {\n // if(verts[i].inout) ssign=1;\n // else ssign=-1;\n\n verts[ i3 ] += ssign * outwt * norms![ i3 ]\n verts[ i3 + 1 ] += ssign * outwt * norms![ i3 + 1 ]\n verts[ i3 + 2 ] += ssign * outwt * norms![ i3 + 2 ]\n }\n }\n }\n}\nObject.assign(laplacianSmooth, {__deps: [ computeVertexNormals ]})\n\nfunction computeVertexNormals (position: Float32Array, index?: NumberArray, normal?: Float32Array) {\n var i, il\n\n if (normal === undefined) {\n normal = new Float32Array(position.length)\n } else {\n // reset existing normals to zero\n for (i = 0, il = normal.length; i < il; i++) {\n normal[ i ] = 0\n }\n }\n\n var a = new Float32Array(3)\n var b = new Float32Array(3)\n var c = new Float32Array(3)\n var cb = new Float32Array(3)\n var ab = new Float32Array(3)\n\n if (index) {\n // indexed elements\n for (i = 0, il = index.length; i < il; i += 3) {\n var ai = index[ i ] * 3\n var bi = index[ i + 1 ] * 3\n var ci = index[ i + 2 ] * 3\n\n v3fromArray(a, position, ai)\n v3fromArray(b, position, bi)\n v3fromArray(c, position, ci)\n\n v3sub(cb, c, b)\n v3sub(ab, a, b)\n v3cross(cb, cb, ab)\n\n normal[ ai ] += cb[ 0 ]\n normal[ ai + 1 ] += cb[ 1 ]\n normal[ ai + 2 ] += cb[ 2 ]\n\n normal[ bi ] += cb[ 0 ]\n normal[ bi + 1 ] += cb[ 1 ]\n normal[ bi + 2 ] += cb[ 2 ]\n\n normal[ ci ] += cb[ 0 ]\n normal[ ci + 1 ] += cb[ 1 ]\n normal[ ci + 2 ] += cb[ 2 ]\n }\n } else {\n // non-indexed elements (unconnected triangle soup)\n for (i = 0, il = position.length; i < il; i += 9) {\n v3fromArray(a, position, i)\n v3fromArray(b, position, i + 3)\n v3fromArray(c, position, i + 6)\n\n v3sub(cb, c, b)\n v3sub(ab, a, b)\n v3cross(cb, cb, ab)\n\n normal[ i ] = cb[ 0 ]\n normal[ i + 1 ] = cb[ 1 ]\n normal[ i + 2 ] = cb[ 2 ]\n\n normal[ i + 3 ] = cb[ 0 ]\n normal[ i + 4 ] = cb[ 1 ]\n normal[ i + 5 ] = cb[ 2 ]\n\n normal[ i + 6 ] = cb[ 0 ]\n normal[ i + 7 ] = cb[ 1 ]\n normal[ i + 8 ] = cb[ 2 ]\n }\n }\n\n normalizeVector3array(normal)\n\n return normal\n}\nObject.assign(computeVertexNormals, {__deps: [\n v3sub, v3cross, v3fromArray, normalizeVector3array\n]})\n\nfunction getRadiusDict (radiusList: number[]) {\n var radiusDict: {[k: number]: boolean} = {}\n for (var i = 0, il = radiusList.length; i < il; ++i) {\n radiusDict[ radiusList[ i ] ] = true\n }\n return radiusDict\n}\n\nfunction getSurfaceGrid (min: Float32Array, max: Float32Array, maxRadius: number, scaleFactor: number, extraMargin: number) {\n // need margin to avoid boundary/round off effects\n var margin = (1 / scaleFactor) * 3\n margin += maxRadius\n\n v3subScalar(min, min, extraMargin + margin)\n v3addScalar(max, max, extraMargin + margin)\n\n v3multiplyScalar(min, min, scaleFactor)\n v3floor(min, min)\n v3divideScalar(min, min, scaleFactor)\n\n v3multiplyScalar(max, max, scaleFactor)\n v3ceil(max, max)\n v3divideScalar(max, max, scaleFactor)\n\n var dim = new Float32Array(3)\n v3sub(dim, max, min)\n v3multiplyScalar(dim, dim, scaleFactor)\n v3ceil(dim, dim)\n v3addScalar(dim, dim, 1)\n\n var maxSize = Math.pow(10, 6) * 256\n var tmpSize = dim[ 0 ] * dim[ 1 ] * dim[ 2 ] * 3\n\n if (maxSize <= tmpSize) {\n scaleFactor *= Math.pow(maxSize / tmpSize, 1 / 3)\n\n v3multiplyScalar(min, min, scaleFactor)\n v3floor(min, min)\n v3divideScalar(min, min, scaleFactor)\n\n v3multiplyScalar(max, max, scaleFactor)\n v3ceil(max, max)\n v3divideScalar(max, max, scaleFactor)\n\n v3sub(dim, max, min)\n v3multiplyScalar(dim, dim, scaleFactor)\n v3ceil(dim, dim)\n v3addScalar(dim, dim, 1)\n }\n\n var tran = new Float32Array(min)\n v3negate(tran, tran)\n\n // coordinate transformation matrix\n var matrix = m4new()\n var mroty = m4new()\n m4makeRotationY(mroty, degToRad(90))\n m4multiply(matrix, matrix, mroty)\n\n var mscale = m4new()\n m4makeScale(\n mscale,\n -1 / scaleFactor,\n 1 / scaleFactor,\n 1 / scaleFactor\n )\n m4multiply(matrix, matrix, mscale)\n\n var mtrans = m4new()\n m4makeTranslation(\n mtrans,\n -scaleFactor * tran[2],\n -scaleFactor * tran[1],\n -scaleFactor * tran[0]\n )\n m4multiply(matrix, matrix, mtrans)\n\n return {\n dim: dim,\n tran: tran,\n matrix: matrix,\n scaleFactor: scaleFactor\n }\n}\nObject.assign(getSurfaceGrid, {__deps: [\n degToRad,\n v3subScalar, v3addScalar, v3divideScalar, v3multiplyScalar,\n v3floor, v3ceil, v3sub, v3negate,\n m4new, m4multiply, m4makeTranslation, m4makeScale, m4makeRotationY\n]})\n\nexport {\n laplacianSmooth,\n computeVertexNormals,\n getRadiusDict,\n getSurfaceGrid\n}\n","/**\n * @file Surface\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3, Geometry, BufferGeometry, Group, Color } from 'three'\n\nimport { Debug, Log, ColormakerRegistry } from '../globals'\nimport { getUintArray } from '../utils'\nimport { AtomPicker, SurfacePicker } from '../utils/picker'\nimport { uniformArray, uniformArray3, serialArray } from '../math/array-utils'\nimport Selection from '../selection/selection'\nimport { ColormakerParameters } from '../color/colormaker';\nimport { Structure, Volume } from '../ngl';\n\nexport interface SurfaceData {\n position: Float32Array\n index: Uint32Array|Uint16Array|undefined\n normal: Float32Array\n color: Float32Array\n atomindex: Int32Array\n contour: boolean\n}\n/**\n * Surface\n */\nclass Surface {\n name: string\n path: string\n position: Float32Array\n index: Uint32Array|Uint16Array|undefined\n normal: Float32Array|undefined\n color: Float32Array|undefined\n atomindex: Int32Array|undefined\n contour: boolean\n center: Vector3\n boundingBox: Box3\n size: number\n info: {\n type?: string\n probeRadius?: number\n scaleFactor?: number\n smooth?: number\n cutoff?: number\n isolevel?: number\n volume?: Volume\n }\n\n /**\n * @param {String} name - surface name\n * @param {String} path - source path\n * @param {Object} data - surface data\n * @param {Float32Array} data.position - surface positions\n * @param {Int32Array} data.index - surface indices\n * @param {Float32Array} data.normal - surface normals\n * @param {Float32Array} data.color - surface colors\n * @param {Int32Array} data.atomindex - atom indices\n * @param {boolean} data.contour - contour mode flag\n */\n constructor (name: string, path: string, data?: SurfaceData) {\n this.name = name || ''\n this.path = path || ''\n this.info = {}\n\n this.center = new Vector3()\n this.boundingBox = new Box3()\n\n if (data instanceof Geometry ||\n data instanceof BufferGeometry ||\n data instanceof Group\n ) {\n // to be removed\n this.fromGeometry(data)\n } else if (data) {\n this.set(\n data.position,\n data.index,\n data.normal,\n data.color,\n data.atomindex,\n data.contour\n )\n\n this.boundingBox.setFromArray(data.position)\n this.boundingBox.getCenter(this.center)\n }\n }\n\n get type () { return 'Surface' }\n\n /**\n * set surface data\n * @param {Float32Array} position - surface positions\n * @param {Int32Array} index - surface indices\n * @param {Float32Array} normal - surface normals\n * @param {Float32Array} color - surface colors\n * @param {Int32Array} atomindex - atom indices\n * @param {boolean} contour - contour mode flag\n * @return {undefined}\n */\n set (position: Float32Array,\n index: Uint32Array|Uint16Array|undefined,\n normal: Float32Array|undefined,\n color: Float32Array|undefined,\n atomindex: Int32Array|undefined,\n contour: boolean = false) {\n /**\n * @type {Float32Array}\n */\n this.position = position\n /**\n * @type {Uint32Array|Uint16Array|undefined}\n */\n this.index = index\n /**\n * @type {Float32Array|undefined}\n */\n this.normal = normal\n /**\n * @type {Float32Array|undefined}\n */\n this.color = color\n /**\n * @type {Int32Array|undefined}\n */\n this.atomindex = atomindex\n\n this.size = position.length / 3\n this.contour = contour\n }\n\n fromGeometry (geometry: Geometry|BufferGeometry|Group) {\n if (Debug) Log.time('GeometrySurface.fromGeometry')\n\n let geo\n\n if (geometry instanceof Geometry) {\n geometry.computeVertexNormals(true)\n geo = new BufferGeometry().fromGeometry(geometry)\n } else if (geometry instanceof BufferGeometry) {\n geo = geometry\n } else {\n geo = (geometry as any)[ 0 ]\n }\n\n if (!geo.boundingBox) geo.computeBoundingBox()\n\n this.boundingBox.copy(geo.boundingBox)\n this.boundingBox.getCenter(this.center)\n\n let position, color, index, normal\n\n if (geo instanceof BufferGeometry) {\n const attr = geo.attributes\n const an = (attr as any).normal ? (attr as any).normal.array : false\n\n // assume there are no normals if the first is zero\n if (!an || (an[ 0 ] === 0 && an[ 1 ] === 0 && an[ 2 ] === 0)) {\n geo.computeVertexNormals()\n }\n\n position = (attr).position.array\n index = (attr).index ? (attr).index.array : null\n normal = (attr).normal.array\n }\n\n this.set(position, index, normal, color, undefined)\n\n if (Debug) Log.timeEnd('GeometrySurface.setGeometry')\n }\n\n getPosition () {\n return this.position\n }\n\n getColor (params: ColormakerParameters&{ scheme: string}) {\n const p = params || {}\n p.surface = this\n\n const n = this.size\n const array = new Float32Array(n * 3)\n const colormaker = ColormakerRegistry.getScheme(p)\n\n if (colormaker.volumeColor || p.scheme === 'random') {\n for (let i = 0; i < n; ++i) {\n colormaker.volumeColorToArray(i, array, i * 3)\n }\n } else if (colormaker.positionColor) {\n const v = new Vector3()\n const pos = this.position\n\n for (let i = 0; i < n; ++i) {\n var i3 = i * 3\n v.set(pos[ i3 ], pos[ i3 + 1 ], pos[ i3 + 2 ])\n colormaker.positionColorToArray(v, array, i3)\n }\n } else if (colormaker.atomColor && this.atomindex) {\n const atomProxy = p.structure!.getAtomProxy()\n const atomindex = this.atomindex\n\n for (let i = 0; i < n; ++i) {\n atomProxy.index = atomindex[ i ]\n colormaker.atomColorToArray(atomProxy, array, i * 3)\n }\n } else {\n const tc = new Color(p.value)\n uniformArray3(n, tc.r, tc.g, tc.b, array)\n }\n\n return array\n }\n\n getPicking (structure?: Structure) {\n if (this.atomindex && structure) {\n return new AtomPicker(this.atomindex as any, structure)\n } else {\n return new SurfacePicker(serialArray(this.size), this)\n }\n }\n\n getNormal () {\n return this.normal\n }\n\n getSize (size: number, scale: number) {\n return uniformArray(this.size, size * scale)\n }\n\n getIndex () {\n return this.index\n }\n\n getFilteredIndex (sele: string, structure: Structure) {\n if (sele && this.atomindex) {\n const selection = new Selection(sele)\n const atomSet = structure.getAtomSet(selection)\n const filteredIndex = []\n\n const atomindex = this.atomindex\n const index = this.index\n const n = index!.length\n const elementSize = this.contour ? 2 : 3\n\n let j = 0\n\n for (let i = 0; i < n; i += elementSize) {\n let include = true\n\n for (let a = 0; a < elementSize; a++) {\n const idx = index![ i + a ]\n const ai = atomindex[ idx ]\n if (!atomSet.get(ai)) {\n include = false\n break\n }\n }\n\n if (!include) { continue }\n\n for (let a = 0; a < elementSize; a++, j++) {\n filteredIndex[ j ] = index![ i + a ]\n }\n }\n\n return getUintArray(filteredIndex, this.position.length / 3)\n } else {\n return this.index\n }\n }\n\n getAtomindex () {\n return this.atomindex\n }\n\n dispose () {\n\n //\n\n }\n}\n\nexport default Surface\n","/**\n * @file Volume\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3, Matrix3, Matrix4 } from 'three'\n\nimport { WorkerRegistry, ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport WorkerPool from '../worker/worker-pool'\nimport { VolumePicker } from '../utils/picker'\nimport {\n uniformArray, serialArray,\n arrayMin, arrayMax, arraySum, arrayMean, arrayRms\n} from '../math/array-utils'\nimport MarchingCubes from './marching-cubes'\nimport { laplacianSmooth, computeVertexNormals } from './surface-utils'\nimport {\n applyMatrix4toVector3array, applyMatrix3toVector3array\n} from '../math/vector-utils'\nimport { m3new, m3makeNormal } from '../math/matrix-utils'\nimport Surface from './surface'\nimport { NumberArray } from '../types';\nimport { ColormakerParameters } from '../color/colormaker';\n\nexport interface VolumeSurface {\n new (data: NumberArray, nx: number, ny: number, nz: number, atomindex: NumberArray): void\n getSurface: (isolevel: number, smooth: boolean|number, box: number[][]|undefined, matrix: Float32Array, contour: boolean, wrap?: boolean) => {\n position: Float32Array\n normal: undefined|Float32Array\n index: Uint32Array|Uint16Array\n atomindex: Int32Array|undefined\n contour: boolean\n }\n}\nexport function VolumeSurface (this: VolumeSurface,data: NumberArray, nx: number, ny: number, nz: number, atomindex: NumberArray) {\n var mc = new (MarchingCubes as any)(data, nx, ny, nz, atomindex) as MarchingCubes\n\n function getSurface (isolevel: number, smooth: boolean|number, box: number[][]|undefined, matrix: Float32Array, contour: boolean, wrap: boolean = false) {\n const sd = mc.triangulate(isolevel, smooth as boolean, box, contour, wrap)\n if (smooth && !contour) {\n laplacianSmooth(sd.position, sd.index as any, smooth as number, true)\n sd.normal = computeVertexNormals(sd.position, sd.index as any)\n }\n if (matrix) {\n applyMatrix4toVector3array(matrix, sd.position)\n if (sd.normal) {\n const normalMatrix = m3new()\n m3makeNormal(normalMatrix, matrix)\n applyMatrix3toVector3array(normalMatrix, sd.normal)\n }\n }\n return sd\n }\n\n this.getSurface = getSurface\n}\nObject.assign(VolumeSurface, {__deps: [\n laplacianSmooth, computeVertexNormals, MarchingCubes,\n applyMatrix4toVector3array, applyMatrix3toVector3array,\n m3new, m3makeNormal\n]})\n\nWorkerRegistry.add('surf', function func (e: any, callback: (data: any, transferList: any) => void) {\n const a = e.data.args\n const p = e.data.params\n if (a) {\n /* global self */\n (self as any).volsurf = new (VolumeSurface as any)(a[0], a[1], a[2], a[3], a[4]) as VolumeSurface\n }\n if (p) {\n const sd = ((self as any).volsurf as VolumeSurface).getSurface(\n p.isolevel, p.smooth, p.box, p.matrix, p.contour, p.wrap\n )\n const transferList = [ sd.position.buffer, sd.index.buffer ]\n if (sd.normal) transferList.push(sd.normal.buffer)\n if (sd.atomindex) transferList.push(sd.atomindex.buffer)\n const data = {\n sd: sd,\n p: p\n }\n callback(data, transferList)\n }\n}, [ VolumeSurface ])\n\nexport type VolumeSize = 'value'|'abs-value'|'value-min'|'deviation'\n/**\n * Volume\n */\nclass Volume {\n name: string\n path: string\n\n matrix: Matrix4\n normalMatrix: Matrix3\n inverseMatrix: Matrix4\n center: Vector3\n boundingBox: Box3\n\n nx: number\n ny: number\n nz: number\n data: Float32Array\n\n worker: Worker\n workerPool: WorkerPool\n _position: Float32Array\n _min: number|undefined\n _max: number|undefined\n _mean: number|undefined\n _rms: number|undefined\n _sum: number|undefined\n __box: Box3|undefined\n\n atomindex: Int32Array|undefined\n volsurf: VolumeSurface|undefined\n header: any\n /**\n * Make Volume instance\n * @param {String} name - volume name\n * @param {String} path - source path\n * @param {Float32array} data - volume 3d grid\n * @param {Integer} nx - x dimension of the 3d volume\n * @param {Integer} ny - y dimension of the 3d volume\n * @param {Integer} nz - z dimension of the 3d volume\n * @param {Int32Array} atomindex - atom indices corresponding to the cells in the 3d grid\n */\n constructor (name: string, path: string, data?: Float32Array, nx?: number, ny?: number, nz?: number, atomindex?: Int32Array) {\n this.name = name\n this.path = path\n\n this.matrix = new Matrix4()\n this.normalMatrix = new Matrix3()\n this.inverseMatrix = new Matrix4()\n this.center = new Vector3()\n this.boundingBox = new Box3()\n\n this.setData(data, nx, ny, nz, atomindex)\n }\n\n get type () { return 'Volume' }\n\n /**\n * set volume data\n * @param {Float32array} data - volume 3d grid\n * @param {Integer} nx - x dimension of the 3d volume\n * @param {Integer} ny - y dimension of the 3d volume\n * @param {Integer} nz - z dimension of the 3d volume\n * @param {Int32Array} atomindex - atom indices corresponding to the cells in the 3d grid\n * @return {undefined}\n */\n setData (data?: Float32Array, nx?: number, ny?: number, nz?: number, atomindex?: Int32Array) {\n this.nx = nx || 1\n this.ny = ny || 1\n this.nz = nz || 1\n\n this.data = data || new Float32Array(1)\n this.setAtomindex(atomindex)\n\n this._position = new Float32Array()\n\n delete this._min\n delete this._max\n delete this._mean\n delete this._rms\n\n if (this.worker) this.worker.terminate()\n }\n\n /**\n * Set statistics, which can be different from the data in this volume,\n * if this volume is a slice of a bigger volume\n * @param {Number|undefined} min - minimum value of the whole data set\n * @param {Number|undefined} max - maximum value of the whole data set\n * @param {Number|undefined} mean - average value of the whole data set\n * @param {Number|undefined} rms - sigma value of the whole data set\n */\n setStats (min: number|undefined, max: number|undefined, mean: number|undefined, rms: number|undefined) {\n this._min = min\n this._max = max\n this._mean = mean\n this._rms = rms\n }\n\n /**\n * set transformation matrix\n * @param {Matrix4} matrix - 4x4 transformation matrix\n * @return {undefined}\n */\n setMatrix (matrix: Matrix4) {\n this.matrix.copy(matrix)\n\n const bb = this.boundingBox\n const v = this.center // temporary re-purposing\n\n const x = this.nx - 1\n const y = this.ny - 1\n const z = this.nz - 1\n\n bb.makeEmpty()\n\n bb.expandByPoint(v.set(x, y, z))\n bb.expandByPoint(v.set(x, y, 0))\n bb.expandByPoint(v.set(x, 0, z))\n bb.expandByPoint(v.set(x, 0, 0))\n bb.expandByPoint(v.set(0, y, z))\n bb.expandByPoint(v.set(0, 0, z))\n bb.expandByPoint(v.set(0, y, 0))\n bb.expandByPoint(v.set(0, 0, 0))\n\n bb.applyMatrix4(this.matrix)\n bb.getCenter(this.center)\n\n // make normal matrix\n\n const me = this.matrix.elements\n const r0 = new Vector3(me[0], me[1], me[2])\n const r1 = new Vector3(me[4], me[5], me[6])\n const r2 = new Vector3(me[8], me[9], me[10])\n const cp = new Vector3()\n // [ r0 ] [ r1 x r2 ]\n // M3x3 = [ r1 ] N = [ r2 x r0 ]\n // [ r2 ] [ r0 x r1 ]\n const ne = this.normalMatrix.elements\n cp.crossVectors(r1, r2)\n ne[ 0 ] = cp.x\n ne[ 1 ] = cp.y\n ne[ 2 ] = cp.z\n cp.crossVectors(r2, r0)\n ne[ 3 ] = cp.x\n ne[ 4 ] = cp.y\n ne[ 5 ] = cp.z\n cp.crossVectors(r0, r1)\n ne[ 6 ] = cp.x\n ne[ 7 ] = cp.y\n ne[ 8 ] = cp.z\n\n this.inverseMatrix.getInverse(this.matrix)\n }\n\n /**\n * set atom indices\n * @param {Int32Array} atomindex - atom indices corresponding to the cells in the 3d grid\n * @return {undefined}\n */\n setAtomindex (atomindex?: Int32Array) {\n this.atomindex = atomindex\n }\n\n getBox (center: Vector3, size: number, target: Box3) {\n if (!target) target = new Box3()\n\n target.set(center, center)\n target.expandByScalar(size)\n target.applyMatrix4(this.inverseMatrix)\n\n target.min.round()\n target.max.round()\n\n return target\n }\n\n _getBox (center: Vector3|undefined, size: number) {\n if (!center || !size) return\n\n if (!this.__box) this.__box = new Box3()\n const box = this.getBox(center, size, this.__box)\n return [ box.min.toArray(), box.max.toArray() ]\n }\n\n _makeSurface (sd: any, isolevel: number, smooth: number) {\n const name = this.name + '@' + isolevel.toPrecision(2)\n const surface = new Surface(name, '', sd)\n surface.info.isolevel = isolevel\n surface.info.smooth = smooth\n surface.info.volume = this\n\n return surface\n }\n\n getSurface (isolevel: number, smooth: number, center: Vector3, size: number, contour: boolean, wrap: boolean = false) {\n isolevel = isNaN(isolevel) ? this.getValueForSigma(2) : isolevel\n smooth = defaults(smooth, 0)\n\n //\n\n if (this.volsurf === undefined) {\n this.volsurf = new (VolumeSurface as any)(\n this.data, this.nx, this.ny, this.nz, this.atomindex\n ) as VolumeSurface\n }\n\n const box = this._getBox(center, size)\n const sd = this.volsurf.getSurface(\n isolevel, smooth, box!, this.matrix.elements as unknown as Float32Array, contour, wrap\n )\n\n return this._makeSurface(sd, isolevel, smooth)\n }\n\n getSurfaceWorker (isolevel: number, smooth: number, center: Vector3, size: number, contour: boolean, wrap: boolean, callback: (s: Surface) => void) {\n isolevel = isNaN(isolevel) ? this.getValueForSigma(2) : isolevel\n smooth = smooth || 0\n\n //\n\n if (window.hasOwnProperty('Worker')) {\n if (this.workerPool === undefined) {\n this.workerPool = new WorkerPool('surf', 2)\n }\n\n const msg = {}\n const worker = this.workerPool.getNextWorker()\n\n if (worker!.postCount === 0) {\n Object.assign(msg, {\n args: [\n this.data, this.nx, this.ny, this.nz, this.atomindex\n ]\n })\n }\n\n Object.assign(msg, {\n params: {\n isolevel: isolevel,\n smooth: smooth,\n box: this._getBox(center, size),\n matrix: this.matrix.elements,\n contour: contour,\n wrap: wrap\n }\n })\n\n worker!.post(msg, undefined,\n (e: any) => {\n const sd = e.data.sd\n const p = e.data.p\n callback(this._makeSurface(sd, p.isolevel, p.smooth))\n },\n (e : string) => {\n console.warn(\n 'Volume.getSurfaceWorker error - trying without worker', e\n )\n const surface = this.getSurface(isolevel, smooth, center, size, contour, wrap)\n callback(surface)\n }\n )\n } else {\n const surface = this.getSurface(isolevel, smooth, center, size, contour, wrap)\n callback(surface)\n }\n }\n\n getValueForSigma (sigma: number) {\n return this.mean + defaults(sigma, 2) * this.rms\n }\n\n getSigmaForValue (value: number) {\n return (defaults(value, 0) - this.mean) / this.rms\n }\n\n get position () {\n if (!this._position) {\n const nz = this.nz\n const ny = this.ny\n const nx = this.nx\n const position = new Float32Array(nx * ny * nz * 3)\n\n let p = 0\n for (let z = 0; z < nz; ++z) {\n for (let y = 0; y < ny; ++y) {\n for (let x = 0; x < nx; ++x) {\n position[ p + 0 ] = x\n position[ p + 1 ] = y\n position[ p + 2 ] = z\n p += 3\n }\n }\n }\n\n applyMatrix4toVector3array(this.matrix.elements as unknown as Float32Array, position)\n this._position = position\n }\n\n return this._position\n }\n\n getDataAtomindex () {\n return this.atomindex\n }\n\n getDataPosition () {\n return this.position\n }\n\n getDataColor (params: ColormakerParameters & {scheme: string}) {\n const p = params || {}\n p.volume = this\n p.scale = p.scale || 'Spectral'\n p.domain = p.domain || [ this.min, this.max ]\n\n const colormaker = ColormakerRegistry.getScheme(p)\n\n const n = this.position.length / 3\n const array = new Float32Array(n * 3)\n\n // var atoms = p.structure.atoms;\n // var atomindex = this.atomindex;\n\n for (let i = 0; i < n; ++i) {\n colormaker.volumeColorToArray(i, array, i * 3)\n // a = atoms[ atomindex[ i ] ];\n // if( a ) colormaker.atomColorToArray( a, array, i * 3 );\n }\n\n return array\n }\n\n getDataPicking () {\n const picking = serialArray(this.position.length / 3)\n return new VolumePicker(picking, this)\n }\n\n getDataSize (size: VolumeSize|number, scale: number) {\n const data = this.data\n const n = this.position.length / 3\n let array\n\n switch (size) {\n case 'value':\n array = new Float32Array(data)\n break\n\n case 'abs-value':\n array = new Float32Array(data)\n for (let i = 0; i < n; ++i) {\n array[ i ] = Math.abs(array[ i ])\n }\n break\n\n case 'value-min': {\n array = new Float32Array(data)\n const min = this.min\n for (let i = 0; i < n; ++i) {\n array[ i ] -= min\n }\n break\n }\n\n case 'deviation':\n array = new Float32Array(data)\n break\n\n default:\n array = uniformArray(n, size)\n break\n }\n\n if (scale !== 1.0) {\n for (let i = 0; i < n; ++i) {\n array[ i ] *= scale\n }\n }\n\n return array\n }\n\n get min () {\n if (this._min === undefined) {\n this._min = arrayMin(this.data)\n }\n return this._min\n }\n\n get max () {\n if (this._max === undefined) {\n this._max = arrayMax(this.data)\n }\n return this._max\n }\n\n get sum () {\n if (this._sum === undefined) {\n this._sum = arraySum(this.data)\n }\n return this._sum\n }\n\n get mean () {\n if (this._mean === undefined) {\n this._mean = arrayMean(this.data)\n }\n return this._mean\n }\n\n get rms () {\n if (this._rms === undefined) {\n this._rms = arrayRms(this.data)\n }\n return this._rms\n }\n\n clone () {\n const vol = new Volume(\n this.name,\n this.path,\n\n this.data,\n\n this.nx,\n this.ny,\n this.nz,\n\n this.atomindex\n )\n\n vol.matrix.copy(this.matrix)\n vol.header = Object.assign({}, this.header)\n\n return vol\n }\n\n dispose () {\n if (this.workerPool) this.workerPool.terminate()\n }\n}\n\nexport default Volume\n","/**\n * @file Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport {\n Color, Vector3, Matrix4,\n FrontSide, BackSide, DoubleSide,\n // VertexColors,\n NoBlending,\n BufferGeometry, BufferAttribute,\n UniformsUtils, UniformsLib, Uniform,\n Group, LineSegments, Points, Mesh, Object3D,\n ShaderMaterial\n} from 'three'\n\nimport { Log } from '../globals'\nimport { createParams, getTypedArray, getUintArray } from '../utils'\nimport { GenericColor, NumberArray } from '../types'\nimport { getShader, ShaderDefines } from '../shader/shader-utils'\nimport { serialArray } from '../math/array-utils'\nimport { Picker } from '../utils/picker'\n\nexport type BufferSide = 'front'|'back'|'double'\n\nfunction getThreeSide (side: BufferSide) {\n if (side === 'front') {\n return FrontSide\n } else if (side === 'back') {\n return BackSide\n } else if (side === 'double') {\n return DoubleSide\n } else {\n return DoubleSide\n }\n}\n\nconst itemSize = {\n 'f': 1, 'v2': 2, 'v3': 3, 'c': 3\n}\n\nfunction setObjectMatrix (object: Object3D, matrix: Matrix4) {\n object.matrix.copy(matrix)\n object.matrix.decompose(object.position, object.quaternion, object.scale)\n object.matrixWorldNeedsUpdate = true\n}\n\nexport type BufferTypes = 'picking'|'background'\nexport type BufferMaterials = 'material'|'wireframeMaterial'|'pickingMaterial'\n\nexport interface _BufferAttribute {\n type: 'f'|'v2'|'v3'|'c'\n value?: NumberArray\n}\n\nexport type Uniforms = { [k: string]: Uniform|{ value: any } }\n\nexport const BufferDefaultParameters = {\n opaqueBack: false,\n side: 'double' as BufferSide, // which triangle sides to render\n opacity: 1.0, // translucency: 1 is fully opaque, 0 is fully transparent\n depthWrite: true,\n clipNear: 0, // position of camera near/front clipping plane in percent of scene bounding box\n clipRadius: 0,\n clipCenter: new Vector3(),\n flatShaded: false, // render flat shaded\n wireframe: false, // render as wireframe\n roughness: 0.4, // how rough the material is, between 0 and 1\n metalness: 0.0, // how metallic the material is, between 0 and 1\n diffuse: 0xffffff, // diffuse color for lighting\n diffuseInterior: false,\n useInteriorColor: false, // render back-side with interior color\n interiorColor: 0xdddddd, // interior color\n interiorDarkening: 0, // interior darkening factor\n forceTransparent: false, // force the material to allow transparency\n matrix: new Matrix4(), // additional transformation matrix\n disablePicking: false, // disable picking\n sortParticles: false,\n background: false\n}\nexport type BufferParameters = Omit & { diffuse: GenericColor; interiorColor: GenericColor }\n\nexport const BufferParameterTypes = {\n opaqueBack: { updateShader: true },\n side: { updateShader: true, property: true },\n opacity: { uniform: true },\n depthWrite: { property: true },\n clipNear: { updateShader: true, property: true },\n clipRadius: { updateShader: true, uniform: true },\n clipCenter: { uniform: true },\n flatShaded: { updateShader: true },\n background: { updateShader: true },\n wireframe: { updateVisibility: true },\n roughness: { uniform: true },\n metalness: { uniform: true },\n diffuse: { uniform: true },\n diffuseInterior: { updateShader: true },\n useInteriorColor: { updateShader: true },\n interiorColor: { uniform: true },\n interiorDarkening: { uniform: true },\n matrix: {}\n}\n\nexport interface BufferData {\n position?: Float32Array\n position1?: Float32Array // TODO\n color?: Float32Array\n index?: Uint32Array|Uint16Array\n normal?: Float32Array\n\n picking?: Picker\n primitiveId?: Float32Array\n}\n\n/**\n * Buffer class. Base class for buffers.\n * @interface\n */\nclass Buffer {\n parameterTypes = BufferParameterTypes\n get defaultParameters() { return BufferDefaultParameters }\n parameters: BufferParameters\n uniforms: Uniforms\n pickingUniforms: Uniforms\n\n private _positionDataSize: number\n\n geometry = new BufferGeometry()\n indexVersion = 0\n wireframeIndexVersion = -1\n group = new Group()\n wireframeGroup = new Group()\n pickingGroup = new Group()\n\n vertexShader = ''\n fragmentShader = ''\n isImpostor = false\n isText = false\n isSurface = false\n isPoint = false\n isLine = false\n dynamic = true\n visible = true\n\n picking?: Picker\n\n material: ShaderMaterial\n wireframeMaterial: ShaderMaterial\n pickingMaterial: ShaderMaterial\n\n wireframeIndex?: Uint32Array|Uint16Array\n wireframeIndexCount = 0\n wireframeGeometry?: BufferGeometry\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Uint32Array|Uint16Array} data.index - triangle indices\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} params - parameters object\n */\n constructor (data: BufferData, params: Partial = {}) {\n this.parameters = createParams(params, this.defaultParameters)\n\n this.uniforms = UniformsUtils.merge([\n UniformsLib.common,\n {\n fogColor: { value: new Color(0x000000) },\n fogNear: { value: 0.0 },\n fogFar: { value: 0.0 },\n opacity: { value: this.parameters.opacity },\n clipNear: { value: 0.0 },\n clipRadius: { value: this.parameters.clipRadius },\n clipCenter: { value: this.parameters.clipCenter }\n },\n {\n emissive: { value: new Color(0x000000) },\n roughness: { value: this.parameters.roughness },\n metalness: { value: this.parameters.metalness },\n interiorColor: { value: new Color(this.parameters.interiorColor) },\n interiorDarkening: { value: this.parameters.interiorDarkening },\n },\n UniformsLib.lights\n ])\n\n this.uniforms.diffuse.value.set(this.parameters.diffuse)\n\n this.pickingUniforms = {\n clipNear: { value: 0.0 },\n objectId: { value: 0 },\n opacity: { value: this.parameters.opacity }\n }\n\n //\n\n const position = data.position || data.position1\n this._positionDataSize = position ? position.length / 3 : 0\n\n if (!data.primitiveId) {\n data.primitiveId = serialArray(this._positionDataSize)\n }\n\n this.addAttributes({\n position: { type: 'v3', value: data.position },\n color: { type: 'c', value: data.color },\n primitiveId: { type: 'f', value: data.primitiveId }\n })\n\n if (params.matrix) {\n this.matrix = params.matrix\n }\n\n if (data.index) {\n this.initIndex(data.index)\n }\n this.picking = data.picking\n\n this.makeWireframeGeometry()\n }\n\n set matrix (m) {\n this.setMatrix(m)\n }\n get matrix () {\n return this.group.matrix.clone()\n }\n\n get transparent () {\n return this.parameters.opacity < 1 || this.parameters.forceTransparent\n }\n\n get size () {\n return this._positionDataSize\n }\n\n get attributeSize () {\n return this.size\n }\n\n get pickable () {\n return !!this.picking && !this.parameters.disablePicking\n }\n\n setMatrix (m: Matrix4) {\n setObjectMatrix(this.group, m)\n setObjectMatrix(this.wireframeGroup, m)\n setObjectMatrix(this.pickingGroup, m)\n }\n\n initIndex (index: Uint32Array|Uint16Array) {\n this.geometry.setIndex(\n new BufferAttribute(index, 1)\n )\n const nindex = this.geometry.getIndex();\n if (!nindex) { Log.error('Index is null'); return; }\n nindex.setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n }\n\n makeMaterial () {\n const side = getThreeSide(this.parameters.side)\n\n const m = new ShaderMaterial({\n uniforms: this.uniforms,\n vertexShader: '',\n fragmentShader: '',\n depthTest: true,\n transparent: this.transparent,\n depthWrite: this.parameters.depthWrite,\n lights: true,\n fog: true,\n side: side\n })\n m.vertexColors = true\n m.extensions.derivatives = true\n m.extensions.fragDepth = this.isImpostor\n\n const wm = new ShaderMaterial({\n uniforms: this.uniforms,\n vertexShader: '',\n fragmentShader: '',\n depthTest: true,\n transparent: this.transparent,\n depthWrite: this.parameters.depthWrite,\n lights: false,\n fog: true,\n side: side\n })\n wm.vertexColors = true\n\n const pm = new ShaderMaterial({\n uniforms: this.pickingUniforms,\n vertexShader: '',\n fragmentShader: '',\n depthTest: true,\n transparent: false,\n depthWrite: this.parameters.depthWrite,\n lights: false,\n fog: false,\n side: side,\n blending: NoBlending\n })\n pm.vertexColors = true\n pm.extensions.fragDepth = this.isImpostor\n\n ;(m as any).clipNear = this.parameters.clipNear\n ;(wm as any).clipNear = this.parameters.clipNear\n ;(pm as any).clipNear = this.parameters.clipNear\n\n this.material = m\n this.wireframeMaterial = wm\n this.pickingMaterial = pm\n\n // also sets vertexShader/fragmentShader\n this.updateShader()\n }\n\n makeWireframeGeometry () {\n this.makeWireframeIndex()\n\n const geometry = this.geometry\n const wireframeIndex = this.wireframeIndex\n const wireframeGeometry = new BufferGeometry()\n\n wireframeGeometry.attributes = geometry.attributes\n if (wireframeIndex) {\n wireframeGeometry.setIndex(\n new BufferAttribute(wireframeIndex, 1).setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n wireframeGeometry.setDrawRange(0, this.wireframeIndexCount)\n }\n\n this.wireframeGeometry = wireframeGeometry\n }\n\n makeWireframeIndex () {\n const edges: number[][] = []\n\n function checkEdge (a: number, b: number) {\n if (a > b) {\n const tmp = a\n a = b\n b = tmp\n }\n\n const list = edges[ a ]\n\n if (list === undefined) {\n edges[ a ] = [ b ]\n return true\n } else if (!list.includes(b)) {\n list.push(b)\n return true\n }\n\n return false\n }\n\n const geometry = this.geometry\n const index = geometry.index\n\n if (!this.parameters.wireframe) {\n this.wireframeIndex = new Uint16Array(0)\n this.wireframeIndexCount = 0\n } else if (index) {\n const array = index.array\n let n = array.length\n if (geometry.drawRange.count !== Infinity) {\n n = geometry.drawRange.count\n }\n let wireframeIndex\n if (this.wireframeIndex && this.wireframeIndex.length > n * 2) {\n wireframeIndex = this.wireframeIndex\n } else {\n const count = (geometry.attributes as any).position.count // TODO\n wireframeIndex = getUintArray(n * 2, count)\n }\n\n let j = 0\n edges.length = 0\n\n for (let i = 0; i < n; i += 3) {\n const a = array[ i + 0 ]\n const b = array[ i + 1 ]\n const c = array[ i + 2 ]\n\n if (checkEdge(a, b)) {\n wireframeIndex[ j + 0 ] = a\n wireframeIndex[ j + 1 ] = b\n j += 2\n }\n if (checkEdge(b, c)) {\n wireframeIndex[ j + 0 ] = b\n wireframeIndex[ j + 1 ] = c\n j += 2\n }\n if (checkEdge(c, a)) {\n wireframeIndex[ j + 0 ] = c\n wireframeIndex[ j + 1 ] = a\n j += 2\n }\n }\n\n this.wireframeIndex = wireframeIndex\n this.wireframeIndexCount = j\n this.wireframeIndexVersion = this.indexVersion\n } else {\n const n = (geometry.attributes as any).position.count // TODO\n\n let wireframeIndex\n if (this.wireframeIndex && this.wireframeIndex.length > n * 2) {\n wireframeIndex = this.wireframeIndex\n } else {\n wireframeIndex = getUintArray(n * 2, n)\n }\n\n for (let i = 0, j = 0; i < n; i += 3) {\n wireframeIndex[ j + 0 ] = i\n wireframeIndex[ j + 1 ] = i + 1\n wireframeIndex[ j + 2 ] = i + 1\n wireframeIndex[ j + 3 ] = i + 2\n wireframeIndex[ j + 4 ] = i + 2\n wireframeIndex[ j + 5 ] = i\n\n j += 6\n }\n\n this.wireframeIndex = wireframeIndex\n this.wireframeIndexCount = n * 2\n this.wireframeIndexVersion = this.indexVersion\n }\n }\n\n updateWireframeIndex () {\n if (!this.wireframeGeometry || !this.wireframeIndex) return\n\n this.wireframeGeometry.setDrawRange(0, Infinity)\n if (this.wireframeIndexVersion < this.indexVersion) this.makeWireframeIndex()\n\n if (this.wireframeGeometry.index &&\n this.wireframeIndex.length > this.wireframeGeometry.index.array.length) {\n this.wireframeGeometry.setIndex(\n new BufferAttribute(this.wireframeIndex, 1).setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n } else {\n const index = this.wireframeGeometry.getIndex()\n if (!index) { Log.error('Index is null'); return; }\n index.set(this.wireframeIndex)\n index.needsUpdate = this.wireframeIndexCount > 0\n index.updateRange.count = this.wireframeIndexCount\n }\n\n this.wireframeGeometry.setDrawRange(0, this.wireframeIndexCount)\n }\n\n getRenderOrder () {\n let renderOrder = 0\n\n if (this.isText) {\n renderOrder = 1\n } else if (this.transparent) {\n if (this.isSurface) {\n renderOrder = 3\n } else {\n renderOrder = 2\n }\n }\n\n return renderOrder\n }\n\n _getMesh (materialName: BufferMaterials) {\n if (!this.material) this.makeMaterial()\n\n const g = this.geometry\n const m = this[ materialName ]\n\n let mesh\n\n if (this.isLine) {\n mesh = new LineSegments(g, m)\n } else if (this.isPoint) {\n mesh = new Points(g, m)\n } else {\n mesh = new Mesh(g, m)\n }\n\n mesh.frustumCulled = false\n mesh.renderOrder = this.getRenderOrder()\n\n return mesh\n }\n\n getMesh () {\n return this._getMesh('material')\n }\n\n getWireframeMesh () {\n let mesh\n\n if (!this.material) this.makeMaterial()\n if (!this.wireframeGeometry) this.makeWireframeGeometry()\n\n mesh = new LineSegments(\n this.wireframeGeometry, this.wireframeMaterial\n )\n\n mesh.frustumCulled = false\n mesh.renderOrder = this.getRenderOrder()\n\n return mesh\n }\n\n getPickingMesh () {\n return this._getMesh('pickingMaterial')\n }\n\n getShader (name: string, type?: BufferTypes) {\n return getShader(name, this.getDefines(type))\n }\n\n getVertexShader (type?: BufferTypes) {\n return this.getShader(this.vertexShader, type)\n }\n\n getFragmentShader (type?: BufferTypes) {\n return this.getShader(this.fragmentShader, type)\n }\n\n getDefines (type?: BufferTypes) {\n const defines: ShaderDefines = {}\n\n if (this.parameters.clipNear) {\n defines.NEAR_CLIP = 1\n }\n\n if (this.parameters.clipRadius) {\n defines.RADIUS_CLIP = 1\n }\n\n if (type === 'picking') {\n defines.PICKING = 1\n } else {\n if (type === 'background' || this.parameters.background) {\n defines.NOLIGHT = 1\n }\n if (this.parameters.flatShaded) {\n defines.FLAT_SHADED = 1\n }\n if (this.parameters.opaqueBack) {\n defines.OPAQUE_BACK = 1\n }\n if (this.parameters.diffuseInterior) {\n defines.DIFFUSE_INTERIOR = 1\n }\n if (this.parameters.useInteriorColor) {\n defines.USE_INTERIOR_COLOR = 1\n }\n }\n\n return defines\n }\n\n getParameters () {\n return this.parameters\n }\n\n addUniforms (uniforms: Uniforms) {\n this.uniforms = UniformsUtils.merge(\n [ this.uniforms, uniforms ]\n )\n\n this.pickingUniforms = UniformsUtils.merge(\n [ this.pickingUniforms, uniforms ]\n )\n }\n\n addAttributes (attributes: { [k: string]: _BufferAttribute }) {\n for (let name in attributes) {\n let buf\n const a = attributes[ name ]\n const arraySize = this.attributeSize * itemSize[ a.type ]\n\n if (a.value) {\n if (arraySize !== a.value.length) {\n Log.error('attribute value has wrong length', name)\n }\n buf = a.value\n } else {\n buf = getTypedArray('float32', arraySize)\n }\n\n this.geometry.setAttribute(\n name,\n new BufferAttribute(buf, itemSize[ a.type ]).setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n }\n }\n\n updateRenderOrder () {\n const renderOrder = this.getRenderOrder()\n function setRenderOrder (mesh: Object3D) {\n mesh.renderOrder = renderOrder\n }\n\n this.group.children.forEach(setRenderOrder)\n if (this.pickingGroup) {\n this.pickingGroup.children.forEach(setRenderOrder)\n }\n }\n\n updateShader () {\n const m = this.material\n const wm = this.wireframeMaterial\n const pm = this.pickingMaterial\n\n m.vertexShader = this.getVertexShader()\n m.fragmentShader = this.getFragmentShader()\n m.needsUpdate = true\n\n wm.vertexShader = this.getShader('Line.vert')\n wm.fragmentShader = this.getShader('Line.frag')\n wm.needsUpdate = true\n\n pm.vertexShader = this.getVertexShader('picking')\n pm.fragmentShader = this.getFragmentShader('picking')\n pm.needsUpdate = true\n }\n\n /**\n * Set buffer parameters\n * @param {BufferParameters} params - buffer parameters object\n * @return {undefined}\n */\n setParameters (params: Partial) {\n const p = params as any\n const pt = this.parameterTypes as any\n const pv = this.parameters as any\n\n const propertyData: { [k: string]: any } = {}\n const uniformData: { [k: string]: any } = {}\n let doShaderUpdate = false\n let doVisibilityUpdate = false\n\n for (const name in p) {\n const value = p[ name ]\n\n if (value === undefined) continue\n pv[ name ] = value\n\n if (pt[ name ] === undefined) continue\n\n if (pt[ name ].property) {\n if (pt[ name ].property !== true) {\n propertyData[ pt[ name ].property as any ] = value\n } else {\n propertyData[ name ] = value\n }\n }\n\n if (pt[ name ].uniform) {\n if (pt[ name ].uniform !== true) {\n uniformData[ pt[ name ].uniform as any ] = value\n } else {\n uniformData[ name ] = value\n }\n }\n\n if (pt[ name ].updateShader) {\n doShaderUpdate = true\n }\n\n if (pt[ name ].updateVisibility) {\n doVisibilityUpdate = true\n }\n\n if (this.dynamic && name === 'wireframe' && value === true) {\n this.updateWireframeIndex()\n }\n\n if (name === 'forceTransparent') {\n propertyData.transparent = this.transparent\n }\n\n if (name === 'matrix') {\n this.matrix = value\n }\n }\n\n this.setProperties(propertyData)\n this.setUniforms(uniformData)\n if (doShaderUpdate) this.updateShader()\n if (doVisibilityUpdate) this.setVisibility(this.visible)\n }\n\n /**\n * Sets buffer attributes\n * @param {Object} data - An object where the keys are the attribute names\n * and the values are the attribute data.\n * @example\n * var buffer = new Buffer();\n * buffer.setAttributes({ attrName: attrData });\n */\n setAttributes (data: any) { // TODO\n const geometry = this.geometry\n const attributes = geometry.attributes as any // TODO\n\n for (const name in data) {\n if (name === 'picking') continue\n\n const array = data[ name ]\n const length = array.length\n\n if (name === 'index') {\n const index = geometry.getIndex()\n if (!index) { Log.error('Index is null'); continue; }\n geometry.setDrawRange(0, Infinity)\n\n if (length > index.array.length) {\n geometry.setIndex(\n new BufferAttribute(array, 1)\n .setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n } else {\n index.set(array)\n index.count = length\n index.needsUpdate = length > 0\n index.updateRange.count = length\n geometry.setDrawRange(0, length)\n }\n\n this.indexVersion++\n if (this.parameters.wireframe) this.updateWireframeIndex()\n } else {\n const attribute = attributes[ name ]\n\n if (length > attribute.array.length) {\n geometry.setAttribute(\n name,\n new BufferAttribute(array, attribute.itemSize)\n .setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n } else {\n attributes[ name ].set(array)\n attributes[ name ].needsUpdate = length > 0\n attributes[ name ].updateRange.count = length\n }\n }\n }\n }\n\n setUniforms (data: any) { // TODO\n if (!data) return\n\n const u = this.material.uniforms\n const wu = this.wireframeMaterial.uniforms\n const pu = this.pickingMaterial.uniforms\n\n for (let name in data) {\n if (name === 'opacity') {\n this.setProperties({ transparent: this.transparent })\n }\n\n if (u[ name ] !== undefined) {\n if (u[ name ].value.isVector3) {\n u[ name ].value.copy(data[ name ])\n } else if (u[ name ].value.set) {\n u[ name ].value.set(data[ name ])\n } else {\n u[ name ].value = data[ name ]\n }\n }\n\n if (wu[ name ] !== undefined) {\n if (wu[ name ].value.isVector3) {\n wu[ name ].value.copy(data[ name ])\n } else if (wu[ name ].value.set) {\n wu[ name ].value.set(data[ name ])\n } else {\n wu[ name ].value = data[ name ]\n }\n }\n\n if (pu[ name ] !== undefined) {\n if (pu[ name ].value.isVector3) {\n pu[ name ].value.copy(data[ name ])\n } else if (pu[ name ].value.set) {\n pu[ name ].value.set(data[ name ])\n } else {\n pu[ name ].value = data[ name ]\n }\n }\n }\n }\n\n setProperties (data: any) { // TODO\n if (!data) return\n\n const m = this.material\n const wm = this.wireframeMaterial\n const pm = this.pickingMaterial\n\n for (const _name in data) {\n const name = _name as 'side'|'transparent' // TODO\n\n let value = data[ name ]\n\n if (name === 'transparent') {\n this.updateRenderOrder()\n } else if (name === 'side') {\n value = getThreeSide(value)\n }\n\n (m[ name ] as any) = value;\n (wm[ name ] as any) = value;\n (pm[ name ] as any) = value\n }\n\n m.needsUpdate = true\n wm.needsUpdate = true\n pm.needsUpdate = true\n }\n\n /**\n * Set buffer visibility\n * @param {Boolean} value - visibility value\n * @return {undefined}\n */\n setVisibility (value: boolean) {\n this.visible = value\n\n if (this.parameters.wireframe) {\n this.group.visible = false\n this.wireframeGroup.visible = value\n if (this.pickable) {\n this.pickingGroup.visible = false\n }\n } else {\n this.group.visible = value\n this.wireframeGroup.visible = false\n if (this.pickable) {\n this.pickingGroup.visible = value\n }\n }\n }\n\n /**\n * Free buffer resources\n * @return {undefined}\n */\n dispose () {\n if (this.material) this.material.dispose()\n if (this.wireframeMaterial) this.wireframeMaterial.dispose()\n if (this.pickingMaterial) this.pickingMaterial.dispose()\n\n this.geometry.dispose()\n if (this.wireframeGeometry) this.wireframeGeometry.dispose()\n }\n\n /**\n * Customize JSON serialization to avoid circular references\n */\n toJSON () {\n var result: any = {};\n for (var x in this) {\n if (x !== \"group\" && x !== \"wireframeGroup\" && x != \"pickingGroup\"\n && x !== \"picking\") {\n result[x] = this[x];\n }\n }\n return result;\n }\n}\n\nexport default Buffer\n","/**\n * @file Mesh Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport '../shader/Mesh.vert'\nimport '../shader/Mesh.frag'\n\nimport Buffer, { BufferParameters, BufferData } from './buffer'\n\n/**\n * Mesh buffer. Draws a triangle mesh.\n *\n * @example\n * var meshBuffer = new MeshBuffer({\n * position: new Float32Array(\n * [ 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1 ]\n * ),\n * color: new Float32Array(\n * [ 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0 ]\n * )\n * });\n */\nclass MeshBuffer extends Buffer {\n vertexShader = 'Mesh.vert'\n fragmentShader = 'Mesh.frag'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} [data.index] - triangle indices\n * @param {Float32Array} [data.normal] - radii\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: BufferData, params: Partial = {}) {\n super(data, params)\n\n this.addAttributes({\n 'normal': { type: 'v3', value: data.normal }\n })\n\n if (data.normal === undefined) {\n this.geometry.computeVertexNormals()\n }\n }\n}\n\nexport default MeshBuffer\n","/**\n * @file Surface Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport MeshBuffer from './mesh-buffer'\n\n/**\n * Surface buffer. Like a {@link MeshBuffer}, but with `.isSurface` set to `true`.\n */\nclass SurfaceBuffer extends MeshBuffer {\n isSurface = true\n}\n\nexport default SurfaceBuffer\n","/**\n * @file Double Sided Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { Group, BufferGeometry, Object3D, Mesh, LineSegments, Vector3, Matrix4 } from 'three'\n\nimport Buffer, { BufferSide } from './buffer'\nimport { Picker } from '../utils/picker'\n\nfunction setVisibilityTrue (m: Object3D) { m.visible = true }\nfunction setVisibilityFalse (m: Object3D) { m.visible = false }\n\n/**\n * A double-sided mesh buffer. Takes a buffer and renders the front and\n * the back as seperate objects to avoid some artifacts when rendering\n * transparent meshes. Also allows to render the back of a mesh opaque\n * while the front is transparent.\n * @implements {Buffer}\n *\n * @example\n * var sphereGeometryBuffer = new SphereGeometryBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n * var doubleSidedBuffer = new DoubleSidedBuffer(sphereGeometryBuffer);\n */\nclass DoubleSidedBuffer {\n size: number\n side: BufferSide\n visible: boolean\n wireframe: boolean\n geometry: BufferGeometry\n\n picking?: Picker\n\n group = new Group()\n wireframeGroup = new Group()\n pickingGroup = new Group()\n\n frontMeshes: (Mesh|LineSegments)[] = []\n backMeshes: (Mesh|LineSegments)[] = []\n\n buffer: Buffer\n frontBuffer: Buffer\n backBuffer: Buffer\n\n /**\n * Create a double sided buffer\n * @param {Buffer} buffer - the buffer to be rendered double-sided\n */\n constructor (buffer: Buffer) {\n this.size = buffer.size\n this.side = buffer.parameters.side\n this.visible = buffer.visible\n this.geometry = buffer.geometry\n this.picking = buffer.picking\n\n this.group = new Group()\n this.wireframeGroup = new Group()\n this.pickingGroup = new Group()\n\n // requires Group objects to be present\n this.matrix = buffer.matrix\n\n const frontBuffer = buffer\n const backBuffer = new (buffer as any).constructor({ // TODO\n position: new Float32Array(0)\n }) as Buffer\n\n frontBuffer.makeMaterial()\n backBuffer.makeMaterial()\n\n backBuffer.picking = buffer.picking\n backBuffer.geometry = buffer.geometry\n backBuffer.wireframeGeometry = buffer.wireframeGeometry\n backBuffer.setParameters(buffer.getParameters())\n backBuffer.updateShader()\n\n frontBuffer.setParameters({\n side: 'front'\n })\n backBuffer.setParameters({\n side: 'back',\n opacity: backBuffer.parameters.opacity\n })\n\n this.buffer = buffer\n this.frontBuffer = frontBuffer\n this.backBuffer = backBuffer\n }\n\n set matrix (m) {\n Buffer.prototype.setMatrix.call(this, m)\n }\n get matrix () {\n return this.group.matrix.clone()\n }\n\n get pickable () {\n return !!this.picking && !this.parameters.disablePicking\n }\n\n get parameters () {\n return this.buffer.parameters\n }\n\n getParameters () {\n const p = Object.assign({}, this.buffer.parameters)\n p.side = this.side\n return p\n }\n\n getMesh (picking: boolean) {\n let front, back\n\n if (picking) {\n back = this.backBuffer.getPickingMesh()\n front = this.frontBuffer.getPickingMesh()\n } else {\n back = this.backBuffer.getMesh()\n front = this.frontBuffer.getMesh()\n }\n\n this.frontMeshes.push(front)\n this.backMeshes.push(back)\n\n this.setParameters({ side: this.side })\n\n return new Group().add(back, front)\n }\n\n getWireframeMesh () {\n return this.buffer.getWireframeMesh()\n }\n\n getPickingMesh () {\n return this.getMesh(true)\n }\n\n setAttributes (data: any) { // TODO\n this.buffer.setAttributes(data)\n }\n\n setParameters (data: any) { // TODO\n data = Object.assign({}, data)\n\n if (data.side === 'front') {\n this.frontMeshes.forEach(setVisibilityTrue)\n this.backMeshes.forEach(setVisibilityFalse)\n } else if (data.side === 'back') {\n this.frontMeshes.forEach(setVisibilityFalse)\n this.backMeshes.forEach(setVisibilityTrue)\n } else if (data.side === 'double') {\n this.frontMeshes.forEach(setVisibilityTrue)\n this.backMeshes.forEach(setVisibilityTrue)\n }\n\n if (data.side !== undefined) {\n this.side = data.side\n }\n delete data.side\n\n if (data.matrix !== undefined) {\n this.matrix = data.matrix\n }\n delete data.matrix\n\n this.frontBuffer.setParameters(data)\n\n if (data.wireframe !== undefined) {\n this.wireframe = data.wireframe\n this.setVisibility(this.visible)\n }\n delete data.wireframe\n\n this.backBuffer.setParameters(data)\n }\n\n setVisibility (value: boolean) {\n this.visible = value\n\n if (this.parameters.wireframe) {\n this.group.visible = false\n this.wireframeGroup.visible = value\n if (this.pickable) {\n this.pickingGroup.visible = false\n }\n } else {\n this.group.visible = value\n this.wireframeGroup.visible = false\n if (this.pickable) {\n this.pickingGroup.visible = value\n }\n }\n }\n\n dispose () {\n this.frontBuffer.dispose()\n this.backBuffer.dispose()\n }\n\n /**\n * Customize JSON serialization to avoid circular references.\n * Only export simple params which could be useful.\n */\n toJSON () {\n var result: any = {};\n for (var x in this) {\n if (['side', 'size', 'visible', 'matrix', 'parameters'].includes(x)) {\n result[x] = this[x];\n }\n }\n return result;\n }\n}\n\nexport default DoubleSidedBuffer\n","/**\n * @file Contour Buffer\n * @author Fred ludlow \n * @private\n */\n\nimport '../shader/Line.vert'\nimport '../shader/Line.frag'\n\nimport Buffer from './buffer'\n\n/**\n * Contour buffer. A buffer that draws lines (instead of triangle meshes).\n */\nclass ContourBuffer extends Buffer {\n isLine = true\n vertexShader = 'Line.vert'\n fragmentShader = 'Line.frag'\n}\n\nexport default ContourBuffer\n","/**\n * @file Surface Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3, Box3 } from 'three'\n\nimport { defaults } from '../utils'\nimport Representation, { RepresentationParameters } from './representation'\nimport Volume from '../surface/volume'\nimport SurfaceBuffer from '../buffer/surface-buffer'\nimport DoubleSidedBuffer from '../buffer/doublesided-buffer'\nimport ContourBuffer from '../buffer/contour-buffer'\nimport Surface from '../surface/surface';\nimport Viewer from '../viewer/viewer';\nimport {SurfaceData} from '../surface/surface'\n// @ts-ignore: unused import ColormakerParameters required for declaration only\nimport { ColormakerParameters } from '../color/colormaker';\nexport type SurfaceDataFields = {position: boolean, color: boolean, index: boolean, normal: boolean, radius: boolean}\n\n/**\n * Surface representation parameter object. Extends {@link RepresentationParameters}\n *\n * @typedef {Object} SurfaceRepresentationParameters - surface representation parameters\n *\n * @property {String} isolevelType - Meaning of the isolevel value. Either *value* for the literal value or *sigma* as a factor of the sigma of the data. For volume data only.\n * @property {Float} isolevel - The value at which to create the isosurface. For volume data only.\n * @property {Boolean} negateIsolevel - For volume data only.\n * @property {Boolean} isolevelScroll - For volume data only\n * @property {Integer} smooth - How many iterations of laplacian smoothing after surface triangulation. For volume data only.\n * @property {Boolean} background - Render the surface in the background, unlit.\n * @property {Boolean} opaqueBack - Render the back-faces (where normals point away from the camera) of the surface opaque, ignoring the transparency parameter.\n * @property {Integer} boxSize - Size of the box to triangulate volume data in. Set to zero to triangulate the whole volume. For volume data only.\n * @property {Boolean} useWorker - Weather or not to triangulate the volume asynchronously in a Web Worker. For volume data only.\n * @property {Boolean} wrap - Wrap volume data around the edges; use in conjuction with boxSize but not larger than the volume dimension. For volume data only.\n */\nexport interface SurfaceRepresentationParameters extends RepresentationParameters {\n isolevelType: 'value'|'sigma'\n isolevel: number\n smooth: number\n background: boolean\n opaqueBack: boolean\n boxSize: number\n useWorker: boolean\n wrap: boolean\n}\n/**\n * Surface representation\n */\n/**\n * Create Surface representation object\n * @param {Surface|Volume} surface - the surface or volume to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {SurfaceRepresentationParameters} params - surface representation parameters\n */\nclass SurfaceRepresentation extends Representation {\n protected surface: Surface|Volume|undefined\n protected volume: Volume|undefined\n protected boxCenter: Vector3\n protected __boxCenter: Vector3\n protected box: Box3\n protected __box: Box3\n protected _position: Vector3\n protected isolevelType: 'value'|'sigma'\n protected isolevel: number\n protected negateIsolevel: boolean\n protected isolevelScroll: boolean\n protected smooth: number\n protected background: boolean\n protected opaqueBack: boolean\n protected boxSize: number\n protected inverseMatrix: Matrix4\n protected colorVolume: Volume\n protected contour: boolean\n protected useWorker: boolean\n protected wrap: boolean\n\n protected __isolevel: number\n protected __smooth: number\n protected __contour: boolean\n protected __wrap: boolean\n protected __boxSize: number\n\n setBox: () => void\n\n constructor (surface: Surface, viewer: Viewer, params: Partial) {\n super(surface, viewer, params)\n\n this.type = 'surface'\n\n this.parameters = Object.assign({\n\n isolevelType: {\n type: 'select',\n options: {\n 'value': 'value', 'sigma': 'sigma'\n }\n },\n isolevel: {\n type: 'number', precision: 2, max: 1000, min: -1000\n },\n negateIsolevel: {\n type: 'boolean'\n },\n isolevelScroll: {\n type: 'boolean'\n },\n smooth: {\n type: 'integer', precision: 1, max: 10, min: 0\n },\n background: {\n type: 'boolean', rebuild: true // FIXME\n },\n opaqueBack: {\n type: 'boolean', buffer: true\n },\n boxSize: {\n type: 'integer', precision: 1, max: 100, min: 0\n },\n colorVolume: {\n type: 'hidden'\n },\n contour: {\n type: 'boolean', rebuild: true\n },\n useWorker: {\n type: 'boolean', rebuild: true\n },\n wrap: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters)\n\n if (surface instanceof Volume) {\n this.surface = undefined\n this.volume = surface\n } else {\n this.surface = surface\n this.volume = undefined\n }\n\n this.boxCenter = new Vector3()\n this.__boxCenter = new Vector3()\n this.box = new Box3()\n this.__box = new Box3()\n\n this._position = new Vector3()\n this.inverseMatrix = new Matrix4()\n\n this.setBox = function setBox () {\n this._position.copy(viewer.translationGroup.position).negate()\n this._position.applyMatrix4(this.inverseMatrix)\n if (!this._position.equals(this.boxCenter)) {\n this.setParameters({ 'boxCenter': this._position })\n }\n }\n\n this.toBePrepared = true\n\n this.viewer.signals.ticked.add(this.setBox, this)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'uniform')\n p.colorValue = defaults(p.colorValue, 0xDDDDDD)\n\n this.isolevelType = defaults(p.isolevelType, 'sigma')\n this.isolevel = defaults(p.isolevel, 2.0)\n this.negateIsolevel = defaults(p.negateIsolevel, false)\n this.isolevelScroll = defaults(p.isolevelScroll, false)\n this.smooth = defaults(p.smooth, 0)\n this.background = defaults(p.background, false)\n this.opaqueBack = defaults(p.opaqueBack, true)\n this.boxSize = defaults(p.boxSize, 0)\n this.colorVolume = defaults(p.colorVolume, undefined)\n this.contour = defaults(p.contour, false)\n this.useWorker = defaults(p.useWorker, true)\n this.wrap = defaults(p.wrap, false)\n\n super.init(p)\n\n this.inverseMatrix.getInverse(this.matrix)\n\n this.build()\n }\n\n attach (callback: () => void) {\n this.bufferList.forEach(buffer => {\n this.viewer.add(buffer)\n })\n\n this.setVisibility(this.visible)\n\n callback()\n }\n\n prepare (callback: () => void) {\n if (this.volume) {\n let isolevel\n\n if (this.isolevelType === 'sigma') {\n isolevel = this.volume.getValueForSigma(this.isolevel)\n } else {\n isolevel = this.isolevel\n }\n if (this.negateIsolevel) isolevel *= -1\n\n if (!this.surface ||\n this.__isolevel !== isolevel ||\n this.__smooth !== this.smooth ||\n this.__contour !== this.contour ||\n this.__wrap !== this.wrap ||\n this.__boxSize !== this.boxSize ||\n (this.boxSize > 0 &&\n !this.__boxCenter.equals(this.boxCenter))\n ) {\n this.__isolevel = isolevel\n this.__smooth = this.smooth\n this.__contour = this.contour\n this.__wrap = this.wrap\n this.__boxSize = this.boxSize\n this.__boxCenter.copy(this.boxCenter)\n this.__box.copy(this.box)\n\n const onSurfaceFinish = (surface: Surface) => {\n this.surface = surface\n callback()\n }\n\n if (this.useWorker) {\n this.volume.getSurfaceWorker(\n isolevel, this.smooth, this.boxCenter, this.boxSize,\n this.contour, this.wrap, onSurfaceFinish\n )\n } else {\n onSurfaceFinish(\n this.volume.getSurface(\n isolevel, this.smooth, this.boxCenter, this.boxSize,\n this.contour, this.wrap\n )\n )\n }\n } else {\n callback()\n }\n } else {\n callback()\n }\n }\n\n create () {\n const sd = {\n position: (this.surface as Surface).getPosition(),\n color: (this.surface as Surface).getColor(this.getColorParams()),\n index: (this.surface as Surface).getIndex()\n }\n\n let buffer\n\n if (this.contour) {\n buffer = new ContourBuffer(\n sd,\n this.getBufferParams({ wireframe: false })\n )\n } else {\n Object.assign(sd, {\n normal: (this.surface as Surface).getNormal(),\n picking: (this.surface as Surface).getPicking()\n })\n\n const surfaceBuffer = new SurfaceBuffer(\n sd,\n this.getBufferParams({\n background: this.background,\n opaqueBack: this.opaqueBack,\n dullInterior: false\n })\n )\n\n buffer = new DoubleSidedBuffer(surfaceBuffer)\n }\n\n this.bufferList.push(buffer as ContourBuffer)\n }\n\n update (what: SurfaceDataFields) {\n if (this.bufferList.length === 0) return\n\n what = what || {}\n\n const surfaceData: Partial = {}\n\n if (what.position) {\n surfaceData.position = (this.surface as Surface).getPosition()\n }\n\n if (what.color) {\n surfaceData.color = (this.surface as Surface).getColor(\n this.getColorParams()\n )\n }\n\n if (what.index) {\n surfaceData.index = (this.surface as Surface).getIndex()\n }\n\n if (what.normal) {\n surfaceData.normal = (this.surface as Surface).getNormal()\n }\n\n this.bufferList.forEach(function (buffer) {\n buffer.setAttributes(surfaceData)\n })\n }\n\n /**\n * Set representation parameters\n * @alias SurfaceRepresentation#setParameters\n * @param {SurfaceRepresentationParameters} params - surface parameter object\n * @param {Object} [what] - buffer data attributes to be updated,\n * note that this needs to be implemented in the\n * derived classes. Generally it allows more\n * fine-grained control over updating than\n * forcing a rebuild.\n * @param {Boolean} what.position - update position data\n * @param {Boolean} what.color - update color data\n * @param {Boolean} [rebuild] - whether or not to rebuild the representation\n * @return {SurfaceRepresentation} this object\n */\n setParameters (params: Partial, what?: SurfaceDataFields, rebuild?: boolean) {\n if (params && params.isolevelType !== undefined &&\n this.volume\n ) {\n if (this.isolevelType === 'value' &&\n params.isolevelType === 'sigma'\n ) {\n this.isolevel = this.volume.getSigmaForValue(this.isolevel)\n } else if (this.isolevelType === 'sigma' &&\n params.isolevelType === 'value'\n ) {\n this.isolevel = this.volume.getValueForSigma(this.isolevel)\n }\n\n this.isolevelType = params.isolevelType\n }\n\n if (params && params.boxCenter) {\n this.boxCenter.copy(params.boxCenter)\n delete params.boxCenter\n }\n\n // Forbid wireframe && contour as in molsurface\n if (params && params.wireframe && (\n params.contour || (params.contour === undefined && this.contour)\n )) {\n params.wireframe = false\n }\n\n super.setParameters(params, what, rebuild)\n\n if (params.matrix) {\n this.inverseMatrix.getInverse(params.matrix)\n }\n\n if (this.volume) {\n this.volume.getBox(this.boxCenter, this.boxSize, this.box)\n }\n\n if (params && params.colorVolume !== undefined) {\n if (what) what.color = true\n }\n\n if (this.surface && (\n params.isolevel !== undefined ||\n params.negateIsolevel !== undefined ||\n params.smooth !== undefined ||\n params.wrap !== undefined ||\n params.boxSize !== undefined ||\n (this.boxSize > 0 &&\n !this.__box.equals(this.box))\n )) {\n this.build({\n 'position': true,\n 'color': true,\n 'index': true,\n 'normal': !this.contour\n })\n }\n\n return this\n }\n\n getColorParams () {\n const p = super.getColorParams()\n\n p.volume = this.colorVolume\n\n return p\n }\n\n dispose () {\n this.viewer.signals.ticked.remove(this.setBox, this)\n\n super.dispose()\n }\n}\n\nexport default SurfaceRepresentation\n","/**\n * @file Mouse Actions\n * @author Alexander Rose \n * @private\n */\n\nimport PickingProxy from './picking-proxy'\nimport { almostIdentity } from '../math/math-utils'\nimport Stage from '../stage/stage'\nimport StructureComponent from '../component/structure-component'\nimport SurfaceRepresentation from '../representation/surface-representation'\n\nexport type ScrollCallback = (stage: Stage, delta: number) => void\nexport type DragCallback = (stage: Stage, dx: number, dy: number) => void\nexport type PickCallback = (stage: Stage, pickingProxy: PickingProxy) => void\nexport type MouseActionCallback = ScrollCallback | DragCallback | PickCallback\n\n/**\n * Mouse actions provided as static methods\n */\nclass MouseActions {\n /**\n * Zoom scene based on scroll-delta\n * @param {Stage} stage - the stage\n * @param {Number} delta - amount to zoom\n * @return {undefined}\n */\n static zoomScroll (stage: Stage, delta: number) {\n stage.trackballControls.zoom(delta)\n }\n\n /**\n * Move near clipping plane based on scroll-delta\n * @param {Stage} stage - the stage\n * @param {Number} delta - amount to move clipping plane\n * @return {undefined}\n */\n static clipNearScroll (stage: Stage, delta: number) {\n const sp = stage.getParameters()\n stage.setParameters({ clipNear: sp.clipNear + delta / 10 })\n }\n\n /**\n * Move clipping planes based on scroll-delta.\n * @param {Stage} stage - the stage\n * @param {Number} delta - direction to move planes\n * @return {undefined}\n */\n static focusScroll (stage: Stage, delta: number) {\n const focus = stage.getFocus()\n const sign = Math.sign(delta)\n const step = sign * almostIdentity((100 - focus) / 10, 5, 0.2)\n stage.setFocus(focus + step)\n }\n\n /**\n * Zoom scene based on scroll-delta and\n * move focus planes based on camera position (zoom)\n * @param {Stage} stage - the stage\n * @param {Number} delta - amount to move focus planes and zoom\n * @return {undefined}\n */\n static zoomFocusScroll (stage: Stage, delta: number) {\n stage.trackballControls.zoom(delta)\n const z = stage.viewer.camera.position.z\n stage.setFocus(100 - Math.abs(z / 8))\n }\n\n /**\n * Change isolevel of volume surfaces based on scroll-delta\n * @param {Stage} stage - the stage\n * @param {Number} delta - amount to change isolevel\n * @return {undefined}\n */\n static isolevelScroll (stage: Stage, delta: number) {\n const d = Math.sign(delta) / 10\n stage.eachRepresentation((reprElem, comp) => {\n if (reprElem.repr instanceof SurfaceRepresentation) {\n const p = reprElem.getParameters() as any // TODO\n if (p.isolevelScroll) {\n reprElem.setParameters({ isolevel: p.isolevel + d })\n }\n }\n })\n }\n\n /**\n * Pan scene based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to pan in x direction\n * @param {Number} dy - amount to pan in y direction\n * @return {undefined}\n */\n static panDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.pan(dx, dy)\n }\n\n /**\n * Rotate scene based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to rotate in x direction\n * @param {Number} dy - amount to rotate in y direction\n * @return {undefined}\n */\n static rotateDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.rotate(dx, dy)\n }\n\n /**\n * Rotate scene around z axis based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to rotate in x direction\n * @param {Number} dy - amount to rotate in y direction\n * @return {undefined}\n */\n static zRotateDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.zRotate(dx, dy)\n }\n\n /**\n * Zoom scene based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to zoom\n * @param {Number} dy - amount to zoom\n * @return {undefined}\n */\n static zoomDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.zoom((dx + dy) / -2)\n }\n\n /**\n * Zoom scene based on mouse coordinate changes and\n * move focus planes based on camera position (zoom)\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to zoom and focus\n * @param {Number} dy - amount to zoom and focus\n * @return {undefined}\n */\n static zoomFocusDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.zoom((dx + dy) / -2)\n const z = stage.viewer.camera.position.z\n stage.setFocus(100 - Math.abs(z / 8))\n }\n\n /**\n * Pan picked component based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to pan in x direction\n * @param {Number} dy - amount to pan in y direction\n * @return {undefined}\n */\n static panComponentDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.panComponent(dx, dy)\n }\n\n /**\n * Pan picked atom based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to pan in x direction\n * @param {Number} dy - amount to pan in y direction\n * @return {undefined}\n */\n static panAtomDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.panAtom(dx, dy)\n }\n\n /**\n * Rotate picked component based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to rotate in x direction\n * @param {Number} dy - amount to rotate in y direction\n * @return {undefined}\n */\n static rotateComponentDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.rotateComponent(dx, dy)\n }\n\n /**\n * Move picked element to the center of the screen\n * @param {Stage} stage - the stage\n * @param {PickingProxy} pickingProxy - the picking data object\n * @return {undefined}\n */\n static movePick (stage: Stage, pickingProxy: PickingProxy) {\n if (pickingProxy) {\n stage.animationControls.move(pickingProxy.position.clone())\n }\n }\n\n /**\n * Show tooltip with information of picked element\n * @param {Stage} stage - the stage\n * @param {PickingProxy} pickingProxy - the picking data object\n * @return {undefined}\n */\n static tooltipPick (stage: Stage, pickingProxy: PickingProxy) {\n const tt = stage.tooltip\n const sp = stage.getParameters() as any\n if (sp.tooltip && pickingProxy) {\n const mp = pickingProxy.mouse.position\n tt.innerText = pickingProxy.getLabel()\n tt.style.bottom = (window.innerHeight - mp.y + 3) + 'px'\n tt.style.left = (mp.x + 3) + 'px'\n tt.style.display = 'block'\n } else {\n tt.style.display = 'none'\n }\n }\n\n static measurePick (stage: Stage, pickingProxy: PickingProxy) {\n if (pickingProxy && (pickingProxy.atom || pickingProxy.bond)) {\n const atom = pickingProxy.atom || pickingProxy.closestBondAtom\n const sc = pickingProxy.component as StructureComponent\n sc.measurePick(atom)\n } else {\n stage.measureClear()\n }\n }\n}\n\ntype MouseActionPreset = [ string, MouseActionCallback ][]\nexport const MouseActionPresets = {\n default: [\n [ 'scroll', MouseActions.zoomScroll ],\n [ 'scroll-shift', MouseActions.focusScroll ],\n [ 'scroll-ctrl', MouseActions.isolevelScroll ],\n [ 'scroll-shift-ctrl', MouseActions.zoomFocusScroll ],\n\n [ 'drag-left', MouseActions.rotateDrag ],\n [ 'drag-right', MouseActions.panDrag ],\n [ 'drag-ctrl-left', MouseActions.panDrag ],\n [ 'drag-ctrl-right', MouseActions.zRotateDrag ],\n [ 'drag-shift-left', MouseActions.zoomDrag ],\n [ 'drag-middle', MouseActions.zoomFocusDrag ],\n\n [ 'drag-ctrl-shift-right', MouseActions.panComponentDrag ],\n [ 'drag-ctrl-shift-left', MouseActions.rotateComponentDrag ],\n\n [ 'clickPick-right', MouseActions.measurePick ],\n [ 'clickPick-ctrl-left', MouseActions.measurePick ],\n [ 'clickPick-middle', MouseActions.movePick ],\n [ 'clickPick-left', MouseActions.movePick ],\n [ 'hoverPick', MouseActions.tooltipPick ]\n ] as MouseActionPreset,\n pymol: [\n [ 'drag-left', MouseActions.rotateDrag ],\n [ 'drag-middle', MouseActions.panDrag ],\n [ 'drag-right', MouseActions.zoomDrag ],\n [ 'scroll', MouseActions.focusScroll ],\n [ 'drag-shift-right', MouseActions.focusScroll ],\n\n [ 'clickPick-ctrl+shift-middle', MouseActions.movePick ],\n [ 'hoverPick', MouseActions.tooltipPick ]\n ] as MouseActionPreset,\n coot: [\n [ 'scroll', MouseActions.isolevelScroll ],\n\n [ 'drag-left', MouseActions.rotateDrag ],\n [ 'drag-middle', MouseActions.panDrag ],\n [ 'drag-ctrl-left', MouseActions.panDrag ],\n [ 'drag-right', MouseActions.zoomFocusDrag ],\n [ 'drag-ctrl-right', MouseActions.focusScroll ],\n\n [ 'clickPick-middle', MouseActions.movePick ],\n [ 'hoverPick', MouseActions.tooltipPick ]\n ] as MouseActionPreset,\n astexviewer: [\n [ 'drag-left', MouseActions.rotateDrag ],\n [ 'drag-ctrl-left', MouseActions.panDrag ],\n [ 'drag-shift-left', MouseActions.zoomDrag ],\n [ 'scroll', MouseActions.focusScroll ],\n [ 'clickPick-middle', MouseActions.movePick ],\n [ 'hoverPick', MouseActions.tooltipPick ]\n ] as MouseActionPreset\n}\n\nexport default MouseActions\n","/**\n * @file Mouse Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { MouseActionPresets, MouseActionCallback } from './mouse-actions'\nimport Stage from '../stage/stage'\nimport MouseObserver from '../stage/mouse-observer'\n\nexport type MouseControlPreset = keyof typeof MouseActionPresets\nexport interface MouseControlsParams {\n preset?: MouseControlPreset\n disabled?: boolean\n}\n\nexport type MouseActionType = ''|'scroll'|'drag'|'click'|'doubleClick'|'hover'|'clickPick'|'hoverPick'\nexport interface MouseAction {\n type: MouseActionType\n key: number\n button: number\n callback: MouseActionCallback\n}\n\n/**\n * Strings to describe mouse events (including optional keyboard modifiers).\n * Must contain an event type: \"scroll\", \"drag\", \"click\", \"doubleClick\",\n * \"hover\", \"clickPick\" or \"hoverPick\". Optionally contain one or more\n * (seperated by plus signs) keyboard modifiers: \"alt\", \"ctrl\", \"meta\" or\n * \"shift\". Can contain the mouse button performing the event: \"left\",\n * \"middle\" or \"right\". The type, key and button parts must be seperated by\n * dashes.\n *\n * @example\n * // triggered on scroll event (no key or button)\n * \"scroll\"\n *\n * @example\n * // triggered on scroll event while shift key is pressed\n * \"scroll-shift\"\n *\n * @example\n * // triggered on drag event with left mouse button\n * \"drag-left\"\n *\n * @example\n * // triggered on drag event with right mouse button\n * // while ctrl and shift keys are pressed\n * \"drag-right-ctrl+shift\"\n *\n * @typedef {String} TriggerString\n */\n\n/**\n * Get event type, key and button\n * @param {TriggerString} str - input trigger string\n * @return {Array} event type, key and button\n */\nfunction triggerFromString (str: string) {\n const tokens = str.split(/[-+]/)\n\n let type = ''\n if (tokens.includes('scroll')) type = 'scroll'\n if (tokens.includes('drag')) type = 'drag'\n if (tokens.includes('click')) type = 'click'\n if (tokens.includes('doubleClick')) type = 'doubleClick'\n if (tokens.includes('hover')) type = 'hover'\n if (tokens.includes('clickPick')) type = 'clickPick'\n if (tokens.includes('hoverPick')) type = 'hoverPick'\n\n let key = 0\n if (tokens.includes('alt')) key += 1\n if (tokens.includes('ctrl')) key += 2\n if (tokens.includes('meta')) key += 4\n if (tokens.includes('shift')) key += 8\n\n let button = 0\n if (tokens.includes('left')) button += 1\n if (tokens.includes('right')) button += 2\n if (tokens.includes('middle')) button += 4\n\n return [ type, key, button ] as [ MouseActionType, number, number ]\n}\n\n/**\n * Mouse controls\n */\nclass MouseControls {\n actionList: MouseAction[] = []\n mouse: MouseObserver\n\n disabled: boolean // Flag to disable all actions\n\n /**\n * @param {Stage} stage - the stage object\n * @param {Object} [params] - the parameters\n * @param {String} params.preset - one of \"default\", \"pymol\", \"coot\"\n * @param {String} params.disabled - flag to disable all actions\n */\n constructor (readonly stage: Stage, params: MouseControlsParams = {}) {\n this.mouse = stage.mouseObserver\n this.disabled = params.disabled || false\n this.preset(params.preset || 'default')\n }\n\n run (type: MouseActionType, ...args: any[]) {\n if (this.disabled) return\n\n const key = this.mouse.key || 0\n const button = this.mouse.buttons || 0\n\n this.actionList.forEach(a => {\n if (a.type === type && a.key === key && a.button === button) {\n (a.callback as any)(this.stage, ...args) // TODO\n }\n })\n }\n\n /**\n * Add a new mouse action triggered by an event, key and button combination.\n * The {@link MouseActions} class provides a number of static methods for\n * use as callback functions.\n *\n * @example\n * // change ambient light intensity on mouse scroll\n * // while the ctrl and shift keys are pressed\n * stage.mouseControls.add( \"scroll-ctrl+shift\", function( stage, delta ){\n * var ai = stage.getParameters().ambientIntensity;\n * stage.setParameters( { ambientIntensity: Math.max( 0, ai + delta / 50 ) } );\n * } );\n *\n * @example\n * // Call the MouseActions.zoomDrag method on mouse drag events\n * // with left and right mouse buttons simultaneous\n * stage.mouseControls.add( \"drag-left+right\", MouseActions.zoomDrag );\n *\n * @param {TriggerString} triggerStr - the trigger for the action\n * @param {function(stage: Stage, ...args: Any)} callback - the callback function for the action\n * @return {undefined}\n */\n add (triggerStr: string, callback: MouseActionCallback) {\n const [ type, key, button ] = triggerFromString(triggerStr)\n\n this.actionList.push({ type, key, button, callback })\n }\n\n /**\n * Remove a mouse action. The trigger string can contain an asterix (*)\n * as a wildcard for any key or mouse button. When the callback function\n * is given, only actions that call that function are removed.\n *\n * @example\n * // remove actions triggered solely by a scroll event\n * stage.mouseControls.remove( \"scroll\" );\n *\n * @example\n * // remove actions triggered by a scroll event, including\n * // those requiring a key pressed or mouse button used\n * stage.mouseControls.remove( \"scroll-*\" );\n *\n * @example\n * // remove actions triggered by a scroll event\n * // while the shift key is pressed\n * stage.mouseControls.remove( \"scroll-shift\" );\n *\n * @param {TriggerString} triggerStr - the trigger for the action\n * @param {Function} [callback] - the callback function for the action\n * @return {undefined}\n */\n remove (triggerStr: string, callback?: MouseActionCallback) {\n const wildcard = triggerStr.includes('*')\n const [ type, key, button ] = triggerFromString(triggerStr)\n\n const actionList = this.actionList.filter(function (a) {\n return !(\n (a.type === type || (wildcard && type === '')) &&\n (a.key === key || (wildcard && key === 0)) &&\n (a.button === button || (wildcard && button === 0)) &&\n (a.callback === callback || callback === undefined)\n )\n })\n\n this.actionList = actionList\n }\n\n /**\n * Set mouse action preset\n * @param {String} name - one of \"default\", \"pymol\", \"coot\"\n * @return {undefined}\n */\n preset (name: MouseControlPreset) {\n this.clear()\n\n const list = MouseActionPresets[ name ] || []\n\n list.forEach(action => this.add(action[0], action[1]))\n }\n\n /**\n * Remove all mouse actions\n * @return {undefined}\n */\n clear () {\n this.actionList.length = 0\n }\n}\n\nexport default MouseControls\n","/**\n * @file Key Actions\n * @author Alexander Rose \n * @private\n */\n\nimport Stage from '../stage/stage'\n\nexport type KeyActionCallback = (stage: Stage) => void\n\n/**\n * Key actions provided as static methods\n */\nclass KeyActions {\n /**\n * Stage auto view\n */\n static autoView (stage: Stage) {\n stage.autoView(1000)\n }\n\n /**\n * Toggle stage animations\n */\n static toggleAnimations (stage: Stage) {\n stage.animationControls.toggle()\n }\n\n /**\n * Toggle stage rocking\n */\n static toggleRock (stage: Stage) {\n stage.toggleRock()\n }\n\n /**\n * Toggle stage spinning\n */\n static toggleSpin (stage: Stage) {\n stage.toggleSpin()\n }\n\n /**\n * Toggle anti-aliasing\n */\n static toggleAntialiasing (stage: Stage) {\n const p = stage.getParameters()\n stage.setParameters({ sampleLevel: p.sampleLevel === -1 ? 0 : -1 })\n }\n}\n\ntype KeyActionPreset = [ string, KeyActionCallback ][]\nexport const KeyActionPresets = {\n default: [\n [ 'i', KeyActions.toggleSpin ],\n [ 'k', KeyActions.toggleRock ],\n [ 'p', KeyActions.toggleAnimations ],\n [ 'a', KeyActions.toggleAntialiasing ],\n [ 'r', KeyActions.autoView ]\n ] as KeyActionPreset\n}\n\nexport default KeyActions\n","/**\n * @file Key Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { KeyActionPresets, KeyActionCallback } from './key-actions'\nimport Stage from '../stage/stage'\n\nexport type KeyControlPreset = keyof typeof KeyActionPresets\nexport interface KeyControlsParams {\n preset?: KeyControlPreset\n disabled?: boolean\n}\n\nexport interface KeyAction {\n key: string,\n callback: KeyActionCallback\n}\n\n/**\n * Mouse controls\n */\nclass KeyControls {\n actionList: KeyAction[] = []\n\n disabled: boolean // Flag to disable all actions\n\n /**\n * @param {Stage} stage - the stage object\n * @param {Object} [params] - the parameters\n * @param {String} params.preset - one of \"default\"\n * @param {String} params.disabled - flag to disable all actions\n */\n constructor (readonly stage: Stage, params: KeyControlsParams = {}) {\n this.disabled = params.disabled || false\n this.preset(params.preset || 'default')\n }\n\n run (key: string) {\n if (this.disabled) return\n\n this.actionList.forEach(a => {\n if (a.key === key) {\n a.callback(this.stage)\n }\n })\n }\n\n /**\n * Add a key action triggered by pressing the given character.\n * The {@link KeyActions} class provides a number of static methods for\n * use as callback functions.\n *\n * @example\n * // call KeyActions.toggleRock when \"k\" is pressed\n * stage.keyControls.remove( \"k\", KeyActions.toggleRock );\n *\n * @param {Char} char - the key/character\n * @param {Function} callback - the callback function for the action\n * @return {undefined}\n */\n add (char: string, callback: KeyActionCallback) {\n this.actionList.push({ key: char, callback })\n }\n\n /**\n * Remove a key action. When the callback function\n * is given, only actions that call that function are removed.\n *\n * @example\n * // remove all actions triggered by pressing \"k\"\n * stage.keyControls.remove( \"k\" );\n *\n * @example\n * // remove action `toggleRock` triggered by pressing \"k\"\n * stage.keyControls.remove( \"k\", toggleRock );\n *\n * @param {Char} char - the key/character\n * @param {Function} [callback] - the callback function for the action\n * @return {undefined}\n */\n remove (char: string, callback: KeyActionCallback) {\n\n const actionList = this.actionList.filter(function (a) {\n return !(\n (a.key === char) &&\n (a.callback === callback || callback === undefined)\n )\n })\n\n this.actionList = actionList\n }\n\n /**\n * Set key action preset\n * @param {String} name - one of \"default\"\n * @return {undefined}\n */\n preset (name: KeyControlPreset) {\n this.clear()\n\n const list = KeyActionPresets[ name ] || []\n\n list.forEach(action => this.add(action[0], action[1]))\n }\n\n /**\n * Remove all key actions\n * @return {undefined}\n */\n clear () {\n this.actionList.length = 0\n }\n}\n\nexport default KeyControls\n","/**\n * @file Picking Behavior\n * @author Alexander Rose \n * @private\n */\n\nimport Stage from './stage'\nimport MouseObserver from './mouse-observer'\nimport Viewer from '../viewer/viewer'\nimport MouseControls from '../controls/mouse-controls'\n\nclass PickingBehavior {\n viewer: Viewer\n mouse: MouseObserver\n controls: MouseControls\n\n constructor (readonly stage: Stage) {\n this.stage = stage\n this.mouse = stage.mouseObserver\n this.controls = stage.mouseControls\n\n this.mouse.signals.clicked.add(this._onClick, this)\n this.mouse.signals.hovered.add(this._onHover, this)\n }\n\n _onClick (x: number, y: number) {\n const pickingProxy = this.stage.pickingControls.pick(x, y)\n this.stage.signals.clicked.dispatch(pickingProxy)\n this.controls.run('clickPick', pickingProxy)\n }\n\n _onHover (x: number, y: number) {\n const pickingProxy = this.stage.pickingControls.pick(x, y)\n if (pickingProxy && this.mouse.down.equals(this.mouse.position)) {\n this.stage.transformComponent = pickingProxy.component\n this.stage.transformAtom = pickingProxy.atom\n }\n this.stage.signals.hovered.dispatch(pickingProxy)\n this.controls.run('hoverPick', pickingProxy)\n }\n\n dispose () {\n this.mouse.signals.clicked.remove(this._onClick, this)\n this.mouse.signals.hovered.remove(this._onHover, this)\n }\n}\n\nexport default PickingBehavior\n","/**\n * @file Mouse Behavior\n * @author Alexander Rose \n * @private\n */\n\nimport Stage from './stage'\nimport MouseObserver from './mouse-observer'\nimport Viewer from '../viewer/viewer'\nimport MouseControls from '../controls/mouse-controls'\n\nclass MouseBehavior {\n viewer: Viewer\n mouse: MouseObserver\n controls: MouseControls\n domElement: HTMLCanvasElement\n\n constructor (readonly stage: Stage) {\n this.stage = stage\n this.mouse = stage.mouseObserver\n this.controls = stage.mouseControls\n\n this.mouse.signals.moved.add(this._onMove, this)\n this.mouse.signals.scrolled.add(this._onScroll, this)\n this.mouse.signals.dragged.add(this._onDrag, this)\n this.mouse.signals.clicked.add(this._onClick, this)\n this.mouse.signals.hovered.add(this._onHover, this)\n this.mouse.signals.doubleClicked.add(this._onDblclick, this)\n }\n\n _onMove (/* x, y */) {\n this.stage.tooltip.style.display = 'none'\n }\n\n _onScroll (delta: number) {\n this.controls.run('scroll', delta)\n }\n\n _onDrag (dx: number, dy: number) {\n this.controls.run('drag', dx, dy)\n }\n\n _onClick (x: number, y: number) {\n this.controls.run('click', x, y)\n }\n\n _onDblclick (x: number, y: number) {\n this.controls.run('doubleClick', x, y)\n }\n\n _onHover (x: number, y: number) {\n this.controls.run('hover', x, y)\n }\n\n dispose () {\n this.mouse.signals.moved.remove(this._onMove, this)\n this.mouse.signals.scrolled.remove(this._onScroll, this)\n this.mouse.signals.dragged.remove(this._onDrag, this)\n this.mouse.signals.clicked.remove(this._onClick, this)\n this.mouse.signals.hovered.remove(this._onHover, this)\n }\n}\n\nexport default MouseBehavior\n","/**\n * @file Animation Behavior\n * @author Alexander Rose \n * @private\n */\n\nimport Stage from './stage'\nimport Viewer from '../viewer/viewer'\nimport Stats from '../viewer/stats'\nimport AnimationControls from '../controls/animation-controls'\n\nclass AnimationBehavior {\n viewer: Viewer\n animationControls: AnimationControls\n\n constructor (readonly stage: Stage) {\n this.viewer = stage.viewer\n this.animationControls = stage.animationControls\n\n this.viewer.signals.ticked.add(this._onTick, this)\n }\n\n _onTick (stats: Stats) {\n this.animationControls.run(stats)\n }\n\n dispose () {\n this.viewer.signals.ticked.remove(this._onTick, this)\n }\n}\n\nexport default AnimationBehavior\n","/**\n * @file Key Behavior\n * @author Alexander Rose \n * @private\n */\n\nimport { SupportsPassiveEventHandler } from '../globals'\nimport Stage from './stage'\nimport Viewer from '../viewer/viewer'\nimport KeyControls from '../controls/key-controls'\n\nconst passive = SupportsPassiveEventHandler ? { passive: true } : false\n\nclass KeyBehavior {\n viewer: Viewer\n controls: KeyControls\n domElement: HTMLCanvasElement\n\n /**\n * @param {Stage} stage - the stage object\n */\n constructor (readonly stage: Stage) {\n this.stage = stage\n this.controls = stage.keyControls\n this.domElement = stage.viewer.renderer.domElement\n\n // ensure the domElement is focusable\n this.domElement.setAttribute('tabIndex', '-1')\n this.domElement.style.outline = 'none'\n\n this._focusDomElement = this._focusDomElement.bind(this)\n this._onKeydown = this._onKeydown.bind(this)\n this._onKeyup = this._onKeyup.bind(this)\n this._onKeypress = this._onKeypress.bind(this)\n\n this.domElement.addEventListener('mousedown', this._focusDomElement)\n this.domElement.addEventListener('touchstart', this._focusDomElement, passive as any) // TODO\n this.domElement.addEventListener('keydown', this._onKeydown)\n this.domElement.addEventListener('keyup', this._onKeyup)\n this.domElement.addEventListener('keypress', this._onKeypress)\n }\n\n /**\n * handle key down\n * @param {Event} event - key event\n * @return {undefined}\n */\n _onKeydown (/* event */) {\n // console.log( \"down\", event.keyCode, String.fromCharCode( event.keyCode ) );\n }\n\n /**\n * handle key up\n * @param {Event} event - key event\n * @return {undefined}\n */\n _onKeyup (/* event */) {\n // console.log( \"up\", event.keyCode, String.fromCharCode( event.keyCode ) );\n }\n\n /**\n * handle key press\n * @param {Event} event - key event\n * @return {undefined}\n */\n _onKeypress (event: KeyboardEvent) {\n // console.log( \"press\", event.keyCode, String.fromCharCode( event.keyCode ) );\n let pressedKey: string;\n if (\"key\" in KeyboardEvent.prototype) {\n pressedKey = event.key;\n // some mobile browsers don't support this attribute\n } else {\n pressedKey = String.fromCharCode(event.which || event.keyCode);\n }\n this.controls.run(pressedKey);\n }\n\n _focusDomElement () {\n this.domElement.focus()\n }\n\n dispose () {\n this.domElement.removeEventListener('mousedown', this._focusDomElement)\n this.domElement.removeEventListener('touchstart', this._focusDomElement, passive as any) // TODO\n this.domElement.removeEventListener('keydown', this._onKeypress)\n this.domElement.removeEventListener('keyup', this._onKeypress)\n this.domElement.removeEventListener('keypress', this._onKeypress)\n }\n}\n\nexport default KeyBehavior\n","/**\n * @file Annotation\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector2, Vector3 } from 'three'\n\nimport { defaults } from '../utils'\nimport { smoothstep } from '../math/math-utils'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\nimport Component from './component'\n\nexport interface AnnotationParams {\n offsetX?: number\n offsetY?: number\n visible?: boolean\n}\n\n/**\n * Annotation HTML element floating on top of a position rendered in 3d\n */\nexport default class Annotation {\n offsetX: number\n offsetY: number\n visible: boolean\n\n stage: Stage\n viewer: Viewer\n element: HTMLElement\n\n private _viewerPosition: Vector3\n private _canvasPosition: Vector2\n private _cameraPosition: Vector3\n private _clientRect: ClientRect\n\n /**\n * @param {Component} component - the associated component\n * @param {Vector3} position - position in 3d\n * @param {String|Element} content - HTML content\n * @param {Object} [params] - parameters\n * @param {Integer} params.offsetX - 2d offset in x direction\n * @param {Integer} params.offsetY - 2d offset in y direction\n * @param {Boolean} params.visible - visibility flag\n */\n constructor (readonly component: Component, readonly position: Vector3, content: string|HTMLElement, params: AnnotationParams = {}) {\n this.offsetX = defaults(params.offsetX, 0)\n this.offsetY = defaults(params.offsetY, 0)\n this.visible = defaults(params.visible, true)\n\n this.stage = component.stage\n this.viewer = component.stage.viewer\n\n this._viewerPosition = new Vector3()\n this._updateViewerPosition()\n this._canvasPosition = new Vector2()\n this._cameraPosition = new Vector3()\n\n this.element = document.createElement('div')\n Object.assign(this.element.style, {\n display: 'block',\n position: 'absolute',\n pointerEvents: 'none',\n whiteSpace: 'nowrap',\n left: '-10000px'\n })\n\n this.viewer.wrapper.appendChild(this.element)\n this.setContent(content)\n this.updateVisibility()\n this.viewer.signals.rendered.add(this._update, this)\n this.component.signals.matrixChanged.add(this._updateViewerPosition, this)\n }\n\n /**\n * Set HTML content of the annotation\n * @param {String|Element} value - HTML content\n * @return {undefined}\n */\n setContent (value: string|HTMLElement) {\n const displayValue = this.element.style.display\n if (displayValue === 'none') {\n this.element.style.left = '-10000px'\n this.element.style.display = 'block'\n }\n\n if (value instanceof HTMLElement) {\n this.element.appendChild(value)\n } else {\n const content = document.createElement('div')\n content.innerText = value\n Object.assign(content.style, {\n backgroundColor: 'rgba( 0, 0, 0, 0.6 )',\n color: 'lightgrey',\n padding: '8px',\n fontFamily: 'sans-serif',\n })\n this.element.appendChild(content)\n }\n\n this._clientRect = this.element.getBoundingClientRect()\n\n if (displayValue === 'none') {\n this.element.style.display = displayValue\n }\n }\n\n /**\n * Set visibility of the annotation\n * @param {Boolean} value - visibility flag\n * @return {undefined}\n */\n setVisibility (value: boolean) {\n this.visible = value\n this.updateVisibility()\n }\n\n getVisibility () {\n return this.visible && this.component.parameters.visible\n }\n\n updateVisibility () {\n this.element.style.display = this.getVisibility() ? 'block' : 'none'\n }\n\n _updateViewerPosition () {\n this._viewerPosition\n .copy(this.position)\n .applyMatrix4(this.component.matrix)\n }\n\n _update () {\n if (!this.getVisibility()) return\n\n const s = this.element.style\n const cp = this._canvasPosition\n const vp = this._viewerPosition\n const cr = this._clientRect\n\n this._cameraPosition.copy(vp)\n .add(this.viewer.translationGroup.position)\n .applyMatrix4(this.viewer.rotationGroup.matrix)\n .sub(this.viewer.camera.position)\n\n if (this._cameraPosition.z < 0) {\n s.display = 'none'\n return\n } else {\n s.display = 'block'\n }\n\n const depth = this._cameraPosition.length()\n const fog = this.viewer.scene.fog as any // TODO\n\n s.opacity = (1 - smoothstep(fog.near, fog.far, depth)).toString()\n s.zIndex = (Math.round((fog.far - depth) * 100)).toString()\n\n this.stage.viewerControls.getPositionOnCanvas(vp, cp)\n\n s.bottom = (this.offsetX + cp.y + cr.height / 2) + 'px'\n s.left = (this.offsetY + cp.x - cr.width / 2) + 'px'\n }\n\n /**\n * Safely remove the annotation\n * @return {undefined}\n */\n dispose () {\n this.viewer.wrapper.removeChild(this.element)\n this.viewer.signals.ticked.remove(this._update, this)\n this.component.signals.matrixChanged.remove(this._updateViewerPosition, this)\n }\n}","/**\n * @file Component Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4, Quaternion } from 'three'\nimport * as signalsWrapper from 'signals'\n\nimport { ensureVector3 } from '../utils'\nimport Component from '../component/component'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\n\nconst tmpRotateMatrix = new Matrix4()\nconst tmpRotateVector = new Vector3()\nconst tmpRotateQuaternion = new Quaternion()\n\n/**\n * Component controls\n */\nclass ComponentControls {\n signals = {\n changed: new signalsWrapper.Signal()\n }\n\n stage: Stage\n viewer: Viewer\n\n /**\n * @param {Component} component - the component object\n */\n constructor (readonly component: Component) {\n this.stage = component.stage\n this.viewer = component.stage.viewer\n }\n\n /**\n * component center position\n * @type {Vector3}\n */\n get position () {\n return this.component.position\n }\n\n /**\n * component rotation\n * @type {Quaternion}\n */\n get rotation () {\n return this.component.quaternion\n }\n\n /**\n * Trigger render and emit changed event\n * @emits {ComponentControls.signals.changed}\n * @return {undefined}\n */\n changed () {\n this.component.updateMatrix()\n this.viewer.requestRender()\n this.signals.changed.dispatch()\n }\n\n /**\n * spin component on axis\n * @param {Vector3|Array} axis - rotation axis\n * @param {Number} angle - amount to spin\n * @return {undefined}\n */\n spin (axis: Vector3, angle: number) {\n tmpRotateMatrix.getInverse(this.viewer.rotationGroup.matrix)\n tmpRotateVector\n .copy(ensureVector3(axis)).applyMatrix4(tmpRotateMatrix)\n\n tmpRotateMatrix.extractRotation(this.component.transform)\n tmpRotateMatrix.premultiply(this.viewer.rotationGroup.matrix)\n tmpRotateMatrix.getInverse(tmpRotateMatrix)\n\n tmpRotateVector.copy(ensureVector3(axis))\n tmpRotateVector.applyMatrix4(tmpRotateMatrix)\n tmpRotateMatrix.makeRotationAxis(tmpRotateVector, angle)\n tmpRotateQuaternion.setFromRotationMatrix(tmpRotateMatrix)\n\n this.component.quaternion.premultiply(tmpRotateQuaternion)\n this.changed()\n }\n}\n\nexport default ComponentControls\n","/**\n * @file Radius Factory\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { NucleicBackboneAtoms } from '../structure/structure-constants'\nimport AtomProxy from '../proxy/atom-proxy'\n\nexport const RadiusFactoryTypes = {\n '': '',\n 'vdw': 'by vdW radius',\n 'covalent': 'by covalent radius',\n 'sstruc': 'by secondary structure',\n 'bfactor': 'by bfactor',\n 'size': 'size',\n 'data': 'data',\n 'explicit' : 'explicit'\n}\nexport type RadiusType = keyof typeof RadiusFactoryTypes\n\nexport interface RadiusParams {\n type?: RadiusType\n scale?: number\n size?: number\n data?: { [k: number]: number }\n}\n\nclass RadiusFactory {\n max = 10\n\n static types = RadiusFactoryTypes\n\n readonly type: RadiusType\n readonly scale: number\n readonly size: number\n readonly data: { [k: number]: number }\n\n constructor (params: RadiusParams = {}) {\n this.type = defaults(params.type, 'size')\n this.scale = defaults(params.scale, 1)\n this.size = defaults(params.size, 1)\n this.data = defaults(params.data, {})\n }\n\n atomRadius (a: AtomProxy) {\n let r\n\n switch (this.type) {\n case 'vdw':\n r = a.vdw\n break\n\n case 'covalent':\n r = a.covalent\n break\n\n case 'bfactor':\n r = a.bfactor || 1.0\n break\n\n case 'sstruc':\n const sstruc = a.sstruc\n if (sstruc === 'h') {\n r = 0.25\n } else if (sstruc === 'g') {\n r = 0.25\n } else if (sstruc === 'i') {\n r = 0.25\n } else if (sstruc === 'e') {\n r = 0.25\n } else if (sstruc === 'b') {\n r = 0.25\n } else if (NucleicBackboneAtoms.includes(a.atomname)) {\n r = 0.4\n } else {\n r = 0.1\n }\n break\n\n case 'data':\n r = defaults(this.data[ a.index ], 1.0)\n break\n\n case 'explicit':\n // defaults is inappropriate as AtomProxy.radius returns\n // null for missing radii\n r = a.radius\n if (r === null) r = this.size\n break\n\n default:\n r = this.size\n break\n }\n\n return Math.min(r * this.scale, this.max)\n }\n\n}\n\nexport default RadiusFactory\n","/**\n * @file Principal Axes\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4, Quaternion } from 'three'\n\nimport {\n Matrix, meanRows, subRows, transpose, multiplyABt, svd\n} from './matrix-utils'\nimport { projectPointOnVector } from './vector-utils'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\n\nconst negateVector = new Vector3(-1, -1, -1)\nconst tmpMatrix = new Matrix4()\n\n/**\n * Principal axes\n */\nclass PrincipalAxes {\n begA: Vector3\n endA: Vector3\n begB: Vector3\n endB: Vector3\n begC: Vector3\n endC: Vector3\n\n center: Vector3\n\n vecA: Vector3\n vecB: Vector3\n vecC: Vector3\n\n normVecA: Vector3\n normVecB: Vector3\n normVecC: Vector3\n\n /**\n * @param {Matrix} points - 3 by N matrix\n */\n constructor (points: Matrix) {\n // console.time( \"PrincipalAxes\" );\n\n const n = points.rows\n const n3 = n / 3\n const pointsT = new Matrix(n, 3)\n const A = new Matrix(3, 3)\n const W = new Matrix(1, 3)\n const U = new Matrix(3, 3)\n const V = new Matrix(3, 3)\n\n // calculate\n const mean = meanRows(points)\n subRows(points, mean)\n transpose(pointsT, points)\n multiplyABt(A, pointsT, pointsT)\n svd(A, W, U, V)\n\n // console.log( points, pointsT, mean )\n // console.log( n, A, W, U, V );\n\n // center\n const vm = new Vector3(mean[0], mean[1], mean[2])\n\n // normalized\n const van = new Vector3(U.data[0], U.data[3], U.data[6])\n const vbn = new Vector3(U.data[1], U.data[4], U.data[7])\n const vcn = new Vector3(U.data[2], U.data[5], U.data[8])\n\n // scaled\n const va = van.clone().multiplyScalar(Math.sqrt(W.data[0] / n3))\n const vb = vbn.clone().multiplyScalar(Math.sqrt(W.data[1] / n3))\n const vc = vcn.clone().multiplyScalar(Math.sqrt(W.data[2] / n3))\n\n // points\n this.begA = vm.clone().sub(va)\n this.endA = vm.clone().add(va)\n this.begB = vm.clone().sub(vb)\n this.endB = vm.clone().add(vb)\n this.begC = vm.clone().sub(vc)\n this.endC = vm.clone().add(vc)\n\n //\n\n this.center = vm\n\n this.vecA = va\n this.vecB = vb\n this.vecC = vc\n\n this.normVecA = van\n this.normVecB = vbn\n this.normVecC = vcn\n\n // console.timeEnd( \"PrincipalAxes\" );\n }\n\n /**\n * Get the basis matrix descriping the axes\n * @param {Matrix4} [optionalTarget] - target object\n * @return {Matrix4} the basis\n */\n getBasisMatrix (optionalTarget = new Matrix4()) {\n const basis = optionalTarget\n\n basis.makeBasis(this.normVecB, this.normVecA, this.normVecC)\n if (basis.determinant() < 0) {\n basis.scale(negateVector)\n }\n\n return basis\n }\n\n /**\n * Get a quaternion descriping the axes rotation\n * @param {Quaternion} [optionalTarget] - target object\n * @return {Quaternion} the rotation\n */\n getRotationQuaternion (optionalTarget = new Quaternion()) {\n const q = optionalTarget\n q.setFromRotationMatrix(this.getBasisMatrix(tmpMatrix))\n\n return q.inverse()\n }\n\n /**\n * Get the scale/length for each dimension for a box around the axes\n * to enclose the atoms of a structure\n * @param {Structure|StructureView} structure - the structure\n * @return {{d1a: Number, d2a: Number, d3a: Number, d1b: Number, d2b: Number, d3b: Number}} scale\n */\n getProjectedScaleForAtoms (structure: Structure) {\n let d1a = -Infinity\n let d1b = -Infinity\n let d2a = -Infinity\n let d2b = -Infinity\n let d3a = -Infinity\n let d3b = -Infinity\n\n const p = new Vector3()\n const t = new Vector3()\n\n const center = this.center\n const ax1 = this.normVecA\n const ax2 = this.normVecB\n const ax3 = this.normVecC\n\n structure.eachAtom(function (ap: AtomProxy) {\n projectPointOnVector(p.copy(ap as any), ax1, center) // TODO\n const dp1 = t.subVectors(p, center).normalize().dot(ax1)\n const dt1 = p.distanceTo(center)\n if (dp1 > 0) {\n if (dt1 > d1a) d1a = dt1\n } else {\n if (dt1 > d1b) d1b = dt1\n }\n\n projectPointOnVector(p.copy(ap as any), ax2, center)\n const dp2 = t.subVectors(p, center).normalize().dot(ax2)\n const dt2 = p.distanceTo(center)\n if (dp2 > 0) {\n if (dt2 > d2a) d2a = dt2\n } else {\n if (dt2 > d2b) d2b = dt2\n }\n\n projectPointOnVector(p.copy(ap as any), ax3, center)\n const dp3 = t.subVectors(p, center).normalize().dot(ax3)\n const dt3 = p.distanceTo(center)\n if (dp3 > 0) {\n if (dt3 > d3a) d3a = dt3\n } else {\n if (dt3 > d3b) d3b = dt3\n }\n })\n\n return {\n d1a: d1a,\n d2a: d2a,\n d3a: d3a,\n d1b: -d1b,\n d2b: -d2b,\n d3b: -d3b\n }\n }\n}\n\nexport default PrincipalAxes\n","/**\n * @file Filtered Volume\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport Volume from './volume'\nimport { Box3, Matrix4, Matrix3, Vector3 } from 'three';\n\nclass FilteredVolume {\n volume: Volume\n data: Float32Array\n position: Float32Array\n atomindex: Int32Array\n _filterHash: string\n _dataBuffer: ArrayBuffer\n _positionBuffer: ArrayBuffer\n _atomindexBuffer: ArrayBuffer\n getValueForSigma: typeof Volume.prototype.getValueForSigma\n getSigmaForValue: typeof Volume.prototype.getSigmaForValue\n getDataAtomindex: typeof Volume.prototype.getDataAtomindex\n getDataPosition: typeof Volume.prototype.getDataPosition\n getDataColor: typeof Volume.prototype.getDataColor\n getDataPicking: typeof Volume.prototype.getDataPicking\n getDataSize: typeof Volume.prototype.getDataSize\n\n\n constructor (volume: Volume, minValue?: number, maxValue?: number, outside?: boolean) {\n this.volume = volume\n this.setFilter(minValue, maxValue, outside)\n }\n\n get header () { return this.volume.header }\n get matrix (): Matrix4 { return this.volume.matrix }\n get normalMatrix (): Matrix3 { return this.volume.normalMatrix }\n get inverseMatrix (): Matrix4 { return this.volume.inverseMatrix }\n get center (): Vector3 { return this.volume.center }\n get boundingBox (): Box3 { return this.volume.boundingBox }\n get min () { return this.volume.min }\n get max () { return this.volume.max }\n get mean () { return this.volume.mean }\n get rms () { return this.volume.rms }\n\n _getFilterHash (minValue: number, maxValue: number, outside: boolean) {\n return JSON.stringify([ minValue, maxValue, outside ])\n }\n\n setFilter (minValue: number|undefined, maxValue: number|undefined, outside: boolean|undefined) {\n if (isNaN(minValue) && this.header) {\n minValue = this.header.DMEAN + 2.0 * this.header.ARMS\n }\n\n minValue = (minValue !== undefined && !isNaN(minValue)) ? minValue : -Infinity\n maxValue = defaults(maxValue, Infinity) as number\n outside = defaults(outside, false) as boolean\n\n const data = this.volume.data\n const position = this.volume.position\n const atomindex = this.volume.atomindex\n\n const filterHash = this._getFilterHash(minValue, maxValue, outside)\n\n if (filterHash === this._filterHash) {\n // already filtered\n return\n } else if (minValue === -Infinity && maxValue === Infinity) {\n this.data = data\n this.position = position\n this.atomindex = atomindex!\n } else {\n const n = data.length\n\n if (!this._dataBuffer) {\n // ArrayBuffer for re-use as Float32Array backend\n\n this._dataBuffer = new ArrayBuffer(n * 4)\n this._positionBuffer = new ArrayBuffer(n * 3 * 4)\n if (atomindex) this._atomindexBuffer = new ArrayBuffer(n * 4)\n }\n\n const filteredData = new Float32Array(this._dataBuffer)\n const filteredPosition = new Float32Array(this._positionBuffer)\n let filteredAtomindex\n if (atomindex) filteredAtomindex = new Uint32Array(this._atomindexBuffer)\n\n let j = 0\n\n for (let i = 0; i < n; ++i) {\n const i3 = i * 3\n const v = data[ i ]\n\n if ((!outside && v >= minValue && v <= maxValue) ||\n (outside && (v < minValue || v > maxValue))\n ) {\n const j3 = j * 3\n\n filteredData[ j ] = v\n\n filteredPosition[ j3 + 0 ] = position[ i3 + 0 ]\n filteredPosition[ j3 + 1 ] = position[ i3 + 1 ]\n filteredPosition[ j3 + 2 ] = position[ i3 + 2 ]\n\n if (atomindex && filteredAtomindex) filteredAtomindex[ j ] = atomindex[ i ]\n\n j += 1\n }\n }\n\n // set views\n\n this.data = new Float32Array(this._dataBuffer, 0, j)\n this.position = new Float32Array(this._positionBuffer, 0, j * 3)\n if (atomindex) this.atomindex = new Int32Array(this._atomindexBuffer, 0, j)\n }\n\n this._filterHash = filterHash\n }\n}\n\nFilteredVolume.prototype.getValueForSigma = Volume.prototype.getValueForSigma\nFilteredVolume.prototype.getSigmaForValue = Volume.prototype.getSigmaForValue\n\nFilteredVolume.prototype.getDataAtomindex = Volume.prototype.getDataAtomindex\nFilteredVolume.prototype.getDataPosition = Volume.prototype.getDataPosition\nFilteredVolume.prototype.getDataColor = Volume.prototype.getDataColor\nFilteredVolume.prototype.getDataPicking = Volume.prototype.getDataPicking\nFilteredVolume.prototype.getDataSize = Volume.prototype.getDataSize\n\nexport default FilteredVolume\n","/**\n * @file Bond Hash\n * @author Alexander Rose \n * @private\n */\n\nimport BondStore from './bond-store'\nimport { createAdjacencyList } from '../utils/adjacency-list'\n\nclass BondHash {\n countArray: Uint8Array\n offsetArray: Int32Array\n indexArray: Int32Array\n\n constructor (bondStore: BondStore, atomCount: number) {\n const al = createAdjacencyList({\n nodeArray1: bondStore.atomIndex1,\n nodeArray2: bondStore.atomIndex2,\n edgeCount: bondStore.count,\n nodeCount: atomCount\n })\n\n this.countArray = al.countArray\n this.offsetArray = al.offsetArray\n this.indexArray = al.indexArray\n }\n}\n\nexport default BondHash\n","/**\n * @file Bond Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Bond store\n */\nexport default class BondStore extends Store {\n atomIndex1: Uint32Array\n atomIndex2: Uint32Array\n bondOrder: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'atomIndex1', 1, 'int32' ],\n [ 'atomIndex2', 1, 'int32' ],\n [ 'bondOrder', 1, 'int8' ]\n ] as StoreField[]\n }\n\n addBond (atom1: AtomProxy, atom2: AtomProxy, bondOrder?: number) {\n this.growIfFull()\n\n const i = this.count\n const ai1 = atom1.index\n const ai2 = atom2.index\n\n if (ai1 < ai2) {\n this.atomIndex1[ i ] = ai1\n this.atomIndex2[ i ] = ai2\n } else {\n this.atomIndex2[ i ] = ai1\n this.atomIndex1[ i ] = ai2\n }\n if (bondOrder) this.bondOrder[ i ] = bondOrder\n\n this.count += 1\n }\n\n addBondIfConnected (atom1: AtomProxy, atom2: AtomProxy, bondOrder?: number) {\n if (atom1.connectedTo(atom2)) {\n this.addBond(atom1, atom2, bondOrder)\n return true\n }\n\n return false\n }\n}","/**\n * @file Atom Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Atom store\n */\nexport default class AtomStore extends Store {\n residueIndex: Uint32Array\n atomTypeId: Uint16Array\n\n x: Float32Array\n y: Float32Array\n z: Float32Array\n serial: Int32Array\n bfactor: Float32Array\n altloc: Uint8Array\n occupancy: Float32Array\n\n partialCharge?: Float32Array\n formalCharge?: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'residueIndex', 1, 'uint32' ],\n [ 'atomTypeId', 1, 'uint16' ],\n\n [ 'x', 1, 'float32' ],\n [ 'y', 1, 'float32' ],\n [ 'z', 1, 'float32' ],\n [ 'serial', 1, 'int32' ],\n [ 'bfactor', 1, 'float32' ],\n [ 'altloc', 1, 'uint8' ],\n [ 'occupancy', 1, 'float32' ]\n ] as StoreField[]\n }\n\n setAltloc (i: number, str: string) {\n this.altloc[ i ] = str.charCodeAt(0)\n }\n\n getAltloc (i: number) {\n const code = this.altloc[ i ]\n return code ? String.fromCharCode(code) : ''\n }\n}","/**\n * @file Residue Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Residue store\n */\nexport default class ResidueStore extends Store {\n chainIndex: Uint32Array\n atomOffset: Uint32Array\n atomCount: Uint32Array\n residueTypeId: Uint16Array\n\n resno: Uint32Array\n sstruc: Uint8Array\n inscode: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'chainIndex', 1, 'uint32' ],\n [ 'atomOffset', 1, 'uint32' ],\n [ 'atomCount', 1, 'uint32' ],\n [ 'residueTypeId', 1, 'uint16' ],\n\n [ 'resno', 1, 'int32' ],\n [ 'sstruc', 1, 'uint8' ],\n [ 'inscode', 1, 'uint8' ]\n ] as StoreField[]\n }\n\n setSstruc (i: number, str: string) {\n this.sstruc[ i ] = str.charCodeAt(0)\n }\n\n getSstruc (i: number) {\n const code = this.sstruc[ i ]\n return code ? String.fromCharCode(code) : ''\n }\n\n setInscode (i: number, str: string) {\n this.inscode[ i ] = str.charCodeAt(0)\n }\n\n getInscode (i: number) {\n const code = this.inscode[ i ]\n return code ? String.fromCharCode(code) : ''\n }\n}","/**\n * @file Chain Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Chain store\n */\nexport default class ChainStore extends Store {\n entityIndex: Uint16Array\n modelIndex: Uint16Array\n residueOffset: Uint32Array\n residueCount: Uint32Array\n\n chainname: Uint8Array\n chainid: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'entityIndex', 1, 'uint16' ],\n [ 'modelIndex', 1, 'uint16' ],\n [ 'residueOffset', 1, 'uint32' ],\n [ 'residueCount', 1, 'uint32' ],\n\n [ 'chainname', 4, 'uint8' ],\n [ 'chainid', 4, 'uint8' ]\n ] as StoreField[]\n }\n\n setChainname (i: number, str: string) {\n const j = 4 * i\n this.chainname[ j ] = str.charCodeAt(0)\n this.chainname[ j + 1 ] = str.charCodeAt(1)\n this.chainname[ j + 2 ] = str.charCodeAt(2)\n this.chainname[ j + 3 ] = str.charCodeAt(3)\n }\n\n getChainname (i: number) {\n let chainname = ''\n for (let k = 0; k < 4; ++k) {\n const code = this.chainname[ 4 * i + k ]\n if (code) {\n chainname += String.fromCharCode(code)\n } else {\n break\n }\n }\n return chainname\n }\n\n setChainid (i: number, str: string) {\n const j = 4 * i\n this.chainid[ j ] = str.charCodeAt(0)\n this.chainid[ j + 1 ] = str.charCodeAt(1)\n this.chainid[ j + 2 ] = str.charCodeAt(2)\n this.chainid[ j + 3 ] = str.charCodeAt(3)\n }\n\n getChainid (i: number) {\n let chainid = ''\n for (let k = 0; k < 4; ++k) {\n const code = this.chainid[ 4 * i + k ]\n if (code) {\n chainid += String.fromCharCode(code)\n } else {\n break\n }\n }\n return chainid\n }\n}\n","/**\n * @file Model Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Model store\n */\nexport default class ModelStore extends Store {\n\tchainOffset: Uint32Array\n\tchainCount: Uint32Array\n\n get _defaultFields () {\n return [\n [ 'chainOffset', 1, 'uint32' ],\n [ 'chainCount', 1, 'uint32' ]\n ] as StoreField[]\n }\n}","/**\n * @file Helixorient\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport { ColormakerParameters } from '../color/colormaker'\nimport { AtomPicker } from '../utils/picker'\nimport RadiusFactory, { RadiusParams } from '../utils/radius-factory'\nimport { copyArray } from '../math/array-utils'\nimport { projectPointOnVector } from '../math/vector-utils'\nimport Polymer from '../proxy/polymer'\n\nexport interface HelixIterator {\n size: number\n next: () => Vector3\n get: (idx: number) => Vector3\n reset: () => void\n}\n\nexport interface HelixPosition {\n center: Float32Array\n axis: Float32Array\n bending: Float32Array\n radius: Float32Array\n rise: Float32Array\n twist: Float32Array\n resdir: Float32Array\n}\n\nclass Helixorient {\n size: number\n\n constructor (readonly polymer: Polymer) {\n this.size = polymer.residueCount\n }\n\n getCenterIterator (smooth = 0): HelixIterator {\n const center = this.getPosition().center\n const size = center.length / 3\n\n let i = 0\n let j = -1\n\n const cache = [\n new Vector3(),\n new Vector3(),\n new Vector3(),\n new Vector3()\n ]\n\n function next (this: HelixIterator) {\n const vector = this.get(j)\n j += 1\n return vector\n }\n\n function get (idx: number) {\n idx = Math.min(size - 1, Math.max(0, idx))\n const v = cache[ i % 4 ]\n const idx3 = 3 * idx\n v.fromArray(center as any, idx3) // TODO\n if (smooth) {\n const w = Math.min(smooth, idx, size - idx - 1)\n for (let k = 1; k <= w; ++k) {\n const l = k * 3\n const t = (w + 1 - k) / (w + 1)\n v.x += t * center[ idx3 - l + 0 ] + t * center[ idx3 + l + 0 ]\n v.y += t * center[ idx3 - l + 1 ] + t * center[ idx3 + l + 1 ]\n v.z += t * center[ idx3 - l + 2 ] + t * center[ idx3 + l + 2 ]\n }\n v.x /= w + 1\n v.y /= w + 1\n v.z /= w + 1\n }\n i += 1\n return v\n }\n\n function reset () {\n i = 0\n j = -1\n }\n\n return { size, next, get, reset }\n }\n\n getColor (params: { scheme: string } & ColormakerParameters) {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const residueIndexStart = polymer.residueIndexStart\n\n const col = new Float32Array(n * 3)\n\n const p = params || {}\n p.structure = structure\n\n const colormaker = ColormakerRegistry.getScheme(p)\n\n const rp = structure.getResidueProxy()\n const ap = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n rp.index = residueIndexStart + i\n ap.index = rp.traceAtomIndex\n\n colormaker.atomColorToArray(ap, col, i * 3)\n }\n\n return {\n 'color': col\n }\n }\n\n getPicking () {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const residueIndexStart = polymer.residueIndexStart\n\n const pick = new Float32Array(n)\n const rp = structure.getResidueProxy()\n\n for (let i = 0; i < n; ++i) {\n rp.index = residueIndexStart + i\n pick[ i ] = rp.traceAtomIndex\n }\n\n return {\n 'picking': new AtomPicker(pick, structure)\n }\n }\n\n getSize (params: RadiusParams) {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const residueIndexStart = polymer.residueIndexStart\n\n const size = new Float32Array(n)\n const radiusFactory = new RadiusFactory(params)\n\n const rp = structure.getResidueProxy()\n const ap = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n rp.index = residueIndexStart + i\n ap.index = rp.traceAtomIndex\n size[ i ] = radiusFactory.atomRadius(ap)\n }\n\n return { size }\n }\n\n getPosition (): HelixPosition {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const n3 = n - 3\n\n const center = new Float32Array(3 * n)\n const axis = new Float32Array(3 * n)\n const diff = new Float32Array(n)\n const radius = new Float32Array(n)\n const rise = new Float32Array(n)\n const twist = new Float32Array(n)\n const resdir = new Float32Array(3 * n)\n\n const r12 = new Vector3()\n const r23 = new Vector3()\n const r34 = new Vector3()\n\n const diff13 = new Vector3()\n const diff24 = new Vector3()\n\n const v1 = new Vector3()\n const v2 = new Vector3()\n const vt = new Vector3()\n\n const _axis = new Vector3()\n const _prevAxis = new Vector3()\n\n const _resdir = new Vector3()\n const _center = new Vector3(0, 0, 0)\n\n const type = 'trace'\n const a1 = structure.getAtomProxy()\n const a2 = structure.getAtomProxy(polymer.getAtomIndexByType(0, type))\n const a3 = structure.getAtomProxy(polymer.getAtomIndexByType(1, type))\n const a4 = structure.getAtomProxy(polymer.getAtomIndexByType(2, type))\n\n for (let i = 0; i < n3; ++i) {\n a1.index = a2.index\n a2.index = a3.index\n a3.index = a4.index\n a4.index = polymer.getAtomIndexByType(i + 3, type)! // TODO\n\n const j = 3 * i\n\n // ported from GROMACS src/tools/gmx_helixorient.c\n\n r12.subVectors(a2 as any, a1 as any) // TODO\n r23.subVectors(a3 as any, a2 as any) // TODO\n r34.subVectors(a4 as any, a3 as any) // TODO\n\n diff13.subVectors(r12, r23)\n diff24.subVectors(r23, r34)\n\n _axis.crossVectors(diff13, diff24).normalize()\n _axis.toArray(axis as any, j) // TODO\n\n if (i > 0) {\n diff[ i ] = _axis.angleTo(_prevAxis)\n }\n\n const tmp = Math.cos(diff13.angleTo(diff24))\n twist[ i ] = 180.0 / Math.PI * Math.acos(tmp)\n\n const diff13Length = diff13.length()\n const diff24Length = diff24.length()\n\n radius[ i ] = (\n Math.sqrt(diff24Length * diff13Length) /\n // clamp, to avoid instabilities for when\n // angle between diff13 and diff24 is near 0\n Math.max(2.0, 2.0 * (1.0 - tmp))\n )\n\n rise[ i ] = Math.abs(r23.dot(_axis))\n\n //\n\n v1.copy(diff13).multiplyScalar(radius[ i ] / diff13Length)\n v2.copy(diff24).multiplyScalar(radius[ i ] / diff24Length)\n\n v1.subVectors(a2 as any, v1) // TODO\n v2.subVectors(a3 as any, v2) // TODO\n\n v1.toArray(center as any, j + 3) // TODO\n v2.toArray(center as any, j + 6) // TODO\n\n //\n\n _resdir.subVectors(a1 as any, _center) // TODO\n _resdir.toArray(resdir as any, j) // TODO\n\n _prevAxis.copy(_axis)\n _center.copy(v1)\n }\n\n //\n\n // calc axis as dir of second and third center pos\n // project first traceAtom onto axis to get first center pos\n v1.fromArray(center as any, 3) // TODO\n v2.fromArray(center as any, 6) // TODO\n _axis.subVectors(v1, v2).normalize()\n // _center.copy( res[ 0 ].getTraceAtom() );\n a1.index = polymer.getAtomIndexByType(0, type)! // TODO\n _center.copy(a1 as any) // TODO\n vt.copy(a1 as any) // TODO\n projectPointOnVector(vt, _axis, v1)\n vt.toArray(center as any, 0) // TODO\n\n // calc first resdir\n _resdir.subVectors(_center, v1)\n _resdir.toArray(resdir as any, 0) // TODO\n\n // calc axis as dir of n-1 and n-2 center pos\n // project last traceAtom onto axis to get last center pos\n v1.fromArray(center as any, 3 * n - 6) // TODO\n v2.fromArray(center as any, 3 * n - 9) // TODO\n _axis.subVectors(v1, v2).normalize()\n // _center.copy( res[ n - 1 ].getTraceAtom() );\n a1.index = polymer.getAtomIndexByType(n - 1, type)! // TODO\n _center.copy(a1 as any) // TODO\n vt.copy(a1 as any) // TODO\n projectPointOnVector(vt, _axis, v1)\n vt.toArray(center as any, 3 * n - 3) // TODO\n\n // calc last three resdir\n for (let i = n - 3; i < n; ++i) {\n v1.fromArray(center as any, 3 * i) // TODO\n // _center.copy( res[ i ].getTraceAtom() );\n a1.index = polymer.getAtomIndexByType(i, type)! // TODO\n _center.copy(a1 as any) // TODO\n\n _resdir.subVectors(_center, v1)\n _resdir.toArray(resdir as any, 3 * i) // TODO\n }\n\n // average measures to define them on the residues\n\n const resRadius = new Float32Array(n)\n const resTwist = new Float32Array(n)\n const resRise = new Float32Array(n)\n const resBending = new Float32Array(n)\n\n resRadius[ 1 ] = radius[ 0 ]\n resTwist[ 1 ] = twist[ 0 ]\n resRise[ 1 ] = radius[ 0 ]\n\n for (let i = 2; i < n - 2; ++i) {\n resRadius[ i ] = 0.5 * (radius[ i - 2 ] + radius[ i - 1 ])\n resTwist[ i ] = 0.5 * (twist[ i - 2 ] + twist[ i - 1 ])\n resRise[ i ] = 0.5 * (rise[ i - 2 ] + rise[ i - 1 ])\n\n v1.fromArray(axis as any, 3 * (i - 2)) // TODO\n v2.fromArray(axis as any, 3 * (i - 1)) // TODO\n resBending[ i ] = 180.0 / Math.PI * Math.acos(Math.cos(v1.angleTo(v2)))\n }\n\n resRadius[ n - 2 ] = radius[ n - 4 ]\n resTwist[ n - 2 ] = twist[ n - 4 ]\n resRise[ n - 2 ] = rise[ n - 4 ]\n\n // average helix axes to define them on the residues\n\n const resAxis = new Float32Array(3 * n)\n\n copyArray(axis, resAxis, 0, 0, 3)\n copyArray(axis, resAxis, 0, 3, 3)\n\n for (let i = 2; i < n - 2; ++i) {\n v1.fromArray(axis as any, 3 * (i - 2)) // TODO\n v2.fromArray(axis as any, 3 * (i - 1)) // TODO\n\n _axis.addVectors(v2, v1).multiplyScalar(0.5).normalize()\n _axis.toArray(resAxis as any, 3 * i) // TODO\n }\n\n copyArray(axis, resAxis, 3 * n - 12, 3 * n - 6, 3)\n copyArray(axis, resAxis, 3 * n - 12, 3 * n - 3, 3)\n\n return {\n center,\n axis: resAxis,\n bending: resBending,\n radius: resRadius,\n rise: resRise,\n twist: resTwist,\n resdir: resdir\n }\n }\n\n}\n\nexport default Helixorient\n","/**\n * @file Helixbundle\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport { AtomPicker } from '../utils/picker'\nimport RadiusFactory, { RadiusParams } from '../utils/radius-factory'\nimport Helixorient, { HelixPosition } from './helixorient'\nimport { calculateMeanVector3, projectPointOnVector } from '../math/vector-utils'\nimport Polymer from '../proxy/polymer'\nimport { ColormakerParameters } from '../color/colormaker';\n\nexport interface Axis {\n axis: Float32Array\n center: Float32Array\n begin: Float32Array\n end: Float32Array\n color: Float32Array\n picking: AtomPicker\n size: Float32Array\n residueOffset: number[]\n residueCount: number[]\n}\n\nclass Helixbundle {\n helixorient: Helixorient;\n position: HelixPosition;\n\n constructor (readonly polymer: Polymer) {\n\n this.helixorient = new Helixorient(polymer)\n this.position = this.helixorient.getPosition()\n }\n\n getAxis (localAngle: number, centerDist: number, ssBorder: boolean, colorParams: { scheme: string} & ColormakerParameters, radiusParams: RadiusParams): Axis {\n localAngle = localAngle || 30\n centerDist = centerDist || 2.5\n ssBorder = ssBorder === undefined ? false : ssBorder\n\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const residueIndexStart = polymer.residueIndexStart\n\n const pos = this.position\n\n const cp = colorParams || {}\n cp.structure = structure\n\n const colormaker = ColormakerRegistry.getScheme(cp)\n\n const radiusFactory = new RadiusFactory(radiusParams)\n\n let j = 0\n let k = 0\n\n const axis: number[] = []\n const center: number[] = []\n const beg: number[] = []\n const end: number[] = []\n const col: number[] = []\n const pick = []\n const size = []\n const residueOffset = []\n const residueCount = []\n\n let tmpAxis = new Float32Array(n * 3)\n let tmpCenter = new Float32Array(n * 3)\n\n let _axis, _center\n const _beg = new Vector3()\n const _end = new Vector3()\n\n const rp1 = structure.getResidueProxy()\n const rp2 = structure.getResidueProxy()\n const ap = structure.getAtomProxy()\n\n const c1 = new Vector3()\n const c2 = new Vector3()\n\n let split = false\n\n for (let i = 0; i < n; ++i) {\n rp1.index = residueIndexStart + i\n c1.fromArray(pos.center as any, i * 3)\n\n if (i === n - 1) {\n split = true\n } else {\n rp2.index = residueIndexStart + i + 1\n c2.fromArray(pos.center as any, i * 3 + 3)\n\n if (ssBorder && rp1.sstruc !== rp2.sstruc) {\n split = true\n } else if (c1.distanceTo(c2) > centerDist) {\n split = true\n } else if (pos.bending[ i ] > localAngle) {\n split = true\n }\n }\n\n if (split) {\n if (i - j < 4) {\n j = i\n split = false\n continue\n }\n\n ap.index = rp1.traceAtomIndex\n\n // ignore first and last axis\n tmpAxis = pos.axis.subarray(j * 3 + 3, i * 3)\n tmpCenter = pos.center.subarray(j * 3, i * 3 + 3)\n\n _axis = calculateMeanVector3(tmpAxis).normalize()\n _center = calculateMeanVector3(tmpCenter)\n\n _beg.fromArray(tmpCenter as any)\n projectPointOnVector(_beg, _axis, _center)\n\n _end.fromArray(tmpCenter as any, tmpCenter.length - 3)\n projectPointOnVector(_end, _axis, _center)\n\n _axis.subVectors(_end, _beg)\n\n _axis.toArray(axis as any, k)\n _center.toArray(center as any, k)\n _beg.toArray(beg as any, k)\n _end.toArray(end as any, k)\n\n colormaker.atomColorToArray(ap, col, k)\n\n pick.push(ap.index)\n\n size.push(radiusFactory.atomRadius(ap))\n\n residueOffset.push(residueIndexStart + j)\n residueCount.push(residueIndexStart + i + 1 - j)\n\n k += 3\n j = i\n split = false\n }\n }\n\n const picking = new Float32Array(pick)\n\n return {\n axis: new Float32Array(axis),\n center: new Float32Array(center),\n begin: new Float32Array(beg),\n end: new Float32Array(end),\n color: new Float32Array(col),\n picking: new AtomPicker(picking, structure),\n size: new Float32Array(size),\n residueOffset: residueOffset,\n residueCount: residueCount\n }\n }\n}\n\nexport default Helixbundle\n","/**\n * @file Binary Heap\n * @author Alexander Rose \n * @private\n */\n\n/**\n * Binary heap implementation\n * @class\n * @author http://eloquentjavascript.net/appendix2.htm\n * @param {Function} scoreFunction - the heap scoring function\n */\nclass BinaryHeap {\n content: T[] = []\n\n constructor(readonly scoreFunction: (x: T) => number) {\n\n this.scoreFunction = scoreFunction\n }\n\n push (element: T) {\n // Add the new element to the end of the array.\n this.content.push(element)\n\n // Allow it to bubble up.\n this.bubbleUp(this.content.length - 1)\n }\n\n pop () {\n // Store the first element so we can return it later.\n const result = this.content[ 0 ]\n\n // Get the element at the end of the array.\n const end = this.content.pop()\n\n // If there are any elements left, put the end element at the\n // start, and let it sink down.\n if (end && this.content.length > 0) {\n this.content[ 0 ] = end\n this.sinkDown(0)\n }\n\n return result\n }\n\n peek () {\n return this.content[ 0 ]\n }\n\n remove (element: T) {\n const len = this.content.length\n\n // To remove a value, we must search through the array to find it.\n for (let i = 0; i < len; i++) {\n if (this.content[ i ] === element) {\n // When it is found, the process seen in 'pop' is repeated\n // to fill up the hole.\n const end = this.content.pop()\n\n if (end && i !== len - 1) {\n this.content[ i ] = end\n\n if (this.scoreFunction(end) < this.scoreFunction(element)) {\n this.bubbleUp(i)\n } else {\n this.sinkDown(i)\n }\n }\n\n return\n }\n }\n\n throw new Error('Node not found.')\n }\n\n size () {\n return this.content.length\n }\n\n bubbleUp (n: number) {\n // Fetch the element that has to be moved.\n const element = this.content[ n ]\n\n // When at 0, an element can not go up any further.\n while (n > 0) {\n // Compute the parent element's index, and fetch it.\n const parentN = Math.floor((n + 1) / 2) - 1\n const parent = this.content[ parentN ]\n\n // Swap the elements if the parent is greater.\n if (this.scoreFunction(element) < this.scoreFunction(parent)) {\n this.content[ parentN ] = element\n this.content[ n ] = parent\n\n // Update 'n' to continue at the new position.\n n = parentN\n } else {\n // Found a parent that is less, no need to move it further.\n break\n }\n }\n }\n\n sinkDown (n: number) {\n // Look up the target element and its score.\n const length = this.content.length\n const element = this.content[ n ]\n const elemScore = this.scoreFunction(element)\n\n let child1Score = 0\n let child2Score = 0\n\n while (true) {\n // Compute the indices of the child elements.\n const child2N = (n + 1) * 2\n const child1N = child2N - 1\n\n // This is used to store the new position of the element, if any.\n let swap = null\n\n // If the first child exists (is inside the array)...\n if (child1N < length) {\n // Look it up and compute its score.\n const child1 = this.content[ child1N ]\n child1Score = this.scoreFunction(child1)\n\n // If the score is less than our element's, we need to swap.\n if (child1Score < elemScore) swap = child1N\n }\n\n // Do the same checks for the other child.\n if (child2N < length) {\n const child2 = this.content[ child2N ]\n child2Score = this.scoreFunction(child2)\n\n if (child2Score < (swap === null ? elemScore : child1Score)) swap = child2N\n }\n\n // If the element needs to be moved, swap it, and continue.\n if (swap !== null) {\n this.content[ n ] = this.content[ swap ]\n this.content[ swap ] = element\n n = swap\n } else {\n // Otherwise, we are done.\n break\n }\n }\n }\n\n}\n\nexport default BinaryHeap\n","/**\n * @file Kdtree\n * @author Alexander Rose \n * @private\n */\n\nimport { NumberArray } from '../types'\nimport BinaryHeap from './binary-heap'\n\n/**\n * Kdtree\n * @class\n * @author Alexander Rose , 2016\n * @author Roman Bolzern , 2013\n * @author I4DS http://www.fhnw.ch/i4ds, 2013\n * @license MIT License \n * @description\n * k-d Tree for typed arrays of 3d points (e.g. for Float32Array), in-place\n * provides fast nearest neighbour search\n *\n * Based on https://github.com/ubilabs/kd-tree-javascript by Ubilabs\n *\n * Further information (including mathematical properties)\n * http://en.wikipedia.org/wiki/Binary_tree\n * http://en.wikipedia.org/wiki/K-d_tree\n *\n * @example\n * points: [x, y, z, x, y, z, x, y, z, ...]\n * metric: function(a, b){\n * return Math.pow(a[0]-b[0], 2) + Math.pow(a[1]-b[1], 2) + Math.pow(a[2]-b[2], 2);\n * }\n *\n * @param {Float32Array} points - points\n * @param {Function} metric - metric\n */\nclass Kdtree {\n indices: Uint32Array\n nodes: Int32Array\n rootIndex: number\n\n maxDepth = 0\n currentNode = 0\n\n constructor(readonly points: NumberArray, readonly metric: (a: NumberArray, b: NumberArray) => number) {\n const n = points.length / 3\n\n const indices = new Uint32Array(n)\n for (let i = 0; i < n; ++i) {\n indices[ i ] = i\n }\n this.indices = indices\n this.nodes = new Int32Array(n * 4)\n this.rootIndex = this.buildTree(0, -1, 0, n)\n }\n\n buildTree (depth: number, parent: number, arrBegin: number, arrEnd: number) {\n if (depth > this.maxDepth) this.maxDepth = depth\n\n const plength = arrEnd - arrBegin\n if (plength === 0) {\n return -1\n }\n\n const nodeIndex = this.currentNode * 4\n const nodes = this.nodes\n\n this.currentNode += 1\n if (plength === 1) {\n nodes[ nodeIndex ] = arrBegin\n nodes[ nodeIndex + 1 ] = -1\n nodes[ nodeIndex + 2 ] = -1\n nodes[ nodeIndex + 3 ] = parent\n return nodeIndex\n }\n // if(plength <= 32){\n // return nodeIndex;\n // }\n\n const indices = this.indices\n const points = this.points\n\n const arrMedian = arrBegin + Math.floor(plength / 2)\n const currentDim = depth % 3\n\n // inlined quickselect function\n let j, tmp, pivotIndex, pivotValue, storeIndex\n let left = arrBegin\n let right = arrEnd - 1\n while (right > left) {\n pivotIndex = (left + right) >> 1\n pivotValue = points[ indices[ pivotIndex ] * 3 + currentDim ]\n // swap( pivotIndex, right );\n tmp = indices[ pivotIndex ]\n indices[ pivotIndex ] = indices[ right ]\n indices[ right ] = tmp\n storeIndex = left\n for (j = left; j < right; ++j) {\n if (points[ indices[ j ] * 3 + currentDim ] < pivotValue) {\n // swap( storeIndex, j );\n tmp = indices[ storeIndex ]\n indices[ storeIndex ] = indices[ j ]\n indices[ j ] = tmp\n ++storeIndex\n }\n }\n // swap( right, storeIndex );\n tmp = indices[ right ]\n indices[ right ] = indices[ storeIndex ]\n indices[ storeIndex ] = tmp\n pivotIndex = storeIndex\n if (arrMedian === pivotIndex) {\n break\n } else if (arrMedian < pivotIndex) {\n right = pivotIndex - 1\n } else {\n left = pivotIndex + 1\n }\n }\n\n nodes[ nodeIndex ] = arrMedian\n nodes[ nodeIndex + 1 ] = this.buildTree(depth + 1, nodeIndex, arrBegin, arrMedian)\n nodes[ nodeIndex + 2 ] = this.buildTree(depth + 1, nodeIndex, arrMedian + 1, arrEnd)\n nodes[ nodeIndex + 3 ] = parent\n\n return nodeIndex\n }\n\n getNodeDepth (nodeIndex: number): number {\n const parentIndex = this.nodes[ nodeIndex + 3 ]\n return (parentIndex === -1) ? 0 : this.getNodeDepth(parentIndex) + 1\n }\n\n // TODO\n // function getNodePos (node) {}\n\n /**\n * find nearest points\n * @param {Array} point - array of size 3\n * @param {Integer} maxNodes - max amount of nodes to return\n * @param {Float} maxDistance - maximum distance of point to result nodes\n * @return {Array} array of point, distance pairs\n */\n nearest (point: NumberArray, maxNodes: number, maxDistance: number) {\n const bestNodes = new BinaryHeap<[number, number]>(e => -e[ 1 ])\n\n const nodes = this.nodes\n const points = this.points\n const indices = this.indices\n\n const nearestSearch = (nodeIndex: number) => {\n let bestChild, otherChild\n const dimension = this.getNodeDepth(nodeIndex) % 3\n const pointIndex = indices[ nodes[ nodeIndex ] ] * 3\n const ownPoint = [\n points[ pointIndex + 0 ],\n points[ pointIndex + 1 ],\n points[ pointIndex + 2 ]\n ]\n const ownDistance = this.metric(point, ownPoint)\n\n function saveNode (nodeIndex: number, distance: number) {\n bestNodes.push([ nodeIndex, distance ])\n if (bestNodes.size() > maxNodes) {\n bestNodes.pop()\n }\n }\n\n const leftIndex = nodes[ nodeIndex + 1 ]\n const rightIndex = nodes[ nodeIndex + 2 ]\n\n // if it's a leaf\n if (rightIndex === -1 && leftIndex === -1) {\n if ((bestNodes.size() < maxNodes || ownDistance < bestNodes.peek()[ 1 ]) &&\n ownDistance <= maxDistance\n ) {\n saveNode(nodeIndex, ownDistance)\n }\n return\n }\n\n if (rightIndex === -1) {\n bestChild = leftIndex\n } else if (leftIndex === -1) {\n bestChild = rightIndex\n } else {\n if (point[ dimension ] <= points[ pointIndex + dimension ]) {\n bestChild = leftIndex\n } else {\n bestChild = rightIndex\n }\n }\n\n // recursive search\n nearestSearch(bestChild)\n\n if ((bestNodes.size() < maxNodes || ownDistance < bestNodes.peek()[ 1 ]) &&\n ownDistance <= maxDistance\n ) {\n saveNode(nodeIndex, ownDistance)\n }\n\n // if there's still room or the current distance is nearer than the best distance\n const linearPoint = []\n for (let i = 0; i < 3; i += 1) {\n if (i === dimension) {\n linearPoint[ i ] = point[ i ]\n } else {\n linearPoint[ i ] = points[ pointIndex + i ]\n }\n }\n const linearDistance = this.metric(linearPoint, ownPoint)\n\n if ((bestNodes.size() < maxNodes || Math.abs(linearDistance) < bestNodes.peek()[ 1 ]) &&\n Math.abs(linearDistance) <= maxDistance\n ) {\n if (bestChild === leftIndex) {\n otherChild = rightIndex\n } else {\n otherChild = leftIndex\n }\n if (otherChild !== -1) {\n nearestSearch(otherChild)\n }\n }\n }\n\n nearestSearch(this.rootIndex)\n\n const result = []\n for (let i = 0, il = Math.min(bestNodes.size(), maxNodes); i < il; i += 1) {\n result.push(bestNodes.content[ i ])\n }\n\n return result\n }\n\n verify (nodeIndex?: number, depth = 0) {\n let count = 1\n\n if (nodeIndex === undefined) {\n nodeIndex = this.rootIndex\n }\n\n if (nodeIndex === -1) {\n throw new Error('node is null')\n }\n\n const dim = depth % 3\n const nodes = this.nodes\n const points = this.points\n const indices = this.indices\n\n const leftIndex = nodes[ nodeIndex + 1 ]\n const rightIndex = nodes[ nodeIndex + 2 ]\n\n if (leftIndex !== -1) {\n if (points[ indices[ nodes[ leftIndex ] ] * 3 + dim ] >\n points[ indices[ nodes[ nodeIndex ] ] * 3 + dim ]\n ) {\n throw new Error('left child is > parent!')\n }\n count += this.verify(leftIndex, depth + 1)\n }\n\n if (rightIndex !== -1) {\n if (points[ indices[ nodes[ rightIndex ] ] * 3 + dim ] <\n points[ indices[ nodes[ nodeIndex ] ] * 3 + dim ]\n ) {\n throw new Error('right child is < parent!')\n }\n count += this.verify(rightIndex, depth + 1)\n }\n\n return count\n }\n}\n\nexport default Kdtree\n","/**\n * @file Atom Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { NumberArray } from '../types'\nimport {\n Elements,\n SecStrucHelix, SecStrucSheet, SecStrucTurn,\n ProteinType, RnaType, DnaType, WaterType, IonType, SaccharideType,\n CgProteinBackboneType, CgRnaBackboneType, CgDnaBackboneType\n} from '../structure/structure-constants'\n\nimport Structure from '../structure/structure'\n\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\nimport AtomStore from '../store/atom-store'\n\nimport AtomMap from '../store/atom-map'\nimport ResidueMap from '../store/residue-map'\n\nimport BondProxy from '../proxy/bond-proxy'\nimport AtomType from '../store/atom-type';\nimport ResidueType from '../store/residue-type';\nimport ResidueProxy from './residue-proxy';\nimport Entity from '../structure/entity';\nimport BondHash from '../store/bond-hash';\n\n/**\n * Atom proxy\n */\nclass AtomProxy {\n index: number\n\n chainStore: ChainStore\n residueStore: ResidueStore\n atomStore: AtomStore\n\n residueMap: ResidueMap\n atomMap: AtomMap\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n this.atomStore = structure.atomStore\n this.residueMap = structure.residueMap\n this.atomMap = structure.atomMap\n }\n\n /**\n * @type {BondHash}\n */\n get bondHash (): BondHash|undefined { return this.structure.bondHash }\n\n /**\n * Molecular enity\n * @type {Entity}\n */\n get entity (): Entity {\n return this.structure.entityList[ this.entityIndex ]\n }\n get entityIndex () {\n return this.chainStore.entityIndex[ this.chainIndex ]\n }\n get modelIndex () {\n return this.chainStore.modelIndex[ this.chainIndex ]\n }\n get chainIndex () {\n return this.residueStore.chainIndex[ this.residueIndex ]\n }\n /**\n * @type {ResidueProxy}\n */\n get residue (): ResidueProxy {\n console.warn('residue - might be expensive')\n return this.structure.getResidueProxy(this.residueIndex)\n }\n\n get residueIndex () {\n return this.atomStore.residueIndex[ this.index ]\n }\n set residueIndex (value) {\n this.atomStore.residueIndex[ this.index ] = value\n }\n\n //\n\n /**\n * Secondary structure code\n * @type {String}\n */\n get sstruc () {\n return this.residueStore.getSstruc(this.residueIndex)\n }\n /**\n * Insertion code\n * @type {String}\n */\n get inscode () {\n return this.residueStore.getInscode(this.residueIndex)\n }\n /**\n * Residue number/label\n * @type {Integer}\n */\n get resno () {\n return this.residueStore.resno[ this.residueIndex ]\n }\n /**\n * Chain name\n * @type {String}\n */\n get chainname () {\n return this.chainStore.getChainname(this.chainIndex)\n }\n /**\n * Chain id\n * @type {String}\n */\n get chainid () {\n return this.chainStore.getChainid(this.chainIndex)\n }\n\n //\n\n /**\n * @type {ResidueType}\n */\n get residueType (): ResidueType {\n return this.residueMap.get(this.residueStore.residueTypeId[ this.residueIndex ])\n }\n /**\n * @type {AtomType}\n */\n get atomType (): AtomType {\n return this.atomMap.get(this.atomStore.atomTypeId[ this.index ])\n }\n get residueAtomOffset () {\n return this.residueStore.atomOffset[ this.residueIndex ]\n }\n\n //\n\n /**\n * Residue name\n */\n get resname () {\n return this.residueType.resname\n }\n /**\n * Hetero flag\n */\n get hetero () {\n return this.residueType.hetero\n }\n\n //\n\n /**\n * Atom name\n */\n get atomname () {\n return this.atomType.atomname\n }\n /**\n * Atomic number\n */\n get number () {\n return this.atomType.number\n }\n /**\n * Element\n */\n get element () {\n return this.atomType.element\n }\n /**\n * Van-der-Waals radius\n */\n get vdw () {\n return this.atomType.vdw\n }\n /**\n * Covalent radius\n */\n get covalent () {\n return this.atomType.covalent\n }\n\n //\n\n /**\n * X coordinate\n */\n get x () {\n return this.atomStore.x[ this.index ]\n }\n set x (value) {\n this.atomStore.x[ this.index ] = value\n }\n\n /**\n * Y coordinate\n */\n get y () {\n return this.atomStore.y[ this.index ]\n }\n set y (value) {\n this.atomStore.y[ this.index ] = value\n }\n\n /**\n * Z coordinate\n */\n get z () {\n return this.atomStore.z[ this.index ]\n }\n set z (value) {\n this.atomStore.z[ this.index ] = value\n }\n\n /**\n * Serial number\n */\n get serial () {\n return this.atomStore.serial[ this.index ]\n }\n set serial (value) {\n this.atomStore.serial[ this.index ] = value\n }\n\n /**\n * B-factor value\n */\n get bfactor () {\n return this.atomStore.bfactor[ this.index ]\n }\n set bfactor (value) {\n this.atomStore.bfactor[ this.index ] = value\n }\n\n /**\n * Occupancy value\n */\n get occupancy () {\n return this.atomStore.occupancy[ this.index ]\n }\n set occupancy (value) {\n this.atomStore.occupancy[ this.index ] = value\n }\n\n /**\n * Alternate location identifier\n */\n get altloc () {\n return this.atomStore.getAltloc(this.index)\n }\n set altloc (value) {\n this.atomStore.setAltloc(this.index, value)\n }\n\n /**\n * Partial charge\n */\n get partialCharge () {\n return this.atomStore.partialCharge ? this.atomStore.partialCharge[ this.index ] : null\n }\n set partialCharge (value) {\n if (this.atomStore.partialCharge) {\n this.atomStore.partialCharge[ this.index ] = value as number\n }\n }\n\n /**\n * Explicit radius\n */\n get radius () {\n return this.atomStore.radius ? this.atomStore.radius[ this.index ] : null\n }\n set radius (value) {\n if (this.atomStore.radius) {\n this.atomStore.radius[ this.index ] = value as number\n }\n }\n\n /**\n * Formal charge\n */\n get formalCharge () {\n return this.atomStore.formalCharge ? this.atomStore.formalCharge[ this.index ] : null\n }\n set formalCharge (value) {\n if (this.atomStore.formalCharge) {\n this.atomStore.formalCharge[ this.index ] = value as number\n }\n }\n\n /**\n * Aromaticity flag\n */\n get aromatic () {\n if (this.atomStore.aromatic) {\n return this.atomStore.aromatic[ this.index ] as number\n } else {\n return this.residueType.isAromatic(this) ? 1 : 0\n }\n }\n set aromatic (value) {\n if (this.atomStore.aromatic) {\n this.atomStore.aromatic[ this.index ] = value as number\n }\n }\n\n //\n\n get bondCount () {\n return this.bondHash!.countArray[ this.index ] // TODO\n }\n\n //\n\n /**\n * Iterate over each bond\n * @param {function(bond: BondProxy)} callback - iterator callback function\n * @param {BondProxy} [bp] - optional target bond proxy for use in the callback\n * @return {undefined}\n */\n eachBond (callback: (bp: BondProxy) => void, bp?: BondProxy) {\n bp = bp || this.structure._bp\n const idx = this.index\n const bondHash = this.bondHash! // TODO\n const indexArray = bondHash.indexArray\n const n = bondHash.countArray[ idx ]\n const offset = bondHash.offsetArray[ idx ]\n\n for (let i = 0; i < n; ++i) {\n bp.index = indexArray[ offset + i ]\n callback(bp)\n }\n }\n\n /**\n * Iterate over each bonded atom\n * @param {function(atom: AtomProxy)} callback - iterator callback function\n * @param {AtomProxy} [ap] - optional target atom proxy for use in the callback\n * @return {undefined}\n */\n eachBondedAtom (callback: (ap: AtomProxy) => void, _ap?: AtomProxy) {\n const ap = _ap ? _ap : this.structure._ap\n const idx = this.index\n\n this.eachBond(function (bp) {\n ap.index = idx !== bp.atomIndex1 ? bp.atomIndex1 : bp.atomIndex2\n callback(ap)\n })\n this.index = idx\n }\n\n /**\n * Check if this atom is bonded to the given atom,\n * assumes both atoms are from the same structure\n * @param {AtomProxy} ap - the given atom\n * @return {Boolean} whether a bond exists or not\n */\n hasBondTo (ap: AtomProxy) {\n let flag = false\n this.eachBondedAtom(function (bap) {\n if (ap.index === bap.index) flag = true\n })\n return flag\n }\n\n bondToElementCount (element: Elements) {\n let count = 0\n const idx = this.index // Avoid reentrancy problems\n this.eachBondedAtom(function (bap) {\n if (bap.number === element) count += 1\n })\n this.index = idx\n return count\n }\n\n hasBondToElement (element: Elements) {\n return this.bondToElementCount(element) > 0\n }\n\n //\n\n /**\n * If atom is part of a backbone\n * @return {Boolean} flag\n */\n isBackbone () {\n const backboneIndexList = this.residueType.backboneIndexList\n if (backboneIndexList.length > 0) {\n return backboneIndexList.includes(this.index - this.residueAtomOffset)\n } else {\n return false\n }\n }\n\n /**\n * If atom is part of a polymer\n * @return {Boolean} flag\n */\n isPolymer () {\n if (this.structure.entityList.length > 0) {\n return this.entity.isPolymer()\n } else {\n const moleculeType = this.residueType.moleculeType\n return (\n moleculeType === ProteinType ||\n moleculeType === RnaType ||\n moleculeType === DnaType\n )\n }\n }\n\n /**\n * If atom is part of a sidechin\n * @return {Boolean} flag\n */\n isSidechain () {\n return this.isPolymer() && !this.isBackbone()\n }\n\n /**\n * If atom is part of a coarse-grain group\n * @return {Boolean} flag\n */\n isCg () {\n const backboneType = this.residueType.backboneType\n return (\n backboneType === CgProteinBackboneType ||\n backboneType === CgRnaBackboneType ||\n backboneType === CgDnaBackboneType\n )\n }\n\n isTrace () {\n return this.index === (this.residueType.traceAtomIndex + this.residueAtomOffset)\n }\n\n /**\n * If atom is part of a hetero group\n * @return {Boolean} flag\n */\n isHetero () {\n return this.residueType.hetero === 1\n }\n\n /**\n * If atom is part of a protein molecule\n * @return {Boolean} flag\n */\n isProtein () {\n return this.residueType.moleculeType === ProteinType\n }\n\n /**\n * If atom is part of a nucleic molecule\n * @return {Boolean} flag\n */\n isNucleic () {\n const moleculeType = this.residueType.moleculeType\n return moleculeType === RnaType || moleculeType === DnaType\n }\n\n /**\n * If atom is part of a rna\n * @return {Boolean} flag\n */\n isRna () {\n return this.residueType.moleculeType === RnaType\n }\n\n /**\n * If atom is part of a dna\n * @return {Boolean} flag\n */\n isDna () {\n return this.residueType.moleculeType === DnaType\n }\n\n /**\n * If atom is part of a water molecule\n * @return {Boolean} flag\n */\n isWater () {\n return this.residueType.moleculeType === WaterType\n }\n\n /**\n * If atom is part of an ion\n * @return {Boolean} flag\n */\n isIon () {\n return this.residueType.moleculeType === IonType\n }\n\n /**\n * If atom is part of a saccharide\n * @return {Boolean} flag\n */\n isSaccharide () {\n return this.residueType.moleculeType === SaccharideType\n }\n\n /**\n * If atom is part of a helix\n * @return {Boolean} flag\n */\n isHelix () {\n return SecStrucHelix.includes(this.sstruc)\n }\n\n /**\n * If atom is part of a sheet\n * @return {Boolean} flag\n */\n isSheet () {\n return SecStrucSheet.includes(this.sstruc)\n }\n\n /**\n * If atom is part of a turn\n * @return {Boolean} flag\n */\n isTurn () {\n return SecStrucTurn.includes(this.sstruc) && this.isProtein()\n }\n\n isBonded () {\n return this.bondHash!.countArray[ this.index ] !== 0 // TODO\n }\n\n /**\n * If atom is part of a ring\n * @return {Boolean} flag\n */\n isRing () {\n const atomRings = this.residueType.getRings()!.atomRings // TODO\n return atomRings[ this.index - this.residueAtomOffset ] !== undefined\n }\n\n isAromatic () {\n return this.aromatic === 1\n }\n\n isPolarHydrogen () {\n let result = false\n\n if (this.number !== 1) return result\n\n result = !this.hasBondToElement(Elements.C)\n\n return result\n }\n\n isMetal () { return this.atomType.isMetal() }\n isNonmetal () { return this.atomType.isNonmetal() }\n isMetalloid () { return this.atomType.isMetalloid() }\n isHalogen () { return this.atomType.isHalogen() }\n isDiatomicNonmetal () { return this.atomType.isDiatomicNonmetal() }\n isPolyatomicNonmetal () { return this.atomType.isPolyatomicNonmetal() }\n isAlkaliMetal () { return this.atomType.isAlkaliMetal() }\n isAlkalineEarthMetal () { return this.atomType.isAlkalineEarthMetal() }\n isNobleGas () { return this.atomType.isNobleGas() }\n isTransitionMetal () { return this.atomType.isTransitionMetal() }\n isPostTransitionMetal () { return this.atomType.isPostTransitionMetal() }\n isLanthanide () { return this.atomType.isLanthanide() }\n isActinide () { return this.atomType.isActinide() }\n\n getDefaultValence () { return this.atomType.getDefaultValence() }\n getValenceList () { return this.atomType.getValenceList() }\n getOuterShellElectronCount () { return this.atomType.getOuterShellElectronCount() }\n\n /**\n * Distance to another atom\n * @param {AtomProxy} atom - the other atom\n * @return {Number} the distance\n */\n distanceTo (atom: AtomProxy) {\n const taa = this.atomStore\n const aaa = atom.atomStore\n const ti = this.index\n const ai = atom.index\n const x = taa.x[ ti ] - aaa.x[ ai ]\n const y = taa.y[ ti ] - aaa.y[ ai ]\n const z = taa.z[ ti ] - aaa.z[ ai ]\n const distSquared = x * x + y * y + z * z\n return Math.sqrt(distSquared)\n }\n\n /**\n * If connected to another atom\n * @param {AtomProxy} atom - the other atom\n * @return {Boolean} flag\n */\n connectedTo (atom: AtomProxy) {\n const taa = this.atomStore\n const aaa = atom.atomStore\n const ti = this.index\n const ai = atom.index\n\n if (taa.altloc && aaa.altloc) {\n const ta = taa.altloc[ ti ] // use Uint8 value to compare\n const aa = aaa.altloc[ ai ] // no need to convert to char\n // 0 is the Null character, 32 is the space character\n if (!(ta === 0 || aa === 0 || ta === 32 || aa === 32 || (ta === aa))) return false\n }\n\n const x = taa.x[ ti ] - aaa.x[ ai ]\n const y = taa.y[ ti ] - aaa.y[ ai ]\n const z = taa.z[ ti ] - aaa.z[ ai ]\n\n const distSquared = x * x + y * y + z * z\n\n // if( this.isCg() ) console.log( this.qualifiedName(), Math.sqrt( distSquared ), distSquared )\n if (distSquared < 48.0 && this.isCg()) return true\n\n if (isNaN(distSquared)) return false\n\n const d = this.covalent + atom.covalent\n const d1 = d + 0.3\n const d2 = d - 0.5\n\n return distSquared < (d1 * d1) && distSquared > (d2 * d2)\n }\n\n /**\n * Set atom position from array\n * @param {Array|TypedArray} array - input array\n * @param {Integer} [offset] - the offset\n * @return {AtomProxy} this object\n */\n positionFromArray (array: NumberArray, offset = 0) {\n this.x = array[ offset + 0 ]\n this.y = array[ offset + 1 ]\n this.z = array[ offset + 2 ]\n\n return this\n }\n\n /**\n * Write atom position to array\n * @param {Array|TypedArray} [array] - target array\n * @param {Integer} [offset] - the offset\n * @return {Array|TypedArray} target array\n */\n positionToArray (array: NumberArray = [], offset = 0) {\n const index = this.index\n const atomStore = this.atomStore\n\n array[ offset + 0 ] = atomStore.x[ index ]\n array[ offset + 1 ] = atomStore.y[ index ]\n array[ offset + 2 ] = atomStore.z[ index ]\n\n return array\n }\n\n /**\n * Write atom position to vector\n * @param {Vector3} [v] - target vector\n * @return {Vector3} target vector\n */\n positionToVector3 (v?: Vector3) {\n if (v === undefined) v = new Vector3()\n\n v.x = this.x\n v.y = this.y\n v.z = this.z\n\n return v\n }\n\n /**\n * Set atom position from vector\n * @param {Vector3} v - input vector\n * @return {AtomProxy} this object\n */\n positionFromVector3 (v: Vector3) {\n this.x = v.x\n this.y = v.y\n this.z = v.z\n\n return this\n }\n\n /**\n * Add vector to atom position\n * @param {Vector3} v - input vector\n * @return {AtomProxy} this object\n */\n positionAdd (v: Vector3|AtomProxy) {\n this.x += v.x\n this.y += v.y\n this.z += v.z\n\n return this\n }\n\n /**\n * Subtract vector from atom position\n * @param {Vector3} v - input vector\n * @return {AtomProxy} this object\n */\n positionSub (v: Vector3|AtomProxy) {\n this.x -= v.x\n this.y -= v.y\n this.z -= v.z\n\n return this\n }\n\n /**\n * Get intra group/residue bonds\n * @param {Boolean} firstOnly - immediately return the first connected atomIndex\n * @return {Integer[]|Integer|undefined} connected atomIndices\n */\n getResidueBonds (firstOnly = false) {\n const residueAtomOffset = this.residueAtomOffset\n const relativeIndex = this.index - this.residueAtomOffset\n const bonds = this.residueType.getBonds()! // TODO\n const atomIndices1 = bonds.atomIndices1\n const atomIndices2 = bonds.atomIndices2\n let idx1, idx2, connectedAtomIndex\n let connectedAtomIndices: number[]|undefined\n\n if (!firstOnly) connectedAtomIndices = []\n\n idx1 = atomIndices1.indexOf(relativeIndex)\n while (idx1 !== -1) {\n connectedAtomIndex = atomIndices2[ idx1 ] + residueAtomOffset\n if (connectedAtomIndices) {\n connectedAtomIndices.push(connectedAtomIndex)\n idx1 = atomIndices1.indexOf(relativeIndex, idx1 + 1)\n } else {\n return connectedAtomIndex\n }\n }\n\n idx2 = atomIndices2.indexOf(relativeIndex)\n while (idx2 !== -1) {\n connectedAtomIndex = atomIndices1[ idx2 ] + residueAtomOffset\n if (connectedAtomIndices) {\n connectedAtomIndices.push(connectedAtomIndex)\n idx2 = atomIndices2.indexOf(relativeIndex, idx2 + 1)\n } else {\n return connectedAtomIndex\n }\n }\n\n return connectedAtomIndices\n }\n\n //\n\n qualifiedName (noResname = false) {\n var name = ''\n if (this.resname && !noResname) name += '[' + this.resname + ']'\n if (this.resno !== undefined) name += this.resno\n if (this.inscode) name += '^' + this.inscode\n if (this.chainname) name += ':' + this.chainname\n if (this.atomname) name += '.' + this.atomname\n if (this.altloc) name += '%' + this.altloc\n if (this.structure.modelStore.count > 1) name += '/' + this.modelIndex\n return name\n }\n\n /**\n * Clone object\n * @return {AtomProxy} cloned atom\n */\n clone () {\n return new AtomProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n index: this.index,\n residueIndex: this.residueIndex,\n\n resname: this.resname,\n x: this.x,\n y: this.y,\n z: this.z,\n element: this.element,\n chainname: this.chainname,\n resno: this.resno,\n serial: this.serial,\n vdw: this.vdw,\n covalent: this.covalent,\n hetero: this.hetero,\n bfactor: this.bfactor,\n altloc: this.altloc,\n atomname: this.atomname,\n modelIndex: this.modelIndex\n }\n }\n}\n\nexport default AtomProxy\n","/**\n * @file Kdtree\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { Debug, Log } from '../globals'\nimport _Kdtree from '../utils/kdtree'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\n\nfunction euclideanDistSq(a: number[], b: number[]) {\n const dx = a[0] - b[0]\n const dy = a[1] - b[1]\n const dz = a[2] - b[2]\n return dx * dx + dy * dy + dz * dz\n}\n\nfunction euclideanDist(a: number[], b: number[]) {\n return Math.sqrt(euclideanDistSq(a, b))\n}\n\nconst pointArray = new Float32Array(3)\n\nclass Kdtree {\n points: Float32Array\n atomIndices: Uint32Array\n kdtree: _Kdtree\n\n constructor(structure: Structure|ResidueProxy, useSquaredDist = false) {\n if (Debug) Log.time('Kdtree build')\n\n const metric = useSquaredDist ? euclideanDistSq : euclideanDist\n\n const points = new Float32Array(structure.atomCount * 3)\n const atomIndices = new Uint32Array(structure.atomCount)\n let i = 0\n\n structure.eachAtom(function (ap) {\n points[ i + 0 ] = ap.x\n points[ i + 1 ] = ap.y\n points[ i + 2 ] = ap.z\n atomIndices[ i / 3 ] = ap.index\n i += 3\n })\n\n this.atomIndices = atomIndices\n this.points = points\n this.kdtree = new _Kdtree(points, metric)\n\n if (Debug) Log.timeEnd('Kdtree build')\n\n // console.log(\"this.kdtree.verify()\", this.kdtree.verify())\n }\n\n nearest (point: number[]|Vector3, maxNodes: number, maxDistance: number) {\n // Log.time( \"Kdtree nearest\" );\n\n if (point instanceof Vector3) {\n point.toArray(pointArray as any)\n } else if (point instanceof AtomProxy) {\n point.positionToArray(pointArray)\n }\n\n const nodeList = this.kdtree.nearest(pointArray, maxNodes, maxDistance)\n\n const indices = this.kdtree.indices\n const nodes = this.kdtree.nodes\n const atomIndices = this.atomIndices\n const resultList = []\n\n for (let i = 0, n = nodeList.length; i < n; ++i) {\n const d = nodeList[ i ]\n const nodeIndex = d[ 0 ]\n const dist = d[ 1 ]\n\n resultList.push({\n index: atomIndices[ indices[ nodes[ nodeIndex ] ] ],\n distance: dist\n })\n }\n\n // Log.timeEnd( \"Kdtree nearest\" );\n\n return resultList\n }\n}\n\nexport default Kdtree\n","/**\n * @file Symmetry Constants\n * @author Alexander Rose \n * @private\n */\n\nexport const SymOpCode: { [k: string]: string } = {\n ' ': 'X',\n '!': 'Y',\n '#': 'Z',\n '$': '-X',\n '%': '-Y',\n '&': '-Z',\n \"'\": 'Y+1/2',\n '(': '1/2+X',\n ')': '1/2+Y',\n '*': '1/2-X',\n '+': '1/2+Z',\n ',': '1/2-Y',\n '-': '1/2-Z',\n '.': 'X+1/2',\n '/': 'Z+1/2',\n '0': '-X+1/2',\n '1': '-Y+1/2',\n '2': '-Z+1/2',\n '3': '1/4+X',\n '4': '1/4-Y',\n '5': '1/4+Z',\n '6': '1/4-X',\n '7': '1/4+Y',\n '8': '3/4-Y',\n '9': '3/4+Z',\n ':': '3/4+Y',\n ';': '3/4+X',\n '<': '3/4-X',\n '=': '1/4-Z',\n '>': '3/4-Z',\n '?': 'X-Y',\n '@': 'Y-X',\n 'A': 'Z+1/3',\n 'B': 'Z+2/3',\n 'C': 'X+2/3',\n 'D': 'Y+1/3',\n 'E': '-Y+2/3',\n 'F': 'X-Y+1/3',\n 'G': 'Y-X+2/3',\n 'H': '-X+1/3',\n 'I': 'X+1/3',\n 'J': 'Y+2/3',\n 'K': '-Y+1/3',\n 'L': 'X-Y+2/3',\n 'M': 'Y-X+1/3',\n 'N': '-X+2/3',\n 'O': '2/3+X',\n 'P': '1/3+Y',\n 'Q': '1/3+Z',\n 'R': '2/3-Y',\n 'S': '1/3+X-Y',\n 'T': '2/3+Y-X',\n 'U': '1/3-X',\n 'V': '2/3-X',\n 'W': '1/3-Y',\n 'X': '1/3-Z',\n 'Y': '2/3+Y',\n 'Z': '1/3+Y-X',\n '[': '2/3+X-Y',\n ']': '1/3+X',\n '^': '2/3+Z',\n '_': '2/3-Z',\n '`': '5/6+Z',\n 'a': '1/6+Z',\n 'b': '5/6-Z',\n 'c': '1/6-Z',\n 'd': 'Z+5/6',\n 'e': 'Z+1/6',\n 'f': 'Z+1/4',\n 'g': '+Y'\n}\n\n// encoded, originally from CCP4 symop.lib\nexport const EncodedSymOp: { [k: string]: string } = {\n 'P 1': ' !#',\n 'P -1': ' !#$%&',\n 'P 1 2 1': ' !#$!&',\n 'P 1 21 1': \" !#$'&\",\n 'C 1 2 1': ' !#$!&()#*)&',\n 'P 1 m 1': ' !# %#',\n 'P 1 c 1': ' !# %+',\n 'C 1 m 1': ' !# %#()#(,#',\n 'C 1 c 1': ' !# %+()#(,+',\n 'P 1 2/m 1': ' !# %#$!&$%&',\n 'P 1 21/m 1': ' !#$)&$%& ,#',\n 'C 1 2/m 1': ' !# %#$!&$%&()#(,#*)&*,&',\n 'P 1 2/c 1': ' !#$!-$%& %+',\n 'P 1 21/c 1': ' !#$%&$)- ,+',\n 'C 1 2/c 1': ' !#$!-$%& %+()#*)-*,&(,+',\n 'P 2 2 2': ' !#$%#$!& %&',\n 'P 2 2 21': ' !#$%+$!- %&',\n 'P 21 21 2': ' !#$%#*)&(,&',\n 'P 21 21 21': ' !#*%+$)-(,&',\n 'C 2 2 21': ' !#$%+$!- %&()#*,+*)-(,&',\n 'C 2 2 2': ' !#$%#$!& %&()#*,#*)&(,&',\n 'F 2 2 2': ' !#$%#$!& %& )+$,+$)- ,-(!+*%+*!-(%-()#*,#*)&(,&',\n 'I 2 2 2': \" !#$%# %&$!&.'/01/.120'2\",\n 'I 21 21 21': ' !#*%+$)-(,&()+$,#*!& %-',\n 'P m m 2': ' !#$%# %#$!#',\n 'P m c 21': ' !#$%+ %+$!#',\n 'P c c 2': ' !#$%# %+$!+',\n 'P m a 2': ' !#$%#(%#*!#',\n 'P c a 21': ' !#$%+(%#*!+',\n 'P n c 2': ' !#$%# ,+$)+',\n 'P m n 21': ' !#*%+(%+$!#',\n 'P b a 2': ' !#$%#(,#*)#',\n 'P n a 21': ' !#$%+(,#*)+',\n 'P n n 2': ' !#$%#(,+*)+',\n 'C m m 2': ' !#$%# %#$!#()#*,#(,#*)#',\n 'C m c 21': ' !#$%+ %+$!#()#*,+(,+*)#',\n 'C c c 2': ' !#$%# %+$!+()#*,#(,+*)+',\n 'A m m 2': ' !#$%# %#$!# )+$,+ ,+$)+',\n 'A b m 2': ' !#$%# ,#$)# )+$,+ %+$!+',\n 'A m a 2': ' !#$%#(%#*!# )+$,+(,+*)+',\n 'A b a 2': ' !#$%#(,#*)# )+$,+(%+*!+',\n 'F m m 2': ' !#$%# %#$!# )+$,+ ,+$)+(!+*%+(%+*!+()#*,#(,#*)#',\n 'F d d 2': ' !#$%#345675 )+$,+3896:9(!+*%+;49<79()#*,#;85<:5',\n 'I m m 2': ' !#$%# %#$!#()+*,+(,+*)+',\n 'I b a 2': ' !#$%#(,#*)#()+*,+ %+$!+',\n 'I m a 2': ' !#$%#(%#*!#()+*,+ ,+$)+',\n 'P 2/m 2/m 2/m': ' !#$%#$!& %&$%& !& %#$!#',\n 'P 2/n 2/n 2/n': ' !#$%#$!& %&*,-()-(,+*)+',\n 'P 2/c 2/c 2/m': ' !#$%#$!- %-$%& !& %+$!+',\n 'P 2/b 2/a 2/n': ' !#$%#$!& %&*,&()&(,#*)#',\n 'P 21/m 2/m 2/a': ' !#*%#$!&(%&$%&(!& %#*!#',\n 'P 2/n 21/n 2/a': ' !#*%#*)- ,-$%&(!&(,+$)+',\n 'P 2/m 2/n 21/a': ' !#*%+*!- %&$%&(!-(%+$!#',\n 'P 21/c 2/c 2/a': ' !#*%#$!-(%-$%&(!& %+*!+',\n 'P 21/b 21/a 2/m': ' !#$%#*)&(,&$%& !&(,#*)#',\n 'P 21/c 21/c 2/n': ' !#*,#$)-(%-$%&()& ,+*!+',\n 'P 2/b 21/c 21/m': ' !#$%+$)- ,&$%& !- ,+$)#',\n 'P 21/n 21/n 2/m': ' !#$%#*)-(,-$%& !&(,+*)+',\n 'P 21/m 21/m 2/n': \" !#$%#*'&.,&*,&.'& %#$!#\",\n 'P 21/b 2/c 21/n': ' !#*,+$!-(,&$%&()- %+*)#',\n 'P 21/b 21/c 21/a': ' !#*%+$)-(,&$%&(!- ,+*)#',\n 'P 21/n 21/m 21/a': \" !#0%/$'&.12$%&.!2 1#0'/\",\n 'C 2/m 2/c 21/m': ' !#$%+$!- %&$%& !- %+$!#()#*,+*)-(,&*,&()-(,+*)#',\n 'C 2/m 2/c 21/a': ' !#$,+$)- %&$%& )- ,+$!#()#*%+*!-(,&*,&(!-(%+*)#',\n 'C 2/m 2/m 2/m': ' !#$%#$!& %&$%& !& %#$!#()#*,#*)&(,&*,&()&(,#*)#',\n 'C 2/c 2/c 2/m': ' !#$%#$!- %-$%& !& %+$!+()#*,#*)-(,-*,&()&(,+*)+',\n 'C 2/m 2/m 2/a': ' !#$,#$)& %&$%& )& ,#$!#()#*%#*!&(,&*,&(!&(%#*)#',\n 'C 2/c 2/c 2/a': ' !#*,#$!&(,&$,-(!- ,+*!+()#$%#*)& %&*%- )-(%+$)+',\n 'F 2/m 2/m 2/m': ' !#$%#$!& %&$%& !& %#$!# )+$,+$)- ,-$,- )- ,+$)+(!+*%+*!-(%-*%-(!-(%+*!+()#*,#*)&(,&*,&()&(,#*)#',\n 'F 2/d 2/d 2/d': ' !#$%#$!& %&64=37=345675 )+$,+$)- ,-68>3:>3896:9(!+*%+*!-(%-<4>;7>;49<79()#*,#*)&(,&<8=;:=;85<:5',\n 'I 2/m 2/m 2/m': ' !#$%#$!& %&$%& !& %#$!#()+*,+*)-(,-*,-()-(,+*)+',\n 'I 2/b 2/a 2/m': ' !#$%#*)&(,&$%& !&(,#*)#()+*,+$!- %-*,-()- %+$!+',\n 'I 21/b 21/c 21/a': ' !#*%+$)-(,&$%&(!- ,+*)#()+$,#*!& %-*,- )&(%#$!+',\n 'I 21/m 21/m 21/a': ' !#$,#$)& %&$%& )& ,#$!#()+*%+*!-(,-*,-(!-(%+*)+',\n 'P 4': ' !#$%#% #!$#',\n 'P 41': ' !#$%+% 5!$9',\n 'P 42': ' !#$%#% +!$+',\n 'P 43': ' !#$%+% 9!$5',\n 'I 4': ' !#$%#% #!$#()+*,+,(+)*+',\n 'I 41': ' !#*,+%(5)$9()+$%#, 9!*5',\n 'P -4': ' !#$%#!$&% &',\n 'I -4': ' !#$%#!$&% &()+*,+)*-,(-',\n 'P 4/m': ' !#$%#% #!$#$%& !&!$&% &',\n 'P 42/m': ' !#$%#% +!$+$%& !&!$-% -',\n 'P 4/n': ' !#$%#,(#)*#*,&()&!$&% &',\n 'P 42/n': ' !#$%#,(+)*+*,-()-!$&% &',\n 'I 4/m': ' !#$%#% #!$#$%& !&!$&% &()+*,+,(+)*+*,-()-)*-,(-',\n 'I 41/a': ' !#*,+%(5)$9$,=(!>!$&,(-()+$%#, 9!*5*%> )=)*-% &',\n 'P 4 2 2': ' !#$%#% #!$#$!& %&! &%$&',\n 'P 4 21 2': ' !#$%#,(#)*#*)&(,&! &%$&',\n 'P 41 2 2': ' !#$%+% 5!$9$!& %-! >%$=',\n 'P 41 21 2': ' !#$%+,(5)*9*)=(,>! &%$-',\n 'P 42 2 2': ' !#$%#% +!$+$!& %&! -%$-',\n 'P 42 21 2': ' !#$%#,(+)*+*)-(,-! &%$&',\n 'P 43 2 2': ' !#$%+% 9!$5$!& %-! =%$>',\n 'P 43 21 2': ' !#$%+,(9)*5*)>(,=! &%$-',\n 'I 4 2 2': ' !#$%#% #!$#$!& %&! &%$&()+*,+,(+)*+*)-(,-)(-,*-',\n 'I 41 2 2': ' !#*,+%(5)$9*!> ,=)(-%$&()+$%#, 9!*5$)=(%>! &,*-',\n 'P 4 m m': ' !#$%#% #!$# %#$!#%$#! #',\n 'P 4 b m': ' !#$%#% #!$#(,#*)#,*#)(#',\n 'P 42 c m': ' !#$%#% +!$+ %+$!+%$#! #',\n 'P 42 n m': ' !#$%#,(+)*+(,+*)+%$#! #',\n 'P 4 c c': ' !#$%#% #!$# %+$!+%$+! +',\n 'P 4 n c': ' !#$%#% #!$#(,+*)+,*+)(+',\n 'P 42 m c': ' !#$%#% +!$+ %#$!#%$+! +',\n 'P 42 b c': ' !#$%#% +!$+(,#*)#,*+)(+',\n 'I 4 m m': ' !#$%#% #!$# %#$!#%$#! #()+*,+,(+)*+(,+*)+,*+)(+',\n 'I 4 c m': ' !#$%#% #!$# %+$!+%$+! +()+*,+,(+)*+(,#*)#,*#)(#',\n 'I 41 m d': ' !#*,+%(5)$9 %#*)+%*5) 9()+$%#, 9!*5(,+$!#,$9!(5',\n 'I 41 c d': ' !#*,+%(5)$9 %+*)#%*9) 5()+$%#, 9!*5(,#$!+,$5!(9',\n 'P -4 2 m': ' !#$%#% &!$&$!& %&%$#! #',\n 'P -4 2 c': ' !#$%#% &!$&$!- %-%$+! +',\n 'P -4 21 m': ' !#$%#% &!$&*)&(,&,*#)(#',\n 'P -4 21 c': ' !#$%#% &!$&*)-(,-,*+)(+',\n 'P -4 m 2': ' !#$%#!$&% & %#$!#! &%$&',\n 'P -4 c 2': ' !#$%#% &!$& %+$!+! -%$-',\n 'P -4 b 2': ' !#$%#% &!$&(,#*)#)(&,*&',\n 'P -4 n 2': ' !#$%#% &!$&(,+*)+)(-,*-',\n 'I -4 m 2': ' !#$%#% &!$& %#$!#! &%$&()+*,+,(-)*-(,+*)+)(-,*-',\n 'I -4 c 2': ' !#$%#% &!$& %+$!+! -%$-()+*,+,(-)*-(,#*)#)(&,*&',\n 'I -4 2 m': ' !#$%#% &!$&$!& %&%$#! #()+*,+,(-)*-*)-(,-,*+)(+',\n 'I -4 2 d': ' !#$%#% &!$&*!>(%>,$9) 9()+*,+,(-)*-$)= ,=%*5!(5',\n 'P 4/m 2/m 2/m': ' !#$%#% #!$#$!& %&! &%$&$%& !&!$&% & %#$!#%$#! #',\n 'P 4/m 2/c 2/c': ' !#$%#% #!$#$!- %-! -%$-$%& !&!$&% & %+$!+%$+! +',\n 'P 4/n 2/b 2/m': ' !#$%#% #!$#$!& %&! &%$&*,&()&)*&,(&(,#*)#,*#)(#',\n 'P 4/n 2/n 2/c': ' !#$%#% #!$#$!& %&! &%$&*,-()-)*-,(-(,+*)+,*+)(+',\n 'P 4/m 21/b 2/m': ' !#$%#% #!$#*)&(,&)(&,*&$%& !&!$&% &(,#*)#,*#)(#',\n 'P 4/m 21/n 2/c': ' !#$%#% #!$#*)-(,-)(-,*-$%& !&!$&% &(,+*)+,*+)(+',\n 'P 4/n 21/m 2/m': ' !#$%#,(#)*#*)&(,&! &%$&*,&()&!$&% & %#$!#,*#)(#',\n 'P 4/n 2/c 2/c': ' !#$%#,(#)*#*)-(,-! -%$-*,&()&!$&% & %+$!+,*+)(+',\n 'P 42/m 2/m 2/c': ' !#$%#% +!$+$!& %&! -%$-$%& !&!$-% - %#$!#%$+! +',\n 'P 42/m 2/c 2/m': ' !#$%#% +!$+$!- %-! &%$&$%& !&!$-% - %+$!+%$#! #',\n 'P 42/n 2/b 2/c': ' !#$%#,(+)*+$!- %-)(&,*&*,-()-!$&% &(,#*)#%$+! +',\n 'P 42/n 2/n 2/m': ' !#$%#,(+)*+$!& %&)(-,*-*,-()-!$&% &(,+*)+%$#! #',\n 'P 42/m 21/b 2/c': ' !#$%#% +!$+*)&(,&)(-,*-$%& !&!$-% -(,#*)#,*+)(+',\n 'P 42/m 21/n 2/m': \" !#$%#,./'*/*'-.,-! &%$&$%& !&'*-,.-.,/*'/%$#! #\",\n 'P 42/n 21/m 2/c': ' !#$%#,(+)*+*)-(,-! &%$&*,-()-!$&% & %#$!#,*+)(+',\n 'P 42/n 21/c 2/m': ' !#$%#,(+)*+*)&(,&! -%$-*,-()-!$&% & %+$!+,*#)(#',\n 'I 4/m 2/m 2/m': ' !#$%#% #!$#$!& %&! &%$&$%& !&!$&% & %#$!#%$#! #()+*,+,(+)*+*)-(,-)(-,*-*,-()-)*-,(-(,+*)+,*+)(+',\n 'I 4/m 2/c 2/m': ' !#$%#% #!$#$!- %-! -%$-$%& !&!$&% & %+$!+%$+! +()+*,+,(+)*+*)&(,&)(&,*&*,-()-)*-,(-(,#*)#,*#)(#',\n 'I 41/a 2/m 2/d': ' !#*,+%(5)$9*!> ,=)(-%$&$,=(!>!$&,(-(,+$!#,$9!(5()+$%#, 9!*5$)=(%>! &,*-*%> )=)*-% & %#*)+%*5) 9',\n 'I 41/a 2/c 2/d': ' !#*,+%(5)$9*!= ,>)(&%$-$,=(!>!$&,(-(,#$!+,$5!(9()+$%#, 9!*5$)>(%=! -,*&*%> )=)*-% & %+*)#%*9) 5',\n 'P 3': ' !#%?#@$#',\n 'P 31': ' !#%?A@$B',\n 'P 32': ' !#%?B@$A',\n 'H 3': ' !#%?#@$#CDAEFAGHAIJBKLBMNB',\n 'R 3': ' !## !!# ',\n 'P -3': ' !#%?#@$#$%&!@&? &',\n 'H -3': ' !#%?#@$#$%&!@&? &OPQRSQTUQVWXYZX[]X]Y^W[^ZV^UR_PT_SO_',\n 'R -3': ' !## !!# $%&&$%%&$',\n 'P 3 1 2': ' !#%?#@$#%$&@!& ?&',\n 'P 3 2 1': ' !#%?#@$#! &?%&$@&',\n 'P 31 1 2': ' !#%?Q@$^%$_@!X ?&',\n 'P 31 2 1': ' !#%?A@$B! &?%_$@X',\n 'P 32 1 2': ' !#%?^@$Q%$X@!_ ?&',\n 'P 32 2 1': ' !#%?B@$A! &?%X$@_',\n 'H 3 2': ' !#%?#@$#! &?%&$@&OPQRSQTUQY]X[WXVZX]Y^W[^ZV^PO_SR_UT_',\n 'R 3 2': ' !## !!# %$&$&%&%$',\n 'P 3 m 1': ' !#%?#@$#%$#@!# ?#',\n 'P 3 1 m': ' !#%?#@$#! #?%#$@#',\n 'P 3 c 1': ' !#%?#@$#%$+@!+ ?+',\n 'P 3 1 c': ' !#%?#@$#! +?%+$@+',\n 'H 3 m': ' !#%?#@$#%$#@!# ?#OPQRSQTUQRUQTPQOSQ]Y^W[^ZV^WV^ZY^][^',\n 'R 3 m': ' !## !!# ! # #!#! ',\n 'H 3 c': ' !#%?#@$#%$+@!+ ?+OPQRSQTUQRU`TP`OS`]Y^W[^ZV^WVaZYa][a',\n 'R 3 c': \" !## !!# '././'/'.\",\n 'P -3 1 2/m': ' !#%?#@$#%$&@!& ?&$%&!@&? &! #?%#$@#',\n 'P -3 1 2/c': ' !#%?#@$#%$-@!- ?-$%&!@&? &! +?%+$@+',\n 'P -3 2/m 1': ' !#%?#@$#! &?%&$@&$%&!@&? &%$#@!# ?#',\n 'P -3 2/c 1': ' !#%?#@$#! -?%-$@-$%&!@&? &%$+@!+ ?+',\n 'H -3 2/m': ' !#%?#@$#! &?%&$@&$%&!@&? &%$#@!# ?#OPQRSQTUQY]X[WXVZXVWXYZX[]XRUQTPQOSQ]Y^W[^ZV^PO_SR_UT_UR_PT_SO_WV^ZY^][^',\n 'R -3 2/m': ' !## !!# %$&$&%&%$$%&&$%%&$! # #!#! ',\n 'H -3 2/c': ' !#%?#@$#! -?%-$@-$%&!@&? &%$+@!+ ?+OPQRSQTUQY]b[WbVZbVWXYZX[]XRU`TP`OS`]Y^W[^ZV^POcSRcUTcUR_PT_SO_WVaZYa][a',\n 'R -3 2/c': \" !## !!# 102021210$%&&$%%&$'././'/'.\",\n 'P 6': ' !#%?#@$#$%#!@#? #',\n 'P 61': ' !#%?A@$B$%/!@d? e',\n 'P 65': ' !#%?B@$A$%/!@e? d',\n 'P 62': ' !#%?^@$Q$%#!@^? Q',\n 'P 64': ' !#%?Q@$^$%#!@Q? ^',\n 'P 63': ' !#%?#@$#$%+!@+? +',\n 'P -6': ' !#%?#@$# !&%?&@$&',\n 'P 6/m': ' !#%?#@$#$%#!@#? #$%&!@&? & !&%?&@$&',\n 'P 63/m': ' !#%?#@$#$%+!@+? +$%&!@&? & !-%?-@$-',\n 'P 6 2 2': ' !#%?#@$#$%#!@#? #! &?%&$@&%$&@!& ?&',\n 'P 61 2 2': ' !#%?Q@$^$%+!@`? a! X?%&$@_%$b@!- ?c',\n 'P 65 2 2': ' !#%?^@$Q$%+!@a? `! _?%&$@X%$c@!- ?b',\n 'P 62 2 2': ' !#%?^@$Q$%#!@^? Q! _?%&$@X%$_@!& ?X',\n 'P 64 2 2': ' !#%?Q@$^$%#!@Q? ^! X?%&$@_%$X@!& ?_',\n 'P 63 2 2': ' !#%?#@$#$%+!@+? +! &?%&$@&%$-@!- ?-',\n 'P 6 m m': ' !#%?#@$#$%#!@#? #%$#@!# ?#! #?%#$@#',\n 'P 6 c c': ' !#%?#@$#$%#!@#? #%$+@!+ ?+! +?%+$@+',\n 'P 63 c m': ' !#%?#@$#$%+!@+? +%$+@!+ ?+! #?%#$@#',\n 'P 63 m c': ' !#%?#@$#$%+!@+? +%$#@!# ?#! +?%+$@+',\n 'P -6 m 2': ' !#%?#@$# !&%?&@$&%$#@!# ?#%$&@!& ?&',\n 'P -6 c 2': ' !#%?#@$# !-%?-@$-%$+@!+ ?+%$&@!& ?&',\n 'P -6 2 m': ' !#%?#@$# !&%?&@$&! &?%&$@&! #?%#$@#',\n 'P -6 2 c': ' !#%?#@$# !-%?-@$-! &?%&$@&! +?%+$@+',\n 'P 6/m 2/m 2/m': ' !#%?#@$#$%#!@#? #! &?%&$@&%$&@!& ?&$%&!@&? & !&@$&%?&%$#@!# ?#! #?%#$@#',\n 'P 6/m 2/c 2/c': ' !#%?#@$#$%#!@#? #! -?%-$@-%$-@!- ?-$%&!@&? & !&@$&%?&%$+@!+ ?+! +?%+$@+',\n 'P 63/m 2/c 2/m': ' !#%?#@$#$%+!@+? +! -?%-$@-%$&@!& ?&$%&!@&? & !-@$-%?-%$+@!+ ?+! #?%#$@#',\n 'P 63/m 2/m 2/c': ' !#%?#@$#$%+!@+? +! &?%&$@&%$-@!- ?-$%&!@&? & !-@$-%?-%$#@!# ?#! +?%+$@+',\n 'P 2 3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ',\n 'F 2 3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ',\n 'I 2 3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-(',\n 'P 21 3': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(',\n 'I 21 3': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- ',\n 'P 2/m -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$',\n 'P 2/n -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& *,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*',\n 'F 2/m -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$ )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-($,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(*%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- *,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$',\n 'F 2/d -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& 64=37=345675=64=375345674=67=3453756 )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(68>3:>3896:9=<8=;:5;85<:4><7>;49;79<(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(<4>;7>;49<79>68>3:93896:8=<:=;85;:5<()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- <8=;:=;8f<:f><4>;79;49<78>6:>3893:96',\n 'I 2/m -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-(*,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*',\n 'P 21/a -3': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&($%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*',\n 'I 21/a -3': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&($%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*()+$,#*g& %-+()#$,&*!- %)+(,#$!&*%- *,- )&(%#$!+-*,& )#(%+$!,-*)& %#(!+$',\n 'P 4 3 2': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$',\n 'P 42 3 2': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*',\n 'F 4 3 2': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$ )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(-%*-!*+%(+ +,$+)$-, -)#)*#,(&)(&,*(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() -,$-)$+, +(#,*#)*&,(&)+!*+%(-!(-%*()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(&,*&)*#,(#(+%*+!*-%(-!+)$+, -) -,$',\n 'F 41 3 2': ' !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=46 )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<(!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>86',\n 'I 4 3 2': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*',\n 'P 43 3 2': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(7;>46=:<5839398<5:6=4;>75:<983>7;=46',\n 'P 41 3 2': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<',\n 'I 41 3 2': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- 7;>46=:<5839398<5:6=4;>75:<983>7;=46',\n 'P -4 3 m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% ',\n 'F -4 3 m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(+%*+!*-%(- +)$+,$-) -,#)(#,*&)*&,((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() +,$+)$-, -(#)*#,*&)(&,+!(+%*-!*-%(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(#,*#)*&,(&(+!*+%*-!(-%+) +,$-)$-, ',\n 'I -4 3 m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,(',\n 'P -4 3 n': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,(',\n 'F -4 3 c': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,( )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-() #,$#)$&, &(#!*#%*&!(&%+! +%$-!$-% (!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(!(#%*#!*&%(& +!$+%$-! -%#) #,$&)$&, ()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ! +%$+!$-% - #)$#,$&) &,#!(#%*&!*&%(',\n 'I -4 3 d': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(7354<9:6>8;=357<946>:;=857394<>:6=8;()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- :;98657<=43>;9:658<=73>49:;586=7<>43',\n 'P 4/m -3 2/m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ',\n 'P 4/n -3 2/n': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$*,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(',\n 'P 42/m -3 2/n': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(',\n 'P 42/n -3 2/m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,**,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ',\n 'F 4/m -3 2/m': ' !#$%#$!& %&# !#$%&$!& %!# %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 )+$%$+! +% -!$-$&) &, #)$#,&%(&!*#%*#!(',\n 'F 41/d -3 2/m': ' !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=4664=3:>;85<79=64>3:5;89<74=6:>385;79<,$+! #%(-)*&*&)(-% #!$+,-%(&)*+,$#! )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<68>37=;49<:5=<8>;753496:4><:=;893756,*#!(+% &)$-*-!(&, +)$#%-, &!$+%*#)((!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<<4>;:=389675>68=379;45<:8=<7>;453:96%$#) +,(&!*-$&! -,(#)*+%&% -)$#,*+!(()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>86<8=;7>3456:9><4=;:9385678>67=349;:5<%*+)(#, -!$&$-) &%(+!*#,&,(-!*#%$+) ',\n 'F 41/d -3 2/c': ' !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=46<8>;7=3496:5><8=;793456:8><7=;493:56%*#)(+, &!$-$-! &,(+)*#%&, -!$#%*+)( )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<<4=;:>385679>64=3:9;85<78=67>345;:9<%$+) #,(-!*&$&) -%(#!*+,&%(-)*#,$+! (!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<68=37>;45<:9=<4>;:5389674>6:=389;75<,*+!(#% -)$&*-)(&% +!$#,-,(&!*+%$#) ()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>8664>3:=;89<75=68>375;49<:4=<:>;853796,$#! +%(&)*-*&!(-, #)$+%-% &)$+,*#!(',\n 'I 4/m -3 2/m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,**,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(',\n 'I 41/a -3 2/d': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<$%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*4<97358;=:6>6>:;=8357<94=8;>:694<573()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- 7;>46=:<5839398<5:6=4;>75:<983>7;=46*,- )&(%#$!+-*,& )#(%+$!,-*)& %#(!+$865:;943>7<=<=73>4;9:658>43=7<5869:;',\n 'P 1 1 2': ' !#$%#',\n 'P 1 1 21': ' !#$%+',\n 'B 1 1 2': ' !#$%#(g+*%+',\n 'A 1 2 1': ' !#$!& )+$)-',\n 'C 1 21 1': ' !#$)&()#*!&',\n 'I 1 2 1': \" !#$!&.'/0'2\",\n 'I 1 21 1': \" !#$)&.'/0!-\",\n 'P 1 1 m': ' !# !&',\n 'P 1 1 b': ' !# )&',\n 'B 1 1 m': ' !# !&(!+(!-',\n 'B 1 1 b': ' !# )&(!+()-',\n 'P 1 1 2/m': ' !# !&$%#$%&',\n 'P 1 1 21/m': ' !#$%+$%& !-',\n 'B 1 1 2/m': ' !# !&$%#$%&(!+(!-*%+*%-',\n 'P 1 1 2/b': ' !#$,#$%& )&',\n 'P 1 1 21/b': ' !#$%&$,+ )-',\n 'B 1 1 2/b': ' !#$,#$%& )&(!+*,+*%-()-',\n 'P 21 2 2': ' !#$!&(%&*%#',\n 'P 2 21 2': ' !# ,&$)&$%#',\n 'P 21 21 2 (a)': \" !#*,#.%&$'&\",\n 'P 21 2 21': ' !#$!&(%-*%+',\n 'P 2 21 21': ' !# %&$)-$,+',\n 'C 2 2 21a)': ' !#*%+(,&$)-()#$,+ %&*!-',\n 'C 2 2 2a': \" !#*,#.%&$'&()#$%# ,&*!&\",\n 'F 2 2 2a': \" !#*,#.%&$'& '/*%/.12$!2.!/$,/ %20'2.'#$%# 1&0!&\",\n 'I 2 2 2a': \" !#*,#.%&$'&()+$%+*!- ,-\",\n 'P 21/m 21/m 2/n a': \" !#*,#$)&(%&$%&.'& ,#*!#\",\n 'P 42 21 2a': \" !#*,#%.+'$+$'&.%&! -,*-\",\n 'I 2 3a': \" !#*,#.%&$'&!# ,- '&$%/$# !-*!/$%&.%()+$%+ ,-*!-)+(%&(!-*,#*+()&$)#*,- ,\"\n}\n","/**\n * @file Symmetry Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Log } from '../globals'\nimport { EncodedSymOp, SymOpCode } from './symmetry-constants'\n\nconst reInteger = /^[1-9]$/\n\nexport function getSymmetryOperations (spacegroup: string) {\n const encodedSymopList = EncodedSymOp[ spacegroup ]\n const matrixDict: { [k: string]: Matrix4 } = {}\n\n if (encodedSymopList === undefined) {\n console.warn(`spacegroup '${spacegroup}' not found in symop library`)\n return matrixDict\n }\n\n const symopList = []\n for (let i = 0, il = encodedSymopList.length; i < il; i += 3) {\n const symop = []\n for (let j = 0; j < 3; ++j) {\n symop.push(SymOpCode[ encodedSymopList[ i + j ] ])\n }\n symopList.push(symop)\n }\n\n symopList.forEach(function (symop) {\n let row = 0\n const matrix = new Matrix4().set(\n 0, 0, 0, 0,\n 0, 0, 0, 0,\n 0, 0, 0, 0,\n 0, 0, 0, 1\n )\n const me = matrix.elements\n\n matrixDict[ symop.toString() ] = matrix\n\n symop.forEach(function (elm) {\n let negate = false\n let denominator = false\n\n for (let i = 0, n = elm.length; i < n; ++i) {\n const c = elm[ i ]\n\n if (c === '-') {\n negate = true\n } else if (c === '+') {\n negate = false\n } else if (c === '/') {\n denominator = true\n } else if (c === 'X') {\n me[ 0 + row ] = negate ? -1 : 1\n } else if (c === 'Y') {\n me[ 4 + row ] = negate ? -1 : 1\n } else if (c === 'Z') {\n me[ 8 + row ] = negate ? -1 : 1\n } else if (reInteger.test(c)) {\n const integer = parseInt(c)\n if (denominator) {\n me[ 12 + row ] /= integer\n } else {\n me[ 12 + row ] = integer\n }\n } else {\n Log.warn(`getSymmetryOperations: unknown token '${c}'`)\n }\n }\n\n row += 1\n })\n })\n\n return matrixDict\n}\n","/**\n * @file Assembly\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Box3, Vector3 } from 'three'\n\nimport { uniqueArray } from '../utils'\nimport Selection from '../selection/selection'\nimport Structure from '../structure/structure'\nimport StructureView from '../structure/structure-view';\n\nfunction selectionFromChains (chainList: string[]) {\n let sele = ''\n if (chainList.length > 0) {\n sele = ':' + uniqueArray(chainList).join(' OR :')\n }\n return new Selection(sele)\n}\n\n/**\n * Assembly of transformed parts of a {@link Structure}\n */\nclass Assembly {\n partList: AssemblyPart[] = []\n\n /**\n * @param {String} name - assembly name\n */\n constructor (readonly name = '') {}\n\n get type () { return 'Assembly' }\n\n /**\n * Add transformed parts to the assembly\n * @example\n * var m1 = new NGL.Matrix4().set( ... );\n * var m2 = new NGL.Matrix4().set( ... );\n * var assembly = new NGL.Assembly( \"myAssembly\" );\n * // add part that transforms chain 'A' and 'B' using matrices `m1` and `m2`\n * assembly.addPart( [ m1, m2 ], [ \"A\", \"B\" ] )\n *\n * @param {Matrix4[]} matrixList - array of 4x4 transformation matrices\n * @param {String[]} chainList - array of chain names\n * @return {AssemblyPart} the added assembly part\n */\n addPart (matrixList?: Matrix4[], chainList?: string[]) {\n const part = new AssemblyPart(matrixList, chainList)\n this.partList.push(part)\n return part\n }\n\n /**\n * Get the number of atom for a given structure\n * @param {Structure} structure - the given structure\n * @return {Integer} number of atoms in the assembly\n */\n getAtomCount (structure: Structure) {\n return this.partList.reduce(\n (count, part) => count + part.getAtomCount(structure), 0\n )\n }\n\n /**\n * Get the number of residues for a given structure\n * @param {Structure} structure - the given structure\n * @return {Integer} number of residues in the assembly\n */\n getResidueCount (structure: Structure) {\n return this.partList.reduce(\n (count, part) => count + part.getResidueCount(structure), 0\n )\n }\n\n /**\n * Get number of instances the assembly will produce, i.e.\n * the number of transformations performed by the assembly\n * @return {Integer} number of instances\n */\n getInstanceCount () {\n let instanceCount = 0\n\n this.partList.forEach(function (part) {\n instanceCount += part.matrixList.length\n })\n\n return instanceCount\n }\n\n /**\n * Determine if the assembly is the full and untransformed structure\n * @param {Structure} structure - the given structure\n * @return {Boolean} whether the assembly is identical to the structure\n */\n isIdentity (structure: Structure) {\n if (this.partList.length !== 1) return false\n\n const part = this.partList[ 0 ]\n if (part.matrixList.length !== 1) return false\n\n const identityMatrix = new Matrix4()\n if (!identityMatrix.equals(part.matrixList[ 0 ])) return false\n\n let structureChainList: string[] = []\n structure.eachChain(function (cp) {\n structureChainList.push(cp.chainname)\n })\n structureChainList = uniqueArray(structureChainList)\n if (part.chainList.length !== structureChainList.length) return false\n\n return true\n }\n\n getBoundingBox (structure: Structure) {\n const boundingBox = new Box3()\n\n this.partList.forEach(function (part) {\n const partBox = part.getBoundingBox(structure)\n boundingBox.expandByPoint(partBox.min)\n boundingBox.expandByPoint(partBox.max)\n })\n\n return boundingBox\n }\n\n getCenter (structure: Structure) {\n return this.getBoundingBox(structure).getCenter(new Vector3())\n }\n\n getSelection () {\n let chainList: string[] = []\n this.partList.forEach(function (part) {\n chainList = chainList.concat(part.chainList)\n })\n return selectionFromChains(chainList)\n }\n}\n\nexport class AssemblyPart {\n constructor (readonly matrixList: Matrix4[] = [], readonly chainList: string[] = []) {}\n\n get type () { return 'AssemblyPart' }\n\n _getCount (structure: Structure, propertyName: 'atomCount'|'residueCount') {\n let count = 0\n\n structure.eachChain(cp => {\n if (this.chainList.length === 0 || this.chainList.includes(cp.chainname)) {\n count += cp[ propertyName ]\n }\n })\n\n return this.matrixList.length * count\n }\n\n getAtomCount (structure: Structure) {\n return this._getCount(structure, 'atomCount')\n }\n\n getResidueCount (structure: Structure) {\n return this._getCount(structure, 'residueCount')\n }\n\n getBoundingBox (structure: Structure) {\n const partBox = new Box3()\n const instanceBox = new Box3()\n\n const selection = this.getSelection()\n const structureBox = structure.getBoundingBox(selection)\n\n this.matrixList.forEach(function (matrix) {\n instanceBox.copy(structureBox).applyMatrix4(matrix)\n partBox.expandByPoint(instanceBox.min)\n partBox.expandByPoint(instanceBox.max)\n })\n\n return partBox\n }\n\n getSelection () {\n return selectionFromChains(this.chainList)\n }\n\n getView (structure: Structure): Structure | StructureView {\n const selection = this.getSelection()\n if (selection) {\n return structure.getView(selection)\n } else {\n return structure\n }\n }\n\n getInstanceList () {\n const instanceList = []\n for (let j = 0, jl = this.matrixList.length; j < jl; ++j) {\n instanceList.push({\n id: j + 1,\n name: j,\n matrix: this.matrixList[ j ]\n })\n }\n return instanceList\n }\n}\n\nexport default Assembly\n","/**\n * @file Structure Builder\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from './structure'\n\nclass StructureBuilder {\n currentModelindex: number|null = null\n currentChainid: string|null = null\n currentResname: string|null = null\n currentResno: number|null = null\n currentInscode: string|undefined = undefined\n currentHetero: boolean|null = null\n\n previousResname: string|null = ''\n previousHetero: boolean|null = null\n\n ai = -1\n ri = -1\n ci = -1\n mi = -1\n\n constructor(readonly structure: Structure) {}\n\n addResidueType (ri: number) {\n const atomStore = this.structure.atomStore\n const residueStore = this.structure.residueStore\n const residueMap = this.structure.residueMap\n\n const count = residueStore.atomCount[ ri ]\n const offset = residueStore.atomOffset[ ri ]\n const atomTypeIdList = new Array(count)\n for (let i = 0; i < count; ++i) {\n atomTypeIdList[ i ] = atomStore.atomTypeId[ offset + i ]\n }\n residueStore.residueTypeId[ ri ] = residueMap.add(\n this.previousResname!, atomTypeIdList, this.previousHetero! // TODO\n )\n }\n\n addAtom (modelindex: number, chainname: string, chainid: string, resname: string, resno: number, hetero: boolean, sstruc?: string|undefined, inscode?: string|undefined) {\n const atomStore = this.structure.atomStore\n const residueStore = this.structure.residueStore\n const chainStore = this.structure.chainStore\n const modelStore = this.structure.modelStore\n\n let addModel = false\n let addChain = false\n let addResidue = false\n\n if (this.currentModelindex !== modelindex) {\n addModel = true\n addChain = true\n addResidue = true\n this.mi += 1\n this.ci += 1\n this.ri += 1\n } else if (this.currentChainid !== chainid) {\n addChain = true\n addResidue = true\n this.ci += 1\n this.ri += 1\n } else if (this.currentResno !== resno || this.currentResname !== resname || this.currentInscode !== inscode) {\n addResidue = true\n this.ri += 1\n }\n this.ai += 1\n\n if (addModel) {\n modelStore.growIfFull()\n modelStore.chainOffset[ this.mi ] = this.ci\n modelStore.chainCount[ this.mi ] = 0\n modelStore.count += 1\n chainStore.modelIndex[ this.ci ] = this.mi\n }\n\n if (addChain) {\n chainStore.growIfFull()\n chainStore.setChainname(this.ci, chainname)\n chainStore.setChainid(this.ci, chainid)\n chainStore.residueOffset[ this.ci ] = this.ri\n chainStore.residueCount[ this.ci ] = 0\n chainStore.count += 1\n chainStore.modelIndex[ this.ci ] = this.mi\n modelStore.chainCount[ this.mi ] += 1\n residueStore.chainIndex[ this.ri ] = this.ci\n }\n\n if (addResidue) {\n this.previousResname = this.currentResname\n this.previousHetero = this.currentHetero\n if (this.ri > 0) this.addResidueType(this.ri - 1)\n residueStore.growIfFull()\n residueStore.resno[ this.ri ] = resno\n if (sstruc !== undefined) {\n residueStore.sstruc[ this.ri ] = sstruc.charCodeAt(0)\n }\n if (inscode !== undefined) {\n residueStore.inscode[ this.ri ] = inscode.charCodeAt(0)\n }\n residueStore.atomOffset[ this.ri ] = this.ai\n residueStore.atomCount[ this.ri ] = 0\n residueStore.count += 1\n residueStore.chainIndex[ this.ri ] = this.ci\n chainStore.residueCount[ this.ci ] += 1\n }\n\n atomStore.count += 1\n atomStore.residueIndex[ this.ai ] = this.ri\n residueStore.atomCount[ this.ri ] += 1\n\n this.currentModelindex = modelindex\n this.currentChainid = chainid\n this.currentResname = resname\n this.currentResno = resno\n this.currentInscode = inscode\n this.currentHetero = hetero\n }\n\n finalize () {\n this.previousResname = this.currentResname\n this.previousHetero = this.currentHetero\n if (this.ri > -1) this.addResidueType(this.ri)\n }\n}\n\nexport default StructureBuilder\n","/**\n * @file Structure Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4 } from 'three'\n\nimport { Debug, Log } from '../globals'\nimport { binarySearchIndexOf } from '../utils'\nimport Helixbundle from '../geometry/helixbundle'\nimport Kdtree from '../geometry/kdtree'\nimport { getSymmetryOperations } from '../symmetry/symmetry-utils'\nimport Assembly from '../symmetry/assembly'\nimport Structure from '../structure/structure'\nimport StructureBuilder from '../structure/structure-builder'\nimport Polymer from '../proxy/polymer'\nimport ResidueProxy from '../proxy/residue-proxy'\n\nimport { UnknownBackboneType, AA3, Bases, AtomicNumbers } from './structure-constants'\n\nexport function reorderAtoms (structure: Structure) {\n if (Debug) Log.time('reorderAtoms')\n\n var ap1 = structure.getAtomProxy()\n var ap2 = structure.getAtomProxy()\n\n function compareModelChainResno (index1: number, index2: number) {\n ap1.index = index1\n ap2.index = index2\n if (ap1.modelIndex < ap2.modelIndex) {\n return -1\n } else if (ap1.modelIndex > ap2.modelIndex) {\n return 1\n } else {\n if (ap1.chainname < ap2.chainname) {\n return -1\n } else if (ap1.chainname > ap2.chainname) {\n return 1\n } else {\n if (ap1.resno < ap2.resno) {\n return -1\n } else if (ap1.resno > ap2.resno) {\n return 1\n } else {\n return 0\n }\n }\n }\n }\n\n structure.atomStore.sort(compareModelChainResno)\n\n if (Debug) Log.timeEnd('reorderAtoms')\n}\n\nexport interface SecStruct {\n helices: [string, number, string, string, number, string, number][]\n sheets: [string, number, string, string, number, string][]\n}\n\nexport function assignSecondaryStructure (structure: Structure, secStruct: SecStruct) {\n if (!secStruct) return\n\n if (Debug) Log.time('assignSecondaryStructure')\n\n const chainnames: string[] = []\n structure.eachModel(function (mp) {\n mp.eachChain(function (cp) {\n chainnames.push(cp.chainname)\n })\n })\n\n const chainnamesSorted = chainnames.slice().sort()\n const chainnamesIndex: number[] = []\n chainnamesSorted.forEach(function (c) {\n chainnamesIndex.push(chainnames.indexOf(c))\n })\n\n // helix assignment\n\n const helices = secStruct.helices.filter(function (h) {\n return binarySearchIndexOf(chainnamesSorted, h[ 0 ]) >= 0\n })\n\n helices.sort(function (h1, h2) {\n const c1 = h1[ 0 ]\n const c2 = h2[ 0 ]\n const r1 = h1[ 1 ]\n const r2 = h2[ 1 ]\n\n if (c1 === c2) {\n if (r1 === r2) {\n return 0\n } else {\n return r1 < r2 ? -1 : 1\n }\n } else {\n const idx1 = binarySearchIndexOf(chainnamesSorted, c1)\n const idx2 = binarySearchIndexOf(chainnamesSorted, c2)\n return chainnamesIndex[ idx1 ] < chainnamesIndex[ idx2 ] ? -1 : 1\n }\n })\n\n const residueStore = structure.residueStore\n\n structure.eachModel(function (mp) {\n let i = 0\n const n = helices.length\n if (n === 0) return\n let helix = helices[ i ]\n let helixRun = false\n let done = false\n\n mp.eachChain(function (cp) {\n let chainChange = false\n\n if (cp.chainname === helix[ 0 ]) {\n const count = cp.residueCount\n const offset = cp.residueOffset\n const end = offset + count\n\n for (let j = offset; j < end; ++j) {\n if (residueStore.resno[ j ] === helix[ 1 ] && // resnoBeg\n residueStore.getInscode(j) === helix[ 2 ] // inscodeBeg\n ) {\n helixRun = true\n }\n\n if (helixRun) {\n residueStore.sstruc[ j ] = helix[ 6 ]\n\n if (residueStore.resno[ j ] === helix[ 4 ] && // resnoEnd\n residueStore.getInscode(j) === helix[ 5 ] // inscodeEnd\n ) {\n helixRun = false\n i += 1\n\n if (i < n) {\n // must look at previous residues as\n // residues may not be ordered by resno\n j = offset - 1\n helix = helices[ i ]\n chainChange = cp.chainname !== helix[ 0 ]\n } else {\n done = true\n }\n }\n }\n\n if (chainChange || done) return\n }\n }\n })\n })\n\n // sheet assignment\n\n const sheets = secStruct.sheets.filter(function (s) {\n return binarySearchIndexOf(chainnamesSorted, s[ 0 ]) >= 0\n })\n\n sheets.sort(function (s1, s2) {\n const c1 = s1[ 0 ]\n const c2 = s2[ 0 ]\n\n if (c1 === c2) return 0\n const idx1 = binarySearchIndexOf(chainnamesSorted, c1)\n const idx2 = binarySearchIndexOf(chainnamesSorted, c2)\n return chainnamesIndex[ idx1 ] < chainnamesIndex[ idx2 ] ? -1 : 1\n })\n\n const strandCharCode = 'e'.charCodeAt(0)\n structure.eachModel(function (mp) {\n let i = 0\n const n = sheets.length\n if (n === 0) return\n let sheet = sheets[ i ]\n let sheetRun = false\n let done = false\n\n mp.eachChain(function (cp) {\n let chainChange = false\n\n if (cp.chainname === sheet[ 0 ]) {\n const count = cp.residueCount\n const offset = cp.residueOffset\n const end = offset + count\n\n for (let j = offset; j < end; ++j) {\n if (residueStore.resno[ j ] === sheet[ 1 ] && // resnoBeg\n residueStore.getInscode(j) === sheet[ 2 ] // inscodeBeg\n ) {\n sheetRun = true\n }\n\n if (sheetRun) {\n residueStore.sstruc[ j ] = strandCharCode\n\n if (residueStore.resno[ j ] === sheet[ 4 ] && // resnoEnd\n residueStore.getInscode(j) === sheet[ 5 ] // inscodeEnd\n ) {\n sheetRun = false\n i += 1\n\n if (i < n) {\n // must look at previous residues as\n // residues may not be ordered by resno\n j = offset - 1\n sheet = sheets[ i ]\n chainChange = cp.chainname !== sheet[ 0 ]\n } else {\n done = true\n }\n }\n }\n\n if (chainChange || done) return\n }\n }\n })\n })\n\n if (Debug) Log.timeEnd('assignSecondaryStructure')\n}\n\nexport const calculateSecondaryStructure = (function () {\n // Implementation for proteins based on \"pv\"\n //\n // assigns secondary structure information based on a simple and very fast\n // algorithm published by Zhang and Skolnick in their TM-align paper.\n // Reference:\n //\n // TM-align: a protein structure alignment algorithm based on the Tm-score\n // (2005) NAR, 33(7) 2302-2309\n\n const zhangSkolnickSS = function (polymer: Polymer, i: number, distances: number[], delta: number) {\n const structure = polymer.structure\n const offset = polymer.residueIndexStart\n const rp1 = structure.getResidueProxy()\n const rp2 = structure.getResidueProxy()\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n for (let j = Math.max(0, i - 2); j <= i; ++j) {\n for (let k = 2; k < 5; ++k) {\n if (j + k >= polymer.residueCount) {\n continue\n }\n\n rp1.index = offset + j\n rp2.index = offset + j + k\n ap1.index = rp1.traceAtomIndex\n ap2.index = rp2.traceAtomIndex\n\n const d = ap1.distanceTo(ap2)\n\n if (Math.abs(d - distances[ k - 2 ]) > delta) {\n return false\n }\n }\n }\n\n return true\n }\n\n const isHelical = function (polymer: Polymer, i: number) {\n const helixDistances = [ 5.45, 5.18, 6.37 ]\n const helixDelta = 2.1\n return zhangSkolnickSS(polymer, i, helixDistances, helixDelta)\n }\n\n const isSheet = function (polymer: Polymer, i: number) {\n const sheetDistances = [ 6.1, 10.4, 13.0 ]\n const sheetDelta = 1.42\n return zhangSkolnickSS(polymer, i, sheetDistances, sheetDelta)\n }\n\n const proteinPolymer = function (p: Polymer) {\n const residueStore = p.residueStore\n const offset = p.residueIndexStart\n for (let i = 0, il = p.residueCount; i < il; ++i) {\n let sstruc = 'c'\n if (isHelical(p, i)) {\n sstruc = 'h'\n } else if (isSheet(p, i)) {\n sstruc = 'e'\n }\n residueStore.sstruc[ offset + i ] = sstruc.charCodeAt(0)\n }\n }\n\n const cgPolymer = function (p: Polymer) {\n const localAngle = 20\n const centerDist = 2.0\n\n const residueStore = p.residueStore\n const offset = p.residueIndexStart\n\n const helixbundle = new Helixbundle(p)\n const pos = helixbundle.position\n\n const c1 = new Vector3()\n const c2 = new Vector3()\n\n for (let i = 0, il = p.residueCount; i < il; ++i) {\n c1.fromArray(pos.center as any, i * 3) // TODO\n c2.fromArray(pos.center as any, i * 3 + 3) // TODO\n const d = c1.distanceTo(c2)\n\n if (d < centerDist && d > 1.0 && pos.bending[ i ] < localAngle) {\n residueStore.sstruc[ offset + i ] = 'h'.charCodeAt(0)\n residueStore.sstruc[ offset + i + 1 ] = 'h'.charCodeAt(0)\n }\n }\n }\n\n return function calculateSecondaryStructure (structure: Structure) {\n if (Debug) Log.time('calculateSecondaryStructure')\n\n structure.eachPolymer(function (p) {\n // assign secondary structure\n if (p.residueCount < 4) return\n if (p.isCg()) {\n cgPolymer(p)\n } else if (p.isProtein()) {\n proteinPolymer(p)\n } else {\n return\n }\n\n // set lone secondary structure assignments to \"c\"\n let prevSstruc: string\n let sstrucCount = 0\n p.eachResidue(function (r: ResidueProxy) {\n if (r.sstruc === prevSstruc) {\n sstrucCount += 1\n } else {\n if (sstrucCount === 1) {\n r.index -= 1\n r.sstruc = 'c'\n }\n sstrucCount = 1\n prevSstruc = r.sstruc\n }\n })\n })\n\n if (Debug) Log.timeEnd('calculateSecondaryStructure')\n }\n}())\n\n// const ChainnameAlphabet = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\" +\n// \"abcdefghijklmnopqrstuvwxyz\" +\n// \"0123456789\";\nconst ChainnameAlphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\n\nexport function getChainname (index: number) {\n const n = ChainnameAlphabet.length\n let j = index\n let k = 0\n let chainname = ChainnameAlphabet[j % n]\n while (j >= n) {\n j = Math.floor(j / n)\n chainname += ChainnameAlphabet[j % n]\n k += 1\n }\n if (k >= 5) {\n Log.warn('chainname overflow')\n }\n return chainname\n}\n\ninterface ChainData {\n mIndex: number\n chainname: string\n rStart: number\n rCount: number\n}\n\n/**\n * When no chain names are set for the given structure, calculates\n * chains based on:\n * - polymer connectivity: when adjacent residues are not bonded, a new chain is created.\n * - non polymer chemical type: adjacent residues which are not polymers but are of the same\n * chemical type (e.g. water molecules) are grouped into the same chain.\n **/\nexport function calculateChainnames (structure: Structure, useExistingBonds = false) {\n if (Debug) Log.time('calculateChainnames')\n\n let doAutoChainName = true\n structure.eachChain(function (c) {\n if (c.chainname) doAutoChainName = false\n })\n\n if (doAutoChainName) {\n const modelStore = structure.modelStore\n const chainStore = structure.chainStore\n const residueStore = structure.residueStore\n\n const addChain = function (mIndex: number, chainname: string, rOffset: number, rCount: number) {\n const ci = chainStore.count\n for (let i = 0; i < rCount; ++i) {\n residueStore.chainIndex[ rOffset + i ] = ci\n }\n chainStore.growIfFull()\n chainStore.modelIndex[ ci ] = mIndex\n chainStore.setChainname(ci, chainname)\n chainStore.setChainid(ci, chainname)\n chainStore.residueOffset[ ci ] = rOffset\n chainStore.residueCount[ ci ] = rCount\n chainStore.count += 1\n modelStore.chainCount[ mIndex ] += 1\n }\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n let i = 0\n let mi = 0\n let rStart = 0\n let rEnd = 0\n const chainData: ChainData[] = []\n\n if (residueStore.count === 1) {\n chainData.push({\n mIndex: 0,\n chainname: 'A',\n rStart: 0,\n rCount: 1\n })\n } else {\n structure.eachResidueN(2, function (rp1: ResidueProxy, rp2: ResidueProxy) {\n let newChain = false\n\n const bbType1 = rp1.backboneType\n const bbType2 = rp2.backboneType\n const bbTypeUnk = UnknownBackboneType\n\n rEnd = rp1.index\n\n if (rp1.modelIndex !== rp2.modelIndex) {\n newChain = true\n } else if (rp1.moleculeType !== rp2.moleculeType) {\n newChain = true\n } else if (bbType1 !== bbTypeUnk && bbType1 === bbType2) {\n ap1.index = rp1.backboneEndAtomIndex\n ap2.index = rp2.backboneStartAtomIndex\n if (useExistingBonds) {\n newChain = !ap1.hasBondTo(ap2)\n } else {\n newChain = !ap1.connectedTo(ap2)\n }\n }\n\n // current chain goes to end of the structure\n if (!newChain && rp2.index === residueStore.count - 1) {\n newChain = true\n rEnd = rp2.index\n }\n\n if (newChain) {\n chainData.push({\n mIndex: mi,\n chainname: getChainname(i),\n rStart: rStart,\n rCount: rEnd - rStart + 1\n })\n\n i += 1\n\n if (rp1.modelIndex !== rp2.modelIndex) {\n i = 0\n mi += 1\n }\n\n // new chain for the last residue of the structure\n if (rp2.index === residueStore.count - 1 && rEnd !== rp2.index) {\n chainData.push({\n mIndex: mi,\n chainname: getChainname(i),\n rStart: residueStore.count - 1,\n rCount: 1\n })\n }\n\n rStart = rp2.index\n rEnd = rp2.index\n }\n })\n }\n\n //\n\n chainStore.count = 0\n modelStore.chainCount.fill(0, 0, modelStore.count)\n modelStore.chainOffset.fill(0, 0, modelStore.count)\n chainData.forEach(function (d) {\n addChain(d.mIndex, d.chainname, d.rStart, d.rCount)\n })\n\n let chainOffset = 0\n structure.eachModel(function (mp) {\n modelStore.chainOffset[ mp.index ] = chainOffset\n chainOffset += modelStore.chainCount[ mp.index ]\n })\n }\n\n if (Debug) Log.timeEnd('calculateChainnames')\n}\n\nexport function calculateBonds (structure: Structure, inferBonds: InferBondsOptions='all') {\n if (inferBonds === 'none') return \n if (Debug) Log.time('calculateBonds')\n\n calculateBondsWithin(structure, false, inferBonds)\n calculateBondsBetween(structure)\n\n if (Debug) Log.timeEnd('calculateBonds')\n}\n\n/**\n * Should Bonds be inferred for `all` atoms, `none` or `auto`\n * If `auto`, any hetgroup residue with at least one CONECT record will \n * not have bonding inferred, and will rely on the CONECT records\n */\nexport type InferBondsOptions = 'all' | 'none' | 'auto'\n\nexport interface ResidueBonds {\n atomIndices1: number[]\n atomIndices2: number[]\n bondOrders: number[]\n}\n\n\nconst BondOrderTable: { [k: string]: number } = {\n 'HIS|CD2|CG': 2,\n 'HIS|CE1|ND1': 2,\n 'ARG|CZ|NH2': 2,\n 'PHE|CE1|CZ': 2,\n 'PHE|CD2|CE2': 2,\n 'PHE|CD1|CG': 2,\n 'TRP|CD1|CG': 2,\n 'TRP|CD2|CE2': 2,\n 'TRP|CE3|CZ3': 2,\n 'TRP|CH2|CZ2': 2,\n 'ASN|CG|OD1': 2,\n 'GLN|CD|OE1': 2,\n 'TYR|CD1|CG': 2,\n 'TYR|CD2|CE2': 2,\n 'TYR|CE1|CZ': 2,\n 'ASP|CG|OD1': 2,\n 'GLU|CD|OE1': 2,\n\n 'G|C8|N7': 2,\n 'G|C4|C5': 2,\n 'G|C2|N3': 2,\n 'G|C6|O6': 2,\n 'C|C4|N3': 2,\n 'C|C5|C6': 2,\n 'C|C2|O2': 2,\n 'A|C2|N3': 2,\n 'A|C6|N1': 2,\n 'A|C4|C5': 2,\n 'A|C8|N7': 2,\n 'U|C5|C6': 2,\n 'U|C2|O2': 2,\n 'U|C4|O4': 2,\n\n 'DG|C8|N7': 2,\n 'DG|C4|C5': 2,\n 'DG|C2|N3': 2,\n 'DG|C6|O6': 2,\n 'DC|C4|N3': 2,\n 'DC|C5|C6': 2,\n 'DC|C2|O2': 2,\n 'DA|C2|N3': 2,\n 'DA|C6|N1': 2,\n 'DA|C4|C5': 2,\n 'DA|C8|N7': 2,\n 'DT|C5|C6': 2,\n 'DT|C2|O2': 2,\n 'DT|C4|O4': 2\n}\nfunction getBondOrderFromTable (resname: string, atomname1: string, atomname2: string) {\n [ atomname1, atomname2 ] = atomname1 < atomname2 ? [ atomname1, atomname2 ] : [ atomname2, atomname1 ]\n if (AA3.includes(resname) && atomname1 === 'C' && atomname2 === 'O') return 2\n if (Bases.includes(resname) && atomname1 === 'OP1' && atomname2 === 'P') return 2\n return BondOrderTable[ `${resname}|${atomname1}|${atomname2}` ] || 1\n}\n\nexport function calculateResidueBonds (r: ResidueProxy) {\n const structure = r.structure\n const a1 = structure.getAtomProxy()\n const a2 = structure.getAtomProxy()\n\n const count = r.atomCount\n const offset = r.atomOffset\n const end = offset + count\n const end1 = end - 1\n\n const atomIndices1 = []\n const atomIndices2 = []\n const bondOrders = []\n\n if (count > 500) {\n if (Debug) Log.warn('more than 500 atoms, skip residue for auto-bonding', r.qualifiedName())\n } else {\n if (count > 50) {\n const kdtree = new Kdtree(r, true)\n const radius = r.isCg() ? 1.2 : 2.3\n\n for (let i = offset; i < end1; ++i) {\n a1.index = i\n const maxd = a1.covalent + radius + 0.3\n const nearestAtoms = kdtree.nearest(a1 as any, Infinity, maxd * maxd) // TODO\n const m = nearestAtoms.length\n for (let j = 0; j < m; ++j) {\n a2.index = nearestAtoms[ j ].index\n if (a1.index < a2.index) {\n if (a1.connectedTo(a2)) {\n atomIndices1.push(a1.index - offset)\n atomIndices2.push(a2.index - offset)\n bondOrders.push(getBondOrderFromTable(a1.resname, a1.atomname, a2.atomname))\n }\n }\n }\n }\n } else {\n for (let i = offset; i < end1; ++i) {\n a1.index = i\n for (let j = i + 1; j <= end1; ++j) {\n a2.index = j\n if (a1.connectedTo(a2)) {\n atomIndices1.push(i - offset)\n atomIndices2.push(j - offset)\n bondOrders.push(getBondOrderFromTable(a1.resname, a1.atomname, a2.atomname))\n }\n }\n }\n }\n }\n\n return {\n atomIndices1: atomIndices1,\n atomIndices2: atomIndices2,\n bondOrders: bondOrders\n }\n}\n\nexport function calculateAtomBondMap (structure: Structure) {\n if (Debug) Log.time('calculateAtomBondMap')\n\n var atomBondMap: number[][] = []\n\n structure.eachBond(function (bp) {\n var ai1 = bp.atomIndex1\n var ai2 = bp.atomIndex2\n if (atomBondMap[ ai1 ] === undefined) atomBondMap[ ai1 ] = []\n atomBondMap[ ai1 ][ ai2 ] = bp.index\n })\n\n if (Debug) Log.timeEnd('calculateAtomBondMap')\n\n return atomBondMap\n}\n\nexport function calculateBondsWithin (structure: Structure, onlyAddRung = false, inferBonds: InferBondsOptions='all') {\n if (Debug) Log.time('calculateBondsWithin')\n\n const bondStore = structure.bondStore\n const rungBondStore = structure.rungBondStore\n const rungAtomSet = structure.getAtomSet(false)\n const a1 = structure.getAtomProxy()\n const a2 = structure.getAtomProxy()\n const bp = structure.getBondProxy()\n const atomBondMap = onlyAddRung ? null : calculateAtomBondMap(structure)\n\n let bondedAtoms: Set\n if (!onlyAddRung && inferBonds === 'auto') {\n bondedAtoms = new Set()\n atomBondMap!.forEach((a, i) => {\n bondedAtoms.add(i)\n a.forEach(j => {bondedAtoms.add(j)})\n })\n }\n\n structure.eachResidue(function (r) {\n if (!onlyAddRung && atomBondMap) {\n const count = r.atomCount\n const offset = r.atomOffset\n\n if (count > 500) {\n Log.warn('more than 500 atoms, skip residue for auto-bonding', r.qualifiedName())\n return\n }\n\n if (inferBonds === 'auto' && r.hetero) {\n // Are bonds present on this residue?\n for (let rai=r.atomOffset; rai {\n ncsMatrixList.forEach(nm => {\n ncsUnitcellMatrixList.push(sm.clone().multiply(nm))\n })\n })\n unitcellAssembly.addPart(ncsUnitcellMatrixList)\n } else {\n unitcellAssembly.addPart(unitcellMatrixList)\n }\n\n const vec = new Vector3()\n const supercellAssembly = new Assembly('SUPERCELL')\n const supercellMatrixList = Array.prototype.concat.call(\n getMatrixList(vec.set(1, 0, 0)), // 655\n getMatrixList(vec.set(0, 1, 0)), // 565\n getMatrixList(vec.set(0, 0, 1)), // 556\n\n getMatrixList(vec.set(-1, 0, 0)), // 455\n getMatrixList(vec.set(0, -1, 0)), // 545\n getMatrixList(vec.set(0, 0, -1)), // 554\n\n getMatrixList(vec.set(1, 1, 0)), // 665\n getMatrixList(vec.set(1, 0, 1)), // 656\n getMatrixList(vec.set(0, 1, 1)), // 566\n\n getMatrixList(vec.set(-1, -1, 0)), // 445\n getMatrixList(vec.set(-1, 0, -1)), // 454\n getMatrixList(vec.set(0, -1, -1)), // 544\n\n getMatrixList(vec.set(1, -1, -1)), // 644\n getMatrixList(vec.set(1, 1, -1)), // 664\n getMatrixList(vec.set(1, -1, 1)), // 646\n getMatrixList(vec.set(-1, 1, 1)), // 466\n getMatrixList(vec.set(-1, -1, 1)), // 446\n getMatrixList(vec.set(-1, 1, -1)), // 464\n\n getMatrixList(vec.set(0, 1, -1)), // 564\n getMatrixList(vec.set(0, -1, 1)), // 546\n getMatrixList(vec.set(1, 0, -1)), // 654\n getMatrixList(vec.set(-1, 0, 1)), // 456\n getMatrixList(vec.set(1, -1, 0)), // 645\n getMatrixList(vec.set(-1, 1, 0)), // 465\n\n getMatrixList(), // 555\n getMatrixList(vec.set(1, 1, 1)), // 666\n getMatrixList(vec.set(-1, -1, -1)) // 444\n )\n if (structure.biomolDict.NCS) {\n const ncsSupercellMatrixList: Matrix4[] = []\n supercellMatrixList.forEach(function (sm: Matrix4) {\n ncsMatrixList.forEach(function (nm) {\n ncsSupercellMatrixList.push(sm.clone().multiply(nm))\n })\n })\n supercellAssembly.addPart(ncsSupercellMatrixList)\n } else {\n supercellAssembly.addPart(supercellMatrixList)\n }\n\n structure.biomolDict.UNITCELL = unitcellAssembly\n structure.biomolDict.SUPERCELL = supercellAssembly\n\n if (Debug) Log.timeEnd('buildUnitcellAssembly')\n}\n\nconst elm1 = [ 'H', 'C', 'O', 'N', 'S', 'P' ]\nconst elm2 = [ 'NA', 'CL', 'FE' ]\n\nexport function guessElement (atomName: string) {\n // Retain first group of letters in atomName\n let at = atomName.toUpperCase()\n let begin = 0, end = 0\n for (let i = 0; i < at.length ; i++) {\n if (at.charCodeAt(i) < 65) {\n if (end > 0) break\n ++begin\n }\n else end = i + 1\n }\n if (begin > 0 || end < at.length) at = at.substring(begin, end)\n \n const n = at.length\n\n if (n === 0) return ''\n if (n === 1) return at\n if (n === 2) {\n if (elm2.indexOf(at) !== -1) return at\n if (elm1.indexOf(at[0]) !== -1) return at[0]\n if (at in AtomicNumbers) return at\n }\n if (n >= 3) {\n if (elm1.indexOf(at[0]) !== -1) return at[0]\n }\n return ''\n}\n\n/**\n * Assigns ResidueType bonds.\n * @param {Structure} structure - the structure object\n * @return {undefined}\n */\nexport function assignResidueTypeBonds (structure: Structure) {\n // if( Debug ) Log.time( \"assignResidueTypeBonds\" )\n\n const bondHash = structure.bondHash! // TODO\n const countArray = bondHash.countArray\n const offsetArray = bondHash.offsetArray\n const indexArray = bondHash.indexArray\n const bp = structure.getBondProxy()\n\n structure.eachResidue(function (rp) {\n const residueType = rp.residueType\n if (residueType.bonds !== undefined) return\n\n var atomOffset = rp.atomOffset\n var atomIndices1: number[] = []\n var atomIndices2: number[] = []\n var bondOrders: number[] = []\n var bondDict: { [k: string]: boolean } = {}\n\n const nextAtomOffset = atomOffset + rp.atomCount\n\n rp.eachAtom(function (ap) {\n const index = ap.index\n const offset = offsetArray[ index ]\n const count = countArray[ index ]\n for (let i = 0, il = count; i < il; ++i) {\n bp.index = indexArray[ offset + i ]\n let idx1 = bp.atomIndex1\n if (idx1 < atomOffset || idx1 >= nextAtomOffset) {\n // Don't add bonds outside of this resiude\n continue\n }\n let idx2 = bp.atomIndex2\n if (idx2 < atomOffset || idx2 >= nextAtomOffset) {\n continue\n }\n\n if (idx1 > idx2) {\n const tmp = idx2\n idx2 = idx1\n idx1 = tmp\n }\n const hash = idx1 + '|' + idx2\n if (bondDict[ hash ] === undefined) {\n bondDict[ hash ] = true\n atomIndices1.push(idx1 - atomOffset)\n atomIndices2.push(idx2 - atomOffset)\n bondOrders.push(bp.bondOrder)\n }\n }\n })\n\n residueType.bonds = {\n atomIndices1: atomIndices1,\n atomIndices2: atomIndices2,\n bondOrders: bondOrders\n }\n })\n\n // if( Debug ) Log.timeEnd( \"assignResidueTypeBonds\" )\n}\n\nexport function concatStructures (name: string, ...structures: Structure[]) {\n if( Debug ) Log.time( \"concatStructures\" )\n\n const s = new Structure(name, '')\n const sb = new StructureBuilder(s)\n\n const atomStore = s.atomStore as any\n const atomMap = s.atomMap\n atomStore.addField('formalCharge', 1, 'int8')\n atomStore.addField('partialCharge', 1, 'float32')\n\n const atomIndexDict: { [k: number]: number } = {}\n\n let idx = 0\n let atomCount = 0\n let modelCount = 0\n structures.forEach(structure => {\n structure.eachAtom(a => {\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(a.atomname, a.element)\n\n atomStore.x[ idx ] = a.x\n atomStore.y[ idx ] = a.y\n atomStore.z[ idx ] = a.z\n atomStore.serial[ idx ] = a.serial\n atomStore.formalCharge[ idx ] = a.formalCharge\n atomStore.partialCharge[ idx ] = a.partialCharge\n atomStore.altloc[ idx ] = a.altloc\n atomStore.occupancy[ idx ] = a.occupancy\n atomStore.bfactor[ idx ] = a.bfactor\n\n sb.addAtom(\n a.modelIndex + modelCount,\n a.chainname,\n a.chainid,\n a.resname,\n a.resno,\n a.hetero === 1,\n a.sstruc,\n a.inscode\n )\n\n atomIndexDict[a.index + atomCount] = idx\n idx += 1\n })\n atomCount += structure.atomStore.count\n modelCount += structure.modelStore.count\n })\n\n const bondStore = s.bondStore\n const a1 = s.getAtomProxy()\n const a2 = s.getAtomProxy()\n\n atomCount = 0\n structures.forEach(structure => {\n structure.eachBond(b => {\n a1.index = atomIndexDict[ b.atomIndex1 + atomCount ]\n a2.index = atomIndexDict[ b.atomIndex2 + atomCount ]\n bondStore.addBond(a1, a2, b.bondOrder)\n })\n atomCount += structure.atomStore.count\n })\n\n sb.finalize()\n\n calculateBondsBetween(s, true) // calculate backbone bonds\n calculateBondsWithin(s, true) // calculate rung bonds\n\n s.finalizeAtoms()\n s.finalizeBonds()\n assignResidueTypeBonds(s)\n\n if( Debug ) Log.timeEnd( \"concatStructures\" )\n\n return s\n}\n","/**\n * @file Atom Type\n * @author Alexander Rose \n * @private\n */\n\nimport { guessElement } from '../structure/structure-utils'\nimport {\n AtomicNumbers, DefaultAtomicNumber,\n VdwRadii, DefaultVdwRadius,\n CovalentRadii, DefaultCovalentRadius,\n Valences, DefaultValence,\n OuterShellElectronCounts, DefaultOuterShellElectronCount\n} from '../structure/structure-constants'\nimport Structure from '../structure/structure'\n\n// Li, Na, K, Rb, Cs Fr\nconst AlkaliMetals = [ 3, 11, 19, 37, 55, 87 ]\n\n// Be, Mg, Ca, Sr, Ba, Ra\nconst AlkalineEarthMetals = [ 4, 12, 20, 38, 56, 88 ]\n\n// C, P, S, Se\nconst PolyatomicNonmetals = [ 6, 15, 16, 34, ]\n\n// H, N, O, F, Cl, Br, I\nconst DiatomicNonmetals = [ 1, 7, 8, 9, 17, 35, 53 ]\n\n// He, Ne, Ar, Kr, Xe, Rn\nconst NobleGases = [ 2, 10, 18, 36, 54, 86 ]\n\n// Zn, Ga, Cd, In, Sn, Hg, Ti, Pb, Bi, Po, Cn\nconst PostTransitionMetals = [ 13, 30, 31, 48, 49, 50, 80, 81, 82, 83, 84, 85, 112 ]\n\n// B, Si, Ge, As, Sb, Te, At\nconst Metalloids = [ 5, 14, 32, 33, 51, 52, 85 ]\n\n// F, Cl, Br, I, At\nconst Halogens = [ 9, 17, 35, 53, 85 ]\n\n/**\n * Atom type\n */\nclass AtomType {\n element: string\n number: number\n vdw: number\n covalent: number\n\n /**\n * @param {Structure} structure - the structure object\n * @param {String} atomname - the name of the atom\n * @param {String} element - the chemical element\n */\n constructor (readonly structure: Structure, readonly atomname: string, element?: string) {\n element = element || guessElement(atomname)\n\n this.element = element\n this.number = AtomicNumbers[ element ] || DefaultAtomicNumber\n this.vdw = VdwRadii[ this.number ] || DefaultVdwRadius\n this.covalent = CovalentRadii[ this.number ] || DefaultCovalentRadius\n }\n\n getDefaultValence() {\n const vl = Valences[ this.number ]\n return vl ? vl[ 0 ] : DefaultValence\n }\n\n getValenceList () {\n return Valences[ this.number ] || []\n }\n\n getOuterShellElectronCount () {\n return OuterShellElectronCounts[ this.number ] || DefaultOuterShellElectronCount\n }\n\n isMetal () {\n return (\n this.isAlkaliMetal() ||\n this.isAlkalineEarthMetal() ||\n this.isLanthanide() ||\n this.isActinide() ||\n this.isTransitionMetal() ||\n this.isPostTransitionMetal()\n )\n }\n\n isNonmetal () {\n return (\n this.isDiatomicNonmetal() ||\n this.isPolyatomicNonmetal() ||\n this.isNobleGas()\n )\n }\n\n isMetalloid () {\n return Metalloids.includes(this.number)\n }\n\n isHalogen () {\n return Halogens.includes(this.number)\n }\n\n isDiatomicNonmetal () {\n return DiatomicNonmetals.includes(this.number)\n }\n\n isPolyatomicNonmetal () {\n return PolyatomicNonmetals.includes(this.number)\n }\n\n isAlkaliMetal () {\n return AlkaliMetals.includes(this.number)\n }\n\n isAlkalineEarthMetal () {\n return AlkalineEarthMetals.includes(this.number)\n }\n\n isNobleGas () {\n return NobleGases.includes(this.number)\n }\n\n isTransitionMetal () {\n const no = this.number\n return (\n (no >= 21 && no <= 29) ||\n (no >= 39 && no <= 47) ||\n (no >= 72 && no <= 79) ||\n (no >= 104 && no <= 108)\n )\n }\n\n isPostTransitionMetal () {\n return PostTransitionMetals.includes(this.number)\n }\n\n isLanthanide () {\n return this.number >= 57 && this.number <= 71\n }\n\n isActinide () {\n return this.number >= 89 && this.number <= 103\n }\n\n}\n\nexport default AtomType","/**\n * @file Atom Map\n * @author Alexander Rose \n * @private\n */\n\nimport AtomType from './atom-type'\nimport { guessElement } from '../structure/structure-utils'\nimport Structure from '../structure/structure'\n\nfunction getHash (atomname: string, element: string) {\n return atomname + '|' + element\n}\n\nclass AtomMap {\n dict: { [k: string]: number } = {}\n list: AtomType[] = []\n\n constructor (readonly structure: Structure) {\n this.structure = structure\n }\n\n add (atomname: string, element?: string) {\n atomname = atomname.toUpperCase()\n if (!element) {\n element = guessElement(atomname)\n } else {\n element = element.toUpperCase()\n }\n const hash = getHash(atomname, element)\n let id = this.dict[ hash ]\n if (id === undefined) {\n const atomType = new AtomType(this.structure, atomname, element)\n id = this.list.length\n this.dict[ hash ] = id\n this.list.push(atomType)\n }\n return id\n }\n\n get (id: number) {\n return this.list[ id ]\n }\n}\n\nexport default AtomMap\n","/**\n * @file Residue Type\n * @author Alexander Rose \n * @author Fred Ludlow\n * @private\n */\n\nimport { defaults } from '../utils'\nimport PrincipalAxes from '../math/principal-axes'\nimport { Matrix } from '../math/matrix-utils'\nimport { calculateResidueBonds, ResidueBonds } from '../structure/structure-utils'\nimport {\n Elements,\n ProteinType, RnaType, DnaType, WaterType, IonType, SaccharideType, UnknownType,\n ProteinBackboneType, RnaBackboneType, DnaBackboneType, UnknownBackboneType,\n CgProteinBackboneType, CgRnaBackboneType, CgDnaBackboneType,\n ChemCompProtein, ChemCompRna, ChemCompDna, ChemCompSaccharide,\n AA3, PurinBases, RnaBases, DnaBases, Bases, IonNames, WaterNames, SaccharideNames,\n ProteinBackboneAtoms, NucleicBackboneAtoms, ResidueTypeAtoms\n} from '../structure/structure-constants'\nimport Structure from '../structure/structure'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\n\nexport interface BondGraph {\n [k: number]: number[]\n}\n\nexport interface RingData {\n atomRings: number[][] // sparse array:\n // atomRings[atomIdx] -> array of ring indices\n rings: number[][] // rings as arrays of indices\n}\n\n/**\n * Residue type\n */\nexport default class ResidueType {\n resname: string\n atomTypeIdList: number[]\n hetero: number\n chemCompType: string\n bonds?: ResidueBonds\n rings?: RingData\n bondGraph?: BondGraph\n aromaticAtoms?: Uint8Array\n aromaticRings?: number[][]\n\n atomCount: number\n\n moleculeType: number\n backboneType: number\n backboneEndType: number\n backboneStartType: number\n backboneIndexList: number[]\n\n traceAtomIndex: number\n direction1AtomIndex: number\n direction2AtomIndex: number\n backboneStartAtomIndex: number\n backboneEndAtomIndex: number\n rungEndAtomIndex: number\n\n // Sparse array containing the reference atom index for each bond.\n bondReferenceAtomIndices: number[] = []\n\n /**\n * @param {Structure} structure - the structure object\n * @param {String} resname - name of the residue\n * @param {Array} atomTypeIdList - list of IDs of {@link AtomType}s corresponding\n * to the atoms of the residue\n * @param {Boolean} hetero - hetero flag\n * @param {String} chemCompType - chemical component type\n * @param {Object} [bonds] - TODO\n */\n constructor (readonly structure: Structure, resname: string, atomTypeIdList: number[], hetero: boolean, chemCompType: string, bonds?: ResidueBonds) {\n this.resname = resname\n this.atomTypeIdList = atomTypeIdList\n this.hetero = hetero ? 1 : 0\n this.chemCompType = chemCompType\n this.bonds = bonds\n this.atomCount = atomTypeIdList.length\n\n this.moleculeType = this.getMoleculeType()\n this.backboneType = this.getBackboneType(0)\n this.backboneEndType = this.getBackboneType(-1)\n this.backboneStartType = this.getBackboneType(1)\n this.backboneIndexList = this.getBackboneIndexList()\n\n const atomnames = ResidueTypeAtoms[ this.backboneType ]\n const atomnamesStart = ResidueTypeAtoms[ this.backboneStartType ]\n const atomnamesEnd = ResidueTypeAtoms[ this.backboneEndType ]\n\n const traceIndex = this.getAtomIndexByName(atomnames.trace)\n this.traceAtomIndex = defaults(traceIndex, -1)\n\n const dir1Index = this.getAtomIndexByName(atomnames.direction1)\n this.direction1AtomIndex = defaults(dir1Index, -1)\n\n const dir2Index = this.getAtomIndexByName(atomnames.direction2)\n this.direction2AtomIndex = defaults(dir2Index, -1)\n\n const bbStartIndex = this.getAtomIndexByName(atomnamesStart.backboneStart)\n this.backboneStartAtomIndex = defaults(bbStartIndex, -1)\n\n const bbEndIndex = this.getAtomIndexByName(atomnamesEnd.backboneEnd)\n this.backboneEndAtomIndex = defaults(bbEndIndex, -1)\n\n let rungEndIndex\n if (PurinBases.includes(resname)) {\n rungEndIndex = this.getAtomIndexByName('N1')\n } else {\n rungEndIndex = this.getAtomIndexByName('N3')\n }\n this.rungEndAtomIndex = defaults(rungEndIndex, -1)\n }\n\n getBackboneIndexList () {\n const backboneIndexList: number[] = []\n let atomnameList\n switch (this.moleculeType) {\n case ProteinType:\n atomnameList = ProteinBackboneAtoms\n break\n case RnaType:\n case DnaType:\n atomnameList = NucleicBackboneAtoms\n break\n default:\n return backboneIndexList\n }\n const atomMap = this.structure.atomMap\n const atomTypeIdList = this.atomTypeIdList\n for (let i = 0, il = this.atomCount; i < il; ++i) {\n const atomType = atomMap.get(atomTypeIdList[ i ])\n if (atomnameList.includes(atomType.atomname)) {\n backboneIndexList.push(i)\n }\n }\n return backboneIndexList\n }\n\n getMoleculeType () {\n if (this.isProtein()) {\n return ProteinType\n } else if (this.isRna()) {\n return RnaType\n } else if (this.isDna()) {\n return DnaType\n } else if (this.isWater()) {\n return WaterType\n } else if (this.isIon()) {\n return IonType\n } else if (this.isSaccharide()) {\n return SaccharideType\n } else {\n return UnknownType\n }\n }\n\n getBackboneType (position: number) {\n if (this.hasProteinBackbone(position)) {\n return ProteinBackboneType\n } else if (this.hasRnaBackbone(position)) {\n return RnaBackboneType\n } else if (this.hasDnaBackbone(position)) {\n return DnaBackboneType\n } else if (this.hasCgProteinBackbone(position)) {\n return CgProteinBackboneType\n } else if (this.hasCgRnaBackbone(position)) {\n return CgRnaBackboneType\n } else if (this.hasCgDnaBackbone(position)) {\n return CgDnaBackboneType\n } else {\n return UnknownBackboneType\n }\n }\n\n isProtein () {\n if (this.chemCompType) {\n return ChemCompProtein.includes(this.chemCompType)\n } else {\n return (\n this.hasAtomWithName('CA', 'C', 'N') ||\n AA3.includes(this.resname)\n )\n }\n }\n\n isCg () {\n const backboneType = this.backboneType\n return (\n backboneType === CgProteinBackboneType ||\n backboneType === CgRnaBackboneType ||\n backboneType === CgDnaBackboneType\n )\n }\n\n isNucleic () {\n return this.isRna() || this.isDna()\n }\n\n isRna () {\n if (this.chemCompType) {\n return ChemCompRna.includes(this.chemCompType)\n } else if (this.hetero === 1) {\n return false\n } else {\n return (\n this.hasAtomWithName(\n [ 'P', \"O3'\", 'O3*' ], [ \"C4'\", 'C4*' ], [ \"O2'\", 'O2*', \"F2'\", 'F2*' ]\n ) ||\n (RnaBases.includes(this.resname) &&\n (this.hasAtomWithName([ \"O2'\", 'O2*', \"F2'\", 'F2*' ])))\n )\n }\n }\n\n isDna () {\n if (this.chemCompType) {\n return ChemCompDna.includes(this.chemCompType)\n } else if (this.hetero === 1) {\n return false\n } else {\n return (\n (this.hasAtomWithName([ 'P', \"O3'\", 'O3*' ], [ \"C3'\", 'C3*' ]) &&\n !this.hasAtomWithName([ \"O2'\", 'O2*', \"F2'\", 'F2*' ])) ||\n DnaBases.includes(this.resname)\n )\n }\n }\n\n isHetero () {\n return this.hetero === 1\n }\n\n isIon () {\n return IonNames.includes(this.resname)\n }\n\n isWater () {\n return WaterNames.includes(this.resname)\n }\n\n isSaccharide () {\n if (this.chemCompType) {\n return ChemCompSaccharide.includes(this.chemCompType)\n } else {\n return SaccharideNames.includes(this.resname)\n }\n }\n\n isStandardAminoacid () {\n return AA3.includes(this.resname)\n }\n\n isStandardBase () {\n return Bases.includes(this.resname)\n }\n\n hasBackboneAtoms (position: number, type: number) {\n const atomnames = ResidueTypeAtoms[ type ]\n if (position === -1) {\n return this.hasAtomWithName(\n atomnames.trace,\n atomnames.backboneEnd,\n atomnames.direction1,\n atomnames.direction2\n )\n } else if (position === 0) {\n return this.hasAtomWithName(\n atomnames.trace,\n atomnames.direction1,\n atomnames.direction2\n )\n } else if (position === 1) {\n return this.hasAtomWithName(\n atomnames.trace,\n atomnames.backboneStart,\n atomnames.direction1,\n atomnames.direction2\n )\n } else {\n return this.hasAtomWithName(\n atomnames.trace,\n atomnames.backboneStart,\n atomnames.backboneEnd,\n atomnames.direction1,\n atomnames.direction2\n )\n }\n }\n\n hasProteinBackbone (position: number) {\n return (\n this.isProtein() &&\n this.hasBackboneAtoms(position, ProteinBackboneType)\n )\n }\n\n hasRnaBackbone (position: number) {\n return (\n this.isRna() &&\n this.hasBackboneAtoms(position, RnaBackboneType)\n )\n }\n\n hasDnaBackbone (position: number) {\n return (\n this.isDna() &&\n this.hasBackboneAtoms(position, DnaBackboneType)\n )\n }\n\n hasCgProteinBackbone (position: number) {\n return (\n this.atomCount < 7 &&\n this.isProtein() &&\n this.hasBackboneAtoms(position, CgProteinBackboneType)\n )\n }\n\n hasCgRnaBackbone (position: number) {\n return (\n this.atomCount < 11 &&\n this.isRna() &&\n this.hasBackboneAtoms(position, CgRnaBackboneType)\n )\n }\n\n hasCgDnaBackbone (position: number) {\n return (\n this.atomCount < 11 &&\n this.isDna() &&\n this.hasBackboneAtoms(position, CgDnaBackboneType)\n )\n }\n\n hasBackbone (position: number) {\n return (\n this.hasProteinBackbone(position) ||\n this.hasRnaBackbone(position) ||\n this.hasDnaBackbone(position) ||\n this.hasCgProteinBackbone(position) ||\n this.hasCgRnaBackbone(position) ||\n this.hasCgDnaBackbone(position)\n )\n }\n\n getAtomIndexByName (atomname: string|string[]) {\n const n = this.atomCount\n const atomMap = this.structure.atomMap\n const atomTypeIdList = this.atomTypeIdList\n if (Array.isArray(atomname)) {\n for (let i = 0; i < n; ++i) {\n const index = atomTypeIdList[ i ]\n if (atomname.includes(atomMap.get(index).atomname)) {\n return i\n }\n }\n } else {\n for (let i = 0; i < n; ++i) {\n const index = atomTypeIdList[ i ]\n if (atomname === atomMap.get(index).atomname) {\n return i\n }\n }\n }\n return undefined\n }\n\n hasAtomWithName (...atomnames: (string|string[])[]) {\n const n = atomnames.length\n for (let i = 0; i < n; ++i) {\n if (atomnames[ i ] === undefined) continue\n if (this.getAtomIndexByName(atomnames[ i ]) === undefined) {\n return false\n }\n }\n return true\n }\n\n getBonds (r?: ResidueProxy) {\n if (this.bonds === undefined) {\n this.bonds = calculateResidueBonds(r!) // TODO\n }\n return this.bonds\n }\n\n getRings () {\n if (this.rings === undefined) {\n this.calculateRings()\n }\n return this.rings\n }\n\n getBondGraph () {\n if (this.bondGraph === undefined) {\n this.calculateBondGraph()\n }\n return this.bondGraph\n }\n\n getAromatic (a?: AtomProxy) {\n if (this.aromaticAtoms === undefined) {\n this.calculateAromatic(this.structure.getResidueProxy((a!).residueIndex)) // TODO\n }\n return this.aromaticAtoms\n }\n\n getAromaticRings (r?: ResidueProxy) {\n if (this.aromaticRings === undefined) {\n this.calculateAromatic(r!) // TODO\n }\n return this.aromaticRings\n }\n\n /**\n * @return {Object} bondGraph - represents the bonding in this\n * residue: { ai1: [ ai2, ai3, ...], ...}\n */\n calculateBondGraph () {\n const bondGraph: BondGraph = this.bondGraph = {}\n const bonds = this.getBonds()\n const nb = bonds.atomIndices1.length\n const atomIndices1 = bonds.atomIndices1\n const atomIndices2 = bonds.atomIndices2\n\n for (let i = 0; i < nb; ++i) {\n const ai1 = atomIndices1[i]\n const ai2 = atomIndices2[i]\n\n const a1 = bondGraph[ ai1 ] = bondGraph[ ai1 ] || []\n a1.push(ai2)\n\n const a2 = bondGraph[ ai2 ] = bondGraph[ ai2 ] || []\n a2.push(ai1)\n }\n }\n\n /**\n * Find all rings up to 2 * RingFinderMaxDepth\n */\n calculateRings () {\n const bondGraph = this.getBondGraph()! // TODO\n const state = RingFinderState(bondGraph, this.atomCount)\n\n for (let i = 0; i < state.count; i++) {\n if (state.visited[i] >= 0) continue\n findRings(state, i)\n }\n\n this.rings = { atomRings: state.atomRings, rings: state.rings }\n }\n\n isAromatic (atom: AtomProxy) {\n this.aromaticAtoms = this.getAromatic(atom)! // TODO\n return this.aromaticAtoms[atom.index - atom.residueAtomOffset] === 1\n }\n\n calculateAromatic (r: ResidueProxy) {\n const aromaticAtoms = this.aromaticAtoms = new Uint8Array(this.atomCount)\n const rings = this.getRings()!.rings\n\n const aromaticRingFlags = rings.map(ring => {\n return isRingAromatic(ring.map(idx => {\n return this.structure.getAtomProxy(idx + r.atomOffset)\n }))\n })\n\n const aromaticRings: number[][] = this.aromaticRings = []\n rings.forEach((ring, i) => {\n if (aromaticRingFlags[i]) {\n aromaticRings.push(ring)\n ring.forEach(idx => aromaticAtoms[idx] = 1)\n }\n })\n }\n\n /**\n * For bonds with order > 1, pick a reference atom\n * @return {undefined}\n */\n assignBondReferenceAtomIndices () {\n const bondGraph = this.getBondGraph()! // TODO\n const rings = this.getRings()! // TODO\n const atomRings = rings.atomRings\n const ringData = rings.rings\n\n const bonds = this.bonds! // TODO\n const atomIndices1 = bonds.atomIndices1\n const atomIndices2 = bonds.atomIndices2\n const bondOrders = bonds.bondOrders\n const bondReferenceAtomIndices = this.bondReferenceAtomIndices\n\n const nb = bonds.atomIndices1.length\n\n bondReferenceAtomIndices.length = 0 // reset array\n\n for (let i = 0; i < nb; ++i) {\n // Not required for single bonds\n if (bondOrders[i] <= 1) continue\n\n let refRing\n\n const ai1 = atomIndices1[i]\n const ai2 = atomIndices2[i]\n\n const rings1 = atomRings[ ai1 ]\n const rings2 = atomRings[ ai2 ]\n // Are both atoms in a ring?\n if (rings1 && rings2) {\n // Are they in the same ring? (If not, ignore ring info)\n for (let ri1 = 0; ri1 < rings1.length; ri1++){\n if (rings2.indexOf(rings1[ ri1 ]) !== -1) {\n refRing = ringData[ rings1[ ri1 ] ]\n break\n }\n }\n }\n\n // Find the first neighbour.\n if (bondGraph[ ai1 ].length > 1) {\n for (let j = 0; j < bondGraph[ ai1 ].length; ++j) {\n const ai3 = bondGraph[ ai1 ][ j ]\n if (ai3 !== ai2) {\n if (refRing === undefined || refRing.indexOf(ai3) !== -1){\n bondReferenceAtomIndices[i] = ai3\n break\n }\n }\n }\n } else if (bondGraph[ ai2 ].length > 1) {\n for (let j = 0; j < bondGraph[ ai2 ].length; ++j) {\n const ai3 = bondGraph[ ai2 ][ j ]\n if (ai3 !== ai1) {\n if (refRing === undefined || refRing.indexOf(ai3) !== -1){\n bondReferenceAtomIndices[i] = ai3\n break\n }\n }\n }\n } // No reference atom could be found (e.g. diatomic molecule/fragment)\n }\n }\n\n getBondIndex (atomIndex1: number, atomIndex2: number) {\n const bonds = this.bonds! // TODO\n const atomIndices1 = bonds.atomIndices1\n const atomIndices2 = bonds.atomIndices2\n let idx1 = atomIndices1.indexOf(atomIndex1)\n let idx2 = atomIndices2.indexOf(atomIndex2)\n const _idx2 = idx2\n while (idx1 !== -1) {\n while (idx2 !== -1) {\n if (idx1 === idx2) return idx1\n idx2 = atomIndices2.indexOf(atomIndex2, idx2 + 1)\n }\n idx1 = atomIndices1.indexOf(atomIndex1, idx1 + 1)\n idx2 = _idx2\n }\n // returns undefined when no bond is found\n }\n\n getBondReferenceAtomIndex (atomIndex1: number, atomIndex2: number) {\n const bondIndex = this.getBondIndex(atomIndex1, atomIndex2)\n if (bondIndex === undefined) return undefined\n if (this.bondReferenceAtomIndices.length === 0) {\n this.assignBondReferenceAtomIndices()\n }\n return this.bondReferenceAtomIndices[ bondIndex ]\n }\n}\n\n//\n\nconst AromaticRingElements = [\n Elements.B, Elements.C, Elements.N, Elements.O,\n Elements.SI, Elements.P, Elements.S,\n Elements.GE, Elements.AS,\n Elements.SN, Elements.SB,\n Elements.BI\n]\nconst AromaticRingPlanarityThreshold = 0.05\n\nfunction isRingAromatic (ring: AtomProxy[]) {\n if (ring.some(a => !AromaticRingElements.includes(a.number))) return false\n\n let i = 0\n const coords = new Matrix(3, ring.length)\n const cd = coords.data\n\n ring.forEach(a => {\n cd[ i + 0 ] = a.x\n cd[ i + 1 ] = a.y\n cd[ i + 2 ] = a.z\n i += 3\n })\n\n const pa = new PrincipalAxes(coords)\n\n return pa.vecC.length() < AromaticRingPlanarityThreshold\n}\n\n//\n\n/**\n * Ring finding code below adapted from MolQL\n * Copyright (c) 2017 MolQL contributors, licensed under MIT\n * @author David Sehnal \n */\n\nfunction addRing(state: RingFinderState, a: number, b: number) {\n // only \"monotonous\" rings\n if (b < a) return\n\n const { pred, color, left, right } = state\n const nc = ++state.currentColor\n\n let current = a\n\n for (let t = 0; t < RingFinderMaxDepth; t++) {\n color[current] = nc\n current = pred[current]\n if (current < 0) break\n }\n\n let leftOffset = 0\n let rightOffset = 0\n\n let found = false\n let target = 0\n current = b\n for (let t = 0; t < RingFinderMaxDepth; t++) {\n if (color[current] === nc) {\n target = current\n found = true\n break\n }\n right[rightOffset++] = current\n current = pred[current]\n if (current < 0) break\n }\n if (!found) return\n\n current = a\n for (let t = 0; t < RingFinderMaxDepth; t++) {\n left[leftOffset++] = current\n if (target === current) break\n current = pred[current]\n if (current < 0) break\n }\n\n const rn = leftOffset + rightOffset\n const ring: number[] = new Array(rn)\n let ringOffset = 0;\n for (let t = 0; t < leftOffset; t++) {\n ring[ringOffset++] = left[t]\n }\n for (let t = rightOffset - 1; t >= 0; t--) {\n ring[ringOffset++] = right[t]\n }\n\n const ri = state.rings.length\n // set atomRing indices:\n for (let i = 0; i < rn; ++i) {\n const ai = ring[i]\n if (state.atomRings[ai]) {\n state.atomRings[ai].push(ri)\n } else {\n state.atomRings[ai] = [ri]\n }\n }\n\n state.rings.push(ring)\n}\n\nfunction findRings(state: RingFinderState, from: number) {\n const { bonds, visited, queue, pred } = state\n\n visited[from] = 1\n queue[0] = from\n\n let head = 0\n let size = 1\n\n while (head < size) {\n const top = queue[head++]\n const start = 0\n if (bonds[top] === undefined) {\n continue\n }\n const end = bonds[top].length\n\n for (let i = start; i < end; i++) {\n const other = bonds[top][i]\n\n if (visited[other] > 0) {\n if (pred[other] !== top && pred[top] !== other) {\n addRing(state, top, other)\n }\n continue\n }\n\n visited[other] = 1\n queue[size++] = other\n pred[other] = top\n }\n }\n}\n\nconst RingFinderMaxDepth = 4\n\ninterface RingFinderState {\n count: number,\n visited: Int32Array,\n queue: Int32Array,\n color: Int32Array,\n pred: Int32Array,\n\n left: Int32Array,\n right: Int32Array,\n\n currentColor: number,\n\n rings: number[][],\n atomRings: number[][],\n\n bonds: BondGraph\n}\n\nfunction RingFinderState(bonds: BondGraph, capacity: number): RingFinderState {\n const state = {\n count: capacity,\n visited: new Int32Array(capacity),\n queue: new Int32Array(capacity),\n pred: new Int32Array(capacity),\n left: new Int32Array(RingFinderMaxDepth),\n right: new Int32Array(RingFinderMaxDepth),\n color: new Int32Array(capacity),\n currentColor: 0,\n rings: [],\n atomRings: [],\n bonds\n }\n for (let i = 0; i < capacity; i++) {\n state.visited[i] = -1\n state.pred[i] = -1\n }\n return state\n}\n","/**\n * @file Residue Map\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport { ResidueBonds } from '../structure/structure-utils'\nimport ResidueType from './residue-type'\n\nfunction getHash (resname: string, atomTypeIdList: number[], hetero: boolean, chemCompType = '') {\n return (\n resname + '|' +\n atomTypeIdList.join(',') + '|' +\n (hetero ? 1 : 0) + '|' +\n chemCompType\n )\n}\n\nclass ResidueMap {\n dict: { [k: string]: number } = {}\n list: ResidueType[] = []\n\n constructor (readonly structure: Structure) {}\n\n add (resname: string, atomTypeIdList: number[], hetero: boolean, chemCompType = '', bonds?: ResidueBonds) {\n resname = resname.toUpperCase()\n const hash = getHash(resname, atomTypeIdList, hetero, chemCompType)\n let id = this.dict[ hash ]\n if (id === undefined) {\n const residueType = new ResidueType(\n this.structure, resname, atomTypeIdList, hetero, chemCompType, bonds\n )\n id = this.list.length\n this.dict[ hash ] = id\n this.list.push(residueType)\n }\n return id\n }\n\n get (id: number) {\n return this.list[ id ]\n }\n}\n\nexport default ResidueMap\n","/**\n * @file Bond Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport Structure from '../structure/structure'\nimport BondStore from '../store/bond-store'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Bond proxy\n */\nclass BondProxy {\n index: number\n\n bondStore: BondStore\n\n private _v12: Vector3\n private _v13: Vector3\n private _ap1: AtomProxy\n private _ap2: AtomProxy\n private _ap3: AtomProxy\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.bondStore = structure.bondStore\n\n this._v12 = new Vector3()\n this._v13 = new Vector3()\n this._ap1 = this.structure.getAtomProxy()\n this._ap2 = this.structure.getAtomProxy()\n this._ap3 = this.structure.getAtomProxy()\n }\n\n /**\n * @type {AtomProxy}\n */\n get atom1 () {\n return this.structure.getAtomProxy(this.atomIndex1)\n }\n\n /**\n * @type {AtomProxy}\n */\n get atom2 () {\n return this.structure.getAtomProxy(this.atomIndex2)\n }\n\n /**\n * @type {Integer}\n */\n get atomIndex1 () {\n return this.bondStore.atomIndex1[ this.index ]\n }\n set atomIndex1 (value) {\n this.bondStore.atomIndex1[ this.index ] = value\n }\n\n /**\n * @type {Integer}\n */\n get atomIndex2 () {\n return this.bondStore.atomIndex2[ this.index ]\n }\n set atomIndex2 (value) {\n this.bondStore.atomIndex2[ this.index ] = value\n }\n\n /**\n * @type {Integer}\n */\n get bondOrder () {\n return this.bondStore.bondOrder[ this.index ]\n }\n set bondOrder (value) {\n this.bondStore.bondOrder[ this.index ] = value\n }\n\n getOtherAtomIndex (atomIndex: number) {\n return atomIndex === this.atomIndex1 ? this.atomIndex2 : this.atomIndex1\n }\n\n getOtherAtom (atom: AtomProxy) {\n return this.structure.getAtomProxy(this.getOtherAtomIndex(atom.index))\n }\n\n /**\n * Get reference atom index for the bond\n * @return {Integer|undefined} atom index, or `undefined` if unavailable\n */\n getReferenceAtomIndex () {\n const ap1 = this._ap1\n const ap2 = this._ap2\n ap1.index = this.atomIndex1\n ap2.index = this.atomIndex2\n if (ap1.residueIndex !== ap2.residueIndex) {\n return undefined // Bond between residues, for now ignore (could detect)\n }\n const typeAtomIndex1 = ap1.index - ap1.residueAtomOffset\n const typeAtomIndex2 = ap2.index - ap2.residueAtomOffset\n const residueType = ap1.residueType\n const ix = residueType.getBondReferenceAtomIndex(typeAtomIndex1, typeAtomIndex2)\n if (ix !== undefined) {\n return ix + ap1.residueAtomOffset\n } else {\n console.warn('No reference atom found', ap1.index, ap2.index)\n }\n }\n\n /**\n * calculate shift direction for displaying double/triple bonds\n * @param {Vector3} [v] pre-allocated output vector\n * @return {Vector3} the shift direction vector\n */\n calculateShiftDir (v = new Vector3()) {\n const ap1 = this._ap1\n const ap2 = this._ap2\n const ap3 = this._ap3\n const v12 = this._v12\n const v13 = this._v13\n\n ap1.index = this.atomIndex1\n ap2.index = this.atomIndex2\n const ai3 = this.getReferenceAtomIndex()\n\n v12.subVectors(ap1 as any, ap2 as any).normalize() // TODO\n if (ai3 !== undefined) {\n ap3.index = ai3\n v13.subVectors(ap1 as any, ap3 as any) // TODO\n } else {\n v13.copy(ap1 as any) // no reference point, use origin // TODO\n }\n v13.normalize()\n\n // make sure v13 and v12 are not colinear\n let dp = v12.dot(v13)\n if (1 - Math.abs(dp) < 1e-5) {\n v13.set(1, 0, 0)\n dp = v12.dot(v13)\n if (1 - Math.abs(dp) < 1e-5) {\n v13.set(0, 1, 0)\n dp = v12.dot(v13)\n }\n }\n\n return v.copy(v13.sub(v12.multiplyScalar(dp))).normalize()\n }\n\n qualifiedName () {\n return this.atomIndex1 + '=' + this.atomIndex2\n }\n\n /**\n * Clone object\n * @return {BondProxy} cloned bond\n */\n clone () {\n return new BondProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n atomIndex1: this.atomIndex1,\n atomIndex2: this.atomIndex2,\n bondOrder: this.bondOrder\n }\n }\n}\n\nexport default BondProxy\n","/**\n * @file Residue Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { NumberArray } from '../types'\nimport { defaults } from '../utils'\nimport {\n SecStrucHelix, SecStrucSheet, SecStrucTurn,\n ProteinType, RnaType, DnaType, WaterType, IonType, SaccharideType,\n CgProteinBackboneType, CgRnaBackboneType, CgDnaBackboneType,\n AA1\n} from '../structure/structure-constants'\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\n\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\nimport AtomStore from '../store/atom-store'\n\nimport AtomMap from '../store/atom-map'\nimport ResidueMap from '../store/residue-map'\n\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueType, { RingData } from '../store/residue-type';\nimport { ResidueBonds } from '../structure/structure-utils';\nimport AtomType from '../store/atom-type';\nimport ChainProxy from './chain-proxy';\nimport Entity from '../structure/entity';\n\n/**\n * Residue proxy\n */\nclass ResidueProxy {\n index: number\n\n chainStore: ChainStore\n residueStore: ResidueStore\n atomStore: AtomStore\n\n residueMap: ResidueMap\n atomMap: AtomMap\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n this.atomStore = structure.atomStore\n this.residueMap = structure.residueMap\n this.atomMap = structure.atomMap\n }\n\n /**\n * Entity\n * @type {Entity}\n */\n get entity (): Entity {\n return this.structure.entityList[ this.entityIndex ]\n }\n get entityIndex () {\n return this.chainStore.entityIndex[ this.chainIndex ]\n }\n /**\n * Chain\n * @type {ChainProxy}\n */\n get chain (): ChainProxy {\n return this.structure.getChainProxy(this.chainIndex)\n }\n\n get chainIndex () {\n return this.residueStore.chainIndex[ this.index ]\n }\n set chainIndex (value) {\n this.residueStore.chainIndex[ this.index ] = value\n }\n\n get atomOffset () {\n return this.residueStore.atomOffset[ this.index ]\n }\n set atomOffset (value) {\n this.residueStore.atomOffset[ this.index ] = value\n }\n\n /**\n * Atom count\n * @type {Integer}\n */\n get atomCount () {\n return this.residueStore.atomCount[ this.index ]\n }\n set atomCount (value) {\n this.residueStore.atomCount[ this.index ] = value\n }\n\n get atomEnd () {\n return this.atomOffset + this.atomCount - 1\n }\n\n //\n\n get modelIndex () {\n return this.chainStore.modelIndex[ this.chainIndex ]\n }\n /**\n * Chain name\n * @type {String}\n */\n get chainname () {\n return this.chainStore.getChainname(this.chainIndex)\n }\n /**\n * Chain id\n * @type {String}\n */\n get chainid () {\n return this.chainStore.getChainid(this.chainIndex)\n }\n\n //\n\n /**\n * Residue number/label\n * @type {Integer}\n */\n get resno () {\n return this.residueStore.resno[ this.index ]\n }\n set resno (value) {\n this.residueStore.resno[ this.index ] = value\n }\n\n /**\n * Secondary structure code\n * @type {String}\n */\n get sstruc () {\n return this.residueStore.getSstruc(this.index)\n }\n set sstruc (value) {\n this.residueStore.setSstruc(this.index, value)\n }\n\n /**\n * Insertion code\n * @type {String}\n */\n get inscode () {\n return this.residueStore.getInscode(this.index)\n }\n set inscode (value) {\n this.residueStore.setInscode(this.index, value)\n }\n\n //\n\n get residueType (): ResidueType {\n return this.residueMap.get(this.residueStore.residueTypeId[ this.index ])\n }\n\n /**\n * Residue name\n * @type {String}\n */\n get resname () {\n return this.residueType.resname\n }\n /**\n * Hetero flag\n * @type {Boolean}\n */\n get hetero () {\n return this.residueType.hetero\n }\n get moleculeType () {\n return this.residueType.moleculeType\n }\n get backboneType () {\n return this.residueType.backboneType\n }\n get backboneStartType () {\n return this.residueType.backboneStartType\n }\n get backboneEndType () {\n return this.residueType.backboneEndType\n }\n get traceAtomIndex () {\n return this.residueType.traceAtomIndex + this.atomOffset\n }\n get direction1AtomIndex () {\n return this.residueType.direction1AtomIndex + this.atomOffset\n }\n get direction2AtomIndex () {\n return this.residueType.direction2AtomIndex + this.atomOffset\n }\n get backboneStartAtomIndex () {\n return this.residueType.backboneStartAtomIndex + this.atomOffset\n }\n get backboneEndAtomIndex () {\n return this.residueType.backboneEndAtomIndex + this.atomOffset\n }\n get rungEndAtomIndex () {\n return this.residueType.rungEndAtomIndex + this.atomOffset\n }\n\n //\n\n get x () {\n let x = 0\n for (let i = this.atomOffset; i <= this.atomEnd; ++i) {\n x += this.atomStore.x[ i ]\n }\n return x / this.atomCount\n }\n\n get y () {\n let y = 0\n for (let i = this.atomOffset; i <= this.atomEnd; ++i) {\n y += this.atomStore.y[ i ]\n }\n return y / this.atomCount\n }\n\n get z () {\n let z = 0\n for (let i = this.atomOffset; i <= this.atomEnd; ++i) {\n z += this.atomStore.z[ i ]\n }\n return z / this.atomCount\n }\n\n //\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (ap: AtomProxy) => void, selection?: Selection) {\n const count = this.atomCount\n const offset = this.atomOffset\n const ap = this.structure._ap\n const end = offset + count\n\n if (selection && selection.atomOnlyTest) {\n const atomOnlyTest = selection.atomOnlyTest\n for (let i = offset; i < end; ++i) {\n ap.index = i\n if (atomOnlyTest(ap)) callback(ap)\n }\n } else {\n for (let i = offset; i < end; ++i) {\n ap.index = i\n callback(ap)\n }\n }\n }\n\n //\n\n /**\n * Write residue center position to array\n * @param {Array|TypedArray} [array] - target array\n * @param {Integer} [offset] - the offset\n * @return {Array|TypedArray} target array\n */\n positionToArray (array: NumberArray = [], offset = 0) {\n array[ offset + 0 ] = this.x\n array[ offset + 1 ] = this.y\n array[ offset + 2 ] = this.z\n\n return array\n }\n\n //\n\n /**\n * If residue is from a protein\n * @return {Boolean} flag\n */\n isProtein () {\n return this.residueType.moleculeType === ProteinType\n }\n\n /**\n * If residue is nucleic\n * @return {Boolean} flag\n */\n isNucleic () {\n const moleculeType = this.residueType.moleculeType\n return moleculeType === RnaType || moleculeType === DnaType\n }\n\n /**\n * If residue is rna\n * @return {Boolean} flag\n */\n isRna () {\n return this.residueType.moleculeType === RnaType\n }\n\n /**\n * If residue is dna\n * @return {Boolean} flag\n */\n isDna () {\n return this.residueType.moleculeType === DnaType\n }\n\n /**\n * If residue is coarse-grain\n * @return {Boolean} flag\n */\n isCg () {\n const backboneType = this.residueType.backboneType\n return (\n backboneType === CgProteinBackboneType ||\n backboneType === CgRnaBackboneType ||\n backboneType === CgDnaBackboneType\n )\n }\n\n /**\n * If residue is from a polymer\n * @return {Boolean} flag\n */\n isPolymer () {\n if (this.structure.entityList.length > 0) {\n return this.entity.isPolymer()\n } else {\n const moleculeType = this.residueType.moleculeType\n return (\n moleculeType === ProteinType ||\n moleculeType === RnaType ||\n moleculeType === DnaType\n )\n }\n }\n\n /**\n * If residue is hetero\n * @return {Boolean} flag\n */\n isHetero () {\n return this.residueType.hetero === 1\n }\n\n /**\n * If residue is a water molecule\n * @return {Boolean} flag\n */\n isWater () {\n return this.residueType.moleculeType === WaterType\n }\n\n /**\n * If residue is an ion\n * @return {Boolean} flag\n */\n isIon () {\n return this.residueType.moleculeType === IonType\n }\n\n /**\n * If residue is a saccharide\n * @return {Boolean} flag\n */\n isSaccharide () {\n return this.residueType.moleculeType === SaccharideType\n }\n\n isStandardAminoacid () {\n return this.residueType.isStandardAminoacid()\n }\n\n isStandardBase () {\n return this.residueType.isStandardBase()\n }\n\n /**\n * If residue is part of a helix\n * @return {Boolean} flag\n */\n isHelix () {\n return SecStrucHelix.includes(this.sstruc)\n }\n\n /**\n * If residue is part of a sheet\n * @return {Boolean} flag\n */\n isSheet () {\n return SecStrucSheet.includes(this.sstruc)\n }\n\n /**\n * If residue is part of a turn\n * @return {Boolean} flag\n */\n isTurn () {\n return SecStrucTurn.includes(this.sstruc) && this.isProtein()\n }\n\n getAtomType (index: number): AtomType {\n return this.atomMap.get(this.atomStore.atomTypeId[ index ])\n }\n\n getResname1 () {\n // FIXME nucleic support\n return AA1[ this.resname.toUpperCase() ] || 'X'\n }\n\n getBackboneType (position: number) {\n switch (position) {\n case -1:\n return this.residueType.backboneStartType\n case 1:\n return this.residueType.backboneEndType\n default:\n return this.residueType.backboneType\n }\n }\n\n getAtomIndexByName (atomname: string) {\n let index = this.residueType.getAtomIndexByName(atomname)\n if (index !== undefined) {\n index += this.atomOffset\n }\n return index\n }\n\n hasAtomWithName (atomname: string) {\n return this.residueType.hasAtomWithName(atomname)\n }\n\n getAtomnameList () {\n console.warn('getAtomnameList - might be expensive')\n\n const n = this.atomCount\n const offset = this.atomOffset\n const list = new Array(n)\n for (let i = 0; i < n; ++i) {\n list[ i ] = this.getAtomType(offset + i).atomname\n }\n return list\n }\n\n /**\n * If residue is connected to another\n * @param {ResidueProxy} rNext - the other residue\n * @return {Boolean} - flag\n */\n connectedTo (rNext: ResidueProxy) {\n const bbAtomEnd = this.structure.getAtomProxy(this.backboneEndAtomIndex)\n const bbAtomStart = this.structure.getAtomProxy(rNext.backboneStartAtomIndex)\n if (bbAtomEnd && bbAtomStart) {\n return bbAtomEnd.connectedTo(bbAtomStart)\n } else {\n return false\n }\n }\n\n getNextConnectedResidue () {\n const rOffset = this.chainStore.residueOffset[ this.chainIndex ]\n const rCount = this.chainStore.residueCount[ this.chainIndex ]\n const nextIndex = this.index + 1\n if (nextIndex < rOffset + rCount) {\n const rpNext = this.structure.getResidueProxy(nextIndex)\n if (this.connectedTo(rpNext)) {\n return rpNext\n }\n } else if (nextIndex === rOffset + rCount) { // cyclic\n const rpFirst = this.structure.getResidueProxy(rOffset)\n if (this.connectedTo(rpFirst)) {\n return rpFirst\n }\n }\n return undefined\n }\n\n getPreviousConnectedResidue (residueProxy?: ResidueProxy) {\n const rOffset = this.chainStore.residueOffset[ this.chainIndex ]\n const prevIndex = this.index - 1\n if (prevIndex >= rOffset) {\n const rpPrev = defaults(residueProxy, this.structure.getResidueProxy())\n rpPrev.index = prevIndex\n if (rpPrev.connectedTo(this)) {\n return rpPrev\n }\n } else if (prevIndex === rOffset - 1) { // cyclic\n const rCount = this.chainStore.residueCount[ this.chainIndex ]\n const rpLast = defaults(residueProxy, this.structure.getResidueProxy())\n rpLast.index = rOffset + rCount - 1\n if (rpLast.connectedTo(this)) {\n return rpLast\n }\n }\n return undefined\n }\n\n getBonds (): ResidueBonds {\n return this.residueType.getBonds(this)\n }\n\n getRings (): RingData|undefined {\n return this.residueType.getRings()\n }\n\n getAromaticRings () {\n return this.residueType.getAromaticRings(this)\n }\n\n qualifiedName (noResname = false) {\n let name = ''\n if (this.resname && !noResname) name += '[' + this.resname + ']'\n if (this.resno !== undefined) name += this.resno\n if (this.inscode) name += '^' + this.inscode\n if (this.chain) name += ':' + this.chainname\n name += '/' + this.modelIndex\n return name\n }\n\n /**\n * Clone object\n * @return {ResidueProxy} cloned residue\n */\n clone () {\n return new ResidueProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n index: this.index,\n chainIndex: this.chainIndex,\n atomOffset: this.atomOffset,\n atomCount: this.atomCount,\n\n resno: this.resno,\n resname: this.resname,\n sstruc: this.sstruc\n }\n }\n}\n\nexport default ResidueProxy\n","/**\n * @file Polymer\n * @author Alexander Rose \n * @private\n */\n\n// import { Log } from '../globals'\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\n\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\nimport AtomStore from '../store/atom-store'\n\nimport ResidueProxy from '../proxy/residue-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Polymer\n */\nclass Polymer {\n chainStore: ChainStore\n residueStore: ResidueStore\n atomStore: AtomStore\n\n residueCount: number\n\n isPrevConnected: boolean\n isNextConnected: boolean\n isNextNextConnected: boolean\n isCyclic: boolean\n\n private __residueProxy: ResidueProxy\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} residueIndexStart - the index of the first residue\n * @param {Integer} residueIndexEnd - the index of the last residue\n */\n constructor (readonly structure: Structure, readonly residueIndexStart: number, readonly residueIndexEnd: number) {\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n this.atomStore = structure.atomStore\n\n /**\n * @type {Integer}\n */\n this.residueCount = residueIndexEnd - residueIndexStart + 1\n\n const rpStart = this.structure.getResidueProxy(this.residueIndexStart)\n const rpEnd = this.structure.getResidueProxy(this.residueIndexEnd)\n this.isPrevConnected = rpStart.getPreviousConnectedResidue() !== undefined\n const rpNext = rpEnd.getNextConnectedResidue()\n this.isNextConnected = rpNext !== undefined\n this.isNextNextConnected = rpNext !== undefined && rpNext.getNextConnectedResidue() !== undefined\n this.isCyclic = rpEnd.connectedTo(rpStart)\n\n this.__residueProxy = this.structure.getResidueProxy()\n\n // console.log( this.qualifiedName(), this );\n }\n\n get chainIndex () {\n return this.residueStore.chainIndex[ this.residueIndexStart ]\n }\n get modelIndex () {\n return this.chainStore.modelIndex[ this.chainIndex ]\n }\n\n /**\n * @type {String}\n */\n get chainname () {\n return this.chainStore.getChainname(this.chainIndex)\n }\n\n //\n\n /**\n * If first residue is from aprotein\n * @return {Boolean} flag\n */\n isProtein () {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.isProtein()\n }\n\n /**\n * If atom is part of a coarse-grain group\n * @return {Boolean} flag\n */\n isCg () {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.isCg()\n }\n\n /**\n * If atom is part of a nucleic molecule\n * @return {Boolean} flag\n */\n isNucleic () {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.isNucleic()\n }\n\n getMoleculeType () {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.moleculeType\n }\n\n getBackboneType (position: number) {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.getBackboneType(position)\n }\n\n getAtomIndexByType (index: number, type: string) {\n // TODO pre-calculate, add to residueStore???\n\n if (this.isCyclic) {\n if (index === -1) {\n index = this.residueCount - 1\n } else if (index === this.residueCount) {\n index = 0\n }\n } else {\n if (index === -1 && !this.isPrevConnected) index += 1\n if (index === this.residueCount && !this.isNextNextConnected) index -= 1\n // if( index === this.residueCount - 1 && !this.isNextConnected ) index -= 1;\n }\n\n const rp = this.__residueProxy\n rp.index = this.residueIndexStart + index\n let aIndex\n\n switch (type) {\n case 'trace':\n aIndex = rp.traceAtomIndex\n break\n case 'direction1':\n aIndex = rp.direction1AtomIndex\n break\n case 'direction2':\n aIndex = rp.direction2AtomIndex\n break\n default:\n aIndex = rp.getAtomIndexByName(type)\n }\n\n // if (!ap){\n // console.log(this, type, rp.residueType)\n // // console.log(rp.qualifiedName(), rp.index, index, this.residueCount - 1)\n // // rp.index = this.residueIndexStart;\n // // console.log(rp.qualifiedName(), this.residueIndexStart)\n // // rp.index = this.residueIndexEnd;\n // // console.log(rp.qualifiedName(), this.residueIndexEnd)\n // }\n\n return aIndex\n }\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (ap: AtomProxy) => void, selection?: Selection) {\n this.eachResidue(function (rp) {\n rp.eachAtom(callback, selection)\n })\n }\n\n eachAtomN (n: number, callback: (...apArray: AtomProxy[]) => void, type: string) {\n const m = this.residueCount\n const array: AtomProxy[] = new Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = this.structure.getAtomProxy(this.getAtomIndexByType(i, type))\n }\n callback.apply(this, array)\n\n for (var j = n; j < m; ++j) {\n for (let i = 1; i < n; ++i) {\n array[ i - 1 ].index = array[ i ].index\n }\n array[ n - 1 ].index = this.getAtomIndexByType(j, type)! // TODO\n callback.apply(this, array)\n }\n }\n\n /**\n * Residue iterator\n * @param {function(residue: ResidueProxy)} callback - the callback\n * @return {undefined}\n */\n eachResidue (callback: (rp: ResidueProxy) => void) {\n const rp = this.structure.getResidueProxy()\n const n = this.residueCount\n const rStartIndex = this.residueIndexStart\n\n for (let i = 0; i < n; ++i) {\n rp.index = rStartIndex + i\n callback(rp)\n }\n }\n\n qualifiedName () {\n const rpStart = this.structure.getResidueProxy(this.residueIndexStart)\n const rpEnd = this.structure.getResidueProxy(this.residueIndexEnd)\n return rpStart.qualifiedName() + ' - ' + rpEnd.qualifiedName()\n }\n}\n\nexport default Polymer\n","/**\n * @file Chain Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { UnknownBackboneType } from '../structure/structure-constants'\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\n\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\n\nimport Polymer from '../proxy/polymer'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ModelProxy from './model-proxy';\nimport Entity from '../structure/entity';\n\n/**\n * Chain proxy\n */\nclass ChainProxy {\n index: number\n\n chainStore: ChainStore\n residueStore: ResidueStore\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n }\n\n /**\n * Entity\n * @type {Entity}\n */\n get entity (): Entity {\n return this.structure.entityList[ this.entityIndex ]\n }\n /**\n * Model\n * @type {ModelProxy}\n */\n get model (): ModelProxy {\n return this.structure.getModelProxy(this.modelIndex)\n }\n\n get entityIndex () {\n return this.chainStore.entityIndex[ this.index ]\n }\n set entityIndex (value) {\n this.chainStore.entityIndex[ this.index ] = value\n }\n\n get modelIndex () {\n return this.chainStore.modelIndex[ this.index ]\n }\n set modelIndex (value) {\n this.chainStore.modelIndex[ this.index ] = value\n }\n\n get residueOffset () {\n return this.chainStore.residueOffset[ this.index ]\n }\n set residueOffset (value) {\n this.chainStore.residueOffset[ this.index ] = value\n }\n\n /**\n * Residue count\n * @type {Integer}\n */\n get residueCount () {\n return this.chainStore.residueCount[ this.index ]\n }\n set residueCount (value) {\n this.chainStore.residueCount[ this.index ] = value\n }\n\n get residueEnd () {\n return this.residueOffset + this.residueCount - 1\n }\n\n get atomOffset () {\n return this.residueStore.atomOffset[ this.residueOffset ]\n }\n get atomEnd () {\n return (\n this.residueStore.atomOffset[ this.residueEnd ] +\n this.residueStore.atomCount[ this.residueEnd ] - 1\n )\n }\n /**\n * Atom count\n * @type {Integer}\n */\n get atomCount () {\n if (this.residueCount === 0) {\n return 0\n } else {\n return this.atomEnd - this.atomOffset + 1\n }\n }\n\n //\n\n /**\n * Chain name\n * @type {String}\n */\n get chainname () {\n return this.chainStore.getChainname(this.index)\n }\n set chainname (value) {\n this.chainStore.setChainname(this.index, value)\n }\n\n /**\n * Chain id\n * @type {String}\n */\n get chainid () {\n return this.chainStore.getChainid(this.index)\n }\n set chainid (value) {\n this.chainStore.setChainid(this.index, value)\n }\n\n //\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (ap: AtomProxy) => void, selection?: Selection) {\n this.eachResidue(function (rp) {\n rp.eachAtom(callback, selection)\n }, selection)\n }\n\n /**\n * Residue iterator\n * @param {function(residue: ResidueProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachResidue (callback: (rp: ResidueProxy) => void, selection?: Selection) {\n const count = this.residueCount\n const offset = this.residueOffset\n const rp = this.structure._rp\n const end = offset + count\n\n if (selection && selection.test) {\n const residueOnlyTest = selection.residueOnlyTest\n if (residueOnlyTest) {\n for (let i = offset; i < end; ++i) {\n rp.index = i\n if (residueOnlyTest(rp)) {\n callback(rp)\n }\n }\n } else {\n for (let i = offset; i < end; ++i) {\n rp.index = i\n callback(rp)\n }\n }\n } else {\n for (let i = offset; i < end; ++i) {\n rp.index = i\n callback(rp)\n }\n }\n }\n\n /**\n * Multi-residue iterator\n * @param {Integer} n - window size\n * @param {function(residueList: ResidueProxy[])} callback - the callback\n * @return {undefined}\n */\n eachResidueN (n: number, callback: (...rpArray: ResidueProxy[]) => void) {\n const count = this.residueCount\n const offset = this.residueOffset\n const end = offset + count\n if (count < n) return\n const array: ResidueProxy[] = new Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = this.structure.getResidueProxy(offset + i)\n }\n callback.apply(this, array)\n\n for (let j = offset + n; j < end; ++j) {\n for (let i = 0; i < n; ++i) {\n array[ i ].index += 1\n }\n callback.apply(this, array)\n }\n }\n\n /**\n * Polymer iterator\n * @param {function(polymer: Polymer)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachPolymer (callback: (p: Polymer) => void, selection?: Selection) {\n let rStartIndex = 0\n let rNextIndex = 0\n const test = selection ? selection.residueOnlyTest : undefined\n const structure = this.model.structure\n\n const count = this.residueCount\n const offset = this.residueOffset\n const end = offset + count\n\n const rp1 = this.structure.getResidueProxy()\n const rp2 = this.structure.getResidueProxy(offset)\n\n const ap1 = this.structure.getAtomProxy()\n const ap2 = this.structure.getAtomProxy()\n\n let first = true\n\n for (let i = offset + 1; i < end; ++i) {\n rp1.index = rp2.index\n rp2.index = i\n\n const bbType1 = first ? rp1.backboneEndType : rp1.backboneType\n const bbType2 = rp2.backboneType\n\n if (first) {\n rStartIndex = rp1.index\n first = false\n }\n rNextIndex = rp2.index\n\n if (bbType1 !== UnknownBackboneType && bbType1 === bbType2) {\n ap1.index = rp1.backboneEndAtomIndex\n ap2.index = rp2.backboneStartAtomIndex\n } else {\n if (bbType1 !== UnknownBackboneType) {\n if (rp1.index - rStartIndex > 1) {\n // console.log(\"FOO1\",rStartIndex, rp1.index)\n callback(new Polymer(structure, rStartIndex, rp1.index))\n }\n }\n rStartIndex = rNextIndex\n\n continue\n }\n\n if (!ap1 || !ap2 || !ap1.connectedTo(ap2) ||\n (test && (!test(rp1) || !test(rp2)))\n ) {\n if (rp1.index - rStartIndex > 1) {\n // console.log(\"FOO2\",rStartIndex, rp1.index)\n callback(new Polymer(structure, rStartIndex, rp1.index))\n }\n rStartIndex = rNextIndex\n }\n }\n\n if (rNextIndex - rStartIndex > 1) {\n if (this.structure.getResidueProxy(rStartIndex).backboneEndType) {\n // console.log(\"FOO3\",rStartIndex, rNextIndex)\n callback(new Polymer(structure, rStartIndex, rNextIndex))\n }\n }\n }\n\n //\n\n qualifiedName () {\n var name = ':' + this.chainname + '/' + this.modelIndex\n return name\n }\n\n /**\n * Clone object\n * @return {ChainProxy} cloned chain\n */\n clone () {\n return new ChainProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n index: this.index,\n residueOffset: this.residueOffset,\n residueCount: this.residueCount,\n\n chainname: this.chainname\n }\n }\n}\n\nexport default ChainProxy\n","/**\n * @file Model Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\n\nimport ModelStore from '../store/model-store'\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\n\nimport ChainProxy from '../proxy/chain-proxy'\nimport Polymer from '../proxy/polymer'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Model proxy\n */\nclass ModelProxy {\n index: number\n\n modelStore: ModelStore\n chainStore: ChainStore\n residueStore: ResidueStore\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.modelStore = structure.modelStore\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n }\n\n get chainOffset () {\n return this.modelStore.chainOffset[ this.index ]\n }\n set chainOffset (value) {\n this.modelStore.chainOffset[ this.index ] = value\n }\n\n get chainCount () {\n return this.modelStore.chainCount[ this.index ]\n }\n set chainCount (value) {\n this.modelStore.chainCount[ this.index ] = value\n }\n\n get residueOffset () {\n return this.chainStore.residueOffset[ this.chainOffset ]\n }\n get atomOffset () {\n return this.residueStore.atomOffset[ this.residueOffset ]\n }\n\n get chainEnd () {\n return this.chainOffset + this.chainCount - 1\n }\n get residueEnd () {\n return (\n this.chainStore.residueOffset[ this.chainEnd ] +\n this.chainStore.residueCount[ this.chainEnd ] - 1\n )\n }\n get atomEnd () {\n return (\n this.residueStore.atomOffset[ this.residueEnd ] +\n this.residueStore.atomCount[ this.residueEnd ] - 1\n )\n }\n\n /**\n * Residue count\n * @type {Integer}\n */\n get residueCount () {\n if (this.chainCount === 0) {\n return 0\n } else {\n return this.residueEnd - this.residueOffset + 1\n }\n }\n\n /**\n * Atom count\n * @type {Integer}\n */\n get atomCount () {\n if (this.residueCount === 0) {\n return 0\n } else {\n return this.atomEnd - this.atomOffset + 1\n }\n }\n\n //\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (ap: AtomProxy) => void, selection?: Selection) {\n this.eachChain(function (cp) {\n cp.eachAtom(callback, selection)\n }, selection)\n }\n\n /**\n * Residue iterator\n * @param {function(residue: ResidueProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachResidue (callback: (rp: ResidueProxy) => void, selection?: Selection) {\n this.eachChain(function (cp) {\n cp.eachResidue(callback, selection)\n }, selection)\n }\n\n /**\n * Polymer iterator\n * @param {function(polymer: Polymer)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachPolymer (callback: (p: Polymer) => void, selection?: Selection) {\n if (selection && selection.chainOnlyTest) {\n const chainOnlyTest = selection.chainOnlyTest\n\n this.eachChain(function (cp) {\n if (chainOnlyTest(cp)) {\n cp.eachPolymer(callback, selection)\n }\n })\n } else {\n this.eachChain(function (cp) {\n cp.eachPolymer(callback, selection)\n })\n }\n }\n\n /**\n * Chain iterator\n * @param {function(chain: ChainProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachChain (callback: (cp: ChainProxy) => void, selection?: Selection) {\n const count = this.chainCount\n const offset = this.chainOffset\n const cp = this.structure._cp\n const end = offset + count\n\n if (selection && selection.test) {\n const chainOnlyTest = selection.chainOnlyTest\n if (chainOnlyTest) {\n for (let i = offset; i < end; ++i) {\n cp.index = i\n if (chainOnlyTest(cp)) {\n callback(cp)\n }\n }\n } else {\n for (let i = offset; i < end; ++i) {\n cp.index = i\n callback(cp)\n }\n }\n } else {\n for (let i = offset; i < end; ++i) {\n cp.index = i\n callback(cp)\n }\n }\n }\n\n //\n\n qualifiedName () {\n const name = '/' + this.index\n return name\n }\n\n /**\n * Clone object\n * @return {ModelProxy} cloned model\n */\n clone () {\n return new ModelProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n index: this.index,\n chainOffset: this.chainOffset,\n chainCount: this.chainCount\n }\n }\n}\n\nexport default ModelProxy\n","/**\n * @file Structure\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3 } from 'three'\nimport { Signal } from 'signals'\n\nimport { Debug, Log, ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { AtomPicker, BondPicker } from '../utils/picker'\nimport { copyWithin, arrayMin, arrayMax } from '../math/array-utils'\nimport BitArray from '../utils/bitarray'\nimport RadiusFactory, { RadiusParams } from '../utils/radius-factory'\nimport { Matrix } from '../math/matrix-utils'\nimport PrincipalAxes from '../math/principal-axes'\nimport SpatialHash from '../geometry/spatial-hash'\nimport FilteredVolume from '../surface/filtered-volume'\nimport StructureView from './structure-view'\nimport { AtomDataParams, AtomData, BondDataParams, BondData } from './structure-data'\nimport { Data, createData } from './data'\n\nimport Entity from './entity'\nimport Unitcell from '../symmetry/unitcell'\nimport Validation from './validation'\nimport Selection from '../selection/selection'\nimport Assembly from '../symmetry/assembly'\nimport Volume from '../surface/volume'\nimport Polymer from '../proxy/polymer'\n\nimport BondHash from '../store/bond-hash'\nimport BondStore from '../store/bond-store'\nimport AtomStore from '../store/atom-store'\nimport ResidueStore from '../store/residue-store'\nimport ChainStore from '../store/chain-store'\nimport ModelStore from '../store/model-store'\n\nimport AtomMap from '../store/atom-map'\nimport ResidueMap from '../store/residue-map'\n\nimport BondProxy from '../proxy/bond-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\ninterface Structure {\n signals: StructureSignals\n\n name: string\n path: string\n title: string\n id: string\n\n data: Data\n\n atomCount: number\n bondCount: number\n\n header: StructureHeader\n extraData: StructureExtraData\n\n atomSetCache: { [k: string]: BitArray }\n atomSetDict: { [k: string]: BitArray }\n biomolDict: { [k: string]: Assembly }\n\n entityList: Entity[]\n unitcell?: Unitcell\n\n frames: Float32Array[]\n boxes: Float32Array[]\n\n validation?: Validation\n\n bondStore: BondStore\n backboneBondStore: BondStore\n rungBondStore: BondStore\n atomStore: AtomStore\n residueStore: ResidueStore\n chainStore: ChainStore\n modelStore: ModelStore\n\n atomMap: AtomMap\n residueMap: ResidueMap\n\n bondHash?: BondHash\n spatialHash?: SpatialHash\n\n atomSet?: BitArray\n bondSet?: BitArray\n\n center: Vector3\n boundingBox: Box3\n\n trajectory?: {\n name: string\n frame: number\n }\n\n getView(selection: Selection): StructureView\n\n _hasCoords?: boolean\n\n _bp: BondProxy\n _ap: AtomProxy\n _rp: ResidueProxy\n _cp: ChainProxy\n}\n\nexport type StructureHeader = {\n releaseDate?: string\n depositionDate?: string\n resolution?: number\n rFree?: number\n rWork?: number\n experimentalMethods?: string[]\n}\n\nexport type StructureExtraData = {\n cif?: object\n sdf?: object[]\n}\n\nexport type StructureSignals = {\n refreshed: Signal\n}\n\n/**\n * Structure\n */\nclass Structure implements Structure{\n signals: StructureSignals = {\n refreshed: new Signal()\n }\n\n /**\n * @param {String} name - structure name\n * @param {String} path - source path\n */\n constructor (name = '', path = '') {\n this.init(name, path)\n }\n\n init (name: string, path: string) {\n this.name = name\n this.path = path\n this.title = ''\n this.id = ''\n\n this.data = createData(this)\n\n this.header = {}\n this.extraData = {}\n\n this.atomSetCache = {}\n this.atomSetDict = {}\n this.biomolDict = {}\n\n this.entityList = []\n this.unitcell = undefined\n\n this.frames = []\n this.boxes = []\n\n this.validation = undefined\n\n this.bondStore = new BondStore(0)\n this.backboneBondStore = new BondStore(0)\n this.rungBondStore = new BondStore(0)\n this.atomStore = new AtomStore(0)\n this.residueStore = new ResidueStore(0)\n this.chainStore = new ChainStore(0)\n this.modelStore = new ModelStore(0)\n\n this.atomMap = new AtomMap(this)\n this.residueMap = new ResidueMap(this)\n\n this.bondHash = undefined\n this.spatialHash = undefined\n\n this.atomSet = undefined\n this.bondSet = undefined\n\n this.center = new Vector3()\n this.boundingBox = new Box3()\n\n this._bp = this.getBondProxy()\n this._ap = this.getAtomProxy()\n this._rp = this.getResidueProxy()\n this._cp = this.getChainProxy()\n }\n\n get type () { return 'Structure' }\n\n finalizeAtoms () {\n this.atomSet = this.getAtomSet()\n this.atomCount = this.atomStore.count\n this.boundingBox = this.getBoundingBox(undefined, this.boundingBox)\n this.center = this.boundingBox.getCenter(new Vector3())\n this.spatialHash = new SpatialHash(this.atomStore, this.boundingBox)\n }\n\n finalizeBonds () {\n this.bondSet = this.getBondSet()\n this.bondCount = this.bondStore.count\n this.bondHash = new BondHash(this.bondStore, this.atomStore.count)\n\n this.atomSetCache = {}\n if (!this.atomSetDict.rung) {\n this.atomSetDict.rung = this.getAtomSet(false)\n }\n\n for (let name in this.atomSetDict) {\n this.atomSetCache[ '__' + name ] = this.atomSetDict[ name ].clone()\n }\n }\n\n //\n\n getBondProxy (index?: number) {\n return new BondProxy(this, index)\n }\n\n getAtomProxy (index?: number) {\n return new AtomProxy(this, index)\n }\n\n getResidueProxy (index?: number) {\n return new ResidueProxy(this, index)\n }\n\n getChainProxy (index?: number) {\n return new ChainProxy(this, index)\n }\n\n getModelProxy (index?: number) {\n return new ModelProxy(this, index)\n }\n\n //\n\n getBondSet (/* selection */) {\n // TODO implement selection parameter\n\n const n = this.bondStore.count\n const bondSet = new BitArray(n)\n const atomSet = this.atomSet\n\n if (atomSet) {\n if (atomSet.isAllSet()) {\n bondSet.setAll()\n } else if (atomSet.isAllClear()) {\n bondSet.clearAll()\n } else {\n const bp = this.getBondProxy()\n\n for (let i = 0; i < n; ++i) {\n bp.index = i\n if (atomSet.isSet(bp.atomIndex1, bp.atomIndex2)) {\n bondSet.set(bp.index)\n }\n }\n }\n } else {\n bondSet.setAll()\n }\n\n return bondSet\n }\n\n getBackboneBondSet (/* selection */) {\n // TODO implement selection parameter\n\n const n = this.backboneBondStore.count\n const backboneBondSet = new BitArray(n)\n const backboneAtomSet = this.atomSetCache.__backbone\n\n if (backboneAtomSet) {\n const bp = this.getBondProxy()\n bp.bondStore = this.backboneBondStore\n\n for (let i = 0; i < n; ++i) {\n bp.index = i\n if (backboneAtomSet.isSet(bp.atomIndex1, bp.atomIndex2)) {\n backboneBondSet.set(bp.index)\n }\n }\n } else {\n backboneBondSet.setAll()\n }\n\n return backboneBondSet\n }\n\n getRungBondSet (/* selection */) {\n // TODO implement selection parameter\n\n const n = this.rungBondStore.count\n const rungBondSet = new BitArray(n)\n const rungAtomSet = this.atomSetCache.__rung\n\n if (rungAtomSet) {\n const bp = this.getBondProxy()\n bp.bondStore = this.rungBondStore\n\n for (let i = 0; i < n; ++i) {\n bp.index = i\n if (rungAtomSet.isSet(bp.atomIndex1, bp.atomIndex2)) {\n rungBondSet.set(bp.index)\n }\n }\n } else {\n rungBondSet.setAll()\n }\n\n return rungBondSet\n }\n\n /**\n * Get a set of atoms\n * @param {Boolean|Selection|BitArray} selection - object defining how to\n * initialize the atom set.\n * Boolean: init with value;\n * Selection: init with selection;\n * BitArray: return bit array\n * @return {BitArray} set of atoms\n */\n getAtomSet (selection?: boolean|Selection|BitArray) {\n const n = this.atomStore.count\n\n if (selection === undefined) {\n return new BitArray(n, true)\n } else if (selection instanceof BitArray) {\n return selection\n } else if (selection === true) {\n return new BitArray(n, true)\n } else if (selection && selection.test) {\n const seleString = selection.string\n if (seleString in this.atomSetCache) {\n return this.atomSetCache[ seleString ]\n } else {\n if (seleString === '') {\n return new BitArray(n, true)\n } else {\n const atomSet = new BitArray(n)\n this.eachAtom(function (ap: AtomProxy) {\n atomSet.set(ap.index)\n }, selection)\n this.atomSetCache[ seleString ] = atomSet\n return atomSet\n }\n }\n } else if (selection === false) {\n return new BitArray(n)\n }\n\n return new BitArray(n, true)\n }\n\n /**\n * Get set of atoms around a set of atoms from a selection\n * @param {Selection} selection - the selection object\n * @param {Number} radius - radius to select within\n * @return {BitArray} set of atoms\n */\n getAtomSetWithinSelection (selection: boolean|Selection|BitArray, radius: number) {\n const spatialHash = this.spatialHash\n const atomSet = this.getAtomSet(false)\n const ap = this.getAtomProxy()\n\n if (!spatialHash) return atomSet\n\n this.getAtomSet(selection).forEach(function (idx: number) {\n ap.index = idx\n spatialHash.within(ap.x, ap.y, ap.z, radius).forEach(function (idx2: number) {\n atomSet.set(idx2)\n })\n })\n\n return atomSet\n }\n\n /**\n * Get set of atoms around a point\n * @param {Vector3|AtomProxy} point - the point\n * @param {Number} radius - radius to select within\n * @return {BitArray} set of atoms\n */\n getAtomSetWithinPoint (point: Vector3|AtomProxy, radius: number) {\n const p = point\n const atomSet = this.getAtomSet(false)\n\n if (!this.spatialHash) return atomSet\n\n this.spatialHash.within(p.x, p.y, p.z, radius).forEach(function (idx: number) {\n atomSet.set(idx)\n })\n\n return atomSet\n }\n\n /**\n * Get set of atoms within a volume\n * @param {Volume} volume - the volume\n * @param {Number} radius - radius to select within\n * @param {[type]} minValue - minimum value to be considered as within the volume\n * @param {[type]} maxValue - maximum value to be considered as within the volume\n * @param {[type]} outside - use only values falling outside of the min/max values\n * @return {BitArray} set of atoms\n */\n getAtomSetWithinVolume (volume: Volume, radius: number, minValue: number, maxValue: number, outside: boolean) {\n const fv = new FilteredVolume(volume, minValue, maxValue, outside) as any // TODO\n\n const dp = fv.getDataPosition()\n const n = dp.length\n const r = fv.matrix.getMaxScaleOnAxis()\n const atomSet = this.getAtomSet(false)\n\n if (!this.spatialHash) return atomSet\n\n for (let i = 0; i < n; i += 3) {\n this.spatialHash.within(dp[ i ], dp[ i + 1 ], dp[ i + 2 ], r).forEach(function (idx) {\n atomSet.set(idx)\n })\n }\n\n return atomSet\n }\n\n /**\n * Get set of all atoms within the groups of a selection\n * @param {Selection} selection - the selection object\n * @return {BitArray} set of atoms\n */\n getAtomSetWithinGroup (selection: boolean|Selection|BitArray) {\n const atomResidueIndex = this.atomStore.residueIndex\n const atomSet = this.getAtomSet(false)\n const rp = this.getResidueProxy()\n\n this.getAtomSet(selection).forEach(function (idx) {\n rp.index = atomResidueIndex[ idx ]\n for (let idx2 = rp.atomOffset; idx2 <= rp.atomEnd; ++idx2) {\n atomSet.set(idx2)\n }\n })\n\n return atomSet\n }\n\n //\n\n getSelection (): undefined|Selection {\n return\n }\n\n getStructure (): Structure|StructureView {\n return this\n }\n\n /**\n * Entity iterator\n * @param {function(entity: Entity)} callback - the callback\n * @param {EntityType} type - entity type\n * @return {undefined}\n */\n eachEntity (callback: (entity: Entity) => void, type: number) {\n this.entityList.forEach(function (entity) {\n if (type === undefined || entity.getEntityType() === type) {\n callback(entity)\n }\n })\n }\n\n /**\n * Bond iterator\n * @param {function(bond: BondProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachBond (callback: (entity: BondProxy) => void, selection?: Selection) {\n const bp = this.getBondProxy()\n let bondSet\n\n if (selection && selection.test) {\n bondSet = this.getBondSet(/*selection*/)\n if (this.bondSet) {\n bondSet.intersection(this.bondSet)\n }\n }\n\n if (bondSet) {\n bondSet.forEach(function (index) {\n bp.index = index\n callback(bp)\n })\n } else {\n const n = this.bondStore.count\n for (let i = 0; i < n; ++i) {\n bp.index = i\n callback(bp)\n }\n }\n }\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (entity: AtomProxy) => void, selection?: Selection) {\n if (selection && selection.test) {\n this.eachModel(function (mp) {\n mp.eachAtom(callback, selection)\n }, selection)\n } else {\n const an = this.atomStore.count\n const ap = this.getAtomProxy()\n for (let i = 0; i < an; ++i) {\n ap.index = i\n callback(ap)\n }\n }\n }\n\n /**\n * Residue iterator\n * @param {function(residue: ResidueProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachResidue (callback: (entity: ResidueProxy) => void, selection?: Selection) {\n if (selection && selection.test) {\n const mn = this.modelStore.count\n const mp = this.getModelProxy()\n const modelOnlyTest = selection.modelOnlyTest\n if (modelOnlyTest) {\n for (let i = 0; i < mn; ++i) {\n mp.index = i\n if (modelOnlyTest(mp)) {\n mp.eachResidue(callback, selection)\n }\n }\n } else {\n for (let i = 0; i < mn; ++i) {\n mp.index = i\n mp.eachResidue(callback, selection)\n }\n }\n } else {\n const rn = this.residueStore.count\n const rp = this.getResidueProxy()\n for (let i = 0; i < rn; ++i) {\n rp.index = i\n callback(rp)\n }\n }\n }\n\n /**\n * Multi-residue iterator\n * @param {Integer} n - window size\n * @param {function(residueList: ResidueProxy[])} callback - the callback\n * @return {undefined}\n */\n eachResidueN (n: number, callback: (...entityArray: ResidueProxy[]) => void) {\n const rn = this.residueStore.count\n if (rn < n) return\n const array: ResidueProxy[] = new Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = this.getResidueProxy(i)\n }\n callback.apply(this, array)\n\n for (let j = n; j < rn; ++j) {\n for (let i = 0; i < n; ++i) {\n array[ i ].index += 1\n }\n callback.apply(this, array)\n }\n }\n\n /**\n * Polymer iterator\n * @param {function(polymer: Polymer)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachPolymer (callback: (entity: Polymer) => void, selection?: Selection) {\n if (selection && selection.modelOnlyTest) {\n const modelOnlyTest = selection.modelOnlyTest\n\n this.eachModel(function (mp) {\n if (modelOnlyTest(mp)) {\n mp.eachPolymer(callback, selection)\n }\n })\n } else {\n this.eachModel(function (mp) {\n mp.eachPolymer(callback, selection)\n })\n }\n }\n\n /**\n * Chain iterator\n * @param {function(chain: ChainProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachChain (callback: (entity: ChainProxy) => void, selection?: Selection) {\n if (selection && selection.test) {\n this.eachModel(function (mp) {\n mp.eachChain(callback, selection)\n })\n } else {\n const cn = this.chainStore.count\n const cp = this.getChainProxy()\n for (let i = 0; i < cn; ++i) {\n cp.index = i\n callback(cp)\n }\n }\n }\n\n /**\n * Model iterator\n * @param {function(model: ModelProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachModel (callback: (entity: ModelProxy) => void, selection?: Selection) {\n const n = this.modelStore.count\n const mp = this.getModelProxy()\n\n if (selection && selection.test) {\n const modelOnlyTest = selection.modelOnlyTest\n if (modelOnlyTest) {\n for (let i = 0; i < n; ++i) {\n mp.index = i\n if (modelOnlyTest(mp)) {\n callback(mp)\n }\n }\n } else {\n for (let i = 0; i < n; ++i) {\n mp.index = i\n callback(mp)\n }\n }\n } else {\n for (let i = 0; i < n; ++i) {\n mp.index = i\n callback(mp)\n }\n }\n }\n\n //\n\n getAtomData (params: AtomDataParams) {\n const p = Object.assign({}, params)\n if (p.colorParams) p.colorParams.structure = this.getStructure()\n\n const what = p.what\n const atomSet = defaults(p.atomSet, this.atomSet)\n\n let radiusFactory: any // TODO\n let colormaker: any // TODO\n\n const atomData: AtomData = {}\n const ap = this.getAtomProxy()\n const atomCount = atomSet.getSize()\n\n if (!what || what.position) {\n atomData.position = new Float32Array(atomCount * 3)\n }\n if ((!what || what.color) && p.colorParams) {\n atomData.color = new Float32Array(atomCount * 3)\n colormaker = ColormakerRegistry.getScheme(p.colorParams)\n }\n if (!what || what.picking) {\n atomData.picking = new AtomPicker(new Float32Array(atomCount), this.getStructure())\n }\n if (!what || what.radius) {\n atomData.radius = new Float32Array(atomCount)\n radiusFactory = new RadiusFactory(p.radiusParams as RadiusParams)\n }\n if (!what || what.index) {\n atomData.index = new Uint32Array(atomCount)\n }\n\n const {position, color, picking, radius, index} = atomData\n\n atomSet.forEach((idx: number, i: number) => {\n const i3 = i * 3\n ap.index = idx\n if (position) {\n ap.positionToArray(position, i3)\n }\n if (color) {\n colormaker.atomColorToArray(ap, color, i3)\n }\n if (picking) {\n picking.array![ i ] = idx\n }\n if (radius) {\n radius[ i ] = radiusFactory.atomRadius(ap)\n }\n if (index) {\n index[ i ] = idx\n }\n })\n return atomData\n }\n\n getBondData (params: BondDataParams) {\n const p = Object.assign({}, params)\n if (p.colorParams) p.colorParams.structure = this.getStructure()\n\n const what = p.what\n const bondSet = defaults(p.bondSet, this.bondSet)\n const multipleBond = defaults(p.multipleBond, 'off')\n const isMulti = multipleBond !== 'off'\n const isOffset = multipleBond === 'offset'\n const bondScale = defaults(p.bondScale, 0.4)\n const bondSpacing = defaults(p.bondSpacing, 1.0)\n\n let radiusFactory: any // TODO\n let colormaker: any // TODO\n\n const bondData: BondData = {}\n const bp = this.getBondProxy()\n if (p.bondStore) bp.bondStore = p.bondStore\n const ap1 = this.getAtomProxy()\n const ap2 = this.getAtomProxy()\n\n let bondCount: number\n if (isMulti) {\n const storeBondOrder = bp.bondStore.bondOrder\n bondCount = 0\n bondSet.forEach(function (index: number) {\n bondCount += storeBondOrder[ index ]\n })\n } else {\n bondCount = bondSet.getSize()\n }\n\n if (!what || what.position) {\n bondData.position1 = new Float32Array(bondCount * 3)\n bondData.position2 = new Float32Array(bondCount * 3)\n }\n if ((!what || what.color) && p.colorParams) {\n bondData.color = new Float32Array(bondCount * 3)\n bondData.color2 = new Float32Array(bondCount * 3)\n colormaker = ColormakerRegistry.getScheme(p.colorParams)\n }\n if (!what || what.picking) {\n bondData.picking = new BondPicker(new Float32Array(bondCount), this.getStructure(), p.bondStore)\n }\n if (!what || what.radius || (isMulti && what.position)) {\n radiusFactory = new RadiusFactory(p.radiusParams as RadiusParams)\n }\n if (!what || what.radius) {\n bondData.radius = new Float32Array(bondCount)\n if (p.radius2) {\n bondData.radius2 = new Float32Array(bondCount)\n }\n }\n\n const {position1, position2, color, color2, picking, radius, radius2} = bondData\n\n let i = 0\n let j, i3, k, bondOrder, absOffset\n let multiRadius\n\n const vt = new Vector3()\n const vShortening = new Vector3()\n const vShift = new Vector3()\n\n bondSet.forEach((index: number) => {\n i3 = i * 3\n bp.index = index\n ap1.index = bp.atomIndex1\n ap2.index = bp.atomIndex2\n bondOrder = bp.bondOrder\n if (position1) {\n if (isMulti && bondOrder > 1) {\n const atomRadius = radiusFactory.atomRadius(ap1)\n multiRadius = atomRadius * bondScale / (0.5 * bondOrder)\n\n bp.calculateShiftDir(vShift)\n\n if (isOffset) {\n absOffset = 2 * bondSpacing * atomRadius\n vShift.multiplyScalar(absOffset)\n vShift.negate()\n\n // Shortening is calculated so that neighbouring double\n // bonds on tetrahedral geometry (e.g. sulphonamide)\n // are not quite touching (arccos(1.9 / 2) ~ 109deg)\n // but don't shorten beyond 10% each end or it looks odd\n vShortening.subVectors(ap2 as any, ap1 as any).multiplyScalar( // TODO\n Math.max(0.1, absOffset / 1.88)\n )\n ap1.positionToArray(position1, i3)\n ap2.positionToArray(position2, i3)\n\n if (bondOrder >= 2) {\n vt.addVectors(ap1 as any, vShift).add(vShortening).toArray(position1 as any, i3 + 3) // TODO\n vt.addVectors(ap2 as any, vShift).sub(vShortening).toArray(position2 as any, i3 + 3) // TODO\n\n if (bondOrder >= 3) {\n vt.subVectors(ap1 as any, vShift).add(vShortening).toArray(position1 as any, i3 + 6) // TODO\n vt.subVectors(ap2 as any, vShift).sub(vShortening).toArray(position2 as any, i3 + 6) // TODO\n }\n }\n } else {\n absOffset = (bondSpacing - bondScale) * atomRadius\n vShift.multiplyScalar(absOffset)\n\n if (bondOrder === 2) {\n vt.addVectors(ap1 as any, vShift).toArray(position1 as any, i3) // TODO\n vt.subVectors(ap1 as any, vShift).toArray(position1 as any, i3 + 3) // TODO\n vt.addVectors(ap2 as any, vShift).toArray(position2 as any, i3) // TODO\n vt.subVectors(ap2 as any, vShift).toArray(position2 as any, i3 + 3) // TODO\n } else if (bondOrder === 3) {\n ap1.positionToArray(position1, i3)\n vt.addVectors(ap1 as any, vShift).toArray(position1 as any, i3 + 3) // TODO\n vt.subVectors(ap1 as any, vShift).toArray(position1 as any, i3 + 6) // TODO\n ap2.positionToArray(position2, i3)\n vt.addVectors(ap2 as any, vShift).toArray(position2 as any, i3 + 3) // TODO\n vt.subVectors(ap2 as any, vShift).toArray(position2 as any, i3 + 6) // TODO\n } else {\n // todo, better fallback\n ap1.positionToArray(position1, i3)\n ap2.positionToArray(position2, i3)\n }\n }\n } else {\n ap1.positionToArray(position1, i3)\n ap2.positionToArray(position2, i3)\n }\n }\n if (color && color2) {\n colormaker.bondColorToArray(bp, 1, color, i3)\n colormaker.bondColorToArray(bp, 0, color2, i3)\n if (isMulti && bondOrder > 1) {\n for (j = 1; j < bondOrder; ++j) {\n k = j * 3 + i3\n copyWithin(color, i3, k, 3)\n copyWithin(color2, i3, k, 3)\n }\n }\n }\n if (picking && picking.array) {\n picking.array[ i ] = index\n if (isMulti && bondOrder > 1) {\n for (j = 1; j < bondOrder; ++j) {\n picking.array[ i + j ] = index\n }\n }\n }\n if (radius) {\n radius[ i ] = radiusFactory.atomRadius(ap1)\n if (isMulti && bondOrder > 1) {\n multiRadius = radius[ i ] * bondScale / (isOffset ? 1 : (0.5 * bondOrder))\n for (j = isOffset ? 1 : 0; j < bondOrder; ++j) {\n radius[ i + j ] = multiRadius\n }\n }\n }\n if (radius2) {\n radius2[ i ] = radiusFactory.atomRadius(ap2)\n if (isMulti && bondOrder > 1) {\n multiRadius = radius2[ i ] * bondScale / (isOffset ? 1 : (0.5 * bondOrder))\n for (j = isOffset ? 1 : 0; j < bondOrder; ++j) {\n radius2[ i + j ] = multiRadius\n }\n }\n }\n i += isMulti ? bondOrder : 1\n })\n\n return bondData\n }\n\n getBackboneAtomData (params: AtomDataParams) {\n params = Object.assign({\n atomSet: this.atomSetCache.__backbone\n }, params)\n\n return this.getAtomData(params)\n }\n\n getBackboneBondData (params: BondDataParams) {\n params = Object.assign({\n bondSet: this.getBackboneBondSet(),\n bondStore: this.backboneBondStore\n }, params)\n\n return this.getBondData(params)\n }\n\n getRungAtomData (params: AtomDataParams) {\n params = Object.assign({\n atomSet: this.atomSetCache.__rung\n }, params)\n\n return this.getAtomData(params)\n }\n\n getRungBondData (params: BondDataParams) {\n params = Object.assign({\n bondSet: this.getRungBondSet(),\n bondStore: this.rungBondStore\n }, params)\n\n return this.getBondData(params)\n }\n\n //\n\n /**\n * Gets the bounding box of the (selected) structure atoms\n * @param {Selection} [selection] - the selection\n * @param {Box3} [box] - optional target\n * @return {Vector3} the box\n */\n getBoundingBox (selection?: Selection, box?: Box3) {\n if (Debug) Log.time('getBoundingBox')\n\n box = box || new Box3()\n\n let minX = +Infinity\n let minY = +Infinity\n let minZ = +Infinity\n\n let maxX = -Infinity\n let maxY = -Infinity\n let maxZ = -Infinity\n\n this.eachAtom(ap => {\n const x = ap.x\n const y = ap.y\n const z = ap.z\n\n if (x < minX) minX = x\n if (y < minY) minY = y\n if (z < minZ) minZ = z\n\n if (x > maxX) maxX = x\n if (y > maxY) maxY = y\n if (z > maxZ) maxZ = z\n }, selection)\n\n box.min.set(minX, minY, minZ)\n box.max.set(maxX, maxY, maxZ)\n\n if (Debug) Log.timeEnd('getBoundingBox')\n\n return box\n }\n\n /**\n * Gets the principal axes of the (selected) structure atoms\n * @param {Selection} [selection] - the selection\n * @return {PrincipalAxes} the principal axes\n */\n getPrincipalAxes (selection?: Selection) {\n if (Debug) Log.time('getPrincipalAxes')\n\n let i = 0\n const coords = new Matrix(3, this.atomCount)\n const cd = coords.data\n\n this.eachAtom(a => {\n cd[ i + 0 ] = a.x\n cd[ i + 1 ] = a.y\n cd[ i + 2 ] = a.z\n i += 3\n }, selection)\n\n if (Debug) Log.timeEnd('getPrincipalAxes')\n\n return new PrincipalAxes(coords)\n }\n\n /**\n * Gets the center of the (selected) structure atoms\n * @param {Selection} [selection] - the selection\n * @return {Vector3} the center\n */\n atomCenter (selection?: Selection) {\n if (selection) {\n return this.getBoundingBox(selection).getCenter(new Vector3())\n } else {\n return this.center.clone()\n }\n }\n\n hasCoords () {\n if (this._hasCoords === undefined) {\n const atomStore = this.atomStore\n this._hasCoords = (\n arrayMin(atomStore.x) !== 0 || arrayMax(atomStore.x) !== 0 ||\n arrayMin(atomStore.y) !== 0 || arrayMax(atomStore.y) !== 0 ||\n arrayMin(atomStore.z) !== 0 || arrayMax(atomStore.z) !== 0\n ) || (\n // allow models with a single atom at the origin\n atomStore.count / this.modelStore.count === 1\n )\n }\n return this._hasCoords;\n }\n\n getSequence (selection?: Selection) {\n const seq: string[] = []\n const rp = this.getResidueProxy()\n\n this.eachAtom(function (ap: AtomProxy) {\n rp.index = ap.residueIndex\n if (ap.index === rp.traceAtomIndex) {\n seq.push(rp.getResname1())\n }\n }, selection)\n\n return seq\n }\n\n getAtomIndices (selection?: Selection) {\n if (selection && selection.string) {\n const indices: number[] = []\n this.eachAtom(function (ap: AtomProxy) {\n indices.push(ap.index)\n }, selection)\n return new Uint32Array(indices)\n } else {\n const p = { what: { index: true } }\n return this.getAtomData(p).index\n }\n }\n\n /**\n * Get number of unique chainnames\n * @param {Selection} selection - limit count to selection\n * @return {Integer} count\n */\n getChainnameCount (selection?: Selection) {\n const chainnames = new Set()\n this.eachChain(function (cp: ChainProxy) {\n if (cp.residueCount) {\n chainnames.add(cp.chainname)\n }\n }, selection)\n\n return chainnames.size\n }\n\n /**\n * Update atomic positions\n * @param position - Array to copy positions from\n * @param refresh - Whether or not to issue a full refresh (automatically\n * triggers re-calculation of bounding boxes, spatial hash,\n * representations etc etc). This provides compatibility with\n * the old behaviour\n */\n updatePosition (position: Float32Array|number[], refresh: boolean = true) {\n let i = 0\n\n this.eachAtom(function (ap: AtomProxy) {\n ap.positionFromArray(position, i)\n i += 3\n }, undefined)\n\n this._hasCoords = undefined // to trigger recalculation (of the _hasCoords value)\n\n if (refresh) { \n this.refreshPosition() // Recalculate bounds - structure-component listener will \n // trigger representation rebuild\n }\n\n }\n\n refreshPosition () {\n this.getBoundingBox(undefined, this.boundingBox)\n this.boundingBox.getCenter(this.center)\n this.spatialHash = new SpatialHash(this.atomStore, this.boundingBox)\n\n this.signals.refreshed.dispatch(this)\n }\n\n /**\n * Calls dispose() method of property objects.\n * Unsets properties to help garbage collection.\n * @return {undefined}\n */\n dispose () {\n if (this.frames) this.frames.length = 0\n if (this.boxes) this.boxes.length = 0\n\n this.bondStore.dispose()\n this.backboneBondStore.dispose()\n this.rungBondStore.dispose()\n this.atomStore.dispose()\n this.residueStore.dispose()\n this.chainStore.dispose()\n this.modelStore.dispose()\n\n // can't delete non-optional properties as of TS 4\n // and since we've already disposed them, don't need to.\n\n delete this.bondSet\n delete this.atomSet\n }\n}\n\nexport default Structure\n","/**\n * @file Shape\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Matrix4 required for declaration only\nimport { Box3, Vector3, Color, Matrix4 } from 'three'\n\nimport { createParams, ensureFloat32Array, getUintArray } from '../utils'\nimport {\n ArrowPrimitive, BoxPrimitive, ConePrimitive, CylinderPrimitive, EllipsoidPrimitive,\n OctahedronPrimitive, SpherePrimitive, TetrahedronPrimitive, TextPrimitive,\n TorusPrimitive, PointPrimitive, WidelinePrimitive\n} from './primitive'\nimport { MeshPicker } from '../utils/picker'\nimport Buffer from '../buffer/buffer'\nimport MeshBuffer from '../buffer/mesh-buffer'\nimport { TextBufferParameters } from '../buffer/text-buffer'\n\nconst tmpBox = new Box3()\n\nconst Primitives = [\n ArrowPrimitive, BoxPrimitive, ConePrimitive, CylinderPrimitive,\n EllipsoidPrimitive, OctahedronPrimitive, SpherePrimitive, TetrahedronPrimitive,\n TextPrimitive, TorusPrimitive, PointPrimitive, WidelinePrimitive\n]\n\nexport const ShapeDefaultParameters = {\n aspectRatio: 1.5,\n sphereDetail: 2,\n radialSegments: 50,\n disableImpostor: false,\n openEnded: false,\n dashedCylinder: false,\n labelParams: {} as Partial,\n pointSize: 2,\n sizeAttenuation: false,\n useTexture: true,\n linewidth: 2\n}\nexport type ShapeParameters = typeof ShapeDefaultParameters\n\n/**\n * Class for building custom shapes.\n *\n * @example\n * var shape = new NGL.Shape('shape', { disableImpostor: true });\n * shape.addSphere([ 0, 0, 9 ], [ 1, 0, 0 ], 1.5 );\n * shape.addEllipsoid([ 6, 0, 0 ], [ 1, 0, 0 ], 1.5, [ 3, 0, 0 ], [ 0, 2, 0 ]);\n * shape.addCylinder([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ], 0.5);\n * shape.addCone([ 0, 2, 7 ], [ 0, 3, 3 ], [ 1, 1, 0 ], 1.5);\n * shape.addArrow([ 1, 2, 7 ], [ 30, 3, 3 ], [ 1, 0, 1 ], 1.0);\n * shape.addBox([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);\n * var shapeComp = stage.addComponentFromObject(shape);\n * geoComp.addRepresentation('buffer');\n */\nclass Shape {\n name: string\n parameters: ShapeParameters\n\n boundingBox = new Box3()\n bufferList: Buffer[] = []\n meshCount = 0\n\n _center?: Vector3\n _primitiveData: { [k: string]: any } = {}\n\n /**\n * @param {String} name - name\n * @param {Object} params - parameter object\n * @param {Integer} params.aspectRatio - arrow aspect ratio, used for cylinder radius and cone length\n * @param {Integer} params.sphereDetail - sphere quality (icosahedron subdivisions)\n * @param {Integer} params.radialSegments - cylinder quality (number of segments)\n * @param {Boolean} params.disableImpostor - disable use of raycasted impostors for rendering\n * @param {Boolean} params.openEnded - capped or not\n * @param {TextBufferParameters} params.labelParams - label parameters\n */\n constructor (name = 'shape', params: Partial = {}) {\n this.name = name\n\n this.parameters = createParams(params, ShapeDefaultParameters)\n\n Primitives.forEach(P => {\n Object.keys(P.fields).forEach(name => {\n this._primitiveData[ P.getShapeKey(name) ] = []\n })\n this._primitiveData[ P.getShapeKey('name') ] = []\n })\n }\n\n /**\n * Add a buffer\n * @param {Buffer} buffer - buffer object\n * @return {Shape} this object\n */\n addBuffer (buffer: Buffer) {\n this.bufferList.push(buffer)\n\n const geometry = (buffer as any).geometry // TODO\n if (!geometry.boundingBox) {\n geometry.computeBoundingBox()\n }\n this.boundingBox.union(geometry.boundingBox)\n\n return this\n }\n\n /**\n * Add a mesh\n * @example\n * shape.addMesh(\n * [ 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1 ],\n * [ 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0 ]\n * );\n *\n * @param {Float32Array|Array} position - positions\n * @param {Float32Array|Array} color - colors\n * @param {Uint32Array|Uint16Array|Array} [index] - indices\n * @param {Float32Array|Array} [normal] - normals\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addMesh (position: Float32Array|number[], color:Float32Array|number[], index: Uint32Array|Uint16Array|number[], normal?: Float32Array|number[], name?: string) {\n position = ensureFloat32Array(position)\n color = ensureFloat32Array(color)\n\n if (Array.isArray(index)) {\n index = getUintArray(index, position.length)\n }\n if (normal) {\n normal = ensureFloat32Array(normal)\n }\n\n let data\n if (normal === undefined || normal.length == 0 ) {\n data = { position, color, index }\n } else {\n data = { position, color, index, normal }\n }\n //const data = { position, color, index, normal }\n const picking = new MeshPicker(\n this, Object.assign({ serial: this.meshCount, name }, data)\n )\n const meshBuffer = new MeshBuffer(\n Object.assign({ picking }, data) as any\n )\n this.bufferList.push(meshBuffer)\n\n tmpBox.setFromArray(position)\n this.boundingBox.union(tmpBox)\n this.meshCount += 1\n\n return this\n }\n\n /**\n * Add a sphere\n * @example\n * shape.addSphere([ 0, 0, 9 ], [ 1, 0, 0 ], 1.5);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addSphere (position: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, name: string) {\n SpherePrimitive.objectToShape(\n this, { position, color, radius, name }\n )\n return this\n }\n\n /**\n * Add an ellipsoid\n * @example\n * shape.addEllipsoid([ 6, 0, 0 ], [ 1, 0, 0 ], 1.5, [ 3, 0, 0 ], [ 0, 2, 0 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {Vector3|Array} majorAxis - major axis vector or array\n * @param {Vector3|Array} minorAxis - minor axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addEllipsoid (position: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, majorAxis: Vector3|[number, number, number], minorAxis: Vector3|[number, number, number], name: string) {\n EllipsoidPrimitive.objectToShape(\n this, { position, color, radius, majorAxis, minorAxis, name }\n )\n return this\n }\n\n /**\n * Add a torus\n * @example\n * shape.addTorus([ 6, 0, 0 ], [ 1, 0, 0 ], 1.5, [ 3, 0, 0 ], [ 0, 2, 0 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {Vector3|Array} majorAxis - major axis vector or array\n * @param {Vector3|Array} minorAxis - minor axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addTorus (position: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, majorAxis: Vector3|[number, number, number], minorAxis: Vector3|[number, number, number], name: string) {\n TorusPrimitive.objectToShape(\n this, { position, color, radius, majorAxis, minorAxis, name }\n )\n return this\n }\n\n /**\n * Add a cylinder\n * @example\n * shape.addCylinder([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ], 0.5);\n *\n * @param {Vector3|Array} position1 - from position vector or array\n * @param {Vector3|Array} position2 - to position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addCylinder (position1: Vector3|[number, number, number], position2: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, name: string) {\n CylinderPrimitive.objectToShape(\n this, { position1, position2, color, radius, name }\n )\n return this\n }\n\n /**\n * Add a cone\n * @example\n * shape.addCone([ 0, 2, 7 ], [ 0, 3, 3 ], [ 1, 1, 0 ], 1.5);\n *\n * @param {Vector3|Array} position1 - from position vector or array\n * @param {Vector3|Array} position2 - to position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addCone (position1: Vector3|[number, number, number], position2: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, name: string) {\n ConePrimitive.objectToShape(\n this, { position1, position2, color, radius, name }\n )\n return this\n }\n\n /**\n * Add an arrow\n * @example\n * shape.addArrow([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ], 0.5);\n *\n * @param {Vector3|Array} position1 - from position vector or array\n * @param {Vector3|Array} position2 - to position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addArrow (position1: Vector3|[number, number, number], position2: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, name: string) {\n ArrowPrimitive.objectToShape(\n this, { position1, position2, color, radius, name }\n )\n return this\n }\n\n /**\n * Add a box\n * @example\n * shape.addBox([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} size - size value\n * @param {Vector3|Array} heightAxis - height axis vector or array\n * @param {Vector3|Array} depthAxis - depth axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addBox (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, heightAxis: Vector3|[number, number, number], depthAxis: Vector3|[number, number, number], name: string) {\n BoxPrimitive.objectToShape(\n this, { position, color, size, heightAxis, depthAxis, name }\n )\n return this\n }\n\n /**\n * Add an octahedron\n * @example\n * shape.addOctahedron([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} size - size value\n * @param {Vector3|Array} heightAxis - height axis vector or array\n * @param {Vector3|Array} depthAxis - depth axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addOctahedron (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, heightAxis: Vector3|[number, number, number], depthAxis: Vector3|[number, number, number], name: string) {\n OctahedronPrimitive.objectToShape(\n this, { position, color, size, heightAxis, depthAxis, name }\n )\n return this\n }\n\n /**\n * Add a tetrahedron\n * @example\n * shape.addTetrahedron([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} size - size value\n * @param {Vector3|Array} heightAxis - height axis vector or array\n * @param {Vector3|Array} depthAxis - depth axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addTetrahedron (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, heightAxis: Vector3|[number, number, number], depthAxis: Vector3|[number, number, number], name: string) {\n TetrahedronPrimitive.objectToShape(\n this, { position, color, size, heightAxis, depthAxis, name }\n )\n return this\n }\n\n /**\n * Add text\n * @example\n * shape.addText([ 10, -2, 4 ], [ 0.2, 0.5, 0.8 ], 0.5, \"Hello\");\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} size - size value\n * @param {String} text - text value\n * @return {Shape} this object\n */\n addText (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, text: string) {\n TextPrimitive.objectToShape(\n this, { position, color, size, text }\n )\n return this\n }\n\n /**\n * Add point\n * @example\n * shape.addPoint([ 10, -2, 4 ], [ 0.2, 0.5, 0.8 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addPoint (position: Vector3|[number, number, number], color: Color|[number, number, number], name: string) {\n PointPrimitive.objectToShape(\n this, { position, color, name }\n )\n return this\n }\n\n /**\n * Add a wideline\n * @example\n * shape.addWideline([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ]);\n *\n * @param {Vector3|Array} position1 - from position vector or array\n * @param {Vector3|Array} position2 - to position vector or array\n * @param {Color|Array} color - color object or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addWideline (position1: Vector3|[number, number, number], position2: Vector3|[number, number, number], color: Color|[number, number, number], linewidth: number, name: string) {\n this.parameters.linewidth = linewidth\n WidelinePrimitive.objectToShape(\n this, { position1, position2, color, name }\n )\n return this\n }\n\n /**\n * Deprecated, use `.addText`\n */\n addLabel (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, text: string) {\n console.warn('Shape.addLabel is deprecated, use .addText instead')\n return this.addText(position, color, size, text)\n }\n\n getBufferList () {\n const buffers: Buffer[] = []\n\n Primitives.forEach(P => {\n if (this._primitiveData[ P.getShapeKey('color') ].length) {\n buffers.push(P.bufferFromShape(this, this.parameters))\n }\n })\n\n return this.bufferList.concat(buffers)\n }\n\n dispose () {\n this.bufferList.forEach(function (buffer) {\n buffer.dispose()\n })\n this.bufferList.length = 0\n\n Primitives.forEach(P => {\n Object.keys(P.fields).forEach(name => {\n this._primitiveData[ P.getShapeKey(name) ].length = 0\n })\n this._primitiveData[ P.getShapeKey('name') ].length = 0\n })\n }\n\n get center () {\n if (!this._center) {\n this._center = this.boundingBox.getCenter(new Vector3())\n }\n return this._center\n }\n\n get type () { return 'Shape' }\n}\n\nexport default Shape\n","/**\n * @file Buffer Representation\n * @author Alexander Rose \n * @private\n */\n\nimport Representation, { RepresentationParameters } from './representation'\nimport Viewer from '../viewer/viewer';\n\n/**\n * Representation for showing buffer objects. Good for efficiently showing\n * large amounts of geometric primitives e.g. spheres via {@link SphereBuffer}.\n * Smaller numbers of geometric primitives are more easily shown with help\n * from the {@link Shape} class.\n *\n * __Name:__ _buffer_\n *\n * @example\n * // add a single red sphere from a buffer to a shape instance\n * var shape = new NGL.Shape( \"shape\" );\n * var sphereBuffer = new NGL.SphereBuffer( {\n * position: new Float32Array( [ 0, 0, 0 ] ),\n * color: new Float32Array( [ 1, 0, 0 ] ),\n * radius: new Float32Array( [ 1 ] )\n * } );\n * shape.addBuffer( sphereBuffer );\n * var shapeComp = stage.addComponentFromObject( shape );\n * shapeComp.addRepresentation( \"buffer\" );\n *\n * @example\n * // add a single red sphere from a buffer to a structure component instance\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * var sphereBuffer = new NGL.SphereBuffer( {\n * position: new Float32Array( [ 0, 0, 0 ] ),\n * color: new Float32Array( [ 1, 0, 0 ] ),\n * radius: new Float32Array( [ 1 ] )\n * } );\n * o.addBufferRepresentation( sphereBuffer, { opacity: 0.5 } );\n * } );\n */\nclass BufferRepresentation extends Representation {\n buffer: Buffer[]\n /**\n * Create Buffer representation\n * @param {Buffer} buffer - a buffer object\n * @param {Viewer} viewer - a viewer object\n * @param {RepresentationParameters} params - representation parameters\n */\n constructor (buffer: Buffer|Buffer[], viewer: Viewer, params: Partial) {\n if (!Array.isArray(buffer)) {\n buffer = [ buffer ]\n }\n\n super(buffer, viewer, params)\n\n this.type = 'buffer'\n\n this.parameters = Object.assign({\n\n }, this.parameters, {\n\n colorScheme: null,\n colorScale: null,\n colorValue: null,\n colorDomain: null,\n colorMode: null\n\n })\n\n this.buffer = buffer\n\n this.init(params)\n }\n\n init (params: Partial) {\n super.init(params)\n\n this.build()\n }\n\n create () {\n this.bufferList.push.apply(this.bufferList, this.buffer)\n }\n\n attach (callback: ()=> void) {\n this.bufferList.forEach(buffer => {\n this.viewer.add(buffer)\n buffer.setParameters(this.getBufferParams())\n })\n this.setVisibility(this.visible)\n\n callback()\n }\n}\n\nexport default BufferRepresentation\n","/**\n * @file Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3 required for declaration only\n import { Vector3, Matrix4, Matrix3, BufferGeometry } from 'three'\n\nimport { getUintArray } from '../utils'\nimport { serialBlockArray } from '../math/array-utils'\nimport { applyMatrix3toVector3array, applyMatrix4toVector3array } from '../math/vector-utils'\nimport MeshBuffer from './mesh-buffer'\nimport { BufferParameters, BufferData } from './buffer'\nimport {Log} from \"../globals\";\n\nconst matrix = new Matrix4()\nconst normalMatrix = new Matrix3()\n\nfunction getData(data: BufferData, geo: BufferGeometry){\n const geoPosition = (geo.attributes as any).position.array\n const geoIndex = geo.index ? geo.index.array : undefined\n\n const n = data.position!.length / 3\n const m = geoPosition.length / 3\n\n const size = n * m\n\n const meshPosition = new Float32Array(size * 3)\n const meshNormal = new Float32Array(size * 3)\n const meshColor = new Float32Array(size * 3)\n\n let meshIndex\n if (geoIndex) {\n meshIndex = getUintArray(n * geoIndex.length, size)\n }\n\n return {\n position: meshPosition,\n color: meshColor,\n index: meshIndex,\n normal: meshNormal,\n primitiveId: data.primitiveId || serialBlockArray(n, m) as Float32Array,\n picking: data.picking\n }\n}\n\n/**\n * Geometry buffer. Base class for geometry-based buffers. Used to draw\n * geometry primitives given a mesh.\n * @interface\n */\nabstract class GeometryBuffer extends MeshBuffer {\n updateNormals = false\n\n geoPosition: Float32Array\n geoNormal: Float32Array\n geoIndex?: Uint32Array|Uint16Array\n\n positionCount: number\n geoPositionCount: number\n\n transformedGeoPosition: Float32Array\n transformedGeoNormal: Float32Array\n\n meshPosition: Float32Array\n meshColor: Float32Array\n meshIndex: Uint32Array|Uint16Array\n meshNormal: Float32Array\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n * @param {BufferGeometry} geo - geometry object\n */\n constructor (data: BufferData, params: Partial = {}, geo: BufferGeometry) {\n super(getData(data, geo), params)\n\n const geoPosition = (geo.attributes as any).position.array\n const geoNormal = (geo.attributes as any).normal.array\n const geoIndex = geo.index ? (geo.index.array as Uint32Array|Uint16Array) : undefined\n\n this.geoPosition = geoPosition\n this.geoNormal = geoNormal\n this.geoIndex = geoIndex\n\n this.positionCount = data.position!.length / 3\n this.geoPositionCount = geoPosition.length / 3\n\n this.transformedGeoPosition = new Float32Array(this.geoPositionCount * 3)\n this.transformedGeoNormal = new Float32Array(this.geoPositionCount * 3)\n\n const attributes = this.geometry.attributes as any // TODO\n this.meshPosition = attributes.position.array\n this.meshColor = attributes.color.array\n this.meshNormal = attributes.normal.array\n\n this.setAttributes(data)\n\n if (geoIndex) {\n const index = this.geometry.getIndex()\n if (!index) { Log.error('Index is null'); return; }\n this.meshIndex = index.array as Uint32Array|Uint16Array\n this.makeIndex()\n }\n }\n\n abstract applyPositionTransform (matrix: Matrix4, i: number, i3?: number): void\n\n setAttributes (data: Partial = {}, initNormals = false) {\n const attributes = this.geometry.attributes as any // TODO\n\n let position, color\n let geoPosition, geoNormal\n let transformedGeoPosition, transformedGeoNormal\n let meshPosition, meshColor, meshNormal\n\n const updateNormals = this.updateNormals\n\n if (data.position) {\n position = data.position\n geoPosition = this.geoPosition\n meshPosition = this.meshPosition\n transformedGeoPosition = this.transformedGeoPosition\n attributes.position.needsUpdate = true\n if (updateNormals || initNormals) {\n geoNormal = this.geoNormal\n meshNormal = this.meshNormal\n transformedGeoNormal = this.transformedGeoNormal\n attributes.normal.needsUpdate = true\n }\n }\n\n if (data.color) {\n color = data.color\n meshColor = this.meshColor\n attributes.color.needsUpdate = true\n }\n\n const n = this.positionCount\n const m = this.geoPositionCount\n\n for (let i = 0; i < n; ++i) {\n let j, l\n const k = i * m * 3\n const i3 = i * 3\n\n if (position && transformedGeoPosition && meshPosition && meshNormal && geoPosition && geoNormal) {\n transformedGeoPosition.set(geoPosition)\n matrix.makeTranslation(\n position[ i3 ], position[ i3 + 1 ], position[ i3 + 2 ]\n )\n this.applyPositionTransform(matrix, i, i3)\n applyMatrix4toVector3array(matrix.elements as unknown as Float32Array,\n transformedGeoPosition)\n\n meshPosition.set(transformedGeoPosition, k)\n\n if (updateNormals && transformedGeoNormal) {\n transformedGeoNormal.set(geoNormal)\n normalMatrix.getNormalMatrix(matrix)\n applyMatrix3toVector3array(normalMatrix.elements as unknown as Float32Array,\n transformedGeoNormal)\n\n meshNormal.set(transformedGeoNormal, k)\n } else if (initNormals) {\n meshNormal.set(geoNormal, k)\n }\n }\n\n if (color && meshColor) {\n for (j = 0; j < m; ++j) {\n l = k + 3 * j\n\n meshColor[ l ] = color[ i3 ]\n meshColor[ l + 1 ] = color[ i3 + 1 ]\n meshColor[ l + 2 ] = color[ i3 + 2 ]\n }\n }\n }\n }\n\n makeIndex () {\n const geoIndex = this.geoIndex\n const meshIndex = this.meshIndex\n\n if (!geoIndex) return\n\n const n = this.positionCount\n const m = this.geoPositionCount\n const o = geoIndex.length / 3\n\n const o3 = o * 3\n\n for (let i = 0; i < n; ++i) {\n const j = i * o3\n const q = j + o3\n\n meshIndex.set(geoIndex, j)\n for (let p = j; p < q; ++p) meshIndex[ p ] += i * m\n }\n }\n}\n\nexport default GeometryBuffer\n","/**\n * @file Sphere Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { IcosahedronBufferGeometry, Vector3, Matrix4 } from 'three'\nimport { defaults } from '../utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { SphereBufferData } from './sphere-buffer'\nimport { BufferDefaultParameters, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\n\nexport const SphereGeometryBufferDefaultParameters = Object.assign({\n sphereDetail: 1\n}, BufferDefaultParameters)\nexport type SphereGeometryBufferParameters = BufferParameters & { sphereDetail: number }\n\n/**\n * Sphere geometry buffer.\n *\n * @example\n * var sphereGeometryBuffer = new SphereGeometryBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass SphereGeometryBuffer extends GeometryBuffer {\n get defaultParameters() { return SphereGeometryBufferDefaultParameters }\n parameters: SphereGeometryBufferParameters\n\n private _radius: Float32Array\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: SphereBufferData, params: Partial = {}) {\n super(data, params, new IcosahedronBufferGeometry(1, defaults(params.sphereDetail, 1)))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number) {\n const r = this._radius[ i ]\n scale.set(r, r, r)\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.radius) this._radius = data.radius\n\n super.setAttributes(data, initNormals)\n }\n}\n\nexport default SphereGeometryBuffer\n","/**\n * @file Mapped Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { getUintArray } from '../utils'\nimport { calculateCenterArray, serialArray } from '../math/array-utils'\nimport Buffer, { BufferParameters, BufferData } from './buffer'\n\nexport type MappingType = 'v2'|'v3'\n\n/**\n * Mapped buffer. Sends mapping attribute to the GPU and repeats data in\n * others attributes. Used to render imposters.\n * @interface\n */\nabstract class MappedBuffer extends Buffer {\n index: Uint32Array|Uint16Array\n\n constructor (mappingType: MappingType, data: BufferData, params: Partial = {}) {\n super(data, params)\n\n this.index = getUintArray(this.indexSize, this.attributeSize)\n this.makeIndex()\n this.initIndex(this.index)\n\n this.addAttributes({\n 'mapping': { type: mappingType, value: null }\n })\n\n this.setAttributes({ primitiveId: serialArray(this.size) })\n }\n\n abstract get mapping (): Float32Array\n abstract get mappingIndices (): Uint32Array|Uint16Array\n abstract get mappingIndicesSize (): number\n abstract get mappingSize (): number\n abstract get mappingItemSize (): number\n\n get attributeSize () {\n return this.size * this.mappingSize\n }\n\n get indexSize () {\n return this.size * this.mappingIndicesSize\n }\n\n addAttributes (attributes: any) {\n const nullValueAttributes: any = {}\n for (const name in attributes) {\n const a = attributes[ name ]\n nullValueAttributes[ name ] = {\n type: a.type,\n value: null\n }\n }\n\n super.addAttributes(nullValueAttributes)\n }\n\n getAttributeIndex (dataIndex: number) {\n return dataIndex * 3 * this.mappingSize\n }\n\n setAttributes (data: any) { // TODO\n if (data && !data.position && data.position1 && data.position2) {\n data.position = calculateCenterArray(data.position1, data.position2)\n }\n\n const size = this.size\n const mappingSize = this.mappingSize\n const attributes = this.geometry.attributes as any // TODO\n\n let a, d, itemSize, array, n, i, j\n\n for (const name in data) {\n if (name === 'index' || name === 'picking') continue\n\n d = data[ name ]\n a = attributes[ name ]\n itemSize = a.itemSize\n array = a.array\n\n for (let k = 0; k < size; ++k) {\n n = k * itemSize\n i = n * mappingSize\n\n for (let l = 0; l < mappingSize; ++l) {\n j = i + (itemSize * l)\n\n for (let m = 0; m < itemSize; ++m) {\n array[ j + m ] = d[ n + m ]\n }\n }\n }\n\n a.needsUpdate = true\n }\n }\n\n makeMapping () {\n const size = this.size\n const mapping = this.mapping\n const mappingSize = this.mappingSize\n const mappingItemSize = this.mappingItemSize\n\n const attributes = this.geometry.attributes as any // TODO\n const aMapping = attributes.mapping.array\n\n for (let v = 0; v < size; v++) {\n aMapping.set(mapping, v * mappingItemSize * mappingSize)\n }\n }\n\n makeIndex () {\n const size = this.size\n const mappingSize = this.mappingSize\n const mappingIndices = this.mappingIndices\n const mappingIndicesSize = this.mappingIndicesSize\n\n const index = this.index\n\n for (let v = 0; v < size; v++) {\n const ix = v * mappingIndicesSize\n const it = v * mappingSize\n\n index.set(mappingIndices, ix)\n\n for (let s = 0; s < mappingIndicesSize; ++s) {\n index[ ix + s ] += it\n }\n }\n }\n}\n\nexport default MappedBuffer\n","/**\n * @file Mapped Quad Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { BufferParameters, BufferData } from './buffer'\nimport MappedBuffer from './mapped-buffer'\n\nconst mapping = new Float32Array([\n -1.0, 1.0,\n -1.0, -1.0,\n 1.0, 1.0,\n 1.0, -1.0\n])\n\nconst mappingIndices = new Uint16Array([\n 0, 1, 2,\n 1, 3, 2\n])\n\n/**\n * Mapped Quad buffer. Draws screen-aligned quads. Used to render impostors.\n * @interface\n */\nclass MappedQuadBuffer extends MappedBuffer {\n constructor(data: BufferData, params: Partial = {}) {\n super('v2', data, params)\n }\n get mapping () { return mapping }\n get mappingIndices () { return mappingIndices }\n get mappingIndicesSize () { return 6 }\n get mappingSize () { return 4 }\n get mappingItemSize () { return 2 }\n}\n\nexport default MappedQuadBuffer\n","/**\n * @file Sphere Impostor Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport '../shader/SphereImpostor.vert'\nimport '../shader/SphereImpostor.frag'\n\nimport MappedQuadBuffer from './mappedquad-buffer'\nimport { SphereBufferData } from './sphere-buffer'\nimport { BufferParameters } from './buffer'\n\n/**\n * Sphere impostor buffer.\n *\n * @example\n * var sphereImpostorBuffer = new SphereImpostorBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass SphereImpostorBuffer extends MappedQuadBuffer {\n isImpostor = true\n vertexShader = 'SphereImpostor.vert'\n fragmentShader = 'SphereImpostor.frag'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: SphereBufferData, params: Partial = {}) {\n super(data, params)\n\n this.addUniforms({\n 'projectionMatrixInverse': { value: new Matrix4() },\n 'ortho': { value: 0.0 }\n })\n\n this.addAttributes({\n 'radius': { type: 'f', value: null }\n })\n\n this.setAttributes(data)\n this.makeMapping()\n }\n}\n\nexport default SphereImpostorBuffer\n","/**\n * @file Sphere Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only \nimport { Vector3, Matrix4 } from 'three'\nimport { BufferRegistry, ExtensionFragDepth } from '../globals'\nimport SphereGeometryBuffer, { SphereGeometryBufferDefaultParameters, SphereGeometryBufferParameters } from './spheregeometry-buffer'\nimport SphereImpostorBuffer from './sphereimpostor-buffer'\nimport { BufferData } from './buffer'\n\nexport interface SphereBufferData extends BufferData {\n radius: Float32Array\n}\n\nexport const SphereBufferDefaultParameters = Object.assign({\n disableImpostor: false\n}, SphereGeometryBufferDefaultParameters)\nexport type SphereBufferParameters = SphereGeometryBufferParameters & { disableImpostor: boolean }\n\nclass SphereBufferImpl {\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} params - parameters object\n * @return {SphereGeometryBuffer|SphereImpostorBuffer} the buffer object\n */\n constructor (data: SphereBufferData, params: SphereBufferParameters) {\n if (!ExtensionFragDepth || (params && params.disableImpostor)) {\n return new SphereGeometryBuffer(data, params)\n } else {\n return new SphereImpostorBuffer(data, params)\n }\n }\n}\n\n/**\n * Sphere buffer. Depending on the value {@link ExtensionFragDepth} and\n * `params.disableImpostor` the constructor returns either a\n * {@link SphereGeometryBuffer} or a {@link SphereImpostorBuffer}\n * @implements {Buffer}\n *\n * @example\n * var sphereBuffer = new SphereBuffer( {\n * position: new Float32Array( [ 0, 0, 0 ] ),\n * color: new Float32Array( [ 1, 0, 0 ] ),\n * radius: new Float32Array( [ 1 ] )\n * } );\n */\n//@ts-expect-error Incompatible constructor signatures\nconst SphereBuffer: {\n new(data: SphereBufferData, params: SphereBufferParameters): SphereGeometryBuffer | SphereImpostorBuffer;\n} = SphereBufferImpl;\n\ntype SphereBuffer = SphereGeometryBuffer | SphereImpostorBuffer;\n\nBufferRegistry.add('sphere', SphereBuffer)\n\nexport default SphereBuffer\n","/**\n * @file Point Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { DataTexture, Vector3, Matrix4 } from 'three'\n\nimport '../shader/Point.vert'\nimport '../shader/Point.frag'\n\nimport { BufferRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { smoothstep } from '../math/math-utils'\nimport Buffer, { BufferDefaultParameters, BufferParameterTypes, BufferData, BufferTypes, BufferParameters } from './buffer'\n\nfunction distance (x0: number, y0: number, x1: number, y1: number) {\n const dx = x1 - x0\n const dy = y1 - y0\n return Math.sqrt(dx * dx + dy * dy)\n}\n\ninterface PointTextureParams {\n width?: number\n height?: number\n delta?: number\n}\n\nfunction makePointTexture (params: PointTextureParams) {\n const p = params || {}\n\n const width = defaults(p.width, 256)\n const height = defaults(p.height, 256)\n const center = [ width / 2, height / 2 ]\n const radius = Math.min(width / 2, height / 2)\n const delta = defaults(p.delta, 1 / (radius + 1)) * radius\n\n let x = 0\n let y = 0\n const data = new Uint8Array(width * height * 4)\n\n for (let i = 0, il = data.length; i < il; i += 4) {\n const dist = distance(x, y, center[ 0 ], center[ 1 ])\n const value = 1 - smoothstep(radius - delta, radius, dist)\n\n data[ i ] = value * 255\n data[ i + 1 ] = value * 255\n data[ i + 2 ] = value * 255\n data[ i + 3 ] = value * 255\n\n if (++x === width) {\n x = 0\n y++\n }\n }\n\n const tex = new DataTexture(data, width, height)\n tex.needsUpdate = true\n\n return tex\n}\n\nexport const PointBufferDefaultParameters = Object.assign({\n pointSize: 1,\n sizeAttenuation: true,\n sortParticles: false,\n alphaTest: 0.5,\n useTexture: false,\n forceTransparent: false,\n edgeBleach: 0.0\n}, BufferDefaultParameters)\nexport type PointBufferParameters = BufferParameters & {\n pointSize: number,\n sizeAttenuation: boolean,\n sortParticles: boolean,\n alphaTest: number,\n useTexture: boolean,\n forceTransparent: boolean,\n edgeBleach: number\n}\n\nconst PointBufferParameterTypes = Object.assign({\n pointSize: { uniform: 'size' },\n sizeAttenuation: { updateShader: true },\n sortParticles: {},\n alphaTest: { updateShader: true },\n useTexture: { updateShader: true },\n forceTransparent: {},\n edgeBleach: { uniform: true }\n}, BufferParameterTypes)\n\n/**\n * Point buffer. Draws points. Optionally textured.\n *\n * @example\n * var pointBuffer = new PointBuffer( {\n * position: new Float32Array( [ 0, 0, 0 ] ),\n * color: new Float32Array( [ 1, 0, 0 ] )\n * } );\n */\nclass PointBuffer extends Buffer {\n parameterTypes = PointBufferParameterTypes\n get defaultParameters() { return PointBufferDefaultParameters }\n parameters: PointBufferParameters\n\n vertexShader = 'Point.vert'\n fragmentShader ='Point.frag'\n\n isPoint = true\n tex: DataTexture\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: BufferData, params: Partial = {}) {\n super(data, params)\n\n this.addUniforms({\n 'size': { value: this.parameters.pointSize },\n 'canvasHeight': { value: 1.0 },\n 'pixelRatio': { value: 1.0 },\n 'map': { value: null }\n })\n }\n\n makeMaterial () {\n super.makeMaterial()\n\n this.makeTexture()\n\n const m = this.material\n const wm = this.wireframeMaterial\n const pm = this.pickingMaterial\n\n m.uniforms.map.value = this.tex\n m.needsUpdate = true\n\n wm.uniforms.map.value = this.tex\n wm.needsUpdate = true\n\n pm.uniforms.map.value = this.tex\n pm.needsUpdate = true\n }\n\n makeTexture () {\n if (this.tex) this.tex.dispose()\n this.tex = makePointTexture({ delta: this.parameters.edgeBleach })\n }\n\n getDefines (type?: BufferTypes) {\n const defines = super.getDefines(type)\n\n if (this.parameters.sizeAttenuation) {\n defines.USE_SIZEATTENUATION = 1\n }\n\n if (this.parameters.useTexture) {\n defines.USE_MAP = 1\n }\n\n if (this.parameters.alphaTest > 0 && this.parameters.alphaTest <= 1) {\n defines.ALPHATEST = this.parameters.alphaTest.toPrecision(2)\n }\n\n return defines\n }\n\n setUniforms (data: any) {\n if (data && data.edgeBleach !== undefined) {\n this.makeTexture()\n data.map = this.tex\n }\n\n super.setUniforms(data)\n }\n\n dispose () {\n super.dispose()\n\n if (this.tex) this.tex.dispose()\n }\n}\n\nBufferRegistry.add('point', PointBuffer)\n\nexport default PointBuffer\n","/**\n * @file Dot Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { ExtensionFragDepth } from '../globals'\nimport { defaults } from '../utils'\nimport Representation, { RepresentationParameters } from './representation'\nimport Volume from '../surface/volume'\nimport FilteredVolume from '../surface/filtered-volume'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport PointBuffer from '../buffer/point-buffer'\nimport Surface from '../surface/surface';\nimport Viewer from '../viewer/viewer';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\n\nexport interface DotDataFields {\n color?: boolean,\n radius?: boolean,\n scale?: boolean\n}\n\n/**\n * Dot representation parameter object. Extends {@link RepresentationParameters}\n *\n * @typedef {Object} DotRepresentationParameters - dot representation parameters\n *\n * @property {String} thresholdType - Meaning of the threshold values. Either *value* for the literal value or *sigma* as a factor of the sigma of the data. For volume data only.\n * @property {Number} thresholdMin - Minimum value to be displayed. For volume data only.\n * @property {Number} thresholdMax - Maximum value to be displayed. For volume data only.\n * @property {Number} thresholdOut - Show only values falling outside of the treshold minumum and maximum. For volume data only.\n */\nexport interface DotRepresentationParameters extends RepresentationParameters {\n thresholdType: 'value'|'value'|'sigma'|'sigma'\n thresholdMin: number\n thresholdMax: number\n thresholdOut: boolean\n dotType: ''|'sphere'|'point'\n radiusType: ''|'value'|'abs-value'|'value-min'|'deviation'|'size'|'radius' //TODO had to add 'radius' because of test in line 333\n radius: number\n scale: number\n sphereDetail: number\n disableImpostor: boolean\n pointSize: number\n sizeAttenuation: boolean\n sortParticles: boolean\n useTexture: boolean\n alphaTest: number\n forceTransparent: boolean\n edgeBleach: number\n}\n/**\n * Dot representation\n */\nclass DotRepresentation extends Representation {\n protected thresholdType: 'value'|'value'|'sigma'|'sigma'\n protected thresholdMin: number\n protected thresholdMax: number\n protected thresholdOut: boolean\n protected dotType: ''|'sphere'|'point'\n protected radiusType: ''|'value'|'abs-value'|'value-min'|'deviation'|'size'|'radius' //TODO had to add 'radius' because of test in line 333\n protected radius: number\n protected scale: number\n protected sphereDetail: number\n protected disableImpostor: boolean\n protected pointSize: number\n protected sizeAttenuation: boolean\n protected sortParticles: boolean\n protected useTexture: boolean\n protected alphaTest: number\n protected forceTransparent: boolean\n protected edgeBleach: number\n\n protected surface: Surface|undefined\n protected volume: FilteredVolume|undefined\n protected dotBuffer: SphereBuffer|PointBuffer\n /**\n * Create Dot representation object\n * @param {Surface|Volume} surface - the surface or volume to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {DotRepresentationParameters} params - dot representation parameters\n */\n constructor (surface: Surface, viewer: Viewer, params: Partial) {\n super(surface, viewer, params)\n\n this.type = 'dot'\n\n this.parameters = Object.assign({\n\n thresholdType: {\n type: 'select',\n rebuild: true,\n options: {\n 'value': 'value', 'sigma': 'sigma'\n }\n },\n thresholdMin: {\n type: 'number', precision: 3, max: Infinity, min: -Infinity, rebuild: true\n },\n thresholdMax: {\n type: 'number', precision: 3, max: Infinity, min: -Infinity, rebuild: true\n },\n thresholdOut: {\n type: 'boolean', rebuild: true\n },\n dotType: {\n type: 'select',\n rebuild: true,\n options: {\n '': '',\n 'sphere': 'sphere',\n 'point': 'point'\n }\n },\n radiusType: {\n type: 'select',\n options: {\n '': '',\n 'value': 'value',\n 'abs-value': 'abs-value',\n 'value-min': 'value-min',\n 'deviation': 'deviation',\n 'size': 'size'\n }\n },\n radius: {\n type: 'number', precision: 3, max: 10.0, min: 0.001, property: 'size'\n },\n scale: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n sphereDetail: true,\n disableImpostor: true,\n\n pointSize: {\n type: 'number', precision: 1, max: 100, min: 0, buffer: true\n },\n sizeAttenuation: {\n type: 'boolean', buffer: true\n },\n sortParticles: {\n type: 'boolean', rebuild: true\n },\n useTexture: {\n type: 'boolean', buffer: true\n },\n alphaTest: {\n type: 'range', step: 0.001, max: 1, min: 0, buffer: true\n },\n forceTransparent: {\n type: 'boolean', buffer: true\n },\n edgeBleach: {\n type: 'range', step: 0.001, max: 1, min: 0, buffer: true\n }\n\n }, this.parameters, {\n\n colorScheme: {\n type: 'select',\n update: 'color',\n options: {\n '': '',\n 'value': 'value',\n 'uniform': 'uniform',\n 'random': 'random'\n }\n }\n\n })\n\n if (surface instanceof Volume) {\n this.surface = undefined\n this.volume = new FilteredVolume(surface)\n } else {\n this.surface = surface\n this.volume = undefined\n }\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'uniform')\n p.colorValue = defaults(p.colorValue, 0xDDDDDD)\n\n this.thresholdType = defaults(p.thresholdType, 'sigma')\n this.thresholdMin = defaults(p.thresholdMin, 2.0)\n this.thresholdMax = defaults(p.thresholdMax, Infinity)\n this.thresholdOut = defaults(p.thresholdOut, false)\n this.dotType = defaults(p.dotType, 'point')\n this.radius = defaults(p.radius, 0.1)\n this.scale = defaults(p.scale, 1.0)\n\n this.pointSize = defaults(p.pointSize, 1)\n this.sizeAttenuation = defaults(p.sizeAttenuation, true)\n this.sortParticles = defaults(p.sortParticles, false)\n this.useTexture = defaults(p.useTexture, false)\n this.alphaTest = defaults(p.alphaTest, 0.5)\n this.forceTransparent = defaults(p.forceTransparent, false)\n this.edgeBleach = defaults(p.edgeBleach, 0.0)\n\n super.init(p)\n\n this.build()\n }\n\n attach (callback: () => void) {\n this.bufferList.forEach(buffer => {\n this.viewer.add(buffer)\n })\n this.setVisibility(this.visible)\n\n callback()\n }\n\n create () {\n var dotData: SphereBufferData|{} = {}\n\n if (this.volume) {\n var volume = this.volume\n var thresholdMin, thresholdMax\n\n if (this.thresholdType === 'sigma') {\n thresholdMin = volume.getValueForSigma(this.thresholdMin)\n thresholdMax = volume.getValueForSigma(this.thresholdMax)\n } else {\n thresholdMin = this.thresholdMin\n thresholdMax = this.thresholdMax\n }\n volume.setFilter(thresholdMin, thresholdMax, this.thresholdOut)\n\n Object.assign(dotData, {\n position: volume.getDataPosition(),\n color: volume.getDataColor(this.getColorParams())\n })\n if (this.dotType === 'sphere') {\n Object.assign(dotData, {\n radius: volume.getDataSize(this.radius, this.scale),\n picking: volume.getDataPicking()\n })\n }\n } else {\n var surface = this.surface\n Object.assign(dotData, {\n position: (surface as Surface).getPosition(),\n color: (surface as Surface).getColor(this.getColorParams())\n })\n if (this.dotType === 'sphere') {\n Object.assign(dotData, {\n radius: (surface as Surface).getSize(this.radius, this.scale),\n picking: (surface as Surface).getPicking()\n })\n }\n }\n\n if (this.dotType === 'sphere') {\n this.dotBuffer = new SphereBuffer(\n dotData as SphereBufferData,\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: false\n }) as SphereBufferParameters\n ) as SphereGeometryBuffer\n } else {\n this.dotBuffer = new PointBuffer(\n dotData,\n this.getBufferParams({\n pointSize: this.pointSize,\n sizeAttenuation: this.sizeAttenuation,\n sortParticles: this.sortParticles,\n useTexture: this.useTexture,\n alphaTest: this.alphaTest,\n forceTransparent: this.forceTransparent,\n edgeBleach: this.edgeBleach\n })\n )\n }\n\n this.bufferList.push(this.dotBuffer as SphereGeometryBuffer)\n }\n\n update (what: DotDataFields = {}) {\n if (this.bufferList.length === 0) return\n\n const dotData: SphereBufferData|{} = {}\n\n if (what.color) {\n if (this.volume) {\n Object.assign(dotData, {\n color: this.volume.getDataColor(\n this.getColorParams()\n )\n })\n } else {\n Object.assign(dotData, {\n color: (this.surface as Surface).getColor(\n this.getColorParams()\n )\n })\n }\n }\n\n if (this.dotType === 'sphere' && (what.radius || what.scale)) {\n if (this.volume) {\n Object.assign(dotData, {\n radius: this.volume.getDataSize(\n this.radius, this.scale\n )\n })\n } else {\n Object.assign(dotData, {\n radius: (this.surface as Surface).getSize(\n this.radius, this.scale\n )\n })\n }\n }\n\n (this.dotBuffer as SphereGeometryBuffer).setAttributes(dotData)\n }\n\n setParameters (params: Partial, what: DotDataFields = {}, rebuild: boolean) {\n \n if (params && params.thresholdType !== undefined &&\n this.volume instanceof Volume\n ) {\n if (this.thresholdType === 'value' &&\n params.thresholdType === 'sigma'\n ) {\n this.thresholdMin = this.volume.getSigmaForValue(\n this.thresholdMin\n )\n this.thresholdMax = this.volume.getSigmaForValue(\n this.thresholdMax\n )\n } else if (this.thresholdType === 'sigma' &&\n params.thresholdType === 'value'\n ) {\n this.thresholdMin = this.volume.getValueForSigma(\n this.thresholdMin\n )\n this.thresholdMax = this.volume.getValueForSigma(\n this.thresholdMax\n )\n }\n\n this.thresholdType = params.thresholdType\n }\n\n if (params && params.radiusType !== undefined) {\n if (params.radiusType === 'radius') {\n this.radius = 0.1\n } else {\n this.radius = parseFloat(params.radiusType)\n }\n what.radius = true\n if (this.dotType === 'sphere' &&\n (!ExtensionFragDepth || this.disableImpostor)\n ) {\n rebuild = true\n }\n }\n\n if (params && params.radius !== undefined) {\n what.radius = true\n if (this.dotType === 'sphere' &&\n (!ExtensionFragDepth || this.disableImpostor)\n ) {\n rebuild = true\n }\n }\n\n if (params && params.scale !== undefined) {\n what.scale = true\n if (this.dotType === 'sphere' &&\n (!ExtensionFragDepth || this.disableImpostor)\n ) {\n rebuild = true\n }\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nexport default DotRepresentation\n","/**\n * @file Image Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport {\n // @ts-ignore: unused import Vector3, Matrix4 required for declaration only\n Vector2, Vector3, Matrix4, BufferAttribute, DataTexture,\n NormalBlending, NearestFilter, LinearFilter\n} from 'three'\n\nimport '../shader/Image.vert'\nimport '../shader/Image.frag'\n\nimport { Picker } from '../utils/picker'\nimport Buffer, { BufferDefaultParameters, BufferParameterTypes, BufferTypes } from './buffer'\n\n\nconst quadIndices = new Uint16Array([\n 0, 1, 2,\n 1, 3, 2\n])\n\nconst quadUvs = new Float32Array([\n 0, 1,\n 0, 0,\n 1, 1,\n 1, 0\n])\n\ntype ImageFilterTypes = 'nearest'|'linear'|'cubic-bspline'|'cubic-catmulrom'|'cubic-mitchell'\n\nexport interface ImageBufferData {\n position: Float32Array\n imageData: Uint8Array\n width: number\n height: number\n\n picking?: Picker\n}\n\nexport const ImageBufferDefaultParameters = Object.assign({\n filter: 'nearest' as ImageFilterTypes,\n forceTransparent: true\n}, BufferDefaultParameters)\nexport type ImageBufferParameters = typeof ImageBufferDefaultParameters\n\nexport const ImageBufferParameterTypes = Object.assign({\n filter: { updateShader: true, uniform: true }\n}, BufferParameterTypes)\n\n/**\n * Image buffer. Draw a single image. Optionally interpolate.\n */\nclass ImageBuffer extends Buffer {\n parameterTypes = ImageBufferParameterTypes\n get defaultParameters() { return ImageBufferDefaultParameters }\n parameters: ImageBufferParameters\n\n alwaysTransparent = true\n hasWireframe = false\n vertexShader = 'Image.vert'\n fragmentShader = 'Image.frag'\n\n tex: DataTexture\n pickingTex: DataTexture\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position - image position\n * @param {Float32Array} data.imageData - image data, rgba channels\n * @param {Float32Array} data.width - image width\n * @param {Float32Array} data.height - image height\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n */\n constructor (data: ImageBufferData, params: ImageBufferParameters) {\n super({\n position: data.position,\n index: quadIndices,\n picking: data.picking\n }, params)\n\n const {imageData, width, height} = data\n\n const tex = new DataTexture(imageData, width, height)\n tex.flipY = true\n this.tex = tex\n\n const n = imageData.length\n const pickingData = new Uint8Array(n)\n for (let i = 0; i < n; i += 4) {\n const j = i / 4\n pickingData[ i ] = j >> 16 & 255\n pickingData[ i + 1 ] = j >> 8 & 255\n pickingData[ i + 2 ] = j & 255\n }\n\n const pickingTex = new DataTexture(pickingData, width, height)\n pickingTex.flipY = true\n pickingTex.minFilter = NearestFilter\n pickingTex.magFilter = NearestFilter\n this.pickingTex = pickingTex\n\n this.addUniforms({\n 'map': { value: tex },\n 'pickingMap': { value: pickingTex },\n 'mapSize': { value: new Vector2(width, height) }\n })\n\n this.geometry.setAttribute('uv', new BufferAttribute(quadUvs, 2))\n }\n\n getDefines (type: BufferTypes) {\n const defines = super.getDefines(type)\n const filter = this.parameters.filter\n\n if (filter.startsWith('cubic')) {\n defines.CUBIC_INTERPOLATION = 1\n if (filter.endsWith('bspline')) {\n defines.BSPLINE_FILTER = 1\n } else if (filter.endsWith('catmulrom')) {\n defines.CATMULROM_FILTER = 1\n } else if (filter.endsWith('mitchell')) {\n defines.MITCHELL_FILTER = 1\n }\n }\n\n return defines\n }\n\n updateTexture () {\n const tex = this.tex\n const filter = this.parameters.filter\n\n if (filter.startsWith('cubic')) {\n tex.minFilter = NearestFilter\n tex.magFilter = NearestFilter\n } else if (filter === 'linear') {\n tex.minFilter = LinearFilter\n tex.magFilter = LinearFilter\n } else { // filter === \"nearest\"\n tex.minFilter = NearestFilter\n tex.magFilter = NearestFilter\n }\n\n tex.needsUpdate = true\n this.pickingTex.needsUpdate = true\n }\n\n makeMaterial () {\n super.makeMaterial()\n this.updateTexture()\n\n const m = this.material\n m.uniforms.map.value = this.tex\n m.blending = NormalBlending\n m.needsUpdate = true\n\n const wm = this.wireframeMaterial\n wm.uniforms.map.value = this.tex\n wm.blending = NormalBlending\n wm.needsUpdate = true\n\n const pm = this.pickingMaterial\n pm.uniforms.map.value = this.tex\n pm.uniforms.pickingMap.value = this.pickingTex\n pm.blending = NormalBlending\n pm.needsUpdate = true\n }\n\n setUniforms (data: any) { // TODO\n if (data && data.filter !== undefined) {\n this.updateTexture()\n data.map = this.tex\n }\n\n super.setUniforms(data)\n }\n}\n\nexport default ImageBuffer\n","/**\n * @file Volume Slice\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { SlicePicker } from '../utils/picker'\nimport { Volume } from '../ngl';\nimport { SliceRepresentationParameters } from '../representation/slice-representation';\n\nclass VolumeSlice {\n dimension: 'x'|'y'|'z'\n positionType: 'percent'|'coordinate'\n position: number\n thresholdType: 'sigma'|'value'\n thresholdMin: number\n thresholdMax: number\n normalize: boolean\n volume: Volume\n\n constructor (volume: Volume, params: Partial) {\n const p = params || {}\n\n this.dimension = defaults(p.dimension, 'x')\n this.positionType = defaults(p.positionType, 'percent')\n this.position = defaults(p.position, 30)\n this.thresholdType = defaults(p.thresholdType, 'sigma')\n this.thresholdMin = defaults(p.thresholdMin, -Infinity)\n this.thresholdMax = defaults(p.thresholdMax, Infinity)\n this.normalize = defaults(p.normalize, false)\n\n this.volume = volume\n }\n\n getPositionFromCoordinate (coord: number) {\n const dim = this.dimension\n const v = this.volume\n const m = v.matrix\n\n const mp = new Vector3().setFromMatrixPosition(m)[ dim ]\n const ms = new Vector3().setFromMatrixScale(m)[ dim ]\n\n let vn\n if (dim === 'x') {\n vn = v.nx\n } else if (dim === 'y') {\n vn = v.ny\n } else {\n vn = v.nz\n }\n\n return Math.round((((coord - mp) / (vn / 100)) + 1) / ms)\n }\n\n getData (params: any) {\n params = params || {}\n\n const v = this.volume\n const d = v.data\n const m = v.matrix\n\n let p: number\n if (this.positionType === 'coordinate') {\n p = this.getPositionFromCoordinate(this.position)\n } else {\n p = this.position\n }\n\n function pos (dimLen: number) {\n return Math.round((dimLen / 100) * (p - 1))\n }\n\n function index (x: number, y: number, z: number, i: number) {\n return (z * v.ny * v.nx + y * v.nx + x) * 3 + i\n }\n\n const position = new Float32Array(4 * 3)\n const vec = new Vector3()\n\n let width, height\n let x\n let y\n let z\n let x0 = 0\n let y0 = 0\n let z0 = 0\n let nx = v.nx\n let ny = v.ny\n let nz = v.nz\n\n function setVec (x: number, y: number, z: number, offset: number) {\n vec.set(x, y, z).applyMatrix4(m).toArray(position as any, offset)\n }\n\n if (this.dimension === 'x') {\n x = pos(v.nx)\n y = v.ny - 1\n z = v.nz - 1\n\n width = v.nz\n height = v.ny\n\n x0 = x\n nx = x0 + 1\n\n setVec(x, 0, 0, 0)\n setVec(x, y, 0, 3)\n setVec(x, 0, z, 6)\n setVec(x, y, z, 9)\n } else if (this.dimension === 'y') {\n x = v.nx - 1\n y = pos(v.ny)\n z = v.nz - 1\n\n width = v.nz\n height = v.nx\n\n y0 = y\n ny = y0 + 1\n\n setVec(0, y, 0, 0)\n setVec(x, y, 0, 3)\n setVec(0, y, z, 6)\n setVec(x, y, z, 9)\n } else if (this.dimension === 'z') {\n x = v.nx - 1\n y = v.ny - 1\n z = pos(v.nz)\n\n width = v.nx\n height = v.ny\n\n z0 = z\n nz = z0 + 1\n\n setVec(0, 0, z, 0)\n setVec(0, y, z, 3)\n setVec(x, 0, z, 6)\n setVec(x, y, z, 9)\n }\n\n let i = 0\n let j = 0\n const imageData = new Uint8Array(width * height * 4)\n const pickingArray = new Float32Array(width * height)\n\n let tMin, tMax\n if (this.thresholdType === 'sigma') {\n tMin = v.getValueForSigma(this.thresholdMin)\n tMax = v.getValueForSigma(this.thresholdMax)\n } else {\n tMin = this.thresholdMin\n tMax = this.thresholdMax\n }\n\n const cp = Object.assign({}, params.colorParams, { volume: v })\n if (this.normalize) {\n cp.domain = [ 0, 1 ]\n }\n const colormaker = ColormakerRegistry.getScheme(cp)\n const tmp = new Float32Array(3)\n const scale = colormaker.getScale()\n\n let min = 0, max, diff = 0\n if (this.normalize) {\n min = +Infinity\n max = -Infinity\n for (let iy = y0; iy < ny; ++iy) {\n for (let ix = x0; ix < nx; ++ix) {\n for (let iz = z0; iz < nz; ++iz) {\n const idx = index(ix, iy, iz, 0) / 3\n const val = d[ idx ]\n if (val < min) min = val\n if (val > max) max = val\n }\n }\n }\n diff = max - min\n }\n\n for (let iy = y0; iy < ny; ++iy) {\n for (let ix = x0; ix < nx; ++ix) {\n for (let iz = z0; iz < nz; ++iz) {\n const idx = index(ix, iy, iz, 0) / 3\n let val = d[ idx ]\n if (this.normalize) {\n val = (val - min) / diff\n }\n\n colormaker.colorToArray(scale(val), tmp)\n imageData[ i ] = Math.round(tmp[ 0 ] * 255)\n imageData[ i + 1 ] = Math.round(tmp[ 1 ] * 255)\n imageData[ i + 2 ] = Math.round(tmp[ 2 ] * 255)\n imageData[ i + 3 ] = (val > tMin && val < tMax) ? 255 : 0\n\n pickingArray[ j ] = idx\n\n ++j\n i += 4\n }\n }\n }\n\n const picking = new SlicePicker(pickingArray, v)\n\n return { position, imageData, width, height, picking }\n }\n}\n\nexport default VolumeSlice\n","/**\n * @file Slice Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport Representation, { RepresentationParameters } from './representation'\nimport ImageBuffer, { ImageBufferParameters, ImageBufferData } from '../buffer/image-buffer'\nimport VolumeSlice from '../surface/volume-slice'\nimport Viewer from '../viewer/viewer';\nimport { Volume } from '../ngl';\n\n/**\n * Slice representation parameter object. Extends {@link RepresentationParameters}\n *\n * @typedef {Object} SliceRepresentationParameters - slice representation parameters\n *\n * @property {String} filter - filter applied to map the volume data on the slice, one of \"nearest\", \"linear\", \"cubic-bspline\", \"cubic-catmulrom\", \"cubic-mitchell\".\n * @property {String} positionType - Meaning of the position value. Either \"percent\" od \"coordinate\".\n * @property {Number} position - position of the slice.\n * @property {String} dimension - one of \"x\", \"y\" or \"z\"\n * @property {String} thresholdType - Meaning of the threshold values. Either *value* for the literal value or *sigma* as a factor of the sigma of the data. For volume data only.\n * @property {Number} thresholdMin - Minimum value to be displayed. For volume data only.\n * @property {Number} thresholdMax - Maximum value to be displayed. For volume data only.\n * @property {Boolean} normalize - Flag indicating wheather to normalize the data in a slice when coloring.\n */\nexport interface SliceRepresentationParameters extends RepresentationParameters {\n filter: 'nearest'|'linear'|'cubic-bspline'|'cubic-catmulrom'|'cubic-mitchell'\n positionType: 'percent'|'coordinate'\n position: number\n dimension: 'x'|'y'|'z'\n thresholdType: 'value'|'sigma'\n thresholdMin: number\n thresholdMax: number\n normalize: boolean\n}\n/**\n * Slice representation\n */\nclass SliceRepresentation extends Representation {\n protected filter: 'nearest'|'linear'|'cubic-bspline'|'cubic-catmulrom'|'cubic-mitchell'\n protected positionType: 'percent'|'coordinate'\n protected position: number\n protected dimension: 'x'|'y'|'z'\n protected thresholdType: 'value'|'sigma'\n protected thresholdMin: number\n protected thresholdMax: number\n protected normalize: boolean\n protected volume: Volume\n /**\n * Create Slice representation object\n * @param {Volume} surface - the volume to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {SliceRepresentationParameters} params - slice representation parameters\n */\n constructor (volume: Volume, viewer: Viewer, params: Partial) {\n super(volume, viewer, params)\n\n this.type = 'slice'\n\n this.parameters = Object.assign({\n\n filter: {\n type: 'select',\n buffer: true,\n options: {\n 'nearest': 'nearest',\n 'linear': 'linear',\n 'cubic-bspline': 'cubic-bspline',\n 'cubic-catmulrom': 'cubic-catmulrom',\n 'cubic-mitchell': 'cubic-mitchell'\n }\n },\n positionType: {\n type: 'select',\n rebuild: true,\n options: {\n 'percent': 'percent', 'coordinate': 'coordinate'\n }\n },\n position: {\n type: 'range',\n step: 0.1,\n max: 100,\n min: 1,\n rebuild: true\n },\n dimension: {\n type: 'select',\n rebuild: true,\n options: {\n 'x': 'x', 'y': 'y', 'z': 'z'\n }\n },\n thresholdType: {\n type: 'select',\n rebuild: true,\n options: {\n 'value': 'value', 'sigma': 'sigma'\n }\n },\n thresholdMin: {\n type: 'number', precision: 3, max: Infinity, min: -Infinity, rebuild: true\n },\n thresholdMax: {\n type: 'number', precision: 3, max: Infinity, min: -Infinity, rebuild: true\n },\n normalize: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n\n flatShaded: null,\n side: null,\n wireframe: null,\n linewidth: null,\n colorScheme: null,\n\n roughness: null,\n metalness: null,\n diffuse: null\n\n })\n\n this.volume = volume\n\n this.init(params)\n }\n\n init (params: Partial) {\n const v = this.volume\n const p = params || {}\n p.colorDomain = defaults(p.colorDomain, [ v.min, v.max ])\n p.colorScheme = defaults(p.colorScheme, 'value')\n p.colorScale = defaults(p.colorScale, 'Spectral')\n\n this.colorScheme = 'value'\n this.dimension = defaults(p.dimension, 'x')\n this.filter = defaults(p.filter, 'cubic-bspline')\n this.positionType = defaults(p.positionType, 'percent')\n this.position = defaults(p.position, 30)\n this.thresholdType = defaults(p.thresholdType, 'sigma')\n this.thresholdMin = defaults(p.thresholdMin, -Infinity)\n this.thresholdMax = defaults(p.thresholdMax, Infinity)\n this.normalize = defaults(p.normalize, false)\n\n super.init(p)\n\n this.build()\n }\n\n attach (callback: () => void) {\n this.bufferList.forEach(buffer => {\n this.viewer.add(buffer)\n })\n this.setVisibility(this.visible)\n\n callback()\n }\n\n create () {\n const volumeSlice = new VolumeSlice(this.volume, {\n positionType: this.positionType,\n position: this.position,\n dimension: this.dimension,\n thresholdType: this.thresholdType,\n thresholdMin: this.thresholdMin,\n thresholdMax: this.thresholdMax,\n normalize: this.normalize\n })\n\n const sliceBuffer = new ImageBuffer(\n volumeSlice.getData({ colorParams: this.getColorParams() }) as ImageBufferData,\n this.getBufferParams({\n filter: this.filter\n }) as ImageBufferParameters\n )\n\n this.bufferList.push(sliceBuffer)\n }\n}\n\nexport default SliceRepresentation\n","/**\n * @file Representation Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, RepresentationRegistry } from '../globals'\n\nimport Viewer from '../viewer/viewer'\nimport Structure from '../structure/structure'\nimport Surface from '../surface/surface'\nimport Volume from '../surface/volume'\nimport Shape from '../geometry/shape'\n\nimport BufferRepresentation from './buffer-representation'\nimport SurfaceRepresentation from './surface-representation'\nimport DotRepresentation from './dot-representation'\nimport SliceRepresentation from './slice-representation'\n\nfunction logReprUnknown (type: string) {\n Log.error(`makeRepresentation: representation type ${type} unknown`)\n}\n\nexport function makeRepresentation (type: string, object: any, viewer: Viewer, params: any) { // TODO\n if (Debug) Log.time('makeRepresentation ' + type)\n\n var ReprClass\n\n if (object instanceof Structure) {\n ReprClass = RepresentationRegistry.get(type)\n\n if (!ReprClass) {\n logReprUnknown(type)\n return\n }\n } else if (object instanceof Surface) {\n if (type === 'surface') {\n ReprClass = SurfaceRepresentation\n } else if (type === 'dot') {\n ReprClass = DotRepresentation\n } else {\n logReprUnknown(type)\n return\n }\n } else if (object instanceof Volume) {\n if (type === 'surface') {\n ReprClass = SurfaceRepresentation\n } else if (type === 'dot') {\n ReprClass = DotRepresentation\n } else if (type === 'slice') {\n ReprClass = SliceRepresentation\n } else {\n logReprUnknown(type)\n return\n }\n } else if (object instanceof Shape) {\n ReprClass = BufferRepresentation\n object = object.getBufferList()\n } else if (type === 'buffer') {\n ReprClass = BufferRepresentation\n } else {\n Log.error('makeRepresentation: object ' + object + ' unknown')\n return\n }\n\n const repr = new ReprClass(object, viewer, params)\n\n if (Debug) Log.timeEnd('makeRepresentation ' + type)\n\n return repr\n}\n","/**\n * @file Element\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { createParams } from '../utils'\nimport { generateUUID } from '../math/math-utils'\nimport Stage from '../stage/stage'\n\nexport const ElementDefaultParameters = {\n name: 'some element',\n status: ''\n}\nexport type ElementParameters = typeof ElementDefaultParameters\n\nexport interface ElementSignals {\n statusChanged: Signal // on status change\n nameChanged: Signal // on name change\n disposed: Signal // on dispose\n}\n\n/**\n * Element base class\n */\nabstract class Element {\n /**\n * Events emitted by the element\n */\n signals: ElementSignals = {\n statusChanged: new Signal(),\n nameChanged: new Signal(),\n disposed: new Signal()\n }\n readonly parameters: ElementParameters\n readonly uuid: string\n\n get defaultParameters() { return ElementDefaultParameters }\n\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {ElementParameters} params - component parameters\n */\n constructor (readonly stage: Stage, params: Partial = {}) {\n this.parameters = createParams(params, this.defaultParameters)\n this.uuid = generateUUID()\n }\n\n abstract get type (): string\n\n get name () { return this.parameters.name }\n\n setStatus (value: string) {\n this.parameters.status = value\n this.signals.statusChanged.dispatch(value)\n\n return this\n }\n\n setName (value: string) {\n this.parameters.name = value\n this.signals.nameChanged.dispatch(value)\n\n return this\n }\n\n dispose () {\n this.signals.disposed.dispatch()\n }\n}\n\nexport default Element\n","/**\n * @file Representation Element\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\nimport { Color } from 'three'\n\nimport Stage from '../stage/stage'\nimport Representation, { RepresentationParameters } from '../representation/representation'\nimport Component from './component'\nimport Element, { ElementDefaultParameters, ElementSignals } from './element'\n\nexport const RepresentationElementDefaultParameters = Object.assign({\n visible: true\n}, ElementDefaultParameters)\nexport type RepresentationElementParameters = typeof RepresentationElementDefaultParameters\n\nexport interface RepresentationElementSignals extends ElementSignals {\n visibilityChanged: Signal // on visibility change\n parametersChanged: Signal // on parameters change\n}\n\n/**\n * Element wrapping a {@link Representation} object\n */\nclass RepresentationElement extends Element {\n signals: RepresentationElementSignals\n parameters: RepresentationElementParameters\n get defaultParameters() { return RepresentationElementDefaultParameters }\n\n repr: Representation\n\n /**\n * Create representation component\n * @param {Stage} stage - stage object the component belongs to\n * @param {Representation} repr - representation object to wrap\n * @param {RepresentationParameters} [params] - component parameters\n * @param {Component} [parent] - parent component\n */\n constructor (stage: Stage, repr: Representation, params: Partial = {}, readonly parent: Component) {\n super(stage, Object.assign({ name: repr.type }, params))\n\n this.signals = Object.assign({\n visibilityChanged: new Signal(),\n parametersChanged: new Signal()\n }, this.signals)\n\n this.setRepresentation(repr)\n }\n\n get visible () { return this.parameters.visible }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'representation' }\n\n getType () {\n return this.repr.type\n }\n\n setRepresentation (repr: Representation) {\n this._disposeRepresentation()\n this.repr = repr\n // this.name = repr.type;\n this.stage.tasks.listen(this.repr.tasks)\n this.updateVisibility()\n }\n\n _disposeRepresentation () {\n if (this.repr) {\n this.stage.tasks.unlisten(this.repr.tasks)\n this.repr.dispose()\n }\n }\n\n dispose () {\n if (this.parent && this.parent.hasRepresentation(this)) {\n this.parent.removeRepresentation(this)\n } else {\n this._disposeRepresentation()\n this.signals.disposed.dispatch()\n }\n }\n\n /**\n * Set the visibility of the component, takes parent visibility into account\n * @param {Boolean} value - visibility flag\n * @return {RepresentationElement} this object\n */\n setVisibility (value: boolean) {\n this.parameters.visible = value\n this.updateVisibility()\n this.signals.visibilityChanged.dispatch(this.parameters.visible)\n\n return this\n }\n\n getVisibility () {\n if (this.parent) {\n return this.parent.parameters.visible && this.parameters.visible\n } else {\n return this.parameters.visible\n }\n }\n\n /**\n * Toggle visibility of the component, takes parent visibility into account\n * @return {RepresentationElement} this object\n */\n toggleVisibility () {\n return this.setVisibility(!this.parameters.visible)\n }\n\n updateVisibility () {\n this.repr.setVisibility(this.getVisibility())\n }\n\n /**\n * Set selection\n * @param {Object} what - flags indicating what attributes to update\n * @param {Boolean} what.position - update position attribute\n * @param {Boolean} what.color - update color attribute\n * @param {Boolean} what.radius - update radius attribute\n * @return {RepresentationElement} this object\n */\n update (what: any) { // TODO\n (this.repr as any).update(what) // TODO\n\n return this\n }\n\n build (params?: any) { // TODO\n this.repr.build(params)\n\n return this\n }\n\n /**\n * Set selection\n * @param {String} string - selection string\n * @return {RepresentationElement} this object\n */\n setSelection (string: string) {\n const repr: any = this.repr // TODO\n\n if (repr.setSelection) {\n repr.setSelection(string)\n }\n\n return this\n }\n\n /**\n * Set representation parameters\n * @param {RepresentationParameters} params - parameter object\n * @return {RepresentationElement} this object\n */\n setParameters (params: any) { // TODO\n this.repr.setParameters(params)\n this.signals.parametersChanged.dispatch(\n this.repr.getParameters()\n )\n\n return this\n }\n\n /**\n * Get representation parameters\n * @return {RepresentationParameters} parameter object\n */\n getParameters (): Partial {\n return this.repr.getParameters()\n }\n\n /**\n * Set color\n * @param {String|Color|Hex} value - color value\n * @return {RepresentationElement} this object\n */\n setColor (value: string|number|Color) {\n this.repr.setColor(value)\n\n return this\n }\n}\n\nexport default RepresentationElement\n","\n/**\n * @file Component\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Quaternion, Matrix4, Euler, Box3 } from 'three'\nimport { Signal } from 'signals'\n\nimport { defaults, createParams } from '../utils'\nimport { generateUUID } from '../math/math-utils'\nimport Annotation, { AnnotationParams } from '../component/annotation'\nimport ComponentControls from '../controls/component-controls'\nimport { makeRepresentation } from '../representation/representation-utils'\nimport RepresentationElement from './representation-element'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\n\nconst _m = new Matrix4()\nconst _v = new Vector3()\n\nexport const ComponentDefaultParameters = {\n name: '',\n status: '',\n visible: true\n}\nexport type ComponentParameters = typeof ComponentDefaultParameters\n\n\nexport interface ComponentSignals {\n representationAdded: Signal // when a representation is added\n representationRemoved: Signal // when a representation is removed\n visibilityChanged: Signal // on visibility change\n matrixChanged: Signal // on matrix change\n statusChanged: Signal // on status change\n nameChanged: Signal // on name change\n disposed: Signal // on dispose\n}\n\n/**\n * Base class for components\n */\nabstract class Component {\n /**\n * Events emitted by the component\n */\n readonly signals: ComponentSignals = {\n representationAdded: new Signal(),\n representationRemoved: new Signal(),\n visibilityChanged: new Signal(),\n matrixChanged: new Signal(),\n statusChanged: new Signal(),\n nameChanged: new Signal(),\n disposed: new Signal()\n }\n\n readonly parameters: ComponentParameters\n get defaultParameters () { return ComponentDefaultParameters }\n\n readonly uuid: string\n readonly viewer: Viewer\n\n reprList: RepresentationElement[] = []\n annotationList: Annotation[] = []\n\n matrix = new Matrix4()\n position = new Vector3()\n quaternion = new Quaternion()\n scale = new Vector3(1, 1, 1)\n transform = new Matrix4()\n\n controls: ComponentControls\n\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {ComponentParameters} params - parameter object\n */\n constructor (readonly stage: Stage, readonly object: any, params: Partial = {}) {\n this.parameters = createParams(params, this.defaultParameters)\n this.uuid = generateUUID()\n this.viewer = stage.viewer\n\n this.controls = new ComponentControls(this)\n }\n\n abstract get type (): string\n\n get name () { return this.parameters.name }\n get status () { return this.parameters.status }\n get visible () { return this.parameters.visible }\n\n /**\n * Set position transform\n *\n * @example\n * // translate by 25 angstrom along x axis\n * component.setPosition([ 25, 0, 0 ]);\n *\n * @param {Vector3|Array} p - the coordinates\n * @return {Component} this object\n */\n setPosition (p: [number, number, number]|Vector3) {\n if (Array.isArray(p)) {\n this.position.fromArray(p)\n } else {\n this.position.copy(p)\n }\n this.updateMatrix()\n\n return this\n }\n\n /**\n * Set local rotation transform\n * (for global rotation use setTransform)\n *\n * @example\n * // rotate by 2 degree radians on x axis\n * component.setRotation( [ 2, 0, 0 ] );\n *\n * @param {Quaternion|Euler|Array} r - the rotation\n * @return {Component} this object\n */\n setRotation (r: [number, number, number]|Euler|Quaternion) {\n if (Array.isArray(r)) {\n if (r.length === 3) {\n const e = new Euler().fromArray(r)\n this.quaternion.setFromEuler(e)\n } else {\n this.quaternion.fromArray(r)\n }\n } else if (r instanceof Euler) {\n this.quaternion.setFromEuler(r)\n } else {\n this.quaternion.copy(r)\n }\n this.updateMatrix()\n\n return this\n }\n\n /**\n * Set scale transform\n *\n * @example\n * // scale by factor of two\n * component.setScale( 2 );\n *\n * @param {Number} s - the scale\n * @return {Component} this object\n */\n setScale (s: number) {\n this.scale.set(s, s, s)\n this.updateMatrix()\n\n return this\n }\n\n /**\n * Set general transform. Is applied before and in addition\n * to the position, rotation and scale transformations\n *\n * @example\n * component.setTransform( matrix );\n *\n * @param {Matrix4} m - the matrix\n * @return {Component} this object\n */\n setTransform (m: Matrix4) {\n this.transform.copy(m)\n this.updateMatrix()\n\n return this\n }\n\n updateMatrix () {\n const c = this.getCenterUntransformed(_v)\n this.matrix.makeTranslation(-c.x, -c.y, -c.z)\n\n _m.makeRotationFromQuaternion(this.quaternion)\n this.matrix.premultiply(_m)\n\n _m.makeScale(this.scale.x, this.scale.y, this.scale.z)\n this.matrix.premultiply(_m)\n\n const p = this.position\n _m.makeTranslation(p.x + c.x, p.y + c.y, p.z + c.z)\n this.matrix.premultiply(_m)\n\n this.matrix.premultiply(this.transform)\n\n this.updateRepresentationMatrices()\n\n this.stage.viewer.updateBoundingBox()\n\n this.signals.matrixChanged.dispatch(this.matrix)\n }\n\n /**\n * Propogates our matrix to each representation\n */\n updateRepresentationMatrices () {\n this.reprList.forEach(repr => {\n repr.setParameters({ matrix: this.matrix })\n })\n }\n\n /**\n * Add an anotation object\n * @param {Vector3} position - the 3d position\n * @param {String|Element} content - the HTML content\n * @param {Object} [params] - parameters\n * @param {Integer} params.offsetX - 2d offset in x direction\n * @param {Integer} params.offsetY - 2d offset in y direction\n * @return {Annotation} the added annotation object\n */\n addAnnotation (position: Vector3, content: string|HTMLElement, params: AnnotationParams) {\n const annotation = new Annotation(this, position, content, params)\n this.annotationList.push(annotation)\n\n return annotation\n }\n\n /**\n * Iterator over each annotation and executing the callback\n * @param {Function} callback - function to execute\n * @return {undefined}\n */\n eachAnnotation (callback: (a: Annotation) => void) {\n this.annotationList.slice().forEach(callback)\n }\n\n /**\n * Remove the give annotation from the component\n * @param {Annotation} annotation - the annotation to remove\n * @return {undefined}\n */\n removeAnnotation (annotation: Annotation) {\n const idx = this.annotationList.indexOf(annotation)\n if (idx !== -1) {\n this.annotationList.splice(idx, 1)\n annotation.dispose()\n }\n }\n\n /**\n * Remove all annotations from the component\n * @return {undefined}\n */\n removeAllAnnotations () {\n this.eachAnnotation(annotation => annotation.dispose())\n this.annotationList.length = 0\n }\n\n /**\n * Add a new representation to the component\n * @param {String} type - the name of the representation\n * @param {Object} object - the object on which the representation should be based\n * @param {RepresentationParameters} [params] - representation parameters\n * @return {RepresentationElement} the created representation wrapped into\n * a representation element object\n */\n protected _addRepresentation (type: string, object: any, params: any, hidden = false) { // TODO\n const p = params || {}\n const sp = this.stage.getParameters() as any // TODO\n p.matrix = this.matrix.clone()\n p.quality = p.quality || sp.quality\n p.disableImpostor = defaults(p.disableImpostor, !sp.impostor)\n p.useWorker = defaults(p.useWorker, sp.workerDefault)\n p.visible = defaults(p.visible, true)\n\n const p2 = Object.assign({}, p, { visible: this.parameters.visible && p.visible })\n const repr = makeRepresentation(type, object, this.viewer, p2)\n const reprElem = new RepresentationElement(this.stage, repr, p, this)\n\n if (!hidden) {\n this.reprList.push(reprElem)\n this.signals.representationAdded.dispatch(reprElem)\n }\n return reprElem\n }\n\n abstract addRepresentation (type: any, params: any): any\n\n addBufferRepresentation (buffer: any, params: any) { // TODO\n return this._addRepresentation.call(this, 'buffer', buffer, params)\n }\n\n hasRepresentation (repr: RepresentationElement) {\n return this.reprList.indexOf(repr) !== -1\n }\n\n /**\n * Iterator over each representation and executing the callback\n * @param {Function} callback - function to execute\n * @return {undefined}\n */\n eachRepresentation (callback: (repr: RepresentationElement) => void) {\n this.reprList.slice().forEach(callback)\n }\n\n /**\n * Removes a representation component\n * @param {RepresentationElement} repr - the representation element\n * @return {undefined}\n */\n removeRepresentation (repr: RepresentationElement) {\n const idx = this.reprList.indexOf(repr)\n if (idx !== -1) {\n this.reprList.splice(idx, 1)\n repr.dispose()\n this.signals.representationRemoved.dispatch(repr)\n }\n }\n\n updateRepresentations (what: any) { // TODO\n this.reprList.forEach(repr => repr.update(what))\n this.stage.viewer.requestRender()\n }\n\n /**\n * Removes all representation components\n * @return {undefined}\n */\n removeAllRepresentations () {\n this.eachRepresentation(repr => repr.dispose())\n }\n\n dispose () {\n this.removeAllAnnotations()\n this.removeAllRepresentations()\n\n this.reprList.length = 0\n\n this.signals.disposed.dispatch()\n }\n\n /**\n * Set the visibility of the component, including added representations\n * @param {Boolean} value - visibility flag\n * @return {Component} this object\n */\n setVisibility (value: boolean) {\n this.parameters.visible = value\n\n this.eachRepresentation((repr: RepresentationElement) => repr.updateVisibility())\n this.eachAnnotation((annotation: Annotation) => annotation.updateVisibility())\n\n this.signals.visibilityChanged.dispatch(value)\n\n return this\n }\n\n setStatus (value: string) {\n this.parameters.status = value\n this.signals.statusChanged.dispatch(value)\n\n return this\n }\n\n setName (value: string) {\n this.parameters.name = value\n this.signals.nameChanged.dispatch(value)\n\n return this\n }\n\n /**\n * @return {Box3} the component's bounding box\n */\n getBox (...args: any[]) {\n return this.getBoxUntransformed(...args)\n .clone().applyMatrix4(this.matrix)\n }\n\n /**\n * @return {Vector3} the component's center position\n */\n getCenter (...args: any[]) {\n return this.getCenterUntransformed(...args)\n .clone().applyMatrix4(this.matrix)\n }\n\n getZoom (...args: any[]) {\n return this.stage.getZoomForBox(this.getBox(...args))\n }\n\n /**\n * @abstract\n * @return {Box3} the untransformed component's bounding box\n */\n getBoxUntransformed (...args: any[]): Box3 {\n return new Box3()\n }\n\n getCenterUntransformed (...args: any[]) {\n return this.getBoxUntransformed().getCenter(new Vector3())\n }\n\n /**\n * Automatically center and zoom the component\n * @param {Integer} [duration] - duration of the animation, defaults to 0\n * @return {undefined}\n */\n autoView (duration?: number) {\n this.stage.animationControls.zoomMove(\n this.getCenter(),\n this.getZoom(),\n defaults(duration, 0)\n )\n }\n}\n\nexport default Component\n","/**\n * @file Collection\n * @author Alexander Rose \n * @private\n */\n\nimport Component from './component'\nimport Element from './element'\n\nclass Collection {\n constructor (readonly list: T[] = []) {\n // remove elements from list when they get disposed\n const n = list.length\n\n for (let i = 0; i < n; ++i) {\n const elm = list[ i ]\n elm.signals.disposed.add(this._remove, this)\n }\n }\n\n _remove (elm: T) {\n const idx = this.list.indexOf(elm)\n\n if (idx !== -1) {\n this.list.splice(idx, 1)\n }\n }\n\n get first () {\n return this.list.length > 0 ? this.list[0] : undefined\n }\n\n forEach (fn: (x: T) => any) {\n this.list.forEach(fn)\n\n return this\n }\n\n dispose () {\n return this.forEach((elm) => elm.dispose())\n }\n}\n\nexport default Collection\n","/**\n * @file Component Collection\n * @author Alexander Rose \n * @private\n */\n\nimport RepresentationElement from './representation-element'\nimport Collection from './collection'\nimport { GenericColor } from '../types'\n\nclass RepresentationCollection extends Collection {\n setParameters (params: any) {\n return this.forEach((repr) => repr.setParameters(params))\n }\n\n setVisibility (value: boolean) {\n return this.forEach((repr) => repr.setVisibility(value))\n }\n\n setSelection (string: string) {\n return this.forEach((repr) => repr.setSelection(string))\n }\n\n setColor (color: GenericColor) {\n return this.forEach((repr) => repr.setColor(color))\n }\n\n update (what: any) {\n return this.forEach((repr) => repr.update(what))\n }\n\n build (params?: any) {\n return this.forEach((repr) => repr.build(params))\n }\n\n dispose (params?: any) {\n return this.forEach((repr) => repr.dispose())\n }\n}\n\nexport default RepresentationCollection\n","/**\n * @file Trajectory Component\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport Element, { ElementSignals, ElementDefaultParameters } from './element'\nimport Stage from '../stage/stage'\nimport Trajectory, { TrajectoryParameters } from '../trajectory/trajectory'\nimport TrajectoryPlayer, {\n TrajectoryPlayerDirection, TrajectoryPlayerMode, TrajectoryPlayerInterpolateType\n} from '../trajectory/trajectory-player'\n\n/**\n * Trajectory component parameter object.\n * @typedef {Object} TrajectoryComponentParameters - component parameters\n *\n * @property {String} name - component name\n * @property {Integer} initialFrame - initial frame the trajectory is set to\n * @property {Integer} defaultStep - default step size to be used by trajectory players\n * @property {Integer} defaultTimeout - default timeout to be used by trajectory players\n * @property {String} defaultInterpolateType - one of \"\" (empty string), \"linear\" or \"spline\"\n * @property {Integer} defaultInterpolateStep - window size used for interpolation\n * @property {String} defaultMode - either \"loop\" or \"once\"\n * @property {String} defaultDirection - either \"forward\" or \"backward\"\n */\n\nexport const TrajectoryElementDefaultParameters = Object.assign({\n defaultStep: 1,\n defaultTimeout: 50,\n defaultInterpolateType: '' as TrajectoryPlayerInterpolateType,\n defaultInterpolateStep: 5,\n defaultMode: 'loop' as TrajectoryPlayerMode,\n defaultDirection: 'forward' as TrajectoryPlayerDirection,\n initialFrame: 0\n}, ElementDefaultParameters)\nexport type TrajectoryElementParameters = typeof TrajectoryElementDefaultParameters\n\nexport interface TrajectoryElementSignals extends ElementSignals {\n frameChanged: Signal // on frame change\n playerChanged: Signal // on player change\n countChanged: Signal // when frame count is available\n parametersChanged: Signal // on parameters change\n}\n\n/**\n * Component wrapping a {@link Trajectory} object\n */\nclass TrajectoryElement extends Element {\n signals: TrajectoryElementSignals\n parameters: TrajectoryElementParameters\n get defaultParameters () { return TrajectoryElementDefaultParameters }\n\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {Trajectory} trajectory - the trajectory object\n * @param {TrajectoryComponentParameters} params - component parameters\n * @param {StructureComponent} parent - the parent structure\n */\n constructor (stage: Stage, readonly trajectory: Trajectory, params: Partial = {}) {\n super(stage, Object.assign({ name: trajectory.name }, params))\n\n this.signals = Object.assign(this.signals, {\n frameChanged: new Signal(),\n playerChanged: new Signal(),\n countChanged: new Signal(),\n parametersChanged: new Signal()\n })\n\n // signals\n\n trajectory.signals.frameChanged.add((i: number) => {\n this.signals.frameChanged.dispatch(i)\n })\n\n trajectory.signals.playerChanged.add((player: TrajectoryPlayer) => {\n this.signals.playerChanged.dispatch(player)\n })\n\n trajectory.signals.countChanged.add((n: number) => {\n this.signals.countChanged.dispatch(n)\n })\n\n //\n\n if (params.initialFrame !== undefined) {\n this.setFrame(params.initialFrame)\n }\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'trajectory' }\n\n /**\n * Set the frame of the trajectory\n * @param {Integer} i - frame number\n * @return {undefined}\n */\n setFrame (i: number) {\n this.trajectory.setFrame(i)\n }\n\n /**\n * Set trajectory parameters\n * @param {TrajectoryParameters} params - trajectory parameters\n * @return {undefined}\n */\n setParameters (params: Partial = {}) {\n this.trajectory.setParameters(params)\n this.signals.parametersChanged.dispatch(params)\n }\n\n dispose () {\n this.trajectory.dispose()\n super.dispose()\n }\n}\n\nexport default TrajectoryElement\n","/**\n * @file Frames\n * @author Alexander Rose \n * @private\n */\n\nexport default class Frames {\n coordinates = []\n boxes = []\n times = []\n\n timeOffset = 0\n deltaTime = 1\n\n constructor (readonly name: string, readonly path: string) {}\n\n get type () { return 'Frames' }\n}\n","/**\n * @file Superposition\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\nimport { Debug, Log } from '../globals'\nimport {\n Matrix, svd, meanRows, subRows, transpose,\n multiplyABt, invert3x3, multiply3x3, mat3x3determinant, multiply\n} from '../math/matrix-utils'\nimport Structure from '../structure/structure'\n\nclass Superposition {\n coords1t: Matrix\n coords2t: Matrix\n\n transformationMatrix: Matrix4\n\n mean1: number[]\n mean2: number[]\n\n A = new Matrix(3, 3)\n W = new Matrix(1, 3)\n U = new Matrix(3, 3)\n V = new Matrix(3, 3)\n VH = new Matrix(3, 3)\n R = new Matrix(3, 3)\n\n private tmp = new Matrix(3, 3)\n private c = new Matrix(3, 3)\n\n constructor (atoms1: Structure|Float32Array, atoms2: Structure|Float32Array) {\n // allocate & init data structures\n\n let n1\n if (atoms1 instanceof Structure) {\n n1 = atoms1.atomCount\n } else if (atoms1 instanceof Float32Array) {\n n1 = atoms1.length / 3\n } else {\n return\n }\n\n let n2\n if (atoms2 instanceof Structure) {\n n2 = atoms2.atomCount\n } else if (atoms2 instanceof Float32Array) {\n n2 = atoms2.length / 3\n } else {\n return\n }\n\n const n = Math.min(n1, n2)\n\n const coords1 = new Matrix(3, n)\n const coords2 = new Matrix(3, n)\n\n this.coords1t = new Matrix(n, 3)\n this.coords2t = new Matrix(n, 3)\n\n this.transformationMatrix = new Matrix4()\n\n this.c.data.set([ 1, 0, 0, 0, 1, 0, 0, 0, -1 ])\n\n // prep coords\n\n this.prepCoords(atoms1, coords1, n, false)\n this.prepCoords(atoms2, coords2, n, false)\n\n // superpose\n\n this._superpose(coords1, coords2)\n }\n\n _superpose (coords1: Matrix, coords2: Matrix) {\n this.mean1 = meanRows(coords1)\n this.mean2 = meanRows(coords2)\n\n subRows(coords1, this.mean1)\n subRows(coords2, this.mean2)\n\n transpose(this.coords1t, coords1)\n transpose(this.coords2t, coords2)\n\n multiplyABt(this.A, this.coords2t, this.coords1t)\n\n svd(this.A, this.W, this.U, this.V)\n\n invert3x3(this.V, this.VH)\n multiply3x3(this.R, this.U, this.VH)\n\n if (mat3x3determinant(this.R) < 0.0) {\n if (Debug) Log.log('R not a right handed system')\n\n multiply3x3(this.tmp, this.c, this.VH)\n multiply3x3(this.R, this.U, this.tmp)\n }\n\n //get the transformation matrix\n\n const transformMat_ = new Matrix(4,4)\n const tmp_1 = new Matrix(4,4)\n const tmp_2 = new Matrix(4,4)\n\n const sub = new Matrix(4,4)\n const mult = new Matrix(4,4)\n const add = new Matrix(4,4)\n\n const R = this.R.data\n const M1 = this.mean1\n const M2 = this.mean2\n\n sub.data.set([ 1, 0, 0, -M1[0],\n 0, 1, 0, -M1[1],\n 0, 0, 1, -M1[2],\n 0, 0, 0, 1 ])\n\n mult.data.set([ R[0], R[1], R[2], 0,\n R[3], R[4], R[5], 0,\n R[6], R[7], R[8], 0,\n 0, 0, 0, 1 ])\n\n add.data.set([ 1, 0, 0, M2[0],\n 0, 1, 0, M2[1],\n 0, 0, 1, M2[2],\n 0, 0, 0, 1 ])\n\n transpose(tmp_1,sub)\n multiplyABt(transformMat_,mult,tmp_1)\n transpose(tmp_2,transformMat_)\n multiplyABt(tmp_1,add,tmp_2)\n\n transpose(transformMat_,tmp_1)\n this.transformationMatrix.elements = transformMat_.data as unknown as number[]\n\n }\n\n prepCoords (atoms: Structure|Float32Array, coords: Matrix, n: number, is4X4: boolean) {\n let i = 0\n const cd = coords.data\n\n let c = 3\n let d = n * 3\n\n if (is4X4) {\n d = n * 4\n c = 4\n }\n if (atoms instanceof Structure) {\n atoms.eachAtom(function (a) {\n if (i < d) {\n cd[ i + 0 ] = a.x\n cd[ i + 1 ] = a.y\n cd[ i + 2 ] = a.z\n if (is4X4) cd[ i + 3 ] = 1\n\n i += c\n }\n })\n } else if (atoms instanceof Float32Array) {\n for (; i < d; i += c){\n if (i < d) {\n cd[ i ] = atoms[ i ]\n cd[ i + 1 ] = atoms[ i + 1 ]\n cd[ i + 2 ] = atoms[ i + 2 ]\n if (is4X4) cd[ i + 3 ] = 1\n }\n }\n } else {\n Log.warn('prepCoords: input type unknown')\n }\n }\n\n transform (atoms: Structure|Float32Array) {\n // allocate data structures\n\n let n\n if (atoms instanceof Structure) {\n n = atoms.atomCount\n } else if (atoms instanceof Float32Array) {\n n = atoms.length / 3\n } else {\n return\n }\n\n const coords = new Matrix(4, n)\n const tCoords = new Matrix(n,4)\n\n // prep coords\n\n this.prepCoords(atoms, coords, n, true)\n\n // check for transformation matrix correctness\n\n const transform = this.transformationMatrix\n const det = transform.determinant()\n if (!det){\n return det\n }\n\n // do transform\n\n const mult = new Matrix(4,4)\n mult.data = transform.elements as unknown as Float32Array\n multiply(tCoords,coords,mult)\n\n let i = 0\n const cd = tCoords.data\n if (atoms instanceof Structure) {\n atoms.eachAtom(function (a) {\n a.x = cd[ i ]\n a.y = cd[ i + 1 ]\n a.z = cd[ i + 2 ]\n i += 4\n })\n\n //update transformation matrices for each assembly\n\n const invertTrasform = new Matrix4()\n invertTrasform.getInverse(transform)\n\n const biomolDict = atoms.biomolDict\n\n for (let key in biomolDict) {\n\n if (biomolDict.hasOwnProperty(key)) {\n let assembly = biomolDict[key]\n\n assembly.partList.forEach(function(part){\n\n part.matrixList.forEach(function(mat){\n\n mat.premultiply(transform)\n mat.multiply(invertTrasform)\n\n })\n })\n }\n }\n } else if (atoms instanceof Float32Array) {\n\n const n4 = n * 4\n for (; i < n4; i += 4){\n\n atoms[ i ] = cd[ i ]\n atoms[ i + 1 ] = cd[ i + 1 ]\n atoms[ i + 2 ] = cd[ i + 2 ]\n\n }\n } else {\n Log.warn('transform: input type unknown')\n }\n\n return this.transformationMatrix\n }\n}\nexport default Superposition\n","/**\n * @file Trajectory Player\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { defaults, createParams, updateParams } from '../utils'\nimport Trajectory from './trajectory'\n\nexport type TrajectoryPlayerInterpolateType = ''|'linear'|'spline'\nexport type TrajectoryPlayerMode = 'loop'|'once'\nexport type TrajectoryPlayerDirection = 'forward'|'backward'|'bounce'\n\nexport const TrajectoryPlayerDefaultParameters = {\n step: 1, // how many frames to advance when playing\n timeout: 50, // how many milliseconds to wait between playing frames\n start: 0, // first frame to play\n end: 0, // last frame to play\n interpolateType: '' as TrajectoryPlayerInterpolateType,\n interpolateStep: 5, // window size used for interpolation\n mode: 'loop' as TrajectoryPlayerMode,\n direction: 'forward' as TrajectoryPlayerDirection\n}\nexport type TrajectoryPlayerParameters = typeof TrajectoryPlayerDefaultParameters\n\nexport interface TrajectoryPlayerSignals {\n startedRunning: Signal\n haltedRunning: Signal\n}\n\n/**\n * Trajectory player for animating coordinate frames\n * @example\n * var player = new TrajectoryPlayer(trajectory, {step: 1, timeout: 50});\n * player.play();\n */\nclass TrajectoryPlayer {\n signals: TrajectoryPlayerSignals = {\n startedRunning: new Signal(),\n haltedRunning: new Signal()\n }\n\n parameters: TrajectoryPlayerParameters\n traj: Trajectory\n\n private _run = false\n private _previousTime = 0\n private _currentTime = 0\n private _currentStep = 1\n private _currentFrame: number|[number, number, number, number]\n private _direction: TrajectoryPlayerDirection\n\n /**\n * make trajectory player\n * @param {Trajectory} traj - the trajectory\n * @param {TrajectoryPlayerParameters} [params] - parameter object\n */\n constructor (traj: Trajectory, params: Partial = {}) {\n traj.signals.playerChanged.add((player: TrajectoryPlayer) => {\n if (player !== this) {\n this.pause()\n }\n }, this)\n\n const n = defaults(traj.frameCount, 1)\n\n this.traj = traj\n this.parameters = createParams(params, TrajectoryPlayerDefaultParameters)\n this.parameters.end = Math.min(defaults(params.end, n - 1), n - 1)\n this.parameters.step = defaults(params.step, Math.ceil((n + 1) / 100))\n\n this._currentFrame = this.parameters.start\n this._direction = this.parameters.direction === 'bounce' ? 'forward' : this.parameters.direction\n\n traj.signals.countChanged.add((n: number) => {\n this.parameters.end = Math.min(defaults(this.parameters.end, n - 1), n - 1)\n }, this)\n\n this._animate = this._animate.bind(this)\n }\n\n get isRunning () { return this._run }\n\n /**\n * set player parameters\n * @param {TrajectoryPlayerParameters} [params] - parameter object\n */\n setParameters (params: Partial = {}) {\n updateParams(this.parameters, params)\n\n if (params.direction !== undefined && this.parameters.direction !== 'bounce') {\n this._direction = this.parameters.direction\n }\n }\n\n _animate () {\n if (!this._run) return\n\n this._currentTime = window.performance.now()\n const dt = this._currentTime - this._previousTime\n const step = this.parameters.interpolateType ? this.parameters.interpolateStep : 1\n const timeout = this.parameters.timeout / step\n const traj = this.traj\n\n if (traj && traj.frameCount && !traj.inProgress && dt >= timeout) {\n if (this.parameters.interpolateType) {\n if (this._currentStep > this.parameters.interpolateStep) {\n this._currentStep = 1\n }\n if (this._currentStep === 1) {\n this._currentFrame = this._nextInterpolated()\n }\n if (traj.hasFrame(this._currentFrame)) {\n this._currentStep += 1\n const t = this._currentStep / (this.parameters.interpolateStep + 1)\n const [i, ip, ipp, ippp] = this._currentFrame as [number, number, number, number]\n traj.setFrameInterpolated(\n i, ip, ipp, ippp, t, this.parameters.interpolateType\n )\n this._previousTime = this._currentTime\n } else {\n traj.loadFrame(this._currentFrame)\n }\n } else {\n const i = this._next()\n if (traj.hasFrame(i)) {\n traj.setFrame(i)\n this._previousTime = this._currentTime\n } else {\n traj.loadFrame(i)\n }\n }\n }\n\n window.requestAnimationFrame(this._animate)\n }\n\n _next () {\n const p = this.parameters\n let i\n\n if (this._direction === 'forward') {\n i = this.traj.currentFrame + p.step\n } else {\n i = this.traj.currentFrame - p.step\n }\n\n if (i > p.end || i < p.start) {\n if (p.direction === 'bounce') {\n if (this._direction === 'forward') {\n this._direction = 'backward'\n } else {\n this._direction = 'forward'\n }\n }\n\n if (p.mode === 'once') {\n this.pause()\n\n if (p.direction === 'forward') {\n i = p.end\n } else if (p.direction === 'backward') {\n i = p.start\n } else {\n if (this._direction === 'forward') {\n i = p.start\n } else {\n i = p.end\n }\n }\n } else {\n if (this._direction === 'forward') {\n i = p.start\n if (p.interpolateType) {\n i = Math.min(p.end, i + p.step)\n }\n } else {\n i = p.end\n if (p.interpolateType) {\n i = Math.max(p.start, i - p.step)\n }\n }\n }\n }\n\n return i\n }\n\n _nextInterpolated () {\n const p = this.parameters\n const i = this._next()\n let ip, ipp, ippp\n\n if (this._direction === 'forward') {\n ip = Math.max(p.start, i - p.step)\n ipp = Math.max(p.start, i - 2 * p.step)\n ippp = Math.max(p.start, i - 3 * p.step)\n } else {\n ip = Math.min(p.end, i + p.step)\n ipp = Math.min(p.end, i + 2 * p.step)\n ippp = Math.min(p.end, i + 3 * p.step)\n }\n\n return [i, ip, ipp, ippp] as [number, number, number, number]\n }\n\n /**\n * toggle between playing and pausing the animation\n * @return {undefined}\n */\n toggle () {\n if (this._run) {\n this.pause()\n } else {\n this.play()\n }\n }\n\n /**\n * start the animation\n * @return {undefined}\n */\n play () {\n if (!this._run) {\n if (this.traj.player !== this) {\n this.traj.setPlayer(this)\n }\n this._currentStep = 1\n\n const p = this.parameters\n const frame = this.traj.currentFrame\n\n // snap to the grid implied by this.step division and multiplication\n // thus minimizing cache misses\n let i = Math.ceil(frame / p.step) * p.step\n // wrap when restarting from the limit (i.e. end or start)\n if (p.direction === 'forward' && frame >= p.end) {\n i = p.start\n } else if (p.direction === 'backward' && frame <= p.start) {\n i = p.end\n }\n\n this.traj.setFrame(i)\n\n this._run = true\n this._animate()\n this.signals.startedRunning.dispatch()\n }\n }\n\n /**\n * pause the animation\n * @return {undefined}\n */\n pause () {\n this._run = false\n this.signals.haltedRunning.dispatch()\n }\n\n /**\n * stop the animation (pause and go to start-frame)\n * @return {undefined}\n */\n stop () {\n this.pause()\n this.traj.setFrame(this.parameters.start)\n }\n}\n\nexport default TrajectoryPlayer\n","/**\n * @file Trajectory\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { Log } from '../globals'\nimport { defaults } from '../utils'\nimport { NumberArray } from '../types'\nimport { circularMean, arrayMean } from '../math/array-utils'\nimport { lerp, spline } from '../math/math-utils'\nimport Selection from '../selection/selection'\nimport Superposition from '../align/superposition'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\nimport TrajectoryPlayer, { TrajectoryPlayerInterpolateType } from './trajectory-player'\n\n\nfunction centerPbc (coords: NumberArray, mean: number[], box: ArrayLike) {\n if (box[ 0 ] === 0 || box[ 8 ] === 0 || box[ 4 ] === 0) {\n return\n }\n\n const n = coords.length\n\n const bx = box[ 0 ]\n const by = box[ 1 ]\n const bz = box[ 2 ]\n const mx = mean[ 0 ]\n const my = mean[ 1 ]\n const mz = mean[ 2 ]\n\n const fx = -mx + bx + bx / 2\n const fy = -my + by + by / 2\n const fz = -mz + bz + bz / 2\n\n for (let i = 0; i < n; i += 3) {\n coords[ i + 0 ] = (coords[ i + 0 ] + fx) % bx\n coords[ i + 1 ] = (coords[ i + 1 ] + fy) % by\n coords[ i + 2 ] = (coords[ i + 2 ] + fz) % bz\n }\n}\n\nfunction removePbc (x: NumberArray, box: ArrayLike) {\n if (box[ 0 ] === 0 || box[ 8 ] === 0 || box[ 4 ] === 0) {\n return\n }\n\n // ported from GROMACS src/gmxlib/rmpbc.c:rm_gropbc()\n // in-place\n\n const n = x.length\n\n for (let i = 3; i < n; i += 3) {\n for (let j = 0; j < 3; ++j) {\n const dist = x[ i + j ] - x[ i - 3 + j ]\n\n if (Math.abs(dist) > 0.9 * box[ j * 3 + j ]) {\n if (dist > 0) {\n for (let d = 0; d < 3; ++d) {\n x[ i + d ] -= box[ j * 3 + d ]\n }\n } else {\n for (let d = 0; d < 3; ++d) {\n x[ i + d ] += box[ j * 3 + d ]\n }\n }\n }\n }\n }\n\n return x\n}\n\nfunction removePeriodicity (x: NumberArray, box: ArrayLike, mean: number[]) {\n if (box[ 0 ] === 0 || box[ 8 ] === 0 || box[ 4 ] === 0) {\n return\n }\n\n const n = x.length\n for (let i = 3; i < n; i += 3) {\n for (let j = 0; j < 3; ++j) {\n const f = (x[ i + j ] - mean[ j ]) / box[ j * 3 + j ]\n if (Math.abs(f) > 0.5) {\n x[ i + j ] -= box[ j * 3 + j ] * Math.round(f)\n }\n }\n }\n\n return x\n}\n\nfunction circularMean3 (indices: NumberArray, coords: NumberArray, box: ArrayLike) {\n return [\n circularMean(coords, box[ 0 ], 3, 0, indices),\n circularMean(coords, box[ 1 ], 3, 1, indices),\n circularMean(coords, box[ 2 ], 3, 2, indices)\n ]\n}\n\nfunction arrayMean3 (coords: NumberArray) {\n return [\n arrayMean(coords, 3, 0),\n arrayMean(coords, 3, 1),\n arrayMean(coords, 3, 2)\n ]\n}\n\nfunction interpolateSpline (c: NumberArray, cp: NumberArray, cpp: NumberArray, cppp: NumberArray, t: number) {\n const m = c.length\n const coords = new Float32Array(m)\n\n for (let j0 = 0; j0 < m; j0 += 3) {\n const j1 = j0 + 1\n const j2 = j0 + 2\n coords[ j0 ] = spline(cppp[ j0 ], cpp[ j0 ], cp[ j0 ], c[ j0 ], t, 1)\n coords[ j1 ] = spline(cppp[ j1 ], cpp[ j1 ], cp[ j1 ], c[ j1 ], t, 1)\n coords[ j2 ] = spline(cppp[ j2 ], cpp[ j2 ], cp[ j2 ], c[ j2 ], t, 1)\n }\n\n return coords\n}\n\nfunction interpolateLerp (c: NumberArray, cp: NumberArray, t: number) {\n const m = c.length\n const coords = new Float32Array(m)\n\n for (let j0 = 0; j0 < m; j0 += 3) {\n const j1 = j0 + 1\n const j2 = j0 + 2\n coords[ j0 ] = lerp(cp[ j0 ], c[ j0 ], t)\n coords[ j1 ] = lerp(cp[ j1 ], c[ j1 ], t)\n coords[ j2 ] = lerp(cp[ j2 ], c[ j2 ], t)\n }\n\n return coords\n}\n\n/**\n * Trajectory parameter object.\n * @typedef {Object} TrajectoryParameters - parameters\n *\n * @property {Number} deltaTime - timestep between frames in picoseconds\n * @property {Number} timeOffset - starting time of frames in picoseconds\n * @property {String} sele - to restrict atoms used for superposition\n * @property {Boolean} centerPbc - center on initial frame\n * @property {Boolean} removePeriodicity - move atoms into the origin box\n * @property {Boolean} remo - try fixing periodic boundary discontinuities\n * @property {Boolean} superpose - superpose on initial frame\n */\n\n/**\n * @example\n * trajectory.signals.frameChanged.add( function(i){ ... } );\n *\n * @typedef {Object} TrajectorySignals\n * @property {Signal} countChanged - when the frame count is changed\n * @property {Signal} frameChanged - when the set frame is changed\n * @property {Signal} playerChanged - when the player is changed\n */\n\nexport interface TrajectoryParameters {\n deltaTime: number // timestep between frames in picoseconds\n timeOffset: number // starting time of frames in picoseconds\n sele: string // to restrict atoms used for superposition\n centerPbc: boolean // center on initial frame\n removePbc: boolean // move atoms into the origin box\n removePeriodicity: boolean // try fixing periodic boundary discontinuities\n superpose: boolean // superpose on initial frame\n}\n\nexport interface TrajectorySignals {\n countChanged: Signal\n frameChanged: Signal\n playerChanged: Signal\n}\n\n/**\n * Base class for trajectories, tying structures and coordinates together\n * @interface\n */\nclass Trajectory {\n signals: TrajectorySignals = {\n countChanged: new Signal(),\n frameChanged: new Signal(),\n playerChanged: new Signal()\n }\n\n deltaTime: number\n timeOffset: number\n sele: string\n centerPbc: boolean\n removePbc: boolean\n removePeriodicity: boolean\n superpose: boolean\n\n name: string\n frame: number\n trajPath: string\n\n initialCoords: Float32Array\n structureCoords: Float32Array\n selectionIndices: NumberArray\n backboneIndices: NumberArray\n\n coords1: Float32Array\n coords2: Float32Array\n\n frameCache: { [k: number]: Float32Array } = {}\n loadQueue: { [k: number]: boolean } = {}\n boxCache: { [k: number]: ArrayLike } = {}\n pathCache = {}\n frameCacheSize = 0\n\n atomCount: number\n inProgress: boolean\n\n selection: Selection // selection to restrict atoms used for superposition\n structure: Structure\n player: TrajectoryPlayer\n\n private _frameCount = 0\n private _currentFrame = -1\n private _disposed = false\n\n /**\n * @param {String} trajPath - trajectory source\n * @param {Structure} structure - the structure object\n * @param {TrajectoryParameters} params - trajectory parameters\n */\n constructor (trajPath: string, structure: Structure, params: Partial = {}) {\n this.deltaTime = defaults(params.deltaTime, 0)\n this.timeOffset = defaults(params.timeOffset, 0)\n this.centerPbc = defaults(params.centerPbc, false)\n this.removePbc = defaults(params.removePbc, false)\n this.removePeriodicity = defaults(params.removePeriodicity, false)\n this.superpose = defaults(params.superpose, false)\n\n this.name = trajPath.replace(/^.*[\\\\/]/, '')\n this.trajPath = trajPath\n\n this.selection = new Selection(\n defaults(params.sele, 'backbone and not hydrogen')\n )\n\n this.selection.signals.stringChanged.add(() => {\n this.selectionIndices = this.structure.getAtomIndices(this.selection)!\n this._resetCache()\n this._saveInitialCoords()\n this.setFrame(this._currentFrame)\n })\n }\n\n /**\n * Number of frames in the trajectory\n */\n get frameCount () {\n return this._frameCount\n }\n\n /**\n * Currently set frame of the trajectory\n */\n get currentFrame () {\n return this._currentFrame\n }\n\n _init (structure: Structure) {\n this.setStructure(structure)\n this._loadFrameCount()\n this.setPlayer(new TrajectoryPlayer(this))\n }\n\n _loadFrameCount () {}\n\n setStructure (structure: Structure) {\n this.structure = structure\n this.atomCount = structure.atomCount\n\n this.backboneIndices = this._getIndices(\n new Selection('backbone and not hydrogen')\n )\n this._makeAtomIndices()\n this._saveStructureCoords()\n\n this.selectionIndices = this._getIndices(this.selection)\n this._resetCache()\n this._saveInitialCoords()\n this.setFrame(this._currentFrame)\n }\n\n _saveInitialCoords () {\n if (this.structure.hasCoords()) {\n this.initialCoords = new Float32Array(this.structureCoords)\n this._makeSuperposeCoords()\n } else if (this.frameCache[0]) {\n this.initialCoords = new Float32Array(this.frameCache[0])\n this._makeSuperposeCoords()\n } else {\n this.loadFrame(0, () => this._saveInitialCoords())\n }\n }\n\n _saveStructureCoords () {\n const p = { what: { position: true } }\n this.structureCoords = this.structure.getAtomData(p).position!\n }\n\n setSelection (string: string) {\n this.selection.setString(string)\n return this\n }\n\n _getIndices (selection: Selection) {\n let i = 0\n const test = selection.test\n const indices: number[] = []\n\n if (test) {\n this.structure.eachAtom((ap: AtomProxy) => {\n if (test(ap)) indices.push(i)\n i += 1\n })\n }\n\n return indices\n }\n\n _makeSuperposeCoords () {\n const n = this.selectionIndices.length * 3\n\n this.coords1 = new Float32Array(n)\n this.coords2 = new Float32Array(n)\n\n const y = this.initialCoords\n const coords2 = this.coords2\n\n for (let i = 0; i < n; i += 3) {\n const j = this.selectionIndices[ i / 3 ] * 3\n\n coords2[ i + 0 ] = y[ j + 0 ]\n coords2[ i + 1 ] = y[ j + 1 ]\n coords2[ i + 2 ] = y[ j + 2 ]\n }\n }\n\n _makeAtomIndices () {\n Log.error('Trajectory._makeAtomIndices not implemented')\n }\n\n _resetCache () {\n this.frameCache = {}\n this.loadQueue = {}\n this.boxCache = {}\n this.pathCache = {}\n this.frameCacheSize = 0\n this.initialCoords = new Float32Array(0)\n }\n\n setParameters (params: Partial = {}) {\n let resetCache = false\n\n if (params.centerPbc !== undefined && params.centerPbc !== this.centerPbc) {\n this.centerPbc = params.centerPbc\n resetCache = true\n }\n\n if (params.removePeriodicity !== undefined && params.removePeriodicity !== this.removePeriodicity) {\n this.removePeriodicity = params.removePeriodicity\n resetCache = true\n }\n\n if (params.removePbc !== undefined && params.removePbc !== this.removePbc) {\n this.removePbc = params.removePbc\n resetCache = true\n }\n\n if (params.superpose !== undefined && params.superpose !== this.superpose) {\n this.superpose = params.superpose\n resetCache = true\n }\n\n this.deltaTime = defaults(params.deltaTime, this.deltaTime)\n this.timeOffset = defaults(params.timeOffset, this.timeOffset)\n\n if (resetCache) {\n this._resetCache()\n this.setFrame(this._currentFrame)\n }\n }\n\n /**\n * Check if a frame is available\n * @param {Integer|Integer[]} i - the frame index\n * @return {Boolean} frame availability\n */\n hasFrame (i: number|number[]) {\n if (Array.isArray(i)) {\n return i.every(j => !!this.frameCache[j])\n } else {\n return !!this.frameCache[i]\n }\n }\n\n /**\n * Set trajectory to a frame index\n * @param {Integer} i - the frame index\n * @param {Function} [callback] - fired when the frame has been set\n */\n setFrame (i: number, callback?: Function) {\n if (i === undefined) return this\n\n this.inProgress = true\n\n // i = parseInt(i) // TODO\n\n if (i === -1 || this.frameCache[ i ]) {\n this._updateStructure(i)\n if (callback) callback()\n } else {\n this.loadFrame(i, () => {\n this._updateStructure(i)\n if (callback) callback()\n })\n }\n\n return this\n }\n\n _interpolate (i: number, ip: number, ipp: number, ippp: number, t: number, type: TrajectoryPlayerInterpolateType) {\n const fc = this.frameCache\n\n let coords\n if (type === 'spline') {\n coords = interpolateSpline(fc[ i ], fc[ ip ], fc[ ipp ], fc[ ippp ], t)\n } else {\n coords = interpolateLerp(fc[ i ], fc[ ip ], t)\n }\n\n this.structure.updatePosition(coords)\n this._currentFrame = i\n this.signals.frameChanged.dispatch(i)\n }\n\n /**\n * Interpolated and set trajectory to frame indices\n * @param {Integer} i - the frame index\n * @param {Integer} ip - one before frame index\n * @param {Integer} ipp - two before frame index\n * @param {Integer} ippp - three before frame index\n * @param {Number} t - interpolation step [0,1]\n * @param {String} type - interpolation type, '', 'spline' or 'linear'\n * @param {Function} callback - fired when the frame has been set\n */\n setFrameInterpolated (i: number, ip: number, ipp: number, ippp: number, t: number, type: TrajectoryPlayerInterpolateType, callback?: Function) {\n if (i === undefined) return this\n\n const fc = this.frameCache\n const iList: number[] = []\n\n if (!fc[ ippp ]) iList.push(ippp)\n if (!fc[ ipp ]) iList.push(ipp)\n if (!fc[ ip ]) iList.push(ip)\n if (!fc[ i ]) iList.push(i)\n\n if (iList.length) {\n this.loadFrame(iList, () => {\n this._interpolate(i, ip, ipp, ippp, t, type)\n if (callback) callback()\n })\n } else {\n this._interpolate(i, ip, ipp, ippp, t, type)\n if (callback) callback()\n }\n\n return this\n }\n\n /**\n * Load frame index\n * @param {Integer|Integer[]} i - the frame index\n * @param {Function} callback - fired when the frame has been loaded\n */\n loadFrame (i: number|number[], callback?: Function) {\n if (Array.isArray(i)) {\n i.forEach(j => {\n if (!this.loadQueue[j] && !this.frameCache[j]) {\n this.loadQueue[j] = true\n this._loadFrame(j, () => {\n delete this.loadQueue[j]\n })\n }\n })\n } else {\n if (!this.loadQueue[i] && !this.frameCache[i]) {\n this.loadQueue[i] = true\n this._loadFrame(i, () => {\n delete this.loadQueue[i]\n if (callback) callback()\n })\n }\n }\n }\n\n /**\n * Load frame index\n * @abstract\n * @param {Integer} i - the frame index\n * @param {Function} callback - fired when the frame has been loaded\n */\n _loadFrame (i: number, callback?: Function) {\n Log.error('Trajectory._loadFrame not implemented', i, callback)\n }\n\n _updateStructure (i: number) {\n if (this._disposed) {\n console.error('updateStructure: traj disposed')\n return\n }\n\n if (i === -1) {\n if (this.structureCoords) {\n this.structure.updatePosition(this.structureCoords)\n }\n } else {\n this.structure.updatePosition(this.frameCache[ i ])\n }\n\n this.structure.trajectory = {\n name: this.trajPath,\n frame: i\n }\n\n this._currentFrame = i\n this.inProgress = false\n this.signals.frameChanged.dispatch(i)\n }\n\n _doSuperpose (x: Float32Array) {\n const n = this.selectionIndices.length * 3\n\n const coords1 = this.coords1\n const coords2 = this.coords2\n\n for (let i = 0; i < n; i += 3) {\n const j = this.selectionIndices[ i / 3 ] * 3\n\n coords1[ i + 0 ] = x[ j + 0 ]\n coords1[ i + 1 ] = x[ j + 1 ]\n coords1[ i + 2 ] = x[ j + 2 ]\n }\n\n // TODO re-use superposition object\n const sp = new Superposition(coords1, coords2)\n sp.transform(x)\n }\n\n _process (i: number, box: ArrayLike, coords: Float32Array, frameCount: number) {\n this._setFrameCount(frameCount)\n\n if (box) {\n if (this.backboneIndices.length > 0 && this.centerPbc) {\n const box2 = [ box[ 0 ], box[ 4 ], box[ 8 ] ]\n const circMean = circularMean3(this.backboneIndices, coords, box2)\n centerPbc(coords, circMean, box2)\n }\n\n if (this.removePeriodicity) {\n const mean = arrayMean3(coords)\n removePeriodicity(coords, box, mean)\n }\n\n if (this.removePbc) {\n removePbc(coords, box)\n }\n }\n\n if (this.selectionIndices.length > 0 && this.coords1 && this.superpose) {\n this._doSuperpose(coords)\n }\n\n this.frameCache[ i ] = coords\n this.boxCache[ i ] = box\n this.frameCacheSize += 1\n }\n\n _setFrameCount (n: number) {\n if (n !== this._frameCount) {\n this._frameCount = n\n this.signals.countChanged.dispatch(n)\n }\n }\n\n /**\n * Dispose of the trajectory object\n * @return {undefined}\n */\n dispose () {\n this._resetCache() // aid GC\n this._disposed = true\n if (this.player) this.player.stop()\n }\n\n /**\n * Set player for this trajectory\n * @param {TrajectoryPlayer} player - the player\n */\n setPlayer (player: TrajectoryPlayer) {\n this.player = player\n this.signals.playerChanged.dispatch(player)\n }\n\n /**\n * Get time for frame\n * @param {Integer} i - frame index\n * @return {Number} time in picoseconds\n */\n getFrameTime (i: number) {\n return this.timeOffset + i * this.deltaTime\n }\n}\n\nexport default Trajectory\n","/**\n * @file Frames Trajectory\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport Structure from '../structure/structure'\nimport Frames from './frames'\nimport Trajectory, { TrajectoryParameters } from './trajectory'\n\n/**\n * Frames trajectory class. Gets data from a frames object.\n */\nclass FramesTrajectory extends Trajectory {\n path: string\n\n frames: ArrayLike[]\n boxes: ArrayLike[]\n\n atomIndices?: ArrayLike\n\n constructor (frames: Frames, structure: Structure, params: TrajectoryParameters) {\n const p = params || {}\n p.timeOffset = defaults(p.timeOffset, frames.timeOffset)\n p.deltaTime = defaults(p.deltaTime, frames.deltaTime)\n\n super('', structure, p)\n\n this.name = frames.name\n this.path = frames.path\n\n this.frames = frames.coordinates\n this.boxes = frames.boxes\n\n this._init(structure)\n }\n\n get type () { return 'frames' }\n\n _makeAtomIndices () {\n if (this.structure.type === 'StructureView') {\n this.atomIndices = this.structure.getAtomIndices()\n } else {\n this.atomIndices = undefined\n }\n }\n\n _loadFrame (i: number, callback?: Function) {\n let coords\n const frame = this.frames[ i ]\n\n if (this.atomIndices) {\n const indices = this.atomIndices\n const m = indices.length\n\n coords = new Float32Array(m * 3)\n\n for (let j = 0; j < m; ++j) {\n const j3 = j * 3\n const idx3 = indices[ j ] * 3\n\n coords[ j3 + 0 ] = frame[ idx3 + 0 ]\n coords[ j3 + 1 ] = frame[ idx3 + 1 ]\n coords[ j3 + 2 ] = frame[ idx3 + 2 ]\n }\n } else {\n coords = new Float32Array(frame)\n }\n\n const box = this.boxes[ i ]\n const frameCount = this.frames.length\n\n this._process(i, box, coords, frameCount)\n\n if (typeof callback === 'function') {\n callback()\n }\n }\n\n _loadFrameCount () {\n if (this.frames) {\n this._setFrameCount(this.frames.length)\n }\n }\n}\n\nexport default FramesTrajectory\n","/**\n * @file Structure Trajectory\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Trajectory, { TrajectoryParameters } from './trajectory'\n\n/**\n * Structure trajectory class. Gets data from a structure object.\n */\nclass StructureTrajectory extends Trajectory {\n atomIndices?: ArrayLike\n\n constructor (trajPath: string, structure: Structure, params: TrajectoryParameters) {\n super('', structure, params)\n this._init(structure)\n }\n\n get type () { return 'structure' }\n\n _makeAtomIndices () {\n if (this.structure.atomSet && this.structure.atomSet.getSize() < this.structure.atomStore.count) {\n this.atomIndices = this.structure.getAtomIndices()\n } else {\n this.atomIndices = undefined\n }\n }\n\n _loadFrame (i: number, callback?: Function) {\n let coords\n const structure = this.structure\n const frame = structure.frames[ i ]\n\n if (this.atomIndices) {\n const indices = this.atomIndices\n const m = indices.length\n\n coords = new Float32Array(m * 3)\n\n for (let j = 0; j < m; ++j) {\n const j3 = j * 3\n const idx3 = indices[ j ] * 3\n\n coords[ j3 + 0 ] = frame[ idx3 + 0 ]\n coords[ j3 + 1 ] = frame[ idx3 + 1 ]\n coords[ j3 + 2 ] = frame[ idx3 + 2 ]\n }\n } else {\n coords = new Float32Array(frame)\n }\n\n const box = structure.boxes[ i ]\n const frameCount = structure.frames.length\n\n this._process(i, box, coords, frameCount)\n\n if (typeof callback === 'function') {\n callback()\n }\n }\n\n _loadFrameCount () {\n this._setFrameCount(this.structure.frames.length)\n }\n}\n\nexport default StructureTrajectory\n","/**\n * @file Remote Trajectory\n * @author Alexander Rose \n * @private\n */\n\nimport { Log, TrajectoryDatasource } from '../globals'\nimport Structure from '../structure/structure'\nimport Trajectory, { TrajectoryParameters } from './trajectory'\n\n/**\n * Remote trajectory class. Gets data from an MDsrv instance.\n */\nclass RemoteTrajectory extends Trajectory {\n atomIndices: number[][]\n\n constructor (trajPath: string, structure: Structure, params: TrajectoryParameters) {\n super(trajPath, structure, params)\n this._init(structure)\n }\n\n get type () { return 'remote' }\n\n _makeAtomIndices () {\n const atomIndices = []\n\n if (this.structure.type === 'StructureView') {\n const indices = this.structure.getAtomIndices()! // TODO\n const n = indices.length\n\n let p = indices[ 0 ]\n let q = indices[ 0 ]\n\n for (let i = 1; i < n; ++i) {\n const r = indices[ i ]\n\n if (q + 1 < r) {\n atomIndices.push([ p, q + 1 ])\n p = r\n }\n\n q = r\n }\n\n atomIndices.push([ p, q + 1 ])\n } else {\n atomIndices.push([ 0, this.atomCount ])\n }\n\n this.atomIndices = atomIndices\n }\n\n _loadFrame (i: number, callback?: Function) {\n // TODO implement max frameCache size, re-use arrays\n\n const request = new XMLHttpRequest()\n\n const url = TrajectoryDatasource.getFrameUrl(this.trajPath, i)\n const params = TrajectoryDatasource.getFrameParams(this.trajPath, this.atomIndices)\n\n request.open('POST', url, true)\n request.responseType = 'arraybuffer'\n request.setRequestHeader(\n 'Content-type', 'application/x-www-form-urlencoded'\n )\n\n request.addEventListener('load', () => {\n const arrayBuffer = request.response\n if (!arrayBuffer) {\n Log.error(`empty arrayBuffer for '${url}'`)\n return\n }\n\n const frameCount = new Int32Array(arrayBuffer, 0, 1)[ 0 ]\n // const time = new Float32Array( arrayBuffer, 1 * 4, 1 )[ 0 ];\n const box = new Float32Array(arrayBuffer, 2 * 4, 9)\n const coords = new Float32Array(arrayBuffer, 11 * 4)\n\n this._process(i, box, coords, frameCount)\n if (typeof callback === 'function') {\n callback()\n }\n }, false)\n\n request.send(params)\n }\n\n _loadFrameCount () {\n const request = new XMLHttpRequest()\n\n const url = TrajectoryDatasource.getCountUrl(this.trajPath)\n\n request.open('GET', url, true)\n request.addEventListener('load', () => {\n this._setFrameCount(parseInt(request.response))\n }, false)\n request.send()\n }\n}\n\nexport default RemoteTrajectory\n","/**\n * @file Callback Trajectory\n * @author Tarn W. Burton \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Trajectory, { TrajectoryParameters } from './trajectory'\n\ntype RequestCallback = (responseCallback: Function, i?: number, atomIndices?: number[][]) => void\n\n/**\n * Callback trajectory class. Gets data from an JavaScript function.\n */\nclass CallbackTrajectory extends Trajectory {\n atomIndices: number[][]\n requestCallback: RequestCallback\n\n constructor (requestCallback: RequestCallback, structure: Structure, params: TrajectoryParameters) {\n super('', structure, params)\n this.requestCallback = requestCallback;\n this._init(structure)\n }\n\n get type () { return 'callback' }\n\n _makeAtomIndices () {\n const atomIndices = []\n\n if (this.structure.type === 'StructureView') {\n const indices = this.structure.getAtomIndices()! // TODO\n const n = indices.length\n\n let p = indices[ 0 ]\n let q = indices[ 0 ]\n\n for (let i = 1; i < n; ++i) {\n const r = indices[ i ]\n\n if (q + 1 < r) {\n atomIndices.push([ p, q + 1 ])\n p = r\n }\n\n q = r\n }\n\n atomIndices.push([ p, q + 1 ])\n } else {\n atomIndices.push([ 0, this.atomCount ])\n }\n\n this.atomIndices = atomIndices\n }\n\n _loadFrame (i: number, callback?: Function) {\n this.requestCallback(\n (i: number, box: ArrayLike, coords: Float32Array, frameCount: number) => {\n this._process(i, box, coords, frameCount)\n if (typeof callback === 'function') {\n callback()\n }\n }, i, this.atomIndices)\n }\n\n _loadFrameCount () {\n this.requestCallback((count: number) => this._setFrameCount(count))\n }\n}\n\nexport default CallbackTrajectory\n\n","/**\n * @file Structure View\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3 } from 'three'\n\nimport { Debug, Log } from '../globals'\nimport Structure from './structure'\nimport Selection from '../selection/selection'\nimport BitArray from '../utils/bitarray'\n\nimport BondProxy from '../proxy/bond-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\nimport SpatialHash from '../geometry/spatial-hash';\nimport BondHash from '../store/bond-hash';\nimport ResidueMap from '../store/residue-map';\nimport AtomMap from '../store/atom-map';\nimport ModelStore from '../store/model-store';\nimport ChainStore from '../store/chain-store';\nimport ResidueStore from '../store/residue-store';\nimport AtomStore from '../store/atom-store';\nimport BondStore from '../store/bond-store';\nimport Validation from './validation';\nimport Unitcell from '../symmetry/unitcell';\nimport Entity from './entity';\nimport Assembly from '../symmetry/assembly';\nimport { Data } from './data';\n\n/**\n * Get view on structure restricted to the selection\n * @param {Selection} selection - the selection\n * @return {StructureView} the view on the structure\n */\nStructure.prototype.getView = function (this: Structure, selection: Selection) {\n // added here to avoid cyclic import dependency\n return new StructureView(this, selection)\n}\n\n/**\n * View on the structure, restricted to the selection\n */\nclass StructureView extends Structure {\n structure: Structure\n selection: Selection\n\n /**\n * @param {Structure} structure - the structure\n * @param {Selection} selection - the selection\n */\n constructor (structure: Structure, selection: Selection) {\n super()\n\n this.structure = structure\n this.selection = selection\n\n this.center = new Vector3()\n this.boundingBox = new Box3()\n\n this._bp = this.getBondProxy()\n this._ap = this.getAtomProxy()\n this._rp = this.getResidueProxy()\n this._cp = this.getChainProxy()\n\n if (this.selection) {\n this.selection.signals.stringChanged.add(this.refresh, this)\n }\n\n this.structure.signals.refreshed.add(this.refresh, this)\n\n this.refresh()\n }\n\n init () {}\n\n get type () { return 'StructureView' }\n\n get name () { return this.structure.name }\n get path () { return this.structure.path }\n get title () { return this.structure.title }\n get id () { return this.structure.id }\n get data (): Data { return this.structure.data }\n get atomSetDict () { return this.structure.atomSetDict }\n get biomolDict (): {[k: string]: Assembly} { return this.structure.biomolDict }\n get entityList (): Entity[] { return this.structure.entityList }\n get unitcell (): Unitcell|undefined { return this.structure.unitcell }\n get frames () { return this.structure.frames }\n get boxes () { return this.structure.boxes }\n get validation (): Validation|undefined { return this.structure.validation }\n get bondStore () { return this.structure.bondStore }\n get backboneBondStore () { return this.structure.backboneBondStore }\n get rungBondStore (): BondStore { return this.structure.rungBondStore }\n get atomStore (): AtomStore { return this.structure.atomStore }\n get residueStore (): ResidueStore { return this.structure.residueStore }\n get chainStore (): ChainStore { return this.structure.chainStore }\n get modelStore (): ModelStore { return this.structure.modelStore }\n get atomMap (): AtomMap { return this.structure.atomMap }\n get residueMap (): ResidueMap { return this.structure.residueMap }\n get bondHash (): BondHash|undefined { return this.structure.bondHash }\n get spatialHash (): SpatialHash|undefined { return this.structure.spatialHash }\n\n get _hasCoords () { return this.structure._hasCoords }\n set _hasCoords (value) { this.structure._hasCoords = value }\n\n /**\n * Updates atomSet, bondSet, atomSetCache, atomCount, bondCount, boundingBox, center.\n * @emits {Structure.signals.refreshed} when refreshed\n * @return {undefined}\n */\n refresh () {\n if (Debug) Log.time('StructureView.refresh')\n\n this.atomSetCache = {}\n const structure = this.structure\n\n if (this.selection.isAllSelection() &&\n structure !== this && structure.atomSet && structure.bondSet\n ) {\n this.atomSet = structure.atomSet.clone()\n this.bondSet = structure.bondSet.clone()\n\n for (let name in this.atomSetDict) {\n const atomSet = this.atomSetDict[ name ]\n this.atomSetCache[ '__' + name ] = atomSet.clone()\n }\n\n this.atomCount = structure.atomCount\n this.bondCount = structure.bondCount\n\n this.boundingBox.copy(structure.boundingBox)\n this.center.copy(structure.center)\n } else if (this.selection.isNoneSelection() &&\n structure !== this && structure.atomSet && structure.bondSet\n ) {\n this.atomSet = new BitArray(structure.atomCount)\n this.bondSet = new BitArray(structure.bondCount)\n\n for (let name in this.atomSetDict) {\n this.atomSetCache[ '__' + name ] = new BitArray(structure.atomCount)\n }\n\n this.atomCount = 0\n this.bondCount = 0\n\n this.boundingBox.makeEmpty()\n this.center.set(0, 0, 0)\n } else {\n this.atomSet = this.getAtomSet(this.selection, true)\n if (structure.atomSet) {\n this.atomSet = this.atomSet.intersection(structure.atomSet)\n }\n\n this.bondSet = this.getBondSet()\n\n for (let name in this.atomSetDict) {\n const atomSet = this.atomSetDict[ name ]\n this.atomSetCache[ '__' + name ] = atomSet.makeIntersection(this.atomSet)\n }\n\n this.atomCount = this.atomSet.getSize()\n this.bondCount = this.bondSet.getSize()\n\n this.boundingBox = this.getBoundingBox()\n this.center = this.boundingBox.getCenter(new Vector3())\n }\n\n if (Debug) Log.timeEnd('StructureView.refresh')\n\n this.signals.refreshed.dispatch()\n }\n\n //\n\n setSelection (selection: Selection) {\n this.selection = selection\n\n this.refresh()\n }\n\n getSelection (selection?: Selection) {\n const seleList: string[] = []\n\n if (selection && selection.string) {\n seleList.push(selection.string)\n }\n\n const parentSelection = this.structure.getSelection()\n if (parentSelection && parentSelection.string) {\n seleList.push(parentSelection.string)\n }\n\n if (this.selection && this.selection.string) {\n seleList.push(this.selection.string)\n }\n\n let sele = ''\n if (seleList.length > 0) {\n sele = `( ${seleList.join(' ) AND ( ')} )`\n }\n\n return new Selection(sele)\n }\n\n getStructure () {\n return this.structure.getStructure()\n }\n\n //\n\n eachBond (callback: (entity: BondProxy) => any, selection?: Selection) {\n this.structure.eachBond(callback, this.getSelection(selection))\n }\n\n eachAtom (callback: (entity: AtomProxy) => any, selection?: Selection) {\n const ap = this.getAtomProxy()\n const atomSet = this.getAtomSet(selection)\n const n = this.atomStore.count\n\n if (atomSet.getSize() < n) {\n atomSet.forEach(function (index) {\n ap.index = index\n callback(ap)\n })\n } else {\n for (let i = 0; i < n; ++i) {\n ap.index = i\n callback(ap)\n }\n }\n }\n\n eachResidue (callback: (entity: ResidueProxy) => any, selection?: Selection) {\n this.structure.eachResidue(callback, this.getSelection(selection))\n }\n\n /**\n * Not implemented\n * @alias StructureView#eachResidueN\n * @return {undefined}\n */\n eachResidueN (n: number, callback: (entity: ResidueProxy) => any) {\n console.error('StructureView.eachResidueN() not implemented')\n }\n\n eachChain (callback: (entity: ChainProxy) => any, selection?: Selection) {\n this.structure.eachChain(callback, this.getSelection(selection))\n }\n\n eachModel (callback: (entity: ModelProxy) => any, selection?: Selection) {\n this.structure.eachModel(callback, this.getSelection(selection))\n }\n\n //\n\n getAtomSet (selection?: boolean|Selection|BitArray, ignoreView = false) {\n let atomSet = this.structure.getAtomSet(selection)\n if (!ignoreView && this.atomSet) {\n atomSet = atomSet.makeIntersection(this.atomSet)\n }\n\n return atomSet\n }\n\n //\n\n getAtomIndices (selection?: Selection) {\n return this.structure.getAtomIndices(this.getSelection(selection))\n }\n\n refreshPosition () {\n return this.structure.refreshPosition()\n }\n\n //\n\n dispose () {\n if (this.selection) {\n this.selection.signals.stringChanged.remove(this.refresh, this)\n }\n\n this.structure.signals.refreshed.remove(this.refresh, this)\n\n this.structure = new Structure() // delete old data\n\n delete this.atomSet\n delete this.bondSet\n\n }\n}\n\nexport default StructureView\n","/**\n * @file Alignment\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log } from '../globals'\n\n// const nucleotides = 'ACTG';\nconst aminoacidsX = 'ACDEFGHIKLMNPQRSTVWY'\nconst aminoacids = 'ARNDCQEGHILKMFPSTWYVBZ?'\n\nconst blosum62x = [\n [4, 0, -2, -1, -2, 0, -2, -1, -1, -1, -1, -2, -1, -1, -1, 1, 0, 0, -3, -2], // A\n [0, 9, -3, -4, -2, -3, -3, -1, -3, -1, -1, -3, -3, -3, -3, -1, -1, -1, -2, -2], // C\n [-2, -3, 6, 2, -3, -1, -1, -3, -1, -4, -3, 1, -1, 0, -2, 0, -1, -3, -4, -3], // D\n [-1, -4, 2, 5, -3, -2, 0, -3, 1, -3, -2, 0, -1, 2, 0, 0, -1, -2, -3, -2], // E\n [-2, -2, -3, -3, 6, -3, -1, 0, -3, 0, 0, -3, -4, -3, -3, -2, -2, -1, 1, 3], // F\n [0, -3, -1, -2, -3, 6, -2, -4, -2, -4, -3, 0, -2, -2, -2, 0, -2, -3, -2, -3], // G\n [-2, -3, -1, 0, -1, -2, 8, -3, -1, -3, -2, 1, -2, 0, 0, -1, -2, -3, -2, 2], // H\n [-1, -1, -3, -3, 0, -4, -3, 4, -3, 2, 1, -3, -3, -3, -3, -2, -1, 3, -3, -1], // I\n [-1, -3, -1, 1, -3, -2, -1, -3, 5, -2, -1, 0, -1, 1, 2, 0, -1, -2, -3, -2], // K\n [-1, -1, -4, -3, 0, -4, -3, 2, -2, 4, 2, -3, -3, -2, -2, -2, -1, 1, -2, -1], // L\n [-1, -1, -3, -2, 0, -3, -2, 1, -1, 2, 5, -2, -2, 0, -1, -1, -1, 1, -1, -1], // M\n [-2, -3, 1, 0, -3, 0, 1, -3, 0, -3, -2, 6, -2, 0, 0, 1, 0, -3, -4, -2], // N\n [-1, -3, -1, -1, -4, -2, -2, -3, -1, -3, -2, -2, 7, -1, -2, -1, -1, -2, -4, -3], // P\n [-1, -3, 0, 2, -3, -2, 0, -3, 1, -2, 0, 0, -1, 5, 1, 0, -1, -2, -2, -1], // Q\n [-1, -3, -2, 0, -3, -2, 0, -3, 2, -2, -1, 0, -2, 1, 5, -1, -1, -3, -3, -2], // R\n [1, -1, 0, 0, -2, 0, -1, -2, 0, -2, -1, 1, -1, 0, -1, 4, 1, -2, -3, -2], // S\n [0, -1, -1, -1, -2, -2, -2, -1, -1, -1, -1, 0, -1, -1, -1, 1, 5, 0, -2, -2], // T\n [0, -1, -3, -2, -1, -3, -3, 3, -2, 1, 1, -3, -2, -2, -3, -2, 0, 4, -3, -1], // V\n [-3, -2, -4, -3, 1, -2, -2, -3, -3, -2, -1, -4, -4, -2, -3, -3, -2, -3, 11, 2], // W\n [-2, -2, -3, -2, 3, -3, 2, -1, -2, -1, -1, -2, -3, -1, -2, -2, -2, -1, 2, 7] // Y\n]\n\nconst blosum62 = [\n // A R N D C Q E G H I L K M F P S T W Y V B Z X\n [4, -1, -2, -2, 0, -1, -1, 0, -2, -1, -1, -1, -1, -2, -1, 1, 0, -3, -2, 0, -2, -1, 0], // A\n [-1, 5, 0, -2, -3, 1, 0, -2, 0, -3, -2, 2, -1, -3, -2, -1, -1, -3, -2, -3, -1, 0, -1], // R\n [-2, 0, 6, 1, -3, 0, 0, 0, 1, -3, -3, 0, -2, -3, -2, 1, 0, -4, -2, -3, 3, 0, -1], // N\n [-2, -2, 1, 6, -3, 0, 2, -1, -1, -3, -4, -1, -3, -3, -1, 0, -1, -4, -3, -3, 4, 1, -1], // D\n [0, -3, -3, -3, 9, -3, -4, -3, -3, -1, -1, -3, -1, -2, -3, -1, -1, -2, -2, -1, -3, -3, -2], // C\n [-1, 1, 0, 0, -3, 5, 2, -2, 0, -3, -2, 1, 0, -3, -1, 0, -1, -2, -1, -2, 0, 3, -1], // Q\n [-1, 0, 0, 2, -4, 2, 5, -2, 0, -3, -3, 1, -2, -3, -1, 0, -1, -3, -2, -2, 1, 4, -1], // E\n [0, -2, 0, -1, -3, -2, -2, 6, -2, -4, -4, -2, -3, -3, -2, 0, -2, -2, -3, -3, -1, -2, -1], // G\n [-2, 0, 1, -1, -3, 0, 0, -2, 8, -3, -3, -1, -2, -1, -2, -1, -2, -2, 2, -3, 0, 0, -1], // H\n [-1, -3, -3, -3, -1, -3, -3, -4, -3, 4, 2, -3, 1, 0, -3, -2, -1, -3, -1, 3, -3, -3, -1], // I\n [-1, -2, -3, -4, -1, -2, -3, -4, -3, 2, 4, -2, 2, 0, -3, -2, -1, -2, -1, 1, -4, -3, -1], // L\n [-1, 2, 0, -1, -3, 1, 1, -2, -1, -3, -2, 5, -1, -3, -1, 0, -1, -3, -2, -2, 0, 1, -1], // K\n [-1, -1, -2, -3, -1, 0, -2, -3, -2, 1, 2, -1, 5, 0, -2, -1, -1, -1, -1, 1, -3, -1, -1], // M\n [-2, -3, -3, -3, -2, -3, -3, -3, -1, 0, 0, -3, 0, 6, -4, -2, -2, 1, 3, -1, -3, -3, -1], // F\n [-1, -2, -2, -1, -3, -1, -1, -2, -2, -3, -3, -1, -2, -4, 7, -1, -1, -4, -3, -2, -2, -1, -2], // P\n [1, -1, 1, 0, -1, 0, 0, 0, -1, -2, -2, 0, -1, -2, -1, 4, 1, -3, -2, -2, 0, 0, 0], // S\n [0, -1, 0, -1, -1, -1, -1, -2, -2, -1, -1, -1, -1, -2, -1, 1, 5, -2, -2, 0, -1, -1, 0], // T\n [-3, -3, -4, -4, -2, -2, -3, -2, -2, -3, -2, -3, -1, 1, -4, -3, -2, 11, 2, -3, -4, -3, -2], // W\n [-2, -2, -2, -3, -2, -1, -2, -3, 2, -1, -1, -2, -1, 3, -3, -2, -2, 2, 7, -1, -3, -2, -1], // Y\n [0, -3, -3, -3, -1, -2, -2, -3, -3, 3, 1, -2, 1, -1, -2, -2, 0, -3, -1, 4, -3, -2, -1], // V\n [-2, -1, 3, 4, -3, 0, 1, -1, 0, -3, -4, 0, -3, -3, -2, 0, -1, -4, -3, -3, 4, 1, -1], // B\n [-1, 0, 0, 1, -3, 3, 4, -2, 0, -3, -3, 1, -1, -3, -1, 0, -1, -3, -2, -2, 1, 4, -1], // Z\n [0, -1, -1, -1, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, 0, 0, -2, -1, -1, -1, -1, -1] // X\n]\n\nfunction prepareMatrix (cellNames: string, mat: number[][]) {\n let j: number\n let i = 0\n const matDict: { [k: string]: { [k: string]: number } } = {}\n mat.forEach(function (row) {\n j = 0\n const rowDict: { [k: string]: number } = {}\n row.forEach(function (elm) {\n rowDict[ cellNames[ j++ ] ] = elm\n })\n matDict[ cellNames[ i++ ] ] = rowDict\n })\n return matDict\n}\n\nconst SubstitutionMatrices = (function () {\n return {\n blosum62: prepareMatrix(aminoacids, blosum62),\n blosum62x: prepareMatrix(aminoacidsX, blosum62x)\n }\n}())\nexport type SubstitutionMatrix = ''|'blosum62'|'blosum62x'\n\nclass Alignment {\n substMatrix: { [k: string]: { [k: string]: number } }\n\n n: number\n m: number\n score?: number\n ali: string\n\n S: number[][]\n V: number[][]\n H: number[][]\n\n ali1: string\n ali2: string\n\n constructor (readonly seq1: string, readonly seq2: string, readonly gapPenalty = -10, readonly gapExtensionPenalty = -1, substMatrix: SubstitutionMatrix = 'blosum62') {\n // TODO try encoding seqs as integers and use array subst matrix, maybe faster\n\n if (substMatrix) {\n this.substMatrix = SubstitutionMatrices[ substMatrix ]\n }\n }\n\n initMatrices () {\n this.n = this.seq1.length\n this.m = this.seq2.length\n\n // Log.log(this.n, this.m);\n\n this.score = undefined\n this.ali = ''\n\n this.S = []\n this.V = []\n this.H = []\n\n for (let i = 0; i <= this.n; ++i) {\n this.S[ i ] = []\n this.V[ i ] = []\n this.H[ i ] = []\n\n for (let j = 0; j <= this.m; ++j) {\n this.S[ i ][ j ] = 0\n this.V[ i ][ j ] = 0\n this.H[ i ][ j ] = 0\n }\n }\n\n for (let i = 0; i <= this.n; ++i) {\n this.S[ i ][ 0 ] = this.gap(0)\n this.H[ i ][ 0 ] = -Infinity\n }\n\n for (let j = 0; j <= this.m; ++j) {\n this.S[ 0 ][ j ] = this.gap(0)\n this.V[ 0 ][ j ] = -Infinity\n }\n\n this.S[ 0 ][ 0 ] = 0\n\n // Log.log(this.S, this.V, this.H);\n }\n\n gap (len: number) {\n return this.gapPenalty + len * this.gapExtensionPenalty\n }\n\n makeScoreFn () {\n const seq1 = this.seq1\n const seq2 = this.seq2\n\n const substMatrix = this.substMatrix\n\n if (substMatrix) {\n return function score (i: number, j: number) {\n const c1 = seq1[ i ]\n const c2 = seq2[ j ]\n\n try {\n return substMatrix[ c1 ][ c2 ]\n } catch (e) {\n return -4\n }\n }\n } else {\n Log.warn('Alignment: no subst matrix')\n\n return function scoreNoSubstMat (i: number, j: number) {\n const c1 = seq1[ i ]\n const c2 = seq2[ j ]\n\n return c1 === c2 ? 5 : -3\n }\n }\n }\n\n calc () {\n if (Debug) Log.time('Alignment.calc')\n\n this.initMatrices()\n\n const gap0 = this.gap(0)\n const scoreFn = this.makeScoreFn()\n const gapExtensionPenalty = this.gapExtensionPenalty\n\n const V = this.V\n const H = this.H\n const S = this.S\n\n const n = this.n\n const m = this.m\n\n let Vi1, Si1, Vi, Hi, Si\n\n for (let i = 1; i <= n; ++i) {\n Si1 = S[ i - 1 ]\n Vi1 = V[ i - 1 ]\n\n Vi = V[ i ]\n Hi = H[ i ]\n Si = S[ i ]\n\n for (let j = 1; j <= m; ++j) {\n Vi[j] = Math.max(\n Si1[ j ] + gap0,\n Vi1[ j ] + gapExtensionPenalty\n )\n\n Hi[j] = Math.max(\n Si[ j - 1 ] + gap0,\n Hi[ j - 1 ] + gapExtensionPenalty\n )\n\n Si[j] = Math.max(\n Si1[ j - 1 ] + scoreFn(i - 1, j - 1), // match\n Vi[ j ], // del\n Hi[ j ] // ins\n )\n }\n }\n\n if (Debug) Log.timeEnd('Alignment.calc')\n\n if (Debug) Log.log(this.S, this.V, this.H)\n }\n\n trace () {\n if (Debug) Log.time('Alignment.trace')\n\n this.ali1 = ''\n this.ali2 = ''\n\n const scoreFn = this.makeScoreFn()\n\n let i = this.n\n let j = this.m\n let mat\n\n if (this.S[i][j] >= this.V[i][j]) {\n mat = 'S'\n this.score = this.S[i][j]\n } else if (this.V[i][j] >= this.H[i][j]) {\n mat = 'V'\n this.score = this.V[i][j]\n } else {\n mat = 'H'\n this.score = this.H[i][j]\n }\n\n if (Debug) Log.log('Alignment: SCORE', this.score)\n if (Debug) Log.log('Alignment: S, V, H', this.S[i][j], this.V[i][j], this.H[i][j])\n\n while (i > 0 && j > 0) {\n if (mat === 'S') {\n if (this.S[i][j] === this.S[i - 1][j - 1] + scoreFn(i - 1, j - 1)) {\n this.ali1 = this.seq1[i - 1] + this.ali1\n this.ali2 = this.seq2[j - 1] + this.ali2\n --i\n --j\n mat = 'S'\n } else if (this.S[i][j] === this.V[i][j]) {\n mat = 'V'\n } else if (this.S[i][j] === this.H[i][j]) {\n mat = 'H'\n } else {\n // Log.debug('Alignment: S');\n --i\n --j\n }\n } else if (mat === 'V') {\n if (this.V[i][j] === this.V[i - 1][j] + this.gapExtensionPenalty) {\n this.ali1 = this.seq1[i - 1] + this.ali1\n this.ali2 = '-' + this.ali2\n --i\n mat = 'V'\n } else if (this.V[i][j] === this.S[i - 1][j] + this.gap(0)) {\n this.ali1 = this.seq1[i - 1] + this.ali1\n this.ali2 = '-' + this.ali2\n --i\n mat = 'S'\n } else {\n // Log.debug('Alignment: V');\n --i\n }\n } else if (mat === 'H') {\n if (this.H[i][j] === this.H[i][j - 1] + this.gapExtensionPenalty) {\n this.ali1 = '-' + this.ali1\n this.ali2 = this.seq2[j - 1] + this.ali2\n --j\n mat = 'H'\n } else if (this.H[i][j] === this.S[i][j - 1] + this.gap(0)) {\n this.ali1 = '-' + this.ali1\n this.ali2 = this.seq2[j - 1] + this.ali2\n --j\n mat = 'S'\n } else {\n // Log.debug('Alignment: H');\n --j\n }\n } else {\n Log.error('Alignment: no matrix')\n }\n }\n\n while (i > 0) {\n this.ali1 = this.seq1[ i - 1 ] + this.ali1\n this.ali2 = '-' + this.ali2\n --i\n }\n\n while (j > 0) {\n this.ali1 = '-' + this.ali1\n this.ali2 = this.seq2[ j - 1 ] + this.ali2\n --j\n }\n\n if (Debug) Log.timeEnd('Alignment.trace')\n\n if (Debug) Log.log([this.ali1, this.ali2])\n }\n}\n\nexport default Alignment\n","/**\n * @file Align Utils\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\nimport Alignment from './alignment'\nimport Superposition from './superposition'\n\n/**\n * Perform structural superposition of two structures,\n * optionally guided by a sequence alignment\n * @param {Structure|StructureView} s1 - structure 1 which is superposed onto structure 2\n * @param {Structure|StructureView} s2 - structure 2 onto which structure 1 is superposed\n * @param {Boolean} [align] - guide the superposition by a sequence alignment\n * @param {String} [sele1] - selection string for structure 1\n * @param {String} [sele2] - selection string for structure 2\n * @return {undefined}\n */\nfunction superpose (s1: Structure, s2: Structure, align = false, sele1 = '', sele2 = '') {\n let i: number\n let j: number\n let n: number\n let atoms1\n let atoms2\n\n if (align) {\n let _s1 = s1\n let _s2 = s2\n\n if (sele1 && sele2) {\n _s1 = s1.getView(new Selection(sele1))\n _s2 = s2.getView(new Selection(sele2))\n }\n\n const seq1 = _s1.getSequence()\n const seq2 = _s2.getSequence()\n\n // Log.log( seq1.join(\"\") );\n // Log.log( seq2.join(\"\") );\n\n const ali = new Alignment(seq1.join(''), seq2.join(''))\n\n ali.calc()\n ali.trace()\n\n // Log.log( \"superpose alignment score\", ali.score );\n\n // Log.log( ali.ali1 );\n // Log.log( ali.ali2 );\n\n let _i, _j\n i = 0\n j = 0\n n = ali.ali1.length\n const aliIdx1: boolean[] = []\n const aliIdx2: boolean[] = []\n\n for (let l = 0; l < n; ++l) {\n const x = ali.ali1[ l ]\n const y = ali.ali2[ l ]\n\n _i = 0\n _j = 0\n\n if (x === '-') {\n aliIdx2[ j ] = false\n } else {\n aliIdx2[ j ] = true\n _i = 1\n }\n\n if (y === '-') {\n aliIdx1[ i ] = false\n } else {\n aliIdx1[ i ] = true\n _j = 1\n }\n\n i += _i\n j += _j\n }\n\n // Log.log( i, j );\n\n // Log.log( aliIdx1 );\n // Log.log( aliIdx2 );\n\n const _atoms1: number[] = []\n const _atoms2: number[] = []\n const ap1 = _s1.getAtomProxy()\n const ap2 = _s2.getAtomProxy()\n\n i = 0\n _s1.eachResidue(function (r) {\n if (r.traceAtomIndex === undefined ||\n r.traceAtomIndex !== r.getAtomIndexByName('CA')) return\n\n if (aliIdx1[ i ]) {\n ap1.index = r.getAtomIndexByName('CA')! // TODO\n _atoms1.push(ap1.x, ap1.y, ap1.z)\n }\n i += 1\n })\n\n i = 0\n _s2.eachResidue(function (r) {\n if (r.traceAtomIndex === undefined ||\n r.traceAtomIndex !== r.getAtomIndexByName('CA')) return\n\n if (aliIdx2[ i ]) {\n ap2.index = r.getAtomIndexByName('CA')! // TODO\n _atoms2.push(ap2.x, ap2.y, ap2.z)\n }\n i += 1\n })\n\n atoms1 = new Float32Array(_atoms1)\n atoms2 = new Float32Array(_atoms2)\n } else {\n const sviewCa1 = s1.getView(new Selection(`${sele1} and .CA`))\n const sviewCa2 = s2.getView(new Selection(`${sele2} and .CA`))\n\n atoms1 = sviewCa1\n atoms2 = sviewCa2\n }\n\n const superpose = new Superposition(atoms1, atoms2)\n const result = superpose.transform(s1)\n s1.refreshPosition()\n return result\n}\n\nexport {\n superpose\n}\n","/**\n * @file Sturucture Component\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { ComponentRegistry, MeasurementDefaultParams } from '../globals'\nimport {\n defaults, /*deepEqual, */createRingBuffer, RingBuffer, createSimpleDict, SimpleDict\n} from '../utils'\nimport { smoothstep } from '../math/math-utils'\nimport Component, { ComponentSignals, ComponentDefaultParameters } from './component'\nimport RepresentationCollection from './representation-collection'\nimport TrajectoryElement from './trajectory-element'\nimport RepresentationElement from './representation-element'\nimport { makeTrajectory } from '../trajectory/trajectory-utils'\nimport { TrajectoryParameters } from '../trajectory/trajectory'\nimport Selection from '../selection/selection'\nimport Structure from '../structure/structure'\nimport StructureView from '../structure/structure-view'\nimport { superpose } from '../align/align-utils'\nimport Stage from '../stage/stage'\nimport StructureRepresentation, { StructureRepresentationParameters } from '../representation/structure-representation'\nimport AtomProxy from '../proxy/atom-proxy'\nimport { Vector3, Box3 } from 'three';\nimport { AngleRepresentationParameters } from '../representation/angle-representation';\nimport { AxesRepresentationParameters } from '../representation/axes-representation';\nimport { BallAndStickRepresentationParameters } from '../representation/ballandstick-representation';\nimport { CartoonRepresentationParameters } from '../representation/cartoon-representation';\nimport { ContactRepresentationParameters } from '../representation/contact-representation';\nimport { DihedralRepresentationParameters } from '../representation/dihedral-representation';\nimport { DihedralHistogramRepresentationParameters } from '../representation/dihedral-histogram-representation';\nimport { DistanceRepresentationParameters } from '../representation/distance-representation';\nimport { HyperballRepresentationParameters } from '../representation/hyperball-representation';\nimport { LabelRepresentationParameters } from '../representation/label-representation';\nimport { LineRepresentationParameters } from '../representation/line-representation';\nimport { PointRepresentationParameters } from '../representation/point-representation';\nimport { SurfaceRepresentationParameters } from '../representation/surface-representation';\nimport { RibbonRepresentationParameters } from '../representation/ribbon-representation';\nimport { RocketRepresentationParameters } from '../representation/rocket-representation';\nimport { TraceRepresentationParameters } from '../representation/trace-representation';\nimport { UnitcellRepresentationParameters } from '../representation/unitcell-representation';\nimport { SliceRepresentationParameters } from '../representation/slice-representation'\nimport { MolecularSurfaceRepresentationParameters } from '../representation/molecularsurface-representation'\nimport { DotRepresentationParameters } from '../representation/dot-representation'\n\nexport type StructureRepresentationType = keyof StructureRepresentationParametersMap\n\ninterface StructureRepresentationParametersMap {\n 'angle': AngleRepresentationParameters,\n 'axes' : AxesRepresentationParameters,\n 'backbone': BallAndStickRepresentationParameters,\n 'ball+stick': BallAndStickRepresentationParameters,\n 'base': BallAndStickRepresentationParameters,\n 'cartoon': CartoonRepresentationParameters,\n 'contact': ContactRepresentationParameters,\n 'dihedral': DihedralRepresentationParameters,\n 'dihedral-histogram': DihedralHistogramRepresentationParameters,\n 'distance': DistanceRepresentationParameters,\n 'dot': DotRepresentationParameters,\n 'helixorient': StructureRepresentationParameters,\n 'hyperball': HyperballRepresentationParameters,\n 'label': LabelRepresentationParameters,\n 'licorice': BallAndStickRepresentationParameters,\n 'line': LineRepresentationParameters,\n 'molecularsurface': MolecularSurfaceRepresentationParameters,\n 'point': PointRepresentationParameters,\n 'ribbon': RibbonRepresentationParameters,\n 'rocket': RocketRepresentationParameters,\n 'rope': CartoonRepresentationParameters,\n 'slice': SliceRepresentationParameters,\n 'spacefill': BallAndStickRepresentationParameters,\n 'surface': SurfaceRepresentationParameters,\n 'trace': TraceRepresentationParameters,\n 'tube': CartoonRepresentationParameters,\n 'unitcell': UnitcellRepresentationParameters,\n 'validation': StructureRepresentationParameters\n}\n\nexport const StructureComponentDefaultParameters = Object.assign({\n sele: '',\n defaultAssembly: ''\n}, ComponentDefaultParameters)\nexport type StructureComponentParameters = typeof StructureComponentDefaultParameters\n\nexport interface StructureComponentSignals extends ComponentSignals {\n trajectoryAdded: Signal // when a trajectory is added\n trajectoryRemoved: Signal // when a trajectory is removed\n defaultAssemblyChanged: Signal // on default assembly change\n}\n\n/**\n * Component wrapping a {@link Structure} object\n *\n * @example\n * // get a structure component by loading a structure file into the stage\n * stage.loadFile( \"rcsb://4opj\" ).then( function( structureComponent ){\n * structureComponent.addRepresentation( \"cartoon\" );\n * structureComponent.autoView();\n * } );\n */\nclass StructureComponent extends Component {\n readonly signals: StructureComponentSignals\n readonly parameters: StructureComponentParameters\n get defaultParameters () { return StructureComponentDefaultParameters }\n\n selection: Selection\n structureView: StructureView\n readonly trajList: TrajectoryElement[] = []\n\n pickBuffer: RingBuffer\n pickDict: SimpleDict\n lastPick?: number\n\n spacefillRepresentation: RepresentationElement\n distanceRepresentation: RepresentationElement\n angleRepresentation: RepresentationElement\n dihedralRepresentation: RepresentationElement\n\n measureRepresentations: RepresentationCollection\n\n constructor (stage: Stage, readonly structure: Structure, params: Partial = {}) {\n super(stage, structure, Object.assign({ name: structure.name }, params))\n\n this.signals = Object.assign(this.signals, {\n trajectoryAdded: new Signal(),\n trajectoryRemoved: new Signal(),\n defaultAssemblyChanged: new Signal()\n })\n\n this.initSelection(this.parameters.sele)\n\n //\n\n this.pickBuffer = createRingBuffer(4)\n this.pickDict = createSimpleDict()\n\n this.spacefillRepresentation = this.addRepresentation('spacefill', {\n sele: 'none',\n opacity: MeasurementDefaultParams.opacity,\n color: MeasurementDefaultParams.color,\n disablePicking: true,\n radiusType: 'data'\n }, true)\n\n this.distanceRepresentation = this.addRepresentation(\n 'distance', MeasurementDefaultParams, true\n )\n this.angleRepresentation = this.addRepresentation(\n 'angle', MeasurementDefaultParams, true\n )\n this.dihedralRepresentation = this.addRepresentation(\n 'dihedral', MeasurementDefaultParams, true\n )\n\n this.measureRepresentations = new RepresentationCollection([\n this.spacefillRepresentation,\n this.distanceRepresentation,\n this.angleRepresentation,\n this.dihedralRepresentation\n ])\n\n //\n\n this.setDefaultAssembly(this.parameters.defaultAssembly)\n\n this.structure.signals.refreshed.add(() => {\n this.updateRepresentations({ position: true })\n })\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'structure' }\n\n /**\n * Initialize selection\n * @private\n * @param {String} sele - selection string\n * @return {undefined}\n */\n initSelection (sele: string) {\n /**\n * Selection for {@link StructureComponent#structureView}\n * @private\n * @type {Selection}\n */\n this.selection = new Selection(sele)\n\n /**\n * View on {@link StructureComponent#structure}.\n * Change its selection via {@link StructureComponent#setSelection}.\n * @type {StructureView}\n */\n this.structureView = new StructureView(\n this.structure, this.selection\n )\n\n this.selection.signals.stringChanged.add(() => {\n this.structureView.setSelection(this.selection)\n\n this.rebuildRepresentations()\n this.rebuildTrajectories()\n })\n }\n\n /**\n * Set selection of {@link StructureComponent#structureView}\n * @param {String} string - selection string\n * @return {StructureComponent} this object\n */\n setSelection (string: string) {\n this.parameters.sele = string\n this.selection.setString(string)\n return this\n }\n\n /**\n * Set the default assembly\n * @param {String} value - assembly name\n * @return {undefined}\n */\n setDefaultAssembly (value:string) {\n // filter out non-exsisting assemblies\n if (this.structure.biomolDict[value] === undefined) value = ''\n // only set default assembly when changed\n if (this.parameters.defaultAssembly !== value) {\n const reprParams = { defaultAssembly: value }\n this.reprList.forEach(repr => repr.setParameters(reprParams))\n this.measureRepresentations.setParameters(reprParams)\n this.parameters.defaultAssembly = value\n this.signals.defaultAssemblyChanged.dispatch(value)\n }\n return this\n }\n\n /**\n * Rebuild all representations\n * @return {undefined}\n */\n rebuildRepresentations () {\n this.reprList.forEach((repr: RepresentationElement) => {\n repr.build()\n })\n this.measureRepresentations.build()\n }\n\n /**\n * Rebuild all trajectories\n * @return {undefined}\n */\n rebuildTrajectories () {\n this.trajList.forEach(trajComp => {\n trajComp.trajectory.setStructure(this.structureView)\n })\n }\n\n updateRepresentations (what: any) {\n super.updateRepresentations(what)\n this.measureRepresentations.update(what)\n }\n\n /**\n * Overrides {@link Component.updateRepresentationMatrices} \n * to also update matrix for measureRepresentations \n */\n updateRepresentationMatrices () {\n super.updateRepresentationMatrices()\n this.measureRepresentations.setParameters({ matrix: this.matrix })\n }\n\n addRepresentation (\n type: K,\n params: Partial|{defaultAssembly: string} = {},\n hidden = false\n ) {\n params.defaultAssembly = this.parameters.defaultAssembly\n\n const reprComp = this._addRepresentation(type, this.structureView, params, hidden)\n if (!hidden) {\n reprComp.signals.parametersChanged.add(() => this.measureUpdate())\n }\n return reprComp\n }\n\n /**\n * Add a new trajectory component to the structure\n */\n addTrajectory (trajPath = '', params: { [k: string]: any } = {}) {\n const traj = makeTrajectory(trajPath, this.structureView, params as TrajectoryParameters)\n\n const trajComp = new TrajectoryElement(this.stage, traj, params)\n this.trajList.push(trajComp)\n this.signals.trajectoryAdded.dispatch(trajComp)\n\n return trajComp\n }\n\n removeTrajectory (traj: TrajectoryElement) {\n const idx = this.trajList.indexOf(traj)\n if (idx !== -1) {\n this.trajList.splice(idx, 1)\n }\n\n traj.dispose()\n\n this.signals.trajectoryRemoved.dispatch(traj)\n }\n\n dispose () {\n // copy via .slice because side effects may change trajList\n this.trajList.slice().forEach(traj => traj.dispose())\n\n this.trajList.length = 0\n this.structure.dispose()\n this.measureRepresentations.dispose()\n\n super.dispose()\n }\n\n /**\n * Automatically center and zoom the component\n * @param {String|Integer} [sele] - selection string or duration if integer\n * @param {Integer} [duration] - duration of the animation, defaults to 0\n * @return {undefined}\n */\n autoView (sele?: string|number, duration?: number) {\n if (typeof sele === 'number') {\n duration = sele\n sele = ''\n }\n\n this.stage.animationControls.zoomMove(\n this.getCenter(sele),\n this.getZoom(sele),\n defaults(duration, 0)\n )\n }\n\n getBoxUntransformed (sele: string): Box3 {\n let bb\n\n if (sele) {\n bb = this.structureView.getBoundingBox(new Selection(sele))\n } else {\n bb = this.structureView.boundingBox\n }\n\n return bb\n }\n\n getCenterUntransformed (sele: string): Vector3 {\n if (sele && typeof sele === 'string') {\n return this.structure.atomCenter(new Selection(sele))\n } else {\n return this.structure.center\n }\n }\n\n superpose (component: StructureComponent, align: boolean, sele1: string, sele2: string) {\n superpose(\n this.structureView, component.structureView, align, sele1, sele2\n )\n\n this.updateRepresentations({ 'position': true })\n\n return this\n }\n\n getMaxRepresentationRadius (atomIndex: number) {\n let maxRadius = 0\n const atom = this.structure.getAtomProxy(atomIndex)\n this.eachRepresentation(reprElem => {\n if (reprElem.getVisibility()) {\n const repr: StructureRepresentation = reprElem.repr as any // TODO\n maxRadius = Math.max(repr.getAtomRadius(atom), maxRadius)\n }\n })\n return maxRadius\n }\n\n measurePick (atom: AtomProxy) {\n const pickCount = this.pickBuffer.count\n\n if (this.lastPick === atom.index && pickCount >= 1) {\n if (pickCount > 1) {\n const atomList = this.pickBuffer.data\n const atomListSorted = this.pickBuffer.data.sort()\n if (this.pickDict.has(atomListSorted)) {\n this.pickDict.del(atomListSorted)\n } else {\n this.pickDict.add(atomListSorted, atomList)\n }\n if (pickCount === 2) {\n this.distanceRepresentation.setParameters({\n atomPair: this.pickDict.values.filter(l => l.length === 2)\n })\n } else if (pickCount === 3) {\n this.angleRepresentation.setParameters({\n atomTriple: this.pickDict.values.filter(l => l.length === 3)\n })\n } else if (pickCount === 4) {\n this.dihedralRepresentation.setParameters({\n atomQuad: this.pickDict.values.filter(l => l.length === 4)\n })\n }\n }\n this.pickBuffer.clear()\n this.lastPick = undefined\n } else {\n if (!this.pickBuffer.has(atom.index)) {\n this.pickBuffer.push(atom.index)\n }\n this.lastPick = atom.index\n }\n\n this.measureUpdate()\n }\n\n measureClear () {\n this.pickBuffer.clear()\n this.lastPick = undefined\n this.spacefillRepresentation.setSelection('none')\n }\n\n measureBuild () {\n const md = this.measureData()\n this.distanceRepresentation.setParameters({ atomPair: md.distance })\n this.angleRepresentation.setParameters({ atomTriple: md.angle })\n this.dihedralRepresentation.setParameters({ atomQuad: md.dihedral })\n }\n\n measureUpdate () {\n const pickData = this.pickBuffer.data\n const radiusData: { [k: number]: number } = {}\n pickData.forEach(ai => {\n const r = Math.max(0.1, this.getMaxRepresentationRadius(ai))\n radiusData[ ai ] = r * (2.3 - smoothstep(0.1, 2, r))\n })\n this.spacefillRepresentation.setSelection(\n pickData.length ? ( '@' + pickData.join(',') ) : 'none'\n )\n if (pickData.length)\n this.spacefillRepresentation.setParameters({ radiusData })\n }\n\n measureData () {\n const pv = this.pickDict.values\n return {\n distance: pv.filter(l => l.length === 2),\n angle: pv.filter(l => l.length === 3),\n dihedral: pv.filter(l => l.length === 4)\n }\n }\n\n /**\n * Remove all measurements, optionally limit to distance, angle or dihedral\n */\n removeAllMeasurements (type?: MeasurementFlags) {\n const pd = this.pickDict\n const pv = pd.values\n const remove = function (len: number) {\n pv.filter(l => l.length === len).forEach(l => pd.del(l.slice().sort()))\n }\n if (!type || type & MeasurementFlags.Distance) remove(2)\n if (!type || type & MeasurementFlags.Angle) remove(3)\n if (!type || type & MeasurementFlags.Dihedral) remove(4)\n this.measureBuild()\n }\n\n /**\n * Remove a measurement given as a pair, triple, quad of atom indices\n */\n removeMeasurement (atomList: number[]) {\n this.pickDict.del(atomList.slice().sort())\n this.measureBuild()\n }\n\n /**\n * Add a measurement given as a pair, triple, quad of atom indices\n */\n addMeasurement (atomList: number[]) {\n if (atomList.length < 2 || atomList.length > 4) return\n const atomListSorted = atomList.slice().sort()\n if (!this.pickDict.has(atomListSorted)) {\n this.pickDict.add(atomListSorted, atomList)\n }\n this.measureBuild()\n }\n}\n\nexport const enum MeasurementFlags {\n Distance = 0x1,\n Angle = 0x2,\n Dihedral = 0x4\n}\n\nComponentRegistry.add('structure', StructureComponent)\nComponentRegistry.add('structureview', StructureComponent)\n\nexport default StructureComponent\n","/**\n * @file Trajectory Utils\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Frames from './frames'\nimport { TrajectoryParameters } from './trajectory'\nimport FramesTrajectory from './frames-trajectory'\nimport StructureTrajectory from './structure-trajectory'\nimport RemoteTrajectory from './remote-trajectory'\nimport CallbackTrajectory from './callback-trajectory'\n\nexport function makeTrajectory (trajSrc: string|Frames, structure: Structure, params: TrajectoryParameters) {\n let traj\n\n if (trajSrc && trajSrc instanceof Frames) {\n traj = new FramesTrajectory(trajSrc, structure, params)\n } else if (!trajSrc && structure.frames) {\n traj = new StructureTrajectory(trajSrc, structure, params)\n } else if (trajSrc && typeof trajSrc === 'function') {\n traj = new CallbackTrajectory(trajSrc, structure, params)\n } else {\n traj = new RemoteTrajectory(trajSrc, structure, params)\n }\n\n return traj\n}\n\n","/**\n * @file Surface Component\n * @author Alexander Rose \n * @private\n */\n\nimport { ComponentRegistry } from '../globals'\nimport Component, { ComponentParameters } from './component'\nimport Stage from '../stage/stage'\nimport Surface from '../surface/surface'\nimport { Vector3, Box3 } from 'three';\nimport RepresentationElement from './representation-element';\n\nexport type SurfaceRepresentationType = 'surface'|'dot'\n\n/**\n * Component wrapping a {@link Surface} object\n *\n * @example\n * // get a surface component by loading a surface file into the stage\n * stage.loadFile( \"url/for/surface\" ).then( function( surfaceComponent ){\n * surfaceComponent.addRepresentation( \"surface\" );\n * surfaceComponent.autoView();\n * } );\n */\nclass SurfaceComponent extends Component {\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {Surface} surface - surface object to wrap\n * @param {ComponentParameters} params - component parameters\n */\n constructor (stage: Stage, readonly surface: Surface, params: Partial = {}) {\n super(stage, surface, Object.assign({ name: surface.name }, params))\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'surface' }\n\n /**\n * Add a new surface representation to the component\n * @param {String} type - the name of the representation, one of:\n * surface, dot.\n * @param {SurfaceRepresentationParameters} params - representation parameters\n * @return {RepresentationComponent} the created representation wrapped into\n * a representation component object\n */\n addRepresentation (type: SurfaceRepresentationType, params: { [k: string]: any } = {}): RepresentationElement {\n return this._addRepresentation(type, this.surface, params)\n }\n\n getBoxUntransformed (): Box3 {\n return this.surface.boundingBox\n }\n\n getCenterUntransformed (): Vector3 {\n return this.surface.center\n }\n\n dispose () {\n this.surface.dispose()\n super.dispose()\n }\n}\n\nComponentRegistry.add('surface', SurfaceComponent)\n\nexport default SurfaceComponent\n","/**\n * @file Volume Component\n * @author Alexander Rose \n * @private\n */\n\nimport { ComponentRegistry } from '../globals'\nimport Component, { ComponentParameters } from './component'\nimport Stage from '../stage/stage'\nimport Volume from '../surface/volume'\nimport { Box3, Vector3 } from 'three';\nimport RepresentationElement from './representation-element';\n\nexport type VolumeRepresentationType = 'surface'|'slice'|'dot'\n\n/**\n * Component wrapping a {@link Volume} object\n *\n * @example\n * // get a volume component by loading a volume file into the stage\n * stage.loadFile( \"url/for/volume\" ).then(function(volumeComponent){\n * volumeComponent.addRepresentation('surface');\n * volumeComponent.autoView();\n * });\n */\nclass VolumeComponent extends Component {\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {Volume} volume - volume object to wrap\n * @param {ComponentParameters} params - component parameters\n */\n constructor (stage: Stage, readonly volume: Volume, params: Partial = {}) {\n super(stage, volume, Object.assign({ name: volume.name }, params))\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'volume' }\n\n /**\n * Add a new volume representation to the component\n */\n addRepresentation (type: VolumeRepresentationType, params: { [k: string]: any } = {}): RepresentationElement {\n return this._addRepresentation(type, this.volume, params)\n }\n\n getBoxUntransformed (): Box3 {\n return this.volume.boundingBox\n }\n\n getCenterUntransformed (): Vector3 {\n return this.volume.center\n }\n\n dispose () {\n this.volume.dispose()\n\n super.dispose()\n }\n}\n\nComponentRegistry.add('volume', VolumeComponent)\n\nexport default VolumeComponent\n","/**\n * @file Component Collection\n * @author Alexander Rose \n * @private\n */\n\nimport Component from './component'\nimport Collection from './collection'\n\nclass ComponentCollection extends Collection {\n addRepresentation (name: string, params: any) {\n \treturn this.forEach((comp) => comp.addRepresentation(name, params))\n }\n\n autoView (duration: number) {\n return this.forEach((comp) => comp.autoView(duration))\n }\n}\n\nexport default ComponentCollection\n","/**\n * @file Stage\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3 } from 'three'\nimport { Signal } from 'signals'\n\nimport {\n Debug, Log, Mobile, ComponentRegistry, ParserRegistry\n} from '../globals'\nimport { defaults, createParams, updateParams } from '../utils'\nimport { degToRad, clamp, pclamp } from '../math/math-utils'\nimport Counter from '../utils/counter'\nimport Viewer from '../viewer/viewer'\nimport { ImageParameters } from '../viewer/viewer-utils'\nimport MouseObserver from './mouse-observer'\n\nimport TrackballControls from '../controls/trackball-controls'\nimport PickingControls from '../controls/picking-controls'\nimport ViewerControls from '../controls/viewer-controls'\nimport AnimationControls from '../controls/animation-controls'\nimport MouseControls, { MouseControlPreset } from '../controls/mouse-controls'\nimport KeyControls from '../controls/key-controls'\n\nimport PickingBehavior from './picking-behavior'\nimport MouseBehavior from './mouse-behavior'\nimport AnimationBehavior from './animation-behavior'\nimport KeyBehavior from './key-behavior'\n\nimport Component, { ComponentParameters } from '../component/component'\nimport RepresentationElement from '../component/representation-element'\nimport StructureComponent from '../component/structure-component'\nimport SurfaceComponent from '../component/surface-component'\nimport VolumeComponent from '../component/volume-component'\nimport ComponentCollection from '../component/component-collection'\nimport RepresentationCollection from '../component/representation-collection'\nimport { autoLoad, getFileInfo, LoaderParameters } from '../loader/loader-utils'\nimport { ParserParams } from '../loader/parser-loader'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Animation from '../animation/animation'\nimport Selection from '../selection/selection'\n\nimport Structure from '../structure/structure'\nimport Surface from '../surface/surface'\nimport Volume from '../surface/volume'\nimport Shape from '../geometry/shape'\nimport Script from '../script'\n\nfunction matchName (name: string|RegExp, object: { name: string }) {\n if (name instanceof RegExp) {\n return object.name.match(name) !== null\n } else {\n return object.name === name\n }\n}\n\nconst tmpZoomVector = new Vector3()\n\ndeclare global {\n interface Document {\n mozFullScreen: boolean\n mozFullScreenEnabled: boolean\n mozFullScreenElement: Element\n mozCancelFullScreen(): void\n\n msFullscreenEnabled: boolean\n msFullscreenElement: Element\n msExitFullscreen(): void\n }\n\n interface Element {\n mozRequestFullScreen(): void\n msRequestFullscreen(): void\n }\n}\n\n/**\n * Stage parameter object.\n * @typedef {Object} StageParameters - stage parameters\n * @property {Color} backgroundColor - background color\n * @property {Integer} sampleLevel - sampling level for antialiasing, between -1 and 5;\n * -1: no sampling, 0: only sampling when not moving\n * @property {Boolean} workerDefault - default value for useWorker parameter of representations\n * @property {Float} rotateSpeed - camera-controls rotation speed, between 0 and 10\n * @property {Float} zoomSpeed - camera-controls zoom speed, between 0 and 10\n * @property {Float} panSpeed - camera-controls pan speed, between 0 and 10\n * @property {Float} clipNear - position of camera near/front clipping plane\n * in percent of scene bounding box\n * @property {Float} clipFar - position of camera far/back clipping plane\n * in percent of scene bounding box\n * @property {Float} clipDist - camera clipping distance in Angstrom\n * @property {String} clipMode - how to interpret clipNear/Far and fogNear/Far values: \"scene\" for scene-relative, \"camera\" for camera-relative\n * @property {String} clipScale - \"relative\" or \"absolute\": interpret clipNear/Far and fogNear/Far as percentage of bounding box or absolute Angstroms (ignored when clipMode==camera)\n * @property {Float} fogNear - position of the start of the fog effect\n * in percent of scene bounding box\n * @property {Float} fogFar - position where the fog is in full effect\n * in percent of scene bounding box\n * @property {String} cameraType - type of camera, either 'persepective' or 'orthographic'\n * @property {Float} cameraFov - perspective camera field of view in degree, between 15 and 120\n * @property {Float} cameraEyeSep - stereo camera eye seperation\n * @property {Color} lightColor - point light color\n * @property {Float} lightIntensity - point light intensity\n * @property {Color} ambientColor - ambient light color\n * @property {Float} ambientIntensity - ambient light intensity\n * @property {Integer} hoverTimeout - timeout for hovering\n */\n\nexport interface StageSignals {\n parametersChanged: Signal\n fullscreenChanged: Signal\n componentAdded: Signal\n componentRemoved: Signal\n clicked: Signal\n hovered: Signal\n}\n\nexport type RenderQualityType = 'auto'|'low'|'medium'|'high'\n\nexport const StageDefaultParameters = {\n impostor: true,\n quality: 'medium' as RenderQualityType,\n workerDefault: true,\n sampleLevel: 0,\n backgroundColor: 'black' as string|number,\n rotateSpeed: 2.0,\n zoomSpeed: 1.2,\n panSpeed: 1.0,\n clipNear: 0,\n clipFar: 100,\n clipDist: 10,\n clipMode: 'scene',\n clipScale: 'relative',\n fogNear: 50,\n fogFar: 100,\n cameraFov: 40,\n cameraEyeSep: 0.3,\n cameraType: 'perspective' as 'perspective'|'orthographic'|'stereo',\n lightColor: 0xdddddd as string|number,\n lightIntensity: 1.0,\n ambientColor: 0xdddddd as string|number,\n ambientIntensity: 0.2,\n hoverTimeout: 0,\n tooltip: true,\n mousePreset: 'default' as MouseControlPreset\n}\nexport type StageParameters = typeof StageDefaultParameters\n\nexport interface StageLoadFileParams extends LoaderParameters {\n defaultRepresentation: boolean,\n assembly: string\n}\n\n/**\n * Stage class, central for creating molecular scenes with NGL.\n *\n * @example\n * var stage = new Stage( \"elementId\", { backgroundColor: \"white\" } );\n */\nclass Stage {\n signals: StageSignals = {\n parametersChanged: new Signal(),\n fullscreenChanged: new Signal(),\n componentAdded: new Signal(),\n componentRemoved: new Signal(),\n clicked: new Signal(),\n hovered: new Signal()\n }\n parameters: StageParameters\n\n /**\n * Counter that keeps track of various potentially long-running tasks,\n * including file loading and surface calculation.\n */\n tasks = new Counter()\n compList: Component[] = []\n defaultFileParams = {}\n logList: string[] = []\n\n transformComponent?: Component\n transformAtom?: AtomProxy\n\n viewer: Viewer\n tooltip: HTMLElement\n lastFullscreenElement: HTMLElement\n\n mouseObserver: MouseObserver\n viewerControls: ViewerControls\n trackballControls: TrackballControls\n pickingControls: PickingControls\n animationControls: AnimationControls\n mouseControls: MouseControls\n keyControls: KeyControls\n\n pickingBehavior: PickingBehavior\n mouseBehavior: MouseBehavior\n animationBehavior: AnimationBehavior\n keyBehavior: KeyBehavior\n\n spinAnimation: Animation\n rockAnimation: Animation\n\n constructor (idOrElement: string|HTMLElement, params: Partial = {}) {\n this.viewer = new Viewer(idOrElement)\n if (!this.viewer.renderer) return\n\n this.tooltip = document.createElement('div')\n Object.assign(this.tooltip.style, {\n display: 'none',\n position: 'fixed',\n zIndex: '1000000',\n pointerEvents: 'none',\n backgroundColor: 'rgba( 0, 0, 0, 0.6 )',\n color: 'lightgrey',\n padding: '8px',\n fontFamily: 'sans-serif'\n })\n this.viewer.container.appendChild(this.tooltip)\n\n this.mouseObserver = new MouseObserver(this.viewer.renderer.domElement)\n this.viewerControls = new ViewerControls(this)\n this.trackballControls = new TrackballControls(this)\n this.pickingControls = new PickingControls(this)\n this.animationControls = new AnimationControls(this)\n this.mouseControls = new MouseControls(this)\n this.keyControls = new KeyControls(this)\n\n this.pickingBehavior = new PickingBehavior(this)\n this.mouseBehavior = new MouseBehavior(this)\n this.animationBehavior = new AnimationBehavior(this)\n this.keyBehavior = new KeyBehavior(this)\n\n this.spinAnimation = this.animationControls.spin([ 0, 1, 0 ], 0.005)\n this.spinAnimation.pause(true)\n this.rockAnimation = this.animationControls.rock([ 0, 1, 0 ], 0.005)\n this.rockAnimation.pause(true)\n\n // must come after the viewer has been instantiated\n this.parameters = createParams(params, StageDefaultParameters)\n this.setParameters(this.parameters)\n\n this.viewer.animate()\n }\n\n /**\n * Set stage parameters\n */\n setParameters (params: Partial = {}) {\n updateParams(this.parameters, params)\n\n const p = params\n const tp = this.parameters\n\n const viewer = this.viewer\n const controls = this.trackballControls\n\n // apply parameters\n if (p.quality !== undefined) this.setQuality(tp.quality)\n if (p.impostor !== undefined) this.setImpostor(tp.impostor)\n if (p.rotateSpeed !== undefined) controls.rotateSpeed = tp.rotateSpeed\n if (p.zoomSpeed !== undefined) controls.zoomSpeed = tp.zoomSpeed\n if (p.panSpeed !== undefined) controls.panSpeed = tp.panSpeed\n if (p.mousePreset !== undefined) this.mouseControls.preset(tp.mousePreset)\n this.mouseObserver.setParameters({ hoverTimeout: tp.hoverTimeout })\n viewer.setClip(tp.clipNear, tp.clipFar, tp.clipDist, tp.clipMode, tp.clipScale)\n viewer.setFog(undefined, tp.fogNear, tp.fogFar)\n viewer.setCamera(tp.cameraType, tp.cameraFov, tp.cameraEyeSep)\n viewer.setSampling(tp.sampleLevel)\n viewer.setBackground(tp.backgroundColor)\n viewer.setLight(tp.lightColor, tp.lightIntensity, tp.ambientColor, tp.ambientIntensity)\n\n this.signals.parametersChanged.dispatch(this.getParameters())\n\n return this\n }\n\n log (msg: string) {\n console.log('STAGE LOG', msg)\n this.logList.push(msg)\n }\n\n /**\n * Get stage parameters\n */\n getParameters () {\n return Object.assign({}, this.parameters)\n }\n\n /**\n * Create default representations for the given component\n * @param {StructureComponent|SurfaceComponent} object - component to create the representations for\n * @return {undefined}\n */\n defaultFileRepresentation (component: Component) {\n if (component instanceof StructureComponent) {\n component.setSelection('/0')\n\n let atomCount, residueCount, instanceCount\n const structure = component.structure\n\n if (structure.biomolDict.BU1) {\n const assembly = structure.biomolDict.BU1\n atomCount = assembly.getAtomCount(structure)\n residueCount = assembly.getResidueCount(structure)\n instanceCount = assembly.getInstanceCount()\n component.setDefaultAssembly('BU1')\n } else {\n atomCount = structure.getModelProxy(0).atomCount\n residueCount = structure.getModelProxy(0).residueCount\n instanceCount = 1\n }\n\n let sizeScore = atomCount\n\n if (Mobile) {\n sizeScore *= 4\n }\n\n const backboneOnly = structure.atomStore.count / structure.residueStore.count < 2\n if (backboneOnly) {\n sizeScore *= 10\n }\n\n let colorScheme = 'chainname'\n let colorScale = 'RdYlBu'\n let colorReverse = false\n if (structure.getChainnameCount(new Selection('polymer and /0')) === 1) {\n colorScheme = 'residueindex'\n colorScale = 'Spectral'\n colorReverse = true\n }\n\n if (Debug) console.log(sizeScore, atomCount, instanceCount, backboneOnly)\n\n if (residueCount / instanceCount < 4) {\n component.addRepresentation('ball+stick', {\n colorScheme: 'element',\n radiusScale: 2.0,\n aspectRatio: 1.5,\n bondScale: 0.3,\n bondSpacing: 0.75,\n quality: 'auto'\n })\n } else if ((instanceCount > 5 && sizeScore > 15000) || sizeScore > 700000) {\n let scaleFactor = (\n Math.min(\n 2.0,\n Math.max(\n 0.1,\n 6000 / (sizeScore / instanceCount)\n )\n )\n )\n if (backboneOnly) scaleFactor = Math.min(scaleFactor, 0.5)\n\n component.addRepresentation('surface', {\n colorScheme, colorScale, colorReverse,\n sele: 'polymer',\n surfaceType: 'av',\n probeRadius: 1.4,\n scaleFactor: scaleFactor,\n useWorker: false\n })\n } else if (sizeScore > 250000) {\n component.addRepresentation('backbone', {\n colorScheme, colorScale, colorReverse,\n lineOnly: true\n })\n } else if (sizeScore > 100000) {\n component.addRepresentation('backbone', {\n colorScheme, colorScale, colorReverse,\n quality: 'low',\n disableImpostor: true,\n radiusScale: 2.0\n })\n } else if (sizeScore > 80000) {\n component.addRepresentation('backbone', {\n colorScheme, colorScale, colorReverse,\n radiusScale: 2.0\n })\n } else {\n component.addRepresentation('cartoon', {\n colorScheme, colorScale, colorReverse,\n radiusScale: 0.7,\n aspectRatio: 5,\n quality: 'auto'\n })\n if (sizeScore < 50000) {\n component.addRepresentation('base', {\n colorScheme, colorScale, colorReverse,\n quality: 'auto'\n })\n }\n component.addRepresentation('ball+stick', {\n sele: 'ligand',\n colorScheme: 'element',\n radiusScale: 2.0,\n aspectRatio: 1.5,\n bondScale: 0.3,\n bondSpacing: 0.75,\n quality: 'auto'\n })\n }\n\n // add frames as trajectory\n if (component.structure.frames.length) {\n component.addTrajectory()\n }\n } else if (component instanceof SurfaceComponent) {\n component.addRepresentation('surface')\n } else if (component instanceof VolumeComponent) {\n component.addRepresentation('surface')\n }\n\n this.tasks.onZeroOnce(this.autoView, this)\n }\n\n /**\n * Load a file onto the stage\n *\n * @example\n * // load from URL\n * stage.loadFile( \"http://files.rcsb.org/download/5IOS.cif\" );\n *\n * @example\n * // load binary data in CCP4 format via a Blob\n * var binaryBlob = new Blob( [ ccp4Data ], { type: 'application/octet-binary'} );\n * stage.loadFile( binaryBlob, { ext: \"ccp4\" } );\n *\n * @example\n * // load string data in PDB format via a Blob\n * var stringBlob = new Blob( [ pdbData ], { type: 'text/plain'} );\n * stage.loadFile( stringBlob, { ext: \"pdb\" } );\n *\n * @example\n * // load a File object\n * stage.loadFile( file );\n *\n * @example\n * // load from URL and add a 'ball+stick' representation with double/triple bonds\n * stage.loadFile( \"http://files.rcsb.org/download/1crn.cif\" ).then( function( comp ){\n * comp.addRepresentation( \"ball+stick\", { multipleBond: true } );\n * } );\n *\n * @param {String|File|Blob} path - either a URL or an object containing the file data\n * @param {LoaderParameters} params - loading parameters\n * @param {Boolean} params.asTrajectory - load multi-model structures as a trajectory\n * @return {Promise} A Promise object that resolves to a {@link StructureComponent},\n * a {@link SurfaceComponent} or a {@link ScriptComponent} object,\n * depending on the type of the loaded file.\n */\n loadFile (path: string|File|Blob, params: Partial = {}) {\n const p = Object.assign({}, this.defaultFileParams, params)\n const name = getFileInfo(path).name\n\n this.tasks.increment()\n this.log(`loading file '${name}'`)\n\n const onLoadFn = (object: Structure|Surface|Volume) => {\n this.log(`loaded '${name}'`)\n\n const component = this.addComponentFromObject(object, p)\n if (p.defaultRepresentation) {\n this.defaultFileRepresentation(component as Component)\n }\n this.tasks.decrement()\n\n return component\n }\n\n const onErrorFn = (e: Error|string) => {\n this.tasks.decrement()\n const errorMsg = `error loading file: '${e}'`\n this.log(errorMsg)\n throw errorMsg // throw so it can be catched\n }\n\n const ext = defaults(p.ext, getFileInfo(path).ext)\n let promise: Promise\n\n if (ParserRegistry.isTrajectory(ext)) {\n promise = Promise.reject(\n new Error(`loadFile: ext '${ext}' is a trajectory and must be loaded into a structure component`)\n )\n } else {\n promise = autoLoad(path, p)\n }\n\n return promise.then(onLoadFn, onErrorFn)\n }\n\n loadScript (path: string|File|Blob) {\n const name = getFileInfo(path).name\n\n this.log(`loading script '${name}'`)\n\n return autoLoad(path).then(\n (script: Script) => {\n this.tasks.increment()\n this.log(`running script '${name}'`)\n script.run(this).then(() => {\n this.tasks.decrement()\n this.log(`finished script '${name}'`)\n })\n this.log(`called script '${name}'`)\n },\n (error: Error|string) => {\n this.tasks.decrement()\n const errorMsg = `errored script '${name}' \"${error}\"`\n this.log(errorMsg)\n throw errorMsg // throw so it can be catched\n }\n )\n }\n\n /**\n * Add the given component to the stage\n * @param {Component} component - the component to add\n * @return {undefined}\n */\n addComponent (component: Component) {\n if (!component) {\n Log.warn('Stage.addComponent: no component given')\n return\n }\n\n this.compList.push(component)\n this.signals.componentAdded.dispatch(component)\n }\n\n /**\n * Create a component from the given object and add to the stage\n */\n addComponentFromObject (object: Structure|Surface|Volume|Shape, params: Partial = {}): void|Component {\n const CompClass = ComponentRegistry.get(object.type)\n\n if (CompClass) {\n const component = new CompClass(this, object, params)\n this.addComponent(component)\n return component\n }\n\n Log.warn('no component for object type', object.type)\n }\n\n /**\n * Remove the given component\n * @param {Component} component - the component to remove\n * @return {undefined}\n */\n removeComponent (component: Component) {\n const idx = this.compList.indexOf(component)\n if (idx !== -1) {\n this.compList.splice(idx, 1)\n component.dispose()\n this.signals.componentRemoved.dispatch(component)\n }\n }\n\n /**\n * Remove all components from the stage\n */\n removeAllComponents () {\n this.compList.slice().forEach(o => this.removeComponent(o))\n }\n\n /**\n * Handle any size-changes of the container element\n * @return {undefined}\n */\n handleResize () {\n this.viewer.handleResize()\n }\n\n /**\n * Set width and height\n * @param {String} width - CSS width value\n * @param {String} height - CSS height value\n * @return {undefined}\n */\n setSize (width: string, height: string) {\n const container = this.viewer.container\n\n if (container !== document.body) {\n if (width !== undefined) container.style.width = width\n if (height !== undefined) container.style.height = height\n this.handleResize()\n }\n }\n\n /**\n * Toggle fullscreen\n * @param {Element} [element] - document element to put into fullscreen,\n * defaults to the viewer container\n * @return {undefined}\n */\n toggleFullscreen (element: HTMLElement) {\n if (!document.fullscreenEnabled && !document.mozFullScreenEnabled &&\n !(document as any).webkitFullscreenEnabled && !document.msFullscreenEnabled\n ) {\n Log.log('fullscreen mode (currently) not possible')\n return\n }\n\n const self = this\n element = element || this.viewer.container\n this.lastFullscreenElement = element\n\n //\n\n function getFullscreenElement () {\n return document.fullscreenElement || document.mozFullScreenElement ||\n (document as any).webkitFullscreenElement || document.msFullscreenElement\n }\n\n function resizeElement () {\n if (!getFullscreenElement() && self.lastFullscreenElement) {\n const element = self.lastFullscreenElement\n element.style.width = element.dataset.normalWidth || ''\n element.style.height = element.dataset.normalHeight || ''\n\n document.removeEventListener('fullscreenchange', resizeElement)\n document.removeEventListener('mozfullscreenchange', resizeElement)\n document.removeEventListener('webkitfullscreenchange', resizeElement)\n document.removeEventListener('MSFullscreenChange', resizeElement)\n\n self.handleResize()\n self.signals.fullscreenChanged.dispatch(false)\n }\n }\n\n //\n\n if (!getFullscreenElement()) {\n element.dataset.normalWidth = element.style.width || ''\n element.dataset.normalHeight = element.style.height || ''\n element.style.width = window.screen.width + 'px'\n element.style.height = window.screen.height + 'px'\n\n if (element.requestFullscreen) {\n element.requestFullscreen()\n } else if (element.msRequestFullscreen) {\n element.msRequestFullscreen()\n } else if (element.mozRequestFullScreen) {\n element.mozRequestFullScreen()\n } else if ((element as any).webkitRequestFullscreen) {\n (element as any).webkitRequestFullscreen()\n }\n\n document.addEventListener('fullscreenchange', resizeElement)\n document.addEventListener('mozfullscreenchange', resizeElement)\n document.addEventListener('webkitfullscreenchange', resizeElement)\n document.addEventListener('MSFullscreenChange', resizeElement)\n\n this.handleResize()\n this.signals.fullscreenChanged.dispatch(true)\n\n // workaround for Safari\n setTimeout(function () { self.handleResize() }, 100)\n } else {\n if (document.exitFullscreen) {\n document.exitFullscreen()\n } else if (document.msExitFullscreen) {\n document.msExitFullscreen()\n } else if (document.mozCancelFullScreen) {\n document.mozCancelFullScreen()\n } else if ((document as any).webkitExitFullscreen) {\n (document as any).webkitExitFullscreen()\n }\n }\n }\n\n /**\n * Set spin\n * @param {Boolean} flag - if true start rocking and stop spinning\n * @return {undefined}\n */\n setSpin (flag: boolean) {\n if (flag) {\n this.spinAnimation.resume(true)\n this.rockAnimation.pause(true)\n } else {\n this.spinAnimation.pause(true)\n }\n }\n\n /**\n * Set rock\n * @param {Boolean} flag - if true start rocking and stop spinning\n * @return {undefined}\n */\n setRock (flag: boolean) {\n if (flag) {\n this.rockAnimation.resume(true)\n this.spinAnimation.pause(true)\n } else {\n this.rockAnimation.pause(true)\n }\n }\n\n /**\n * Toggle spin\n * @return {undefined}\n */\n toggleSpin () {\n this.setSpin(this.spinAnimation.paused)\n }\n\n /**\n * Toggle rock\n * @return {undefined}\n */\n toggleRock () {\n this.setRock(this.rockAnimation.paused)\n }\n\n /**\n * Get the current focus from the current clipNear value expressed\n * as 0 (full view) to 100 (completely clipped)\n * Negative values may be returned in some cases.\n *\n * In 'camera' clipMode focus isn't applicable, this method returns 0.0\n *\n * @return {number} focus\n */\n getFocus () : number {\n const p = this.parameters\n if (p.clipMode !== 'scene') return 0.0\n\n let clipNear = p.clipNear\n if (p.clipScale === 'absolute') {\n clipNear = this.viewer.absoluteToRelative(clipNear)\n }\n return clipNear * 2\n }\n\n\n /**\n * Set the focus, a value of 0 sets clipping planes to show full scene,\n * while a value of 100 will compltely clip the scene.\n *\n * @param {number} value focus\n */\n setFocus (value: number) {\n if (this.parameters.clipMode !== 'scene') return\n\n let clipNear\n let clipFar\n let fogNear\n let fogFar\n\n if (this.parameters.clipScale === 'relative') {\n clipNear = clamp(value / 2.0, 0.0, 49.9)\n clipFar = 100 - clipNear\n fogNear = 50\n fogFar = pclamp(2 * clipFar - 50)\n\n } else {\n clipNear = this.viewer.relativeToAbsolute(value / 2.0)\n clipFar = clipNear\n fogNear = 0\n fogFar = 2 * clipFar\n }\n\n this.setParameters({ clipNear, clipFar, fogNear, fogFar })\n }\n\n getZoomForBox (boundingBox: Box3) {\n const bbSize = boundingBox.getSize(tmpZoomVector)\n const maxSize = Math.max(bbSize.x, bbSize.y, bbSize.z)\n const minSize = Math.min(bbSize.x, bbSize.y, bbSize.z)\n let distance = maxSize + Math.sqrt(minSize)\n\n const fov = degToRad(this.viewer.perspectiveCamera.fov)\n const width = this.viewer.width\n const height = this.viewer.height\n const aspect = width / height\n const aspectFactor = (height < width ? 1 : aspect)\n\n distance = Math.abs(\n ((distance * 0.5) / aspectFactor) / Math.sin(fov / 2)\n )\n distance += this.parameters.clipDist\n return -distance\n }\n\n getBox () {\n return this.viewer.boundingBox\n }\n\n getZoom () {\n return this.getZoomForBox(this.getBox())\n }\n\n getCenter (optionalTarget?: Vector3) {\n return this.getBox().getCenter(optionalTarget || new Vector3())\n }\n\n /**\n * Add a zoom and a move animation with automatic targets\n * @param {Integer} duration - animation time in milliseconds\n * @return {undefined}\n */\n autoView (duration?: number) {\n this.animationControls.zoomMove(\n this.getCenter(),\n this.getZoom(),\n defaults(duration, 0)\n )\n }\n\n /**\n * Make image from what is shown in a viewer canvas\n */\n makeImage (params: Partial = {}) {\n return new Promise((resolve, reject) => {\n this.tasks.onZeroOnce(() => {\n this.tasks.increment()\n this.viewer.makeImage(params).then(blob => {\n this.tasks.decrement()\n resolve(blob)\n }).catch(e => {\n this.tasks.decrement()\n reject(e)\n })\n })\n })\n }\n\n setImpostor (value: boolean) {\n this.parameters.impostor = value\n\n const types = [\n 'spacefill', 'ball+stick', 'licorice', 'hyperball',\n 'backbone', 'rocket', 'helixorient', 'contact', 'distance',\n 'dot'\n ]\n\n this.eachRepresentation(function (reprElem) {\n if (!types.includes(reprElem.getType())) return\n\n const p = reprElem.getParameters() as any // TODO\n p.disableImpostor = !value\n reprElem.build(p)\n })\n }\n\n setQuality (value: RenderQualityType) {\n this.parameters.quality = value\n\n const types = [\n 'tube', 'cartoon', 'ribbon', 'trace', 'rope'\n ]\n\n const impostorTypes = [\n 'spacefill', 'ball+stick', 'licorice', 'hyperball',\n 'backbone', 'rocket', 'helixorient', 'contact', 'distance',\n 'dot'\n ]\n\n this.eachRepresentation(function (repr) {\n const p = repr.getParameters() as any // TODO\n\n if (!types.includes(repr.getType())) {\n if (!impostorTypes.includes(repr.getType())) return\n\n if (!p.disableImpostor) {\n (repr.repr as any).quality = value // TODO\n return\n }\n }\n\n p.quality = value\n repr.build(p)\n })\n }\n\n /**\n * Iterator over each component and executing the callback\n */\n eachComponent (callback: (comp: Component) => void, type?: string) {\n this.compList.slice().forEach(comp => {\n if (type === undefined || type === comp.type) callback(comp)\n })\n }\n\n /**\n * Iterator over each representation and executing the callback\n */\n eachRepresentation (callback: (reprElem: RepresentationElement, comp: Component) => void, type?: string) {\n this.eachComponent(comp => {\n comp.reprList.slice().forEach(reprElem => {\n if (type === undefined || type === reprElem.getType()) callback(reprElem, comp)\n })\n })\n }\n\n /**\n * Get collection of components by name\n */\n getComponentsByName (name: string|RegExp) {\n const compList: Component[] = []\n\n this.eachComponent(comp => {\n if (name === undefined || matchName(name, comp)) compList.push(comp)\n })\n\n return new ComponentCollection(compList)\n }\n\n /**\n * Get collection of components by object\n */\n getComponentsByObject (object: Structure|Surface|Volume|Shape) {\n const compList: Component[] = []\n\n this.eachComponent(comp => {\n if (comp.object === object) compList.push(comp)\n })\n\n return new ComponentCollection(compList)\n }\n\n /**\n * Get collection of representations by name\n */\n getRepresentationsByName (name: string|RegExp) {\n const reprList: RepresentationElement[] = []\n\n this.eachRepresentation((repr, comp) => {\n if (name === undefined || matchName(name, repr)) reprList.push(repr)\n })\n\n return new RepresentationCollection(reprList)\n }\n\n measureClear () {\n this.eachComponent((sc: StructureComponent) => sc.measureClear(), 'structure')\n }\n\n measureUpdate () {\n this.eachComponent((sc: StructureComponent) => sc.measureUpdate(), 'structure')\n }\n\n /**\n * Cleanup when disposing of a stage object\n */\n dispose () {\n this.tasks.dispose()\n this.viewer.dispose()\n this.mouseObserver.dispose()\n }\n}\n\nexport default Stage\n","/**\n * @file Shape Component\n * @author Alexander Rose \n * @private\n */\n\nimport { ComponentRegistry } from '../globals'\nimport Component, { ComponentParameters } from './component'\nimport Stage from '../stage/stage'\nimport Shape from '../geometry/shape'\nimport { Vector3, Box3 } from 'three';\nimport RepresentationElement from './representation-element';\n\nexport type ShapeRepresentationType = 'buffer'\n\n/**\n * Component wrapping a {@link Shape} object\n *\n * @example\n * // get a shape component by adding a shape object to the stage\n * var shape = new NGL.Shape( \"shape\" );\n * shape.addSphere( [ 0, 0, 0 ], [ 1, 0, 0 ], 1.5 );\n * var shapeComponent = stage.addComponentFromObject( shape );\n * shapeComponent.addRepresentation( \"buffer\" );\n */\nclass ShapeComponent extends Component {\n constructor (stage: Stage, readonly shape: Shape, params: Partial = {}) {\n super(stage, shape, Object.assign({ name: shape.name }, params))\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'shape' }\n\n /**\n * Add a new shape representation to the component\n * @param {String} type - the name of the representation, one of:\n * buffer.\n * @param {BufferRepresentationParameters} params - representation parameters\n * @return {RepresentationComponent} the created representation wrapped into\n * a representation component object\n */\n addRepresentation (type: ShapeRepresentationType, params: { [k: string]: any } = {}): RepresentationElement {\n return this._addRepresentation(type, this.shape, params)\n }\n\n getBoxUntransformed (): Box3 {\n return this.shape.boundingBox\n }\n\n getCenterUntransformed (): Vector3 {\n return this.shape.center\n }\n\n dispose () {\n this.shape.dispose()\n super.dispose()\n }\n}\n\nComponentRegistry.add('shape', ShapeComponent)\n\nexport default ShapeComponent\n","/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n}\r\n","/**\n * @file Atomindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\n/**\n * Color by atom index. The {@link AtomProxy.index} property is used for coloring.\n * Each {@link ModelProxy} of a {@link Structure} is colored seperately. The\n * `params.domain` parameter is ignored.\n *\n * __Name:__ _atomindex_\n *\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"ball+stick\", { colorScheme: \"atomindex\" } );\n * o.autoView();\n * } );\n */\nclass AtomindexColormaker extends Colormaker {\n scalePerModel: { [k: number]: ColormakerScale }\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rainbow'\n this.parameters.reverse = defaults(params.reverse, true)\n }\n\n this.scalePerModel = {}\n\n params.structure.eachModel((mp: ModelProxy) => {\n this.parameters.domain = [ mp.atomOffset, mp.atomEnd ]\n this.scalePerModel[ mp.index ] = this.getScale() // TODO\n })\n }\n\n /**\n * get color for an atom\n * @param {AtomProxy} atom - atom to get color for\n * @return {Integer} hex atom color\n */\n @manageColor\n atomColor (atom: AtomProxy) {\n return this.scalePerModel[ atom.modelIndex ](atom.index)\n }\n}\n\nColormakerRegistry.add('atomindex', AtomindexColormaker)\n\nexport default AtomindexColormaker\n","/**\n * @file Bfactor Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Selection from '../selection/selection'\n\n/**\n * Color by b-factor. The {@link AtomProxy.bfactor} property is used for coloring.\n * By default the min and max b-factor values are used for the scale`s domain.\n *\n * __Name:__ _bfactor_\n *\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"ball+stick\", { colorScheme: \"bfactor\" } );\n * o.autoView();\n * } );\n */\nclass BfactorColormaker extends Colormaker {\n bfactorScale: ColormakerScale\n\n constructor (params: { sele?: string } & StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'OrRd'\n }\n\n if (!params.domain) {\n let selection\n let min = Infinity\n let max = -Infinity\n\n if (params.sele) {\n selection = new Selection(params.sele)\n }\n\n params.structure.eachAtom(function (a) {\n const bfactor = a.bfactor\n min = Math.min(min, bfactor)\n max = Math.max(max, bfactor)\n }, selection)\n\n this.parameters.domain = [ min, max ]\n }\n\n this.bfactorScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.bfactorScale(a.bfactor)\n }\n}\n\nColormakerRegistry.add('bfactor', BfactorColormaker)\n\nexport default BfactorColormaker\n","/**\n * @file Chainid Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\nexport type ChainidDict = { [k: string]: number }\n\n/**\n * Color by chain id\n */\nclass ChainidColormaker extends Colormaker {\n chainidDictPerModel: { [k: number]: ChainidDict } = {}\n scalePerModel: { [k: number]: ColormakerScale } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'Spectral'\n }\n\n params.structure.eachModel((mp: ModelProxy) => {\n let i = 0\n const chainidDict: ChainidDict = {}\n mp.eachChain(function (cp: ChainProxy) {\n if (chainidDict[ cp.chainid ] === undefined) {\n chainidDict[ cp.chainid ] = i\n i += 1\n }\n })\n this.parameters.domain = [ 0, i - 1 ]\n this.chainidDictPerModel[ mp.index ] = chainidDict\n this.scalePerModel[ mp.index ] = this.getScale()\n })\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n const chainidDict = this.chainidDictPerModel[ a.modelIndex ]\n return this.scalePerModel[ a.modelIndex ](chainidDict[ a.chainid ])\n }\n}\n\nColormakerRegistry.add('chainid', ChainidColormaker)\n\nexport default ChainidColormaker\n","/**\n * @file Chainindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\n/**\n * Color by chain index\n */\nclass ChainindexColormaker extends Colormaker {\n scalePerModel: { [k: number]: ColormakerScale } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'Spectral'\n }\n\n params.structure.eachModel((mp: ModelProxy) => {\n this.parameters.domain = [ mp.chainOffset, mp.chainEnd ]\n this.scalePerModel[ mp.index ] = this.getScale()\n })\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.scalePerModel[ a.modelIndex ](a.chainIndex)\n }\n}\n\nColormakerRegistry.add('chainindex', ChainindexColormaker)\n\nexport default ChainindexColormaker\n","/**\n * @file Chainname Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\nexport type ChainnameDict = { [k: string]: number }\n\n/**\n * Color by chain name\n */\nclass ChainnameColormaker extends Colormaker {\n chainnameDictPerModel: { [k: number]: ChainnameDict } = {}\n scalePerModel: { [k: number]: ColormakerScale } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'Spectral'\n }\n\n params.structure.eachModel((mp: ModelProxy) => {\n let i = 0\n const chainnameDict: ChainnameDict = {}\n mp.eachChain(function (cp: ChainProxy) {\n if (chainnameDict[ cp.chainname ] === undefined) {\n chainnameDict[ cp.chainname ] = i\n i += 1\n }\n })\n this.parameters.domain = [ 0, i - 1 ]\n this.chainnameDictPerModel[ mp.index ] = chainnameDict\n this.scalePerModel[ mp.index ] = this.getScale()\n })\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n const chainnameDict = this.chainnameDictPerModel[ a.modelIndex ]\n return this.scalePerModel[ a.modelIndex ](chainnameDict[ a.chainname ])\n }\n}\n\nColormakerRegistry.add('chainname', ChainnameColormaker)\n\nexport default ChainnameColormaker\n","/**\n * @file Densityfit Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by validation density fit\n */\nclass DensityfitColormaker extends Colormaker {\n rsrzScale: ColormakerScale\n rsccScale: ColormakerScale\n\n rsrzDict: { [k: string]: number|undefined } = {}\n rsccDict: { [k: string]: number|undefined } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'RdYlBu'\n }\n\n this.rsrzScale = this.getScale({ domain: [ 2, 0 ] })\n this.rsccScale = this.getScale({ domain: [ 0.678, 1.0 ] })\n\n const val = params.structure.validation\n if (val) {\n this.rsrzDict = val.rsrzDict\n this.rsccDict = val.rsccDict\n }\n\n }\n\n @manageColor\n atomColor (atom: AtomProxy) {\n let sele = atom.resno + ''\n if (atom.inscode) sele += '^' + atom.inscode\n if (atom.chainname) sele += ':' + atom.chainname\n sele += '/' + atom.modelIndex\n\n const rsrz = this.rsrzDict[ sele ]\n if (rsrz !== undefined) {\n return this.rsrzScale(rsrz)\n }\n\n const rscc = this.rsccDict[ sele ]\n if (rscc !== undefined) {\n return this.rsccScale(rscc)\n }\n\n return 0x909090\n }\n}\n\nColormakerRegistry.add('densityfit', DensityfitColormaker)\n\nexport default DensityfitColormaker\n","/**\n * @file Atomindex Colormaker\n * @author Fred Ludlow \n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport SpatialHash from '../geometry/spatial-hash'\n\n// from CHARMM\nconst partialCharges: { [k: string]: { [k: string]: number } } = {\n 'ARG': {\n 'CD': 0.1,\n 'CZ': 0.5,\n 'NE': -0.1\n },\n 'ASN': {\n 'CG': 0.55,\n 'OD1': -0.55\n },\n 'ASP': {\n 'CB': -0.16,\n 'CG': 0.36,\n 'OD1': -0.6,\n 'OD2': -0.6\n },\n 'CYS': {\n 'CB': 0.19,\n 'SG': -0.19\n },\n 'GLN': {\n 'CD': 0.55,\n 'OE1': -0.55\n },\n 'GLU': {\n 'CD': 0.36,\n 'CG': -0.16,\n 'OE1': -0.6,\n 'OE2': -0.6\n },\n 'HIS': {\n 'CB': 0.1,\n 'CD2': 0.2,\n 'CE1': 0.45,\n 'CG': 0.15,\n 'ND1': 0.05,\n 'NE2': 0.05\n },\n 'LYS': {\n 'CE': 0.25,\n 'NZ': 0.75\n },\n 'MET': {\n 'CE': 0.06,\n 'CG': 0.06,\n 'SD': -0.12\n },\n 'PTR': {\n 'C': 0.55,\n 'CA': 0.1,\n 'CZ': 0.25,\n 'N': -0.35,\n 'O': -0.55,\n 'O1P': -0.85,\n 'O2P': -0.85,\n 'O3P': -0.85,\n 'OG1': -1.1,\n 'P': 1.4\n },\n 'SEP': {\n 'C': 0.55,\n 'CA': 0.1,\n 'CB': 0.25,\n 'N': -0.35,\n 'O': -0.55,\n 'O1P': -0.85,\n 'O2P': -0.85,\n 'O3P': -0.85,\n 'OG1': -1.1,\n 'P': 1.4\n },\n 'SER': {\n 'CB': 0.25,\n 'OG': -0.25\n },\n 'THR': {\n 'CB': 0.25,\n 'OG1': -0.25\n },\n 'TPO': {\n 'C': 0.55,\n 'CA': 0.1,\n 'CB': 0.25,\n 'N': -0.35,\n 'O': -0.55,\n 'OG1': -1.1,\n 'O1P': -0.85,\n 'O2P': -0.85,\n 'O3P': -0.85,\n 'P': 1.4\n },\n 'TRP': {\n 'CD1': 0.06,\n 'CD2': 0.1,\n 'CE2': -0.04,\n 'CE3': -0.03,\n 'CG': -0.03,\n 'NE1': -0.06\n },\n 'TYR': {\n 'CZ': 0.25,\n 'OH': -0.25\n },\n 'backbone': {\n 'C': 0.55,\n 'O': -0.55,\n 'N': -0.35,\n 'CA': 0.1\n }\n}\n\nconst maxRadius = 12.0\nconst nHBondDistance = 1.04\nconst nHCharge = 0.25\n\n/**\n * Populates position vector with location of implicit or explicit H\n * Returns position or undefined if not able to locate H\n *\n * @param {AtomProxy} ap - the nitrogen atom\n * @param {Vector3} [position] - optional target\n * @return {Vectors|undefined} the hydrogen atom position\n */\nfunction backboneNHPosition (ap: AtomProxy, position = new Vector3()) {\n let h = false\n let ca = false\n let c = false\n position.set(2 * ap.x, 2 * ap.y, 2 * ap.z)\n\n ap.eachBondedAtom(function (a2: AtomProxy) {\n // Any time we detect H, reset position and skip\n // future tests\n if (h) return\n if (a2.atomname === 'H') {\n position.set(a2.x, a2.y, a2.z)\n h = true\n return\n }\n if (!ca && a2.atomname === 'CA') {\n position.sub(a2 as any) // TODO\n ca = true\n } else if (!c && a2.atomname === 'C') {\n c = true\n position.sub(a2 as any) // TODO\n }\n })\n\n if (h) { return position }\n\n if (ca && c) {\n position.normalize()\n position.multiplyScalar(nHBondDistance)\n position.add(ap as any)\n return position\n }\n}\n\n/**\n * Takes an array of Vector3 objects and\n * converts to an object that looks like an AtomStore\n *\n * @param {Vector3[]} positions - array of positions\n * @return {Object} AtomStore-like object\n */\nfunction buildStoreLike (positions: Vector3[]) {\n const n = positions.length\n const x = new Float32Array(n)\n const y = new Float32Array(n)\n const z = new Float32Array(n)\n\n for (let i = 0; i < positions.length; i++) {\n const v = positions[ i ]\n x[ i ] = v.x\n y[ i ] = v.y\n z[ i ] = v.z\n }\n\n return { x: x, y: y, z: z, count: n }\n}\n\nfunction chargeForAtom (a: AtomProxy): number {\n if (a.partialCharge !== null) return a.partialCharge\n if (!a.isProtein()) { return 0.0 }\n return (\n (partialCharges[ a.resname ] &&\n partialCharges[ a.resname ][ a.atomname ]) ||\n partialCharges[ 'backbone' ][ a.atomname ] || 0.0\n )\n}\n\n/**\n * Color a surface by electrostatic charge. This is a highly approximate\n * calculation! The partial charges are CHARMM with hydrogens added to heavy\n * atoms and hydrogen positions generated for amides.\n *\n * __Name:__ _electrostatic_\n *\n * @example\n * stage.loadFile( \"rcsb://3dqb\" ).then( function( o ){\n * o.addRepresentation( \"surface\", { colorScheme: \"electrostatic\" } );\n * o.autoView();\n * } );\n */\nclass ElectrostaticColormaker extends Colormaker {\n scale: ColormakerScale\n hHash: SpatialHash\n hash: SpatialHash\n charges: Float32Array\n hStore: { x: Float32Array, y: Float32Array, z: Float32Array, count: number }\n atomProxy: AtomProxy\n\n delta = new Vector3()\n hCharges: number[] = []\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rwb'\n }\n if (!params.domain) {\n this.parameters.domain = [ -50, 50 ]\n }\n\n this.scale = this.getScale()\n\n this.charges = new Float32Array(params.structure.atomCount)\n const hPositions: Vector3[] = []\n\n params.structure.eachAtom((ap: AtomProxy) => {\n this.charges[ ap.index ] = chargeForAtom(ap) * ap.occupancy\n if (ap.atomname === 'N') {\n\n // In the specific case where N forms two bonds to\n // CA and C, try and place a dummy hydrogen\n\n if (ap.bondCount >= 3) return; // Skip if 3 bonds already (e.g. PRO)\n\n if (ap.bondToElementCount(1)) return; // Skip if any H specificed\n\n const hPos = backboneNHPosition(ap)\n if (hPos !== undefined) {\n hPositions.push(hPos)\n this.hCharges.push(nHCharge * ap.occupancy)\n }\n }\n })\n\n const bbox = params.structure.getBoundingBox()\n bbox.expandByScalar(nHBondDistance) // Worst case\n\n // SpatialHash requires x,y,z and count\n this.hStore = buildStoreLike(hPositions)\n this.hHash = new SpatialHash(this.hStore as any, bbox) // TODO\n this.hash = new SpatialHash(params.structure.atomStore, bbox)\n }\n\n @manageColor\n positionColor (v: Vector3) {\n\n const charges = this.charges\n const hCharges = this.hCharges\n\n let p = 0.0\n this.hash.eachWithin(v.x, v.y, v.z, maxRadius, (atomIndex, dSq) => {\n const charge = charges[atomIndex]\n if (charge === 0.0) return\n p += charge / dSq\n })\n\n this.hHash.eachWithin(v.x, v.y, v.z, maxRadius, (atomIndex, dSq) => {\n const charge = hCharges[atomIndex]\n if (charge === 0.0) return\n p += charge / dSq\n })\n\n return this.scale(p * 332) // 332 to convert to kcal/mol\n }\n}\n\nColormakerRegistry.add('electrostatic', ElectrostaticColormaker)\n\nexport default ElectrostaticColormaker\n","/**\n * @file Element Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Colormaker, { ColormakerParameters, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n// from Jmol http://jmol.sourceforge.net/jscolors/ (or 0xFFFFFF)\nconst ElementColors: { [k: string]: number } = {\n 'H': 0xFFFFFF,\n 'HE': 0xD9FFFF,\n 'LI': 0xCC80FF,\n 'BE': 0xC2FF00,\n 'B': 0xFFB5B5,\n 'C': 0x909090,\n 'N': 0x3050F8,\n 'O': 0xFF0D0D,\n 'F': 0x90E050,\n 'NE': 0xB3E3F5,\n 'NA': 0xAB5CF2,\n 'MG': 0x8AFF00,\n 'AL': 0xBFA6A6,\n 'SI': 0xF0C8A0,\n 'P': 0xFF8000,\n 'S': 0xFFFF30,\n 'CL': 0x1FF01F,\n 'AR': 0x80D1E3,\n 'K': 0x8F40D4,\n 'CA': 0x3DFF00,\n 'SC': 0xE6E6E6,\n 'TI': 0xBFC2C7,\n 'V': 0xA6A6AB,\n 'CR': 0x8A99C7,\n 'MN': 0x9C7AC7,\n 'FE': 0xE06633,\n 'CO': 0xF090A0,\n 'NI': 0x50D050,\n 'CU': 0xC88033,\n 'ZN': 0x7D80B0,\n 'GA': 0xC28F8F,\n 'GE': 0x668F8F,\n 'AS': 0xBD80E3,\n 'SE': 0xFFA100,\n 'BR': 0xA62929,\n 'KR': 0x5CB8D1,\n 'RB': 0x702EB0,\n 'SR': 0x00FF00,\n 'Y': 0x94FFFF,\n 'ZR': 0x94E0E0,\n 'NB': 0x73C2C9,\n 'MO': 0x54B5B5,\n 'TC': 0x3B9E9E,\n 'RU': 0x248F8F,\n 'RH': 0x0A7D8C,\n 'PD': 0x006985,\n 'AG': 0xC0C0C0,\n 'CD': 0xFFD98F,\n 'IN': 0xA67573,\n 'SN': 0x668080,\n 'SB': 0x9E63B5,\n 'TE': 0xD47A00,\n 'I': 0x940094,\n 'XE': 0x940094,\n 'CS': 0x57178F,\n 'BA': 0x00C900,\n 'LA': 0x70D4FF,\n 'CE': 0xFFFFC7,\n 'PR': 0xD9FFC7,\n 'ND': 0xC7FFC7,\n 'PM': 0xA3FFC7,\n 'SM': 0x8FFFC7,\n 'EU': 0x61FFC7,\n 'GD': 0x45FFC7,\n 'TB': 0x30FFC7,\n 'DY': 0x1FFFC7,\n 'HO': 0x00FF9C,\n 'ER': 0x00E675,\n 'TM': 0x00D452,\n 'YB': 0x00BF38,\n 'LU': 0x00AB24,\n 'HF': 0x4DC2FF,\n 'TA': 0x4DA6FF,\n 'W': 0x2194D6,\n 'RE': 0x267DAB,\n 'OS': 0x266696,\n 'IR': 0x175487,\n 'PT': 0xD0D0E0,\n 'AU': 0xFFD123,\n 'HG': 0xB8B8D0,\n 'TL': 0xA6544D,\n 'PB': 0x575961,\n 'BI': 0x9E4FB5,\n 'PO': 0xAB5C00,\n 'AT': 0x754F45,\n 'RN': 0x428296,\n 'FR': 0x420066,\n 'RA': 0x007D00,\n 'AC': 0x70ABFA,\n 'TH': 0x00BAFF,\n 'PA': 0x00A1FF,\n 'U': 0x008FFF,\n 'NP': 0x0080FF,\n 'PU': 0x006BFF,\n 'AM': 0x545CF2,\n 'CM': 0x785CE3,\n 'BK': 0x8A4FE3,\n 'CF': 0xA136D4,\n 'ES': 0xB31FD4,\n 'FM': 0xB31FBA,\n 'MD': 0xB30DA6,\n 'NO': 0xBD0D87,\n 'LR': 0xC70066,\n 'RF': 0xCC0059,\n 'DB': 0xD1004F,\n 'SG': 0xD90045,\n 'BH': 0xE00038,\n 'HS': 0xE6002E,\n 'MT': 0xEB0026,\n 'DS': 0xFFFFFF,\n 'RG': 0xFFFFFF,\n 'CN': 0xFFFFFF,\n 'UUT': 0xFFFFFF,\n 'FL': 0xFFFFFF,\n 'UUP': 0xFFFFFF,\n 'LV': 0xFFFFFF,\n 'UUH': 0xFFFFFF,\n\n 'D': 0xFFFFC0,\n 'T': 0xFFFFA0\n}\nconst DefaultElementColor = 0xFFFFFF\n\n/**\n * Color by element\n */\nclass ElementColormaker extends Colormaker {\n constructor (params: ColormakerParameters) {\n params.value = defaults(params.value, ElementColors.C)\n\n super(params)\n }\n\n\n @manageColor\n atomColor (a: AtomProxy) {\n const element = a.element\n\n if (element === 'C') {\n return this.parameters.value\n } else {\n return ElementColors[ element ] || DefaultElementColor\n }\n }\n}\n\nColormakerRegistry.add('element', ElementColormaker)\n\nexport default ElementColormaker\n","/**\n * @file Entityindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by entity index\n */\nclass EntityindexColormaker extends Colormaker {\n entityindexScale: ColormakerScale\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'Spectral'\n }\n if (!params.domain) {\n this.parameters.domain = [ 0, params.structure.entityList.length - 1 ]\n }\n\n this.entityindexScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.entityindexScale(a.entityIndex)\n }\n}\n\nColormakerRegistry.add('entityindex', EntityindexColormaker)\n\nexport default EntityindexColormaker\n","/**\n * @file Entitytype Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\nimport {\n PolymerEntity, NonPolymerEntity, MacrolideEntity, WaterEntity\n} from '../structure/structure-constants'\n\n/**\n * Color by entity type\n */\nclass EntitytypeColormaker extends Colormaker {\n @manageColor\n atomColor (a: AtomProxy) {\n const e = a.entity\n const et = e ? e.entityType : undefined\n switch (et) {\n case PolymerEntity:\n return 0x7fc97f\n case NonPolymerEntity:\n return 0xfdc086\n case MacrolideEntity:\n return 0xbeaed4\n case WaterEntity:\n return 0x386cb0\n default:\n return 0xffff99\n }\n }\n}\n\nColormakerRegistry.add('entitytype', EntitytypeColormaker)\n\nexport default EntitytypeColormaker\n","/**\n * @file Geoquality Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport { countSetBits } from '../math/math-utils'\n\n/**\n * Color by validation gometry quality\n */\nclass GeoqualityColormaker extends Colormaker {\n geoAtomDict: { [k: string]: { [k: string]: number } } = {}\n geoDict: { [k: string]: number|undefined } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n const val = params.structure.validation\n if (val) {\n this.geoAtomDict = val.geoAtomDict\n this.geoDict = val.geoDict\n }\n }\n\n @manageColor\n atomColor (atom: AtomProxy) {\n let sele = atom.resno + ''\n if (atom.inscode) sele += '^' + atom.inscode\n if (atom.chainname) sele += ':' + atom.chainname\n sele += '/' + atom.modelIndex\n\n let geoProblemCount\n const geoAtom = this.geoAtomDict[ sele ]\n if (geoAtom !== undefined) {\n const atomProblems: number = geoAtom[ atom.atomname ] || 0\n geoProblemCount = countSetBits(atomProblems)\n } else {\n geoProblemCount = this.geoDict[ sele ] || 0\n }\n\n if (geoProblemCount === 0) {\n return 0x2166ac\n } else if (geoProblemCount === 1) {\n return 0xfee08b\n } else if (geoProblemCount === 2) {\n return 0xf46d43\n } else if (geoProblemCount >= 3) {\n return 0xa50026\n }\n return 0x909090\n }\n}\n\nColormakerRegistry.add('geoquality', GeoqualityColormaker)\n\nexport default GeoqualityColormaker\n","/**\n * @file Hydrophobicity Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { ColormakerParameters, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\nimport {\n ResidueHydrophobicity, DefaultResidueHydrophobicity\n} from '../structure/structure-constants'\n\n/**\n * Color by hydrophobicity\n */\nclass HydrophobicityColormaker extends Colormaker {\n hfScale: ColormakerScale\n resHF: { [k: string]: number } = {}\n defaultResidueHydrophobicity: number\n\n constructor (params: ColormakerParameters) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'RdYlGn'\n }\n\n const idx = 0 // 0: DGwif, 1: DGwoct, 2: Oct-IF\n\n for (const name in ResidueHydrophobicity) {\n this.resHF[ name ] = ResidueHydrophobicity[ name ][ idx ]\n }\n this.defaultResidueHydrophobicity = DefaultResidueHydrophobicity[idx]\n\n if (!params.domain) {\n let min = Infinity\n let max = -Infinity\n\n for (const name in this.resHF) {\n const val = this.resHF[ name ]\n min = Math.min(min, val)\n max = Math.max(max, val)\n }\n\n this.parameters.domain = [ min, 0, max ]\n }\n\n this.hfScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.hfScale(this.resHF[ a.resname ] || this.defaultResidueHydrophobicity)\n }\n}\n\nColormakerRegistry.add('hydrophobicity', HydrophobicityColormaker)\n\nexport default HydrophobicityColormaker\n","/**\n * @file Modelindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by model index\n */\nclass ModelindexColormaker extends Colormaker {\n modelindexScale: ColormakerScale\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rainbow'\n }\n if (!params.domain) {\n this.parameters.domain = [ 0, params.structure.modelStore.count ]\n }\n\n this.modelindexScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.modelindexScale(a.modelIndex)\n }\n}\n\nColormakerRegistry.add('modelindex', ModelindexColormaker)\n\nexport default ModelindexColormaker\n","/**\n * @file Moleculetype Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\nimport {\n WaterType, IonType, ProteinType, RnaType, DnaType, SaccharideType\n} from '../structure/structure-constants'\n\n/**\n * Color by molecule type\n */\nclass MoleculetypeColormaker extends Colormaker {\n @manageColor\n atomColor (a: AtomProxy) {\n switch (a.residueType.moleculeType) {\n case WaterType:\n return 0x386cb0\n case IonType:\n return 0xf0027f\n case ProteinType:\n return 0xbeaed4\n case RnaType:\n return 0xfdc086\n case DnaType:\n return 0xbf5b17\n case SaccharideType:\n return 0x7fc97f\n default:\n return 0xffff99\n }\n }\n}\n\nColormakerRegistry.add('moleculetype', MoleculetypeColormaker)\n\nexport default MoleculetypeColormaker\n","/**\n * @file Occupancy Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { ColormakerParameters, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by occupancy\n */\nclass OccupancyColormaker extends Colormaker {\n occupancyScale: ColormakerScale\n\n constructor (params: ColormakerParameters) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'PuBu'\n }\n\n if (!params.domain) {\n this.parameters.domain = [ 0.0, 1.0 ]\n }\n\n this.occupancyScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.occupancyScale(a.occupancy)\n }\n}\n\nColormakerRegistry.add('occupancy', OccupancyColormaker)\n\nexport default OccupancyColormaker\n","/**\n * @file Partialcharge Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { ColormakerParameters, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by partial charge. The {@link AtomProxy.partialCharge} property is used for coloring.\n * The default domain is [-1, 1].\n *\n * __Name:__ _partialCharge_\n *\n * @example\n * stage.loadFile(\"rcsb://1crn\").then(function (o) {\n * o.addRepresentation(\"ball+stick\", {colorScheme: \"partialCharge\"});\n * o.autoView();\n * });\n */\nclass PartialchargeColormaker extends Colormaker {\n partialchargeScale: ColormakerScale\n\n constructor (params: ColormakerParameters) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rwb'\n }\n\n if (!params.domain) {\n this.parameters.domain = [-1, 1]\n }\n\n this.partialchargeScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.partialchargeScale(a.partialCharge || 0)\n }\n}\n\nColormakerRegistry.add('partialcharge', PartialchargeColormaker)\n\nexport default PartialchargeColormaker\n","/**\n * @file Random Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\n\nfunction randomColor () {\n return Math.random() * 0xFFFFFF\n}\n\n/**\n * Class by random color\n */\nclass RandomColormaker extends Colormaker {\n /**\n * get color for an atom\n * @return {Integer} random hex color\n */\n @manageColor\n atomColor () {\n return randomColor()\n }\n\n /**\n * get color for volume cell\n * @return {Integer} random hex color\n */\n @manageColor\n volumeColor () {\n return randomColor()\n }\n\n /**\n * get color for coordinates in space\n * @return {Integer} random hex color\n */\n @manageColor\n positionColor () {\n return randomColor()\n }\n}\n\nColormakerRegistry.add('random', RandomColormaker)\n\nexport default RandomColormaker\n","/**\n * @file Randomcoilindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by random coil index\n */\nclass RandomcoilindexColormaker extends Colormaker {\n rciScale: ColormakerScale\n rciDict: { [k: string]: number|undefined } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'RdYlBu'\n }\n\n this.rciScale = this.getScale({ domain: [ 0.6, 0 ] })\n\n const val = params.structure.validation\n if (val) this.rciDict = val.rciDict\n\n }\n\n @manageColor\n atomColor (atom: AtomProxy) {\n let sele = `[${atom.resname}]${atom.resno}`\n if (atom.chainname) sele += ':' + atom.chainname\n\n const rci = this.rciDict[ sele ]\n return rci !== undefined ? this.rciScale(rci) : 0x909090\n }\n}\n\nColormakerRegistry.add('randomcoilindex', RandomcoilindexColormaker)\n\nexport default RandomcoilindexColormaker\n","/**\n * @file Residueindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\n\n/**\n * Color by residue index\n */\nclass ResidueindexColormaker extends Colormaker {\n scalePerChain: { [k: number]: ColormakerScale } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rainbow'\n this.parameters.reverse = defaults(params.reverse, true)\n }\n\n params.structure.eachChain((cp: ChainProxy) => {\n this.parameters.domain = [ cp.residueOffset, cp.residueEnd ]\n this.scalePerChain[ cp.index ] = this.getScale()\n })\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.scalePerChain[ a.chainIndex ](a.residueIndex)\n }\n}\n\nColormakerRegistry.add('residueindex', ResidueindexColormaker)\n\nexport default ResidueindexColormaker\n","/**\n * @file Resname Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n// protein colors from Jmol http://jmol.sourceforge.net/jscolors/\nconst ResidueColors: { [k: string]: number } = {\n 'ALA': 0x8CFF8C,\n 'ARG': 0x00007C,\n 'ASN': 0xFF7C70,\n 'ASP': 0xA00042,\n 'CYS': 0xFFFF70,\n 'GLN': 0xFF4C4C,\n 'GLU': 0x660000,\n 'GLY': 0xFFFFFF,\n 'HIS': 0x7070FF,\n 'ILE': 0x004C00,\n 'LEU': 0x455E45,\n 'LYS': 0x4747B8,\n 'MET': 0xB8A042,\n 'PHE': 0x534C52,\n 'PRO': 0x525252,\n 'SER': 0xFF7042,\n 'THR': 0xB84C00,\n 'TRP': 0x4F4600,\n 'TYR': 0x8C704C,\n 'VAL': 0xFF8CFF,\n\n 'ASX': 0xFF00FF,\n 'GLX': 0xFF00FF,\n 'ASH': 0xFF00FF,\n 'GLH': 0xFF00FF,\n\n 'A': 0xDC143C, // Crimson Red\n 'G': 0x32CD32, // Lime Green\n 'I': 0x9ACD32, // Yellow Green\n 'X': 0x7CFC00, // Lawn Green\n 'C': 0xFFD700, // Gold Yellow\n 'T': 0x4169E1, // Royal Blue\n 'U': 0x40E0D0, // Turquoise Cyan\n 'D': 0x008B8B, // Dark Cyan\n\n 'DA': 0xDC143C,\n 'DG': 0x32CD32,\n 'DI': 0x9ACD32,\n 'DX': 0x7CFC00,\n 'DC': 0xFFD700,\n 'DT': 0x4169E1,\n 'DU': 0x40E0D0,\n 'DD': 0x008B8B\n}\nconst DefaultResidueColor = 0xFF00FF\n\n/**\n * Color by residue name\n */\nclass ResnameColormaker extends Colormaker {\n @manageColor\n atomColor (a: AtomProxy) {\n return ResidueColors[ a.resname ] || DefaultResidueColor\n }\n}\n\nColormakerRegistry.add('resname', ResnameColormaker)\n\nexport default ResnameColormaker\n","/**\n * @file Sstruc Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\n\n// from Jmol http://jmol.sourceforge.net/jscolors/ (shapely)\nconst StructureColors = {\n 'alphaHelix': 0xFF0080,\n 'threeTenHelix': 0xA00080,\n 'piHelix': 0x600080,\n 'betaStrand': 0xFFC800,\n 'betaTurn': 0x6080FF,\n 'coil': 0xFFFFFF,\n\n 'dna': 0xAE00FE,\n 'rna': 0xFD0162,\n\n 'carbohydrate': 0xA6A6FA\n}\nconst DefaultStructureColor = 0x808080\n\n/**\n * Color by secondary structure\n */\nclass SstrucColormaker extends Colormaker {\n residueProxy: ResidueProxy\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n this.residueProxy = params.structure.getResidueProxy()\n }\n\n @manageColor\n atomColor (ap: AtomProxy) {\n const sstruc = ap.sstruc\n const rp = this.residueProxy\n\n if (sstruc === 'h') {\n return StructureColors.alphaHelix\n } else if (sstruc === 'g') {\n return StructureColors.threeTenHelix\n } else if (sstruc === 'i') {\n return StructureColors.piHelix\n } else if (sstruc === 'e' || sstruc === 'b') {\n return StructureColors.betaStrand\n } else if (sstruc === 't') {\n return StructureColors.betaTurn\n } else {\n rp.index = ap.residueIndex\n if (rp.isDna()) {\n return StructureColors.dna\n } else if (rp.isRna()) {\n return StructureColors.rna\n } else if (rp.isSaccharide()) {\n return StructureColors.carbohydrate\n } else if (rp.isProtein() || sstruc === 's' || sstruc === 'l') {\n return StructureColors.coil\n } else {\n return DefaultStructureColor\n }\n }\n }\n}\n\nColormakerRegistry.add('sstruc', SstrucColormaker)\n\nexport default SstrucColormaker\n","/**\n * @file Colordata Colormaker\n * @author Fred Ludlow \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { ColorData, ColormakerScale, manageColor, StuctureColormakerParams } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport BondProxy from '../proxy/bond-proxy'\n\n\nclass StructuredataColormaker extends Colormaker {\n atomData?: ColorData['atomData']\n bondData?: ColorData['bondData']\n scale: ColormakerScale\n\n constructor(params: StuctureColormakerParams) {\n super(params)\n if (!params.scale) {\n this.parameters.scale = 'rwb'\n }\n this.atomData = this.parameters.data?.atomData\n this.bondData = this.parameters.data?.bondData\n this.scale = this.getScale(this.parameters)\n }\n\n @manageColor\n atomColor(a: AtomProxy) {\n const val = this.atomData?.[a.index]\n return (val !== undefined) ? this.scale(val) : this.parameters.value\n }\n\n @manageColor\n bondColor(bond: BondProxy, fromTo: boolean) {\n const val = this.bondData?.[bond.index]\n \n // Explicit bond data?\n if (val !== undefined) return this.scale(val)\n \n \n if (this.atomProxy) {\n this.atomProxy.index = fromTo ? bond.atomIndex1 : bond.atomIndex2\n return this.atomColor(this.atomProxy)\n } \n \n // Fallback\n return this.parameters.value\n }\n}\n\nColormakerRegistry.add('structuredata', StructuredataColormaker)\n\nexport default StructuredataColormaker","/**\n * @file Uniform Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\n\n/**\n * Color by uniform color\n */\nclass UniformColormaker extends Colormaker {\n @manageColor\n atomColor () {\n return this.parameters.value\n }\n\n @manageColor\n bondColor () {\n return this.parameters.value\n }\n\n @manageColor\n valueColor () {\n return this.parameters.value\n }\n\n @manageColor\n volumeColor () {\n return this.parameters.value\n }\n}\n\nColormakerRegistry.add('uniform', UniformColormaker)\n\nexport default UniformColormaker\n","/**\n * @file Value Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { VolumeColormakerParams, ColormakerScale, manageColor } from './colormaker'\n\n/**\n * Color by volume value\n */\nclass ValueColormaker extends Colormaker {\n valueScale: ColormakerScale\n\n constructor (params: VolumeColormakerParams) {\n super(params)\n this.valueScale = this.getScale()\n }\n\n /**\n * return the color for a volume cell\n * @param {Integer} index - volume cell index\n * @return {Integer} hex cell color\n */\n @manageColor\n volumeColor (index: number) {\n return this.valueScale((this.parameters.volume! as any).data[ index ]) // TODO\n }\n}\n\nColormakerRegistry.add('value', ValueColormaker)\n\nexport default ValueColormaker\n","/**\n * @file Volume Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\nimport { lerp } from '../math/math-utils'\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { VolumeColormakerParams, ColormakerScale, manageColor } from './colormaker'\n\n/**\n * Color by volume position\n */\nclass VolumeColormaker extends Colormaker {\n valueScale: ColormakerScale\n vec = new Vector3()\n\n constructor (params: VolumeColormakerParams) {\n super(params)\n this.valueScale = this.getScale()\n }\n\n /**\n * return the color for coordinates in space\n * @param {Vector3} coords - xyz coordinates\n * @return {Integer} hex coords color\n */\n @manageColor\n positionColor (coords: Vector3) {\n const volume = this.parameters.volume as any // TODO\n\n if (!volume || !volume.inverseMatrix) {\n return this.parameters.value\n }\n\n const vec = this.vec\n const data = volume.data\n const nx = volume.nx\n const ny = volume.ny\n const nxy = nx * ny\n\n vec.copy(coords)\n vec.applyMatrix4(volume.inverseMatrix)\n\n // position of grid cell\n const x0 = Math.floor(vec.x)\n const y0 = Math.floor(vec.y)\n const z0 = Math.floor(vec.z)\n\n // Indices\n const i = ((((z0 * ny) + y0) * nx) + x0)\n const i1 = i + 1\n const iy = i + nx\n const iz = i + nxy\n const i1y = iy + 1\n const i1z = iz + 1\n const iyz = iy + nxy\n const i1yz = iyz + 1\n\n // Values\n const v = data[ i ]\n const v1 = data[ i1 ]\n const vy = data[ iy ]\n const vz = data[ iz ]\n const v1y = data[ i1y ]\n const v1z = data[ i1z ]\n const vyz = data[ iyz ]\n const v1yz = data[ i1yz ]\n\n // Position of point in fraction of grid\n const xd = vec.x - x0\n const yd = vec.y - y0\n const zd = vec.z - z0\n\n // 1st Dimension\n const c00 = lerp(v, v1, xd)\n const c01 = lerp(vz, v1z, xd)\n const c10 = lerp(vy, v1y, xd)\n const c11 = lerp(vyz, v1yz, xd)\n\n // 2nd Dimension\n const c0 = lerp(c00, c10, yd)\n const c1 = lerp(c01, c11, yd)\n\n // 3rd Dimension\n const c = lerp(c0, c1, zd)\n\n return this.valueScale(c)\n }\n}\n\nColormakerRegistry.add('volume', VolumeColormaker)\n\nexport default VolumeColormaker\n","/**\n * @file Structure Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { ExtensionFragDepth, Mobile } from '../globals'\nimport { defaults } from '../utils'\nimport { RepresentationParameters, default as Representation } from './representation'\nimport Selection from '../selection/selection'\nimport RadiusFactory, { RadiusFactoryTypes, RadiusType } from '../utils/radius-factory'\nimport Structure from '../structure/structure'\nimport Viewer from '../viewer/viewer'\n// @ts-ignore: unused import Volume required for declaration only\nimport { Assembly, Volume } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport AtomProxy from '../proxy/atom-proxy';\nimport Polymer from '../proxy/polymer';\nimport Buffer from '../buffer/buffer';\nimport { AtomDataFields, BondDataFields, AtomDataParams, BondDataParams } from '../structure/structure-data';\n// @ts-ignore: unused import Surface required for declaration only\nimport Surface from '../surface/surface'\n\n/**\n * Structure representation parameter object.\n * @typedef {Object} StructureRepresentationParameters - structure representation parameters\n * @mixes RepresentationParameters\n *\n * @property {String} radiusType - A list of possible sources of the radius used for rendering the representation. The radius can be based on the *vdW radius*, the *covalent radius* or the *B-factor* value of the corresponding atom. Additionally the radius can be based on the *secondary structure*. Alternatively, when set to *size*, the value from the *radius* parameter is used for all atoms.\n * @property {Float} radius - A number providing a fixed radius used for rendering the representation.\n * @property {Float} scale - A number that scales the value defined by the *radius* or the *radiusType* parameter.\n * @property {String} assembly - name of an assembly object. Included are the asymmetric unit (*AU*) corresponding to the coordinates given in the structure file, biological assemblies from *PDB*, *mmCIF* or *MMTF* files (*BU1*, *BU2*, ...), a filled (crystallographic) unitcell of a given space group (*UNITCELL*), a supercell consisting of a center unitcell and its 26 direct neighbors (*SUPERCELL*). Set to *default* to use the default asemmbly of the structure object.\n */\nexport interface StructureRepresentationParameters extends RepresentationParameters {\n radiusType: string\n radius: number\n scale: number\n assembly: string\n}\nexport interface StructureRepresentationData {\n bufferList: Buffer[]\n polymerList?: Polymer[]\n sview?: StructureView | Structure\n [k: string]: any\n}\n/**\n * Structure representation\n * @interface\n */\nabstract class StructureRepresentation extends Representation {\n\n protected selection: Selection\n protected dataList: StructureRepresentationData[]\n structure: Structure\n structureView: StructureView\n\n protected radiusType: RadiusType\n protected radiusData: {[k: number]: number}\n protected radiusSize: number\n protected radiusScale: number\n protected assembly: string\n protected defaultAssembly: string\n protected needsBuild: boolean\n\n /**\n * Create Structure representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {StructureRepresentationParameters} params - structure representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n const p = params || {}\n\n super(structure, viewer, p)\n\n this.type = 'structure'\n\n this.parameters = Object.assign({\n radiusType: {\n type: 'select', options: RadiusFactory.types\n },\n radiusData: {\n type: 'hidden'\n },\n radiusSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n radiusScale: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n assembly: null,\n defaultAssembly: {\n type: 'hidden'\n }\n }, this.parameters)\n\n /**\n * @type {Selection}\n * @private\n */\n this.selection = new Selection(p.sele)\n\n /**\n * @type {Array}\n * @private\n */\n this.dataList = []\n\n /**\n * @type {Structure}\n */\n this.structure = structure\n\n /**\n * @type {StructureView}\n */\n this.structureView = this.structure.getView(this.selection)\n\n if (structure.biomolDict) {\n const biomolOptions:{[key: string]: string} = {\n 'default': 'default',\n '': (structure.unitcell ? 'AU' : 'FULL')\n }\n Object.keys(structure.biomolDict).forEach(function (k) {\n biomolOptions[ k ] = k\n })\n this.parameters.assembly = {\n type: 'select',\n options: biomolOptions,\n rebuild: true\n }\n } else {\n this.parameters.assembly = null\n }\n }\n\n get defaultScale () {\n return {\n 'vdw': 1.0,\n 'covalent': 1.0,\n 'bfactor': 0.01,\n 'sstruc': 1.0\n }\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'element')\n\n this.setRadius(p.radius, p)\n\n this.radiusType = defaults(p.radiusType, 'vdw')\n this.radiusData = defaults(p.radiusData, {})\n this.radiusSize = defaults(p.radiusSize, 1.0)\n this.radiusScale = defaults(p.radiusScale, 1.0)\n this.assembly = defaults(p.assembly, 'default')\n this.defaultAssembly = defaults(p.defaultAssembly, '')\n\n if (p.quality === 'auto') {\n p.quality = this.getQuality()\n }\n\n super.init(p)\n\n this.selection.signals.stringChanged.add((/* sele */) => {\n this.build()\n })\n\n this.build()\n }\n\n setRadius (value: string | number | undefined, p: Partial) {\n const types = Object.keys(RadiusFactoryTypes)\n\n if (typeof value === 'string' && types.includes(value.toLowerCase())) {\n p.radiusType = value\n } else if (value !== undefined) {\n p.radiusType = 'size'\n p.radiusSize = value\n }\n\n return this\n }\n\n getAssembly (): Assembly {\n const name = this.assembly === 'default' ? this.defaultAssembly : this.assembly\n return this.structure.biomolDict[ name ]\n }\n\n getQuality () {\n let atomCount\n const s = this.structureView\n const assembly = this.getAssembly()\n if (assembly) {\n atomCount = assembly.getAtomCount(s)\n } else {\n atomCount = s.atomCount\n }\n if (Mobile) {\n atomCount *= 4\n }\n const backboneOnly = s.atomStore.count / s.residueStore.count < 2\n if (backboneOnly) {\n atomCount *= 10\n }\n\n if (atomCount < 15000) {\n return 'high'\n } else if (atomCount < 80000) {\n return 'medium'\n } else {\n return 'low'\n }\n }\n\n create () {\n if (this.structureView.atomCount === 0) return\n\n if (!this.structureView.hasCoords()) {\n this.needsBuild = true\n return\n } else {\n this.needsBuild = false\n }\n\n const assembly = this.getAssembly()\n\n if (assembly) {\n assembly.partList.forEach((part, i) => {\n const sview = part.getView(this.structureView)\n if (sview.atomCount === 0) return\n const data = this.createData(sview, i)\n if (data) {\n data.sview = sview\n data.instanceList = part.getInstanceList()\n this.dataList.push(data)\n }\n })\n } else {\n const data = this.createData(this.structureView, 0)\n if (data) {\n data.sview = this.structureView\n this.dataList.push(data)\n }\n }\n }\n\n abstract createData (sview: StructureView, k?: number): StructureRepresentationData|undefined\n\n update (what: AtomDataFields|BondDataFields) {\n if (this.lazy && !this.visible) {\n Object.assign(this.lazyProps.what, what)\n return\n }\n\n if (this.needsBuild) {\n this.build()\n return\n }\n\n this.dataList.forEach((data) => {\n if (data.bufferList.length > 0) {\n this.updateData(what, data)\n }\n }, this)\n }\n\n updateData (what?: AtomDataFields|BondDataFields, data?: any) {\n this.build()\n }\n\n getColorParams () {\n return {\n ...super.getColorParams(),\n structure: this.structure\n }\n }\n\n getRadiusParams (param?: any) {\n return {\n type: this.radiusType,\n scale: this.radiusScale,\n size: this.radiusSize,\n data: this.radiusData\n }\n }\n\n getAtomParams (what?: AtomDataFields, params?: AtomDataParams) {\n return Object.assign({\n what: what,\n colorParams: this.getColorParams(),\n radiusParams: this.getRadiusParams()\n }, params)\n }\n\n getBondParams (what?: BondDataFields, params?: BondDataParams) {\n return Object.assign({\n what: what,\n colorParams: this.getColorParams(),\n radiusParams: this.getRadiusParams()\n }, params)\n }\n\n getAtomRadius (atom: AtomProxy) {\n if (this.structureView.atomSet!.isSet(atom.index)) {\n const radiusFactory = new RadiusFactory(this.getRadiusParams())\n return radiusFactory.atomRadius(atom)\n }\n return 0\n }\n\n /**\n * Set representation parameters\n * @alias StructureRepresentation#setSelection\n * @param {String} string - selection string, see {@tutorial selection-language}\n * @param {Boolean} [silent] - don't trigger a change event in the selection\n * @return {StructureRepresentation} this object\n */\n setSelection (string: string, silent?: boolean) {\n this.selection.setString(string, silent)\n\n return this\n }\n\n /**\n * Set representation parameters\n * @alias StructureRepresentation#setParameters\n * @param {StructureRepresentationParameters} params - structure parameter object\n * @param {Object} [what] - buffer data attributes to be updated,\n * note that this needs to be implemented in the\n * derived classes. Generally it allows more\n * fine-grained control over updating than\n * forcing a rebuild.\n * @param {Boolean} what.position - update position data\n * @param {Boolean} what.color - update color data\n * @param {Boolean} [rebuild] - whether or not to rebuild the representation\n * @return {StructureRepresentation} this object\n */\n setParameters (params: Partial, what: AtomDataFields = {}, rebuild = false) {\n const p = params || {}\n\n this.setRadius(p.radius, p)\n\n if (p.radiusType !== undefined || p.radiusData !== undefined || p.radiusSize !== undefined || p.radiusScale !== undefined) {\n what.radius = true\n if (!ExtensionFragDepth || this.disableImpostor) {\n rebuild = true\n }\n }\n\n if (p.defaultAssembly !== undefined &&\n p.defaultAssembly !== this.defaultAssembly &&\n ((this.assembly === 'default' && p.assembly === undefined) ||\n p.assembly === 'default')\n ) {\n rebuild = true\n }\n\n super.setParameters(p, what, rebuild)\n\n return this\n }\n\n getParameters () {\n const params = Object.assign(\n super.getParameters(),\n {\n sele: this.selection ? this.selection.string : undefined,\n defaultAssembly: this.defaultAssembly\n }\n )\n\n return params\n }\n\n attach (callback: ()=> void) {\n const viewer = this.viewer\n const bufferList = this.bufferList\n\n this.dataList.forEach(function (data) {\n data.bufferList.forEach(function (buffer) {\n bufferList.push(buffer)\n viewer.add(buffer, data.instanceList)\n })\n })\n\n this.setVisibility(this.visible)\n callback()\n }\n\n clear () {\n this.dataList.length = 0\n\n super.clear()\n }\n\n dispose () {\n this.structureView.dispose()\n\n super.dispose()\n }\n}\n\nexport default StructureRepresentation\n","/**\n * @file Measurement Representation\n * @author Fred Ludlow \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { Color, Vector3, Matrix4 } from 'three'\n\nimport Selection from '../selection/selection'\nimport { Browser } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport { uniformArray, uniformArray3 } from '../math/array-utils'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { LabelRepresentationParameters } from './label-representation';\nimport TextBuffer, { TextBufferData } from '../buffer/text-buffer';\nimport { GenericColor } from '../types'\n\nexport interface LabelDataField {\n position?: boolean\n labelColor?: boolean\n labelSize?: boolean\n radius?: boolean\n labelText?: boolean\n}\n\n/**\n * Measurement representation parameter object.\n * @typedef {Object} MeasurementRepresentationParameters - measurement representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n *\n * @property {Float} labelSize - size of the distance label\n * @property {Color} labelColor - color of the distance label\n * @property {Boolean} labelVisible - visibility of the distance label\n * @property {Float} labelZOffset - offset in z-direction (i.e. in camera direction)\n */\nexport interface MeasurementRepresentationParameters extends StructureRepresentationParameters {\n labelVisible: boolean\n labelSize: number\n labelColor: GenericColor\n labelType: 'atomname'|'atomindex'|'occupancy'|'bfactor'|'serial'|'element'|'atom'|'resname'|'resno'|'res'|'text'|'qualified'\n labelText: string\n labelFormat: string\n labelGrouping: 'atom'|'residue'\n labelFontFamily: 'sans-serif'|'monospace'|'serif'\n labelFontStyle: 'normal'|'italic'\n labelFontWeight: 'normal'|'bold'\n labelsdf: boolean\n labelXOffset: number\n labelYOffset: number\n labelZOffset: number\n labelAttachment: 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n labelBorder: boolean\n labelBorderColor: GenericColor\n labelBorderWidth: number\n labelBackground: boolean\n labelBackgroundColor: GenericColor\n labelBackgroundMargin: number\n labelBackgroundOpacity: number\n labelFixedSize: boolean\n lineOpacity: number\n linewidth: number\n}\n\n/**\n * Measurement representation\n * @interface\n */\nabstract class MeasurementRepresentation extends StructureRepresentation {\n protected n: number\n protected labelVisible: boolean\n protected labelSize: number\n protected labelColor: GenericColor\n protected labelType: 'atomname'|'atomindex'|'occupancy'|'bfactor'|'serial'|'element'|'atom'|'resname'|'resno'|'res'|'text'|'qualified'\n protected labelText: string\n protected labelFormat: string\n protected labelGrouping: 'atom'|'residue'\n protected labelFontFamily: 'sans-serif'|'monospace'|'serif'\n protected labelFontStyle: 'normal'|'italic'\n protected labelFontWeight: 'normal'|'bold'\n protected labelsdf: boolean\n protected labelXOffset: number\n protected labelYOffset: number\n protected labelZOffset: number\n protected labelAttachment: 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n protected labelBorder: boolean\n protected labelBorderColor: GenericColor\n protected labelBorderWidth: number\n protected labelBackground: boolean\n protected labelBackgroundColor: GenericColor\n protected labelBackgroundMargin: number\n protected labelBackgroundOpacity: number\n protected labelFixedSize: boolean\n protected lineOpacity: number\n protected linewidth: number\n protected lineVisible: boolean\n\n protected textBuffer: TextBuffer\n /**\n * Handles common label settings and position logic for\n * distance, angle and dihedral representations\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.n = 0 // Subclass create sets value\n this.parameters = Object.assign({\n labelVisible: {\n type: 'boolean'\n },\n labelSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n labelColor: {\n type: 'color'\n },\n labelFontFamily: {\n type: 'select',\n options: {\n 'sans-serif': 'sans-serif',\n 'monospace': 'monospace',\n 'serif': 'serif'\n },\n buffer: 'fontFamily'\n },\n labelFontStyle: {\n type: 'select',\n options: {\n 'normal': 'normal',\n 'italic': 'italic'\n },\n buffer: 'fontStyle'\n },\n labelFontWeight: {\n type: 'select',\n options: {\n 'normal': 'normal',\n 'bold': 'bold'\n },\n buffer: 'fontWeight'\n },\n labelsdf: {\n type: 'boolean', buffer: 'sdf'\n },\n labelXOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: 'xOffset'\n },\n labelYOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: 'yOffset'\n },\n labelZOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: 'zOffset'\n },\n labelAttachment: {\n type: 'select',\n options: {\n 'bottom-left': 'bottom-left',\n 'bottom-center': 'bottom-center',\n 'bottom-right': 'bottom-right',\n 'middle-left': 'middle-left',\n 'middle-center': 'middle-center',\n 'middle-right': 'middle-right',\n 'top-left': 'top-left',\n 'top-center': 'top-center',\n 'top-right': 'top-right'\n },\n rebuild: true\n },\n labelBorder: {\n type: 'boolean', buffer: 'showBorder'\n },\n labelBorderColor: {\n type: 'color', buffer: 'borderColor'\n },\n labelBorderWidth: {\n type: 'number', precision: 2, max: 0.3, min: 0, buffer: 'borderWidth'\n },\n labelBackground: {\n type: 'boolean', rebuild: true\n },\n labelBackgroundColor: {\n type: 'color', buffer: 'backgroundColor'\n },\n labelBackgroundMargin: {\n type: 'number', precision: 2, max: 2, min: 0, rebuild: true\n },\n labelBackgroundOpacity: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: 'backgroundOpacity'\n },\n labelFixedSize: {\n type: 'boolean', buffer: 'fixedSize'\n },\n lineOpacity: {\n type: 'range', min: 0.0, max: 1.0, step: 0.01\n },\n linewidth: {\n type: 'integer', max: 50, min: 1, buffer: true\n }\n }, this.parameters, {\n flatShaded: null\n })\n }\n\n init (params: Partial) {\n const p = params || {}\n this.labelVisible = defaults(p.labelVisible, true)\n this.labelSize = defaults(p.labelSize, 2.0)\n this.labelColor = defaults(p.labelColor, 0xFFFFFF)\n this.labelFontFamily = defaults(p.labelFontFamily, 'sans-serif')\n this.labelFontStyle = defaults(p.labelFontstyle, 'normal')\n this.labelFontWeight = defaults(p.labelFontWeight, 'bold')\n this.labelsdf = defaults(p.labelsdf, Browser === 'Chrome')\n this.labelXOffset = defaults(p.labelXOffset, 0.0)\n this.labelYOffset = defaults(p.labelYOffset, 0.0)\n this.labelZOffset = defaults(p.labelZOffset, 0.5)\n this.labelAttachment = defaults(p.labelAttachment, 'bottom-left')\n this.labelBorder = defaults(p.labelBorder, false)\n this.labelBorderColor = defaults(p.labelBorderColor, 'lightgrey')\n this.labelBorderWidth = defaults(p.labelBorderWidth, 0.15)\n this.labelBackground = defaults(p.labelBackground, false)\n this.labelBackgroundColor = defaults(p.labelBackgroundColor, 'lightgrey')\n this.labelBackgroundMargin = defaults(p.labelBackgroundMargin, 0.5)\n this.labelBackgroundOpacity = defaults(p.labelBackgroundOpacity, 1.0)\n this.labelFixedSize = defaults(p.labelFixedSize, false)\n this.lineOpacity = defaults(p.lineOpacity, 1.0)\n this.linewidth = defaults(p.linewidth, 2)\n\n super.init(p)\n }\n\n // All measurements need to rebuild on position change\n update (what: LabelDataField) {\n if (what.position) {\n this.build()\n } else {\n super.update(what)\n }\n }\n\n updateData (what: LabelDataField & {[k: string]: any}, data: any) {\n const textData: TextBufferData | {} = {}\n if (!what || what.labelSize) {\n Object.assign(textData, {size: uniformArray(this.n, this.labelSize)})\n }\n\n if (!what || what.labelColor) {\n const c = new Color(this.labelColor)\n Object.assign(textData, {color: uniformArray3(this.n, c.r, c.g, c.b)})\n }\n\n this.textBuffer.setAttributes(textData as TextBufferData)\n }\n\n setParameters (params: Partial, what: LabelDataField = {}, rebuild = false) {\n if (params && params.labelSize) {\n what.labelSize = true\n }\n\n if (params && (params.labelColor || params.labelColor === 0x000000)) {\n what.labelColor = true\n rebuild = true\n }\n\n super.setParameters(params, what, rebuild)\n\n if (params && params.opacity !== undefined) {\n this.textBuffer.setParameters({ opacity: 1.0 }) // only opaque labels\n }\n\n if (params && params.labelVisible !== undefined) {\n this.setVisibility(this.visible)\n }\n\n return this\n }\n\n setVisibility (value: boolean, noRenderRequest?: boolean) {\n super.setVisibility(value, true)\n if (this.textBuffer) {\n this.textBuffer.setVisibility(\n this.labelVisible && this.visible\n )\n }\n\n if (!noRenderRequest) this.viewer.requestRender()\n\n return this\n }\n\n getLabelBufferParams (params: Partial = {}) {\n return super.getBufferParams(Object.assign({\n fontFamily: this.labelFontFamily,\n fontStyle: this.labelFontStyle,\n fontWeight: this.labelFontWeight,\n sdf: this.labelsdf,\n xOffset: this.labelXOffset,\n yOffset: this.labelYOffset,\n zOffset: this.labelZOffset,\n attachment: this.labelAttachment,\n showBorder: this.labelBorder,\n borderColor: this.labelBorderColor,\n borderWidth: this.labelBorderWidth,\n showBackground: this.labelBackground,\n backgroundColor: this.labelBackgroundColor,\n backgroundMargin: this.labelBackgroundMargin,\n backgroundOpacity: this.labelBackgroundOpacity,\n fixedSize: this.labelFixedSize,\n disablePicking: true,\n visible: this.labelVisible\n }, params, {\n opacity: 1.0 // only opaque labels\n }))\n }\n\n getAtomRadius () {\n return 0\n }\n}\n\n/**\n * MeasurementRepresentations take atom[Pair|Triple|Quad] parameters.\n *\n * Parses nested array of either integer atom indices or selection\n * expressions into a flat array of coordinates.\n *\n * @param {Structure} sview The structure to which the atoms refer\n * @param {Array} atoms Nested array of atom pairs|triples|quads as\n * Integer indices or selection expressions\n * @return {Float32Array} Flattened array of position coordinates\n */\nfunction parseNestedAtoms (sview: StructureView, atoms: (number|string)[][]) {\n const ap = sview.getAtomProxy()\n const sele = new Selection()\n\n const nSets = atoms.length\n if (nSets === 0) return new Float32Array(0)\n\n // Peek-ahead at first item to determine order and parse mode\n const order = atoms[ 0 ].length\n const selected = sview.getAtomSet()\n\n const a = new Float32Array(nSets * order * 3)\n\n let p = 0\n atoms.forEach(function (group) {\n let _break = false\n for (let j = 0; j < order; j++) {\n const value = group[ j ]\n if (typeof (value) === 'number' && Number.isInteger(value)) {\n if (selected.get(value)) {\n ap.index = value\n } else {\n _break = true\n break\n }\n } else {\n sele.setString(value as string)\n const atomIndices = sview.getAtomIndices(sele)\n if (atomIndices!.length) {\n ap.index = atomIndices![ 0 ]\n } else {\n _break = true\n break\n }\n }\n\n let offset = p + j * 3\n a[ offset++ ] = ap.x\n a[ offset++ ] = ap.y\n a[ offset++ ] = ap.z\n }\n if (!_break) p += 3 * order\n })\n\n return a.subarray(0, p)\n}\n\n/* out = v1 * cos(angle) + v2 * sin(angle) */\nfunction calcArcPoint (out: Float32Array, center: Float32Array, v1: Float32Array, v2: Float32Array, angle: number) {\n const x = Math.cos(angle)\n const y = Math.sin(angle)\n out[ 0 ] = center[ 0 ] + v1[ 0 ] * x + v2[ 0 ] * y\n out[ 1 ] = center[ 1 ] + v1[ 1 ] * x + v2[ 1 ] * y\n out[ 2 ] = center[ 2 ] + v1[ 2 ] * x + v2[ 2 ] * y\n}\n\nexport {\n MeasurementRepresentation as default,\n calcArcPoint,\n parseNestedAtoms\n}\n","/**\n * @file Edt\n * @author Alexander Rose \n * @private\n */\n\nimport { NumberArray } from '../types'\n\n// 2D Euclidean distance transform by Felzenszwalb & Huttenlocher https://cs.brown.edu/~pff/papers/dt-final.pdf\nexport function edt(data: NumberArray, width: number, height: number, f: NumberArray, d: NumberArray, v: NumberArray, z: NumberArray) {\n for (let x = 0; x < width; x++) {\n for (let y = 0; y < height; y++) {\n f[y] = data[y * width + x]\n }\n edt1d(f, d, v, z, height)\n for (let y = 0; y < height; y++) {\n data[y * width + x] = d[y]\n }\n }\n for (let y = 0; y < height; y++) {\n for (let x = 0; x < width; x++) {\n f[x] = data[y * width + x]\n }\n edt1d(f, d, v, z, width)\n for (let x = 0; x < width; x++) {\n data[y * width + x] = Math.sqrt(d[x])\n }\n }\n}\n\n// 1D squared distance transform\nfunction edt1d(f: NumberArray, d: NumberArray, v: NumberArray, z: NumberArray, n: number) {\n v[0] = 0\n z[0] = Number.MIN_SAFE_INTEGER\n z[1] = Number.MAX_SAFE_INTEGER\n\n for (let q = 1, k = 0; q < n; q++) {\n let s = ((f[q] + q * q) - (f[v[k]] + v[k] * v[k])) / (2 * q - 2 * v[k])\n while (s <= z[k]) {\n k--\n s = ((f[q] + q * q) - (f[v[k]] + v[k] * v[k])) / (2 * q - 2 * v[k])\n }\n k++\n v[k] = q\n z[k] = s\n z[k + 1] = Number.MAX_SAFE_INTEGER\n }\n\n for (let q = 0, k = 0; q < n; q++) {\n while (z[k + 1] < q) k++\n d[q] = (q - v[k]) * (q - v[k]) + f[v[k]]\n }\n}\n","/**\n * @file Text Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { Color, CanvasTexture, Vector3, Matrix4 } from 'three'\n\nimport '../shader/SDFFont.vert'\nimport '../shader/SDFFont.frag'\n\nimport { BufferRegistry } from '../globals'\nimport { createParams } from '../utils'\nimport MappedQuadBuffer from './mappedquad-buffer'\nimport { IgnorePicker } from '../utils/picker'\nimport { edt } from '../utils/edt'\nimport { BufferDefaultParameters, BufferParameterTypes, BufferData, BufferTypes, BufferParameters } from './buffer'\nimport { GenericColor } from '../types'\n\nconst TextAtlasCache: { [k: string]: TextAtlas } = {}\n\nfunction getTextAtlas (params: Partial) {\n const hash = JSON.stringify(params)\n if (TextAtlasCache[ hash ] === undefined) {\n TextAtlasCache[ hash ] = new TextAtlas(params)\n }\n return TextAtlasCache[ hash ]\n}\n\ntype TextFonts = 'sans-serif'|'monospace'|'serif'\ntype TextStyles = 'normal'|'italic'\ntype TextVariants = 'normal'\ntype TextWeights = 'normal'|'bold'\n\nexport const TextAtlasDefaultParams = {\n font: 'sans-serif' as TextFonts,\n size: 36,\n style: 'normal' as TextStyles,\n variant: 'normal' as TextVariants,\n weight: 'normal' as TextWeights,\n outline: 3,\n width: 1024,\n height: 1024\n}\nexport type TextAtlasParams = typeof TextAtlasDefaultParams\n\nexport type TextAtlasMap = { x: number, y: number, w: number, h: number }\n\nexport class TextAtlas {\n parameters: TextAtlasParams\n\n gamma = 1\n mapped: { [k: string]: TextAtlasMap } = {}\n scratchW = 0\n scratchH = 0\n currentX = 0\n currentY = 0\n\n cutoff = 0.25\n padding: number\n radius: number\n\n gridOuter: Float64Array\n gridInner: Float64Array\n f: Float64Array\n d: Float64Array\n z: Float64Array\n v: Int16Array\n\n paddedSize: number\n middle: number\n\n texture: CanvasTexture\n canvas: HTMLCanvasElement\n context: CanvasRenderingContext2D\n\n lineHeight: number\n maxWidth: number\n colors: string[]\n scratch: Uint8Array\n canvas2: HTMLCanvasElement\n context2: CanvasRenderingContext2D\n data: Uint8Array\n\n placeholder: TextAtlasMap\n\n constructor (params: Partial = {}) {\n this.parameters = createParams(params, TextAtlasDefaultParams)\n const p = this.parameters\n\n this.radius = p.size / 8\n this.padding = p.size / 3\n\n // Prepare line-height with room for outline and descenders/ascenders\n const lineHeight = this.lineHeight = p.size + 2 * p.outline + Math.round(p.size / 4)\n const maxWidth = this.maxWidth = p.width / 4\n\n // Prepare scratch canvas\n const canvas = this.canvas = document.createElement('canvas')\n canvas.width = maxWidth\n canvas.height = lineHeight\n\n const ctx = this.context = this.canvas.getContext('2d')!\n ctx.font = `${p.style} ${p.variant} ${p.weight} ${p.size}px ${p.font}`\n ctx.fillStyle = 'black'\n ctx.textAlign = 'left'\n ctx.textBaseline = 'bottom'\n ctx.lineJoin = 'round'\n\n // temporary arrays for the distance transform\n this.gridOuter = new Float64Array(lineHeight * maxWidth)\n this.gridInner = new Float64Array(lineHeight * maxWidth)\n this.f = new Float64Array(Math.max(lineHeight, maxWidth))\n this.d = new Float64Array(Math.max(lineHeight, maxWidth))\n this.z = new Float64Array(Math.max(lineHeight, maxWidth) + 1)\n this.v = new Int16Array(Math.max(lineHeight, maxWidth))\n\n //\n this.data = new Uint8Array(p.width * p.height * 4)\n this.canvas2 = document.createElement('canvas')\n this.canvas2.width = p.width\n this.canvas2.height = p.height\n this.context2 = this.canvas2.getContext('2d')!\n\n // Replacement Character\n this.placeholder = this.map(String.fromCharCode(0xFFFD))\n\n // Basic Latin (subset)\n for (let i = 0x0020; i <= 0x007E; ++i) {\n this.map(String.fromCharCode(i))\n }\n\n // TODO: to slow to always prepare them\n // // Latin-1 Supplement (subset)\n // for (let i = 0x00A1; i <= 0x00FF; ++i) {\n // this.map(String.fromCharCode(i))\n // }\n\n // Degree sign\n this.map(String.fromCharCode(0x00B0))\n\n // // Greek and Coptic (subset)\n // for (let i = 0x0391; i <= 0x03C9; ++i) {\n // this.map(String.fromCharCode(i))\n // }\n\n // // Cyrillic (subset)\n // for (let i = 0x0400; i <= 0x044F; ++i) {\n // this.map(String.fromCharCode(i))\n // }\n\n // Angstrom Sign\n this.map(String.fromCharCode(0x212B))\n\n this.texture = new CanvasTexture(this.canvas2)\n this.texture.flipY = false\n this.texture.needsUpdate = true\n }\n\n map (text: string) {\n const p = this.parameters\n\n if (this.mapped[ text ] === undefined) {\n this.draw(text)\n\n if (this.currentX + this.scratchW > p.width) {\n this.currentX = 0\n this.currentY += this.scratchH\n }\n if (this.currentY + this.scratchH > p.height) {\n console.warn('canvas to small')\n }\n\n this.mapped[ text ] = {\n x: this.currentX,\n y: this.currentY,\n w: this.scratchW,\n h: this.scratchH\n }\n\n this.context2.drawImage(\n this.canvas,\n 0, 0,\n this.scratchW, this.scratchH,\n this.currentX, this.currentY,\n this.scratchW, this.scratchH\n )\n\n this.currentX += this.scratchW\n }\n\n return this.mapped[ text ]\n }\n\n get (text: string) {\n return this.mapped[ text ] || this.placeholder\n }\n\n draw (text: string) {\n const p = this.parameters\n\n const h = this.lineHeight\n const o = p.outline\n const ctx = this.context\n // const dst = this.scratch\n const max = this.maxWidth\n // const colors = this.colors\n\n // Bottom aligned, take outline into account\n const x = o\n const y = h - p.outline\n\n // Measure text\n const m = ctx.measureText(text)\n const w = Math.min(max, Math.ceil(m.width + 2 * x + 1))\n\n const n = w * h\n\n // Clear scratch area\n ctx.clearRect(0, 0, w, h)\n\n // Draw text\n ctx.fillText(text, x, y)\n\n const imageData = ctx.getImageData(0, 0, w, h)\n const data = imageData.data\n\n for (let i = 0; i < n; i++) {\n const a = imageData.data[i * 4 + 3] / 255; // alpha value\n this.gridOuter[i] = a === 1 ? 0 : a === 0 ? Number.MAX_SAFE_INTEGER : Math.pow(Math.max(0, 0.5 - a), 2);\n this.gridInner[i] = a === 1 ? Number.MAX_SAFE_INTEGER : a === 0 ? 0 : Math.pow(Math.max(0, a - 0.5), 2);\n }\n\n edt(this.gridOuter, w, h, this.f, this.d, this.v, this.z);\n edt(this.gridInner, w, h, this.f, this.d, this.v, this.z);\n\n for (let i = 0; i < n; i++) {\n const d = this.gridOuter[i] - this.gridInner[i];\n data[i * 4 + 3] = Math.max(0, Math.min(255, Math.round(255 - 255 * (d / this.radius + this.cutoff))));\n }\n\n ctx.putImageData(imageData, 0, 0)\n this.scratchW = w\n this.scratchH = h\n }\n}\n\n/**\n * Text buffer parameter object.\n * @typedef {Object} TextBufferParameters - text buffer parameters\n *\n * @property {Float} opacity - translucency: 1 is fully opaque, 0 is fully transparent\n * @property {Integer} clipNear - position of camera near/front clipping plane\n * in percent of scene bounding box\n * @property {String} labelType - type of the label, one of:\n * \"atomname\", \"atomindex\", \"occupancy\", \"bfactor\",\n * \"serial\", \"element\", \"atom\", \"resname\", \"resno\",\n * \"res\", \"text\", \"qualified\". When set to \"text\", the\n * `labelText` list is used.\n * @property {String[]} labelText - list of label strings, must set `labelType` to \"text\"\n * to take effect\n * @property {String} fontFamily - font family, one of: \"sans-serif\", \"monospace\", \"serif\"\n * @property {String} fontStyle - font style, \"normal\" or \"italic\"\n * @property {String} fontWeight - font weight, \"normal\" or \"bold\"\n * @property {Float} xOffset - offset in x-direction\n * @property {Float} yOffset - offset in y-direction\n * @property {Float} zOffset - offset in z-direction (i.e. in camera direction)\n * @property {String} attachment - attachment of the label, one of:\n * \"bottom-left\", \"bottom-center\", \"bottom-right\",\n * \"middle-left\", \"middle-center\", \"middle-right\",\n * \"top-left\", \"top-center\", \"top-right\"\n * @property {Boolean} showBorder - show border/outline\n * @property {Color} borderColor - color of the border/outline\n * @property {Float} borderWidth - width of the border/outline\n * @property {Boolean} showBackground - show background rectangle\n * @property {Color} backgroundColor - color of the background\n * @property {Float} backgroundMargin - width of the background\n * @property {Float} backgroundOpacity - opacity of the background\n * @property {Boolean} fixedSize - show text with a fixed pixel size\n */\n\nexport interface TextBufferData extends BufferData {\n size: Float32Array\n text: string[]\n}\n\ntype TextAttachments = 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n\nexport const TextBufferDefaultParameters = Object.assign({\n fontFamily: 'sans-serif' as TextFonts,\n fontStyle: 'normal' as TextStyles,\n fontWeight: 'bold' as TextWeights,\n fontSize: 36,\n xOffset: 0.0,\n yOffset: 0.0,\n zOffset: 0.5,\n attachment: 'bottom-left' as TextAttachments,\n showBorder: false,\n borderColor: 'lightgrey' as number|string,\n borderWidth: 0.15,\n showBackground: false,\n backgroundColor: 'lightgrey' as number|string,\n backgroundMargin: 0.5,\n backgroundOpacity: 1.0,\n forceTransparent: true,\n fixedSize: false\n}, BufferDefaultParameters)\nexport type TextBufferParameters = BufferParameters & {\n fontFamily: TextFonts,\n fontStyle: TextStyles,\n fontWeight: TextWeights,\n fontSize: number,\n xOffset: number,\n yOffset: number,\n zOffset: number,\n attachment: TextAttachments,\n showBorder: boolean,\n borderColor: GenericColor,\n borderWidth: number,\n showBackground: boolean,\n backgroundColor: GenericColor,\n backgroundMargin: number,\n backgroundOpacity: number,\n forceTransparent: boolean,\n fixedSize: boolean\n}\n\nconst TextBufferParameterTypes = Object.assign({\n fontFamily: { uniform: true },\n fontStyle: { uniform: true },\n fontWeight: { uniform: true },\n fontSize: { uniform: true },\n xOffset: { uniform: true },\n yOffset: { uniform: true },\n zOffset: { uniform: true },\n showBorder: { uniform: true },\n borderColor: { uniform: true },\n borderWidth: { uniform: true },\n backgroundColor: { uniform: true },\n backgroundOpacity: { uniform: true },\n fixedSize: { updateShader: true }\n}, BufferParameterTypes)\n\nfunction getCharCount (data: TextBufferData, params: Partial) {\n const n = data.position!.length / 3\n let charCount = 0\n for (let i = 0; i < n; ++i) {\n charCount += data.text[ i ].length\n }\n if (params.showBackground) charCount += n\n\n return charCount\n}\n\n/**\n * Text buffer. Renders screen-aligned text strings.\n *\n * @example\n * var textBuffer = new TextBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * size: new Float32Array([ 2 ]),\n * text: [ \"Hello\" ]\n * });\n */\nclass TextBuffer extends MappedQuadBuffer {\n parameterTypes = TextBufferParameterTypes\n get defaultParameters() { return TextBufferDefaultParameters }\n parameters: TextBufferParameters\n\n alwaysTransparent = true\n hasWireframe = false\n isText = true\n vertexShader = 'SDFFont.vert'\n fragmentShader = 'SDFFont.frag'\n\n text: string[]\n positionCount: number\n texture: CanvasTexture\n textAtlas: TextAtlas\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.size - sizes\n * @param {String[]} data.text - text strings\n * @param {TextBufferParameters} params - parameters object\n */\n constructor (data: TextBufferData, params: Partial = {}) {\n super({\n position: new Float32Array(getCharCount(data, params) * 3),\n color: new Float32Array(getCharCount(data, params) * 3),\n picking: new IgnorePicker()\n }, params)\n\n this.text = data.text\n this.positionCount = data.position!.length / 3\n\n this.addUniforms({\n 'fontTexture': { value: null },\n 'xOffset': { value: this.parameters.xOffset },\n 'yOffset': { value: this.parameters.yOffset },\n 'zOffset': { value: this.parameters.zOffset },\n 'ortho': { value: false },\n 'showBorder': { value: this.parameters.showBorder },\n 'borderColor': { value: new Color(this.parameters.borderColor as number) },\n 'borderWidth': { value: this.parameters.borderWidth },\n 'backgroundColor': { value: new Color(this.parameters.backgroundColor as number) },\n 'backgroundOpacity': { value: this.parameters.backgroundOpacity },\n 'canvasHeight': { value: 1.0 },\n 'pixelRatio': { value: 1.0 }\n })\n\n this.addAttributes({\n 'inputTexCoord': { type: 'v2', value: null },\n 'inputSize': { type: 'f', value: null }\n })\n\n this.setAttributes(data)\n\n this.makeTexture()\n this.makeMapping()\n }\n\n makeMaterial () {\n super.makeMaterial()\n\n const tex = this.texture\n\n const m = this.material\n m.transparent = true\n m.extensions.derivatives = true\n m.lights = false\n m.uniforms.fontTexture.value = tex\n m.needsUpdate = true\n\n const wm = this.wireframeMaterial\n wm.transparent = true\n wm.extensions.derivatives = true\n wm.lights = false\n wm.uniforms.fontTexture.value = tex\n wm.needsUpdate = true\n\n const pm = this.pickingMaterial\n pm.extensions.derivatives = true\n pm.lights = false\n pm.uniforms.fontTexture.value = tex\n pm.needsUpdate = true\n }\n\n setAttributes (data: Partial = {}) {\n let position, size, color\n let aPosition, inputSize, aColor\n\n const text = this.text\n const attributes = this.geometry.attributes as any // TODO\n\n if (data.position) {\n position = data.position\n aPosition = attributes.position.array\n attributes.position.needsUpdate = true\n }\n\n if (data.size) {\n size = data.size\n inputSize = attributes.inputSize.array\n attributes.inputSize.needsUpdate = true\n }\n\n if (data.color) {\n color = data.color\n aColor = attributes.color.array\n attributes.color.needsUpdate = true\n }\n\n const n = this.positionCount\n\n let j, o\n let iCharAll = 0\n let txt, iChar, nChar\n\n for (let v = 0; v < n; ++v) {\n o = 3 * v\n txt = text[ v ]\n nChar = txt.length\n if (this.parameters.showBackground) nChar += 1\n\n for (iChar = 0; iChar < nChar; ++iChar, ++iCharAll) {\n for (let m = 0; m < 4; m++) {\n j = iCharAll * 4 * 3 + (3 * m)\n\n if (position) {\n aPosition[ j ] = position[ o ]\n aPosition[ j + 1 ] = position[ o + 1 ]\n aPosition[ j + 2 ] = position[ o + 2 ]\n }\n\n if (size) {\n inputSize[ (iCharAll * 4) + m ] = size[ v ]\n }\n\n if (color) {\n aColor[ j ] = color[ o ]\n aColor[ j + 1 ] = color[ o + 1 ]\n aColor[ j + 2 ] = color[ o + 2 ]\n }\n }\n }\n }\n }\n\n makeTexture () {\n this.textAtlas = getTextAtlas({\n font: this.parameters.fontFamily,\n style: this.parameters.fontStyle,\n weight: this.parameters.fontWeight,\n size: this.parameters.fontSize\n })\n\n this.texture = this.textAtlas.texture\n }\n\n makeMapping () {\n const ta = this.textAtlas\n const text = this.text\n const attachment = this.parameters.attachment\n const margin = (ta.lineHeight * this.parameters.backgroundMargin * 0.1) - 10\n\n const attribs = this.geometry.attributes as any // TODO\n const inputTexCoord = attribs.inputTexCoord.array\n const inputMapping = attribs.mapping.array\n\n const n = this.positionCount\n let iCharAll = 0\n let c, i, txt, xadvance, iChar, nChar, xShift, yShift\n\n for (let v = 0; v < n; ++v) {\n txt = text[ v ]\n xadvance = 0\n nChar = txt.length\n\n // calculate width\n for (iChar = 0; iChar < nChar; ++iChar) {\n c = ta.get(txt[ iChar ])\n xadvance += c.w - 2 * ta.parameters.outline\n }\n\n // attachment\n if (attachment.startsWith('top')) {\n yShift = ta.lineHeight / 1.25\n } else if (attachment.startsWith('middle')) {\n yShift = ta.lineHeight / 2.5\n } else {\n yShift = 0 // \"bottom\"\n }\n if (attachment.endsWith('right')) {\n xShift = xadvance\n } else if (attachment.endsWith('center')) {\n xShift = xadvance / 2\n } else {\n xShift = 0 // \"left\"\n }\n xShift += ta.parameters.outline\n yShift += ta.parameters.outline\n\n // background\n if (this.parameters.showBackground) {\n i = iCharAll * 2 * 4\n inputMapping[ i + 0 ] = -ta.lineHeight / 6 - xShift - margin // top left\n inputMapping[ i + 1 ] = ta.lineHeight - yShift + margin\n inputMapping[ i + 2 ] = -ta.lineHeight / 6 - xShift - margin // bottom left\n inputMapping[ i + 3 ] = 0 - yShift - margin\n inputMapping[ i + 4 ] = xadvance + ta.lineHeight / 6 - xShift + 2 * ta.parameters.outline + margin // top right\n inputMapping[ i + 5 ] = ta.lineHeight - yShift + margin\n inputMapping[ i + 6 ] = xadvance + ta.lineHeight / 6 - xShift + 2 * ta.parameters.outline + margin // bottom right\n inputMapping[ i + 7 ] = 0 - yShift - margin\n inputTexCoord[ i + 0 ] = 10\n inputTexCoord[ i + 2 ] = 10\n inputTexCoord[ i + 4 ] = 10\n inputTexCoord[ i + 6 ] = 10\n iCharAll += 1\n }\n\n xadvance = 0\n\n for (iChar = 0; iChar < nChar; ++iChar, ++iCharAll) {\n c = ta.get(txt[ iChar ])\n i = iCharAll * 2 * 4\n\n inputMapping[ i + 0 ] = xadvance - xShift // top left\n inputMapping[ i + 1 ] = c.h - yShift\n inputMapping[ i + 2 ] = xadvance - xShift // bottom left\n inputMapping[ i + 3 ] = 0 - yShift\n inputMapping[ i + 4 ] = xadvance + c.w - xShift // top right\n inputMapping[ i + 5 ] = c.h - yShift\n inputMapping[ i + 6 ] = xadvance + c.w - xShift // bottom right\n inputMapping[ i + 7 ] = 0 - yShift\n\n const texWidth = ta.parameters.width\n const texHeight = ta.parameters.height\n\n const texCoords = [\n c.x / texWidth, c.y / texHeight, // top left\n c.x / texWidth, (c.y + c.h) / texHeight, // bottom left\n (c.x + c.w) / texWidth, c.y / texHeight, // top right\n (c.x + c.w) / texWidth, (c.y + c.h) / texHeight // bottom right\n ]\n inputTexCoord.set(texCoords, i)\n\n xadvance += c.w - 2 * ta.parameters.outline\n }\n }\n\n attribs.inputTexCoord.needsUpdate = true\n attribs.mapping.needsUpdate = true\n }\n\n getDefines (type: BufferTypes) {\n const defines = super.getDefines(type)\n\n if (this.parameters.fixedSize) {\n defines.FIXED_SIZE = 1\n }\n\n return defines\n }\n\n setUniforms (data: any) { // TODO\n if (data && (\n data.fontFamily !== undefined ||\n data.fontStyle !== undefined ||\n data.fontWeight !== undefined ||\n data.fontSize !== undefined\n )) {\n this.makeTexture()\n this.makeMapping()\n this.texture.needsUpdate = true\n data.fontTexture = this.texture\n }\n\n super.setUniforms(data)\n }\n}\n\nBufferRegistry.add('text', TextBuffer)\n\nexport default TextBuffer\n","/**\n * @file Wide Line Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3 required for declaration only\nimport { Vector2, Vector3, Matrix4 } from 'three'\n\nimport '../shader/WideLine.vert'\nimport '../shader/WideLine.frag'\n\nimport { BufferRegistry } from '../globals'\nimport MappedQuadBuffer from './mappedquad-buffer'\nimport { BufferDefaultParameters, BufferParameterTypes, BufferData, BufferParameters } from './buffer'\n\nexport interface WideLineBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n color2: Float32Array\n}\n\nexport const WideLineBufferDefaultParameters = Object.assign({\n linewidth: 2\n}, BufferDefaultParameters)\nexport type WideLineBufferParameters = BufferParameters & { linewidth: number }\n\nconst WideLineBufferParameterTypes = Object.assign({\n linewidth: { uniform: true }\n}, BufferParameterTypes)\n\n/**\n * Wide Line buffer. Draws lines with a fixed width in pixels.\n *\n * @example\n * var lineBuffer = new WideLineBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ])\n * });\n */\nclass WideLineBuffer extends MappedQuadBuffer {\n parameterTypes = WideLineBufferParameterTypes\n get defaultParameters() { return WideLineBufferDefaultParameters }\n parameters: WideLineBufferParameters\n\n vertexShader = 'WideLine.vert'\n fragmentShader ='WideLine.frag'\n\n constructor (data: Partial, params: Partial = {}) {\n super(data, params)\n\n if (!data.color2 && data.color) data.color2 = data.color\n\n this.addUniforms({\n 'linewidth': { value: this.parameters.linewidth },\n 'resolution': { value: new Vector2() },\n 'projectionMatrixInverse': { value: new Matrix4() }\n })\n\n this.addAttributes({\n 'position1': { type: 'v3', value: null },\n 'position2': { type: 'v3', value: null },\n 'color2': { type: 'c', value: null }\n })\n\n this.setAttributes(data)\n this.makeMapping()\n }\n\n setParameters (params: Partial) {\n super.setParameters(params)\n }\n}\n\nBufferRegistry.add('wideline', WideLineBuffer)\n\nexport default WideLineBuffer\n","/**\n * @file Angle Representation\n * @author Fred Ludlow \n * @private\n */\nimport { Color } from 'three'\n\nimport { RepresentationRegistry } from '../globals'\nimport MeasurementRepresentation, { parseNestedAtoms, calcArcPoint, MeasurementRepresentationParameters, LabelDataField } from './measurement-representation'\nimport { defaults } from '../utils'\n\nimport MeshBuffer from '../buffer/mesh-buffer'\nimport TextBuffer, { TextBufferData, TextBufferParameters } from '../buffer/text-buffer'\nimport WideLineBuffer, { WideLineBufferData } from '../buffer/wideline-buffer'\n\nimport { v3add, v3cross, v3dot, v3fromArray, v3length, v3new,\n v3normalize, v3sub, v3toArray } from '../math/vector-utils'\nimport { copyArray, uniformArray, uniformArray3 } from '../math/array-utils'\nimport { RAD2DEG } from '../math/math-constants'\nimport { getFixedLengthWrappedDashData } from '../geometry/dash'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { BufferData } from '../buffer/buffer';\nimport { StructureRepresentationData, StructureRepresentationParameters } from './structure-representation';\n\n/**\n * @typedef {Object} AngleRepresentationParameters - angle representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n * @mixes MeasurementRepresentationParameters\n *\n * @property {String} atomTriple - list of triplets of selection strings\n * or atom indices\n * @property {Boolean} vectorVisible - Indicate the 3 points for each angle by drawing lines 1-2-3\n * @property {Boolean} arcVisible - Show the arc outline for each angle\n * @property {Number} lineOpacity - opacity for the line part of the representation\n * @property {Number} linewidth - width for line part of representation\n * @property {Boolean} sectorVisible - Show the filled arc for each angle\n */\n\nexport interface AngleRepresentationParameters extends MeasurementRepresentationParameters {\n atomTriple: (number|string)[][]\n vectorVisible: boolean\n arcVisible: boolean\n lineOpacity: number\n lineWidth: number\n sectorVisible: boolean\n}\n\n/**\n * Angle representation object\n *\n * Reperesentation consists of four parts, visibility can be set for each\n * label - the text label with the angle size\n * vectors - lines joining the three points\n * sector - triangles representing the angle\n * arc - line bordering the sector\n *\n * @param {Structure} structure - the structure to measure angles in\n * @param {Viewer} viewer - a viewer object\n * @param {AngleRepresentationParameters} params - angle representation parameters\n */\nclass AngleRepresentation extends MeasurementRepresentation {\n protected atomTriple: (number|string)[][]\n protected vectorVisible: boolean\n protected arcVisible: boolean\n protected lineOpacity: number\n protected lineWidth: number\n protected sectorVisible: boolean\n protected vectorBuffer: WideLineBuffer\n arcLength: number\n sectorLength: number\n arcBuffer: WideLineBuffer\n sectorBuffer: MeshBuffer\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'angle'\n\n this.parameters = Object.assign({\n atomTriple: {\n type: 'hidden', rebuild: true\n },\n vectorVisible: {\n type: 'boolean', default: true\n },\n arcVisible: {\n type: 'boolean', default: true\n },\n sectorVisible: {\n type: 'boolean', default: true\n }\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.side = defaults(p.side, 'double')\n p.opacity = defaults(p.opacity, 0.5)\n\n this.atomTriple = defaults(p.atomTriple, [])\n this.arcVisible = defaults(p.arcVisible, true)\n this.sectorVisible = defaults(p.sectorVisible, true)\n this.vectorVisible = defaults(p.vectorVisible, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n if (!sview.atomCount || !this.atomTriple.length) return\n\n const atomPosition = atomTriplePositions(sview, this.atomTriple)\n const angleData = getAngleData(atomPosition)\n const n = this.n = angleData.labelPosition.length / 3\n\n const labelColor = new Color(this.labelColor)\n\n // Create buffers\n this.textBuffer = new TextBuffer({\n position: angleData.labelPosition,\n size: uniformArray(n, this.labelSize),\n color: uniformArray3(n, labelColor.r, labelColor.g, labelColor.b),\n text: angleData.labelText\n } as TextBufferData, this.getLabelBufferParams() as TextBufferParameters)\n\n const c = new Color(this.colorValue)\n\n this.vectorBuffer = new WideLineBuffer(\n getFixedLengthWrappedDashData({\n position1: angleData.vectorPosition1,\n position2: angleData.vectorPosition2,\n color: uniformArray3(2 * n, c.r, c.g, c.b),\n color2: uniformArray3(2 * n, c.r, c.g, c.b)\n } as WideLineBufferData),\n this.getBufferParams({\n linewidth: this.linewidth,\n visible: this.vectorVisible,\n opacity: this.lineOpacity\n })\n )\n\n this.arcLength = angleData.arcPosition1.length / 3\n\n this.arcBuffer = new WideLineBuffer(\n getFixedLengthWrappedDashData({\n position1: angleData.arcPosition1,\n position2: angleData.arcPosition2,\n color: uniformArray3(this.arcLength, c.r, c.g, c.b),\n color2: uniformArray3(this.arcLength, c.r, c.g, c.b)\n } as WideLineBufferData), this.getBufferParams({\n linewidth: this.linewidth,\n visible: this.arcVisible,\n opacity: this.lineOpacity\n }))\n\n this.sectorLength = angleData.sectorPosition.length / 3\n\n this.sectorBuffer = new MeshBuffer({\n position: angleData.sectorPosition,\n color: uniformArray3(this.sectorLength, c.r, c.g, c.b)\n } as BufferData, this.getBufferParams({\n visible: this.sectorVisible\n }))\n\n return {\n bufferList: [\n this.textBuffer,\n this.vectorBuffer,\n this.arcBuffer,\n this.sectorBuffer\n ]\n }\n }\n\n updateData (what: LabelDataField & {color?: boolean}, data: StructureRepresentationData) {\n super.updateData(what, data)\n const vectorData = {}\n const arcData = {}\n const sectorData = {}\n\n if (what.color) {\n const c = new Color(this.colorValue)\n Object.assign(vectorData, {\n color: uniformArray3(this.n * 2, c.r, c.g, c.b),\n color2: uniformArray3(this.n * 2, c.r, c.g, c.b)\n })\n Object.assign(arcData, {\n color: uniformArray3(this.arcLength, c.r, c.g, c.b),\n color2: uniformArray3(this.arcLength, c.r, c.g, c.b)\n })\n Object.assign(sectorData, {\n color: uniformArray3(this.sectorLength, c.r, c.g, c.b)\n })\n }\n\n // if (what.sectorOpacity) {\n // this.sectorBuffer.opacity = what.sectorOpacity\n // }\n\n this.vectorBuffer.setAttributes(vectorData)\n this.arcBuffer.setAttributes(arcData)\n this.sectorBuffer.setAttributes(sectorData)\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n super.setParameters(params, what, rebuild)\n\n if (params && (\n params.vectorVisible !== undefined ||\n params.arcVisible !== undefined ||\n params.sectorVisible !== undefined)) {\n this.setVisibility(this.visible)\n }\n\n if (params && params.lineOpacity) {\n this.vectorBuffer.setParameters({ opacity: params.lineOpacity })\n this.arcBuffer.setParameters({ opacity: params.lineOpacity })\n }\n\n if (params && params.opacity !== undefined) {\n this.vectorBuffer.setParameters({ opacity: this.lineOpacity })\n this.arcBuffer.setParameters({ opacity: this.lineOpacity })\n }\n\n if (params && params.linewidth) {\n this.vectorBuffer.setParameters({ linewidth: params.linewidth })\n this.arcBuffer.setParameters({ linewidth: params.linewidth })\n }\n\n return this\n }\n\n setVisibility (value: boolean, noRenderRequest?: boolean) {\n super.setVisibility(value, true)\n\n if (this.vectorBuffer) {\n this.vectorBuffer.setVisibility(this.vectorVisible && this.visible)\n }\n\n if (this.arcBuffer) {\n this.arcBuffer.setVisibility(this.arcVisible && this.visible)\n }\n\n if (this.sectorBuffer) {\n this.sectorBuffer.setVisibility(this.sectorVisible && this.visible)\n }\n\n if (!noRenderRequest) this.viewer.requestRender()\n\n return this\n }\n}\n\n/**\n * Ensure mid point does not coincide with first or second\n * @param {Float32Array} position 9*nAngle array of coordinates\n * @return {Float32Array} Filtered position array, may be shorter\n */\nfunction validatePositions (position: Float32Array) {\n const include = []\n const n = position.length / 9\n for (let i = 0; i < n; i++) {\n // Check that first point not same as second and that second not same as third\n let okay = true\n for (let j = i; j < i + 3; j += 3) {\n if (position[j] === position[j + 3] &&\n position[j + 1] === position[j + 4] &&\n position[j + 2] === position[j + 5]) {\n okay = false\n }\n }\n if (okay) include.push(i)\n }\n const outPosition = new Float32Array(include.length * 9)\n let outIdx = 0\n include.forEach(function (i) {\n copyArray(position, outPosition, i * 9, outIdx * 9, 9)\n outIdx++\n })\n return outPosition\n}\n\nfunction atomTriplePositions (sview: StructureView, atomTriple: (number|string)[][]) {\n return validatePositions(parseNestedAtoms(sview, atomTriple))\n}\n\n/**\n * Converts triple positions into data required to build various buffers.\n */\nfunction getAngleData (position: Float32Array, params: Partial = {}) {\n const angleStep = defaults(params.angleStep, Math.PI / 90)\n const n = position.length / 9\n const angles = new Float32Array(n)\n const labelPosition = new Float32Array(n * 3)\n const labelText = new Array(n)\n\n const vectorPosition1 = new Float32Array(n * 6) // Two lines per angle\n const vectorPosition2 = new Float32Array(n * 6)\n\n const arcPositionTmp1 = new Array(n) // Start points for arc lines\n const arcPositionTmp2 = new Array(n) // End points for arc lines\n const sectorPositionTmp = new Array(n) // Triangle points\n\n let totalSegments = 0\n\n // Re-used vectors etc\n const p1 = v3new() // Positions of points for each angel\n const p2 = v3new()\n const p3 = v3new()\n const v21 = v3new() // Vectors\n const v23 = v3new()\n const cross = v3new() // Cross product v21xv23\n const cross2 = v3new() // In-plane cross product v21 x (v21 x v23)\n const labelTmp = v3new()\n const arcPoint = v3new()\n\n for (var i = 0; i < n; i++) {\n let p = 9 * i\n v3fromArray(p1, position, p)\n v3fromArray(p2, position, p + 3)\n v3fromArray(p3, position, p + 6)\n\n let v = 6 * i\n v3toArray(p1, vectorPosition1, v)\n v3toArray(p2, vectorPosition2, v)\n v3toArray(p2, vectorPosition1, v + 3)\n v3toArray(p3, vectorPosition2, v + 3)\n\n v3sub(v21, p1, p2)\n v3sub(v23, p3, p2)\n\n v3normalize(v21, v21) // validatePositions ensures valid\n v3normalize(v23, v23)\n\n v3cross(cross, v21, v23)\n const crossLength = v3length(cross)\n const dot = v3dot(v21, v23)\n\n const angle = angles[i] = Math.atan2(crossLength, dot)\n labelText[i] = (RAD2DEG * angle).toFixed(1) + String.fromCharCode(0x00B0)\n\n if (v3length(cross) === 0.0) {\n // Angle exactly 0/180, pick an arbitrary direction\n cross[ 0 ] = 1.0\n cross[ 1 ] = 0.0\n cross[ 2 ] = 0.0\n }\n v3cross(cross2, cross, v21)\n v3normalize(cross2, cross2)\n\n calcArcPoint(labelTmp, p2, v21, cross2, angle / 2.0)\n // TODO: Scale label position?\n v3toArray(labelTmp, labelPosition, 3 * i)\n\n // Build the arc and sector\n\n const nSegments = Math.ceil(angle / angleStep)\n const sectorVertices = new Float32Array(nSegments * 9)\n sectorPositionTmp[ i ] = sectorVertices\n const arcVertices1 = new Float32Array(nSegments * 3)\n const arcVertices2 = new Float32Array(nSegments * 3)\n arcPositionTmp1[ i ] = arcVertices1\n arcPositionTmp2[ i ] = arcVertices2\n\n v3add(arcPoint, p2, v21) // Our initial arc point\n\n const appendArcSection = function (a: number, j: number) {\n const si = j * 9\n const ai = j * 3\n v3toArray(p2, sectorVertices, si)\n v3toArray(arcPoint, sectorVertices, si + 3)\n v3toArray(arcPoint, arcVertices1, ai)\n\n calcArcPoint(arcPoint, p2, v21, cross2, a)\n\n v3toArray(arcPoint, sectorVertices, si + 6)\n v3toArray(arcPoint, arcVertices2, ai)\n }\n\n let j = 0\n for (let a = angleStep; a < angle; a += angleStep) {\n appendArcSection(a, j)\n j++\n }\n appendArcSection(angle, j)\n totalSegments += nSegments\n }\n\n // Flatten nested arrays of arc/segment points\n const arcSize = totalSegments * 3\n const sectorSize = totalSegments * 9\n const arcPosition1 = new Float32Array(arcSize)\n const arcPosition2 = new Float32Array(arcSize)\n const sectorPosition = new Float32Array(sectorSize)\n\n let sectorOffset = 0\n let arcOffset = 0\n for (let i = 0; i < n; i++) {\n const ap1 = arcPositionTmp1[ i ]\n const ap2 = arcPositionTmp2[ i ]\n copyArray(ap1, arcPosition1, 0, arcOffset, ap1.length)\n copyArray(ap2, arcPosition2, 0, arcOffset, ap2.length)\n arcOffset += ap1.length // === ap2.length\n\n const sp = sectorPositionTmp[ i ]\n copyArray(sp, sectorPosition, 0, sectorOffset, sp.length)\n sectorOffset += sp.length\n }\n\n return {\n labelPosition,\n labelText,\n vectorPosition1,\n vectorPosition2,\n arcPosition1,\n arcPosition2,\n sectorPosition\n }\n}\n\nRepresentationRegistry.add('angle', AngleRepresentation)\n\nexport default AngleRepresentation\n","/**\n * @file Cylinder Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3, CylinderBufferGeometry } from 'three'\n\nimport { defaults } from '../utils'\nimport { calculateCenterArray, serialBlockArray } from '../math/array-utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { CylinderBufferData } from './cylinder-buffer'\nimport { BufferDefaultParameters, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\nconst eye = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3(0, 1, 0)\n\nexport const CylinderGeometryBufferDefaultParameters = Object.assign({\n radialSegments: 1,\n openEnded: true\n}, BufferDefaultParameters)\nexport type CylinderGeometryBufferParameters = BufferParameters & {radialSegments: number, openEnded: boolean}\n\nfunction getData (data: CylinderBufferData, params: Partial = {}) {\n const geo = getGeo(params)\n\n const n = data.position1.length\n\n const geoLength = (geo.attributes as any).position.array.length / 3\n const count = n / 3\n const primitiveId = new Float32Array(count * 2 * geoLength)\n serialBlockArray(count, geoLength, 0, primitiveId)\n serialBlockArray(count, geoLength, count * geoLength, primitiveId)\n\n const position = new Float32Array(n * 2)\n const color = new Float32Array(n * 2)\n\n return {\n position, color, primitiveId, picking: data.picking\n }\n}\n\nfunction getGeo (params: Partial = {}) {\n const radialSegments = defaults(params.radialSegments, 10)\n const openEnded = defaults(params.openEnded, true)\n const matrix = new Matrix4().makeRotationX(Math.PI / 2)\n\n const geo = new CylinderBufferGeometry(\n 1, // radiusTop,\n 1, // radiusBottom,\n 1, // height,\n radialSegments, // radialSegments,\n 1, // heightSegments,\n openEnded // openEnded\n )\n geo.applyMatrix4(matrix)\n\n return geo\n}\n\n/**\n * Cylinder geometry buffer.\n *\n * @example\n * var cylinderGeometryBuffer = new CylinderGeometryBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass CylinderGeometryBuffer extends GeometryBuffer {\n updateNormals = true\n\n get defaultParameters() { return CylinderGeometryBufferDefaultParameters }\n parameters: CylinderGeometryBufferParameters\n\n __center: Float32Array\n _position: Float32Array\n _color: Float32Array\n _from: Float32Array\n _to: Float32Array\n _radius: Float32Array\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - from colors\n * @param {Float32Array} data.color2 - to colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n */\n constructor (data: CylinderBufferData, params: Partial = {}) {\n super(getData(data, params), params, getGeo(params))\n\n const n = data.position1.length\n const m = data.radius.length\n\n this.__center = new Float32Array(n)\n this._position = new Float32Array(n * 2)\n this._color = new Float32Array(n * 2)\n this._from = new Float32Array(n * 2)\n this._to = new Float32Array(n * 2)\n this._radius = new Float32Array(m * 2)\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n eye.fromArray(this._from as any, i3)\n target.fromArray(this._to as any, i3)\n matrix.lookAt(eye, target, up)\n\n const r = this._radius[ i ]\n scale.set(r, r, eye.distanceTo(target))\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n const meshData: Partial = {}\n\n if (data.position1 && data.position2) {\n calculateCenterArray(\n data.position1, data.position2, this.__center\n )\n calculateCenterArray(\n data.position1, this.__center, this._position\n )\n calculateCenterArray(\n this.__center, data.position2, this._position, data.position1.length\n )\n this._from.set(data.position1)\n this._from.set(this.__center, data.position1.length)\n this._to.set(this.__center)\n this._to.set(data.position2, this.__center.length)\n meshData.position = this._position\n }\n\n if (data.color && data.color2) {\n this._color.set(data.color)\n this._color.set(data.color2, data.color.length)\n meshData.color = this._color\n }\n\n if (data.radius) {\n this._radius.set(data.radius)\n this._radius.set(data.radius, data.radius.length)\n meshData.radius = this._radius\n }\n\n super.setAttributes(meshData, initNormals)\n }\n}\n\nexport default CylinderGeometryBuffer\n","/**\n * @file Mapped Aligned Box Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { BufferParameters, BufferData } from './buffer'\nimport MappedBuffer from './mapped-buffer'\n\n// +Y /\n// 0**********2\n// * | / **\n// * |/ * *\n// -----------3---- +X\n// * /| * *\n// * / | * *\n// 1/**|******4\n// / | * *\n// / | ** \n// +Z | 5 \nconst mapping = new Float32Array([\n -1.0, 1.0, -1.0,\n -1.0, -1.0, -1.0,\n 1.0, 1.0, -1.0,\n 1.0, 1.0, 1.0,\n 1.0, -1.0, -1.0,\n 1.0, -1.0, 1.0\n])\n\nconst mappingIndices = new Uint16Array([\n 0, 1, 2,\n 1, 4, 2,\n 2, 4, 3,\n 4, 5, 3\n])\n\n/**\n * Mapped Aligned box buffer. Draws boxes where one side is always screen-space aligned.\n * Used to render cylinder imposters.\n * @interface\n */\nclass MappedAlignedBoxBuffer extends MappedBuffer {\n constructor(data: BufferData, params: Partial = {}) {\n super('v3', data, params)\n }\n get mapping () { return mapping }\n get mappingIndices () { return mappingIndices }\n get mappingIndicesSize () { return 12 }\n get mappingSize () { return 6 }\n get mappingItemSize () { return 3 }\n}\n\nexport default MappedAlignedBoxBuffer\n","/**\n * @file Cylinder Impostor Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3 required for declaration only\nimport { Matrix4, Vector3 } from 'three'\n\nimport '../shader/CylinderImpostor.vert'\nimport '../shader/CylinderImpostor.frag'\n\nimport MappedAlignedBoxBuffer from './mappedalignedbox-buffer'\nimport { BufferDefaultParameters, BufferParameters, BufferParameterTypes, BufferTypes } from './buffer'\nimport { CylinderBufferData } from './cylinder-buffer'\n\nexport const CylinderImpostorBufferDefaultParameters = Object.assign({\n openEnded: false\n}, BufferDefaultParameters)\nexport type CylinderImpostorBufferParameters = BufferParameters & { openEnded: boolean }\n\nconst CylinderImpostorBufferParameterTypes = Object.assign({\n openEnded: { updateShader: true }\n}, BufferParameterTypes)\n\n/**\n * Cylinder impostor buffer.\n *\n * @example\n * var cylinderimpostorBuffer = new CylinderImpostorBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass CylinderImpostorBuffer extends MappedAlignedBoxBuffer {\n parameterTypes = CylinderImpostorBufferParameterTypes\n get defaultParameters() { return CylinderImpostorBufferDefaultParameters }\n parameters: CylinderImpostorBufferParameters\n\n isImpostor = true\n vertexShader = 'CylinderImpostor.vert'\n fragmentShader = 'CylinderImpostor.frag'\n\n /**\n * make cylinder impostor buffer\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - from colors\n * @param {Float32Array} data.color2 - to colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} data.picking - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: CylinderBufferData, params: Partial = {}) {\n super(data, params)\n\n this.addUniforms({\n 'modelViewMatrixInverse': { value: new Matrix4() },\n 'ortho': { value: 0.0 }\n })\n\n this.addAttributes({\n 'position1': { type: 'v3', value: null },\n 'position2': { type: 'v3', value: null },\n 'color2': { type: 'c', value: null },\n 'radius': { type: 'f', value: null }\n })\n\n this.setAttributes(data)\n this.makeMapping()\n }\n\n getDefines (type?: BufferTypes) {\n const defines = MappedAlignedBoxBuffer.prototype.getDefines.call(this, type)\n\n if (!this.parameters.openEnded) {\n defines.CAP = 1\n }\n\n return defines\n }\n}\n\nexport default CylinderImpostorBuffer\n","/**\n * @file Cylinder Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import required for declaration only\nimport { Vector3, Matrix4 } from 'three'\nimport { BufferRegistry, ExtensionFragDepth } from '../globals'\nimport CylinderGeometryBuffer, { CylinderGeometryBufferDefaultParameters, CylinderGeometryBufferParameters } from './cylindergeometry-buffer'\nimport CylinderImpostorBuffer, { CylinderImpostorBufferDefaultParameters, CylinderImpostorBufferParameters } from './cylinderimpostor-buffer'\nimport { BufferData } from './buffer'\n\nexport interface CylinderBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n color2: Float32Array\n radius: Float32Array\n}\n\nexport const CylinderBufferDefaultParameters = Object.assign({\n disableImpostor: false\n}, CylinderGeometryBufferDefaultParameters, CylinderImpostorBufferDefaultParameters)\nexport type CylinderBufferParameters = (CylinderGeometryBufferParameters & {disableImpostor: boolean}) | (CylinderImpostorBufferParameters & {disableImpostor: boolean})\n\nclass CylinderBufferImpl {\n constructor (data: CylinderBufferData, params: Partial = {}) {\n if (!data.color2 && data.color) data.color2 = data.color\n if (!ExtensionFragDepth || (params && params.disableImpostor)) {\n return new CylinderGeometryBuffer(data, params)\n } else {\n return new CylinderImpostorBuffer(data, params)\n }\n }\n}\n\n/**\n * Cylinder buffer. Depending on the value {@link ExtensionFragDepth} and\n * `params.disableImpostor` the constructor returns either a\n * {@link CylinderGeometryBuffer} or a {@link CylinderImpostorBuffer}\n * @implements {Buffer}\n *\n * @example\n * var cylinderBuffer = new CylinderBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\n//@ts-expect-error Incompatible constructor signatures\nconst CylinderBuffer: {\n new(data: CylinderBufferData, params: Partial): CylinderGeometryBuffer | CylinderImpostorBuffer;\n} = CylinderBufferImpl;\n\ntype CylinderBuffer = CylinderGeometryBuffer | CylinderImpostorBuffer;\n\nBufferRegistry.add('cylinder', CylinderBuffer)\n\nexport default CylinderBuffer\n","/**\n * @file Axes Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { Color, Vector3 } from 'three'\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { AxesPicker } from '../utils/picker'\nimport { uniformArray, uniformArray3 } from '../math/array-utils'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport CylinderBuffer, { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport StructureView from '../structure/structure-view';\nimport Viewer from '../viewer/viewer';\nimport { Structure } from '../ngl';\nimport { AtomDataFields } from '../structure/structure-data';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport PrincipalAxes from '../math/principal-axes';\n\nexport interface AxesRepresentationParameters extends StructureRepresentationParameters {\n showAxes: boolean\n showBox: boolean\n}\n\n/**\n * Axes representation. Show principal axes and/or a box aligned with them\n * that fits the structure or selection.\n *\n * __Name:__ _axes_\n *\n * @example\n * stage.loadFile( \"rcsb://3pqr\", {\n * assembly: \"BU1\"\n * } ).then( function( o ){\n * o.addRepresentation( \"cartoon\" );\n * o.addRepresentation( \"axes\", {\n * sele: \"RET\", showAxes: false, showBox: true, radius: 0.2\n * } );\n * o.addRepresentation( \"ball+stick\", { sele: \"RET\" } );\n * o.addRepresentation( \"axes\", {\n * sele: \":B and backbone\", showAxes: false, showBox: true, radius: 0.2\n * } );\n * stage.autoView();\n * var pa = o.structure.getPrincipalAxes();\n * stage.animationControls.rotate( pa.getRotationQuaternion(), 1500 );\n * } );\n */\nclass AxesRepresentation extends StructureRepresentation {\n \n protected showAxes: boolean\n protected showBox: boolean\n protected sphereBuffer: SphereBuffer\n protected cylinderBuffer: CylinderBuffer\n /**\n * @param {Structure} structure - the structure object\n * @param {Viewer} viewer - the viewer object\n * @param {StructureRepresentationParameters} params - parameters object\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'axes'\n\n this.parameters = Object.assign({\n\n radiusSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n sphereDetail: true,\n radialSegments: true,\n disableImpostor: true,\n showAxes: {\n type: 'boolean', rebuild: true\n },\n showBox: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n assembly: null\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.radiusSize = defaults(p.radiusSize, 0.5)\n p.colorValue = defaults(p.colorValue, 'lightgreen')\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.showAxes = defaults(p.showAxes, true)\n this.showBox = defaults(p.showBox, false)\n\n super.init(p)\n }\n\n getPrincipalAxes (): PrincipalAxes {\n let selection\n const assembly = this.getAssembly()\n\n if (assembly) {\n selection = assembly.partList[ 0 ].getSelection()\n }\n\n return this.structureView.getPrincipalAxes(selection)\n }\n\n getAxesData (sview: StructureView) {\n const pa = this.getPrincipalAxes()\n const c = new Color(this.colorValue)\n\n let vn = 0\n let en = 0\n\n if (this.showAxes) {\n vn += 6\n en += 3\n }\n\n if (this.showBox) {\n vn += 8\n en += 12\n }\n\n const vertexPosition = new Float32Array(3 * vn)\n const vertexColor = uniformArray3(vn, c.r, c.g, c.b)\n const vertexRadius = uniformArray(vn, this.radiusSize)\n\n const edgePosition1 = new Float32Array(3 * en)\n const edgePosition2 = new Float32Array(3 * en)\n const edgeColor = uniformArray3(en, c.r, c.g, c.b)\n const edgeRadius = uniformArray(en, this.radiusSize)\n\n let offset = 0\n\n if (this.showAxes) {\n const addAxis = function (v1: Vector3, v2: Vector3) {\n v1.toArray(vertexPosition as any, offset * 2)\n v2.toArray(vertexPosition as any, offset * 2 + 3)\n v1.toArray(edgePosition1 as any, offset)\n v2.toArray(edgePosition2 as any, offset)\n offset += 3\n }\n\n addAxis(pa.begA, pa.endA)\n addAxis(pa.begB, pa.endB)\n addAxis(pa.begC, pa.endC)\n }\n\n if (this.showBox) {\n const v = new Vector3()\n const { d1a, d2a, d3a, d1b, d2b, d3b } = pa.getProjectedScaleForAtoms(sview)\n\n // console.log(d1a, d2a, d3a, d1b, d2b, d3b)\n\n let offset2 = offset * 2\n const addCorner = function (d1: number, d2: number, d3: number) {\n v.copy(pa.center)\n .addScaledVector(pa.normVecA, d1)\n .addScaledVector(pa.normVecB, d2)\n .addScaledVector(pa.normVecC, d3)\n v.toArray(vertexPosition as any, offset2)\n offset2 += 3\n }\n addCorner(d1a, d2a, d3a)\n addCorner(d1a, d2a, d3b)\n addCorner(d1a, d2b, d3b)\n addCorner(d1a, d2b, d3a)\n addCorner(d1b, d2b, d3b)\n addCorner(d1b, d2b, d3a)\n addCorner(d1b, d2a, d3a)\n addCorner(d1b, d2a, d3b)\n\n let edgeOffset = offset\n const addEdge = function (a: number, b: number) {\n v.fromArray(vertexPosition as any, offset * 2 + a * 3)\n .toArray(edgePosition1 as any, edgeOffset)\n v.fromArray(vertexPosition as any, offset * 2 + b * 3)\n .toArray(edgePosition2 as any, edgeOffset)\n edgeOffset += 3\n }\n addEdge(0, 1)\n addEdge(0, 3)\n addEdge(0, 6)\n addEdge(1, 2)\n addEdge(1, 7)\n addEdge(2, 3)\n addEdge(2, 4)\n addEdge(3, 5)\n addEdge(4, 5)\n addEdge(4, 7)\n addEdge(5, 6)\n addEdge(6, 7)\n }\n\n const picker = new AxesPicker(pa)\n\n return {\n vertex: {\n position: vertexPosition,\n color: vertexColor,\n radius: vertexRadius,\n picking: picker\n },\n edge: {\n position1: edgePosition1,\n position2: edgePosition2,\n color: edgeColor,\n color2: edgeColor,\n radius: edgeRadius,\n picking: picker\n }\n }\n }\n\n create () {\n const axesData = this.getAxesData(this.structureView)\n\n this.sphereBuffer = new SphereBuffer(\n axesData.vertex as SphereBufferData,\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters\n )\n\n this.cylinderBuffer = new CylinderBuffer(\n axesData.edge as CylinderBufferData,\n this.getBufferParams({\n openEnded: true,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n this.dataList.push({\n sview: this.structureView,\n bufferList: [ this.sphereBuffer as SphereGeometryBuffer, this.cylinderBuffer as CylinderGeometryBuffer]\n })\n }\n\n createData (sview: StructureView): undefined {\n return\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n const axesData = this.getAxesData(data.sview as StructureView)\n const sphereData = {}\n const cylinderData = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {\n position: axesData.vertex.position\n })\n Object.assign(cylinderData, {\n position1: axesData.edge.position1,\n position2: axesData.edge.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {\n color: axesData.vertex.color as Float32Array\n })\n Object.assign(cylinderData, {\n color: axesData.edge.color as Float32Array,\n color2: axesData.edge.color as Float32Array\n })\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {\n radius: axesData.vertex.radius as Float32Array\n })\n Object.assign(cylinderData, {\n radius: axesData.edge.radius as Float32Array\n })\n }\n\n (this.sphereBuffer as SphereGeometryBuffer).setAttributes(sphereData);\n (this.cylinderBuffer as CylinderGeometryBuffer).setAttributes(cylinderData)\n }\n}\n\nRepresentationRegistry.add('axes', AxesRepresentation)\n\nexport default AxesRepresentation\n","/**\n * @file Ball And Stick Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { ExtensionFragDepth, RepresentationRegistry } from '../globals'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport CylinderBuffer, { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport WideLineBuffer from '../buffer/wideline-buffer'\nimport Viewer from '../viewer/viewer';\n// @ts-ignore: unused import Volume required for declaration only\nimport { Structure, Volume } from '../ngl';\nimport AtomProxy from '../proxy/atom-proxy';\nimport { AtomDataParams, BondDataParams, BondDataFields, AtomDataFields, BondData, AtomData } from '../structure/structure-data';\nimport StructureView from '../structure/structure-view';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\n// @ts-ignore: unused import Surface required for declaration only\nimport Surface from '../surface/surface';\n\nexport interface BallAndStickRepresentationParameters extends StructureRepresentationParameters {\n sphereDetail: number\n radialSegments: number\n openEnded: boolean\n disableImpostor: boolean\n aspectRatio: number\n lineOnly: boolean\n lineWidth: number\n cylinderOnly: boolean\n multipleBond: 'off' | 'symmetric' | 'offset'\n bondSpacing: number\n bondScale: number\n linewidth: number\n}\n\n/**\n * Ball And Stick representation parameter object. Extends {@link RepresentationParameters} and\n * {@link StructureRepresentationParameters}.\n *\n * @typedef {Object} BallAndStickRepresentationParameters - ball and stick representation parameters\n *\n * @property {Integer} sphereDetail - sphere quality (icosahedron subdivisions)\n * @property {Integer} radialSegments - cylinder quality (number of segments)\n * @property {Boolean} openEnded - capped or not\n * @property {Boolean} disableImpostor - disable use of raycasted impostors for rendering\n * @property {Float} aspectRatio - size difference between atom and bond radii\n * @property {Boolean} lineOnly - render only bonds, and only as lines\n * @property {Integer} linewidth - width of lines\n * @property {Boolean} cylinderOnly - render only bonds (no atoms)\n * @property {String} multipleBond - one off \"off\", \"symmetric\", \"offset\"\n * @property {Float} bondSpacing - spacing for multiple bond rendering\n * @property {Float} bondScale - scale/radius for multiple bond rendering\n */\n\n/**\n * Ball And Stick representation. Show atoms as spheres and bonds as cylinders.\n *\n * __Name:__ _ball+stick_\n *\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"ball+stick\" );\n * o.autoView();\n * } );\n */\nclass BallAndStickRepresentation extends StructureRepresentation {\n protected sphereDetail: number\n protected radialSegments: number\n protected openEnded: boolean\n protected disableImpostor: boolean\n protected aspectRatio: number\n protected lineOnly: boolean\n protected lineWidth: number\n protected cylinderOnly: boolean\n protected multipleBond: 'off' | 'symmetric' | 'offset'\n protected bondSpacing: number\n protected bondScale: number\n protected linewidth: number\n\n protected lineBuffer: WideLineBuffer\n /**\n * Create Ball And Stick representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {BallAndStickRepresentationParameters} params - ball and stick representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'ball+stick'\n\n this.parameters = Object.assign({\n\n sphereDetail: true,\n radialSegments: true,\n openEnded: true,\n disableImpostor: true,\n aspectRatio: {\n type: 'number', precision: 1, max: 10.0, min: 1.0\n },\n lineOnly: {\n type: 'boolean', rebuild: true\n },\n cylinderOnly: {\n type: 'boolean', rebuild: true\n },\n multipleBond: {\n type: 'select',\n rebuild: true,\n options: {\n 'off': 'off',\n 'symmetric': 'symmetric',\n 'offset': 'offset'\n }\n },\n bondScale: {\n type: 'number', precision: 2, max: 1.0, min: 0.01\n },\n bondSpacing: {\n type: 'number', precision: 2, max: 2.0, min: 0.5\n },\n linewidth: {\n type: 'integer', max: 50, min: 1, buffer: true\n }\n\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.radiusType = defaults(p.radiusType, 'size')\n p.radiusSize = defaults(p.radiusSize, 0.15)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.aspectRatio = defaults(p.aspectRatio, 2.0)\n this.lineOnly = defaults(p.lineOnly, false)\n this.cylinderOnly = defaults(p.cylinderOnly, false)\n this.multipleBond = defaults(p.multipleBond, 'off')\n this.bondSpacing = defaults(p.bondSpacing, 1.0)\n this.bondScale = defaults(p.bondScale, 0.4)\n this.linewidth = defaults(p.linewidth, 2)\n\n super.init(p)\n }\n\n getAtomRadius (atom: AtomProxy) {\n return this.aspectRatio * super.getAtomRadius(atom)\n }\n\n getAtomParams (what?: AtomDataFields, params?: Partial) {\n var p = super.getAtomParams(what, params)\n p.radiusParams.scale *= this.aspectRatio\n\n return p\n }\n\n getAtomData (sview: StructureView, what?: AtomDataFields, params?: Partial): AtomData {\n return sview.getAtomData(this.getAtomParams(what, params))\n }\n\n getBondParams (what?: BondDataFields, params?: Partial) {\n params = Object.assign({\n multipleBond: this.multipleBond,\n bondSpacing: this.bondSpacing,\n bondScale: this.bondScale\n }, params)\n\n return super.getBondParams(what, params)\n }\n\n getBondData (sview: StructureView, what?: BondDataFields, params?: Partial): BondData {\n return sview.getBondData(this.getBondParams(what, params))\n }\n\n createData (sview: StructureView) {\n const bufferList: any[] = []\n\n if (this.lineOnly) {\n this.lineBuffer = new WideLineBuffer(\n this.getBondData(sview, { position: true, color: true, picking: true }),\n this.getBufferParams({ linewidth: this.linewidth })\n )\n\n bufferList.push(this.lineBuffer)\n } else {\n const cylinderBuffer = new CylinderBuffer(\n (this.getBondData(sview) as CylinderBufferData),\n this.getBufferParams({\n openEnded: this.openEnded,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n bufferList.push(cylinderBuffer as CylinderGeometryBuffer)\n\n if (!this.cylinderOnly) {\n const sphereBuffer = new SphereBuffer(\n (this.getAtomData(sview) as SphereBufferData),\n (this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters)\n )\n\n bufferList.push(sphereBuffer as SphereGeometryBuffer)\n }\n }\n\n return {\n bufferList: bufferList\n }\n }\n\n updateData (what: BondDataFields | AtomDataFields, data: StructureRepresentationData) {\n if (this.multipleBond !== 'off' && what && what.radius) {\n what.position = true\n }\n\n const bondData = this.getBondData(data.sview as StructureView, what)\n\n if (this.lineOnly) {\n const lineData:Partial = {}\n\n if (!what || what.position) {\n Object.assign(lineData, {\n position1: bondData.position1,\n position2: bondData.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(lineData, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n data.bufferList[ 0 ].setAttributes(lineData)\n } else {\n var cylinderData: Partial = {}\n\n if (!what || what.position) {\n Object.assign(cylinderData, {\n position1: bondData.position1,\n position2: bondData.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(cylinderData, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n if (!what || what.radius) {\n Object.assign(cylinderData, {\n radius: bondData.radius\n })\n }\n\n data.bufferList[ 0 ].setAttributes(cylinderData)\n\n if (!this.cylinderOnly) {\n var atomData = this.getAtomData(data.sview as StructureView, what)\n\n var sphereData: Partial = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {\n position: atomData.position\n })\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {\n color: atomData.color\n })\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {\n radius: atomData.radius\n })\n }\n\n data.bufferList[ 1 ].setAttributes(sphereData)\n }\n }\n }\n\n setParameters (params: Partial = {}) {\n let rebuild = false\n const what: AtomDataFields = {}\n\n if (params.aspectRatio || params.bondSpacing || params.bondScale) {\n Object.assign(what, {radius: true})\n if (!ExtensionFragDepth || this.disableImpostor) {\n rebuild = true\n }\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('ball+stick', BallAndStickRepresentation)\n\nexport default BallAndStickRepresentation\n","/**\n * @file Backbone Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport BallAndStickRepresentation, { BallAndStickRepresentationParameters } from './ballandstick-representation'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport StructureView from '../structure/structure-view';\nimport { AtomDataFields, AtomDataParams, BondDataFields, BondDataParams, BondData, AtomData } from '../structure/structure-data';\n\n/**\n * Backbone representation. Show cylinders (or lines) connecting .CA (protein)\n * or .C4'/.C3' (RNA/DNA) of polymers.\n *\n * __Name:__ _backbone_\n *\n * @example\n * stage.loadFile( \"rcsb://1sfi\" ).then( function( o ){\n * o.addRepresentation( \"backbone\" );\n * o.autoView();\n * } );\n */\nclass BackboneRepresentation extends BallAndStickRepresentation {\n /**\n * @param {Structure} structure - the structure object\n * @param {Viewer} viewer - the viewer object\n * @param {BallAndStickRepresentationParameters} params - parameters object\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'backbone'\n\n this.parameters = Object.assign({\n\n }, this.parameters, {\n\n multipleBond: null,\n bondSpacing: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.aspectRatio = defaults(p.aspectRatio, 1.0)\n p.radiusSize = defaults(p.radiusSize, 0.25)\n\n super.init(p)\n }\n\n getAtomRadius (atom: AtomProxy) {\n return atom.isTrace() ? super.getAtomRadius(atom) : 0\n }\n\n getAtomData (sview: StructureView, what?: AtomDataFields, params?: Partial): AtomData {\n return sview.getBackboneAtomData(this.getAtomParams(what, params))\n }\n\n getBondData (sview: StructureView, what?: BondDataFields, params?: Partial): BondData {\n return sview.getBackboneBondData(this.getBondParams(what, params))\n }\n}\n\nRepresentationRegistry.add('backbone', BackboneRepresentation)\n\nexport default BackboneRepresentation\n","/**\n * @file Base Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport BallAndStickRepresentation, { BallAndStickRepresentationParameters } from './ballandstick-representation'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { AtomDataFields, AtomDataParams, BondDataFields, BondDataParams, BondData, AtomData } from '../structure/structure-data';\n\n/**\n * Base representation. Show cylinders for RNA/DNA ladders.\n *\n * __Name:__ _base_\n *\n * @example\n * stage.loadFile( \"rcsb://1d66\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\", { sele: \"nucleic\" } );\n * o.addRepresentation( \"base\", { color: \"resname\" } );\n * o.autoView( \"nucleic\" );\n * } );\n */\nclass BaseRepresentation extends BallAndStickRepresentation {\n /**\n * @param {Structure} structure - the structure object\n * @param {Viewer} viewer - the viewer object\n * @param {BallAndStickRepresentationParameters} params - parameters object\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'base'\n\n this.parameters = Object.assign({\n\n }, this.parameters, {\n\n multipleBond: null,\n bondSpacing: null\n\n })\n }\n\n init (params: Partial) {\n let p = params || {}\n p.aspectRatio = defaults(p.aspectRatio, 1.0)\n p.radiusSize = defaults(p.radiusSize, 0.3)\n\n super.init(p)\n }\n\n getAtomData (sview: StructureView, what?: AtomDataFields, params?: AtomDataParams): AtomData {\n return sview.getRungAtomData(this.getAtomParams(what, params))\n }\n\n getBondData (sview: StructureView, what?: BondDataFields, params?: BondDataParams): BondData {\n let p = this.getBondParams(what, params)\n Object.assign(p.colorParams, {rung: true})\n\n return sview.getRungBondData(p)\n }\n}\n\nRepresentationRegistry.add('base', BaseRepresentation)\n\nexport default BaseRepresentation\n","/**\n * @file Spline\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport { AtomPicker } from '../utils/picker'\nimport RadiusFactory, { RadiusParams } from '../utils/radius-factory'\nimport { copyArray } from '../math/array-utils'\nimport { spline } from '../math/math-utils'\nimport Polymer from '../proxy/polymer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport { ColormakerParameters } from '../color/colormaker';\nimport { NumberArray } from '../types';\n\nexport class Interpolator {\n \n m: number\n tension: number\n dt: number\n delta: number\n vec1: Vector3\n vec2: Vector3\n vDir: Vector3 \n vTan: Vector3\n vNorm: Vector3\n vBin: Vector3\n m2: number\n\n constructor (m: number, tension: number) {\n this.m = m\n this.tension = tension\n this.dt = 1.0 / this.m\n this.delta = 0.0001\n\n this.vec1 = new Vector3()\n this.vec2 = new Vector3()\n\n this.vDir = new Vector3()\n this.vTan = new Vector3()\n this.vNorm = new Vector3()\n this.vBin = new Vector3()\n \n this.m2 = Math.ceil(this.m / 2)\n }\n\n private interpolateToArr (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, t: number, arr: Float32Array, offset: number) {\n arr[ offset + 0 ] = spline(v0.x, v1.x, v2.x, v3.x, t, this.tension)\n arr[ offset + 1 ] = spline(v0.y, v1.y, v2.y, v3.y, t, this.tension)\n arr[ offset + 2 ] = spline(v0.z, v1.z, v2.z, v3.z, t, this.tension)\n }\n\n private interpolateToVec (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, t: number, vec: Vector3) {\n vec.x = spline(v0.x, v1.x, v2.x, v3.x, t, this.tension)\n vec.y = spline(v0.y, v1.y, v2.y, v3.y, t, this.tension)\n vec.z = spline(v0.z, v1.z, v2.z, v3.z, t, this.tension)\n }\n\n private interpolatePosition (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, pos: Float32Array, offset: number) {\n for (var j = 0; j < this.m; ++j) {\n var l = offset + j * 3\n var d = this.dt * j\n this.interpolateToArr(v0, v1, v2, v3, d, pos, l)\n }\n }\n\n private interpolateTangent (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, tan: Float32Array, offset: number) {\n for (var j = 0; j < this.m; ++j) {\n var d = this.dt * j\n var d1 = d - this.delta\n var d2 = d + this.delta\n var l = offset + j * 3\n // capping as a precaution\n if (d1 < 0) d1 = 0\n if (d2 > 1) d2 = 1\n //\n this.interpolateToVec(v0, v1, v2, v3, d1, this.vec1)\n this.interpolateToVec(v0, v1, v2, v3, d2, this.vec2)\n //\n this.vec2.sub(this.vec1).normalize()\n this.vec2.toArray(tan as any, l)\n }\n }\n\n private vectorSubdivide (interpolationFn: (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, array: Float32Array, offset: number) => void,\n iterator: AtomIterator, array: Float32Array, offset: number, isCyclic: boolean) {\n let v0: Vector3\n let v1 = iterator.next()\n let v2 = iterator.next()\n let v3 = iterator.next()\n //\n const n = iterator.size\n const n1 = n - 1\n let k = offset || 0\n for (let i = 0; i < n1; ++i) {\n v0 = v1\n v1 = v2\n v2 = v3\n v3 = iterator.next()\n interpolationFn.apply(this, [v0, v1, v2, v3, array, k])\n k += 3 * this.m\n }\n if (isCyclic) {\n v0 = iterator.get(n - 2)\n v1 = iterator.get(n - 1)\n v2 = iterator.get(0)\n v3 = iterator.get(1)\n interpolationFn.apply(this, [v0, v1, v2, v3, array, k])\n k += 3 * this.m\n }\n }\n\n //\n\n public getPosition (iterator: AtomIterator, array: Float32Array, offset: number, isCyclic: boolean) {\n iterator.reset()\n this.vectorSubdivide(this.interpolatePosition, iterator, array, offset, isCyclic)\n var n1 = iterator.size - 1\n var k = n1 * this.m * 3\n if (isCyclic) k += this.m * 3\n var v = iterator.get(isCyclic ? 0 : n1)\n array[ k ] = v.x\n array[ k + 1 ] = v.y\n array[ k + 2 ] = v.z\n }\n\n public getTangent (iterator: AtomIterator, array: Float32Array, offset: number, isCyclic: boolean) {\n iterator.reset()\n this.vectorSubdivide(this.interpolateTangent, iterator, array, offset, isCyclic)\n const n1 = iterator.size - 1\n let k = n1 * this.m * 3\n if (isCyclic) k += this.m * 3\n copyArray(array, array, k - 3, k, 3)\n }\n\n private interpolateNormalDir (u0: Vector3, u1: Vector3, u2: Vector3, u3: Vector3,\n v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3,\n tan: Float32Array, norm: Float32Array, bin: Float32Array,\n offset: number, shift: boolean) {\n for (let j = 0; j < this.m; ++j) {\n let l = offset + j * 3\n if (shift) l += this.m2 * 3\n const d = this.dt * j\n this.interpolateToVec(u0, u1, u2, u3, d, this.vec1)\n this.interpolateToVec(v0, v1, v2, v3, d, this.vec2)\n this.vDir.subVectors(this.vec2, this.vec1).normalize()\n this.vTan.fromArray(tan as any, l)\n this.vBin.crossVectors(this.vDir, this.vTan).normalize()\n this.vBin.toArray(bin as any, l)\n this.vNorm.crossVectors(this.vTan, this.vBin).normalize()\n this.vNorm.toArray(norm as any, l)\n }\n }\n\n private interpolateNormal (vDir: Vector3, tan: Float32Array, norm: Float32Array, bin: Float32Array, offset: number) {\n for (var j = 0; j < this.m; ++j) {\n var l = offset + j * 3\n vDir.copy(this.vNorm)\n this.vTan.fromArray(tan as any, l)\n this.vBin.crossVectors(vDir, this.vTan).normalize()\n this.vBin.toArray(bin as any, l)\n this.vNorm.crossVectors(this.vTan, this.vBin).normalize()\n this.vNorm.toArray(norm as any, l)\n }\n }\n\n public getNormal (size: number, tan: Float32Array, norm: Float32Array, bin: Float32Array, offset: number, isCyclic: boolean) {\n this.vNorm.set(0, 0, 1)\n const n = size\n const n1 = n - 1\n let k = offset || 0\n for (var i = 0; i < n1; ++i) {\n this.interpolateNormal(this.vDir, tan, norm, bin, k)\n k += 3 * this.m\n }\n if (isCyclic) {\n this.interpolateNormal(this.vDir, tan, norm, bin, k)\n k += 3 * this.m\n }\n this.vBin.toArray(bin as any, k)\n this.vNorm.toArray(norm as any, k)\n }\n\n public getNormalDir (iterDir1: AtomIterator, iterDir2: AtomIterator, tan: Float32Array, norm: Float32Array, bin: Float32Array, offset: number, isCyclic: boolean, shift: boolean) {\n iterDir1.reset()\n iterDir2.reset()\n //\n const vSub1 = new Vector3()\n const vSub2 = new Vector3()\n const vSub3 = new Vector3()\n const vSub4 = new Vector3()\n //\n const d1v1 = new Vector3()\n const d1v2 = new Vector3().copy(iterDir1.next())\n const d1v3 = new Vector3().copy(iterDir1.next())\n const d1v4 = new Vector3().copy(iterDir1.next())\n const d2v1 = new Vector3()\n const d2v2 = new Vector3().copy(iterDir2.next())\n const d2v3 = new Vector3().copy(iterDir2.next())\n const d2v4 = new Vector3().copy(iterDir2.next())\n //\n this.vNorm.set(0, 0, 1)\n let n = iterDir1.size\n let n1 = n - 1\n let k = offset || 0\n for (var i = 0; i < n1; ++i) {\n d1v1.copy(d1v2)\n d1v2.copy(d1v3)\n d1v3.copy(d1v4)\n d1v4.copy(iterDir1.next())\n d2v1.copy(d2v2)\n d2v2.copy(d2v3)\n d2v3.copy(d2v4)\n d2v4.copy(iterDir2.next())\n //\n if (i === 0) {\n vSub1.subVectors(d2v1, d1v1)\n vSub2.subVectors(d2v2, d1v2)\n if (vSub1.dot(vSub2) < 0) {\n vSub2.multiplyScalar(-1)\n d2v2.addVectors(d1v2, vSub2)\n }\n vSub3.subVectors(d2v3, d1v3)\n if (vSub2.dot(vSub3) < 0) {\n vSub3.multiplyScalar(-1)\n d2v3.addVectors(d1v3, vSub3)\n }\n } else {\n vSub3.copy(vSub4)\n }\n vSub4.subVectors(d2v4, d1v4)\n if (vSub3.dot(vSub4) < 0) {\n vSub4.multiplyScalar(-1)\n d2v4.addVectors(d1v4, vSub4)\n }\n this.interpolateNormalDir(\n d1v1, d1v2, d1v3, d1v4,\n d2v1, d2v2, d2v3, d2v4,\n tan, norm, bin, k, shift\n )\n k += 3 * this.m\n }\n if (isCyclic) {\n d1v1.copy(iterDir1.get(n - 2))\n d1v2.copy(iterDir1.get(n - 1))\n d1v3.copy(iterDir1.get(0))\n d1v4.copy(iterDir1.get(1))\n d2v1.copy(iterDir2.get(n - 2))\n d2v2.copy(iterDir2.get(n - 1))\n d2v3.copy(iterDir2.get(0))\n d2v4.copy(iterDir2.get(1))\n //\n vSub3.copy(vSub4)\n vSub4.subVectors(d2v4, d1v4)\n if (vSub3.dot(vSub4) < 0) {\n vSub4.multiplyScalar(-1)\n d2v4.addVectors(d1v4, vSub4)\n }\n this.interpolateNormalDir(\n d1v1, d1v2, d1v3, d1v4,\n d2v1, d2v2, d2v3, d2v4,\n tan, norm, bin, k, shift\n )\n k += 3 * this.m\n }\n if (shift) {\n // FIXME shift requires data from one this.more preceeding residue\n this.vBin.fromArray(bin as any, this.m2 * 3)\n this.vNorm.fromArray(norm as any, this.m2 * 3)\n for (var j = 0; j < this.m2; ++j) {\n this.vBin.toArray(bin as any, j * 3)\n this.vNorm.toArray(norm as any, j * 3)\n }\n } else {\n this.vBin.toArray(bin as any, k)\n this.vNorm.toArray(norm as any, k)\n }\n }\n\n //\n\n private interpolateColor (item1: AtomProxy, item2: AtomProxy, colFn: (...arg: any[]) => void, col: any, offset: number) {\n var j, l\n for (j = 0; j < this.m2; ++j) {\n l = offset + j * 3\n colFn.apply(this, [item1, col, l]) // itemColorToArray\n }\n for (j = this.m2; j < this.m; ++j) {\n l = offset + j * 3\n colFn.apply(this, [item2, col, l]) // itemColorToArray\n }\n }\n\n public getColor (iterator: AtomIterator, colFn: (...arg: any[]) => void, col: any, offset: number, isCyclic: boolean) {\n iterator.reset()\n iterator.next() // first element not needed\n let i0: AtomProxy\n let i1 = iterator.next()\n //\n var n = iterator.size\n var n1 = n - 1\n var k = offset || 0\n for (var i = 0; i < n1; ++i) {\n i0 = i1\n i1 = iterator.next()\n this.interpolateColor(i0, i1, colFn, col, k)\n k += 3 * this.m\n }\n if (isCyclic) {\n i0 = iterator.get(n - 1)\n i1 = iterator.get(0)\n this.interpolateColor(i0, i1, colFn, col, k)\n k += 3 * this.m\n }\n //\n col[ k ] = col[ k - 3 ]\n col[ k + 1 ] = col[ k - 2 ]\n col[ k + 2 ] = col[ k - 1 ]\n }\n\n //\n\n private interpolatePicking (item1: AtomProxy, item2: AtomProxy, pickFn: (item: AtomProxy) => number, pick: Float32Array, offset: number) {\n var j\n for (j = 0; j < this.m2; ++j) {\n pick[ offset + j ] = pickFn.apply(this, [item1])\n }\n for (j = this.m2; j < this.m; ++j) {\n pick[ offset + j ] = pickFn.apply(this, [item2])\n }\n }\n\n public getPicking (iterator: AtomIterator, pickFn: (item: AtomProxy) => number, pick: Float32Array, offset: number, isCyclic: boolean) {\n iterator.reset()\n iterator.next() // first element not needed\n let i0: AtomProxy\n let i1 = iterator.next()\n //\n const n = iterator.size\n const n1 = n - 1\n let k = offset || 0\n for (var i = 0; i < n1; ++i) {\n i0 = i1\n i1 = iterator.next()\n this.interpolatePicking(i0, i1, pickFn, pick, k)\n k += this.m\n }\n if (isCyclic) {\n i0 = iterator.get(n - 1)\n i1 = iterator.get(0)\n this.interpolatePicking(i0, i1, pickFn, pick, k)\n k += this.m\n }\n //\n pick[ k ] = pick[ k - 1 ]\n }\n\n //\n\n private interpolateSize (item1: AtomProxy, item2: AtomProxy, sizeFn: (item: AtomProxy) => number, size: Float32Array, offset: number) {\n const s1: number = sizeFn.apply(this, [item1])\n const s2: number = sizeFn.apply(this, [item2])\n for (let j = 0; j < this.m; ++j) {\n // linear interpolation\n let t = j / this.m\n size[ offset + j ] = (1 - t) * s1 + t * s2\n }\n }\n\n public getSize (iterator: AtomIterator, sizeFn: (item: AtomProxy) => number, size: Float32Array, offset: number, isCyclic: boolean) {\n iterator.reset()\n iterator.next() // first element not needed\n let i0: AtomProxy\n let i1: AtomProxy = iterator.next()\n //\n const n = iterator.size\n const n1 = n - 1\n let k = offset || 0\n for (var i = 0; i < n1; ++i) {\n i0 = i1\n i1 = iterator.next()\n this.interpolateSize(i0, i1, sizeFn, size, k)\n k += this.m\n }\n if (isCyclic) {\n i0 = iterator.get(n - 1)\n i1 = iterator.get(0)\n this.interpolateSize(i0, i1, sizeFn, size, k)\n k += this.m\n }\n //\n size[ k ] = size[ k - 1 ]\n }\n}\n\nexport interface SplineParameters {\n directional?: boolean\n positionIterator?: boolean\n subdiv?: number\n smoothSheet?: boolean\n tension?: number\n}\nexport interface AtomIterator {\n size: number,\n next: () => AtomProxy | Vector3,\n get: (idx: number) => AtomProxy | Vector3,\n reset: () => void\n}\nclass Spline {\n\n polymer: Polymer\n size: number\n directional: boolean\n positionIterator: any\n subdiv: number\n smoothSheet: boolean\n tension: number\n interpolator: Interpolator\n\n constructor (polymer: Polymer, params?: SplineParameters) {\n this.polymer = polymer\n this.size = polymer.residueCount\n\n var p = params || {}\n this.directional = p.directional || false\n this.positionIterator = p.positionIterator || false\n this.subdiv = p.subdiv || 1\n this.smoothSheet = p.smoothSheet || false\n\n if (!p.tension) {\n this.tension = this.polymer.isNucleic() ? 0.5 : 0.9\n } else {\n this.tension = p.tension\n }\n\n this.interpolator = new Interpolator(this.subdiv, this.tension)\n }\n\n getAtomIterator (type: string, smooth?: boolean): AtomIterator {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n\n let i = 0\n let j = -1\n\n const cache = [\n structure.getAtomProxy(),\n structure.getAtomProxy(),\n structure.getAtomProxy(),\n structure.getAtomProxy()\n ]\n\n const cache2 = [\n new Vector3(),\n new Vector3(),\n new Vector3(),\n new Vector3()\n ]\n\n function next () {\n var atomProxy = get(j)\n j += 1\n return atomProxy\n }\n\n var apPrev = structure.getAtomProxy()\n var apNext = structure.getAtomProxy()\n\n function get (idx: number) {\n var atomProxy = cache[ i % 4 ]\n atomProxy.index = polymer.getAtomIndexByType(idx, type) as number\n if (smooth && idx > 0 && idx < n && atomProxy.sstruc === 'e') {\n var vec = cache2[ i % 4 ]\n apPrev.index = polymer.getAtomIndexByType(idx + 1, type) as number\n apNext.index = polymer.getAtomIndexByType(idx - 1, type) as number\n vec.addVectors(apPrev as any, apNext as any)\n .add(atomProxy as any).add(atomProxy as any)\n .multiplyScalar(0.25)\n i += 1\n return vec\n }\n i += 1\n return atomProxy\n }\n\n function reset () {\n i = 0\n j = -1\n }\n\n return {\n size: n,\n next: next,\n get: get,\n reset: reset\n }\n }\n\n getSubdividedColor (params: {scheme: string, [k: string]: any } & ColormakerParameters) {\n var m = this.subdiv\n var polymer = this.polymer\n var n = polymer.residueCount\n var n1 = n - 1\n var nCol = n1 * m * 3 + 3\n if (polymer.isCyclic) nCol += m * 3\n\n var col = new Float32Array(nCol)\n var iterator = this.getAtomIterator('trace')\n\n var p = params || {}\n p.structure = polymer.structure\n\n var colormaker = ColormakerRegistry.getScheme(p)\n\n function colFn (item: AtomProxy, array: NumberArray, offset: number) {\n colormaker.atomColorToArray(item, array, offset)\n }\n\n this.interpolator.getColor(\n iterator, colFn, col, 0, polymer.isCyclic\n )\n\n return {\n 'color': col\n }\n }\n \n getSubdividedPicking () {\n var m = this.subdiv\n var polymer = this.polymer\n var n = polymer.residueCount\n var n1 = n - 1\n var nCol = n1 * m + 1\n if (polymer.isCyclic) nCol += m\n\n var structure = polymer.structure\n var iterator = this.getAtomIterator('trace')\n var pick = new Float32Array(nCol)\n\n function pickFn (item: AtomProxy) {\n return item.index\n }\n\n this.interpolator.getPicking(\n iterator, pickFn, pick, 0, polymer.isCyclic\n )\n\n return {\n 'picking': new AtomPicker(pick, structure)\n }\n }\n\n getSubdividedPosition () {\n var pos = this.getPosition()\n\n return {\n 'position': pos\n }\n }\n \n getSubdividedOrientation () {\n const tan = this.getTangent()\n const normals = this.getNormals(tan)\n\n return {\n 'tangent': tan,\n 'normal': normals.normal,\n 'binormal': normals.binormal\n }\n }\n\n getSubdividedSize (params: RadiusParams) {\n var m = this.subdiv\n var polymer = this.polymer\n var n = polymer.residueCount\n var n1 = n - 1\n var nSize = n1 * m + 1\n if (polymer.isCyclic) nSize += m\n\n var size = new Float32Array(nSize)\n var iterator = this.getAtomIterator('trace')\n\n var radiusFactory = new RadiusFactory(params)\n\n function sizeFn (item: AtomProxy) {\n return radiusFactory.atomRadius(item)\n }\n\n this.interpolator.getSize(\n iterator, sizeFn, size, 0, polymer.isCyclic\n )\n\n return {\n 'size': size\n }\n }\n\n getPosition () {\n const m = this.subdiv\n const polymer = this.polymer\n const n = polymer.residueCount\n const n1 = n - 1\n let nPos = n1 * m * 3 + 3\n if (polymer.isCyclic) nPos += m * 3\n\n const pos = new Float32Array(nPos)\n const iterator = this.positionIterator || this.getAtomIterator('trace', this.smoothSheet)\n\n this.interpolator.getPosition(iterator, pos, 0, polymer.isCyclic)\n\n return pos\n }\n\n getTangent () {\n const m = this.subdiv\n const polymer = this.polymer\n const n = this.size\n const n1 = n - 1\n let nTan = n1 * m * 3 + 3\n if (polymer.isCyclic) nTan += m * 3\n\n const tan = new Float32Array(nTan)\n const iterator = this.positionIterator || this.getAtomIterator('trace', this.smoothSheet)\n\n this.interpolator.getTangent(iterator, tan, 0, polymer.isCyclic)\n\n return tan\n }\n\n getNormals (tan: Float32Array) {\n const m = this.subdiv\n const polymer = this.polymer\n const isProtein = polymer.isProtein()\n const n = this.size\n const n1 = n - 1\n let nNorm = n1 * m * 3 + 3\n if (polymer.isCyclic) nNorm += m * 3\n\n const norm = new Float32Array(nNorm)\n const bin = new Float32Array(nNorm)\n\n if (this.directional && !this.polymer.isCg()) {\n const iterDir1 = this.getAtomIterator('direction1')\n const iterDir2 = this.getAtomIterator('direction2')\n this.interpolator.getNormalDir(\n iterDir1, iterDir2, tan, norm, bin, 0, polymer.isCyclic, isProtein\n )\n } else {\n this.interpolator.getNormal(\n n, tan, norm, bin, 0, polymer.isCyclic\n )\n }\n\n return {\n 'normal': norm,\n 'binormal': bin\n }\n }\n\n}\n\nexport default Spline\n","/**\n * @file Tube Mesh Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Matrix4 required for declaration only\nimport { Vector3, Matrix4 } from 'three'\n\nimport { defaults, getUintArray } from '../utils'\nimport { serialArray } from '../math/array-utils'\nimport MeshBuffer from './mesh-buffer'\nimport { BufferDefaultParameters, BufferData, BufferParameters } from './buffer'\nimport {Log} from \"../globals\";\n\nconst vTangent = new Vector3()\nconst vMeshNormal = new Vector3()\n\nexport interface TubeMeshBufferData extends BufferData {\n binormal: Float32Array\n tangent: Float32Array\n size: Float32Array\n}\n\nexport const TubeMeshBufferDefaultParameters = Object.assign({\n radialSegments: 4,\n capped: false,\n aspectRatio: 1.0\n}, BufferDefaultParameters)\nexport type TubeMeshBufferParameters = BufferParameters & {\n radialSegments: number,\n capped: boolean,\n aspectRatio: number\n}\n\nfunction getData (data: TubeMeshBufferData, params: Partial = {}) {\n const radialSegments = defaults(params.radialSegments, 4)\n const capped = defaults(params.capped, false)\n\n const capVertices = capped ? radialSegments : 0\n const capTriangles = capped ? radialSegments - 2 : 0\n\n const n = data.position!.length / 3\n const n1 = n - 1\n const x = n * radialSegments * 3 + 2 * capVertices * 3\n const xi = n1 * 2 * radialSegments * 3 + 2 * capTriangles * 3\n\n return {\n position: new Float32Array(x),\n color: new Float32Array(x),\n index: getUintArray(xi, x / 3),\n normal: new Float32Array(x),\n picking: data.picking\n }\n}\n\n/**\n * Tube mesh buffer. Draws a tube.\n */\nclass TubeMeshBuffer extends MeshBuffer {\n get defaultParameters() { return TubeMeshBufferDefaultParameters }\n parameters: TubeMeshBufferParameters\n\n capVertices: number\n capTriangles: number\n size2: number\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.normal - normals\n * @param {Float32Array} data.binormal - binormals\n * @param {Float32Array} data.tangent - tangents\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.size - sizes\n * @param {Picker} data.picking - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: TubeMeshBufferData, params: Partial = {}) {\n super(getData(data, params), params)\n\n this.capVertices = this.parameters.capped ? this.parameters.radialSegments : 0\n this.capTriangles = this.parameters.capped ? this.parameters.radialSegments - 2 : 0\n\n this.size2 = data.position!.length / 3\n data.primitiveId = serialArray(this.size2)\n\n this.setAttributes(data)\n this.makeIndex()\n }\n\n setAttributes (data: Partial = {}) {\n const aspectRatio = this.parameters.aspectRatio\n\n const n = this.size2\n const n1 = n - 1\n const radialSegments = this.parameters.radialSegments\n\n const attributes = this.geometry.attributes as any\n\n let position, normal, binormal, tangent, color, size, primitiveId\n let meshPosition, meshColor, meshNormal, meshPrimitiveId\n\n if (data.position) {\n position = data.position\n normal = data.normal\n binormal = data.binormal\n tangent = data.tangent\n size = data.size\n\n meshPosition = attributes.position.array\n meshNormal = attributes.normal.array\n\n attributes.position.needsUpdate = true\n attributes.normal.needsUpdate = true\n }\n\n if (data.color) {\n color = data.color\n meshColor = attributes.color.array\n attributes.color.needsUpdate = true\n }\n\n if (data.primitiveId) {\n primitiveId = data.primitiveId\n meshPrimitiveId = attributes.primitiveId.array\n attributes.primitiveId.needsUpdate = true\n }\n\n let k, l\n let radius = 0\n\n let normX = 0\n let normY = 0\n let normZ = 0\n let biX = 0\n let biY = 0\n let biZ = 0\n let posX = 0\n let posY = 0\n let posZ = 0\n\n const cxArr = []\n const cyArr = []\n const cx1Arr = []\n const cy1Arr = []\n const cx2Arr = []\n const cy2Arr = []\n\n if (position) {\n for (let j = 0; j < radialSegments; ++j) {\n const v = (j / radialSegments) * 2 * Math.PI\n\n cxArr[ j ] = aspectRatio * Math.cos(v)\n cyArr[ j ] = Math.sin(v)\n\n cx1Arr[ j ] = aspectRatio * Math.cos(v - 0.01)\n cy1Arr[ j ] = Math.sin(v - 0.01)\n cx2Arr[ j ] = aspectRatio * Math.cos(v + 0.01)\n cy2Arr[ j ] = Math.sin(v + 0.01)\n }\n }\n\n for (let i = 0; i < n; ++i) {\n k = i * 3\n l = k * radialSegments\n\n if (position && tangent && normal && binormal && size) {\n vTangent.set(\n tangent[ k ], tangent[ k + 1 ], tangent[ k + 2 ]\n )\n\n normX = normal[ k ]\n normY = normal[ k + 1 ]\n normZ = normal[ k + 2 ]\n\n biX = binormal[ k ]\n biY = binormal[ k + 1 ]\n biZ = binormal[ k + 2 ]\n\n posX = position[ k ]\n posY = position[ k + 1 ]\n posZ = position[ k + 2 ]\n\n radius = size[ i ]\n }\n\n for (let j = 0; j < radialSegments; ++j) {\n const s = l + j * 3\n\n if (position) {\n const cx = -radius * cxArr[ j ] // TODO: Hack: Negating it so it faces outside.\n const cy = radius * cyArr[ j ]\n\n const cx1 = -radius * cx1Arr[ j ]\n const cy1 = radius * cy1Arr[ j ]\n const cx2 = -radius * cx2Arr[ j ]\n const cy2 = radius * cy2Arr[ j ]\n\n meshPosition[ s ] = posX + cx * normX + cy * biX\n meshPosition[ s + 1 ] = posY + cx * normY + cy * biY\n meshPosition[ s + 2 ] = posZ + cx * normZ + cy * biZ\n\n // TODO half of these are symmetric\n vMeshNormal.set(\n // ellipse tangent approximated as vector from/to adjacent points\n (cx2 * normX + cy2 * biX) - (cx1 * normX + cy1 * biX),\n (cx2 * normY + cy2 * biY) - (cx1 * normY + cy1 * biY),\n (cx2 * normZ + cy2 * biZ) - (cx1 * normZ + cy1 * biZ)\n ).cross(vTangent)\n\n meshNormal[ s ] = vMeshNormal.x\n meshNormal[ s + 1 ] = vMeshNormal.y\n meshNormal[ s + 2 ] = vMeshNormal.z\n }\n\n if (color) {\n meshColor[ s ] = color[ k ]\n meshColor[ s + 1 ] = color[ k + 1 ]\n meshColor[ s + 2 ] = color[ k + 2 ]\n }\n\n if (primitiveId) {\n meshPrimitiveId[ i * radialSegments + j ] = primitiveId[ i ]\n }\n }\n }\n\n // front cap\n\n k = 0\n l = n * 3 * radialSegments\n\n for (let j = 0; j < radialSegments; ++j) {\n const s = k + j * 3\n const t = l + j * 3\n\n if (position && tangent) {\n meshPosition[ t ] = meshPosition[ s ]\n meshPosition[ t + 1 ] = meshPosition[ s + 1 ]\n meshPosition[ t + 2 ] = meshPosition[ s + 2 ]\n\n meshNormal[ t ] = tangent[ k ]\n meshNormal[ t + 1 ] = tangent[ k + 1 ]\n meshNormal[ t + 2 ] = tangent[ k + 2 ]\n }\n\n if (color) {\n meshColor[ t ] = meshColor[ s ]\n meshColor[ t + 1 ] = meshColor[ s + 1 ]\n meshColor[ t + 2 ] = meshColor[ s + 2 ]\n }\n\n if (primitiveId) {\n meshPrimitiveId[ n * radialSegments + j ] = meshPrimitiveId[ 0 + j ]\n }\n }\n\n // back cap\n\n k = (n - 1) * 3 * radialSegments\n l = (n + 1) * 3 * radialSegments\n\n for (let j = 0; j < radialSegments; ++j) {\n const s = k + j * 3\n const t = l + j * 3\n\n if (position && tangent) {\n meshPosition[ t ] = meshPosition[ s ]\n meshPosition[ t + 1 ] = meshPosition[ s + 1 ]\n meshPosition[ t + 2 ] = meshPosition[ s + 2 ]\n\n meshNormal[ t ] = tangent[ n1 * 3 ]\n meshNormal[ t + 1 ] = tangent[ n1 * 3 + 1 ]\n meshNormal[ t + 2 ] = tangent[ n1 * 3 + 2 ]\n }\n\n if (color) {\n meshColor[ t ] = meshColor[ s ]\n meshColor[ t + 1 ] = meshColor[ s + 1 ]\n meshColor[ t + 2 ] = meshColor[ s + 2 ]\n }\n\n if (primitiveId) {\n meshPrimitiveId[ (n + 1) * radialSegments + j ] = meshPrimitiveId[ (n - 1) * radialSegments + j ]\n }\n }\n }\n\n makeIndex () {\n const index = this.geometry.getIndex()\n if (!index) { Log.error('Index is null'); return; }\n const meshIndex = index.array as Uint32Array|Uint16Array\n\n const n = this.size2\n const n1 = n - 1\n const capTriangles = this.capTriangles\n const radialSegments = this.parameters.radialSegments\n const radialSegments1 = this.parameters.radialSegments + 1\n\n let k, l\n\n for (let i = 0; i < n1; ++i) {\n const k = i * radialSegments * 3 * 2\n\n const irs = i * radialSegments\n const irs1 = (i + 1) * radialSegments\n\n for (let j = 0; j < radialSegments; ++j) {\n l = k + j * 3 * 2\n\n // meshIndex[ l + 0 ] = irs + ( ( j + 0 ) % radialSegments );\n meshIndex[ l ] = irs + j\n meshIndex[ l + 1 ] = irs + ((j + 1) % radialSegments)\n // meshIndex[ l + 2 ] = irs1 + ( ( j + 0 ) % radialSegments );\n meshIndex[ l + 2 ] = irs1 + j\n\n // meshIndex[ l + 3 ] = irs1 + ( ( j + 0 ) % radialSegments );\n meshIndex[ l + 3 ] = irs1 + j\n meshIndex[ l + 4 ] = irs + ((j + 1) % radialSegments)\n meshIndex[ l + 5 ] = irs1 + ((j + 1) % radialSegments)\n }\n }\n\n // capping\n\n const strip = [ 0 ]\n\n for (let j = 1; j < radialSegments1 / 2; ++j) {\n strip.push(j)\n if (radialSegments - j !== j) {\n strip.push(radialSegments - j)\n }\n }\n\n // front cap\n\n l = n1 * radialSegments * 3 * 2\n k = n * radialSegments\n\n for (let j = 0; j < strip.length - 2; ++j) {\n if (j % 2 === 0) {\n meshIndex[ l + j * 3 + 0 ] = k + strip[ j + 0 ]\n meshIndex[ l + j * 3 + 1 ] = k + strip[ j + 1 ]\n meshIndex[ l + j * 3 + 2 ] = k + strip[ j + 2 ]\n } else {\n meshIndex[ l + j * 3 + 0 ] = k + strip[ j + 2 ]\n meshIndex[ l + j * 3 + 1 ] = k + strip[ j + 1 ]\n meshIndex[ l + j * 3 + 2 ] = k + strip[ j + 0 ]\n }\n }\n\n // back cap\n\n l = n1 * radialSegments * 3 * 2 + 3 * capTriangles\n k = n * radialSegments + radialSegments\n\n for (let j = 0; j < strip.length - 2; ++j) {\n if (j % 2 === 0) {\n meshIndex[ l + j * 3 + 0 ] = k + strip[ j + 0 ]\n meshIndex[ l + j * 3 + 1 ] = k + strip[ j + 1 ]\n meshIndex[ l + j * 3 + 2 ] = k + strip[ j + 2 ]\n } else {\n meshIndex[ l + j * 3 + 0 ] = k + strip[ j + 2 ]\n meshIndex[ l + j * 3 + 1 ] = k + strip[ j + 1 ]\n meshIndex[ l + j * 3 + 2 ] = k + strip[ j + 0 ]\n }\n }\n }\n}\n\nexport default TubeMeshBuffer\n","/**\n * @file Cartoon Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { Debug, Log, RepresentationRegistry } from '../globals'\nimport Spline from '../geometry/spline'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport TubeMeshBuffer from '../buffer/tubemesh-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport Polymer from '../proxy/polymer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport StructureView from '../structure/structure-view';\nimport Buffer from '../buffer/buffer';\n\nexport interface CartoonRepresentationParameters extends StructureRepresentationParameters {\n aspectRatio: number\n subdiv: number\n radialSegments: number\n tension: number\n capped: boolean\n smoothSheet: boolean\n}\n\n/**\n * Cartoon representation. Show a thick ribbon that\n * smoothly connecting backbone atoms in polymers.\n *\n * __Name:__ _cartoon_\n *\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\" );\n * o.autoView();\n * } );\n */\nclass CartoonRepresentation extends StructureRepresentation {\n protected aspectRatio: number\n protected tension: number\n protected capped: boolean\n protected smoothSheet: boolean\n protected subdiv: number\n \n /**\n * Create Cartoon representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {StructureRepresentationParameters} params - representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'cartoon'\n\n this.parameters = Object.assign({\n\n aspectRatio: {\n type: 'number', precision: 1, max: 10.0, min: 1.0, rebuild: true\n },\n subdiv: {\n type: 'integer', max: 50, min: 1, rebuild: true\n },\n radialSegments: {\n type: 'integer', max: 50, min: 1, rebuild: true\n },\n tension: {\n type: 'number', precision: 1, max: 1.0, min: 0.1\n },\n capped: {\n type: 'boolean', rebuild: true\n },\n smoothSheet: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'chainname')\n p.colorScale = defaults(p.colorScale, 'RdYlBu')\n p.radiusType = defaults(p.radiusType, 'sstruc')\n p.radiusScale = defaults(p.radiusScale, 0.7)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.aspectRatio = defaults(p.aspectRatio, 5.0)\n this.tension = defaults(p.tension, NaN)\n this.capped = defaults(p.capped, true)\n this.smoothSheet = defaults(p.smoothSheet, false)\n\n if (p.quality === 'low') {\n this.subdiv = 3\n this.radialSegments = 6\n } else if (p.quality === 'medium') {\n this.subdiv = 6\n } else if (p.quality === 'high') {\n this.subdiv = 12\n } else {\n this.subdiv = defaults(p.subdiv, 6)\n }\n\n super.init(p)\n }\n\n getSplineParams (params?: Partial) {\n return Object.assign({\n subdiv: this.subdiv,\n tension: this.tension,\n directional: this.aspectRatio !== 1.0,\n smoothSheet: this.smoothSheet\n }, params)\n }\n\n getSpline (polymer: Polymer): Spline {\n return new Spline(polymer, this.getSplineParams())\n }\n\n getAspectRatio (polymer: Polymer): number {\n return polymer.isCg() ? 1.0 : this.aspectRatio\n }\n\n getAtomRadius (atom: AtomProxy): number {\n return atom.isTrace() ? super.getAtomRadius(atom) : 0\n }\n\n createData (sview: StructureView) {\n let bufferList: Buffer[] = []\n let polymerList: Polymer[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4) return\n polymerList.push(polymer)\n\n const spline = this.getSpline(polymer)\n const aspectRatio = this.getAspectRatio(polymer)\n\n const subPos = spline.getSubdividedPosition()\n const subOri = spline.getSubdividedOrientation()\n const subCol = spline.getSubdividedColor(this.getColorParams())\n const subPick = spline.getSubdividedPicking()\n const subSize = spline.getSubdividedSize(this.getRadiusParams())\n\n bufferList.push(\n new TubeMeshBuffer(\n Object.assign({}, subPos, subOri, subCol, subPick, subSize),\n this.getBufferParams({\n radialSegments: this.radialSegments,\n aspectRatio: aspectRatio,\n capped: this.capped\n })\n )\n )\n }, sview.getSelection())\n\n return {\n bufferList: bufferList,\n polymerList: polymerList\n }\n }\n\n updateData (what: any, data: StructureRepresentationData) {\n if (Debug) Log.time(this.type + ' repr update')\n\n what = what || {}\n\n for (var i = 0, il = data.polymerList!.length; i < il; ++i) {\n var bufferData: {[key: string]: any} = {}\n var polymer = data.polymerList![ i ]\n var spline = this.getSpline(polymer)\n var aspectRatio = this.getAspectRatio(polymer)\n\n Object.assign(data.bufferList[ i ], {aspectRatio: aspectRatio})\n\n if (what.position || what.radius) {\n var subPos = spline.getSubdividedPosition()\n var subOri = spline.getSubdividedOrientation()\n var subSize = spline.getSubdividedSize(this.getRadiusParams(aspectRatio))\n\n bufferData.position = subPos.position\n bufferData.normal = subOri.normal\n bufferData.binormal = subOri.binormal\n bufferData.tangent = subOri.tangent\n bufferData.size = subSize.size\n }\n\n if (what.color) {\n var subCol = spline.getSubdividedColor(this.getColorParams())\n bufferData.color = subCol.color\n }\n\n if (what.picking) {\n var subPick = spline.getSubdividedPicking()\n bufferData.picking = subPick.picking\n }\n\n data.bufferList[ i ].setAttributes(bufferData)\n }\n\n if (Debug) Log.timeEnd(this.type + ' repr update')\n }\n\n setParameters (params: Partial) {\n const rebuild = false\n var what: {[k: string]: any} = {}\n\n if (params && params.aspectRatio) {\n what.radius = true\n }\n\n if (params && params.tension) {\n what.position = true\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('cartoon', CartoonRepresentation)\n\nexport default CartoonRepresentation\n","/**\n * @file Contact Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { RepresentationRegistry } from '../globals'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport { calculateContacts, getContactData, getLabelData } from '../chemistry/interactions/contact'\nimport CylinderBuffer from '../buffer/cylinder-buffer'\nimport TextBuffer from '../buffer/text-buffer'\nimport { getFixedCountDashData } from '../geometry/dash'\nimport Viewer from '../viewer/viewer';\nimport { Structure } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport CylinderImpostorBuffer from '../buffer/cylinderimpostor-buffer';\n// @ts-ignore: unused import ContactPicker required for declaration only\nimport { ContactPicker } from '../utils/picker';\n\nexport interface ContactRepresentationParameters extends StructureRepresentationParameters {\n hydrogenBond: boolean\n weakHydrogenBond: boolean\n waterHydrogenBond: boolean\n backboneHydrogenBond: boolean\n hydrophobic: boolean\n halogenBond: boolean\n ionicInteraction: boolean\n metalCoordination: boolean\n cationPi: boolean\n piStacking: boolean\n filterSele: string|[string, string]\n maxHydrophobicDist: number\n maxHbondDist: number\n maxHbondSulfurDist: number\n maxHbondAccAngle: number\n maxHbondDonAngle: number\n maxHbondAccPlaneAngle: number\n maxHbondDonPlaneAngle: number\n maxPiStackingDist: number\n maxPiStackingOffset: number\n maxPiStackingAngle: number\n maxCationPiDist: number\n maxCationPiOffset: number\n maxIonicDist: number\n maxHalogenBondDist: number\n maxHalogenBondAngle: number\n maxMetalDist: number\n refineSaltBridges: boolean\n masterModelIndex: number\n lineOfSightDistFactor: number\n}\n\n/**\n * Contact representation.\n */\nclass ContactRepresentation extends StructureRepresentation {\n protected hydrogenBond: boolean\n protected weakHydrogenBond: boolean\n protected waterHydrogenBond: boolean\n protected backboneHydrogenBond: boolean\n protected hydrophobic: boolean\n protected halogenBond: boolean\n protected ionicInteraction: boolean\n protected metalCoordination: boolean\n protected cationPi: boolean\n protected piStacking: boolean\n protected filterSele: string|[string, string]\n protected maxHydrophobicDist: number\n protected maxHbondDist: number\n protected maxHbondSulfurDist: number\n protected maxHbondAccAngle: number\n protected maxHbondDonAngle: number\n protected maxHbondAccPlaneAngle: number\n protected maxHbondDonPlaneAngle: number\n protected maxPiStackingDist: number\n protected maxPiStackingOffset: number\n protected maxPiStackingAngle: number\n protected maxCationPiDist: number\n protected maxCationPiOffset: number\n protected maxIonicDist: number\n protected maxHalogenBondDist: number\n protected maxHalogenBondAngle: number\n protected maxMetalDist: number\n protected refineSaltBridges: boolean\n protected masterModelIndex: number\n protected lineOfSightDistFactor: number\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'contact'\n\n this.parameters = Object.assign({\n hydrogenBond: {\n type: 'boolean', rebuild: true\n },\n weakHydrogenBond: {\n type: 'boolean', rebuild: true\n },\n waterHydrogenBond: {\n type: 'boolean', rebuild: true\n },\n backboneHydrogenBond: {\n type: 'boolean', rebuild: true\n },\n hydrophobic: {\n type: 'boolean', rebuild: true\n },\n halogenBond: {\n type: 'boolean', rebuild: true\n },\n ionicInteraction: {\n type: 'boolean', rebuild: true\n },\n metalCoordination: {\n type: 'boolean', rebuild: true\n },\n cationPi: {\n type: 'boolean', rebuild: true\n },\n piStacking: {\n type: 'boolean', rebuild: true\n },\n\n filterSele: {\n type: 'text', rebuild: true\n },\n\n labelVisible: {\n type: 'boolean', rebuild: true\n },\n\n labelFixedSize: {\n type: 'boolean', buffer: 'fixedSize'\n },\n\n labelSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001, rebuild: true\n },\n\n labelUnit: {\n type: 'select',\n rebuild: true,\n options: { '': '', angstrom: 'angstrom', nm: 'nm' }\n },\n\n maxHydrophobicDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHbondDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHbondSulfurDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHbondAccAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n maxHbondDonAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n maxHbondAccPlaneAngle: {\n type: 'integer', max: 90, min: 0, rebuild: true\n },\n maxHbondDonPlaneAngle: {\n type: 'integer', max: 90, min: 0, rebuild: true\n },\n maxPiStackingDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxPiStackingOffset: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxPiStackingAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n maxCationPiDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxCationPiOffset: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxIonicDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHalogenBondDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHalogenBondAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n maxMetalDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n refineSaltBridges: {\n type: 'boolean', rebuild: true\n },\n masterModelIndex: {\n type: 'integer', max: 1000, min: -1, rebuild: true\n },\n lineOfSightDistFactor: {\n type: 'number', precision: 1, max: 10, min: 0.0, rebuild: true\n },\n\n radialSegments: true,\n disableImpostor: true\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.radiusSize = defaults(p.radiusSize, 0.05)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.hydrogenBond = defaults(p.hydrogenBond, true)\n this.weakHydrogenBond = defaults(p.weakHydrogenBond, false)\n this.waterHydrogenBond = defaults(p.waterHydrogenBond, false)\n this.backboneHydrogenBond = defaults(p.backboneHydrogenBond, false)\n this.hydrophobic = defaults(p.hydrophobic, false)\n this.halogenBond = defaults(p.halogenBond, true)\n this.ionicInteraction = defaults(p.ionicInteraction, true)\n this.metalCoordination = defaults(p.metalCoordination, true)\n this.cationPi = defaults(p.cationPi, true)\n this.piStacking = defaults(p.piStacking, true)\n\n this.filterSele = defaults(p.filterSele, '')\n this.labelVisible = defaults(p.labelVisible, false)\n this.labelFixedSize = defaults(p.labelFixedSize, false)\n this.labelSize = defaults(p.labelSize, 2.0)\n this.labelUnit = defaults(p.labelUnit, '')\n\n this.maxHydrophobicDist = defaults(p.maxHydrophobicDist, 4.0)\n this.maxHbondDist = defaults(p.maxHbondDist, 3.5)\n this.maxHbondSulfurDist = defaults(p.maxHbondSulfurDist, 4.1)\n this.maxHbondAccAngle = defaults(p.maxHbondAccAngle, 45)\n this.maxHbondDonAngle = defaults(p.maxHbondDonAngle, 45)\n this.maxHbondAccPlaneAngle = defaults(p.maxHbondAccPlaneAngle, 90)\n this.maxHbondDonPlaneAngle = defaults(p.maxHbondDonPlaneAngle, 30)\n this.maxPiStackingDist = defaults(p.maxPiStackingDist, 5.5)\n this.maxPiStackingOffset = defaults(p.maxPiStackingOffset, 2.0)\n this.maxPiStackingAngle = defaults(p.maxPiStackingAngle, 30)\n this.maxCationPiDist = defaults(p.maxCationPiDist, 6.0)\n this.maxCationPiOffset = defaults(p.maxCationPiOffset, 2.0)\n this.maxIonicDist = defaults(p.maxIonicDist, 5.0)\n this.maxHalogenBondDist = defaults(p.maxHalogenBondDist, 3.5)\n this.maxHalogenBondAngle = defaults(p.maxHalogenBondAngle, 30)\n this.maxMetalDist = defaults(p.maxMetalDist, 3.0)\n this.refineSaltBridges = defaults(p.refineSaltBridges, true)\n this.masterModelIndex = defaults(p.masterModelIndex, -1)\n this.lineOfSightDistFactor = defaults(p.lineOfSightDistFactor, 1.0)\n\n super.init(p)\n }\n\n getAtomRadius () {\n return 0\n }\n\n getContactData (sview: StructureView) {\n const params = {\n maxHydrophobicDist: this.maxHydrophobicDist,\n maxHbondDist: this.maxHbondDist,\n maxHbondSulfurDist: this.maxHbondSulfurDist,\n maxHbondAccAngle: this.maxHbondAccAngle,\n maxHbondDonAngle: this.maxHbondDonAngle,\n maxHbondAccPlaneAngle: this.maxHbondAccPlaneAngle,\n maxHbondDonPlaneAngle: this.maxHbondDonPlaneAngle,\n maxPiStackingDist: this.maxPiStackingDist,\n maxPiStackingOffset: this.maxPiStackingOffset,\n maxPiStackingAngle: this.maxPiStackingAngle,\n maxCationPiDist: this.maxCationPiDist,\n maxCationPiOffset: this.maxCationPiOffset,\n maxIonicDist: this.maxIonicDist,\n maxHalogenBondDist: this.maxHalogenBondDist,\n maxHalogenBondAngle: this.maxHalogenBondAngle,\n maxMetalDist: this.maxMetalDist,\n refineSaltBridges: this.refineSaltBridges,\n masterModelIndex: this.masterModelIndex,\n lineOfSightDistFactor: this.lineOfSightDistFactor\n }\n\n const dataParams = {\n hydrogenBond: this.hydrogenBond,\n weakHydrogenBond: this.weakHydrogenBond,\n waterHydrogenBond: this.waterHydrogenBond,\n backboneHydrogenBond: this.backboneHydrogenBond,\n hydrophobic: this.hydrophobic,\n halogenBond: this.halogenBond,\n ionicInteraction: this.ionicInteraction,\n metalCoordination: this.metalCoordination,\n cationPi: this.cationPi,\n piStacking: this.piStacking,\n radius: this.radiusSize * this.radiusScale,\n filterSele: this.filterSele\n }\n\n const contacts = calculateContacts(sview, params)\n return getContactData(contacts, sview, dataParams)\n }\n\n createData (sview: StructureView) {\n const contactData = this.getContactData(sview)\n\n const bufferList = [\n new CylinderBuffer(\n getFixedCountDashData(contactData),\n this.getBufferParams({\n sphereDetail: 1,\n dullInterior: true,\n disableImpostor: this.disableImpostor\n })\n ) as (CylinderGeometryBuffer | CylinderImpostorBuffer | TextBuffer)\n ]\n\n if (this.labelVisible) {\n const labelParams = {\n size: this.labelSize,\n unit: this.labelUnit\n }\n bufferList.push(new TextBuffer(\n getLabelData(contactData, labelParams),\n this.getBufferParams({fixedSize: this.labelFixedSize})\n ))\n }\n\n return { bufferList }\n }\n}\n\nRepresentationRegistry.add('contact', ContactRepresentation)\n\nexport default ContactRepresentation\n","/**\n * @file Dihedral Representation\n * @author Fred Ludlow \n * @private\n */\nimport { Color } from 'three'\n\nimport { RepresentationRegistry } from '../globals'\nimport MeasurementRepresentation, { calcArcPoint, parseNestedAtoms, MeasurementRepresentationParameters, LabelDataField } from './measurement-representation'\nimport { defaults } from '../utils'\n\nimport MeshBuffer from '../buffer/mesh-buffer'\nimport TextBuffer, { TextBufferData } from '../buffer/text-buffer'\nimport WideLineBuffer from '../buffer/wideline-buffer'\n\nimport { copyArray, uniformArray, uniformArray3 } from '../math/array-utils'\nimport { v3add, v3angle, v3cross, v3dot, v3multiplyScalar, v3fromArray, v3length,\n v3negate, v3new, v3normalize, v3sub, v3toArray } from '../math/vector-utils'\nimport { RAD2DEG } from '../math/math-constants'\nimport { getFixedLengthWrappedDashData } from '../geometry/dash'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { CylinderBufferData } from '../buffer/cylinder-buffer';\nimport { BufferData } from '../buffer/buffer';\nimport { StructureRepresentationData } from './structure-representation';\n\n/**\n * @typedef {Object} DihedralRepresentationParameters - dihedral representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n * @mixes MeasurementRepresentationParameters\n *\n * @property {String} atomQuad - list of quadruplets of selection strings\n * or atom indices\n * @property {Boolean} extendLine - Extend lines in planes\n * @property {Number} lineOpacity - Opacity for the line part of the representation\n * @property {Boolean} lineVisible - Display the line part of the representation\n * @property {Number} linewidth - width for line part of representation\n * @property {Boolean} planeVisible - Display the two planes corresponding to dihedral\n * @property {Boolean} sectorVisible - Display the filled arc for each angle\n */\n\nexport interface DihedralRepresentationParameters extends MeasurementRepresentationParameters {\n atomQuad: (number|string)[][]\n extendLine: boolean\n lineOpacity: number\n lineVisible: boolean\n linewidth: number\n planeVisible: boolean\n sectorVisible: boolean\n}\n\n/**\n * Dihedral representation object\n *\n * Reperesentation consists of three parts, visibility can be set for each\n * label - text label indicating dihedral angle\n * line - line indicating four positions that define the dihedral\n * sector - filled arc section\n *\n * @param {Structure} structure - the structure to measure angles in\n * @param {Viewer} viewer - a viewer object\n * @param {AngleRepresentationParameters} params - angle representation parameters\n */\nclass DihedralRepresentation extends MeasurementRepresentation {\n protected atomQuad: (number|string)[][]\n protected extendLine: boolean\n protected lineOpacity: number\n protected lineVisible: boolean\n protected linewidth: number\n protected planeVisible: boolean\n protected sectorVisible: boolean\n\n protected lineLength: number\n protected planeLength: number\n protected sectorLength: number\n\n protected lineBuffer: WideLineBuffer\n protected planeBuffer: MeshBuffer\n protected sectorBuffer: MeshBuffer\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'dihedral'\n\n this.parameters = Object.assign({\n atomQuad: {\n type: 'hidden', rebuild: true\n },\n extendLine: {\n type: 'boolean', rebuild: true, default: true\n },\n lineVisible: {\n type: 'boolean', default: true\n },\n planeVisible: {\n type: 'boolean', default: true\n },\n sectorVisible: {\n type: 'boolean', default: true\n }\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.side = defaults(p.side, 'double')\n p.opacity = defaults(p.opacity, 0.5)\n\n this.atomQuad = defaults(p.atomQuad, [])\n this.extendLine = defaults(p.extendLine, true)\n this.lineVisible = defaults(p.lineVisible, true)\n this.planeVisible = defaults(p.planeVisible, true)\n this.sectorVisible = defaults(p.sectorVisible, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n if (!sview.atomCount || !this.atomQuad.length) return\n\n const atomPosition = parseNestedAtoms(sview, this.atomQuad)\n const dihedralData = getDihedralData(\n atomPosition, {\n extendLine: this.extendLine\n }\n )\n\n const n = this.n = dihedralData.labelText.length\n const labelColor = new Color(this.labelColor)\n\n this.textBuffer = new TextBuffer({\n position: dihedralData.labelPosition,\n size: uniformArray(n, this.labelSize),\n color: uniformArray3(n, labelColor.r, labelColor.g, labelColor.b),\n text: dihedralData.labelText\n } as TextBufferData, this.getLabelBufferParams())\n\n const c = new Color(this.colorValue)\n this.lineLength = dihedralData.linePosition1.length / 3\n const lineColor = uniformArray3(this.lineLength, c.r, c.g, c.b)\n\n this.lineBuffer = new WideLineBuffer(\n getFixedLengthWrappedDashData({\n position1: dihedralData.linePosition1,\n position2: dihedralData.linePosition2,\n color: lineColor,\n color2: lineColor\n } as CylinderBufferData) ,\n this.getBufferParams({\n linewidth: this.linewidth,\n visible: this.lineVisible,\n opacity: this.lineOpacity\n })\n )\n\n this.planeLength = dihedralData.planePosition.length / 3\n this.planeBuffer = new MeshBuffer({\n position: dihedralData.planePosition,\n color: uniformArray3(this.planeLength, c.r, c.g, c.b)\n } as BufferData, this.getBufferParams({\n visible: this.planeVisible\n }))\n\n this.sectorLength = dihedralData.sectorPosition.length / 3\n this.sectorBuffer = new MeshBuffer({\n position: dihedralData.sectorPosition,\n color: uniformArray3(this.sectorLength, c.r, c.g, c.b)\n } as BufferData, this.getBufferParams({\n visible: this.sectorVisible\n }))\n\n return {\n bufferList: [\n this.textBuffer,\n this.lineBuffer,\n this.planeBuffer,\n this.sectorBuffer\n ]\n }\n }\n\n updateData (what: LabelDataField & {color?: boolean}, data: StructureRepresentationData) {\n super.updateData(what, data)\n const lineData = {}\n const planeData = {}\n const sectorData = {}\n\n if (what.color) {\n const c = new Color(this.colorValue)\n Object.assign(lineData, {\n color: uniformArray3(this.lineLength, c.r, c.g, c.b),\n color2: uniformArray3(this.lineLength, c.r, c.g, c.b)\n })\n Object.assign(planeData, {\n color: uniformArray3(this.planeLength, c.r, c.g, c.b)\n })\n Object.assign(sectorData, {\n color: uniformArray3(this.sectorLength, c.r, c.g, c.b)\n })\n }\n\n this.lineBuffer.setAttributes(lineData)\n this.planeBuffer.setAttributes(planeData)\n this.sectorBuffer.setAttributes(sectorData)\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n super.setParameters(params, what, rebuild)\n\n if (params && (\n params.lineVisible !== undefined ||\n params.sectorVisible !== undefined ||\n params.planeVisible !== undefined)) {\n this.setVisibility(this.visible)\n }\n\n if (params && params.lineOpacity) {\n this.lineBuffer.setParameters({ opacity: params.lineOpacity })\n }\n\n if (params && params.opacity !== undefined) {\n this.lineBuffer.setParameters({ opacity: this.lineOpacity })\n }\n\n if (params && params.linewidth) {\n this.lineBuffer.setParameters({ linewidth: params.linewidth })\n }\n\n return this\n }\n\n setVisibility (value: boolean, noRenderRequest?: boolean) {\n super.setVisibility(value, true)\n\n if (this.lineBuffer) {\n this.lineBuffer.setVisibility(this.lineVisible && this.visible)\n }\n\n if (this.planeBuffer) {\n this.planeBuffer.setVisibility(this.planeVisible && this.visible)\n }\n\n if (this.sectorBuffer) {\n this.sectorBuffer.setVisibility(this.sectorVisible && this.visible)\n }\n\n if (!noRenderRequest) this.viewer.requestRender()\n\n return this\n }\n}\n\n/**\n * Build the data required to create {Buffer} objects, given positions\n * @param {Float32Array} atomPosition 3*4*nDihedral array of coordinates\n * @return {Object} Arrays for building buffers\n */\nfunction getDihedralData (position: Float32Array, params: Partial = {}) {\n const angleStep = defaults(params.angleStep, Math.PI / 90)\n const nPos = position.length\n const n = position.length / 12\n const angles = new Float32Array(n)\n const labelPosition = new Float32Array(n * 3)\n const labelText = new Array(n)\n\n // Temporary arrays as don't know output length yet\n const lineTmp1 = new Array(n)\n const lineTmp2 = new Array(n)\n const sectorTmp = new Array(n)\n const planeTmp = new Array(n)\n\n // Eventual sizes of output arrays\n let totalLines = 0\n let totalSegments = 0\n let totalPlanes = 0\n\n const p1 = v3new()\n const p2 = v3new()\n const p3 = v3new()\n const p4 = v3new()\n\n const v21 = v3new()\n const v23 = v3new()\n const v34 = v3new()\n\n const tmp = v3new()\n const mid = v3new()\n const inPlane1 = v3new()\n const inPlane2 = v3new()\n const start = v3new()\n const end = v3new()\n\n const cross = v3new()\n const arcPoint = v3new()\n\n let i = 0 // Actual output index (after skipping inappropriate)\n\n for (var p = 0; p < nPos; p += 12) {\n // Set Positions\n v3fromArray(p1, position, p)\n v3fromArray(p2, position, p + 3)\n v3fromArray(p3, position, p + 6)\n v3fromArray(p4, position, p + 9)\n\n // Vectors between points\n v3sub(v21, p1, p2)\n v3sub(v23, p3, p2)\n if (v3length(v23) === 0.0) {\n continue // Can't define axis\n }\n\n v3sub(v34, p4, p3)\n\n v3multiplyScalar(tmp, v23, 0.5)\n v3add(mid, p2, tmp)\n\n v3normalize(v21, v21)\n v3normalize(v23, v23)\n v3normalize(v34, v34)\n\n // Which side of plane are p1, p4 (are we measuring something that\n // looks more like an improper? e.g. C, CA, CB, N)\n v3sub(tmp, p1, mid)\n const improperStart = v3dot(tmp, v23) > 0.0\n v3sub(tmp, p4, mid)\n const improperEnd = v3dot(tmp, v23) < 0.0\n\n // Calculate vectors perp to v23 (lying in plane (1,2,3) and (2,3,4))\n v3multiplyScalar(tmp, v23, v3dot(v23, v21))\n v3sub(inPlane1, v21, tmp)\n\n v3multiplyScalar(tmp, v23, v3dot(v23, v34))\n v3sub(inPlane2, v34, tmp)\n\n if (v3length(inPlane1) === 0.0 || v3length(inPlane2) === 0.0) {\n continue // Indeterminate angle\n }\n\n v3normalize(inPlane1, inPlane1)\n v3normalize(inPlane2, inPlane2)\n\n const angle = angles[ i ] = v3angle(inPlane1, inPlane2)\n labelText[ i ] = (RAD2DEG * angle).toFixed(1) + String.fromCharCode(0x00B0)\n\n v3cross(cross, inPlane1, v23)\n v3normalize(cross, cross)\n if (v3dot(cross, inPlane2) < 0.0) {\n v3negate(cross, cross) // Ensure cp faces correct way\n }\n\n calcArcPoint(tmp, mid, inPlane1, cross, angle / 2.0)\n v3toArray(tmp, labelPosition, 3 * i)\n\n const nSegments = Math.ceil(angle / angleStep)\n // For extended display mode, 4 straight lines plus arc/segment edge\n // For non-extended, 2 straight lines plus segment edge\n const nLines = nSegments + ((params.extendLine) ? 4 : 2)\n\n // Don't draw planes if not extending lines\n const nPlanes = params.extendLine ? 36 : 0\n\n const line1 = new Float32Array(nLines * 3)\n const line2 = new Float32Array(nLines * 3)\n const sector = new Float32Array(nSegments * 9)\n // 2 planes, 2 triangles each per dihedral (2*2*9)\n const plane = new Float32Array(nPlanes)\n\n lineTmp1[ i ] = line1\n lineTmp2[ i ] = line2\n sectorTmp[ i ] = sector\n planeTmp[ i ] = plane\n\n // Start points for lines/planes, only required\n // if extending lines\n if (params.extendLine) {\n if (improperStart) { // We'll start on the v3->1 line (tmp)\n v3sub(tmp, p1, p3)\n v3normalize(tmp, tmp)\n v3multiplyScalar(start, tmp, 1.0 / v3dot(inPlane1, tmp))\n v3add(start, start, p3)\n } else { // start on the 2->1 line\n v3multiplyScalar(start, v21, 1.0 / v3dot(inPlane1, v21))\n v3add(start, start, p2)\n }\n\n if (improperEnd) { // Finish on 2->4 line\n v3sub(tmp, p4, p2)\n v3normalize(tmp, tmp)\n v3multiplyScalar(end, tmp, 1.0 / v3dot(inPlane2, tmp))\n v3add(end, end, p2)\n } else { // end on the 3->4 line\n v3multiplyScalar(end, v34, 1.0 / v3dot(inPlane2, v34))\n v3add(end, end, p3)\n }\n }\n\n v3add(arcPoint, mid, inPlane1)\n\n // index into line1, line2\n let li = 0\n // If extending lines, there's a bit of stuff to do here\n // figuring out start and end positions\n if (params.extendLine) {\n v3toArray(p1, line1, li)\n v3toArray(start, line2, li)\n li += 3\n v3toArray(start, line1, li)\n v3toArray(arcPoint, line2, li)\n li += 3\n\n // Construct plane at start, if not extening lines\n // this is skipped\n v3toArray(start, plane, 0)\n v3toArray(arcPoint, plane, 3)\n v3toArray(improperStart ? p3 : p2, plane, 6)\n v3toArray(improperStart ? p3 : p2, plane, 9)\n v3toArray(arcPoint, plane, 12)\n v3toArray(mid, plane, 15)\n } else {\n // Not extending lines\n v3toArray(mid, line1, li)\n v3toArray(arcPoint, line2, li)\n li += 3\n }\n\n const appendArcSection = function (a: number, j: number) {\n const si = j * 9\n\n v3toArray(mid, sector, si)\n v3toArray(arcPoint, sector, si + 3)\n v3toArray(arcPoint, line1, li)\n\n calcArcPoint(arcPoint, mid, inPlane1, cross, a)\n\n v3toArray(arcPoint, sector, si + 6)\n v3toArray(arcPoint, line2, li)\n li += 3\n }\n\n let j = 0\n for (let a = angleStep; a < angle; a += angleStep) {\n appendArcSection(a, j++)\n }\n appendArcSection(angle, j++)\n\n if (params.extendLine) {\n v3toArray(arcPoint, line1, (nLines - 2) * 3)\n v3toArray(end, line2, (nLines - 2) * 3)\n v3toArray(end, line1, (nLines - 1) * 3)\n v3toArray(p4, line2, (nLines - 1) * 3)\n\n // Construct plane at end\n v3toArray(end, plane, 18)\n v3toArray(arcPoint, plane, 21)\n v3toArray(improperEnd ? p2 : p3, plane, 24)\n v3toArray(improperEnd ? p2 : p3, plane, 27)\n v3toArray(arcPoint, plane, 30)\n v3toArray(mid, plane, 33)\n } else {\n v3toArray(arcPoint, line1, li)\n v3toArray(mid, line2, li)\n li += 3\n }\n\n totalLines += nLines * 3\n totalSegments += nSegments * 9\n totalPlanes += nPlanes\n i += 1\n }\n\n const nSuccess = i\n\n const linePosition1 = new Float32Array(totalLines)\n const linePosition2 = new Float32Array(totalLines)\n const sectorPosition = new Float32Array(totalSegments)\n const planePosition = new Float32Array(totalPlanes)\n\n let lineOffset = 0\n let sectorOffset = 0\n let planeOffset = 0\n\n for (let i = 0; i < nSuccess; i++) {\n const lp1 = lineTmp1[ i ]\n const lp2 = lineTmp2[ i ]\n const sp = sectorTmp[ i ]\n const pp = planeTmp[ i ]\n\n copyArray(lp1, linePosition1, 0, lineOffset, lp1.length)\n copyArray(lp2, linePosition2, 0, lineOffset, lp2.length)\n copyArray(sp, sectorPosition, 0, sectorOffset, sp.length)\n copyArray(pp, planePosition, 0, planeOffset, pp.length)\n\n lineOffset += lp1.length\n sectorOffset += sp.length\n planeOffset += pp.length\n }\n\n return {\n labelPosition: labelPosition.subarray(0, nSuccess * 3),\n labelText: labelText.slice(0, nSuccess),\n linePosition1,\n linePosition2,\n planePosition,\n sectorPosition\n }\n}\n\nRepresentationRegistry.add('dihedral', DihedralRepresentation)\n\nexport default DihedralRepresentation\n","/**\n * @file Dihedral Histogram Representation\n * @author Rudolfs Petrovs \n * @private\n */\nimport { Color } from 'three'\n\nimport { calcArcPoint, parseNestedAtoms } from './measurement-representation'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\n\nimport { RepresentationRegistry } from '../globals'\nimport { Structure } from '../ngl'\nimport { defaults } from '../utils'\n\nimport { BufferData } from '../buffer/buffer'\nimport MeshBuffer from '../buffer/mesh-buffer'\nimport WideLineBuffer, { WideLineBufferData } from '../buffer/wideline-buffer'\n\nimport { copyArray, uniformArray3, arraySum } from '../math/array-utils'\nimport {\n v3add, v3cross, v3dot, v3multiplyScalar, v3fromArray,\n v3negate, v3new, v3normalize, v3sub, v3toArray, v3length\n} from '../math/vector-utils'\n\nimport StructureView from '../structure/structure-view'\n\nimport Viewer from '../viewer/viewer'\n\n\nconst pointLength = 3 // One Point Length (number of coordinates of one point in 3D)\nconst pointsInTriangle = 3\n\ntype ColorDefinition = Color | string | number | undefined\n\ninterface HistogramColorParameters {\n histogramBinBorderColor: ColorDefinition\n adjacentBondArrowColor: ColorDefinition\n distantBondArrowColor: ColorDefinition\n frontHistogramColor: ColorDefinition\n backHistogramColor: ColorDefinition\n opaqueMiddleDiscColor: ColorDefinition\n}\n\ninterface HistogramInputData extends Partial {\n atomQuad: (number | string)[]\n histogram360: number[]\n}\n\ninterface HistogramData extends HistogramInputData {\n atomPositions: Float32Array\n histogram360Scaled: number[]\n}\n\ninterface WideLineData {\n startPoints: Float32Array\n endPoints: Float32Array\n startColors: Float32Array\n endColors: Float32Array\n}\n\ninterface MeshData {\n triangles: Float32Array\n triangleColors: Float32Array\n}\n\nfunction createUpdatedObject(o: Object, updateSource: Object) {\n function hasKey(obj: O, key: keyof any): key is keyof O {\n return key in obj\n }\n\n const result = { ...o } // Shallow copy\n for (const key in result) {\n if (hasKey(result, key) && hasKey(updateSource, key)) {\n result[key] = defaults(updateSource[key], result[key])\n }\n }\n return result\n}\n\nfunction createColorArray(color: ColorDefinition, arrayLength: number) {\n const colorValue = new Color(color)\n const targetArray = new Float32Array(arrayLength * 3)\n uniformArray3(arrayLength, colorValue.r, colorValue.g, colorValue.b, targetArray)\n return targetArray\n}\n\n/**\n * @typedef {Object} DihedralHistogramRepresentationParameters - dihedral representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n *\n * @property {HistogramInputData[]} histogramsData\n * List of HistogramInputData objects, which properties specifies each particular\n * histogram, and can contain particular histogram-specific parameters.\n * Obligatory properties are:\n * atomQuad - Quadruplet of selection strings or atom indices\n * histogram360 - List of values, representing histogram from 0 to 360 degrees.\n * @property {Boolean} histogramBinBorderVisible - Display the lines that separate circular histogram bins\n * @property {Boolean} scaleBinToSectorArea - Should sector-based histogram bins'\n * area be proportional to the bins' value\n */\n\nexport interface DihedralHistogramRepresentationParameters extends StructureRepresentationParameters {\n histogramsData: HistogramInputData[]\n\n histogramBinBorderVisible: boolean\n scaleBinToSectorArea: boolean\n}\n\n/**\n * Dihedral Histogram representation object\n *\n * Reperesentation consists of several parts:\n * opaqueMiddleDisc - opaque disc in the middle of the dihedral between front and back histograms\n * frontHistogram - circular histogram from the adjacent bond viewpoint\n * backHistogram - circular histogram from the distant bond viewpoint\n * histogramBinBorder - lines, which separate histogram bins\n * bondArrows - lines, which show the actual angle on the histogram disc\n *\n * @param {Structure} structure - the structure to measure angles in\n * @param {Viewer} viewer - a viewer object\n * @param {DihedralHistogramRepresentationParameters} params - Dihedral histogram representation parameters\n */\nclass DihedralHistogramRepresentation extends StructureRepresentation {\n protected histogramsData: HistogramData[]\n\n protected histogramBinBorderVisible: boolean\n protected histogramBinBorderWidth: number\n protected histogramBinBorderColor: ColorDefinition\n protected histogramBinBorderOpacity: number\n\n protected bondArrowVisible: boolean\n protected bondArrowWidth: number\n protected bondArrowOpacity: number\n\n protected adjacentBondArrowColor: ColorDefinition\n protected distantBondArrowColor: ColorDefinition\n\n protected histogramOpacity: number\n protected frontHistogramColor: ColorDefinition\n protected backHistogramColor: ColorDefinition\n\n protected opaqueMiddleDiscVisible: boolean\n protected opaqueMiddleDiscColor: ColorDefinition\n protected opaqueMiddleDiscOpacity: number\n\n protected scaleBinToSectorArea: boolean\n\n constructor(structure: Structure, viewer: Viewer, params: DihedralHistogramRepresentationParameters) {\n super(structure, viewer, params)\n\n this.type = 'dihedral-histogram'\n\n this.parameters = Object.assign({\n histogramsData: {\n type: 'hidden', rebuild: true\n },\n histogramBinBorderVisible: {\n type: 'boolean', default: true\n },\n scaleBinToSectorArea: {\n type: 'boolean',\n rebuild: true,\n default: false\n }\n }, this.parameters)\n\n this.init(params)\n }\n\n init(params: Partial) {\n const p = params || {}\n\n const defaultColorData = {\n histogramBinBorderColor: 'grey',\n adjacentBondArrowColor: 'black',\n distantBondArrowColor: 'magenta',\n frontHistogramColor: 'green',\n backHistogramColor: 'blue',\n opaqueMiddleDiscColor: 'white'\n }\n\n const colorData = createUpdatedObject(defaultColorData, p)\n Object.assign(this, colorData)\n\n const defaultParameters = {\n histogramsData: [],\n histogramOpacity: 1.0,\n\n opaqueMiddleDiscVisible: true,\n opaqueMiddleDiscOpacity: 1.0,\n\n histogramBinBorderVisible: true,\n histogramBinBorderWidth: 1,\n histogramBinBorderOpacity: 0.5,\n\n bondArrowVisible: true,\n bondArrowWidth: 2,\n bondArrowOpacity: 1.0,\n\n scaleBinToSectorArea: false,\n }\n const parameters = createUpdatedObject(defaultParameters, p)\n Object.assign(this, parameters)\n\n this.histogramsData.forEach(x => {\n const specificColorData = createUpdatedObject(colorData, x)\n Object.assign(x, specificColorData)\n })\n\n p.side = defaults(p.side, 'double')\n p.opacity = defaults(p.opacity, 0.5)\n p.radiusType = defaults(p.radiusType, 'size')\n p.radiusSize = defaults(p.radiusSize, 0.15)\n\n super.init(p)\n }\n\n getHistogramBinBorderBufferParameters() {\n return this.getBufferParams({\n linewidth: this.histogramBinBorderWidth,\n visible: this.histogramBinBorderVisible,\n opacity: this.histogramBinBorderOpacity,\n })\n }\n\n getBondArrowsBufferParameters() {\n return this.getBufferParams({\n linewidth: this.bondArrowWidth,\n visible: this.bondArrowVisible,\n opacity: this.bondArrowOpacity,\n })\n }\n\n getOpaqueMiddleDiscBufferParameters() {\n return this.getBufferParams({\n visible: this.opaqueMiddleDiscVisible,\n opacity: this.opaqueMiddleDiscOpacity\n })\n }\n\n getHistogramBufferParameters() {\n return this.getBufferParams({\n visible: true,\n opacity: this.histogramOpacity,\n side: \"double\"\n })\n }\n\n createData(sview: StructureView) {\n if (!sview.atomCount || !this.histogramsData.length) return\n this.histogramsData.forEach(x => x.atomPositions = parseNestedAtoms(sview, [x.atomQuad]))\n const scaleData = this.scaleBinToSectorArea ? function (y: number) { return Math.sqrt(y) } : function (y: number) { return y }\n this.histogramsData.forEach(x => x.histogram360Scaled = x.histogram360.map(scaleData))\n function Float32Concat(arrays: Float32Array[]) {\n const lengths = arrays.map(x => x.length)\n const result = new Float32Array(arraySum(lengths))\n let accumulatedOffset = 0\n for (let i = 0; i < arrays.length; i++) {\n result.set(arrays[i], accumulatedOffset)\n accumulatedOffset += arrays[i].length\n }\n return result\n }\n\n function createWideLineBuffer(linesList: WideLineData[], params: {}) {\n return new WideLineBuffer(\n {\n position1: Float32Concat(linesList.map(x => x.startPoints)),\n position2: Float32Concat(linesList.map(x => x.endPoints)),\n color: Float32Concat(linesList.map(x => x.startColors)),\n color2: Float32Concat(linesList.map(x => x.endColors)),\n } as WideLineBufferData,\n params)\n }\n\n function createMeshBuffer(mesh: MeshData[], params: {}) {\n return new MeshBuffer(\n {\n position: Float32Concat(mesh.map(x => x.triangles)),\n color: Float32Concat(mesh.map(x => x.triangleColors))\n } as BufferData,\n params)\n }\n\n const dihedralDataArray = []\n\n for (let i = 0; i < this.histogramsData.length; i++) {\n let dihedralData = undefined\n let currentHistogramData = this.histogramsData[i]\n let currentHistogram360 = currentHistogramData.histogram360\n if (currentHistogram360.length >= 3) {\n dihedralData = calculateDihedralHistogram(currentHistogramData)\n }\n if (typeof dihedralData === \"undefined\") continue\n dihedralDataArray.push(dihedralData)\n }\n\n this.frontHistogramBinBordersBuffer = createWideLineBuffer(\n dihedralDataArray.map(x => x.frontHistogramBinBorders),\n this.getHistogramBinBorderBufferParameters()\n )\n\n this.backHistogramBinBordersBuffer = createWideLineBuffer(\n dihedralDataArray.map(x => x.backHistogramBinBorders),\n this.getHistogramBinBorderBufferParameters()\n )\n\n this.adjacentBondArrowsBuffer = createWideLineBuffer(\n dihedralDataArray.map(x => x.adjacentBondArrows),\n this.getBondArrowsBufferParameters()\n )\n\n this.distantBondArrowsBuffer = createWideLineBuffer(\n dihedralDataArray.map(x => x.distantBondArrows),\n this.getBondArrowsBufferParameters()\n )\n\n this.opaqueMiddleDiscBuffer = createMeshBuffer(\n dihedralDataArray.map(x => x.opaqueMiddleDisc),\n this.getOpaqueMiddleDiscBufferParameters()\n )\n\n this.frontHistogramBuffer = createMeshBuffer(\n dihedralDataArray.map(x => x.frontHistogram),\n this.getHistogramBufferParameters()\n )\n\n this.backHistogramBuffer = createMeshBuffer(\n dihedralDataArray.map(x => x.backHistogram),\n this.getHistogramBufferParameters()\n )\n\n return {\n bufferList: [].concat(\n this.frontHistogramBinBordersBuffer,\n this.backHistogramBinBordersBuffer,\n this.adjacentBondArrowsBuffer,\n this.distantBondArrowsBuffer,\n this.opaqueMiddleDiscBuffer,\n this.frontHistogramBuffer,\n this.backHistogramBuffer\n )\n }\n }\n\n setParameters(params: Partial) {\n const rebuild = false\n const what = {}\n super.setParameters(params, what, rebuild)\n\n if (params && (params.histogramBinBorderVisible !== undefined)) {\n this.setVisibility(this.visible)\n }\n return this\n }\n\n setVisibility(value: boolean, noRenderRequest?: boolean) {\n super.setVisibility(value, true)\n if (this.frontHistogramBinBordersBuffer) {\n this.frontHistogramBinBordersBuffer.setVisibility(this.histogramBinBorderVisible)\n }\n if (this.backHistogramBinBordersBuffer) {\n this.backHistogramBinBordersBuffer.setVisibility(this.histogramBinBorderVisible)\n }\n if (!noRenderRequest) this.viewer.requestRender()\n return this\n }\n}\n\n/**\n * Calculates the data required to create {Buffer} objects for one histogram, given positions\n * @param Float32Array positionOfDihedralAtoms 3*4 array of coordinates\n * @param NumberArray histogram array of coordinates\n * @return Arrays for building buffers\n */\nfunction calculateDihedralHistogram(histogramData: HistogramData) {\n const positionOfDihedralAtoms = histogramData.atomPositions\n const histogram = histogramData.histogram360Scaled;\n const totalSectorTrianglesInOpaqueMiddleDisc = histogram.length <= 180 ? 360 : histogram.length * 2\n const frontAndBack = 2\n\n const opaqueMiddleDisc = {\n triangles: new Float32Array(totalSectorTrianglesInOpaqueMiddleDisc * pointsInTriangle * pointLength),\n triangleColors: createColorArray(histogramData.opaqueMiddleDiscColor, totalSectorTrianglesInOpaqueMiddleDisc * pointsInTriangle)\n }\n\n const frontHistogram = {\n triangles: new Float32Array(histogram.length * pointsInTriangle * pointLength),\n triangleColors: createColorArray(histogramData.frontHistogramColor, histogram.length * pointsInTriangle)\n }\n\n const backHistogram = {\n triangles: new Float32Array(histogram.length * pointsInTriangle * pointLength),\n triangleColors: createColorArray(histogramData.backHistogramColor, histogram.length * pointsInTriangle)\n }\n\n const frontHistogramBinBorders = {\n startPoints: new Float32Array(histogram.length * pointLength),\n endPoints: new Float32Array(histogram.length * pointLength),\n startColors: createColorArray(histogramData.histogramBinBorderColor, histogram.length),\n endColors: createColorArray(histogramData.histogramBinBorderColor, histogram.length)\n }\n\n const backHistogramBinBorders = {\n startPoints: new Float32Array(histogram.length * pointLength),\n endPoints: new Float32Array(histogram.length * pointLength),\n startColors: createColorArray(histogramData.histogramBinBorderColor, histogram.length),\n endColors: createColorArray(histogramData.histogramBinBorderColor, histogram.length)\n }\n\n const adjacentBondArrows = {\n startPoints: new Float32Array(frontAndBack * pointLength),\n endPoints: new Float32Array(frontAndBack * pointLength),\n startColors: createColorArray(histogramData.adjacentBondArrowColor, histogram.length),\n endColors: createColorArray(histogramData.adjacentBondArrowColor, histogram.length)\n }\n const distantBondArrows = {\n startPoints: new Float32Array(frontAndBack * pointLength),\n endPoints: new Float32Array(frontAndBack * pointLength),\n startColors: createColorArray(histogramData.distantBondArrowColor, histogram.length),\n endColors: createColorArray(histogramData.distantBondArrowColor, histogram.length)\n }\n\n const p1 = v3new()\n const p2 = v3new()\n const p3 = v3new()\n const p4 = v3new()\n\n const v21 = v3new()\n const v23 = v3new()\n const v32 = v3new()\n const v34 = v3new()\n\n const mid = v3new()\n const inPlane1 = v3new()\n const inPlane2 = v3new()\n\n const cross1 = v3new()\n const cross2 = v3new()\n\n const arcPoint = v3new()\n const tmp = v3new()\n const tmp2 = v3new()\n\n // Set Atom Coordinates\n const dihedralAtomVectors = [p1, p2, p3, p4]\n\n for (let i = 0; i < dihedralAtomVectors.length; i++) {\n v3fromArray(dihedralAtomVectors[i], positionOfDihedralAtoms, i * pointLength)\n }\n\n // Vectors between points\n v3sub(v21, p1, p2)\n v3sub(v23, p3, p2)\n v3sub(v34, p4, p3)\n if (v3length(v23) === 0.0) {\n return // Can't define axis\n }\n\n v3multiplyScalar(tmp, v23, 0.5)\n v3add(mid, p2, tmp)\n\n v3normalize(v21, v21)\n v3normalize(v23, v23)\n v3normalize(v34, v34)\n\n v3negate(v32, v23)\n // Calculate vectors perp to v23 (lying in plane (1,2,3) and (2,3,4))\n v3multiplyScalar(tmp, v32, v3dot(v32, v21))\n v3sub(inPlane1, v21, tmp)\n\n v3multiplyScalar(tmp, v23, v3dot(v23, v34))\n v3sub(inPlane2, v34, tmp)\n\n if (v3length(inPlane1) === 0.0 || v3length(inPlane2) === 0.0) {\n return // Indeterminate angle\n }\n\n v3normalize(inPlane1, inPlane1)\n v3normalize(inPlane2, inPlane2)\n\n // Can use acos as normalized and non-zero\n const absAngle = Math.acos(v3dot(inPlane1, inPlane2))\n\n v3cross(cross1, v32, inPlane1)\n v3cross(cross2, v23, inPlane2)\n v3normalize(cross1, cross1)\n v3normalize(cross2, cross2)\n\n let angle = absAngle\n if (v3dot(cross1, inPlane2) < 0.0) {\n angle = -absAngle\n }\n\n v3add(arcPoint, mid, inPlane1)\n\n // Calculate necessary constants\n const maxHist = Math.max.apply(null, histogram)\n const histBinAngleStep = (Math.PI * 2) / histogram.length\n\n function setHistogramBinCoordinates(out: Float32Array, ind: number, zeroDegreeVector: Float32Array, crossVector: Float32Array, histBinAngleStep: number) {\n const startOffset = ind * pointsInTriangle * pointLength\n v3toArray(mid, out, startOffset)\n const scalingFactor = Number(histogram[ind]) / maxHist\n v3multiplyScalar(tmp, zeroDegreeVector, scalingFactor)\n v3multiplyScalar(tmp2, crossVector, scalingFactor)\n calcArcPoint(arcPoint, mid, tmp, tmp2, ind * histBinAngleStep)\n v3toArray(arcPoint, out, startOffset + 1 * pointLength)\n calcArcPoint(arcPoint, mid, tmp, tmp2, (ind + 1) * histBinAngleStep)\n v3toArray(arcPoint, out, startOffset + 2 * pointLength)\n }\n\n function setOneSideHistogram(discHistogram: MeshData, binBorders: { startPoints: Float32Array, endPoints: Float32Array }, ind: number, zeroDegreeVector: Float32Array, crossVector: Float32Array) {\n // Set Bond Arrows\n\n copyArray(mid, adjacentBondArrows.startPoints, 0, ind * pointLength, mid.length)\n calcArcPoint(tmp, mid, zeroDegreeVector, crossVector, 0 + histBinAngleStep * 0)\n copyArray(tmp, adjacentBondArrows.endPoints, 0, ind * pointLength, mid.length)\n\n copyArray(mid, distantBondArrows.startPoints, 0, ind * pointLength, mid.length)\n calcArcPoint(tmp, mid, zeroDegreeVector, crossVector, angle)\n copyArray(tmp, distantBondArrows.endPoints, 0, ind * pointLength, mid.length)\n\n // Set Histogram Bin Borders\n\n for (let i = 0; i < histogram.length; i++) {\n copyArray(mid, binBorders.startPoints, 0, i * 3, mid.length)\n calcArcPoint(tmp, mid, zeroDegreeVector, crossVector, 0 + histBinAngleStep * i)\n copyArray(tmp, binBorders.endPoints, 0, i * 3, tmp.length)\n }\n\n // Set Histogram Bins\n\n for (let sectionIndex = 0; sectionIndex < histogram.length; sectionIndex++) {\n setHistogramBinCoordinates(discHistogram.triangles, sectionIndex, zeroDegreeVector, crossVector, histBinAngleStep)\n }\n }\n\n // Opaque disc\n const opaqueCircleSectorAngleStep = Math.PI * 2 / totalSectorTrianglesInOpaqueMiddleDisc\n\n for (let sectionIndex = 0; sectionIndex < totalSectorTrianglesInOpaqueMiddleDisc; sectionIndex++) {\n const startOffset = sectionIndex * pointsInTriangle * pointLength\n v3toArray(mid, opaqueMiddleDisc.triangles, startOffset)\n calcArcPoint(arcPoint, mid, inPlane1, cross1, sectionIndex * opaqueCircleSectorAngleStep)\n v3toArray(arcPoint, opaqueMiddleDisc.triangles, startOffset + 1 * pointLength)\n calcArcPoint(arcPoint, mid, inPlane1, cross1, (sectionIndex + 1) * opaqueCircleSectorAngleStep)\n v3toArray(arcPoint, opaqueMiddleDisc.triangles, startOffset + 2 * pointLength)\n }\n\n // Front Histogram\n const distanceToOpaqueDisc = 0.01\n v3multiplyScalar(tmp, v23, -distanceToOpaqueDisc) // Get a vector to move \"mid\" just a bit from opaque disc\n v3add(mid, mid, tmp)\n setOneSideHistogram(frontHistogram, frontHistogramBinBorders, 0, inPlane1, cross1)\n\n // Back Histogram\n v3multiplyScalar(tmp, v23, 2 * distanceToOpaqueDisc) // Get a vector to move \"mid\" back and plus just a bit from opaque disc the other way\n v3add(mid, mid, tmp)\n setOneSideHistogram(backHistogram, backHistogramBinBorders, 1, inPlane2, cross2)\n\n return {\n opaqueMiddleDisc,\n frontHistogram,\n backHistogram,\n frontHistogramBinBorders,\n backHistogramBinBorders,\n adjacentBondArrows,\n distantBondArrows\n }\n}\n\nRepresentationRegistry.add('dihedral-histogram', DihedralHistogramRepresentation)\n\nexport default DihedralHistogramRepresentation\n","/**\n * @file Distance Representation\n * @author Alexander Rose \n * @author Fred Ludlow \n * @private\n */\n\nimport { Color } from 'three'\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { DistancePicker } from '../utils/picker'\nimport { uniformArray, uniformArray3 } from '../math/array-utils'\nimport BitArray from '../utils/bitarray'\nimport MeasurementRepresentation, { MeasurementRepresentationParameters } from './measurement-representation'\nimport Selection from '../selection/selection'\nimport BondStore from '../store/bond-store'\nimport TextBuffer, { TextBufferData, TextBufferParameters } from '../buffer/text-buffer'\nimport WideLineBuffer from '../buffer/wideline-buffer'\nimport CylinderBuffer, { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport { getFixedLengthDashData } from '../geometry/dash'\nimport Viewer from '../viewer/viewer';\nimport { Structure } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport { BondDataFields, BondDataParams, BondData } from '../structure/structure-data';\nimport { StructureRepresentationData } from './structure-representation';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\n\n/**\n * Distance representation parameter object.\n * @typedef {Object} DistanceRepresentationParameters - distance representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n * @mixes MeasurementRepresentationParameters\n *\n * @property {String} labelUnit - distance unit (e.g. \"angstrom\" or \"nm\"). If set, a distance\n * symbol is appended to the label (i.e. 'nm' or '\\u00C5'). In case of 'nm', the\n * distance value is computed in nanometers instead of Angstroms.\n * @property {Array[]} atomPair - list of pairs of selection strings (see {@link Selection})\n * or pairs of atom indices. Using atom indices is much more\n * efficient when the representation is updated often, e.g. by\n * changing the selection or the atom positions, as there\n * are no selection strings to be evaluated.\n */\nexport interface DistanceRepresentationParameters extends MeasurementRepresentationParameters {\n labelUnit: string\n atomPair: AtomPair\n useCylinder: boolean\n}\nexport type AtomPair = (number|string)[][]\n/**\n * Distance representation\n */\nclass DistanceRepresentation extends MeasurementRepresentation {\n protected labelUnit: string\n protected atomPair: AtomPair\n protected useCylinder: boolean\n protected distanceBuffer: WideLineBuffer|CylinderGeometryBuffer\n /**\n * Create Distance representation object\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\" );\n * // either give selections (uses first selected atom) ...\n * var atomPair = [ [ \"1.CA\", \"4.CA\" ], [ \"7.CA\", \"13.CA\" ] ];\n * // or atom indices\n * var atomPair = [ [ 8, 28 ], [ 173, 121 ] ];\n * o.addRepresentation( \"distance\", { atomPair: atomPair } );\n * stage.autoView();\n * } );\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {DistanceRepresentationParameters} params - distance representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'distance'\n\n this.parameters = Object.assign({\n radialSegments: true,\n openEnded: true,\n disableImpostor: true,\n labelUnit: {\n type: 'select',\n rebuild: true,\n options: { '': '', angstrom: 'angstrom', nm: 'nm' }\n },\n useCylinder: {\n type: 'boolean', rebuild: true\n },\n atomPair: {\n type: 'hidden', rebuild: true\n }\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.linewidth = defaults(p.linewidth, 5.0)\n p.radiusType = defaults(p.radiusType, 'size')\n p.radiusSize = defaults(p.radiusSize, 0.2)\n\n this.labelUnit = defaults(p.labelUnit, '')\n this.useCylinder = defaults(p.useCylinder, false)\n this.atomPair = defaults(p.atomPair, [])\n\n super.init(p)\n }\n\n getDistanceData (sview: StructureView, atomPair: AtomPair) {\n let n = atomPair.length\n const text = new Array(n)\n let position = new Float32Array(n * 3)\n const sele1 = new Selection()\n const sele2 = new Selection()\n\n const bondStore = new BondStore()\n\n const ap1 = sview.getAtomProxy()\n const ap2 = sview.getAtomProxy()\n\n let j = 0 // Skipped pairs\n const selected = sview.getAtomSet()\n\n atomPair.forEach((pair, i) => {\n let v1 = pair[ 0 ]\n let v2 = pair[ 1 ]\n\n if (typeof(v1) === 'number' && Number.isInteger(v1) && typeof(v2) === 'number' && Number.isInteger(v2)) {\n if (selected.get(v1) && selected.get(v2)) {\n ap1.index = v1\n ap2.index = v2\n } else {\n j += 1\n return\n }\n } else {\n sele1.setString(v1 as string)\n sele2.setString(v2 as string)\n\n var atomIndices1 = sview.getAtomIndices(sele1)\n var atomIndices2 = sview.getAtomIndices(sele2)\n\n if (atomIndices1!.length && atomIndices2!.length) {\n ap1.index = atomIndices1![ 0 ]\n ap2.index = atomIndices2![ 0 ]\n } else {\n j += 1\n return\n }\n }\n\n bondStore.addBond(ap1, ap2, 1)\n\n i -= j\n var d = ap1.distanceTo(ap2)\n switch (this.labelUnit) {\n case 'angstrom':\n text[ i ] = d.toFixed(2) + ' ' + String.fromCharCode(0x212B)\n break\n case 'nm':\n text[ i ] = (d / 10).toFixed(2) + ' nm'\n break\n default:\n text[ i ] = d.toFixed(2)\n break\n }\n\n var i3 = i * 3\n position[ i3 + 0 ] = (ap1.x + ap2.x) / 2\n position[ i3 + 1 ] = (ap1.y + ap2.y) / 2\n position[ i3 + 2 ] = (ap1.z + ap2.z) / 2\n })\n\n if (j > 0) {\n n -= j\n position = position.subarray(0, n * 3)\n }\n\n var bondSet = new BitArray(bondStore.count, true)\n\n return {\n text: text,\n position: position,\n bondSet: bondSet,\n bondStore: bondStore\n }\n }\n\n getBondData (sview: StructureView, what: BondDataFields, params: BondDataParams): BondData {\n const bondData = sview.getBondData(this.getBondParams(what, params))\n if (bondData.picking) {\n bondData.picking = new DistancePicker(\n bondData.picking.array,\n bondData.picking.structure,\n params.bondStore!\n ) as any\n }\n return bondData\n }\n\n createData (sview: StructureView) {\n if (!sview.atomCount || !this.atomPair.length) return\n\n const n = this.atomPair.length\n const c = new Color(this.labelColor)\n const distanceData = this.getDistanceData(sview, this.atomPair)\n\n this.textBuffer = new TextBuffer({\n position: distanceData.position,\n size: uniformArray(n, this.labelSize),\n color: uniformArray3(n, c.r, c.g, c.b),\n text: distanceData.text\n } as TextBufferData, this.getLabelBufferParams() as TextBufferParameters)\n\n const bondParams = {\n bondSet: distanceData.bondSet,\n bondStore: distanceData.bondStore\n }\n\n const bondData = this.getBondData(\n sview,\n { position: true, color: true, picking: true, radius: this.useCylinder },\n bondParams\n )\n\n if (this.useCylinder) {\n this.distanceBuffer = new CylinderBuffer(\n bondData as CylinderBufferData,\n this.getBufferParams({\n openEnded: this.openEnded,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) \n ) as CylinderGeometryBuffer\n } else {\n this.distanceBuffer = new WideLineBuffer(\n getFixedLengthDashData(bondData as CylinderBufferData),\n this.getBufferParams({\n linewidth: this.linewidth,\n visible: this.lineVisible,\n opacity: this.lineOpacity\n })\n )\n }\n\n return {\n bondSet: distanceData.bondSet,\n bondStore: distanceData.bondStore,\n position: distanceData.position,\n bufferList: [ this.textBuffer, this.distanceBuffer ]\n }\n }\n\n updateData (what: BondDataFields, data: StructureRepresentationData) {\n super.updateData(what, data)\n\n const bondParams = {\n bondSet: data.bondSet,\n bondStore: data.bondStore\n }\n\n const bondData = this.getBondData(data.sview as StructureView, what, bondParams)\n const distanceData = {}\n\n if (!what || what.color) {\n Object.assign( distanceData, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n if (!what || what.radius) {\n Object.assign( distanceData, {radius: bondData.radius})\n }\n\n (this.distanceBuffer as CylinderGeometryBuffer).setAttributes(distanceData)\n }\n\n setParameters (params: Partial) {\n let rebuild = false\n const what = {}\n\n super.setParameters(params, what, rebuild)\n\n if (!this.useCylinder) {\n if (params && params.lineOpacity) {\n (this.distanceBuffer as WideLineBuffer).setParameters({ opacity: params.lineOpacity })\n }\n if (params && params.opacity !== undefined) {\n (this.distanceBuffer as WideLineBuffer).setParameters({ opacity: this.lineOpacity })\n }\n if (params && params.linewidth) {\n (this.distanceBuffer as WideLineBuffer).setParameters({ linewidth: params.linewidth })\n }\n }\n\n return this\n }\n}\n\nRepresentationRegistry.add('distance', DistanceRepresentation)\n\nexport default DistanceRepresentation\n","/**\n * @file Vector Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { Color, Matrix4, Vector3 } from 'three'\n\nimport '../shader/Line.vert'\nimport '../shader/Line.frag'\n\nimport { uniformArray3 } from '../math/array-utils'\nimport Buffer, { BufferDefaultParameters, BufferData, BufferParameters } from './buffer'\nimport { GenericColor } from '../types'\n\nfunction getSize(data: BufferData){\n const n = data.position!.length / 3\n return n * 2 * 3\n}\n\nexport interface VectorBufferData extends BufferData {\n vector: Float32Array\n}\n\nexport const VectorBufferDefaultParameters = Object.assign({\n scale: 1,\n color: 'grey'\n}, BufferDefaultParameters)\nexport type VectorBufferParameters = BufferParameters & { scale: number, color: GenericColor }\n\n/**\n * Vector buffer. Draws vectors as lines.\n */\nclass VectorBuffer extends Buffer {\n get defaultParameters() { return VectorBufferDefaultParameters }\n parameters: VectorBufferParameters\n\n isLine = true\n vertexShader = 'Line.vert'\n fragmentShader = 'Line.frag'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.vector - vectors\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: VectorBufferData, params: Partial = {}) {\n super({\n position: new Float32Array(getSize(data)),\n color: new Float32Array(getSize(data))\n }, params)\n\n const color = new Color(this.parameters.color)\n const attributes = this.geometry.attributes as any // TODO\n uniformArray3(getSize(data) / 3, color.r, color.g, color.b, attributes.color.array)\n\n this.setAttributes(data)\n }\n\n setAttributes (data: Partial = {}) {\n const attributes = this.geometry.attributes as any // TODO\n\n let position, vector\n let aPosition\n\n if (data.position && data.vector) {\n position = data.position\n vector = data.vector\n aPosition = attributes.position.array\n attributes.position.needsUpdate = true\n }\n\n const n = this.size / 2\n const scale = this.parameters.scale\n\n if (position && vector) {\n for (let v = 0; v < n; v++) {\n const i = v * 2 * 3\n const j = v * 3\n\n aPosition[ i + 0 ] = position[ j + 0 ]\n aPosition[ i + 1 ] = position[ j + 1 ]\n aPosition[ i + 2 ] = position[ j + 2 ]\n aPosition[ i + 3 ] = position[ j + 0 ] + vector[ j + 0 ] * scale\n aPosition[ i + 4 ] = position[ j + 1 ] + vector[ j + 1 ] * scale\n aPosition[ i + 5 ] = position[ j + 2 ] + vector[ j + 2 ] * scale\n }\n }\n }\n}\n\nexport default VectorBuffer\n","/**\n * @file Helixorient Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Helixorient from '../geometry/helixorient'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferParameters } from '../buffer/sphere-buffer'\nimport VectorBuffer from '../buffer/vector-buffer'\nimport Viewer from '../viewer/viewer';\nimport { Structure } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport Polymer from '../proxy/polymer';\nimport { AtomDataFields } from '../structure/structure-data';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\nimport SphereImpostorBuffer from '../buffer/sphereimpostor-buffer';\nimport { BufferData } from '../buffer/buffer';\n\n/**\n * Helixorient Representation\n */\nclass HelixorientRepresentation extends StructureRepresentation {\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'helixorient'\n\n this.parameters = Object.assign({\n sphereDetail: true,\n disableImpostor: true\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'sstruc')\n p.radiusType = defaults(p.radiusType, 'size')\n p.radiusSize = defaults(p.radiusSize, 0.15)\n p.radiusScale = defaults(p.radiusScale, 1.0)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n const bufferList: (SphereBuffer|VectorBuffer)[] = []\n const polymerList: Polymer[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4) return\n polymerList.push(polymer)\n\n const helixorient = new Helixorient(polymer)\n const position = helixorient.getPosition()\n const color = helixorient.getColor(this.getColorParams())\n const size = helixorient.getSize(this.getRadiusParams())\n const picking = helixorient.getPicking()\n\n bufferList.push(\n new SphereBuffer(\n {\n position: position.center,\n color: color.color,\n radius: size.size,\n picking: picking.picking\n },\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters\n ),\n new VectorBuffer(\n {\n position: position.center,\n vector: position.axis\n },\n this.getBufferParams({\n color: 'skyblue',\n scale: 1\n })\n ),\n new VectorBuffer(\n {\n position: position.center,\n vector: position.resdir\n },\n this.getBufferParams({\n color: 'lightgreen',\n scale: 1\n })\n )\n )\n }, sview.getSelection())\n\n return {\n bufferList: bufferList as (SphereGeometryBuffer|SphereImpostorBuffer|VectorBuffer)[],\n polymerList: polymerList\n }\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n if (Debug) Log.time(this.type + ' repr update')\n\n what = what || {}\n\n for (let i = 0, il = data.polymerList!.length; i < il; ++i) {\n const j = i * 3\n\n const bufferData: Partial = {}\n const polymer = data.polymerList![ i ]\n const helixorient = new Helixorient(polymer)\n\n if (what.position) {\n const position = helixorient.getPosition()\n\n Object.assign(bufferData, {position: position.center})\n\n data.bufferList[ j + 1 ].setAttributes({\n 'position': position.center,\n 'vector': position.axis\n })\n data.bufferList[ j + 2 ].setAttributes({\n 'position': position.center,\n 'vector': position.resdir\n })\n }\n\n data.bufferList[ j ].setAttributes(bufferData)\n }\n\n if (Debug) Log.timeEnd(this.type + ' repr update')\n }\n}\n\nRepresentationRegistry.add('helixorient', HelixorientRepresentation)\n\nexport default HelixorientRepresentation\n","/**\n * @file Licorice Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport BallAndStickRepresentation, { BallAndStickRepresentationParameters } from './ballandstick-representation'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\n\n/**\n * Licorice representation object ({@link BallAndStickRepresentation} with `aspectRatio` fixed at 1.0)\n */\nclass LicoriceRepresentation extends BallAndStickRepresentation {\n /**\n * Create Licorice representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {BallAndStickRepresentationParameters} params - ball and stick representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'licorice'\n\n this.parameters = Object.assign(\n {}, this.parameters, { aspectRatio: null }\n )\n }\n\n init (params: Partial) {\n var p = params || {}\n p.aspectRatio = 1.0\n\n super.init(p)\n }\n}\n\nRepresentationRegistry.add('licorice', LicoriceRepresentation)\n\nexport default LicoriceRepresentation\n","/**\n * @file Mapped Box Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { BufferParameters, BufferData } from './buffer'\nimport MappedBuffer from './mapped-buffer'\n\nconst mapping = new Float32Array([\n -1.0, -1.0, -1.0,\n 1.0, -1.0, -1.0,\n 1.0, -1.0, 1.0,\n -1.0, -1.0, 1.0,\n -1.0, 1.0, -1.0,\n 1.0, 1.0, -1.0,\n 1.0, 1.0, 1.0,\n -1.0, 1.0, 1.0\n])\n\nconst mappingIndices = new Uint16Array([\n 0, 1, 2,\n 0, 2, 3,\n 1, 5, 6,\n 1, 6, 2,\n 4, 6, 5,\n 4, 7, 6,\n 0, 7, 4,\n 0, 3, 7,\n 0, 5, 1,\n 0, 4, 5,\n 3, 2, 6,\n 3, 6, 7\n])\n\n/**\n * Mapped Box buffer. Draws boxes. Used to render general imposters.\n * @interface\n */\nclass MappedBoxBuffer extends MappedBuffer {\n constructor(data: BufferData, params: Partial = {}) {\n super('v3', data, params)\n }\n get mapping () { return mapping }\n get mappingIndices () { return mappingIndices }\n get mappingIndicesSize () { return 36 }\n get mappingSize () { return 8 }\n get mappingItemSize () { return 3 }\n}\n\nexport default MappedBoxBuffer\n","/**\n * @file Hyperball Stick Impostor Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3 required for declaration only\nimport { Matrix4, Vector3 } from 'three'\n\nimport '../shader/HyperballStickImpostor.vert'\nimport '../shader/HyperballStickImpostor.frag'\n\nimport MappedBoxBuffer from './mappedbox-buffer'\nimport { BufferDefaultParameters, BufferParameterTypes, BufferData, BufferParameters } from './buffer'\n\nexport interface HyperballStickImpostorBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n color2: Float32Array\n radius: Float32Array\n radius2: Float32Array\n}\n\nexport const HyperballStickImpostorBufferDefaultParameters = Object.assign({\n shrink: 0.14\n}, BufferDefaultParameters)\nexport type HyperballStickImpostorBufferParameters = BufferParameters & { shrink: number }\n\nconst HyperballStickImpostorBufferParameterTypes = Object.assign({\n shrink: { uniform: true }\n}, BufferParameterTypes)\n\n/**\n * Hyperball stick impostor buffer.\n *\n * @example\n * var hyperballStickImpostorBuffer = new HyperballStickImpostorBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 2, 2, 2 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ]),\n * radius2: new Float32Array([ 2 ])\n * });\n */\nclass HyperballStickImpostorBuffer extends MappedBoxBuffer {\n parameterTypes = HyperballStickImpostorBufferParameterTypes\n get defaultParameters() { return HyperballStickImpostorBufferDefaultParameters }\n parameters: HyperballStickImpostorBufferParameters\n\n isImpostor = true\n vertexShader = 'HyperballStickImpostor.vert'\n fragmentShader = 'HyperballStickImpostor.frag'\n\n constructor (data: HyperballStickImpostorBufferData, params: Partial = {}) {\n super(data, params)\n\n this.addUniforms({\n 'modelViewProjectionMatrix': { value: new Matrix4() },\n 'modelViewProjectionMatrixInverse': { value: new Matrix4() },\n 'modelViewMatrixInverseTranspose': { value: new Matrix4() },\n 'shrink': { value: this.parameters.shrink }\n })\n\n this.addAttributes({\n 'position1': { type: 'v3', value: null },\n 'position2': { type: 'v3', value: null },\n 'color2': { type: 'c', value: null },\n 'radius': { type: 'f', value: null },\n 'radius2': { type: 'f', value: null }\n })\n\n this.setAttributes(data)\n this.makeMapping()\n }\n}\n\nexport default HyperballStickImpostorBuffer\n","/**\n * @file Hyperball Stick Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import required for declaration only\nimport { Vector3, Matrix4 } from 'three'\nimport { ExtensionFragDepth } from '../globals'\nimport { calculateMinArray } from '../math/array-utils'\nimport CylinderGeometryBuffer, { CylinderGeometryBufferDefaultParameters, CylinderGeometryBufferParameters } from './cylindergeometry-buffer'\nimport HyperballStickImpostorBuffer, { HyperballStickImpostorBufferDefaultParameters, HyperballStickImpostorBufferParameters } from './hyperballstickimpostor-buffer'\nimport { BufferData } from './buffer'\n\nexport interface HyperballStickBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n color2: Float32Array\n radius: Float32Array\n radius2: Float32Array\n}\n\nexport const HyperballStickBufferDefaultParameters = Object.assign({\n disableImpostor: false\n}, CylinderGeometryBufferDefaultParameters, HyperballStickImpostorBufferDefaultParameters)\nexport type HyperballStickBufferParameters = HyperballStickImpostorBufferParameters & CylinderGeometryBufferParameters & { disableImpostor: boolean }\n\nclass HyperballStickBufferImpl {\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - from colors\n * @param {Float32Array} data.color2 - to colors\n * @param {Float32Array} data.radius - from radii\n * @param {Float32Array} data.radius2 - to radii\n * @param {Float32Array} data.picking - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: HyperballStickBufferData, params: Partial = {}) {\n if (!ExtensionFragDepth || (params && params.disableImpostor)) {\n data.radius = calculateMinArray(data.radius, data.radius2)\n return new CylinderGeometryBuffer(data, params)\n } else {\n return new HyperballStickImpostorBuffer(data, params)\n }\n }\n}\n\n/**\n * Hyperball stick buffer. Depending on the value {@link ExtensionFragDepth} and\n * `params.disableImpostor` the constructor returns either a\n * {@link CylinderGeometryBuffer} or a {@link HyperballStickImpostorBuffer}\n * @implements {Buffer}\n *\n * @example\n * var hyperballStickBuffer = new HyperballStickBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 2, 2, 2 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ]),\n * radius2: new Float32Array([ 2 ])\n * });\n */\n//@ts-expect-error Incompatible constructor signatures\nconst HyperballStickBuffer: {\n new(data: HyperballStickBufferData, params: Partial): CylinderGeometryBuffer | HyperballStickImpostorBuffer;\n} = HyperballStickBufferImpl;\n\ntype HyperballStickBuffer = CylinderGeometryBuffer | HyperballStickImpostorBuffer;\n\nexport default HyperballStickBuffer\n","/**\n * @file Hyperball Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { calculateCenterArray } from '../math/array-utils'\nimport LicoriceRepresentation from './licorice-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport HyperballStickBuffer, { HyperballStickBufferData } from '../buffer/hyperballstick-buffer'\nimport { BallAndStickRepresentationParameters } from './ballandstick-representation';\n// @ts-ignore: unused import Volume required for declaration only\nimport { Structure, Volume } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport { BondDataParams, BondDataFields, AtomDataFields } from '../structure/structure-data';\nimport StructureView from '../structure/structure-view';\nimport { StructureRepresentationData } from './structure-representation';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\n// @ts-ignore: unused import Surface required for declaration only\nimport Surface from '../surface/surface';\n\nexport interface HyperballRepresentationParameters extends BallAndStickRepresentationParameters {\n shrink: number\n}\n\n/**\n * Hyperball Representation\n */\nclass HyperballRepresentation extends LicoriceRepresentation {\n protected shrink: number\n protected __center: Float32Array\n \n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'hyperball'\n\n this.parameters = Object.assign({\n\n shrink: {\n type: 'number', precision: 3, max: 1.0, min: 0.001, buffer: true\n }\n\n }, this.parameters, {\n\n multipleBond: null,\n bondSpacing: null\n\n })\n }\n\n init (params: Partial) {\n var p = params || {}\n p.radiusScale = defaults(p.radiusScale, 0.2)\n p.radiusType = defaults(p.radiusType, 'vdw')\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.shrink = defaults(p.shrink, 0.12)\n\n super.init(p)\n }\n\n getBondParams (what?: BondDataFields, params?: BondDataParams) {\n if (!what || what.radius) {\n params = Object.assign({ radius2: true }, params)\n }\n\n return super.getBondParams(what, params)\n }\n\n createData (sview: StructureView) {\n var sphereBuffer = new SphereBuffer(\n (sview.getAtomData(this.getAtomParams()) as SphereBufferData),\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters\n ) as SphereGeometryBuffer\n\n this.__center = new Float32Array(sview.bondCount * 3)\n\n var stickBuffer = new HyperballStickBuffer(\n sview.getBondData(this.getBondParams()) as HyperballStickBufferData,\n this.getBufferParams({\n shrink: this.shrink,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n return {\n bufferList: [ sphereBuffer, stickBuffer ]\n }\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n var atomData = data.sview!.getAtomData(this.getAtomParams())\n var bondData = data.sview!.getBondData(this.getBondParams())\n var sphereData = {}\n var stickData = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {position: atomData.position})\n var from = bondData.position1\n var to = bondData.position2\n Object.assign(stickData, {\n position: calculateCenterArray(from!, to!, this.__center),\n position1: from,\n position2: to\n })\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {color: atomData.color})\n Object.assign(stickData, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {radius: atomData.radius})\n Object.assign(stickData, {\n radius: bondData.radius,\n radius2: bondData.radius2\n })\n }\n\n data.bufferList[ 0 ].setAttributes(sphereData)\n data.bufferList[ 1 ].setAttributes(stickData)\n }\n}\n\nRepresentationRegistry.add('hyperball', HyperballRepresentation)\n\nexport default HyperballRepresentation\n","/**\n * @file Label Factory\n * @author Alexander Rose \n * @private\n */\n\nimport { AA1 } from '../structure/structure-constants'\nimport AtomProxy from '../proxy/atom-proxy'\nimport { sprintf } from 'sprintf-js'\n\nexport const LabelFactoryTypes = {\n '': '',\n 'atomname': 'atom name',\n 'atomindex': 'atom index',\n 'occupancy': 'occupancy',\n 'bfactor': 'b-factor',\n 'serial': 'serial',\n 'element': 'element',\n 'atom': 'atom name + index',\n 'resname': 'residue name',\n 'resno': 'residue no',\n 'res': 'one letter code + no',\n 'residue': '[residue name] + no + inscode',\n 'text': 'text',\n 'format': 'format',\n 'qualified': 'qualified name'\n}\nexport type LabelType = keyof typeof LabelFactoryTypes\n\nclass LabelFactory {\n\n static types = LabelFactoryTypes\n errorLogged: boolean = false\n\n constructor(readonly type: LabelType, readonly text: { [k: number]: string } = {},\n readonly format: string = '') {}\n\n atomLabel (a: AtomProxy) {\n const type = this.type\n\n let l\n\n switch (type) {\n case 'atomname':\n l = a.atomname\n break\n\n case 'atomindex':\n l = `${a.index}`\n break\n\n case 'occupancy':\n l = a.occupancy.toFixed(2)\n break\n\n case 'bfactor':\n l = a.bfactor.toFixed(2)\n break\n\n case 'serial':\n l = `${a.serial}`\n break\n\n case 'element':\n l = a.element\n break\n\n case 'atom':\n l = `${a.atomname}|${a.index}`\n break\n\n case 'resname':\n l = a.resname\n break\n\n case 'resno':\n l = `${a.resno}`\n break\n\n case 'res':\n l = `${(AA1[ a.resname.toUpperCase() ] || a.resname)}${a.resno}`\n break\n\n case 'residue':\n const aa1 = AA1[ a.resname.toUpperCase() ]\n if (aa1 && !a.inscode) {\n l = `${aa1}${a.resno}`\n } else {\n l = `[${a.resname}]${a.resno}${a.inscode}`\n }\n break\n\n case 'text':\n l = this.text[ a.index ]\n break\n\n case 'format':\n try {\n l = sprintf(this.format, a)\n } catch (e) {\n if (!this.errorLogged) {\n this.errorLogged = true\n console.log(e.message)\n }\n }\n break\n\n // case \"qualified\":\n default:\n l = a.qualifiedName()\n break\n }\n\n return l === undefined ? '' : l\n }\n}\n\nexport default LabelFactory\n","/**\n * @file Label Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry, ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport LabelFactory, { LabelType } from '../utils/label-factory'\nimport RadiusFactory from '../utils/radius-factory'\nimport StructureRepresentation, { StructureRepresentationData } from './structure-representation'\nimport TextBuffer, { TextBufferData } from '../buffer/text-buffer'\nimport { RepresentationParameters } from './representation';\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { GenericColor } from '../types'\n\nexport interface TextDataField {\n position?: boolean\n color?: boolean\n radius?: boolean\n text?: boolean\n}\n\n/**\n * Label representation parameter object. Extends {@link RepresentationParameters} and\n * {@link StructureRepresentationParameters}.\n *\n * @typedef {Object} LabelRepresentationParameters - label representation parameters\n *\n * @property {Integer} clipNear - position of camera near/front clipping plane\n * in percent of scene bounding box\n * @property {Float} opacity - translucency: 1 is fully opaque, 0 is fully transparent\n * @property {String} labelType - type of the label, one of:\n * \"atomname\", \"atomindex\", \"occupancy\", \"bfactor\",\n * \"serial\", \"element\", \"atom\", \"resname\", \"resno\",\n * \"res\", \"text\", \"qualified\". When set to \"text\", the\n * `labelText` list is used.\n * @property {String[]} labelText - list of label strings, must set `labelType` to \"text\"\n * to take effect\n * @property {String} labelFormat - sprintf-js format string, any attribute of\n * {@link AtomProxy} can be used\n * @property {String} labelGrouping - grouping of the label, one of:\n * \"atom\", \"residue\".\n * @property {String} fontFamily - font family, one of: \"sans-serif\", \"monospace\", \"serif\"\n * @property {String} fontStyle - font style, \"normal\" or \"italic\"\n * @property {String} fontWeight - font weight, \"normal\" or \"bold\"\n * @property {Float} xOffset - offset in x-direction\n * @property {Float} yOffset - offset in y-direction\n * @property {Float} zOffset - offset in z-direction (i.e. in camera direction)\n * @property {String} attachment - attachment of the label, one of:\n * \"bottom-left\", \"bottom-center\", \"bottom-right\",\n * \"middle-left\", \"middle-center\", \"middle-right\",\n * \"top-left\", \"top-center\", \"top-right\"\n * @property {Boolean} showBorder - show border/outline\n * @property {Color} borderColor - color of the border/outline\n * @property {Float} borderWidth - width of the border/outline\n * @property {Boolean} showBackground - show background rectangle\n * @property {Color} backgroundColor - color of the background\n * @property {Float} backgroundMargin - width of the background\n * @property {Float} backgroundOpacity - opacity of the background\n * @property {Boolean} fixedSize - show text with a fixed pixel size\n */\nexport interface LabelRepresentationParameters extends RepresentationParameters {\n labelType: LabelType\n labelText: string[]\n labelFormat: string\n labelGrouping: 'atom'|'residue'\n fontFamily: 'sans-serif'|'monospace'|'serif'\n fontStyle: 'normal'|'italic'\n fontWeight: 'normal'|'bold'\n xOffset: number\n yOffset: number\n zOffset: number\n attachment: 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n showBorder: boolean\n borderColor: GenericColor\n borderWidth: number\n showBackground: boolean\n backgroundColor: GenericColor\n backgroundMargin: number\n backgroundOpacity: number\n fixedSize: boolean\n}\n/**\n * Label representation\n */\nclass LabelRepresentation extends StructureRepresentation {\n\n protected labelType: LabelType\n protected labelText: string[]\n protected labelFormat: string\n protected labelGrouping: 'atom'|'residue'\n protected fontFamily: 'sans-serif'|'monospace'|'serif'\n protected fontStyle: 'normal'|'italic'\n protected fontWeight: 'normal'|'bold'\n protected xOffset: number\n protected yOffset: number\n protected zOffset: number\n protected attachment: 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n protected showBorder: boolean\n protected borderColor: GenericColor\n protected borderWidth: number\n protected showBackground: boolean\n protected backgroundColor: GenericColor\n protected backgroundMargin: number\n protected backgroundOpacity: number\n protected fixedSize: boolean\n\n /**\n * Create Label representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {LabelRepresentationParameters} params - label representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'label'\n\n this.parameters = Object.assign({\n\n labelType: {\n type: 'select', options: LabelFactory.types, rebuild: true\n },\n labelText: {\n type: 'hidden', rebuild: true\n },\n labelFormat: {\n type: 'text', rebuild: true\n },\n labelGrouping: {\n type: 'select',\n options: {\n 'atom': 'atom',\n 'residue': 'residue'\n },\n rebuild: true\n },\n fontFamily: {\n type: 'select',\n options: {\n 'sans-serif': 'sans-serif',\n 'monospace': 'monospace',\n 'serif': 'serif'\n },\n buffer: true\n },\n fontStyle: {\n type: 'select',\n options: {\n 'normal': 'normal',\n 'italic': 'italic'\n },\n buffer: true\n },\n fontWeight: {\n type: 'select',\n options: {\n 'normal': 'normal',\n 'bold': 'bold'\n },\n buffer: true\n },\n xOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: true\n },\n yOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: true\n },\n zOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: true\n },\n attachment: {\n type: 'select',\n options: {\n 'bottom-left': 'bottom-left',\n 'bottom-center': 'bottom-center',\n 'bottom-right': 'bottom-right',\n 'middle-left': 'middle-left',\n 'middle-center': 'middle-center',\n 'middle-right': 'middle-right',\n 'top-left': 'top-left',\n 'top-center': 'top-center',\n 'top-right': 'top-right'\n },\n rebuild: true\n },\n showBorder: {\n type: 'boolean', buffer: true\n },\n borderColor: {\n type: 'color', buffer: true\n },\n borderWidth: {\n type: 'number', precision: 2, max: 0.3, min: 0, buffer: true\n },\n showBackground: {\n type: 'boolean', rebuild: true\n },\n backgroundColor: {\n type: 'color', buffer: true\n },\n backgroundMargin: {\n type: 'number', precision: 2, max: 2, min: 0, rebuild: true\n },\n backgroundOpacity: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n fixedSize: {\n type: 'boolean', buffer: true\n }\n\n }, this.parameters, {\n\n side: null,\n flatShaded: null,\n wireframe: null,\n linewidth: null,\n\n roughness: null,\n metalness: null,\n diffuse: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n\n this.labelType = defaults(p.labelType, 'res')\n this.labelText = defaults(p.labelText, {})\n this.labelFormat = defaults(p.labelFormat, '')\n this.labelGrouping = defaults(p.labelGrouping, 'atom')\n this.fontFamily = defaults(p.fontFamily, 'sans-serif')\n this.fontStyle = defaults(p.fontStyle, 'normal')\n this.fontWeight = defaults(p.fontWeight, 'bold')\n this.xOffset = defaults(p.xOffset, 0.0)\n this.yOffset = defaults(p.yOffset, 0.0)\n this.zOffset = defaults(p.zOffset, 0.5)\n this.attachment = defaults(p.attachment, 'bottom-left')\n this.showBorder = defaults(p.showBorder, false)\n this.borderColor = defaults(p.borderColor, 'lightgrey')\n this.borderWidth = defaults(p.borderWidth, 0.15)\n this.showBackground = defaults(p.showBackground, false)\n this.backgroundColor = defaults(p.backgroundColor, 'lightgrey')\n this.backgroundMargin = defaults(p.backgroundMargin, 0.5)\n this.backgroundOpacity = defaults(p.backgroundOpacity, 1.0)\n this.fixedSize = defaults(p.fixedSize, false)\n\n super.init(p)\n }\n\n getTextData (sview: StructureView, what?: TextDataField) {\n const p = this.getAtomParams(what)\n const labelFactory = new LabelFactory(this.labelType, this.labelText, this.labelFormat)\n let position: Float32Array, size: Float32Array, color: Float32Array, text: string[],\n positionN: number[], sizeN: number[], colorN: number[]\n if (this.labelGrouping === 'atom') {\n const atomData = sview.getAtomData(p)\n position = atomData.position as Float32Array\n size = atomData.radius as Float32Array\n color = atomData.color as Float32Array\n if (!what || what.text) {\n text = []\n sview.eachAtom(ap => text.push(labelFactory.atomLabel(ap)))\n }\n } else if (this.labelGrouping === 'residue') {\n if (!what || what.position) positionN = []\n if (!what || what.color) colorN = []\n if (!what || what.radius) sizeN = []\n if (!what || what.text) text = []\n if (p.colorParams) p.colorParams.structure = sview.getStructure()\n const colormaker = ColormakerRegistry.getScheme(p.colorParams)\n const radiusFactory = new RadiusFactory(p.radiusParams)\n const ap1 = sview.getAtomProxy()\n\n let i = 0\n sview.eachResidue(rp => {\n const i3 = i * 3\n if (rp.isProtein() || rp.isNucleic()) {\n ap1.index = rp.traceAtomIndex\n if (!what || what.position) {\n ap1.positionToArray(positionN, i3)\n }\n } else {\n ap1.index = rp.atomOffset\n if (!what || what.position) {\n rp.positionToArray(positionN, i3)\n }\n }\n if (!what || what.color) {\n colormaker.atomColorToArray(ap1, colorN, i3)\n }\n if (!what || what.radius) {\n sizeN[ i ] = radiusFactory.atomRadius(ap1)\n }\n if (!what || what.text) {\n text.push(labelFactory.atomLabel(ap1))\n }\n ++i\n })\n\n if (!what || what.position) position = new Float32Array(positionN!)\n if (!what || what.color) color = new Float32Array(colorN!)\n if (!what || what.radius) size = new Float32Array(sizeN!)\n }\n\n return { position: position!, size: size!, color: color!, text: text! }\n }\n\n createData (sview: StructureView) {\n const what: TextDataField = { position: true, color: true, radius: true, text: true }\n\n const textBuffer = new TextBuffer(\n this.getTextData(sview, what) as TextBufferData,\n this.getBufferParams({\n fontFamily: this.fontFamily,\n fontStyle: this.fontStyle,\n fontWeight: this.fontWeight,\n xOffset: this.xOffset,\n yOffset: this.yOffset,\n zOffset: this.zOffset,\n attachment: this.attachment,\n showBorder: this.showBorder,\n borderColor: this.borderColor,\n borderWidth: this.borderWidth,\n showBackground: this.showBackground,\n backgroundColor: this.backgroundColor,\n backgroundMargin: this.backgroundMargin,\n backgroundOpacity: this.backgroundOpacity,\n fixedSize: this.fixedSize\n })\n )\n\n return { bufferList: [ textBuffer ] }\n }\n\n updateData (what: TextDataField, data: StructureRepresentationData) {\n data.bufferList[ 0 ].setAttributes(this.getTextData(data.sview as StructureView, what))\n }\n\n getAtomRadius () {\n return 0\n }\n}\n\nRepresentationRegistry.add('label', LabelRepresentation)\n\nexport default LabelRepresentation\n","/**\n * @file Line Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { RepresentationRegistry } from '../globals'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport WideLineBuffer from '../buffer/wideline-buffer'\nimport { AtomPicker } from '../utils/picker'\n// @ts-ignore: unused import Volume required for declaration only\nimport { Structure, Volume } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport Viewer from '../viewer/viewer';\nimport AtomProxy from '../proxy/atom-proxy';\n// @ts-ignore: unused import Surface required for declaration only\nimport Surface from '../surface/surface';\n// @ts-ignore: unused import BondDataFields, BondDataParams required for declaration only\nimport { BondDataFields, BondDataParams } from '../structure/structure-data';\n\n/**\n * Determine which atoms in a Structure[View] form no bonds to any other atoms\n * in that Structure.\n *\n * This differs from setting the selection to \"nonbonded\" as it finds atoms\n * that have no bonds within the current selection.\n * @param {Structure} structure - The Structure or StructureView object\n * @return {AtomSet} AtomSet of lone atoms\n */\nfunction getLoneAtomSet (structure: Structure | StructureView) {\n const atomSet = structure.getAtomSet()\n const bondSet = structure.getBondSet()\n const bp = structure.getBondProxy()\n bondSet.forEach(function (idx) {\n bp.index = idx\n atomSet.clear(bp.atomIndex1)\n atomSet.clear(bp.atomIndex2)\n })\n return atomSet\n}\n\nexport interface LineRepresentationParameters extends StructureRepresentationParameters {\n multipleBond: 'off' | 'symmetric' | 'offset'\n bondSpacing: number\n linewidth: number\n lines: boolean\n crosses: 'off' | 'all' | 'lone'\n crossSize: number\n}\n\nexport interface CrossData {\n position1?: Float32Array\n position2?: Float32Array\n color?: Float32Array\n color2?: Float32Array\n picking?: AtomPicker\n}\n\n/**\n * Line representation\n */\nclass LineRepresentation extends StructureRepresentation {\n protected multipleBond: 'off' | 'symmetric' | 'offset'\n protected bondSpacing: number\n protected linewidth: number\n protected lines: boolean\n protected crosses: 'off' | 'all' | 'lone'\n protected crossSize: number\n /**\n * Create Line representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {RepresentationParameters} params - representation parameters, plus the properties listed below\n * @property {String} multipleBond - one off \"off\", \"symmetric\", \"offset\"\n * @param {Float} params.bondSpacing - spacing for multiple bond rendering\n * @param {Integer} params.linewidth - width of lines\n * @param {Boolean} params.lines - render bonds as lines\n * @param {String} params.crosses - render atoms as crosses: \"off\", \"all\" or \"lone\" (default)\n * @param {Float} params.crossSize - size of cross\n * @param {null} params.flatShaded - not available\n * @param {null} params.side - not available\n * @param {null} params.wireframe - not available\n * @param {null} params.roughness - not available\n * @param {null} params.metalness - not available\n * @param {null} params.diffuse - not available\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'line'\n\n this.parameters = Object.assign({\n\n multipleBond: {\n type: 'select',\n rebuild: true,\n options: {\n 'off': 'off',\n 'symmetric': 'symmetric',\n 'offset': 'offset'\n }\n },\n bondSpacing: {\n type: 'number', precision: 2, max: 2.0, min: 0.5\n },\n linewidth: {\n type: 'integer', max: 50, min: 1, buffer: true\n },\n lines: {\n type: 'boolean', rebuild: true\n },\n crosses: {\n type: 'select',\n rebuild: true,\n options: {\n 'off': 'off',\n 'lone': 'lone',\n 'all': 'all'\n }\n },\n crossSize: {\n type: 'number', precision: 2, max: 2.0, min: 0.1\n }\n\n }, this.parameters, {\n\n flatShaded: null,\n side: null,\n wireframe: null,\n\n roughness: null,\n metalness: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n\n this.multipleBond = defaults(p.multipleBond, 'off')\n this.bondSpacing = defaults(p.bondSpacing, 1.0)\n this.linewidth = defaults(p.linewidth, 2)\n this.lines = defaults(p.lines, true)\n this.crosses = defaults(p.crosses, 'lone')\n this.crossSize = defaults(p.crossSize, 0.4)\n\n super.init(p)\n }\n\n getAtomRadius (atom:AtomProxy) {\n return 0.1\n }\n\n getBondParams (what: any, params?: Partial) {\n params = Object.assign({\n multipleBond: this.multipleBond,\n bondSpacing: this.bondSpacing,\n radiusParams: { 'type': 'size', 'size': 0.1, 'scale': 1 }\n }, params)\n\n return super.getBondParams(what, params)\n }\n\n _crossData (what: any, sview: StructureView) {\n if (what) {\n if (!what.position && !what.color) return\n }\n\n const p = {}\n if (this.crosses === 'lone') {\n Object.assign(p, {atomSet : getLoneAtomSet(sview)})\n }\n\n const atomData = sview.getAtomData(this.getAtomParams(what, p))\n const crossData: CrossData = {}\n const position = atomData.position\n const color = atomData.color\n const picking = atomData.picking\n\n const size = (position! || color).length\n const attrSize = size * 3\n\n let cPosition1 = new Float32Array(0)\n let cPosition2 = new Float32Array(0)\n let cColor = new Float32Array(0)\n let cColor2 = new Float32Array(0)\n let cOffset: number = 0\n\n let pickingArray = new Float32Array(0)\n\n if (!what || what.position) {\n cPosition1 = crossData.position1 = new Float32Array(attrSize)\n cPosition2 = crossData.position2 = new Float32Array(attrSize)\n cOffset = this.crossSize / 2\n }\n if (!what || what.color) {\n cColor = crossData.color = new Float32Array(attrSize)\n cColor2 = crossData.color2 = new Float32Array(attrSize)\n }\n if (!what || what.picking) {\n pickingArray = new Float32Array(atomData.picking!.array!.length * 3) // Needs padding??\n }\n\n for (let v = 0; v < size; v++) {\n const j = v * 3\n const i = j * 3\n\n if (!what || what.position) {\n const x = position![ j ]\n const y = position![ j + 1 ]\n const z = position![ j + 2 ]\n\n cPosition1[ i ] = x - cOffset!\n cPosition1[ i + 1 ] = y\n cPosition1[ i + 2 ] = z\n cPosition2[ i ] = x + cOffset\n cPosition2[ i + 1 ] = y\n cPosition2[ i + 2 ] = z\n\n cPosition1[ i + 3 ] = x\n cPosition1[ i + 4 ] = y - cOffset\n cPosition1[ i + 5 ] = z\n cPosition2[ i + 3 ] = x\n cPosition2[ i + 4 ] = y + cOffset\n cPosition2[ i + 5 ] = z\n\n cPosition1[ i + 6 ] = x\n cPosition1[ i + 7 ] = y\n cPosition1[ i + 8 ] = z - cOffset\n cPosition2[ i + 6 ] = x\n cPosition2[ i + 7 ] = y\n cPosition2[ i + 8 ] = z + cOffset\n }\n\n if (!what || what.color) {\n const cimax = i + 9\n for (let ci = i; ci < cimax; ci += 3) {\n cColor[ ci ] = cColor2[ ci ] = color![ j ]\n cColor[ ci + 1 ] = cColor2[ ci + 1 ] = color![ j + 1 ]\n cColor[ ci + 2 ] = cColor2[ ci + 2 ] = color![ j + 2 ]\n }\n }\n\n if (!what || what.picking) {\n pickingArray[ j ] =\n pickingArray[ j + 1 ] =\n pickingArray[ j + 2 ] = picking!.array![ v ]\n }\n }\n\n if (!what || what.picking) {\n crossData.picking = new AtomPicker(\n pickingArray, picking!.structure\n )\n }\n\n return crossData\n }\n\n createData (sview: StructureView) {\n const what = { position: true, color: true, picking: true }\n\n const bufferList = []\n\n if (this.lines) {\n const bondData = sview.getBondData(this.getBondParams(what))\n\n const lineBuffer = new WideLineBuffer(\n bondData, this.getBufferParams({ linewidth: this.linewidth })\n )\n\n bufferList.push(lineBuffer)\n }\n\n if (this.crosses !== 'off') {\n const crossBuffer = new WideLineBuffer(\n (this._crossData(what, sview) as CrossData),\n this.getBufferParams({linewidth: this.linewidth})\n )\n bufferList.push(crossBuffer)\n }\n\n return {\n bufferList: bufferList\n }\n }\n\n updateData (what: any, data: StructureRepresentationData) {\n let bufferIdx = 0\n\n if (this.lines) {\n const bondData = data.sview!.getBondData(this.getBondParams(what))\n const lineAttributes = {}\n\n if (!what || what.position) {\n Object.assign(lineAttributes, {\n position1: bondData.position1,\n position2: bondData.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(lineAttributes, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n data.bufferList[ bufferIdx++ ].setAttributes(lineAttributes)\n }\n\n if (this.crosses !== 'off') {\n const crossData = this._crossData(what, (data.sview as StructureView))\n const crossAttributes = {}\n\n if (!what || what.position) {\n Object.assign(crossAttributes, {\n position1: crossData!.position1,\n position2: crossData!.position2\n })\n }\n if (!what || what.color) {\n Object.assign(crossAttributes, {\n color: crossData!.color,\n color2: crossData!.color2\n })\n }\n\n data.bufferList[ bufferIdx++ ].setAttributes(crossAttributes)\n }\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n if (params && (params.bondSpacing || params.crossSize)) {\n Object.assign(what, { position: true })\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('line', LineRepresentation)\n\nexport default LineRepresentation\n","import { NumberArray, TypedArray } from \"../types\";\n\n/**\n * @file Grid\n * @author Alexander Rose \n * @private\n */\nexport interface iGrid {\n data: TypedArray\n index: (x: number, y: number, z: number) => number\n set: (x: number, y: number, z: number, ...arg: number[]) => void\n toArray: (x: number, y: number, z: number, array?: NumberArray, offset?: number) => void\n fromArray: (x: number, y: number, z: number, array: NumberArray, offset?: number) => void\n copy: (grid: iGrid) => void\n // clone: () => iGrid\n}\n\nfunction makeGrid (length: number, width: number, height: number, DataCtor: any, elemSize: number) : iGrid {\n DataCtor = DataCtor || Int32Array\n elemSize = elemSize || 1\n\n const data = new DataCtor(length * width * height * elemSize)\n\n function index (x: number, y: number, z: number) {\n return ((((x * width) + y) * height) + z) * elemSize\n }\n\n function set (x: number, y: number, z: number, ...args: number[]) {\n const i = index(x, y, z)\n\n for (let j = 0; j < elemSize; ++j) {\n data[ i + j ] = args[ j ]\n }\n }\n\n function toArray (x: number, y: number, z: number, array: NumberArray = [], offset: number = 0) {\n const i = index(x, y, z)\n\n for (let j = 0; j < elemSize; ++j) {\n array[ offset + j ] = data[ i + j ]\n }\n }\n\n function fromArray(x: number, y: number, z: number, array: NumberArray, offset: number = 0) {\n const i = index(x, y, z)\n\n for (let j = 0; j < elemSize; ++j) {\n data[ i + j ] = array[ offset + j ]\n }\n }\n\n function copy(grid: iGrid) {\n data.set(grid.data)\n }\n\n // function clone() {\n // return makeGrid(\n // length, width, height, DataCtor, elemSize\n // ).copy(this)\n // }\n return { data, index, set, toArray, fromArray, copy }\n}\n\nexport { makeGrid }","/**\n * @file EDT Surface\n * @author Alexander Rose \n * @private\n */\n\nimport { VolumeSurface } from './volume'\nimport { iGrid, makeGrid } from '../geometry/grid'\nimport { computeBoundingBox } from '../math/vector-utils'\nimport { getRadiusDict, getSurfaceGrid } from './surface-utils'\nimport { TypedArray } from '../types';\n\ninterface EDTSurface {\n getVolume: (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean) => {\n data: TypedArray\n nx: number\n ny: number\n nz: number\n atomindex: TypedArray\n }\n getSurface: (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean, smooth: number, contour: boolean) => any\n}\n\nfunction EDTSurface (this: EDTSurface, coordList: Float32Array, radiusList: Float32Array, indexList: Uint16Array|Uint32Array) {\n // based on D. Xu, Y. Zhang (2009) Generating Triangulated Macromolecular\n // Surfaces by Euclidean Distance Transform. PLoS ONE 4(12): e8140.\n //\n // Permission to use, copy, modify, and distribute this program for\n // any purpose, with or without fee, is hereby granted, provided that\n // the notices on the head, the reference information, and this\n // copyright notice appear in all copies or substantial portions of\n // the Software. It is provided \"as is\" without express or implied\n // warranty.\n //\n // ported to JavaScript by biochem_fan (http://webglmol.sourceforge.jp/)\n // refactored by dkoes (https://github.com/dkoes)\n //\n // adapted to NGL by Alexander Rose\n\n var radiusDict = getRadiusDict(radiusList as any)\n var bbox = computeBoundingBox(coordList)\n if (coordList.length === 0) {\n bbox[ 0 ].set([ 0, 0, 0 ])\n bbox[ 1 ].set([ 0, 0, 0 ])\n }\n var min = bbox[ 0 ]\n var max = bbox[ 1 ]\n\n var probeRadius: number, scaleFactor: number, cutoff: number\n var pLength: number, pWidth: number, pHeight: number\n var matrix: Float32Array, ptran: Float32Array\n var depty: {[k: string]: TypedArray}, widxz: {[k: string]: number}\n var cutRadius: number\n var setAtomID: boolean\n var vpBits: TypedArray, vpDistance: TypedArray, vpAtomID: TypedArray\n\n function init (btype: boolean, _probeRadius: number, _scaleFactor: number, _cutoff: number, _setAtomID: boolean) {\n probeRadius = _probeRadius || 1.4\n scaleFactor = _scaleFactor || 2.0\n setAtomID = _setAtomID || true\n\n var maxRadius = 0\n for (var radius in radiusDict) {\n maxRadius = Math.max(maxRadius, radius as any)\n }\n\n var grid = getSurfaceGrid(\n min, max, maxRadius, scaleFactor, btype ? probeRadius : 0\n )\n\n pLength = grid.dim[0]\n pWidth = grid.dim[1]\n pHeight = grid.dim[2]\n\n matrix = grid.matrix\n ptran = grid.tran\n scaleFactor = grid.scaleFactor\n\n // boundingatom caches\n depty = {}\n widxz = {}\n boundingatom(btype)\n\n cutRadius = probeRadius * scaleFactor\n\n if (_cutoff) {\n cutoff = _cutoff\n } else {\n // cutoff = Math.max( 0.1, -1.2 + scaleFactor * probeRadius );\n cutoff = probeRadius / scaleFactor\n }\n\n vpBits = new Uint8Array(pLength * pWidth * pHeight)\n if (btype) {\n vpDistance = new Float64Array(pLength * pWidth * pHeight)\n }\n if (setAtomID) {\n vpAtomID = new Int32Array(pLength * pWidth * pHeight)\n }\n }\n\n // constants for vpBits bitmasks\n var INOUT = 1\n var ISDONE = 2\n var ISBOUND = 4\n\n var nb = [\n new Int32Array([ 1, 0, 0 ]), new Int32Array([ -1, 0, 0 ]),\n new Int32Array([ 0, 1, 0 ]), new Int32Array([ 0, -1, 0 ]),\n new Int32Array([ 0, 0, 1 ]), new Int32Array([ 0, 0, -1 ]),\n new Int32Array([ 1, 1, 0 ]), new Int32Array([ 1, -1, 0 ]),\n new Int32Array([ -1, 1, 0 ]), new Int32Array([ -1, -1, 0 ]),\n new Int32Array([ 1, 0, 1 ]), new Int32Array([ 1, 0, -1 ]),\n new Int32Array([ -1, 0, 1 ]), new Int32Array([ -1, 0, -1 ]),\n new Int32Array([ 0, 1, 1 ]), new Int32Array([ 0, 1, -1 ]),\n new Int32Array([ 0, -1, 1 ]), new Int32Array([ 0, -1, -1 ]),\n new Int32Array([ 1, 1, 1 ]), new Int32Array([ 1, 1, -1 ]),\n new Int32Array([ 1, -1, 1 ]), new Int32Array([ -1, 1, 1 ]),\n new Int32Array([ 1, -1, -1 ]), new Int32Array([ -1, -1, 1 ]),\n new Int32Array([ -1, 1, -1 ]), new Int32Array([ -1, -1, -1 ])\n ]\n\n //\n\n this.getVolume = function (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean) {\n console.time('EDTSurface.getVolume')\n\n var btype = type !== 'vws'\n\n init(btype, probeRadius, scaleFactor, cutoff, setAtomID)\n\n fillvoxels(btype)\n buildboundary()\n\n if (type === 'ms' || type === 'ses') {\n fastdistancemap()\n }\n\n if (type === 'ses') {\n boundingatom(false)\n fillvoxelswaals()\n }\n\n marchingcubeinit(type)\n\n // set atomindex in the volume data\n for (var i = 0, il = vpAtomID.length; i < il; ++i) {\n vpAtomID[ i ] = indexList[ vpAtomID[ i ] ]\n }\n\n console.timeEnd('EDTSurface.getVolume')\n\n return {\n data: vpBits,\n nx: pHeight,\n ny: pWidth,\n nz: pLength,\n atomindex: vpAtomID\n }\n }\n\n this.getSurface = function (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean, smooth: number, contour: boolean) {\n var vd = this.getVolume(\n type, probeRadius, scaleFactor, cutoff, setAtomID\n )\n\n var volsurf = new (VolumeSurface as any)(\n vd.data, vd.nx, vd.ny, vd.nz, vd.atomindex\n ) as VolumeSurface\n\n return (volsurf!.getSurface as any)(1, smooth, undefined, matrix, contour)\n }\n\n function boundingatom (btype: boolean) {\n var r\n var j\n var k\n var txz\n var tdept\n var sradius\n var tradius\n var widxzR\n var deptyName\n var indx\n\n for (var name in radiusDict) {\n r = parseFloat(name)\n\n if (depty[ name ]) continue\n\n if (!btype) {\n tradius = r * scaleFactor + 0.5\n } else {\n tradius = (r + probeRadius) * scaleFactor + 0.5\n }\n\n sradius = tradius * tradius\n widxzR = Math.floor(tradius) + 1\n deptyName = new Int32Array(widxzR * widxzR)\n indx = 0\n\n for (j = 0; j < widxzR; ++j) {\n for (k = 0; k < widxzR; ++k) {\n txz = j * j + k * k\n\n if (txz > sradius) {\n deptyName[ indx ] = -1\n } else {\n tdept = Math.sqrt(sradius - txz)\n deptyName[ indx ] = Math.floor(tdept)\n }\n\n ++indx\n }\n }\n\n widxz[ name ] = widxzR\n depty[ name ] = deptyName\n }\n }\n\n function fillatom (idx: number) {\n var ci = idx * 3\n var ri = idx\n\n var cx, cy, cz, ox, oy, oz, mi, mj, mk, i, j, k, si, sj, sk\n var ii, jj, kk\n\n cx = Math.floor(0.5 + scaleFactor * (coordList[ ci ] + ptran[0]))\n cy = Math.floor(0.5 + scaleFactor * (coordList[ ci + 1 ] + ptran[1]))\n cz = Math.floor(0.5 + scaleFactor * (coordList[ ci + 2 ] + ptran[2]))\n\n var at = radiusList[ ri ]\n var deptyAt = depty[ at ]\n var nind = 0\n var pWH = pWidth * pHeight\n var n = widxz[ at ]\n\n var deptyAtNind\n\n for (i = 0; i < n; ++i) {\n for (j = 0; j < n; ++j) {\n deptyAtNind = deptyAt[ nind ]\n\n if (deptyAtNind !== -1) {\n for (ii = -1; ii < 2; ++ii) {\n for (jj = -1; jj < 2; ++jj) {\n for (kk = -1; kk < 2; ++kk) {\n if (ii !== 0 && jj !== 0 && kk !== 0) {\n mi = ii * i\n mk = kk * j\n\n for (k = 0; k <= deptyAtNind; ++k) {\n mj = k * jj\n si = cx + mi\n sj = cy + mj\n sk = cz + mk\n\n if (si < 0 || sj < 0 || sk < 0 ||\n si >= pLength || sj >= pWidth || sk >= pHeight\n ) {\n continue\n }\n\n var index = si * pWH + sj * pHeight + sk\n\n if (!setAtomID) {\n vpBits[ index ] |= INOUT\n } else {\n if (!(vpBits[ index ] & INOUT)) {\n vpBits[ index ] |= INOUT\n vpAtomID[ index ] = idx\n } else if (vpBits[ index ] & INOUT) {\n var ci2 = vpAtomID[ index ]\n\n if (ci2 !== ci) {\n ox = cx + mi - Math.floor(0.5 + scaleFactor * (coordList[ci2] + ptran[0]))\n oy = cy + mj - Math.floor(0.5 + scaleFactor * (coordList[ci2 + 1] + ptran[1]))\n oz = cz + mk - Math.floor(0.5 + scaleFactor * (coordList[ci2 + 2] + ptran[2]))\n\n if (mi * mi + mj * mj + mk * mk < ox * ox + oy * oy + oz * oz) {\n vpAtomID[ index ] = idx\n }\n }\n }\n }\n } // k\n } // if\n } // kk\n } // jj\n } // ii\n } // if\n\n nind++\n } // j\n } // i\n }\n\n function fillvoxels (btype: boolean) {\n console.time('EDTSurface fillvoxels')\n\n var i, il\n\n for (i = 0, il = vpBits.length; i < il; ++i) {\n vpBits[ i ] = 0\n if (btype) vpDistance[ i ] = -1.0\n if (setAtomID) vpAtomID[ i ] = -1\n }\n\n for (i = 0, il = coordList.length / 3; i < il; ++i) {\n fillatom(i)\n }\n\n for (i = 0, il = vpBits.length; i < il; ++i) {\n if (vpBits[ i ] & INOUT) {\n vpBits[ i ] |= ISDONE\n }\n }\n\n console.timeEnd('EDTSurface fillvoxels')\n }\n\n function fillAtomWaals (idx: number) {\n var ci = idx * 3\n var ri = idx\n\n var cx\n var cy\n var cz\n var ox\n var oy\n var oz\n var nind = 0\n\n var mi\n var mj\n var mk\n var si\n var sj\n var sk\n var i\n var j\n var k\n var ii\n var jj\n var kk\n var n\n\n cx = Math.floor(0.5 + scaleFactor * (coordList[ ci ] + ptran[0]))\n cy = Math.floor(0.5 + scaleFactor * (coordList[ ci + 1 ] + ptran[1]))\n cz = Math.floor(0.5 + scaleFactor * (coordList[ ci + 2 ] + ptran[2]))\n\n var at = radiusList[ ri ]\n var pWH = pWidth * pHeight\n\n for (i = 0, n = widxz[at]; i < n; ++i) {\n for (j = 0; j < n; ++j) {\n if (depty[ at ][ nind ] !== -1) {\n for (ii = -1; ii < 2; ++ii) {\n for (jj = -1; jj < 2; ++jj) {\n for (kk = -1; kk < 2; ++kk) {\n if (ii !== 0 && jj !== 0 && kk !== 0) {\n mi = ii * i\n mk = kk * j\n\n for (k = 0; k <= depty[ at ][ nind ]; ++k) {\n mj = k * jj\n si = cx + mi\n sj = cy + mj\n sk = cz + mk\n\n if (si < 0 || sj < 0 || sk < 0 ||\n si >= pLength || sj >= pWidth || sk >= pHeight\n ) {\n continue\n }\n\n var index = si * pWH + sj * pHeight + sk\n\n if (!(vpBits[ index ] & ISDONE)) {\n vpBits[ index ] |= ISDONE\n if (setAtomID) vpAtomID[ index ] = idx\n } else if (setAtomID) {\n var ci2 = vpAtomID[ index ]\n\n ox = Math.floor(0.5 + scaleFactor * (coordList[ ci2 ] + ptran[0]))\n oy = Math.floor(0.5 + scaleFactor * (coordList[ ci2 + 1 ] + ptran[1]))\n oz = Math.floor(0.5 + scaleFactor * (coordList[ ci2 + 2 ] + ptran[2]))\n\n if (mi * mi + mj * mj + mk * mk < ox * ox + oy * oy + oz * oz) {\n vpAtomID[ index ] = idx\n }\n }\n } // k\n } // if\n } // kk\n } // jj\n } // ii\n } // if\n\n nind++\n } // j\n } // i\n }\n\n function fillvoxelswaals () {\n var i, il\n\n for (i = 0, il = vpBits.length; i < il; ++i) {\n vpBits[ i ] &= ~ISDONE // not isdone\n }\n\n for (i = 0, il = coordList.length / 3; i < il; ++i) {\n fillAtomWaals(i)\n }\n }\n\n function buildboundary () {\n var i, j, k\n var pWH = pWidth * pHeight\n\n for (i = 0; i < pLength; ++i) {\n for (j = 0; j < pHeight; ++j) {\n for (k = 0; k < pWidth; ++k) {\n var index = i * pWH + k * pHeight + j\n\n if (vpBits[ index ] & INOUT) {\n // var flagbound = false;\n var ii = 0\n\n // while( !flagbound && ii < 26 ){\n while (ii < 26) {\n var ti = i + nb[ ii ][ 0 ]\n var tj = j + nb[ ii ][ 2 ]\n var tk = k + nb[ ii ][ 1 ]\n\n if (ti > -1 && ti < pLength &&\n tk > -1 && tk < pWidth &&\n tj > -1 && tj < pHeight &&\n !(vpBits[ ti * pWH + tk * pHeight + tj ] & INOUT)\n ) {\n vpBits[ index ] |= ISBOUND\n // flagbound = true;\n break\n } else {\n ii++\n }\n }\n }\n } // k\n } // j\n } // i\n }\n\n function fastdistancemap () {\n console.time('EDTSurface fastdistancemap')\n\n var i, j, k, n\n\n var boundPoint = makeGrid(\n pLength, pWidth, pHeight, Uint16Array, 3\n )\n var pWH = pWidth * pHeight\n var cutRSq = cutRadius * cutRadius\n\n var totalsurfacevox = 0\n // var totalinnervox = 0;\n\n var index\n\n for (i = 0; i < pLength; ++i) {\n for (j = 0; j < pWidth; ++j) {\n for (k = 0; k < pHeight; ++k) {\n index = i * pWH + j * pHeight + k\n\n vpBits[ index ] &= ~ISDONE\n\n if (vpBits[ index ] & INOUT) {\n if (vpBits[ index ] & ISBOUND) {\n boundPoint.set(\n i, j, k,\n i, j, k\n )\n\n vpDistance[ index ] = 0\n vpBits[ index ] |= ISDONE\n\n totalsurfacevox += 1\n }/* else{\n totalinnervox += 1;\n } */\n }\n }\n }\n }\n\n var inarray = new Int32Array(3 * totalsurfacevox)\n var positin = 0\n var outarray = new Int32Array(3 * totalsurfacevox)\n var positout = 0\n\n for (i = 0; i < pLength; ++i) {\n for (j = 0; j < pWidth; ++j) {\n for (k = 0; k < pHeight; ++k) {\n index = i * pWH + j * pHeight + k\n\n if (vpBits[ index ] & ISBOUND) {\n inarray[ positin ] = i\n inarray[ positin + 1 ] = j\n inarray[ positin + 2 ] = k\n positin += 3\n\n vpBits[ index ] &= ~ISBOUND\n }\n }\n }\n }\n\n do {\n positout = fastoneshell(inarray, boundPoint, positin, outarray)\n positin = 0\n\n for (i = 0, n = positout; i < n; i += 3) {\n index = pWH * outarray[ i ] + pHeight * outarray[ i + 1 ] + outarray[ i + 2 ]\n vpBits[ index ] &= ~ISBOUND\n\n if (vpDistance[ index ] <= 1.0404 * cutRSq) {\n // if( vpDistance[ index ] <= 1.02 * cutRadius ){\n\n inarray[ positin ] = outarray[ i ]\n inarray[ positin + 1 ] = outarray[ i + 1 ]\n inarray[ positin + 2 ] = outarray[ i + 2 ]\n positin += 3\n }\n }\n } while (positin > 0)\n\n // var cutsf = Math.max( 0, scaleFactor - 0.5 );\n // cutoff = cutRadius - 0.5 / ( 0.1 + cutsf );\n var cutoffSq = cutoff * cutoff\n\n var index2\n var bp = new Uint16Array(3)\n\n for (i = 0; i < pLength; ++i) {\n for (j = 0; j < pWidth; ++j) {\n for (k = 0; k < pHeight; ++k) {\n index = i * pWH + j * pHeight + k\n vpBits[ index ] &= ~ISBOUND\n\n // ses solid\n\n if (vpBits[ index ] & INOUT) {\n if (!(vpBits[ index ] & ISDONE) ||\n ((vpBits[ index ] & ISDONE) && vpDistance[ index ] >= cutoffSq)\n ) {\n vpBits[ index ] |= ISBOUND\n\n if (setAtomID && (vpBits[ index ] & ISDONE)) {\n boundPoint.toArray(i, j, k, bp)\n index2 = bp[ 0 ] * pWH + bp[ 1 ] * pHeight + bp[ 2 ]\n\n vpAtomID[ index ] = vpAtomID[ index2 ]\n }\n }\n }\n }\n }\n }\n\n console.timeEnd('EDTSurface fastdistancemap')\n }\n\n function fastoneshell (inarray: Int32Array, boundPoint: iGrid, positin: number, outarray: Int32Array) {\n // *allocout,voxel2\n // ***boundPoint, int*\n // outnum, int *elimi)\n var tx, ty, tz\n var dx, dy, dz\n var i, j, n\n var square\n var index\n var nbj\n var bp = new Uint16Array(3)\n var positout = 0\n\n if (positin === 0) {\n return positout\n }\n\n var tnvix = -1\n var tnviy = -1\n var tnviz = -1\n\n var pWH = pWidth * pHeight\n\n for (i = 0, n = positin; i < n; i += 3) {\n tx = inarray[ i ]\n ty = inarray[ i + 1 ]\n tz = inarray[ i + 2 ]\n boundPoint.toArray(tx, ty, tz, bp)\n\n for (j = 0; j < 6; ++j) {\n nbj = nb[ j ]\n tnvix = tx + nbj[ 0 ]\n tnviy = ty + nbj[ 1 ]\n tnviz = tz + nbj[ 2 ]\n\n if (tnvix < pLength && tnvix > -1 &&\n tnviy < pWidth && tnviy > -1 &&\n tnviz < pHeight && tnviz > -1\n ) {\n index = tnvix * pWH + pHeight * tnviy + tnviz\n\n if ((vpBits[ index ] & INOUT) && !(vpBits[ index ] & ISDONE)) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n vpDistance[ index ] = square\n vpBits[ index ] |= ISDONE\n vpBits[ index ] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n } else if ((vpBits[ index ] & INOUT) && (vpBits[ index ] & ISDONE)) {\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n if (square < vpDistance[ index ]) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n vpDistance[ index ] = square\n\n if (!(vpBits[ index ] & ISBOUND)) {\n vpBits[ index ] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n }\n }\n }\n }\n }\n }\n\n for (i = 0, n = positin; i < n; i += 3) {\n tx = inarray[ i ]\n ty = inarray[ i + 1 ]\n tz = inarray[ i + 2 ]\n boundPoint.toArray(tx, ty, tz, bp)\n\n for (j = 6; j < 18; j++) {\n nbj = nb[ j ]\n tnvix = tx + nbj[ 0 ]\n tnviy = ty + nbj[ 1 ]\n tnviz = tz + nbj[ 2 ]\n\n if (tnvix < pLength && tnvix > -1 &&\n tnviy < pWidth && tnviy > -1 &&\n tnviz < pHeight && tnviz > -1\n ) {\n index = tnvix * pWH + pHeight * tnviy + tnviz\n\n if ((vpBits[index] & INOUT) && !(vpBits[index] & ISDONE)) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n vpDistance[index] = square\n vpBits[index] |= ISDONE\n vpBits[index] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n } else if ((vpBits[index] & INOUT) && (vpBits[index] & ISDONE)) {\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n if (square < vpDistance[index]) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n vpDistance[index] = square\n\n if (!(vpBits[index] & ISBOUND)) {\n vpBits[index] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n }\n }\n }\n }\n }\n }\n\n for (i = 0, n = positin; i < n; i += 3) {\n tx = inarray[ i ]\n ty = inarray[ i + 1 ]\n tz = inarray[ i + 2 ]\n boundPoint.toArray(tx, ty, tz, bp)\n\n for (j = 18; j < 26; j++) {\n nbj = nb[ j ]\n tnvix = tx + nbj[ 0 ]\n tnviy = ty + nbj[ 1 ]\n tnviz = tz + nbj[ 2 ]\n\n if (tnvix < pLength && tnvix > -1 &&\n tnviy < pWidth && tnviy > -1 &&\n tnviz < pHeight && tnviz > -1\n ) {\n index = tnvix * pWH + pHeight * tnviy + tnviz\n\n if ((vpBits[index] & INOUT) && !(vpBits[index] & ISDONE)) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n vpDistance[index] = square\n vpBits[index] |= ISDONE\n vpBits[index] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n } else if ((vpBits[index] & INOUT) && (vpBits[index] & ISDONE)) {\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n if (square < vpDistance[index]) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n vpDistance[index] = square\n\n if (!(vpBits[index] & ISBOUND)) {\n vpBits[index] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n }\n }\n }\n }\n }\n }\n\n return positout\n }\n\n function marchingcubeinit (stype: string) {\n var i\n var n = vpBits.length\n\n if (stype === 'vws') {\n for (i = 0; i < n; ++i) {\n vpBits[ i ] &= ~ISBOUND\n vpBits[ i ] = (vpBits[ i ] & ISDONE) ? 1 : 0\n }\n } else if (stype === 'ms') { // ses without vdw => ms\n for (i = 0; i < n; ++i) {\n vpBits[ i ] &= ~ISDONE\n if (vpBits[ i ] & ISBOUND) {\n vpBits[ i ] |= ISDONE\n }\n vpBits[ i ] &= ~ISBOUND\n vpBits[ i ] = (vpBits[ i ] & ISDONE) ? 1 : 0\n }\n } else if (stype === 'ses') {\n for (i = 0; i < n; ++i) {\n if ((vpBits[ i ] & ISBOUND) && (vpBits[ i ] & ISDONE)) {\n vpBits[ i ] &= ~ISBOUND\n } else if ((vpBits[ i ] & ISBOUND) && !(vpBits[ i ] & ISDONE)) {\n vpBits[ i ] |= ISDONE\n }\n vpBits[ i ] = (vpBits[ i ] & ISDONE) ? 1 : 0\n }\n } else if (stype === 'sas') {\n for (i = 0; i < n; ++i) {\n vpBits[ i ] &= ~ISBOUND\n vpBits[ i ] = (vpBits[ i ] & ISDONE) ? 1 : 0\n }\n }\n }\n}\nObject.assign(EDTSurface, {__deps: [\n getSurfaceGrid, getRadiusDict, VolumeSurface, computeBoundingBox, makeGrid\n]})\n\nexport default EDTSurface\n","/**\n * @file AV Surface\n * @author Fred Ludlow \n * @private\n */\n\nimport { getSurfaceGrid } from './surface-utils'\nimport { VolumeSurface } from './volume'\nimport { uniformArray } from '../math/array-utils'\nimport {\n computeBoundingBox, v3multiplyScalar, v3cross, v3normalize\n} from '../math/vector-utils'\nimport { defaults } from '../utils'\nimport { NumberArray } from '../types';\n\n\n/**\n * Modifed from SpatialHash\n *\n * Main differences are:\n * - Optimized grid size to ensure we only ever need to look +/-1 cell\n * - Aware of atomic radii and will only output atoms within rAtom + rExtra\n * (see withinRadii method)\n *\n * (Uses rounding rather than bitshifting as consequence of arbitrary grid size)\n * @class\n * @param {Float32Array} atomsX - x coordinates\n * @param {Float32Array} atomsY - y coordinates\n * @param {Float32Array} atomsZ - z coordinates\n * @param {Float32Array} atomsR - atom radii\n * @param {Float32Array} min - xyz min coordinates\n * @param {Float32Array} max - xyz max coordinates\n * @param {Float} maxDistance - max distance\n */\nexport interface iAVHash {\n neighbourListLength: number\n withinRadii: (x: number, y: number, z: number, rExtra: number, out: Int32Array) => void\n}\n\n\nfunction makeAVHash (atomsX: Float32Array, atomsY: Float32Array, atomsZ: Float32Array, atomsR: Float32Array, min: Float32Array, max: Float32Array, maxDistance: number): iAVHash {\n maxDistance = Math.max(0.1, maxDistance) // Avoid maxDistance of zero, see #802\n var nAtoms = atomsX.length\n\n var minX = min[ 0 ]\n var minY = min[ 1 ]\n var minZ = min[ 2 ]\n\n var maxX = max[ 0 ]\n var maxY = max[ 1 ]\n var maxZ = max[ 2 ]\n\n function hashFunc (w: number, minW: number) {\n return Math.floor((w - minW) / maxDistance)\n }\n\n var iDim = hashFunc(maxX, minX) + 1\n var jDim = hashFunc(maxY, minY) + 1\n var kDim = hashFunc(maxZ, minZ) + 1\n\n var nCells = iDim * jDim * kDim\n\n var jkDim = jDim * kDim\n\n /* Get cellID for cartesian x,y,z */\n var cellID = function (x: number, y: number, z: number) {\n return (((hashFunc(x, minX) * jDim) + hashFunc(y, minY)) * kDim) + hashFunc(z, minZ)\n }\n\n /* Initial building, could probably be optimized further */\n var preHash = [] // preHash[ cellID ] = [ atomId1, atomId2 ];\n\n for (var i = 0; i < nAtoms; i++) {\n var cid = cellID(atomsX[ i ], atomsY[ i ], atomsZ[ i ])\n\n if (preHash[ cid ] === undefined) {\n preHash[ cid ] = [ i ]\n } else {\n preHash[ cid ].push(i)\n }\n }\n\n var cellOffsets = new Uint32Array(nCells)\n var cellLengths = new Uint16Array(nCells)\n var data = new Uint32Array(nAtoms)\n\n var offset = 0\n var maxCellLength = 0\n\n for (i = 0; i < nCells; i++) {\n var start = cellOffsets[ i ] = offset\n\n var subArray = preHash[ i ]\n\n if (subArray !== undefined) {\n for (var j = 0; j < subArray.length; j++) {\n data[ offset ] = subArray[ j ]\n offset++\n }\n }\n\n var cellLength = offset - start\n cellLengths[ i ] = cellLength\n\n if (cellLength > maxCellLength) { maxCellLength = cellLength }\n }\n\n // Maximum number of neighbours we could ever produce (27 adjacent cells of equal population)\n const neighbourListLength = (27 * maxCellLength) + 1\n\n /**\n * Populate the supplied out array with atom indices that are within rAtom + rExtra\n * of x,y,z\n *\n * -1 in out array indicates the end of the list\n *\n * @param {Float} x - x coordinate\n * @param {Float} y - y coordinate\n * @param {Float} z - z coordinate\n * @param {Float} rExtra - additional radius\n * @param {Float32Array} out - pre-allocated output array\n * @return {undefined}\n */\n const withinRadii = function (x: number, y: number, z: number, rExtra: number, out: Int32Array) {\n var outIdx = 0\n\n var nearI = hashFunc(x, minX)\n var nearJ = hashFunc(y, minY)\n var nearK = hashFunc(z, minZ)\n\n var loI = Math.max(0, nearI - 1)\n var loJ = Math.max(0, nearJ - 1)\n var loK = Math.max(0, nearK - 1)\n\n var hiI = Math.min(iDim, nearI + 2)\n var hiJ = Math.min(jDim, nearJ + 2)\n var hiK = Math.min(kDim, nearK + 2)\n\n for (var i = loI; i < hiI; ++i) {\n var iOffset = i * jkDim\n\n for (var j = loJ; j < hiJ; ++j) {\n var jOffset = j * kDim\n\n for (var k = loK; k < hiK; ++k) {\n var cid = iOffset + jOffset + k\n\n var cellStart = cellOffsets[ cid ]\n var cellEnd = cellStart + cellLengths[ cid ]\n\n for (var dataIndex = cellStart; dataIndex < cellEnd; dataIndex++) {\n var atomIndex = data[ dataIndex ]\n var dx = atomsX[ atomIndex ] - x\n var dy = atomsY[ atomIndex ] - y\n var dz = atomsZ[ atomIndex ] - z\n var rSum = atomsR[ atomIndex ] + rExtra\n\n if ((dx * dx + dy * dy + dz * dz) <= (rSum * rSum)) {\n out[ outIdx++ ] = data[ dataIndex ]\n }\n }\n }\n }\n }\n // Add terminator\n out[ outIdx ] = -1\n }\n return {\n neighbourListLength: neighbourListLength,\n withinRadii: withinRadii\n }\n}\n\ninterface AVSurface {\n getSurface: (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean, smooth: number, contour: boolean) => any\n}\nfunction AVSurface (this: AVSurface, coordList: Float32Array, radiusList: Float32Array, indexList: Uint16Array|Uint32Array) {\n // Field generation method adapted from AstexViewer (Mike Hartshorn)\n // by Fred Ludlow.\n // Other parts based heavily on NGL (Alexander Rose) EDT Surface class\n //\n // Should work as a drop-in alternative to EDTSurface (though some of\n // the EDT paramters are not relevant in this method).\n\n const nAtoms = radiusList.length\n\n const x = new Float32Array(nAtoms)\n const y = new Float32Array(nAtoms)\n const z = new Float32Array(nAtoms)\n\n for (let i = 0; i < nAtoms; i++) {\n const ci = 3 * i\n x[ i ] = coordList[ ci ]\n y[ i ] = coordList[ ci + 1 ]\n z[ i ] = coordList[ ci + 2 ]\n }\n\n let bbox = computeBoundingBox(coordList)\n if (coordList.length === 0) {\n bbox[ 0 ].set([ 0, 0, 0 ])\n bbox[ 1 ].set([ 0, 0, 0 ])\n }\n const min = bbox[0]\n const max = bbox[1]\n\n let r: Float32Array, r2: Float32Array // Atom positions, expanded radii (squared)\n let maxRadius: number\n\n // Parameters\n let probeRadius: number, scaleFactor: number, setAtomID: boolean, probePositions: number\n\n // Cache last value for obscured test\n let lastClip = -1\n\n // Grid params\n let dim: Float32Array, matrix: Float32Array, grid: NumberArray, atomIndex: Int32Array\n\n // grid indices -> xyz coords\n let gridx: Float32Array, gridy: Float32Array, gridz: Float32Array\n\n // Lookup tables:\n let sinTable: Float32Array, cosTable: Float32Array\n\n // Spatial Hash\n let hash: iAVHash\n\n // Neighbour array to be filled by hash\n let neighbours: Int32Array\n\n // Vectors for Torus Projection\n const atob = new Float32Array([ 0.0, 0.0, 0.0 ])\n const mid = new Float32Array([ 0.0, 0.0, 0.0 ])\n const n1 = new Float32Array([ 0.0, 0.0, 0.0 ])\n const n2 = new Float32Array([ 0.0, 0.0, 0.0 ])\n\n let ngTorus: number\n\n function init (_probeRadius?: number, _scaleFactor?: number, _setAtomID?: boolean, _probePositions?: number) {\n probeRadius = defaults(_probeRadius, 1.4)\n scaleFactor = defaults(_scaleFactor, 2.0)\n setAtomID = defaults(_setAtomID, true)\n probePositions = defaults(_probePositions, 30)\n\n r = new Float32Array(nAtoms)\n r2 = new Float32Array(nAtoms)\n\n for (let i = 0; i < r.length; ++i) {\n var rExt = radiusList[ i ] + probeRadius\n r[ i ] = rExt\n r2[ i ] = rExt * rExt\n }\n\n maxRadius = 0\n for (let j = 0; j < r.length; ++j) {\n if (r[ j ] > maxRadius) maxRadius = r[ j ]\n }\n\n initializeGrid()\n initializeAngleTables()\n initializeHash()\n\n lastClip = -1\n }\n\n function fillGridDim (a: Float32Array, start: number, step: number) {\n for (let i = 0; i < a.length; i++) {\n a[i] = start + (step * i)\n }\n }\n\n function initializeGrid () {\n const surfGrid = getSurfaceGrid(\n min, max, maxRadius, scaleFactor, 0.0\n )\n\n scaleFactor = surfGrid.scaleFactor\n dim = surfGrid.dim\n matrix = surfGrid.matrix\n\n ngTorus = Math.max(5, 2 + Math.floor(probeRadius * scaleFactor))\n\n grid = uniformArray(dim[0] * dim[1] * dim[2], -1001.0)\n\n atomIndex = new Int32Array(grid.length)\n\n gridx = new Float32Array(dim[0])\n gridy = new Float32Array(dim[1])\n gridz = new Float32Array(dim[2])\n\n fillGridDim(gridx, min[0], 1 / scaleFactor)\n fillGridDim(gridy, min[1], 1 / scaleFactor)\n fillGridDim(gridz, min[2], 1 / scaleFactor)\n }\n\n function initializeAngleTables () {\n var theta = 0.0\n var step = 2 * Math.PI / probePositions\n\n cosTable = new Float32Array(probePositions)\n sinTable = new Float32Array(probePositions)\n for (var i = 0; i < probePositions; i++) {\n cosTable[ i ] = Math.cos(theta)\n sinTable[ i ] = Math.sin(theta)\n theta += step\n }\n }\n\n function initializeHash () {\n hash = makeAVHash(x, y, z, r, min, max, 2.01 * maxRadius)\n neighbours = new Int32Array(hash.neighbourListLength)\n }\n\n function obscured (x: number, y: number, z: number, a: number, b: number) {\n // Is the point at x,y,z obscured by any of the atoms\n // specifeid by indices in neighbours. Ignore indices\n // a and b (these are the relevant atoms in projectPoints/Torii)\n\n // Cache the last clipped atom (as very often the same one in\n // subsequent calls)\n let ai: number\n\n if (lastClip !== -1) {\n ai = lastClip\n if (ai !== a && ai !== b && singleAtomObscures(ai, x, y, z)) {\n return ai\n } else {\n lastClip = -1\n }\n }\n\n var ni = 0\n ai = neighbours[ ni ]\n while (ai >= 0) {\n if (ai !== a && ai !== b && singleAtomObscures(ai, x, y, z)) {\n lastClip = ai\n return ai\n }\n ai = neighbours[ ++ni ]\n }\n\n lastClip = -1\n\n return -1\n }\n\n function singleAtomObscures (ai: number, x: number, y: number, z: number) {\n var ci = 3 * ai\n var ra2 = r2[ ai ]\n var dx = coordList[ ci ] - x\n var dy = coordList[ ci + 1 ] - y\n var dz = coordList[ ci + 2 ] - z\n var d2 = dx * dx + dy * dy + dz * dz\n\n return d2 < ra2\n }\n\n function projectPoints () {\n // For each atom:\n // Iterate over a subsection of the grid, for each point:\n // If current value < 0.0, unvisited, set positive\n //\n // In any case: Project this point onto surface of the atomic sphere\n // If this projected point is not obscured by any other atom\n // Calcualte delta distance and set grid value to minimum of\n // itself and delta\n\n // Should we alias frequently accessed closure variables??\n // Assume JS engine capable of optimizing this\n // anyway...\n\n for (var i = 0; i < nAtoms; i++) {\n var ax = x[ i ]\n var ay = y[ i ]\n var az = z[ i ]\n var ar = r[ i ]\n var ar2 = r2[ i ]\n\n hash.withinRadii(ax, ay, az, ar, neighbours)\n\n // Number of grid points, round this up...\n var ng = Math.ceil(ar * scaleFactor)\n\n // Center of the atom, mapped to grid points (take floor)\n var iax = Math.floor(scaleFactor * (ax - min[ 0 ]))\n var iay = Math.floor(scaleFactor * (ay - min[ 1 ]))\n var iaz = Math.floor(scaleFactor * (az - min[ 2 ]))\n\n // Extents of grid to consider for this atom\n var minx = Math.max(0, iax - ng)\n var miny = Math.max(0, iay - ng)\n var minz = Math.max(0, iaz - ng)\n\n // Add two to these points:\n // - iax are floor'd values so this ensures coverage\n // - these are loop limits (exclusive)\n var maxx = Math.min(dim[ 0 ], iax + ng + 2)\n var maxy = Math.min(dim[ 1 ], iay + ng + 2)\n var maxz = Math.min(dim[ 2 ], iaz + ng + 2)\n\n for (var ix = minx; ix < maxx; ix++) {\n var dx = gridx[ ix ] - ax\n var xoffset = dim[ 1 ] * dim[ 2 ] * ix\n\n for (var iy = miny; iy < maxy; iy++) {\n var dy = gridy[ iy ] - ay\n var dxy2 = dx * dx + dy * dy\n var xyoffset = xoffset + dim[ 2 ] * iy\n\n for (var iz = minz; iz < maxz; iz++) {\n var dz = gridz[ iz ] - az\n var d2 = dxy2 + dz * dz\n\n if (d2 < ar2) {\n var idx = iz + xyoffset\n\n if (grid[idx] < 0.0) {\n // Unvisited, make positive\n grid[ idx ] = -grid[ idx ]\n }\n // Project on to the surface of the sphere\n // sp is the projected point ( dx, dy, dz ) * ( ra / d )\n var d = Math.sqrt(d2)\n var ap = ar / d\n var spx = dx * ap\n var spy = dy * ap\n var spz = dz * ap\n\n spx += ax\n spy += ay\n spz += az\n\n if (obscured(spx, spy, spz, i, -1) === -1) {\n var dd = ar - d\n if (dd < grid[ idx ]) {\n grid[ idx ] = dd\n if (setAtomID) atomIndex[ idx ] = i\n }\n }\n }\n }\n }\n }\n }\n }\n\n function projectTorii () {\n for (var i = 0; i < nAtoms; i++) {\n hash.withinRadii(x[ i ], y[ i ], z[ i ], r[ i ], neighbours)\n var ia = 0\n var ni = neighbours[ ia ]\n while (ni >= 0) {\n if (i < ni) {\n projectTorus(i, ni)\n }\n ni = neighbours[ ++ia ]\n }\n }\n }\n\n function projectTorus (a: number, b: number) {\n var r1 = r[ a ]\n var r2 = r[ b ]\n var dx = atob[ 0 ] = x[ b ] - x[ a ]\n var dy = atob[ 1 ] = y[ b ] - y[ a ]\n var dz = atob[ 2 ] = z[ b ] - z[ a ]\n var d2 = dx * dx + dy * dy + dz * dz\n\n // This check now redundant as already done in AVHash.withinRadii\n // if( d2 > (( r1 + r2 ) * ( r1 + r2 )) ){ return; }\n\n var d = Math.sqrt(d2)\n\n // Find angle between a->b vector and the circle\n // of their intersection by cosine rule\n var cosA = (r1 * r1 + d * d - r2 * r2) / (2.0 * r1 * d)\n\n // distance along a->b at intersection\n var dmp = r1 * cosA\n\n v3normalize(atob, atob)\n\n // Create normal to line\n normalToLine(n1 as any, atob)\n v3normalize(n1, n1)\n\n // Cross together for second normal vector\n v3cross(n2, atob, n1)\n v3normalize(n2, n2)\n\n // r is radius of circle of intersection\n var rInt = Math.sqrt(r1 * r1 - dmp * dmp)\n\n v3multiplyScalar(n1, n1, rInt)\n v3multiplyScalar(n2, n2, rInt)\n v3multiplyScalar(atob, atob, dmp)\n\n mid[ 0 ] = atob[ 0 ] + x[ a ]\n mid[ 1 ] = atob[ 1 ] + y[ a ]\n mid[ 2 ] = atob[ 2 ] + z[ a ]\n\n lastClip = -1\n\n var ng = ngTorus\n\n for (var i = 0; i < probePositions; i++) {\n var cost = cosTable[ i ]\n var sint = sinTable[ i ]\n\n var px = mid[ 0 ] + cost * n1[ 0 ] + sint * n2[ 0 ]\n var py = mid[ 1 ] + cost * n1[ 1 ] + sint * n2[ 1 ]\n var pz = mid[ 2 ] + cost * n1[ 2 ] + sint * n2[ 2 ]\n\n if (obscured(px, py, pz, a, b) === -1) {\n // As above, iterate over our grid...\n // px, py, pz in grid coords\n var iax = Math.floor(scaleFactor * (px - min[ 0 ]))\n var iay = Math.floor(scaleFactor * (py - min[ 1 ]))\n var iaz = Math.floor(scaleFactor * (pz - min[ 2 ]))\n\n var minx = Math.max(0, iax - ng)\n var miny = Math.max(0, iay - ng)\n var minz = Math.max(0, iaz - ng)\n\n var maxx = Math.min(dim[ 0 ], iax + ng + 2)\n var maxy = Math.min(dim[ 1 ], iay + ng + 2)\n var maxz = Math.min(dim[ 2 ], iaz + ng + 2)\n\n for (var ix = minx; ix < maxx; ix++) {\n dx = px - gridx[ ix ]\n var xoffset = dim[ 1 ] * dim[ 2 ] * ix\n\n for (var iy = miny; iy < maxy; iy++) {\n dy = py - gridy[ iy ]\n var dxy2 = dx * dx + dy * dy\n var xyoffset = xoffset + dim[ 2 ] * iy\n\n for (var iz = minz; iz < maxz; iz++) {\n dz = pz - gridz[ iz ]\n d2 = dxy2 + dz * dz\n var idx = iz + xyoffset\n var current = grid[ idx ]\n\n if (current > 0.0 && d2 < (current * current)) {\n grid[ idx ] = Math.sqrt(d2)\n if (setAtomID) {\n // Is this grid point closer to a or b?\n // Take dot product of atob and gridpoint->p (dx, dy, dz)\n const dp = dx * atob[ 0 ] + dy * atob [ 1 ] + dz * atob[ 2 ]\n atomIndex[ idx ] = dp < 0.0 ? b : a\n }\n }\n }\n }\n }\n }\n }\n }\n\n function normalToLine (out: Int32Array, p: Float32Array) {\n out[ 0 ] = out[ 1 ] = out[ 2 ] = 1.0\n if (p[ 0 ] !== 0) {\n out[ 0 ] = (p[ 1 ] + p[ 2 ]) / -p[ 0 ]\n } else if (p[ 1 ] !== 0) {\n out[ 1 ] = (p[ 0 ] + p[ 2 ]) / -p[ 1 ]\n } else if (p[ 2 ] !== 0) {\n out[ 2 ] = (p[ 0 ] + p[ 1 ]) / -p[ 2 ]\n }\n return out\n }\n\n function fixNegatives () {\n for (var i = 0; i < grid.length; i++) {\n if (grid[ i ] < 0) grid[ i ] = 0\n }\n }\n\n function fixAtomIDs () {\n for (var i = 0; i < atomIndex.length; i++) {\n atomIndex[ i ] = indexList[ atomIndex[ i ] ]\n }\n }\n\n function getVolume (probeRadius: number, scaleFactor: number, setAtomID: boolean) {\n // Basic steps are:\n // 1) Initialize\n // 2) Project points\n // 3) Project torii\n\n console.time('AVSurface.getVolume')\n\n console.time('AVSurface.init')\n init(probeRadius, scaleFactor, setAtomID)\n console.timeEnd('AVSurface.init')\n\n console.time('AVSurface.projectPoints')\n projectPoints()\n console.timeEnd('AVSurface.projectPoints')\n\n console.time('AVSurface.projectTorii')\n projectTorii()\n console.timeEnd('AVSurface.projectTorii')\n fixNegatives()\n fixAtomIDs()\n\n console.timeEnd('AVSurface.getVolume')\n }\n\n this.getSurface = function (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean, smooth: number, contour: boolean) {\n // type and cutoff left in for compatibility with EDTSurface.getSurface\n // function signature\n\n getVolume(probeRadius, scaleFactor, setAtomID)\n\n var volsurf = new (VolumeSurface as any)(\n grid, dim[ 2 ], dim[ 1 ], dim[ 0 ], atomIndex\n ) as VolumeSurface\n\n return volsurf.getSurface!(probeRadius, false, undefined, matrix, contour)\n }\n}\nObject.assign(AVSurface, {__deps: [\n getSurfaceGrid, VolumeSurface, uniformArray, computeBoundingBox,\n v3multiplyScalar, v3cross, v3normalize,\n makeAVHash,\n defaults\n]})\n\nexport { AVSurface, makeAVHash }\n","/**\n * @file Molecular Surface\n * @author Alexander Rose \n * @private\n */\n\nimport { WorkerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Worker from '../worker/worker'\nimport EDTSurface from './edt-surface'\nimport { AVSurface } from './av-surface'\nimport Surface, { SurfaceData } from './surface'\nimport { Structure } from '../ngl';\nimport { AtomData, RadiusParams } from '../structure/structure-data';\n\nWorkerRegistry.add('molsurf', function func (e: any, callback: (data: any, buffers: any[])=> void) {\n const a = e.data.args\n const p = e.data.params\n if (a && p) {\n const SurfClass = (p.type === 'av') ? AVSurface : EDTSurface\n const surf = new (SurfClass as any)(a.coordList, a.radiusList, a.indexList) as AVSurface|EDTSurface\n const sd = surf.getSurface(\n p.type, p.probeRadius, p.scaleFactor, p.cutoff, true, p.smooth, p.contour\n ) as SurfaceData\n const transferList = [ sd.position.buffer, sd.index!.buffer ]\n if (sd.normal) transferList.push(sd.normal.buffer)\n if (sd.atomindex) transferList.push(sd.atomindex.buffer)\n const data = {\n sd: sd,\n p: p\n }\n callback(data, transferList)\n }\n}, [ EDTSurface, AVSurface ])\n\n/**\n * Molecular surface parameter object.\n * @typedef {Object} MolecularSurfaceParameters - stage parameters\n * @property {String} type - \"av\" or \"edt\"\n * @property {Number} probeRadius - probe radius\n * @property {Number} scaleFactor - higher for better quality\n * @property {Integer} smooth - number of smoothing cycles to apply\n * @property {String} name - name for created surface\n */\nexport interface MolecularSurfaceParameters {\n type: 'av'|'edt'\n probeRadius: number\n scaleFactor: number\n smooth: number\n name: string\n cutoff: number\n contour: boolean,\n radiusParams: RadiusParams\n}\n/**\n * Create Molecular surfaces\n */\nclass MolecularSurface {\n structure: Structure\n worker: Worker|undefined\n\n constructor (structure: Structure) {\n this.structure = structure\n }\n\n _getAtomData (params: Partial): AtomData {\n return this.structure.getAtomData({\n what: { position: true, radius: true, index: true },\n radiusParams: defaults(params.radiusParams, {\n type: 'vdw', scale: 1.0\n })\n })\n }\n\n _makeSurface (sd: SurfaceData, p: Partial) {\n var surface = new Surface(p.name!, '', sd)\n\n surface.info.type = p.type\n surface.info.probeRadius = p.probeRadius\n surface.info.scaleFactor = p.scaleFactor\n surface.info.smooth = p.smooth\n surface.info.cutoff = p.cutoff\n\n return surface\n }\n\n /**\n * Get molecular surface\n * @param {MolecularSurfaceParameters} params - parameters for surface creation\n * @return {Surface} the surface\n */\n getSurface (params: Partial) {\n const p = params || {}\n\n const atomData = this._getAtomData(params)\n const coordList = atomData.position\n const radiusList = atomData.radius\n const indexList = atomData.index\n\n const SurfClass = (p.type === 'av') ? AVSurface : EDTSurface\n const surf = new (SurfClass as any)(coordList, radiusList, indexList) as AVSurface|EDTSurface\n const sd = surf.getSurface(\n p.type!, p.probeRadius!, p.scaleFactor!, p.cutoff!, true, p.smooth!, p.contour!\n )\n\n return this._makeSurface(sd, p)\n }\n\n /**\n * Get molecular surface asynchronous\n * @param {MolecularSurfaceParameters} params - parameters for surface creation\n * @param {function(surface: Surface)} callback - function to be called after surface is created\n * @return {undefined}\n */\n getSurfaceWorker (params: MolecularSurfaceParameters, callback: (s: Surface) => void) {\n const p = Object.assign({}, params)\n\n if (window.hasOwnProperty('Worker')) {\n if (this.worker === undefined) {\n this.worker = new Worker('molsurf')\n }\n\n const atomData = this._getAtomData(params)\n const coordList = atomData.position\n const radiusList = atomData.radius\n const indexList = atomData.index\n\n const msg = {\n args: {\n coordList: coordList,\n radiusList: radiusList,\n indexList: indexList\n },\n params: p\n }\n\n const transferList = [\n coordList!.buffer, radiusList!.buffer, indexList!.buffer\n ]\n\n this.worker.post(msg, transferList,\n\n (e: any) => {\n callback(this._makeSurface(e.data.sd, p))\n },\n\n (e: string) => {\n console.warn(\n 'MolecularSurface.getSurfaceWorker error - trying without worker', e\n )\n this.worker!.terminate()\n this.worker = undefined\n const surface = this.getSurface(p)\n callback(surface)\n }\n\n )\n } else {\n const surface = this.getSurface(p)\n callback(surface)\n }\n }\n\n /**\n * Cleanup\n * @return {undefined}\n */\n dispose () {\n if (this.worker) this.worker.terminate()\n }\n}\n\nexport default MolecularSurface\n","/**\n * @file Molecular Surface Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport MolecularSurface, { MolecularSurfaceParameters } from '../surface/molecular-surface'\nimport SurfaceBuffer from '../buffer/surface-buffer'\nimport ContourBuffer from '../buffer/contour-buffer'\nimport DoubleSidedBuffer from '../buffer/doublesided-buffer'\nimport Selection from '../selection/selection'\nimport Viewer from '../viewer/viewer';\n// @ts-ignore: unused import Volume required for declaration only\nimport { Structure, Vector3, Volume } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport { SurfaceDataFields } from './surface-representation';\nimport Surface, {SurfaceData} from '../surface/surface';\n\nexport interface MolecularSurfaceRepresentationParameters extends StructureRepresentationParameters {\n surfaceType: 'vws'|'sas'|'ms'|'ses'|'av'\n probeRadius: number\n smooth: number\n scaleFactor: number\n cutoff: number\n contour: boolean\n background: boolean\n opaqueBack: boolean\n filterSele: string\n colorVolume: any\n useWorker: boolean\n}\n\nexport interface MolecularSurfaceInfo {\n molsurf?: MolecularSurface\n sele?: string\n surface?: Surface\n}\n\n/**\n * Molecular Surface Representation\n */\nclass MolecularSurfaceRepresentation extends StructureRepresentation {\n protected surfaceType: 'vws'|'sas'|'ms'|'ses'|'av'\n protected probeRadius: number\n protected smooth: number\n protected scaleFactor: number\n protected cutoff: number\n protected contour: boolean\n protected background: boolean\n protected opaqueBack: boolean\n protected filterSele: string\n protected colorVolume: any\n protected useWorker: boolean\n\n protected __infoList: MolecularSurfaceInfo[]\n protected __forceNewMolsurf: boolean\n protected __sele: string\n protected __surfaceParams: string\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'surface'\n\n this.parameters = Object.assign({\n\n surfaceType: {\n type: 'select',\n rebuild: true,\n options: {\n 'vws': 'vws',\n 'sas': 'sas',\n 'ms': 'ms',\n 'ses': 'ses',\n 'av': 'av'\n }\n },\n probeRadius: {\n type: 'number',\n precision: 1,\n max: 20,\n min: 0,\n rebuild: true\n },\n smooth: {\n type: 'integer',\n precision: 1,\n max: 10,\n min: 0,\n rebuild: true\n },\n scaleFactor: {\n type: 'number',\n precision: 1,\n max: 5,\n min: 0,\n rebuild: true\n },\n cutoff: {\n type: 'number',\n precision: 2,\n max: 50,\n min: 0,\n rebuild: true\n },\n contour: {\n type: 'boolean', rebuild: true\n },\n background: {\n type: 'boolean', rebuild: true // FIXME\n },\n opaqueBack: {\n type: 'boolean', buffer: true\n },\n filterSele: {\n type: 'text', rebuild: true\n },\n colorVolume: {\n type: 'hidden'\n },\n useWorker: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n\n radius: null,\n scale: null\n\n })\n\n this.__infoList = []\n\n // TODO find a more direct way\n this.structure.signals.refreshed.add(() => {\n this.__forceNewMolsurf = true\n })\n\n this.toBePrepared = true\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'uniform')\n p.colorValue = defaults(p.colorValue, 0xDDDDDD)\n p.disablePicking = defaults(p.disablePicking, true)\n\n this.surfaceType = defaults(p.surfaceType, 'ms')\n this.probeRadius = defaults(p.probeRadius, 1.4)\n this.smooth = defaults(p.smooth, 2)\n this.scaleFactor = defaults(p.scaleFactor, 2.0)\n this.cutoff = defaults(p.cutoff, 0.0)\n this.contour = defaults(p.contour, false)\n this.background = defaults(p.background, false)\n this.opaqueBack = defaults(p.opaqueBack, true)\n this.filterSele = defaults(p.filterSele, '')\n this.colorVolume = defaults(p.colorVolume, undefined)\n this.useWorker = defaults(p.useWorker, true)\n\n super.init(params)\n }\n\n prepareData (sview: StructureView, i: number, callback: (i: number) => void) {\n let info: MolecularSurfaceInfo = this.__infoList[ i ]\n if (!info) {\n info = {}\n this.__infoList[ i ] = info\n }\n\n if (!info.molsurf || info.sele !== sview.selection.string) {\n if (this.filterSele) {\n const sviewFilter = sview.structure.getView(new Selection(this.filterSele))\n const bbSize = sviewFilter.boundingBox.getSize(new Vector3())\n const maxDim = Math.max(bbSize.x, bbSize.y, bbSize.z)\n const asWithin = sview.getAtomSetWithinPoint(sviewFilter.center, (maxDim / 2) + 6.0)\n sview = sview.getView(\n new Selection(sview.getAtomSetWithinSelection(asWithin, 3).toSeleString())\n )\n if (sview.atomCount === 0) {\n callback(i)\n return\n }\n }\n\n info.sele = sview.selection.string\n info.molsurf = new MolecularSurface(sview)\n\n const p = this.getSurfaceParams()\n const onSurfaceFinish = (surface: Surface) => {\n info.surface = surface\n callback(i)\n }\n\n if (this.useWorker) {\n info.molsurf.getSurfaceWorker(p as MolecularSurfaceParameters, onSurfaceFinish)\n } else {\n onSurfaceFinish(info.molsurf.getSurface(p as {name: string, type: 'av'|'edt' } & MolecularSurfaceRepresentationParameters))\n }\n } else {\n callback(i)\n }\n }\n\n prepare (callback: () => void) {\n if (this.__forceNewMolsurf || this.__sele !== this.selection.string ||\n this.__surfaceParams !== JSON.stringify(this.getSurfaceParams())) {\n this.__infoList.forEach((info: MolecularSurfaceInfo) => {\n if (info && info.molsurf) {\n info.molsurf.dispose()\n }\n })\n this.__infoList.length = 0\n }\n\n if (this.structureView.atomCount === 0) {\n callback()\n return\n }\n\n const after = () => {\n this.__sele = this.selection.string\n this.__surfaceParams = JSON.stringify(this.getSurfaceParams())\n this.__forceNewMolsurf = false\n callback()\n }\n\n const name = this.assembly === 'default' ? this.defaultAssembly : this.assembly\n const assembly = this.structure.biomolDict[ name ]\n\n if (assembly) {\n assembly.partList.forEach((part, i) => {\n const sview = part.getView(this.structureView)\n this.prepareData(sview as StructureView, i, (_i) => {\n if (_i === assembly.partList.length - 1) after()\n })\n })\n } else {\n this.prepareData(this.structureView, 0, after)\n }\n }\n\n createData (sview: StructureView, i: number) {\n const info = this.__infoList[ i ]\n const surface = info.surface\n\n if (!surface) {\n // Surface creation bailed (no surface generated for this sview)\n return\n }\n\n const surfaceData = {\n position: surface!.getPosition(),\n color: surface!.getColor(this.getColorParams()),\n index: surface!.getFilteredIndex(this.filterSele, sview)\n }\n\n const bufferList = []\n\n if (surface.contour) {\n const contourBuffer = new ContourBuffer(\n surfaceData,\n this.getBufferParams({\n wireframe: false\n })\n )\n\n bufferList.push(contourBuffer)\n } else {\n Object.assign(surfaceData, {\n normal: surface.getNormal(),\n picking: surface.getPicking(sview.getStructure())\n })\n\n const surfaceBuffer = new SurfaceBuffer(\n surfaceData,\n this.getBufferParams({\n background: this.background,\n opaqueBack: this.opaqueBack,\n dullInterior: false\n })\n )\n\n if (this.getBufferParams().side == 'double') {\n const doubleSidedBuffer = new DoubleSidedBuffer(surfaceBuffer)\n bufferList.push(doubleSidedBuffer)\n }\n else {\n bufferList.push(surfaceBuffer)\n }\n }\n\n return { bufferList, info } as StructureRepresentationData\n }\n\n updateData (what: SurfaceDataFields, data: StructureRepresentationData) {\n const surfaceData: Partial = {}\n\n if (what.position || what.radius) {\n this.__forceNewMolsurf = true\n this.build()\n return\n }\n\n if (what.color) {\n surfaceData.color = data.info.surface.getColor(this.getColorParams())\n }\n\n if (what.index) {\n surfaceData.index = data.info.surface.getFilteredIndex(this.filterSele, data.sview)\n }\n\n data.bufferList[ 0 ].setAttributes(surfaceData)\n }\n\n setParameters (params: Partial, what: Partial = {}, rebuild?: boolean) {\n if (params && params.filterSele) {\n what.index = true\n }\n\n if (params && params.colorVolume !== undefined) {\n what.color = true\n }\n\n // forbid setting wireframe to true when contour is true\n if (params && params.wireframe && (\n params.contour || (params.contour === undefined && this.contour)\n )\n ) {\n params.wireframe = false\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n\n getSurfaceParams (params: Partial = {}) {\n const p = Object.assign({\n type: this.surfaceType as string,\n probeRadius: this.probeRadius as number,\n scaleFactor: this.scaleFactor as number,\n smooth: this.smooth && !this.contour,\n cutoff: this.cutoff as number,\n contour: this.contour as boolean,\n useWorker: this.useWorker as boolean,\n radiusParams: this.getRadiusParams()\n }, params)\n\n return p\n }\n\n getColorParams () {\n const p = super.getColorParams()\n\n p.volume = this.colorVolume\n\n return p\n }\n\n getAtomRadius () {\n return 0\n }\n\n clear () {\n super.clear()\n }\n\n dispose () {\n this.__infoList.forEach((info: MolecularSurfaceInfo) => {\n if (info && info.molsurf) {\n info.molsurf.dispose()\n }\n })\n this.__infoList.length = 0\n\n super.dispose()\n }\n}\n\nRepresentationRegistry.add('surface', MolecularSurfaceRepresentation)\n\nexport default MolecularSurfaceRepresentation\n","/**\n * @file Point Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport PointBuffer from '../buffer/point-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { AtomDataFields } from '../structure/structure-data';\n\nexport interface PointRepresentationParameters extends StructureRepresentationParameters {\n pointSize: number\n sizeAttenuation: boolean\n sortParticles: boolean\n useTexture: boolean\n alphaTest: number\n forceTransparent: boolean\n edgeBleach: number\n}\n\n/**\n * Point Representation\n */\nclass PointRepresentation extends StructureRepresentation {\n protected pointSize: number\n protected sizeAttenuation: boolean\n protected sortParticles: boolean\n protected useTexture: boolean\n protected alphaTest: number\n protected forceTransparent: boolean\n protected edgeBleach: number\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'point'\n\n this.parameters = Object.assign({\n\n pointSize: {\n type: 'number', precision: 1, max: 100, min: 0, buffer: true\n },\n sizeAttenuation: {\n type: 'boolean', buffer: true\n },\n sortParticles: {\n type: 'boolean', rebuild: true\n },\n useTexture: {\n type: 'boolean', buffer: true\n },\n alphaTest: {\n type: 'range', step: 0.001, max: 1, min: 0, buffer: true\n },\n forceTransparent: {\n type: 'boolean', buffer: true\n },\n edgeBleach: {\n type: 'range', step: 0.001, max: 1, min: 0, buffer: true\n }\n\n }, this.parameters, {\n\n flatShaded: null,\n wireframe: null,\n linewidth: null,\n side: null,\n\n roughness: null,\n metalness: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n\n this.pointSize = defaults(p.pointSize, 1)\n this.sizeAttenuation = defaults(p.sizeAttenuation, true)\n this.sortParticles = defaults(p.sortParticles, false)\n this.useTexture = defaults(p.useTexture, false)\n this.alphaTest = defaults(p.alphaTest, 0.5)\n this.forceTransparent = defaults(p.forceTransparent, false)\n this.edgeBleach = defaults(p.edgeBleach, 0.0)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n var what = { position: true, color: true, picking: true }\n var atomData = sview.getAtomData(this.getAtomParams(what))\n\n var pointBuffer = new PointBuffer(\n atomData,\n this.getBufferParams({\n pointSize: this.pointSize,\n sizeAttenuation: this.sizeAttenuation,\n sortParticles: this.sortParticles,\n useTexture: this.useTexture,\n alphaTest: this.alphaTest,\n forceTransparent: this.forceTransparent,\n edgeBleach: this.edgeBleach\n })\n )\n\n return {\n bufferList: [ pointBuffer ]\n }\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n var atomData = data.sview!.getAtomData(this.getAtomParams(what))\n var pointData = {}\n\n if (!what || what.position) {\n Object.assign(pointData, {position: atomData.position})\n }\n\n if (!what || what.color) {\n Object.assign(pointData, {color: atomData.color})\n }\n\n data.bufferList[ 0 ].setAttributes(pointData)\n }\n\n getAtomRadius () {\n return 0.1\n }\n}\n\nRepresentationRegistry.add('point', PointRepresentation)\n\nexport default PointRepresentation\n","/**\n * @file Ribbon Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport '../shader/Ribbon.vert'\n\nimport { getUintArray } from '../utils'\nimport { serialArray } from '../math/array-utils'\nimport MeshBuffer from './mesh-buffer'\nimport { BufferParameters, BufferData } from './buffer'\nimport {Log} from \"../globals\";\n\nconst quadIndices = new Uint16Array([\n 0, 1, 2,\n 1, 3, 2\n])\n\nexport interface RibbonBufferData extends BufferData {\n normal: Float32Array\n dir: Float32Array\n size: Float32Array\n}\n\nfunction getSize(data: RibbonBufferData){\n const n = (data.position!.length / 3) - 1\n const n4 = n * 4\n const x = n4 * 3\n return x\n}\n\n/**\n * Ribbon buffer. Draws a thin ribbon.\n */\nclass RibbonBuffer extends MeshBuffer {\n vertexShader = 'Ribbon.vert'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.normal - normals\n * @param {Float32Array} data.dir - binormals\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.size - sizes\n * @param {Picker} data.picking - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: RibbonBufferData, params: Partial = {}) {\n super({\n position: new Float32Array(getSize(data)),\n color: new Float32Array(getSize(data)),\n index: getUintArray(getSize(data), getSize(data) / 3),\n normal: new Float32Array(getSize(data)),\n picking: data.picking\n }, params)\n\n const n = (data.position!.length / 3) - 1\n const n4 = n * 4\n const x = n4 * 3\n\n this.addAttributes({\n 'dir': { type: 'v3', value: new Float32Array(x) }\n })\n this.addAttributes({\n 'size': { type: 'f', value: new Float32Array(n4) }\n })\n\n data.primitiveId = serialArray(n)\n this.setAttributes(data)\n\n this.makeIndex()\n }\n\n setAttributes (data: Partial = {}) {\n const n4 = this.size\n const n = n4 / 4\n\n const attributes = this.geometry.attributes as any // TODO\n\n let position, normal, size, dir, color, primitiveId\n let aPosition, aNormal, aSize, aDir, aColor, aPrimitiveId\n\n if (data.position) {\n position = data.position\n aPosition = attributes.position.array\n attributes.position.needsUpdate = true\n }\n\n if (data.normal) {\n normal = data.normal\n aNormal = attributes.normal.array\n attributes.normal.needsUpdate = true\n }\n\n if (data.size) {\n size = data.size\n aSize = attributes.size.array\n attributes.size.needsUpdate = true\n }\n\n if (data.dir) {\n dir = data.dir\n aDir = attributes.dir.array\n attributes.dir.needsUpdate = true\n }\n\n if (data.color) {\n color = data.color\n aColor = attributes.color.array\n attributes.color.needsUpdate = true\n }\n\n if (data.primitiveId) {\n primitiveId = data.primitiveId\n aPrimitiveId = attributes.primitiveId.array\n attributes.primitiveId.needsUpdate = true\n }\n\n let v, i, k, p, l, v3\n let currSize\n let prevSize = size ? size[ 0 ] : null\n\n for (v = 0; v < n; ++v) {\n v3 = v * 3\n k = v * 3 * 4\n l = v * 4\n\n if (position) {\n aPosition[ k ] = aPosition[ k + 3 ] = position[ v3 ]\n aPosition[ k + 1 ] = aPosition[ k + 4 ] = position[ v3 + 1 ]\n aPosition[ k + 2 ] = aPosition[ k + 5 ] = position[ v3 + 2 ]\n\n aPosition[ k + 6 ] = aPosition[ k + 9 ] = position[ v3 + 3 ]\n aPosition[ k + 7 ] = aPosition[ k + 10 ] = position[ v3 + 4 ]\n aPosition[ k + 8 ] = aPosition[ k + 11 ] = position[ v3 + 5 ]\n }\n\n if (normal) {\n aNormal[ k ] = aNormal[ k + 3 ] = -normal[ v3 ]\n aNormal[ k + 1 ] = aNormal[ k + 4 ] = -normal[ v3 + 1 ]\n aNormal[ k + 2 ] = aNormal[ k + 5 ] = -normal[ v3 + 2 ]\n\n aNormal[ k + 6 ] = aNormal[ k + 9 ] = -normal[ v3 + 3 ]\n aNormal[ k + 7 ] = aNormal[ k + 10 ] = -normal[ v3 + 4 ]\n aNormal[ k + 8 ] = aNormal[ k + 11 ] = -normal[ v3 + 5 ]\n }\n\n for (i = 0; i < 4; ++i) {\n p = k + 3 * i\n\n if (color) {\n aColor[ p ] = color[ v3 ]\n aColor[ p + 1 ] = color[ v3 + 1 ]\n aColor[ p + 2 ] = color[ v3 + 2 ]\n }\n\n if (primitiveId) {\n aPrimitiveId[ l + i ] = primitiveId[ v ]\n }\n }\n\n if (size) {\n currSize = size[ v ]\n\n if (prevSize !== size[ v ]) {\n aSize[ l ] = prevSize\n aSize[ l + 1 ] = prevSize\n aSize[ l + 2 ] = currSize\n aSize[ l + 3 ] = currSize\n } else {\n aSize[ l ] = currSize\n aSize[ l + 1 ] = currSize\n aSize[ l + 2 ] = currSize\n aSize[ l + 3 ] = currSize\n }\n\n prevSize = currSize\n }\n\n if (dir) {\n aDir[ k ] = dir[ v3 ]\n aDir[ k + 1 ] = dir[ v3 + 1 ]\n aDir[ k + 2 ] = dir[ v3 + 2 ]\n\n aDir[ k + 3 ] = -dir[ v3 ]\n aDir[ k + 4 ] = -dir[ v3 + 1 ]\n aDir[ k + 5 ] = -dir[ v3 + 2 ]\n\n aDir[ k + 6 ] = dir[ v3 + 3 ]\n aDir[ k + 7 ] = dir[ v3 + 4 ]\n aDir[ k + 8 ] = dir[ v3 + 5 ]\n\n aDir[ k + 9 ] = -dir[ v3 + 3 ]\n aDir[ k + 10 ] = -dir[ v3 + 4 ]\n aDir[ k + 11 ] = -dir[ v3 + 5 ]\n }\n }\n }\n\n makeIndex () {\n const index = this.geometry.getIndex()\n if (!index) { Log.error('Index is null'); return; }\n const meshIndex = index.array as Uint32Array|Uint16Array\n const n = meshIndex.length / 4 / 3\n\n for (let v = 0; v < n; ++v) {\n const ix = v * 6\n const it = v * 4\n\n meshIndex.set(quadIndices, ix)\n for (let s = 0; s < 6; ++s) {\n meshIndex[ ix + s ] += it\n }\n }\n }\n}\n\nexport default RibbonBuffer\n","/**\n * @file Ribbon Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Spline, { SplineParameters } from '../geometry/spline'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport RibbonBuffer from '../buffer/ribbon-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport StructureView from '../structure/structure-view';\nimport Polymer from '../proxy/polymer';\n\nexport interface RibbonRepresentationParameters extends StructureRepresentationParameters {\n subdiv: number\n tension: number\n smoothSheet: boolean\n}\n\n/**\n * Ribbon Representation\n */\nclass RibbonRepresentation extends StructureRepresentation {\n protected subdiv: number\n protected tension: number\n protected smoothSheet: boolean\n \n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'ribbon'\n\n this.parameters = Object.assign({\n\n subdiv: {\n type: 'integer', max: 50, min: 1, rebuild: true\n },\n tension: {\n type: 'number', precision: 1, max: 1.0, min: 0.1\n },\n smoothSheet: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n\n side: null,\n wireframe: null,\n linewidth: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'chainname')\n p.colorScale = defaults(p.colorScale, 'RdYlBu')\n p.radiusType = defaults(p.radiusType, 'sstruc')\n p.radiusScale = defaults(p.radiusScale, 4.0)\n\n if (p.quality === 'low') {\n this.subdiv = 3\n } else if (p.quality === 'medium') {\n this.subdiv = 6\n } else if (p.quality === 'high') {\n this.subdiv = 12\n } else {\n this.subdiv = defaults(p.subdiv, 6)\n }\n\n this.tension = defaults(p.tension, NaN)\n this.smoothSheet = defaults(p.smoothSheet, false)\n\n super.init(p)\n }\n\n getSplineParams (params?: Partial) {\n return Object.assign({\n subdiv: this.subdiv,\n tension: this.tension,\n directional: true,\n smoothSheet: this.smoothSheet\n }, params)\n }\n\n getAtomRadius (atom: AtomProxy) {\n return atom.isTrace() ? super.getAtomRadius(atom) : 0\n }\n\n createData (sview: StructureView) {\n var bufferList: RibbonBuffer[] = []\n var polymerList: Polymer[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4) return\n polymerList.push(polymer)\n\n var spline = new Spline(polymer, this.getSplineParams())\n var subPos = spline.getSubdividedPosition()\n var subOri = spline.getSubdividedOrientation()\n var subCol = spline.getSubdividedColor(this.getColorParams())\n var subPick = spline.getSubdividedPicking()\n var subSize = spline.getSubdividedSize(this.getRadiusParams())\n\n bufferList.push(\n new RibbonBuffer(\n ({\n position: subPos.position,\n normal: subOri.binormal,\n dir: subOri.normal,\n color: subCol.color,\n size: subSize.size,\n picking: subPick.picking\n }),\n this.getBufferParams()\n )\n )\n }, sview.getSelection())\n\n return {\n bufferList: bufferList,\n polymerList: polymerList\n }\n }\n\n updateData (what: {position?: boolean, radius?: boolean, scale?: boolean, color?: boolean}, data: {polymerList: Polymer[], bufferList: RibbonBuffer[]}) {\n what = what || {}\n\n var i = 0\n var n = data.polymerList.length\n\n for (i = 0; i < n; ++i) {\n var bufferData = {}\n var spline = new Spline(data.polymerList[ i ], this.getSplineParams())\n\n if (what.position) {\n var subPos = spline.getSubdividedPosition()\n var subOri = spline.getSubdividedOrientation()\n Object.assign(bufferData, {\n position: subPos.position,\n normal: subOri.binormal,\n dir: subOri.normal\n })\n }\n\n if (what.radius || what.scale) {\n var subSize = spline.getSubdividedSize(this.getRadiusParams())\n Object.assign(bufferData, {size: subSize.size})\n }\n\n if (what.color) {\n var subCol = spline.getSubdividedColor(this.getColorParams())\n Object.assign(bufferData, {color: subCol.color})\n }\n\n data.bufferList[ i ].setAttributes(bufferData)\n }\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n if (params && params.tension) {\n Object.assign(what, {position: true})\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('ribbon', RibbonRepresentation)\n\nexport default RibbonRepresentation\n","/**\n * @file Rocket Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { AtomPicker } from '../utils/picker'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport Helixbundle, { Axis } from '../geometry/helixbundle'\nimport CylinderBuffer from '../buffer/cylinder-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport CylinderImpostorBuffer from '../buffer/cylinderimpostor-buffer';\n\nexport interface RocketRepresentationParameters extends StructureRepresentationParameters {\n localAngle: number\n centerDist: number\n ssBorder: boolean\n radialSegments: number\n openEnded: boolean\n disableImpostor: boolean\n}\n\nexport interface AxisData {\n begin: Float32Array\n end: Float32Array\n size: Float32Array\n color: Float32Array\n picking: AtomPicker\n}\n\n/**\n * Rocket Representation\n */\nclass RocketRepresentation extends StructureRepresentation {\n\n protected localAngle: number\n protected centerDist: number\n protected ssBorder: boolean\n protected radialSegments: number\n protected openEnded: boolean\n protected disableImpostor: boolean\n // protected helixbundleList: Helixbundle[]\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'rocket'\n\n this.parameters = Object.assign({\n\n localAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n centerDist: {\n type: 'number', precision: 1, max: 10, min: 0, rebuild: true\n },\n ssBorder: {\n type: 'boolean', rebuild: true\n },\n radialSegments: true,\n openEnded: true,\n disableImpostor: true\n\n }, this.parameters)\n\n // this.helixbundleList = []\n\n this.init(params)\n }\n\n init (params: Partial) {\n let p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'sstruc')\n p.radiusSize = defaults(p.radiusSize, 1.5)\n p.radiusScale = defaults(p.radiusScale, 1.0)\n p.openEnded = defaults(p.openEnded, false)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.localAngle = defaults(p.localAngle, 30)\n this.centerDist = defaults(p.centerDist, 2.5)\n this.ssBorder = defaults(p.ssBorder, false)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n let length = 0\n const axisList:Axis[] = []\n const helixbundleList:Helixbundle[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4 || polymer.isNucleic()) return\n\n const helixbundle = new Helixbundle(polymer)\n const axis = helixbundle.getAxis(\n this.localAngle, this.centerDist, this.ssBorder,\n this.getColorParams(), this.getRadiusParams()\n )\n\n length += axis.size.length\n axisList.push(axis)\n helixbundleList.push(helixbundle)\n }, sview.getSelection())\n\n const axisData = {\n begin: new Float32Array(length * 3),\n end: new Float32Array(length * 3),\n size: new Float32Array(length),\n color: new Float32Array(length * 3),\n picking: {}\n }\n\n let picking = new Float32Array(length)\n\n let offset = 0\n\n axisList.forEach(function (axis) {\n axisData.begin.set(axis.begin, offset * 3)\n axisData.end.set(axis.end, offset * 3)\n axisData.size.set(axis.size, offset)\n axisData.color.set(axis.color, offset * 3)\n picking.set(axis.picking.array!, offset)\n offset += axis.size.length\n })\n\n if (length) {\n axisData.picking = new AtomPicker(\n picking, sview.getStructure()\n )\n }\n\n const cylinderBuffer = new CylinderBuffer(\n {\n position1: axisData.begin,\n position2: axisData.end,\n color: axisData.color,\n color2: axisData.color,\n radius: axisData.size,\n picking: axisData.picking\n },\n this.getBufferParams({\n openEnded: this.openEnded,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n return {\n bufferList: [ cylinderBuffer as CylinderGeometryBuffer|CylinderImpostorBuffer ],\n axisList: axisList,\n helixbundleList: helixbundleList,\n axisData: axisData\n }\n }\n\n \n updateData (what: any, data: {bufferList: CylinderBuffer[], helixbundleList: Helixbundle[], axisList: Axis[], axisData: AxisData}) {\n what = what || {}\n\n if (what.position) {\n this.build()\n return\n }\n\n var cylinderData = {}\n\n if (what.color || what.radius) {\n var offset = 0\n\n data.helixbundleList.forEach((helixbundle) => {\n var axis = helixbundle.getAxis(\n this.localAngle, this.centerDist, this.ssBorder,\n this.getColorParams(), this.getRadiusParams()\n )\n if (what.color) {\n data.axisData.color.set(axis.color, offset * 3)\n }\n if (what.radius || what.scale) {\n data.axisData.size.set(axis.size, offset)\n }\n offset += axis.size.length\n })\n\n if (what.color) {\n Object.assign(cylinderData, {\n color: data.axisData.color,\n color2: data.axisData.color\n })\n }\n\n if (what.radius || what.scale) {\n Object.assign(cylinderData, {\n radius: data.axisData.size\n })\n }\n }\n\n (data.bufferList[ 0 ] as CylinderGeometryBuffer).setAttributes(cylinderData)\n }\n}\n\nRepresentationRegistry.add('rocket', RocketRepresentation)\n\nexport default RocketRepresentation\n","/**\n * @file Rope Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport CartoonRepresentation, { CartoonRepresentationParameters } from './cartoon-representation'\nimport Helixorient from '../geometry/helixorient'\nimport Spline from '../geometry/spline'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport Polymer from '../proxy/polymer';\n\n/**\n * Rope Representation\n */\nclass RopeRepresentation extends CartoonRepresentation {\n protected smooth: number\n \n constructor (structure: Structure, viewer: Viewer, params: Partial&{smooth: number}) {\n super(structure, viewer, params)\n\n this.type = 'rope'\n\n this.parameters = Object.assign({\n\n smooth: {\n type: 'integer', max: 15, min: 0, rebuild: true\n }\n\n }, this.parameters, {\n aspectRatio: null,\n smoothSheet: null\n })\n }\n\n init (params: Partial) {\n var p = params || {}\n p.aspectRatio = 1.0\n p.tension = defaults(p.tension, 0.5)\n p.radiusScale = defaults(p.radiusScale, 5.0)\n p.smoothSheet = false\n\n this.smooth = defaults(p.smooth, 2)\n\n super.init(p)\n }\n\n getSpline (polymer: Polymer) {\n var helixorient = new Helixorient(polymer)\n\n return new Spline(polymer, this.getSplineParams({\n directional: false,\n positionIterator: helixorient.getCenterIterator(this.smooth)\n }))\n }\n}\n\nRepresentationRegistry.add('rope', RopeRepresentation)\n\nexport default RopeRepresentation\n","/**\n * @file Spacefill Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { RepresentationRegistry } from '../globals'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\nimport { AtomDataFields } from '../structure/structure-data';\nimport SphereImpostorBuffer from '../buffer/sphereimpostor-buffer';\n\n/**\n * Spacefill Representation\n */\nclass SpacefillRepresentation extends StructureRepresentation {\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'spacefill'\n\n this.parameters = Object.assign({\n sphereDetail: true,\n disableImpostor: true\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n var sphereBuffer = new SphereBuffer(\n (sview.getAtomData(this.getAtomParams()) as SphereBufferData),\n (this.getBufferParams({\n sphereDetail: this.sphereDetail,\n dullInterior: true,\n disableImpostor: this.disableImpostor\n }) as SphereBufferParameters)\n )\n\n return {\n bufferList: [ sphereBuffer as SphereGeometryBuffer|SphereImpostorBuffer ]\n }\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n var atomData = data.sview!.getAtomData(this.getAtomParams(what))\n var sphereData: Partial = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {position: atomData.position})\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {color: atomData.color})\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {radius: atomData.radius})\n }\n\n data.bufferList[ 0 ].setAttributes(sphereData)\n }\n}\n\nRepresentationRegistry.add('spacefill', SpacefillRepresentation)\n\nexport default SpacefillRepresentation\n","/**\n * @file Trace Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport '../shader/Line.vert'\nimport '../shader/Line.frag'\n\nimport { Log } from '../globals'\nimport Buffer, { BufferParameters, BufferData } from './buffer'\n\nfunction getSize(data: BufferData){\n const n = data.position!.length / 3\n const n1 = n - 1\n return n1 * 3 * 2\n}\n\n/**\n * Trace buffer. Draws a series of lines.\n */\nclass TraceBuffer extends Buffer {\n isLine = true\n vertexShader = 'Line.vert'\n fragmentShader = 'Line.frag'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: BufferData, params: Partial = {}) {\n super({\n position: new Float32Array(getSize(data)),\n color: new Float32Array(getSize(data))\n }, params)\n\n this.setAttributes(data)\n }\n\n setAttributes (data: Partial) {\n let position, color\n let linePosition, lineColor\n\n const attributes = this.geometry.attributes as any // TODO\n\n if (data.position) {\n position = data.position\n linePosition = attributes.position.array\n attributes.position.needsUpdate = true\n }\n\n if (data.color) {\n color = data.color\n lineColor = attributes.color.array\n attributes.color.needsUpdate = true\n }\n\n if (!position && !color) {\n Log.warn('TraceBuffer.prototype.setAttributes no data')\n return\n }\n\n let v, v2\n const n = this.size\n const n1 = n - 1\n\n for (let i = 0; i < n1; ++i) {\n v = 3 * i\n v2 = 3 * i * 2\n\n if (position) {\n linePosition[ v2 ] = position[ v ]\n linePosition[ v2 + 1 ] = position[ v + 1 ]\n linePosition[ v2 + 2 ] = position[ v + 2 ]\n\n linePosition[ v2 + 3 ] = position[ v + 3 ]\n linePosition[ v2 + 4 ] = position[ v + 4 ]\n linePosition[ v2 + 5 ] = position[ v + 5 ]\n }\n\n if (color) {\n lineColor[ v2 ] = color[ v ]\n lineColor[ v2 + 1 ] = color[ v + 1 ]\n lineColor[ v2 + 2 ] = color[ v + 2 ]\n\n lineColor[ v2 + 3 ] = color[ v + 3 ]\n lineColor[ v2 + 4 ] = color[ v + 4 ]\n lineColor[ v2 + 5 ] = color[ v + 5 ]\n }\n }\n }\n}\n\nexport default TraceBuffer\n","/**\n * @file Trace Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Spline from '../geometry/spline'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport TraceBuffer from '../buffer/trace-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport StructureView from '../structure/structure-view';\nimport Polymer from '../proxy/polymer';\n\nexport interface TraceRepresentationParameters extends StructureRepresentationParameters {\n subdiv: number\n tension: number\n smoothSheet: boolean\n}\n/**\n * Trace Representation\n */\nclass TraceRepresentation extends StructureRepresentation {\n protected subdiv: number\n protected tension: number\n protected smoothSheet: boolean\n \n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'trace'\n\n this.parameters = Object.assign({\n\n subdiv: {\n type: 'integer', max: 50, min: 1, rebuild: true\n },\n tension: {\n type: 'number', precision: 1, max: 1.0, min: 0.1\n },\n smoothSheet: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n\n flatShaded: null,\n side: null,\n wireframe: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'chainname')\n p.colorScale = defaults(p.colorScale, 'RdYlBu')\n\n if (p.quality === 'low') {\n this.subdiv = 3\n } else if (p.quality === 'medium') {\n this.subdiv = 6\n } else if (p.quality === 'high') {\n this.subdiv = 12\n } else {\n this.subdiv = defaults(p.subdiv, 6)\n }\n\n this.tension = defaults(p.tension, NaN)\n this.smoothSheet = defaults(p.smoothSheet, false)\n\n super.init(p)\n }\n\n getSplineParams (params?: {[k:string]: any}) {\n return Object.assign({\n subdiv: this.subdiv,\n tension: this.tension,\n directional: false,\n smoothSheet: this.smoothSheet\n }, params)\n }\n\n getAtomRadius (atom: AtomProxy) {\n return atom.isTrace() ? 0.1 : 0\n }\n\n createData (sview: StructureView) {\n var bufferList: TraceBuffer[] = []\n var polymerList: Polymer[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4) return\n polymerList.push(polymer)\n\n var spline = new Spline(polymer, this.getSplineParams())\n var subPos = spline.getSubdividedPosition()\n var subCol = spline.getSubdividedColor(this.getColorParams())\n\n bufferList.push(\n new TraceBuffer(\n Object.assign({}, subPos, subCol),\n this.getBufferParams()\n )\n )\n }, sview.getSelection())\n\n return {\n bufferList: bufferList,\n polymerList: polymerList\n }\n }\n\n updateData (what: any, data: StructureRepresentationData) {\n what = what || {}\n\n var i = 0\n var n = data.polymerList!.length\n\n for (i = 0; i < n; ++i) {\n var bufferData = {}\n var spline = new Spline(data.polymerList![ i ], this.getSplineParams())\n\n if (what.position) {\n var subPos = spline.getSubdividedPosition()\n Object.assign(bufferData, { position: subPos.position })\n }\n\n if (what.color) {\n var subCol = spline.getSubdividedColor(this.getColorParams())\n Object.assign(bufferData, { color: subCol.color })\n }\n\n data.bufferList[ i ].setAttributes(bufferData)\n }\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n if (params && params.tension) {\n Object.assign(what, {position: true})\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('trace', TraceRepresentation)\n\nexport default TraceRepresentation\n","/**\n * @file Tube Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport CartoonRepresentation, {CartoonRepresentationParameters} from './cartoon-representation'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\n\n/**\n * Tube Representation\n */\nclass TubeRepresentation extends CartoonRepresentation {\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'tube'\n\n this.parameters = Object.assign(\n {}, this.parameters, { aspectRatio: null }\n )\n }\n\n init (params: Partial) {\n var p = params || {}\n p.aspectRatio = 1.0\n p.radiusScale = defaults(p.radiusScale, 2.0)\n\n if (p.quality === 'low') {\n this.radialSegments = 5\n }\n\n super.init(p)\n }\n\n getSplineParams (/* params */) {\n return super.getSplineParams({\n directional: false\n })\n }\n}\n\nRepresentationRegistry.add('tube', TubeRepresentation)\n\nexport default TubeRepresentation\n","/**\n * @file Unitcell Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport CylinderBuffer, { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport { AtomDataFields } from '../structure/structure-data';\nimport StructureView from '../structure/structure-view';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\n// @ts-ignore: unused import UnitcellPicker required for declaration only\nimport { UnitcellPicker } from '../utils/picker';\n\nexport interface UnitcellRepresentationParameters extends StructureRepresentationParameters {\n radiusSize: number\n sphereDetail: number\n radialSegments: number\n disableImpostor: boolean\n}\n\n/**\n * Unitcell Representation\n */\nclass UnitcellRepresentation extends StructureRepresentation {\n sphereBuffer: SphereBuffer\n cylinderBuffer: CylinderBuffer\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'unitcell'\n\n this.parameters = Object.assign({\n\n radiusSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n sphereDetail: true,\n radialSegments: true,\n disableImpostor: true\n\n }, this.parameters, {\n assembly: null\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n\n let defaultRadius = 0.5\n if (this.structure.unitcell) {\n defaultRadius = Math.cbrt(this.structure.unitcell.volume) / 200\n }\n\n p.radiusSize = defaults(p.radiusSize, defaultRadius)\n p.colorValue = defaults(p.colorValue, 'orange')\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n super.init(p)\n }\n\n getUnitcellData (structure: Structure) {\n return structure.unitcell!.getData(structure)\n }\n\n create () {\n const structure = this.structureView.getStructure()\n if (!structure.unitcell) return\n const unitcellData = this.getUnitcellData(structure)\n\n this.sphereBuffer = new SphereBuffer(\n unitcellData.vertex as SphereBufferData,\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters\n )\n\n this.cylinderBuffer = new CylinderBuffer(\n unitcellData.edge as CylinderBufferData,\n this.getBufferParams({\n openEnded: true,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n this.dataList.push({\n sview: this.structureView,\n bufferList: [ this.sphereBuffer as SphereGeometryBuffer, this.cylinderBuffer as CylinderGeometryBuffer ]\n })\n }\n\n createData (sview: StructureView): undefined {\n return\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n const structure = data.sview!.getStructure()\n if (!structure.unitcell) return\n const unitcellData = this.getUnitcellData(structure)\n const sphereData: Partial = {}\n const cylinderData: Partial = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {position: unitcellData.vertex.position})\n Object.assign(cylinderData, {\n position1: unitcellData.edge.position1,\n position2: unitcellData.edge.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {color: unitcellData.vertex.color})\n Object.assign(cylinderData, {\n color: unitcellData.edge.color,\n color2: unitcellData.edge.color2\n })\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {radius: unitcellData.vertex.radius})\n Object.assign(cylinderData, {radius: unitcellData.edge.radius})\n }\n\n (this.sphereBuffer as SphereGeometryBuffer).setAttributes(sphereData);\n (this.cylinderBuffer as CylinderGeometryBuffer).setAttributes(cylinderData)\n }\n}\n\nRepresentationRegistry.add('unitcell', UnitcellRepresentation)\n\nexport default UnitcellRepresentation\n","/**\n * @file Validation Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport CylinderBuffer from '../buffer/cylinder-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport CylinderImpostorBuffer from '../buffer/cylinderimpostor-buffer';\n\n/**\n * Validation representation\n */\nclass ValidationRepresentation extends StructureRepresentation {\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'validation'\n\n this.parameters = Object.assign({\n\n }, this.parameters, {\n radiusType: null,\n radiusSize: null,\n radiusScale: null\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorValue = defaults(p.colorValue, '#f0027f')\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n if (!sview.validation) return\n\n const clashData = sview.validation.getClashData({\n structure: sview,\n color: this.colorValue\n })\n\n const cylinderBuffer = new CylinderBuffer(\n clashData, this.getBufferParams({ openEnded: false })\n )\n\n return {\n bufferList: [ cylinderBuffer as CylinderGeometryBuffer|CylinderImpostorBuffer ]\n }\n }\n}\n\nRepresentationRegistry.add('validation', ValidationRepresentation)\n\nexport default ValidationRepresentation\n","/**\n * @file Cone Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3, ConeBufferGeometry } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { calculateCenterArray } from '../math/array-utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferDefaultParameters } from './buffer'\n\nconst scale = new Vector3()\nconst eye = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3(0, 1, 0)\n\nfunction getGeo (params: Partial = {}) {\n const geo = new ConeBufferGeometry(\n 1, // radius\n 1, // height\n defaults(params.radialSegments, 60), // radialSegments\n 1, // heightSegments\n defaults(params.openEnded, false) // openEnded\n )\n geo.applyMatrix4(new Matrix4().makeRotationX(-Math.PI / 2))\n\n return geo\n}\n\nexport interface ConeBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n radius: Float32Array\n}\n\nexport const ConeBufferDefaultParameters = Object.assign({\n radialSegments: 60,\n openEnded: false\n}, BufferDefaultParameters)\nexport type ConeBufferParameters = typeof ConeBufferDefaultParameters\n\n\n/**\n * Cone geometry buffer.\n *\n * @example\n * var coneBuffer = new ConeBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass ConeBuffer extends GeometryBuffer {\n updateNormals = true\n\n get defaultParameters() { return ConeBufferDefaultParameters }\n parameters: ConeBufferParameters\n\n _position: Float32Array\n _position1: Float32Array\n _position2: Float32Array\n _radius: Float32Array\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n */\n constructor (data: ConeBufferData, params: Partial = {}) {\n super({\n position: new Float32Array(data.position1.length),\n color: data.color,\n picking: data.picking\n }, params, getGeo(params))\n\n this._position = new Float32Array(data.position1.length)\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n eye.fromArray(this._position1 as any, i3)\n target.fromArray(this._position2 as any, i3)\n matrix.lookAt(eye, target, up)\n\n const r = this._radius[ i ]\n scale.set(r, r, eye.distanceTo(target))\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.position1 && data.position2) {\n calculateCenterArray(data.position1, data.position2, this._position)\n this._position1 = data.position1\n this._position2 = data.position2\n data.position = this._position\n }\n if (data.radius) this._radius = data.radius\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('cone', ConeBuffer)\n\nexport default ConeBuffer\n","/**\n * @file Geometry Group\n * @author Alexander Rose \n * @private\n */\n\nimport { Box3, BufferGeometry } from 'three'\n\nclass GeometryGroup {\n geometryList: BufferGeometry[]\n boundingBox: Box3\n\n constructor (geometryList: BufferGeometry[] = []) {\n this.geometryList = geometryList\n }\n\n computeBoundingBox () {\n if (!this.boundingBox) {\n this.boundingBox = new Box3()\n } else {\n this.boundingBox.empty()\n }\n\n this.geometryList.forEach(geo => {\n if (!geo.boundingBox) geo.computeBoundingBox()\n this.boundingBox.union(geo.boundingBox as Box3)\n })\n }\n}\n\nexport default GeometryGroup\n","/**\n * @file Arrow Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3, Group } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport { createParams, defaults } from '../utils'\nimport { Picker } from '../utils/picker'\nimport Buffer from './buffer'\nimport CylinderBuffer, { CylinderBufferData } from './cylinder-buffer'\nimport CylinderGeometryBuffer from './cylindergeometry-buffer'\nimport ConeBuffer, { ConeBufferData } from './cone-buffer'\nimport GeometryGroup from '../viewer/geometry-group'\nimport { BufferData, BufferDefaultParameters } from './buffer'\n\nexport interface ArrowBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n radius: Float32Array\n}\n\nexport const ArrowBufferDefaultParameters = Object.assign({\n aspectRatio: 1.5,\n radialSegments: 50,\n openEnded: false,\n disableImpostor: false\n}, BufferDefaultParameters)\nexport type ArrowBufferParameters = typeof ArrowBufferDefaultParameters\n\n/**\n * Arrow buffer. Draws arrows made from a cylinder and a cone.\n * @implements {Buffer}\n *\n * @example\n * var arrowBuffer = new ArrowBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 10, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass ArrowBuffer {\n parameters: ArrowBufferParameters\n get defaultParameters() { return ArrowBufferDefaultParameters }\n\n cylinderBuffer: CylinderGeometryBuffer\n coneBuffer: ConeBuffer\n\n splitPosition: Float32Array\n cylinderRadius: Float32Array\n\n geometry: GeometryGroup\n picking?: Picker\n\n group = new Group()\n wireframeGroup = new Group()\n pickingGroup = new Group()\n\n visible = true\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n */\n constructor (data: ArrowBufferData, params: Partial = {}) {\n this.parameters = createParams(params, this.defaultParameters)\n\n this.splitPosition = new Float32Array(data.position1.length)\n this.cylinderRadius = new Float32Array(data.radius.length)\n\n const attr = this.makeAttributes(data)\n const bufferParams = {\n radialSegments: this.parameters.radialSegments,\n openEnded: this.parameters.openEnded,\n disableImpostor: this.parameters.disableImpostor\n }\n\n this.cylinderBuffer = new CylinderBuffer(\n attr.cylinder as CylinderBufferData, bufferParams\n ) as CylinderGeometryBuffer\n this.coneBuffer = new ConeBuffer(\n attr.cone as ConeBufferData, bufferParams\n )\n\n this.geometry = new GeometryGroup([\n this.cylinderBuffer.geometry,\n this.coneBuffer.geometry\n ])\n\n // requires Group objects to be present\n this.matrix = defaults(params.matrix, new Matrix4())\n\n this.picking = data.picking\n }\n\n set matrix (m) {\n Buffer.prototype.setMatrix.call(this, m)\n }\n get matrix () {\n return this.group.matrix.clone()\n }\n\n get pickable () {\n return !!this.picking\n }\n\n makeAttributes (data: Partial = {}) {\n const splitPosition = this.splitPosition\n const cylinderRadius = this.cylinderRadius\n\n const aspectRatio = this.parameters.aspectRatio\n\n let i, il\n const cylinder: Partial = {}\n const cone: Partial = {}\n\n if (data.radius) {\n for (i = 0, il = cylinderRadius.length; i < il; ++i) {\n cylinderRadius[ i ] = data.radius[ i ] / aspectRatio\n }\n cylinder.radius = cylinderRadius\n cone.radius = data.radius\n }\n\n if (data.position1 && data.position2) {\n const vFrom = new Vector3()\n const vTo = new Vector3()\n const vDir = new Vector3()\n const vSplit = new Vector3()\n for (i = 0, il = splitPosition.length; i < il; i += 3) {\n vFrom.fromArray(data.position1 as any, i)\n vTo.fromArray(data.position2 as any, i)\n vDir.subVectors(vFrom, vTo)\n const fullLength = vDir.length()\n const coneLength = cylinderRadius[ i / 3 ] * aspectRatio * 2\n const length = Math.min(fullLength, coneLength)\n vDir.setLength(length)\n vSplit.copy(vTo).add(vDir)\n vSplit.toArray(splitPosition as any, i)\n }\n cylinder.position1 = data.position1\n cylinder.position2 = splitPosition\n cone.position1 = splitPosition\n cone.position2 = data.position2\n }\n\n if (data.color) {\n cylinder.color = data.color\n cylinder.color2 = data.color\n cone.color = data.color\n }\n\n return {\n cylinder: cylinder,\n cone: cone\n }\n }\n\n getMesh () {\n return new Group().add(\n this.cylinderBuffer.getMesh(),\n this.coneBuffer.getMesh()\n )\n }\n\n getWireframeMesh () {\n return new Group().add(\n this.cylinderBuffer.getWireframeMesh(),\n this.coneBuffer.getWireframeMesh()\n )\n }\n\n getPickingMesh () {\n return new Group().add(\n this.cylinderBuffer.getPickingMesh(),\n this.coneBuffer.getPickingMesh()\n )\n }\n\n setAttributes (data: Partial = {}) {\n const attr = this.makeAttributes(data)\n\n this.cylinderBuffer.setAttributes(attr.cylinder)\n this.coneBuffer.setAttributes(attr.cone)\n }\n\n /**\n * Set buffer parameters\n * @param {BufferParameters} params - buffer parameters object\n * @return {undefined}\n */\n setParameters (params: Partial = {}) {\n params = Object.assign({}, params)\n\n if (params && params.matrix !== undefined) {\n this.matrix = params.matrix\n }\n delete params.matrix\n\n if (params && params.wireframe !== undefined) {\n this.parameters.wireframe = params.wireframe\n this.setVisibility(this.visible)\n }\n\n this.cylinderBuffer.setParameters(params)\n this.coneBuffer.setParameters(params)\n }\n\n setVisibility (value: boolean) {\n Buffer.prototype.setVisibility.call(this, value)\n }\n\n dispose () {\n this.cylinderBuffer.dispose()\n this.coneBuffer.dispose()\n }\n}\n\nBufferRegistry.add('arrow', ArrowBuffer)\n\nexport default ArrowBuffer\n","/**\n * @file Box Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { BoxBufferGeometry, Vector3, Matrix4 } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface BoxBufferData extends BufferData {\n heightAxis: Float32Array\n depthAxis: Float32Array\n size: Float32Array\n}\n\n/**\n * Box buffer. Draws boxes.\n *\n * @example\n * var boxBuffer = new BoxBuffer({\n * position: new Float32Array([ 0, 3, 0, -2, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 1, 0, 1, 0 ]),\n * size: new Float32Array([ 2, 1.5 ]),\n * heightAxis: new Float32Array([ 0, 1, 1, 0, 2, 0 ]),\n * depthAxis: new Float32Array([ 1, 0, 1, 0, 0, 2 ])\n * })\n */\nclass BoxBuffer extends GeometryBuffer {\n updateNormals = true\n\n _heightAxis: Float32Array\n _depthAxis: Float32Array\n _size: Float32Array\n\n constructor (data: BoxBufferData, params: Partial = {}) {\n super(data, params, new BoxBufferGeometry(1, 1, 1))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._heightAxis as any, i3)\n up.fromArray(this._depthAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n scale.set(this._size[ i ], up.length(), target.length())\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.size) this._size = data.size\n if (data.heightAxis) this._heightAxis = data.heightAxis\n if (data.depthAxis) this._depthAxis = data.depthAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('box', BoxBuffer)\n\nexport default BoxBuffer\n","/**\n * @file Ellipsoid Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { IcosahedronBufferGeometry, Vector3, Matrix4 } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferDefaultParameters } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface EllipsoidBufferData extends BufferData {\n majorAxis: Float32Array\n minorAxis: Float32Array\n radius: Float32Array\n}\n\nexport const EllipsoidBufferDefaultParameters = Object.assign({\n sphereDetail: 2,\n}, BufferDefaultParameters)\nexport type EllipsoidBufferParameters = typeof EllipsoidBufferDefaultParameters\n\n/**\n * Ellipsoid buffer. Draws ellipsoids.\n *\n * @example\n * var ellipsoidBuffer = new EllipsoidBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ]),\n * majorAxis: new Float32Array([ 1, 1, 0 ]),\n * minorAxis: new Float32Array([ 0.5, 0, 0.5 ]),\n * });\n */\nclass EllipsoidBuffer extends GeometryBuffer {\n updateNormals = true\n\n get defaultParameters() { return EllipsoidBufferDefaultParameters }\n parameters: EllipsoidBufferParameters\n\n _majorAxis: Float32Array\n _minorAxis: Float32Array\n _radius: Float32Array\n\n constructor (data: EllipsoidBufferData, params: Partial = {}) {\n super(data, params, new IcosahedronBufferGeometry(1, defaults(params.sphereDetail, 2)))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._majorAxis as any, i3)\n up.fromArray(this._minorAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n scale.set(this._radius[ i ], up.length(), target.length())\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.radius) this._radius = data.radius\n if (data.majorAxis) this._majorAxis = data.majorAxis\n if (data.minorAxis) this._minorAxis = data.minorAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('ellipsoid', EllipsoidBuffer)\n\nexport default EllipsoidBuffer\n","/**\n * @file Octahedron Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { OctahedronBufferGeometry, Vector3, Matrix4 } from 'three'\nimport { BufferRegistry } from '../globals'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface OctahedronBufferData extends BufferData {\n heightAxis: Float32Array\n depthAxis: Float32Array\n size: Float32Array\n}\n\n/**\n * Octahedron buffer. Draws octahedrons.\n *\n * @example\n * var octahedronBuffer = new OctahedronBuffer({\n * position: new Float32Array([ 0, 3, 0, -2, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 1, 0, 1, 0 ]),\n * size: new Float32Array([ 2, 1.5 ]),\n * heightAxis: new Float32Array([ 0, 1, 1, 0, 2, 0 ]),\n * depthAxis: new Float32Array([ 1, 0, 1, 0, 0, 2 ])\n * })\n */\nclass OctahedronBuffer extends GeometryBuffer {\n updateNormals = true\n\n _heightAxis: Float32Array\n _depthAxis: Float32Array\n _size: Float32Array\n\n constructor (data: OctahedronBufferData, params: Partial = {}) {\n super(data, params, new OctahedronBufferGeometry(1, 0))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._heightAxis as any, i3)\n up.fromArray(this._depthAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n scale.set(this._size[ i ], up.length(), target.length())\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.size) this._size = data.size\n if (data.heightAxis) this._heightAxis = data.heightAxis\n if (data.depthAxis) this._depthAxis = data.depthAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('octahedron', OctahedronBuffer)\n\nexport default OctahedronBuffer\n","/**\n * @file Tetrahedron Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { TetrahedronBufferGeometry, Vector3, Matrix4 } from 'three'\nimport { BufferRegistry } from '../globals'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface TetrahedronBufferData extends BufferData {\n heightAxis: Float32Array\n depthAxis: Float32Array\n size: Float32Array\n}\n\n/**\n * Tetrahedron buffer. Draws tetrahedrons.\n *\n * @example\n * var tetrahedronBuffer = new TetrahedronBuffer({\n * position: new Float32Array([ 0, 3, 0, -2, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 1, 0, 1, 0 ]),\n * size: new Float32Array([ 2, 1.5 ]),\n * heightAxis: new Float32Array([ 0, 1, 1, 0, 2, 0 ]),\n * depthAxis: new Float32Array([ 1, 0, 1, 0, 0, 2 ])\n * })\n */\nclass TetrahedronBuffer extends GeometryBuffer {\n updateNormals = true\n\n _heightAxis: Float32Array\n _depthAxis: Float32Array\n _size: Float32Array\n\n constructor (data: TetrahedronBufferData, params: Partial = {}) {\n super(data, params, new TetrahedronBufferGeometry(1, 0))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._heightAxis as any, i3)\n up.fromArray(this._depthAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n scale.set(this._size[ i ], up.length(), target.length())\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.size) this._size = data.size\n if (data.heightAxis) this._heightAxis = data.heightAxis\n if (data.depthAxis) this._depthAxis = data.depthAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('tetrahedron', TetrahedronBuffer)\n\nexport default TetrahedronBuffer\n","/**\n * @file Tetrahedron Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { TorusBufferGeometry, Vector3, Matrix4 } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferDefaultParameters, BufferData } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface TorusBufferData extends BufferData {\n majorAxis: Float32Array\n minorAxis: Float32Array\n radius: Float32Array\n}\n\nexport const TorusBufferDefaultParameters = Object.assign({\n radiusRatio: 0.2,\n radialSegments: 16,\n tubularSegments: 32\n}, BufferDefaultParameters)\nexport type TorusBufferParameters = typeof TorusBufferDefaultParameters\n\n/**\n * Torus geometry buffer. Draws torii.\n *\n * @example\n * var torusBuffer = new TorusBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ]),\n * majorAxis: new Float32Array([ 1, 1, 0 ]),\n * minorAxis: new Float32Array([ 0.5, 0, 0.5 ]),\n * });\n */\nclass TorusBuffer extends GeometryBuffer {\n updateNormals = true\n\n get defaultParameters() { return TorusBufferDefaultParameters }\n parameters: TorusBufferParameters\n\n _majorAxis: Float32Array\n _minorAxis: Float32Array\n _radius: Float32Array\n\n constructor (data: TorusBufferData, params: Partial = {}) {\n super(data, params, new TorusBufferGeometry(\n 1,\n defaults(params.radiusRatio, 0.2),\n defaults(params.radialSegments, 16),\n defaults(params.tubularSegments, 32)\n ))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._majorAxis as any, i3)\n up.fromArray(this._minorAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n const r = this._radius[ i ]\n scale.set(r, r, r)\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.radius) this._radius = data.radius\n if (data.majorAxis) this._majorAxis = data.majorAxis\n if (data.minorAxis) this._minorAxis = data.minorAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('torus', TorusBuffer)\n\nexport default TorusBuffer\n","/**\n * @file Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log } from '../globals'\nimport { defaults } from '../utils'\nimport Streamer from '../streamer/streamer';\n\nexport interface ParserParameters {\n name: string\n path: string\n}\n\nclass Parser {\n streamer: Streamer\n name: string\n path: string\n [k: string]: any\n \n constructor (streamer: Streamer, params?: Partial) {\n var p = params || {}\n\n this.streamer = streamer\n\n this.name = defaults(p.name, '')\n this.path = defaults(p.path, '')\n }\n\n get type () { return '' }\n get __objName () { return '' }\n get isBinary () { return false }\n get isJson () { return false }\n get isXml () { return false }\n\n parse () {\n return this.streamer.read().then(() => {\n this._beforeParse()\n this._parse()\n this._afterParse()\n return this[ this.__objName ]\n })\n }\n\n _parse () {}\n\n _beforeParse () {}\n\n _afterParse () {\n if (Debug) Log.log(this[ this.__objName ])\n }\n}\n\nexport default Parser\n","/**\n * @file Structure Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport Parser, { ParserParameters } from './parser'\nimport Structure from '../structure/structure'\nimport StructureBuilder from '../structure/structure-builder'\nimport Streamer from '../streamer/streamer';\n\nexport interface StructureParserParameters extends ParserParameters {\n firstModelOnly: boolean\n asTrajectory: boolean\n cAlphaOnly: boolean\n}\nclass StructureParser extends Parser {\n\n structureBuilder: StructureBuilder\n\n constructor (streamer: Streamer, params?: Partial) {\n var p = params || {}\n\n super(streamer, p)\n\n this.firstModelOnly = defaults(p.firstModelOnly, false)\n this.asTrajectory = defaults(p.asTrajectory, false)\n this.cAlphaOnly = defaults(p.cAlphaOnly, false)\n\n this.structure = new Structure(this.name, this.path)\n this.structureBuilder = new StructureBuilder(this.structure)\n }\n\n get type () { return 'structure' }\n get __objName () { return 'structure' }\n}\n\nexport default StructureParser\n","/**\n * @file Entity\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from './structure'\nimport {\n UnknownEntity, PolymerEntity, NonPolymerEntity, MacrolideEntity, WaterEntity\n} from './structure-constants'\nimport ChainProxy from '../proxy/chain-proxy'\n\nfunction entityTypeFromString (string: string) {\n string = string.toLowerCase()\n switch (string) {\n case 'polymer':\n return PolymerEntity\n case 'non-polymer':\n return NonPolymerEntity\n case 'macrolide':\n return MacrolideEntity\n case 'water':\n return WaterEntity\n default:\n return UnknownEntity\n }\n}\n\nfunction entityFromType (type: number) {\n switch (type) {\n case PolymerEntity:\n return 'polymer'\n case NonPolymerEntity:\n return 'non-polymer'\n case MacrolideEntity:\n return 'macrolide'\n case WaterEntity:\n return 'water'\n default:\n return undefined\n }\n}\n\nexport const EntityTypeString = {\n 'polymer': PolymerEntity,\n 'non-polymer': NonPolymerEntity,\n 'macrolide': MacrolideEntity,\n 'water': WaterEntity,\n}\nexport type EntityTypeString = keyof typeof EntityTypeString\n\n/**\n * Entity of a {@link Structure}\n */\nexport default class Entity {\n structure: Structure\n index: number\n description: string\n entityType: number\n chainIndexList: number[]\n\n /**\n * @param {Structure} structure - structure the entity belongs to\n * @param {Integer} index - index within structure.entityList\n * @param {String} description - entity description\n * @param {String} type - entity type\n * @param {Array} chainIndexList - entity chainIndexList\n */\n constructor (structure: Structure, index: number, description = '', type?: EntityTypeString, chainIndexList: number[] = []) {\n this.structure = structure\n this.index = index\n this.description = description\n this.entityType = entityTypeFromString(type || '')\n this.chainIndexList = chainIndexList\n\n chainIndexList.forEach(function (ci: number) {\n structure.chainStore.entityIndex[ ci ] = index\n })\n }\n\n get type () { return entityFromType(this.entityType) }\n\n getEntityType () {\n return this.entityType\n }\n\n isPolymer () {\n return this.entityType === PolymerEntity\n }\n\n isNonPolymer () {\n return this.entityType === NonPolymerEntity\n }\n\n isMacrolide () {\n return this.entityType === MacrolideEntity\n }\n\n isWater () {\n return this.entityType === WaterEntity\n }\n\n eachChain (callback: (cp: ChainProxy) => any) {\n const cp = this.structure.getChainProxy()\n\n this.chainIndexList.forEach(function (index) {\n cp.index = index\n callback(cp)\n })\n }\n}","/**\n * @file Unitcell\n * @author Alexander Rose \n * @private\n */\n\nimport { Color, Vector3, Matrix4 } from 'three'\n\nimport { defaults } from '../utils'\nimport { degToRad } from '../math/math-utils'\nimport {\n uniformArray, uniformArray3, centerArray3\n} from '../math/array-utils'\nimport { UnitcellPicker } from '../utils/picker'\nimport Structure from '../structure/structure'\n\nexport interface UnitcellParams {\n a: number\n b: number\n c: number\n alpha: number\n beta: number\n gamma: number\n spacegroup: string\n cartToFrac?: Matrix4\n}\n\nconst DefaultBoxParams = {\n a: 1,\n b: 1,\n c: 1,\n alpha: 90,\n beta: 90,\n gamma: 90,\n spacegroup: 'P 1'\n}\n\nexport interface UnitcellDataParams {\n colorValue?: string|number,\n radius?: number\n}\n\n/**\n * Unitcell class\n */\nclass Unitcell {\n a: number\n b: number\n c: number\n alpha: number\n beta: number\n gamma: number\n\n spacegroup: string\n\n cartToFrac = new Matrix4()\n fracToCart = new Matrix4()\n\n volume: number\n\n /**\n * @param {Object} params - unitcell parameters\n * @param {Number} params.a - length a\n * @param {Number} params.b - length b\n * @param {Number} params.c - length c\n * @param {Number} params.alpha - angle alpha\n * @param {Number} params.beta - angle beta\n * @param {Number} params.gamma - angle gamma\n * @param {String} params.spacegroup - spacegroup\n * @param {Matrix4} [params.cartToFrac] - transformation matrix from\n * cartesian to fractional coordinates\n * @param {Matrix4} [params.scale] - alias for `params.cartToFrac`\n */\n constructor (params: UnitcellParams = DefaultBoxParams) {\n this.a = params.a\n this.b = params.b\n this.c = params.c\n this.alpha = params.alpha\n this.beta = params.beta\n this.gamma = params.gamma\n this.spacegroup = params.spacegroup\n\n const alphaRad = degToRad(this.alpha)\n const betaRad = degToRad(this.beta)\n const gammaRad = degToRad(this.gamma)\n const cosAlpha = Math.cos(alphaRad)\n const cosBeta = Math.cos(betaRad)\n const cosGamma = Math.cos(gammaRad)\n const sinBeta = Math.sin(betaRad)\n const sinGamma = Math.sin(gammaRad)\n\n this.volume = (\n this.a * this.b * this.c *\n Math.sqrt(\n 1 - cosAlpha * cosAlpha - cosBeta * cosBeta - cosGamma * cosGamma +\n 2.0 * cosAlpha * cosBeta * cosGamma\n )\n )\n\n if (params.cartToFrac === undefined) {\n // https://github.com/biojava/biojava/blob/master/biojava-structure/src/main/java/org/biojava/nbio/structure/xtal/CrystalCell.java\n\n const cStar = (this.a * this.b * sinGamma) / this.volume\n const cosAlphaStar = (\n (cosBeta * cosGamma - cosAlpha) / (sinBeta * sinGamma)\n )\n\n this.fracToCart.set(\n this.a, 0, 0, 0,\n this.b * cosGamma, this.b * sinGamma, 0, 0,\n this.c * cosBeta, -this.c * sinBeta * cosAlphaStar, 1.0 / cStar, 0,\n 0, 0, 0, 1\n ).transpose()\n this.cartToFrac.getInverse(this.fracToCart)\n } else {\n this.cartToFrac.copy(params.cartToFrac)\n this.fracToCart.getInverse(this.cartToFrac)\n }\n }\n\n getPosition (structure: Structure): Float32Array {\n const vertexPosition = new Float32Array(3 * 8)\n\n if (structure.unitcell) {\n const uc = structure.unitcell\n const centerFrac = structure.center.clone().applyMatrix4(uc.cartToFrac).floor()\n const v = new Vector3()\n\n let cornerOffset = 0\n const addCorner = function (x: number, y: number, z: number) {\n v.set(x, y, z)\n .add(centerFrac)\n .applyMatrix4(uc.fracToCart)\n .toArray(vertexPosition as any, cornerOffset)\n cornerOffset += 3\n }\n addCorner(0, 0, 0)\n addCorner(1, 0, 0)\n addCorner(0, 1, 0)\n addCorner(0, 0, 1)\n addCorner(1, 1, 0)\n addCorner(1, 0, 1)\n addCorner(0, 1, 1)\n addCorner(1, 1, 1)\n }\n\n return vertexPosition\n }\n\n getCenter (structure: Structure) {\n return centerArray3(this.getPosition(structure))\n }\n\n getData (structure: Structure, params: UnitcellDataParams = {}) {\n const colorValue = defaults(params.colorValue, 'orange')\n const radius = defaults(params.radius, Math.cbrt(this.volume) / 200)\n\n const c = new Color(colorValue)\n const v = new Vector3()\n\n const vertexPosition = this.getPosition(structure)\n const vertexColor = uniformArray3(8, c.r, c.g, c.b)\n const vertexRadius = uniformArray(8, radius)\n\n const edgePosition1 = new Float32Array(3 * 12)\n const edgePosition2 = new Float32Array(3 * 12)\n const edgeColor = uniformArray3(12, c.r, c.g, c.b)\n const edgeRadius = uniformArray(12, radius)\n\n let edgeOffset = 0\n function addEdge (a: number, b: number) {\n v.fromArray(vertexPosition as any, a * 3)\n .toArray(edgePosition1 as any, edgeOffset)\n v.fromArray(vertexPosition as any, b * 3)\n .toArray(edgePosition2 as any, edgeOffset)\n edgeOffset += 3\n }\n addEdge(0, 1)\n addEdge(0, 2)\n addEdge(0, 3)\n addEdge(1, 4)\n addEdge(1, 5)\n addEdge(2, 6)\n addEdge(3, 5)\n addEdge(4, 7)\n addEdge(5, 7)\n addEdge(2, 4)\n addEdge(7, 6)\n addEdge(3, 6)\n\n const picker = new UnitcellPicker(this, structure)\n\n return {\n vertex: {\n position: vertexPosition,\n color: vertexColor,\n radius: vertexRadius,\n picking: picker\n },\n edge: {\n position1: edgePosition1,\n position2: edgePosition2,\n color: edgeColor,\n color2: edgeColor,\n radius: edgeRadius,\n picking: picker\n }\n }\n }\n}\n\nexport default Unitcell\n","/**\n * @file Pdb Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureParser from './structure-parser'\nimport Entity, { EntityTypeString } from '../structure/entity'\nimport Unitcell, { UnitcellParams } from '../symmetry/unitcell'\nimport Assembly, { AssemblyPart } from '../symmetry/assembly'\nimport { PDBQTSpecialElements, WaterNames } from '../structure/structure-constants'\nimport {\n assignSecondaryStructure, InferBondsOptions, buildUnitcellAssembly,\n calculateBonds, calculateChainnames, calculateSecondaryStructure\n} from '../structure/structure-utils'\nimport Streamer from '../streamer/streamer';\nimport { ParserParameters } from './parser';\nimport { NumberArray } from '../types';\nimport { Structure } from '../ngl';\n\n// PDB helix record encoding\nconst HelixTypes: {[k: number]: string} = {\n 1: 'h', // Right-handed alpha (default)\n 2: 'h', // Right-handed omega\n 3: 'i', // Right-handed pi\n 4: 'h', // Right-handed gamma\n 5: 'g', // Right-handed 310\n 6: 'h', // Left-handed alpha\n 7: 'h', // Left-handed omega\n 8: 'h', // Left-handed gamma\n 9: 'h', // 27 ribbon/helix\n 10: 'h', // Polyproline\n 0: 'h' //Used to be ''\n}\n\nconst dAminoAcids = [\n 'DAL', // D-ALANINE\n 'DAR', // D-ARGININE\n 'DSG', // D-ASPARAGINE\n 'DAS', // D-ASPARTIC ACID\n 'DCY', // D-CYSTEINE\n 'DGL', // D-GLUTAMIC ACID\n 'DGN', // D-GLUTAMINE\n 'DHI', // D-HISTIDINE\n 'DIL', // D-ISOLEUCINE\n 'DLE', // D-LEUCINE\n 'DLY', // D-LYSINE\n 'MED', // D-METHIONINE\n 'DPN', // D-PHENYLALANINE\n 'DPR', // D-PROLINE\n 'DSN', // D-SERINE\n 'DTH', // D-THREONINE\n 'DTR', // D-TRYPTOPHAN\n 'DTY', // D-TYROSINE\n 'DVA', // D-VALINE\n\n 'DNE' // D-NORLEUCINE\n\n // ??? // D-SELENOCYSTEINE\n]\n\nconst entityKeyList = [\n 'MOL_ID', 'MOLECULE', 'CHAIN', 'FRAGMENT', 'SYNONYM',\n 'EC', 'ENGINEERED', 'MUTATION', 'OTHER_DETAILS'\n]\n\nconst reWhitespace = /\\s+/\n\nfunction getModresId (resno: number, chainname?: string, inscode?: string) {\n let id = `${resno}`\n if (chainname) id += `:${chainname}`\n if (inscode) id += `^${inscode}`\n return id\n}\n\nexport interface PdbParserParameters extends ParserParameters {\n hex: boolean\n inferBonds: InferBondsOptions\n}\n\nclass PdbParser extends StructureParser {\n\n hex: boolean\n inferBonds: InferBondsOptions\n\n /**\n * Create a pdb parser\n * @param {Streamer} streamer - streamer object\n * @param {Object} params - params object\n * @param {Boolean} params.hex - hexadecimal parsing of\n * atom numbers >99.999 and\n * residue numbers >9.999\n * @param {InferBondsOptions} params.inferBonds: 'all': use explicit bonds and detect by distance\n * 'auto': If a hetgroup residue has explicit bonds, don't auto-detect\n * 'none': Don't add any bonds automatically\n * @return {undefined}\n */\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.hex = defaults(p.hex, false)\n this.inferBonds = defaults(p.inferBonds, 'all')\n }\n\n get type () { return 'pdb' }\n\n _parse () {\n // http://www.wwpdb.org/documentation/file-format.php\n\n if (Debug) Log.time('PdbParser._parse ' + this.name)\n\n let isLegacy = false\n const headerLine = this.streamer.peekLines(1)[ 0 ]\n const headerId = headerLine.substr(62, 4)\n const legacyId = headerLine.substr(72, 4)\n if (headerId === legacyId && legacyId.trim()) {\n isLegacy = true\n }\n\n const isPqr = this.type === 'pqr'\n const isPdbqt = this.type === 'pdbqt'\n\n const s: Structure = this.structure\n const sb = this.structureBuilder\n\n const hex = this.hex\n let serialRadix = 10\n let resnoRadix = 10\n\n const firstModelOnly = this.firstModelOnly\n const asTrajectory = this.asTrajectory\n const cAlphaOnly = this.cAlphaOnly\n\n const frames = s.frames\n const boxes = s.boxes\n let doFrames = false\n let currentFrame: NumberArray, currentCoord: number\n\n const biomolDict = s.biomolDict\n let currentBiomol: Assembly\n let currentPart: AssemblyPart\n let currentMatrix: Matrix4\n\n let line, recordName\n let serial, chainname: string, resno: number, resname: string, occupancy: number\n let inscode: string, atomname, hetero: boolean, bfactor: number, altloc\n let formalCharge: number\n\n let startChain, startResi, startIcode\n let endChain, endResi, endIcode\n\n let serialDict: {[k: number]: number} = {}\n const unitcellDict: Partial<{\n origx: Matrix4\n scale: Matrix4\n a: number\n b: number\n c: number\n alpha: number\n beta: number\n gamma: number\n spacegroup: string\n }> = {}\n const bondDict: {[k: string]: boolean} = {}\n\n const entityDataList: {chainList: string[], name: string}[] = []\n let currentEntityData: {chainList: string[], name: string}\n let currentEntityKey: 'MOL_ID'|'MOLECULE'|'CHAIN'|'FRAGMENT'|'SYNONYM'|'EC'|'ENGINEERED'|'MUTATION'|'OTHER_DETAILS'\n // MOL_ID Numbers each component; also used in SOURCE to associate\n // the information.\n // MOLECULE Name of the macromolecule.\n // CHAIN Comma-separated list of chain identifier(s).\n // FRAGMENT Specifies a domain or region of the molecule.\n // SYNONYM Comma-separated list of synonyms for the MOLECULE.\n // EC The Enzyme Commission number associated with the molecule.\n // If there is more than one EC number, they are presented\n // as a comma-separated list.\n // ENGINEERED Indicates that the molecule was produced using\n // recombinant technology or by purely chemical synthesis.\n // MUTATION Indicates if there is a mutation.\n // OTHER_DETAILS Additional comments.\n\n const hetnameDict: {[k: string]: string} = {}\n const modresDict: {[k: string]: any} = {}\n\n const chainDict: {[k: string]: number} = {}\n let chainIdx: number, chainid: string, newChain: boolean\n let currentChainname: string, currentResno: number, currentResname: string, currentInscode: string\n\n const seqresDict: {[k: string]: string[]} = {}\n let currentSeqresChainname: string\n\n const secStruct = {\n helices: [] as any[],\n sheets: [] as any[]\n }\n const helices = secStruct.helices\n const sheets = secStruct.sheets\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.resize(Math.round(this.streamer.data.length / 80))\n if (isPqr || isPdbqt) atomStore.addField('partialCharge', 1, 'float32')\n if (isPqr) atomStore.addField('radius', 1, 'float32')\n\n const ap1 = s.getAtomProxy()\n const ap2 = s.getAtomProxy()\n\n let idx = 0\n let modelIdx = 0\n let pendingStart = true\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n line = lines[ i ]\n recordName = line.substr(0, 6)\n\n if (recordName === 'ATOM ' || recordName === 'HETATM') {\n // http://www.wwpdb.org/documentation/file-format-content/format33/sect9.html#ATOM\n // PQR: Field_name Atom_number Atom_name Residue_name Chain_ID Residue_number X Y Z Charge Radius\n\n if (pendingStart) {\n if (asTrajectory) {\n if (doFrames) {\n currentFrame = new Float32Array(atomStore.count * 3)\n frames.push(currentFrame)\n } else {\n currentFrame = []\n }\n currentCoord = 0\n } else {\n if (!firstModelOnly) serialDict = {}\n }\n\n chainIdx = 1\n chainid = chainIdx.toString()\n newChain = true\n\n pendingStart = false\n }\n\n if (firstModelOnly && modelIdx > 0) continue\n\n let x, y, z, ls: string[], dd = 0\n\n if (isPqr) {\n ls = line.split(reWhitespace)\n dd = ls.length === 10 ? 1 : 0\n\n atomname = ls[ 2 ]\n if (cAlphaOnly && atomname !== 'CA') continue\n\n x = parseFloat(ls[ 6 - dd ])\n y = parseFloat(ls[ 7 - dd ])\n z = parseFloat(ls[ 8 - dd ])\n } else {\n atomname = line.substr(12, 4).trim()\n if (cAlphaOnly && atomname !== 'CA') continue\n\n x = parseFloat(line.substr(30, 8))\n y = parseFloat(line.substr(38, 8))\n z = parseFloat(line.substr(46, 8))\n }\n\n if (asTrajectory) {\n const j = currentCoord * 3\n\n currentFrame[ j + 0 ] = x\n currentFrame[ j + 1 ] = y\n currentFrame[ j + 2 ] = z\n\n currentCoord += 1\n\n if (doFrames) continue\n }\n\n let element\n\n if (isPqr) {\n serial = parseInt(ls![ 1 ])\n element = ''\n hetero = (line[ 0 ] === 'H')\n chainname = dd ? '' : ls![ 4 ]\n resno = parseInt(ls![ 5 - dd! ])\n inscode = ''\n resname = ls![ 3 ]\n altloc = ''\n occupancy = 1.0\n } else {\n serial = parseInt(line.substr(6, 5), serialRadix)\n if (hex && serial === 99999) {\n serialRadix = 16\n }\n hetero = (line[ 0 ] === 'H')\n chainname = line[ 21 ].trim()\n resno = parseInt(line.substr(22, 4), resnoRadix)\n if (hex && resno === 9999) {\n resnoRadix = 16\n }\n inscode = line[ 26 ].trim()\n resname = line.substr(17, 4).trim() || 'MOL'\n bfactor = parseFloat(line.substr(60, 6))\n altloc = line[ 16 ].trim()\n occupancy = parseFloat(line.substr(54, 6))\n\n if (!isLegacy) {\n if (isPdbqt) {\n element = line.substr(76, 3).trim()\n // @ts-expect-error TS limitation on narrowing indexes types with `in`\n if (element in PDBQTSpecialElements) element = PDBQTSpecialElements[element]\n } else {\n element = line.substr(76, 2).trim()\n if (!chainname) {\n chainname = line.substr(72, 4).trim() // segid\n }\n }\n // Where specified, formalCharge is of form \"2-\" or \"1+\"\n formalCharge = parseInt((line.substr(79,1) + line.substr(78, 1)).trim())\n }\n }\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname, element)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = serial\n atomStore.altloc[ idx ] = altloc.charCodeAt(0)\n atomStore.occupancy[ idx ] = isNaN(occupancy) ? 0 : occupancy\n\n if (isPqr) {\n atomStore.partialCharge![ idx ] = parseFloat(ls![ 9 - dd! ])\n atomStore.radius[ idx ] = parseFloat(ls![ 10 - dd! ])\n } else {\n atomStore.bfactor[ idx ] = isNaN(bfactor) ? 0 : bfactor\n if (isPdbqt) {\n atomStore.partialCharge![ idx ] = parseFloat(line.substr(70, 6))\n }\n // isFinite check will reject undefined (in legacy case) and NaN values\n if (isFinite(formalCharge)) {\n if (!atomStore.formalCharge) {\n atomStore.addField('formalCharge', 1, 'int8')\n }\n atomStore.formalCharge![ idx ] = formalCharge\n }\n }\n\n const modresId = getModresId(resno, chainname, inscode)\n\n // TODO instead of looking at MODRES look at SEQRES and\n // missing residues in REMARK 465\n if (hetero && !modresDict[modresId] && !dAminoAcids.includes(resname)) {\n if (currentChainname !== chainname || currentResname !== resname ||\n (!WaterNames.includes(resname) &&\n (currentResno !== resno || currentInscode !== inscode))\n ) {\n chainIdx += 1\n chainid = chainIdx.toString()\n\n currentResno = resno\n currentResname = resname\n currentInscode = inscode\n }\n } else if (!newChain && currentChainname !== chainname) {\n chainIdx += 1\n chainid = chainIdx.toString()\n }\n\n sb.addAtom(modelIdx, chainname, chainid, resname, resno, hetero, undefined, inscode)\n\n serialDict[ serial ] = idx\n idx += 1\n newChain = false\n currentChainname = chainname\n } else if (recordName === 'CONECT') {\n const fromIdx = serialDict[ parseInt(line.substr(6, 5)) ]\n const pos = [ 11, 16, 21, 26 ]\n const bondIndex: {[k: number]: number} = {}\n\n if (fromIdx === undefined) {\n // Log.log( \"missing CONNECT serial\" );\n continue\n }\n\n for (let j = 0; j < 4; ++j) {\n let toIdx = parseInt(line.substr(pos[ j ], 5))\n if (Number.isNaN(toIdx)) continue\n toIdx = serialDict[ toIdx ]\n if (toIdx === undefined) {\n // Log.log( \"missing CONNECT serial\" );\n continue\n }/* else if( toIdx < fromIdx ){\n // likely a duplicate in standard PDB format\n // but not necessarily, so better remove duplicates\n // in a pass after parsing (and auto bonding)\n continue;\n } */\n\n if (fromIdx < toIdx) {\n ap1.index = fromIdx\n ap2.index = toIdx\n } else {\n ap1.index = toIdx\n ap2.index = fromIdx\n }\n\n // interpret records where a 'toIdx' atom is given multiple times\n // as double/triple bonds, e.g. CONECT 1529 1528 1528 is a double bond\n if (bondIndex[ toIdx ] !== undefined) {\n s.bondStore.bondOrder[ bondIndex[ toIdx ] ] += 1\n } else {\n const hash = ap1.index + '|' + ap2.index\n if (bondDict[ hash ] === undefined) {\n bondDict[ hash ] = true\n bondIndex[ toIdx ] = s.bondStore.count\n s.bondStore.addBond(ap1, ap2, 1) // start/assume with single bond\n }\n }\n }\n } else if (recordName === 'HELIX ') {\n startChain = line[ 19 ].trim()\n startResi = parseInt(line.substr(21, 4))\n startIcode = line[ 25 ].trim()\n endChain = line[ 31 ].trim()\n endResi = parseInt(line.substr(33, 4))\n endIcode = line[ 37 ].trim()\n let helixType = parseInt(line.substr(39, 1))\n helixType = (HelixTypes[ helixType ] || HelixTypes[0]).charCodeAt(0)\n helices.push([\n startChain, startResi, startIcode,\n endChain, endResi, endIcode,\n helixType\n ])\n } else if (recordName === 'SHEET ') {\n startChain = line[ 21 ].trim()\n startResi = parseInt(line.substr(22, 4))\n startIcode = line[ 26 ].trim()\n endChain = line[ 32 ].trim()\n endResi = parseInt(line.substr(33, 4))\n endIcode = line[ 37 ].trim()\n sheets.push([\n startChain, startResi, startIcode,\n endChain, endResi, endIcode\n ])\n } else if (recordName === 'HETNAM') {\n hetnameDict[ line.substr(11, 3) ] = line.substr(15).trim()\n } else if (recordName === 'SEQRES') {\n const seqresChainname = line[11].trim()\n if (seqresChainname !== currentSeqresChainname) {\n seqresDict[ seqresChainname ] = []\n currentSeqresChainname = seqresChainname\n }\n seqresDict[ seqresChainname ].push(\n ...line.substr(19).trim().split(reWhitespace)\n )\n } else if (recordName === 'MODRES') {\n // MODRES 2SRC PTR A 527 TYR O-PHOSPHOTYROSINE\n const resname = line.substr(12, 3).trim()\n const chainname = line[16].trim()\n const inscode = line[22].trim()\n const resno = parseInt(line.substr(18, 4).trim())\n const id = getModresId(resno, chainname, inscode)\n modresDict[ id ] = { resname, chainname, inscode, resno }\n } else if (recordName === 'COMPND') {\n const comp = line.substr(10, 70).trim()\n const keyEnd = comp.indexOf(':')\n const key = comp.substring(0, keyEnd)\n let value\n\n if (entityKeyList.includes(key)) {\n currentEntityKey = key as 'MOL_ID'|'MOLECULE'|'CHAIN'|'FRAGMENT'|'SYNONYM'|'EC'|'ENGINEERED'|'MUTATION'|'OTHER_DETAILS'\n value = comp.substring(keyEnd + 2)\n } else {\n value = comp\n }\n value = value.replace(/;$/, '')\n\n if (currentEntityKey === 'MOL_ID') {\n currentEntityData = {\n chainList: [],\n name: ''\n }\n entityDataList.push(currentEntityData)\n } else if (currentEntityKey === 'MOLECULE') {\n if (currentEntityData.name) currentEntityData.name += ' '\n currentEntityData.name += value\n } else if (currentEntityKey === 'CHAIN') {\n Array.prototype.push.apply(\n currentEntityData.chainList,\n value.split(/\\s*,\\s*/)\n )\n }\n } else if (line.startsWith('TER')) {\n const cp = s.getChainProxy(s.chainStore.count - 1)\n chainDict[ cp.chainname ] = cp.index\n chainIdx += 1\n chainid = chainIdx.toString()\n newChain = true\n } else if (recordName === 'REMARK' && line.substr(7, 3) === '350') {\n if (line.substr(11, 12) === 'BIOMOLECULE:') {\n let name = line.substr(23).trim()\n if (/^(0|[1-9][0-9]*)$/.test(name)) name = 'BU' + name\n\n currentBiomol = new Assembly(name)\n biomolDict[ name ] = currentBiomol\n } else if (line.substr(13, 5) === 'BIOMT') {\n const biomt = line.split(/\\s+/)\n const row = parseInt(line[ 18 ]) - 1\n\n if (row === 0) {\n currentMatrix = new Matrix4()\n currentPart.matrixList.push(currentMatrix)\n }\n\n const biomtElms = currentMatrix.elements\n\n biomtElms[ 4 * 0 + row ] = parseFloat(biomt[ 4 ])\n biomtElms[ 4 * 1 + row ] = parseFloat(biomt[ 5 ])\n biomtElms[ 4 * 2 + row ] = parseFloat(biomt[ 6 ])\n biomtElms[ 4 * 3 + row ] = parseFloat(biomt[ 7 ])\n } else if (\n line.substr(11, 30) === 'APPLY THE FOLLOWING TO CHAINS:' ||\n line.substr(11, 30) === ' AND CHAINS:'\n ) {\n if (line.substr(11, 5) === 'APPLY') {\n currentPart = currentBiomol.addPart()\n }\n\n const chainList = line.substr(41, 30).split(',')\n for (let j = 0, jl = chainList.length; j < jl; ++j) {\n const c = chainList[ j ].trim()\n if (c) currentPart.chainList.push(c)\n }\n }\n } else if (recordName === 'HEADER') {\n s.id = line.substr(62, 4)\n } else if (recordName === 'TITLE ') {\n s.title += (s.title ? ' ' : '') + line.substr(10, 70).trim()\n } else if (recordName === 'MODEL ') {\n pendingStart = true\n } else if (recordName === 'ENDMDL' || line.trim() === 'END') {\n if (pendingStart) continue\n\n if (asTrajectory && !doFrames) {\n frames.push(new Float32Array(currentFrame))\n doFrames = true\n }\n\n modelIdx += 1\n pendingStart = true\n } else if (line.substr(0, 5) === 'MTRIX') {\n // ignore 'given' operators\n if (line[ 59 ] === '1') continue\n\n if (!currentBiomol || currentBiomol.name !== 'NCS') {\n const ncsName = 'NCS'\n currentBiomol = new Assembly(ncsName)\n biomolDict[ ncsName ] = currentBiomol\n currentPart = currentBiomol.addPart()\n }\n\n const ncs = line.split(/\\s+/)\n const ncsRow = parseInt(line[ 5 ]) - 1\n\n if (ncsRow === 0) {\n currentMatrix = new Matrix4()\n currentPart.matrixList.push(currentMatrix)\n }\n\n const ncsElms = currentMatrix.elements\n\n ncsElms[ 4 * 0 + ncsRow ] = parseFloat(ncs[ 2 ])\n ncsElms[ 4 * 1 + ncsRow ] = parseFloat(ncs[ 3 ])\n ncsElms[ 4 * 2 + ncsRow ] = parseFloat(ncs[ 4 ])\n ncsElms[ 4 * 3 + ncsRow ] = parseFloat(ncs[ 5 ])\n } else if (line.substr(0, 5) === 'ORIGX') {\n if (!unitcellDict.origx) {\n unitcellDict.origx = new Matrix4()\n }\n\n const orgix = line.split(/\\s+/)\n const origxRow = parseInt(line[ 5 ]) - 1\n const origxElms = unitcellDict.origx.elements\n\n origxElms[ 4 * 0 + origxRow ] = parseFloat(orgix[ 1 ])\n origxElms[ 4 * 1 + origxRow ] = parseFloat(orgix[ 2 ])\n origxElms[ 4 * 2 + origxRow ] = parseFloat(orgix[ 3 ])\n origxElms[ 4 * 3 + origxRow ] = parseFloat(orgix[ 4 ])\n } else if (line.substr(0, 5) === 'SCALE') {\n if (!unitcellDict.scale) {\n unitcellDict.scale = new Matrix4()\n }\n\n const scale = line.split(/\\s+/)\n const scaleRow = parseInt(line[ 5 ]) - 1\n const scaleElms = unitcellDict.scale.elements\n\n scaleElms[ 4 * 0 + scaleRow ] = parseFloat(scale[ 1 ])\n scaleElms[ 4 * 1 + scaleRow ] = parseFloat(scale[ 2 ])\n scaleElms[ 4 * 2 + scaleRow ] = parseFloat(scale[ 3 ])\n scaleElms[ 4 * 3 + scaleRow ] = parseFloat(scale[ 4 ])\n } else if (recordName === 'CRYST1') {\n // CRYST1 55.989 55.989 55.989 90.00 90.00 90.00 P 1 1\n // 7 - 15 Real(9.3) a (Angstroms)\n // 16 - 24 Real(9.3) b (Angstroms)\n // 25 - 33 Real(9.3) c (Angstroms)\n // 34 - 40 Real(7.2) alpha alpha (degrees).\n // 41 - 47 Real(7.2) beta beta (degrees).\n // 48 - 54 Real(7.2) gamma gamma (degrees).\n // 56 - 66 LString sGroup Space group.\n // 67 - 70 Integer z Z value.\n\n const aLength = parseFloat(line.substr(6, 9))\n const bLength = parseFloat(line.substr(15, 9))\n const cLength = parseFloat(line.substr(24, 9))\n\n const alpha = parseFloat(line.substr(33, 7))\n const beta = parseFloat(line.substr(40, 7))\n const gamma = parseFloat(line.substr(47, 7))\n\n const sGroup = line.substr(55, 11).trim()\n // const zValue = parseInt( line.substr( 66, 4 ) );\n\n const box = new Float32Array(9)\n box[ 0 ] = aLength\n box[ 4 ] = bLength\n box[ 8 ] = cLength\n boxes.push(box)\n\n if (modelIdx === 0) {\n unitcellDict.a = aLength\n unitcellDict.b = bLength\n unitcellDict.c = cLength\n unitcellDict.alpha = alpha\n unitcellDict.beta = beta\n unitcellDict.gamma = gamma\n unitcellDict.spacegroup = sGroup\n }\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n\n // finalize ensures resname will be defined for all rp.resname\n // (required in entity handling below)\n sb.finalize()\n\n //\n\n const en = entityDataList.length\n\n if (en) {\n s.eachChain(function (cp) {\n cp.entityIndex = en\n })\n\n entityDataList.forEach(function (e, i) {\n const chainIndexList = e.chainList.map(function (chainname) {\n return chainDict[ chainname ]\n })\n s.entityList.push(new Entity(\n s, i, e.name, 'polymer', chainIndexList\n ))\n })\n\n let ei = entityDataList.length\n const rp = s.getResidueProxy()\n const residueDict: {[k: string]: number[]} = {}\n\n s.eachChain(function (cp) {\n if (cp.entityIndex === en) {\n rp.index = cp.residueOffset\n if (!residueDict[ rp.resname ]) {\n residueDict[ rp.resname ] = []\n }\n residueDict[ rp.resname ].push(cp.index)\n }\n })\n\n Object.keys(residueDict).forEach(function (resname) {\n const chainList = residueDict[ resname ]\n let type: EntityTypeString = 'non-polymer'\n let name = hetnameDict[ resname ] || resname\n if (WaterNames.includes(resname)) {\n name = 'water'\n type = 'water'\n }\n s.entityList.push(new Entity(\n s, ei, name, type, chainList\n ))\n ei += 1\n })\n }\n\n //\n\n if (unitcellDict.a !== undefined) {\n s.unitcell = new Unitcell(unitcellDict as UnitcellParams)\n } else {\n s.unitcell = undefined\n }\n\n if (helices.length || sheets.length) {\n assignSecondaryStructure(s, secStruct)\n }\n\n s.finalizeAtoms()\n if (!isLegacy) calculateChainnames(s)\n calculateBonds(s, this.inferBonds)\n s.finalizeBonds()\n\n if (!helices.length && !sheets.length) {\n calculateSecondaryStructure(s)\n }\n buildUnitcellAssembly(s)\n\n if (Debug) Log.timeEnd('PdbParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('pdb', PdbParser)\nParserRegistry.add('pdb1', PdbParser)\nParserRegistry.add('ent', PdbParser)\n\nexport default PdbParser\n\nexport {\n HelixTypes\n}\n","/**\n * @file Cif Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport { HelixTypes } from './pdb-parser'\nimport Entity from '../structure/entity'\nimport Unitcell, { UnitcellParams } from '../symmetry/unitcell'\nimport Assembly from '../symmetry/assembly'\nimport Selection from '../selection/selection'\nimport {\n assignResidueTypeBonds, assignSecondaryStructure, buildUnitcellAssembly,\n calculateBonds, calculateSecondaryStructure\n} from '../structure/structure-utils'\nimport { Structure } from '../ngl';\nimport StructureBuilder from '../structure/structure-builder';\nimport { NumberArray } from '../types';\n\nconst reWhitespace = /\\s+/\nconst reQuotedWhitespace = /'((?:(?!'\\s).)*)'|\"((?:(?!\"\\s).)*)\"|(\\S+)/g\nconst reDoubleQuote = /\"/g\nconst reTrimQuotes = /^['\"]+|['\"]+$/g\n\ninterface Cif {[k: string]: any}\n\nfunction trimQuotes (str: string) {\n if (str && str[0] === str[ str.length - 1 ] && (str[0] === \"'\" || str[0] === '\"')) {\n return str.substring(1, str.length - 1)\n } else {\n return str\n }\n}\n\nfunction ensureArray (dict: {[k: string]: any[]}, field: string) {\n if (!Array.isArray(dict[ field ])) {\n Object.keys(dict).forEach(function (key) {\n dict[ key ] = [ dict[ key ] ]\n })\n }\n}\n\nfunction hasValue (d: string) {\n return d !== '?'\n}\n\nfunction cifDefaults (value: string, defaultValue: string) {\n return hasValue(value) ? value : defaultValue\n}\n\nfunction getBondOrder (valueOrder: string) {\n switch (valueOrder.toLowerCase()) {\n case '?': // assume single bond\n case 'sing':\n return 1\n case 'doub':\n return 2\n case 'trip':\n return 3\n case 'quad':\n return 4\n }\n return 0\n}\n\nfunction parseChemComp (cif: Cif, structure: Structure, structureBuilder: StructureBuilder) {\n const atomStore = structure.atomStore\n const atomMap = structure.atomMap\n\n let i, n\n const cc = cif.chem_comp\n const cca = cif.chem_comp_atom\n const ccb = cif.chem_comp_bond\n\n if (cc) {\n if (cc.name) {\n structure.title = cc.name.trim().replace(reTrimQuotes, '')\n }\n if (cc.id) {\n structure.id = cc.id.trim().replace(reTrimQuotes, '')\n }\n }\n\n var atomnameDict: {[k: string]: number} = {}\n\n if (cca) {\n ensureArray(cca, 'comp_id')\n\n var atomname, element, resname, resno\n n = cca.comp_id.length\n\n for (i = 0; i < n; ++i) {\n atomStore.growIfFull()\n\n atomname = cca.atom_id[ i ].replace(reDoubleQuote, '')\n element = cca.type_symbol[ i ]\n\n atomnameDict[ atomname ] = i\n atomStore.atomTypeId[ i ] = atomMap.add(atomname, element)\n\n atomStore.x[ i ] = cca.model_Cartn_x[ i ]\n atomStore.y[ i ] = cca.model_Cartn_y[ i ]\n atomStore.z[ i ] = cca.model_Cartn_z[ i ]\n atomStore.serial[ i ] = i\n\n resname = cca.pdbx_component_comp_id[ i ]\n resno = cca.pdbx_residue_numbering ? cca.pdbx_residue_numbering[ i ] : 1\n\n structureBuilder.addAtom(0, '', '', resname, resno, true)\n }\n\n for (i = 0; i < n; ++i) {\n var j = i + n\n\n atomStore.growIfFull()\n\n atomname = cca.atom_id[ i ].replace(reDoubleQuote, '')\n element = cca.type_symbol[ i ]\n\n atomStore.atomTypeId[ j ] = atomMap.add(atomname, element)\n\n atomStore.x[ j ] = cca.pdbx_model_Cartn_x_ideal[ i ]\n atomStore.y[ j ] = cca.pdbx_model_Cartn_y_ideal[ i ]\n atomStore.z[ j ] = cca.pdbx_model_Cartn_z_ideal[ i ]\n atomStore.serial[ j ] = j\n\n resname = cca.pdbx_component_comp_id[ i ]\n resno = cca.pdbx_residue_numbering ? cca.pdbx_residue_numbering[ i ] : 1\n\n structureBuilder.addAtom(1, '', '', resname, resno, true)\n }\n }\n\n if (cca && ccb) {\n ensureArray(ccb, 'comp_id')\n\n var atomname1, atomname2, bondOrder\n n = ccb.comp_id.length\n var na = cca.comp_id.length\n\n var ap1 = structure.getAtomProxy()\n var ap2 = structure.getAtomProxy()\n\n for (i = 0; i < n; ++i) {\n atomname1 = ccb.atom_id_1[ i ].replace(reDoubleQuote, '')\n atomname2 = ccb.atom_id_2[ i ].replace(reDoubleQuote, '')\n bondOrder = getBondOrder(ccb.value_order[ i ])\n\n ap1.index = atomnameDict[ atomname1 ]\n ap2.index = atomnameDict[ atomname2 ]\n structure.bondStore.growIfFull()\n structure.bondStore.addBond(ap1, ap2, bondOrder)\n\n ap1.index += na\n ap2.index += na\n structure.bondStore.growIfFull()\n structure.bondStore.addBond(ap1, ap2, bondOrder)\n }\n }\n}\n\nfunction parseCore (cif: Cif, structure: Structure, structureBuilder: StructureBuilder) {\n var atomStore = structure.atomStore\n var atomMap = structure.atomMap\n\n if (cif.data) {\n structure.id = cif.data\n structure.name = cif.data\n }\n\n structure.unitcell = new Unitcell({\n a: parseFloat(cif.cell_length_a),\n b: parseFloat(cif.cell_length_b),\n c: parseFloat(cif.cell_length_c),\n alpha: parseFloat(cif.cell_angle_alpha),\n beta: parseFloat(cif.cell_angle_beta),\n gamma: parseFloat(cif.cell_angle_gamma),\n spacegroup: trimQuotes(cif['symmetry_space_group_name_H-M'])\n })\n\n const v = new Vector3()\n const c = new Vector3()\n const n = cif.atom_site_type_symbol.length\n\n for (let i = 0; i < n; ++i) {\n atomStore.growIfFull()\n\n const atomname = cif.atom_site_label[ i ]\n const element = cif.atom_site_type_symbol[ i ]\n\n atomStore.atomTypeId[ i ] = atomMap.add(atomname, element)\n\n v.set(\n cif.atom_site_fract_x[ i ],\n cif.atom_site_fract_y[ i ],\n cif.atom_site_fract_z[ i ]\n )\n v.applyMatrix4(structure.unitcell.fracToCart)\n c.add(v)\n\n atomStore.x[ i ] = v.x\n atomStore.y[ i ] = v.y\n atomStore.z[ i ] = v.z\n if (cif.atom_site_occupancy) {\n atomStore.occupancy[ i ] = parseFloat(cif.atom_site_occupancy[ i ])\n }\n atomStore.serial[ i ] = i\n\n structureBuilder.addAtom(0, '', '', 'HET', 1, true)\n }\n\n c.divideScalar(n)\n structure.center = c\n buildUnitcellAssembly(structure)\n\n const v2 = new Vector3()\n const v3 = new Vector3()\n const ml = structure.biomolDict.SUPERCELL.partList[ 0 ].matrixList\n\n let k = n\n\n function covalent (idx: number) {\n return atomMap.get(atomStore.atomTypeId[ idx ]).covalent\n }\n const identityMatrix = new Matrix4()\n\n for (let i = 0; i < n; ++i) {\n const covalentI = covalent(i)\n\n v.set(\n atomStore.x[ i ],\n atomStore.y[ i ],\n atomStore.z[ i ]\n )\n\n ml.forEach(function (m) {\n if (identityMatrix.equals(m)) return\n\n v2.copy(v)\n v2.applyMatrix4(m)\n\n for (let j = 0; j < n; ++j) {\n v3.set(\n atomStore.x[ j ],\n atomStore.y[ j ],\n atomStore.z[ j ]\n )\n\n const distSquared = v2.distanceToSquared(v3)\n const d = covalent(j) + covalentI\n const d1 = d + 0.3\n const d2 = d - 0.5\n\n if (distSquared < (d1 * d1) && distSquared > (d2 * d2)) {\n atomStore.growIfFull()\n\n atomStore.atomTypeId[ k ] = atomStore.atomTypeId[ i ]\n atomStore.x[ k ] = v2.x\n atomStore.y[ k ] = v2.y\n atomStore.z[ k ] = v2.z\n atomStore.occupancy[ k ] = atomStore.occupancy[ i ]\n atomStore.serial[ k ] = k\n atomStore.altloc[ k ] = 'A'.charCodeAt(0)\n\n structureBuilder.addAtom(0, '', '', 'HET', 1, true)\n\n k += 1\n return\n }\n }\n })\n }\n}\n\nfunction processSecondaryStructure (cif: Cif, structure: Structure, asymIdDict: {[k: string]: string}) {\n var helices: [string, number, string, string, number, string, number][] = []\n var sheets: [string, number, string, string, number, string][] = []\n\n var i, il, begIcode, endIcode\n\n // get helices\n var sc = cif.struct_conf\n\n if (sc?.pdbx_PDB_helix_class) {\n ensureArray(sc, 'id')\n\n for (i = 0, il = sc.beg_auth_seq_id.length; i < il; ++i) {\n var helixType = parseInt(sc.pdbx_PDB_helix_class[ i ])\n if (!Number.isNaN(helixType)) {\n begIcode = sc.pdbx_beg_PDB_ins_code[ i ]\n endIcode = sc.pdbx_end_PDB_ins_code[ i ]\n helices.push([\n asymIdDict[ sc.beg_label_asym_id[ i ] ],\n parseInt(sc.beg_auth_seq_id[ i ]),\n cifDefaults(begIcode, ''),\n asymIdDict[ sc.end_label_asym_id[ i ] ],\n parseInt(sc.end_auth_seq_id[ i ]),\n cifDefaults(endIcode, ''),\n (HelixTypes[ helixType ] || HelixTypes[0]).charCodeAt(0)\n ])\n }\n }\n }\n\n // get sheets\n var ssr = cif.struct_sheet_range\n\n if (ssr) {\n ensureArray(ssr, 'id')\n\n for (i = 0, il = ssr.beg_auth_seq_id.length; i < il; ++i) {\n begIcode = ssr.pdbx_beg_PDB_ins_code[ i ]\n endIcode = ssr.pdbx_end_PDB_ins_code[ i ]\n sheets.push([\n asymIdDict[ ssr.beg_label_asym_id[ i ] ],\n parseInt(ssr.beg_auth_seq_id[ i ]),\n cifDefaults(begIcode, ''),\n asymIdDict[ ssr.end_label_asym_id[ i ] ],\n parseInt(ssr.end_auth_seq_id[ i ]),\n cifDefaults(endIcode, '')\n ])\n }\n }\n\n if (sc || ssr) {\n return {\n helices: helices,\n sheets: sheets\n }\n } else {\n return false\n }\n}\n\nfunction processSymmetry (cif: Cif, structure: Structure, asymIdDict: {[k: string]: string}) {\n // biomol & ncs processing\n var operDict: {[k: string]: Matrix4} = {}\n var biomolDict = structure.biomolDict\n\n if (cif.pdbx_struct_oper_list) {\n var biomolOp = cif.pdbx_struct_oper_list\n ensureArray(biomolOp, 'id')\n\n biomolOp.id.forEach(function (id: number, i: number) {\n var m = new Matrix4()\n var elms = m.elements\n\n elms[ 0 ] = parseFloat(biomolOp[ 'matrix[1][1]' ][ i ])\n elms[ 1 ] = parseFloat(biomolOp[ 'matrix[1][2]' ][ i ])\n elms[ 2 ] = parseFloat(biomolOp[ 'matrix[1][3]' ][ i ])\n\n elms[ 4 ] = parseFloat(biomolOp[ 'matrix[2][1]' ][ i ])\n elms[ 5 ] = parseFloat(biomolOp[ 'matrix[2][2]' ][ i ])\n elms[ 6 ] = parseFloat(biomolOp[ 'matrix[2][3]' ][ i ])\n\n elms[ 8 ] = parseFloat(biomolOp[ 'matrix[3][1]' ][ i ])\n elms[ 9 ] = parseFloat(biomolOp[ 'matrix[3][2]' ][ i ])\n elms[ 10 ] = parseFloat(biomolOp[ 'matrix[3][3]' ][ i ])\n\n elms[ 3 ] = parseFloat(biomolOp[ 'vector[1]' ][ i ])\n elms[ 7 ] = parseFloat(biomolOp[ 'vector[2]' ][ i ])\n elms[ 11 ] = parseFloat(biomolOp[ 'vector[3]' ][ i ])\n\n m.transpose()\n\n operDict[ id ] = m\n })\n }\n\n if (cif.pdbx_struct_assembly_gen) {\n var gen = cif.pdbx_struct_assembly_gen\n ensureArray(gen, 'assembly_id')\n\n var getMatrixDict = function (expr: string) {\n var matDict: {[k: string]: Matrix4} = {}\n\n var l = expr.replace(/[()']/g, '').split(',')\n\n l.forEach(function (e) {\n if (e.includes('-')) {\n var es = e.split('-')\n\n var j = parseInt(es[ 0 ])\n var m = parseInt(es[ 1 ])\n\n for (; j <= m; ++j) {\n matDict[ j ] = operDict[ j ]\n }\n } else {\n matDict[ e ] = operDict[ e ]\n }\n })\n\n return matDict\n }\n\n gen.assembly_id.forEach(function (id: string, i: number) {\n var md:{[k: string]: Matrix4} = {}\n var oe = gen.oper_expression[ i ].replace(/['\"]\\(|['\"]/g, '')\n\n if (oe.includes(')(') || oe.indexOf('(') > 0) {\n oe = oe.split('(')\n\n var md1 = getMatrixDict(oe[ 0 ])\n var md2 = getMatrixDict(oe[ 1 ])\n\n Object.keys(md1).forEach(function (k1) {\n Object.keys(md2).forEach(function (k2) {\n var mat = new Matrix4()\n\n mat.multiplyMatrices(md1[ k1 ], md2[ k2 ])\n md[ k1 + 'x' + k2 ] = mat\n })\n })\n } else {\n md = getMatrixDict(oe)\n }\n\n var matrixList = []\n for (var k in md) {\n matrixList.push(md[ k ])\n }\n\n var name = id\n if (/^(0|[1-9][0-9]*)$/.test(name)) name = 'BU' + name\n\n var chainList = gen.asym_id_list[ i ].split(',')\n for (var j = 0, jl = chainList.length; j < jl; ++j) {\n chainList[ j ] = asymIdDict[ chainList[ j ] ]\n }\n\n if (biomolDict[ name ] === undefined) {\n biomolDict[ name ] = new Assembly(name)\n }\n biomolDict[ name ].addPart(matrixList, chainList)\n })\n }\n\n // non-crystallographic symmetry operations\n if (cif.struct_ncs_oper) {\n var ncsOp = cif.struct_ncs_oper\n ensureArray(ncsOp, 'id')\n\n var ncsName = 'NCS'\n biomolDict[ ncsName ] = new Assembly(ncsName)\n var ncsPart = biomolDict[ ncsName ].addPart()\n\n ncsOp.id.forEach(function (id: string, i: number) {\n // ignore 'given' operators\n if (ncsOp.code[ i ] === 'given') return\n\n var m = new Matrix4()\n var elms = m.elements\n\n elms[ 0 ] = parseFloat(ncsOp[ 'matrix[1][1]' ][ i ])\n elms[ 1 ] = parseFloat(ncsOp[ 'matrix[1][2]' ][ i ])\n elms[ 2 ] = parseFloat(ncsOp[ 'matrix[1][3]' ][ i ])\n\n elms[ 4 ] = parseFloat(ncsOp[ 'matrix[2][1]' ][ i ])\n elms[ 5 ] = parseFloat(ncsOp[ 'matrix[2][2]' ][ i ])\n elms[ 6 ] = parseFloat(ncsOp[ 'matrix[2][3]' ][ i ])\n\n elms[ 8 ] = parseFloat(ncsOp[ 'matrix[3][1]' ][ i ])\n elms[ 9 ] = parseFloat(ncsOp[ 'matrix[3][2]' ][ i ])\n elms[ 10 ] = parseFloat(ncsOp[ 'matrix[3][3]' ][ i ])\n\n elms[ 3 ] = parseFloat(ncsOp[ 'vector[1]' ][ i ])\n elms[ 7 ] = parseFloat(ncsOp[ 'vector[2]' ][ i ])\n elms[ 11 ] = parseFloat(ncsOp[ 'vector[3]' ][ i ])\n\n m.transpose()\n\n ncsPart.matrixList.push(m)\n })\n\n if (ncsPart.matrixList.length === 0) {\n delete biomolDict[ ncsName ]\n }\n }\n\n // cell & symmetry\n const unitcellDict: {\n a?: number\n b?: number\n c?: number\n alpha?: number\n beta?: number\n gamma?: number\n spacegroup?: string\n origx?: Matrix4\n scale?: Matrix4\n } = {}\n\n if (cif.cell) {\n const cell = cif.cell\n\n const a = parseFloat(cell.length_a)\n const b = parseFloat(cell.length_b)\n const c = parseFloat(cell.length_c)\n\n const box = new Float32Array(9)\n box[ 0 ] = a\n box[ 4 ] = b\n box[ 8 ] = c\n structure.boxes.push(box)\n\n unitcellDict.a = a\n unitcellDict.b = b\n unitcellDict.c = c\n unitcellDict.alpha = parseFloat(cell.angle_alpha)\n unitcellDict.beta = parseFloat(cell.angle_beta)\n unitcellDict.gamma = parseFloat(cell.angle_gamma)\n }\n\n if (cif.symmetry) {\n unitcellDict.spacegroup = trimQuotes(\n cif.symmetry[ 'space_group_name_H-M' ]\n )\n }\n\n // origx\n var origx = new Matrix4()\n\n if (cif.database_PDB_matrix) {\n var origxMat = cif.database_PDB_matrix\n var origxElms = origx.elements\n\n origxElms[ 0 ] = parseFloat(origxMat[ 'origx[1][1]' ])\n origxElms[ 1 ] = parseFloat(origxMat[ 'origx[1][2]' ])\n origxElms[ 2 ] = parseFloat(origxMat[ 'origx[1][3]' ])\n\n origxElms[ 4 ] = parseFloat(origxMat[ 'origx[2][1]' ])\n origxElms[ 5 ] = parseFloat(origxMat[ 'origx[2][2]' ])\n origxElms[ 6 ] = parseFloat(origxMat[ 'origx[2][3]' ])\n\n origxElms[ 8 ] = parseFloat(origxMat[ 'origx[3][1]' ])\n origxElms[ 9 ] = parseFloat(origxMat[ 'origx[3][2]' ])\n origxElms[ 10 ] = parseFloat(origxMat[ 'origx[3][3]' ])\n\n origxElms[ 3 ] = parseFloat(origxMat[ 'origx_vector[1]' ])\n origxElms[ 7 ] = parseFloat(origxMat[ 'origx_vector[2]' ])\n origxElms[ 11 ] = parseFloat(origxMat[ 'origx_vector[3]' ])\n\n origx.transpose()\n\n unitcellDict.origx = origx\n }\n\n // scale\n var scale = new Matrix4()\n\n if (cif.atom_sites) {\n var scaleMat = cif.atom_sites\n var scaleElms = scale.elements\n\n scaleElms[ 0 ] = parseFloat(scaleMat[ 'fract_transf_matrix[1][1]' ])\n scaleElms[ 1 ] = parseFloat(scaleMat[ 'fract_transf_matrix[1][2]' ])\n scaleElms[ 2 ] = parseFloat(scaleMat[ 'fract_transf_matrix[1][3]' ])\n\n scaleElms[ 4 ] = parseFloat(scaleMat[ 'fract_transf_matrix[2][1]' ])\n scaleElms[ 5 ] = parseFloat(scaleMat[ 'fract_transf_matrix[2][2]' ])\n scaleElms[ 6 ] = parseFloat(scaleMat[ 'fract_transf_matrix[2][3]' ])\n\n scaleElms[ 8 ] = parseFloat(scaleMat[ 'fract_transf_matrix[3][1]' ])\n scaleElms[ 9 ] = parseFloat(scaleMat[ 'fract_transf_matrix[3][2]' ])\n scaleElms[ 10 ] = parseFloat(scaleMat[ 'fract_transf_matrix[3][3]' ])\n\n scaleElms[ 3 ] = parseFloat(scaleMat[ 'fract_transf_vector[1]' ])\n scaleElms[ 7 ] = parseFloat(scaleMat[ 'fract_transf_vector[2]' ])\n scaleElms[ 11 ] = parseFloat(scaleMat[ 'fract_transf_vector[3]' ])\n\n scale.transpose()\n\n unitcellDict.scale = scale\n }\n\n if (unitcellDict.a !== undefined) {\n structure.unitcell = new Unitcell(unitcellDict as UnitcellParams)\n } else {\n structure.unitcell = undefined\n }\n}\n\nfunction processConnections (cif: Cif, structure: Structure, asymIdDict: {[k: string]: string}) {\n // add connections\n var sc = cif.struct_conn\n\n if (sc) {\n ensureArray(sc, 'id')\n\n var reDoubleQuote = /\"/g\n var ap1 = structure.getAtomProxy()\n var ap2 = structure.getAtomProxy()\n var atomIndicesCache: {[k: string]: Uint32Array|undefined} = {}\n\n for (var i = 0, il = sc.id.length; i < il; ++i) {\n // ignore:\n // hydrog - hydrogen bond\n // mismat - mismatched base pairs\n // saltbr - ionic interaction\n\n var connTypeId = sc.conn_type_id[ i ]\n if (connTypeId === 'hydrog' ||\n connTypeId === 'mismat' ||\n connTypeId === 'saltbr') continue\n\n // ignore bonds between symmetry mates\n if (sc.ptnr1_symmetry[ i ] !== '1_555' ||\n sc.ptnr2_symmetry[ i ] !== '1_555') continue\n\n // process:\n // covale - covalent bond\n // covale_base -\n // covalent modification of a nucleotide base\n // covale_phosphate -\n // covalent modification of a nucleotide phosphate\n // covale_sugar -\n // covalent modification of a nucleotide sugar\n // disulf - disulfide bridge\n // metalc - metal coordination\n // modres - covalent residue modification\n\n var inscode1 = sc.pdbx_ptnr1_PDB_ins_code[ i ]\n var altloc1 = sc.pdbx_ptnr1_label_alt_id[ i ]\n var sele1 = (\n sc.ptnr1_auth_seq_id[ i ] +\n (hasValue(inscode1) ? ('^' + inscode1) : '') +\n ':' + asymIdDict[ sc.ptnr1_label_asym_id[ i ] ] +\n '.' + sc.ptnr1_label_atom_id[ i ].replace(reDoubleQuote, '') +\n (hasValue(altloc1) ? ('%' + altloc1) : '')\n )\n var atomIndices1 = atomIndicesCache[ sele1 ]\n if (!atomIndices1) {\n var selection1 = new Selection(sele1)\n if (selection1.selection.error) {\n if (Debug) Log.warn('invalid selection for connection', sele1)\n continue\n }\n atomIndices1 = structure.getAtomIndices(selection1)\n atomIndicesCache[ sele1 ] = atomIndices1\n }\n\n var inscode2 = sc.pdbx_ptnr2_PDB_ins_code[ i ]\n var altloc2 = sc.pdbx_ptnr2_label_alt_id[ i ]\n var sele2 = (\n sc.ptnr2_auth_seq_id[ i ] +\n (hasValue(inscode2) ? ('^' + inscode2) : '') +\n ':' + asymIdDict[ sc.ptnr2_label_asym_id[ i ] ] +\n '.' + sc.ptnr2_label_atom_id[ i ].replace(reDoubleQuote, '') +\n (hasValue(altloc2) ? ('%' + altloc2) : '')\n )\n var atomIndices2 = atomIndicesCache[ sele2 ]\n if (!atomIndices2) {\n var selection2 = new Selection(sele2)\n if (selection2.selection.error) {\n if (Debug) Log.warn('invalid selection for connection', sele2)\n continue\n }\n atomIndices2 = structure.getAtomIndices(selection2)\n atomIndicesCache[ sele2 ] = atomIndices2\n }\n\n // cases with more than one atom per selection\n // - #altloc1 to #altloc2\n // - #model to #model\n // - #altloc1 * #model to #altloc2 * #model\n\n var k = atomIndices1!.length\n var l = atomIndices2!.length\n\n if (k > l) {\n var tmpA = k\n k = l\n l = tmpA\n var tmpB = atomIndices1\n atomIndices1 = atomIndices2\n atomIndices2 = tmpB\n }\n\n // console.log( k, l );\n\n if (k === 0 || l === 0) {\n if (Debug) Log.warn('no atoms found for', sele1, sele2)\n continue\n }\n\n for (var j = 0; j < l; ++j) {\n ap1.index = atomIndices1![ j % k ]\n ap2.index = atomIndices2![ j ]\n\n if (ap1 && ap2) {\n structure.bondStore.addBond(\n ap1, ap2, getBondOrder(sc.pdbx_value_order[ i ])\n )\n } else {\n Log.log('atoms for connection not found')\n }\n }\n }\n }\n}\n\nfunction processEntities (cif: Cif, structure: Structure, chainIndexDict: {[k: string]: Set}) {\n if (cif.entity) {\n ensureArray(cif.entity, 'id')\n var e = cif.entity\n var n = e.id.length\n for (var i = 0; i < n; ++i) {\n var description = e.pdbx_description[ i ]\n var type = e.type[ i ]\n var chainIndexList: number[] = Array.from(chainIndexDict[ e.id[ i ] ])\n structure.entityList[ i ] = new Entity(\n structure, i, description, type, chainIndexList\n )\n }\n }\n}\n\n//\n\nclass CifParser extends StructureParser {\n get type () { return 'cif' }\n\n _parse () {\n // http://mmcif.wwpdb.org/\n\n Log.time('CifParser._parse ' + this.name)\n\n var s = this.structure\n var sb = this.structureBuilder\n\n var firstModelOnly = this.firstModelOnly\n var asTrajectory = this.asTrajectory\n var cAlphaOnly = this.cAlphaOnly\n\n var frames = s.frames\n var currentFrame: NumberArray, currentCoord: number\n\n var rawline, line\n\n //\n\n var cif: Cif = {}\n var asymIdDict: {[k: string]: string} = {}\n var chainIndexDict:{[k: string]: Set} = {}\n\n var pendingString = false\n var currentString: string|null = null\n var pendingValue = false\n var pendingLoop = false\n var pendingName = false\n var loopPointers: string[][] = []\n var currentLoopIndex: number|null = null\n var currentCategory: string|null = null\n var currentName: string|boolean|null = null\n var first: boolean|null = null\n var pointerNames: string[] = []\n\n var authAsymId: number, authSeqId: number, labelSeqId: number,\n labelAtomId: number, labelCompId: number, labelAsymId: number, labelEntityId: number, labelAltId: number,\n groupPDB: number, id: number, typeSymbol: number, pdbxPDBmodelNum: number, pdbxPDBinsCode: number,\n CartnX: number, CartnY: number, CartnZ: number, bIsoOrEquiv: number, occupancy: number\n\n //\n\n var atomMap = s.atomMap\n var atomStore = s.atomStore\n atomStore.resize(this.streamer.data.length / 100)\n\n var idx = 0\n var modelIdx = 0\n var modelNum: number\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (var i = _i; i < _n; ++i) {\n rawline = lines[i]\n line = rawline.trim()\n\n if ((!line && !pendingString && !pendingLoop) || line[0] === '#') {\n // Log.log( \"NEW BLOCK\" );\n\n pendingString = false\n pendingLoop = false\n pendingValue = false\n loopPointers.length = 0\n currentLoopIndex = null\n currentCategory = null\n currentName = null\n first = null\n pointerNames.length = 0\n } else if (line.substring(0, 5) === 'data_') {\n cif.data = line.substring(5).trim()\n\n // Log.log( \"DATA\", data );\n } else if (line[0] === ';') {\n if (pendingString) {\n // Log.log( \"STRING END\", currentString );\n\n if (pendingLoop) {\n if (currentLoopIndex === loopPointers.length) {\n currentLoopIndex = 0\n }\n loopPointers[ currentLoopIndex as number ].push(currentString as string);\n (currentLoopIndex as number) += 1\n } else {\n if (currentName === false) {\n cif[ currentCategory as string ] = currentString\n } else {\n cif[ currentCategory as string ][ currentName as string ] = currentString //TODO currentname can equals null\n }\n }\n\n pendingString = false\n currentString = null\n } else {\n // Log.log( \"STRING START\" );\n\n pendingString = true\n currentString = line.substring(1)\n }\n } else if (line === 'loop_') {\n // Log.log( \"LOOP START\" );\n\n pendingLoop = true\n pendingName = true\n loopPointers.length = 0\n pointerNames.length = 0\n currentLoopIndex = 0\n } else if (line[0] === '_') {\n var keyParts, category, name\n\n if (pendingLoop && !pendingName) {\n pendingLoop = false\n }\n\n if (pendingLoop) {\n // Log.log( \"LOOP KEY\", line );\n\n keyParts = line.split('.')\n category = keyParts[ 0 ].substring(1)\n name = keyParts[ 1 ]\n\n if (keyParts.length === 1) {\n name = false\n if (!cif[ category ]) cif[ category ] = []\n loopPointers.push(cif[ category ])\n } else {\n if (!cif[ category ]) cif[ category ] = {}\n if (cif[ category ][ name ]) {\n if (Debug) Log.warn(category, name, 'already exists')\n } else {\n cif[ category ][ name ] = []\n loopPointers.push(cif[ category ][ name ])\n pointerNames.push(name)\n }\n }\n\n currentCategory = category\n currentName = name\n first = true\n } else {\n var keyValuePair = line.match(reQuotedWhitespace)\n var key = keyValuePair![ 0 ]\n var value = keyValuePair![ 1 ]\n keyParts = key.split('.')\n category = keyParts[ 0 ].substring(1)\n name = keyParts[ 1 ]\n\n if (keyParts.length === 1) {\n name = false\n cif[ category ] = value\n } else {\n if (!cif[ category ]) cif[ category ] = {}\n\n if (cif[ category ][ name ]) {\n if (Debug) Log.warn(category, name, 'already exists')\n } else {\n cif[ category ][ name ] = value\n }\n }\n\n if (!value) pendingValue = true\n\n currentCategory = category\n currentName = name\n }\n } else {\n if (pendingString) {\n // Log.log( \"STRING VALUE\", line );\n\n currentString += rawline\n } else if (pendingLoop) {\n // Log.log( \"LOOP VALUE\", line );\n\n if (!line) {\n continue\n } else if (currentCategory === 'atom_site') {\n const ls = line.split(reWhitespace)\n\n if (first) {\n authAsymId = pointerNames.indexOf('auth_asym_id')\n authSeqId = pointerNames.indexOf('auth_seq_id')\n labelSeqId = pointerNames.indexOf('label_seq_id')\n labelAtomId = pointerNames.indexOf('label_atom_id')\n labelCompId = pointerNames.indexOf('label_comp_id')\n labelAsymId = pointerNames.indexOf('label_asym_id')\n labelEntityId = pointerNames.indexOf('label_entity_id')\n labelAltId = pointerNames.indexOf('label_alt_id')\n CartnX = pointerNames.indexOf('Cartn_x')\n CartnY = pointerNames.indexOf('Cartn_y')\n CartnZ = pointerNames.indexOf('Cartn_z')\n id = pointerNames.indexOf('id')\n typeSymbol = pointerNames.indexOf('type_symbol')\n groupPDB = pointerNames.indexOf('group_PDB')\n bIsoOrEquiv = pointerNames.indexOf('B_iso_or_equiv')\n pdbxPDBmodelNum = pointerNames.indexOf('pdbx_PDB_model_num')\n\n pdbxPDBinsCode = pointerNames.indexOf('pdbx_PDB_ins_code')\n occupancy = pointerNames.indexOf('occupancy')\n\n first = false\n\n modelNum = parseInt(ls[ pdbxPDBmodelNum ])\n\n if (asTrajectory) {\n currentFrame = []\n currentCoord = 0\n }\n }\n\n //\n\n const _modelNum = parseInt(ls[ pdbxPDBmodelNum ])\n\n if (modelNum !== _modelNum) {\n if (asTrajectory) {\n if (modelIdx === 0) {\n frames.push(new Float32Array(currentFrame))\n }\n\n currentFrame = new Float32Array(atomStore.count * 3)\n frames.push(currentFrame)\n currentCoord = 0\n }\n\n modelIdx += 1\n }\n\n modelNum = _modelNum\n\n if (firstModelOnly && modelIdx > 0) continue\n\n //\n\n const atomname = ls[ labelAtomId ].replace(reDoubleQuote, '')\n if (cAlphaOnly && atomname !== 'CA') continue\n\n const x = parseFloat(ls[ CartnX ])\n const y = parseFloat(ls[ CartnY ])\n const z = parseFloat(ls[ CartnZ ])\n\n if (asTrajectory) {\n const frameOffset = currentCoord * 3\n\n currentFrame[ frameOffset + 0 ] = x\n currentFrame[ frameOffset + 1 ] = y\n currentFrame[ frameOffset + 2 ] = z\n\n currentCoord += 1\n\n if (modelIdx > 0) continue\n }\n\n //\n\n const resname = ls[ labelCompId ]\n const resno = parseInt(ls[ authSeqId !== -1 ? authSeqId : labelSeqId ])\n let inscode = ls[ pdbxPDBinsCode ]\n inscode = (inscode === '?') ? '' : inscode\n const chainname = ls[ authAsymId ]\n const chainid = ls[ labelAsymId ]\n const hetero = (ls[ groupPDB ][ 0 ] === 'H')\n\n //\n\n const element = ls[ typeSymbol ]\n const bfactor = parseFloat(ls[ bIsoOrEquiv ])\n const occ = parseFloat(ls[ occupancy ])\n let altloc = ls[ labelAltId ]\n altloc = (altloc === '.') ? '' : altloc\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname, element)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = parseInt(ls[ id ])\n atomStore.bfactor[ idx ] = isNaN(bfactor) ? 0 : bfactor\n atomStore.occupancy[ idx ] = isNaN(occ) ? 0 : occ\n atomStore.altloc[ idx ] = altloc.charCodeAt(0)\n\n sb.addAtom(modelIdx, chainname, chainid, resname, resno, hetero, undefined, inscode)\n\n if (Debug) {\n // check if one-to-many (chainname-asymId) relationship is\n // actually a many-to-many mapping\n const assignedChainname = asymIdDict[ chainid ]\n if (assignedChainname !== undefined && assignedChainname !== chainname) {\n if (Debug) Log.warn(assignedChainname, chainname)\n }\n }\n // chainname mapping: label_asym_id -> auth_asym_id\n asymIdDict[ chainid ] = chainname\n\n // entity mapping: chainIndex -> label_entity_id\n const entityId = ls[ labelEntityId ]\n if (!chainIndexDict[ entityId ]) {\n chainIndexDict[ entityId ] = new Set()\n }\n chainIndexDict[ entityId ].add(s.chainStore.count - 1)\n\n idx += 1\n } else {\n const ls = line.match(reQuotedWhitespace)\n const nn = ls!.length\n\n if (currentLoopIndex === loopPointers.length) {\n currentLoopIndex = 0\n }/* else if( currentLoopIndex + nn > loopPointers.length ){\n Log.warn( \"cif parsing error, wrong number of loop data entries\", nn, loopPointers.length );\n } */\n\n for (let j = 0; j < nn; ++j) {\n loopPointers[ currentLoopIndex + j ].push(ls![ j ])\n }\n\n (currentLoopIndex) += nn\n }\n\n pendingName = false\n } else if (line[0] === \"'\" && line[line.length - 1] === \"'\") {\n // Log.log( \"NEWLINE STRING\", line );\n\n const str = line.substring(1, line.length - 1)\n\n if (currentName === false) {\n cif[ currentCategory as string ] = str\n } else {\n cif[ currentCategory as string ][ currentName as string ] = str\n }\n } else if (pendingValue) {\n // Log.log( \"NEWLINE VALUE\", line );\n\n if (currentName === false) {\n cif[ currentCategory as string ] = line\n } else {\n cif[ currentCategory as string ][ currentName as string ] = line\n }\n } else {\n if (Debug) Log.log('CifParser._parse: unknown state', line)\n }\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n if (cif.chem_comp && cif.chem_comp_atom) {\n parseChemComp(cif, s, sb)\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n assignResidueTypeBonds(s)\n } else if (cif.atom_site_type_symbol && cif.atom_site_label && cif.atom_site_fract_x) {\n parseCore(cif, s, sb)\n sb.finalize()\n s.finalizeAtoms()\n calculateBonds(s)\n s.finalizeBonds()\n // assignResidueTypeBonds( s );\n } else {\n var secStruct = processSecondaryStructure(cif, s, asymIdDict)\n processSymmetry(cif, s, asymIdDict)\n processConnections(cif, s, asymIdDict)\n processEntities(cif, s, chainIndexDict)\n\n if (cif.struct && cif.struct.title) {\n s.title = cif.struct.title.trim().replace(reTrimQuotes, '')\n }\n if (cif.entry && cif.entry.id) {\n s.id = cif.entry.id.trim().replace(reTrimQuotes, '')\n }\n\n // structure header (mimicking biojava)\n if (cif.pdbx_audit_revision_history) {\n if (cif.pdbx_audit_revision_history.revision_date) {\n ensureArray(cif.pdbx_audit_revision_history, 'revision_date')\n const dates = cif.pdbx_audit_revision_history.revision_date.filter(hasValue)\n if (dates.length) {\n s.header.releaseDate = dates[ 0 ]\n }\n }\n if (cif.pdbx_database_status.recvd_initial_deposition_date) {\n ensureArray(cif.pdbx_database_status, 'recvd_initial_deposition_date')\n const depDates = cif.pdbx_database_status.recvd_initial_deposition_date.filter(hasValue)\n if (depDates.length) {\n s.header.depositionDate = depDates[ 0 ]\n }\n }\n } else if (cif.database_PDB_rev) {\n if (cif.database_PDB_rev.date) {\n ensureArray(cif.database_PDB_rev, 'date')\n const dates = cif.database_PDB_rev.date.filter(hasValue)\n if (dates.length) {\n s.header.releaseDate = dates[ 0 ]\n }\n }\n if (cif.database_PDB_rev.date_original) {\n ensureArray(cif.database_PDB_rev, 'date_original')\n const depDates = cif.database_PDB_rev.date_original.filter(hasValue)\n if (depDates.length) {\n s.header.depositionDate = depDates[ 0 ]\n }\n }\n }\n if (cif.reflns && cif.reflns.d_resolution_high) {\n if (hasValue(cif.reflns.d_resolution_high)) {\n s.header.resolution = parseFloat(cif.reflns.d_resolution_high)\n }\n } else if (cif.refine && cif.refine.ls_d_res_high) {\n if (hasValue(cif.refine.ls_d_res_high)) {\n s.header.resolution = parseFloat(cif.refine.ls_d_res_high)\n }\n }\n if (cif.refine && cif.refine.ls_R_factor_R_free) {\n if (hasValue(cif.refine.ls_R_factor_R_free)) {\n s.header.rFree = parseFloat(cif.refine.ls_R_factor_R_free)\n }\n }\n if (cif.refine && cif.refine.ls_R_factor_R_work) {\n if (hasValue(cif.refine.ls_R_factor_R_work)) {\n s.header.rWork = parseFloat(cif.refine.ls_R_factor_R_work)\n }\n }\n if (cif.exptl && cif.exptl.method) {\n ensureArray(cif.exptl, 'method')\n s.header.experimentalMethods = cif.exptl.method.map(function (m: string) {\n return m.replace(reTrimQuotes, '')\n })\n }\n\n sb.finalize()\n s.finalizeAtoms()\n calculateBonds(s)\n s.finalizeBonds()\n\n if (!secStruct) {\n calculateSecondaryStructure(s)\n } else {\n assignSecondaryStructure(s, secStruct)\n }\n buildUnitcellAssembly(s)\n\n s.extraData.cif = cif\n }\n\n if (Debug) Log.timeEnd('CifParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('cif', CifParser)\nParserRegistry.add('mcif', CifParser)\nParserRegistry.add('mmcif', CifParser)\n\nexport default CifParser\n","/**\n * @file Gro Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport {\n calculateBonds, calculateChainnames, calculateSecondaryStructure\n} from '../structure/structure-utils'\n\nclass GroParser extends StructureParser {\n get type () { return 'gro' }\n\n _parse () {\n // http://manual.gromacs.org/current/online/gro.html\n\n if (Debug) Log.time('GroParser._parse ' + this.name)\n\n var s = this.structure\n var sb = this.structureBuilder\n\n var firstModelOnly = this.firstModelOnly\n var asTrajectory = this.asTrajectory\n var cAlphaOnly = this.cAlphaOnly\n\n var frames = s.frames\n var boxes = s.boxes\n var currentFrame: Float32Array, currentCoord: number\n\n var firstLines = this.streamer.peekLines(3)\n\n s.title = firstLines[ 0 ].trim()\n\n // determine number of decimal places\n var ndec = firstLines[ 2 ].length - firstLines[ 2 ].lastIndexOf('.') - 1\n var lpos = 5 + ndec\n var xpos = 20\n var ypos = 20 + lpos\n var zpos = 20 + 2 * lpos\n\n //\n\n var atomname, resname, resno, serial\n\n var atomCount = parseInt(firstLines[ 1 ])\n var modelLineCount = atomCount + 3\n\n var atomMap = s.atomMap\n var atomStore = s.atomStore\n atomStore.resize(atomCount)\n\n var idx = 0\n var modelIdx = 0\n var lineNo = 0\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (var i = _i; i < _n; ++i) {\n ++lineNo\n var l = lineNo - 1\n\n var line = lines[ i ]\n\n if (!line) continue\n\n if (l % modelLineCount === 0) {\n // Log.log( \"title\", line )\n\n if (asTrajectory) {\n currentFrame = new Float32Array(atomCount * 3)\n frames.push(currentFrame)\n currentCoord = 0\n }\n } else if (l % modelLineCount === 1) {\n\n // Log.log( \"atomCount\", line )\n\n } else if (l % modelLineCount === modelLineCount - 1) {\n var str = line.trim().split(/\\s+/)\n var box = new Float32Array(9)\n box[ 0 ] = parseFloat(str[ 0 ]) * 10\n box[ 4 ] = parseFloat(str[ 1 ]) * 10\n box[ 8 ] = parseFloat(str[ 2 ]) * 10\n boxes.push(box)\n\n if (firstModelOnly) {\n return true\n }\n\n modelIdx += 1\n } else {\n atomname = line.substr(10, 5).trim()\n if (cAlphaOnly && atomname !== 'CA') continue\n\n var x = parseFloat(line.substr(xpos, lpos)) * 10\n var y = parseFloat(line.substr(ypos, lpos)) * 10\n var z = parseFloat(line.substr(zpos, lpos)) * 10\n\n if (asTrajectory) {\n var j = currentCoord * 3\n\n currentFrame[ j + 0 ] = x\n currentFrame[ j + 1 ] = y\n currentFrame[ j + 2 ] = z\n\n currentCoord += 1\n\n if (l > modelLineCount) continue\n }\n\n resname = line.substr(5, 5).trim()\n resno = parseInt(line.substr(0, 5))\n serial = parseInt(line.substr(15, 5))\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = serial\n\n sb.addAtom(modelIdx, '', '', resname, resno, false, 'l')\n\n idx += 1\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n sb.finalize()\n s.finalizeAtoms()\n calculateChainnames(s)\n calculateBonds(s)\n s.finalizeBonds()\n\n calculateSecondaryStructure(s)\n\n if (Debug) Log.timeEnd('GroParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('gro', GroParser)\n\nexport default GroParser\n","/**\n * @file utf8-utils\n * @private\n * @author Alexander Rose \n * mostly copied from https://github.com/creationix/msgpack-js-browser\n * by Tim Caswell , MIT License, Copyright (c) 2013\n */\n\n\n// Encode string as utf8 into dataview at offset\nfunction utf8Write(view, offset, string) {\n var byteLength = view.byteLength;\n for(var i = 0, l = string.length; i < l; i++) {\n var codePoint = string.charCodeAt(i);\n\n // One byte of UTF-8\n if (codePoint < 0x80) {\n view.setUint8(offset++, codePoint >>> 0 & 0x7f | 0x00);\n continue;\n }\n\n // Two bytes of UTF-8\n if (codePoint < 0x800) {\n view.setUint8(offset++, codePoint >>> 6 & 0x1f | 0xc0);\n view.setUint8(offset++, codePoint >>> 0 & 0x3f | 0x80);\n continue;\n }\n\n // Three bytes of UTF-8.\n if (codePoint < 0x10000) {\n view.setUint8(offset++, codePoint >>> 12 & 0x0f | 0xe0);\n view.setUint8(offset++, codePoint >>> 6 & 0x3f | 0x80);\n view.setUint8(offset++, codePoint >>> 0 & 0x3f | 0x80);\n continue;\n }\n\n // Four bytes of UTF-8\n if (codePoint < 0x110000) {\n view.setUint8(offset++, codePoint >>> 18 & 0x07 | 0xf0);\n view.setUint8(offset++, codePoint >>> 12 & 0x3f | 0x80);\n view.setUint8(offset++, codePoint >>> 6 & 0x3f | 0x80);\n view.setUint8(offset++, codePoint >>> 0 & 0x3f | 0x80);\n continue;\n }\n throw new Error(\"bad codepoint \" + codePoint);\n }\n}\n\nfunction utf8ByteCount(string) {\n var count = 0;\n for(var i = 0, l = string.length; i < l; i++) {\n var codePoint = string.charCodeAt(i);\n if (codePoint < 0x80) {\n count += 1;\n continue;\n }\n if (codePoint < 0x800) {\n count += 2;\n continue;\n }\n if (codePoint < 0x10000) {\n count += 3;\n continue;\n }\n if (codePoint < 0x110000) {\n count += 4;\n continue;\n }\n throw new Error(\"bad codepoint \" + codePoint);\n }\n return count;\n}\n\n/**\n * encode data value (recursively) into binary encoded MessagePack v5 (http://msgpack.org/)\n * @param {Object|Array|String|Number|Boolean|null} value [description]\n * @param {DataView} view [description]\n * @param {Integer} offset [description]\n * @return {Integer} number of bytes written into view\n */\nfunction encode$1(value, view, offset) {\n var type = typeof value;\n\n // Strings Bytes\n if (type === \"string\") {\n var length = utf8ByteCount(value);\n // fix str\n if (length < 0x20) {\n view.setUint8(offset, length | 0xa0);\n utf8Write(view, offset + 1, value);\n return 1 + length;\n }\n // str 8\n if (length < 0x100) {\n view.setUint8(offset, 0xd9);\n view.setUint8(offset + 1, length);\n utf8Write(view, offset + 2, value);\n return 2 + length;\n }\n // str 16\n if (length < 0x10000) {\n view.setUint8(offset, 0xda);\n view.setUint16(offset + 1, length);\n utf8Write(view, offset + 3, value);\n return 3 + length;\n }\n // str 32\n if (length < 0x100000000) {\n view.setUint8(offset, 0xdb);\n view.setUint32(offset + 1, length);\n utf8Write(view, offset + 5, value);\n return 5 + length;\n }\n }\n\n if (value instanceof Uint8Array) {\n var length = value.byteLength;\n var bytes = new Uint8Array(view.buffer);\n // bin 8\n if (length < 0x100) {\n view.setUint8(offset, 0xc4);\n view.setUint8(offset + 1, length);\n bytes.set(value, offset + 2);\n return 2 + length;\n }\n // bin 16\n if (length < 0x10000) {\n view.setUint8(offset, 0xc5);\n view.setUint16(offset + 1, length);\n bytes.set(value, offset + 3);\n return 3 + length;\n }\n // bin 32\n if (length < 0x100000000) {\n view.setUint8(offset, 0xc6);\n view.setUint32(offset + 1, length);\n bytes.set(value, offset + 5);\n return 5 + length;\n }\n }\n\n if (type === \"number\") {\n if (!isFinite(value)) {\n throw new Error(\"Number not finite: \" + value);\n }\n\n // Floating point\n if (Math.floor(value) !== value) {\n view.setUint8(offset, 0xcb);\n view.setFloat64(offset + 1, value);\n return 9;\n }\n\n // Integers\n if (value >=0) {\n // positive fixnum\n if (value < 0x80) {\n view.setUint8(offset, value);\n return 1;\n }\n // uint 8\n if (value < 0x100) {\n view.setUint8(offset, 0xcc);\n view.setUint8(offset + 1, value);\n return 2;\n }\n // uint 16\n if (value < 0x10000) {\n view.setUint8(offset, 0xcd);\n view.setUint16(offset + 1, value);\n return 3;\n }\n // uint 32\n if (value < 0x100000000) {\n view.setUint8(offset, 0xce);\n view.setUint32(offset + 1, value);\n return 5;\n }\n throw new Error(\"Number too big 0x\" + value.toString(16));\n }\n // negative fixnum\n if (value >= -0x20) {\n view.setInt8(offset, value);\n return 1;\n }\n // int 8\n if (value >= -0x80) {\n view.setUint8(offset, 0xd0);\n view.setInt8(offset + 1, value);\n return 2;\n }\n // int 16\n if (value >= -0x8000) {\n view.setUint8(offset, 0xd1);\n view.setInt16(offset + 1, value);\n return 3;\n }\n // int 32\n if (value >= -0x80000000) {\n view.setUint8(offset, 0xd2);\n view.setInt32(offset + 1, value);\n return 5;\n }\n throw new Error(\"Number too small -0x\" + (-value).toString(16).substr(1));\n }\n\n // null\n if (value === null) {\n view.setUint8(offset, 0xc0);\n return 1;\n }\n\n // Boolean\n if (type === \"boolean\") {\n view.setUint8(offset, value ? 0xc3 : 0xc2);\n return 1;\n }\n\n // Container Types\n if (type === \"object\") {\n var length, size = 0;\n var isArray = Array.isArray(value);\n\n if (isArray) {\n length = value.length;\n }\n else {\n var keys = Object.keys(value);\n length = keys.length;\n }\n\n var size;\n if (length < 0x10) {\n view.setUint8(offset, length | (isArray ? 0x90 : 0x80));\n size = 1;\n }\n else if (length < 0x10000) {\n view.setUint8(offset, isArray ? 0xdc : 0xde);\n view.setUint16(offset + 1, length);\n size = 3;\n }\n else if (length < 0x100000000) {\n view.setUint8(offset, isArray ? 0xdd : 0xdf);\n view.setUint32(offset + 1, length);\n size = 5;\n }\n\n if (isArray) {\n for (var i = 0; i < length; i++) {\n size += encode$1(value[i], view, offset + size);\n }\n }\n else {\n for (var i = 0; i < length; i++) {\n var key = keys[i];\n size += encode$1(key, view, offset + size);\n size += encode$1(value[key], view, offset + size);\n }\n }\n\n return size;\n }\n throw new Error(\"Unknown type \" + type);\n}\n\nfunction encodedSize(value) {\n var type = typeof value;\n\n // Raw Bytes\n if (type === \"string\") {\n var length = utf8ByteCount(value);\n if (length < 0x20) {\n return 1 + length;\n }\n if (length < 0x100) {\n return 2 + length;\n }\n if (length < 0x10000) {\n return 3 + length;\n }\n if (length < 0x100000000) {\n return 5 + length;\n }\n }\n\n if (value instanceof Uint8Array) {\n var length = value.byteLength;\n if (length < 0x100) {\n return 2 + length;\n }\n if (length < 0x10000) {\n return 3 + length;\n }\n if (length < 0x100000000) {\n return 5 + length;\n }\n }\n\n if (type === \"number\") {\n // Floating Point\n // double\n if (Math.floor(value) !== value) return 9;\n\n // Integers\n if (value >=0) {\n // positive fixnum\n if (value < 0x80) return 1;\n // uint 8\n if (value < 0x100) return 2;\n // uint 16\n if (value < 0x10000) return 3;\n // uint 32\n if (value < 0x100000000) return 5;\n throw new Error(\"Number too big 0x\" + value.toString(16));\n }\n // negative fixnum\n if (value >= -0x20) return 1;\n // int 8\n if (value >= -0x80) return 2;\n // int 16\n if (value >= -0x8000) return 3;\n // int 32\n if (value >= -0x80000000) return 5;\n throw new Error(\"Number too small -0x\" + value.toString(16).substr(1));\n }\n\n // Boolean, null\n if (type === \"boolean\" || value === null) return 1;\n\n // Container Types\n if (type === \"object\") {\n var length, size = 0;\n if (Array.isArray(value)) {\n length = value.length;\n for (var i = 0; i < length; i++) {\n size += encodedSize(value[i]);\n }\n }\n else {\n var keys = Object.keys(value);\n length = keys.length;\n for (var i = 0; i < length; i++) {\n var key = keys[i];\n size += encodedSize(key) + encodedSize(value[key]);\n }\n }\n if (length < 0x10) {\n return 1 + size;\n }\n if (length < 0x10000) {\n return 3 + size;\n }\n if (length < 0x100000000) {\n return 5 + size;\n }\n throw new Error(\"Array or object too long 0x\" + length.toString(16));\n }\n throw new Error(\"Unknown type \" + type);\n}\n\nfunction encodeMsgpack(value) {\n var buffer = new ArrayBuffer(encodedSize(value));\n var view = new DataView(buffer);\n encode$1(value, view, 0);\n return new Uint8Array(buffer);\n}\n\n/**\n * @file mmtf-constants\n * @private\n * @author Alexander Rose \n */\n\n\nvar PassThroughFields = [\n \"mmtfVersion\", \"mmtfProducer\",\n \"unitCell\", \"spaceGroup\", \"structureId\", \"title\",\n \"depositionDate\", \"releaseDate\",\n \"experimentalMethods\", \"resolution\", \"rFree\", \"rWork\",\n \"bioAssemblyList\", \"ncsOperatorList\", \"entityList\", \"groupList\",\n \"numBonds\", \"numAtoms\", \"numGroups\", \"numChains\", \"numModels\",\n \"groupsPerChain\", \"chainsPerModel\",\n];\n\nvar EncodedFields = [\n\t// required\n \"xCoordList\", \"yCoordList\", \"zCoordList\",\n \"groupIdList\", \"groupTypeList\",\n \"chainIdList\",\n // optional\n \"bFactorList\", \"atomIdList\", \"altLocList\", \"occupancyList\",\n \"secStructList\", \"insCodeList\", \"sequenceIndexList\",\n \"chainNameList\",\n \"bondAtomList\", \"bondOrderList\"\n];\n\nvar AllFields = PassThroughFields.concat( EncodedFields );\n\n/**\n * @file mmtf-utils\n * @private\n * @author Alexander Rose \n */\n\n/**\n * mmtf utils module.\n * @module MmtfUtils\n */\n\n\nfunction getView( ctor, typedArray, elemSize ){\n return typedArray ? new ctor(\n typedArray.buffer,\n typedArray.byteOffset,\n typedArray.byteLength / ( elemSize || 1 )\n ) : undefined;\n}\n\nfunction getDataView( typedArray ){\n return getView( DataView, typedArray );\n}\n\n/**\n * get an Uint8Array view on the input array memory\n * @static\n * @param {TypedArray} dataArray - input array\n * @return {Uint8Array} new view on the input array memory\n */\nfunction getUint8View( typedArray ){\n return getView( Uint8Array, typedArray );\n}\n\n/**\n * get an Int8Array view on the input array memory\n * @static\n * @param {TypedArray} dataArray - input array\n * @return {Int8Array} new view on the input array memory\n */\nfunction getInt8View( typedArray ){\n return getView( Int8Array, typedArray );\n}\n\n/**\n * get an Int32Array view on the input array memory\n * @static\n * @param {TypedArray} dataArray - input array\n * @return {Int32Array} new view on the input array memory\n */\nfunction getInt32View( typedArray ){\n return getView( Int32Array, typedArray, 4 );\n}\n\nfunction getFloat32View( typedArray ){\n return getView( Float32Array, typedArray, 4 );\n}\n\n\n/**\n * get an Int16Array copy of the the input array data\n * @static\n * @param {TypedArray} view - input data in big endian format\n * @param {Int16Array} [dataArray] - pre-allocated output array\n * @return {Int16Array} copy of the input array data\n */\nfunction decodeInt16( bytes, output ){\n var n = bytes.length / 2;\n if( !output ) output = new Int16Array( n );\n for( var i = 0, i2 = 0; i < n; ++i, i2 += 2 ){\n output[ i ] = bytes[ i2 ] << 8 ^ bytes[ i2 + 1 ] << 0;\n }\n return output;\n}\n\n/**\n * make big endian buffer of an int16 array\n * @static\n * @param {Array|TypedArray} array - array of int16 values\n * @return {ArrayBuffer} big endian buffer\n */\nfunction encodeInt16( array, output ){\n var n = array.length;\n if( !output ) output = new Uint8Array( 2 * n );\n var dv = getDataView( output );\n for( var i = 0; i < n; ++i ){\n dv.setInt16( 2 * i, array[ i ] );\n }\n return getUint8View( output );\n}\n\n/**\n * get an Int32Array copy of the the input array data\n * @static\n * @param {TypedArray} view - input data in big endian format\n * @param {Int32Array} [dataArray] - pre-allocated output array\n * @return {Int32Array} copy of the input array data\n */\nfunction decodeInt32( bytes, output ){\n var n = bytes.length / 4;\n if( !output ) output = new Int32Array( n );\n for( var i = 0, i4 = 0; i < n; ++i, i4 += 4 ){\n output[ i ] = (\n bytes[ i4 ] << 24 ^ bytes[ i4 + 1 ] << 16 ^\n bytes[ i4 + 2 ] << 8 ^ bytes[ i4 + 3 ] << 0\n );\n }\n return output;\n}\n\n/**\n * make big endian buffer of an int32 array\n * @static\n * @param {Array|TypedArray} array - array of int32 values\n * @return {ArrayBuffer} big endian buffer\n */\nfunction encodeInt32( array, output ){\n var n = array.length;\n if( !output ) output = new Uint8Array( 4 * n );\n var dv = getDataView( output );\n for( var i = 0; i < n; ++i ){\n dv.setInt32( 4 * i, array[ i ] );\n }\n return getUint8View( output );\n}\n\nfunction decodeFloat32( bytes, output ){\n var n = bytes.length;\n if( !output ) output = new Float32Array( n / 4 );\n var dvOut = getDataView( output );\n var dvIn = getDataView( bytes );\n for( var i = 0, i4 = 0, il = n / 4; i < il; ++i, i4 += 4 ){\n dvOut.setFloat32( i4, dvIn.getFloat32( i4 ), true );\n }\n return output;\n}\n\n/**\n * decode integers into floats using given divisor\n * example:\n * intArray: [ 12, 34, 543, 687, 2, 0, 4689 ]\n * divisor: 100\n * return: [ 0.12, 0.34, 5.43, 6.87, 0.02, 0.00, 46.89 ]\n * @static\n * @param {TypedArray|Array} intArray - input array containing integers\n * @param {Number} divisor - number to devide the integers to obtain floats\n * @param {Float32Array} [dataArray] - pre-allocated output array\n * @return {Float32Array} decoded array\n */\nfunction decodeInteger( intArray, divisor, output ){\n var n = intArray.length;\n var invDiv = 1/divisor;\n if( !output ) output = new Float32Array( n );\n for( var i = 0; i < n; ++i ){\n // multiply by inverse of the divisor which is faster then division\n output[ i ] = intArray[ i ] * invDiv;\n }\n return output;\n}\n\nfunction encodeInteger( floatArray, factor, output ){\n var n = floatArray.length;\n if( !output ) output = new Int32Array( n );\n for( var i = 0; i < n; ++i ){\n output[ i ] = Math.round( floatArray[ i ] * factor );\n }\n return output;\n}\n\n\n\n/**\n * perform run-length decoding of input array\n * example:\n * array: [ 0, 2, 3, 5 ] // pairs of values and length of a run\n * return: [ 0, 0, 3, 3, 3, 3, 3 ]\n * @static\n * @param {TypedArray|Array} array - run-length encoded input array\n * @param {TypedArray|Array} [dataArray] - pre-allocated output array\n * @return {TypedArray|Array} decoded array\n */\nfunction decodeRun( array, output ){\n var i, il;\n if( !output ){\n // calculate the length the decoded array will have\n var fullLength = 0;\n for( i = 0, il = array.length; i < il; i+=2 ){\n fullLength += array[ i + 1 ];\n }\n // create a new array of the same type of the input array\n output = new array.constructor( fullLength );\n }\n var dataOffset = 0;\n for( i = 0, il = array.length; i < il; i+=2 ){\n var value = array[ i ]; // value to be repeated\n var length = array[ i + 1 ]; // number of repeats\n for( var j = 0; j < length; ++j ){\n output[ dataOffset ] = value;\n ++dataOffset;\n }\n }\n return output;\n}\n\nfunction encodeRun( array ){\n if( array.length === 0 ) return new Int32Array();\n var i, il;\n // calculate output size\n var fullLength = 2;\n for( i = 1, il = array.length; i < il; ++i ){\n if( array[ i - 1 ] !== array[ i ] ){\n fullLength += 2;\n }\n }\n var output = new Int32Array( fullLength );\n var offset = 0;\n var runLength = 1;\n for( i = 1, il = array.length; i < il; ++i ){\n if( array[ i - 1 ] !== array[ i ] ){\n output[ offset ] = array[ i - 1 ];\n output[ offset + 1 ] = runLength;\n runLength = 1;\n offset += 2;\n }else{\n ++runLength;\n }\n }\n output[ offset ] = array[ array.length - 1 ];\n output[ offset + 1 ] = runLength;\n return output;\n}\n\n\n\n/**\n * perform delta decoding of the input array\n * by iterativly adding the ith element's value to the i+1th\n * example:\n * dataArray: [ 0, 2, 1, 2, 1, 1, -4, -2, 9 ]\n * return: [ 0, 2, 3, 5, 6, 7, 3, 1, 10 ]\n * @static\n * @param {TypedArray|Array} dataArray - delta encoded input array\n * @return {TypedArray|Array} decoded array\n */\nfunction decodeDelta( array, output ){\n var n = array.length;\n if( !output ) output = new array.constructor( n );\n if( n ) output[ 0 ] = array[ 0 ];\n for( var i = 1; i < n; ++i ){\n output[ i ] = array[ i ] + output[ i - 1 ];\n }\n return output;\n}\n\nfunction encodeDelta( array, output ){\n var n = array.length;\n if( !output ) output = new array.constructor( n );\n output[ 0 ] = array[ 0 ];\n for( var i = 1; i < n; ++i ){\n output[ i ] = array[ i ] - array[ i - 1 ];\n }\n return output;\n}\n\n\n\n/**\n * [decodePacking description]\n * @param {Int16Array|Int8Array} int16or8 [description]\n * @param {Int32Array} output [description]\n * @return {Int32Array} [description]\n */\nfunction decodePacking( int16or8, output ){\n var upperLimit = int16or8 instanceof Int8Array ? 0x7F : 0x7FFF;\n var lowerLimit = -upperLimit - 1;\n var n = int16or8.length;\n var i, j;\n if( !output ){\n var fullLength = 0;\n for( i = 0; i < n; ++i ){\n if( int16or8[ i ] < upperLimit && int16or8[ i ] > lowerLimit ){\n ++fullLength;\n }\n }\n output = new Int32Array( fullLength );\n }\n i = 0;\n j = 0;\n while( i < n ){\n var value = 0;\n while( int16or8[ i ] === upperLimit || int16or8[ i ] === lowerLimit ){\n value += int16or8[ i ];\n ++i;\n }\n value += int16or8[ i ];\n ++i;\n output[ j ] = value;\n ++j;\n }\n return output;\n}\n\n/**\n * integer packing using recursive indexing\n * @param {Array|TyepedArray} intArray [description]\n * @param {Boolean} useInt8 [description]\n * @return {Int16Array|Int8Array} [description]\n */\nfunction encodePacking( intArray, useInt8 ){\n var upperLimit = useInt8 ? 0x7F : 0x7FFF;\n var lowerLimit = -upperLimit - 1;\n var i;\n var n = intArray.length;\n var size = 0;\n for( i = 0; i < n; ++i ){\n var value = intArray[ i ];\n if( value === 0 ){\n ++size;\n }else if( value === upperLimit || value === lowerLimit ){\n size += 2;\n }else if( value > 0) {\n size += Math.ceil( value / upperLimit );\n }else {\n size += Math.ceil( value / lowerLimit );\n }\n }\n var output = useInt8 ? new Int8Array( size ) : new Int16Array( size );\n var j = 0;\n for( i = 0; i < n; ++i ){\n var value = intArray[ i ];\n if( value >= 0) {\n while( value >= upperLimit ){\n output[ j ] = upperLimit;\n ++j;\n value -= upperLimit;\n }\n }else{\n while( value <= lowerLimit ){\n output[ j ] = lowerLimit;\n ++j;\n value -= lowerLimit;\n }\n }\n output[ j ] = value;\n ++j;\n }\n return output;\n}\n\n\n\nfunction decodeDeltaRun( array, output ){\n return decodeDelta( decodeRun( array ), output );\n}\n\nfunction encodeDeltaRun( array ){\n return encodeRun( encodeDelta( array ) );\n}\n\n\n\n/**\n * perform run-length decoding followed (@see decodeRunLength)\n * by decoding integers into floats using given divisor (@see decodeIntegerToFloat)\n * example:\n * array: [ 320, 3, 100, 2 ]\n * divisor: 100\n * return: [ 3.20, 3.20, 3.20, 1.00, 1.00 ]\n * @static\n * @param {Uint8Array} array - run-length encoded int32 array as bytes in big endian format\n * @param {Integer} divisor - number to devide the integers to obtain floats\n * @param {Float32Array} dataArray - pre-allocated output array\n * @return {Float32Array} decoded array\n */\nfunction decodeIntegerRun( intArray, divisor, output ){\n return decodeInteger(\n decodeRun( intArray, getInt32View( output ) ), divisor, output\n );\n}\n\nfunction encodeIntegerRun( floatArray, factor ){\n return encodeRun( encodeInteger( floatArray, factor ) );\n}\n\n\n\nfunction decodeIntegerDelta( intArray, divisor, output ){\n return decodeInteger(\n decodeDelta( intArray, getInt32View( output ) ), divisor, output\n );\n}\n\nfunction encodeIntegerDelta( floatArray, factor, output ){\n return encodeDelta( encodeInteger( floatArray, factor ), output );\n}\n\n\n\nfunction decodeIntegerPacking( int16or8, divisor, output ){\n return decodeInteger(\n decodePacking( int16or8, getInt32View( output ) ), divisor, output\n );\n}\n\nfunction decodeIntegerDeltaPacking( int16or8, divisor, output ){\n var unpacked = decodePacking( int16or8, getInt32View( output ) );\n return decodeIntegerDelta( unpacked, divisor, getFloat32View( unpacked ) );\n}\n\nfunction encodeIntegerDeltaPacking( floatArray, factor, useInt8 ){\n return encodePacking( encodeIntegerDelta( floatArray, factor ), useInt8 );\n}\n\n\n\nfunction decodeBytes( bytes ){\n var dv = getDataView( bytes );\n var type = dv.getInt32( 0 );\n var size = dv.getInt32( 4 );\n var param = bytes.subarray( 8, 12 );\n var bytes = bytes.subarray( 12 );\n return [ type, bytes, size, param ];\n}\n\nfunction encodeBytes( type, size, param, bytes ){\n var buffer = new ArrayBuffer( 12 + bytes.byteLength );\n var out = new Uint8Array( buffer );\n var dv = new DataView( buffer );\n dv.setInt32( 0, type );\n dv.setInt32( 4, size );\n if( param ) out.set( param, 8 );\n out.set( bytes, 12 );\n return out;\n}\n\nfunction passInt8( int8 ){\n var size = int8.length;\n var bytes = getUint8View( int8 );\n return encodeBytes( 2, size, undefined, bytes );\n}\n\nfunction passInt32( int32 ){\n var size = int32.length;\n var bytes = encodeInt32( int32 );\n return encodeBytes( 4, size, undefined, bytes );\n}\n\nfunction passString( stringBytes, length ){\n var size = stringBytes.length / length;\n var param = encodeInt32([ length ]);\n var bytes = getUint8View( stringBytes );\n return encodeBytes( 5, size, param, bytes );\n}\n\nfunction runChar( charBytes ){\n var size = charBytes.length;\n var bytes = encodeInt32( encodeRun( charBytes ) );\n return encodeBytes( 6, size, undefined, bytes );\n}\n\nfunction deltaRun( int32 ){\n var size = int32.length;\n var bytes = encodeInt32( encodeDeltaRun( int32 ) );\n return encodeBytes( 8, size, undefined, bytes );\n}\n\nfunction integerRun( float32, factor ){\n var size = float32.length;\n var param = encodeInt32([ factor ]);\n var bytes = encodeInt32( encodeIntegerRun( float32, factor ) );\n return encodeBytes( 9, size, param, bytes );\n}\n\nfunction integerDeltaPacking16( float32, factor ){\n var size = float32.length;\n var param = encodeInt32([ factor ]);\n var bytes = encodeInt16( encodeIntegerDeltaPacking( float32, factor ) );\n return encodeBytes( 10, size, param, bytes );\n}\n\nfunction encodeMmtf( inputDict ){\n\n var outputDict = {};\n\n // copy some fields over from the input dict\n PassThroughFields.forEach( function( name ){\n if( inputDict[ name ] !== undefined ){\n outputDict[ name ] = inputDict[ name ];\n }\n } );\n\n //////////////\n // bond data\n\n // encode inter group bond atom indices, i.e. get bytes in big endian order\n if( inputDict.bondAtomList ){\n outputDict.bondAtomList = passInt32( inputDict.bondAtomList );\n }\n\n // encode inter group bond orders, i.e. get bytes\n if( inputDict.bondOrderList ){\n outputDict.bondOrderList = passInt8( inputDict.bondOrderList );\n }\n\n //////////////\n // atom data\n\n // split-list delta & integer encode x, y, z atom coords\n outputDict.xCoordList = integerDeltaPacking16( inputDict.xCoordList, 1000 );\n outputDict.yCoordList = integerDeltaPacking16( inputDict.yCoordList, 1000 );\n outputDict.zCoordList = integerDeltaPacking16( inputDict.zCoordList, 1000 );\n\n // split-list delta & integer encode b-factors\n if( inputDict.bFactorList ){\n outputDict.bFactorList = integerDeltaPacking16( inputDict.bFactorList, 100 );\n }\n\n // delta & run-length encode atom ids\n if( inputDict.atomIdList ){\n outputDict.atomIdList = deltaRun( inputDict.atomIdList );\n }\n\n // run-length encode alternate labels\n if( inputDict.altLocList ){\n outputDict.altLocList = runChar( inputDict.altLocList );\n }\n\n // run-length & integer encode occupancies\n if( inputDict.occupancyList ){\n outputDict.occupancyList = integerRun( inputDict.occupancyList, 100 );\n }\n\n ///////////////\n // group data\n\n // run-length & delta encode group numbers\n outputDict.groupIdList = deltaRun( inputDict.groupIdList );\n\n // encode group types, i.e. get int32 array\n outputDict.groupTypeList = passInt32( inputDict.groupTypeList );\n\n // encode secondary structure, i.e. get bytes\n if( inputDict.secStructList ){\n outputDict.secStructList = passInt8( inputDict.secStructList, 1 );\n }\n\n // run-length encode insertion codes\n if( inputDict.insCodeList ){\n outputDict.insCodeList = runChar( inputDict.insCodeList );\n }\n\n // run-length & delta encode sequence indices\n if( inputDict.sequenceIndexList ){\n outputDict.sequenceIndexList = deltaRun( inputDict.sequenceIndexList );\n }\n\n ///////////////\n // chain data\n\n // encode chain ids, i.e. get bytes\n outputDict.chainIdList = passString( inputDict.chainIdList, 4 );\n\n // encode chain names, i.e. get bytes\n if( inputDict.chainNameList ){\n outputDict.chainNameList = passString( inputDict.chainNameList, 4 );\n }\n\n return outputDict;\n\n}\n\n/**\n * @file msgpack-decode\n * @private\n * @author Alexander Rose \n */\n\n/**\n * msgpack decode module.\n * @module MsgpackDecode\n */\n\n/**\n * decode binary encoded MessagePack v5 (http://msgpack.org/) data\n * @static\n * @param {Uint8Array} buffer - binary encoded MessagePack data\n * @return {Object|Array|String|Number|Boolean|null} decoded Messagepack data\n */\nfunction decodeMsgpack(buffer) {\n // Loosely based on\n // The MIT License (MIT)\n // Copyright (c) 2013 Tim Caswell \n // https://github.com/creationix/msgpack-js\n var offset = 0;\n var dataView = new DataView(buffer.buffer);\n\n /**\n * decode all key-value pairs of a map into an object\n * @param {Integer} length - number of key-value pairs\n * @return {Object} decoded map\n */\n function map(length) {\n var value = {};\n for (var i = 0; i < length; i++) {\n var key = parse();\n value[key] = parse();\n }\n return value;\n }\n\n /**\n * decode binary array\n * @param {Integer} length - number of elements in the array\n * @return {Uint8Array} decoded array\n */\n function bin(length) {\n var value = buffer.subarray(offset, offset + length);\n offset += length;\n return value;\n }\n\n /**\n * decode string\n * @param {Integer} length - number string characters\n * @return {String} decoded string\n */\n function str(length) {\n var array = buffer.subarray(offset, offset + length);\n offset += length;\n // limit number of arguments to String.fromCharCode to something\n // browsers can handle, see http://stackoverflow.com/a/22747272\n var chunkSize = 0xffff;\n if(length > chunkSize){\n var c = [];\n for(var i = 0; i < array.length; i += chunkSize) {\n c.push(String.fromCharCode.apply(\n null, array.subarray(i, i + chunkSize)\n ));\n }\n return c.join(\"\");\n }else{\n return String.fromCharCode.apply(null, array);\n }\n }\n\n /**\n * decode array\n * @param {Integer} length - number of array elements\n * @return {Array} decoded array\n */\n function array(length) {\n var value = new Array(length);\n for (var i = 0; i < length; i++) {\n value[i] = parse();\n }\n return value;\n }\n\n /**\n * recursively parse the MessagePack data\n * @return {Object|Array|String|Number|Boolean|null} decoded MessagePack data\n */\n function parse() {\n var type = buffer[offset];\n var value, length, extType;\n // Positive FixInt\n if ((type & 0x80) === 0x00) {\n offset++;\n return type;\n }\n // FixMap\n if ((type & 0xf0) === 0x80) {\n length = type & 0x0f;\n offset++;\n return map(length);\n }\n // FixArray\n if ((type & 0xf0) === 0x90) {\n length = type & 0x0f;\n offset++;\n return array(length);\n }\n // FixStr\n if ((type & 0xe0) === 0xa0) {\n length = type & 0x1f;\n offset++;\n return str(length);\n }\n // Negative FixInt\n if ((type & 0xe0) === 0xe0) {\n value = dataView.getInt8(offset);\n offset++;\n return value;\n }\n switch (type) {\n // nil\n case 0xc0:\n offset++;\n return null;\n // 0xc1: (never used, could be employed for padding)\n // false\n case 0xc2:\n offset++;\n return false;\n // true\n case 0xc3:\n offset++;\n return true;\n // bin 8\n case 0xc4:\n length = dataView.getUint8(offset + 1);\n offset += 2;\n return bin(length);\n // bin 16\n case 0xc5:\n length = dataView.getUint16(offset + 1);\n offset += 3;\n return bin(length);\n // bin 32\n case 0xc6:\n length = dataView.getUint32(offset + 1);\n offset += 5;\n return bin(length);\n // // ext 8\n // case 0xc7:\n // length = dataView.getUint8(offset + 1);\n // extType = dataView.getUint8(offset + 2);\n // offset += 3;\n // return [extType, bin(length)];\n // // ext 16\n // case 0xc8:\n // length = dataView.getUint16(offset + 1);\n // extType = dataView.getUint8(offset + 3);\n // offset += 4;\n // return [extType, bin(length)];\n // // ext 32\n // case 0xc9:\n // length = dataView.getUint32(offset + 1);\n // extType = dataView.getUint8(offset + 5);\n // offset += 6;\n // return [extType, bin(length)];\n // float 32\n case 0xca:\n value = dataView.getFloat32(offset + 1);\n offset += 5;\n return value;\n // float 64\n case 0xcb:\n value = dataView.getFloat64(offset + 1);\n offset += 9;\n return value;\n // uint8\n case 0xcc:\n value = buffer[offset + 1];\n offset += 2;\n return value;\n // uint 16\n case 0xcd:\n value = dataView.getUint16(offset + 1);\n offset += 3;\n return value;\n // uint 32\n case 0xce:\n value = dataView.getUint32(offset + 1);\n offset += 5;\n return value;\n // // uint64\n // case 0xcf:\n // // FIXME not available/representable in JS\n // // largest possible int in JS is 2^53\n // // value = dataView.getUint64(offset + 1);\n // offset += 9;\n // return 0;\n // int 8\n case 0xd0:\n value = dataView.getInt8(offset + 1);\n offset += 2;\n return value;\n // int 16\n case 0xd1:\n value = dataView.getInt16(offset + 1);\n offset += 3;\n return value;\n // int 32\n case 0xd2:\n value = dataView.getInt32(offset + 1);\n offset += 5;\n return value;\n // // int 64\n // case 0xd3:\n // // FIXME not available/representable in JS\n // // largest possible int in JS is 2^53\n // // value = dataView.getInt64(offset + 1);\n // offset += 9;\n // return 0;\n\n // // fixext 1\n // case 0xd4:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(1)];\n // // fixext 2\n // case 0xd5:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(2)];\n // // fixext 4\n // case 0xd6:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(4)];\n // // fixext 8\n // case 0xd7:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(8)];\n // // fixext 16\n // case 0xd8:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(16)];\n // str 8\n case 0xd9:\n length = dataView.getUint8(offset + 1);\n offset += 2;\n return str(length);\n // str 16\n case 0xda:\n length = dataView.getUint16(offset + 1);\n offset += 3;\n return str(length);\n // str 32\n case 0xdb:\n length = dataView.getUint32(offset + 1);\n offset += 5;\n return str(length);\n // array 16\n case 0xdc:\n length = dataView.getUint16(offset + 1);\n offset += 3;\n return array(length);\n // array 32\n case 0xdd:\n length = dataView.getUint32(offset + 1);\n offset += 5;\n return array(length);\n // map 16:\n case 0xde:\n length = dataView.getUint16(offset + 1);\n offset += 3;\n return map(length);\n // map 32\n case 0xdf:\n length = dataView.getUint32(offset + 1);\n offset += 5;\n return map(length);\n }\n\n throw new Error(\"Unknown type 0x\" + type.toString(16));\n }\n\n // start the recursive parsing\n return parse();\n}\n\n/**\n * Fields shared in encoded and decoded mmtf data objects.\n * @typedef {Object} module:MmtfDecode.SharedMmtfData\n * @property {String} mmtfVersion - MMTF specification version\n * @property {String} mmtfProducer - Program that created the file\n * @property {Float[]} [unitCell] - Crystallographic unit cell\n * @property {Float} unitCell.0 - x length\n * @property {Float} unitCell.1 - y length\n * @property {Float} unitCell.2 - z length\n * @property {Float} unitCell.3 - alpha angle\n * @property {Float} unitCell.4 - beta angle\n * @property {Float} unitCell.5 - gamma angle\n * @property {String} [spaceGroup] - Hermann-Mauguin symbol\n * @property {String} [structureId] - Some reference, e.g. a PDB ID\n * @property {String} [title] - Short description\n * @property {String} [depositionDate] - Deposition date in YYYY-MM-DD format\n * @property {String} [releaseDate] - Release date in YYYY-MM-DD format\n * @property {String[]} [experimentalMethods] - Structure determination methods\n * @property {Float} [resolution] - Resolution in Å\n * @property {Float} [rFree] - R-free value\n * @property {Float} [rWork] - R-work value\n * @property {Integer} numBonds - Number of bonds\n * @property {Integer} numAtoms - Number of atoms\n * @property {Integer} numGroups - Number of groups (residues)\n * @property {Integer} numChains - Number of chains\n * @property {Integer} numModels - Number of models\n * @property {Integer[]} chainsPerModel - List of number of chains in each model\n * @property {Integer[]} groupsPerChain - List of number of groups in each chain\n * @property {Entity[]} [entityList] - List of entity objects\n * @property {Integer[]} entityList.chainIndexList - Pointers into chain data fields\n * @property {String} entityList.description - Description of the entity\n * @property {String} entityList.type - Name of the entity type\n * @property {String} entityList.sequence - One letter code sequence\n * @property {Assembly[]} [bioAssemblyList] - List of assembly objects\n * @property {Transform[]} bioAssemblyList.transformList - List of transform objects\n * @property {Integer[]} bioAssemblyList.transformList.chainIndexList - Pointers into chain data fields\n * @property {Float[]} bioAssemblyList.transformList.matrix - 4x4 transformation matrix\n * @property {Array[]} [ncsOperatorList] - List of ncs operator matrices\n * @property {Float[]} ncsOperatorList. - 4x4 transformation matrix\n * @property {GroupType[]} groupList - List of groupType objects\n * @property {Integer[]} groupList.formalChargeList - List of atom formal charges\n * @property {String[]} groupList.elementList - List of elements\n * @property {String[]} groupList.atomNameList - List of atom names\n * @property {Integer[]} groupList.bondAtomList - List of bonded atom indices\n * @property {Integer[]} groupList.bondOrderList - List of bond orders\n * @property {String} groupList.groupName - The name of the group\n * @property {String} groupList.singleLetterCode - The single letter code\n * @property {String} groupList.chemCompType - The chemical component type\n */\n\n/**\n * Encoded mmtf data object. Also includes the fields from {@link module:MmtfDecode.SharedMmtfData}. See MMTF specification on how they are encoded.\n * @typedef {Object} module:MmtfDecode.EncodedMmtfData\n * @mixes module:MmtfDecode.SharedMmtfData\n * @property {Uint8Array} [bondAtomList] - Encoded bonded atom indices\n * @property {Uint8Array} [bondOrderList] - Encoded bond orders\n * @property {Uint8Array} xCoordBig - Encoded x coordinates in Å, part 1\n * @property {Uint8Array} xCoordSmall - Encoded x coordinates in Å, part 2\n * @property {Uint8Array} yCoordBig - Encoded y coordinates in Å, part 1\n * @property {Uint8Array} yCoordSmall - Encoded y coordinates in Å, part 2\n * @property {Uint8Array} yCoordBig - Encoded y coordinates in Å, part 1\n * @property {Uint8Array} yCoordSmall - Encoded y coordinates in Å, part 2\n * @property {Uint8Array} [bFactorBig] - Encoded B-factors in Å^2, part 1\n * @property {Uint8Array} [bFactorSmall] - Encoded B-factors in Å^2, part 2\n * @property {Uint8Array} [atomIdList] - Encoded atom ids\n * @property {Uint8Array} [altLocList] - Encoded alternate location labels\n * @property {Uint8Array} [occupancyList] - Encoded occupancies\n * @property {Uint8Array} groupIdList - Encoded group ids\n * @property {Uint8Array} groupTypeList - Encoded group types\n * @property {Uint8Array} [secStructList] - Encoded secondary structure codes\n * @property {Uint8Array} [insCodeList] - Encoded insertion codes\n * @property {Uint8Array} [seuenceIdList] - Encoded sequence ids\n * @property {Uint8Array} chainIdList - Encoded chain ids\n * @property {Uint8Array} [chainNameList] - Encoded chain names\n */\n\n/**\n * Decoded mmtf data object. Also includes fields the from {@link module:MmtfDecode.SharedMmtfData}.\n * @typedef {Object} module:MmtfDecode.MmtfData\n * @mixes module:MmtfDecode.SharedMmtfData\n * @property {Int32Array} [bondAtomList] - List of bonded atom indices\n * @property {Uint8Array} [bondOrderList] - List of bond orders\n * @property {Float32Array} xCoordList - List of x coordinates in Å\n * @property {Float32Array} yCoordList - List of y coordinates in Å\n * @property {Float32Array} zCoordList - List of z coordinates in Å\n * @property {Float32Array} [bFactorList] - List of B-factors in Å^2\n * @property {Int32Array} [atomIdList] - List of atom ids\n * @property {Uint8Array} [altLocList] - List of alternate location labels\n * @property {Float32Array} [occupancyList] - List of occupancies\n * @property {Int32Array} groupIdList - List of group ids\n * @property {Int32Array} groupTypeList - List of group types\n * @property {Int8Array} [secStructList] - List of secondary structure codes, encoding\n * 0: pi helix, 1: bend, 2: alpha helix, 3: extended,\n * 4: 3-10 helix, 5: bridge, 6: turn, 7: coil, -1: undefined\n * @property {Uint8Array} [insCodeList] - List of insertion codes\n * @property {Int32Array} [seuenceIdList] - List of sequence ids\n * @property {Uint8Array} chainIdList - List of chain ids\n * @property {Uint8Array} [chainNameList] - List of chain names\n */\n\n\n/**\n * [performDecoding description]\n * @param {Integer} bytes [description]\n * @param {Integer} size [description]\n * @param {Uint8Array} param [description]\n * @return {TypedArray} [description]\n */\nfunction performDecoding( type, bytes, size, param ){\n\n switch( type ){\n case 1:\n return decodeFloat32( bytes );\n case 2:\n return getInt8View( bytes );\n case 3:\n return decodeInt16( bytes );\n case 4:\n return decodeInt32( bytes );\n case 5:\n // var length = decodeInt32( param )[ 0 ];\n return getUint8View( bytes ); // interpret as string array\n case 6:\n // interpret as char array\n return decodeRun( decodeInt32( bytes ), new Uint8Array( size ) );\n case 7:\n return decodeRun( decodeInt32( bytes ) )\n case 8:\n return decodeDeltaRun( decodeInt32( bytes ) );\n case 9:\n return decodeIntegerRun( decodeInt32( bytes ), decodeInt32( param )[ 0 ] );\n case 10:\n return decodeIntegerDeltaPacking( decodeInt16( bytes ), decodeInt32( param )[ 0 ] );\n case 11:\n return decodeInteger( decodeInt16( bytes ), decodeInt32( param )[ 0 ] );\n case 12:\n return decodeIntegerPacking( decodeInt16( bytes ), decodeInt32( param )[ 0 ] );\n case 13:\n return decodeIntegerPacking( getInt8View( bytes ), decodeInt32( param )[ 0 ] );\n case 14:\n return decodePacking( decodeInt16( bytes ) );\n case 15:\n return decodePacking( getInt8View( bytes ) );\n }\n\n};\n\n\n/**\n * Decode MMTF fields\n * @static\n * @param {Object} inputDict - encoded MMTF data\n * @param {Object} [params] - decoding parameters\n * @param {String[]} params.ignoreFields - names of optional fields not to decode\n * @return {module:MmtfDecode.MmtfData} mmtfData\n */\nfunction decodeMmtf( inputDict, params ){\n\n params = params || {};\n var ignoreFields = params.ignoreFields;\n var outputDict = {};\n\n AllFields.forEach( function( name ){\n var ignore = ignoreFields ? ignoreFields.indexOf( name ) !== -1 : false;\n var data = inputDict[ name ];\n if( !ignore && data !== undefined ){\n if( data instanceof Uint8Array ){\n outputDict[ name ] = performDecoding.apply( null, decodeBytes( data ) );\n }else{\n outputDict[ name ] = data;\n }\n }\n } );\n\n return outputDict;\n\n}\n\n/**\n * @file mmtf-traverse\n * @private\n * @author Alexander Rose \n */\n\n/**\n * mmtf traverse module.\n * @module MmtfTraverse\n */\n\n/**\n * Converts an array of ASCII codes trimming '\\0' bytes\n * @private\n * @param {Array} charCodeArray - array of ASCII char codes\n * @return {String} '\\0' trimmed string\n */\nfunction fromCharCode( charCodeArray ){\n return String.fromCharCode.apply( null, charCodeArray ).replace(/\\0/g, '');\n}\n\n\n/**\n * @callback module:MmtfTraverse.onModel\n * @param {Object} modelData\n * @param {Integer} modelData.chainCount - number of chains in the model\n * @param {Integer} modelData.modelIndex - index of the model\n */\n\n/**\n * @callback module:MmtfTraverse.onChain\n * @param {Object} chainData\n * @param {Integer} chainData.groupCount - number of groups in the chain\n * @param {Integer} chainData.chainIndex - index of the chain\n * @param {Integer} chainData.modelIndex - index of the parent model\n * @param {String} chainData.chainId - chain id\n * @param {?String} chainData.chainName - additional chain name\n */\n\n/**\n * @callback module:MmtfTraverse.onGroup\n * @param {Object} groupData\n * @param {Integer} groupData.atomCount - number of atoms in the group\n * @param {Integer} groupData.groupIndex - index of the group\n * @param {Integer} groupData.chainIndex - index of the parent chain\n * @param {Integer} groupData.modelIndex - index of the parent model\n * @param {Integer} groupData.groupId - group id (residue number)\n * @param {Integer} groupData.groupType - index to an entry in {@link module:MmtfDecode.MmtfData}#groupList\n * @param {String} groupData.groupName - name of the group, 0 to 5 characters\n * @param {Char} groupData.singleLetterCode - IUPAC single letter code, otherwise 'X', 1 character\n * @param {String} groupData.chemCompType - chemical component type from the mmCIF dictionary\n * @param {?Integer} groupData.secStruct - sencoded secondary structure |\n * 0: pi helix, 1: bend, 2: alpha helix, 3: extended,\n * 4: 3-10 helix, 5: bridge, 6: turn, 7: coil, -1: undefined\n * @param {?Char} groupData.insCode - insertion code\n * @param {?Integer} groupData.sequenceIndex - index to the `sequence` property of\n * the corresponding entity, -1 when the entity has no sequence\n */\n\n/**\n * @callback module:MmtfTraverse.onAtom\n * @param {Object} atomData\n * @param {Integer} atomData.atomIndex - index of the atom\n * @param {Integer} atomData.groupIndex - index of the parent group\n * @param {Integer} atomData.chainIndex - index of the parent chain\n * @param {Integer} atomData.modelIndex - index of the parent model\n * @param {?Integer} atomData.atomId - atom id\n * @param {String} atomData.element - IUPAC element name, 0 to 3 characters\n * @param {String} atomData.atomName - name of the atom, 0 to 5 characters\n * @param {Integer} atomData.formalCharge - formal charge of the atom\n * @param {Float} atomData.xCoord - x coordinate in Å\n * @param {Float} atomData.yCoord - y coordinate in Å\n * @param {Float} atomData.zCoord - z coordinate in Å\n * @param {?Float} atomData.bFactor - B-factor in in Å^2\n * @param {?Char} atomData.altLoc - alternate location identifier\n * @param {?Float} atomData.occupancy - occupancy of the atom\n */\n\n/**\n * @callback module:MmtfTraverse.onBond\n * @param {Object} bondData\n * @param {Integer} bondData.atomIndex1 - index of the first atom\n * @param {Integer} bondData.atomIndex2 - index of the secound atom\n * @param {Integer} bondData.bondOrder - bond order, allowed values are 1 to 3\n */\n\n\n/**\n * Traverse the MMTF structure data.\n * @static\n * @param {module:MmtfDecode.MmtfData} mmtfData - decoded mmtf data\n * @param {Object} eventCallbacks\n * @param {module:MmtfTraverse.onModel} [eventCallbacks.onModel] - called for each model\n * @param {module:MmtfTraverse.onChain} [eventCallbacks.onChain] - called for each chain\n * @param {module:MmtfTraverse.onGroup} [eventCallbacks.onGroup] - called for each group\n * @param {module:MmtfTraverse.onAtom} [eventCallbacks.onAtom] - called for each atom\n * @param {module:MmtfTraverse.onBond} [eventCallbacks.onBond] - called for each bond\n * @param {Object} [params] - traversal parameters\n * @param {Boolean} [params.firstModelOnly] - traverse only the first model\n */\nfunction traverseMmtf( mmtfData, eventCallbacks, params ){\n\n params = params || {};\n\n var firstModelOnly = params.firstModelOnly;\n\n // setup callbacks\n var onModel = eventCallbacks.onModel;\n var onChain = eventCallbacks.onChain;\n var onGroup = eventCallbacks.onGroup;\n var onAtom = eventCallbacks.onAtom;\n var onBond = eventCallbacks.onBond;\n\n // setup index counters\n var modelIndex = 0;\n var chainIndex = 0;\n var groupIndex = 0;\n var atomIndex = 0;\n\n var modelFirstAtomIndex = 0;\n var modelLastAtomIndex = -1;\n\n // setup optional fields\n var chainNameList = mmtfData.chainNameList;\n var secStructList = mmtfData.secStructList;\n var insCodeList = mmtfData.insCodeList;\n var sequenceIndexList = mmtfData.sequenceIndexList;\n var atomIdList = mmtfData.atomIdList;\n var bFactorList = mmtfData.bFactorList;\n var altLocList = mmtfData.altLocList;\n var occupancyList = mmtfData.occupancyList;\n var bondAtomList = mmtfData.bondAtomList;\n var bondOrderList = mmtfData.bondOrderList;\n\n // hoisted loop variables\n var o, ol, i, j, k, kl;\n\n // loop over all models\n for( o = 0, ol = mmtfData.chainsPerModel.length; o < ol; ++o ){\n\n if( firstModelOnly && modelIndex > 0 ) break;\n\n var modelChainCount = mmtfData.chainsPerModel[ modelIndex ];\n\n if( onModel ){\n onModel({\n chainCount: modelChainCount,\n modelIndex: modelIndex\n });\n }\n\n for( i = 0; i < modelChainCount; ++i ){\n\n var chainGroupCount = mmtfData.groupsPerChain[ chainIndex ];\n if( onChain ){\n var chainId = fromCharCode(\n mmtfData.chainIdList.subarray( chainIndex * 4, chainIndex * 4 + 4 )\n );\n var chainName = null;\n if( chainNameList ){\n chainName = fromCharCode(\n chainNameList.subarray( chainIndex * 4, chainIndex * 4 + 4 )\n );\n }\n onChain({\n groupCount: chainGroupCount,\n chainIndex: chainIndex,\n modelIndex: modelIndex,\n chainId: chainId,\n chainName: chainName\n });\n }\n\n for( j = 0; j < chainGroupCount; ++j ){\n\n var groupData = mmtfData.groupList[ mmtfData.groupTypeList[ groupIndex ] ];\n var groupAtomCount = groupData.atomNameList.length;\n if( onGroup ){\n var secStruct = null;\n if( secStructList ){\n secStruct = secStructList[ groupIndex ];\n }\n var insCode = null;\n if( mmtfData.insCodeList ){\n insCode = String.fromCharCode( insCodeList[ groupIndex ] );\n }\n var sequenceIndex = null;\n if( sequenceIndexList ){\n sequenceIndex = sequenceIndexList[ groupIndex ];\n }\n onGroup({\n atomCount: groupAtomCount,\n groupIndex: groupIndex,\n chainIndex: chainIndex,\n modelIndex: modelIndex,\n groupId: mmtfData.groupIdList[ groupIndex ],\n groupType: mmtfData.groupTypeList[ groupIndex ],\n groupName: groupData.groupName,\n singleLetterCode: groupData.singleLetterCode,\n chemCompType: groupData.chemCompType,\n secStruct: secStruct,\n insCode: insCode,\n sequenceIndex: sequenceIndex\n });\n }\n\n for( k = 0; k < groupAtomCount; ++k ){\n\n if( onAtom ){\n var atomId = null;\n if( atomIdList ){\n atomId = atomIdList[ atomIndex ];\n }\n var bFactor = null;\n if( bFactorList ){\n bFactor = bFactorList[ atomIndex ];\n }\n var altLoc = null;\n if( altLocList ){\n altLoc = String.fromCharCode( altLocList[ atomIndex ] );\n }\n var occupancy = null;\n if( occupancyList ){\n occupancy = occupancyList[ atomIndex ];\n }\n onAtom({\n atomIndex: atomIndex,\n groupIndex: groupIndex,\n chainIndex: chainIndex,\n modelIndex: modelIndex,\n atomId: atomId,\n element: groupData.elementList[ k ],\n atomName: groupData.atomNameList[ k ],\n formalCharge: groupData.formalChargeList[ k ],\n xCoord: mmtfData.xCoordList[ atomIndex ],\n yCoord: mmtfData.yCoordList[ atomIndex ],\n zCoord: mmtfData.zCoordList[ atomIndex ],\n bFactor: bFactor,\n altLoc: altLoc,\n occupancy: occupancy\n });\n }\n\n atomIndex += 1;\n }\n\n if( onBond ){\n // intra group bonds\n var groupBondAtomList = groupData.bondAtomList;\n for( k = 0, kl = groupData.bondOrderList.length; k < kl; ++k ){\n onBond({\n atomIndex1: atomIndex - groupAtomCount + groupBondAtomList[ k * 2 ],\n atomIndex2: atomIndex - groupAtomCount + groupBondAtomList[ k * 2 + 1 ],\n bondOrder: groupData.bondOrderList[ k ]\n });\n }\n }\n\n groupIndex += 1;\n }\n\n chainIndex += 1;\n }\n\n modelFirstAtomIndex = modelLastAtomIndex + 1;\n modelLastAtomIndex = atomIndex - 1; // subtract one as it already has been incremented\n\n if( onBond ){\n // inter group bonds\n if( bondAtomList ){\n for( k = 0, kl = bondAtomList.length; k < kl; k += 2 ){\n var atomIndex1 = bondAtomList[ k ];\n var atomIndex2 = bondAtomList[ k + 1 ];\n if( ( atomIndex1 >= modelFirstAtomIndex && atomIndex1 <= modelLastAtomIndex ) ||\n ( atomIndex2 >= modelFirstAtomIndex && atomIndex2 <= modelLastAtomIndex )\n ){\n onBond({\n atomIndex1: atomIndex1,\n atomIndex2: atomIndex2,\n bondOrder: bondOrderList ? bondOrderList[ k / 2 ] : null\n });\n }\n }\n }\n }\n\n modelIndex += 1;\n }\n\n}\n\n/**\n * Version name\n * @static\n * @type {String}\n */\nvar version = \"v1.1.0dev\";\n\n/**\n * Version name\n * @private\n * @type {String}\n */\nvar baseUrl = \"//mmtf.rcsb.org/v1.0/\";\n\n/**\n * URL of the RCSB webservice to obtain MMTF files\n * @static\n * @type {String}\n */\nvar fetchUrl = baseUrl + \"full/\";\n\n/**\n * URL of the RCSB webservice to obtain reduced MMTF files\n * @static\n * @type {String}\n */\nvar fetchReducedUrl = baseUrl + \"reduced/\";\n\n/**\n * Encode MMTF fields\n * @static\n * @param {module:MmtfDecode.MmtfData} mmtfData - mmtf data\n * @return {Uint8Array} encoded MMTF fields\n */\nfunction encode( mmtfData ){\n return encodeMsgpack( encodeMmtf( mmtfData ) );\n}\n\n/**\n * Decode MMTF fields\n * @static\n * @example\n * // bin is Uint8Array containing the mmtf msgpack\n * var mmtfData = MMTF.decode( bin );\n * console.log( mmtfData.numAtoms );\n *\n * @param {Uint8Array|ArrayBuffer|module:MmtfDecode.EncodedMmtfData} binOrDict - binary MessagePack or encoded MMTF data\n * @param {Object} [params] - decoding parameters\n * @param {String[]} params.ignoreFields - names of optional fields not to decode\n * @return {module:MmtfDecode.MmtfData} mmtfData\n */\nfunction decode( binOrDict, params ){\n\t// make sure binOrDict is not a plain Arraybuffer\n if( binOrDict instanceof ArrayBuffer ){\n binOrDict = new Uint8Array( binOrDict );\n }\n\n var inputDict;\n if( binOrDict instanceof Uint8Array ){\n // get dict from msgpack\n inputDict = decodeMsgpack( binOrDict );\n }else{\n // already a dict\n inputDict = binOrDict;\n }\n\n return decodeMmtf( inputDict, params );\n}\n\n/**\n * @callback module:MMTF.onLoad\n * @param {module:MmtfDecode.MmtfData} mmtfData - decoded mmtf data object\n */\n\n/**\n * helper method to fetch binary files from an URL\n * @private\n * @param {String} pdbid - PDB ID to fetch\n * @param {String} baseUrl - URL to fetch from\n * @param {module:MMTF.onLoad} onLoad - callback( mmtfData )\n * @param {Function} onError - callback( error )\n * @return {undefined}\n */\nfunction _fetch( pdbid, baseUrl, onLoad, onError ){\n var xhr = new XMLHttpRequest();\n function _onLoad(){\n try{\n var mmtfData = decode( xhr.response );\n onLoad( mmtfData );\n }catch( error ){\n onError( error );\n }\n }\n xhr.addEventListener( \"load\", _onLoad, true );\n xhr.addEventListener( \"error\", onError, true );\n xhr.responseType = \"arraybuffer\";\n xhr.open( \"GET\", baseUrl + pdbid.toUpperCase() );\n xhr.send();\n}\n\n/**\n * Fetch MMTF file from RCSB webservice which contains\n * @static\n * @example\n * MMTF.fetch(\n * \"3PQR\",\n * // onLoad callback\n * function( mmtfData ){ console.log( mmtfData ) },\n * // onError callback\n * function( error ){ console.error( error ) }\n * );\n *\n * @param {String} pdbid - PDB ID to fetch\n * @param {module:MMTF.onLoad} onLoad - callback( mmtfData )\n * @param {Function} onError - callback( error )\n * @return {undefined}\n */\nfunction fetch( pdbid, onLoad, onError ){\n _fetch( pdbid, fetchUrl, onLoad, onError );\n}\n\n/**\n * Fetch reduced MMTF file from RCSB webservice which contains\n * protein C-alpha, nucleotide phosphate and ligand atoms\n * @static\n * @example\n * MMTF.fetchReduced(\n * \"3PQR\",\n * // onLoad callback\n * function( mmtfData ){ console.log( mmtfData ) },\n * // onError callback\n * function( error ){ console.error( error ) }\n * );\n *\n * @param {String} pdbid - PDB ID to fetch\n * @param {module:MMTF.onLoad} onLoad - callback( mmtfData )\n * @param {Function} onError - callback( error )\n * @return {undefined}\n */\nfunction fetchReduced( pdbid, onLoad, onError ){\n _fetch( pdbid, fetchReducedUrl, onLoad, onError );\n}\n\nexport { encode, decode, traverseMmtf as traverse, fetch, fetchReduced, version, fetchUrl, fetchReducedUrl, encodeMsgpack, encodeMmtf, decodeMsgpack, decodeMmtf };","/**\n * @file Mmtf Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport {\n buildUnitcellAssembly, calculateBondsBetween, calculateBondsWithin\n} from '../structure/structure-utils'\nimport { ChemCompHetero } from '../structure/structure-constants'\nimport Entity from '../structure/entity'\nimport Unitcell from '../symmetry/unitcell'\nimport Assembly, { AssemblyPart } from '../symmetry/assembly'\n\nimport { decodeMsgpack, decodeMmtf } from '../../lib/mmtf.es6'\n\nconst SstrucMap: {[k: string]: number} = {\n '0': 'i'.charCodeAt(0), // pi helix\n '1': 's'.charCodeAt(0), // bend\n '2': 'h'.charCodeAt(0), // alpha helix\n '3': 'e'.charCodeAt(0), // extended\n '4': 'g'.charCodeAt(0), // 3-10 helix\n '5': 'b'.charCodeAt(0), // bridge\n '6': 't'.charCodeAt(0), // turn\n '7': 'l'.charCodeAt(0), // coil\n '-1': ''.charCodeAt(0) // NA\n}\n\nclass MmtfParser extends StructureParser {\n get type () { return 'mmtf' }\n get isBinary () { return true }\n\n _parse () {\n // https://github.com/rcsb/mmtf\n\n if (Debug) Log.time('MmtfParser._parse ' + this.name)\n\n let i, il, j, jl, groupData\n\n const s = this.structure\n const sd: {[k: string]: any} = decodeMmtf(decodeMsgpack(this.streamer.data))\n\n // structure header\n const headerFields = [\n 'depositionDate', 'releaseDate', 'resolution',\n 'rFree', 'rWork', 'experimentalMethods'\n ]\n headerFields.forEach(function (name) {\n if (sd[ name ] !== undefined) {\n s.header[ name ] = sd[ name ]\n }\n })\n\n let numBonds, numAtoms, numGroups, numChains, numModels\n let chainsPerModel\n\n s.id = sd.structureId\n s.title = sd.title\n\n s.atomStore.addField('formalCharge', 1, 'int8')\n\n if (this.firstModelOnly || this.asTrajectory) {\n numModels = 1\n numChains = sd.chainsPerModel[ 0 ]\n\n numGroups = 0\n for (i = 0, il = numChains; i < il; ++i) {\n numGroups += sd.groupsPerChain[ i ]\n }\n\n numAtoms = 0\n for (i = 0, il = numGroups; i < il; ++i) {\n groupData = sd.groupList[ sd.groupTypeList[ i ] ]\n numAtoms += groupData.atomNameList.length\n }\n\n numBonds = sd.numBonds\n\n chainsPerModel = [ numChains ]\n } else {\n numBonds = sd.numBonds\n numAtoms = sd.numAtoms\n numGroups = sd.numGroups\n numChains = sd.numChains\n numModels = sd.numModels\n\n chainsPerModel = sd.chainsPerModel\n }\n\n numBonds += numGroups // add numGroups to have space for polymer bonds\n\n //\n\n if (this.asTrajectory) {\n for (i = 0, il = sd.numModels; i < il; ++i) {\n const frame = new Float32Array(numAtoms * 3)\n const frameAtomOffset = numAtoms * i\n\n for (j = 0; j < numAtoms; ++j) {\n const j3 = j * 3\n const offset = j + frameAtomOffset\n frame[ j3 ] = sd.xCoordList[ offset ]\n frame[ j3 + 1 ] = sd.yCoordList[ offset ]\n frame[ j3 + 2 ] = sd.zCoordList[ offset ]\n }\n\n s.frames.push(frame)\n }\n }\n\n // bondStore\n const bAtomIndex1 = new Uint32Array(numBonds)\n const bAtomIndex2 = new Uint32Array(numBonds)\n const bBondOrder = new Uint8Array(numBonds)\n\n const aGroupIndex = new Uint32Array(numAtoms)\n const aFormalCharge = new Int8Array(numAtoms)\n\n const gChainIndex = new Uint32Array(numGroups)\n const gAtomOffset = new Uint32Array(numGroups)\n const gAtomCount = new Uint16Array(numGroups)\n\n const cModelIndex = new Uint16Array(numChains)\n const cGroupOffset = new Uint32Array(numChains)\n const cGroupCount = new Uint32Array(numChains)\n\n const mChainOffset = new Uint32Array(numModels)\n const mChainCount = new Uint32Array(numModels)\n\n // set-up model-chain relations\n let chainOffset = 0\n for (i = 0, il = numModels; i < il; ++i) {\n const modelChainCount = chainsPerModel[ i ]\n mChainOffset[ i ] = chainOffset\n mChainCount[ i ] = modelChainCount\n for (j = 0; j < modelChainCount; ++j) {\n cModelIndex[ j + chainOffset ] = i\n }\n chainOffset += modelChainCount\n }\n\n // set-up chain-residue relations\n const groupsPerChain = sd.groupsPerChain\n let groupOffset = 0\n for (i = 0, il = numChains; i < il; ++i) {\n const chainGroupCount = groupsPerChain[ i ]\n cGroupOffset[ i ] = groupOffset\n cGroupCount[ i ] = chainGroupCount\n for (j = 0; j < chainGroupCount; ++j) {\n gChainIndex[ j + groupOffset ] = i\n }\n groupOffset += chainGroupCount\n }\n\n /// ///\n // get data from group map\n\n let atomOffset = 0\n let bondOffset = 0\n\n for (i = 0, il = numGroups; i < il; ++i) {\n groupData = sd.groupList[ sd.groupTypeList[ i ] ]\n const groupAtomCount = groupData.atomNameList.length\n const groupFormalChargeList = groupData.formalChargeList\n\n const groupBondAtomList = groupData.bondAtomList\n const groupBondOrderList = groupData.bondOrderList\n\n for (j = 0, jl = groupBondOrderList.length; j < jl; ++j) {\n bAtomIndex1[ bondOffset ] = atomOffset + groupBondAtomList[ j * 2 ]\n bAtomIndex2[ bondOffset ] = atomOffset + groupBondAtomList[ j * 2 + 1 ]\n bBondOrder[ bondOffset ] = groupBondOrderList[ j ]\n bondOffset += 1\n }\n\n //\n\n gAtomOffset[ i ] = atomOffset\n gAtomCount[ i ] = groupAtomCount\n\n for (j = 0; j < groupAtomCount; ++j) {\n aGroupIndex[ atomOffset ] = i\n aFormalCharge[ atomOffset ] = groupFormalChargeList[ j ]\n atomOffset += 1\n }\n }\n\n // extra bonds\n\n const bondAtomList = sd.bondAtomList\n if (bondAtomList) {\n if (sd.bondOrderList) {\n bBondOrder.set(sd.bondOrderList, bondOffset)\n }\n\n for (i = 0, il = bondAtomList.length; i < il; i += 2) {\n const atomIndex1 = bondAtomList[ i ]\n const atomIndex2 = bondAtomList[ i + 1 ]\n if (atomIndex1 < numAtoms && atomIndex2 < numAtoms) {\n bAtomIndex1[ bondOffset ] = atomIndex1\n bAtomIndex2[ bondOffset ] = atomIndex2\n bondOffset += 1\n }\n }\n }\n\n //\n\n s.bondStore.length = bBondOrder.length\n s.bondStore.count = bondOffset\n s.bondStore.atomIndex1 = bAtomIndex1\n s.bondStore.atomIndex2 = bAtomIndex2\n s.bondStore.bondOrder = bBondOrder\n\n s.atomStore.length = numAtoms\n s.atomStore.count = numAtoms\n s.atomStore.residueIndex = aGroupIndex\n s.atomStore.atomTypeId = new Uint16Array(numAtoms)\n s.atomStore.x = sd.xCoordList.subarray(0, numAtoms)\n s.atomStore.y = sd.yCoordList.subarray(0, numAtoms)\n s.atomStore.z = sd.zCoordList.subarray(0, numAtoms)\n s.atomStore.serial = sd.atomIdList.subarray(0, numAtoms)\n s.atomStore.bfactor = sd.bFactorList.subarray(0, numAtoms)\n s.atomStore.altloc = sd.altLocList.subarray(0, numAtoms)\n s.atomStore.occupancy = sd.occupancyList.subarray(0, numAtoms)\n s.atomStore.formalCharge = aFormalCharge\n\n s.residueStore.length = numGroups\n s.residueStore.count = numGroups\n s.residueStore.chainIndex = gChainIndex\n s.residueStore.residueTypeId = sd.groupTypeList\n s.residueStore.atomOffset = gAtomOffset\n s.residueStore.atomCount = gAtomCount\n s.residueStore.resno = sd.groupIdList.subarray(0, numGroups)\n s.residueStore.sstruc = sd.secStructList.subarray(0, numGroups)\n s.residueStore.inscode = sd.insCodeList.subarray(0, numGroups)\n\n s.chainStore.length = numChains\n s.chainStore.count = numChains\n s.chainStore.entityIndex = new Uint16Array(numChains)\n s.chainStore.modelIndex = cModelIndex\n s.chainStore.residueOffset = cGroupOffset\n s.chainStore.residueCount = cGroupCount\n s.chainStore.chainname = sd.chainNameList.subarray(0, numChains * 4)\n s.chainStore.chainid = sd.chainIdList.subarray(0, numChains * 4)\n\n s.modelStore.length = numModels\n s.modelStore.count = numModels\n s.modelStore.chainOffset = mChainOffset\n s.modelStore.chainCount = mChainCount\n\n //\n\n let groupTypeDict: {[k: number]: any} = {}\n for (i = 0, il = sd.groupList.length; i < il; ++i) {\n const groupType = sd.groupList[ i ]\n const atomTypeIdList: number[] = []\n for (j = 0, jl = groupType.atomNameList.length; j < jl; ++j) {\n const element = groupType.elementList[ j ].toUpperCase()\n const atomname = groupType.atomNameList[ j ]\n atomTypeIdList.push(s.atomMap.add(atomname, element))\n }\n const chemCompType = groupType.chemCompType.toUpperCase()\n const hetFlag = ChemCompHetero.includes(chemCompType)\n\n const numGroupBonds = groupType.bondOrderList.length\n const atomIndices1 = new Array(numGroupBonds)\n const atomIndices2 = new Array(numGroupBonds)\n for (j = 0; j < numGroupBonds; ++j) {\n atomIndices1[ j ] = groupType.bondAtomList[ j * 2 ]\n atomIndices2[ j ] = groupType.bondAtomList[ j * 2 + 1 ]\n }\n const bonds = {\n atomIndices1: atomIndices1,\n atomIndices2: atomIndices2,\n bondOrders: groupType.bondOrderList\n }\n\n groupTypeDict[ i ] = s.residueMap.add(\n groupType.groupName, atomTypeIdList, hetFlag, chemCompType, bonds\n )\n }\n\n for (i = 0, il = numGroups; i < il; ++i) {\n s.residueStore.residueTypeId[ i ] = groupTypeDict[ s.residueStore.residueTypeId[ i ] ]\n }\n\n for (i = 0, il = s.atomStore.count; i < il; ++i) {\n const residueIndex = s.atomStore.residueIndex[ i ]\n const residueType = s.residueMap.list[ s.residueStore.residueTypeId[ residueIndex ] ]\n const resAtomOffset = s.residueStore.atomOffset[ residueIndex ]\n s.atomStore.atomTypeId[ i ] = residueType.atomTypeIdList[ i - resAtomOffset ]\n }\n\n if (sd.secStructList) {\n const secStructLength: number = sd.secStructList.length\n for (i = 0, il = s.residueStore.count; i < il; ++i) {\n // with ( i % secStructLength ) secStruct entries are reused\n const sstruc = SstrucMap[ s.residueStore.sstruc[ i % secStructLength ] ]\n if (sstruc !== undefined) s.residueStore.sstruc[ i ] = sstruc\n }\n }\n\n //\n\n if (sd.entityList) {\n sd.entityList.forEach(function (e: Entity, i: number) {\n s.entityList[ i ] = new Entity(\n s, i, e.description, e.type, e.chainIndexList\n )\n })\n }\n\n if (sd.bioAssemblyList) {\n sd.bioAssemblyList.forEach(function (_assembly: any, k: number) {\n const id = k + 1\n const assembly = new Assembly('' + id)\n s.biomolDict[ 'BU' + id ] = assembly\n let chainToPart: {[k: string]: AssemblyPart} = {}\n _assembly.transformList.forEach(function (_transform: any) {\n const matrix = new Matrix4().fromArray(_transform.matrix).transpose()\n const chainList: string[] = _transform.chainIndexList.map(function (chainIndex: number) {\n let chainname = ''\n for (let k = 0; k < 4; ++k) {\n const code = sd.chainNameList[ chainIndex * 4 + k ]\n if (code) {\n chainname += String.fromCharCode(code)\n } else {\n break\n }\n }\n return chainname\n })\n const part = chainToPart[ chainList.toString() ]\n if (part) {\n part.matrixList.push(matrix)\n } else {\n chainToPart[ chainList.toString() ] = assembly.addPart([ matrix ], chainList)\n }\n })\n })\n }\n\n if (sd.ncsOperatorList) {\n const ncsName = 'NCS'\n const ncsAssembly = new Assembly(ncsName)\n const ncsPart = ncsAssembly.addPart()\n sd.ncsOperatorList.forEach(function (_operator: number[]) {\n const matrix = new Matrix4().fromArray(_operator).transpose()\n ncsPart.matrixList.push(matrix)\n })\n if (ncsPart.matrixList.length > 0) {\n s.biomolDict[ ncsName ] = ncsAssembly\n }\n }\n\n const uc = sd.unitCell\n if (uc && Array.isArray(uc) && uc[ 0 ]) {\n s.unitcell = new Unitcell({\n a: uc[ 0 ],\n b: uc[ 1 ],\n c: uc[ 2 ],\n alpha: uc[ 3 ],\n beta: uc[ 4 ],\n gamma: uc[ 5 ],\n spacegroup: sd.spaceGroup\n })\n } else {\n s.unitcell = undefined\n }\n\n // calculate backbone bonds\n calculateBondsBetween(s, true)\n\n // calculate rung bonds\n calculateBondsWithin(s, true)\n\n s.finalizeAtoms()\n s.finalizeBonds()\n\n buildUnitcellAssembly(s)\n\n if (Debug) Log.timeEnd('MmtfParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('mmtf', MmtfParser)\n\nexport default MmtfParser\n","/**\n * @file Mol2 Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport {\n assignResidueTypeBonds,\n calculateChainnames, calculateSecondaryStructure,\n calculateBondsBetween, calculateBondsWithin\n} from '../structure/structure-utils'\nimport StructureParser from './structure-parser'\n\nconst reWhitespace = /\\s+/\nconst bondTypes: {[k: string]: number} = {\n '1': 1,\n '2': 2,\n '3': 3,\n 'am': 1, // amide\n 'ar': 1, // aromatic\n 'du': 1, // dummy\n 'un': 1, // unknown\n 'nc': 0 // not connected\n}\n\nclass Mol2Parser extends StructureParser {\n get type () { return 'mol2' }\n\n _parse () {\n // http://paulbourke.net/dataformats/mol2/\n\n if (Debug) Log.time('Mol2Parser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n const firstModelOnly = this.firstModelOnly\n const asTrajectory = this.asTrajectory\n\n const frames = s.frames\n let doFrames = false\n let currentFrame: Float32Array, currentCoord: number\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.resize(Math.round(this.streamer.data.length / 60))\n atomStore.addField('partialCharge', 1, 'float32')\n\n let idx = 0\n let moleculeLineNo = 0\n let modelAtomIdxStart = 0\n let modelIdx = -1\n let numAtoms = 0\n\n let currentRecordType = 0\n let moleculeRecordType = 1\n let atomRecordType = 2\n let bondRecordType = 3\n\n const ap1 = s.getAtomProxy()\n const ap2 = s.getAtomProxy()\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ].trim()\n\n if (line === '' || line[ 0 ] === '#') continue\n\n if (line[ 0 ] === '@') {\n if (line === '@MOLECULE') {\n currentRecordType = moleculeRecordType\n moleculeLineNo = 0\n\n ++modelIdx\n } else if (line === '@ATOM') {\n currentRecordType = atomRecordType\n modelAtomIdxStart = atomStore.count\n\n if (asTrajectory) {\n currentCoord = 0\n currentFrame = new Float32Array(numAtoms * 3)\n frames.push(currentFrame)\n\n if (modelIdx > 0) doFrames = true\n }\n } else if (line === '@BOND') {\n currentRecordType = bondRecordType\n } else {\n currentRecordType = 0\n }\n } else if (currentRecordType === moleculeRecordType) {\n if (moleculeLineNo === 0) {\n s.title = line\n s.id = line\n } else if (moleculeLineNo === 1) {\n const ls = line.split(reWhitespace)\n numAtoms = parseInt(ls[ 0 ])\n // num_atoms [num_bonds [num_subst [num_feat [num_sets]]]]\n } else if (moleculeLineNo === 2) {\n\n // const molType = line;\n // SMALL, BIOPOLYMER, PROTEIN, NUCLEIC_ACID, SACCHARIDE\n\n } else if (moleculeLineNo === 3) {\n\n // const chargeType = line;\n // NO_CHARGES, DEL_RE, GASTEIGER, GAST_HUCK, HUCKEL,\n // PULLMAN, GAUSS80_CHARGES, AMPAC_CHARGES,\n // MULLIKEN_CHARGES, DICT_ CHARGES, MMFF94_CHARGES,\n // USER_CHARGES\n\n } else if (moleculeLineNo === 4) {\n\n // const statusBits = line;\n\n } else if (moleculeLineNo === 5) {\n\n // const molComment = line;\n\n }\n\n ++moleculeLineNo\n } else if (currentRecordType === atomRecordType) {\n const ls = line.split(reWhitespace)\n\n if (firstModelOnly && modelIdx > 0) continue\n\n const x = parseFloat(ls[ 2 ])\n const y = parseFloat(ls[ 3 ])\n const z = parseFloat(ls[ 4 ])\n\n if (asTrajectory) {\n const j = currentCoord * 3\n\n currentFrame[ j + 0 ] = x\n currentFrame[ j + 1 ] = y\n currentFrame[ j + 2 ] = z\n\n currentCoord += 1\n\n if (doFrames) continue\n }\n\n const serial = ls[ 0 ]\n const atomname = ls[ 1 ]\n const element = ls[ 5 ].split('.')[ 0 ]\n const resno = ls[ 6 ] ? parseInt(ls[ 6 ]) : 1\n const resname = ls[ 7 ] ? ls[ 7 ] : ''\n const partialCharge = ls[ 8 ] ? parseFloat(ls[ 8 ]) : 0.0\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname, element)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = serial\n atomStore.partialCharge[ idx ] = partialCharge\n\n sb.addAtom(modelIdx, '', '', resname, resno, true)\n\n idx += 1\n } else if (currentRecordType === bondRecordType) {\n if (firstModelOnly && modelIdx > 0) continue\n if (asTrajectory && modelIdx > 0) continue\n\n const ls = line.split(reWhitespace)\n\n // ls[ 0 ] is bond id\n ap1.index = parseInt(ls[ 1 ]) - 1 + modelAtomIdxStart\n ap2.index = parseInt(ls[ 2 ]) - 1 + modelAtomIdxStart\n const order = bondTypes[ ls[ 3 ] ]\n\n s.bondStore.addBond(ap1, ap2, order)\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n sb.finalize()\n s.finalizeAtoms()\n calculateChainnames(s)\n calculateBondsWithin(s, true)\n calculateBondsBetween(s, true)\n s.finalizeBonds()\n assignResidueTypeBonds(s)\n calculateSecondaryStructure(s)\n\n if (Debug) Log.timeEnd('Mol2Parser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('mol2', Mol2Parser)\n\nexport default Mol2Parser\n","/**\n * @file Pdbqt Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport PdbParser from './pdb-parser'\n\n// autodock variant of PDB format with\n// - atom partial charges (empty column in pdb format)\n// - atom types (bfactor column in pdb format)\n// http://autodock.scripps.edu/faqs-help/faq/what-is-the-format-of-a-pdbqt-file\n\nclass PdbqtParser extends PdbParser {\n get type () { return 'pdbqt' }\n}\n\nParserRegistry.add('pdbqt', PdbqtParser)\n\nexport default PdbqtParser\n","/**\n * @file Pqr Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport PdbParser from './pdb-parser'\n\n// http://www.poissonboltzmann.org/docs/file-format-info/\n\nclass PqrParser extends PdbParser {\n get type () { return 'pqr' }\n}\n\nParserRegistry.add('pqr', PqrParser)\n\nexport default PqrParser\n","/**\n * @file Sdf Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { assignResidueTypeBonds } from '../structure/structure-utils'\nimport StructureParser from './structure-parser'\n\nconst reItem = /> +<(.+)>/\n\nclass SdfParser extends StructureParser {\n get type () { return 'sdf' }\n\n _parse () {\n // https://en.wikipedia.org/wiki/Chemical_table_file#SDF\n // http://download.accelrys.com/freeware/ctfile-formats/ctfile-formats.zip\n\n if (Debug) Log.time('SdfParser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n const firstModelOnly = this.firstModelOnly\n const asTrajectory = this.asTrajectory\n\n const headerLines = this.streamer.peekLines(2)\n\n s.id = headerLines[ 0 ].trim()\n s.title = headerLines[ 1 ].trim()\n\n const frames = s.frames\n let doFrames = false\n let currentFrame: Float32Array, currentCoord: number\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.resize(Math.round(this.streamer.data.length / 50))\n atomStore.addField('formalCharge', 1, 'int8')\n\n const ap1 = s.getAtomProxy()\n const ap2 = s.getAtomProxy()\n\n let idx = 0\n let lineNo = 0 // for V2000: current line number in currently parsed Mol file\n let modelIdx = 0\n let modelAtomIdxStart = 0\n\n const sdfData: {[k: string]: string[]}[] = []\n let currentItem: string|boolean = false\n let currentData: {[k: string]: string[]} = {}\n let mItem: RegExpMatchArray | null\n s.extraData.sdf = sdfData\n\n let atomCount, bondCount, atomStart: number, atomEnd: number, bondStart: number, bondEnd: number, x: number, y: number, z: number, atomname: string, element: string, atomindex: number, order: number\n let isV3000 = false, isAtomBlock = false, isBondBlock = false\n let tokens: string[] = [], acc: string[] = []\n const atomindexToStoreindex = new Map()\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n\n if (isV3000 && line) {\n tokens = line.substring(7).split(' ')\n\n // Entity properties may extend over multiple lines (hanging line finishes with '-')\n // Tokens are accumulated to be processed at the same time for a given entity\n if (acc.length) {\n tokens = [...acc, ...tokens]\n acc = []\n }\n if (tokens[tokens.length - 1] === '-') {\n tokens.pop();\n acc = tokens;\n continue;\n }\n }\n\n if (line.substr(0, 4) === '$$$$') {\n lineNo = -1\n ++modelIdx\n modelAtomIdxStart = atomStore.count\n sdfData.push(currentData)\n currentData = {}\n currentItem = false\n isV3000 = false\n } else if (lineNo === 3) {\n isV3000 = line.indexOf(' V3000') > -1\n\n if (isV3000) {\n atomindexToStoreindex.clear()\n } else {\n\n atomCount = parseInt(line.substr(0, 3))\n bondCount = parseInt(line.substr(3, 3))\n\n atomStart = 4\n atomEnd = atomStart + atomCount\n bondStart = atomEnd\n bondEnd = bondStart + bondCount\n\n if (asTrajectory) {\n currentCoord = 0\n currentFrame = new Float32Array(atomCount * 3)\n frames.push(currentFrame)\n\n if (modelIdx > 0) doFrames = true\n }\n }\n } else if (isV3000 && tokens[0] === 'COUNTS') {\n atomCount = parseInt(tokens[1]);\n\n if (asTrajectory) {\n currentCoord = 0\n currentFrame = new Float32Array(atomCount * 3)\n frames.push(currentFrame)\n\n if (modelIdx > 0) doFrames = true\n }\n } else if (isV3000 && tokens.length == 2) {\n if (tokens[1] === 'ATOM') {\n if (tokens[0] === 'BEGIN') isAtomBlock = true\n else if (tokens[0] === 'END') isAtomBlock = false\n } else if (tokens[1] === 'BOND') {\n if (tokens[0] === 'BEGIN') isBondBlock = true\n else if (tokens[0] === 'END') isBondBlock = false\n }\n } else if (\n isAtomBlock \n || (!isV3000 && lineNo >= atomStart && lineNo < atomEnd)\n ) {\n if (firstModelOnly && modelIdx > 0) continue\n\n let charge = 0\n if (isV3000) {\n x = parseFloat(tokens[2])\n y = parseFloat(tokens[3])\n z = parseFloat(tokens[4])\n\n element = tokens[1]\n atomindex = parseInt(tokens[0])\n atomindexToStoreindex.set(atomindex, idx)\n atomname = element + atomindex\n\n if (tokens.length > 6) {\n let chgTok = tokens.slice(6).find(t => t.indexOf('CHG=') === 0);\n if (chgTok) {\n charge = parseInt(chgTok.substring(4))\n }\n }\n } else {\n x = parseFloat(line.substr(0, 10))\n y = parseFloat(line.substr(10, 10))\n z = parseFloat(line.substr(20, 10))\n\n element = line.substr(31, 3).trim()\n atomname = element + (idx - modelAtomIdxStart + 1)\n }\n\n if (asTrajectory) {\n const j = currentCoord * 3\n\n currentFrame[ j + 0 ] = x\n currentFrame[ j + 1 ] = y\n currentFrame[ j + 2 ] = z\n\n currentCoord += 1\n\n if (doFrames) continue\n }\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname, element)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = isV3000 ? atomindex : idx\n atomStore.formalCharge[ idx ] = charge\n\n sb.addAtom(modelIdx, '', '', 'HET', 1, true)\n\n idx += 1\n } else if (\n isBondBlock \n || (!isV3000 && lineNo >= bondStart && lineNo < bondEnd)\n ) {\n if (firstModelOnly && modelIdx > 0) continue\n if (asTrajectory && modelIdx > 0) continue\n\n if (isV3000) {\n ap1.index = atomindexToStoreindex.get(parseInt(tokens[2]))\n ap2.index = atomindexToStoreindex.get(parseInt(tokens[3]))\n order = parseInt(tokens[1])\n } else {\n ap1.index = parseInt(line.substr(0, 3)) - 1 + modelAtomIdxStart\n ap2.index = parseInt(line.substr(3, 3)) - 1 + modelAtomIdxStart\n order = parseInt(line.substr(6, 3))\n }\n\n s.bondStore.addBond(ap1, ap2, order)\n } else if (line.substr(0, 6) === 'M CHG') {\n const chargeCount = parseInt(line.substr(6, 3))\n for (let ci = 0, coffset = 10; ci < chargeCount; ++ci, coffset += 8) {\n const aToken = parseInt(line.substr(coffset, 3))\n const atomIdx = aToken - 1 + modelAtomIdxStart\n const cToken = parseInt(line.substr(coffset + 4, 3))\n atomStore.formalCharge[ atomIdx ] = cToken\n }\n // eslint-disable-next-line no-cond-assign\n } else if (line.charAt(0) === '>' && (mItem = line.match(reItem))) {\n currentItem = mItem[ 1 ]\n currentData[ currentItem ] = []\n } else if (currentItem !== false && line) {\n currentData[ currentItem ].push(line)\n }\n\n ++lineNo\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n assignResidueTypeBonds(s)\n\n if (Debug) Log.timeEnd('SdfParser._parse ' + this.name)\n }\n\n _postProcess () {\n assignResidueTypeBonds(this.structure)\n }\n}\n\nParserRegistry.add('sdf', SdfParser)\nParserRegistry.add('sd', SdfParser)\nParserRegistry.add('mol', SdfParser)\n\nexport default SdfParser\n","/**\n * @file Prmtop Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport {\n assignResidueTypeBonds, calculateBondsBetween,\n calculateBondsWithin, calculateChainnames\n} from '../structure/structure-utils'\n\nconst amberChargeUnitFactor = 18.2223\n\nconst enum Mode {\n Title,\n Pointers,\n AtomName,\n Charge,\n Mass,\n ResidueLabel,\n ResiduePointer,\n BondsIncHydrogen,\n BondsWithoutHydrogen,\n Radii\n}\n\nfunction parseIntSubstr (line: string, start: number, length: number) {\n return parseInt(line.substr(start, length).trim())\n}\n\nclass PrmtopParser extends StructureParser {\n get type () { return 'prmtop' }\n\n _parse () {\n // http://ambermd.org/prmtop.pdf\n // http://ambermd.org/formats.html#topology\n\n if (Debug) Log.time('PrmtopParser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n //\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.addField('partialCharge', 1, 'float32')\n atomStore.addField('radius', 1, 'float32')\n\n const title: string[] = []\n const pointersDict: {[k: string]: number} = {}\n const pointers = [\n 'NATOM', 'NTYPES', 'NBONH', 'MBONA', 'NTHETH', 'MTHETA',\n 'NPHIH', 'MPHIA', 'NHPARM', 'NPARM', 'NNB', 'NRES',\n 'NBONA', 'NTHETA', 'NPHIA', 'NUMBND', 'NUMANG', 'NPTRA',\n 'NATYP', 'NPHB', 'IFPERT', 'NBPER', 'NGPER', 'NDPER',\n 'MBPER', 'MGPER', 'MDPER', 'IFBOX', 'NMXRS', 'IFCAP',\n 'NUMEXTRA', 'NCOPY'\n ]\n pointers.forEach(name => { pointersDict[ name ] = 0 })\n\n let atomNames: string[]\n let charges: Float32Array\n let radii: Float32Array\n let bAtomIndex1: Uint32Array\n let bAtomIndex2: Uint32Array\n let bBondOrder: Uint8Array = new Uint8Array(0)\n let residueLabels: string[]\n let residuePointers: Uint32Array\n\n let mode: number|undefined\n // let currentFormat\n let curIdx: number\n let bondIdx: number\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n const lt = line.trim()\n\n if (!lt) {\n continue\n } else if (line.startsWith('%FORMAT')) {\n // currentFormat = lt.substring(8, lt.length - 1)\n } else if (line.startsWith('%FLAG')) {\n const flag = line.substr(5).trim()\n curIdx = 0\n\n if (flag === 'TITLE') {\n mode = Mode.Title\n } else if (flag === 'POINTERS') {\n mode = Mode.Pointers\n } else if (flag === 'ATOM_NAME') {\n mode = Mode.AtomName\n } else if (flag === 'CHARGE') {\n mode = Mode.Charge\n } else if (flag === 'MASS') {\n mode = Mode.Mass\n } else if (flag === 'RESIDUE_LABEL') {\n mode = Mode.ResidueLabel\n } else if (flag === 'RESIDUE_POINTER') {\n mode = Mode.ResiduePointer\n } else if (flag === 'BONDS_INC_HYDROGEN') {\n bondIdx = 0\n mode = Mode.BondsIncHydrogen\n } else if (flag === 'BONDS_WITHOUT_HYDROGEN') {\n bondIdx = pointersDict['NBONH']\n mode = Mode.BondsWithoutHydrogen\n } else if (flag === 'RADII') {\n mode = Mode.Radii\n } else {\n mode = undefined\n }\n } else if (mode === Mode.Title) {\n title.push(lt)\n } else if (mode === Mode.Pointers) {\n const n = Math.min(curIdx + 10, 32)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n pointersDict[pointers[curIdx]] = parseInt(\n line.substr(i * 8, 8).trim()\n )\n }\n atomNames = new Array(pointersDict.NATOM)\n charges = new Float32Array(pointersDict.NATOM)\n radii = new Float32Array(pointersDict.NATOM)\n atomStore.resize(pointersDict.NATOM)\n const bondCount = pointersDict.NBONH + pointersDict.MBONA\n bAtomIndex1 = new Uint32Array(bondCount)\n bAtomIndex2 = new Uint32Array(bondCount)\n bBondOrder = new Uint8Array(bondCount)\n residueLabels = new Array(pointersDict.NRES)\n residuePointers = new Uint32Array(pointersDict.NRES)\n } else if (mode === Mode.AtomName) {\n const n = Math.min(curIdx + 20, pointersDict.NATOM)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n atomNames[curIdx] = line.substr(i * 4, 4).trim()\n }\n } else if (mode === Mode.Charge) {\n const n = Math.min(curIdx + 5, pointersDict.NATOM)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n charges[curIdx] = parseFloat(line.substr(i * 16, 16)) / amberChargeUnitFactor\n }\n } else if (mode === Mode.Mass) {\n\n // not currently used\n\n } else if (mode === Mode.ResidueLabel) {\n const n = Math.min(curIdx + 20, pointersDict.NRES)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n residueLabels[curIdx] = line.substr(i * 4, 4).trim()\n }\n } else if (mode === Mode.ResiduePointer) {\n const n = Math.min(curIdx + 10, pointersDict.NRES)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n residuePointers[curIdx] = parseIntSubstr(line, i * 8, 8)\n }\n } else if (mode === Mode.BondsIncHydrogen) {\n const n = Math.min(curIdx + 10, pointersDict.NBONH * 3)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n const r = curIdx % 3\n if (r === 0) {\n bAtomIndex1[bondIdx] = parseIntSubstr(line, i * 8, 8) / 3\n } if (r === 1) {\n bAtomIndex2[bondIdx] = parseIntSubstr(line, i * 8, 8) / 3\n bBondOrder[bondIdx] = 1\n ++bondIdx\n }\n }\n } else if (mode === Mode.BondsWithoutHydrogen) {\n const n = Math.min(curIdx + 10, pointersDict.MBONA * 3)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n const r = curIdx % 3\n if (r === 0) {\n bAtomIndex1[bondIdx] = parseIntSubstr(line, i * 8, 8) / 3\n } if (r === 1) {\n bAtomIndex2[bondIdx] = parseIntSubstr(line, i * 8, 8) / 3\n bBondOrder[bondIdx] = 1\n ++bondIdx\n }\n }\n } else if (mode === Mode.Radii) {\n const n = Math.min(curIdx + 5, pointersDict.NATOM)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n radii[curIdx] = parseFloat(line.substr(i * 16, 16))\n }\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n s.title = title.join(' ')\n\n const atomCount = pointersDict.NATOM\n let curResIdx = 0\n let curResname = residueLabels![0]\n let curResno = 1\n for (let i = 0; i < atomCount; ++i) {\n if (i + 1 === residuePointers![curResIdx + 1]) {\n ++curResIdx\n curResname = residueLabels![curResIdx]\n curResno = curResIdx + 1\n }\n atomStore.atomTypeId[i] = atomMap.add(atomNames![i])\n atomStore.serial[i] = i + 1\n sb.addAtom(0, '', '', curResname, curResno, false)\n }\n\n atomStore.partialCharge.set(charges!)\n atomStore.radius.set(radii!)\n\n s.bondStore.length = bBondOrder!.length\n s.bondStore.count = bBondOrder!.length\n s.bondStore.atomIndex1 = bAtomIndex1!\n s.bondStore.atomIndex2 = bAtomIndex2!\n s.bondStore.bondOrder = bBondOrder\n\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n calculateBondsWithin(s, true)\n calculateBondsBetween(s, true, true)\n calculateChainnames(s, true)\n assignResidueTypeBonds(s)\n\n if (Debug) Log.timeEnd('PrmtopParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('prmtop', PrmtopParser)\nParserRegistry.add('parm7', PrmtopParser)\n\nexport default PrmtopParser\n","/**\n * @file Psf Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport {\n assignResidueTypeBonds, calculateBondsBetween,\n calculateBondsWithin, getChainname\n} from '../structure/structure-utils'\n\nconst TitleMode = 1\nconst AtomMode = 2\nconst BondMode = 3\nconst AngleMode = 4\nconst DihedralMode = 5\nconst ImproperMode = 6\n\nconst reWhitespace = /\\s+/\nconst reTitle = /(^\\*|REMARK)*/\n\nclass PsfParser extends StructureParser {\n get type () { return 'psf' }\n\n _parse () {\n // http://www.ks.uiuc.edu/Training/Tutorials/namd/namd-tutorial-unix-html/node23.html\n\n if (Debug) Log.time('PsfParser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n //\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.addField('partialCharge', 1, 'float32')\n\n const title: string[] = []\n\n let mode: number|undefined\n let chainid: string\n let lastSegid: string\n let idx = 0\n let chainIdx = 0\n let bondIdx = 0\n let bAtomIndex1: Uint32Array, bAtomIndex2: Uint32Array, bBondOrder: Uint8Array\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ].trim()\n\n if (!line) {\n mode = undefined\n continue\n }\n\n if (mode === AtomMode) {\n const ls = line.split(reWhitespace)\n\n const serial = parseInt(ls[ 0 ])\n const segid = ls[ 1 ]\n const resno = parseInt(ls[ 2 ])\n const resname = ls[ 3 ]\n const atomname = ls[ 4 ]\n const charge = parseFloat(ls[ 6 ])\n\n if (segid !== lastSegid) {\n chainid = getChainname(chainIdx)\n ++chainIdx\n }\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname)\n\n atomStore.serial[ idx ] = serial\n atomStore.partialCharge[ idx ] = charge\n\n sb.addAtom(0, chainid, chainid, resname, resno, false)\n\n idx += 1\n lastSegid = segid\n } else if (mode === BondMode) {\n const ls = line.split(reWhitespace)\n\n for (let j = 0, m = ls.length; j < m; j += 2) {\n bAtomIndex1[ bondIdx ] = parseInt(ls[ j ]) - 1\n bAtomIndex2[ bondIdx ] = parseInt(ls[ j + 1 ]) - 1\n bBondOrder[ bondIdx ] = 1\n bondIdx += 1\n }\n } else if (mode === TitleMode) {\n title.push(line.replace(reTitle, '').trim())\n } else if (mode === AngleMode) {\n\n // currently not used\n\n } else if (mode === DihedralMode) {\n\n // currently not used\n\n } else if (mode === ImproperMode) {\n\n // currently not used\n\n } else if (line.includes('!NATOM')) {\n mode = AtomMode\n\n const numAtoms = parseInt(line.split(reWhitespace)[ 0 ])\n atomStore.resize(numAtoms)\n } else if (line.includes('!NBOND')) {\n mode = BondMode\n\n const numBonds = parseInt(line.split(reWhitespace)[ 0 ])\n bAtomIndex1 = new Uint32Array(numBonds)\n bAtomIndex2 = new Uint32Array(numBonds)\n bBondOrder = new Uint8Array(numBonds)\n } else if (line.includes('!NTITLE')) {\n mode = TitleMode\n } else if (line.includes('!NTHETA')) {\n mode = AngleMode\n } else if (line.includes('!NPHI')) {\n mode = DihedralMode\n } else if (line.includes('!NIMPHI')) {\n mode = ImproperMode\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n s.title = title.join(' ')\n\n s.bondStore.length = bBondOrder!.length\n s.bondStore.count = bondIdx\n s.bondStore.atomIndex1 = bAtomIndex1!\n s.bondStore.atomIndex2 = bAtomIndex2!\n s.bondStore.bondOrder = bBondOrder!\n\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n calculateBondsWithin(s, true)\n calculateBondsBetween(s, true, true)\n assignResidueTypeBonds(s)\n\n if (Debug) Log.timeEnd('PsfParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('psf', PsfParser)\n\nexport default PsfParser\n","/**\n * @file Top Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport { WaterNames } from '../structure/structure-constants'\nimport {\n assignResidueTypeBonds, calculateBondsBetween,\n calculateBondsWithin, getChainname\n} from '../structure/structure-utils'\n\nconst enum Mode {\n System,\n Molecules,\n Moleculetype,\n Atoms,\n Bonds\n}\n\nconst reField = /\\[ (.+) \\]/\nconst reWhitespace = /\\s+/\n\nclass TopParser extends StructureParser {\n get type () { return 'top' }\n\n _parse () {\n // http://manual.gromacs.org/online/top.html\n\n if (Debug) Log.time('TopParser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n //\n\n const atomMap = s.atomMap\n const bondStore = s.bondStore\n\n const atomStore = s.atomStore\n atomStore.addField('partialCharge', 1, 'float32')\n\n const molecules: [string, number][] = []\n const moleculetypeDict: {[k: string]: {atoms: any[], bonds: any[] }} = {}\n\n let currentMoleculetype: {\n atoms: [number, string, string, number][],\n bonds: [number, number][]\n }\n let mode: number|undefined\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n let lt = line.trim()\n\n if (!lt || lt[0] === '*' || lt[0] === ';') {\n continue\n }\n\n if (lt.startsWith('#include')) {\n throw new Error('TopParser: #include statements not allowed')\n }\n\n const fieldMatch = line.match(reField)\n if (fieldMatch !== null) {\n const name = fieldMatch[1]\n if (name === 'moleculetype') {\n mode = Mode.Moleculetype\n currentMoleculetype = {\n atoms: [],\n bonds: []\n }\n } else if (name === 'atoms') {\n mode = Mode.Atoms\n } else if (name === 'bonds') {\n mode = Mode.Bonds\n } else if (name === 'system') {\n mode = Mode.System\n } else if (name === 'molecules') {\n mode = Mode.Molecules\n } else {\n mode = undefined\n }\n continue\n }\n\n const cIdx = lt.indexOf(';')\n if (cIdx !== -1) {\n lt = lt.substring(0, cIdx).trim()\n }\n if (mode === Mode.Moleculetype) {\n const molName = lt.split(reWhitespace)[0]\n moleculetypeDict[molName] = currentMoleculetype\n } else if (mode === Mode.Atoms) {\n const ls = lt.split(reWhitespace)\n currentMoleculetype.atoms.push([\n parseInt(ls[2]), // resnr\n ls[3], // residue\n ls[4], // atom\n parseFloat(ls[6]) // charge\n ])\n } else if (mode === Mode.Bonds) {\n const ls = lt.split(reWhitespace)\n currentMoleculetype.bonds.push([\n parseInt(ls[0]), // ai\n parseInt(ls[1]) // aj\n ])\n } else if (mode === Mode.System) {\n s.title = lt\n } else if (mode === Mode.Molecules) {\n const ls = lt.split(reWhitespace)\n molecules.push([\n ls[0], // name\n parseInt(ls[1]) // count\n ])\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n let atomCount = 0\n let bondCount = 0\n molecules.forEach(function (val) {\n const [name, molCount] = val\n const molType = moleculetypeDict[name]\n atomCount += molCount * molType.atoms.length\n bondCount += molCount * molType.bonds.length\n })\n\n atomStore.resize(atomCount)\n bondStore.resize(bondCount)\n\n let atomIdx = 0\n let resIdx = 0\n let chainidIdx = 0\n let chainnameIdx = 0\n let bondIdx = 0\n let atomOffset = 0\n let lastResno: number\n\n molecules.forEach(function (val) {\n const [name, molCount] = val\n const molType = moleculetypeDict[name]\n const chainname = getChainname(chainnameIdx)\n for (let i = 0; i < molCount; ++i) {\n lastResno = -1\n const chainid = WaterNames.includes(name) ? chainname : getChainname(chainidIdx)\n molType.atoms.forEach(function (atomData) {\n const [resno, resname, atomname, charge] = atomData\n if (resno !== lastResno) {\n ++resIdx\n }\n atomStore.atomTypeId[atomIdx] = atomMap.add(atomname)\n atomStore.serial[atomIdx] = atomIdx + 1\n atomStore.partialCharge[atomIdx] = charge\n sb.addAtom(0, chainname, chainid, resname, resIdx + 1, false)\n ++atomIdx\n lastResno = resno\n })\n molType.bonds.forEach(function (bondData) {\n bondStore.atomIndex1[bondIdx] = atomOffset + bondData[0] - 1\n bondStore.atomIndex2[bondIdx] = atomOffset + bondData[1] - 1\n ++bondIdx\n })\n ++chainidIdx\n atomOffset += molType.atoms.length\n }\n ++chainnameIdx\n })\n\n bondStore.count = bondCount\n\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n calculateBondsWithin(s, true)\n calculateBondsBetween(s, true, true)\n assignResidueTypeBonds(s)\n\n if (Debug) Log.timeEnd('TopParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('top', TopParser)\n\nexport default TopParser\n","/**\n * @file Trajectory Parser\n * @author Alexander Rose \n * @private\n */\n\nimport Parser, { ParserParameters } from './parser'\nimport Frames from '../trajectory/frames'\nimport Streamer from '../streamer/streamer';\n\nclass TrajectoryParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n super(streamer, params)\n\n this.frames = new Frames(this.name, this.path)\n }\n\n get type () { return 'trajectory' }\n get __objName () { return 'frames' }\n}\n\nexport default TrajectoryParser\n","/**\n * @file Netcdf Reader\n * @author Alexander Rose \n * @private\n *\n * Adapted from https://github.com/cheminfo-js/netcdfjs\n * MIT License, Copyright (c) 2016 cheminfo\n */\n\nimport IOBuffer from './io-buffer'\n\nexport interface NetCDFRecordDimension {\n length: number,\n id?: number,\n name?: string,\n recordStep?: number\n}\n\nexport interface NetCDFHeader {\n recordDimension: NetCDFRecordDimension,\n version: number,\n dimensions: any[],\n globalAttributes: any[],\n variables: any[]\n}\n\nexport interface NetCDFDimension {\n name: string,\n size: number\n}\n\n/**\n * Throws a non-valid NetCDF exception if the statement it's true\n * @ignore\n * @param {boolean} statement - Throws if true\n * @param {string} reason - Reason to throw\n */\nfunction notNetcdf (statement: boolean, reason: string) {\n if (statement) {\n throw new TypeError('Not a valid NetCDF v3.x file: ' + reason)\n }\n}\n\n/**\n * Moves 1, 2, or 3 bytes to next 4-byte boundary\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n */\nfunction padding (buffer: IOBuffer) {\n if ((buffer.offset % 4) !== 0) {\n buffer.skip(4 - (buffer.offset % 4))\n }\n}\n\n/**\n * Reads the name\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @return {string} - Name\n */\nfunction readName (buffer: IOBuffer) {\n // Read name\n const nameLength = buffer.readUint32()\n const name = buffer.readChars(nameLength)\n\n // validate name\n // TODO\n\n // Apply padding\n padding(buffer)\n return name\n}\n\nconst types = {\n BYTE: 1,\n CHAR: 2,\n SHORT: 3,\n INT: 4,\n FLOAT: 5,\n DOUBLE: 6\n}\n\n/**\n * Parse a number into their respective type\n * @ignore\n * @param {number} type - integer that represents the type\n * @return {string} - parsed value of the type\n */\nfunction num2str (type: number) {\n switch (Number(type)) {\n case types.BYTE:\n return 'byte'\n case types.CHAR:\n return 'char'\n case types.SHORT:\n return 'short'\n case types.INT:\n return 'int'\n case types.FLOAT:\n return 'float'\n case types.DOUBLE:\n return 'double'\n default:\n return 'undefined'\n }\n}\n\n/**\n * Parse a number type identifier to his size in bytes\n * @ignore\n * @param {number} type - integer that represents the type\n * @return {number} -size of the type\n */\nfunction num2bytes (type: number) {\n switch (Number(type)) {\n case types.BYTE:\n return 1\n case types.CHAR:\n return 1\n case types.SHORT:\n return 2\n case types.INT:\n return 4\n case types.FLOAT:\n return 4\n case types.DOUBLE:\n return 8\n default:\n return -1\n }\n}\n\n/**\n * Reverse search of num2str\n * @ignore\n * @param {string} type - string that represents the type\n * @return {number} - parsed value of the type\n */\nfunction str2num (type: string) {\n switch (String(type)) {\n case 'byte':\n return types.BYTE\n case 'char':\n return types.CHAR\n case 'short':\n return types.SHORT\n case 'int':\n return types.INT\n case 'float':\n return types.FLOAT\n case 'double':\n return types.DOUBLE\n default:\n return -1\n }\n}\n\n/**\n * Auxiliary function to read numeric data\n * @ignore\n * @param {number} size - Size of the element to read\n * @param {function} bufferReader - Function to read next value\n * @return {Array|number}\n */\nfunction readNumber (size: number, bufferReader: Function) {\n if (size !== 1) {\n const numbers = new Array(size)\n for (let i = 0; i < size; i++) {\n numbers[i] = bufferReader()\n }\n return numbers\n } else {\n return bufferReader()\n }\n}\n\n/**\n * Given a type and a size reads the next element\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {number} type - Type of the data to read\n * @param {number} size - Size of the element to read\n * @return {string|Array|number}\n */\nfunction readType (buffer: IOBuffer, type: number, size: number) {\n switch (type) {\n case types.BYTE:\n return buffer.readBytes(size)\n case types.CHAR:\n return trimNull(buffer.readChars(size))\n case types.SHORT:\n return readNumber(size, buffer.readInt16.bind(buffer))\n case types.INT:\n return readNumber(size, buffer.readInt32.bind(buffer))\n case types.FLOAT:\n return readNumber(size, buffer.readFloat32.bind(buffer))\n case types.DOUBLE:\n return readNumber(size, buffer.readFloat64.bind(buffer))\n default:\n notNetcdf(true, 'non valid type ' + type)\n return undefined\n }\n}\n\n/**\n * Removes null terminate value\n * @ignore\n * @param {string} value - String to trim\n * @return {string} - Trimmed string\n */\nfunction trimNull (value: string) {\n if (value.charCodeAt(value.length - 1) === 0) {\n return value.substring(0, value.length - 1)\n }\n return value\n}\n\n// const STREAMING = 4294967295;\n\n/**\n * Read data for the given non-record variable\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {object} variable - Variable metadata\n * @return {Array} - Data of the element\n */\nfunction nonRecord (buffer: IOBuffer, variable: {type: string, size: number}) {\n // variable type\n const type = str2num(variable.type)\n\n // size of the data\n const size = variable.size / num2bytes(type)\n\n // iterates over the data\n const data = new Array(size)\n for (let i = 0; i < size; i++) {\n data[i] = readType(buffer, type, 1)\n }\n\n return data\n}\n\n/**\n * Read data for the given record variable\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {object} variable - Variable metadata\n * @param {object} recordDimension - Record dimension metadata\n * @return {Array} - Data of the element\n */\nfunction record (buffer:IOBuffer, variable: {type: string, size: number}, recordDimension: NetCDFRecordDimension) {\n // variable type\n const type = str2num(variable.type)\n const width = variable.size ? variable.size / num2bytes(type) : 1\n\n // size of the data\n // TODO streaming data\n const size = recordDimension.length\n\n // iterates over the data\n const data = new Array(size)\n const step = recordDimension.recordStep\n\n for (let i = 0; i < size; i++) {\n const currentOffset = buffer.offset\n data[i] = readType(buffer, type, width)\n buffer.seek(currentOffset + step!)\n }\n\n return data\n}\n\n// Grammar constants\nconst ZERO = 0\nconst NC_DIMENSION = 10\nconst NC_VARIABLE = 11\nconst NC_ATTRIBUTE = 12\n\n/**\n * Read the header of the file\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {number} version - Version of the file\n * @return {object} - Object with the fields:\n * * `recordDimension`: Number with the length of record dimension\n * * `dimensions`: List of dimensions\n * * `globalAttributes`: List of global attributes\n * * `variables`: List of variables\n */\nfunction header (buffer: IOBuffer, version: number) {\n // Length of record dimension\n // sum of the varSize's of all the record variables.\n const header: Partial = {recordDimension: {length: buffer.readUint32()}}\n\n // Version\n header.version = version\n\n // List of dimensions\n const dimList = dimensionsList(buffer) as {dimensions: NetCDFDimension[], recordId: number, recordName: string}\n header.recordDimension!.id = dimList.recordId\n header.recordDimension!.name = dimList.recordName\n header.dimensions = dimList.dimensions\n\n // List of global attributes\n header.globalAttributes = attributesList(buffer)\n\n // List of variables\n const variables = variablesList(buffer, dimList.recordId, version) as {variables: any[], recordStep: number}\n header.variables = variables.variables\n header.recordDimension!.recordStep = variables.recordStep\n\n return header\n}\n\n/**\n * List of dimensions\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @return {object} - List of dimensions and record dimension with:\n * * `name`: String with the name of the dimension\n * * `size`: Number with the size of the dimension\n */\nfunction dimensionsList (buffer: IOBuffer) {\n let dimensions: NetCDFDimension[], recordId, recordName\n const dimList = buffer.readUint32()\n if (dimList === ZERO) {\n notNetcdf((buffer.readUint32() !== ZERO), 'wrong empty tag for list of dimensions')\n return []\n } else {\n notNetcdf((dimList !== NC_DIMENSION), 'wrong tag for list of dimensions')\n\n // Length of dimensions\n const dimensionSize = buffer.readUint32()\n dimensions = new Array(dimensionSize)\n for (let dim = 0; dim < dimensionSize; dim++) {\n // Read name\n const name = readName(buffer)\n\n // Read dimension size\n const size = buffer.readUint32()\n if (size === 0) {\n recordId = dim\n recordName = name\n }\n\n dimensions[dim] = {\n name: name,\n size: size\n }\n }\n return {\n dimensions: dimensions,\n recordId: recordId,\n recordName: recordName\n }\n }\n}\n\n/**\n * List of attributes\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @return {Array} - List of attributes with:\n * * `name`: String with the name of the attribute\n * * `type`: String with the type of the attribute\n * * `value`: A number or string with the value of the attribute\n */\nfunction attributesList (buffer: IOBuffer) {\n let attributes\n const gAttList = buffer.readUint32()\n if (gAttList === ZERO) {\n notNetcdf((buffer.readUint32() !== ZERO), 'wrong empty tag for list of attributes')\n return []\n } else {\n notNetcdf((gAttList !== NC_ATTRIBUTE), 'wrong tag for list of attributes')\n\n // Length of attributes\n const attributeSize = buffer.readUint32()\n attributes = new Array(attributeSize)\n for (let gAtt = 0; gAtt < attributeSize; gAtt++) {\n // Read name\n const name = readName(buffer)\n\n // Read type\n const type = buffer.readUint32()\n notNetcdf(((type < 1) || (type > 6)), 'non valid type ' + type)\n\n // Read attribute\n const size = buffer.readUint32()\n const value = readType(buffer, type, size)\n\n // Apply padding\n padding(buffer)\n\n attributes[gAtt] = {\n name: name,\n type: num2str(type),\n value: value\n }\n }\n }\n return attributes\n}\n\n/**\n * List of variables\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {number} recordId - Id if the record dimension\n * @param {number} version - Version of the file\n * @return {object} - Number of recordStep and list of variables with:\n * * `name`: String with the name of the variable\n * * `dimensions`: Array with the dimension IDs of the variable\n * * `attributes`: Array with the attributes of the variable\n * * `type`: String with the type of the variable\n * * `size`: Number with the size of the variable\n * * `offset`: Number with the offset where of the variable begins\n * * `record`: True if is a record variable, false otherwise\n */\nfunction variablesList (buffer: IOBuffer, recordId: number, version: number) {\n const varList = buffer.readUint32()\n let recordStep = 0\n let variables\n if (varList === ZERO) {\n notNetcdf(\n (buffer.readUint32() !== ZERO),\n 'wrong empty tag for list of variables'\n )\n return []\n } else {\n notNetcdf((varList !== NC_VARIABLE), 'wrong tag for list of variables')\n\n // Length of variables\n const variableSize = buffer.readUint32()\n variables = new Array(variableSize)\n for (let v = 0; v < variableSize; v++) {\n // Read name\n const name = readName(buffer)\n\n // Read dimensionality of the variable\n const dimensionality = buffer.readUint32()\n\n // Index into the list of dimensions\n const dimensionsIds = new Array(dimensionality)\n for (let dim = 0; dim < dimensionality; dim++) {\n dimensionsIds[dim] = buffer.readUint32()\n }\n\n // Read variables size\n const attributes = attributesList(buffer)\n\n // Read type\n const type = buffer.readUint32()\n notNetcdf(((type < 1) && (type > 6)), 'non valid type ' + type)\n\n // Read variable size\n // The 32-bit varSize field is not large enough to contain the\n // size of variables that require more than 2^32 - 4 bytes,\n // so 2^32 - 1 is used in the varSize field for such variables.\n const varSize = buffer.readUint32()\n\n // Read offset\n let offset = buffer.readUint32()\n if (version === 2) {\n notNetcdf((offset > 0), 'offsets larger than 4GB not supported')\n offset = buffer.readUint32()\n }\n\n // Count amount of record variables\n if (dimensionsIds[0] === recordId) {\n recordStep += varSize\n }\n\n variables[v] = {\n name: name,\n dimensions: dimensionsIds,\n attributes: attributes,\n type: num2str(type),\n size: varSize,\n offset: offset,\n record: (dimensionsIds[0] === recordId)\n }\n }\n }\n\n return {\n variables: variables,\n recordStep: recordStep\n }\n}\n\n/**\n * Reads a NetCDF v3.x file\n * https://www.unidata.ucar.edu/software/netcdf/docs/file_format_specifications.html\n */\nclass NetcdfReader {\n header: Partial\n buffer: IOBuffer\n /**\n * @param {ArrayBuffer} data - ArrayBuffer or any Typed Array with the data\n */\n constructor (data: ArrayBuffer) {\n const buffer = new IOBuffer(data)\n buffer.setBigEndian()\n\n // Validate that it's a NetCDF file\n notNetcdf((buffer.readChars(3) !== 'CDF'), 'should start with CDF')\n\n // Check the NetCDF format\n const version = buffer.readByte()\n notNetcdf((version > 2), 'unknown version')\n\n // Read the header\n this.header = header(buffer, version)\n this.buffer = buffer\n }\n\n /**\n * @return {string} - Version for the NetCDF format\n */\n get version () {\n if (this.header.version === 1) {\n return 'classic format'\n } else {\n return '64-bit offset format'\n }\n }\n\n /**\n * @return {object} - Metadata for the record dimension\n * * `length`: Number of elements in the record dimension\n * * `id`: Id number in the list of dimensions for the record dimension\n * * `name`: String with the name of the record dimension\n * * `recordStep`: Number with the record variables step size\n */\n get recordDimension () {\n return this.header.recordDimension\n }\n\n /**\n * @return {Array} - List of dimensions with:\n * * `name`: String with the name of the dimension\n * * `size`: Number with the size of the dimension\n */\n get dimensions () {\n return this.header.dimensions\n }\n\n /**\n * @return {Array} - List of global attributes with:\n * * `name`: String with the name of the attribute\n * * `type`: String with the type of the attribute\n * * `value`: A number or string with the value of the attribute\n */\n get globalAttributes () {\n return this.header.globalAttributes\n }\n\n /**\n * @return {Array} - List of variables with:\n * * `name`: String with the name of the variable\n * * `dimensions`: Array with the dimension IDs of the variable\n * * `attributes`: Array with the attributes of the variable\n * * `type`: String with the type of the variable\n * * `size`: Number with the size of the variable\n * * `offset`: Number with the offset where of the variable begins\n * * `record`: True if is a record variable, false otherwise\n */\n get variables () {\n return this.header.variables\n }\n\n /**\n * Checks if a variable is available\n * @param {string|object} variableName - Name of the variable to check\n * @return {Boolean} - Variable existence\n */\n hasDataVariable (variableName: string) {\n return this.header.variables!.findIndex(function (val) {\n return val.name === variableName\n }) !== -1\n }\n\n /**\n * Retrieves the data for a given variable\n * @param {string|object} variableName - Name of the variable to search or variable object\n * @return {Array} - List with the variable values\n */\n getDataVariable (variableName: string|{}) {\n let variable\n if (typeof variableName === 'string') {\n // search the variable\n variable = this.header.variables!.find(function (val) {\n return val.name === variableName\n })\n } else {\n variable = variableName\n }\n\n // throws if variable not found\n notNetcdf((variable === undefined), 'variable not found')\n\n // go to the offset position\n this.buffer.seek(variable.offset)\n\n if (variable.record) {\n // record variable case\n return record(this.buffer, variable, this.header.recordDimension!)\n } else {\n // non-record variable case\n return nonRecord(this.buffer, variable)\n }\n }\n}\n\nexport default NetcdfReader\n","/**\n * @file Dcd Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { uint8ToString, ensureBuffer } from '../utils'\nimport TrajectoryParser from './trajectory-parser'\n\nconst charmmTimeUnitFactor = 20.45482949774598\n\ninterface DcdHeader {\n NSET: number,\n ISTART: number,\n NSAVC: number,\n NAMNF: number,\n DELTA: number,\n TITLE: string,\n NATOM: number\n}\n\nclass DcdParser extends TrajectoryParser {\n get type () { return 'dcd' }\n get isBinary () { return true }\n\n _parse () {\n // http://www.ks.uiuc.edu/Research/vmd/plugins/molfile/dcdplugin.html\n\n // The DCD format is structured as follows\n // (FORTRAN UNFORMATTED, with Fortran data type descriptions):\n // HDR NSET ISTRT NSAVC 5-ZEROS NATOM-NFREAT DELTA 9-ZEROS\n // `CORD' #files step 1 step zeroes (zero) timestep (zeroes)\n // interval\n // C*4 INT INT INT 5INT INT DOUBLE 9INT\n // ==========================================================================\n // NTITLE TITLE\n // INT (=2) C*MAXTITL\n // (=32)\n // ==========================================================================\n // NATOM\n // #atoms\n // INT\n // ==========================================================================\n // X(I), I=1,NATOM (DOUBLE)\n // Y(I), I=1,NATOM\n // Z(I), I=1,NATOM\n // ==========================================================================\n\n if (Debug) Log.time('DcdParser._parse ' + this.name)\n\n const bin = ensureBuffer(this.streamer.data)\n const dv = new DataView(bin)\n\n const f = this.frames\n const coordinates = f.coordinates\n const boxes = f.boxes\n const header: Partial = {}\n\n let nextPos = 0\n\n // header block\n\n const intView = new Int32Array(bin, 0, 23)\n const ef = intView[ 0 ] !== dv.getInt32(0) // endianess flag\n // swap byte order when big endian (84 indicates little endian)\n if (intView[ 0 ] !== 84) {\n const n = bin.byteLength\n for (let i = 0; i < n; i += 4) {\n dv.setFloat32(i, dv.getFloat32(i), true)\n }\n }\n if (intView[ 0 ] !== 84) {\n Log.error('dcd bad format, header block start')\n }\n // format indicator, should read 'CORD'\n const formatString = String.fromCharCode(\n dv.getUint8(4), dv.getUint8(5),\n dv.getUint8(6), dv.getUint8(7)\n )\n if (formatString !== 'CORD') {\n Log.error('dcd bad format, format string')\n }\n let isCharmm = false\n let extraBlock = false\n let fourDims = false\n // version field in charmm, unused in X-PLOR\n if (intView[ 22 ] !== 0) {\n isCharmm = true\n if (intView[ 12 ] !== 0) extraBlock = true\n if (intView[ 13 ] === 1) fourDims = true\n }\n header.NSET = intView[ 2 ]\n header.ISTART = intView[ 3 ]\n header.NSAVC = intView[ 4 ]\n header.NAMNF = intView[ 10 ]\n if (isCharmm) {\n header.DELTA = dv.getFloat32(44, ef)\n } else {\n header.DELTA = dv.getFloat64(44, ef)\n }\n if (intView[ 22 ] !== 84) {\n Log.error('dcd bad format, header block end')\n }\n nextPos = nextPos + 21 * 4 + 8\n\n // title block\n\n const titleLength = dv.getInt32(nextPos, ef)\n const titlePos = nextPos + 1\n if ((titleLength - 4) % 80 !== 0) {\n Log.error('dcd bad format, title block start')\n }\n header.TITLE = uint8ToString(\n new Uint8Array(bin, titlePos, titleLength)\n )\n if (dv.getInt32(titlePos + titleLength + 4 - 1, ef) !== titleLength) {\n Log.error('dcd bad format, title block end')\n }\n nextPos = nextPos + titleLength + 8\n\n // natom block\n\n if (dv.getInt32(nextPos, ef) !== 4) {\n Log.error('dcd bad format, natom block start')\n }\n header.NATOM = dv.getInt32(nextPos + 4, ef)\n if (dv.getInt32(nextPos + 8, ef) !== 4) {\n Log.error('dcd bad format, natom block end')\n }\n nextPos = nextPos + 4 + 8\n\n // fixed atoms block\n\n if (header.NAMNF > 0) {\n // TODO read coordinates and indices of fixed atoms\n Log.error('dcd format with fixed atoms unsupported, aborting')\n return\n }\n\n // frames\n\n const natom = header.NATOM\n const natom4 = natom * 4\n\n for (let i = 0, n = header.NSET; i < n; ++i) {\n if (extraBlock) {\n nextPos += 4 // block start\n // unitcell: A, alpha, B, beta, gamma, C (doubles)\n const box = new Float32Array(9)\n box[ 0 ] = dv.getFloat64(nextPos, ef)\n box[ 4 ] = dv.getFloat64(nextPos + 2 * 8, ef)\n box[ 8 ] = dv.getFloat64(nextPos + 5 * 8, ef)\n boxes.push(box)\n nextPos += 48\n nextPos += 4 // block end\n }\n\n // xyz coordinates\n const coord = new Float32Array(natom * 3)\n for (let j = 0; j < 3; ++j) {\n if (dv.getInt32(nextPos, ef) !== natom4) {\n Log.error('dcd bad format, coord block start', i, j)\n }\n nextPos += 4 // block start\n const c = new Float32Array(bin, nextPos, natom)\n for (let k = 0; k < natom; ++k) {\n coord[ 3 * k + j ] = c[ k ]\n }\n nextPos += natom4\n if (dv.getInt32(nextPos, ef) !== natom4) {\n Log.error('dcd bad format, coord block end', i, j)\n }\n nextPos += 4 // block end\n }\n coordinates.push(coord)\n\n if (fourDims) {\n const bytes = dv.getInt32(nextPos, ef)\n nextPos += 4 + bytes + 4 // block start + skip + block end\n }\n }\n\n if (header.DELTA) {\n f.deltaTime = header.DELTA * charmmTimeUnitFactor\n }\n if (header.ISTART >= 1) {\n f.timeOffset = (header.ISTART - 1) * f.deltaTime\n }\n\n // console.log(header)\n // console.log(header.TITLE)\n // console.log('isCharmm', isCharmm, 'extraBlock', extraBlock, 'fourDims, fourDims)\n\n if (Debug) Log.timeEnd('DcdParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('dcd', DcdParser)\n\nexport default DcdParser\n","/**\n * @file Nctraj Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport TrajectoryParser from './trajectory-parser'\nimport NetcdfReader from '../utils/netcdf-reader'\n\nclass NctrajParser extends TrajectoryParser {\n get type () { return 'nctraj' }\n get isBinary () { return true }\n\n _parse () {\n // http://ambermd.org/netcdf/nctraj.xhtml\n\n if (Debug) Log.time('NctrajParser._parse ' + this.name)\n\n const netcdfReader = new NetcdfReader(this.streamer.data)\n\n const f = this.frames\n const coordinates = f.coordinates\n const boxes = f.boxes\n const times = f.times\n\n netcdfReader.getDataVariable('coordinates').forEach(function (c) {\n coordinates.push(new Float32Array(c))\n })\n\n if (netcdfReader.hasDataVariable('cell_lengths')) {\n netcdfReader.getDataVariable('cell_lengths').forEach(function (b) {\n boxes.push(new Float32Array(b))\n })\n }\n\n if (netcdfReader.hasDataVariable('time')) {\n netcdfReader.getDataVariable('time').forEach(function (t) {\n times.push(t)\n })\n }\n\n if (times.length >= 1) {\n f.timeOffset = times[0]\n }\n if (times.length >= 2) {\n f.deltaTime = times[1] - times[0]\n }\n\n if (Debug) Log.timeEnd('NctrajParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('nctraj', NctrajParser)\nParserRegistry.add('ncdf', NctrajParser)\nParserRegistry.add('nc', NctrajParser)\n\nexport default NctrajParser\n","/**\n * @file Trr Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { ensureBuffer } from '../utils'\nimport TrajectoryParser from './trajectory-parser'\n\nclass TrrParser extends TrajectoryParser {\n get type () { return 'trr' }\n get isBinary () { return true }\n\n _parse () {\n // https://github.com/gromacs/gromacs/blob/master/src/gromacs/fileio/trrio.cpp\n\n if (Debug) Log.time('TrrParser._parse ' + this.name)\n\n const bin = ensureBuffer(this.streamer.data)\n const dv = new DataView(bin)\n\n const f = this.frames\n const coordinates = f.coordinates\n const boxes = f.boxes\n const times = f.times\n\n let offset = 0\n\n while (true) {\n // const magicnum = dv.getInt32(offset)\n // const i1 = dv.getFloat32(offset + 4)\n offset += 8\n\n const versionSize = dv.getInt32(offset)\n offset += 4\n offset += versionSize\n\n // const irSize = dv.getInt32(offset)\n // const eSize = dv.getInt32(offset + 4)\n const boxSize = dv.getInt32(offset + 8)\n const virSize = dv.getInt32(offset + 12)\n const presSize = dv.getInt32(offset + 16)\n // const topSize = dv.getInt32(offset + 20)\n // const symSize = dv.getInt32(offset + 24)\n const coordSize = dv.getInt32(offset + 28)\n const velocitySize = dv.getInt32(offset + 32)\n const forceSize = dv.getInt32(offset + 36)\n const natoms = dv.getInt32(offset + 40)\n // const step = dv.getInt32(offset + 44)\n // const nre = dv.getInt32(offset + 48)\n offset += 52\n\n const floatSize = boxSize / 9\n const natoms3 = natoms * 3\n\n // let lambda\n if (floatSize === 8) {\n times.push(dv.getFloat64(offset))\n // lambda = dv.getFloat64(offset + 8)\n } else {\n times.push(dv.getFloat32(offset))\n // lambda = dv.getFloat32(offset + 4)\n }\n offset += 2 * floatSize\n\n if (boxSize) {\n const box = new Float32Array(9)\n if (floatSize === 8) {\n for (let i = 0; i < 9; ++i) {\n box[i] = dv.getFloat64(offset) * 10\n offset += 8\n }\n } else {\n for (let i = 0; i < 9; ++i) {\n box[i] = dv.getFloat32(offset) * 10\n offset += 4\n }\n }\n boxes.push(box)\n }\n\n // ignore, unused\n offset += virSize\n\n // ignore, unused\n offset += presSize\n\n if (coordSize) {\n let frameCoords\n if (floatSize === 8) {\n frameCoords = new Float32Array(natoms3)\n for (let i = 0; i < natoms3; ++i) {\n frameCoords[i] = dv.getFloat64(offset) * 10\n offset += 8\n }\n } else {\n const tmp = new Uint32Array(bin, offset, natoms3)\n for (let i = 0; i < natoms3; ++i) {\n const value = tmp[i]\n tmp[i] = (\n ((value & 0xFF) << 24) | ((value & 0xFF00) << 8) |\n ((value >> 8) & 0xFF00) | ((value >> 24) & 0xFF)\n )\n }\n frameCoords = new Float32Array(bin, offset, natoms3)\n for (let i = 0; i < natoms3; ++i) {\n frameCoords[i] *= 10\n offset += 4\n }\n }\n coordinates.push(frameCoords)\n }\n\n // ignore, unused\n offset += velocitySize\n\n // ignore, unused\n offset += forceSize\n\n if (offset >= bin.byteLength) break\n }\n\n if (times.length >= 1) {\n f.timeOffset = times[0]\n }\n if (times.length >= 2) {\n f.deltaTime = times[1] - times[0]\n }\n\n if (Debug) Log.timeEnd('TrrParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('trr', TrrParser)\n\nexport default TrrParser\n","/**\n * @file Xtc Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { ensureBuffer } from '../utils'\nimport TrajectoryParser from './trajectory-parser'\nimport { NumberArray } from '../types';\n\nconst MagicInts = new Uint32Array([\n 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 10, 12, 16, 20, 25, 32, 40, 50, 64,\n 80, 101, 128, 161, 203, 256, 322, 406, 512, 645, 812, 1024, 1290,\n 1625, 2048, 2580, 3250, 4096, 5060, 6501, 8192, 10321, 13003,\n 16384, 20642, 26007, 32768, 41285, 52015, 65536, 82570, 104031,\n 131072, 165140, 208063, 262144, 330280, 416127, 524287, 660561,\n 832255, 1048576, 1321122, 1664510, 2097152, 2642245, 3329021,\n 4194304, 5284491, 6658042, 8388607, 10568983, 13316085, 16777216\n])\nconst FirstIdx = 9\n// const LastIdx = MagicInts.length\n\nfunction sizeOfInt (size: number) {\n let num = 1\n let numOfBits = 0\n while (size >= num && numOfBits < 32) {\n numOfBits++\n num <<= 1\n }\n return numOfBits\n}\n\nconst _tmpBytes = new Uint8Array(32)\n\nfunction sizeOfInts (numOfInts: number, sizes: Int32Array) {\n let numOfBytes = 1\n let numOfBits = 0\n _tmpBytes[0] = 1\n for (let i = 0; i < numOfInts; i++) {\n let bytecnt\n let tmp = 0\n for (bytecnt = 0; bytecnt < numOfBytes; bytecnt++) {\n tmp += _tmpBytes[bytecnt] * sizes[i]\n _tmpBytes[bytecnt] = tmp & 0xff\n tmp >>= 8\n }\n while (tmp !== 0) {\n _tmpBytes[bytecnt++] = tmp & 0xff\n tmp >>= 8\n }\n numOfBytes = bytecnt\n }\n let num = 1\n numOfBytes--\n while (_tmpBytes[numOfBytes] >= num) {\n numOfBits++\n num *= 2\n }\n return numOfBits + numOfBytes * 8\n}\n\nfunction decodeBits (buf: Int32Array, cbuf: Uint8Array, numOfBits: number, buf2: Uint32Array) {\n const mask = (1 << numOfBits) - 1\n let lastBB0 = buf2[1]\n let lastBB1 = buf2[2]\n let cnt = buf[0]\n let num = 0\n\n while (numOfBits >= 8) {\n lastBB1 = (lastBB1 << 8) | cbuf[cnt++]\n num |= (lastBB1 >> lastBB0) << (numOfBits - 8)\n numOfBits -= 8\n }\n\n if (numOfBits > 0) {\n if (lastBB0 < numOfBits) {\n lastBB0 += 8\n lastBB1 = (lastBB1 << 8) | cbuf[cnt++]\n }\n lastBB0 -= numOfBits\n num |= (lastBB1 >> lastBB0) & ((1 << numOfBits) - 1)\n }\n\n num &= mask\n buf[0] = cnt\n buf[1] = lastBB0\n buf[2] = lastBB1\n\n return num\n}\n\nconst _tmpIntBytes = new Int32Array(32)\n\nfunction decodeInts (buf: Int32Array, cbuf: Uint8Array, numOfInts: number, numOfBits: number, sizes: NumberArray, nums: Float32Array, buf2: Uint32Array) {\n let numOfBytes = 0\n _tmpIntBytes[1] = 0\n _tmpIntBytes[2] = 0\n _tmpIntBytes[3] = 0\n\n while (numOfBits > 8) {\n // this is inversed??? why??? because of the endiannness???\n _tmpIntBytes[numOfBytes++] = decodeBits(buf, cbuf, 8, buf2)\n numOfBits -= 8\n }\n\n if (numOfBits > 0) {\n _tmpIntBytes[numOfBytes++] = decodeBits(buf, cbuf, numOfBits, buf2)\n }\n\n for (let i = numOfInts - 1; i > 0; i--) {\n let num = 0\n for (let j = numOfBytes - 1; j >= 0; j--) {\n num = (num << 8) | _tmpIntBytes[j]\n const p = (num / sizes[i]) | 0\n _tmpIntBytes[j] = p\n num = num - p * sizes[i]\n }\n nums[i] = num\n }\n nums[0] = (\n _tmpIntBytes[0] |\n (_tmpIntBytes[1] << 8) |\n (_tmpIntBytes[2] << 16) |\n (_tmpIntBytes[3] << 24)\n )\n}\n\nclass XtcParser extends TrajectoryParser {\n get type () { return 'xtc' }\n get isBinary () { return true }\n\n _parse () {\n // https://github.com/gromacs/gromacs/blob/master/src/gromacs/fileio/xtcio.cpp\n // https://github.com/gromacs/gromacs/blob/master/src/gromacs/fileio/libxdrf.cpp\n\n if (Debug) Log.time('XtcParser._parse ' + this.name)\n\n const bin = ensureBuffer(this.streamer.data)\n const dv = new DataView(bin)\n\n const f = this.frames\n const coordinates = f.coordinates\n const boxes = f.boxes\n const times = f.times\n\n const minMaxInt = new Int32Array(6)\n const sizeint = new Int32Array(3)\n const bitsizeint = new Int32Array(3)\n const sizesmall = new Uint32Array(3)\n const thiscoord = new Float32Array(3)\n const prevcoord = new Float32Array(3)\n\n let offset = 0\n const buf = new Int32Array(3)\n const buf2 = new Uint32Array(buf.buffer)\n\n while (true) {\n let frameCoords: NumberArray\n\n // const magicnum = dv.getInt32(offset)\n const natoms = dv.getInt32(offset + 4)\n // const step = dv.getInt32(offset + 8)\n offset += 12\n\n const natoms3 = natoms * 3\n\n times.push(dv.getFloat32(offset))\n offset += 4\n\n const box = new Float32Array(9)\n for (let i = 0; i < 9; ++i) {\n box[i] = dv.getFloat32(offset) * 10\n offset += 4\n }\n boxes.push(box)\n\n if (natoms <= 9) { // no compression\n frameCoords = new Float32Array(natoms)\n for (let i = 0; i < natoms; ++i) {\n frameCoords[i] = dv.getFloat32(offset)\n offset += 4\n }\n } else {\n buf[0] = buf[1] = buf[2] = 0.0\n sizeint[0] = sizeint[1] = sizeint[2] = 0\n sizesmall[0] = sizesmall[1] = sizesmall[2] = 0\n bitsizeint[0] = bitsizeint[1] = bitsizeint[2] = 0\n thiscoord[0] = thiscoord[1] = thiscoord[2] = 0\n prevcoord[0] = prevcoord[1] = prevcoord[2] = 0\n\n frameCoords = new Float32Array(natoms3)\n let lfp = 0\n\n const lsize = dv.getInt32(offset)\n offset += 4\n const precision = dv.getFloat32(offset)\n offset += 4\n\n minMaxInt[0] = dv.getInt32(offset)\n minMaxInt[1] = dv.getInt32(offset + 4)\n minMaxInt[2] = dv.getInt32(offset + 8)\n minMaxInt[3] = dv.getInt32(offset + 12)\n minMaxInt[4] = dv.getInt32(offset + 16)\n minMaxInt[5] = dv.getInt32(offset + 20)\n sizeint[0] = minMaxInt[3] - minMaxInt[0] + 1\n sizeint[1] = minMaxInt[4] - minMaxInt[1] + 1\n sizeint[2] = minMaxInt[5] - minMaxInt[2] + 1\n offset += 24\n\n let bitsize\n if ((sizeint[0] | sizeint[1] | sizeint[2]) > 0xffffff) {\n bitsizeint[0] = sizeOfInt(sizeint[0])\n bitsizeint[1] = sizeOfInt(sizeint[1])\n bitsizeint[2] = sizeOfInt(sizeint[2])\n bitsize = 0 // flag the use of large sizes\n } else {\n bitsize = sizeOfInts(3, sizeint)\n }\n\n let smallidx = dv.getInt32(offset)\n offset += 4\n // if (smallidx == 0) {alert(\"Undocumented error 1\"); return;}\n\n // let tmpIdx = smallidx + 8\n // const maxidx = (LastIdx < tmpIdx) ? LastIdx : tmpIdx\n // const minidx = maxidx - 8 // often this equal smallidx\n let tmpIdx = smallidx - 1\n tmpIdx = (FirstIdx > tmpIdx) ? FirstIdx : tmpIdx\n let smaller = (MagicInts[tmpIdx] / 2) | 0\n let smallnum = (MagicInts[smallidx] / 2) | 0\n\n sizesmall[0] = sizesmall[1] = sizesmall[2] = MagicInts[smallidx]\n // larger = MagicInts[maxidx]\n\n let adz = Math.ceil(dv.getInt32(offset) / 4) * 4\n offset += 4\n // if (tmpIdx == 0) {alert(\"Undocumented error 2\"); return;}\n\n // buf = new Int32Array(bin, offset);\n // buf8 = new Uint8Array(bin, offset);\n\n // tmpIdx += 3; rndup = tmpIdx%4;\n // for (i=tmpIdx+rndup-1; i>=tmpIdx; i--) buf8[i] = 0;\n\n // now unpack buf2...\n\n const invPrecision = 1.0 / precision\n let run = 0\n let i = 0\n\n const buf8 = new Uint8Array(bin, offset) // 229...\n\n thiscoord[0] = thiscoord[1] = thiscoord[2] = 0\n\n while (i < lsize) {\n if (bitsize === 0) {\n thiscoord[0] = decodeBits(buf, buf8, bitsizeint[0], buf2)\n thiscoord[1] = decodeBits(buf, buf8, bitsizeint[1], buf2)\n thiscoord[2] = decodeBits(buf, buf8, bitsizeint[2], buf2)\n } else {\n decodeInts(buf, buf8, 3, bitsize, sizeint, thiscoord, buf2)\n }\n\n i++\n\n thiscoord[0] += minMaxInt[0]\n thiscoord[1] += minMaxInt[1]\n thiscoord[2] += minMaxInt[2]\n\n prevcoord[0] = thiscoord[0]\n prevcoord[1] = thiscoord[1]\n prevcoord[2] = thiscoord[2]\n\n const flag = decodeBits(buf, buf8, 1, buf2)\n let isSmaller = 0\n\n if (flag === 1) {\n run = decodeBits(buf, buf8, 5, buf2)\n isSmaller = run % 3\n run -= isSmaller\n isSmaller--\n }\n\n // if ((lfp-ptrstart)+run > size3){\n // fprintf(stderr, \"(xdrfile error) Buffer overrun during decompression.\\n\");\n // return 0;\n // }\n\n if (run > 0) {\n thiscoord[0] = thiscoord[1] = thiscoord[2] = 0\n\n for (let k = 0; k < run; k += 3) {\n decodeInts(buf, buf8, 3, smallidx, sizesmall, thiscoord, buf2)\n i++\n\n thiscoord[0] += prevcoord[0] - smallnum\n thiscoord[1] += prevcoord[1] - smallnum\n thiscoord[2] += prevcoord[2] - smallnum\n\n if (k === 0) {\n // interchange first with second atom for\n // better compression of water molecules\n let tmpSwap = thiscoord[0]\n thiscoord[0] = prevcoord[0]\n prevcoord[0] = tmpSwap\n\n tmpSwap = thiscoord[1]\n thiscoord[1] = prevcoord[1]\n prevcoord[1] = tmpSwap\n\n tmpSwap = thiscoord[2]\n thiscoord[2] = prevcoord[2]\n prevcoord[2] = tmpSwap\n\n frameCoords[lfp++] = prevcoord[0] * invPrecision\n frameCoords[lfp++] = prevcoord[1] * invPrecision\n frameCoords[lfp++] = prevcoord[2] * invPrecision\n } else {\n prevcoord[0] = thiscoord[0]\n prevcoord[1] = thiscoord[1]\n prevcoord[2] = thiscoord[2]\n }\n frameCoords[lfp++] = thiscoord[0] * invPrecision\n frameCoords[lfp++] = thiscoord[1] * invPrecision\n frameCoords[lfp++] = thiscoord[2] * invPrecision\n }\n } else {\n frameCoords[lfp++] = thiscoord[0] * invPrecision\n frameCoords[lfp++] = thiscoord[1] * invPrecision\n frameCoords[lfp++] = thiscoord[2] * invPrecision\n }\n\n smallidx += isSmaller\n\n if (isSmaller < 0) {\n smallnum = smaller\n if (smallidx > FirstIdx) {\n smaller = (MagicInts[smallidx - 1] / 2) | 0\n } else {\n smaller = 0\n }\n } else if (isSmaller > 0) {\n smaller = smallnum\n smallnum = (MagicInts[smallidx] / 2) | 0\n }\n sizesmall[0] = sizesmall[1] = sizesmall[2] = MagicInts[smallidx]\n\n if (sizesmall[0] === 0 || sizesmall[1] === 0 || sizesmall[2] === 0) {\n console.error('(xdrfile error) Undefined error.')\n return\n }\n }\n offset += adz\n }\n\n for (let c = 0; c < natoms3; c++) {\n frameCoords[c] *= 10\n }\n\n coordinates.push(frameCoords)\n\n if (offset >= bin.byteLength) break\n }\n\n if (times.length >= 1) {\n f.timeOffset = times[0]\n }\n if (times.length >= 2) {\n f.deltaTime = times[1] - times[0]\n }\n\n if (Debug) Log.timeEnd('XtcParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('xtc', XtcParser)\n\nexport default XtcParser\n","/**\n * @file Volume Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { defaults } from '../utils'\nimport Parser, { ParserParameters } from './parser'\nimport Volume from '../surface/volume'\nimport Streamer from '../streamer/streamer';\n\nexport interface VolumeParserParameters extends ParserParameters {\n voxelSize: number\n}\n\nclass VolumeParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.volume = new Volume(this.name, this.path)\n this.voxelSize = defaults(p.voxelSize, 1)\n }\n\n get type () { return 'volume' }\n get __objName () { return 'volume' }\n\n _afterParse () {\n this.volume.setMatrix(this.getMatrix())\n super._afterParse()\n }\n\n getMatrix () {\n return new Matrix4()\n }\n}\n\nexport default VolumeParser\n","/**\n * @file Cube Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport VolumeParser from './volume-parser'\n\n// @author Johanna Tiemann \n// @author Alexander Rose \n\nconst reWhitespace = /\\s+/\nconst reScientificNotation = /-?\\d+(?:\\.\\d*)?(?:[eE][+-]?\\d+)?/g\nconst bohrToAngstromFactor = 0.529177210859\ninterface Header {\n atomCount: number,\n originX: number,\n originY: number,\n originZ: number,\n NVX: number,\n NVY: number,\n NVZ: number,\n basisX: Vector3,\n basisY: Vector3,\n basisZ: Vector3\n}\n\nclass CubeParser extends VolumeParser {\n get type () { return 'cube' }\n\n _parse () {\n // http://paulbourke.net/dataformats/cube/\n\n if (Debug) Log.time('CubeParser._parse ' + this.name)\n\n const v = this.volume\n const headerLines = this.streamer.peekLines(6)\n const header: Partial
= {}\n\n const scaleFactor = bohrToAngstromFactor * this.voxelSize\n\n function h (k: number, l: number) {\n var field = headerLines[ k ].trim().split(reWhitespace)[ l ]\n return parseFloat(field)\n }\n\n header.atomCount = Math.abs(h(2, 0)) // Number of atoms\n header.originX = h(2, 1) * bohrToAngstromFactor // Position of origin of volumetric data\n header.originY = h(2, 2) * bohrToAngstromFactor\n header.originZ = h(2, 3) * bohrToAngstromFactor\n header.NVX = h(3, 0) // Number of voxels\n header.NVY = h(4, 0)\n header.NVZ = h(5, 0)\n\n header.basisX = new Vector3(h(3, 1), h(3, 2), h(3, 3))\n .multiplyScalar(scaleFactor)\n header.basisY = new Vector3(h(4, 1), h(4, 2), h(4, 3))\n .multiplyScalar(scaleFactor)\n header.basisZ = new Vector3(h(5, 1), h(5, 2), h(5, 3))\n .multiplyScalar(scaleFactor)\n\n const data = new Float32Array(header.NVX * header.NVY * header.NVZ)\n let count = 0\n let lineNo = 0\n const oribitalFlag = h(2, 0) > 0 ? 0 : 1\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ].trim()\n\n if (line !== '' && lineNo >= header.atomCount! + 6 + oribitalFlag) {\n const m = line.match(reScientificNotation) as RegExpMatchArray\n for (let j = 0, lj = m.length; j < lj; ++j) {\n data[ count ] = parseFloat(m[ j ])\n ++count\n }\n }\n\n ++lineNo\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n v.header = header\n v.setData(data, header.NVZ, header.NVY, header.NVX)\n\n if (Debug) Log.timeEnd('CubeParser._parse ' + this.name)\n }\n\n getMatrix () {\n const h = this.volume.header\n const matrix = new Matrix4()\n\n matrix.multiply(\n new Matrix4().makeTranslation(\n h.originX, h.originY, h.originZ\n )\n )\n\n matrix.multiply(\n new Matrix4().makeBasis(\n h.basisZ, h.basisY, h.basisX\n )\n )\n\n return matrix\n }\n}\n\nParserRegistry.add('cub', CubeParser)\nParserRegistry.add('cube', CubeParser)\n\nexport default CubeParser\n","/**\n * @file Dsn6 Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { ensureBuffer } from '../utils'\nimport { degToRad } from '../math/math-utils'\nimport VolumeParser from './volume-parser'\n\ninterface Dsn6Header {\n xStart: number,\n yStart: number,\n zStart: number,\n xExtent: number,\n yExtent: number,\n zExtent: number,\n xRate: number,\n yRate: number,\n zRate: number,\n xlen: number,\n ylen: number,\n zlen: number,\n alpha: number,\n beta: number,\n gamma: number,\n sigma: number\n}\n\nclass Dsn6Parser extends VolumeParser {\n get type () { return 'dsn6' }\n get isBinary () { return true }\n\n _parse () {\n // DSN6 http://www.uoxray.uoregon.edu/tnt/manual/node104.html\n // BRIX http://svn.cgl.ucsf.edu/svn/chimera/trunk/libs/VolumeData/dsn6/brix-1.html\n\n if (Debug) Log.time('Dsn6Parser._parse ' + this.name)\n\n const v = this.volume\n const header: Partial = {}\n let divisor, summand\n\n const bin = ensureBuffer(this.streamer.data)\n const intView = new Int16Array(bin)\n const byteView = new Uint8Array(bin)\n const brixStr = String.fromCharCode.apply(null, byteView.subarray(0, 512))\n\n if (brixStr.startsWith(':-)')) {\n header.xStart = parseInt(brixStr.substr(10, 5)) // NXSTART\n header.yStart = parseInt(brixStr.substr(15, 5))\n header.zStart = parseInt(brixStr.substr(20, 5))\n\n header.xExtent = parseInt(brixStr.substr(32, 5)) // NX\n header.yExtent = parseInt(brixStr.substr(38, 5))\n header.zExtent = parseInt(brixStr.substr(42, 5))\n\n header.xRate = parseInt(brixStr.substr(52, 5)) // MX\n header.yRate = parseInt(brixStr.substr(58, 5))\n header.zRate = parseInt(brixStr.substr(62, 5))\n\n header.xlen = parseFloat(brixStr.substr(73, 10)) * this.voxelSize\n header.ylen = parseFloat(brixStr.substr(83, 10)) * this.voxelSize\n header.zlen = parseFloat(brixStr.substr(93, 10)) * this.voxelSize\n\n header.alpha = parseFloat(brixStr.substr(103, 10))\n header.beta = parseFloat(brixStr.substr(113, 10))\n header.gamma = parseFloat(brixStr.substr(123, 10))\n\n divisor = parseFloat(brixStr.substr(138, 12)) / 100\n summand = parseInt(brixStr.substr(155, 8))\n\n header.sigma = parseFloat(brixStr.substr(170, 12)) * 100\n } else {\n // swap byte order when big endian\n if (intView[ 18 ] !== 100) {\n for (let i = 0, n = intView.length; i < n; ++i) {\n const val = intView[ i ]\n intView[ i ] = ((val & 0xff) << 8) | ((val >> 8) & 0xff)\n }\n }\n\n header.xStart = intView[ 0 ] // NXSTART\n header.yStart = intView[ 1 ]\n header.zStart = intView[ 2 ]\n\n header.xExtent = intView[ 3 ] // NX\n header.yExtent = intView[ 4 ]\n header.zExtent = intView[ 5 ]\n\n header.xRate = intView[ 6 ] // MX\n header.yRate = intView[ 7 ]\n header.zRate = intView[ 8 ]\n\n const factor = 1 / intView[ 17 ]\n const scalingFactor = factor * this.voxelSize\n\n header.xlen = intView[ 9 ] * scalingFactor\n header.ylen = intView[ 10 ] * scalingFactor\n header.zlen = intView[ 11 ] * scalingFactor\n\n header.alpha = intView[ 12 ] * factor\n header.beta = intView[ 13 ] * factor\n header.gamma = intView[ 14 ] * factor\n\n divisor = intView[ 15 ] / 100\n summand = intView[ 16 ]\n header.gamma = intView[ 14 ] * factor\n }\n\n v.header = header\n\n if (Debug) Log.log(header, divisor, summand)\n\n const data = new Float32Array(\n header.xExtent * header.yExtent * header.zExtent\n )\n\n let offset = 512\n const xBlocks = Math.ceil(header.xExtent / 8)\n const yBlocks = Math.ceil(header.yExtent / 8)\n const zBlocks = Math.ceil(header.zExtent / 8)\n\n // loop over blocks\n for (var zz = 0; zz < zBlocks; ++zz) {\n for (var yy = 0; yy < yBlocks; ++yy) {\n for (var xx = 0; xx < xBlocks; ++xx) {\n // loop inside block\n for (var k = 0; k < 8; ++k) {\n var z = 8 * zz + k\n for (var j = 0; j < 8; ++j) {\n var y = 8 * yy + j\n for (var i = 0; i < 8; ++i) {\n var x = 8 * xx + i\n\n // check if remaining slice-part contains data\n if (x < header.xExtent && y < header.yExtent && z < header.zExtent) {\n var idx = ((((x * header.yExtent) + y) * header.zExtent) + z)\n data[ idx ] = (byteView[ offset ] - summand) / divisor\n ++offset\n } else {\n offset += 8 - i\n break\n }\n }\n }\n }\n }\n }\n }\n\n v.setData(data, header.zExtent, header.yExtent, header.xExtent)\n if (header.sigma) {\n v.setStats(undefined, undefined, undefined, header.sigma)\n }\n\n if (Debug) Log.timeEnd('Dsn6Parser._parse ' + this.name)\n }\n\n getMatrix () {\n const h: Dsn6Header = this.volume.header\n\n const basisX = [\n h.xlen as number,\n 0,\n 0\n ]\n\n const basisY = [\n h.ylen * Math.cos(Math.PI / 180.0 * h.gamma),\n h.ylen * Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n\n const basisZ = [\n h.zlen * Math.cos(Math.PI / 180.0 * h.beta),\n h.zlen * (\n Math.cos(Math.PI / 180.0 * h.alpha) -\n Math.cos(Math.PI / 180.0 * h.gamma) *\n Math.cos(Math.PI / 180.0 * h.beta)\n ) / Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n basisZ[ 2 ] = Math.sqrt(\n h.zlen * h.zlen * Math.sin(Math.PI / 180.0 * h.beta) *\n Math.sin(Math.PI / 180.0 * h.beta) - basisZ[ 1 ] * basisZ[ 1 ]\n )\n\n const basis = [ [], basisX, basisY, basisZ ]\n const nxyz = [ 0, h.xRate, h.yRate, h.zRate ]\n const mapcrs = [ 0, 1, 2, 3 ]\n\n const matrix = new Matrix4()\n\n matrix.set(\n basis[ mapcrs[1] ][0] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][0] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][0] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][1] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][1] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][1] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][2] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][2] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][2] / nxyz[ mapcrs[3] ],\n 0,\n 0, 0, 0, 1\n )\n\n matrix.multiply(\n new Matrix4().makeRotationY(degToRad(90))\n )\n\n matrix.multiply(new Matrix4().makeTranslation(\n -h.zStart, h.yStart, h.xStart\n ))\n\n matrix.multiply(new Matrix4().makeScale(\n -1, 1, 1\n ))\n\n return matrix\n }\n}\n\nParserRegistry.add('dsn6', Dsn6Parser)\nParserRegistry.add('brix', Dsn6Parser)\n\nexport default Dsn6Parser\n","/**\n * @file Dx Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { degToRad } from '../math/math-utils'\nimport VolumeParser from './volume-parser'\n\nconst reWhitespace = /\\s+/\n\ninterface DxHeader {\n nx: number,\n ny: number,\n nz: number,\n xmin: number,\n ymin: number,\n zmin: number,\n hx: number,\n hy: number,\n hz: number\n}\n\nclass DxParser extends VolumeParser {\n get type () { return 'dx' }\n\n _parse () {\n // http://apbs.readthedocs.io/en/latest/formats/opendx.html\n\n if (Debug) Log.time('DxParser._parse ' + this.name)\n\n const v = this.volume\n const headerLines = this.streamer.peekLines(30)\n const headerInfo = this.parseHeaderLines(headerLines)\n const header = this.volume.header\n const dataLineStart = headerInfo.dataLineStart\n\n const size = header.nx * header.ny * header.nz\n const data = new Float32Array(size)\n let count = 0\n let lineNo = 0\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string []) {\n for (let i = _i; i < _n; ++i) {\n if (count < size && lineNo > dataLineStart) {\n const line = lines[ i ].trim()\n\n if (line !== '') {\n const ls = line.split(reWhitespace)\n\n for (let j = 0, lj = ls.length; j < lj; ++j) {\n data[ count ] = parseFloat(ls[ j ])\n ++count\n }\n }\n }\n\n ++lineNo\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n v.setData(data, header.nz, header.ny, header.nx)\n\n if (Debug) Log.timeEnd('DxParser._parse ' + this.name)\n }\n\n parseHeaderLines (headerLines: string []) {\n const header: Partial = {}\n const n = headerLines.length\n\n let dataLineStart = 0\n let headerByteCount = 0\n let deltaLineCount = 0\n\n for (let i = 0; i < n; ++i) {\n let ls\n const line = headerLines[ i ]\n\n if (line.startsWith('object 1')) {\n ls = line.split(reWhitespace)\n\n header.nx = parseInt(ls[ 5 ])\n header.ny = parseInt(ls[ 6 ])\n header.nz = parseInt(ls[ 7 ])\n } else if (line.startsWith('origin')) {\n ls = line.split(reWhitespace)\n\n header.xmin = parseFloat(ls[ 1 ])\n header.ymin = parseFloat(ls[ 2 ])\n header.zmin = parseFloat(ls[ 3 ])\n } else if (line.startsWith('delta')) {\n ls = line.split(reWhitespace)\n\n if (deltaLineCount === 0) {\n header.hx = parseFloat(ls[ 1 ]) * this.voxelSize\n } else if (deltaLineCount === 1) {\n header.hy = parseFloat(ls[ 2 ]) * this.voxelSize\n } else if (deltaLineCount === 2) {\n header.hz = parseFloat(ls[ 3 ]) * this.voxelSize\n }\n\n deltaLineCount += 1\n } else if (line.startsWith('object 3')) {\n dataLineStart = i\n headerByteCount += line.length + 1\n break\n }\n\n headerByteCount += line.length + 1\n }\n\n this.volume.header = header\n\n return {\n dataLineStart: dataLineStart,\n headerByteCount: headerByteCount\n }\n }\n\n getMatrix () {\n const h = this.volume.header\n const matrix = new Matrix4()\n\n matrix.multiply(\n new Matrix4().makeRotationY(degToRad(90))\n )\n\n matrix.multiply(\n new Matrix4().makeTranslation(\n -h.zmin, h.ymin, h.xmin\n )\n )\n\n matrix.multiply(\n new Matrix4().makeScale(\n -h.hz, h.hy, h.hx\n )\n )\n\n return matrix\n }\n}\n\nParserRegistry.add('dx', DxParser)\n\nexport default DxParser\n","/**\n * @file Dxbin Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { uint8ToLines, ensureBuffer } from '../utils'\nimport DxParser from './dx-parser'\n\nclass DxbinParser extends DxParser {\n get type () { return 'dxbin' }\n get isBinary () { return true }\n\n _parse () {\n // https://github.com/Electrostatics/apbs-pdb2pqr/issues/216\n\n if (Debug) Log.time('DxbinParser._parse ' + this.name)\n\n const bin = ensureBuffer(this.streamer.data)\n const headerLines = uint8ToLines(new Uint8Array(bin, 0, 1000))\n const headerInfo = this.parseHeaderLines(headerLines)\n const header = this.volume.header\n const headerByteCount = headerInfo.headerByteCount\n\n const size = header.nx * header.ny * header.nz\n const dv = new DataView(bin)\n const data = new Float32Array(size)\n\n for (let i = 0; i < size; ++i) {\n data[ i ] = dv.getFloat64(i * 8 + headerByteCount, true)\n }\n\n this.volume.setData(data, header.nz, header.ny, header.nx)\n\n if (Debug) Log.timeEnd('DxbinParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('dxbin', DxbinParser)\n\nexport default DxbinParser\n","/**\n * @file Mrc Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { ensureBuffer } from '../utils'\nimport VolumeParser from './volume-parser'\n\ninterface MrcHeader {\n MAP: string,\n MACHST: number [],\n NX: number,\n NY: number,\n NZ: number,\n MODE: number,\n NXSTART: number,\n NYSTART: number,\n NZSTART: number,\n MX: number,\n MY: number,\n MZ: number,\n xlen: number,\n ylen: number,\n zlen: number,\n alpha: number,\n beta: number,\n gamma: number,\n MAPC: number,\n MAPR: number,\n MAPS: number,\n DMIN: number,\n DMAX: number,\n DMEAN: number,\n ISPG: number,\n NSYMBT: number,\n LSKFLG: number,\n originX: number,\n originY: number,\n originZ: number,\n ARMS: number\n}\n\nclass MrcParser extends VolumeParser {\n get type () { return 'mrc' }\n get isBinary () { return true }\n\n _parse () {\n // MRC\n // http://ami.scripps.edu/software/mrctools/mrc_specification.php\n // http://www2.mrc-lmb.cam.ac.uk/research/locally-developed-software/image-processing-software/#image\n // http://bio3d.colorado.edu/imod/doc/mrc_format.txt\n\n // CCP4 (MAP)\n // http://www.ccp4.ac.uk/html/maplib.html\n\n // MRC format does not use the skew transformation header records (words 25-37)\n // CCP4 format does not use the ORIGIN header records (words 50-52)\n\n if (Debug) Log.time('MrcParser._parse ' + this.name)\n\n const v = this.volume\n const header: Partial = {}\n\n const bin = ensureBuffer(this.streamer.data)\n const intView = new Int32Array(bin, 0, 56)\n const floatView = new Float32Array(bin, 0, 56)\n const dv = new DataView(bin)\n\n // 53 MAP Character string 'MAP ' to identify file type\n header.MAP = String.fromCharCode(\n dv.getUint8(52 * 4), dv.getUint8(52 * 4 + 1),\n dv.getUint8(52 * 4 + 2), dv.getUint8(52 * 4 + 3)\n )\n\n // 54 MACHST Machine stamp indicating machine type which wrote file\n // 17 and 17 for big-endian or 68 and 65 for little-endian\n header.MACHST = [ dv.getUint8(53 * 4), dv.getUint8(53 * 4 + 1) ]\n\n // swap byte order when big endian\n if (header.MACHST[ 0 ] === 17 && header.MACHST[ 1 ] === 17) {\n const n = bin.byteLength\n for (let i = 0; i < n; i += 4) {\n dv.setFloat32(i, dv.getFloat32(i), true)\n }\n }\n\n header.NX = intView[ 0 ] // NC - columns (fastest changing)\n header.NY = intView[ 1 ] // NR - rows\n header.NZ = intView[ 2 ] // NS - sections (slowest changing)\n\n // mode\n // 0 image : signed 8-bit bytes range -128 to 127\n // 1 image : 16-bit halfwords\n // 2 image : 32-bit reals\n // 3 transform : complex 16-bit integers\n // 4 transform : complex 32-bit reals\n // 6 image : unsigned 16-bit range 0 to 65535\n // 16 image: unsigned char * 3 (for rgb data, non-standard)\n //\n // Note: Mode 2 is the normal mode used in the CCP4 programs.\n // Other modes than 2 and 0 may NOT WORK\n header.MODE = intView[ 3 ]\n\n // start\n header.NXSTART = intView[ 4 ] // NCSTART - first column\n header.NYSTART = intView[ 5 ] // NRSTART - first row\n header.NZSTART = intView[ 6 ] // NSSTART - first section\n\n // intervals\n header.MX = intView[ 7 ] // intervals along x\n header.MY = intView[ 8 ] // intervals along y\n header.MZ = intView[ 9 ] // intervals along z\n\n // cell length (Angstroms in CCP4)\n header.xlen = floatView[ 10 ] * this.voxelSize\n header.ylen = floatView[ 11 ] * this.voxelSize\n header.zlen = floatView[ 12 ] * this.voxelSize\n\n // cell angle (Degrees)\n header.alpha = floatView[ 13 ]\n header.beta = floatView[ 14 ]\n header.gamma = floatView[ 15 ]\n\n // axis correspondence (1,2,3 for X,Y,Z)\n header.MAPC = intView[ 16 ] // column\n header.MAPR = intView[ 17 ] // row\n header.MAPS = intView[ 18 ] // section\n\n // density statistics\n header.DMIN = floatView[ 19 ]\n header.DMAX = floatView[ 20 ]\n header.DMEAN = floatView[ 21 ]\n\n // space group number 0 or 1 (default=0)\n header.ISPG = intView[ 22 ]\n\n // number of bytes used for symmetry data (0 or 80)\n header.NSYMBT = intView[ 23 ]\n\n // Flag for skew transformation, =0 none, =1 if foll\n header.LSKFLG = intView[ 24 ]\n\n // 26-34 SKWMAT Skew matrix S (in order S11, S12, S13, S21 etc) if\n // LSKFLG .ne. 0.\n // 35-37 SKWTRN Skew translation t if LSKFLG != 0.\n // Skew transformation is from standard orthogonal\n // coordinate frame (as used for atoms) to orthogonal\n // map frame, as Xo(map) = S * (Xo(atoms) - t)\n\n // 38 future use (some of these are used by the MSUBSX routines\n // . \" in MAPBRICK, MAPCONT and FRODO)\n // . \" (all set to zero by default)\n // . \"\n // 52 \"\n\n // 50-52 origin in X,Y,Z used for transforms\n header.originX = floatView[ 49 ]\n header.originY = floatView[ 50 ]\n header.originZ = floatView[ 51 ]\n\n // 53 MAP Character string 'MAP ' to identify file type\n // => see top of this parser\n\n // 54 MACHST Machine stamp indicating machine type which wrote file\n // => see top of this parser\n\n // Rms deviation of map from mean density\n header.ARMS = floatView[ 54 ]\n\n // 56 NLABL Number of labels being used\n // 57-256 LABEL(20,10) 10 80 character text labels (ie. A4 format)\n\n v.header = header\n\n // Log.log( header );\n\n let data\n if (header.MODE === 2) {\n data = new Float32Array(\n bin, 256 * 4 + header.NSYMBT,\n header.NX * header.NY * header.NZ\n )\n } else if (header.MODE === 0) {\n data = new Float32Array(new Int8Array(\n bin, 256 * 4 + header.NSYMBT,\n header.NX * header.NY * header.NZ\n ))\n\n // based on uglymol (https://github.com/uglymol/uglymol) by Marcin Wojdyr (wojdyr)\n // if the file was converted by mapmode2to0 - scale the data\n if (intView[ 39 ] === -128 && intView[ 40 ] === 127) {\n // scaling f(x)=b1*x+b0 such that f(-128)=min and f(127)=max\n const b1 = (header.DMAX - header.DMIN) / 255.0\n const b0 = 0.5 * (header.DMIN + header.DMAX + b1)\n for (let j = 0, jl = data.length; j < jl; ++j) {\n data[ j ] = b1 * data[ j ] + b0\n }\n }\n } else {\n Log.error('MrcParser unknown mode', header.MODE)\n }\n\n v.setData(data, header.NX, header.NY, header.NZ)\n if (header.ARMS !== 0) {\n v.setStats(header.DMIN, header.DMAX, header.DMEAN, header.ARMS)\n }\n\n if (Debug) Log.timeEnd('MrcParser._parse ' + this.name)\n }\n\n getMatrix () {\n const h = this.volume.header\n\n const basisX = [\n h.xlen,\n 0,\n 0\n ]\n\n const basisY = [\n h.ylen * Math.cos(Math.PI / 180.0 * h.gamma),\n h.ylen * Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n\n const basisZ = [\n h.zlen * Math.cos(Math.PI / 180.0 * h.beta),\n h.zlen * (\n Math.cos(Math.PI / 180.0 * h.alpha) -\n Math.cos(Math.PI / 180.0 * h.gamma) *\n Math.cos(Math.PI / 180.0 * h.beta)\n ) / Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n basisZ[ 2 ] = Math.sqrt(\n h.zlen * h.zlen * Math.sin(Math.PI / 180.0 * h.beta) *\n Math.sin(Math.PI / 180.0 * h.beta) - basisZ[ 1 ] * basisZ[ 1 ]\n )\n\n const basis = [ [], basisX, basisY, basisZ ]\n const nxyz = [ 0, h.MX, h.MY, h.MZ ]\n const mapcrs = [ 0, h.MAPC, h.MAPR, h.MAPS ]\n\n const matrix = new Matrix4()\n\n matrix.set(\n basis[ mapcrs[1] ][0] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][0] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][0] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][1] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][1] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][1] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][2] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][2] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][2] / nxyz[ mapcrs[3] ],\n 0,\n 0, 0, 0, 1\n )\n\n matrix.setPosition(new Vector3(\n h.originX, h.originY, h.originZ\n ))\n\n matrix.multiply(new Matrix4().makeTranslation(\n h.NXSTART, h.NYSTART, h.NZSTART\n ))\n\n return matrix\n }\n}\n\nParserRegistry.add('mrc', MrcParser)\nParserRegistry.add('ccp4', MrcParser)\nParserRegistry.add('map', MrcParser)\n\nexport default MrcParser\n","/**\n * @file Xplor Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport VolumeParser from './volume-parser'\n\nconst reWhitespace = /\\s+/\n\nfunction parseNumberLine (line: string) {\n return line.trim().split(reWhitespace).map(parseFloat)\n}\n\ninterface XplorHeader {\n NA: number,\n AMIN: number,\n AMAX: number,\n NB: number,\n BMIN: number,\n BMAX: number,\n NC: number,\n CMIN: number,\n CMAX: number,\n a: number,\n b: number,\n c: number,\n alpha: number,\n beta: number,\n gamma: number,\n RAVE: number,\n RSIGMA: number\n}\n\nclass XplorParser extends VolumeParser {\n get type () { return 'xplor' }\n\n _parse () {\n // http://hincklab.uthscsa.edu/html/soft_packs/msi_docs/insight980/xplor/formats.html\n // http://www.mrc-lmb.cam.ac.uk/public/xtal/doc/cns/cns_1.3/tutorial/formats/maps/text.html\n\n if (Debug) Log.time('XplorParser._parse ' + this.name)\n\n const v = this.volume\n const headerLines = this.streamer.peekLines(8)\n const header: Partial = {}\n\n let infoStart\n if (headerLines[ 2 ].startsWith('REMARKS')) {\n infoStart = parseInt(headerLines[ 1 ].substring(0, 8)) + 2\n } else {\n infoStart = 5\n }\n const dataStart = infoStart + 3\n\n const gridInfo = parseNumberLine(headerLines[ infoStart ])\n header.NA = gridInfo[ 0 ]\n header.AMIN = gridInfo[ 1 ]\n header.AMAX = gridInfo[ 2 ]\n header.NB = gridInfo[ 3 ]\n header.BMIN = gridInfo[ 4 ]\n header.BMAX = gridInfo[ 5 ]\n header.NC = gridInfo[ 6 ]\n header.CMIN = gridInfo[ 7 ]\n header.CMAX = gridInfo[ 8 ]\n\n const cellInfo = parseNumberLine(headerLines[ infoStart + 1 ])\n header.a = cellInfo[ 0 ] * this.voxelSize\n header.b = cellInfo[ 1 ] * this.voxelSize\n header.c = cellInfo[ 2 ] * this.voxelSize\n header.alpha = cellInfo[ 3 ]\n header.beta = cellInfo[ 4 ]\n header.gamma = cellInfo[ 5 ]\n\n const na = header.AMAX - header.AMIN + 1\n const nb = header.BMAX - header.BMIN + 1\n const nc = header.CMAX - header.CMIN + 1\n const n = na * nb * nc\n\n const data = new Float32Array(n)\n const lineSection = Math.ceil(1 + (na * nb) / 6)\n let count = 0\n let lineNo = 0\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n\n if (lineNo >= dataStart && (lineNo - dataStart) % lineSection !== 0 && count < n) {\n for (let j = 0, lj = 6; j < lj; ++j) {\n const value = parseFloat(line.substr(12 * j, 12))\n if (isNaN(value)) { break } // Last line of map section\n data[count++] = value\n }\n } else if (count === n) {\n const lt = line.trim()\n if (lt && lt !== '-9999') {\n const ls = parseNumberLine(line)\n header.RAVE = ls[0]\n header.RSIGMA = ls[1]\n }\n }\n\n ++lineNo\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n v.header = header\n v.setData(data, na, nb, nc)\n if (header.RAVE !== 0 && header.RSIGMA !== 1) {\n v.setStats(undefined, undefined, header.RAVE, header.RSIGMA)\n }\n\n if (Debug) Log.timeEnd('XplorParser._parse ' + this.name)\n }\n\n getMatrix () {\n const h = this.volume.header\n\n const basisX = [\n h.a,\n 0,\n 0\n ]\n\n const basisY = [\n h.b * Math.cos(Math.PI / 180.0 * h.gamma),\n h.b * Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n\n const basisZ = [\n h.c * Math.cos(Math.PI / 180.0 * h.beta),\n h.c * (\n Math.cos(Math.PI / 180.0 * h.alpha) -\n Math.cos(Math.PI / 180.0 * h.gamma) *\n Math.cos(Math.PI / 180.0 * h.beta)\n ) / Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n basisZ[ 2 ] = Math.sqrt(\n h.c * h.c * Math.sin(Math.PI / 180.0 * h.beta) *\n Math.sin(Math.PI / 180.0 * h.beta) - basisZ[ 1 ] * basisZ[ 1 ]\n )\n\n const basis = [ [], basisX, basisY, basisZ ]\n const nxyz = [ 0, h.NA, h.NB, h.NC ]\n const mapcrs = [ 0, 1, 2, 3 ]\n\n const matrix = new Matrix4()\n\n matrix.set(\n basis[ mapcrs[1] ][0] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][0] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][0] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][1] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][1] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][1] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][2] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][2] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][2] / nxyz[ mapcrs[3] ],\n 0,\n 0, 0, 0, 1\n )\n\n matrix.multiply(new Matrix4().makeTranslation(\n h.AMIN, h.BMIN, h.CMIN\n ))\n\n return matrix\n }\n}\n\nParserRegistry.add('xplor', XplorParser)\nParserRegistry.add('cns', XplorParser)\n\nexport default XplorParser\n","/**\n * @file Kin Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { Vector3 } from 'three'\nimport Parser from './parser'\n\nfunction hsvToRgb (h: number, s: number, v: number) {\n h /= 360\n s /= 100\n v /= 100\n let r, g, b\n const i = Math.floor(h * 6)\n const f = h * 6 - i\n const p = v * (1 - s)\n const q = v * (1 - f * s)\n const t = v * (1 - (1 - f) * s)\n switch (i % 6) {\n case 0: r = v; g = t; b = p; break\n case 1: r = q; g = v; b = p; break\n case 2: r = p; g = v; b = t; break\n case 3: r = p; g = q; b = v; break\n case 4: r = t; g = p; b = v; break\n case 5: r = v; g = p; b = q; break\n }\n return [ r, g, b ] as number []\n}\n\nconst ColorDict: {[k: string]: number[]} = {\n red: hsvToRgb(0, 100, 100),\n orange: hsvToRgb(20, 100, 100),\n gold: hsvToRgb(40, 100, 100),\n yellow: hsvToRgb(60, 100, 100),\n lime: hsvToRgb(80, 100, 100),\n green: hsvToRgb(120, 80, 100),\n sea: hsvToRgb(150, 100, 100),\n cyan: hsvToRgb(180, 100, 85),\n sky: hsvToRgb(210, 75, 95),\n blue: hsvToRgb(240, 70, 100),\n purple: hsvToRgb(275, 75, 100),\n magenta: hsvToRgb(300, 95, 100),\n hotpink: hsvToRgb(335, 100, 100),\n pink: hsvToRgb(350, 55, 100),\n peach: hsvToRgb(25, 75, 100),\n lilac: hsvToRgb(275, 55, 100),\n pinktint: hsvToRgb(340, 30, 100),\n peachtint: hsvToRgb(25, 50, 100),\n yellowtint: hsvToRgb(60, 50, 100),\n greentint: hsvToRgb(135, 40, 100),\n bluetint: hsvToRgb(220, 40, 100),\n lilactint: hsvToRgb(275, 35, 100),\n white: hsvToRgb(0, 0, 100),\n gray: hsvToRgb(0, 0, 50),\n brown: hsvToRgb(20, 45, 75),\n deadwhite: [ 1, 1, 1 ],\n deadblack: [ 0, 0, 0 ],\n invisible: [ 0, 0, 0 ]\n}\n\nconst reWhitespaceComma = /[\\s,]+/\nconst reCurlyWhitespace = /[^{}\\s]*{[^{}]+}|[^{}\\s]+/g\nconst reTrimCurly = /^{+|}+$/g\nconst reTrimQuotes = /^['\"]+|['\"]+$/g\nconst reCollapseEqual = /\\s*=\\s*/g\n\nfunction parseListDef (line: string) {\n let name\n let defaultColor\n let master = []\n let width\n\n line = line.replace(reCollapseEqual, '=')\n\n const lm = line.match(reCurlyWhitespace) as RegExpMatchArray\n for (let j = 1; j < lm.length; ++j) {\n const e = lm[ j ]\n if (e[ 0 ] === '{') {\n name = e.substring(1, e.length - 1)\n } else {\n const es = e.split('=')\n if (es.length === 2) {\n if (es[ 0 ] === 'color') {\n defaultColor = ColorDict[ es[ 1 ] ]\n } else if (es[ 0 ] === 'width') {\n width = parseInt(es[ 1 ])\n } else if (es[ 0 ] === 'master') {\n master.push(es[ 1 ].replace(reTrimCurly, ''))\n }\n }\n }\n }\n\n return {\n listName: name,\n listColor: defaultColor,\n listMasters: master,\n listWidth: width\n }\n}\n\nfunction parseListElm (line: string) {\n line = line.trim()\n\n const idx1 = line.indexOf('{')\n const idx2 = line.indexOf('}')\n const ls = line.substr(idx2 + 1).split(reWhitespaceComma)\n\n const label = line.substr(idx1 + 1, idx2 - 1)\n const position = [\n parseFloat(ls[ ls.length - 3 ]),\n parseFloat(ls[ ls.length - 2 ]),\n parseFloat(ls[ ls.length - 1 ])\n ]\n let color, width, radius\n let lineBreak = false\n let triangleBreak = false\n for (let lsindex = 4; lsindex <= ls.length; lsindex++) {\n const literal = ls[ ls.length - lsindex ]\n if (literal in ColorDict) {\n color = ColorDict[ ls[ ls.length - lsindex ] ]\n }\n if (literal.startsWith('width')) {\n width = parseInt(literal.substring(5))\n }\n if (literal.startsWith('r=')) {\n radius = parseFloat(literal.split('=')[1])\n }\n if (literal.startsWith('P')) {\n lineBreak = true\n }\n if (literal.startsWith('X')) {\n triangleBreak = true\n }\n }\n // const color = line[ idx2 + 1 ] === ' ' ? undefined : ColorDict[ ls[ 0 ] ]\n\n return {\n label: label,\n position: position,\n color: color,\n radius: radius,\n width: width,\n isLineBreak: lineBreak,\n isTriangleBreak: triangleBreak\n }\n}\n\nfunction parseStr (line: string) {\n const start = line.indexOf('{')\n const end = line.indexOf('}')\n return line.substring(\n start !== -1 ? start + 1 : 0,\n end !== -1 ? end : undefined\n ).trim()\n}\n\nfunction parseFlag (line: string) {\n const end = line.indexOf('}')\n return end === -1 ? undefined : line.substr(end + 1).trim()\n}\n\nfunction parseGroup (line: string) {\n let name:string = ''\n let master:string[] = []\n let flags: {[k: string]: string|boolean} = {}\n\n line = line.replace(reCollapseEqual, '=')\n\n const lm = line.match(reCurlyWhitespace) as RegExpMatchArray\n for (let j = 1; j < lm.length; ++j) {\n const e = lm[ j ]\n if (e[ 0 ] === '{') {\n name = e.substring(1, e.length - 1)\n } else {\n const es = e.split('=')\n if (es.length === 2) {\n if (es[ 0 ] === 'master') {\n master.push(es[ 1 ].replace(reTrimCurly, ''))\n } else {\n flags[ es[ 0 ] ] = es[ 1 ].replace(reTrimCurly, '')\n }\n } else {\n flags[ es[ 0 ] ] = true\n }\n }\n }\n\n return { groupName: name,\n groupFlags: flags,\n groupMasters: master\n }\n}\ninterface RibbonObject {\n labelArray: string[],\n positionArray: number[],\n breakArray: boolean[],\n colorArray: number[],\n name?: string,\n masterArray: any[]\n}\nfunction convertKinTriangleArrays (ribbonObject: RibbonObject) {\n // have to convert ribbons/triangle lists from stripdrawmode to normal drawmode\n // index [ 0 1 2 3 4 5 6 7 8 91011 ]\n // label [ 0 1 2 3 4 5 ] to [ 0 1 2 1 2 3 2 3 4 3 4 5 ]\n // convertedindex [ 0 1 2 3 4 5 6 7 8 91011121314151617181920212223242526 ]\n // index [ 0 1 2 3 4 5 6 7 8 91011121314 ] [ 0 1 2 3 4 5 6 7 8 3 4 5 6 7 8 91011 6 7 8 91011121314 ]\n // position/color [ 0 0 0 1 1 1 2 2 2 3 3 3 4 4 4 ] to [ 0 0 0 1 1 1 2 2 2 1 1 1 2 2 2 3 3 3 2 2 2 3 3 3 4 4 4 ]\n let { labelArray, positionArray, colorArray, breakArray } = ribbonObject\n let convertedLabels = []\n for (let i = 0; i < (labelArray.length - 2) * 3; ++i) {\n convertedLabels[i] = labelArray[i - Math.floor(i / 3) * 2]\n }\n let convertedBreaks = []\n for (let i = 0; i < (breakArray.length - 2) * 3; ++i) {\n convertedBreaks[i] = breakArray[i - Math.floor(i / 3) * 2]\n }\n let convertedPositions = []\n for (let i = 0; i < (positionArray.length / 3 - 2) * 9; ++i) {\n convertedPositions[i] = positionArray[i - Math.floor(i / 9) * 6]\n }\n let convertedColors = []\n for (let i = 0; i < (colorArray.length / 3 - 2) * 9; ++i) {\n convertedColors[i] = colorArray[i - Math.floor(i / 9) * 6]\n }\n let vector3Positions = []\n for (let i = 0; i < (convertedPositions.length) / 3; ++i) {\n vector3Positions.push(new Vector3(convertedPositions[i * 3], convertedPositions[i * 3] + 1, convertedPositions[i * 3] + 2))\n }\n //let normals = []\n //for (let i = 0; i < vector3Positions.length - 1; ++i) {\n // let normalVec3 = vector3Positions[i].cross(vector3Positions[i + 1])\n // normals.push(normalVec3.x)\n // normals.push(normalVec3.y)\n // normals.push(normalVec3.z)\n //}\n return {\n name: ribbonObject.name,\n masterArray: ribbonObject.masterArray,\n labelArray: convertedLabels,\n positionArray: convertedPositions,\n breakArray: convertedBreaks,\n colorArray: convertedColors\n }\n}\n\nfunction removePointBreaksTriangleArrays (convertedRibbonObject: RibbonObject) {\n // after converting ribbon/triangle arrys to drawmode, removed point break triangles\n // label [ 0 1 2 3 4 5 ] to [ 0 1 2 1 2 3 2 3 4 3 4 5 ]\n // position/color [ 0 0 0 1 1 1 2 2 2 3 3 3 4 4 4 ] to [ 0 0 0 1 1 1 2 2 2 1 1 1 2 2 2 3 3 3 2 2 2 3 3 3 4 4 4 ]\n let { labelArray, positionArray, colorArray, breakArray } = convertedRibbonObject\n let editedLabels = []\n let editedPositions = []\n let editedColors = []\n let editedBreaks = []\n for (let i = 0; i < breakArray.length / 3; i++) {\n let breakPointer = i * 3\n let positionPointer = i * 9\n if (!breakArray[breakPointer+1]&&!breakArray[breakPointer+2]) {\n editedLabels.push(labelArray[breakPointer])\n editedLabels.push(labelArray[breakPointer+1])\n editedLabels.push(labelArray[breakPointer+2])\n editedBreaks.push(breakArray[breakPointer])\n editedBreaks.push(breakArray[breakPointer+1])\n editedBreaks.push(breakArray[breakPointer+2])\n editedPositions.push(positionArray[positionPointer])\n editedPositions.push(positionArray[positionPointer+1])\n editedPositions.push(positionArray[positionPointer+2])\n editedPositions.push(positionArray[positionPointer+3])\n editedPositions.push(positionArray[positionPointer+4])\n editedPositions.push(positionArray[positionPointer+5])\n editedPositions.push(positionArray[positionPointer+6])\n editedPositions.push(positionArray[positionPointer+7])\n editedPositions.push(positionArray[positionPointer+8])\n editedColors.push(colorArray[positionPointer])\n editedColors.push(colorArray[positionPointer+1])\n editedColors.push(colorArray[positionPointer+2])\n editedColors.push(colorArray[positionPointer+3])\n editedColors.push(colorArray[positionPointer+4])\n editedColors.push(colorArray[positionPointer+5])\n editedColors.push(colorArray[positionPointer+6])\n editedColors.push(colorArray[positionPointer+7])\n editedColors.push(colorArray[positionPointer+8])\n } else {\n //console.log('X triangle break found')\n //console.log('skipping: '+positionArray[positionPointer]+','+positionArray[positionPointer+1]+','+positionArray[positionPointer+2]+','\n // +positionArray[positionPointer+3]+','+positionArray[positionPointer+4]+','+positionArray[positionPointer+5]+','\n // +positionArray[positionPointer+6]+','+positionArray[positionPointer+7]+','+positionArray[positionPointer+8])\n }\n }\n return {\n name: convertedRibbonObject.name,\n masterArray: convertedRibbonObject.masterArray,\n labelArray: editedLabels,\n positionArray: editedPositions,\n breakArray: editedBreaks,\n colorArray: editedColors\n }\n}\n\ninterface Kinemage {\n kinemage?: number,\n onewidth?: any,\n '1viewid'?: string,\n pdbfile?: string,\n text: string,\n texts: string[],\n captions: string[],\n caption: string,\n groupDict: {[k:string]: {[k:string]: boolean}},\n subgroupDict: {[k: string]: any},\n masterDict: {[k:string]: {indent: boolean, visible: boolean}},\n pointmasterDict: {[k: string]: any},\n dotLists: DotList[],\n vectorLists: VectorList[],\n ballLists: any[],\n ribbonLists: RibbonObject[]\n}\n\ninterface DotList {\n name?: string,\n masterArray: any[],\n labelArray: any[],\n positionArray: any[],\n colorArray: any[]\n}\n\ninterface VectorList {\n name?: string,\n masterArray: any[],\n label1Array: string[],\n label2Array: string[],\n position1Array: number[],\n position2Array: number[],\n color1Array: number[],\n color2Array: number[],\n width: number[]\n}\n\nclass KinParser extends Parser {\n kinemage: Kinemage\n get type () { return 'kin' }\n get __objName () { return 'kinemage' }\n\n _parse () {\n // http://kinemage.biochem.duke.edu/software/king.php\n\n if (Debug) Log.time(`KinParser._parse ${this.name}`)\n\n const kinemage: Kinemage = {\n kinemage: undefined,\n onewidth: undefined,\n '1viewid': undefined,\n pdbfile: undefined,\n texts: [],\n text: '',\n captions: [],\n caption: '',\n groupDict: {},\n subgroupDict: {},\n masterDict: {},\n pointmasterDict: {},\n dotLists: [],\n vectorLists: [],\n ballLists: [],\n ribbonLists: []\n }\n this.kinemage = kinemage\n\n let currentGroupMasters: string[]\n let currentSubgroupMasters: string[]\n\n let isDotList = false\n let prevDotLabel = ''\n let dotDefaultColor: number[]\n let dotLabel: string[], dotPosition: number[], dotColor: number[]\n\n let isVectorList = false\n let prevVecLabel = ''\n let prevVecPosition: number[]|null = null\n let prevVecColor: number[]|null = null\n let vecDefaultColor: number[], vecDefaultWidth: number[]\n let vecLabel1: string[], vecLabel2: string[], vecPosition1: number[], vecPosition2: number[], vecColor1: number[], vecColor2: number[]\n\n let isBallList = false\n let prevBallLabel = ''\n let ballRadius: number[], ballDefaultColor: number[]\n let ballLabel: string[], ballPosition: number[], ballColor: number[]\n\n let isRibbonList = false\n let prevRibbonPointLabel = ''\n\n let ribbonListDefaultColor: number[]\n let ribbonPointLabelArray: string[], ribbonPointPositionArray: number[], ribbonPointBreakArray: boolean[], ribbonPointColorArray: number[]\n\n let isText = false\n let isCaption = false\n\n // @vectorlist {mc} color= white master= {mainchain}\n // { n thr A 1 B13.79 1crnFH} P 17.047, 14.099, 3.625 { n thr A 1 B13.79 1crnFH} L 17.047, 14.099, 3.625\n\n // @dotlist {x} color=white master={vdw contact} master={dots}\n // { CB THR 1 A}sky 'P' 18.915,14.199,5.024\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n\n if (line[ 0 ] === '@') {\n isDotList = false\n isVectorList = false\n isBallList = false\n isRibbonList = false\n isText = false\n isCaption = false\n }\n\n if (!line) {\n isDotList = false\n isVectorList = false\n isBallList = false\n isRibbonList = false\n } else if (line.startsWith('@dotlist')) {\n // @dotlist {x} color=white master={vdw contact} master={dots}\n\n let { listColor, listName, listMasters } = parseListDef(line)\n\n isDotList = true\n prevDotLabel = ''\n dotLabel = []\n dotPosition = []\n dotColor = []\n dotDefaultColor = listColor as number[]\n\n if (currentGroupMasters) {\n listMasters = listMasters.concat(currentGroupMasters)\n }\n if (currentSubgroupMasters) {\n listMasters = listMasters.concat(currentSubgroupMasters)\n }\n\n kinemage.dotLists.push({\n name: listName,\n masterArray: listMasters,\n labelArray: dotLabel,\n positionArray: dotPosition,\n colorArray: dotColor\n })\n } else if (line.startsWith('@vectorlist')) {\n // @vectorlist {x} color=white master={small overlap} master={dots}\n\n let { listMasters, listName, listWidth, listColor } = parseListDef(line)\n\n if (listMasters) {\n listMasters.forEach(function (name: string) {\n if (!kinemage.masterDict[ name ]) {\n kinemage.masterDict[ name ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n\n isVectorList = true\n prevVecLabel = ''\n prevVecPosition = null\n prevVecColor = null\n vecLabel1 = []\n vecLabel2 = []\n vecPosition1 = []\n vecPosition2 = []\n vecColor1 = []\n vecColor2 = []\n vecDefaultColor = listColor as number[]\n vecDefaultWidth = []\n if (listWidth) {\n vecDefaultWidth.push(listWidth)\n }\n\n if (currentGroupMasters) {\n listMasters = listMasters.concat(currentGroupMasters)\n }\n if (currentSubgroupMasters) {\n listMasters = listMasters.concat(currentSubgroupMasters)\n }\n\n kinemage.vectorLists.push({\n name: listName,\n masterArray: listMasters,\n label1Array: vecLabel1,\n label2Array: vecLabel2,\n position1Array: vecPosition1,\n position2Array: vecPosition2,\n color1Array: vecColor1,\n color2Array: vecColor2,\n width: vecDefaultWidth\n })\n } else if (line.startsWith('@balllist')) {\n let { listName, listColor, listMasters } = parseListDef(line)\n\n if (listMasters) {\n listMasters.forEach(function (name: string) {\n if (!kinemage.masterDict[ name ]) {\n kinemage.masterDict[ name ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n\n isBallList = true\n\n prevBallLabel = ''\n ballLabel = []\n ballRadius = []\n ballPosition = []\n ballColor = []\n ballDefaultColor = listColor as number[]\n\n if (currentGroupMasters) {\n listMasters = listMasters.concat(currentGroupMasters)\n }\n if (currentSubgroupMasters) {\n listMasters = listMasters.concat(currentSubgroupMasters)\n }\n\n kinemage.ballLists.push({\n name: listName,\n masterArray: listMasters,\n labelArray: ballLabel,\n radiusArray: ballRadius,\n positionArray: ballPosition,\n colorArray: ballColor\n })\n } else if (line.startsWith('@ribbonlist')||line.startsWith('@trianglelist')) {\n let { listMasters, listName, listColor } = parseListDef(line)\n\n if (listMasters) {\n listMasters.forEach(function (name: string) {\n if (!kinemage.masterDict[ name ]) {\n kinemage.masterDict[ name ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n isRibbonList = true\n prevRibbonPointLabel = ''\n ribbonPointLabelArray = []\n ribbonPointPositionArray = []\n ribbonPointBreakArray = []\n ribbonPointColorArray = []\n ribbonListDefaultColor = listColor as number[]\n\n if (currentGroupMasters) {\n listMasters = listMasters.concat(currentGroupMasters)\n }\n if (currentSubgroupMasters) {\n listMasters = listMasters.concat(currentSubgroupMasters)\n }\n\n kinemage.ribbonLists.push({\n name: listName,\n masterArray: listMasters,\n labelArray: ribbonPointLabelArray,\n positionArray: ribbonPointPositionArray,\n breakArray: ribbonPointBreakArray,\n colorArray: ribbonPointColorArray\n })\n } else if (line.startsWith('@text')) {\n isText = true\n kinemage.texts.push(line.substr(5))\n } else if (line.startsWith('@caption')) {\n isCaption = true\n kinemage.captions.push(line.substr(8))\n } else if (isDotList) {\n // { CB THR 1 A}sky 'P' 18.915,14.199,5.024\n\n let { label, color, position } = parseListElm(line)\n\n if (label === '\"') {\n label = prevDotLabel\n } else {\n prevDotLabel = label\n }\n\n if (color === undefined) {\n color = dotDefaultColor\n }\n\n dotLabel.push(label)\n dotPosition.push(...position)\n dotColor.push(...color)\n } else if (isVectorList) {\n // { n thr A 1 B13.79 1crnFH} P 17.047, 14.099, 3.625 { n thr A 1 B13.79 1crnFH} L 17.047, 14.099, 3.625\n\n let doubleLine = line.replace(/(?!^){/g, '\\n{')\n let splitLine = doubleLine.split(/\\n/)\n\n for (var i2 = 0; i2 < splitLine.length; i2++) {\n let singlePointLine = splitLine[i2]\n let { label, color, width, position, isLineBreak } = parseListElm(singlePointLine)\n\n if (label === '\"') {\n label = prevVecLabel\n } else {\n prevVecLabel = label\n }\n\n if (color === undefined) {\n color = vecDefaultColor\n }\n\n if (!isLineBreak) {\n if (prevVecPosition !== null) {\n if (width) {\n vecDefaultWidth.push(width)\n }\n\n vecLabel1.push(prevVecLabel)\n vecPosition1.push(...prevVecPosition)\n vecColor1.push(...prevVecColor as number[])\n\n vecLabel2.push(label)\n vecPosition2.push(...position)\n vecColor2.push(...color)\n\n }\n }\n\n prevVecLabel = label\n prevVecPosition = position\n prevVecColor = color\n }\n } else if (isBallList) {\n // {cb arg A 1 1.431 -106.80} r=1.431 39.085, 8.083, 22.182\n\n let { label, radius, color, position } = parseListElm(line)\n\n if (label === '\"') {\n label = prevBallLabel\n } else {\n prevBallLabel = label\n }\n\n if (radius === undefined) {\n radius = 1 // temporary default radius\n }\n\n if (color === undefined) {\n color = ballDefaultColor\n }\n\n ballLabel.push(label)\n ballRadius.push(radius)\n ballPosition.push(...position)\n ballColor.push(...color)\n } else if (isRibbonList) {\n let { label, color, position, isTriangleBreak } = parseListElm(line)\n\n if (label === '\"') {\n label = prevRibbonPointLabel\n } else {\n prevRibbonPointLabel = label\n }\n\n if (color === undefined) {\n color = ribbonListDefaultColor\n }\n\n ribbonPointLabelArray.push(label)\n ribbonPointPositionArray.push(...position)\n ribbonPointBreakArray.push(isTriangleBreak)\n ribbonPointColorArray.push(...color)\n } else if (isText) {\n kinemage.texts.push(line)\n } else if (isCaption) {\n kinemage.captions.push(line)\n } else if (line.startsWith('@kinemage')) {\n kinemage.kinemage = parseInt(line.substr(9).trim())\n } else if (line.startsWith('@onewidth')) {\n kinemage.onewidth = true\n } else if (line.startsWith('@1viewid')) {\n kinemage[ '1viewid' ] = parseStr(line)\n } else if (line.startsWith('@pdbfile')) {\n kinemage.pdbfile = parseStr(line)\n } else if (line.startsWith('@group')) {\n let { groupName, groupFlags, groupMasters } = parseGroup(line)\n if (!kinemage.groupDict[ groupName as string ]) {\n kinemage.groupDict[ groupName as string ] = {\n dominant: false,\n animate: false\n }\n currentGroupMasters = groupMasters\n }\n\n if (currentGroupMasters) {\n currentGroupMasters.forEach(function (master) {\n if (!kinemage.masterDict[ master ]) {\n kinemage.masterDict[ master ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n\n for (let key in groupFlags as {[k: string]: boolean}) {\n kinemage.groupDict[ groupName as string ][ key ] = (groupFlags as {[k: string]: boolean})[ key ]\n }\n } else if (line.startsWith('@subgroup')) {\n const { groupName, groupFlags, groupMasters } = parseGroup(line)\n\n if (!kinemage.subgroupDict[ groupName as string ]) {\n kinemage.subgroupDict[ groupName as string ] = {\n dominant: false,\n animate: false\n }\n currentSubgroupMasters = groupMasters\n }\n\n if (currentSubgroupMasters) {\n currentSubgroupMasters.forEach(function (master) {\n if (!kinemage.masterDict[ master ]) {\n kinemage.masterDict[ master ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n\n for (let key in groupFlags as {[k: string]: boolean}) {\n kinemage.subgroupDict[ groupName as string ][ key ] = (groupFlags as {[k: string]: boolean})[ key ]\n }\n } else if (line.startsWith('@master')) {\n const name = parseStr(line)\n const flag = parseFlag(line)\n\n if (!kinemage.masterDict[ name ]) {\n kinemage.masterDict[ name ] = {\n indent: false,\n visible: false\n }\n }\n\n if (flag === 'on') {\n kinemage.masterDict[ name ].visible = true\n } else if (flag === 'off') {\n kinemage.masterDict[ name ].visible = false\n } else if (flag === 'indent') {\n kinemage.masterDict[ name ].indent = true\n } else if (!flag) {\n // nothing to do\n }\n } else if (line.startsWith('@pointmaster')) {\n const { groupName, groupFlags } = parseGroup(line)\n\n kinemage.pointmasterDict[ groupName as string] = {\n id: Object.keys(groupFlags as {[k: string]: boolean})[ 0 ].replace(reTrimQuotes, '')\n }\n } else {\n console.log(line)\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n kinemage.text = kinemage.texts.join('\\n').trim()\n kinemage.caption = kinemage.captions.join('\\n').trim()\n if (kinemage.ribbonLists) {\n let convertedLists: RibbonObject[] = []\n kinemage.ribbonLists.forEach(function (listObject) {\n convertedLists.push(removePointBreaksTriangleArrays(convertKinTriangleArrays(listObject)))\n })\n kinemage.ribbonLists = convertedLists\n }\n\n if (Debug) Log.timeEnd(`KinParser._parse ${this.name}`)\n }\n}\n\nParserRegistry.add('kin', KinParser)\n\nexport default KinParser\n","/**\n * @file Surface Parser\n * @author Alexander Rose \n * @private\n */\n\nimport Parser, { ParserParameters } from './parser'\nimport Surface from '../surface/surface'\nimport Streamer from '../streamer/streamer';\n\nclass SurfaceParser extends Parser {\n constructor (streamer: Streamer, params?:Partial) {\n super(streamer, params)\n\n this.loader = this.getLoader()\n this.surface = new Surface(this.name, this.path)\n }\n\n get type () { return 'surface' }\n get __objName () { return 'surface' }\n\n _parse () {\n var geometry = this.loader.parse(this.streamer.asText())\n\n this.surface.fromGeometry(geometry)\n }\n}\n\nexport default SurfaceParser\n","/**\n * @file Obj Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { BufferGeometry, BufferAttribute } from 'three'\n\nimport { ParserRegistry } from '../globals'\nimport SurfaceParser from './surface-parser'\n\nexport interface _OBJLoader {\n regexp: {[k: string]: RegExp}\n}\n\ninterface _OBJLoaderConstructor {\n (this: _OBJLoader): void\n new(): _OBJLoader\n}\n\ninterface ObjectType {\n name: string,\n fromDeclaration: boolean,\n geometry: {\n vertices: number[],\n normals: number[],\n type?: string\n }\n}\n/**\n * OBJLoader\n * @class\n * @private\n * @author mrdoob / http://mrdoob.com/\n */\nconst OBJLoader = (function OBJLoader (this: _OBJLoader) {\n this.regexp = {\n // v float float float\n vertex_pattern: /^v\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)/,\n // vn float float float\n normal_pattern: /^vn\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)/,\n // vt float float\n uv_pattern: /^vt\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)/,\n // f vertex vertex vertex\n face_vertex: /^f\\s+(-?\\d+)\\s+(-?\\d+)\\s+(-?\\d+)(?:\\s+(-?\\d+))?/,\n // f vertex/uv vertex/uv vertex/uv\n face_vertex_uv: /^f\\s+(-?\\d+)\\/(-?\\d+)\\s+(-?\\d+)\\/(-?\\d+)\\s+(-?\\d+)\\/(-?\\d+)(?:\\s+(-?\\d+)\\/(-?\\d+))?/,\n // f vertex/uv/normal vertex/uv/normal vertex/uv/normal\n face_vertex_uv_normal: /^f\\s+(-?\\d+)\\/(-?\\d+)\\/(-?\\d+)\\s+(-?\\d+)\\/(-?\\d+)\\/(-?\\d+)\\s+(-?\\d+)\\/(-?\\d+)\\/(-?\\d+)(?:\\s+(-?\\d+)\\/(-?\\d+)\\/(-?\\d+))?/,\n // f vertex//normal vertex//normal vertex//normal\n face_vertex_normal: /^f\\s+(-?\\d+)\\/\\/(-?\\d+)\\s+(-?\\d+)\\/\\/(-?\\d+)\\s+(-?\\d+)\\/\\/(-?\\d+)(?:\\s+(-?\\d+)\\/\\/(-?\\d+))?/,\n // o object_name | g group_name\n object_pattern: /^[og]\\s*(.+)?/,\n // s boolean\n smoothing_pattern: /^s\\s+(\\d+|on|off)/,\n // mtllib file_reference\n material_library_pattern: /^mtllib /,\n // usemtl material_name\n material_use_pattern: /^usemtl /\n }\n}) as _OBJLoaderConstructor\n\nOBJLoader.prototype = {\n\n constructor: OBJLoader,\n\n setPath: function (value: string) {\n this.path = value\n },\n\n _createParserState: function () {\n var state = {\n objects: [] as ObjectType[],\n object: {} as ObjectType,\n\n vertices: [],\n normals: [],\n\n startObject: function (name: string, fromDeclaration: boolean) {\n // If the current object (initial from reset) is not from a g/o declaration in the parsed\n // file. We need to use it for the first parsed g/o to keep things in sync.\n if (this.object && this.object.fromDeclaration === false) {\n this.object.name = name\n this.object.fromDeclaration = (fromDeclaration !== false)\n return\n }\n\n this.object = {\n name: name || '',\n geometry: {\n vertices: [],\n normals: []\n },\n fromDeclaration: (fromDeclaration !== false)\n }\n\n this.objects.push(this.object)\n },\n\n parseVertexIndex: function (value: string, len: number) {\n var index = parseInt(value, 10)\n return (index >= 0 ? index - 1 : index + len / 3) * 3\n },\n\n parseNormalIndex: function (value: string, len: number) {\n var index = parseInt(value, 10)\n return (index >= 0 ? index - 1 : index + len / 3) * 3\n },\n\n addVertex: function (a: number, b: number, c: number) {\n var src = this.vertices\n var dst = this.object.geometry.vertices\n\n dst.push(src[ a + 0 ])\n dst.push(src[ a + 1 ])\n dst.push(src[ a + 2 ])\n dst.push(src[ b + 0 ])\n dst.push(src[ b + 1 ])\n dst.push(src[ b + 2 ])\n dst.push(src[ c + 0 ])\n dst.push(src[ c + 1 ])\n dst.push(src[ c + 2 ])\n },\n\n addVertexLine: function (a: number) {\n var src = this.vertices\n var dst = this.object.geometry.vertices\n\n dst.push(src[ a + 0 ])\n dst.push(src[ a + 1 ])\n dst.push(src[ a + 2 ])\n },\n\n addNormal: function (a: number, b: number, c: number) {\n var src = this.normals\n var dst = this.object.geometry.normals\n\n dst.push(src[ a + 0 ])\n dst.push(src[ a + 1 ])\n dst.push(src[ a + 2 ])\n dst.push(src[ b + 0 ])\n dst.push(src[ b + 1 ])\n dst.push(src[ b + 2 ])\n dst.push(src[ c + 0 ])\n dst.push(src[ c + 1 ])\n dst.push(src[ c + 2 ])\n },\n\n addFace: function (a: string, b: string, c: string, d?: string, na?: string, nb?: string, nc?: string, nd?: string) {\n var vLen = this.vertices.length\n\n var ia = this.parseVertexIndex(a, vLen)\n var ib = this.parseVertexIndex(b, vLen)\n var ic = this.parseVertexIndex(c, vLen)\n var id\n\n if (d === undefined) {\n this.addVertex(ia, ib, ic)\n } else {\n id = this.parseVertexIndex(d, vLen)\n\n this.addVertex(ia, ib, id)\n this.addVertex(ib, ic, id)\n }\n\n if (na !== undefined) {\n // Normals are many times the same. If so, skip function call and parseInt.\n var nLen = this.normals.length\n ia = this.parseNormalIndex(na, nLen)\n\n ib = na === nb ? ia : this.parseNormalIndex(nb!, nLen)\n ic = na === nc ? ia : this.parseNormalIndex(nc!, nLen)\n\n if (d === undefined) {\n this.addNormal(ia, ib, ic)\n } else {\n id = this.parseNormalIndex(nd!, nLen)\n\n this.addNormal(ia, ib, id)\n this.addNormal(ib, ic, id)\n }\n }\n },\n\n addLineGeometry: function (vertices: string[]) {\n this.object.geometry.type = 'Line'\n\n var vLen = this.vertices.length\n\n for (var vi = 0, l = vertices.length; vi < l; vi++) {\n this.addVertexLine(this.parseVertexIndex(vertices[ vi ], vLen))\n }\n }\n\n }\n\n state.startObject('', false)\n\n return state\n },\n\n parse: function (text: string) {\n var state = this._createParserState()\n\n if (text.indexOf('\\r\\n') !== -1) {\n // This is faster than String.split with regex that splits on both\n text = text.replace(/\\r\\n/g, '\\n')\n }\n\n if (text.indexOf('\\\\\\n') !== -1) {\n // join lines separated by a line continuation character (\\)\n text = text.replace(/\\\\\\n/g, '')\n }\n\n var i, l\n var lines = text.split('\\n')\n var line = ''\n var lineFirstChar = ''\n var lineSecondChar = ''\n var lineLength = 0\n var result = []\n\n // Faster to just trim left side of the line. Use if available.\n var trimLeft = (typeof ''.trimLeft === 'function')\n\n for (i = 0, l = lines.length; i < l; i++) {\n line = lines[ i ]\n\n line = trimLeft ? line.trimLeft() : line.trim()\n\n lineLength = line.length\n\n if (lineLength === 0) continue\n\n lineFirstChar = line.charAt(0)\n\n // @todo invoke passed in handler if any\n if (lineFirstChar === '#') continue\n\n if (lineFirstChar === 'v') {\n lineSecondChar = line.charAt(1)\n\n if (lineSecondChar === ' ' && (result = this.regexp.vertex_pattern.exec(line)) !== null) {\n // 0 1 2 3\n // [\"v 1.0 2.0 3.0\", \"1.0\", \"2.0\", \"3.0\"]\n\n state.vertices.push(\n parseFloat(result[ 1 ]),\n parseFloat(result[ 2 ]),\n parseFloat(result[ 3 ])\n )\n } else if (lineSecondChar === 'n' && (result = this.regexp.normal_pattern.exec(line)) !== null) {\n // 0 1 2 3\n // [\"vn 1.0 2.0 3.0\", \"1.0\", \"2.0\", \"3.0\"]\n\n state.normals.push(\n parseFloat(result[ 1 ]),\n parseFloat(result[ 2 ]),\n parseFloat(result[ 3 ])\n )\n } else if (lineSecondChar === 't' && this.regexp.uv_pattern.exec(line) !== null) {\n\n // ignore uv line\n\n } else {\n throw new Error(\"Unexpected vertex/normal/uv line: '\" + line + \"'\")\n }\n } else if (lineFirstChar === 'f') {\n if ((result = this.regexp.face_vertex_uv_normal.exec(line)) !== null) {\n // f vertex/uv/normal vertex/uv/normal vertex/uv/normal\n // 0 1 2 3 4 5 6 7 8 9 10 11 12\n // [\"f 1/1/1 2/2/2 3/3/3\", \"1\", \"1\", \"1\", \"2\", \"2\", \"2\", \"3\", \"3\", \"3\", undefined, undefined, undefined]\n\n state.addFace(\n result[ 1 ], result[ 4 ], result[ 7 ], result[ 10 ],\n // result[ 2 ], result[ 5 ], result[ 8 ], result[ 11 ], // ignore uv part\n result[ 3 ], result[ 6 ], result[ 9 ], result[ 12 ]\n )\n } else if (this.regexp.face_vertex_uv.exec(line) !== null) {\n\n // ignore uv line\n\n } else if ((result = this.regexp.face_vertex_normal.exec(line)) !== null) {\n // f vertex//normal vertex//normal vertex//normal\n // 0 1 2 3 4 5 6 7 8\n // [\"f 1//1 2//2 3//3\", \"1\", \"1\", \"2\", \"2\", \"3\", \"3\", undefined, undefined]\n\n state.addFace(\n result[ 1 ], result[ 3 ], result[ 5 ], result[ 7 ],\n result[ 2 ], result[ 4 ], result[ 6 ], result[ 8 ]\n )\n } else if ((result = this.regexp.face_vertex.exec(line)) !== null) {\n // f vertex vertex vertex\n // 0 1 2 3 4\n // [\"f 1 2 3\", \"1\", \"2\", \"3\", undefined]\n\n state.addFace(\n result[ 1 ], result[ 2 ], result[ 3 ], result[ 4 ]\n )\n } else {\n throw new Error(\"Unexpected face line: '\" + line + \"'\")\n }\n } else if (lineFirstChar === 'l') {\n var lineParts = line.substring(1).trim().split(' ')\n var lineVertices = []\n var lineUVs = []\n\n if (line.indexOf('/') === -1) {\n lineVertices = lineParts\n } else {\n for (var li = 0, llen = lineParts.length; li < llen; li++) {\n var parts = lineParts[ li ].split('/')\n\n if (parts[ 0 ] !== '') lineVertices.push(parts[ 0 ])\n if (parts[ 1 ] !== '') lineUVs.push(parts[ 1 ])\n }\n }\n state.addLineGeometry(lineVertices, lineUVs)\n } else if ((result = this.regexp.object_pattern.exec(line)) !== null) {\n // o object_name\n // or\n // g group_name\n\n var name = result[ 0 ].substr(1).trim()\n state.startObject(name)\n\n // ignore material related lines\n // eslint-disable-next-line no-empty\n } else if (this.regexp.material_use_pattern.test(line)) {\n // eslint-disable-next-line no-empty\n } else if (this.regexp.material_library_pattern.test(line)) {\n // eslint-disable-next-line no-empty\n } else if (this.regexp.smoothing_pattern.exec(line) !== null) {\n } else {\n // Handle null terminated files without exception\n if (line === '\\0') continue\n\n throw new Error(\"Unexpected line: '\" + line + \"'\")\n }\n }\n\n var container = []\n\n for (i = 0, l = state.objects.length; i < l; i++) {\n var object = state.objects[ i ]\n var geometry = object.geometry\n\n // Skip o/g line declarations that did not follow with any faces\n if (geometry.vertices.length === 0) continue\n\n var buffergeometry = new BufferGeometry()\n\n buffergeometry.setAttribute('position', new BufferAttribute(new Float32Array(geometry.vertices), 3))\n\n if (geometry.normals.length > 0) {\n buffergeometry.setAttribute('normal', new BufferAttribute(new Float32Array(geometry.normals), 3))\n } else {\n buffergeometry.computeVertexNormals()\n }\n\n container.push(buffergeometry)\n }\n\n return container\n }\n\n}\n\nclass ObjParser extends SurfaceParser {\n get type () { return 'obj' }\n\n getLoader () {\n return new OBJLoader()\n }\n}\n\nParserRegistry.add('obj', ObjParser)\n\nexport default ObjParser\n","/**\n * @file Ply Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Geometry, Vector3, Face3, Color } from 'three'\n\nimport { ParserRegistry } from '../globals'\nimport SurfaceParser from './surface-parser'\n\n/**\n * PLYLoader\n * @class\n * @private\n * @author Wei Meng / http://about.me/menway\n *\n * @description\n * A THREE loader for PLY ASCII files (known as the Polygon File Format or the Stanford Triangle Format).\n *\n * Limitations: ASCII decoding assumes file is UTF-8.\n *\n * @example\n * var loader = new THREE.PLYLoader();\n * loader.load('./models/ply/ascii/dolphins.ply', function (geometry) {\n * scene.add( new THREE.Mesh( geometry ) );\n * } );\n *\n * // If the PLY file uses non standard property names, they can be mapped while\n * // loading. For example, the following maps the properties\n * // “diffuse_(red|green|blue)” in the file to standard color names.\n *\n * loader.setPropertyNameMapping( {\n * diffuse_red: 'red',\n * diffuse_green: 'green',\n * diffuse_blue: 'blue'\n * } );\n *\n */\n\nexport interface _PLYLoader {\n propertyNameMapping: {[k: string]: string}\n}\n\ninterface _PLYLoaderConstructor {\n (this: _PLYLoader): void\n new(): _PLYLoader\n}\n\ninterface PLYProperty {\n type: string,\n name: string,\n countType: string,\n itemType: string\n}\n\ninterface PLYElement {\n name: string,\n count: number,\n properties: PLYProperty[],\n x: number,\n y: number,\n z: number,\n red: number,\n green: number,\n blue: number,\n [k:string]: any\n}\n\ninterface PLYHeader {\n format: string,\n version: string,\n comments: string[],\n elements: PLYElement[],\n headerLength: number\n}\n\ninterface GeometryPLY extends Geometry {\n useColor: boolean\n}\n\nconst PLYLoader = (function PLYLoader (this: _PLYLoader) {\n this.propertyNameMapping = {}\n}) as _PLYLoaderConstructor\n\nPLYLoader.prototype = {\n\n constructor: PLYLoader,\n\n setPropertyNameMapping: function (mapping: {[k: string]: string}) {\n this.propertyNameMapping = mapping\n },\n\n bin2str: function (buf: ArrayBuffer) {\n var arrayBuffer = new Uint8Array(buf)\n var str = ''\n for (var i = 0; i < buf.byteLength; i++) {\n str += String.fromCharCode(arrayBuffer[ i ]) // implicitly assumes little-endian\n }\n\n return str\n },\n\n isASCII: function (data: ArrayBuffer) {\n var header = this.parseHeader(this.bin2str(data))\n\n return header.format === 'ascii'\n },\n\n parse: function (data: string|ArrayBuffer) {\n if (data instanceof ArrayBuffer) {\n return (\n this.isASCII(data)\n ? this.parseASCII(this.bin2str(data))\n : this.parseBinary(data)\n )\n } else {\n return this.parseASCII(data)\n }\n },\n\n parseHeader: function (data: string) {\n var patternHeader = /ply([\\s\\S]*)end_header\\s/\n var headerText = ''\n var headerLength = 0\n var result = patternHeader.exec(data)\n if (result !== null) {\n headerText = result[ 1 ]\n headerLength = result[ 0 ].length\n }\n\n var header: Partial = {\n comments: [],\n elements: [],\n headerLength: headerLength\n }\n\n var lines = headerText.split('\\n')\n var currentElement: PLYElement|undefined, lineType, lineValues\n\n function makePlyElementProperty (propertValues: string[], propertyNameMapping: {[k: string]: string}) {\n var property = {\n type: propertValues[ 0 ]\n } as PLYProperty\n\n if (property.type === 'list') {\n property.name = propertValues[ 3 ]\n property.countType = propertValues[ 1 ]\n property.itemType = propertValues[ 2 ]\n } else {\n property.name = propertValues[ 1 ]\n }\n\n if (property.name in propertyNameMapping) {\n property.name = propertyNameMapping[ property.name ]\n }\n\n return property\n }\n\n for (var i = 0; i < lines.length; i++) {\n var line = lines[ i ]\n line = line.trim()\n if (line === '') {\n continue\n }\n lineValues = line.split(/\\s+/)\n lineType = lineValues.shift()\n line = lineValues.join(' ')\n\n switch (lineType) {\n case 'format':\n\n header.format = lineValues[ 0 ]\n header.version = lineValues[ 1 ]\n\n break\n\n case 'comment':\n\n header.comments!.push(line)\n\n break\n\n case 'element':\n\n if (currentElement !== undefined) {\n header.elements!.push(currentElement as PLYElement)\n }\n\n currentElement = {} as PLYElement\n currentElement.name = lineValues[ 0 ]\n currentElement.count = parseInt(lineValues[ 1 ])\n currentElement.properties = []\n\n break\n\n case 'property':\n\n currentElement!.properties.push(makePlyElementProperty(lineValues, this.propertyNameMapping))\n\n break\n\n default:\n\n console.log('unhandled', lineType, lineValues)\n }\n }\n\n if (currentElement !== undefined) {\n header.elements!.push(currentElement)\n }\n\n return header\n },\n\n parseASCIINumber: function (n: string, type: string) {\n switch (type) {\n case 'char': case 'uchar': case 'short': case 'ushort': case 'int': case 'uint':\n case 'int8': case 'uint8': case 'int16': case 'uint16': case 'int32': case 'uint32':\n\n return parseInt(n)\n\n case 'float': case 'double': case 'float32': case 'float64':\n\n return parseFloat(n)\n }\n },\n\n parseASCIIElement: function (properties: PLYProperty[], line: string) {\n var values = line.split(/\\s+/)\n\n var element = {} as PLYElement\n\n for (var i = 0; i < properties.length; i++) {\n if (properties[ i ].type === 'list') {\n var list = []\n var n = this.parseASCIINumber(values.shift(), properties[ i ].countType)\n\n for (var j = 0; j < n; j++) {\n list.push(this.parseASCIINumber(values.shift(), properties[ i ].itemType))\n }\n\n element[ properties[ i ].name ] = list\n } else {\n element[ properties[ i ].name ] = this.parseASCIINumber(values.shift(), properties[ i ].type)\n }\n }\n\n return element\n },\n\n parseASCII: function (data: string) {\n // PLY ascii format specification, as per http://en.wikipedia.org/wiki/PLY_(file_format)\n\n var geometry = new Geometry() as GeometryPLY\n\n var result\n\n var header = this.parseHeader(data)\n\n var patternBody = /end_header\\s([\\s\\S]*)$/\n var body = ''\n if ((result = patternBody.exec(data)) !== null) {\n body = result[ 1 ]\n }\n\n var lines = body.split('\\n')\n var currentElement = 0\n var currentElementCount = 0\n geometry.useColor = false\n\n for (var i = 0; i < lines.length; i++) {\n var line = lines[ i ]\n line = line.trim()\n if (line === '') {\n continue\n }\n\n if (currentElementCount >= header.elements[ currentElement ].count) {\n currentElement++\n currentElementCount = 0\n }\n\n var element = this.parseASCIIElement(header.elements[ currentElement ].properties, line)\n\n this.handleElement(geometry, header.elements[ currentElement ].name, element)\n\n currentElementCount++\n }\n\n return this.postProcess(geometry)\n },\n\n postProcess: function (geometry: GeometryPLY) {\n if (geometry.useColor) {\n for (var i = 0; i < geometry.faces.length; i++) {\n geometry.faces[ i ].vertexColors = [\n geometry.colors[ geometry.faces[ i ].a ],\n geometry.colors[ geometry.faces[ i ].b ],\n geometry.colors[ geometry.faces[ i ].c ]\n ]\n }\n\n geometry.elementsNeedUpdate = true\n }\n\n geometry.computeBoundingSphere()\n\n return geometry\n },\n\n handleElement: function (geometry: GeometryPLY, elementName: string, element: PLYElement) {\n if (elementName === 'vertex') {\n geometry.vertices.push(\n new Vector3(element.x, element.y, element.z)\n )\n\n if ('red' in element && 'green' in element && 'blue' in element) {\n geometry.useColor = true\n\n var color = new Color()\n color.setRGB(element.red / 255.0, element.green / 255.0, element.blue / 255.0)\n geometry.colors.push(color)\n }\n } else if (elementName === 'face') {\n var vertexIndices = element.vertex_indices\n\n if (vertexIndices.length === 3) {\n geometry.faces.push(\n new Face3(vertexIndices[ 0 ], vertexIndices[ 1 ], vertexIndices[ 2 ])\n )\n } else if (vertexIndices.length === 4) {\n geometry.faces.push(\n new Face3(vertexIndices[ 0 ], vertexIndices[ 1 ], vertexIndices[ 3 ]),\n new Face3(vertexIndices[ 1 ], vertexIndices[ 2 ], vertexIndices[ 3 ])\n )\n }\n }\n },\n\n binaryRead: function (dataview: DataView, at: number, type: string, littleEndian: boolean) {\n switch (type) {\n // corespondences for non-specific length types here match rply:\n case 'int8': case 'char': return [ dataview.getInt8(at), 1 ]\n\n case 'uint8': case 'uchar': return [ dataview.getUint8(at), 1 ]\n\n case 'int16': case 'short': return [ dataview.getInt16(at, littleEndian), 2 ]\n\n case 'uint16': case 'ushort': return [ dataview.getUint16(at, littleEndian), 2 ]\n\n case 'int32': case 'int': return [ dataview.getInt32(at, littleEndian), 4 ]\n\n case 'uint32': case 'uint': return [ dataview.getUint32(at, littleEndian), 4 ]\n\n case 'float32': case 'float': return [ dataview.getFloat32(at, littleEndian), 4 ]\n\n case 'float64': case 'double': return [ dataview.getFloat64(at, littleEndian), 8 ]\n }\n },\n\n binaryReadElement: function (dataview: DataView, at: number, properties: PLYProperty[], littleEndian: boolean) {\n var element = {} as PLYElement\n var result\n var read = 0\n\n for (var i = 0; i < properties.length; i++) {\n if (properties[ i ].type === 'list') {\n var list = []\n\n result = this.binaryRead(dataview, at + read, properties[ i ].countType, littleEndian)\n var n = result[ 0 ]\n read += result[ 1 ]\n\n for (var j = 0; j < n; j++) {\n result = this.binaryRead(dataview, at + read, properties[ i ].itemType, littleEndian)\n list.push(result[ 0 ])\n read += result[ 1 ]\n }\n\n element[ properties[ i ].name ] = list\n } else {\n result = this.binaryRead(dataview, at + read, properties[ i ].type, littleEndian)\n element[ properties[ i ].name ] = result[ 0 ]\n read += result[ 1 ]\n }\n }\n\n return [ element, read ]\n },\n\n parseBinary: function (data: ArrayBuffer) {\n var geometry = new Geometry()\n\n var header = this.parseHeader(this.bin2str(data))\n var littleEndian = (header.format === 'binary_little_endian')\n var body = new DataView(data, header.headerLength)\n var result\n var loc = 0\n\n for (var currentElement = 0; currentElement < header.elements.length; currentElement++) {\n for (var currentElementCount = 0; currentElementCount < header.elements[ currentElement ].count; currentElementCount++) {\n result = this.binaryReadElement(body, loc, header.elements[ currentElement ].properties, littleEndian)\n loc += result[ 1 ]\n var element = result[ 0 ]\n\n this.handleElement(geometry, header.elements[ currentElement ].name, element)\n }\n }\n\n return this.postProcess(geometry)\n }\n\n}\n\nclass PlyParser extends SurfaceParser {\n get type () { return 'ply' }\n\n getLoader () {\n return new PLYLoader()\n }\n}\n\nParserRegistry.add('ply', PlyParser)\n\nexport default PlyParser\n","/**\n * @file Csv Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { ParserRegistry } from '../globals'\nimport Parser, { ParserParameters } from './parser'\nimport Streamer from '../streamer/streamer';\n\nexport interface CsvParserParameters extends ParserParameters {\n delimiter: string\n comment: string\n columnNames: boolean\n}\n/**\n * CSV parser\n */\nclass CsvParser extends Parser {\n /**\n * [constructor description]\n * @param {Streamer} streamer - the streamer object\n * @param {Object} params - parameter object\n * @param {Char} params.delimiter - delimiter character\n * @param {Char} params.comment - comment character\n * @param {Boolean} params.columnNames - use first data line as column names\n */\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.delimiter = defaults(p.delimiter, ',')\n this.comment = defaults(p.comment, '#')\n this.columnNames = defaults(p.columnNames, false)\n\n this.table = {\n name: this.name,\n path: this.path,\n columnNames: [],\n data: []\n }\n }\n\n get type () { return 'csv' }\n get __objName () { return 'table' }\n\n _parse () {\n const data = this.table.data\n const reDelimiter = new RegExp('\\\\s*' + this.delimiter + '\\\\s*')\n\n let j = 0\n\n this.streamer.eachChunkOfLines(chunk => {\n const n = chunk.length\n\n for (let i = 0; i < n; ++i) {\n const line = chunk[ i ].trim()\n if (line.startsWith(this.comment)) continue\n const values = line.split(reDelimiter)\n\n if (j === 0) {\n this.table.columnNames = values\n } else if (line) {\n data.push(values)\n }\n ++j\n }\n })\n }\n}\n\nParserRegistry.add('csv', CsvParser)\n\nexport default CsvParser\n","/**\n * @file Json Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Parser, { ParserParameters } from './parser'\nimport Streamer from '../streamer/streamer';\n\nexport interface JsonParserParameters extends ParserParameters {\n string: boolean\n}\n\nclass JsonParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.string = defaults(p.string, false)\n\n this.json = {\n name: this.name,\n path: this.path,\n data: {}\n }\n }\n\n get type () { return 'json' }\n get __objName () { return 'json' }\n get isJson () { return true }\n\n _parse () {\n if (this.streamer.isBinary() || this.string) {\n this.json.data = JSON.parse(this.streamer.asText())\n } else {\n this.json.data = this.streamer.data\n }\n }\n}\n\nParserRegistry.add('json', JsonParser)\n\nexport default JsonParser\n","/**\n * @file Msgpack Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport Parser, { ParserParameters } from './parser'\n\nimport { decodeMsgpack } from '../../lib/mmtf.es6'\nimport Streamer from '../streamer/streamer';\n\nclass MsgpackParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.msgpack = {\n name: this.name,\n path: this.path,\n data: undefined\n }\n }\n\n get type () { return 'msgpack' }\n get __objName () { return 'msgpack' }\n get isBinary () { return true }\n\n _parse () {\n if (Debug) Log.time('MsgpackParser._parse ' + this.name)\n\n this.msgpack.data = decodeMsgpack(this.streamer.data)\n\n if (Debug) Log.timeEnd('MsgpackParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('msgpack', MsgpackParser)\n\nexport default MsgpackParser\n","/**\n * @file Netcdf Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport Parser, { ParserParameters } from './parser'\nimport NetcdfReader from '../utils/netcdf-reader'\nimport Streamer from '../streamer/streamer';\n\nclass NetcdfParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.netcdf = {\n name: this.name,\n path: this.path,\n data: undefined\n }\n }\n\n get type () { return 'netcdf' }\n get __objName () { return 'netcdf' }\n get isBinary () { return true }\n\n _parse () {\n if (Debug) Log.time('NetcdfParser._parse ' + this.name)\n\n this.netcdf.data = new NetcdfReader(this.streamer.data)\n\n if (Debug) Log.timeEnd('NetcdfParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('netcdf', NetcdfParser)\n\nexport default NetcdfParser\n","/**\n * @file Text Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport Parser, { ParserParameters } from './parser'\nimport Streamer from '../streamer/streamer';\n\nclass TextParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n super(streamer, params)\n\n this.text = {\n\n name: this.name,\n path: this.path,\n data: ''\n\n }\n }\n\n get type () { return 'text' }\n get __objName () { return 'text' }\n\n _parse () {\n this.text.data = this.streamer.asText()\n }\n}\n\nParserRegistry.add('txt', TextParser)\nParserRegistry.add('text', TextParser)\n\nexport default TextParser\n","/**\n * @file Parse Xml\n * @author Alexander Rose \n * @private\n */\n\n// https://github.com/segmentio/xml-parser\n// MIT license\n\nexport type XMLNodeAttributes = { [k: string]: any }\nexport interface XMLNode {\n name?: string\n content?: string\n attributes: XMLNodeAttributes\n children?: XMLNode[]\n}\n\nconst reStrip = /^['\"]|['\"]$/g\nconst reTag = /^<([\\w-:.]+)\\s*/\nconst reContent = /^([^<]*)/\nconst reAttr = /([\\w:-]+)\\s*=\\s*(\"[^\"]*\"|'[^']*'|\\w+)\\s*/\n\nfunction strip (val: string) {\n return val.replace(reStrip, '')\n}\n\nexport function parseXml (xml: string) {\n // trim and strip comments\n xml = xml.trim().replace(//g, '')\n\n return document()\n\n function document () {\n return {\n declaration: declaration(),\n root: tag()\n }\n }\n\n function declaration () {\n const m = match(/^<\\?xml\\s*/)\n if (!m) return\n\n // tag\n const node: XMLNode = {\n attributes: {}\n }\n\n // attributes\n while (!(eos() || is('?>'))) {\n const attr = attribute()\n if (!attr) return node\n node.attributes[attr.name] = attr.value\n }\n match(/\\?>\\s*/)\n return node\n }\n\n function tag () {\n const m = match(reTag)\n if (!m) return\n\n // name\n const node: XMLNode = {\n name: m[1],\n attributes: {},\n children: []\n }\n\n // attributes\n while (!(eos() || is('>') || is('?>') || is('/>'))) {\n const attr = attribute()\n if (!attr) return node\n node.attributes[attr.name] = attr.value\n }\n\n // self closing tag\n if (match(/^\\s*\\/>\\s*/)) {\n return node\n }\n match(/\\??>\\s*/)\n\n // content\n node.content = content()\n\n // children\n let child\n while ((child = tag())) {\n node.children!.push(child)\n }\n\n // closing\n match(/^<\\/[\\w-:.]+>\\s*/)\n return node\n }\n\n function content () {\n const m = match(reContent)\n if (m) return m[1]\n return ''\n }\n\n function attribute () {\n const m = match(reAttr)\n if (!m) return\n return { name: m[1], value: strip(m[2]) }\n }\n\n function match (re: RegExp) {\n const m = xml.match(re)\n if (!m) return\n xml = xml.slice(m[0].length)\n return m\n }\n\n function eos () {\n return xml.length === 0\n }\n\n function is (prefix: string) {\n return xml.indexOf(prefix) === 0\n }\n}\n","/**\n * @file Xml Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { defaults } from '../utils'\n// @ts-ignore: unused import XMLNode required for declaration only\nimport { parseXml, XMLNode } from '../utils/parse-xml'\nimport Parser, { ParserParameters } from './parser'\nimport Streamer from '../streamer/streamer';\n\nexport interface XmlParserParameters extends ParserParameters {\n useDomParser: boolean\n}\n\nclass XmlParser extends Parser {\n xml: {\n name: string\n path: string\n data: any\n }\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.useDomParser = defaults(p.useDomParser, false)\n\n this.xml = {\n name: this.name,\n path: this.path,\n data: {}\n }\n }\n\n get type () { return 'xml' }\n get __objName () { return 'xml' }\n get isXml () { return true }\n\n __xmlParser (xml: string) {\n return parseXml(xml)\n }\n\n __domParser (xml: string) {\n const domParser = new (window as any).DOMParser() as DOMParser\n return domParser.parseFromString(xml, 'text/xml')\n }\n\n _parse () {\n if (Debug) Log.time('XmlParser._parse ' + this.name)\n\n if (this.useDomParser) {\n if (this.streamer.data instanceof Document) { //TS conversion: stripped the window prefix from window.Document\n this.xml.data = this.streamer.data\n } else {\n this.xml.data = this.__domParser(this.streamer.asText())\n }\n } else {\n this.xml.data = this.__xmlParser(this.streamer.asText())\n }\n\n if (Debug) Log.timeEnd('XmlParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('xml', XmlParser)\n\nexport default XmlParser\n","/**\n * @file Validation\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Color } from 'three'\n\nimport { Debug, Log } from '../globals'\nimport { defaults } from '../utils'\nimport { ClashPicker } from '../utils/picker'\nimport { uniformArray3 } from '../math/array-utils'\nimport { guessElement } from '../structure/structure-utils'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Structure from '../structure/structure'\n\nfunction getNamedItem(a: NamedNodeMap, name: string) {\n const item = a.getNamedItem(name)\n return item !== null ? item.value : ''\n}\n\nfunction getSele (a: NamedNodeMap, atomname?: string, useAltcode = false) {\n const icode = getNamedItem(a, 'icode').trim()\n const chain = getNamedItem(a, 'chain').trim()\n const altcode = getNamedItem(a, 'altcode')\n let sele = getNamedItem(a, 'resnum')\n if (icode) sele += '^' + icode\n if (chain) sele += ':' + chain\n if (atomname) sele += '.' + atomname\n if (useAltcode && altcode.trim()) sele += '%' + altcode\n sele += '/' + (parseInt(getNamedItem(a, 'model')) - 1)\n return sele\n}\n\nfunction getResSele (a: NamedNodeMap) {\n const chain = getNamedItem(a, 'chain').trim()\n const rescode = getNamedItem(a, 'rescode')\n const resnum = getNamedItem(a, 'resnum')\n let sele = `[${rescode}]${resnum}`\n if (chain) sele += `:${chain}`\n return sele\n}\n\nfunction setBitDict (dict: { [k: string]: number }, key: string, bit: number) {\n if (dict[ key ] === undefined) {\n dict[ key ] = bit\n } else {\n dict[ key ] |= bit\n }\n}\n\nfunction hasAttrValue (attr: Attr|null, value: string) {\n return attr !== null && attr.value === value\n}\n\nfunction getAtomSele (ap: AtomProxy) {\n const icode = ap.inscode\n const chain = ap.chainname\n const atomname = ap.atomname\n const altcode = ap.altloc\n let sele = ap.resno + ''\n if (icode) sele += '^' + icode\n if (chain) sele += ':' + chain\n if (atomname) sele += '.' + atomname\n if (altcode) sele += '%' + altcode\n sele += '/' + ap.modelIndex\n return sele\n}\n\nfunction getProblemCount (clashDict: { [k: string]: { [k: string]: string } }, g: Element, ga: NamedNodeMap) {\n let geoProblemCount = 0\n\n const clashes = g.getElementsByTagName('clash')\n for (let j = 0, jl = clashes.length; j < jl; ++j) {\n if (clashDict[ getNamedItem(clashes[ j ].attributes, 'cid') ]) {\n geoProblemCount += 1\n break\n }\n }\n\n const angleOutliers = g.getElementsByTagName('angle-outlier')\n if (angleOutliers.length > 0) {\n geoProblemCount += 1\n }\n\n const bondOutliers = g.getElementsByTagName('bond-outlier')\n if (bondOutliers.length > 0) {\n geoProblemCount += 1\n }\n\n const planeOutliers = g.getElementsByTagName('plane-outlier')\n if (planeOutliers.length > 0) {\n geoProblemCount += 1\n }\n\n if (hasAttrValue(ga.getNamedItem('rota'), 'OUTLIER')) {\n geoProblemCount += 1\n }\n\n if (hasAttrValue(ga.getNamedItem('rama'), 'OUTLIER')) {\n geoProblemCount += 1\n }\n\n if (hasAttrValue(ga.getNamedItem('RNApucker'), 'outlier')) {\n geoProblemCount += 1\n }\n\n return geoProblemCount\n}\n\nclass Validation {\n rsrzDict: { [k: string]: number } = {}\n rsccDict: { [k: string]: number } = {}\n /**\n * Random Coil Index (RCI) - evaluates the proximity of residue structural\n * and dynamic properties to the properties of flexible random coil regions\n * from NMR chemical shifts.\n *\n * Mark V. Berjanskii and David S. Wishart (2005)\n * A Simple Method To Predict Protein Flexibility Using Secondary Chemical Shifts\n * J. Am. Chem. Soc., 2005, 127 (43), pp 14970–14971\n * http://pubs.acs.org/doi/abs/10.1021/ja054842f\n *\n * Mark V. Berjanskii and David S. Wishart (2008)\n * Application of the random coil index to studying protein flexibility.\n * J Biomol NMR. 2008 Jan;40(1):31-48. Epub 2007 Nov 6.\n * http://www.springerlink.com/content/2966482w10306126/\n */\n rciDict: { [k: string]: number } = {}\n clashDict: { [k: string]: { [k: string]: string } } = {}\n clashArray: { [k: string]: string }[] = []\n geoDict: { [k: string]: number } = {}\n geoAtomDict: { [k: string]: { [k: string]: number } } = {}\n atomDict: { [k: string]: boolean|number } = {}\n clashSele = 'NONE'\n\n constructor (readonly name: string, readonly path: string) {}\n\n get type () { return 'validation' }\n\n fromXml (xml: XMLDocument) {\n if (Debug) Log.time('Validation.fromXml')\n\n const rsrzDict = this.rsrzDict\n const rsccDict = this.rsccDict\n const rciDict = this.rciDict\n const clashDict = this.clashDict\n const clashArray = this.clashArray\n const geoDict = this.geoDict\n const geoAtomDict = this.geoAtomDict\n const atomDict = this.atomDict\n\n const entries = xml.getElementsByTagName('Entry')\n if (entries.length === 1) {\n const chemicalShiftLists = entries[0].getElementsByTagName('chemical_shift_list')\n if (chemicalShiftLists.length === 1) {\n const randomCoilIndices = chemicalShiftLists[0].getElementsByTagName('random_coil_index')\n for (let j = 0, jl = randomCoilIndices.length; j < jl; ++j) {\n const rcia = randomCoilIndices[ j ].attributes\n const sele = getResSele(rcia)\n rciDict[ sele ] = parseFloat(getNamedItem(rcia, 'value'))\n }\n }\n }\n\n const groups = xml.getElementsByTagName('ModelledSubgroup')\n\n const _clashDict: { [k: string]: { [k: string]: string } } = {}\n const clashList: string[] = []\n\n if (Debug) Log.time('Validation.fromXml#clashDict')\n\n for (let i = 0, il = groups.length; i < il; ++i) {\n const g = groups[ i ]\n const ga = g.attributes\n\n const sele = getSele(ga)\n if (ga.getNamedItem('rsrz') !== null) {\n rsrzDict[ sele ] = parseFloat(getNamedItem(ga, 'rsrz'))\n }\n if (ga.getNamedItem('rscc') !== null) {\n rsccDict[ sele ] = parseFloat(getNamedItem(ga, 'rscc'))\n }\n const seleAttr = xml.createAttribute('sele')\n seleAttr.value = sele\n ga.setNamedItem(seleAttr)\n\n const clashes = g.getElementsByTagName('clash')\n\n for (let j = 0, jl = clashes.length; j < jl; ++j) {\n const ca = clashes[ j ].attributes\n const atom = getNamedItem(ca, 'atom')\n\n if (guessElement(atom) !== 'H') {\n const cid = getNamedItem(ca, 'cid')\n const atomSele = getSele(ga, atom, true)\n atomDict[ atomSele ] = true\n\n if (_clashDict[ cid ] === undefined) {\n _clashDict[ cid ] = {\n sele1: atomSele,\n res1: sele\n }\n } else {\n const c = _clashDict[ cid ]\n if (c.res1 !== sele) {\n c.sele2 = atomSele\n c.res2 = sele\n clashList.push(c.res1, sele)\n clashDict[ cid ] = c\n clashArray.push(c)\n }\n }\n }\n }\n }\n\n if (Debug) Log.timeEnd('Validation.fromXml#clashDict')\n\n for (let i = 0, il = groups.length; i < il; ++i) {\n const g = groups[ i ]\n const ga = g.attributes\n\n const sele = getNamedItem(ga, 'sele')\n const isPolymer = getNamedItem(ga, 'seq') !== '.'\n\n if (isPolymer) {\n const geoProblemCount = getProblemCount(clashDict, g, ga)\n if (geoProblemCount > 0) {\n geoDict[ sele ] = geoProblemCount\n }\n } else {\n const clashes = g.getElementsByTagName('clash')\n const mogBondOutliers = g.getElementsByTagName('mog-bond-outlier')\n const mogAngleOutliers = g.getElementsByTagName('mog-angle-outlier')\n\n if (mogBondOutliers.length > 0 || mogAngleOutliers.length > 0 || clashes.length > 0) {\n const atomDict = {}\n geoAtomDict[ sele ] = atomDict\n\n for (let j = 0, jl = clashes.length; j < jl; ++j) {\n const ca = clashes[ j ].attributes\n if (clashDict[ getNamedItem(ca, 'cid') ]) {\n setBitDict(atomDict, getNamedItem(ca, 'atom'), 1)\n }\n }\n\n for (let j = 0, jl = mogBondOutliers.length; j < jl; ++j) {\n const mbo = mogBondOutliers[ j ].attributes\n getNamedItem(mbo, 'atoms').split(',').forEach(function (atomname) {\n setBitDict(atomDict, atomname, 2)\n })\n }\n\n for (let j = 0, jl = mogAngleOutliers.length; j < jl; ++j) {\n const mao = mogAngleOutliers[ j ].attributes\n getNamedItem(mao, 'atoms').split(',').forEach(function (atomname) {\n setBitDict(atomDict, atomname, 4)\n })\n }\n }\n }\n }\n\n this.clashSele = clashList.length ? clashList.join(' OR ') : 'NONE'\n\n if (Debug) Log.timeEnd('Validation.fromXml')\n }\n\n getClashData (params: { color: number|string|Color, structure: Structure }) {\n if (Debug) Log.time('Validation.getClashData')\n\n const p = params || {}\n\n const s = p.structure\n const atomSet = s.atomSet! // TODO\n const c = new Color(defaults(p.color, '#f0027f'))\n\n const ap1 = s.getAtomProxy()\n const ap2 = s.getAtomProxy()\n const vDir = new Vector3()\n const vPos1 = new Vector3()\n const vPos2 = new Vector3()\n\n const clashArray = this.clashArray\n const n = clashArray.length\n\n const position1 = new Float32Array(n * 3)\n const position2 = new Float32Array(n * 3)\n const color = uniformArray3(n, c.r, c.g, c.b) as Float32Array\n const radius = new Float32Array(n)\n const picking = new Float32Array(n)\n\n if (Debug) Log.time('Validation.getClashData#atomDict')\n\n const atomDict = this.atomDict\n\n s.eachAtom(function (ap) {\n const sele = getAtomSele(ap)\n if (atomDict[ sele ] === true) {\n atomDict[ sele ] = ap.index\n }\n })\n\n if (Debug) Log.timeEnd('Validation.getClashData#atomDict')\n\n let i = 0\n\n clashArray.forEach(function (c, idx) {\n ap1.index = atomDict[ c.sele1 ] as number // TODO\n ap2.index = atomDict[ c.sele2 ] as number // TODO\n\n if (ap1.index === undefined || ap2.index === undefined ||\n !atomSet.isSet(ap1.index, ap2.index)) return\n\n vDir.subVectors(ap2 as any, ap1 as any).setLength(ap1.vdw) // TODO\n vPos1.copy(ap1 as any).add(vDir) // TODO\n\n vDir.subVectors(ap1 as any, ap2 as any).setLength(ap2.vdw) // TODO\n vPos2.copy(ap2 as any).add(vDir) // TODO\n\n const dHalf = ap1.distanceTo(ap2) / 2\n const r1 = Math.sqrt(ap1.vdw * ap1.vdw - dHalf * dHalf)\n const r2 = Math.sqrt(ap2.vdw * ap2.vdw - dHalf * dHalf)\n\n vPos1.toArray(position1 as any, i * 3) // TODO\n vPos2.toArray(position2 as any, i * 3)\n radius[ i ] = (r1 + r2) / 2\n picking[ i ] = idx\n\n ++i\n })\n\n if (Debug) Log.timeEnd('Validation.getClashData')\n\n return {\n position1: position1.subarray(0, i * 3),\n position2: position2.subarray(0, i * 3),\n color: color.subarray(0, i * 3),\n color2: color.subarray(0, i * 3),\n radius: radius.subarray(0, i),\n picking: new ClashPicker(picking.subarray(0, i), this, s)\n }\n }\n}\n\nexport default Validation\n","\n// https://github.com/nodeca/pako\n// MIT License, Copyright (c) 2014 by Vitaly Puzrin\n\n\n// 'use strict';\n\n\n// var TYPED_OK = (typeof Uint8Array !== 'undefined') &&\n// (typeof Uint16Array !== 'undefined') &&\n// (typeof Int32Array !== 'undefined');\n\n\nfunction assign(obj /*from1, from2, from3, ...*/) {\n var sources = Array.prototype.slice.call(arguments, 1);\n while (sources.length) {\n var source = sources.shift();\n if (!source) { continue; }\n\n if (typeof source !== 'object') {\n throw new TypeError(source + 'must be non-object');\n }\n\n for (var p in source) {\n if (source.hasOwnProperty(p)) {\n obj[p] = source[p];\n }\n }\n }\n\n return obj;\n}\n\n\n// reduce buffer size, avoiding mem copy\nfunction shrinkBuf(buf, size) {\n if (buf.length === size) { return buf; }\n if (buf.subarray) { return buf.subarray(0, size); }\n buf.length = size;\n return buf;\n}\n\n\nfunction arraySet(dest, src, src_offs, len, dest_offs) {\n if (src.subarray && dest.subarray) {\n dest.set(src.subarray(src_offs, src_offs + len), dest_offs);\n return;\n }\n // Fallback to ordinary array\n for (var i = 0; i < len; i++) {\n dest[dest_offs + i] = src[src_offs + i];\n }\n}\n\n// Join array of chunks to single array.\nfunction flattenChunks(chunks) {\n var i, l, len, pos, chunk, result;\n\n // calculate data length\n len = 0;\n for (i = 0, l = chunks.length; i < l; i++) {\n len += chunks[i].length;\n }\n\n // join chunks\n result = new Uint8Array(len);\n pos = 0;\n for (i = 0, l = chunks.length; i < l; i++) {\n chunk = chunks[i];\n result.set(chunk, pos);\n pos += chunk.length;\n }\n\n return result;\n}\n\n// 'use strict';\n\n// Note: adler32 takes 12% for level 0 and 2% for level 6.\n// It doesn't worth to make additional optimizationa as in original.\n// Small size is preferable.\n\nfunction adler32(adler, buf, len, pos) {\n var s1 = (adler & 0xffff) |0,\n s2 = ((adler >>> 16) & 0xffff) |0,\n n = 0;\n\n while (len !== 0) {\n // Set limit ~ twice less than 5552, to keep\n // s2 in 31-bits, because we force signed ints.\n // in other case %= will fail.\n n = len > 2000 ? 2000 : len;\n len -= n;\n\n do {\n s1 = (s1 + buf[pos++]) |0;\n s2 = (s2 + s1) |0;\n } while (--n);\n\n s1 %= 65521;\n s2 %= 65521;\n }\n\n return (s1 | (s2 << 16)) |0;\n}\n\n// 'use strict';\n\n// Note: we can't get significant speed boost here.\n// So write code to minimize size - no pregenerated tables\n// and array tools dependencies.\n\n\n// Use ordinary array, since untyped makes no boost here\nfunction makeTable() {\n var c, table = [];\n\n for (var n = 0; n < 256; n++) {\n c = n;\n for (var k = 0; k < 8; k++) {\n c = ((c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));\n }\n table[n] = c;\n }\n\n return table;\n}\n\n// Create table on load. Just 255 signed longs. Not a problem.\nvar crcTable = makeTable();\n\n\nfunction crc32(crc, buf, len, pos) {\n var t = crcTable,\n end = pos + len;\n\n crc ^= -1;\n\n for (var i = pos; i < end; i++) {\n crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF];\n }\n\n return (crc ^ (-1)); // >>> 0;\n}\n\n// 'use strict';\n\n// See state defs from inflate.js\nvar BAD$1 = 30; /* got a data error -- remain here until reset */\nvar TYPE$1 = 12; /* i: waiting for type bits, including last-flag bit */\n\n/*\n Decode literal, length, and distance codes and write out the resulting\n literal and match bytes until either not enough input or output is\n available, an end-of-block is encountered, or a data error is encountered.\n When large enough input and output buffers are supplied to inflate(), for\n example, a 16K input buffer and a 64K output buffer, more than 95% of the\n inflate execution time is spent in this routine.\n\n Entry assumptions:\n\n state.mode === LEN\n strm.avail_in >= 6\n strm.avail_out >= 258\n start >= strm.avail_out\n state.bits < 8\n\n On return, state.mode is one of:\n\n LEN -- ran out of enough output space or enough available input\n TYPE -- reached end of block code, inflate() to interpret next block\n BAD -- error in block data\n\n Notes:\n\n - The maximum input bits used by a length/distance pair is 15 bits for the\n length code, 5 bits for the length extra, 15 bits for the distance code,\n and 13 bits for the distance extra. This totals 48 bits, or six bytes.\n Therefore if strm.avail_in >= 6, then there is enough input to avoid\n checking for available input while decoding.\n\n - The maximum bytes that a single length/distance pair can output is 258\n bytes, which is the maximum length that can be coded. inflate_fast()\n requires strm.avail_out >= 258 for each loop to avoid checking for\n output space.\n */\n// module.exports =\nfunction inflate_fast(strm, start) {\n var state;\n var _in; /* local strm.input */\n var last; /* have enough input while in < last */\n var _out; /* local strm.output */\n var beg; /* inflate()'s initial strm.output */\n var end; /* while out < end, enough space available */\n//#ifdef INFLATE_STRICT\n var dmax; /* maximum distance from zlib header */\n//#endif\n var wsize; /* window size or zero if not using window */\n var whave; /* valid bytes in the window */\n var wnext; /* window write index */\n // Use `s_window` instead `window`, avoid conflict with instrumentation tools\n var s_window; /* allocated sliding window, if wsize != 0 */\n var hold; /* local strm.hold */\n var bits; /* local strm.bits */\n var lcode; /* local strm.lencode */\n var dcode; /* local strm.distcode */\n var lmask; /* mask for first level of length codes */\n var dmask; /* mask for first level of distance codes */\n var here; /* retrieved table entry */\n var op; /* code bits, operation, extra bits, or */\n /* window position, window bytes to copy */\n var len; /* match length, unused bytes */\n var dist; /* match distance */\n var from; /* where to copy match from */\n var from_source;\n\n\n var input, output; // JS specific, because we have no pointers\n\n /* copy state to local variables */\n state = strm.state;\n //here = state.here;\n _in = strm.next_in;\n input = strm.input;\n last = _in + (strm.avail_in - 5);\n _out = strm.next_out;\n output = strm.output;\n beg = _out - (start - strm.avail_out);\n end = _out + (strm.avail_out - 257);\n//#ifdef INFLATE_STRICT\n dmax = state.dmax;\n//#endif\n wsize = state.wsize;\n whave = state.whave;\n wnext = state.wnext;\n s_window = state.window;\n hold = state.hold;\n bits = state.bits;\n lcode = state.lencode;\n dcode = state.distcode;\n lmask = (1 << state.lenbits) - 1;\n dmask = (1 << state.distbits) - 1;\n\n\n /* decode literals and length/distances until end-of-block or not enough\n input data or output space */\n\n top:\n do {\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n\n here = lcode[hold & lmask];\n\n dolen:\n for (;;) { // Goto emulation\n op = here >>> 24/*here.bits*/;\n hold >>>= op;\n bits -= op;\n op = (here >>> 16) & 0xff/*here.op*/;\n if (op === 0) { /* literal */\n //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n // \"inflate: literal '%c'\\n\" :\n // \"inflate: literal 0x%02x\\n\", here.val));\n output[_out++] = here & 0xffff/*here.val*/;\n }\n else if (op & 16) { /* length base */\n len = here & 0xffff/*here.val*/;\n op &= 15; /* number of extra bits */\n if (op) {\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n len += hold & ((1 << op) - 1);\n hold >>>= op;\n bits -= op;\n }\n //Tracevv((stderr, \"inflate: length %u\\n\", len));\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n here = dcode[hold & dmask];\n\n dodist:\n for (;;) { // goto emulation\n op = here >>> 24/*here.bits*/;\n hold >>>= op;\n bits -= op;\n op = (here >>> 16) & 0xff/*here.op*/;\n\n if (op & 16) { /* distance base */\n dist = here & 0xffff/*here.val*/;\n op &= 15; /* number of extra bits */\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n }\n dist += hold & ((1 << op) - 1);\n//#ifdef INFLATE_STRICT\n if (dist > dmax) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD$1;\n break top;\n }\n//#endif\n hold >>>= op;\n bits -= op;\n //Tracevv((stderr, \"inflate: distance %u\\n\", dist));\n op = _out - beg; /* max distance in output */\n if (dist > op) { /* see if copy from window */\n op = dist - op; /* distance back in window */\n if (op > whave) {\n if (state.sane) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD$1;\n break top;\n }\n\n// (!) This block is disabled in zlib defailts,\n// don't enable it for binary compatibility\n//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n// if (len <= op - whave) {\n// do {\n// output[_out++] = 0;\n// } while (--len);\n// continue top;\n// }\n// len -= op - whave;\n// do {\n// output[_out++] = 0;\n// } while (--op > whave);\n// if (op === 0) {\n// from = _out - dist;\n// do {\n// output[_out++] = output[from++];\n// } while (--len);\n// continue top;\n// }\n//#endif\n }\n from = 0; // window index\n from_source = s_window;\n if (wnext === 0) { /* very common case */\n from += wsize - op;\n if (op < len) { /* some from window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n else if (wnext < op) { /* wrap around window */\n from += wsize + wnext - op;\n op -= wnext;\n if (op < len) { /* some from end of window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = 0;\n if (wnext < len) { /* some from start of window */\n op = wnext;\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n }\n else { /* contiguous in window */\n from += wnext - op;\n if (op < len) { /* some from window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n while (len > 2) {\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n len -= 3;\n }\n if (len) {\n output[_out++] = from_source[from++];\n if (len > 1) {\n output[_out++] = from_source[from++];\n }\n }\n }\n else {\n from = _out - dist; /* copy direct from output */\n do { /* minimum length is three */\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n len -= 3;\n } while (len > 2);\n if (len) {\n output[_out++] = output[from++];\n if (len > 1) {\n output[_out++] = output[from++];\n }\n }\n }\n }\n else if ((op & 64) === 0) { /* 2nd level distance code */\n here = dcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n continue dodist;\n }\n else {\n strm.msg = 'invalid distance code';\n state.mode = BAD$1;\n break top;\n }\n\n break; // need to emulate goto via \"continue\"\n }\n }\n else if ((op & 64) === 0) { /* 2nd level length code */\n here = lcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n continue dolen;\n }\n else if (op & 32) { /* end-of-block */\n //Tracevv((stderr, \"inflate: end of block\\n\"));\n state.mode = TYPE$1;\n break top;\n }\n else {\n strm.msg = 'invalid literal/length code';\n state.mode = BAD$1;\n break top;\n }\n\n break; // need to emulate goto via \"continue\"\n }\n } while (_in < last && _out < end);\n\n /* return unused bytes (on entry, bits < 8, so in won't go too far back) */\n len = bits >> 3;\n _in -= len;\n bits -= len << 3;\n hold &= (1 << bits) - 1;\n\n /* update state and return */\n strm.next_in = _in;\n strm.next_out = _out;\n strm.avail_in = (_in < last ? 5 + (last - _in) : 5 - (_in - last));\n strm.avail_out = (_out < end ? 257 + (end - _out) : 257 - (_out - end));\n state.hold = hold;\n state.bits = bits;\n return;\n};\n\n// 'use strict';\n\n\n// var utils = require('../utils/common');\n\nvar MAXBITS = 15;\nvar ENOUGH_LENS$1 = 852;\nvar ENOUGH_DISTS$1 = 592;\n//var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);\n\nvar CODES$1 = 0;\nvar LENS$1 = 1;\nvar DISTS$1 = 2;\n\nvar lbase = [ /* Length codes 257..285 base */\n 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,\n 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0\n];\n\nvar lext = [ /* Length codes 257..285 extra */\n 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,\n 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78\n];\n\nvar dbase = [ /* Distance codes 0..29 base */\n 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,\n 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,\n 8193, 12289, 16385, 24577, 0, 0\n];\n\nvar dext = [ /* Distance codes 0..29 extra */\n 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,\n 23, 23, 24, 24, 25, 25, 26, 26, 27, 27,\n 28, 28, 29, 29, 64, 64\n];\n\n// module.exports =\nfunction inflate_table(type, lens, lens_index, codes, table, table_index, work, opts)\n{\n var bits = opts.bits;\n //here = opts.here; /* table entry for duplication */\n\n var len = 0; /* a code's length in bits */\n var sym = 0; /* index of code symbols */\n var min = 0, max = 0; /* minimum and maximum code lengths */\n var root = 0; /* number of index bits for root table */\n var curr = 0; /* number of index bits for current table */\n var drop = 0; /* code bits to drop for sub-table */\n var left = 0; /* number of prefix codes available */\n var used = 0; /* code entries in table used */\n var huff = 0; /* Huffman code */\n var incr; /* for incrementing code, index */\n var fill; /* index for replicating entries */\n var low; /* low bits for current root entry */\n var mask; /* mask for low root bits */\n var next; /* next available space in table */\n var base = null; /* base value table to use */\n var base_index = 0;\n// var shoextra; /* extra bits table to use */\n var end; /* use base and extra for symbol > end */\n var count = new Uint16Array(MAXBITS + 1); //[MAXBITS+1]; /* number of codes of each length */\n var offs = new Uint16Array(MAXBITS + 1); //[MAXBITS+1]; /* offsets in table for each length */\n var extra = null;\n var extra_index = 0;\n\n var here_bits, here_op, here_val;\n\n /*\n Process a set of code lengths to create a canonical Huffman code. The\n code lengths are lens[0..codes-1]. Each length corresponds to the\n symbols 0..codes-1. The Huffman code is generated by first sorting the\n symbols by length from short to long, and retaining the symbol order\n for codes with equal lengths. Then the code starts with all zero bits\n for the first code of the shortest length, and the codes are integer\n increments for the same length, and zeros are appended as the length\n increases. For the deflate format, these bits are stored backwards\n from their more natural integer increment ordering, and so when the\n decoding tables are built in the large loop below, the integer codes\n are incremented backwards.\n\n This routine assumes, but does not check, that all of the entries in\n lens[] are in the range 0..MAXBITS. The caller must assure this.\n 1..MAXBITS is interpreted as that code length. zero means that that\n symbol does not occur in this code.\n\n The codes are sorted by computing a count of codes for each length,\n creating from that a table of starting indices for each length in the\n sorted table, and then entering the symbols in order in the sorted\n table. The sorted table is work[], with that space being provided by\n the caller.\n\n The length counts are used for other purposes as well, i.e. finding\n the minimum and maximum length codes, determining if there are any\n codes at all, checking for a valid set of lengths, and looking ahead\n at length counts to determine sub-table sizes when building the\n decoding tables.\n */\n\n /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */\n for (len = 0; len <= MAXBITS; len++) {\n count[len] = 0;\n }\n for (sym = 0; sym < codes; sym++) {\n count[lens[lens_index + sym]]++;\n }\n\n /* bound code lengths, force root to be within code lengths */\n root = bits;\n for (max = MAXBITS; max >= 1; max--) {\n if (count[max] !== 0) { break; }\n }\n if (root > max) {\n root = max;\n }\n if (max === 0) { /* no symbols to code at all */\n //table.op[opts.table_index] = 64; //here.op = (var char)64; /* invalid code marker */\n //table.bits[opts.table_index] = 1; //here.bits = (var char)1;\n //table.val[opts.table_index++] = 0; //here.val = (var short)0;\n table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n\n //table.op[opts.table_index] = 64;\n //table.bits[opts.table_index] = 1;\n //table.val[opts.table_index++] = 0;\n table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n opts.bits = 1;\n return 0; /* no symbols, but wait for decoding to report error */\n }\n for (min = 1; min < max; min++) {\n if (count[min] !== 0) { break; }\n }\n if (root < min) {\n root = min;\n }\n\n /* check for an over-subscribed or incomplete set of lengths */\n left = 1;\n for (len = 1; len <= MAXBITS; len++) {\n left <<= 1;\n left -= count[len];\n if (left < 0) {\n return -1;\n } /* over-subscribed */\n }\n if (left > 0 && (type === CODES$1 || max !== 1)) {\n return -1; /* incomplete set */\n }\n\n /* generate offsets into symbol table for each length for sorting */\n offs[1] = 0;\n for (len = 1; len < MAXBITS; len++) {\n offs[len + 1] = offs[len] + count[len];\n }\n\n /* sort symbols by length, by symbol order within each length */\n for (sym = 0; sym < codes; sym++) {\n if (lens[lens_index + sym] !== 0) {\n work[offs[lens[lens_index + sym]]++] = sym;\n }\n }\n\n /*\n Create and fill in decoding tables. In this loop, the table being\n filled is at next and has curr index bits. The code being used is huff\n with length len. That code is converted to an index by dropping drop\n bits off of the bottom. For codes where len is less than drop + curr,\n those top drop + curr - len bits are incremented through all values to\n fill the table with replicated entries.\n\n root is the number of index bits for the root table. When len exceeds\n root, sub-tables are created pointed to by the root entry with an index\n of the low root bits of huff. This is saved in low to check for when a\n new sub-table should be started. drop is zero when the root table is\n being filled, and drop is root when sub-tables are being filled.\n\n When a new sub-table is needed, it is necessary to look ahead in the\n code lengths to determine what size sub-table is needed. The length\n counts are used for this, and so count[] is decremented as codes are\n entered in the tables.\n\n used keeps track of how many table entries have been allocated from the\n provided *table space. It is checked for LENS and DIST tables against\n the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in\n the initial root table size constants. See the comments in inftrees.h\n for more information.\n\n sym increments through all symbols, and the loop terminates when\n all codes of length max, i.e. all codes, have been processed. This\n routine permits incomplete codes, so another loop after this one fills\n in the rest of the decoding tables with invalid code markers.\n */\n\n /* set up for code type */\n // poor man optimization - use if-else instead of switch,\n // to avoid deopts in old v8\n if (type === CODES$1) {\n base = extra = work; /* dummy value--not used */\n end = 19;\n\n } else if (type === LENS$1) {\n base = lbase;\n base_index -= 257;\n extra = lext;\n extra_index -= 257;\n end = 256;\n\n } else { /* DISTS */\n base = dbase;\n extra = dext;\n end = -1;\n }\n\n /* initialize opts for loop */\n huff = 0; /* starting code */\n sym = 0; /* starting code symbol */\n len = min; /* starting code length */\n next = table_index; /* current table to fill in */\n curr = root; /* current table index bits */\n drop = 0; /* current bits to drop from code for index */\n low = -1; /* trigger new sub-table when len > root */\n used = 1 << root; /* use root table entries */\n mask = used - 1; /* mask for comparing low */\n\n /* check available table space */\n if ((type === LENS$1 && used > ENOUGH_LENS$1) ||\n (type === DISTS$1 && used > ENOUGH_DISTS$1)) {\n return 1;\n }\n\n var i = 0;\n /* process all codes and make table entries */\n for (;;) {\n i++;\n /* create table entry */\n here_bits = len - drop;\n if (work[sym] < end) {\n here_op = 0;\n here_val = work[sym];\n }\n else if (work[sym] > end) {\n here_op = extra[extra_index + work[sym]];\n here_val = base[base_index + work[sym]];\n }\n else {\n here_op = 32 + 64; /* end of block */\n here_val = 0;\n }\n\n /* replicate for those indices with low len bits equal to huff */\n incr = 1 << (len - drop);\n fill = 1 << curr;\n min = fill; /* save offset to next table */\n do {\n fill -= incr;\n table[next + (huff >> drop) + fill] = (here_bits << 24) | (here_op << 16) | here_val |0;\n } while (fill !== 0);\n\n /* backwards increment the len-bit code huff */\n incr = 1 << (len - 1);\n while (huff & incr) {\n incr >>= 1;\n }\n if (incr !== 0) {\n huff &= incr - 1;\n huff += incr;\n } else {\n huff = 0;\n }\n\n /* go to next symbol, update count, len */\n sym++;\n if (--count[len] === 0) {\n if (len === max) { break; }\n len = lens[lens_index + work[sym]];\n }\n\n /* create new sub-table if needed */\n if (len > root && (huff & mask) !== low) {\n /* if first time, transition to sub-tables */\n if (drop === 0) {\n drop = root;\n }\n\n /* increment past last table */\n next += min; /* here min is 1 << curr */\n\n /* determine length of next table */\n curr = len - drop;\n left = 1 << curr;\n while (curr + drop < max) {\n left -= count[curr + drop];\n if (left <= 0) { break; }\n curr++;\n left <<= 1;\n }\n\n /* check for enough space */\n used += 1 << curr;\n if ((type === LENS$1 && used > ENOUGH_LENS$1) ||\n (type === DISTS$1 && used > ENOUGH_DISTS$1)) {\n return 1;\n }\n\n /* point entry in root table to sub-table */\n low = huff & mask;\n /*table.op[low] = curr;\n table.bits[low] = root;\n table.val[low] = next - opts.table_index;*/\n table[low] = (root << 24) | (curr << 16) | (next - table_index) |0;\n }\n }\n\n /* fill in remaining table entry if code is incomplete (guaranteed to have\n at most one remaining entry, since if the code is incomplete, the\n maximum code length that was allowed to get this far is one bit) */\n if (huff !== 0) {\n //table.op[next + huff] = 64; /* invalid code marker */\n //table.bits[next + huff] = len - drop;\n //table.val[next + huff] = 0;\n table[next + huff] = ((len - drop) << 24) | (64 << 16) |0;\n }\n\n /* set return parameters */\n //opts.table_index += used;\n opts.bits = root;\n return 0;\n};\n\n// 'use strict';\n\n\n// var utils = require('../utils/common');\n// var adler32 = require('./adler32');\n// var crc32 = require('./crc32');\n// var inflate_fast = require('./inffast');\n// var inflate_table = require('./inftrees');\n\nvar CODES = 0;\nvar LENS = 1;\nvar DISTS = 2;\n\n/* Public constants ==========================================================*/\n/* ===========================================================================*/\n\n\n/* Allowed flush values; see deflate() and inflate() below for details */\n//var Z_NO_FLUSH = 0;\n//var Z_PARTIAL_FLUSH = 1;\n//var Z_SYNC_FLUSH = 2;\n//var Z_FULL_FLUSH = 3;\nvar Z_FINISH = 4;\nvar Z_BLOCK = 5;\nvar Z_TREES = 6;\n\n\n/* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\nvar Z_OK = 0;\nvar Z_STREAM_END = 1;\nvar Z_NEED_DICT = 2;\n//var Z_ERRNO = -1;\nvar Z_STREAM_ERROR = -2;\nvar Z_DATA_ERROR = -3;\nvar Z_MEM_ERROR = -4;\nvar Z_BUF_ERROR = -5;\n//var Z_VERSION_ERROR = -6;\n\n/* The deflate compression method */\nvar Z_DEFLATED = 8;\n\n\n/* STATES ====================================================================*/\n/* ===========================================================================*/\n\n\nvar HEAD = 1; /* i: waiting for magic header */\nvar FLAGS = 2; /* i: waiting for method and flags (gzip) */\nvar TIME = 3; /* i: waiting for modification time (gzip) */\nvar OS = 4; /* i: waiting for extra flags and operating system (gzip) */\nvar EXLEN = 5; /* i: waiting for extra length (gzip) */\nvar EXTRA = 6; /* i: waiting for extra bytes (gzip) */\nvar NAME = 7; /* i: waiting for end of file name (gzip) */\nvar COMMENT = 8; /* i: waiting for end of comment (gzip) */\nvar HCRC = 9; /* i: waiting for header crc (gzip) */\nvar DICTID = 10; /* i: waiting for dictionary check value */\nvar DICT = 11; /* waiting for inflateSetDictionary() call */\nvar TYPE = 12; /* i: waiting for type bits, including last-flag bit */\nvar TYPEDO = 13; /* i: same, but skip check to exit inflate on new block */\nvar STORED = 14; /* i: waiting for stored size (length and complement) */\nvar COPY_ = 15; /* i/o: same as COPY below, but only first time in */\nvar COPY = 16; /* i/o: waiting for input or output to copy stored block */\nvar TABLE = 17; /* i: waiting for dynamic block table lengths */\nvar LENLENS = 18; /* i: waiting for code length code lengths */\nvar CODELENS = 19; /* i: waiting for length/lit and distance code lengths */\nvar LEN_ = 20; /* i: same as LEN below, but only first time in */\nvar LEN = 21; /* i: waiting for length/lit/eob code */\nvar LENEXT = 22; /* i: waiting for length extra bits */\nvar DIST = 23; /* i: waiting for distance code */\nvar DISTEXT = 24; /* i: waiting for distance extra bits */\nvar MATCH = 25; /* o: waiting for output space to copy string */\nvar LIT = 26; /* o: waiting for output space to write literal */\nvar CHECK = 27; /* i: waiting for 32-bit check value */\nvar LENGTH = 28; /* i: waiting for 32-bit length (gzip) */\nvar DONE = 29; /* finished check, done -- remain here until reset */\nvar BAD = 30; /* got a data error -- remain here until reset */\nvar MEM = 31; /* got an inflate() memory error -- remain here until reset */\nvar SYNC = 32; /* looking for synchronization bytes to restart inflate() */\n\n/* ===========================================================================*/\n\n\n\nvar ENOUGH_LENS = 852;\nvar ENOUGH_DISTS = 592;\nfunction zswap32(q) {\n return (((q >>> 24) & 0xff) +\n ((q >>> 8) & 0xff00) +\n ((q & 0xff00) << 8) +\n ((q & 0xff) << 24));\n}\n\n\nfunction InflateState() {\n this.mode = 0; /* current inflate mode */\n this.last = false; /* true if processing last block */\n this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip */\n this.havedict = false; /* true if dictionary provided */\n this.flags = 0; /* gzip header method and flags (0 if zlib) */\n this.dmax = 0; /* zlib header max distance (INFLATE_STRICT) */\n this.check = 0; /* protected copy of check value */\n this.total = 0; /* protected copy of output count */\n // TODO: may be {}\n this.head = null; /* where to save gzip header information */\n\n /* sliding window */\n this.wbits = 0; /* log base 2 of requested window size */\n this.wsize = 0; /* window size or zero if not using window */\n this.whave = 0; /* valid bytes in the window */\n this.wnext = 0; /* window write index */\n this.window = null; /* allocated sliding window, if needed */\n\n /* bit accumulator */\n this.hold = 0; /* input bit accumulator */\n this.bits = 0; /* number of bits in \"in\" */\n\n /* for string and stored block copying */\n this.length = 0; /* literal or length of data to copy */\n this.offset = 0; /* distance back to copy string from */\n\n /* for table and code decoding */\n this.extra = 0; /* extra bits needed */\n\n /* fixed and dynamic code tables */\n this.lencode = null; /* starting table for length/literal codes */\n this.distcode = null; /* starting table for distance codes */\n this.lenbits = 0; /* index bits for lencode */\n this.distbits = 0; /* index bits for distcode */\n\n /* dynamic table building */\n this.ncode = 0; /* number of code length code lengths */\n this.nlen = 0; /* number of length code lengths */\n this.ndist = 0; /* number of distance code lengths */\n this.have = 0; /* number of code lengths in lens[] */\n this.next = null; /* next available space in codes[] */\n\n this.lens = new Uint16Array(320); /* temporary storage for code lengths */\n this.work = new Uint16Array(288); /* work area for code table building */\n\n /*\n because we don't have pointers in js, we use lencode and distcode directly\n as buffers so we don't need codes\n */\n //this.codes = new Buf32(ENOUGH); /* space for code tables */\n this.lendyn = null; /* dynamic table for length/literal codes (JS specific) */\n this.distdyn = null; /* dynamic table for distance codes (JS specific) */\n this.sane = 0; /* if false, allow invalid distance too far */\n this.back = 0; /* bits back of last unprocessed length/lit */\n this.was = 0; /* initial length of match */\n}\n\nfunction inflateResetKeep(strm) {\n var state;\n\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n strm.total_in = strm.total_out = state.total = 0;\n strm.msg = ''; /*Z_NULL*/\n if (state.wrap) { /* to support ill-conceived Java test suite */\n strm.adler = state.wrap & 1;\n }\n state.mode = HEAD;\n state.last = 0;\n state.havedict = 0;\n state.dmax = 32768;\n state.head = null/*Z_NULL*/;\n state.hold = 0;\n state.bits = 0;\n //state.lencode = state.distcode = state.next = state.codes;\n state.lencode = state.lendyn = new Int32Array(ENOUGH_LENS);\n state.distcode = state.distdyn = new Int32Array(ENOUGH_DISTS);\n\n state.sane = 1;\n state.back = -1;\n //Tracev((stderr, \"inflate: reset\\n\"));\n return Z_OK;\n}\n\nfunction inflateReset(strm) {\n var state;\n\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n state.wsize = 0;\n state.whave = 0;\n state.wnext = 0;\n return inflateResetKeep(strm);\n\n}\n\nfunction inflateReset2(strm, windowBits) {\n var wrap;\n var state;\n\n /* get the state */\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n\n /* extract wrap request from windowBits parameter */\n if (windowBits < 0) {\n wrap = 0;\n windowBits = -windowBits;\n }\n else {\n wrap = (windowBits >> 4) + 1;\n if (windowBits < 48) {\n windowBits &= 15;\n }\n }\n\n /* set number of window bits, free window if different */\n if (windowBits && (windowBits < 8 || windowBits > 15)) {\n return Z_STREAM_ERROR;\n }\n if (state.window !== null && state.wbits !== windowBits) {\n state.window = null;\n }\n\n /* update state and reset the rest of it */\n state.wrap = wrap;\n state.wbits = windowBits;\n return inflateReset(strm);\n}\n\nfunction inflateInit2(strm, windowBits) {\n var ret;\n var state;\n\n if (!strm) { return Z_STREAM_ERROR; }\n //strm.msg = Z_NULL; /* in case we return an error */\n\n state = new InflateState();\n\n //if (state === Z_NULL) return Z_MEM_ERROR;\n //Tracev((stderr, \"inflate: allocated\\n\"));\n strm.state = state;\n state.window = null/*Z_NULL*/;\n ret = inflateReset2(strm, windowBits);\n if (ret !== Z_OK) {\n strm.state = null/*Z_NULL*/;\n }\n return ret;\n}\n\n/*\n Return state with length and distance decoding tables and index sizes set to\n fixed code decoding. Normally this returns fixed tables from inffixed.h.\n If BUILDFIXED is defined, then instead this routine builds the tables the\n first time it's called, and returns those tables the first time and\n thereafter. This reduces the size of the code by about 2K bytes, in\n exchange for a little execution time. However, BUILDFIXED should not be\n used for threaded applications, since the rewriting of the tables and virgin\n may not be thread-safe.\n */\nvar virgin = true;\n\nvar lenfix;\nvar distfix;\n// We have no pointers in JS, so keep tables separate\n\nfunction fixedtables(state) {\n /* build fixed huffman tables if first call (may not be thread safe) */\n if (virgin) {\n var sym;\n\n lenfix = new Int32Array(512);\n distfix = new Int32Array(32);\n\n /* literal/length table */\n sym = 0;\n while (sym < 144) { state.lens[sym++] = 8; }\n while (sym < 256) { state.lens[sym++] = 9; }\n while (sym < 280) { state.lens[sym++] = 7; }\n while (sym < 288) { state.lens[sym++] = 8; }\n\n inflate_table(LENS, state.lens, 0, 288, lenfix, 0, state.work, { bits: 9 });\n\n /* distance table */\n sym = 0;\n while (sym < 32) { state.lens[sym++] = 5; }\n\n inflate_table(DISTS, state.lens, 0, 32, distfix, 0, state.work, { bits: 5 });\n\n /* do this just once */\n virgin = false;\n }\n\n state.lencode = lenfix;\n state.lenbits = 9;\n state.distcode = distfix;\n state.distbits = 5;\n}\n\n\n/*\n Update the window with the last wsize (normally 32K) bytes written before\n returning. If window does not exist yet, create it. This is only called\n when a window is already in use, or when output has been written during this\n inflate call, but the end of the deflate stream has not been reached yet.\n It is also called to create a window for dictionary data when a dictionary\n is loaded.\n\n Providing output buffers larger than 32K to inflate() should provide a speed\n advantage, since only the last 32K of output is copied to the sliding window\n upon return from inflate(), and since all distances after the first 32K of\n output will fall in the output data, making match copies simpler and faster.\n The advantage may be dependent on the size of the processor's data caches.\n */\nfunction updatewindow(strm, src, end, copy) {\n var dist;\n var state = strm.state;\n\n /* if it hasn't been done already, allocate space for the window */\n if (state.window === null) {\n state.wsize = 1 << state.wbits;\n state.wnext = 0;\n state.whave = 0;\n\n state.window = new Uint8Array(state.wsize);\n }\n\n /* copy state->wsize or less output bytes into the circular window */\n if (copy >= state.wsize) {\n arraySet(state.window, src, end - state.wsize, state.wsize, 0);\n state.wnext = 0;\n state.whave = state.wsize;\n }\n else {\n dist = state.wsize - state.wnext;\n if (dist > copy) {\n dist = copy;\n }\n //zmemcpy(state->window + state->wnext, end - copy, dist);\n arraySet(state.window, src, end - copy, dist, state.wnext);\n copy -= dist;\n if (copy) {\n //zmemcpy(state->window, end - copy, copy);\n arraySet(state.window, src, end - copy, copy, 0);\n state.wnext = copy;\n state.whave = state.wsize;\n }\n else {\n state.wnext += dist;\n if (state.wnext === state.wsize) { state.wnext = 0; }\n if (state.whave < state.wsize) { state.whave += dist; }\n }\n }\n return 0;\n}\n\nfunction inflate(strm, flush) {\n var state;\n var input, output; // input/output buffers\n var next; /* next input INDEX */\n var put; /* next output INDEX */\n var have, left; /* available input and output */\n var hold; /* bit buffer */\n var bits; /* bits in bit buffer */\n var _in, _out; /* save starting available input and output */\n var copy; /* number of stored or match bytes to copy */\n var from; /* where to copy match bytes from */\n var from_source;\n var here = 0; /* current decoding table entry */\n var here_bits, here_op, here_val; // paked \"here\" denormalized (JS specific)\n //var last; /* parent table entry */\n var last_bits, last_op, last_val; // paked \"last\" denormalized (JS specific)\n var len; /* length to copy for repeats, bits to drop */\n var ret; /* return code */\n var hbuf = new Uint8Array(4); /* buffer for gzip header crc calculation */\n var opts;\n\n var n; // temporary var for NEED_BITS\n\n var order = /* permutation of code lengths */\n [ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ];\n\n\n if (!strm || !strm.state || !strm.output ||\n (!strm.input && strm.avail_in !== 0)) {\n return Z_STREAM_ERROR;\n }\n\n state = strm.state;\n if (state.mode === TYPE) { state.mode = TYPEDO; } /* skip check */\n\n\n //--- LOAD() ---\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n //---\n\n _in = have;\n _out = left;\n ret = Z_OK;\n\n inf_leave: // goto emulation\n for (;;) {\n switch (state.mode) {\n case HEAD:\n if (state.wrap === 0) {\n state.mode = TYPEDO;\n break;\n }\n //=== NEEDBITS(16);\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if ((state.wrap & 2) && hold === 0x8b1f) { /* gzip header */\n state.check = 0/*crc32(0L, Z_NULL, 0)*/;\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = FLAGS;\n break;\n }\n state.flags = 0; /* expect zlib header */\n if (state.head) {\n state.head.done = false;\n }\n if (!(state.wrap & 1) || /* check if zlib header allowed */\n (((hold & 0xff)/*BITS(8)*/ << 8) + (hold >> 8)) % 31) {\n strm.msg = 'incorrect header check';\n state.mode = BAD;\n break;\n }\n if ((hold & 0x0f)/*BITS(4)*/ !== Z_DEFLATED) {\n strm.msg = 'unknown compression method';\n state.mode = BAD;\n break;\n }\n //--- DROPBITS(4) ---//\n hold >>>= 4;\n bits -= 4;\n //---//\n len = (hold & 0x0f)/*BITS(4)*/ + 8;\n if (state.wbits === 0) {\n state.wbits = len;\n }\n else if (len > state.wbits) {\n strm.msg = 'invalid window size';\n state.mode = BAD;\n break;\n }\n state.dmax = 1 << len;\n //Tracev((stderr, \"inflate: zlib header ok\\n\"));\n strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n state.mode = hold & 0x200 ? DICTID : TYPE;\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n break;\n case FLAGS:\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.flags = hold;\n if ((state.flags & 0xff) !== Z_DEFLATED) {\n strm.msg = 'unknown compression method';\n state.mode = BAD;\n break;\n }\n if (state.flags & 0xe000) {\n strm.msg = 'unknown header flags set';\n state.mode = BAD;\n break;\n }\n if (state.head) {\n state.head.text = ((hold >> 8) & 1);\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = TIME;\n /* falls through */\n case TIME:\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (state.head) {\n state.head.time = hold;\n }\n if (state.flags & 0x0200) {\n //=== CRC4(state.check, hold)\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n hbuf[2] = (hold >>> 16) & 0xff;\n hbuf[3] = (hold >>> 24) & 0xff;\n state.check = crc32(state.check, hbuf, 4, 0);\n //===\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = OS;\n /* falls through */\n case OS:\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (state.head) {\n state.head.xflags = (hold & 0xff);\n state.head.os = (hold >> 8);\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = EXLEN;\n /* falls through */\n case EXLEN:\n if (state.flags & 0x0400) {\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.length = hold;\n if (state.head) {\n state.head.extra_len = hold;\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n }\n else if (state.head) {\n state.head.extra = null/*Z_NULL*/;\n }\n state.mode = EXTRA;\n /* falls through */\n case EXTRA:\n if (state.flags & 0x0400) {\n copy = state.length;\n if (copy > have) { copy = have; }\n if (copy) {\n if (state.head) {\n len = state.head.extra_len - state.length;\n if (!state.head.extra) {\n // Use untyped array for more conveniend processing later\n state.head.extra = new Array(state.head.extra_len);\n }\n arraySet(\n state.head.extra,\n input,\n next,\n // extra field is limited to 65536 bytes\n // - no need for additional size check\n copy,\n /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/\n len\n );\n //zmemcpy(state.head.extra + len, next,\n // len + copy > state.head.extra_max ?\n // state.head.extra_max - len : copy);\n }\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n state.length -= copy;\n }\n if (state.length) { break inf_leave; }\n }\n state.length = 0;\n state.mode = NAME;\n /* falls through */\n case NAME:\n if (state.flags & 0x0800) {\n if (have === 0) { break inf_leave; }\n copy = 0;\n do {\n // TODO: 2 or 1 bytes?\n len = input[next + copy++];\n /* use constant limit because in js we should not preallocate memory */\n if (state.head && len &&\n (state.length < 65536 /*state.head.name_max*/)) {\n state.head.name += String.fromCharCode(len);\n }\n } while (len && copy < have);\n\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) { break inf_leave; }\n }\n else if (state.head) {\n state.head.name = null;\n }\n state.length = 0;\n state.mode = COMMENT;\n /* falls through */\n case COMMENT:\n if (state.flags & 0x1000) {\n if (have === 0) { break inf_leave; }\n copy = 0;\n do {\n len = input[next + copy++];\n /* use constant limit because in js we should not preallocate memory */\n if (state.head && len &&\n (state.length < 65536 /*state.head.comm_max*/)) {\n state.head.comment += String.fromCharCode(len);\n }\n } while (len && copy < have);\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) { break inf_leave; }\n }\n else if (state.head) {\n state.head.comment = null;\n }\n state.mode = HCRC;\n /* falls through */\n case HCRC:\n if (state.flags & 0x0200) {\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (hold !== (state.check & 0xffff)) {\n strm.msg = 'header crc mismatch';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n }\n if (state.head) {\n state.head.hcrc = ((state.flags >> 9) & 1);\n state.head.done = true;\n }\n strm.adler = state.check = 0;\n state.mode = TYPE;\n break;\n case DICTID:\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n strm.adler = state.check = zswap32(hold);\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = DICT;\n /* falls through */\n case DICT:\n if (state.havedict === 0) {\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n return Z_NEED_DICT;\n }\n strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n state.mode = TYPE;\n /* falls through */\n case TYPE:\n if (flush === Z_BLOCK || flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case TYPEDO:\n if (state.last) {\n //--- BYTEBITS() ---//\n hold >>>= bits & 7;\n bits -= bits & 7;\n //---//\n state.mode = CHECK;\n break;\n }\n //=== NEEDBITS(3); */\n while (bits < 3) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.last = (hold & 0x01)/*BITS(1)*/;\n //--- DROPBITS(1) ---//\n hold >>>= 1;\n bits -= 1;\n //---//\n\n switch ((hold & 0x03)/*BITS(2)*/) {\n case 0: /* stored block */\n //Tracev((stderr, \"inflate: stored block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = STORED;\n break;\n case 1: /* fixed block */\n fixedtables(state);\n //Tracev((stderr, \"inflate: fixed codes block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = LEN_; /* decode codes */\n if (flush === Z_TREES) {\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n break inf_leave;\n }\n break;\n case 2: /* dynamic block */\n //Tracev((stderr, \"inflate: dynamic codes block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = TABLE;\n break;\n case 3:\n strm.msg = 'invalid block type';\n state.mode = BAD;\n }\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n break;\n case STORED:\n //--- BYTEBITS() ---// /* go to byte boundary */\n hold >>>= bits & 7;\n bits -= bits & 7;\n //---//\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if ((hold & 0xffff) !== ((hold >>> 16) ^ 0xffff)) {\n strm.msg = 'invalid stored block lengths';\n state.mode = BAD;\n break;\n }\n state.length = hold & 0xffff;\n //Tracev((stderr, \"inflate: stored length %u\\n\",\n // state.length));\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = COPY_;\n if (flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case COPY_:\n state.mode = COPY;\n /* falls through */\n case COPY:\n copy = state.length;\n if (copy) {\n if (copy > have) { copy = have; }\n if (copy > left) { copy = left; }\n if (copy === 0) { break inf_leave; }\n //--- zmemcpy(put, next, copy); ---\n arraySet(output, input, next, copy, put);\n //---//\n have -= copy;\n next += copy;\n left -= copy;\n put += copy;\n state.length -= copy;\n break;\n }\n //Tracev((stderr, \"inflate: stored end\\n\"));\n state.mode = TYPE;\n break;\n case TABLE:\n //=== NEEDBITS(14); */\n while (bits < 14) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.nlen = (hold & 0x1f)/*BITS(5)*/ + 257;\n //--- DROPBITS(5) ---//\n hold >>>= 5;\n bits -= 5;\n //---//\n state.ndist = (hold & 0x1f)/*BITS(5)*/ + 1;\n //--- DROPBITS(5) ---//\n hold >>>= 5;\n bits -= 5;\n //---//\n state.ncode = (hold & 0x0f)/*BITS(4)*/ + 4;\n //--- DROPBITS(4) ---//\n hold >>>= 4;\n bits -= 4;\n //---//\n//#ifndef PKZIP_BUG_WORKAROUND\n if (state.nlen > 286 || state.ndist > 30) {\n strm.msg = 'too many length or distance symbols';\n state.mode = BAD;\n break;\n }\n//#endif\n //Tracev((stderr, \"inflate: table sizes ok\\n\"));\n state.have = 0;\n state.mode = LENLENS;\n /* falls through */\n case LENLENS:\n while (state.have < state.ncode) {\n //=== NEEDBITS(3);\n while (bits < 3) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.lens[order[state.have++]] = (hold & 0x07);//BITS(3);\n //--- DROPBITS(3) ---//\n hold >>>= 3;\n bits -= 3;\n //---//\n }\n while (state.have < 19) {\n state.lens[order[state.have++]] = 0;\n }\n // We have separate tables & no pointers. 2 commented lines below not needed.\n //state.next = state.codes;\n //state.lencode = state.next;\n // Switch to use dynamic table\n state.lencode = state.lendyn;\n state.lenbits = 7;\n\n opts = { bits: state.lenbits };\n ret = inflate_table(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts);\n state.lenbits = opts.bits;\n\n if (ret) {\n strm.msg = 'invalid code lengths set';\n state.mode = BAD;\n break;\n }\n //Tracev((stderr, \"inflate: code lengths ok\\n\"));\n state.have = 0;\n state.mode = CODELENS;\n /* falls through */\n case CODELENS:\n while (state.have < state.nlen + state.ndist) {\n for (;;) {\n here = state.lencode[hold & ((1 << state.lenbits) - 1)];/*BITS(state.lenbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if (here_val < 16) {\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.lens[state.have++] = here_val;\n }\n else {\n if (here_val === 16) {\n //=== NEEDBITS(here.bits + 2);\n n = here_bits + 2;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n if (state.have === 0) {\n strm.msg = 'invalid bit length repeat';\n state.mode = BAD;\n break;\n }\n len = state.lens[state.have - 1];\n copy = 3 + (hold & 0x03);//BITS(2);\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n }\n else if (here_val === 17) {\n //=== NEEDBITS(here.bits + 3);\n n = here_bits + 3;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n len = 0;\n copy = 3 + (hold & 0x07);//BITS(3);\n //--- DROPBITS(3) ---//\n hold >>>= 3;\n bits -= 3;\n //---//\n }\n else {\n //=== NEEDBITS(here.bits + 7);\n n = here_bits + 7;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n len = 0;\n copy = 11 + (hold & 0x7f);//BITS(7);\n //--- DROPBITS(7) ---//\n hold >>>= 7;\n bits -= 7;\n //---//\n }\n if (state.have + copy > state.nlen + state.ndist) {\n strm.msg = 'invalid bit length repeat';\n state.mode = BAD;\n break;\n }\n while (copy--) {\n state.lens[state.have++] = len;\n }\n }\n }\n\n /* handle error breaks in while */\n if (state.mode === BAD) { break; }\n\n /* check for end-of-block code (better have one) */\n if (state.lens[256] === 0) {\n strm.msg = 'invalid code -- missing end-of-block';\n state.mode = BAD;\n break;\n }\n\n /* build code tables -- note: do not change the lenbits or distbits\n values here (9 and 6) without reading the comments in inftrees.h\n concerning the ENOUGH constants, which depend on those values */\n state.lenbits = 9;\n\n opts = { bits: state.lenbits };\n ret = inflate_table(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts);\n // We have separate tables & no pointers. 2 commented lines below not needed.\n // state.next_index = opts.table_index;\n state.lenbits = opts.bits;\n // state.lencode = state.next;\n\n if (ret) {\n strm.msg = 'invalid literal/lengths set';\n state.mode = BAD;\n break;\n }\n\n state.distbits = 6;\n //state.distcode.copy(state.codes);\n // Switch to use dynamic table\n state.distcode = state.distdyn;\n opts = { bits: state.distbits };\n ret = inflate_table(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts);\n // We have separate tables & no pointers. 2 commented lines below not needed.\n // state.next_index = opts.table_index;\n state.distbits = opts.bits;\n // state.distcode = state.next;\n\n if (ret) {\n strm.msg = 'invalid distances set';\n state.mode = BAD;\n break;\n }\n //Tracev((stderr, 'inflate: codes ok\\n'));\n state.mode = LEN_;\n if (flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case LEN_:\n state.mode = LEN;\n /* falls through */\n case LEN:\n if (have >= 6 && left >= 258) {\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n inflate_fast(strm, _out);\n //--- LOAD() ---\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n //---\n\n if (state.mode === TYPE) {\n state.back = -1;\n }\n break;\n }\n state.back = 0;\n for (;;) {\n here = state.lencode[hold & ((1 << state.lenbits) - 1)]; /*BITS(state.lenbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if (here_bits <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if (here_op && (here_op & 0xf0) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (;;) {\n here = state.lencode[last_val +\n ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((last_bits + here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n //--- DROPBITS(last.bits) ---//\n hold >>>= last_bits;\n bits -= last_bits;\n //---//\n state.back += last_bits;\n }\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.back += here_bits;\n state.length = here_val;\n if (here_op === 0) {\n //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n // \"inflate: literal '%c'\\n\" :\n // \"inflate: literal 0x%02x\\n\", here.val));\n state.mode = LIT;\n break;\n }\n if (here_op & 32) {\n //Tracevv((stderr, \"inflate: end of block\\n\"));\n state.back = -1;\n state.mode = TYPE;\n break;\n }\n if (here_op & 64) {\n strm.msg = 'invalid literal/length code';\n state.mode = BAD;\n break;\n }\n state.extra = here_op & 15;\n state.mode = LENEXT;\n /* falls through */\n case LENEXT:\n if (state.extra) {\n //=== NEEDBITS(state.extra);\n n = state.extra;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.length += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n //--- DROPBITS(state.extra) ---//\n hold >>>= state.extra;\n bits -= state.extra;\n //---//\n state.back += state.extra;\n }\n //Tracevv((stderr, \"inflate: length %u\\n\", state.length));\n state.was = state.length;\n state.mode = DIST;\n /* falls through */\n case DIST:\n for (;;) {\n here = state.distcode[hold & ((1 << state.distbits) - 1)];/*BITS(state.distbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if ((here_op & 0xf0) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (;;) {\n here = state.distcode[last_val +\n ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((last_bits + here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n //--- DROPBITS(last.bits) ---//\n hold >>>= last_bits;\n bits -= last_bits;\n //---//\n state.back += last_bits;\n }\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.back += here_bits;\n if (here_op & 64) {\n strm.msg = 'invalid distance code';\n state.mode = BAD;\n break;\n }\n state.offset = here_val;\n state.extra = (here_op) & 15;\n state.mode = DISTEXT;\n /* falls through */\n case DISTEXT:\n if (state.extra) {\n //=== NEEDBITS(state.extra);\n n = state.extra;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.offset += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n //--- DROPBITS(state.extra) ---//\n hold >>>= state.extra;\n bits -= state.extra;\n //---//\n state.back += state.extra;\n }\n//#ifdef INFLATE_STRICT\n if (state.offset > state.dmax) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break;\n }\n//#endif\n //Tracevv((stderr, \"inflate: distance %u\\n\", state.offset));\n state.mode = MATCH;\n /* falls through */\n case MATCH:\n if (left === 0) { break inf_leave; }\n copy = _out - left;\n if (state.offset > copy) { /* copy from window */\n copy = state.offset - copy;\n if (copy > state.whave) {\n if (state.sane) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break;\n }\n// (!) This block is disabled in zlib defailts,\n// don't enable it for binary compatibility\n//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n// Trace((stderr, \"inflate.c too far\\n\"));\n// copy -= state.whave;\n// if (copy > state.length) { copy = state.length; }\n// if (copy > left) { copy = left; }\n// left -= copy;\n// state.length -= copy;\n// do {\n// output[put++] = 0;\n// } while (--copy);\n// if (state.length === 0) { state.mode = LEN; }\n// break;\n//#endif\n }\n if (copy > state.wnext) {\n copy -= state.wnext;\n from = state.wsize - copy;\n }\n else {\n from = state.wnext - copy;\n }\n if (copy > state.length) { copy = state.length; }\n from_source = state.window;\n }\n else { /* copy from output */\n from_source = output;\n from = put - state.offset;\n copy = state.length;\n }\n if (copy > left) { copy = left; }\n left -= copy;\n state.length -= copy;\n do {\n output[put++] = from_source[from++];\n } while (--copy);\n if (state.length === 0) { state.mode = LEN; }\n break;\n case LIT:\n if (left === 0) { break inf_leave; }\n output[put++] = state.length;\n left--;\n state.mode = LEN;\n break;\n case CHECK:\n if (state.wrap) {\n //=== NEEDBITS(32);\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n // Use '|' insdead of '+' to make sure that result is signed\n hold |= input[next++] << bits;\n bits += 8;\n }\n //===//\n _out -= left;\n strm.total_out += _out;\n state.total += _out;\n if (_out) {\n strm.adler = state.check =\n /*UPDATE(state.check, put - _out, _out);*/\n (state.flags ? crc32(state.check, output, _out, put - _out) : adler32(state.check, output, _out, put - _out));\n\n }\n _out = left;\n // NB: crc32 stored as signed 32-bit int, zswap32 returns signed too\n if ((state.flags ? hold : zswap32(hold)) !== state.check) {\n strm.msg = 'incorrect data check';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n //Tracev((stderr, \"inflate: check matches trailer\\n\"));\n }\n state.mode = LENGTH;\n /* falls through */\n case LENGTH:\n if (state.wrap && state.flags) {\n //=== NEEDBITS(32);\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (hold !== (state.total & 0xffffffff)) {\n strm.msg = 'incorrect length check';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n //Tracev((stderr, \"inflate: length matches trailer\\n\"));\n }\n state.mode = DONE;\n /* falls through */\n case DONE:\n ret = Z_STREAM_END;\n break inf_leave;\n case BAD:\n ret = Z_DATA_ERROR;\n break inf_leave;\n case MEM:\n return Z_MEM_ERROR;\n case SYNC:\n /* falls through */\n default:\n return Z_STREAM_ERROR;\n }\n }\n\n // inf_leave <- here is real place for \"goto inf_leave\", emulated via \"break inf_leave\"\n\n /*\n Return from inflate(), updating the total counts and the check value.\n If there was no progress during the inflate() call, return a buffer\n error. Call updatewindow() to create and/or update the window state.\n Note: a memory error from inflate() is non-recoverable.\n */\n\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n\n if (state.wsize || (_out !== strm.avail_out && state.mode < BAD &&\n (state.mode < CHECK || flush !== Z_FINISH))) {\n if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) {\n state.mode = MEM;\n return Z_MEM_ERROR;\n }\n }\n _in -= strm.avail_in;\n _out -= strm.avail_out;\n strm.total_in += _in;\n strm.total_out += _out;\n state.total += _out;\n if (state.wrap && _out) {\n strm.adler = state.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/\n (state.flags ? crc32(state.check, output, _out, strm.next_out - _out) : adler32(state.check, output, _out, strm.next_out - _out));\n }\n strm.data_type = state.bits + (state.last ? 64 : 0) +\n (state.mode === TYPE ? 128 : 0) +\n (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);\n if (((_in === 0 && _out === 0) || flush === Z_FINISH) && ret === Z_OK) {\n ret = Z_BUF_ERROR;\n }\n return ret;\n}\n\nfunction inflateEnd(strm) {\n\n if (!strm || !strm.state /*|| strm->zfree == (free_func)0*/) {\n return Z_STREAM_ERROR;\n }\n\n var state = strm.state;\n if (state.window) {\n state.window = null;\n }\n strm.state = null;\n return Z_OK;\n}\n\nfunction inflateGetHeader(strm, head) {\n var state;\n\n /* check state */\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n if ((state.wrap & 2) === 0) { return Z_STREAM_ERROR; }\n\n /* save header structure */\n state.head = head;\n head.done = false;\n return Z_OK;\n}\n\nfunction inflateSetDictionary(strm, dictionary) {\n var dictLength = dictionary.length;\n\n var state;\n var dictid;\n var ret;\n\n /* check state */\n if (!strm /* == Z_NULL */ || !strm.state /* == Z_NULL */) { return Z_STREAM_ERROR; }\n state = strm.state;\n\n if (state.wrap !== 0 && state.mode !== DICT) {\n return Z_STREAM_ERROR;\n }\n\n /* check for correct dictionary identifier */\n if (state.mode === DICT) {\n dictid = 1; /* adler32(0, null, 0)*/\n /* dictid = adler32(dictid, dictionary, dictLength); */\n dictid = adler32(dictid, dictionary, dictLength, 0);\n if (dictid !== state.check) {\n return Z_DATA_ERROR;\n }\n }\n /* copy dictionary to window using updatewindow(), which will amend the\n existing dictionary if appropriate */\n ret = updatewindow(strm, dictionary, dictLength, dictLength);\n if (ret) {\n state.mode = MEM;\n return Z_MEM_ERROR;\n }\n state.havedict = 1;\n // Tracev((stderr, \"inflate: dictionary set\\n\"));\n return Z_OK;\n}\n\n// String encode/decode helpers\n// 'use strict';\n\n\n// var utils = require('./common');\n\n\n// Quick check if we can use fast array to bin string conversion\n//\n// - apply(Array) can fail on Android 2.2\n// - apply(Uint8Array) can fail on iOS 5.1 Safary\n//\nvar STR_APPLY_OK = true;\nvar STR_APPLY_UIA_OK = true;\n\ntry { String.fromCharCode.apply(null, [ 0 ]); } catch (__) { STR_APPLY_OK = false; }\ntry { String.fromCharCode.apply(null, new Uint8Array(1)); } catch (__) { STR_APPLY_UIA_OK = false; }\n\n\n// Table with utf8 lengths (calculated by first byte of sequence)\n// Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS,\n// because max possible codepoint is 0x10ffff\nvar _utf8len = new Uint8Array(256);\nfor (var q = 0; q < 256; q++) {\n _utf8len[q] = (q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1);\n}\n_utf8len[254] = _utf8len[254] = 1; // Invalid sequence start\n\n\n// convert string to array (typed, when possible)\nfunction string2buf(str) {\n var buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;\n\n // count binary size\n for (m_pos = 0; m_pos < str_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n m_pos++;\n }\n }\n buf_len += c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4;\n }\n\n // allocate buffer\n buf = new Uint8Array(buf_len);\n\n // convert\n for (i = 0, m_pos = 0; i < buf_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n m_pos++;\n }\n }\n if (c < 0x80) {\n /* one byte */\n buf[i++] = c;\n } else if (c < 0x800) {\n /* two bytes */\n buf[i++] = 0xC0 | (c >>> 6);\n buf[i++] = 0x80 | (c & 0x3f);\n } else if (c < 0x10000) {\n /* three bytes */\n buf[i++] = 0xE0 | (c >>> 12);\n buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n buf[i++] = 0x80 | (c & 0x3f);\n } else {\n /* four bytes */\n buf[i++] = 0xf0 | (c >>> 18);\n buf[i++] = 0x80 | (c >>> 12 & 0x3f);\n buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n buf[i++] = 0x80 | (c & 0x3f);\n }\n }\n\n return buf;\n}\n\n// Helper (used in 2 places)\nfunction _buf2binstring(buf, len) {\n // use fallback for big arrays to avoid stack overflow\n if (len < 65537) {\n if ((buf.subarray && STR_APPLY_UIA_OK) || (!buf.subarray && STR_APPLY_OK)) {\n return String.fromCharCode.apply(null, shrinkBuf(buf, len));\n }\n }\n\n var result = '';\n for (var i = 0; i < len; i++) {\n result += String.fromCharCode(buf[i]);\n }\n return result;\n}\n\n\n// Convert binary string (typed, when possible)\nfunction binstring2buf(str) {\n var buf = new Uint8Array(str.length);\n for (var i = 0, len = buf.length; i < len; i++) {\n buf[i] = str.charCodeAt(i);\n }\n return buf;\n}\n\n\n// convert array to string\nfunction buf2string(buf, max) {\n var i, out, c, c_len;\n var len = max || buf.length;\n\n // Reserve max possible length (2 words per char)\n // NB: by unknown reasons, Array is significantly faster for\n // String.fromCharCode.apply than Uint16Array.\n var utf16buf = new Array(len * 2);\n\n for (out = 0, i = 0; i < len;) {\n c = buf[i++];\n // quick process ascii\n if (c < 0x80) { utf16buf[out++] = c; continue; }\n\n c_len = _utf8len[c];\n // skip 5 & 6 byte codes\n if (c_len > 4) { utf16buf[out++] = 0xfffd; i += c_len - 1; continue; }\n\n // apply mask on first byte\n c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07;\n // join the rest\n while (c_len > 1 && i < len) {\n c = (c << 6) | (buf[i++] & 0x3f);\n c_len--;\n }\n\n // terminated by end of string?\n if (c_len > 1) { utf16buf[out++] = 0xfffd; continue; }\n\n if (c < 0x10000) {\n utf16buf[out++] = c;\n } else {\n c -= 0x10000;\n utf16buf[out++] = 0xd800 | ((c >> 10) & 0x3ff);\n utf16buf[out++] = 0xdc00 | (c & 0x3ff);\n }\n }\n\n return _buf2binstring(utf16buf, out);\n}\n\n\n// Calculate max possible position in utf8 buffer,\n// that will not break sequence. If that's not possible\n// - (very small limits) return max size as is.\n//\n// buf[] - utf8 bytes array\n// max - length limit (mandatory);\nfunction utf8border(buf, max) {\n var pos;\n\n max = max || buf.length;\n if (max > buf.length) { max = buf.length; }\n\n // go back from last position, until start of sequence found\n pos = max - 1;\n while (pos >= 0 && (buf[pos] & 0xC0) === 0x80) { pos--; }\n\n // Fuckup - very small and broken sequence,\n // return max, because we should return something anyway.\n if (pos < 0) { return max; }\n\n // If we came to start of buffer - that means vuffer is too small,\n // return max too.\n if (pos === 0) { return max; }\n\n return (pos + _utf8len[buf[pos]] > max) ? pos : max;\n}\n\n/* Allowed flush values; see deflate() and inflate() below for details */\nvar Z_NO_FLUSH = 0;\nvar Z_SYNC_FLUSH = 2;\nvar Z_FINISH$1 = 4;\n/* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\nvar Z_OK$1 = 0;\nvar Z_STREAM_END$1 = 1;\nvar Z_NEED_DICT$1 = 2;\n//export var Z_MEM_ERROR = -4;\nvar Z_BUF_ERROR$1 = -5;\n\n// 'use strict';\n\nvar messages = {\n 2: 'need dictionary', /* Z_NEED_DICT 2 */\n 1: 'stream end', /* Z_STREAM_END 1 */\n 0: '', /* Z_OK 0 */\n '-1': 'file error', /* Z_ERRNO (-1) */\n '-2': 'stream error', /* Z_STREAM_ERROR (-2) */\n '-3': 'data error', /* Z_DATA_ERROR (-3) */\n '-4': 'insufficient memory', /* Z_MEM_ERROR (-4) */\n '-5': 'buffer error', /* Z_BUF_ERROR (-5) */\n '-6': 'incompatible version' /* Z_VERSION_ERROR (-6) */\n};\n\n// 'use strict';\n\n\nfunction ZStream() {\n /* next input byte */\n this.input = null; // JS specific, because we have no pointers\n this.next_in = 0;\n /* number of bytes available at input */\n this.avail_in = 0;\n /* total number of input bytes read so far */\n this.total_in = 0;\n /* next output byte should be put there */\n this.output = null; // JS specific, because we have no pointers\n this.next_out = 0;\n /* remaining free space at output */\n this.avail_out = 0;\n /* total number of bytes output so far */\n this.total_out = 0;\n /* last error message, NULL if no error */\n this.msg = ''/*Z_NULL*/;\n /* not visible by applications */\n this.state = null;\n /* best guess about the data type: binary or text */\n this.data_type = 2/*Z_UNKNOWN*/;\n /* adler32 value of the uncompressed data */\n this.adler = 0;\n}\n\n// 'use strict';\n\n\nfunction GZheader() {\n /* true if compressed data believed to be text */\n this.text = 0;\n /* modification time */\n this.time = 0;\n /* extra flags (not used when writing a gzip file) */\n this.xflags = 0;\n /* operating system */\n this.os = 0;\n /* pointer to extra field or Z_NULL if none */\n this.extra = null;\n /* extra field length (valid if extra != Z_NULL) */\n this.extra_len = 0; // Actually, we don't need it in JS,\n // but leave for few code modifications\n\n //\n // Setup limits is not necessary because in js we should not preallocate memory\n // for inflate use constant limit in 65536 bytes\n //\n\n /* space at extra (only when reading header) */\n // this.extra_max = 0;\n /* pointer to zero-terminated file name or Z_NULL */\n this.name = '';\n /* space at name (only when reading header) */\n // this.name_max = 0;\n /* pointer to zero-terminated comment or Z_NULL */\n this.comment = '';\n /* space at comment (only when reading header) */\n // this.comm_max = 0;\n /* true if there was or will be a header crc */\n this.hcrc = 0;\n /* true when done reading gzip header (not used when writing a gzip file) */\n this.done = false;\n}\n\n// 'use strict';\n\n\n// var zlib_inflate = require('./zlib/inflate');\n// var utils = require('./utils/common');\n// var strings = require('./utils/strings');\n// var c = require('./zlib/constants');\n// var msg = require('./zlib/messages');\n// var ZStream = require('./zlib/zstream');\n// var GZheader = require('./zlib/gzheader');\n\nvar toString = Object.prototype.toString;\n\n/**\n * class Inflate\n *\n * Generic JS-style wrapper for zlib calls. If you don't need\n * streaming behaviour - use more simple functions: [[inflate]]\n * and [[inflateRaw]].\n **/\n\n/* internal\n * inflate.chunks -> Array\n *\n * Chunks of output data, if [[Inflate#onData]] not overriden.\n **/\n\n/**\n * Inflate.result -> Uint8Array|Array|String\n *\n * Uncompressed result, generated by default [[Inflate#onData]]\n * and [[Inflate#onEnd]] handlers. Filled after you push last chunk\n * (call [[Inflate#push]] with `Z_FINISH` / `true` param) or if you\n * push a chunk with explicit flush (call [[Inflate#push]] with\n * `Z_SYNC_FLUSH` param).\n **/\n\n/**\n * Inflate.err -> Number\n *\n * Error code after inflate finished. 0 (Z_OK) on success.\n * Should be checked if broken data possible.\n **/\n\n/**\n * Inflate.msg -> String\n *\n * Error message, if [[Inflate.err]] != 0\n **/\n\n\n/**\n * new Inflate(options)\n * - options (Object): zlib inflate options.\n *\n * Creates new inflator instance with specified params. Throws exception\n * on bad params. Supported options:\n *\n * - `windowBits`\n * - `dictionary`\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information on these.\n *\n * Additional options, for internal needs:\n *\n * - `chunkSize` - size of generated data chunks (16K by default)\n * - `raw` (Boolean) - do raw inflate\n * - `to` (String) - if equal to 'string', then result will be converted\n * from utf8 to utf16 (javascript) string. When string output requested,\n * chunk length can differ from `chunkSize`, depending on content.\n *\n * By default, when no options set, autodetect deflate/gzip data format via\n * wrapper header.\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , chunk1 = Uint8Array([1,2,3,4,5,6,7,8,9])\n * , chunk2 = Uint8Array([10,11,12,13,14,15,16,17,18,19]);\n *\n * var inflate = new pako.Inflate({ level: 3});\n *\n * inflate.push(chunk1, false);\n * inflate.push(chunk2, true); // true -> last chunk\n *\n * if (inflate.err) { throw new Error(inflate.err); }\n *\n * console.log(inflate.result);\n * ```\n **/\nfunction Inflate(options) {\n if (!(this instanceof Inflate)) return new Inflate(options);\n\n this.options = assign({\n chunkSize: 16384,\n windowBits: 0,\n to: ''\n }, options || {});\n\n var opt = this.options;\n\n // Force window size for `raw` data, if not set directly,\n // because we have no header for autodetect.\n if (opt.raw && (opt.windowBits >= 0) && (opt.windowBits < 16)) {\n opt.windowBits = -opt.windowBits;\n if (opt.windowBits === 0) { opt.windowBits = -15; }\n }\n\n // If `windowBits` not defined (and mode not raw) - set autodetect flag for gzip/deflate\n if ((opt.windowBits >= 0) && (opt.windowBits < 16) &&\n !(options && options.windowBits)) {\n opt.windowBits += 32;\n }\n\n // Gzip header has no info about windows size, we can do autodetect only\n // for deflate. So, if window size not set, force it to max when gzip possible\n if ((opt.windowBits > 15) && (opt.windowBits < 48)) {\n // bit 3 (16) -> gzipped data\n // bit 4 (32) -> autodetect gzip/deflate\n if ((opt.windowBits & 15) === 0) {\n opt.windowBits |= 15;\n }\n }\n\n this.err = 0; // error code, if happens (0 = Z_OK)\n this.msg = ''; // error message\n this.ended = false; // used to avoid multiple onEnd() calls\n this.chunks = []; // chunks of compressed data\n\n this.strm = new ZStream();\n this.strm.avail_out = 0;\n\n var status = inflateInit2(\n this.strm,\n opt.windowBits\n );\n\n if (status !== Z_OK$1) {\n throw new Error(messages[status]);\n }\n\n this.header = new GZheader();\n\n inflateGetHeader(this.strm, this.header);\n}\n\n/**\n * Inflate#push(data[, mode]) -> Boolean\n * - data (Uint8Array|Array|ArrayBuffer|String): input data\n * - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.\n * See constants. Skipped or `false` means Z_NO_FLUSH, `true` meansh Z_FINISH.\n *\n * Sends input data to inflate pipe, generating [[Inflate#onData]] calls with\n * new output chunks. Returns `true` on success. The last data block must have\n * mode Z_FINISH (or `true`). That will flush internal pending buffers and call\n * [[Inflate#onEnd]]. For interim explicit flushes (without ending the stream) you\n * can use mode Z_SYNC_FLUSH, keeping the decompression context.\n *\n * On fail call [[Inflate#onEnd]] with error code and return false.\n *\n * We strongly recommend to use `Uint8Array` on input for best speed (output\n * format is detected automatically). Also, don't skip last param and always\n * use the same type in your code (boolean or number). That will improve JS speed.\n *\n * For regular `Array`-s make sure all elements are [0..255].\n *\n * ##### Example\n *\n * ```javascript\n * push(chunk, false); // push one of data chunks\n * ...\n * push(chunk, true); // push last chunk\n * ```\n **/\nInflate.prototype.push = function (data, mode) {\n var strm = this.strm;\n var chunkSize = this.options.chunkSize;\n var dictionary = this.options.dictionary;\n var status, _mode;\n var next_out_utf8, tail, utf8str;\n var dict;\n\n // Flag to properly process Z_BUF_ERROR on testing inflate call\n // when we check that all output data was flushed.\n var allowBufError = false;\n\n if (this.ended) { return false; }\n _mode = (mode === ~~mode) ? mode : ((mode === true) ? Z_FINISH$1 : Z_NO_FLUSH);\n\n // Convert data if needed\n if (typeof data === 'string') {\n // Only binary strings can be decompressed on practice\n strm.input = binstring2buf(data);\n } else if (toString.call(data) === '[object ArrayBuffer]') {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\n\n do {\n if (strm.avail_out === 0) {\n strm.output = new Uint8Array(chunkSize);\n strm.next_out = 0;\n strm.avail_out = chunkSize;\n }\n\n status = inflate(strm, Z_NO_FLUSH); /* no bad return value */\n\n if (status === Z_NEED_DICT$1 && dictionary) {\n // Convert data if needed\n if (typeof dictionary === 'string') {\n dict = string2buf(dictionary);\n } else if (toString.call(dictionary) === '[object ArrayBuffer]') {\n dict = new Uint8Array(dictionary);\n } else {\n dict = dictionary;\n }\n\n status = inflateSetDictionary(this.strm, dict);\n\n }\n\n if (status === Z_BUF_ERROR$1 && allowBufError === true) {\n status = Z_OK$1;\n allowBufError = false;\n }\n\n if (status !== Z_STREAM_END$1 && status !== Z_OK$1) {\n this.onEnd(status);\n this.ended = true;\n return false;\n }\n\n if (strm.next_out) {\n if (strm.avail_out === 0 || status === Z_STREAM_END$1 || (strm.avail_in === 0 && (_mode === Z_FINISH$1 || _mode === Z_SYNC_FLUSH))) {\n\n if (this.options.to === 'string') {\n\n next_out_utf8 = utf8border(strm.output, strm.next_out);\n\n tail = strm.next_out - next_out_utf8;\n utf8str = buf2string(strm.output, next_out_utf8);\n\n // move tail\n strm.next_out = tail;\n strm.avail_out = chunkSize - tail;\n if (tail) { arraySet(strm.output, strm.output, next_out_utf8, tail, 0); }\n\n this.onData(utf8str);\n\n } else {\n this.onData(shrinkBuf(strm.output, strm.next_out));\n }\n }\n }\n\n // When no more input data, we should check that internal inflate buffers\n // are flushed. The only way to do it when avail_out = 0 - run one more\n // inflate pass. But if output data not exists, inflate return Z_BUF_ERROR.\n // Here we set flag to process this error properly.\n //\n // NOTE. Deflate does not return error in this case and does not needs such\n // logic.\n if (strm.avail_in === 0 && strm.avail_out === 0) {\n allowBufError = true;\n }\n\n } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== Z_STREAM_END$1);\n\n if (status === Z_STREAM_END$1) {\n _mode = Z_FINISH$1;\n }\n\n // Finalize on the last chunk.\n if (_mode === Z_FINISH$1) {\n status = inflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return status === Z_OK$1;\n }\n\n // callback interim results if Z_SYNC_FLUSH.\n if (_mode === Z_SYNC_FLUSH) {\n this.onEnd(Z_OK$1);\n strm.avail_out = 0;\n return true;\n }\n\n return true;\n};\n\n\n/**\n * Inflate#onData(chunk) -> Void\n * - chunk (Uint8Array|Array|String): ouput data. Type of array depends\n * on js engine support. When string output requested, each chunk\n * will be string.\n *\n * By default, stores data blocks in `chunks[]` property and glue\n * those in `onEnd`. Override this handler, if you need another behaviour.\n **/\nInflate.prototype.onData = function (chunk) {\n this.chunks.push(chunk);\n};\n\n\n/**\n * Inflate#onEnd(status) -> Void\n * - status (Number): inflate status. 0 (Z_OK) on success,\n * other if not.\n *\n * Called either after you tell inflate that the input stream is\n * complete (Z_FINISH) or should be flushed (Z_SYNC_FLUSH)\n * or if an error happened. By default - join collected chunks,\n * free memory and fill `results` / `err` properties.\n **/\nInflate.prototype.onEnd = function (status) {\n // On success - join\n if (status === Z_OK$1) {\n if (this.options.to === 'string') {\n // Glue & convert here, until we teach pako to send\n // utf8 alligned strings to onData\n this.result = this.chunks.join('');\n } else {\n this.result = flattenChunks(this.chunks);\n }\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n};\n\n\n/**\n * inflate(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * Decompress `data` with inflate/ungzip and `options`. Autodetect\n * format via wrapper header by default. That's why we don't provide\n * separate `ungzip` method.\n *\n * Supported options are:\n *\n * - windowBits\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information.\n *\n * Sugar (options):\n *\n * - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify\n * negative windowBits implicitly.\n * - `to` (String) - if equal to 'string', then result will be converted\n * from utf8 to utf16 (javascript) string. When string output requested,\n * chunk length can differ from `chunkSize`, depending on content.\n *\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , input = pako.deflate([1,2,3,4,5,6,7,8,9])\n * , output;\n *\n * try {\n * output = pako.inflate(input);\n * } catch (err)\n * console.log(err);\n * }\n * ```\n **/\nfunction doInflate(input, options) {\n var inflator = new Inflate(options);\n\n inflator.push(input, true);\n\n // That will never happens, if you don't cheat with options :)\n if (inflator.err) { throw inflator.msg; }\n\n return inflator.result;\n}\n\nexport { doInflate as ungzip };","/**\n * @file Validation Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport XmlParser, { XmlParserParameters } from './xml-parser'\nimport Validation from '../structure/validation'\nimport Streamer from '../streamer/streamer';\n\nclass ValidationParser extends XmlParser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.useDomParser = true\n this.validation = new Validation(this.name, this.path)\n }\n\n get __objName () { return 'validation' }\n get isXml () { return true }\n\n _parse () {\n super._parse()\n\n if (Debug) Log.time('ValidationParser._parse ' + this.name)\n\n this.validation.fromXml(this.xml.data)\n\n if (Debug) Log.timeEnd('ValidationParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('validation', ValidationParser)\n\nexport default ValidationParser\n","/**\n * @file Gzip Decompressor\n * @author Alexander Rose \n * @private\n */\n\nimport { ungzip } from '../../lib/pako_inflate.es6'\n\nimport { DecompressorRegistry } from '../globals'\n\nfunction gzipDecompress (data: ArrayBuffer|Uint8Array) {\n let decompressedData\n\n if (data instanceof ArrayBuffer) {\n data = new Uint8Array(data)\n }\n\n try {\n decompressedData = ungzip(data as Uint8Array)\n } catch (e) {\n decompressedData = data // assume it is already uncompressed\n }\n\n return decompressedData\n}\n\nDecompressorRegistry.add('gz', gzipDecompress)\n","/**\n * @file Datasource\n * @author Alexander Rose \n * @private\n */\n\n/**\n * Datasource base class\n * @interface\n */\nabstract class Datasource {\n /**\n * Get full url\n * @abstract\n * @param {String} path - datasource string\n * @return {String} - url\n */\n abstract getUrl (path: string): string\n\n /**\n * Get file extension\n * @abstract\n * @param {String} path - datasource string\n * @return {String} - extension\n */\n abstract getExt (path: string): string\n}\n\nexport default Datasource\n","/**\n * @file RCSB Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { Log, DatasourceRegistry } from '../globals'\nimport { getProtocol } from '../utils'\nimport { getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nconst baseUrl = '//files.rcsb.org/download/'\nconst mmtfBaseUrl = '//mmtf.rcsb.org/v1.0/'\nconst mmtfFullUrl = mmtfBaseUrl + 'full/'\nconst mmtfReducedUrl = mmtfBaseUrl + 'reduced/'\n\nclass RcsbDatasource extends Datasource {\n getUrl (src: string) {\n // valid path are\n // XXXX.pdb, XXXX.pdb.gz, XXXX.cif, XXXX.cif.gz, XXXX.mmtf, XXXX.bb.mmtf\n // XXXX defaults to XXXX.cif\n const info = getFileInfo(src)\n const pdbid = info.name.substr(0, 4)\n let url\n if ([ 'pdb', 'cif' ].includes(info.ext) &&\n (info.compressed === false || info.compressed === 'gz')\n ) {\n url = baseUrl + info.path\n } else if (info.ext === 'mmtf') {\n if (info.base.endsWith('.bb')) {\n url = mmtfReducedUrl + pdbid\n } else {\n url = mmtfFullUrl + pdbid\n }\n } else if (!info.ext) {\n url = mmtfFullUrl + pdbid\n } else {\n Log.warn('unsupported ext', info.ext)\n url = mmtfFullUrl + pdbid\n }\n return getProtocol() + url\n }\n\n getExt (src: string) {\n const ext = getFileInfo(src).ext\n return ext ? ext : 'mmtf'\n }\n}\n\nDatasourceRegistry.add('rcsb', new RcsbDatasource())\n\nexport default RcsbDatasource\n","/**\n * @file PubChem Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { Log, DatasourceRegistry } from '../globals'\nimport { getProtocol } from '../utils'\nimport { getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nconst baseUrl = '//pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/'\nconst suffixUrl = '/SDF?record_type=3d'\n\nclass PubchemDatasource extends Datasource {\n getUrl (src: string) {\n const info = getFileInfo(src)\n const cid = info.name\n let url\n if (!info.ext || info.ext === 'sdf') {\n url = baseUrl + cid + suffixUrl\n } else {\n Log.warn('unsupported ext', info.ext)\n url = baseUrl + cid + suffixUrl\n }\n return getProtocol() + url\n }\n\n getExt (src: string) {\n const ext = getFileInfo(src).ext\n return ext ? ext : 'sdf'\n }\n}\n\nDatasourceRegistry.add('pubchem', new PubchemDatasource())\n\nexport default PubchemDatasource\n","/**\n * @file Pass Through Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { DatasourceRegistry } from '../globals'\nimport { getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nclass PassThroughDatasource extends Datasource {\n getUrl (path: string) {\n return path\n }\n\n getExt (path: string) {\n return getFileInfo(path).ext\n }\n}\n\nDatasourceRegistry.add('ftp', new PassThroughDatasource())\nDatasourceRegistry.add('http', new PassThroughDatasource())\nDatasourceRegistry.add('https', new PassThroughDatasource())\n\nexport default PassThroughDatasource\n","/**\r\n * @file Alphafold Datasource\r\n * @author Fredric Johansson \r\n * @private\r\n */\r\n\r\nimport { Log, DatasourceRegistry } from '../globals'\r\nimport { getProtocol } from '../utils'\r\nimport { getFileInfo } from '../loader/loader-utils'\r\nimport Datasource from './datasource'\r\n\r\nconst baseUrl = '//alphafold.ebi.ac.uk/files/AF-'\r\nconst suffixURL = '-F1-model_v2.pdb'\r\n\r\nclass AlphafoldDatasource extends Datasource {\r\n getUrl (src: string) {\r\n const info = getFileInfo(src)\r\n const uniprotid = info.name\r\n let url\r\n if (!info.ext || info.ext === 'pdb') {\r\n url = baseUrl + uniprotid + suffixURL\r\n } else {\r\n Log.warn('unsupported AF ext', info.ext)\r\n url = baseUrl + uniprotid + suffixURL\r\n }\r\n return getProtocol() + url\r\n }\r\n\r\n getExt (src: string) {\r\n const ext = getFileInfo(src).ext\r\n return ext ? ext : 'pdb'\r\n }\r\n}\r\n\r\nDatasourceRegistry.add('alphafold', new AlphafoldDatasource())\r\n\r\nexport default AlphafoldDatasource\r\n","/**\n * @file Static Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { getAbsolutePath } from '../utils'\nimport { getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nconst reProtocol = /^((http|https|ftp):)*\\/\\//\n\nclass StaticDatasource extends Datasource {\n baseUrl: string\n\n constructor (baseUrl: string = '') {\n super()\n this.baseUrl = baseUrl\n }\n\n getUrl (src: string) {\n const info = getFileInfo(src)\n let url = this.baseUrl + info.path\n if (!reProtocol.test(this.baseUrl)) {\n url = getAbsolutePath(url)\n }\n return url\n }\n\n getExt (src: string) {\n return getFileInfo(src).ext\n }\n}\n\nexport default StaticDatasource\n","/**\n * @file UI Parameters\n * @author Alexander Rose \n */\n\nimport { StageParameters } from '../stage/stage'\nimport { MouseActionPresets } from '../controls/mouse-actions'\n\nexport type BooleanParam = { type: 'boolean' }\nfunction BooleanParam () { return { type: 'boolean' } as BooleanParam }\n\nexport type ColorParam = { type: 'color' }\nfunction ColorParam () { return { type: 'color' } as ColorParam }\n\nexport type IntegerParam = { type: 'integer', max: number, min: number }\nfunction IntegerParam (max: number, min: number) {\n return { type: 'integer', max, min } as IntegerParam\n}\n\nexport type NumberParam = { type: 'number', precision: number, max: number, min: number }\nfunction NumberParam (precision: number, max: number, min: number) {\n return { type: 'number', precision, max, min } as NumberParam\n}\n\nexport type RangeParam = { type: 'range', step: number, max: number, min: number }\nfunction RangeParam (step: number, max: number, min: number) {\n return { type: 'range', step, max, min } as RangeParam\n}\n\nexport type SelectParam = { type: 'select', options: { [k: string]: string } }\nfunction SelectParam (...options: string[]) {\n return { type: 'select', options: options.reduce((o, k) => ({ ...o, [k]: k}), {}) } as SelectParam\n}\n\nexport type ParamType = BooleanParam|ColorParam|IntegerParam|NumberParam|RangeParam|SelectParam\n\nexport const UIStageParameters: { [k in keyof StageParameters]: ParamType } = {\n backgroundColor: ColorParam(),\n quality: SelectParam('auto', 'low', 'medium', 'high'),\n sampleLevel: RangeParam(1, 5, -1),\n impostor: BooleanParam(),\n workerDefault: BooleanParam(),\n rotateSpeed: NumberParam(1, 10, 0),\n zoomSpeed: NumberParam(1, 10, 0),\n panSpeed: NumberParam(1, 10, 0),\n clipNear: RangeParam(1, 100, 0),\n clipFar: RangeParam(1, 100, 0),\n clipDist: IntegerParam(200, 0),\n clipMode: SelectParam('scene', 'camera'),\n clipScale: SelectParam('relative', 'absolute'),\n fogNear: RangeParam(1, 100, 0),\n fogFar: RangeParam(1, 100, 0),\n cameraType: SelectParam('perspective', 'orthographic', 'stereo'),\n cameraEyeSep: NumberParam(3, 1.0, 0.01),\n cameraFov: RangeParam(1, 120, 15),\n lightColor: ColorParam(),\n lightIntensity: NumberParam(2, 10, 0),\n ambientColor: ColorParam(),\n ambientIntensity: NumberParam(2, 10, 0),\n hoverTimeout: IntegerParam(10000, -1),\n tooltip: BooleanParam(),\n mousePreset: SelectParam(...Object.keys(MouseActionPresets))\n}\n","/**\n * @file MDsrv Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { autoLoad, getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nclass MdsrvDatasource extends Datasource {\n baseUrl: string\n\n constructor (baseUrl: string = '') {\n super()\n this.baseUrl = baseUrl\n }\n\n getListing (path: string = '') {\n let url = `${this.baseUrl}dir/${path}`\n if (url[url.length - 1] !== '/') url += '/'\n return autoLoad(url, {\n ext: 'json'\n }).then((jsonData: any) => ({\n path: path,\n data: jsonData.data\n }))\n }\n\n getUrl (src: string) {\n const info = getFileInfo(src)\n return `${this.baseUrl}file/${info.path}${info.query}`\n }\n\n getCountUrl (src: string) {\n const info = getFileInfo(src)\n return `${this.baseUrl}traj/numframes/${info.path}${info.query}`\n }\n\n getFrameUrl (src: string, frameIndex: number|string) {\n const info = getFileInfo(src)\n return `${this.baseUrl}traj/frame/${frameIndex}/${info.path}${info.query}`\n }\n\n getFrameParams (src: string, atomIndices: (number|string)[]) {\n return `atomIndices=${atomIndices.join(';')}`\n }\n\n getPathUrl (src: string, atomIndex: number|string) {\n const info = getFileInfo(src)\n return `${this.baseUrl}traj/path/${atomIndex}/${info.path}${info.query}`\n }\n\n getExt (src: string) {\n return getFileInfo(src).ext\n }\n}\n\nexport default MdsrvDatasource\n","/**\n * @file Pdb Writer\n * @author Alexander Rose \n * @private\n */\n\nimport { sprintf } from 'sprintf-js'\n\nimport Writer from './writer'\nimport { defaults, ensureArray } from '../utils'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\n\n// http://www.wwpdb.org/documentation/file-format\n\n// Sample PDB line, the coords X,Y,Z are fields 5,6,7 on each line.\n// ATOM 1 N ARG 1 29.292 13.212 -12.751 1.00 33.78 1BPT 108\n\nconst AtomFormat =\n 'ATOM %5d %-4s %3s %1s%4d %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%1s%1s'\n\nconst HetatmFormat =\n 'HETATM%5d %-4s %3s %1s%4d %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%1s%1s'\n\nexport interface PdbWriterParams {\n renumberSerial: boolean\n remarks: string[]\n}\n\n/**\n * Create a PDB file from a Structure object\n */\nexport default class PdbWriter extends Writer {\n readonly mimeType = 'text/plain'\n readonly defaultName = 'structure'\n readonly defaultExt = 'pdb'\n\n renumberSerial: boolean\n remarks: string[]\n\n structure: Structure\n private _records: string[]\n\n /**\n * @param {Structure} structure - the structure object\n * @param {Object} params - parameters]\n */\n constructor (structure: Structure, params?: PdbWriterParams) {\n super()\n\n const p = Object.assign({}, params)\n\n this.renumberSerial = defaults(p.renumberSerial, true)\n this.remarks = ensureArray(defaults(p.remarks, []))\n\n this.structure = structure\n this._records = []\n }\n\n private _writeRecords () {\n this._records.length = 0\n\n this._writeTitle()\n this._writeRemarks()\n this._writeAtoms()\n }\n\n private _writeTitle () {\n // FIXME multiline if title line longer than 80 chars\n this._records.push(sprintf('TITLE %-74s', this.structure.name))\n }\n\n private _writeRemarks () {\n this.remarks.forEach(str => {\n this._records.push(sprintf('REMARK %-73s', str))\n })\n\n if (this.structure.trajectory) {\n this._records.push(sprintf(\n 'REMARK %-73s',\n \"Trajectory '\" + this.structure.trajectory.name + \"'\"\n ))\n this._records.push(sprintf(\n 'REMARK %-73s',\n `Frame ${(this.structure.trajectory as any).frame}` // TODO\n ))\n }\n }\n\n private _writeAtoms () {\n let ia = 1\n let im = 1\n let charge = \" \"\n let chargeSign = \" \"\n const hasModels = this.structure.modelStore.count > 1\n\n this.structure.eachModel(m => {\n if (hasModels) this._records.push(sprintf('MODEL %4d%-66s', im++, ''))\n\n m.eachAtom((a: AtomProxy) => {\n const formatString = a.hetero ? HetatmFormat : AtomFormat\n const serial = this.renumberSerial ? ia : a.serial\n\n // Formal PDB spec\n // Alignment of one-letter atom name such as C starts at column 14,\n // while two-letter atom name such as FE starts at column 13.\n\n // This, however, leaves Calcium and C-alpha ambiguous\n // The convention (from earlier versions of the spec, see 1992, and also: \n // https://www.cgl.ucsf.edu/chimera/docs/UsersGuide/tutorials/pdbintro.html#misalignment)\n // is that element is right-justified in 13-14, modifiers are left justified in columns 15-16\n // A single-character element symmbol should not appear in column 13 unless the atom name has four characters\n let atomname = a.atomname\n\n if (atomname.length === 1) {\n // Simple case\n atomname = ' ' + atomname\n } else if (atomname.length < 4) {\n // 2 or 3-letter name, if element symbol is single char and matches name, add a space\n if (a.element.length === 1 && atomname[0] === a.element) {\n atomname = ' ' + atomname\n }\n }\n\n if (a.formalCharge) { // Skip nulls and zeros\n charge = Math.abs(a.formalCharge).toPrecision(1)\n chargeSign = (a.formalCharge > 0) ? \"+\" : \"-\"\n } else {\n charge = \" \"\n chargeSign = \" \"\n }\n\n this._records.push(sprintf(\n formatString,\n\n serial,\n atomname,\n a.resname,\n defaults(a.chainname, ' '),\n a.resno,\n a.x, a.y, a.z,\n defaults(a.occupancy, 1.0),\n defaults(a.bfactor, 0.0),\n '', // segid\n defaults(a.element, ''),\n charge,\n chargeSign\n ))\n ia += 1\n }, this.structure.getSelection())\n\n if (hasModels) this._records.push(sprintf('%-80s', 'ENDMDL'))\n })\n\n this._records.push(sprintf('%-80s', 'END'))\n }\n\n getString () {\n console.warn('PdbWriter.getString() is deprecated, use .getData instead')\n return this.getData()\n }\n\n /**\n * Get string containing the PDB file data\n * @return {String} PDB file\n */\n getData () {\n this._writeRecords()\n return this._records.join('\\n')\n }\n}\n","/**\n * Writer class for sdf/mol files.\n */\n\nimport { sprintf } from 'sprintf-js'\n\nimport Writer from './writer'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\nimport BondProxy from '../proxy/bond-proxy'\n\n// Hard-coded chiral as false as we don't specify it any atoms\nconst CountFormat = '%3i%3i 0 0 0 0 0 0 0 0999 V2000'\nconst AtomLine = '%10.4f%10.4f%10.4f %-3s 0%3i 0 0 0'\nconst BondFormat = '%3i%3i%3i 0 0 0'\n\nclass SdfWriter extends Writer {\n readonly mimeType = 'text/plain'\n readonly defaultName = 'structure'\n readonly defaultExt = 'sdf'\n\n structure: Structure\n private _records: string[]\n\n /**\n * @param {Structure} structure - structure to write\n * @param {Object} params - parameters\n */\n constructor (structure: Structure) {\n super()\n\n this.structure = structure\n // Follow the pdb-writer example:\n this._records = []\n }\n\n get idString () {\n return this.structure.id\n }\n\n get titleString () {\n return ' ' + this.structure.title\n }\n\n get countsString () {\n return sprintf(\n CountFormat,\n this.structure.atomCount,\n this.structure.bondCount\n )\n }\n\n get chargeLines () {\n const pairs: [number, number][] = []\n this.structure.eachAtom(ap => {\n if (ap.formalCharge != null && ap.formalCharge !== 0) {\n pairs.push([ap.index, ap.formalCharge])\n }\n })\n const lines = []\n for (let i = 0; i < pairs.length; i += 8) {\n const nCharges = Math.min(8, pairs.length - i)\n let s = sprintf('M CHG%3i', nCharges)\n for (let j = i; j < i + nCharges; j++) {\n s += sprintf(' %3i %3i', pairs[j][0] + 1, pairs[j][1])\n }\n lines.push(s)\n }\n return lines\n }\n\n formatAtom (ap: AtomProxy) {\n let charge = 0\n if (ap.formalCharge != null && ap.formalCharge !== 0) {\n charge = 4 - ap.formalCharge\n }\n const line = sprintf(\n AtomLine, ap.x, ap.y, ap.z, ap.element, charge\n )\n if (line.length !== 48) { throw new Error('Incompatible atom for sdf format') }\n\n return line\n }\n\n formatBond (bp: BondProxy) {\n return sprintf(\n BondFormat,\n bp.atomIndex1 + 1,\n bp.atomIndex2 + 1,\n bp.bondOrder)\n }\n\n _writeRecords () {\n this._records.length = 0\n this._writeHeader()\n this._writeCTab()\n this._writeFooter()\n }\n\n _writeHeader () {\n this._records.push(this.idString, this.titleString, '')\n }\n\n _writeCTab () {\n this._records.push(this.countsString)\n this.structure.eachAtom(ap => {\n this._records.push(this.formatAtom(ap))\n })\n this.structure.eachBond(bp => {\n this._records.push(this.formatBond(bp))\n })\n this.chargeLines.forEach(line => {\n this._records.push(line)\n })\n this._records.push('M END')\n }\n\n _writeFooter () {\n this._records.push('$$$$')\n }\n\n getData () {\n this._writeRecords()\n return this._records.join('\\n')\n }\n}\n\nexport default SdfWriter\n","/**\n * @file STL Writer\n * @author Paul Pillot \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport Writer from './writer'\nimport IOBuffer from '../utils/io-buffer'\nimport Surface from '../surface/surface'\n\n// https://en.wikipedia.org/wiki/STL_(file_format)#ASCII_STL\n\n/**\n * Create an STL File from a surface Object (e.g. for 3D printing)\n *\n * @example\n * molsurf = new MolecularSurface(structure)\n * surf = molsurf.getSurface({type: 'av', probeRadius: 1.4})\n * stl = new StlWriter(surf)\n * stl.download('myFileName')\n */\nexport default class StlWriter extends Writer {\n readonly mimeType = 'application/vnd.ms-pki.stl'\n readonly defaultName = 'surface'\n readonly defaultExt = 'stl'\n\n surface: any // TODO\n\n /**\n * @param {Surface} surface - the surface to write out\n */\n constructor (surface: Surface) {\n super()\n\n this.surface = surface\n }\n\n /*\n * Get STL Binary data\n *\n * Adapted from: https://github.com/mrdoob/three.js/blob/master/examples/js/exporters/STLBinaryExporter.js\n * see https://en.wikipedia.org/wiki/STL_(file_format)#Binary_STL for the file format description\n *\n * @return {DataView} the data\n */\n getData () {\n const triangles = this.surface.index.length / 3\n const bufferLength = triangles * 2 + triangles * 3 * 4 * 4 + 80 + 4\n const output = new IOBuffer(bufferLength)\n\n output.skip(80) // skip header\n output.writeUint32(triangles)\n\n const vector = new Vector3()\n const vectorNorm1 = new Vector3()\n const vectorNorm2 = new Vector3()\n const vectorNorm3 = new Vector3()\n\n // traversing vertices\n for (let i = 0; i < triangles; i++) {\n const indices = [\n this.surface.index[i * 3],\n this.surface.index[i * 3 + 1],\n this.surface.index[i * 3 + 2]\n ]\n\n vectorNorm1.fromArray(this.surface.normal, indices[0] * 3)\n vectorNorm2.fromArray(this.surface.normal, indices[1] * 3)\n vectorNorm3.fromArray(this.surface.normal, indices[2] * 3)\n\n vector.addVectors(vectorNorm1, vectorNorm2).add(vectorNorm3).normalize()\n\n output.writeFloat32(vector.x)\n output.writeFloat32(vector.y)\n output.writeFloat32(vector.z)\n\n for (let j = 0; j < 3; j++) {\n vector.fromArray(this.surface.position, indices[j] * 3)\n\n output.writeFloat32(vector.x) // vertices\n output.writeFloat32(vector.y)\n output.writeFloat32(vector.z)\n }\n\n output.writeUint16(0) // attribute byte count\n }\n\n return new DataView(output.buffer)\n }\n}"],"names":["getQuery","id","window","m","RegExp","exec","location","search","decodeURIComponent","defaults","value","defaultValue","undefined","createParams","params","defaultParams","o","Object","assign","k","updateParams","newParams","getProtocol","protocol","match","getBrowser","ua","navigator","userAgent","test","openUrl","url","open","href","download","data","downloadName","isSafari","isChromeIos","a","document","createElement","str","replace","msSaveOrOpenBlob","FileReader","Blob","reader","onloadend","result","readAsDataURL","objectUrlCreated","URL","createObjectURL","style","display","body","appendChild","target","click","removeChild","revokeObjectURL","lexicographicCompare","elm1","elm2","binarySearchIndexOf","array","element","compareFunction","low","high","length","mid","cmp","rangeInSortedArray","min","max","indexLeft","leftRange","binarySearchForLeftRange","indexRight","rightRange","binarySearchForRightRange","uniqueArray","sort","filter","index","sorted","uint8ToString","u8a","chunkSize","c","i","push","String","fromCharCode","apply","subarray","join","getTypedArray","arrayType","arraySize","Int8Array","Int16Array","Int32Array","Uint8Array","Uint16Array","Uint32Array","Float32Array","Error","getUintArray","sizeOrArray","maxUint","ensureBuffer","buffer","ArrayBuffer","_ensureClassFromArray","constructor","Array","isArray","fromArray","ensureVector3","v","Vector3","ensureMatrix4","Matrix4","ensureQuaternion","q","Quaternion","ensureFloat32Array","arg","toLowerCaseString","toString","toLowerCase","Registry","name","this","_dict","add","key","get","names","keys","degToRad","deg","chars","split","uuid","generateUUID","r","rnd","Math","random","clamp","lerp","start","stop","alpha","spline","p0","p1","p2","p3","t","tension","v0","v1","t2","smoothstep","x","normalize","colorSpace","ScaleDefaultParameters","scale","mode","domain","reverse","tmpColor","Color","manageColor","_target","_name","descriptor","originalMethod","fromTo","bind","set","convertSRGBToLinear","getHex","Colormaker","parameters","structure","atomProxy","getAtomProxy","getScale","p","slice","chroma","out","colorToArray","color","offset","atomColorToArray","atom","atomColor","bondColor","bond","atomIndex1","atomIndex2","bondColorToArray","volumeColorToArray","volumeColor","positionColorToArray","coords","positionColor","kwd","SelectAllKeyword","SelectNoneKeyword","AtomOnlyKeywords","BACKBONE","SIDECHAIN","BONDED","RING","AROMATICRING","METAL","POLARH","ChainKeywords","POLYMER","WATER","SmallResname","NucleophilicResname","HydrophobicResname","AromaticResname","AmideResname","AcidicResname","BasicResname","ChargedResname","PolarResname","NonpolarResname","CyclicResname","AliphaticResname","atomTestFn","s","atomname","altloc","atomindex","keyword","inscode","resname","sstruc","resno","chainname","model","isBackbone","isSidechain","isBonded","isRing","isAromatic","HETERO","isHetero","PROTEIN","isProtein","NUCLEIC","isNucleic","RNA","isRna","DNA","isDna","isPolymer","isWater","HELIX","isHelix","SHEET","isSheet","TURN","isTurn","ION","isIon","SACCHARIDE","isSaccharide","isMetal","isPolarHydrogen","includes","modelIndex","residueTestFn","atomOffset","atomEnd","chainTestFn","entity","modelTestFn","makeTest","selection","fn","error","rules","n","negate","f","subTests","hasOwnProperty","and","operator","na","ret","ALL","NONE","filtered","fs","makeAtomTest","atomOnly","filteredSelection","makeResidueTest","residueOnly","makeChainTest","chainOnly","makeModelTest","modelOnly","Selection","string","signals","stringChanged","Signal","setString","type","silent","retSelection","newSelection","oldSelection","selectionStack","trim","charAt","substr","chunks","createNewContext","getPrevContext","pop","pushRule","rule","not","cu","toUpperCase","lastRule","indexOf","indexList","map","parseInt","b","console","resnameList","isNaN","sele","substring","chain","negate2","resi","resiSingle","resiRange","parseSele","e","message","residueTest","chainTest","modelTest","atomOnlyTest","residueOnlyTest","chainOnlyTest","modelOnlyTest","dispatch","isAllSelection","isNoneSelection","SelectionColormaker","super","colormakerList","selectionList","dataList","forEach","scheme","ColormakerRegistry","hasScheme","getScheme","ColormakerScales","OrRd","PuBu","BuPu","Oranges","BuGn","YlOrBr","YlGn","Reds","RdPu","Greens","YlGnBu","Purples","GnBu","Greys","YlOrRd","PuRd","Blues","PuBuGn","Viridis","Spectral","RdYlGn","RdBu","PiYG","PRGn","RdYlBu","BrBG","RdGy","PuOr","Set1","Set2","Set3","Dark2","Paired","Pastel1","Pastel2","Accent","rainbow","rwb","ColormakerModes","rgb","hsv","hsl","hsi","lab","hcl","getWorkerDeps","vars","deps","sym","__deps","prototype","makeWorkerString","onmessage","__name","postId","__postId","self","func","callback","aMessage","transferList","postMessage","makeWorkerBlob","Browser","SupportsPassiveEventHandler","opts","defineProperty","addEventListener","Mobile","orientation","SupportsReadPixelsFloat","setSupportsReadPixelsFloat","ExtensionFragDepth","setExtensionFragDepth","Log","log","Function","call","info","warn","time","timeEnd","MeasurementDefaultParams","labelColor","labelAttachment","labelSize","labelZOffset","labelYOffset","labelBorder","labelBorderColor","labelBorderWidth","lineOpacity","linewidth","opacity","labelUnit","arcVisible","planeVisible","Debug","ScriptExtensions","WorkerRegistry","activeWorkerCount","_funcDict","_depsDict","_blobDict","schemes","userSchemes","SchemeClass","getSchemes","types","getScales","getModes","addScheme","label","_createScheme","_addUserScheme","removeScheme","_Colormaker","addSelectionScheme","DatasourceRegistry","RepresentationRegistry","ParserRegistry","__hasObjName","objName","parser","__objName","isTrajectory","isStructure","isVolume","isSurface","isBinary","isXml","isJson","getTrajectoryExtensions","getStructureExtensions","getVolumeExtensions","getSurfaceExtensions","ShaderRegistry","DecompressorRegistry","ComponentRegistry","BufferRegistry","PickerRegistry","exports","ListingDatasource","TrajectoryDatasource","Streamer","src","newline","__pointer","__partialLine","compressed","binary","json","xml","read","_read","then","decompressFn","_chunk","end","chunk","peekLines","charCodeAt","count","chunkToLines","lines","chunkCount","floor","asText","partialLine","isLast","idx","lastIndexOf","str2","concat","nextChunk","nextChunkOfLines","d","eachChunk","round","eachChunkOfLines","chunkNo","dispose","FileStreamer","Promise","resolve","reject","file","onload","event","onerror","readAsArrayBuffer","readAsText","NetworkStreamer","xhr","XMLHttpRequest","status","response","statusText","responseType","send","Loader","ext","dir","path","streamerParams","File","streamer","ParserLoader","parserParams","voxelSize","firstModelOnly","asTrajectory","cAlphaOnly","delimiter","comment","columnNames","inferBonds","load","parse","Script","functionBody","elementAdded","elementRemoved","nameChanged","run","stage","ScriptLoader","getFileInfo","compressedExtList","queryIndex","query","base","nameSplit","protocolMatch","getDataInfo","datasource","getUrl","getExt","autoLoad","loader","Writer","getBlob","getData","mimeType","defaultName","defaultExt","charArray","IOBuffer","_mark","_marks","littleEndian","dataIsGiven","byteLength","dvOffset","byteOffset","_lastWrittenByte","_data","DataView","available","isLittleEndian","setLittleEndian","isBigEndian","setBigEndian","skip","seek","mark","reset","pushMark","popMark","rewind","ensureAvailable","newLength","newArray","readBoolean","readUint8","readInt8","getInt8","getUint8","readByte","readBytes","bytes","readInt16","getInt16","readUint16","getUint16","readInt32","getInt32","readUint32","getUint32","readFloat32","getFloat32","readFloat64","getFloat64","readChar","readChars","writeBoolean","writeUint8","writeInt8","setInt8","_updateLastWrittenByte","setUint8","writeByte","writeBytes","writeInt16","setInt16","writeUint16","setUint16","writeInt32","setInt32","writeUint32","setUint32","writeFloat32","setFloat32","writeFloat64","setFloat64","writeChar","writeChars","toArray","Counter","countChanged","signalsWrapper","clear","change","delta","increment","decrement","listen","counter","unlisten","has","remove","onZeroOnce","context","Stats","updated","maxDuration","Infinity","minDuration","avgDuration","lastDuration","prevFpsTime","lastFps","lastFrames","frames","begin","update","startTime","currentTime","performance","now","reInclude","shaderCache","getShader","defines","hash","definesText","getDefines","shaderText","ShaderChunk","WebGLRenderingContext","wrcp","_getShaderParameter","getShaderParameter","arguments","_getShaderInfoLog","getShaderInfoLog","_getProgramParameter","getProgramParameter","program","pname","LINK_STATUS","_getProgramInfoLog","getProgramInfoLog","JitterVectors","offsetList","TiledRenderer","renderer","camera","viewer","canvas","_viewer","_factor","factor","_antialias","antialias","_onProgress","onProgress","_onFinish","onFinish","_n","_width","width","_height","height","_ctx","getContext","_viewerSampleLevel","sampleLevel","setSampling","_renderTile","offsetX","offsetY","setViewOffset","render","w","h","drawImage","domElement","ceil","_finalize","view","renderAsync","setTimeout","TwoPI","PI","RAD2DEG","circularMean","stride","indices","cosMean","sinMean","angle","cos","sin","atan2","calculateCenterArray","array1","array2","center","calculateDirectionArray","direction","uniformArray","optionalTarget","uniformArray3","j","serialArray","serialBlockArray","replicateArrayEntries","repArr","copyArray","dst","srcOffset","dstOffset","copyWithin","arrayMax","il","arrayMin","arraySum","sum","arrayMean","ImageDefaultParameters","transparent","makeImage","originalClearAlpha","getClearAlpha","backgroundColor","getClearColor","setLineWidthAndPixelSize","invert","scene","traverse","material","uniforms","size","__seen","trimCanvas","bg","g","canvasHeight","canvasWidth","pixels","getImageData","y","doBreak","off","topY","topX","bottomY","bottomX","trimedCanvas","_trimCanvas","finished","tiledRenderer","toBlob","blob","setClearAlpha","requestRender","vertex","matrix","modelViewProjectionMatrix","resolution","Vector2","projectionMatrixInverse","projectionMatrixTranspose","updateCameraUniforms","group","getInverse","projectionMatrix","copy","transpose","u","loadShader","gl","shaderSource","shaderType","shader","createShader","compileShader","COMPILE_STATUS","deleteShader","getExtension","TextureTestTexCoords","testTextureSupport","vertShader","VERTEX_SHADER","fragShader","FRAGMENT_SHADER","shaders","attribs","locations","createProgram","attachShader","attrib","bindAttribLocation","linkProgram","deleteProgram","useProgram","positionLocation","getAttribLocation","colorLoc","getUniformLocation","positionBuffer","createBuffer","bindBuffer","ARRAY_BUFFER","bufferData","STATIC_DRAW","enableVertexAttribArray","vertexAttribPointer","FLOAT","whiteTex","createTexture","whiteData","bindTexture","TEXTURE_2D","texImage2D","RGBA","UNSIGNED_BYTE","tex","texParameteri","TEXTURE_MIN_FILTER","NEAREST","TEXTURE_MAG_FILTER","fb","createFramebuffer","bindFramebuffer","FRAMEBUFFER","framebufferTexture2D","COLOR_ATTACHMENT0","checkFramebufferStatus","FRAMEBUFFER_COMPLETE","uniform4fv","drawArrays","TRIANGLES","clearColor","COLOR_BUFFER_BIT","pixel","readPixels","floatPixel","getError","NO_ERROR","INVALID_ENUM","INVALID_VALUE","INVALID_OPERATION","INVALID_FRAMEBUFFER_OPERATION","OUT_OF_MEMORY","CONTEXT_LOST_WEBGL","getErrorDescription","pixelBufferFloat","pixelBufferUint","pixelOrder","tmpMatrix","onBeforeRender","geometry","updateList","objectId","modelViewMatrixInverse","modelViewMatrixInverseTranspose","modelViewProjectionMatrixInverse","modelViewMatrix","multiplyMatrices","matrixWorldInverse","matrixWorld","materialProperties","properties","pu","getUniforms","setValue","Viewer","idOrElement","boundingBox","Box3","boundingBoxSize","boundingBoxLength","memory","programs","geometries","textures","calls","vertices","faces","points","distVector","ticked","rendered","elm","getElementById","container","HTMLElement","innerWidth","innerHeight","box","getBoundingClientRect","overflow","wrapper","position","_initParams","_initStats","_initCamera","_initScene","_initRenderer","_initHelper","setBackground","setFog","animate","fogColor","fogNear","fogFar","cameraType","cameraFov","cameraEyeSep","cameraZ","clipNear","clipFar","clipDist","clipMode","clipScale","lightColor","lightIntensity","ambientColor","ambientIntensity","rendererEncoding","LinearEncoding","lookAt","perspectiveCamera","PerspectiveCamera","z","orthographicCamera","OrthographicCamera","stereoCamera","StereoCamera","aspect","eyeSep","updateProjectionMatrix","stats","Scene","rotationGroup","Group","translationGroup","modelGroup","pickingGroup","backgroundGroup","helperGroup","fog","Fog","spotLight","SpotLight","ambientLight","AmbientLight","dpr","devicePixelRatio","WebGLRenderer","preserveDrawingBuffer","innerHTML","setPixelRatio","setSize","autoClear","sortObjects","outputEncoding","capabilities","isWebGL2","extensions","supportsHalfFloat","dprWidth","dprHeight","JSON","stringify","OES_texture_float","OES_texture_half_float","WEBGL_color_buffer_float","pickingTarget","WebGLRenderTarget","minFilter","NearestFilter","magFilter","stencilBuffer","format","RGBAFormat","FloatType","UnsignedByteType","texture","generateMipmaps","encoding","setRenderTarget","sampleTarget","LinearFilter","holdTarget","compositeUniforms","tForeground","Uniform","compositeMaterial","ShaderMaterial","vertexShader","fragmentShader","premultipliedAlpha","blending","AdditiveBlending","depthTest","depthWrite","compositeCamera","compositeScene","Mesh","PlaneGeometry","positions","bbGeometry","BufferGeometry","setIndex","BufferAttribute","setAttribute","bbMaterial","uColor","boundingBoxMesh","LineSegments","updateHelper","attributes","needsUpdate","isEmpty","computeBoundingSphere","cameraDistance","abs","instanceList","instance","addBuffer","wireframeGroup","background","pickable","setUserData","object","children","userData","mesh","getMesh","applyMatrix4","wireframeMesh","getWireframeMesh","quaternion","pickingMesh","getPickingMesh","_updateBoundingBox","updateBoundingBox","instanceMatrix","updateGeometry","computeBoundingBox","geoBoundingBox","clone","equals","expandByScalar","union","updateNode","node","makeEmpty","getSize","getPickingPixels","imgBuffer","readRenderTargetPixels","getImage","picking","imgBuffer2","ctx","imgData","putImageData","setLight","intensity","near","far","setClearColor","getStyle","level","setOutputEncoding","setColorWorkflow","sRGBEncoding","setCamera","fov","up","updateZoom","setClip","dist","left","right","top","bottom","handleResize","updateInfo","rInfo","rMemory","rRender","triangles","isStill","currentSampleLevel","renderPending","frameRequest","requestAnimationFrame","pick","pid","picker","pixelBuffer","oid","getObjectById","tan","zoom","absoluteToRelative","bRadius","relativeToAbsolute","__updateClipping","isFinite","getWorldPosition","cDist","nearFactor","farFactor","fogNearFactor","fogFarFactor","__updateCamera","updateMatrix","updateMatrixWorld","pixelRatio","getPixelRatio","ortho","nearClip","updateMaterialUniforms","traverseVisible","Points","sortParticles","sortData","sortArray","zArray","cmpFn","indexSrc","indexDst","tmpTab","__zArray","__sortArray","__cmpFn","ai","bi","arr","stack","tmp","sp","swap","tmp2","quicksortCmp","attr","itemSize","sortProjectedPosition","__setVisibility","helper","visible","__updateLights","setLength","__renderPickingGroup","__renderModelGroup","renderTarget","__renderSuperSample","baseSampleWeight","sampleWeight","clearViewOffset","__renderStereo","_renderTarget","setScissorTest","setScissor","setViewport","cameraL","__render","cameraR","lastRenderedPicking","rendering","cancelAnimationFrame","getTouchDistance","dx","touches","pageX","dy","pageY","sqrt","MouseObserver","moved","scrolled","dragged","dropped","clicked","hovered","doubleClicked","prevPosition","down","canvasPosition","prevClickCP","moving","hovering","lastMoved","which","buttons","pressed","altKey","ctrlKey","metaKey","shiftKey","touchAction","hoverTimeout","handleScroll","doubleClickSpeed","_listen","_onMousewheel","_onMousemove","_onMousedown","_onMouseup","_onContextmenu","_onTouchstart","_onTouchend","_onTouchmove","opt","passive","setParameters","cp","doubleClickPending","lastClicked","overElement","preventDefault","_setKeys","deltaY","deltaMode","WheelEvent","DOM_DELTA_PIXEL","DOM_DELTA_LINE","wheelDelta","wheelDeltaY","detail","clientX","clientY","_setCanvasPosition","button","getMouseButtons","_distance","distanceTo","lastTouchDistance","touchDistance","removeEventListener","tmpRotateXMatrix","tmpRotateYMatrix","tmpRotateZMatrix","tmpRotateMatrix","tmpRotateCameraMatrix","tmpRotateVector","tmpRotateQuaternion","tmpRotateQuaternion2","tmpPanMatrix","tmpPanVector","tmpAtomVector","TrackballControls","rotateSpeed","zoomSpeed","panSpeed","mouse","mouseObserver","controls","viewerControls","component","transformComponent","transformAtom","_setPanVector","scaleFactor","getCanvasScaleFactor","multiplyScalar","_getRotateXY","_getCameraRotation","extractRotation","multiply","makeRotationY","_transformPanVector","transform","premultiply","pan","translate","panComponent","panAtom","positionToVector3","positionAdd","updateRepresentations","rotate","setFromAxisAngle","makeRotationFromQuaternion","applyMatrix","zRotate","dz","makeRotationZ","rotateComponent","makeRotationAxis","setFromRotationMatrix","tmpVec","PickingProxy","pickingData","getComponentsByObject","list","getObject","getPosition","closestBondAtom","atom1","v2","atom2","acp1","getPositionOnCanvas","acp2","closeAtom","ca","acp","radius","getMaxRepresentationRadius","arrow","_objectIfType","axes","cone","clash","contact","cylinder","distance","ellipsoid","octahedron","point","sphere","tetrahedron","torus","surface","unitcell","unknown","volume","wideline","getLabel","msg","qualifiedName","sele1","sele2","serial","shape","toPrecision","spacegroup","PickingControls","pickerArray","tmpQ","tmpP","tmpS","tmpCanvasVector","tmpScaleVector","tmpAlignMatrix","ViewerControls","changed","rotation","project","getCameraDistance","getOrientation","setPosition","orient","decompose","setRotationFromQuaternion","vector","spin","axis","rotateOnAxis","align","basis","setRotationFromMatrix","Animation","duration","args","pausedTime","elapsedDuration","pausedDuration","ignoreGlobalToggle","_paused","_resolveList","_init","done","paused","tick","_tick","pause","hold","_hold","resume","releaseHold","toggle","SpinAnimation","RockAnimation","angleSum","angleStep","angleEnd","MoveAnimation","moveFrom","moveTo","lerpVectors","ZoomAnimation","zoomFrom","zoomTo","RotateAnimation","_currentRotation","rotateFrom","rotateTo","slerp","ValueAnimation","valueFrom","valueTo","TimeoutAnimation","AnimationList","_list","every","animation","AnimationControls","animationList","finishedList","splice","rock","move","zoomMove","orientTo","timeout","spinComponent","rockComponent","moveComponent","Queue","argList","queue","pending","next","shift","kill","Representation","lazy","step","clipRadius","precision","clipCenter","flatShaded","side","options","front","back","double","wireframe","colorData","colorScheme","colorScale","colorReverse","colorValue","colorDomain","colorMode","roughness","metalness","diffuse","diffuseInterior","useInteriorColor","interiorColor","interiorDarkening","disablePicking","rebuild","tasks","make","bufferList","toBePrepared","init","setColor","quality","lazyProps","build","bufferParams","what","tp","sphereDetail","radialSegments","openEnded","disableImpostor","getColorParams","getBufferParams","val","prepare","cb","create","updateWhat","_make","manualAttach","disposed","attach","setVisibility","noRenderRequest","updateParameters","int","float","parseFloat","getParameters","_Worker","postCount","onmessageDict","onerrorDict","blobUrl","worker","Worker","post","__debug","terminate","WorkerPool","maxCount","pool","getNextWorker","nextWorker","minPending","calculateMeanVector3","projectPointOnVector","origin","sub","projectOnVector","minX","minY","minZ","maxX","maxY","maxZ","l","v3new","applyMatrix4toVector3array","applyMatrix3toVector3array","normalizeVector3array","len2","v3cross","ax","ay","az","bx","by","bz","v3dot","v3sub","v3add","v3fromArray","v3toArray","input","v3length2","v3length","v3divideScalar","v3multiplyScalar","v3normalize","length2","v3subScalar","v3addScalar","v3floor","v3ceil","v3negate","v3angle","cx","cy","cz","getFixedCountDashData","segmentCount","position1","sn3","position2","i3","j3","f1","f2","replicateArray3Entries","color2","primitiveId","getFixedLengthDashData","segmentLength","pos1","pos2","col","rad","getFixedLengthWrappedDashData","remaining","drawing","k3","kprev","vl","inv","Primitive","Picker","Buffer","static","_primitiveData","getShapeKey","fields","valueToShape","expandBoundingBox","valueFromShape","arrayFromShape","dataFromShape","SpherePrimitive","expandByPoint","BoxPrimitive","heightAxis","depthAxis","OctahedronPrimitive","TetrahedronPrimitive","CylinderPrimitive","dashedCylinder","ArrowPrimitive","ConePrimitive","EllipsoidPrimitive","majorAxis","minorAxis","TorusPrimitive","TextPrimitive","text","PointPrimitive","WidelinePrimitive","SpatialHash","exp","bb","createBoundingBox","boundX","boundY","boundZ","an","xArray","yArray","grid","bucketIndex","bucketCount","bucketOffset","bucketFill","bucketArray","bucketIdx","within","eachWithin","atomIndex","rSq","loX","loY","loZ","hiX","hiY","hiZ","ix","iy","iz","dSq","Store","_fields","_defaultFields","_initField","addField","resize","tmpArray","growIfFull","copyFrom","other","thisOffset","otherOffset","thisField","otherField","thisIndex","otherIndex","offsetTarget","offsetSource","targetIndex","sourceIndex","thisStore","tmpStore","quicksort","pivot","leftNew","rightNew","index1","index2","ContactStore","addContact","hammingWeight","BitArray","setAll","_words","flip","_assignRange","words","wordValue","wordStart","wordEnd","startWord","endWord","setRange","clearRange","setBits","clearBits","clearAll","flipAll","bs","_isRangeValue","isRangeSet","isRangeClear","isAllSet","isAllClear","isSet","isClear","isEqualTo","otherBitarray","words1","words2","difference","intersection","intersects","getIntersectionSize","makeIntersection","wordsA","answer","pos","toSeleString","createAdjacencyList","edges","edgeCount","nodeCount","nodeArray1","nodeArray2","countArray","offsetArray","bondCount2","indexArray","idx1","idx2","j1","j2","createFeatureState","atomSet","addAtom","state","addFeature","features","groups","centers","atomSets","UnknownBackboneType","ChemCompProtein","ChemCompRna","ChemCompDna","ChemCompSaccharide","ChemCompHetero","SecStrucHelix","SecStrucSheet","SecStrucTurn","AtomicNumbers","H","D","T","HE","LI","BE","B","C","N","O","F","NE","NA","MG","AL","SI","P","S","CL","AR","K","CA","SC","TI","V","CR","MN","FE","CO","NI","CU","ZN","GA","GE","AS","SE","BR","KR","RB","SR","Y","ZR","NB","MO","TC","RU","RH","PD","AG","CD","IN","SN","SB","TE","I","XE","CS","BA","LA","CE","PR","ND","PM","SM","EU","GD","TB","DY","HO","ER","TM","YB","LU","HF","TA","W","RE","OS","IR","PT","AU","HG","TL","PB","BI","PO","AT","RN","FR","RA","AC","TH","PA","U","NP","PU","AM","CM","BK","CF","ES","FM","MD","NO","LR","RF","DB","SG","BH","HS","MT","DS","RG","CN","NH","FL","MC","LV","TS","OG","VdwRadii","CovalentRadii","Valences","OuterShellElectronCounts","ResidueHydrophobicity","ALA","ARG","ASN","ASP","ASH","CYS","GLN","GLU","GLH","GLY","HIS","ILE","LEU","LYS","MET","PHE","PRO","SER","THR","TRP","TYR","VAL","DefaultResidueHydrophobicity","AA1","SEC","PYL","AA3","RnaBases","DnaBases","PurinBases","Bases","WaterNames","IonNames","SaccharideNames","ProteinBackboneAtoms","NucleicBackboneAtoms","ResidueTypeAtoms","trace","direction1","direction2","backboneStart","backboneEnd","PDBQTSpecialElements","HD","A","NS","OA","SA","G0","G1","G2","G3","CG0","CG1","CG2","CG3","assignGeometry","totalCoordination","Angles","Map","calcAngles","ap1","ap2","angles","d1","d2","subVectors","eachBondedAtom","number","angleTo","calcPlaneAngle","x1","v12","neighbours","ni","cross","ValenceModel","atomCount","charge","implicitH","totalH","idealGeometry","eachAtom","chg","implH","totH","geom","hydrogenCount","bondToElementCount","formalCharge","assignCharge","assignH","degree","bondCount","valence","eachBond","bondOrder","explicitValence","conjugated","_bp","getBondProxy","atomicNumber","hetero","flag","a2","getOtherAtom","b2","atomicNumber2","isConjugated","multiBond","implicitHCount","ba","oa","calculateHydrogensCharge","valenceModel","isPhosphate","PositvelyCharged","NegativelyCharged","isIonicInteraction","ti","tj","isPiStacking","isCationPi","isHistidineNitrogen","ap","isHydrogenBond","isWeakHydrogenBond","IonicTypeMetals","isMetalComplex","halBondElements","X","OptimalHalogenAngle","OptimalAcceptorAngle","invalidAtomContact","masterIdx","isMasterContact","ContactDefaultParams","maxHydrophobicDist","maxHbondDist","maxHbondSulfurDist","maxHbondAccAngle","maxHbondDonAngle","maxHbondAccPlaneAngle","maxHbondDonPlaneAngle","maxPiStackingDist","maxPiStackingOffset","maxPiStackingAngle","maxCationPiDist","maxCationPiOffset","maxIonicDist","maxHalogenBondDist","maxHalogenBondAngle","maxMetalDist","refineSaltBridges","masterModelIndex","lineOfSightDistFactor","residueIndex","calculateFeatures","atomInGroupDict","eachResidue","addGroup","terminalNitrogenCount","isGuanidine","isAcetamidine","addPositiveCharges","isSulfonicAcid","isSulfate","terminalOxygenCount","isCarboxylate","addNegativeCharges","rings","getAromaticRings","ring","addAromaticRings","totalBonds","ig","addHydrogenAcceptors","addHydrogenDonors","ringData","residueType","getRings","hasElement","some","residueAtomOffset","atomTypeId","atomTypeIdList","atomMap","inAromaticRingWithElectronNegativeElement","addWeakHydrogenDonors","dative","ionic","isStandardAminoacid","isStandardBase","isHalogen","addMetalBinding","isTransitionMetal","addMetals","addHydrophobic","addHalogenAcceptors","addHalogenDonors","calculateContacts","contacts","spatialHash","contactStore","featureSet","createContacts","maxDistance","maxPiStackingDistSq","maxCationPiDistSq","atomStore","areAtomSetsWithinDist","atomSet1","atomSet2","maxDist","sn","sm","si","sj","v3","n1","n2","getNormal","atoms","normal","crossVectors","getOffset","projectOnPlane","ct","addChargedContacts","maxHbondDistSq","donor","acceptor","isWeak","connectedTo","donorAngles","idealDonorAngle","donorAngle","outOfPlane","acceptorAngles","idealAcceptorAngle","acceptorAngle","bondType","isWaterHydrogenBond","isBackboneHydrogenBond","addHydrogenBonds","m1","m2","addMetalComplexation","addHydrophobicContacts","halogen","halogenAngles","addHalogenBonds","frozenContacts","adjacencyList","contactSet","createFrozenContacts","ac1","ac2","aw","c1","c2","lineOfSightDist","lineOfSightDistFactorSq","as1","as2","vdw","distanceToSquared","refineLineOfSight","residueContactDict","handleResidueContact","minDist","minIndex","refineHydrophobicContacts","ionicInteractionDict","isHydrogenBondType","iil1","iil2","piStackingDict","pil1","pil2","refinePiStacking","refineMetalCoordination","contactTypeName","ContactDataDefaultParams","hydrogenBond","hydrophobic","halogenBond","ionicInteraction","metalCoordination","cationPi","piStacking","weakHydrogenBond","waterHydrogenBond","backboneHydrogenBond","filterSele","getContactData","filterSet","getAtomSet","setHex","contactColor","ContactPicker","getIndex","_applyTransformations","_getPosition","ShapePicker","primitive","objectFromShape","positionFromShape","AtomPicker","AxesPicker","BondPicker","bondStore","bp","center1","center2","addVectors","ClashPicker","validation","clashArray","_getAtomProxyFromSele","getAtomIndices","DistancePicker","IgnorePicker","MeshPicker","__position","SurfacePicker","UnitcellPicker","getCenter","VolumePicker","vol","dp","SlicePicker","getEdgeTable","getTriTable","MarchingCubes","field","nx","ny","nz","normalCache","vertexIndex","icount","mx","my","mz","allowedContours","isolevel","noNormals","contour","wrap","isNegativeIso","normalFactor","yd","zd","ilist","positionArray","normalArray","atomindexArray","edgeTable","triTable","VIntX","valp1","valp2","_q","mu","nc","q3","VIntY","q6","VIntZ","compNorm","polygonize","fx","fy","fz","edgeFilter","q1","qy","qz","q1y","q1z","qyz","q1yz","cubeindex","field0","field1","field2","field3","field4","field5","field6","field7","bits","fx2","fy2","fz2","e1","e2","e3","triIndex","triangulate","xBeg","yBeg","zBeg","xEnd","yEnd","zEnd","yOffset","zOffset","xBeg2","yBeg2","zBeg2","xEnd2","yEnd2","zEnd2","__break","__xBeg","__yBeg","__zBeg","__xEnd","__yEnd","__zEnd","_isolevel","_noNormals","_box","_contour","_wrap","vIndexLength","Matrix","cols","rows","copyTo","At","nrows","ncols","Ai","Ati","pAt","ad","atd","multiplyABt","Ap","pA","pB","Cp","mrows","bd","cd","multiply3x3","Cd","Ad","Bd","m10","m11","m12","m13","m14","m15","m16","m17","m18","m20","m21","m22","m23","m24","m25","m26","m27","m28","meanRows","mean","subRows","row","i0","i1","hypot","EPSILON","FLT_MIN","svd","at","_m","amt","wmt","vmt","astep","_W","Vt","vstep","eps","minval","iter","maxIter","Aj","Vi","Vj","t0","t1","sd","beta","gamma","seed","val0","asum","Float64Array","JacobiSVDImpl","m4new","m4set","n11","n12","n13","n14","n21","n22","n23","n24","n31","n32","n33","n34","n41","n42","n43","n44","m4multiply","a11","a12","a13","a14","a21","a22","a23","a24","a31","a32","a33","a34","a41","a42","a43","a44","b11","b12","b13","b14","b21","b22","b23","b24","b31","b32","b33","b34","b41","b42","b43","b44","m4makeScale","m4makeTranslation","m4makeRotationY","theta","m3new","m3makeNormal","m4","r0","r1","r2","laplacianSmooth","verts","numiter","inflate","nv","nf","norms","tps","vertdeg","jl","flagvert","ao","bo","co","vi3","vdi","wtvi","wt2vi","wt2","outwt","computeVertexNormals","nv3","ab","ci","getRadiusDict","radiusList","radiusDict","getSurfaceGrid","maxRadius","extraMargin","margin","dim","maxSize","pow","tmpSize","tran","mroty","mscale","mtrans","Surface","Geometry","fromGeometry","setFromArray","geo","getColor","colormaker","tc","getPicking","getFilteredIndex","filteredIndex","elementSize","include","getAtomindex","VolumeSurface","mc","getSurface","smooth","normalMatrix","volsurf","Volume","Matrix3","inverseMatrix","setData","setAtomindex","_position","_min","_max","_mean","_rms","setStats","rms","setMatrix","me","elements","ne","getBox","_getBox","__box","_makeSurface","getValueForSigma","getSurfaceWorker","workerPool","sigma","getSigmaForValue","getDataAtomindex","getDataPosition","getDataColor","getDataPicking","getDataSize","_sum","sumSq","di","arrayRms","header","getThreeSide","FrontSide","BackSide","DoubleSide","setObjectMatrix","matrixWorldNeedsUpdate","BufferDefaultParameters","opaqueBack","forceTransparent","BufferParameterTypes","updateShader","property","uniform","updateVisibility","parameterTypes","indexVersion","wireframeIndexVersion","isImpostor","isText","isPoint","isLine","dynamic","wireframeIndexCount","defaultParameters","UniformsUtils","merge","UniformsLib","common","emissive","lights","pickingUniforms","_positionDataSize","addAttributes","initIndex","makeWireframeGeometry","attributeSize","nindex","setUsage","DYNAMIC_DRAW","makeMaterial","vertexColors","derivatives","fragDepth","wm","pm","NoBlending","wireframeMaterial","pickingMaterial","makeWireframeIndex","wireframeIndex","wireframeGeometry","setDrawRange","checkEdge","drawRange","updateWireframeIndex","updateRange","getRenderOrder","renderOrder","_getMesh","materialName","frustumCulled","getVertexShader","getFragmentShader","NEAR_CLIP","RADIUS_CLIP","PICKING","NOLIGHT","FLAT_SHADED","OPAQUE_BACK","DIFFUSE_INTERIOR","USE_INTERIOR_COLOR","addUniforms","buf","updateRenderOrder","setRenderOrder","pt","pv","propertyData","uniformData","doShaderUpdate","doVisibilityUpdate","setProperties","setUniforms","setAttributes","attribute","wu","isVector3","toJSON","MeshBuffer","SurfaceBuffer","setVisibilityTrue","setVisibilityFalse","DoubleSidedBuffer","frontMeshes","backMeshes","frontBuffer","backBuffer","ContourBuffer","SurfaceRepresentation","isolevelType","negateIsolevel","isolevelScroll","boxSize","colorVolume","useWorker","boxCenter","__boxCenter","setBox","__isolevel","__smooth","__contour","__wrap","__boxSize","onSurfaceFinish","surfaceBuffer","dullInterior","surfaceData","MouseActions","trackballControls","focus","getFocus","sign","almostIdentity","setFocus","eachRepresentation","reprElem","comp","repr","pickingProxy","animationControls","tt","tooltip","mp","innerText","measurePick","measureClear","MouseActionPresets","default","zoomScroll","focusScroll","zoomFocusScroll","rotateDrag","panDrag","zRotateDrag","zoomDrag","zoomFocusDrag","panComponentDrag","rotateComponentDrag","movePick","tooltipPick","pymol","coot","astexviewer","triggerFromString","tokens","MouseControls","actionList","disabled","preset","triggerStr","wildcard","action","KeyActions","autoView","toggleRock","toggleSpin","KeyActionPresets","toggleAnimations","toggleAntialiasing","KeyControls","char","PickingBehavior","mouseControls","_onClick","_onHover","pickingControls","MouseBehavior","_onMove","_onScroll","_onDrag","_onDblclick","AnimationBehavior","_onTick","KeyBehavior","keyControls","outline","_focusDomElement","_onKeydown","_onKeyup","_onKeypress","pressedKey","KeyboardEvent","keyCode","Annotation","content","_viewerPosition","_updateViewerPosition","_canvasPosition","_cameraPosition","pointerEvents","whiteSpace","setContent","_update","matrixChanged","displayValue","padding","fontFamily","_clientRect","getVisibility","vp","cr","depth","zIndex","ComponentControls","RadiusFactoryTypes","covalent","bfactor","explicit","RadiusFactory","atomRadius","negateVector","PrincipalAxes","n3","pointsT","vm","van","vbn","vcn","va","vb","vc","begA","endA","begB","endB","begC","endC","vecA","vecB","vecC","normVecA","normVecB","normVecC","getBasisMatrix","makeBasis","determinant","getRotationQuaternion","inverse","getProjectedScaleForAtoms","d1a","d1b","d2a","d2b","d3a","d3b","ax1","ax2","ax3","dp1","dot","dt1","dp2","dt2","dp3","dt3","FilteredVolume","minValue","maxValue","outside","setFilter","_getFilterHash","DMEAN","ARMS","filterHash","_filterHash","_dataBuffer","_positionBuffer","_atomindexBuffer","filteredData","filteredPosition","filteredAtomindex","BondHash","al","BondStore","addBond","ai1","ai2","addBondIfConnected","AtomStore","setAltloc","getAltloc","code","ResidueStore","setSstruc","getSstruc","setInscode","getInscode","ChainStore","setChainname","getChainname","setChainid","chainid","getChainid","ModelStore","Helixorient","polymer","residueCount","getCenterIterator","cache","idx3","residueIndexStart","rp","getResidueProxy","traceAtomIndex","radiusFactory","diff","rise","twist","resdir","r12","r23","r34","diff13","diff24","vt","_axis","_prevAxis","_resdir","_center","a1","getAtomIndexByType","a3","a4","acos","diff13Length","diff24Length","resRadius","resTwist","resRise","resBending","resAxis","bending","Helixbundle","helixorient","getAxis","localAngle","centerDist","ssBorder","colorParams","radiusParams","beg","residueOffset","tmpAxis","tmpCenter","_beg","_end","rp1","rp2","BinaryHeap","scoreFunction","bubbleUp","sinkDown","peek","len","parentN","parent","elemScore","child1Score","child2Score","child2N","child1N","child1","child2","Kdtree","metric","maxDepth","currentNode","nodes","rootIndex","buildTree","arrBegin","arrEnd","plength","nodeIndex","arrMedian","currentDim","pivotIndex","pivotValue","storeIndex","getNodeDepth","parentIndex","nearest","maxNodes","bestNodes","nearestSearch","bestChild","otherChild","dimension","pointIndex","ownPoint","ownDistance","saveNode","leftIndex","rightIndex","linearPoint","linearDistance","verify","AtomProxy","chainStore","residueStore","residueMap","bondHash","entityList","entityIndex","chainIndex","residue","residueTypeId","atomType","occupancy","partialCharge","aromatic","_ap","hasBondTo","bap","hasBondToElement","backboneIndexList","moleculeType","isCg","backboneType","isTrace","atomRings","isNonmetal","isMetalloid","isDiatomicNonmetal","isPolyatomicNonmetal","isAlkaliMetal","isAlkalineEarthMetal","isNobleGas","isPostTransitionMetal","isLanthanide","isActinide","getDefaultValence","getValenceList","getOuterShellElectronCount","taa","aaa","distSquared","ta","aa","positionFromArray","positionToArray","positionFromVector3","positionSub","getResidueBonds","firstOnly","relativeIndex","bonds","getBonds","atomIndices1","atomIndices2","connectedAtomIndex","connectedAtomIndices","noResname","modelStore","toObject","euclideanDistSq","euclideanDist","pointArray","useSquaredDist","atomIndices","kdtree","_Kdtree","nodeList","resultList","SymOpCode","$","E","G","J","L","M","Q","R","Z","_","EncodedSymOp","reInteger","selectionFromChains","chainList","Assembly","partList","addPart","matrixList","part","AssemblyPart","getAtomCount","reduce","getResidueCount","getInstanceCount","instanceCount","isIdentity","structureChainList","eachChain","getBoundingBox","partBox","getSelection","_getCount","propertyName","instanceBox","structureBox","getView","getInstanceList","StructureBuilder","currentModelindex","currentChainid","currentResname","currentResno","currentInscode","currentHetero","previousResname","previousHetero","ri","mi","addResidueType","modelindex","addModel","addChain","addResidue","chainOffset","chainCount","finalize","assignSecondaryStructure","secStruct","chainnames","eachModel","chainnamesSorted","chainnamesIndex","helices","h1","h2","helix","helixRun","chainChange","sheets","s1","s2","strandCharCode","sheet","sheetRun","calculateSecondaryStructure","zhangSkolnickSS","distances","isHelical","eachPolymer","cgPolymer","proteinPolymer","prevSstruc","sstrucCount","ChainnameAlphabet","calculateChainnames","useExistingBonds","doAutoChainName","mIndex","rOffset","rCount","rStart","rEnd","chainData","eachResidueN","newChain","bbType1","bbType2","bbTypeUnk","backboneEndAtomIndex","backboneStartAtomIndex","fill","calculateBonds","calculateBondsWithin","calculateBondsBetween","BondOrderTable","getBondOrderFromTable","atomname1","atomname2","onlyAddRung","rungBondStore","rungAtomSet","atomBondMap","calculateAtomBondMap","bondedAtoms","Set","rai","bondOrders","nn","rai1","rai2","getBondIndex","rungEndAtomIndex","atomSetDict","rung","onlyAddBackbone","backboneBondStore","backboneAtomSet","needsBond","needsBackbone","backbone","buildUnitcellAssembly","uc","structureCenterFrac","cartToFrac","centerFrac","symopDict","encodedSymopList","matrixDict","symopList","symop","denominator","integer","getSymmetryOperations","centerFracSymop","positionFracSymop","getMatrixList","setFromMatrixPosition","fracToCart","unitcellAssembly","unitcellMatrixList","ncsMatrixList","biomolDict","NCS","ncsUnitcellMatrixList","nm","vec","supercellAssembly","supercellMatrixList","ncsSupercellMatrixList","UNITCELL","SUPERCELL","guessElement","atomName","assignResidueTypeBonds","bondDict","nextAtomOffset","AlkaliMetals","AlkalineEarthMetals","PolyatomicNonmetals","DiatomicNonmetals","NobleGases","PostTransitionMetals","Metalloids","Halogens","AtomType","no","AtomMap","dict","getHash","ResidueType","chemCompType","bondReferenceAtomIndices","getMoleculeType","getBackboneType","backboneEndType","backboneStartType","getBackboneIndexList","atomnames","atomnamesStart","atomnamesEnd","traceIndex","getAtomIndexByName","dir1Index","direction1AtomIndex","dir2Index","direction2AtomIndex","bbStartIndex","bbEndIndex","rungEndIndex","atomnameList","hasProteinBackbone","hasRnaBackbone","hasDnaBackbone","hasCgProteinBackbone","hasCgRnaBackbone","hasCgDnaBackbone","hasAtomWithName","hasBackboneAtoms","hasBackbone","end1","maxd","nearestAtoms","calculateResidueBonds","calculateRings","getBondGraph","bondGraph","calculateBondGraph","getAromatic","aromaticAtoms","calculateAromatic","aromaticRings","nb","capacity","visited","pred","RingFinderMaxDepth","currentColor","RingFinderState","findRings","aromaticRingFlags","AromaticRingElements","AromaticRingPlanarityThreshold","isRingAromatic","assignBondReferenceAtomIndices","refRing","rings1","rings2","ri1","ai3","_idx2","getBondReferenceAtomIndex","bondIndex","addRing","current","leftOffset","rightOffset","found","rn","ringOffset","from","head","ResidueMap","BondProxy","_v12","_v13","_ap1","_ap2","_ap3","getOtherAtomIndex","getReferenceAtomIndex","typeAtomIndex1","typeAtomIndex2","calculateShiftDir","ap3","v13","ResidueProxy","getChainProxy","getAtomType","getResname1","getAtomnameList","rNext","bbAtomEnd","bbAtomStart","getNextConnectedResidue","nextIndex","rpNext","rpFirst","getPreviousConnectedResidue","residueProxy","prevIndex","rpPrev","rpLast","Polymer","residueIndexEnd","rpStart","rpEnd","isPrevConnected","isNextConnected","isNextNextConnected","isCyclic","__residueProxy","aIndex","eachAtomN","rStartIndex","ChainProxy","getModelProxy","residueEnd","_rp","rNextIndex","first","ModelProxy","chainEnd","_cp","Structure","refreshed","title","extraData","atomSetCache","boxes","bondSet","finalizeAtoms","finalizeBonds","getBondSet","getBackboneBondSet","backboneBondSet","__backbone","getRungBondSet","rungBondSet","__rung","seleString","getAtomSetWithinSelection","getAtomSetWithinPoint","getAtomSetWithinVolume","fv","getMaxScaleOnAxis","getAtomSetWithinGroup","atomResidueIndex","getStructure","eachEntity","getEntityType","mn","cn","getAtomData","atomData","getBondData","multipleBond","isMulti","isOffset","bondScale","bondSpacing","bondData","storeBondOrder","radius2","absOffset","multiRadius","vShortening","vShift","getBackboneAtomData","getBackboneBondData","getRungAtomData","getRungBondData","getPrincipalAxes","atomCenter","hasCoords","_hasCoords","getSequence","seq","getChainnameCount","updatePosition","refresh","refreshPosition","tmpBox","Primitives","ShapeDefaultParameters","aspectRatio","labelParams","pointSize","sizeAttenuation","useTexture","Shape","meshCount","addMesh","meshBuffer","addSphere","objectToShape","addEllipsoid","addTorus","addCylinder","addCone","addArrow","addBox","addOctahedron","addTetrahedron","addText","addPoint","addWideline","addLabel","getBufferList","buffers","bufferFromShape","BufferRepresentation","GeometryBuffer","geoPosition","geoIndex","meshPosition","meshNormal","meshColor","meshIndex","updateNormals","geoNormal","positionCount","geoPositionCount","transformedGeoPosition","transformedGeoNormal","makeIndex","initNormals","makeTranslation","applyPositionTransform","getNormalMatrix","o3","SphereGeometryBufferDefaultParameters","SphereGeometryBuffer","IcosahedronBufferGeometry","_radius","MappedBuffer","mappingType","indexSize","mapping","mappingSize","mappingIndicesSize","nullValueAttributes","getAttributeIndex","dataIndex","makeMapping","mappingItemSize","aMapping","mappingIndices","it","MappedQuadBuffer","SphereImpostorBuffer","SphereBuffer","x0","y0","y1","PointBufferDefaultParameters","alphaTest","edgeBleach","PointBufferParameterTypes","PointBuffer","makeTexture","DataTexture","makePointTexture","USE_SIZEATTENUATION","USE_MAP","ALPHATEST","DotRepresentation","thresholdType","thresholdMin","thresholdMax","thresholdOut","dotType","radiusType","deviation","dotData","dotBuffer","quadIndices","quadUvs","ImageBufferDefaultParameters","ImageBufferParameterTypes","ImageBuffer","alwaysTransparent","hasWireframe","imageData","flipY","pickingTex","pickingMap","mapSize","startsWith","CUBIC_INTERPOLATION","endsWith","BSPLINE_FILTER","CATMULROM_FILTER","MITCHELL_FILTER","updateTexture","NormalBlending","VolumeSlice","positionType","getPositionFromCoordinate","coord","ms","setFromMatrixScale","vn","dimLen","z0","setVec","pickingArray","tMin","tMax","SliceRepresentation","linear","percent","coordinate","volumeSlice","sliceBuffer","logReprUnknown","ElementDefaultParameters","Element","statusChanged","setStatus","setName","RepresentationElementDefaultParameters","RepresentationElement","visibilityChanged","parametersChanged","setRepresentation","getType","_disposeRepresentation","hasRepresentation","removeRepresentation","toggleVisibility","setSelection","_v","ComponentDefaultParameters","Component","representationAdded","representationRemoved","reprList","annotationList","setRotation","Euler","setFromEuler","setScale","setTransform","getCenterUntransformed","makeScale","updateRepresentationMatrices","addAnnotation","annotation","eachAnnotation","removeAnnotation","removeAllAnnotations","_addRepresentation","hidden","impostor","workerDefault","ReprClass","makeRepresentation","addBufferRepresentation","removeAllRepresentations","getBoxUntransformed","getZoom","getZoomForBox","Collection","_remove","RepresentationCollection","TrajectoryElementDefaultParameters","defaultStep","defaultTimeout","defaultInterpolateType","defaultInterpolateStep","defaultMode","defaultDirection","initialFrame","TrajectoryElement","trajectory","frameChanged","playerChanged","player","setFrame","Frames","coordinates","times","timeOffset","deltaTime","Superposition","atoms1","atoms2","VH","coords1","coords2","coords1t","coords2t","transformationMatrix","prepCoords","_superpose","mean1","mean2","to","invA","t4","t5","t8","t9","t11","t13","t14","t15","t17","t18","t20","t21","t23","t26","invert3x3","md","mat3x3determinant","transformMat_","tmp_1","tmp_2","mult","M1","M2","is4X4","tCoords","det","_pB","mcols","invertTrasform","mat","n4","TrajectoryPlayerDefaultParameters","interpolateType","interpolateStep","TrajectoryPlayer","traj","startedRunning","haltedRunning","_run","_previousTime","_currentTime","_currentStep","frameCount","_currentFrame","_direction","_animate","isRunning","dt","inProgress","_nextInterpolated","hasFrame","ip","ipp","ippp","setFrameInterpolated","loadFrame","_next","currentFrame","play","setPlayer","frame","Trajectory","trajPath","frameCache","loadQueue","boxCache","pathCache","frameCacheSize","_frameCount","_disposed","centerPbc","removePbc","removePeriodicity","superpose","selectionIndices","_resetCache","_saveInitialCoords","setStructure","_loadFrameCount","backboneIndices","_getIndices","_makeAtomIndices","_saveStructureCoords","initialCoords","structureCoords","_makeSuperposeCoords","resetCache","_updateStructure","_interpolate","fc","cpp","cppp","j0","interpolateSpline","interpolateLerp","iList","_loadFrame","_doSuperpose","_process","_setFrameCount","box2","circMean","circularMean3","arrayMean3","getFrameTime","FramesTrajectory","StructureTrajectory","RemoteTrajectory","request","getFrameUrl","getFrameParams","setRequestHeader","arrayBuffer","getCountUrl","CallbackTrajectory","requestCallback","StructureView","seleList","parentSelection","ignoreView","blosum62x","prepareMatrix","cellNames","matDict","rowDict","SubstitutionMatrices","blosum62","Alignment","seq1","seq2","gapPenalty","gapExtensionPenalty","substMatrix","initMatrices","score","ali","gap","makeScoreFn","calc","gap0","scoreFn","Vi1","Si1","Hi","Si","ali1","ali2","_s1","_s2","_i","_j","aliIdx1","aliIdx2","_atoms1","_atoms2","StructureComponentDefaultParameters","defaultAssembly","StructureComponent","trajList","trajectoryAdded","trajectoryRemoved","defaultAssemblyChanged","initSelection","pickBuffer","pointer","item","createRingBuffer","pickDict","del","values","createSimpleDict","spacefillRepresentation","addRepresentation","distanceRepresentation","angleRepresentation","dihedralRepresentation","measureRepresentations","setDefaultAssembly","structureView","rebuildRepresentations","rebuildTrajectories","reprParams","trajComp","reprComp","measureUpdate","addTrajectory","trajSrc","makeTrajectory","removeTrajectory","getAtomRadius","pickCount","lastPick","atomList","atomListSorted","atomPair","atomTriple","atomQuad","measureBuild","measureData","dihedral","pickData","radiusData","removeAllMeasurements","pd","removeMeasurement","addMeasurement","SurfaceComponent","VolumeComponent","ComponentCollection","matchName","tmpZoomVector","StageDefaultParameters","mousePreset","ShapeComponent","__decorate","decorators","desc","getOwnPropertyDescriptor","Reflect","decorate","AtomindexColormaker","scalePerModel","BfactorColormaker","bfactorScale","ChainidColormaker","chainidDictPerModel","chainidDict","ChainindexColormaker","ChainnameColormaker","chainnameDictPerModel","chainnameDict","DensityfitColormaker","rsrzDict","rsccDict","rsrzScale","rsccScale","rsrz","rscc","partialCharges","CZ","CG","OD1","CB","OD2","OE1","OE2","CD2","CE1","ND1","NE2","NZ","SD","PTR","O1P","O2P","O3P","OG1","SEP","TPO","CD1","CE2","CE3","NE1","OH","ElectrostaticColormaker","hCharges","charges","hPositions","hPos","backboneNHPosition","bbox","hStore","buildStoreLike","hHash","ElementColors","UUT","UUP","UUH","ElementColormaker","EntityindexColormaker","entityindexScale","EntitytypeColormaker","entityType","GeoqualityColormaker","geoAtomDict","geoDict","geoProblemCount","geoAtom","atomProblems","HydrophobicityColormaker","resHF","defaultResidueHydrophobicity","hfScale","ModelindexColormaker","modelindexScale","MoleculetypeColormaker","OccupancyColormaker","occupancyScale","PartialchargeColormaker","partialchargeScale","randomColor","RandomColormaker","RandomcoilindexColormaker","rciDict","rciScale","rci","ResidueindexColormaker","scalePerChain","ResidueColors","ASX","GLX","DA","DG","DI","DX","DC","DT","DU","DD","ResnameColormaker","StructureColors","SstrucColormaker","StructuredataColormaker","_a","_b","UniformColormaker","valueColor","ValueColormaker","valueScale","VolumeColormaker","nxy","i1y","i1z","iyz","i1yz","vy","vz","v1y","v1z","vyz","v1yz","xd","c00","c01","c10","c11","c0","StructureRepresentation","radiusSize","radiusScale","assembly","biomolOptions","defaultScale","setRadius","getQuality","getAssembly","needsBuild","sview","createData","updateData","getRadiusParams","param","getAtomParams","getBondParams","MeasurementRepresentation","labelVisible","labelFontFamily","monospace","serif","labelFontStyle","italic","labelFontWeight","bold","labelsdf","labelXOffset","labelBackground","labelBackgroundColor","labelBackgroundMargin","labelBackgroundOpacity","labelFixedSize","labelFontstyle","textData","textBuffer","getLabelBufferParams","fontStyle","fontWeight","sdf","xOffset","attachment","showBorder","borderColor","borderWidth","showBackground","backgroundMargin","backgroundOpacity","fixedSize","parseNestedAtoms","nSets","order","selected","_break","Number","isInteger","calcArcPoint","edt","edt1d","MIN_SAFE_INTEGER","MAX_SAFE_INTEGER","TextAtlasCache","TextAtlasDefaultParams","font","variant","weight","TextAtlas","mapped","scratchW","scratchH","currentX","currentY","cutoff","lineHeight","maxWidth","fillStyle","textAlign","textBaseline","lineJoin","gridOuter","gridInner","canvas2","context2","placeholder","CanvasTexture","draw","measureText","clearRect","fillText","TextBufferDefaultParameters","fontSize","TextBufferParameterTypes","getCharCount","charCount","TextBuffer","fontTexture","inputTexCoord","inputSize","aPosition","aColor","txt","iChar","nChar","iCharAll","textAtlas","getTextAtlas","inputMapping","xadvance","xShift","yShift","texWidth","texHeight","texCoords","FIXED_SIZE","WideLineBufferDefaultParameters","WideLineBufferParameterTypes","WideLineBuffer","AngleRepresentation","vectorVisible","sectorVisible","atomPosition","okay","outPosition","outIdx","validatePositions","atomTriplePositions","angleData","labelPosition","labelText","vectorPosition1","vectorPosition2","arcPositionTmp1","arcPositionTmp2","sectorPositionTmp","totalSegments","v21","v23","cross2","labelTmp","arcPoint","crossLength","toFixed","nSegments","sectorVertices","arcVertices1","arcVertices2","appendArcSection","arcSize","sectorSize","arcPosition1","arcPosition2","sectorPosition","sectorOffset","arcOffset","getAngleData","vectorBuffer","arcLength","arcBuffer","sectorLength","sectorBuffer","vectorData","arcData","sectorData","eye","CylinderGeometryBufferDefaultParameters","getGeo","makeRotationX","CylinderBufferGeometry","CylinderGeometryBuffer","geoLength","__center","_color","_from","_to","meshData","MappedAlignedBoxBuffer","CylinderImpostorBufferDefaultParameters","CylinderImpostorBufferParameterTypes","CylinderImpostorBuffer","CAP","CylinderBuffer","AxesRepresentation","showAxes","showBox","getAxesData","pa","en","vertexPosition","vertexColor","vertexRadius","edgePosition1","edgePosition2","edgeColor","edgeRadius","addAxis","offset2","addCorner","d3","addScaledVector","edgeOffset","addEdge","edge","axesData","sphereBuffer","cylinderBuffer","sphereData","cylinderData","BallAndStickRepresentation","lineOnly","cylinderOnly","symmetric","lineBuffer","lineData","BackboneRepresentation","BaseRepresentation","Interpolator","vec1","vec2","vDir","vTan","vNorm","vBin","interpolateToArr","interpolateToVec","interpolatePosition","interpolateTangent","vectorSubdivide","interpolationFn","iterator","getTangent","interpolateNormalDir","u0","u1","u2","u3","norm","bin","interpolateNormal","getNormalDir","iterDir1","iterDir2","vSub1","vSub2","vSub3","vSub4","d1v1","d1v2","d1v3","d1v4","d2v1","d2v2","d2v3","d2v4","interpolateColor","item1","item2","colFn","interpolatePicking","pickFn","interpolateSize","sizeFn","Spline","directional","positionIterator","subdiv","smoothSheet","interpolator","getAtomIterator","cache2","apPrev","apNext","getSubdividedColor","nCol","getSubdividedPicking","getSubdividedPosition","getSubdividedOrientation","normals","getNormals","tangent","binormal","getSubdividedSize","nSize","nPos","nTan","nNorm","vTangent","vMeshNormal","TubeMeshBufferDefaultParameters","capped","TubeMeshBuffer","capVertices","capTriangles","xi","size2","meshPrimitiveId","normX","normY","normZ","biX","biY","biZ","posX","posY","posZ","cxArr","cyArr","cx1Arr","cy1Arr","cx2Arr","cy2Arr","cx1","cy1","cx2","cy2","radialSegments1","irs","irs1","strip","CartoonRepresentation","NaN","getSplineParams","getSpline","getAspectRatio","polymerList","subPos","subOri","subCol","subPick","subSize","ContactRepresentation","angstrom","dataParams","contactData","unit","getLabelData","DihedralRepresentation","extendLine","lineVisible","dihedralData","lineTmp1","lineTmp2","sectorTmp","planeTmp","totalLines","totalPlanes","p4","v34","inPlane1","inPlane2","improperStart","improperEnd","nLines","nPlanes","line1","line2","sector","plane","li","nSuccess","linePosition1","linePosition2","planePosition","lineOffset","planeOffset","lp1","lp2","pp","getDihedralData","lineLength","lineColor","planeLength","planeBuffer","planeData","createUpdatedObject","updateSource","hasKey","obj","createColorArray","arrayLength","targetArray","DihedralHistogramRepresentation","histogramsData","histogramBinBorderVisible","scaleBinToSectorArea","histogramBinBorderColor","adjacentBondArrowColor","distantBondArrowColor","frontHistogramColor","backHistogramColor","opaqueMiddleDiscColor","histogramOpacity","opaqueMiddleDiscVisible","opaqueMiddleDiscOpacity","histogramBinBorderWidth","histogramBinBorderOpacity","bondArrowVisible","bondArrowWidth","bondArrowOpacity","specificColorData","getHistogramBinBorderBufferParameters","getBondArrowsBufferParameters","getOpaqueMiddleDiscBufferParameters","getHistogramBufferParameters","atomPositions","scaleData","Float32Concat","arrays","lengths","accumulatedOffset","createWideLineBuffer","linesList","startPoints","endPoints","startColors","endColors","createMeshBuffer","triangleColors","histogram360Scaled","histogram360","dihedralDataArray","currentHistogramData","calculateDihedralHistogram","frontHistogramBinBordersBuffer","frontHistogramBinBorders","backHistogramBinBordersBuffer","backHistogramBinBorders","adjacentBondArrowsBuffer","adjacentBondArrows","distantBondArrowsBuffer","distantBondArrows","opaqueMiddleDiscBuffer","opaqueMiddleDisc","frontHistogramBuffer","frontHistogram","backHistogramBuffer","backHistogram","histogramData","positionOfDihedralAtoms","histogram","totalSectorTrianglesInOpaqueMiddleDisc","frontAndBack","v32","cross1","dihedralAtomVectors","absAngle","maxHist","histBinAngleStep","setHistogramBinCoordinates","ind","zeroDegreeVector","crossVector","startOffset","scalingFactor","setOneSideHistogram","discHistogram","binBorders","sectionIndex","opaqueCircleSectorAngleStep","DistanceRepresentation","useCylinder","getDistanceData","pair","distanceData","bondParams","distanceBuffer","VectorBufferDefaultParameters","VectorBuffer","HelixorientRepresentation","LicoriceRepresentation","MappedBoxBuffer","HyperballStickImpostorBufferDefaultParameters","shrink","HyperballStickImpostorBufferParameterTypes","HyperballStickImpostorBuffer","HyperballStickBuffer","calculateMinArray","HyperballRepresentation","stickData","LabelFactory","errorLogged","atomLabel","aa1","sprintf","res","qualified","LabelRepresentation","labelType","labelFormat","labelGrouping","getTextData","labelFactory","positionN","sizeN","colorN","getLoneAtomSet","LineRepresentation","crosses","lone","all","crossSize","_crossData","crossData","attrSize","cPosition1","cPosition2","cColor","cColor2","cOffset","cimax","crossBuffer","bufferIdx","lineAttributes","crossAttributes","makeGrid","DataCtor","elemSize","EDTSurface","coordList","probeRadius","pLength","pWidth","pHeight","ptran","depty","widxz","cutRadius","setAtomID","vpBits","vpDistance","vpAtomID","btype","_probeRadius","_scaleFactor","_cutoff","_setAtomID","boundingatom","INOUT","ISDONE","ISBOUND","txz","tdept","sradius","tradius","widxzR","deptyName","indx","fillatom","ox","oy","oz","mj","mk","sk","ii","jj","kk","deptyAtNind","deptyAt","nind","pWH","ci2","fillvoxels","fillAtomWaals","fastdistancemap","boundPoint","cutRSq","totalsurfacevox","inarray","positin","outarray","positout","fastoneshell","cutoffSq","tx","ty","tz","square","nbj","tnvix","tnviy","tnviz","getVolume","tk","buildboundary","fillvoxelswaals","stype","marchingcubeinit","vd","makeAVHash","atomsX","atomsY","atomsZ","atomsR","nAtoms","hashFunc","minW","iDim","jDim","kDim","nCells","jkDim","preHash","cid","cellOffsets","cellLengths","maxCellLength","subArray","cellLength","neighbourListLength","withinRadii","rExtra","nearI","nearJ","nearK","loI","loJ","loK","hiI","hiJ","hiK","iOffset","jOffset","cellStart","cellEnd","rSum","AVSurface","probePositions","gridx","gridy","gridz","sinTable","cosTable","lastClip","atob","ngTorus","_probePositions","rExt","surfGrid","fillGridDim","initializeGrid","initializeAngleTables","obscured","singleAtomObscures","ra2","projectPoints","ar","ar2","ng","iax","iay","iaz","minx","miny","minz","maxx","maxy","maxz","xoffset","dxy2","xyoffset","spx","spy","spz","dd","projectTorus","dmp","normalToLine","rInt","cost","sint","px","py","pz","ia","projectTorii","fixNegatives","fixAtomIDs","MolecularSurface","_getAtomData","MolecularSurfaceRepresentation","surfaceType","vws","sas","ses","av","__infoList","__forceNewMolsurf","prepareData","molsurf","sviewFilter","bbSize","maxDim","asWithin","getSurfaceParams","__sele","__surfaceParams","after","contourBuffer","doubleSidedBuffer","PointRepresentation","pointData","RibbonBuffer","aNormal","aSize","aDir","aPrimitiveId","currSize","prevSize","RibbonRepresentation","RocketRepresentation","axisList","helixbundleList","helixbundle","axisData","RopeRepresentation","SpacefillRepresentation","TraceBuffer","linePosition","TraceRepresentation","TubeRepresentation","UnitcellRepresentation","defaultRadius","cbrt","getUnitcellData","unitcellData","ValidationRepresentation","clashData","getClashData","ConeBufferDefaultParameters","ConeBuffer","ConeBufferGeometry","_position1","_position2","GeometryGroup","geometryList","empty","ArrowBufferDefaultParameters","ArrowBuffer","splitPosition","cylinderRadius","makeAttributes","coneBuffer","vFrom","vTo","vSplit","fullLength","coneLength","BoxBuffer","BoxBufferGeometry","_heightAxis","_depthAxis","_size","EllipsoidBufferDefaultParameters","EllipsoidBuffer","_majorAxis","_minorAxis","OctahedronBuffer","OctahedronBufferGeometry","TetrahedronBuffer","TetrahedronBufferGeometry","TorusBufferDefaultParameters","radiusRatio","tubularSegments","TorusBuffer","TorusBufferGeometry","Parser","_beforeParse","_parse","_afterParse","StructureParser","structureBuilder","Entity","description","chainIndexList","entityTypeFromString","entityFromType","isNonPolymer","isMacrolide","DefaultBoxParams","Unitcell","alphaRad","betaRad","gammaRad","cosAlpha","cosBeta","cosGamma","sinBeta","sinGamma","cStar","cosAlphaStar","cornerOffset","divideScalar","centerArray3","HelixTypes","dAminoAcids","entityKeyList","reWhitespace","getModresId","PdbParser","hex","isLegacy","headerLine","headerId","legacyId","isPqr","isPdbqt","sb","serialRadix","resnoRadix","currentCoord","doFrames","currentBiomol","currentPart","currentMatrix","line","recordName","startChain","startResi","startIcode","endChain","endResi","endIcode","serialDict","unitcellDict","entityDataList","currentEntityData","currentEntityKey","hetnameDict","modresDict","chainDict","chainIdx","currentChainname","seqresDict","currentSeqresChainname","modelIdx","pendingStart","ls","modresId","fromIdx","toIdx","helixType","seqresChainname","keyEnd","biomt","biomtElms","ncsName","ncs","ncsRow","ncsElms","origx","orgix","origxRow","origxElms","scaleRow","scaleElms","aLength","bLength","cLength","sGroup","_parseChunkOfLines","ei","residueDict","reQuotedWhitespace","reDoubleQuote","reTrimQuotes","trimQuotes","ensureArray","hasValue","cifDefaults","getBondOrder","valueOrder","CifParser","rawline","authAsymId","authSeqId","labelSeqId","labelAtomId","labelCompId","labelAsymId","labelEntityId","labelAltId","groupPDB","typeSymbol","pdbxPDBmodelNum","pdbxPDBinsCode","CartnX","CartnY","CartnZ","bIsoOrEquiv","cif","asymIdDict","chainIndexDict","pendingString","currentString","pendingValue","pendingLoop","pendingName","loopPointers","currentLoopIndex","currentCategory","currentName","pointerNames","modelNum","keyParts","category","keyValuePair","_modelNum","frameOffset","occ","assignedChainname","entityId","chem_comp","chem_comp_atom","cc","cca","ccb","chem_comp_bond","atomnameDict","comp_id","atom_id","type_symbol","model_Cartn_x","model_Cartn_y","model_Cartn_z","pdbx_component_comp_id","pdbx_residue_numbering","pdbx_model_Cartn_x_ideal","pdbx_model_Cartn_y_ideal","pdbx_model_Cartn_z_ideal","atom_id_1","atom_id_2","value_order","parseChemComp","atom_site_type_symbol","atom_site_label","atom_site_fract_x","cell_length_a","cell_length_b","cell_length_c","cell_angle_alpha","cell_angle_beta","cell_angle_gamma","atom_site_fract_y","atom_site_fract_z","atom_site_occupancy","ml","identityMatrix","covalentI","parseCore","begIcode","sc","struct_conf","pdbx_PDB_helix_class","beg_auth_seq_id","pdbx_beg_PDB_ins_code","pdbx_end_PDB_ins_code","beg_label_asym_id","end_label_asym_id","end_auth_seq_id","ssr","struct_sheet_range","processSecondaryStructure","operDict","pdbx_struct_oper_list","biomolOp","elms","pdbx_struct_assembly_gen","gen","getMatrixDict","expr","es","assembly_id","oe","oper_expression","md1","md2","k1","k2","asym_id_list","struct_ncs_oper","ncsOp","ncsPart","cell","length_a","length_b","length_c","angle_alpha","angle_beta","angle_gamma","symmetry","database_PDB_matrix","origxMat","atom_sites","scaleMat","processSymmetry","struct_conn","atomIndicesCache","connTypeId","conn_type_id","ptnr1_symmetry","ptnr2_symmetry","inscode1","pdbx_ptnr1_PDB_ins_code","altloc1","pdbx_ptnr1_label_alt_id","ptnr1_auth_seq_id","ptnr1_label_asym_id","ptnr1_label_atom_id","selection1","inscode2","pdbx_ptnr2_PDB_ins_code","altloc2","pdbx_ptnr2_label_alt_id","ptnr2_auth_seq_id","ptnr2_label_asym_id","ptnr2_label_atom_id","selection2","tmpA","tmpB","pdbx_value_order","processConnections","pdbx_description","processEntities","struct","entry","pdbx_audit_revision_history","revision_date","dates","releaseDate","pdbx_database_status","recvd_initial_deposition_date","depDates","depositionDate","database_PDB_rev","date","date_original","reflns","d_resolution_high","refine","ls_d_res_high","ls_R_factor_R_free","rFree","ls_R_factor_R_work","rWork","exptl","method","experimentalMethods","firstLines","lpos","ypos","zpos","modelLineCount","lineNo","AllFields","ctor","typedArray","getDataView","getInt8View","getInt32View","decodeInt16","output","i2","decodeInt32","i4","decodeInteger","intArray","divisor","invDiv","decodeRun","dataOffset","decodeDelta","decodePacking","int16or8","upperLimit","lowerLimit","decodeIntegerPacking","decodeIntegerDeltaPacking","unpacked","decodeIntegerDelta","decodeMsgpack","dataView","performDecoding","dvOut","dvIn","decodeFloat32","decodeIntegerRun","decodeMmtf","inputDict","ignoreFields","outputDict","dv","ignore","SstrucMap","groupData","numBonds","numAtoms","numGroups","numChains","numModels","chainsPerModel","structureId","groupsPerChain","groupList","groupTypeList","atomNameList","frameAtomOffset","xCoordList","yCoordList","zCoordList","bAtomIndex1","bAtomIndex2","bBondOrder","aGroupIndex","aFormalCharge","gChainIndex","gAtomOffset","gAtomCount","cModelIndex","cGroupOffset","cGroupCount","mChainOffset","mChainCount","modelChainCount","groupOffset","chainGroupCount","bondOffset","groupAtomCount","groupFormalChargeList","formalChargeList","groupBondAtomList","bondAtomList","groupBondOrderList","bondOrderList","atomIdList","bFactorList","altLocList","occupancyList","groupIdList","secStructList","insCodeList","chainNameList","chainIdList","groupTypeDict","groupType","elementList","hetFlag","numGroupBonds","groupName","resAtomOffset","secStructLength","bioAssemblyList","_assembly","chainToPart","transformList","_transform","ncsOperatorList","ncsAssembly","_operator","unitCell","spaceGroup","bondTypes","am","du","un","moleculeLineNo","modelAtomIdxStart","currentRecordType","reItem","SdfParser","headerLines","sdfData","mItem","atomStart","bondStart","bondEnd","currentItem","currentData","isV3000","isAtomBlock","isBondBlock","acc","atomindexToStoreindex","chgTok","find","chargeCount","coffset","atomIdx","cToken","_postProcess","parseIntSubstr","PrmtopParser","pointersDict","pointers","atomNames","radii","residueLabels","residuePointers","curIdx","bondIdx","lt","NATOM","NBONH","MBONA","NRES","curResIdx","curResname","curResno","reTitle","lastSegid","segid","reField","molecules","moleculetypeDict","currentMoleculetype","fieldMatch","cIdx","molName","molCount","molType","lastResno","resIdx","chainidIdx","chainnameIdx","TrajectoryParser","notNetcdf","statement","reason","TypeError","readName","nameLength","nextPos","intView","ef","isCharmm","extraBlock","fourDims","NSET","ISTART","NSAVC","NAMNF","DELTA","titleLength","titlePos","TITLE","natom","natom4","BYTE","CHAR","SHORT","INT","DOUBLE","num2str","num2bytes","str2num","readNumber","bufferReader","numbers","readType","trimNull","ZERO","NC_DIMENSION","NC_VARIABLE","NC_ATTRIBUTE","version","recordDimension","dimList","dimensions","recordId","dimensionSize","dimensionsList","globalAttributes","attributesList","variables","varList","recordStep","variableSize","dimensionality","dimensionsIds","varSize","record","variablesList","gAttList","gAtt","NetcdfReader","hasDataVariable","variableName","findIndex","getDataVariable","variable","currentOffset","nonRecord","NctrajParser","netcdfReader","versionSize","virSize","presSize","coordSize","velocitySize","forceSize","natoms","floatSize","natoms3","frameCoords","MagicInts","sizeOfInt","num","numOfBits","_tmpBytes","sizeOfInts","numOfInts","sizes","numOfBytes","bytecnt","decodeBits","cbuf","buf2","mask","lastBB0","lastBB1","cnt","_tmpIntBytes","decodeInts","nums","minMaxInt","sizeint","bitsizeint","sizesmall","thiscoord","prevcoord","lfp","lsize","bitsize","smallidx","tmpIdx","smaller","smallnum","adz","invPrecision","buf8","isSmaller","tmpSwap","VolumeParser","getMatrix","reScientificNotation","bohrToAngstromFactor","CubeParser","originX","originY","originZ","NVX","NVY","NVZ","basisX","basisY","basisZ","oribitalFlag","lj","Dsn6Parser","summand","byteView","brixStr","xStart","yStart","zStart","xExtent","yExtent","zExtent","xRate","yRate","zRate","xlen","ylen","zlen","xBlocks","yBlocks","zBlocks","zz","yy","xx","nxyz","mapcrs","DxParser","headerInfo","parseHeaderLines","dataLineStart","headerByteCount","deltaLineCount","xmin","ymin","zmin","hx","hy","hz","uint8ToLines","MrcParser","floatView","MAP","MACHST","NX","NY","MODE","NXSTART","NYSTART","NZSTART","MX","MY","MZ","MAPC","MAPR","MAPS","DMIN","DMAX","ISPG","NSYMBT","LSKFLG","b1","b0","parseNumberLine","XplorParser","infoStart","dataStart","gridInfo","AMIN","AMAX","BMIN","BMAX","NC","CMIN","CMAX","cellInfo","lineSection","RAVE","RSIGMA","hsvToRgb","ColorDict","red","orange","gold","yellow","lime","green","sea","cyan","sky","blue","purple","magenta","hotpink","pink","peach","lilac","pinktint","peachtint","yellowtint","greentint","bluetint","lilactint","white","gray","brown","deadwhite","deadblack","invisible","reWhitespaceComma","reCurlyWhitespace","reTrimCurly","reCollapseEqual","parseListDef","defaultColor","master","lm","listName","listColor","listMasters","listWidth","parseListElm","lineBreak","triangleBreak","lsindex","literal","isLineBreak","isTriangleBreak","parseStr","parseFlag","parseGroup","flags","groupFlags","groupMasters","kinemage","onewidth","pdbfile","texts","captions","caption","groupDict","subgroupDict","masterDict","pointmasterDict","dotLists","vectorLists","ballLists","ribbonLists","currentGroupMasters","currentSubgroupMasters","dotDefaultColor","dotLabel","dotPosition","dotColor","vecDefaultColor","vecDefaultWidth","vecLabel1","vecLabel2","vecPosition1","vecPosition2","vecColor1","vecColor2","ballRadius","ballDefaultColor","ballLabel","ballPosition","ballColor","ribbonListDefaultColor","ribbonPointLabelArray","ribbonPointPositionArray","ribbonPointBreakArray","ribbonPointColorArray","isDotList","prevDotLabel","isVectorList","prevVecLabel","prevVecPosition","prevVecColor","isBallList","prevBallLabel","isRibbonList","prevRibbonPointLabel","isCaption","masterArray","labelArray","colorArray","indent","label1Array","label2Array","position1Array","position2Array","color1Array","color2Array","radiusArray","breakArray","splitLine","singlePointLine","dominant","convertedLists","listObject","convertedRibbonObject","editedLabels","editedPositions","editedColors","editedBreaks","breakPointer","positionPointer","removePointBreaksTriangleArrays","ribbonObject","convertedLabels","convertedBreaks","convertedPositions","convertedColors","vector3Positions","convertKinTriangleArrays","SurfaceParser","getLoader","OBJLoader","regexp","vertex_pattern","normal_pattern","uv_pattern","face_vertex","face_vertex_uv","face_vertex_uv_normal","face_vertex_normal","object_pattern","smoothing_pattern","material_library_pattern","material_use_pattern","setPath","_createParserState","objects","startObject","fromDeclaration","parseVertexIndex","parseNormalIndex","addVertex","addVertexLine","addNormal","addFace","nd","vLen","ib","ic","nLen","addLineGeometry","vi","lineFirstChar","lineSecondChar","trimLeft","lineParts","lineVertices","lineUVs","llen","parts","buffergeometry","PLYLoader","propertyNameMapping","setPropertyNameMapping","bin2str","isASCII","parseHeader","parseASCII","parseBinary","headerText","headerLength","currentElement","lineType","lineValues","propertValues","comments","countType","itemType","parseASCIINumber","parseASCIIElement","currentElementCount","useColor","handleElement","postProcess","colors","elementsNeedUpdate","elementName","setRGB","vertexIndices","vertex_indices","Face3","binaryRead","dataview","binaryReadElement","loc","table","reDelimiter","msgpack","netcdf","TextParser","reStrip","reTag","reContent","reAttr","parseXml","declaration","root","tag","eos","is","child","re","prefix","XmlParser","useDomParser","__xmlParser","__domParser","DOMParser","parseFromString","Document","getNamedItem","getSele","useAltcode","icode","altcode","getResSele","setBitDict","bit","hasAttrValue","getProblemCount","clashDict","ga","clashes","getElementsByTagName","Validation","atomDict","clashSele","fromXml","entries","chemicalShiftLists","randomCoilIndices","rcia","_clashDict","clashList","seleAttr","createAttribute","setNamedItem","atomSele","res1","res2","mogBondOutliers","mogAngleOutliers","vPos1","vPos2","getAtomSele","dHalf","shrinkBuf","arraySet","dest","src_offs","dest_offs","adler32","adler","crcTable","makeTable","crc32","crc","BAD$1","TYPE$1","inflate_fast","strm","_in","last","_out","dmax","wsize","whave","wnext","s_window","lcode","dcode","lmask","dmask","here","op","from_source","next_in","avail_in","next_out","avail_out","lencode","distcode","lenbits","distbits","dolen","dodist","sane","MAXBITS","ENOUGH_LENS$1","ENOUGH_DISTS$1","CODES$1","LENS$1","DISTS$1","lbase","lext","dbase","dext","inflate_table","lens","lens_index","codes","table_index","work","incr","here_bits","here_op","here_val","curr","drop","used","huff","base_index","offs","extra","extra_index","LENS","DISTS","Z_OK","Z_STREAM_ERROR","HEAD","TYPE","BAD","ENOUGH_LENS","ENOUGH_DISTS","zswap32","InflateState","havedict","check","total","wbits","ncode","nlen","ndist","have","lendyn","distdyn","was","inflateReset","total_in","total_out","inflateResetKeep","inflateInit2","windowBits","inflateReset2","lenfix","distfix","virgin","fixedtables","updatewindow","flush","put","last_bits","last_op","last_val","hbuf","inf_leave","xflags","os","extra_len","hcrc","data_type","inflateSetDictionary","dictionary","dictLength","STR_APPLY_OK","STR_APPLY_UIA_OK","__","_utf8len","string2buf","m_pos","str_len","buf_len","buf2string","c_len","utf16buf","_buf2binstring","utf8border","Z_OK$1","messages","ZStream","GZheader","Inflate","sources","source","raw","err","ended","_mode","next_out_utf8","tail","utf8str","allowBufError","binstring2buf","onEnd","onData","inflateEnd","flattenChunks","decompressedData","inflator","ungzip","Datasource","mmtfBaseUrl","mmtfFullUrl","mmtfReducedUrl","pdbid","baseUrl","suffixUrl","PassThroughDatasource","suffixURL","uniprotid","reProtocol","IntegerParam","NumberParam","RangeParam","SelectParam","UIStageParameters","getListing","jsonData","frameIndex","getPathUrl","renumberSerial","remarks","_records","_writeRecords","_writeTitle","_writeRemarks","_writeAtoms","im","chargeSign","hasModels","formatString","getString","idString","titleString","countsString","chargeLines","pairs","nCharges","formatAtom","formatBond","_writeHeader","_writeCTab","_writeFooter","fullscreenChanged","componentAdded","componentRemoved","compList","defaultFileParams","logList","pickingBehavior","mouseBehavior","animationBehavior","keyBehavior","spinAnimation","rockAnimation","setQuality","setImpostor","defaultFileRepresentation","BU1","sizeScore","backboneOnly","loadFile","promise","addComponentFromObject","defaultRepresentation","errorMsg","loadScript","script","addComponent","CompClass","removeComponent","removeAllComponents","toggleFullscreen","fullscreenEnabled","mozFullScreenEnabled","webkitFullscreenEnabled","msFullscreenEnabled","getFullscreenElement","fullscreenElement","mozFullScreenElement","webkitFullscreenElement","msFullscreenElement","resizeElement","lastFullscreenElement","dataset","normalWidth","normalHeight","exitFullscreen","msExitFullscreen","mozCancelFullScreen","webkitExitFullscreen","screen","requestFullscreen","msRequestFullscreen","mozRequestFullScreen","webkitRequestFullscreen","setSpin","setRock","pclamp","minSize","aspectFactor","catch","impostorTypes","eachComponent","getComponentsByName","getRepresentationsByName","relativePath","pn","pathname","basePath","getAbsolutePath","vectorNorm1","vectorNorm2","vectorNorm3","structures","atomIndexDict","modelCount","flatten","wait","previous","later","leading","Date","clearTimeout","trailing"],"mappings":"4sBAQM,SAAUA,EAAUC,GACxB,GAAsB,oBAAXC,OAAwB,OAEnC,MACMC,EADI,IAAIC,OAAO,GAAGH,eACZI,KAAKH,OAAOI,SAASC,QAEjC,OAAIJ,EACKK,mBAAmBL,EAAE,SAE5B,CAEJ,CAcgB,SAAAM,EAAUC,EAAYC,GACpC,YAAiBC,IAAVF,EAAsBA,EAAQC,CACvC,CAEgB,SAAAE,EAAiBC,EAAgCC,GAC/D,MAAMC,EAASC,OAAOC,OAAO,CAAE,EAAEJ,GACjC,IAAK,MAAMK,KAAKJ,EAAe,MAEfH,IADAE,EAAOK,KACIH,EAAEG,GAAKJ,EAAcI,GAC/C,CACD,OAAOH,CACT,CAEgB,SAAAI,EAAiBN,EAAWO,GAC1C,IAAK,MAAMF,KAAKE,EAAW,CACzB,MAAMX,EAAQW,EAAUF,QACVP,IAAVF,IAAqBI,EAAOK,GAAKT,EACtC,CACD,OAAOI,CACT,UAsBgBQ,IACd,MAAMC,EAAWrB,OAAOI,SAASiB,SACjC,OAAyC,OAAlCA,EAASC,MAAM,eAA0B,QAAUD,CAC5D,UAEgBE,IACd,GAAsB,oBAAXvB,OAAwB,OAAO,EAE1C,MAAMwB,EAAKxB,OAAOyB,UAAUC,UAE5B,MAAI,YAAYC,KAAKH,GACZ,QACE,UAAUG,KAAKH,GACjB,SACE,WAAWG,KAAKH,GAClB,UACE,wBAAwBG,KAAKH,GAC/B,gBACE,QAAQG,KAAKH,GACf,sBACE,UAAUG,KAAKH,IACjB,QAIX,CAqEA,SAASI,EAASC,GACD7B,OAAO8B,KAAKD,EAAK,YAE9B7B,OAAOI,SAAS2B,KAAOF,EAE3B,UAEgBG,EAAUC,EAAmBC,EAAe,YAG1D,IAAKD,EAAM,OAEX,MAAME,EAA4B,WAA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ACV,yBAqBM,SAAgCA,GACpCigB,EAAAA,kBAAoBjgB,CACtB,gCA9BgB,SAA6BI,EAAS,IACpDG,OAAOC,OAAO6b,GAA0Bjc,EAC1C,4BA+BM,SAAmCJ,GACvCkgB,EAAAA,qBAAuBlgB,CACzB,qCXsJ0B4a,EAAgBs8K,EAAct3I,GAGtD,IAAI7zB,EACAuvB,EACA/4C,EACAk8C,EAAe,KACf04I,EAAW,EAIf,SAASC,IACPD,GAA+B,IAApBv3I,EAAQy3I,QAAoB,EAAIC,KAAKtqK,MAChDyxB,EAAU,KACVl8C,EAASqY,EAAKtV,MAAMymB,EAASuvB,GACxBmD,IAAS1yB,EAAUuvB,EAAO,KAChC,CAED,OATKsE,IAASA,EAAU,CAAA,GASjB,WACL,IAAI5yB,EAAMsqK,KAAKtqK,MACVmqK,IAAgC,IAApBv3I,EAAQy3I,UAAmBF,EAAWnqK,GACvD,IAAIm7B,EAAY+uI,GAAQlqK,EAAMmqK,GAe9B,OAdAprK,EAAUjkB,KACVwzC,EAAOxtB,UACHq6B,GAAa,GAAKA,EAAY+uI,GAC5Bz4I,IACF84I,aAAa94I,GACbA,EAAU,MAEZ04I,EAAWnqK,EACXzqB,EAASqY,EAAKtV,MAAMymB,EAASuvB,GACxBmD,IAAS1yB,EAAUuvB,EAAO,OACrBmD,IAAgC,IAArBmB,EAAQ43I,WAC7B/4I,EAAU1tB,WAAWqmK,EAAOjvI,IAGvB5lD,CACT,CACF"} \ No newline at end of file +{"version":3,"file":"ngl.umd.js","sources":["../src/utils.ts","../src/utils/registry.ts","../src/math/math-utils.ts","../src/color/colormaker.ts","../src/selection/selection-constants.ts","../src/selection/selection-test.ts","../src/selection/selection.ts","../src/selection/selection-parser.ts","../src/color/selection-colormaker.ts","../src/color/colormaker-registry.ts","../src/worker/worker-utils.ts","../src/globals.ts","../src/worker/worker-registry.ts","../src/parser/parser-registry.ts","../src/streamer/streamer.ts","../src/streamer/file-streamer.ts","../src/streamer/network-streamer.ts","../src/loader/loader.ts","../src/loader/parser-loader.ts","../src/script.ts","../src/loader/script-loader.ts","../src/loader/loader-utils.ts","../src/writer/writer.ts","../src/utils/io-buffer.ts","../src/utils/counter.ts","../src/viewer/stats.ts","../src/shader/shader-utils.ts","../src/viewer/viewer-constants.ts","../src/viewer/tiled-renderer.ts","../src/math/math-constants.ts","../src/math/array-utils.ts","../src/viewer/viewer-utils.ts","../src/viewer/gl-utils.ts","../src/viewer/viewer.ts","../src/stage/mouse-observer.ts","../src/constants.ts","../src/controls/trackball-controls.ts","../src/controls/picking-proxy.ts","../src/controls/picking-controls.ts","../src/controls/viewer-controls.ts","../src/animation/animation.ts","../src/controls/animation-controls.ts","../src/utils/queue.ts","../src/representation/representation.ts","../src/worker/worker.ts","../src/worker/worker-pool.ts","../src/math/vector-utils.ts","../src/geometry/dash.ts","../src/geometry/primitive.ts","../src/geometry/spatial-hash.ts","../src/store/store.ts","../src/store/contact-store.ts","../src/utils/bitarray.ts","../src/utils/adjacency-list.ts","../src/chemistry/interactions/features.ts","../src/structure/structure-constants.ts","../src/chemistry/geometry.ts","../src/chemistry/valence-model.ts","../src/structure/data.ts","../src/chemistry/functional-groups.ts","../src/chemistry/interactions/charged.ts","../src/chemistry/interactions/hydrogen-bonds.ts","../src/chemistry/interactions/metal-binding.ts","../src/chemistry/interactions/halogen-bonds.ts","../src/chemistry/interactions/refine-contacts.ts","../src/chemistry/interactions/contact.ts","../src/chemistry/interactions/hydrophobic.ts","../src/utils/picker.ts","../src/surface/marching-cubes.ts","../src/math/matrix-utils.ts","../src/surface/surface-utils.ts","../src/surface/surface.ts","../src/surface/volume.ts","../src/buffer/buffer.ts","../src/buffer/mesh-buffer.ts","../src/buffer/surface-buffer.ts","../src/buffer/doublesided-buffer.ts","../src/buffer/contour-buffer.ts","../src/representation/surface-representation.ts","../src/controls/mouse-actions.ts","../src/controls/mouse-controls.ts","../src/controls/key-actions.ts","../src/controls/key-controls.ts","../src/stage/picking-behavior.ts","../src/stage/mouse-behavior.ts","../src/stage/animation-behavior.ts","../src/stage/key-behavior.ts","../src/component/annotation.ts","../src/controls/component-controls.ts","../src/utils/radius-factory.ts","../src/math/principal-axes.ts","../src/surface/filtered-volume.ts","../src/store/bond-hash.ts","../src/store/bond-store.ts","../src/store/atom-store.ts","../src/store/residue-store.ts","../src/store/chain-store.ts","../src/store/model-store.ts","../src/geometry/helixorient.ts","../src/geometry/helixbundle.ts","../src/utils/binary-heap.ts","../src/utils/kdtree.ts","../src/proxy/atom-proxy.ts","../src/geometry/kdtree.ts","../src/symmetry/symmetry-constants.ts","../src/symmetry/symmetry-utils.ts","../src/symmetry/assembly.ts","../src/structure/structure-builder.ts","../src/structure/structure-utils.ts","../src/store/atom-type.ts","../src/store/atom-map.ts","../src/store/residue-type.ts","../src/store/residue-map.ts","../src/proxy/bond-proxy.ts","../src/proxy/residue-proxy.ts","../src/proxy/polymer.ts","../src/proxy/chain-proxy.ts","../src/proxy/model-proxy.ts","../src/structure/structure.ts","../src/geometry/shape.ts","../src/representation/buffer-representation.ts","../src/buffer/geometry-buffer.ts","../src/buffer/spheregeometry-buffer.ts","../src/buffer/mapped-buffer.ts","../src/buffer/mappedquad-buffer.ts","../src/buffer/sphereimpostor-buffer.ts","../src/buffer/sphere-buffer.ts","../src/buffer/point-buffer.ts","../src/representation/dot-representation.ts","../src/buffer/image-buffer.ts","../src/surface/volume-slice.ts","../src/representation/slice-representation.ts","../src/representation/representation-utils.ts","../src/component/element.ts","../src/component/representation-element.ts","../src/component/component.ts","../src/component/collection.ts","../src/component/representation-collection.ts","../src/component/trajectory-element.ts","../src/trajectory/frames.ts","../src/align/superposition.ts","../src/trajectory/trajectory-player.ts","../src/trajectory/trajectory.ts","../src/trajectory/frames-trajectory.ts","../src/trajectory/structure-trajectory.ts","../src/trajectory/remote-trajectory.ts","../src/trajectory/callback-trajectory.ts","../src/structure/structure-view.ts","../src/align/alignment.ts","../src/align/align-utils.ts","../src/component/structure-component.ts","../src/trajectory/trajectory-utils.ts","../src/component/surface-component.ts","../src/component/volume-component.ts","../src/component/component-collection.ts","../src/stage/stage.ts","../src/component/shape-component.ts","../node_modules/tslib/tslib.es6.js","../src/color/atomindex-colormaker.ts","../src/color/bfactor-colormaker.ts","../src/color/chainid-colormaker.ts","../src/color/chainindex-colormaker.ts","../src/color/chainname-colormaker.ts","../src/color/densityfit-colormaker.ts","../src/color/electrostatic-colormaker.ts","../src/color/element-colormaker.ts","../src/color/entityindex-colormaker.ts","../src/color/entitytype-colormaker.ts","../src/color/geoquality-colormaker.ts","../src/color/hydrophobicity-colormaker.ts","../src/color/modelindex-colormaker.ts","../src/color/moleculetype-colormaker.ts","../src/color/occupancy-colormaker.ts","../src/color/partialcharge-colormaker.ts","../src/color/random-colormaker.ts","../src/color/randomcoilindex-colormaker.ts","../src/color/residueindex-colormaker.ts","../src/color/resname-colormaker.ts","../src/color/sstruc-colormaker.ts","../src/color/structuredata-colormaker.ts","../src/color/uniform-colormaker.ts","../src/color/value-colormaker.ts","../src/color/volume-colormaker.ts","../src/representation/structure-representation.ts","../src/representation/measurement-representation.ts","../src/utils/edt.ts","../src/buffer/text-buffer.ts","../src/buffer/wideline-buffer.ts","../src/representation/angle-representation.ts","../src/buffer/cylindergeometry-buffer.ts","../src/buffer/mappedalignedbox-buffer.ts","../src/buffer/cylinderimpostor-buffer.ts","../src/buffer/cylinder-buffer.ts","../src/representation/axes-representation.ts","../src/representation/ballandstick-representation.ts","../src/representation/backbone-representation.ts","../src/representation/base-representation.ts","../src/geometry/spline.ts","../src/buffer/tubemesh-buffer.ts","../src/representation/cartoon-representation.ts","../src/representation/contact-representation.ts","../src/representation/dihedral-representation.ts","../src/representation/dihedral-histogram-representation.ts","../src/representation/distance-representation.ts","../src/buffer/vector-buffer.ts","../src/representation/helixorient-representation.ts","../src/representation/licorice-representation.ts","../src/buffer/mappedbox-buffer.ts","../src/buffer/hyperballstickimpostor-buffer.ts","../src/buffer/hyperballstick-buffer.ts","../src/representation/hyperball-representation.ts","../src/utils/label-factory.ts","../src/representation/label-representation.ts","../src/representation/line-representation.ts","../src/geometry/grid.ts","../src/surface/edt-surface.ts","../src/surface/av-surface.ts","../src/surface/molecular-surface.ts","../src/representation/molecularsurface-representation.ts","../src/representation/point-representation.ts","../src/buffer/ribbon-buffer.ts","../src/representation/ribbon-representation.ts","../src/representation/rocket-representation.ts","../src/representation/rope-representation.ts","../src/representation/spacefill-representation.ts","../src/buffer/trace-buffer.ts","../src/representation/trace-representation.ts","../src/representation/tube-representation.ts","../src/representation/unitcell-representation.ts","../src/representation/validation-representation.ts","../src/buffer/cone-buffer.ts","../src/viewer/geometry-group.ts","../src/buffer/arrow-buffer.ts","../src/buffer/box-buffer.ts","../src/buffer/ellipsoid-buffer.ts","../src/buffer/octahedron-buffer.ts","../src/buffer/tetrahedron-buffer.ts","../src/buffer/torus-buffer.ts","../src/parser/parser.ts","../src/parser/structure-parser.ts","../src/structure/entity.ts","../src/symmetry/unitcell.ts","../src/parser/pdb-parser.ts","../src/parser/cif-parser.ts","../src/parser/gro-parser.ts","../lib/mmtf.es6.js","../src/parser/mmtf-parser.ts","../src/parser/mol2-parser.ts","../src/parser/pdbqt-parser.ts","../src/parser/pqr-parser.ts","../src/parser/sdf-parser.ts","../src/parser/prmtop-parser.ts","../src/parser/psf-parser.ts","../src/parser/top-parser.ts","../src/parser/trajectory-parser.ts","../src/utils/netcdf-reader.ts","../src/parser/dcd-parser.ts","../src/parser/nctraj-parser.ts","../src/parser/trr-parser.ts","../src/parser/xtc-parser.ts","../src/parser/volume-parser.ts","../src/parser/cube-parser.ts","../src/parser/dsn6-parser.ts","../src/parser/dx-parser.ts","../src/parser/dxbin-parser.ts","../src/parser/mrc-parser.ts","../src/parser/xplor-parser.ts","../src/parser/kin-parser.ts","../src/parser/surface-parser.ts","../src/parser/obj-parser.ts","../src/parser/ply-parser.ts","../src/parser/csv-parser.ts","../src/parser/json-parser.ts","../src/parser/msgpack-parser.ts","../src/parser/netcdf-parser.ts","../src/parser/text-parser.ts","../src/utils/parse-xml.ts","../src/parser/xml-parser.ts","../src/structure/validation.ts","../lib/pako_inflate.es6.js","../src/parser/validation-parser.ts","../src/utils/gzip-decompressor.ts","../src/datasource/datasource.ts","../src/datasource/rcsb-datasource.ts","../src/datasource/pubchem-datasource.ts","../src/datasource/passthrough-datasource.ts","../src/datasource/alphafold-datasource.ts","../src/datasource/static-datasource.ts","../src/ui/parameters.ts","../src/datasource/mdsrv-datasource.ts","../src/writer/pdb-writer.ts","../src/writer/sdf-writer.ts","../src/writer/stl-writer.ts"],"sourcesContent":["/**\n * @file Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector2, Vector3, Matrix4, Quaternion } from 'three'\n\nexport function getQuery (id: string) {\n if (typeof window === 'undefined') return undefined\n\n const a = new RegExp(`${id}=([^&#=]*)`)\n const m = a.exec(window.location.search)\n\n if (m) {\n return decodeURIComponent(m[1])\n } else {\n return undefined\n }\n}\n\nexport function boolean (value: any) {\n if (!value) {\n return false\n }\n\n if (typeof value === 'string') {\n return /^1|true|t|yes|y$/i.test(value)\n }\n\n return true\n}\n\nexport function defaults (value: any, defaultValue: any) {\n return value !== undefined ? value : defaultValue\n}\n\nexport function createParams (params: {[k in keyof T]?: any}, defaultParams: T) {\n const o: any = Object.assign({}, params)\n for (const k in defaultParams) {\n const value = params[k]\n if (value === undefined) o[k] = defaultParams[k]\n }\n return o as T\n}\n\nexport function updateParams (params: T, newParams: {[k in keyof T]?: any}) {\n for (const k in newParams) {\n const value = newParams[k]\n if (value !== undefined) params[k] = value\n }\n return params as T\n}\n\nexport function pick (object: { [index: string]: any }) {\n const properties = [].slice.call(arguments, 1)\n return properties.reduce((a: { [index: string]: any }, e: any) => {\n a[ e ] = object[ e ]\n return a\n }, {})\n}\n\nexport function flatten (array: any[], ret: any[]) {\n ret = defaults(ret, [])\n for (let i = 0; i < array.length; i++) {\n if (Array.isArray(array[i])) {\n flatten(array[i], ret)\n } else {\n ret.push(array[i])\n }\n }\n return ret\n}\n\nexport function getProtocol () {\n const protocol = window.location.protocol\n return protocol.match(/http(s)?:/gi) === null ? 'http:' : protocol\n}\n\nexport function getBrowser () {\n if (typeof window === 'undefined') return false\n\n const ua = window.navigator.userAgent\n\n if (/Opera|OPR/.test(ua)) {\n return 'Opera'\n } else if (/Chrome/i.test(ua)) {\n return 'Chrome'\n } else if (/Firefox/i.test(ua)) {\n return 'Firefox'\n } else if (/Mobile(\\/.*)? Safari/i.test(ua)) {\n return 'Mobile Safari'\n } else if (/MSIE/i.test(ua)) {\n return 'Internet Explorer'\n } else if (/Safari/i.test(ua)) {\n return 'Safari'\n }\n\n return false\n}\n\nexport function getAbsolutePath (relativePath: string) {\n const loc = window.location\n const pn = loc.pathname\n const basePath = pn.substring(0, pn.lastIndexOf('/') + 1)\n\n return loc.origin + basePath + relativePath\n}\n\nexport function deepCopy (src: any) {\n if (typeof src !== 'object') {\n return src\n }\n\n const dst: { [index: string]: any } = Array.isArray(src) ? [] : {}\n\n for (let key in src) {\n dst[ key ] = deepCopy(src[ key ])\n }\n\n return dst\n}\n\nexport function deepEqual(a: any, b: any) {\n // from https://github.com/epoberezkin/fast-deep-equal MIT\n if (a === b) return true;\n\n const arrA = Array.isArray(a)\n const arrB = Array.isArray(b)\n\n if (arrA && arrB) {\n if (a.length !== b.length) return false\n for (let i = 0; i < a.length; i++) {\n if (!deepEqual(a[i], b[i])) return false\n }\n return true\n }\n\n if (arrA !== arrB) return false\n\n if (a && b && typeof a === 'object' && typeof b === 'object') {\n const keys = Object.keys(a)\n if (keys.length !== Object.keys(b).length) return false;\n\n const dateA = a instanceof Date\n const dateB = b instanceof Date\n if (dateA && dateB) return a.getTime() === b.getTime()\n if (dateA !== dateB) return false\n\n const regexpA = a instanceof RegExp\n const regexpB = b instanceof RegExp\n if (regexpA && regexpB) return a.toString() === b.toString()\n if (regexpA !== regexpB) return false\n\n for (let i = 0; i < keys.length; i++) {\n if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false\n }\n\n for (let i = 0; i < keys.length; i++) {\n if(!deepEqual(a[keys[i]], b[keys[i]])) return false\n }\n\n return true\n }\n\n return false\n}\n\nfunction openUrl (url: string) {\n const opened = window.open(url, '_blank')\n if (!opened) {\n window.location.href = url\n }\n}\n\nexport function download (data: Blob|string, downloadName = 'download') {\n // using ideas from https://github.com/eligrey/FileSaver.js/blob/master/FileSaver.js\n\n if (!data) return\n\n const isSafari = getBrowser() === 'Safari'\n const isChromeIos = /CriOS\\/[\\d]+/.test(window.navigator.userAgent)\n\n const a = document.createElement('a')\n\n function open (str: string) {\n openUrl(isChromeIos ? str : str.replace(/^data:[^;]*;/, 'data:attachment/file;'))\n }\n\n if (typeof navigator !== 'undefined' && (navigator as any).msSaveOrOpenBlob) {\n // native saveAs in IE 10+\n (navigator as any).msSaveOrOpenBlob(data, downloadName)\n } else if ((isSafari || isChromeIos) && FileReader) {\n if (data instanceof Blob) {\n // no downloading of blob urls in Safari\n var reader = new FileReader()\n reader.onloadend = function () {\n open(reader.result as string)\n }\n reader.readAsDataURL(data)\n } else {\n open(data)\n }\n } else {\n let objectUrlCreated = false\n if (data instanceof Blob) {\n data = URL.createObjectURL(data)\n objectUrlCreated = true\n }\n\n if ('download' in a) {\n // download link available\n a.style.display = 'hidden'\n document.body.appendChild(a)\n a.href = data\n a.download = downloadName\n a.target = '_blank'\n a.click()\n document.body.removeChild(a)\n } else {\n openUrl(data)\n }\n\n if (objectUrlCreated) {\n window.URL.revokeObjectURL(data)\n }\n }\n}\n\nexport function submit (url: string, data: FormData, callback: Function, onerror: Function) {\n const xhr = new XMLHttpRequest()\n xhr.open('POST', url)\n\n xhr.addEventListener('load', function () {\n if (xhr.status === 200 || xhr.status === 304) {\n callback(xhr.response)\n } else {\n if (typeof onerror === 'function') {\n onerror(xhr.status)\n }\n }\n }, false)\n\n xhr.send(data)\n}\n\ninterface HTMLInputEvent extends Event {\n target: HTMLInputElement & EventTarget\n}\n\nexport function open (callback: Function, extensionList = ['*']) {\n const fileInput = document.createElement('input')\n fileInput.type = 'file'\n fileInput.multiple = true\n fileInput.style.display = 'hidden'\n document.body.appendChild(fileInput)\n fileInput.accept = '.' + extensionList.join(',.')\n fileInput.addEventListener('change', function (e: HTMLInputEvent) {\n callback(e.target.files)\n }, false)\n\n fileInput.click()\n}\n\nexport function throttle (func: Function, wait: number, options: { leading?: boolean, trailing?: boolean }) {\n // from http://underscorejs.org/docs/underscore.html\n\n let context: any\n let args: any\n let result: any\n let timeout: any = null\n let previous = 0\n\n if (!options) options = {}\n\n function later () {\n previous = options.leading === false ? 0 : Date.now()\n timeout = null\n result = func.apply(context, args)\n if (!timeout) context = args = null\n }\n\n return function throttle (this: any) {\n var now = Date.now()\n if (!previous && options.leading === false) previous = now\n var remaining = wait - (now - previous)\n context = this\n args = arguments\n if (remaining <= 0 || remaining > wait) {\n if (timeout) {\n clearTimeout(timeout)\n timeout = null\n }\n previous = now\n result = func.apply(context, args)\n if (!timeout) context = args = null\n } else if (!timeout && options.trailing !== false) {\n timeout = setTimeout(later, remaining)\n }\n\n return result\n }\n}\n\nexport function lexicographicCompare (elm1: T, elm2: T) {\n if (elm1 < elm2) return -1\n if (elm1 > elm2) return 1\n return 0\n}\n\n/**\n * Does a binary search to get the index of an element in the input array\n * @function\n * @example\n * var array = [ 1, 2, 3, 4, 5, 6 ];\n * var element = 4;\n * binarySearchIndexOf( array, element ); // returns 3\n *\n * @param {Array} array - sorted array\n * @param {Anything} element - element to search for in the array\n * @param {Function} [compareFunction] - compare function\n * @return {Number} the index of the element or -1 if not in the array\n */\nexport function binarySearchIndexOf (array: T[], element: T, compareFunction = lexicographicCompare) {\n let low = 0\n let high = array.length - 1\n while (low <= high) {\n const mid = (low + high) >> 1\n const cmp = compareFunction(element, array[ mid ])\n if (cmp > 0) {\n low = mid + 1\n } else if (cmp < 0) {\n high = mid - 1\n } else {\n return mid\n }\n }\n return -low - 1\n}\n\nexport function binarySearchForLeftRange (array: number[], leftRange: number) {\n let high = array.length - 1\n if (array[ high ] < leftRange) return -1\n let low = 0\n while (low <= high) {\n const mid = (low + high) >> 1\n if (array[ mid ] >= leftRange) {\n high = mid - 1\n } else {\n low = mid + 1\n }\n }\n return high + 1\n}\n\nexport function binarySearchForRightRange (array: number[], rightRange: number) {\n if (array[ 0 ] > rightRange) return -1\n let low = 0\n let high = array.length - 1\n while (low <= high) {\n const mid = (low + high) >> 1\n if (array[ mid ] > rightRange) {\n high = mid - 1\n } else {\n low = mid + 1\n }\n }\n return low - 1\n}\n\nexport function rangeInSortedArray (array: number[], min: number, max: number) {\n const indexLeft = binarySearchForLeftRange(array, min)\n const indexRight = binarySearchForRightRange(array, max)\n if (indexLeft === -1 || indexRight === -1 || indexLeft > indexRight) {\n return 0\n } else {\n return indexRight - indexLeft + 1\n }\n}\n\nexport function dataURItoImage (dataURI: string) {\n const img = document.createElement('img')\n img.src = dataURI\n return img\n}\n\nexport function uniqueArray (array: any[]) {\n return array.sort().filter(function (value, index, sorted) {\n return (index === 0) || (value !== sorted[ index - 1 ])\n })\n}\n\n// String/arraybuffer conversion\n\nexport function uint8ToString (u8a: Uint8Array) {\n const chunkSize = 0x7000\n\n if (u8a.length > chunkSize) {\n const c = []\n\n for (let i = 0; i < u8a.length; i += chunkSize) {\n c.push(String.fromCharCode.apply(\n null, u8a.subarray(i, i + chunkSize)\n ))\n }\n\n return c.join('')\n } else {\n return String.fromCharCode.apply(null, u8a)\n }\n}\n\nexport function uint8ToLines (u8a: Uint8Array, chunkSize = 1024 * 1024 * 10, newline = '\\n') {\n let partialLine = ''\n let lines: string[] = []\n\n for (let i = 0; i < u8a.length; i += chunkSize) {\n const str = uint8ToString(u8a.subarray(i, i + chunkSize))\n const idx = str.lastIndexOf(newline)\n\n if (idx === -1) {\n partialLine += str\n } else {\n const str2 = partialLine + str.substr(0, idx)\n lines = lines.concat(str2.split(newline))\n\n if (idx === str.length - newline.length) {\n partialLine = ''\n } else {\n partialLine = str.substr(idx + newline.length)\n }\n }\n }\n\n if (partialLine !== '') {\n lines.push(partialLine)\n }\n\n return lines\n}\n\nexport type TypedArrayString = 'int8'|'int16'|'int32'|'uint8'|'uint16'|'uint32'|'float32'\nexport function getTypedArray (arrayType: TypedArrayString, arraySize: number) {\n switch (arrayType) {\n case 'int8':\n return new Int8Array(arraySize)\n case 'int16':\n return new Int16Array(arraySize)\n case 'int32':\n return new Int32Array(arraySize)\n case 'uint8':\n return new Uint8Array(arraySize)\n case 'uint16':\n return new Uint16Array(arraySize)\n case 'uint32':\n return new Uint32Array(arraySize)\n case 'float32':\n return new Float32Array(arraySize)\n default:\n throw new Error('arrayType unknown: ' + arrayType)\n }\n}\n\nexport function getUintArray (sizeOrArray: any, maxUint: number) { // TODO\n const TypedArray = maxUint > 65535 ? Uint32Array : Uint16Array\n return new TypedArray(sizeOrArray)\n}\n\nexport function ensureArray (value: any) {\n return Array.isArray(value) ? value : [value]\n}\n\nexport function ensureBuffer (a: any) { // TODO\n return (a.buffer && a.buffer instanceof ArrayBuffer) ? a.buffer : a\n}\n\nfunction _ensureClassFromArg (arg: any, constructor: { new (arg: any): any }) {\n return arg instanceof constructor ? arg : new constructor(arg)\n}\n\nfunction _ensureClassFromArray (array: any, constructor: { new (): any }) {\n if (array === undefined) {\n array = new constructor()\n } else if (Array.isArray(array)) {\n array = new constructor().fromArray(array)\n }\n return array\n}\n\nexport function ensureVector2 (v?: number[]|Vector2) {\n return _ensureClassFromArray(v, Vector2)\n}\n\nexport function ensureVector3 (v?: number[]|Vector3) {\n return _ensureClassFromArray(v, Vector3)\n}\n\nexport function ensureMatrix4 (m?: number[]|Matrix4) {\n return _ensureClassFromArray(m, Matrix4)\n}\n\nexport function ensureQuaternion (q?: number[]|Quaternion) {\n return _ensureClassFromArray(q, Quaternion)\n}\n\nexport function ensureFloat32Array (a?: number[]|Float32Array) {\n return _ensureClassFromArg(a, Float32Array)\n}\n\nexport interface RingBuffer {\n has: (value: T) => boolean\n get: (value: number) => T\n push: (value: T) => void\n count: number\n data: T[]\n clear: () => void\n}\n\nexport function createRingBuffer (length: number): RingBuffer {\n let pointer = 0\n let count = 0\n const buffer: T[] = []\n\n return {\n has: function (value: any) { return buffer.indexOf(value) !== -1 },\n get: function (idx: number) { return buffer[idx] },\n push: function (item: any) {\n buffer[pointer] = item\n pointer = (length + pointer + 1) % length\n ++count\n },\n get count () { return count },\n get data () { return buffer.slice(0, Math.min(count, length)) },\n clear: function () {\n count = 0\n pointer = 0\n buffer.length = 0\n }\n }\n}\n\nexport interface SimpleDict {\n has: (k: K) => boolean\n add: (k: K, v: V) => void\n del: (k: K) => void\n values: V[]\n}\n\nexport function createSimpleDict (): SimpleDict {\n const set: { [k: string]: V } = {}\n\n return {\n has: function (k: K) { return set[JSON.stringify(k)] !== undefined },\n add: function (k: K, v: V) { set[JSON.stringify(k)] = v },\n del: function (k: K) { delete set[JSON.stringify(k)] },\n get values () { return Object.keys(set).map(k => set[k]) }\n }\n}\n\nexport interface SimpleSet {\n has: (value: T) => boolean\n add: (value: T) => void\n del: (value: T) => void\n list: T[]\n}\n\nexport function createSimpleSet (): SimpleSet {\n const set: { [k: string]: T } = {}\n\n return {\n has: function (v: T) { return set[JSON.stringify(v)] !== undefined },\n add: function (v: T) { set[JSON.stringify(v)] = v },\n del: function (v: T) { delete set[JSON.stringify(v)] },\n get list () { return Object.keys(set).map(k => set[k]) },\n }\n}\n","/**\n * @file Registry\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\n\nfunction toLowerCaseString (value: string) {\n return defaults(value, '').toString().toLowerCase()\n}\n\nexport default class Registry {\n name: string\n private _dict: {[k: string]: any}\n\n constructor (name: string) {\n this.name = name\n this._dict = {}\n }\n\n add (key: string, value: any) {\n this._dict[ toLowerCaseString(key) ] = value\n }\n\n get (key: string) {\n return this._dict[ toLowerCaseString(key) ]\n }\n\n get names () {\n return Object.keys(this._dict)\n }\n}","/**\n * @file Math Utils\n * @author Alexander Rose \n * @private\n */\n\nexport function degToRad (deg: number) {\n return deg * 0.01745 // deg * Math.PI / 180\n}\n\nexport function radToDeg (rad: number) {\n return rad * 57.29578 // rad * 180 / Math.PI\n}\n\n// http://www.broofa.com/Tools/Math.uuid.htm\nconst chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('')\nconst uuid = new Array(36)\n\nexport function generateUUID () {\n let rnd = 0\n let r\n\n for (let i = 0; i < 36; i++) {\n if (i === 8 || i === 13 || i === 18 || i === 23) {\n uuid[ i ] = '-'\n } else if (i === 14) {\n uuid[ i ] = '4'\n } else {\n if (rnd <= 0x02) rnd = 0x2000000 + (Math.random() * 0x1000000) | 0\n r = rnd & 0xf\n rnd = rnd >> 4\n uuid[ i ] = chars[ (i === 19) ? (r & 0x3) | 0x8 : r ]\n }\n }\n\n return uuid.join('')\n}\n\nexport function countSetBits (i: number) {\n i = i - ((i >> 1) & 0x55555555)\n i = (i & 0x33333333) + ((i >> 2) & 0x33333333)\n return (((i + (i >> 4)) & 0x0F0F0F0F) * 0x01010101) >> 24\n}\n\nexport function normalize (value: number, min: number, max: number) {\n return (value - min) / (max - min)\n}\n\nexport function clamp (value: number, min: number, max: number) {\n return Math.max(min, Math.min(max, value))\n}\n\nexport function pclamp (value: number) {\n return clamp(value, 0, 100)\n}\n\nexport function saturate (value: number) {\n return clamp(value, 0, 1)\n}\n\nexport function lerp (start: number, stop: number, alpha: number) {\n return start + (stop - start) * alpha\n}\n\nexport function spline (p0: number, p1: number, p2: number, p3: number, t: number, tension: number) {\n const v0 = (p2 - p0) * tension\n const v1 = (p3 - p1) * tension\n const t2 = t * t\n const t3 = t * t2\n return (2 * p1 - 2 * p2 + v0 + v1) * t3 +\n (-3 * p1 + 3 * p2 - 2 * v0 - v1) * t2 +\n v0 * t + p1\n}\n\nexport function smoothstep (min: number, max: number, x: number) {\n x = saturate(normalize(x, min, max))\n return x * x * (3 - 2 * x)\n}\n\nexport function smootherstep (min: number, max: number, x: number) {\n x = saturate(normalize(x, min, max))\n return x * x * x * (x * (x * 6 - 15) + 10)\n}\n\nexport function smootheststep (min: number, max: number, x: number) {\n x = saturate(normalize(x, min, max))\n return (\n -20 * Math.pow(x, 7) +\n 70 * Math.pow(x, 6) -\n 84 * Math.pow(x, 5) +\n 35 * Math.pow(x, 4)\n )\n}\n\nexport function almostIdentity (value: number, start: number, stop: number) {\n if (value > start) return value\n const a = 2 * stop - start\n const b = 2 * start - 3 * stop\n const t = value / start\n return (a * t + b) * t * t + stop\n}","/**\n * @file Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Color } from 'three'\nimport * as chroma from 'chroma-js'\n\nimport { createParams } from '../utils'\nimport { NumberArray } from '../types'\nimport Structure from '../structure/structure'\nimport Surface from '../surface/surface'\nimport Volume from '../surface/volume'\nimport AtomProxy from '../proxy/atom-proxy'\nimport BondProxy from '../proxy/bond-proxy'\n\nexport type ColorMode = 'rgb'|'hsv'|'hsl'|'hsi'|'lab'|'hcl'\nexport type ColorSpace = 'sRGB' | 'linear'\n\n/**\n * Internal color space for all colors (global).\n * Colors are always specified as sRGB; if this is set to\n * 'linear' then colors get linearized when used internally\n * as vertex or texture colors.\n * @see setColorSpace/getColorSpace.\n */\nvar colorSpace: ColorSpace = 'sRGB' // default: don't linearize\n\n/** Set the global internal color space for colormakers */\nexport function setColorSpace(space: ColorSpace) {\n colorSpace = space\n}\n\n/** Get the global internal color space for colormakers */\nexport function getColorSpace() {\n return colorSpace\n}\n\nexport const ScaleDefaultParameters = {\n scale: 'uniform' as string|string[],\n mode: 'hcl' as ColorMode,\n domain: [ 0, 1 ] as number[],\n value: 0xFFFFFF,\n reverse: false,\n}\nexport type ScaleParameters = typeof ScaleDefaultParameters\n\nexport interface ColorData {\n atomData?: number[],\n bondData?: number[]\n}\n\nexport interface ColormakerParameters extends ScaleParameters {\n structure?: Structure\n volume?: Volume\n surface?: Surface\n data?: ColorData\n}\n\nexport type StuctureColormakerParams = { structure: Structure } & Partial\nexport type VolumeColormakerParams = { volume: Volume } & Partial\nexport type ColormakerScale = (v: number) => number\n\nconst tmpColor = new Color()\n\n/** Decorator for optionally linearizing a numeric color */\ntype colorFuncType = (value: any, fromTo?: boolean) => number // decorator applies to functions with this shape\nexport function manageColor\n (_target: Object,\n _name: string | symbol,\n descriptor: TypedPropertyDescriptor): PropertyDescriptor {\n const originalMethod = descriptor.value\n const linearize: colorFuncType = function (this: T, value: any, fromTo?: boolean) {\n let result = originalMethod!.bind(this, value, fromTo)()\n if (colorSpace == 'linear') {\n tmpColor.set(result)\n tmpColor.convertSRGBToLinear()\n return tmpColor.getHex()\n } else {\n return result\n }\n }\n descriptor.value = linearize\n return descriptor\n }\n\n/**\n * Class for making colors.\n * @interface\n */\nabstract class Colormaker {\n parameters: ColormakerParameters\n atomProxy?: AtomProxy\n\n /**\n * Create a colormaker instance\n * @param {ColormakerParameters} params - colormaker parameter\n */\n constructor (params: Partial = {}) {\n this.parameters = createParams(params, ScaleDefaultParameters)\n\n if (typeof this.parameters.value === 'string') {\n this.parameters.value = tmpColor.set(this.parameters.value).getHex()\n }\n\n if (this.parameters.structure) {\n this.atomProxy = this.parameters.structure.getAtomProxy()\n }\n }\n\n getScale (params: Partial = {}) {\n const p = createParams(params, this.parameters)\n\n if (p.scale === 'rainbow') {\n p.scale = [ 'red', 'orange', 'yellow', 'green', 'blue' ]\n } else if (p.scale === 'rwb') {\n p.scale = [ 'red', 'white', 'blue' ]\n }\n\n if (p.reverse) {\n p.domain = p.domain.slice().reverse()\n }\n return chroma\n .scale(p.scale as any) // TODO\n .mode(p.mode)\n .domain(p.domain)\n .out('num' as any) // returns RGB color as numeric (not string \"#ffffff\")\n }\n\n /**\n * save a color to an array\n * @param {Integer} color - hex color value\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n colorToArray (color: number, array: NumberArray = [], offset = 0) {\n array[ offset ] = (color >> 16 & 255) / 255\n array[ offset + 1 ] = (color >> 8 & 255) / 255\n array[ offset + 2 ] = (color & 255) / 255\n\n return array\n }\n\n atomColor? (atom: AtomProxy): number\n\n /**\n * save an atom color to an array\n * @param {AtomProxy} atom - atom to get color for\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n atomColorToArray (atom: AtomProxy, array: NumberArray, offset: number) {\n return this.colorToArray(\n this.atomColor ? this.atomColor(atom) : 0x000000, array, offset\n )\n }\n\n /**\n * return the color for an bond\n * @param {BondProxy} bond - bond to get color for\n * @param {Boolean} fromTo - whether to use the first or second atom of the bond\n * @return {Integer} hex bond color\n */\n bondColor (bond: BondProxy, fromTo: boolean) {\n if (this.atomProxy && this.atomColor) {\n this.atomProxy.index = fromTo ? bond.atomIndex1 : bond.atomIndex2\n return this.atomColor(this.atomProxy)\n } else {\n return 0x000000\n }\n }\n\n /**\n * safe a bond color to an array\n * @param {BondProxy} bond - bond to get color for\n * @param {Boolean} fromTo - whether to use the first or second atom of the bond\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n bondColorToArray (bond: BondProxy, fromTo: boolean, array: NumberArray, offset: number) {\n return this.colorToArray(\n this.bondColor(bond, fromTo), array, offset\n )\n }\n\n volumeColor? (index: number): number\n\n /**\n * safe a volume cell color to an array\n * @param {Integer} index - volume cell index\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n volumeColorToArray (index: number, array: NumberArray, offset: number) {\n return this.colorToArray(\n this.volumeColor ? this.volumeColor(index) : 0x000000, array, offset\n )\n }\n\n positionColor? (position: Vector3): number\n\n /**\n * safe a color for coordinates in space to an array\n * @param {Vector3} coords - xyz coordinates\n * @param {Array|TypedArray} array - destination\n * @param {Integer} offset - index into the array\n * @return {Array} the destination array\n */\n positionColorToArray (coords: Vector3, array: NumberArray, offset: number) {\n return this.colorToArray(\n this.positionColor ? this.positionColor(coords) : 0x000000, array, offset\n )\n }\n}\n\nexport default Colormaker\n","/**\n * @file Selection Constants\n * @author Alexander Rose \n * @private\n */\n\nexport enum kwd {\n PROTEIN = 1,\n NUCLEIC = 2,\n RNA = 3,\n DNA = 4,\n POLYMER = 5,\n WATER = 6,\n HELIX = 7,\n SHEET = 8,\n TURN = 9,\n BACKBONE = 10,\n SIDECHAIN = 11,\n ALL = 12,\n HETERO = 13,\n ION = 14,\n SACCHARIDE = 15,\n SUGAR = 15,\n BONDED = 16,\n RING = 17,\n AROMATICRING = 18,\n METAL = 19,\n POLARH = 20,\n NONE = 21\n}\n\nexport const SelectAllKeyword = [ '*', '', 'ALL' ]\nexport const SelectNoneKeyword = [ 'NONE' ]\n\nexport const AtomOnlyKeywords = [\n kwd.BACKBONE, kwd.SIDECHAIN, kwd.BONDED, kwd.RING, kwd.AROMATICRING, kwd.METAL, kwd.POLARH\n]\n\nexport const ChainKeywords = [\n kwd.POLYMER, kwd.WATER\n]\n\nexport const SmallResname = [ 'ALA', 'GLY', 'SER' ]\nexport const NucleophilicResname = [ 'CYS', 'SER', 'THR' ]\nexport const HydrophobicResname = [ 'ALA', 'ILE', 'LEU', 'MET', 'PHE', 'PRO', 'TRP', 'VAL' ]\nexport const AromaticResname = [ 'PHE', 'TRP', 'TYR', 'HIS' ]\nexport const AmideResname = [ 'ASN', 'GLN' ]\nexport const AcidicResname = [ 'ASP', 'GLU' ]\nexport const BasicResname = [ 'ARG', 'HIS', 'LYS' ]\nexport const ChargedResname = [ 'ARG', 'ASP', 'GLU', 'HIS', 'LYS' ]\nexport const PolarResname = [ 'ASN', 'ARG', 'ASP', 'CYS', 'GLY', 'GLN', 'GLU', 'HIS', 'LYS', 'SER', 'THR', 'TYR' ]\nexport const NonpolarResname = [ 'ALA', 'ILE', 'LEU', 'MET', 'PHE', 'PRO', 'TRP', 'VAL' ]\nexport const CyclicResname = [ 'HIS', 'PHE', 'PRO', 'TRP', 'TYR' ]\nexport const AliphaticResname = [ 'ALA', 'GLY', 'ILE', 'LEU', 'VAL' ]\n","/**\n * @file Selection Test\n * @author Alexander Rose \n * @private\n */\n\nimport { binarySearchIndexOf, rangeInSortedArray } from '../utils'\nimport { kwd, AtomOnlyKeywords, ChainKeywords } from './selection-constants'\n\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\nexport type ProxyEntity = AtomProxy|ResidueProxy|ChainProxy|ModelProxy\ntype TestEntityFn = (e: ProxyEntity, s: SelectionRule) => boolean|-1\ntype FilterFn = (s: SelectionRule) => boolean\nexport type SelectionTest = false|((e: ProxyEntity) => boolean|-1)\n\nexport type SelectionOperator = 'AND'|'OR'\nexport interface SelectionRule {\n keyword?: any\n atomname?: string\n element?: string\n atomindex?: number[]\n altloc?: string\n inscode?: string\n resname?: string|string[]\n sstruc?: string\n resno?: number|[number, number]\n chainname?: string\n model?: number\n\n error?: string\n rules?: SelectionRule[]\n negate?: boolean\n operator?: SelectionOperator\n}\n\nfunction atomTestFn (a: AtomProxy, s: SelectionRule) {\n // returning -1 means the rule is not applicable\n if (s.atomname === undefined && s.element === undefined &&\n s.altloc === undefined && s.atomindex === undefined &&\n s.keyword === undefined && s.inscode === undefined &&\n s.resname === undefined && s.sstruc === undefined &&\n s.resno === undefined && s.chainname === undefined &&\n s.model === undefined\n ) return -1\n\n if (s.keyword !== undefined) {\n if (s.keyword === kwd.BACKBONE && !a.isBackbone()) return false\n if (s.keyword === kwd.SIDECHAIN && !a.isSidechain()) return false\n if (s.keyword === kwd.BONDED && !a.isBonded()) return false\n if (s.keyword === kwd.RING && !a.isRing()) return false\n if (s.keyword === kwd.AROMATICRING && !a.isAromatic()) return false\n\n if (s.keyword === kwd.HETERO && !a.isHetero()) return false\n if (s.keyword === kwd.PROTEIN && !a.isProtein()) return false\n if (s.keyword === kwd.NUCLEIC && !a.isNucleic()) return false\n if (s.keyword === kwd.RNA && !a.isRna()) return false\n if (s.keyword === kwd.DNA && !a.isDna()) return false\n if (s.keyword === kwd.POLYMER && !a.isPolymer()) return false\n if (s.keyword === kwd.WATER && !a.isWater()) return false\n if (s.keyword === kwd.HELIX && !a.isHelix()) return false\n if (s.keyword === kwd.SHEET && !a.isSheet()) return false\n if (s.keyword === kwd.TURN && !a.isTurn()) return false\n if (s.keyword === kwd.ION && !a.isIon()) return false\n if (s.keyword === kwd.SACCHARIDE && !a.isSaccharide()) return false\n if (s.keyword === kwd.METAL && !a.isMetal()) return false\n if (s.keyword === kwd.POLARH && !a.isPolarHydrogen()) return false\n }\n\n if (s.atomname !== undefined && s.atomname !== a.atomname) return false\n if (s.element !== undefined && s.element !== a.element) return false\n if (s.altloc !== undefined && s.altloc !== a.altloc) return false\n\n if (s.atomindex !== undefined &&\n binarySearchIndexOf(s.atomindex, a.index) < 0\n ) return false\n\n if (s.resname !== undefined) {\n if (Array.isArray(s.resname)) {\n if (!s.resname.includes(a.resname)) return false\n } else {\n if (s.resname !== a.resname) return false\n }\n }\n if (s.sstruc !== undefined && s.sstruc !== a.sstruc) return false\n if (s.resno !== undefined) {\n if (Array.isArray(s.resno) && s.resno.length === 2) {\n if (s.resno[0] > a.resno || s.resno[1] < a.resno) return false\n } else {\n if (s.resno !== a.resno) return false\n }\n }\n if (s.inscode !== undefined && s.inscode !== a.inscode) return false\n\n if (s.chainname !== undefined && s.chainname !== a.chainname) return false\n if (s.model !== undefined && s.model !== a.modelIndex) return false\n\n return true\n}\n\nfunction residueTestFn (r: ResidueProxy, s: SelectionRule) {\n // returning -1 means the rule is not applicable\n if (s.resname === undefined && s.resno === undefined && s.inscode === undefined &&\n s.sstruc === undefined && s.model === undefined && s.chainname === undefined &&\n s.atomindex === undefined &&\n (s.keyword === undefined || AtomOnlyKeywords.includes(s.keyword))\n ) return -1\n\n if (s.keyword !== undefined) {\n if (s.keyword === kwd.HETERO && !r.isHetero()) return false\n if (s.keyword === kwd.PROTEIN && !r.isProtein()) return false\n if (s.keyword === kwd.NUCLEIC && !r.isNucleic()) return false\n if (s.keyword === kwd.RNA && !r.isRna()) return false\n if (s.keyword === kwd.DNA && !r.isDna()) return false\n if (s.keyword === kwd.POLYMER && !r.isPolymer()) return false\n if (s.keyword === kwd.WATER && !r.isWater()) return false\n if (s.keyword === kwd.HELIX && !r.isHelix()) return false\n if (s.keyword === kwd.SHEET && !r.isSheet()) return false\n if (s.keyword === kwd.TURN && !r.isTurn()) return false\n if (s.keyword === kwd.ION && !r.isIon()) return false\n if (s.keyword === kwd.SACCHARIDE && !r.isSaccharide()) return false\n }\n\n if (s.atomindex !== undefined &&\n rangeInSortedArray(s.atomindex, r.atomOffset, r.atomEnd) === 0\n ) return false\n\n if (s.resname !== undefined) {\n if (Array.isArray(s.resname)) {\n if (!s.resname.includes(r.resname)) return false\n } else {\n if (s.resname !== r.resname) return false\n }\n }\n if (s.sstruc !== undefined && s.sstruc !== r.sstruc) return false\n if (s.resno !== undefined) {\n if (Array.isArray(s.resno) && s.resno.length === 2) {\n if (s.resno[0] > r.resno || s.resno[1] < r.resno) return false\n } else {\n if (s.resno !== r.resno) return false\n }\n }\n if (s.inscode !== undefined && s.inscode !== r.inscode) return false\n\n if (s.chainname !== undefined && s.chainname !== r.chainname) return false\n if (s.model !== undefined && s.model !== r.modelIndex) return false\n\n return true\n}\n\nfunction chainTestFn (c: ChainProxy, s: SelectionRule) {\n // returning -1 means the rule is not applicable\n if (s.chainname === undefined && s.model === undefined && s.atomindex === undefined &&\n (s.keyword === undefined || !ChainKeywords.includes(s.keyword) || !c.entity)\n ) return -1\n\n if (s.keyword !== undefined) {\n if (s.keyword === kwd.POLYMER && !c.entity.isPolymer()) return false\n if (s.keyword === kwd.WATER && !c.entity.isWater()) return false\n }\n\n if (s.atomindex !== undefined &&\n rangeInSortedArray(s.atomindex, c.atomOffset, c.atomEnd) === 0\n ) return false\n\n if (s.chainname !== undefined && s.chainname !== c.chainname) return false\n\n if (s.model !== undefined && s.model !== c.modelIndex) return false\n\n return true\n}\n\nfunction modelTestFn (m: ModelProxy, s: SelectionRule) {\n // returning -1 means the rule is not applicable\n if (s.model === undefined && s.atomindex === undefined) return -1\n\n if (s.atomindex !== undefined &&\n rangeInSortedArray(s.atomindex, m.atomOffset, m.atomEnd) === 0\n ) return false\n\n if (s.model !== undefined && s.model !== m.index) return false\n\n return true\n}\n\nfunction makeTest (selection: SelectionRule|null, fn: TestEntityFn) {\n if (selection === null) return false\n if (selection.error) return false\n if (!selection.rules || selection.rules.length === 0) return false\n\n const n = selection.rules.length\n\n const t = !selection.negate\n const f = !!selection.negate\n\n const subTests: SelectionTest[] = []\n for (let i = 0; i < n; ++i) {\n const s = selection.rules[ i ]\n if (s.hasOwnProperty('operator')) {\n subTests[ i ] = makeTest(s, fn) as SelectionTest // TODO\n }\n }\n\n // ( x and y ) can short circuit on false\n // ( x or y ) can short circuit on true\n // not ( x and y )\n\n return function test (entity: ProxyEntity) {\n const and = selection.operator === 'AND'\n let na = false\n\n for (let i = 0; i < n; ++i) {\n const s = selection.rules![ i ] // TODO\n let ret\n\n if (s.hasOwnProperty('operator')) {\n const test = subTests[ i ]\n if (test !== false) {\n ret = test(entity)\n } else {\n ret = -1\n }\n\n if (ret === -1) {\n na = true\n continue\n } else if (ret === true) {\n if (and) { continue } else { return t }\n } else {\n if (and) { return f } else { continue }\n }\n } else {\n if (s.keyword === kwd.ALL) {\n if (and) { continue } else { return t }\n } else if (s.keyword === kwd.NONE) {\n if (and) { continue } else { return f }\n }\n\n ret = fn(entity, s)\n\n // console.log( entity.qualifiedName(), ret, s, selection.negate, \"t\", t, \"f\", f )\n\n if (ret === -1) {\n na = true\n continue\n } else if (ret === true) {\n if (and) { continue } else { return t }\n } else {\n if (and) { return f } else { continue }\n }\n }\n }\n\n if (na) {\n return -1\n } else {\n if (and) { return t } else { return f }\n }\n } as SelectionTest\n}\n\nfunction filter (selection: SelectionRule, fn: FilterFn) {\n if (selection.error) return selection\n if (!selection.rules || selection.rules.length === 0) return selection\n\n const n = selection.rules.length\n\n const filtered: SelectionRule = {\n operator: selection.operator,\n rules: []\n }\n if (selection.hasOwnProperty('negate')) {\n filtered.negate = selection.negate\n }\n\n for (let i = 0; i < n; ++i) {\n const s = selection.rules[ i ]\n if (s.hasOwnProperty('operator')) {\n const fs = filter(s, fn)\n if (fs !== null) filtered.rules!.push(fs) // TODO\n } else if (!fn(s)) {\n filtered.rules!.push(s) // TODO\n }\n }\n\n if (filtered.rules!.length > 0) { // TODO\n // TODO maybe the filtered rules could be returned\n // in some case, but the way how tests are applied\n // e.g. when traversing a structure would also need\n // to change\n return selection\n // return filtered;\n } else {\n return null\n }\n}\n\nfunction makeAtomTest (selection: SelectionRule, atomOnly = false) {\n let filteredSelection: SelectionRule|null = selection\n if (atomOnly) {\n filteredSelection = filter(selection, function (s) {\n if (s.keyword !== undefined && !AtomOnlyKeywords.includes(s.keyword)) return true\n if (s.model !== undefined) return true\n if (s.chainname !== undefined) return true\n if (s.resname !== undefined) return true\n if (s.resno !== undefined) return true\n if (s.sstruc !== undefined) return true\n return false\n })\n }\n return makeTest(filteredSelection, atomTestFn)\n}\n\nfunction makeResidueTest (selection: SelectionRule, residueOnly = false) {\n let filteredSelection: SelectionRule|null = selection\n if (residueOnly) {\n filteredSelection = filter(selection, function (s) {\n if (s.keyword !== undefined && AtomOnlyKeywords.includes(s.keyword)) return true\n if (s.model !== undefined) return true\n if (s.chainname !== undefined) return true\n if (s.atomname !== undefined) return true\n if (s.element !== undefined) return true\n if (s.altloc !== undefined) return true\n return false\n })\n }\n return makeTest(filteredSelection, residueTestFn)\n}\n\nfunction makeChainTest (selection: SelectionRule, chainOnly = false) {\n let filteredSelection: SelectionRule|null = selection\n if (chainOnly) {\n filteredSelection = filter(selection, function (s) {\n if (s.keyword !== undefined && !ChainKeywords.includes(s.keyword)) return true\n // if( s.model!==undefined ) return true;\n if (s.resname !== undefined) return true\n if (s.resno !== undefined) return true\n if (s.atomname !== undefined) return true\n if (s.element !== undefined) return true\n if (s.altloc !== undefined) return true\n if (s.sstruc !== undefined) return true\n if (s.inscode !== undefined) return true\n return false\n })\n }\n return makeTest(filteredSelection, chainTestFn)\n}\n\nfunction makeModelTest (selection: SelectionRule, modelOnly = false) {\n let filteredSelection: SelectionRule|null = selection\n if (modelOnly) {\n filteredSelection = filter(selection, function (s) {\n if (s.keyword !== undefined) return true\n if (s.chainname !== undefined) return true\n if (s.resname !== undefined) return true\n if (s.resno !== undefined) return true\n if (s.atomname !== undefined) return true\n if (s.element !== undefined) return true\n if (s.altloc !== undefined) return true\n if (s.sstruc !== undefined) return true\n if (s.inscode !== undefined) return true\n return false\n })\n }\n return makeTest(filteredSelection, modelTestFn)\n}\n\nexport {\n makeAtomTest,\n makeResidueTest,\n makeChainTest,\n makeModelTest\n}\n","/**\n * @file Selection\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { parseSele } from './selection-parser'\nimport {\n SelectionTest, SelectionRule,\n makeAtomTest, makeResidueTest, makeChainTest, makeModelTest\n} from './selection-test'\nimport { SelectAllKeyword, SelectNoneKeyword } from './selection-constants'\n\nexport type SelectionSignals = {\n stringChanged: Signal\n}\n\n/**\n * Selection\n */\nclass Selection {\n signals: SelectionSignals\n string: string\n selection: SelectionRule\n\n test: SelectionTest\n residueTest: SelectionTest\n chainTest: SelectionTest\n modelTest: SelectionTest\n\n atomOnlyTest: SelectionTest\n residueOnlyTest: SelectionTest\n chainOnlyTest: SelectionTest\n modelOnlyTest: SelectionTest\n\n /**\n * Create Selection\n * @param {String} string - selection string, see {@tutorial selection-language}\n */\n constructor (string?: string) {\n this.signals = {\n stringChanged: new Signal()\n }\n\n this.setString(string)\n }\n\n get type () { return 'selection' }\n\n setString (string?: string, silent?: boolean) {\n if (string === undefined) string = this.string || ''\n if (string === this.string) return\n\n try {\n this.selection = parseSele(string)\n } catch (e) {\n // Log.error( e.stack );\n this.selection = { 'error': e.message }\n }\n const selection = this.selection\n\n this.string = string\n\n this.test = makeAtomTest(selection)\n this.residueTest = makeResidueTest(selection)\n this.chainTest = makeChainTest(selection)\n this.modelTest = makeModelTest(selection)\n\n this.atomOnlyTest = makeAtomTest(selection, true)\n this.residueOnlyTest = makeResidueTest(selection, true)\n this.chainOnlyTest = makeChainTest(selection, true)\n this.modelOnlyTest = makeModelTest(selection, true)\n\n if (!silent) {\n this.signals.stringChanged.dispatch(this.string)\n }\n }\n\n isAllSelection () {\n return SelectAllKeyword.includes(this.string.toUpperCase())\n }\n\n isNoneSelection () {\n return SelectNoneKeyword.includes(this.string.toUpperCase())\n }\n}\n\nexport default Selection\n","/**\n * @file Selection Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { SelectionRule, SelectionOperator } from './selection-test'\nimport {\n kwd, SelectAllKeyword,\n SmallResname, NucleophilicResname, HydrophobicResname, AromaticResname,\n AmideResname, AcidicResname, BasicResname, ChargedResname,\n PolarResname, NonpolarResname, CyclicResname, AliphaticResname\n} from './selection-constants'\n\nfunction parseSele (string: string) {\n let retSelection: SelectionRule = {\n operator: undefined,\n rules: []\n }\n\n if (!string) {\n return retSelection\n }\n\n let selection = retSelection\n let newSelection: SelectionRule\n let oldSelection: SelectionRule\n const selectionStack: SelectionRule[] = []\n\n string = string.replace(/\\(/g, ' ( ').replace(/\\)/g, ' ) ').trim()\n if (string.charAt(0) === '(' && string.substr(-1) === ')') {\n string = string.slice(1, -1).trim()\n }\n const chunks = string.split(/\\s+/)\n\n // Log.log( string, chunks )\n\n const createNewContext = (operator?: SelectionOperator) => {\n newSelection = {\n operator,\n rules: []\n }\n if (selection === undefined) {\n selection = newSelection\n retSelection = newSelection\n } else {\n selection.rules!.push(newSelection)\n selectionStack.push(selection)\n selection = newSelection\n }\n }\n\n const getPrevContext = function (operator?: SelectionOperator) {\n oldSelection = selection\n selection = selectionStack.pop()!\n if (selection === undefined) {\n createNewContext(operator)\n pushRule(oldSelection)\n }\n }\n\n const pushRule = function (rule: SelectionRule) {\n selection.rules!.push(rule)\n }\n\n let not: false|0|1|2 = false\n\n for (let i = 0; i < chunks.length; ++i) {\n const c = chunks[ i ]\n const cu = c.toUpperCase()\n\n // handle parens\n\n if (c === '(') {\n // Log.log( \"(\" );\n not = false\n createNewContext()\n continue\n } else if (c === ')') {\n // Log.log( \")\" );\n getPrevContext()\n if (selection.negate) {\n getPrevContext()\n }\n continue\n }\n\n // leave 'not' context\n\n if (not > 0) {\n if (cu === 'NOT') {\n not = 1\n } else if (not === 1) {\n not = 2\n } else if (not === 2) {\n not = false\n getPrevContext()\n } else {\n throw new Error(\"something went wrong with 'not'\")\n }\n }\n\n // handle logic operators\n\n if (cu === 'AND') {\n // Log.log( \"AND\" );\n if (selection.operator === 'OR') {\n const lastRule = selection.rules!.pop()!\n createNewContext('AND')\n pushRule(lastRule)\n } else {\n selection.operator = 'AND'\n }\n continue\n } else if (cu === 'OR') {\n // Log.log( \"OR\" );\n if (selection.operator === 'AND') {\n getPrevContext('OR')\n } else {\n selection.operator = 'OR'\n }\n continue\n } else if (c.toUpperCase() === 'NOT') {\n // Log.log( \"NOT\", j );\n not = 1\n createNewContext()\n selection.negate = true\n continue\n } else {\n // Log.log( \"chunk\", c, j, selection );\n }\n\n // handle keyword attributes\n\n // ensure `cu` is not a number before testing if it is in the\n // kwd enum dictionary which includes the enum numbers as well...\n if (+cu !== +cu) {\n const keyword = (kwd as any)[ cu ]\n if (keyword !== undefined) {\n pushRule({ keyword })\n continue\n }\n }\n\n if (cu === 'HYDROGEN') {\n pushRule({\n operator: 'OR',\n rules: [\n { element: 'H' },\n { element: 'D' }\n ]\n })\n continue\n }\n\n if (cu === 'SMALL') {\n pushRule({ resname: SmallResname })\n continue\n }\n\n if (cu === 'NUCLEOPHILIC') {\n pushRule({ resname: NucleophilicResname })\n continue\n }\n\n if (cu === 'HYDROPHOBIC') {\n pushRule({ resname: HydrophobicResname })\n continue\n }\n\n if (cu === 'AROMATIC') {\n pushRule({ resname: AromaticResname })\n continue\n }\n\n if (cu === 'AMIDE') {\n pushRule({ resname: AmideResname })\n continue\n }\n\n if (cu === 'ACIDIC') {\n pushRule({ resname: AcidicResname })\n continue\n }\n\n if (cu === 'BASIC') {\n pushRule({ resname: BasicResname })\n continue\n }\n\n if (cu === 'CHARGED') {\n pushRule({ resname: ChargedResname })\n continue\n }\n\n if (cu === 'POLAR') {\n pushRule({ resname: PolarResname })\n continue\n }\n\n if (cu === 'NONPOLAR') {\n pushRule({ resname: NonpolarResname })\n continue\n }\n\n if (cu === 'CYCLIC') {\n pushRule({ resname: CyclicResname })\n continue\n }\n\n if (cu === 'ALIPHATIC') {\n pushRule({ resname: AliphaticResname })\n continue\n }\n\n if (cu === 'SIDECHAINATTACHED') {\n pushRule({\n operator: 'OR',\n rules: [\n { keyword: kwd.SIDECHAIN },\n {\n operator: 'AND',\n negate: false,\n rules: [\n { keyword: kwd.PROTEIN },\n {\n operator: 'OR',\n negate: false,\n rules: [\n { atomname: 'CA' },\n { atomname: 'BB' }\n ]\n }\n ]\n },\n {\n operator: 'AND',\n negate: false,\n rules: [\n { resname: 'PRO' },\n { atomname: 'N' }\n ]\n },\n {\n operator: 'AND',\n negate: false,\n rules: [\n { keyword: kwd.NUCLEIC },\n {\n operator: 'OR',\n negate: true,\n rules: [\n { atomname: 'P' },\n { atomname: 'OP1' },\n { atomname: 'OP2' },\n { atomname: \"O3'\" },\n { atomname: 'O3*' },\n { atomname: \"HO3'\"},\n { atomname: \"O5'\" },\n { atomname: 'O5*' },\n { atomname: \"HO5'\"},\n { atomname: \"C5'\" },\n { atomname: 'C5*' },\n { atomname: \"H5'\" },\n { atomname: \"H5''\"}\n ]\n }\n ]\n }\n ]\n })\n continue\n }\n\n if (cu === 'APOLARH') {\n pushRule({\n operator: 'AND',\n negate: false,\n rules: [\n { element: 'H' },\n {\n negate: true,\n operator: undefined,\n rules: [\n { keyword: kwd.POLARH }\n ]\n }\n ]\n })\n continue\n }\n\n if (cu === 'LIGAND') {\n pushRule({\n operator: 'AND',\n rules: [\n {\n operator: 'OR',\n rules: [\n {\n operator: 'AND',\n rules: [\n { keyword: kwd.HETERO },\n {\n negate: true,\n operator: undefined,\n rules: [\n { keyword: kwd.POLYMER }\n ]\n }\n ]\n },\n {\n negate: true,\n operator: undefined,\n rules: [\n { keyword: kwd.POLYMER }\n ]\n }\n ]\n },\n {\n negate: true,\n operator: undefined,\n rules: [\n {\n operator: 'OR',\n rules: [\n { keyword: kwd.WATER },\n { keyword: kwd.ION }\n ]\n }\n ]\n }\n ]\n })\n continue\n }\n\n if (SelectAllKeyword.indexOf(cu) !== -1) {\n pushRule({ keyword: kwd.ALL })\n continue\n }\n\n // handle atom expressions\n\n if (c.charAt(0) === '@') {\n const indexList = c.substr(1).split(',').map(x => parseInt(x))\n indexList.sort(function (a, b) { return a - b })\n pushRule({ atomindex: indexList })\n continue\n }\n\n if (c.charAt(0) === '#') {\n console.error('# for element selection deprecated, use _')\n pushRule({ element: cu.substr(1) })\n continue\n }\n if (c.charAt(0) === '_') {\n pushRule({ element: cu.substr(1) })\n continue\n }\n\n if (c[0] === '[' && c[c.length - 1] === ']') {\n const resnameList = cu.substr(1, c.length - 2).split(',')\n const resname = resnameList.length > 1 ? resnameList : resnameList[ 0 ]\n pushRule({ resname: resname })\n continue\n } else if (\n (c.length >= 1 && c.length <= 4) &&\n c[0] !== '^' && c[0] !== ':' && c[0] !== '.' && c[0] !== '%' && c[0] !== '/' &&\n isNaN(parseInt(c))\n ) {\n pushRule({ resname: cu })\n continue\n }\n\n // there must be only one constraint per rule\n // otherwise a test quickly becomes not applicable\n // e.g. chainTest for chainname when resno is present too\n\n const sele: SelectionRule = {\n operator: 'AND',\n rules: []\n }\n\n const model = c.split('/')\n if (model.length > 1 && model[1]) {\n if (isNaN(parseInt(model[1]))) {\n throw new Error('model must be an integer')\n }\n sele.rules!.push({\n model: parseInt(model[1])\n })\n }\n\n const altloc = model[0].split('%')\n if (altloc.length > 1) {\n sele.rules!.push({\n altloc: altloc[1]\n })\n }\n\n const atomname = altloc[0].split('.')\n if (atomname.length > 1 && atomname[1]) {\n if (atomname[1].length > 4) {\n throw new Error('atomname must be one to four characters')\n }\n sele.rules!.push({\n atomname: atomname[1].substring(0, 4).toUpperCase()\n })\n }\n\n const chain = atomname[0].split(':')\n if (chain.length > 1 && chain[1]) {\n sele.rules!.push({\n chainname: chain[1]\n })\n }\n\n const inscode = chain[0].split('^')\n if (inscode.length > 1) {\n sele.rules!.push({\n inscode: inscode[1]\n })\n }\n\n if (inscode[0]) {\n let negate, negate2\n if (inscode[0][0] === '-') {\n inscode[0] = inscode[0].substr(1)\n negate = true\n }\n if (inscode[0].includes('--')) {\n inscode[0] = inscode[0].replace('--', '-')\n negate2 = true\n }\n let resi = inscode[0].split('-')\n if (resi.length === 1) {\n let resiSingle = parseInt(resi[0])\n if (isNaN(resiSingle)) {\n throw new Error('resi must be an integer')\n }\n if (negate) resiSingle *= -1\n sele.rules!.push({\n resno: resiSingle\n })\n } else if (resi.length === 2) {\n const resiRange = resi.map(x => parseInt(x))\n if (negate) resiRange[0] *= -1\n if (negate2) resiRange[1] *= -1\n sele.rules!.push({\n resno: [resiRange[0], resiRange[1]]\n })\n } else {\n throw new Error(\"resi range must contain one '-'\")\n }\n }\n\n // round up\n\n if (sele.rules!.length === 1) {\n pushRule(sele.rules![ 0 ])\n } else if (sele.rules!.length > 1) {\n pushRule(sele)\n } else {\n throw new Error('empty selection chunk')\n }\n }\n\n // cleanup\n\n if (\n retSelection.operator === undefined &&\n retSelection.rules!.length === 1 &&\n retSelection.rules![ 0 ].hasOwnProperty('operator')\n ) {\n retSelection = retSelection.rules![ 0 ]\n }\n\n return retSelection\n}\n\nexport {\n parseSele\n}\n","/**\n * @file Selection Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { Color } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport Selection from '../selection/selection'\nimport Colormaker, { ColormakerParameters } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Structure from '../structure/structure'\n\nexport type SelectionSchemeData = [ string, string, ColormakerParameters|undefined ]\n\n/**\n * Color based on {@link Selection}\n */\nclass SelectionColormaker extends Colormaker {\n colormakerList: any[] = [] // TODO\n selectionList: Selection[] = []\n\n constructor (params: { structure: Structure, dataList: SelectionSchemeData[] } & Partial) {\n super(params)\n\n const dataList = params.dataList || []\n\n dataList.forEach((data: SelectionSchemeData) => {\n const [ scheme, sele, params = {} ] = data\n\n if (ColormakerRegistry.hasScheme(scheme)) {\n Object.assign(params, {\n scheme: scheme,\n structure: this.parameters.structure\n })\n } else {\n Object.assign(params, {\n scheme: 'uniform',\n value: new Color(scheme).getHex()\n })\n }\n\n this.colormakerList.push(ColormakerRegistry.getScheme(params as { scheme: string } & ColormakerParameters))\n this.selectionList.push(new Selection(sele))\n })\n }\n\n // NOT NEEDED @manageColor\n atomColor (a: AtomProxy) {\n for (let i = 0, n = this.selectionList.length; i < n; ++i) {\n const test = this.selectionList[ i ].test\n if (test && test(a)) {\n return this.colormakerList[ i ].atomColor(a)\n }\n }\n\n return 0xFFFFFF\n }\n}\n\nexport default SelectionColormaker\n","/**\n * @file Colormaker Registry\n * @author Alexander Rose \n * @private\n */\n\nimport { generateUUID } from '../math/math-utils'\nimport Colormaker, { ColormakerParameters } from './colormaker'\nimport SelectionColormaker, { SelectionSchemeData } from './selection-colormaker'\nimport Structure from '../structure/structure'\n\nconst ColormakerScales = {\n '': '',\n\n // Sequential\n OrRd: '[S] Orange-Red',\n PuBu: '[S] Purple-Blue',\n BuPu: '[S] Blue-Purple',\n Oranges: '[S] Oranges',\n BuGn: '[S] Blue-Green',\n YlOrBr: '[S] Yellow-Orange-Brown',\n YlGn: '[S] Yellow-Green',\n Reds: '[S] Reds',\n RdPu: '[S] Red-Purple',\n Greens: '[S] Greens',\n YlGnBu: '[S] Yellow-Green-Blue',\n Purples: '[S] Purples',\n GnBu: '[S] Green-Blue',\n Greys: '[S] Greys',\n YlOrRd: '[S] Yellow-Orange-Red',\n PuRd: '[S] Purple-Red',\n Blues: '[S] Blues',\n PuBuGn: '[S] Purple-Blue-Green',\n\n // Diverging\n Viridis: '[D] Viridis',\n Spectral: '[D] Spectral',\n RdYlGn: '[D] Red-Yellow-Green',\n RdBu: '[D] Red-Blue',\n PiYG: '[D] Pink-Yellowgreen',\n PRGn: '[D] Purplered-Green',\n RdYlBu: '[D] Red-Yellow-Blue',\n BrBG: '[D] Brown-Bluegreen',\n RdGy: '[D] Red-Grey',\n PuOr: '[D] Purple-Orange',\n\n // Qualitative\n Set1: '[Q] Set1',\n Set2: '[Q] Set2',\n Set3: '[Q] Set3',\n Dark2: '[Q] Dark2',\n Paired: '[Q] Paired',\n Pastel1: '[Q] Pastel1',\n Pastel2: '[Q] Pastel2',\n Accent: '[Q] Accent',\n\n // Other\n rainbow: '[?] Rainbow',\n rwb: '[?] Red-White-Blue'\n}\n\nconst ColormakerModes = {\n '': '',\n\n rgb: 'Red Green Blue',\n hsv: 'Hue Saturation Value',\n hsl: 'Hue Saturation Lightness',\n hsi: 'Hue Saturation Intensity',\n lab: 'CIE L*a*b*',\n hcl: 'Hue Chroma Lightness'\n}\n\n/**\n * Class for registering {@link Colormaker}s. Generally use the\n * global {@link src/globals.js~ColormakerRegistry} instance.\n */\nclass ColormakerRegistry {\n schemes: { [k: string]: any }\n userSchemes: { [k: string]: any }\n\n constructor () {\n this.schemes = {}\n this.userSchemes = {}\n }\n\n getScheme (params: Partial<{ scheme: string } & ColormakerParameters>) {\n const p = params || {}\n const id = (p.scheme || '').toLowerCase()\n\n let SchemeClass\n\n if (id in this.schemes) {\n SchemeClass = this.schemes[ id ]\n } else if (id in this.userSchemes) {\n SchemeClass = this.userSchemes[ id ]\n } else {\n SchemeClass = Colormaker\n }\n\n return new SchemeClass(params)\n }\n\n /**\n * Get an description of available schemes as an\n * object with id-label as key-value pairs\n * @return {Object} available schemes\n */\n getSchemes () {\n const types: { [k: string]: any } = {}\n\n Object.keys(this.schemes).forEach(function (k) {\n types[ k ] = k\n })\n\n Object.keys(this.userSchemes).forEach(function (k) {\n types[ k ] = k.split('|')[ 1 ]\n })\n\n return types\n }\n\n /**\n * Get an description of available scales as an\n * object with id-label as key-value pairs\n * @return {Object} available scales\n */\n getScales () {\n return ColormakerScales\n }\n\n getModes () {\n return ColormakerModes\n }\n\n /**\n * Add a scheme with a hardcoded id\n * @param {String} id - the id\n * @param {Colormaker} scheme - the colormaker\n * @return {undefined}\n */\n add (id: string, scheme: typeof Colormaker) {\n id = id.toLowerCase()\n this.schemes[ id ] = scheme\n }\n\n /**\n * Register a custom scheme\n *\n * @example\n * // Create a class with a `atomColor` method that returns a hex color.\n * var schemeId = NGL.ColormakerRegistry.addScheme( function( params ){\n * this.atomColor = function( atom ){\n * if( atom.serial < 1000 ){\n * return 0x0000FF; // blue\n * }else if( atom.serial > 2000 ){\n * return 0xFF0000; // red\n * }else{\n * return 0x00FF00; // green\n * }\n * };\n * } );\n *\n * stage.loadFile( \"rcsb://3dqb.pdb\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\", { color: schemeId } ); // pass schemeId here\n * o.autoView();\n * } );\n *\n * @param {Function|Colormaker} scheme - constructor or {@link Colormaker} instance\n * @param {String} label - scheme label\n * @return {String} id to refer to the registered scheme\n */\n addScheme (scheme: any, label?: string) {\n if (!(scheme instanceof Colormaker)) {\n scheme = this._createScheme(scheme)\n }\n\n return this._addUserScheme(scheme, label)\n }\n\n /**\n * Add a user-defined scheme\n * @param {Colormaker} scheme - the user-defined scheme\n * @param {String} [label] - scheme label\n * @return {String} id to refer to the registered scheme\n */\n _addUserScheme (scheme: any, label?: string) {\n label = label || ''\n const id = `${generateUUID()}|${label}`.toLowerCase()\n this.userSchemes[ id ] = scheme\n\n return id\n }\n\n /**\n * Remove the scheme with the given id\n * @param {String} id - scheme to remove\n * @return {undefined}\n */\n removeScheme (id: string) {\n id = id.toLowerCase()\n delete this.userSchemes[ id ]\n }\n\n _createScheme (constructor: any) {\n const _Colormaker = function (this: any, params: ColormakerParameters) {\n Colormaker.call(this, params)\n constructor.call(this, params)\n }\n\n _Colormaker.prototype = Colormaker.prototype\n _Colormaker.prototype.constructor = Colormaker\n\n return _Colormaker\n }\n\n /**\n * Create and a selection-based coloring scheme. Supply a list with pairs\n * of colorname and selection for coloring by selections. Use the last\n * entry as a default (catch all) coloring definition.\n *\n * @example\n * var schemeId = NGL.ColormakerRegistry.addSelectionScheme( [\n * [ \"red\", \"64-74 or 134-154 or 222-254 or 310-310 or 322-326\" ],\n * [ \"green\", \"311-322\" ],\n * [ \"yellow\", \"40-63 or 75-95 or 112-133 or 155-173 or 202-221 or 255-277 or 289-309\" ],\n * [ \"blue\", \"1-39 or 96-112 or 174-201 or 278-288\" ],\n * [ \"white\", \"*\" ]\n * ], \"Transmembrane 3dqb\" );\n *\n * stage.loadFile( \"rcsb://3dqb.pdb\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\", { color: schemeId } ); // pass schemeId here\n * o.autoView();\n * } );\n *\n * @param {Array} dataList - cloror-selection pairs\n * @param {String} label - scheme name\n * @return {String} id to refer to the registered scheme\n */\n addSelectionScheme (dataList: SelectionSchemeData[], label?: string) {\n class MySelectionColormaker extends SelectionColormaker {\n constructor (params: { structure: Structure } & ColormakerParameters) {\n super(Object.assign({ dataList }, params))\n }\n }\n\n return this._addUserScheme(MySelectionColormaker, label)\n }\n\n /**\n * Check if a scheme with the given id exists\n * @param {String} id - the id to check\n * @return {Boolean} flag indicating if the scheme exists\n */\n hasScheme (id: string) {\n id = id.toLowerCase()\n return id in this.schemes || id in this.userSchemes\n }\n}\n\nexport default ColormakerRegistry\n","/**\n * @file Worker Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { uniqueArray } from '../utils'\n\nexport type FunctionWithDeps = { __deps?: Function[] } & Function\nexport interface WorkerEvent {\n data: {\n __name: string\n __postId: string\n }\n}\n\nfunction getWorkerDeps (vars: FunctionWithDeps[]) {\n const deps = vars\n vars.forEach(function (sym) {\n if (sym.__deps) {\n Array.prototype.push.apply(deps, getWorkerDeps(sym.__deps))\n }\n })\n return deps\n}\n\nfunction makeWorkerString (vars: any) {\n const deps = uniqueArray(getWorkerDeps(vars))\n return deps.map(function (sym) {\n return sym.toString()\n }).join('\\n\\n\\n')\n}\n\nfunction onmessage (e: WorkerEvent) {\n const name = e.data.__name\n const postId = e.data.__postId\n\n /* global self */\n if (name === undefined) {\n console.error('message __name undefined')\n } else if ((self as any).func === undefined) {\n console.error('worker func undefined', name)\n } else {\n const callback = function (aMessage: any, transferList: any[]) {\n aMessage = aMessage || {}\n if (postId !== undefined) aMessage.__postId = postId\n\n try {\n (self as any).postMessage(aMessage, transferList)\n } catch (error) {\n console.error('self.postMessage:', error);\n (self as any).postMessage(aMessage)\n }\n };\n (self as any).func(e, callback)\n }\n}\n\nexport function makeWorkerBlob (func: Function, deps: Function[]) {\n let str = \"'use strict';\\n\\n\" + makeWorkerString(deps)\n str += '\\n\\n\\nself.func = ' + func.toString() + ';'\n str += '\\n\\n\\nself.onmessage = ' + onmessage.toString() + ';'\n // console.log(str);\n return new Blob([ str ], { type: 'application/javascript' })\n}\n","/**\n * @file Globals\n * @author Alexander Rose \n * @private\n */\n\nimport { getBrowser, getQuery, boolean } from './utils'\nimport Registry from './utils/registry'\nimport _ColormakerRegistry from './color/colormaker-registry'\nimport _ParserRegistry from './parser/parser-registry'\nimport _WorkerRegistry from './worker/worker-registry'\nimport { MeasurementRepresentationParameters } from './representation/measurement-representation';\n\n/**\n * The browser name: \"Opera\", \"Chrome\", \"Firefox\", \"Mobile Safari\",\n * \"Internet Explorer\", \"Safari\" or false.\n */\nexport const Browser = getBrowser()\n\n/**\n * Flag indicating support for the 'passive' option for event handler\n */\nexport let SupportsPassiveEventHandler = false\ntry {\n // Test via a getter in the options object to see if the passive property is accessed\n const opts = Object.defineProperty({}, 'passive', {\n get: function () {\n SupportsPassiveEventHandler = true\n }\n })\n window.addEventListener('test', e => {}, opts)\n} catch (e) {}\n\n/**\n * Flag indicating a mobile browser\n */\nexport const Mobile = typeof window !== 'undefined' ? typeof window.orientation !== 'undefined' : false\n\nexport let SupportsReadPixelsFloat = false\nexport function setSupportsReadPixelsFloat (value: boolean) {\n SupportsReadPixelsFloat = value\n}\n\n/**\n * Flag indicating support for the `EXT_frag_depth` WebGL extension\n * (Always present in WebGL2)\n */\nexport let ExtensionFragDepth = false\nexport function setExtensionFragDepth (value: boolean) {\n ExtensionFragDepth = value\n}\n\nexport const Log = {\n log: Function.prototype.bind.call(console.log, console),\n info: Function.prototype.bind.call(console.info, console),\n warn: Function.prototype.bind.call(console.warn, console),\n error: Function.prototype.bind.call(console.error, console),\n time: Function.prototype.bind.call(console.time, console),\n timeEnd: Function.prototype.bind.call(console.timeEnd, console)\n}\n\nexport let MeasurementDefaultParams: Partial = {\n color: 'green',\n labelColor: 0x808080,\n labelAttachment: 'bottom-center',\n labelSize: 0.7,\n labelZOffset: 0.5,\n labelYOffset: 0.1,\n labelBorder: true,\n labelBorderColor: 0xd3d3d3,\n labelBorderWidth: 0.25,\n lineOpacity: 0.8,\n linewidth: 5.0,\n opacity: 0.6,\n\n labelUnit: 'angstrom',\n arcVisible: true,\n planeVisible: false\n}\nexport function setMeasurementDefaultParams (params = {}) {\n Object.assign(MeasurementDefaultParams, params)\n}\n\nexport let Debug = boolean(getQuery('debug'))\nexport function setDebug (value: boolean) {\n Debug = value\n}\n\nexport const WebglErrorMessage = '

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

Find out how to get it here.

'\n\n/**\n * List of file extensions to be recognized as scripts\n */\nexport const ScriptExtensions = [ 'ngl', 'js' ]\n\nexport const WorkerRegistry = new _WorkerRegistry()\nexport const ColormakerRegistry = new _ColormakerRegistry()\nexport const DatasourceRegistry = new Registry('datasource')\nexport const RepresentationRegistry = new Registry('representatation')\nexport const ParserRegistry = new _ParserRegistry()\nexport const ShaderRegistry = new Registry('shader')\nexport const DecompressorRegistry = new Registry('decompressor')\nexport const ComponentRegistry = new Registry('component')\nexport const BufferRegistry = new Registry('buffer')\nexport const PickerRegistry = new Registry('picker')\n\nexport let ListingDatasource: any\nexport function setListingDatasource (value: any) {\n ListingDatasource = value\n}\n\nexport let TrajectoryDatasource: any // TODO should accept mdsrvDatasource\nexport function setTrajectoryDatasource (value: any) {\n TrajectoryDatasource = value\n}\n","/**\n * @file Worker Registry\n * @author Alexander Rose \n * @private\n */\n\nimport { makeWorkerBlob } from './worker-utils'\n\nclass WorkerRegistry {\n activeWorkerCount = 0\n\n private _funcDict: { [k: string]: Function } = {}\n private _depsDict: { [k: string]: Function[] } = {}\n private _blobDict: { [k: string]: Blob } = {}\n\n add (name: string, func: Function, deps: Function[]) {\n this._funcDict[ name ] = func\n this._depsDict[ name ] = deps\n }\n\n get (name: string) {\n if (!this._blobDict[ name ]) {\n this._blobDict[ name ] = makeWorkerBlob(\n this._funcDict[ name ], this._depsDict[ name ]\n )\n }\n return this._blobDict[ name ]\n }\n}\n\nexport default WorkerRegistry\n","/**\n * @file Parser Registry\n * @author Alexander Rose \n * @private\n */\n\nimport Registry from '../utils/registry'\n\nclass ParserRegistry extends Registry {\n constructor () {\n super('parser')\n }\n\n __hasObjName (key: string, objName: string) {\n const parser = this.get(key)\n return parser && parser.prototype.__objName === objName\n }\n\n isTrajectory (key: string) {\n return this.__hasObjName(key, 'frames')\n }\n\n isStructure (key: string) {\n return this.__hasObjName(key, 'structure')\n }\n\n isVolume (key: string) {\n return this.__hasObjName(key, 'volume')\n }\n\n isSurface (key: string) {\n return this.__hasObjName(key, 'surface')\n }\n\n isBinary (key: string) {\n const parser = this.get(key)\n return parser && parser.prototype.isBinary\n }\n\n isXml (key: string) {\n const parser = this.get(key)\n return parser && parser.prototype.isXml\n }\n\n isJson (key: string) {\n const parser = this.get(key)\n return parser && parser.prototype.isJson\n }\n\n getTrajectoryExtensions () {\n return this.names.filter(name => this.isTrajectory(name))\n }\n\n getStructureExtensions () {\n return this.names.filter(name => this.isStructure(name))\n }\n\n getVolumeExtensions () {\n return this.names.filter(name => this.isVolume(name))\n }\n\n getSurfaceExtensions () {\n return this.names.filter(name => this.isSurface(name))\n }\n}\n\nexport default ParserRegistry\n","/**\n * @file Streamer\n * @author Alexander Rose \n * @private\n */\n\nimport { DecompressorRegistry } from '../globals'\nimport { uint8ToString, defaults } from '../utils'\n\nexport interface StreamerParams {\n compressed?: string|false\n binary?: boolean\n json?: boolean\n xml?: boolean\n}\n\nabstract class Streamer {\n src: any\n data: any\n\n compressed: string|false\n binary: boolean\n json: boolean\n xml: boolean\n\n chunkSize = 1024 * 1024 * 10\n newline = '\\n'\n\n protected __pointer = 0\n protected __partialLine = ''\n\n constructor (src: any, params: StreamerParams = {}) {\n this.compressed = defaults(params.compressed, false)\n this.binary = defaults(params.binary, false)\n this.json = defaults(params.json, false)\n this.xml = defaults(params.xml, false)\n\n this.src = src\n }\n\n isBinary () {\n return this.binary || this.compressed\n }\n\n read () {\n return this._read().then(data => {\n const decompressFn = this.compressed ? DecompressorRegistry.get(this.compressed) : undefined\n\n if (this.compressed && decompressFn) {\n this.data = decompressFn(data)\n } else {\n if ((this.binary || this.compressed) && data instanceof ArrayBuffer) {\n data = new Uint8Array(data)\n }\n this.data = data\n }\n\n return this.data\n })\n }\n\n protected abstract _read (): Promise\n\n protected _chunk (start: number, end: number) {\n end = Math.min(this.data.length, end)\n\n if (start === 0 && this.data.length === end) {\n return this.data\n } else {\n if (this.isBinary()) {\n return this.data.subarray(start, end)\n } else {\n return this.data.substring(start, end)\n }\n }\n }\n\n chunk (start: number) {\n const end = start + this.chunkSize\n\n return this._chunk(start, end)\n }\n\n peekLines (m: number) {\n const data = this.data\n const n = data.length\n\n // FIXME does not work for multi-char newline\n const newline = this.isBinary() ? this.newline.charCodeAt(0) : this.newline\n\n let i\n let count = 0\n for (i = 0; i < n; ++i) {\n if (data[ i ] === newline) ++count\n if (count === m) break\n }\n\n const chunk = this._chunk(0, i + 1)\n const d = this.chunkToLines(chunk, '', i > n)\n\n return d.lines\n }\n\n chunkCount () {\n return Math.floor(this.data.length / this.chunkSize) + 1\n }\n\n asText () {\n return this.isBinary() ? uint8ToString(this.data) : this.data\n }\n\n chunkToLines (chunk: string|Uint8Array, partialLine: string, isLast: boolean) {\n const newline = this.newline\n\n if (!this.isBinary() && chunk.length === this.data.length) {\n return {\n lines: (chunk as string).split(newline),\n partialLine: ''\n }\n }\n\n let lines: string[] = []\n const str = this.isBinary() ? uint8ToString(chunk as Uint8Array) : chunk\n const idx = str.lastIndexOf(newline)\n\n if (idx === -1) {\n partialLine += str\n } else {\n const str2 = partialLine + str.substr(0, idx)\n lines = lines.concat(str2.split(newline))\n\n if (idx === str.length - newline.length) {\n partialLine = ''\n } else {\n partialLine = str.substr(idx + newline.length)\n }\n }\n\n if (isLast && partialLine !== '') {\n lines.push(partialLine)\n }\n\n return {\n lines: lines,\n partialLine: partialLine\n }\n }\n\n nextChunk () {\n const start = this.__pointer\n\n if (start > this.data.length) {\n return undefined\n }\n\n this.__pointer += this.chunkSize\n return this.chunk(start)\n }\n\n nextChunkOfLines () {\n const chunk = this.nextChunk()\n\n if (chunk === undefined) {\n return undefined\n }\n\n const isLast = this.__pointer > this.data.length\n const d = this.chunkToLines(chunk, this.__partialLine, isLast)\n\n this.__partialLine = d.partialLine\n\n return d.lines\n }\n\n eachChunk (callback: (chunk: string|Uint8Array, chunkNo: number, chunkCount: number) => void) {\n const chunkSize = this.chunkSize\n const n = this.data.length\n const chunkCount = this.chunkCount()\n\n for (let i = 0; i < n; i += chunkSize) {\n const chunk = this.chunk(i)\n const chunkNo = Math.round(i / chunkSize)\n\n callback(chunk, chunkNo, chunkCount)\n }\n }\n\n eachChunkOfLines (callback: (chunk: string[], chunkNo: number, chunkCount: number) => void) {\n this.eachChunk((chunk, chunkNo, chunkCount) => {\n const isLast = chunkNo === chunkCount + 1\n const d = this.chunkToLines(chunk, this.__partialLine, isLast)\n\n this.__partialLine = d.partialLine\n\n callback(d.lines, chunkNo, chunkCount)\n })\n }\n\n dispose () {\n delete this.src\n }\n}\n\nexport default Streamer\n","/**\n * @file File Streamer\n * @author Alexander Rose \n * @private\n */\n\nimport Streamer from './streamer'\n\ninterface FileReaderEventTarget extends EventTarget {\n result:string | ArrayBuffer | null\n}\n\ninterface FileReaderEvent extends ProgressEvent {\n target: FileReaderEventTarget | null;\n}\n\nclass FileStreamer extends Streamer {\n _read () {\n return new Promise((resolve, reject) => {\n const file = this.src\n const reader = new FileReader()\n\n reader.onload = (event: FileReaderEvent) => {\n if(event.target) resolve(event.target.result)\n }\n\n // if (typeof this.onprogress === 'function') {\n // reader.onprogress = event => this.onprogress(event)\n // }\n\n reader.onerror = event => reject(event)\n\n if (this.binary || this.compressed) {\n reader.readAsArrayBuffer(file)\n } else {\n reader.readAsText(file)\n }\n })\n }\n}\n\nexport default FileStreamer\n","/**\n * @file Network Streamer\n * @author Alexander Rose \n * @private\n */\n\nimport Streamer from './streamer'\n\nclass NetworkStreamer extends Streamer {\n _read () {\n return new Promise((resolve, reject) => {\n const url = this.src\n const xhr = new XMLHttpRequest()\n\n xhr.open('GET', url, true)\n\n xhr.addEventListener('load', () => {\n if (xhr.status === 200 || xhr.status === 304 ||\n // when requesting from local file system\n // the status in Google Chrome/Chromium is 0\n xhr.status === 0\n ) {\n try {\n resolve(xhr.response)\n } catch (e) {\n reject(e)\n }\n } else {\n reject(xhr.statusText)\n }\n }, false)\n\n // if (typeof this.onprogress === 'function') {\n // xhr.addEventListener('progress', event => this.onprogress(event), false);\n // }\n\n xhr.addEventListener('error', event => reject('network error'), false)\n\n if (this.isBinary()) {\n xhr.responseType = 'arraybuffer'\n } else if (this.json) {\n xhr.responseType = 'json'\n } else if (this.xml) {\n xhr.responseType = 'document'\n } else {\n xhr.responseType = 'text'\n }\n // xhr.crossOrigin = true;\n\n xhr.send()\n })\n }\n}\n\nexport default NetworkStreamer\n","/**\n * @file Loader\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport { createParams } from '../utils'\nimport FileStreamer from '../streamer/file-streamer'\nimport NetworkStreamer from '../streamer/network-streamer'\nimport { LoaderParameters, LoaderInput } from './loader-utils'\n\n/**\n * Loader parameter object.\n * @typedef {Object} LoaderParameters - loader parameters\n * @property {String} ext - file extension, determines file type\n * @property {Boolean} compressed - flag data as compressed\n * @property {Boolean} binary - flag data as binary\n * @property {String} name - set data name\n */\n\n/**\n * Loader base class\n */\nabstract class Loader {\n parameters: LoaderParameters\n streamer: FileStreamer | NetworkStreamer\n\n /**\n * Construct a loader object\n * @param {String|File|Blob} src - data source, string is interpreted as an URL\n * @param {LoaderParameters} params - parameters object\n */\n constructor (src: LoaderInput, params: Partial = {}) {\n this.parameters = createParams(params, {\n ext: '',\n compressed: false,\n binary: ParserRegistry.isBinary(params.ext || ''),\n name: '',\n\n dir: '',\n path: '',\n protocol: ''\n } as LoaderParameters)\n\n const streamerParams = {\n compressed: this.parameters.compressed as string|false,\n binary: this.parameters.binary,\n json: ParserRegistry.isJson(this.parameters.ext),\n xml: ParserRegistry.isXml(this.parameters.ext)\n }\n\n if ((typeof File !== 'undefined' && src instanceof File) ||\n (typeof Blob !== 'undefined' && src instanceof Blob)\n ) {\n this.streamer = new FileStreamer(src, streamerParams)\n } else {\n this.streamer = new NetworkStreamer(src, streamerParams)\n }\n }\n\n /**\n * Load data\n * @abstract\n * @return {Promise} resolves to the loaded data {@link Object}\n */\n abstract load (): Promise\n}\n\nexport default Loader\n","/**\n * @file Parser Loader\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport type { InferBondsOptions } from '../structure/structure-utils'\nimport Loader from './loader'\nimport { LoaderParameters, LoaderInput } from './loader-utils'\n\nexport interface ParserParams {\n voxelSize?: number\n firstModelOnly?: boolean\n asTrajectory?: boolean\n cAlphaOnly?: boolean\n name?: string\n path?: string\n delimiter?: string\n comment?: string\n columnNames?: string\n inferBonds?: InferBondsOptions\n}\n\n/**\n * Parser loader class\n * @extends Loader\n */\nclass ParserLoader extends Loader {\n parserParams: ParserParams\n\n constructor (src: LoaderInput, params: Partial & ParserParams = {}) {\n super(src, params)\n this.parserParams = {\n voxelSize: params.voxelSize,\n firstModelOnly: params.firstModelOnly,\n asTrajectory: params.asTrajectory,\n cAlphaOnly: params.cAlphaOnly,\n delimiter: params.delimiter,\n comment: params.comment,\n columnNames: params.columnNames,\n inferBonds: params.inferBonds,\n name: this.parameters.name,\n path: this.parameters.path\n }\n }\n\n /**\n * Load parsed object\n * @return {Promise} resolves to the loaded & parsed {@link Structure},\n * {@link Volume}, {@link Surface} or data object\n */\n load () {\n var ParserClass = ParserRegistry.get(this.parameters.ext)\n var parser = new ParserClass(this.streamer, this.parserParams)\n\n return parser.parse()\n }\n}\n\nexport default ParserLoader\n","/**\n * @file Script\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { Log } from './globals'\nimport Stage from './stage/stage'\n\nexport interface ScriptSignals {\n elementAdded: Signal\n elementRemoved: Signal\n nameChanged: Signal\n}\n\n/**\n * Script class\n */\nclass Script {\n readonly signals: ScriptSignals = {\n elementAdded: new Signal(),\n elementRemoved: new Signal(),\n nameChanged: new Signal()\n }\n\n readonly dir: string\n readonly fn: Function\n\n readonly type = 'Script'\n\n /**\n * Create a script instance\n * @param {String} functionBody - the function source\n * @param {String} name - name of the script\n * @param {String} path - path of the script\n */\n constructor (functionBody: string, readonly name: string, readonly path: string) {\n this.dir = path.substring(0, path.lastIndexOf('/') + 1)\n\n try {\n /* eslint-disable no-new-func */\n this.fn = new Function('stage', '__name', '__path', '__dir', functionBody)\n } catch (e) {\n Log.error('Script compilation failed', e)\n this.fn = function () {}\n }\n }\n\n /**\n * Execute the script\n * @param {Stage} stage - the stage context\n * @return {Promise} - resolve when script finished running\n */\n run (stage: Stage): Promise {\n return new Promise((resolve, reject) => {\n try {\n this.fn.apply(null, [ stage, this.name, this.path, this.dir ])\n resolve()\n } catch (e) {\n Log.error('Script.fn', e)\n reject(e)\n }\n })\n }\n}\n\nexport default Script\n","/**\n * @file Script Loader\n * @author Alexander Rose \n * @private\n */\n\nimport Loader from './loader'\nimport Script from '../script'\n\n/**\n * Script loader class\n * @extends Loader\n */\nclass ScriptLoader extends Loader {\n /**\n * Load script\n * @return {Promise} resolves to the loaded {@link Script}\n */\n load () {\n return this.streamer.read().then(() => {\n return new Script(\n this.streamer.asText(), this.parameters.name, this.parameters.path\n )\n })\n }\n}\n\nexport default ScriptLoader\n","/**\n * @file Loader Utils\n * @author Alexander Rose \n * @private\n */\n\nimport {\n DatasourceRegistry, DecompressorRegistry, ParserRegistry, ScriptExtensions\n} from '../globals'\nimport ParserLoader, { ParserParams } from './parser-loader'\nimport ScriptLoader from './script-loader'\n\nexport interface LoaderParameters {\n ext: string // file extension, determines file type\n compressed: string|false // flag data as compressed\n binary: boolean // flag data as binary\n name: string // set data name\n\n dir: string\n path: string\n protocol: string\n}\n\nexport type LoaderInput = File|Blob|string\n\nexport function getFileInfo (file: LoaderInput) {\n const compressedExtList = DecompressorRegistry.names\n\n let path: string\n let compressed: string|false\n let protocol = ''\n\n if (file instanceof File) {\n path = file.name\n } else if (file instanceof Blob) {\n path = ''\n } else {\n path = file\n }\n const queryIndex = path.lastIndexOf('?')\n const query = queryIndex !== -1 ? path.substring(queryIndex) : ''\n path = path.substring(0, queryIndex === -1 ? path.length : queryIndex)\n\n const name = path.replace(/^.*[\\\\/]/, '')\n let base = name.substring(0, name.lastIndexOf('.'))\n\n const nameSplit = name.split('.')\n let ext = nameSplit.length > 1 ? (nameSplit.pop() || '').toLowerCase() : ''\n\n const protocolMatch = path.match(/^(.+):\\/\\/(.+)$/)\n if (protocolMatch) {\n protocol = protocolMatch[ 1 ].toLowerCase()\n path = protocolMatch[ 2 ] || ''\n }\n\n const dir = path.substring(0, path.lastIndexOf('/') + 1)\n\n if (compressedExtList.includes(ext)) {\n compressed = ext\n const n = path.length - ext.length - 1\n ext = (path.substr(0, n).split('.').pop() || '').toLowerCase()\n const m = base.length - ext.length - 1\n base = base.substr(0, m)\n } else {\n compressed = false\n }\n\n return { path, name, ext, base, dir, compressed, protocol, query, 'src': file }\n}\n\nexport function getDataInfo (src: LoaderInput) {\n let info = getFileInfo(src)\n const datasource = DatasourceRegistry.get(info.protocol)\n if (datasource) {\n info = getFileInfo(datasource.getUrl(info.src))\n if (!info.ext && datasource.getExt) {\n info.ext = datasource.getExt(src)\n }\n }\n return info\n}\n\n/**\n * Load a file\n *\n * @example\n * // load from URL\n * NGL.autoLoad( \"http://files.rcsb.org/download/5IOS.cif\" );\n *\n * @example\n * // load binary data in CCP4 format via a Blob\n * var binaryBlob = new Blob( [ ccp4Data ], { type: 'application/octet-binary'} );\n * NGL.autoLoad( binaryBlob, { ext: \"ccp4\" } );\n *\n * @example\n * // load string data in PDB format via a Blob\n * var stringBlob = new Blob( [ pdbData ], { type: 'text/plain'} );\n * NGL.autoLoad( stringBlob, { ext: \"pdb\" } );\n *\n * @example\n * // load a File object\n * NGL.autoLoad( file );\n *\n * @param {String|File|Blob} file - either a URL or an object containing the file data\n * @param {LoaderParameters} params - loading parameters\n * @return {Promise} Promise resolves to the loaded data\n */\nexport function autoLoad (file: LoaderInput, params: Partial = {}) {\n const p = Object.assign(getDataInfo(file), params)\n\n let loader\n if (ParserRegistry.names.includes(p.ext)) {\n loader = new ParserLoader(p.src, p)\n } else if (ScriptExtensions.includes(p.ext)) {\n loader = new ScriptLoader(p.src, p)\n }\n\n if (loader) {\n return loader.load()\n } else {\n return Promise.reject(new Error(`autoLoad: ext '${p.ext}' unknown`))\n }\n}\n","/**\n * @file Writer\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults, download } from '../utils'\n\n/**\n * Base class for writers\n * @interface\n */\nabstract class Writer {\n readonly mimeType: string\n readonly defaultName: string\n readonly defaultExt: string\n\n /**\n * @abstract\n * @return {Anything} the data to be written\n */\n abstract getData (): any\n\n /**\n * Get a blob with the written data\n * @return {Blob} the blob\n */\n getBlob () {\n return new Blob([ this.getData() ], { type: this.mimeType })\n }\n\n /**\n * Trigger a download of the\n * @param {[type]} name [description]\n * @param {[type]} ext [description]\n * @return {[type]} [description]\n */\n download (name?: string, ext?: string) {\n name = defaults(name, this.defaultName)\n ext = defaults(ext, this.defaultExt)\n\n download(this.getBlob(), `${name}.${ext}`)\n }\n}\n\nexport default Writer","/**\n * @file IO Buffer\n * @author Alexander Rose \n * @private\n *\n * Adapted and converted to TypeScript from https://github.com/image-js/iobuffer\n * MIT License, Copyright (c) 2015 Michaël Zasso\n */\n\nimport { TypedArray } from '../types'\n\nconst defaultByteLength = 1024 * 8\nconst charArray: string[] = []\n\nexport interface IOBufferParameters {\n offset?: number // Ignore the first n bytes of the ArrayBuffer\n}\n\n/**\n * Class for writing and reading binary data\n */\nclass IOBuffer {\n private _lastWrittenByte: number\n private _mark = 0\n private _marks: number[] = []\n private _data: DataView\n\n offset = 0 // The current offset of the buffer's pointer\n littleEndian = true\n buffer: ArrayBuffer // Reference to the internal ArrayBuffer object\n length: number // Byte length of the internal ArrayBuffer\n byteLength: number // Byte length of the internal ArrayBuffer\n byteOffset: number // Byte offset of the internal ArrayBuffer\n\n /**\n * If it's a number, it will initialize the buffer with the number as\n * the buffer's length. If it's undefined, it will initialize the buffer\n * with a default length of 8 Kb. If its an ArrayBuffer, a TypedArray,\n * it will create a view over the underlying ArrayBuffer.\n */\n constructor (data: number|ArrayBuffer|TypedArray, params: IOBufferParameters = {}) {\n let dataIsGiven = false\n if (data === undefined) {\n data = defaultByteLength\n }\n if (typeof data === 'number') {\n data = new ArrayBuffer(data)\n } else {\n dataIsGiven = true\n }\n\n const offset = params.offset ? params.offset >>> 0 : 0\n let byteLength = data.byteLength - offset\n let dvOffset = offset\n if (!(data instanceof ArrayBuffer)) {\n if (data.byteLength !== data.buffer.byteLength) {\n dvOffset = data.byteOffset + offset\n }\n data = data.buffer\n }\n if (dataIsGiven) {\n this._lastWrittenByte = byteLength\n } else {\n this._lastWrittenByte = 0\n }\n\n this.buffer = data\n this.length = byteLength\n this.byteLength = byteLength\n this.byteOffset = dvOffset\n\n this._data = new DataView(this.buffer, dvOffset, byteLength)\n }\n\n /**\n * Checks if the memory allocated to the buffer is sufficient to store more bytes after the offset\n * @param {number} [byteLength=1] The needed memory in bytes\n * @return {boolean} Returns true if there is sufficient space and false otherwise\n */\n available (byteLength: number) {\n if (byteLength === undefined) byteLength = 1\n return (this.offset + byteLength) <= this.length\n }\n\n /**\n * Check if little-endian mode is used for reading and writing multi-byte values\n * @return {boolean} Returns true if little-endian mode is used, false otherwise\n */\n isLittleEndian () {\n return this.littleEndian\n }\n\n /**\n * Set little-endian mode for reading and writing multi-byte values\n * @return {IOBuffer}\n */\n setLittleEndian () {\n this.littleEndian = true\n return this\n }\n\n /**\n * Check if big-endian mode is used for reading and writing multi-byte values\n * @return {boolean} Returns true if big-endian mode is used, false otherwise\n */\n isBigEndian () {\n return !this.littleEndian\n }\n\n /**\n * Switches to big-endian mode for reading and writing multi-byte values\n * @return {IOBuffer}\n */\n setBigEndian () {\n this.littleEndian = false\n return this\n }\n\n /**\n * Move the pointer n bytes forward\n * @param {number} n\n * @return {IOBuffer}\n */\n skip (n: number) {\n if (n === undefined) n = 1\n this.offset += n\n return this\n }\n\n /**\n * Move the pointer to the given offset\n * @param {number} offset\n * @return {IOBuffer}\n */\n seek (offset: number) {\n this.offset = offset\n return this\n }\n\n /**\n * Store the current pointer offset.\n * @see {@link IOBuffer#reset}\n * @return {IOBuffer}\n */\n mark () {\n this._mark = this.offset\n return this\n }\n\n /**\n * Move the pointer back to the last pointer offset set by mark\n * @see {@link IOBuffer#mark}\n * @return {IOBuffer}\n */\n reset () {\n this.offset = this._mark\n return this\n }\n\n /**\n * Push the current pointer offset to the mark stack\n * @see {@link IOBuffer#popMark}\n * @return {IOBuffer}\n */\n pushMark () {\n this._marks.push(this.offset)\n return this\n }\n\n /**\n * Pop the last pointer offset from the mark stack, and set the current pointer offset to the popped value\n * @see {@link IOBuffer#pushMark}\n * @return {IOBuffer}\n */\n popMark () {\n const offset = this._marks.pop()\n if (offset === undefined) throw new Error('Mark stack empty')\n this.seek(offset)\n return this\n }\n\n /**\n * Move the pointer offset back to 0\n * @return {IOBuffer}\n */\n rewind () {\n this.offset = 0\n return this\n }\n\n /**\n * Make sure the buffer has sufficient memory to write a given byteLength at the current pointer offset\n * If the buffer's memory is insufficient, this method will create a new buffer (a copy) with a length\n * that is twice (byteLength + current offset)\n * @param {number} [byteLength = 1]\n * @return {IOBuffer}\n */\n ensureAvailable (byteLength: number) {\n if (byteLength === undefined) byteLength = 1\n if (!this.available(byteLength)) {\n const lengthNeeded = this.offset + byteLength\n const newLength = lengthNeeded * 2\n const newArray = new Uint8Array(newLength)\n newArray.set(new Uint8Array(this.buffer))\n this.buffer = newArray.buffer\n this.length = this.byteLength = newLength\n this._data = new DataView(this.buffer)\n }\n return this\n }\n\n /**\n * Read a byte and return false if the byte's value is 0, or true otherwise\n * Moves pointer forward\n * @return {boolean}\n */\n readBoolean () {\n return this.readUint8() !== 0\n }\n\n /**\n * Read a signed 8-bit integer and move pointer forward\n * @return {number}\n */\n readInt8 () {\n return this._data.getInt8(this.offset++)\n }\n\n /**\n * Read an unsigned 8-bit integer and move pointer forward\n * @return {number}\n */\n readUint8 () {\n return this._data.getUint8(this.offset++)\n }\n\n /**\n * Alias for {@link IOBuffer#readUint8}\n * @return {number}\n */\n readByte () {\n return this.readUint8()\n }\n\n /**\n * Read n bytes and move pointer forward.\n * @param {number} n\n * @return {Uint8Array}\n */\n readBytes (n: number) {\n if (n === undefined) n = 1\n var bytes = new Uint8Array(n)\n for (var i = 0; i < n; i++) {\n bytes[i] = this.readByte()\n }\n return bytes\n }\n\n /**\n * Read a 16-bit signed integer and move pointer forward\n * @return {number}\n */\n readInt16 () {\n var value = this._data.getInt16(this.offset, this.littleEndian)\n this.offset += 2\n return value\n }\n\n /**\n * Read a 16-bit unsigned integer and move pointer forward\n * @return {number}\n */\n readUint16 () {\n var value = this._data.getUint16(this.offset, this.littleEndian)\n this.offset += 2\n return value\n }\n\n /**\n * Read a 32-bit signed integer and move pointer forward\n * @return {number}\n */\n readInt32 () {\n var value = this._data.getInt32(this.offset, this.littleEndian)\n this.offset += 4\n return value\n }\n\n /**\n * Read a 32-bit unsigned integer and move pointer forward\n * @return {number}\n */\n readUint32 () {\n var value = this._data.getUint32(this.offset, this.littleEndian)\n this.offset += 4\n return value\n }\n\n /**\n * Read a 32-bit floating number and move pointer forward\n * @return {number}\n */\n readFloat32 () {\n var value = this._data.getFloat32(this.offset, this.littleEndian)\n this.offset += 4\n return value\n }\n\n /**\n * Read a 64-bit floating number and move pointer forward\n * @return {number}\n */\n readFloat64 () {\n var value = this._data.getFloat64(this.offset, this.littleEndian)\n this.offset += 8\n return value\n }\n\n /**\n * Read 1-byte ascii character and move pointer forward\n * @return {string}\n */\n readChar () {\n return String.fromCharCode(this.readInt8())\n }\n\n /**\n * Read n 1-byte ascii characters and move pointer forward\n * @param {number} n\n * @return {string}\n */\n readChars (n = 1) {\n charArray.length = n\n for (var i = 0; i < n; i++) {\n charArray[i] = this.readChar()\n }\n return charArray.join('')\n }\n\n /**\n * Write 0xff if the passed value is truthy, 0x00 otherwise\n * @param {any} value\n * @return {IOBuffer}\n */\n writeBoolean (value = false) {\n this.writeUint8(value ? 0xff : 0x00)\n return this\n }\n\n /**\n * Write value as an 8-bit signed integer\n * @param {number} value\n * @return {IOBuffer}\n */\n writeInt8 (value: number) {\n this.ensureAvailable(1)\n this._data.setInt8(this.offset++, value)\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write value as a 8-bit unsigned integer\n * @param {number} value\n * @return {IOBuffer}\n */\n writeUint8 (value: number) {\n this.ensureAvailable(1)\n this._data.setUint8(this.offset++, value)\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * An alias for {@link IOBuffer#writeUint8}\n * @param {number} value\n * @return {IOBuffer}\n */\n writeByte (value: number) {\n return this.writeUint8(value)\n }\n\n /**\n * Write bytes\n * @param {Array|Uint8Array} bytes\n * @return {IOBuffer}\n */\n writeBytes (bytes: number[]|Uint8Array) {\n this.ensureAvailable(bytes.length)\n for (var i = 0; i < bytes.length; i++) {\n this._data.setUint8(this.offset++, bytes[i])\n }\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write value as an 16-bit signed integer\n * @param {number} value\n * @return {IOBuffer}\n */\n writeInt16 (value: number) {\n this.ensureAvailable(2)\n this._data.setInt16(this.offset, value, this.littleEndian)\n this.offset += 2\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write value as a 16-bit unsigned integer\n * @param {number} value\n * @return {IOBuffer}\n */\n writeUint16 (value: number) {\n this.ensureAvailable(2)\n this._data.setUint16(this.offset, value, this.littleEndian)\n this.offset += 2\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write a 32-bit signed integer at the current pointer offset\n * @param {number} value\n * @return {IOBuffer}\n */\n writeInt32 (value: number) {\n this.ensureAvailable(4)\n this._data.setInt32(this.offset, value, this.littleEndian)\n this.offset += 4\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write a 32-bit unsigned integer at the current pointer offset\n * @param {number} value - The value to set\n * @return {IOBuffer}\n */\n writeUint32 (value: number) {\n this.ensureAvailable(4)\n this._data.setUint32(this.offset, value, this.littleEndian)\n this.offset += 4\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write a 32-bit floating number at the current pointer offset\n * @param {number} value - The value to set\n * @return {IOBuffer}\n */\n writeFloat32 (value: number) {\n this.ensureAvailable(4)\n this._data.setFloat32(this.offset, value, this.littleEndian)\n this.offset += 4\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write a 64-bit floating number at the current pointer offset\n * @param {number} value\n * @return {IOBuffer}\n */\n writeFloat64 (value: number) {\n this.ensureAvailable(8)\n this._data.setFloat64(this.offset, value, this.littleEndian)\n this.offset += 8\n this._updateLastWrittenByte()\n return this\n }\n\n /**\n * Write the charCode of the passed string's first character to the current pointer offset\n * @param {string} str - The character to set\n * @return {IOBuffer}\n */\n writeChar (str: string) {\n return this.writeUint8(str.charCodeAt(0))\n }\n\n /**\n * Write the charCodes of the passed string's characters to the current pointer offset\n * @param {string} str\n * @return {IOBuffer}\n */\n writeChars (str: string) {\n for (var i = 0; i < str.length; i++) {\n this.writeUint8(str.charCodeAt(i))\n }\n return this\n }\n\n /**\n * Export a Uint8Array view of the internal buffer.\n * The view starts at the byte offset and its length\n * is calculated to stop at the last written byte or the original length.\n * @return {Uint8Array}\n */\n toArray () {\n return new Uint8Array(this.buffer, this.byteOffset, this._lastWrittenByte)\n }\n\n /**\n * Update the last written byte offset\n * @private\n */\n _updateLastWrittenByte () {\n if (this.offset > this._lastWrittenByte) {\n this._lastWrittenByte = this.offset\n }\n }\n}\n\nexport default IOBuffer\n","/**\n * @file Counter\n * @author Alexander Rose \n * @private\n */\n\nimport { Log } from '../globals'\n\nimport * as signalsWrapper from 'signals'\n\n/**\n * {@link Signal}, dispatched when the `count` changes\n * @example\n * counter.signals.countChanged.add( function( delta ){ ... } );\n * @event Counter#countChanged\n * @type {Integer}\n */\n\nexport interface CounterSignals {\n countChanged: signalsWrapper.Signal\n}\n\n/**\n * Counter class for keeping track of counts\n */\nclass Counter {\n count = 0\n\n signals: CounterSignals = {\n countChanged: new signalsWrapper.Signal()\n }\n\n /**\n * Set the `count` to zero\n * @return {undefined}\n */\n clear () {\n this.change(-this.count)\n }\n\n /**\n * Change the `count`\n * @fires Counter#countChanged\n * @param {Integer} delta - count change\n * @return {undefined}\n */\n change (delta: number) {\n this.count += delta\n this.signals.countChanged.dispatch(delta, this.count)\n\n if (this.count < 0) {\n Log.warn('Counter.count below zero', this.count)\n }\n }\n\n /**\n * Increments the `count` by one.\n * @return {undefined}\n */\n increment () {\n this.change(1)\n }\n\n /**\n * Decrements the `count` by one.\n * @return {undefined}\n */\n decrement () {\n this.change(-1)\n }\n\n /**\n * Listen to another counter object and change this `count` by the\n * same amount\n * @param {Counter} counter - the counter object to listen to\n * @return {undefined}\n */\n listen (counter: Counter) {\n this.change(counter.count)\n counter.signals.countChanged.add(this.change, this)\n }\n\n /**\n * Stop listening to the other counter object\n * @param {Counter} counter - the counter object to stop listening to\n * @return {undefined}\n */\n unlisten (counter: Counter) {\n const countChanged = counter.signals.countChanged\n if (countChanged.has(this.change, this)) {\n countChanged.remove(this.change, this)\n }\n }\n\n /**\n * Invole the callback function once, when the `count` becomes zero\n * @param {Function} callback - the callback function\n * @param {Object} context - the context for the callback function\n * @return {undefined}\n */\n onZeroOnce (callback: () => void, context?: any) {\n if (this.count === 0) {\n callback.call(context)\n } else {\n const fn = () => {\n if (this.count === 0) {\n this.signals.countChanged.remove(fn, this)\n callback.call(context)\n }\n }\n this.signals.countChanged.add(fn, this)\n }\n }\n\n dispose () {\n this.clear()\n this.signals.countChanged.dispose()\n }\n}\n\nexport default Counter\n","/**\n * @file Stats\n * @author Alexander Rose \n * @private\n */\n\nimport * as signalsWrapper from 'signals'\n\nexport default class Stats {\n signals = {\n updated: new signalsWrapper.Signal()\n }\n\n maxDuration = -Infinity\n minDuration = Infinity\n avgDuration = 14\n lastDuration = Infinity\n\n prevFpsTime = 0\n lastFps = Infinity\n lastFrames = 1\n frames = 0\n count = 0\n\n startTime: number\n currentTime: number\n\n constructor () {\n this.begin()\n }\n\n update () {\n this.startTime = this.end()\n this.currentTime = this.startTime\n this.signals.updated.dispatch()\n }\n\n begin () {\n this.startTime = window.performance.now()\n this.lastFrames = this.frames\n }\n\n end () {\n const time = window.performance.now()\n\n this.count += 1\n this.frames += 1\n\n this.lastDuration = time - this.startTime\n this.minDuration = Math.min(this.minDuration, this.lastDuration)\n this.maxDuration = Math.max(this.maxDuration, this.lastDuration)\n this.avgDuration -= this.avgDuration / 30\n this.avgDuration += this.lastDuration / 30\n\n if (time > this.prevFpsTime + 1000) {\n this.lastFps = this.frames\n this.prevFpsTime = time\n this.frames = 0\n }\n\n return time\n }\n}","/**\n * @file Shader Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { ShaderChunk } from 'three'\n\nimport './chunk/fog_fragment.glsl'\nimport './chunk/interior_fragment.glsl'\nimport './chunk/matrix_scale.glsl'\nimport './chunk/nearclip_vertex.glsl'\nimport './chunk/nearclip_fragment.glsl'\nimport './chunk/opaque_back_fragment.glsl'\nimport './chunk/radiusclip_vertex.glsl'\nimport './chunk/radiusclip_fragment.glsl'\nimport './chunk/unpack_color.glsl'\n\nimport { ShaderRegistry } from '../globals'\n\nexport type ShaderDefine = (\n 'NEAR_CLIP'|'RADIUS_CLIP'|'PICKING'|'NOLIGHT'|'FLAT_SHADED'|'OPAQUE_BACK'|\n 'DIFFUSE_INTERIOR'|'USE_INTERIOR_COLOR'|\n 'USE_SIZEATTENUATION'|'USE_MAP'|'ALPHATEST'|'SDF'|'FIXED_SIZE'|\n 'CUBIC_INTERPOLATION'|'BSPLINE_FILTER'|'CATMULROM_FILTER'|'MITCHELL_FILTER'\n)\nexport type ShaderDefines = {\n [k in ShaderDefine]?: number|string\n}\n\nfunction getDefines (defines: ShaderDefines) {\n if (defines === undefined) return ''\n\n const lines = []\n\n for (const name in defines) {\n const value = defines[ name as keyof ShaderDefines ]\n\n if (!value) continue\n\n lines.push(`#define ${name} ${value}`)\n }\n\n return lines.join('\\n') + '\\n'\n}\n\nconst reInclude = /^(?!\\/\\/)\\s*#include\\s+(\\S+)/gmi\nconst shaderCache: { [k: string]: string } = {}\n\nexport function getShader (name: string, defines: ShaderDefines = {}) {\n let hash = name + '|'\n for (const key in defines) {\n hash += key + ':' + defines[ key as keyof ShaderDefines ]\n }\n\n if (!shaderCache[ hash ]) {\n const definesText = getDefines(defines)\n\n let shaderText = ShaderRegistry.get(`shader/${name}`) as string\n if (!shaderText) {\n throw new Error(`empty shader, '${name}'`)\n }\n shaderText = shaderText.replace(reInclude, function (match, p1) {\n const path = `shader/chunk/${p1}.glsl`\n const chunk = ShaderRegistry.get(path) || ShaderChunk[ p1 ]\n if (!chunk) {\n throw new Error(`empty chunk, '${p1}'`)\n }\n return chunk\n })\n\n shaderCache[ hash ] = definesText + shaderText\n }\n\n return shaderCache[ hash ]\n}\n","/**\n * @file Viewer Constants\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug } from '../globals'\n\nif (typeof WebGLRenderingContext !== 'undefined') {\n const wrcp = WebGLRenderingContext.prototype\n\n // wrap WebGL debug function used by three.js and\n // ignore calls to them when the debug flag is not set\n\n const _getShaderParameter = wrcp.getShaderParameter\n wrcp.getShaderParameter = function getShaderParameter (this: WebGLRenderingContext) {\n if (Debug) {\n return _getShaderParameter.apply(this, arguments)\n } else {\n return true\n }\n }\n\n const _getShaderInfoLog = wrcp.getShaderInfoLog\n wrcp.getShaderInfoLog = function getShaderInfoLog (this: WebGLRenderingContext) {\n if (Debug) {\n return _getShaderInfoLog.apply(this, arguments)\n } else {\n return ''\n }\n }\n\n const _getProgramParameter = wrcp.getProgramParameter\n wrcp.getProgramParameter = function getProgramParameter (this: WebGLRenderingContext, program, pname) {\n if (Debug || pname !== wrcp.LINK_STATUS) {\n return _getProgramParameter.apply(this, arguments)\n } else {\n return true\n }\n }\n\n const _getProgramInfoLog = wrcp.getProgramInfoLog\n wrcp.getProgramInfoLog = function getProgramInfoLog (this: WebGLRenderingContext) {\n if (Debug) {\n return _getProgramInfoLog.apply(this, arguments)\n } else {\n return ''\n }\n }\n}\n\nexport const JitterVectors = [\n [\n [ 0, 0 ]\n ],\n [\n [ 4, 4 ], [ -4, -4 ]\n ],\n [\n [ -2, -6 ], [ 6, -2 ], [ -6, 2 ], [ 2, 6 ]\n ],\n [\n [ 1, -3 ], [ -1, 3 ], [ 5, 1 ], [ -3, -5 ],\n [ -5, 5 ], [ -7, -1 ], [ 3, 7 ], [ 7, -7 ]\n ],\n [\n [ 1, 1 ], [ -1, -3 ], [ -3, 2 ], [ 4, -1 ],\n [ -5, -2 ], [ 2, 5 ], [ 5, 3 ], [ 3, -5 ],\n [ -2, 6 ], [ 0, -7 ], [ -4, -6 ], [ -6, 4 ],\n [ -8, 0 ], [ 7, -4 ], [ 6, 7 ], [ -7, -8 ]\n ],\n [\n [ -4, -7 ], [ -7, -5 ], [ -3, -5 ], [ -5, -4 ],\n [ -1, -4 ], [ -2, -2 ], [ -6, -1 ], [ -4, 0 ],\n [ -7, 1 ], [ -1, 2 ], [ -6, 3 ], [ -3, 3 ],\n [ -7, 6 ], [ -3, 6 ], [ -5, 7 ], [ -1, 7 ],\n [ 5, -7 ], [ 1, -6 ], [ 6, -5 ], [ 4, -4 ],\n [ 2, -3 ], [ 7, -2 ], [ 1, -1 ], [ 4, -1 ],\n [ 2, 1 ], [ 6, 2 ], [ 0, 4 ], [ 4, 4 ],\n [ 2, 5 ], [ 7, 5 ], [ 5, 6 ], [ 3, 7 ]\n ]\n]\n\nJitterVectors.forEach(offsetList => {\n offsetList.forEach(offset => {\n // 0.0625 = 1 / 16\n offset[ 0 ] *= 0.0625\n offset[ 1 ] *= 0.0625\n })\n})\n","/**\n * @file Tiled Renderer\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { Camera, WebGLRenderer } from 'three'\nimport Viewer from './viewer'\n\nexport interface TiledRendererParams {\n factor?: number\n antialias?: boolean\n onProgress?: Function\n onFinish?: Function\n}\n\nclass TiledRenderer {\n canvas = document.createElement('canvas')\n\n private _width: number\n private _height: number\n private _n: number\n private _factor: number\n private _antialias: boolean\n private _viewerSampleLevel: number\n\n private _viewer: Viewer\n private _onProgress?: Function\n private _onFinish?: Function\n private _ctx: CanvasRenderingContext2D\n\n constructor(renderer: WebGLRenderer, camera: Camera, viewer: Viewer, params: TiledRendererParams) {\n this._viewer = viewer\n\n this._factor = defaults(params.factor, 2)\n this._antialias = defaults(params.antialias, false)\n\n this._onProgress = params.onProgress\n this._onFinish = params.onFinish\n\n if (this._antialias) this._factor *= 2\n this._n = this._factor * this._factor\n\n // canvas\n\n this._width = this._viewer.width\n this._height = this._viewer.height\n\n if (this._antialias) {\n this.canvas.width = this._width * this._factor / 2\n this.canvas.height = this._height * this._factor / 2\n } else {\n this.canvas.width = this._width * this._factor\n this.canvas.height = this._height * this._factor\n }\n\n this._ctx = this.canvas.getContext('2d')!\n\n this._viewerSampleLevel = viewer.sampleLevel\n this._viewer.setSampling(-1)\n }\n\n private _renderTile (i: number) {\n const viewer = this._viewer\n const width = this._width\n const height = this._height\n const factor = this._factor\n\n const x = i % factor\n const y = Math.floor(i / factor)\n\n const offsetX = x * width\n const offsetY = y * height\n\n viewer.camera.setViewOffset(\n width * factor,\n height * factor,\n offsetX,\n offsetY,\n width,\n height\n )\n\n viewer.render()\n\n if (this._antialias) {\n const w = Math.round((offsetX + width) / 2) - Math.round (offsetX / 2);\n const h = Math.round((offsetY + height) / 2) - Math.round (offsetY / 2);\n this._ctx.drawImage(\n viewer.renderer.domElement,\n Math.round(offsetX / 2),\n Math.round(offsetY / 2),\n w,\n h\n )\n } else {\n this._ctx.drawImage(\n viewer.renderer.domElement,\n Math.floor(offsetX),\n Math.floor(offsetY),\n Math.ceil(width),\n Math.ceil(height)\n )\n }\n\n if (typeof this._onProgress === 'function') {\n this._onProgress(i + 1, this._n, false)\n }\n }\n\n private _finalize () {\n this._viewer.setSampling(this._viewerSampleLevel)\n this._viewer.camera.view = null! // TODO\n\n if (typeof this._onFinish === 'function') {\n this._onFinish(this._n + 1, this._n, false)\n }\n }\n\n render () {\n for (let i = 0; i <= this._n; ++i) {\n if (i === this._n) {\n this._finalize()\n } else {\n this._renderTile(i)\n }\n }\n }\n\n renderAsync () {\n let count = 0\n const n = this._n\n\n const fn = () => {\n if (count === n) {\n this._finalize()\n } else {\n this._renderTile(count)\n }\n count += 1\n }\n\n for (let i = 0; i <= n; ++i) {\n setTimeout(fn, 0)\n }\n }\n}\n\nexport default TiledRenderer\n","/**\n * @file Math Constants\n * @author Alexander Rose \n * @private\n */\n\nexport const EPS = 0.0000001\nexport const TwoPI = 2 * Math.PI\n\nexport const DEG2RAD = Math.PI / 180\nexport const RAD2DEG = 180 / Math.PI\n","/**\n * @file Array Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { NumberArray } from '../types'\nimport { TwoPI } from './math-constants'\n\nexport function circularMean (array: NumberArray, max: number, stride = 1, offset = 0, indices?: NumberArray) {\n // http://en.wikipedia.org/wiki/Center_of_mass#Systems_with_periodic_boundary_conditions\n\n // Bai, Linge; Breen, David (2008). Calculating Center of Mass in an Unbounded 2D Environment. Journal of Graphics, GPU, and Game Tools 13 (4): 53–60.\n\n // http://stackoverflow.com/questions/18166507/using-fft-to-find-the-center-of-mass-under-periodic-boundary-conditions\n\n const n = indices ? indices.length : array.length / stride\n\n let cosMean = 0\n let sinMean = 0\n\n if (indices) {\n for (let i = 0; i < n; ++i) {\n const c = (array[ indices[ i ] * stride + offset ] + max) % max\n const angle = (c / max) * TwoPI - Math.PI\n\n cosMean += Math.cos(angle)\n sinMean += Math.sin(angle)\n }\n } else {\n for (let i = offset; i < n; i += stride) {\n const c = (array[ i ] + max) % max\n const angle = (c / max) * TwoPI - Math.PI\n\n cosMean += Math.cos(angle)\n sinMean += Math.sin(angle)\n }\n }\n\n cosMean /= n\n sinMean /= n\n\n const meanAngle = Math.atan2(sinMean, cosMean)\n const mean = (meanAngle + Math.PI) / TwoPI * max\n\n return mean\n}\n\nexport function calculateCenterArray (array1: NumberArray, array2: NumberArray, center?: T, offset = 0): T {\n const n = array1.length\n const c = center || new Float32Array(n)\n\n for (let i = 0; i < n; i += 3) {\n c[ offset + i + 0 ] = (array1[ i + 0 ] + array2[ i + 0 ]) / 2.0\n c[ offset + i + 1 ] = (array1[ i + 1 ] + array2[ i + 1 ]) / 2.0\n c[ offset + i + 2 ] = (array1[ i + 2 ] + array2[ i + 2 ]) / 2.0\n }\n\n return c as T\n}\n\nexport function calculateDirectionArray (array1: NumberArray, array2: NumberArray) {\n const n = array1.length\n const direction = new Float32Array(n)\n\n for (let i = 0; i < n; i += 3) {\n direction[ i + 0 ] = array2[ i + 0 ] - array1[ i + 0 ]\n direction[ i + 1 ] = array2[ i + 1 ] - array1[ i + 1 ]\n direction[ i + 2 ] = array2[ i + 2 ] - array1[ i + 2 ]\n }\n\n return direction\n}\n\nexport function uniformArray (n: number, a: number, optionalTarget?: T): T {\n const array = optionalTarget || new Float32Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = a\n }\n\n return array as T\n}\n\nexport function uniformArray3 (n: number, a: number, b: number, c: number, optionalTarget?: NumberArray) {\n const array = optionalTarget || new Float32Array(n * 3)\n\n for (let i = 0; i < n; ++i) {\n const j = i * 3\n\n array[ j + 0 ] = a\n array[ j + 1 ] = b\n array[ j + 2 ] = c\n }\n\n return array\n}\n\nexport function centerArray3 (array: NumberArray, center = new Vector3()) {\n const n = array.length\n\n for (let i = 0; i < n; i += 3) {\n center.x += array[ i ]\n center.y += array[ i + 1 ]\n center.z += array[ i + 2 ]\n }\n\n center.divideScalar(n / 3)\n\n return center\n}\n\nexport function serialArray (n: number) {\n const array = new Float32Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = i\n }\n\n return array\n}\n\nexport function serialBlockArray (n: number, b: number, offset = 0, optionalTarget?: NumberArray) {\n const array = optionalTarget || new Float32Array(n * b)\n\n for (let i = 0; i < n; ++i) {\n const k = offset + i * b\n\n for (let j = 0; j < b; ++j) {\n array[ k + j ] = i\n }\n }\n\n return array\n}\n\nexport function randomColorArray (n: number) {\n const array = new Float32Array(n * 3)\n\n for (let i = 0; i < n; ++i) {\n const j = i * 3\n\n array[ j + 0 ] = Math.random()\n array[ j + 1 ] = Math.random()\n array[ j + 2 ] = Math.random()\n }\n\n return array\n}\n\nexport function replicateArrayEntries (array: NumberArray, m: number) {\n const n = array.length\n const repArr = new Float32Array(n * m)\n\n for (let i = 0; i < n; ++i) {\n const k = i * m\n const a = array[ i ]\n\n for (let j = 0; j < m; ++j) {\n repArr[ k + j ] = a\n }\n }\n\n return repArr\n}\n\nexport function replicateArray3Entries (array: NumberArray, m: number) {\n const n = array.length / 3\n const repArr = new Float32Array(n * m * 3)\n\n for (let i = 0; i < n; ++i) {\n const v = i * 3\n const k = i * m * 3\n\n const a = array[ v + 0 ]\n const b = array[ v + 1 ]\n const c = array[ v + 2 ]\n\n for (let j = 0; j < m; ++j) {\n const l = k + j * 3\n\n repArr[ l + 0 ] = a\n repArr[ l + 1 ] = b\n repArr[ l + 2 ] = c\n }\n }\n\n return repArr\n}\n\nexport function calculateMeanArray (array1: NumberArray, array2: NumberArray) {\n const n = array1.length\n const mean = new Float32Array(n)\n\n for (let i = 0; i < n; i++) {\n mean[ i ] = (array1[ i ] + array2[ i ]) / 2.0\n }\n\n return mean\n}\n\nexport function calculateMinArray (array1: NumberArray, array2: NumberArray) {\n const n = array1.length\n const min = new Float32Array(n)\n\n for (let i = 0; i < n; i++) {\n min[ i ] = Math.min(array1[ i ], array2[ i ])\n }\n\n return min\n}\n\nexport function copyArray (src: T, dst: T, srcOffset: number, dstOffset: number, length: number) {\n for (let i = 0; i < length; ++i) {\n dst[ dstOffset + i ] = src[ srcOffset + i ]\n }\n}\n\nexport function copyWithin (array: NumberArray|any[], srcOffset: number, dstOffset: number, length: number) {\n copyArray(array, array, srcOffset, dstOffset, length)\n}\n\nconst swap = new Float32Array(4)\nconst temp = new Float32Array(4)\n/**\n * quicksortIP\n * @function\n * @author Roman Bolzern , 2013\n * @author I4DS http://www.fhnw.ch/i4ds, 2013\n * @license MIT License \n * @description\n * In-place quicksort for typed arrays (e.g. for Float32Array)\n * provides fast sorting\n * useful e.g. for a custom shader and/or BufferGeometry\n * Complexity: http://bigocheatsheet.com/ see Quicksort\n *\n * @example\n * points: [x, y, z, x, y, z, x, y, z, ...]\n * eleSize: 3 //because of (x, y, z)\n * orderElement: 0 //order according to x\n *\n * @param {TypedArray} arr - array to be sorted\n * @param {Integer} eleSize - element size\n * @param {Integer} orderElement - index of element used for sorting, < eleSize\n * @param {Integer} [begin] - start index for range to be sorted\n * @param {Integer} [end] - end index for range to be sorted\n * @return {TypedArray} the input array\n */\nexport function quicksortIP (arr: NumberArray, eleSize: number, orderElement: number, begin = 0, end?: number) {\n end = (end || (arr.length / eleSize)) - 1\n\n const stack = []\n let sp = -1\n let left = begin\n let right = end\n let tmp = 0.0\n let x = 0\n let y = 0\n\n const swapF = function (a: number, b: number) {\n a *= eleSize; b *= eleSize\n for (y = 0; y < eleSize; y++) {\n tmp = arr[ a + y ]\n arr[ a + y ] = arr[ b + y ]\n arr[ b + y ] = tmp\n }\n }\n\n let i, j\n\n while (true) {\n if (right - left <= 25) {\n for (j = left + 1; j <= right; j++) {\n for (x = 0; x < eleSize; x++) {\n swap[ x ] = arr[ j * eleSize + x ]\n }\n\n i = j - 1\n\n while (i >= left && arr[ i * eleSize + orderElement ] > swap[ orderElement ]) {\n for (x = 0; x < eleSize; x++) {\n arr[ (i + 1) * eleSize + x ] = arr[ i * eleSize + x ]\n }\n i--\n }\n\n for (x = 0; x < eleSize; x++) {\n arr[ (i + 1) * eleSize + x ] = swap[ x ]\n }\n }\n\n if (sp === -1) break\n\n right = stack[ sp-- ] // ?\n left = stack[ sp-- ]\n } else {\n const median = (left + right) >> 1\n\n i = left + 1\n j = right\n\n swapF(median, i)\n\n if (arr[ left * eleSize + orderElement ] > arr[ right * eleSize + orderElement ]) {\n swapF(left, right)\n }\n\n if (arr[ i * eleSize + orderElement ] > arr[ right * eleSize + orderElement ]) {\n swapF(i, right)\n }\n\n if (arr[ left * eleSize + orderElement ] > arr[ i * eleSize + orderElement ]) {\n swapF(left, i)\n }\n\n for (x = 0; x < eleSize; x++) {\n temp[ x ] = arr[ i * eleSize + x ]\n }\n\n while (true) {\n do i++; while (arr[ i * eleSize + orderElement ] < temp[ orderElement ])\n do j--; while (arr[ j * eleSize + orderElement ] > temp[ orderElement ])\n if (j < i) break\n swapF(i, j)\n }\n\n for (x = 0; x < eleSize; x++) {\n arr[ (left + 1) * eleSize + x ] = arr[ j * eleSize + x ]\n arr[ j * eleSize + x ] = temp[ x ]\n }\n\n if (right - i + 1 >= j - left) {\n stack[ ++sp ] = i\n stack[ ++sp ] = right\n right = j - 1\n } else {\n stack[ ++sp ] = left\n stack[ ++sp ] = j - 1\n left = i\n }\n }\n }\n\n return arr\n}\n\nexport function quicksortCmp (arr: NumberArray|T[], cmp?: (a: number|T, b: number|T) => number, begin = 0, end?: number) {\n cmp = cmp || function cmp (a, b) {\n if (a > b) return 1\n if (a < b) return -1\n return 0\n }\n end = (end || arr.length) - 1\n\n const stack = []\n let sp = -1\n let left = begin\n let right = end\n let tmp: number|T\n\n function swap (a: number, b: number) {\n const tmp2 = arr[ a ]\n arr[ a ] = arr[ b ]\n arr[ b ] = tmp2\n }\n\n let i, j\n\n while (true) {\n if (right - left <= 25) {\n for (let k = left + 1; k <= right; ++k) {\n tmp = arr[ k ]\n i = k - 1\n\n while (i >= left && cmp(arr[ i ], tmp) > 0) {\n arr[ i + 1 ] = arr[ i ]\n --i\n }\n\n arr[ i + 1 ] = tmp\n }\n\n if (sp === -1) break\n\n right = stack[ sp-- ] // ?\n left = stack[ sp-- ]\n } else {\n const median = (left + right) >> 1\n\n i = left + 1\n j = right\n\n swap(median, i)\n\n if (cmp(arr[ left ], arr[ right ]) > 0) {\n swap(left, right)\n }\n\n if (cmp(arr[ i ], arr[ right ]) > 0) {\n swap(i, right)\n }\n\n if (cmp(arr[ left ], arr[ i ]) > 0) {\n swap(left, i)\n }\n\n tmp = arr[ i ]\n\n while (true) {\n do i++; while (cmp(arr[ i ], tmp) < 0)\n do j--; while (cmp(arr[ j ], tmp) > 0)\n if (j < i) break\n swap(i, j)\n }\n\n arr[ left + 1 ] = arr[ j ]\n arr[ j ] = tmp\n\n if (right - i + 1 >= j - left) {\n stack[ ++sp ] = i\n stack[ ++sp ] = right\n right = j - 1\n } else {\n stack[ ++sp ] = left\n stack[ ++sp ] = j - 1\n left = i\n }\n }\n }\n\n return arr\n}\n\nexport function quickselectCmp (arr: NumberArray|T[], n: number, cmp?: (a: number|T, b: number|T) => number, left = 0, right?: number) {\n cmp = cmp || function cmp (a, b) {\n if (a > b) return 1\n if (a < b) return -1\n return 0\n }\n right = (right || arr.length) - 1\n\n let pivotIndex, pivotValue, storeIndex\n\n function swap (a: number, b: number) {\n const tmp = arr[ a ]\n arr[ a ] = arr[ b ]\n arr[ b ] = tmp\n }\n\n while (true) {\n if (left === right) {\n return arr[ left ]\n }\n pivotIndex = (left + right) >> 1\n pivotValue = arr[ pivotIndex ]\n swap(pivotIndex, right)\n storeIndex = left\n for (let i = left; i < right; ++i) {\n if (cmp(arr[ i ], pivotValue) < 0) {\n swap(storeIndex, i)\n ++storeIndex\n }\n }\n swap(right, storeIndex)\n pivotIndex = storeIndex\n if (n === pivotIndex) {\n return arr[ n ]\n } else if (n < pivotIndex) {\n right = pivotIndex - 1\n } else {\n left = pivotIndex + 1\n }\n }\n}\n\nexport function arrayMax (array: NumberArray) {\n let max = -Infinity\n for (let i = 0, il = array.length; i < il; ++i) {\n if (array[ i ] > max) max = array[ i ]\n }\n return max\n}\n\nexport function arrayMin (array: NumberArray) {\n let min = Infinity\n for (let i = 0, il = array.length; i < il; ++i) {\n if (array[ i ] < min) min = array[ i ]\n }\n return min\n}\n\nexport function arraySum (array: NumberArray, stride = 1, offset = 0) {\n const n = array.length\n let sum = 0\n for (let i = offset; i < n; i += stride) {\n sum += array[ i ]\n }\n return sum\n}\n\nexport function arrayMean (array: NumberArray, stride = 1, offset = 0) {\n return arraySum(array, stride, offset) / (array.length / stride)\n}\n\nexport function arrayRms (array: NumberArray) {\n const n = array.length\n let sumSq = 0\n for (let i = 0; i < n; ++i) {\n const di = array[ i ]\n sumSq += di * di\n }\n return Math.sqrt(sumSq / n)\n}\n\nexport function arraySorted (array: NumberArray) {\n for (let i = 1, il = array.length; i < il; ++i) {\n if (array[ i - 1 ] > array[ i ]) return false\n }\n return true\n}\n\nexport function arraySortedCmp (array: NumberArray|T[], cmp: (a: number|T, b: number|T) => number) {\n for (let i = 1, il = array.length; i < il; ++i) {\n if (cmp(array[ i - 1 ], array[ i ]) > 0) return false\n }\n return true\n}\n","/**\n * @file Viewer Utils\n * @author Alexander Rose \n * @private\n */\n\nimport {\n Vector2, Vector3, Matrix4, Points, Scene, Camera,\n Object3D, WebGLRenderer\n} from 'three'\n\nimport { createParams } from '../utils'\nimport TiledRenderer from './tiled-renderer'\nimport { quicksortCmp } from '../math/array-utils'\nimport Viewer from './viewer'\n\nfunction _trimCanvas (canvas: HTMLCanvasElement, r: number, g: number, b: number, a: number) {\n const canvasHeight = canvas.height\n const canvasWidth = canvas.width\n\n const ctx = canvas.getContext('2d')!\n const pixels = ctx.getImageData(0, 0, canvasWidth, canvasHeight).data\n\n let x, y, doBreak, off\n\n doBreak = false\n for (y = 0; y < canvasHeight; y++) {\n for (x = 0; x < canvasWidth; x++) {\n off = (y * canvasWidth + x) * 4\n if (pixels[ off ] !== r || pixels[ off + 1 ] !== g ||\n pixels[ off + 2 ] !== b || pixels[ off + 3 ] !== a\n ) {\n doBreak = true\n break\n }\n }\n if (doBreak) {\n break\n }\n }\n const topY = y\n\n doBreak = false\n for (x = 0; x < canvasWidth; x++) {\n for (y = 0; y < canvasHeight; y++) {\n off = (y * canvasWidth + x) * 4\n if (pixels[ off ] !== r || pixels[ off + 1 ] !== g ||\n pixels[ off + 2 ] !== b || pixels[ off + 3 ] !== a\n ) {\n doBreak = true\n break\n }\n }\n if (doBreak) {\n break\n }\n }\n const topX = x\n\n doBreak = false\n for (y = canvasHeight - 1; y >= 0; y--) {\n for (x = canvasWidth - 1; x >= 0; x--) {\n off = (y * canvasWidth + x) * 4\n if (pixels[ off ] !== r || pixels[ off + 1 ] !== g ||\n pixels[ off + 2 ] !== b || pixels[ off + 3 ] !== a\n ) {\n doBreak = true\n break\n }\n }\n if (doBreak) {\n break\n }\n }\n const bottomY = y\n\n doBreak = false\n for (x = canvasWidth - 1; x >= 0; x--) {\n for (y = canvasHeight - 1; y >= 0; y--) {\n off = (y * canvasWidth + x) * 4\n if (pixels[ off ] !== r || pixels[ off + 1 ] !== g ||\n pixels[ off + 2 ] !== b || pixels[ off + 3 ] !== a\n ) {\n doBreak = true\n break\n }\n }\n if (doBreak) {\n break\n }\n }\n const bottomX = x\n\n const trimedCanvas = document.createElement('canvas')\n trimedCanvas.width = bottomX - topX\n trimedCanvas.height = bottomY - topY\n\n const trimedCtx = trimedCanvas.getContext('2d')!\n trimedCtx.drawImage(\n canvas,\n topX, topY,\n trimedCanvas.width, trimedCanvas.height,\n 0, 0,\n trimedCanvas.width, trimedCanvas.height\n )\n\n return trimedCanvas\n}\n\n/**\n * Image parameter object.\n * @typedef {Object} ImageParameters - image generation parameters\n * @property {Boolean} trim - trim the image\n * @property {Integer} factor - scaling factor to apply to the viewer canvas\n * @property {Boolean} antialias - antialias the image\n * @property {Boolean} transparent - transparent image background\n */\n\nexport const ImageDefaultParameters = {\n trim: false,\n factor: 1,\n antialias: false,\n transparent: false,\n onProgress: undefined as Function|undefined\n}\nexport type ImageParameters = typeof ImageDefaultParameters\n\n/**\n * Make image from what is shown in a viewer canvas\n * @param {Viewer} viewer - the viewer\n * @param {ImageParameters} params - parameters object\n * @return {Promise} A Promise object that resolves to an image {@link Blob}.\n */\nexport function makeImage (viewer: Viewer, params: Partial = {}) {\n const {trim, factor, antialias, transparent} = createParams(params, ImageDefaultParameters)\n\n const renderer = viewer.renderer\n const camera = viewer.camera\n\n const originalClearAlpha = renderer.getClearAlpha()\n const backgroundColor = renderer.getClearColor()\n\n function setLineWidthAndPixelSize (invert = false) {\n let _factor = factor\n if (antialias) _factor *= 2\n if (invert) _factor = 1 / _factor\n viewer.scene.traverse(function (o: any) { // TODO\n const m = o.material\n if (m && m.linewidth) {\n m.linewidth *= _factor\n }\n if (m && m.uniforms && m.uniforms.size) {\n if (m.uniforms.size.__seen === undefined) {\n m.uniforms.size.value *= _factor\n m.uniforms.size.__seen = true\n }\n }\n if (m && m.uniforms && m.uniforms.linewidth) {\n if (m.uniforms.linewidth.__seen === undefined) {\n m.uniforms.linewidth.value *= _factor\n m.uniforms.linewidth.__seen = true\n }\n }\n })\n viewer.scene.traverse(function (o: any) { // TODO\n const m = o.material\n if (m && m.uniforms && m.uniforms.size) {\n delete m.uniforms.size.__seen\n }\n if (m && m.uniforms && m.uniforms.linewidth) {\n delete m.uniforms.linewidth.__seen\n }\n })\n }\n\n function trimCanvas (canvas: HTMLCanvasElement) {\n if (trim) {\n const bg = backgroundColor\n const r = transparent ? 0 : bg.r * 255\n const g = transparent ? 0 : bg.g * 255\n const b = transparent ? 0 : bg.b * 255\n const a = transparent ? 0 : 255\n return _trimCanvas(canvas, r, g, b, a)\n } else {\n return canvas\n }\n }\n\n function onProgress (i: number, n: number, finished: boolean) {\n if (typeof params.onProgress === 'function') {\n params.onProgress(i, n, finished)\n }\n }\n\n return new Promise(function (resolve, reject) {\n const tiledRenderer = new TiledRenderer(\n renderer, camera, viewer,\n { factor, antialias, onProgress, onFinish }\n )\n\n renderer.setClearAlpha(transparent ? 0 : 1)\n setLineWidthAndPixelSize()\n tiledRenderer.renderAsync()\n\n function onFinish (i: number, n: number) {\n const canvas = trimCanvas(tiledRenderer.canvas)\n canvas.toBlob(\n function (blob) {\n renderer.setClearAlpha(originalClearAlpha)\n setLineWidthAndPixelSize(true)\n viewer.requestRender()\n onProgress(n, n, true)\n if (blob) {\n resolve(blob)\n } else {\n reject('error creating image')\n }\n },\n 'image/png'\n )\n }\n })\n}\n\nconst vertex = new Vector3()\nconst matrix = new Matrix4()\nconst modelViewProjectionMatrix = new Matrix4()\n\nexport function sortProjectedPosition (scene: Scene, camera: Camera) {\n // console.time( \"sort\" );\n\n scene.traverseVisible(function (o) {\n if (!(o instanceof Points) || !o.userData.buffer.parameters.sortParticles) {\n return\n }\n\n const attributes = (o.geometry as any).attributes // TODO\n const n = attributes.position.count\n\n if (n === 0) return\n\n matrix.multiplyMatrices(\n camera.matrixWorldInverse, o.matrixWorld\n )\n modelViewProjectionMatrix.multiplyMatrices(\n camera.projectionMatrix, matrix\n )\n\n let sortData, sortArray, zArray: Float32Array, cmpFn\n\n if (!o.userData.sortData) {\n zArray = new Float32Array(n)\n sortArray = new Uint32Array(n)\n cmpFn = function (ai: number, bi: number) {\n const a = zArray[ ai ]\n const b = zArray[ bi ]\n if (a > b) return 1\n if (a < b) return -1\n return 0\n }\n\n sortData = {\n __zArray: zArray,\n __sortArray: sortArray,\n __cmpFn: cmpFn\n }\n\n o.userData.sortData = sortData\n } else {\n sortData = o.userData.sortData\n zArray = sortData.__zArray\n sortArray = sortData.__sortArray\n cmpFn = sortData.__cmpFn\n }\n\n for (let i = 0; i < n; ++i) {\n vertex.fromArray(attributes.position.array, i * 3)\n vertex.applyMatrix4(modelViewProjectionMatrix)\n\n // negate, so that sorting order is reversed\n zArray[ i ] = -vertex.z\n sortArray[ i ] = i\n }\n\n quicksortCmp(sortArray, cmpFn)\n\n let index, indexSrc, indexDst, tmpTab\n\n for (let name in attributes) {\n const attr = attributes[ name ]\n const array = attr.array\n const itemSize = attr.itemSize\n\n if (!sortData[ name ]) {\n sortData[ name ] = new Float32Array(itemSize * n)\n }\n\n tmpTab = sortData[ name ]\n sortData[ name ] = array\n\n for (let i = 0; i < n; ++i) {\n index = sortArray[ i ]\n\n for (let j = 0; j < itemSize; ++j) {\n indexSrc = index * itemSize + j\n indexDst = i * itemSize + j\n tmpTab[ indexDst ] = array[ indexSrc ]\n }\n }\n\n attributes[ name ].array = tmpTab\n attributes[ name ].needsUpdate = true\n }\n })\n\n // console.timeEnd( \"sort\" );\n}\n\nconst resolution = new Vector2()\nconst projectionMatrixInverse = new Matrix4()\nconst projectionMatrixTranspose = new Matrix4()\n\nexport function updateMaterialUniforms (group: Object3D, camera: Camera, renderer: WebGLRenderer, cDist: number, bRadius: number) {\n let size = new Vector2()\n renderer.getSize(size)\n const canvasHeight = size.height\n const pixelRatio = renderer.getPixelRatio()\n const ortho = camera.type === 'OrthographicCamera'\n\n resolution.set(size.width, size.height)\n projectionMatrixInverse.getInverse(camera.projectionMatrix)\n projectionMatrixTranspose.copy(camera.projectionMatrix).transpose()\n\n group.traverse(function (o: any) {\n const m = o.material\n if (!m) return\n\n const u = m.uniforms\n if (!u) return\n\n if (m.clipNear) {\n const nearFactor = (50 - m.clipNear) / 50\n const nearClip = cDist - (bRadius * nearFactor)\n u.clipNear.value = nearClip\n }\n\n if (u.canvasHeight) {\n u.canvasHeight.value = canvasHeight\n }\n\n if (u.resolution) {\n u.resolution.value.copy(resolution)\n }\n\n if (u.pixelRatio) {\n u.pixelRatio.value = pixelRatio\n }\n\n if (u.projectionMatrixInverse) {\n u.projectionMatrixInverse.value.copy(projectionMatrixInverse)\n }\n\n if (u.projectionMatrixTranspose) {\n u.projectionMatrixTranspose.value.copy(projectionMatrixTranspose)\n }\n\n if (u.ortho) {\n u.ortho.value = ortho\n }\n })\n}\n\nexport function updateCameraUniforms (group: Object3D, camera: Camera) {\n projectionMatrixInverse.getInverse(camera.projectionMatrix)\n projectionMatrixTranspose.copy(camera.projectionMatrix).transpose()\n\n group.traverse(function (o: any) {\n const m = o.material\n if (!m) return\n\n const u = m.uniforms\n if (!u) return\n\n if (u.projectionMatrixInverse) {\n u.projectionMatrixInverse.value.copy(projectionMatrixInverse)\n }\n\n if (u.projectionMatrixTranspose) {\n u.projectionMatrixTranspose.value.copy(projectionMatrixTranspose)\n }\n })\n}\n","/**\n * @file Viewer\n * @author Alexander Rose \n * @private\n */\n\n// adapted from https://webglfundamentals.org/webgl/resources/webgl-utils.js\n// Copyright 2012, Gregg Tavares. Modified BSD License\n\nexport function createProgram(gl: WebGLRenderingContext, shaders: WebGLShader[], attribs?: string[], locations?: number[]) {\n const program = gl.createProgram()\n if (!program) {\n console.log(`error creating WebGL program`)\n return\n }\n shaders.forEach(shader => gl.attachShader(program, shader))\n if (attribs) {\n attribs.forEach((attrib, i) => {\n gl.bindAttribLocation(program, locations ? locations[i] : i, attrib)\n })\n }\n gl.linkProgram(program);\n\n // Check the link status\n const linked = gl.getProgramParameter(program, gl.LINK_STATUS)\n if (!linked) {\n console.log(`error linking program: ${gl.getProgramInfoLog(program)}`)\n gl.deleteProgram(program)\n return null\n }\n return program\n}\n\nexport function loadShader(gl: WebGLRenderingContext, shaderSource: string, shaderType: number) {\n const shader = gl.createShader(shaderType)\n if (!shader) {\n console.log(`error creating WebGL shader ${shaderType}`)\n return // can't create shader\n }\n gl.shaderSource(shader, shaderSource)\n gl.compileShader(shader)\n\n // Check the compile status\n const compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS)\n if (!compiled) {\n console.log(`error compiling shader ${shader}: ${gl.getShaderInfoLog(shader)}`)\n gl.deleteShader(shader)\n return null\n }\n\n return shader\n}\n\n//\n\nexport function getErrorDescription(gl: WebGLRenderingContext, error: number) {\n switch (error) {\n case gl.NO_ERROR: return 'no error'\n case gl.INVALID_ENUM: return 'invalid enum'\n case gl.INVALID_VALUE: return 'invalid value'\n case gl.INVALID_OPERATION: return 'invalid operation'\n case gl.INVALID_FRAMEBUFFER_OPERATION: return 'invalid framebuffer operation'\n case gl.OUT_OF_MEMORY: return 'out of memory'\n case gl.CONTEXT_LOST_WEBGL: return 'context lost'\n }\n return 'unknown error'\n}\n\nexport function getExtension (gl: WebGLRenderingContext, name: string) {\n const ext = gl.getExtension(name)\n if (!ext) console.log(`extension '${name}' not available`)\n return ext\n}\n\nconst TextureTestVertShader = `\nattribute vec4 a_position;\n\nvoid main() {\n gl_Position = a_position;\n}`\n\nconst TextureTestFragShader = `\nprecision mediump float;\nuniform vec4 u_color;\nuniform sampler2D u_texture;\n\nvoid main() {\n gl_FragColor = texture2D(u_texture, vec2(0.5, 0.5)) * u_color;\n}`\n\nconst TextureTestTexCoords = new Float32Array([\n -1.0, -1.0, 1.0, -1.0, -1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0\n])\n\nexport function testTextureSupport (type: number) {\n // adapted from\n // https://stackoverflow.com/questions/28827511/webgl-ios-render-to-floating-point-texture\n\n // Get A WebGL context\n const canvas = document.createElement('canvas')\n canvas.width = 16\n canvas.height = 16\n canvas.style.width = 16 + 'px'\n canvas.style.height = 16 + 'px'\n const gl = canvas.getContext(\"webgl\") || canvas.getContext(\"experimental-webgl\");\n if (!gl) {\n console.log(`error creating webgl context for ${type}`)\n return false\n }\n if (!(gl instanceof WebGLRenderingContext)) {\n console.log(`Got unexpected type for WebGL rendering context`)\n return false\n }\n\n getExtension(gl, 'OES_texture_float')\n getExtension(gl, 'OES_texture_half_float')\n getExtension(gl, 'WEBGL_color_buffer_float')\n\n // setup shaders\n const vertShader = loadShader(gl, TextureTestVertShader, gl.VERTEX_SHADER)\n const fragShader = loadShader(gl, TextureTestFragShader, gl.FRAGMENT_SHADER)\n if (!vertShader || !fragShader) return false\n\n // setup program\n const program = createProgram(gl, [ vertShader, fragShader ])\n if (!program) {\n console.log(`error creating WebGL program`)\n return false\n }\n gl.useProgram(program);\n\n // look up where the vertex data needs to go.\n const positionLocation = gl.getAttribLocation(program, \"a_position\");\n const colorLoc = gl.getUniformLocation(program, \"u_color\");\n if (!colorLoc) {\n console.log(`error getting 'u_color' uniform location`)\n return false\n }\n\n // provide texture coordinates for the rectangle.\n const positionBuffer = gl.createBuffer()\n gl.bindBuffer(gl.ARRAY_BUFFER, positionBuffer)\n gl.bufferData(gl.ARRAY_BUFFER, TextureTestTexCoords, gl.STATIC_DRAW)\n gl.enableVertexAttribArray(positionLocation)\n gl.vertexAttribPointer(positionLocation, 2, gl.FLOAT, false, 0, 0)\n\n const whiteTex = gl.createTexture()\n const whiteData = new Uint8Array([255, 255, 255, 255])\n gl.bindTexture(gl.TEXTURE_2D, whiteTex)\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, gl.UNSIGNED_BYTE, whiteData)\n\n const tex = gl.createTexture()\n gl.bindTexture(gl.TEXTURE_2D, tex)\n gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, 1, 1, 0, gl.RGBA, type, null)\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST)\n gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST)\n\n const fb = gl.createFramebuffer()\n gl.bindFramebuffer(gl.FRAMEBUFFER, fb)\n gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, tex, 0)\n const status = gl.checkFramebufferStatus(gl.FRAMEBUFFER)\n if (status !== gl.FRAMEBUFFER_COMPLETE) {\n console.log(`error creating framebuffer for ${type}`)\n return false\n }\n\n // Draw the rectangle.\n gl.bindTexture(gl.TEXTURE_2D, whiteTex)\n gl.uniform4fv(colorLoc, [0, 10, 20, 1])\n gl.drawArrays(gl.TRIANGLES, 0, 6)\n\n gl.bindTexture(gl.TEXTURE_2D, tex)\n gl.bindFramebuffer(gl.FRAMEBUFFER, null)\n gl.clearColor(1, 0, 0, 1)\n gl.clear(gl.COLOR_BUFFER_BIT)\n gl.uniform4fv(colorLoc, [0, 1/10, 1/20, 1])\n gl.drawArrays(gl.TRIANGLES, 0, 6)\n\n // Check if rendered correctly\n const pixel = new Uint8Array(4)\n gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, pixel)\n if (pixel[0] !== 0 || pixel[1] < 248 || pixel[2] < 248 || pixel[3] < 254) {\n console.log(`not able to actually render to ${type} texture`)\n return false\n }\n\n // Check reading from float texture\n if (type === gl.FLOAT) {\n gl.bindFramebuffer(gl.FRAMEBUFFER, fb)\n const floatPixel = new Float32Array(4)\n gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.FLOAT, floatPixel)\n const error = gl.getError()\n if (error) {\n console.log(`error reading pixels as float: '${getErrorDescription(gl, error)}'`)\n return false\n }\n }\n\n return true\n}\n","/**\n * @file Viewer\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\nimport {\n PerspectiveCamera, OrthographicCamera, StereoCamera,\n Vector2, Box3, Vector3, Matrix4, Color,\n WebGLRenderer, WebGLRenderTarget,\n NearestFilter, LinearFilter, AdditiveBlending,\n RGBAFormat, FloatType, /*HalfFloatType, */UnsignedByteType,\n ShaderMaterial,\n PlaneGeometry, Geometry,\n Scene, Mesh, Group, Object3D, Uniform,\n Fog, SpotLight, AmbientLight,\n BufferGeometry, BufferAttribute,\n LineSegments,\n LinearEncoding, sRGBEncoding, TextureEncoding\n} from 'three'\nimport '../shader/BasicLine.vert'\nimport '../shader/BasicLine.frag'\nimport '../shader/Quad.vert'\nimport '../shader/Quad.frag'\n\nimport {\n Debug, Log, WebglErrorMessage, Browser,\n setExtensionFragDepth, SupportsReadPixelsFloat, setSupportsReadPixelsFloat\n} from '../globals'\nimport { degToRad } from '../math/math-utils'\nimport Stats from './stats'\nimport { getShader } from '../shader/shader-utils'\nimport { setColorSpace } from '../color/colormaker'\nimport { JitterVectors } from './viewer-constants'\nimport {\n makeImage, ImageParameters,\n sortProjectedPosition, updateMaterialUniforms, updateCameraUniforms\n} from './viewer-utils'\nimport { testTextureSupport } from './gl-utils'\n\nimport Buffer from '../buffer/buffer'\n\nconst pixelBufferFloat = new Float32Array(4 * 25)\nconst pixelBufferUint = new Uint8Array(4 * 25)\n\n// When picking, we read a 25 pixel (5x5) array (readRenderTargetPixels)\n// We read the pixels in the order below to find what was picked.\n// This starts at the center and tries successively further points.\n// (Many points will be at equal distance to the center, their order\n// is arbitrary).\nconst pixelOrder = [12,7,13,17,11,6,8,18,16,2,14,22,10,1,3,9,19,23,21,15,5,0,4,24,20]\n\n\nconst tmpMatrix = new Matrix4()\n\nfunction onBeforeRender (this: Object3D, renderer: WebGLRenderer, scene: Scene, camera: PerspectiveCamera|OrthographicCamera, geometry: Geometry, material: ShaderMaterial/*, group */) {\n const u = material.uniforms\n const updateList = []\n\n if (!u) return // See #908 - some materials may not have uniforms, ignore these\n\n if (u.objectId) {\n u.objectId.value = SupportsReadPixelsFloat ? this.id : this.id / 255\n updateList.push('objectId')\n }\n\n if (u.modelViewMatrixInverse || u.modelViewMatrixInverseTranspose ||\n u.modelViewProjectionMatrix || u.modelViewProjectionMatrixInverse\n ) {\n this.modelViewMatrix.multiplyMatrices(camera.matrixWorldInverse, this.matrixWorld)\n }\n\n if (u.modelViewMatrixInverse) {\n u.modelViewMatrixInverse.value.getInverse(this.modelViewMatrix)\n updateList.push('modelViewMatrixInverse')\n }\n\n if (u.modelViewMatrixInverseTranspose) {\n if (u.modelViewMatrixInverse) {\n u.modelViewMatrixInverseTranspose.value.copy(\n u.modelViewMatrixInverse.value\n ).transpose()\n } else {\n u.modelViewMatrixInverseTranspose.value\n .getInverse(this.modelViewMatrix)\n .transpose()\n }\n updateList.push('modelViewMatrixInverseTranspose')\n }\n\n if (u.modelViewProjectionMatrix) {\n u.modelViewProjectionMatrix.value.multiplyMatrices(\n camera.projectionMatrix, this.modelViewMatrix\n )\n updateList.push('modelViewProjectionMatrix')\n }\n\n if (u.modelViewProjectionMatrixInverse) {\n if (u.modelViewProjectionMatrix) {\n tmpMatrix.copy(\n u.modelViewProjectionMatrix.value\n )\n u.modelViewProjectionMatrixInverse.value.getInverse(\n tmpMatrix\n )\n } else {\n tmpMatrix.multiplyMatrices(\n camera.projectionMatrix, this.modelViewMatrix\n )\n u.modelViewProjectionMatrixInverse.value.getInverse(\n tmpMatrix\n )\n }\n updateList.push('modelViewProjectionMatrixInverse')\n }\n\n if (updateList.length) {\n const materialProperties = renderer.properties.get(material)\n\n if (materialProperties.program) {\n const gl = renderer.getContext()\n const p = materialProperties.program\n gl.useProgram(p.program)\n const pu = p.getUniforms()\n\n updateList.forEach(function (name) {\n pu.setValue(gl, name, u[ name ].value)\n })\n }\n }\n}\n\nexport type CameraType = 'perspective'|'orthographic'|'stereo'\nexport type ColorWorkflow = 'linear' | 'sRGB'\n\nexport interface ViewerSignals {\n ticked: Signal,\n rendered: Signal\n}\n\nexport interface ViewerParameters {\n fogColor: Color\n fogNear: number\n fogFar: number\n\n backgroundColor: Color\n\n cameraType: CameraType\n cameraFov: number\n cameraEyeSep: number\n cameraZ: number\n\n clipNear: number\n clipFar: number\n clipDist: number\n clipMode: string // \"scene\" or \"camera\"\n clipScale: string // \"relative\" or \"absolute\"\n\n lightColor: Color\n lightIntensity: number\n ambientColor: Color\n ambientIntensity: number\n\n sampleLevel: number\n\n rendererEncoding: TextureEncoding // default is three.LinearEncoding; three.sRGBEncoding gives more correct results\n}\n\nexport interface BufferInstance {\n matrix: Matrix4\n}\n\n/**\n * Viewer class\n * @class\n * @param {String|Element} [idOrElement] - dom id or element\n */\nexport default class Viewer {\n signals: ViewerSignals\n\n container: HTMLElement\n wrapper: HTMLElement\n\n private rendering: boolean\n private renderPending: boolean\n private lastRenderedPicking: boolean\n private isStill: boolean\n private frameRequest: number\n\n sampleLevel: number\n private cDist: number\n private bRadius: number\n\n private parameters: ViewerParameters\n stats: Stats\n\n perspectiveCamera: PerspectiveCamera\n private orthographicCamera: OrthographicCamera\n private stereoCamera: StereoCamera\n camera: PerspectiveCamera|OrthographicCamera\n\n width: number\n height: number\n\n scene: Scene\n private spotLight: SpotLight\n private ambientLight: AmbientLight\n rotationGroup: Group\n translationGroup: Group\n private modelGroup: Group\n private pickingGroup: Group\n private backgroundGroup: Group\n private helperGroup: Group\n\n renderer: WebGLRenderer\n private supportsHalfFloat: boolean\n\n private pickingTarget: WebGLRenderTarget\n private sampleTarget: WebGLRenderTarget\n private holdTarget: WebGLRenderTarget\n\n private compositeUniforms: {\n tForeground: Uniform\n scale: Uniform\n }\n private compositeMaterial: ShaderMaterial\n private compositeCamera: OrthographicCamera\n private compositeScene: Scene\n\n private boundingBoxMesh: LineSegments\n boundingBox = new Box3()\n private boundingBoxSize = new Vector3()\n private boundingBoxLength = 0\n\n private info = {\n memory: {\n programs: 0,\n geometries: 0,\n textures: 0\n },\n render: {\n calls: 0,\n vertices: 0,\n faces: 0,\n points: 0\n }\n }\n\n private distVector = new Vector3()\n\n constructor (idOrElement: string|HTMLElement) {\n this.signals = {\n ticked: new Signal(),\n rendered: new Signal()\n }\n\n if (typeof idOrElement === 'string') {\n const elm = document.getElementById(idOrElement)\n if (elm === null) {\n this.container = document.createElement('div')\n }else {\n this.container = elm\n }\n } else if (idOrElement instanceof HTMLElement) {\n this.container = idOrElement\n } else {\n this.container = document.createElement('div')\n }\n\n if (this.container === document.body) {\n this.width = window.innerWidth || 1\n this.height = window.innerHeight || 1\n } else {\n const box = this.container.getBoundingClientRect()\n this.width = box.width || 1\n this.height = box.height || 1\n this.container.style.overflow = 'hidden'\n }\n\n this.wrapper = document.createElement('div')\n this.wrapper.style.position = 'relative'\n this.container.appendChild(this.wrapper)\n\n this._initParams()\n this._initStats()\n this._initCamera()\n this._initScene()\n\n if (this._initRenderer() === false) {\n Log.error('Viewer: could not initialize renderer')\n return\n }\n\n this._initHelper()\n\n // fog & background\n this.setBackground()\n this.setFog()\n\n this.animate = this.animate.bind(this)\n }\n\n private _initParams () {\n this.parameters = {\n fogColor: new Color(0x000000),\n fogNear: 50,\n fogFar: 100,\n\n backgroundColor: new Color(0x000000),\n\n cameraType: 'perspective',\n cameraFov: 40,\n cameraEyeSep: 0.3,\n cameraZ: -80, // FIXME initial value should be automatically determined\n\n clipNear: 0,\n clipFar: 100,\n clipDist: 10,\n clipMode: 'scene',\n clipScale: 'relative',\n\n lightColor: new Color(0xdddddd),\n lightIntensity: 1.0,\n ambientColor: new Color(0xdddddd),\n ambientIntensity: 0.2,\n\n sampleLevel: 0,\n\n // output encoding: use sRGB for a linear internal workflow, linear for traditional sRGB workflow.\n rendererEncoding: LinearEncoding,\n }\n }\n\n private _initCamera () {\n const lookAt = new Vector3(0, 0, 0)\n const {width, height} = this\n\n this.perspectiveCamera = new PerspectiveCamera(\n this.parameters.cameraFov, width / height\n )\n this.perspectiveCamera.position.z = this.parameters.cameraZ\n this.perspectiveCamera.lookAt(lookAt)\n\n this.orthographicCamera = new OrthographicCamera(\n width / -2, width / 2, height / 2, height / -2\n )\n this.orthographicCamera.position.z = this.parameters.cameraZ\n this.orthographicCamera.lookAt(lookAt)\n\n this.stereoCamera = new StereoCamera()\n this.stereoCamera.aspect = 0.5\n this.stereoCamera.eyeSep = this.parameters.cameraEyeSep\n\n const cameraType = this.parameters.cameraType\n if (cameraType === 'orthographic') {\n this.camera = this.orthographicCamera\n } else if(cameraType === 'perspective' || cameraType === 'stereo') {\n this.camera = this.perspectiveCamera\n } else {\n throw new Error(`Unknown cameraType '${cameraType}'`)\n }\n this.camera.updateProjectionMatrix()\n }\n\n private _initStats () {\n this.stats = new Stats()\n }\n\n private _initScene () {\n if (!this.scene) {\n this.scene = new Scene()\n this.scene.name = 'scene'\n }\n\n this.rotationGroup = new Group()\n this.rotationGroup.name = 'rotationGroup'\n this.scene.add(this.rotationGroup)\n\n this.translationGroup = new Group()\n this.translationGroup.name = 'translationGroup'\n this.rotationGroup.add(this.translationGroup)\n\n this.modelGroup = new Group()\n this.modelGroup.name = 'modelGroup'\n this.translationGroup.add(this.modelGroup)\n\n this.pickingGroup = new Group()\n this.pickingGroup.name = 'pickingGroup'\n this.translationGroup.add(this.pickingGroup)\n\n this.backgroundGroup = new Group()\n this.backgroundGroup.name = 'backgroundGroup'\n this.translationGroup.add(this.backgroundGroup)\n\n this.helperGroup = new Group()\n this.helperGroup.name = 'helperGroup'\n this.translationGroup.add(this.helperGroup)\n\n // fog\n\n this.scene.fog = new Fog(this.parameters.fogColor.getHex())\n\n // light\n\n this.spotLight = new SpotLight(\n this.parameters.lightColor.getHex(), this.parameters.lightIntensity\n )\n this.scene.add(this.spotLight)\n\n this.ambientLight = new AmbientLight(\n this.parameters.ambientColor.getHex(), this.parameters.ambientIntensity\n )\n this.scene.add(this.ambientLight)\n }\n\n private _initRenderer () {\n const dpr = window.devicePixelRatio\n const {width, height} = this\n\n try {\n this.renderer = new WebGLRenderer({\n preserveDrawingBuffer: true,\n alpha: true,\n antialias: true\n })\n } catch (e) {\n this.wrapper.innerHTML = WebglErrorMessage\n return false\n }\n this.renderer.setPixelRatio(dpr)\n this.renderer.setSize(width, height)\n this.renderer.autoClear = false\n this.renderer.sortObjects = true\n this.renderer.outputEncoding = this.parameters.rendererEncoding\n\n const gl = this.renderer.getContext()\n // console.log(gl.getContextAttributes().antialias)\n // console.log(gl.getParameter(gl.SAMPLES))\n\n // For WebGL1, extensions must be explicitly enabled.\n // The following are builtin to WebGL2 (and don't appear as\n // extensions)\n // EXT_frag_depth, OES_element_index_uint, OES_texture_float\n // OES_texture_half_float\n\n // The WEBGL_color_buffer_float extension is replaced by\n // EXT_color_buffer_float\n\n // If not webgl2 context, explicitly check for these\n if (!this.renderer.capabilities.isWebGL2) {\n setExtensionFragDepth(this.renderer.extensions.get('EXT_frag_depth'))\n this.renderer.extensions.get('OES_element_index_uint')\n\n setSupportsReadPixelsFloat(\n (this.renderer.extensions.get('OES_texture_float') &&\n this.renderer.extensions.get('WEBGL_color_buffer_float')) ||\n (this.renderer.extensions.get('OES_texture_float') &&\n testTextureSupport(gl.FLOAT))\n )\n // picking texture\n\n this.renderer.extensions.get('OES_texture_float')\n\n this.supportsHalfFloat = (\n this.renderer.extensions.get('OES_texture_half_float') &&\n testTextureSupport(0x8D61)\n )\n\n } else {\n setExtensionFragDepth(true)\n setSupportsReadPixelsFloat(\n this.renderer.extensions.get('EXT_color_buffer_float')\n )\n this.supportsHalfFloat = true\n }\n\n this.wrapper.appendChild(this.renderer.domElement)\n\n const dprWidth = width * dpr\n const dprHeight = height * dpr\n\n\n if (Debug) {\n console.log(JSON.stringify({\n 'Browser': Browser,\n 'OES_texture_float': !!this.renderer.extensions.get('OES_texture_float'),\n 'OES_texture_half_float': !!this.renderer.extensions.get('OES_texture_half_float'),\n 'WEBGL_color_buffer_float': !!this.renderer.extensions.get('WEBGL_color_buffer_float'),\n 'testTextureSupport Float': testTextureSupport(gl.FLOAT),\n 'testTextureSupport HalfFloat': testTextureSupport(0x8D61),\n 'this.supportsHalfFloat': this.supportsHalfFloat,\n 'SupportsReadPixelsFloat': SupportsReadPixelsFloat\n }, null, 2))\n }\n\n this.pickingTarget = new WebGLRenderTarget(\n dprWidth, dprHeight,\n {\n minFilter: NearestFilter,\n magFilter: NearestFilter,\n stencilBuffer: false,\n format: RGBAFormat,\n type: SupportsReadPixelsFloat ? FloatType : UnsignedByteType\n }\n )\n this.pickingTarget.texture.generateMipmaps = false\n this.pickingTarget.texture.encoding = this.parameters.rendererEncoding\n\n // workaround to reset the gl state after using testTextureSupport\n // fixes some bug where nothing is rendered to the canvas\n // when animations are started on page load\n this.renderer.setRenderTarget(this.pickingTarget)\n this.renderer.clear()\n this.renderer.setRenderTarget(null!)\n\n // ssaa textures\n\n this.sampleTarget = new WebGLRenderTarget(\n dprWidth, dprHeight,\n {\n minFilter: LinearFilter,\n magFilter: LinearFilter,\n format: RGBAFormat\n }\n )\n this.sampleTarget.texture.encoding = this.parameters.rendererEncoding\n\n this.holdTarget = new WebGLRenderTarget(\n dprWidth, dprHeight,\n {\n minFilter: NearestFilter,\n magFilter: NearestFilter,\n format: RGBAFormat,\n type: UnsignedByteType\n // using HalfFloatType or FloatType does not work on some Chrome 61 installations\n // type: this.supportsHalfFloat ? HalfFloatType : (\n // SupportsReadPixelsFloat ? FloatType : UnsignedByteType\n // )\n }\n )\n this.holdTarget.texture.encoding = this.parameters.rendererEncoding\n\n this.compositeUniforms = {\n 'tForeground': new Uniform(this.sampleTarget.texture),\n 'scale': new Uniform(1.0)\n }\n\n this.compositeMaterial = new ShaderMaterial({\n uniforms: this.compositeUniforms,\n vertexShader: getShader('Quad.vert'),\n fragmentShader: getShader('Quad.frag'),\n premultipliedAlpha: true,\n transparent: true,\n blending: AdditiveBlending,\n depthTest: false,\n depthWrite: false\n })\n\n this.compositeCamera = new OrthographicCamera(-1, 1, 1, -1, 0, 1)\n this.compositeScene = new Scene()\n this.compositeScene.name = 'compositeScene'\n this.compositeScene.add(new Mesh(\n new PlaneGeometry(2, 2), this.compositeMaterial\n ))\n }\n\n private _initHelper () {\n const indices = new Uint16Array([\n 0, 1, 1, 2, 2, 3, 3, 0, 4, 5, 5, 6,\n 6, 7, 7, 4, 0, 4, 1, 5, 2, 6, 3, 7\n ])\n const positions = new Float32Array(8 * 3)\n\n const bbGeometry = new BufferGeometry()\n bbGeometry.setIndex(new BufferAttribute(indices, 1))\n bbGeometry.setAttribute('position', new BufferAttribute(positions, 3))\n const bbMaterial = new ShaderMaterial({\n uniforms: { 'uColor': { value: new Color('skyblue') } },\n vertexShader: getShader('BasicLine.vert'),\n fragmentShader: getShader('BasicLine.frag')\n })\n\n this.boundingBoxMesh = new LineSegments(bbGeometry, bbMaterial)\n this.helperGroup.add(this.boundingBoxMesh)\n }\n\n updateHelper () {\n const position = ((this.boundingBoxMesh.geometry as BufferGeometry).attributes as any).position // TODO\n const array = position.array\n const {min, max} = this.boundingBox\n\n array[ 0 ] = max.x; array[ 1 ] = max.y; array[ 2 ] = max.z\n array[ 3 ] = min.x; array[ 4 ] = max.y; array[ 5 ] = max.z\n array[ 6 ] = min.x; array[ 7 ] = min.y; array[ 8 ] = max.z\n array[ 9 ] = max.x; array[ 10 ] = min.y; array[ 11 ] = max.z\n array[ 12 ] = max.x; array[ 13 ] = max.y; array[ 14 ] = min.z\n array[ 15 ] = min.x; array[ 16 ] = max.y; array[ 17 ] = min.z\n array[ 18 ] = min.x; array[ 19 ] = min.y; array[ 20 ] = min.z\n array[ 21 ] = max.x; array[ 22 ] = min.y; array[ 23 ] = min.z\n\n position.needsUpdate = true\n\n if (!this.boundingBox.isEmpty()) {\n this.boundingBoxMesh.geometry.computeBoundingSphere()\n }\n }\n\n /** Distance from origin (lookAt point) */\n get cameraDistance(): number {\n return Math.abs(this.camera.position.z)\n }\n\n /** Set distance from origin (lookAt point); along the -z axis */\n set cameraDistance(d: number) {\n this.camera.position.z = -d\n }\n\n add (buffer: Buffer, instanceList?: BufferInstance[]) {\n // Log.time( \"Viewer.add\" );\n\n if (instanceList) {\n instanceList.forEach(instance => this.addBuffer(buffer, instance))\n } else {\n this.addBuffer(buffer)\n }\n\n buffer.group.name = 'meshGroup'\n buffer.wireframeGroup.name = 'wireframeGroup'\n if (buffer.parameters.background) {\n this.backgroundGroup.add(buffer.group)\n this.backgroundGroup.add(buffer.wireframeGroup)\n } else {\n this.modelGroup.add(buffer.group)\n this.modelGroup.add(buffer.wireframeGroup)\n }\n\n if (buffer.pickable) {\n this.pickingGroup.add(buffer.pickingGroup)\n }\n\n if (Debug) this.updateHelper()\n\n // Log.timeEnd( \"Viewer.add\" );\n }\n\n addBuffer (buffer: Buffer, instance?: BufferInstance) {\n // Log.time( \"Viewer.addBuffer\" );\n\n function setUserData (object: Object3D) {\n if (object instanceof Group) {\n object.children.forEach(setUserData)\n } else {\n object.userData.buffer = buffer\n object.userData.instance = instance\n object.onBeforeRender = onBeforeRender\n }\n }\n\n const mesh = buffer.getMesh()\n if (instance) {\n mesh.applyMatrix4(instance.matrix)\n }\n setUserData(mesh)\n buffer.group.add(mesh)\n\n const wireframeMesh = buffer.getWireframeMesh()\n if (instance) {\n // wireframeMesh.applyMatrix( instance.matrix );\n wireframeMesh.matrix.copy(mesh.matrix)\n wireframeMesh.position.copy(mesh.position)\n wireframeMesh.quaternion.copy(mesh.quaternion)\n wireframeMesh.scale.copy(mesh.scale)\n }\n setUserData(wireframeMesh)\n buffer.wireframeGroup.add(wireframeMesh)\n\n if (buffer.pickable) {\n const pickingMesh = buffer.getPickingMesh()\n if (instance) {\n // pickingMesh.applyMatrix( instance.matrix );\n pickingMesh.matrix.copy(mesh.matrix)\n pickingMesh.position.copy(mesh.position)\n pickingMesh.quaternion.copy(mesh.quaternion)\n pickingMesh.scale.copy(mesh.scale)\n }\n setUserData(pickingMesh)\n buffer.pickingGroup.add(pickingMesh)\n }\n\n if (instance) {\n this._updateBoundingBox(buffer.geometry, buffer.matrix, instance.matrix)\n } else {\n this._updateBoundingBox(buffer.geometry, buffer.matrix)\n }\n\n // Log.timeEnd( \"Viewer.addBuffer\" );\n }\n\n remove (buffer: Buffer) {\n this.translationGroup.children.forEach(function (group) {\n group.remove(buffer.group)\n group.remove(buffer.wireframeGroup)\n })\n\n if (buffer.pickable) {\n this.pickingGroup.remove(buffer.pickingGroup)\n }\n\n this.updateBoundingBox()\n if (Debug) this.updateHelper()\n\n // this.requestRender();\n }\n\n private _updateBoundingBox (geometry?: BufferGeometry, matrix?: Matrix4, instanceMatrix?: Matrix4) {\n const boundingBox = this.boundingBox\n\n function updateGeometry (geometry: BufferGeometry, matrix?: Matrix4, instanceMatrix?: Matrix4) {\n if (geometry.boundingBox == null) {\n geometry.computeBoundingBox()\n }\n\n const geoBoundingBox = (geometry.boundingBox as Box3).clone()\n\n if (matrix) {\n geoBoundingBox.applyMatrix4(matrix)\n }\n if (instanceMatrix) {\n geoBoundingBox.applyMatrix4(instanceMatrix)\n }\n\n if (geoBoundingBox.min.equals(geoBoundingBox.max)) {\n // mainly to give a single impostor geometry some volume\n // as it is only expanded in the shader on the GPU\n geoBoundingBox.expandByScalar(5)\n }\n\n boundingBox.union(geoBoundingBox)\n }\n\n function updateNode (node: Mesh) {\n if (node.geometry !== undefined) {\n let matrix, instanceMatrix\n if (node.userData.buffer) {\n matrix = node.userData.buffer.matrix\n }\n if (node.userData.instance) {\n instanceMatrix = node.userData.instance.matrix\n }\n updateGeometry(node.geometry as BufferGeometry, matrix, instanceMatrix) // TODO\n }\n }\n\n if (geometry) {\n updateGeometry(geometry, matrix, instanceMatrix)\n } else {\n boundingBox.makeEmpty()\n this.modelGroup.traverse(updateNode)\n this.backgroundGroup.traverse(updateNode)\n }\n\n boundingBox.getSize(this.boundingBoxSize)\n this.boundingBoxLength = this.boundingBoxSize.length()\n }\n\n updateBoundingBox () {\n this._updateBoundingBox()\n if (Debug) this.updateHelper()\n }\n\n getPickingPixels () {\n const {width, height} = this\n\n const n = width * height * 4\n const imgBuffer = SupportsReadPixelsFloat ? new Float32Array(n) : new Uint8Array(n)\n\n this.render(true)\n this.renderer.readRenderTargetPixels(\n this.pickingTarget, 0, 0, width, height, imgBuffer\n )\n\n return imgBuffer\n }\n\n getImage (picking: boolean) {\n return new Promise(resolve => {\n if (picking) {\n const {width, height} = this\n const n = width * height * 4\n let imgBuffer = this.getPickingPixels()\n\n if (SupportsReadPixelsFloat) {\n const imgBuffer2 = new Uint8Array(n)\n for (let i = 0; i < n; ++i) {\n imgBuffer2[ i ] = Math.round(imgBuffer[ i ] * 255)\n }\n imgBuffer = imgBuffer2\n }\n\n const canvas = document.createElement('canvas')\n canvas.width = width\n canvas.height = height\n const ctx = canvas.getContext('2d')! // TODO\n const imgData = ctx.getImageData(0, 0, width, height)\n imgData.data.set(imgBuffer as any) // TODO\n ctx.putImageData(imgData, 0, 0)\n canvas.toBlob(resolve as any, 'image/png') // TODO\n } else {\n this.renderer.domElement.toBlob(resolve as any, 'image/png') // TODO\n }\n })\n }\n\n makeImage (params: Partial = {}) {\n return makeImage(this, params)\n }\n\n setLight (color: Color|number|string, intensity: number, ambientColor: Color|number|string, ambientIntensity: number) {\n const p = this.parameters\n\n if (color !== undefined) p.lightColor.set(color as string) // TODO\n if (intensity !== undefined) p.lightIntensity = intensity\n if (ambientColor !== undefined) p.ambientColor.set(ambientColor as string) // TODO\n if (ambientIntensity !== undefined) p.ambientIntensity = ambientIntensity\n\n this.requestRender()\n }\n\n setFog (color?: Color|number|string, near?: number, far?: number) {\n const p = this.parameters\n\n if (color !== undefined) p.fogColor.set(color as string) // TODO\n if (near !== undefined) p.fogNear = near\n if (far !== undefined) p.fogFar = far\n\n this.requestRender()\n }\n\n setBackground (color?: Color|number|string) {\n const p = this.parameters\n\n if (color) p.backgroundColor.set(color as string) // TODO\n\n this.setFog(p.backgroundColor)\n this.renderer.setClearColor(p.backgroundColor, 0)\n this.renderer.domElement.style.backgroundColor = p.backgroundColor.getStyle()\n\n this.requestRender()\n }\n\n setSampling (level: number) {\n if (level !== undefined) {\n this.parameters.sampleLevel = level\n this.sampleLevel = level\n }\n\n this.requestRender()\n }\n\n /**\n * Set the output color encoding, i.e. how the renderer translates\n * colorspaces as it renders to the screen.\n\n * The default is LinearEncoding, because the internals of NGL are\n * already sRGB so no translation is needed to show sRGB colors.\n * Set to sRGBEncoding to create a linear workflow, and also call\n * `setColorEncoding(LinearEncoding)` to linearize colors on input.\n * @see setColorEncoding\n */\n private setOutputEncoding (encoding: TextureEncoding) {\n this.parameters.rendererEncoding = encoding\n this.renderer.outputEncoding = encoding\n this.pickingTarget.texture.encoding = encoding\n this.sampleTarget.texture.encoding = encoding\n this.holdTarget.texture.encoding = encoding\n }\n\n /**\n * Set the internal color workflow, linear or sRGB.\n * sRGB, the default, is more \"vibrant\" at the cost of accuracy.\n * Linear gives more accurate results, especially for transparent objects.\n * In all cases, the output is always sRGB; this just affects how colors are computed internally.\n * Call this just after creating the viewer, before loading any models.\n */\n setColorWorkflow (encoding: ColorWorkflow) {\n if (encoding != 'linear' && encoding != 'sRGB')\n throw new Error(`setColorWorkflow: invalid color workflow ${encoding}`)\n setColorSpace(encoding == 'linear' ? 'linear' : 'sRGB')\n this.setOutputEncoding(encoding == 'linear' ? sRGBEncoding : LinearEncoding)\n // Note: this doesn't rebuild models, so existing geometry will have\n // the old color encoding.\n this.requestRender()\n }\n\n setCamera (type: CameraType, fov?: number, eyeSep?: number) {\n const p = this.parameters\n\n if (type) p.cameraType = type\n if (fov) p.cameraFov = fov\n if (eyeSep) p.cameraEyeSep = eyeSep\n\n if (p.cameraType === 'orthographic') {\n if (this.camera !== this.orthographicCamera) {\n this.camera = this.orthographicCamera\n this.camera.position.copy(this.perspectiveCamera.position)\n this.camera.up.copy(this.perspectiveCamera.up)\n this.updateZoom()\n }\n } else if (p.cameraType === 'perspective' || p.cameraType === 'stereo') {\n if (this.camera !== this.perspectiveCamera) {\n this.camera = this.perspectiveCamera\n this.camera.position.copy(this.orthographicCamera.position)\n this.camera.up.copy(this.orthographicCamera.up)\n }\n } else {\n throw new Error(`Unknown cameraType '${p.cameraType}'`)\n }\n\n this.perspectiveCamera.fov = p.cameraFov\n this.stereoCamera.eyeSep = p.cameraEyeSep\n this.camera.updateProjectionMatrix()\n\n this.requestRender()\n }\n\n setClip (near: number, far: number, dist: number, clipMode?: string, clipScale?: string) {\n const p = this.parameters\n\n if (near !== undefined) p.clipNear = near\n if (far !== undefined) p.clipFar = far\n if (dist !== undefined) p.clipDist = dist\n if (clipMode !== undefined) p.clipMode = clipMode\n if (clipScale !== undefined) p.clipScale = clipScale\n\n this.requestRender()\n }\n\n setSize (width: number, height: number) {\n this.width = width || 1\n this.height = height || 1\n\n this.perspectiveCamera.aspect = this.width / this.height\n this.orthographicCamera.left = -this.width / 2\n this.orthographicCamera.right = this.width / 2\n this.orthographicCamera.top = this.height / 2\n this.orthographicCamera.bottom = -this.height / 2\n this.camera.updateProjectionMatrix()\n\n const dpr = window.devicePixelRatio\n\n this.renderer.setPixelRatio(dpr)\n this.renderer.setSize(width, height)\n\n const dprWidth = this.width * dpr\n const dprHeight = this.height * dpr\n\n this.pickingTarget.setSize(dprWidth, dprHeight)\n this.sampleTarget.setSize(dprWidth, dprHeight)\n this.holdTarget.setSize(dprWidth, dprHeight)\n\n this.requestRender()\n }\n\n handleResize () {\n if (this.container === document.body) {\n this.setSize(window.innerWidth, window.innerHeight)\n } else {\n const box = this.container.getBoundingClientRect()\n this.setSize(box.width, box.height)\n }\n }\n\n updateInfo (reset?: boolean) {\n const { memory, render } = this.info\n\n if (reset) {\n memory.programs = 0\n memory.geometries = 0\n memory.textures = 0\n\n render.calls = 0\n render.vertices = 0\n render.points = 0\n } else {\n const rInfo = this.renderer.info\n const rMemory = rInfo.memory\n const rRender = rInfo.render\n\n memory.geometries = rMemory.geometries\n memory.textures = rMemory.textures\n\n render.calls += rRender.calls\n render.faces += rRender.triangles\n render.points += rRender.points\n }\n }\n\n animate () {\n this.signals.ticked.dispatch(this.stats)\n const delta = window.performance.now() - this.stats.startTime\n\n if (delta > 500 && !this.isStill && this.sampleLevel < 3 && this.sampleLevel !== -1) {\n const currentSampleLevel = this.sampleLevel\n this.sampleLevel = 3\n this.renderPending = true\n this.render()\n this.isStill = true\n this.sampleLevel = currentSampleLevel\n if (Debug) Log.log('rendered still frame')\n }\n\n this.frameRequest = window.requestAnimationFrame(this.animate)\n }\n\n pick (x: number, y: number) {\n if (this.parameters.cameraType === 'stereo') {\n // TODO picking broken for stereo camera\n return {\n 'pid': 0,\n 'instance': undefined,\n 'picker': undefined\n }\n }\n\n x *= window.devicePixelRatio\n y *= window.devicePixelRatio\n\n x = Math.max(x - 2, 0)\n y = Math.max(y - 2, 0)\n\n let pid = 0, instance, picker\n const pixelBuffer = SupportsReadPixelsFloat ? pixelBufferFloat : pixelBufferUint\n\n this.render(true)\n this.renderer.readRenderTargetPixels(\n this.pickingTarget, x, y, 5, 5, pixelBuffer\n )\n\n for (let i = 0; i < pixelOrder.length; i++) {\n\n const offset = pixelOrder[i] * 4\n\n const oid = Math.round(pixelBuffer[ offset + 3 ])\n const object = this.pickingGroup.getObjectById(oid)\n if (object) {\n instance = object.userData.instance\n picker = object.userData.buffer.picking\n } else {\n continue\n }\n\n if (SupportsReadPixelsFloat) {\n pid =\n ((Math.round(pixelBuffer[offset] * 255) << 16) & 0xFF0000) |\n ((Math.round(pixelBuffer[offset + 1] * 255) << 8) & 0x00FF00) |\n ((Math.round(pixelBuffer[offset + 2] * 255)) & 0x0000FF)\n } else {\n pid =\n (pixelBuffer[offset] << 16) |\n (pixelBuffer[offset + 1] << 8) |\n (pixelBuffer[offset + 2])\n }\n }\n // if( Debug ){\n // const rgba = Array.apply( [], pixelBuffer );\n // Log.log( pixelBuffer );\n // Log.log(\n // \"picked color\",\n // rgba.map( c => { return c.toPrecision( 2 ) } )\n // );\n // Log.log( \"picked pid\", pid );\n // Log.log( \"picked oid\", oid );\n // Log.log( \"picked object\", object );\n // Log.log( \"picked instance\", instance );\n // Log.log( \"picked position\", x, y );\n // Log.log( \"devicePixelRatio\", window.devicePixelRatio );\n // }\n\n return { pid, instance, picker }\n }\n\n requestRender () {\n if (this.renderPending) {\n // Log.info(\"there is still a 'render' call pending\")\n return\n }\n\n // start gathering stats anew after inactivity\n if (window.performance.now() - this.stats.startTime > 22) {\n this.stats.begin()\n this.isStill = false\n }\n\n this.renderPending = true\n\n window.requestAnimationFrame(() => {\n this.render()\n this.stats.update()\n })\n }\n\n updateZoom () {\n const fov = degToRad(this.perspectiveCamera.fov)\n const height = 2 * Math.tan(fov / 2) * this.cameraDistance\n this.orthographicCamera.zoom = this.height / height\n }\n\n /**\n * Convert an absolute clip value to a relative one using bRadius.\n *\n * 0.0 -> 50.0\n * bRadius -> 0.0\n */\n absoluteToRelative (d: number) :number {\n return 50 * (1 - d / this.bRadius)\n }\n\n /**\n * Convert a relative clip value to an absolute one using bRadius\n *\n * 0.0 -> bRadius\n * 50.0 -> 0.0\n */\n relativeToAbsolute (d: number) : number {\n return this.bRadius * (1 - d / 50)\n }\n\n /**\n * Intepret clipMode, clipScale and set the camera and fog clipping.\n * Also ensures bRadius and cDist are valid\n */\n private __updateClipping () {\n const p = this.parameters\n\n // bRadius must always be updated for material-based clipping\n // and for focus calculations\n this.bRadius = Math.max(10, this.boundingBoxLength * 0.5)\n\n // FL: Removed below, but leaving commented as I don't understand intention\n // this.bRadius += this.boundingBox.getCenter(this.distVector).length()\n\n if (!isFinite(this.bRadius)) {\n this.bRadius = 50\n }\n\n this.camera.getWorldPosition(this.distVector)\n this.cDist = this.distVector.length()\n if (!this.cDist) {\n // recover from a broken (NaN) camera position\n this.cameraDistance = Math.abs(p.cameraZ)\n this.cDist = Math.abs(p.cameraZ)\n }\n\n // fog\n const fog = this.scene.fog as Fog\n fog.color.set(p.fogColor)\n\n if (p.clipMode === 'camera') {\n // Always interpret clipScale as absolute for clipMode camera\n\n this.camera.near = p.clipNear\n this.camera.far = p.clipFar\n fog.near = p.fogNear\n fog.far = p.fogFar\n\n } else {\n // scene mode\n\n if (p.clipScale === 'absolute') {\n // absolute scene mode; offset clip planes from scene center\n // (note: positive values move near plane towards camera and rear plane away)\n\n this.camera.near = this.cDist - p.clipNear\n this.camera.far = this.cDist + p.clipFar\n fog.near = this.cDist - p.fogNear\n fog.far = this.cDist + p.fogFar\n\n } else {\n // relative scene mode (default): convert pecentages to Angstroms\n\n const nearFactor = (50 - p.clipNear) / 50\n const farFactor = -(50 - p.clipFar) / 50\n this.camera.near = this.cDist - (this.bRadius * nearFactor)\n this.camera.far = this.cDist + (this.bRadius * farFactor)\n\n const fogNearFactor = (50 - p.fogNear) / 50\n const fogFarFactor = -(50 - p.fogFar) / 50\n fog.near = this.cDist - (this.bRadius * fogNearFactor)\n fog.far = this.cDist + (this.bRadius * fogFarFactor)\n }\n }\n\n if (p.clipMode !== 'camera') {\n\n if (this.camera.type === 'PerspectiveCamera') {\n\n this.camera.near = Math.max(0.1, p.clipDist, this.camera.near)\n this.camera.far = Math.max(1, this.camera.far)\n fog.near = Math.max(0.1, fog.near)\n fog.far = Math.max(1, fog.far)\n } else if (this.camera.type === 'OrthographicCamera') {\n\n if (p.clipDist > 0) {\n this.camera.near = Math.max(p.clipDist, this.camera.near)\n }\n }\n }\n }\n\n private __updateCamera () {\n const camera = this.camera\n camera.updateMatrix()\n camera.updateMatrixWorld(true)\n camera.updateProjectionMatrix()\n\n updateMaterialUniforms(this.scene, camera, this.renderer, this.cDist, this.bRadius)\n sortProjectedPosition(this.scene, camera)\n }\n\n private __setVisibility (model: boolean, picking: boolean, background: boolean, helper: boolean) {\n this.modelGroup.visible = model\n this.pickingGroup.visible = picking\n this.backgroundGroup.visible = background\n this.helperGroup.visible = helper\n }\n\n private __updateLights () {\n this.spotLight.color.set(this.parameters.lightColor)\n this.spotLight.intensity = this.parameters.lightIntensity\n\n this.distVector.copy(this.camera.position).setLength(this.boundingBoxLength * 100)\n this.spotLight.position.copy(this.camera.position).add(this.distVector)\n\n this.ambientLight.color.set(this.parameters.ambientColor)\n this.ambientLight.intensity = this.parameters.ambientIntensity\n }\n\n private __renderPickingGroup (camera: PerspectiveCamera|OrthographicCamera) {\n this.renderer.setRenderTarget(this.pickingTarget || null)\n this.renderer.clear()\n this.__setVisibility(false, true, false, false)\n this.renderer.render(this.scene, camera)\n // back to standard render target\n this.renderer.setRenderTarget(null)\n this.updateInfo()\n\n // if (Debug) {\n // this.__setVisibility(false, true, false, true);\n\n // this.renderer.clear();\n // this.renderer.render(this.scene, camera);\n // }\n }\n\n private __renderModelGroup (camera: PerspectiveCamera|OrthographicCamera, renderTarget?: WebGLRenderTarget) {\n this.renderer.setRenderTarget(renderTarget || null)\n this.renderer.clear()\n this.__setVisibility(false, false, true, false)\n this.renderer.render(this.scene, camera)\n this.renderer.clear(false, true, true)\n this.updateInfo()\n\n this.__setVisibility(true, false, false, Debug)\n this.renderer.render(this.scene, camera)\n this.renderer.setRenderTarget(null) // set back to default canvas\n this.updateInfo()\n }\n\n private __renderSuperSample (camera: PerspectiveCamera|OrthographicCamera, renderTarget?: WebGLRenderTarget) {\n // based on the Supersample Anti-Aliasing Render Pass\n // contributed to three.js by bhouston / http://clara.io/\n //\n // This manual approach to SSAA re-renders the scene ones for\n // each sample with camera jitter and accumulates the results.\n // References: https://en.wikipedia.org/wiki/Supersampling\n const offsetList = JitterVectors[ Math.max(0, Math.min(this.sampleLevel, 5)) ]\n\n const baseSampleWeight = 1.0 / offsetList.length\n const roundingRange = 1 / 32\n\n this.compositeUniforms.tForeground.value = this.sampleTarget.texture\n\n let width = this.sampleTarget.width\n const height = this.sampleTarget.height\n if (this.parameters.cameraType === 'stereo') {\n width /= 2\n }\n\n // render the scene multiple times, each slightly jitter offset\n // from the last and accumulate the results.\n for (let i = 0; i < offsetList.length; ++i) {\n const offset = offsetList[ i ]\n camera.setViewOffset(\n width, height, offset[ 0 ], offset[ 1 ], width, height\n )\n camera.updateProjectionMatrix()\n updateCameraUniforms(this.scene, camera)\n\n let sampleWeight = baseSampleWeight\n // the theory is that equal weights for each sample lead to an\n // accumulation of rounding errors.\n // The following equation varies the sampleWeight per sample\n // so that it is uniformly distributed across a range of values\n // whose rounding errors cancel each other out.\n const uniformCenteredDistribution = -0.5 + (i + 0.5) / offsetList.length\n sampleWeight += roundingRange * uniformCenteredDistribution\n this.compositeUniforms.scale.value = sampleWeight\n\n this.__renderModelGroup(camera, this.sampleTarget)\n this.renderer.setRenderTarget(this.holdTarget)\n if (i === 0) {\n this.renderer.clear()\n }\n\n this.renderer.render(this.compositeScene, this.compositeCamera)\n }\n\n this.compositeUniforms.scale.value = 1.0\n this.compositeUniforms.tForeground.value = this.holdTarget.texture\n\n camera.clearViewOffset()\n this.renderer.setRenderTarget(renderTarget || null)\n this.renderer.clear()\n this.renderer.render(this.compositeScene, this.compositeCamera)\n }\n\n private __renderStereo (picking = false, _renderTarget?: WebGLRenderTarget) {\n const stereoCamera = this.stereoCamera\n stereoCamera.update(this.perspectiveCamera);\n\n const renderer = this.renderer\n let size = new Vector2()\n renderer.getSize(size)\n\n renderer.setScissorTest(true)\n\n renderer.setScissor(0, 0, size.width / 2, size.height)\n renderer.setViewport(0, 0, size.width / 2, size.height)\n updateCameraUniforms(this.scene, stereoCamera.cameraL)\n this.__render(picking, stereoCamera.cameraL)\n\n renderer.setScissor(size.width / 2, 0, size.width / 2, size.height)\n renderer.setViewport(size.width / 2, 0, size.width / 2, size.height)\n updateCameraUniforms(this.scene, stereoCamera.cameraR)\n this.__render(picking, stereoCamera.cameraR)\n\n renderer.setScissorTest(false)\n renderer.setViewport(0, 0, size.width, size.height)\n }\n\n private __render(picking = false, camera: PerspectiveCamera|OrthographicCamera, renderTarget?: WebGLRenderTarget) {\n if (picking) {\n if (!this.lastRenderedPicking) this.__renderPickingGroup(camera)\n } else if (this.sampleLevel > 0 && this.parameters.cameraType !== 'stereo') {\n // TODO super sample broken for stereo camera\n this.__renderSuperSample(camera, renderTarget)\n } else {\n this.__renderModelGroup(camera, renderTarget)\n }\n }\n\n render (picking = false, renderTarget?: WebGLRenderTarget) {\n if (this.rendering) {\n Log.warn(\"'tried to call 'render' from within 'render'\")\n return\n }\n\n // Log.time('Viewer.render')\n\n this.rendering = true\n\n try {\n this.__updateClipping()\n this.__updateCamera()\n this.__updateLights()\n this.updateInfo(true)\n\n // render\n if (this.parameters.cameraType === 'stereo') {\n this.__renderStereo(picking, renderTarget)\n } else {\n this.__render(picking, this.camera, renderTarget)\n }\n this.lastRenderedPicking = picking\n } finally {\n this.rendering = false\n this.renderPending = false\n }\n this.signals.rendered.dispatch()\n\n // Log.timeEnd('Viewer.render')\n // Log.log(this.info.memory, this.info.render)\n }\n\n clear () {\n Log.log('scene cleared')\n this.scene.remove(this.rotationGroup)\n this._initScene()\n this.renderer.clear()\n }\n\n dispose () {\n this.renderer.dispose()\n window.cancelAnimationFrame(this.frameRequest)\n }\n}\n","/**\n * @file Mouse Observer\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector2 } from 'three'\nimport { Signal } from 'signals'\n\nimport { LeftMouseButton, RightMouseButton } from '../constants'\nimport { defaults } from '../utils'\nimport Viewer from '../viewer/viewer'\nimport MouseControls from '../controls/mouse-controls'\n\ntype Optional = Pick, K> & Omit;\n\n/**\n * @example\n * mouseObserver.signals.scrolled.add( function( delta ){ ... } );\n *\n * @typedef {Object} MouseSignals\n * @property {Signal} moved - on move: deltaX, deltaY\n * @property {Signal} scrolled - on scroll: delta\n * @property {Signal} dragged - on drag: deltaX, deltaY\n * @property {Signal} dropped - on drop\n * @property {Signal} clicked - on click\n * @property {Signal} hovered - on hover\n */\n\nfunction getTouchDistance (event: TouchEvent) {\n const dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX\n const dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY\n return Math.sqrt(dx * dx + dy * dy)\n}\n\nfunction getMouseButtons (event: MouseEvent) {\n if (typeof event === 'object') {\n if ('buttons' in event) {\n return event.buttons\n } else if ('which' in event as any) {\n const b = (event as any).which\n if (b === 2) {\n return 4\n } else if (b === 3) {\n return 2\n } else if (b > 0) {\n return 1 << (b - 1)\n }\n } else if ('button' in event as any) {\n const b = (event as any).button\n if (b === 1) {\n return 4\n } else if (b === 2) {\n return 2\n } else if (b >= 0) {\n return 1 << b\n }\n }\n }\n return 0\n}\n\nexport interface MouseSignals {\n moved: Signal // on move: deltaX, deltaY\n scrolled: Signal // on scroll: delta\n dragged: Signal // on drag: deltaX, deltaY\n dropped: Signal // on drop\n clicked: Signal // on click\n hovered: Signal // on hover\n doubleClicked: Signal\n}\n\nexport interface MouseParams {\n hoverTimeout?: number\n handleScroll?:boolean\n doubleClickSpeed?: number\n}\n\n/**\n * Mouse observer\n *\n * @example\n * // listen to mouse moving (and touch-moving) events\n * mouseObserver.moved.moved.add( function( deltaX, deltaY ){ ... } );\n *\n * @example\n * // listen to scrolling (and pinching) events\n * mouseObserver.signals.scrolled.add( function( delta ){ ... } );\n *\n * @example\n * // listen to dragging (and touch-dragging) events\n * mouseObserver.signals.dragged.add( function( deltaX, deltaY ){ ... } );\n *\n * @example\n * // listen to clicking (and tapping) events\n * mouseObserver.signals.clicked.add( function(){ ... } );\n *\n * @example\n * // listen to double clicking (and double tapping) events\n * mouseObserver.signals.doubleClicked.add( function(){ ... } );\n *\n * @example\n * // listen to hovering events\n * mouseObserver.signals.hovered.add( function(){ ... } );\n */\nclass MouseObserver {\n signals: MouseSignals = {\n moved: new Signal(),\n scrolled: new Signal(),\n dragged: new Signal(),\n dropped: new Signal(),\n clicked: new Signal(),\n hovered: new Signal(),\n doubleClicked: new Signal()\n }\n\n hoverTimeout: number\n handleScroll:boolean\n doubleClickSpeed: number\n\n viewer: Viewer\n mouse: MouseObserver\n controls: MouseControls\n\n position = new Vector2() // Position on page\n prevPosition = new Vector2() // Previous position on page\n down = new Vector2() // Position on page when clicked\n canvasPosition = new Vector2() // Position on dom element\n prevClickCP = new Vector2()\n\n moving = false // Flag indicating if the mouse is moving\n hovering = true // Flag indicating if the mouse is hovering\n scrolled = false // Flag indicating if there was a scolling event since the last mouse move\n lastMoved = Infinity // Timestamp of last mouse move\n which? = 0 // 0: No button; 1: Left button; 2: Middle button; 3: Right button\n buttons? = 0 // 0: No button; 1: Left button; 2: Right button; 4: Middle button\n pressed? = false // Flag indicating if the mouse is pressed down\n altKey = false // Flag indicating if the alt key is pressed\n ctrlKey = false // Flag indicating if the ctrl key is pressed\n metaKey = false // Flag indicating if the meta key is pressed\n shiftKey = false // Flag indicating if the shift key is pressed\n\n doubleClickPending: boolean\n lastClicked: number\n overElement: boolean\n lastTouchDistance: number\n private frameRequest: number\n\n /**\n * @param {Element} domElement - the dom element to observe mouse events in\n * @param {Object} params - parameters object\n * @param {Integer} params.hoverTimeout - timeout in ms until the {@link MouseSignals.hovered}\n * signal is fired, set to -1 to ignore hovering\n * @param {Boolean} params.handleScroll - whether or not to handle scroll events\n * @param {Integer} params.doubleClickSpeed - max time in ms to trigger double click\n */\n constructor (readonly domElement: HTMLCanvasElement, params: MouseParams = {}) {\n this.domElement.style.touchAction = 'none'\n\n this.hoverTimeout = defaults(params.hoverTimeout, 50)\n this.handleScroll = defaults(params.handleScroll, true)\n this.doubleClickSpeed = defaults(params.doubleClickSpeed, 500)\n\n this._listen = this._listen.bind(this)\n this._onMousewheel = this._onMousewheel.bind(this)\n this._onMousemove = this._onMousemove.bind(this)\n this._onMousedown = this._onMousedown.bind(this)\n this._onMouseup = this._onMouseup.bind(this)\n this._onContextmenu = this._onContextmenu.bind(this)\n this._onTouchstart = this._onTouchstart.bind(this)\n this._onTouchend = this._onTouchend.bind(this)\n this._onTouchmove = this._onTouchmove.bind(this)\n\n this._listen()\n\n const opt = { passive: false } // treat as 'passive' so preventDefault can be called\n document.addEventListener('mousewheel', this._onMousewheel, opt)\n document.addEventListener('wheel', this._onMousewheel, opt)\n document.addEventListener('MozMousePixelScroll', this._onMousewheel, opt)\n document.addEventListener('mousemove', this._onMousemove, opt)\n document.addEventListener('mousedown', this._onMousedown, opt)\n document.addEventListener('mouseup', this._onMouseup, opt)\n document.addEventListener('contextmenu', this._onContextmenu, opt)\n document.addEventListener('touchstart', this._onTouchstart, opt)\n document.addEventListener('touchend', this._onTouchend, opt)\n document.addEventListener('touchmove', this._onTouchmove, opt)\n }\n\n get key () {\n let key = 0\n if (this.altKey) key += 1\n if (this.ctrlKey) key += 2\n if (this.metaKey) key += 4\n if (this.shiftKey) key += 8\n return key\n }\n\n setParameters (params: MouseParams = {}) {\n this.hoverTimeout = defaults(params.hoverTimeout, this.hoverTimeout)\n }\n\n /**\n * listen to mouse actions\n * @emits {MouseSignals.clicked} when clicked\n * @emits {MouseSignals.hovered} when hovered\n * @return {undefined}\n */\n _listen () {\n const now = window.performance.now()\n const cp = this.canvasPosition\n if (this.doubleClickPending && now - this.lastClicked > this.doubleClickSpeed) {\n this.doubleClickPending = false\n }\n if (now - this.lastMoved > this.hoverTimeout) {\n this.moving = false\n }\n if (this.scrolled || (!this.moving && !this.hovering)) {\n this.scrolled = false\n if (this.hoverTimeout !== -1 && this.overElement) {\n this.hovering = true\n this.signals.hovered.dispatch(cp.x, cp.y)\n }\n }\n this.frameRequest = window.requestAnimationFrame(this._listen)\n }\n\n /**\n * handle mouse scroll\n * @emits {MouseSignals.scrolled} when scrolled\n * @param {Event} event - mouse event\n * @return {undefined}\n */\n _onMousewheel(event: Optional & { wheelDelta?: number, wheelDeltaY?: number }) {\n if (event.target !== this.domElement || !this.handleScroll) {\n return\n }\n event.preventDefault()\n this._setKeys(event as any)\n\n let delta = 0\n // This has to be written in a particular way to handle old browsers that\n // all send events with different properties set in different ways.\n if ('deltaY' in event && 'deltaMode' in event &&\n event.deltaY !== undefined && event.deltaMode !== undefined) {\n // all modern browsers, using WheelEvent; deltaY + down (toward user)\n if (event.deltaMode === WheelEvent.DOM_DELTA_PIXEL)\n // everything except Firefox: normally 100 per wheel click\n delta = -event.deltaY * (2.5 / 100.0)\n else if (event.deltaMode === WheelEvent.DOM_DELTA_LINE)\n // Firefox in line mode, normally 3 per wheel click\n delta = -event.deltaY * (2.5 / 3.0)\n else // page mode: 1 per wheel click\n delta = -event.deltaY * 2.5\n } else if ('deltaY' in event && !('detail' in event)) {\n // Old Firefox or IE 11: deltaY but no deltaMode; treat as pixels\n delta = -event.deltaY * (2.5 / 100.0)\n } else if (event.wheelDelta !== undefined) {\n delta = -event.wheelDelta * (2.5 / 100)\n } else if (event.wheelDeltaY !== undefined) {\n delta = -event.wheelDeltaY * (2.5 / 100)\n } else if (event.detail !== undefined){\n // Old Firefox, MouseWheelEvent\n delta = -event.detail / 3\n }\n this.signals.scrolled.dispatch(delta)\n\n setTimeout(() => {\n this.scrolled = true\n }, this.hoverTimeout)\n }\n\n /**\n * handle mouse move\n * @emits {MouseSignals.moved} when moved\n * @emits {MouseSignals.dragged} when dragged\n * @param {Event} event - mouse event\n * @return {undefined}\n */\n _onMousemove (event: MouseEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n this.overElement = true\n } else {\n this.overElement = false\n }\n this._setKeys(event)\n this.moving = true\n this.hovering = false\n this.lastMoved = window.performance.now()\n this.prevPosition.copy(this.position)\n this.position.set(event.clientX, event.clientY)\n this._setCanvasPosition(event)\n const dx = this.prevPosition.x - this.position.x\n const dy = this.prevPosition.y - this.position.y\n this.signals.moved.dispatch(dx, dy)\n if (this.pressed) {\n this.signals.dragged.dispatch(dx, dy)\n }\n }\n\n _onMousedown (event: MouseEvent) {\n if (event.target !== this.domElement) {\n return\n }\n event.preventDefault()\n this._setKeys(event)\n this.moving = false\n this.hovering = false\n this.down.set(event.clientX, event.clientY)\n this.position.set(event.clientX, event.clientY)\n this.which = event.which\n this.buttons = getMouseButtons(event)\n this.pressed = true\n this._setCanvasPosition(event)\n }\n\n /**\n * handle mouse up\n * @emits {MouseSignals.doubleClicked} when double clicked\n * @emits {MouseSignals.dropped} when dropped\n * @param {Event} event - mouse event\n * @return {undefined}\n */\n _onMouseup (event: MouseEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n }\n this._setKeys(event)\n const cp = this.canvasPosition\n if (this._distance() < 4) {\n this.lastClicked = window.performance.now()\n if (this.doubleClickPending && this.prevClickCP.distanceTo(cp) < 4) {\n this.signals.doubleClicked.dispatch(cp.x, cp.y)\n this.doubleClickPending = false\n }\n this.signals.clicked.dispatch(cp.x, cp.y)\n this.doubleClickPending = true\n this.prevClickCP.copy(cp)\n }\n this.which = undefined\n this.buttons = undefined\n this.pressed = undefined\n // if (this._distance() > 3 || event.which === RightMouseButton) {\n // this.signals.dropped.dispatch();\n // }\n }\n\n _onContextmenu (event: MouseEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n }\n }\n\n _onTouchstart (event: TouchEvent) {\n if (event.target !== this.domElement) {\n return\n }\n event.preventDefault()\n this.pressed = true\n switch (event.touches.length) {\n case 1: {\n this.moving = false\n this.hovering = false\n this.down.set(\n event.touches[ 0 ].pageX,\n event.touches[ 0 ].pageY\n )\n this.position.set(\n event.touches[ 0 ].pageX,\n event.touches[ 0 ].pageY\n )\n this._setCanvasPosition(event.touches[ 0 ])\n break\n }\n\n case 2: {\n this.down.set(\n (event.touches[ 0 ].pageX + event.touches[ 1 ].pageX) / 2,\n (event.touches[ 0 ].pageY + event.touches[ 1 ].pageY) / 2\n )\n this.position.set(\n (event.touches[ 0 ].pageX + event.touches[ 1 ].pageX) / 2,\n (event.touches[ 0 ].pageY + event.touches[ 1 ].pageY) / 2\n )\n this.lastTouchDistance = getTouchDistance(event)\n }\n }\n }\n\n _onTouchend (event: TouchEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n }\n this.which = undefined\n this.buttons = undefined\n this.pressed = undefined\n }\n\n _onTouchmove (event: TouchEvent) {\n if (event.target === this.domElement) {\n event.preventDefault()\n this.overElement = true\n } else {\n this.overElement = false\n }\n switch (event.touches.length) {\n case 1: {\n this._setKeys(event)\n this.which = LeftMouseButton\n this.buttons = 1\n this.moving = true\n this.hovering = false\n this.lastMoved = window.performance.now()\n this.prevPosition.copy(this.position)\n this.position.set(\n event.touches[ 0 ].pageX,\n event.touches[ 0 ].pageY\n )\n this._setCanvasPosition(event.touches[ 0 ])\n const dx = this.prevPosition.x - this.position.x\n const dy = this.prevPosition.y - this.position.y\n this.signals.moved.dispatch(dx, dy)\n if (this.pressed) {\n this.signals.dragged.dispatch(dx, dy)\n }\n break\n }\n\n case 2: {\n const touchDistance = getTouchDistance(event)\n const delta = touchDistance - this.lastTouchDistance\n this.lastTouchDistance = touchDistance\n this.prevPosition.copy(this.position)\n this.position.set(\n (event.touches[ 0 ].pageX + event.touches[ 1 ].pageX) / 2,\n (event.touches[ 0 ].pageY + event.touches[ 1 ].pageY) / 2\n )\n if (Math.abs(delta) > 2 && this.handleScroll &&\n this.position.distanceTo(this.prevPosition) < 2\n ) {\n this.which = 0\n this.buttons = 0\n this.signals.scrolled.dispatch(delta / 2)\n } else {\n this.which = RightMouseButton\n this.buttons = 2\n const dx = this.prevPosition.x - this.position.x\n const dy = this.prevPosition.y - this.position.y\n this.signals.moved.dispatch(dx, dy)\n if (this.pressed) {\n this.signals.dragged.dispatch(dx, dy)\n }\n }\n }\n }\n }\n\n _distance () {\n return this.position.distanceTo(this.down)\n }\n\n _setCanvasPosition (event: any) { // TODO\n const box = this.domElement.getBoundingClientRect()\n let offsetX, offsetY;\n if ('clientX' in event && 'clientY' in event) {\n offsetX = event.clientX - box.left\n offsetY = event.clientY - box.top\n } else {\n offsetX = event.offsetX\n offsetY = event.offsetY\n }\n this.canvasPosition.set(offsetX, box.height - offsetY)\n }\n\n _setKeys (event: MouseEvent|TouchEvent) {\n this.altKey = event.altKey\n this.ctrlKey = event.ctrlKey\n this.metaKey = event.metaKey\n this.shiftKey = event.shiftKey\n }\n\n dispose () {\n document.removeEventListener('mousewheel', this._onMousewheel)\n document.removeEventListener('wheel', this._onMousewheel)\n document.removeEventListener('MozMousePixelScroll', this._onMousewheel)\n document.removeEventListener('mousemove', this._onMousemove)\n document.removeEventListener('mousedown', this._onMousedown)\n document.removeEventListener('mouseup', this._onMouseup)\n document.removeEventListener('contextmenu', this._onContextmenu)\n document.removeEventListener('touchstart', this._onTouchstart)\n document.removeEventListener('touchend', this._onTouchend)\n document.removeEventListener('touchmove', this._onTouchmove)\n window.cancelAnimationFrame(this.frameRequest)\n }\n}\n\nexport default MouseObserver\n","/**\n * @file Constants\n * @author Alexander Rose \n * @private\n */\n\nexport const LeftMouseButton = 1\nexport const MiddleMouseButton = 2\nexport const RightMouseButton = 3\n","/**\n * @file Trackball Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4, Quaternion } from 'three'\n\nimport { defaults } from '../utils'\nimport Stage from '../stage/stage'\nimport MouseObserver from '../stage/mouse-observer'\nimport Viewer from '../viewer/viewer'\nimport ViewerControls from './viewer-controls'\nimport AtomProxy from '../proxy/atom-proxy';\nimport Component from '../component/component';\n\nconst tmpRotateXMatrix = new Matrix4()\nconst tmpRotateYMatrix = new Matrix4()\nconst tmpRotateZMatrix = new Matrix4()\nconst tmpRotateMatrix = new Matrix4()\nconst tmpRotateCameraMatrix = new Matrix4()\nconst tmpRotateVector = new Vector3()\nconst tmpRotateQuaternion = new Quaternion()\nconst tmpRotateQuaternion2 = new Quaternion()\nconst tmpPanMatrix = new Matrix4()\nconst tmpPanVector = new Vector3()\nconst tmpAtomVector = new Vector3()\n\nexport interface TrackballControlsParams {\n rotateSpeed?: number\n zoomSpeed?: number\n panSpeed?: number\n}\n\n/**\n * Trackball controls\n */\nclass TrackballControls {\n viewer: Viewer\n mouse: MouseObserver\n controls: ViewerControls\n\n rotateSpeed: number\n zoomSpeed: number\n panSpeed: number\n\n constructor (readonly stage: Stage, params: TrackballControlsParams = {}) {\n this.rotateSpeed = defaults(params.rotateSpeed, 2.0)\n this.zoomSpeed = defaults(params.zoomSpeed, 1.2)\n this.panSpeed = defaults(params.panSpeed, 1.0)\n\n this.viewer = stage.viewer\n this.mouse = stage.mouseObserver\n this.controls = stage.viewerControls\n }\n\n get component (): Component|undefined {\n return this.stage.transformComponent\n }\n\n get atom (): AtomProxy|undefined {\n return this.stage.transformAtom\n }\n\n private _setPanVector (x: number, y: number, z = 0) {\n const scaleFactor = this.controls.getCanvasScaleFactor(z)\n tmpPanVector.set(x, y, 0)\n tmpPanVector.multiplyScalar(this.panSpeed * scaleFactor)\n }\n\n private _getRotateXY (x: number, y: number) {\n return [\n this.rotateSpeed * -x * 0.01,\n this.rotateSpeed * y * 0.01\n ]\n }\n\n private _getCameraRotation(m: Matrix4) {\n m.extractRotation(this.viewer.camera.matrixWorld)\n m.multiply(tmpRotateYMatrix.makeRotationY(Math.PI))\n\n return m\n }\n\n private _transformPanVector () {\n if (!this.component) return\n\n // Adjust for component and scene rotation\n tmpPanMatrix.extractRotation(this.component.transform)\n tmpPanMatrix.premultiply(this.viewer.rotationGroup.matrix)\n tmpPanMatrix.getInverse(tmpPanMatrix)\n\n // Adjust for camera rotation\n tmpPanMatrix.multiply(this._getCameraRotation(tmpRotateMatrix))\n\n tmpPanVector.applyMatrix4(tmpPanMatrix)\n }\n\n zoom (delta: number) {\n this.controls.zoom(this.zoomSpeed * delta * 0.02)\n }\n\n pan (x: number, y: number) {\n this._setPanVector(x, y)\n\n // Adjust for scene rotation\n tmpPanMatrix.getInverse(this.viewer.rotationGroup.matrix)\n\n // Adjust for camera rotation\n tmpPanMatrix.multiply(this._getCameraRotation(tmpRotateMatrix))\n\n tmpPanVector.applyMatrix4(tmpPanMatrix)\n this.controls.translate(tmpPanVector)\n }\n\n panComponent (x: number, y: number) {\n if (!this.component) return\n\n this._setPanVector(x, y)\n this._transformPanVector()\n\n this.component.position.add(tmpPanVector)\n this.component.updateMatrix()\n }\n\n panAtom (x: number, y: number) {\n if (!this.atom || !this.component) return\n\n this.atom.positionToVector3(tmpAtomVector)\n tmpAtomVector.add(this.viewer.translationGroup.position)\n tmpAtomVector.applyMatrix4(this.viewer.rotationGroup.matrix)\n\n this._setPanVector(x, y, tmpAtomVector.z)\n this._transformPanVector()\n\n this.atom.positionAdd(tmpPanVector)\n this.component.updateRepresentations({ 'position': true })\n }\n\n rotate (x: number, y: number) {\n const [ dx, dy ] = this._getRotateXY(x, y)\n\n // rotate around screen X then screen Y\n this._getCameraRotation(tmpRotateMatrix)\n tmpRotateVector.set(1, 0, 0) // X axis\n tmpRotateVector.applyMatrix4(tmpRotateMatrix) // screen X\n tmpRotateQuaternion.setFromAxisAngle(tmpRotateVector, dy)\n\n tmpRotateVector.set(0, 1, 0) // Y axis\n tmpRotateVector.applyMatrix4(tmpRotateMatrix) // screen Y\n tmpRotateQuaternion2.setFromAxisAngle(tmpRotateVector, dx)\n\n tmpRotateQuaternion.multiply(tmpRotateQuaternion2)\n tmpRotateMatrix.makeRotationFromQuaternion(tmpRotateQuaternion)\n this.controls.applyMatrix(tmpRotateMatrix)\n }\n\n zRotate (x: number, y: number) {\n const dz = this.rotateSpeed * ((-x + y) / -2) * 0.01\n\n tmpRotateZMatrix.makeRotationZ(dz)\n this.controls.applyMatrix(tmpRotateZMatrix)\n }\n\n rotateComponent (x: number, y: number) {\n if (!this.component) return\n\n const [ dx, dy ] = this._getRotateXY(x, y)\n\n this._getCameraRotation(tmpRotateCameraMatrix)\n\n tmpRotateMatrix.extractRotation(this.component.transform)\n tmpRotateMatrix.premultiply(this.viewer.rotationGroup.matrix)\n tmpRotateMatrix.getInverse(tmpRotateMatrix)\n tmpRotateMatrix.premultiply(tmpRotateCameraMatrix)\n\n tmpRotateVector.set(1, 0, 0)\n tmpRotateVector.applyMatrix4(tmpRotateMatrix)\n tmpRotateXMatrix.makeRotationAxis(tmpRotateVector, dy)\n\n tmpRotateVector.set(0, 1, 0)\n tmpRotateVector.applyMatrix4(tmpRotateMatrix)\n tmpRotateYMatrix.makeRotationAxis(tmpRotateVector, dx)\n\n tmpRotateXMatrix.multiply(tmpRotateYMatrix)\n tmpRotateQuaternion.setFromRotationMatrix(tmpRotateXMatrix)\n this.component.quaternion.premultiply(tmpRotateQuaternion)\n this.component.quaternion.normalize()\n this.component.updateMatrix()\n }\n}\n\nexport default TrackballControls\n","/**\n * @file Picking Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4, Vector2 } from 'three'\n\nimport Stage from '../stage/stage'\nimport StructureComponent from '../component/structure-component'\nimport MouseObserver from '../stage/mouse-observer'\nimport { Picker } from '../utils/picker'\nimport ViewerControls from './viewer-controls'\nimport Shape from '../geometry/shape'\nimport Structure from '../structure/structure'\nimport BondProxy from '../proxy/bond-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Surface from '../surface/surface'\nimport Volume from '../surface/volume'\nimport Unitcell from '../symmetry/unitcell'\nimport Component from '../component/component';\n\nconst tmpVec = new Vector3()\n\nexport interface ShapePrimitive {\n name: string\n shape: Shape\n}\n\nfunction closer (x: Vector3, a: Vector3, b: Vector3) {\n return x.distanceTo(a) < x.distanceTo(b)\n}\n\n/**\n * Picking data object.\n * @typedef {Object} PickingData - picking data\n * @property {Number} [pid] - picking id\n * @property {Object} [instance] - instance data\n * @property {Integer} instance.id - instance id\n * @property {String|Integer} instance.name - instance name\n * @property {Matrix4} instance.matrix - transformation matrix of the instance\n * @property {Picker} [picker] - picker object\n */\n\nexport interface InstanceData {\n id: number\n name: number|string\n matrix: Matrix4\n}\n\nexport interface PickingData {\n pid: number\n instance: InstanceData\n picker: Picker\n}\n\n/**\n * Picking proxy class.\n */\nclass PickingProxy {\n pid: number\n picker: Picker\n instance: InstanceData\n controls: ViewerControls\n mouse: MouseObserver\n\n /**\n * Create picking proxy object\n * @param {PickingData} pickingData - picking data\n * @param {Stage} stage - stage object\n */\n constructor (pickingData: PickingData, readonly stage: Stage) {\n this.pid = pickingData.pid\n this.picker = pickingData.picker\n\n /**\n * @type {Object}\n */\n this.instance = pickingData.instance\n\n /**\n * @type {Stage}\n */\n this.stage = stage\n /**\n * @type {ViewerControls}\n */\n this.controls = stage.viewerControls\n /**\n * @type {MouseObserver}\n */\n this.mouse = stage.mouseObserver\n }\n\n /**\n * Kind of the picked data\n * @type {String}\n */\n get type () { return this.picker.type }\n\n /**\n * If the `alt` key was pressed\n * @type {Boolean}\n */\n get altKey () { return this.mouse.altKey }\n /**\n * If the `ctrl` key was pressed\n * @type {Boolean}\n */\n get ctrlKey () { return this.mouse.ctrlKey }\n /**\n * If the `meta` key was pressed\n * @type {Boolean}\n */\n get metaKey () { return this.mouse.metaKey }\n /**\n * If the `shift` key was pressed\n * @type {Boolean}\n */\n get shiftKey () { return this.mouse.shiftKey }\n\n /**\n * Position of the mouse on the canvas\n * @type {Vector2}\n */\n get canvasPosition (): Vector2 { return this.mouse.canvasPosition }\n\n /**\n * The component the picked data is part of\n * @type {Component}\n */\n get component (): Component {\n return this.stage.getComponentsByObject(this.picker.data as any).list[ 0 ] // TODO\n }\n\n /**\n * The picked object data\n * @type {Object}\n */\n get object () {\n return this.picker.getObject(this.pid)\n }\n\n /**\n * The 3d position in the scene of the picked object\n * @type {Vector3}\n */\n get position () {\n return this.picker.getPosition(this.pid, this.instance, this.component)\n }\n\n /**\n * The atom of a picked bond that is closest to the mouse\n * @type {AtomProxy}\n */\n get closestBondAtom (): AtomProxy|undefined {\n if (this.type !== 'bond' || !this.bond) return undefined\n\n const bond = this.bond\n const controls = this.controls\n const cp = this.canvasPosition\n\n const v1 = bond.atom1.positionToVector3()\n const v2 = bond.atom2.positionToVector3()\n\n v1.applyMatrix4(this.component.matrix)\n v2.applyMatrix4(this.component.matrix)\n\n const acp1 = controls.getPositionOnCanvas(v1)\n const acp2 = controls.getPositionOnCanvas(v2)\n\n return closer(cp as any, acp1, acp2) ? bond.atom1 : bond.atom2\n }\n\n /**\n * Close-by atom\n * @type {AtomProxy}\n */\n get closeAtom (): AtomProxy|undefined {\n const cp = this.canvasPosition\n const ca = this.closestBondAtom\n if (!ca) return undefined\n\n const v = ca.positionToVector3().applyMatrix4(this.component.matrix)\n\n const acp = this.controls.getPositionOnCanvas(v)\n\n ca.positionToVector3(tmpVec)\n if (this.instance) tmpVec.applyMatrix4(this.instance.matrix)\n tmpVec.applyMatrix4(this.component.matrix)\n const viewer = this.controls.viewer\n tmpVec.add(viewer.translationGroup.position)\n tmpVec.applyMatrix4(viewer.rotationGroup.matrix)\n\n const scaleFactor = this.controls.getCanvasScaleFactor(tmpVec.z)\n const sc = this.component as StructureComponent\n const radius = sc.getMaxRepresentationRadius(ca.index)\n //console.log(scaleFactor, cp.distanceTo(acp), radius/scaleFactor, radius)\n\n if (cp.distanceTo(acp) <= radius/scaleFactor) {\n return ca\n } else {\n return undefined\n }\n }\n\n /**\n * @type {Object}\n */\n get arrow () { return this._objectIfType('arrow') as ShapePrimitive }\n /**\n * @type {AtomProxy}\n */\n get atom () { return this._objectIfType('atom') as AtomProxy }\n /**\n * @type {Object}\n */\n get axes () { return this._objectIfType('axes') }\n /**\n * @type {BondProxy}\n */\n get bond () { return this._objectIfType('bond') as BondProxy }\n /**\n * @type {Object}\n */\n get box () { return this._objectIfType('box') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get cone () { return this._objectIfType('cone') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get clash () { return this._objectIfType('clash') as { clash: { sele1: string, sele2: string } } }\n /**\n * @type {BondProxy}\n */\n get contact () { return this._objectIfType('contact') as { type: string, atom1: AtomProxy, atom2: AtomProxy } }\n /**\n * @type {Object}\n */\n get cylinder () { return this._objectIfType('cylinder') as ShapePrimitive }\n /**\n * @type {BondProxy}\n */\n get distance () { return this._objectIfType('distance') as BondProxy }\n /**\n * @type {Object}\n */\n get ellipsoid () { return this._objectIfType('ellipsoid') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get octahedron () { return this._objectIfType('octahedron') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get point () { return this._objectIfType('point') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get mesh () { return this._objectIfType('mesh') as { name: string, shape: Shape, serial: number } }\n /**\n * @type {Object}\n */\n get slice () { return this._objectIfType('slice') as { volume: Volume, value: number } }\n /**\n * @type {Object}\n */\n get sphere () { return this._objectIfType('sphere') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get tetrahedron () { return this._objectIfType('tetrahedron') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get torus () { return this._objectIfType('torus') as ShapePrimitive }\n /**\n * @type {Object}\n */\n get surface () { return this._objectIfType('surface') as { surface: Surface, index: number } }\n /**\n * @type {Object}\n */\n get unitcell () { return this._objectIfType('unitcell') as { unitcell: Unitcell, structure: Structure } }\n /**\n * @type {Object}\n */\n get unknown () { return this._objectIfType('unknown') }\n /**\n * @type {Object}\n */\n get volume () { return this._objectIfType('volume') as { volume: Volume, value: number } }\n /**\n * @type {Object}\n */\n get wideline () { return this._objectIfType('wideline') as ShapePrimitive }\n\n _objectIfType (type: string) {\n return this.type === type ? this.object : undefined\n }\n\n getLabel () {\n const atom = this.atom || this.closeAtom\n let msg = 'nothing'\n if (this.arrow) {\n msg = this.arrow.name\n } else if (atom) {\n msg = `atom: ${atom.qualifiedName()} (${atom.structure.name})`\n } else if (this.axes) {\n msg = 'axes'\n } else if (this.bond) {\n msg = `bond: ${this.bond.atom1.qualifiedName()} - ${this.bond.atom2.qualifiedName()} (${this.bond.structure.name})`\n } else if (this.box) {\n msg = this.box.name\n } else if (this.cone) {\n msg = this.cone.name\n } else if (this.clash) {\n msg = `clash: ${this.clash.clash.sele1} - ${this.clash.clash.sele2}`\n } else if (this.contact) {\n msg = `${this.contact.type}: ${this.contact.atom1.qualifiedName()} - ${this.contact.atom2.qualifiedName()} (${this.contact.atom1.structure.name})`\n } else if (this.cylinder) {\n msg = this.cylinder.name\n } else if (this.distance) {\n msg = `distance: ${this.distance.atom1.qualifiedName()} - ${this.distance.atom2.qualifiedName()} (${this.distance.structure.name})`\n } else if (this.ellipsoid) {\n msg = this.ellipsoid.name\n } else if (this.octahedron) {\n msg = this.octahedron.name\n } else if (this.point) {\n msg = this.point.name\n } else if (this.mesh) {\n msg = `mesh: ${this.mesh.name || this.mesh.serial} (${this.mesh.shape.name})`\n } else if (this.slice) {\n msg = `slice: ${this.slice.value.toPrecision(3)} (${this.slice.volume.name})`\n } else if (this.sphere) {\n msg = this.sphere.name\n } else if (this.surface) {\n msg = `surface: ${this.surface.surface.name}`\n } else if (this.tetrahedron) {\n msg = this.tetrahedron.name\n } else if (this.torus) {\n msg = this.torus.name\n } else if (this.unitcell) {\n msg = `unitcell: ${this.unitcell.unitcell.spacegroup} (${this.unitcell.structure.name})`\n } else if (this.unknown) {\n msg = 'unknown'\n } else if (this.volume) {\n msg = `volume: ${this.volume.value.toPrecision(3)} (${this.volume.volume.name})`\n } else if (this.wideline) {\n msg = this.wideline.name\n }\n return msg\n }\n}\n\nexport default PickingProxy\n","/**\n * @file Picking Controls\n * @author Alexander Rose \n * @private\n */\n\nimport PickingProxy from './picking-proxy'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\n\n/**\n * Picking controls\n */\nclass PickingControls {\n viewer: Viewer\n\n constructor (readonly stage: Stage) {\n this.viewer = stage.viewer\n }\n\n /**\n * get picking data\n * @param {Number} x - canvas x coordinate\n * @param {Number} y - canvas y coordinate\n * @return {PickingProxy|undefined} picking proxy\n */\n pick (x: number, y: number) {\n const pickingData = this.viewer.pick(x, y)\n\n if (pickingData.picker &&\n pickingData.picker.type !== 'ignore' &&\n pickingData.pid !== undefined\n ) {\n const pickerArray = pickingData.picker.array\n if (pickerArray && pickingData.pid >= pickerArray.length) {\n console.error('pid >= picker.array.length')\n } else {\n return new PickingProxy(pickingData, this.stage)\n }\n }\n }\n}\n\nexport default PickingControls\n","/**\n * @file Viewer Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector2, Vector3, Matrix4, Quaternion, OrthographicCamera } from 'three'\nimport * as signalsWrapper from 'signals'\n\nimport {\n ensureVector2, ensureVector3, ensureMatrix4, ensureQuaternion\n} from '../utils'\nimport { degToRad } from '../math/math-utils'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\n\n/**\n * Orientation matrix, a 4x4 transformation matrix with rotation part\n * used for scene rotation, scale part for scene camera distance and\n * position part for scene translation\n * @typedef {Matrix4} OrientationMatrix - orientation matrix\n */\n\nconst tmpQ = new Quaternion()\nconst tmpP = new Vector3()\nconst tmpS = new Vector3()\n\nconst tmpCanvasVector = new Vector3()\nconst tmpScaleVector = new Vector3()\nconst tmpRotateMatrix = new Matrix4()\nconst tmpRotateVector = new Vector3()\nconst tmpAlignMatrix = new Matrix4()\n\n/**\n * Viewer controls\n */\nclass ViewerControls {\n signals = {\n changed: new signalsWrapper.Signal()\n }\n\n viewer: Viewer\n\n /**\n * @param {Stage} stage - the stage object\n */\n constructor (readonly stage: Stage) {\n this.viewer = stage.viewer\n }\n\n /**\n * scene center position\n * @type {Vector3}\n */\n get position () {\n return this.viewer.translationGroup.position\n }\n\n /**\n * scene rotation\n * @type {Quaternion}\n */\n get rotation () {\n return this.viewer.rotationGroup.quaternion\n }\n\n /**\n * Trigger render and emit changed event\n * @emits {ViewerControls.signals.changed}\n * @return {undefined}\n */\n changed () {\n this.viewer.requestRender()\n this.signals.changed.dispatch()\n }\n\n getPositionOnCanvas (position: Vector3, optionalTarget?: Vector2) {\n const canvasPosition = ensureVector2(optionalTarget)\n const viewer = this.viewer\n\n tmpCanvasVector.copy(position)\n .add(viewer.translationGroup.position)\n .applyMatrix4(viewer.rotationGroup.matrix)\n .project(viewer.camera)\n\n return canvasPosition.set(\n (tmpCanvasVector.x + 1) * viewer.width / 2,\n (tmpCanvasVector.y + 1) * viewer.height / 2\n )\n }\n\n getCanvasScaleFactor (z = 0) {\n const camera = this.viewer.camera\n if (camera instanceof OrthographicCamera) {\n return 1 / camera.zoom\n } else {\n z = Math.abs(z)\n z += this.getCameraDistance()\n const fov = degToRad(camera.fov)\n const unitHeight = 2.0 * z * Math.tan(fov / 2)\n return unitHeight / this.viewer.height\n }\n }\n\n /**\n * get scene orientation\n * @param {Matrix4} optionalTarget - pre-allocated target matrix\n * @return {OrientationMatrix} scene orientation\n */\n getOrientation (optionalTarget?: Matrix4) {\n const m = ensureMatrix4(optionalTarget)\n\n m.copy(this.viewer.rotationGroup.matrix)\n const z = this.getCameraDistance()\n m.scale(tmpScaleVector.set(z, z, z))\n m.setPosition(this.viewer.translationGroup.position)\n\n return m\n }\n\n /**\n * set scene orientation\n * @param {OrientationMatrix|Array} orientation - scene orientation\n * @return {undefined}\n */\n orient (orientation?: Matrix4) {\n ensureMatrix4(orientation).decompose(tmpP, tmpQ, tmpS)\n\n const v = this.viewer\n v.rotationGroup.setRotationFromQuaternion(tmpQ)\n v.translationGroup.position.copy(tmpP)\n v.cameraDistance = tmpS.z\n v.updateZoom()\n this.changed()\n }\n\n /**\n * translate scene\n * @param {Vector3|Array} vector - translation vector\n * @return {undefined}\n */\n translate (vector: Vector3|number[]) {\n this.viewer.translationGroup.position\n .add(ensureVector3(vector))\n this.changed()\n }\n\n /**\n * center scene\n * @param {Vector3|Array} position - center position\n * @return {undefined}\n */\n center (position: Vector3|number[]) {\n this.viewer.translationGroup.position\n .copy(ensureVector3(position)).negate()\n this.changed()\n }\n\n /**\n * \"zoom\" scene by moving camera closer to origin\n * @param {Number} delta - zoom change\n * @return {undefined}\n */\n zoom (delta: number) {\n this.distance(this.getCameraDistance() * (1 - delta))\n }\n\n /**\n * get camera distance\n */\n getCameraDistance(): number {\n return this.viewer.cameraDistance\n }\n\n /**\n * camera distance\n * @param {Number} z - distance\n * @return {undefined}\n */\n distance (distance: number) {\n // Math.abs because distance used to be \"z\", normally negative.\n // Math.max to prevent us from getting _too_ close.\n this.viewer.cameraDistance = Math.max(Math.abs(distance), 0.2)\n this.viewer.updateZoom()\n this.changed()\n }\n\n /**\n * spin scene on axis\n * @param {Vector3|Array} axis - rotation axis\n * @param {Number} angle - amount to spin\n * @return {undefined}\n */\n spin (axis: Vector3|number[], angle: number) {\n tmpRotateMatrix.getInverse(this.viewer.rotationGroup.matrix)\n tmpRotateVector\n .copy(ensureVector3(axis)).applyMatrix4(tmpRotateMatrix)\n\n this.viewer.rotationGroup.rotateOnAxis(tmpRotateVector, angle)\n this.changed()\n }\n\n /**\n * rotate scene\n * @param {Quaternion|Array} quaternion - rotation quaternion\n * @return {undefined}\n */\n rotate (quaternion: Quaternion|number[]) {\n this.viewer.rotationGroup\n .setRotationFromQuaternion(ensureQuaternion(quaternion))\n this.changed()\n }\n\n /**\n * align scene to basis matrix\n * @param {Matrix4|Array} basis - basis matrix\n * @return {undefined}\n */\n align (basis: Matrix4|number[]) {\n tmpAlignMatrix.getInverse(ensureMatrix4(basis))\n\n this.viewer.rotationGroup.setRotationFromMatrix(tmpAlignMatrix)\n this.changed()\n }\n\n /**\n * apply rotation matrix to scene\n * @param {Matrix4|Array} matrix - rotation matrix\n * @return {undefined}\n */\n applyMatrix (matrix: Matrix4|number[]) {\n this.viewer.rotationGroup.applyMatrix4(ensureMatrix4(matrix))\n this.changed()\n }\n}\n\nexport default ViewerControls\n","/**\n * @file Animation\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Quaternion } from 'three'\n\nimport { defaults, ensureVector3, ensureQuaternion } from '../utils'\nimport { lerp, smoothstep } from '../math/math-utils'\nimport ViewerControls from '../controls/viewer-controls'\nimport Stats from '../viewer/stats'\n\n/**\n * Animation. Base animation class.\n * @interface\n */\nabstract class Animation {\n duration: number\n controls: ViewerControls\n\n alpha: number\n startTime: number\n\n pausedTime = -1\n elapsedDuration = 0\n pausedDuration = 0\n ignoreGlobalToggle = false\n\n private _paused = false\n private _resolveList: Function[] = []\n private _hold: boolean\n\n constructor (duration: number|undefined, controls: ViewerControls, ...args: any[]) {\n this.duration = defaults(duration, 1000)\n this.controls = controls\n\n this.startTime = window.performance.now()\n\n this._init(...args)\n }\n\n /**\n * True when animation has finished\n */\n get done () {\n return this.alpha === 1\n }\n\n /**\n * True when animation is paused\n */\n get paused () {\n return this._paused\n }\n\n /**\n * init animation\n */\n abstract _init (...args: any[]): void\n\n /**\n * called on every tick\n */\n abstract _tick (stats?: Stats): void\n\n tick (stats: Stats) {\n if (this._paused) return\n\n this.elapsedDuration = stats.currentTime - this.startTime - this.pausedDuration\n\n if (this.duration === 0) {\n this.alpha = 1\n } else {\n this.alpha = smoothstep(0, 1, this.elapsedDuration / this.duration)\n }\n\n this._tick(stats)\n\n if (this.done) {\n this._resolveList.forEach(resolve => resolve())\n }\n\n return this.done\n }\n\n /**\n * Pause animation\n * @param {boolean} [hold] - put animation on a hold which\n * must be release before it can be resumed\n */\n pause (hold?: boolean) {\n if (hold) this._hold = true\n\n if (this.pausedTime === -1) {\n this.pausedTime = window.performance.now()\n }\n this._paused = true\n }\n\n /**\n * Resume animation\n * @param {Boolean} [releaseHold] - release a hold on the animation\n */\n resume (releaseHold?: boolean) {\n if (!releaseHold && this._hold) return\n\n this.pausedDuration += window.performance.now() - this.pausedTime\n this._paused = false\n this._hold = false\n this.pausedTime = -1\n }\n\n /**\n * Toggle animation\n */\n toggle () {\n if (this._paused) {\n this.resume()\n } else {\n this.pause()\n }\n }\n\n /**\n * Promise-like interface\n */\n then (callback: Function) {\n let p: Promise\n\n if (this.done) {\n p = Promise.resolve()\n } else {\n p = new Promise(resolve => this._resolveList.push(resolve))\n }\n\n return p.then(callback as any)\n }\n}\n\nexport default Animation\n\n/**\n * Spin animation. Spin around an axis.\n */\nexport class SpinAnimation extends Animation {\n axis: Vector3\n angle: number\n\n constructor (duration: number|undefined, controls: ViewerControls, ...args: any[]) {\n super(defaults(duration, Infinity), controls, ...args)\n }\n\n _init (axis: number[]|Vector3, angle: number) {\n if (Array.isArray(axis)) {\n this.axis = new Vector3().fromArray(axis)\n } else {\n this.axis = defaults(axis, new Vector3(0, 1, 0))\n }\n this.angle = defaults(angle, 0.01)\n }\n\n _tick (stats: Stats) {\n if (!this.axis || !this.angle) return\n\n this.controls.spin(\n this.axis, this.angle * stats.lastDuration / 16\n )\n }\n}\n\n/**\n * Rock animation. Rock around an axis.\n */\nexport class RockAnimation extends Animation {\n axis: Vector3\n angleStep: number\n angleEnd: number\n angleSum = 0\n direction = 1\n\n constructor (duration: number|undefined, controls: ViewerControls, ...args: any[]) {\n super(defaults(duration, Infinity), controls, ...args)\n }\n\n _init (axis: number[]|Vector3, angleStep: number, angleEnd: number) {\n if (Array.isArray(axis)) {\n this.axis = new Vector3().fromArray(axis)\n } else {\n this.axis = defaults(axis, new Vector3(0, 1, 0))\n }\n this.angleStep = defaults(angleStep, 0.01)\n this.angleEnd = defaults(angleEnd, 0.2)\n }\n\n _tick (stats: Stats) {\n if (!this.axis || !this.angleStep || !this.angleEnd) return\n\n const alpha = smoothstep(\n 0, 1, Math.abs(this.angleSum) / this.angleEnd\n )\n const angle = this.angleStep * this.direction * (1.1 - alpha)\n\n this.controls.spin(\n this.axis, angle * stats.lastDuration / 16\n )\n\n this.angleSum += this.angleStep\n\n if (this.angleSum >= this.angleEnd) {\n this.direction *= -1\n this.angleSum = -this.angleEnd\n }\n }\n}\n\n/**\n * Move animation. Move from one position to another.\n */\nexport class MoveAnimation extends Animation {\n moveFrom: Vector3\n moveTo: Vector3\n\n _init (moveFrom: number[]|Vector3, moveTo: number[]|Vector3) {\n this.moveFrom = ensureVector3(defaults(moveFrom, new Vector3()))\n this.moveTo = ensureVector3(defaults(moveTo, new Vector3()))\n }\n\n _tick (/* stats */) {\n this.controls.position.lerpVectors(\n this.moveFrom, this.moveTo, this.alpha\n ).negate()\n this.controls.changed()\n }\n}\n\n/**\n * Zoom animation. Gradually change the zoom level.\n */\nexport class ZoomAnimation extends Animation {\n zoomFrom: number\n zoomTo: number\n\n _init (zoomFrom: number, zoomTo: number) {\n this.zoomFrom = zoomFrom\n this.zoomTo = zoomTo\n }\n\n _tick () {\n this.controls.distance(lerp(this.zoomFrom, this.zoomTo, this.alpha))\n }\n}\n\n/**\n * Rotate animation. Rotate from one orientation to another.\n */\nexport class RotateAnimation extends Animation {\n rotateFrom: Quaternion\n rotateTo: Quaternion\n\n private _currentRotation = new Quaternion()\n\n _init (rotateFrom: number[]|Quaternion, rotateTo: number[]|Quaternion) {\n this.rotateFrom = ensureQuaternion(rotateFrom)\n this.rotateTo = ensureQuaternion(rotateTo)\n\n this._currentRotation = new Quaternion()\n }\n\n _tick () {\n this._currentRotation\n .copy(this.rotateFrom)\n .slerp(this.rotateTo, this.alpha)\n\n this.controls.rotate(this._currentRotation)\n }\n}\n\n/**\n * Value animation. Call callback with interpolated value.\n */\nexport class ValueAnimation extends Animation {\n valueFrom: number\n valueTo: number\n callback: Function\n\n _init (valueFrom: number, valueTo: number, callback: Function) {\n this.valueFrom = valueFrom\n this.valueTo = valueTo\n\n this.callback = callback\n }\n\n _tick (/* stats */) {\n this.callback(lerp(this.valueFrom, this.valueTo, this.alpha))\n }\n}\n\n/**\n * Timeout animation. Call callback after duration.\n */\nexport class TimeoutAnimation extends Animation {\n callback: Function\n\n _init (callback: Function) {\n this.callback = callback\n }\n\n _tick () {\n if (this.alpha === 1) this.callback()\n }\n}\n\n/**\n * Animation list.\n */\nexport class AnimationList {\n _list: Animation[]\n _resolveList: Function[] = []\n\n constructor (list: Animation[] = []) {\n this._list = list\n }\n\n /**\n * True when all animations have finished\n */\n get done () {\n return this._list.every(animation => {\n return animation.done\n })\n }\n\n /**\n * Promise-like interface\n */\n then (callback: Function) {\n let p: Promise\n\n if (this.done) {\n p = Promise.resolve()\n } else {\n p = new Promise(resolve => {\n this._resolveList.push(resolve)\n this._list.forEach(animation => {\n animation.then(() => {\n this._resolveList.forEach(callback => {\n callback()\n })\n this._resolveList.length = 0\n })\n })\n })\n }\n\n return p.then(callback as any)\n }\n}\n","/**\n * @file Animation Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Quaternion, Matrix4 } from 'three'\n\nimport { ensureMatrix4 } from '../utils'\nimport Animation, {\n SpinAnimation, RockAnimation, MoveAnimation, ZoomAnimation,\n RotateAnimation, ValueAnimation, TimeoutAnimation, AnimationList\n} from '../animation/animation'\nimport Stage from '../stage/stage'\nimport Component from '../component/component'\nimport Viewer from '../viewer/viewer'\nimport Stats from '../viewer/stats'\nimport ViewerControls from './viewer-controls'\n\n/**\n * Animation controls\n */\nclass AnimationControls {\n viewer: Viewer\n controls: ViewerControls\n\n animationList: Animation[] = []\n finishedList: Animation[] = []\n\n /**\n * Create animation controls\n * @param {Stage} stage - the stage object\n */\n constructor (readonly stage: Stage) {\n this.viewer = stage.viewer\n this.controls = stage.viewerControls\n }\n\n /**\n * True when all animations are paused\n * @type {Boolean}\n */\n get paused () {\n return this.animationList.every((animation: Animation) => animation.paused)\n }\n\n /**\n * Add an animation\n */\n add (animation: Animation) {\n if (animation.duration === 0) {\n animation.tick(this.viewer.stats)\n } else {\n this.animationList.push(animation)\n }\n\n return animation\n }\n\n /**\n * Remove an animation\n */\n remove (animation: Animation) {\n const list = this.animationList\n const index = list.indexOf(animation)\n\n if (index > -1) {\n list.splice(index, 1)\n }\n }\n\n /**\n * Run all animations\n */\n run (stats: Stats) {\n const finishedList = this.finishedList\n const animationList = this.animationList\n\n const n = animationList.length\n for (let i = 0; i < n; ++i) {\n const animation = animationList[ i ]\n // tick returns true when finished\n if (animation.tick(stats)) {\n finishedList.push(animation)\n }\n }\n\n const m = finishedList.length\n if (m) {\n for (let j = 0; j < m; ++j) {\n this.remove(finishedList[ j ])\n }\n finishedList.length = 0\n }\n }\n\n /**\n * Add a spin animation\n * @param {Vector3} axis - axis to spin around\n * @param {Number} angle - amount to spin per frame, radians\n * @param {Number} duration - animation time in milliseconds\n * @return {SpinAnimation} the animation\n */\n spin (axis: Vector3|number[], angle?: number, duration?: number) {\n return this.add(\n new SpinAnimation(duration, this.controls, axis, angle)\n )\n }\n\n /**\n * Add a rock animation\n * @param {Vector3} axis - axis to rock around\n * @param {Number} angle - amount to spin per frame, radians\n * @param {Number} end - maximum extend of motion, radians\n * @param {Number} duration - animation time in milliseconds\n * @return {SpinAnimation} the animation\n */\n rock (axis: Vector3|number[], angle?: number, end?: number, duration?: number) {\n return this.add(\n new RockAnimation(duration, this.controls, axis, angle, end)\n )\n }\n\n /**\n * Add a rotate animation\n * @param {Quaternion} rotateTo - target rotation\n * @param {Number} duration - animation time in milliseconds\n * @return {RotateAnimation} the animation\n */\n rotate (rotateTo: Quaternion|number[], duration?: number) {\n const rotateFrom = this.viewer.rotationGroup.quaternion.clone()\n\n return this.add(\n new RotateAnimation(duration, this.controls, rotateFrom, rotateTo)\n )\n }\n\n /**\n * Add a move animation\n * @param {Vector3} moveTo - target position\n * @param {Number} duration - animation time in milliseconds\n * @return {MoveAnimation} the animation\n */\n move (moveTo: Vector3|number[], duration?: number) {\n const moveFrom = this.controls.position.clone().negate()\n\n return this.add(\n new MoveAnimation(duration, this.controls, moveFrom, moveTo)\n )\n }\n\n /**\n * Add a zoom animation\n * @param {Number} zoomTo - target distance\n * @param {Number} duration - animation time in milliseconds\n * @return {ZoomAnimation} the animation\n */\n zoom (zoomTo: number, duration?: number) {\n const zoomFrom = this.viewer.camera.position.z\n\n return this.add(\n new ZoomAnimation(duration, this.controls, zoomFrom, zoomTo)\n )\n }\n\n /**\n * Add a zoom and a move animation\n * @param {Vector3} moveTo - target position\n * @param {Number} zoomTo - target distance\n * @param {Number} duration - animation time in milliseconds\n * @return {Array} the animations\n */\n zoomMove (moveTo: Vector3, zoomTo: number, duration?: number) {\n return new AnimationList([\n this.move(moveTo, duration),\n this.zoom(zoomTo, duration)\n ])\n }\n\n /**\n * Add an orient animation\n * @param {OrientationMatrix|Array} orientTo - target orientation\n * @param {Number} duration - animation time in milliseconds\n * @return {Array} the animations\n */\n orient (orientTo: Matrix4|number[], duration?: number) {\n const p = new Vector3()\n const q = new Quaternion()\n const s = new Vector3()\n\n ensureMatrix4(orientTo).decompose(p, q, s)\n\n return new AnimationList([\n this.move(p.negate(), duration),\n this.rotate(q, duration),\n this.zoom(-s.x, duration)\n ])\n }\n\n /**\n * Add a value animation\n * @param {Number} valueFrom - start value\n * @param {Number} valueTo - target value\n * @param {Function} callback - called on every tick\n * @param {Number} duration - animation time in milliseconds\n * @return {ValueAnimation} the animation\n */\n value (valueFrom: number, valueTo: number, callback: Function, duration?: number) {\n return this.add(\n new ValueAnimation(duration, this.controls, valueFrom, valueTo, callback)\n )\n }\n\n /**\n * Add a timeout animation\n * @param {Function} callback - called after duration\n * @param {Number} duration - timeout in milliseconds\n * @return {TimeoutAnimation} the animation\n */\n timeout (callback: Function, duration?: number) {\n return this.add(\n new TimeoutAnimation(duration, this.controls, callback)\n )\n }\n\n /**\n * Add a component spin animation\n * @param {Component} component - object to move\n * @param {Vector3} axis - axis to spin around\n * @param {Number} angle - amount to spin per frame, radians\n * @param {Number} duration - animation time in milliseconds\n * @return {SpinAnimation} the animation\n */\n spinComponent (component: Component, axis?: Vector3|number[], angle?: number, duration?: number) {\n return this.add(\n // TODO\n new SpinAnimation(duration, component.controls as any, axis, angle)\n )\n }\n\n /**\n * Add a component rock animation\n * @param {Component} component - object to move\n * @param {Vector3} axis - axis to rock around\n * @param {Number} angle - amount to spin per frame, radians\n * @param {Number} end - maximum extend of motion, radians\n * @param {Number} duration - animation time in milliseconds\n * @return {SpinAnimation} the animation\n */\n rockComponent (component: Component, axis: Vector3|number[], angle?: number, end?: number, duration?: number) {\n return this.add(\n // TODO\n new RockAnimation(duration, component.controls as any, axis, angle, end)\n )\n }\n\n /**\n * Add a component move animation\n * @param {Component} component - object to move\n * @param {Vector3} moveTo - target position\n * @param {Number} duration - animation time in milliseconds\n * @return {MoveAnimation} the animation\n */\n moveComponent (component: Component, moveTo: Vector3|number[], duration?: number) {\n const moveFrom = component.controls.position.clone().negate()\n\n return this.add(\n // TODO\n new MoveAnimation(duration, component.controls as any, moveFrom, moveTo)\n )\n }\n\n /**\n * Pause all animations\n * @return {undefined}\n */\n pause () {\n this.animationList.forEach(animation => animation.pause())\n }\n\n /**\n * Resume all animations\n * @return {undefined}\n */\n resume () {\n this.animationList.forEach(animation => animation.resume())\n }\n\n /**\n * Toggle all animations\n * @return {undefined}\n */\n toggle () {\n if (this.paused) {\n this.resume()\n } else {\n this.pause()\n }\n }\n\n /**\n * Clear all animations\n * @return {undefined}\n */\n clear () {\n this.animationList.length = 0\n }\n\n dispose () {\n this.clear()\n }\n}\n\nexport default AnimationControls\n","/**\n * @file Queue\n * @author Alexander Rose \n * @private\n */\n\nclass Queue {\n queue: T[] = []\n pending = false\n\n constructor(readonly fn: Function, argList?: T[]) {\n this.next = this.next.bind(this)\n\n if (argList) {\n for (let i = 0, il = argList.length; i < il; ++i) {\n this.queue.push(argList[ i ])\n }\n this.next()\n }\n }\n\n private run (arg: any) {\n this.fn(arg, this.next)\n }\n\n private next () {\n const arg = this.queue.shift()\n if (arg !== undefined) {\n this.pending = true\n setTimeout(() => this.run(arg))\n } else {\n this.pending = false\n }\n }\n\n push (arg: T) {\n this.queue.push(arg)\n if (!this.pending) this.next()\n }\n\n kill () {\n this.queue.length = 0\n }\n\n length () {\n return this.queue.length\n }\n}\n\nexport default Queue\n","/**\n * @file Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { Color, Vector3, Matrix4 } from 'three'\n\nimport { Debug, Log, ColormakerRegistry, ExtensionFragDepth } from '../globals'\nimport { defaults } from '../utils'\nimport Queue from '../utils/queue'\nimport Counter from '../utils/counter'\nimport Viewer from '../viewer/viewer'\nimport { BufferParameters, BufferSide, default as Buffer } from '../buffer/buffer';\nimport { ColorData, ColormakerParameters, ColorMode } from '../color/colormaker';\nimport { GenericColor } from '../types'\n\nexport interface RepresentationParameters {\n name: string\n lazy: boolean,\n clipNear: number,\n clipRadius: number,\n clipCenter: Vector3,\n flatShaded: boolean,\n opacity: number,\n depthWrite: boolean,\n side: BufferSide,\n wireframe: boolean,\n colorData: ColorData,\n colorScheme: string,\n colorScale: string | number[],\n colorReverse: boolean,\n colorValue: GenericColor,\n colorDomain: number[],\n colorMode: ColorMode,\n colorSpace: 'sRGB' | 'linear',\n roughness: number,\n metalness: number,\n diffuse: GenericColor,\n diffuseInterior: boolean,\n useInteriorColor: boolean,\n interiorColor: GenericColor,\n interiorDarkening: number,\n disablePicking: boolean,\n matrix: Matrix4\n quality: string,\n visible: boolean,\n color: GenericColor,\n sphereDetail: number,\n radialSegments: number,\n openEnded: boolean\n disableImpostor: boolean\n [key: string]: any//boolean | number | undefined | Color | string | Vector3 | Matrix4 | number[]\n}\n/**\n * Representation parameter object.\n * @typedef {Object} RepresentationParameters - representation parameters\n * @property {Boolean} [lazy] - only build & update the representation when visible\n * otherwise defer changes until set visible again\n * @property {Integer} [clipNear] - position of camera near/front clipping plane\n * in percent of scene bounding box\n * @property {Integer} [clipRadius] - radius of clipping sphere\n * @property {Vector3} [clipCenter] - position of for spherical clipping\n * @property {Boolean} [flatShaded] - render flat shaded\n * @property {Float} [opacity] - translucency: 1 is fully opaque, 0 is fully transparent\n * @property {Boolean} [depthWrite] - depth write\n * @property {String} [side] - which triangle sides to render, \"front\" front-side,\n * \"back\" back-side, \"double\" front- and back-side\n * @property {Boolean} [wireframe] - render as wireframe\n * @property {ColorData} [colorData] - atom or bond indexed data for coloring\n * @property {String} [colorScheme] - color scheme\n * @property {String} [colorScale] - color scale, either a string for a\n * predefined scale or an array of\n * colors to be used as the scale\n * @property {Boolean} [colorReverse] - reverse color scale\n * @property {Color} [colorValue] - color value\n * @property {Integer[]} [colorDomain] - scale value range\n * @property {Integer} colorDomain.0 - min value\n * @property {Integer} colorDomain.1 - max value\n * @property {String} [colorMode] - color mode, one of rgb, hsv, hsl, hsi, lab, hcl\n * @property {Float} [roughness] - how rough the material is, between 0 and 1\n * @property {Float} [metalness] - how metallic the material is, between 0 and 1\n * @property {Color} [diffuse] - diffuse color for lighting\n * @property {Boolean} [diffuseInterior] - diffuse interior, i.e. ignore normal\n * @property {Boolean} [useInteriorColor] - use interior color\n * @property {Color} [interiorColor] - interior color\n * @property {Float} [interiorDarkening] - interior darkening: 0 no darking, 1 fully darkened\n * @property {Boolean} [disablePicking] - disable picking\n */\n\n/**\n * Representation object\n * @interface\n * @param {Object} object - the object to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {RepresentationParameters} [params] - representation parameters\n */\nclass Representation {\n parameters: any\n type: string\n viewer: Viewer\n tasks: Counter\n private queue: Queue\n bufferList: Buffer[]\n\n lazy: boolean\n lazyProps: { build: boolean, bufferParams: BufferParameters | {}, what: {}}\n protected name: string\n protected clipNear: number\n protected clipRadius: number\n protected clipCenter: Vector3\n protected flatShaded: boolean\n protected opacity: number\n protected depthWrite: boolean\n protected side: BufferSide\n protected wireframe: boolean\n protected colorData: ColorData\n protected colorScheme: string\n protected colorScale: string | string[]\n protected colorReverse: boolean\n protected colorValue: number\n protected colorDomain: number[]\n protected colorMode: ColorMode\n protected roughness: number\n protected metalness: number\n protected diffuse: GenericColor\n protected diffuseInterior?: boolean\n protected useInteriorColor?: boolean\n protected interiorColor: GenericColor\n protected interiorDarkening: number\n protected disablePicking: boolean\n protected sphereDetail: number\n protected radialSegments: number\n protected openEnded: boolean\n protected disableImpostor: boolean\n protected disposed: boolean\n\n protected matrix: Matrix4\n\n private quality: string\n visible: boolean\n\n protected manualAttach: ()=> any\n\n protected toBePrepared: boolean\n\n [key: string]: any\n\n constructor (object: any, viewer: Viewer, params: Partial) {\n // eslint-disable-next-line no-unused-vars\n // const p = params || {}\n\n this.type = ''\n\n this.parameters = {\n\n lazy: {\n type: 'boolean'\n },\n\n clipNear: {\n type: 'range', step: 1, max: 100, min: 0, buffer: true\n },\n clipRadius: {\n type: 'number', precision: 1, max: 1000, min: 0, buffer: true\n },\n clipCenter: {\n type: 'vector3', precision: 1, buffer: true\n },\n flatShaded: {\n type: 'boolean', buffer: true\n },\n opacity: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n depthWrite: {\n type: 'boolean', buffer: true\n },\n side: {\n type: 'select',\n buffer: true,\n options: { front: 'front', back: 'back', double: 'double' }\n },\n wireframe: {\n type: 'boolean', buffer: true\n },\n\n colorData: {\n type: 'hidden',\n update: 'color',\n },\n\n colorScheme: {\n type: 'select',\n update: 'color',\n options: {}\n },\n colorScale: {\n type: 'select',\n update: 'color',\n options: ColormakerRegistry.getScales()\n },\n colorReverse: {\n type: 'boolean', update: 'color'\n },\n colorValue: {\n type: 'color', update: 'color'\n },\n colorDomain: {\n type: 'hidden', update: 'color'\n },\n colorMode: {\n type: 'select',\n update: 'color',\n options: ColormakerRegistry.getModes()\n },\n\n roughness: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n metalness: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n diffuse: {\n type: 'color', buffer: true\n },\n\n diffuseInterior: {\n type: 'boolean', buffer: true\n },\n useInteriorColor: {\n type: 'boolean', buffer: true\n },\n interiorColor: {\n type: 'color', buffer: true\n },\n interiorDarkening: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n\n matrix: {\n type: 'hidden', buffer: true\n },\n\n disablePicking: {\n type: 'boolean', rebuild: true\n }\n\n }\n\n /**\n * @type {Viewer}\n */\n this.viewer = viewer\n\n /**\n * Counter that keeps track of tasks related to the creation of\n * the representation, including surface calculations.\n * @type {Counter}\n */\n this.tasks = new Counter()\n\n /**\n * @type {Queue}\n * @private\n */\n this.queue = new Queue(this.make.bind(this))\n\n /**\n * @type {Array}\n * @private\n */\n this.bufferList = []\n\n if (this.parameters.colorScheme) {\n this.parameters.colorScheme.options = ColormakerRegistry.getSchemes()\n }\n\n this.toBePrepared = false\n }\n\n init (params: Partial) {\n const p = params || {}\n\n this.clipNear = defaults(p.clipNear, 0)\n this.clipRadius = defaults(p.clipRadius, 0)\n this.clipCenter = defaults(p.clipCenter, new Vector3())\n this.flatShaded = defaults(p.flatShaded, false)\n this.side = defaults(p.side, 'double')\n this.opacity = defaults(p.opacity, 1.0)\n this.depthWrite = defaults(p.depthWrite, true)\n this.wireframe = defaults(p.wireframe, false)\n\n this.setColor(p.color, p)\n\n this.colorData = defaults(p.colorData, undefined)\n this.colorScheme = defaults(p.colorScheme, 'uniform')\n this.colorScale = defaults(p.colorScale, '')\n this.colorReverse = defaults(p.colorReverse, false)\n this.colorValue = defaults(p.colorValue, 0x909090)\n this.colorDomain = defaults(p.colorDomain, undefined)\n this.colorMode = defaults(p.colorMode, 'hcl')\n\n this.visible = defaults(p.visible, true)\n this.quality = defaults(p.quality, undefined)\n\n this.roughness = defaults(p.roughness, 0.4)\n this.metalness = defaults(p.metalness, 0.0)\n this.diffuse = defaults(p.diffuse, 0xffffff)\n\n this.diffuseInterior = defaults(p.diffuseInterior, false)\n this.useInteriorColor = defaults(p.useInteriorColor, false)\n this.interiorColor = defaults(p.interiorColor, 0x222222)\n this.interiorDarkening = defaults(p.interiorDarkening, 0)\n\n this.lazy = defaults(p.lazy, false)\n this.lazyProps = {\n build: false,\n bufferParams: {},\n what: {}\n }\n\n this.matrix = defaults(p.matrix, new Matrix4())\n\n this.disablePicking = defaults(p.disablePicking, false)\n\n // handle common parameters when applicable\n\n const tp = this.parameters\n\n if (tp.sphereDetail === true) {\n tp.sphereDetail = {\n type: 'integer', max: 3, min: 0, rebuild: 'impostor'\n }\n }\n if (tp.radialSegments === true) {\n tp.radialSegments = {\n type: 'integer', max: 25, min: 5, rebuild: 'impostor'\n }\n }\n if (tp.openEnded === true) {\n tp.openEnded = {\n type: 'boolean', rebuild: 'impostor', buffer: true\n }\n }\n if (tp.disableImpostor === true) {\n tp.disableImpostor = {\n type: 'boolean', rebuild: true\n }\n }\n\n if (p.quality === 'low') {\n if (tp.sphereDetail) this.sphereDetail = 0\n if (tp.radialSegments) this.radialSegments = 5\n } else if (p.quality === 'medium') {\n if (tp.sphereDetail) this.sphereDetail = 1\n if (tp.radialSegments) this.radialSegments = 10\n } else if (p.quality === 'high') {\n if (tp.sphereDetail) this.sphereDetail = 2\n if (tp.radialSegments) this.radialSegments = 20\n } else {\n if (tp.sphereDetail) {\n this.sphereDetail = defaults(p.sphereDetail, 1)\n }\n if (tp.radialSegments) {\n this.radialSegments = defaults(p.radialSegments, 10)\n }\n }\n\n if (tp.openEnded) {\n this.openEnded = defaults(p.openEnded, true)\n }\n\n if (tp.disableImpostor) {\n this.disableImpostor = defaults(p.disableImpostor, false)\n }\n\n }\n\n getColorParams (p?: {[k: string]: any}): { scheme: string, [k: string]: any } & ColormakerParameters {\n return Object.assign({\n\n data: this.colorData,\n scheme: this.colorScheme,\n scale: this.colorScale,\n reverse: this.colorReverse,\n value: this.colorValue,\n domain: this.colorDomain,\n mode: this.colorMode,\n colorSpace: this.colorSpace,\n\n }, p)\n }\n\n getBufferParams (p: {[k: string]: any} = {}) {\n return Object.assign({\n\n clipNear: this.clipNear,\n clipRadius: this.clipRadius,\n clipCenter: this.clipCenter,\n flatShaded: this.flatShaded,\n opacity: this.opacity,\n depthWrite: this.depthWrite,\n side: this.side,\n wireframe: this.wireframe,\n\n roughness: this.roughness,\n metalness: this.metalness,\n diffuse: this.diffuse,\n\n diffuseInterior: this.diffuseInterior,\n useInteriorColor: this.useInteriorColor,\n interiorColor: this.interiorColor,\n interiorDarkening: this.interiorDarkening,\n\n matrix: this.matrix,\n\n disablePicking: this.disablePicking\n\n }, p)\n }\n\n setColor (value: number | string | Color | undefined , p?: Partial) {\n const types = Object.keys(ColormakerRegistry.getSchemes())\n\n if (typeof value === 'string' && types.includes(value.toLowerCase())) {\n if (p) {\n p.colorScheme = value\n } else {\n this.setParameters({ colorScheme: value })\n }\n } else if (value !== undefined) {\n let val = new Color(value as string).getHex() //TODO\n if (p) {\n p.colorScheme = 'uniform'\n p.colorValue = val\n } else {\n this.setParameters({\n colorScheme: 'uniform', colorValue: val\n })\n }\n }\n\n return this\n }\n\n // TODO\n prepare (cb: ()=> void) {\n\n }\n\n create () {\n // this.bufferList.length = 0;\n }\n\n update (what?: any) {\n this.build()\n }\n\n build (updateWhat?: {[k: string]: boolean}) {\n if (this.lazy && (!this.visible || !this.opacity)) {\n this.lazyProps.build = true\n return\n }\n\n if (!this.toBePrepared) {\n this.tasks.increment()\n this.make()\n return\n }\n\n // don't let tasks accumulate\n if (this.queue.length() > 0) {\n this.tasks.change(1 - this.queue.length())\n this.queue.kill()\n } else {\n this.tasks.increment()\n }\n\n this.queue.push(updateWhat || false)\n }\n\n make (updateWhat?: boolean, callback?: () => void) {\n if (Debug) Log.time('Representation.make ' + this.type)\n\n const _make = () => {\n if (updateWhat) {\n this.update(updateWhat)\n this.viewer.requestRender()\n this.tasks.decrement()\n if (callback) callback()\n } else {\n this.clear()\n this.create()\n if (!this.manualAttach && !this.disposed) {\n if (Debug) Log.time('Representation.attach ' + this.type)\n this.attach(() => {\n if (Debug) Log.timeEnd('Representation.attach ' + this.type)\n this.tasks.decrement()\n if (callback) callback()\n })\n }\n }\n\n if (Debug) Log.timeEnd('Representation.make ' + this.type)\n }\n\n if (this.toBePrepared) {\n this.prepare(_make)\n } else {\n _make()\n }\n }\n\n attach (callback: () => void) {\n this.setVisibility(this.visible)\n\n callback()\n }\n\n /**\n * Set the visibility of the representation\n * @param {Boolean} value - visibility flag\n * @param {Boolean} [noRenderRequest] - whether or not to request a re-render from the viewer\n * @return {Representation} this object\n */\n setVisibility (value: boolean, noRenderRequest?: boolean): Representation {\n this.visible = value\n\n if (this.visible && this.opacity) {\n const lazyProps = this.lazyProps\n const bufferParams = lazyProps.bufferParams\n const what = lazyProps.what\n\n if (lazyProps.build) {\n lazyProps.build = false\n this.build()\n return this\n } else if (Object.keys(bufferParams).length || Object.keys(what).length) {\n lazyProps.bufferParams = {}\n lazyProps.what = {}\n this.updateParameters(bufferParams, what)\n }\n }\n\n this.bufferList.forEach(function (buffer) {\n buffer.setVisibility(value)\n })\n\n if (!noRenderRequest) this.viewer.requestRender()\n\n return this\n }\n\n /**\n * Set the visibility of the representation\n * @param {RepresentationParameters} params - parameters object\n * @param {Object} [what] - buffer data attributes to be updated,\n * note that this needs to be implemented in the\n * derived classes. Generally it allows more\n * fine-grained control over updating than\n * forcing a rebuild.\n * @param {Boolean} what.position - update position data\n * @param {Boolean} what.color - update color data\n * @param {Boolean} [rebuild] - whether or not to rebuild the representation\n * @return {Representation} this object\n */\n setParameters (params: Partial, what:{[propName: string]: any} = {}, rebuild = false) {\n const p = params || {}\n const tp = this.parameters\n const bufferParams: BufferParameters = {}\n\n if (!this.opacity && p.opacity !== undefined) {\n if (this.lazyProps.build) {\n this.lazyProps.build = false\n rebuild = true\n } else {\n Object.assign(bufferParams, this.lazyProps.bufferParams)\n Object.assign(what, this.lazyProps.what)\n this.lazyProps.bufferParams = {}\n this.lazyProps.what = {}\n }\n }\n\n this.setColor(p.color, p)\n\n for (let name in p) {\n if (p[ name ] === undefined) continue\n if (tp[ name ] == undefined ) continue // Skip nulls as well as undefined\n\n if (tp[ name ].int) p[ name ] = parseInt(p[ name ] as string)\n if (tp[ name ].float) p[ name ] = parseFloat(p[ name ] as string)\n\n // no value change\n if (p[ name ] === this[ name ] && (\n !p[ name ].equals || p[ name ].equals(this[ name ])\n )) continue\n\n if (this[ name ] && this[ name ].copy && p[ name ].copy) {\n this[ name ].copy(p[ name ])\n } else if (this[ name ] && this[ name ].set) {\n this[ name ].set(p[ name ])\n } else {\n this[ name ] = p[ name ]\n }\n\n // buffer param\n if (tp[ name ].buffer) {\n if (tp[ name ].buffer === true) {\n (bufferParams[ name as keyof BufferParameters ] as any) = p[ name ]\n } else {\n let key: (keyof BufferParameters) = tp[ name ].buffer;\n (bufferParams[ key ] as any) = p[ name ]\n }\n }\n\n // mark for update\n if (tp[ name ].update) {\n what[ tp[ name ].update ] = true\n }\n\n // mark for rebuild\n if (tp[ name ].rebuild &&\n !(tp[ name ].rebuild === 'impostor' &&\n ExtensionFragDepth && !this.disableImpostor)\n ) {\n rebuild = true\n }\n }\n\n //\n\n if (rebuild) {\n this.build()\n } else {\n this.updateParameters(bufferParams, what)\n }\n\n return this\n }\n\n updateParameters (bufferParams: BufferParameters | {} = {}, what?: any) {\n if (this.lazy && (!this.visible || !this.opacity) && bufferParams.hasOwnProperty('opacity') === false) {\n Object.assign(this.lazyProps.bufferParams, bufferParams)\n Object.assign(this.lazyProps.what, what)\n return\n }\n\n this.bufferList.forEach(function (buffer) {\n buffer.setParameters(bufferParams)\n })\n\n if (Object.keys(what).length) {\n this.update(what) // update buffer attribute\n }\n\n this.viewer.requestRender()\n }\n\n getParameters () {\n const params: Partial = {\n lazy: this.lazy,\n visible: this.visible,\n quality: this.quality\n }\n\n Object.keys(this.parameters).forEach(name => {\n if (this.parameters[ name ] !== null) {\n params[ name ] = this[ name ]\n }\n })\n\n return params\n }\n\n clear () {\n this.bufferList.forEach(buffer => {\n this.viewer.remove(buffer)\n buffer.dispose()\n })\n this.bufferList.length = 0\n\n this.viewer.requestRender()\n }\n\n dispose () {\n this.disposed = true\n this.queue.kill()\n this.tasks.dispose()\n this.clear()\n }\n}\n\nexport default Representation\n","/**\n * @file Worker\n * @author Alexander Rose \n * @private\n */\n\nimport { Log, Debug, WorkerRegistry } from '../globals'\n\nexport default class _Worker {\n\n pending = 0\n postCount = 0\n onmessageDict: { [k: number]: Function|undefined } = {}\n onerrorDict: { [k: number]: Function|undefined } = {}\n\n name: string\n blobUrl: string\n worker: Worker\n\n constructor (name: string) {\n\n this.name = name\n this.blobUrl = window.URL.createObjectURL(WorkerRegistry.get(name))\n this.worker = new Worker(this.blobUrl)\n\n WorkerRegistry.activeWorkerCount += 1\n\n this.worker.onmessage = (event: any) => {\n this.pending -= 1\n const postId = event.data.__postId\n\n if (Debug) Log.timeEnd('Worker.postMessage ' + name + ' #' + postId)\n\n const onmessage = this.onmessageDict[ postId ]\n if (onmessage) {\n onmessage.call(this.worker, event)\n } else {\n // Log.debug('No onmessage', postId, name)\n }\n\n delete this.onmessageDict[ postId ]\n delete this.onerrorDict[ postId ]\n }\n\n this.worker.onerror = (event: any) => {\n this.pending -= 1\n if (event.data) {\n const postId = event.data.__postId\n\n const onerror = this.onerrorDict[ postId ]\n if (onerror) {\n onerror.call(this.worker, event)\n } else {\n Log.error('Worker.onerror', postId, name, event)\n }\n\n delete this.onmessageDict[ postId ]\n delete this.onerrorDict[ postId ]\n } else {\n Log.error('Worker.onerror', name, event)\n }\n }\n }\n\n post (aMessage: any = {}, transferList?: any, onmessage?: Function, onerror?: Function) {\n this.onmessageDict[ this.postCount ] = onmessage\n this.onerrorDict[ this.postCount ] = onerror\n\n aMessage.__name = this.name\n aMessage.__postId = this.postCount\n aMessage.__debug = Debug\n\n if (Debug) Log.time(`Worker.postMessage ${this.name} #${this.postCount}`)\n\n try {\n this.worker.postMessage(aMessage, transferList)\n } catch (error) {\n Log.error('worker.post:', error)\n this.worker.postMessage(aMessage)\n }\n\n this.pending += 1\n this.postCount += 1\n\n return this\n }\n\n terminate () {\n if (this.worker) {\n this.worker.terminate()\n window.URL.revokeObjectURL(this.blobUrl)\n WorkerRegistry.activeWorkerCount -= 1\n } else {\n Log.log('no worker to terminate')\n }\n }\n}\n","/**\n * @file Worker Pool\n * @author Alexander Rose \n * @private\n */\n\nimport Worker from './worker'\n\nclass WorkerPool {\n maxCount: number\n pool: Worker[] = []\n count = 0\n name: string\n\n constructor (name: string, maxCount = 2) {\n this.maxCount = Math.min(8, maxCount)\n this.name = name\n }\n\n post (aMessage: any = {}, transferList?: any, onmessage?: Function, onerror?: Function) {\n const worker = this.getNextWorker()\n if (worker) {\n worker.post(aMessage, transferList, onmessage, onerror)\n } else {\n console.error('unable to get worker from pool')\n }\n\n return this\n }\n\n terminate () {\n this.pool.forEach(function (worker) {\n worker.terminate()\n })\n }\n\n getNextWorker () {\n let nextWorker\n let minPending = Infinity\n\n for (let i = 0; i < this.maxCount; ++i) {\n if (i >= this.count) {\n nextWorker = new Worker(this.name)\n this.pool.push(nextWorker)\n this.count += 1\n break\n }\n\n const worker = this.pool[ i ]\n\n if (worker.pending === 0) {\n nextWorker = worker\n break\n } else if (worker.pending < minPending) {\n minPending = worker.pending\n nextWorker = worker\n }\n }\n\n return nextWorker\n }\n}\n\nWorkerPool.prototype.constructor = WorkerPool\n\nexport default WorkerPool\n","/**\n * @file Vector Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { NumberArray } from '../types'\nimport { EPS } from './math-constants'\n\n/**\n * Calculate the two intersection points\n * Converted to JavaScript from\n * {@link http://paulbourke.net/geometry/pointlineplane/lineline.c}\n */\nexport function lineLineIntersect (p1: Vector3, p2: Vector3, p3: Vector3, p4: Vector3) {\n const p13 = new Vector3()\n const p43 = new Vector3()\n const p21 = new Vector3()\n let d1343, d4321, d1321, d4343, d2121\n let denom, numer\n\n p13.x = p1.x - p3.x\n p13.y = p1.y - p3.y\n p13.z = p1.z - p3.z\n p43.x = p4.x - p3.x\n p43.y = p4.y - p3.y\n p43.z = p4.z - p3.z\n if (Math.abs(p43.x) < EPS && Math.abs(p43.y) < EPS && Math.abs(p43.z) < EPS) { return null }\n\n p21.x = p2.x - p1.x\n p21.y = p2.y - p1.y\n p21.z = p2.z - p1.z\n if (Math.abs(p21.x) < EPS && Math.abs(p21.y) < EPS && Math.abs(p21.z) < EPS) { return null }\n\n d1343 = p13.x * p43.x + p13.y * p43.y + p13.z * p43.z\n d4321 = p43.x * p21.x + p43.y * p21.y + p43.z * p21.z\n d1321 = p13.x * p21.x + p13.y * p21.y + p13.z * p21.z\n d4343 = p43.x * p43.x + p43.y * p43.y + p43.z * p43.z\n d2121 = p21.x * p21.x + p21.y * p21.y + p21.z * p21.z\n\n denom = d2121 * d4343 - d4321 * d4321\n if (Math.abs(denom) < EPS) { return null }\n numer = d1343 * d4321 - d1321 * d4343\n\n const mua = numer / denom\n const mub = (d1343 + d4321 * mua) / d4343\n\n const pa = new Vector3(\n p1.x + mua * p21.x,\n p1.y + mua * p21.y,\n p1.z + mua * p21.z\n )\n const pb = new Vector3(\n p3.x + mub * p43.x,\n p3.y + mub * p43.y,\n p3.z + mub * p43.z\n )\n\n return [ pa, pb ]\n}\n\nexport function calculateMeanVector3 (array: NumberArray) {\n const n = array.length\n const m = n / 3\n\n let x = 0\n let y = 0\n let z = 0\n\n for (let i = 0; i < n; i += 3) {\n x += array[ i + 0 ]\n y += array[ i + 1 ]\n z += array[ i + 2 ]\n }\n\n return new Vector3(x / m, y / m, z / m)\n}\n\nexport function isPointOnSegment (p: Vector3, l1: Vector3, l2: Vector3) {\n const len = l1.distanceTo(l2)\n\n return p.distanceTo(l1) <= len && p.distanceTo(l2) <= len\n}\n\nexport function projectPointOnVector (point: Vector3, vector: Vector3, origin?: Vector3) {\n if (origin) {\n point.sub(origin).projectOnVector(vector).add(origin)\n } else {\n point.projectOnVector(vector)\n }\n\n return point\n}\n\nexport function computeBoundingBox (array: NumberArray) {\n let minX = +Infinity\n let minY = +Infinity\n let minZ = +Infinity\n let maxX = -Infinity\n let maxY = -Infinity\n let maxZ = -Infinity\n for (let i = 0, l = array.length; i < l; i += 3) {\n const x = array[ i ]\n const y = array[ i + 1 ]\n const z = array[ i + 2 ]\n if (x < minX) minX = x\n if (y < minY) minY = y\n if (z < minZ) minZ = z\n if (x > maxX) maxX = x\n if (y > maxY) maxY = y\n if (z > maxZ) maxZ = z\n }\n return [\n v3new([ minX, minY, minZ ]),\n v3new([ maxX, maxY, maxZ ])\n ]\n}\n(computeBoundingBox as any).__deps = [ v3new ]\n\nexport function applyMatrix4toVector3array (m: Float32Array, a: Float32Array) {\n for (let i = 0, il = a.length; i < il; i += 3) {\n const x = a[ i ]\n const y = a[ i + 1 ]\n const z = a[ i + 2 ]\n a[ i ] = m[ 0 ] * x + m[ 4 ] * y + m[ 8 ] * z + m[ 12 ]\n a[ i + 1 ] = m[ 1 ] * x + m[ 5 ] * y + m[ 9 ] * z + m[ 13 ]\n a[ i + 2 ] = m[ 2 ] * x + m[ 6 ] * y + m[ 10 ] * z + m[ 14 ]\n }\n}\n\nexport function applyMatrix3toVector3array (m: Float32Array, a: Float32Array) {\n for (let i = 0, il = a.length; i < il; i += 3) {\n const x = a[ i ]\n const y = a[ i + 1 ]\n const z = a[ i + 2 ]\n a[ i ] = m[ 0 ] * x + m[ 3 ] * y + m[ 6 ] * z\n a[ i + 1 ] = m[ 1 ] * x + m[ 4 ] * y + m[ 7 ] * z\n a[ i + 2 ] = m[ 2 ] * x + m[ 5 ] * y + m[ 8 ] * z\n }\n}\n\nexport function normalizeVector3array (a: Float32Array) {\n for (let i = 0, il = a.length; i < il; i += 3) {\n const x = a[ i ]\n const y = a[ i + 1 ]\n const z = a[ i + 2 ]\n const len2 = x * x + y * y + z * z\n if (len2 > 0) { // avoid divide by zero\n const s = 1 / Math.sqrt(len2)\n a[ i ] = x * s\n a[ i + 1 ] = y * s\n a[ i + 2 ] = z * s\n }\n // else leave as all zeros\n }\n}\n\nexport function v3new (array?: NumberArray) {\n return new Float32Array(array as any || 3) // TODO\n}\n\nexport function v3cross (out: Float32Array, a: Float32Array, b: Float32Array) {\n const ax = a[0]\n const ay = a[1]\n const az = a[2]\n const bx = b[0]\n const by = b[1]\n const bz = b[2]\n out[0] = ay * bz - az * by\n out[1] = az * bx - ax * bz\n out[2] = ax * by - ay * bx\n}\n\nexport function v3dot (a: Float32Array, b: Float32Array) {\n return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]\n}\n\nexport function v3sub (out: Float32Array, a: Float32Array, b: Float32Array) {\n out[0] = a[0] - b[0]\n out[1] = a[1] - b[1]\n out[2] = a[2] - b[2]\n}\n\nexport function v3add (out: Float32Array, a: Float32Array, b: Float32Array) {\n out[0] = a[0] + b[0]\n out[1] = a[1] + b[1]\n out[2] = a[2] + b[2]\n}\n\nexport function v3fromArray (out: Float32Array, array: Float32Array, offset = 0) {\n out[0] = array[offset]\n out[1] = array[offset + 1]\n out[2] = array[offset + 2]\n}\n\nexport function v3toArray (input: Float32Array, array: Float32Array, offset = 0) {\n array[offset] = input[0]\n array[offset + 1] = input[1]\n array[offset + 2] = input[2]\n}\n\nexport function v3forEach (array: Float32Array, fn: (i: Float32Array, j: Float32Array, k: Float32Array) => void, b: Float32Array) {\n const a = v3new()\n for (let i = 0, n = array.length; i < n; i += 3) {\n v3fromArray(a, array, i)\n fn(a, a, b)\n v3toArray(a, array, i)\n }\n}\n(v3forEach as any).__deps = [ v3new, v3fromArray, v3toArray ]\n\nexport function v3length2 (a: Float32Array) {\n return a[0] * a[0] + a[1] * a[1] + a[2] * a[2]\n}\n\nexport function v3length (a: Float32Array) {\n return Math.sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2])\n}\n\nexport function v3divide (out: Float32Array, a: Float32Array, b: Float32Array) {\n out[0] = a[0] / b[0]\n out[1] = a[1] / b[1]\n out[2] = a[2] / b[2]\n}\n\nexport function v3multiply (out: Float32Array, a: Float32Array, b: Float32Array) {\n out[0] = a[0] * b[0]\n out[1] = a[1] * b[1]\n out[2] = a[2] * b[2]\n}\n\nexport function v3divideScalar (out: Float32Array, a: Float32Array, s: number) {\n v3multiplyScalar(out, a, 1 / s)\n}\n(v3divideScalar as any).__deps = [ v3multiplyScalar ]\n\nexport function v3multiplyScalar (out: Float32Array, a: Float32Array, s: number) {\n out[0] = a[0] * s\n out[1] = a[1] * s\n out[2] = a[2] * s\n}\n\nexport function v3normalize (out: Float32Array, a: Float32Array) {\n const length2 = v3length2(a)\n if (length2 == 0) {\n out[0] = a[0]\n out[1] = a[1]\n out[2] = a[2]\n } else {\n v3multiplyScalar(out, a, 1 / Math.sqrt(length2))\n }\n}\n(v3normalize as any).__deps = [ v3multiplyScalar, v3length2 ]\n\nexport function v3subScalar (out: Float32Array, a: Float32Array, s: number) {\n out[0] = a[0] - s\n out[1] = a[1] - s\n out[2] = a[2] - s\n}\n\nexport function v3addScalar (out: Float32Array, a: Float32Array, s: number) {\n out[0] = a[0] + s\n out[1] = a[1] + s\n out[2] = a[2] + s\n}\n\nexport function v3floor (out: Float32Array, a: Float32Array) {\n out[0] = Math.floor(a[0])\n out[1] = Math.floor(a[1])\n out[2] = Math.floor(a[2])\n}\n\nexport function v3ceil (out: Float32Array, a: Float32Array) {\n out[0] = Math.ceil(a[0])\n out[1] = Math.ceil(a[1])\n out[2] = Math.ceil(a[2])\n}\n\nexport function v3round (out: Float32Array, a: Float32Array) {\n out[0] = Math.round(a[0])\n out[1] = Math.round(a[1])\n out[2] = Math.round(a[2])\n}\n\nexport function v3negate (out: Float32Array, a: Float32Array) {\n out[0] = -a[0]\n out[1] = -a[1]\n out[2] = -a[2]\n}\n\nexport function v3angle (a: Float32Array, b: Float32Array) {\n const ax = a[0]\n const ay = a[1]\n const az = a[2]\n const bx = b[0]\n const by = b[1]\n const bz = b[2]\n const cx = ay * bz - az * by\n const cy = az * bx - ax * bz\n const cz = ax * by - ay * bx\n const s = Math.sqrt(cx * cx + cy * cy + cz * cz)\n const c = ax * bx + ay * by + az * bz\n return Math.atan2(s, c)\n}\n","/**\n * @file Dash\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport { WideLineBufferData } from '../buffer/wideline-buffer'\nimport {\n calculateDirectionArray, calculateCenterArray,\n replicateArrayEntries, replicateArray3Entries\n} from '../math/array-utils'\n\nexport function getFixedCountDashData (data: T, segmentCount: number = 9) {\n\n const s = Math.floor(segmentCount / 2)\n const n = data.position1.length / 3\n const sn = s * n\n const sn3 = sn * 3\n const step = 1 / segmentCount\n\n const direction = calculateDirectionArray(data.position1, data.position2)\n const position1 = new Float32Array(sn3)\n const position2 = new Float32Array(sn3)\n\n const v = new Vector3()\n\n for (let i = 0; i < n; ++i) {\n const i3 = i * 3\n v.set(direction[ i3 ], direction[ i3 + 1 ], direction[ i3 + 2 ])\n\n const x = data.position1[ i3 ]\n const y = data.position1[ i3 + 1 ]\n const z = data.position1[ i3 + 2 ]\n\n for (let j = 0; j < s; ++j) {\n const j3 = s * i3 + j * 3\n\n const f1 = step * (j * 2 + 1)\n const f2 = step * (j * 2 + 2)\n\n position1[ j3 ] = x + v.x * f1\n position1[ j3 + 1 ] = y + v.y * f1\n position1[ j3 + 2 ] = z + v.z * f1\n\n position2[ j3 ] = x + v.x * f2\n position2[ j3 + 1 ] = y + v.y * f2\n position2[ j3 + 2 ] = z + v.z * f2\n }\n }\n\n const position = calculateCenterArray(position1, position2) as Float32Array\n const color = replicateArray3Entries(data.color!, s) // TODO\n const color2 = color\n\n const d: any = { position, position1, position2, color, color2 }\n\n if ((data as any).radius) { // TODO\n d.radius = replicateArrayEntries((data as any).radius, s) // TODO\n }\n\n if (data.picking && data.picking.array) {\n data.picking.array = replicateArrayEntries(data.picking.array, s)\n d.picking = data.picking\n }\n if (data.primitiveId) {\n d.primitiveId = replicateArrayEntries(data.primitiveId, s)\n }\n\n return d as T\n}\n\nexport function getFixedLengthDashData (data: T, segmentLength: number = 0.1) {\n\n const direction = calculateDirectionArray(data.position1, data.position2)\n const pos1: number[] = []\n const pos2: number[] = []\n const col: number[] = []\n const rad: number[]|undefined = (data as any).radius ? [] : undefined\n const pick: number[]|undefined = (data as any).picking ? [] : undefined\n const id: number[]|undefined = (data as any).primitiveId ? [] : undefined\n\n const v = new Vector3()\n const n = data.position1.length / 3\n\n let k = 0\n\n for (let i = 0; i < n; ++i) {\n const i3 = i * 3\n v.set(direction[ i3 ], direction[ i3 + 1 ], direction[ i3 + 2 ])\n\n const vl = v.length()\n const segmentCount = vl / segmentLength\n const s = Math.floor(segmentCount / 2)\n const step = 1 / segmentCount\n\n const x = data.position1[ i3 ]\n const y = data.position1[ i3 + 1 ]\n const z = data.position1[ i3 + 2 ]\n\n for (let j = 0; j < s; ++j) {\n const j3 = k * 3 + j * 3\n\n const f1 = step * (j * 2 + 1)\n const f2 = step * (j * 2 + 2)\n\n pos1[ j3 ] = x + v.x * f1\n pos1[ j3 + 1 ] = y + v.y * f1\n pos1[ j3 + 2 ] = z + v.z * f1\n\n pos2[ j3 ] = x + v.x * f2\n pos2[ j3 + 1 ] = y + v.y * f2\n pos2[ j3 + 2 ] = z + v.z * f2\n\n if (data.color) {\n col[ j3 ] = data.color[ i3 ]\n col[ j3 + 1 ] = data.color[ i3 + 1 ]\n col[ j3 + 2 ] = data.color[ i3 + 2 ]\n }\n\n if (rad) rad[ k + j ] = (data as any).radius[ i ]\n if (pick) {\n if ((data as any).picking.array) {\n pick[ k + j ] = (data as any).picking.array[ i ]\n } else {\n pick[ k + j ] = i\n }\n }\n if (id) id[ k + j ] = (data as any).primitiveId[ i ]\n }\n\n k += s\n }\n\n const position1 = new Float32Array(pos1)\n const position2 = new Float32Array(pos2)\n const position = calculateCenterArray(position1, position2) as Float32Array\n const color = new Float32Array(col)\n const color2 = color\n\n const d: any = { position, position1, position2, color, color2 }\n\n if (rad) d.radius = new Float32Array(rad)\n if (pick && data.picking) {\n data.picking.array = new Float32Array(pick)\n d.picking = data.picking\n }\n if (id) d.primitiveId = new Float32Array(id)\n\n return d as T\n}\n\nexport function getFixedLengthWrappedDashData (data: T, segmentLength: number = 0.1) {\n\n const direction = calculateDirectionArray(data.position1, data.position2)\n const pos1: number[] = []\n const pos2: number[] = []\n const col: number[] = []\n const rad: number[]|undefined = (data as any).radius ? [] : undefined\n const pick: number[]|undefined = (data as any).picking ? [] : undefined\n const id: number[]|undefined = (data as any).primitiveId ? [] : undefined\n\n const v = new Vector3()\n const n = data.position1.length / 3\n\n let remaining = segmentLength\n let drawing = true\n\n let k = 0\n let k3 = 0\n let kprev = 0\n\n for (let i = 0; i < n; ++i) {\n const i3 = i * 3\n const x = data.position1[ i3 ]\n const y = data.position1[ i3 + 1 ]\n const z = data.position1[ i3 + 2 ]\n\n v.set(direction[ i3 ], direction[ i3 + 1 ], direction[ i3 + 2 ])\n const vl = v.length()\n\n if (drawing) {\n pos1[ k3 ] = x\n pos1[ k3 + 1 ] = y\n pos1[ k3 + 2 ] = z\n }\n\n let dist = remaining\n const inv = 1 / vl\n while (dist < vl) {\n const a = drawing ? pos2 : pos1\n a[ k3 ] = x + v.x * dist * inv\n a[ k3 + 1 ] = y + v.y * dist * inv\n a[ k3 + 2 ] = z + v.z * dist * inv\n if (drawing) {\n k++\n k3 = k * 3\n }\n drawing = !drawing\n remaining = segmentLength\n dist += segmentLength\n }\n\n if (drawing) {\n pos2[ k3 ] = data.position2[ i3 ]\n pos2[ k3 + 1 ] = data.position2[ i3 + 1 ]\n pos2[ k3 + 2 ] = data.position2[ i3 + 2 ]\n k++\n k3 = k * 3\n }\n\n remaining = dist - vl\n\n for (let j = kprev; j < k ; j++){\n if (data.color) {\n const j3 = j * 3\n col[ j3 ] = data.color[ i3 ]\n col[ j3 + 1 ] = data.color[ i3 + 1 ]\n col[ j3 + 2 ] = data.color[ i3 + 2 ]\n }\n\n if (rad) rad[ j ] = (data as any).radius[ i ]\n if (pick) {\n if ((data as any).picking.array) {\n pick[ j ] = (data as any).picking.array[ i ]\n } else {\n pick[ j ] = i\n }\n }\n if (id) id[ j ] = (data as any).primitiveId[ i ]\n }\n\n kprev = k\n\n }\n\n if (!drawing && n > 0) {\n const k3 = k * 3\n pos2[ k3 ] = data.position2[ 3 * n - 3 ]\n pos2[ k3 + 1 ] = data.position2[ 3 * n - 2 ]\n pos2[ k3 + 1 ] = data.position2[ 3 * n - 1 ]\n }\n\n const position1 = new Float32Array(pos1)\n const position2 = new Float32Array(pos2)\n const position = calculateCenterArray(position1, position2) as Float32Array\n const color = new Float32Array(col)\n const color2 = color\n\n const d: any = { position, position1, position2, color, color2 }\n\n if (rad) d.radius = new Float32Array(rad)\n if (pick && data.picking) {\n data.picking.array = new Float32Array(pick)\n d.picking = data.picking\n }\n if (id) d.primitiveId = new Float32Array(id)\n\n return d as T\n}\n","/**\n * @file Primitive\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Color, Box3 } from 'three'\n\nimport { BufferRegistry, PickerRegistry } from '../globals'\nimport Shape from './shape'\nimport { getFixedLengthDashData } from './dash'\n\nfunction addElement (elm: any, array: any[]) {\n if (elm.toArray !== undefined) {\n elm = elm.toArray()\n } else if (elm.x !== undefined) {\n elm = [ elm.x, elm.y, elm.z ]\n } else if (elm.r !== undefined) {\n elm = [ elm.r, elm.g, elm.b ]\n }\n array.push.apply(array, elm)\n}\n\nconst tmpVec = new Vector3()\n\nexport type PrimitiveFields = { [k: string]: string }\n\n/**\n * Base class for geometry primitives\n * @interface\n */\nexport abstract class Primitive {\n static type = ''\n static fields: PrimitiveFields = {}\n\n static get Picker () { return PickerRegistry.get(this.type) }\n static get Buffer () { return BufferRegistry.get(this.type) }\n\n static getShapeKey (name: string) {\n return this.type + name[0].toUpperCase() + name.substr(1)\n }\n\n static expandBoundingBox (box: Box3, data: any) {}\n\n static valueToShape (shape: Shape, name: string, value: any) {\n const data = shape._primitiveData[this.getShapeKey(name)]\n const type = this.fields[name]\n\n switch (type) {\n case 'v3':\n case 'c':\n addElement(value, data)\n break\n default:\n data.push(value)\n }\n }\n\n static objectToShape (shape: Shape, data: any) {\n Object.keys(this.fields).forEach(name => {\n this.valueToShape(shape, name, data[name])\n })\n this.valueToShape(shape, 'name', data.name)\n this.expandBoundingBox(shape.boundingBox, data)\n }\n\n static valueFromShape (shape: Shape, pid: number, name: string) {\n const data = shape._primitiveData[this.getShapeKey(name)]\n const type = this.fields[name]\n\n switch (type) {\n case 'v3':\n return new Vector3().fromArray(data, 3 * pid)\n case 'c':\n return new Color().fromArray(data, 3 * pid)\n default:\n return data[pid]\n }\n }\n\n static objectFromShape (shape: Shape, pid: number) {\n let name = this.valueFromShape(shape, pid, 'name')\n if (name === undefined) {\n name = `${this.type}: ${pid} (${shape.name})`\n }\n const o: any = { shape, name }\n\n Object.keys(this.fields).forEach(name => {\n o[name] = this.valueFromShape(shape, pid, name)\n })\n\n return o\n }\n\n static arrayFromShape (shape: Shape, name: string) {\n const data = shape._primitiveData[this.getShapeKey(name)]\n const type = this.fields[name]\n\n switch (type) {\n case 's':\n return data\n default:\n return new Float32Array(data)\n }\n }\n\n static dataFromShape (shape: Shape) {\n const data: any = {}\n\n if (this.Picker) {\n data.picking = new this.Picker(shape)\n }\n\n Object.keys(this.fields).forEach(name => {\n data[name] = this.arrayFromShape(shape, name)\n })\n\n return data\n }\n\n static bufferFromShape (shape: Shape, params: any) {\n return new this.Buffer(this.dataFromShape(shape), params)\n }\n}\n\n/**\n * Sphere geometry primitive\n */\nexport class SpherePrimitive extends Primitive {\n static type = 'sphere'\n\n static fields = {\n position: 'v3',\n color: 'c',\n radius: 'f'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n return this.valueFromShape(shape, pid, 'position')\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position))\n }\n}\n\n/**\n * Box geometry primitive\n */\nexport class BoxPrimitive extends Primitive {\n static type = 'box'\n\n static fields = {\n position: 'v3',\n color: 'c',\n size: 'f',\n heightAxis: 'v3',\n depthAxis: 'v3'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n return this.valueFromShape(shape, pid, 'position')\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position))\n }\n}\n\n/**\n * Octahedron geometry primitive\n */\nexport class OctahedronPrimitive extends BoxPrimitive {\n static type = 'octahedron'\n}\n\n/**\n * Tetrahedron geometry primitive\n */\nexport class TetrahedronPrimitive extends BoxPrimitive {\n static type = 'tetrahedron'\n}\n\n/**\n * Cylinder geometry primitive\n */\nexport class CylinderPrimitive extends Primitive {\n static type = 'cylinder'\n\n static fields = {\n position1: 'v3',\n position2: 'v3',\n color: 'c',\n radius: 'f'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n const p1 = this.valueFromShape(shape, pid, 'position1')\n const p2 = this.valueFromShape(shape, pid, 'position2')\n return p1.add(p2).multiplyScalar(0.5)\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position1))\n box.expandByPoint(tmpVec.fromArray(data.position2))\n }\n\n static bufferFromShape (shape: Shape, params: any = {}) {\n let data = this.dataFromShape(shape)\n if (this.type === 'cylinder' && params.dashedCylinder) {\n data = getFixedLengthDashData(data)\n }\n return new this.Buffer(data, params)\n }\n}\n\n/**\n * Arrow geometry primitive\n */\nexport class ArrowPrimitive extends CylinderPrimitive {\n static type = 'arrow'\n}\n\n/**\n * Cone geometry primitive\n */\nexport class ConePrimitive extends CylinderPrimitive {\n static type = 'cone'\n}\n\n/**\n * Ellipsoid geometry primitive\n */\nexport class EllipsoidPrimitive extends SpherePrimitive {\n static type = 'ellipsoid'\n\n static fields = {\n position: 'v3',\n color: 'c',\n radius: 'f',\n majorAxis: 'v3',\n minorAxis: 'v3'\n }\n}\n\n/**\n * Torus geometry primitive\n */\nexport class TorusPrimitive extends EllipsoidPrimitive {\n static type = 'torus'\n}\n\n/**\n * Text geometry primitive\n */\nexport class TextPrimitive extends Primitive {\n static type = 'text'\n\n static fields = {\n position: 'v3',\n color: 'c',\n size: 'f',\n text: 's'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n return this.valueFromShape(shape, pid, 'position')\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position))\n }\n}\n\n/**\n * Point primitive\n */\nexport class PointPrimitive extends Primitive {\n static type = 'point'\n\n static fields = {\n position: 'v3',\n color: 'c',\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n return this.valueFromShape(shape, pid, 'position')\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position))\n }\n}\n\n/**\n * Wideline geometry primitive\n */\nexport class WidelinePrimitive extends Primitive {\n static type = 'wideline'\n\n static fields = {\n position1: 'v3',\n position2: 'v3',\n color: 'c'\n }\n\n static positionFromShape (shape: Shape, pid: number) {\n const p1 = this.valueFromShape(shape, pid, 'position1')\n const p2 = this.valueFromShape(shape, pid, 'position2')\n return p1.add(p2).multiplyScalar(0.5)\n }\n\n static expandBoundingBox (box: Box3, data: any) {\n box.expandByPoint(tmpVec.fromArray(data.position1))\n box.expandByPoint(tmpVec.fromArray(data.position2))\n }\n}\n","/**\n * @file Spatial Hash\n * @author Alexander Rose \n * @private\n */\n\nimport { Box3 } from 'three'\n\nexport type Positions = {\n x: ArrayLike,\n y: ArrayLike,\n z: ArrayLike,\n count?:number\n}\n\nfunction createBoundingBox(positions: Positions) {\n const { x, y, z } = positions\n const boundingBox = new Box3()\n const count = x.length\n const { min, max } = boundingBox\n\n for (let i = 0; i < count; i++) {\n min.x = Math.min(x[i], min.x)\n min.y = Math.min(y[i], min.y)\n min.z = Math.min(z[i], min.z)\n max.x = Math.max(x[i], max.x)\n max.y = Math.max(y[i], max.y)\n max.z = Math.max(z[i], max.z)\n }\n\n return boundingBox\n}\n\nexport default class SpatialHash {\n exp = 3\n\n minX: number\n minY: number\n minZ: number\n\n boundX: number\n boundY: number\n boundZ: number\n\n grid: Uint32Array\n bucketCount: Uint16Array\n bucketOffset: Uint32Array\n bucketArray: Int32Array\n\n xArray: ArrayLike\n yArray: ArrayLike\n zArray: ArrayLike\n\n constructor(positions: Positions, boundingBox?: Box3) {\n const bb = boundingBox || createBoundingBox(positions)\n this.minX = bb.min.x\n this.minY = bb.min.y\n this.minZ = bb.min.z\n this.boundX = ((bb.max.x - this.minX) >> this.exp) + 1\n this.boundY = ((bb.max.y - this.minY) >> this.exp) + 1\n this.boundZ = ((bb.max.z - this.minZ) >> this.exp) + 1\n\n const n = this.boundX * this.boundY * this.boundZ\n const an = (positions.count !== undefined) ? positions.count : positions.x.length\n\n const xArray = positions.x\n const yArray = positions.y\n const zArray = positions.z\n\n let count = 0\n const grid = new Uint32Array(n)\n const bucketIndex = new Int32Array(an)\n for (let i = 0; i < an; ++i) {\n const x = (xArray[ i ] - this.minX) >> this.exp\n const y = (yArray[ i ] - this.minY) >> this.exp\n const z = (zArray[ i ] - this.minZ) >> this.exp\n const idx = (((x * this.boundY) + y) * this.boundZ) + z\n if ((grid[ idx ] += 1) === 1) {\n count += 1\n }\n bucketIndex[ i ] = idx\n }\n\n const bucketCount = new Uint16Array(count)\n for (let i = 0, j = 0; i < n; ++i) {\n const c = grid[ i ]\n if (c > 0) {\n grid[ i ] = j + 1\n bucketCount[ j ] = c\n j += 1\n }\n }\n\n const bucketOffset = new Uint32Array(count)\n for (let i = 1; i < count; ++i) {\n bucketOffset[ i ] += bucketOffset[ i - 1 ] + bucketCount[ i - 1 ]\n }\n\n const bucketFill = new Uint16Array(count)\n const bucketArray = new Int32Array(an)\n for (let i = 0; i < an; ++i) {\n const bucketIdx = grid[ bucketIndex[ i ] ]\n if (bucketIdx > 0) {\n const k = bucketIdx - 1\n bucketArray[ bucketOffset[ k ] + bucketFill[ k ] ] = i\n bucketFill[ k ] += 1\n }\n }\n\n this.grid = grid\n this.bucketCount = bucketCount\n this.bucketOffset = bucketOffset\n this.bucketArray = bucketArray\n\n this.xArray = xArray\n this.yArray = yArray\n this.zArray = zArray\n }\n\n within (x: number, y: number, z: number, r: number) {\n const result: number[] = []\n\n this.eachWithin(x, y, z, r, atomIndex => result.push(atomIndex))\n\n return result\n }\n\n eachWithin (x: number, y: number, z: number, r: number, callback: (atomIndex: number, dSq: number) => void) {\n const rSq = r * r\n\n const loX = Math.max(0, (x - r - this.minX) >> this.exp)\n const loY = Math.max(0, (y - r - this.minY) >> this.exp)\n const loZ = Math.max(0, (z - r - this.minZ) >> this.exp)\n\n const hiX = Math.min(this.boundX, ((x + r - this.minX) >> this.exp) + 1)\n const hiY = Math.min(this.boundY, ((y + r - this.minY) >> this.exp) + 1)\n const hiZ = Math.min(this.boundZ, ((z + r - this.minZ) >> this.exp) + 1)\n\n for (let ix = loX; ix < hiX; ++ix) {\n for (let iy = loY; iy < hiY; ++iy) {\n for (let iz = loZ; iz < hiZ; ++iz) {\n const idx = (((ix * this.boundY) + iy) * this.boundZ) + iz\n const bucketIdx = this.grid[ idx ]\n\n if (bucketIdx > 0) {\n const k = bucketIdx - 1\n const offset = this.bucketOffset[ k ]\n const count = this.bucketCount[ k ]\n const end = offset + count\n\n for (let i = offset; i < end; ++i) {\n const atomIndex = this.bucketArray[ i ]\n const dx = this.xArray[ atomIndex ] - x\n const dy = this.yArray[ atomIndex ] - y\n const dz = this.zArray[ atomIndex ] - z\n\n const dSq = dx * dx + dy * dy + dz * dz\n if (dSq <= rSq) callback(atomIndex, dSq)\n }\n }\n }\n }\n }\n }\n}","/**\n * @file Store\n * @author Alexander Rose \n * @private\n */\n\nimport { Log } from '../globals'\nimport { getTypedArray, TypedArrayString } from '../utils'\n\nexport type StoreField = [string, number, TypedArrayString]\n\n/**\n * Store base class\n * @interface\n */\nexport default class Store {\n [k: string]: any\n\n length: number\n count: number\n\n _fields: StoreField[]\n get _defaultFields(): StoreField[] { return [] }\n\n /**\n * @param {Integer} [size] - initial size\n */\n constructor (size = 0) {\n this._fields = this._defaultFields\n this._init(0)\n }\n\n /**\n * Initialize the store\n * @param {Integer} size - size to initialize\n * @return {undefined}\n */\n _init (size: number) {\n this.length = size\n this.count = 0\n\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const [name, size, type]: StoreField = this._fields[ i ]\n this._initField(name, size, type)\n }\n }\n\n /**\n * Initialize a field\n * @param {String} name - field name\n * @param {Integer} size - element size\n * @param {String} type - data type, one of int8, int16, int32,\n * uint8, uint16, uint32, float32\n * @return {undefined}\n */\n _initField (name: string, size: number, type: TypedArrayString) {\n this[ name ] = getTypedArray(type, this.length * size)\n }\n\n /**\n * Add a field\n * @param {String} name - field name\n * @param {Integer} size - element size\n * @param {String} type - data type, one of int8, int16, int32,\n * uint8, uint16, uint32, float32\n * @return {undefined}\n */\n addField (name: string, size: number, type: TypedArrayString) {\n this._fields.push([name, size, type])\n this._initField(name, size, type)\n }\n\n /**\n * Resize the store to the new size\n * @param {Integer} size - new size\n * @return {undefined}\n */\n resize (size?: number) {\n // Log.time( \"Store.resize\" );\n\n this.length = Math.round(size || 0)\n this.count = Math.min(this.count, this.length)\n\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const name = this._fields[ i ][ 0 ]\n const itemSize = this._fields[ i ][ 1 ]\n const arraySize = this.length * itemSize\n const tmpArray = new this[ name ].constructor(arraySize)\n\n if (this[ name ].length > arraySize) {\n tmpArray.set(this[ name ].subarray(0, arraySize))\n } else {\n tmpArray.set(this[ name ])\n }\n this[ name ] = tmpArray\n }\n\n // Log.timeEnd( \"Store.resize\" );\n }\n\n /**\n * Resize the store to 1.5 times its current size if full\n * @return {undefined}\n */\n growIfFull () {\n if (this.count >= this.length) {\n const size = Math.round(this.length * 1.5)\n this.resize(Math.max(256, size))\n }\n }\n\n /**\n * Copy data from one store to another\n * @param {Store} other - store to copy from\n * @param {Integer} thisOffset - offset to start copying to\n * @param {Integer} otherOffset - offset to start copying from\n * @param {Integer} length - number of entries to copy\n * @return {undefined}\n */\n copyFrom (other: Store, thisOffset: number, otherOffset: number, length: number) {\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const name = this._fields[ i ][ 0 ]\n const itemSize = this._fields[ i ][ 1 ]\n const thisField = this[ name ]\n const otherField = other[ name ]\n\n for (let j = 0; j < length; ++j) {\n const thisIndex = itemSize * (thisOffset + j)\n const otherIndex = itemSize * (otherOffset + j)\n for (let k = 0; k < itemSize; ++k) {\n thisField[ thisIndex + k ] = otherField[ otherIndex + k ]\n }\n }\n }\n }\n\n /**\n * Copy data within this store\n * @param {Integer} thisOffset - offset to start copying to\n * @param {Integer} otherOffset - offset to start copying from\n * @param {Integer} length - number of entries to copy\n * @return {undefined}\n */\n copyWithin (offsetTarget: number, offsetSource: number, length: number) {\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const name = this._fields[ i ][ 0 ]\n const itemSize = this._fields[ i ][ 1 ]\n const thisField = this[ name ]\n\n for (let j = 0; j < length; ++j) {\n const targetIndex = itemSize * (offsetTarget + j)\n const sourceIndex = itemSize * (offsetSource + j)\n for (let k = 0; k < itemSize; ++k) {\n thisField[ targetIndex + k ] = thisField[ sourceIndex + k ]\n }\n }\n }\n }\n\n /**\n * Sort entries in the store given the compare function\n * @param {[type]} compareFunction - function to sort by\n * @return {undefined}\n */\n sort (compareFunction: (a: any, b: any) => number) {\n Log.time('Store.sort')\n\n const thisStore = this\n const tmpStore = new (this.constructor as any)(1)\n\n function swap (index1: number, index2: number) {\n if (index1 === index2) return\n tmpStore.copyFrom(thisStore, 0, index1, 1)\n thisStore.copyWithin(index1, index2, 1)\n thisStore.copyFrom(tmpStore, index2, 0, 1)\n }\n\n function quicksort (left: number, right: number) {\n if (left < right) {\n let pivot = Math.floor((left + right) / 2)\n let leftNew = left\n let rightNew = right\n do {\n while (compareFunction(leftNew, pivot) < 0) {\n leftNew += 1\n }\n while (compareFunction(rightNew, pivot) > 0) {\n rightNew -= 1\n }\n if (leftNew <= rightNew) {\n if (leftNew === pivot) {\n pivot = rightNew\n } else if (rightNew === pivot) {\n pivot = leftNew\n }\n swap(leftNew, rightNew)\n leftNew += 1\n rightNew -= 1\n }\n } while (leftNew <= rightNew)\n quicksort(left, rightNew)\n quicksort(leftNew, right)\n }\n }\n\n quicksort(0, this.count - 1)\n\n Log.timeEnd('Store.sort')\n }\n\n /**\n * Empty the store\n * @return {undefined}\n */\n clear () {\n this.count = 0\n }\n\n /**\n * Dispose of the store entries and fields\n * @return {undefined}\n */\n dispose () {\n\n for (let i = 0, il = this._fields.length; i < il; ++i) {\n const name = this._fields[ i ][ 0 ]\n delete this[ name ]\n }\n }\n}\n","/**\n * @file Contact Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Bond store\n */\nexport default class ContactStore extends Store {\n index1: Uint32Array\n index2: Uint32Array\n type: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'index1', 1, 'int32' ],\n [ 'index2', 1, 'int32' ],\n [ 'type', 1, 'int8' ]\n ] as StoreField[]\n }\n\n addContact (index1: number, index2: number, type?: number) {\n this.growIfFull()\n\n const i = this.count\n\n if (index1 < index2) {\n this.index1[ i ] = index1\n this.index2[ i ] = index2\n } else {\n this.index2[ i ] = index1\n this.index1[ i ] = index2\n }\n if (type) this.type[ i ] = type\n\n this.count += 1\n }\n}","/**\n * @file Bit array\n * @author Alexander Rose \n * @author Paul Pillot \n * @private\n */\n\n/**\n * Compute the Hamming weight of a 32-bit unsigned integer\n * @param {Integer} v - a 32-bit unsigned integer\n * @return {Integer} the Hamming weight\n */\nfunction hammingWeight (v: number) {\n // works with signed or unsigned shifts\n v -= ((v >>> 1) & 0x55555555)\n v = (v & 0x33333333) + ((v >>> 2) & 0x33333333)\n return ((v + (v >>> 4) & 0xF0F0F0F) * 0x1010101) >>> 24\n}\n\n/**\n * Bit array\n *\n * Based heavily on https://github.com/lemire/FastBitSet.js\n * which is licensed under the Apache License, Version 2.0.\n */\nexport default class BitArray {\n private _words: Uint32Array\n public length: number\n\n /**\n * @param {Integer} length - array length\n * @param {Boolean} [setAll] - initialize with true\n */\n constructor (length: number, setAll?: boolean) {\n this.length = length\n this._words = new Uint32Array((length + 32) >>> 5)\n if (setAll === true) {\n this.setAll()\n }\n }\n\n /**\n * Get value at index\n * @param {Integer} index - the index\n * @return {Boolean} value\n */\n get (index: number) {\n return (this._words[ index >>> 5 ] & (1 << index)) !== 0\n }\n\n /**\n * Set value at index to true\n * @param {Integer} index - the index\n * @return {undefined}\n */\n set (index: number) {\n this._words[ index >>> 5 ] |= 1 << index\n }\n\n /**\n * Set value at index to false\n * @param {Integer} index - the index\n * @return {undefined}\n */\n clear (index: number) {\n this._words[ index >>> 5 ] &= ~(1 << index)\n }\n\n /**\n * Flip value at index\n * @param {Integer} index - the index\n * @return {undefined}\n */\n flip (index: number) {\n this._words[ index >>> 5 ] ^= 1 << index\n }\n\n _assignRange (start: number, end: number, value: boolean) {\n if (end < start) return\n const words = this._words\n const wordValue = value === true ? 0xFFFFFFFF : 0\n const wordStart = start >>> 5\n const wordEnd = end >>> 5\n // set complete words when applicable\n for (let k = wordStart + 1; k < wordEnd; ++k) {\n words[ k ] = wordValue\n }\n // set parts of the range not spanning complete words\n const startWord = wordStart << 5\n const endWord = wordEnd << 5\n if (value === true) {\n if (end - start < 32) {\n for (let i = start, n = end + 1; i < n; ++i) {\n words[ i >>> 5 ] |= 1 << i\n }\n } else {\n for (let i = start, n = startWord + 32; i < n; ++i) {\n words[ i >>> 5 ] |= 1 << i\n }\n for (let i = endWord, n = end + 1; i < n; ++i) {\n words[ i >>> 5 ] |= 1 << i\n }\n }\n } else {\n if (end - start < 32) {\n for (let i = start, n = end + 1; i < n; ++i) {\n words[ i >>> 5 ] &= ~(1 << i)\n }\n } else {\n for (let i = start, n = startWord + 32; i < n; ++i) {\n words[ i >>> 5 ] &= ~(1 << i)\n }\n for (let i = endWord, n = end + 1; i < n; ++i) {\n words[ i >>> 5 ] &= ~(1 << i)\n }\n }\n }\n return this\n }\n\n /**\n * Set bits of the given range\n * @param {Integer} start - start index\n * @param {Integer} end - end index\n * @return {BitArray} this object\n */\n setRange (start: number, end: number) {\n return this._assignRange(start, end, true)\n }\n\n /**\n * Clear bits of the given range\n * @param {Integer} start - start index\n * @param {Integer} end - end index\n * @return {BitArray} this object\n */\n clearRange (start: number, end: number) {\n return this._assignRange(start, end, false)\n }\n\n /**\n * Set bits at all given indices\n * @param {...Integer} arguments - indices\n * @return {Boolean} this object\n */\n setBits (...indices: number[]) {\n const words = this._words\n const n = indices.length\n for (let i = 0; i < n; ++i) {\n const index = indices[ i ]\n words[ index >>> 5 ] |= 1 << index\n }\n return this\n }\n\n /**\n * Clear bits at all given indices\n * @param {...Integer} arguments - indices\n * @return {Boolean} this object\n */\n clearBits (...indices: number[]) {\n const words = this._words\n const n = indices.length\n for (let i = 0; i < n; ++i) {\n const index = indices[ i ]\n words[ index >>> 5 ] &= ~(1 << index)\n }\n return this\n }\n\n /**\n * Set all bits of the array\n * @return {BitArray} this object\n */\n setAll () {\n return this._assignRange(0, this.length - 1, true)\n }\n\n /**\n * Clear all bits of the array\n * @return {BitArray} this object\n */\n clearAll () {\n return this._assignRange(0, this.length - 1, false)\n }\n\n /**\n * Flip all the values in the array\n * @return {BitArray} this object\n */\n flipAll () {\n const count = this._words.length\n const words = this._words\n const bs = 32 - this.length % 32\n for (let k = 0; k < count - 1; ++k) {\n words[k] = ~words[ k ]\n }\n words[ count - 1 ] = (~(words[ count - 1 ] << bs)) >>> bs\n return this\n }\n\n _isRangeValue (start: number, end: number, value: boolean) {\n if (end < start) return\n const words = this._words\n const wordValue = value === true ? 0xFFFFFFFF : 0\n const wordStart = start >>> 5\n const wordEnd = end >>> 5\n // set complete words when applicable\n for (let k = wordStart + 1; k < wordEnd; ++k) {\n if (words[ k ] !== wordValue) return false\n }\n // set parts of the range not spanning complete words\n if (end - start < 32) {\n for (let i = start, n = end + 1; i < n; ++i) {\n if (!!(words[ i >>> 5 ] & (1 << i)) !== value) return false\n }\n } else {\n const startWord = wordStart << 5\n const endWord = wordEnd << 5\n for (let i = start, n = startWord + 32; i < n; ++i) {\n if (!!(words[ i >>> 5 ] & (1 << i)) !== value) return false\n }\n for (let i = endWord, n = end + 1; i < n; ++i) {\n if (!!(words[ i >>> 5 ] & (1 << i)) !== value) return false\n }\n }\n return true\n }\n\n /**\n * Test if bits in given range are set\n * @param {Integer} start - start index\n * @param {Integer} end - end index\n * @return {BitArray} this object\n */\n isRangeSet (start: number, end: number) {\n return this._isRangeValue(start, end, true)\n }\n\n /**\n * Test if bits in given range are clear\n * @param {Integer} start - start index\n * @param {Integer} end - end index\n * @return {BitArray} this object\n */\n isRangeClear (start: number, end: number) {\n return this._isRangeValue(start, end, false)\n }\n\n /**\n * Test if all bits in the array are set\n * @return {Boolean} test result\n */\n isAllSet () {\n return this._isRangeValue(0, this.length - 1, true)\n }\n\n /**\n * Test if all bits in the array are clear\n * @return {Boolean} test result\n */\n isAllClear () {\n return this._isRangeValue(0, this.length - 1, false)\n }\n\n /**\n * Test if bits at all given indices are set\n * @param {...Integer} arguments - indices\n * @return {Boolean} test result\n */\n isSet (...indices: number[]) {\n const words = this._words\n const n = indices.length\n for (let i = 0; i < n; ++i) {\n const index = indices[ i ]\n if ((words[ index >>> 5 ] & (1 << index)) === 0) return false\n }\n return true\n }\n\n /**\n * Test if bits at all given indices are clear\n * @param {...Integer} arguments - indices\n * @return {Boolean} test result\n */\n isClear (...indices: number[]) {\n const words = this._words\n const n = indices.length\n for (let i = 0; i < n; ++i) {\n const index = indices[ i ]\n if ((words[ index >>> 5 ] & (1 << index)) !== 0) return false\n }\n return true\n }\n\n /**\n * Test if two BitArrays are identical in all their values\n * @param {BitArray} otherBitarray - the other BitArray\n * @return {Boolean} test result\n */\n isEqualTo (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n if (words1[ k ] !== words2[ k ]) {\n return false\n }\n }\n return true\n }\n\n /**\n * How many set bits?\n * @return {Integer} number of set bits\n */\n getSize () {\n const count = this._words.length\n const words = this._words\n let size = 0\n for (let i = 0; i < count; ++i) {\n size += hammingWeight(words[ i ])\n }\n return size\n }\n\n /**\n * Calculate difference betwen this and another bit array.\n * Store result in this object.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {BitArray} this object\n */\n difference (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n words1[ k ] = words1[ k ] & ~words2[ k ]\n }\n for (let k = words1.length; k < count; ++k) {\n words1[ k ] = 0\n }\n return this\n }\n\n /**\n * Calculate union betwen this and another bit array.\n * Store result in this object.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {BitArray} this object\n */\n union (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n words1[ k ] |= words2[ k ]\n }\n for (let k = words1.length; k < count; ++k) {\n words1[ k ] = 0\n }\n return this\n }\n\n /**\n * Calculate intersection betwen this and another bit array.\n * Store result in this object.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {BitArray} this object\n */\n intersection (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n words1[ k ] &= words2[ k ]\n }\n for (let k = words1.length; k < count; ++k) {\n words1[ k ] = 0\n }\n return this\n }\n\n /**\n * Test if there is any intersection betwen this and another bit array.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {Boolean} test result\n */\n intersects (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n for (let k = 0; k < count; ++k) {\n if ((words1[ k ] & words2[ k ]) !== 0) {\n return true\n }\n }\n return false\n }\n\n /**\n * Calculate the number of bits in common betwen this and another bit array.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {Integer} size\n */\n getIntersectionSize (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n let size = 0\n for (let k = 0; k < count; ++k) {\n size += hammingWeight(words1[ k ] & words2[ k ])\n }\n return size\n }\n\n /**\n * Calculate intersection betwen this and another bit array.\n * Store result in a new bit array.\n * @param {BitArray} otherBitarray - the other bit array\n * @return {BitArray} the new bit array\n */\n makeIntersection (otherBitarray: BitArray) {\n const words1 = this._words\n const words2 = otherBitarray._words\n const count = Math.min(words1.length, words2.length)\n const wordsA = new Uint32Array(count)\n const intersection = Object.create(BitArray.prototype)\n intersection._words = wordsA\n intersection.length = Math.min(this.length, otherBitarray.length)\n for (let k = 0; k < count; ++k) {\n wordsA[ k ] = words1[ k ] & words2[ k ]\n }\n return intersection\n }\n\n /**\n * Iterate over all set bits in the array\n * @param {function( index: Integer, i: Integer )} callback - the callback\n * @return {undefined}\n */\n forEach (callback: (index: number, i: number) => any) {\n const count = this._words.length\n const words = this._words\n let i = 0\n for (let k = 0; k < count; ++k) {\n let w = words[ k ]\n while (w !== 0) {\n const t = w & -w\n const index = (k << 5) + hammingWeight(t - 1)\n callback(index, i)\n w ^= t\n ++i\n }\n }\n }\n\n /**\n * Get an array with the set bits\n * @return {Array} bit indices\n */\n toArray () {\n const words = this._words\n const answer = new Array(this.getSize())\n const count = this._words.length\n let pos = 0\n for (let k = 0; k < count; ++k) {\n let w = words[ k ]\n while (w !== 0) {\n const t = w & -w\n answer[ pos++ ] = (k << 5) + hammingWeight(t - 1)\n w ^= t\n }\n }\n return answer\n }\n\n toString () {\n return '{' + this.toArray().join(',') + '}'\n }\n\n toSeleString () {\n const sele = this.toArray().join(',')\n return sele ? '@' + sele : 'NONE'\n }\n\n /**\n * Clone this object\n * @return {BitArray} the cloned object\n */\n clone () {\n const clone = Object.create(BitArray.prototype)\n clone.length = this.length\n clone._words = new Uint32Array(this._words)\n return clone\n }\n}","/**\n * @file Adjacency List\n * @author Alexander Rose \n * @private\n */\n\nexport interface Edges {\n nodeArray1: ArrayLike\n nodeArray2: ArrayLike\n edgeCount: number\n nodeCount: number\n}\n\nexport interface AdjacencyList {\n /* number of edges for each node */\n countArray: Uint8Array\n /* offset into indexArray for each node */\n offsetArray: Int32Array\n /* edge indices, grouped by nodes */\n indexArray: Int32Array\n}\n\nexport function createAdjacencyList (edges: Edges): AdjacencyList {\n const { edgeCount, nodeCount, nodeArray1, nodeArray2 } = edges\n\n const countArray = new Uint8Array(nodeCount)\n const offsetArray = new Int32Array(nodeCount)\n\n // count edges per node\n for (let i = 0; i < edgeCount; ++i) {\n countArray[ nodeArray1[ i ] ] += 1\n countArray[ nodeArray2[ i ] ] += 1\n }\n\n // get offsets to node edges\n for (let i = 1; i < nodeCount; ++i) {\n offsetArray[ i ] += offsetArray[ i - 1 ] + countArray[ i - 1 ]\n }\n\n // prepare index array\n const bondCount2 = edgeCount * 2\n const indexArray = new Int32Array(bondCount2)\n for (let j = 0; j < bondCount2; ++j) {\n indexArray[ j ] = -1\n }\n\n // build index array\n for (let i = 0; i < edgeCount; ++i) {\n const idx1 = nodeArray1[ i ]\n const idx2 = nodeArray2[ i ]\n let j1 = offsetArray[ idx1 ]\n while (indexArray[ j1 ] !== -1 && j1 < bondCount2) {\n j1 += 1\n }\n indexArray[ j1 ] = i\n let j2 = offsetArray[ idx2 ]\n while (indexArray[ j2 ] !== -1 && j2 < bondCount2) {\n j2 += 1\n }\n indexArray[ j2 ] = i\n }\n\n return { countArray, offsetArray, indexArray }\n}\n","/**\n * @file Features\n * @author Alexander Rose \n */\n\nimport AtomProxy from '../../proxy/atom-proxy'\n\nexport interface Features {\n types: FeatureType[]\n groups: FeatureGroup[]\n centers: { x: number[], y: number[], z: number[] }\n atomSets: number[][]\n}\n\nexport const enum FeatureType {\n Unknown = 0,\n PositiveCharge = 1,\n NegativeCharge = 2,\n AromaticRing = 3,\n HydrogenDonor = 4,\n HydrogenAcceptor = 5,\n HalogenDonor = 6,\n HalogenAcceptor = 7,\n Hydrophobic = 8,\n WeakHydrogenDonor = 9,\n IonicTypePartner = 10,\n DativeBondPartner = 11,\n TransitionMetal = 12,\n IonicTypeMetal = 13\n}\n\nexport const enum FeatureGroup {\n Unknown = 0,\n QuaternaryAmine = 1,\n TertiaryAmine = 2,\n Sulfonium = 3,\n SulfonicAcid = 4,\n Sulfate = 5,\n Phosphate = 6,\n Halocarbon = 7,\n Guanidine = 8,\n Acetamidine = 9,\n Carboxylate = 10\n}\n\nexport function createFeatures (): Features {\n return {\n types: [],\n groups: [],\n centers: { x: [], y: [], z: [] },\n atomSets: []\n }\n}\n\nexport interface FeatureState {\n type: FeatureType\n group: FeatureGroup\n x: number\n y: number\n z: number\n atomSet: number[]\n}\n\nexport function createFeatureState(type = FeatureType.Unknown, group = FeatureGroup.Unknown): FeatureState {\n return { type, group, x: 0, y: 0, z: 0, atomSet: [] }\n}\n\nexport function addAtom (state: FeatureState, atom: AtomProxy) {\n state.x += atom.x\n state.y += atom.y\n state.z += atom.z\n state.atomSet.push(atom.index)\n}\n\nexport function addFeature (features: Features, state: FeatureState) {\n const n = state.atomSet.length\n if (n > 0) {\n const { types, groups, centers, atomSets } = features\n types.push(state.type)\n groups.push(state.group)\n centers.x.push(state.x / n)\n centers.y.push(state.y / n)\n centers.z.push(state.z / n)\n atomSets.push(state.atomSet)\n }\n}\n","/**\n * @file Structure Constants\n * @author Alexander Rose \n * @private\n */\n\n// entity types\nexport const UnknownEntity = 0\nexport const PolymerEntity = 1\nexport const NonPolymerEntity = 2\nexport const MacrolideEntity = 3\nexport const WaterEntity = 4\n\n// molecule types\nexport const UnknownType = 0\nexport const WaterType = 1\nexport const IonType = 2\nexport const ProteinType = 3\nexport const RnaType = 4\nexport const DnaType = 5\nexport const SaccharideType = 6\n\n// backbone types\nexport const UnknownBackboneType = 0\nexport const ProteinBackboneType = 1\nexport const RnaBackboneType = 2\nexport const DnaBackboneType = 3\nexport const CgProteinBackboneType = 4\nexport const CgRnaBackboneType = 5\nexport const CgDnaBackboneType = 6\n\n// chemical component types\nexport const ChemCompProtein = [\n 'D-BETA-PEPTIDE, C-GAMMA LINKING', 'D-GAMMA-PEPTIDE, C-DELTA LINKING',\n 'D-PEPTIDE COOH CARBOXY TERMINUS', 'D-PEPTIDE NH3 AMINO TERMINUS', 'D-PEPTIDE LINKING',\n 'L-BETA-PEPTIDE, C-GAMMA LINKING', 'L-GAMMA-PEPTIDE, C-DELTA LINKING',\n 'L-PEPTIDE COOH CARBOXY TERMINUS', 'L-PEPTIDE NH3 AMINO TERMINUS', 'L-PEPTIDE LINKING',\n 'PEPTIDE LINKING', 'PEPTIDE-LIKE'\n]\nexport const ChemCompRna = [\n 'RNA OH 3 PRIME TERMINUS', 'RNA OH 5 PRIME TERMINUS', 'RNA LINKING'\n]\nexport const ChemCompDna = [\n 'DNA OH 3 PRIME TERMINUS', 'DNA OH 5 PRIME TERMINUS', 'DNA LINKING',\n 'L-DNA LINKING', 'L-RNA LINKING'\n]\nexport const ChemCompSaccharide = [\n 'D-SACCHARIDE', 'D-SACCHARIDE 1,4 AND 1,4 LINKING', 'D-SACCHARIDE 1,4 AND 1,6 LINKING',\n 'L-SACCHARIDE', 'L-SACCHARIDE 1,4 AND 1,4 LINKING', 'L-SACCHARIDE 1,4 AND 1,6 LINKING',\n 'SACCHARIDE'\n]\nexport const ChemCompOther = [\n 'OTHER'\n]\nexport const ChemCompNonPolymer = [\n 'NON-POLYMER'\n]\nexport const ChemCompHetero = ChemCompNonPolymer.concat(ChemCompOther, ChemCompSaccharide)\n\n// secondary structure\nexport const SecStrucHelix = [ 'h', 'g', 'i' ]\nexport const SecStrucSheet = [ 'e', 'b' ]\nexport const SecStrucTurn = [ 's', 't', 'l', '' ]\n\nexport const AtomicNumbers: { [e: string]: number | undefined } = {\n 'H': 1, 'D': 1, 'T': 1, 'HE': 2, 'LI': 3, 'BE': 4, 'B': 5, 'C': 6, 'N': 7, 'O': 8, 'F': 9, 'NE': 10, 'NA': 11, 'MG': 12, 'AL': 13, 'SI': 14, 'P': 15, 'S': 16, 'CL': 17, 'AR': 18, 'K': 19, 'CA': 20, 'SC': 21, 'TI': 22, 'V': 23, 'CR': 24, 'MN': 25, 'FE': 26, 'CO': 27, 'NI': 28, 'CU': 29, 'ZN': 30, 'GA': 31, 'GE': 32, 'AS': 33, 'SE': 34, 'BR': 35, 'KR': 36, 'RB': 37, 'SR': 38, 'Y': 39, 'ZR': 40, 'NB': 41, 'MO': 42, 'TC': 43, 'RU': 44, 'RH': 45, 'PD': 46, 'AG': 47, 'CD': 48, 'IN': 49, 'SN': 50, 'SB': 51, 'TE': 52, 'I': 53, 'XE': 54, 'CS': 55, 'BA': 56, 'LA': 57, 'CE': 58, 'PR': 59, 'ND': 60, 'PM': 61, 'SM': 62, 'EU': 63, 'GD': 64, 'TB': 65, 'DY': 66, 'HO': 67, 'ER': 68, 'TM': 69, 'YB': 70, 'LU': 71, 'HF': 72, 'TA': 73, 'W': 74, 'RE': 75, 'OS': 76, 'IR': 77, 'PT': 78, 'AU': 79, 'HG': 80, 'TL': 81, 'PB': 82, 'BI': 83, 'PO': 84, 'AT': 85, 'RN': 86, 'FR': 87, 'RA': 88, 'AC': 89, 'TH': 90, 'PA': 91, 'U': 92, 'NP': 93, 'PU': 94, 'AM': 95, 'CM': 96, 'BK': 97, 'CF': 98, 'ES': 99, 'FM': 100, 'MD': 101, 'NO': 102, 'LR': 103, 'RF': 104, 'DB': 105, 'SG': 106, 'BH': 107, 'HS': 108, 'MT': 109, 'DS': 110, 'RG': 111, 'CN': 112, 'NH': 113, 'FL': 114, 'MC': 115, 'LV': 116, 'TS': 117, 'OG': 118\n}\nexport const DefaultAtomicNumber = 0\n\n/**\n * Enum mapping element to atomic number\n */\nexport const enum Elements {\n H = 1, D = 1, T = 1, HE = 2, LI = 3, BE = 4, B = 5, C = 6, N = 7, O = 8, F = 9, NE = 10, NA = 11, MG = 12, AL = 13, SI = 14, P = 15, S = 16, CL = 17, AR = 18, K = 19, CA = 20, SC = 21, TI = 22, V = 23, CR = 24, MN = 25, FE = 26, CO = 27, NI = 28, CU = 29, ZN = 30, GA = 31, GE = 32, AS = 33, SE = 34, BR = 35, KR = 36, RB = 37, SR = 38, Y = 39, ZR = 40, NB = 41, MO = 42, TC = 43, RU = 44, RH = 45, PD = 46, AG = 47, CD = 48, IN = 49, SN = 50, SB = 51, TE = 52, I = 53, XE = 54, CS = 55, BA = 56, LA = 57, CE = 58, PR = 59, ND = 60, PM = 61, SM = 62, EU = 63, GD = 64, TB = 65, DY = 66, HO = 67, ER = 68, TM = 69, YB = 70, LU = 71, HF = 72, TA = 73, W = 74, RE = 75, OS = 76, IR = 77, PT = 78, AU = 79, HG = 80, TL = 81, PB = 82, BI = 83, PO = 84, AT = 85, RN = 86, FR = 87, RA = 88, AC = 89, TH = 90, PA = 91, U = 92, NP = 93, PU = 94, AM = 95, CM = 96, BK = 97, CF = 98, ES = 99, FM = 100, MD = 101, NO = 102, LR = 103, RF = 104, DB = 105, SG = 106, BH = 107, HS = 108, MT = 109, DS = 110, RG = 111, CN = 112, NH = 113, FL = 114, MC = 115, LV = 116, TS = 117, OG = 118\n}\n\n// https://doi.org/10.1515/pac-2015-0305 (table 2, 3, and 4)\nexport const AtomWeights: { [e: number]: number | undefined } = {\n 1: 1.008, 2: 4.0026, 3: 6.94, 4: 9.0122, 5: 10.81, 6: 10.81, 7: 14.007, 8: 15.999, 9: 18.998, 10: 20.180, 11: 22.990, 12: 24.305, 13: 26.982, 14: 28.085, 15: 30.974, 16: 32.06, 17: 35.45, 18: 39.948, 19: 39.098, 20: 40.078, 21: 44.956, 22: 47.867, 23: 50.942, 24: 51.996, 25: 54.938, 26: 55.845, 27: 58.933, 28: 58.693, 29: 63.546, 30: 65.38, 31: 69.723, 32: 72.630, 33: 74.922, 34: 78.971, 35: 79.904, 36: 83.798, 37: 85.468, 38: 87.62, 39: 88.906, 40: 91.224, 41: 92.906, 42: 95.95, 43: 96.906, 44: 101.07, 45: 102.91, 46: 106.42, 47: 107.87, 48: 112.41, 49: 114.82, 50: 118.71, 51: 121.76, 52: 127.60, 53: 127.60, 54: 131.29, 55: 132.91, 56: 137.33, 57: 138.91, 58: 140.12, 59: 140.91, 60: 144.24, 61: 144.912, 62: 150.36, 63: 151.96, 64: 157.25, 65: 158.93, 66: 162.50, 67: 164.93, 68: 167.26, 69: 168.93, 70: 173.05, 71: 174.97, 72: 178.49, 73: 180.95, 74: 183.84, 75: 186.21, 76: 190.23, 77: 192.22, 78: 195.08, 79: 196.97, 80: 200.59, 81: 204.38, 82: 207.2, 83: 208.98, 84: 1.97, 85: 2.02, 86: 2.2, 87: 3.48, 88: 2.83, 89: 2.0, 90: 232.04, 91: 231.04, 92: 238.03, 93: 237.048, 94: 244.064, 95: 243.061, 96: 247.070, 97: 247.070, 98: 251.079, 99: 252.083, 100: 257.095, 101: 258.098, 102: 259.101, 103: 262.110, 104: 267.122, 105: 270.131, 106: 271.134, 107: 270.133, 108: 270.134, 109: 278.156, 110: 281.165, 111: 281.166, 112: 285.177, 113: 286.182, 114: 289.190, 115: 289.194, 116: 293.204, 117: 293.208, 118: 294.214\n}\nexport const DefaultAtomWeight = 10.81 // C\n\n// http://dx.doi.org/10.1021/jp8111556 (or 2.0)\nexport const VdwRadii: { [e: number]: number | undefined } = {\n 1: 1.1, 2: 1.4, 3: 1.81, 4: 1.53, 5: 1.92, 6: 1.7, 7: 1.55, 8: 1.52, 9: 1.47, 10: 1.54, 11: 2.27, 12: 1.73, 13: 1.84, 14: 2.1, 15: 1.8, 16: 1.8, 17: 1.75, 18: 1.88, 19: 2.75, 20: 2.31, 21: 2.3, 22: 2.15, 23: 2.05, 24: 2.05, 25: 2.05, 26: 2.05, 27: 2.0, 28: 2.0, 29: 2.0, 30: 2.1, 31: 1.87, 32: 2.11, 33: 1.85, 34: 1.9, 35: 1.83, 36: 2.02, 37: 3.03, 38: 2.49, 39: 2.4, 40: 2.3, 41: 2.15, 42: 2.1, 43: 2.05, 44: 2.05, 45: 2.0, 46: 2.05, 47: 2.1, 48: 2.2, 49: 2.2, 50: 1.93, 51: 2.17, 52: 2.06, 53: 1.98, 54: 2.16, 55: 3.43, 56: 2.68, 57: 2.5, 58: 2.48, 59: 2.47, 60: 2.45, 61: 2.43, 62: 2.42, 63: 2.4, 64: 2.38, 65: 2.37, 66: 2.35, 67: 2.33, 68: 2.32, 69: 2.3, 70: 2.28, 71: 2.27, 72: 2.25, 73: 2.2, 74: 2.1, 75: 2.05, 76: 2.0, 77: 2.0, 78: 2.05, 79: 2.1, 80: 2.05, 81: 1.96, 82: 2.02, 83: 2.07, 84: 1.97, 85: 2.02, 86: 2.2, 87: 3.48, 88: 2.83, 89: 2.0, 90: 2.4, 91: 2.0, 92: 2.3, 93: 2.0, 94: 2.0, 95: 2.0, 96: 2.0, 97: 2.0, 98: 2.0, 99: 2.0, 100: 2.0, 101: 2.0, 102: 2.0, 103: 2.0, 104: 2.0, 105: 2.0, 106: 2.0, 107: 2.0, 108: 2.0, 109: 2.0, 110: 2.0, 111: 2.0, 112: 2.0, 113: 2.0, 114: 2.0, 115: 2.0, 116: 2.0, 117: 2.0, 118: 2.0\n}\nexport const DefaultVdwRadius = 2.0 // C\n\n// Peter Rose (peter.rose@rcsb.org), private communication, average accross PDB\nexport const ResidueRadii: { [k: string]: number } = {\n '2QY': 6.58,\n 'CY0': 11.98,\n '2QZ': 2.52,\n 'CY1': 6.59,\n 'HHK': 5.11,\n 'CXM': 4.69,\n 'HHI': 4.58,\n 'CY4': 4.57,\n 'S12': 18.57,\n 'CY3': 2.79,\n 'C5C': 5.35,\n 'PFX': 11.84,\n '2R3': 6.94,\n '2R1': 3.78,\n 'ILX': 4.99,\n '32S': 5.68,\n 'BTK': 8.59,\n '32T': 5.72,\n 'FAK': 9.8,\n 'B27': 2.78,\n 'ILM': 3.84,\n 'C4R': 5.63,\n '32L': 6.75,\n 'SYS': 3.01,\n '1MH': 5.04,\n 'ILE': 3.65,\n 'YNM': 6.39,\n '2RX': 4.91,\n 'B3A': 2.48,\n 'GEE': 4.76,\n '7MN': 7.34,\n 'B3E': 5.4,\n 'ARG': 6.33,\n '200': 6.89,\n 'HIP': 5.47,\n 'HIA': 4.64,\n 'B3K': 5.89,\n 'HIC': 5.76,\n 'B3L': 4.96,\n 'B3M': 5.07,\n 'ARM': 6.86,\n 'ARO': 7.35,\n 'AR4': 8.42,\n 'PG1': 10.67,\n 'YOF': 6.44,\n 'IML': 3.74,\n 'SXE': 6.65,\n 'HIQ': 7.98,\n 'PFF': 6.31,\n 'HIS': 4.52,\n '0TD': 3.62,\n 'C3Y': 5.24,\n '1OP': 11.55,\n '02Y': 4.77,\n '02V': 4.83,\n 'ASB': 5.59,\n '30V': 8.53,\n 'S2P': 4.81,\n 'ASP': 3.55,\n 'ASN': 3.54,\n '2OR': 6.91,\n 'QMM': 6.13,\n '2P0': 8.52,\n 'ASL': 5.36,\n 'HFA': 5.14,\n '5PG': 5.69,\n 'B3X': 4.38,\n 'AS9': 4.1,\n 'ARV': 7.59,\n 'B3U': 6.06,\n 'S2C': 7.54,\n 'B3T': 3.34,\n '175': 5.64,\n 'GFT': 8.18,\n 'HG7': 6.8,\n 'B3Q': 4.48,\n 'ASA': 3.64,\n '02K': 2.94,\n 'B3Y': 7.45,\n 'PHD': 5.35,\n 'C6C': 6.42,\n 'BUC': 5.8,\n 'HGL': 8.07,\n 'PHE': 5.06,\n '03Y': 2.6,\n 'PHA': 5.11,\n 'OCY': 5.0,\n '4PH': 6.79,\n '5OH': 4.7,\n '31Q': 10.46,\n 'BTR': 7.98,\n '3PX': 4.7,\n '1PA': 8.07,\n 'ASX': 3.54,\n 'IOR': 7.23,\n '03E': 3.38,\n 'PHL': 5.17,\n 'KWS': 5.09,\n 'PHI': 7.12,\n 'NAL': 7.22,\n 'S1H': 19.21,\n '2ML': 3.86,\n '2MR': 7.35,\n 'GHG': 4.83,\n 'TYY': 6.54,\n '2MT': 3.67,\n '56A': 13.01,\n 'SVA': 5.46,\n 'TYX': 8.31,\n 'TYS': 8.59,\n 'TYR': 6.38,\n 'TYQ': 6.43,\n 'HLU': 3.99,\n 'MYK': 19.47,\n 'TYO': 7.71,\n 'HLX': 4.98,\n 'TYN': 9.87,\n 'TYJ': 6.25,\n 'TYI': 6.49,\n 'LYH': 5.13,\n 'LYF': 12.19,\n 'SUN': 6.73,\n 'LYR': 18.28,\n 'TYB': 6.46,\n '11W': 14.39,\n 'LYS': 5.54,\n 'LYN': 4.8,\n '11Q': 4.85,\n 'LYO': 4.71,\n 'LYZ': 1.76,\n 'TXY': 6.44,\n 'MYN': 4.71,\n 'TY5': 10.6,\n 'HMR': 5.09,\n '01W': 8.55,\n 'LYX': 13.36,\n 'TY8': 7.22,\n 'TY2': 6.49,\n 'KYN': 6.18,\n 'KYQ': 9.75,\n 'CZZ': 5.14,\n 'IIL': 3.81,\n 'HNC': 10.41,\n 'OIC': 4.62,\n 'LVN': 2.89,\n 'QIL': 3.84,\n 'JJL': 8.3,\n 'VAH': 3.88,\n 'JJJ': 7.5,\n 'JJK': 7.43,\n 'VAD': 2.56,\n 'CYW': 4.65,\n '0QL': 5.72,\n '143': 8.22,\n 'SVX': 7.04,\n 'CYJ': 11.64,\n 'SVY': 7.1,\n 'SVZ': 6.6,\n 'CYG': 8.03,\n 'CYF': 13.54,\n 'SVV': 5.09,\n 'GL3': 2.72,\n '8SP': 14.26,\n 'CYS': 2.78,\n '004': 4.33,\n 'CYR': 10.33,\n 'PLJ': 3.71,\n 'EXY': 7.37,\n 'HL2': 3.75,\n 'A5N': 5.21,\n 'CYQ': 5.67,\n 'CZ2': 5.16,\n 'LWY': 4.12,\n 'PM3': 8.78,\n 'OHS': 6.98,\n 'OHI': 5.35,\n '3TY': 8.42,\n 'CYD': 8.55,\n 'DYS': 7.87,\n 'DAH': 6.47,\n '4IK': 11.81,\n '3EG': 3.66,\n 'AYA': 3.65,\n '4IN': 6.31,\n 'DAB': 3.48,\n '4HT': 6.03,\n 'RGL': 7.03,\n 'DAM': 2.49,\n 'NFA': 5.04,\n 'WFP': 6.07,\n '2JC': 2.97,\n 'HAR': 7.55,\n '2JG': 5.67,\n 'MH6': 1.72,\n '2JF': 9.13,\n '3FG': 4.96,\n 'MGN': 4.84,\n 'AZH': 5.36,\n 'AZK': 6.03,\n 'ZBZ': 7.79,\n 'TBG': 2.58,\n 'VAL': 2.51,\n 'MGG': 7.34,\n 'AZS': 5.61,\n 'FHL': 9.75,\n '2JH': 4.56,\n 'IEL': 7.07,\n 'FHO': 6.75,\n 'DA2': 7.79,\n 'FH7': 6.99,\n 'ME0': 4.52,\n '3GL': 4.84,\n 'MDO': 5.03,\n 'AZY': 7.37,\n 'A8E': 3.76,\n 'ZCL': 6.71,\n 'MDH': 2.58,\n 'LA2': 14.07,\n '4FW': 6.1,\n 'YCM': 5.32,\n 'MDF': 4.95,\n 'YCP': 3.01,\n 'TEF': 8.63,\n 'FGP': 4.34,\n 'UF0': 19.72,\n 'XCN': 4.57,\n 'FGL': 2.56,\n 'MF3': 6.37,\n 'MEQ': 5.13,\n 'LAA': 3.23,\n 'IGL': 5.52,\n 'MET': 4.49,\n 'NIY': 6.81,\n 'QCS': 5.18,\n 'TCQ': 8.56,\n 'MEN': 4.33,\n '4HL': 8.79,\n 'MEA': 4.95,\n 'EFC': 5.28,\n 'LAL': 2.41,\n '2HF': 5.52,\n 'KBE': 5.64,\n 'OCS': 3.94,\n 'CAF': 5.46,\n 'NC1': 11.4,\n 'NBQ': 9.82,\n 'CAB': 4.19,\n 'MBQ': 9.55,\n '193': 7.38,\n '192': 2.44,\n '0WZ': 7.61,\n 'CAS': 5.35,\n 'NB8': 11.98,\n 'OBS': 11.71,\n '1AC': 2.42,\n 'PCA': 3.48,\n 'MCL': 9.73,\n 'LBY': 7.75,\n 'GAU': 4.67,\n 'PBF': 9.75,\n 'MCG': 6.46,\n 'DDE': 6.86,\n '19W': 3.94,\n 'MD5': 9.33,\n 'MD6': 6.44,\n 'MD3': 8.41,\n 'MCS': 7.56,\n 'OBF': 3.64,\n 'UAL': 4.68,\n 'PAT': 6.05,\n 'IAM': 8.88,\n 'PAQ': 8.77,\n 'FDL': 9.49,\n 'NCB': 3.45,\n 'LCK': 9.81,\n 'DDZ': 2.52,\n '2FM': 5.54,\n 'IAR': 6.77,\n 'OAS': 4.8,\n 'HBN': 8.8,\n 'TA4': 5.55,\n '1C3': 7.43,\n 'ECX': 5.51,\n 'PF5': 6.28,\n 'RE3': 5.29,\n 'FCL': 6.25,\n 'ECC': 4.79,\n 'LDH': 7.06,\n 'NCY': 2.91,\n 'CCS': 4.58,\n 'PEC': 6.54,\n '2CO': 4.45,\n 'LE1': 2.72,\n 'HCM': 5.53,\n '07O': 8.05,\n 'HCL': 4.96,\n 'NEP': 6.94,\n 'PE1': 8.01,\n 'LEF': 4.37,\n 'FC0': 5.18,\n 'LED': 4.34,\n 'HCS': 4.09,\n 'DBU': 2.49,\n 'RE0': 5.53,\n 'LEN': 3.82,\n '1E3': 8.71,\n 'BB9': 2.56,\n 'BB8': 5.14,\n 'PCS': 5.05,\n 'BB7': 4.56,\n 'BB6': 2.62,\n 'LEU': 3.83,\n 'DBZ': 7.08,\n 'LET': 11.29,\n 'DBY': 6.46,\n 'ICY': 7.76,\n 'MAA': 2.4,\n 'CGA': 7.91,\n '5CS': 8.34,\n 'UGY': 3.7,\n 'LGY': 11.71,\n 'N10': 8.96,\n 'AAR': 6.39,\n 'FT6': 7.5,\n 'MOD': 12.62,\n '5CW': 7.21,\n 'PVH': 4.58,\n 'BBC': 6.42,\n 'YYA': 7.3,\n 'O12': 14.08,\n 'NOT': 7.15,\n 'KGC': 9.88,\n 'MP4': 5.86,\n '0CS': 4.07,\n 'MP8': 3.75,\n 'VLL': 2.54,\n 'VLM': 2.51,\n 'BCS': 8.03,\n 'MNL': 4.9,\n 'AA4': 4.47,\n 'SAC': 3.49,\n 'BCX': 2.99,\n '3CF': 6.47,\n 'SAH': 11.7,\n 'NNH': 6.86,\n 'CGU': 4.71,\n 'SIB': 12.41,\n 'TLY': 8.78,\n 'SIC': 4.81,\n 'VMS': 8.82,\n 'TMD': 6.76,\n 'MMO': 6.53,\n 'PXU': 2.46,\n '4AW': 6.22,\n 'OTH': 3.6,\n 'DLS': 6.84,\n 'MME': 4.99,\n 'DM0': 6.99,\n '0FL': 2.76,\n 'SBL': 8.96,\n 'CDV': 3.72,\n 'OTY': 6.51,\n 'PYA': 7.75,\n '2AS': 3.57,\n 'DMH': 4.92,\n 'ELY': 7.42,\n 'GVL': 9.6,\n 'FVA': 2.9,\n 'SAR': 2.48,\n '4BF': 6.92,\n 'EME': 4.69,\n 'CDE': 2.51,\n '3AR': 7.86,\n '3AH': 9.11,\n 'AC5': 2.44,\n 'FTR': 6.08,\n 'MLL': 3.76,\n 'NPH': 11.66,\n 'NPI': 6.9,\n 'DMT': 6.67,\n 'PYX': 11.3,\n 'MLE': 3.87,\n 'PYL': 9.67,\n 'ZZU': 6.94,\n 'H5M': 3.61,\n 'SCH': 4.46,\n 'DMK': 3.52,\n 'FTY': 9.07,\n '2AG': 3.7,\n 'ABA': 2.55,\n 'ZZJ': 2.44,\n 'MLZ': 6.8,\n 'MLY': 6.88,\n 'KCX': 7.28,\n 'ZZD': 8.16,\n '3A5': 5.37,\n 'LHC': 7.75,\n '9AT': 2.47,\n 'OZT': 3.4,\n 'THO': 2.62,\n 'THR': 2.5,\n 'DFI': 3.93,\n 'MKD': 6.42,\n '4CY': 4.6,\n 'SDP': 6.07,\n 'DFO': 3.94,\n '0A0': 3.45,\n '4DB': 9.73,\n 'ML3': 6.26,\n 'BG1': 8.02,\n 'SD4': 4.57,\n 'THC': 3.8,\n 'SCS': 5.48,\n 'TH5': 4.65,\n 'BFD': 5.33,\n 'AEI': 6.34,\n 'TH6': 2.85,\n 'SCY': 4.53,\n 'TIS': 4.81,\n 'SEE': 4.53,\n 'BHD': 3.48,\n 'SEB': 8.18,\n 'SEC': 2.96,\n 'SEP': 4.8,\n 'CLH': 7.13,\n 'TIH': 5.02,\n 'CLG': 13.62,\n 'SEN': 6.43,\n 'XXA': 7.34,\n 'SEL': 2.46,\n 'SE7': 4.19,\n '4CF': 7.72,\n 'G8M': 3.57,\n 'BH2': 3.51,\n 'UN2': 3.22,\n 'VR0': 10.51,\n 'MK8': 4.76,\n 'DHA': 2.32,\n 'LMQ': 4.69,\n 'SFE': 5.01,\n 'AHB': 3.47,\n 'OXX': 7.05,\n 'BIF': 9.63,\n 'IZO': 4.47,\n 'NMM': 8.25,\n '0BN': 7.0,\n 'HZP': 3.12,\n 'NMC': 4.23,\n 'DHL': 2.69,\n '9DS': 9.29,\n 'SER': 2.41,\n 'CHG': 4.2,\n 'MIR': 6.54,\n 'AGQ': 7.79,\n 'SET': 2.46,\n 'MIS': 6.32,\n '4FB': 3.08,\n '0AR': 8.46,\n 'LME': 3.99,\n 'FZN': 24.42,\n 'AGT': 9.04,\n 'IYR': 6.46,\n '9DN': 9.31,\n 'CHP': 5.75,\n 'UNK': 1.64,\n 'XX1': 9.92,\n 'AGM': 6.57,\n '0AH': 5.78,\n 'LLP': 10.22,\n '0AF': 6.72,\n '4DP': 9.28,\n 'HYP': 2.25,\n 'DIR': 5.8,\n 'LLY': 8.71,\n '0AK': 6.11,\n 'NLE': 4.67,\n 'OYL': 6.42,\n 'WVL': 4.69,\n '0A8': 8.1,\n 'NLY': 6.37,\n 'MHO': 4.89,\n 'VOL': 2.55,\n '0A1': 7.1,\n 'MHL': 3.92,\n 'NLP': 4.81,\n 'NLQ': 4.65,\n 'MHW': 2.74,\n 'BIL': 4.7,\n 'NLO': 4.8,\n 'MHU': 7.51,\n 'XW1': 9.36,\n 'LLO': 10.13,\n 'SGB': 6.88,\n 'MHV': 3.6,\n 'MHS': 4.51,\n '0A9': 5.17,\n '0LF': 9.96,\n 'HT7': 6.82,\n 'X2W': 6.6,\n 'YPZ': 9.38,\n 'I58': 6.73,\n 'FLA': 2.4,\n 'M0H': 4.83,\n 'HSL': 2.46,\n 'FLE': 6.17,\n 'KOR': 10.1,\n '1VR': 3.89,\n 'HSO': 4.56,\n 'TTS': 9.41,\n 'RVX': 7.01,\n 'TTQ': 7.71,\n 'H14': 5.27,\n 'HTI': 7.8,\n 'ONH': 6.14,\n 'LP6': 8.58,\n 'ONL': 4.83,\n 'AHH': 5.06,\n 'HS8': 7.4,\n 'HS9': 4.71,\n 'BL2': 5.82,\n 'AHP': 5.26,\n '6HN': 7.34,\n 'HRP': 5.46,\n 'POM': 3.6,\n 'WPA': 5.11,\n '2ZC': 4.29,\n 'CPC': 2.65,\n 'AIB': 2.4,\n 'XSN': 3.47,\n 'M2S': 5.28,\n 'GND': 6.67,\n 'GNC': 4.6,\n 'MVA': 2.56,\n 'OLZ': 5.32,\n 'M2L': 6.15,\n 'TRF': 6.69,\n 'NZH': 7.66,\n 'SRZ': 5.27,\n 'OLD': 10.47,\n 'CME': 5.86,\n 'CMH': 5.3,\n 'ALA': 2.38,\n 'TRQ': 7.36,\n 'PPN': 7.24,\n 'TRP': 6.07,\n 'TRO': 5.82,\n 'TRN': 5.95,\n 'NYS': 8.1,\n 'ALC': 5.26,\n 'U3X': 11.7,\n 'HVA': 2.58,\n 'TS9': 3.92,\n 'TRX': 7.27,\n 'TRW': 11.8,\n 'LPL': 7.51,\n 'GMA': 4.4,\n 'OMT': 5.07,\n 'CMT': 3.54,\n 'GME': 4.66,\n 'NYB': 6.07,\n 'PR3': 5.12,\n 'LPD': 2.48,\n 'GLU': 4.49,\n '1X6': 6.84,\n 'LPG': 2.39,\n 'GLX': 4.52,\n 'PR4': 4.52,\n 'CML': 6.16,\n 'FME': 4.52,\n 'HTR': 6.48,\n 'PR7': 4.66,\n 'Z3E': 7.2,\n 'GLZ': 2.39,\n 'BMT': 6.37,\n 'WRP': 8.16,\n 'GLY': 2.37,\n 'OMY': 6.11,\n 'MTY': 5.46,\n 'OMX': 6.15,\n 'GLN': 4.46,\n '2XA': 8.25,\n '28X': 7.84,\n '7JA': 9.46,\n 'FLT': 9.65,\n 'GLJ': 3.7,\n 'OMH': 5.26,\n 'TSY': 4.26,\n 'PRV': 4.28,\n 'CS4': 11.21,\n 'DOA': 12.33,\n '23P': 5.42,\n 'CS3': 8.24,\n '6CL': 6.47,\n 'PRR': 5.58,\n 'KST': 11.58,\n 'CS1': 7.23,\n 'PRS': 2.63,\n 'ZYJ': 11.4,\n 'IT1': 9.75,\n 'UU5': 4.98,\n 'ESB': 6.69,\n 'UU4': 2.49,\n 'ESC': 5.65,\n 'LSO': 10.58,\n 'ZYK': 11.45,\n '9NV': 8.99,\n '23F': 5.27,\n 'ORN': 4.25,\n 'HOX': 6.61,\n 'CSD': 3.95,\n 'FP9': 3.03,\n 'DO2': 4.44,\n 'SLL': 11.53,\n 'P3Q': 9.54,\n 'ORQ': 6.04,\n 'MSL': 5.21,\n 'DNP': 2.45,\n 'CSB': 3.51,\n 'WLU': 4.24,\n 'CSA': 5.7,\n 'MT2': 5.51,\n 'CSO': 3.53,\n 'TPO': 4.73,\n 'MSP': 13.11,\n '23S': 6.09,\n 'MSO': 4.96,\n 'PRO': 2.41,\n 'TPL': 5.41,\n 'DNS': 8.79,\n 'CSK': 3.91,\n 'Z70': 7.4,\n 'CSJ': 7.51,\n 'DNW': 7.97,\n 'PRK': 9.15,\n 'GSU': 11.81,\n 'LTA': 6.57,\n 'HPE': 6.63,\n 'TPQ': 6.48,\n 'PRJ': 5.26,\n 'PSW': 4.65,\n 'L3O': 3.89,\n 'CSU': 4.89,\n 'ALY': 7.38,\n 'M3L': 7.12,\n 'CSW': 3.68,\n 'XPR': 7.68,\n 'D4P': 5.66,\n 'FOE': 8.17,\n 'SLZ': 5.69,\n 'CSP': 5.26,\n 'TQI': 7.68,\n 'ALT': 2.72,\n 'CSR': 5.42,\n 'CSS': 3.61,\n 'M3R': 7.18,\n 'ALO': 2.57,\n 'R4K': 4.67,\n 'SMF': 9.0,\n 'MSA': 2.73,\n 'SMC': 3.39,\n 'CSX': 3.47,\n 'SME': 4.8,\n 'ETA': 2.4,\n 'CSZ': 3.6,\n '22G': 8.8,\n 'MSE': 4.62,\n 'ALN': 6.16,\n 'PSH': 7.26,\n 'CTE': 7.27,\n 'DON': 6.72,\n 'CTH': 3.45,\n 'U2X': 11.54,\n '6CW': 7.56,\n 'TQZ': 6.97,\n '3YM': 6.52,\n 'OSE': 4.49,\n '2VA': 9.82,\n 'TQQ': 7.76,\n 'NRG': 8.35,\n 'BPE': 7.24,\n 'F2F': 6.25,\n '1TQ': 8.58,\n 'I2M': 3.13,\n 'NVA': 3.76,\n 'R1A': 8.2,\n 'QPA': 6.95,\n 'C1X': 11.63,\n 'FRD': 5.05,\n 'HR7': 6.98,\n 'SNC': 3.93,\n 'QPH': 5.15,\n '26B': 8.39,\n 'DPQ': 6.54,\n 'DPP': 2.51,\n '2TY': 8.65,\n 'TNR': 6.88,\n 'PTH': 8.35,\n 'DPL': 3.58,\n 'APK': 8.79,\n '1TY': 8.84,\n 'HRG': 7.36,\n 'PTM': 8.74,\n '1U8': 3.62,\n 'PTR': 8.64,\n 'LVG': 3.01,\n '6FL': 4.85,\n 'SOC': 4.05,\n 'KPI': 9.79,\n 'IPG': 2.91,\n 'P2Y': 2.51,\n 'N2C': 3.55,\n 'T0I': 7.34,\n 'MPH': 5.29,\n 'R2T': 4.71,\n 'TOX': 6.78,\n 'P2Q': 9.8,\n 'GPL': 10.77,\n 'MPJ': 5.07,\n 'F2Y': 6.2,\n 'T11': 8.58,\n '9NR': 9.33,\n 'FPR': 8.85,\n '9NF': 8.93,\n 'KPY': 10.17,\n '9NE': 9.77,\n 'TOQ': 7.5,\n 'MPQ': 4.2,\n 'FPK': 3.08,\n 'HQA': 7.25,\n 'SOY': 10.94\n}\nexport const DefaultResidueRadius = 5.0\n\n// http://dx.doi.org/10.1039/b801115j (or 1.6)\nexport const CovalentRadii: { [e: number]: number | undefined } = {\n 1: 0.31, 2: 0.28, 3: 1.28, 4: 0.96, 5: 0.84, 6: 0.76, 7: 0.71, 8: 0.66, 9: 0.57, 10: 0.58, 11: 1.66, 12: 1.41, 13: 1.21, 14: 1.11, 15: 1.07, 16: 1.05, 17: 1.02, 18: 1.06, 19: 2.03, 20: 1.76, 21: 1.7, 22: 1.6, 23: 1.53, 24: 1.39, 25: 1.39, 26: 1.32, 27: 1.26, 28: 1.24, 29: 1.32, 30: 1.22, 31: 1.22, 32: 1.2, 33: 1.19, 34: 1.2, 35: 1.2, 36: 1.16, 37: 2.2, 38: 1.95, 39: 1.9, 40: 1.75, 41: 1.64, 42: 1.54, 43: 1.47, 44: 1.46, 45: 1.42, 46: 1.39, 47: 1.45, 48: 1.44, 49: 1.42, 50: 1.39, 51: 1.39, 52: 1.38, 53: 1.39, 54: 1.4, 55: 2.44, 56: 2.15, 57: 2.07, 58: 2.04, 59: 2.03, 60: 2.01, 61: 1.99, 62: 1.98, 63: 1.98, 64: 1.96, 65: 1.94, 66: 1.92, 67: 1.92, 68: 1.89, 69: 1.9, 70: 1.87, 71: 1.87, 72: 1.75, 73: 1.7, 74: 1.62, 75: 1.51, 76: 1.44, 77: 1.41, 78: 1.36, 79: 1.36, 80: 1.32, 81: 1.45, 82: 1.46, 83: 1.48, 84: 1.4, 85: 1.5, 86: 1.5, 87: 2.6, 88: 2.21, 89: 2.15, 90: 2.06, 91: 2.0, 92: 1.96, 93: 1.9, 94: 1.87, 95: 1.8, 96: 1.69, 97: 1.6, 98: 1.6, 99: 1.6, 100: 1.6, 101: 1.6, 102: 1.6, 103: 1.6, 104: 1.6, 105: 1.6, 106: 1.6, 107: 1.6, 108: 1.6, 109: 1.6, 110: 1.6, 111: 1.6, 112: 1.6, 113: 1.6, 114: 1.6, 115: 1.6, 116: 1.6, 117: 1.6, 118: 1.6\n}\nexport const DefaultCovalentRadius = 1.6\n\nexport const Valences: { [e: number]: number[] | undefined } = {\n 1: [ 1 ],\n 2: [ 0 ],\n 3: [ 1 ],\n 4: [ 2 ],\n 5: [ 3 ],\n 6: [ 4 ],\n 7: [ 3 ],\n 8: [ 2 ],\n 9: [ 1 ],\n 10: [ 0 ],\n 11: [ 1 ],\n 12: [ 2 ],\n 13: [ 6 ],\n 14: [ 6 ],\n 15: [ 3, 5, 7 ],\n 16: [ 2, 4, 6 ],\n 17: [ 1 ],\n 18: [ 0 ],\n 19: [ 1 ],\n 20: [ 2 ],\n\n 31: [ 3 ],\n 32: [ 4 ],\n 33: [ 3, 5 ],\n 34: [ 2, 4, 6 ],\n 35: [ 1 ],\n 36: [ 0 ],\n 37: [ 1 ],\n 38: [ 2 ],\n\n 49: [ 3 ],\n 50: [ 4 ],\n 51: [ 3, 5 ],\n 52: [ 2 ],\n 53: [ 1, 2, 5 ],\n 54: [ 0, 2 ],\n 55: [ 1 ],\n 56: [ 2 ],\n\n 81: [ 3 ],\n 82: [ 4 ],\n 83: [ 3 ],\n 84: [ 2 ],\n 85: [ 1 ],\n 86: [ 0 ],\n 87: [ 1 ],\n 88: [ 2 ]\n}\nexport const DefaultValence = -1\n\nexport const OuterShellElectronCounts: { [e: number]: number | undefined } = {\n1: 1, 2: 2, 3: 1, 4: 2, 5: 3, 6: 4, 7: 5, 8: 6, 9: 7, 10: 8, 11: 1, 12: 2, 13: 3, 14: 4, 15: 5, 16: 6, 17: 7, 18: 8, 19: 1, 20: 2, 21: 3, 22: 4, 23: 5, 24: 6, 25: 7, 26: 8, 27: 9, 28: 10, 29: 11, 30: 2, 31: 3, 32: 4, 33: 5, 34: 6, 35: 7, 36: 8, 37: 1, 38: 2, 39: 3, 40: 4, 41: 5, 42: 6, 43: 7, 44: 8, 45: 9, 46: 10, 47: 11, 48: 2, 49: 3, 50: 4, 51: 5, 52: 6, 53: 7, 54: 8, 55: 1, 56: 2, 57: 3, 58: 4, 59: 3, 60: 4, 61: 5, 62: 6, 63: 7, 64: 8, 65: 9, 66: 10, 67: 11, 68: 12, 69: 13, 70: 14, 71: 15, 72: 4, 73: 5, 74: 6, 75: 7, 76: 8, 77: 9, 78: 10, 79: 11, 80: 2, 81: 3, 82: 4, 83: 5, 84: 6, 85: 7, 86: 8, 87: 1, 88: 2, 89: 3, 90: 4, 91: 3, 92: 4, 93: 5, 94: 6, 95: 7, 96: 8, 97: 9, 98: 10, 99: 11, 100: 12, 101: 13, 102: 14, 103: 15, 104: 2, 105: 2, 106: 2, 107: 2, 108: 2, 109: 2, 110: 2, 111: 2, 112: 2, 113: 3, 114: 4, 115: 5, 116: 6, 117: 7, 118: 8\n}\nexport const DefaultOuterShellElectronCount = 2\n\n// http://blanco.biomol.uci.edu/Whole_residue_HFscales.txt\n// https://www.nature.com/articles/nsb1096-842\nexport const ResidueHydrophobicity: { [k: string]: [number, number, number] } = {\n // AA DGwif DGwoct Oct-IF\n 'ALA': [ 0.17, 0.50, 0.33 ],\n 'ARG': [ 0.81, 1.81, 1.00 ],\n 'ASN': [ 0.42, 0.85, 0.43 ],\n 'ASP': [ 1.23, 3.64, 2.41 ],\n 'ASH': [ -0.07, 0.43, 0.50 ],\n 'CYS': [ -0.24, -0.02, 0.22 ],\n 'GLN': [ 0.58, 0.77, 0.19 ],\n 'GLU': [ 2.02, 3.63, 1.61 ],\n 'GLH': [ -0.01, 0.11, 0.12 ],\n 'GLY': [ 0.01, 1.15, 1.14 ],\n // \"His+\": [ 0.96, 2.33, 1.37 ],\n 'HIS': [ 0.17, 0.11, -0.06 ],\n 'ILE': [ -0.31, -1.12, -0.81 ],\n 'LEU': [ -0.56, -1.25, -0.69 ],\n 'LYS': [ 0.99, 2.80, 1.81 ],\n 'MET': [ -0.23, -0.67, -0.44 ],\n 'PHE': [ -1.13, -1.71, -0.58 ],\n 'PRO': [ 0.45, 0.14, -0.31 ],\n 'SER': [ 0.13, 0.46, 0.33 ],\n 'THR': [ 0.14, 0.25, 0.11 ],\n 'TRP': [ -1.85, -2.09, -0.24 ],\n 'TYR': [ -0.94, -0.71, 0.23 ],\n 'VAL': [ 0.07, -0.46, -0.53 ]\n}\nexport const DefaultResidueHydrophobicity = [ 0.00, 0.00, 0.00 ]\n\nexport const AA1: { [k: string]: string } = {\n 'HIS': 'H',\n 'ARG': 'R',\n 'LYS': 'K',\n 'ILE': 'I',\n 'PHE': 'F',\n 'LEU': 'L',\n 'TRP': 'W',\n 'ALA': 'A',\n 'MET': 'M',\n 'PRO': 'P',\n 'CYS': 'C',\n 'ASN': 'N',\n 'VAL': 'V',\n 'GLY': 'G',\n 'SER': 'S',\n 'GLN': 'Q',\n 'TYR': 'Y',\n 'ASP': 'D',\n 'GLU': 'E',\n 'THR': 'T',\n\n 'SEC': 'U', // as per IUPAC definition\n 'PYL': 'O', // as per IUPAC definition\n}\n\nexport const AA3 = Object.keys(AA1)\n\nexport const RnaBases = [ 'A', 'C', 'T', 'G', 'U', 'I' ]\n\nexport const DnaBases = [ 'DA', 'DC', 'DT', 'DG', 'DU', 'DI' ]\n\nexport const PurinBases = [ 'A', 'G', 'I', 'DA', 'DG', 'DI' ]\n\nexport const Bases = RnaBases.concat(DnaBases)\n\nexport const WaterNames = [\n 'SOL', 'WAT', 'HOH', 'H2O', 'W', 'DOD', 'D3O', 'TIP3', 'TIP4', 'SPC'\n]\n\n// all chemical components with the word \"ion\" in their name, Sep 2016\n//\n// SET SESSION group_concat_max_len = 1000000;\n// SELECT GROUP_CONCAT(id_ ORDER BY id_ ASC SEPARATOR '\", \"') from\n// (\n// SELECT count(obj_id) as c, id_\n// FROM pdb.chem_comp WHERE name LIKE \"% ION%\"\n// GROUP BY id_\n// ) AS t1;\nexport const IonNames = [\n '118', '119', '1AL', '1CU', '2FK', '2HP', '2OF', '3CO',\n '3MT', '3NI', '3OF', '3P8', '4MO', '4PU', '543', '6MO', 'ACT', 'AG', 'AL',\n 'ALF', 'AM', 'ATH', 'AU', 'AU3', 'AUC', 'AZI', 'BA', 'BCT', 'BEF', 'BF4', 'BO4',\n 'BR', 'BS3', 'BSY', 'CA', 'CAC', 'CD', 'CD1', 'CD3', 'CD5', 'CE', 'CHT', 'CL',\n 'CO', 'CO3', 'CO5', 'CON', 'CR', 'CS', 'CSB', 'CU', 'CU1', 'CU3', 'CUA', 'CUZ',\n 'CYN', 'DME', 'DMI', 'DSC', 'DTI', 'DY', 'E4N', 'EDR', 'EMC', 'ER3', 'EU',\n 'EU3', 'F', 'FE', 'FE2', 'FPO', 'GA', 'GD3', 'GEP', 'HAI', 'HG', 'HGC', 'IN',\n 'IOD', 'IR', 'IR3', 'IRI', 'IUM', 'K', 'KO4', 'LA', 'LCO', 'LCP', 'LI', 'LU',\n 'MAC', 'MG', 'MH2', 'MH3', 'MLI', 'MLT', 'MMC', 'MN', 'MN3', 'MN5', 'MN6',\n 'MO1', 'MO2', 'MO3', 'MO4', 'MO5', 'MO6', 'MOO', 'MOS', 'MOW', 'MW1', 'MW2',\n 'MW3', 'NA', 'NA2', 'NA5', 'NA6', 'NAO', 'NAW', 'NCO', 'NET', 'NH4', 'NI',\n 'NI1', 'NI2', 'NI3', 'NO2', 'NO3', 'NRU', 'O4M', 'OAA', 'OC1', 'OC2', 'OC3',\n 'OC4', 'OC5', 'OC6', 'OC7', 'OC8', 'OCL', 'OCM', 'OCN', 'OCO', 'OF1', 'OF2',\n 'OF3', 'OH', 'OS', 'OS4', 'OXL', 'PB', 'PBM', 'PD', 'PDV', 'PER', 'PI', 'PO3',\n 'PO4', 'PR', 'PT', 'PT4', 'PTN', 'RB', 'RH3', 'RHD', 'RU', 'SB', 'SCN', 'SE4',\n 'SEK', 'SM', 'SMO', 'SO3', 'SO4', 'SR', 'T1A', 'TB', 'TBA', 'TCN', 'TEA', 'TH',\n 'THE', 'TL', 'TMA', 'TRA', 'UNX', 'V', 'VN3', 'VO4', 'W', 'WO5', 'Y1', 'YB',\n 'YB2', 'YH', 'YT3', 'ZCM', 'ZN', 'ZN2', 'ZN3', 'ZNO', 'ZO3',\n // additional ion names\n 'OHX'\n]\n\n// all chemical components with the word \"%saccharide%\" in their type, Sep 2016\n//\n// SET SESSION group_concat_max_len = 1000000;\n// select GROUP_CONCAT(id_ ORDER BY id_ ASC SEPARATOR '\", \"') from\n// (\n// SELECT count(obj_id), id_\n// FROM pdb.chem_comp WHERE type like \"%SACCHARIDE%\"\n// GROUP BY id_\n// ) AS t1;\nexport const SaccharideNames = [\n '045', '0AT', '0BD', '0MK', '0NZ', '0TS', '0V4', '0XY', '0YT', '10M',\n '147', '149', '14T', '15L', '16G', '18T', '18Y', '1AR', '1BW', '1GL', '1GN',\n '1JB', '1LL', '1NA', '1S3', '26M', '26Q', '26R', '26V', '26W', '26Y', '27C',\n '289', '291', '293', '2DG', '2F8', '2FG', '2FL', '2FP', '2GL', '2M4', '2M5',\n '32O', '34V', '3CM', '3DO', '3DY', '3FM', '3LR', '3MF', '3MG', '3SA', '3ZW',\n '46D', '46M', '46Z', '48Z', '4CQ', '4GC', '4NN', '50A', '5DI', '5GF', '5MM',\n '5RP', '5SA', '5SP', '64K', '6PG', '6SA', '7JZ', '7SA', 'A1Q', 'A2G', 'AAB',\n 'AAL', 'AAO', 'ABC', 'ABD', 'ABE', 'ABF', 'ABL', 'ACG', 'ACI', 'ACR', 'ACX',\n 'ADA', 'ADG', 'ADR', 'AF1', 'AFD', 'AFL', 'AFO', 'AFP', 'AFR', 'AGC', 'AGH',\n 'AGL', 'AHR', 'AIG', 'ALL', 'ALX', 'AMU', 'AOG', 'AOS', 'ARA', 'ARB', 'ARE',\n 'ARI', 'ASG', 'ASO', 'AXP', 'AXR', 'B0D', 'B16', 'B2G', 'B4G', 'B6D', 'B8D',\n 'B9D', 'BBK', 'BCD', 'BDG', 'BDP', 'BDR', 'BEM', 'BFP', 'BGC', 'BGL', 'BGP',\n 'BGS', 'BHG', 'BMA', 'BMX', 'BNG', 'BNX', 'BOG', 'BRI', 'BXF', 'BXP', 'BXX',\n 'BXY', 'C3X', 'C4X', 'C5X', 'CAP', 'CBI', 'CBK', 'CBS', 'CDR', 'CEG', 'CGF',\n 'CHO', 'CR1', 'CR6', 'CRA', 'CT3', 'CTO', 'CTR', 'CTT', 'D6G', 'DAF', 'DAG',\n 'DDA', 'DDB', 'DDL', 'DEL', 'DFR', 'DFX', 'DG0', 'DGC', 'DGD', 'DGM', 'DGS',\n 'DIG', 'DLF', 'DLG', 'DMU', 'DNO', 'DOM', 'DP5', 'DQQ', 'DQR', 'DR2', 'DR3',\n 'DR4', 'DRI', 'DSR', 'DT6', 'DVC', 'E4P', 'E5G', 'EAG', 'EBG', 'EBQ', 'EGA',\n 'EJT', 'EPG', 'ERE', 'ERI', 'F1P', 'F1X', 'F6P', 'FBP', 'FCA', 'FCB', 'FCT',\n 'FDP', 'FDQ', 'FFC', 'FIX', 'FMO', 'FRU', 'FSI', 'FU4', 'FUB', 'FUC', 'FUD',\n 'FUL', 'FXP', 'G16', 'G1P', 'G2F', 'G3I', 'G4D', 'G4S', 'G6D', 'G6P', 'G6S',\n 'GAC', 'GAD', 'GAL', 'GC1', 'GC4', 'GCD', 'GCN', 'GCO', 'GCS', 'GCT', 'GCU',\n 'GCV', 'GCW', 'GCX', 'GE1', 'GFG', 'GFP', 'GIV', 'GL0', 'GL2', 'GL5', 'GL6',\n 'GL7', 'GL9', 'GLA', 'GLB', 'GLC', 'GLD', 'GLF', 'GLG', 'GLO', 'GLP', 'GLS',\n 'GLT', 'GLW', 'GMH', 'GN1', 'GNX', 'GP1', 'GP4', 'GPH', 'GPM', 'GQ1', 'GQ2',\n 'GQ4', 'GS1', 'GS4', 'GSA', 'GSD', 'GTE', 'GTH', 'GTK', 'GTR', 'GTZ', 'GU0',\n 'GU1', 'GU2', 'GU3', 'GU4', 'GU5', 'GU6', 'GU8', 'GU9', 'GUF', 'GUP', 'GUZ',\n 'GYP', 'GYV', 'H2P', 'HDL', 'HMS', 'HS2', 'HSD', 'HSG', 'HSH', 'HSJ', 'HSQ',\n 'HSR', 'HSU', 'HSX', 'HSY', 'HSZ', 'IAB', 'IDG', 'IDR', 'IDS', 'IDT', 'IDU',\n 'IDX', 'IDY', 'IMK', 'IN1', 'IPT', 'ISL', 'KBG', 'KD2', 'KDA', 'KDM', 'KDO',\n 'KFN', 'KO1', 'KO2', 'KTU', 'L6S', 'LAG', 'LAI', 'LAK', 'LAO', 'LAT', 'LB2',\n 'LBT', 'LCN', 'LDY', 'LGC', 'LGU', 'LM2', 'LMT', 'LMU', 'LOG', 'LOX', 'LPK',\n 'LSM', 'LTM', 'LVZ', 'LXB', 'LXZ', 'M1F', 'M3M', 'M6P', 'M8C', 'MA1', 'MA2',\n 'MA3', 'MAB', 'MAG', 'MAL', 'MAN', 'MAT', 'MAV', 'MAW', 'MBG', 'MCU', 'MDA',\n 'MDM', 'MDP', 'MFA', 'MFB', 'MFU', 'MG5', 'MGA', 'MGL', 'MLB', 'MMA', 'MMN',\n 'MN0', 'MRP', 'MTT', 'MUG', 'MVP', 'MXY', 'N1L', 'N9S', 'NAA', 'NAG', 'NBG',\n 'NDG', 'NED', 'NG1', 'NG6', 'NGA', 'NGB', 'NGC', 'NGE', 'NGF', 'NGL', 'NGS',\n 'NGY', 'NHF', 'NM6', 'NM9', 'NTF', 'NTO', 'NTP', 'NXD', 'NYT', 'OPG', 'OPM',\n 'ORP', 'OX2', 'P3M', 'P53', 'P6P', 'PA5', 'PNA', 'PNG', 'PNW', 'PRP', 'PSJ',\n 'PSV', 'PTQ', 'QDK', 'QPS', 'QV4', 'R1P', 'R1X', 'R2B', 'R5P', 'RAA', 'RAE',\n 'RAF', 'RAM', 'RAO', 'RAT', 'RB5', 'RBL', 'RCD', 'RDP', 'REL', 'RER', 'RF5',\n 'RG1', 'RGG', 'RHA', 'RIB', 'RIP', 'RNS', 'RNT', 'ROB', 'ROR', 'RPA', 'RST',\n 'RUB', 'RUU', 'RZM', 'S6P', 'S7P', 'SA0', 'SCR', 'SDD', 'SF6', 'SF9', 'SG4',\n 'SG5', 'SG6', 'SG7', 'SGA', 'SGC', 'SGD', 'SGN', 'SGS', 'SHB', 'SHG', 'SI3',\n 'SIO', 'SOE', 'SOL', 'SSG', 'SUC', 'SUP', 'SUS', 'T6P', 'T6T', 'TAG', 'TCB',\n 'TDG', 'TGK', 'TGY', 'TH1', 'TIA', 'TM5', 'TM6', 'TM9', 'TMR', 'TMX', 'TOA',\n 'TOC', 'TRE', 'TYV', 'UCD', 'UDC', 'VG1', 'X0X', 'X1X', 'X2F', 'X4S', 'X5S',\n 'X6X', 'XBP', 'XDN', 'XDP', 'XIF', 'XIM', 'XLF', 'XLS', 'XMM', 'XUL', 'XXR',\n 'XYP', 'XYS', 'YO5', 'Z3Q', 'Z6J', 'Z9M', 'ZDC', 'ZDM'\n]\n\nexport const ProteinBackboneAtoms = [\n 'CA', 'C', 'N', 'O',\n 'O1', 'O2', 'OC1', 'OC2', 'OX1', 'OXT', 'OT1', 'OT2',\n 'H', 'H1', 'H2', 'H3', 'HA', 'HN',\n 'BB'\n]\n\nexport const NucleicBackboneAtoms = [\n 'P', 'OP1', 'OP2', 'HOP2', 'HOP3',\n \"O2'\", \"O3'\", \"O4'\", \"O5'\", \"C1'\", \"C2'\", \"C3'\", \"C4'\", \"C5'\",\n \"H1'\", \"H2'\", \"H2''\", \"HO2'\", \"H3'\", \"H4'\", \"H5'\", \"H5''\", \"HO3'\", \"HO5'\",\n 'O2*', 'O3*', 'O4*', 'O5*', 'C1*', 'C2*', 'C3*', 'C4*', 'C5*'\n]\n\nexport const ResidueTypeAtoms: { [k: number]: { [k: string]: string|string[] } } = {}\n\nResidueTypeAtoms[ ProteinBackboneType ] = {\n trace: 'CA',\n direction1: 'C',\n direction2: [ 'O', 'OC1', 'O1', 'OX1', 'OXT', 'OT1', 'OT2' ],\n backboneStart: 'N',\n backboneEnd: 'C'\n}\n\nResidueTypeAtoms[ RnaBackboneType ] = {\n trace: [ \"C4'\", 'C4*' ],\n direction1: [ \"C1'\", 'C1*' ],\n direction2: [ \"C3'\", 'C3*' ],\n backboneStart: 'P',\n backboneEnd: [ \"O3'\", 'O3*' ]\n}\n\nResidueTypeAtoms[ DnaBackboneType ] = {\n trace: [ \"C3'\", 'C3*' ],\n direction1: [ \"C2'\", 'C2*' ],\n direction2: [ \"O4'\", 'O4*' ],\n backboneStart: 'P',\n backboneEnd: [ \"O3'\", 'O3*' ]\n}\n\nResidueTypeAtoms[ CgProteinBackboneType ] = {\n trace: [ 'CA', 'BB' ],\n backboneStart: [ 'CA', 'BB' ],\n backboneEnd: [ 'CA', 'BB' ]\n}\n\nResidueTypeAtoms[ CgRnaBackboneType ] = {\n trace: [ \"C4'\", 'C4*', 'P' ],\n backboneStart: [ \"C4'\", 'C4*', 'P' ],\n backboneEnd: [ \"C4'\", 'C4*', 'P' ]\n}\n\nResidueTypeAtoms[ CgDnaBackboneType ] = {\n trace: [ \"C3'\", 'C3*', \"C2'\", 'P' ], // C2' is used in martini ff\n backboneStart: [ \"C3'\", 'C3*', \"C2'\", 'P' ],\n backboneEnd: [ \"C3'\", 'C3*', \"C2'\", 'P' ]\n}\n\nResidueTypeAtoms[ UnknownBackboneType ] = {}\n\n// Mappings taken from Meeko: https://github.com/forlilab/Meeko/blob/develop/meeko/utils/autodock4_atom_types_elements.py\nexport const PDBQTSpecialElements = {\n 'HD': 'H',\n 'HS': 'H',\n 'A': 'C',\n 'NA': 'N',\n 'NS': 'N',\n 'OA': 'O',\n 'OS': 'O',\n 'SA': 'S',\n 'G0': 'C',\n 'G1': 'C',\n 'G2': 'C',\n 'G3': 'C',\n 'CG0': 'C',\n 'CG1': 'C',\n 'CG2': 'C',\n 'CG3': 'C',\n 'W': 'O'\n}","/**\n * @file Geometry\n * @author Fred Ludlow \n * @author Alexander Rose \n */\n\nimport { Vector3 } from 'three'\n\nimport { Elements } from '../structure/structure-constants'\nimport { degToRad } from '../math/math-utils'\nimport AtomProxy from '../proxy/atom-proxy'\n\n// Changed numbering so they're mostly inline with coordination number\n// from VSEPR\nexport const enum AtomGeometry {\n Spherical = 0,\n Terminal = 1,\n Linear = 2,\n Trigonal = 3,\n Tetrahedral = 4,\n TrigonalBiPyramidal = 5,\n Octahedral = 6,\n SquarePlanar = 7, // Okay, it breaks down somewhere!\n Unknown = 8\n}\n\nexport function assignGeometry (totalCoordination: number): AtomGeometry {\n switch(totalCoordination){\n case 0:\n return AtomGeometry.Spherical\n case 1:\n return AtomGeometry.Terminal\n case 2:\n return AtomGeometry.Linear\n case 3:\n return AtomGeometry.Trigonal\n case 4:\n return AtomGeometry.Tetrahedral\n default:\n return AtomGeometry.Unknown\n }\n}\n\nexport const Angles = new Map([\n [ AtomGeometry.Linear, degToRad(180) ],\n [ AtomGeometry.Trigonal, degToRad(120) ],\n [ AtomGeometry.Tetrahedral, degToRad(109.4721) ],\n [ AtomGeometry.Octahedral, degToRad(90) ]\n])\n\n/**\n * Calculate the angles x-1-2 for all x where x is a heavy atom bonded to ap1.\n * @param {AtomProxy} ap1 First atom (angle centre)\n * @param {AtomProxy} ap2 Second atom\n * @return {number[]} Angles in radians\n */\nexport function calcAngles (ap1: AtomProxy, ap2: AtomProxy): number[] {\n let angles: number[] = []\n const d1 = new Vector3()\n const d2 = new Vector3()\n d1.subVectors(ap2 as any, ap1 as any)\n ap1.eachBondedAtom( x => {\n if (x.number !== Elements.H) {\n d2.subVectors(x as any, ap1 as any)\n angles.push(d1.angleTo(d2))\n }\n })\n return angles\n}\n\n/**\n * Find two neighbours of ap1 to define a plane (if possible) and\n * measure angle out of plane to ap2\n * @param {AtomProxy} ap1 First atom (angle centre)\n * @param {AtomProxy} ap2 Second atom (out-of-plane)\n * @return {number} Angle from plane to second atom\n */\nexport function calcPlaneAngle (ap1: AtomProxy, ap2: AtomProxy): number | undefined {\n const x1 = ap1.clone()\n\n const v12 = new Vector3()\n v12.subVectors(ap2 as any, ap1 as any)\n\n const neighbours = [new Vector3(), new Vector3()]\n let ni = 0\n ap1.eachBondedAtom( x => {\n if (ni > 1) { return }\n if (x.number !== Elements.H) {\n x1.index = x.index\n neighbours[ni++].subVectors(x as any, ap1 as any)\n }\n })\n if (ni === 1) {\n x1.eachBondedAtom( x => {\n if (ni > 1) { return }\n if (x.number !== Elements.H && x.index !== ap1.index){\n neighbours[ni++].subVectors(x as any, ap1 as any)\n }\n })\n }\n if (ni !== 2) {\n return\n }\n\n const cp = neighbours[0].cross(neighbours[1])\n return Math.abs((Math.PI / 2) - cp.angleTo(v12))\n}\n","/**\n * @file Valence Model\n * @author Fred Ludlow \n * @author Alexander Rose \n */\n\n/**\n * Reworked ValenceModel\n *\n * TODO:\n * Ensure proper treatment of disorder/models. e.g. V257 N in 5vim\n * Formal charge of 255 for SO4 anion (e.g. 5ghl)\n * Have removed a lot of explicit features (as I think they're more\n * generally captured by better VM).\n * Could we instead have a \"delocalised negative/positive\" charge\n * feature and flag these up?\n *\n */\nimport { Data } from '../structure/data'\nimport AtomProxy from '../proxy/atom-proxy'\nimport { AtomGeometry, assignGeometry } from './geometry'\nimport { Elements } from '../structure/structure-constants'\n\n/**\n * Are we involved in some kind of pi system. Either explicitly forming\n * double bond or N, O next to a double bond, except:\n *\n * N,O with degree 4 cannot be conjugated.\n * N,O adjacent to P=O or S=O do not qualify (keeps sulfonamide N sp3 geom)\n */\nfunction isConjugated (a: AtomProxy) {\n const _bp = a.structure.getBondProxy()\n const atomicNumber = a.number\n const hetero = atomicNumber === Elements.O || atomicNumber === Elements.N\n\n if (hetero && a.bondCount === 4) {\n return false\n }\n\n let flag = false\n\n a.eachBond(b => {\n if (b.bondOrder > 1) {\n flag = true\n return\n }\n if (hetero) {\n const a2 = b.getOtherAtom(a)\n\n a2.eachBond(b2 => {\n if (b2.bondOrder > 1) {\n const atomicNumber2 = a2.number\n if (\n (atomicNumber2 === Elements.P || atomicNumber2 === Elements.S) &&\n b2.getOtherAtom(a2).number === Elements.O\n ) {\n return\n }\n flag = true\n }\n }, _bp) // Avoid reuse of structure._bp\n }\n })\n\n return flag\n}\n\n/* function hasExplicitCharge(r: ResidueProxy) {\n let flag = false\n r.eachAtom(a => {\n if (a.formalCharge != null && a.formalCharge !== 0) flag = true\n })\n return flag\n}\n\nfunction hasExplicitHydrogen(r: ResidueProxy) {\n let flag = false\n r.eachAtom(a => {\n if (a.number === Elements.H) flag = true\n })\n return flag\n} */\n\nexport function explicitValence (a: AtomProxy) {\n let v = 0\n a.eachBond(b => v += b.bondOrder)\n return v\n}\n\n/**\n * Attempts to produce a consistent charge and implicit\n * H-count for an atom.\n *\n * If both params.assignCharge and params.assignH, this\n * approximately followsthe rules described in\n * https://docs.eyesopen.com/toolkits/python/oechemtk/valence.html#openeye-hydrogen-count-model\n *\n * If only charge or hydrogens are to be assigned it takes\n * a much simpler view and deduces one from the other\n *\n * @param {AtomProxy} a Atom to analyze\n * @param {assignChargeHParams} params What to assign\n */\nexport function calculateHydrogensCharge (a: AtomProxy, params: ValenceModelParams) {\n const hydrogenCount = a.bondToElementCount(Elements.H)\n let charge = a.formalCharge || 0\n\n const assignCharge = (params.assignCharge === 'always' ||\n (params.assignCharge === 'auto' && charge === 0))\n const assignH = (params.assignH === 'always' ||\n (params.assignH === 'auto' && hydrogenCount === 0))\n\n const degree = a.bondCount\n const valence = explicitValence(a)\n\n const conjugated = isConjugated(a)\n const multiBond = (valence - degree > 0)\n\n\n let implicitHCount = 0\n let geom = AtomGeometry.Unknown\n\n switch (a.number) {\n case Elements.H:\n if (assignCharge){\n if (degree === 0){\n charge = 1\n geom = AtomGeometry.Spherical\n } else if (degree === 1) {\n charge = 0\n geom = AtomGeometry.Terminal\n }\n }\n break\n\n case Elements.C:\n // TODO: Isocyanide?\n if (assignCharge) {\n charge = 0 // Assume carbon always neutral\n }\n if (assignH) {\n // Carbocation/carbanion are 3-valent\n implicitHCount = Math.max(0, 4 - valence - Math.abs(charge))\n }\n // Carbocation is planar, carbanion is tetrahedral\n geom = assignGeometry(degree + implicitHCount + Math.max(0, -charge))\n break\n\n case Elements.N:\n if (assignCharge) {\n if (!assignH) { // Trust input H explicitly:\n charge = valence - 3\n } else if (conjugated && valence < 4) {\n // Neutral unless amidine/guanidine double-bonded N:\n if (degree - hydrogenCount === 1 && valence - hydrogenCount === 2) {\n charge = 1\n } else {\n charge = 0\n }\n } else {\n // Sulfonamide nitrogen and classed as sp3 in conjugation model but\n // they won't be charged\n // Don't assign charge to nitrogens bound to metals\n let flag = false\n a.eachBondedAtom(ba => {\n if (ba.number === Elements.S || ba.isMetal()) flag = true\n })\n if (flag) charge = 0\n else charge = 1\n // TODO: Planarity sanity check?\n }\n\n }\n\n if (assignH) {\n // NH4+ -> 4, 1' amide -> 2, nitro N/N+ depiction -> 0\n implicitHCount = Math.max(0, 3 - valence + charge)\n }\n\n if (conjugated && !multiBond) {\n // Amide, anilinic N etc. cannot consider lone-pair for geometry purposes\n // Anilinic N geometry is depenent on ring electronics, for our purposes we\n // assume it's trigonal!\n geom = assignGeometry(degree + implicitHCount - charge)\n } else {\n // Everything else, pyridine, amine, nitrile, lp plays normal role:\n geom = assignGeometry(degree + implicitHCount + 1 - charge)\n }\n break\n\n case Elements.O:\n if (assignCharge) {\n if (!assignH) {\n charge = valence - 2 //\n }\n if (valence === 1) {\n a.eachBondedAtom(ba => {\n ba.eachBond(b => {\n const oa = b.getOtherAtom(ba)\n if (oa.index !== a.index && oa.number === Elements.O && b.bondOrder === 2){\n charge = -1\n }\n })\n })\n }\n }\n if (assignH) {\n // ethanol -> 1, carboxylate -> -1\n implicitHCount = Math.max(0, 2 - valence + charge)\n }\n if (conjugated && !multiBond){\n // carboxylate OH, phenol OH, one lone-pair taken up with conjugation\n geom = assignGeometry(degree + implicitHCount - charge + 1)\n } else {\n // Carbonyl (trigonal)\n geom = assignGeometry(degree + implicitHCount - charge + 2)\n }\n break\n\n // Only handles thiols/thiolates/thioether/sulfonium. Sulfoxides and higher\n // oxidiation states are assumed neutral S (charge carried on O if required)\n case Elements.S:\n if (assignCharge) {\n if (!assignH) {\n if (valence <= 3 && !a.bondToElementCount(Elements.O)) {\n charge = valence - 2 // e.g. explicitly deprotonated thiol\n } else {\n charge = 0\n }\n }\n }\n if (assignH){\n if (valence < 2){\n implicitHCount = Math.max(0, 2 - valence + charge)\n }\n }\n if (valence <= 3){\n // Thiol, thiolate, tioether -> tetrahedral\n geom = assignGeometry(degree + implicitHCount - charge + 2)\n }\n\n break\n\n case Elements.F:\n case Elements.CL:\n case Elements.BR:\n case Elements.I:\n case Elements.AT:\n // Never implicitly protonate halides\n if (assignCharge) {\n charge = valence - 1\n }\n break\n\n case Elements.LI:\n case Elements.NA:\n case Elements.K:\n case Elements.RB:\n case Elements.CS:\n case Elements.FR:\n if (assignCharge) {\n charge = 1 - valence\n }\n break\n\n case Elements.BE:\n case Elements.MG:\n case Elements.CA:\n case Elements.SR:\n case Elements.BA:\n case Elements.RA:\n if (assignCharge) {\n charge = 2 - valence\n }\n break\n\n default:\n console.warn('Requested charge, protonation for an unhandled element', a.element)\n }\n\n return [ charge, implicitHCount, implicitHCount + hydrogenCount, geom ]\n}\n\n\nexport interface ValenceModel {\n charge: Int8Array,\n implicitH: Int8Array,\n totalH: Int8Array,\n idealGeometry: Int8Array\n}\n\nexport interface ValenceModelParams {\n assignCharge: string,\n assignH: string\n}\n\nexport function ValenceModel (data: Data, params: ValenceModelParams) {\n const structure = data.structure\n const n = structure.atomCount\n\n const charge = new Int8Array(n)\n const implicitH = new Int8Array(n)\n const totalH = new Int8Array(n)\n const idealGeometry = new Int8Array(n)\n\n structure.eachAtom(a => {\n const i = a.index\n const [ chg, implH, totH, geom ] = calculateHydrogensCharge(a, params)\n charge[ i ] = chg\n implicitH[ i ] = implH\n totalH[ i ] = totH\n idealGeometry[ i ] = geom\n })\n\n return { charge, implicitH, totalH, idealGeometry }\n}","\nimport Structure from './structure'\nimport SpatialHash from '../geometry/spatial-hash'\nimport { ValenceModel } from '../chemistry/valence-model'\n\nexport interface Data {\n structure: Structure\n '@spatialLookup': SpatialHash | undefined\n '@valenceModel': ValenceModel | undefined\n}\n\nexport function createData(structure: Structure): Data {\n return {\n structure,\n '@spatialLookup': undefined,\n '@valenceModel': undefined\n }\n}\n\nexport function spatialLookup(data: Data): SpatialHash {\n if (data['@spatialLookup']) return data['@spatialLookup']!\n const lookup = new SpatialHash(data.structure.atomStore, data.structure.boundingBox)\n data['@spatialLookup'] = lookup\n return lookup\n}\n\nexport function valenceModel(data: Data): ValenceModel {\n if (data['@valenceModel']) return data['@valenceModel']!\n const valenceModel = ValenceModel(data, {assignCharge: 'auto', assignH: 'auto'})\n data['@valenceModel'] = valenceModel\n return valenceModel\n}\n","/**\n * @file Functional Groups\n * @author Alexander Rose \n */\n\nimport AtomProxy from '../proxy/atom-proxy'\nimport { Elements } from '../structure/structure-constants'\n\n/**\n * Nitrogen in a quaternary amine\n */\nexport function isQuaternaryAmine (a: AtomProxy) {\n return (\n a.number === 7 &&\n a.bondCount === 4 &&\n a.bondToElementCount(Elements.H) === 0\n )\n}\n\n/**\n * Nitrogen in a tertiary amine\n */\nexport function isTertiaryAmine (a: AtomProxy, idealValence: number) {\n return (\n a.number === 7 &&\n a.bondCount >= 3 &&\n idealValence === 3\n )\n}\n\n/**\n * Nitrogen in an imide\n */\nexport function isImide (a: AtomProxy) {\n let flag = false\n if (a.number === Elements.N && (a.bondCount - a.bondToElementCount(Elements.H)) === 2) {\n let carbonylCount = 0\n a.eachBondedAtom(ba => {\n if (isCarbonyl(ba)) ++carbonylCount\n })\n flag = carbonylCount === 2\n }\n return flag\n}\n\n/**\n * Nitrogen in an amide\n */\nexport function isAmide (a: AtomProxy) {\n let flag = false\n if (a.number === Elements.N && (a.bondCount - a.bondToElementCount(Elements.H)) === 2) {\n let carbonylCount = 0\n a.eachBondedAtom(ba => {\n if (isCarbonyl(ba)) ++carbonylCount\n })\n flag = carbonylCount === 1\n }\n return flag\n}\n\n/**\n * Sulfur in a sulfonium group\n */\nexport function isSulfonium (a: AtomProxy) {\n return (\n a.number === 16 &&\n a.bondCount === 3 &&\n a.bondToElementCount(Elements.H) === 0\n )\n}\n\n/**\n * Sulfur in a sulfonic acid or sulfonate group\n */\nexport function isSulfonicAcid (a: AtomProxy) {\n return (\n a.number === 16 &&\n a.bondToElementCount(Elements.O) === 3\n )\n}\n\n/**\n * Sulfur in a sulfate group\n */\nexport function isSulfate (a: AtomProxy) {\n return (\n a.number === 16 &&\n a.bondToElementCount(Elements.O) === 4\n )\n}\n\n/**\n * Phosphor in a phosphate group\n */\nexport function isPhosphate (a: AtomProxy) {\n return (\n a.number === 15 &&\n a.bondToElementCount(Elements.O) === a.bondCount\n )\n}\n\n/**\n * Halogen with one bond to a carbon\n */\nexport function isHalocarbon (a: AtomProxy) {\n return (\n a.isHalogen() &&\n a.bondCount === 1 &&\n a.bondToElementCount(Elements.C) === 1\n )\n}\n\n/**\n * Carbon in a carbonyl/acyl group\n */\nexport function isCarbonyl (a: AtomProxy) {\n let flag = false\n if (a.number === Elements.C) {\n a.eachBond(b => {\n if (b.bondOrder === 2 && b.getOtherAtom(a).number === Elements.O) {\n flag = true\n }\n })\n }\n return flag\n}\n\n/**\n * Carbon in a carboxylate group\n */\nexport function isCarboxylate (a: AtomProxy) {\n let terminalOxygenCount = 0\n if (\n a.number === 6 &&\n a.bondToElementCount(Elements.O) === 2 &&\n a.bondToElementCount(Elements.C) === 1\n ) {\n a.eachBondedAtom(ba => {\n if (ba.number === 8 && ba.bondCount - ba.bondToElementCount(Elements.H) === 1) {\n ++terminalOxygenCount\n }\n })\n }\n return terminalOxygenCount === 2\n}\n\n/**\n * Carbon in a guanidine group\n */\nexport function isGuanidine (a: AtomProxy) {\n let terminalNitrogenCount = 0\n if (\n a.number === 6 &&\n a.bondCount === 3 &&\n a.bondToElementCount(Elements.N) === 3\n ) {\n a.eachBondedAtom(ba => {\n if (ba.bondCount - ba.bondToElementCount(Elements.H) === 1) {\n ++terminalNitrogenCount\n }\n })\n }\n return terminalNitrogenCount === 2\n}\n\n/**\n * Carbon in a acetamidine group\n */\nexport function isAcetamidine (a: AtomProxy) {\n let terminalNitrogenCount = 0\n if (\n a.number === 6 &&\n a.bondCount === 3 &&\n a.bondToElementCount(Elements.N) === 2 &&\n a.bondToElementCount(Elements.C) === 1\n ) {\n a.eachBondedAtom(ba => {\n if (ba.bondCount - ba.bondToElementCount(Elements.H) === 1) {\n ++terminalNitrogenCount\n }\n })\n }\n return terminalNitrogenCount === 2\n}\n\nconst PolarElements = [\n Elements.N, Elements.O, Elements.S,\n Elements.F, Elements.CL, Elements.BR, Elements.I\n]\n\nexport function isPolar (a: AtomProxy) {\n return PolarElements.includes(a.number)\n}\n\nexport function hasPolarNeighbour (a: AtomProxy) {\n let flag = false\n a.eachBondedAtom(ba => {\n if (isPolar(ba)) flag = true\n })\n return flag\n}\n\nexport function hasAromaticNeighbour (a: AtomProxy) {\n let flag = false\n a.eachBondedAtom(function (bap) {\n if (bap.aromatic) flag = true\n })\n return flag\n}\n","/**\n * @file Charged\n * @author Alexander Rose \n * @author Fred Ludlow \n */\n\nimport { Vector3 } from 'three'\n\nimport { defaults } from '../../utils'\nimport { radToDeg } from '../../math/math-utils'\nimport Structure from '../../structure/structure'\nimport { AA3, Bases, Elements } from '../../structure/structure-constants'\nimport { valenceModel } from '../../structure/data'\nimport {\n isGuanidine, isAcetamidine, isSulfonicAcid, isPhosphate, isSulfate, isCarboxylate\n} from '../functional-groups'\nimport {\n Features, FeatureType, FeatureGroup,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\n\nconst PositvelyCharged = [ 'ARG', 'HIS', 'LYS' ]\nconst NegativelyCharged = [ 'GLU', 'ASP' ]\n\nexport function addPositiveCharges (structure: Structure, features: Features) {\n const { charge } = valenceModel(structure.data)\n const atomInGroupDict: { [atomIndex: number]: true } = {}\n\n structure.eachResidue(r => {\n if (PositvelyCharged.includes(r.resname)) {\n const state = createFeatureState(FeatureType.PositiveCharge)\n r.eachAtom(a => {\n if (a.number === Elements.N && a.isSidechain()) {\n addAtom(state, a)\n }\n })\n addFeature(features, state)\n } else if(!AA3.includes(r.resname) && !r.isNucleic()) {\n r.eachAtom(a => {\n let addGroup = false\n const state = createFeatureState(FeatureType.PositiveCharge)\n if (isGuanidine(a)) {\n state.group = FeatureGroup.Guanidine\n addGroup = true\n } else if (isAcetamidine(a)) {\n state.group = FeatureGroup.Acetamidine\n addGroup = true\n }\n if (addGroup) {\n a.eachBondedAtom(a => {\n if (a.number === Elements.N) {\n atomInGroupDict[a.index] = true\n addAtom(state, a)\n }\n })\n addFeature(features, state)\n }\n })\n r.eachAtom(a => {\n const state = createFeatureState(FeatureType.PositiveCharge)\n if (charge[a.index] > 0) {\n if (!atomInGroupDict[a.index]) {\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n })\n }\n })\n}\n\nexport function addNegativeCharges (structure: Structure, features: Features) {\n const { charge } = valenceModel(structure.data)\n const atomInGroupDict: { [atomIndex: number]: true } = {}\n\n structure.eachResidue(r => {\n if (NegativelyCharged.includes(r.resname)) {\n const state = createFeatureState(FeatureType.NegativeCharge)\n r.eachAtom(a => {\n if (a.number === Elements.O && a.isSidechain()) {\n addAtom(state, a)\n }\n })\n addFeature(features, state)\n } else if (Bases.includes(r.resname)) {\n const state = createFeatureState(FeatureType.NegativeCharge)\n r.eachAtom(a => {\n if (isPhosphate(a)) {\n state.group = FeatureGroup.Phosphate\n a.eachBondedAtom(a => {\n if (a.number === Elements.O) addAtom(state, a)\n })\n addFeature(features, state)\n }\n })\n } else if(!AA3.includes(r.resname) && !Bases.includes(r.resname)) {\n r.eachAtom(a => {\n let addGroup = false\n const state = createFeatureState(FeatureType.NegativeCharge)\n if (isSulfonicAcid(a)) {\n state.group = FeatureGroup.SulfonicAcid\n addGroup = true\n } else if (isPhosphate(a)) {\n state.group = FeatureGroup.Phosphate\n addGroup = true\n } else if (isSulfate(a)) {\n state.group = FeatureGroup.Sulfate\n addGroup = true\n } else if (isCarboxylate(a)) {\n state.group = FeatureGroup.Carboxylate\n addGroup = true\n }\n if (addGroup) {\n a.eachBondedAtom(a => {\n if (a.number === Elements.O) {\n atomInGroupDict[a.index] = true\n addAtom(state, a)\n }\n })\n addFeature(features, state)\n }\n })\n r.eachAtom(a => {\n const state = createFeatureState(FeatureType.NegativeCharge)\n if (charge[a.index] < 0) {\n if (!atomInGroupDict[a.index]) {\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n })\n }\n })\n}\n\nexport function addAromaticRings (structure: Structure, features: Features) {\n const a = structure.getAtomProxy()\n structure.eachResidue(r => {\n const rings = r.getAromaticRings()\n if (rings) {\n const offset = r.atomOffset\n rings.forEach(ring => {\n const state = createFeatureState(FeatureType.AromaticRing)\n ring.forEach(i => {\n a.index = i + offset\n addAtom(state, a)\n })\n addFeature(features, state)\n })\n }\n })\n}\n\nfunction isIonicInteraction (ti: FeatureType, tj: FeatureType) {\n return (\n (ti === FeatureType.NegativeCharge && tj === FeatureType.PositiveCharge) ||\n (ti === FeatureType.PositiveCharge && tj === FeatureType.NegativeCharge)\n )\n}\n\nfunction isPiStacking (ti: FeatureType, tj: FeatureType) {\n return ti === FeatureType.AromaticRing && tj === FeatureType.AromaticRing\n}\n\nfunction isCationPi (ti: FeatureType, tj: FeatureType) {\n return (\n (ti === FeatureType.AromaticRing && tj === FeatureType.PositiveCharge) ||\n (ti === FeatureType.PositiveCharge && tj === FeatureType.AromaticRing)\n )\n}\n\nexport interface ChargedContactsParams {\n maxIonicDist?: number\n maxPiStackingDist?: number\n maxPiStackingOffset?: number\n maxPiStackingAngle?: number\n maxCationPiDist?: number\n maxCationPiOffset?: number\n masterModelIndex?: number\n}\n\nexport function addChargedContacts (structure: Structure, contacts: Contacts, params: ChargedContactsParams = {}) {\n const maxIonicDist = defaults(params.maxIonicDist, ContactDefaultParams.maxIonicDist)\n const maxPiStackingDist = defaults(params.maxPiStackingDist, ContactDefaultParams.maxPiStackingDist)\n const maxPiStackingOffset = defaults(params.maxPiStackingOffset, ContactDefaultParams.maxPiStackingOffset)\n const maxPiStackingAngle = defaults(params.maxPiStackingAngle, ContactDefaultParams.maxPiStackingAngle)\n const maxCationPiDist = defaults(params.maxCationPiDist, ContactDefaultParams.maxCationPiDist)\n const maxCationPiOffset = defaults(params.maxCationPiOffset, ContactDefaultParams.maxCationPiOffset)\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const maxDistance = Math.max(maxIonicDist + 2, maxPiStackingDist, maxCationPiDist)\n // const maxSaltBridgeDistSq = maxSaltBridgeDist * maxSaltBridgeDist\n const maxPiStackingDistSq = maxPiStackingDist * maxPiStackingDist\n const maxCationPiDistSq = maxCationPiDist * maxCationPiDist\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const ax = structure.atomStore.x\n const ay = structure.atomStore.y\n const az = structure.atomStore.z\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n const areAtomSetsWithinDist = function (atomSet1: number[], atomSet2: number[], maxDist: number) {\n const sn = atomSet1.length\n const sm = atomSet2.length\n for (let si = 0; si < sn; ++si) {\n ap1.index = atomSet1[ si ]\n for (let sj = 0; sj < sm; ++sj) {\n ap2.index = atomSet2[ sj ]\n if (ap1.distanceTo(ap2) <= maxDist) {\n return true\n }\n }\n }\n return false\n }\n\n const v1 = new Vector3()\n const v2 = new Vector3()\n const v3 = new Vector3()\n const d1 = new Vector3()\n const d2 = new Vector3()\n const n1 = new Vector3()\n const n2 = new Vector3()\n\n const getNormal = function (atoms: number[], normal: Vector3) {\n v1.set(ax[ atoms[ 0 ] ], ay[ atoms[ 0 ] ], az[ atoms[ 0 ] ])\n v2.set(ax[ atoms[ 1 ] ], ay[ atoms[ 1 ] ], az[ atoms[ 1 ] ])\n v3.set(ax[ atoms[ 2 ] ], ay[ atoms[ 2 ] ], az[ atoms[ 2 ] ])\n d1.subVectors(v1, v2)\n d2.subVectors(v1, v3)\n normal.crossVectors(d1, d2)\n }\n\n const getOffset = function (i: number, j: number, normal: Vector3) {\n v1.set(x[ i ], y[ i ], z[ i ])\n v2.set(x[ j ], y[ j ], z[ j ])\n return v1.sub(v2).projectOnPlane(normal).add(v2).distanceTo(v2)\n }\n\n const add = function (i: number, j: number, ct: ContactType) {\n featureSet.setBits(i, j)\n contactStore.addContact(i, j, ct)\n }\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxDistance, (j, dSq) => {\n if (j <= i) return\n\n ap1.index = atomSets[ i ][ 0 ]\n ap2.index = atomSets[ j ][ 0 ]\n\n if (invalidAtomContact(ap1, ap2, masterIdx)) return\n\n const ti = types[ i ]\n const tj = types[ j ]\n\n if (isIonicInteraction(ti, tj)) {\n if (areAtomSetsWithinDist(atomSets[ i ], atomSets[ j ], maxIonicDist)) {\n add(i, j, ContactType.IonicInteraction)\n }\n } else if (isPiStacking(ti, tj)) {\n if (dSq <= maxPiStackingDistSq) {\n getNormal(atomSets[ i ], n1)\n getNormal(atomSets[ j ], n2)\n\n const angle = radToDeg(n1.angleTo(n2))\n const offset = Math.min(getOffset(i, j, n2), getOffset(j, i, n1))\n if (offset <= maxPiStackingOffset) {\n if (angle <= maxPiStackingAngle || angle >= 180 - maxPiStackingAngle) {\n add(i, j, ContactType.PiStacking) // parallel\n } else if (angle <= maxPiStackingAngle + 90 && angle >= 90 - maxPiStackingAngle) {\n add(i, j, ContactType.PiStacking) // t-shaped\n }\n }\n }\n } else if (isCationPi(ti, tj)) {\n if (dSq <= maxCationPiDistSq) {\n const [ l, k ] = ti === FeatureType.AromaticRing ? [ i, j ] : [ j, i ]\n\n getNormal(atomSets[ l ], n1)\n const offset = getOffset(k, l, n1)\n if (offset <= maxCationPiOffset) {\n add(l, k, ContactType.CationPi)\n }\n }\n }\n })\n }\n}\n","/**\n * @file Hydrogen Bonds\n * @author Alexander Rose \n * @author Fred Ludlow \n */\nimport { defaults } from '../../utils'\nimport { degToRad } from '../../math/math-utils'\nimport Structure from '../../structure/structure'\nimport AtomProxy from '../../proxy/atom-proxy'\nimport { valenceModel } from '../../structure/data'\nimport { Elements } from '../../structure/structure-constants'\nimport { Angles, AtomGeometry, calcAngles, calcPlaneAngle } from '../geometry'\nimport {\n Features, FeatureType,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\n\n\n// Geometric characteristics of hydrogen bonds involving sulfur atoms in proteins\n// https://doi.org/10.1002/prot.22327\n\n// Satisfying Hydrogen Bonding Potential in Proteins (HBPLUS)\n// https://doi.org/10.1006/jmbi.1994.1334\n// http://www.csb.yale.edu/userguides/datamanip/hbplus/hbplus_descrip.html\n\n/**\n * Potential hydrogen donor\n */\nexport function addHydrogenDonors (structure: Structure, features: Features) {\n const { totalH } = valenceModel(structure.data)\n\n structure.eachAtom(a => {\n const state = createFeatureState(FeatureType.HydrogenDonor)\n\n const an = a.number\n if (isHistidineNitrogen(a)) {\n // include both nitrogen atoms in histidine due to\n // their often ambiguous protonation assignment\n addAtom(state, a)\n addFeature(features, state)\n } else if (\n totalH[ a.index ] > 0 &&\n (an === Elements.N || an === Elements.O || an === Elements.S)\n ) {\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\n/**\n * Weak hydrogen donor.\n */\nexport function addWeakHydrogenDonors (structure: Structure, features: Features) {\n const { totalH } = valenceModel(structure.data)\n\n structure.eachAtom(a => {\n if (\n a.number === Elements.C &&\n totalH[ a.index ] > 0 &&\n (\n a.bondToElementCount(Elements.N) > 0 ||\n a.bondToElementCount(Elements.O) > 0 ||\n inAromaticRingWithElectronNegativeElement(a)\n )\n ) {\n const state = createFeatureState(FeatureType.WeakHydrogenDonor)\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\nfunction inAromaticRingWithElectronNegativeElement (a: AtomProxy) {\n if (!a.isAromatic()) return false\n\n const ringData = a.residueType.getRings()\n if (!ringData) return false\n\n let hasElement = false\n const rings = ringData.rings\n rings.forEach(ring => {\n if (hasElement) return // already found one\n if (ring.some(idx => (a.index - a.residueAtomOffset) === idx)) { // in ring\n hasElement = ring.some(idx => {\n const atomTypeId = a.residueType.atomTypeIdList[ idx ]\n const number = a.atomMap.get(atomTypeId).number\n return number === Elements.N || number === Elements.O\n })\n }\n })\n\n return hasElement\n}\n\n/**\n * Potential hydrogen acceptor\n */\nexport function addHydrogenAcceptors (structure: Structure, features: Features) {\n const { charge, implicitH, idealGeometry } = valenceModel(structure.data)\n\n structure.eachAtom(a => {\n const state = createFeatureState(FeatureType.HydrogenAcceptor)\n\n const an = a.number\n if (an === Elements.O) {\n // Basically assume all oxygen atoms are acceptors!\n addAtom(state, a)\n addFeature(features, state)\n }else if (an === Elements.N) {\n if (isHistidineNitrogen(a)) {\n // include both nitrogen atoms in histidine due to\n // their often ambiguous protonation assignment\n addAtom(state, a)\n addFeature(features, state)\n } else if (charge[ a.index ] < 1){\n // Neutral nitrogen might be an acceptor\n // It must have at least one lone pair not conjugated\n const totalBonds = a.bondCount + implicitH[ a.index ]\n const ig = idealGeometry[ a.index ]\n if (\n (ig === AtomGeometry.Tetrahedral && totalBonds < 4) ||\n (ig === AtomGeometry.Trigonal && totalBonds < 3) ||\n (ig === AtomGeometry.Linear && totalBonds < 2)\n ) {\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n }else if (an === 16) { // S\n if (a.resname === 'CYS' || a.resname === 'MET' || a.formalCharge === -1) {\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n })\n}\n\n/**\n * Atom that is only bound to carbon or hydrogen\n */\n// function isHydrocarbon (atom: AtomProxy) {\n// let flag = true\n// atom.eachBondedAtom(ap => {\n// const e = ap.element\n// if (e !== 'C' && e !== 'H') flag = false\n// })\n// return flag\n// }\n\nfunction isHistidineNitrogen (ap: AtomProxy) {\n return ap.resname === 'HIS' && ap.number == Elements.N && ap.isRing()\n}\n\nfunction isBackboneHydrogenBond (ap1: AtomProxy, ap2: AtomProxy) {\n return ap1.isBackbone() && ap2.isBackbone()\n}\n\nfunction isWaterHydrogenBond (ap1: AtomProxy, ap2: AtomProxy) {\n return ap1.isWater() && ap2.isWater()\n}\n\nfunction isHydrogenBond (ti: FeatureType, tj: FeatureType) {\n return (\n (ti === FeatureType.HydrogenAcceptor && tj === FeatureType.HydrogenDonor) ||\n (ti === FeatureType.HydrogenDonor && tj === FeatureType.HydrogenAcceptor)\n )\n}\n\nfunction isWeakHydrogenBond (ti: FeatureType, tj: FeatureType){\n return (\n (ti === FeatureType.WeakHydrogenDonor && tj === FeatureType.HydrogenAcceptor) ||\n (ti === FeatureType.HydrogenAcceptor && tj === FeatureType.WeakHydrogenDonor)\n )\n}\n\nfunction getHydrogenBondType (ap1: AtomProxy, ap2: AtomProxy) {\n if (isWaterHydrogenBond(ap1, ap2)) {\n return ContactType.WaterHydrogenBond\n } else if (isBackboneHydrogenBond(ap1, ap2)) {\n return ContactType.BackboneHydrogenBond\n } else {\n return ContactType.HydrogenBond\n }\n}\n\nexport interface HydrogenBondParams {\n maxHbondDist?: number\n maxHbondSulfurDist?: number\n maxHbondAccAngle?: number\n maxHbondDonAngle?: number\n maxHbondAccPlaneAngle?: number\n maxHbondDonPlaneAngle?: number\n backboneHbond?: boolean\n waterHbond?: boolean\n masterModelIndex?: number\n}\n\n/**\n * All pairs of hydrogen donor and acceptor atoms\n */\nexport function addHydrogenBonds (structure: Structure, contacts: Contacts, params: HydrogenBondParams = {}) {\n const maxHbondDist = defaults(params.maxHbondDist, ContactDefaultParams.maxHbondDist)\n const maxHbondSulfurDist = defaults(params.maxHbondSulfurDist, ContactDefaultParams.maxHbondSulfurDist)\n const maxHbondAccAngle = degToRad(defaults(params.maxHbondAccAngle, ContactDefaultParams.maxHbondAccAngle))\n const maxHbondDonAngle = degToRad(defaults(params.maxHbondDonAngle, ContactDefaultParams.maxHbondDonAngle))\n const maxHbondAccPlaneAngle = degToRad(defaults(params.maxHbondAccPlaneAngle, ContactDefaultParams.maxHbondAccPlaneAngle))\n const maxHbondDonPlaneAngle = degToRad(defaults(params.maxHbondDonPlaneAngle, ContactDefaultParams.maxHbondDonPlaneAngle))\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const maxDist = Math.max(maxHbondDist, maxHbondSulfurDist)\n const maxHbondDistSq = maxHbondDist * maxHbondDist\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const { idealGeometry } = valenceModel(structure.data)\n\n const donor = structure.getAtomProxy()\n const acceptor = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxDist, (j, dSq) => {\n if (j <= i) return\n\n const ti = types[ i ]\n const tj = types[ j ]\n\n const isWeak = isWeakHydrogenBond(ti, tj)\n if (!isWeak && !isHydrogenBond(ti, tj)) return\n\n const [ l, k ] = tj === FeatureType.HydrogenAcceptor ? [ i, j ] : [ j, i ]\n\n donor.index = atomSets[ l ][ 0 ]\n acceptor.index = atomSets[ k ][ 0 ]\n\n if (acceptor.index === donor.index) return // DA to self\n\n if (invalidAtomContact(donor, acceptor, masterIdx)) return\n if (donor.number !== Elements.S && acceptor.number !== Elements.S && dSq > maxHbondDistSq) return\n if (donor.connectedTo(acceptor)) return\n\n const donorAngles = calcAngles(donor, acceptor)\n const idealDonorAngle = Angles.get(idealGeometry[donor.index]) || degToRad(120)\n if (donorAngles.some(donorAngle => {\n return Math.abs(idealDonorAngle - donorAngle) > maxHbondDonAngle\n })) return\n\n if (idealGeometry[donor.index] === AtomGeometry.Trigonal){\n const outOfPlane = calcPlaneAngle(donor, acceptor)\n if (outOfPlane !== undefined && outOfPlane > maxHbondDonPlaneAngle) return\n }\n\n const acceptorAngles = calcAngles(acceptor, donor)\n const idealAcceptorAngle = Angles.get(idealGeometry[acceptor.index]) || degToRad(120)\n if (acceptorAngles.some(acceptorAngle => {\n // Do not limit large acceptor angles\n return idealAcceptorAngle - acceptorAngle > maxHbondAccAngle\n })) return\n\n if (idealGeometry[acceptor.index] === AtomGeometry.Trigonal){\n const outOfPlane = calcPlaneAngle(acceptor, donor)\n if (outOfPlane !== undefined && outOfPlane > maxHbondAccPlaneAngle) return\n }\n\n featureSet.setBits(l, k)\n const bondType = isWeak ? ContactType.WeakHydrogenBond : getHydrogenBondType(donor, acceptor)\n contactStore.addContact(l, k, bondType)\n })\n }\n}\n","/**\n * @file Metal Binding\n * @author Alexander Rose \n */\n\nimport { defaults } from '../../utils'\nimport Structure from '../../structure/structure'\n// import { valenceModel } from '../../structure/data'\nimport { Elements, AA3, Bases } from '../../structure/structure-constants'\n// import { hasAromaticNeighbour } from '../functional-groups'\nimport {\n Features, FeatureType,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\n\nconst IonicTypeMetals = [\n Elements.LI, Elements.NA, Elements.K, Elements.RB, Elements.CS,\n Elements.MG, Elements.CA, Elements.SR, Elements.BA, Elements.AL,\n Elements.GA, Elements.IN, Elements.TL, Elements.SC, Elements.SN,\n Elements.PB, Elements.BI, Elements.SB, Elements.HG\n]\n\n/**\n * Metal binding partners (dative bond or ionic-type interaction)\n */\nexport function addMetalBinding (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n let dative = false\n let ionic = false\n\n const isStandardAminoacid = AA3.includes(a.resname)\n const isStandardBase = Bases.includes(a.resname)\n\n if (!isStandardAminoacid && !isStandardBase) {\n if (a.isHalogen() || a.number === Elements.O || a.number === Elements.S) {\n dative = true\n ionic = true\n } else if (a.number === Elements.N) {\n dative = true\n }\n } else if (isStandardAminoacid){\n // main chain oxygen atom or oxygen, nitrogen and sulfur from specific amino acids\n if (a.number === Elements.O) {\n if(['ASP', 'GLU', 'SER', 'THR', 'TYR', 'ASN', 'GLN'].includes(a.resname) && a.isSidechain()) {\n dative = true\n ionic = true\n } else if (a.isBackbone()) {\n dative = true\n ionic = true\n }\n } else if (a.number === Elements.S && 'CYS' === a.resname) {\n dative = true\n ionic = true\n } else if (a.number === Elements.N) {\n if(a.resname === 'HIS' && a.isSidechain()) {\n dative = true\n }\n }\n } else if (isStandardBase){\n // http://pubs.acs.org/doi/pdf/10.1021/acs.accounts.6b00253\n // http://onlinelibrary.wiley.com/doi/10.1002/anie.200900399/full\n if (a.number === Elements.O && a.isBackbone()) {\n dative = true\n ionic = true\n } else if(['N3', 'N4', 'N7'].includes(a.atomname)) {\n dative = true\n } else if(['O2', 'O4', 'O6'].includes(a.atomname)) {\n dative = true\n ionic = true\n }\n }\n if (dative) {\n const state = createFeatureState(FeatureType.DativeBondPartner)\n addAtom(state, a)\n addFeature(features, state)\n }\n if (ionic) {\n const state = createFeatureState(FeatureType.IonicTypePartner)\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\n/**\n * Metal Pi complexation partner\n */\n// export function addMetalPiPartners (structure: Structure, features: Features) {\n// const { charge } = valenceModel(structure.data)\n\n// structure.eachAtom(a => {\n// const state = createFeatureState(FeatureType.MetalPiPartner)\n\n// const resname = a.resname\n// const element = a.element\n// const atomname = a.atomname\n// if (!a.isPolymer()) {\n// // water oxygen, as well as oxygen from carboxylate, phosphoryl, phenolate, alcohol;\n// // nitrogen from imidazole; sulfur from thiolate\n// if (element === 'O') {\n// // Water oxygen\n// if (a.bondCount === 0 || a.isWater()) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// // Oxygen in alcohol (R-[O]-H)\n// if (a.bondCount === 2 && charge[ a.index ] || a.hasBondToElement('H')) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// // Phenolate oxygen\n// if (hasAromaticNeighbour(a) && !a.aromatic) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// // Carboxylic acid oxygen\n// if (a.bondToElementCount('C') === 1) {\n// let flag = false\n// a.eachBondedAtom(ba => {\n// if (ba.element === 'C' && ba.bondToElementCount('O') === 2 && ba.bondToElementCount('C') === 1) {\n// flag = true\n// }\n// })\n// if (flag) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// }\n// // Phosphoryl oxygen\n// if (a.bondToElementCount('P') === 1) {\n// let flag = false\n// a.eachBondedAtom(ba => {\n// if (ba.element === 'P' && ba.bondToElementCount('O') >= 3) {\n// flag = true\n// }\n// })\n// if (flag) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// }\n// } else if (element === 'N') {\n// // Imidazole/pyrrole or similar\n// if (a.bondToElementCount('C') === 2) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// } else if (element === 'S') {\n// // Thiolate\n// if (hasAromaticNeighbour(a) && !a.aromatic) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// // Sulfur in Iron sulfur cluster\n// const ironCount = a.bondToElementCount('FE')\n// if (ironCount > 0 && ironCount === a.bondCount) {\n// addAtom(state, a)\n// addFeature(features, state)\n// return\n// }\n// }\n// }\n// })\n// }\n\nexport function addMetals (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n if (a.isTransitionMetal() || a.number === Elements.ZN || a.number === Elements.CD) {\n const state = createFeatureState(FeatureType.TransitionMetal)\n addAtom(state, a)\n addFeature(features, state)\n } else if (IonicTypeMetals.includes(a.number)) {\n const state = createFeatureState(FeatureType.IonicTypeMetal)\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\nfunction isMetalComplex (ti: FeatureType, tj: FeatureType) {\n if (ti === FeatureType.TransitionMetal) {\n return (\n tj === FeatureType.DativeBondPartner ||\n tj === FeatureType.TransitionMetal\n )\n } else if (ti === FeatureType.IonicTypeMetal) {\n return (\n tj === FeatureType.IonicTypePartner\n )\n }\n}\n\nexport interface MetalComplexationParams {\n maxMetalDist?: number\n masterModelIndex?: number\n}\n\n/**\n * Metal complexes of metals and appropriate groups in protein and ligand, including water\n */\nexport function addMetalComplexation (structure: Structure, contacts: Contacts, params: MetalComplexationParams = {}) {\n const maxMetalDist = defaults(params.maxMetalDist, ContactDefaultParams.maxMetalDist)\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxMetalDist, (j, dSq) => {\n if (j <= i) return\n\n ap1.index = atomSets[ i ][ 0 ]\n ap2.index = atomSets[ j ][ 0 ]\n\n if (invalidAtomContact(ap1, ap2, masterIdx)) return\n\n const m1 = ap1.isMetal()\n const m2 = ap2.isMetal()\n if (!m1 && !m2) return\n\n const [ ti, tj ] = m1 ? [ types[ i ],types[ j ] ] : [ types[ j ],types[ i ] ]\n\n if (isMetalComplex(ti, tj)) {\n featureSet.setBits(i, j)\n contactStore.addContact(i, j, ContactType.MetalCoordination)\n }\n })\n }\n}\n","/**\n * @file Halogen Bonds\n * @author Alexander Rose \n * @author Fred Ludlow \n */\n\nimport { defaults } from '../../utils'\nimport Structure from '../../structure/structure'\nimport { Elements } from '../../structure/structure-constants'\nimport { degToRad } from '../../math/math-utils'\nimport {\n Features, FeatureType,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\nimport { calcAngles } from '../geometry'\n\nconst halBondElements = [17, 35, 53, 85]\n\n/**\n * Halogen bond donors (X-C, with X one of Cl, Br, I or At) not F!\n */\nexport function addHalogenDonors (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n if (halBondElements.includes(a.number) && a.bondToElementCount(Elements.C) === 1) {\n const state = createFeatureState(FeatureType.HalogenDonor)\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\nconst X = [ Elements.N, Elements.O, Elements.S ]\nconst Y = [ Elements.C, Elements.N, Elements.P, Elements.S ]\n\n/**\n * Halogen bond acceptors (Y-{O|N|S}, with Y=C,P,N,S)\n */\nexport function addHalogenAcceptors (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n if (X.includes(a.number)) {\n let flag = false\n a.eachBondedAtom(ba => {\n if (Y.includes(ba.number)) {\n flag = true\n }\n })\n if (flag) {\n const state = createFeatureState(FeatureType.HalogenAcceptor)\n addAtom(state, a)\n addFeature(features, state)\n }\n }\n })\n}\n\nfunction isHalogenBond (ti: FeatureType, tj: FeatureType) {\n return (\n (ti === FeatureType.HalogenAcceptor && tj === FeatureType.HalogenDonor) ||\n (ti === FeatureType.HalogenDonor && tj === FeatureType.HalogenAcceptor)\n )\n}\n\nexport interface HalogenBondsParams {\n maxHalogenBondDist?: number\n maxHalogenBondAngle?: number\n masterModelIndex?: number\n}\n\n// http://www.pnas.org/content/101/48/16789.full\nconst OptimalHalogenAngle = degToRad(180) // adjusted from 165 to account for spherical statistics\nconst OptimalAcceptorAngle = degToRad(120)\n\n/**\n * All pairs of halogen donor and acceptor atoms\n */\nexport function addHalogenBonds (structure: Structure, contacts: Contacts, params: HalogenBondsParams = {}) {\n const maxHalogenBondDist = defaults(params.maxHalogenBondDist, ContactDefaultParams.maxHalogenBondDist)\n const maxHalogenBondAngle = degToRad(defaults(params.maxHalogenBondAngle, ContactDefaultParams.maxHalogenBondAngle))\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxHalogenBondDist, (j, dSq) => {\n if (j <= i) return\n\n ap1.index = atomSets[ i ][ 0 ]\n ap2.index = atomSets[ j ][ 0 ]\n\n if (invalidAtomContact(ap1, ap2, masterIdx)) return\n if (!isHalogenBond(types[ i ], types[ j ])) return\n\n const [ halogen, acceptor ] = types[ i ] === FeatureType.HalogenDonor ? [ ap1, ap2 ] : [ ap2, ap1 ]\n\n const halogenAngles = calcAngles(halogen, acceptor)\n // Singly bonded halogen only (not bromide ion for example)\n if (halogenAngles.length !== 1) return\n if (OptimalHalogenAngle - halogenAngles[0] > maxHalogenBondAngle) return\n\n const acceptorAngles = calcAngles(acceptor, halogen)\n // Angle must be defined. Excludes water as acceptor. Debatable\n if (acceptorAngles.length === 0) return\n if (acceptorAngles.some(acceptorAngle => {\n return (OptimalAcceptorAngle - acceptorAngle > maxHalogenBondAngle)\n })) return\n\n\n featureSet.setBits(i, j)\n contactStore.addContact(i, j, ContactType.HalogenBond)\n\n })\n }\n}\n","/**\n * @file Refine Contacts\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { Debug, Log } from '../../globals'\nimport { defaults } from '../../utils'\nimport Structure from '../../structure/structure'\nimport AtomProxy from '../../proxy/atom-proxy'\nimport { Elements } from '../../structure/structure-constants'\nimport { FrozenContacts, ContactType, ContactDefaultParams, isMasterContact } from './contact'\nimport { FeatureType } from './features'\n\nexport interface LineOfSightParams {\n lineOfSightDistFactor?: number\n masterModelIndex?: number\n}\n\n// also allows intra-residue contacts\nexport function invalidAtomContact (ap1: AtomProxy, ap2: AtomProxy, masterIdx: number) {\n return !isMasterContact(ap1, ap2, masterIdx) && (\n ap1.modelIndex !== ap2.modelIndex ||\n (ap1.altloc && ap2.altloc && ap1.altloc !== ap2.altloc)\n )\n}\n\nexport function refineLineOfSight (structure: Structure, contacts: FrozenContacts, params: LineOfSightParams = {}) {\n if (Debug) Log.time('refineLineOfSight')\n\n const lineOfSightDistFactor = defaults(params.lineOfSightDistFactor, ContactDefaultParams.lineOfSightDistFactor)\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const spatialHash = structure.spatialHash!\n const { contactSet, contactStore, features } = contacts\n const { index1, index2 } = contactStore\n const { centers, atomSets } = features\n const { x, y, z } = centers\n\n const ac1 = structure.getAtomProxy()\n const ac2 = structure.getAtomProxy()\n const aw = structure.getAtomProxy()\n\n const c1 = new Vector3()\n const c2 = new Vector3()\n\n const lineOfSightDist = 3 * lineOfSightDistFactor\n const lineOfSightDistFactorSq = lineOfSightDistFactor * lineOfSightDistFactor\n\n contactSet.forEach(i => {\n c1.set(x[index1[i]], y[index1[i]], z[index1[i]])\n c2.set(x[index2[i]], y[index2[i]], z[index2[i]])\n\n const cx = ( c1.x + c2.x ) / 2\n const cy = ( c1.y + c2.y ) / 2\n const cz = ( c1.z + c2.z ) / 2\n\n const as1 = atomSets[ index1[ i ] ]\n const as2 = atomSets[ index2[ i ] ]\n\n ac1.index = as1[ 0 ]\n ac2.index = as2[ 0 ]\n\n spatialHash.eachWithin(cx, cy, cz, lineOfSightDist, (j, dSq) => {\n aw.index = j\n if (\n aw.number !== Elements.H &&\n (aw.vdw * aw.vdw * lineOfSightDistFactorSq) > dSq &&\n !invalidAtomContact(ac1, aw, masterIdx) &&\n !invalidAtomContact(ac2, aw, masterIdx) &&\n !as1.includes(j) &&\n !as2.includes(j) &&\n // to ignore atoms in the center of functional groups\n c1.distanceToSquared(aw as any) > 1 &&\n c2.distanceToSquared(aw as any) > 1\n ) {\n contactSet.clear(i)\n if (Debug) Log.log('removing', ac1.qualifiedName(), ac2.qualifiedName(), 'because', aw.qualifiedName())\n }\n })\n })\n\n if (Debug) Log.timeEnd('refineLineOfSight')\n}\n\n/**\n * For atoms interacting with several atoms in the same residue\n * only the one with the closest distance is kept.\n */\nexport function refineHydrophobicContacts (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features } = contacts\n const { type, index1, index2 } = contactStore\n const { atomSets } = features\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n const residueContactDict: { [k: string]: number[] } = {}\n\n /* keep only closest contact between residues */\n const handleResidueContact = function (dist: number, i: number, key: string) {\n const [ minDist, minIndex ] = residueContactDict[ key ] || [ Infinity, -1 ]\n if (dist < minDist) {\n if (minIndex !== -1) contactSet.clear(minIndex)\n residueContactDict[ key ] = [ dist, i ]\n } else {\n contactSet.clear(i)\n }\n }\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.Hydrophobic) return\n\n ap1.index = atomSets[ index1[ i ] ][ 0 ]\n ap2.index = atomSets[ index2[ i ] ][ 0 ]\n\n const dist = ap1.distanceTo(ap2)\n handleResidueContact(dist, i, `${ap1.index}|${ap2.residueIndex}`)\n handleResidueContact(dist, i, `${ap2.index}|${ap1.residueIndex}`)\n })\n}\n\nfunction isHydrogenBondType (type: number) {\n return (\n type === ContactType.HydrogenBond ||\n type === ContactType.WaterHydrogenBond ||\n type === ContactType.BackboneHydrogenBond\n )\n}\n\n/**\n * Remove weak hydrogen bonds when the acceptor is involved in\n * a normal/strong hydrogen bond\n */\nexport function refineWeakHydrogenBonds (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features, adjacencyList } = contacts\n const { type, index1, index2 } = contactStore\n const { types } = features\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.WeakHydrogenBond) return\n\n let accFeat: number\n if (types[ index1[ i ] ] === FeatureType.WeakHydrogenDonor) {\n accFeat = index2[ i ]\n } else {\n accFeat = index1[ i ]\n }\n\n const n = adjacencyList.countArray[ accFeat ]\n const offset = adjacencyList.offsetArray[ accFeat ]\n for (let j = 0; j < n; ++j) {\n const ci = adjacencyList.indexArray[ offset + j ]\n if (isHydrogenBondType(type[ ci ])) {\n contactSet.clear(i)\n return\n }\n }\n })\n}\n\n/**\n * Remove hydrogen bonds between groups that also form\n * a salt bridge between each other\n */\nexport function refineSaltBridges (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features } = contacts\n const { type, index1, index2 } = contactStore\n const { atomSets } = features\n\n const ionicInteractionDict: { [atomIndex: number]: number[] } = {}\n\n const add = function(idx: number, i: number) {\n if (!ionicInteractionDict[ idx ]) ionicInteractionDict[ idx ] = []\n ionicInteractionDict[ idx ].push(i)\n }\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.IonicInteraction) return\n atomSets[ index1[ i ] ].forEach(idx => add(idx, i))\n atomSets[ index2[ i ] ].forEach(idx => add(idx, i))\n })\n\n contactSet.forEach(i => {\n if (!isHydrogenBondType(type[ i ])) return\n\n const iil1 = ionicInteractionDict[ atomSets[ index1[ i ] ][ 0 ] ]\n const iil2 = ionicInteractionDict[ atomSets[ index2[ i ] ][ 0 ] ]\n if (!iil1 || !iil2) return\n\n const n = iil1.length\n for (let j = 0; j < n; ++j) {\n if (iil2.includes(iil1[j])) {\n contactSet.clear(i)\n return\n }\n }\n })\n}\n\n/**\n * Remove hydrophobic and cation-pi interactions between groups that also form\n * a pi-stacking interaction between each other\n */\nexport function refinePiStacking (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features } = contacts\n const { type, index1, index2 } = contactStore\n const { atomSets } = features\n\n const piStackingDict: { [atomIndex: number]: number[] } = {}\n\n const add = function(idx: number, i: number) {\n if (!piStackingDict[ idx ]) piStackingDict[ idx ] = []\n piStackingDict[ idx ].push(i)\n }\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.PiStacking) return\n atomSets[ index1[ i ] ].forEach(idx => add(idx, i))\n atomSets[ index2[ i ] ].forEach(idx => add(idx, i))\n })\n\n contactSet.forEach(i => {\n if (\n type[ i ] !== ContactType.Hydrophobic &&\n type[ i ] !== ContactType.CationPi\n ) return\n\n const pil1 = piStackingDict[ atomSets[ index1[ i ] ][ 0 ] ]\n const pil2 = piStackingDict[ atomSets[ index2[ i ] ][ 0 ] ]\n if (!pil1 || !pil2) return\n\n const n = pil1.length\n for (let j = 0; j < n; ++j) {\n if (pil2.includes(pil1[j])) {\n contactSet.clear(i)\n return\n }\n }\n })\n}\n\n/**\n * Remove ionic interactions between groups that also form\n * a metal coordination between each other\n */\nexport function refineMetalCoordination (structure: Structure, contacts: FrozenContacts) {\n const { contactSet, contactStore, features } = contacts\n const { type, index1, index2 } = contactStore\n const { atomSets } = features\n\n const ionicInteractionDict: { [atomIndex: number]: number[] } = {}\n\n const add = function(idx: number, i: number) {\n if (!ionicInteractionDict[ idx ]) ionicInteractionDict[ idx ] = []\n ionicInteractionDict[ idx ].push(i)\n }\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.IonicInteraction) return\n atomSets[ index1[ i ] ].forEach(idx => add(idx, i))\n atomSets[ index2[ i ] ].forEach(idx => add(idx, i))\n })\n\n contactSet.forEach(i => {\n if (type[ i ] !== ContactType.MetalCoordination) return\n\n const iil1 = ionicInteractionDict[ atomSets[ index1[ i ] ][ 0 ] ]\n const iil2 = ionicInteractionDict[ atomSets[ index2[ i ] ][ 0 ] ]\n if (!iil1 || !iil2) return\n\n const n = iil1.length\n for (let j = 0; j < n; ++j) {\n if (iil2.includes(iil1[j])) {\n contactSet.clear(iil1[j])\n return\n }\n }\n })\n}\n\n// TODO: refactor refineSaltBridges, refinePiStacking and refineMetalCoordination to be DRY\n","/**\n * @file Contact\n * @author Alexander Rose \n */\n\nimport { Color } from 'three'\n\nimport { Debug, Log } from '../../globals'\nimport { createParams } from '../../utils'\nimport { TextBufferData } from '../../buffer/text-buffer'\nimport Structure from '../../structure/structure'\nimport AtomProxy from '../../proxy/atom-proxy'\nimport SpatialHash from '../../geometry/spatial-hash'\nimport { calculateCenterArray, calculateDirectionArray, uniformArray } from '../../math/array-utils'\nimport ContactStore from '../../store/contact-store'\nimport BitArray from '../../utils/bitarray'\nimport Selection from '../../selection/selection'\nimport { ContactPicker } from '../../utils/picker'\nimport { createAdjacencyList, AdjacencyList } from '../../utils/adjacency-list'\nimport { createFeatures, Features } from './features'\nimport { addAromaticRings, addNegativeCharges, addPositiveCharges, addChargedContacts } from './charged'\nimport { addHydrogenAcceptors, addHydrogenDonors, addHydrogenBonds, addWeakHydrogenDonors } from './hydrogen-bonds'\nimport { addMetalBinding, addMetals, addMetalComplexation } from './metal-binding'\nimport { addHydrophobic, addHydrophobicContacts } from './hydrophobic'\nimport { addHalogenAcceptors, addHalogenDonors, addHalogenBonds } from './halogen-bonds'\nimport {\n refineLineOfSight,\n refineHydrophobicContacts, refineSaltBridges, refinePiStacking, refineMetalCoordination\n} from './refine-contacts'\n\nexport interface Contacts {\n features: Features\n spatialHash: SpatialHash\n contactStore: ContactStore\n featureSet: BitArray\n}\n\nexport interface FrozenContacts extends Contacts {\n contactSet: BitArray\n adjacencyList: AdjacencyList\n}\n\nexport const enum ContactType {\n Unknown = 0,\n IonicInteraction = 1,\n CationPi = 2,\n PiStacking = 3,\n HydrogenBond = 4,\n HalogenBond = 5,\n Hydrophobic = 6,\n MetalCoordination = 7,\n WeakHydrogenBond = 8,\n WaterHydrogenBond = 9,\n BackboneHydrogenBond = 10\n}\n\nexport const ContactDefaultParams = {\n maxHydrophobicDist: 4.0,\n maxHbondDist: 3.5,\n maxHbondSulfurDist: 4.1,\n maxHbondAccAngle: 45,\n maxHbondDonAngle: 45,\n maxHbondAccPlaneAngle: 90,\n maxHbondDonPlaneAngle: 30,\n maxPiStackingDist: 5.5,\n maxPiStackingOffset: 2.0,\n maxPiStackingAngle: 30,\n maxCationPiDist: 6.0,\n maxCationPiOffset: 2.0,\n maxIonicDist: 5.0,\n maxHalogenBondDist: 4.0,\n maxHalogenBondAngle: 30,\n maxMetalDist: 3.0,\n refineSaltBridges: true,\n masterModelIndex: -1,\n lineOfSightDistFactor: 1.0\n}\n\nexport function isMasterContact (ap1: AtomProxy, ap2: AtomProxy, masterIdx: number) {\n return (\n (ap1.modelIndex === masterIdx && ap2.modelIndex !== masterIdx) ||\n (ap2.modelIndex === masterIdx && ap1.modelIndex !== masterIdx)\n )\n}\n\nexport function invalidAtomContact (ap1: AtomProxy, ap2: AtomProxy, masterIdx: number) {\n return !isMasterContact(ap1, ap2, masterIdx) && (\n ap1.modelIndex !== ap2.modelIndex ||\n ap1.residueIndex === ap2.residueIndex ||\n (ap1.altloc && ap2.altloc && ap1.altloc !== ap2.altloc)\n )\n}\n\nexport function createContacts (features: Features): Contacts {\n const { types, centers } = features\n\n const spatialHash = new SpatialHash(centers)\n const contactStore = new ContactStore()\n const featureSet = new BitArray(types.length, false)\n\n return { features, spatialHash, contactStore, featureSet }\n}\n\nexport function createFrozenContacts (contacts: Contacts): FrozenContacts {\n const { index1, index2, count } = contacts.contactStore\n\n const adjacencyList = createAdjacencyList({\n nodeArray1: index1,\n nodeArray2: index2,\n edgeCount: count,\n nodeCount: contacts.featureSet.length\n })\n const contactSet = new BitArray(contacts.contactStore.count, true)\n\n return Object.assign({ adjacencyList, contactSet }, contacts)\n}\n\nfunction calculateFeatures (structure: Structure) {\n const features = createFeatures()\n\n if (Debug) Log.time('calculateFeatures')\n\n addPositiveCharges(structure, features)\n addNegativeCharges(structure, features)\n addAromaticRings(structure, features)\n\n addHydrogenAcceptors(structure, features)\n addHydrogenDonors(structure, features)\n addWeakHydrogenDonors(structure, features)\n\n addMetalBinding(structure, features)\n addMetals(structure, features)\n\n addHydrophobic(structure, features)\n\n addHalogenAcceptors(structure, features)\n addHalogenDonors(structure, features)\n\n if (Debug) Log.timeEnd('calculateFeatures')\n\n return features\n}\n\nexport function calculateContacts (structure: Structure, params = ContactDefaultParams) {\n const features = calculateFeatures(structure)\n const contacts = createContacts(features)\n\n if (Debug) Log.time('calculateContacts')\n\n addChargedContacts(structure, contacts, params)\n addHydrogenBonds(structure, contacts, params)\n addMetalComplexation(structure, contacts, params)\n addHydrophobicContacts(structure, contacts, params)\n addHalogenBonds(structure, contacts, params)\n\n const frozenContacts = createFrozenContacts(contacts)\n\n refineLineOfSight(structure, frozenContacts, params)\n refineHydrophobicContacts(structure, frozenContacts)\n if (params.refineSaltBridges) refineSaltBridges(structure, frozenContacts)\n refinePiStacking(structure, frozenContacts)\n refineMetalCoordination(structure, frozenContacts)\n\n if (Debug) Log.timeEnd('calculateContacts')\n\n return frozenContacts\n}\n\nexport function contactTypeName (type: ContactType) {\n switch (type) {\n case ContactType.HydrogenBond:\n case ContactType.WaterHydrogenBond:\n case ContactType.BackboneHydrogenBond:\n return 'hydrogen bond'\n case ContactType.Hydrophobic:\n return 'hydrophobic contact'\n case ContactType.HalogenBond:\n return 'halogen bond'\n case ContactType.IonicInteraction:\n return 'ionic interaction'\n case ContactType.MetalCoordination:\n return 'metal coordination'\n case ContactType.CationPi:\n return 'cation-pi interaction'\n case ContactType.PiStacking:\n return 'pi-pi stacking'\n case ContactType.WeakHydrogenBond:\n return 'weak hydrogen bond'\n default:\n return 'unknown contact'\n }\n}\n\nexport const ContactDataDefaultParams = {\n hydrogenBond: true,\n hydrophobic: true,\n halogenBond: true,\n ionicInteraction: true,\n metalCoordination: true,\n cationPi: true,\n piStacking: true,\n weakHydrogenBond: true,\n waterHydrogenBond: true,\n backboneHydrogenBond: true,\n radius: 1,\n filterSele: ''\n}\nexport type ContactDataParams = typeof ContactDataDefaultParams\n | { filterSele: string|[string, string] }\n\nexport const ContactLabelDefaultParams = {\n unit: '',\n size: 2.0\n}\n\nexport type ContactLabelParams = typeof ContactLabelDefaultParams\n\nconst tmpColor = new Color()\nfunction contactColor (type: ContactType) {\n switch (type) {\n case ContactType.HydrogenBond:\n case ContactType.WaterHydrogenBond:\n case ContactType.BackboneHydrogenBond:\n return tmpColor.setHex(0x2B83BA).toArray()\n case ContactType.Hydrophobic:\n return tmpColor.setHex(0x808080).toArray()\n case ContactType.HalogenBond:\n return tmpColor.setHex(0x40FFBF).toArray()\n case ContactType.IonicInteraction:\n return tmpColor.setHex(0xF0C814).toArray()\n case ContactType.MetalCoordination:\n return tmpColor.setHex(0x8C4099).toArray()\n case ContactType.CationPi:\n return tmpColor.setHex(0xFF8000).toArray()\n case ContactType.PiStacking:\n return tmpColor.setHex(0x8CB366).toArray()\n case ContactType.WeakHydrogenBond:\n return tmpColor.setHex(0xC5DDEC).toArray()\n default:\n return tmpColor.setHex(0xCCCCCC).toArray()\n }\n}\n\nexport interface ContactData {\n position1: Float32Array,\n position2: Float32Array,\n color: Float32Array,\n color2: Float32Array,\n radius: Float32Array,\n picking: ContactPicker\n}\n\nexport function getContactData (contacts: FrozenContacts, structure: Structure, params: ContactDataParams): ContactData {\n const p = createParams(params, ContactDataDefaultParams)\n const types: ContactType[] = []\n if (p.hydrogenBond) types.push(ContactType.HydrogenBond)\n if (p.hydrophobic) types.push(ContactType.Hydrophobic)\n if (p.halogenBond) types.push(ContactType.HalogenBond)\n if (p.ionicInteraction) types.push(ContactType.IonicInteraction)\n if (p.metalCoordination) types.push(ContactType.MetalCoordination)\n if (p.cationPi) types.push(ContactType.CationPi)\n if (p.piStacking) types.push(ContactType.PiStacking)\n if (p.weakHydrogenBond) types.push(ContactType.WeakHydrogenBond)\n if (p.waterHydrogenBond) types.push(ContactType.WaterHydrogenBond)\n if (p.backboneHydrogenBond) types.push(ContactType.BackboneHydrogenBond)\n\n const { features, contactSet, contactStore } = contacts\n const { centers, atomSets } = features\n const { x, y, z } = centers\n const { index1, index2, type } = contactStore\n\n const position1: number[] = []\n const position2: number[] = []\n const color: number[] = []\n const radius: number[] = []\n const picking: number[] = []\n\n let filterSet: BitArray | BitArray[] | undefined\n if (p.filterSele) {\n if (Array.isArray(p.filterSele)) {\n filterSet = p.filterSele.map(sele => {\n return structure.getAtomSet(new Selection(sele))\n })\n } else {\n filterSet = structure.getAtomSet(new Selection(p.filterSele))\n }\n }\n\n contactSet.forEach(i => {\n const ti = type[ i ]\n if (!types.includes(ti)) return\n\n if (filterSet) {\n const idx1 = atomSets[index1[i]][0]\n const idx2 = atomSets[index2[i]][0]\n\n if (Array.isArray(filterSet)) {\n if (!(filterSet[0].isSet(idx1) && filterSet[1].isSet(idx2) || (filterSet[1].isSet(idx1) && filterSet[0].isSet(idx2)))) return\n } else {\n if (!filterSet.isSet(idx1) && !filterSet.isSet(idx2)) return\n }\n }\n\n const k = index1[i]\n const l = index2[i]\n position1.push(x[k], y[k], z[k])\n position2.push(x[l], y[l], z[l])\n color.push(...contactColor(ti))\n radius.push(p.radius)\n picking.push(i)\n })\n\n return {\n position1: new Float32Array(position1),\n position2: new Float32Array(position2),\n color: new Float32Array(color),\n color2: new Float32Array(color),\n radius: new Float32Array(radius),\n picking: new ContactPicker(picking, contacts, structure)\n }\n}\n\nexport function getLabelData (contactData: ContactData, params: ContactLabelParams): TextBufferData {\n\n const position = calculateCenterArray(contactData.position1, contactData.position2)\n const text: string[] = []\n\n const direction = calculateDirectionArray(contactData.position1, contactData.position2)\n\n const n = direction.length / 3\n for (let i=0; i\n */\n\nimport { defaults } from '../../utils'\nimport Structure from '../../structure/structure'\nimport { Elements } from '../../structure/structure-constants'\nimport {\n Features, FeatureType,\n addAtom, addFeature, createFeatureState,\n} from './features'\nimport { Contacts, ContactType, ContactDefaultParams, invalidAtomContact } from './contact'\n\n/**\n * Hydrophobic carbon (only bonded to carbon or hydrogen); fluorine\n */\nexport function addHydrophobic (structure: Structure, features: Features) {\n structure.eachAtom(a => {\n const state = createFeatureState(FeatureType.Hydrophobic)\n let flag = false\n if (a.number === Elements.C) {\n flag = true\n a.eachBondedAtom(ap => {\n const an = ap.number\n if (an !== Elements.C && an !== Elements.H) flag = false\n })\n } else if (a.number === Elements.F) {\n flag = true\n }\n if (flag) {\n addAtom(state, a)\n addFeature(features, state)\n }\n })\n}\n\nfunction isHydrophobicContact (ti: FeatureType, tj: FeatureType) {\n return ti === FeatureType.Hydrophobic && tj === FeatureType.Hydrophobic\n}\n\nexport interface HydrophobicContactsParams {\n maxHydrophobicDist?: number\n masterModelIndex?: number\n}\n\n/**\n * All hydrophobic contacts\n */\nexport function addHydrophobicContacts (structure: Structure, contacts: Contacts, params: HydrophobicContactsParams = {}) {\n const maxHydrophobicDist = defaults(params.maxHydrophobicDist, ContactDefaultParams.maxHydrophobicDist)\n const masterIdx = defaults(params.masterModelIndex, ContactDefaultParams.masterModelIndex)\n\n const { features, spatialHash, contactStore, featureSet } = contacts\n const { types, centers, atomSets } = features\n const { x, y, z } = centers\n const n = types.length\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n spatialHash.eachWithin(x[i], y[i], z[i], maxHydrophobicDist, (j, dSq) => {\n if (j <= i) return\n\n ap1.index = atomSets[ i ][ 0 ]\n ap2.index = atomSets[ j ][ 0 ]\n\n if (invalidAtomContact(ap1, ap2, masterIdx)) return\n if (ap1.number === Elements.F && ap2.number === Elements.F) return\n if (ap1.connectedTo(ap2)) return\n\n if (isHydrophobicContact(types[ i ], types[ j ])) {\n featureSet.setBits(i, j)\n contactStore.addContact(i, j, ContactType.Hydrophobic)\n }\n })\n }\n}\n","/**\n * @file Picker\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { PickerRegistry } from '../globals'\nimport { calculateMeanVector3 } from '../math/vector-utils'\nimport Selection from '../selection/selection'\nimport {\n ArrowPrimitive, BoxPrimitive, ConePrimitive, CylinderPrimitive,\n EllipsoidPrimitive, OctahedronPrimitive, SpherePrimitive,\n TetrahedronPrimitive, TorusPrimitive, PointPrimitive, WidelinePrimitive\n} from '../geometry/primitive'\nimport { contactTypeName, Contacts } from '../chemistry/interactions/contact'\nimport { TypedArray } from '../types';\nimport Component from '../component/component';\nimport { Shape, Structure, Volume } from '../ngl';\nimport BondStore from '../store/bond-store';\nimport Validation from '../structure/validation';\nimport PrincipalAxes from '../math/principal-axes';\nimport Surface from '../surface/surface';\nimport Unitcell from '../symmetry/unitcell';\nimport BondProxy from '../proxy/bond-proxy';\nimport AtomProxy from '../proxy/atom-proxy';\n\n/**\n * Picker class\n * @interface\n */\nclass Picker {\n array: number[]|TypedArray|undefined\n /**\n * @param {Array|TypedArray} [array] - mapping\n */\n constructor (array?: number[]|TypedArray) {\n this.array = array\n }\n\n get type () { return '' }\n get data () { return {} }\n\n /**\n * Get the index for the given picking id\n * @param {Integer} pid - the picking id\n * @return {Integer} the index\n */\n getIndex (pid: number) {\n return this.array ? this.array[ pid ] : pid\n }\n\n /**\n * Get object data\n * @abstract\n * @param {Integer} pid - the picking id\n * @return {Object} the object data\n */\n getObject (pid: number) {\n return {}\n }\n\n _applyTransformations (vector: Vector3, instance: any, component: Component) {\n if (instance) {\n vector.applyMatrix4(instance.matrix)\n }\n if (component) {\n vector.applyMatrix4(component.matrix)\n }\n return vector\n }\n\n /**\n * Get object position\n * @abstract\n * @param {Integer} pid - the picking id\n * @return {Vector3} the object position\n */\n _getPosition (pid: number) {\n return new Vector3()\n }\n\n /**\n * Get position for the given picking id\n * @param {Integer} pid - the picking id\n * @param {Object} instance - the instance that should be applied\n * @param {Component} component - the component of the picked object\n * @return {Vector3} the position\n */\n getPosition (pid: number, instance: any, component: Component) {\n return this._applyTransformations(\n this._getPosition(pid), instance, component\n )\n }\n}\n\n/**\n * Shape picker class\n * @interface\n */\nclass ShapePicker extends Picker {\n shape: Shape\n /**\n * @param {Shape} shape - shape object\n */\n constructor (shape: Shape) {\n super()\n this.shape = shape\n }\n\n get primitive (): any { return }\n\n get data () { return this.shape }\n get type () { return this.primitive.type }\n\n getObject (pid: number) {\n return this.primitive.objectFromShape(this.shape, this.getIndex(pid))\n }\n\n _getPosition (pid: number) {\n return this.primitive.positionFromShape(this.shape, this.getIndex(pid))\n }\n}\n\n//\n\nclass CylinderPicker extends ShapePicker {\n get primitive () { return CylinderPrimitive }\n}\n\nclass ArrowPicker extends ShapePicker {\n get primitive () { return ArrowPrimitive }\n}\n\nclass AtomPicker extends Picker {\n structure: Structure\n constructor (array: Float32Array, structure: Structure) {\n super(array)\n this.structure = structure\n }\n\n get type () { return 'atom' }\n get data () { return this.structure }\n\n getObject (pid: number): AtomProxy {\n return this.structure.getAtomProxy(this.getIndex(pid))\n }\n\n _getPosition (pid: number) {\n return new Vector3().copy(this.getObject(pid) as any)\n }\n}\n\nclass AxesPicker extends Picker {\n axes: PrincipalAxes\n constructor (axes: PrincipalAxes) {\n super()\n this.axes = axes\n }\n\n get type () { return 'axes' }\n get data () { return this.axes }\n\n getObject (/* pid */) {\n return {\n axes: this.axes\n }\n }\n\n _getPosition (/* pid */) {\n return this.axes.center.clone()\n }\n}\n\nclass BondPicker extends Picker {\n structure: Structure\n bondStore: BondStore\n constructor (array: number[]|TypedArray|undefined, structure: Structure, bondStore?: BondStore) {\n super(array)\n this.structure = structure\n this.bondStore = bondStore || structure.bondStore\n }\n\n get type () { return 'bond' }\n get data () { return this.structure }\n\n getObject (pid: number): BondProxy {\n const bp = this.structure.getBondProxy(this.getIndex(pid))\n bp.bondStore = this.bondStore\n return bp\n }\n\n _getPosition (pid: number) {\n const b = this.getObject(pid)\n return new Vector3()\n .copy(b.atom1 as any)\n .add(b.atom2 as any)\n .multiplyScalar(0.5)\n }\n}\n\nclass ContactPicker extends Picker {\n contacts: Contacts\n structure: Structure\n constructor (array: number[]|TypedArray|undefined, contacts: Contacts, structure: Structure) {\n super(array)\n this.contacts = contacts\n this.structure = structure\n }\n\n get type () { return 'contact' }\n get data () { return this.contacts }\n\n getObject (pid: number) {\n const idx = this.getIndex(pid)\n const { features, contactStore } = this.contacts\n const { centers, atomSets } = features\n const { x, y, z } = centers\n const { index1, index2, type } = contactStore\n const k = index1[idx]\n const l = index2[idx]\n return {\n center1: new Vector3(x[k], y[k], z[k]),\n center2: new Vector3(x[l], y[l], z[l]),\n atom1: this.structure.getAtomProxy(atomSets[k][0]),\n atom2: this.structure.getAtomProxy(atomSets[l][0]),\n type: contactTypeName(type[idx])\n }\n }\n\n _getPosition (pid: number) {\n const { center1, center2 } = this.getObject(pid)\n return new Vector3().addVectors(center1, center2).multiplyScalar(0.5)\n }\n}\n\nclass ConePicker extends ShapePicker {\n get primitive () { return ConePrimitive }\n}\n\nclass ClashPicker extends Picker {\n validation: Validation\n structure: Structure\n constructor (array: number[]|TypedArray|undefined, validation: Validation, structure: Structure) {\n super(array)\n this.validation = validation\n this.structure = structure\n }\n\n get type () { return 'clash' }\n get data () { return this.validation }\n\n getObject (pid: number) {\n const val = this.validation\n const idx = this.getIndex(pid)\n return {\n validation: val,\n index: idx,\n clash: val.clashArray[ idx ]\n }\n }\n\n _getAtomProxyFromSele (sele: string) {\n const selection = new Selection(sele)\n const idx = this.structure.getAtomIndices(selection)![ 0 ]\n return this.structure.getAtomProxy(idx)\n }\n\n _getPosition (pid: number) {\n const clash = this.getObject(pid).clash\n const ap1 = this._getAtomProxyFromSele(clash.sele1)\n const ap2 = this._getAtomProxyFromSele(clash.sele2)\n return new Vector3().copy(ap1 as any).add(ap2 as any).multiplyScalar(0.5)\n }\n}\n\nclass DistancePicker extends BondPicker {\n get type () { return 'distance' }\n}\n\nclass EllipsoidPicker extends ShapePicker {\n get primitive () { return EllipsoidPrimitive }\n}\n\nclass OctahedronPicker extends ShapePicker {\n get primitive () { return OctahedronPrimitive }\n}\n\nclass BoxPicker extends ShapePicker {\n get primitive () { return BoxPrimitive }\n}\n\nclass IgnorePicker extends Picker {\n get type () { return 'ignore' }\n}\n\nexport interface MeshData {\n name: string|undefined\n serial: number\n index: Uint32Array|Uint16Array|number[]\n normal?: Float32Array|number[]\n position: Float32Array|number[]\n color: Float32Array|number[]\n}\nclass MeshPicker extends ShapePicker {\n mesh: MeshData\n __position: Vector3\n\n constructor (shape: Shape, mesh: MeshData) {\n super(shape)\n this.mesh = mesh\n }\n\n get type () { return 'mesh' }\n\n getObject (/* pid */) {\n const m = this.mesh\n return {\n shape: this.shape,\n name: m.name,\n serial: m.serial\n }\n }\n\n _getPosition (/* pid */) {\n if (!this.__position) {\n this.__position = calculateMeanVector3(this.mesh.position as any)\n }\n return this.__position\n }\n}\n\nclass SpherePicker extends ShapePicker {\n get primitive () { return SpherePrimitive }\n}\n\nclass SurfacePicker extends Picker {\n surface: Surface\n constructor (array: number[]|TypedArray|undefined, surface: Surface) {\n super(array)\n this.surface = surface\n }\n\n get type () { return 'surface' }\n get data () { return this.surface }\n\n getObject (pid: number) {\n return {\n surface: this.surface,\n index: this.getIndex(pid)\n }\n }\n\n _getPosition (/* pid */) {\n return this.surface.center.clone()\n }\n}\n\nclass TetrahedronPicker extends ShapePicker {\n get primitive () { return TetrahedronPrimitive }\n}\n\nclass TorusPicker extends ShapePicker {\n get primitive () { return TorusPrimitive }\n}\n\nclass UnitcellPicker extends Picker {\n unitcell: Unitcell\n structure: Structure\n\n constructor (unitcell: Unitcell, structure: Structure) {\n super()\n this.unitcell = unitcell\n this.structure = structure\n }\n\n get type () { return 'unitcell' }\n get data () { return this.unitcell }\n\n getObject (/* pid */) {\n return {\n unitcell: this.unitcell,\n structure: this.structure\n }\n }\n\n _getPosition (/* pid */) {\n return this.unitcell.getCenter(this.structure)\n }\n}\n\nclass UnknownPicker extends Picker {\n get type () { return 'unknown' }\n}\n\nclass VolumePicker extends Picker {\n volume: Volume\n constructor (array: TypedArray, volume: Volume) {\n super(array)\n this.volume = volume\n }\n\n get type () { return 'volume' }\n get data () { return this.volume }\n\n getObject (pid: number) {\n const vol = this.volume\n const idx = this.getIndex(pid)\n return {\n volume: vol,\n index: idx,\n value: vol.data[ idx ]\n }\n }\n\n _getPosition (pid: number) {\n const dp = this.volume.position\n const idx = this.getIndex(pid)\n return new Vector3(\n dp[ idx * 3 ],\n dp[ idx * 3 + 1 ],\n dp[ idx * 3 + 2 ]\n )\n }\n}\n\nclass SlicePicker extends VolumePicker {\n get type () { return 'slice' }\n}\n\nclass PointPicker extends ShapePicker {\n get primitive () { return PointPrimitive }\n}\n\nclass WidelinePicker extends ShapePicker {\n get primitive () { return WidelinePrimitive }\n}\n\nPickerRegistry.add('arrow', ArrowPicker)\nPickerRegistry.add('box', BoxPicker)\nPickerRegistry.add('cone', ConePicker)\nPickerRegistry.add('cylinder', CylinderPicker)\nPickerRegistry.add('ellipsoid', EllipsoidPicker)\nPickerRegistry.add('octahedron', OctahedronPicker)\nPickerRegistry.add('sphere', SpherePicker)\nPickerRegistry.add('tetrahedron', TetrahedronPicker)\nPickerRegistry.add('torus', TorusPicker)\nPickerRegistry.add('point', PointPicker)\nPickerRegistry.add('wideline', WidelinePicker)\n\nexport {\n Picker,\n ShapePicker,\n ArrowPicker,\n AtomPicker,\n AxesPicker,\n BondPicker,\n BoxPicker,\n ConePicker,\n ContactPicker,\n CylinderPicker,\n ClashPicker,\n DistancePicker,\n EllipsoidPicker,\n IgnorePicker,\n OctahedronPicker,\n MeshPicker,\n SlicePicker,\n SpherePicker,\n SurfacePicker,\n TetrahedronPicker,\n TorusPicker,\n UnitcellPicker,\n UnknownPicker,\n VolumePicker,\n PointPicker,\n WidelinePicker\n}\n","/**\n * @file Marching Cubes\n * @author Alexander Rose \n * @private\n */\n\nimport { getUintArray } from '../utils'\n\nfunction getEdgeTable () {\n return new Uint32Array([\n 0x0, 0x109, 0x203, 0x30a, 0x406, 0x50f, 0x605, 0x70c,\n 0x80c, 0x905, 0xa0f, 0xb06, 0xc0a, 0xd03, 0xe09, 0xf00,\n 0x190, 0x99, 0x393, 0x29a, 0x596, 0x49f, 0x795, 0x69c,\n 0x99c, 0x895, 0xb9f, 0xa96, 0xd9a, 0xc93, 0xf99, 0xe90,\n 0x230, 0x339, 0x33, 0x13a, 0x636, 0x73f, 0x435, 0x53c,\n 0xa3c, 0xb35, 0x83f, 0x936, 0xe3a, 0xf33, 0xc39, 0xd30,\n 0x3a0,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a3, 0x2a9, 0x3a0,\n 0xd30, 0xc39, 0xf33, 0xe3a, 0x936, 0x83f, 0xb35, 0xa3c,\n 0x53c, 0x435, 0x73f, 0x636, 0x13a, 0x33, 0x339, 0x230,\n 0xe90, 0xf99, 0xc93, 0xd9a, 0xa96, 0xb9f, 0x895, 0x99c,\n 0x69c, 0x795, 0x49f, 0x596, 0x29a, 0x393, 0x99, 0x190,\n 0xf00, 0xe09, 0xd03, 0xc0a, 0xb06, 0xa0f, 0x905, 0x80c,\n 0x70c, 0x605, 0x50f, 0x406, 0x30a, 0x203, 0x109, 0x0\n ])\n}\n\nfunction getTriTable (): Int32Array {\n return new Int32Array([\n -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 8, 3, 9, 8, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 2, 10, 0, 2, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 8, 3, 2, 10, 8, 10, 9, 8, -1, -1, -1, -1, -1, -1, -1,\n 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 11, 2, 8, 11, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 9, 0, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 11, 2, 1, 9, 11, 9, 8, 11, -1, -1, -1, -1, -1, -1, -1,\n 3, 10, 1, 11, 10, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 10, 1, 0, 8, 10, 8, 11, 10, -1, -1, -1, -1, -1, -1, -1,\n 3, 9, 0, 3, 11, 9, 11, 10, 9, -1, -1, -1, -1, -1, -1, -1,\n 9, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 3, 0, 7, 3, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 9, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 1, 9, 4, 7, 1, 7, 3, 1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 4, 7, 3, 0, 4, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1,\n 9, 2, 10, 9, 0, 2, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1,\n 2, 10, 9, 2, 9, 7, 2, 7, 3, 7, 9, 4, -1, -1, -1, -1,\n 8, 4, 7, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 11, 4, 7, 11, 2, 4, 2, 0, 4, -1, -1, -1, -1, -1, -1, -1,\n 9, 0, 1, 8, 4, 7, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1,\n 4, 7, 11, 9, 4, 11, 9, 11, 2, 9, 2, 1, -1, -1, -1, -1,\n 3, 10, 1, 3, 11, 10, 7, 8, 4, -1, -1, -1, -1, -1, -1, -1,\n 1, 11, 10, 1, 4, 11, 1, 0, 4, 7, 11, 4, -1, -1, -1, -1,\n 4, 7, 8, 9, 0, 11, 9, 11, 10, 11, 0, 3, -1, -1, -1, -1,\n 4, 7, 11, 4, 11, 9, 9, 11, 10, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 4, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 5, 4, 1, 5, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 8, 5, 4, 8, 3, 5, 3, 1, 5, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 8, 1, 2, 10, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1,\n 5, 2, 10, 5, 4, 2, 4, 0, 2, -1, -1, -1, -1, -1, -1, -1,\n 2, 10, 5, 3, 2, 5, 3, 5, 4, 3, 4, 8, -1, -1, -1, -1,\n 9, 5, 4, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 11, 2, 0, 8, 11, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1,\n 0, 5, 4, 0, 1, 5, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1,\n 2, 1, 5, 2, 5, 8, 2, 8, 11, 4, 8, 5, -1, -1, -1, -1,\n 10, 3, 11, 10, 1, 3, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1,\n 4, 9, 5, 0, 8, 1, 8, 10, 1, 8, 11, 10, -1, -1, -1, -1,\n 5, 4, 0, 5, 0, 11, 5, 11, 10, 11, 0, 3, -1, -1, -1, -1,\n 5, 4, 8, 5, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1,\n 9, 7, 8, 5, 7, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 3, 0, 9, 5, 3, 5, 7, 3, -1, -1, -1, -1, -1, -1, -1,\n 0, 7, 8, 0, 1, 7, 1, 5, 7, -1, -1, -1, -1, -1, -1, -1,\n 1, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 7, 8, 9, 5, 7, 10, 1, 2, -1, -1, -1, -1, -1, -1, -1,\n 10, 1, 2, 9, 5, 0, 5, 3, 0, 5, 7, 3, -1, -1, -1, -1,\n 8, 0, 2, 8, 2, 5, 8, 5, 7, 10, 5, 2, -1, -1, -1, -1,\n 2, 10, 5, 2, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1,\n 7, 9, 5, 7, 8, 9, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 7, 9, 7, 2, 9, 2, 0, 2, 7, 11, -1, -1, -1, -1,\n 2, 3, 11, 0, 1, 8, 1, 7, 8, 1, 5, 7, -1, -1, -1, -1,\n 11, 2, 1, 11, 1, 7, 7, 1, 5, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 8, 8, 5, 7, 10, 1, 3, 10, 3, 11, -1, -1, -1, -1,\n 5, 7, 0, 5, 0, 9, 7, 11, 0, 1, 0, 10, 11, 10, 0, -1,\n 11, 10, 0, 11, 0, 3, 10, 5, 0, 8, 0, 7, 5, 7, 0, -1,\n 11, 10, 5, 7, 11, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 0, 1, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 8, 3, 1, 9, 8, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1,\n 1, 6, 5, 2, 6, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 6, 5, 1, 2, 6, 3, 0, 8, -1, -1, -1, -1, -1, -1, -1,\n 9, 6, 5, 9, 0, 6, 0, 2, 6, -1, -1, -1, -1, -1, -1, -1,\n 5, 9, 8, 5, 8, 2, 5, 2, 6, 3, 2, 8, -1, -1, -1, -1,\n 2, 3, 11, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 11, 0, 8, 11, 2, 0, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 9, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1,\n 5, 10, 6, 1, 9, 2, 9, 11, 2, 9, 8, 11, -1, -1, -1, -1,\n 6, 3, 11, 6, 5, 3, 5, 1, 3, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 11, 0, 11, 5, 0, 5, 1, 5, 11, 6, -1, -1, -1, -1,\n 3, 11, 6, 0, 3, 6, 0, 6, 5, 0, 5, 9, -1, -1, -1, -1,\n 6, 5, 9, 6, 9, 11, 11, 9, 8, -1, -1, -1, -1, -1, -1, -1,\n 5, 10, 6, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 3, 0, 4, 7, 3, 6, 5, 10, -1, -1, -1, -1, -1, -1, -1,\n 1, 9, 0, 5, 10, 6, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1,\n 10, 6, 5, 1, 9, 7, 1, 7, 3, 7, 9, 4, -1, -1, -1, -1,\n 6, 1, 2, 6, 5, 1, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 5, 5, 2, 6, 3, 0, 4, 3, 4, 7, -1, -1, -1, -1,\n 8, 4, 7, 9, 0, 5, 0, 6, 5, 0, 2, 6, -1, -1, -1, -1,\n 7, 3, 9, 7, 9, 4, 3, 2, 9, 5, 9, 6, 2, 6, 9, -1,\n 3, 11, 2, 7, 8, 4, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1,\n 5, 10, 6, 4, 7, 2, 4, 2, 0, 2, 7, 11, -1, -1, -1, -1,\n 0, 1, 9, 4, 7, 8, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1,\n 9, 2, 1, 9, 11, 2, 9, 4, 11, 7, 11, 4, 5, 10, 6, -1,\n 8, 4, 7, 3, 11, 5, 3, 5, 1, 5, 11, 6, -1, -1, -1, -1,\n 5, 1, 11, 5, 11, 6, 1, 0, 11, 7, 11, 4, 0, 4, 11, -1,\n 0, 5, 9, 0, 6, 5, 0, 3, 6, 11, 6, 3, 8, 4, 7, -1,\n 6, 5, 9, 6, 9, 11, 4, 7, 9, 7, 11, 9, -1, -1, -1, -1,\n 10, 4, 9, 6, 4, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 10, 6, 4, 9, 10, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1,\n 10, 0, 1, 10, 6, 0, 6, 4, 0, -1, -1, -1, -1, -1, -1, -1,\n 8, 3, 1, 8, 1, 6, 8, 6, 4, 6, 1, 10, -1, -1, -1, -1,\n 1, 4, 9, 1, 2, 4, 2, 6, 4, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 8, 1, 2, 9, 2, 4, 9, 2, 6, 4, -1, -1, -1, -1,\n 0, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 8, 3, 2, 8, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1,\n 10, 4, 9, 10, 6, 4, 11, 2, 3, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 2, 2, 8, 11, 4, 9, 10, 4, 10, 6, -1, -1, -1, -1,\n 3, 11, 2, 0, 1, 6, 0, 6, 4, 6, 1, 10, -1, -1, -1, -1,\n 6, 4, 1, 6, 1, 10, 4, 8, 1, 2, 1, 11, 8, 11, 1, -1,\n 9, 6, 4, 9, 3, 6, 9, 1, 3, 11, 6, 3, -1, -1, -1, -1,\n 8, 11, 1, 8, 1, 0, 11, 6, 1, 9, 1, 4, 6, 4, 1, -1,\n 3, 11, 6, 3, 6, 0, 0, 6, 4, -1, -1, -1, -1, -1, -1, -1,\n 6, 4, 8, 11, 6, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 7, 10, 6, 7, 8, 10, 8, 9, 10, -1, -1, -1, -1, -1, -1, -1,\n 0, 7, 3, 0, 10, 7, 0, 9, 10, 6, 7, 10, -1, -1, -1, -1,\n 10, 6, 7, 1, 10, 7, 1, 7, 8, 1, 8, 0, -1, -1, -1, -1,\n 10, 6, 7, 10, 7, 1, 1, 7, 3, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 6, 1, 6, 8, 1, 8, 9, 8, 6, 7, -1, -1, -1, -1,\n 2, 6, 9, 2, 9, 1, 6, 7, 9, 0, 9, 3, 7, 3, 9, -1,\n 7, 8, 0, 7, 0, 6, 6, 0, 2, -1, -1, -1, -1, -1, -1, -1,\n 7, 3, 2, 6, 7, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 3, 11, 10, 6, 8, 10, 8, 9, 8, 6, 7, -1, -1, -1, -1,\n 2, 0, 7, 2, 7, 11, 0, 9, 7, 6, 7, 10, 9, 10, 7, -1,\n 1, 8, 0, 1, 7, 8, 1, 10, 7, 6, 7, 10, 2, 3, 11, -1,\n 11, 2, 1, 11, 1, 7, 10, 6, 1, 6, 7, 1, -1, -1, -1, -1,\n 8, 9, 6, 8, 6, 7, 9, 1, 6, 11, 6, 3, 1, 3, 6, -1,\n 0, 9, 1, 11, 6, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 7, 8, 0, 7, 0, 6, 3, 11, 0, 11, 6, 0, -1, -1, -1, -1,\n 7, 11, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 8, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 9, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 8, 1, 9, 8, 3, 1, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1,\n 10, 1, 2, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 3, 0, 8, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1,\n 2, 9, 0, 2, 10, 9, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1,\n 6, 11, 7, 2, 10, 3, 10, 8, 3, 10, 9, 8, -1, -1, -1, -1,\n 7, 2, 3, 6, 2, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 7, 0, 8, 7, 6, 0, 6, 2, 0, -1, -1, -1, -1, -1, -1, -1,\n 2, 7, 6, 2, 3, 7, 0, 1, 9, -1, -1, -1, -1, -1, -1, -1,\n 1, 6, 2, 1, 8, 6, 1, 9, 8, 8, 7, 6, -1, -1, -1, -1,\n 10, 7, 6, 10, 1, 7, 1, 3, 7, -1, -1, -1, -1, -1, -1, -1,\n 10, 7, 6, 1, 7, 10, 1, 8, 7, 1, 0, 8, -1, -1, -1, -1,\n 0, 3, 7, 0, 7, 10, 0, 10, 9, 6, 10, 7, -1, -1, -1, -1,\n 7, 6, 10, 7, 10, 8, 8, 10, 9, -1, -1, -1, -1, -1, -1, -1,\n 6, 8, 4, 11, 8, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 6, 11, 3, 0, 6, 0, 4, 6, -1, -1, -1, -1, -1, -1, -1,\n 8, 6, 11, 8, 4, 6, 9, 0, 1, -1, -1, -1, -1, -1, -1, -1,\n 9, 4, 6, 9, 6, 3, 9, 3, 1, 11, 3, 6, -1, -1, -1, -1,\n 6, 8, 4, 6, 11, 8, 2, 10, 1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 3, 0, 11, 0, 6, 11, 0, 4, 6, -1, -1, -1, -1,\n 4, 11, 8, 4, 6, 11, 0, 2, 9, 2, 10, 9, -1, -1, -1, -1,\n 10, 9, 3, 10, 3, 2, 9, 4, 3, 11, 3, 6, 4, 6, 3, -1,\n 8, 2, 3, 8, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1,\n 0, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 9, 0, 2, 3, 4, 2, 4, 6, 4, 3, 8, -1, -1, -1, -1,\n 1, 9, 4, 1, 4, 2, 2, 4, 6, -1, -1, -1, -1, -1, -1, -1,\n 8, 1, 3, 8, 6, 1, 8, 4, 6, 6, 10, 1, -1, -1, -1, -1,\n 10, 1, 0, 10, 0, 6, 6, 0, 4, -1, -1, -1, -1, -1, -1, -1,\n 4, 6, 3, 4, 3, 8, 6, 10, 3, 0, 3, 9, 10, 9, 3, -1,\n 10, 9, 4, 6, 10, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 9, 5, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 4, 9, 5, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1,\n 5, 0, 1, 5, 4, 0, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1,\n 11, 7, 6, 8, 3, 4, 3, 5, 4, 3, 1, 5, -1, -1, -1, -1,\n 9, 5, 4, 10, 1, 2, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1,\n 6, 11, 7, 1, 2, 10, 0, 8, 3, 4, 9, 5, -1, -1, -1, -1,\n 7, 6, 11, 5, 4, 10, 4, 2, 10, 4, 0, 2, -1, -1, -1, -1,\n 3, 4, 8, 3, 5, 4, 3, 2, 5, 10, 5, 2, 11, 7, 6, -1,\n 7, 2, 3, 7, 6, 2, 5, 4, 9, -1, -1, -1, -1, -1, -1, -1,\n 9, 5, 4, 0, 8, 6, 0, 6, 2, 6, 8, 7, -1, -1, -1, -1,\n 3, 6, 2, 3, 7, 6, 1, 5, 0, 5, 4, 0, -1, -1, -1, -1,\n 6, 2, 8, 6, 8, 7, 2, 1, 8, 4, 8, 5, 1, 5, 8, -1,\n 9, 5, 4, 10, 1, 6, 1, 7, 6, 1, 3, 7, -1, -1, -1, -1,\n 1, 6, 10, 1, 7, 6, 1, 0, 7, 8, 7, 0, 9, 5, 4, -1,\n 4, 0, 10, 4, 10, 5, 0, 3, 10, 6, 10, 7, 3, 7, 10, -1,\n 7, 6, 10, 7, 10, 8, 5, 4, 10, 4, 8, 10, -1, -1, -1, -1,\n 6, 9, 5, 6, 11, 9, 11, 8, 9, -1, -1, -1, -1, -1, -1, -1,\n 3, 6, 11, 0, 6, 3, 0, 5, 6, 0, 9, 5, -1, -1, -1, -1,\n 0, 11, 8, 0, 5, 11, 0, 1, 5, 5, 6, 11, -1, -1, -1, -1,\n 6, 11, 3, 6, 3, 5, 5, 3, 1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 10, 9, 5, 11, 9, 11, 8, 11, 5, 6, -1, -1, -1, -1,\n 0, 11, 3, 0, 6, 11, 0, 9, 6, 5, 6, 9, 1, 2, 10, -1,\n 11, 8, 5, 11, 5, 6, 8, 0, 5, 10, 5, 2, 0, 2, 5, -1,\n 6, 11, 3, 6, 3, 5, 2, 10, 3, 10, 5, 3, -1, -1, -1, -1,\n 5, 8, 9, 5, 2, 8, 5, 6, 2, 3, 8, 2, -1, -1, -1, -1,\n 9, 5, 6, 9, 6, 0, 0, 6, 2, -1, -1, -1, -1, -1, -1, -1,\n 1, 5, 8, 1, 8, 0, 5, 6, 8, 3, 8, 2, 6, 2, 8, -1,\n 1, 5, 6, 2, 1, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 3, 6, 1, 6, 10, 3, 8, 6, 5, 6, 9, 8, 9, 6, -1,\n 10, 1, 0, 10, 0, 6, 9, 5, 0, 5, 6, 0, -1, -1, -1, -1,\n 0, 3, 8, 5, 6, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 10, 5, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 11, 5, 10, 7, 5, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 11, 5, 10, 11, 7, 5, 8, 3, 0, -1, -1, -1, -1, -1, -1, -1,\n 5, 11, 7, 5, 10, 11, 1, 9, 0, -1, -1, -1, -1, -1, -1, -1,\n 10, 7, 5, 10, 11, 7, 9, 8, 1, 8, 3, 1, -1, -1, -1, -1,\n 11, 1, 2, 11, 7, 1, 7, 5, 1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 1, 2, 7, 1, 7, 5, 7, 2, 11, -1, -1, -1, -1,\n 9, 7, 5, 9, 2, 7, 9, 0, 2, 2, 11, 7, -1, -1, -1, -1,\n 7, 5, 2, 7, 2, 11, 5, 9, 2, 3, 2, 8, 9, 8, 2, -1,\n 2, 5, 10, 2, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1,\n 8, 2, 0, 8, 5, 2, 8, 7, 5, 10, 2, 5, -1, -1, -1, -1,\n 9, 0, 1, 5, 10, 3, 5, 3, 7, 3, 10, 2, -1, -1, -1, -1,\n 9, 8, 2, 9, 2, 1, 8, 7, 2, 10, 2, 5, 7, 5, 2, -1,\n 1, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 7, 0, 7, 1, 1, 7, 5, -1, -1, -1, -1, -1, -1, -1,\n 9, 0, 3, 9, 3, 5, 5, 3, 7, -1, -1, -1, -1, -1, -1, -1,\n 9, 8, 7, 5, 9, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 5, 8, 4, 5, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1,\n 5, 0, 4, 5, 11, 0, 5, 10, 11, 11, 3, 0, -1, -1, -1, -1,\n 0, 1, 9, 8, 4, 10, 8, 10, 11, 10, 4, 5, -1, -1, -1, -1,\n 10, 11, 4, 10, 4, 5, 11, 3, 4, 9, 4, 1, 3, 1, 4, -1,\n 2, 5, 1, 2, 8, 5, 2, 11, 8, 4, 5, 8, -1, -1, -1, -1,\n 0, 4, 11, 0, 11, 3, 4, 5, 11, 2, 11, 1, 5, 1, 11, -1,\n 0, 2, 5, 0, 5, 9, 2, 11, 5, 4, 5, 8, 11, 8, 5, -1,\n 9, 4, 5, 2, 11, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 5, 10, 3, 5, 2, 3, 4, 5, 3, 8, 4, -1, -1, -1, -1,\n 5, 10, 2, 5, 2, 4, 4, 2, 0, -1, -1, -1, -1, -1, -1, -1,\n 3, 10, 2, 3, 5, 10, 3, 8, 5, 4, 5, 8, 0, 1, 9, -1,\n 5, 10, 2, 5, 2, 4, 1, 9, 2, 9, 4, 2, -1, -1, -1, -1,\n 8, 4, 5, 8, 5, 3, 3, 5, 1, -1, -1, -1, -1, -1, -1, -1,\n 0, 4, 5, 1, 0, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 8, 4, 5, 8, 5, 3, 9, 0, 5, 0, 3, 5, -1, -1, -1, -1,\n 9, 4, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 11, 7, 4, 9, 11, 9, 10, 11, -1, -1, -1, -1, -1, -1, -1,\n 0, 8, 3, 4, 9, 7, 9, 11, 7, 9, 10, 11, -1, -1, -1, -1,\n 1, 10, 11, 1, 11, 4, 1, 4, 0, 7, 4, 11, -1, -1, -1, -1,\n 3, 1, 4, 3, 4, 8, 1, 10, 4, 7, 4, 11, 10, 11, 4, -1,\n 4, 11, 7, 9, 11, 4, 9, 2, 11, 9, 1, 2, -1, -1, -1, -1,\n 9, 7, 4, 9, 11, 7, 9, 1, 11, 2, 11, 1, 0, 8, 3, -1,\n 11, 7, 4, 11, 4, 2, 2, 4, 0, -1, -1, -1, -1, -1, -1, -1,\n 11, 7, 4, 11, 4, 2, 8, 3, 4, 3, 2, 4, -1, -1, -1, -1,\n 2, 9, 10, 2, 7, 9, 2, 3, 7, 7, 4, 9, -1, -1, -1, -1,\n 9, 10, 7, 9, 7, 4, 10, 2, 7, 8, 7, 0, 2, 0, 7, -1,\n 3, 7, 10, 3, 10, 2, 7, 4, 10, 1, 10, 0, 4, 0, 10, -1,\n 1, 10, 2, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 9, 1, 4, 1, 7, 7, 1, 3, -1, -1, -1, -1, -1, -1, -1,\n 4, 9, 1, 4, 1, 7, 0, 8, 1, 8, 7, 1, -1, -1, -1, -1,\n 4, 0, 3, 7, 4, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 4, 8, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 9, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 9, 3, 9, 11, 11, 9, 10, -1, -1, -1, -1, -1, -1, -1,\n 0, 1, 10, 0, 10, 8, 8, 10, 11, -1, -1, -1, -1, -1, -1, -1,\n 3, 1, 10, 11, 3, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 2, 11, 1, 11, 9, 9, 11, 8, -1, -1, -1, -1, -1, -1, -1,\n 3, 0, 9, 3, 9, 11, 1, 2, 9, 2, 11, 9, -1, -1, -1, -1,\n 0, 2, 11, 8, 0, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 3, 2, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 3, 8, 2, 8, 10, 10, 8, 9, -1, -1, -1, -1, -1, -1, -1,\n 9, 10, 2, 0, 9, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 2, 3, 8, 2, 8, 10, 0, 1, 8, 1, 10, 8, -1, -1, -1, -1,\n 1, 10, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 1, 3, 8, 9, 1, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 9, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n 0, 3, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,\n -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1\n ])\n}\n\ninterface MarchingCubes {\n new (field: number[], nx: number, ny: number, nz: number, atomindex: number[]): void\n triangulate: (_isolevel: number, _noNormals: boolean, _box: number[][]|undefined, _contour: boolean, _wrap: boolean) => {\n position: Float32Array\n normal: undefined|Float32Array\n index: Uint32Array|Uint16Array\n atomindex: Int32Array|undefined\n contour: boolean\n }\n}\nfunction MarchingCubes (this: MarchingCubes, field: number[], nx: number, ny: number, nz: number, atomindex: number[]) {\n // Based on alteredq / http://alteredqualia.com/\n // port of greggman's ThreeD version of marching cubes to Three.js\n // http://webglsamples.googlecode.com/hg/blob/blob.html\n //\n // Adapted for NGL by Alexander Rose\n\n // Triangles are constructed between points on cube edges.\n // allowedContours[edge1][edge1] indicates which lines from a given\n // triangle should be shown in line mode.\n\n // Values are bitmasks:\n // In loop over cubes we keep another bitmask indicating whether our current\n // cell is the first x-value (1),\n // first y-value (2) or first z-value (4) of the current loop.\n // We draw all lines on leading faces but only draw trailing face lines the first\n // time through the loop\n // A value of 8 below means the edge is always drawn (leading face)\n\n // E.g. the first row, lines between edge0 and other edges in the bottom\n // x-y plane are only drawn for the first value of z, edges in the\n // x-z plane are only drawn for the first value of y. No other lines\n // are drawn as they're redundant\n // The line between edge 1 and 5 is always drawn as it's on the leading edge\n var allowedContours = [\n\n [ 0, 4, 4, 4, 2, 0, 0, 0, 2, 2, 0, 0 ], // 1 2 3 4 8 9\n [ 4, 0, 4, 4, 0, 8, 0, 0, 0, 8, 8, 0 ], // 0 2 3 5 9 10\n [ 4, 4, 0, 4, 0, 0, 8, 0, 0, 0, 8, 8 ], // 0 1 3 6 10 11\n [ 4, 4, 4, 0, 0, 0, 0, 1, 1, 0, 0, 1 ], // 0 1 2 7 8 11\n [ 2, 0, 0, 0, 0, 8, 8, 8, 2, 2, 0, 0 ], // 0 5 6 7 8 9\n [ 0, 8, 0, 0, 8, 0, 8, 8, 0, 8, 8, 0 ], // And rotate it\n [ 0, 0, 8, 0, 8, 8, 0, 8, 0, 0, 8, 8 ],\n [ 0, 0, 0, 1, 8, 8, 8, 0, 1, 0, 0, 1 ],\n [ 2, 0, 0, 1, 2, 0, 0, 1, 0, 2, 0, 1 ], // 0 3 4 7 9 11\n [ 2, 8, 0, 0, 2, 8, 0, 0, 2, 0, 8, 0 ], // And rotate some more\n [ 0, 8, 8, 0, 0, 8, 8, 0, 0, 8, 0, 8 ],\n [ 0, 0, 8, 1, 0, 0, 8, 1, 1, 0, 8, 0 ]\n\n ]\n\n var isolevel = 0\n var noNormals = false\n var contour = false\n var wrap = false\n var isNegativeIso = false\n var normalFactor = -1\n\n\n var n = nx * ny * nz\n\n // deltas\n var yd = nx\n var zd = nx * ny\n\n var normalCache: Float32Array, vertexIndex: Int32Array\n var count: number, icount: number\n\n var ilist = new Int32Array(12)\n\n var positionArray: number[] = []\n var normalArray: number[] = []\n var indexArray: number[] = []\n var atomindexArray: number[] = []\n\n var edgeTable = getEdgeTable()\n var triTable = getTriTable()\n\n var mx: number, my: number, mz: number\n\n //\n\n this.triangulate = function (_isolevel: number, _noNormals: boolean, _box: number[][]|undefined, _contour: boolean, _wrap: boolean) {\n isolevel = _isolevel\n isNegativeIso = isolevel < 0.0\n contour = _contour\n wrap = _wrap\n // Normals currently disabled in contour mode for performance (unused)\n noNormals = _noNormals || contour\n\n if (!noNormals) {\n normalFactor = isolevel > 0 ? -1.0 : 1.0\n if (!normalCache) {\n normalCache = new Float32Array(n * 3)\n } \n }\n\n var vIndexLength = n * 3\n\n if (!vertexIndex || vertexIndex.length !== vIndexLength) {\n vertexIndex = new Int32Array(vIndexLength)\n }\n\n count = 0\n icount = 0\n\n if (_box !== undefined) {\n var min = _box[ 0 ].map(Math.round)\n var max = _box[ 1 ].map(Math.round)\n\n mx = nx * Math.ceil(Math.abs(min[ 0 ]) / nx)\n my = ny * Math.ceil(Math.abs(min[ 1 ]) / ny)\n mz = nz * Math.ceil(Math.abs(min[ 2 ]) / nz)\n\n triangulate(\n min[ 0 ], min[ 1 ], min[ 2 ],\n max[ 0 ], max[ 1 ], max[ 2 ]\n )\n } else {\n mx = my = mz = 0\n\n triangulate()\n }\n\n positionArray.length = count * 3\n if (!noNormals) normalArray.length = count * 3\n indexArray.length = icount\n if (atomindex) atomindexArray.length = count\n\n return {\n position: new Float32Array(positionArray),\n normal: noNormals ? undefined : new Float32Array(normalArray),\n index: getUintArray(indexArray, positionArray.length / 3),\n atomindex: atomindex ? new Int32Array(atomindexArray) : undefined,\n contour: contour\n }\n }\n\n // polygonization\n\n function lerp (a: number, b: number, t: number) { return a + (b - a) * t }\n\n function index (x: number, y: number, z: number) {\n x = (x + mx) % nx\n y = (y + my) % ny\n z = (z + mz) % nz\n return ((zd * z) + yd * y) + x\n }\n\n function VIntX (q: number, offset: number, x: number, y: number, z: number, valp1: number, valp2: number) {\n var _q = 3 * q\n\n if (vertexIndex[ _q ] < 0) {\n var mu = (isolevel - valp1) / (valp2 - valp1)\n var nc = normalCache\n\n var c = count * 3\n\n positionArray[ c ] = x + mu\n positionArray[ c + 1 ] = y\n positionArray[ c + 2 ] = z\n\n if (!noNormals) {\n var q3 = q * 3\n\n normalArray[ c ] = normalFactor * lerp(nc[ q3 ], nc[ q3 + 3 ], mu)\n normalArray[ c + 1 ] = normalFactor * lerp(nc[ q3 + 1 ], nc[ q3 + 4 ], mu)\n normalArray[ c + 2 ] = normalFactor * lerp(nc[ q3 + 2 ], nc[ q3 + 5 ], mu)\n }\n\n if (atomindex) atomindexArray[ count ] = atomindex[ q + Math.round(mu) ]\n\n vertexIndex[ _q ] = count\n ilist[ offset ] = count\n\n count += 1\n } else {\n ilist[ offset ] = vertexIndex[ _q ]\n }\n }\n\n function VIntY (q: number, offset: number, x: number, y: number, z: number, valp1: number, valp2: number) {\n var _q = 3 * q + 1\n\n if (vertexIndex[ _q ] < 0) {\n var mu = (isolevel - valp1) / (valp2 - valp1)\n var nc = normalCache\n\n var c = count * 3\n\n positionArray[ c ] = x\n positionArray[ c + 1 ] = y + mu\n positionArray[ c + 2 ] = z\n\n if (!noNormals) {\n var q3 = q * 3\n var q6 = q3 + yd * 3\n\n normalArray[ c ] = normalFactor * lerp(nc[ q3 ], nc[ q6 ], mu)\n normalArray[ c + 1 ] = normalFactor * lerp(nc[ q3 + 1 ], nc[ q6 + 1 ], mu)\n normalArray[ c + 2 ] = normalFactor * lerp(nc[ q3 + 2 ], nc[ q6 + 2 ], mu)\n }\n\n if (atomindex) atomindexArray[ count ] = atomindex[ q + Math.round(mu) * yd ]\n\n vertexIndex[ _q ] = count\n ilist[ offset ] = count\n\n count += 1\n } else {\n ilist[ offset ] = vertexIndex[ _q ]\n }\n }\n\n function VIntZ (q: number, offset: number, x: number, y: number, z: number, valp1: number, valp2: number) {\n var _q = 3 * q + 2\n\n if (vertexIndex[ _q ] < 0) {\n var mu = (isolevel - valp1) / (valp2 - valp1)\n var nc = normalCache\n\n var c = count * 3\n\n positionArray[ c ] = x\n positionArray[ c + 1 ] = y\n positionArray[ c + 2 ] = z + mu\n\n if (!noNormals) {\n var q3 = q * 3\n var q6 = q3 + zd * 3\n\n normalArray[ c ] = normalFactor * lerp(nc[ q3 ], nc[ q6 ], mu)\n normalArray[ c + 1 ] = normalFactor * lerp(nc[ q3 + 1 ], nc[ q6 + 1 ], mu)\n normalArray[ c + 2 ] = normalFactor * lerp(nc[ q3 + 2 ], nc[ q6 + 2 ], mu)\n }\n\n if (atomindex) atomindexArray[ count ] = atomindex[ q + Math.round(mu) * zd ]\n\n vertexIndex[ _q ] = count\n ilist[ offset ] = count\n\n count += 1\n } else {\n ilist[ offset ] = vertexIndex[ _q ]\n }\n }\n\n function compNorm (q: number) {\n var q3 = q * 3\n\n if (normalCache[ q3 ] === 0.0) {\n normalCache[ q3 ] = field[ (q - 1 + n) % n ] - field[ (q + 1) % n ]\n normalCache[ q3 + 1 ] = field[ (q - yd + n) % n ] - field[ (q + yd) % n ]\n normalCache[ q3 + 2 ] = field[ (q - zd + n) % n ] - field[ (q + zd) % n ]\n }\n }\n\n function polygonize (fx: number, fy: number, fz: number, q: number, edgeFilter: number) {\n // cache indices\n var q1\n var qy\n var qz\n var q1y\n var q1z\n var qyz\n var q1yz\n if (wrap) {\n q = index(fx, fy, fz)\n q1 = index(fx + 1, fy, fz)\n qy = index(fx, fy + 1, fz)\n qz = index(fx, fy, fz + 1)\n q1y = index(fx + 1, fy + 1, fz)\n q1z = index(fx + 1, fy, fz + 1)\n qyz = index(fx, fy + 1, fz + 1)\n q1yz = index(fx + 1, fy + 1, fz + 1)\n } else {\n q1 = q + 1\n qy = q + yd\n qz = q + zd\n q1y = qy + 1\n q1z = qz + 1\n qyz = qy + zd\n q1yz = qyz + 1\n }\n\n var cubeindex = 0\n var field0 = field[ q ]\n var field1 = field[ q1 ]\n var field2 = field[ qy ]\n var field3 = field[ q1y ]\n var field4 = field[ qz ]\n var field5 = field[ q1z ]\n var field6 = field[ qyz ]\n var field7 = field[ q1yz ]\n\n if (field0 < isolevel) cubeindex |= 1\n if (field1 < isolevel) cubeindex |= 2\n if (field2 < isolevel) cubeindex |= 8\n if (field3 < isolevel) cubeindex |= 4\n if (field4 < isolevel) cubeindex |= 16\n if (field5 < isolevel) cubeindex |= 32\n if (field6 < isolevel) cubeindex |= 128\n if (field7 < isolevel) cubeindex |= 64\n\n // if cube is entirely in/out of the surface - bail, nothing to draw\n\n var bits = edgeTable[ cubeindex ]\n if (bits === 0) return 0\n\n var fx2 = fx + 1\n var fy2 = fy + 1\n var fz2 = fz + 1\n\n // top of the cube\n\n if (bits & 1) {\n if (!noNormals) {\n compNorm(q)\n compNorm(q1)\n }\n VIntX(q, 0, fx, fy, fz, field0, field1)\n }\n\n if (bits & 2) {\n if (!noNormals) {\n compNorm(q1)\n compNorm(q1y)\n }\n VIntY(q1, 1, fx2, fy, fz, field1, field3)\n }\n\n if (bits & 4) {\n if (!noNormals) {\n compNorm(qy)\n compNorm(q1y)\n }\n VIntX(qy, 2, fx, fy2, fz, field2, field3)\n }\n\n if (bits & 8) {\n if (!noNormals) {\n compNorm(q)\n compNorm(qy)\n }\n VIntY(q, 3, fx, fy, fz, field0, field2)\n }\n\n // bottom of the cube\n\n if (bits & 16) {\n if (!noNormals) {\n compNorm(qz)\n compNorm(q1z)\n }\n VIntX(qz, 4, fx, fy, fz2, field4, field5)\n }\n\n if (bits & 32) {\n if (!noNormals) {\n compNorm(q1z)\n compNorm(q1yz)\n }\n VIntY(q1z, 5, fx2, fy, fz2, field5, field7)\n }\n\n if (bits & 64) {\n if (!noNormals) {\n compNorm(qyz)\n compNorm(q1yz)\n }\n VIntX(qyz, 6, fx, fy2, fz2, field6, field7)\n }\n\n if (bits & 128) {\n if (!noNormals) {\n compNorm(qz)\n compNorm(qyz)\n }\n VIntY(qz, 7, fx, fy, fz2, field4, field6)\n }\n\n // vertical lines of the cube\n\n if (bits & 256) {\n if (!noNormals) {\n compNorm(q)\n compNorm(qz)\n }\n VIntZ(q, 8, fx, fy, fz, field0, field4)\n }\n\n if (bits & 512) {\n if (!noNormals) {\n compNorm(q1)\n compNorm(q1z)\n }\n VIntZ(q1, 9, fx2, fy, fz, field1, field5)\n }\n\n if (bits & 1024) {\n if (!noNormals) {\n compNorm(q1y)\n compNorm(q1yz)\n }\n VIntZ(q1y, 10, fx2, fy2, fz, field3, field7)\n }\n\n if (bits & 2048) {\n if (!noNormals) {\n compNorm(qy)\n compNorm(qyz)\n }\n VIntZ(qy, 11, fx, fy2, fz, field2, field6)\n }\n\n var triIndex = cubeindex << 4 // re-purpose cubeindex into an offset into triTable\n\n var e1\n var e2\n var e3\n var i = 0\n\n // here is where triangles are created\n\n while (triTable[ triIndex + i ] !== -1) {\n e1 = triTable[ triIndex + i ]\n e2 = triTable[ triIndex + i + 1 ]\n e3 = triTable[ triIndex + i + 2 ]\n\n if (contour) {\n if (allowedContours[ e1 ][ e2 ] & edgeFilter) {\n indexArray[ icount++ ] = ilist[ e1 ]\n indexArray[ icount++ ] = ilist[ e2 ]\n }\n if (allowedContours[ e2 ][ e3 ] & edgeFilter) {\n indexArray[ icount++ ] = ilist[ e2 ]\n indexArray[ icount++ ] = ilist[ e3 ]\n }\n if (allowedContours[ e1 ][ e3 ] & edgeFilter) {\n indexArray[ icount++ ] = ilist[ e1 ]\n indexArray[ icount++ ] = ilist[ e3 ]\n }\n } else {\n indexArray[ icount++ ] = ilist[ isNegativeIso ? e1 : e2 ]\n indexArray[ icount++ ] = ilist[ isNegativeIso ? e2 : e1 ]\n indexArray[ icount++ ] = ilist[ e3 ]\n }\n\n i += 3\n }\n }\n\n function triangulate (xBeg?: number, yBeg?: number, zBeg?: number, xEnd?: number, yEnd?: number, zEnd?: number) {\n let q\n let q3\n let x\n let y\n let z\n let yOffset\n let zOffset\n\n xBeg = xBeg !== undefined ? xBeg : 0\n yBeg = yBeg !== undefined ? yBeg : 0\n zBeg = zBeg !== undefined ? zBeg : 0\n\n xEnd = xEnd !== undefined ? xEnd : nx - 1\n yEnd = yEnd !== undefined ? yEnd : ny - 1\n zEnd = zEnd !== undefined ? zEnd : nz - 1\n\n if (!wrap) {\n if (noNormals) {\n xBeg = Math.max(0, xBeg)\n yBeg = Math.max(0, yBeg)\n zBeg = Math.max(0, zBeg)\n\n xEnd = Math.min(nx - 1, xEnd)\n yEnd = Math.min(ny - 1, yEnd)\n zEnd = Math.min(nz - 1, zEnd)\n } else {\n xBeg = Math.max(1, xBeg)\n yBeg = Math.max(1, yBeg)\n zBeg = Math.max(1, zBeg)\n\n xEnd = Math.min(nx - 2, xEnd)\n yEnd = Math.min(ny - 2, yEnd)\n zEnd = Math.min(nz - 2, zEnd)\n }\n }\n\n let xBeg2, yBeg2, zBeg2, xEnd2, yEnd2, zEnd2\n\n if (!wrap) {\n // init part of the vertexIndex\n // (takes a significant amount of time to do for all)\n\n xBeg2 = Math.max(0, xBeg - 2)\n yBeg2 = Math.max(0, yBeg - 2)\n zBeg2 = Math.max(0, zBeg - 2)\n\n xEnd2 = Math.min(nx, xEnd + 2)\n yEnd2 = Math.min(ny, yEnd + 2)\n zEnd2 = Math.min(nz, zEnd + 2)\n\n for (z = zBeg2; z < zEnd2; ++z) {\n zOffset = zd * z\n for (y = yBeg2; y < yEnd2; ++y) {\n yOffset = zOffset + yd * y\n for (x = xBeg2; x < xEnd2; ++x) {\n q = 3 * (yOffset + x)\n vertexIndex[ q ] = -1\n vertexIndex[ q + 1 ] = -1\n vertexIndex[ q + 2 ] = -1\n }\n }\n }\n } else {\n xBeg2 = xBeg - 2\n yBeg2 = yBeg - 2\n zBeg2 = zBeg - 2\n\n xEnd2 = xEnd + 2\n yEnd2 = yEnd + 2\n zEnd2 = zEnd + 2\n\n for (z = zBeg2; z < zEnd2; ++z) {\n for (y = yBeg2; y < yEnd2; ++y) {\n for (x = xBeg2; x < xEnd2; ++x) {\n q3 = index(x, y, z) * 3\n vertexIndex[ q3 ] = -1\n vertexIndex[ q3 + 1 ] = -1\n vertexIndex[ q3 + 2 ] = -1\n }\n }\n }\n }\n\n if (!wrap) {\n // clip space where the isovalue is too low\n\n var __break\n var __xBeg = xBeg; var __yBeg = yBeg; var __zBeg = zBeg\n var __xEnd = xEnd; var __yEnd = yEnd; var __zEnd = zEnd\n\n __break = false\n for (z = zBeg; z < zEnd; ++z) {\n for (y = yBeg; y < yEnd; ++y) {\n for (x = xBeg; x < xEnd; ++x) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __zBeg = z\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (y = yBeg; y < yEnd; ++y) {\n for (z = __zBeg; z < zEnd; ++z) {\n for (x = xBeg; x < xEnd; ++x) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __yBeg = y\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (x = xBeg; x < xEnd; ++x) {\n for (y = __yBeg; y < yEnd; ++y) {\n for (z = __zBeg; z < zEnd; ++z) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __xBeg = x\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (z = zEnd; z >= zBeg; --z) {\n for (y = yEnd; y >= yBeg; --y) {\n for (x = xEnd; x >= xBeg; --x) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __zEnd = z\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (y = yEnd; y >= yBeg; --y) {\n for (z = __zEnd; z >= zBeg; --z) {\n for (x = xEnd; x >= xBeg; --x) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __yEnd = y\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n __break = false\n for (x = xEnd; x >= xBeg; --x) {\n for (y = __yEnd; y >= yBeg; --y) {\n for (z = __zEnd; z >= zBeg; --z) {\n q = ((nx * ny) * z) + (nx * y) + x\n if (field[ q ] >= isolevel) {\n __xEnd = x\n __break = true\n break\n }\n }\n if (__break) break\n }\n if (__break) break\n }\n\n //\n\n if (noNormals) {\n xBeg = Math.max(0, __xBeg - 1)\n yBeg = Math.max(0, __yBeg - 1)\n zBeg = Math.max(0, __zBeg - 1)\n\n xEnd = Math.min(nx - 1, __xEnd + 1)\n yEnd = Math.min(ny - 1, __yEnd + 1)\n zEnd = Math.min(nz - 1, __zEnd + 1)\n } else {\n xBeg = Math.max(1, __xBeg - 1)\n yBeg = Math.max(1, __yBeg - 1)\n zBeg = Math.max(1, __zBeg - 1)\n\n xEnd = Math.min(nx - 2, __xEnd + 1)\n yEnd = Math.min(ny - 2, __yEnd + 1)\n zEnd = Math.min(nz - 2, __zEnd + 1)\n }\n }\n\n // polygonize part of the grid\n var edgeFilter = 15\n for (z = zBeg; z < zEnd; ++z, edgeFilter &= ~4) {\n zOffset = zd * z\n edgeFilter |= 2\n for (y = yBeg; y < yEnd; ++y, edgeFilter &= ~2) {\n yOffset = zOffset + yd * y\n edgeFilter |= 1\n for (x = xBeg; x < xEnd; ++x, edgeFilter &= ~1) {\n q = yOffset + x\n polygonize(x, y, z, q, edgeFilter)\n }\n }\n }\n }\n}\nObject.assign(MarchingCubes, {__deps: [ getEdgeTable, getTriTable, getUintArray ]})\n\nexport default MarchingCubes\n","/**\n * @file Matrix Utils\n * @private\n * @author Alexander Rose \n *\n * svd methods from Eugene Zatepyakin / http://inspirit.github.io/jsfeat/\n */\n\nimport { NumberArray } from '../types'\nimport { v3new, v3cross } from './vector-utils'\n\nexport class Matrix {\n size: number\n data: Float32Array\n\n constructor (readonly cols: number, readonly rows: number) {\n this.size = this.cols * this.rows\n this.data = new Float32Array(this.size)\n }\n\n copyTo (matrix: Matrix) {\n matrix.data.set(this.data)\n }\n}\n\nexport function transpose (At: Matrix, A: Matrix) {\n let i = 0\n let j = 0\n const nrows = A.rows\n const ncols = A.cols\n let Ai = 0\n let Ati = 0\n let pAt = 0\n const ad = A.data\n const atd = At.data\n\n for (; i < nrows; Ati += 1, Ai += ncols, i++) {\n pAt = Ati\n for (j = 0; j < ncols; pAt += nrows, j++) atd[pAt] = ad[Ai + j]\n }\n}\n\n// C = A * B\nexport function multiply (C: Matrix, A: Matrix, B: Matrix) {\n let i = 0\n let j = 0\n let k = 0\n let Ap = 0\n let pA = 0\n let pB = 0\n let _pB = 0\n let Cp = 0\n const ncols = A.cols\n const nrows = A.rows\n const mcols = B.cols\n const ad = A.data\n const bd = B.data\n const cd = C.data\n let sum = 0.0\n\n for (; i < nrows; Ap += ncols, i++) {\n for (_pB = 0, j = 0; j < mcols; Cp++, _pB++, j++) {\n pB = _pB\n pA = Ap\n sum = 0.0\n for (k = 0; k < ncols; pA++, pB += mcols, k++) {\n sum += ad[pA] * bd[pB]\n }\n cd[Cp] = sum\n }\n }\n}\n\n// C = A * B'\nexport function multiplyABt (C: Matrix, A: Matrix, B: Matrix) {\n let i = 0\n let j = 0\n let k = 0\n let Ap = 0\n let pA = 0\n let pB = 0\n let Cp = 0\n const ncols = A.cols\n const nrows = A.rows\n const mrows = B.rows\n const ad = A.data\n const bd = B.data\n const cd = C.data\n let sum = 0.0\n\n for (; i < nrows; Ap += ncols, i++) {\n for (pB = 0, j = 0; j < mrows; Cp++, j++) {\n pA = Ap\n sum = 0.0\n for (k = 0; k < ncols; pA++, pB++, k++) {\n sum += ad[pA] * bd[pB]\n }\n cd[Cp] = sum\n }\n }\n}\n\n// C = A' * B\nexport function multiplyAtB (C: Matrix, A: Matrix, B: Matrix) {\n let i = 0\n let j = 0\n let k = 0\n let Ap = 0\n let pA = 0\n let pB = 0\n let _pB = 0\n let Cp = 0\n const ncols = A.cols\n const nrows = A.rows\n const mcols = B.cols\n const ad = A.data\n const bd = B.data\n const cd = C.data\n let sum = 0.0\n\n for (; i < ncols; Ap++, i++) {\n for (_pB = 0, j = 0; j < mcols; Cp++, _pB++, j++) {\n pB = _pB\n pA = Ap\n sum = 0.0\n for (k = 0; k < nrows; pA += ncols, pB += mcols, k++) {\n sum += ad[pA] * bd[pB]\n }\n cd[Cp] = sum\n }\n }\n}\n\nexport function invert3x3 (from: Matrix, to: Matrix) {\n const A = from.data\n const invA = to.data\n const t1 = A[4]\n const t2 = A[8]\n const t4 = A[5]\n const t5 = A[7]\n const t8 = A[0]\n\n const t9 = t8 * t1\n const t11 = t8 * t4\n const t13 = A[3]\n const t14 = A[1]\n const t15 = t13 * t14\n const t17 = A[2]\n const t18 = t13 * t17\n const t20 = A[6]\n const t21 = t20 * t14\n const t23 = t20 * t17\n const t26 = 1.0 / (t9 * t2 - t11 * t5 - t15 * t2 + t18 * t5 + t21 * t4 - t23 * t1)\n invA[0] = (t1 * t2 - t4 * t5) * t26\n invA[1] = -(t14 * t2 - t17 * t5) * t26\n invA[2] = -(-t14 * t4 + t17 * t1) * t26\n invA[3] = -(t13 * t2 - t4 * t20) * t26\n invA[4] = (t8 * t2 - t23) * t26\n invA[5] = -(t11 - t18) * t26\n invA[6] = -(-t13 * t5 + t1 * t20) * t26\n invA[7] = -(t8 * t5 - t21) * t26\n invA[8] = (t9 - t15) * t26\n}\n\nexport function mat3x3determinant (M: Matrix) {\n const md = M.data\n return md[0] * md[4] * md[8] -\n md[0] * md[5] * md[7] -\n md[3] * md[1] * md[8] +\n md[3] * md[2] * md[7] +\n md[6] * md[1] * md[5] -\n md[6] * md[2] * md[4]\n}\n\n// C = A * B\nexport function multiply3x3 (C: Matrix, A: Matrix, B: Matrix) {\n const Cd = C.data\n const Ad = A.data\n const Bd = B.data\n const m10 = Ad[0]\n const m11 = Ad[1]\n const m12 = Ad[2]\n const m13 = Ad[3]\n const m14 = Ad[4]\n const m15 = Ad[5]\n const m16 = Ad[6]\n const m17 = Ad[7]\n const m18 = Ad[8]\n\n const m20 = Bd[0]\n const m21 = Bd[1]\n const m22 = Bd[2]\n const m23 = Bd[3]\n const m24 = Bd[4]\n const m25 = Bd[5]\n const m26 = Bd[6]\n const m27 = Bd[7]\n const m28 = Bd[8]\n\n Cd[0] = m10 * m20 + m11 * m23 + m12 * m26\n Cd[1] = m10 * m21 + m11 * m24 + m12 * m27\n Cd[2] = m10 * m22 + m11 * m25 + m12 * m28\n Cd[3] = m13 * m20 + m14 * m23 + m15 * m26\n Cd[4] = m13 * m21 + m14 * m24 + m15 * m27\n Cd[5] = m13 * m22 + m14 * m25 + m15 * m28\n Cd[6] = m16 * m20 + m17 * m23 + m18 * m26\n Cd[7] = m16 * m21 + m17 * m24 + m18 * m27\n Cd[8] = m16 * m22 + m17 * m25 + m18 * m28\n}\n\nexport function meanRows (A: Matrix) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n const mean = new Array(ncols)\n\n for (let j = 0; j < ncols; ++j) {\n mean[ j ] = 0.0\n }\n\n for (let i = 0, p = 0; i < nrows; ++i) {\n for (let j = 0; j < ncols; ++j, ++p) {\n mean[ j ] += Ad[ p ]\n }\n }\n\n for (let j = 0; j < ncols; ++j) {\n mean[ j ] /= nrows\n }\n\n return mean\n}\n\nexport function meanCols (A: Matrix) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n const mean = new Array(nrows)\n\n for (let j = 0; j < nrows; ++j) {\n mean[ j ] = 0.0\n }\n\n for (let i = 0, p = 0; i < ncols; ++i) {\n for (let j = 0; j < nrows; ++j, ++p) {\n mean[ j ] += Ad[ p ]\n }\n }\n\n for (let j = 0; j < nrows; ++j) {\n mean[ j ] /= ncols\n }\n\n return mean\n}\n\nexport function subRows (A: Matrix, row: number[]) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n\n for (let i = 0, p = 0; i < nrows; ++i) {\n for (let j = 0; j < ncols; ++j, ++p) {\n Ad[ p ] -= row[ j ]\n }\n }\n}\n\nexport function subCols (A: Matrix, col: number[]) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n\n for (let i = 0, p = 0; i < ncols; ++i) {\n for (let j = 0; j < nrows; ++j, ++p) {\n Ad[ p ] -= col[ j ]\n }\n }\n}\n\nexport function addRows (A: Matrix, row: number[]) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n\n for (let i = 0, p = 0; i < nrows; ++i) {\n for (let j = 0; j < ncols; ++j, ++p) {\n Ad[ p ] += row[ j ]\n }\n }\n}\n\nexport function addCols (A: Matrix, col: number[]) {\n const nrows = A.rows\n const ncols = A.cols\n const Ad = A.data\n\n for (let i = 0, p = 0; i < ncols; ++i) {\n for (let j = 0; j < nrows; ++j, ++p) {\n Ad[ p ] += col[ j ]\n }\n }\n}\n\nexport function swap (A: NumberArray, i0: number, i1: number, t: number) {\n t = A[i0]\n A[i0] = A[i1]\n A[i1] = t\n}\n\nexport function hypot (a: number, b: number) {\n a = Math.abs(a)\n b = Math.abs(b)\n if (a > b) {\n b /= a\n return a * Math.sqrt(1.0 + b * b)\n }\n if (b > 0) {\n a /= b\n return b * Math.sqrt(1.0 + a * a)\n }\n return 0.0\n}\n\nconst EPSILON = 0.0000001192092896\nconst FLT_MIN = 1E-37\n\nexport function JacobiSVDImpl (At: NumberArray, astep: number, _W: NumberArray, Vt: NumberArray, vstep: number, m: number, n: number, n1: number) {\n const eps = EPSILON * 2.0\n const minval = FLT_MIN\n let i = 0\n let j = 0\n let k = 0\n let iter = 0\n const maxIter = Math.max(m, 30)\n let Ai = 0\n let Aj = 0\n let Vi = 0\n let Vj = 0\n let changed = 0\n let c = 0.0\n let s = 0.0\n let t = 0.0\n let t0 = 0.0\n let t1 = 0.0\n let sd = 0.0\n let beta = 0.0\n let gamma = 0.0\n let delta = 0.0\n let a = 0.0\n let p = 0.0\n let b = 0.0\n let seed = 0x1234\n let val = 0.0\n let val0 = 0.0\n let asum = 0.0\n\n const W = new Float64Array(n << 3)\n\n for (; i < n; i++) {\n for (k = 0, sd = 0; k < m; k++) {\n t = At[i * astep + k]\n sd += t * t\n }\n W[i] = sd\n\n if (Vt) {\n for (k = 0; k < n; k++) {\n Vt[i * vstep + k] = 0\n }\n Vt[i * vstep + i] = 1\n }\n }\n\n for (; iter < maxIter; iter++) {\n changed = 0\n\n for (i = 0; i < n - 1; i++) {\n for (j = i + 1; j < n; j++) {\n Ai = (i * astep) | 0\n Aj = (j * astep) | 0\n a = W[i]\n p = 0\n b = W[j]\n\n k = 2\n p += At[Ai] * At[Aj]\n p += At[Ai + 1] * At[Aj + 1]\n\n for (; k < m; k++) { p += At[Ai + k] * At[Aj + k] }\n\n if (Math.abs(p) <= eps * Math.sqrt(a * b)) continue\n\n p *= 2.0\n beta = a - b\n gamma = hypot(p, beta)\n if (beta < 0) {\n delta = (gamma - beta) * 0.5\n s = Math.sqrt(delta / gamma)\n c = (p / (gamma * s * 2.0))\n } else {\n c = Math.sqrt((gamma + beta) / (gamma * 2.0))\n s = (p / (gamma * c * 2.0))\n }\n\n a = 0.0\n b = 0.0\n\n k = 2 // unroll\n t0 = c * At[Ai] + s * At[Aj]\n t1 = -s * At[Ai] + c * At[Aj]\n At[Ai] = t0; At[Aj] = t1\n a += t0 * t0; b += t1 * t1\n\n t0 = c * At[Ai + 1] + s * At[Aj + 1]\n t1 = -s * At[Ai + 1] + c * At[Aj + 1]\n At[Ai + 1] = t0; At[Aj + 1] = t1\n a += t0 * t0; b += t1 * t1\n\n for (; k < m; k++) {\n t0 = c * At[Ai + k] + s * At[Aj + k]\n t1 = -s * At[Ai + k] + c * At[Aj + k]\n At[Ai + k] = t0; At[Aj + k] = t1\n\n a += t0 * t0; b += t1 * t1\n }\n\n W[i] = a\n W[j] = b\n\n changed = 1\n\n if (Vt) {\n Vi = (i * vstep) | 0\n Vj = (j * vstep) | 0\n\n k = 2\n t0 = c * Vt[Vi] + s * Vt[Vj]\n t1 = -s * Vt[Vi] + c * Vt[Vj]\n Vt[Vi] = t0; Vt[Vj] = t1\n\n t0 = c * Vt[Vi + 1] + s * Vt[Vj + 1]\n t1 = -s * Vt[Vi + 1] + c * Vt[Vj + 1]\n Vt[Vi + 1] = t0; Vt[Vj + 1] = t1\n\n for (; k < n; k++) {\n t0 = c * Vt[Vi + k] + s * Vt[Vj + k]\n t1 = -s * Vt[Vi + k] + c * Vt[Vj + k]\n Vt[Vi + k] = t0; Vt[Vj + k] = t1\n }\n }\n }\n }\n if (changed === 0) break\n }\n\n for (i = 0; i < n; i++) {\n for (k = 0, sd = 0; k < m; k++) {\n t = At[i * astep + k]\n sd += t * t\n }\n W[i] = Math.sqrt(sd)\n }\n\n for (i = 0; i < n - 1; i++) {\n j = i\n for (k = i + 1; k < n; k++) {\n if (W[j] < W[k]) { j = k }\n }\n if (i !== j) {\n swap(W, i, j, sd)\n if (Vt) {\n for (k = 0; k < m; k++) {\n swap(At, i * astep + k, j * astep + k, t)\n }\n\n for (k = 0; k < n; k++) {\n swap(Vt, i * vstep + k, j * vstep + k, t)\n }\n }\n }\n }\n\n for (i = 0; i < n; i++) {\n _W[i] = W[i]\n }\n\n if (!Vt) {\n return\n }\n\n for (i = 0; i < n1; i++) {\n sd = i < n ? W[i] : 0\n\n while (sd <= minval) {\n // if we got a zero singular value, then in order to get the corresponding left singular vector\n // we generate a random vector, project it to the previously computed left singular vectors,\n // subtract the projection and normalize the difference.\n val0 = (1.0 / m)\n for (k = 0; k < m; k++) {\n seed = (seed * 214013 + 2531011)\n val = (((seed >> 16) & 0x7fff) & 256) !== 0 ? val0 : -val0\n At[i * astep + k] = val\n }\n for (iter = 0; iter < 2; iter++) {\n for (j = 0; j < i; j++) {\n sd = 0\n for (k = 0; k < m; k++) {\n sd += At[i * astep + k] * At[j * astep + k]\n }\n asum = 0.0\n for (k = 0; k < m; k++) {\n t = (At[i * astep + k] - sd * At[j * astep + k])\n At[i * astep + k] = t\n asum += Math.abs(t)\n }\n asum = asum ? 1.0 / asum : 0\n for (k = 0; k < m; k++) {\n At[i * astep + k] *= asum\n }\n }\n }\n sd = 0\n for (k = 0; k < m; k++) {\n t = At[i * astep + k]\n sd += t * t\n }\n sd = Math.sqrt(sd)\n }\n\n s = (1.0 / sd)\n for (k = 0; k < m; k++) {\n At[i * astep + k] *= s\n }\n }\n}\n\nexport function svd (A: Matrix, W: Matrix, U: Matrix, V: Matrix) {\n let at = 0\n let i = 0\n const _m = A.rows\n const _n = A.cols\n let m = _m\n let n = _n\n\n if (m < n) {\n at = 1\n i = m\n m = n\n n = i\n }\n\n const amt = new Matrix(m, m)\n const wmt = new Matrix(1, n)\n const vmt = new Matrix(n, n)\n\n if (at === 0) {\n transpose(amt, A)\n } else {\n for (i = 0; i < _n * _m; i++) {\n amt.data[i] = A.data[i]\n }\n for (; i < n * m; i++) {\n amt.data[i] = 0\n }\n }\n\n JacobiSVDImpl(amt.data, m, wmt.data, vmt.data, n, m, n, m)\n\n if (W) {\n for (i = 0; i < n; i++) {\n W.data[i] = wmt.data[i]\n }\n for (; i < _n; i++) {\n W.data[i] = 0\n }\n }\n\n if (at === 0) {\n if (U) transpose(U, amt)\n if (V) transpose(V, vmt)\n } else {\n if (U) transpose(U, vmt)\n if (V) transpose(V, amt)\n }\n}\n\n//\n\nexport function m4new () {\n return new Float32Array([\n 1, 0, 0, 0,\n 0, 1, 0, 0,\n 0, 0, 1, 0,\n 0, 0, 0, 1\n ])\n}\n\nexport function m4set (out: Float32Array, n11: number, n12: number, n13: number, n14: number, n21: number, n22: number, n23: number, n24: number, n31: number, n32: number, n33: number, n34: number, n41: number, n42: number, n43: number, n44: number) {\n out[ 0 ] = n11; out[ 4 ] = n12; out[ 8 ] = n13; out[ 12 ] = n14\n out[ 1 ] = n21; out[ 5 ] = n22; out[ 9 ] = n23; out[ 13 ] = n24\n out[ 2 ] = n31; out[ 6 ] = n32; out[ 10 ] = n33; out[ 14 ] = n34\n out[ 3 ] = n41; out[ 7 ] = n42; out[ 11 ] = n43; out[ 15 ] = n44\n}\n\nexport function m4identity (out: Float32Array) {\n m4set(out,\n 1, 0, 0, 0,\n 0, 1, 0, 0,\n 0, 0, 1, 0,\n 0, 0, 0, 1\n )\n}\n(m4identity as any).__deps = [ m4set ]\n\nexport function m4multiply (out: Float32Array, a: Float32Array, b: Float32Array) {\n const a11 = a[ 0 ]\n const a12 = a[ 4 ]\n const a13 = a[ 8 ]\n const a14 = a[ 12 ]\n const a21 = a[ 1 ]\n const a22 = a[ 5 ]\n const a23 = a[ 9 ]\n const a24 = a[ 13 ]\n const a31 = a[ 2 ]\n const a32 = a[ 6 ]\n const a33 = a[ 10 ]\n const a34 = a[ 14 ]\n const a41 = a[ 3 ]\n const a42 = a[ 7 ]\n const a43 = a[ 11 ]\n const a44 = a[ 15 ]\n\n const b11 = b[ 0 ]\n const b12 = b[ 4 ]\n const b13 = b[ 8 ]\n const b14 = b[ 12 ]\n const b21 = b[ 1 ]\n const b22 = b[ 5 ]\n const b23 = b[ 9 ]\n const b24 = b[ 13 ]\n const b31 = b[ 2 ]\n const b32 = b[ 6 ]\n const b33 = b[ 10 ]\n const b34 = b[ 14 ]\n const b41 = b[ 3 ]\n const b42 = b[ 7 ]\n const b43 = b[ 11 ]\n const b44 = b[ 15 ]\n\n out[ 0 ] = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41\n out[ 4 ] = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42\n out[ 8 ] = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43\n out[ 12 ] = a11 * b14 + a12 * b24 + a13 * b34 + a14 * b44\n\n out[ 1 ] = a21 * b11 + a22 * b21 + a23 * b31 + a24 * b41\n out[ 5 ] = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42\n out[ 9 ] = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43\n out[ 13 ] = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44\n\n out[ 2 ] = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41\n out[ 6 ] = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42\n out[ 10 ] = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43\n out[ 14 ] = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44\n\n out[ 3 ] = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41\n out[ 7 ] = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42\n out[ 11 ] = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43\n out[ 15 ] = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44\n}\n\nexport function m4makeScale (out: Float32Array, x: number, y: number, z: number) {\n m4set(out,\n x, 0, 0, 0,\n 0, y, 0, 0,\n 0, 0, z, 0,\n 0, 0, 0, 1\n )\n}\n(m4makeScale as any).__deps = [ m4set ]\n\nexport function m4makeTranslation (out: Float32Array, x: number, y: number, z: number) {\n m4set(out,\n 1, 0, 0, x,\n 0, 1, 0, y,\n 0, 0, 1, z,\n 0, 0, 0, 1\n )\n}\n(m4makeTranslation as any).__deps = [ m4set ]\n\nexport function m4makeRotationY (out: Float32Array, theta: number) {\n const c = Math.cos(theta)\n const s = Math.sin(theta)\n m4set(out,\n c, 0, s, 0,\n 0, 1, 0, 0,\n -s, 0, c, 0,\n 0, 0, 0, 1\n )\n}\n(m4makeRotationY as any).__deps = [ m4set ]\n\n//\n\nexport function m3new () {\n return new Float32Array([\n 1, 0, 0,\n 0, 1, 0,\n 0, 0, 1\n ])\n}\n\nexport function m3makeNormal (out: Float32Array, m4: Float32Array) {\n const r0 = v3new([ m4[0], m4[1], m4[2] ])\n const r1 = v3new([ m4[4], m4[5], m4[6] ])\n const r2 = v3new([ m4[8], m4[9], m4[10] ])\n const cp = v3new()\n // [ r0 ] [ r1 x r2 ]\n // M3x3 = [ r1 ] N = [ r2 x r0 ]\n // [ r2 ] [ r0 x r1 ]\n v3cross(cp, r1, r2)\n out[ 0 ] = cp[ 0 ]\n out[ 1 ] = cp[ 1 ]\n out[ 2 ] = cp[ 2 ]\n v3cross(cp, r2, r0)\n out[ 3 ] = cp[ 0 ]\n out[ 4 ] = cp[ 1 ]\n out[ 5 ] = cp[ 2 ]\n v3cross(cp, r0, r1)\n out[ 6 ] = cp[ 0 ]\n out[ 7 ] = cp[ 1 ]\n out[ 8 ] = cp[ 2 ]\n}\n(m3makeNormal as any).__deps = [ v3new, v3cross ]\n","/**\n * @file Surface Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { degToRad } from '../math/math-utils'\nimport {\n m4new, m4multiply, m4makeTranslation, m4makeScale, m4makeRotationY\n} from '../math/matrix-utils'\nimport {\n v3addScalar, v3subScalar, v3divideScalar, v3multiplyScalar,\n v3floor, v3ceil, v3sub, v3negate,\n v3cross, v3fromArray, normalizeVector3array\n} from '../math/vector-utils'\nimport { NumberArray } from '../types'\n\nfunction laplacianSmooth (verts: Float32Array, faces: Float32Array, numiter: number, inflate: boolean) {\n // based on D. Xu, Y. Zhang (2009) Generating Triangulated Macromolecular\n // Surfaces by Euclidean Distance Transform. PLoS ONE 4(12): e8140.\n //\n // Permission to use, copy, modify, and distribute this program for\n // any purpose, with or without fee, is hereby granted, provided that\n // the notices on the head, the reference information, and this\n // copyright notice appear in all copies or substantial portions of\n // the Software. It is provided \"as is\" without express or implied\n // warranty.\n //\n // ported to JavaScript and adapted to NGL by Alexander Rose\n\n numiter = numiter || 1\n inflate = inflate || true\n\n const nv = verts.length / 3\n const nf = faces.length / 3\n let norms: Float32Array | undefined = undefined\n\n if (inflate) {\n norms = new Float32Array(nv * 3)\n }\n\n const tps = new Float32Array(nv * 3)\n\n let i\n const ndeg = 20\n const vertdeg = new Array(ndeg)\n\n for (i = 0; i < ndeg; ++i) {\n vertdeg[ i ] = new Uint32Array(nv)\n }\n\n for (i = 0; i < nv; ++i) {\n vertdeg[ 0 ][ i ] = 0\n }\n\n let j, jl\n let flagvert: boolean\n\n // for each face\n\n for (i = 0; i < nf; ++i) {\n var ao = i * 3\n var bo = i * 3 + 1\n var co = i * 3 + 2\n\n // vertex a\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ao] ]; j < jl; ++j) {\n if (faces[ bo ] === vertdeg[ j + 1 ][ faces[ ao ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ ao ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ ao ] ] ][ faces[ ao ] ] = faces[ bo ]\n }\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ ao ] ]; j < jl; ++j) {\n if (faces[ co ] === vertdeg[ j + 1 ][ faces[ ao ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ ao ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ ao ] ] ][ faces[ ao ] ] = faces[ co ]\n }\n\n // vertex b\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ bo ] ]; j < jl; ++j) {\n if (faces[ ao ] === vertdeg[ j + 1 ][ faces[ bo ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ bo ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ bo ] ] ][ faces[ bo ] ] = faces[ ao ]\n }\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ bo ] ]; j < jl; ++j) {\n if (faces[ co ] === vertdeg[ j + 1 ][ faces[ bo ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ bo ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ bo ] ] ][ faces[ bo ] ] = faces[ co ]\n }\n\n // vertex c\n\n flagvert = true\n for (j = 0; j < vertdeg[ 0 ][ faces[ co ] ]; ++j) {\n if (faces[ ao ] === vertdeg[ j + 1 ][ faces[ co ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ co ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ co ] ] ][ faces[ co ] ] = faces[ ao ]\n }\n\n flagvert = true\n for (j = 0, jl = vertdeg[ 0 ][ faces[ co ] ]; j < jl; ++j) {\n if (faces[ bo ] === vertdeg[ j + 1 ][ faces[ co ] ]) {\n flagvert = false\n break\n }\n }\n if (flagvert) {\n vertdeg[ 0 ][ faces[ co ] ]++\n vertdeg[ vertdeg[ 0 ][ faces[ co ] ] ][ faces[ co ] ] = faces[ bo ]\n }\n }\n\n var wt = 1.0\n var wt2 = 0.5\n var i3, vi3, vdi, wtvi, wt2vi\n var ssign = -1\n var scaleFactor = 1\n var outwt = 0.75 / (scaleFactor + 3.5) // area-preserving\n\n // smoothing iterations\n\n for (var k = 0; k < numiter; ++k) {\n // for each vertex\n\n for (i = 0; i < nv; ++i) {\n i3 = i * 3\n vdi = vertdeg[ 0 ][ i ]\n\n if (vdi < 3) {\n tps[ i3 ] = verts[ i3 ]\n tps[ i3 + 1 ] = verts[ i3 + 1 ]\n tps[ i3 + 2 ] = verts[ i3 + 2 ]\n } else if (vdi === 3 || vdi === 4) {\n tps[ i3 ] = 0\n tps[ i3 + 1 ] = 0\n tps[ i3 + 2 ] = 0\n\n for (j = 0; j < vdi; ++j) {\n vi3 = vertdeg[ j + 1 ][ i ] * 3\n tps[ i3 ] += verts[ vi3 ]\n tps[ i3 + 1 ] += verts[ vi3 + 1 ]\n tps[ i3 + 2 ] += verts[ vi3 + 2 ]\n }\n\n tps[ i3 ] += wt2 * verts[ i3 ]\n tps[ i3 + 1 ] += wt2 * verts[ i3 + 1 ]\n tps[ i3 + 2 ] += wt2 * verts[ i3 + 2 ]\n\n wt2vi = wt2 + vdi\n tps[ i3 ] /= wt2vi\n tps[ i3 + 1 ] /= wt2vi\n tps[ i3 + 2 ] /= wt2vi\n } else {\n tps[ i3 ] = 0\n tps[ i3 + 1 ] = 0\n tps[ i3 + 2 ] = 0\n\n for (j = 0; j < vdi; ++j) {\n vi3 = vertdeg[ j + 1 ][ i ] * 3\n tps[ i3 ] += verts[ vi3 ]\n tps[ i3 + 1 ] += verts[ vi3 + 1 ]\n tps[ i3 + 2 ] += verts[ vi3 + 2 ]\n }\n\n tps[ i3 ] += wt * verts[ i3 ]\n tps[ i3 + 1 ] += wt * verts[ i3 + 1 ]\n tps[ i3 + 2 ] += wt * verts[ i3 + 2 ]\n\n wtvi = wt + vdi\n tps[ i3 ] /= wtvi\n tps[ i3 + 1 ] /= wtvi\n tps[ i3 + 2 ] /= wtvi\n }\n }\n\n verts.set(tps) // copy smoothed positions\n\n if (inflate) {\n computeVertexNormals(verts, faces, norms)\n var nv3 = nv * 3\n\n for (i3 = 0; i3 < nv3; i3 += 3) {\n // if(verts[i].inout) ssign=1;\n // else ssign=-1;\n\n verts[ i3 ] += ssign * outwt * norms![ i3 ]\n verts[ i3 + 1 ] += ssign * outwt * norms![ i3 + 1 ]\n verts[ i3 + 2 ] += ssign * outwt * norms![ i3 + 2 ]\n }\n }\n }\n}\nObject.assign(laplacianSmooth, {__deps: [ computeVertexNormals ]})\n\nfunction computeVertexNormals (position: Float32Array, index?: NumberArray, normal?: Float32Array) {\n var i, il\n\n if (normal === undefined) {\n normal = new Float32Array(position.length)\n } else {\n // reset existing normals to zero\n for (i = 0, il = normal.length; i < il; i++) {\n normal[ i ] = 0\n }\n }\n\n var a = new Float32Array(3)\n var b = new Float32Array(3)\n var c = new Float32Array(3)\n var cb = new Float32Array(3)\n var ab = new Float32Array(3)\n\n if (index) {\n // indexed elements\n for (i = 0, il = index.length; i < il; i += 3) {\n var ai = index[ i ] * 3\n var bi = index[ i + 1 ] * 3\n var ci = index[ i + 2 ] * 3\n\n v3fromArray(a, position, ai)\n v3fromArray(b, position, bi)\n v3fromArray(c, position, ci)\n\n v3sub(cb, c, b)\n v3sub(ab, a, b)\n v3cross(cb, cb, ab)\n\n normal[ ai ] += cb[ 0 ]\n normal[ ai + 1 ] += cb[ 1 ]\n normal[ ai + 2 ] += cb[ 2 ]\n\n normal[ bi ] += cb[ 0 ]\n normal[ bi + 1 ] += cb[ 1 ]\n normal[ bi + 2 ] += cb[ 2 ]\n\n normal[ ci ] += cb[ 0 ]\n normal[ ci + 1 ] += cb[ 1 ]\n normal[ ci + 2 ] += cb[ 2 ]\n }\n } else {\n // non-indexed elements (unconnected triangle soup)\n for (i = 0, il = position.length; i < il; i += 9) {\n v3fromArray(a, position, i)\n v3fromArray(b, position, i + 3)\n v3fromArray(c, position, i + 6)\n\n v3sub(cb, c, b)\n v3sub(ab, a, b)\n v3cross(cb, cb, ab)\n\n normal[ i ] = cb[ 0 ]\n normal[ i + 1 ] = cb[ 1 ]\n normal[ i + 2 ] = cb[ 2 ]\n\n normal[ i + 3 ] = cb[ 0 ]\n normal[ i + 4 ] = cb[ 1 ]\n normal[ i + 5 ] = cb[ 2 ]\n\n normal[ i + 6 ] = cb[ 0 ]\n normal[ i + 7 ] = cb[ 1 ]\n normal[ i + 8 ] = cb[ 2 ]\n }\n }\n\n normalizeVector3array(normal)\n\n return normal\n}\nObject.assign(computeVertexNormals, {__deps: [\n v3sub, v3cross, v3fromArray, normalizeVector3array\n]})\n\nfunction getRadiusDict (radiusList: number[]) {\n var radiusDict: {[k: number]: boolean} = {}\n for (var i = 0, il = radiusList.length; i < il; ++i) {\n radiusDict[ radiusList[ i ] ] = true\n }\n return radiusDict\n}\n\nfunction getSurfaceGrid (min: Float32Array, max: Float32Array, maxRadius: number, scaleFactor: number, extraMargin: number) {\n // need margin to avoid boundary/round off effects\n var margin = (1 / scaleFactor) * 3\n margin += maxRadius\n\n v3subScalar(min, min, extraMargin + margin)\n v3addScalar(max, max, extraMargin + margin)\n\n v3multiplyScalar(min, min, scaleFactor)\n v3floor(min, min)\n v3divideScalar(min, min, scaleFactor)\n\n v3multiplyScalar(max, max, scaleFactor)\n v3ceil(max, max)\n v3divideScalar(max, max, scaleFactor)\n\n var dim = new Float32Array(3)\n v3sub(dim, max, min)\n v3multiplyScalar(dim, dim, scaleFactor)\n v3ceil(dim, dim)\n v3addScalar(dim, dim, 1)\n\n var maxSize = Math.pow(10, 6) * 256\n var tmpSize = dim[ 0 ] * dim[ 1 ] * dim[ 2 ] * 3\n\n if (maxSize <= tmpSize) {\n scaleFactor *= Math.pow(maxSize / tmpSize, 1 / 3)\n\n v3multiplyScalar(min, min, scaleFactor)\n v3floor(min, min)\n v3divideScalar(min, min, scaleFactor)\n\n v3multiplyScalar(max, max, scaleFactor)\n v3ceil(max, max)\n v3divideScalar(max, max, scaleFactor)\n\n v3sub(dim, max, min)\n v3multiplyScalar(dim, dim, scaleFactor)\n v3ceil(dim, dim)\n v3addScalar(dim, dim, 1)\n }\n\n var tran = new Float32Array(min)\n v3negate(tran, tran)\n\n // coordinate transformation matrix\n var matrix = m4new()\n var mroty = m4new()\n m4makeRotationY(mroty, degToRad(90))\n m4multiply(matrix, matrix, mroty)\n\n var mscale = m4new()\n m4makeScale(\n mscale,\n -1 / scaleFactor,\n 1 / scaleFactor,\n 1 / scaleFactor\n )\n m4multiply(matrix, matrix, mscale)\n\n var mtrans = m4new()\n m4makeTranslation(\n mtrans,\n -scaleFactor * tran[2],\n -scaleFactor * tran[1],\n -scaleFactor * tran[0]\n )\n m4multiply(matrix, matrix, mtrans)\n\n return {\n dim: dim,\n tran: tran,\n matrix: matrix,\n scaleFactor: scaleFactor\n }\n}\nObject.assign(getSurfaceGrid, {__deps: [\n degToRad,\n v3subScalar, v3addScalar, v3divideScalar, v3multiplyScalar,\n v3floor, v3ceil, v3sub, v3negate,\n m4new, m4multiply, m4makeTranslation, m4makeScale, m4makeRotationY\n]})\n\nexport {\n laplacianSmooth,\n computeVertexNormals,\n getRadiusDict,\n getSurfaceGrid\n}\n","/**\n * @file Surface\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3, Geometry, BufferGeometry, Group, Color } from 'three'\n\nimport { Debug, Log, ColormakerRegistry } from '../globals'\nimport { getUintArray } from '../utils'\nimport { AtomPicker, SurfacePicker } from '../utils/picker'\nimport { uniformArray, uniformArray3, serialArray } from '../math/array-utils'\nimport Selection from '../selection/selection'\nimport { ColormakerParameters } from '../color/colormaker';\nimport { Structure, Volume } from '../ngl';\n\nexport interface SurfaceData {\n position: Float32Array\n index: Uint32Array|Uint16Array|undefined\n normal: Float32Array\n color: Float32Array\n atomindex: Int32Array\n contour: boolean\n}\n/**\n * Surface\n */\nclass Surface {\n name: string\n path: string\n position: Float32Array\n index: Uint32Array|Uint16Array|undefined\n normal: Float32Array|undefined\n color: Float32Array|undefined\n atomindex: Int32Array|undefined\n contour: boolean\n center: Vector3\n boundingBox: Box3\n size: number\n info: {\n type?: string\n probeRadius?: number\n scaleFactor?: number\n smooth?: number\n cutoff?: number\n isolevel?: number\n volume?: Volume\n }\n\n /**\n * @param {String} name - surface name\n * @param {String} path - source path\n * @param {Object} data - surface data\n * @param {Float32Array} data.position - surface positions\n * @param {Int32Array} data.index - surface indices\n * @param {Float32Array} data.normal - surface normals\n * @param {Float32Array} data.color - surface colors\n * @param {Int32Array} data.atomindex - atom indices\n * @param {boolean} data.contour - contour mode flag\n */\n constructor (name: string, path: string, data?: SurfaceData) {\n this.name = name || ''\n this.path = path || ''\n this.info = {}\n\n this.center = new Vector3()\n this.boundingBox = new Box3()\n\n if (data instanceof Geometry ||\n data instanceof BufferGeometry ||\n data instanceof Group\n ) {\n // to be removed\n this.fromGeometry(data)\n } else if (data) {\n this.set(\n data.position,\n data.index,\n data.normal,\n data.color,\n data.atomindex,\n data.contour\n )\n\n this.boundingBox.setFromArray(data.position)\n this.boundingBox.getCenter(this.center)\n }\n }\n\n get type () { return 'Surface' }\n\n /**\n * set surface data\n * @param {Float32Array} position - surface positions\n * @param {Int32Array} index - surface indices\n * @param {Float32Array} normal - surface normals\n * @param {Float32Array} color - surface colors\n * @param {Int32Array} atomindex - atom indices\n * @param {boolean} contour - contour mode flag\n * @return {undefined}\n */\n set (position: Float32Array,\n index: Uint32Array|Uint16Array|undefined,\n normal: Float32Array|undefined,\n color: Float32Array|undefined,\n atomindex: Int32Array|undefined,\n contour: boolean = false) {\n /**\n * @type {Float32Array}\n */\n this.position = position\n /**\n * @type {Uint32Array|Uint16Array|undefined}\n */\n this.index = index\n /**\n * @type {Float32Array|undefined}\n */\n this.normal = normal\n /**\n * @type {Float32Array|undefined}\n */\n this.color = color\n /**\n * @type {Int32Array|undefined}\n */\n this.atomindex = atomindex\n\n this.size = position.length / 3\n this.contour = contour\n }\n\n fromGeometry (geometry: Geometry|BufferGeometry|Group) {\n if (Debug) Log.time('GeometrySurface.fromGeometry')\n\n let geo\n\n if (geometry instanceof Geometry) {\n geometry.computeVertexNormals(true)\n geo = new BufferGeometry().fromGeometry(geometry)\n } else if (geometry instanceof BufferGeometry) {\n geo = geometry\n } else {\n geo = (geometry as any)[ 0 ]\n }\n\n if (!geo.boundingBox) geo.computeBoundingBox()\n\n this.boundingBox.copy(geo.boundingBox)\n this.boundingBox.getCenter(this.center)\n\n let position, color, index, normal\n\n if (geo instanceof BufferGeometry) {\n const attr = geo.attributes\n const an = (attr as any).normal ? (attr as any).normal.array : false\n\n // assume there are no normals if the first is zero\n if (!an || (an[ 0 ] === 0 && an[ 1 ] === 0 && an[ 2 ] === 0)) {\n geo.computeVertexNormals()\n }\n\n position = (attr).position.array\n index = (attr).index ? (attr).index.array : null\n normal = (attr).normal.array\n }\n\n this.set(position, index, normal, color, undefined)\n\n if (Debug) Log.timeEnd('GeometrySurface.setGeometry')\n }\n\n getPosition () {\n return this.position\n }\n\n getColor (params: ColormakerParameters&{ scheme: string}) {\n const p = params || {}\n p.surface = this\n\n const n = this.size\n const array = new Float32Array(n * 3)\n const colormaker = ColormakerRegistry.getScheme(p)\n\n if (colormaker.volumeColor || p.scheme === 'random') {\n for (let i = 0; i < n; ++i) {\n colormaker.volumeColorToArray(i, array, i * 3)\n }\n } else if (colormaker.positionColor) {\n const v = new Vector3()\n const pos = this.position\n\n for (let i = 0; i < n; ++i) {\n var i3 = i * 3\n v.set(pos[ i3 ], pos[ i3 + 1 ], pos[ i3 + 2 ])\n colormaker.positionColorToArray(v, array, i3)\n }\n } else if (colormaker.atomColor && this.atomindex) {\n const atomProxy = p.structure!.getAtomProxy()\n const atomindex = this.atomindex\n\n for (let i = 0; i < n; ++i) {\n atomProxy.index = atomindex[ i ]\n colormaker.atomColorToArray(atomProxy, array, i * 3)\n }\n } else {\n const tc = new Color(p.value)\n uniformArray3(n, tc.r, tc.g, tc.b, array)\n }\n\n return array\n }\n\n getPicking (structure?: Structure) {\n if (this.atomindex && structure) {\n return new AtomPicker(this.atomindex as any, structure)\n } else {\n return new SurfacePicker(serialArray(this.size), this)\n }\n }\n\n getNormal () {\n return this.normal\n }\n\n getSize (size: number, scale: number) {\n return uniformArray(this.size, size * scale)\n }\n\n getIndex () {\n return this.index\n }\n\n getFilteredIndex (sele: string, structure: Structure) {\n if (sele && this.atomindex) {\n const selection = new Selection(sele)\n const atomSet = structure.getAtomSet(selection)\n const filteredIndex = []\n\n const atomindex = this.atomindex\n const index = this.index\n const n = index!.length\n const elementSize = this.contour ? 2 : 3\n\n let j = 0\n\n for (let i = 0; i < n; i += elementSize) {\n let include = true\n\n for (let a = 0; a < elementSize; a++) {\n const idx = index![ i + a ]\n const ai = atomindex[ idx ]\n if (!atomSet.get(ai)) {\n include = false\n break\n }\n }\n\n if (!include) { continue }\n\n for (let a = 0; a < elementSize; a++, j++) {\n filteredIndex[ j ] = index![ i + a ]\n }\n }\n\n return getUintArray(filteredIndex, this.position.length / 3)\n } else {\n return this.index\n }\n }\n\n getAtomindex () {\n return this.atomindex\n }\n\n dispose () {\n\n //\n\n }\n}\n\nexport default Surface\n","/**\n * @file Volume\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3, Matrix3, Matrix4 } from 'three'\n\nimport { WorkerRegistry, ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport WorkerPool from '../worker/worker-pool'\nimport { VolumePicker } from '../utils/picker'\nimport {\n uniformArray, serialArray,\n arrayMin, arrayMax, arraySum, arrayMean, arrayRms\n} from '../math/array-utils'\nimport MarchingCubes from './marching-cubes'\nimport { laplacianSmooth, computeVertexNormals } from './surface-utils'\nimport {\n applyMatrix4toVector3array, applyMatrix3toVector3array\n} from '../math/vector-utils'\nimport { m3new, m3makeNormal } from '../math/matrix-utils'\nimport Surface from './surface'\nimport { NumberArray } from '../types';\nimport { ColormakerParameters } from '../color/colormaker';\n\nexport interface VolumeSurface {\n new (data: NumberArray, nx: number, ny: number, nz: number, atomindex: NumberArray): void\n getSurface: (isolevel: number, smooth: boolean|number, box: number[][]|undefined, matrix: Float32Array, contour: boolean, wrap?: boolean) => {\n position: Float32Array\n normal: undefined|Float32Array\n index: Uint32Array|Uint16Array\n atomindex: Int32Array|undefined\n contour: boolean\n }\n}\nexport function VolumeSurface (this: VolumeSurface,data: NumberArray, nx: number, ny: number, nz: number, atomindex: NumberArray) {\n var mc = new (MarchingCubes as any)(data, nx, ny, nz, atomindex) as MarchingCubes\n\n function getSurface (isolevel: number, smooth: boolean|number, box: number[][]|undefined, matrix: Float32Array, contour: boolean, wrap: boolean = false) {\n const sd = mc.triangulate(isolevel, smooth as boolean, box, contour, wrap)\n if (smooth && !contour) {\n laplacianSmooth(sd.position, sd.index as any, smooth as number, true)\n sd.normal = computeVertexNormals(sd.position, sd.index as any)\n }\n if (matrix) {\n applyMatrix4toVector3array(matrix, sd.position)\n if (sd.normal) {\n const normalMatrix = m3new()\n m3makeNormal(normalMatrix, matrix)\n applyMatrix3toVector3array(normalMatrix, sd.normal)\n }\n }\n return sd\n }\n\n this.getSurface = getSurface\n}\nObject.assign(VolumeSurface, {__deps: [\n laplacianSmooth, computeVertexNormals, MarchingCubes,\n applyMatrix4toVector3array, applyMatrix3toVector3array,\n m3new, m3makeNormal\n]})\n\nWorkerRegistry.add('surf', function func (e: any, callback: (data: any, transferList: any) => void) {\n const a = e.data.args\n const p = e.data.params\n if (a) {\n /* global self */\n (self as any).volsurf = new (VolumeSurface as any)(a[0], a[1], a[2], a[3], a[4]) as VolumeSurface\n }\n if (p) {\n const sd = ((self as any).volsurf as VolumeSurface).getSurface(\n p.isolevel, p.smooth, p.box, p.matrix, p.contour, p.wrap\n )\n const transferList = [ sd.position.buffer, sd.index.buffer ]\n if (sd.normal) transferList.push(sd.normal.buffer)\n if (sd.atomindex) transferList.push(sd.atomindex.buffer)\n const data = {\n sd: sd,\n p: p\n }\n callback(data, transferList)\n }\n}, [ VolumeSurface ])\n\nexport type VolumeSize = 'value'|'abs-value'|'value-min'|'deviation'\n/**\n * Volume\n */\nclass Volume {\n name: string\n path: string\n\n matrix: Matrix4\n normalMatrix: Matrix3\n inverseMatrix: Matrix4\n center: Vector3\n boundingBox: Box3\n\n nx: number\n ny: number\n nz: number\n data: Float32Array\n\n worker: Worker\n workerPool: WorkerPool\n _position: Float32Array\n _min: number|undefined\n _max: number|undefined\n _mean: number|undefined\n _rms: number|undefined\n _sum: number|undefined\n __box: Box3|undefined\n\n atomindex: Int32Array|undefined\n volsurf: VolumeSurface|undefined\n header: any\n /**\n * Make Volume instance\n * @param {String} name - volume name\n * @param {String} path - source path\n * @param {Float32array} data - volume 3d grid\n * @param {Integer} nx - x dimension of the 3d volume\n * @param {Integer} ny - y dimension of the 3d volume\n * @param {Integer} nz - z dimension of the 3d volume\n * @param {Int32Array} atomindex - atom indices corresponding to the cells in the 3d grid\n */\n constructor (name: string, path: string, data?: Float32Array, nx?: number, ny?: number, nz?: number, atomindex?: Int32Array) {\n this.name = name\n this.path = path\n\n this.matrix = new Matrix4()\n this.normalMatrix = new Matrix3()\n this.inverseMatrix = new Matrix4()\n this.center = new Vector3()\n this.boundingBox = new Box3()\n\n this.setData(data, nx, ny, nz, atomindex)\n }\n\n get type () { return 'Volume' }\n\n /**\n * set volume data\n * @param {Float32array} data - volume 3d grid\n * @param {Integer} nx - x dimension of the 3d volume\n * @param {Integer} ny - y dimension of the 3d volume\n * @param {Integer} nz - z dimension of the 3d volume\n * @param {Int32Array} atomindex - atom indices corresponding to the cells in the 3d grid\n * @return {undefined}\n */\n setData (data?: Float32Array, nx?: number, ny?: number, nz?: number, atomindex?: Int32Array) {\n this.nx = nx || 1\n this.ny = ny || 1\n this.nz = nz || 1\n\n this.data = data || new Float32Array(1)\n this.setAtomindex(atomindex)\n\n this._position = new Float32Array()\n\n delete this._min\n delete this._max\n delete this._mean\n delete this._rms\n\n if (this.worker) this.worker.terminate()\n }\n\n /**\n * Set statistics, which can be different from the data in this volume,\n * if this volume is a slice of a bigger volume\n * @param {Number|undefined} min - minimum value of the whole data set\n * @param {Number|undefined} max - maximum value of the whole data set\n * @param {Number|undefined} mean - average value of the whole data set\n * @param {Number|undefined} rms - sigma value of the whole data set\n */\n setStats (min: number|undefined, max: number|undefined, mean: number|undefined, rms: number|undefined) {\n this._min = min\n this._max = max\n this._mean = mean\n this._rms = rms\n }\n\n /**\n * set transformation matrix\n * @param {Matrix4} matrix - 4x4 transformation matrix\n * @return {undefined}\n */\n setMatrix (matrix: Matrix4) {\n this.matrix.copy(matrix)\n\n const bb = this.boundingBox\n const v = this.center // temporary re-purposing\n\n const x = this.nx - 1\n const y = this.ny - 1\n const z = this.nz - 1\n\n bb.makeEmpty()\n\n bb.expandByPoint(v.set(x, y, z))\n bb.expandByPoint(v.set(x, y, 0))\n bb.expandByPoint(v.set(x, 0, z))\n bb.expandByPoint(v.set(x, 0, 0))\n bb.expandByPoint(v.set(0, y, z))\n bb.expandByPoint(v.set(0, 0, z))\n bb.expandByPoint(v.set(0, y, 0))\n bb.expandByPoint(v.set(0, 0, 0))\n\n bb.applyMatrix4(this.matrix)\n bb.getCenter(this.center)\n\n // make normal matrix\n\n const me = this.matrix.elements\n const r0 = new Vector3(me[0], me[1], me[2])\n const r1 = new Vector3(me[4], me[5], me[6])\n const r2 = new Vector3(me[8], me[9], me[10])\n const cp = new Vector3()\n // [ r0 ] [ r1 x r2 ]\n // M3x3 = [ r1 ] N = [ r2 x r0 ]\n // [ r2 ] [ r0 x r1 ]\n const ne = this.normalMatrix.elements\n cp.crossVectors(r1, r2)\n ne[ 0 ] = cp.x\n ne[ 1 ] = cp.y\n ne[ 2 ] = cp.z\n cp.crossVectors(r2, r0)\n ne[ 3 ] = cp.x\n ne[ 4 ] = cp.y\n ne[ 5 ] = cp.z\n cp.crossVectors(r0, r1)\n ne[ 6 ] = cp.x\n ne[ 7 ] = cp.y\n ne[ 8 ] = cp.z\n\n this.inverseMatrix.getInverse(this.matrix)\n }\n\n /**\n * set atom indices\n * @param {Int32Array} atomindex - atom indices corresponding to the cells in the 3d grid\n * @return {undefined}\n */\n setAtomindex (atomindex?: Int32Array) {\n this.atomindex = atomindex\n }\n\n getBox (center: Vector3, size: number, target: Box3) {\n if (!target) target = new Box3()\n\n target.set(center, center)\n target.expandByScalar(size)\n target.applyMatrix4(this.inverseMatrix)\n\n target.min.round()\n target.max.round()\n\n return target\n }\n\n _getBox (center: Vector3|undefined, size: number) {\n if (!center || !size) return\n\n if (!this.__box) this.__box = new Box3()\n const box = this.getBox(center, size, this.__box)\n return [ box.min.toArray(), box.max.toArray() ]\n }\n\n _makeSurface (sd: any, isolevel: number, smooth: number) {\n const name = this.name + '@' + isolevel.toPrecision(2)\n const surface = new Surface(name, '', sd)\n surface.info.isolevel = isolevel\n surface.info.smooth = smooth\n surface.info.volume = this\n\n return surface\n }\n\n getSurface (isolevel: number, smooth: number, center: Vector3, size: number, contour: boolean, wrap: boolean = false) {\n isolevel = isNaN(isolevel) ? this.getValueForSigma(2) : isolevel\n smooth = defaults(smooth, 0)\n\n //\n\n if (this.volsurf === undefined) {\n this.volsurf = new (VolumeSurface as any)(\n this.data, this.nx, this.ny, this.nz, this.atomindex\n ) as VolumeSurface\n }\n\n const box = this._getBox(center, size)\n const sd = this.volsurf.getSurface(\n isolevel, smooth, box!, this.matrix.elements as unknown as Float32Array, contour, wrap\n )\n\n return this._makeSurface(sd, isolevel, smooth)\n }\n\n getSurfaceWorker (isolevel: number, smooth: number, center: Vector3, size: number, contour: boolean, wrap: boolean, callback: (s: Surface) => void) {\n isolevel = isNaN(isolevel) ? this.getValueForSigma(2) : isolevel\n smooth = smooth || 0\n\n //\n\n if (window.hasOwnProperty('Worker')) {\n if (this.workerPool === undefined) {\n this.workerPool = new WorkerPool('surf', 2)\n }\n\n const msg = {}\n const worker = this.workerPool.getNextWorker()\n\n if (worker!.postCount === 0) {\n Object.assign(msg, {\n args: [\n this.data, this.nx, this.ny, this.nz, this.atomindex\n ]\n })\n }\n\n Object.assign(msg, {\n params: {\n isolevel: isolevel,\n smooth: smooth,\n box: this._getBox(center, size),\n matrix: this.matrix.elements,\n contour: contour,\n wrap: wrap\n }\n })\n\n worker!.post(msg, undefined,\n (e: any) => {\n const sd = e.data.sd\n const p = e.data.p\n callback(this._makeSurface(sd, p.isolevel, p.smooth))\n },\n (e : string) => {\n console.warn(\n 'Volume.getSurfaceWorker error - trying without worker', e\n )\n const surface = this.getSurface(isolevel, smooth, center, size, contour, wrap)\n callback(surface)\n }\n )\n } else {\n const surface = this.getSurface(isolevel, smooth, center, size, contour, wrap)\n callback(surface)\n }\n }\n\n getValueForSigma (sigma: number) {\n return this.mean + defaults(sigma, 2) * this.rms\n }\n\n getSigmaForValue (value: number) {\n return (defaults(value, 0) - this.mean) / this.rms\n }\n\n get position () {\n if (!this._position) {\n const nz = this.nz\n const ny = this.ny\n const nx = this.nx\n const position = new Float32Array(nx * ny * nz * 3)\n\n let p = 0\n for (let z = 0; z < nz; ++z) {\n for (let y = 0; y < ny; ++y) {\n for (let x = 0; x < nx; ++x) {\n position[ p + 0 ] = x\n position[ p + 1 ] = y\n position[ p + 2 ] = z\n p += 3\n }\n }\n }\n\n applyMatrix4toVector3array(this.matrix.elements as unknown as Float32Array, position)\n this._position = position\n }\n\n return this._position\n }\n\n getDataAtomindex () {\n return this.atomindex\n }\n\n getDataPosition () {\n return this.position\n }\n\n getDataColor (params: ColormakerParameters & {scheme: string}) {\n const p = params || {}\n p.volume = this\n p.scale = p.scale || 'Spectral'\n p.domain = p.domain || [ this.min, this.max ]\n\n const colormaker = ColormakerRegistry.getScheme(p)\n\n const n = this.position.length / 3\n const array = new Float32Array(n * 3)\n\n // var atoms = p.structure.atoms;\n // var atomindex = this.atomindex;\n\n for (let i = 0; i < n; ++i) {\n colormaker.volumeColorToArray(i, array, i * 3)\n // a = atoms[ atomindex[ i ] ];\n // if( a ) colormaker.atomColorToArray( a, array, i * 3 );\n }\n\n return array\n }\n\n getDataPicking () {\n const picking = serialArray(this.position.length / 3)\n return new VolumePicker(picking, this)\n }\n\n getDataSize (size: VolumeSize|number, scale: number) {\n const data = this.data\n const n = this.position.length / 3\n let array\n\n switch (size) {\n case 'value':\n array = new Float32Array(data)\n break\n\n case 'abs-value':\n array = new Float32Array(data)\n for (let i = 0; i < n; ++i) {\n array[ i ] = Math.abs(array[ i ])\n }\n break\n\n case 'value-min': {\n array = new Float32Array(data)\n const min = this.min\n for (let i = 0; i < n; ++i) {\n array[ i ] -= min\n }\n break\n }\n\n case 'deviation':\n array = new Float32Array(data)\n break\n\n default:\n array = uniformArray(n, size)\n break\n }\n\n if (scale !== 1.0) {\n for (let i = 0; i < n; ++i) {\n array[ i ] *= scale\n }\n }\n\n return array\n }\n\n get min () {\n if (this._min === undefined) {\n this._min = arrayMin(this.data)\n }\n return this._min\n }\n\n get max () {\n if (this._max === undefined) {\n this._max = arrayMax(this.data)\n }\n return this._max\n }\n\n get sum () {\n if (this._sum === undefined) {\n this._sum = arraySum(this.data)\n }\n return this._sum\n }\n\n get mean () {\n if (this._mean === undefined) {\n this._mean = arrayMean(this.data)\n }\n return this._mean\n }\n\n get rms () {\n if (this._rms === undefined) {\n this._rms = arrayRms(this.data)\n }\n return this._rms\n }\n\n clone () {\n const vol = new Volume(\n this.name,\n this.path,\n\n this.data,\n\n this.nx,\n this.ny,\n this.nz,\n\n this.atomindex\n )\n\n vol.matrix.copy(this.matrix)\n vol.header = Object.assign({}, this.header)\n\n return vol\n }\n\n dispose () {\n if (this.workerPool) this.workerPool.terminate()\n }\n}\n\nexport default Volume\n","/**\n * @file Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport {\n Color, Vector3, Matrix4,\n FrontSide, BackSide, DoubleSide,\n // VertexColors,\n NoBlending,\n BufferGeometry, BufferAttribute,\n UniformsUtils, UniformsLib, Uniform,\n Group, LineSegments, Points, Mesh, Object3D,\n ShaderMaterial\n} from 'three'\n\nimport { Log } from '../globals'\nimport { createParams, getTypedArray, getUintArray } from '../utils'\nimport { GenericColor, NumberArray } from '../types'\nimport { getShader, ShaderDefines } from '../shader/shader-utils'\nimport { serialArray } from '../math/array-utils'\nimport { Picker } from '../utils/picker'\n\nexport type BufferSide = 'front'|'back'|'double'\n\nfunction getThreeSide (side: BufferSide) {\n if (side === 'front') {\n return FrontSide\n } else if (side === 'back') {\n return BackSide\n } else if (side === 'double') {\n return DoubleSide\n } else {\n return DoubleSide\n }\n}\n\nconst itemSize = {\n 'f': 1, 'v2': 2, 'v3': 3, 'c': 3\n}\n\nfunction setObjectMatrix (object: Object3D, matrix: Matrix4) {\n object.matrix.copy(matrix)\n object.matrix.decompose(object.position, object.quaternion, object.scale)\n object.matrixWorldNeedsUpdate = true\n}\n\nexport type BufferTypes = 'picking'|'background'\nexport type BufferMaterials = 'material'|'wireframeMaterial'|'pickingMaterial'\n\nexport interface _BufferAttribute {\n type: 'f'|'v2'|'v3'|'c'\n value?: NumberArray\n}\n\nexport type Uniforms = { [k: string]: Uniform|{ value: any } }\n\nexport const BufferDefaultParameters = {\n opaqueBack: false,\n side: 'double' as BufferSide, // which triangle sides to render\n opacity: 1.0, // translucency: 1 is fully opaque, 0 is fully transparent\n depthWrite: true,\n clipNear: 0, // position of camera near/front clipping plane in percent of scene bounding box\n clipRadius: 0,\n clipCenter: new Vector3(),\n flatShaded: false, // render flat shaded\n wireframe: false, // render as wireframe\n roughness: 0.4, // how rough the material is, between 0 and 1\n metalness: 0.0, // how metallic the material is, between 0 and 1\n diffuse: 0xffffff, // diffuse color for lighting\n diffuseInterior: false,\n useInteriorColor: false, // render back-side with interior color\n interiorColor: 0xdddddd, // interior color\n interiorDarkening: 0, // interior darkening factor\n forceTransparent: false, // force the material to allow transparency\n matrix: new Matrix4(), // additional transformation matrix\n disablePicking: false, // disable picking\n sortParticles: false,\n background: false\n}\nexport type BufferParameters = Omit & { diffuse: GenericColor; interiorColor: GenericColor }\n\nexport const BufferParameterTypes = {\n opaqueBack: { updateShader: true },\n side: { updateShader: true, property: true },\n opacity: { uniform: true },\n depthWrite: { property: true },\n clipNear: { updateShader: true, property: true },\n clipRadius: { updateShader: true, uniform: true },\n clipCenter: { uniform: true },\n flatShaded: { updateShader: true },\n background: { updateShader: true },\n wireframe: { updateVisibility: true },\n roughness: { uniform: true },\n metalness: { uniform: true },\n diffuse: { uniform: true },\n diffuseInterior: { updateShader: true },\n useInteriorColor: { updateShader: true },\n interiorColor: { uniform: true },\n interiorDarkening: { uniform: true },\n matrix: {}\n}\n\nexport interface BufferData {\n position?: Float32Array\n position1?: Float32Array // TODO\n color?: Float32Array\n index?: Uint32Array|Uint16Array\n normal?: Float32Array\n\n picking?: Picker\n primitiveId?: Float32Array\n}\n\n/**\n * Buffer class. Base class for buffers.\n * @interface\n */\nclass Buffer {\n parameterTypes = BufferParameterTypes\n get defaultParameters() { return BufferDefaultParameters }\n parameters: BufferParameters\n uniforms: Uniforms\n pickingUniforms: Uniforms\n\n private _positionDataSize: number\n\n geometry = new BufferGeometry()\n indexVersion = 0\n wireframeIndexVersion = -1\n group = new Group()\n wireframeGroup = new Group()\n pickingGroup = new Group()\n\n vertexShader = ''\n fragmentShader = ''\n isImpostor = false\n isText = false\n isSurface = false\n isPoint = false\n isLine = false\n dynamic = true\n visible = true\n\n picking?: Picker\n\n material: ShaderMaterial\n wireframeMaterial: ShaderMaterial\n pickingMaterial: ShaderMaterial\n\n wireframeIndex?: Uint32Array|Uint16Array\n wireframeIndexCount = 0\n wireframeGeometry?: BufferGeometry\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Uint32Array|Uint16Array} data.index - triangle indices\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} params - parameters object\n */\n constructor (data: BufferData, params: Partial = {}) {\n this.parameters = createParams(params, this.defaultParameters)\n\n this.uniforms = UniformsUtils.merge([\n UniformsLib.common,\n {\n fogColor: { value: new Color(0x000000) },\n fogNear: { value: 0.0 },\n fogFar: { value: 0.0 },\n opacity: { value: this.parameters.opacity },\n clipNear: { value: 0.0 },\n clipRadius: { value: this.parameters.clipRadius },\n clipCenter: { value: this.parameters.clipCenter }\n },\n {\n emissive: { value: new Color(0x000000) },\n roughness: { value: this.parameters.roughness },\n metalness: { value: this.parameters.metalness },\n interiorColor: { value: new Color(this.parameters.interiorColor) },\n interiorDarkening: { value: this.parameters.interiorDarkening },\n },\n UniformsLib.lights\n ])\n\n this.uniforms.diffuse.value.set(this.parameters.diffuse)\n\n this.pickingUniforms = {\n clipNear: { value: 0.0 },\n objectId: { value: 0 },\n opacity: { value: this.parameters.opacity }\n }\n\n //\n\n const position = data.position || data.position1\n this._positionDataSize = position ? position.length / 3 : 0\n\n if (!data.primitiveId) {\n data.primitiveId = serialArray(this._positionDataSize)\n }\n\n this.addAttributes({\n position: { type: 'v3', value: data.position },\n color: { type: 'c', value: data.color },\n primitiveId: { type: 'f', value: data.primitiveId }\n })\n\n if (params.matrix) {\n this.matrix = params.matrix\n }\n\n if (data.index) {\n this.initIndex(data.index)\n }\n this.picking = data.picking\n\n this.makeWireframeGeometry()\n }\n\n set matrix (m) {\n this.setMatrix(m)\n }\n get matrix () {\n return this.group.matrix.clone()\n }\n\n get transparent () {\n return this.parameters.opacity < 1 || this.parameters.forceTransparent\n }\n\n get size () {\n return this._positionDataSize\n }\n\n get attributeSize () {\n return this.size\n }\n\n get pickable () {\n return !!this.picking && !this.parameters.disablePicking\n }\n\n setMatrix (m: Matrix4) {\n setObjectMatrix(this.group, m)\n setObjectMatrix(this.wireframeGroup, m)\n setObjectMatrix(this.pickingGroup, m)\n }\n\n initIndex (index: Uint32Array|Uint16Array) {\n this.geometry.setIndex(\n new BufferAttribute(index, 1)\n )\n const nindex = this.geometry.getIndex();\n if (!nindex) { Log.error('Index is null'); return; }\n nindex.setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n }\n\n makeMaterial () {\n const side = getThreeSide(this.parameters.side)\n\n const m = new ShaderMaterial({\n uniforms: this.uniforms,\n vertexShader: '',\n fragmentShader: '',\n depthTest: true,\n transparent: this.transparent,\n depthWrite: this.parameters.depthWrite,\n lights: true,\n fog: true,\n side: side\n })\n m.vertexColors = true\n m.extensions.derivatives = true\n m.extensions.fragDepth = this.isImpostor\n\n const wm = new ShaderMaterial({\n uniforms: this.uniforms,\n vertexShader: '',\n fragmentShader: '',\n depthTest: true,\n transparent: this.transparent,\n depthWrite: this.parameters.depthWrite,\n lights: false,\n fog: true,\n side: side\n })\n wm.vertexColors = true\n\n const pm = new ShaderMaterial({\n uniforms: this.pickingUniforms,\n vertexShader: '',\n fragmentShader: '',\n depthTest: true,\n transparent: false,\n depthWrite: this.parameters.depthWrite,\n lights: false,\n fog: false,\n side: side,\n blending: NoBlending\n })\n pm.vertexColors = true\n pm.extensions.fragDepth = this.isImpostor\n\n ;(m as any).clipNear = this.parameters.clipNear\n ;(wm as any).clipNear = this.parameters.clipNear\n ;(pm as any).clipNear = this.parameters.clipNear\n\n this.material = m\n this.wireframeMaterial = wm\n this.pickingMaterial = pm\n\n // also sets vertexShader/fragmentShader\n this.updateShader()\n }\n\n makeWireframeGeometry () {\n this.makeWireframeIndex()\n\n const geometry = this.geometry\n const wireframeIndex = this.wireframeIndex\n const wireframeGeometry = new BufferGeometry()\n\n wireframeGeometry.attributes = geometry.attributes\n if (wireframeIndex) {\n wireframeGeometry.setIndex(\n new BufferAttribute(wireframeIndex, 1).setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n wireframeGeometry.setDrawRange(0, this.wireframeIndexCount)\n }\n\n this.wireframeGeometry = wireframeGeometry\n }\n\n makeWireframeIndex () {\n const edges: number[][] = []\n\n function checkEdge (a: number, b: number) {\n if (a > b) {\n const tmp = a\n a = b\n b = tmp\n }\n\n const list = edges[ a ]\n\n if (list === undefined) {\n edges[ a ] = [ b ]\n return true\n } else if (!list.includes(b)) {\n list.push(b)\n return true\n }\n\n return false\n }\n\n const geometry = this.geometry\n const index = geometry.index\n\n if (!this.parameters.wireframe) {\n this.wireframeIndex = new Uint16Array(0)\n this.wireframeIndexCount = 0\n } else if (index) {\n const array = index.array\n let n = array.length\n if (geometry.drawRange.count !== Infinity) {\n n = geometry.drawRange.count\n }\n let wireframeIndex\n if (this.wireframeIndex && this.wireframeIndex.length > n * 2) {\n wireframeIndex = this.wireframeIndex\n } else {\n const count = (geometry.attributes as any).position.count // TODO\n wireframeIndex = getUintArray(n * 2, count)\n }\n\n let j = 0\n edges.length = 0\n\n for (let i = 0; i < n; i += 3) {\n const a = array[ i + 0 ]\n const b = array[ i + 1 ]\n const c = array[ i + 2 ]\n\n if (checkEdge(a, b)) {\n wireframeIndex[ j + 0 ] = a\n wireframeIndex[ j + 1 ] = b\n j += 2\n }\n if (checkEdge(b, c)) {\n wireframeIndex[ j + 0 ] = b\n wireframeIndex[ j + 1 ] = c\n j += 2\n }\n if (checkEdge(c, a)) {\n wireframeIndex[ j + 0 ] = c\n wireframeIndex[ j + 1 ] = a\n j += 2\n }\n }\n\n this.wireframeIndex = wireframeIndex\n this.wireframeIndexCount = j\n this.wireframeIndexVersion = this.indexVersion\n } else {\n const n = (geometry.attributes as any).position.count // TODO\n\n let wireframeIndex\n if (this.wireframeIndex && this.wireframeIndex.length > n * 2) {\n wireframeIndex = this.wireframeIndex\n } else {\n wireframeIndex = getUintArray(n * 2, n)\n }\n\n for (let i = 0, j = 0; i < n; i += 3) {\n wireframeIndex[ j + 0 ] = i\n wireframeIndex[ j + 1 ] = i + 1\n wireframeIndex[ j + 2 ] = i + 1\n wireframeIndex[ j + 3 ] = i + 2\n wireframeIndex[ j + 4 ] = i + 2\n wireframeIndex[ j + 5 ] = i\n\n j += 6\n }\n\n this.wireframeIndex = wireframeIndex\n this.wireframeIndexCount = n * 2\n this.wireframeIndexVersion = this.indexVersion\n }\n }\n\n updateWireframeIndex () {\n if (!this.wireframeGeometry || !this.wireframeIndex) return\n\n this.wireframeGeometry.setDrawRange(0, Infinity)\n if (this.wireframeIndexVersion < this.indexVersion) this.makeWireframeIndex()\n\n if (this.wireframeGeometry.index &&\n this.wireframeIndex.length > this.wireframeGeometry.index.array.length) {\n this.wireframeGeometry.setIndex(\n new BufferAttribute(this.wireframeIndex, 1).setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n } else {\n const index = this.wireframeGeometry.getIndex()\n if (!index) { Log.error('Index is null'); return; }\n index.set(this.wireframeIndex)\n index.needsUpdate = this.wireframeIndexCount > 0\n index.updateRange.count = this.wireframeIndexCount\n }\n\n this.wireframeGeometry.setDrawRange(0, this.wireframeIndexCount)\n }\n\n getRenderOrder () {\n let renderOrder = 0\n\n if (this.isText) {\n renderOrder = 1\n } else if (this.transparent) {\n if (this.isSurface) {\n renderOrder = 3\n } else {\n renderOrder = 2\n }\n }\n\n return renderOrder\n }\n\n _getMesh (materialName: BufferMaterials) {\n if (!this.material) this.makeMaterial()\n\n const g = this.geometry\n const m = this[ materialName ]\n\n let mesh\n\n if (this.isLine) {\n mesh = new LineSegments(g, m)\n } else if (this.isPoint) {\n mesh = new Points(g, m)\n } else {\n mesh = new Mesh(g, m)\n }\n\n mesh.frustumCulled = false\n mesh.renderOrder = this.getRenderOrder()\n\n return mesh\n }\n\n getMesh () {\n return this._getMesh('material')\n }\n\n getWireframeMesh () {\n let mesh\n\n if (!this.material) this.makeMaterial()\n if (!this.wireframeGeometry) this.makeWireframeGeometry()\n\n mesh = new LineSegments(\n this.wireframeGeometry, this.wireframeMaterial\n )\n\n mesh.frustumCulled = false\n mesh.renderOrder = this.getRenderOrder()\n\n return mesh\n }\n\n getPickingMesh () {\n return this._getMesh('pickingMaterial')\n }\n\n getShader (name: string, type?: BufferTypes) {\n return getShader(name, this.getDefines(type))\n }\n\n getVertexShader (type?: BufferTypes) {\n return this.getShader(this.vertexShader, type)\n }\n\n getFragmentShader (type?: BufferTypes) {\n return this.getShader(this.fragmentShader, type)\n }\n\n getDefines (type?: BufferTypes) {\n const defines: ShaderDefines = {}\n\n if (this.parameters.clipNear) {\n defines.NEAR_CLIP = 1\n }\n\n if (this.parameters.clipRadius) {\n defines.RADIUS_CLIP = 1\n }\n\n if (type === 'picking') {\n defines.PICKING = 1\n } else {\n if (type === 'background' || this.parameters.background) {\n defines.NOLIGHT = 1\n }\n if (this.parameters.flatShaded) {\n defines.FLAT_SHADED = 1\n }\n if (this.parameters.opaqueBack) {\n defines.OPAQUE_BACK = 1\n }\n if (this.parameters.diffuseInterior) {\n defines.DIFFUSE_INTERIOR = 1\n }\n if (this.parameters.useInteriorColor) {\n defines.USE_INTERIOR_COLOR = 1\n }\n }\n\n return defines\n }\n\n getParameters () {\n return this.parameters\n }\n\n addUniforms (uniforms: Uniforms) {\n this.uniforms = UniformsUtils.merge(\n [ this.uniforms, uniforms ]\n )\n\n this.pickingUniforms = UniformsUtils.merge(\n [ this.pickingUniforms, uniforms ]\n )\n }\n\n addAttributes (attributes: { [k: string]: _BufferAttribute }) {\n for (let name in attributes) {\n let buf\n const a = attributes[ name ]\n const arraySize = this.attributeSize * itemSize[ a.type ]\n\n if (a.value) {\n if (arraySize !== a.value.length) {\n Log.error('attribute value has wrong length', name)\n }\n buf = a.value\n } else {\n buf = getTypedArray('float32', arraySize)\n }\n\n this.geometry.setAttribute(\n name,\n new BufferAttribute(buf, itemSize[ a.type ]).setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n }\n }\n\n updateRenderOrder () {\n const renderOrder = this.getRenderOrder()\n function setRenderOrder (mesh: Object3D) {\n mesh.renderOrder = renderOrder\n }\n\n this.group.children.forEach(setRenderOrder)\n if (this.pickingGroup) {\n this.pickingGroup.children.forEach(setRenderOrder)\n }\n }\n\n updateShader () {\n const m = this.material\n const wm = this.wireframeMaterial\n const pm = this.pickingMaterial\n\n m.vertexShader = this.getVertexShader()\n m.fragmentShader = this.getFragmentShader()\n m.needsUpdate = true\n\n wm.vertexShader = this.getShader('Line.vert')\n wm.fragmentShader = this.getShader('Line.frag')\n wm.needsUpdate = true\n\n pm.vertexShader = this.getVertexShader('picking')\n pm.fragmentShader = this.getFragmentShader('picking')\n pm.needsUpdate = true\n }\n\n /**\n * Set buffer parameters\n * @param {BufferParameters} params - buffer parameters object\n * @return {undefined}\n */\n setParameters (params: Partial) {\n const p = params as any\n const pt = this.parameterTypes as any\n const pv = this.parameters as any\n\n const propertyData: { [k: string]: any } = {}\n const uniformData: { [k: string]: any } = {}\n let doShaderUpdate = false\n let doVisibilityUpdate = false\n\n for (const name in p) {\n const value = p[ name ]\n\n if (value === undefined) continue\n pv[ name ] = value\n\n if (pt[ name ] === undefined) continue\n\n if (pt[ name ].property) {\n if (pt[ name ].property !== true) {\n propertyData[ pt[ name ].property as any ] = value\n } else {\n propertyData[ name ] = value\n }\n }\n\n if (pt[ name ].uniform) {\n if (pt[ name ].uniform !== true) {\n uniformData[ pt[ name ].uniform as any ] = value\n } else {\n uniformData[ name ] = value\n }\n }\n\n if (pt[ name ].updateShader) {\n doShaderUpdate = true\n }\n\n if (pt[ name ].updateVisibility) {\n doVisibilityUpdate = true\n }\n\n if (this.dynamic && name === 'wireframe' && value === true) {\n this.updateWireframeIndex()\n }\n\n if (name === 'forceTransparent') {\n propertyData.transparent = this.transparent\n }\n\n if (name === 'matrix') {\n this.matrix = value\n }\n }\n\n this.setProperties(propertyData)\n this.setUniforms(uniformData)\n if (doShaderUpdate) this.updateShader()\n if (doVisibilityUpdate) this.setVisibility(this.visible)\n }\n\n /**\n * Sets buffer attributes\n * @param {Object} data - An object where the keys are the attribute names\n * and the values are the attribute data.\n * @example\n * var buffer = new Buffer();\n * buffer.setAttributes({ attrName: attrData });\n */\n setAttributes (data: any) { // TODO\n const geometry = this.geometry\n const attributes = geometry.attributes as any // TODO\n\n for (const name in data) {\n if (name === 'picking') continue\n\n const array = data[ name ]\n const length = array.length\n\n if (name === 'index') {\n const index = geometry.getIndex()\n if (!index) { Log.error('Index is null'); continue; }\n geometry.setDrawRange(0, Infinity)\n\n if (length > index.array.length) {\n geometry.setIndex(\n new BufferAttribute(array, 1)\n .setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n } else {\n index.set(array)\n index.count = length\n index.needsUpdate = length > 0\n index.updateRange.count = length\n geometry.setDrawRange(0, length)\n }\n\n this.indexVersion++\n if (this.parameters.wireframe) this.updateWireframeIndex()\n } else {\n const attribute = attributes[ name ]\n\n if (length > attribute.array.length) {\n geometry.setAttribute(\n name,\n new BufferAttribute(array, attribute.itemSize)\n .setUsage(this.dynamic ? WebGLRenderingContext.DYNAMIC_DRAW : 0)\n )\n } else {\n attributes[ name ].set(array)\n attributes[ name ].needsUpdate = length > 0\n attributes[ name ].updateRange.count = length\n }\n }\n }\n }\n\n setUniforms (data: any) { // TODO\n if (!data) return\n\n const u = this.material.uniforms\n const wu = this.wireframeMaterial.uniforms\n const pu = this.pickingMaterial.uniforms\n\n for (let name in data) {\n if (name === 'opacity') {\n this.setProperties({ transparent: this.transparent })\n }\n\n if (u[ name ] !== undefined) {\n if (u[ name ].value.isVector3) {\n u[ name ].value.copy(data[ name ])\n } else if (u[ name ].value.set) {\n u[ name ].value.set(data[ name ])\n } else {\n u[ name ].value = data[ name ]\n }\n }\n\n if (wu[ name ] !== undefined) {\n if (wu[ name ].value.isVector3) {\n wu[ name ].value.copy(data[ name ])\n } else if (wu[ name ].value.set) {\n wu[ name ].value.set(data[ name ])\n } else {\n wu[ name ].value = data[ name ]\n }\n }\n\n if (pu[ name ] !== undefined) {\n if (pu[ name ].value.isVector3) {\n pu[ name ].value.copy(data[ name ])\n } else if (pu[ name ].value.set) {\n pu[ name ].value.set(data[ name ])\n } else {\n pu[ name ].value = data[ name ]\n }\n }\n }\n }\n\n setProperties (data: any) { // TODO\n if (!data) return\n\n const m = this.material\n const wm = this.wireframeMaterial\n const pm = this.pickingMaterial\n\n for (const _name in data) {\n const name = _name as 'side'|'transparent' // TODO\n\n let value = data[ name ]\n\n if (name === 'transparent') {\n this.updateRenderOrder()\n } else if (name === 'side') {\n value = getThreeSide(value)\n }\n\n (m[ name ] as any) = value;\n (wm[ name ] as any) = value;\n (pm[ name ] as any) = value\n }\n\n m.needsUpdate = true\n wm.needsUpdate = true\n pm.needsUpdate = true\n }\n\n /**\n * Set buffer visibility\n * @param {Boolean} value - visibility value\n * @return {undefined}\n */\n setVisibility (value: boolean) {\n this.visible = value\n\n if (this.parameters.wireframe) {\n this.group.visible = false\n this.wireframeGroup.visible = value\n if (this.pickable) {\n this.pickingGroup.visible = false\n }\n } else {\n this.group.visible = value\n this.wireframeGroup.visible = false\n if (this.pickable) {\n this.pickingGroup.visible = value\n }\n }\n }\n\n /**\n * Free buffer resources\n * @return {undefined}\n */\n dispose () {\n if (this.material) this.material.dispose()\n if (this.wireframeMaterial) this.wireframeMaterial.dispose()\n if (this.pickingMaterial) this.pickingMaterial.dispose()\n\n this.geometry.dispose()\n if (this.wireframeGeometry) this.wireframeGeometry.dispose()\n }\n\n /**\n * Customize JSON serialization to avoid circular references\n */\n toJSON () {\n var result: any = {};\n for (var x in this) {\n if (x !== \"group\" && x !== \"wireframeGroup\" && x != \"pickingGroup\"\n && x !== \"picking\") {\n result[x] = this[x];\n }\n }\n return result;\n }\n}\n\nexport default Buffer\n","/**\n * @file Mesh Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport '../shader/Mesh.vert'\nimport '../shader/Mesh.frag'\n\nimport Buffer, { BufferParameters, BufferData } from './buffer'\n\n/**\n * Mesh buffer. Draws a triangle mesh.\n *\n * @example\n * var meshBuffer = new MeshBuffer({\n * position: new Float32Array(\n * [ 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1 ]\n * ),\n * color: new Float32Array(\n * [ 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0 ]\n * )\n * });\n */\nclass MeshBuffer extends Buffer {\n vertexShader = 'Mesh.vert'\n fragmentShader = 'Mesh.frag'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} [data.index] - triangle indices\n * @param {Float32Array} [data.normal] - radii\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: BufferData, params: Partial = {}) {\n super(data, params)\n\n this.addAttributes({\n 'normal': { type: 'v3', value: data.normal }\n })\n\n if (data.normal === undefined) {\n this.geometry.computeVertexNormals()\n }\n }\n}\n\nexport default MeshBuffer\n","/**\n * @file Surface Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport MeshBuffer from './mesh-buffer'\n\n/**\n * Surface buffer. Like a {@link MeshBuffer}, but with `.isSurface` set to `true`.\n */\nclass SurfaceBuffer extends MeshBuffer {\n isSurface = true\n}\n\nexport default SurfaceBuffer\n","/**\n * @file Double Sided Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { Group, BufferGeometry, Object3D, Mesh, LineSegments, Vector3, Matrix4 } from 'three'\n\nimport Buffer, { BufferSide } from './buffer'\nimport { Picker } from '../utils/picker'\n\nfunction setVisibilityTrue (m: Object3D) { m.visible = true }\nfunction setVisibilityFalse (m: Object3D) { m.visible = false }\n\n/**\n * A double-sided mesh buffer. Takes a buffer and renders the front and\n * the back as seperate objects to avoid some artifacts when rendering\n * transparent meshes. Also allows to render the back of a mesh opaque\n * while the front is transparent.\n * @implements {Buffer}\n *\n * @example\n * var sphereGeometryBuffer = new SphereGeometryBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n * var doubleSidedBuffer = new DoubleSidedBuffer(sphereGeometryBuffer);\n */\nclass DoubleSidedBuffer {\n size: number\n side: BufferSide\n visible: boolean\n wireframe: boolean\n geometry: BufferGeometry\n\n picking?: Picker\n\n group = new Group()\n wireframeGroup = new Group()\n pickingGroup = new Group()\n\n frontMeshes: (Mesh|LineSegments)[] = []\n backMeshes: (Mesh|LineSegments)[] = []\n\n buffer: Buffer\n frontBuffer: Buffer\n backBuffer: Buffer\n\n /**\n * Create a double sided buffer\n * @param {Buffer} buffer - the buffer to be rendered double-sided\n */\n constructor (buffer: Buffer) {\n this.size = buffer.size\n this.side = buffer.parameters.side\n this.visible = buffer.visible\n this.geometry = buffer.geometry\n this.picking = buffer.picking\n\n this.group = new Group()\n this.wireframeGroup = new Group()\n this.pickingGroup = new Group()\n\n // requires Group objects to be present\n this.matrix = buffer.matrix\n\n const frontBuffer = buffer\n const backBuffer = new (buffer as any).constructor({ // TODO\n position: new Float32Array(0)\n }) as Buffer\n\n frontBuffer.makeMaterial()\n backBuffer.makeMaterial()\n\n backBuffer.picking = buffer.picking\n backBuffer.geometry = buffer.geometry\n backBuffer.wireframeGeometry = buffer.wireframeGeometry\n backBuffer.setParameters(buffer.getParameters())\n backBuffer.updateShader()\n\n frontBuffer.setParameters({\n side: 'front'\n })\n backBuffer.setParameters({\n side: 'back',\n opacity: backBuffer.parameters.opacity\n })\n\n this.buffer = buffer\n this.frontBuffer = frontBuffer\n this.backBuffer = backBuffer\n }\n\n set matrix (m) {\n Buffer.prototype.setMatrix.call(this, m)\n }\n get matrix () {\n return this.group.matrix.clone()\n }\n\n get pickable () {\n return !!this.picking && !this.parameters.disablePicking\n }\n\n get parameters () {\n return this.buffer.parameters\n }\n\n getParameters () {\n const p = Object.assign({}, this.buffer.parameters)\n p.side = this.side\n return p\n }\n\n getMesh (picking: boolean) {\n let front, back\n\n if (picking) {\n back = this.backBuffer.getPickingMesh()\n front = this.frontBuffer.getPickingMesh()\n } else {\n back = this.backBuffer.getMesh()\n front = this.frontBuffer.getMesh()\n }\n\n this.frontMeshes.push(front)\n this.backMeshes.push(back)\n\n this.setParameters({ side: this.side })\n\n return new Group().add(back, front)\n }\n\n getWireframeMesh () {\n return this.buffer.getWireframeMesh()\n }\n\n getPickingMesh () {\n return this.getMesh(true)\n }\n\n setAttributes (data: any) { // TODO\n this.buffer.setAttributes(data)\n }\n\n setParameters (data: any) { // TODO\n data = Object.assign({}, data)\n\n if (data.side === 'front') {\n this.frontMeshes.forEach(setVisibilityTrue)\n this.backMeshes.forEach(setVisibilityFalse)\n } else if (data.side === 'back') {\n this.frontMeshes.forEach(setVisibilityFalse)\n this.backMeshes.forEach(setVisibilityTrue)\n } else if (data.side === 'double') {\n this.frontMeshes.forEach(setVisibilityTrue)\n this.backMeshes.forEach(setVisibilityTrue)\n }\n\n if (data.side !== undefined) {\n this.side = data.side\n }\n delete data.side\n\n if (data.matrix !== undefined) {\n this.matrix = data.matrix\n }\n delete data.matrix\n\n this.frontBuffer.setParameters(data)\n\n if (data.wireframe !== undefined) {\n this.wireframe = data.wireframe\n this.setVisibility(this.visible)\n }\n delete data.wireframe\n\n this.backBuffer.setParameters(data)\n }\n\n setVisibility (value: boolean) {\n this.visible = value\n\n if (this.parameters.wireframe) {\n this.group.visible = false\n this.wireframeGroup.visible = value\n if (this.pickable) {\n this.pickingGroup.visible = false\n }\n } else {\n this.group.visible = value\n this.wireframeGroup.visible = false\n if (this.pickable) {\n this.pickingGroup.visible = value\n }\n }\n }\n\n dispose () {\n this.frontBuffer.dispose()\n this.backBuffer.dispose()\n }\n\n /**\n * Customize JSON serialization to avoid circular references.\n * Only export simple params which could be useful.\n */\n toJSON () {\n var result: any = {};\n for (var x in this) {\n if (['side', 'size', 'visible', 'matrix', 'parameters'].includes(x)) {\n result[x] = this[x];\n }\n }\n return result;\n }\n}\n\nexport default DoubleSidedBuffer\n","/**\n * @file Contour Buffer\n * @author Fred ludlow \n * @private\n */\n\nimport '../shader/Line.vert'\nimport '../shader/Line.frag'\n\nimport Buffer from './buffer'\n\n/**\n * Contour buffer. A buffer that draws lines (instead of triangle meshes).\n */\nclass ContourBuffer extends Buffer {\n isLine = true\n vertexShader = 'Line.vert'\n fragmentShader = 'Line.frag'\n}\n\nexport default ContourBuffer\n","/**\n * @file Surface Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3, Box3 } from 'three'\n\nimport { defaults } from '../utils'\nimport Representation, { RepresentationParameters } from './representation'\nimport Volume from '../surface/volume'\nimport SurfaceBuffer from '../buffer/surface-buffer'\nimport DoubleSidedBuffer from '../buffer/doublesided-buffer'\nimport ContourBuffer from '../buffer/contour-buffer'\nimport Surface from '../surface/surface';\nimport Viewer from '../viewer/viewer';\nimport {SurfaceData} from '../surface/surface'\n// @ts-ignore: unused import ColormakerParameters required for declaration only\nimport { ColormakerParameters } from '../color/colormaker';\nexport type SurfaceDataFields = {position: boolean, color: boolean, index: boolean, normal: boolean, radius: boolean}\n\n/**\n * Surface representation parameter object. Extends {@link RepresentationParameters}\n *\n * @typedef {Object} SurfaceRepresentationParameters - surface representation parameters\n *\n * @property {String} isolevelType - Meaning of the isolevel value. Either *value* for the literal value or *sigma* as a factor of the sigma of the data. For volume data only.\n * @property {Float} isolevel - The value at which to create the isosurface. For volume data only.\n * @property {Boolean} negateIsolevel - For volume data only.\n * @property {Boolean} isolevelScroll - For volume data only\n * @property {Integer} smooth - How many iterations of laplacian smoothing after surface triangulation. For volume data only.\n * @property {Boolean} background - Render the surface in the background, unlit.\n * @property {Boolean} opaqueBack - Render the back-faces (where normals point away from the camera) of the surface opaque, ignoring the transparency parameter.\n * @property {Integer} boxSize - Size of the box to triangulate volume data in. Set to zero to triangulate the whole volume. For volume data only.\n * @property {Boolean} useWorker - Weather or not to triangulate the volume asynchronously in a Web Worker. For volume data only.\n * @property {Boolean} wrap - Wrap volume data around the edges; use in conjuction with boxSize but not larger than the volume dimension. For volume data only.\n */\nexport interface SurfaceRepresentationParameters extends RepresentationParameters {\n isolevelType: 'value'|'sigma'\n isolevel: number\n smooth: number\n background: boolean\n opaqueBack: boolean\n boxSize: number\n useWorker: boolean\n wrap: boolean\n}\n/**\n * Surface representation\n */\n/**\n * Create Surface representation object\n * @param {Surface|Volume} surface - the surface or volume to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {SurfaceRepresentationParameters} params - surface representation parameters\n */\nclass SurfaceRepresentation extends Representation {\n protected surface: Surface|Volume|undefined\n protected volume: Volume|undefined\n protected boxCenter: Vector3\n protected __boxCenter: Vector3\n protected box: Box3\n protected __box: Box3\n protected _position: Vector3\n protected isolevelType: 'value'|'sigma'\n protected isolevel: number\n protected negateIsolevel: boolean\n protected isolevelScroll: boolean\n protected smooth: number\n protected background: boolean\n protected opaqueBack: boolean\n protected boxSize: number\n protected inverseMatrix: Matrix4\n protected colorVolume: Volume\n protected contour: boolean\n protected useWorker: boolean\n protected wrap: boolean\n\n protected __isolevel: number\n protected __smooth: number\n protected __contour: boolean\n protected __wrap: boolean\n protected __boxSize: number\n\n setBox: () => void\n\n constructor (surface: Surface, viewer: Viewer, params: Partial) {\n super(surface, viewer, params)\n\n this.type = 'surface'\n\n this.parameters = Object.assign({\n\n isolevelType: {\n type: 'select',\n options: {\n 'value': 'value', 'sigma': 'sigma'\n }\n },\n isolevel: {\n type: 'number', precision: 2, max: 1000, min: -1000\n },\n negateIsolevel: {\n type: 'boolean'\n },\n isolevelScroll: {\n type: 'boolean'\n },\n smooth: {\n type: 'integer', precision: 1, max: 10, min: 0\n },\n background: {\n type: 'boolean', rebuild: true // FIXME\n },\n opaqueBack: {\n type: 'boolean', buffer: true\n },\n boxSize: {\n type: 'integer', precision: 1, max: 100, min: 0\n },\n colorVolume: {\n type: 'hidden'\n },\n contour: {\n type: 'boolean', rebuild: true\n },\n useWorker: {\n type: 'boolean', rebuild: true\n },\n wrap: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters)\n\n if (surface instanceof Volume) {\n this.surface = undefined\n this.volume = surface\n } else {\n this.surface = surface\n this.volume = undefined\n }\n\n this.boxCenter = new Vector3()\n this.__boxCenter = new Vector3()\n this.box = new Box3()\n this.__box = new Box3()\n\n this._position = new Vector3()\n this.inverseMatrix = new Matrix4()\n\n this.setBox = function setBox () {\n this._position.copy(viewer.translationGroup.position).negate()\n this._position.applyMatrix4(this.inverseMatrix)\n if (!this._position.equals(this.boxCenter)) {\n this.setParameters({ 'boxCenter': this._position })\n }\n }\n\n this.toBePrepared = true\n\n this.viewer.signals.ticked.add(this.setBox, this)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'uniform')\n p.colorValue = defaults(p.colorValue, 0xDDDDDD)\n\n this.isolevelType = defaults(p.isolevelType, 'sigma')\n this.isolevel = defaults(p.isolevel, 2.0)\n this.negateIsolevel = defaults(p.negateIsolevel, false)\n this.isolevelScroll = defaults(p.isolevelScroll, false)\n this.smooth = defaults(p.smooth, 0)\n this.background = defaults(p.background, false)\n this.opaqueBack = defaults(p.opaqueBack, true)\n this.boxSize = defaults(p.boxSize, 0)\n this.colorVolume = defaults(p.colorVolume, undefined)\n this.contour = defaults(p.contour, false)\n this.useWorker = defaults(p.useWorker, true)\n this.wrap = defaults(p.wrap, false)\n\n super.init(p)\n\n this.inverseMatrix.getInverse(this.matrix)\n\n this.build()\n }\n\n attach (callback: () => void) {\n this.bufferList.forEach(buffer => {\n this.viewer.add(buffer)\n })\n\n this.setVisibility(this.visible)\n\n callback()\n }\n\n prepare (callback: () => void) {\n if (this.volume) {\n let isolevel\n\n if (this.isolevelType === 'sigma') {\n isolevel = this.volume.getValueForSigma(this.isolevel)\n } else {\n isolevel = this.isolevel\n }\n if (this.negateIsolevel) isolevel *= -1\n\n if (!this.surface ||\n this.__isolevel !== isolevel ||\n this.__smooth !== this.smooth ||\n this.__contour !== this.contour ||\n this.__wrap !== this.wrap ||\n this.__boxSize !== this.boxSize ||\n (this.boxSize > 0 &&\n !this.__boxCenter.equals(this.boxCenter))\n ) {\n this.__isolevel = isolevel\n this.__smooth = this.smooth\n this.__contour = this.contour\n this.__wrap = this.wrap\n this.__boxSize = this.boxSize\n this.__boxCenter.copy(this.boxCenter)\n this.__box.copy(this.box)\n\n const onSurfaceFinish = (surface: Surface) => {\n this.surface = surface\n callback()\n }\n\n if (this.useWorker) {\n this.volume.getSurfaceWorker(\n isolevel, this.smooth, this.boxCenter, this.boxSize,\n this.contour, this.wrap, onSurfaceFinish\n )\n } else {\n onSurfaceFinish(\n this.volume.getSurface(\n isolevel, this.smooth, this.boxCenter, this.boxSize,\n this.contour, this.wrap\n )\n )\n }\n } else {\n callback()\n }\n } else {\n callback()\n }\n }\n\n create () {\n const sd = {\n position: (this.surface as Surface).getPosition(),\n color: (this.surface as Surface).getColor(this.getColorParams()),\n index: (this.surface as Surface).getIndex()\n }\n\n let buffer\n\n if (this.contour) {\n buffer = new ContourBuffer(\n sd,\n this.getBufferParams({ wireframe: false })\n )\n } else {\n Object.assign(sd, {\n normal: (this.surface as Surface).getNormal(),\n picking: (this.surface as Surface).getPicking()\n })\n\n const surfaceBuffer = new SurfaceBuffer(\n sd,\n this.getBufferParams({\n background: this.background,\n opaqueBack: this.opaqueBack,\n dullInterior: false\n })\n )\n\n buffer = new DoubleSidedBuffer(surfaceBuffer)\n }\n\n this.bufferList.push(buffer as ContourBuffer)\n }\n\n update (what: SurfaceDataFields) {\n if (this.bufferList.length === 0) return\n\n what = what || {}\n\n const surfaceData: Partial = {}\n\n if (what.position) {\n surfaceData.position = (this.surface as Surface).getPosition()\n }\n\n if (what.color) {\n surfaceData.color = (this.surface as Surface).getColor(\n this.getColorParams()\n )\n }\n\n if (what.index) {\n surfaceData.index = (this.surface as Surface).getIndex()\n }\n\n if (what.normal) {\n surfaceData.normal = (this.surface as Surface).getNormal()\n }\n\n this.bufferList.forEach(function (buffer) {\n buffer.setAttributes(surfaceData)\n })\n }\n\n /**\n * Set representation parameters\n * @alias SurfaceRepresentation#setParameters\n * @param {SurfaceRepresentationParameters} params - surface parameter object\n * @param {Object} [what] - buffer data attributes to be updated,\n * note that this needs to be implemented in the\n * derived classes. Generally it allows more\n * fine-grained control over updating than\n * forcing a rebuild.\n * @param {Boolean} what.position - update position data\n * @param {Boolean} what.color - update color data\n * @param {Boolean} [rebuild] - whether or not to rebuild the representation\n * @return {SurfaceRepresentation} this object\n */\n setParameters (params: Partial, what?: SurfaceDataFields, rebuild?: boolean) {\n if (params && params.isolevelType !== undefined &&\n this.volume\n ) {\n if (this.isolevelType === 'value' &&\n params.isolevelType === 'sigma'\n ) {\n this.isolevel = this.volume.getSigmaForValue(this.isolevel)\n } else if (this.isolevelType === 'sigma' &&\n params.isolevelType === 'value'\n ) {\n this.isolevel = this.volume.getValueForSigma(this.isolevel)\n }\n\n this.isolevelType = params.isolevelType\n }\n\n if (params && params.boxCenter) {\n this.boxCenter.copy(params.boxCenter)\n delete params.boxCenter\n }\n\n // Forbid wireframe && contour as in molsurface\n if (params && params.wireframe && (\n params.contour || (params.contour === undefined && this.contour)\n )) {\n params.wireframe = false\n }\n\n super.setParameters(params, what, rebuild)\n\n if (params.matrix) {\n this.inverseMatrix.getInverse(params.matrix)\n }\n\n if (this.volume) {\n this.volume.getBox(this.boxCenter, this.boxSize, this.box)\n }\n\n if (params && params.colorVolume !== undefined) {\n if (what) what.color = true\n }\n\n if (this.surface && (\n params.isolevel !== undefined ||\n params.negateIsolevel !== undefined ||\n params.smooth !== undefined ||\n params.wrap !== undefined ||\n params.boxSize !== undefined ||\n (this.boxSize > 0 &&\n !this.__box.equals(this.box))\n )) {\n this.build({\n 'position': true,\n 'color': true,\n 'index': true,\n 'normal': !this.contour\n })\n }\n\n return this\n }\n\n getColorParams () {\n const p = super.getColorParams()\n\n p.volume = this.colorVolume\n\n return p\n }\n\n dispose () {\n this.viewer.signals.ticked.remove(this.setBox, this)\n\n super.dispose()\n }\n}\n\nexport default SurfaceRepresentation\n","/**\n * @file Mouse Actions\n * @author Alexander Rose \n * @private\n */\n\nimport PickingProxy from './picking-proxy'\nimport { almostIdentity } from '../math/math-utils'\nimport Stage from '../stage/stage'\nimport StructureComponent from '../component/structure-component'\nimport SurfaceRepresentation from '../representation/surface-representation'\n\nexport type ScrollCallback = (stage: Stage, delta: number) => void\nexport type DragCallback = (stage: Stage, dx: number, dy: number) => void\nexport type PickCallback = (stage: Stage, pickingProxy: PickingProxy) => void\nexport type MouseActionCallback = ScrollCallback | DragCallback | PickCallback\n\n/**\n * Mouse actions provided as static methods\n */\nclass MouseActions {\n /**\n * Zoom scene based on scroll-delta\n * @param {Stage} stage - the stage\n * @param {Number} delta - amount to zoom\n * @return {undefined}\n */\n static zoomScroll (stage: Stage, delta: number) {\n stage.trackballControls.zoom(delta)\n }\n\n /**\n * Move near clipping plane based on scroll-delta\n * @param {Stage} stage - the stage\n * @param {Number} delta - amount to move clipping plane\n * @return {undefined}\n */\n static clipNearScroll (stage: Stage, delta: number) {\n const sp = stage.getParameters()\n stage.setParameters({ clipNear: sp.clipNear + delta / 10 })\n }\n\n /**\n * Move clipping planes based on scroll-delta.\n * @param {Stage} stage - the stage\n * @param {Number} delta - direction to move planes\n * @return {undefined}\n */\n static focusScroll (stage: Stage, delta: number) {\n const focus = stage.getFocus()\n const sign = Math.sign(delta)\n const step = sign * almostIdentity((100 - focus) / 10, 5, 0.2)\n stage.setFocus(focus + step)\n }\n\n /**\n * Zoom scene based on scroll-delta and\n * move focus planes based on camera position (zoom)\n * @param {Stage} stage - the stage\n * @param {Number} delta - amount to move focus planes and zoom\n * @return {undefined}\n */\n static zoomFocusScroll (stage: Stage, delta: number) {\n stage.trackballControls.zoom(delta)\n const z = stage.viewer.camera.position.z\n stage.setFocus(100 - Math.abs(z / 8))\n }\n\n /**\n * Change isolevel of volume surfaces based on scroll-delta\n * @param {Stage} stage - the stage\n * @param {Number} delta - amount to change isolevel\n * @return {undefined}\n */\n static isolevelScroll (stage: Stage, delta: number) {\n const d = Math.sign(delta) / 10\n stage.eachRepresentation((reprElem, comp) => {\n if (reprElem.repr instanceof SurfaceRepresentation) {\n const p = reprElem.getParameters() as any // TODO\n if (p.isolevelScroll) {\n reprElem.setParameters({ isolevel: p.isolevel + d })\n }\n }\n })\n }\n\n /**\n * Pan scene based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to pan in x direction\n * @param {Number} dy - amount to pan in y direction\n * @return {undefined}\n */\n static panDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.pan(dx, dy)\n }\n\n /**\n * Rotate scene based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to rotate in x direction\n * @param {Number} dy - amount to rotate in y direction\n * @return {undefined}\n */\n static rotateDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.rotate(dx, dy)\n }\n\n /**\n * Rotate scene around z axis based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to rotate in x direction\n * @param {Number} dy - amount to rotate in y direction\n * @return {undefined}\n */\n static zRotateDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.zRotate(dx, dy)\n }\n\n /**\n * Zoom scene based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to zoom\n * @param {Number} dy - amount to zoom\n * @return {undefined}\n */\n static zoomDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.zoom((dx + dy) / -2)\n }\n\n /**\n * Zoom scene based on mouse coordinate changes and\n * move focus planes based on camera position (zoom)\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to zoom and focus\n * @param {Number} dy - amount to zoom and focus\n * @return {undefined}\n */\n static zoomFocusDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.zoom((dx + dy) / -2)\n const z = stage.viewer.camera.position.z\n stage.setFocus(100 - Math.abs(z / 8))\n }\n\n /**\n * Pan picked component based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to pan in x direction\n * @param {Number} dy - amount to pan in y direction\n * @return {undefined}\n */\n static panComponentDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.panComponent(dx, dy)\n }\n\n /**\n * Pan picked atom based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to pan in x direction\n * @param {Number} dy - amount to pan in y direction\n * @return {undefined}\n */\n static panAtomDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.panAtom(dx, dy)\n }\n\n /**\n * Rotate picked component based on mouse coordinate changes\n * @param {Stage} stage - the stage\n * @param {Number} dx - amount to rotate in x direction\n * @param {Number} dy - amount to rotate in y direction\n * @return {undefined}\n */\n static rotateComponentDrag (stage: Stage, dx: number, dy: number) {\n stage.trackballControls.rotateComponent(dx, dy)\n }\n\n /**\n * Move picked element to the center of the screen\n * @param {Stage} stage - the stage\n * @param {PickingProxy} pickingProxy - the picking data object\n * @return {undefined}\n */\n static movePick (stage: Stage, pickingProxy: PickingProxy) {\n if (pickingProxy) {\n stage.animationControls.move(pickingProxy.position.clone())\n }\n }\n\n /**\n * Show tooltip with information of picked element\n * @param {Stage} stage - the stage\n * @param {PickingProxy} pickingProxy - the picking data object\n * @return {undefined}\n */\n static tooltipPick (stage: Stage, pickingProxy: PickingProxy) {\n const tt = stage.tooltip\n const sp = stage.getParameters() as any\n if (sp.tooltip && pickingProxy) {\n const mp = pickingProxy.mouse.position\n tt.innerText = pickingProxy.getLabel()\n tt.style.bottom = (window.innerHeight - mp.y + 3) + 'px'\n tt.style.left = (mp.x + 3) + 'px'\n tt.style.display = 'block'\n } else {\n tt.style.display = 'none'\n }\n }\n\n static measurePick (stage: Stage, pickingProxy: PickingProxy) {\n if (pickingProxy && (pickingProxy.atom || pickingProxy.bond)) {\n const atom = pickingProxy.atom || pickingProxy.closestBondAtom\n const sc = pickingProxy.component as StructureComponent\n sc.measurePick(atom)\n } else {\n stage.measureClear()\n }\n }\n}\n\ntype MouseActionPreset = [ string, MouseActionCallback ][]\nexport const MouseActionPresets = {\n default: [\n [ 'scroll', MouseActions.zoomScroll ],\n [ 'scroll-shift', MouseActions.focusScroll ],\n [ 'scroll-ctrl', MouseActions.isolevelScroll ],\n [ 'scroll-shift-ctrl', MouseActions.zoomFocusScroll ],\n\n [ 'drag-left', MouseActions.rotateDrag ],\n [ 'drag-right', MouseActions.panDrag ],\n [ 'drag-ctrl-left', MouseActions.panDrag ],\n [ 'drag-ctrl-right', MouseActions.zRotateDrag ],\n [ 'drag-shift-left', MouseActions.zoomDrag ],\n [ 'drag-middle', MouseActions.zoomFocusDrag ],\n\n [ 'drag-ctrl-shift-right', MouseActions.panComponentDrag ],\n [ 'drag-ctrl-shift-left', MouseActions.rotateComponentDrag ],\n\n [ 'clickPick-right', MouseActions.measurePick ],\n [ 'clickPick-ctrl-left', MouseActions.measurePick ],\n [ 'clickPick-middle', MouseActions.movePick ],\n [ 'clickPick-left', MouseActions.movePick ],\n [ 'hoverPick', MouseActions.tooltipPick ]\n ] as MouseActionPreset,\n pymol: [\n [ 'drag-left', MouseActions.rotateDrag ],\n [ 'drag-middle', MouseActions.panDrag ],\n [ 'drag-right', MouseActions.zoomDrag ],\n [ 'scroll', MouseActions.focusScroll ],\n [ 'drag-shift-right', MouseActions.focusScroll ],\n\n [ 'clickPick-ctrl+shift-middle', MouseActions.movePick ],\n [ 'hoverPick', MouseActions.tooltipPick ]\n ] as MouseActionPreset,\n coot: [\n [ 'scroll', MouseActions.isolevelScroll ],\n\n [ 'drag-left', MouseActions.rotateDrag ],\n [ 'drag-middle', MouseActions.panDrag ],\n [ 'drag-ctrl-left', MouseActions.panDrag ],\n [ 'drag-right', MouseActions.zoomFocusDrag ],\n [ 'drag-ctrl-right', MouseActions.focusScroll ],\n\n [ 'clickPick-middle', MouseActions.movePick ],\n [ 'hoverPick', MouseActions.tooltipPick ]\n ] as MouseActionPreset,\n astexviewer: [\n [ 'drag-left', MouseActions.rotateDrag ],\n [ 'drag-ctrl-left', MouseActions.panDrag ],\n [ 'drag-shift-left', MouseActions.zoomDrag ],\n [ 'scroll', MouseActions.focusScroll ],\n [ 'clickPick-middle', MouseActions.movePick ],\n [ 'hoverPick', MouseActions.tooltipPick ]\n ] as MouseActionPreset\n}\n\nexport default MouseActions\n","/**\n * @file Mouse Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { MouseActionPresets, MouseActionCallback } from './mouse-actions'\nimport Stage from '../stage/stage'\nimport MouseObserver from '../stage/mouse-observer'\n\nexport type MouseControlPreset = keyof typeof MouseActionPresets\nexport interface MouseControlsParams {\n preset?: MouseControlPreset\n disabled?: boolean\n}\n\nexport type MouseActionType = ''|'scroll'|'drag'|'click'|'doubleClick'|'hover'|'clickPick'|'hoverPick'\nexport interface MouseAction {\n type: MouseActionType\n key: number\n button: number\n callback: MouseActionCallback\n}\n\n/**\n * Strings to describe mouse events (including optional keyboard modifiers).\n * Must contain an event type: \"scroll\", \"drag\", \"click\", \"doubleClick\",\n * \"hover\", \"clickPick\" or \"hoverPick\". Optionally contain one or more\n * (seperated by plus signs) keyboard modifiers: \"alt\", \"ctrl\", \"meta\" or\n * \"shift\". Can contain the mouse button performing the event: \"left\",\n * \"middle\" or \"right\". The type, key and button parts must be seperated by\n * dashes.\n *\n * @example\n * // triggered on scroll event (no key or button)\n * \"scroll\"\n *\n * @example\n * // triggered on scroll event while shift key is pressed\n * \"scroll-shift\"\n *\n * @example\n * // triggered on drag event with left mouse button\n * \"drag-left\"\n *\n * @example\n * // triggered on drag event with right mouse button\n * // while ctrl and shift keys are pressed\n * \"drag-right-ctrl+shift\"\n *\n * @typedef {String} TriggerString\n */\n\n/**\n * Get event type, key and button\n * @param {TriggerString} str - input trigger string\n * @return {Array} event type, key and button\n */\nfunction triggerFromString (str: string) {\n const tokens = str.split(/[-+]/)\n\n let type = ''\n if (tokens.includes('scroll')) type = 'scroll'\n if (tokens.includes('drag')) type = 'drag'\n if (tokens.includes('click')) type = 'click'\n if (tokens.includes('doubleClick')) type = 'doubleClick'\n if (tokens.includes('hover')) type = 'hover'\n if (tokens.includes('clickPick')) type = 'clickPick'\n if (tokens.includes('hoverPick')) type = 'hoverPick'\n\n let key = 0\n if (tokens.includes('alt')) key += 1\n if (tokens.includes('ctrl')) key += 2\n if (tokens.includes('meta')) key += 4\n if (tokens.includes('shift')) key += 8\n\n let button = 0\n if (tokens.includes('left')) button += 1\n if (tokens.includes('right')) button += 2\n if (tokens.includes('middle')) button += 4\n\n return [ type, key, button ] as [ MouseActionType, number, number ]\n}\n\n/**\n * Mouse controls\n */\nclass MouseControls {\n actionList: MouseAction[] = []\n mouse: MouseObserver\n\n disabled: boolean // Flag to disable all actions\n\n /**\n * @param {Stage} stage - the stage object\n * @param {Object} [params] - the parameters\n * @param {String} params.preset - one of \"default\", \"pymol\", \"coot\"\n * @param {String} params.disabled - flag to disable all actions\n */\n constructor (readonly stage: Stage, params: MouseControlsParams = {}) {\n this.mouse = stage.mouseObserver\n this.disabled = params.disabled || false\n this.preset(params.preset || 'default')\n }\n\n run (type: MouseActionType, ...args: any[]) {\n if (this.disabled) return\n\n const key = this.mouse.key || 0\n const button = this.mouse.buttons || 0\n\n this.actionList.forEach(a => {\n if (a.type === type && a.key === key && a.button === button) {\n (a.callback as any)(this.stage, ...args) // TODO\n }\n })\n }\n\n /**\n * Add a new mouse action triggered by an event, key and button combination.\n * The {@link MouseActions} class provides a number of static methods for\n * use as callback functions.\n *\n * @example\n * // change ambient light intensity on mouse scroll\n * // while the ctrl and shift keys are pressed\n * stage.mouseControls.add( \"scroll-ctrl+shift\", function( stage, delta ){\n * var ai = stage.getParameters().ambientIntensity;\n * stage.setParameters( { ambientIntensity: Math.max( 0, ai + delta / 50 ) } );\n * } );\n *\n * @example\n * // Call the MouseActions.zoomDrag method on mouse drag events\n * // with left and right mouse buttons simultaneous\n * stage.mouseControls.add( \"drag-left+right\", MouseActions.zoomDrag );\n *\n * @param {TriggerString} triggerStr - the trigger for the action\n * @param {function(stage: Stage, ...args: Any)} callback - the callback function for the action\n * @return {undefined}\n */\n add (triggerStr: string, callback: MouseActionCallback) {\n const [ type, key, button ] = triggerFromString(triggerStr)\n\n this.actionList.push({ type, key, button, callback })\n }\n\n /**\n * Remove a mouse action. The trigger string can contain an asterix (*)\n * as a wildcard for any key or mouse button. When the callback function\n * is given, only actions that call that function are removed.\n *\n * @example\n * // remove actions triggered solely by a scroll event\n * stage.mouseControls.remove( \"scroll\" );\n *\n * @example\n * // remove actions triggered by a scroll event, including\n * // those requiring a key pressed or mouse button used\n * stage.mouseControls.remove( \"scroll-*\" );\n *\n * @example\n * // remove actions triggered by a scroll event\n * // while the shift key is pressed\n * stage.mouseControls.remove( \"scroll-shift\" );\n *\n * @param {TriggerString} triggerStr - the trigger for the action\n * @param {Function} [callback] - the callback function for the action\n * @return {undefined}\n */\n remove (triggerStr: string, callback?: MouseActionCallback) {\n const wildcard = triggerStr.includes('*')\n const [ type, key, button ] = triggerFromString(triggerStr)\n\n const actionList = this.actionList.filter(function (a) {\n return !(\n (a.type === type || (wildcard && type === '')) &&\n (a.key === key || (wildcard && key === 0)) &&\n (a.button === button || (wildcard && button === 0)) &&\n (a.callback === callback || callback === undefined)\n )\n })\n\n this.actionList = actionList\n }\n\n /**\n * Set mouse action preset\n * @param {String} name - one of \"default\", \"pymol\", \"coot\"\n * @return {undefined}\n */\n preset (name: MouseControlPreset) {\n this.clear()\n\n const list = MouseActionPresets[ name ] || []\n\n list.forEach(action => this.add(action[0], action[1]))\n }\n\n /**\n * Remove all mouse actions\n * @return {undefined}\n */\n clear () {\n this.actionList.length = 0\n }\n}\n\nexport default MouseControls\n","/**\n * @file Key Actions\n * @author Alexander Rose \n * @private\n */\n\nimport Stage from '../stage/stage'\n\nexport type KeyActionCallback = (stage: Stage) => void\n\n/**\n * Key actions provided as static methods\n */\nclass KeyActions {\n /**\n * Stage auto view\n */\n static autoView (stage: Stage) {\n stage.autoView(1000)\n }\n\n /**\n * Toggle stage animations\n */\n static toggleAnimations (stage: Stage) {\n stage.animationControls.toggle()\n }\n\n /**\n * Toggle stage rocking\n */\n static toggleRock (stage: Stage) {\n stage.toggleRock()\n }\n\n /**\n * Toggle stage spinning\n */\n static toggleSpin (stage: Stage) {\n stage.toggleSpin()\n }\n\n /**\n * Toggle anti-aliasing\n */\n static toggleAntialiasing (stage: Stage) {\n const p = stage.getParameters()\n stage.setParameters({ sampleLevel: p.sampleLevel === -1 ? 0 : -1 })\n }\n}\n\ntype KeyActionPreset = [ string, KeyActionCallback ][]\nexport const KeyActionPresets = {\n default: [\n [ 'i', KeyActions.toggleSpin ],\n [ 'k', KeyActions.toggleRock ],\n [ 'p', KeyActions.toggleAnimations ],\n [ 'a', KeyActions.toggleAntialiasing ],\n [ 'r', KeyActions.autoView ]\n ] as KeyActionPreset\n}\n\nexport default KeyActions\n","/**\n * @file Key Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { KeyActionPresets, KeyActionCallback } from './key-actions'\nimport Stage from '../stage/stage'\n\nexport type KeyControlPreset = keyof typeof KeyActionPresets\nexport interface KeyControlsParams {\n preset?: KeyControlPreset\n disabled?: boolean\n}\n\nexport interface KeyAction {\n key: string,\n callback: KeyActionCallback\n}\n\n/**\n * Mouse controls\n */\nclass KeyControls {\n actionList: KeyAction[] = []\n\n disabled: boolean // Flag to disable all actions\n\n /**\n * @param {Stage} stage - the stage object\n * @param {Object} [params] - the parameters\n * @param {String} params.preset - one of \"default\"\n * @param {String} params.disabled - flag to disable all actions\n */\n constructor (readonly stage: Stage, params: KeyControlsParams = {}) {\n this.disabled = params.disabled || false\n this.preset(params.preset || 'default')\n }\n\n run (key: string) {\n if (this.disabled) return\n\n this.actionList.forEach(a => {\n if (a.key === key) {\n a.callback(this.stage)\n }\n })\n }\n\n /**\n * Add a key action triggered by pressing the given character.\n * The {@link KeyActions} class provides a number of static methods for\n * use as callback functions.\n *\n * @example\n * // call KeyActions.toggleRock when \"k\" is pressed\n * stage.keyControls.remove( \"k\", KeyActions.toggleRock );\n *\n * @param {Char} char - the key/character\n * @param {Function} callback - the callback function for the action\n * @return {undefined}\n */\n add (char: string, callback: KeyActionCallback) {\n this.actionList.push({ key: char, callback })\n }\n\n /**\n * Remove a key action. When the callback function\n * is given, only actions that call that function are removed.\n *\n * @example\n * // remove all actions triggered by pressing \"k\"\n * stage.keyControls.remove( \"k\" );\n *\n * @example\n * // remove action `toggleRock` triggered by pressing \"k\"\n * stage.keyControls.remove( \"k\", toggleRock );\n *\n * @param {Char} char - the key/character\n * @param {Function} [callback] - the callback function for the action\n * @return {undefined}\n */\n remove (char: string, callback: KeyActionCallback) {\n\n const actionList = this.actionList.filter(function (a) {\n return !(\n (a.key === char) &&\n (a.callback === callback || callback === undefined)\n )\n })\n\n this.actionList = actionList\n }\n\n /**\n * Set key action preset\n * @param {String} name - one of \"default\"\n * @return {undefined}\n */\n preset (name: KeyControlPreset) {\n this.clear()\n\n const list = KeyActionPresets[ name ] || []\n\n list.forEach(action => this.add(action[0], action[1]))\n }\n\n /**\n * Remove all key actions\n * @return {undefined}\n */\n clear () {\n this.actionList.length = 0\n }\n}\n\nexport default KeyControls\n","/**\n * @file Picking Behavior\n * @author Alexander Rose \n * @private\n */\n\nimport Stage from './stage'\nimport MouseObserver from './mouse-observer'\nimport Viewer from '../viewer/viewer'\nimport MouseControls from '../controls/mouse-controls'\n\nclass PickingBehavior {\n viewer: Viewer\n mouse: MouseObserver\n controls: MouseControls\n\n constructor (readonly stage: Stage) {\n this.stage = stage\n this.mouse = stage.mouseObserver\n this.controls = stage.mouseControls\n\n this.mouse.signals.clicked.add(this._onClick, this)\n this.mouse.signals.hovered.add(this._onHover, this)\n }\n\n _onClick (x: number, y: number) {\n const pickingProxy = this.stage.pickingControls.pick(x, y)\n this.stage.signals.clicked.dispatch(pickingProxy)\n this.controls.run('clickPick', pickingProxy)\n }\n\n _onHover (x: number, y: number) {\n const pickingProxy = this.stage.pickingControls.pick(x, y)\n if (pickingProxy && this.mouse.down.equals(this.mouse.position)) {\n this.stage.transformComponent = pickingProxy.component\n this.stage.transformAtom = pickingProxy.atom\n }\n this.stage.signals.hovered.dispatch(pickingProxy)\n this.controls.run('hoverPick', pickingProxy)\n }\n\n dispose () {\n this.mouse.signals.clicked.remove(this._onClick, this)\n this.mouse.signals.hovered.remove(this._onHover, this)\n }\n}\n\nexport default PickingBehavior\n","/**\n * @file Mouse Behavior\n * @author Alexander Rose \n * @private\n */\n\nimport Stage from './stage'\nimport MouseObserver from './mouse-observer'\nimport Viewer from '../viewer/viewer'\nimport MouseControls from '../controls/mouse-controls'\n\nclass MouseBehavior {\n viewer: Viewer\n mouse: MouseObserver\n controls: MouseControls\n domElement: HTMLCanvasElement\n\n constructor (readonly stage: Stage) {\n this.stage = stage\n this.mouse = stage.mouseObserver\n this.controls = stage.mouseControls\n\n this.mouse.signals.moved.add(this._onMove, this)\n this.mouse.signals.scrolled.add(this._onScroll, this)\n this.mouse.signals.dragged.add(this._onDrag, this)\n this.mouse.signals.clicked.add(this._onClick, this)\n this.mouse.signals.hovered.add(this._onHover, this)\n this.mouse.signals.doubleClicked.add(this._onDblclick, this)\n }\n\n _onMove (/* x, y */) {\n this.stage.tooltip.style.display = 'none'\n }\n\n _onScroll (delta: number) {\n this.controls.run('scroll', delta)\n }\n\n _onDrag (dx: number, dy: number) {\n this.controls.run('drag', dx, dy)\n }\n\n _onClick (x: number, y: number) {\n this.controls.run('click', x, y)\n }\n\n _onDblclick (x: number, y: number) {\n this.controls.run('doubleClick', x, y)\n }\n\n _onHover (x: number, y: number) {\n this.controls.run('hover', x, y)\n }\n\n dispose () {\n this.mouse.signals.moved.remove(this._onMove, this)\n this.mouse.signals.scrolled.remove(this._onScroll, this)\n this.mouse.signals.dragged.remove(this._onDrag, this)\n this.mouse.signals.clicked.remove(this._onClick, this)\n this.mouse.signals.hovered.remove(this._onHover, this)\n }\n}\n\nexport default MouseBehavior\n","/**\n * @file Animation Behavior\n * @author Alexander Rose \n * @private\n */\n\nimport Stage from './stage'\nimport Viewer from '../viewer/viewer'\nimport Stats from '../viewer/stats'\nimport AnimationControls from '../controls/animation-controls'\n\nclass AnimationBehavior {\n viewer: Viewer\n animationControls: AnimationControls\n\n constructor (readonly stage: Stage) {\n this.viewer = stage.viewer\n this.animationControls = stage.animationControls\n\n this.viewer.signals.ticked.add(this._onTick, this)\n }\n\n _onTick (stats: Stats) {\n this.animationControls.run(stats)\n }\n\n dispose () {\n this.viewer.signals.ticked.remove(this._onTick, this)\n }\n}\n\nexport default AnimationBehavior\n","/**\n * @file Key Behavior\n * @author Alexander Rose \n * @private\n */\n\nimport { SupportsPassiveEventHandler } from '../globals'\nimport Stage from './stage'\nimport Viewer from '../viewer/viewer'\nimport KeyControls from '../controls/key-controls'\n\nconst passive = SupportsPassiveEventHandler ? { passive: true } : false\n\nclass KeyBehavior {\n viewer: Viewer\n controls: KeyControls\n domElement: HTMLCanvasElement\n\n /**\n * @param {Stage} stage - the stage object\n */\n constructor (readonly stage: Stage) {\n this.stage = stage\n this.controls = stage.keyControls\n this.domElement = stage.viewer.renderer.domElement\n\n // ensure the domElement is focusable\n this.domElement.setAttribute('tabIndex', '-1')\n this.domElement.style.outline = 'none'\n\n this._focusDomElement = this._focusDomElement.bind(this)\n this._onKeydown = this._onKeydown.bind(this)\n this._onKeyup = this._onKeyup.bind(this)\n this._onKeypress = this._onKeypress.bind(this)\n\n this.domElement.addEventListener('mousedown', this._focusDomElement)\n this.domElement.addEventListener('touchstart', this._focusDomElement, passive as any) // TODO\n this.domElement.addEventListener('keydown', this._onKeydown)\n this.domElement.addEventListener('keyup', this._onKeyup)\n this.domElement.addEventListener('keypress', this._onKeypress)\n }\n\n /**\n * handle key down\n * @param {Event} event - key event\n * @return {undefined}\n */\n _onKeydown (/* event */) {\n // console.log( \"down\", event.keyCode, String.fromCharCode( event.keyCode ) );\n }\n\n /**\n * handle key up\n * @param {Event} event - key event\n * @return {undefined}\n */\n _onKeyup (/* event */) {\n // console.log( \"up\", event.keyCode, String.fromCharCode( event.keyCode ) );\n }\n\n /**\n * handle key press\n * @param {Event} event - key event\n * @return {undefined}\n */\n _onKeypress (event: KeyboardEvent) {\n // console.log( \"press\", event.keyCode, String.fromCharCode( event.keyCode ) );\n let pressedKey: string;\n if (\"key\" in KeyboardEvent.prototype) {\n pressedKey = event.key;\n // some mobile browsers don't support this attribute\n } else {\n pressedKey = String.fromCharCode(event.which || event.keyCode);\n }\n this.controls.run(pressedKey);\n }\n\n _focusDomElement () {\n this.domElement.focus()\n }\n\n dispose () {\n this.domElement.removeEventListener('mousedown', this._focusDomElement)\n this.domElement.removeEventListener('touchstart', this._focusDomElement, passive as any) // TODO\n this.domElement.removeEventListener('keydown', this._onKeypress)\n this.domElement.removeEventListener('keyup', this._onKeypress)\n this.domElement.removeEventListener('keypress', this._onKeypress)\n }\n}\n\nexport default KeyBehavior\n","/**\n * @file Annotation\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector2, Vector3 } from 'three'\n\nimport { defaults } from '../utils'\nimport { smoothstep } from '../math/math-utils'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\nimport Component from './component'\n\nexport interface AnnotationParams {\n offsetX?: number\n offsetY?: number\n visible?: boolean\n}\n\n/**\n * Annotation HTML element floating on top of a position rendered in 3d\n */\nexport default class Annotation {\n offsetX: number\n offsetY: number\n visible: boolean\n\n stage: Stage\n viewer: Viewer\n element: HTMLElement\n\n private _viewerPosition: Vector3\n private _canvasPosition: Vector2\n private _cameraPosition: Vector3\n private _clientRect: ClientRect\n\n /**\n * @param {Component} component - the associated component\n * @param {Vector3} position - position in 3d\n * @param {String|Element} content - HTML content\n * @param {Object} [params] - parameters\n * @param {Integer} params.offsetX - 2d offset in x direction\n * @param {Integer} params.offsetY - 2d offset in y direction\n * @param {Boolean} params.visible - visibility flag\n */\n constructor (readonly component: Component, readonly position: Vector3, content: string|HTMLElement, params: AnnotationParams = {}) {\n this.offsetX = defaults(params.offsetX, 0)\n this.offsetY = defaults(params.offsetY, 0)\n this.visible = defaults(params.visible, true)\n\n this.stage = component.stage\n this.viewer = component.stage.viewer\n\n this._viewerPosition = new Vector3()\n this._updateViewerPosition()\n this._canvasPosition = new Vector2()\n this._cameraPosition = new Vector3()\n\n this.element = document.createElement('div')\n Object.assign(this.element.style, {\n display: 'block',\n position: 'absolute',\n pointerEvents: 'none',\n whiteSpace: 'nowrap',\n left: '-10000px'\n })\n\n this.viewer.wrapper.appendChild(this.element)\n this.setContent(content)\n this.updateVisibility()\n this.viewer.signals.rendered.add(this._update, this)\n this.component.signals.matrixChanged.add(this._updateViewerPosition, this)\n }\n\n /**\n * Set HTML content of the annotation\n * @param {String|Element} value - HTML content\n * @return {undefined}\n */\n setContent (value: string|HTMLElement) {\n const displayValue = this.element.style.display\n if (displayValue === 'none') {\n this.element.style.left = '-10000px'\n this.element.style.display = 'block'\n }\n\n if (value instanceof HTMLElement) {\n this.element.appendChild(value)\n } else {\n const content = document.createElement('div')\n content.innerText = value\n Object.assign(content.style, {\n backgroundColor: 'rgba( 0, 0, 0, 0.6 )',\n color: 'lightgrey',\n padding: '8px',\n fontFamily: 'sans-serif',\n })\n this.element.appendChild(content)\n }\n\n this._clientRect = this.element.getBoundingClientRect()\n\n if (displayValue === 'none') {\n this.element.style.display = displayValue\n }\n }\n\n /**\n * Set visibility of the annotation\n * @param {Boolean} value - visibility flag\n * @return {undefined}\n */\n setVisibility (value: boolean) {\n this.visible = value\n this.updateVisibility()\n }\n\n getVisibility () {\n return this.visible && this.component.parameters.visible\n }\n\n updateVisibility () {\n this.element.style.display = this.getVisibility() ? 'block' : 'none'\n }\n\n _updateViewerPosition () {\n this._viewerPosition\n .copy(this.position)\n .applyMatrix4(this.component.matrix)\n }\n\n _update () {\n if (!this.getVisibility()) return\n\n const s = this.element.style\n const cp = this._canvasPosition\n const vp = this._viewerPosition\n const cr = this._clientRect\n\n this._cameraPosition.copy(vp)\n .add(this.viewer.translationGroup.position)\n .applyMatrix4(this.viewer.rotationGroup.matrix)\n .sub(this.viewer.camera.position)\n\n if (this._cameraPosition.z < 0) {\n s.display = 'none'\n return\n } else {\n s.display = 'block'\n }\n\n const depth = this._cameraPosition.length()\n const fog = this.viewer.scene.fog as any // TODO\n\n s.opacity = (1 - smoothstep(fog.near, fog.far, depth)).toString()\n s.zIndex = (Math.round((fog.far - depth) * 100)).toString()\n\n this.stage.viewerControls.getPositionOnCanvas(vp, cp)\n\n s.bottom = (this.offsetX + cp.y + cr.height / 2) + 'px'\n s.left = (this.offsetY + cp.x - cr.width / 2) + 'px'\n }\n\n /**\n * Safely remove the annotation\n * @return {undefined}\n */\n dispose () {\n this.viewer.wrapper.removeChild(this.element)\n this.viewer.signals.ticked.remove(this._update, this)\n this.component.signals.matrixChanged.remove(this._updateViewerPosition, this)\n }\n}","/**\n * @file Component Controls\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4, Quaternion } from 'three'\nimport * as signalsWrapper from 'signals'\n\nimport { ensureVector3 } from '../utils'\nimport Component from '../component/component'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\n\nconst tmpRotateMatrix = new Matrix4()\nconst tmpRotateVector = new Vector3()\nconst tmpRotateQuaternion = new Quaternion()\n\n/**\n * Component controls\n */\nclass ComponentControls {\n signals = {\n changed: new signalsWrapper.Signal()\n }\n\n stage: Stage\n viewer: Viewer\n\n /**\n * @param {Component} component - the component object\n */\n constructor (readonly component: Component) {\n this.stage = component.stage\n this.viewer = component.stage.viewer\n }\n\n /**\n * component center position\n * @type {Vector3}\n */\n get position () {\n return this.component.position\n }\n\n /**\n * component rotation\n * @type {Quaternion}\n */\n get rotation () {\n return this.component.quaternion\n }\n\n /**\n * Trigger render and emit changed event\n * @emits {ComponentControls.signals.changed}\n * @return {undefined}\n */\n changed () {\n this.component.updateMatrix()\n this.viewer.requestRender()\n this.signals.changed.dispatch()\n }\n\n /**\n * spin component on axis\n * @param {Vector3|Array} axis - rotation axis\n * @param {Number} angle - amount to spin\n * @return {undefined}\n */\n spin (axis: Vector3, angle: number) {\n tmpRotateMatrix.getInverse(this.viewer.rotationGroup.matrix)\n tmpRotateVector\n .copy(ensureVector3(axis)).applyMatrix4(tmpRotateMatrix)\n\n tmpRotateMatrix.extractRotation(this.component.transform)\n tmpRotateMatrix.premultiply(this.viewer.rotationGroup.matrix)\n tmpRotateMatrix.getInverse(tmpRotateMatrix)\n\n tmpRotateVector.copy(ensureVector3(axis))\n tmpRotateVector.applyMatrix4(tmpRotateMatrix)\n tmpRotateMatrix.makeRotationAxis(tmpRotateVector, angle)\n tmpRotateQuaternion.setFromRotationMatrix(tmpRotateMatrix)\n\n this.component.quaternion.premultiply(tmpRotateQuaternion)\n this.changed()\n }\n}\n\nexport default ComponentControls\n","/**\n * @file Radius Factory\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { NucleicBackboneAtoms } from '../structure/structure-constants'\nimport AtomProxy from '../proxy/atom-proxy'\n\nexport const RadiusFactoryTypes = {\n '': '',\n 'vdw': 'by vdW radius',\n 'covalent': 'by covalent radius',\n 'sstruc': 'by secondary structure',\n 'bfactor': 'by bfactor',\n 'size': 'size',\n 'data': 'data',\n 'explicit' : 'explicit'\n}\nexport type RadiusType = keyof typeof RadiusFactoryTypes\n\nexport interface RadiusParams {\n type?: RadiusType\n scale?: number\n size?: number\n data?: { [k: number]: number }\n}\n\nclass RadiusFactory {\n max = 10\n\n static types = RadiusFactoryTypes\n\n readonly type: RadiusType\n readonly scale: number\n readonly size: number\n readonly data: { [k: number]: number }\n\n constructor (params: RadiusParams = {}) {\n this.type = defaults(params.type, 'size')\n this.scale = defaults(params.scale, 1)\n this.size = defaults(params.size, 1)\n this.data = defaults(params.data, {})\n }\n\n atomRadius (a: AtomProxy) {\n let r\n\n switch (this.type) {\n case 'vdw':\n r = a.vdw\n break\n\n case 'covalent':\n r = a.covalent\n break\n\n case 'bfactor':\n r = a.bfactor || 1.0\n break\n\n case 'sstruc':\n const sstruc = a.sstruc\n if (sstruc === 'h') {\n r = 0.25\n } else if (sstruc === 'g') {\n r = 0.25\n } else if (sstruc === 'i') {\n r = 0.25\n } else if (sstruc === 'e') {\n r = 0.25\n } else if (sstruc === 'b') {\n r = 0.25\n } else if (NucleicBackboneAtoms.includes(a.atomname)) {\n r = 0.4\n } else {\n r = 0.1\n }\n break\n\n case 'data':\n r = defaults(this.data[ a.index ], 1.0)\n break\n\n case 'explicit':\n // defaults is inappropriate as AtomProxy.radius returns\n // null for missing radii\n r = a.radius\n if (r === null) r = this.size\n break\n\n default:\n r = this.size\n break\n }\n\n return Math.min(r * this.scale, this.max)\n }\n\n}\n\nexport default RadiusFactory\n","/**\n * @file Principal Axes\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4, Quaternion } from 'three'\n\nimport {\n Matrix, meanRows, subRows, transpose, multiplyABt, svd\n} from './matrix-utils'\nimport { projectPointOnVector } from './vector-utils'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\n\nconst negateVector = new Vector3(-1, -1, -1)\nconst tmpMatrix = new Matrix4()\n\n/**\n * Principal axes\n */\nclass PrincipalAxes {\n begA: Vector3\n endA: Vector3\n begB: Vector3\n endB: Vector3\n begC: Vector3\n endC: Vector3\n\n center: Vector3\n\n vecA: Vector3\n vecB: Vector3\n vecC: Vector3\n\n normVecA: Vector3\n normVecB: Vector3\n normVecC: Vector3\n\n /**\n * @param {Matrix} points - 3 by N matrix\n */\n constructor (points: Matrix) {\n // console.time( \"PrincipalAxes\" );\n\n const n = points.rows\n const n3 = n / 3\n const pointsT = new Matrix(n, 3)\n const A = new Matrix(3, 3)\n const W = new Matrix(1, 3)\n const U = new Matrix(3, 3)\n const V = new Matrix(3, 3)\n\n // calculate\n const mean = meanRows(points)\n subRows(points, mean)\n transpose(pointsT, points)\n multiplyABt(A, pointsT, pointsT)\n svd(A, W, U, V)\n\n // console.log( points, pointsT, mean )\n // console.log( n, A, W, U, V );\n\n // center\n const vm = new Vector3(mean[0], mean[1], mean[2])\n\n // normalized\n const van = new Vector3(U.data[0], U.data[3], U.data[6])\n const vbn = new Vector3(U.data[1], U.data[4], U.data[7])\n const vcn = new Vector3(U.data[2], U.data[5], U.data[8])\n\n // scaled\n const va = van.clone().multiplyScalar(Math.sqrt(W.data[0] / n3))\n const vb = vbn.clone().multiplyScalar(Math.sqrt(W.data[1] / n3))\n const vc = vcn.clone().multiplyScalar(Math.sqrt(W.data[2] / n3))\n\n // points\n this.begA = vm.clone().sub(va)\n this.endA = vm.clone().add(va)\n this.begB = vm.clone().sub(vb)\n this.endB = vm.clone().add(vb)\n this.begC = vm.clone().sub(vc)\n this.endC = vm.clone().add(vc)\n\n //\n\n this.center = vm\n\n this.vecA = va\n this.vecB = vb\n this.vecC = vc\n\n this.normVecA = van\n this.normVecB = vbn\n this.normVecC = vcn\n\n // console.timeEnd( \"PrincipalAxes\" );\n }\n\n /**\n * Get the basis matrix descriping the axes\n * @param {Matrix4} [optionalTarget] - target object\n * @return {Matrix4} the basis\n */\n getBasisMatrix (optionalTarget = new Matrix4()) {\n const basis = optionalTarget\n\n basis.makeBasis(this.normVecB, this.normVecA, this.normVecC)\n if (basis.determinant() < 0) {\n basis.scale(negateVector)\n }\n\n return basis\n }\n\n /**\n * Get a quaternion descriping the axes rotation\n * @param {Quaternion} [optionalTarget] - target object\n * @return {Quaternion} the rotation\n */\n getRotationQuaternion (optionalTarget = new Quaternion()) {\n const q = optionalTarget\n q.setFromRotationMatrix(this.getBasisMatrix(tmpMatrix))\n\n return q.inverse()\n }\n\n /**\n * Get the scale/length for each dimension for a box around the axes\n * to enclose the atoms of a structure\n * @param {Structure|StructureView} structure - the structure\n * @return {{d1a: Number, d2a: Number, d3a: Number, d1b: Number, d2b: Number, d3b: Number}} scale\n */\n getProjectedScaleForAtoms (structure: Structure) {\n let d1a = -Infinity\n let d1b = -Infinity\n let d2a = -Infinity\n let d2b = -Infinity\n let d3a = -Infinity\n let d3b = -Infinity\n\n const p = new Vector3()\n const t = new Vector3()\n\n const center = this.center\n const ax1 = this.normVecA\n const ax2 = this.normVecB\n const ax3 = this.normVecC\n\n structure.eachAtom(function (ap: AtomProxy) {\n projectPointOnVector(p.copy(ap as any), ax1, center) // TODO\n const dp1 = t.subVectors(p, center).normalize().dot(ax1)\n const dt1 = p.distanceTo(center)\n if (dp1 > 0) {\n if (dt1 > d1a) d1a = dt1\n } else {\n if (dt1 > d1b) d1b = dt1\n }\n\n projectPointOnVector(p.copy(ap as any), ax2, center)\n const dp2 = t.subVectors(p, center).normalize().dot(ax2)\n const dt2 = p.distanceTo(center)\n if (dp2 > 0) {\n if (dt2 > d2a) d2a = dt2\n } else {\n if (dt2 > d2b) d2b = dt2\n }\n\n projectPointOnVector(p.copy(ap as any), ax3, center)\n const dp3 = t.subVectors(p, center).normalize().dot(ax3)\n const dt3 = p.distanceTo(center)\n if (dp3 > 0) {\n if (dt3 > d3a) d3a = dt3\n } else {\n if (dt3 > d3b) d3b = dt3\n }\n })\n\n return {\n d1a: d1a,\n d2a: d2a,\n d3a: d3a,\n d1b: -d1b,\n d2b: -d2b,\n d3b: -d3b\n }\n }\n}\n\nexport default PrincipalAxes\n","/**\n * @file Filtered Volume\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport Volume from './volume'\nimport { Box3, Matrix4, Matrix3, Vector3 } from 'three';\n\nclass FilteredVolume {\n volume: Volume\n data: Float32Array\n position: Float32Array\n atomindex: Int32Array\n _filterHash: string\n _dataBuffer: ArrayBuffer\n _positionBuffer: ArrayBuffer\n _atomindexBuffer: ArrayBuffer\n getValueForSigma: typeof Volume.prototype.getValueForSigma\n getSigmaForValue: typeof Volume.prototype.getSigmaForValue\n getDataAtomindex: typeof Volume.prototype.getDataAtomindex\n getDataPosition: typeof Volume.prototype.getDataPosition\n getDataColor: typeof Volume.prototype.getDataColor\n getDataPicking: typeof Volume.prototype.getDataPicking\n getDataSize: typeof Volume.prototype.getDataSize\n\n\n constructor (volume: Volume, minValue?: number, maxValue?: number, outside?: boolean) {\n this.volume = volume\n this.setFilter(minValue, maxValue, outside)\n }\n\n get header () { return this.volume.header }\n get matrix (): Matrix4 { return this.volume.matrix }\n get normalMatrix (): Matrix3 { return this.volume.normalMatrix }\n get inverseMatrix (): Matrix4 { return this.volume.inverseMatrix }\n get center (): Vector3 { return this.volume.center }\n get boundingBox (): Box3 { return this.volume.boundingBox }\n get min () { return this.volume.min }\n get max () { return this.volume.max }\n get mean () { return this.volume.mean }\n get rms () { return this.volume.rms }\n\n _getFilterHash (minValue: number, maxValue: number, outside: boolean) {\n return JSON.stringify([ minValue, maxValue, outside ])\n }\n\n setFilter (minValue: number|undefined, maxValue: number|undefined, outside: boolean|undefined) {\n if (isNaN(minValue) && this.header) {\n minValue = this.header.DMEAN + 2.0 * this.header.ARMS\n }\n\n minValue = (minValue !== undefined && !isNaN(minValue)) ? minValue : -Infinity\n maxValue = defaults(maxValue, Infinity) as number\n outside = defaults(outside, false) as boolean\n\n const data = this.volume.data\n const position = this.volume.position\n const atomindex = this.volume.atomindex\n\n const filterHash = this._getFilterHash(minValue, maxValue, outside)\n\n if (filterHash === this._filterHash) {\n // already filtered\n return\n } else if (minValue === -Infinity && maxValue === Infinity) {\n this.data = data\n this.position = position\n this.atomindex = atomindex!\n } else {\n const n = data.length\n\n if (!this._dataBuffer) {\n // ArrayBuffer for re-use as Float32Array backend\n\n this._dataBuffer = new ArrayBuffer(n * 4)\n this._positionBuffer = new ArrayBuffer(n * 3 * 4)\n if (atomindex) this._atomindexBuffer = new ArrayBuffer(n * 4)\n }\n\n const filteredData = new Float32Array(this._dataBuffer)\n const filteredPosition = new Float32Array(this._positionBuffer)\n let filteredAtomindex\n if (atomindex) filteredAtomindex = new Uint32Array(this._atomindexBuffer)\n\n let j = 0\n\n for (let i = 0; i < n; ++i) {\n const i3 = i * 3\n const v = data[ i ]\n\n if ((!outside && v >= minValue && v <= maxValue) ||\n (outside && (v < minValue || v > maxValue))\n ) {\n const j3 = j * 3\n\n filteredData[ j ] = v\n\n filteredPosition[ j3 + 0 ] = position[ i3 + 0 ]\n filteredPosition[ j3 + 1 ] = position[ i3 + 1 ]\n filteredPosition[ j3 + 2 ] = position[ i3 + 2 ]\n\n if (atomindex && filteredAtomindex) filteredAtomindex[ j ] = atomindex[ i ]\n\n j += 1\n }\n }\n\n // set views\n\n this.data = new Float32Array(this._dataBuffer, 0, j)\n this.position = new Float32Array(this._positionBuffer, 0, j * 3)\n if (atomindex) this.atomindex = new Int32Array(this._atomindexBuffer, 0, j)\n }\n\n this._filterHash = filterHash\n }\n}\n\nFilteredVolume.prototype.getValueForSigma = Volume.prototype.getValueForSigma\nFilteredVolume.prototype.getSigmaForValue = Volume.prototype.getSigmaForValue\n\nFilteredVolume.prototype.getDataAtomindex = Volume.prototype.getDataAtomindex\nFilteredVolume.prototype.getDataPosition = Volume.prototype.getDataPosition\nFilteredVolume.prototype.getDataColor = Volume.prototype.getDataColor\nFilteredVolume.prototype.getDataPicking = Volume.prototype.getDataPicking\nFilteredVolume.prototype.getDataSize = Volume.prototype.getDataSize\n\nexport default FilteredVolume\n","/**\n * @file Bond Hash\n * @author Alexander Rose \n * @private\n */\n\nimport BondStore from './bond-store'\nimport { createAdjacencyList } from '../utils/adjacency-list'\n\nclass BondHash {\n countArray: Uint8Array\n offsetArray: Int32Array\n indexArray: Int32Array\n\n constructor (bondStore: BondStore, atomCount: number) {\n const al = createAdjacencyList({\n nodeArray1: bondStore.atomIndex1,\n nodeArray2: bondStore.atomIndex2,\n edgeCount: bondStore.count,\n nodeCount: atomCount\n })\n\n this.countArray = al.countArray\n this.offsetArray = al.offsetArray\n this.indexArray = al.indexArray\n }\n}\n\nexport default BondHash\n","/**\n * @file Bond Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Bond store\n */\nexport default class BondStore extends Store {\n atomIndex1: Uint32Array\n atomIndex2: Uint32Array\n bondOrder: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'atomIndex1', 1, 'int32' ],\n [ 'atomIndex2', 1, 'int32' ],\n [ 'bondOrder', 1, 'int8' ]\n ] as StoreField[]\n }\n\n addBond (atom1: AtomProxy, atom2: AtomProxy, bondOrder?: number) {\n this.growIfFull()\n\n const i = this.count\n const ai1 = atom1.index\n const ai2 = atom2.index\n\n if (ai1 < ai2) {\n this.atomIndex1[ i ] = ai1\n this.atomIndex2[ i ] = ai2\n } else {\n this.atomIndex2[ i ] = ai1\n this.atomIndex1[ i ] = ai2\n }\n if (bondOrder) this.bondOrder[ i ] = bondOrder\n\n this.count += 1\n }\n\n addBondIfConnected (atom1: AtomProxy, atom2: AtomProxy, bondOrder?: number) {\n if (atom1.connectedTo(atom2)) {\n this.addBond(atom1, atom2, bondOrder)\n return true\n }\n\n return false\n }\n}","/**\n * @file Atom Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Atom store\n */\nexport default class AtomStore extends Store {\n residueIndex: Uint32Array\n atomTypeId: Uint16Array\n\n x: Float32Array\n y: Float32Array\n z: Float32Array\n serial: Int32Array\n bfactor: Float32Array\n altloc: Uint8Array\n occupancy: Float32Array\n\n partialCharge?: Float32Array\n formalCharge?: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'residueIndex', 1, 'uint32' ],\n [ 'atomTypeId', 1, 'uint16' ],\n\n [ 'x', 1, 'float32' ],\n [ 'y', 1, 'float32' ],\n [ 'z', 1, 'float32' ],\n [ 'serial', 1, 'int32' ],\n [ 'bfactor', 1, 'float32' ],\n [ 'altloc', 1, 'uint8' ],\n [ 'occupancy', 1, 'float32' ]\n ] as StoreField[]\n }\n\n setAltloc (i: number, str: string) {\n this.altloc[ i ] = str.charCodeAt(0)\n }\n\n getAltloc (i: number) {\n const code = this.altloc[ i ]\n return code ? String.fromCharCode(code) : ''\n }\n}","/**\n * @file Residue Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Residue store\n */\nexport default class ResidueStore extends Store {\n chainIndex: Uint32Array\n atomOffset: Uint32Array\n atomCount: Uint32Array\n residueTypeId: Uint16Array\n\n resno: Uint32Array\n sstruc: Uint8Array\n inscode: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'chainIndex', 1, 'uint32' ],\n [ 'atomOffset', 1, 'uint32' ],\n [ 'atomCount', 1, 'uint32' ],\n [ 'residueTypeId', 1, 'uint16' ],\n\n [ 'resno', 1, 'int32' ],\n [ 'sstruc', 1, 'uint8' ],\n [ 'inscode', 1, 'uint8' ]\n ] as StoreField[]\n }\n\n setSstruc (i: number, str: string) {\n this.sstruc[ i ] = str.charCodeAt(0)\n }\n\n getSstruc (i: number) {\n const code = this.sstruc[ i ]\n return code ? String.fromCharCode(code) : ''\n }\n\n setInscode (i: number, str: string) {\n this.inscode[ i ] = str.charCodeAt(0)\n }\n\n getInscode (i: number) {\n const code = this.inscode[ i ]\n return code ? String.fromCharCode(code) : ''\n }\n}","/**\n * @file Chain Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Chain store\n */\nexport default class ChainStore extends Store {\n entityIndex: Uint16Array\n modelIndex: Uint16Array\n residueOffset: Uint32Array\n residueCount: Uint32Array\n\n chainname: Uint8Array\n chainid: Uint8Array\n\n get _defaultFields () {\n return [\n [ 'entityIndex', 1, 'uint16' ],\n [ 'modelIndex', 1, 'uint16' ],\n [ 'residueOffset', 1, 'uint32' ],\n [ 'residueCount', 1, 'uint32' ],\n\n [ 'chainname', 4, 'uint8' ],\n [ 'chainid', 4, 'uint8' ]\n ] as StoreField[]\n }\n\n setChainname (i: number, str: string) {\n const j = 4 * i\n this.chainname[ j ] = str.charCodeAt(0)\n this.chainname[ j + 1 ] = str.charCodeAt(1)\n this.chainname[ j + 2 ] = str.charCodeAt(2)\n this.chainname[ j + 3 ] = str.charCodeAt(3)\n }\n\n getChainname (i: number) {\n let chainname = ''\n for (let k = 0; k < 4; ++k) {\n const code = this.chainname[ 4 * i + k ]\n if (code) {\n chainname += String.fromCharCode(code)\n } else {\n break\n }\n }\n return chainname\n }\n\n setChainid (i: number, str: string) {\n const j = 4 * i\n this.chainid[ j ] = str.charCodeAt(0)\n this.chainid[ j + 1 ] = str.charCodeAt(1)\n this.chainid[ j + 2 ] = str.charCodeAt(2)\n this.chainid[ j + 3 ] = str.charCodeAt(3)\n }\n\n getChainid (i: number) {\n let chainid = ''\n for (let k = 0; k < 4; ++k) {\n const code = this.chainid[ 4 * i + k ]\n if (code) {\n chainid += String.fromCharCode(code)\n } else {\n break\n }\n }\n return chainid\n }\n}\n","/**\n * @file Model Store\n * @author Alexander Rose \n * @private\n */\n\nimport Store, { StoreField } from './store'\n\n/**\n * Model store\n */\nexport default class ModelStore extends Store {\n\tchainOffset: Uint32Array\n\tchainCount: Uint32Array\n\n get _defaultFields () {\n return [\n [ 'chainOffset', 1, 'uint32' ],\n [ 'chainCount', 1, 'uint32' ]\n ] as StoreField[]\n }\n}","/**\n * @file Helixorient\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport { ColormakerParameters } from '../color/colormaker'\nimport { AtomPicker } from '../utils/picker'\nimport RadiusFactory, { RadiusParams } from '../utils/radius-factory'\nimport { copyArray } from '../math/array-utils'\nimport { projectPointOnVector } from '../math/vector-utils'\nimport Polymer from '../proxy/polymer'\n\nexport interface HelixIterator {\n size: number\n next: () => Vector3\n get: (idx: number) => Vector3\n reset: () => void\n}\n\nexport interface HelixPosition {\n center: Float32Array\n axis: Float32Array\n bending: Float32Array\n radius: Float32Array\n rise: Float32Array\n twist: Float32Array\n resdir: Float32Array\n}\n\nclass Helixorient {\n size: number\n\n constructor (readonly polymer: Polymer) {\n this.size = polymer.residueCount\n }\n\n getCenterIterator (smooth = 0): HelixIterator {\n const center = this.getPosition().center\n const size = center.length / 3\n\n let i = 0\n let j = -1\n\n const cache = [\n new Vector3(),\n new Vector3(),\n new Vector3(),\n new Vector3()\n ]\n\n function next (this: HelixIterator) {\n const vector = this.get(j)\n j += 1\n return vector\n }\n\n function get (idx: number) {\n idx = Math.min(size - 1, Math.max(0, idx))\n const v = cache[ i % 4 ]\n const idx3 = 3 * idx\n v.fromArray(center as any, idx3) // TODO\n if (smooth) {\n const w = Math.min(smooth, idx, size - idx - 1)\n for (let k = 1; k <= w; ++k) {\n const l = k * 3\n const t = (w + 1 - k) / (w + 1)\n v.x += t * center[ idx3 - l + 0 ] + t * center[ idx3 + l + 0 ]\n v.y += t * center[ idx3 - l + 1 ] + t * center[ idx3 + l + 1 ]\n v.z += t * center[ idx3 - l + 2 ] + t * center[ idx3 + l + 2 ]\n }\n v.x /= w + 1\n v.y /= w + 1\n v.z /= w + 1\n }\n i += 1\n return v\n }\n\n function reset () {\n i = 0\n j = -1\n }\n\n return { size, next, get, reset }\n }\n\n getColor (params: { scheme: string } & ColormakerParameters) {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const residueIndexStart = polymer.residueIndexStart\n\n const col = new Float32Array(n * 3)\n\n const p = params || {}\n p.structure = structure\n\n const colormaker = ColormakerRegistry.getScheme(p)\n\n const rp = structure.getResidueProxy()\n const ap = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n rp.index = residueIndexStart + i\n ap.index = rp.traceAtomIndex\n\n colormaker.atomColorToArray(ap, col, i * 3)\n }\n\n return {\n 'color': col\n }\n }\n\n getPicking () {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const residueIndexStart = polymer.residueIndexStart\n\n const pick = new Float32Array(n)\n const rp = structure.getResidueProxy()\n\n for (let i = 0; i < n; ++i) {\n rp.index = residueIndexStart + i\n pick[ i ] = rp.traceAtomIndex\n }\n\n return {\n 'picking': new AtomPicker(pick, structure)\n }\n }\n\n getSize (params: RadiusParams) {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const residueIndexStart = polymer.residueIndexStart\n\n const size = new Float32Array(n)\n const radiusFactory = new RadiusFactory(params)\n\n const rp = structure.getResidueProxy()\n const ap = structure.getAtomProxy()\n\n for (let i = 0; i < n; ++i) {\n rp.index = residueIndexStart + i\n ap.index = rp.traceAtomIndex\n size[ i ] = radiusFactory.atomRadius(ap)\n }\n\n return { size }\n }\n\n getPosition (): HelixPosition {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const n3 = n - 3\n\n const center = new Float32Array(3 * n)\n const axis = new Float32Array(3 * n)\n const diff = new Float32Array(n)\n const radius = new Float32Array(n)\n const rise = new Float32Array(n)\n const twist = new Float32Array(n)\n const resdir = new Float32Array(3 * n)\n\n const r12 = new Vector3()\n const r23 = new Vector3()\n const r34 = new Vector3()\n\n const diff13 = new Vector3()\n const diff24 = new Vector3()\n\n const v1 = new Vector3()\n const v2 = new Vector3()\n const vt = new Vector3()\n\n const _axis = new Vector3()\n const _prevAxis = new Vector3()\n\n const _resdir = new Vector3()\n const _center = new Vector3(0, 0, 0)\n\n const type = 'trace'\n const a1 = structure.getAtomProxy()\n const a2 = structure.getAtomProxy(polymer.getAtomIndexByType(0, type))\n const a3 = structure.getAtomProxy(polymer.getAtomIndexByType(1, type))\n const a4 = structure.getAtomProxy(polymer.getAtomIndexByType(2, type))\n\n for (let i = 0; i < n3; ++i) {\n a1.index = a2.index\n a2.index = a3.index\n a3.index = a4.index\n a4.index = polymer.getAtomIndexByType(i + 3, type)! // TODO\n\n const j = 3 * i\n\n // ported from GROMACS src/tools/gmx_helixorient.c\n\n r12.subVectors(a2 as any, a1 as any) // TODO\n r23.subVectors(a3 as any, a2 as any) // TODO\n r34.subVectors(a4 as any, a3 as any) // TODO\n\n diff13.subVectors(r12, r23)\n diff24.subVectors(r23, r34)\n\n _axis.crossVectors(diff13, diff24).normalize()\n _axis.toArray(axis as any, j) // TODO\n\n if (i > 0) {\n diff[ i ] = _axis.angleTo(_prevAxis)\n }\n\n const tmp = Math.cos(diff13.angleTo(diff24))\n twist[ i ] = 180.0 / Math.PI * Math.acos(tmp)\n\n const diff13Length = diff13.length()\n const diff24Length = diff24.length()\n\n radius[ i ] = (\n Math.sqrt(diff24Length * diff13Length) /\n // clamp, to avoid instabilities for when\n // angle between diff13 and diff24 is near 0\n Math.max(2.0, 2.0 * (1.0 - tmp))\n )\n\n rise[ i ] = Math.abs(r23.dot(_axis))\n\n //\n\n v1.copy(diff13).multiplyScalar(radius[ i ] / diff13Length)\n v2.copy(diff24).multiplyScalar(radius[ i ] / diff24Length)\n\n v1.subVectors(a2 as any, v1) // TODO\n v2.subVectors(a3 as any, v2) // TODO\n\n v1.toArray(center as any, j + 3) // TODO\n v2.toArray(center as any, j + 6) // TODO\n\n //\n\n _resdir.subVectors(a1 as any, _center) // TODO\n _resdir.toArray(resdir as any, j) // TODO\n\n _prevAxis.copy(_axis)\n _center.copy(v1)\n }\n\n //\n\n // calc axis as dir of second and third center pos\n // project first traceAtom onto axis to get first center pos\n v1.fromArray(center as any, 3) // TODO\n v2.fromArray(center as any, 6) // TODO\n _axis.subVectors(v1, v2).normalize()\n // _center.copy( res[ 0 ].getTraceAtom() );\n a1.index = polymer.getAtomIndexByType(0, type)! // TODO\n _center.copy(a1 as any) // TODO\n vt.copy(a1 as any) // TODO\n projectPointOnVector(vt, _axis, v1)\n vt.toArray(center as any, 0) // TODO\n\n // calc first resdir\n _resdir.subVectors(_center, v1)\n _resdir.toArray(resdir as any, 0) // TODO\n\n // calc axis as dir of n-1 and n-2 center pos\n // project last traceAtom onto axis to get last center pos\n v1.fromArray(center as any, 3 * n - 6) // TODO\n v2.fromArray(center as any, 3 * n - 9) // TODO\n _axis.subVectors(v1, v2).normalize()\n // _center.copy( res[ n - 1 ].getTraceAtom() );\n a1.index = polymer.getAtomIndexByType(n - 1, type)! // TODO\n _center.copy(a1 as any) // TODO\n vt.copy(a1 as any) // TODO\n projectPointOnVector(vt, _axis, v1)\n vt.toArray(center as any, 3 * n - 3) // TODO\n\n // calc last three resdir\n for (let i = n - 3; i < n; ++i) {\n v1.fromArray(center as any, 3 * i) // TODO\n // _center.copy( res[ i ].getTraceAtom() );\n a1.index = polymer.getAtomIndexByType(i, type)! // TODO\n _center.copy(a1 as any) // TODO\n\n _resdir.subVectors(_center, v1)\n _resdir.toArray(resdir as any, 3 * i) // TODO\n }\n\n // average measures to define them on the residues\n\n const resRadius = new Float32Array(n)\n const resTwist = new Float32Array(n)\n const resRise = new Float32Array(n)\n const resBending = new Float32Array(n)\n\n resRadius[ 1 ] = radius[ 0 ]\n resTwist[ 1 ] = twist[ 0 ]\n resRise[ 1 ] = radius[ 0 ]\n\n for (let i = 2; i < n - 2; ++i) {\n resRadius[ i ] = 0.5 * (radius[ i - 2 ] + radius[ i - 1 ])\n resTwist[ i ] = 0.5 * (twist[ i - 2 ] + twist[ i - 1 ])\n resRise[ i ] = 0.5 * (rise[ i - 2 ] + rise[ i - 1 ])\n\n v1.fromArray(axis as any, 3 * (i - 2)) // TODO\n v2.fromArray(axis as any, 3 * (i - 1)) // TODO\n resBending[ i ] = 180.0 / Math.PI * Math.acos(Math.cos(v1.angleTo(v2)))\n }\n\n resRadius[ n - 2 ] = radius[ n - 4 ]\n resTwist[ n - 2 ] = twist[ n - 4 ]\n resRise[ n - 2 ] = rise[ n - 4 ]\n\n // average helix axes to define them on the residues\n\n const resAxis = new Float32Array(3 * n)\n\n copyArray(axis, resAxis, 0, 0, 3)\n copyArray(axis, resAxis, 0, 3, 3)\n\n for (let i = 2; i < n - 2; ++i) {\n v1.fromArray(axis as any, 3 * (i - 2)) // TODO\n v2.fromArray(axis as any, 3 * (i - 1)) // TODO\n\n _axis.addVectors(v2, v1).multiplyScalar(0.5).normalize()\n _axis.toArray(resAxis as any, 3 * i) // TODO\n }\n\n copyArray(axis, resAxis, 3 * n - 12, 3 * n - 6, 3)\n copyArray(axis, resAxis, 3 * n - 12, 3 * n - 3, 3)\n\n return {\n center,\n axis: resAxis,\n bending: resBending,\n radius: resRadius,\n rise: resRise,\n twist: resTwist,\n resdir: resdir\n }\n }\n\n}\n\nexport default Helixorient\n","/**\n * @file Helixbundle\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport { AtomPicker } from '../utils/picker'\nimport RadiusFactory, { RadiusParams } from '../utils/radius-factory'\nimport Helixorient, { HelixPosition } from './helixorient'\nimport { calculateMeanVector3, projectPointOnVector } from '../math/vector-utils'\nimport Polymer from '../proxy/polymer'\nimport { ColormakerParameters } from '../color/colormaker';\n\nexport interface Axis {\n axis: Float32Array\n center: Float32Array\n begin: Float32Array\n end: Float32Array\n color: Float32Array\n picking: AtomPicker\n size: Float32Array\n residueOffset: number[]\n residueCount: number[]\n}\n\nclass Helixbundle {\n helixorient: Helixorient;\n position: HelixPosition;\n\n constructor (readonly polymer: Polymer) {\n\n this.helixorient = new Helixorient(polymer)\n this.position = this.helixorient.getPosition()\n }\n\n getAxis (localAngle: number, centerDist: number, ssBorder: boolean, colorParams: { scheme: string} & ColormakerParameters, radiusParams: RadiusParams): Axis {\n localAngle = localAngle || 30\n centerDist = centerDist || 2.5\n ssBorder = ssBorder === undefined ? false : ssBorder\n\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n const residueIndexStart = polymer.residueIndexStart\n\n const pos = this.position\n\n const cp = colorParams || {}\n cp.structure = structure\n\n const colormaker = ColormakerRegistry.getScheme(cp)\n\n const radiusFactory = new RadiusFactory(radiusParams)\n\n let j = 0\n let k = 0\n\n const axis: number[] = []\n const center: number[] = []\n const beg: number[] = []\n const end: number[] = []\n const col: number[] = []\n const pick = []\n const size = []\n const residueOffset = []\n const residueCount = []\n\n let tmpAxis = new Float32Array(n * 3)\n let tmpCenter = new Float32Array(n * 3)\n\n let _axis, _center\n const _beg = new Vector3()\n const _end = new Vector3()\n\n const rp1 = structure.getResidueProxy()\n const rp2 = structure.getResidueProxy()\n const ap = structure.getAtomProxy()\n\n const c1 = new Vector3()\n const c2 = new Vector3()\n\n let split = false\n\n for (let i = 0; i < n; ++i) {\n rp1.index = residueIndexStart + i\n c1.fromArray(pos.center as any, i * 3)\n\n if (i === n - 1) {\n split = true\n } else {\n rp2.index = residueIndexStart + i + 1\n c2.fromArray(pos.center as any, i * 3 + 3)\n\n if (ssBorder && rp1.sstruc !== rp2.sstruc) {\n split = true\n } else if (c1.distanceTo(c2) > centerDist) {\n split = true\n } else if (pos.bending[ i ] > localAngle) {\n split = true\n }\n }\n\n if (split) {\n if (i - j < 4) {\n j = i\n split = false\n continue\n }\n\n ap.index = rp1.traceAtomIndex\n\n // ignore first and last axis\n tmpAxis = pos.axis.subarray(j * 3 + 3, i * 3)\n tmpCenter = pos.center.subarray(j * 3, i * 3 + 3)\n\n _axis = calculateMeanVector3(tmpAxis).normalize()\n _center = calculateMeanVector3(tmpCenter)\n\n _beg.fromArray(tmpCenter as any)\n projectPointOnVector(_beg, _axis, _center)\n\n _end.fromArray(tmpCenter as any, tmpCenter.length - 3)\n projectPointOnVector(_end, _axis, _center)\n\n _axis.subVectors(_end, _beg)\n\n _axis.toArray(axis as any, k)\n _center.toArray(center as any, k)\n _beg.toArray(beg as any, k)\n _end.toArray(end as any, k)\n\n colormaker.atomColorToArray(ap, col, k)\n\n pick.push(ap.index)\n\n size.push(radiusFactory.atomRadius(ap))\n\n residueOffset.push(residueIndexStart + j)\n residueCount.push(residueIndexStart + i + 1 - j)\n\n k += 3\n j = i\n split = false\n }\n }\n\n const picking = new Float32Array(pick)\n\n return {\n axis: new Float32Array(axis),\n center: new Float32Array(center),\n begin: new Float32Array(beg),\n end: new Float32Array(end),\n color: new Float32Array(col),\n picking: new AtomPicker(picking, structure),\n size: new Float32Array(size),\n residueOffset: residueOffset,\n residueCount: residueCount\n }\n }\n}\n\nexport default Helixbundle\n","/**\n * @file Binary Heap\n * @author Alexander Rose \n * @private\n */\n\n/**\n * Binary heap implementation\n * @class\n * @author http://eloquentjavascript.net/appendix2.htm\n * @param {Function} scoreFunction - the heap scoring function\n */\nclass BinaryHeap {\n content: T[] = []\n\n constructor(readonly scoreFunction: (x: T) => number) {\n\n this.scoreFunction = scoreFunction\n }\n\n push (element: T) {\n // Add the new element to the end of the array.\n this.content.push(element)\n\n // Allow it to bubble up.\n this.bubbleUp(this.content.length - 1)\n }\n\n pop () {\n // Store the first element so we can return it later.\n const result = this.content[ 0 ]\n\n // Get the element at the end of the array.\n const end = this.content.pop()\n\n // If there are any elements left, put the end element at the\n // start, and let it sink down.\n if (end && this.content.length > 0) {\n this.content[ 0 ] = end\n this.sinkDown(0)\n }\n\n return result\n }\n\n peek () {\n return this.content[ 0 ]\n }\n\n remove (element: T) {\n const len = this.content.length\n\n // To remove a value, we must search through the array to find it.\n for (let i = 0; i < len; i++) {\n if (this.content[ i ] === element) {\n // When it is found, the process seen in 'pop' is repeated\n // to fill up the hole.\n const end = this.content.pop()\n\n if (end && i !== len - 1) {\n this.content[ i ] = end\n\n if (this.scoreFunction(end) < this.scoreFunction(element)) {\n this.bubbleUp(i)\n } else {\n this.sinkDown(i)\n }\n }\n\n return\n }\n }\n\n throw new Error('Node not found.')\n }\n\n size () {\n return this.content.length\n }\n\n bubbleUp (n: number) {\n // Fetch the element that has to be moved.\n const element = this.content[ n ]\n\n // When at 0, an element can not go up any further.\n while (n > 0) {\n // Compute the parent element's index, and fetch it.\n const parentN = Math.floor((n + 1) / 2) - 1\n const parent = this.content[ parentN ]\n\n // Swap the elements if the parent is greater.\n if (this.scoreFunction(element) < this.scoreFunction(parent)) {\n this.content[ parentN ] = element\n this.content[ n ] = parent\n\n // Update 'n' to continue at the new position.\n n = parentN\n } else {\n // Found a parent that is less, no need to move it further.\n break\n }\n }\n }\n\n sinkDown (n: number) {\n // Look up the target element and its score.\n const length = this.content.length\n const element = this.content[ n ]\n const elemScore = this.scoreFunction(element)\n\n let child1Score = 0\n let child2Score = 0\n\n while (true) {\n // Compute the indices of the child elements.\n const child2N = (n + 1) * 2\n const child1N = child2N - 1\n\n // This is used to store the new position of the element, if any.\n let swap = null\n\n // If the first child exists (is inside the array)...\n if (child1N < length) {\n // Look it up and compute its score.\n const child1 = this.content[ child1N ]\n child1Score = this.scoreFunction(child1)\n\n // If the score is less than our element's, we need to swap.\n if (child1Score < elemScore) swap = child1N\n }\n\n // Do the same checks for the other child.\n if (child2N < length) {\n const child2 = this.content[ child2N ]\n child2Score = this.scoreFunction(child2)\n\n if (child2Score < (swap === null ? elemScore : child1Score)) swap = child2N\n }\n\n // If the element needs to be moved, swap it, and continue.\n if (swap !== null) {\n this.content[ n ] = this.content[ swap ]\n this.content[ swap ] = element\n n = swap\n } else {\n // Otherwise, we are done.\n break\n }\n }\n }\n\n}\n\nexport default BinaryHeap\n","/**\n * @file Kdtree\n * @author Alexander Rose \n * @private\n */\n\nimport { NumberArray } from '../types'\nimport BinaryHeap from './binary-heap'\n\n/**\n * Kdtree\n * @class\n * @author Alexander Rose , 2016\n * @author Roman Bolzern , 2013\n * @author I4DS http://www.fhnw.ch/i4ds, 2013\n * @license MIT License \n * @description\n * k-d Tree for typed arrays of 3d points (e.g. for Float32Array), in-place\n * provides fast nearest neighbour search\n *\n * Based on https://github.com/ubilabs/kd-tree-javascript by Ubilabs\n *\n * Further information (including mathematical properties)\n * http://en.wikipedia.org/wiki/Binary_tree\n * http://en.wikipedia.org/wiki/K-d_tree\n *\n * @example\n * points: [x, y, z, x, y, z, x, y, z, ...]\n * metric: function(a, b){\n * return Math.pow(a[0]-b[0], 2) + Math.pow(a[1]-b[1], 2) + Math.pow(a[2]-b[2], 2);\n * }\n *\n * @param {Float32Array} points - points\n * @param {Function} metric - metric\n */\nclass Kdtree {\n indices: Uint32Array\n nodes: Int32Array\n rootIndex: number\n\n maxDepth = 0\n currentNode = 0\n\n constructor(readonly points: NumberArray, readonly metric: (a: NumberArray, b: NumberArray) => number) {\n const n = points.length / 3\n\n const indices = new Uint32Array(n)\n for (let i = 0; i < n; ++i) {\n indices[ i ] = i\n }\n this.indices = indices\n this.nodes = new Int32Array(n * 4)\n this.rootIndex = this.buildTree(0, -1, 0, n)\n }\n\n buildTree (depth: number, parent: number, arrBegin: number, arrEnd: number) {\n if (depth > this.maxDepth) this.maxDepth = depth\n\n const plength = arrEnd - arrBegin\n if (plength === 0) {\n return -1\n }\n\n const nodeIndex = this.currentNode * 4\n const nodes = this.nodes\n\n this.currentNode += 1\n if (plength === 1) {\n nodes[ nodeIndex ] = arrBegin\n nodes[ nodeIndex + 1 ] = -1\n nodes[ nodeIndex + 2 ] = -1\n nodes[ nodeIndex + 3 ] = parent\n return nodeIndex\n }\n // if(plength <= 32){\n // return nodeIndex;\n // }\n\n const indices = this.indices\n const points = this.points\n\n const arrMedian = arrBegin + Math.floor(plength / 2)\n const currentDim = depth % 3\n\n // inlined quickselect function\n let j, tmp, pivotIndex, pivotValue, storeIndex\n let left = arrBegin\n let right = arrEnd - 1\n while (right > left) {\n pivotIndex = (left + right) >> 1\n pivotValue = points[ indices[ pivotIndex ] * 3 + currentDim ]\n // swap( pivotIndex, right );\n tmp = indices[ pivotIndex ]\n indices[ pivotIndex ] = indices[ right ]\n indices[ right ] = tmp\n storeIndex = left\n for (j = left; j < right; ++j) {\n if (points[ indices[ j ] * 3 + currentDim ] < pivotValue) {\n // swap( storeIndex, j );\n tmp = indices[ storeIndex ]\n indices[ storeIndex ] = indices[ j ]\n indices[ j ] = tmp\n ++storeIndex\n }\n }\n // swap( right, storeIndex );\n tmp = indices[ right ]\n indices[ right ] = indices[ storeIndex ]\n indices[ storeIndex ] = tmp\n pivotIndex = storeIndex\n if (arrMedian === pivotIndex) {\n break\n } else if (arrMedian < pivotIndex) {\n right = pivotIndex - 1\n } else {\n left = pivotIndex + 1\n }\n }\n\n nodes[ nodeIndex ] = arrMedian\n nodes[ nodeIndex + 1 ] = this.buildTree(depth + 1, nodeIndex, arrBegin, arrMedian)\n nodes[ nodeIndex + 2 ] = this.buildTree(depth + 1, nodeIndex, arrMedian + 1, arrEnd)\n nodes[ nodeIndex + 3 ] = parent\n\n return nodeIndex\n }\n\n getNodeDepth (nodeIndex: number): number {\n const parentIndex = this.nodes[ nodeIndex + 3 ]\n return (parentIndex === -1) ? 0 : this.getNodeDepth(parentIndex) + 1\n }\n\n // TODO\n // function getNodePos (node) {}\n\n /**\n * find nearest points\n * @param {Array} point - array of size 3\n * @param {Integer} maxNodes - max amount of nodes to return\n * @param {Float} maxDistance - maximum distance of point to result nodes\n * @return {Array} array of point, distance pairs\n */\n nearest (point: NumberArray, maxNodes: number, maxDistance: number) {\n const bestNodes = new BinaryHeap<[number, number]>(e => -e[ 1 ])\n\n const nodes = this.nodes\n const points = this.points\n const indices = this.indices\n\n const nearestSearch = (nodeIndex: number) => {\n let bestChild, otherChild\n const dimension = this.getNodeDepth(nodeIndex) % 3\n const pointIndex = indices[ nodes[ nodeIndex ] ] * 3\n const ownPoint = [\n points[ pointIndex + 0 ],\n points[ pointIndex + 1 ],\n points[ pointIndex + 2 ]\n ]\n const ownDistance = this.metric(point, ownPoint)\n\n function saveNode (nodeIndex: number, distance: number) {\n bestNodes.push([ nodeIndex, distance ])\n if (bestNodes.size() > maxNodes) {\n bestNodes.pop()\n }\n }\n\n const leftIndex = nodes[ nodeIndex + 1 ]\n const rightIndex = nodes[ nodeIndex + 2 ]\n\n // if it's a leaf\n if (rightIndex === -1 && leftIndex === -1) {\n if ((bestNodes.size() < maxNodes || ownDistance < bestNodes.peek()[ 1 ]) &&\n ownDistance <= maxDistance\n ) {\n saveNode(nodeIndex, ownDistance)\n }\n return\n }\n\n if (rightIndex === -1) {\n bestChild = leftIndex\n } else if (leftIndex === -1) {\n bestChild = rightIndex\n } else {\n if (point[ dimension ] <= points[ pointIndex + dimension ]) {\n bestChild = leftIndex\n } else {\n bestChild = rightIndex\n }\n }\n\n // recursive search\n nearestSearch(bestChild)\n\n if ((bestNodes.size() < maxNodes || ownDistance < bestNodes.peek()[ 1 ]) &&\n ownDistance <= maxDistance\n ) {\n saveNode(nodeIndex, ownDistance)\n }\n\n // if there's still room or the current distance is nearer than the best distance\n const linearPoint = []\n for (let i = 0; i < 3; i += 1) {\n if (i === dimension) {\n linearPoint[ i ] = point[ i ]\n } else {\n linearPoint[ i ] = points[ pointIndex + i ]\n }\n }\n const linearDistance = this.metric(linearPoint, ownPoint)\n\n if ((bestNodes.size() < maxNodes || Math.abs(linearDistance) < bestNodes.peek()[ 1 ]) &&\n Math.abs(linearDistance) <= maxDistance\n ) {\n if (bestChild === leftIndex) {\n otherChild = rightIndex\n } else {\n otherChild = leftIndex\n }\n if (otherChild !== -1) {\n nearestSearch(otherChild)\n }\n }\n }\n\n nearestSearch(this.rootIndex)\n\n const result = []\n for (let i = 0, il = Math.min(bestNodes.size(), maxNodes); i < il; i += 1) {\n result.push(bestNodes.content[ i ])\n }\n\n return result\n }\n\n verify (nodeIndex?: number, depth = 0) {\n let count = 1\n\n if (nodeIndex === undefined) {\n nodeIndex = this.rootIndex\n }\n\n if (nodeIndex === -1) {\n throw new Error('node is null')\n }\n\n const dim = depth % 3\n const nodes = this.nodes\n const points = this.points\n const indices = this.indices\n\n const leftIndex = nodes[ nodeIndex + 1 ]\n const rightIndex = nodes[ nodeIndex + 2 ]\n\n if (leftIndex !== -1) {\n if (points[ indices[ nodes[ leftIndex ] ] * 3 + dim ] >\n points[ indices[ nodes[ nodeIndex ] ] * 3 + dim ]\n ) {\n throw new Error('left child is > parent!')\n }\n count += this.verify(leftIndex, depth + 1)\n }\n\n if (rightIndex !== -1) {\n if (points[ indices[ nodes[ rightIndex ] ] * 3 + dim ] <\n points[ indices[ nodes[ nodeIndex ] ] * 3 + dim ]\n ) {\n throw new Error('right child is < parent!')\n }\n count += this.verify(rightIndex, depth + 1)\n }\n\n return count\n }\n}\n\nexport default Kdtree\n","/**\n * @file Atom Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { NumberArray } from '../types'\nimport {\n Elements,\n SecStrucHelix, SecStrucSheet, SecStrucTurn,\n ProteinType, RnaType, DnaType, WaterType, IonType, SaccharideType,\n CgProteinBackboneType, CgRnaBackboneType, CgDnaBackboneType\n} from '../structure/structure-constants'\n\nimport Structure from '../structure/structure'\n\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\nimport AtomStore from '../store/atom-store'\n\nimport AtomMap from '../store/atom-map'\nimport ResidueMap from '../store/residue-map'\n\nimport BondProxy from '../proxy/bond-proxy'\nimport AtomType from '../store/atom-type';\nimport ResidueType from '../store/residue-type';\nimport ResidueProxy from './residue-proxy';\nimport Entity from '../structure/entity';\nimport BondHash from '../store/bond-hash';\n\n/**\n * Atom proxy\n */\nclass AtomProxy {\n index: number\n\n chainStore: ChainStore\n residueStore: ResidueStore\n atomStore: AtomStore\n\n residueMap: ResidueMap\n atomMap: AtomMap\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n this.atomStore = structure.atomStore\n this.residueMap = structure.residueMap\n this.atomMap = structure.atomMap\n }\n\n /**\n * @type {BondHash}\n */\n get bondHash (): BondHash|undefined { return this.structure.bondHash }\n\n /**\n * Molecular enity\n * @type {Entity}\n */\n get entity (): Entity {\n return this.structure.entityList[ this.entityIndex ]\n }\n get entityIndex () {\n return this.chainStore.entityIndex[ this.chainIndex ]\n }\n get modelIndex () {\n return this.chainStore.modelIndex[ this.chainIndex ]\n }\n get chainIndex () {\n return this.residueStore.chainIndex[ this.residueIndex ]\n }\n /**\n * @type {ResidueProxy}\n */\n get residue (): ResidueProxy {\n console.warn('residue - might be expensive')\n return this.structure.getResidueProxy(this.residueIndex)\n }\n\n get residueIndex () {\n return this.atomStore.residueIndex[ this.index ]\n }\n set residueIndex (value) {\n this.atomStore.residueIndex[ this.index ] = value\n }\n\n //\n\n /**\n * Secondary structure code\n * @type {String}\n */\n get sstruc () {\n return this.residueStore.getSstruc(this.residueIndex)\n }\n /**\n * Insertion code\n * @type {String}\n */\n get inscode () {\n return this.residueStore.getInscode(this.residueIndex)\n }\n /**\n * Residue number/label\n * @type {Integer}\n */\n get resno () {\n return this.residueStore.resno[ this.residueIndex ]\n }\n /**\n * Chain name\n * @type {String}\n */\n get chainname () {\n return this.chainStore.getChainname(this.chainIndex)\n }\n /**\n * Chain id\n * @type {String}\n */\n get chainid () {\n return this.chainStore.getChainid(this.chainIndex)\n }\n\n //\n\n /**\n * @type {ResidueType}\n */\n get residueType (): ResidueType {\n return this.residueMap.get(this.residueStore.residueTypeId[ this.residueIndex ])\n }\n /**\n * @type {AtomType}\n */\n get atomType (): AtomType {\n return this.atomMap.get(this.atomStore.atomTypeId[ this.index ])\n }\n get residueAtomOffset () {\n return this.residueStore.atomOffset[ this.residueIndex ]\n }\n\n //\n\n /**\n * Residue name\n */\n get resname () {\n return this.residueType.resname\n }\n /**\n * Hetero flag\n */\n get hetero () {\n return this.residueType.hetero\n }\n\n //\n\n /**\n * Atom name\n */\n get atomname () {\n return this.atomType.atomname\n }\n /**\n * Atomic number\n */\n get number () {\n return this.atomType.number\n }\n /**\n * Element\n */\n get element () {\n return this.atomType.element\n }\n /**\n * Van-der-Waals radius\n */\n get vdw () {\n return this.atomType.vdw\n }\n /**\n * Covalent radius\n */\n get covalent () {\n return this.atomType.covalent\n }\n\n //\n\n /**\n * X coordinate\n */\n get x () {\n return this.atomStore.x[ this.index ]\n }\n set x (value) {\n this.atomStore.x[ this.index ] = value\n }\n\n /**\n * Y coordinate\n */\n get y () {\n return this.atomStore.y[ this.index ]\n }\n set y (value) {\n this.atomStore.y[ this.index ] = value\n }\n\n /**\n * Z coordinate\n */\n get z () {\n return this.atomStore.z[ this.index ]\n }\n set z (value) {\n this.atomStore.z[ this.index ] = value\n }\n\n /**\n * Serial number\n */\n get serial () {\n return this.atomStore.serial[ this.index ]\n }\n set serial (value) {\n this.atomStore.serial[ this.index ] = value\n }\n\n /**\n * B-factor value\n */\n get bfactor () {\n return this.atomStore.bfactor[ this.index ]\n }\n set bfactor (value) {\n this.atomStore.bfactor[ this.index ] = value\n }\n\n /**\n * Occupancy value\n */\n get occupancy () {\n return this.atomStore.occupancy[ this.index ]\n }\n set occupancy (value) {\n this.atomStore.occupancy[ this.index ] = value\n }\n\n /**\n * Alternate location identifier\n */\n get altloc () {\n return this.atomStore.getAltloc(this.index)\n }\n set altloc (value) {\n this.atomStore.setAltloc(this.index, value)\n }\n\n /**\n * Partial charge\n */\n get partialCharge () {\n return this.atomStore.partialCharge ? this.atomStore.partialCharge[ this.index ] : null\n }\n set partialCharge (value) {\n if (this.atomStore.partialCharge) {\n this.atomStore.partialCharge[ this.index ] = value as number\n }\n }\n\n /**\n * Explicit radius\n */\n get radius () {\n return this.atomStore.radius ? this.atomStore.radius[ this.index ] : null\n }\n set radius (value) {\n if (this.atomStore.radius) {\n this.atomStore.radius[ this.index ] = value as number\n }\n }\n\n /**\n * Formal charge\n */\n get formalCharge () {\n return this.atomStore.formalCharge ? this.atomStore.formalCharge[ this.index ] : null\n }\n set formalCharge (value) {\n if (this.atomStore.formalCharge) {\n this.atomStore.formalCharge[ this.index ] = value as number\n }\n }\n\n /**\n * Aromaticity flag\n */\n get aromatic () {\n if (this.atomStore.aromatic) {\n return this.atomStore.aromatic[ this.index ] as number\n } else {\n return this.residueType.isAromatic(this) ? 1 : 0\n }\n }\n set aromatic (value) {\n if (this.atomStore.aromatic) {\n this.atomStore.aromatic[ this.index ] = value as number\n }\n }\n\n //\n\n get bondCount () {\n return this.bondHash!.countArray[ this.index ] // TODO\n }\n\n //\n\n /**\n * Iterate over each bond\n * @param {function(bond: BondProxy)} callback - iterator callback function\n * @param {BondProxy} [bp] - optional target bond proxy for use in the callback\n * @return {undefined}\n */\n eachBond (callback: (bp: BondProxy) => void, bp?: BondProxy) {\n bp = bp || this.structure._bp\n const idx = this.index\n const bondHash = this.bondHash! // TODO\n const indexArray = bondHash.indexArray\n const n = bondHash.countArray[ idx ]\n const offset = bondHash.offsetArray[ idx ]\n\n for (let i = 0; i < n; ++i) {\n bp.index = indexArray[ offset + i ]\n callback(bp)\n }\n }\n\n /**\n * Iterate over each bonded atom\n * @param {function(atom: AtomProxy)} callback - iterator callback function\n * @param {AtomProxy} [ap] - optional target atom proxy for use in the callback\n * @return {undefined}\n */\n eachBondedAtom (callback: (ap: AtomProxy) => void, _ap?: AtomProxy) {\n const ap = _ap ? _ap : this.structure._ap\n const idx = this.index\n\n this.eachBond(function (bp) {\n ap.index = idx !== bp.atomIndex1 ? bp.atomIndex1 : bp.atomIndex2\n callback(ap)\n })\n this.index = idx\n }\n\n /**\n * Check if this atom is bonded to the given atom,\n * assumes both atoms are from the same structure\n * @param {AtomProxy} ap - the given atom\n * @return {Boolean} whether a bond exists or not\n */\n hasBondTo (ap: AtomProxy) {\n let flag = false\n this.eachBondedAtom(function (bap) {\n if (ap.index === bap.index) flag = true\n })\n return flag\n }\n\n bondToElementCount (element: Elements) {\n let count = 0\n const idx = this.index // Avoid reentrancy problems\n this.eachBondedAtom(function (bap) {\n if (bap.number === element) count += 1\n })\n this.index = idx\n return count\n }\n\n hasBondToElement (element: Elements) {\n return this.bondToElementCount(element) > 0\n }\n\n //\n\n /**\n * If atom is part of a backbone\n * @return {Boolean} flag\n */\n isBackbone () {\n const backboneIndexList = this.residueType.backboneIndexList\n if (backboneIndexList.length > 0) {\n return backboneIndexList.includes(this.index - this.residueAtomOffset)\n } else {\n return false\n }\n }\n\n /**\n * If atom is part of a polymer\n * @return {Boolean} flag\n */\n isPolymer () {\n if (this.structure.entityList.length > 0) {\n return this.entity.isPolymer()\n } else {\n const moleculeType = this.residueType.moleculeType\n return (\n moleculeType === ProteinType ||\n moleculeType === RnaType ||\n moleculeType === DnaType\n )\n }\n }\n\n /**\n * If atom is part of a sidechin\n * @return {Boolean} flag\n */\n isSidechain () {\n return this.isPolymer() && !this.isBackbone()\n }\n\n /**\n * If atom is part of a coarse-grain group\n * @return {Boolean} flag\n */\n isCg () {\n const backboneType = this.residueType.backboneType\n return (\n backboneType === CgProteinBackboneType ||\n backboneType === CgRnaBackboneType ||\n backboneType === CgDnaBackboneType\n )\n }\n\n isTrace () {\n return this.index === (this.residueType.traceAtomIndex + this.residueAtomOffset)\n }\n\n /**\n * If atom is part of a hetero group\n * @return {Boolean} flag\n */\n isHetero () {\n return this.residueType.hetero === 1\n }\n\n /**\n * If atom is part of a protein molecule\n * @return {Boolean} flag\n */\n isProtein () {\n return this.residueType.moleculeType === ProteinType\n }\n\n /**\n * If atom is part of a nucleic molecule\n * @return {Boolean} flag\n */\n isNucleic () {\n const moleculeType = this.residueType.moleculeType\n return moleculeType === RnaType || moleculeType === DnaType\n }\n\n /**\n * If atom is part of a rna\n * @return {Boolean} flag\n */\n isRna () {\n return this.residueType.moleculeType === RnaType\n }\n\n /**\n * If atom is part of a dna\n * @return {Boolean} flag\n */\n isDna () {\n return this.residueType.moleculeType === DnaType\n }\n\n /**\n * If atom is part of a water molecule\n * @return {Boolean} flag\n */\n isWater () {\n return this.residueType.moleculeType === WaterType\n }\n\n /**\n * If atom is part of an ion\n * @return {Boolean} flag\n */\n isIon () {\n return this.residueType.moleculeType === IonType\n }\n\n /**\n * If atom is part of a saccharide\n * @return {Boolean} flag\n */\n isSaccharide () {\n return this.residueType.moleculeType === SaccharideType\n }\n\n /**\n * If atom is part of a helix\n * @return {Boolean} flag\n */\n isHelix () {\n return SecStrucHelix.includes(this.sstruc)\n }\n\n /**\n * If atom is part of a sheet\n * @return {Boolean} flag\n */\n isSheet () {\n return SecStrucSheet.includes(this.sstruc)\n }\n\n /**\n * If atom is part of a turn\n * @return {Boolean} flag\n */\n isTurn () {\n return SecStrucTurn.includes(this.sstruc) && this.isProtein()\n }\n\n isBonded () {\n return this.bondHash!.countArray[ this.index ] !== 0 // TODO\n }\n\n /**\n * If atom is part of a ring\n * @return {Boolean} flag\n */\n isRing () {\n const atomRings = this.residueType.getRings()!.atomRings // TODO\n return atomRings[ this.index - this.residueAtomOffset ] !== undefined\n }\n\n isAromatic () {\n return this.aromatic === 1\n }\n\n isPolarHydrogen () {\n let result = false\n\n if (this.number !== 1) return result\n\n result = !this.hasBondToElement(Elements.C)\n\n return result\n }\n\n isMetal () { return this.atomType.isMetal() }\n isNonmetal () { return this.atomType.isNonmetal() }\n isMetalloid () { return this.atomType.isMetalloid() }\n isHalogen () { return this.atomType.isHalogen() }\n isDiatomicNonmetal () { return this.atomType.isDiatomicNonmetal() }\n isPolyatomicNonmetal () { return this.atomType.isPolyatomicNonmetal() }\n isAlkaliMetal () { return this.atomType.isAlkaliMetal() }\n isAlkalineEarthMetal () { return this.atomType.isAlkalineEarthMetal() }\n isNobleGas () { return this.atomType.isNobleGas() }\n isTransitionMetal () { return this.atomType.isTransitionMetal() }\n isPostTransitionMetal () { return this.atomType.isPostTransitionMetal() }\n isLanthanide () { return this.atomType.isLanthanide() }\n isActinide () { return this.atomType.isActinide() }\n\n getDefaultValence () { return this.atomType.getDefaultValence() }\n getValenceList () { return this.atomType.getValenceList() }\n getOuterShellElectronCount () { return this.atomType.getOuterShellElectronCount() }\n\n /**\n * Distance to another atom\n * @param {AtomProxy} atom - the other atom\n * @return {Number} the distance\n */\n distanceTo (atom: AtomProxy) {\n const taa = this.atomStore\n const aaa = atom.atomStore\n const ti = this.index\n const ai = atom.index\n const x = taa.x[ ti ] - aaa.x[ ai ]\n const y = taa.y[ ti ] - aaa.y[ ai ]\n const z = taa.z[ ti ] - aaa.z[ ai ]\n const distSquared = x * x + y * y + z * z\n return Math.sqrt(distSquared)\n }\n\n /**\n * If connected to another atom\n * @param {AtomProxy} atom - the other atom\n * @return {Boolean} flag\n */\n connectedTo (atom: AtomProxy) {\n const taa = this.atomStore\n const aaa = atom.atomStore\n const ti = this.index\n const ai = atom.index\n\n if (taa.altloc && aaa.altloc) {\n const ta = taa.altloc[ ti ] // use Uint8 value to compare\n const aa = aaa.altloc[ ai ] // no need to convert to char\n // 0 is the Null character, 32 is the space character\n if (!(ta === 0 || aa === 0 || ta === 32 || aa === 32 || (ta === aa))) return false\n }\n\n const x = taa.x[ ti ] - aaa.x[ ai ]\n const y = taa.y[ ti ] - aaa.y[ ai ]\n const z = taa.z[ ti ] - aaa.z[ ai ]\n\n const distSquared = x * x + y * y + z * z\n\n // if( this.isCg() ) console.log( this.qualifiedName(), Math.sqrt( distSquared ), distSquared )\n if (distSquared < 48.0 && this.isCg()) return true\n\n if (isNaN(distSquared)) return false\n\n const d = this.covalent + atom.covalent\n const d1 = d + 0.3\n const d2 = d - 0.5\n\n return distSquared < (d1 * d1) && distSquared > (d2 * d2)\n }\n\n /**\n * Set atom position from array\n * @param {Array|TypedArray} array - input array\n * @param {Integer} [offset] - the offset\n * @return {AtomProxy} this object\n */\n positionFromArray (array: NumberArray, offset = 0) {\n this.x = array[ offset + 0 ]\n this.y = array[ offset + 1 ]\n this.z = array[ offset + 2 ]\n\n return this\n }\n\n /**\n * Write atom position to array\n * @param {Array|TypedArray} [array] - target array\n * @param {Integer} [offset] - the offset\n * @return {Array|TypedArray} target array\n */\n positionToArray (array: NumberArray = [], offset = 0) {\n const index = this.index\n const atomStore = this.atomStore\n\n array[ offset + 0 ] = atomStore.x[ index ]\n array[ offset + 1 ] = atomStore.y[ index ]\n array[ offset + 2 ] = atomStore.z[ index ]\n\n return array\n }\n\n /**\n * Write atom position to vector\n * @param {Vector3} [v] - target vector\n * @return {Vector3} target vector\n */\n positionToVector3 (v?: Vector3) {\n if (v === undefined) v = new Vector3()\n\n v.x = this.x\n v.y = this.y\n v.z = this.z\n\n return v\n }\n\n /**\n * Set atom position from vector\n * @param {Vector3} v - input vector\n * @return {AtomProxy} this object\n */\n positionFromVector3 (v: Vector3) {\n this.x = v.x\n this.y = v.y\n this.z = v.z\n\n return this\n }\n\n /**\n * Add vector to atom position\n * @param {Vector3} v - input vector\n * @return {AtomProxy} this object\n */\n positionAdd (v: Vector3|AtomProxy) {\n this.x += v.x\n this.y += v.y\n this.z += v.z\n\n return this\n }\n\n /**\n * Subtract vector from atom position\n * @param {Vector3} v - input vector\n * @return {AtomProxy} this object\n */\n positionSub (v: Vector3|AtomProxy) {\n this.x -= v.x\n this.y -= v.y\n this.z -= v.z\n\n return this\n }\n\n /**\n * Get intra group/residue bonds\n * @param {Boolean} firstOnly - immediately return the first connected atomIndex\n * @return {Integer[]|Integer|undefined} connected atomIndices\n */\n getResidueBonds (firstOnly = false) {\n const residueAtomOffset = this.residueAtomOffset\n const relativeIndex = this.index - this.residueAtomOffset\n const bonds = this.residueType.getBonds()! // TODO\n const atomIndices1 = bonds.atomIndices1\n const atomIndices2 = bonds.atomIndices2\n let idx1, idx2, connectedAtomIndex\n let connectedAtomIndices: number[]|undefined\n\n if (!firstOnly) connectedAtomIndices = []\n\n idx1 = atomIndices1.indexOf(relativeIndex)\n while (idx1 !== -1) {\n connectedAtomIndex = atomIndices2[ idx1 ] + residueAtomOffset\n if (connectedAtomIndices) {\n connectedAtomIndices.push(connectedAtomIndex)\n idx1 = atomIndices1.indexOf(relativeIndex, idx1 + 1)\n } else {\n return connectedAtomIndex\n }\n }\n\n idx2 = atomIndices2.indexOf(relativeIndex)\n while (idx2 !== -1) {\n connectedAtomIndex = atomIndices1[ idx2 ] + residueAtomOffset\n if (connectedAtomIndices) {\n connectedAtomIndices.push(connectedAtomIndex)\n idx2 = atomIndices2.indexOf(relativeIndex, idx2 + 1)\n } else {\n return connectedAtomIndex\n }\n }\n\n return connectedAtomIndices\n }\n\n //\n\n qualifiedName (noResname = false) {\n var name = ''\n if (this.resname && !noResname) name += '[' + this.resname + ']'\n if (this.resno !== undefined) name += this.resno\n if (this.inscode) name += '^' + this.inscode\n if (this.chainname) name += ':' + this.chainname\n if (this.atomname) name += '.' + this.atomname\n if (this.altloc) name += '%' + this.altloc\n if (this.structure.modelStore.count > 1) name += '/' + this.modelIndex\n return name\n }\n\n /**\n * Clone object\n * @return {AtomProxy} cloned atom\n */\n clone () {\n return new AtomProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n index: this.index,\n residueIndex: this.residueIndex,\n\n resname: this.resname,\n x: this.x,\n y: this.y,\n z: this.z,\n element: this.element,\n chainname: this.chainname,\n resno: this.resno,\n serial: this.serial,\n vdw: this.vdw,\n covalent: this.covalent,\n hetero: this.hetero,\n bfactor: this.bfactor,\n altloc: this.altloc,\n atomname: this.atomname,\n modelIndex: this.modelIndex\n }\n }\n}\n\nexport default AtomProxy\n","/**\n * @file Kdtree\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { Debug, Log } from '../globals'\nimport _Kdtree from '../utils/kdtree'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\n\nfunction euclideanDistSq(a: number[], b: number[]) {\n const dx = a[0] - b[0]\n const dy = a[1] - b[1]\n const dz = a[2] - b[2]\n return dx * dx + dy * dy + dz * dz\n}\n\nfunction euclideanDist(a: number[], b: number[]) {\n return Math.sqrt(euclideanDistSq(a, b))\n}\n\nconst pointArray = new Float32Array(3)\n\nclass Kdtree {\n points: Float32Array\n atomIndices: Uint32Array\n kdtree: _Kdtree\n\n constructor(structure: Structure|ResidueProxy, useSquaredDist = false) {\n if (Debug) Log.time('Kdtree build')\n\n const metric = useSquaredDist ? euclideanDistSq : euclideanDist\n\n const points = new Float32Array(structure.atomCount * 3)\n const atomIndices = new Uint32Array(structure.atomCount)\n let i = 0\n\n structure.eachAtom(function (ap) {\n points[ i + 0 ] = ap.x\n points[ i + 1 ] = ap.y\n points[ i + 2 ] = ap.z\n atomIndices[ i / 3 ] = ap.index\n i += 3\n })\n\n this.atomIndices = atomIndices\n this.points = points\n this.kdtree = new _Kdtree(points, metric)\n\n if (Debug) Log.timeEnd('Kdtree build')\n\n // console.log(\"this.kdtree.verify()\", this.kdtree.verify())\n }\n\n nearest (point: number[]|Vector3, maxNodes: number, maxDistance: number) {\n // Log.time( \"Kdtree nearest\" );\n\n if (point instanceof Vector3) {\n point.toArray(pointArray as any)\n } else if (point instanceof AtomProxy) {\n point.positionToArray(pointArray)\n }\n\n const nodeList = this.kdtree.nearest(pointArray, maxNodes, maxDistance)\n\n const indices = this.kdtree.indices\n const nodes = this.kdtree.nodes\n const atomIndices = this.atomIndices\n const resultList = []\n\n for (let i = 0, n = nodeList.length; i < n; ++i) {\n const d = nodeList[ i ]\n const nodeIndex = d[ 0 ]\n const dist = d[ 1 ]\n\n resultList.push({\n index: atomIndices[ indices[ nodes[ nodeIndex ] ] ],\n distance: dist\n })\n }\n\n // Log.timeEnd( \"Kdtree nearest\" );\n\n return resultList\n }\n}\n\nexport default Kdtree\n","/**\n * @file Symmetry Constants\n * @author Alexander Rose \n * @private\n */\n\nexport const SymOpCode: { [k: string]: string } = {\n ' ': 'X',\n '!': 'Y',\n '#': 'Z',\n '$': '-X',\n '%': '-Y',\n '&': '-Z',\n \"'\": 'Y+1/2',\n '(': '1/2+X',\n ')': '1/2+Y',\n '*': '1/2-X',\n '+': '1/2+Z',\n ',': '1/2-Y',\n '-': '1/2-Z',\n '.': 'X+1/2',\n '/': 'Z+1/2',\n '0': '-X+1/2',\n '1': '-Y+1/2',\n '2': '-Z+1/2',\n '3': '1/4+X',\n '4': '1/4-Y',\n '5': '1/4+Z',\n '6': '1/4-X',\n '7': '1/4+Y',\n '8': '3/4-Y',\n '9': '3/4+Z',\n ':': '3/4+Y',\n ';': '3/4+X',\n '<': '3/4-X',\n '=': '1/4-Z',\n '>': '3/4-Z',\n '?': 'X-Y',\n '@': 'Y-X',\n 'A': 'Z+1/3',\n 'B': 'Z+2/3',\n 'C': 'X+2/3',\n 'D': 'Y+1/3',\n 'E': '-Y+2/3',\n 'F': 'X-Y+1/3',\n 'G': 'Y-X+2/3',\n 'H': '-X+1/3',\n 'I': 'X+1/3',\n 'J': 'Y+2/3',\n 'K': '-Y+1/3',\n 'L': 'X-Y+2/3',\n 'M': 'Y-X+1/3',\n 'N': '-X+2/3',\n 'O': '2/3+X',\n 'P': '1/3+Y',\n 'Q': '1/3+Z',\n 'R': '2/3-Y',\n 'S': '1/3+X-Y',\n 'T': '2/3+Y-X',\n 'U': '1/3-X',\n 'V': '2/3-X',\n 'W': '1/3-Y',\n 'X': '1/3-Z',\n 'Y': '2/3+Y',\n 'Z': '1/3+Y-X',\n '[': '2/3+X-Y',\n ']': '1/3+X',\n '^': '2/3+Z',\n '_': '2/3-Z',\n '`': '5/6+Z',\n 'a': '1/6+Z',\n 'b': '5/6-Z',\n 'c': '1/6-Z',\n 'd': 'Z+5/6',\n 'e': 'Z+1/6',\n 'f': 'Z+1/4',\n 'g': '+Y'\n}\n\n// encoded, originally from CCP4 symop.lib\nexport const EncodedSymOp: { [k: string]: string } = {\n 'P 1': ' !#',\n 'P -1': ' !#$%&',\n 'P 1 2 1': ' !#$!&',\n 'P 1 21 1': \" !#$'&\",\n 'C 1 2 1': ' !#$!&()#*)&',\n 'P 1 m 1': ' !# %#',\n 'P 1 c 1': ' !# %+',\n 'C 1 m 1': ' !# %#()#(,#',\n 'C 1 c 1': ' !# %+()#(,+',\n 'P 1 2/m 1': ' !# %#$!&$%&',\n 'P 1 21/m 1': ' !#$)&$%& ,#',\n 'C 1 2/m 1': ' !# %#$!&$%&()#(,#*)&*,&',\n 'P 1 2/c 1': ' !#$!-$%& %+',\n 'P 1 21/c 1': ' !#$%&$)- ,+',\n 'C 1 2/c 1': ' !#$!-$%& %+()#*)-*,&(,+',\n 'P 2 2 2': ' !#$%#$!& %&',\n 'P 2 2 21': ' !#$%+$!- %&',\n 'P 21 21 2': ' !#$%#*)&(,&',\n 'P 21 21 21': ' !#*%+$)-(,&',\n 'C 2 2 21': ' !#$%+$!- %&()#*,+*)-(,&',\n 'C 2 2 2': ' !#$%#$!& %&()#*,#*)&(,&',\n 'F 2 2 2': ' !#$%#$!& %& )+$,+$)- ,-(!+*%+*!-(%-()#*,#*)&(,&',\n 'I 2 2 2': \" !#$%# %&$!&.'/01/.120'2\",\n 'I 21 21 21': ' !#*%+$)-(,&()+$,#*!& %-',\n 'P m m 2': ' !#$%# %#$!#',\n 'P m c 21': ' !#$%+ %+$!#',\n 'P c c 2': ' !#$%# %+$!+',\n 'P m a 2': ' !#$%#(%#*!#',\n 'P c a 21': ' !#$%+(%#*!+',\n 'P n c 2': ' !#$%# ,+$)+',\n 'P m n 21': ' !#*%+(%+$!#',\n 'P b a 2': ' !#$%#(,#*)#',\n 'P n a 21': ' !#$%+(,#*)+',\n 'P n n 2': ' !#$%#(,+*)+',\n 'C m m 2': ' !#$%# %#$!#()#*,#(,#*)#',\n 'C m c 21': ' !#$%+ %+$!#()#*,+(,+*)#',\n 'C c c 2': ' !#$%# %+$!+()#*,#(,+*)+',\n 'A m m 2': ' !#$%# %#$!# )+$,+ ,+$)+',\n 'A b m 2': ' !#$%# ,#$)# )+$,+ %+$!+',\n 'A m a 2': ' !#$%#(%#*!# )+$,+(,+*)+',\n 'A b a 2': ' !#$%#(,#*)# )+$,+(%+*!+',\n 'F m m 2': ' !#$%# %#$!# )+$,+ ,+$)+(!+*%+(%+*!+()#*,#(,#*)#',\n 'F d d 2': ' !#$%#345675 )+$,+3896:9(!+*%+;49<79()#*,#;85<:5',\n 'I m m 2': ' !#$%# %#$!#()+*,+(,+*)+',\n 'I b a 2': ' !#$%#(,#*)#()+*,+ %+$!+',\n 'I m a 2': ' !#$%#(%#*!#()+*,+ ,+$)+',\n 'P 2/m 2/m 2/m': ' !#$%#$!& %&$%& !& %#$!#',\n 'P 2/n 2/n 2/n': ' !#$%#$!& %&*,-()-(,+*)+',\n 'P 2/c 2/c 2/m': ' !#$%#$!- %-$%& !& %+$!+',\n 'P 2/b 2/a 2/n': ' !#$%#$!& %&*,&()&(,#*)#',\n 'P 21/m 2/m 2/a': ' !#*%#$!&(%&$%&(!& %#*!#',\n 'P 2/n 21/n 2/a': ' !#*%#*)- ,-$%&(!&(,+$)+',\n 'P 2/m 2/n 21/a': ' !#*%+*!- %&$%&(!-(%+$!#',\n 'P 21/c 2/c 2/a': ' !#*%#$!-(%-$%&(!& %+*!+',\n 'P 21/b 21/a 2/m': ' !#$%#*)&(,&$%& !&(,#*)#',\n 'P 21/c 21/c 2/n': ' !#*,#$)-(%-$%&()& ,+*!+',\n 'P 2/b 21/c 21/m': ' !#$%+$)- ,&$%& !- ,+$)#',\n 'P 21/n 21/n 2/m': ' !#$%#*)-(,-$%& !&(,+*)+',\n 'P 21/m 21/m 2/n': \" !#$%#*'&.,&*,&.'& %#$!#\",\n 'P 21/b 2/c 21/n': ' !#*,+$!-(,&$%&()- %+*)#',\n 'P 21/b 21/c 21/a': ' !#*%+$)-(,&$%&(!- ,+*)#',\n 'P 21/n 21/m 21/a': \" !#0%/$'&.12$%&.!2 1#0'/\",\n 'C 2/m 2/c 21/m': ' !#$%+$!- %&$%& !- %+$!#()#*,+*)-(,&*,&()-(,+*)#',\n 'C 2/m 2/c 21/a': ' !#$,+$)- %&$%& )- ,+$!#()#*%+*!-(,&*,&(!-(%+*)#',\n 'C 2/m 2/m 2/m': ' !#$%#$!& %&$%& !& %#$!#()#*,#*)&(,&*,&()&(,#*)#',\n 'C 2/c 2/c 2/m': ' !#$%#$!- %-$%& !& %+$!+()#*,#*)-(,-*,&()&(,+*)+',\n 'C 2/m 2/m 2/a': ' !#$,#$)& %&$%& )& ,#$!#()#*%#*!&(,&*,&(!&(%#*)#',\n 'C 2/c 2/c 2/a': ' !#*,#$!&(,&$,-(!- ,+*!+()#$%#*)& %&*%- )-(%+$)+',\n 'F 2/m 2/m 2/m': ' !#$%#$!& %&$%& !& %#$!# )+$,+$)- ,-$,- )- ,+$)+(!+*%+*!-(%-*%-(!-(%+*!+()#*,#*)&(,&*,&()&(,#*)#',\n 'F 2/d 2/d 2/d': ' !#$%#$!& %&64=37=345675 )+$,+$)- ,-68>3:>3896:9(!+*%+*!-(%-<4>;7>;49<79()#*,#*)&(,&<8=;:=;85<:5',\n 'I 2/m 2/m 2/m': ' !#$%#$!& %&$%& !& %#$!#()+*,+*)-(,-*,-()-(,+*)+',\n 'I 2/b 2/a 2/m': ' !#$%#*)&(,&$%& !&(,#*)#()+*,+$!- %-*,-()- %+$!+',\n 'I 21/b 21/c 21/a': ' !#*%+$)-(,&$%&(!- ,+*)#()+$,#*!& %-*,- )&(%#$!+',\n 'I 21/m 21/m 21/a': ' !#$,#$)& %&$%& )& ,#$!#()+*%+*!-(,-*,-(!-(%+*)+',\n 'P 4': ' !#$%#% #!$#',\n 'P 41': ' !#$%+% 5!$9',\n 'P 42': ' !#$%#% +!$+',\n 'P 43': ' !#$%+% 9!$5',\n 'I 4': ' !#$%#% #!$#()+*,+,(+)*+',\n 'I 41': ' !#*,+%(5)$9()+$%#, 9!*5',\n 'P -4': ' !#$%#!$&% &',\n 'I -4': ' !#$%#!$&% &()+*,+)*-,(-',\n 'P 4/m': ' !#$%#% #!$#$%& !&!$&% &',\n 'P 42/m': ' !#$%#% +!$+$%& !&!$-% -',\n 'P 4/n': ' !#$%#,(#)*#*,&()&!$&% &',\n 'P 42/n': ' !#$%#,(+)*+*,-()-!$&% &',\n 'I 4/m': ' !#$%#% #!$#$%& !&!$&% &()+*,+,(+)*+*,-()-)*-,(-',\n 'I 41/a': ' !#*,+%(5)$9$,=(!>!$&,(-()+$%#, 9!*5*%> )=)*-% &',\n 'P 4 2 2': ' !#$%#% #!$#$!& %&! &%$&',\n 'P 4 21 2': ' !#$%#,(#)*#*)&(,&! &%$&',\n 'P 41 2 2': ' !#$%+% 5!$9$!& %-! >%$=',\n 'P 41 21 2': ' !#$%+,(5)*9*)=(,>! &%$-',\n 'P 42 2 2': ' !#$%#% +!$+$!& %&! -%$-',\n 'P 42 21 2': ' !#$%#,(+)*+*)-(,-! &%$&',\n 'P 43 2 2': ' !#$%+% 9!$5$!& %-! =%$>',\n 'P 43 21 2': ' !#$%+,(9)*5*)>(,=! &%$-',\n 'I 4 2 2': ' !#$%#% #!$#$!& %&! &%$&()+*,+,(+)*+*)-(,-)(-,*-',\n 'I 41 2 2': ' !#*,+%(5)$9*!> ,=)(-%$&()+$%#, 9!*5$)=(%>! &,*-',\n 'P 4 m m': ' !#$%#% #!$# %#$!#%$#! #',\n 'P 4 b m': ' !#$%#% #!$#(,#*)#,*#)(#',\n 'P 42 c m': ' !#$%#% +!$+ %+$!+%$#! #',\n 'P 42 n m': ' !#$%#,(+)*+(,+*)+%$#! #',\n 'P 4 c c': ' !#$%#% #!$# %+$!+%$+! +',\n 'P 4 n c': ' !#$%#% #!$#(,+*)+,*+)(+',\n 'P 42 m c': ' !#$%#% +!$+ %#$!#%$+! +',\n 'P 42 b c': ' !#$%#% +!$+(,#*)#,*+)(+',\n 'I 4 m m': ' !#$%#% #!$# %#$!#%$#! #()+*,+,(+)*+(,+*)+,*+)(+',\n 'I 4 c m': ' !#$%#% #!$# %+$!+%$+! +()+*,+,(+)*+(,#*)#,*#)(#',\n 'I 41 m d': ' !#*,+%(5)$9 %#*)+%*5) 9()+$%#, 9!*5(,+$!#,$9!(5',\n 'I 41 c d': ' !#*,+%(5)$9 %+*)#%*9) 5()+$%#, 9!*5(,#$!+,$5!(9',\n 'P -4 2 m': ' !#$%#% &!$&$!& %&%$#! #',\n 'P -4 2 c': ' !#$%#% &!$&$!- %-%$+! +',\n 'P -4 21 m': ' !#$%#% &!$&*)&(,&,*#)(#',\n 'P -4 21 c': ' !#$%#% &!$&*)-(,-,*+)(+',\n 'P -4 m 2': ' !#$%#!$&% & %#$!#! &%$&',\n 'P -4 c 2': ' !#$%#% &!$& %+$!+! -%$-',\n 'P -4 b 2': ' !#$%#% &!$&(,#*)#)(&,*&',\n 'P -4 n 2': ' !#$%#% &!$&(,+*)+)(-,*-',\n 'I -4 m 2': ' !#$%#% &!$& %#$!#! &%$&()+*,+,(-)*-(,+*)+)(-,*-',\n 'I -4 c 2': ' !#$%#% &!$& %+$!+! -%$-()+*,+,(-)*-(,#*)#)(&,*&',\n 'I -4 2 m': ' !#$%#% &!$&$!& %&%$#! #()+*,+,(-)*-*)-(,-,*+)(+',\n 'I -4 2 d': ' !#$%#% &!$&*!>(%>,$9) 9()+*,+,(-)*-$)= ,=%*5!(5',\n 'P 4/m 2/m 2/m': ' !#$%#% #!$#$!& %&! &%$&$%& !&!$&% & %#$!#%$#! #',\n 'P 4/m 2/c 2/c': ' !#$%#% #!$#$!- %-! -%$-$%& !&!$&% & %+$!+%$+! +',\n 'P 4/n 2/b 2/m': ' !#$%#% #!$#$!& %&! &%$&*,&()&)*&,(&(,#*)#,*#)(#',\n 'P 4/n 2/n 2/c': ' !#$%#% #!$#$!& %&! &%$&*,-()-)*-,(-(,+*)+,*+)(+',\n 'P 4/m 21/b 2/m': ' !#$%#% #!$#*)&(,&)(&,*&$%& !&!$&% &(,#*)#,*#)(#',\n 'P 4/m 21/n 2/c': ' !#$%#% #!$#*)-(,-)(-,*-$%& !&!$&% &(,+*)+,*+)(+',\n 'P 4/n 21/m 2/m': ' !#$%#,(#)*#*)&(,&! &%$&*,&()&!$&% & %#$!#,*#)(#',\n 'P 4/n 2/c 2/c': ' !#$%#,(#)*#*)-(,-! -%$-*,&()&!$&% & %+$!+,*+)(+',\n 'P 42/m 2/m 2/c': ' !#$%#% +!$+$!& %&! -%$-$%& !&!$-% - %#$!#%$+! +',\n 'P 42/m 2/c 2/m': ' !#$%#% +!$+$!- %-! &%$&$%& !&!$-% - %+$!+%$#! #',\n 'P 42/n 2/b 2/c': ' !#$%#,(+)*+$!- %-)(&,*&*,-()-!$&% &(,#*)#%$+! +',\n 'P 42/n 2/n 2/m': ' !#$%#,(+)*+$!& %&)(-,*-*,-()-!$&% &(,+*)+%$#! #',\n 'P 42/m 21/b 2/c': ' !#$%#% +!$+*)&(,&)(-,*-$%& !&!$-% -(,#*)#,*+)(+',\n 'P 42/m 21/n 2/m': \" !#$%#,./'*/*'-.,-! &%$&$%& !&'*-,.-.,/*'/%$#! #\",\n 'P 42/n 21/m 2/c': ' !#$%#,(+)*+*)-(,-! &%$&*,-()-!$&% & %#$!#,*+)(+',\n 'P 42/n 21/c 2/m': ' !#$%#,(+)*+*)&(,&! -%$-*,-()-!$&% & %+$!+,*#)(#',\n 'I 4/m 2/m 2/m': ' !#$%#% #!$#$!& %&! &%$&$%& !&!$&% & %#$!#%$#! #()+*,+,(+)*+*)-(,-)(-,*-*,-()-)*-,(-(,+*)+,*+)(+',\n 'I 4/m 2/c 2/m': ' !#$%#% #!$#$!- %-! -%$-$%& !&!$&% & %+$!+%$+! +()+*,+,(+)*+*)&(,&)(&,*&*,-()-)*-,(-(,#*)#,*#)(#',\n 'I 41/a 2/m 2/d': ' !#*,+%(5)$9*!> ,=)(-%$&$,=(!>!$&,(-(,+$!#,$9!(5()+$%#, 9!*5$)=(%>! &,*-*%> )=)*-% & %#*)+%*5) 9',\n 'I 41/a 2/c 2/d': ' !#*,+%(5)$9*!= ,>)(&%$-$,=(!>!$&,(-(,#$!+,$5!(9()+$%#, 9!*5$)>(%=! -,*&*%> )=)*-% & %+*)#%*9) 5',\n 'P 3': ' !#%?#@$#',\n 'P 31': ' !#%?A@$B',\n 'P 32': ' !#%?B@$A',\n 'H 3': ' !#%?#@$#CDAEFAGHAIJBKLBMNB',\n 'R 3': ' !## !!# ',\n 'P -3': ' !#%?#@$#$%&!@&? &',\n 'H -3': ' !#%?#@$#$%&!@&? &OPQRSQTUQVWXYZX[]X]Y^W[^ZV^UR_PT_SO_',\n 'R -3': ' !## !!# $%&&$%%&$',\n 'P 3 1 2': ' !#%?#@$#%$&@!& ?&',\n 'P 3 2 1': ' !#%?#@$#! &?%&$@&',\n 'P 31 1 2': ' !#%?Q@$^%$_@!X ?&',\n 'P 31 2 1': ' !#%?A@$B! &?%_$@X',\n 'P 32 1 2': ' !#%?^@$Q%$X@!_ ?&',\n 'P 32 2 1': ' !#%?B@$A! &?%X$@_',\n 'H 3 2': ' !#%?#@$#! &?%&$@&OPQRSQTUQY]X[WXVZX]Y^W[^ZV^PO_SR_UT_',\n 'R 3 2': ' !## !!# %$&$&%&%$',\n 'P 3 m 1': ' !#%?#@$#%$#@!# ?#',\n 'P 3 1 m': ' !#%?#@$#! #?%#$@#',\n 'P 3 c 1': ' !#%?#@$#%$+@!+ ?+',\n 'P 3 1 c': ' !#%?#@$#! +?%+$@+',\n 'H 3 m': ' !#%?#@$#%$#@!# ?#OPQRSQTUQRUQTPQOSQ]Y^W[^ZV^WV^ZY^][^',\n 'R 3 m': ' !## !!# ! # #!#! ',\n 'H 3 c': ' !#%?#@$#%$+@!+ ?+OPQRSQTUQRU`TP`OS`]Y^W[^ZV^WVaZYa][a',\n 'R 3 c': \" !## !!# '././'/'.\",\n 'P -3 1 2/m': ' !#%?#@$#%$&@!& ?&$%&!@&? &! #?%#$@#',\n 'P -3 1 2/c': ' !#%?#@$#%$-@!- ?-$%&!@&? &! +?%+$@+',\n 'P -3 2/m 1': ' !#%?#@$#! &?%&$@&$%&!@&? &%$#@!# ?#',\n 'P -3 2/c 1': ' !#%?#@$#! -?%-$@-$%&!@&? &%$+@!+ ?+',\n 'H -3 2/m': ' !#%?#@$#! &?%&$@&$%&!@&? &%$#@!# ?#OPQRSQTUQY]X[WXVZXVWXYZX[]XRUQTPQOSQ]Y^W[^ZV^PO_SR_UT_UR_PT_SO_WV^ZY^][^',\n 'R -3 2/m': ' !## !!# %$&$&%&%$$%&&$%%&$! # #!#! ',\n 'H -3 2/c': ' !#%?#@$#! -?%-$@-$%&!@&? &%$+@!+ ?+OPQRSQTUQY]b[WbVZbVWXYZX[]XRU`TP`OS`]Y^W[^ZV^POcSRcUTcUR_PT_SO_WVaZYa][a',\n 'R -3 2/c': \" !## !!# 102021210$%&&$%%&$'././'/'.\",\n 'P 6': ' !#%?#@$#$%#!@#? #',\n 'P 61': ' !#%?A@$B$%/!@d? e',\n 'P 65': ' !#%?B@$A$%/!@e? d',\n 'P 62': ' !#%?^@$Q$%#!@^? Q',\n 'P 64': ' !#%?Q@$^$%#!@Q? ^',\n 'P 63': ' !#%?#@$#$%+!@+? +',\n 'P -6': ' !#%?#@$# !&%?&@$&',\n 'P 6/m': ' !#%?#@$#$%#!@#? #$%&!@&? & !&%?&@$&',\n 'P 63/m': ' !#%?#@$#$%+!@+? +$%&!@&? & !-%?-@$-',\n 'P 6 2 2': ' !#%?#@$#$%#!@#? #! &?%&$@&%$&@!& ?&',\n 'P 61 2 2': ' !#%?Q@$^$%+!@`? a! X?%&$@_%$b@!- ?c',\n 'P 65 2 2': ' !#%?^@$Q$%+!@a? `! _?%&$@X%$c@!- ?b',\n 'P 62 2 2': ' !#%?^@$Q$%#!@^? Q! _?%&$@X%$_@!& ?X',\n 'P 64 2 2': ' !#%?Q@$^$%#!@Q? ^! X?%&$@_%$X@!& ?_',\n 'P 63 2 2': ' !#%?#@$#$%+!@+? +! &?%&$@&%$-@!- ?-',\n 'P 6 m m': ' !#%?#@$#$%#!@#? #%$#@!# ?#! #?%#$@#',\n 'P 6 c c': ' !#%?#@$#$%#!@#? #%$+@!+ ?+! +?%+$@+',\n 'P 63 c m': ' !#%?#@$#$%+!@+? +%$+@!+ ?+! #?%#$@#',\n 'P 63 m c': ' !#%?#@$#$%+!@+? +%$#@!# ?#! +?%+$@+',\n 'P -6 m 2': ' !#%?#@$# !&%?&@$&%$#@!# ?#%$&@!& ?&',\n 'P -6 c 2': ' !#%?#@$# !-%?-@$-%$+@!+ ?+%$&@!& ?&',\n 'P -6 2 m': ' !#%?#@$# !&%?&@$&! &?%&$@&! #?%#$@#',\n 'P -6 2 c': ' !#%?#@$# !-%?-@$-! &?%&$@&! +?%+$@+',\n 'P 6/m 2/m 2/m': ' !#%?#@$#$%#!@#? #! &?%&$@&%$&@!& ?&$%&!@&? & !&@$&%?&%$#@!# ?#! #?%#$@#',\n 'P 6/m 2/c 2/c': ' !#%?#@$#$%#!@#? #! -?%-$@-%$-@!- ?-$%&!@&? & !&@$&%?&%$+@!+ ?+! +?%+$@+',\n 'P 63/m 2/c 2/m': ' !#%?#@$#$%+!@+? +! -?%-$@-%$&@!& ?&$%&!@&? & !-@$-%?-%$+@!+ ?+! #?%#$@#',\n 'P 63/m 2/m 2/c': ' !#%?#@$#$%+!@+? +! &?%&$@&%$-@!- ?-$%&!@&? & !-@$-%?-%$#@!# ?#! +?%+$@+',\n 'P 2 3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ',\n 'F 2 3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ',\n 'I 2 3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-(',\n 'P 21 3': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(',\n 'I 21 3': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- ',\n 'P 2/m -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$',\n 'P 2/n -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& *,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*',\n 'F 2/m -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$ )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-($,- )- ,+$)+&*,&()#(,#*)%-*!-(%+(!+*(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(*%-(!-(%+*!+-$,- )+ ,+$),&*)&(,#()#*()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- *,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$',\n 'F 2/d -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& 64=37=345675=64=375345674=67=3453756 )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(68>3:>3896:9=<8=;:5;85<:4><7>;49;79<(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(<4>;7>;49<79>68>3:93896:8=<:=;85;:5<()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- <8=;:=;8f<:f><4>;79;49<78>6:>3893:96',\n 'I 2/m -3': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& $%& !& %#$!#&$%& !# %#$!%&$!& %# !#$()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-(*,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*',\n 'P 21/a -3': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&($%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*',\n 'I 21/a -3': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&($%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*()+$,#*g& %-+()#$,&*!- %)+(,#$!&*%- *,- )&(%#$!+-*,& )#(%+$!,-*)& %#(!+$',\n 'P 4 3 2': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$',\n 'P 42 3 2': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*',\n 'F 4 3 2': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$ )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(-%*-!*+%(+ +,$+)$-, -)#)*#,(&)(&,*(!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() -,$-)$+, +(#,*#)*&,(&)+!*+%(-!(-%*()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(&,*&)*#,(#(+%*+!*-%(-!+)$+, -) -,$',\n 'F 41 3 2': ' !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=46 )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<(!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>86',\n 'I 4 3 2': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*',\n 'P 43 3 2': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(7;>46=:<5839398<5:6=4;>75:<983>7;=46',\n 'P 41 3 2': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<',\n 'I 41 3 2': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- 7;>46=:<5839398<5:6=4;>75:<983>7;=46',\n 'P -4 3 m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% ',\n 'F -4 3 m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-(!(+%*+!*-%(- +)$+,$-) -,#)(#,*&)*&,((!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&() +,$+)$-, -(#)*#,*&)(&,+!(+%*-!*-%(()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- )(#,*#)*&,(&(+!*+%*-!(-%+) +,$-)$-, ',\n 'I -4 3 m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! #%$#!$&% & #!$#%$&! &%#! #%$&!$&% ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,(',\n 'P -4 3 n': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,(',\n 'F -4 3 c': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(+,*+)*-,(-(+)*+,*-)(-,+)(+,*-)*-,( )+$,+$)- ,-#()#*,&*)&(,!+(%+*!-*%-() #,$#)$&, &(#!*#%*&!(&%+! +%$-!$-% (!+*%+*!-(%-+ )+$,-$)- ,)#(,#*)&*,&(!(#%*#!*&%(& +!$+%$-! -%#) #,$&)$&, ()#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ! +%$+!$-% - #)$#,$&) &,#!(#%*&!*&%(',\n 'I -4 3 d': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(7354<9:6>8;=357<946>:;=857394<>:6=8;()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- :;98657<=43>;9:658<=73>49:;586=7<>43',\n 'P 4/m -3 2/m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ',\n 'P 4/n -3 2/n': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$*,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(',\n 'P 42/m -3 2/n': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,*$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(',\n 'P 42/n -3 2/m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& )(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,**,-()-(,+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#*,#*)&(,&+(!+*%-*!-(%)+ ,+$)-$,- ! -%$-!$+% + #,$#)$&, &)#!*#%(&!(&%**,&()&(,#*)#-*%-(!+(%+*!,-$)- ,+ )+$%$+! +% -!$-$&) &, #)$#,&%(&!*#%*#!(',\n 'F 41/d -3 2/m': ' !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=4664=3:>;85<79=64>3:5;89<74=6:>385;79<,$+! #%(-)*&*&)(-% #!$+,-%(&)*+,$#! )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<68>37=;49<:5=<8>;753496:4><:=;893756,*#!(+% &)$-*-!(&, +)$#%-, &!$+%*#)((!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<<4>;:=389675>68=379;45<:8=<7>;453:96%$#) +,(&!*-$&! -,(#)*+%&% -)$#,*+!(()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>86<8=;7>3456:9><4=;:9385678>67=349;:5<%*+)(#, -!$&$-) &%(+!*#,&,(-!*#%$+) ',\n 'F 41/d -3 2/c': ' !#$,+*)&(%-# !+$,&*)-(%!# ,+$)&*%-(:3>46=7<98;5;58<976=43>:97<58;>:3=46<8>;7=3496:5><8=;793456:8><7=;493:56%*#)(+, &!$-$-! &,(+)*#%&, -!$#%*+)( )+$%#*!-(,&#()+*%&$!- ,!+(,#*)-$%& :;=4<>765839;94<5:6>83=79:6543>7;=8<<4=;:>385679>64=3:9;85<78=67>345;:9<%$+) #,(-!*&$&) -%(#!*+,&%(-)*#,$+! (!+*,#$)- %&+ )#$%-*!&(,)#(%+*!&$,- 73=86>:<54;935469:<=8;>7576983=:;>4<68=37>;45<:9=<4>;:5389674>6:=389;75<,*+!(#% -)$&*-)(&% +!$#,-,(&!*+%$#) ()#*%+$!& ,-+(!#*,-$)& %)+ %#$!-*,&(7;>8<=:69435398657<>4;=:5:<94;=73>8664>3:=;89<75=68>375;49<:4=<:>;853796,$#! +%(&)*-*&!(-, #)$+%-% &)$+,*#!(',\n 'I 4/m -3 2/m': ' !#$%#$!& %&# !#$%&$!& %!# %#$!&$%& ! &%$&!$#% # #%$#!$&% &!#!$#% &! &%$$%& !& %#$!#&$%& !# %#$!%&$!& %# !#$%$#! #% &!$&$&! &% #!$#%&% &!$#%$#! ()+*,+*)-(,-+()+*,-*)-(,)+(,+*)-*,-()(-,*-)*+,(+(+,*+)*-,(-)+)*+,(-)(-,**,-()-(,+*)+-*,-()+(,+*),-*)-(,+()+*,*+)(+,(-)*-*-)(-,(+)*+,-,(-)*+,*+)(',\n 'I 41/a -3 2/d': ' !#*%+$)-(,&# !+*%-$)&(,!# %+*)-$,&(:3=8<>7694;5;54697<>83=:97654;=:3>8<$%&(!- ,+*)#&$%-(!+ ,#*)%&$!-(,+ )#*4<97358;=:6>6>:;=8357<94=8;>:694<573()+$,#*!& %-+()#$,&*!- %)+(,#$!&*%- 7;>46=:<5839398<5:6=4;>75:<983>7;=46*,- )&(%#$!+-*,& )#(%+$!,-*)& %#(!+$865:;943>7<=<=73>4;9:658>43=7<5869:;',\n 'P 1 1 2': ' !#$%#',\n 'P 1 1 21': ' !#$%+',\n 'B 1 1 2': ' !#$%#(g+*%+',\n 'A 1 2 1': ' !#$!& )+$)-',\n 'C 1 21 1': ' !#$)&()#*!&',\n 'I 1 2 1': \" !#$!&.'/0'2\",\n 'I 1 21 1': \" !#$)&.'/0!-\",\n 'P 1 1 m': ' !# !&',\n 'P 1 1 b': ' !# )&',\n 'B 1 1 m': ' !# !&(!+(!-',\n 'B 1 1 b': ' !# )&(!+()-',\n 'P 1 1 2/m': ' !# !&$%#$%&',\n 'P 1 1 21/m': ' !#$%+$%& !-',\n 'B 1 1 2/m': ' !# !&$%#$%&(!+(!-*%+*%-',\n 'P 1 1 2/b': ' !#$,#$%& )&',\n 'P 1 1 21/b': ' !#$%&$,+ )-',\n 'B 1 1 2/b': ' !#$,#$%& )&(!+*,+*%-()-',\n 'P 21 2 2': ' !#$!&(%&*%#',\n 'P 2 21 2': ' !# ,&$)&$%#',\n 'P 21 21 2 (a)': \" !#*,#.%&$'&\",\n 'P 21 2 21': ' !#$!&(%-*%+',\n 'P 2 21 21': ' !# %&$)-$,+',\n 'C 2 2 21a)': ' !#*%+(,&$)-()#$,+ %&*!-',\n 'C 2 2 2a': \" !#*,#.%&$'&()#$%# ,&*!&\",\n 'F 2 2 2a': \" !#*,#.%&$'& '/*%/.12$!2.!/$,/ %20'2.'#$%# 1&0!&\",\n 'I 2 2 2a': \" !#*,#.%&$'&()+$%+*!- ,-\",\n 'P 21/m 21/m 2/n a': \" !#*,#$)&(%&$%&.'& ,#*!#\",\n 'P 42 21 2a': \" !#*,#%.+'$+$'&.%&! -,*-\",\n 'I 2 3a': \" !#*,#.%&$'&!# ,- '&$%/$# !-*!/$%&.%()+$%+ ,-*!-)+(%&(!-*,#*+()&$)#*,- ,\"\n}\n","/**\n * @file Symmetry Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Log } from '../globals'\nimport { EncodedSymOp, SymOpCode } from './symmetry-constants'\n\nconst reInteger = /^[1-9]$/\n\nexport function getSymmetryOperations (spacegroup: string) {\n const encodedSymopList = EncodedSymOp[ spacegroup ]\n const matrixDict: { [k: string]: Matrix4 } = {}\n\n if (encodedSymopList === undefined) {\n console.warn(`spacegroup '${spacegroup}' not found in symop library`)\n return matrixDict\n }\n\n const symopList = []\n for (let i = 0, il = encodedSymopList.length; i < il; i += 3) {\n const symop = []\n for (let j = 0; j < 3; ++j) {\n symop.push(SymOpCode[ encodedSymopList[ i + j ] ])\n }\n symopList.push(symop)\n }\n\n symopList.forEach(function (symop) {\n let row = 0\n const matrix = new Matrix4().set(\n 0, 0, 0, 0,\n 0, 0, 0, 0,\n 0, 0, 0, 0,\n 0, 0, 0, 1\n )\n const me = matrix.elements\n\n matrixDict[ symop.toString() ] = matrix\n\n symop.forEach(function (elm) {\n let negate = false\n let denominator = false\n\n for (let i = 0, n = elm.length; i < n; ++i) {\n const c = elm[ i ]\n\n if (c === '-') {\n negate = true\n } else if (c === '+') {\n negate = false\n } else if (c === '/') {\n denominator = true\n } else if (c === 'X') {\n me[ 0 + row ] = negate ? -1 : 1\n } else if (c === 'Y') {\n me[ 4 + row ] = negate ? -1 : 1\n } else if (c === 'Z') {\n me[ 8 + row ] = negate ? -1 : 1\n } else if (reInteger.test(c)) {\n const integer = parseInt(c)\n if (denominator) {\n me[ 12 + row ] /= integer\n } else {\n me[ 12 + row ] = integer\n }\n } else {\n Log.warn(`getSymmetryOperations: unknown token '${c}'`)\n }\n }\n\n row += 1\n })\n })\n\n return matrixDict\n}\n","/**\n * @file Assembly\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Box3, Vector3 } from 'three'\n\nimport { uniqueArray } from '../utils'\nimport Selection from '../selection/selection'\nimport Structure from '../structure/structure'\nimport StructureView from '../structure/structure-view';\n\nfunction selectionFromChains (chainList: string[]) {\n let sele = ''\n if (chainList.length > 0) {\n sele = ':' + uniqueArray(chainList).join(' OR :')\n }\n return new Selection(sele)\n}\n\n/**\n * Assembly of transformed parts of a {@link Structure}\n */\nclass Assembly {\n partList: AssemblyPart[] = []\n\n /**\n * @param {String} name - assembly name\n */\n constructor (readonly name = '') {}\n\n get type () { return 'Assembly' }\n\n /**\n * Add transformed parts to the assembly\n * @example\n * var m1 = new NGL.Matrix4().set( ... );\n * var m2 = new NGL.Matrix4().set( ... );\n * var assembly = new NGL.Assembly( \"myAssembly\" );\n * // add part that transforms chain 'A' and 'B' using matrices `m1` and `m2`\n * assembly.addPart( [ m1, m2 ], [ \"A\", \"B\" ] )\n *\n * @param {Matrix4[]} matrixList - array of 4x4 transformation matrices\n * @param {String[]} chainList - array of chain names\n * @return {AssemblyPart} the added assembly part\n */\n addPart (matrixList?: Matrix4[], chainList?: string[]) {\n const part = new AssemblyPart(matrixList, chainList)\n this.partList.push(part)\n return part\n }\n\n /**\n * Get the number of atom for a given structure\n * @param {Structure} structure - the given structure\n * @return {Integer} number of atoms in the assembly\n */\n getAtomCount (structure: Structure) {\n return this.partList.reduce(\n (count, part) => count + part.getAtomCount(structure), 0\n )\n }\n\n /**\n * Get the number of residues for a given structure\n * @param {Structure} structure - the given structure\n * @return {Integer} number of residues in the assembly\n */\n getResidueCount (structure: Structure) {\n return this.partList.reduce(\n (count, part) => count + part.getResidueCount(structure), 0\n )\n }\n\n /**\n * Get number of instances the assembly will produce, i.e.\n * the number of transformations performed by the assembly\n * @return {Integer} number of instances\n */\n getInstanceCount () {\n let instanceCount = 0\n\n this.partList.forEach(function (part) {\n instanceCount += part.matrixList.length\n })\n\n return instanceCount\n }\n\n /**\n * Determine if the assembly is the full and untransformed structure\n * @param {Structure} structure - the given structure\n * @return {Boolean} whether the assembly is identical to the structure\n */\n isIdentity (structure: Structure) {\n if (this.partList.length !== 1) return false\n\n const part = this.partList[ 0 ]\n if (part.matrixList.length !== 1) return false\n\n const identityMatrix = new Matrix4()\n if (!identityMatrix.equals(part.matrixList[ 0 ])) return false\n\n let structureChainList: string[] = []\n structure.eachChain(function (cp) {\n structureChainList.push(cp.chainname)\n })\n structureChainList = uniqueArray(structureChainList)\n if (part.chainList.length !== structureChainList.length) return false\n\n return true\n }\n\n getBoundingBox (structure: Structure) {\n const boundingBox = new Box3()\n\n this.partList.forEach(function (part) {\n const partBox = part.getBoundingBox(structure)\n boundingBox.expandByPoint(partBox.min)\n boundingBox.expandByPoint(partBox.max)\n })\n\n return boundingBox\n }\n\n getCenter (structure: Structure) {\n return this.getBoundingBox(structure).getCenter(new Vector3())\n }\n\n getSelection () {\n let chainList: string[] = []\n this.partList.forEach(function (part) {\n chainList = chainList.concat(part.chainList)\n })\n return selectionFromChains(chainList)\n }\n}\n\nexport class AssemblyPart {\n constructor (readonly matrixList: Matrix4[] = [], readonly chainList: string[] = []) {}\n\n get type () { return 'AssemblyPart' }\n\n _getCount (structure: Structure, propertyName: 'atomCount'|'residueCount') {\n let count = 0\n\n structure.eachChain(cp => {\n if (this.chainList.length === 0 || this.chainList.includes(cp.chainname)) {\n count += cp[ propertyName ]\n }\n })\n\n return this.matrixList.length * count\n }\n\n getAtomCount (structure: Structure) {\n return this._getCount(structure, 'atomCount')\n }\n\n getResidueCount (structure: Structure) {\n return this._getCount(structure, 'residueCount')\n }\n\n getBoundingBox (structure: Structure) {\n const partBox = new Box3()\n const instanceBox = new Box3()\n\n const selection = this.getSelection()\n const structureBox = structure.getBoundingBox(selection)\n\n this.matrixList.forEach(function (matrix) {\n instanceBox.copy(structureBox).applyMatrix4(matrix)\n partBox.expandByPoint(instanceBox.min)\n partBox.expandByPoint(instanceBox.max)\n })\n\n return partBox\n }\n\n getSelection () {\n return selectionFromChains(this.chainList)\n }\n\n getView (structure: Structure): Structure | StructureView {\n const selection = this.getSelection()\n if (selection) {\n return structure.getView(selection)\n } else {\n return structure\n }\n }\n\n getInstanceList () {\n const instanceList = []\n for (let j = 0, jl = this.matrixList.length; j < jl; ++j) {\n instanceList.push({\n id: j + 1,\n name: j,\n matrix: this.matrixList[ j ]\n })\n }\n return instanceList\n }\n}\n\nexport default Assembly\n","/**\n * @file Structure Builder\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from './structure'\n\nclass StructureBuilder {\n currentModelindex: number|null = null\n currentChainid: string|null = null\n currentResname: string|null = null\n currentResno: number|null = null\n currentInscode: string|undefined = undefined\n currentHetero: boolean|null = null\n\n previousResname: string|null = ''\n previousHetero: boolean|null = null\n\n ai = -1\n ri = -1\n ci = -1\n mi = -1\n\n constructor(readonly structure: Structure) {}\n\n addResidueType (ri: number) {\n const atomStore = this.structure.atomStore\n const residueStore = this.structure.residueStore\n const residueMap = this.structure.residueMap\n\n const count = residueStore.atomCount[ ri ]\n const offset = residueStore.atomOffset[ ri ]\n const atomTypeIdList = new Array(count)\n for (let i = 0; i < count; ++i) {\n atomTypeIdList[ i ] = atomStore.atomTypeId[ offset + i ]\n }\n residueStore.residueTypeId[ ri ] = residueMap.add(\n this.previousResname!, atomTypeIdList, this.previousHetero! // TODO\n )\n }\n\n addAtom (modelindex: number, chainname: string, chainid: string, resname: string, resno: number, hetero: boolean, sstruc?: string|undefined, inscode?: string|undefined) {\n const atomStore = this.structure.atomStore\n const residueStore = this.structure.residueStore\n const chainStore = this.structure.chainStore\n const modelStore = this.structure.modelStore\n\n let addModel = false\n let addChain = false\n let addResidue = false\n\n if (this.currentModelindex !== modelindex) {\n addModel = true\n addChain = true\n addResidue = true\n this.mi += 1\n this.ci += 1\n this.ri += 1\n } else if (this.currentChainid !== chainid) {\n addChain = true\n addResidue = true\n this.ci += 1\n this.ri += 1\n } else if (this.currentResno !== resno || this.currentResname !== resname || this.currentInscode !== inscode) {\n addResidue = true\n this.ri += 1\n }\n this.ai += 1\n\n if (addModel) {\n modelStore.growIfFull()\n modelStore.chainOffset[ this.mi ] = this.ci\n modelStore.chainCount[ this.mi ] = 0\n modelStore.count += 1\n chainStore.modelIndex[ this.ci ] = this.mi\n }\n\n if (addChain) {\n chainStore.growIfFull()\n chainStore.setChainname(this.ci, chainname)\n chainStore.setChainid(this.ci, chainid)\n chainStore.residueOffset[ this.ci ] = this.ri\n chainStore.residueCount[ this.ci ] = 0\n chainStore.count += 1\n chainStore.modelIndex[ this.ci ] = this.mi\n modelStore.chainCount[ this.mi ] += 1\n residueStore.chainIndex[ this.ri ] = this.ci\n }\n\n if (addResidue) {\n this.previousResname = this.currentResname\n this.previousHetero = this.currentHetero\n if (this.ri > 0) this.addResidueType(this.ri - 1)\n residueStore.growIfFull()\n residueStore.resno[ this.ri ] = resno\n if (sstruc !== undefined) {\n residueStore.sstruc[ this.ri ] = sstruc.charCodeAt(0)\n }\n if (inscode !== undefined) {\n residueStore.inscode[ this.ri ] = inscode.charCodeAt(0)\n }\n residueStore.atomOffset[ this.ri ] = this.ai\n residueStore.atomCount[ this.ri ] = 0\n residueStore.count += 1\n residueStore.chainIndex[ this.ri ] = this.ci\n chainStore.residueCount[ this.ci ] += 1\n }\n\n atomStore.count += 1\n atomStore.residueIndex[ this.ai ] = this.ri\n residueStore.atomCount[ this.ri ] += 1\n\n this.currentModelindex = modelindex\n this.currentChainid = chainid\n this.currentResname = resname\n this.currentResno = resno\n this.currentInscode = inscode\n this.currentHetero = hetero\n }\n\n finalize () {\n this.previousResname = this.currentResname\n this.previousHetero = this.currentHetero\n if (this.ri > -1) this.addResidueType(this.ri)\n }\n}\n\nexport default StructureBuilder\n","/**\n * @file Structure Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4 } from 'three'\n\nimport { Debug, Log } from '../globals'\nimport { binarySearchIndexOf } from '../utils'\nimport Helixbundle from '../geometry/helixbundle'\nimport Kdtree from '../geometry/kdtree'\nimport { getSymmetryOperations } from '../symmetry/symmetry-utils'\nimport Assembly from '../symmetry/assembly'\nimport Structure from '../structure/structure'\nimport StructureBuilder from '../structure/structure-builder'\nimport Polymer from '../proxy/polymer'\nimport ResidueProxy from '../proxy/residue-proxy'\n\nimport { UnknownBackboneType, AA3, Bases, AtomicNumbers } from './structure-constants'\n\nexport function reorderAtoms (structure: Structure) {\n if (Debug) Log.time('reorderAtoms')\n\n var ap1 = structure.getAtomProxy()\n var ap2 = structure.getAtomProxy()\n\n function compareModelChainResno (index1: number, index2: number) {\n ap1.index = index1\n ap2.index = index2\n if (ap1.modelIndex < ap2.modelIndex) {\n return -1\n } else if (ap1.modelIndex > ap2.modelIndex) {\n return 1\n } else {\n if (ap1.chainname < ap2.chainname) {\n return -1\n } else if (ap1.chainname > ap2.chainname) {\n return 1\n } else {\n if (ap1.resno < ap2.resno) {\n return -1\n } else if (ap1.resno > ap2.resno) {\n return 1\n } else {\n return 0\n }\n }\n }\n }\n\n structure.atomStore.sort(compareModelChainResno)\n\n if (Debug) Log.timeEnd('reorderAtoms')\n}\n\nexport interface SecStruct {\n helices: [string, number, string, string, number, string, number][]\n sheets: [string, number, string, string, number, string][]\n}\n\nexport function assignSecondaryStructure (structure: Structure, secStruct: SecStruct) {\n if (!secStruct) return\n\n if (Debug) Log.time('assignSecondaryStructure')\n\n const chainnames: string[] = []\n structure.eachModel(function (mp) {\n mp.eachChain(function (cp) {\n chainnames.push(cp.chainname)\n })\n })\n\n const chainnamesSorted = chainnames.slice().sort()\n const chainnamesIndex: number[] = []\n chainnamesSorted.forEach(function (c) {\n chainnamesIndex.push(chainnames.indexOf(c))\n })\n\n // helix assignment\n\n const helices = secStruct.helices.filter(function (h) {\n return binarySearchIndexOf(chainnamesSorted, h[ 0 ]) >= 0\n })\n\n helices.sort(function (h1, h2) {\n const c1 = h1[ 0 ]\n const c2 = h2[ 0 ]\n const r1 = h1[ 1 ]\n const r2 = h2[ 1 ]\n\n if (c1 === c2) {\n if (r1 === r2) {\n return 0\n } else {\n return r1 < r2 ? -1 : 1\n }\n } else {\n const idx1 = binarySearchIndexOf(chainnamesSorted, c1)\n const idx2 = binarySearchIndexOf(chainnamesSorted, c2)\n return chainnamesIndex[ idx1 ] < chainnamesIndex[ idx2 ] ? -1 : 1\n }\n })\n\n const residueStore = structure.residueStore\n\n structure.eachModel(function (mp) {\n let i = 0\n const n = helices.length\n if (n === 0) return\n let helix = helices[ i ]\n let helixRun = false\n let done = false\n\n mp.eachChain(function (cp) {\n let chainChange = false\n\n if (cp.chainname === helix[ 0 ]) {\n const count = cp.residueCount\n const offset = cp.residueOffset\n const end = offset + count\n\n for (let j = offset; j < end; ++j) {\n if (residueStore.resno[ j ] === helix[ 1 ] && // resnoBeg\n residueStore.getInscode(j) === helix[ 2 ] // inscodeBeg\n ) {\n helixRun = true\n }\n\n if (helixRun) {\n residueStore.sstruc[ j ] = helix[ 6 ]\n\n if (residueStore.resno[ j ] === helix[ 4 ] && // resnoEnd\n residueStore.getInscode(j) === helix[ 5 ] // inscodeEnd\n ) {\n helixRun = false\n i += 1\n\n if (i < n) {\n // must look at previous residues as\n // residues may not be ordered by resno\n j = offset - 1\n helix = helices[ i ]\n chainChange = cp.chainname !== helix[ 0 ]\n } else {\n done = true\n }\n }\n }\n\n if (chainChange || done) return\n }\n }\n })\n })\n\n // sheet assignment\n\n const sheets = secStruct.sheets.filter(function (s) {\n return binarySearchIndexOf(chainnamesSorted, s[ 0 ]) >= 0\n })\n\n sheets.sort(function (s1, s2) {\n const c1 = s1[ 0 ]\n const c2 = s2[ 0 ]\n\n if (c1 === c2) return 0\n const idx1 = binarySearchIndexOf(chainnamesSorted, c1)\n const idx2 = binarySearchIndexOf(chainnamesSorted, c2)\n return chainnamesIndex[ idx1 ] < chainnamesIndex[ idx2 ] ? -1 : 1\n })\n\n const strandCharCode = 'e'.charCodeAt(0)\n structure.eachModel(function (mp) {\n let i = 0\n const n = sheets.length\n if (n === 0) return\n let sheet = sheets[ i ]\n let sheetRun = false\n let done = false\n\n mp.eachChain(function (cp) {\n let chainChange = false\n\n if (cp.chainname === sheet[ 0 ]) {\n const count = cp.residueCount\n const offset = cp.residueOffset\n const end = offset + count\n\n for (let j = offset; j < end; ++j) {\n if (residueStore.resno[ j ] === sheet[ 1 ] && // resnoBeg\n residueStore.getInscode(j) === sheet[ 2 ] // inscodeBeg\n ) {\n sheetRun = true\n }\n\n if (sheetRun) {\n residueStore.sstruc[ j ] = strandCharCode\n\n if (residueStore.resno[ j ] === sheet[ 4 ] && // resnoEnd\n residueStore.getInscode(j) === sheet[ 5 ] // inscodeEnd\n ) {\n sheetRun = false\n i += 1\n\n if (i < n) {\n // must look at previous residues as\n // residues may not be ordered by resno\n j = offset - 1\n sheet = sheets[ i ]\n chainChange = cp.chainname !== sheet[ 0 ]\n } else {\n done = true\n }\n }\n }\n\n if (chainChange || done) return\n }\n }\n })\n })\n\n if (Debug) Log.timeEnd('assignSecondaryStructure')\n}\n\nexport const calculateSecondaryStructure = (function () {\n // Implementation for proteins based on \"pv\"\n //\n // assigns secondary structure information based on a simple and very fast\n // algorithm published by Zhang and Skolnick in their TM-align paper.\n // Reference:\n //\n // TM-align: a protein structure alignment algorithm based on the Tm-score\n // (2005) NAR, 33(7) 2302-2309\n\n const zhangSkolnickSS = function (polymer: Polymer, i: number, distances: number[], delta: number) {\n const structure = polymer.structure\n const offset = polymer.residueIndexStart\n const rp1 = structure.getResidueProxy()\n const rp2 = structure.getResidueProxy()\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n for (let j = Math.max(0, i - 2); j <= i; ++j) {\n for (let k = 2; k < 5; ++k) {\n if (j + k >= polymer.residueCount) {\n continue\n }\n\n rp1.index = offset + j\n rp2.index = offset + j + k\n ap1.index = rp1.traceAtomIndex\n ap2.index = rp2.traceAtomIndex\n\n const d = ap1.distanceTo(ap2)\n\n if (Math.abs(d - distances[ k - 2 ]) > delta) {\n return false\n }\n }\n }\n\n return true\n }\n\n const isHelical = function (polymer: Polymer, i: number) {\n const helixDistances = [ 5.45, 5.18, 6.37 ]\n const helixDelta = 2.1\n return zhangSkolnickSS(polymer, i, helixDistances, helixDelta)\n }\n\n const isSheet = function (polymer: Polymer, i: number) {\n const sheetDistances = [ 6.1, 10.4, 13.0 ]\n const sheetDelta = 1.42\n return zhangSkolnickSS(polymer, i, sheetDistances, sheetDelta)\n }\n\n const proteinPolymer = function (p: Polymer) {\n const residueStore = p.residueStore\n const offset = p.residueIndexStart\n for (let i = 0, il = p.residueCount; i < il; ++i) {\n let sstruc = 'c'\n if (isHelical(p, i)) {\n sstruc = 'h'\n } else if (isSheet(p, i)) {\n sstruc = 'e'\n }\n residueStore.sstruc[ offset + i ] = sstruc.charCodeAt(0)\n }\n }\n\n const cgPolymer = function (p: Polymer) {\n const localAngle = 20\n const centerDist = 2.0\n\n const residueStore = p.residueStore\n const offset = p.residueIndexStart\n\n const helixbundle = new Helixbundle(p)\n const pos = helixbundle.position\n\n const c1 = new Vector3()\n const c2 = new Vector3()\n\n for (let i = 0, il = p.residueCount; i < il; ++i) {\n c1.fromArray(pos.center as any, i * 3) // TODO\n c2.fromArray(pos.center as any, i * 3 + 3) // TODO\n const d = c1.distanceTo(c2)\n\n if (d < centerDist && d > 1.0 && pos.bending[ i ] < localAngle) {\n residueStore.sstruc[ offset + i ] = 'h'.charCodeAt(0)\n residueStore.sstruc[ offset + i + 1 ] = 'h'.charCodeAt(0)\n }\n }\n }\n\n return function calculateSecondaryStructure (structure: Structure) {\n if (Debug) Log.time('calculateSecondaryStructure')\n\n structure.eachPolymer(function (p) {\n // assign secondary structure\n if (p.residueCount < 4) return\n if (p.isCg()) {\n cgPolymer(p)\n } else if (p.isProtein()) {\n proteinPolymer(p)\n } else {\n return\n }\n\n // set lone secondary structure assignments to \"c\"\n let prevSstruc: string\n let sstrucCount = 0\n p.eachResidue(function (r: ResidueProxy) {\n if (r.sstruc === prevSstruc) {\n sstrucCount += 1\n } else {\n if (sstrucCount === 1) {\n r.index -= 1\n r.sstruc = 'c'\n }\n sstrucCount = 1\n prevSstruc = r.sstruc\n }\n })\n })\n\n if (Debug) Log.timeEnd('calculateSecondaryStructure')\n }\n}())\n\n// const ChainnameAlphabet = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\" +\n// \"abcdefghijklmnopqrstuvwxyz\" +\n// \"0123456789\";\nconst ChainnameAlphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\n\nexport function getChainname (index: number) {\n const n = ChainnameAlphabet.length\n let j = index\n let k = 0\n let chainname = ChainnameAlphabet[j % n]\n while (j >= n) {\n j = Math.floor(j / n)\n chainname += ChainnameAlphabet[j % n]\n k += 1\n }\n if (k >= 5) {\n Log.warn('chainname overflow')\n }\n return chainname\n}\n\ninterface ChainData {\n mIndex: number\n chainname: string\n rStart: number\n rCount: number\n}\n\n/**\n * When no chain names are set for the given structure, calculates\n * chains based on:\n * - polymer connectivity: when adjacent residues are not bonded, a new chain is created.\n * - non polymer chemical type: adjacent residues which are not polymers but are of the same\n * chemical type (e.g. water molecules) are grouped into the same chain.\n **/\nexport function calculateChainnames (structure: Structure, useExistingBonds = false) {\n if (Debug) Log.time('calculateChainnames')\n\n let doAutoChainName = true\n structure.eachChain(function (c) {\n if (c.chainname) doAutoChainName = false\n })\n\n if (doAutoChainName) {\n const modelStore = structure.modelStore\n const chainStore = structure.chainStore\n const residueStore = structure.residueStore\n\n const addChain = function (mIndex: number, chainname: string, rOffset: number, rCount: number) {\n const ci = chainStore.count\n for (let i = 0; i < rCount; ++i) {\n residueStore.chainIndex[ rOffset + i ] = ci\n }\n chainStore.growIfFull()\n chainStore.modelIndex[ ci ] = mIndex\n chainStore.setChainname(ci, chainname)\n chainStore.setChainid(ci, chainname)\n chainStore.residueOffset[ ci ] = rOffset\n chainStore.residueCount[ ci ] = rCount\n chainStore.count += 1\n modelStore.chainCount[ mIndex ] += 1\n }\n\n const ap1 = structure.getAtomProxy()\n const ap2 = structure.getAtomProxy()\n\n let i = 0\n let mi = 0\n let rStart = 0\n let rEnd = 0\n const chainData: ChainData[] = []\n\n if (residueStore.count === 1) {\n chainData.push({\n mIndex: 0,\n chainname: 'A',\n rStart: 0,\n rCount: 1\n })\n } else {\n structure.eachResidueN(2, function (rp1: ResidueProxy, rp2: ResidueProxy) {\n let newChain = false\n\n const bbType1 = rp1.backboneType\n const bbType2 = rp2.backboneType\n const bbTypeUnk = UnknownBackboneType\n\n rEnd = rp1.index\n\n if (rp1.modelIndex !== rp2.modelIndex) {\n newChain = true\n } else if (rp1.moleculeType !== rp2.moleculeType) {\n newChain = true\n } else if (bbType1 !== bbTypeUnk && bbType1 === bbType2) {\n ap1.index = rp1.backboneEndAtomIndex\n ap2.index = rp2.backboneStartAtomIndex\n if (useExistingBonds) {\n newChain = !ap1.hasBondTo(ap2)\n } else {\n newChain = !ap1.connectedTo(ap2)\n }\n }\n\n // current chain goes to end of the structure\n if (!newChain && rp2.index === residueStore.count - 1) {\n newChain = true\n rEnd = rp2.index\n }\n\n if (newChain) {\n chainData.push({\n mIndex: mi,\n chainname: getChainname(i),\n rStart: rStart,\n rCount: rEnd - rStart + 1\n })\n\n i += 1\n\n if (rp1.modelIndex !== rp2.modelIndex) {\n i = 0\n mi += 1\n }\n\n // new chain for the last residue of the structure\n if (rp2.index === residueStore.count - 1 && rEnd !== rp2.index) {\n chainData.push({\n mIndex: mi,\n chainname: getChainname(i),\n rStart: residueStore.count - 1,\n rCount: 1\n })\n }\n\n rStart = rp2.index\n rEnd = rp2.index\n }\n })\n }\n\n //\n\n chainStore.count = 0\n modelStore.chainCount.fill(0, 0, modelStore.count)\n modelStore.chainOffset.fill(0, 0, modelStore.count)\n chainData.forEach(function (d) {\n addChain(d.mIndex, d.chainname, d.rStart, d.rCount)\n })\n\n let chainOffset = 0\n structure.eachModel(function (mp) {\n modelStore.chainOffset[ mp.index ] = chainOffset\n chainOffset += modelStore.chainCount[ mp.index ]\n })\n }\n\n if (Debug) Log.timeEnd('calculateChainnames')\n}\n\nexport function calculateBonds (structure: Structure, inferBonds: InferBondsOptions='all') {\n if (inferBonds === 'none') return \n if (Debug) Log.time('calculateBonds')\n\n calculateBondsWithin(structure, false, inferBonds)\n calculateBondsBetween(structure)\n\n if (Debug) Log.timeEnd('calculateBonds')\n}\n\n/**\n * Should Bonds be inferred for `all` atoms, `none` or `auto`\n * If `auto`, any hetgroup residue with at least one CONECT record will \n * not have bonding inferred, and will rely on the CONECT records\n */\nexport type InferBondsOptions = 'all' | 'none' | 'auto'\n\nexport interface ResidueBonds {\n atomIndices1: number[]\n atomIndices2: number[]\n bondOrders: number[]\n}\n\n\nconst BondOrderTable: { [k: string]: number } = {\n 'HIS|CD2|CG': 2,\n 'HIS|CE1|ND1': 2,\n 'ARG|CZ|NH2': 2,\n 'PHE|CE1|CZ': 2,\n 'PHE|CD2|CE2': 2,\n 'PHE|CD1|CG': 2,\n 'TRP|CD1|CG': 2,\n 'TRP|CD2|CE2': 2,\n 'TRP|CE3|CZ3': 2,\n 'TRP|CH2|CZ2': 2,\n 'ASN|CG|OD1': 2,\n 'GLN|CD|OE1': 2,\n 'TYR|CD1|CG': 2,\n 'TYR|CD2|CE2': 2,\n 'TYR|CE1|CZ': 2,\n 'ASP|CG|OD1': 2,\n 'GLU|CD|OE1': 2,\n\n 'G|C8|N7': 2,\n 'G|C4|C5': 2,\n 'G|C2|N3': 2,\n 'G|C6|O6': 2,\n 'C|C4|N3': 2,\n 'C|C5|C6': 2,\n 'C|C2|O2': 2,\n 'A|C2|N3': 2,\n 'A|C6|N1': 2,\n 'A|C4|C5': 2,\n 'A|C8|N7': 2,\n 'U|C5|C6': 2,\n 'U|C2|O2': 2,\n 'U|C4|O4': 2,\n\n 'DG|C8|N7': 2,\n 'DG|C4|C5': 2,\n 'DG|C2|N3': 2,\n 'DG|C6|O6': 2,\n 'DC|C4|N3': 2,\n 'DC|C5|C6': 2,\n 'DC|C2|O2': 2,\n 'DA|C2|N3': 2,\n 'DA|C6|N1': 2,\n 'DA|C4|C5': 2,\n 'DA|C8|N7': 2,\n 'DT|C5|C6': 2,\n 'DT|C2|O2': 2,\n 'DT|C4|O4': 2\n}\nfunction getBondOrderFromTable (resname: string, atomname1: string, atomname2: string) {\n [ atomname1, atomname2 ] = atomname1 < atomname2 ? [ atomname1, atomname2 ] : [ atomname2, atomname1 ]\n if (AA3.includes(resname) && atomname1 === 'C' && atomname2 === 'O') return 2\n if (Bases.includes(resname) && atomname1 === 'OP1' && atomname2 === 'P') return 2\n return BondOrderTable[ `${resname}|${atomname1}|${atomname2}` ] || 1\n}\n\nexport function calculateResidueBonds (r: ResidueProxy) {\n const structure = r.structure\n const a1 = structure.getAtomProxy()\n const a2 = structure.getAtomProxy()\n\n const count = r.atomCount\n const offset = r.atomOffset\n const end = offset + count\n const end1 = end - 1\n\n const atomIndices1 = []\n const atomIndices2 = []\n const bondOrders = []\n\n if (count > 500) {\n if (Debug) Log.warn('more than 500 atoms, skip residue for auto-bonding', r.qualifiedName())\n } else {\n if (count > 50) {\n const kdtree = new Kdtree(r, true)\n const radius = r.isCg() ? 1.2 : 2.3\n\n for (let i = offset; i < end1; ++i) {\n a1.index = i\n const maxd = a1.covalent + radius + 0.3\n const nearestAtoms = kdtree.nearest(a1 as any, Infinity, maxd * maxd) // TODO\n const m = nearestAtoms.length\n for (let j = 0; j < m; ++j) {\n a2.index = nearestAtoms[ j ].index\n if (a1.index < a2.index) {\n if (a1.connectedTo(a2)) {\n atomIndices1.push(a1.index - offset)\n atomIndices2.push(a2.index - offset)\n bondOrders.push(getBondOrderFromTable(a1.resname, a1.atomname, a2.atomname))\n }\n }\n }\n }\n } else {\n for (let i = offset; i < end1; ++i) {\n a1.index = i\n for (let j = i + 1; j <= end1; ++j) {\n a2.index = j\n if (a1.connectedTo(a2)) {\n atomIndices1.push(i - offset)\n atomIndices2.push(j - offset)\n bondOrders.push(getBondOrderFromTable(a1.resname, a1.atomname, a2.atomname))\n }\n }\n }\n }\n }\n\n return {\n atomIndices1: atomIndices1,\n atomIndices2: atomIndices2,\n bondOrders: bondOrders\n }\n}\n\nexport function calculateAtomBondMap (structure: Structure) {\n if (Debug) Log.time('calculateAtomBondMap')\n\n var atomBondMap: number[][] = []\n\n structure.eachBond(function (bp) {\n var ai1 = bp.atomIndex1\n var ai2 = bp.atomIndex2\n if (atomBondMap[ ai1 ] === undefined) atomBondMap[ ai1 ] = []\n atomBondMap[ ai1 ][ ai2 ] = bp.index\n })\n\n if (Debug) Log.timeEnd('calculateAtomBondMap')\n\n return atomBondMap\n}\n\nexport function calculateBondsWithin (structure: Structure, onlyAddRung = false, inferBonds: InferBondsOptions='all') {\n if (Debug) Log.time('calculateBondsWithin')\n\n const bondStore = structure.bondStore\n const rungBondStore = structure.rungBondStore\n const rungAtomSet = structure.getAtomSet(false)\n const a1 = structure.getAtomProxy()\n const a2 = structure.getAtomProxy()\n const bp = structure.getBondProxy()\n const atomBondMap = onlyAddRung ? null : calculateAtomBondMap(structure)\n\n let bondedAtoms: Set\n if (!onlyAddRung && inferBonds === 'auto') {\n bondedAtoms = new Set()\n atomBondMap!.forEach((a, i) => {\n bondedAtoms.add(i)\n a.forEach(j => {bondedAtoms.add(j)})\n })\n }\n\n structure.eachResidue(function (r) {\n if (!onlyAddRung && atomBondMap) {\n const count = r.atomCount\n const offset = r.atomOffset\n\n if (count > 500) {\n Log.warn('more than 500 atoms, skip residue for auto-bonding', r.qualifiedName())\n return\n }\n\n if (inferBonds === 'auto' && r.hetero) {\n // Are bonds present on this residue?\n for (let rai=r.atomOffset; rai {\n ncsMatrixList.forEach(nm => {\n ncsUnitcellMatrixList.push(sm.clone().multiply(nm))\n })\n })\n unitcellAssembly.addPart(ncsUnitcellMatrixList)\n } else {\n unitcellAssembly.addPart(unitcellMatrixList)\n }\n\n const vec = new Vector3()\n const supercellAssembly = new Assembly('SUPERCELL')\n const supercellMatrixList = Array.prototype.concat.call(\n getMatrixList(vec.set(1, 0, 0)), // 655\n getMatrixList(vec.set(0, 1, 0)), // 565\n getMatrixList(vec.set(0, 0, 1)), // 556\n\n getMatrixList(vec.set(-1, 0, 0)), // 455\n getMatrixList(vec.set(0, -1, 0)), // 545\n getMatrixList(vec.set(0, 0, -1)), // 554\n\n getMatrixList(vec.set(1, 1, 0)), // 665\n getMatrixList(vec.set(1, 0, 1)), // 656\n getMatrixList(vec.set(0, 1, 1)), // 566\n\n getMatrixList(vec.set(-1, -1, 0)), // 445\n getMatrixList(vec.set(-1, 0, -1)), // 454\n getMatrixList(vec.set(0, -1, -1)), // 544\n\n getMatrixList(vec.set(1, -1, -1)), // 644\n getMatrixList(vec.set(1, 1, -1)), // 664\n getMatrixList(vec.set(1, -1, 1)), // 646\n getMatrixList(vec.set(-1, 1, 1)), // 466\n getMatrixList(vec.set(-1, -1, 1)), // 446\n getMatrixList(vec.set(-1, 1, -1)), // 464\n\n getMatrixList(vec.set(0, 1, -1)), // 564\n getMatrixList(vec.set(0, -1, 1)), // 546\n getMatrixList(vec.set(1, 0, -1)), // 654\n getMatrixList(vec.set(-1, 0, 1)), // 456\n getMatrixList(vec.set(1, -1, 0)), // 645\n getMatrixList(vec.set(-1, 1, 0)), // 465\n\n getMatrixList(), // 555\n getMatrixList(vec.set(1, 1, 1)), // 666\n getMatrixList(vec.set(-1, -1, -1)) // 444\n )\n if (structure.biomolDict.NCS) {\n const ncsSupercellMatrixList: Matrix4[] = []\n supercellMatrixList.forEach(function (sm: Matrix4) {\n ncsMatrixList.forEach(function (nm) {\n ncsSupercellMatrixList.push(sm.clone().multiply(nm))\n })\n })\n supercellAssembly.addPart(ncsSupercellMatrixList)\n } else {\n supercellAssembly.addPart(supercellMatrixList)\n }\n\n structure.biomolDict.UNITCELL = unitcellAssembly\n structure.biomolDict.SUPERCELL = supercellAssembly\n\n if (Debug) Log.timeEnd('buildUnitcellAssembly')\n}\n\nconst elm1 = [ 'H', 'C', 'O', 'N', 'S', 'P' ]\nconst elm2 = [ 'NA', 'CL', 'FE' ]\n\nexport function guessElement (atomName: string) {\n // Retain first group of letters in atomName\n let at = atomName.toUpperCase()\n let begin = 0, end = 0\n for (let i = 0; i < at.length ; i++) {\n if (at.charCodeAt(i) < 65) {\n if (end > 0) break\n ++begin\n }\n else end = i + 1\n }\n if (begin > 0 || end < at.length) at = at.substring(begin, end)\n \n const n = at.length\n\n if (n === 0) return ''\n if (n === 1) return at\n if (n === 2) {\n if (elm2.indexOf(at) !== -1) return at\n if (elm1.indexOf(at[0]) !== -1) return at[0]\n if (at in AtomicNumbers) return at\n }\n if (n >= 3) {\n if (elm1.indexOf(at[0]) !== -1) return at[0]\n }\n return ''\n}\n\n/**\n * Assigns ResidueType bonds.\n * @param {Structure} structure - the structure object\n * @return {undefined}\n */\nexport function assignResidueTypeBonds (structure: Structure) {\n // if( Debug ) Log.time( \"assignResidueTypeBonds\" )\n\n const bondHash = structure.bondHash! // TODO\n const countArray = bondHash.countArray\n const offsetArray = bondHash.offsetArray\n const indexArray = bondHash.indexArray\n const bp = structure.getBondProxy()\n\n structure.eachResidue(function (rp) {\n const residueType = rp.residueType\n if (residueType.bonds !== undefined) return\n\n var atomOffset = rp.atomOffset\n var atomIndices1: number[] = []\n var atomIndices2: number[] = []\n var bondOrders: number[] = []\n var bondDict: { [k: string]: boolean } = {}\n\n const nextAtomOffset = atomOffset + rp.atomCount\n\n rp.eachAtom(function (ap) {\n const index = ap.index\n const offset = offsetArray[ index ]\n const count = countArray[ index ]\n for (let i = 0, il = count; i < il; ++i) {\n bp.index = indexArray[ offset + i ]\n let idx1 = bp.atomIndex1\n if (idx1 < atomOffset || idx1 >= nextAtomOffset) {\n // Don't add bonds outside of this resiude\n continue\n }\n let idx2 = bp.atomIndex2\n if (idx2 < atomOffset || idx2 >= nextAtomOffset) {\n continue\n }\n\n if (idx1 > idx2) {\n const tmp = idx2\n idx2 = idx1\n idx1 = tmp\n }\n const hash = idx1 + '|' + idx2\n if (bondDict[ hash ] === undefined) {\n bondDict[ hash ] = true\n atomIndices1.push(idx1 - atomOffset)\n atomIndices2.push(idx2 - atomOffset)\n bondOrders.push(bp.bondOrder)\n }\n }\n })\n\n residueType.bonds = {\n atomIndices1: atomIndices1,\n atomIndices2: atomIndices2,\n bondOrders: bondOrders\n }\n })\n\n // if( Debug ) Log.timeEnd( \"assignResidueTypeBonds\" )\n}\n\nexport function concatStructures (name: string, ...structures: Structure[]) {\n if( Debug ) Log.time( \"concatStructures\" )\n\n const s = new Structure(name, '')\n const sb = new StructureBuilder(s)\n\n const atomStore = s.atomStore as any\n const atomMap = s.atomMap\n atomStore.addField('formalCharge', 1, 'int8')\n atomStore.addField('partialCharge', 1, 'float32')\n\n const atomIndexDict: { [k: number]: number } = {}\n\n let idx = 0\n let atomCount = 0\n let modelCount = 0\n structures.forEach(structure => {\n structure.eachAtom(a => {\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(a.atomname, a.element)\n\n atomStore.x[ idx ] = a.x\n atomStore.y[ idx ] = a.y\n atomStore.z[ idx ] = a.z\n atomStore.serial[ idx ] = a.serial\n atomStore.formalCharge[ idx ] = a.formalCharge\n atomStore.partialCharge[ idx ] = a.partialCharge\n atomStore.altloc[ idx ] = a.altloc\n atomStore.occupancy[ idx ] = a.occupancy\n atomStore.bfactor[ idx ] = a.bfactor\n\n sb.addAtom(\n a.modelIndex + modelCount,\n a.chainname,\n a.chainid,\n a.resname,\n a.resno,\n a.hetero === 1,\n a.sstruc,\n a.inscode\n )\n\n atomIndexDict[a.index + atomCount] = idx\n idx += 1\n })\n atomCount += structure.atomStore.count\n modelCount += structure.modelStore.count\n })\n\n const bondStore = s.bondStore\n const a1 = s.getAtomProxy()\n const a2 = s.getAtomProxy()\n\n atomCount = 0\n structures.forEach(structure => {\n structure.eachBond(b => {\n a1.index = atomIndexDict[ b.atomIndex1 + atomCount ]\n a2.index = atomIndexDict[ b.atomIndex2 + atomCount ]\n bondStore.addBond(a1, a2, b.bondOrder)\n })\n atomCount += structure.atomStore.count\n })\n\n sb.finalize()\n\n calculateBondsBetween(s, true) // calculate backbone bonds\n calculateBondsWithin(s, true) // calculate rung bonds\n\n s.finalizeAtoms()\n s.finalizeBonds()\n assignResidueTypeBonds(s)\n\n if( Debug ) Log.timeEnd( \"concatStructures\" )\n\n return s\n}\n","/**\n * @file Atom Type\n * @author Alexander Rose \n * @private\n */\n\nimport { guessElement } from '../structure/structure-utils'\nimport {\n AtomicNumbers, DefaultAtomicNumber,\n VdwRadii, DefaultVdwRadius,\n CovalentRadii, DefaultCovalentRadius,\n Valences, DefaultValence,\n OuterShellElectronCounts, DefaultOuterShellElectronCount\n} from '../structure/structure-constants'\nimport Structure from '../structure/structure'\n\n// Li, Na, K, Rb, Cs Fr\nconst AlkaliMetals = [ 3, 11, 19, 37, 55, 87 ]\n\n// Be, Mg, Ca, Sr, Ba, Ra\nconst AlkalineEarthMetals = [ 4, 12, 20, 38, 56, 88 ]\n\n// C, P, S, Se\nconst PolyatomicNonmetals = [ 6, 15, 16, 34, ]\n\n// H, N, O, F, Cl, Br, I\nconst DiatomicNonmetals = [ 1, 7, 8, 9, 17, 35, 53 ]\n\n// He, Ne, Ar, Kr, Xe, Rn\nconst NobleGases = [ 2, 10, 18, 36, 54, 86 ]\n\n// Zn, Ga, Cd, In, Sn, Hg, Ti, Pb, Bi, Po, Cn\nconst PostTransitionMetals = [ 13, 30, 31, 48, 49, 50, 80, 81, 82, 83, 84, 85, 112 ]\n\n// B, Si, Ge, As, Sb, Te, At\nconst Metalloids = [ 5, 14, 32, 33, 51, 52, 85 ]\n\n// F, Cl, Br, I, At\nconst Halogens = [ 9, 17, 35, 53, 85 ]\n\n/**\n * Atom type\n */\nclass AtomType {\n element: string\n number: number\n vdw: number\n covalent: number\n\n /**\n * @param {Structure} structure - the structure object\n * @param {String} atomname - the name of the atom\n * @param {String} element - the chemical element\n */\n constructor (readonly structure: Structure, readonly atomname: string, element?: string) {\n element = element || guessElement(atomname)\n\n this.element = element\n this.number = AtomicNumbers[ element ] || DefaultAtomicNumber\n this.vdw = VdwRadii[ this.number ] || DefaultVdwRadius\n this.covalent = CovalentRadii[ this.number ] || DefaultCovalentRadius\n }\n\n getDefaultValence() {\n const vl = Valences[ this.number ]\n return vl ? vl[ 0 ] : DefaultValence\n }\n\n getValenceList () {\n return Valences[ this.number ] || []\n }\n\n getOuterShellElectronCount () {\n return OuterShellElectronCounts[ this.number ] || DefaultOuterShellElectronCount\n }\n\n isMetal () {\n return (\n this.isAlkaliMetal() ||\n this.isAlkalineEarthMetal() ||\n this.isLanthanide() ||\n this.isActinide() ||\n this.isTransitionMetal() ||\n this.isPostTransitionMetal()\n )\n }\n\n isNonmetal () {\n return (\n this.isDiatomicNonmetal() ||\n this.isPolyatomicNonmetal() ||\n this.isNobleGas()\n )\n }\n\n isMetalloid () {\n return Metalloids.includes(this.number)\n }\n\n isHalogen () {\n return Halogens.includes(this.number)\n }\n\n isDiatomicNonmetal () {\n return DiatomicNonmetals.includes(this.number)\n }\n\n isPolyatomicNonmetal () {\n return PolyatomicNonmetals.includes(this.number)\n }\n\n isAlkaliMetal () {\n return AlkaliMetals.includes(this.number)\n }\n\n isAlkalineEarthMetal () {\n return AlkalineEarthMetals.includes(this.number)\n }\n\n isNobleGas () {\n return NobleGases.includes(this.number)\n }\n\n isTransitionMetal () {\n const no = this.number\n return (\n (no >= 21 && no <= 29) ||\n (no >= 39 && no <= 47) ||\n (no >= 72 && no <= 79) ||\n (no >= 104 && no <= 108)\n )\n }\n\n isPostTransitionMetal () {\n return PostTransitionMetals.includes(this.number)\n }\n\n isLanthanide () {\n return this.number >= 57 && this.number <= 71\n }\n\n isActinide () {\n return this.number >= 89 && this.number <= 103\n }\n\n}\n\nexport default AtomType","/**\n * @file Atom Map\n * @author Alexander Rose \n * @private\n */\n\nimport AtomType from './atom-type'\nimport { guessElement } from '../structure/structure-utils'\nimport Structure from '../structure/structure'\n\nfunction getHash (atomname: string, element: string) {\n return atomname + '|' + element\n}\n\nclass AtomMap {\n dict: { [k: string]: number } = {}\n list: AtomType[] = []\n\n constructor (readonly structure: Structure) {\n this.structure = structure\n }\n\n add (atomname: string, element?: string) {\n atomname = atomname.toUpperCase()\n if (!element) {\n element = guessElement(atomname)\n } else {\n element = element.toUpperCase()\n }\n const hash = getHash(atomname, element)\n let id = this.dict[ hash ]\n if (id === undefined) {\n const atomType = new AtomType(this.structure, atomname, element)\n id = this.list.length\n this.dict[ hash ] = id\n this.list.push(atomType)\n }\n return id\n }\n\n get (id: number) {\n return this.list[ id ]\n }\n}\n\nexport default AtomMap\n","/**\n * @file Residue Type\n * @author Alexander Rose \n * @author Fred Ludlow\n * @private\n */\n\nimport { defaults } from '../utils'\nimport PrincipalAxes from '../math/principal-axes'\nimport { Matrix } from '../math/matrix-utils'\nimport { calculateResidueBonds, ResidueBonds } from '../structure/structure-utils'\nimport {\n Elements,\n ProteinType, RnaType, DnaType, WaterType, IonType, SaccharideType, UnknownType,\n ProteinBackboneType, RnaBackboneType, DnaBackboneType, UnknownBackboneType,\n CgProteinBackboneType, CgRnaBackboneType, CgDnaBackboneType,\n ChemCompProtein, ChemCompRna, ChemCompDna, ChemCompSaccharide,\n AA3, PurinBases, RnaBases, DnaBases, Bases, IonNames, WaterNames, SaccharideNames,\n ProteinBackboneAtoms, NucleicBackboneAtoms, ResidueTypeAtoms\n} from '../structure/structure-constants'\nimport Structure from '../structure/structure'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\n\nexport interface BondGraph {\n [k: number]: number[]\n}\n\nexport interface RingData {\n atomRings: number[][] // sparse array:\n // atomRings[atomIdx] -> array of ring indices\n rings: number[][] // rings as arrays of indices\n}\n\n/**\n * Residue type\n */\nexport default class ResidueType {\n resname: string\n atomTypeIdList: number[]\n hetero: number\n chemCompType: string\n bonds?: ResidueBonds\n rings?: RingData\n bondGraph?: BondGraph\n aromaticAtoms?: Uint8Array\n aromaticRings?: number[][]\n\n atomCount: number\n\n moleculeType: number\n backboneType: number\n backboneEndType: number\n backboneStartType: number\n backboneIndexList: number[]\n\n traceAtomIndex: number\n direction1AtomIndex: number\n direction2AtomIndex: number\n backboneStartAtomIndex: number\n backboneEndAtomIndex: number\n rungEndAtomIndex: number\n\n // Sparse array containing the reference atom index for each bond.\n bondReferenceAtomIndices: number[] = []\n\n /**\n * @param {Structure} structure - the structure object\n * @param {String} resname - name of the residue\n * @param {Array} atomTypeIdList - list of IDs of {@link AtomType}s corresponding\n * to the atoms of the residue\n * @param {Boolean} hetero - hetero flag\n * @param {String} chemCompType - chemical component type\n * @param {Object} [bonds] - TODO\n */\n constructor (readonly structure: Structure, resname: string, atomTypeIdList: number[], hetero: boolean, chemCompType: string, bonds?: ResidueBonds) {\n this.resname = resname\n this.atomTypeIdList = atomTypeIdList\n this.hetero = hetero ? 1 : 0\n this.chemCompType = chemCompType\n this.bonds = bonds\n this.atomCount = atomTypeIdList.length\n\n this.moleculeType = this.getMoleculeType()\n this.backboneType = this.getBackboneType(0)\n this.backboneEndType = this.getBackboneType(-1)\n this.backboneStartType = this.getBackboneType(1)\n this.backboneIndexList = this.getBackboneIndexList()\n\n const atomnames = ResidueTypeAtoms[ this.backboneType ]\n const atomnamesStart = ResidueTypeAtoms[ this.backboneStartType ]\n const atomnamesEnd = ResidueTypeAtoms[ this.backboneEndType ]\n\n const traceIndex = this.getAtomIndexByName(atomnames.trace)\n this.traceAtomIndex = defaults(traceIndex, -1)\n\n const dir1Index = this.getAtomIndexByName(atomnames.direction1)\n this.direction1AtomIndex = defaults(dir1Index, -1)\n\n const dir2Index = this.getAtomIndexByName(atomnames.direction2)\n this.direction2AtomIndex = defaults(dir2Index, -1)\n\n const bbStartIndex = this.getAtomIndexByName(atomnamesStart.backboneStart)\n this.backboneStartAtomIndex = defaults(bbStartIndex, -1)\n\n const bbEndIndex = this.getAtomIndexByName(atomnamesEnd.backboneEnd)\n this.backboneEndAtomIndex = defaults(bbEndIndex, -1)\n\n let rungEndIndex\n if (PurinBases.includes(resname)) {\n rungEndIndex = this.getAtomIndexByName('N1')\n } else {\n rungEndIndex = this.getAtomIndexByName('N3')\n }\n this.rungEndAtomIndex = defaults(rungEndIndex, -1)\n }\n\n getBackboneIndexList () {\n const backboneIndexList: number[] = []\n let atomnameList\n switch (this.moleculeType) {\n case ProteinType:\n atomnameList = ProteinBackboneAtoms\n break\n case RnaType:\n case DnaType:\n atomnameList = NucleicBackboneAtoms\n break\n default:\n return backboneIndexList\n }\n const atomMap = this.structure.atomMap\n const atomTypeIdList = this.atomTypeIdList\n for (let i = 0, il = this.atomCount; i < il; ++i) {\n const atomType = atomMap.get(atomTypeIdList[ i ])\n if (atomnameList.includes(atomType.atomname)) {\n backboneIndexList.push(i)\n }\n }\n return backboneIndexList\n }\n\n getMoleculeType () {\n if (this.isProtein()) {\n return ProteinType\n } else if (this.isRna()) {\n return RnaType\n } else if (this.isDna()) {\n return DnaType\n } else if (this.isWater()) {\n return WaterType\n } else if (this.isIon()) {\n return IonType\n } else if (this.isSaccharide()) {\n return SaccharideType\n } else {\n return UnknownType\n }\n }\n\n getBackboneType (position: number) {\n if (this.hasProteinBackbone(position)) {\n return ProteinBackboneType\n } else if (this.hasRnaBackbone(position)) {\n return RnaBackboneType\n } else if (this.hasDnaBackbone(position)) {\n return DnaBackboneType\n } else if (this.hasCgProteinBackbone(position)) {\n return CgProteinBackboneType\n } else if (this.hasCgRnaBackbone(position)) {\n return CgRnaBackboneType\n } else if (this.hasCgDnaBackbone(position)) {\n return CgDnaBackboneType\n } else {\n return UnknownBackboneType\n }\n }\n\n isProtein () {\n if (this.chemCompType) {\n return ChemCompProtein.includes(this.chemCompType)\n } else {\n return (\n this.hasAtomWithName('CA', 'C', 'N') ||\n AA3.includes(this.resname)\n )\n }\n }\n\n isCg () {\n const backboneType = this.backboneType\n return (\n backboneType === CgProteinBackboneType ||\n backboneType === CgRnaBackboneType ||\n backboneType === CgDnaBackboneType\n )\n }\n\n isNucleic () {\n return this.isRna() || this.isDna()\n }\n\n isRna () {\n if (this.chemCompType) {\n return ChemCompRna.includes(this.chemCompType)\n } else if (this.hetero === 1) {\n return false\n } else {\n return (\n this.hasAtomWithName(\n [ 'P', \"O3'\", 'O3*' ], [ \"C4'\", 'C4*' ], [ \"O2'\", 'O2*', \"F2'\", 'F2*' ]\n ) ||\n (RnaBases.includes(this.resname) &&\n (this.hasAtomWithName([ \"O2'\", 'O2*', \"F2'\", 'F2*' ])))\n )\n }\n }\n\n isDna () {\n if (this.chemCompType) {\n return ChemCompDna.includes(this.chemCompType)\n } else if (this.hetero === 1) {\n return false\n } else {\n return (\n (this.hasAtomWithName([ 'P', \"O3'\", 'O3*' ], [ \"C3'\", 'C3*' ]) &&\n !this.hasAtomWithName([ \"O2'\", 'O2*', \"F2'\", 'F2*' ])) ||\n DnaBases.includes(this.resname)\n )\n }\n }\n\n isHetero () {\n return this.hetero === 1\n }\n\n isIon () {\n return IonNames.includes(this.resname)\n }\n\n isWater () {\n return WaterNames.includes(this.resname)\n }\n\n isSaccharide () {\n if (this.chemCompType) {\n return ChemCompSaccharide.includes(this.chemCompType)\n } else {\n return SaccharideNames.includes(this.resname)\n }\n }\n\n isStandardAminoacid () {\n return AA3.includes(this.resname)\n }\n\n isStandardBase () {\n return Bases.includes(this.resname)\n }\n\n hasBackboneAtoms (position: number, type: number) {\n const atomnames = ResidueTypeAtoms[ type ]\n if (position === -1) {\n return this.hasAtomWithName(\n atomnames.trace,\n atomnames.backboneEnd,\n atomnames.direction1,\n atomnames.direction2\n )\n } else if (position === 0) {\n return this.hasAtomWithName(\n atomnames.trace,\n atomnames.direction1,\n atomnames.direction2\n )\n } else if (position === 1) {\n return this.hasAtomWithName(\n atomnames.trace,\n atomnames.backboneStart,\n atomnames.direction1,\n atomnames.direction2\n )\n } else {\n return this.hasAtomWithName(\n atomnames.trace,\n atomnames.backboneStart,\n atomnames.backboneEnd,\n atomnames.direction1,\n atomnames.direction2\n )\n }\n }\n\n hasProteinBackbone (position: number) {\n return (\n this.isProtein() &&\n this.hasBackboneAtoms(position, ProteinBackboneType)\n )\n }\n\n hasRnaBackbone (position: number) {\n return (\n this.isRna() &&\n this.hasBackboneAtoms(position, RnaBackboneType)\n )\n }\n\n hasDnaBackbone (position: number) {\n return (\n this.isDna() &&\n this.hasBackboneAtoms(position, DnaBackboneType)\n )\n }\n\n hasCgProteinBackbone (position: number) {\n return (\n this.atomCount < 7 &&\n this.isProtein() &&\n this.hasBackboneAtoms(position, CgProteinBackboneType)\n )\n }\n\n hasCgRnaBackbone (position: number) {\n return (\n this.atomCount < 11 &&\n this.isRna() &&\n this.hasBackboneAtoms(position, CgRnaBackboneType)\n )\n }\n\n hasCgDnaBackbone (position: number) {\n return (\n this.atomCount < 11 &&\n this.isDna() &&\n this.hasBackboneAtoms(position, CgDnaBackboneType)\n )\n }\n\n hasBackbone (position: number) {\n return (\n this.hasProteinBackbone(position) ||\n this.hasRnaBackbone(position) ||\n this.hasDnaBackbone(position) ||\n this.hasCgProteinBackbone(position) ||\n this.hasCgRnaBackbone(position) ||\n this.hasCgDnaBackbone(position)\n )\n }\n\n getAtomIndexByName (atomname: string|string[]) {\n const n = this.atomCount\n const atomMap = this.structure.atomMap\n const atomTypeIdList = this.atomTypeIdList\n if (Array.isArray(atomname)) {\n for (let i = 0; i < n; ++i) {\n const index = atomTypeIdList[ i ]\n if (atomname.includes(atomMap.get(index).atomname)) {\n return i\n }\n }\n } else {\n for (let i = 0; i < n; ++i) {\n const index = atomTypeIdList[ i ]\n if (atomname === atomMap.get(index).atomname) {\n return i\n }\n }\n }\n return undefined\n }\n\n hasAtomWithName (...atomnames: (string|string[])[]) {\n const n = atomnames.length\n for (let i = 0; i < n; ++i) {\n if (atomnames[ i ] === undefined) continue\n if (this.getAtomIndexByName(atomnames[ i ]) === undefined) {\n return false\n }\n }\n return true\n }\n\n getBonds (r?: ResidueProxy) {\n if (this.bonds === undefined) {\n this.bonds = calculateResidueBonds(r!) // TODO\n }\n return this.bonds\n }\n\n getRings () {\n if (this.rings === undefined) {\n this.calculateRings()\n }\n return this.rings\n }\n\n getBondGraph () {\n if (this.bondGraph === undefined) {\n this.calculateBondGraph()\n }\n return this.bondGraph\n }\n\n getAromatic (a?: AtomProxy) {\n if (this.aromaticAtoms === undefined) {\n this.calculateAromatic(this.structure.getResidueProxy((a!).residueIndex)) // TODO\n }\n return this.aromaticAtoms\n }\n\n getAromaticRings (r?: ResidueProxy) {\n if (this.aromaticRings === undefined) {\n this.calculateAromatic(r!) // TODO\n }\n return this.aromaticRings\n }\n\n /**\n * @return {Object} bondGraph - represents the bonding in this\n * residue: { ai1: [ ai2, ai3, ...], ...}\n */\n calculateBondGraph () {\n const bondGraph: BondGraph = this.bondGraph = {}\n const bonds = this.getBonds()\n const nb = bonds.atomIndices1.length\n const atomIndices1 = bonds.atomIndices1\n const atomIndices2 = bonds.atomIndices2\n\n for (let i = 0; i < nb; ++i) {\n const ai1 = atomIndices1[i]\n const ai2 = atomIndices2[i]\n\n const a1 = bondGraph[ ai1 ] = bondGraph[ ai1 ] || []\n a1.push(ai2)\n\n const a2 = bondGraph[ ai2 ] = bondGraph[ ai2 ] || []\n a2.push(ai1)\n }\n }\n\n /**\n * Find all rings up to 2 * RingFinderMaxDepth\n */\n calculateRings () {\n const bondGraph = this.getBondGraph()! // TODO\n const state = RingFinderState(bondGraph, this.atomCount)\n\n for (let i = 0; i < state.count; i++) {\n if (state.visited[i] >= 0) continue\n findRings(state, i)\n }\n\n this.rings = { atomRings: state.atomRings, rings: state.rings }\n }\n\n isAromatic (atom: AtomProxy) {\n this.aromaticAtoms = this.getAromatic(atom)! // TODO\n return this.aromaticAtoms[atom.index - atom.residueAtomOffset] === 1\n }\n\n calculateAromatic (r: ResidueProxy) {\n const aromaticAtoms = this.aromaticAtoms = new Uint8Array(this.atomCount)\n const rings = this.getRings()!.rings\n\n const aromaticRingFlags = rings.map(ring => {\n return isRingAromatic(ring.map(idx => {\n return this.structure.getAtomProxy(idx + r.atomOffset)\n }))\n })\n\n const aromaticRings: number[][] = this.aromaticRings = []\n rings.forEach((ring, i) => {\n if (aromaticRingFlags[i]) {\n aromaticRings.push(ring)\n ring.forEach(idx => aromaticAtoms[idx] = 1)\n }\n })\n }\n\n /**\n * For bonds with order > 1, pick a reference atom\n * @return {undefined}\n */\n assignBondReferenceAtomIndices () {\n const bondGraph = this.getBondGraph()! // TODO\n const rings = this.getRings()! // TODO\n const atomRings = rings.atomRings\n const ringData = rings.rings\n\n const bonds = this.bonds! // TODO\n const atomIndices1 = bonds.atomIndices1\n const atomIndices2 = bonds.atomIndices2\n const bondOrders = bonds.bondOrders\n const bondReferenceAtomIndices = this.bondReferenceAtomIndices\n\n const nb = bonds.atomIndices1.length\n\n bondReferenceAtomIndices.length = 0 // reset array\n\n for (let i = 0; i < nb; ++i) {\n // Not required for single bonds\n if (bondOrders[i] <= 1) continue\n\n let refRing\n\n const ai1 = atomIndices1[i]\n const ai2 = atomIndices2[i]\n\n const rings1 = atomRings[ ai1 ]\n const rings2 = atomRings[ ai2 ]\n // Are both atoms in a ring?\n if (rings1 && rings2) {\n // Are they in the same ring? (If not, ignore ring info)\n for (let ri1 = 0; ri1 < rings1.length; ri1++){\n if (rings2.indexOf(rings1[ ri1 ]) !== -1) {\n refRing = ringData[ rings1[ ri1 ] ]\n break\n }\n }\n }\n\n // Find the first neighbour.\n if (bondGraph[ ai1 ].length > 1) {\n for (let j = 0; j < bondGraph[ ai1 ].length; ++j) {\n const ai3 = bondGraph[ ai1 ][ j ]\n if (ai3 !== ai2) {\n if (refRing === undefined || refRing.indexOf(ai3) !== -1){\n bondReferenceAtomIndices[i] = ai3\n break\n }\n }\n }\n } else if (bondGraph[ ai2 ].length > 1) {\n for (let j = 0; j < bondGraph[ ai2 ].length; ++j) {\n const ai3 = bondGraph[ ai2 ][ j ]\n if (ai3 !== ai1) {\n if (refRing === undefined || refRing.indexOf(ai3) !== -1){\n bondReferenceAtomIndices[i] = ai3\n break\n }\n }\n }\n } // No reference atom could be found (e.g. diatomic molecule/fragment)\n }\n }\n\n getBondIndex (atomIndex1: number, atomIndex2: number) {\n const bonds = this.bonds! // TODO\n const atomIndices1 = bonds.atomIndices1\n const atomIndices2 = bonds.atomIndices2\n let idx1 = atomIndices1.indexOf(atomIndex1)\n let idx2 = atomIndices2.indexOf(atomIndex2)\n const _idx2 = idx2\n while (idx1 !== -1) {\n while (idx2 !== -1) {\n if (idx1 === idx2) return idx1\n idx2 = atomIndices2.indexOf(atomIndex2, idx2 + 1)\n }\n idx1 = atomIndices1.indexOf(atomIndex1, idx1 + 1)\n idx2 = _idx2\n }\n // returns undefined when no bond is found\n }\n\n getBondReferenceAtomIndex (atomIndex1: number, atomIndex2: number) {\n const bondIndex = this.getBondIndex(atomIndex1, atomIndex2)\n if (bondIndex === undefined) return undefined\n if (this.bondReferenceAtomIndices.length === 0) {\n this.assignBondReferenceAtomIndices()\n }\n return this.bondReferenceAtomIndices[ bondIndex ]\n }\n}\n\n//\n\nconst AromaticRingElements = [\n Elements.B, Elements.C, Elements.N, Elements.O,\n Elements.SI, Elements.P, Elements.S,\n Elements.GE, Elements.AS,\n Elements.SN, Elements.SB,\n Elements.BI\n]\nconst AromaticRingPlanarityThreshold = 0.05\n\nfunction isRingAromatic (ring: AtomProxy[]) {\n if (ring.some(a => !AromaticRingElements.includes(a.number))) return false\n\n let i = 0\n const coords = new Matrix(3, ring.length)\n const cd = coords.data\n\n ring.forEach(a => {\n cd[ i + 0 ] = a.x\n cd[ i + 1 ] = a.y\n cd[ i + 2 ] = a.z\n i += 3\n })\n\n const pa = new PrincipalAxes(coords)\n\n return pa.vecC.length() < AromaticRingPlanarityThreshold\n}\n\n//\n\n/**\n * Ring finding code below adapted from MolQL\n * Copyright (c) 2017 MolQL contributors, licensed under MIT\n * @author David Sehnal \n */\n\nfunction addRing(state: RingFinderState, a: number, b: number) {\n // only \"monotonous\" rings\n if (b < a) return\n\n const { pred, color, left, right } = state\n const nc = ++state.currentColor\n\n let current = a\n\n for (let t = 0; t < RingFinderMaxDepth; t++) {\n color[current] = nc\n current = pred[current]\n if (current < 0) break\n }\n\n let leftOffset = 0\n let rightOffset = 0\n\n let found = false\n let target = 0\n current = b\n for (let t = 0; t < RingFinderMaxDepth; t++) {\n if (color[current] === nc) {\n target = current\n found = true\n break\n }\n right[rightOffset++] = current\n current = pred[current]\n if (current < 0) break\n }\n if (!found) return\n\n current = a\n for (let t = 0; t < RingFinderMaxDepth; t++) {\n left[leftOffset++] = current\n if (target === current) break\n current = pred[current]\n if (current < 0) break\n }\n\n const rn = leftOffset + rightOffset\n const ring: number[] = new Array(rn)\n let ringOffset = 0;\n for (let t = 0; t < leftOffset; t++) {\n ring[ringOffset++] = left[t]\n }\n for (let t = rightOffset - 1; t >= 0; t--) {\n ring[ringOffset++] = right[t]\n }\n\n const ri = state.rings.length\n // set atomRing indices:\n for (let i = 0; i < rn; ++i) {\n const ai = ring[i]\n if (state.atomRings[ai]) {\n state.atomRings[ai].push(ri)\n } else {\n state.atomRings[ai] = [ri]\n }\n }\n\n state.rings.push(ring)\n}\n\nfunction findRings(state: RingFinderState, from: number) {\n const { bonds, visited, queue, pred } = state\n\n visited[from] = 1\n queue[0] = from\n\n let head = 0\n let size = 1\n\n while (head < size) {\n const top = queue[head++]\n const start = 0\n if (bonds[top] === undefined) {\n continue\n }\n const end = bonds[top].length\n\n for (let i = start; i < end; i++) {\n const other = bonds[top][i]\n\n if (visited[other] > 0) {\n if (pred[other] !== top && pred[top] !== other) {\n addRing(state, top, other)\n }\n continue\n }\n\n visited[other] = 1\n queue[size++] = other\n pred[other] = top\n }\n }\n}\n\nconst RingFinderMaxDepth = 4\n\ninterface RingFinderState {\n count: number,\n visited: Int32Array,\n queue: Int32Array,\n color: Int32Array,\n pred: Int32Array,\n\n left: Int32Array,\n right: Int32Array,\n\n currentColor: number,\n\n rings: number[][],\n atomRings: number[][],\n\n bonds: BondGraph\n}\n\nfunction RingFinderState(bonds: BondGraph, capacity: number): RingFinderState {\n const state = {\n count: capacity,\n visited: new Int32Array(capacity),\n queue: new Int32Array(capacity),\n pred: new Int32Array(capacity),\n left: new Int32Array(RingFinderMaxDepth),\n right: new Int32Array(RingFinderMaxDepth),\n color: new Int32Array(capacity),\n currentColor: 0,\n rings: [],\n atomRings: [],\n bonds\n }\n for (let i = 0; i < capacity; i++) {\n state.visited[i] = -1\n state.pred[i] = -1\n }\n return state\n}\n","/**\n * @file Residue Map\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport { ResidueBonds } from '../structure/structure-utils'\nimport ResidueType from './residue-type'\n\nfunction getHash (resname: string, atomTypeIdList: number[], hetero: boolean, chemCompType = '') {\n return (\n resname + '|' +\n atomTypeIdList.join(',') + '|' +\n (hetero ? 1 : 0) + '|' +\n chemCompType\n )\n}\n\nclass ResidueMap {\n dict: { [k: string]: number } = {}\n list: ResidueType[] = []\n\n constructor (readonly structure: Structure) {}\n\n add (resname: string, atomTypeIdList: number[], hetero: boolean, chemCompType = '', bonds?: ResidueBonds) {\n resname = resname.toUpperCase()\n const hash = getHash(resname, atomTypeIdList, hetero, chemCompType)\n let id = this.dict[ hash ]\n if (id === undefined) {\n const residueType = new ResidueType(\n this.structure, resname, atomTypeIdList, hetero, chemCompType, bonds\n )\n id = this.list.length\n this.dict[ hash ] = id\n this.list.push(residueType)\n }\n return id\n }\n\n get (id: number) {\n return this.list[ id ]\n }\n}\n\nexport default ResidueMap\n","/**\n * @file Bond Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport Structure from '../structure/structure'\nimport BondStore from '../store/bond-store'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Bond proxy\n */\nclass BondProxy {\n index: number\n\n bondStore: BondStore\n\n private _v12: Vector3\n private _v13: Vector3\n private _ap1: AtomProxy\n private _ap2: AtomProxy\n private _ap3: AtomProxy\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.bondStore = structure.bondStore\n\n this._v12 = new Vector3()\n this._v13 = new Vector3()\n this._ap1 = this.structure.getAtomProxy()\n this._ap2 = this.structure.getAtomProxy()\n this._ap3 = this.structure.getAtomProxy()\n }\n\n /**\n * @type {AtomProxy}\n */\n get atom1 () {\n return this.structure.getAtomProxy(this.atomIndex1)\n }\n\n /**\n * @type {AtomProxy}\n */\n get atom2 () {\n return this.structure.getAtomProxy(this.atomIndex2)\n }\n\n /**\n * @type {Integer}\n */\n get atomIndex1 () {\n return this.bondStore.atomIndex1[ this.index ]\n }\n set atomIndex1 (value) {\n this.bondStore.atomIndex1[ this.index ] = value\n }\n\n /**\n * @type {Integer}\n */\n get atomIndex2 () {\n return this.bondStore.atomIndex2[ this.index ]\n }\n set atomIndex2 (value) {\n this.bondStore.atomIndex2[ this.index ] = value\n }\n\n /**\n * @type {Integer}\n */\n get bondOrder () {\n return this.bondStore.bondOrder[ this.index ]\n }\n set bondOrder (value) {\n this.bondStore.bondOrder[ this.index ] = value\n }\n\n getOtherAtomIndex (atomIndex: number) {\n return atomIndex === this.atomIndex1 ? this.atomIndex2 : this.atomIndex1\n }\n\n getOtherAtom (atom: AtomProxy) {\n return this.structure.getAtomProxy(this.getOtherAtomIndex(atom.index))\n }\n\n /**\n * Get reference atom index for the bond\n * @return {Integer|undefined} atom index, or `undefined` if unavailable\n */\n getReferenceAtomIndex () {\n const ap1 = this._ap1\n const ap2 = this._ap2\n ap1.index = this.atomIndex1\n ap2.index = this.atomIndex2\n if (ap1.residueIndex !== ap2.residueIndex) {\n return undefined // Bond between residues, for now ignore (could detect)\n }\n const typeAtomIndex1 = ap1.index - ap1.residueAtomOffset\n const typeAtomIndex2 = ap2.index - ap2.residueAtomOffset\n const residueType = ap1.residueType\n const ix = residueType.getBondReferenceAtomIndex(typeAtomIndex1, typeAtomIndex2)\n if (ix !== undefined) {\n return ix + ap1.residueAtomOffset\n } else {\n console.warn('No reference atom found', ap1.index, ap2.index)\n }\n }\n\n /**\n * calculate shift direction for displaying double/triple bonds\n * @param {Vector3} [v] pre-allocated output vector\n * @return {Vector3} the shift direction vector\n */\n calculateShiftDir (v = new Vector3()) {\n const ap1 = this._ap1\n const ap2 = this._ap2\n const ap3 = this._ap3\n const v12 = this._v12\n const v13 = this._v13\n\n ap1.index = this.atomIndex1\n ap2.index = this.atomIndex2\n const ai3 = this.getReferenceAtomIndex()\n\n v12.subVectors(ap1 as any, ap2 as any).normalize() // TODO\n if (ai3 !== undefined) {\n ap3.index = ai3\n v13.subVectors(ap1 as any, ap3 as any) // TODO\n } else {\n v13.copy(ap1 as any) // no reference point, use origin // TODO\n }\n v13.normalize()\n\n // make sure v13 and v12 are not colinear\n let dp = v12.dot(v13)\n if (1 - Math.abs(dp) < 1e-5) {\n v13.set(1, 0, 0)\n dp = v12.dot(v13)\n if (1 - Math.abs(dp) < 1e-5) {\n v13.set(0, 1, 0)\n dp = v12.dot(v13)\n }\n }\n\n return v.copy(v13.sub(v12.multiplyScalar(dp))).normalize()\n }\n\n qualifiedName () {\n return this.atomIndex1 + '=' + this.atomIndex2\n }\n\n /**\n * Clone object\n * @return {BondProxy} cloned bond\n */\n clone () {\n return new BondProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n atomIndex1: this.atomIndex1,\n atomIndex2: this.atomIndex2,\n bondOrder: this.bondOrder\n }\n }\n}\n\nexport default BondProxy\n","/**\n * @file Residue Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { NumberArray } from '../types'\nimport { defaults } from '../utils'\nimport {\n SecStrucHelix, SecStrucSheet, SecStrucTurn,\n ProteinType, RnaType, DnaType, WaterType, IonType, SaccharideType,\n CgProteinBackboneType, CgRnaBackboneType, CgDnaBackboneType,\n AA1\n} from '../structure/structure-constants'\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\n\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\nimport AtomStore from '../store/atom-store'\n\nimport AtomMap from '../store/atom-map'\nimport ResidueMap from '../store/residue-map'\n\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueType, { RingData } from '../store/residue-type';\nimport { ResidueBonds } from '../structure/structure-utils';\nimport AtomType from '../store/atom-type';\nimport ChainProxy from './chain-proxy';\nimport Entity from '../structure/entity';\n\n/**\n * Residue proxy\n */\nclass ResidueProxy {\n index: number\n\n chainStore: ChainStore\n residueStore: ResidueStore\n atomStore: AtomStore\n\n residueMap: ResidueMap\n atomMap: AtomMap\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n this.atomStore = structure.atomStore\n this.residueMap = structure.residueMap\n this.atomMap = structure.atomMap\n }\n\n /**\n * Entity\n * @type {Entity}\n */\n get entity (): Entity {\n return this.structure.entityList[ this.entityIndex ]\n }\n get entityIndex () {\n return this.chainStore.entityIndex[ this.chainIndex ]\n }\n /**\n * Chain\n * @type {ChainProxy}\n */\n get chain (): ChainProxy {\n return this.structure.getChainProxy(this.chainIndex)\n }\n\n get chainIndex () {\n return this.residueStore.chainIndex[ this.index ]\n }\n set chainIndex (value) {\n this.residueStore.chainIndex[ this.index ] = value\n }\n\n get atomOffset () {\n return this.residueStore.atomOffset[ this.index ]\n }\n set atomOffset (value) {\n this.residueStore.atomOffset[ this.index ] = value\n }\n\n /**\n * Atom count\n * @type {Integer}\n */\n get atomCount () {\n return this.residueStore.atomCount[ this.index ]\n }\n set atomCount (value) {\n this.residueStore.atomCount[ this.index ] = value\n }\n\n get atomEnd () {\n return this.atomOffset + this.atomCount - 1\n }\n\n //\n\n get modelIndex () {\n return this.chainStore.modelIndex[ this.chainIndex ]\n }\n /**\n * Chain name\n * @type {String}\n */\n get chainname () {\n return this.chainStore.getChainname(this.chainIndex)\n }\n /**\n * Chain id\n * @type {String}\n */\n get chainid () {\n return this.chainStore.getChainid(this.chainIndex)\n }\n\n //\n\n /**\n * Residue number/label\n * @type {Integer}\n */\n get resno () {\n return this.residueStore.resno[ this.index ]\n }\n set resno (value) {\n this.residueStore.resno[ this.index ] = value\n }\n\n /**\n * Secondary structure code\n * @type {String}\n */\n get sstruc () {\n return this.residueStore.getSstruc(this.index)\n }\n set sstruc (value) {\n this.residueStore.setSstruc(this.index, value)\n }\n\n /**\n * Insertion code\n * @type {String}\n */\n get inscode () {\n return this.residueStore.getInscode(this.index)\n }\n set inscode (value) {\n this.residueStore.setInscode(this.index, value)\n }\n\n //\n\n get residueType (): ResidueType {\n return this.residueMap.get(this.residueStore.residueTypeId[ this.index ])\n }\n\n /**\n * Residue name\n * @type {String}\n */\n get resname () {\n return this.residueType.resname\n }\n /**\n * Hetero flag\n * @type {Boolean}\n */\n get hetero () {\n return this.residueType.hetero\n }\n get moleculeType () {\n return this.residueType.moleculeType\n }\n get backboneType () {\n return this.residueType.backboneType\n }\n get backboneStartType () {\n return this.residueType.backboneStartType\n }\n get backboneEndType () {\n return this.residueType.backboneEndType\n }\n get traceAtomIndex () {\n return this.residueType.traceAtomIndex + this.atomOffset\n }\n get direction1AtomIndex () {\n return this.residueType.direction1AtomIndex + this.atomOffset\n }\n get direction2AtomIndex () {\n return this.residueType.direction2AtomIndex + this.atomOffset\n }\n get backboneStartAtomIndex () {\n return this.residueType.backboneStartAtomIndex + this.atomOffset\n }\n get backboneEndAtomIndex () {\n return this.residueType.backboneEndAtomIndex + this.atomOffset\n }\n get rungEndAtomIndex () {\n return this.residueType.rungEndAtomIndex + this.atomOffset\n }\n\n //\n\n get x () {\n let x = 0\n for (let i = this.atomOffset; i <= this.atomEnd; ++i) {\n x += this.atomStore.x[ i ]\n }\n return x / this.atomCount\n }\n\n get y () {\n let y = 0\n for (let i = this.atomOffset; i <= this.atomEnd; ++i) {\n y += this.atomStore.y[ i ]\n }\n return y / this.atomCount\n }\n\n get z () {\n let z = 0\n for (let i = this.atomOffset; i <= this.atomEnd; ++i) {\n z += this.atomStore.z[ i ]\n }\n return z / this.atomCount\n }\n\n //\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (ap: AtomProxy) => void, selection?: Selection) {\n const count = this.atomCount\n const offset = this.atomOffset\n const ap = this.structure._ap\n const end = offset + count\n\n if (selection && selection.atomOnlyTest) {\n const atomOnlyTest = selection.atomOnlyTest\n for (let i = offset; i < end; ++i) {\n ap.index = i\n if (atomOnlyTest(ap)) callback(ap)\n }\n } else {\n for (let i = offset; i < end; ++i) {\n ap.index = i\n callback(ap)\n }\n }\n }\n\n //\n\n /**\n * Write residue center position to array\n * @param {Array|TypedArray} [array] - target array\n * @param {Integer} [offset] - the offset\n * @return {Array|TypedArray} target array\n */\n positionToArray (array: NumberArray = [], offset = 0) {\n array[ offset + 0 ] = this.x\n array[ offset + 1 ] = this.y\n array[ offset + 2 ] = this.z\n\n return array\n }\n\n //\n\n /**\n * If residue is from a protein\n * @return {Boolean} flag\n */\n isProtein () {\n return this.residueType.moleculeType === ProteinType\n }\n\n /**\n * If residue is nucleic\n * @return {Boolean} flag\n */\n isNucleic () {\n const moleculeType = this.residueType.moleculeType\n return moleculeType === RnaType || moleculeType === DnaType\n }\n\n /**\n * If residue is rna\n * @return {Boolean} flag\n */\n isRna () {\n return this.residueType.moleculeType === RnaType\n }\n\n /**\n * If residue is dna\n * @return {Boolean} flag\n */\n isDna () {\n return this.residueType.moleculeType === DnaType\n }\n\n /**\n * If residue is coarse-grain\n * @return {Boolean} flag\n */\n isCg () {\n const backboneType = this.residueType.backboneType\n return (\n backboneType === CgProteinBackboneType ||\n backboneType === CgRnaBackboneType ||\n backboneType === CgDnaBackboneType\n )\n }\n\n /**\n * If residue is from a polymer\n * @return {Boolean} flag\n */\n isPolymer () {\n if (this.structure.entityList.length > 0) {\n return this.entity.isPolymer()\n } else {\n const moleculeType = this.residueType.moleculeType\n return (\n moleculeType === ProteinType ||\n moleculeType === RnaType ||\n moleculeType === DnaType\n )\n }\n }\n\n /**\n * If residue is hetero\n * @return {Boolean} flag\n */\n isHetero () {\n return this.residueType.hetero === 1\n }\n\n /**\n * If residue is a water molecule\n * @return {Boolean} flag\n */\n isWater () {\n return this.residueType.moleculeType === WaterType\n }\n\n /**\n * If residue is an ion\n * @return {Boolean} flag\n */\n isIon () {\n return this.residueType.moleculeType === IonType\n }\n\n /**\n * If residue is a saccharide\n * @return {Boolean} flag\n */\n isSaccharide () {\n return this.residueType.moleculeType === SaccharideType\n }\n\n isStandardAminoacid () {\n return this.residueType.isStandardAminoacid()\n }\n\n isStandardBase () {\n return this.residueType.isStandardBase()\n }\n\n /**\n * If residue is part of a helix\n * @return {Boolean} flag\n */\n isHelix () {\n return SecStrucHelix.includes(this.sstruc)\n }\n\n /**\n * If residue is part of a sheet\n * @return {Boolean} flag\n */\n isSheet () {\n return SecStrucSheet.includes(this.sstruc)\n }\n\n /**\n * If residue is part of a turn\n * @return {Boolean} flag\n */\n isTurn () {\n return SecStrucTurn.includes(this.sstruc) && this.isProtein()\n }\n\n getAtomType (index: number): AtomType {\n return this.atomMap.get(this.atomStore.atomTypeId[ index ])\n }\n\n getResname1 () {\n // FIXME nucleic support\n return AA1[ this.resname.toUpperCase() ] || 'X'\n }\n\n getBackboneType (position: number) {\n switch (position) {\n case -1:\n return this.residueType.backboneStartType\n case 1:\n return this.residueType.backboneEndType\n default:\n return this.residueType.backboneType\n }\n }\n\n getAtomIndexByName (atomname: string) {\n let index = this.residueType.getAtomIndexByName(atomname)\n if (index !== undefined) {\n index += this.atomOffset\n }\n return index\n }\n\n hasAtomWithName (atomname: string) {\n return this.residueType.hasAtomWithName(atomname)\n }\n\n getAtomnameList () {\n console.warn('getAtomnameList - might be expensive')\n\n const n = this.atomCount\n const offset = this.atomOffset\n const list = new Array(n)\n for (let i = 0; i < n; ++i) {\n list[ i ] = this.getAtomType(offset + i).atomname\n }\n return list\n }\n\n /**\n * If residue is connected to another\n * @param {ResidueProxy} rNext - the other residue\n * @return {Boolean} - flag\n */\n connectedTo (rNext: ResidueProxy) {\n const bbAtomEnd = this.structure.getAtomProxy(this.backboneEndAtomIndex)\n const bbAtomStart = this.structure.getAtomProxy(rNext.backboneStartAtomIndex)\n if (bbAtomEnd && bbAtomStart) {\n return bbAtomEnd.connectedTo(bbAtomStart)\n } else {\n return false\n }\n }\n\n getNextConnectedResidue () {\n const rOffset = this.chainStore.residueOffset[ this.chainIndex ]\n const rCount = this.chainStore.residueCount[ this.chainIndex ]\n const nextIndex = this.index + 1\n if (nextIndex < rOffset + rCount) {\n const rpNext = this.structure.getResidueProxy(nextIndex)\n if (this.connectedTo(rpNext)) {\n return rpNext\n }\n } else if (nextIndex === rOffset + rCount) { // cyclic\n const rpFirst = this.structure.getResidueProxy(rOffset)\n if (this.connectedTo(rpFirst)) {\n return rpFirst\n }\n }\n return undefined\n }\n\n getPreviousConnectedResidue (residueProxy?: ResidueProxy) {\n const rOffset = this.chainStore.residueOffset[ this.chainIndex ]\n const prevIndex = this.index - 1\n if (prevIndex >= rOffset) {\n const rpPrev = defaults(residueProxy, this.structure.getResidueProxy())\n rpPrev.index = prevIndex\n if (rpPrev.connectedTo(this)) {\n return rpPrev\n }\n } else if (prevIndex === rOffset - 1) { // cyclic\n const rCount = this.chainStore.residueCount[ this.chainIndex ]\n const rpLast = defaults(residueProxy, this.structure.getResidueProxy())\n rpLast.index = rOffset + rCount - 1\n if (rpLast.connectedTo(this)) {\n return rpLast\n }\n }\n return undefined\n }\n\n getBonds (): ResidueBonds {\n return this.residueType.getBonds(this)\n }\n\n getRings (): RingData|undefined {\n return this.residueType.getRings()\n }\n\n getAromaticRings () {\n return this.residueType.getAromaticRings(this)\n }\n\n qualifiedName (noResname = false) {\n let name = ''\n if (this.resname && !noResname) name += '[' + this.resname + ']'\n if (this.resno !== undefined) name += this.resno\n if (this.inscode) name += '^' + this.inscode\n if (this.chain) name += ':' + this.chainname\n name += '/' + this.modelIndex\n return name\n }\n\n /**\n * Clone object\n * @return {ResidueProxy} cloned residue\n */\n clone () {\n return new ResidueProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n index: this.index,\n chainIndex: this.chainIndex,\n atomOffset: this.atomOffset,\n atomCount: this.atomCount,\n\n resno: this.resno,\n resname: this.resname,\n sstruc: this.sstruc\n }\n }\n}\n\nexport default ResidueProxy\n","/**\n * @file Polymer\n * @author Alexander Rose \n * @private\n */\n\n// import { Log } from '../globals'\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\n\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\nimport AtomStore from '../store/atom-store'\n\nimport ResidueProxy from '../proxy/residue-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Polymer\n */\nclass Polymer {\n chainStore: ChainStore\n residueStore: ResidueStore\n atomStore: AtomStore\n\n residueCount: number\n\n isPrevConnected: boolean\n isNextConnected: boolean\n isNextNextConnected: boolean\n isCyclic: boolean\n\n private __residueProxy: ResidueProxy\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} residueIndexStart - the index of the first residue\n * @param {Integer} residueIndexEnd - the index of the last residue\n */\n constructor (readonly structure: Structure, readonly residueIndexStart: number, readonly residueIndexEnd: number) {\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n this.atomStore = structure.atomStore\n\n /**\n * @type {Integer}\n */\n this.residueCount = residueIndexEnd - residueIndexStart + 1\n\n const rpStart = this.structure.getResidueProxy(this.residueIndexStart)\n const rpEnd = this.structure.getResidueProxy(this.residueIndexEnd)\n this.isPrevConnected = rpStart.getPreviousConnectedResidue() !== undefined\n const rpNext = rpEnd.getNextConnectedResidue()\n this.isNextConnected = rpNext !== undefined\n this.isNextNextConnected = rpNext !== undefined && rpNext.getNextConnectedResidue() !== undefined\n this.isCyclic = rpEnd.connectedTo(rpStart)\n\n this.__residueProxy = this.structure.getResidueProxy()\n\n // console.log( this.qualifiedName(), this );\n }\n\n get chainIndex () {\n return this.residueStore.chainIndex[ this.residueIndexStart ]\n }\n get modelIndex () {\n return this.chainStore.modelIndex[ this.chainIndex ]\n }\n\n /**\n * @type {String}\n */\n get chainname () {\n return this.chainStore.getChainname(this.chainIndex)\n }\n\n //\n\n /**\n * If first residue is from aprotein\n * @return {Boolean} flag\n */\n isProtein () {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.isProtein()\n }\n\n /**\n * If atom is part of a coarse-grain group\n * @return {Boolean} flag\n */\n isCg () {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.isCg()\n }\n\n /**\n * If atom is part of a nucleic molecule\n * @return {Boolean} flag\n */\n isNucleic () {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.isNucleic()\n }\n\n getMoleculeType () {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.moleculeType\n }\n\n getBackboneType (position: number) {\n this.__residueProxy.index = this.residueIndexStart\n return this.__residueProxy.getBackboneType(position)\n }\n\n getAtomIndexByType (index: number, type: string) {\n // TODO pre-calculate, add to residueStore???\n\n if (this.isCyclic) {\n if (index === -1) {\n index = this.residueCount - 1\n } else if (index === this.residueCount) {\n index = 0\n }\n } else {\n if (index === -1 && !this.isPrevConnected) index += 1\n if (index === this.residueCount && !this.isNextNextConnected) index -= 1\n // if( index === this.residueCount - 1 && !this.isNextConnected ) index -= 1;\n }\n\n const rp = this.__residueProxy\n rp.index = this.residueIndexStart + index\n let aIndex\n\n switch (type) {\n case 'trace':\n aIndex = rp.traceAtomIndex\n break\n case 'direction1':\n aIndex = rp.direction1AtomIndex\n break\n case 'direction2':\n aIndex = rp.direction2AtomIndex\n break\n default:\n aIndex = rp.getAtomIndexByName(type)\n }\n\n // if (!ap){\n // console.log(this, type, rp.residueType)\n // // console.log(rp.qualifiedName(), rp.index, index, this.residueCount - 1)\n // // rp.index = this.residueIndexStart;\n // // console.log(rp.qualifiedName(), this.residueIndexStart)\n // // rp.index = this.residueIndexEnd;\n // // console.log(rp.qualifiedName(), this.residueIndexEnd)\n // }\n\n return aIndex\n }\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (ap: AtomProxy) => void, selection?: Selection) {\n this.eachResidue(function (rp) {\n rp.eachAtom(callback, selection)\n })\n }\n\n eachAtomN (n: number, callback: (...apArray: AtomProxy[]) => void, type: string) {\n const m = this.residueCount\n const array: AtomProxy[] = new Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = this.structure.getAtomProxy(this.getAtomIndexByType(i, type))\n }\n callback.apply(this, array)\n\n for (var j = n; j < m; ++j) {\n for (let i = 1; i < n; ++i) {\n array[ i - 1 ].index = array[ i ].index\n }\n array[ n - 1 ].index = this.getAtomIndexByType(j, type)! // TODO\n callback.apply(this, array)\n }\n }\n\n /**\n * Residue iterator\n * @param {function(residue: ResidueProxy)} callback - the callback\n * @return {undefined}\n */\n eachResidue (callback: (rp: ResidueProxy) => void) {\n const rp = this.structure.getResidueProxy()\n const n = this.residueCount\n const rStartIndex = this.residueIndexStart\n\n for (let i = 0; i < n; ++i) {\n rp.index = rStartIndex + i\n callback(rp)\n }\n }\n\n qualifiedName () {\n const rpStart = this.structure.getResidueProxy(this.residueIndexStart)\n const rpEnd = this.structure.getResidueProxy(this.residueIndexEnd)\n return rpStart.qualifiedName() + ' - ' + rpEnd.qualifiedName()\n }\n}\n\nexport default Polymer\n","/**\n * @file Chain Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport { UnknownBackboneType } from '../structure/structure-constants'\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\n\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\n\nimport Polymer from '../proxy/polymer'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ModelProxy from './model-proxy';\nimport Entity from '../structure/entity';\n\n/**\n * Chain proxy\n */\nclass ChainProxy {\n index: number\n\n chainStore: ChainStore\n residueStore: ResidueStore\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n }\n\n /**\n * Entity\n * @type {Entity}\n */\n get entity (): Entity {\n return this.structure.entityList[ this.entityIndex ]\n }\n /**\n * Model\n * @type {ModelProxy}\n */\n get model (): ModelProxy {\n return this.structure.getModelProxy(this.modelIndex)\n }\n\n get entityIndex () {\n return this.chainStore.entityIndex[ this.index ]\n }\n set entityIndex (value) {\n this.chainStore.entityIndex[ this.index ] = value\n }\n\n get modelIndex () {\n return this.chainStore.modelIndex[ this.index ]\n }\n set modelIndex (value) {\n this.chainStore.modelIndex[ this.index ] = value\n }\n\n get residueOffset () {\n return this.chainStore.residueOffset[ this.index ]\n }\n set residueOffset (value) {\n this.chainStore.residueOffset[ this.index ] = value\n }\n\n /**\n * Residue count\n * @type {Integer}\n */\n get residueCount () {\n return this.chainStore.residueCount[ this.index ]\n }\n set residueCount (value) {\n this.chainStore.residueCount[ this.index ] = value\n }\n\n get residueEnd () {\n return this.residueOffset + this.residueCount - 1\n }\n\n get atomOffset () {\n return this.residueStore.atomOffset[ this.residueOffset ]\n }\n get atomEnd () {\n return (\n this.residueStore.atomOffset[ this.residueEnd ] +\n this.residueStore.atomCount[ this.residueEnd ] - 1\n )\n }\n /**\n * Atom count\n * @type {Integer}\n */\n get atomCount () {\n if (this.residueCount === 0) {\n return 0\n } else {\n return this.atomEnd - this.atomOffset + 1\n }\n }\n\n //\n\n /**\n * Chain name\n * @type {String}\n */\n get chainname () {\n return this.chainStore.getChainname(this.index)\n }\n set chainname (value) {\n this.chainStore.setChainname(this.index, value)\n }\n\n /**\n * Chain id\n * @type {String}\n */\n get chainid () {\n return this.chainStore.getChainid(this.index)\n }\n set chainid (value) {\n this.chainStore.setChainid(this.index, value)\n }\n\n //\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (ap: AtomProxy) => void, selection?: Selection) {\n this.eachResidue(function (rp) {\n rp.eachAtom(callback, selection)\n }, selection)\n }\n\n /**\n * Residue iterator\n * @param {function(residue: ResidueProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachResidue (callback: (rp: ResidueProxy) => void, selection?: Selection) {\n const count = this.residueCount\n const offset = this.residueOffset\n const rp = this.structure._rp\n const end = offset + count\n\n if (selection && selection.test) {\n const residueOnlyTest = selection.residueOnlyTest\n if (residueOnlyTest) {\n for (let i = offset; i < end; ++i) {\n rp.index = i\n if (residueOnlyTest(rp)) {\n callback(rp)\n }\n }\n } else {\n for (let i = offset; i < end; ++i) {\n rp.index = i\n callback(rp)\n }\n }\n } else {\n for (let i = offset; i < end; ++i) {\n rp.index = i\n callback(rp)\n }\n }\n }\n\n /**\n * Multi-residue iterator\n * @param {Integer} n - window size\n * @param {function(residueList: ResidueProxy[])} callback - the callback\n * @return {undefined}\n */\n eachResidueN (n: number, callback: (...rpArray: ResidueProxy[]) => void) {\n const count = this.residueCount\n const offset = this.residueOffset\n const end = offset + count\n if (count < n) return\n const array: ResidueProxy[] = new Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = this.structure.getResidueProxy(offset + i)\n }\n callback.apply(this, array)\n\n for (let j = offset + n; j < end; ++j) {\n for (let i = 0; i < n; ++i) {\n array[ i ].index += 1\n }\n callback.apply(this, array)\n }\n }\n\n /**\n * Polymer iterator\n * @param {function(polymer: Polymer)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachPolymer (callback: (p: Polymer) => void, selection?: Selection) {\n let rStartIndex = 0\n let rNextIndex = 0\n const test = selection ? selection.residueOnlyTest : undefined\n const structure = this.model.structure\n\n const count = this.residueCount\n const offset = this.residueOffset\n const end = offset + count\n\n const rp1 = this.structure.getResidueProxy()\n const rp2 = this.structure.getResidueProxy(offset)\n\n const ap1 = this.structure.getAtomProxy()\n const ap2 = this.structure.getAtomProxy()\n\n let first = true\n\n for (let i = offset + 1; i < end; ++i) {\n rp1.index = rp2.index\n rp2.index = i\n\n const bbType1 = first ? rp1.backboneEndType : rp1.backboneType\n const bbType2 = rp2.backboneType\n\n if (first) {\n rStartIndex = rp1.index\n first = false\n }\n rNextIndex = rp2.index\n\n if (bbType1 !== UnknownBackboneType && bbType1 === bbType2) {\n ap1.index = rp1.backboneEndAtomIndex\n ap2.index = rp2.backboneStartAtomIndex\n } else {\n if (bbType1 !== UnknownBackboneType) {\n if (rp1.index - rStartIndex > 1) {\n // console.log(\"FOO1\",rStartIndex, rp1.index)\n callback(new Polymer(structure, rStartIndex, rp1.index))\n }\n }\n rStartIndex = rNextIndex\n\n continue\n }\n\n if (!ap1 || !ap2 || !ap1.connectedTo(ap2) ||\n (test && (!test(rp1) || !test(rp2)))\n ) {\n if (rp1.index - rStartIndex > 1) {\n // console.log(\"FOO2\",rStartIndex, rp1.index)\n callback(new Polymer(structure, rStartIndex, rp1.index))\n }\n rStartIndex = rNextIndex\n }\n }\n\n if (rNextIndex - rStartIndex > 1) {\n if (this.structure.getResidueProxy(rStartIndex).backboneEndType) {\n // console.log(\"FOO3\",rStartIndex, rNextIndex)\n callback(new Polymer(structure, rStartIndex, rNextIndex))\n }\n }\n }\n\n //\n\n qualifiedName () {\n var name = ':' + this.chainname + '/' + this.modelIndex\n return name\n }\n\n /**\n * Clone object\n * @return {ChainProxy} cloned chain\n */\n clone () {\n return new ChainProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n index: this.index,\n residueOffset: this.residueOffset,\n residueCount: this.residueCount,\n\n chainname: this.chainname\n }\n }\n}\n\nexport default ChainProxy\n","/**\n * @file Model Proxy\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\n\nimport ModelStore from '../store/model-store'\nimport ChainStore from '../store/chain-store'\nimport ResidueStore from '../store/residue-store'\n\nimport ChainProxy from '../proxy/chain-proxy'\nimport Polymer from '../proxy/polymer'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Model proxy\n */\nclass ModelProxy {\n index: number\n\n modelStore: ModelStore\n chainStore: ChainStore\n residueStore: ResidueStore\n\n /**\n * @param {Structure} structure - the structure\n * @param {Integer} index - the index\n */\n constructor (readonly structure: Structure, index = 0) {\n this.index = index\n this.modelStore = structure.modelStore\n this.chainStore = structure.chainStore\n this.residueStore = structure.residueStore\n }\n\n get chainOffset () {\n return this.modelStore.chainOffset[ this.index ]\n }\n set chainOffset (value) {\n this.modelStore.chainOffset[ this.index ] = value\n }\n\n get chainCount () {\n return this.modelStore.chainCount[ this.index ]\n }\n set chainCount (value) {\n this.modelStore.chainCount[ this.index ] = value\n }\n\n get residueOffset () {\n return this.chainStore.residueOffset[ this.chainOffset ]\n }\n get atomOffset () {\n return this.residueStore.atomOffset[ this.residueOffset ]\n }\n\n get chainEnd () {\n return this.chainOffset + this.chainCount - 1\n }\n get residueEnd () {\n return (\n this.chainStore.residueOffset[ this.chainEnd ] +\n this.chainStore.residueCount[ this.chainEnd ] - 1\n )\n }\n get atomEnd () {\n return (\n this.residueStore.atomOffset[ this.residueEnd ] +\n this.residueStore.atomCount[ this.residueEnd ] - 1\n )\n }\n\n /**\n * Residue count\n * @type {Integer}\n */\n get residueCount () {\n if (this.chainCount === 0) {\n return 0\n } else {\n return this.residueEnd - this.residueOffset + 1\n }\n }\n\n /**\n * Atom count\n * @type {Integer}\n */\n get atomCount () {\n if (this.residueCount === 0) {\n return 0\n } else {\n return this.atomEnd - this.atomOffset + 1\n }\n }\n\n //\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (ap: AtomProxy) => void, selection?: Selection) {\n this.eachChain(function (cp) {\n cp.eachAtom(callback, selection)\n }, selection)\n }\n\n /**\n * Residue iterator\n * @param {function(residue: ResidueProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachResidue (callback: (rp: ResidueProxy) => void, selection?: Selection) {\n this.eachChain(function (cp) {\n cp.eachResidue(callback, selection)\n }, selection)\n }\n\n /**\n * Polymer iterator\n * @param {function(polymer: Polymer)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachPolymer (callback: (p: Polymer) => void, selection?: Selection) {\n if (selection && selection.chainOnlyTest) {\n const chainOnlyTest = selection.chainOnlyTest\n\n this.eachChain(function (cp) {\n if (chainOnlyTest(cp)) {\n cp.eachPolymer(callback, selection)\n }\n })\n } else {\n this.eachChain(function (cp) {\n cp.eachPolymer(callback, selection)\n })\n }\n }\n\n /**\n * Chain iterator\n * @param {function(chain: ChainProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachChain (callback: (cp: ChainProxy) => void, selection?: Selection) {\n const count = this.chainCount\n const offset = this.chainOffset\n const cp = this.structure._cp\n const end = offset + count\n\n if (selection && selection.test) {\n const chainOnlyTest = selection.chainOnlyTest\n if (chainOnlyTest) {\n for (let i = offset; i < end; ++i) {\n cp.index = i\n if (chainOnlyTest(cp)) {\n callback(cp)\n }\n }\n } else {\n for (let i = offset; i < end; ++i) {\n cp.index = i\n callback(cp)\n }\n }\n } else {\n for (let i = offset; i < end; ++i) {\n cp.index = i\n callback(cp)\n }\n }\n }\n\n //\n\n qualifiedName () {\n const name = '/' + this.index\n return name\n }\n\n /**\n * Clone object\n * @return {ModelProxy} cloned model\n */\n clone () {\n return new ModelProxy(this.structure, this.index)\n }\n\n toObject () {\n return {\n index: this.index,\n chainOffset: this.chainOffset,\n chainCount: this.chainCount\n }\n }\n}\n\nexport default ModelProxy\n","/**\n * @file Structure\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3 } from 'three'\nimport { Signal } from 'signals'\n\nimport { Debug, Log, ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { AtomPicker, BondPicker } from '../utils/picker'\nimport { copyWithin, arrayMin, arrayMax } from '../math/array-utils'\nimport BitArray from '../utils/bitarray'\nimport RadiusFactory, { RadiusParams } from '../utils/radius-factory'\nimport { Matrix } from '../math/matrix-utils'\nimport PrincipalAxes from '../math/principal-axes'\nimport SpatialHash from '../geometry/spatial-hash'\nimport FilteredVolume from '../surface/filtered-volume'\nimport StructureView from './structure-view'\nimport { AtomDataParams, AtomData, BondDataParams, BondData } from './structure-data'\nimport { Data, createData } from './data'\n\nimport Entity from './entity'\nimport Unitcell from '../symmetry/unitcell'\nimport Validation from './validation'\nimport Selection from '../selection/selection'\nimport Assembly from '../symmetry/assembly'\nimport Volume from '../surface/volume'\nimport Polymer from '../proxy/polymer'\n\nimport BondHash from '../store/bond-hash'\nimport BondStore from '../store/bond-store'\nimport AtomStore from '../store/atom-store'\nimport ResidueStore from '../store/residue-store'\nimport ChainStore from '../store/chain-store'\nimport ModelStore from '../store/model-store'\n\nimport AtomMap from '../store/atom-map'\nimport ResidueMap from '../store/residue-map'\n\nimport BondProxy from '../proxy/bond-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\ninterface Structure {\n signals: StructureSignals\n\n name: string\n path: string\n title: string\n id: string\n\n data: Data\n\n atomCount: number\n bondCount: number\n\n header: StructureHeader\n extraData: StructureExtraData\n\n atomSetCache: { [k: string]: BitArray }\n atomSetDict: { [k: string]: BitArray }\n biomolDict: { [k: string]: Assembly }\n\n entityList: Entity[]\n unitcell?: Unitcell\n\n frames: Float32Array[]\n boxes: Float32Array[]\n\n validation?: Validation\n\n bondStore: BondStore\n backboneBondStore: BondStore\n rungBondStore: BondStore\n atomStore: AtomStore\n residueStore: ResidueStore\n chainStore: ChainStore\n modelStore: ModelStore\n\n atomMap: AtomMap\n residueMap: ResidueMap\n\n bondHash?: BondHash\n spatialHash?: SpatialHash\n\n atomSet?: BitArray\n bondSet?: BitArray\n\n center: Vector3\n boundingBox: Box3\n\n trajectory?: {\n name: string\n frame: number\n }\n\n getView(selection: Selection): StructureView\n\n _hasCoords?: boolean\n\n _bp: BondProxy\n _ap: AtomProxy\n _rp: ResidueProxy\n _cp: ChainProxy\n}\n\nexport type StructureHeader = {\n releaseDate?: string\n depositionDate?: string\n resolution?: number\n rFree?: number\n rWork?: number\n experimentalMethods?: string[]\n}\n\nexport type StructureExtraData = {\n cif?: object\n sdf?: object[]\n}\n\nexport type StructureSignals = {\n refreshed: Signal\n}\n\n/**\n * Structure\n */\nclass Structure implements Structure{\n signals: StructureSignals = {\n refreshed: new Signal()\n }\n\n /**\n * @param {String} name - structure name\n * @param {String} path - source path\n */\n constructor (name = '', path = '') {\n this.init(name, path)\n }\n\n init (name: string, path: string) {\n this.name = name\n this.path = path\n this.title = ''\n this.id = ''\n\n this.data = createData(this)\n\n this.header = {}\n this.extraData = {}\n\n this.atomSetCache = {}\n this.atomSetDict = {}\n this.biomolDict = {}\n\n this.entityList = []\n this.unitcell = undefined\n\n this.frames = []\n this.boxes = []\n\n this.validation = undefined\n\n this.bondStore = new BondStore(0)\n this.backboneBondStore = new BondStore(0)\n this.rungBondStore = new BondStore(0)\n this.atomStore = new AtomStore(0)\n this.residueStore = new ResidueStore(0)\n this.chainStore = new ChainStore(0)\n this.modelStore = new ModelStore(0)\n\n this.atomMap = new AtomMap(this)\n this.residueMap = new ResidueMap(this)\n\n this.bondHash = undefined\n this.spatialHash = undefined\n\n this.atomSet = undefined\n this.bondSet = undefined\n\n this.center = new Vector3()\n this.boundingBox = new Box3()\n\n this._bp = this.getBondProxy()\n this._ap = this.getAtomProxy()\n this._rp = this.getResidueProxy()\n this._cp = this.getChainProxy()\n }\n\n get type () { return 'Structure' }\n\n finalizeAtoms () {\n this.atomSet = this.getAtomSet()\n this.atomCount = this.atomStore.count\n this.boundingBox = this.getBoundingBox(undefined, this.boundingBox)\n this.center = this.boundingBox.getCenter(new Vector3())\n this.spatialHash = new SpatialHash(this.atomStore, this.boundingBox)\n }\n\n finalizeBonds () {\n this.bondSet = this.getBondSet()\n this.bondCount = this.bondStore.count\n this.bondHash = new BondHash(this.bondStore, this.atomStore.count)\n\n this.atomSetCache = {}\n if (!this.atomSetDict.rung) {\n this.atomSetDict.rung = this.getAtomSet(false)\n }\n\n for (let name in this.atomSetDict) {\n this.atomSetCache[ '__' + name ] = this.atomSetDict[ name ].clone()\n }\n }\n\n //\n\n getBondProxy (index?: number) {\n return new BondProxy(this, index)\n }\n\n getAtomProxy (index?: number) {\n return new AtomProxy(this, index)\n }\n\n getResidueProxy (index?: number) {\n return new ResidueProxy(this, index)\n }\n\n getChainProxy (index?: number) {\n return new ChainProxy(this, index)\n }\n\n getModelProxy (index?: number) {\n return new ModelProxy(this, index)\n }\n\n //\n\n getBondSet (/* selection */) {\n // TODO implement selection parameter\n\n const n = this.bondStore.count\n const bondSet = new BitArray(n)\n const atomSet = this.atomSet\n\n if (atomSet) {\n if (atomSet.isAllSet()) {\n bondSet.setAll()\n } else if (atomSet.isAllClear()) {\n bondSet.clearAll()\n } else {\n const bp = this.getBondProxy()\n\n for (let i = 0; i < n; ++i) {\n bp.index = i\n if (atomSet.isSet(bp.atomIndex1, bp.atomIndex2)) {\n bondSet.set(bp.index)\n }\n }\n }\n } else {\n bondSet.setAll()\n }\n\n return bondSet\n }\n\n getBackboneBondSet (/* selection */) {\n // TODO implement selection parameter\n\n const n = this.backboneBondStore.count\n const backboneBondSet = new BitArray(n)\n const backboneAtomSet = this.atomSetCache.__backbone\n\n if (backboneAtomSet) {\n const bp = this.getBondProxy()\n bp.bondStore = this.backboneBondStore\n\n for (let i = 0; i < n; ++i) {\n bp.index = i\n if (backboneAtomSet.isSet(bp.atomIndex1, bp.atomIndex2)) {\n backboneBondSet.set(bp.index)\n }\n }\n } else {\n backboneBondSet.setAll()\n }\n\n return backboneBondSet\n }\n\n getRungBondSet (/* selection */) {\n // TODO implement selection parameter\n\n const n = this.rungBondStore.count\n const rungBondSet = new BitArray(n)\n const rungAtomSet = this.atomSetCache.__rung\n\n if (rungAtomSet) {\n const bp = this.getBondProxy()\n bp.bondStore = this.rungBondStore\n\n for (let i = 0; i < n; ++i) {\n bp.index = i\n if (rungAtomSet.isSet(bp.atomIndex1, bp.atomIndex2)) {\n rungBondSet.set(bp.index)\n }\n }\n } else {\n rungBondSet.setAll()\n }\n\n return rungBondSet\n }\n\n /**\n * Get a set of atoms\n * @param {Boolean|Selection|BitArray} selection - object defining how to\n * initialize the atom set.\n * Boolean: init with value;\n * Selection: init with selection;\n * BitArray: return bit array\n * @return {BitArray} set of atoms\n */\n getAtomSet (selection?: boolean|Selection|BitArray) {\n const n = this.atomStore.count\n\n if (selection === undefined) {\n return new BitArray(n, true)\n } else if (selection instanceof BitArray) {\n return selection\n } else if (selection === true) {\n return new BitArray(n, true)\n } else if (selection && selection.test) {\n const seleString = selection.string\n if (seleString in this.atomSetCache) {\n return this.atomSetCache[ seleString ]\n } else {\n if (seleString === '') {\n return new BitArray(n, true)\n } else {\n const atomSet = new BitArray(n)\n this.eachAtom(function (ap: AtomProxy) {\n atomSet.set(ap.index)\n }, selection)\n this.atomSetCache[ seleString ] = atomSet\n return atomSet\n }\n }\n } else if (selection === false) {\n return new BitArray(n)\n }\n\n return new BitArray(n, true)\n }\n\n /**\n * Get set of atoms around a set of atoms from a selection\n * @param {Selection} selection - the selection object\n * @param {Number} radius - radius to select within\n * @return {BitArray} set of atoms\n */\n getAtomSetWithinSelection (selection: boolean|Selection|BitArray, radius: number) {\n const spatialHash = this.spatialHash\n const atomSet = this.getAtomSet(false)\n const ap = this.getAtomProxy()\n\n if (!spatialHash) return atomSet\n\n this.getAtomSet(selection).forEach(function (idx: number) {\n ap.index = idx\n spatialHash.within(ap.x, ap.y, ap.z, radius).forEach(function (idx2: number) {\n atomSet.set(idx2)\n })\n })\n\n return atomSet\n }\n\n /**\n * Get set of atoms around a point\n * @param {Vector3|AtomProxy} point - the point\n * @param {Number} radius - radius to select within\n * @return {BitArray} set of atoms\n */\n getAtomSetWithinPoint (point: Vector3|AtomProxy, radius: number) {\n const p = point\n const atomSet = this.getAtomSet(false)\n\n if (!this.spatialHash) return atomSet\n\n this.spatialHash.within(p.x, p.y, p.z, radius).forEach(function (idx: number) {\n atomSet.set(idx)\n })\n\n return atomSet\n }\n\n /**\n * Get set of atoms within a volume\n * @param {Volume} volume - the volume\n * @param {Number} radius - radius to select within\n * @param {[type]} minValue - minimum value to be considered as within the volume\n * @param {[type]} maxValue - maximum value to be considered as within the volume\n * @param {[type]} outside - use only values falling outside of the min/max values\n * @return {BitArray} set of atoms\n */\n getAtomSetWithinVolume (volume: Volume, radius: number, minValue: number, maxValue: number, outside: boolean) {\n const fv = new FilteredVolume(volume, minValue, maxValue, outside) as any // TODO\n\n const dp = fv.getDataPosition()\n const n = dp.length\n const r = fv.matrix.getMaxScaleOnAxis()\n const atomSet = this.getAtomSet(false)\n\n if (!this.spatialHash) return atomSet\n\n for (let i = 0; i < n; i += 3) {\n this.spatialHash.within(dp[ i ], dp[ i + 1 ], dp[ i + 2 ], r).forEach(function (idx) {\n atomSet.set(idx)\n })\n }\n\n return atomSet\n }\n\n /**\n * Get set of all atoms within the groups of a selection\n * @param {Selection} selection - the selection object\n * @return {BitArray} set of atoms\n */\n getAtomSetWithinGroup (selection: boolean|Selection|BitArray) {\n const atomResidueIndex = this.atomStore.residueIndex\n const atomSet = this.getAtomSet(false)\n const rp = this.getResidueProxy()\n\n this.getAtomSet(selection).forEach(function (idx) {\n rp.index = atomResidueIndex[ idx ]\n for (let idx2 = rp.atomOffset; idx2 <= rp.atomEnd; ++idx2) {\n atomSet.set(idx2)\n }\n })\n\n return atomSet\n }\n\n //\n\n getSelection (): undefined|Selection {\n return\n }\n\n getStructure (): Structure|StructureView {\n return this\n }\n\n /**\n * Entity iterator\n * @param {function(entity: Entity)} callback - the callback\n * @param {EntityType} type - entity type\n * @return {undefined}\n */\n eachEntity (callback: (entity: Entity) => void, type: number) {\n this.entityList.forEach(function (entity) {\n if (type === undefined || entity.getEntityType() === type) {\n callback(entity)\n }\n })\n }\n\n /**\n * Bond iterator\n * @param {function(bond: BondProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachBond (callback: (entity: BondProxy) => void, selection?: Selection) {\n const bp = this.getBondProxy()\n let bondSet\n\n if (selection && selection.test) {\n bondSet = this.getBondSet(/*selection*/)\n if (this.bondSet) {\n bondSet.intersection(this.bondSet)\n }\n }\n\n if (bondSet) {\n bondSet.forEach(function (index) {\n bp.index = index\n callback(bp)\n })\n } else {\n const n = this.bondStore.count\n for (let i = 0; i < n; ++i) {\n bp.index = i\n callback(bp)\n }\n }\n }\n\n /**\n * Atom iterator\n * @param {function(atom: AtomProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachAtom (callback: (entity: AtomProxy) => void, selection?: Selection) {\n if (selection && selection.test) {\n this.eachModel(function (mp) {\n mp.eachAtom(callback, selection)\n }, selection)\n } else {\n const an = this.atomStore.count\n const ap = this.getAtomProxy()\n for (let i = 0; i < an; ++i) {\n ap.index = i\n callback(ap)\n }\n }\n }\n\n /**\n * Residue iterator\n * @param {function(residue: ResidueProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachResidue (callback: (entity: ResidueProxy) => void, selection?: Selection) {\n if (selection && selection.test) {\n const mn = this.modelStore.count\n const mp = this.getModelProxy()\n const modelOnlyTest = selection.modelOnlyTest\n if (modelOnlyTest) {\n for (let i = 0; i < mn; ++i) {\n mp.index = i\n if (modelOnlyTest(mp)) {\n mp.eachResidue(callback, selection)\n }\n }\n } else {\n for (let i = 0; i < mn; ++i) {\n mp.index = i\n mp.eachResidue(callback, selection)\n }\n }\n } else {\n const rn = this.residueStore.count\n const rp = this.getResidueProxy()\n for (let i = 0; i < rn; ++i) {\n rp.index = i\n callback(rp)\n }\n }\n }\n\n /**\n * Multi-residue iterator\n * @param {Integer} n - window size\n * @param {function(residueList: ResidueProxy[])} callback - the callback\n * @return {undefined}\n */\n eachResidueN (n: number, callback: (...entityArray: ResidueProxy[]) => void) {\n const rn = this.residueStore.count\n if (rn < n) return\n const array: ResidueProxy[] = new Array(n)\n\n for (let i = 0; i < n; ++i) {\n array[ i ] = this.getResidueProxy(i)\n }\n callback.apply(this, array)\n\n for (let j = n; j < rn; ++j) {\n for (let i = 0; i < n; ++i) {\n array[ i ].index += 1\n }\n callback.apply(this, array)\n }\n }\n\n /**\n * Polymer iterator\n * @param {function(polymer: Polymer)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachPolymer (callback: (entity: Polymer) => void, selection?: Selection) {\n if (selection && selection.modelOnlyTest) {\n const modelOnlyTest = selection.modelOnlyTest\n\n this.eachModel(function (mp) {\n if (modelOnlyTest(mp)) {\n mp.eachPolymer(callback, selection)\n }\n })\n } else {\n this.eachModel(function (mp) {\n mp.eachPolymer(callback, selection)\n })\n }\n }\n\n /**\n * Chain iterator\n * @param {function(chain: ChainProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachChain (callback: (entity: ChainProxy) => void, selection?: Selection) {\n if (selection && selection.test) {\n this.eachModel(function (mp) {\n mp.eachChain(callback, selection)\n })\n } else {\n const cn = this.chainStore.count\n const cp = this.getChainProxy()\n for (let i = 0; i < cn; ++i) {\n cp.index = i\n callback(cp)\n }\n }\n }\n\n /**\n * Model iterator\n * @param {function(model: ModelProxy)} callback - the callback\n * @param {Selection} [selection] - the selection\n * @return {undefined}\n */\n eachModel (callback: (entity: ModelProxy) => void, selection?: Selection) {\n const n = this.modelStore.count\n const mp = this.getModelProxy()\n\n if (selection && selection.test) {\n const modelOnlyTest = selection.modelOnlyTest\n if (modelOnlyTest) {\n for (let i = 0; i < n; ++i) {\n mp.index = i\n if (modelOnlyTest(mp)) {\n callback(mp)\n }\n }\n } else {\n for (let i = 0; i < n; ++i) {\n mp.index = i\n callback(mp)\n }\n }\n } else {\n for (let i = 0; i < n; ++i) {\n mp.index = i\n callback(mp)\n }\n }\n }\n\n //\n\n getAtomData (params: AtomDataParams) {\n const p = Object.assign({}, params)\n if (p.colorParams) p.colorParams.structure = this.getStructure()\n\n const what = p.what\n const atomSet = defaults(p.atomSet, this.atomSet)\n\n let radiusFactory: any // TODO\n let colormaker: any // TODO\n\n const atomData: AtomData = {}\n const ap = this.getAtomProxy()\n const atomCount = atomSet.getSize()\n\n if (!what || what.position) {\n atomData.position = new Float32Array(atomCount * 3)\n }\n if ((!what || what.color) && p.colorParams) {\n atomData.color = new Float32Array(atomCount * 3)\n colormaker = ColormakerRegistry.getScheme(p.colorParams)\n }\n if (!what || what.picking) {\n atomData.picking = new AtomPicker(new Float32Array(atomCount), this.getStructure())\n }\n if (!what || what.radius) {\n atomData.radius = new Float32Array(atomCount)\n radiusFactory = new RadiusFactory(p.radiusParams as RadiusParams)\n }\n if (!what || what.index) {\n atomData.index = new Uint32Array(atomCount)\n }\n\n const {position, color, picking, radius, index} = atomData\n\n atomSet.forEach((idx: number, i: number) => {\n const i3 = i * 3\n ap.index = idx\n if (position) {\n ap.positionToArray(position, i3)\n }\n if (color) {\n colormaker.atomColorToArray(ap, color, i3)\n }\n if (picking) {\n picking.array![ i ] = idx\n }\n if (radius) {\n radius[ i ] = radiusFactory.atomRadius(ap)\n }\n if (index) {\n index[ i ] = idx\n }\n })\n return atomData\n }\n\n getBondData (params: BondDataParams) {\n const p = Object.assign({}, params)\n if (p.colorParams) p.colorParams.structure = this.getStructure()\n\n const what = p.what\n const bondSet = defaults(p.bondSet, this.bondSet)\n const multipleBond = defaults(p.multipleBond, 'off')\n const isMulti = multipleBond !== 'off'\n const isOffset = multipleBond === 'offset'\n const bondScale = defaults(p.bondScale, 0.4)\n const bondSpacing = defaults(p.bondSpacing, 1.0)\n\n let radiusFactory: any // TODO\n let colormaker: any // TODO\n\n const bondData: BondData = {}\n const bp = this.getBondProxy()\n if (p.bondStore) bp.bondStore = p.bondStore\n const ap1 = this.getAtomProxy()\n const ap2 = this.getAtomProxy()\n\n let bondCount: number\n if (isMulti) {\n const storeBondOrder = bp.bondStore.bondOrder\n bondCount = 0\n bondSet.forEach(function (index: number) {\n bondCount += storeBondOrder[ index ]\n })\n } else {\n bondCount = bondSet.getSize()\n }\n\n if (!what || what.position) {\n bondData.position1 = new Float32Array(bondCount * 3)\n bondData.position2 = new Float32Array(bondCount * 3)\n }\n if ((!what || what.color) && p.colorParams) {\n bondData.color = new Float32Array(bondCount * 3)\n bondData.color2 = new Float32Array(bondCount * 3)\n colormaker = ColormakerRegistry.getScheme(p.colorParams)\n }\n if (!what || what.picking) {\n bondData.picking = new BondPicker(new Float32Array(bondCount), this.getStructure(), p.bondStore)\n }\n if (!what || what.radius || (isMulti && what.position)) {\n radiusFactory = new RadiusFactory(p.radiusParams as RadiusParams)\n }\n if (!what || what.radius) {\n bondData.radius = new Float32Array(bondCount)\n if (p.radius2) {\n bondData.radius2 = new Float32Array(bondCount)\n }\n }\n\n const {position1, position2, color, color2, picking, radius, radius2} = bondData\n\n let i = 0\n let j, i3, k, bondOrder, absOffset\n let multiRadius\n\n const vt = new Vector3()\n const vShortening = new Vector3()\n const vShift = new Vector3()\n\n bondSet.forEach((index: number) => {\n i3 = i * 3\n bp.index = index\n ap1.index = bp.atomIndex1\n ap2.index = bp.atomIndex2\n bondOrder = bp.bondOrder\n if (position1) {\n if (isMulti && bondOrder > 1) {\n const atomRadius = radiusFactory.atomRadius(ap1)\n multiRadius = atomRadius * bondScale / (0.5 * bondOrder)\n\n bp.calculateShiftDir(vShift)\n\n if (isOffset) {\n absOffset = 2 * bondSpacing * atomRadius\n vShift.multiplyScalar(absOffset)\n vShift.negate()\n\n // Shortening is calculated so that neighbouring double\n // bonds on tetrahedral geometry (e.g. sulphonamide)\n // are not quite touching (arccos(1.9 / 2) ~ 109deg)\n // but don't shorten beyond 10% each end or it looks odd\n vShortening.subVectors(ap2 as any, ap1 as any).multiplyScalar( // TODO\n Math.max(0.1, absOffset / 1.88)\n )\n ap1.positionToArray(position1, i3)\n ap2.positionToArray(position2, i3)\n\n if (bondOrder >= 2) {\n vt.addVectors(ap1 as any, vShift).add(vShortening).toArray(position1 as any, i3 + 3) // TODO\n vt.addVectors(ap2 as any, vShift).sub(vShortening).toArray(position2 as any, i3 + 3) // TODO\n\n if (bondOrder >= 3) {\n vt.subVectors(ap1 as any, vShift).add(vShortening).toArray(position1 as any, i3 + 6) // TODO\n vt.subVectors(ap2 as any, vShift).sub(vShortening).toArray(position2 as any, i3 + 6) // TODO\n }\n }\n } else {\n absOffset = (bondSpacing - bondScale) * atomRadius\n vShift.multiplyScalar(absOffset)\n\n if (bondOrder === 2) {\n vt.addVectors(ap1 as any, vShift).toArray(position1 as any, i3) // TODO\n vt.subVectors(ap1 as any, vShift).toArray(position1 as any, i3 + 3) // TODO\n vt.addVectors(ap2 as any, vShift).toArray(position2 as any, i3) // TODO\n vt.subVectors(ap2 as any, vShift).toArray(position2 as any, i3 + 3) // TODO\n } else if (bondOrder === 3) {\n ap1.positionToArray(position1, i3)\n vt.addVectors(ap1 as any, vShift).toArray(position1 as any, i3 + 3) // TODO\n vt.subVectors(ap1 as any, vShift).toArray(position1 as any, i3 + 6) // TODO\n ap2.positionToArray(position2, i3)\n vt.addVectors(ap2 as any, vShift).toArray(position2 as any, i3 + 3) // TODO\n vt.subVectors(ap2 as any, vShift).toArray(position2 as any, i3 + 6) // TODO\n } else {\n // todo, better fallback\n ap1.positionToArray(position1, i3)\n ap2.positionToArray(position2, i3)\n }\n }\n } else {\n ap1.positionToArray(position1, i3)\n ap2.positionToArray(position2, i3)\n }\n }\n if (color && color2) {\n colormaker.bondColorToArray(bp, 1, color, i3)\n colormaker.bondColorToArray(bp, 0, color2, i3)\n if (isMulti && bondOrder > 1) {\n for (j = 1; j < bondOrder; ++j) {\n k = j * 3 + i3\n copyWithin(color, i3, k, 3)\n copyWithin(color2, i3, k, 3)\n }\n }\n }\n if (picking && picking.array) {\n picking.array[ i ] = index\n if (isMulti && bondOrder > 1) {\n for (j = 1; j < bondOrder; ++j) {\n picking.array[ i + j ] = index\n }\n }\n }\n if (radius) {\n radius[ i ] = radiusFactory.atomRadius(ap1)\n if (isMulti && bondOrder > 1) {\n multiRadius = radius[ i ] * bondScale / (isOffset ? 1 : (0.5 * bondOrder))\n for (j = isOffset ? 1 : 0; j < bondOrder; ++j) {\n radius[ i + j ] = multiRadius\n }\n }\n }\n if (radius2) {\n radius2[ i ] = radiusFactory.atomRadius(ap2)\n if (isMulti && bondOrder > 1) {\n multiRadius = radius2[ i ] * bondScale / (isOffset ? 1 : (0.5 * bondOrder))\n for (j = isOffset ? 1 : 0; j < bondOrder; ++j) {\n radius2[ i + j ] = multiRadius\n }\n }\n }\n i += isMulti ? bondOrder : 1\n })\n\n return bondData\n }\n\n getBackboneAtomData (params: AtomDataParams) {\n params = Object.assign({\n atomSet: this.atomSetCache.__backbone\n }, params)\n\n return this.getAtomData(params)\n }\n\n getBackboneBondData (params: BondDataParams) {\n params = Object.assign({\n bondSet: this.getBackboneBondSet(),\n bondStore: this.backboneBondStore\n }, params)\n\n return this.getBondData(params)\n }\n\n getRungAtomData (params: AtomDataParams) {\n params = Object.assign({\n atomSet: this.atomSetCache.__rung\n }, params)\n\n return this.getAtomData(params)\n }\n\n getRungBondData (params: BondDataParams) {\n params = Object.assign({\n bondSet: this.getRungBondSet(),\n bondStore: this.rungBondStore\n }, params)\n\n return this.getBondData(params)\n }\n\n //\n\n /**\n * Gets the bounding box of the (selected) structure atoms\n * @param {Selection} [selection] - the selection\n * @param {Box3} [box] - optional target\n * @return {Vector3} the box\n */\n getBoundingBox (selection?: Selection, box?: Box3) {\n if (Debug) Log.time('getBoundingBox')\n\n box = box || new Box3()\n\n let minX = +Infinity\n let minY = +Infinity\n let minZ = +Infinity\n\n let maxX = -Infinity\n let maxY = -Infinity\n let maxZ = -Infinity\n\n this.eachAtom(ap => {\n const x = ap.x\n const y = ap.y\n const z = ap.z\n\n if (x < minX) minX = x\n if (y < minY) minY = y\n if (z < minZ) minZ = z\n\n if (x > maxX) maxX = x\n if (y > maxY) maxY = y\n if (z > maxZ) maxZ = z\n }, selection)\n\n box.min.set(minX, minY, minZ)\n box.max.set(maxX, maxY, maxZ)\n\n if (Debug) Log.timeEnd('getBoundingBox')\n\n return box\n }\n\n /**\n * Gets the principal axes of the (selected) structure atoms\n * @param {Selection} [selection] - the selection\n * @return {PrincipalAxes} the principal axes\n */\n getPrincipalAxes (selection?: Selection) {\n if (Debug) Log.time('getPrincipalAxes')\n\n let i = 0\n const coords = new Matrix(3, this.atomCount)\n const cd = coords.data\n\n this.eachAtom(a => {\n cd[ i + 0 ] = a.x\n cd[ i + 1 ] = a.y\n cd[ i + 2 ] = a.z\n i += 3\n }, selection)\n\n if (Debug) Log.timeEnd('getPrincipalAxes')\n\n return new PrincipalAxes(coords)\n }\n\n /**\n * Gets the center of the (selected) structure atoms\n * @param {Selection} [selection] - the selection\n * @return {Vector3} the center\n */\n atomCenter (selection?: Selection) {\n if (selection) {\n return this.getBoundingBox(selection).getCenter(new Vector3())\n } else {\n return this.center.clone()\n }\n }\n\n hasCoords () {\n if (this._hasCoords === undefined) {\n const atomStore = this.atomStore\n this._hasCoords = (\n arrayMin(atomStore.x) !== 0 || arrayMax(atomStore.x) !== 0 ||\n arrayMin(atomStore.y) !== 0 || arrayMax(atomStore.y) !== 0 ||\n arrayMin(atomStore.z) !== 0 || arrayMax(atomStore.z) !== 0\n ) || (\n // allow models with a single atom at the origin\n atomStore.count / this.modelStore.count === 1\n )\n }\n return this._hasCoords;\n }\n\n getSequence (selection?: Selection) {\n const seq: string[] = []\n const rp = this.getResidueProxy()\n\n this.eachAtom(function (ap: AtomProxy) {\n rp.index = ap.residueIndex\n if (ap.index === rp.traceAtomIndex) {\n seq.push(rp.getResname1())\n }\n }, selection)\n\n return seq\n }\n\n getAtomIndices (selection?: Selection) {\n if (selection && selection.string) {\n const indices: number[] = []\n this.eachAtom(function (ap: AtomProxy) {\n indices.push(ap.index)\n }, selection)\n return new Uint32Array(indices)\n } else {\n const p = { what: { index: true } }\n return this.getAtomData(p).index\n }\n }\n\n /**\n * Get number of unique chainnames\n * @param {Selection} selection - limit count to selection\n * @return {Integer} count\n */\n getChainnameCount (selection?: Selection) {\n const chainnames = new Set()\n this.eachChain(function (cp: ChainProxy) {\n if (cp.residueCount) {\n chainnames.add(cp.chainname)\n }\n }, selection)\n\n return chainnames.size\n }\n\n /**\n * Update atomic positions\n * @param position - Array to copy positions from\n * @param refresh - Whether or not to issue a full refresh (automatically\n * triggers re-calculation of bounding boxes, spatial hash,\n * representations etc etc). This provides compatibility with\n * the old behaviour\n */\n updatePosition (position: Float32Array|number[], refresh: boolean = true) {\n let i = 0\n\n this.eachAtom(function (ap: AtomProxy) {\n ap.positionFromArray(position, i)\n i += 3\n }, undefined)\n\n this._hasCoords = undefined // to trigger recalculation (of the _hasCoords value)\n\n if (refresh) { \n this.refreshPosition() // Recalculate bounds - structure-component listener will \n // trigger representation rebuild\n }\n\n }\n\n refreshPosition () {\n this.getBoundingBox(undefined, this.boundingBox)\n this.boundingBox.getCenter(this.center)\n this.spatialHash = new SpatialHash(this.atomStore, this.boundingBox)\n\n this.signals.refreshed.dispatch(this)\n }\n\n /**\n * Calls dispose() method of property objects.\n * Unsets properties to help garbage collection.\n * @return {undefined}\n */\n dispose () {\n if (this.frames) this.frames.length = 0\n if (this.boxes) this.boxes.length = 0\n\n this.bondStore.dispose()\n this.backboneBondStore.dispose()\n this.rungBondStore.dispose()\n this.atomStore.dispose()\n this.residueStore.dispose()\n this.chainStore.dispose()\n this.modelStore.dispose()\n\n // can't delete non-optional properties as of TS 4\n // and since we've already disposed them, don't need to.\n\n delete this.bondSet\n delete this.atomSet\n }\n}\n\nexport default Structure\n","/**\n * @file Shape\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Matrix4 required for declaration only\nimport { Box3, Vector3, Color, Matrix4 } from 'three'\n\nimport { createParams, ensureFloat32Array, getUintArray } from '../utils'\nimport {\n ArrowPrimitive, BoxPrimitive, ConePrimitive, CylinderPrimitive, EllipsoidPrimitive,\n OctahedronPrimitive, SpherePrimitive, TetrahedronPrimitive, TextPrimitive,\n TorusPrimitive, PointPrimitive, WidelinePrimitive\n} from './primitive'\nimport { MeshPicker } from '../utils/picker'\nimport Buffer from '../buffer/buffer'\nimport MeshBuffer from '../buffer/mesh-buffer'\nimport { TextBufferParameters } from '../buffer/text-buffer'\n\nconst tmpBox = new Box3()\n\nconst Primitives = [\n ArrowPrimitive, BoxPrimitive, ConePrimitive, CylinderPrimitive,\n EllipsoidPrimitive, OctahedronPrimitive, SpherePrimitive, TetrahedronPrimitive,\n TextPrimitive, TorusPrimitive, PointPrimitive, WidelinePrimitive\n]\n\nexport const ShapeDefaultParameters = {\n aspectRatio: 1.5,\n sphereDetail: 2,\n radialSegments: 50,\n disableImpostor: false,\n openEnded: false,\n dashedCylinder: false,\n labelParams: {} as Partial,\n pointSize: 2,\n sizeAttenuation: false,\n useTexture: true,\n linewidth: 2\n}\nexport type ShapeParameters = typeof ShapeDefaultParameters\n\n/**\n * Class for building custom shapes.\n *\n * @example\n * var shape = new NGL.Shape('shape', { disableImpostor: true });\n * shape.addSphere([ 0, 0, 9 ], [ 1, 0, 0 ], 1.5 );\n * shape.addEllipsoid([ 6, 0, 0 ], [ 1, 0, 0 ], 1.5, [ 3, 0, 0 ], [ 0, 2, 0 ]);\n * shape.addCylinder([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ], 0.5);\n * shape.addCone([ 0, 2, 7 ], [ 0, 3, 3 ], [ 1, 1, 0 ], 1.5);\n * shape.addArrow([ 1, 2, 7 ], [ 30, 3, 3 ], [ 1, 0, 1 ], 1.0);\n * shape.addBox([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);\n * var shapeComp = stage.addComponentFromObject(shape);\n * geoComp.addRepresentation('buffer');\n */\nclass Shape {\n name: string\n parameters: ShapeParameters\n\n boundingBox = new Box3()\n bufferList: Buffer[] = []\n meshCount = 0\n\n _center?: Vector3\n _primitiveData: { [k: string]: any } = {}\n\n /**\n * @param {String} name - name\n * @param {Object} params - parameter object\n * @param {Integer} params.aspectRatio - arrow aspect ratio, used for cylinder radius and cone length\n * @param {Integer} params.sphereDetail - sphere quality (icosahedron subdivisions)\n * @param {Integer} params.radialSegments - cylinder quality (number of segments)\n * @param {Boolean} params.disableImpostor - disable use of raycasted impostors for rendering\n * @param {Boolean} params.openEnded - capped or not\n * @param {TextBufferParameters} params.labelParams - label parameters\n */\n constructor (name = 'shape', params: Partial = {}) {\n this.name = name\n\n this.parameters = createParams(params, ShapeDefaultParameters)\n\n Primitives.forEach(P => {\n Object.keys(P.fields).forEach(name => {\n this._primitiveData[ P.getShapeKey(name) ] = []\n })\n this._primitiveData[ P.getShapeKey('name') ] = []\n })\n }\n\n /**\n * Add a buffer\n * @param {Buffer} buffer - buffer object\n * @return {Shape} this object\n */\n addBuffer (buffer: Buffer) {\n this.bufferList.push(buffer)\n\n const geometry = (buffer as any).geometry // TODO\n if (!geometry.boundingBox) {\n geometry.computeBoundingBox()\n }\n this.boundingBox.union(geometry.boundingBox)\n\n return this\n }\n\n /**\n * Add a mesh\n * @example\n * shape.addMesh(\n * [ 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 0, 0, 0, 1 ],\n * [ 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 0 ]\n * );\n *\n * @param {Float32Array|Array} position - positions\n * @param {Float32Array|Array} color - colors\n * @param {Uint32Array|Uint16Array|Array} [index] - indices\n * @param {Float32Array|Array} [normal] - normals\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addMesh (position: Float32Array|number[], color:Float32Array|number[], index: Uint32Array|Uint16Array|number[], normal?: Float32Array|number[], name?: string) {\n position = ensureFloat32Array(position)\n color = ensureFloat32Array(color)\n\n if (Array.isArray(index)) {\n index = getUintArray(index, position.length)\n }\n if (normal) {\n normal = ensureFloat32Array(normal)\n }\n\n let data\n if (normal === undefined || normal.length == 0 ) {\n data = { position, color, index }\n } else {\n data = { position, color, index, normal }\n }\n //const data = { position, color, index, normal }\n const picking = new MeshPicker(\n this, Object.assign({ serial: this.meshCount, name }, data)\n )\n const meshBuffer = new MeshBuffer(\n Object.assign({ picking }, data) as any\n )\n this.bufferList.push(meshBuffer)\n\n tmpBox.setFromArray(position)\n this.boundingBox.union(tmpBox)\n this.meshCount += 1\n\n return this\n }\n\n /**\n * Add a sphere\n * @example\n * shape.addSphere([ 0, 0, 9 ], [ 1, 0, 0 ], 1.5);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addSphere (position: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, name: string) {\n SpherePrimitive.objectToShape(\n this, { position, color, radius, name }\n )\n return this\n }\n\n /**\n * Add an ellipsoid\n * @example\n * shape.addEllipsoid([ 6, 0, 0 ], [ 1, 0, 0 ], 1.5, [ 3, 0, 0 ], [ 0, 2, 0 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {Vector3|Array} majorAxis - major axis vector or array\n * @param {Vector3|Array} minorAxis - minor axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addEllipsoid (position: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, majorAxis: Vector3|[number, number, number], minorAxis: Vector3|[number, number, number], name: string) {\n EllipsoidPrimitive.objectToShape(\n this, { position, color, radius, majorAxis, minorAxis, name }\n )\n return this\n }\n\n /**\n * Add a torus\n * @example\n * shape.addTorus([ 6, 0, 0 ], [ 1, 0, 0 ], 1.5, [ 3, 0, 0 ], [ 0, 2, 0 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {Vector3|Array} majorAxis - major axis vector or array\n * @param {Vector3|Array} minorAxis - minor axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addTorus (position: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, majorAxis: Vector3|[number, number, number], minorAxis: Vector3|[number, number, number], name: string) {\n TorusPrimitive.objectToShape(\n this, { position, color, radius, majorAxis, minorAxis, name }\n )\n return this\n }\n\n /**\n * Add a cylinder\n * @example\n * shape.addCylinder([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ], 0.5);\n *\n * @param {Vector3|Array} position1 - from position vector or array\n * @param {Vector3|Array} position2 - to position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addCylinder (position1: Vector3|[number, number, number], position2: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, name: string) {\n CylinderPrimitive.objectToShape(\n this, { position1, position2, color, radius, name }\n )\n return this\n }\n\n /**\n * Add a cone\n * @example\n * shape.addCone([ 0, 2, 7 ], [ 0, 3, 3 ], [ 1, 1, 0 ], 1.5);\n *\n * @param {Vector3|Array} position1 - from position vector or array\n * @param {Vector3|Array} position2 - to position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addCone (position1: Vector3|[number, number, number], position2: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, name: string) {\n ConePrimitive.objectToShape(\n this, { position1, position2, color, radius, name }\n )\n return this\n }\n\n /**\n * Add an arrow\n * @example\n * shape.addArrow([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ], 0.5);\n *\n * @param {Vector3|Array} position1 - from position vector or array\n * @param {Vector3|Array} position2 - to position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} radius - radius value\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addArrow (position1: Vector3|[number, number, number], position2: Vector3|[number, number, number], color: Color|[number, number, number], radius: number, name: string) {\n ArrowPrimitive.objectToShape(\n this, { position1, position2, color, radius, name }\n )\n return this\n }\n\n /**\n * Add a box\n * @example\n * shape.addBox([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} size - size value\n * @param {Vector3|Array} heightAxis - height axis vector or array\n * @param {Vector3|Array} depthAxis - depth axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addBox (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, heightAxis: Vector3|[number, number, number], depthAxis: Vector3|[number, number, number], name: string) {\n BoxPrimitive.objectToShape(\n this, { position, color, size, heightAxis, depthAxis, name }\n )\n return this\n }\n\n /**\n * Add an octahedron\n * @example\n * shape.addOctahedron([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} size - size value\n * @param {Vector3|Array} heightAxis - height axis vector or array\n * @param {Vector3|Array} depthAxis - depth axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addOctahedron (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, heightAxis: Vector3|[number, number, number], depthAxis: Vector3|[number, number, number], name: string) {\n OctahedronPrimitive.objectToShape(\n this, { position, color, size, heightAxis, depthAxis, name }\n )\n return this\n }\n\n /**\n * Add a tetrahedron\n * @example\n * shape.addTetrahedron([ 0, 3, 0 ], [ 1, 0, 1 ], 2, [ 0, 1, 1 ], [ 1, 0, 1 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} size - size value\n * @param {Vector3|Array} heightAxis - height axis vector or array\n * @param {Vector3|Array} depthAxis - depth axis vector or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addTetrahedron (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, heightAxis: Vector3|[number, number, number], depthAxis: Vector3|[number, number, number], name: string) {\n TetrahedronPrimitive.objectToShape(\n this, { position, color, size, heightAxis, depthAxis, name }\n )\n return this\n }\n\n /**\n * Add text\n * @example\n * shape.addText([ 10, -2, 4 ], [ 0.2, 0.5, 0.8 ], 0.5, \"Hello\");\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {Float} size - size value\n * @param {String} text - text value\n * @return {Shape} this object\n */\n addText (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, text: string) {\n TextPrimitive.objectToShape(\n this, { position, color, size, text }\n )\n return this\n }\n\n /**\n * Add point\n * @example\n * shape.addPoint([ 10, -2, 4 ], [ 0.2, 0.5, 0.8 ]);\n *\n * @param {Vector3|Array} position - position vector or array\n * @param {Color|Array} color - color object or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addPoint (position: Vector3|[number, number, number], color: Color|[number, number, number], name: string) {\n PointPrimitive.objectToShape(\n this, { position, color, name }\n )\n return this\n }\n\n /**\n * Add a wideline\n * @example\n * shape.addWideline([ 0, 2, 7 ], [ 0, 0, 9 ], [ 1, 1, 0 ]);\n *\n * @param {Vector3|Array} position1 - from position vector or array\n * @param {Vector3|Array} position2 - to position vector or array\n * @param {Color|Array} color - color object or array\n * @param {String} [name] - text\n * @return {Shape} this object\n */\n addWideline (position1: Vector3|[number, number, number], position2: Vector3|[number, number, number], color: Color|[number, number, number], linewidth: number, name: string) {\n this.parameters.linewidth = linewidth\n WidelinePrimitive.objectToShape(\n this, { position1, position2, color, name }\n )\n return this\n }\n\n /**\n * Deprecated, use `.addText`\n */\n addLabel (position: Vector3|[number, number, number], color: Color|[number, number, number], size: number, text: string) {\n console.warn('Shape.addLabel is deprecated, use .addText instead')\n return this.addText(position, color, size, text)\n }\n\n getBufferList () {\n const buffers: Buffer[] = []\n\n Primitives.forEach(P => {\n if (this._primitiveData[ P.getShapeKey('color') ].length) {\n buffers.push(P.bufferFromShape(this, this.parameters))\n }\n })\n\n return this.bufferList.concat(buffers)\n }\n\n dispose () {\n this.bufferList.forEach(function (buffer) {\n buffer.dispose()\n })\n this.bufferList.length = 0\n\n Primitives.forEach(P => {\n Object.keys(P.fields).forEach(name => {\n this._primitiveData[ P.getShapeKey(name) ].length = 0\n })\n this._primitiveData[ P.getShapeKey('name') ].length = 0\n })\n }\n\n get center () {\n if (!this._center) {\n this._center = this.boundingBox.getCenter(new Vector3())\n }\n return this._center\n }\n\n get type () { return 'Shape' }\n}\n\nexport default Shape\n","/**\n * @file Buffer Representation\n * @author Alexander Rose \n * @private\n */\n\nimport Representation, { RepresentationParameters } from './representation'\nimport Viewer from '../viewer/viewer';\n\n/**\n * Representation for showing buffer objects. Good for efficiently showing\n * large amounts of geometric primitives e.g. spheres via {@link SphereBuffer}.\n * Smaller numbers of geometric primitives are more easily shown with help\n * from the {@link Shape} class.\n *\n * __Name:__ _buffer_\n *\n * @example\n * // add a single red sphere from a buffer to a shape instance\n * var shape = new NGL.Shape( \"shape\" );\n * var sphereBuffer = new NGL.SphereBuffer( {\n * position: new Float32Array( [ 0, 0, 0 ] ),\n * color: new Float32Array( [ 1, 0, 0 ] ),\n * radius: new Float32Array( [ 1 ] )\n * } );\n * shape.addBuffer( sphereBuffer );\n * var shapeComp = stage.addComponentFromObject( shape );\n * shapeComp.addRepresentation( \"buffer\" );\n *\n * @example\n * // add a single red sphere from a buffer to a structure component instance\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * var sphereBuffer = new NGL.SphereBuffer( {\n * position: new Float32Array( [ 0, 0, 0 ] ),\n * color: new Float32Array( [ 1, 0, 0 ] ),\n * radius: new Float32Array( [ 1 ] )\n * } );\n * o.addBufferRepresentation( sphereBuffer, { opacity: 0.5 } );\n * } );\n */\nclass BufferRepresentation extends Representation {\n buffer: Buffer[]\n /**\n * Create Buffer representation\n * @param {Buffer} buffer - a buffer object\n * @param {Viewer} viewer - a viewer object\n * @param {RepresentationParameters} params - representation parameters\n */\n constructor (buffer: Buffer|Buffer[], viewer: Viewer, params: Partial) {\n if (!Array.isArray(buffer)) {\n buffer = [ buffer ]\n }\n\n super(buffer, viewer, params)\n\n this.type = 'buffer'\n\n this.parameters = Object.assign({\n\n }, this.parameters, {\n\n colorScheme: null,\n colorScale: null,\n colorValue: null,\n colorDomain: null,\n colorMode: null\n\n })\n\n this.buffer = buffer\n\n this.init(params)\n }\n\n init (params: Partial) {\n super.init(params)\n\n this.build()\n }\n\n create () {\n this.bufferList.push.apply(this.bufferList, this.buffer)\n }\n\n attach (callback: ()=> void) {\n this.bufferList.forEach(buffer => {\n this.viewer.add(buffer)\n buffer.setParameters(this.getBufferParams())\n })\n this.setVisibility(this.visible)\n\n callback()\n }\n}\n\nexport default BufferRepresentation\n","/**\n * @file Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3 required for declaration only\n import { Vector3, Matrix4, Matrix3, BufferGeometry } from 'three'\n\nimport { getUintArray } from '../utils'\nimport { serialBlockArray } from '../math/array-utils'\nimport { applyMatrix3toVector3array, applyMatrix4toVector3array } from '../math/vector-utils'\nimport MeshBuffer from './mesh-buffer'\nimport { BufferParameters, BufferData } from './buffer'\nimport {Log} from \"../globals\";\n\nconst matrix = new Matrix4()\nconst normalMatrix = new Matrix3()\n\nfunction getData(data: BufferData, geo: BufferGeometry){\n const geoPosition = (geo.attributes as any).position.array\n const geoIndex = geo.index ? geo.index.array : undefined\n\n const n = data.position!.length / 3\n const m = geoPosition.length / 3\n\n const size = n * m\n\n const meshPosition = new Float32Array(size * 3)\n const meshNormal = new Float32Array(size * 3)\n const meshColor = new Float32Array(size * 3)\n\n let meshIndex\n if (geoIndex) {\n meshIndex = getUintArray(n * geoIndex.length, size)\n }\n\n return {\n position: meshPosition,\n color: meshColor,\n index: meshIndex,\n normal: meshNormal,\n primitiveId: data.primitiveId || serialBlockArray(n, m) as Float32Array,\n picking: data.picking\n }\n}\n\n/**\n * Geometry buffer. Base class for geometry-based buffers. Used to draw\n * geometry primitives given a mesh.\n * @interface\n */\nabstract class GeometryBuffer extends MeshBuffer {\n updateNormals = false\n\n geoPosition: Float32Array\n geoNormal: Float32Array\n geoIndex?: Uint32Array|Uint16Array\n\n positionCount: number\n geoPositionCount: number\n\n transformedGeoPosition: Float32Array\n transformedGeoNormal: Float32Array\n\n meshPosition: Float32Array\n meshColor: Float32Array\n meshIndex: Uint32Array|Uint16Array\n meshNormal: Float32Array\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n * @param {BufferGeometry} geo - geometry object\n */\n constructor (data: BufferData, params: Partial = {}, geo: BufferGeometry) {\n super(getData(data, geo), params)\n\n const geoPosition = (geo.attributes as any).position.array\n const geoNormal = (geo.attributes as any).normal.array\n const geoIndex = geo.index ? (geo.index.array as Uint32Array|Uint16Array) : undefined\n\n this.geoPosition = geoPosition\n this.geoNormal = geoNormal\n this.geoIndex = geoIndex\n\n this.positionCount = data.position!.length / 3\n this.geoPositionCount = geoPosition.length / 3\n\n this.transformedGeoPosition = new Float32Array(this.geoPositionCount * 3)\n this.transformedGeoNormal = new Float32Array(this.geoPositionCount * 3)\n\n const attributes = this.geometry.attributes as any // TODO\n this.meshPosition = attributes.position.array\n this.meshColor = attributes.color.array\n this.meshNormal = attributes.normal.array\n\n this.setAttributes(data)\n\n if (geoIndex) {\n const index = this.geometry.getIndex()\n if (!index) { Log.error('Index is null'); return; }\n this.meshIndex = index.array as Uint32Array|Uint16Array\n this.makeIndex()\n }\n }\n\n abstract applyPositionTransform (matrix: Matrix4, i: number, i3?: number): void\n\n setAttributes (data: Partial = {}, initNormals = false) {\n const attributes = this.geometry.attributes as any // TODO\n\n let position, color\n let geoPosition, geoNormal\n let transformedGeoPosition, transformedGeoNormal\n let meshPosition, meshColor, meshNormal\n\n const updateNormals = this.updateNormals\n\n if (data.position) {\n position = data.position\n geoPosition = this.geoPosition\n meshPosition = this.meshPosition\n transformedGeoPosition = this.transformedGeoPosition\n attributes.position.needsUpdate = true\n if (updateNormals || initNormals) {\n geoNormal = this.geoNormal\n meshNormal = this.meshNormal\n transformedGeoNormal = this.transformedGeoNormal\n attributes.normal.needsUpdate = true\n }\n }\n\n if (data.color) {\n color = data.color\n meshColor = this.meshColor\n attributes.color.needsUpdate = true\n }\n\n const n = this.positionCount\n const m = this.geoPositionCount\n\n for (let i = 0; i < n; ++i) {\n let j, l\n const k = i * m * 3\n const i3 = i * 3\n\n if (position && transformedGeoPosition && meshPosition && meshNormal && geoPosition && geoNormal) {\n transformedGeoPosition.set(geoPosition)\n matrix.makeTranslation(\n position[ i3 ], position[ i3 + 1 ], position[ i3 + 2 ]\n )\n this.applyPositionTransform(matrix, i, i3)\n applyMatrix4toVector3array(matrix.elements as unknown as Float32Array,\n transformedGeoPosition)\n\n meshPosition.set(transformedGeoPosition, k)\n\n if (updateNormals && transformedGeoNormal) {\n transformedGeoNormal.set(geoNormal)\n normalMatrix.getNormalMatrix(matrix)\n applyMatrix3toVector3array(normalMatrix.elements as unknown as Float32Array,\n transformedGeoNormal)\n\n meshNormal.set(transformedGeoNormal, k)\n } else if (initNormals) {\n meshNormal.set(geoNormal, k)\n }\n }\n\n if (color && meshColor) {\n for (j = 0; j < m; ++j) {\n l = k + 3 * j\n\n meshColor[ l ] = color[ i3 ]\n meshColor[ l + 1 ] = color[ i3 + 1 ]\n meshColor[ l + 2 ] = color[ i3 + 2 ]\n }\n }\n }\n }\n\n makeIndex () {\n const geoIndex = this.geoIndex\n const meshIndex = this.meshIndex\n\n if (!geoIndex) return\n\n const n = this.positionCount\n const m = this.geoPositionCount\n const o = geoIndex.length / 3\n\n const o3 = o * 3\n\n for (let i = 0; i < n; ++i) {\n const j = i * o3\n const q = j + o3\n\n meshIndex.set(geoIndex, j)\n for (let p = j; p < q; ++p) meshIndex[ p ] += i * m\n }\n }\n}\n\nexport default GeometryBuffer\n","/**\n * @file Sphere Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { IcosahedronBufferGeometry, Vector3, Matrix4 } from 'three'\nimport { defaults } from '../utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { SphereBufferData } from './sphere-buffer'\nimport { BufferDefaultParameters, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\n\nexport const SphereGeometryBufferDefaultParameters = Object.assign({\n sphereDetail: 1\n}, BufferDefaultParameters)\nexport type SphereGeometryBufferParameters = BufferParameters & { sphereDetail: number }\n\n/**\n * Sphere geometry buffer.\n *\n * @example\n * var sphereGeometryBuffer = new SphereGeometryBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass SphereGeometryBuffer extends GeometryBuffer {\n get defaultParameters() { return SphereGeometryBufferDefaultParameters }\n parameters: SphereGeometryBufferParameters\n\n private _radius: Float32Array\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: SphereBufferData, params: Partial = {}) {\n super(data, params, new IcosahedronBufferGeometry(1, defaults(params.sphereDetail, 1)))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number) {\n const r = this._radius[ i ]\n scale.set(r, r, r)\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.radius) this._radius = data.radius\n\n super.setAttributes(data, initNormals)\n }\n}\n\nexport default SphereGeometryBuffer\n","/**\n * @file Mapped Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { getUintArray } from '../utils'\nimport { calculateCenterArray, serialArray } from '../math/array-utils'\nimport Buffer, { BufferParameters, BufferData } from './buffer'\n\nexport type MappingType = 'v2'|'v3'\n\n/**\n * Mapped buffer. Sends mapping attribute to the GPU and repeats data in\n * others attributes. Used to render imposters.\n * @interface\n */\nabstract class MappedBuffer extends Buffer {\n index: Uint32Array|Uint16Array\n\n constructor (mappingType: MappingType, data: BufferData, params: Partial = {}) {\n super(data, params)\n\n this.index = getUintArray(this.indexSize, this.attributeSize)\n this.makeIndex()\n this.initIndex(this.index)\n\n this.addAttributes({\n 'mapping': { type: mappingType, value: null }\n })\n\n this.setAttributes({ primitiveId: serialArray(this.size) })\n }\n\n abstract get mapping (): Float32Array\n abstract get mappingIndices (): Uint32Array|Uint16Array\n abstract get mappingIndicesSize (): number\n abstract get mappingSize (): number\n abstract get mappingItemSize (): number\n\n get attributeSize () {\n return this.size * this.mappingSize\n }\n\n get indexSize () {\n return this.size * this.mappingIndicesSize\n }\n\n addAttributes (attributes: any) {\n const nullValueAttributes: any = {}\n for (const name in attributes) {\n const a = attributes[ name ]\n nullValueAttributes[ name ] = {\n type: a.type,\n value: null\n }\n }\n\n super.addAttributes(nullValueAttributes)\n }\n\n getAttributeIndex (dataIndex: number) {\n return dataIndex * 3 * this.mappingSize\n }\n\n setAttributes (data: any) { // TODO\n if (data && !data.position && data.position1 && data.position2) {\n data.position = calculateCenterArray(data.position1, data.position2)\n }\n\n const size = this.size\n const mappingSize = this.mappingSize\n const attributes = this.geometry.attributes as any // TODO\n\n let a, d, itemSize, array, n, i, j\n\n for (const name in data) {\n if (name === 'index' || name === 'picking') continue\n\n d = data[ name ]\n a = attributes[ name ]\n itemSize = a.itemSize\n array = a.array\n\n for (let k = 0; k < size; ++k) {\n n = k * itemSize\n i = n * mappingSize\n\n for (let l = 0; l < mappingSize; ++l) {\n j = i + (itemSize * l)\n\n for (let m = 0; m < itemSize; ++m) {\n array[ j + m ] = d[ n + m ]\n }\n }\n }\n\n a.needsUpdate = true\n }\n }\n\n makeMapping () {\n const size = this.size\n const mapping = this.mapping\n const mappingSize = this.mappingSize\n const mappingItemSize = this.mappingItemSize\n\n const attributes = this.geometry.attributes as any // TODO\n const aMapping = attributes.mapping.array\n\n for (let v = 0; v < size; v++) {\n aMapping.set(mapping, v * mappingItemSize * mappingSize)\n }\n }\n\n makeIndex () {\n const size = this.size\n const mappingSize = this.mappingSize\n const mappingIndices = this.mappingIndices\n const mappingIndicesSize = this.mappingIndicesSize\n\n const index = this.index\n\n for (let v = 0; v < size; v++) {\n const ix = v * mappingIndicesSize\n const it = v * mappingSize\n\n index.set(mappingIndices, ix)\n\n for (let s = 0; s < mappingIndicesSize; ++s) {\n index[ ix + s ] += it\n }\n }\n }\n}\n\nexport default MappedBuffer\n","/**\n * @file Mapped Quad Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { BufferParameters, BufferData } from './buffer'\nimport MappedBuffer from './mapped-buffer'\n\nconst mapping = new Float32Array([\n -1.0, 1.0,\n -1.0, -1.0,\n 1.0, 1.0,\n 1.0, -1.0\n])\n\nconst mappingIndices = new Uint16Array([\n 0, 1, 2,\n 1, 3, 2\n])\n\n/**\n * Mapped Quad buffer. Draws screen-aligned quads. Used to render impostors.\n * @interface\n */\nclass MappedQuadBuffer extends MappedBuffer {\n constructor(data: BufferData, params: Partial = {}) {\n super('v2', data, params)\n }\n get mapping () { return mapping }\n get mappingIndices () { return mappingIndices }\n get mappingIndicesSize () { return 6 }\n get mappingSize () { return 4 }\n get mappingItemSize () { return 2 }\n}\n\nexport default MappedQuadBuffer\n","/**\n * @file Sphere Impostor Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport '../shader/SphereImpostor.vert'\nimport '../shader/SphereImpostor.frag'\n\nimport MappedQuadBuffer from './mappedquad-buffer'\nimport { SphereBufferData } from './sphere-buffer'\nimport { BufferParameters } from './buffer'\n\n/**\n * Sphere impostor buffer.\n *\n * @example\n * var sphereImpostorBuffer = new SphereImpostorBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass SphereImpostorBuffer extends MappedQuadBuffer {\n isImpostor = true\n vertexShader = 'SphereImpostor.vert'\n fragmentShader = 'SphereImpostor.frag'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: SphereBufferData, params: Partial = {}) {\n super(data, params)\n\n this.addUniforms({\n 'projectionMatrixInverse': { value: new Matrix4() },\n 'ortho': { value: 0.0 }\n })\n\n this.addAttributes({\n 'radius': { type: 'f', value: null }\n })\n\n this.setAttributes(data)\n this.makeMapping()\n }\n}\n\nexport default SphereImpostorBuffer\n","/**\n * @file Sphere Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only \nimport { Vector3, Matrix4 } from 'three'\nimport { BufferRegistry, ExtensionFragDepth } from '../globals'\nimport SphereGeometryBuffer, { SphereGeometryBufferDefaultParameters, SphereGeometryBufferParameters } from './spheregeometry-buffer'\nimport SphereImpostorBuffer from './sphereimpostor-buffer'\nimport { BufferData } from './buffer'\n\nexport interface SphereBufferData extends BufferData {\n radius: Float32Array\n}\n\nexport const SphereBufferDefaultParameters = Object.assign({\n disableImpostor: false\n}, SphereGeometryBufferDefaultParameters)\nexport type SphereBufferParameters = SphereGeometryBufferParameters & { disableImpostor: boolean }\n\nclass SphereBufferImpl {\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} params - parameters object\n * @return {SphereGeometryBuffer|SphereImpostorBuffer} the buffer object\n */\n constructor (data: SphereBufferData, params: SphereBufferParameters) {\n if (!ExtensionFragDepth || (params && params.disableImpostor)) {\n return new SphereGeometryBuffer(data, params)\n } else {\n return new SphereImpostorBuffer(data, params)\n }\n }\n}\n\n/**\n * Sphere buffer. Depending on the value {@link ExtensionFragDepth} and\n * `params.disableImpostor` the constructor returns either a\n * {@link SphereGeometryBuffer} or a {@link SphereImpostorBuffer}\n * @implements {Buffer}\n *\n * @example\n * var sphereBuffer = new SphereBuffer( {\n * position: new Float32Array( [ 0, 0, 0 ] ),\n * color: new Float32Array( [ 1, 0, 0 ] ),\n * radius: new Float32Array( [ 1 ] )\n * } );\n */\n//@ts-expect-error Incompatible constructor signatures\nconst SphereBuffer: {\n new(data: SphereBufferData, params: SphereBufferParameters): SphereGeometryBuffer | SphereImpostorBuffer;\n} = SphereBufferImpl;\n\ntype SphereBuffer = SphereGeometryBuffer | SphereImpostorBuffer;\n\nBufferRegistry.add('sphere', SphereBuffer)\n\nexport default SphereBuffer\n","/**\n * @file Point Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { DataTexture, Vector3, Matrix4 } from 'three'\n\nimport '../shader/Point.vert'\nimport '../shader/Point.frag'\n\nimport { BufferRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { smoothstep } from '../math/math-utils'\nimport Buffer, { BufferDefaultParameters, BufferParameterTypes, BufferData, BufferTypes, BufferParameters } from './buffer'\n\nfunction distance (x0: number, y0: number, x1: number, y1: number) {\n const dx = x1 - x0\n const dy = y1 - y0\n return Math.sqrt(dx * dx + dy * dy)\n}\n\ninterface PointTextureParams {\n width?: number\n height?: number\n delta?: number\n}\n\nfunction makePointTexture (params: PointTextureParams) {\n const p = params || {}\n\n const width = defaults(p.width, 256)\n const height = defaults(p.height, 256)\n const center = [ width / 2, height / 2 ]\n const radius = Math.min(width / 2, height / 2)\n const delta = defaults(p.delta, 1 / (radius + 1)) * radius\n\n let x = 0\n let y = 0\n const data = new Uint8Array(width * height * 4)\n\n for (let i = 0, il = data.length; i < il; i += 4) {\n const dist = distance(x, y, center[ 0 ], center[ 1 ])\n const value = 1 - smoothstep(radius - delta, radius, dist)\n\n data[ i ] = value * 255\n data[ i + 1 ] = value * 255\n data[ i + 2 ] = value * 255\n data[ i + 3 ] = value * 255\n\n if (++x === width) {\n x = 0\n y++\n }\n }\n\n const tex = new DataTexture(data, width, height)\n tex.needsUpdate = true\n\n return tex\n}\n\nexport const PointBufferDefaultParameters = Object.assign({\n pointSize: 1,\n sizeAttenuation: true,\n sortParticles: false,\n alphaTest: 0.5,\n useTexture: false,\n forceTransparent: false,\n edgeBleach: 0.0\n}, BufferDefaultParameters)\nexport type PointBufferParameters = BufferParameters & {\n pointSize: number,\n sizeAttenuation: boolean,\n sortParticles: boolean,\n alphaTest: number,\n useTexture: boolean,\n forceTransparent: boolean,\n edgeBleach: number\n}\n\nconst PointBufferParameterTypes = Object.assign({\n pointSize: { uniform: 'size' },\n sizeAttenuation: { updateShader: true },\n sortParticles: {},\n alphaTest: { updateShader: true },\n useTexture: { updateShader: true },\n forceTransparent: {},\n edgeBleach: { uniform: true }\n}, BufferParameterTypes)\n\n/**\n * Point buffer. Draws points. Optionally textured.\n *\n * @example\n * var pointBuffer = new PointBuffer( {\n * position: new Float32Array( [ 0, 0, 0 ] ),\n * color: new Float32Array( [ 1, 0, 0 ] )\n * } );\n */\nclass PointBuffer extends Buffer {\n parameterTypes = PointBufferParameterTypes\n get defaultParameters() { return PointBufferDefaultParameters }\n parameters: PointBufferParameters\n\n vertexShader = 'Point.vert'\n fragmentShader ='Point.frag'\n\n isPoint = true\n tex: DataTexture\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: BufferData, params: Partial = {}) {\n super(data, params)\n\n this.addUniforms({\n 'size': { value: this.parameters.pointSize },\n 'canvasHeight': { value: 1.0 },\n 'pixelRatio': { value: 1.0 },\n 'map': { value: null }\n })\n }\n\n makeMaterial () {\n super.makeMaterial()\n\n this.makeTexture()\n\n const m = this.material\n const wm = this.wireframeMaterial\n const pm = this.pickingMaterial\n\n m.uniforms.map.value = this.tex\n m.needsUpdate = true\n\n wm.uniforms.map.value = this.tex\n wm.needsUpdate = true\n\n pm.uniforms.map.value = this.tex\n pm.needsUpdate = true\n }\n\n makeTexture () {\n if (this.tex) this.tex.dispose()\n this.tex = makePointTexture({ delta: this.parameters.edgeBleach })\n }\n\n getDefines (type?: BufferTypes) {\n const defines = super.getDefines(type)\n\n if (this.parameters.sizeAttenuation) {\n defines.USE_SIZEATTENUATION = 1\n }\n\n if (this.parameters.useTexture) {\n defines.USE_MAP = 1\n }\n\n if (this.parameters.alphaTest > 0 && this.parameters.alphaTest <= 1) {\n defines.ALPHATEST = this.parameters.alphaTest.toPrecision(2)\n }\n\n return defines\n }\n\n setUniforms (data: any) {\n if (data && data.edgeBleach !== undefined) {\n this.makeTexture()\n data.map = this.tex\n }\n\n super.setUniforms(data)\n }\n\n dispose () {\n super.dispose()\n\n if (this.tex) this.tex.dispose()\n }\n}\n\nBufferRegistry.add('point', PointBuffer)\n\nexport default PointBuffer\n","/**\n * @file Dot Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { ExtensionFragDepth } from '../globals'\nimport { defaults } from '../utils'\nimport Representation, { RepresentationParameters } from './representation'\nimport Volume from '../surface/volume'\nimport FilteredVolume from '../surface/filtered-volume'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport PointBuffer from '../buffer/point-buffer'\nimport Surface from '../surface/surface';\nimport Viewer from '../viewer/viewer';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\n\nexport interface DotDataFields {\n color?: boolean,\n radius?: boolean,\n scale?: boolean\n}\n\n/**\n * Dot representation parameter object. Extends {@link RepresentationParameters}\n *\n * @typedef {Object} DotRepresentationParameters - dot representation parameters\n *\n * @property {String} thresholdType - Meaning of the threshold values. Either *value* for the literal value or *sigma* as a factor of the sigma of the data. For volume data only.\n * @property {Number} thresholdMin - Minimum value to be displayed. For volume data only.\n * @property {Number} thresholdMax - Maximum value to be displayed. For volume data only.\n * @property {Number} thresholdOut - Show only values falling outside of the treshold minumum and maximum. For volume data only.\n */\nexport interface DotRepresentationParameters extends RepresentationParameters {\n thresholdType: 'value'|'value'|'sigma'|'sigma'\n thresholdMin: number\n thresholdMax: number\n thresholdOut: boolean\n dotType: ''|'sphere'|'point'\n radiusType: ''|'value'|'abs-value'|'value-min'|'deviation'|'size'|'radius' //TODO had to add 'radius' because of test in line 333\n radius: number\n scale: number\n sphereDetail: number\n disableImpostor: boolean\n pointSize: number\n sizeAttenuation: boolean\n sortParticles: boolean\n useTexture: boolean\n alphaTest: number\n forceTransparent: boolean\n edgeBleach: number\n}\n/**\n * Dot representation\n */\nclass DotRepresentation extends Representation {\n protected thresholdType: 'value'|'value'|'sigma'|'sigma'\n protected thresholdMin: number\n protected thresholdMax: number\n protected thresholdOut: boolean\n protected dotType: ''|'sphere'|'point'\n protected radiusType: ''|'value'|'abs-value'|'value-min'|'deviation'|'size'|'radius' //TODO had to add 'radius' because of test in line 333\n protected radius: number\n protected scale: number\n protected sphereDetail: number\n protected disableImpostor: boolean\n protected pointSize: number\n protected sizeAttenuation: boolean\n protected sortParticles: boolean\n protected useTexture: boolean\n protected alphaTest: number\n protected forceTransparent: boolean\n protected edgeBleach: number\n\n protected surface: Surface|undefined\n protected volume: FilteredVolume|undefined\n protected dotBuffer: SphereBuffer|PointBuffer\n /**\n * Create Dot representation object\n * @param {Surface|Volume} surface - the surface or volume to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {DotRepresentationParameters} params - dot representation parameters\n */\n constructor (surface: Surface, viewer: Viewer, params: Partial) {\n super(surface, viewer, params)\n\n this.type = 'dot'\n\n this.parameters = Object.assign({\n\n thresholdType: {\n type: 'select',\n rebuild: true,\n options: {\n 'value': 'value', 'sigma': 'sigma'\n }\n },\n thresholdMin: {\n type: 'number', precision: 3, max: Infinity, min: -Infinity, rebuild: true\n },\n thresholdMax: {\n type: 'number', precision: 3, max: Infinity, min: -Infinity, rebuild: true\n },\n thresholdOut: {\n type: 'boolean', rebuild: true\n },\n dotType: {\n type: 'select',\n rebuild: true,\n options: {\n '': '',\n 'sphere': 'sphere',\n 'point': 'point'\n }\n },\n radiusType: {\n type: 'select',\n options: {\n '': '',\n 'value': 'value',\n 'abs-value': 'abs-value',\n 'value-min': 'value-min',\n 'deviation': 'deviation',\n 'size': 'size'\n }\n },\n radius: {\n type: 'number', precision: 3, max: 10.0, min: 0.001, property: 'size'\n },\n scale: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n sphereDetail: true,\n disableImpostor: true,\n\n pointSize: {\n type: 'number', precision: 1, max: 100, min: 0, buffer: true\n },\n sizeAttenuation: {\n type: 'boolean', buffer: true\n },\n sortParticles: {\n type: 'boolean', rebuild: true\n },\n useTexture: {\n type: 'boolean', buffer: true\n },\n alphaTest: {\n type: 'range', step: 0.001, max: 1, min: 0, buffer: true\n },\n forceTransparent: {\n type: 'boolean', buffer: true\n },\n edgeBleach: {\n type: 'range', step: 0.001, max: 1, min: 0, buffer: true\n }\n\n }, this.parameters, {\n\n colorScheme: {\n type: 'select',\n update: 'color',\n options: {\n '': '',\n 'value': 'value',\n 'uniform': 'uniform',\n 'random': 'random'\n }\n }\n\n })\n\n if (surface instanceof Volume) {\n this.surface = undefined\n this.volume = new FilteredVolume(surface)\n } else {\n this.surface = surface\n this.volume = undefined\n }\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'uniform')\n p.colorValue = defaults(p.colorValue, 0xDDDDDD)\n\n this.thresholdType = defaults(p.thresholdType, 'sigma')\n this.thresholdMin = defaults(p.thresholdMin, 2.0)\n this.thresholdMax = defaults(p.thresholdMax, Infinity)\n this.thresholdOut = defaults(p.thresholdOut, false)\n this.dotType = defaults(p.dotType, 'point')\n this.radius = defaults(p.radius, 0.1)\n this.scale = defaults(p.scale, 1.0)\n\n this.pointSize = defaults(p.pointSize, 1)\n this.sizeAttenuation = defaults(p.sizeAttenuation, true)\n this.sortParticles = defaults(p.sortParticles, false)\n this.useTexture = defaults(p.useTexture, false)\n this.alphaTest = defaults(p.alphaTest, 0.5)\n this.forceTransparent = defaults(p.forceTransparent, false)\n this.edgeBleach = defaults(p.edgeBleach, 0.0)\n\n super.init(p)\n\n this.build()\n }\n\n attach (callback: () => void) {\n this.bufferList.forEach(buffer => {\n this.viewer.add(buffer)\n })\n this.setVisibility(this.visible)\n\n callback()\n }\n\n create () {\n var dotData: SphereBufferData|{} = {}\n\n if (this.volume) {\n var volume = this.volume\n var thresholdMin, thresholdMax\n\n if (this.thresholdType === 'sigma') {\n thresholdMin = volume.getValueForSigma(this.thresholdMin)\n thresholdMax = volume.getValueForSigma(this.thresholdMax)\n } else {\n thresholdMin = this.thresholdMin\n thresholdMax = this.thresholdMax\n }\n volume.setFilter(thresholdMin, thresholdMax, this.thresholdOut)\n\n Object.assign(dotData, {\n position: volume.getDataPosition(),\n color: volume.getDataColor(this.getColorParams())\n })\n if (this.dotType === 'sphere') {\n Object.assign(dotData, {\n radius: volume.getDataSize(this.radius, this.scale),\n picking: volume.getDataPicking()\n })\n }\n } else {\n var surface = this.surface\n Object.assign(dotData, {\n position: (surface as Surface).getPosition(),\n color: (surface as Surface).getColor(this.getColorParams())\n })\n if (this.dotType === 'sphere') {\n Object.assign(dotData, {\n radius: (surface as Surface).getSize(this.radius, this.scale),\n picking: (surface as Surface).getPicking()\n })\n }\n }\n\n if (this.dotType === 'sphere') {\n this.dotBuffer = new SphereBuffer(\n dotData as SphereBufferData,\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: false\n }) as SphereBufferParameters\n ) as SphereGeometryBuffer\n } else {\n this.dotBuffer = new PointBuffer(\n dotData,\n this.getBufferParams({\n pointSize: this.pointSize,\n sizeAttenuation: this.sizeAttenuation,\n sortParticles: this.sortParticles,\n useTexture: this.useTexture,\n alphaTest: this.alphaTest,\n forceTransparent: this.forceTransparent,\n edgeBleach: this.edgeBleach\n })\n )\n }\n\n this.bufferList.push(this.dotBuffer as SphereGeometryBuffer)\n }\n\n update (what: DotDataFields = {}) {\n if (this.bufferList.length === 0) return\n\n const dotData: SphereBufferData|{} = {}\n\n if (what.color) {\n if (this.volume) {\n Object.assign(dotData, {\n color: this.volume.getDataColor(\n this.getColorParams()\n )\n })\n } else {\n Object.assign(dotData, {\n color: (this.surface as Surface).getColor(\n this.getColorParams()\n )\n })\n }\n }\n\n if (this.dotType === 'sphere' && (what.radius || what.scale)) {\n if (this.volume) {\n Object.assign(dotData, {\n radius: this.volume.getDataSize(\n this.radius, this.scale\n )\n })\n } else {\n Object.assign(dotData, {\n radius: (this.surface as Surface).getSize(\n this.radius, this.scale\n )\n })\n }\n }\n\n (this.dotBuffer as SphereGeometryBuffer).setAttributes(dotData)\n }\n\n setParameters (params: Partial, what: DotDataFields = {}, rebuild: boolean) {\n \n if (params && params.thresholdType !== undefined &&\n this.volume instanceof Volume\n ) {\n if (this.thresholdType === 'value' &&\n params.thresholdType === 'sigma'\n ) {\n this.thresholdMin = this.volume.getSigmaForValue(\n this.thresholdMin\n )\n this.thresholdMax = this.volume.getSigmaForValue(\n this.thresholdMax\n )\n } else if (this.thresholdType === 'sigma' &&\n params.thresholdType === 'value'\n ) {\n this.thresholdMin = this.volume.getValueForSigma(\n this.thresholdMin\n )\n this.thresholdMax = this.volume.getValueForSigma(\n this.thresholdMax\n )\n }\n\n this.thresholdType = params.thresholdType\n }\n\n if (params && params.radiusType !== undefined) {\n if (params.radiusType === 'radius') {\n this.radius = 0.1\n } else {\n this.radius = parseFloat(params.radiusType)\n }\n what.radius = true\n if (this.dotType === 'sphere' &&\n (!ExtensionFragDepth || this.disableImpostor)\n ) {\n rebuild = true\n }\n }\n\n if (params && params.radius !== undefined) {\n what.radius = true\n if (this.dotType === 'sphere' &&\n (!ExtensionFragDepth || this.disableImpostor)\n ) {\n rebuild = true\n }\n }\n\n if (params && params.scale !== undefined) {\n what.scale = true\n if (this.dotType === 'sphere' &&\n (!ExtensionFragDepth || this.disableImpostor)\n ) {\n rebuild = true\n }\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nexport default DotRepresentation\n","/**\n * @file Image Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport {\n // @ts-ignore: unused import Vector3, Matrix4 required for declaration only\n Vector2, Vector3, Matrix4, BufferAttribute, DataTexture,\n NormalBlending, NearestFilter, LinearFilter\n} from 'three'\n\nimport '../shader/Image.vert'\nimport '../shader/Image.frag'\n\nimport { Picker } from '../utils/picker'\nimport Buffer, { BufferDefaultParameters, BufferParameterTypes, BufferTypes } from './buffer'\n\n\nconst quadIndices = new Uint16Array([\n 0, 1, 2,\n 1, 3, 2\n])\n\nconst quadUvs = new Float32Array([\n 0, 1,\n 0, 0,\n 1, 1,\n 1, 0\n])\n\ntype ImageFilterTypes = 'nearest'|'linear'|'cubic-bspline'|'cubic-catmulrom'|'cubic-mitchell'\n\nexport interface ImageBufferData {\n position: Float32Array\n imageData: Uint8Array\n width: number\n height: number\n\n picking?: Picker\n}\n\nexport const ImageBufferDefaultParameters = Object.assign({\n filter: 'nearest' as ImageFilterTypes,\n forceTransparent: true\n}, BufferDefaultParameters)\nexport type ImageBufferParameters = typeof ImageBufferDefaultParameters\n\nexport const ImageBufferParameterTypes = Object.assign({\n filter: { updateShader: true, uniform: true }\n}, BufferParameterTypes)\n\n/**\n * Image buffer. Draw a single image. Optionally interpolate.\n */\nclass ImageBuffer extends Buffer {\n parameterTypes = ImageBufferParameterTypes\n get defaultParameters() { return ImageBufferDefaultParameters }\n parameters: ImageBufferParameters\n\n alwaysTransparent = true\n hasWireframe = false\n vertexShader = 'Image.vert'\n fragmentShader = 'Image.frag'\n\n tex: DataTexture\n pickingTex: DataTexture\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position - image position\n * @param {Float32Array} data.imageData - image data, rgba channels\n * @param {Float32Array} data.width - image width\n * @param {Float32Array} data.height - image height\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n */\n constructor (data: ImageBufferData, params: ImageBufferParameters) {\n super({\n position: data.position,\n index: quadIndices,\n picking: data.picking\n }, params)\n\n const {imageData, width, height} = data\n\n const tex = new DataTexture(imageData, width, height)\n tex.flipY = true\n this.tex = tex\n\n const n = imageData.length\n const pickingData = new Uint8Array(n)\n for (let i = 0; i < n; i += 4) {\n const j = i / 4\n pickingData[ i ] = j >> 16 & 255\n pickingData[ i + 1 ] = j >> 8 & 255\n pickingData[ i + 2 ] = j & 255\n }\n\n const pickingTex = new DataTexture(pickingData, width, height)\n pickingTex.flipY = true\n pickingTex.minFilter = NearestFilter\n pickingTex.magFilter = NearestFilter\n this.pickingTex = pickingTex\n\n this.addUniforms({\n 'map': { value: tex },\n 'pickingMap': { value: pickingTex },\n 'mapSize': { value: new Vector2(width, height) }\n })\n\n this.geometry.setAttribute('uv', new BufferAttribute(quadUvs, 2))\n }\n\n getDefines (type: BufferTypes) {\n const defines = super.getDefines(type)\n const filter = this.parameters.filter\n\n if (filter.startsWith('cubic')) {\n defines.CUBIC_INTERPOLATION = 1\n if (filter.endsWith('bspline')) {\n defines.BSPLINE_FILTER = 1\n } else if (filter.endsWith('catmulrom')) {\n defines.CATMULROM_FILTER = 1\n } else if (filter.endsWith('mitchell')) {\n defines.MITCHELL_FILTER = 1\n }\n }\n\n return defines\n }\n\n updateTexture () {\n const tex = this.tex\n const filter = this.parameters.filter\n\n if (filter.startsWith('cubic')) {\n tex.minFilter = NearestFilter\n tex.magFilter = NearestFilter\n } else if (filter === 'linear') {\n tex.minFilter = LinearFilter\n tex.magFilter = LinearFilter\n } else { // filter === \"nearest\"\n tex.minFilter = NearestFilter\n tex.magFilter = NearestFilter\n }\n\n tex.needsUpdate = true\n this.pickingTex.needsUpdate = true\n }\n\n makeMaterial () {\n super.makeMaterial()\n this.updateTexture()\n\n const m = this.material\n m.uniforms.map.value = this.tex\n m.blending = NormalBlending\n m.needsUpdate = true\n\n const wm = this.wireframeMaterial\n wm.uniforms.map.value = this.tex\n wm.blending = NormalBlending\n wm.needsUpdate = true\n\n const pm = this.pickingMaterial\n pm.uniforms.map.value = this.tex\n pm.uniforms.pickingMap.value = this.pickingTex\n pm.blending = NormalBlending\n pm.needsUpdate = true\n }\n\n setUniforms (data: any) { // TODO\n if (data && data.filter !== undefined) {\n this.updateTexture()\n data.map = this.tex\n }\n\n super.setUniforms(data)\n }\n}\n\nexport default ImageBuffer\n","/**\n * @file Volume Slice\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { SlicePicker } from '../utils/picker'\nimport { Volume } from '../ngl';\nimport { SliceRepresentationParameters } from '../representation/slice-representation';\n\nclass VolumeSlice {\n dimension: 'x'|'y'|'z'\n positionType: 'percent'|'coordinate'\n position: number\n thresholdType: 'sigma'|'value'\n thresholdMin: number\n thresholdMax: number\n normalize: boolean\n volume: Volume\n\n constructor (volume: Volume, params: Partial) {\n const p = params || {}\n\n this.dimension = defaults(p.dimension, 'x')\n this.positionType = defaults(p.positionType, 'percent')\n this.position = defaults(p.position, 30)\n this.thresholdType = defaults(p.thresholdType, 'sigma')\n this.thresholdMin = defaults(p.thresholdMin, -Infinity)\n this.thresholdMax = defaults(p.thresholdMax, Infinity)\n this.normalize = defaults(p.normalize, false)\n\n this.volume = volume\n }\n\n getPositionFromCoordinate (coord: number) {\n const dim = this.dimension\n const v = this.volume\n const m = v.matrix\n\n const mp = new Vector3().setFromMatrixPosition(m)[ dim ]\n const ms = new Vector3().setFromMatrixScale(m)[ dim ]\n\n let vn\n if (dim === 'x') {\n vn = v.nx\n } else if (dim === 'y') {\n vn = v.ny\n } else {\n vn = v.nz\n }\n\n return Math.round((((coord - mp) / (vn / 100)) + 1) / ms)\n }\n\n getData (params: any) {\n params = params || {}\n\n const v = this.volume\n const d = v.data\n const m = v.matrix\n\n let p: number\n if (this.positionType === 'coordinate') {\n p = this.getPositionFromCoordinate(this.position)\n } else {\n p = this.position\n }\n\n function pos (dimLen: number) {\n return Math.round((dimLen / 100) * (p - 1))\n }\n\n function index (x: number, y: number, z: number, i: number) {\n return (z * v.ny * v.nx + y * v.nx + x) * 3 + i\n }\n\n const position = new Float32Array(4 * 3)\n const vec = new Vector3()\n\n let width, height\n let x\n let y\n let z\n let x0 = 0\n let y0 = 0\n let z0 = 0\n let nx = v.nx\n let ny = v.ny\n let nz = v.nz\n\n function setVec (x: number, y: number, z: number, offset: number) {\n vec.set(x, y, z).applyMatrix4(m).toArray(position as any, offset)\n }\n\n if (this.dimension === 'x') {\n x = pos(v.nx)\n y = v.ny - 1\n z = v.nz - 1\n\n width = v.nz\n height = v.ny\n\n x0 = x\n nx = x0 + 1\n\n setVec(x, 0, 0, 0)\n setVec(x, y, 0, 3)\n setVec(x, 0, z, 6)\n setVec(x, y, z, 9)\n } else if (this.dimension === 'y') {\n x = v.nx - 1\n y = pos(v.ny)\n z = v.nz - 1\n\n width = v.nz\n height = v.nx\n\n y0 = y\n ny = y0 + 1\n\n setVec(0, y, 0, 0)\n setVec(x, y, 0, 3)\n setVec(0, y, z, 6)\n setVec(x, y, z, 9)\n } else if (this.dimension === 'z') {\n x = v.nx - 1\n y = v.ny - 1\n z = pos(v.nz)\n\n width = v.nx\n height = v.ny\n\n z0 = z\n nz = z0 + 1\n\n setVec(0, 0, z, 0)\n setVec(0, y, z, 3)\n setVec(x, 0, z, 6)\n setVec(x, y, z, 9)\n }\n\n let i = 0\n let j = 0\n const imageData = new Uint8Array(width * height * 4)\n const pickingArray = new Float32Array(width * height)\n\n let tMin, tMax\n if (this.thresholdType === 'sigma') {\n tMin = v.getValueForSigma(this.thresholdMin)\n tMax = v.getValueForSigma(this.thresholdMax)\n } else {\n tMin = this.thresholdMin\n tMax = this.thresholdMax\n }\n\n const cp = Object.assign({}, params.colorParams, { volume: v })\n if (this.normalize) {\n cp.domain = [ 0, 1 ]\n }\n const colormaker = ColormakerRegistry.getScheme(cp)\n const tmp = new Float32Array(3)\n const scale = colormaker.getScale()\n\n let min = 0, max, diff = 0\n if (this.normalize) {\n min = +Infinity\n max = -Infinity\n for (let iy = y0; iy < ny; ++iy) {\n for (let ix = x0; ix < nx; ++ix) {\n for (let iz = z0; iz < nz; ++iz) {\n const idx = index(ix, iy, iz, 0) / 3\n const val = d[ idx ]\n if (val < min) min = val\n if (val > max) max = val\n }\n }\n }\n diff = max - min\n }\n\n for (let iy = y0; iy < ny; ++iy) {\n for (let ix = x0; ix < nx; ++ix) {\n for (let iz = z0; iz < nz; ++iz) {\n const idx = index(ix, iy, iz, 0) / 3\n let val = d[ idx ]\n if (this.normalize) {\n val = (val - min) / diff\n }\n\n colormaker.colorToArray(scale(val), tmp)\n imageData[ i ] = Math.round(tmp[ 0 ] * 255)\n imageData[ i + 1 ] = Math.round(tmp[ 1 ] * 255)\n imageData[ i + 2 ] = Math.round(tmp[ 2 ] * 255)\n imageData[ i + 3 ] = (val > tMin && val < tMax) ? 255 : 0\n\n pickingArray[ j ] = idx\n\n ++j\n i += 4\n }\n }\n }\n\n const picking = new SlicePicker(pickingArray, v)\n\n return { position, imageData, width, height, picking }\n }\n}\n\nexport default VolumeSlice\n","/**\n * @file Slice Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport Representation, { RepresentationParameters } from './representation'\nimport ImageBuffer, { ImageBufferParameters, ImageBufferData } from '../buffer/image-buffer'\nimport VolumeSlice from '../surface/volume-slice'\nimport Viewer from '../viewer/viewer';\nimport { Volume } from '../ngl';\n\n/**\n * Slice representation parameter object. Extends {@link RepresentationParameters}\n *\n * @typedef {Object} SliceRepresentationParameters - slice representation parameters\n *\n * @property {String} filter - filter applied to map the volume data on the slice, one of \"nearest\", \"linear\", \"cubic-bspline\", \"cubic-catmulrom\", \"cubic-mitchell\".\n * @property {String} positionType - Meaning of the position value. Either \"percent\" od \"coordinate\".\n * @property {Number} position - position of the slice.\n * @property {String} dimension - one of \"x\", \"y\" or \"z\"\n * @property {String} thresholdType - Meaning of the threshold values. Either *value* for the literal value or *sigma* as a factor of the sigma of the data. For volume data only.\n * @property {Number} thresholdMin - Minimum value to be displayed. For volume data only.\n * @property {Number} thresholdMax - Maximum value to be displayed. For volume data only.\n * @property {Boolean} normalize - Flag indicating wheather to normalize the data in a slice when coloring.\n */\nexport interface SliceRepresentationParameters extends RepresentationParameters {\n filter: 'nearest'|'linear'|'cubic-bspline'|'cubic-catmulrom'|'cubic-mitchell'\n positionType: 'percent'|'coordinate'\n position: number\n dimension: 'x'|'y'|'z'\n thresholdType: 'value'|'sigma'\n thresholdMin: number\n thresholdMax: number\n normalize: boolean\n}\n/**\n * Slice representation\n */\nclass SliceRepresentation extends Representation {\n protected filter: 'nearest'|'linear'|'cubic-bspline'|'cubic-catmulrom'|'cubic-mitchell'\n protected positionType: 'percent'|'coordinate'\n protected position: number\n protected dimension: 'x'|'y'|'z'\n protected thresholdType: 'value'|'sigma'\n protected thresholdMin: number\n protected thresholdMax: number\n protected normalize: boolean\n protected volume: Volume\n /**\n * Create Slice representation object\n * @param {Volume} surface - the volume to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {SliceRepresentationParameters} params - slice representation parameters\n */\n constructor (volume: Volume, viewer: Viewer, params: Partial) {\n super(volume, viewer, params)\n\n this.type = 'slice'\n\n this.parameters = Object.assign({\n\n filter: {\n type: 'select',\n buffer: true,\n options: {\n 'nearest': 'nearest',\n 'linear': 'linear',\n 'cubic-bspline': 'cubic-bspline',\n 'cubic-catmulrom': 'cubic-catmulrom',\n 'cubic-mitchell': 'cubic-mitchell'\n }\n },\n positionType: {\n type: 'select',\n rebuild: true,\n options: {\n 'percent': 'percent', 'coordinate': 'coordinate'\n }\n },\n position: {\n type: 'range',\n step: 0.1,\n max: 100,\n min: 1,\n rebuild: true\n },\n dimension: {\n type: 'select',\n rebuild: true,\n options: {\n 'x': 'x', 'y': 'y', 'z': 'z'\n }\n },\n thresholdType: {\n type: 'select',\n rebuild: true,\n options: {\n 'value': 'value', 'sigma': 'sigma'\n }\n },\n thresholdMin: {\n type: 'number', precision: 3, max: Infinity, min: -Infinity, rebuild: true\n },\n thresholdMax: {\n type: 'number', precision: 3, max: Infinity, min: -Infinity, rebuild: true\n },\n normalize: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n\n flatShaded: null,\n side: null,\n wireframe: null,\n linewidth: null,\n colorScheme: null,\n\n roughness: null,\n metalness: null,\n diffuse: null\n\n })\n\n this.volume = volume\n\n this.init(params)\n }\n\n init (params: Partial) {\n const v = this.volume\n const p = params || {}\n p.colorDomain = defaults(p.colorDomain, [ v.min, v.max ])\n p.colorScheme = defaults(p.colorScheme, 'value')\n p.colorScale = defaults(p.colorScale, 'Spectral')\n\n this.colorScheme = 'value'\n this.dimension = defaults(p.dimension, 'x')\n this.filter = defaults(p.filter, 'cubic-bspline')\n this.positionType = defaults(p.positionType, 'percent')\n this.position = defaults(p.position, 30)\n this.thresholdType = defaults(p.thresholdType, 'sigma')\n this.thresholdMin = defaults(p.thresholdMin, -Infinity)\n this.thresholdMax = defaults(p.thresholdMax, Infinity)\n this.normalize = defaults(p.normalize, false)\n\n super.init(p)\n\n this.build()\n }\n\n attach (callback: () => void) {\n this.bufferList.forEach(buffer => {\n this.viewer.add(buffer)\n })\n this.setVisibility(this.visible)\n\n callback()\n }\n\n create () {\n const volumeSlice = new VolumeSlice(this.volume, {\n positionType: this.positionType,\n position: this.position,\n dimension: this.dimension,\n thresholdType: this.thresholdType,\n thresholdMin: this.thresholdMin,\n thresholdMax: this.thresholdMax,\n normalize: this.normalize\n })\n\n const sliceBuffer = new ImageBuffer(\n volumeSlice.getData({ colorParams: this.getColorParams() }) as ImageBufferData,\n this.getBufferParams({\n filter: this.filter\n }) as ImageBufferParameters\n )\n\n this.bufferList.push(sliceBuffer)\n }\n}\n\nexport default SliceRepresentation\n","/**\n * @file Representation Utils\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, RepresentationRegistry } from '../globals'\n\nimport Viewer from '../viewer/viewer'\nimport Structure from '../structure/structure'\nimport Surface from '../surface/surface'\nimport Volume from '../surface/volume'\nimport Shape from '../geometry/shape'\n\nimport BufferRepresentation from './buffer-representation'\nimport SurfaceRepresentation from './surface-representation'\nimport DotRepresentation from './dot-representation'\nimport SliceRepresentation from './slice-representation'\n\nfunction logReprUnknown (type: string) {\n Log.error(`makeRepresentation: representation type ${type} unknown`)\n}\n\nexport function makeRepresentation (type: string, object: any, viewer: Viewer, params: any) { // TODO\n if (Debug) Log.time('makeRepresentation ' + type)\n\n var ReprClass\n\n if (object instanceof Structure) {\n ReprClass = RepresentationRegistry.get(type)\n\n if (!ReprClass) {\n logReprUnknown(type)\n return\n }\n } else if (object instanceof Surface) {\n if (type === 'surface') {\n ReprClass = SurfaceRepresentation\n } else if (type === 'dot') {\n ReprClass = DotRepresentation\n } else {\n logReprUnknown(type)\n return\n }\n } else if (object instanceof Volume) {\n if (type === 'surface') {\n ReprClass = SurfaceRepresentation\n } else if (type === 'dot') {\n ReprClass = DotRepresentation\n } else if (type === 'slice') {\n ReprClass = SliceRepresentation\n } else {\n logReprUnknown(type)\n return\n }\n } else if (object instanceof Shape) {\n ReprClass = BufferRepresentation\n object = object.getBufferList()\n } else if (type === 'buffer') {\n ReprClass = BufferRepresentation\n } else {\n Log.error('makeRepresentation: object ' + object + ' unknown')\n return\n }\n\n const repr = new ReprClass(object, viewer, params)\n\n if (Debug) Log.timeEnd('makeRepresentation ' + type)\n\n return repr\n}\n","/**\n * @file Element\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { createParams } from '../utils'\nimport { generateUUID } from '../math/math-utils'\nimport Stage from '../stage/stage'\n\nexport const ElementDefaultParameters = {\n name: 'some element',\n status: ''\n}\nexport type ElementParameters = typeof ElementDefaultParameters\n\nexport interface ElementSignals {\n statusChanged: Signal // on status change\n nameChanged: Signal // on name change\n disposed: Signal // on dispose\n}\n\n/**\n * Element base class\n */\nabstract class Element {\n /**\n * Events emitted by the element\n */\n signals: ElementSignals = {\n statusChanged: new Signal(),\n nameChanged: new Signal(),\n disposed: new Signal()\n }\n readonly parameters: ElementParameters\n readonly uuid: string\n\n get defaultParameters() { return ElementDefaultParameters }\n\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {ElementParameters} params - component parameters\n */\n constructor (readonly stage: Stage, params: Partial = {}) {\n this.parameters = createParams(params, this.defaultParameters)\n this.uuid = generateUUID()\n }\n\n abstract get type (): string\n\n get name () { return this.parameters.name }\n\n setStatus (value: string) {\n this.parameters.status = value\n this.signals.statusChanged.dispatch(value)\n\n return this\n }\n\n setName (value: string) {\n this.parameters.name = value\n this.signals.nameChanged.dispatch(value)\n\n return this\n }\n\n dispose () {\n this.signals.disposed.dispatch()\n }\n}\n\nexport default Element\n","/**\n * @file Representation Element\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\nimport { Color } from 'three'\n\nimport Stage from '../stage/stage'\nimport Representation, { RepresentationParameters } from '../representation/representation'\nimport Component from './component'\nimport Element, { ElementDefaultParameters, ElementSignals } from './element'\n\nexport const RepresentationElementDefaultParameters = Object.assign({\n visible: true\n}, ElementDefaultParameters)\nexport type RepresentationElementParameters = typeof RepresentationElementDefaultParameters\n\nexport interface RepresentationElementSignals extends ElementSignals {\n visibilityChanged: Signal // on visibility change\n parametersChanged: Signal // on parameters change\n}\n\n/**\n * Element wrapping a {@link Representation} object\n */\nclass RepresentationElement extends Element {\n signals: RepresentationElementSignals\n parameters: RepresentationElementParameters\n get defaultParameters() { return RepresentationElementDefaultParameters }\n\n repr: Representation\n\n /**\n * Create representation component\n * @param {Stage} stage - stage object the component belongs to\n * @param {Representation} repr - representation object to wrap\n * @param {RepresentationParameters} [params] - component parameters\n * @param {Component} [parent] - parent component\n */\n constructor (stage: Stage, repr: Representation, params: Partial = {}, readonly parent: Component) {\n super(stage, Object.assign({ name: repr.type }, params))\n\n this.signals = Object.assign({\n visibilityChanged: new Signal(),\n parametersChanged: new Signal()\n }, this.signals)\n\n this.setRepresentation(repr)\n }\n\n get visible () { return this.parameters.visible }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'representation' }\n\n getType () {\n return this.repr.type\n }\n\n setRepresentation (repr: Representation) {\n this._disposeRepresentation()\n this.repr = repr\n // this.name = repr.type;\n this.stage.tasks.listen(this.repr.tasks)\n this.updateVisibility()\n }\n\n _disposeRepresentation () {\n if (this.repr) {\n this.stage.tasks.unlisten(this.repr.tasks)\n this.repr.dispose()\n }\n }\n\n dispose () {\n if (this.parent && this.parent.hasRepresentation(this)) {\n this.parent.removeRepresentation(this)\n } else {\n this._disposeRepresentation()\n this.signals.disposed.dispatch()\n }\n }\n\n /**\n * Set the visibility of the component, takes parent visibility into account\n * @param {Boolean} value - visibility flag\n * @return {RepresentationElement} this object\n */\n setVisibility (value: boolean) {\n this.parameters.visible = value\n this.updateVisibility()\n this.signals.visibilityChanged.dispatch(this.parameters.visible)\n\n return this\n }\n\n getVisibility () {\n if (this.parent) {\n return this.parent.parameters.visible && this.parameters.visible\n } else {\n return this.parameters.visible\n }\n }\n\n /**\n * Toggle visibility of the component, takes parent visibility into account\n * @return {RepresentationElement} this object\n */\n toggleVisibility () {\n return this.setVisibility(!this.parameters.visible)\n }\n\n updateVisibility () {\n this.repr.setVisibility(this.getVisibility())\n }\n\n /**\n * Set selection\n * @param {Object} what - flags indicating what attributes to update\n * @param {Boolean} what.position - update position attribute\n * @param {Boolean} what.color - update color attribute\n * @param {Boolean} what.radius - update radius attribute\n * @return {RepresentationElement} this object\n */\n update (what: any) { // TODO\n (this.repr as any).update(what) // TODO\n\n return this\n }\n\n build (params?: any) { // TODO\n this.repr.build(params)\n\n return this\n }\n\n /**\n * Set selection\n * @param {String} string - selection string\n * @return {RepresentationElement} this object\n */\n setSelection (string: string) {\n const repr: any = this.repr // TODO\n\n if (repr.setSelection) {\n repr.setSelection(string)\n }\n\n return this\n }\n\n /**\n * Set representation parameters\n * @param {RepresentationParameters} params - parameter object\n * @return {RepresentationElement} this object\n */\n setParameters (params: any) { // TODO\n this.repr.setParameters(params)\n this.signals.parametersChanged.dispatch(\n this.repr.getParameters()\n )\n\n return this\n }\n\n /**\n * Get representation parameters\n * @return {RepresentationParameters} parameter object\n */\n getParameters (): Partial {\n return this.repr.getParameters()\n }\n\n /**\n * Set color\n * @param {String|Color|Hex} value - color value\n * @return {RepresentationElement} this object\n */\n setColor (value: string|number|Color) {\n this.repr.setColor(value)\n\n return this\n }\n}\n\nexport default RepresentationElement\n","\n/**\n * @file Component\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Quaternion, Matrix4, Euler, Box3 } from 'three'\nimport { Signal } from 'signals'\n\nimport { defaults, createParams } from '../utils'\nimport { generateUUID } from '../math/math-utils'\nimport Annotation, { AnnotationParams } from '../component/annotation'\nimport ComponentControls from '../controls/component-controls'\nimport { makeRepresentation } from '../representation/representation-utils'\nimport RepresentationElement from './representation-element'\nimport Stage from '../stage/stage'\nimport Viewer from '../viewer/viewer'\n\nconst _m = new Matrix4()\nconst _v = new Vector3()\n\nexport const ComponentDefaultParameters = {\n name: '',\n status: '',\n visible: true\n}\nexport type ComponentParameters = typeof ComponentDefaultParameters\n\n\nexport interface ComponentSignals {\n representationAdded: Signal // when a representation is added\n representationRemoved: Signal // when a representation is removed\n visibilityChanged: Signal // on visibility change\n matrixChanged: Signal // on matrix change\n statusChanged: Signal // on status change\n nameChanged: Signal // on name change\n disposed: Signal // on dispose\n}\n\n/**\n * Base class for components\n */\nabstract class Component {\n /**\n * Events emitted by the component\n */\n readonly signals: ComponentSignals = {\n representationAdded: new Signal(),\n representationRemoved: new Signal(),\n visibilityChanged: new Signal(),\n matrixChanged: new Signal(),\n statusChanged: new Signal(),\n nameChanged: new Signal(),\n disposed: new Signal()\n }\n\n readonly parameters: ComponentParameters\n get defaultParameters () { return ComponentDefaultParameters }\n\n readonly uuid: string\n readonly viewer: Viewer\n\n reprList: RepresentationElement[] = []\n annotationList: Annotation[] = []\n\n matrix = new Matrix4()\n position = new Vector3()\n quaternion = new Quaternion()\n scale = new Vector3(1, 1, 1)\n transform = new Matrix4()\n\n controls: ComponentControls\n\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {ComponentParameters} params - parameter object\n */\n constructor (readonly stage: Stage, readonly object: any, params: Partial = {}) {\n this.parameters = createParams(params, this.defaultParameters)\n this.uuid = generateUUID()\n this.viewer = stage.viewer\n\n this.controls = new ComponentControls(this)\n }\n\n abstract get type (): string\n\n get name () { return this.parameters.name }\n get status () { return this.parameters.status }\n get visible () { return this.parameters.visible }\n\n /**\n * Set position transform\n *\n * @example\n * // translate by 25 angstrom along x axis\n * component.setPosition([ 25, 0, 0 ]);\n *\n * @param {Vector3|Array} p - the coordinates\n * @return {Component} this object\n */\n setPosition (p: [number, number, number]|Vector3) {\n if (Array.isArray(p)) {\n this.position.fromArray(p)\n } else {\n this.position.copy(p)\n }\n this.updateMatrix()\n\n return this\n }\n\n /**\n * Set local rotation transform\n * (for global rotation use setTransform)\n *\n * @example\n * // rotate by 2 degree radians on x axis\n * component.setRotation( [ 2, 0, 0 ] );\n *\n * @param {Quaternion|Euler|Array} r - the rotation\n * @return {Component} this object\n */\n setRotation (r: [number, number, number]|Euler|Quaternion) {\n if (Array.isArray(r)) {\n if (r.length === 3) {\n const e = new Euler().fromArray(r)\n this.quaternion.setFromEuler(e)\n } else {\n this.quaternion.fromArray(r)\n }\n } else if (r instanceof Euler) {\n this.quaternion.setFromEuler(r)\n } else {\n this.quaternion.copy(r)\n }\n this.updateMatrix()\n\n return this\n }\n\n /**\n * Set scale transform\n *\n * @example\n * // scale by factor of two\n * component.setScale( 2 );\n *\n * @param {Number} s - the scale\n * @return {Component} this object\n */\n setScale (s: number) {\n this.scale.set(s, s, s)\n this.updateMatrix()\n\n return this\n }\n\n /**\n * Set general transform. Is applied before and in addition\n * to the position, rotation and scale transformations\n *\n * @example\n * component.setTransform( matrix );\n *\n * @param {Matrix4} m - the matrix\n * @return {Component} this object\n */\n setTransform (m: Matrix4) {\n this.transform.copy(m)\n this.updateMatrix()\n\n return this\n }\n\n updateMatrix () {\n const c = this.getCenterUntransformed(_v)\n this.matrix.makeTranslation(-c.x, -c.y, -c.z)\n\n _m.makeRotationFromQuaternion(this.quaternion)\n this.matrix.premultiply(_m)\n\n _m.makeScale(this.scale.x, this.scale.y, this.scale.z)\n this.matrix.premultiply(_m)\n\n const p = this.position\n _m.makeTranslation(p.x + c.x, p.y + c.y, p.z + c.z)\n this.matrix.premultiply(_m)\n\n this.matrix.premultiply(this.transform)\n\n this.updateRepresentationMatrices()\n\n this.stage.viewer.updateBoundingBox()\n\n this.signals.matrixChanged.dispatch(this.matrix)\n }\n\n /**\n * Propogates our matrix to each representation\n */\n updateRepresentationMatrices () {\n this.reprList.forEach(repr => {\n repr.setParameters({ matrix: this.matrix })\n })\n }\n\n /**\n * Add an anotation object\n * @param {Vector3} position - the 3d position\n * @param {String|Element} content - the HTML content\n * @param {Object} [params] - parameters\n * @param {Integer} params.offsetX - 2d offset in x direction\n * @param {Integer} params.offsetY - 2d offset in y direction\n * @return {Annotation} the added annotation object\n */\n addAnnotation (position: Vector3, content: string|HTMLElement, params: AnnotationParams) {\n const annotation = new Annotation(this, position, content, params)\n this.annotationList.push(annotation)\n\n return annotation\n }\n\n /**\n * Iterator over each annotation and executing the callback\n * @param {Function} callback - function to execute\n * @return {undefined}\n */\n eachAnnotation (callback: (a: Annotation) => void) {\n this.annotationList.slice().forEach(callback)\n }\n\n /**\n * Remove the give annotation from the component\n * @param {Annotation} annotation - the annotation to remove\n * @return {undefined}\n */\n removeAnnotation (annotation: Annotation) {\n const idx = this.annotationList.indexOf(annotation)\n if (idx !== -1) {\n this.annotationList.splice(idx, 1)\n annotation.dispose()\n }\n }\n\n /**\n * Remove all annotations from the component\n * @return {undefined}\n */\n removeAllAnnotations () {\n this.eachAnnotation(annotation => annotation.dispose())\n this.annotationList.length = 0\n }\n\n /**\n * Add a new representation to the component\n * @param {String} type - the name of the representation\n * @param {Object} object - the object on which the representation should be based\n * @param {RepresentationParameters} [params] - representation parameters\n * @return {RepresentationElement} the created representation wrapped into\n * a representation element object\n */\n protected _addRepresentation (type: string, object: any, params: any, hidden = false) { // TODO\n const p = params || {}\n const sp = this.stage.getParameters() as any // TODO\n p.matrix = this.matrix.clone()\n p.quality = p.quality || sp.quality\n p.disableImpostor = defaults(p.disableImpostor, !sp.impostor)\n p.useWorker = defaults(p.useWorker, sp.workerDefault)\n p.visible = defaults(p.visible, true)\n\n const p2 = Object.assign({}, p, { visible: this.parameters.visible && p.visible })\n const repr = makeRepresentation(type, object, this.viewer, p2)\n const reprElem = new RepresentationElement(this.stage, repr, p, this)\n\n if (!hidden) {\n this.reprList.push(reprElem)\n this.signals.representationAdded.dispatch(reprElem)\n }\n return reprElem\n }\n\n abstract addRepresentation (type: any, params: any): any\n\n addBufferRepresentation (buffer: any, params: any) { // TODO\n return this._addRepresentation.call(this, 'buffer', buffer, params)\n }\n\n hasRepresentation (repr: RepresentationElement) {\n return this.reprList.indexOf(repr) !== -1\n }\n\n /**\n * Iterator over each representation and executing the callback\n * @param {Function} callback - function to execute\n * @return {undefined}\n */\n eachRepresentation (callback: (repr: RepresentationElement) => void) {\n this.reprList.slice().forEach(callback)\n }\n\n /**\n * Removes a representation component\n * @param {RepresentationElement} repr - the representation element\n * @return {undefined}\n */\n removeRepresentation (repr: RepresentationElement) {\n const idx = this.reprList.indexOf(repr)\n if (idx !== -1) {\n this.reprList.splice(idx, 1)\n repr.dispose()\n this.signals.representationRemoved.dispatch(repr)\n }\n }\n\n updateRepresentations (what: any) { // TODO\n this.reprList.forEach(repr => repr.update(what))\n this.stage.viewer.requestRender()\n }\n\n /**\n * Removes all representation components\n * @return {undefined}\n */\n removeAllRepresentations () {\n this.eachRepresentation(repr => repr.dispose())\n }\n\n dispose () {\n this.removeAllAnnotations()\n this.removeAllRepresentations()\n\n this.reprList.length = 0\n\n this.signals.disposed.dispatch()\n }\n\n /**\n * Set the visibility of the component, including added representations\n * @param {Boolean} value - visibility flag\n * @return {Component} this object\n */\n setVisibility (value: boolean) {\n this.parameters.visible = value\n\n this.eachRepresentation((repr: RepresentationElement) => repr.updateVisibility())\n this.eachAnnotation((annotation: Annotation) => annotation.updateVisibility())\n\n this.signals.visibilityChanged.dispatch(value)\n\n return this\n }\n\n setStatus (value: string) {\n this.parameters.status = value\n this.signals.statusChanged.dispatch(value)\n\n return this\n }\n\n setName (value: string) {\n this.parameters.name = value\n this.signals.nameChanged.dispatch(value)\n\n return this\n }\n\n /**\n * @return {Box3} the component's bounding box\n */\n getBox (...args: any[]) {\n return this.getBoxUntransformed(...args)\n .clone().applyMatrix4(this.matrix)\n }\n\n /**\n * @return {Vector3} the component's center position\n */\n getCenter (...args: any[]) {\n return this.getCenterUntransformed(...args)\n .clone().applyMatrix4(this.matrix)\n }\n\n getZoom (...args: any[]) {\n return this.stage.getZoomForBox(this.getBox(...args))\n }\n\n /**\n * @abstract\n * @return {Box3} the untransformed component's bounding box\n */\n getBoxUntransformed (...args: any[]): Box3 {\n return new Box3()\n }\n\n getCenterUntransformed (...args: any[]) {\n return this.getBoxUntransformed().getCenter(new Vector3())\n }\n\n /**\n * Automatically center and zoom the component\n * @param {Integer} [duration] - duration of the animation, defaults to 0\n * @return {undefined}\n */\n autoView (duration?: number) {\n this.stage.animationControls.zoomMove(\n this.getCenter(),\n this.getZoom(),\n defaults(duration, 0)\n )\n }\n}\n\nexport default Component\n","/**\n * @file Collection\n * @author Alexander Rose \n * @private\n */\n\nimport Component from './component'\nimport Element from './element'\n\nclass Collection {\n constructor (readonly list: T[] = []) {\n // remove elements from list when they get disposed\n const n = list.length\n\n for (let i = 0; i < n; ++i) {\n const elm = list[ i ]\n elm.signals.disposed.add(this._remove, this)\n }\n }\n\n _remove (elm: T) {\n const idx = this.list.indexOf(elm)\n\n if (idx !== -1) {\n this.list.splice(idx, 1)\n }\n }\n\n get first () {\n return this.list.length > 0 ? this.list[0] : undefined\n }\n\n forEach (fn: (x: T) => any) {\n this.list.forEach(fn)\n\n return this\n }\n\n dispose () {\n return this.forEach((elm) => elm.dispose())\n }\n}\n\nexport default Collection\n","/**\n * @file Component Collection\n * @author Alexander Rose \n * @private\n */\n\nimport RepresentationElement from './representation-element'\nimport Collection from './collection'\nimport { GenericColor } from '../types'\n\nclass RepresentationCollection extends Collection {\n setParameters (params: any) {\n return this.forEach((repr) => repr.setParameters(params))\n }\n\n setVisibility (value: boolean) {\n return this.forEach((repr) => repr.setVisibility(value))\n }\n\n setSelection (string: string) {\n return this.forEach((repr) => repr.setSelection(string))\n }\n\n setColor (color: GenericColor) {\n return this.forEach((repr) => repr.setColor(color))\n }\n\n update (what: any) {\n return this.forEach((repr) => repr.update(what))\n }\n\n build (params?: any) {\n return this.forEach((repr) => repr.build(params))\n }\n\n dispose (params?: any) {\n return this.forEach((repr) => repr.dispose())\n }\n}\n\nexport default RepresentationCollection\n","/**\n * @file Trajectory Component\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport Element, { ElementSignals, ElementDefaultParameters } from './element'\nimport Stage from '../stage/stage'\nimport Trajectory, { TrajectoryParameters } from '../trajectory/trajectory'\nimport TrajectoryPlayer, {\n TrajectoryPlayerDirection, TrajectoryPlayerMode, TrajectoryPlayerInterpolateType\n} from '../trajectory/trajectory-player'\n\n/**\n * Trajectory component parameter object.\n * @typedef {Object} TrajectoryComponentParameters - component parameters\n *\n * @property {String} name - component name\n * @property {Integer} initialFrame - initial frame the trajectory is set to\n * @property {Integer} defaultStep - default step size to be used by trajectory players\n * @property {Integer} defaultTimeout - default timeout to be used by trajectory players\n * @property {String} defaultInterpolateType - one of \"\" (empty string), \"linear\" or \"spline\"\n * @property {Integer} defaultInterpolateStep - window size used for interpolation\n * @property {String} defaultMode - either \"loop\" or \"once\"\n * @property {String} defaultDirection - either \"forward\" or \"backward\"\n */\n\nexport const TrajectoryElementDefaultParameters = Object.assign({\n defaultStep: 1,\n defaultTimeout: 50,\n defaultInterpolateType: '' as TrajectoryPlayerInterpolateType,\n defaultInterpolateStep: 5,\n defaultMode: 'loop' as TrajectoryPlayerMode,\n defaultDirection: 'forward' as TrajectoryPlayerDirection,\n initialFrame: 0\n}, ElementDefaultParameters)\nexport type TrajectoryElementParameters = typeof TrajectoryElementDefaultParameters\n\nexport interface TrajectoryElementSignals extends ElementSignals {\n frameChanged: Signal // on frame change\n playerChanged: Signal // on player change\n countChanged: Signal // when frame count is available\n parametersChanged: Signal // on parameters change\n}\n\n/**\n * Component wrapping a {@link Trajectory} object\n */\nclass TrajectoryElement extends Element {\n signals: TrajectoryElementSignals\n parameters: TrajectoryElementParameters\n get defaultParameters () { return TrajectoryElementDefaultParameters }\n\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {Trajectory} trajectory - the trajectory object\n * @param {TrajectoryComponentParameters} params - component parameters\n * @param {StructureComponent} parent - the parent structure\n */\n constructor (stage: Stage, readonly trajectory: Trajectory, params: Partial = {}) {\n super(stage, Object.assign({ name: trajectory.name }, params))\n\n this.signals = Object.assign(this.signals, {\n frameChanged: new Signal(),\n playerChanged: new Signal(),\n countChanged: new Signal(),\n parametersChanged: new Signal()\n })\n\n // signals\n\n trajectory.signals.frameChanged.add((i: number) => {\n this.signals.frameChanged.dispatch(i)\n })\n\n trajectory.signals.playerChanged.add((player: TrajectoryPlayer) => {\n this.signals.playerChanged.dispatch(player)\n })\n\n trajectory.signals.countChanged.add((n: number) => {\n this.signals.countChanged.dispatch(n)\n })\n\n //\n\n if (params.initialFrame !== undefined) {\n this.setFrame(params.initialFrame)\n }\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'trajectory' }\n\n /**\n * Set the frame of the trajectory\n * @param {Integer} i - frame number\n * @return {undefined}\n */\n setFrame (i: number) {\n this.trajectory.setFrame(i)\n }\n\n /**\n * Set trajectory parameters\n * @param {TrajectoryParameters} params - trajectory parameters\n * @return {undefined}\n */\n setParameters (params: Partial = {}) {\n this.trajectory.setParameters(params)\n this.signals.parametersChanged.dispatch(params)\n }\n\n dispose () {\n this.trajectory.dispose()\n super.dispose()\n }\n}\n\nexport default TrajectoryElement\n","/**\n * @file Frames\n * @author Alexander Rose \n * @private\n */\n\nexport default class Frames {\n coordinates = []\n boxes = []\n times = []\n\n timeOffset = 0\n deltaTime = 1\n\n constructor (readonly name: string, readonly path: string) {}\n\n get type () { return 'Frames' }\n}\n","/**\n * @file Superposition\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\nimport { Debug, Log } from '../globals'\nimport {\n Matrix, svd, meanRows, subRows, transpose,\n multiplyABt, invert3x3, multiply3x3, mat3x3determinant, multiply\n} from '../math/matrix-utils'\nimport Structure from '../structure/structure'\n\nclass Superposition {\n coords1t: Matrix\n coords2t: Matrix\n\n transformationMatrix: Matrix4\n\n mean1: number[]\n mean2: number[]\n\n A = new Matrix(3, 3)\n W = new Matrix(1, 3)\n U = new Matrix(3, 3)\n V = new Matrix(3, 3)\n VH = new Matrix(3, 3)\n R = new Matrix(3, 3)\n\n private tmp = new Matrix(3, 3)\n private c = new Matrix(3, 3)\n\n constructor (atoms1: Structure|Float32Array, atoms2: Structure|Float32Array) {\n // allocate & init data structures\n\n let n1\n if (atoms1 instanceof Structure) {\n n1 = atoms1.atomCount\n } else if (atoms1 instanceof Float32Array) {\n n1 = atoms1.length / 3\n } else {\n return\n }\n\n let n2\n if (atoms2 instanceof Structure) {\n n2 = atoms2.atomCount\n } else if (atoms2 instanceof Float32Array) {\n n2 = atoms2.length / 3\n } else {\n return\n }\n\n const n = Math.min(n1, n2)\n\n const coords1 = new Matrix(3, n)\n const coords2 = new Matrix(3, n)\n\n this.coords1t = new Matrix(n, 3)\n this.coords2t = new Matrix(n, 3)\n\n this.transformationMatrix = new Matrix4()\n\n this.c.data.set([ 1, 0, 0, 0, 1, 0, 0, 0, -1 ])\n\n // prep coords\n\n this.prepCoords(atoms1, coords1, n, false)\n this.prepCoords(atoms2, coords2, n, false)\n\n // superpose\n\n this._superpose(coords1, coords2)\n }\n\n _superpose (coords1: Matrix, coords2: Matrix) {\n this.mean1 = meanRows(coords1)\n this.mean2 = meanRows(coords2)\n\n subRows(coords1, this.mean1)\n subRows(coords2, this.mean2)\n\n transpose(this.coords1t, coords1)\n transpose(this.coords2t, coords2)\n\n multiplyABt(this.A, this.coords2t, this.coords1t)\n\n svd(this.A, this.W, this.U, this.V)\n\n invert3x3(this.V, this.VH)\n multiply3x3(this.R, this.U, this.VH)\n\n if (mat3x3determinant(this.R) < 0.0) {\n if (Debug) Log.log('R not a right handed system')\n\n multiply3x3(this.tmp, this.c, this.VH)\n multiply3x3(this.R, this.U, this.tmp)\n }\n\n //get the transformation matrix\n\n const transformMat_ = new Matrix(4,4)\n const tmp_1 = new Matrix(4,4)\n const tmp_2 = new Matrix(4,4)\n\n const sub = new Matrix(4,4)\n const mult = new Matrix(4,4)\n const add = new Matrix(4,4)\n\n const R = this.R.data\n const M1 = this.mean1\n const M2 = this.mean2\n\n sub.data.set([ 1, 0, 0, -M1[0],\n 0, 1, 0, -M1[1],\n 0, 0, 1, -M1[2],\n 0, 0, 0, 1 ])\n\n mult.data.set([ R[0], R[1], R[2], 0,\n R[3], R[4], R[5], 0,\n R[6], R[7], R[8], 0,\n 0, 0, 0, 1 ])\n\n add.data.set([ 1, 0, 0, M2[0],\n 0, 1, 0, M2[1],\n 0, 0, 1, M2[2],\n 0, 0, 0, 1 ])\n\n transpose(tmp_1,sub)\n multiplyABt(transformMat_,mult,tmp_1)\n transpose(tmp_2,transformMat_)\n multiplyABt(tmp_1,add,tmp_2)\n\n transpose(transformMat_,tmp_1)\n this.transformationMatrix.elements = transformMat_.data as unknown as number[]\n\n }\n\n prepCoords (atoms: Structure|Float32Array, coords: Matrix, n: number, is4X4: boolean) {\n let i = 0\n const cd = coords.data\n\n let c = 3\n let d = n * 3\n\n if (is4X4) {\n d = n * 4\n c = 4\n }\n if (atoms instanceof Structure) {\n atoms.eachAtom(function (a) {\n if (i < d) {\n cd[ i + 0 ] = a.x\n cd[ i + 1 ] = a.y\n cd[ i + 2 ] = a.z\n if (is4X4) cd[ i + 3 ] = 1\n\n i += c\n }\n })\n } else if (atoms instanceof Float32Array) {\n for (; i < d; i += c){\n if (i < d) {\n cd[ i ] = atoms[ i ]\n cd[ i + 1 ] = atoms[ i + 1 ]\n cd[ i + 2 ] = atoms[ i + 2 ]\n if (is4X4) cd[ i + 3 ] = 1\n }\n }\n } else {\n Log.warn('prepCoords: input type unknown')\n }\n }\n\n transform (atoms: Structure|Float32Array) {\n // allocate data structures\n\n let n\n if (atoms instanceof Structure) {\n n = atoms.atomCount\n } else if (atoms instanceof Float32Array) {\n n = atoms.length / 3\n } else {\n return\n }\n\n const coords = new Matrix(4, n)\n const tCoords = new Matrix(n,4)\n\n // prep coords\n\n this.prepCoords(atoms, coords, n, true)\n\n // check for transformation matrix correctness\n\n const transform = this.transformationMatrix\n const det = transform.determinant()\n if (!det){\n return det\n }\n\n // do transform\n\n const mult = new Matrix(4,4)\n mult.data = transform.elements as unknown as Float32Array\n multiply(tCoords,coords,mult)\n\n let i = 0\n const cd = tCoords.data\n if (atoms instanceof Structure) {\n atoms.eachAtom(function (a) {\n a.x = cd[ i ]\n a.y = cd[ i + 1 ]\n a.z = cd[ i + 2 ]\n i += 4\n })\n\n //update transformation matrices for each assembly\n\n const invertTrasform = new Matrix4()\n invertTrasform.getInverse(transform)\n\n const biomolDict = atoms.biomolDict\n\n for (let key in biomolDict) {\n\n if (biomolDict.hasOwnProperty(key)) {\n let assembly = biomolDict[key]\n\n assembly.partList.forEach(function(part){\n\n part.matrixList.forEach(function(mat){\n\n mat.premultiply(transform)\n mat.multiply(invertTrasform)\n\n })\n })\n }\n }\n } else if (atoms instanceof Float32Array) {\n\n const n4 = n * 4\n for (; i < n4; i += 4){\n\n atoms[ i ] = cd[ i ]\n atoms[ i + 1 ] = cd[ i + 1 ]\n atoms[ i + 2 ] = cd[ i + 2 ]\n\n }\n } else {\n Log.warn('transform: input type unknown')\n }\n\n return this.transformationMatrix\n }\n}\nexport default Superposition\n","/**\n * @file Trajectory Player\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { defaults, createParams, updateParams } from '../utils'\nimport Trajectory from './trajectory'\n\nexport type TrajectoryPlayerInterpolateType = ''|'linear'|'spline'\nexport type TrajectoryPlayerMode = 'loop'|'once'\nexport type TrajectoryPlayerDirection = 'forward'|'backward'|'bounce'\n\nexport const TrajectoryPlayerDefaultParameters = {\n step: 1, // how many frames to advance when playing\n timeout: 50, // how many milliseconds to wait between playing frames\n start: 0, // first frame to play\n end: 0, // last frame to play\n interpolateType: '' as TrajectoryPlayerInterpolateType,\n interpolateStep: 5, // window size used for interpolation\n mode: 'loop' as TrajectoryPlayerMode,\n direction: 'forward' as TrajectoryPlayerDirection\n}\nexport type TrajectoryPlayerParameters = typeof TrajectoryPlayerDefaultParameters\n\nexport interface TrajectoryPlayerSignals {\n startedRunning: Signal\n haltedRunning: Signal\n}\n\n/**\n * Trajectory player for animating coordinate frames\n * @example\n * var player = new TrajectoryPlayer(trajectory, {step: 1, timeout: 50});\n * player.play();\n */\nclass TrajectoryPlayer {\n signals: TrajectoryPlayerSignals = {\n startedRunning: new Signal(),\n haltedRunning: new Signal()\n }\n\n parameters: TrajectoryPlayerParameters\n traj: Trajectory\n\n private _run = false\n private _previousTime = 0\n private _currentTime = 0\n private _currentStep = 1\n private _currentFrame: number|[number, number, number, number]\n private _direction: TrajectoryPlayerDirection\n\n /**\n * make trajectory player\n * @param {Trajectory} traj - the trajectory\n * @param {TrajectoryPlayerParameters} [params] - parameter object\n */\n constructor (traj: Trajectory, params: Partial = {}) {\n traj.signals.playerChanged.add((player: TrajectoryPlayer) => {\n if (player !== this) {\n this.pause()\n }\n }, this)\n\n const n = defaults(traj.frameCount, 1)\n\n this.traj = traj\n this.parameters = createParams(params, TrajectoryPlayerDefaultParameters)\n this.parameters.end = Math.min(defaults(params.end, n - 1), n - 1)\n this.parameters.step = defaults(params.step, Math.ceil((n + 1) / 100))\n\n this._currentFrame = this.parameters.start\n this._direction = this.parameters.direction === 'bounce' ? 'forward' : this.parameters.direction\n\n traj.signals.countChanged.add((n: number) => {\n this.parameters.end = Math.min(defaults(this.parameters.end, n - 1), n - 1)\n }, this)\n\n this._animate = this._animate.bind(this)\n }\n\n get isRunning () { return this._run }\n\n /**\n * set player parameters\n * @param {TrajectoryPlayerParameters} [params] - parameter object\n */\n setParameters (params: Partial = {}) {\n updateParams(this.parameters, params)\n\n if (params.direction !== undefined && this.parameters.direction !== 'bounce') {\n this._direction = this.parameters.direction\n }\n }\n\n _animate () {\n if (!this._run) return\n\n this._currentTime = window.performance.now()\n const dt = this._currentTime - this._previousTime\n const step = this.parameters.interpolateType ? this.parameters.interpolateStep : 1\n const timeout = this.parameters.timeout / step\n const traj = this.traj\n\n if (traj && traj.frameCount && !traj.inProgress && dt >= timeout) {\n if (this.parameters.interpolateType) {\n if (this._currentStep > this.parameters.interpolateStep) {\n this._currentStep = 1\n }\n if (this._currentStep === 1) {\n this._currentFrame = this._nextInterpolated()\n }\n if (traj.hasFrame(this._currentFrame)) {\n this._currentStep += 1\n const t = this._currentStep / (this.parameters.interpolateStep + 1)\n const [i, ip, ipp, ippp] = this._currentFrame as [number, number, number, number]\n traj.setFrameInterpolated(\n i, ip, ipp, ippp, t, this.parameters.interpolateType\n )\n this._previousTime = this._currentTime\n } else {\n traj.loadFrame(this._currentFrame)\n }\n } else {\n const i = this._next()\n if (traj.hasFrame(i)) {\n traj.setFrame(i)\n this._previousTime = this._currentTime\n } else {\n traj.loadFrame(i)\n }\n }\n }\n\n window.requestAnimationFrame(this._animate)\n }\n\n _next () {\n const p = this.parameters\n let i\n\n if (this._direction === 'forward') {\n i = this.traj.currentFrame + p.step\n } else {\n i = this.traj.currentFrame - p.step\n }\n\n if (i > p.end || i < p.start) {\n if (p.direction === 'bounce') {\n if (this._direction === 'forward') {\n this._direction = 'backward'\n } else {\n this._direction = 'forward'\n }\n }\n\n if (p.mode === 'once') {\n this.pause()\n\n if (p.direction === 'forward') {\n i = p.end\n } else if (p.direction === 'backward') {\n i = p.start\n } else {\n if (this._direction === 'forward') {\n i = p.start\n } else {\n i = p.end\n }\n }\n } else {\n if (this._direction === 'forward') {\n i = p.start\n if (p.interpolateType) {\n i = Math.min(p.end, i + p.step)\n }\n } else {\n i = p.end\n if (p.interpolateType) {\n i = Math.max(p.start, i - p.step)\n }\n }\n }\n }\n\n return i\n }\n\n _nextInterpolated () {\n const p = this.parameters\n const i = this._next()\n let ip, ipp, ippp\n\n if (this._direction === 'forward') {\n ip = Math.max(p.start, i - p.step)\n ipp = Math.max(p.start, i - 2 * p.step)\n ippp = Math.max(p.start, i - 3 * p.step)\n } else {\n ip = Math.min(p.end, i + p.step)\n ipp = Math.min(p.end, i + 2 * p.step)\n ippp = Math.min(p.end, i + 3 * p.step)\n }\n\n return [i, ip, ipp, ippp] as [number, number, number, number]\n }\n\n /**\n * toggle between playing and pausing the animation\n * @return {undefined}\n */\n toggle () {\n if (this._run) {\n this.pause()\n } else {\n this.play()\n }\n }\n\n /**\n * start the animation\n * @return {undefined}\n */\n play () {\n if (!this._run) {\n if (this.traj.player !== this) {\n this.traj.setPlayer(this)\n }\n this._currentStep = 1\n\n const p = this.parameters\n const frame = this.traj.currentFrame\n\n // snap to the grid implied by this.step division and multiplication\n // thus minimizing cache misses\n let i = Math.ceil(frame / p.step) * p.step\n // wrap when restarting from the limit (i.e. end or start)\n if (p.direction === 'forward' && frame >= p.end) {\n i = p.start\n } else if (p.direction === 'backward' && frame <= p.start) {\n i = p.end\n }\n\n this.traj.setFrame(i)\n\n this._run = true\n this._animate()\n this.signals.startedRunning.dispatch()\n }\n }\n\n /**\n * pause the animation\n * @return {undefined}\n */\n pause () {\n this._run = false\n this.signals.haltedRunning.dispatch()\n }\n\n /**\n * stop the animation (pause and go to start-frame)\n * @return {undefined}\n */\n stop () {\n this.pause()\n this.traj.setFrame(this.parameters.start)\n }\n}\n\nexport default TrajectoryPlayer\n","/**\n * @file Trajectory\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { Log } from '../globals'\nimport { defaults } from '../utils'\nimport { NumberArray } from '../types'\nimport { circularMean, arrayMean } from '../math/array-utils'\nimport { lerp, spline } from '../math/math-utils'\nimport Selection from '../selection/selection'\nimport Superposition from '../align/superposition'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\nimport TrajectoryPlayer, { TrajectoryPlayerInterpolateType } from './trajectory-player'\n\n\nfunction centerPbc (coords: NumberArray, mean: number[], box: ArrayLike) {\n if (box[ 0 ] === 0 || box[ 8 ] === 0 || box[ 4 ] === 0) {\n return\n }\n\n const n = coords.length\n\n const bx = box[ 0 ]\n const by = box[ 1 ]\n const bz = box[ 2 ]\n const mx = mean[ 0 ]\n const my = mean[ 1 ]\n const mz = mean[ 2 ]\n\n const fx = -mx + bx + bx / 2\n const fy = -my + by + by / 2\n const fz = -mz + bz + bz / 2\n\n for (let i = 0; i < n; i += 3) {\n coords[ i + 0 ] = (coords[ i + 0 ] + fx) % bx\n coords[ i + 1 ] = (coords[ i + 1 ] + fy) % by\n coords[ i + 2 ] = (coords[ i + 2 ] + fz) % bz\n }\n}\n\nfunction removePbc (x: NumberArray, box: ArrayLike) {\n if (box[ 0 ] === 0 || box[ 8 ] === 0 || box[ 4 ] === 0) {\n return\n }\n\n // ported from GROMACS src/gmxlib/rmpbc.c:rm_gropbc()\n // in-place\n\n const n = x.length\n\n for (let i = 3; i < n; i += 3) {\n for (let j = 0; j < 3; ++j) {\n const dist = x[ i + j ] - x[ i - 3 + j ]\n\n if (Math.abs(dist) > 0.9 * box[ j * 3 + j ]) {\n if (dist > 0) {\n for (let d = 0; d < 3; ++d) {\n x[ i + d ] -= box[ j * 3 + d ]\n }\n } else {\n for (let d = 0; d < 3; ++d) {\n x[ i + d ] += box[ j * 3 + d ]\n }\n }\n }\n }\n }\n\n return x\n}\n\nfunction removePeriodicity (x: NumberArray, box: ArrayLike, mean: number[]) {\n if (box[ 0 ] === 0 || box[ 8 ] === 0 || box[ 4 ] === 0) {\n return\n }\n\n const n = x.length\n for (let i = 3; i < n; i += 3) {\n for (let j = 0; j < 3; ++j) {\n const f = (x[ i + j ] - mean[ j ]) / box[ j * 3 + j ]\n if (Math.abs(f) > 0.5) {\n x[ i + j ] -= box[ j * 3 + j ] * Math.round(f)\n }\n }\n }\n\n return x\n}\n\nfunction circularMean3 (indices: NumberArray, coords: NumberArray, box: ArrayLike) {\n return [\n circularMean(coords, box[ 0 ], 3, 0, indices),\n circularMean(coords, box[ 1 ], 3, 1, indices),\n circularMean(coords, box[ 2 ], 3, 2, indices)\n ]\n}\n\nfunction arrayMean3 (coords: NumberArray) {\n return [\n arrayMean(coords, 3, 0),\n arrayMean(coords, 3, 1),\n arrayMean(coords, 3, 2)\n ]\n}\n\nfunction interpolateSpline (c: NumberArray, cp: NumberArray, cpp: NumberArray, cppp: NumberArray, t: number) {\n const m = c.length\n const coords = new Float32Array(m)\n\n for (let j0 = 0; j0 < m; j0 += 3) {\n const j1 = j0 + 1\n const j2 = j0 + 2\n coords[ j0 ] = spline(cppp[ j0 ], cpp[ j0 ], cp[ j0 ], c[ j0 ], t, 1)\n coords[ j1 ] = spline(cppp[ j1 ], cpp[ j1 ], cp[ j1 ], c[ j1 ], t, 1)\n coords[ j2 ] = spline(cppp[ j2 ], cpp[ j2 ], cp[ j2 ], c[ j2 ], t, 1)\n }\n\n return coords\n}\n\nfunction interpolateLerp (c: NumberArray, cp: NumberArray, t: number) {\n const m = c.length\n const coords = new Float32Array(m)\n\n for (let j0 = 0; j0 < m; j0 += 3) {\n const j1 = j0 + 1\n const j2 = j0 + 2\n coords[ j0 ] = lerp(cp[ j0 ], c[ j0 ], t)\n coords[ j1 ] = lerp(cp[ j1 ], c[ j1 ], t)\n coords[ j2 ] = lerp(cp[ j2 ], c[ j2 ], t)\n }\n\n return coords\n}\n\n/**\n * Trajectory parameter object.\n * @typedef {Object} TrajectoryParameters - parameters\n *\n * @property {Number} deltaTime - timestep between frames in picoseconds\n * @property {Number} timeOffset - starting time of frames in picoseconds\n * @property {String} sele - to restrict atoms used for superposition\n * @property {Boolean} centerPbc - center on initial frame\n * @property {Boolean} removePeriodicity - move atoms into the origin box\n * @property {Boolean} remo - try fixing periodic boundary discontinuities\n * @property {Boolean} superpose - superpose on initial frame\n */\n\n/**\n * @example\n * trajectory.signals.frameChanged.add( function(i){ ... } );\n *\n * @typedef {Object} TrajectorySignals\n * @property {Signal} countChanged - when the frame count is changed\n * @property {Signal} frameChanged - when the set frame is changed\n * @property {Signal} playerChanged - when the player is changed\n */\n\nexport interface TrajectoryParameters {\n deltaTime: number // timestep between frames in picoseconds\n timeOffset: number // starting time of frames in picoseconds\n sele: string // to restrict atoms used for superposition\n centerPbc: boolean // center on initial frame\n removePbc: boolean // move atoms into the origin box\n removePeriodicity: boolean // try fixing periodic boundary discontinuities\n superpose: boolean // superpose on initial frame\n}\n\nexport interface TrajectorySignals {\n countChanged: Signal\n frameChanged: Signal\n playerChanged: Signal\n}\n\n/**\n * Base class for trajectories, tying structures and coordinates together\n * @interface\n */\nclass Trajectory {\n signals: TrajectorySignals = {\n countChanged: new Signal(),\n frameChanged: new Signal(),\n playerChanged: new Signal()\n }\n\n deltaTime: number\n timeOffset: number\n sele: string\n centerPbc: boolean\n removePbc: boolean\n removePeriodicity: boolean\n superpose: boolean\n\n name: string\n frame: number\n trajPath: string\n\n initialCoords: Float32Array\n structureCoords: Float32Array\n selectionIndices: NumberArray\n backboneIndices: NumberArray\n\n coords1: Float32Array\n coords2: Float32Array\n\n frameCache: { [k: number]: Float32Array } = {}\n loadQueue: { [k: number]: boolean } = {}\n boxCache: { [k: number]: ArrayLike } = {}\n pathCache = {}\n frameCacheSize = 0\n\n atomCount: number\n inProgress: boolean\n\n selection: Selection // selection to restrict atoms used for superposition\n structure: Structure\n player: TrajectoryPlayer\n\n private _frameCount = 0\n private _currentFrame = -1\n private _disposed = false\n\n /**\n * @param {String} trajPath - trajectory source\n * @param {Structure} structure - the structure object\n * @param {TrajectoryParameters} params - trajectory parameters\n */\n constructor (trajPath: string, structure: Structure, params: Partial = {}) {\n this.deltaTime = defaults(params.deltaTime, 0)\n this.timeOffset = defaults(params.timeOffset, 0)\n this.centerPbc = defaults(params.centerPbc, false)\n this.removePbc = defaults(params.removePbc, false)\n this.removePeriodicity = defaults(params.removePeriodicity, false)\n this.superpose = defaults(params.superpose, false)\n\n this.name = trajPath.replace(/^.*[\\\\/]/, '')\n this.trajPath = trajPath\n\n this.selection = new Selection(\n defaults(params.sele, 'backbone and not hydrogen')\n )\n\n this.selection.signals.stringChanged.add(() => {\n this.selectionIndices = this.structure.getAtomIndices(this.selection)!\n this._resetCache()\n this._saveInitialCoords()\n this.setFrame(this._currentFrame)\n })\n }\n\n /**\n * Number of frames in the trajectory\n */\n get frameCount () {\n return this._frameCount\n }\n\n /**\n * Currently set frame of the trajectory\n */\n get currentFrame () {\n return this._currentFrame\n }\n\n _init (structure: Structure) {\n this.setStructure(structure)\n this._loadFrameCount()\n this.setPlayer(new TrajectoryPlayer(this))\n }\n\n _loadFrameCount () {}\n\n setStructure (structure: Structure) {\n this.structure = structure\n this.atomCount = structure.atomCount\n\n this.backboneIndices = this._getIndices(\n new Selection('backbone and not hydrogen')\n )\n this._makeAtomIndices()\n this._saveStructureCoords()\n\n this.selectionIndices = this._getIndices(this.selection)\n this._resetCache()\n this._saveInitialCoords()\n this.setFrame(this._currentFrame)\n }\n\n _saveInitialCoords () {\n if (this.structure.hasCoords()) {\n this.initialCoords = new Float32Array(this.structureCoords)\n this._makeSuperposeCoords()\n } else if (this.frameCache[0]) {\n this.initialCoords = new Float32Array(this.frameCache[0])\n this._makeSuperposeCoords()\n } else {\n this.loadFrame(0, () => this._saveInitialCoords())\n }\n }\n\n _saveStructureCoords () {\n const p = { what: { position: true } }\n this.structureCoords = this.structure.getAtomData(p).position!\n }\n\n setSelection (string: string) {\n this.selection.setString(string)\n return this\n }\n\n _getIndices (selection: Selection) {\n let i = 0\n const test = selection.test\n const indices: number[] = []\n\n if (test) {\n this.structure.eachAtom((ap: AtomProxy) => {\n if (test(ap)) indices.push(i)\n i += 1\n })\n }\n\n return indices\n }\n\n _makeSuperposeCoords () {\n const n = this.selectionIndices.length * 3\n\n this.coords1 = new Float32Array(n)\n this.coords2 = new Float32Array(n)\n\n const y = this.initialCoords\n const coords2 = this.coords2\n\n for (let i = 0; i < n; i += 3) {\n const j = this.selectionIndices[ i / 3 ] * 3\n\n coords2[ i + 0 ] = y[ j + 0 ]\n coords2[ i + 1 ] = y[ j + 1 ]\n coords2[ i + 2 ] = y[ j + 2 ]\n }\n }\n\n _makeAtomIndices () {\n Log.error('Trajectory._makeAtomIndices not implemented')\n }\n\n _resetCache () {\n this.frameCache = {}\n this.loadQueue = {}\n this.boxCache = {}\n this.pathCache = {}\n this.frameCacheSize = 0\n this.initialCoords = new Float32Array(0)\n }\n\n setParameters (params: Partial = {}) {\n let resetCache = false\n\n if (params.centerPbc !== undefined && params.centerPbc !== this.centerPbc) {\n this.centerPbc = params.centerPbc\n resetCache = true\n }\n\n if (params.removePeriodicity !== undefined && params.removePeriodicity !== this.removePeriodicity) {\n this.removePeriodicity = params.removePeriodicity\n resetCache = true\n }\n\n if (params.removePbc !== undefined && params.removePbc !== this.removePbc) {\n this.removePbc = params.removePbc\n resetCache = true\n }\n\n if (params.superpose !== undefined && params.superpose !== this.superpose) {\n this.superpose = params.superpose\n resetCache = true\n }\n\n this.deltaTime = defaults(params.deltaTime, this.deltaTime)\n this.timeOffset = defaults(params.timeOffset, this.timeOffset)\n\n if (resetCache) {\n this._resetCache()\n this.setFrame(this._currentFrame)\n }\n }\n\n /**\n * Check if a frame is available\n * @param {Integer|Integer[]} i - the frame index\n * @return {Boolean} frame availability\n */\n hasFrame (i: number|number[]) {\n if (Array.isArray(i)) {\n return i.every(j => !!this.frameCache[j])\n } else {\n return !!this.frameCache[i]\n }\n }\n\n /**\n * Set trajectory to a frame index\n * @param {Integer} i - the frame index\n * @param {Function} [callback] - fired when the frame has been set\n */\n setFrame (i: number, callback?: Function) {\n if (i === undefined) return this\n\n this.inProgress = true\n\n // i = parseInt(i) // TODO\n\n if (i === -1 || this.frameCache[ i ]) {\n this._updateStructure(i)\n if (callback) callback()\n } else {\n this.loadFrame(i, () => {\n this._updateStructure(i)\n if (callback) callback()\n })\n }\n\n return this\n }\n\n _interpolate (i: number, ip: number, ipp: number, ippp: number, t: number, type: TrajectoryPlayerInterpolateType) {\n const fc = this.frameCache\n\n let coords\n if (type === 'spline') {\n coords = interpolateSpline(fc[ i ], fc[ ip ], fc[ ipp ], fc[ ippp ], t)\n } else {\n coords = interpolateLerp(fc[ i ], fc[ ip ], t)\n }\n\n this.structure.updatePosition(coords)\n this._currentFrame = i\n this.signals.frameChanged.dispatch(i)\n }\n\n /**\n * Interpolated and set trajectory to frame indices\n * @param {Integer} i - the frame index\n * @param {Integer} ip - one before frame index\n * @param {Integer} ipp - two before frame index\n * @param {Integer} ippp - three before frame index\n * @param {Number} t - interpolation step [0,1]\n * @param {String} type - interpolation type, '', 'spline' or 'linear'\n * @param {Function} callback - fired when the frame has been set\n */\n setFrameInterpolated (i: number, ip: number, ipp: number, ippp: number, t: number, type: TrajectoryPlayerInterpolateType, callback?: Function) {\n if (i === undefined) return this\n\n const fc = this.frameCache\n const iList: number[] = []\n\n if (!fc[ ippp ]) iList.push(ippp)\n if (!fc[ ipp ]) iList.push(ipp)\n if (!fc[ ip ]) iList.push(ip)\n if (!fc[ i ]) iList.push(i)\n\n if (iList.length) {\n this.loadFrame(iList, () => {\n this._interpolate(i, ip, ipp, ippp, t, type)\n if (callback) callback()\n })\n } else {\n this._interpolate(i, ip, ipp, ippp, t, type)\n if (callback) callback()\n }\n\n return this\n }\n\n /**\n * Load frame index\n * @param {Integer|Integer[]} i - the frame index\n * @param {Function} callback - fired when the frame has been loaded\n */\n loadFrame (i: number|number[], callback?: Function) {\n if (Array.isArray(i)) {\n i.forEach(j => {\n if (!this.loadQueue[j] && !this.frameCache[j]) {\n this.loadQueue[j] = true\n this._loadFrame(j, () => {\n delete this.loadQueue[j]\n })\n }\n })\n } else {\n if (!this.loadQueue[i] && !this.frameCache[i]) {\n this.loadQueue[i] = true\n this._loadFrame(i, () => {\n delete this.loadQueue[i]\n if (callback) callback()\n })\n }\n }\n }\n\n /**\n * Load frame index\n * @abstract\n * @param {Integer} i - the frame index\n * @param {Function} callback - fired when the frame has been loaded\n */\n _loadFrame (i: number, callback?: Function) {\n Log.error('Trajectory._loadFrame not implemented', i, callback)\n }\n\n _updateStructure (i: number) {\n if (this._disposed) {\n console.error('updateStructure: traj disposed')\n return\n }\n\n if (i === -1) {\n if (this.structureCoords) {\n this.structure.updatePosition(this.structureCoords)\n }\n } else {\n this.structure.updatePosition(this.frameCache[ i ])\n }\n\n this.structure.trajectory = {\n name: this.trajPath,\n frame: i\n }\n\n this._currentFrame = i\n this.inProgress = false\n this.signals.frameChanged.dispatch(i)\n }\n\n _doSuperpose (x: Float32Array) {\n const n = this.selectionIndices.length * 3\n\n const coords1 = this.coords1\n const coords2 = this.coords2\n\n for (let i = 0; i < n; i += 3) {\n const j = this.selectionIndices[ i / 3 ] * 3\n\n coords1[ i + 0 ] = x[ j + 0 ]\n coords1[ i + 1 ] = x[ j + 1 ]\n coords1[ i + 2 ] = x[ j + 2 ]\n }\n\n // TODO re-use superposition object\n const sp = new Superposition(coords1, coords2)\n sp.transform(x)\n }\n\n _process (i: number, box: ArrayLike, coords: Float32Array, frameCount: number) {\n this._setFrameCount(frameCount)\n\n if (box) {\n if (this.backboneIndices.length > 0 && this.centerPbc) {\n const box2 = [ box[ 0 ], box[ 4 ], box[ 8 ] ]\n const circMean = circularMean3(this.backboneIndices, coords, box2)\n centerPbc(coords, circMean, box2)\n }\n\n if (this.removePeriodicity) {\n const mean = arrayMean3(coords)\n removePeriodicity(coords, box, mean)\n }\n\n if (this.removePbc) {\n removePbc(coords, box)\n }\n }\n\n if (this.selectionIndices.length > 0 && this.coords1 && this.superpose) {\n this._doSuperpose(coords)\n }\n\n this.frameCache[ i ] = coords\n this.boxCache[ i ] = box\n this.frameCacheSize += 1\n }\n\n _setFrameCount (n: number) {\n if (n !== this._frameCount) {\n this._frameCount = n\n this.signals.countChanged.dispatch(n)\n }\n }\n\n /**\n * Dispose of the trajectory object\n * @return {undefined}\n */\n dispose () {\n this._resetCache() // aid GC\n this._disposed = true\n if (this.player) this.player.stop()\n }\n\n /**\n * Set player for this trajectory\n * @param {TrajectoryPlayer} player - the player\n */\n setPlayer (player: TrajectoryPlayer) {\n this.player = player\n this.signals.playerChanged.dispatch(player)\n }\n\n /**\n * Get time for frame\n * @param {Integer} i - frame index\n * @return {Number} time in picoseconds\n */\n getFrameTime (i: number) {\n return this.timeOffset + i * this.deltaTime\n }\n}\n\nexport default Trajectory\n","/**\n * @file Frames Trajectory\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport Structure from '../structure/structure'\nimport Frames from './frames'\nimport Trajectory, { TrajectoryParameters } from './trajectory'\n\n/**\n * Frames trajectory class. Gets data from a frames object.\n */\nclass FramesTrajectory extends Trajectory {\n path: string\n\n frames: ArrayLike[]\n boxes: ArrayLike[]\n\n atomIndices?: ArrayLike\n\n constructor (frames: Frames, structure: Structure, params: TrajectoryParameters) {\n const p = params || {}\n p.timeOffset = defaults(p.timeOffset, frames.timeOffset)\n p.deltaTime = defaults(p.deltaTime, frames.deltaTime)\n\n super('', structure, p)\n\n this.name = frames.name\n this.path = frames.path\n\n this.frames = frames.coordinates\n this.boxes = frames.boxes\n\n this._init(structure)\n }\n\n get type () { return 'frames' }\n\n _makeAtomIndices () {\n if (this.structure.type === 'StructureView') {\n this.atomIndices = this.structure.getAtomIndices()\n } else {\n this.atomIndices = undefined\n }\n }\n\n _loadFrame (i: number, callback?: Function) {\n let coords\n const frame = this.frames[ i ]\n\n if (this.atomIndices) {\n const indices = this.atomIndices\n const m = indices.length\n\n coords = new Float32Array(m * 3)\n\n for (let j = 0; j < m; ++j) {\n const j3 = j * 3\n const idx3 = indices[ j ] * 3\n\n coords[ j3 + 0 ] = frame[ idx3 + 0 ]\n coords[ j3 + 1 ] = frame[ idx3 + 1 ]\n coords[ j3 + 2 ] = frame[ idx3 + 2 ]\n }\n } else {\n coords = new Float32Array(frame)\n }\n\n const box = this.boxes[ i ]\n const frameCount = this.frames.length\n\n this._process(i, box, coords, frameCount)\n\n if (typeof callback === 'function') {\n callback()\n }\n }\n\n _loadFrameCount () {\n if (this.frames) {\n this._setFrameCount(this.frames.length)\n }\n }\n}\n\nexport default FramesTrajectory\n","/**\n * @file Structure Trajectory\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Trajectory, { TrajectoryParameters } from './trajectory'\n\n/**\n * Structure trajectory class. Gets data from a structure object.\n */\nclass StructureTrajectory extends Trajectory {\n atomIndices?: ArrayLike\n\n constructor (trajPath: string, structure: Structure, params: TrajectoryParameters) {\n super('', structure, params)\n this._init(structure)\n }\n\n get type () { return 'structure' }\n\n _makeAtomIndices () {\n if (this.structure.atomSet && this.structure.atomSet.getSize() < this.structure.atomStore.count) {\n this.atomIndices = this.structure.getAtomIndices()\n } else {\n this.atomIndices = undefined\n }\n }\n\n _loadFrame (i: number, callback?: Function) {\n let coords\n const structure = this.structure\n const frame = structure.frames[ i ]\n\n if (this.atomIndices) {\n const indices = this.atomIndices\n const m = indices.length\n\n coords = new Float32Array(m * 3)\n\n for (let j = 0; j < m; ++j) {\n const j3 = j * 3\n const idx3 = indices[ j ] * 3\n\n coords[ j3 + 0 ] = frame[ idx3 + 0 ]\n coords[ j3 + 1 ] = frame[ idx3 + 1 ]\n coords[ j3 + 2 ] = frame[ idx3 + 2 ]\n }\n } else {\n coords = new Float32Array(frame)\n }\n\n const box = structure.boxes[ i ]\n const frameCount = structure.frames.length\n\n this._process(i, box, coords, frameCount)\n\n if (typeof callback === 'function') {\n callback()\n }\n }\n\n _loadFrameCount () {\n this._setFrameCount(this.structure.frames.length)\n }\n}\n\nexport default StructureTrajectory\n","/**\n * @file Remote Trajectory\n * @author Alexander Rose \n * @private\n */\n\nimport { Log, TrajectoryDatasource } from '../globals'\nimport Structure from '../structure/structure'\nimport Trajectory, { TrajectoryParameters } from './trajectory'\n\n/**\n * Remote trajectory class. Gets data from an MDsrv instance.\n */\nclass RemoteTrajectory extends Trajectory {\n atomIndices: number[][]\n\n constructor (trajPath: string, structure: Structure, params: TrajectoryParameters) {\n super(trajPath, structure, params)\n this._init(structure)\n }\n\n get type () { return 'remote' }\n\n _makeAtomIndices () {\n const atomIndices = []\n\n if (this.structure.type === 'StructureView') {\n const indices = this.structure.getAtomIndices()! // TODO\n const n = indices.length\n\n let p = indices[ 0 ]\n let q = indices[ 0 ]\n\n for (let i = 1; i < n; ++i) {\n const r = indices[ i ]\n\n if (q + 1 < r) {\n atomIndices.push([ p, q + 1 ])\n p = r\n }\n\n q = r\n }\n\n atomIndices.push([ p, q + 1 ])\n } else {\n atomIndices.push([ 0, this.atomCount ])\n }\n\n this.atomIndices = atomIndices\n }\n\n _loadFrame (i: number, callback?: Function) {\n // TODO implement max frameCache size, re-use arrays\n\n const request = new XMLHttpRequest()\n\n const url = TrajectoryDatasource.getFrameUrl(this.trajPath, i)\n const params = TrajectoryDatasource.getFrameParams(this.trajPath, this.atomIndices)\n\n request.open('POST', url, true)\n request.responseType = 'arraybuffer'\n request.setRequestHeader(\n 'Content-type', 'application/x-www-form-urlencoded'\n )\n\n request.addEventListener('load', () => {\n const arrayBuffer = request.response\n if (!arrayBuffer) {\n Log.error(`empty arrayBuffer for '${url}'`)\n return\n }\n\n const frameCount = new Int32Array(arrayBuffer, 0, 1)[ 0 ]\n // const time = new Float32Array( arrayBuffer, 1 * 4, 1 )[ 0 ];\n const box = new Float32Array(arrayBuffer, 2 * 4, 9)\n const coords = new Float32Array(arrayBuffer, 11 * 4)\n\n this._process(i, box, coords, frameCount)\n if (typeof callback === 'function') {\n callback()\n }\n }, false)\n\n request.send(params)\n }\n\n _loadFrameCount () {\n const request = new XMLHttpRequest()\n\n const url = TrajectoryDatasource.getCountUrl(this.trajPath)\n\n request.open('GET', url, true)\n request.addEventListener('load', () => {\n this._setFrameCount(parseInt(request.response))\n }, false)\n request.send()\n }\n}\n\nexport default RemoteTrajectory\n","/**\n * @file Callback Trajectory\n * @author Tarn W. Burton \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Trajectory, { TrajectoryParameters } from './trajectory'\n\ntype RequestCallback = (responseCallback: Function, i?: number, atomIndices?: number[][]) => void\n\n/**\n * Callback trajectory class. Gets data from an JavaScript function.\n */\nclass CallbackTrajectory extends Trajectory {\n atomIndices: number[][]\n requestCallback: RequestCallback\n\n constructor (requestCallback: RequestCallback, structure: Structure, params: TrajectoryParameters) {\n super('', structure, params)\n this.requestCallback = requestCallback;\n this._init(structure)\n }\n\n get type () { return 'callback' }\n\n _makeAtomIndices () {\n const atomIndices = []\n\n if (this.structure.type === 'StructureView') {\n const indices = this.structure.getAtomIndices()! // TODO\n const n = indices.length\n\n let p = indices[ 0 ]\n let q = indices[ 0 ]\n\n for (let i = 1; i < n; ++i) {\n const r = indices[ i ]\n\n if (q + 1 < r) {\n atomIndices.push([ p, q + 1 ])\n p = r\n }\n\n q = r\n }\n\n atomIndices.push([ p, q + 1 ])\n } else {\n atomIndices.push([ 0, this.atomCount ])\n }\n\n this.atomIndices = atomIndices\n }\n\n _loadFrame (i: number, callback?: Function) {\n this.requestCallback(\n (i: number, box: ArrayLike, coords: Float32Array, frameCount: number) => {\n this._process(i, box, coords, frameCount)\n if (typeof callback === 'function') {\n callback()\n }\n }, i, this.atomIndices)\n }\n\n _loadFrameCount () {\n this.requestCallback((count: number) => this._setFrameCount(count))\n }\n}\n\nexport default CallbackTrajectory\n\n","/**\n * @file Structure View\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3 } from 'three'\n\nimport { Debug, Log } from '../globals'\nimport Structure from './structure'\nimport Selection from '../selection/selection'\nimport BitArray from '../utils/bitarray'\n\nimport BondProxy from '../proxy/bond-proxy'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\nimport SpatialHash from '../geometry/spatial-hash';\nimport BondHash from '../store/bond-hash';\nimport ResidueMap from '../store/residue-map';\nimport AtomMap from '../store/atom-map';\nimport ModelStore from '../store/model-store';\nimport ChainStore from '../store/chain-store';\nimport ResidueStore from '../store/residue-store';\nimport AtomStore from '../store/atom-store';\nimport BondStore from '../store/bond-store';\nimport Validation from './validation';\nimport Unitcell from '../symmetry/unitcell';\nimport Entity from './entity';\nimport Assembly from '../symmetry/assembly';\nimport { Data } from './data';\n\n/**\n * Get view on structure restricted to the selection\n * @param {Selection} selection - the selection\n * @return {StructureView} the view on the structure\n */\nStructure.prototype.getView = function (this: Structure, selection: Selection) {\n // added here to avoid cyclic import dependency\n return new StructureView(this, selection)\n}\n\n/**\n * View on the structure, restricted to the selection\n */\nclass StructureView extends Structure {\n structure: Structure\n selection: Selection\n\n /**\n * @param {Structure} structure - the structure\n * @param {Selection} selection - the selection\n */\n constructor (structure: Structure, selection: Selection) {\n super()\n\n this.structure = structure\n this.selection = selection\n\n this.center = new Vector3()\n this.boundingBox = new Box3()\n\n this._bp = this.getBondProxy()\n this._ap = this.getAtomProxy()\n this._rp = this.getResidueProxy()\n this._cp = this.getChainProxy()\n\n if (this.selection) {\n this.selection.signals.stringChanged.add(this.refresh, this)\n }\n\n this.structure.signals.refreshed.add(this.refresh, this)\n\n this.refresh()\n }\n\n init () {}\n\n get type () { return 'StructureView' }\n\n get name () { return this.structure.name }\n get path () { return this.structure.path }\n get title () { return this.structure.title }\n get id () { return this.structure.id }\n get data (): Data { return this.structure.data }\n get atomSetDict () { return this.structure.atomSetDict }\n get biomolDict (): {[k: string]: Assembly} { return this.structure.biomolDict }\n get entityList (): Entity[] { return this.structure.entityList }\n get unitcell (): Unitcell|undefined { return this.structure.unitcell }\n get frames () { return this.structure.frames }\n get boxes () { return this.structure.boxes }\n get validation (): Validation|undefined { return this.structure.validation }\n get bondStore () { return this.structure.bondStore }\n get backboneBondStore () { return this.structure.backboneBondStore }\n get rungBondStore (): BondStore { return this.structure.rungBondStore }\n get atomStore (): AtomStore { return this.structure.atomStore }\n get residueStore (): ResidueStore { return this.structure.residueStore }\n get chainStore (): ChainStore { return this.structure.chainStore }\n get modelStore (): ModelStore { return this.structure.modelStore }\n get atomMap (): AtomMap { return this.structure.atomMap }\n get residueMap (): ResidueMap { return this.structure.residueMap }\n get bondHash (): BondHash|undefined { return this.structure.bondHash }\n get spatialHash (): SpatialHash|undefined { return this.structure.spatialHash }\n\n get _hasCoords () { return this.structure._hasCoords }\n set _hasCoords (value) { this.structure._hasCoords = value }\n\n /**\n * Updates atomSet, bondSet, atomSetCache, atomCount, bondCount, boundingBox, center.\n * @emits {Structure.signals.refreshed} when refreshed\n * @return {undefined}\n */\n refresh () {\n if (Debug) Log.time('StructureView.refresh')\n\n this.atomSetCache = {}\n const structure = this.structure\n\n if (this.selection.isAllSelection() &&\n structure !== this && structure.atomSet && structure.bondSet\n ) {\n this.atomSet = structure.atomSet.clone()\n this.bondSet = structure.bondSet.clone()\n\n for (let name in this.atomSetDict) {\n const atomSet = this.atomSetDict[ name ]\n this.atomSetCache[ '__' + name ] = atomSet.clone()\n }\n\n this.atomCount = structure.atomCount\n this.bondCount = structure.bondCount\n\n this.boundingBox.copy(structure.boundingBox)\n this.center.copy(structure.center)\n } else if (this.selection.isNoneSelection() &&\n structure !== this && structure.atomSet && structure.bondSet\n ) {\n this.atomSet = new BitArray(structure.atomCount)\n this.bondSet = new BitArray(structure.bondCount)\n\n for (let name in this.atomSetDict) {\n this.atomSetCache[ '__' + name ] = new BitArray(structure.atomCount)\n }\n\n this.atomCount = 0\n this.bondCount = 0\n\n this.boundingBox.makeEmpty()\n this.center.set(0, 0, 0)\n } else {\n this.atomSet = this.getAtomSet(this.selection, true)\n if (structure.atomSet) {\n this.atomSet = this.atomSet.intersection(structure.atomSet)\n }\n\n this.bondSet = this.getBondSet()\n\n for (let name in this.atomSetDict) {\n const atomSet = this.atomSetDict[ name ]\n this.atomSetCache[ '__' + name ] = atomSet.makeIntersection(this.atomSet)\n }\n\n this.atomCount = this.atomSet.getSize()\n this.bondCount = this.bondSet.getSize()\n\n this.boundingBox = this.getBoundingBox()\n this.center = this.boundingBox.getCenter(new Vector3())\n }\n\n if (Debug) Log.timeEnd('StructureView.refresh')\n\n this.signals.refreshed.dispatch()\n }\n\n //\n\n setSelection (selection: Selection) {\n this.selection = selection\n\n this.refresh()\n }\n\n getSelection (selection?: Selection) {\n const seleList: string[] = []\n\n if (selection && selection.string) {\n seleList.push(selection.string)\n }\n\n const parentSelection = this.structure.getSelection()\n if (parentSelection && parentSelection.string) {\n seleList.push(parentSelection.string)\n }\n\n if (this.selection && this.selection.string) {\n seleList.push(this.selection.string)\n }\n\n let sele = ''\n if (seleList.length > 0) {\n sele = `( ${seleList.join(' ) AND ( ')} )`\n }\n\n return new Selection(sele)\n }\n\n getStructure () {\n return this.structure.getStructure()\n }\n\n //\n\n eachBond (callback: (entity: BondProxy) => any, selection?: Selection) {\n this.structure.eachBond(callback, this.getSelection(selection))\n }\n\n eachAtom (callback: (entity: AtomProxy) => any, selection?: Selection) {\n const ap = this.getAtomProxy()\n const atomSet = this.getAtomSet(selection)\n const n = this.atomStore.count\n\n if (atomSet.getSize() < n) {\n atomSet.forEach(function (index) {\n ap.index = index\n callback(ap)\n })\n } else {\n for (let i = 0; i < n; ++i) {\n ap.index = i\n callback(ap)\n }\n }\n }\n\n eachResidue (callback: (entity: ResidueProxy) => any, selection?: Selection) {\n this.structure.eachResidue(callback, this.getSelection(selection))\n }\n\n /**\n * Not implemented\n * @alias StructureView#eachResidueN\n * @return {undefined}\n */\n eachResidueN (n: number, callback: (entity: ResidueProxy) => any) {\n console.error('StructureView.eachResidueN() not implemented')\n }\n\n eachChain (callback: (entity: ChainProxy) => any, selection?: Selection) {\n this.structure.eachChain(callback, this.getSelection(selection))\n }\n\n eachModel (callback: (entity: ModelProxy) => any, selection?: Selection) {\n this.structure.eachModel(callback, this.getSelection(selection))\n }\n\n //\n\n getAtomSet (selection?: boolean|Selection|BitArray, ignoreView = false) {\n let atomSet = this.structure.getAtomSet(selection)\n if (!ignoreView && this.atomSet) {\n atomSet = atomSet.makeIntersection(this.atomSet)\n }\n\n return atomSet\n }\n\n //\n\n getAtomIndices (selection?: Selection) {\n return this.structure.getAtomIndices(this.getSelection(selection))\n }\n\n refreshPosition () {\n return this.structure.refreshPosition()\n }\n\n //\n\n dispose () {\n if (this.selection) {\n this.selection.signals.stringChanged.remove(this.refresh, this)\n }\n\n this.structure.signals.refreshed.remove(this.refresh, this)\n\n this.structure = new Structure() // delete old data\n\n delete this.atomSet\n delete this.bondSet\n\n }\n}\n\nexport default StructureView\n","/**\n * @file Alignment\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log } from '../globals'\n\n// const nucleotides = 'ACTG';\nconst aminoacidsX = 'ACDEFGHIKLMNPQRSTVWY'\nconst aminoacids = 'ARNDCQEGHILKMFPSTWYVBZ?'\n\nconst blosum62x = [\n [4, 0, -2, -1, -2, 0, -2, -1, -1, -1, -1, -2, -1, -1, -1, 1, 0, 0, -3, -2], // A\n [0, 9, -3, -4, -2, -3, -3, -1, -3, -1, -1, -3, -3, -3, -3, -1, -1, -1, -2, -2], // C\n [-2, -3, 6, 2, -3, -1, -1, -3, -1, -4, -3, 1, -1, 0, -2, 0, -1, -3, -4, -3], // D\n [-1, -4, 2, 5, -3, -2, 0, -3, 1, -3, -2, 0, -1, 2, 0, 0, -1, -2, -3, -2], // E\n [-2, -2, -3, -3, 6, -3, -1, 0, -3, 0, 0, -3, -4, -3, -3, -2, -2, -1, 1, 3], // F\n [0, -3, -1, -2, -3, 6, -2, -4, -2, -4, -3, 0, -2, -2, -2, 0, -2, -3, -2, -3], // G\n [-2, -3, -1, 0, -1, -2, 8, -3, -1, -3, -2, 1, -2, 0, 0, -1, -2, -3, -2, 2], // H\n [-1, -1, -3, -3, 0, -4, -3, 4, -3, 2, 1, -3, -3, -3, -3, -2, -1, 3, -3, -1], // I\n [-1, -3, -1, 1, -3, -2, -1, -3, 5, -2, -1, 0, -1, 1, 2, 0, -1, -2, -3, -2], // K\n [-1, -1, -4, -3, 0, -4, -3, 2, -2, 4, 2, -3, -3, -2, -2, -2, -1, 1, -2, -1], // L\n [-1, -1, -3, -2, 0, -3, -2, 1, -1, 2, 5, -2, -2, 0, -1, -1, -1, 1, -1, -1], // M\n [-2, -3, 1, 0, -3, 0, 1, -3, 0, -3, -2, 6, -2, 0, 0, 1, 0, -3, -4, -2], // N\n [-1, -3, -1, -1, -4, -2, -2, -3, -1, -3, -2, -2, 7, -1, -2, -1, -1, -2, -4, -3], // P\n [-1, -3, 0, 2, -3, -2, 0, -3, 1, -2, 0, 0, -1, 5, 1, 0, -1, -2, -2, -1], // Q\n [-1, -3, -2, 0, -3, -2, 0, -3, 2, -2, -1, 0, -2, 1, 5, -1, -1, -3, -3, -2], // R\n [1, -1, 0, 0, -2, 0, -1, -2, 0, -2, -1, 1, -1, 0, -1, 4, 1, -2, -3, -2], // S\n [0, -1, -1, -1, -2, -2, -2, -1, -1, -1, -1, 0, -1, -1, -1, 1, 5, 0, -2, -2], // T\n [0, -1, -3, -2, -1, -3, -3, 3, -2, 1, 1, -3, -2, -2, -3, -2, 0, 4, -3, -1], // V\n [-3, -2, -4, -3, 1, -2, -2, -3, -3, -2, -1, -4, -4, -2, -3, -3, -2, -3, 11, 2], // W\n [-2, -2, -3, -2, 3, -3, 2, -1, -2, -1, -1, -2, -3, -1, -2, -2, -2, -1, 2, 7] // Y\n]\n\nconst blosum62 = [\n // A R N D C Q E G H I L K M F P S T W Y V B Z X\n [4, -1, -2, -2, 0, -1, -1, 0, -2, -1, -1, -1, -1, -2, -1, 1, 0, -3, -2, 0, -2, -1, 0], // A\n [-1, 5, 0, -2, -3, 1, 0, -2, 0, -3, -2, 2, -1, -3, -2, -1, -1, -3, -2, -3, -1, 0, -1], // R\n [-2, 0, 6, 1, -3, 0, 0, 0, 1, -3, -3, 0, -2, -3, -2, 1, 0, -4, -2, -3, 3, 0, -1], // N\n [-2, -2, 1, 6, -3, 0, 2, -1, -1, -3, -4, -1, -3, -3, -1, 0, -1, -4, -3, -3, 4, 1, -1], // D\n [0, -3, -3, -3, 9, -3, -4, -3, -3, -1, -1, -3, -1, -2, -3, -1, -1, -2, -2, -1, -3, -3, -2], // C\n [-1, 1, 0, 0, -3, 5, 2, -2, 0, -3, -2, 1, 0, -3, -1, 0, -1, -2, -1, -2, 0, 3, -1], // Q\n [-1, 0, 0, 2, -4, 2, 5, -2, 0, -3, -3, 1, -2, -3, -1, 0, -1, -3, -2, -2, 1, 4, -1], // E\n [0, -2, 0, -1, -3, -2, -2, 6, -2, -4, -4, -2, -3, -3, -2, 0, -2, -2, -3, -3, -1, -2, -1], // G\n [-2, 0, 1, -1, -3, 0, 0, -2, 8, -3, -3, -1, -2, -1, -2, -1, -2, -2, 2, -3, 0, 0, -1], // H\n [-1, -3, -3, -3, -1, -3, -3, -4, -3, 4, 2, -3, 1, 0, -3, -2, -1, -3, -1, 3, -3, -3, -1], // I\n [-1, -2, -3, -4, -1, -2, -3, -4, -3, 2, 4, -2, 2, 0, -3, -2, -1, -2, -1, 1, -4, -3, -1], // L\n [-1, 2, 0, -1, -3, 1, 1, -2, -1, -3, -2, 5, -1, -3, -1, 0, -1, -3, -2, -2, 0, 1, -1], // K\n [-1, -1, -2, -3, -1, 0, -2, -3, -2, 1, 2, -1, 5, 0, -2, -1, -1, -1, -1, 1, -3, -1, -1], // M\n [-2, -3, -3, -3, -2, -3, -3, -3, -1, 0, 0, -3, 0, 6, -4, -2, -2, 1, 3, -1, -3, -3, -1], // F\n [-1, -2, -2, -1, -3, -1, -1, -2, -2, -3, -3, -1, -2, -4, 7, -1, -1, -4, -3, -2, -2, -1, -2], // P\n [1, -1, 1, 0, -1, 0, 0, 0, -1, -2, -2, 0, -1, -2, -1, 4, 1, -3, -2, -2, 0, 0, 0], // S\n [0, -1, 0, -1, -1, -1, -1, -2, -2, -1, -1, -1, -1, -2, -1, 1, 5, -2, -2, 0, -1, -1, 0], // T\n [-3, -3, -4, -4, -2, -2, -3, -2, -2, -3, -2, -3, -1, 1, -4, -3, -2, 11, 2, -3, -4, -3, -2], // W\n [-2, -2, -2, -3, -2, -1, -2, -3, 2, -1, -1, -2, -1, 3, -3, -2, -2, 2, 7, -1, -3, -2, -1], // Y\n [0, -3, -3, -3, -1, -2, -2, -3, -3, 3, 1, -2, 1, -1, -2, -2, 0, -3, -1, 4, -3, -2, -1], // V\n [-2, -1, 3, 4, -3, 0, 1, -1, 0, -3, -4, 0, -3, -3, -2, 0, -1, -4, -3, -3, 4, 1, -1], // B\n [-1, 0, 0, 1, -3, 3, 4, -2, 0, -3, -3, 1, -1, -3, -1, 0, -1, -3, -2, -2, 1, 4, -1], // Z\n [0, -1, -1, -1, -2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -2, 0, 0, -2, -1, -1, -1, -1, -1] // X\n]\n\nfunction prepareMatrix (cellNames: string, mat: number[][]) {\n let j: number\n let i = 0\n const matDict: { [k: string]: { [k: string]: number } } = {}\n mat.forEach(function (row) {\n j = 0\n const rowDict: { [k: string]: number } = {}\n row.forEach(function (elm) {\n rowDict[ cellNames[ j++ ] ] = elm\n })\n matDict[ cellNames[ i++ ] ] = rowDict\n })\n return matDict\n}\n\nconst SubstitutionMatrices = (function () {\n return {\n blosum62: prepareMatrix(aminoacids, blosum62),\n blosum62x: prepareMatrix(aminoacidsX, blosum62x)\n }\n}())\nexport type SubstitutionMatrix = ''|'blosum62'|'blosum62x'\n\nclass Alignment {\n substMatrix: { [k: string]: { [k: string]: number } }\n\n n: number\n m: number\n score?: number\n ali: string\n\n S: number[][]\n V: number[][]\n H: number[][]\n\n ali1: string\n ali2: string\n\n constructor (readonly seq1: string, readonly seq2: string, readonly gapPenalty = -10, readonly gapExtensionPenalty = -1, substMatrix: SubstitutionMatrix = 'blosum62') {\n // TODO try encoding seqs as integers and use array subst matrix, maybe faster\n\n if (substMatrix) {\n this.substMatrix = SubstitutionMatrices[ substMatrix ]\n }\n }\n\n initMatrices () {\n this.n = this.seq1.length\n this.m = this.seq2.length\n\n // Log.log(this.n, this.m);\n\n this.score = undefined\n this.ali = ''\n\n this.S = []\n this.V = []\n this.H = []\n\n for (let i = 0; i <= this.n; ++i) {\n this.S[ i ] = []\n this.V[ i ] = []\n this.H[ i ] = []\n\n for (let j = 0; j <= this.m; ++j) {\n this.S[ i ][ j ] = 0\n this.V[ i ][ j ] = 0\n this.H[ i ][ j ] = 0\n }\n }\n\n for (let i = 0; i <= this.n; ++i) {\n this.S[ i ][ 0 ] = this.gap(0)\n this.H[ i ][ 0 ] = -Infinity\n }\n\n for (let j = 0; j <= this.m; ++j) {\n this.S[ 0 ][ j ] = this.gap(0)\n this.V[ 0 ][ j ] = -Infinity\n }\n\n this.S[ 0 ][ 0 ] = 0\n\n // Log.log(this.S, this.V, this.H);\n }\n\n gap (len: number) {\n return this.gapPenalty + len * this.gapExtensionPenalty\n }\n\n makeScoreFn () {\n const seq1 = this.seq1\n const seq2 = this.seq2\n\n const substMatrix = this.substMatrix\n\n if (substMatrix) {\n return function score (i: number, j: number) {\n const c1 = seq1[ i ]\n const c2 = seq2[ j ]\n\n try {\n return substMatrix[ c1 ][ c2 ]\n } catch (e) {\n return -4\n }\n }\n } else {\n Log.warn('Alignment: no subst matrix')\n\n return function scoreNoSubstMat (i: number, j: number) {\n const c1 = seq1[ i ]\n const c2 = seq2[ j ]\n\n return c1 === c2 ? 5 : -3\n }\n }\n }\n\n calc () {\n if (Debug) Log.time('Alignment.calc')\n\n this.initMatrices()\n\n const gap0 = this.gap(0)\n const scoreFn = this.makeScoreFn()\n const gapExtensionPenalty = this.gapExtensionPenalty\n\n const V = this.V\n const H = this.H\n const S = this.S\n\n const n = this.n\n const m = this.m\n\n let Vi1, Si1, Vi, Hi, Si\n\n for (let i = 1; i <= n; ++i) {\n Si1 = S[ i - 1 ]\n Vi1 = V[ i - 1 ]\n\n Vi = V[ i ]\n Hi = H[ i ]\n Si = S[ i ]\n\n for (let j = 1; j <= m; ++j) {\n Vi[j] = Math.max(\n Si1[ j ] + gap0,\n Vi1[ j ] + gapExtensionPenalty\n )\n\n Hi[j] = Math.max(\n Si[ j - 1 ] + gap0,\n Hi[ j - 1 ] + gapExtensionPenalty\n )\n\n Si[j] = Math.max(\n Si1[ j - 1 ] + scoreFn(i - 1, j - 1), // match\n Vi[ j ], // del\n Hi[ j ] // ins\n )\n }\n }\n\n if (Debug) Log.timeEnd('Alignment.calc')\n\n if (Debug) Log.log(this.S, this.V, this.H)\n }\n\n trace () {\n if (Debug) Log.time('Alignment.trace')\n\n this.ali1 = ''\n this.ali2 = ''\n\n const scoreFn = this.makeScoreFn()\n\n let i = this.n\n let j = this.m\n let mat\n\n if (this.S[i][j] >= this.V[i][j]) {\n mat = 'S'\n this.score = this.S[i][j]\n } else if (this.V[i][j] >= this.H[i][j]) {\n mat = 'V'\n this.score = this.V[i][j]\n } else {\n mat = 'H'\n this.score = this.H[i][j]\n }\n\n if (Debug) Log.log('Alignment: SCORE', this.score)\n if (Debug) Log.log('Alignment: S, V, H', this.S[i][j], this.V[i][j], this.H[i][j])\n\n while (i > 0 && j > 0) {\n if (mat === 'S') {\n if (this.S[i][j] === this.S[i - 1][j - 1] + scoreFn(i - 1, j - 1)) {\n this.ali1 = this.seq1[i - 1] + this.ali1\n this.ali2 = this.seq2[j - 1] + this.ali2\n --i\n --j\n mat = 'S'\n } else if (this.S[i][j] === this.V[i][j]) {\n mat = 'V'\n } else if (this.S[i][j] === this.H[i][j]) {\n mat = 'H'\n } else {\n // Log.debug('Alignment: S');\n --i\n --j\n }\n } else if (mat === 'V') {\n if (this.V[i][j] === this.V[i - 1][j] + this.gapExtensionPenalty) {\n this.ali1 = this.seq1[i - 1] + this.ali1\n this.ali2 = '-' + this.ali2\n --i\n mat = 'V'\n } else if (this.V[i][j] === this.S[i - 1][j] + this.gap(0)) {\n this.ali1 = this.seq1[i - 1] + this.ali1\n this.ali2 = '-' + this.ali2\n --i\n mat = 'S'\n } else {\n // Log.debug('Alignment: V');\n --i\n }\n } else if (mat === 'H') {\n if (this.H[i][j] === this.H[i][j - 1] + this.gapExtensionPenalty) {\n this.ali1 = '-' + this.ali1\n this.ali2 = this.seq2[j - 1] + this.ali2\n --j\n mat = 'H'\n } else if (this.H[i][j] === this.S[i][j - 1] + this.gap(0)) {\n this.ali1 = '-' + this.ali1\n this.ali2 = this.seq2[j - 1] + this.ali2\n --j\n mat = 'S'\n } else {\n // Log.debug('Alignment: H');\n --j\n }\n } else {\n Log.error('Alignment: no matrix')\n }\n }\n\n while (i > 0) {\n this.ali1 = this.seq1[ i - 1 ] + this.ali1\n this.ali2 = '-' + this.ali2\n --i\n }\n\n while (j > 0) {\n this.ali1 = '-' + this.ali1\n this.ali2 = this.seq2[ j - 1 ] + this.ali2\n --j\n }\n\n if (Debug) Log.timeEnd('Alignment.trace')\n\n if (Debug) Log.log([this.ali1, this.ali2])\n }\n}\n\nexport default Alignment\n","/**\n * @file Align Utils\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Selection from '../selection/selection'\nimport Alignment from './alignment'\nimport Superposition from './superposition'\n\n/**\n * Perform structural superposition of two structures,\n * optionally guided by a sequence alignment\n * @param {Structure|StructureView} s1 - structure 1 which is superposed onto structure 2\n * @param {Structure|StructureView} s2 - structure 2 onto which structure 1 is superposed\n * @param {Boolean} [align] - guide the superposition by a sequence alignment\n * @param {String} [sele1] - selection string for structure 1\n * @param {String} [sele2] - selection string for structure 2\n * @return {undefined}\n */\nfunction superpose (s1: Structure, s2: Structure, align = false, sele1 = '', sele2 = '') {\n let i: number\n let j: number\n let n: number\n let atoms1\n let atoms2\n\n if (align) {\n let _s1 = s1\n let _s2 = s2\n\n if (sele1 && sele2) {\n _s1 = s1.getView(new Selection(sele1))\n _s2 = s2.getView(new Selection(sele2))\n }\n\n const seq1 = _s1.getSequence()\n const seq2 = _s2.getSequence()\n\n // Log.log( seq1.join(\"\") );\n // Log.log( seq2.join(\"\") );\n\n const ali = new Alignment(seq1.join(''), seq2.join(''))\n\n ali.calc()\n ali.trace()\n\n // Log.log( \"superpose alignment score\", ali.score );\n\n // Log.log( ali.ali1 );\n // Log.log( ali.ali2 );\n\n let _i, _j\n i = 0\n j = 0\n n = ali.ali1.length\n const aliIdx1: boolean[] = []\n const aliIdx2: boolean[] = []\n\n for (let l = 0; l < n; ++l) {\n const x = ali.ali1[ l ]\n const y = ali.ali2[ l ]\n\n _i = 0\n _j = 0\n\n if (x === '-') {\n aliIdx2[ j ] = false\n } else {\n aliIdx2[ j ] = true\n _i = 1\n }\n\n if (y === '-') {\n aliIdx1[ i ] = false\n } else {\n aliIdx1[ i ] = true\n _j = 1\n }\n\n i += _i\n j += _j\n }\n\n // Log.log( i, j );\n\n // Log.log( aliIdx1 );\n // Log.log( aliIdx2 );\n\n const _atoms1: number[] = []\n const _atoms2: number[] = []\n const ap1 = _s1.getAtomProxy()\n const ap2 = _s2.getAtomProxy()\n\n i = 0\n _s1.eachResidue(function (r) {\n if (r.traceAtomIndex === undefined ||\n r.traceAtomIndex !== r.getAtomIndexByName('CA')) return\n\n if (aliIdx1[ i ]) {\n ap1.index = r.getAtomIndexByName('CA')! // TODO\n _atoms1.push(ap1.x, ap1.y, ap1.z)\n }\n i += 1\n })\n\n i = 0\n _s2.eachResidue(function (r) {\n if (r.traceAtomIndex === undefined ||\n r.traceAtomIndex !== r.getAtomIndexByName('CA')) return\n\n if (aliIdx2[ i ]) {\n ap2.index = r.getAtomIndexByName('CA')! // TODO\n _atoms2.push(ap2.x, ap2.y, ap2.z)\n }\n i += 1\n })\n\n atoms1 = new Float32Array(_atoms1)\n atoms2 = new Float32Array(_atoms2)\n } else {\n const sviewCa1 = s1.getView(new Selection(`${sele1} and .CA`))\n const sviewCa2 = s2.getView(new Selection(`${sele2} and .CA`))\n\n atoms1 = sviewCa1\n atoms2 = sviewCa2\n }\n\n const superpose = new Superposition(atoms1, atoms2)\n const result = superpose.transform(s1)\n s1.refreshPosition()\n return result\n}\n\nexport {\n superpose\n}\n","/**\n * @file Sturucture Component\n * @author Alexander Rose \n * @private\n */\n\nimport { Signal } from 'signals'\n\nimport { ComponentRegistry, MeasurementDefaultParams } from '../globals'\nimport {\n defaults, /*deepEqual, */createRingBuffer, RingBuffer, createSimpleDict, SimpleDict\n} from '../utils'\nimport { smoothstep } from '../math/math-utils'\nimport Component, { ComponentSignals, ComponentDefaultParameters } from './component'\nimport RepresentationCollection from './representation-collection'\nimport TrajectoryElement from './trajectory-element'\nimport RepresentationElement from './representation-element'\nimport { makeTrajectory } from '../trajectory/trajectory-utils'\nimport { TrajectoryParameters } from '../trajectory/trajectory'\nimport Selection from '../selection/selection'\nimport Structure from '../structure/structure'\nimport StructureView from '../structure/structure-view'\nimport { superpose } from '../align/align-utils'\nimport Stage from '../stage/stage'\nimport StructureRepresentation, { StructureRepresentationParameters } from '../representation/structure-representation'\nimport AtomProxy from '../proxy/atom-proxy'\nimport { Vector3, Box3 } from 'three';\nimport { AngleRepresentationParameters } from '../representation/angle-representation';\nimport { AxesRepresentationParameters } from '../representation/axes-representation';\nimport { BallAndStickRepresentationParameters } from '../representation/ballandstick-representation';\nimport { CartoonRepresentationParameters } from '../representation/cartoon-representation';\nimport { ContactRepresentationParameters } from '../representation/contact-representation';\nimport { DihedralRepresentationParameters } from '../representation/dihedral-representation';\nimport { DihedralHistogramRepresentationParameters } from '../representation/dihedral-histogram-representation';\nimport { DistanceRepresentationParameters } from '../representation/distance-representation';\nimport { HyperballRepresentationParameters } from '../representation/hyperball-representation';\nimport { LabelRepresentationParameters } from '../representation/label-representation';\nimport { LineRepresentationParameters } from '../representation/line-representation';\nimport { PointRepresentationParameters } from '../representation/point-representation';\nimport { SurfaceRepresentationParameters } from '../representation/surface-representation';\nimport { RibbonRepresentationParameters } from '../representation/ribbon-representation';\nimport { RocketRepresentationParameters } from '../representation/rocket-representation';\nimport { TraceRepresentationParameters } from '../representation/trace-representation';\nimport { UnitcellRepresentationParameters } from '../representation/unitcell-representation';\nimport { SliceRepresentationParameters } from '../representation/slice-representation'\nimport { MolecularSurfaceRepresentationParameters } from '../representation/molecularsurface-representation'\nimport { DotRepresentationParameters } from '../representation/dot-representation'\n\nexport type StructureRepresentationType = keyof StructureRepresentationParametersMap\n\ninterface StructureRepresentationParametersMap {\n 'angle': AngleRepresentationParameters,\n 'axes' : AxesRepresentationParameters,\n 'backbone': BallAndStickRepresentationParameters,\n 'ball+stick': BallAndStickRepresentationParameters,\n 'base': BallAndStickRepresentationParameters,\n 'cartoon': CartoonRepresentationParameters,\n 'contact': ContactRepresentationParameters,\n 'dihedral': DihedralRepresentationParameters,\n 'dihedral-histogram': DihedralHistogramRepresentationParameters,\n 'distance': DistanceRepresentationParameters,\n 'dot': DotRepresentationParameters,\n 'helixorient': StructureRepresentationParameters,\n 'hyperball': HyperballRepresentationParameters,\n 'label': LabelRepresentationParameters,\n 'licorice': BallAndStickRepresentationParameters,\n 'line': LineRepresentationParameters,\n 'molecularsurface': MolecularSurfaceRepresentationParameters,\n 'point': PointRepresentationParameters,\n 'ribbon': RibbonRepresentationParameters,\n 'rocket': RocketRepresentationParameters,\n 'rope': CartoonRepresentationParameters,\n 'slice': SliceRepresentationParameters,\n 'spacefill': BallAndStickRepresentationParameters,\n 'surface': SurfaceRepresentationParameters,\n 'trace': TraceRepresentationParameters,\n 'tube': CartoonRepresentationParameters,\n 'unitcell': UnitcellRepresentationParameters,\n 'validation': StructureRepresentationParameters\n}\n\nexport const StructureComponentDefaultParameters = Object.assign({\n sele: '',\n defaultAssembly: ''\n}, ComponentDefaultParameters)\nexport type StructureComponentParameters = typeof StructureComponentDefaultParameters\n\nexport interface StructureComponentSignals extends ComponentSignals {\n trajectoryAdded: Signal // when a trajectory is added\n trajectoryRemoved: Signal // when a trajectory is removed\n defaultAssemblyChanged: Signal // on default assembly change\n}\n\n/**\n * Component wrapping a {@link Structure} object\n *\n * @example\n * // get a structure component by loading a structure file into the stage\n * stage.loadFile( \"rcsb://4opj\" ).then( function( structureComponent ){\n * structureComponent.addRepresentation( \"cartoon\" );\n * structureComponent.autoView();\n * } );\n */\nclass StructureComponent extends Component {\n readonly signals: StructureComponentSignals\n readonly parameters: StructureComponentParameters\n get defaultParameters () { return StructureComponentDefaultParameters }\n\n selection: Selection\n structureView: StructureView\n readonly trajList: TrajectoryElement[] = []\n\n pickBuffer: RingBuffer\n pickDict: SimpleDict\n lastPick?: number\n\n spacefillRepresentation: RepresentationElement\n distanceRepresentation: RepresentationElement\n angleRepresentation: RepresentationElement\n dihedralRepresentation: RepresentationElement\n\n measureRepresentations: RepresentationCollection\n\n constructor (stage: Stage, readonly structure: Structure, params: Partial = {}) {\n super(stage, structure, Object.assign({ name: structure.name }, params))\n\n this.signals = Object.assign(this.signals, {\n trajectoryAdded: new Signal(),\n trajectoryRemoved: new Signal(),\n defaultAssemblyChanged: new Signal()\n })\n\n this.initSelection(this.parameters.sele)\n\n //\n\n this.pickBuffer = createRingBuffer(4)\n this.pickDict = createSimpleDict()\n\n this.spacefillRepresentation = this.addRepresentation('spacefill', {\n sele: 'none',\n opacity: MeasurementDefaultParams.opacity,\n color: MeasurementDefaultParams.color,\n disablePicking: true,\n radiusType: 'data'\n }, true)\n\n this.distanceRepresentation = this.addRepresentation(\n 'distance', MeasurementDefaultParams, true\n )\n this.angleRepresentation = this.addRepresentation(\n 'angle', MeasurementDefaultParams, true\n )\n this.dihedralRepresentation = this.addRepresentation(\n 'dihedral', MeasurementDefaultParams, true\n )\n\n this.measureRepresentations = new RepresentationCollection([\n this.spacefillRepresentation,\n this.distanceRepresentation,\n this.angleRepresentation,\n this.dihedralRepresentation\n ])\n\n //\n\n this.setDefaultAssembly(this.parameters.defaultAssembly)\n\n this.structure.signals.refreshed.add(() => {\n this.updateRepresentations({ position: true })\n })\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'structure' }\n\n /**\n * Initialize selection\n * @private\n * @param {String} sele - selection string\n * @return {undefined}\n */\n initSelection (sele: string) {\n /**\n * Selection for {@link StructureComponent#structureView}\n * @private\n * @type {Selection}\n */\n this.selection = new Selection(sele)\n\n /**\n * View on {@link StructureComponent#structure}.\n * Change its selection via {@link StructureComponent#setSelection}.\n * @type {StructureView}\n */\n this.structureView = new StructureView(\n this.structure, this.selection\n )\n\n this.selection.signals.stringChanged.add(() => {\n this.structureView.setSelection(this.selection)\n\n this.rebuildRepresentations()\n this.rebuildTrajectories()\n })\n }\n\n /**\n * Set selection of {@link StructureComponent#structureView}\n * @param {String} string - selection string\n * @return {StructureComponent} this object\n */\n setSelection (string: string) {\n this.parameters.sele = string\n this.selection.setString(string)\n return this\n }\n\n /**\n * Set the default assembly\n * @param {String} value - assembly name\n * @return {undefined}\n */\n setDefaultAssembly (value:string) {\n // filter out non-exsisting assemblies\n if (this.structure.biomolDict[value] === undefined) value = ''\n // only set default assembly when changed\n if (this.parameters.defaultAssembly !== value) {\n const reprParams = { defaultAssembly: value }\n this.reprList.forEach(repr => repr.setParameters(reprParams))\n this.measureRepresentations.setParameters(reprParams)\n this.parameters.defaultAssembly = value\n this.signals.defaultAssemblyChanged.dispatch(value)\n }\n return this\n }\n\n /**\n * Rebuild all representations\n * @return {undefined}\n */\n rebuildRepresentations () {\n this.reprList.forEach((repr: RepresentationElement) => {\n repr.build()\n })\n this.measureRepresentations.build()\n }\n\n /**\n * Rebuild all trajectories\n * @return {undefined}\n */\n rebuildTrajectories () {\n this.trajList.forEach(trajComp => {\n trajComp.trajectory.setStructure(this.structureView)\n })\n }\n\n updateRepresentations (what: any) {\n super.updateRepresentations(what)\n this.measureRepresentations.update(what)\n }\n\n /**\n * Overrides {@link Component.updateRepresentationMatrices} \n * to also update matrix for measureRepresentations \n */\n updateRepresentationMatrices () {\n super.updateRepresentationMatrices()\n this.measureRepresentations.setParameters({ matrix: this.matrix })\n }\n\n addRepresentation (\n type: K,\n params: Partial|{defaultAssembly: string} = {},\n hidden = false\n ) {\n params.defaultAssembly = this.parameters.defaultAssembly\n\n const reprComp = this._addRepresentation(type, this.structureView, params, hidden)\n if (!hidden) {\n reprComp.signals.parametersChanged.add(() => this.measureUpdate())\n }\n return reprComp\n }\n\n /**\n * Add a new trajectory component to the structure\n */\n addTrajectory (trajPath = '', params: { [k: string]: any } = {}) {\n const traj = makeTrajectory(trajPath, this.structureView, params as TrajectoryParameters)\n\n const trajComp = new TrajectoryElement(this.stage, traj, params)\n this.trajList.push(trajComp)\n this.signals.trajectoryAdded.dispatch(trajComp)\n\n return trajComp\n }\n\n removeTrajectory (traj: TrajectoryElement) {\n const idx = this.trajList.indexOf(traj)\n if (idx !== -1) {\n this.trajList.splice(idx, 1)\n }\n\n traj.dispose()\n\n this.signals.trajectoryRemoved.dispatch(traj)\n }\n\n dispose () {\n // copy via .slice because side effects may change trajList\n this.trajList.slice().forEach(traj => traj.dispose())\n\n this.trajList.length = 0\n this.structure.dispose()\n this.measureRepresentations.dispose()\n\n super.dispose()\n }\n\n /**\n * Automatically center and zoom the component\n * @param {String|Integer} [sele] - selection string or duration if integer\n * @param {Integer} [duration] - duration of the animation, defaults to 0\n * @return {undefined}\n */\n autoView (sele?: string|number, duration?: number) {\n if (typeof sele === 'number') {\n duration = sele\n sele = ''\n }\n\n this.stage.animationControls.zoomMove(\n this.getCenter(sele),\n this.getZoom(sele),\n defaults(duration, 0)\n )\n }\n\n getBoxUntransformed (sele: string): Box3 {\n let bb\n\n if (sele) {\n bb = this.structureView.getBoundingBox(new Selection(sele))\n } else {\n bb = this.structureView.boundingBox\n }\n\n return bb\n }\n\n getCenterUntransformed (sele: string): Vector3 {\n if (sele && typeof sele === 'string') {\n return this.structure.atomCenter(new Selection(sele))\n } else {\n return this.structure.center\n }\n }\n\n superpose (component: StructureComponent, align: boolean, sele1: string, sele2: string) {\n superpose(\n this.structureView, component.structureView, align, sele1, sele2\n )\n\n this.updateRepresentations({ 'position': true })\n\n return this\n }\n\n getMaxRepresentationRadius (atomIndex: number) {\n let maxRadius = 0\n const atom = this.structure.getAtomProxy(atomIndex)\n this.eachRepresentation(reprElem => {\n if (reprElem.getVisibility()) {\n const repr: StructureRepresentation = reprElem.repr as any // TODO\n maxRadius = Math.max(repr.getAtomRadius(atom), maxRadius)\n }\n })\n return maxRadius\n }\n\n measurePick (atom: AtomProxy) {\n const pickCount = this.pickBuffer.count\n\n if (this.lastPick === atom.index && pickCount >= 1) {\n if (pickCount > 1) {\n const atomList = this.pickBuffer.data\n const atomListSorted = this.pickBuffer.data.sort()\n if (this.pickDict.has(atomListSorted)) {\n this.pickDict.del(atomListSorted)\n } else {\n this.pickDict.add(atomListSorted, atomList)\n }\n if (pickCount === 2) {\n this.distanceRepresentation.setParameters({\n atomPair: this.pickDict.values.filter(l => l.length === 2)\n })\n } else if (pickCount === 3) {\n this.angleRepresentation.setParameters({\n atomTriple: this.pickDict.values.filter(l => l.length === 3)\n })\n } else if (pickCount === 4) {\n this.dihedralRepresentation.setParameters({\n atomQuad: this.pickDict.values.filter(l => l.length === 4)\n })\n }\n }\n this.pickBuffer.clear()\n this.lastPick = undefined\n } else {\n if (!this.pickBuffer.has(atom.index)) {\n this.pickBuffer.push(atom.index)\n }\n this.lastPick = atom.index\n }\n\n this.measureUpdate()\n }\n\n measureClear () {\n this.pickBuffer.clear()\n this.lastPick = undefined\n this.spacefillRepresentation.setSelection('none')\n }\n\n measureBuild () {\n const md = this.measureData()\n this.distanceRepresentation.setParameters({ atomPair: md.distance })\n this.angleRepresentation.setParameters({ atomTriple: md.angle })\n this.dihedralRepresentation.setParameters({ atomQuad: md.dihedral })\n }\n\n measureUpdate () {\n const pickData = this.pickBuffer.data\n const radiusData: { [k: number]: number } = {}\n pickData.forEach(ai => {\n const r = Math.max(0.1, this.getMaxRepresentationRadius(ai))\n radiusData[ ai ] = r * (2.3 - smoothstep(0.1, 2, r))\n })\n this.spacefillRepresentation.setSelection(\n pickData.length ? ( '@' + pickData.join(',') ) : 'none'\n )\n if (pickData.length)\n this.spacefillRepresentation.setParameters({ radiusData })\n }\n\n measureData () {\n const pv = this.pickDict.values\n return {\n distance: pv.filter(l => l.length === 2),\n angle: pv.filter(l => l.length === 3),\n dihedral: pv.filter(l => l.length === 4)\n }\n }\n\n /**\n * Remove all measurements, optionally limit to distance, angle or dihedral\n */\n removeAllMeasurements (type?: MeasurementFlags) {\n const pd = this.pickDict\n const pv = pd.values\n const remove = function (len: number) {\n pv.filter(l => l.length === len).forEach(l => pd.del(l.slice().sort()))\n }\n if (!type || type & MeasurementFlags.Distance) remove(2)\n if (!type || type & MeasurementFlags.Angle) remove(3)\n if (!type || type & MeasurementFlags.Dihedral) remove(4)\n this.measureBuild()\n }\n\n /**\n * Remove a measurement given as a pair, triple, quad of atom indices\n */\n removeMeasurement (atomList: number[]) {\n this.pickDict.del(atomList.slice().sort())\n this.measureBuild()\n }\n\n /**\n * Add a measurement given as a pair, triple, quad of atom indices\n */\n addMeasurement (atomList: number[]) {\n if (atomList.length < 2 || atomList.length > 4) return\n const atomListSorted = atomList.slice().sort()\n if (!this.pickDict.has(atomListSorted)) {\n this.pickDict.add(atomListSorted, atomList)\n }\n this.measureBuild()\n }\n}\n\nexport const enum MeasurementFlags {\n Distance = 0x1,\n Angle = 0x2,\n Dihedral = 0x4\n}\n\nComponentRegistry.add('structure', StructureComponent)\nComponentRegistry.add('structureview', StructureComponent)\n\nexport default StructureComponent\n","/**\n * @file Trajectory Utils\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from '../structure/structure'\nimport Frames from './frames'\nimport { TrajectoryParameters } from './trajectory'\nimport FramesTrajectory from './frames-trajectory'\nimport StructureTrajectory from './structure-trajectory'\nimport RemoteTrajectory from './remote-trajectory'\nimport CallbackTrajectory from './callback-trajectory'\n\nexport function makeTrajectory (trajSrc: string|Frames, structure: Structure, params: TrajectoryParameters) {\n let traj\n\n if (trajSrc && trajSrc instanceof Frames) {\n traj = new FramesTrajectory(trajSrc, structure, params)\n } else if (!trajSrc && structure.frames) {\n traj = new StructureTrajectory(trajSrc, structure, params)\n } else if (trajSrc && typeof trajSrc === 'function') {\n traj = new CallbackTrajectory(trajSrc, structure, params)\n } else {\n traj = new RemoteTrajectory(trajSrc, structure, params)\n }\n\n return traj\n}\n\n","/**\n * @file Surface Component\n * @author Alexander Rose \n * @private\n */\n\nimport { ComponentRegistry } from '../globals'\nimport Component, { ComponentParameters } from './component'\nimport Stage from '../stage/stage'\nimport Surface from '../surface/surface'\nimport { Vector3, Box3 } from 'three';\nimport RepresentationElement from './representation-element';\n\nexport type SurfaceRepresentationType = 'surface'|'dot'\n\n/**\n * Component wrapping a {@link Surface} object\n *\n * @example\n * // get a surface component by loading a surface file into the stage\n * stage.loadFile( \"url/for/surface\" ).then( function( surfaceComponent ){\n * surfaceComponent.addRepresentation( \"surface\" );\n * surfaceComponent.autoView();\n * } );\n */\nclass SurfaceComponent extends Component {\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {Surface} surface - surface object to wrap\n * @param {ComponentParameters} params - component parameters\n */\n constructor (stage: Stage, readonly surface: Surface, params: Partial = {}) {\n super(stage, surface, Object.assign({ name: surface.name }, params))\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'surface' }\n\n /**\n * Add a new surface representation to the component\n * @param {String} type - the name of the representation, one of:\n * surface, dot.\n * @param {SurfaceRepresentationParameters} params - representation parameters\n * @return {RepresentationComponent} the created representation wrapped into\n * a representation component object\n */\n addRepresentation (type: SurfaceRepresentationType, params: { [k: string]: any } = {}): RepresentationElement {\n return this._addRepresentation(type, this.surface, params)\n }\n\n getBoxUntransformed (): Box3 {\n return this.surface.boundingBox\n }\n\n getCenterUntransformed (): Vector3 {\n return this.surface.center\n }\n\n dispose () {\n this.surface.dispose()\n super.dispose()\n }\n}\n\nComponentRegistry.add('surface', SurfaceComponent)\n\nexport default SurfaceComponent\n","/**\n * @file Volume Component\n * @author Alexander Rose \n * @private\n */\n\nimport { ComponentRegistry } from '../globals'\nimport Component, { ComponentParameters } from './component'\nimport Stage from '../stage/stage'\nimport Volume from '../surface/volume'\nimport { Box3, Vector3 } from 'three';\nimport RepresentationElement from './representation-element';\n\nexport type VolumeRepresentationType = 'surface'|'slice'|'dot'\n\n/**\n * Component wrapping a {@link Volume} object\n *\n * @example\n * // get a volume component by loading a volume file into the stage\n * stage.loadFile( \"url/for/volume\" ).then(function(volumeComponent){\n * volumeComponent.addRepresentation('surface');\n * volumeComponent.autoView();\n * });\n */\nclass VolumeComponent extends Component {\n /**\n * @param {Stage} stage - stage object the component belongs to\n * @param {Volume} volume - volume object to wrap\n * @param {ComponentParameters} params - component parameters\n */\n constructor (stage: Stage, readonly volume: Volume, params: Partial = {}) {\n super(stage, volume, Object.assign({ name: volume.name }, params))\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'volume' }\n\n /**\n * Add a new volume representation to the component\n */\n addRepresentation (type: VolumeRepresentationType, params: { [k: string]: any } = {}): RepresentationElement {\n return this._addRepresentation(type, this.volume, params)\n }\n\n getBoxUntransformed (): Box3 {\n return this.volume.boundingBox\n }\n\n getCenterUntransformed (): Vector3 {\n return this.volume.center\n }\n\n dispose () {\n this.volume.dispose()\n\n super.dispose()\n }\n}\n\nComponentRegistry.add('volume', VolumeComponent)\n\nexport default VolumeComponent\n","/**\n * @file Component Collection\n * @author Alexander Rose \n * @private\n */\n\nimport Component from './component'\nimport Collection from './collection'\n\nclass ComponentCollection extends Collection {\n addRepresentation (name: string, params: any) {\n \treturn this.forEach((comp) => comp.addRepresentation(name, params))\n }\n\n autoView (duration: number) {\n return this.forEach((comp) => comp.autoView(duration))\n }\n}\n\nexport default ComponentCollection\n","/**\n * @file Stage\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Box3 } from 'three'\nimport { Signal } from 'signals'\n\nimport {\n Debug, Log, Mobile, ComponentRegistry, ParserRegistry\n} from '../globals'\nimport { defaults, createParams, updateParams } from '../utils'\nimport { degToRad, clamp, pclamp } from '../math/math-utils'\nimport Counter from '../utils/counter'\nimport Viewer from '../viewer/viewer'\nimport { ImageParameters } from '../viewer/viewer-utils'\nimport MouseObserver from './mouse-observer'\n\nimport TrackballControls from '../controls/trackball-controls'\nimport PickingControls from '../controls/picking-controls'\nimport ViewerControls from '../controls/viewer-controls'\nimport AnimationControls from '../controls/animation-controls'\nimport MouseControls, { MouseControlPreset } from '../controls/mouse-controls'\nimport KeyControls from '../controls/key-controls'\n\nimport PickingBehavior from './picking-behavior'\nimport MouseBehavior from './mouse-behavior'\nimport AnimationBehavior from './animation-behavior'\nimport KeyBehavior from './key-behavior'\n\nimport Component, { ComponentParameters } from '../component/component'\nimport RepresentationElement from '../component/representation-element'\nimport StructureComponent from '../component/structure-component'\nimport SurfaceComponent from '../component/surface-component'\nimport VolumeComponent from '../component/volume-component'\nimport ComponentCollection from '../component/component-collection'\nimport RepresentationCollection from '../component/representation-collection'\nimport { autoLoad, getFileInfo, LoaderParameters } from '../loader/loader-utils'\nimport { ParserParams } from '../loader/parser-loader'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Animation from '../animation/animation'\nimport Selection from '../selection/selection'\n\nimport Structure from '../structure/structure'\nimport Surface from '../surface/surface'\nimport Volume from '../surface/volume'\nimport Shape from '../geometry/shape'\nimport Script from '../script'\n\nfunction matchName (name: string|RegExp, object: { name: string }) {\n if (name instanceof RegExp) {\n return object.name.match(name) !== null\n } else {\n return object.name === name\n }\n}\n\nconst tmpZoomVector = new Vector3()\n\ndeclare global {\n interface Document {\n mozFullScreen: boolean\n mozFullScreenEnabled: boolean\n mozFullScreenElement: Element\n mozCancelFullScreen(): void\n\n msFullscreenEnabled: boolean\n msFullscreenElement: Element\n msExitFullscreen(): void\n }\n\n interface Element {\n mozRequestFullScreen(): void\n msRequestFullscreen(): void\n }\n}\n\n/**\n * Stage parameter object.\n * @typedef {Object} StageParameters - stage parameters\n * @property {Color} backgroundColor - background color\n * @property {Integer} sampleLevel - sampling level for antialiasing, between -1 and 5;\n * -1: no sampling, 0: only sampling when not moving\n * @property {Boolean} workerDefault - default value for useWorker parameter of representations\n * @property {Float} rotateSpeed - camera-controls rotation speed, between 0 and 10\n * @property {Float} zoomSpeed - camera-controls zoom speed, between 0 and 10\n * @property {Float} panSpeed - camera-controls pan speed, between 0 and 10\n * @property {Float} clipNear - position of camera near/front clipping plane\n * in percent of scene bounding box\n * @property {Float} clipFar - position of camera far/back clipping plane\n * in percent of scene bounding box\n * @property {Float} clipDist - camera clipping distance in Angstrom\n * @property {String} clipMode - how to interpret clipNear/Far and fogNear/Far values: \"scene\" for scene-relative, \"camera\" for camera-relative\n * @property {String} clipScale - \"relative\" or \"absolute\": interpret clipNear/Far and fogNear/Far as percentage of bounding box or absolute Angstroms (ignored when clipMode==camera)\n * @property {Float} fogNear - position of the start of the fog effect\n * in percent of scene bounding box\n * @property {Float} fogFar - position where the fog is in full effect\n * in percent of scene bounding box\n * @property {String} cameraType - type of camera, either 'persepective' or 'orthographic'\n * @property {Float} cameraFov - perspective camera field of view in degree, between 15 and 120\n * @property {Float} cameraEyeSep - stereo camera eye seperation\n * @property {Color} lightColor - point light color\n * @property {Float} lightIntensity - point light intensity\n * @property {Color} ambientColor - ambient light color\n * @property {Float} ambientIntensity - ambient light intensity\n * @property {Integer} hoverTimeout - timeout for hovering\n */\n\nexport interface StageSignals {\n parametersChanged: Signal\n fullscreenChanged: Signal\n componentAdded: Signal\n componentRemoved: Signal\n clicked: Signal\n hovered: Signal\n}\n\nexport type RenderQualityType = 'auto'|'low'|'medium'|'high'\n\nexport const StageDefaultParameters = {\n impostor: true,\n quality: 'medium' as RenderQualityType,\n workerDefault: true,\n sampleLevel: 0,\n backgroundColor: 'black' as string|number,\n rotateSpeed: 2.0,\n zoomSpeed: 1.2,\n panSpeed: 1.0,\n clipNear: 0,\n clipFar: 100,\n clipDist: 10,\n clipMode: 'scene',\n clipScale: 'relative',\n fogNear: 50,\n fogFar: 100,\n cameraFov: 40,\n cameraEyeSep: 0.3,\n cameraType: 'perspective' as 'perspective'|'orthographic'|'stereo',\n lightColor: 0xdddddd as string|number,\n lightIntensity: 1.0,\n ambientColor: 0xdddddd as string|number,\n ambientIntensity: 0.2,\n hoverTimeout: 0,\n tooltip: true,\n mousePreset: 'default' as MouseControlPreset\n}\nexport type StageParameters = typeof StageDefaultParameters\n\nexport interface StageLoadFileParams extends LoaderParameters {\n defaultRepresentation: boolean,\n assembly: string\n}\n\n/**\n * Stage class, central for creating molecular scenes with NGL.\n *\n * @example\n * var stage = new Stage( \"elementId\", { backgroundColor: \"white\" } );\n */\nclass Stage {\n signals: StageSignals = {\n parametersChanged: new Signal(),\n fullscreenChanged: new Signal(),\n componentAdded: new Signal(),\n componentRemoved: new Signal(),\n clicked: new Signal(),\n hovered: new Signal()\n }\n parameters: StageParameters\n\n /**\n * Counter that keeps track of various potentially long-running tasks,\n * including file loading and surface calculation.\n */\n tasks = new Counter()\n compList: Component[] = []\n defaultFileParams = {}\n logList: string[] = []\n\n transformComponent?: Component\n transformAtom?: AtomProxy\n\n viewer: Viewer\n tooltip: HTMLElement\n lastFullscreenElement: HTMLElement\n\n mouseObserver: MouseObserver\n viewerControls: ViewerControls\n trackballControls: TrackballControls\n pickingControls: PickingControls\n animationControls: AnimationControls\n mouseControls: MouseControls\n keyControls: KeyControls\n\n pickingBehavior: PickingBehavior\n mouseBehavior: MouseBehavior\n animationBehavior: AnimationBehavior\n keyBehavior: KeyBehavior\n\n spinAnimation: Animation\n rockAnimation: Animation\n\n constructor (idOrElement: string|HTMLElement, params: Partial = {}) {\n this.viewer = new Viewer(idOrElement)\n if (!this.viewer.renderer) return\n\n this.tooltip = document.createElement('div')\n Object.assign(this.tooltip.style, {\n display: 'none',\n position: 'fixed',\n zIndex: '1000000',\n pointerEvents: 'none',\n backgroundColor: 'rgba( 0, 0, 0, 0.6 )',\n color: 'lightgrey',\n padding: '8px',\n fontFamily: 'sans-serif'\n })\n this.viewer.container.appendChild(this.tooltip)\n\n this.mouseObserver = new MouseObserver(this.viewer.renderer.domElement)\n this.viewerControls = new ViewerControls(this)\n this.trackballControls = new TrackballControls(this)\n this.pickingControls = new PickingControls(this)\n this.animationControls = new AnimationControls(this)\n this.mouseControls = new MouseControls(this)\n this.keyControls = new KeyControls(this)\n\n this.pickingBehavior = new PickingBehavior(this)\n this.mouseBehavior = new MouseBehavior(this)\n this.animationBehavior = new AnimationBehavior(this)\n this.keyBehavior = new KeyBehavior(this)\n\n this.spinAnimation = this.animationControls.spin([ 0, 1, 0 ], 0.005)\n this.spinAnimation.pause(true)\n this.rockAnimation = this.animationControls.rock([ 0, 1, 0 ], 0.005)\n this.rockAnimation.pause(true)\n\n // must come after the viewer has been instantiated\n this.parameters = createParams(params, StageDefaultParameters)\n this.setParameters(this.parameters)\n\n this.viewer.animate()\n }\n\n /**\n * Set stage parameters\n */\n setParameters (params: Partial = {}) {\n updateParams(this.parameters, params)\n\n const p = params\n const tp = this.parameters\n\n const viewer = this.viewer\n const controls = this.trackballControls\n\n // apply parameters\n if (p.quality !== undefined) this.setQuality(tp.quality)\n if (p.impostor !== undefined) this.setImpostor(tp.impostor)\n if (p.rotateSpeed !== undefined) controls.rotateSpeed = tp.rotateSpeed\n if (p.zoomSpeed !== undefined) controls.zoomSpeed = tp.zoomSpeed\n if (p.panSpeed !== undefined) controls.panSpeed = tp.panSpeed\n if (p.mousePreset !== undefined) this.mouseControls.preset(tp.mousePreset)\n this.mouseObserver.setParameters({ hoverTimeout: tp.hoverTimeout })\n viewer.setClip(tp.clipNear, tp.clipFar, tp.clipDist, tp.clipMode, tp.clipScale)\n viewer.setFog(undefined, tp.fogNear, tp.fogFar)\n viewer.setCamera(tp.cameraType, tp.cameraFov, tp.cameraEyeSep)\n viewer.setSampling(tp.sampleLevel)\n viewer.setBackground(tp.backgroundColor)\n viewer.setLight(tp.lightColor, tp.lightIntensity, tp.ambientColor, tp.ambientIntensity)\n\n this.signals.parametersChanged.dispatch(this.getParameters())\n\n return this\n }\n\n log (msg: string) {\n console.log('STAGE LOG', msg)\n this.logList.push(msg)\n }\n\n /**\n * Get stage parameters\n */\n getParameters () {\n return Object.assign({}, this.parameters)\n }\n\n /**\n * Create default representations for the given component\n * @param {StructureComponent|SurfaceComponent} object - component to create the representations for\n * @return {undefined}\n */\n defaultFileRepresentation (component: Component) {\n if (component instanceof StructureComponent) {\n component.setSelection('/0')\n\n let atomCount, residueCount, instanceCount\n const structure = component.structure\n\n if (structure.biomolDict.BU1) {\n const assembly = structure.biomolDict.BU1\n atomCount = assembly.getAtomCount(structure)\n residueCount = assembly.getResidueCount(structure)\n instanceCount = assembly.getInstanceCount()\n component.setDefaultAssembly('BU1')\n } else {\n atomCount = structure.getModelProxy(0).atomCount\n residueCount = structure.getModelProxy(0).residueCount\n instanceCount = 1\n }\n\n let sizeScore = atomCount\n\n if (Mobile) {\n sizeScore *= 4\n }\n\n const backboneOnly = structure.atomStore.count / structure.residueStore.count < 2\n if (backboneOnly) {\n sizeScore *= 10\n }\n\n let colorScheme = 'chainname'\n let colorScale = 'RdYlBu'\n let colorReverse = false\n if (structure.getChainnameCount(new Selection('polymer and /0')) === 1) {\n colorScheme = 'residueindex'\n colorScale = 'Spectral'\n colorReverse = true\n }\n\n if (Debug) console.log(sizeScore, atomCount, instanceCount, backboneOnly)\n\n if (residueCount / instanceCount < 4) {\n component.addRepresentation('ball+stick', {\n colorScheme: 'element',\n radiusScale: 2.0,\n aspectRatio: 1.5,\n bondScale: 0.3,\n bondSpacing: 0.75,\n quality: 'auto'\n })\n } else if ((instanceCount > 5 && sizeScore > 15000) || sizeScore > 700000) {\n let scaleFactor = (\n Math.min(\n 2.0,\n Math.max(\n 0.1,\n 6000 / (sizeScore / instanceCount)\n )\n )\n )\n if (backboneOnly) scaleFactor = Math.min(scaleFactor, 0.5)\n\n component.addRepresentation('surface', {\n colorScheme, colorScale, colorReverse,\n sele: 'polymer',\n surfaceType: 'av',\n probeRadius: 1.4,\n scaleFactor: scaleFactor,\n useWorker: false\n })\n } else if (sizeScore > 250000) {\n component.addRepresentation('backbone', {\n colorScheme, colorScale, colorReverse,\n lineOnly: true\n })\n } else if (sizeScore > 100000) {\n component.addRepresentation('backbone', {\n colorScheme, colorScale, colorReverse,\n quality: 'low',\n disableImpostor: true,\n radiusScale: 2.0\n })\n } else if (sizeScore > 80000) {\n component.addRepresentation('backbone', {\n colorScheme, colorScale, colorReverse,\n radiusScale: 2.0\n })\n } else {\n component.addRepresentation('cartoon', {\n colorScheme, colorScale, colorReverse,\n radiusScale: 0.7,\n aspectRatio: 5,\n quality: 'auto'\n })\n if (sizeScore < 50000) {\n component.addRepresentation('base', {\n colorScheme, colorScale, colorReverse,\n quality: 'auto'\n })\n }\n component.addRepresentation('ball+stick', {\n sele: 'ligand',\n colorScheme: 'element',\n radiusScale: 2.0,\n aspectRatio: 1.5,\n bondScale: 0.3,\n bondSpacing: 0.75,\n quality: 'auto'\n })\n }\n\n // add frames as trajectory\n if (component.structure.frames.length) {\n component.addTrajectory()\n }\n } else if (component instanceof SurfaceComponent) {\n component.addRepresentation('surface')\n } else if (component instanceof VolumeComponent) {\n component.addRepresentation('surface')\n }\n\n this.tasks.onZeroOnce(this.autoView, this)\n }\n\n /**\n * Load a file onto the stage\n *\n * @example\n * // load from URL\n * stage.loadFile( \"http://files.rcsb.org/download/5IOS.cif\" );\n *\n * @example\n * // load binary data in CCP4 format via a Blob\n * var binaryBlob = new Blob( [ ccp4Data ], { type: 'application/octet-binary'} );\n * stage.loadFile( binaryBlob, { ext: \"ccp4\" } );\n *\n * @example\n * // load string data in PDB format via a Blob\n * var stringBlob = new Blob( [ pdbData ], { type: 'text/plain'} );\n * stage.loadFile( stringBlob, { ext: \"pdb\" } );\n *\n * @example\n * // load a File object\n * stage.loadFile( file );\n *\n * @example\n * // load from URL and add a 'ball+stick' representation with double/triple bonds\n * stage.loadFile( \"http://files.rcsb.org/download/1crn.cif\" ).then( function( comp ){\n * comp.addRepresentation( \"ball+stick\", { multipleBond: true } );\n * } );\n *\n * @param {String|File|Blob} path - either a URL or an object containing the file data\n * @param {LoaderParameters} params - loading parameters\n * @param {Boolean} params.asTrajectory - load multi-model structures as a trajectory\n * @return {Promise} A Promise object that resolves to a {@link StructureComponent},\n * a {@link SurfaceComponent} or a {@link ScriptComponent} object,\n * depending on the type of the loaded file.\n */\n loadFile (path: string|File|Blob, params: Partial = {}) {\n const p = Object.assign({}, this.defaultFileParams, params)\n const name = getFileInfo(path).name\n\n this.tasks.increment()\n this.log(`loading file '${name}'`)\n\n const onLoadFn = (object: Structure|Surface|Volume) => {\n this.log(`loaded '${name}'`)\n\n const component = this.addComponentFromObject(object, p)\n if (p.defaultRepresentation) {\n this.defaultFileRepresentation(component as Component)\n }\n this.tasks.decrement()\n\n return component\n }\n\n const onErrorFn = (e: Error|string) => {\n this.tasks.decrement()\n const errorMsg = `error loading file: '${e}'`\n this.log(errorMsg)\n throw errorMsg // throw so it can be catched\n }\n\n const ext = defaults(p.ext, getFileInfo(path).ext)\n let promise: Promise\n\n if (ParserRegistry.isTrajectory(ext)) {\n promise = Promise.reject(\n new Error(`loadFile: ext '${ext}' is a trajectory and must be loaded into a structure component`)\n )\n } else {\n promise = autoLoad(path, p)\n }\n\n return promise.then(onLoadFn, onErrorFn)\n }\n\n loadScript (path: string|File|Blob) {\n const name = getFileInfo(path).name\n\n this.log(`loading script '${name}'`)\n\n return autoLoad(path).then(\n (script: Script) => {\n this.tasks.increment()\n this.log(`running script '${name}'`)\n script.run(this).then(() => {\n this.tasks.decrement()\n this.log(`finished script '${name}'`)\n })\n this.log(`called script '${name}'`)\n },\n (error: Error|string) => {\n this.tasks.decrement()\n const errorMsg = `errored script '${name}' \"${error}\"`\n this.log(errorMsg)\n throw errorMsg // throw so it can be catched\n }\n )\n }\n\n /**\n * Add the given component to the stage\n * @param {Component} component - the component to add\n * @return {undefined}\n */\n addComponent (component: Component) {\n if (!component) {\n Log.warn('Stage.addComponent: no component given')\n return\n }\n\n this.compList.push(component)\n this.signals.componentAdded.dispatch(component)\n }\n\n /**\n * Create a component from the given object and add to the stage\n */\n addComponentFromObject (object: Structure|Surface|Volume|Shape, params: Partial = {}): void|Component {\n const CompClass = ComponentRegistry.get(object.type)\n\n if (CompClass) {\n const component = new CompClass(this, object, params)\n this.addComponent(component)\n return component\n }\n\n Log.warn('no component for object type', object.type)\n }\n\n /**\n * Remove the given component\n * @param {Component} component - the component to remove\n * @return {undefined}\n */\n removeComponent (component: Component) {\n const idx = this.compList.indexOf(component)\n if (idx !== -1) {\n this.compList.splice(idx, 1)\n component.dispose()\n this.signals.componentRemoved.dispatch(component)\n }\n }\n\n /**\n * Remove all components from the stage\n */\n removeAllComponents () {\n this.compList.slice().forEach(o => this.removeComponent(o))\n }\n\n /**\n * Handle any size-changes of the container element\n * @return {undefined}\n */\n handleResize () {\n this.viewer.handleResize()\n }\n\n /**\n * Set width and height\n * @param {String} width - CSS width value\n * @param {String} height - CSS height value\n * @return {undefined}\n */\n setSize (width: string, height: string) {\n const container = this.viewer.container\n\n if (container !== document.body) {\n if (width !== undefined) container.style.width = width\n if (height !== undefined) container.style.height = height\n this.handleResize()\n }\n }\n\n /**\n * Toggle fullscreen\n * @param {Element} [element] - document element to put into fullscreen,\n * defaults to the viewer container\n * @return {undefined}\n */\n toggleFullscreen (element: HTMLElement) {\n if (!document.fullscreenEnabled && !document.mozFullScreenEnabled &&\n !(document as any).webkitFullscreenEnabled && !document.msFullscreenEnabled\n ) {\n Log.log('fullscreen mode (currently) not possible')\n return\n }\n\n const self = this\n element = element || this.viewer.container\n this.lastFullscreenElement = element\n\n //\n\n function getFullscreenElement () {\n return document.fullscreenElement || document.mozFullScreenElement ||\n (document as any).webkitFullscreenElement || document.msFullscreenElement\n }\n\n function resizeElement () {\n if (!getFullscreenElement() && self.lastFullscreenElement) {\n const element = self.lastFullscreenElement\n element.style.width = element.dataset.normalWidth || ''\n element.style.height = element.dataset.normalHeight || ''\n\n document.removeEventListener('fullscreenchange', resizeElement)\n document.removeEventListener('mozfullscreenchange', resizeElement)\n document.removeEventListener('webkitfullscreenchange', resizeElement)\n document.removeEventListener('MSFullscreenChange', resizeElement)\n\n self.handleResize()\n self.signals.fullscreenChanged.dispatch(false)\n }\n }\n\n //\n\n if (!getFullscreenElement()) {\n element.dataset.normalWidth = element.style.width || ''\n element.dataset.normalHeight = element.style.height || ''\n element.style.width = window.screen.width + 'px'\n element.style.height = window.screen.height + 'px'\n\n if (element.requestFullscreen) {\n element.requestFullscreen()\n } else if (element.msRequestFullscreen) {\n element.msRequestFullscreen()\n } else if (element.mozRequestFullScreen) {\n element.mozRequestFullScreen()\n } else if ((element as any).webkitRequestFullscreen) {\n (element as any).webkitRequestFullscreen()\n }\n\n document.addEventListener('fullscreenchange', resizeElement)\n document.addEventListener('mozfullscreenchange', resizeElement)\n document.addEventListener('webkitfullscreenchange', resizeElement)\n document.addEventListener('MSFullscreenChange', resizeElement)\n\n this.handleResize()\n this.signals.fullscreenChanged.dispatch(true)\n\n // workaround for Safari\n setTimeout(function () { self.handleResize() }, 100)\n } else {\n if (document.exitFullscreen) {\n document.exitFullscreen()\n } else if (document.msExitFullscreen) {\n document.msExitFullscreen()\n } else if (document.mozCancelFullScreen) {\n document.mozCancelFullScreen()\n } else if ((document as any).webkitExitFullscreen) {\n (document as any).webkitExitFullscreen()\n }\n }\n }\n\n /**\n * Set spin\n * @param {Boolean} flag - if true start rocking and stop spinning\n * @return {undefined}\n */\n setSpin (flag: boolean) {\n if (flag) {\n this.spinAnimation.resume(true)\n this.rockAnimation.pause(true)\n } else {\n this.spinAnimation.pause(true)\n }\n }\n\n /**\n * Set rock\n * @param {Boolean} flag - if true start rocking and stop spinning\n * @return {undefined}\n */\n setRock (flag: boolean) {\n if (flag) {\n this.rockAnimation.resume(true)\n this.spinAnimation.pause(true)\n } else {\n this.rockAnimation.pause(true)\n }\n }\n\n /**\n * Toggle spin\n * @return {undefined}\n */\n toggleSpin () {\n this.setSpin(this.spinAnimation.paused)\n }\n\n /**\n * Toggle rock\n * @return {undefined}\n */\n toggleRock () {\n this.setRock(this.rockAnimation.paused)\n }\n\n /**\n * Get the current focus from the current clipNear value expressed\n * as 0 (full view) to 100 (completely clipped)\n * Negative values may be returned in some cases.\n *\n * In 'camera' clipMode focus isn't applicable, this method returns 0.0\n *\n * @return {number} focus\n */\n getFocus () : number {\n const p = this.parameters\n if (p.clipMode !== 'scene') return 0.0\n\n let clipNear = p.clipNear\n if (p.clipScale === 'absolute') {\n clipNear = this.viewer.absoluteToRelative(clipNear)\n }\n return clipNear * 2\n }\n\n\n /**\n * Set the focus, a value of 0 sets clipping planes to show full scene,\n * while a value of 100 will compltely clip the scene.\n *\n * @param {number} value focus\n */\n setFocus (value: number) {\n if (this.parameters.clipMode !== 'scene') return\n\n let clipNear\n let clipFar\n let fogNear\n let fogFar\n\n if (this.parameters.clipScale === 'relative') {\n clipNear = clamp(value / 2.0, 0.0, 49.9)\n clipFar = 100 - clipNear\n fogNear = 50\n fogFar = pclamp(2 * clipFar - 50)\n\n } else {\n clipNear = this.viewer.relativeToAbsolute(value / 2.0)\n clipFar = clipNear\n fogNear = 0\n fogFar = 2 * clipFar\n }\n\n this.setParameters({ clipNear, clipFar, fogNear, fogFar })\n }\n\n getZoomForBox (boundingBox: Box3) {\n const bbSize = boundingBox.getSize(tmpZoomVector)\n const maxSize = Math.max(bbSize.x, bbSize.y, bbSize.z)\n const minSize = Math.min(bbSize.x, bbSize.y, bbSize.z)\n let distance = maxSize + Math.sqrt(minSize)\n\n const fov = degToRad(this.viewer.perspectiveCamera.fov)\n const width = this.viewer.width\n const height = this.viewer.height\n const aspect = width / height\n const aspectFactor = (height < width ? 1 : aspect)\n\n distance = Math.abs(\n ((distance * 0.5) / aspectFactor) / Math.sin(fov / 2)\n )\n distance += this.parameters.clipDist\n return -distance\n }\n\n getBox () {\n return this.viewer.boundingBox\n }\n\n getZoom () {\n return this.getZoomForBox(this.getBox())\n }\n\n getCenter (optionalTarget?: Vector3) {\n return this.getBox().getCenter(optionalTarget || new Vector3())\n }\n\n /**\n * Add a zoom and a move animation with automatic targets\n * @param {Integer} duration - animation time in milliseconds\n * @return {undefined}\n */\n autoView (duration?: number) {\n this.animationControls.zoomMove(\n this.getCenter(),\n this.getZoom(),\n defaults(duration, 0)\n )\n }\n\n /**\n * Make image from what is shown in a viewer canvas\n */\n makeImage (params: Partial = {}) {\n return new Promise((resolve, reject) => {\n this.tasks.onZeroOnce(() => {\n this.tasks.increment()\n this.viewer.makeImage(params).then(blob => {\n this.tasks.decrement()\n resolve(blob)\n }).catch(e => {\n this.tasks.decrement()\n reject(e)\n })\n })\n })\n }\n\n setImpostor (value: boolean) {\n this.parameters.impostor = value\n\n const types = [\n 'spacefill', 'ball+stick', 'licorice', 'hyperball',\n 'backbone', 'rocket', 'helixorient', 'contact', 'distance',\n 'dot'\n ]\n\n this.eachRepresentation(function (reprElem) {\n if (!types.includes(reprElem.getType())) return\n\n const p = reprElem.getParameters() as any // TODO\n p.disableImpostor = !value\n reprElem.build(p)\n })\n }\n\n setQuality (value: RenderQualityType) {\n this.parameters.quality = value\n\n const types = [\n 'tube', 'cartoon', 'ribbon', 'trace', 'rope'\n ]\n\n const impostorTypes = [\n 'spacefill', 'ball+stick', 'licorice', 'hyperball',\n 'backbone', 'rocket', 'helixorient', 'contact', 'distance',\n 'dot'\n ]\n\n this.eachRepresentation(function (repr) {\n const p = repr.getParameters() as any // TODO\n\n if (!types.includes(repr.getType())) {\n if (!impostorTypes.includes(repr.getType())) return\n\n if (!p.disableImpostor) {\n (repr.repr as any).quality = value // TODO\n return\n }\n }\n\n p.quality = value\n repr.build(p)\n })\n }\n\n /**\n * Iterator over each component and executing the callback\n */\n eachComponent (callback: (comp: Component) => void, type?: string) {\n this.compList.slice().forEach(comp => {\n if (type === undefined || type === comp.type) callback(comp)\n })\n }\n\n /**\n * Iterator over each representation and executing the callback\n */\n eachRepresentation (callback: (reprElem: RepresentationElement, comp: Component) => void, type?: string) {\n this.eachComponent(comp => {\n comp.reprList.slice().forEach(reprElem => {\n if (type === undefined || type === reprElem.getType()) callback(reprElem, comp)\n })\n })\n }\n\n /**\n * Get collection of components by name\n */\n getComponentsByName (name: string|RegExp) {\n const compList: Component[] = []\n\n this.eachComponent(comp => {\n if (name === undefined || matchName(name, comp)) compList.push(comp)\n })\n\n return new ComponentCollection(compList)\n }\n\n /**\n * Get collection of components by object\n */\n getComponentsByObject (object: Structure|Surface|Volume|Shape) {\n const compList: Component[] = []\n\n this.eachComponent(comp => {\n if (comp.object === object) compList.push(comp)\n })\n\n return new ComponentCollection(compList)\n }\n\n /**\n * Get collection of representations by name\n */\n getRepresentationsByName (name: string|RegExp) {\n const reprList: RepresentationElement[] = []\n\n this.eachRepresentation((repr, comp) => {\n if (name === undefined || matchName(name, repr)) reprList.push(repr)\n })\n\n return new RepresentationCollection(reprList)\n }\n\n measureClear () {\n this.eachComponent((sc: StructureComponent) => sc.measureClear(), 'structure')\n }\n\n measureUpdate () {\n this.eachComponent((sc: StructureComponent) => sc.measureUpdate(), 'structure')\n }\n\n /**\n * Cleanup when disposing of a stage object\n */\n dispose () {\n this.tasks.dispose()\n this.viewer.dispose()\n this.mouseObserver.dispose()\n }\n}\n\nexport default Stage\n","/**\n * @file Shape Component\n * @author Alexander Rose \n * @private\n */\n\nimport { ComponentRegistry } from '../globals'\nimport Component, { ComponentParameters } from './component'\nimport Stage from '../stage/stage'\nimport Shape from '../geometry/shape'\nimport { Vector3, Box3 } from 'three';\nimport RepresentationElement from './representation-element';\n\nexport type ShapeRepresentationType = 'buffer'\n\n/**\n * Component wrapping a {@link Shape} object\n *\n * @example\n * // get a shape component by adding a shape object to the stage\n * var shape = new NGL.Shape( \"shape\" );\n * shape.addSphere( [ 0, 0, 0 ], [ 1, 0, 0 ], 1.5 );\n * var shapeComponent = stage.addComponentFromObject( shape );\n * shapeComponent.addRepresentation( \"buffer\" );\n */\nclass ShapeComponent extends Component {\n constructor (stage: Stage, readonly shape: Shape, params: Partial = {}) {\n super(stage, shape, Object.assign({ name: shape.name }, params))\n }\n\n /**\n * Component type\n * @type {String}\n */\n get type () { return 'shape' }\n\n /**\n * Add a new shape representation to the component\n * @param {String} type - the name of the representation, one of:\n * buffer.\n * @param {BufferRepresentationParameters} params - representation parameters\n * @return {RepresentationComponent} the created representation wrapped into\n * a representation component object\n */\n addRepresentation (type: ShapeRepresentationType, params: { [k: string]: any } = {}): RepresentationElement {\n return this._addRepresentation(type, this.shape, params)\n }\n\n getBoxUntransformed (): Box3 {\n return this.shape.boundingBox\n }\n\n getCenterUntransformed (): Vector3 {\n return this.shape.center\n }\n\n dispose () {\n this.shape.dispose()\n super.dispose()\n }\n}\n\nComponentRegistry.add('shape', ShapeComponent)\n\nexport default ShapeComponent\n","/******************************************************************************\r\nCopyright (c) Microsoft Corporation.\r\n\r\nPermission to use, copy, modify, and/or distribute this software for any\r\npurpose with or without fee is hereby granted.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\nREGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\nAND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\nINDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\nLOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\nOTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\nPERFORMANCE OF THIS SOFTWARE.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nexport function __extends(d, b) {\r\n if (typeof b !== \"function\" && b !== null)\r\n throw new TypeError(\"Class extends value \" + String(b) + \" is not a constructor or null\");\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nexport var __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nexport function __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {\r\n if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))\r\n t[p[i]] = s[p[i]];\r\n }\r\n return t;\r\n}\r\n\r\nexport function __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nexport function __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nexport function __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nexport function __awaiter(thisArg, _arguments, P, generator) {\r\n function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nexport function __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nexport var __createBinding = Object.create ? (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n var desc = Object.getOwnPropertyDescriptor(m, k);\r\n if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\r\n desc = { enumerable: true, get: function() { return m[k]; } };\r\n }\r\n Object.defineProperty(o, k2, desc);\r\n}) : (function(o, m, k, k2) {\r\n if (k2 === undefined) k2 = k;\r\n o[k2] = m[k];\r\n});\r\n\r\nexport function __exportStar(m, o) {\r\n for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);\r\n}\r\n\r\nexport function __values(o) {\r\n var s = typeof Symbol === \"function\" && Symbol.iterator, m = s && o[s], i = 0;\r\n if (m) return m.call(o);\r\n if (o && typeof o.length === \"number\") return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n throw new TypeError(s ? \"Object is not iterable.\" : \"Symbol.iterator is not defined.\");\r\n}\r\n\r\nexport function __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\n/** @deprecated */\r\nexport function __spreadArrays() {\r\n for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;\r\n for (var r = Array(s), k = 0, i = 0; i < il; i++)\r\n for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)\r\n r[k] = a[j];\r\n return r;\r\n}\r\n\r\nexport function __spreadArray(to, from, pack) {\r\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\r\n if (ar || !(i in from)) {\r\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\r\n ar[i] = from[i];\r\n }\r\n }\r\n return to.concat(ar || Array.prototype.slice.call(from));\r\n}\r\n\r\nexport function __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nexport function __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nexport function __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nexport function __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nexport function __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nvar __setModuleDefault = Object.create ? (function(o, v) {\r\n Object.defineProperty(o, \"default\", { enumerable: true, value: v });\r\n}) : function(o, v) {\r\n o[\"default\"] = v;\r\n};\r\n\r\nexport function __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (k !== \"default\" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);\r\n __setModuleDefault(result, mod);\r\n return result;\r\n}\r\n\r\nexport function __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\r\nexport function __classPrivateFieldGet(receiver, state, kind, f) {\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a getter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot read private member from an object whose class did not declare it\");\r\n return kind === \"m\" ? f : kind === \"a\" ? f.call(receiver) : f ? f.value : state.get(receiver);\r\n}\r\n\r\nexport function __classPrivateFieldSet(receiver, state, value, kind, f) {\r\n if (kind === \"m\") throw new TypeError(\"Private method is not writable\");\r\n if (kind === \"a\" && !f) throw new TypeError(\"Private accessor was defined without a setter\");\r\n if (typeof state === \"function\" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError(\"Cannot write private member to an object whose class did not declare it\");\r\n return (kind === \"a\" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;\r\n}\r\n\r\nexport function __classPrivateFieldIn(state, receiver) {\r\n if (receiver === null || (typeof receiver !== \"object\" && typeof receiver !== \"function\")) throw new TypeError(\"Cannot use 'in' operator on non-object\");\r\n return typeof state === \"function\" ? receiver === state : state.has(receiver);\r\n}\r\n","/**\n * @file Atomindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\n/**\n * Color by atom index. The {@link AtomProxy.index} property is used for coloring.\n * Each {@link ModelProxy} of a {@link Structure} is colored seperately. The\n * `params.domain` parameter is ignored.\n *\n * __Name:__ _atomindex_\n *\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"ball+stick\", { colorScheme: \"atomindex\" } );\n * o.autoView();\n * } );\n */\nclass AtomindexColormaker extends Colormaker {\n scalePerModel: { [k: number]: ColormakerScale }\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rainbow'\n this.parameters.reverse = defaults(params.reverse, true)\n }\n\n this.scalePerModel = {}\n\n params.structure.eachModel((mp: ModelProxy) => {\n this.parameters.domain = [ mp.atomOffset, mp.atomEnd ]\n this.scalePerModel[ mp.index ] = this.getScale() // TODO\n })\n }\n\n /**\n * get color for an atom\n * @param {AtomProxy} atom - atom to get color for\n * @return {Integer} hex atom color\n */\n @manageColor\n atomColor (atom: AtomProxy) {\n return this.scalePerModel[ atom.modelIndex ](atom.index)\n }\n}\n\nColormakerRegistry.add('atomindex', AtomindexColormaker)\n\nexport default AtomindexColormaker\n","/**\n * @file Bfactor Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Selection from '../selection/selection'\n\n/**\n * Color by b-factor. The {@link AtomProxy.bfactor} property is used for coloring.\n * By default the min and max b-factor values are used for the scale`s domain.\n *\n * __Name:__ _bfactor_\n *\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"ball+stick\", { colorScheme: \"bfactor\" } );\n * o.autoView();\n * } );\n */\nclass BfactorColormaker extends Colormaker {\n bfactorScale: ColormakerScale\n\n constructor (params: { sele?: string } & StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'OrRd'\n }\n\n if (!params.domain) {\n let selection\n let min = Infinity\n let max = -Infinity\n\n if (params.sele) {\n selection = new Selection(params.sele)\n }\n\n params.structure.eachAtom(function (a) {\n const bfactor = a.bfactor\n min = Math.min(min, bfactor)\n max = Math.max(max, bfactor)\n }, selection)\n\n this.parameters.domain = [ min, max ]\n }\n\n this.bfactorScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.bfactorScale(a.bfactor)\n }\n}\n\nColormakerRegistry.add('bfactor', BfactorColormaker)\n\nexport default BfactorColormaker\n","/**\n * @file Chainid Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\nexport type ChainidDict = { [k: string]: number }\n\n/**\n * Color by chain id\n */\nclass ChainidColormaker extends Colormaker {\n chainidDictPerModel: { [k: number]: ChainidDict } = {}\n scalePerModel: { [k: number]: ColormakerScale } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'Spectral'\n }\n\n params.structure.eachModel((mp: ModelProxy) => {\n let i = 0\n const chainidDict: ChainidDict = {}\n mp.eachChain(function (cp: ChainProxy) {\n if (chainidDict[ cp.chainid ] === undefined) {\n chainidDict[ cp.chainid ] = i\n i += 1\n }\n })\n this.parameters.domain = [ 0, i - 1 ]\n this.chainidDictPerModel[ mp.index ] = chainidDict\n this.scalePerModel[ mp.index ] = this.getScale()\n })\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n const chainidDict = this.chainidDictPerModel[ a.modelIndex ]\n return this.scalePerModel[ a.modelIndex ](chainidDict[ a.chainid ])\n }\n}\n\nColormakerRegistry.add('chainid', ChainidColormaker)\n\nexport default ChainidColormaker\n","/**\n * @file Chainindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\n/**\n * Color by chain index\n */\nclass ChainindexColormaker extends Colormaker {\n scalePerModel: { [k: number]: ColormakerScale } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'Spectral'\n }\n\n params.structure.eachModel((mp: ModelProxy) => {\n this.parameters.domain = [ mp.chainOffset, mp.chainEnd ]\n this.scalePerModel[ mp.index ] = this.getScale()\n })\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.scalePerModel[ a.modelIndex ](a.chainIndex)\n }\n}\n\nColormakerRegistry.add('chainindex', ChainindexColormaker)\n\nexport default ChainindexColormaker\n","/**\n * @file Chainname Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\nimport ModelProxy from '../proxy/model-proxy'\n\nexport type ChainnameDict = { [k: string]: number }\n\n/**\n * Color by chain name\n */\nclass ChainnameColormaker extends Colormaker {\n chainnameDictPerModel: { [k: number]: ChainnameDict } = {}\n scalePerModel: { [k: number]: ColormakerScale } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'Spectral'\n }\n\n params.structure.eachModel((mp: ModelProxy) => {\n let i = 0\n const chainnameDict: ChainnameDict = {}\n mp.eachChain(function (cp: ChainProxy) {\n if (chainnameDict[ cp.chainname ] === undefined) {\n chainnameDict[ cp.chainname ] = i\n i += 1\n }\n })\n this.parameters.domain = [ 0, i - 1 ]\n this.chainnameDictPerModel[ mp.index ] = chainnameDict\n this.scalePerModel[ mp.index ] = this.getScale()\n })\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n const chainnameDict = this.chainnameDictPerModel[ a.modelIndex ]\n return this.scalePerModel[ a.modelIndex ](chainnameDict[ a.chainname ])\n }\n}\n\nColormakerRegistry.add('chainname', ChainnameColormaker)\n\nexport default ChainnameColormaker\n","/**\n * @file Densityfit Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by validation density fit\n */\nclass DensityfitColormaker extends Colormaker {\n rsrzScale: ColormakerScale\n rsccScale: ColormakerScale\n\n rsrzDict: { [k: string]: number|undefined } = {}\n rsccDict: { [k: string]: number|undefined } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'RdYlBu'\n }\n\n this.rsrzScale = this.getScale({ domain: [ 2, 0 ] })\n this.rsccScale = this.getScale({ domain: [ 0.678, 1.0 ] })\n\n const val = params.structure.validation\n if (val) {\n this.rsrzDict = val.rsrzDict\n this.rsccDict = val.rsccDict\n }\n\n }\n\n @manageColor\n atomColor (atom: AtomProxy) {\n let sele = atom.resno + ''\n if (atom.inscode) sele += '^' + atom.inscode\n if (atom.chainname) sele += ':' + atom.chainname\n sele += '/' + atom.modelIndex\n\n const rsrz = this.rsrzDict[ sele ]\n if (rsrz !== undefined) {\n return this.rsrzScale(rsrz)\n }\n\n const rscc = this.rsccDict[ sele ]\n if (rscc !== undefined) {\n return this.rsccScale(rscc)\n }\n\n return 0x909090\n }\n}\n\nColormakerRegistry.add('densityfit', DensityfitColormaker)\n\nexport default DensityfitColormaker\n","/**\n * @file Atomindex Colormaker\n * @author Fred Ludlow \n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport SpatialHash from '../geometry/spatial-hash'\n\n// from CHARMM\nconst partialCharges: { [k: string]: { [k: string]: number } } = {\n 'ARG': {\n 'CD': 0.1,\n 'CZ': 0.5,\n 'NE': -0.1\n },\n 'ASN': {\n 'CG': 0.55,\n 'OD1': -0.55\n },\n 'ASP': {\n 'CB': -0.16,\n 'CG': 0.36,\n 'OD1': -0.6,\n 'OD2': -0.6\n },\n 'CYS': {\n 'CB': 0.19,\n 'SG': -0.19\n },\n 'GLN': {\n 'CD': 0.55,\n 'OE1': -0.55\n },\n 'GLU': {\n 'CD': 0.36,\n 'CG': -0.16,\n 'OE1': -0.6,\n 'OE2': -0.6\n },\n 'HIS': {\n 'CB': 0.1,\n 'CD2': 0.2,\n 'CE1': 0.45,\n 'CG': 0.15,\n 'ND1': 0.05,\n 'NE2': 0.05\n },\n 'LYS': {\n 'CE': 0.25,\n 'NZ': 0.75\n },\n 'MET': {\n 'CE': 0.06,\n 'CG': 0.06,\n 'SD': -0.12\n },\n 'PTR': {\n 'C': 0.55,\n 'CA': 0.1,\n 'CZ': 0.25,\n 'N': -0.35,\n 'O': -0.55,\n 'O1P': -0.85,\n 'O2P': -0.85,\n 'O3P': -0.85,\n 'OG1': -1.1,\n 'P': 1.4\n },\n 'SEP': {\n 'C': 0.55,\n 'CA': 0.1,\n 'CB': 0.25,\n 'N': -0.35,\n 'O': -0.55,\n 'O1P': -0.85,\n 'O2P': -0.85,\n 'O3P': -0.85,\n 'OG1': -1.1,\n 'P': 1.4\n },\n 'SER': {\n 'CB': 0.25,\n 'OG': -0.25\n },\n 'THR': {\n 'CB': 0.25,\n 'OG1': -0.25\n },\n 'TPO': {\n 'C': 0.55,\n 'CA': 0.1,\n 'CB': 0.25,\n 'N': -0.35,\n 'O': -0.55,\n 'OG1': -1.1,\n 'O1P': -0.85,\n 'O2P': -0.85,\n 'O3P': -0.85,\n 'P': 1.4\n },\n 'TRP': {\n 'CD1': 0.06,\n 'CD2': 0.1,\n 'CE2': -0.04,\n 'CE3': -0.03,\n 'CG': -0.03,\n 'NE1': -0.06\n },\n 'TYR': {\n 'CZ': 0.25,\n 'OH': -0.25\n },\n 'backbone': {\n 'C': 0.55,\n 'O': -0.55,\n 'N': -0.35,\n 'CA': 0.1\n }\n}\n\nconst maxRadius = 12.0\nconst nHBondDistance = 1.04\nconst nHCharge = 0.25\n\n/**\n * Populates position vector with location of implicit or explicit H\n * Returns position or undefined if not able to locate H\n *\n * @param {AtomProxy} ap - the nitrogen atom\n * @param {Vector3} [position] - optional target\n * @return {Vectors|undefined} the hydrogen atom position\n */\nfunction backboneNHPosition (ap: AtomProxy, position = new Vector3()) {\n let h = false\n let ca = false\n let c = false\n position.set(2 * ap.x, 2 * ap.y, 2 * ap.z)\n\n ap.eachBondedAtom(function (a2: AtomProxy) {\n // Any time we detect H, reset position and skip\n // future tests\n if (h) return\n if (a2.atomname === 'H') {\n position.set(a2.x, a2.y, a2.z)\n h = true\n return\n }\n if (!ca && a2.atomname === 'CA') {\n position.sub(a2 as any) // TODO\n ca = true\n } else if (!c && a2.atomname === 'C') {\n c = true\n position.sub(a2 as any) // TODO\n }\n })\n\n if (h) { return position }\n\n if (ca && c) {\n position.normalize()\n position.multiplyScalar(nHBondDistance)\n position.add(ap as any)\n return position\n }\n}\n\n/**\n * Takes an array of Vector3 objects and\n * converts to an object that looks like an AtomStore\n *\n * @param {Vector3[]} positions - array of positions\n * @return {Object} AtomStore-like object\n */\nfunction buildStoreLike (positions: Vector3[]) {\n const n = positions.length\n const x = new Float32Array(n)\n const y = new Float32Array(n)\n const z = new Float32Array(n)\n\n for (let i = 0; i < positions.length; i++) {\n const v = positions[ i ]\n x[ i ] = v.x\n y[ i ] = v.y\n z[ i ] = v.z\n }\n\n return { x: x, y: y, z: z, count: n }\n}\n\nfunction chargeForAtom (a: AtomProxy): number {\n if (a.partialCharge !== null) return a.partialCharge\n if (!a.isProtein()) { return 0.0 }\n return (\n (partialCharges[ a.resname ] &&\n partialCharges[ a.resname ][ a.atomname ]) ||\n partialCharges[ 'backbone' ][ a.atomname ] || 0.0\n )\n}\n\n/**\n * Color a surface by electrostatic charge. This is a highly approximate\n * calculation! The partial charges are CHARMM with hydrogens added to heavy\n * atoms and hydrogen positions generated for amides.\n *\n * __Name:__ _electrostatic_\n *\n * @example\n * stage.loadFile( \"rcsb://3dqb\" ).then( function( o ){\n * o.addRepresentation( \"surface\", { colorScheme: \"electrostatic\" } );\n * o.autoView();\n * } );\n */\nclass ElectrostaticColormaker extends Colormaker {\n scale: ColormakerScale\n hHash: SpatialHash\n hash: SpatialHash\n charges: Float32Array\n hStore: { x: Float32Array, y: Float32Array, z: Float32Array, count: number }\n atomProxy: AtomProxy\n\n delta = new Vector3()\n hCharges: number[] = []\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rwb'\n }\n if (!params.domain) {\n this.parameters.domain = [ -50, 50 ]\n }\n\n this.scale = this.getScale()\n\n this.charges = new Float32Array(params.structure.atomCount)\n const hPositions: Vector3[] = []\n\n params.structure.eachAtom((ap: AtomProxy) => {\n this.charges[ ap.index ] = chargeForAtom(ap) * ap.occupancy\n if (ap.atomname === 'N') {\n\n // In the specific case where N forms two bonds to\n // CA and C, try and place a dummy hydrogen\n\n if (ap.bondCount >= 3) return; // Skip if 3 bonds already (e.g. PRO)\n\n if (ap.bondToElementCount(1)) return; // Skip if any H specificed\n\n const hPos = backboneNHPosition(ap)\n if (hPos !== undefined) {\n hPositions.push(hPos)\n this.hCharges.push(nHCharge * ap.occupancy)\n }\n }\n })\n\n const bbox = params.structure.getBoundingBox()\n bbox.expandByScalar(nHBondDistance) // Worst case\n\n // SpatialHash requires x,y,z and count\n this.hStore = buildStoreLike(hPositions)\n this.hHash = new SpatialHash(this.hStore as any, bbox) // TODO\n this.hash = new SpatialHash(params.structure.atomStore, bbox)\n }\n\n @manageColor\n positionColor (v: Vector3) {\n\n const charges = this.charges\n const hCharges = this.hCharges\n\n let p = 0.0\n this.hash.eachWithin(v.x, v.y, v.z, maxRadius, (atomIndex, dSq) => {\n const charge = charges[atomIndex]\n if (charge === 0.0) return\n p += charge / dSq\n })\n\n this.hHash.eachWithin(v.x, v.y, v.z, maxRadius, (atomIndex, dSq) => {\n const charge = hCharges[atomIndex]\n if (charge === 0.0) return\n p += charge / dSq\n })\n\n return this.scale(p * 332) // 332 to convert to kcal/mol\n }\n}\n\nColormakerRegistry.add('electrostatic', ElectrostaticColormaker)\n\nexport default ElectrostaticColormaker\n","/**\n * @file Element Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Colormaker, { ColormakerParameters, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n// from Jmol http://jmol.sourceforge.net/jscolors/ (or 0xFFFFFF)\nconst ElementColors: { [k: string]: number } = {\n 'H': 0xFFFFFF,\n 'HE': 0xD9FFFF,\n 'LI': 0xCC80FF,\n 'BE': 0xC2FF00,\n 'B': 0xFFB5B5,\n 'C': 0x909090,\n 'N': 0x3050F8,\n 'O': 0xFF0D0D,\n 'F': 0x90E050,\n 'NE': 0xB3E3F5,\n 'NA': 0xAB5CF2,\n 'MG': 0x8AFF00,\n 'AL': 0xBFA6A6,\n 'SI': 0xF0C8A0,\n 'P': 0xFF8000,\n 'S': 0xFFFF30,\n 'CL': 0x1FF01F,\n 'AR': 0x80D1E3,\n 'K': 0x8F40D4,\n 'CA': 0x3DFF00,\n 'SC': 0xE6E6E6,\n 'TI': 0xBFC2C7,\n 'V': 0xA6A6AB,\n 'CR': 0x8A99C7,\n 'MN': 0x9C7AC7,\n 'FE': 0xE06633,\n 'CO': 0xF090A0,\n 'NI': 0x50D050,\n 'CU': 0xC88033,\n 'ZN': 0x7D80B0,\n 'GA': 0xC28F8F,\n 'GE': 0x668F8F,\n 'AS': 0xBD80E3,\n 'SE': 0xFFA100,\n 'BR': 0xA62929,\n 'KR': 0x5CB8D1,\n 'RB': 0x702EB0,\n 'SR': 0x00FF00,\n 'Y': 0x94FFFF,\n 'ZR': 0x94E0E0,\n 'NB': 0x73C2C9,\n 'MO': 0x54B5B5,\n 'TC': 0x3B9E9E,\n 'RU': 0x248F8F,\n 'RH': 0x0A7D8C,\n 'PD': 0x006985,\n 'AG': 0xC0C0C0,\n 'CD': 0xFFD98F,\n 'IN': 0xA67573,\n 'SN': 0x668080,\n 'SB': 0x9E63B5,\n 'TE': 0xD47A00,\n 'I': 0x940094,\n 'XE': 0x940094,\n 'CS': 0x57178F,\n 'BA': 0x00C900,\n 'LA': 0x70D4FF,\n 'CE': 0xFFFFC7,\n 'PR': 0xD9FFC7,\n 'ND': 0xC7FFC7,\n 'PM': 0xA3FFC7,\n 'SM': 0x8FFFC7,\n 'EU': 0x61FFC7,\n 'GD': 0x45FFC7,\n 'TB': 0x30FFC7,\n 'DY': 0x1FFFC7,\n 'HO': 0x00FF9C,\n 'ER': 0x00E675,\n 'TM': 0x00D452,\n 'YB': 0x00BF38,\n 'LU': 0x00AB24,\n 'HF': 0x4DC2FF,\n 'TA': 0x4DA6FF,\n 'W': 0x2194D6,\n 'RE': 0x267DAB,\n 'OS': 0x266696,\n 'IR': 0x175487,\n 'PT': 0xD0D0E0,\n 'AU': 0xFFD123,\n 'HG': 0xB8B8D0,\n 'TL': 0xA6544D,\n 'PB': 0x575961,\n 'BI': 0x9E4FB5,\n 'PO': 0xAB5C00,\n 'AT': 0x754F45,\n 'RN': 0x428296,\n 'FR': 0x420066,\n 'RA': 0x007D00,\n 'AC': 0x70ABFA,\n 'TH': 0x00BAFF,\n 'PA': 0x00A1FF,\n 'U': 0x008FFF,\n 'NP': 0x0080FF,\n 'PU': 0x006BFF,\n 'AM': 0x545CF2,\n 'CM': 0x785CE3,\n 'BK': 0x8A4FE3,\n 'CF': 0xA136D4,\n 'ES': 0xB31FD4,\n 'FM': 0xB31FBA,\n 'MD': 0xB30DA6,\n 'NO': 0xBD0D87,\n 'LR': 0xC70066,\n 'RF': 0xCC0059,\n 'DB': 0xD1004F,\n 'SG': 0xD90045,\n 'BH': 0xE00038,\n 'HS': 0xE6002E,\n 'MT': 0xEB0026,\n 'DS': 0xFFFFFF,\n 'RG': 0xFFFFFF,\n 'CN': 0xFFFFFF,\n 'UUT': 0xFFFFFF,\n 'FL': 0xFFFFFF,\n 'UUP': 0xFFFFFF,\n 'LV': 0xFFFFFF,\n 'UUH': 0xFFFFFF,\n\n 'D': 0xFFFFC0,\n 'T': 0xFFFFA0\n}\nconst DefaultElementColor = 0xFFFFFF\n\n/**\n * Color by element\n */\nclass ElementColormaker extends Colormaker {\n constructor (params: ColormakerParameters) {\n params.value = defaults(params.value, ElementColors.C)\n\n super(params)\n }\n\n\n @manageColor\n atomColor (a: AtomProxy) {\n const element = a.element\n\n if (element === 'C') {\n return this.parameters.value\n } else {\n return ElementColors[ element ] || DefaultElementColor\n }\n }\n}\n\nColormakerRegistry.add('element', ElementColormaker)\n\nexport default ElementColormaker\n","/**\n * @file Entityindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by entity index\n */\nclass EntityindexColormaker extends Colormaker {\n entityindexScale: ColormakerScale\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'Spectral'\n }\n if (!params.domain) {\n this.parameters.domain = [ 0, params.structure.entityList.length - 1 ]\n }\n\n this.entityindexScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.entityindexScale(a.entityIndex)\n }\n}\n\nColormakerRegistry.add('entityindex', EntityindexColormaker)\n\nexport default EntityindexColormaker\n","/**\n * @file Entitytype Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\nimport {\n PolymerEntity, NonPolymerEntity, MacrolideEntity, WaterEntity\n} from '../structure/structure-constants'\n\n/**\n * Color by entity type\n */\nclass EntitytypeColormaker extends Colormaker {\n @manageColor\n atomColor (a: AtomProxy) {\n const e = a.entity\n const et = e ? e.entityType : undefined\n switch (et) {\n case PolymerEntity:\n return 0x7fc97f\n case NonPolymerEntity:\n return 0xfdc086\n case MacrolideEntity:\n return 0xbeaed4\n case WaterEntity:\n return 0x386cb0\n default:\n return 0xffff99\n }\n }\n}\n\nColormakerRegistry.add('entitytype', EntitytypeColormaker)\n\nexport default EntitytypeColormaker\n","/**\n * @file Geoquality Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport { countSetBits } from '../math/math-utils'\n\n/**\n * Color by validation gometry quality\n */\nclass GeoqualityColormaker extends Colormaker {\n geoAtomDict: { [k: string]: { [k: string]: number } } = {}\n geoDict: { [k: string]: number|undefined } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n const val = params.structure.validation\n if (val) {\n this.geoAtomDict = val.geoAtomDict\n this.geoDict = val.geoDict\n }\n }\n\n @manageColor\n atomColor (atom: AtomProxy) {\n let sele = atom.resno + ''\n if (atom.inscode) sele += '^' + atom.inscode\n if (atom.chainname) sele += ':' + atom.chainname\n sele += '/' + atom.modelIndex\n\n let geoProblemCount\n const geoAtom = this.geoAtomDict[ sele ]\n if (geoAtom !== undefined) {\n const atomProblems: number = geoAtom[ atom.atomname ] || 0\n geoProblemCount = countSetBits(atomProblems)\n } else {\n geoProblemCount = this.geoDict[ sele ] || 0\n }\n\n if (geoProblemCount === 0) {\n return 0x2166ac\n } else if (geoProblemCount === 1) {\n return 0xfee08b\n } else if (geoProblemCount === 2) {\n return 0xf46d43\n } else if (geoProblemCount >= 3) {\n return 0xa50026\n }\n return 0x909090\n }\n}\n\nColormakerRegistry.add('geoquality', GeoqualityColormaker)\n\nexport default GeoqualityColormaker\n","/**\n * @file Hydrophobicity Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { ColormakerParameters, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\nimport {\n ResidueHydrophobicity, DefaultResidueHydrophobicity\n} from '../structure/structure-constants'\n\n/**\n * Color by hydrophobicity\n */\nclass HydrophobicityColormaker extends Colormaker {\n hfScale: ColormakerScale\n resHF: { [k: string]: number } = {}\n defaultResidueHydrophobicity: number\n\n constructor (params: ColormakerParameters) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'RdYlGn'\n }\n\n const idx = 0 // 0: DGwif, 1: DGwoct, 2: Oct-IF\n\n for (const name in ResidueHydrophobicity) {\n this.resHF[ name ] = ResidueHydrophobicity[ name ][ idx ]\n }\n this.defaultResidueHydrophobicity = DefaultResidueHydrophobicity[idx]\n\n if (!params.domain) {\n let min = Infinity\n let max = -Infinity\n\n for (const name in this.resHF) {\n const val = this.resHF[ name ]\n min = Math.min(min, val)\n max = Math.max(max, val)\n }\n\n this.parameters.domain = [ min, 0, max ]\n }\n\n this.hfScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.hfScale(this.resHF[ a.resname ] || this.defaultResidueHydrophobicity)\n }\n}\n\nColormakerRegistry.add('hydrophobicity', HydrophobicityColormaker)\n\nexport default HydrophobicityColormaker\n","/**\n * @file Modelindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by model index\n */\nclass ModelindexColormaker extends Colormaker {\n modelindexScale: ColormakerScale\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rainbow'\n }\n if (!params.domain) {\n this.parameters.domain = [ 0, params.structure.modelStore.count ]\n }\n\n this.modelindexScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.modelindexScale(a.modelIndex)\n }\n}\n\nColormakerRegistry.add('modelindex', ModelindexColormaker)\n\nexport default ModelindexColormaker\n","/**\n * @file Moleculetype Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\nimport {\n WaterType, IonType, ProteinType, RnaType, DnaType, SaccharideType\n} from '../structure/structure-constants'\n\n/**\n * Color by molecule type\n */\nclass MoleculetypeColormaker extends Colormaker {\n @manageColor\n atomColor (a: AtomProxy) {\n switch (a.residueType.moleculeType) {\n case WaterType:\n return 0x386cb0\n case IonType:\n return 0xf0027f\n case ProteinType:\n return 0xbeaed4\n case RnaType:\n return 0xfdc086\n case DnaType:\n return 0xbf5b17\n case SaccharideType:\n return 0x7fc97f\n default:\n return 0xffff99\n }\n }\n}\n\nColormakerRegistry.add('moleculetype', MoleculetypeColormaker)\n\nexport default MoleculetypeColormaker\n","/**\n * @file Occupancy Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { ColormakerParameters, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by occupancy\n */\nclass OccupancyColormaker extends Colormaker {\n occupancyScale: ColormakerScale\n\n constructor (params: ColormakerParameters) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'PuBu'\n }\n\n if (!params.domain) {\n this.parameters.domain = [ 0.0, 1.0 ]\n }\n\n this.occupancyScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.occupancyScale(a.occupancy)\n }\n}\n\nColormakerRegistry.add('occupancy', OccupancyColormaker)\n\nexport default OccupancyColormaker\n","/**\n * @file Partialcharge Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { ColormakerParameters, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by partial charge. The {@link AtomProxy.partialCharge} property is used for coloring.\n * The default domain is [-1, 1].\n *\n * __Name:__ _partialCharge_\n *\n * @example\n * stage.loadFile(\"rcsb://1crn\").then(function (o) {\n * o.addRepresentation(\"ball+stick\", {colorScheme: \"partialCharge\"});\n * o.autoView();\n * });\n */\nclass PartialchargeColormaker extends Colormaker {\n partialchargeScale: ColormakerScale\n\n constructor (params: ColormakerParameters) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rwb'\n }\n\n if (!params.domain) {\n this.parameters.domain = [-1, 1]\n }\n\n this.partialchargeScale = this.getScale()\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.partialchargeScale(a.partialCharge || 0)\n }\n}\n\nColormakerRegistry.add('partialcharge', PartialchargeColormaker)\n\nexport default PartialchargeColormaker\n","/**\n * @file Random Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\n\nfunction randomColor () {\n return Math.random() * 0xFFFFFF\n}\n\n/**\n * Class by random color\n */\nclass RandomColormaker extends Colormaker {\n /**\n * get color for an atom\n * @return {Integer} random hex color\n */\n @manageColor\n atomColor () {\n return randomColor()\n }\n\n /**\n * get color for volume cell\n * @return {Integer} random hex color\n */\n @manageColor\n volumeColor () {\n return randomColor()\n }\n\n /**\n * get color for coordinates in space\n * @return {Integer} random hex color\n */\n @manageColor\n positionColor () {\n return randomColor()\n }\n}\n\nColormakerRegistry.add('random', RandomColormaker)\n\nexport default RandomColormaker\n","/**\n * @file Randomcoilindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n/**\n * Color by random coil index\n */\nclass RandomcoilindexColormaker extends Colormaker {\n rciScale: ColormakerScale\n rciDict: { [k: string]: number|undefined } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'RdYlBu'\n }\n\n this.rciScale = this.getScale({ domain: [ 0.6, 0 ] })\n\n const val = params.structure.validation\n if (val) this.rciDict = val.rciDict\n\n }\n\n @manageColor\n atomColor (atom: AtomProxy) {\n let sele = `[${atom.resname}]${atom.resno}`\n if (atom.chainname) sele += ':' + atom.chainname\n\n const rci = this.rciDict[ sele ]\n return rci !== undefined ? this.rciScale(rci) : 0x909090\n }\n}\n\nColormakerRegistry.add('randomcoilindex', RandomcoilindexColormaker)\n\nexport default RandomcoilindexColormaker\n","/**\n * @file Residueindex Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Colormaker, { StuctureColormakerParams, ColormakerScale, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ChainProxy from '../proxy/chain-proxy'\n\n/**\n * Color by residue index\n */\nclass ResidueindexColormaker extends Colormaker {\n scalePerChain: { [k: number]: ColormakerScale } = {}\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n if (!params.scale) {\n this.parameters.scale = 'rainbow'\n this.parameters.reverse = defaults(params.reverse, true)\n }\n\n params.structure.eachChain((cp: ChainProxy) => {\n this.parameters.domain = [ cp.residueOffset, cp.residueEnd ]\n this.scalePerChain[ cp.index ] = this.getScale()\n })\n }\n\n @manageColor\n atomColor (a: AtomProxy) {\n return this.scalePerChain[ a.chainIndex ](a.residueIndex)\n }\n}\n\nColormakerRegistry.add('residueindex', ResidueindexColormaker)\n\nexport default ResidueindexColormaker\n","/**\n * @file Resname Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\n\n// protein colors from Jmol http://jmol.sourceforge.net/jscolors/\nconst ResidueColors: { [k: string]: number } = {\n 'ALA': 0x8CFF8C,\n 'ARG': 0x00007C,\n 'ASN': 0xFF7C70,\n 'ASP': 0xA00042,\n 'CYS': 0xFFFF70,\n 'GLN': 0xFF4C4C,\n 'GLU': 0x660000,\n 'GLY': 0xFFFFFF,\n 'HIS': 0x7070FF,\n 'ILE': 0x004C00,\n 'LEU': 0x455E45,\n 'LYS': 0x4747B8,\n 'MET': 0xB8A042,\n 'PHE': 0x534C52,\n 'PRO': 0x525252,\n 'SER': 0xFF7042,\n 'THR': 0xB84C00,\n 'TRP': 0x4F4600,\n 'TYR': 0x8C704C,\n 'VAL': 0xFF8CFF,\n\n 'ASX': 0xFF00FF,\n 'GLX': 0xFF00FF,\n 'ASH': 0xFF00FF,\n 'GLH': 0xFF00FF,\n\n 'A': 0xDC143C, // Crimson Red\n 'G': 0x32CD32, // Lime Green\n 'I': 0x9ACD32, // Yellow Green\n 'X': 0x7CFC00, // Lawn Green\n 'C': 0xFFD700, // Gold Yellow\n 'T': 0x4169E1, // Royal Blue\n 'U': 0x40E0D0, // Turquoise Cyan\n 'D': 0x008B8B, // Dark Cyan\n\n 'DA': 0xDC143C,\n 'DG': 0x32CD32,\n 'DI': 0x9ACD32,\n 'DX': 0x7CFC00,\n 'DC': 0xFFD700,\n 'DT': 0x4169E1,\n 'DU': 0x40E0D0,\n 'DD': 0x008B8B\n}\nconst DefaultResidueColor = 0xFF00FF\n\n/**\n * Color by residue name\n */\nclass ResnameColormaker extends Colormaker {\n @manageColor\n atomColor (a: AtomProxy) {\n return ResidueColors[ a.resname ] || DefaultResidueColor\n }\n}\n\nColormakerRegistry.add('resname', ResnameColormaker)\n\nexport default ResnameColormaker\n","/**\n * @file Sstruc Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { StuctureColormakerParams, manageColor } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport ResidueProxy from '../proxy/residue-proxy'\n\n// from Jmol http://jmol.sourceforge.net/jscolors/ (shapely)\nconst StructureColors = {\n 'alphaHelix': 0xFF0080,\n 'threeTenHelix': 0xA00080,\n 'piHelix': 0x600080,\n 'betaStrand': 0xFFC800,\n 'betaTurn': 0x6080FF,\n 'coil': 0xFFFFFF,\n\n 'dna': 0xAE00FE,\n 'rna': 0xFD0162,\n\n 'carbohydrate': 0xA6A6FA\n}\nconst DefaultStructureColor = 0x808080\n\n/**\n * Color by secondary structure\n */\nclass SstrucColormaker extends Colormaker {\n residueProxy: ResidueProxy\n\n constructor (params: StuctureColormakerParams) {\n super(params)\n\n this.residueProxy = params.structure.getResidueProxy()\n }\n\n @manageColor\n atomColor (ap: AtomProxy) {\n const sstruc = ap.sstruc\n const rp = this.residueProxy\n\n if (sstruc === 'h') {\n return StructureColors.alphaHelix\n } else if (sstruc === 'g') {\n return StructureColors.threeTenHelix\n } else if (sstruc === 'i') {\n return StructureColors.piHelix\n } else if (sstruc === 'e' || sstruc === 'b') {\n return StructureColors.betaStrand\n } else if (sstruc === 't') {\n return StructureColors.betaTurn\n } else {\n rp.index = ap.residueIndex\n if (rp.isDna()) {\n return StructureColors.dna\n } else if (rp.isRna()) {\n return StructureColors.rna\n } else if (rp.isSaccharide()) {\n return StructureColors.carbohydrate\n } else if (rp.isProtein() || sstruc === 's' || sstruc === 'l') {\n return StructureColors.coil\n } else {\n return DefaultStructureColor\n }\n }\n }\n}\n\nColormakerRegistry.add('sstruc', SstrucColormaker)\n\nexport default SstrucColormaker\n","/**\n * @file Colordata Colormaker\n * @author Fred Ludlow \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { ColorData, ColormakerScale, manageColor, StuctureColormakerParams } from './colormaker'\nimport AtomProxy from '../proxy/atom-proxy'\nimport BondProxy from '../proxy/bond-proxy'\n\n\nclass StructuredataColormaker extends Colormaker {\n atomData?: ColorData['atomData']\n bondData?: ColorData['bondData']\n scale: ColormakerScale\n\n constructor(params: StuctureColormakerParams) {\n super(params)\n if (!params.scale) {\n this.parameters.scale = 'rwb'\n }\n this.atomData = this.parameters.data?.atomData\n this.bondData = this.parameters.data?.bondData\n this.scale = this.getScale(this.parameters)\n }\n\n @manageColor\n atomColor(a: AtomProxy) {\n const val = this.atomData?.[a.index]\n return (val !== undefined) ? this.scale(val) : this.parameters.value\n }\n\n @manageColor\n bondColor(bond: BondProxy, fromTo: boolean) {\n const val = this.bondData?.[bond.index]\n \n // Explicit bond data?\n if (val !== undefined) return this.scale(val)\n \n \n if (this.atomProxy) {\n this.atomProxy.index = fromTo ? bond.atomIndex1 : bond.atomIndex2\n return this.atomColor(this.atomProxy)\n } \n \n // Fallback\n return this.parameters.value\n }\n}\n\nColormakerRegistry.add('structuredata', StructuredataColormaker)\n\nexport default StructuredataColormaker","/**\n * @file Uniform Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { manageColor } from './colormaker'\n\n/**\n * Color by uniform color\n */\nclass UniformColormaker extends Colormaker {\n @manageColor\n atomColor () {\n return this.parameters.value\n }\n\n @manageColor\n bondColor () {\n return this.parameters.value\n }\n\n @manageColor\n valueColor () {\n return this.parameters.value\n }\n\n @manageColor\n volumeColor () {\n return this.parameters.value\n }\n}\n\nColormakerRegistry.add('uniform', UniformColormaker)\n\nexport default UniformColormaker\n","/**\n * @file Value Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { VolumeColormakerParams, ColormakerScale, manageColor } from './colormaker'\n\n/**\n * Color by volume value\n */\nclass ValueColormaker extends Colormaker {\n valueScale: ColormakerScale\n\n constructor (params: VolumeColormakerParams) {\n super(params)\n this.valueScale = this.getScale()\n }\n\n /**\n * return the color for a volume cell\n * @param {Integer} index - volume cell index\n * @return {Integer} hex cell color\n */\n @manageColor\n volumeColor (index: number) {\n return this.valueScale((this.parameters.volume! as any).data[ index ]) // TODO\n }\n}\n\nColormakerRegistry.add('value', ValueColormaker)\n\nexport default ValueColormaker\n","/**\n * @file Volume Colormaker\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\nimport { lerp } from '../math/math-utils'\n\nimport { ColormakerRegistry } from '../globals'\nimport Colormaker, { VolumeColormakerParams, ColormakerScale, manageColor } from './colormaker'\n\n/**\n * Color by volume position\n */\nclass VolumeColormaker extends Colormaker {\n valueScale: ColormakerScale\n vec = new Vector3()\n\n constructor (params: VolumeColormakerParams) {\n super(params)\n this.valueScale = this.getScale()\n }\n\n /**\n * return the color for coordinates in space\n * @param {Vector3} coords - xyz coordinates\n * @return {Integer} hex coords color\n */\n @manageColor\n positionColor (coords: Vector3) {\n const volume = this.parameters.volume as any // TODO\n\n if (!volume || !volume.inverseMatrix) {\n return this.parameters.value\n }\n\n const vec = this.vec\n const data = volume.data\n const nx = volume.nx\n const ny = volume.ny\n const nxy = nx * ny\n\n vec.copy(coords)\n vec.applyMatrix4(volume.inverseMatrix)\n\n // position of grid cell\n const x0 = Math.floor(vec.x)\n const y0 = Math.floor(vec.y)\n const z0 = Math.floor(vec.z)\n\n // Indices\n const i = ((((z0 * ny) + y0) * nx) + x0)\n const i1 = i + 1\n const iy = i + nx\n const iz = i + nxy\n const i1y = iy + 1\n const i1z = iz + 1\n const iyz = iy + nxy\n const i1yz = iyz + 1\n\n // Values\n const v = data[ i ]\n const v1 = data[ i1 ]\n const vy = data[ iy ]\n const vz = data[ iz ]\n const v1y = data[ i1y ]\n const v1z = data[ i1z ]\n const vyz = data[ iyz ]\n const v1yz = data[ i1yz ]\n\n // Position of point in fraction of grid\n const xd = vec.x - x0\n const yd = vec.y - y0\n const zd = vec.z - z0\n\n // 1st Dimension\n const c00 = lerp(v, v1, xd)\n const c01 = lerp(vz, v1z, xd)\n const c10 = lerp(vy, v1y, xd)\n const c11 = lerp(vyz, v1yz, xd)\n\n // 2nd Dimension\n const c0 = lerp(c00, c10, yd)\n const c1 = lerp(c01, c11, yd)\n\n // 3rd Dimension\n const c = lerp(c0, c1, zd)\n\n return this.valueScale(c)\n }\n}\n\nColormakerRegistry.add('volume', VolumeColormaker)\n\nexport default VolumeColormaker\n","/**\n * @file Structure Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { ExtensionFragDepth, Mobile } from '../globals'\nimport { defaults } from '../utils'\nimport { RepresentationParameters, default as Representation } from './representation'\nimport Selection from '../selection/selection'\nimport RadiusFactory, { RadiusFactoryTypes, RadiusType } from '../utils/radius-factory'\nimport Structure from '../structure/structure'\nimport Viewer from '../viewer/viewer'\n// @ts-ignore: unused import Volume required for declaration only\nimport { Assembly, Volume } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport AtomProxy from '../proxy/atom-proxy';\nimport Polymer from '../proxy/polymer';\nimport Buffer from '../buffer/buffer';\nimport { AtomDataFields, BondDataFields, AtomDataParams, BondDataParams } from '../structure/structure-data';\n// @ts-ignore: unused import Surface required for declaration only\nimport Surface from '../surface/surface'\n\n/**\n * Structure representation parameter object.\n * @typedef {Object} StructureRepresentationParameters - structure representation parameters\n * @mixes RepresentationParameters\n *\n * @property {String} radiusType - A list of possible sources of the radius used for rendering the representation. The radius can be based on the *vdW radius*, the *covalent radius* or the *B-factor* value of the corresponding atom. Additionally the radius can be based on the *secondary structure*. Alternatively, when set to *size*, the value from the *radius* parameter is used for all atoms.\n * @property {Float} radius - A number providing a fixed radius used for rendering the representation.\n * @property {Float} scale - A number that scales the value defined by the *radius* or the *radiusType* parameter.\n * @property {String} assembly - name of an assembly object. Included are the asymmetric unit (*AU*) corresponding to the coordinates given in the structure file, biological assemblies from *PDB*, *mmCIF* or *MMTF* files (*BU1*, *BU2*, ...), a filled (crystallographic) unitcell of a given space group (*UNITCELL*), a supercell consisting of a center unitcell and its 26 direct neighbors (*SUPERCELL*). Set to *default* to use the default asemmbly of the structure object.\n */\nexport interface StructureRepresentationParameters extends RepresentationParameters {\n radiusType: string\n radius: number\n scale: number\n assembly: string\n}\nexport interface StructureRepresentationData {\n bufferList: Buffer[]\n polymerList?: Polymer[]\n sview?: StructureView | Structure\n [k: string]: any\n}\n/**\n * Structure representation\n * @interface\n */\nabstract class StructureRepresentation extends Representation {\n\n protected selection: Selection\n protected dataList: StructureRepresentationData[]\n structure: Structure\n structureView: StructureView\n\n protected radiusType: RadiusType\n protected radiusData: {[k: number]: number}\n protected radiusSize: number\n protected radiusScale: number\n protected assembly: string\n protected defaultAssembly: string\n protected needsBuild: boolean\n\n /**\n * Create Structure representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {StructureRepresentationParameters} params - structure representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n const p = params || {}\n\n super(structure, viewer, p)\n\n this.type = 'structure'\n\n this.parameters = Object.assign({\n radiusType: {\n type: 'select', options: RadiusFactory.types\n },\n radiusData: {\n type: 'hidden'\n },\n radiusSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n radiusScale: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n assembly: null,\n defaultAssembly: {\n type: 'hidden'\n }\n }, this.parameters)\n\n /**\n * @type {Selection}\n * @private\n */\n this.selection = new Selection(p.sele)\n\n /**\n * @type {Array}\n * @private\n */\n this.dataList = []\n\n /**\n * @type {Structure}\n */\n this.structure = structure\n\n /**\n * @type {StructureView}\n */\n this.structureView = this.structure.getView(this.selection)\n\n if (structure.biomolDict) {\n const biomolOptions:{[key: string]: string} = {\n 'default': 'default',\n '': (structure.unitcell ? 'AU' : 'FULL')\n }\n Object.keys(structure.biomolDict).forEach(function (k) {\n biomolOptions[ k ] = k\n })\n this.parameters.assembly = {\n type: 'select',\n options: biomolOptions,\n rebuild: true\n }\n } else {\n this.parameters.assembly = null\n }\n }\n\n get defaultScale () {\n return {\n 'vdw': 1.0,\n 'covalent': 1.0,\n 'bfactor': 0.01,\n 'sstruc': 1.0\n }\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'element')\n\n this.setRadius(p.radius, p)\n\n this.radiusType = defaults(p.radiusType, 'vdw')\n this.radiusData = defaults(p.radiusData, {})\n this.radiusSize = defaults(p.radiusSize, 1.0)\n this.radiusScale = defaults(p.radiusScale, 1.0)\n this.assembly = defaults(p.assembly, 'default')\n this.defaultAssembly = defaults(p.defaultAssembly, '')\n\n if (p.quality === 'auto') {\n p.quality = this.getQuality()\n }\n\n super.init(p)\n\n this.selection.signals.stringChanged.add((/* sele */) => {\n this.build()\n })\n\n this.build()\n }\n\n setRadius (value: string | number | undefined, p: Partial) {\n const types = Object.keys(RadiusFactoryTypes)\n\n if (typeof value === 'string' && types.includes(value.toLowerCase())) {\n p.radiusType = value\n } else if (value !== undefined) {\n p.radiusType = 'size'\n p.radiusSize = value\n }\n\n return this\n }\n\n getAssembly (): Assembly {\n const name = this.assembly === 'default' ? this.defaultAssembly : this.assembly\n return this.structure.biomolDict[ name ]\n }\n\n getQuality () {\n let atomCount\n const s = this.structureView\n const assembly = this.getAssembly()\n if (assembly) {\n atomCount = assembly.getAtomCount(s)\n } else {\n atomCount = s.atomCount\n }\n if (Mobile) {\n atomCount *= 4\n }\n const backboneOnly = s.atomStore.count / s.residueStore.count < 2\n if (backboneOnly) {\n atomCount *= 10\n }\n\n if (atomCount < 15000) {\n return 'high'\n } else if (atomCount < 80000) {\n return 'medium'\n } else {\n return 'low'\n }\n }\n\n create () {\n if (this.structureView.atomCount === 0) return\n\n if (!this.structureView.hasCoords()) {\n this.needsBuild = true\n return\n } else {\n this.needsBuild = false\n }\n\n const assembly = this.getAssembly()\n\n if (assembly) {\n assembly.partList.forEach((part, i) => {\n const sview = part.getView(this.structureView)\n if (sview.atomCount === 0) return\n const data = this.createData(sview, i)\n if (data) {\n data.sview = sview\n data.instanceList = part.getInstanceList()\n this.dataList.push(data)\n }\n })\n } else {\n const data = this.createData(this.structureView, 0)\n if (data) {\n data.sview = this.structureView\n this.dataList.push(data)\n }\n }\n }\n\n abstract createData (sview: StructureView, k?: number): StructureRepresentationData|undefined\n\n update (what: AtomDataFields|BondDataFields) {\n if (this.lazy && !this.visible) {\n Object.assign(this.lazyProps.what, what)\n return\n }\n\n if (this.needsBuild) {\n this.build()\n return\n }\n\n this.dataList.forEach((data) => {\n if (data.bufferList.length > 0) {\n this.updateData(what, data)\n }\n }, this)\n }\n\n updateData (what?: AtomDataFields|BondDataFields, data?: any) {\n this.build()\n }\n\n getColorParams () {\n return {\n ...super.getColorParams(),\n structure: this.structure\n }\n }\n\n getRadiusParams (param?: any) {\n return {\n type: this.radiusType,\n scale: this.radiusScale,\n size: this.radiusSize,\n data: this.radiusData\n }\n }\n\n getAtomParams (what?: AtomDataFields, params?: AtomDataParams) {\n return Object.assign({\n what: what,\n colorParams: this.getColorParams(),\n radiusParams: this.getRadiusParams()\n }, params)\n }\n\n getBondParams (what?: BondDataFields, params?: BondDataParams) {\n return Object.assign({\n what: what,\n colorParams: this.getColorParams(),\n radiusParams: this.getRadiusParams()\n }, params)\n }\n\n getAtomRadius (atom: AtomProxy) {\n if (this.structureView.atomSet!.isSet(atom.index)) {\n const radiusFactory = new RadiusFactory(this.getRadiusParams())\n return radiusFactory.atomRadius(atom)\n }\n return 0\n }\n\n /**\n * Set representation parameters\n * @alias StructureRepresentation#setSelection\n * @param {String} string - selection string, see {@tutorial selection-language}\n * @param {Boolean} [silent] - don't trigger a change event in the selection\n * @return {StructureRepresentation} this object\n */\n setSelection (string: string, silent?: boolean) {\n this.selection.setString(string, silent)\n\n return this\n }\n\n /**\n * Set representation parameters\n * @alias StructureRepresentation#setParameters\n * @param {StructureRepresentationParameters} params - structure parameter object\n * @param {Object} [what] - buffer data attributes to be updated,\n * note that this needs to be implemented in the\n * derived classes. Generally it allows more\n * fine-grained control over updating than\n * forcing a rebuild.\n * @param {Boolean} what.position - update position data\n * @param {Boolean} what.color - update color data\n * @param {Boolean} [rebuild] - whether or not to rebuild the representation\n * @return {StructureRepresentation} this object\n */\n setParameters (params: Partial, what: AtomDataFields = {}, rebuild = false) {\n const p = params || {}\n\n this.setRadius(p.radius, p)\n\n if (p.radiusType !== undefined || p.radiusData !== undefined || p.radiusSize !== undefined || p.radiusScale !== undefined) {\n what.radius = true\n if (!ExtensionFragDepth || this.disableImpostor) {\n rebuild = true\n }\n }\n\n if (p.defaultAssembly !== undefined &&\n p.defaultAssembly !== this.defaultAssembly &&\n ((this.assembly === 'default' && p.assembly === undefined) ||\n p.assembly === 'default')\n ) {\n rebuild = true\n }\n\n super.setParameters(p, what, rebuild)\n\n return this\n }\n\n getParameters () {\n const params = Object.assign(\n super.getParameters(),\n {\n sele: this.selection ? this.selection.string : undefined,\n defaultAssembly: this.defaultAssembly\n }\n )\n\n return params\n }\n\n attach (callback: ()=> void) {\n const viewer = this.viewer\n const bufferList = this.bufferList\n\n this.dataList.forEach(function (data) {\n data.bufferList.forEach(function (buffer) {\n bufferList.push(buffer)\n viewer.add(buffer, data.instanceList)\n })\n })\n\n this.setVisibility(this.visible)\n callback()\n }\n\n clear () {\n this.dataList.length = 0\n\n super.clear()\n }\n\n dispose () {\n this.structureView.dispose()\n\n super.dispose()\n }\n}\n\nexport default StructureRepresentation\n","/**\n * @file Measurement Representation\n * @author Fred Ludlow \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { Color, Vector3, Matrix4 } from 'three'\n\nimport Selection from '../selection/selection'\nimport { Browser } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport { uniformArray, uniformArray3 } from '../math/array-utils'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { LabelRepresentationParameters } from './label-representation';\nimport TextBuffer, { TextBufferData } from '../buffer/text-buffer';\nimport { GenericColor } from '../types'\n\nexport interface LabelDataField {\n position?: boolean\n labelColor?: boolean\n labelSize?: boolean\n radius?: boolean\n labelText?: boolean\n}\n\n/**\n * Measurement representation parameter object.\n * @typedef {Object} MeasurementRepresentationParameters - measurement representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n *\n * @property {Float} labelSize - size of the distance label\n * @property {Color} labelColor - color of the distance label\n * @property {Boolean} labelVisible - visibility of the distance label\n * @property {Float} labelZOffset - offset in z-direction (i.e. in camera direction)\n */\nexport interface MeasurementRepresentationParameters extends StructureRepresentationParameters {\n labelVisible: boolean\n labelSize: number\n labelColor: GenericColor\n labelType: 'atomname'|'atomindex'|'occupancy'|'bfactor'|'serial'|'element'|'atom'|'resname'|'resno'|'res'|'text'|'qualified'\n labelText: string\n labelFormat: string\n labelGrouping: 'atom'|'residue'\n labelFontFamily: 'sans-serif'|'monospace'|'serif'\n labelFontStyle: 'normal'|'italic'\n labelFontWeight: 'normal'|'bold'\n labelsdf: boolean\n labelXOffset: number\n labelYOffset: number\n labelZOffset: number\n labelAttachment: 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n labelBorder: boolean\n labelBorderColor: GenericColor\n labelBorderWidth: number\n labelBackground: boolean\n labelBackgroundColor: GenericColor\n labelBackgroundMargin: number\n labelBackgroundOpacity: number\n labelFixedSize: boolean\n lineOpacity: number\n linewidth: number\n}\n\n/**\n * Measurement representation\n * @interface\n */\nabstract class MeasurementRepresentation extends StructureRepresentation {\n protected n: number\n protected labelVisible: boolean\n protected labelSize: number\n protected labelColor: GenericColor\n protected labelType: 'atomname'|'atomindex'|'occupancy'|'bfactor'|'serial'|'element'|'atom'|'resname'|'resno'|'res'|'text'|'qualified'\n protected labelText: string\n protected labelFormat: string\n protected labelGrouping: 'atom'|'residue'\n protected labelFontFamily: 'sans-serif'|'monospace'|'serif'\n protected labelFontStyle: 'normal'|'italic'\n protected labelFontWeight: 'normal'|'bold'\n protected labelsdf: boolean\n protected labelXOffset: number\n protected labelYOffset: number\n protected labelZOffset: number\n protected labelAttachment: 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n protected labelBorder: boolean\n protected labelBorderColor: GenericColor\n protected labelBorderWidth: number\n protected labelBackground: boolean\n protected labelBackgroundColor: GenericColor\n protected labelBackgroundMargin: number\n protected labelBackgroundOpacity: number\n protected labelFixedSize: boolean\n protected lineOpacity: number\n protected linewidth: number\n protected lineVisible: boolean\n\n protected textBuffer: TextBuffer\n /**\n * Handles common label settings and position logic for\n * distance, angle and dihedral representations\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.n = 0 // Subclass create sets value\n this.parameters = Object.assign({\n labelVisible: {\n type: 'boolean'\n },\n labelSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n labelColor: {\n type: 'color'\n },\n labelFontFamily: {\n type: 'select',\n options: {\n 'sans-serif': 'sans-serif',\n 'monospace': 'monospace',\n 'serif': 'serif'\n },\n buffer: 'fontFamily'\n },\n labelFontStyle: {\n type: 'select',\n options: {\n 'normal': 'normal',\n 'italic': 'italic'\n },\n buffer: 'fontStyle'\n },\n labelFontWeight: {\n type: 'select',\n options: {\n 'normal': 'normal',\n 'bold': 'bold'\n },\n buffer: 'fontWeight'\n },\n labelsdf: {\n type: 'boolean', buffer: 'sdf'\n },\n labelXOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: 'xOffset'\n },\n labelYOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: 'yOffset'\n },\n labelZOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: 'zOffset'\n },\n labelAttachment: {\n type: 'select',\n options: {\n 'bottom-left': 'bottom-left',\n 'bottom-center': 'bottom-center',\n 'bottom-right': 'bottom-right',\n 'middle-left': 'middle-left',\n 'middle-center': 'middle-center',\n 'middle-right': 'middle-right',\n 'top-left': 'top-left',\n 'top-center': 'top-center',\n 'top-right': 'top-right'\n },\n rebuild: true\n },\n labelBorder: {\n type: 'boolean', buffer: 'showBorder'\n },\n labelBorderColor: {\n type: 'color', buffer: 'borderColor'\n },\n labelBorderWidth: {\n type: 'number', precision: 2, max: 0.3, min: 0, buffer: 'borderWidth'\n },\n labelBackground: {\n type: 'boolean', rebuild: true\n },\n labelBackgroundColor: {\n type: 'color', buffer: 'backgroundColor'\n },\n labelBackgroundMargin: {\n type: 'number', precision: 2, max: 2, min: 0, rebuild: true\n },\n labelBackgroundOpacity: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: 'backgroundOpacity'\n },\n labelFixedSize: {\n type: 'boolean', buffer: 'fixedSize'\n },\n lineOpacity: {\n type: 'range', min: 0.0, max: 1.0, step: 0.01\n },\n linewidth: {\n type: 'integer', max: 50, min: 1, buffer: true\n }\n }, this.parameters, {\n flatShaded: null\n })\n }\n\n init (params: Partial) {\n const p = params || {}\n this.labelVisible = defaults(p.labelVisible, true)\n this.labelSize = defaults(p.labelSize, 2.0)\n this.labelColor = defaults(p.labelColor, 0xFFFFFF)\n this.labelFontFamily = defaults(p.labelFontFamily, 'sans-serif')\n this.labelFontStyle = defaults(p.labelFontstyle, 'normal')\n this.labelFontWeight = defaults(p.labelFontWeight, 'bold')\n this.labelsdf = defaults(p.labelsdf, Browser === 'Chrome')\n this.labelXOffset = defaults(p.labelXOffset, 0.0)\n this.labelYOffset = defaults(p.labelYOffset, 0.0)\n this.labelZOffset = defaults(p.labelZOffset, 0.5)\n this.labelAttachment = defaults(p.labelAttachment, 'bottom-left')\n this.labelBorder = defaults(p.labelBorder, false)\n this.labelBorderColor = defaults(p.labelBorderColor, 'lightgrey')\n this.labelBorderWidth = defaults(p.labelBorderWidth, 0.15)\n this.labelBackground = defaults(p.labelBackground, false)\n this.labelBackgroundColor = defaults(p.labelBackgroundColor, 'lightgrey')\n this.labelBackgroundMargin = defaults(p.labelBackgroundMargin, 0.5)\n this.labelBackgroundOpacity = defaults(p.labelBackgroundOpacity, 1.0)\n this.labelFixedSize = defaults(p.labelFixedSize, false)\n this.lineOpacity = defaults(p.lineOpacity, 1.0)\n this.linewidth = defaults(p.linewidth, 2)\n\n super.init(p)\n }\n\n // All measurements need to rebuild on position change\n update (what: LabelDataField) {\n if (what.position) {\n this.build()\n } else {\n super.update(what)\n }\n }\n\n updateData (what: LabelDataField & {[k: string]: any}, data: any) {\n const textData: TextBufferData | {} = {}\n if (!what || what.labelSize) {\n Object.assign(textData, {size: uniformArray(this.n, this.labelSize)})\n }\n\n if (!what || what.labelColor) {\n const c = new Color(this.labelColor)\n Object.assign(textData, {color: uniformArray3(this.n, c.r, c.g, c.b)})\n }\n\n this.textBuffer.setAttributes(textData as TextBufferData)\n }\n\n setParameters (params: Partial, what: LabelDataField = {}, rebuild = false) {\n if (params && params.labelSize) {\n what.labelSize = true\n }\n\n if (params && (params.labelColor || params.labelColor === 0x000000)) {\n what.labelColor = true\n rebuild = true\n }\n\n super.setParameters(params, what, rebuild)\n\n if (params && params.opacity !== undefined) {\n this.textBuffer.setParameters({ opacity: 1.0 }) // only opaque labels\n }\n\n if (params && params.labelVisible !== undefined) {\n this.setVisibility(this.visible)\n }\n\n return this\n }\n\n setVisibility (value: boolean, noRenderRequest?: boolean) {\n super.setVisibility(value, true)\n if (this.textBuffer) {\n this.textBuffer.setVisibility(\n this.labelVisible && this.visible\n )\n }\n\n if (!noRenderRequest) this.viewer.requestRender()\n\n return this\n }\n\n getLabelBufferParams (params: Partial = {}) {\n return super.getBufferParams(Object.assign({\n fontFamily: this.labelFontFamily,\n fontStyle: this.labelFontStyle,\n fontWeight: this.labelFontWeight,\n sdf: this.labelsdf,\n xOffset: this.labelXOffset,\n yOffset: this.labelYOffset,\n zOffset: this.labelZOffset,\n attachment: this.labelAttachment,\n showBorder: this.labelBorder,\n borderColor: this.labelBorderColor,\n borderWidth: this.labelBorderWidth,\n showBackground: this.labelBackground,\n backgroundColor: this.labelBackgroundColor,\n backgroundMargin: this.labelBackgroundMargin,\n backgroundOpacity: this.labelBackgroundOpacity,\n fixedSize: this.labelFixedSize,\n disablePicking: true,\n visible: this.labelVisible\n }, params, {\n opacity: 1.0 // only opaque labels\n }))\n }\n\n getAtomRadius () {\n return 0\n }\n}\n\n/**\n * MeasurementRepresentations take atom[Pair|Triple|Quad] parameters.\n *\n * Parses nested array of either integer atom indices or selection\n * expressions into a flat array of coordinates.\n *\n * @param {Structure} sview The structure to which the atoms refer\n * @param {Array} atoms Nested array of atom pairs|triples|quads as\n * Integer indices or selection expressions\n * @return {Float32Array} Flattened array of position coordinates\n */\nfunction parseNestedAtoms (sview: StructureView, atoms: (number|string)[][]) {\n const ap = sview.getAtomProxy()\n const sele = new Selection()\n\n const nSets = atoms.length\n if (nSets === 0) return new Float32Array(0)\n\n // Peek-ahead at first item to determine order and parse mode\n const order = atoms[ 0 ].length\n const selected = sview.getAtomSet()\n\n const a = new Float32Array(nSets * order * 3)\n\n let p = 0\n atoms.forEach(function (group) {\n let _break = false\n for (let j = 0; j < order; j++) {\n const value = group[ j ]\n if (typeof (value) === 'number' && Number.isInteger(value)) {\n if (selected.get(value)) {\n ap.index = value\n } else {\n _break = true\n break\n }\n } else {\n sele.setString(value as string)\n const atomIndices = sview.getAtomIndices(sele)\n if (atomIndices!.length) {\n ap.index = atomIndices![ 0 ]\n } else {\n _break = true\n break\n }\n }\n\n let offset = p + j * 3\n a[ offset++ ] = ap.x\n a[ offset++ ] = ap.y\n a[ offset++ ] = ap.z\n }\n if (!_break) p += 3 * order\n })\n\n return a.subarray(0, p)\n}\n\n/* out = v1 * cos(angle) + v2 * sin(angle) */\nfunction calcArcPoint (out: Float32Array, center: Float32Array, v1: Float32Array, v2: Float32Array, angle: number) {\n const x = Math.cos(angle)\n const y = Math.sin(angle)\n out[ 0 ] = center[ 0 ] + v1[ 0 ] * x + v2[ 0 ] * y\n out[ 1 ] = center[ 1 ] + v1[ 1 ] * x + v2[ 1 ] * y\n out[ 2 ] = center[ 2 ] + v1[ 2 ] * x + v2[ 2 ] * y\n}\n\nexport {\n MeasurementRepresentation as default,\n calcArcPoint,\n parseNestedAtoms\n}\n","/**\n * @file Edt\n * @author Alexander Rose \n * @private\n */\n\nimport { NumberArray } from '../types'\n\n// 2D Euclidean distance transform by Felzenszwalb & Huttenlocher https://cs.brown.edu/~pff/papers/dt-final.pdf\nexport function edt(data: NumberArray, width: number, height: number, f: NumberArray, d: NumberArray, v: NumberArray, z: NumberArray) {\n for (let x = 0; x < width; x++) {\n for (let y = 0; y < height; y++) {\n f[y] = data[y * width + x]\n }\n edt1d(f, d, v, z, height)\n for (let y = 0; y < height; y++) {\n data[y * width + x] = d[y]\n }\n }\n for (let y = 0; y < height; y++) {\n for (let x = 0; x < width; x++) {\n f[x] = data[y * width + x]\n }\n edt1d(f, d, v, z, width)\n for (let x = 0; x < width; x++) {\n data[y * width + x] = Math.sqrt(d[x])\n }\n }\n}\n\n// 1D squared distance transform\nfunction edt1d(f: NumberArray, d: NumberArray, v: NumberArray, z: NumberArray, n: number) {\n v[0] = 0\n z[0] = Number.MIN_SAFE_INTEGER\n z[1] = Number.MAX_SAFE_INTEGER\n\n for (let q = 1, k = 0; q < n; q++) {\n let s = ((f[q] + q * q) - (f[v[k]] + v[k] * v[k])) / (2 * q - 2 * v[k])\n while (s <= z[k]) {\n k--\n s = ((f[q] + q * q) - (f[v[k]] + v[k] * v[k])) / (2 * q - 2 * v[k])\n }\n k++\n v[k] = q\n z[k] = s\n z[k + 1] = Number.MAX_SAFE_INTEGER\n }\n\n for (let q = 0, k = 0; q < n; q++) {\n while (z[k + 1] < q) k++\n d[q] = (q - v[k]) * (q - v[k]) + f[v[k]]\n }\n}\n","/**\n * @file Text Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { Color, CanvasTexture, Vector3, Matrix4 } from 'three'\n\nimport '../shader/SDFFont.vert'\nimport '../shader/SDFFont.frag'\n\nimport { BufferRegistry } from '../globals'\nimport { createParams } from '../utils'\nimport MappedQuadBuffer from './mappedquad-buffer'\nimport { IgnorePicker } from '../utils/picker'\nimport { edt } from '../utils/edt'\nimport { BufferDefaultParameters, BufferParameterTypes, BufferData, BufferTypes, BufferParameters } from './buffer'\nimport { GenericColor } from '../types'\n\nconst TextAtlasCache: { [k: string]: TextAtlas } = {}\n\nfunction getTextAtlas (params: Partial) {\n const hash = JSON.stringify(params)\n if (TextAtlasCache[ hash ] === undefined) {\n TextAtlasCache[ hash ] = new TextAtlas(params)\n }\n return TextAtlasCache[ hash ]\n}\n\ntype TextFonts = 'sans-serif'|'monospace'|'serif'\ntype TextStyles = 'normal'|'italic'\ntype TextVariants = 'normal'\ntype TextWeights = 'normal'|'bold'\n\nexport const TextAtlasDefaultParams = {\n font: 'sans-serif' as TextFonts,\n size: 36,\n style: 'normal' as TextStyles,\n variant: 'normal' as TextVariants,\n weight: 'normal' as TextWeights,\n outline: 3,\n width: 1024,\n height: 1024\n}\nexport type TextAtlasParams = typeof TextAtlasDefaultParams\n\nexport type TextAtlasMap = { x: number, y: number, w: number, h: number }\n\nexport class TextAtlas {\n parameters: TextAtlasParams\n\n gamma = 1\n mapped: { [k: string]: TextAtlasMap } = {}\n scratchW = 0\n scratchH = 0\n currentX = 0\n currentY = 0\n\n cutoff = 0.25\n padding: number\n radius: number\n\n gridOuter: Float64Array\n gridInner: Float64Array\n f: Float64Array\n d: Float64Array\n z: Float64Array\n v: Int16Array\n\n paddedSize: number\n middle: number\n\n texture: CanvasTexture\n canvas: HTMLCanvasElement\n context: CanvasRenderingContext2D\n\n lineHeight: number\n maxWidth: number\n colors: string[]\n scratch: Uint8Array\n canvas2: HTMLCanvasElement\n context2: CanvasRenderingContext2D\n data: Uint8Array\n\n placeholder: TextAtlasMap\n\n constructor (params: Partial = {}) {\n this.parameters = createParams(params, TextAtlasDefaultParams)\n const p = this.parameters\n\n this.radius = p.size / 8\n this.padding = p.size / 3\n\n // Prepare line-height with room for outline and descenders/ascenders\n const lineHeight = this.lineHeight = p.size + 2 * p.outline + Math.round(p.size / 4)\n const maxWidth = this.maxWidth = p.width / 4\n\n // Prepare scratch canvas\n const canvas = this.canvas = document.createElement('canvas')\n canvas.width = maxWidth\n canvas.height = lineHeight\n\n const ctx = this.context = this.canvas.getContext('2d')!\n ctx.font = `${p.style} ${p.variant} ${p.weight} ${p.size}px ${p.font}`\n ctx.fillStyle = 'black'\n ctx.textAlign = 'left'\n ctx.textBaseline = 'bottom'\n ctx.lineJoin = 'round'\n\n // temporary arrays for the distance transform\n this.gridOuter = new Float64Array(lineHeight * maxWidth)\n this.gridInner = new Float64Array(lineHeight * maxWidth)\n this.f = new Float64Array(Math.max(lineHeight, maxWidth))\n this.d = new Float64Array(Math.max(lineHeight, maxWidth))\n this.z = new Float64Array(Math.max(lineHeight, maxWidth) + 1)\n this.v = new Int16Array(Math.max(lineHeight, maxWidth))\n\n //\n this.data = new Uint8Array(p.width * p.height * 4)\n this.canvas2 = document.createElement('canvas')\n this.canvas2.width = p.width\n this.canvas2.height = p.height\n this.context2 = this.canvas2.getContext('2d')!\n\n // Replacement Character\n this.placeholder = this.map(String.fromCharCode(0xFFFD))\n\n // Basic Latin (subset)\n for (let i = 0x0020; i <= 0x007E; ++i) {\n this.map(String.fromCharCode(i))\n }\n\n // TODO: to slow to always prepare them\n // // Latin-1 Supplement (subset)\n // for (let i = 0x00A1; i <= 0x00FF; ++i) {\n // this.map(String.fromCharCode(i))\n // }\n\n // Degree sign\n this.map(String.fromCharCode(0x00B0))\n\n // // Greek and Coptic (subset)\n // for (let i = 0x0391; i <= 0x03C9; ++i) {\n // this.map(String.fromCharCode(i))\n // }\n\n // // Cyrillic (subset)\n // for (let i = 0x0400; i <= 0x044F; ++i) {\n // this.map(String.fromCharCode(i))\n // }\n\n // Angstrom Sign\n this.map(String.fromCharCode(0x212B))\n\n this.texture = new CanvasTexture(this.canvas2)\n this.texture.flipY = false\n this.texture.needsUpdate = true\n }\n\n map (text: string) {\n const p = this.parameters\n\n if (this.mapped[ text ] === undefined) {\n this.draw(text)\n\n if (this.currentX + this.scratchW > p.width) {\n this.currentX = 0\n this.currentY += this.scratchH\n }\n if (this.currentY + this.scratchH > p.height) {\n console.warn('canvas to small')\n }\n\n this.mapped[ text ] = {\n x: this.currentX,\n y: this.currentY,\n w: this.scratchW,\n h: this.scratchH\n }\n\n this.context2.drawImage(\n this.canvas,\n 0, 0,\n this.scratchW, this.scratchH,\n this.currentX, this.currentY,\n this.scratchW, this.scratchH\n )\n\n this.currentX += this.scratchW\n }\n\n return this.mapped[ text ]\n }\n\n get (text: string) {\n return this.mapped[ text ] || this.placeholder\n }\n\n draw (text: string) {\n const p = this.parameters\n\n const h = this.lineHeight\n const o = p.outline\n const ctx = this.context\n // const dst = this.scratch\n const max = this.maxWidth\n // const colors = this.colors\n\n // Bottom aligned, take outline into account\n const x = o\n const y = h - p.outline\n\n // Measure text\n const m = ctx.measureText(text)\n const w = Math.min(max, Math.ceil(m.width + 2 * x + 1))\n\n const n = w * h\n\n // Clear scratch area\n ctx.clearRect(0, 0, w, h)\n\n // Draw text\n ctx.fillText(text, x, y)\n\n const imageData = ctx.getImageData(0, 0, w, h)\n const data = imageData.data\n\n for (let i = 0; i < n; i++) {\n const a = imageData.data[i * 4 + 3] / 255; // alpha value\n this.gridOuter[i] = a === 1 ? 0 : a === 0 ? Number.MAX_SAFE_INTEGER : Math.pow(Math.max(0, 0.5 - a), 2);\n this.gridInner[i] = a === 1 ? Number.MAX_SAFE_INTEGER : a === 0 ? 0 : Math.pow(Math.max(0, a - 0.5), 2);\n }\n\n edt(this.gridOuter, w, h, this.f, this.d, this.v, this.z);\n edt(this.gridInner, w, h, this.f, this.d, this.v, this.z);\n\n for (let i = 0; i < n; i++) {\n const d = this.gridOuter[i] - this.gridInner[i];\n data[i * 4 + 3] = Math.max(0, Math.min(255, Math.round(255 - 255 * (d / this.radius + this.cutoff))));\n }\n\n ctx.putImageData(imageData, 0, 0)\n this.scratchW = w\n this.scratchH = h\n }\n}\n\n/**\n * Text buffer parameter object.\n * @typedef {Object} TextBufferParameters - text buffer parameters\n *\n * @property {Float} opacity - translucency: 1 is fully opaque, 0 is fully transparent\n * @property {Integer} clipNear - position of camera near/front clipping plane\n * in percent of scene bounding box\n * @property {String} labelType - type of the label, one of:\n * \"atomname\", \"atomindex\", \"occupancy\", \"bfactor\",\n * \"serial\", \"element\", \"atom\", \"resname\", \"resno\",\n * \"res\", \"text\", \"qualified\". When set to \"text\", the\n * `labelText` list is used.\n * @property {String[]} labelText - list of label strings, must set `labelType` to \"text\"\n * to take effect\n * @property {String} fontFamily - font family, one of: \"sans-serif\", \"monospace\", \"serif\"\n * @property {String} fontStyle - font style, \"normal\" or \"italic\"\n * @property {String} fontWeight - font weight, \"normal\" or \"bold\"\n * @property {Float} xOffset - offset in x-direction\n * @property {Float} yOffset - offset in y-direction\n * @property {Float} zOffset - offset in z-direction (i.e. in camera direction)\n * @property {String} attachment - attachment of the label, one of:\n * \"bottom-left\", \"bottom-center\", \"bottom-right\",\n * \"middle-left\", \"middle-center\", \"middle-right\",\n * \"top-left\", \"top-center\", \"top-right\"\n * @property {Boolean} showBorder - show border/outline\n * @property {Color} borderColor - color of the border/outline\n * @property {Float} borderWidth - width of the border/outline\n * @property {Boolean} showBackground - show background rectangle\n * @property {Color} backgroundColor - color of the background\n * @property {Float} backgroundMargin - width of the background\n * @property {Float} backgroundOpacity - opacity of the background\n * @property {Boolean} fixedSize - show text with a fixed pixel size\n */\n\nexport interface TextBufferData extends BufferData {\n size: Float32Array\n text: string[]\n}\n\ntype TextAttachments = 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n\nexport const TextBufferDefaultParameters = Object.assign({\n fontFamily: 'sans-serif' as TextFonts,\n fontStyle: 'normal' as TextStyles,\n fontWeight: 'bold' as TextWeights,\n fontSize: 36,\n xOffset: 0.0,\n yOffset: 0.0,\n zOffset: 0.5,\n attachment: 'bottom-left' as TextAttachments,\n showBorder: false,\n borderColor: 'lightgrey' as number|string,\n borderWidth: 0.15,\n showBackground: false,\n backgroundColor: 'lightgrey' as number|string,\n backgroundMargin: 0.5,\n backgroundOpacity: 1.0,\n forceTransparent: true,\n fixedSize: false\n}, BufferDefaultParameters)\nexport type TextBufferParameters = BufferParameters & {\n fontFamily: TextFonts,\n fontStyle: TextStyles,\n fontWeight: TextWeights,\n fontSize: number,\n xOffset: number,\n yOffset: number,\n zOffset: number,\n attachment: TextAttachments,\n showBorder: boolean,\n borderColor: GenericColor,\n borderWidth: number,\n showBackground: boolean,\n backgroundColor: GenericColor,\n backgroundMargin: number,\n backgroundOpacity: number,\n forceTransparent: boolean,\n fixedSize: boolean\n}\n\nconst TextBufferParameterTypes = Object.assign({\n fontFamily: { uniform: true },\n fontStyle: { uniform: true },\n fontWeight: { uniform: true },\n fontSize: { uniform: true },\n xOffset: { uniform: true },\n yOffset: { uniform: true },\n zOffset: { uniform: true },\n showBorder: { uniform: true },\n borderColor: { uniform: true },\n borderWidth: { uniform: true },\n backgroundColor: { uniform: true },\n backgroundOpacity: { uniform: true },\n fixedSize: { updateShader: true }\n}, BufferParameterTypes)\n\nfunction getCharCount (data: TextBufferData, params: Partial) {\n const n = data.position!.length / 3\n let charCount = 0\n for (let i = 0; i < n; ++i) {\n charCount += data.text[ i ].length\n }\n if (params.showBackground) charCount += n\n\n return charCount\n}\n\n/**\n * Text buffer. Renders screen-aligned text strings.\n *\n * @example\n * var textBuffer = new TextBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * size: new Float32Array([ 2 ]),\n * text: [ \"Hello\" ]\n * });\n */\nclass TextBuffer extends MappedQuadBuffer {\n parameterTypes = TextBufferParameterTypes\n get defaultParameters() { return TextBufferDefaultParameters }\n parameters: TextBufferParameters\n\n alwaysTransparent = true\n hasWireframe = false\n isText = true\n vertexShader = 'SDFFont.vert'\n fragmentShader = 'SDFFont.frag'\n\n text: string[]\n positionCount: number\n texture: CanvasTexture\n textAtlas: TextAtlas\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.size - sizes\n * @param {String[]} data.text - text strings\n * @param {TextBufferParameters} params - parameters object\n */\n constructor (data: TextBufferData, params: Partial = {}) {\n super({\n position: new Float32Array(getCharCount(data, params) * 3),\n color: new Float32Array(getCharCount(data, params) * 3),\n picking: new IgnorePicker()\n }, params)\n\n this.text = data.text\n this.positionCount = data.position!.length / 3\n\n this.addUniforms({\n 'fontTexture': { value: null },\n 'xOffset': { value: this.parameters.xOffset },\n 'yOffset': { value: this.parameters.yOffset },\n 'zOffset': { value: this.parameters.zOffset },\n 'ortho': { value: false },\n 'showBorder': { value: this.parameters.showBorder },\n 'borderColor': { value: new Color(this.parameters.borderColor as number) },\n 'borderWidth': { value: this.parameters.borderWidth },\n 'backgroundColor': { value: new Color(this.parameters.backgroundColor as number) },\n 'backgroundOpacity': { value: this.parameters.backgroundOpacity },\n 'canvasHeight': { value: 1.0 },\n 'pixelRatio': { value: 1.0 }\n })\n\n this.addAttributes({\n 'inputTexCoord': { type: 'v2', value: null },\n 'inputSize': { type: 'f', value: null }\n })\n\n this.setAttributes(data)\n\n this.makeTexture()\n this.makeMapping()\n }\n\n makeMaterial () {\n super.makeMaterial()\n\n const tex = this.texture\n\n const m = this.material\n m.transparent = true\n m.extensions.derivatives = true\n m.lights = false\n m.uniforms.fontTexture.value = tex\n m.needsUpdate = true\n\n const wm = this.wireframeMaterial\n wm.transparent = true\n wm.extensions.derivatives = true\n wm.lights = false\n wm.uniforms.fontTexture.value = tex\n wm.needsUpdate = true\n\n const pm = this.pickingMaterial\n pm.extensions.derivatives = true\n pm.lights = false\n pm.uniforms.fontTexture.value = tex\n pm.needsUpdate = true\n }\n\n setAttributes (data: Partial = {}) {\n let position, size, color\n let aPosition, inputSize, aColor\n\n const text = this.text\n const attributes = this.geometry.attributes as any // TODO\n\n if (data.position) {\n position = data.position\n aPosition = attributes.position.array\n attributes.position.needsUpdate = true\n }\n\n if (data.size) {\n size = data.size\n inputSize = attributes.inputSize.array\n attributes.inputSize.needsUpdate = true\n }\n\n if (data.color) {\n color = data.color\n aColor = attributes.color.array\n attributes.color.needsUpdate = true\n }\n\n const n = this.positionCount\n\n let j, o\n let iCharAll = 0\n let txt, iChar, nChar\n\n for (let v = 0; v < n; ++v) {\n o = 3 * v\n txt = text[ v ]\n nChar = txt.length\n if (this.parameters.showBackground) nChar += 1\n\n for (iChar = 0; iChar < nChar; ++iChar, ++iCharAll) {\n for (let m = 0; m < 4; m++) {\n j = iCharAll * 4 * 3 + (3 * m)\n\n if (position) {\n aPosition[ j ] = position[ o ]\n aPosition[ j + 1 ] = position[ o + 1 ]\n aPosition[ j + 2 ] = position[ o + 2 ]\n }\n\n if (size) {\n inputSize[ (iCharAll * 4) + m ] = size[ v ]\n }\n\n if (color) {\n aColor[ j ] = color[ o ]\n aColor[ j + 1 ] = color[ o + 1 ]\n aColor[ j + 2 ] = color[ o + 2 ]\n }\n }\n }\n }\n }\n\n makeTexture () {\n this.textAtlas = getTextAtlas({\n font: this.parameters.fontFamily,\n style: this.parameters.fontStyle,\n weight: this.parameters.fontWeight,\n size: this.parameters.fontSize\n })\n\n this.texture = this.textAtlas.texture\n }\n\n makeMapping () {\n const ta = this.textAtlas\n const text = this.text\n const attachment = this.parameters.attachment\n const margin = (ta.lineHeight * this.parameters.backgroundMargin * 0.1) - 10\n\n const attribs = this.geometry.attributes as any // TODO\n const inputTexCoord = attribs.inputTexCoord.array\n const inputMapping = attribs.mapping.array\n\n const n = this.positionCount\n let iCharAll = 0\n let c, i, txt, xadvance, iChar, nChar, xShift, yShift\n\n for (let v = 0; v < n; ++v) {\n txt = text[ v ]\n xadvance = 0\n nChar = txt.length\n\n // calculate width\n for (iChar = 0; iChar < nChar; ++iChar) {\n c = ta.get(txt[ iChar ])\n xadvance += c.w - 2 * ta.parameters.outline\n }\n\n // attachment\n if (attachment.startsWith('top')) {\n yShift = ta.lineHeight / 1.25\n } else if (attachment.startsWith('middle')) {\n yShift = ta.lineHeight / 2.5\n } else {\n yShift = 0 // \"bottom\"\n }\n if (attachment.endsWith('right')) {\n xShift = xadvance\n } else if (attachment.endsWith('center')) {\n xShift = xadvance / 2\n } else {\n xShift = 0 // \"left\"\n }\n xShift += ta.parameters.outline\n yShift += ta.parameters.outline\n\n // background\n if (this.parameters.showBackground) {\n i = iCharAll * 2 * 4\n inputMapping[ i + 0 ] = -ta.lineHeight / 6 - xShift - margin // top left\n inputMapping[ i + 1 ] = ta.lineHeight - yShift + margin\n inputMapping[ i + 2 ] = -ta.lineHeight / 6 - xShift - margin // bottom left\n inputMapping[ i + 3 ] = 0 - yShift - margin\n inputMapping[ i + 4 ] = xadvance + ta.lineHeight / 6 - xShift + 2 * ta.parameters.outline + margin // top right\n inputMapping[ i + 5 ] = ta.lineHeight - yShift + margin\n inputMapping[ i + 6 ] = xadvance + ta.lineHeight / 6 - xShift + 2 * ta.parameters.outline + margin // bottom right\n inputMapping[ i + 7 ] = 0 - yShift - margin\n inputTexCoord[ i + 0 ] = 10\n inputTexCoord[ i + 2 ] = 10\n inputTexCoord[ i + 4 ] = 10\n inputTexCoord[ i + 6 ] = 10\n iCharAll += 1\n }\n\n xadvance = 0\n\n for (iChar = 0; iChar < nChar; ++iChar, ++iCharAll) {\n c = ta.get(txt[ iChar ])\n i = iCharAll * 2 * 4\n\n inputMapping[ i + 0 ] = xadvance - xShift // top left\n inputMapping[ i + 1 ] = c.h - yShift\n inputMapping[ i + 2 ] = xadvance - xShift // bottom left\n inputMapping[ i + 3 ] = 0 - yShift\n inputMapping[ i + 4 ] = xadvance + c.w - xShift // top right\n inputMapping[ i + 5 ] = c.h - yShift\n inputMapping[ i + 6 ] = xadvance + c.w - xShift // bottom right\n inputMapping[ i + 7 ] = 0 - yShift\n\n const texWidth = ta.parameters.width\n const texHeight = ta.parameters.height\n\n const texCoords = [\n c.x / texWidth, c.y / texHeight, // top left\n c.x / texWidth, (c.y + c.h) / texHeight, // bottom left\n (c.x + c.w) / texWidth, c.y / texHeight, // top right\n (c.x + c.w) / texWidth, (c.y + c.h) / texHeight // bottom right\n ]\n inputTexCoord.set(texCoords, i)\n\n xadvance += c.w - 2 * ta.parameters.outline\n }\n }\n\n attribs.inputTexCoord.needsUpdate = true\n attribs.mapping.needsUpdate = true\n }\n\n getDefines (type: BufferTypes) {\n const defines = super.getDefines(type)\n\n if (this.parameters.fixedSize) {\n defines.FIXED_SIZE = 1\n }\n\n return defines\n }\n\n setUniforms (data: any) { // TODO\n if (data && (\n data.fontFamily !== undefined ||\n data.fontStyle !== undefined ||\n data.fontWeight !== undefined ||\n data.fontSize !== undefined\n )) {\n this.makeTexture()\n this.makeMapping()\n this.texture.needsUpdate = true\n data.fontTexture = this.texture\n }\n\n super.setUniforms(data)\n }\n}\n\nBufferRegistry.add('text', TextBuffer)\n\nexport default TextBuffer\n","/**\n * @file Wide Line Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3 required for declaration only\nimport { Vector2, Vector3, Matrix4 } from 'three'\n\nimport '../shader/WideLine.vert'\nimport '../shader/WideLine.frag'\n\nimport { BufferRegistry } from '../globals'\nimport MappedQuadBuffer from './mappedquad-buffer'\nimport { BufferDefaultParameters, BufferParameterTypes, BufferData, BufferParameters } from './buffer'\n\nexport interface WideLineBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n color2: Float32Array\n}\n\nexport const WideLineBufferDefaultParameters = Object.assign({\n linewidth: 2\n}, BufferDefaultParameters)\nexport type WideLineBufferParameters = BufferParameters & { linewidth: number }\n\nconst WideLineBufferParameterTypes = Object.assign({\n linewidth: { uniform: true }\n}, BufferParameterTypes)\n\n/**\n * Wide Line buffer. Draws lines with a fixed width in pixels.\n *\n * @example\n * var lineBuffer = new WideLineBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ])\n * });\n */\nclass WideLineBuffer extends MappedQuadBuffer {\n parameterTypes = WideLineBufferParameterTypes\n get defaultParameters() { return WideLineBufferDefaultParameters }\n parameters: WideLineBufferParameters\n\n vertexShader = 'WideLine.vert'\n fragmentShader ='WideLine.frag'\n\n constructor (data: Partial, params: Partial = {}) {\n super(data, params)\n\n if (!data.color2 && data.color) data.color2 = data.color\n\n this.addUniforms({\n 'linewidth': { value: this.parameters.linewidth },\n 'resolution': { value: new Vector2() },\n 'projectionMatrixInverse': { value: new Matrix4() }\n })\n\n this.addAttributes({\n 'position1': { type: 'v3', value: null },\n 'position2': { type: 'v3', value: null },\n 'color2': { type: 'c', value: null }\n })\n\n this.setAttributes(data)\n this.makeMapping()\n }\n\n setParameters (params: Partial) {\n super.setParameters(params)\n }\n}\n\nBufferRegistry.add('wideline', WideLineBuffer)\n\nexport default WideLineBuffer\n","/**\n * @file Angle Representation\n * @author Fred Ludlow \n * @private\n */\nimport { Color } from 'three'\n\nimport { RepresentationRegistry } from '../globals'\nimport MeasurementRepresentation, { parseNestedAtoms, calcArcPoint, MeasurementRepresentationParameters, LabelDataField } from './measurement-representation'\nimport { defaults } from '../utils'\n\nimport MeshBuffer from '../buffer/mesh-buffer'\nimport TextBuffer, { TextBufferData, TextBufferParameters } from '../buffer/text-buffer'\nimport WideLineBuffer, { WideLineBufferData } from '../buffer/wideline-buffer'\n\nimport { v3add, v3cross, v3dot, v3fromArray, v3length, v3new,\n v3normalize, v3sub, v3toArray } from '../math/vector-utils'\nimport { copyArray, uniformArray, uniformArray3 } from '../math/array-utils'\nimport { RAD2DEG } from '../math/math-constants'\nimport { getFixedLengthWrappedDashData } from '../geometry/dash'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { BufferData } from '../buffer/buffer';\nimport { StructureRepresentationData, StructureRepresentationParameters } from './structure-representation';\n\n/**\n * @typedef {Object} AngleRepresentationParameters - angle representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n * @mixes MeasurementRepresentationParameters\n *\n * @property {String} atomTriple - list of triplets of selection strings\n * or atom indices\n * @property {Boolean} vectorVisible - Indicate the 3 points for each angle by drawing lines 1-2-3\n * @property {Boolean} arcVisible - Show the arc outline for each angle\n * @property {Number} lineOpacity - opacity for the line part of the representation\n * @property {Number} linewidth - width for line part of representation\n * @property {Boolean} sectorVisible - Show the filled arc for each angle\n */\n\nexport interface AngleRepresentationParameters extends MeasurementRepresentationParameters {\n atomTriple: (number|string)[][]\n vectorVisible: boolean\n arcVisible: boolean\n lineOpacity: number\n lineWidth: number\n sectorVisible: boolean\n}\n\n/**\n * Angle representation object\n *\n * Reperesentation consists of four parts, visibility can be set for each\n * label - the text label with the angle size\n * vectors - lines joining the three points\n * sector - triangles representing the angle\n * arc - line bordering the sector\n *\n * @param {Structure} structure - the structure to measure angles in\n * @param {Viewer} viewer - a viewer object\n * @param {AngleRepresentationParameters} params - angle representation parameters\n */\nclass AngleRepresentation extends MeasurementRepresentation {\n protected atomTriple: (number|string)[][]\n protected vectorVisible: boolean\n protected arcVisible: boolean\n protected lineOpacity: number\n protected lineWidth: number\n protected sectorVisible: boolean\n protected vectorBuffer: WideLineBuffer\n arcLength: number\n sectorLength: number\n arcBuffer: WideLineBuffer\n sectorBuffer: MeshBuffer\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'angle'\n\n this.parameters = Object.assign({\n atomTriple: {\n type: 'hidden', rebuild: true\n },\n vectorVisible: {\n type: 'boolean', default: true\n },\n arcVisible: {\n type: 'boolean', default: true\n },\n sectorVisible: {\n type: 'boolean', default: true\n }\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.side = defaults(p.side, 'double')\n p.opacity = defaults(p.opacity, 0.5)\n\n this.atomTriple = defaults(p.atomTriple, [])\n this.arcVisible = defaults(p.arcVisible, true)\n this.sectorVisible = defaults(p.sectorVisible, true)\n this.vectorVisible = defaults(p.vectorVisible, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n if (!sview.atomCount || !this.atomTriple.length) return\n\n const atomPosition = atomTriplePositions(sview, this.atomTriple)\n const angleData = getAngleData(atomPosition)\n const n = this.n = angleData.labelPosition.length / 3\n\n const labelColor = new Color(this.labelColor)\n\n // Create buffers\n this.textBuffer = new TextBuffer({\n position: angleData.labelPosition,\n size: uniformArray(n, this.labelSize),\n color: uniformArray3(n, labelColor.r, labelColor.g, labelColor.b),\n text: angleData.labelText\n } as TextBufferData, this.getLabelBufferParams() as TextBufferParameters)\n\n const c = new Color(this.colorValue)\n\n this.vectorBuffer = new WideLineBuffer(\n getFixedLengthWrappedDashData({\n position1: angleData.vectorPosition1,\n position2: angleData.vectorPosition2,\n color: uniformArray3(2 * n, c.r, c.g, c.b),\n color2: uniformArray3(2 * n, c.r, c.g, c.b)\n } as WideLineBufferData),\n this.getBufferParams({\n linewidth: this.linewidth,\n visible: this.vectorVisible,\n opacity: this.lineOpacity\n })\n )\n\n this.arcLength = angleData.arcPosition1.length / 3\n\n this.arcBuffer = new WideLineBuffer(\n getFixedLengthWrappedDashData({\n position1: angleData.arcPosition1,\n position2: angleData.arcPosition2,\n color: uniformArray3(this.arcLength, c.r, c.g, c.b),\n color2: uniformArray3(this.arcLength, c.r, c.g, c.b)\n } as WideLineBufferData), this.getBufferParams({\n linewidth: this.linewidth,\n visible: this.arcVisible,\n opacity: this.lineOpacity\n }))\n\n this.sectorLength = angleData.sectorPosition.length / 3\n\n this.sectorBuffer = new MeshBuffer({\n position: angleData.sectorPosition,\n color: uniformArray3(this.sectorLength, c.r, c.g, c.b)\n } as BufferData, this.getBufferParams({\n visible: this.sectorVisible\n }))\n\n return {\n bufferList: [\n this.textBuffer,\n this.vectorBuffer,\n this.arcBuffer,\n this.sectorBuffer\n ]\n }\n }\n\n updateData (what: LabelDataField & {color?: boolean}, data: StructureRepresentationData) {\n super.updateData(what, data)\n const vectorData = {}\n const arcData = {}\n const sectorData = {}\n\n if (what.color) {\n const c = new Color(this.colorValue)\n Object.assign(vectorData, {\n color: uniformArray3(this.n * 2, c.r, c.g, c.b),\n color2: uniformArray3(this.n * 2, c.r, c.g, c.b)\n })\n Object.assign(arcData, {\n color: uniformArray3(this.arcLength, c.r, c.g, c.b),\n color2: uniformArray3(this.arcLength, c.r, c.g, c.b)\n })\n Object.assign(sectorData, {\n color: uniformArray3(this.sectorLength, c.r, c.g, c.b)\n })\n }\n\n // if (what.sectorOpacity) {\n // this.sectorBuffer.opacity = what.sectorOpacity\n // }\n\n this.vectorBuffer.setAttributes(vectorData)\n this.arcBuffer.setAttributes(arcData)\n this.sectorBuffer.setAttributes(sectorData)\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n super.setParameters(params, what, rebuild)\n\n if (params && (\n params.vectorVisible !== undefined ||\n params.arcVisible !== undefined ||\n params.sectorVisible !== undefined)) {\n this.setVisibility(this.visible)\n }\n\n if (params && params.lineOpacity) {\n this.vectorBuffer.setParameters({ opacity: params.lineOpacity })\n this.arcBuffer.setParameters({ opacity: params.lineOpacity })\n }\n\n if (params && params.opacity !== undefined) {\n this.vectorBuffer.setParameters({ opacity: this.lineOpacity })\n this.arcBuffer.setParameters({ opacity: this.lineOpacity })\n }\n\n if (params && params.linewidth) {\n this.vectorBuffer.setParameters({ linewidth: params.linewidth })\n this.arcBuffer.setParameters({ linewidth: params.linewidth })\n }\n\n return this\n }\n\n setVisibility (value: boolean, noRenderRequest?: boolean) {\n super.setVisibility(value, true)\n\n if (this.vectorBuffer) {\n this.vectorBuffer.setVisibility(this.vectorVisible && this.visible)\n }\n\n if (this.arcBuffer) {\n this.arcBuffer.setVisibility(this.arcVisible && this.visible)\n }\n\n if (this.sectorBuffer) {\n this.sectorBuffer.setVisibility(this.sectorVisible && this.visible)\n }\n\n if (!noRenderRequest) this.viewer.requestRender()\n\n return this\n }\n}\n\n/**\n * Ensure mid point does not coincide with first or second\n * @param {Float32Array} position 9*nAngle array of coordinates\n * @return {Float32Array} Filtered position array, may be shorter\n */\nfunction validatePositions (position: Float32Array) {\n const include = []\n const n = position.length / 9\n for (let i = 0; i < n; i++) {\n // Check that first point not same as second and that second not same as third\n let okay = true\n for (let j = i; j < i + 3; j += 3) {\n if (position[j] === position[j + 3] &&\n position[j + 1] === position[j + 4] &&\n position[j + 2] === position[j + 5]) {\n okay = false\n }\n }\n if (okay) include.push(i)\n }\n const outPosition = new Float32Array(include.length * 9)\n let outIdx = 0\n include.forEach(function (i) {\n copyArray(position, outPosition, i * 9, outIdx * 9, 9)\n outIdx++\n })\n return outPosition\n}\n\nfunction atomTriplePositions (sview: StructureView, atomTriple: (number|string)[][]) {\n return validatePositions(parseNestedAtoms(sview, atomTriple))\n}\n\n/**\n * Converts triple positions into data required to build various buffers.\n */\nfunction getAngleData (position: Float32Array, params: Partial = {}) {\n const angleStep = defaults(params.angleStep, Math.PI / 90)\n const n = position.length / 9\n const angles = new Float32Array(n)\n const labelPosition = new Float32Array(n * 3)\n const labelText = new Array(n)\n\n const vectorPosition1 = new Float32Array(n * 6) // Two lines per angle\n const vectorPosition2 = new Float32Array(n * 6)\n\n const arcPositionTmp1 = new Array(n) // Start points for arc lines\n const arcPositionTmp2 = new Array(n) // End points for arc lines\n const sectorPositionTmp = new Array(n) // Triangle points\n\n let totalSegments = 0\n\n // Re-used vectors etc\n const p1 = v3new() // Positions of points for each angel\n const p2 = v3new()\n const p3 = v3new()\n const v21 = v3new() // Vectors\n const v23 = v3new()\n const cross = v3new() // Cross product v21xv23\n const cross2 = v3new() // In-plane cross product v21 x (v21 x v23)\n const labelTmp = v3new()\n const arcPoint = v3new()\n\n for (var i = 0; i < n; i++) {\n let p = 9 * i\n v3fromArray(p1, position, p)\n v3fromArray(p2, position, p + 3)\n v3fromArray(p3, position, p + 6)\n\n let v = 6 * i\n v3toArray(p1, vectorPosition1, v)\n v3toArray(p2, vectorPosition2, v)\n v3toArray(p2, vectorPosition1, v + 3)\n v3toArray(p3, vectorPosition2, v + 3)\n\n v3sub(v21, p1, p2)\n v3sub(v23, p3, p2)\n\n v3normalize(v21, v21) // validatePositions ensures valid\n v3normalize(v23, v23)\n\n v3cross(cross, v21, v23)\n const crossLength = v3length(cross)\n const dot = v3dot(v21, v23)\n\n const angle = angles[i] = Math.atan2(crossLength, dot)\n labelText[i] = (RAD2DEG * angle).toFixed(1) + String.fromCharCode(0x00B0)\n\n if (v3length(cross) === 0.0) {\n // Angle exactly 0/180, pick an arbitrary direction\n cross[ 0 ] = 1.0\n cross[ 1 ] = 0.0\n cross[ 2 ] = 0.0\n }\n v3cross(cross2, cross, v21)\n v3normalize(cross2, cross2)\n\n calcArcPoint(labelTmp, p2, v21, cross2, angle / 2.0)\n // TODO: Scale label position?\n v3toArray(labelTmp, labelPosition, 3 * i)\n\n // Build the arc and sector\n\n const nSegments = Math.ceil(angle / angleStep)\n const sectorVertices = new Float32Array(nSegments * 9)\n sectorPositionTmp[ i ] = sectorVertices\n const arcVertices1 = new Float32Array(nSegments * 3)\n const arcVertices2 = new Float32Array(nSegments * 3)\n arcPositionTmp1[ i ] = arcVertices1\n arcPositionTmp2[ i ] = arcVertices2\n\n v3add(arcPoint, p2, v21) // Our initial arc point\n\n const appendArcSection = function (a: number, j: number) {\n const si = j * 9\n const ai = j * 3\n v3toArray(p2, sectorVertices, si)\n v3toArray(arcPoint, sectorVertices, si + 3)\n v3toArray(arcPoint, arcVertices1, ai)\n\n calcArcPoint(arcPoint, p2, v21, cross2, a)\n\n v3toArray(arcPoint, sectorVertices, si + 6)\n v3toArray(arcPoint, arcVertices2, ai)\n }\n\n let j = 0\n for (let a = angleStep; a < angle; a += angleStep) {\n appendArcSection(a, j)\n j++\n }\n appendArcSection(angle, j)\n totalSegments += nSegments\n }\n\n // Flatten nested arrays of arc/segment points\n const arcSize = totalSegments * 3\n const sectorSize = totalSegments * 9\n const arcPosition1 = new Float32Array(arcSize)\n const arcPosition2 = new Float32Array(arcSize)\n const sectorPosition = new Float32Array(sectorSize)\n\n let sectorOffset = 0\n let arcOffset = 0\n for (let i = 0; i < n; i++) {\n const ap1 = arcPositionTmp1[ i ]\n const ap2 = arcPositionTmp2[ i ]\n copyArray(ap1, arcPosition1, 0, arcOffset, ap1.length)\n copyArray(ap2, arcPosition2, 0, arcOffset, ap2.length)\n arcOffset += ap1.length // === ap2.length\n\n const sp = sectorPositionTmp[ i ]\n copyArray(sp, sectorPosition, 0, sectorOffset, sp.length)\n sectorOffset += sp.length\n }\n\n return {\n labelPosition,\n labelText,\n vectorPosition1,\n vectorPosition2,\n arcPosition1,\n arcPosition2,\n sectorPosition\n }\n}\n\nRepresentationRegistry.add('angle', AngleRepresentation)\n\nexport default AngleRepresentation\n","/**\n * @file Cylinder Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3, CylinderBufferGeometry } from 'three'\n\nimport { defaults } from '../utils'\nimport { calculateCenterArray, serialBlockArray } from '../math/array-utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { CylinderBufferData } from './cylinder-buffer'\nimport { BufferDefaultParameters, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\nconst eye = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3(0, 1, 0)\n\nexport const CylinderGeometryBufferDefaultParameters = Object.assign({\n radialSegments: 1,\n openEnded: true\n}, BufferDefaultParameters)\nexport type CylinderGeometryBufferParameters = BufferParameters & {radialSegments: number, openEnded: boolean}\n\nfunction getData (data: CylinderBufferData, params: Partial = {}) {\n const geo = getGeo(params)\n\n const n = data.position1.length\n\n const geoLength = (geo.attributes as any).position.array.length / 3\n const count = n / 3\n const primitiveId = new Float32Array(count * 2 * geoLength)\n serialBlockArray(count, geoLength, 0, primitiveId)\n serialBlockArray(count, geoLength, count * geoLength, primitiveId)\n\n const position = new Float32Array(n * 2)\n const color = new Float32Array(n * 2)\n\n return {\n position, color, primitiveId, picking: data.picking\n }\n}\n\nfunction getGeo (params: Partial = {}) {\n const radialSegments = defaults(params.radialSegments, 10)\n const openEnded = defaults(params.openEnded, true)\n const matrix = new Matrix4().makeRotationX(Math.PI / 2)\n\n const geo = new CylinderBufferGeometry(\n 1, // radiusTop,\n 1, // radiusBottom,\n 1, // height,\n radialSegments, // radialSegments,\n 1, // heightSegments,\n openEnded // openEnded\n )\n geo.applyMatrix4(matrix)\n\n return geo\n}\n\n/**\n * Cylinder geometry buffer.\n *\n * @example\n * var cylinderGeometryBuffer = new CylinderGeometryBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass CylinderGeometryBuffer extends GeometryBuffer {\n updateNormals = true\n\n get defaultParameters() { return CylinderGeometryBufferDefaultParameters }\n parameters: CylinderGeometryBufferParameters\n\n __center: Float32Array\n _position: Float32Array\n _color: Float32Array\n _from: Float32Array\n _to: Float32Array\n _radius: Float32Array\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - from colors\n * @param {Float32Array} data.color2 - to colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n */\n constructor (data: CylinderBufferData, params: Partial = {}) {\n super(getData(data, params), params, getGeo(params))\n\n const n = data.position1.length\n const m = data.radius.length\n\n this.__center = new Float32Array(n)\n this._position = new Float32Array(n * 2)\n this._color = new Float32Array(n * 2)\n this._from = new Float32Array(n * 2)\n this._to = new Float32Array(n * 2)\n this._radius = new Float32Array(m * 2)\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n eye.fromArray(this._from as any, i3)\n target.fromArray(this._to as any, i3)\n matrix.lookAt(eye, target, up)\n\n const r = this._radius[ i ]\n scale.set(r, r, eye.distanceTo(target))\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n const meshData: Partial = {}\n\n if (data.position1 && data.position2) {\n calculateCenterArray(\n data.position1, data.position2, this.__center\n )\n calculateCenterArray(\n data.position1, this.__center, this._position\n )\n calculateCenterArray(\n this.__center, data.position2, this._position, data.position1.length\n )\n this._from.set(data.position1)\n this._from.set(this.__center, data.position1.length)\n this._to.set(this.__center)\n this._to.set(data.position2, this.__center.length)\n meshData.position = this._position\n }\n\n if (data.color && data.color2) {\n this._color.set(data.color)\n this._color.set(data.color2, data.color.length)\n meshData.color = this._color\n }\n\n if (data.radius) {\n this._radius.set(data.radius)\n this._radius.set(data.radius, data.radius.length)\n meshData.radius = this._radius\n }\n\n super.setAttributes(meshData, initNormals)\n }\n}\n\nexport default CylinderGeometryBuffer\n","/**\n * @file Mapped Aligned Box Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { BufferParameters, BufferData } from './buffer'\nimport MappedBuffer from './mapped-buffer'\n\n// +Y /\n// 0**********2\n// * | / **\n// * |/ * *\n// -----------3---- +X\n// * /| * *\n// * / | * *\n// 1/**|******4\n// / | * *\n// / | ** \n// +Z | 5 \nconst mapping = new Float32Array([\n -1.0, 1.0, -1.0,\n -1.0, -1.0, -1.0,\n 1.0, 1.0, -1.0,\n 1.0, 1.0, 1.0,\n 1.0, -1.0, -1.0,\n 1.0, -1.0, 1.0\n])\n\nconst mappingIndices = new Uint16Array([\n 0, 1, 2,\n 1, 4, 2,\n 2, 4, 3,\n 4, 5, 3\n])\n\n/**\n * Mapped Aligned box buffer. Draws boxes where one side is always screen-space aligned.\n * Used to render cylinder imposters.\n * @interface\n */\nclass MappedAlignedBoxBuffer extends MappedBuffer {\n constructor(data: BufferData, params: Partial = {}) {\n super('v3', data, params)\n }\n get mapping () { return mapping }\n get mappingIndices () { return mappingIndices }\n get mappingIndicesSize () { return 12 }\n get mappingSize () { return 6 }\n get mappingItemSize () { return 3 }\n}\n\nexport default MappedAlignedBoxBuffer\n","/**\n * @file Cylinder Impostor Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3 required for declaration only\nimport { Matrix4, Vector3 } from 'three'\n\nimport '../shader/CylinderImpostor.vert'\nimport '../shader/CylinderImpostor.frag'\n\nimport MappedAlignedBoxBuffer from './mappedalignedbox-buffer'\nimport { BufferDefaultParameters, BufferParameters, BufferParameterTypes, BufferTypes } from './buffer'\nimport { CylinderBufferData } from './cylinder-buffer'\n\nexport const CylinderImpostorBufferDefaultParameters = Object.assign({\n openEnded: false\n}, BufferDefaultParameters)\nexport type CylinderImpostorBufferParameters = BufferParameters & { openEnded: boolean }\n\nconst CylinderImpostorBufferParameterTypes = Object.assign({\n openEnded: { updateShader: true }\n}, BufferParameterTypes)\n\n/**\n * Cylinder impostor buffer.\n *\n * @example\n * var cylinderimpostorBuffer = new CylinderImpostorBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass CylinderImpostorBuffer extends MappedAlignedBoxBuffer {\n parameterTypes = CylinderImpostorBufferParameterTypes\n get defaultParameters() { return CylinderImpostorBufferDefaultParameters }\n parameters: CylinderImpostorBufferParameters\n\n isImpostor = true\n vertexShader = 'CylinderImpostor.vert'\n fragmentShader = 'CylinderImpostor.frag'\n\n /**\n * make cylinder impostor buffer\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - from colors\n * @param {Float32Array} data.color2 - to colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} data.picking - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: CylinderBufferData, params: Partial = {}) {\n super(data, params)\n\n this.addUniforms({\n 'modelViewMatrixInverse': { value: new Matrix4() },\n 'ortho': { value: 0.0 }\n })\n\n this.addAttributes({\n 'position1': { type: 'v3', value: null },\n 'position2': { type: 'v3', value: null },\n 'color2': { type: 'c', value: null },\n 'radius': { type: 'f', value: null }\n })\n\n this.setAttributes(data)\n this.makeMapping()\n }\n\n getDefines (type?: BufferTypes) {\n const defines = MappedAlignedBoxBuffer.prototype.getDefines.call(this, type)\n\n if (!this.parameters.openEnded) {\n defines.CAP = 1\n }\n\n return defines\n }\n}\n\nexport default CylinderImpostorBuffer\n","/**\n * @file Cylinder Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import required for declaration only\nimport { Vector3, Matrix4 } from 'three'\nimport { BufferRegistry, ExtensionFragDepth } from '../globals'\nimport CylinderGeometryBuffer, { CylinderGeometryBufferDefaultParameters, CylinderGeometryBufferParameters } from './cylindergeometry-buffer'\nimport CylinderImpostorBuffer, { CylinderImpostorBufferDefaultParameters, CylinderImpostorBufferParameters } from './cylinderimpostor-buffer'\nimport { BufferData } from './buffer'\n\nexport interface CylinderBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n color2: Float32Array\n radius: Float32Array\n}\n\nexport const CylinderBufferDefaultParameters = Object.assign({\n disableImpostor: false\n}, CylinderGeometryBufferDefaultParameters, CylinderImpostorBufferDefaultParameters)\nexport type CylinderBufferParameters = (CylinderGeometryBufferParameters & {disableImpostor: boolean}) | (CylinderImpostorBufferParameters & {disableImpostor: boolean})\n\nclass CylinderBufferImpl {\n constructor (data: CylinderBufferData, params: Partial = {}) {\n if (!data.color2 && data.color) data.color2 = data.color\n if (!ExtensionFragDepth || (params && params.disableImpostor)) {\n return new CylinderGeometryBuffer(data, params)\n } else {\n return new CylinderImpostorBuffer(data, params)\n }\n }\n}\n\n/**\n * Cylinder buffer. Depending on the value {@link ExtensionFragDepth} and\n * `params.disableImpostor` the constructor returns either a\n * {@link CylinderGeometryBuffer} or a {@link CylinderImpostorBuffer}\n * @implements {Buffer}\n *\n * @example\n * var cylinderBuffer = new CylinderBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\n//@ts-expect-error Incompatible constructor signatures\nconst CylinderBuffer: {\n new(data: CylinderBufferData, params: Partial): CylinderGeometryBuffer | CylinderImpostorBuffer;\n} = CylinderBufferImpl;\n\ntype CylinderBuffer = CylinderGeometryBuffer | CylinderImpostorBuffer;\n\nBufferRegistry.add('cylinder', CylinderBuffer)\n\nexport default CylinderBuffer\n","/**\n * @file Axes Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { Color, Vector3 } from 'three'\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { AxesPicker } from '../utils/picker'\nimport { uniformArray, uniformArray3 } from '../math/array-utils'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport CylinderBuffer, { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport StructureView from '../structure/structure-view';\nimport Viewer from '../viewer/viewer';\nimport { Structure } from '../ngl';\nimport { AtomDataFields } from '../structure/structure-data';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport PrincipalAxes from '../math/principal-axes';\n\nexport interface AxesRepresentationParameters extends StructureRepresentationParameters {\n showAxes: boolean\n showBox: boolean\n}\n\n/**\n * Axes representation. Show principal axes and/or a box aligned with them\n * that fits the structure or selection.\n *\n * __Name:__ _axes_\n *\n * @example\n * stage.loadFile( \"rcsb://3pqr\", {\n * assembly: \"BU1\"\n * } ).then( function( o ){\n * o.addRepresentation( \"cartoon\" );\n * o.addRepresentation( \"axes\", {\n * sele: \"RET\", showAxes: false, showBox: true, radius: 0.2\n * } );\n * o.addRepresentation( \"ball+stick\", { sele: \"RET\" } );\n * o.addRepresentation( \"axes\", {\n * sele: \":B and backbone\", showAxes: false, showBox: true, radius: 0.2\n * } );\n * stage.autoView();\n * var pa = o.structure.getPrincipalAxes();\n * stage.animationControls.rotate( pa.getRotationQuaternion(), 1500 );\n * } );\n */\nclass AxesRepresentation extends StructureRepresentation {\n \n protected showAxes: boolean\n protected showBox: boolean\n protected sphereBuffer: SphereBuffer\n protected cylinderBuffer: CylinderBuffer\n /**\n * @param {Structure} structure - the structure object\n * @param {Viewer} viewer - the viewer object\n * @param {StructureRepresentationParameters} params - parameters object\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'axes'\n\n this.parameters = Object.assign({\n\n radiusSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n sphereDetail: true,\n radialSegments: true,\n disableImpostor: true,\n showAxes: {\n type: 'boolean', rebuild: true\n },\n showBox: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n assembly: null\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.radiusSize = defaults(p.radiusSize, 0.5)\n p.colorValue = defaults(p.colorValue, 'lightgreen')\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.showAxes = defaults(p.showAxes, true)\n this.showBox = defaults(p.showBox, false)\n\n super.init(p)\n }\n\n getPrincipalAxes (): PrincipalAxes {\n let selection\n const assembly = this.getAssembly()\n\n if (assembly) {\n selection = assembly.partList[ 0 ].getSelection()\n }\n\n return this.structureView.getPrincipalAxes(selection)\n }\n\n getAxesData (sview: StructureView) {\n const pa = this.getPrincipalAxes()\n const c = new Color(this.colorValue)\n\n let vn = 0\n let en = 0\n\n if (this.showAxes) {\n vn += 6\n en += 3\n }\n\n if (this.showBox) {\n vn += 8\n en += 12\n }\n\n const vertexPosition = new Float32Array(3 * vn)\n const vertexColor = uniformArray3(vn, c.r, c.g, c.b)\n const vertexRadius = uniformArray(vn, this.radiusSize)\n\n const edgePosition1 = new Float32Array(3 * en)\n const edgePosition2 = new Float32Array(3 * en)\n const edgeColor = uniformArray3(en, c.r, c.g, c.b)\n const edgeRadius = uniformArray(en, this.radiusSize)\n\n let offset = 0\n\n if (this.showAxes) {\n const addAxis = function (v1: Vector3, v2: Vector3) {\n v1.toArray(vertexPosition as any, offset * 2)\n v2.toArray(vertexPosition as any, offset * 2 + 3)\n v1.toArray(edgePosition1 as any, offset)\n v2.toArray(edgePosition2 as any, offset)\n offset += 3\n }\n\n addAxis(pa.begA, pa.endA)\n addAxis(pa.begB, pa.endB)\n addAxis(pa.begC, pa.endC)\n }\n\n if (this.showBox) {\n const v = new Vector3()\n const { d1a, d2a, d3a, d1b, d2b, d3b } = pa.getProjectedScaleForAtoms(sview)\n\n // console.log(d1a, d2a, d3a, d1b, d2b, d3b)\n\n let offset2 = offset * 2\n const addCorner = function (d1: number, d2: number, d3: number) {\n v.copy(pa.center)\n .addScaledVector(pa.normVecA, d1)\n .addScaledVector(pa.normVecB, d2)\n .addScaledVector(pa.normVecC, d3)\n v.toArray(vertexPosition as any, offset2)\n offset2 += 3\n }\n addCorner(d1a, d2a, d3a)\n addCorner(d1a, d2a, d3b)\n addCorner(d1a, d2b, d3b)\n addCorner(d1a, d2b, d3a)\n addCorner(d1b, d2b, d3b)\n addCorner(d1b, d2b, d3a)\n addCorner(d1b, d2a, d3a)\n addCorner(d1b, d2a, d3b)\n\n let edgeOffset = offset\n const addEdge = function (a: number, b: number) {\n v.fromArray(vertexPosition as any, offset * 2 + a * 3)\n .toArray(edgePosition1 as any, edgeOffset)\n v.fromArray(vertexPosition as any, offset * 2 + b * 3)\n .toArray(edgePosition2 as any, edgeOffset)\n edgeOffset += 3\n }\n addEdge(0, 1)\n addEdge(0, 3)\n addEdge(0, 6)\n addEdge(1, 2)\n addEdge(1, 7)\n addEdge(2, 3)\n addEdge(2, 4)\n addEdge(3, 5)\n addEdge(4, 5)\n addEdge(4, 7)\n addEdge(5, 6)\n addEdge(6, 7)\n }\n\n const picker = new AxesPicker(pa)\n\n return {\n vertex: {\n position: vertexPosition,\n color: vertexColor,\n radius: vertexRadius,\n picking: picker\n },\n edge: {\n position1: edgePosition1,\n position2: edgePosition2,\n color: edgeColor,\n color2: edgeColor,\n radius: edgeRadius,\n picking: picker\n }\n }\n }\n\n create () {\n const axesData = this.getAxesData(this.structureView)\n\n this.sphereBuffer = new SphereBuffer(\n axesData.vertex as SphereBufferData,\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters\n )\n\n this.cylinderBuffer = new CylinderBuffer(\n axesData.edge as CylinderBufferData,\n this.getBufferParams({\n openEnded: true,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n this.dataList.push({\n sview: this.structureView,\n bufferList: [ this.sphereBuffer as SphereGeometryBuffer, this.cylinderBuffer as CylinderGeometryBuffer]\n })\n }\n\n createData (sview: StructureView): undefined {\n return\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n const axesData = this.getAxesData(data.sview as StructureView)\n const sphereData = {}\n const cylinderData = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {\n position: axesData.vertex.position\n })\n Object.assign(cylinderData, {\n position1: axesData.edge.position1,\n position2: axesData.edge.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {\n color: axesData.vertex.color as Float32Array\n })\n Object.assign(cylinderData, {\n color: axesData.edge.color as Float32Array,\n color2: axesData.edge.color as Float32Array\n })\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {\n radius: axesData.vertex.radius as Float32Array\n })\n Object.assign(cylinderData, {\n radius: axesData.edge.radius as Float32Array\n })\n }\n\n (this.sphereBuffer as SphereGeometryBuffer).setAttributes(sphereData);\n (this.cylinderBuffer as CylinderGeometryBuffer).setAttributes(cylinderData)\n }\n}\n\nRepresentationRegistry.add('axes', AxesRepresentation)\n\nexport default AxesRepresentation\n","/**\n * @file Ball And Stick Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { ExtensionFragDepth, RepresentationRegistry } from '../globals'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport CylinderBuffer, { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport WideLineBuffer from '../buffer/wideline-buffer'\nimport Viewer from '../viewer/viewer';\n// @ts-ignore: unused import Volume required for declaration only\nimport { Structure, Volume } from '../ngl';\nimport AtomProxy from '../proxy/atom-proxy';\nimport { AtomDataParams, BondDataParams, BondDataFields, AtomDataFields, BondData, AtomData } from '../structure/structure-data';\nimport StructureView from '../structure/structure-view';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\n// @ts-ignore: unused import Surface required for declaration only\nimport Surface from '../surface/surface';\n\nexport interface BallAndStickRepresentationParameters extends StructureRepresentationParameters {\n sphereDetail: number\n radialSegments: number\n openEnded: boolean\n disableImpostor: boolean\n aspectRatio: number\n lineOnly: boolean\n lineWidth: number\n cylinderOnly: boolean\n multipleBond: 'off' | 'symmetric' | 'offset'\n bondSpacing: number\n bondScale: number\n linewidth: number\n}\n\n/**\n * Ball And Stick representation parameter object. Extends {@link RepresentationParameters} and\n * {@link StructureRepresentationParameters}.\n *\n * @typedef {Object} BallAndStickRepresentationParameters - ball and stick representation parameters\n *\n * @property {Integer} sphereDetail - sphere quality (icosahedron subdivisions)\n * @property {Integer} radialSegments - cylinder quality (number of segments)\n * @property {Boolean} openEnded - capped or not\n * @property {Boolean} disableImpostor - disable use of raycasted impostors for rendering\n * @property {Float} aspectRatio - size difference between atom and bond radii\n * @property {Boolean} lineOnly - render only bonds, and only as lines\n * @property {Integer} linewidth - width of lines\n * @property {Boolean} cylinderOnly - render only bonds (no atoms)\n * @property {String} multipleBond - one off \"off\", \"symmetric\", \"offset\"\n * @property {Float} bondSpacing - spacing for multiple bond rendering\n * @property {Float} bondScale - scale/radius for multiple bond rendering\n */\n\n/**\n * Ball And Stick representation. Show atoms as spheres and bonds as cylinders.\n *\n * __Name:__ _ball+stick_\n *\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"ball+stick\" );\n * o.autoView();\n * } );\n */\nclass BallAndStickRepresentation extends StructureRepresentation {\n protected sphereDetail: number\n protected radialSegments: number\n protected openEnded: boolean\n protected disableImpostor: boolean\n protected aspectRatio: number\n protected lineOnly: boolean\n protected lineWidth: number\n protected cylinderOnly: boolean\n protected multipleBond: 'off' | 'symmetric' | 'offset'\n protected bondSpacing: number\n protected bondScale: number\n protected linewidth: number\n\n protected lineBuffer: WideLineBuffer\n /**\n * Create Ball And Stick representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {BallAndStickRepresentationParameters} params - ball and stick representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'ball+stick'\n\n this.parameters = Object.assign({\n\n sphereDetail: true,\n radialSegments: true,\n openEnded: true,\n disableImpostor: true,\n aspectRatio: {\n type: 'number', precision: 1, max: 10.0, min: 1.0\n },\n lineOnly: {\n type: 'boolean', rebuild: true\n },\n cylinderOnly: {\n type: 'boolean', rebuild: true\n },\n multipleBond: {\n type: 'select',\n rebuild: true,\n options: {\n 'off': 'off',\n 'symmetric': 'symmetric',\n 'offset': 'offset'\n }\n },\n bondScale: {\n type: 'number', precision: 2, max: 1.0, min: 0.01\n },\n bondSpacing: {\n type: 'number', precision: 2, max: 2.0, min: 0.5\n },\n linewidth: {\n type: 'integer', max: 50, min: 1, buffer: true\n }\n\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.radiusType = defaults(p.radiusType, 'size')\n p.radiusSize = defaults(p.radiusSize, 0.15)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.aspectRatio = defaults(p.aspectRatio, 2.0)\n this.lineOnly = defaults(p.lineOnly, false)\n this.cylinderOnly = defaults(p.cylinderOnly, false)\n this.multipleBond = defaults(p.multipleBond, 'off')\n this.bondSpacing = defaults(p.bondSpacing, 1.0)\n this.bondScale = defaults(p.bondScale, 0.4)\n this.linewidth = defaults(p.linewidth, 2)\n\n super.init(p)\n }\n\n getAtomRadius (atom: AtomProxy) {\n return this.aspectRatio * super.getAtomRadius(atom)\n }\n\n getAtomParams (what?: AtomDataFields, params?: Partial) {\n var p = super.getAtomParams(what, params)\n p.radiusParams.scale *= this.aspectRatio\n\n return p\n }\n\n getAtomData (sview: StructureView, what?: AtomDataFields, params?: Partial): AtomData {\n return sview.getAtomData(this.getAtomParams(what, params))\n }\n\n getBondParams (what?: BondDataFields, params?: Partial) {\n params = Object.assign({\n multipleBond: this.multipleBond,\n bondSpacing: this.bondSpacing,\n bondScale: this.bondScale\n }, params)\n\n return super.getBondParams(what, params)\n }\n\n getBondData (sview: StructureView, what?: BondDataFields, params?: Partial): BondData {\n return sview.getBondData(this.getBondParams(what, params))\n }\n\n createData (sview: StructureView) {\n const bufferList: any[] = []\n\n if (this.lineOnly) {\n this.lineBuffer = new WideLineBuffer(\n this.getBondData(sview, { position: true, color: true, picking: true }),\n this.getBufferParams({ linewidth: this.linewidth })\n )\n\n bufferList.push(this.lineBuffer)\n } else {\n const cylinderBuffer = new CylinderBuffer(\n (this.getBondData(sview) as CylinderBufferData),\n this.getBufferParams({\n openEnded: this.openEnded,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n bufferList.push(cylinderBuffer as CylinderGeometryBuffer)\n\n if (!this.cylinderOnly) {\n const sphereBuffer = new SphereBuffer(\n (this.getAtomData(sview) as SphereBufferData),\n (this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters)\n )\n\n bufferList.push(sphereBuffer as SphereGeometryBuffer)\n }\n }\n\n return {\n bufferList: bufferList\n }\n }\n\n updateData (what: BondDataFields | AtomDataFields, data: StructureRepresentationData) {\n if (this.multipleBond !== 'off' && what && what.radius) {\n what.position = true\n }\n\n const bondData = this.getBondData(data.sview as StructureView, what)\n\n if (this.lineOnly) {\n const lineData:Partial = {}\n\n if (!what || what.position) {\n Object.assign(lineData, {\n position1: bondData.position1,\n position2: bondData.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(lineData, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n data.bufferList[ 0 ].setAttributes(lineData)\n } else {\n var cylinderData: Partial = {}\n\n if (!what || what.position) {\n Object.assign(cylinderData, {\n position1: bondData.position1,\n position2: bondData.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(cylinderData, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n if (!what || what.radius) {\n Object.assign(cylinderData, {\n radius: bondData.radius\n })\n }\n\n data.bufferList[ 0 ].setAttributes(cylinderData)\n\n if (!this.cylinderOnly) {\n var atomData = this.getAtomData(data.sview as StructureView, what)\n\n var sphereData: Partial = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {\n position: atomData.position\n })\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {\n color: atomData.color\n })\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {\n radius: atomData.radius\n })\n }\n\n data.bufferList[ 1 ].setAttributes(sphereData)\n }\n }\n }\n\n setParameters (params: Partial = {}) {\n let rebuild = false\n const what: AtomDataFields = {}\n\n if (params.aspectRatio || params.bondSpacing || params.bondScale) {\n Object.assign(what, {radius: true})\n if (!ExtensionFragDepth || this.disableImpostor) {\n rebuild = true\n }\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('ball+stick', BallAndStickRepresentation)\n\nexport default BallAndStickRepresentation\n","/**\n * @file Backbone Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport BallAndStickRepresentation, { BallAndStickRepresentationParameters } from './ballandstick-representation'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport StructureView from '../structure/structure-view';\nimport { AtomDataFields, AtomDataParams, BondDataFields, BondDataParams, BondData, AtomData } from '../structure/structure-data';\n\n/**\n * Backbone representation. Show cylinders (or lines) connecting .CA (protein)\n * or .C4'/.C3' (RNA/DNA) of polymers.\n *\n * __Name:__ _backbone_\n *\n * @example\n * stage.loadFile( \"rcsb://1sfi\" ).then( function( o ){\n * o.addRepresentation( \"backbone\" );\n * o.autoView();\n * } );\n */\nclass BackboneRepresentation extends BallAndStickRepresentation {\n /**\n * @param {Structure} structure - the structure object\n * @param {Viewer} viewer - the viewer object\n * @param {BallAndStickRepresentationParameters} params - parameters object\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'backbone'\n\n this.parameters = Object.assign({\n\n }, this.parameters, {\n\n multipleBond: null,\n bondSpacing: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.aspectRatio = defaults(p.aspectRatio, 1.0)\n p.radiusSize = defaults(p.radiusSize, 0.25)\n\n super.init(p)\n }\n\n getAtomRadius (atom: AtomProxy) {\n return atom.isTrace() ? super.getAtomRadius(atom) : 0\n }\n\n getAtomData (sview: StructureView, what?: AtomDataFields, params?: Partial): AtomData {\n return sview.getBackboneAtomData(this.getAtomParams(what, params))\n }\n\n getBondData (sview: StructureView, what?: BondDataFields, params?: Partial): BondData {\n return sview.getBackboneBondData(this.getBondParams(what, params))\n }\n}\n\nRepresentationRegistry.add('backbone', BackboneRepresentation)\n\nexport default BackboneRepresentation\n","/**\n * @file Base Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport BallAndStickRepresentation, { BallAndStickRepresentationParameters } from './ballandstick-representation'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { AtomDataFields, AtomDataParams, BondDataFields, BondDataParams, BondData, AtomData } from '../structure/structure-data';\n\n/**\n * Base representation. Show cylinders for RNA/DNA ladders.\n *\n * __Name:__ _base_\n *\n * @example\n * stage.loadFile( \"rcsb://1d66\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\", { sele: \"nucleic\" } );\n * o.addRepresentation( \"base\", { color: \"resname\" } );\n * o.autoView( \"nucleic\" );\n * } );\n */\nclass BaseRepresentation extends BallAndStickRepresentation {\n /**\n * @param {Structure} structure - the structure object\n * @param {Viewer} viewer - the viewer object\n * @param {BallAndStickRepresentationParameters} params - parameters object\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'base'\n\n this.parameters = Object.assign({\n\n }, this.parameters, {\n\n multipleBond: null,\n bondSpacing: null\n\n })\n }\n\n init (params: Partial) {\n let p = params || {}\n p.aspectRatio = defaults(p.aspectRatio, 1.0)\n p.radiusSize = defaults(p.radiusSize, 0.3)\n\n super.init(p)\n }\n\n getAtomData (sview: StructureView, what?: AtomDataFields, params?: AtomDataParams): AtomData {\n return sview.getRungAtomData(this.getAtomParams(what, params))\n }\n\n getBondData (sview: StructureView, what?: BondDataFields, params?: BondDataParams): BondData {\n let p = this.getBondParams(what, params)\n Object.assign(p.colorParams, {rung: true})\n\n return sview.getRungBondData(p)\n }\n}\n\nRepresentationRegistry.add('base', BaseRepresentation)\n\nexport default BaseRepresentation\n","/**\n * @file Spline\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport { ColormakerRegistry } from '../globals'\nimport { AtomPicker } from '../utils/picker'\nimport RadiusFactory, { RadiusParams } from '../utils/radius-factory'\nimport { copyArray } from '../math/array-utils'\nimport { spline } from '../math/math-utils'\nimport Polymer from '../proxy/polymer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport { ColormakerParameters } from '../color/colormaker';\nimport { NumberArray } from '../types';\n\nexport class Interpolator {\n \n m: number\n tension: number\n dt: number\n delta: number\n vec1: Vector3\n vec2: Vector3\n vDir: Vector3 \n vTan: Vector3\n vNorm: Vector3\n vBin: Vector3\n m2: number\n\n constructor (m: number, tension: number) {\n this.m = m\n this.tension = tension\n this.dt = 1.0 / this.m\n this.delta = 0.0001\n\n this.vec1 = new Vector3()\n this.vec2 = new Vector3()\n\n this.vDir = new Vector3()\n this.vTan = new Vector3()\n this.vNorm = new Vector3()\n this.vBin = new Vector3()\n \n this.m2 = Math.ceil(this.m / 2)\n }\n\n private interpolateToArr (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, t: number, arr: Float32Array, offset: number) {\n arr[ offset + 0 ] = spline(v0.x, v1.x, v2.x, v3.x, t, this.tension)\n arr[ offset + 1 ] = spline(v0.y, v1.y, v2.y, v3.y, t, this.tension)\n arr[ offset + 2 ] = spline(v0.z, v1.z, v2.z, v3.z, t, this.tension)\n }\n\n private interpolateToVec (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, t: number, vec: Vector3) {\n vec.x = spline(v0.x, v1.x, v2.x, v3.x, t, this.tension)\n vec.y = spline(v0.y, v1.y, v2.y, v3.y, t, this.tension)\n vec.z = spline(v0.z, v1.z, v2.z, v3.z, t, this.tension)\n }\n\n private interpolatePosition (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, pos: Float32Array, offset: number) {\n for (var j = 0; j < this.m; ++j) {\n var l = offset + j * 3\n var d = this.dt * j\n this.interpolateToArr(v0, v1, v2, v3, d, pos, l)\n }\n }\n\n private interpolateTangent (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, tan: Float32Array, offset: number) {\n for (var j = 0; j < this.m; ++j) {\n var d = this.dt * j\n var d1 = d - this.delta\n var d2 = d + this.delta\n var l = offset + j * 3\n // capping as a precaution\n if (d1 < 0) d1 = 0\n if (d2 > 1) d2 = 1\n //\n this.interpolateToVec(v0, v1, v2, v3, d1, this.vec1)\n this.interpolateToVec(v0, v1, v2, v3, d2, this.vec2)\n //\n this.vec2.sub(this.vec1).normalize()\n this.vec2.toArray(tan as any, l)\n }\n }\n\n private vectorSubdivide (interpolationFn: (v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, array: Float32Array, offset: number) => void,\n iterator: AtomIterator, array: Float32Array, offset: number, isCyclic: boolean) {\n let v0: Vector3\n let v1 = iterator.next()\n let v2 = iterator.next()\n let v3 = iterator.next()\n //\n const n = iterator.size\n const n1 = n - 1\n let k = offset || 0\n for (let i = 0; i < n1; ++i) {\n v0 = v1\n v1 = v2\n v2 = v3\n v3 = iterator.next()\n interpolationFn.apply(this, [v0, v1, v2, v3, array, k])\n k += 3 * this.m\n }\n if (isCyclic) {\n v0 = iterator.get(n - 2)\n v1 = iterator.get(n - 1)\n v2 = iterator.get(0)\n v3 = iterator.get(1)\n interpolationFn.apply(this, [v0, v1, v2, v3, array, k])\n k += 3 * this.m\n }\n }\n\n //\n\n public getPosition (iterator: AtomIterator, array: Float32Array, offset: number, isCyclic: boolean) {\n iterator.reset()\n this.vectorSubdivide(this.interpolatePosition, iterator, array, offset, isCyclic)\n var n1 = iterator.size - 1\n var k = n1 * this.m * 3\n if (isCyclic) k += this.m * 3\n var v = iterator.get(isCyclic ? 0 : n1)\n array[ k ] = v.x\n array[ k + 1 ] = v.y\n array[ k + 2 ] = v.z\n }\n\n public getTangent (iterator: AtomIterator, array: Float32Array, offset: number, isCyclic: boolean) {\n iterator.reset()\n this.vectorSubdivide(this.interpolateTangent, iterator, array, offset, isCyclic)\n const n1 = iterator.size - 1\n let k = n1 * this.m * 3\n if (isCyclic) k += this.m * 3\n copyArray(array, array, k - 3, k, 3)\n }\n\n private interpolateNormalDir (u0: Vector3, u1: Vector3, u2: Vector3, u3: Vector3,\n v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3,\n tan: Float32Array, norm: Float32Array, bin: Float32Array,\n offset: number, shift: boolean) {\n for (let j = 0; j < this.m; ++j) {\n let l = offset + j * 3\n if (shift) l += this.m2 * 3\n const d = this.dt * j\n this.interpolateToVec(u0, u1, u2, u3, d, this.vec1)\n this.interpolateToVec(v0, v1, v2, v3, d, this.vec2)\n this.vDir.subVectors(this.vec2, this.vec1).normalize()\n this.vTan.fromArray(tan as any, l)\n this.vBin.crossVectors(this.vDir, this.vTan).normalize()\n this.vBin.toArray(bin as any, l)\n this.vNorm.crossVectors(this.vTan, this.vBin).normalize()\n this.vNorm.toArray(norm as any, l)\n }\n }\n\n private interpolateNormal (vDir: Vector3, tan: Float32Array, norm: Float32Array, bin: Float32Array, offset: number) {\n for (var j = 0; j < this.m; ++j) {\n var l = offset + j * 3\n vDir.copy(this.vNorm)\n this.vTan.fromArray(tan as any, l)\n this.vBin.crossVectors(vDir, this.vTan).normalize()\n this.vBin.toArray(bin as any, l)\n this.vNorm.crossVectors(this.vTan, this.vBin).normalize()\n this.vNorm.toArray(norm as any, l)\n }\n }\n\n public getNormal (size: number, tan: Float32Array, norm: Float32Array, bin: Float32Array, offset: number, isCyclic: boolean) {\n this.vNorm.set(0, 0, 1)\n const n = size\n const n1 = n - 1\n let k = offset || 0\n for (var i = 0; i < n1; ++i) {\n this.interpolateNormal(this.vDir, tan, norm, bin, k)\n k += 3 * this.m\n }\n if (isCyclic) {\n this.interpolateNormal(this.vDir, tan, norm, bin, k)\n k += 3 * this.m\n }\n this.vBin.toArray(bin as any, k)\n this.vNorm.toArray(norm as any, k)\n }\n\n public getNormalDir (iterDir1: AtomIterator, iterDir2: AtomIterator, tan: Float32Array, norm: Float32Array, bin: Float32Array, offset: number, isCyclic: boolean, shift: boolean) {\n iterDir1.reset()\n iterDir2.reset()\n //\n const vSub1 = new Vector3()\n const vSub2 = new Vector3()\n const vSub3 = new Vector3()\n const vSub4 = new Vector3()\n //\n const d1v1 = new Vector3()\n const d1v2 = new Vector3().copy(iterDir1.next())\n const d1v3 = new Vector3().copy(iterDir1.next())\n const d1v4 = new Vector3().copy(iterDir1.next())\n const d2v1 = new Vector3()\n const d2v2 = new Vector3().copy(iterDir2.next())\n const d2v3 = new Vector3().copy(iterDir2.next())\n const d2v4 = new Vector3().copy(iterDir2.next())\n //\n this.vNorm.set(0, 0, 1)\n let n = iterDir1.size\n let n1 = n - 1\n let k = offset || 0\n for (var i = 0; i < n1; ++i) {\n d1v1.copy(d1v2)\n d1v2.copy(d1v3)\n d1v3.copy(d1v4)\n d1v4.copy(iterDir1.next())\n d2v1.copy(d2v2)\n d2v2.copy(d2v3)\n d2v3.copy(d2v4)\n d2v4.copy(iterDir2.next())\n //\n if (i === 0) {\n vSub1.subVectors(d2v1, d1v1)\n vSub2.subVectors(d2v2, d1v2)\n if (vSub1.dot(vSub2) < 0) {\n vSub2.multiplyScalar(-1)\n d2v2.addVectors(d1v2, vSub2)\n }\n vSub3.subVectors(d2v3, d1v3)\n if (vSub2.dot(vSub3) < 0) {\n vSub3.multiplyScalar(-1)\n d2v3.addVectors(d1v3, vSub3)\n }\n } else {\n vSub3.copy(vSub4)\n }\n vSub4.subVectors(d2v4, d1v4)\n if (vSub3.dot(vSub4) < 0) {\n vSub4.multiplyScalar(-1)\n d2v4.addVectors(d1v4, vSub4)\n }\n this.interpolateNormalDir(\n d1v1, d1v2, d1v3, d1v4,\n d2v1, d2v2, d2v3, d2v4,\n tan, norm, bin, k, shift\n )\n k += 3 * this.m\n }\n if (isCyclic) {\n d1v1.copy(iterDir1.get(n - 2))\n d1v2.copy(iterDir1.get(n - 1))\n d1v3.copy(iterDir1.get(0))\n d1v4.copy(iterDir1.get(1))\n d2v1.copy(iterDir2.get(n - 2))\n d2v2.copy(iterDir2.get(n - 1))\n d2v3.copy(iterDir2.get(0))\n d2v4.copy(iterDir2.get(1))\n //\n vSub3.copy(vSub4)\n vSub4.subVectors(d2v4, d1v4)\n if (vSub3.dot(vSub4) < 0) {\n vSub4.multiplyScalar(-1)\n d2v4.addVectors(d1v4, vSub4)\n }\n this.interpolateNormalDir(\n d1v1, d1v2, d1v3, d1v4,\n d2v1, d2v2, d2v3, d2v4,\n tan, norm, bin, k, shift\n )\n k += 3 * this.m\n }\n if (shift) {\n // FIXME shift requires data from one this.more preceeding residue\n this.vBin.fromArray(bin as any, this.m2 * 3)\n this.vNorm.fromArray(norm as any, this.m2 * 3)\n for (var j = 0; j < this.m2; ++j) {\n this.vBin.toArray(bin as any, j * 3)\n this.vNorm.toArray(norm as any, j * 3)\n }\n } else {\n this.vBin.toArray(bin as any, k)\n this.vNorm.toArray(norm as any, k)\n }\n }\n\n //\n\n private interpolateColor (item1: AtomProxy, item2: AtomProxy, colFn: (...arg: any[]) => void, col: any, offset: number) {\n var j, l\n for (j = 0; j < this.m2; ++j) {\n l = offset + j * 3\n colFn.apply(this, [item1, col, l]) // itemColorToArray\n }\n for (j = this.m2; j < this.m; ++j) {\n l = offset + j * 3\n colFn.apply(this, [item2, col, l]) // itemColorToArray\n }\n }\n\n public getColor (iterator: AtomIterator, colFn: (...arg: any[]) => void, col: any, offset: number, isCyclic: boolean) {\n iterator.reset()\n iterator.next() // first element not needed\n let i0: AtomProxy\n let i1 = iterator.next()\n //\n var n = iterator.size\n var n1 = n - 1\n var k = offset || 0\n for (var i = 0; i < n1; ++i) {\n i0 = i1\n i1 = iterator.next()\n this.interpolateColor(i0, i1, colFn, col, k)\n k += 3 * this.m\n }\n if (isCyclic) {\n i0 = iterator.get(n - 1)\n i1 = iterator.get(0)\n this.interpolateColor(i0, i1, colFn, col, k)\n k += 3 * this.m\n }\n //\n col[ k ] = col[ k - 3 ]\n col[ k + 1 ] = col[ k - 2 ]\n col[ k + 2 ] = col[ k - 1 ]\n }\n\n //\n\n private interpolatePicking (item1: AtomProxy, item2: AtomProxy, pickFn: (item: AtomProxy) => number, pick: Float32Array, offset: number) {\n var j\n for (j = 0; j < this.m2; ++j) {\n pick[ offset + j ] = pickFn.apply(this, [item1])\n }\n for (j = this.m2; j < this.m; ++j) {\n pick[ offset + j ] = pickFn.apply(this, [item2])\n }\n }\n\n public getPicking (iterator: AtomIterator, pickFn: (item: AtomProxy) => number, pick: Float32Array, offset: number, isCyclic: boolean) {\n iterator.reset()\n iterator.next() // first element not needed\n let i0: AtomProxy\n let i1 = iterator.next()\n //\n const n = iterator.size\n const n1 = n - 1\n let k = offset || 0\n for (var i = 0; i < n1; ++i) {\n i0 = i1\n i1 = iterator.next()\n this.interpolatePicking(i0, i1, pickFn, pick, k)\n k += this.m\n }\n if (isCyclic) {\n i0 = iterator.get(n - 1)\n i1 = iterator.get(0)\n this.interpolatePicking(i0, i1, pickFn, pick, k)\n k += this.m\n }\n //\n pick[ k ] = pick[ k - 1 ]\n }\n\n //\n\n private interpolateSize (item1: AtomProxy, item2: AtomProxy, sizeFn: (item: AtomProxy) => number, size: Float32Array, offset: number) {\n const s1: number = sizeFn.apply(this, [item1])\n const s2: number = sizeFn.apply(this, [item2])\n for (let j = 0; j < this.m; ++j) {\n // linear interpolation\n let t = j / this.m\n size[ offset + j ] = (1 - t) * s1 + t * s2\n }\n }\n\n public getSize (iterator: AtomIterator, sizeFn: (item: AtomProxy) => number, size: Float32Array, offset: number, isCyclic: boolean) {\n iterator.reset()\n iterator.next() // first element not needed\n let i0: AtomProxy\n let i1: AtomProxy = iterator.next()\n //\n const n = iterator.size\n const n1 = n - 1\n let k = offset || 0\n for (var i = 0; i < n1; ++i) {\n i0 = i1\n i1 = iterator.next()\n this.interpolateSize(i0, i1, sizeFn, size, k)\n k += this.m\n }\n if (isCyclic) {\n i0 = iterator.get(n - 1)\n i1 = iterator.get(0)\n this.interpolateSize(i0, i1, sizeFn, size, k)\n k += this.m\n }\n //\n size[ k ] = size[ k - 1 ]\n }\n}\n\nexport interface SplineParameters {\n directional?: boolean\n positionIterator?: boolean\n subdiv?: number\n smoothSheet?: boolean\n tension?: number\n}\nexport interface AtomIterator {\n size: number,\n next: () => AtomProxy | Vector3,\n get: (idx: number) => AtomProxy | Vector3,\n reset: () => void\n}\nclass Spline {\n\n polymer: Polymer\n size: number\n directional: boolean\n positionIterator: any\n subdiv: number\n smoothSheet: boolean\n tension: number\n interpolator: Interpolator\n\n constructor (polymer: Polymer, params?: SplineParameters) {\n this.polymer = polymer\n this.size = polymer.residueCount\n\n var p = params || {}\n this.directional = p.directional || false\n this.positionIterator = p.positionIterator || false\n this.subdiv = p.subdiv || 1\n this.smoothSheet = p.smoothSheet || false\n\n if (!p.tension) {\n this.tension = this.polymer.isNucleic() ? 0.5 : 0.9\n } else {\n this.tension = p.tension\n }\n\n this.interpolator = new Interpolator(this.subdiv, this.tension)\n }\n\n getAtomIterator (type: string, smooth?: boolean): AtomIterator {\n const polymer = this.polymer\n const structure = polymer.structure\n const n = polymer.residueCount\n\n let i = 0\n let j = -1\n\n const cache = [\n structure.getAtomProxy(),\n structure.getAtomProxy(),\n structure.getAtomProxy(),\n structure.getAtomProxy()\n ]\n\n const cache2 = [\n new Vector3(),\n new Vector3(),\n new Vector3(),\n new Vector3()\n ]\n\n function next () {\n var atomProxy = get(j)\n j += 1\n return atomProxy\n }\n\n var apPrev = structure.getAtomProxy()\n var apNext = structure.getAtomProxy()\n\n function get (idx: number) {\n var atomProxy = cache[ i % 4 ]\n atomProxy.index = polymer.getAtomIndexByType(idx, type) as number\n if (smooth && idx > 0 && idx < n && atomProxy.sstruc === 'e') {\n var vec = cache2[ i % 4 ]\n apPrev.index = polymer.getAtomIndexByType(idx + 1, type) as number\n apNext.index = polymer.getAtomIndexByType(idx - 1, type) as number\n vec.addVectors(apPrev as any, apNext as any)\n .add(atomProxy as any).add(atomProxy as any)\n .multiplyScalar(0.25)\n i += 1\n return vec\n }\n i += 1\n return atomProxy\n }\n\n function reset () {\n i = 0\n j = -1\n }\n\n return {\n size: n,\n next: next,\n get: get,\n reset: reset\n }\n }\n\n getSubdividedColor (params: {scheme: string, [k: string]: any } & ColormakerParameters) {\n var m = this.subdiv\n var polymer = this.polymer\n var n = polymer.residueCount\n var n1 = n - 1\n var nCol = n1 * m * 3 + 3\n if (polymer.isCyclic) nCol += m * 3\n\n var col = new Float32Array(nCol)\n var iterator = this.getAtomIterator('trace')\n\n var p = params || {}\n p.structure = polymer.structure\n\n var colormaker = ColormakerRegistry.getScheme(p)\n\n function colFn (item: AtomProxy, array: NumberArray, offset: number) {\n colormaker.atomColorToArray(item, array, offset)\n }\n\n this.interpolator.getColor(\n iterator, colFn, col, 0, polymer.isCyclic\n )\n\n return {\n 'color': col\n }\n }\n \n getSubdividedPicking () {\n var m = this.subdiv\n var polymer = this.polymer\n var n = polymer.residueCount\n var n1 = n - 1\n var nCol = n1 * m + 1\n if (polymer.isCyclic) nCol += m\n\n var structure = polymer.structure\n var iterator = this.getAtomIterator('trace')\n var pick = new Float32Array(nCol)\n\n function pickFn (item: AtomProxy) {\n return item.index\n }\n\n this.interpolator.getPicking(\n iterator, pickFn, pick, 0, polymer.isCyclic\n )\n\n return {\n 'picking': new AtomPicker(pick, structure)\n }\n }\n\n getSubdividedPosition () {\n var pos = this.getPosition()\n\n return {\n 'position': pos\n }\n }\n \n getSubdividedOrientation () {\n const tan = this.getTangent()\n const normals = this.getNormals(tan)\n\n return {\n 'tangent': tan,\n 'normal': normals.normal,\n 'binormal': normals.binormal\n }\n }\n\n getSubdividedSize (params: RadiusParams) {\n var m = this.subdiv\n var polymer = this.polymer\n var n = polymer.residueCount\n var n1 = n - 1\n var nSize = n1 * m + 1\n if (polymer.isCyclic) nSize += m\n\n var size = new Float32Array(nSize)\n var iterator = this.getAtomIterator('trace')\n\n var radiusFactory = new RadiusFactory(params)\n\n function sizeFn (item: AtomProxy) {\n return radiusFactory.atomRadius(item)\n }\n\n this.interpolator.getSize(\n iterator, sizeFn, size, 0, polymer.isCyclic\n )\n\n return {\n 'size': size\n }\n }\n\n getPosition () {\n const m = this.subdiv\n const polymer = this.polymer\n const n = polymer.residueCount\n const n1 = n - 1\n let nPos = n1 * m * 3 + 3\n if (polymer.isCyclic) nPos += m * 3\n\n const pos = new Float32Array(nPos)\n const iterator = this.positionIterator || this.getAtomIterator('trace', this.smoothSheet)\n\n this.interpolator.getPosition(iterator, pos, 0, polymer.isCyclic)\n\n return pos\n }\n\n getTangent () {\n const m = this.subdiv\n const polymer = this.polymer\n const n = this.size\n const n1 = n - 1\n let nTan = n1 * m * 3 + 3\n if (polymer.isCyclic) nTan += m * 3\n\n const tan = new Float32Array(nTan)\n const iterator = this.positionIterator || this.getAtomIterator('trace', this.smoothSheet)\n\n this.interpolator.getTangent(iterator, tan, 0, polymer.isCyclic)\n\n return tan\n }\n\n getNormals (tan: Float32Array) {\n const m = this.subdiv\n const polymer = this.polymer\n const isProtein = polymer.isProtein()\n const n = this.size\n const n1 = n - 1\n let nNorm = n1 * m * 3 + 3\n if (polymer.isCyclic) nNorm += m * 3\n\n const norm = new Float32Array(nNorm)\n const bin = new Float32Array(nNorm)\n\n if (this.directional && !this.polymer.isCg()) {\n const iterDir1 = this.getAtomIterator('direction1')\n const iterDir2 = this.getAtomIterator('direction2')\n this.interpolator.getNormalDir(\n iterDir1, iterDir2, tan, norm, bin, 0, polymer.isCyclic, isProtein\n )\n } else {\n this.interpolator.getNormal(\n n, tan, norm, bin, 0, polymer.isCyclic\n )\n }\n\n return {\n 'normal': norm,\n 'binormal': bin\n }\n }\n\n}\n\nexport default Spline\n","/**\n * @file Tube Mesh Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Matrix4 required for declaration only\nimport { Vector3, Matrix4 } from 'three'\n\nimport { defaults, getUintArray } from '../utils'\nimport { serialArray } from '../math/array-utils'\nimport MeshBuffer from './mesh-buffer'\nimport { BufferDefaultParameters, BufferData, BufferParameters } from './buffer'\nimport {Log} from \"../globals\";\n\nconst vTangent = new Vector3()\nconst vMeshNormal = new Vector3()\n\nexport interface TubeMeshBufferData extends BufferData {\n binormal: Float32Array\n tangent: Float32Array\n size: Float32Array\n}\n\nexport const TubeMeshBufferDefaultParameters = Object.assign({\n radialSegments: 4,\n capped: false,\n aspectRatio: 1.0\n}, BufferDefaultParameters)\nexport type TubeMeshBufferParameters = BufferParameters & {\n radialSegments: number,\n capped: boolean,\n aspectRatio: number\n}\n\nfunction getData (data: TubeMeshBufferData, params: Partial = {}) {\n const radialSegments = defaults(params.radialSegments, 4)\n const capped = defaults(params.capped, false)\n\n const capVertices = capped ? radialSegments : 0\n const capTriangles = capped ? radialSegments - 2 : 0\n\n const n = data.position!.length / 3\n const n1 = n - 1\n const x = n * radialSegments * 3 + 2 * capVertices * 3\n const xi = n1 * 2 * radialSegments * 3 + 2 * capTriangles * 3\n\n return {\n position: new Float32Array(x),\n color: new Float32Array(x),\n index: getUintArray(xi, x / 3),\n normal: new Float32Array(x),\n picking: data.picking\n }\n}\n\n/**\n * Tube mesh buffer. Draws a tube.\n */\nclass TubeMeshBuffer extends MeshBuffer {\n get defaultParameters() { return TubeMeshBufferDefaultParameters }\n parameters: TubeMeshBufferParameters\n\n capVertices: number\n capTriangles: number\n size2: number\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.normal - normals\n * @param {Float32Array} data.binormal - binormals\n * @param {Float32Array} data.tangent - tangents\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.size - sizes\n * @param {Picker} data.picking - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: TubeMeshBufferData, params: Partial = {}) {\n super(getData(data, params), params)\n\n this.capVertices = this.parameters.capped ? this.parameters.radialSegments : 0\n this.capTriangles = this.parameters.capped ? this.parameters.radialSegments - 2 : 0\n\n this.size2 = data.position!.length / 3\n data.primitiveId = serialArray(this.size2)\n\n this.setAttributes(data)\n this.makeIndex()\n }\n\n setAttributes (data: Partial = {}) {\n const aspectRatio = this.parameters.aspectRatio\n\n const n = this.size2\n const n1 = n - 1\n const radialSegments = this.parameters.radialSegments\n\n const attributes = this.geometry.attributes as any\n\n let position, normal, binormal, tangent, color, size, primitiveId\n let meshPosition, meshColor, meshNormal, meshPrimitiveId\n\n if (data.position) {\n position = data.position\n normal = data.normal\n binormal = data.binormal\n tangent = data.tangent\n size = data.size\n\n meshPosition = attributes.position.array\n meshNormal = attributes.normal.array\n\n attributes.position.needsUpdate = true\n attributes.normal.needsUpdate = true\n }\n\n if (data.color) {\n color = data.color\n meshColor = attributes.color.array\n attributes.color.needsUpdate = true\n }\n\n if (data.primitiveId) {\n primitiveId = data.primitiveId\n meshPrimitiveId = attributes.primitiveId.array\n attributes.primitiveId.needsUpdate = true\n }\n\n let k, l\n let radius = 0\n\n let normX = 0\n let normY = 0\n let normZ = 0\n let biX = 0\n let biY = 0\n let biZ = 0\n let posX = 0\n let posY = 0\n let posZ = 0\n\n const cxArr = []\n const cyArr = []\n const cx1Arr = []\n const cy1Arr = []\n const cx2Arr = []\n const cy2Arr = []\n\n if (position) {\n for (let j = 0; j < radialSegments; ++j) {\n const v = (j / radialSegments) * 2 * Math.PI\n\n cxArr[ j ] = aspectRatio * Math.cos(v)\n cyArr[ j ] = Math.sin(v)\n\n cx1Arr[ j ] = aspectRatio * Math.cos(v - 0.01)\n cy1Arr[ j ] = Math.sin(v - 0.01)\n cx2Arr[ j ] = aspectRatio * Math.cos(v + 0.01)\n cy2Arr[ j ] = Math.sin(v + 0.01)\n }\n }\n\n for (let i = 0; i < n; ++i) {\n k = i * 3\n l = k * radialSegments\n\n if (position && tangent && normal && binormal && size) {\n vTangent.set(\n tangent[ k ], tangent[ k + 1 ], tangent[ k + 2 ]\n )\n\n normX = normal[ k ]\n normY = normal[ k + 1 ]\n normZ = normal[ k + 2 ]\n\n biX = binormal[ k ]\n biY = binormal[ k + 1 ]\n biZ = binormal[ k + 2 ]\n\n posX = position[ k ]\n posY = position[ k + 1 ]\n posZ = position[ k + 2 ]\n\n radius = size[ i ]\n }\n\n for (let j = 0; j < radialSegments; ++j) {\n const s = l + j * 3\n\n if (position) {\n const cx = -radius * cxArr[ j ] // TODO: Hack: Negating it so it faces outside.\n const cy = radius * cyArr[ j ]\n\n const cx1 = -radius * cx1Arr[ j ]\n const cy1 = radius * cy1Arr[ j ]\n const cx2 = -radius * cx2Arr[ j ]\n const cy2 = radius * cy2Arr[ j ]\n\n meshPosition[ s ] = posX + cx * normX + cy * biX\n meshPosition[ s + 1 ] = posY + cx * normY + cy * biY\n meshPosition[ s + 2 ] = posZ + cx * normZ + cy * biZ\n\n // TODO half of these are symmetric\n vMeshNormal.set(\n // ellipse tangent approximated as vector from/to adjacent points\n (cx2 * normX + cy2 * biX) - (cx1 * normX + cy1 * biX),\n (cx2 * normY + cy2 * biY) - (cx1 * normY + cy1 * biY),\n (cx2 * normZ + cy2 * biZ) - (cx1 * normZ + cy1 * biZ)\n ).cross(vTangent)\n\n meshNormal[ s ] = vMeshNormal.x\n meshNormal[ s + 1 ] = vMeshNormal.y\n meshNormal[ s + 2 ] = vMeshNormal.z\n }\n\n if (color) {\n meshColor[ s ] = color[ k ]\n meshColor[ s + 1 ] = color[ k + 1 ]\n meshColor[ s + 2 ] = color[ k + 2 ]\n }\n\n if (primitiveId) {\n meshPrimitiveId[ i * radialSegments + j ] = primitiveId[ i ]\n }\n }\n }\n\n // front cap\n\n k = 0\n l = n * 3 * radialSegments\n\n for (let j = 0; j < radialSegments; ++j) {\n const s = k + j * 3\n const t = l + j * 3\n\n if (position && tangent) {\n meshPosition[ t ] = meshPosition[ s ]\n meshPosition[ t + 1 ] = meshPosition[ s + 1 ]\n meshPosition[ t + 2 ] = meshPosition[ s + 2 ]\n\n meshNormal[ t ] = tangent[ k ]\n meshNormal[ t + 1 ] = tangent[ k + 1 ]\n meshNormal[ t + 2 ] = tangent[ k + 2 ]\n }\n\n if (color) {\n meshColor[ t ] = meshColor[ s ]\n meshColor[ t + 1 ] = meshColor[ s + 1 ]\n meshColor[ t + 2 ] = meshColor[ s + 2 ]\n }\n\n if (primitiveId) {\n meshPrimitiveId[ n * radialSegments + j ] = meshPrimitiveId[ 0 + j ]\n }\n }\n\n // back cap\n\n k = (n - 1) * 3 * radialSegments\n l = (n + 1) * 3 * radialSegments\n\n for (let j = 0; j < radialSegments; ++j) {\n const s = k + j * 3\n const t = l + j * 3\n\n if (position && tangent) {\n meshPosition[ t ] = meshPosition[ s ]\n meshPosition[ t + 1 ] = meshPosition[ s + 1 ]\n meshPosition[ t + 2 ] = meshPosition[ s + 2 ]\n\n meshNormal[ t ] = tangent[ n1 * 3 ]\n meshNormal[ t + 1 ] = tangent[ n1 * 3 + 1 ]\n meshNormal[ t + 2 ] = tangent[ n1 * 3 + 2 ]\n }\n\n if (color) {\n meshColor[ t ] = meshColor[ s ]\n meshColor[ t + 1 ] = meshColor[ s + 1 ]\n meshColor[ t + 2 ] = meshColor[ s + 2 ]\n }\n\n if (primitiveId) {\n meshPrimitiveId[ (n + 1) * radialSegments + j ] = meshPrimitiveId[ (n - 1) * radialSegments + j ]\n }\n }\n }\n\n makeIndex () {\n const index = this.geometry.getIndex()\n if (!index) { Log.error('Index is null'); return; }\n const meshIndex = index.array as Uint32Array|Uint16Array\n\n const n = this.size2\n const n1 = n - 1\n const capTriangles = this.capTriangles\n const radialSegments = this.parameters.radialSegments\n const radialSegments1 = this.parameters.radialSegments + 1\n\n let k, l\n\n for (let i = 0; i < n1; ++i) {\n const k = i * radialSegments * 3 * 2\n\n const irs = i * radialSegments\n const irs1 = (i + 1) * radialSegments\n\n for (let j = 0; j < radialSegments; ++j) {\n l = k + j * 3 * 2\n\n // meshIndex[ l + 0 ] = irs + ( ( j + 0 ) % radialSegments );\n meshIndex[ l ] = irs + j\n meshIndex[ l + 1 ] = irs + ((j + 1) % radialSegments)\n // meshIndex[ l + 2 ] = irs1 + ( ( j + 0 ) % radialSegments );\n meshIndex[ l + 2 ] = irs1 + j\n\n // meshIndex[ l + 3 ] = irs1 + ( ( j + 0 ) % radialSegments );\n meshIndex[ l + 3 ] = irs1 + j\n meshIndex[ l + 4 ] = irs + ((j + 1) % radialSegments)\n meshIndex[ l + 5 ] = irs1 + ((j + 1) % radialSegments)\n }\n }\n\n // capping\n\n const strip = [ 0 ]\n\n for (let j = 1; j < radialSegments1 / 2; ++j) {\n strip.push(j)\n if (radialSegments - j !== j) {\n strip.push(radialSegments - j)\n }\n }\n\n // front cap\n\n l = n1 * radialSegments * 3 * 2\n k = n * radialSegments\n\n for (let j = 0; j < strip.length - 2; ++j) {\n if (j % 2 === 0) {\n meshIndex[ l + j * 3 + 0 ] = k + strip[ j + 0 ]\n meshIndex[ l + j * 3 + 1 ] = k + strip[ j + 1 ]\n meshIndex[ l + j * 3 + 2 ] = k + strip[ j + 2 ]\n } else {\n meshIndex[ l + j * 3 + 0 ] = k + strip[ j + 2 ]\n meshIndex[ l + j * 3 + 1 ] = k + strip[ j + 1 ]\n meshIndex[ l + j * 3 + 2 ] = k + strip[ j + 0 ]\n }\n }\n\n // back cap\n\n l = n1 * radialSegments * 3 * 2 + 3 * capTriangles\n k = n * radialSegments + radialSegments\n\n for (let j = 0; j < strip.length - 2; ++j) {\n if (j % 2 === 0) {\n meshIndex[ l + j * 3 + 0 ] = k + strip[ j + 0 ]\n meshIndex[ l + j * 3 + 1 ] = k + strip[ j + 1 ]\n meshIndex[ l + j * 3 + 2 ] = k + strip[ j + 2 ]\n } else {\n meshIndex[ l + j * 3 + 0 ] = k + strip[ j + 2 ]\n meshIndex[ l + j * 3 + 1 ] = k + strip[ j + 1 ]\n meshIndex[ l + j * 3 + 2 ] = k + strip[ j + 0 ]\n }\n }\n }\n}\n\nexport default TubeMeshBuffer\n","/**\n * @file Cartoon Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { Debug, Log, RepresentationRegistry } from '../globals'\nimport Spline from '../geometry/spline'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport TubeMeshBuffer from '../buffer/tubemesh-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport Polymer from '../proxy/polymer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport StructureView from '../structure/structure-view';\nimport Buffer from '../buffer/buffer';\n\nexport interface CartoonRepresentationParameters extends StructureRepresentationParameters {\n aspectRatio: number\n subdiv: number\n radialSegments: number\n tension: number\n capped: boolean\n smoothSheet: boolean\n}\n\n/**\n * Cartoon representation. Show a thick ribbon that\n * smoothly connecting backbone atoms in polymers.\n *\n * __Name:__ _cartoon_\n *\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\" );\n * o.autoView();\n * } );\n */\nclass CartoonRepresentation extends StructureRepresentation {\n protected aspectRatio: number\n protected tension: number\n protected capped: boolean\n protected smoothSheet: boolean\n protected subdiv: number\n \n /**\n * Create Cartoon representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {StructureRepresentationParameters} params - representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'cartoon'\n\n this.parameters = Object.assign({\n\n aspectRatio: {\n type: 'number', precision: 1, max: 10.0, min: 1.0, rebuild: true\n },\n subdiv: {\n type: 'integer', max: 50, min: 1, rebuild: true\n },\n radialSegments: {\n type: 'integer', max: 50, min: 1, rebuild: true\n },\n tension: {\n type: 'number', precision: 1, max: 1.0, min: 0.1\n },\n capped: {\n type: 'boolean', rebuild: true\n },\n smoothSheet: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'chainname')\n p.colorScale = defaults(p.colorScale, 'RdYlBu')\n p.radiusType = defaults(p.radiusType, 'sstruc')\n p.radiusScale = defaults(p.radiusScale, 0.7)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.aspectRatio = defaults(p.aspectRatio, 5.0)\n this.tension = defaults(p.tension, NaN)\n this.capped = defaults(p.capped, true)\n this.smoothSheet = defaults(p.smoothSheet, false)\n\n if (p.quality === 'low') {\n this.subdiv = 3\n this.radialSegments = 6\n } else if (p.quality === 'medium') {\n this.subdiv = 6\n } else if (p.quality === 'high') {\n this.subdiv = 12\n } else {\n this.subdiv = defaults(p.subdiv, 6)\n }\n\n super.init(p)\n }\n\n getSplineParams (params?: Partial) {\n return Object.assign({\n subdiv: this.subdiv,\n tension: this.tension,\n directional: this.aspectRatio !== 1.0,\n smoothSheet: this.smoothSheet\n }, params)\n }\n\n getSpline (polymer: Polymer): Spline {\n return new Spline(polymer, this.getSplineParams())\n }\n\n getAspectRatio (polymer: Polymer): number {\n return polymer.isCg() ? 1.0 : this.aspectRatio\n }\n\n getAtomRadius (atom: AtomProxy): number {\n return atom.isTrace() ? super.getAtomRadius(atom) : 0\n }\n\n createData (sview: StructureView) {\n let bufferList: Buffer[] = []\n let polymerList: Polymer[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4) return\n polymerList.push(polymer)\n\n const spline = this.getSpline(polymer)\n const aspectRatio = this.getAspectRatio(polymer)\n\n const subPos = spline.getSubdividedPosition()\n const subOri = spline.getSubdividedOrientation()\n const subCol = spline.getSubdividedColor(this.getColorParams())\n const subPick = spline.getSubdividedPicking()\n const subSize = spline.getSubdividedSize(this.getRadiusParams())\n\n bufferList.push(\n new TubeMeshBuffer(\n Object.assign({}, subPos, subOri, subCol, subPick, subSize),\n this.getBufferParams({\n radialSegments: this.radialSegments,\n aspectRatio: aspectRatio,\n capped: this.capped\n })\n )\n )\n }, sview.getSelection())\n\n return {\n bufferList: bufferList,\n polymerList: polymerList\n }\n }\n\n updateData (what: any, data: StructureRepresentationData) {\n if (Debug) Log.time(this.type + ' repr update')\n\n what = what || {}\n\n for (var i = 0, il = data.polymerList!.length; i < il; ++i) {\n var bufferData: {[key: string]: any} = {}\n var polymer = data.polymerList![ i ]\n var spline = this.getSpline(polymer)\n var aspectRatio = this.getAspectRatio(polymer)\n\n Object.assign(data.bufferList[ i ], {aspectRatio: aspectRatio})\n\n if (what.position || what.radius) {\n var subPos = spline.getSubdividedPosition()\n var subOri = spline.getSubdividedOrientation()\n var subSize = spline.getSubdividedSize(this.getRadiusParams(aspectRatio))\n\n bufferData.position = subPos.position\n bufferData.normal = subOri.normal\n bufferData.binormal = subOri.binormal\n bufferData.tangent = subOri.tangent\n bufferData.size = subSize.size\n }\n\n if (what.color) {\n var subCol = spline.getSubdividedColor(this.getColorParams())\n bufferData.color = subCol.color\n }\n\n if (what.picking) {\n var subPick = spline.getSubdividedPicking()\n bufferData.picking = subPick.picking\n }\n\n data.bufferList[ i ].setAttributes(bufferData)\n }\n\n if (Debug) Log.timeEnd(this.type + ' repr update')\n }\n\n setParameters (params: Partial) {\n const rebuild = false\n var what: {[k: string]: any} = {}\n\n if (params && params.aspectRatio) {\n what.radius = true\n }\n\n if (params && params.tension) {\n what.position = true\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('cartoon', CartoonRepresentation)\n\nexport default CartoonRepresentation\n","/**\n * @file Contact Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { RepresentationRegistry } from '../globals'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport { calculateContacts, getContactData, getLabelData } from '../chemistry/interactions/contact'\nimport CylinderBuffer from '../buffer/cylinder-buffer'\nimport TextBuffer from '../buffer/text-buffer'\nimport { getFixedCountDashData } from '../geometry/dash'\nimport Viewer from '../viewer/viewer';\nimport { Structure } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport CylinderImpostorBuffer from '../buffer/cylinderimpostor-buffer';\n// @ts-ignore: unused import ContactPicker required for declaration only\nimport { ContactPicker } from '../utils/picker';\n\nexport interface ContactRepresentationParameters extends StructureRepresentationParameters {\n hydrogenBond: boolean\n weakHydrogenBond: boolean\n waterHydrogenBond: boolean\n backboneHydrogenBond: boolean\n hydrophobic: boolean\n halogenBond: boolean\n ionicInteraction: boolean\n metalCoordination: boolean\n cationPi: boolean\n piStacking: boolean\n filterSele: string|[string, string]\n maxHydrophobicDist: number\n maxHbondDist: number\n maxHbondSulfurDist: number\n maxHbondAccAngle: number\n maxHbondDonAngle: number\n maxHbondAccPlaneAngle: number\n maxHbondDonPlaneAngle: number\n maxPiStackingDist: number\n maxPiStackingOffset: number\n maxPiStackingAngle: number\n maxCationPiDist: number\n maxCationPiOffset: number\n maxIonicDist: number\n maxHalogenBondDist: number\n maxHalogenBondAngle: number\n maxMetalDist: number\n refineSaltBridges: boolean\n masterModelIndex: number\n lineOfSightDistFactor: number\n}\n\n/**\n * Contact representation.\n */\nclass ContactRepresentation extends StructureRepresentation {\n protected hydrogenBond: boolean\n protected weakHydrogenBond: boolean\n protected waterHydrogenBond: boolean\n protected backboneHydrogenBond: boolean\n protected hydrophobic: boolean\n protected halogenBond: boolean\n protected ionicInteraction: boolean\n protected metalCoordination: boolean\n protected cationPi: boolean\n protected piStacking: boolean\n protected filterSele: string|[string, string]\n protected maxHydrophobicDist: number\n protected maxHbondDist: number\n protected maxHbondSulfurDist: number\n protected maxHbondAccAngle: number\n protected maxHbondDonAngle: number\n protected maxHbondAccPlaneAngle: number\n protected maxHbondDonPlaneAngle: number\n protected maxPiStackingDist: number\n protected maxPiStackingOffset: number\n protected maxPiStackingAngle: number\n protected maxCationPiDist: number\n protected maxCationPiOffset: number\n protected maxIonicDist: number\n protected maxHalogenBondDist: number\n protected maxHalogenBondAngle: number\n protected maxMetalDist: number\n protected refineSaltBridges: boolean\n protected masterModelIndex: number\n protected lineOfSightDistFactor: number\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'contact'\n\n this.parameters = Object.assign({\n hydrogenBond: {\n type: 'boolean', rebuild: true\n },\n weakHydrogenBond: {\n type: 'boolean', rebuild: true\n },\n waterHydrogenBond: {\n type: 'boolean', rebuild: true\n },\n backboneHydrogenBond: {\n type: 'boolean', rebuild: true\n },\n hydrophobic: {\n type: 'boolean', rebuild: true\n },\n halogenBond: {\n type: 'boolean', rebuild: true\n },\n ionicInteraction: {\n type: 'boolean', rebuild: true\n },\n metalCoordination: {\n type: 'boolean', rebuild: true\n },\n cationPi: {\n type: 'boolean', rebuild: true\n },\n piStacking: {\n type: 'boolean', rebuild: true\n },\n\n filterSele: {\n type: 'text', rebuild: true\n },\n\n labelVisible: {\n type: 'boolean', rebuild: true\n },\n\n labelFixedSize: {\n type: 'boolean', buffer: 'fixedSize'\n },\n\n labelSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001, rebuild: true\n },\n\n labelUnit: {\n type: 'select',\n rebuild: true,\n options: { '': '', angstrom: 'angstrom', nm: 'nm' }\n },\n\n maxHydrophobicDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHbondDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHbondSulfurDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHbondAccAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n maxHbondDonAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n maxHbondAccPlaneAngle: {\n type: 'integer', max: 90, min: 0, rebuild: true\n },\n maxHbondDonPlaneAngle: {\n type: 'integer', max: 90, min: 0, rebuild: true\n },\n maxPiStackingDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxPiStackingOffset: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxPiStackingAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n maxCationPiDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxCationPiOffset: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxIonicDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHalogenBondDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n maxHalogenBondAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n maxMetalDist: {\n type: 'number', precision: 1, max: 10, min: 0.1, rebuild: true\n },\n refineSaltBridges: {\n type: 'boolean', rebuild: true\n },\n masterModelIndex: {\n type: 'integer', max: 1000, min: -1, rebuild: true\n },\n lineOfSightDistFactor: {\n type: 'number', precision: 1, max: 10, min: 0.0, rebuild: true\n },\n\n radialSegments: true,\n disableImpostor: true\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.radiusSize = defaults(p.radiusSize, 0.05)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.hydrogenBond = defaults(p.hydrogenBond, true)\n this.weakHydrogenBond = defaults(p.weakHydrogenBond, false)\n this.waterHydrogenBond = defaults(p.waterHydrogenBond, false)\n this.backboneHydrogenBond = defaults(p.backboneHydrogenBond, false)\n this.hydrophobic = defaults(p.hydrophobic, false)\n this.halogenBond = defaults(p.halogenBond, true)\n this.ionicInteraction = defaults(p.ionicInteraction, true)\n this.metalCoordination = defaults(p.metalCoordination, true)\n this.cationPi = defaults(p.cationPi, true)\n this.piStacking = defaults(p.piStacking, true)\n\n this.filterSele = defaults(p.filterSele, '')\n this.labelVisible = defaults(p.labelVisible, false)\n this.labelFixedSize = defaults(p.labelFixedSize, false)\n this.labelSize = defaults(p.labelSize, 2.0)\n this.labelUnit = defaults(p.labelUnit, '')\n\n this.maxHydrophobicDist = defaults(p.maxHydrophobicDist, 4.0)\n this.maxHbondDist = defaults(p.maxHbondDist, 3.5)\n this.maxHbondSulfurDist = defaults(p.maxHbondSulfurDist, 4.1)\n this.maxHbondAccAngle = defaults(p.maxHbondAccAngle, 45)\n this.maxHbondDonAngle = defaults(p.maxHbondDonAngle, 45)\n this.maxHbondAccPlaneAngle = defaults(p.maxHbondAccPlaneAngle, 90)\n this.maxHbondDonPlaneAngle = defaults(p.maxHbondDonPlaneAngle, 30)\n this.maxPiStackingDist = defaults(p.maxPiStackingDist, 5.5)\n this.maxPiStackingOffset = defaults(p.maxPiStackingOffset, 2.0)\n this.maxPiStackingAngle = defaults(p.maxPiStackingAngle, 30)\n this.maxCationPiDist = defaults(p.maxCationPiDist, 6.0)\n this.maxCationPiOffset = defaults(p.maxCationPiOffset, 2.0)\n this.maxIonicDist = defaults(p.maxIonicDist, 5.0)\n this.maxHalogenBondDist = defaults(p.maxHalogenBondDist, 3.5)\n this.maxHalogenBondAngle = defaults(p.maxHalogenBondAngle, 30)\n this.maxMetalDist = defaults(p.maxMetalDist, 3.0)\n this.refineSaltBridges = defaults(p.refineSaltBridges, true)\n this.masterModelIndex = defaults(p.masterModelIndex, -1)\n this.lineOfSightDistFactor = defaults(p.lineOfSightDistFactor, 1.0)\n\n super.init(p)\n }\n\n getAtomRadius () {\n return 0\n }\n\n getContactData (sview: StructureView) {\n const params = {\n maxHydrophobicDist: this.maxHydrophobicDist,\n maxHbondDist: this.maxHbondDist,\n maxHbondSulfurDist: this.maxHbondSulfurDist,\n maxHbondAccAngle: this.maxHbondAccAngle,\n maxHbondDonAngle: this.maxHbondDonAngle,\n maxHbondAccPlaneAngle: this.maxHbondAccPlaneAngle,\n maxHbondDonPlaneAngle: this.maxHbondDonPlaneAngle,\n maxPiStackingDist: this.maxPiStackingDist,\n maxPiStackingOffset: this.maxPiStackingOffset,\n maxPiStackingAngle: this.maxPiStackingAngle,\n maxCationPiDist: this.maxCationPiDist,\n maxCationPiOffset: this.maxCationPiOffset,\n maxIonicDist: this.maxIonicDist,\n maxHalogenBondDist: this.maxHalogenBondDist,\n maxHalogenBondAngle: this.maxHalogenBondAngle,\n maxMetalDist: this.maxMetalDist,\n refineSaltBridges: this.refineSaltBridges,\n masterModelIndex: this.masterModelIndex,\n lineOfSightDistFactor: this.lineOfSightDistFactor\n }\n\n const dataParams = {\n hydrogenBond: this.hydrogenBond,\n weakHydrogenBond: this.weakHydrogenBond,\n waterHydrogenBond: this.waterHydrogenBond,\n backboneHydrogenBond: this.backboneHydrogenBond,\n hydrophobic: this.hydrophobic,\n halogenBond: this.halogenBond,\n ionicInteraction: this.ionicInteraction,\n metalCoordination: this.metalCoordination,\n cationPi: this.cationPi,\n piStacking: this.piStacking,\n radius: this.radiusSize * this.radiusScale,\n filterSele: this.filterSele\n }\n\n const contacts = calculateContacts(sview, params)\n return getContactData(contacts, sview, dataParams)\n }\n\n createData (sview: StructureView) {\n const contactData = this.getContactData(sview)\n\n const bufferList = [\n new CylinderBuffer(\n getFixedCountDashData(contactData),\n this.getBufferParams({\n sphereDetail: 1,\n dullInterior: true,\n disableImpostor: this.disableImpostor\n })\n ) as (CylinderGeometryBuffer | CylinderImpostorBuffer | TextBuffer)\n ]\n\n if (this.labelVisible) {\n const labelParams = {\n size: this.labelSize,\n unit: this.labelUnit\n }\n bufferList.push(new TextBuffer(\n getLabelData(contactData, labelParams),\n this.getBufferParams({fixedSize: this.labelFixedSize})\n ))\n }\n\n return { bufferList }\n }\n}\n\nRepresentationRegistry.add('contact', ContactRepresentation)\n\nexport default ContactRepresentation\n","/**\n * @file Dihedral Representation\n * @author Fred Ludlow \n * @private\n */\nimport { Color } from 'three'\n\nimport { RepresentationRegistry } from '../globals'\nimport MeasurementRepresentation, { calcArcPoint, parseNestedAtoms, MeasurementRepresentationParameters, LabelDataField } from './measurement-representation'\nimport { defaults } from '../utils'\n\nimport MeshBuffer from '../buffer/mesh-buffer'\nimport TextBuffer, { TextBufferData } from '../buffer/text-buffer'\nimport WideLineBuffer from '../buffer/wideline-buffer'\n\nimport { copyArray, uniformArray, uniformArray3 } from '../math/array-utils'\nimport { v3add, v3angle, v3cross, v3dot, v3multiplyScalar, v3fromArray, v3length,\n v3negate, v3new, v3normalize, v3sub, v3toArray } from '../math/vector-utils'\nimport { RAD2DEG } from '../math/math-constants'\nimport { getFixedLengthWrappedDashData } from '../geometry/dash'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { CylinderBufferData } from '../buffer/cylinder-buffer';\nimport { BufferData } from '../buffer/buffer';\nimport { StructureRepresentationData } from './structure-representation';\n\n/**\n * @typedef {Object} DihedralRepresentationParameters - dihedral representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n * @mixes MeasurementRepresentationParameters\n *\n * @property {String} atomQuad - list of quadruplets of selection strings\n * or atom indices\n * @property {Boolean} extendLine - Extend lines in planes\n * @property {Number} lineOpacity - Opacity for the line part of the representation\n * @property {Boolean} lineVisible - Display the line part of the representation\n * @property {Number} linewidth - width for line part of representation\n * @property {Boolean} planeVisible - Display the two planes corresponding to dihedral\n * @property {Boolean} sectorVisible - Display the filled arc for each angle\n */\n\nexport interface DihedralRepresentationParameters extends MeasurementRepresentationParameters {\n atomQuad: (number|string)[][]\n extendLine: boolean\n lineOpacity: number\n lineVisible: boolean\n linewidth: number\n planeVisible: boolean\n sectorVisible: boolean\n}\n\n/**\n * Dihedral representation object\n *\n * Reperesentation consists of three parts, visibility can be set for each\n * label - text label indicating dihedral angle\n * line - line indicating four positions that define the dihedral\n * sector - filled arc section\n *\n * @param {Structure} structure - the structure to measure angles in\n * @param {Viewer} viewer - a viewer object\n * @param {AngleRepresentationParameters} params - angle representation parameters\n */\nclass DihedralRepresentation extends MeasurementRepresentation {\n protected atomQuad: (number|string)[][]\n protected extendLine: boolean\n protected lineOpacity: number\n protected lineVisible: boolean\n protected linewidth: number\n protected planeVisible: boolean\n protected sectorVisible: boolean\n\n protected lineLength: number\n protected planeLength: number\n protected sectorLength: number\n\n protected lineBuffer: WideLineBuffer\n protected planeBuffer: MeshBuffer\n protected sectorBuffer: MeshBuffer\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'dihedral'\n\n this.parameters = Object.assign({\n atomQuad: {\n type: 'hidden', rebuild: true\n },\n extendLine: {\n type: 'boolean', rebuild: true, default: true\n },\n lineVisible: {\n type: 'boolean', default: true\n },\n planeVisible: {\n type: 'boolean', default: true\n },\n sectorVisible: {\n type: 'boolean', default: true\n }\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.side = defaults(p.side, 'double')\n p.opacity = defaults(p.opacity, 0.5)\n\n this.atomQuad = defaults(p.atomQuad, [])\n this.extendLine = defaults(p.extendLine, true)\n this.lineVisible = defaults(p.lineVisible, true)\n this.planeVisible = defaults(p.planeVisible, true)\n this.sectorVisible = defaults(p.sectorVisible, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n if (!sview.atomCount || !this.atomQuad.length) return\n\n const atomPosition = parseNestedAtoms(sview, this.atomQuad)\n const dihedralData = getDihedralData(\n atomPosition, {\n extendLine: this.extendLine\n }\n )\n\n const n = this.n = dihedralData.labelText.length\n const labelColor = new Color(this.labelColor)\n\n this.textBuffer = new TextBuffer({\n position: dihedralData.labelPosition,\n size: uniformArray(n, this.labelSize),\n color: uniformArray3(n, labelColor.r, labelColor.g, labelColor.b),\n text: dihedralData.labelText\n } as TextBufferData, this.getLabelBufferParams())\n\n const c = new Color(this.colorValue)\n this.lineLength = dihedralData.linePosition1.length / 3\n const lineColor = uniformArray3(this.lineLength, c.r, c.g, c.b)\n\n this.lineBuffer = new WideLineBuffer(\n getFixedLengthWrappedDashData({\n position1: dihedralData.linePosition1,\n position2: dihedralData.linePosition2,\n color: lineColor,\n color2: lineColor\n } as CylinderBufferData) ,\n this.getBufferParams({\n linewidth: this.linewidth,\n visible: this.lineVisible,\n opacity: this.lineOpacity\n })\n )\n\n this.planeLength = dihedralData.planePosition.length / 3\n this.planeBuffer = new MeshBuffer({\n position: dihedralData.planePosition,\n color: uniformArray3(this.planeLength, c.r, c.g, c.b)\n } as BufferData, this.getBufferParams({\n visible: this.planeVisible\n }))\n\n this.sectorLength = dihedralData.sectorPosition.length / 3\n this.sectorBuffer = new MeshBuffer({\n position: dihedralData.sectorPosition,\n color: uniformArray3(this.sectorLength, c.r, c.g, c.b)\n } as BufferData, this.getBufferParams({\n visible: this.sectorVisible\n }))\n\n return {\n bufferList: [\n this.textBuffer,\n this.lineBuffer,\n this.planeBuffer,\n this.sectorBuffer\n ]\n }\n }\n\n updateData (what: LabelDataField & {color?: boolean}, data: StructureRepresentationData) {\n super.updateData(what, data)\n const lineData = {}\n const planeData = {}\n const sectorData = {}\n\n if (what.color) {\n const c = new Color(this.colorValue)\n Object.assign(lineData, {\n color: uniformArray3(this.lineLength, c.r, c.g, c.b),\n color2: uniformArray3(this.lineLength, c.r, c.g, c.b)\n })\n Object.assign(planeData, {\n color: uniformArray3(this.planeLength, c.r, c.g, c.b)\n })\n Object.assign(sectorData, {\n color: uniformArray3(this.sectorLength, c.r, c.g, c.b)\n })\n }\n\n this.lineBuffer.setAttributes(lineData)\n this.planeBuffer.setAttributes(planeData)\n this.sectorBuffer.setAttributes(sectorData)\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n super.setParameters(params, what, rebuild)\n\n if (params && (\n params.lineVisible !== undefined ||\n params.sectorVisible !== undefined ||\n params.planeVisible !== undefined)) {\n this.setVisibility(this.visible)\n }\n\n if (params && params.lineOpacity) {\n this.lineBuffer.setParameters({ opacity: params.lineOpacity })\n }\n\n if (params && params.opacity !== undefined) {\n this.lineBuffer.setParameters({ opacity: this.lineOpacity })\n }\n\n if (params && params.linewidth) {\n this.lineBuffer.setParameters({ linewidth: params.linewidth })\n }\n\n return this\n }\n\n setVisibility (value: boolean, noRenderRequest?: boolean) {\n super.setVisibility(value, true)\n\n if (this.lineBuffer) {\n this.lineBuffer.setVisibility(this.lineVisible && this.visible)\n }\n\n if (this.planeBuffer) {\n this.planeBuffer.setVisibility(this.planeVisible && this.visible)\n }\n\n if (this.sectorBuffer) {\n this.sectorBuffer.setVisibility(this.sectorVisible && this.visible)\n }\n\n if (!noRenderRequest) this.viewer.requestRender()\n\n return this\n }\n}\n\n/**\n * Build the data required to create {Buffer} objects, given positions\n * @param {Float32Array} atomPosition 3*4*nDihedral array of coordinates\n * @return {Object} Arrays for building buffers\n */\nfunction getDihedralData (position: Float32Array, params: Partial = {}) {\n const angleStep = defaults(params.angleStep, Math.PI / 90)\n const nPos = position.length\n const n = position.length / 12\n const angles = new Float32Array(n)\n const labelPosition = new Float32Array(n * 3)\n const labelText = new Array(n)\n\n // Temporary arrays as don't know output length yet\n const lineTmp1 = new Array(n)\n const lineTmp2 = new Array(n)\n const sectorTmp = new Array(n)\n const planeTmp = new Array(n)\n\n // Eventual sizes of output arrays\n let totalLines = 0\n let totalSegments = 0\n let totalPlanes = 0\n\n const p1 = v3new()\n const p2 = v3new()\n const p3 = v3new()\n const p4 = v3new()\n\n const v21 = v3new()\n const v23 = v3new()\n const v34 = v3new()\n\n const tmp = v3new()\n const mid = v3new()\n const inPlane1 = v3new()\n const inPlane2 = v3new()\n const start = v3new()\n const end = v3new()\n\n const cross = v3new()\n const arcPoint = v3new()\n\n let i = 0 // Actual output index (after skipping inappropriate)\n\n for (var p = 0; p < nPos; p += 12) {\n // Set Positions\n v3fromArray(p1, position, p)\n v3fromArray(p2, position, p + 3)\n v3fromArray(p3, position, p + 6)\n v3fromArray(p4, position, p + 9)\n\n // Vectors between points\n v3sub(v21, p1, p2)\n v3sub(v23, p3, p2)\n if (v3length(v23) === 0.0) {\n continue // Can't define axis\n }\n\n v3sub(v34, p4, p3)\n\n v3multiplyScalar(tmp, v23, 0.5)\n v3add(mid, p2, tmp)\n\n v3normalize(v21, v21)\n v3normalize(v23, v23)\n v3normalize(v34, v34)\n\n // Which side of plane are p1, p4 (are we measuring something that\n // looks more like an improper? e.g. C, CA, CB, N)\n v3sub(tmp, p1, mid)\n const improperStart = v3dot(tmp, v23) > 0.0\n v3sub(tmp, p4, mid)\n const improperEnd = v3dot(tmp, v23) < 0.0\n\n // Calculate vectors perp to v23 (lying in plane (1,2,3) and (2,3,4))\n v3multiplyScalar(tmp, v23, v3dot(v23, v21))\n v3sub(inPlane1, v21, tmp)\n\n v3multiplyScalar(tmp, v23, v3dot(v23, v34))\n v3sub(inPlane2, v34, tmp)\n\n if (v3length(inPlane1) === 0.0 || v3length(inPlane2) === 0.0) {\n continue // Indeterminate angle\n }\n\n v3normalize(inPlane1, inPlane1)\n v3normalize(inPlane2, inPlane2)\n\n const angle = angles[ i ] = v3angle(inPlane1, inPlane2)\n labelText[ i ] = (RAD2DEG * angle).toFixed(1) + String.fromCharCode(0x00B0)\n\n v3cross(cross, inPlane1, v23)\n v3normalize(cross, cross)\n if (v3dot(cross, inPlane2) < 0.0) {\n v3negate(cross, cross) // Ensure cp faces correct way\n }\n\n calcArcPoint(tmp, mid, inPlane1, cross, angle / 2.0)\n v3toArray(tmp, labelPosition, 3 * i)\n\n const nSegments = Math.ceil(angle / angleStep)\n // For extended display mode, 4 straight lines plus arc/segment edge\n // For non-extended, 2 straight lines plus segment edge\n const nLines = nSegments + ((params.extendLine) ? 4 : 2)\n\n // Don't draw planes if not extending lines\n const nPlanes = params.extendLine ? 36 : 0\n\n const line1 = new Float32Array(nLines * 3)\n const line2 = new Float32Array(nLines * 3)\n const sector = new Float32Array(nSegments * 9)\n // 2 planes, 2 triangles each per dihedral (2*2*9)\n const plane = new Float32Array(nPlanes)\n\n lineTmp1[ i ] = line1\n lineTmp2[ i ] = line2\n sectorTmp[ i ] = sector\n planeTmp[ i ] = plane\n\n // Start points for lines/planes, only required\n // if extending lines\n if (params.extendLine) {\n if (improperStart) { // We'll start on the v3->1 line (tmp)\n v3sub(tmp, p1, p3)\n v3normalize(tmp, tmp)\n v3multiplyScalar(start, tmp, 1.0 / v3dot(inPlane1, tmp))\n v3add(start, start, p3)\n } else { // start on the 2->1 line\n v3multiplyScalar(start, v21, 1.0 / v3dot(inPlane1, v21))\n v3add(start, start, p2)\n }\n\n if (improperEnd) { // Finish on 2->4 line\n v3sub(tmp, p4, p2)\n v3normalize(tmp, tmp)\n v3multiplyScalar(end, tmp, 1.0 / v3dot(inPlane2, tmp))\n v3add(end, end, p2)\n } else { // end on the 3->4 line\n v3multiplyScalar(end, v34, 1.0 / v3dot(inPlane2, v34))\n v3add(end, end, p3)\n }\n }\n\n v3add(arcPoint, mid, inPlane1)\n\n // index into line1, line2\n let li = 0\n // If extending lines, there's a bit of stuff to do here\n // figuring out start and end positions\n if (params.extendLine) {\n v3toArray(p1, line1, li)\n v3toArray(start, line2, li)\n li += 3\n v3toArray(start, line1, li)\n v3toArray(arcPoint, line2, li)\n li += 3\n\n // Construct plane at start, if not extening lines\n // this is skipped\n v3toArray(start, plane, 0)\n v3toArray(arcPoint, plane, 3)\n v3toArray(improperStart ? p3 : p2, plane, 6)\n v3toArray(improperStart ? p3 : p2, plane, 9)\n v3toArray(arcPoint, plane, 12)\n v3toArray(mid, plane, 15)\n } else {\n // Not extending lines\n v3toArray(mid, line1, li)\n v3toArray(arcPoint, line2, li)\n li += 3\n }\n\n const appendArcSection = function (a: number, j: number) {\n const si = j * 9\n\n v3toArray(mid, sector, si)\n v3toArray(arcPoint, sector, si + 3)\n v3toArray(arcPoint, line1, li)\n\n calcArcPoint(arcPoint, mid, inPlane1, cross, a)\n\n v3toArray(arcPoint, sector, si + 6)\n v3toArray(arcPoint, line2, li)\n li += 3\n }\n\n let j = 0\n for (let a = angleStep; a < angle; a += angleStep) {\n appendArcSection(a, j++)\n }\n appendArcSection(angle, j++)\n\n if (params.extendLine) {\n v3toArray(arcPoint, line1, (nLines - 2) * 3)\n v3toArray(end, line2, (nLines - 2) * 3)\n v3toArray(end, line1, (nLines - 1) * 3)\n v3toArray(p4, line2, (nLines - 1) * 3)\n\n // Construct plane at end\n v3toArray(end, plane, 18)\n v3toArray(arcPoint, plane, 21)\n v3toArray(improperEnd ? p2 : p3, plane, 24)\n v3toArray(improperEnd ? p2 : p3, plane, 27)\n v3toArray(arcPoint, plane, 30)\n v3toArray(mid, plane, 33)\n } else {\n v3toArray(arcPoint, line1, li)\n v3toArray(mid, line2, li)\n li += 3\n }\n\n totalLines += nLines * 3\n totalSegments += nSegments * 9\n totalPlanes += nPlanes\n i += 1\n }\n\n const nSuccess = i\n\n const linePosition1 = new Float32Array(totalLines)\n const linePosition2 = new Float32Array(totalLines)\n const sectorPosition = new Float32Array(totalSegments)\n const planePosition = new Float32Array(totalPlanes)\n\n let lineOffset = 0\n let sectorOffset = 0\n let planeOffset = 0\n\n for (let i = 0; i < nSuccess; i++) {\n const lp1 = lineTmp1[ i ]\n const lp2 = lineTmp2[ i ]\n const sp = sectorTmp[ i ]\n const pp = planeTmp[ i ]\n\n copyArray(lp1, linePosition1, 0, lineOffset, lp1.length)\n copyArray(lp2, linePosition2, 0, lineOffset, lp2.length)\n copyArray(sp, sectorPosition, 0, sectorOffset, sp.length)\n copyArray(pp, planePosition, 0, planeOffset, pp.length)\n\n lineOffset += lp1.length\n sectorOffset += sp.length\n planeOffset += pp.length\n }\n\n return {\n labelPosition: labelPosition.subarray(0, nSuccess * 3),\n labelText: labelText.slice(0, nSuccess),\n linePosition1,\n linePosition2,\n planePosition,\n sectorPosition\n }\n}\n\nRepresentationRegistry.add('dihedral', DihedralRepresentation)\n\nexport default DihedralRepresentation\n","/**\n * @file Dihedral Histogram Representation\n * @author Rudolfs Petrovs \n * @private\n */\nimport { Color } from 'three'\n\nimport { calcArcPoint, parseNestedAtoms } from './measurement-representation'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\n\nimport { RepresentationRegistry } from '../globals'\nimport { Structure } from '../ngl'\nimport { defaults } from '../utils'\n\nimport { BufferData } from '../buffer/buffer'\nimport MeshBuffer from '../buffer/mesh-buffer'\nimport WideLineBuffer, { WideLineBufferData } from '../buffer/wideline-buffer'\n\nimport { copyArray, uniformArray3, arraySum } from '../math/array-utils'\nimport {\n v3add, v3cross, v3dot, v3multiplyScalar, v3fromArray,\n v3negate, v3new, v3normalize, v3sub, v3toArray, v3length\n} from '../math/vector-utils'\n\nimport StructureView from '../structure/structure-view'\n\nimport Viewer from '../viewer/viewer'\n\n\nconst pointLength = 3 // One Point Length (number of coordinates of one point in 3D)\nconst pointsInTriangle = 3\n\ntype ColorDefinition = Color | string | number | undefined\n\ninterface HistogramColorParameters {\n histogramBinBorderColor: ColorDefinition\n adjacentBondArrowColor: ColorDefinition\n distantBondArrowColor: ColorDefinition\n frontHistogramColor: ColorDefinition\n backHistogramColor: ColorDefinition\n opaqueMiddleDiscColor: ColorDefinition\n}\n\ninterface HistogramInputData extends Partial {\n atomQuad: (number | string)[]\n histogram360: number[]\n}\n\ninterface HistogramData extends HistogramInputData {\n atomPositions: Float32Array\n histogram360Scaled: number[]\n}\n\ninterface WideLineData {\n startPoints: Float32Array\n endPoints: Float32Array\n startColors: Float32Array\n endColors: Float32Array\n}\n\ninterface MeshData {\n triangles: Float32Array\n triangleColors: Float32Array\n}\n\nfunction createUpdatedObject(o: Object, updateSource: Object) {\n function hasKey(obj: O, key: keyof any): key is keyof O {\n return key in obj\n }\n\n const result = { ...o } // Shallow copy\n for (const key in result) {\n if (hasKey(result, key) && hasKey(updateSource, key)) {\n result[key] = defaults(updateSource[key], result[key])\n }\n }\n return result\n}\n\nfunction createColorArray(color: ColorDefinition, arrayLength: number) {\n const colorValue = new Color(color)\n const targetArray = new Float32Array(arrayLength * 3)\n uniformArray3(arrayLength, colorValue.r, colorValue.g, colorValue.b, targetArray)\n return targetArray\n}\n\n/**\n * @typedef {Object} DihedralHistogramRepresentationParameters - dihedral representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n *\n * @property {HistogramInputData[]} histogramsData\n * List of HistogramInputData objects, which properties specifies each particular\n * histogram, and can contain particular histogram-specific parameters.\n * Obligatory properties are:\n * atomQuad - Quadruplet of selection strings or atom indices\n * histogram360 - List of values, representing histogram from 0 to 360 degrees.\n * @property {Boolean} histogramBinBorderVisible - Display the lines that separate circular histogram bins\n * @property {Boolean} scaleBinToSectorArea - Should sector-based histogram bins'\n * area be proportional to the bins' value\n */\n\nexport interface DihedralHistogramRepresentationParameters extends StructureRepresentationParameters {\n histogramsData: HistogramInputData[]\n\n histogramBinBorderVisible: boolean\n scaleBinToSectorArea: boolean\n}\n\n/**\n * Dihedral Histogram representation object\n *\n * Reperesentation consists of several parts:\n * opaqueMiddleDisc - opaque disc in the middle of the dihedral between front and back histograms\n * frontHistogram - circular histogram from the adjacent bond viewpoint\n * backHistogram - circular histogram from the distant bond viewpoint\n * histogramBinBorder - lines, which separate histogram bins\n * bondArrows - lines, which show the actual angle on the histogram disc\n *\n * @param {Structure} structure - the structure to measure angles in\n * @param {Viewer} viewer - a viewer object\n * @param {DihedralHistogramRepresentationParameters} params - Dihedral histogram representation parameters\n */\nclass DihedralHistogramRepresentation extends StructureRepresentation {\n protected histogramsData: HistogramData[]\n\n protected histogramBinBorderVisible: boolean\n protected histogramBinBorderWidth: number\n protected histogramBinBorderColor: ColorDefinition\n protected histogramBinBorderOpacity: number\n\n protected bondArrowVisible: boolean\n protected bondArrowWidth: number\n protected bondArrowOpacity: number\n\n protected adjacentBondArrowColor: ColorDefinition\n protected distantBondArrowColor: ColorDefinition\n\n protected histogramOpacity: number\n protected frontHistogramColor: ColorDefinition\n protected backHistogramColor: ColorDefinition\n\n protected opaqueMiddleDiscVisible: boolean\n protected opaqueMiddleDiscColor: ColorDefinition\n protected opaqueMiddleDiscOpacity: number\n\n protected scaleBinToSectorArea: boolean\n\n constructor(structure: Structure, viewer: Viewer, params: DihedralHistogramRepresentationParameters) {\n super(structure, viewer, params)\n\n this.type = 'dihedral-histogram'\n\n this.parameters = Object.assign({\n histogramsData: {\n type: 'hidden', rebuild: true\n },\n histogramBinBorderVisible: {\n type: 'boolean', default: true\n },\n scaleBinToSectorArea: {\n type: 'boolean',\n rebuild: true,\n default: false\n }\n }, this.parameters)\n\n this.init(params)\n }\n\n init(params: Partial) {\n const p = params || {}\n\n const defaultColorData = {\n histogramBinBorderColor: 'grey',\n adjacentBondArrowColor: 'black',\n distantBondArrowColor: 'magenta',\n frontHistogramColor: 'green',\n backHistogramColor: 'blue',\n opaqueMiddleDiscColor: 'white'\n }\n\n const colorData = createUpdatedObject(defaultColorData, p)\n Object.assign(this, colorData)\n\n const defaultParameters = {\n histogramsData: [],\n histogramOpacity: 1.0,\n\n opaqueMiddleDiscVisible: true,\n opaqueMiddleDiscOpacity: 1.0,\n\n histogramBinBorderVisible: true,\n histogramBinBorderWidth: 1,\n histogramBinBorderOpacity: 0.5,\n\n bondArrowVisible: true,\n bondArrowWidth: 2,\n bondArrowOpacity: 1.0,\n\n scaleBinToSectorArea: false,\n }\n const parameters = createUpdatedObject(defaultParameters, p)\n Object.assign(this, parameters)\n\n this.histogramsData.forEach(x => {\n const specificColorData = createUpdatedObject(colorData, x)\n Object.assign(x, specificColorData)\n })\n\n p.side = defaults(p.side, 'double')\n p.opacity = defaults(p.opacity, 0.5)\n p.radiusType = defaults(p.radiusType, 'size')\n p.radiusSize = defaults(p.radiusSize, 0.15)\n\n super.init(p)\n }\n\n getHistogramBinBorderBufferParameters() {\n return this.getBufferParams({\n linewidth: this.histogramBinBorderWidth,\n visible: this.histogramBinBorderVisible,\n opacity: this.histogramBinBorderOpacity,\n })\n }\n\n getBondArrowsBufferParameters() {\n return this.getBufferParams({\n linewidth: this.bondArrowWidth,\n visible: this.bondArrowVisible,\n opacity: this.bondArrowOpacity,\n })\n }\n\n getOpaqueMiddleDiscBufferParameters() {\n return this.getBufferParams({\n visible: this.opaqueMiddleDiscVisible,\n opacity: this.opaqueMiddleDiscOpacity\n })\n }\n\n getHistogramBufferParameters() {\n return this.getBufferParams({\n visible: true,\n opacity: this.histogramOpacity,\n side: \"double\"\n })\n }\n\n createData(sview: StructureView) {\n if (!sview.atomCount || !this.histogramsData.length) return\n this.histogramsData.forEach(x => x.atomPositions = parseNestedAtoms(sview, [x.atomQuad]))\n const scaleData = this.scaleBinToSectorArea ? function (y: number) { return Math.sqrt(y) } : function (y: number) { return y }\n this.histogramsData.forEach(x => x.histogram360Scaled = x.histogram360.map(scaleData))\n function Float32Concat(arrays: Float32Array[]) {\n const lengths = arrays.map(x => x.length)\n const result = new Float32Array(arraySum(lengths))\n let accumulatedOffset = 0\n for (let i = 0; i < arrays.length; i++) {\n result.set(arrays[i], accumulatedOffset)\n accumulatedOffset += arrays[i].length\n }\n return result\n }\n\n function createWideLineBuffer(linesList: WideLineData[], params: {}) {\n return new WideLineBuffer(\n {\n position1: Float32Concat(linesList.map(x => x.startPoints)),\n position2: Float32Concat(linesList.map(x => x.endPoints)),\n color: Float32Concat(linesList.map(x => x.startColors)),\n color2: Float32Concat(linesList.map(x => x.endColors)),\n } as WideLineBufferData,\n params)\n }\n\n function createMeshBuffer(mesh: MeshData[], params: {}) {\n return new MeshBuffer(\n {\n position: Float32Concat(mesh.map(x => x.triangles)),\n color: Float32Concat(mesh.map(x => x.triangleColors))\n } as BufferData,\n params)\n }\n\n const dihedralDataArray = []\n\n for (let i = 0; i < this.histogramsData.length; i++) {\n let dihedralData = undefined\n let currentHistogramData = this.histogramsData[i]\n let currentHistogram360 = currentHistogramData.histogram360\n if (currentHistogram360.length >= 3) {\n dihedralData = calculateDihedralHistogram(currentHistogramData)\n }\n if (typeof dihedralData === \"undefined\") continue\n dihedralDataArray.push(dihedralData)\n }\n\n this.frontHistogramBinBordersBuffer = createWideLineBuffer(\n dihedralDataArray.map(x => x.frontHistogramBinBorders),\n this.getHistogramBinBorderBufferParameters()\n )\n\n this.backHistogramBinBordersBuffer = createWideLineBuffer(\n dihedralDataArray.map(x => x.backHistogramBinBorders),\n this.getHistogramBinBorderBufferParameters()\n )\n\n this.adjacentBondArrowsBuffer = createWideLineBuffer(\n dihedralDataArray.map(x => x.adjacentBondArrows),\n this.getBondArrowsBufferParameters()\n )\n\n this.distantBondArrowsBuffer = createWideLineBuffer(\n dihedralDataArray.map(x => x.distantBondArrows),\n this.getBondArrowsBufferParameters()\n )\n\n this.opaqueMiddleDiscBuffer = createMeshBuffer(\n dihedralDataArray.map(x => x.opaqueMiddleDisc),\n this.getOpaqueMiddleDiscBufferParameters()\n )\n\n this.frontHistogramBuffer = createMeshBuffer(\n dihedralDataArray.map(x => x.frontHistogram),\n this.getHistogramBufferParameters()\n )\n\n this.backHistogramBuffer = createMeshBuffer(\n dihedralDataArray.map(x => x.backHistogram),\n this.getHistogramBufferParameters()\n )\n\n return {\n bufferList: [].concat(\n this.frontHistogramBinBordersBuffer,\n this.backHistogramBinBordersBuffer,\n this.adjacentBondArrowsBuffer,\n this.distantBondArrowsBuffer,\n this.opaqueMiddleDiscBuffer,\n this.frontHistogramBuffer,\n this.backHistogramBuffer\n )\n }\n }\n\n setParameters(params: Partial) {\n const rebuild = false\n const what = {}\n super.setParameters(params, what, rebuild)\n\n if (params && (params.histogramBinBorderVisible !== undefined)) {\n this.setVisibility(this.visible)\n }\n return this\n }\n\n setVisibility(value: boolean, noRenderRequest?: boolean) {\n super.setVisibility(value, true)\n if (this.frontHistogramBinBordersBuffer) {\n this.frontHistogramBinBordersBuffer.setVisibility(this.histogramBinBorderVisible)\n }\n if (this.backHistogramBinBordersBuffer) {\n this.backHistogramBinBordersBuffer.setVisibility(this.histogramBinBorderVisible)\n }\n if (!noRenderRequest) this.viewer.requestRender()\n return this\n }\n}\n\n/**\n * Calculates the data required to create {Buffer} objects for one histogram, given positions\n * @param Float32Array positionOfDihedralAtoms 3*4 array of coordinates\n * @param NumberArray histogram array of coordinates\n * @return Arrays for building buffers\n */\nfunction calculateDihedralHistogram(histogramData: HistogramData) {\n const positionOfDihedralAtoms = histogramData.atomPositions\n const histogram = histogramData.histogram360Scaled;\n const totalSectorTrianglesInOpaqueMiddleDisc = histogram.length <= 180 ? 360 : histogram.length * 2\n const frontAndBack = 2\n\n const opaqueMiddleDisc = {\n triangles: new Float32Array(totalSectorTrianglesInOpaqueMiddleDisc * pointsInTriangle * pointLength),\n triangleColors: createColorArray(histogramData.opaqueMiddleDiscColor, totalSectorTrianglesInOpaqueMiddleDisc * pointsInTriangle)\n }\n\n const frontHistogram = {\n triangles: new Float32Array(histogram.length * pointsInTriangle * pointLength),\n triangleColors: createColorArray(histogramData.frontHistogramColor, histogram.length * pointsInTriangle)\n }\n\n const backHistogram = {\n triangles: new Float32Array(histogram.length * pointsInTriangle * pointLength),\n triangleColors: createColorArray(histogramData.backHistogramColor, histogram.length * pointsInTriangle)\n }\n\n const frontHistogramBinBorders = {\n startPoints: new Float32Array(histogram.length * pointLength),\n endPoints: new Float32Array(histogram.length * pointLength),\n startColors: createColorArray(histogramData.histogramBinBorderColor, histogram.length),\n endColors: createColorArray(histogramData.histogramBinBorderColor, histogram.length)\n }\n\n const backHistogramBinBorders = {\n startPoints: new Float32Array(histogram.length * pointLength),\n endPoints: new Float32Array(histogram.length * pointLength),\n startColors: createColorArray(histogramData.histogramBinBorderColor, histogram.length),\n endColors: createColorArray(histogramData.histogramBinBorderColor, histogram.length)\n }\n\n const adjacentBondArrows = {\n startPoints: new Float32Array(frontAndBack * pointLength),\n endPoints: new Float32Array(frontAndBack * pointLength),\n startColors: createColorArray(histogramData.adjacentBondArrowColor, histogram.length),\n endColors: createColorArray(histogramData.adjacentBondArrowColor, histogram.length)\n }\n const distantBondArrows = {\n startPoints: new Float32Array(frontAndBack * pointLength),\n endPoints: new Float32Array(frontAndBack * pointLength),\n startColors: createColorArray(histogramData.distantBondArrowColor, histogram.length),\n endColors: createColorArray(histogramData.distantBondArrowColor, histogram.length)\n }\n\n const p1 = v3new()\n const p2 = v3new()\n const p3 = v3new()\n const p4 = v3new()\n\n const v21 = v3new()\n const v23 = v3new()\n const v32 = v3new()\n const v34 = v3new()\n\n const mid = v3new()\n const inPlane1 = v3new()\n const inPlane2 = v3new()\n\n const cross1 = v3new()\n const cross2 = v3new()\n\n const arcPoint = v3new()\n const tmp = v3new()\n const tmp2 = v3new()\n\n // Set Atom Coordinates\n const dihedralAtomVectors = [p1, p2, p3, p4]\n\n for (let i = 0; i < dihedralAtomVectors.length; i++) {\n v3fromArray(dihedralAtomVectors[i], positionOfDihedralAtoms, i * pointLength)\n }\n\n // Vectors between points\n v3sub(v21, p1, p2)\n v3sub(v23, p3, p2)\n v3sub(v34, p4, p3)\n if (v3length(v23) === 0.0) {\n return // Can't define axis\n }\n\n v3multiplyScalar(tmp, v23, 0.5)\n v3add(mid, p2, tmp)\n\n v3normalize(v21, v21)\n v3normalize(v23, v23)\n v3normalize(v34, v34)\n\n v3negate(v32, v23)\n // Calculate vectors perp to v23 (lying in plane (1,2,3) and (2,3,4))\n v3multiplyScalar(tmp, v32, v3dot(v32, v21))\n v3sub(inPlane1, v21, tmp)\n\n v3multiplyScalar(tmp, v23, v3dot(v23, v34))\n v3sub(inPlane2, v34, tmp)\n\n if (v3length(inPlane1) === 0.0 || v3length(inPlane2) === 0.0) {\n return // Indeterminate angle\n }\n\n v3normalize(inPlane1, inPlane1)\n v3normalize(inPlane2, inPlane2)\n\n // Can use acos as normalized and non-zero\n const absAngle = Math.acos(v3dot(inPlane1, inPlane2))\n\n v3cross(cross1, v32, inPlane1)\n v3cross(cross2, v23, inPlane2)\n v3normalize(cross1, cross1)\n v3normalize(cross2, cross2)\n\n let angle = absAngle\n if (v3dot(cross1, inPlane2) < 0.0) {\n angle = -absAngle\n }\n\n v3add(arcPoint, mid, inPlane1)\n\n // Calculate necessary constants\n const maxHist = Math.max.apply(null, histogram)\n const histBinAngleStep = (Math.PI * 2) / histogram.length\n\n function setHistogramBinCoordinates(out: Float32Array, ind: number, zeroDegreeVector: Float32Array, crossVector: Float32Array, histBinAngleStep: number) {\n const startOffset = ind * pointsInTriangle * pointLength\n v3toArray(mid, out, startOffset)\n const scalingFactor = Number(histogram[ind]) / maxHist\n v3multiplyScalar(tmp, zeroDegreeVector, scalingFactor)\n v3multiplyScalar(tmp2, crossVector, scalingFactor)\n calcArcPoint(arcPoint, mid, tmp, tmp2, ind * histBinAngleStep)\n v3toArray(arcPoint, out, startOffset + 1 * pointLength)\n calcArcPoint(arcPoint, mid, tmp, tmp2, (ind + 1) * histBinAngleStep)\n v3toArray(arcPoint, out, startOffset + 2 * pointLength)\n }\n\n function setOneSideHistogram(discHistogram: MeshData, binBorders: { startPoints: Float32Array, endPoints: Float32Array }, ind: number, zeroDegreeVector: Float32Array, crossVector: Float32Array) {\n // Set Bond Arrows\n\n copyArray(mid, adjacentBondArrows.startPoints, 0, ind * pointLength, mid.length)\n calcArcPoint(tmp, mid, zeroDegreeVector, crossVector, 0 + histBinAngleStep * 0)\n copyArray(tmp, adjacentBondArrows.endPoints, 0, ind * pointLength, mid.length)\n\n copyArray(mid, distantBondArrows.startPoints, 0, ind * pointLength, mid.length)\n calcArcPoint(tmp, mid, zeroDegreeVector, crossVector, angle)\n copyArray(tmp, distantBondArrows.endPoints, 0, ind * pointLength, mid.length)\n\n // Set Histogram Bin Borders\n\n for (let i = 0; i < histogram.length; i++) {\n copyArray(mid, binBorders.startPoints, 0, i * 3, mid.length)\n calcArcPoint(tmp, mid, zeroDegreeVector, crossVector, 0 + histBinAngleStep * i)\n copyArray(tmp, binBorders.endPoints, 0, i * 3, tmp.length)\n }\n\n // Set Histogram Bins\n\n for (let sectionIndex = 0; sectionIndex < histogram.length; sectionIndex++) {\n setHistogramBinCoordinates(discHistogram.triangles, sectionIndex, zeroDegreeVector, crossVector, histBinAngleStep)\n }\n }\n\n // Opaque disc\n const opaqueCircleSectorAngleStep = Math.PI * 2 / totalSectorTrianglesInOpaqueMiddleDisc\n\n for (let sectionIndex = 0; sectionIndex < totalSectorTrianglesInOpaqueMiddleDisc; sectionIndex++) {\n const startOffset = sectionIndex * pointsInTriangle * pointLength\n v3toArray(mid, opaqueMiddleDisc.triangles, startOffset)\n calcArcPoint(arcPoint, mid, inPlane1, cross1, sectionIndex * opaqueCircleSectorAngleStep)\n v3toArray(arcPoint, opaqueMiddleDisc.triangles, startOffset + 1 * pointLength)\n calcArcPoint(arcPoint, mid, inPlane1, cross1, (sectionIndex + 1) * opaqueCircleSectorAngleStep)\n v3toArray(arcPoint, opaqueMiddleDisc.triangles, startOffset + 2 * pointLength)\n }\n\n // Front Histogram\n const distanceToOpaqueDisc = 0.01\n v3multiplyScalar(tmp, v23, -distanceToOpaqueDisc) // Get a vector to move \"mid\" just a bit from opaque disc\n v3add(mid, mid, tmp)\n setOneSideHistogram(frontHistogram, frontHistogramBinBorders, 0, inPlane1, cross1)\n\n // Back Histogram\n v3multiplyScalar(tmp, v23, 2 * distanceToOpaqueDisc) // Get a vector to move \"mid\" back and plus just a bit from opaque disc the other way\n v3add(mid, mid, tmp)\n setOneSideHistogram(backHistogram, backHistogramBinBorders, 1, inPlane2, cross2)\n\n return {\n opaqueMiddleDisc,\n frontHistogram,\n backHistogram,\n frontHistogramBinBorders,\n backHistogramBinBorders,\n adjacentBondArrows,\n distantBondArrows\n }\n}\n\nRepresentationRegistry.add('dihedral-histogram', DihedralHistogramRepresentation)\n\nexport default DihedralHistogramRepresentation\n","/**\n * @file Distance Representation\n * @author Alexander Rose \n * @author Fred Ludlow \n * @private\n */\n\nimport { Color } from 'three'\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { DistancePicker } from '../utils/picker'\nimport { uniformArray, uniformArray3 } from '../math/array-utils'\nimport BitArray from '../utils/bitarray'\nimport MeasurementRepresentation, { MeasurementRepresentationParameters } from './measurement-representation'\nimport Selection from '../selection/selection'\nimport BondStore from '../store/bond-store'\nimport TextBuffer, { TextBufferData, TextBufferParameters } from '../buffer/text-buffer'\nimport WideLineBuffer from '../buffer/wideline-buffer'\nimport CylinderBuffer, { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport { getFixedLengthDashData } from '../geometry/dash'\nimport Viewer from '../viewer/viewer';\nimport { Structure } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport { BondDataFields, BondDataParams, BondData } from '../structure/structure-data';\nimport { StructureRepresentationData } from './structure-representation';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\n\n/**\n * Distance representation parameter object.\n * @typedef {Object} DistanceRepresentationParameters - distance representation parameters\n * @mixes RepresentationParameters\n * @mixes StructureRepresentationParameters\n * @mixes MeasurementRepresentationParameters\n *\n * @property {String} labelUnit - distance unit (e.g. \"angstrom\" or \"nm\"). If set, a distance\n * symbol is appended to the label (i.e. 'nm' or '\\u00C5'). In case of 'nm', the\n * distance value is computed in nanometers instead of Angstroms.\n * @property {Array[]} atomPair - list of pairs of selection strings (see {@link Selection})\n * or pairs of atom indices. Using atom indices is much more\n * efficient when the representation is updated often, e.g. by\n * changing the selection or the atom positions, as there\n * are no selection strings to be evaluated.\n */\nexport interface DistanceRepresentationParameters extends MeasurementRepresentationParameters {\n labelUnit: string\n atomPair: AtomPair\n useCylinder: boolean\n}\nexport type AtomPair = (number|string)[][]\n/**\n * Distance representation\n */\nclass DistanceRepresentation extends MeasurementRepresentation {\n protected labelUnit: string\n protected atomPair: AtomPair\n protected useCylinder: boolean\n protected distanceBuffer: WideLineBuffer|CylinderGeometryBuffer\n /**\n * Create Distance representation object\n * @example\n * stage.loadFile( \"rcsb://1crn\" ).then( function( o ){\n * o.addRepresentation( \"cartoon\" );\n * // either give selections (uses first selected atom) ...\n * var atomPair = [ [ \"1.CA\", \"4.CA\" ], [ \"7.CA\", \"13.CA\" ] ];\n * // or atom indices\n * var atomPair = [ [ 8, 28 ], [ 173, 121 ] ];\n * o.addRepresentation( \"distance\", { atomPair: atomPair } );\n * stage.autoView();\n * } );\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {DistanceRepresentationParameters} params - distance representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'distance'\n\n this.parameters = Object.assign({\n radialSegments: true,\n openEnded: true,\n disableImpostor: true,\n labelUnit: {\n type: 'select',\n rebuild: true,\n options: { '': '', angstrom: 'angstrom', nm: 'nm' }\n },\n useCylinder: {\n type: 'boolean', rebuild: true\n },\n atomPair: {\n type: 'hidden', rebuild: true\n }\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.linewidth = defaults(p.linewidth, 5.0)\n p.radiusType = defaults(p.radiusType, 'size')\n p.radiusSize = defaults(p.radiusSize, 0.2)\n\n this.labelUnit = defaults(p.labelUnit, '')\n this.useCylinder = defaults(p.useCylinder, false)\n this.atomPair = defaults(p.atomPair, [])\n\n super.init(p)\n }\n\n getDistanceData (sview: StructureView, atomPair: AtomPair) {\n let n = atomPair.length\n const text = new Array(n)\n let position = new Float32Array(n * 3)\n const sele1 = new Selection()\n const sele2 = new Selection()\n\n const bondStore = new BondStore()\n\n const ap1 = sview.getAtomProxy()\n const ap2 = sview.getAtomProxy()\n\n let j = 0 // Skipped pairs\n const selected = sview.getAtomSet()\n\n atomPair.forEach((pair, i) => {\n let v1 = pair[ 0 ]\n let v2 = pair[ 1 ]\n\n if (typeof(v1) === 'number' && Number.isInteger(v1) && typeof(v2) === 'number' && Number.isInteger(v2)) {\n if (selected.get(v1) && selected.get(v2)) {\n ap1.index = v1\n ap2.index = v2\n } else {\n j += 1\n return\n }\n } else {\n sele1.setString(v1 as string)\n sele2.setString(v2 as string)\n\n var atomIndices1 = sview.getAtomIndices(sele1)\n var atomIndices2 = sview.getAtomIndices(sele2)\n\n if (atomIndices1!.length && atomIndices2!.length) {\n ap1.index = atomIndices1![ 0 ]\n ap2.index = atomIndices2![ 0 ]\n } else {\n j += 1\n return\n }\n }\n\n bondStore.addBond(ap1, ap2, 1)\n\n i -= j\n var d = ap1.distanceTo(ap2)\n switch (this.labelUnit) {\n case 'angstrom':\n text[ i ] = d.toFixed(2) + ' ' + String.fromCharCode(0x212B)\n break\n case 'nm':\n text[ i ] = (d / 10).toFixed(2) + ' nm'\n break\n default:\n text[ i ] = d.toFixed(2)\n break\n }\n\n var i3 = i * 3\n position[ i3 + 0 ] = (ap1.x + ap2.x) / 2\n position[ i3 + 1 ] = (ap1.y + ap2.y) / 2\n position[ i3 + 2 ] = (ap1.z + ap2.z) / 2\n })\n\n if (j > 0) {\n n -= j\n position = position.subarray(0, n * 3)\n }\n\n var bondSet = new BitArray(bondStore.count, true)\n\n return {\n text: text,\n position: position,\n bondSet: bondSet,\n bondStore: bondStore\n }\n }\n\n getBondData (sview: StructureView, what: BondDataFields, params: BondDataParams): BondData {\n const bondData = sview.getBondData(this.getBondParams(what, params))\n if (bondData.picking) {\n bondData.picking = new DistancePicker(\n bondData.picking.array,\n bondData.picking.structure,\n params.bondStore!\n ) as any\n }\n return bondData\n }\n\n createData (sview: StructureView) {\n if (!sview.atomCount || !this.atomPair.length) return\n\n const n = this.atomPair.length\n const c = new Color(this.labelColor)\n const distanceData = this.getDistanceData(sview, this.atomPair)\n\n this.textBuffer = new TextBuffer({\n position: distanceData.position,\n size: uniformArray(n, this.labelSize),\n color: uniformArray3(n, c.r, c.g, c.b),\n text: distanceData.text\n } as TextBufferData, this.getLabelBufferParams() as TextBufferParameters)\n\n const bondParams = {\n bondSet: distanceData.bondSet,\n bondStore: distanceData.bondStore\n }\n\n const bondData = this.getBondData(\n sview,\n { position: true, color: true, picking: true, radius: this.useCylinder },\n bondParams\n )\n\n if (this.useCylinder) {\n this.distanceBuffer = new CylinderBuffer(\n bondData as CylinderBufferData,\n this.getBufferParams({\n openEnded: this.openEnded,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) \n ) as CylinderGeometryBuffer\n } else {\n this.distanceBuffer = new WideLineBuffer(\n getFixedLengthDashData(bondData as CylinderBufferData),\n this.getBufferParams({\n linewidth: this.linewidth,\n visible: this.lineVisible,\n opacity: this.lineOpacity\n })\n )\n }\n\n return {\n bondSet: distanceData.bondSet,\n bondStore: distanceData.bondStore,\n position: distanceData.position,\n bufferList: [ this.textBuffer, this.distanceBuffer ]\n }\n }\n\n updateData (what: BondDataFields, data: StructureRepresentationData) {\n super.updateData(what, data)\n\n const bondParams = {\n bondSet: data.bondSet,\n bondStore: data.bondStore\n }\n\n const bondData = this.getBondData(data.sview as StructureView, what, bondParams)\n const distanceData = {}\n\n if (!what || what.color) {\n Object.assign( distanceData, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n if (!what || what.radius) {\n Object.assign( distanceData, {radius: bondData.radius})\n }\n\n (this.distanceBuffer as CylinderGeometryBuffer).setAttributes(distanceData)\n }\n\n setParameters (params: Partial) {\n let rebuild = false\n const what = {}\n\n super.setParameters(params, what, rebuild)\n\n if (!this.useCylinder) {\n if (params && params.lineOpacity) {\n (this.distanceBuffer as WideLineBuffer).setParameters({ opacity: params.lineOpacity })\n }\n if (params && params.opacity !== undefined) {\n (this.distanceBuffer as WideLineBuffer).setParameters({ opacity: this.lineOpacity })\n }\n if (params && params.linewidth) {\n (this.distanceBuffer as WideLineBuffer).setParameters({ linewidth: params.linewidth })\n }\n }\n\n return this\n }\n}\n\nRepresentationRegistry.add('distance', DistanceRepresentation)\n\nexport default DistanceRepresentation\n","/**\n * @file Vector Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3, Matrix4 required for declaration only\nimport { Color, Matrix4, Vector3 } from 'three'\n\nimport '../shader/Line.vert'\nimport '../shader/Line.frag'\n\nimport { uniformArray3 } from '../math/array-utils'\nimport Buffer, { BufferDefaultParameters, BufferData, BufferParameters } from './buffer'\nimport { GenericColor } from '../types'\n\nfunction getSize(data: BufferData){\n const n = data.position!.length / 3\n return n * 2 * 3\n}\n\nexport interface VectorBufferData extends BufferData {\n vector: Float32Array\n}\n\nexport const VectorBufferDefaultParameters = Object.assign({\n scale: 1,\n color: 'grey'\n}, BufferDefaultParameters)\nexport type VectorBufferParameters = BufferParameters & { scale: number, color: GenericColor }\n\n/**\n * Vector buffer. Draws vectors as lines.\n */\nclass VectorBuffer extends Buffer {\n get defaultParameters() { return VectorBufferDefaultParameters }\n parameters: VectorBufferParameters\n\n isLine = true\n vertexShader = 'Line.vert'\n fragmentShader = 'Line.frag'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.vector - vectors\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: VectorBufferData, params: Partial = {}) {\n super({\n position: new Float32Array(getSize(data)),\n color: new Float32Array(getSize(data))\n }, params)\n\n const color = new Color(this.parameters.color)\n const attributes = this.geometry.attributes as any // TODO\n uniformArray3(getSize(data) / 3, color.r, color.g, color.b, attributes.color.array)\n\n this.setAttributes(data)\n }\n\n setAttributes (data: Partial = {}) {\n const attributes = this.geometry.attributes as any // TODO\n\n let position, vector\n let aPosition\n\n if (data.position && data.vector) {\n position = data.position\n vector = data.vector\n aPosition = attributes.position.array\n attributes.position.needsUpdate = true\n }\n\n const n = this.size / 2\n const scale = this.parameters.scale\n\n if (position && vector) {\n for (let v = 0; v < n; v++) {\n const i = v * 2 * 3\n const j = v * 3\n\n aPosition[ i + 0 ] = position[ j + 0 ]\n aPosition[ i + 1 ] = position[ j + 1 ]\n aPosition[ i + 2 ] = position[ j + 2 ]\n aPosition[ i + 3 ] = position[ j + 0 ] + vector[ j + 0 ] * scale\n aPosition[ i + 4 ] = position[ j + 1 ] + vector[ j + 1 ] * scale\n aPosition[ i + 5 ] = position[ j + 2 ] + vector[ j + 2 ] * scale\n }\n }\n }\n}\n\nexport default VectorBuffer\n","/**\n * @file Helixorient Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Helixorient from '../geometry/helixorient'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferParameters } from '../buffer/sphere-buffer'\nimport VectorBuffer from '../buffer/vector-buffer'\nimport Viewer from '../viewer/viewer';\nimport { Structure } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport Polymer from '../proxy/polymer';\nimport { AtomDataFields } from '../structure/structure-data';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\nimport SphereImpostorBuffer from '../buffer/sphereimpostor-buffer';\nimport { BufferData } from '../buffer/buffer';\n\n/**\n * Helixorient Representation\n */\nclass HelixorientRepresentation extends StructureRepresentation {\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'helixorient'\n\n this.parameters = Object.assign({\n sphereDetail: true,\n disableImpostor: true\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'sstruc')\n p.radiusType = defaults(p.radiusType, 'size')\n p.radiusSize = defaults(p.radiusSize, 0.15)\n p.radiusScale = defaults(p.radiusScale, 1.0)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n const bufferList: (SphereBuffer|VectorBuffer)[] = []\n const polymerList: Polymer[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4) return\n polymerList.push(polymer)\n\n const helixorient = new Helixorient(polymer)\n const position = helixorient.getPosition()\n const color = helixorient.getColor(this.getColorParams())\n const size = helixorient.getSize(this.getRadiusParams())\n const picking = helixorient.getPicking()\n\n bufferList.push(\n new SphereBuffer(\n {\n position: position.center,\n color: color.color,\n radius: size.size,\n picking: picking.picking\n },\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters\n ),\n new VectorBuffer(\n {\n position: position.center,\n vector: position.axis\n },\n this.getBufferParams({\n color: 'skyblue',\n scale: 1\n })\n ),\n new VectorBuffer(\n {\n position: position.center,\n vector: position.resdir\n },\n this.getBufferParams({\n color: 'lightgreen',\n scale: 1\n })\n )\n )\n }, sview.getSelection())\n\n return {\n bufferList: bufferList as (SphereGeometryBuffer|SphereImpostorBuffer|VectorBuffer)[],\n polymerList: polymerList\n }\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n if (Debug) Log.time(this.type + ' repr update')\n\n what = what || {}\n\n for (let i = 0, il = data.polymerList!.length; i < il; ++i) {\n const j = i * 3\n\n const bufferData: Partial = {}\n const polymer = data.polymerList![ i ]\n const helixorient = new Helixorient(polymer)\n\n if (what.position) {\n const position = helixorient.getPosition()\n\n Object.assign(bufferData, {position: position.center})\n\n data.bufferList[ j + 1 ].setAttributes({\n 'position': position.center,\n 'vector': position.axis\n })\n data.bufferList[ j + 2 ].setAttributes({\n 'position': position.center,\n 'vector': position.resdir\n })\n }\n\n data.bufferList[ j ].setAttributes(bufferData)\n }\n\n if (Debug) Log.timeEnd(this.type + ' repr update')\n }\n}\n\nRepresentationRegistry.add('helixorient', HelixorientRepresentation)\n\nexport default HelixorientRepresentation\n","/**\n * @file Licorice Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport BallAndStickRepresentation, { BallAndStickRepresentationParameters } from './ballandstick-representation'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\n\n/**\n * Licorice representation object ({@link BallAndStickRepresentation} with `aspectRatio` fixed at 1.0)\n */\nclass LicoriceRepresentation extends BallAndStickRepresentation {\n /**\n * Create Licorice representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {BallAndStickRepresentationParameters} params - ball and stick representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'licorice'\n\n this.parameters = Object.assign(\n {}, this.parameters, { aspectRatio: null }\n )\n }\n\n init (params: Partial) {\n var p = params || {}\n p.aspectRatio = 1.0\n\n super.init(p)\n }\n}\n\nRepresentationRegistry.add('licorice', LicoriceRepresentation)\n\nexport default LicoriceRepresentation\n","/**\n * @file Mapped Box Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { BufferParameters, BufferData } from './buffer'\nimport MappedBuffer from './mapped-buffer'\n\nconst mapping = new Float32Array([\n -1.0, -1.0, -1.0,\n 1.0, -1.0, -1.0,\n 1.0, -1.0, 1.0,\n -1.0, -1.0, 1.0,\n -1.0, 1.0, -1.0,\n 1.0, 1.0, -1.0,\n 1.0, 1.0, 1.0,\n -1.0, 1.0, 1.0\n])\n\nconst mappingIndices = new Uint16Array([\n 0, 1, 2,\n 0, 2, 3,\n 1, 5, 6,\n 1, 6, 2,\n 4, 6, 5,\n 4, 7, 6,\n 0, 7, 4,\n 0, 3, 7,\n 0, 5, 1,\n 0, 4, 5,\n 3, 2, 6,\n 3, 6, 7\n])\n\n/**\n * Mapped Box buffer. Draws boxes. Used to render general imposters.\n * @interface\n */\nclass MappedBoxBuffer extends MappedBuffer {\n constructor(data: BufferData, params: Partial = {}) {\n super('v3', data, params)\n }\n get mapping () { return mapping }\n get mappingIndices () { return mappingIndices }\n get mappingIndicesSize () { return 36 }\n get mappingSize () { return 8 }\n get mappingItemSize () { return 3 }\n}\n\nexport default MappedBoxBuffer\n","/**\n * @file Hyperball Stick Impostor Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import Vector3 required for declaration only\nimport { Matrix4, Vector3 } from 'three'\n\nimport '../shader/HyperballStickImpostor.vert'\nimport '../shader/HyperballStickImpostor.frag'\n\nimport MappedBoxBuffer from './mappedbox-buffer'\nimport { BufferDefaultParameters, BufferParameterTypes, BufferData, BufferParameters } from './buffer'\n\nexport interface HyperballStickImpostorBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n color2: Float32Array\n radius: Float32Array\n radius2: Float32Array\n}\n\nexport const HyperballStickImpostorBufferDefaultParameters = Object.assign({\n shrink: 0.14\n}, BufferDefaultParameters)\nexport type HyperballStickImpostorBufferParameters = BufferParameters & { shrink: number }\n\nconst HyperballStickImpostorBufferParameterTypes = Object.assign({\n shrink: { uniform: true }\n}, BufferParameterTypes)\n\n/**\n * Hyperball stick impostor buffer.\n *\n * @example\n * var hyperballStickImpostorBuffer = new HyperballStickImpostorBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 2, 2, 2 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ]),\n * radius2: new Float32Array([ 2 ])\n * });\n */\nclass HyperballStickImpostorBuffer extends MappedBoxBuffer {\n parameterTypes = HyperballStickImpostorBufferParameterTypes\n get defaultParameters() { return HyperballStickImpostorBufferDefaultParameters }\n parameters: HyperballStickImpostorBufferParameters\n\n isImpostor = true\n vertexShader = 'HyperballStickImpostor.vert'\n fragmentShader = 'HyperballStickImpostor.frag'\n\n constructor (data: HyperballStickImpostorBufferData, params: Partial = {}) {\n super(data, params)\n\n this.addUniforms({\n 'modelViewProjectionMatrix': { value: new Matrix4() },\n 'modelViewProjectionMatrixInverse': { value: new Matrix4() },\n 'modelViewMatrixInverseTranspose': { value: new Matrix4() },\n 'shrink': { value: this.parameters.shrink }\n })\n\n this.addAttributes({\n 'position1': { type: 'v3', value: null },\n 'position2': { type: 'v3', value: null },\n 'color2': { type: 'c', value: null },\n 'radius': { type: 'f', value: null },\n 'radius2': { type: 'f', value: null }\n })\n\n this.setAttributes(data)\n this.makeMapping()\n }\n}\n\nexport default HyperballStickImpostorBuffer\n","/**\n * @file Hyperball Stick Buffer\n * @author Alexander Rose \n * @private\n */\n\n// @ts-ignore: unused import required for declaration only\nimport { Vector3, Matrix4 } from 'three'\nimport { ExtensionFragDepth } from '../globals'\nimport { calculateMinArray } from '../math/array-utils'\nimport CylinderGeometryBuffer, { CylinderGeometryBufferDefaultParameters, CylinderGeometryBufferParameters } from './cylindergeometry-buffer'\nimport HyperballStickImpostorBuffer, { HyperballStickImpostorBufferDefaultParameters, HyperballStickImpostorBufferParameters } from './hyperballstickimpostor-buffer'\nimport { BufferData } from './buffer'\n\nexport interface HyperballStickBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n color2: Float32Array\n radius: Float32Array\n radius2: Float32Array\n}\n\nexport const HyperballStickBufferDefaultParameters = Object.assign({\n disableImpostor: false\n}, CylinderGeometryBufferDefaultParameters, HyperballStickImpostorBufferDefaultParameters)\nexport type HyperballStickBufferParameters = HyperballStickImpostorBufferParameters & CylinderGeometryBufferParameters & { disableImpostor: boolean }\n\nclass HyperballStickBufferImpl {\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - from colors\n * @param {Float32Array} data.color2 - to colors\n * @param {Float32Array} data.radius - from radii\n * @param {Float32Array} data.radius2 - to radii\n * @param {Float32Array} data.picking - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: HyperballStickBufferData, params: Partial = {}) {\n if (!ExtensionFragDepth || (params && params.disableImpostor)) {\n data.radius = calculateMinArray(data.radius, data.radius2)\n return new CylinderGeometryBuffer(data, params)\n } else {\n return new HyperballStickImpostorBuffer(data, params)\n }\n }\n}\n\n/**\n * Hyperball stick buffer. Depending on the value {@link ExtensionFragDepth} and\n * `params.disableImpostor` the constructor returns either a\n * {@link CylinderGeometryBuffer} or a {@link HyperballStickImpostorBuffer}\n * @implements {Buffer}\n *\n * @example\n * var hyperballStickBuffer = new HyperballStickBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 2, 2, 2 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ]),\n * radius2: new Float32Array([ 2 ])\n * });\n */\n//@ts-expect-error Incompatible constructor signatures\nconst HyperballStickBuffer: {\n new(data: HyperballStickBufferData, params: Partial): CylinderGeometryBuffer | HyperballStickImpostorBuffer;\n} = HyperballStickBufferImpl;\n\ntype HyperballStickBuffer = CylinderGeometryBuffer | HyperballStickImpostorBuffer;\n\nexport default HyperballStickBuffer\n","/**\n * @file Hyperball Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { calculateCenterArray } from '../math/array-utils'\nimport LicoriceRepresentation from './licorice-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport HyperballStickBuffer, { HyperballStickBufferData } from '../buffer/hyperballstick-buffer'\nimport { BallAndStickRepresentationParameters } from './ballandstick-representation';\n// @ts-ignore: unused import Volume required for declaration only\nimport { Structure, Volume } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport { BondDataParams, BondDataFields, AtomDataFields } from '../structure/structure-data';\nimport StructureView from '../structure/structure-view';\nimport { StructureRepresentationData } from './structure-representation';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\n// @ts-ignore: unused import Surface required for declaration only\nimport Surface from '../surface/surface';\n\nexport interface HyperballRepresentationParameters extends BallAndStickRepresentationParameters {\n shrink: number\n}\n\n/**\n * Hyperball Representation\n */\nclass HyperballRepresentation extends LicoriceRepresentation {\n protected shrink: number\n protected __center: Float32Array\n \n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'hyperball'\n\n this.parameters = Object.assign({\n\n shrink: {\n type: 'number', precision: 3, max: 1.0, min: 0.001, buffer: true\n }\n\n }, this.parameters, {\n\n multipleBond: null,\n bondSpacing: null\n\n })\n }\n\n init (params: Partial) {\n var p = params || {}\n p.radiusScale = defaults(p.radiusScale, 0.2)\n p.radiusType = defaults(p.radiusType, 'vdw')\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.shrink = defaults(p.shrink, 0.12)\n\n super.init(p)\n }\n\n getBondParams (what?: BondDataFields, params?: BondDataParams) {\n if (!what || what.radius) {\n params = Object.assign({ radius2: true }, params)\n }\n\n return super.getBondParams(what, params)\n }\n\n createData (sview: StructureView) {\n var sphereBuffer = new SphereBuffer(\n (sview.getAtomData(this.getAtomParams()) as SphereBufferData),\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters\n ) as SphereGeometryBuffer\n\n this.__center = new Float32Array(sview.bondCount * 3)\n\n var stickBuffer = new HyperballStickBuffer(\n sview.getBondData(this.getBondParams()) as HyperballStickBufferData,\n this.getBufferParams({\n shrink: this.shrink,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n return {\n bufferList: [ sphereBuffer, stickBuffer ]\n }\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n var atomData = data.sview!.getAtomData(this.getAtomParams())\n var bondData = data.sview!.getBondData(this.getBondParams())\n var sphereData = {}\n var stickData = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {position: atomData.position})\n var from = bondData.position1\n var to = bondData.position2\n Object.assign(stickData, {\n position: calculateCenterArray(from!, to!, this.__center),\n position1: from,\n position2: to\n })\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {color: atomData.color})\n Object.assign(stickData, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {radius: atomData.radius})\n Object.assign(stickData, {\n radius: bondData.radius,\n radius2: bondData.radius2\n })\n }\n\n data.bufferList[ 0 ].setAttributes(sphereData)\n data.bufferList[ 1 ].setAttributes(stickData)\n }\n}\n\nRepresentationRegistry.add('hyperball', HyperballRepresentation)\n\nexport default HyperballRepresentation\n","/**\n * @file Label Factory\n * @author Alexander Rose \n * @private\n */\n\nimport { AA1 } from '../structure/structure-constants'\nimport AtomProxy from '../proxy/atom-proxy'\nimport { sprintf } from 'sprintf-js'\n\nexport const LabelFactoryTypes = {\n '': '',\n 'atomname': 'atom name',\n 'atomindex': 'atom index',\n 'occupancy': 'occupancy',\n 'bfactor': 'b-factor',\n 'serial': 'serial',\n 'element': 'element',\n 'atom': 'atom name + index',\n 'resname': 'residue name',\n 'resno': 'residue no',\n 'res': 'one letter code + no',\n 'residue': '[residue name] + no + inscode',\n 'text': 'text',\n 'format': 'format',\n 'qualified': 'qualified name'\n}\nexport type LabelType = keyof typeof LabelFactoryTypes\n\nclass LabelFactory {\n\n static types = LabelFactoryTypes\n errorLogged: boolean = false\n\n constructor(readonly type: LabelType, readonly text: { [k: number]: string } = {},\n readonly format: string = '') {}\n\n atomLabel (a: AtomProxy) {\n const type = this.type\n\n let l\n\n switch (type) {\n case 'atomname':\n l = a.atomname\n break\n\n case 'atomindex':\n l = `${a.index}`\n break\n\n case 'occupancy':\n l = a.occupancy.toFixed(2)\n break\n\n case 'bfactor':\n l = a.bfactor.toFixed(2)\n break\n\n case 'serial':\n l = `${a.serial}`\n break\n\n case 'element':\n l = a.element\n break\n\n case 'atom':\n l = `${a.atomname}|${a.index}`\n break\n\n case 'resname':\n l = a.resname\n break\n\n case 'resno':\n l = `${a.resno}`\n break\n\n case 'res':\n l = `${(AA1[ a.resname.toUpperCase() ] || a.resname)}${a.resno}`\n break\n\n case 'residue':\n const aa1 = AA1[ a.resname.toUpperCase() ]\n if (aa1 && !a.inscode) {\n l = `${aa1}${a.resno}`\n } else {\n l = `[${a.resname}]${a.resno}${a.inscode}`\n }\n break\n\n case 'text':\n l = this.text[ a.index ]\n break\n\n case 'format':\n try {\n l = sprintf(this.format, a)\n } catch (e) {\n if (!this.errorLogged) {\n this.errorLogged = true\n console.log(e.message)\n }\n }\n break\n\n // case \"qualified\":\n default:\n l = a.qualifiedName()\n break\n }\n\n return l === undefined ? '' : l\n }\n}\n\nexport default LabelFactory\n","/**\n * @file Label Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry, ColormakerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport LabelFactory, { LabelType } from '../utils/label-factory'\nimport RadiusFactory from '../utils/radius-factory'\nimport StructureRepresentation, { StructureRepresentationData } from './structure-representation'\nimport TextBuffer, { TextBufferData } from '../buffer/text-buffer'\nimport { RepresentationParameters } from './representation';\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { GenericColor } from '../types'\n\nexport interface TextDataField {\n position?: boolean\n color?: boolean\n radius?: boolean\n text?: boolean\n}\n\n/**\n * Label representation parameter object. Extends {@link RepresentationParameters} and\n * {@link StructureRepresentationParameters}.\n *\n * @typedef {Object} LabelRepresentationParameters - label representation parameters\n *\n * @property {Integer} clipNear - position of camera near/front clipping plane\n * in percent of scene bounding box\n * @property {Float} opacity - translucency: 1 is fully opaque, 0 is fully transparent\n * @property {String} labelType - type of the label, one of:\n * \"atomname\", \"atomindex\", \"occupancy\", \"bfactor\",\n * \"serial\", \"element\", \"atom\", \"resname\", \"resno\",\n * \"res\", \"text\", \"qualified\". When set to \"text\", the\n * `labelText` list is used.\n * @property {String[]} labelText - list of label strings, must set `labelType` to \"text\"\n * to take effect\n * @property {String} labelFormat - sprintf-js format string, any attribute of\n * {@link AtomProxy} can be used\n * @property {String} labelGrouping - grouping of the label, one of:\n * \"atom\", \"residue\".\n * @property {String} fontFamily - font family, one of: \"sans-serif\", \"monospace\", \"serif\"\n * @property {String} fontStyle - font style, \"normal\" or \"italic\"\n * @property {String} fontWeight - font weight, \"normal\" or \"bold\"\n * @property {Float} xOffset - offset in x-direction\n * @property {Float} yOffset - offset in y-direction\n * @property {Float} zOffset - offset in z-direction (i.e. in camera direction)\n * @property {String} attachment - attachment of the label, one of:\n * \"bottom-left\", \"bottom-center\", \"bottom-right\",\n * \"middle-left\", \"middle-center\", \"middle-right\",\n * \"top-left\", \"top-center\", \"top-right\"\n * @property {Boolean} showBorder - show border/outline\n * @property {Color} borderColor - color of the border/outline\n * @property {Float} borderWidth - width of the border/outline\n * @property {Boolean} showBackground - show background rectangle\n * @property {Color} backgroundColor - color of the background\n * @property {Float} backgroundMargin - width of the background\n * @property {Float} backgroundOpacity - opacity of the background\n * @property {Boolean} fixedSize - show text with a fixed pixel size\n */\nexport interface LabelRepresentationParameters extends RepresentationParameters {\n labelType: LabelType\n labelText: string[]\n labelFormat: string\n labelGrouping: 'atom'|'residue'\n fontFamily: 'sans-serif'|'monospace'|'serif'\n fontStyle: 'normal'|'italic'\n fontWeight: 'normal'|'bold'\n xOffset: number\n yOffset: number\n zOffset: number\n attachment: 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n showBorder: boolean\n borderColor: GenericColor\n borderWidth: number\n showBackground: boolean\n backgroundColor: GenericColor\n backgroundMargin: number\n backgroundOpacity: number\n fixedSize: boolean\n}\n/**\n * Label representation\n */\nclass LabelRepresentation extends StructureRepresentation {\n\n protected labelType: LabelType\n protected labelText: string[]\n protected labelFormat: string\n protected labelGrouping: 'atom'|'residue'\n protected fontFamily: 'sans-serif'|'monospace'|'serif'\n protected fontStyle: 'normal'|'italic'\n protected fontWeight: 'normal'|'bold'\n protected xOffset: number\n protected yOffset: number\n protected zOffset: number\n protected attachment: 'bottom-left'|'bottom-center'|'bottom-right'|'middle-left'|'middle-center'|'middle-right'|'top-left'|'top-center'|'top-right'\n protected showBorder: boolean\n protected borderColor: GenericColor\n protected borderWidth: number\n protected showBackground: boolean\n protected backgroundColor: GenericColor\n protected backgroundMargin: number\n protected backgroundOpacity: number\n protected fixedSize: boolean\n\n /**\n * Create Label representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {LabelRepresentationParameters} params - label representation parameters\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'label'\n\n this.parameters = Object.assign({\n\n labelType: {\n type: 'select', options: LabelFactory.types, rebuild: true\n },\n labelText: {\n type: 'hidden', rebuild: true\n },\n labelFormat: {\n type: 'text', rebuild: true\n },\n labelGrouping: {\n type: 'select',\n options: {\n 'atom': 'atom',\n 'residue': 'residue'\n },\n rebuild: true\n },\n fontFamily: {\n type: 'select',\n options: {\n 'sans-serif': 'sans-serif',\n 'monospace': 'monospace',\n 'serif': 'serif'\n },\n buffer: true\n },\n fontStyle: {\n type: 'select',\n options: {\n 'normal': 'normal',\n 'italic': 'italic'\n },\n buffer: true\n },\n fontWeight: {\n type: 'select',\n options: {\n 'normal': 'normal',\n 'bold': 'bold'\n },\n buffer: true\n },\n xOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: true\n },\n yOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: true\n },\n zOffset: {\n type: 'number', precision: 1, max: 20, min: -20, buffer: true\n },\n attachment: {\n type: 'select',\n options: {\n 'bottom-left': 'bottom-left',\n 'bottom-center': 'bottom-center',\n 'bottom-right': 'bottom-right',\n 'middle-left': 'middle-left',\n 'middle-center': 'middle-center',\n 'middle-right': 'middle-right',\n 'top-left': 'top-left',\n 'top-center': 'top-center',\n 'top-right': 'top-right'\n },\n rebuild: true\n },\n showBorder: {\n type: 'boolean', buffer: true\n },\n borderColor: {\n type: 'color', buffer: true\n },\n borderWidth: {\n type: 'number', precision: 2, max: 0.3, min: 0, buffer: true\n },\n showBackground: {\n type: 'boolean', rebuild: true\n },\n backgroundColor: {\n type: 'color', buffer: true\n },\n backgroundMargin: {\n type: 'number', precision: 2, max: 2, min: 0, rebuild: true\n },\n backgroundOpacity: {\n type: 'range', step: 0.01, max: 1, min: 0, buffer: true\n },\n fixedSize: {\n type: 'boolean', buffer: true\n }\n\n }, this.parameters, {\n\n side: null,\n flatShaded: null,\n wireframe: null,\n linewidth: null,\n\n roughness: null,\n metalness: null,\n diffuse: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n\n this.labelType = defaults(p.labelType, 'res')\n this.labelText = defaults(p.labelText, {})\n this.labelFormat = defaults(p.labelFormat, '')\n this.labelGrouping = defaults(p.labelGrouping, 'atom')\n this.fontFamily = defaults(p.fontFamily, 'sans-serif')\n this.fontStyle = defaults(p.fontStyle, 'normal')\n this.fontWeight = defaults(p.fontWeight, 'bold')\n this.xOffset = defaults(p.xOffset, 0.0)\n this.yOffset = defaults(p.yOffset, 0.0)\n this.zOffset = defaults(p.zOffset, 0.5)\n this.attachment = defaults(p.attachment, 'bottom-left')\n this.showBorder = defaults(p.showBorder, false)\n this.borderColor = defaults(p.borderColor, 'lightgrey')\n this.borderWidth = defaults(p.borderWidth, 0.15)\n this.showBackground = defaults(p.showBackground, false)\n this.backgroundColor = defaults(p.backgroundColor, 'lightgrey')\n this.backgroundMargin = defaults(p.backgroundMargin, 0.5)\n this.backgroundOpacity = defaults(p.backgroundOpacity, 1.0)\n this.fixedSize = defaults(p.fixedSize, false)\n\n super.init(p)\n }\n\n getTextData (sview: StructureView, what?: TextDataField) {\n const p = this.getAtomParams(what)\n const labelFactory = new LabelFactory(this.labelType, this.labelText, this.labelFormat)\n let position: Float32Array, size: Float32Array, color: Float32Array, text: string[],\n positionN: number[], sizeN: number[], colorN: number[]\n if (this.labelGrouping === 'atom') {\n const atomData = sview.getAtomData(p)\n position = atomData.position as Float32Array\n size = atomData.radius as Float32Array\n color = atomData.color as Float32Array\n if (!what || what.text) {\n text = []\n sview.eachAtom(ap => text.push(labelFactory.atomLabel(ap)))\n }\n } else if (this.labelGrouping === 'residue') {\n if (!what || what.position) positionN = []\n if (!what || what.color) colorN = []\n if (!what || what.radius) sizeN = []\n if (!what || what.text) text = []\n if (p.colorParams) p.colorParams.structure = sview.getStructure()\n const colormaker = ColormakerRegistry.getScheme(p.colorParams)\n const radiusFactory = new RadiusFactory(p.radiusParams)\n const ap1 = sview.getAtomProxy()\n\n let i = 0\n sview.eachResidue(rp => {\n const i3 = i * 3\n if (rp.isProtein() || rp.isNucleic()) {\n ap1.index = rp.traceAtomIndex\n if (!what || what.position) {\n ap1.positionToArray(positionN, i3)\n }\n } else {\n ap1.index = rp.atomOffset\n if (!what || what.position) {\n rp.positionToArray(positionN, i3)\n }\n }\n if (!what || what.color) {\n colormaker.atomColorToArray(ap1, colorN, i3)\n }\n if (!what || what.radius) {\n sizeN[ i ] = radiusFactory.atomRadius(ap1)\n }\n if (!what || what.text) {\n text.push(labelFactory.atomLabel(ap1))\n }\n ++i\n })\n\n if (!what || what.position) position = new Float32Array(positionN!)\n if (!what || what.color) color = new Float32Array(colorN!)\n if (!what || what.radius) size = new Float32Array(sizeN!)\n }\n\n return { position: position!, size: size!, color: color!, text: text! }\n }\n\n createData (sview: StructureView) {\n const what: TextDataField = { position: true, color: true, radius: true, text: true }\n\n const textBuffer = new TextBuffer(\n this.getTextData(sview, what) as TextBufferData,\n this.getBufferParams({\n fontFamily: this.fontFamily,\n fontStyle: this.fontStyle,\n fontWeight: this.fontWeight,\n xOffset: this.xOffset,\n yOffset: this.yOffset,\n zOffset: this.zOffset,\n attachment: this.attachment,\n showBorder: this.showBorder,\n borderColor: this.borderColor,\n borderWidth: this.borderWidth,\n showBackground: this.showBackground,\n backgroundColor: this.backgroundColor,\n backgroundMargin: this.backgroundMargin,\n backgroundOpacity: this.backgroundOpacity,\n fixedSize: this.fixedSize\n })\n )\n\n return { bufferList: [ textBuffer ] }\n }\n\n updateData (what: TextDataField, data: StructureRepresentationData) {\n data.bufferList[ 0 ].setAttributes(this.getTextData(data.sview as StructureView, what))\n }\n\n getAtomRadius () {\n return 0\n }\n}\n\nRepresentationRegistry.add('label', LabelRepresentation)\n\nexport default LabelRepresentation\n","/**\n * @file Line Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { RepresentationRegistry } from '../globals'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport WideLineBuffer from '../buffer/wideline-buffer'\nimport { AtomPicker } from '../utils/picker'\n// @ts-ignore: unused import Volume required for declaration only\nimport { Structure, Volume } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport Viewer from '../viewer/viewer';\nimport AtomProxy from '../proxy/atom-proxy';\n// @ts-ignore: unused import Surface required for declaration only\nimport Surface from '../surface/surface';\n// @ts-ignore: unused import BondDataFields, BondDataParams required for declaration only\nimport { BondDataFields, BondDataParams } from '../structure/structure-data';\n\n/**\n * Determine which atoms in a Structure[View] form no bonds to any other atoms\n * in that Structure.\n *\n * This differs from setting the selection to \"nonbonded\" as it finds atoms\n * that have no bonds within the current selection.\n * @param {Structure} structure - The Structure or StructureView object\n * @return {AtomSet} AtomSet of lone atoms\n */\nfunction getLoneAtomSet (structure: Structure | StructureView) {\n const atomSet = structure.getAtomSet()\n const bondSet = structure.getBondSet()\n const bp = structure.getBondProxy()\n bondSet.forEach(function (idx) {\n bp.index = idx\n atomSet.clear(bp.atomIndex1)\n atomSet.clear(bp.atomIndex2)\n })\n return atomSet\n}\n\nexport interface LineRepresentationParameters extends StructureRepresentationParameters {\n multipleBond: 'off' | 'symmetric' | 'offset'\n bondSpacing: number\n linewidth: number\n lines: boolean\n crosses: 'off' | 'all' | 'lone'\n crossSize: number\n}\n\nexport interface CrossData {\n position1?: Float32Array\n position2?: Float32Array\n color?: Float32Array\n color2?: Float32Array\n picking?: AtomPicker\n}\n\n/**\n * Line representation\n */\nclass LineRepresentation extends StructureRepresentation {\n protected multipleBond: 'off' | 'symmetric' | 'offset'\n protected bondSpacing: number\n protected linewidth: number\n protected lines: boolean\n protected crosses: 'off' | 'all' | 'lone'\n protected crossSize: number\n /**\n * Create Line representation object\n * @param {Structure} structure - the structure to be represented\n * @param {Viewer} viewer - a viewer object\n * @param {RepresentationParameters} params - representation parameters, plus the properties listed below\n * @property {String} multipleBond - one off \"off\", \"symmetric\", \"offset\"\n * @param {Float} params.bondSpacing - spacing for multiple bond rendering\n * @param {Integer} params.linewidth - width of lines\n * @param {Boolean} params.lines - render bonds as lines\n * @param {String} params.crosses - render atoms as crosses: \"off\", \"all\" or \"lone\" (default)\n * @param {Float} params.crossSize - size of cross\n * @param {null} params.flatShaded - not available\n * @param {null} params.side - not available\n * @param {null} params.wireframe - not available\n * @param {null} params.roughness - not available\n * @param {null} params.metalness - not available\n * @param {null} params.diffuse - not available\n */\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'line'\n\n this.parameters = Object.assign({\n\n multipleBond: {\n type: 'select',\n rebuild: true,\n options: {\n 'off': 'off',\n 'symmetric': 'symmetric',\n 'offset': 'offset'\n }\n },\n bondSpacing: {\n type: 'number', precision: 2, max: 2.0, min: 0.5\n },\n linewidth: {\n type: 'integer', max: 50, min: 1, buffer: true\n },\n lines: {\n type: 'boolean', rebuild: true\n },\n crosses: {\n type: 'select',\n rebuild: true,\n options: {\n 'off': 'off',\n 'lone': 'lone',\n 'all': 'all'\n }\n },\n crossSize: {\n type: 'number', precision: 2, max: 2.0, min: 0.1\n }\n\n }, this.parameters, {\n\n flatShaded: null,\n side: null,\n wireframe: null,\n\n roughness: null,\n metalness: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n\n this.multipleBond = defaults(p.multipleBond, 'off')\n this.bondSpacing = defaults(p.bondSpacing, 1.0)\n this.linewidth = defaults(p.linewidth, 2)\n this.lines = defaults(p.lines, true)\n this.crosses = defaults(p.crosses, 'lone')\n this.crossSize = defaults(p.crossSize, 0.4)\n\n super.init(p)\n }\n\n getAtomRadius (atom:AtomProxy) {\n return 0.1\n }\n\n getBondParams (what: any, params?: Partial) {\n params = Object.assign({\n multipleBond: this.multipleBond,\n bondSpacing: this.bondSpacing,\n radiusParams: { 'type': 'size', 'size': 0.1, 'scale': 1 }\n }, params)\n\n return super.getBondParams(what, params)\n }\n\n _crossData (what: any, sview: StructureView) {\n if (what) {\n if (!what.position && !what.color) return\n }\n\n const p = {}\n if (this.crosses === 'lone') {\n Object.assign(p, {atomSet : getLoneAtomSet(sview)})\n }\n\n const atomData = sview.getAtomData(this.getAtomParams(what, p))\n const crossData: CrossData = {}\n const position = atomData.position\n const color = atomData.color\n const picking = atomData.picking\n\n const size = (position! || color).length\n const attrSize = size * 3\n\n let cPosition1 = new Float32Array(0)\n let cPosition2 = new Float32Array(0)\n let cColor = new Float32Array(0)\n let cColor2 = new Float32Array(0)\n let cOffset: number = 0\n\n let pickingArray = new Float32Array(0)\n\n if (!what || what.position) {\n cPosition1 = crossData.position1 = new Float32Array(attrSize)\n cPosition2 = crossData.position2 = new Float32Array(attrSize)\n cOffset = this.crossSize / 2\n }\n if (!what || what.color) {\n cColor = crossData.color = new Float32Array(attrSize)\n cColor2 = crossData.color2 = new Float32Array(attrSize)\n }\n if (!what || what.picking) {\n pickingArray = new Float32Array(atomData.picking!.array!.length * 3) // Needs padding??\n }\n\n for (let v = 0; v < size; v++) {\n const j = v * 3\n const i = j * 3\n\n if (!what || what.position) {\n const x = position![ j ]\n const y = position![ j + 1 ]\n const z = position![ j + 2 ]\n\n cPosition1[ i ] = x - cOffset!\n cPosition1[ i + 1 ] = y\n cPosition1[ i + 2 ] = z\n cPosition2[ i ] = x + cOffset\n cPosition2[ i + 1 ] = y\n cPosition2[ i + 2 ] = z\n\n cPosition1[ i + 3 ] = x\n cPosition1[ i + 4 ] = y - cOffset\n cPosition1[ i + 5 ] = z\n cPosition2[ i + 3 ] = x\n cPosition2[ i + 4 ] = y + cOffset\n cPosition2[ i + 5 ] = z\n\n cPosition1[ i + 6 ] = x\n cPosition1[ i + 7 ] = y\n cPosition1[ i + 8 ] = z - cOffset\n cPosition2[ i + 6 ] = x\n cPosition2[ i + 7 ] = y\n cPosition2[ i + 8 ] = z + cOffset\n }\n\n if (!what || what.color) {\n const cimax = i + 9\n for (let ci = i; ci < cimax; ci += 3) {\n cColor[ ci ] = cColor2[ ci ] = color![ j ]\n cColor[ ci + 1 ] = cColor2[ ci + 1 ] = color![ j + 1 ]\n cColor[ ci + 2 ] = cColor2[ ci + 2 ] = color![ j + 2 ]\n }\n }\n\n if (!what || what.picking) {\n pickingArray[ j ] =\n pickingArray[ j + 1 ] =\n pickingArray[ j + 2 ] = picking!.array![ v ]\n }\n }\n\n if (!what || what.picking) {\n crossData.picking = new AtomPicker(\n pickingArray, picking!.structure\n )\n }\n\n return crossData\n }\n\n createData (sview: StructureView) {\n const what = { position: true, color: true, picking: true }\n\n const bufferList = []\n\n if (this.lines) {\n const bondData = sview.getBondData(this.getBondParams(what))\n\n const lineBuffer = new WideLineBuffer(\n bondData, this.getBufferParams({ linewidth: this.linewidth })\n )\n\n bufferList.push(lineBuffer)\n }\n\n if (this.crosses !== 'off') {\n const crossBuffer = new WideLineBuffer(\n (this._crossData(what, sview) as CrossData),\n this.getBufferParams({linewidth: this.linewidth})\n )\n bufferList.push(crossBuffer)\n }\n\n return {\n bufferList: bufferList\n }\n }\n\n updateData (what: any, data: StructureRepresentationData) {\n let bufferIdx = 0\n\n if (this.lines) {\n const bondData = data.sview!.getBondData(this.getBondParams(what))\n const lineAttributes = {}\n\n if (!what || what.position) {\n Object.assign(lineAttributes, {\n position1: bondData.position1,\n position2: bondData.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(lineAttributes, {\n color: bondData.color,\n color2: bondData.color2\n })\n }\n\n data.bufferList[ bufferIdx++ ].setAttributes(lineAttributes)\n }\n\n if (this.crosses !== 'off') {\n const crossData = this._crossData(what, (data.sview as StructureView))\n const crossAttributes = {}\n\n if (!what || what.position) {\n Object.assign(crossAttributes, {\n position1: crossData!.position1,\n position2: crossData!.position2\n })\n }\n if (!what || what.color) {\n Object.assign(crossAttributes, {\n color: crossData!.color,\n color2: crossData!.color2\n })\n }\n\n data.bufferList[ bufferIdx++ ].setAttributes(crossAttributes)\n }\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n if (params && (params.bondSpacing || params.crossSize)) {\n Object.assign(what, { position: true })\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('line', LineRepresentation)\n\nexport default LineRepresentation\n","import { NumberArray, TypedArray } from \"../types\";\n\n/**\n * @file Grid\n * @author Alexander Rose \n * @private\n */\nexport interface iGrid {\n data: TypedArray\n index: (x: number, y: number, z: number) => number\n set: (x: number, y: number, z: number, ...arg: number[]) => void\n toArray: (x: number, y: number, z: number, array?: NumberArray, offset?: number) => void\n fromArray: (x: number, y: number, z: number, array: NumberArray, offset?: number) => void\n copy: (grid: iGrid) => void\n // clone: () => iGrid\n}\n\nfunction makeGrid (length: number, width: number, height: number, DataCtor: any, elemSize: number) : iGrid {\n DataCtor = DataCtor || Int32Array\n elemSize = elemSize || 1\n\n const data = new DataCtor(length * width * height * elemSize)\n\n function index (x: number, y: number, z: number) {\n return ((((x * width) + y) * height) + z) * elemSize\n }\n\n function set (x: number, y: number, z: number, ...args: number[]) {\n const i = index(x, y, z)\n\n for (let j = 0; j < elemSize; ++j) {\n data[ i + j ] = args[ j ]\n }\n }\n\n function toArray (x: number, y: number, z: number, array: NumberArray = [], offset: number = 0) {\n const i = index(x, y, z)\n\n for (let j = 0; j < elemSize; ++j) {\n array[ offset + j ] = data[ i + j ]\n }\n }\n\n function fromArray(x: number, y: number, z: number, array: NumberArray, offset: number = 0) {\n const i = index(x, y, z)\n\n for (let j = 0; j < elemSize; ++j) {\n data[ i + j ] = array[ offset + j ]\n }\n }\n\n function copy(grid: iGrid) {\n data.set(grid.data)\n }\n\n // function clone() {\n // return makeGrid(\n // length, width, height, DataCtor, elemSize\n // ).copy(this)\n // }\n return { data, index, set, toArray, fromArray, copy }\n}\n\nexport { makeGrid }","/**\n * @file EDT Surface\n * @author Alexander Rose \n * @private\n */\n\nimport { VolumeSurface } from './volume'\nimport { iGrid, makeGrid } from '../geometry/grid'\nimport { computeBoundingBox } from '../math/vector-utils'\nimport { getRadiusDict, getSurfaceGrid } from './surface-utils'\nimport { TypedArray } from '../types';\n\ninterface EDTSurface {\n getVolume: (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean) => {\n data: TypedArray\n nx: number\n ny: number\n nz: number\n atomindex: TypedArray\n }\n getSurface: (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean, smooth: number, contour: boolean) => any\n}\n\nfunction EDTSurface (this: EDTSurface, coordList: Float32Array, radiusList: Float32Array, indexList: Uint16Array|Uint32Array) {\n // based on D. Xu, Y. Zhang (2009) Generating Triangulated Macromolecular\n // Surfaces by Euclidean Distance Transform. PLoS ONE 4(12): e8140.\n //\n // Permission to use, copy, modify, and distribute this program for\n // any purpose, with or without fee, is hereby granted, provided that\n // the notices on the head, the reference information, and this\n // copyright notice appear in all copies or substantial portions of\n // the Software. It is provided \"as is\" without express or implied\n // warranty.\n //\n // ported to JavaScript by biochem_fan (http://webglmol.sourceforge.jp/)\n // refactored by dkoes (https://github.com/dkoes)\n //\n // adapted to NGL by Alexander Rose\n\n var radiusDict = getRadiusDict(radiusList as any)\n var bbox = computeBoundingBox(coordList)\n if (coordList.length === 0) {\n bbox[ 0 ].set([ 0, 0, 0 ])\n bbox[ 1 ].set([ 0, 0, 0 ])\n }\n var min = bbox[ 0 ]\n var max = bbox[ 1 ]\n\n var probeRadius: number, scaleFactor: number, cutoff: number\n var pLength: number, pWidth: number, pHeight: number\n var matrix: Float32Array, ptran: Float32Array\n var depty: {[k: string]: TypedArray}, widxz: {[k: string]: number}\n var cutRadius: number\n var setAtomID: boolean\n var vpBits: TypedArray, vpDistance: TypedArray, vpAtomID: TypedArray\n\n function init (btype: boolean, _probeRadius: number, _scaleFactor: number, _cutoff: number, _setAtomID: boolean) {\n probeRadius = _probeRadius || 1.4\n scaleFactor = _scaleFactor || 2.0\n setAtomID = _setAtomID || true\n\n var maxRadius = 0\n for (var radius in radiusDict) {\n maxRadius = Math.max(maxRadius, radius as any)\n }\n\n var grid = getSurfaceGrid(\n min, max, maxRadius, scaleFactor, btype ? probeRadius : 0\n )\n\n pLength = grid.dim[0]\n pWidth = grid.dim[1]\n pHeight = grid.dim[2]\n\n matrix = grid.matrix\n ptran = grid.tran\n scaleFactor = grid.scaleFactor\n\n // boundingatom caches\n depty = {}\n widxz = {}\n boundingatom(btype)\n\n cutRadius = probeRadius * scaleFactor\n\n if (_cutoff) {\n cutoff = _cutoff\n } else {\n // cutoff = Math.max( 0.1, -1.2 + scaleFactor * probeRadius );\n cutoff = probeRadius / scaleFactor\n }\n\n vpBits = new Uint8Array(pLength * pWidth * pHeight)\n if (btype) {\n vpDistance = new Float64Array(pLength * pWidth * pHeight)\n }\n if (setAtomID) {\n vpAtomID = new Int32Array(pLength * pWidth * pHeight)\n }\n }\n\n // constants for vpBits bitmasks\n var INOUT = 1\n var ISDONE = 2\n var ISBOUND = 4\n\n var nb = [\n new Int32Array([ 1, 0, 0 ]), new Int32Array([ -1, 0, 0 ]),\n new Int32Array([ 0, 1, 0 ]), new Int32Array([ 0, -1, 0 ]),\n new Int32Array([ 0, 0, 1 ]), new Int32Array([ 0, 0, -1 ]),\n new Int32Array([ 1, 1, 0 ]), new Int32Array([ 1, -1, 0 ]),\n new Int32Array([ -1, 1, 0 ]), new Int32Array([ -1, -1, 0 ]),\n new Int32Array([ 1, 0, 1 ]), new Int32Array([ 1, 0, -1 ]),\n new Int32Array([ -1, 0, 1 ]), new Int32Array([ -1, 0, -1 ]),\n new Int32Array([ 0, 1, 1 ]), new Int32Array([ 0, 1, -1 ]),\n new Int32Array([ 0, -1, 1 ]), new Int32Array([ 0, -1, -1 ]),\n new Int32Array([ 1, 1, 1 ]), new Int32Array([ 1, 1, -1 ]),\n new Int32Array([ 1, -1, 1 ]), new Int32Array([ -1, 1, 1 ]),\n new Int32Array([ 1, -1, -1 ]), new Int32Array([ -1, -1, 1 ]),\n new Int32Array([ -1, 1, -1 ]), new Int32Array([ -1, -1, -1 ])\n ]\n\n //\n\n this.getVolume = function (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean) {\n console.time('EDTSurface.getVolume')\n\n var btype = type !== 'vws'\n\n init(btype, probeRadius, scaleFactor, cutoff, setAtomID)\n\n fillvoxels(btype)\n buildboundary()\n\n if (type === 'ms' || type === 'ses') {\n fastdistancemap()\n }\n\n if (type === 'ses') {\n boundingatom(false)\n fillvoxelswaals()\n }\n\n marchingcubeinit(type)\n\n // set atomindex in the volume data\n for (var i = 0, il = vpAtomID.length; i < il; ++i) {\n vpAtomID[ i ] = indexList[ vpAtomID[ i ] ]\n }\n\n console.timeEnd('EDTSurface.getVolume')\n\n return {\n data: vpBits,\n nx: pHeight,\n ny: pWidth,\n nz: pLength,\n atomindex: vpAtomID\n }\n }\n\n this.getSurface = function (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean, smooth: number, contour: boolean) {\n var vd = this.getVolume(\n type, probeRadius, scaleFactor, cutoff, setAtomID\n )\n\n var volsurf = new (VolumeSurface as any)(\n vd.data, vd.nx, vd.ny, vd.nz, vd.atomindex\n ) as VolumeSurface\n\n return (volsurf!.getSurface as any)(1, smooth, undefined, matrix, contour)\n }\n\n function boundingatom (btype: boolean) {\n var r\n var j\n var k\n var txz\n var tdept\n var sradius\n var tradius\n var widxzR\n var deptyName\n var indx\n\n for (var name in radiusDict) {\n r = parseFloat(name)\n\n if (depty[ name ]) continue\n\n if (!btype) {\n tradius = r * scaleFactor + 0.5\n } else {\n tradius = (r + probeRadius) * scaleFactor + 0.5\n }\n\n sradius = tradius * tradius\n widxzR = Math.floor(tradius) + 1\n deptyName = new Int32Array(widxzR * widxzR)\n indx = 0\n\n for (j = 0; j < widxzR; ++j) {\n for (k = 0; k < widxzR; ++k) {\n txz = j * j + k * k\n\n if (txz > sradius) {\n deptyName[ indx ] = -1\n } else {\n tdept = Math.sqrt(sradius - txz)\n deptyName[ indx ] = Math.floor(tdept)\n }\n\n ++indx\n }\n }\n\n widxz[ name ] = widxzR\n depty[ name ] = deptyName\n }\n }\n\n function fillatom (idx: number) {\n var ci = idx * 3\n var ri = idx\n\n var cx, cy, cz, ox, oy, oz, mi, mj, mk, i, j, k, si, sj, sk\n var ii, jj, kk\n\n cx = Math.floor(0.5 + scaleFactor * (coordList[ ci ] + ptran[0]))\n cy = Math.floor(0.5 + scaleFactor * (coordList[ ci + 1 ] + ptran[1]))\n cz = Math.floor(0.5 + scaleFactor * (coordList[ ci + 2 ] + ptran[2]))\n\n var at = radiusList[ ri ]\n var deptyAt = depty[ at ]\n var nind = 0\n var pWH = pWidth * pHeight\n var n = widxz[ at ]\n\n var deptyAtNind\n\n for (i = 0; i < n; ++i) {\n for (j = 0; j < n; ++j) {\n deptyAtNind = deptyAt[ nind ]\n\n if (deptyAtNind !== -1) {\n for (ii = -1; ii < 2; ++ii) {\n for (jj = -1; jj < 2; ++jj) {\n for (kk = -1; kk < 2; ++kk) {\n if (ii !== 0 && jj !== 0 && kk !== 0) {\n mi = ii * i\n mk = kk * j\n\n for (k = 0; k <= deptyAtNind; ++k) {\n mj = k * jj\n si = cx + mi\n sj = cy + mj\n sk = cz + mk\n\n if (si < 0 || sj < 0 || sk < 0 ||\n si >= pLength || sj >= pWidth || sk >= pHeight\n ) {\n continue\n }\n\n var index = si * pWH + sj * pHeight + sk\n\n if (!setAtomID) {\n vpBits[ index ] |= INOUT\n } else {\n if (!(vpBits[ index ] & INOUT)) {\n vpBits[ index ] |= INOUT\n vpAtomID[ index ] = idx\n } else if (vpBits[ index ] & INOUT) {\n var ci2 = vpAtomID[ index ]\n\n if (ci2 !== ci) {\n ox = cx + mi - Math.floor(0.5 + scaleFactor * (coordList[ci2] + ptran[0]))\n oy = cy + mj - Math.floor(0.5 + scaleFactor * (coordList[ci2 + 1] + ptran[1]))\n oz = cz + mk - Math.floor(0.5 + scaleFactor * (coordList[ci2 + 2] + ptran[2]))\n\n if (mi * mi + mj * mj + mk * mk < ox * ox + oy * oy + oz * oz) {\n vpAtomID[ index ] = idx\n }\n }\n }\n }\n } // k\n } // if\n } // kk\n } // jj\n } // ii\n } // if\n\n nind++\n } // j\n } // i\n }\n\n function fillvoxels (btype: boolean) {\n console.time('EDTSurface fillvoxels')\n\n var i, il\n\n for (i = 0, il = vpBits.length; i < il; ++i) {\n vpBits[ i ] = 0\n if (btype) vpDistance[ i ] = -1.0\n if (setAtomID) vpAtomID[ i ] = -1\n }\n\n for (i = 0, il = coordList.length / 3; i < il; ++i) {\n fillatom(i)\n }\n\n for (i = 0, il = vpBits.length; i < il; ++i) {\n if (vpBits[ i ] & INOUT) {\n vpBits[ i ] |= ISDONE\n }\n }\n\n console.timeEnd('EDTSurface fillvoxels')\n }\n\n function fillAtomWaals (idx: number) {\n var ci = idx * 3\n var ri = idx\n\n var cx\n var cy\n var cz\n var ox\n var oy\n var oz\n var nind = 0\n\n var mi\n var mj\n var mk\n var si\n var sj\n var sk\n var i\n var j\n var k\n var ii\n var jj\n var kk\n var n\n\n cx = Math.floor(0.5 + scaleFactor * (coordList[ ci ] + ptran[0]))\n cy = Math.floor(0.5 + scaleFactor * (coordList[ ci + 1 ] + ptran[1]))\n cz = Math.floor(0.5 + scaleFactor * (coordList[ ci + 2 ] + ptran[2]))\n\n var at = radiusList[ ri ]\n var pWH = pWidth * pHeight\n\n for (i = 0, n = widxz[at]; i < n; ++i) {\n for (j = 0; j < n; ++j) {\n if (depty[ at ][ nind ] !== -1) {\n for (ii = -1; ii < 2; ++ii) {\n for (jj = -1; jj < 2; ++jj) {\n for (kk = -1; kk < 2; ++kk) {\n if (ii !== 0 && jj !== 0 && kk !== 0) {\n mi = ii * i\n mk = kk * j\n\n for (k = 0; k <= depty[ at ][ nind ]; ++k) {\n mj = k * jj\n si = cx + mi\n sj = cy + mj\n sk = cz + mk\n\n if (si < 0 || sj < 0 || sk < 0 ||\n si >= pLength || sj >= pWidth || sk >= pHeight\n ) {\n continue\n }\n\n var index = si * pWH + sj * pHeight + sk\n\n if (!(vpBits[ index ] & ISDONE)) {\n vpBits[ index ] |= ISDONE\n if (setAtomID) vpAtomID[ index ] = idx\n } else if (setAtomID) {\n var ci2 = vpAtomID[ index ]\n\n ox = Math.floor(0.5 + scaleFactor * (coordList[ ci2 ] + ptran[0]))\n oy = Math.floor(0.5 + scaleFactor * (coordList[ ci2 + 1 ] + ptran[1]))\n oz = Math.floor(0.5 + scaleFactor * (coordList[ ci2 + 2 ] + ptran[2]))\n\n if (mi * mi + mj * mj + mk * mk < ox * ox + oy * oy + oz * oz) {\n vpAtomID[ index ] = idx\n }\n }\n } // k\n } // if\n } // kk\n } // jj\n } // ii\n } // if\n\n nind++\n } // j\n } // i\n }\n\n function fillvoxelswaals () {\n var i, il\n\n for (i = 0, il = vpBits.length; i < il; ++i) {\n vpBits[ i ] &= ~ISDONE // not isdone\n }\n\n for (i = 0, il = coordList.length / 3; i < il; ++i) {\n fillAtomWaals(i)\n }\n }\n\n function buildboundary () {\n var i, j, k\n var pWH = pWidth * pHeight\n\n for (i = 0; i < pLength; ++i) {\n for (j = 0; j < pHeight; ++j) {\n for (k = 0; k < pWidth; ++k) {\n var index = i * pWH + k * pHeight + j\n\n if (vpBits[ index ] & INOUT) {\n // var flagbound = false;\n var ii = 0\n\n // while( !flagbound && ii < 26 ){\n while (ii < 26) {\n var ti = i + nb[ ii ][ 0 ]\n var tj = j + nb[ ii ][ 2 ]\n var tk = k + nb[ ii ][ 1 ]\n\n if (ti > -1 && ti < pLength &&\n tk > -1 && tk < pWidth &&\n tj > -1 && tj < pHeight &&\n !(vpBits[ ti * pWH + tk * pHeight + tj ] & INOUT)\n ) {\n vpBits[ index ] |= ISBOUND\n // flagbound = true;\n break\n } else {\n ii++\n }\n }\n }\n } // k\n } // j\n } // i\n }\n\n function fastdistancemap () {\n console.time('EDTSurface fastdistancemap')\n\n var i, j, k, n\n\n var boundPoint = makeGrid(\n pLength, pWidth, pHeight, Uint16Array, 3\n )\n var pWH = pWidth * pHeight\n var cutRSq = cutRadius * cutRadius\n\n var totalsurfacevox = 0\n // var totalinnervox = 0;\n\n var index\n\n for (i = 0; i < pLength; ++i) {\n for (j = 0; j < pWidth; ++j) {\n for (k = 0; k < pHeight; ++k) {\n index = i * pWH + j * pHeight + k\n\n vpBits[ index ] &= ~ISDONE\n\n if (vpBits[ index ] & INOUT) {\n if (vpBits[ index ] & ISBOUND) {\n boundPoint.set(\n i, j, k,\n i, j, k\n )\n\n vpDistance[ index ] = 0\n vpBits[ index ] |= ISDONE\n\n totalsurfacevox += 1\n }/* else{\n totalinnervox += 1;\n } */\n }\n }\n }\n }\n\n var inarray = new Int32Array(3 * totalsurfacevox)\n var positin = 0\n var outarray = new Int32Array(3 * totalsurfacevox)\n var positout = 0\n\n for (i = 0; i < pLength; ++i) {\n for (j = 0; j < pWidth; ++j) {\n for (k = 0; k < pHeight; ++k) {\n index = i * pWH + j * pHeight + k\n\n if (vpBits[ index ] & ISBOUND) {\n inarray[ positin ] = i\n inarray[ positin + 1 ] = j\n inarray[ positin + 2 ] = k\n positin += 3\n\n vpBits[ index ] &= ~ISBOUND\n }\n }\n }\n }\n\n do {\n positout = fastoneshell(inarray, boundPoint, positin, outarray)\n positin = 0\n\n for (i = 0, n = positout; i < n; i += 3) {\n index = pWH * outarray[ i ] + pHeight * outarray[ i + 1 ] + outarray[ i + 2 ]\n vpBits[ index ] &= ~ISBOUND\n\n if (vpDistance[ index ] <= 1.0404 * cutRSq) {\n // if( vpDistance[ index ] <= 1.02 * cutRadius ){\n\n inarray[ positin ] = outarray[ i ]\n inarray[ positin + 1 ] = outarray[ i + 1 ]\n inarray[ positin + 2 ] = outarray[ i + 2 ]\n positin += 3\n }\n }\n } while (positin > 0)\n\n // var cutsf = Math.max( 0, scaleFactor - 0.5 );\n // cutoff = cutRadius - 0.5 / ( 0.1 + cutsf );\n var cutoffSq = cutoff * cutoff\n\n var index2\n var bp = new Uint16Array(3)\n\n for (i = 0; i < pLength; ++i) {\n for (j = 0; j < pWidth; ++j) {\n for (k = 0; k < pHeight; ++k) {\n index = i * pWH + j * pHeight + k\n vpBits[ index ] &= ~ISBOUND\n\n // ses solid\n\n if (vpBits[ index ] & INOUT) {\n if (!(vpBits[ index ] & ISDONE) ||\n ((vpBits[ index ] & ISDONE) && vpDistance[ index ] >= cutoffSq)\n ) {\n vpBits[ index ] |= ISBOUND\n\n if (setAtomID && (vpBits[ index ] & ISDONE)) {\n boundPoint.toArray(i, j, k, bp)\n index2 = bp[ 0 ] * pWH + bp[ 1 ] * pHeight + bp[ 2 ]\n\n vpAtomID[ index ] = vpAtomID[ index2 ]\n }\n }\n }\n }\n }\n }\n\n console.timeEnd('EDTSurface fastdistancemap')\n }\n\n function fastoneshell (inarray: Int32Array, boundPoint: iGrid, positin: number, outarray: Int32Array) {\n // *allocout,voxel2\n // ***boundPoint, int*\n // outnum, int *elimi)\n var tx, ty, tz\n var dx, dy, dz\n var i, j, n\n var square\n var index\n var nbj\n var bp = new Uint16Array(3)\n var positout = 0\n\n if (positin === 0) {\n return positout\n }\n\n var tnvix = -1\n var tnviy = -1\n var tnviz = -1\n\n var pWH = pWidth * pHeight\n\n for (i = 0, n = positin; i < n; i += 3) {\n tx = inarray[ i ]\n ty = inarray[ i + 1 ]\n tz = inarray[ i + 2 ]\n boundPoint.toArray(tx, ty, tz, bp)\n\n for (j = 0; j < 6; ++j) {\n nbj = nb[ j ]\n tnvix = tx + nbj[ 0 ]\n tnviy = ty + nbj[ 1 ]\n tnviz = tz + nbj[ 2 ]\n\n if (tnvix < pLength && tnvix > -1 &&\n tnviy < pWidth && tnviy > -1 &&\n tnviz < pHeight && tnviz > -1\n ) {\n index = tnvix * pWH + pHeight * tnviy + tnviz\n\n if ((vpBits[ index ] & INOUT) && !(vpBits[ index ] & ISDONE)) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n vpDistance[ index ] = square\n vpBits[ index ] |= ISDONE\n vpBits[ index ] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n } else if ((vpBits[ index ] & INOUT) && (vpBits[ index ] & ISDONE)) {\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n if (square < vpDistance[ index ]) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n vpDistance[ index ] = square\n\n if (!(vpBits[ index ] & ISBOUND)) {\n vpBits[ index ] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n }\n }\n }\n }\n }\n }\n\n for (i = 0, n = positin; i < n; i += 3) {\n tx = inarray[ i ]\n ty = inarray[ i + 1 ]\n tz = inarray[ i + 2 ]\n boundPoint.toArray(tx, ty, tz, bp)\n\n for (j = 6; j < 18; j++) {\n nbj = nb[ j ]\n tnvix = tx + nbj[ 0 ]\n tnviy = ty + nbj[ 1 ]\n tnviz = tz + nbj[ 2 ]\n\n if (tnvix < pLength && tnvix > -1 &&\n tnviy < pWidth && tnviy > -1 &&\n tnviz < pHeight && tnviz > -1\n ) {\n index = tnvix * pWH + pHeight * tnviy + tnviz\n\n if ((vpBits[index] & INOUT) && !(vpBits[index] & ISDONE)) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n vpDistance[index] = square\n vpBits[index] |= ISDONE\n vpBits[index] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n } else if ((vpBits[index] & INOUT) && (vpBits[index] & ISDONE)) {\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n if (square < vpDistance[index]) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n vpDistance[index] = square\n\n if (!(vpBits[index] & ISBOUND)) {\n vpBits[index] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n }\n }\n }\n }\n }\n }\n\n for (i = 0, n = positin; i < n; i += 3) {\n tx = inarray[ i ]\n ty = inarray[ i + 1 ]\n tz = inarray[ i + 2 ]\n boundPoint.toArray(tx, ty, tz, bp)\n\n for (j = 18; j < 26; j++) {\n nbj = nb[ j ]\n tnvix = tx + nbj[ 0 ]\n tnviy = ty + nbj[ 1 ]\n tnviz = tz + nbj[ 2 ]\n\n if (tnvix < pLength && tnvix > -1 &&\n tnviy < pWidth && tnviy > -1 &&\n tnviz < pHeight && tnviz > -1\n ) {\n index = tnvix * pWH + pHeight * tnviy + tnviz\n\n if ((vpBits[index] & INOUT) && !(vpBits[index] & ISDONE)) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n vpDistance[index] = square\n vpBits[index] |= ISDONE\n vpBits[index] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n } else if ((vpBits[index] & INOUT) && (vpBits[index] & ISDONE)) {\n dx = tnvix - bp[ 0 ]\n dy = tnviy - bp[ 1 ]\n dz = tnviz - bp[ 2 ]\n square = dx * dx + dy * dy + dz * dz\n // square = Math.sqrt( square );\n\n if (square < vpDistance[index]) {\n boundPoint.fromArray(tnvix, tnviy, tnviz, bp)\n vpDistance[index] = square\n\n if (!(vpBits[index] & ISBOUND)) {\n vpBits[index] |= ISBOUND\n\n outarray[ positout ] = tnvix\n outarray[ positout + 1 ] = tnviy\n outarray[ positout + 2 ] = tnviz\n positout += 3\n }\n }\n }\n }\n }\n }\n\n return positout\n }\n\n function marchingcubeinit (stype: string) {\n var i\n var n = vpBits.length\n\n if (stype === 'vws') {\n for (i = 0; i < n; ++i) {\n vpBits[ i ] &= ~ISBOUND\n vpBits[ i ] = (vpBits[ i ] & ISDONE) ? 1 : 0\n }\n } else if (stype === 'ms') { // ses without vdw => ms\n for (i = 0; i < n; ++i) {\n vpBits[ i ] &= ~ISDONE\n if (vpBits[ i ] & ISBOUND) {\n vpBits[ i ] |= ISDONE\n }\n vpBits[ i ] &= ~ISBOUND\n vpBits[ i ] = (vpBits[ i ] & ISDONE) ? 1 : 0\n }\n } else if (stype === 'ses') {\n for (i = 0; i < n; ++i) {\n if ((vpBits[ i ] & ISBOUND) && (vpBits[ i ] & ISDONE)) {\n vpBits[ i ] &= ~ISBOUND\n } else if ((vpBits[ i ] & ISBOUND) && !(vpBits[ i ] & ISDONE)) {\n vpBits[ i ] |= ISDONE\n }\n vpBits[ i ] = (vpBits[ i ] & ISDONE) ? 1 : 0\n }\n } else if (stype === 'sas') {\n for (i = 0; i < n; ++i) {\n vpBits[ i ] &= ~ISBOUND\n vpBits[ i ] = (vpBits[ i ] & ISDONE) ? 1 : 0\n }\n }\n }\n}\nObject.assign(EDTSurface, {__deps: [\n getSurfaceGrid, getRadiusDict, VolumeSurface, computeBoundingBox, makeGrid\n]})\n\nexport default EDTSurface\n","/**\n * @file AV Surface\n * @author Fred Ludlow \n * @private\n */\n\nimport { getSurfaceGrid } from './surface-utils'\nimport { VolumeSurface } from './volume'\nimport { uniformArray } from '../math/array-utils'\nimport {\n computeBoundingBox, v3multiplyScalar, v3cross, v3normalize\n} from '../math/vector-utils'\nimport { defaults } from '../utils'\nimport { NumberArray } from '../types';\n\n\n/**\n * Modifed from SpatialHash\n *\n * Main differences are:\n * - Optimized grid size to ensure we only ever need to look +/-1 cell\n * - Aware of atomic radii and will only output atoms within rAtom + rExtra\n * (see withinRadii method)\n *\n * (Uses rounding rather than bitshifting as consequence of arbitrary grid size)\n * @class\n * @param {Float32Array} atomsX - x coordinates\n * @param {Float32Array} atomsY - y coordinates\n * @param {Float32Array} atomsZ - z coordinates\n * @param {Float32Array} atomsR - atom radii\n * @param {Float32Array} min - xyz min coordinates\n * @param {Float32Array} max - xyz max coordinates\n * @param {Float} maxDistance - max distance\n */\nexport interface iAVHash {\n neighbourListLength: number\n withinRadii: (x: number, y: number, z: number, rExtra: number, out: Int32Array) => void\n}\n\n\nfunction makeAVHash (atomsX: Float32Array, atomsY: Float32Array, atomsZ: Float32Array, atomsR: Float32Array, min: Float32Array, max: Float32Array, maxDistance: number): iAVHash {\n maxDistance = Math.max(0.1, maxDistance) // Avoid maxDistance of zero, see #802\n var nAtoms = atomsX.length\n\n var minX = min[ 0 ]\n var minY = min[ 1 ]\n var minZ = min[ 2 ]\n\n var maxX = max[ 0 ]\n var maxY = max[ 1 ]\n var maxZ = max[ 2 ]\n\n function hashFunc (w: number, minW: number) {\n return Math.floor((w - minW) / maxDistance)\n }\n\n var iDim = hashFunc(maxX, minX) + 1\n var jDim = hashFunc(maxY, minY) + 1\n var kDim = hashFunc(maxZ, minZ) + 1\n\n var nCells = iDim * jDim * kDim\n\n var jkDim = jDim * kDim\n\n /* Get cellID for cartesian x,y,z */\n var cellID = function (x: number, y: number, z: number) {\n return (((hashFunc(x, minX) * jDim) + hashFunc(y, minY)) * kDim) + hashFunc(z, minZ)\n }\n\n /* Initial building, could probably be optimized further */\n var preHash = [] // preHash[ cellID ] = [ atomId1, atomId2 ];\n\n for (var i = 0; i < nAtoms; i++) {\n var cid = cellID(atomsX[ i ], atomsY[ i ], atomsZ[ i ])\n\n if (preHash[ cid ] === undefined) {\n preHash[ cid ] = [ i ]\n } else {\n preHash[ cid ].push(i)\n }\n }\n\n var cellOffsets = new Uint32Array(nCells)\n var cellLengths = new Uint16Array(nCells)\n var data = new Uint32Array(nAtoms)\n\n var offset = 0\n var maxCellLength = 0\n\n for (i = 0; i < nCells; i++) {\n var start = cellOffsets[ i ] = offset\n\n var subArray = preHash[ i ]\n\n if (subArray !== undefined) {\n for (var j = 0; j < subArray.length; j++) {\n data[ offset ] = subArray[ j ]\n offset++\n }\n }\n\n var cellLength = offset - start\n cellLengths[ i ] = cellLength\n\n if (cellLength > maxCellLength) { maxCellLength = cellLength }\n }\n\n // Maximum number of neighbours we could ever produce (27 adjacent cells of equal population)\n const neighbourListLength = (27 * maxCellLength) + 1\n\n /**\n * Populate the supplied out array with atom indices that are within rAtom + rExtra\n * of x,y,z\n *\n * -1 in out array indicates the end of the list\n *\n * @param {Float} x - x coordinate\n * @param {Float} y - y coordinate\n * @param {Float} z - z coordinate\n * @param {Float} rExtra - additional radius\n * @param {Float32Array} out - pre-allocated output array\n * @return {undefined}\n */\n const withinRadii = function (x: number, y: number, z: number, rExtra: number, out: Int32Array) {\n var outIdx = 0\n\n var nearI = hashFunc(x, minX)\n var nearJ = hashFunc(y, minY)\n var nearK = hashFunc(z, minZ)\n\n var loI = Math.max(0, nearI - 1)\n var loJ = Math.max(0, nearJ - 1)\n var loK = Math.max(0, nearK - 1)\n\n var hiI = Math.min(iDim, nearI + 2)\n var hiJ = Math.min(jDim, nearJ + 2)\n var hiK = Math.min(kDim, nearK + 2)\n\n for (var i = loI; i < hiI; ++i) {\n var iOffset = i * jkDim\n\n for (var j = loJ; j < hiJ; ++j) {\n var jOffset = j * kDim\n\n for (var k = loK; k < hiK; ++k) {\n var cid = iOffset + jOffset + k\n\n var cellStart = cellOffsets[ cid ]\n var cellEnd = cellStart + cellLengths[ cid ]\n\n for (var dataIndex = cellStart; dataIndex < cellEnd; dataIndex++) {\n var atomIndex = data[ dataIndex ]\n var dx = atomsX[ atomIndex ] - x\n var dy = atomsY[ atomIndex ] - y\n var dz = atomsZ[ atomIndex ] - z\n var rSum = atomsR[ atomIndex ] + rExtra\n\n if ((dx * dx + dy * dy + dz * dz) <= (rSum * rSum)) {\n out[ outIdx++ ] = data[ dataIndex ]\n }\n }\n }\n }\n }\n // Add terminator\n out[ outIdx ] = -1\n }\n return {\n neighbourListLength: neighbourListLength,\n withinRadii: withinRadii\n }\n}\n\ninterface AVSurface {\n getSurface: (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean, smooth: number, contour: boolean) => any\n}\nfunction AVSurface (this: AVSurface, coordList: Float32Array, radiusList: Float32Array, indexList: Uint16Array|Uint32Array) {\n // Field generation method adapted from AstexViewer (Mike Hartshorn)\n // by Fred Ludlow.\n // Other parts based heavily on NGL (Alexander Rose) EDT Surface class\n //\n // Should work as a drop-in alternative to EDTSurface (though some of\n // the EDT paramters are not relevant in this method).\n\n const nAtoms = radiusList.length\n\n const x = new Float32Array(nAtoms)\n const y = new Float32Array(nAtoms)\n const z = new Float32Array(nAtoms)\n\n for (let i = 0; i < nAtoms; i++) {\n const ci = 3 * i\n x[ i ] = coordList[ ci ]\n y[ i ] = coordList[ ci + 1 ]\n z[ i ] = coordList[ ci + 2 ]\n }\n\n let bbox = computeBoundingBox(coordList)\n if (coordList.length === 0) {\n bbox[ 0 ].set([ 0, 0, 0 ])\n bbox[ 1 ].set([ 0, 0, 0 ])\n }\n const min = bbox[0]\n const max = bbox[1]\n\n let r: Float32Array, r2: Float32Array // Atom positions, expanded radii (squared)\n let maxRadius: number\n\n // Parameters\n let probeRadius: number, scaleFactor: number, setAtomID: boolean, probePositions: number\n\n // Cache last value for obscured test\n let lastClip = -1\n\n // Grid params\n let dim: Float32Array, matrix: Float32Array, grid: NumberArray, atomIndex: Int32Array\n\n // grid indices -> xyz coords\n let gridx: Float32Array, gridy: Float32Array, gridz: Float32Array\n\n // Lookup tables:\n let sinTable: Float32Array, cosTable: Float32Array\n\n // Spatial Hash\n let hash: iAVHash\n\n // Neighbour array to be filled by hash\n let neighbours: Int32Array\n\n // Vectors for Torus Projection\n const atob = new Float32Array([ 0.0, 0.0, 0.0 ])\n const mid = new Float32Array([ 0.0, 0.0, 0.0 ])\n const n1 = new Float32Array([ 0.0, 0.0, 0.0 ])\n const n2 = new Float32Array([ 0.0, 0.0, 0.0 ])\n\n let ngTorus: number\n\n function init (_probeRadius?: number, _scaleFactor?: number, _setAtomID?: boolean, _probePositions?: number) {\n probeRadius = defaults(_probeRadius, 1.4)\n scaleFactor = defaults(_scaleFactor, 2.0)\n setAtomID = defaults(_setAtomID, true)\n probePositions = defaults(_probePositions, 30)\n\n r = new Float32Array(nAtoms)\n r2 = new Float32Array(nAtoms)\n\n for (let i = 0; i < r.length; ++i) {\n var rExt = radiusList[ i ] + probeRadius\n r[ i ] = rExt\n r2[ i ] = rExt * rExt\n }\n\n maxRadius = 0\n for (let j = 0; j < r.length; ++j) {\n if (r[ j ] > maxRadius) maxRadius = r[ j ]\n }\n\n initializeGrid()\n initializeAngleTables()\n initializeHash()\n\n lastClip = -1\n }\n\n function fillGridDim (a: Float32Array, start: number, step: number) {\n for (let i = 0; i < a.length; i++) {\n a[i] = start + (step * i)\n }\n }\n\n function initializeGrid () {\n const surfGrid = getSurfaceGrid(\n min, max, maxRadius, scaleFactor, 0.0\n )\n\n scaleFactor = surfGrid.scaleFactor\n dim = surfGrid.dim\n matrix = surfGrid.matrix\n\n ngTorus = Math.max(5, 2 + Math.floor(probeRadius * scaleFactor))\n\n grid = uniformArray(dim[0] * dim[1] * dim[2], -1001.0)\n\n atomIndex = new Int32Array(grid.length)\n\n gridx = new Float32Array(dim[0])\n gridy = new Float32Array(dim[1])\n gridz = new Float32Array(dim[2])\n\n fillGridDim(gridx, min[0], 1 / scaleFactor)\n fillGridDim(gridy, min[1], 1 / scaleFactor)\n fillGridDim(gridz, min[2], 1 / scaleFactor)\n }\n\n function initializeAngleTables () {\n var theta = 0.0\n var step = 2 * Math.PI / probePositions\n\n cosTable = new Float32Array(probePositions)\n sinTable = new Float32Array(probePositions)\n for (var i = 0; i < probePositions; i++) {\n cosTable[ i ] = Math.cos(theta)\n sinTable[ i ] = Math.sin(theta)\n theta += step\n }\n }\n\n function initializeHash () {\n hash = makeAVHash(x, y, z, r, min, max, 2.01 * maxRadius)\n neighbours = new Int32Array(hash.neighbourListLength)\n }\n\n function obscured (x: number, y: number, z: number, a: number, b: number) {\n // Is the point at x,y,z obscured by any of the atoms\n // specifeid by indices in neighbours. Ignore indices\n // a and b (these are the relevant atoms in projectPoints/Torii)\n\n // Cache the last clipped atom (as very often the same one in\n // subsequent calls)\n let ai: number\n\n if (lastClip !== -1) {\n ai = lastClip\n if (ai !== a && ai !== b && singleAtomObscures(ai, x, y, z)) {\n return ai\n } else {\n lastClip = -1\n }\n }\n\n var ni = 0\n ai = neighbours[ ni ]\n while (ai >= 0) {\n if (ai !== a && ai !== b && singleAtomObscures(ai, x, y, z)) {\n lastClip = ai\n return ai\n }\n ai = neighbours[ ++ni ]\n }\n\n lastClip = -1\n\n return -1\n }\n\n function singleAtomObscures (ai: number, x: number, y: number, z: number) {\n var ci = 3 * ai\n var ra2 = r2[ ai ]\n var dx = coordList[ ci ] - x\n var dy = coordList[ ci + 1 ] - y\n var dz = coordList[ ci + 2 ] - z\n var d2 = dx * dx + dy * dy + dz * dz\n\n return d2 < ra2\n }\n\n function projectPoints () {\n // For each atom:\n // Iterate over a subsection of the grid, for each point:\n // If current value < 0.0, unvisited, set positive\n //\n // In any case: Project this point onto surface of the atomic sphere\n // If this projected point is not obscured by any other atom\n // Calcualte delta distance and set grid value to minimum of\n // itself and delta\n\n // Should we alias frequently accessed closure variables??\n // Assume JS engine capable of optimizing this\n // anyway...\n\n for (var i = 0; i < nAtoms; i++) {\n var ax = x[ i ]\n var ay = y[ i ]\n var az = z[ i ]\n var ar = r[ i ]\n var ar2 = r2[ i ]\n\n hash.withinRadii(ax, ay, az, ar, neighbours)\n\n // Number of grid points, round this up...\n var ng = Math.ceil(ar * scaleFactor)\n\n // Center of the atom, mapped to grid points (take floor)\n var iax = Math.floor(scaleFactor * (ax - min[ 0 ]))\n var iay = Math.floor(scaleFactor * (ay - min[ 1 ]))\n var iaz = Math.floor(scaleFactor * (az - min[ 2 ]))\n\n // Extents of grid to consider for this atom\n var minx = Math.max(0, iax - ng)\n var miny = Math.max(0, iay - ng)\n var minz = Math.max(0, iaz - ng)\n\n // Add two to these points:\n // - iax are floor'd values so this ensures coverage\n // - these are loop limits (exclusive)\n var maxx = Math.min(dim[ 0 ], iax + ng + 2)\n var maxy = Math.min(dim[ 1 ], iay + ng + 2)\n var maxz = Math.min(dim[ 2 ], iaz + ng + 2)\n\n for (var ix = minx; ix < maxx; ix++) {\n var dx = gridx[ ix ] - ax\n var xoffset = dim[ 1 ] * dim[ 2 ] * ix\n\n for (var iy = miny; iy < maxy; iy++) {\n var dy = gridy[ iy ] - ay\n var dxy2 = dx * dx + dy * dy\n var xyoffset = xoffset + dim[ 2 ] * iy\n\n for (var iz = minz; iz < maxz; iz++) {\n var dz = gridz[ iz ] - az\n var d2 = dxy2 + dz * dz\n\n if (d2 < ar2) {\n var idx = iz + xyoffset\n\n if (grid[idx] < 0.0) {\n // Unvisited, make positive\n grid[ idx ] = -grid[ idx ]\n }\n // Project on to the surface of the sphere\n // sp is the projected point ( dx, dy, dz ) * ( ra / d )\n var d = Math.sqrt(d2)\n var ap = ar / d\n var spx = dx * ap\n var spy = dy * ap\n var spz = dz * ap\n\n spx += ax\n spy += ay\n spz += az\n\n if (obscured(spx, spy, spz, i, -1) === -1) {\n var dd = ar - d\n if (dd < grid[ idx ]) {\n grid[ idx ] = dd\n if (setAtomID) atomIndex[ idx ] = i\n }\n }\n }\n }\n }\n }\n }\n }\n\n function projectTorii () {\n for (var i = 0; i < nAtoms; i++) {\n hash.withinRadii(x[ i ], y[ i ], z[ i ], r[ i ], neighbours)\n var ia = 0\n var ni = neighbours[ ia ]\n while (ni >= 0) {\n if (i < ni) {\n projectTorus(i, ni)\n }\n ni = neighbours[ ++ia ]\n }\n }\n }\n\n function projectTorus (a: number, b: number) {\n var r1 = r[ a ]\n var r2 = r[ b ]\n var dx = atob[ 0 ] = x[ b ] - x[ a ]\n var dy = atob[ 1 ] = y[ b ] - y[ a ]\n var dz = atob[ 2 ] = z[ b ] - z[ a ]\n var d2 = dx * dx + dy * dy + dz * dz\n\n // This check now redundant as already done in AVHash.withinRadii\n // if( d2 > (( r1 + r2 ) * ( r1 + r2 )) ){ return; }\n\n var d = Math.sqrt(d2)\n\n // Find angle between a->b vector and the circle\n // of their intersection by cosine rule\n var cosA = (r1 * r1 + d * d - r2 * r2) / (2.0 * r1 * d)\n\n // distance along a->b at intersection\n var dmp = r1 * cosA\n\n v3normalize(atob, atob)\n\n // Create normal to line\n normalToLine(n1 as any, atob)\n v3normalize(n1, n1)\n\n // Cross together for second normal vector\n v3cross(n2, atob, n1)\n v3normalize(n2, n2)\n\n // r is radius of circle of intersection\n var rInt = Math.sqrt(r1 * r1 - dmp * dmp)\n\n v3multiplyScalar(n1, n1, rInt)\n v3multiplyScalar(n2, n2, rInt)\n v3multiplyScalar(atob, atob, dmp)\n\n mid[ 0 ] = atob[ 0 ] + x[ a ]\n mid[ 1 ] = atob[ 1 ] + y[ a ]\n mid[ 2 ] = atob[ 2 ] + z[ a ]\n\n lastClip = -1\n\n var ng = ngTorus\n\n for (var i = 0; i < probePositions; i++) {\n var cost = cosTable[ i ]\n var sint = sinTable[ i ]\n\n var px = mid[ 0 ] + cost * n1[ 0 ] + sint * n2[ 0 ]\n var py = mid[ 1 ] + cost * n1[ 1 ] + sint * n2[ 1 ]\n var pz = mid[ 2 ] + cost * n1[ 2 ] + sint * n2[ 2 ]\n\n if (obscured(px, py, pz, a, b) === -1) {\n // As above, iterate over our grid...\n // px, py, pz in grid coords\n var iax = Math.floor(scaleFactor * (px - min[ 0 ]))\n var iay = Math.floor(scaleFactor * (py - min[ 1 ]))\n var iaz = Math.floor(scaleFactor * (pz - min[ 2 ]))\n\n var minx = Math.max(0, iax - ng)\n var miny = Math.max(0, iay - ng)\n var minz = Math.max(0, iaz - ng)\n\n var maxx = Math.min(dim[ 0 ], iax + ng + 2)\n var maxy = Math.min(dim[ 1 ], iay + ng + 2)\n var maxz = Math.min(dim[ 2 ], iaz + ng + 2)\n\n for (var ix = minx; ix < maxx; ix++) {\n dx = px - gridx[ ix ]\n var xoffset = dim[ 1 ] * dim[ 2 ] * ix\n\n for (var iy = miny; iy < maxy; iy++) {\n dy = py - gridy[ iy ]\n var dxy2 = dx * dx + dy * dy\n var xyoffset = xoffset + dim[ 2 ] * iy\n\n for (var iz = minz; iz < maxz; iz++) {\n dz = pz - gridz[ iz ]\n d2 = dxy2 + dz * dz\n var idx = iz + xyoffset\n var current = grid[ idx ]\n\n if (current > 0.0 && d2 < (current * current)) {\n grid[ idx ] = Math.sqrt(d2)\n if (setAtomID) {\n // Is this grid point closer to a or b?\n // Take dot product of atob and gridpoint->p (dx, dy, dz)\n const dp = dx * atob[ 0 ] + dy * atob [ 1 ] + dz * atob[ 2 ]\n atomIndex[ idx ] = dp < 0.0 ? b : a\n }\n }\n }\n }\n }\n }\n }\n }\n\n function normalToLine (out: Int32Array, p: Float32Array) {\n out[ 0 ] = out[ 1 ] = out[ 2 ] = 1.0\n if (p[ 0 ] !== 0) {\n out[ 0 ] = (p[ 1 ] + p[ 2 ]) / -p[ 0 ]\n } else if (p[ 1 ] !== 0) {\n out[ 1 ] = (p[ 0 ] + p[ 2 ]) / -p[ 1 ]\n } else if (p[ 2 ] !== 0) {\n out[ 2 ] = (p[ 0 ] + p[ 1 ]) / -p[ 2 ]\n }\n return out\n }\n\n function fixNegatives () {\n for (var i = 0; i < grid.length; i++) {\n if (grid[ i ] < 0) grid[ i ] = 0\n }\n }\n\n function fixAtomIDs () {\n for (var i = 0; i < atomIndex.length; i++) {\n atomIndex[ i ] = indexList[ atomIndex[ i ] ]\n }\n }\n\n function getVolume (probeRadius: number, scaleFactor: number, setAtomID: boolean) {\n // Basic steps are:\n // 1) Initialize\n // 2) Project points\n // 3) Project torii\n\n console.time('AVSurface.getVolume')\n\n console.time('AVSurface.init')\n init(probeRadius, scaleFactor, setAtomID)\n console.timeEnd('AVSurface.init')\n\n console.time('AVSurface.projectPoints')\n projectPoints()\n console.timeEnd('AVSurface.projectPoints')\n\n console.time('AVSurface.projectTorii')\n projectTorii()\n console.timeEnd('AVSurface.projectTorii')\n fixNegatives()\n fixAtomIDs()\n\n console.timeEnd('AVSurface.getVolume')\n }\n\n this.getSurface = function (type: string, probeRadius: number, scaleFactor: number, cutoff: number, setAtomID: boolean, smooth: number, contour: boolean) {\n // type and cutoff left in for compatibility with EDTSurface.getSurface\n // function signature\n\n getVolume(probeRadius, scaleFactor, setAtomID)\n\n var volsurf = new (VolumeSurface as any)(\n grid, dim[ 2 ], dim[ 1 ], dim[ 0 ], atomIndex\n ) as VolumeSurface\n\n return volsurf.getSurface!(probeRadius, false, undefined, matrix, contour)\n }\n}\nObject.assign(AVSurface, {__deps: [\n getSurfaceGrid, VolumeSurface, uniformArray, computeBoundingBox,\n v3multiplyScalar, v3cross, v3normalize,\n makeAVHash,\n defaults\n]})\n\nexport { AVSurface, makeAVHash }\n","/**\n * @file Molecular Surface\n * @author Alexander Rose \n * @private\n */\n\nimport { WorkerRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Worker from '../worker/worker'\nimport EDTSurface from './edt-surface'\nimport { AVSurface } from './av-surface'\nimport Surface, { SurfaceData } from './surface'\nimport { Structure } from '../ngl';\nimport { AtomData, RadiusParams } from '../structure/structure-data';\n\nWorkerRegistry.add('molsurf', function func (e: any, callback: (data: any, buffers: any[])=> void) {\n const a = e.data.args\n const p = e.data.params\n if (a && p) {\n const SurfClass = (p.type === 'av') ? AVSurface : EDTSurface\n const surf = new (SurfClass as any)(a.coordList, a.radiusList, a.indexList) as AVSurface|EDTSurface\n const sd = surf.getSurface(\n p.type, p.probeRadius, p.scaleFactor, p.cutoff, true, p.smooth, p.contour\n ) as SurfaceData\n const transferList = [ sd.position.buffer, sd.index!.buffer ]\n if (sd.normal) transferList.push(sd.normal.buffer)\n if (sd.atomindex) transferList.push(sd.atomindex.buffer)\n const data = {\n sd: sd,\n p: p\n }\n callback(data, transferList)\n }\n}, [ EDTSurface, AVSurface ])\n\n/**\n * Molecular surface parameter object.\n * @typedef {Object} MolecularSurfaceParameters - stage parameters\n * @property {String} type - \"av\" or \"edt\"\n * @property {Number} probeRadius - probe radius\n * @property {Number} scaleFactor - higher for better quality\n * @property {Integer} smooth - number of smoothing cycles to apply\n * @property {String} name - name for created surface\n */\nexport interface MolecularSurfaceParameters {\n type: 'av'|'edt'\n probeRadius: number\n scaleFactor: number\n smooth: number\n name: string\n cutoff: number\n contour: boolean,\n radiusParams: RadiusParams\n}\n/**\n * Create Molecular surfaces\n */\nclass MolecularSurface {\n structure: Structure\n worker: Worker|undefined\n\n constructor (structure: Structure) {\n this.structure = structure\n }\n\n _getAtomData (params: Partial): AtomData {\n return this.structure.getAtomData({\n what: { position: true, radius: true, index: true },\n radiusParams: defaults(params.radiusParams, {\n type: 'vdw', scale: 1.0\n })\n })\n }\n\n _makeSurface (sd: SurfaceData, p: Partial) {\n var surface = new Surface(p.name!, '', sd)\n\n surface.info.type = p.type\n surface.info.probeRadius = p.probeRadius\n surface.info.scaleFactor = p.scaleFactor\n surface.info.smooth = p.smooth\n surface.info.cutoff = p.cutoff\n\n return surface\n }\n\n /**\n * Get molecular surface\n * @param {MolecularSurfaceParameters} params - parameters for surface creation\n * @return {Surface} the surface\n */\n getSurface (params: Partial) {\n const p = params || {}\n\n const atomData = this._getAtomData(params)\n const coordList = atomData.position\n const radiusList = atomData.radius\n const indexList = atomData.index\n\n const SurfClass = (p.type === 'av') ? AVSurface : EDTSurface\n const surf = new (SurfClass as any)(coordList, radiusList, indexList) as AVSurface|EDTSurface\n const sd = surf.getSurface(\n p.type!, p.probeRadius!, p.scaleFactor!, p.cutoff!, true, p.smooth!, p.contour!\n )\n\n return this._makeSurface(sd, p)\n }\n\n /**\n * Get molecular surface asynchronous\n * @param {MolecularSurfaceParameters} params - parameters for surface creation\n * @param {function(surface: Surface)} callback - function to be called after surface is created\n * @return {undefined}\n */\n getSurfaceWorker (params: MolecularSurfaceParameters, callback: (s: Surface) => void) {\n const p = Object.assign({}, params)\n\n if (window.hasOwnProperty('Worker')) {\n if (this.worker === undefined) {\n this.worker = new Worker('molsurf')\n }\n\n const atomData = this._getAtomData(params)\n const coordList = atomData.position\n const radiusList = atomData.radius\n const indexList = atomData.index\n\n const msg = {\n args: {\n coordList: coordList,\n radiusList: radiusList,\n indexList: indexList\n },\n params: p\n }\n\n const transferList = [\n coordList!.buffer, radiusList!.buffer, indexList!.buffer\n ]\n\n this.worker.post(msg, transferList,\n\n (e: any) => {\n callback(this._makeSurface(e.data.sd, p))\n },\n\n (e: string) => {\n console.warn(\n 'MolecularSurface.getSurfaceWorker error - trying without worker', e\n )\n this.worker!.terminate()\n this.worker = undefined\n const surface = this.getSurface(p)\n callback(surface)\n }\n\n )\n } else {\n const surface = this.getSurface(p)\n callback(surface)\n }\n }\n\n /**\n * Cleanup\n * @return {undefined}\n */\n dispose () {\n if (this.worker) this.worker.terminate()\n }\n}\n\nexport default MolecularSurface\n","/**\n * @file Molecular Surface Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport MolecularSurface, { MolecularSurfaceParameters } from '../surface/molecular-surface'\nimport SurfaceBuffer from '../buffer/surface-buffer'\nimport ContourBuffer from '../buffer/contour-buffer'\nimport DoubleSidedBuffer from '../buffer/doublesided-buffer'\nimport Selection from '../selection/selection'\nimport Viewer from '../viewer/viewer';\n// @ts-ignore: unused import Volume required for declaration only\nimport { Structure, Vector3, Volume } from '../ngl';\nimport StructureView from '../structure/structure-view';\nimport { SurfaceDataFields } from './surface-representation';\nimport Surface, {SurfaceData} from '../surface/surface';\n\nexport interface MolecularSurfaceRepresentationParameters extends StructureRepresentationParameters {\n surfaceType: 'vws'|'sas'|'ms'|'ses'|'av'\n probeRadius: number\n smooth: number\n scaleFactor: number\n cutoff: number\n contour: boolean\n background: boolean\n opaqueBack: boolean\n filterSele: string\n colorVolume: any\n useWorker: boolean\n}\n\nexport interface MolecularSurfaceInfo {\n molsurf?: MolecularSurface\n sele?: string\n surface?: Surface\n}\n\n/**\n * Molecular Surface Representation\n */\nclass MolecularSurfaceRepresentation extends StructureRepresentation {\n protected surfaceType: 'vws'|'sas'|'ms'|'ses'|'av'\n protected probeRadius: number\n protected smooth: number\n protected scaleFactor: number\n protected cutoff: number\n protected contour: boolean\n protected background: boolean\n protected opaqueBack: boolean\n protected filterSele: string\n protected colorVolume: any\n protected useWorker: boolean\n\n protected __infoList: MolecularSurfaceInfo[]\n protected __forceNewMolsurf: boolean\n protected __sele: string\n protected __surfaceParams: string\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'surface'\n\n this.parameters = Object.assign({\n\n surfaceType: {\n type: 'select',\n rebuild: true,\n options: {\n 'vws': 'vws',\n 'sas': 'sas',\n 'ms': 'ms',\n 'ses': 'ses',\n 'av': 'av'\n }\n },\n probeRadius: {\n type: 'number',\n precision: 1,\n max: 20,\n min: 0,\n rebuild: true\n },\n smooth: {\n type: 'integer',\n precision: 1,\n max: 10,\n min: 0,\n rebuild: true\n },\n scaleFactor: {\n type: 'number',\n precision: 1,\n max: 5,\n min: 0,\n rebuild: true\n },\n cutoff: {\n type: 'number',\n precision: 2,\n max: 50,\n min: 0,\n rebuild: true\n },\n contour: {\n type: 'boolean', rebuild: true\n },\n background: {\n type: 'boolean', rebuild: true // FIXME\n },\n opaqueBack: {\n type: 'boolean', buffer: true\n },\n filterSele: {\n type: 'text', rebuild: true\n },\n colorVolume: {\n type: 'hidden'\n },\n useWorker: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n\n radius: null,\n scale: null\n\n })\n\n this.__infoList = []\n\n // TODO find a more direct way\n this.structure.signals.refreshed.add(() => {\n this.__forceNewMolsurf = true\n })\n\n this.toBePrepared = true\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'uniform')\n p.colorValue = defaults(p.colorValue, 0xDDDDDD)\n p.disablePicking = defaults(p.disablePicking, true)\n\n this.surfaceType = defaults(p.surfaceType, 'ms')\n this.probeRadius = defaults(p.probeRadius, 1.4)\n this.smooth = defaults(p.smooth, 2)\n this.scaleFactor = defaults(p.scaleFactor, 2.0)\n this.cutoff = defaults(p.cutoff, 0.0)\n this.contour = defaults(p.contour, false)\n this.background = defaults(p.background, false)\n this.opaqueBack = defaults(p.opaqueBack, true)\n this.filterSele = defaults(p.filterSele, '')\n this.colorVolume = defaults(p.colorVolume, undefined)\n this.useWorker = defaults(p.useWorker, true)\n\n super.init(params)\n }\n\n prepareData (sview: StructureView, i: number, callback: (i: number) => void) {\n let info: MolecularSurfaceInfo = this.__infoList[ i ]\n if (!info) {\n info = {}\n this.__infoList[ i ] = info\n }\n\n if (!info.molsurf || info.sele !== sview.selection.string) {\n if (this.filterSele) {\n const sviewFilter = sview.structure.getView(new Selection(this.filterSele))\n const bbSize = sviewFilter.boundingBox.getSize(new Vector3())\n const maxDim = Math.max(bbSize.x, bbSize.y, bbSize.z)\n const asWithin = sview.getAtomSetWithinPoint(sviewFilter.center, (maxDim / 2) + 6.0)\n sview = sview.getView(\n new Selection(sview.getAtomSetWithinSelection(asWithin, 3).toSeleString())\n )\n if (sview.atomCount === 0) {\n callback(i)\n return\n }\n }\n\n info.sele = sview.selection.string\n info.molsurf = new MolecularSurface(sview)\n\n const p = this.getSurfaceParams()\n const onSurfaceFinish = (surface: Surface) => {\n info.surface = surface\n callback(i)\n }\n\n if (this.useWorker) {\n info.molsurf.getSurfaceWorker(p as MolecularSurfaceParameters, onSurfaceFinish)\n } else {\n onSurfaceFinish(info.molsurf.getSurface(p as {name: string, type: 'av'|'edt' } & MolecularSurfaceRepresentationParameters))\n }\n } else {\n callback(i)\n }\n }\n\n prepare (callback: () => void) {\n if (this.__forceNewMolsurf || this.__sele !== this.selection.string ||\n this.__surfaceParams !== JSON.stringify(this.getSurfaceParams())) {\n this.__infoList.forEach((info: MolecularSurfaceInfo) => {\n if (info && info.molsurf) {\n info.molsurf.dispose()\n }\n })\n this.__infoList.length = 0\n }\n\n if (this.structureView.atomCount === 0) {\n callback()\n return\n }\n\n const after = () => {\n this.__sele = this.selection.string\n this.__surfaceParams = JSON.stringify(this.getSurfaceParams())\n this.__forceNewMolsurf = false\n callback()\n }\n\n const name = this.assembly === 'default' ? this.defaultAssembly : this.assembly\n const assembly = this.structure.biomolDict[ name ]\n\n if (assembly) {\n assembly.partList.forEach((part, i) => {\n const sview = part.getView(this.structureView)\n this.prepareData(sview as StructureView, i, (_i) => {\n if (_i === assembly.partList.length - 1) after()\n })\n })\n } else {\n this.prepareData(this.structureView, 0, after)\n }\n }\n\n createData (sview: StructureView, i: number) {\n const info = this.__infoList[ i ]\n const surface = info.surface\n\n if (!surface) {\n // Surface creation bailed (no surface generated for this sview)\n return\n }\n\n const surfaceData = {\n position: surface!.getPosition(),\n color: surface!.getColor(this.getColorParams()),\n index: surface!.getFilteredIndex(this.filterSele, sview)\n }\n\n const bufferList = []\n\n if (surface.contour) {\n const contourBuffer = new ContourBuffer(\n surfaceData,\n this.getBufferParams({\n wireframe: false\n })\n )\n\n bufferList.push(contourBuffer)\n } else {\n Object.assign(surfaceData, {\n normal: surface.getNormal(),\n picking: surface.getPicking(sview.getStructure())\n })\n\n const surfaceBuffer = new SurfaceBuffer(\n surfaceData,\n this.getBufferParams({\n background: this.background,\n opaqueBack: this.opaqueBack,\n dullInterior: false\n })\n )\n\n if (this.getBufferParams().side == 'double') {\n const doubleSidedBuffer = new DoubleSidedBuffer(surfaceBuffer)\n bufferList.push(doubleSidedBuffer)\n }\n else {\n bufferList.push(surfaceBuffer)\n }\n }\n\n return { bufferList, info } as StructureRepresentationData\n }\n\n updateData (what: SurfaceDataFields, data: StructureRepresentationData) {\n const surfaceData: Partial = {}\n\n if (what.position || what.radius) {\n this.__forceNewMolsurf = true\n this.build()\n return\n }\n\n if (what.color) {\n surfaceData.color = data.info.surface.getColor(this.getColorParams())\n }\n\n if (what.index) {\n surfaceData.index = data.info.surface.getFilteredIndex(this.filterSele, data.sview)\n }\n\n data.bufferList[ 0 ].setAttributes(surfaceData)\n }\n\n setParameters (params: Partial, what: Partial = {}, rebuild?: boolean) {\n if (params && params.filterSele) {\n what.index = true\n }\n\n if (params && params.colorVolume !== undefined) {\n what.color = true\n }\n\n // forbid setting wireframe to true when contour is true\n if (params && params.wireframe && (\n params.contour || (params.contour === undefined && this.contour)\n )\n ) {\n params.wireframe = false\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n\n getSurfaceParams (params: Partial = {}) {\n const p = Object.assign({\n type: this.surfaceType as string,\n probeRadius: this.probeRadius as number,\n scaleFactor: this.scaleFactor as number,\n smooth: this.smooth && !this.contour,\n cutoff: this.cutoff as number,\n contour: this.contour as boolean,\n useWorker: this.useWorker as boolean,\n radiusParams: this.getRadiusParams()\n }, params)\n\n return p\n }\n\n getColorParams () {\n const p = super.getColorParams()\n\n p.volume = this.colorVolume\n\n return p\n }\n\n getAtomRadius () {\n return 0\n }\n\n clear () {\n super.clear()\n }\n\n dispose () {\n this.__infoList.forEach((info: MolecularSurfaceInfo) => {\n if (info && info.molsurf) {\n info.molsurf.dispose()\n }\n })\n this.__infoList.length = 0\n\n super.dispose()\n }\n}\n\nRepresentationRegistry.add('surface', MolecularSurfaceRepresentation)\n\nexport default MolecularSurfaceRepresentation\n","/**\n * @file Point Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport PointBuffer from '../buffer/point-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport { AtomDataFields } from '../structure/structure-data';\n\nexport interface PointRepresentationParameters extends StructureRepresentationParameters {\n pointSize: number\n sizeAttenuation: boolean\n sortParticles: boolean\n useTexture: boolean\n alphaTest: number\n forceTransparent: boolean\n edgeBleach: number\n}\n\n/**\n * Point Representation\n */\nclass PointRepresentation extends StructureRepresentation {\n protected pointSize: number\n protected sizeAttenuation: boolean\n protected sortParticles: boolean\n protected useTexture: boolean\n protected alphaTest: number\n protected forceTransparent: boolean\n protected edgeBleach: number\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'point'\n\n this.parameters = Object.assign({\n\n pointSize: {\n type: 'number', precision: 1, max: 100, min: 0, buffer: true\n },\n sizeAttenuation: {\n type: 'boolean', buffer: true\n },\n sortParticles: {\n type: 'boolean', rebuild: true\n },\n useTexture: {\n type: 'boolean', buffer: true\n },\n alphaTest: {\n type: 'range', step: 0.001, max: 1, min: 0, buffer: true\n },\n forceTransparent: {\n type: 'boolean', buffer: true\n },\n edgeBleach: {\n type: 'range', step: 0.001, max: 1, min: 0, buffer: true\n }\n\n }, this.parameters, {\n\n flatShaded: null,\n wireframe: null,\n linewidth: null,\n side: null,\n\n roughness: null,\n metalness: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n\n this.pointSize = defaults(p.pointSize, 1)\n this.sizeAttenuation = defaults(p.sizeAttenuation, true)\n this.sortParticles = defaults(p.sortParticles, false)\n this.useTexture = defaults(p.useTexture, false)\n this.alphaTest = defaults(p.alphaTest, 0.5)\n this.forceTransparent = defaults(p.forceTransparent, false)\n this.edgeBleach = defaults(p.edgeBleach, 0.0)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n var what = { position: true, color: true, picking: true }\n var atomData = sview.getAtomData(this.getAtomParams(what))\n\n var pointBuffer = new PointBuffer(\n atomData,\n this.getBufferParams({\n pointSize: this.pointSize,\n sizeAttenuation: this.sizeAttenuation,\n sortParticles: this.sortParticles,\n useTexture: this.useTexture,\n alphaTest: this.alphaTest,\n forceTransparent: this.forceTransparent,\n edgeBleach: this.edgeBleach\n })\n )\n\n return {\n bufferList: [ pointBuffer ]\n }\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n var atomData = data.sview!.getAtomData(this.getAtomParams(what))\n var pointData = {}\n\n if (!what || what.position) {\n Object.assign(pointData, {position: atomData.position})\n }\n\n if (!what || what.color) {\n Object.assign(pointData, {color: atomData.color})\n }\n\n data.bufferList[ 0 ].setAttributes(pointData)\n }\n\n getAtomRadius () {\n return 0.1\n }\n}\n\nRepresentationRegistry.add('point', PointRepresentation)\n\nexport default PointRepresentation\n","/**\n * @file Ribbon Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport '../shader/Ribbon.vert'\n\nimport { getUintArray } from '../utils'\nimport { serialArray } from '../math/array-utils'\nimport MeshBuffer from './mesh-buffer'\nimport { BufferParameters, BufferData } from './buffer'\nimport {Log} from \"../globals\";\n\nconst quadIndices = new Uint16Array([\n 0, 1, 2,\n 1, 3, 2\n])\n\nexport interface RibbonBufferData extends BufferData {\n normal: Float32Array\n dir: Float32Array\n size: Float32Array\n}\n\nfunction getSize(data: RibbonBufferData){\n const n = (data.position!.length / 3) - 1\n const n4 = n * 4\n const x = n4 * 3\n return x\n}\n\n/**\n * Ribbon buffer. Draws a thin ribbon.\n */\nclass RibbonBuffer extends MeshBuffer {\n vertexShader = 'Ribbon.vert'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.normal - normals\n * @param {Float32Array} data.dir - binormals\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.size - sizes\n * @param {Picker} data.picking - picking ids\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: RibbonBufferData, params: Partial = {}) {\n super({\n position: new Float32Array(getSize(data)),\n color: new Float32Array(getSize(data)),\n index: getUintArray(getSize(data), getSize(data) / 3),\n normal: new Float32Array(getSize(data)),\n picking: data.picking\n }, params)\n\n const n = (data.position!.length / 3) - 1\n const n4 = n * 4\n const x = n4 * 3\n\n this.addAttributes({\n 'dir': { type: 'v3', value: new Float32Array(x) }\n })\n this.addAttributes({\n 'size': { type: 'f', value: new Float32Array(n4) }\n })\n\n data.primitiveId = serialArray(n)\n this.setAttributes(data)\n\n this.makeIndex()\n }\n\n setAttributes (data: Partial = {}) {\n const n4 = this.size\n const n = n4 / 4\n\n const attributes = this.geometry.attributes as any // TODO\n\n let position, normal, size, dir, color, primitiveId\n let aPosition, aNormal, aSize, aDir, aColor, aPrimitiveId\n\n if (data.position) {\n position = data.position\n aPosition = attributes.position.array\n attributes.position.needsUpdate = true\n }\n\n if (data.normal) {\n normal = data.normal\n aNormal = attributes.normal.array\n attributes.normal.needsUpdate = true\n }\n\n if (data.size) {\n size = data.size\n aSize = attributes.size.array\n attributes.size.needsUpdate = true\n }\n\n if (data.dir) {\n dir = data.dir\n aDir = attributes.dir.array\n attributes.dir.needsUpdate = true\n }\n\n if (data.color) {\n color = data.color\n aColor = attributes.color.array\n attributes.color.needsUpdate = true\n }\n\n if (data.primitiveId) {\n primitiveId = data.primitiveId\n aPrimitiveId = attributes.primitiveId.array\n attributes.primitiveId.needsUpdate = true\n }\n\n let v, i, k, p, l, v3\n let currSize\n let prevSize = size ? size[ 0 ] : null\n\n for (v = 0; v < n; ++v) {\n v3 = v * 3\n k = v * 3 * 4\n l = v * 4\n\n if (position) {\n aPosition[ k ] = aPosition[ k + 3 ] = position[ v3 ]\n aPosition[ k + 1 ] = aPosition[ k + 4 ] = position[ v3 + 1 ]\n aPosition[ k + 2 ] = aPosition[ k + 5 ] = position[ v3 + 2 ]\n\n aPosition[ k + 6 ] = aPosition[ k + 9 ] = position[ v3 + 3 ]\n aPosition[ k + 7 ] = aPosition[ k + 10 ] = position[ v3 + 4 ]\n aPosition[ k + 8 ] = aPosition[ k + 11 ] = position[ v3 + 5 ]\n }\n\n if (normal) {\n aNormal[ k ] = aNormal[ k + 3 ] = -normal[ v3 ]\n aNormal[ k + 1 ] = aNormal[ k + 4 ] = -normal[ v3 + 1 ]\n aNormal[ k + 2 ] = aNormal[ k + 5 ] = -normal[ v3 + 2 ]\n\n aNormal[ k + 6 ] = aNormal[ k + 9 ] = -normal[ v3 + 3 ]\n aNormal[ k + 7 ] = aNormal[ k + 10 ] = -normal[ v3 + 4 ]\n aNormal[ k + 8 ] = aNormal[ k + 11 ] = -normal[ v3 + 5 ]\n }\n\n for (i = 0; i < 4; ++i) {\n p = k + 3 * i\n\n if (color) {\n aColor[ p ] = color[ v3 ]\n aColor[ p + 1 ] = color[ v3 + 1 ]\n aColor[ p + 2 ] = color[ v3 + 2 ]\n }\n\n if (primitiveId) {\n aPrimitiveId[ l + i ] = primitiveId[ v ]\n }\n }\n\n if (size) {\n currSize = size[ v ]\n\n if (prevSize !== size[ v ]) {\n aSize[ l ] = prevSize\n aSize[ l + 1 ] = prevSize\n aSize[ l + 2 ] = currSize\n aSize[ l + 3 ] = currSize\n } else {\n aSize[ l ] = currSize\n aSize[ l + 1 ] = currSize\n aSize[ l + 2 ] = currSize\n aSize[ l + 3 ] = currSize\n }\n\n prevSize = currSize\n }\n\n if (dir) {\n aDir[ k ] = dir[ v3 ]\n aDir[ k + 1 ] = dir[ v3 + 1 ]\n aDir[ k + 2 ] = dir[ v3 + 2 ]\n\n aDir[ k + 3 ] = -dir[ v3 ]\n aDir[ k + 4 ] = -dir[ v3 + 1 ]\n aDir[ k + 5 ] = -dir[ v3 + 2 ]\n\n aDir[ k + 6 ] = dir[ v3 + 3 ]\n aDir[ k + 7 ] = dir[ v3 + 4 ]\n aDir[ k + 8 ] = dir[ v3 + 5 ]\n\n aDir[ k + 9 ] = -dir[ v3 + 3 ]\n aDir[ k + 10 ] = -dir[ v3 + 4 ]\n aDir[ k + 11 ] = -dir[ v3 + 5 ]\n }\n }\n }\n\n makeIndex () {\n const index = this.geometry.getIndex()\n if (!index) { Log.error('Index is null'); return; }\n const meshIndex = index.array as Uint32Array|Uint16Array\n const n = meshIndex.length / 4 / 3\n\n for (let v = 0; v < n; ++v) {\n const ix = v * 6\n const it = v * 4\n\n meshIndex.set(quadIndices, ix)\n for (let s = 0; s < 6; ++s) {\n meshIndex[ ix + s ] += it\n }\n }\n }\n}\n\nexport default RibbonBuffer\n","/**\n * @file Ribbon Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Spline, { SplineParameters } from '../geometry/spline'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport RibbonBuffer from '../buffer/ribbon-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport StructureView from '../structure/structure-view';\nimport Polymer from '../proxy/polymer';\n\nexport interface RibbonRepresentationParameters extends StructureRepresentationParameters {\n subdiv: number\n tension: number\n smoothSheet: boolean\n}\n\n/**\n * Ribbon Representation\n */\nclass RibbonRepresentation extends StructureRepresentation {\n protected subdiv: number\n protected tension: number\n protected smoothSheet: boolean\n \n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'ribbon'\n\n this.parameters = Object.assign({\n\n subdiv: {\n type: 'integer', max: 50, min: 1, rebuild: true\n },\n tension: {\n type: 'number', precision: 1, max: 1.0, min: 0.1\n },\n smoothSheet: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n\n side: null,\n wireframe: null,\n linewidth: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'chainname')\n p.colorScale = defaults(p.colorScale, 'RdYlBu')\n p.radiusType = defaults(p.radiusType, 'sstruc')\n p.radiusScale = defaults(p.radiusScale, 4.0)\n\n if (p.quality === 'low') {\n this.subdiv = 3\n } else if (p.quality === 'medium') {\n this.subdiv = 6\n } else if (p.quality === 'high') {\n this.subdiv = 12\n } else {\n this.subdiv = defaults(p.subdiv, 6)\n }\n\n this.tension = defaults(p.tension, NaN)\n this.smoothSheet = defaults(p.smoothSheet, false)\n\n super.init(p)\n }\n\n getSplineParams (params?: Partial) {\n return Object.assign({\n subdiv: this.subdiv,\n tension: this.tension,\n directional: true,\n smoothSheet: this.smoothSheet\n }, params)\n }\n\n getAtomRadius (atom: AtomProxy) {\n return atom.isTrace() ? super.getAtomRadius(atom) : 0\n }\n\n createData (sview: StructureView) {\n var bufferList: RibbonBuffer[] = []\n var polymerList: Polymer[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4) return\n polymerList.push(polymer)\n\n var spline = new Spline(polymer, this.getSplineParams())\n var subPos = spline.getSubdividedPosition()\n var subOri = spline.getSubdividedOrientation()\n var subCol = spline.getSubdividedColor(this.getColorParams())\n var subPick = spline.getSubdividedPicking()\n var subSize = spline.getSubdividedSize(this.getRadiusParams())\n\n bufferList.push(\n new RibbonBuffer(\n ({\n position: subPos.position,\n normal: subOri.binormal,\n dir: subOri.normal,\n color: subCol.color,\n size: subSize.size,\n picking: subPick.picking\n }),\n this.getBufferParams()\n )\n )\n }, sview.getSelection())\n\n return {\n bufferList: bufferList,\n polymerList: polymerList\n }\n }\n\n updateData (what: {position?: boolean, radius?: boolean, scale?: boolean, color?: boolean}, data: {polymerList: Polymer[], bufferList: RibbonBuffer[]}) {\n what = what || {}\n\n var i = 0\n var n = data.polymerList.length\n\n for (i = 0; i < n; ++i) {\n var bufferData = {}\n var spline = new Spline(data.polymerList[ i ], this.getSplineParams())\n\n if (what.position) {\n var subPos = spline.getSubdividedPosition()\n var subOri = spline.getSubdividedOrientation()\n Object.assign(bufferData, {\n position: subPos.position,\n normal: subOri.binormal,\n dir: subOri.normal\n })\n }\n\n if (what.radius || what.scale) {\n var subSize = spline.getSubdividedSize(this.getRadiusParams())\n Object.assign(bufferData, {size: subSize.size})\n }\n\n if (what.color) {\n var subCol = spline.getSubdividedColor(this.getColorParams())\n Object.assign(bufferData, {color: subCol.color})\n }\n\n data.bufferList[ i ].setAttributes(bufferData)\n }\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n if (params && params.tension) {\n Object.assign(what, {position: true})\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('ribbon', RibbonRepresentation)\n\nexport default RibbonRepresentation\n","/**\n * @file Rocket Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { AtomPicker } from '../utils/picker'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport Helixbundle, { Axis } from '../geometry/helixbundle'\nimport CylinderBuffer from '../buffer/cylinder-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport CylinderImpostorBuffer from '../buffer/cylinderimpostor-buffer';\n\nexport interface RocketRepresentationParameters extends StructureRepresentationParameters {\n localAngle: number\n centerDist: number\n ssBorder: boolean\n radialSegments: number\n openEnded: boolean\n disableImpostor: boolean\n}\n\nexport interface AxisData {\n begin: Float32Array\n end: Float32Array\n size: Float32Array\n color: Float32Array\n picking: AtomPicker\n}\n\n/**\n * Rocket Representation\n */\nclass RocketRepresentation extends StructureRepresentation {\n\n protected localAngle: number\n protected centerDist: number\n protected ssBorder: boolean\n protected radialSegments: number\n protected openEnded: boolean\n protected disableImpostor: boolean\n // protected helixbundleList: Helixbundle[]\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'rocket'\n\n this.parameters = Object.assign({\n\n localAngle: {\n type: 'integer', max: 180, min: 0, rebuild: true\n },\n centerDist: {\n type: 'number', precision: 1, max: 10, min: 0, rebuild: true\n },\n ssBorder: {\n type: 'boolean', rebuild: true\n },\n radialSegments: true,\n openEnded: true,\n disableImpostor: true\n\n }, this.parameters)\n\n // this.helixbundleList = []\n\n this.init(params)\n }\n\n init (params: Partial) {\n let p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'sstruc')\n p.radiusSize = defaults(p.radiusSize, 1.5)\n p.radiusScale = defaults(p.radiusScale, 1.0)\n p.openEnded = defaults(p.openEnded, false)\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n this.localAngle = defaults(p.localAngle, 30)\n this.centerDist = defaults(p.centerDist, 2.5)\n this.ssBorder = defaults(p.ssBorder, false)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n let length = 0\n const axisList:Axis[] = []\n const helixbundleList:Helixbundle[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4 || polymer.isNucleic()) return\n\n const helixbundle = new Helixbundle(polymer)\n const axis = helixbundle.getAxis(\n this.localAngle, this.centerDist, this.ssBorder,\n this.getColorParams(), this.getRadiusParams()\n )\n\n length += axis.size.length\n axisList.push(axis)\n helixbundleList.push(helixbundle)\n }, sview.getSelection())\n\n const axisData = {\n begin: new Float32Array(length * 3),\n end: new Float32Array(length * 3),\n size: new Float32Array(length),\n color: new Float32Array(length * 3),\n picking: {}\n }\n\n let picking = new Float32Array(length)\n\n let offset = 0\n\n axisList.forEach(function (axis) {\n axisData.begin.set(axis.begin, offset * 3)\n axisData.end.set(axis.end, offset * 3)\n axisData.size.set(axis.size, offset)\n axisData.color.set(axis.color, offset * 3)\n picking.set(axis.picking.array!, offset)\n offset += axis.size.length\n })\n\n if (length) {\n axisData.picking = new AtomPicker(\n picking, sview.getStructure()\n )\n }\n\n const cylinderBuffer = new CylinderBuffer(\n {\n position1: axisData.begin,\n position2: axisData.end,\n color: axisData.color,\n color2: axisData.color,\n radius: axisData.size,\n picking: axisData.picking\n },\n this.getBufferParams({\n openEnded: this.openEnded,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n return {\n bufferList: [ cylinderBuffer as CylinderGeometryBuffer|CylinderImpostorBuffer ],\n axisList: axisList,\n helixbundleList: helixbundleList,\n axisData: axisData\n }\n }\n\n \n updateData (what: any, data: {bufferList: CylinderBuffer[], helixbundleList: Helixbundle[], axisList: Axis[], axisData: AxisData}) {\n what = what || {}\n\n if (what.position) {\n this.build()\n return\n }\n\n var cylinderData = {}\n\n if (what.color || what.radius) {\n var offset = 0\n\n data.helixbundleList.forEach((helixbundle) => {\n var axis = helixbundle.getAxis(\n this.localAngle, this.centerDist, this.ssBorder,\n this.getColorParams(), this.getRadiusParams()\n )\n if (what.color) {\n data.axisData.color.set(axis.color, offset * 3)\n }\n if (what.radius || what.scale) {\n data.axisData.size.set(axis.size, offset)\n }\n offset += axis.size.length\n })\n\n if (what.color) {\n Object.assign(cylinderData, {\n color: data.axisData.color,\n color2: data.axisData.color\n })\n }\n\n if (what.radius || what.scale) {\n Object.assign(cylinderData, {\n radius: data.axisData.size\n })\n }\n }\n\n (data.bufferList[ 0 ] as CylinderGeometryBuffer).setAttributes(cylinderData)\n }\n}\n\nRepresentationRegistry.add('rocket', RocketRepresentation)\n\nexport default RocketRepresentation\n","/**\n * @file Rope Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport CartoonRepresentation, { CartoonRepresentationParameters } from './cartoon-representation'\nimport Helixorient from '../geometry/helixorient'\nimport Spline from '../geometry/spline'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport Polymer from '../proxy/polymer';\n\n/**\n * Rope Representation\n */\nclass RopeRepresentation extends CartoonRepresentation {\n protected smooth: number\n \n constructor (structure: Structure, viewer: Viewer, params: Partial&{smooth: number}) {\n super(structure, viewer, params)\n\n this.type = 'rope'\n\n this.parameters = Object.assign({\n\n smooth: {\n type: 'integer', max: 15, min: 0, rebuild: true\n }\n\n }, this.parameters, {\n aspectRatio: null,\n smoothSheet: null\n })\n }\n\n init (params: Partial) {\n var p = params || {}\n p.aspectRatio = 1.0\n p.tension = defaults(p.tension, 0.5)\n p.radiusScale = defaults(p.radiusScale, 5.0)\n p.smoothSheet = false\n\n this.smooth = defaults(p.smooth, 2)\n\n super.init(p)\n }\n\n getSpline (polymer: Polymer) {\n var helixorient = new Helixorient(polymer)\n\n return new Spline(polymer, this.getSplineParams({\n directional: false,\n positionIterator: helixorient.getCenterIterator(this.smooth)\n }))\n }\n}\n\nRepresentationRegistry.add('rope', RopeRepresentation)\n\nexport default RopeRepresentation\n","/**\n * @file Spacefill Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { RepresentationRegistry } from '../globals'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\nimport { AtomDataFields } from '../structure/structure-data';\nimport SphereImpostorBuffer from '../buffer/sphereimpostor-buffer';\n\n/**\n * Spacefill Representation\n */\nclass SpacefillRepresentation extends StructureRepresentation {\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'spacefill'\n\n this.parameters = Object.assign({\n sphereDetail: true,\n disableImpostor: true\n }, this.parameters)\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n var sphereBuffer = new SphereBuffer(\n (sview.getAtomData(this.getAtomParams()) as SphereBufferData),\n (this.getBufferParams({\n sphereDetail: this.sphereDetail,\n dullInterior: true,\n disableImpostor: this.disableImpostor\n }) as SphereBufferParameters)\n )\n\n return {\n bufferList: [ sphereBuffer as SphereGeometryBuffer|SphereImpostorBuffer ]\n }\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n var atomData = data.sview!.getAtomData(this.getAtomParams(what))\n var sphereData: Partial = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {position: atomData.position})\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {color: atomData.color})\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {radius: atomData.radius})\n }\n\n data.bufferList[ 0 ].setAttributes(sphereData)\n }\n}\n\nRepresentationRegistry.add('spacefill', SpacefillRepresentation)\n\nexport default SpacefillRepresentation\n","/**\n * @file Trace Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport '../shader/Line.vert'\nimport '../shader/Line.frag'\n\nimport { Log } from '../globals'\nimport Buffer, { BufferParameters, BufferData } from './buffer'\n\nfunction getSize(data: BufferData){\n const n = data.position!.length / 3\n const n1 = n - 1\n return n1 * 3 * 2\n}\n\n/**\n * Trace buffer. Draws a series of lines.\n */\nclass TraceBuffer extends Buffer {\n isLine = true\n vertexShader = 'Line.vert'\n fragmentShader = 'Line.frag'\n\n /**\n * @param {Object} data - attribute object\n * @param {Float32Array} data.position - positions\n * @param {Float32Array} data.color - colors\n * @param {BufferParameters} params - parameter object\n */\n constructor (data: BufferData, params: Partial = {}) {\n super({\n position: new Float32Array(getSize(data)),\n color: new Float32Array(getSize(data))\n }, params)\n\n this.setAttributes(data)\n }\n\n setAttributes (data: Partial) {\n let position, color\n let linePosition, lineColor\n\n const attributes = this.geometry.attributes as any // TODO\n\n if (data.position) {\n position = data.position\n linePosition = attributes.position.array\n attributes.position.needsUpdate = true\n }\n\n if (data.color) {\n color = data.color\n lineColor = attributes.color.array\n attributes.color.needsUpdate = true\n }\n\n if (!position && !color) {\n Log.warn('TraceBuffer.prototype.setAttributes no data')\n return\n }\n\n let v, v2\n const n = this.size\n const n1 = n - 1\n\n for (let i = 0; i < n1; ++i) {\n v = 3 * i\n v2 = 3 * i * 2\n\n if (position) {\n linePosition[ v2 ] = position[ v ]\n linePosition[ v2 + 1 ] = position[ v + 1 ]\n linePosition[ v2 + 2 ] = position[ v + 2 ]\n\n linePosition[ v2 + 3 ] = position[ v + 3 ]\n linePosition[ v2 + 4 ] = position[ v + 4 ]\n linePosition[ v2 + 5 ] = position[ v + 5 ]\n }\n\n if (color) {\n lineColor[ v2 ] = color[ v ]\n lineColor[ v2 + 1 ] = color[ v + 1 ]\n lineColor[ v2 + 2 ] = color[ v + 2 ]\n\n lineColor[ v2 + 3 ] = color[ v + 3 ]\n lineColor[ v2 + 4 ] = color[ v + 4 ]\n lineColor[ v2 + 5 ] = color[ v + 5 ]\n }\n }\n }\n}\n\nexport default TraceBuffer\n","/**\n * @file Trace Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Spline from '../geometry/spline'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport TraceBuffer from '../buffer/trace-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport AtomProxy from '../proxy/atom-proxy';\nimport StructureView from '../structure/structure-view';\nimport Polymer from '../proxy/polymer';\n\nexport interface TraceRepresentationParameters extends StructureRepresentationParameters {\n subdiv: number\n tension: number\n smoothSheet: boolean\n}\n/**\n * Trace Representation\n */\nclass TraceRepresentation extends StructureRepresentation {\n protected subdiv: number\n protected tension: number\n protected smoothSheet: boolean\n \n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'trace'\n\n this.parameters = Object.assign({\n\n subdiv: {\n type: 'integer', max: 50, min: 1, rebuild: true\n },\n tension: {\n type: 'number', precision: 1, max: 1.0, min: 0.1\n },\n smoothSheet: {\n type: 'boolean', rebuild: true\n }\n\n }, this.parameters, {\n\n flatShaded: null,\n side: null,\n wireframe: null\n\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n var p = params || {}\n p.colorScheme = defaults(p.colorScheme, 'chainname')\n p.colorScale = defaults(p.colorScale, 'RdYlBu')\n\n if (p.quality === 'low') {\n this.subdiv = 3\n } else if (p.quality === 'medium') {\n this.subdiv = 6\n } else if (p.quality === 'high') {\n this.subdiv = 12\n } else {\n this.subdiv = defaults(p.subdiv, 6)\n }\n\n this.tension = defaults(p.tension, NaN)\n this.smoothSheet = defaults(p.smoothSheet, false)\n\n super.init(p)\n }\n\n getSplineParams (params?: {[k:string]: any}) {\n return Object.assign({\n subdiv: this.subdiv,\n tension: this.tension,\n directional: false,\n smoothSheet: this.smoothSheet\n }, params)\n }\n\n getAtomRadius (atom: AtomProxy) {\n return atom.isTrace() ? 0.1 : 0\n }\n\n createData (sview: StructureView) {\n var bufferList: TraceBuffer[] = []\n var polymerList: Polymer[] = []\n\n this.structure.eachPolymer(polymer => {\n if (polymer.residueCount < 4) return\n polymerList.push(polymer)\n\n var spline = new Spline(polymer, this.getSplineParams())\n var subPos = spline.getSubdividedPosition()\n var subCol = spline.getSubdividedColor(this.getColorParams())\n\n bufferList.push(\n new TraceBuffer(\n Object.assign({}, subPos, subCol),\n this.getBufferParams()\n )\n )\n }, sview.getSelection())\n\n return {\n bufferList: bufferList,\n polymerList: polymerList\n }\n }\n\n updateData (what: any, data: StructureRepresentationData) {\n what = what || {}\n\n var i = 0\n var n = data.polymerList!.length\n\n for (i = 0; i < n; ++i) {\n var bufferData = {}\n var spline = new Spline(data.polymerList![ i ], this.getSplineParams())\n\n if (what.position) {\n var subPos = spline.getSubdividedPosition()\n Object.assign(bufferData, { position: subPos.position })\n }\n\n if (what.color) {\n var subCol = spline.getSubdividedColor(this.getColorParams())\n Object.assign(bufferData, { color: subCol.color })\n }\n\n data.bufferList[ i ].setAttributes(bufferData)\n }\n }\n\n setParameters (params: Partial) {\n var rebuild = false\n var what = {}\n\n if (params && params.tension) {\n Object.assign(what, {position: true})\n }\n\n super.setParameters(params, what, rebuild)\n\n return this\n }\n}\n\nRepresentationRegistry.add('trace', TraceRepresentation)\n\nexport default TraceRepresentation\n","/**\n * @file Tube Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport CartoonRepresentation, {CartoonRepresentationParameters} from './cartoon-representation'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\n\n/**\n * Tube Representation\n */\nclass TubeRepresentation extends CartoonRepresentation {\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'tube'\n\n this.parameters = Object.assign(\n {}, this.parameters, { aspectRatio: null }\n )\n }\n\n init (params: Partial) {\n var p = params || {}\n p.aspectRatio = 1.0\n p.radiusScale = defaults(p.radiusScale, 2.0)\n\n if (p.quality === 'low') {\n this.radialSegments = 5\n }\n\n super.init(p)\n }\n\n getSplineParams (/* params */) {\n return super.getSplineParams({\n directional: false\n })\n }\n}\n\nRepresentationRegistry.add('tube', TubeRepresentation)\n\nexport default TubeRepresentation\n","/**\n * @file Unitcell Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters, StructureRepresentationData } from './structure-representation'\nimport SphereBuffer, { SphereBufferData, SphereBufferParameters } from '../buffer/sphere-buffer'\nimport CylinderBuffer, { CylinderBufferData } from '../buffer/cylinder-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport { AtomDataFields } from '../structure/structure-data';\nimport StructureView from '../structure/structure-view';\nimport SphereGeometryBuffer from '../buffer/spheregeometry-buffer';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\n// @ts-ignore: unused import UnitcellPicker required for declaration only\nimport { UnitcellPicker } from '../utils/picker';\n\nexport interface UnitcellRepresentationParameters extends StructureRepresentationParameters {\n radiusSize: number\n sphereDetail: number\n radialSegments: number\n disableImpostor: boolean\n}\n\n/**\n * Unitcell Representation\n */\nclass UnitcellRepresentation extends StructureRepresentation {\n sphereBuffer: SphereBuffer\n cylinderBuffer: CylinderBuffer\n\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'unitcell'\n\n this.parameters = Object.assign({\n\n radiusSize: {\n type: 'number', precision: 3, max: 10.0, min: 0.001\n },\n sphereDetail: true,\n radialSegments: true,\n disableImpostor: true\n\n }, this.parameters, {\n assembly: null\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n\n let defaultRadius = 0.5\n if (this.structure.unitcell) {\n defaultRadius = Math.cbrt(this.structure.unitcell.volume) / 200\n }\n\n p.radiusSize = defaults(p.radiusSize, defaultRadius)\n p.colorValue = defaults(p.colorValue, 'orange')\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n super.init(p)\n }\n\n getUnitcellData (structure: Structure) {\n return structure.unitcell!.getData(structure)\n }\n\n create () {\n const structure = this.structureView.getStructure()\n if (!structure.unitcell) return\n const unitcellData = this.getUnitcellData(structure)\n\n this.sphereBuffer = new SphereBuffer(\n unitcellData.vertex as SphereBufferData,\n this.getBufferParams({\n sphereDetail: this.sphereDetail,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n }) as SphereBufferParameters\n )\n\n this.cylinderBuffer = new CylinderBuffer(\n unitcellData.edge as CylinderBufferData,\n this.getBufferParams({\n openEnded: true,\n radialSegments: this.radialSegments,\n disableImpostor: this.disableImpostor,\n dullInterior: true\n })\n )\n\n this.dataList.push({\n sview: this.structureView,\n bufferList: [ this.sphereBuffer as SphereGeometryBuffer, this.cylinderBuffer as CylinderGeometryBuffer ]\n })\n }\n\n createData (sview: StructureView): undefined {\n return\n }\n\n updateData (what: AtomDataFields, data: StructureRepresentationData) {\n const structure = data.sview!.getStructure()\n if (!structure.unitcell) return\n const unitcellData = this.getUnitcellData(structure)\n const sphereData: Partial = {}\n const cylinderData: Partial = {}\n\n if (!what || what.position) {\n Object.assign(sphereData, {position: unitcellData.vertex.position})\n Object.assign(cylinderData, {\n position1: unitcellData.edge.position1,\n position2: unitcellData.edge.position2\n })\n }\n\n if (!what || what.color) {\n Object.assign(sphereData, {color: unitcellData.vertex.color})\n Object.assign(cylinderData, {\n color: unitcellData.edge.color,\n color2: unitcellData.edge.color2\n })\n }\n\n if (!what || what.radius) {\n Object.assign(sphereData, {radius: unitcellData.vertex.radius})\n Object.assign(cylinderData, {radius: unitcellData.edge.radius})\n }\n\n (this.sphereBuffer as SphereGeometryBuffer).setAttributes(sphereData);\n (this.cylinderBuffer as CylinderGeometryBuffer).setAttributes(cylinderData)\n }\n}\n\nRepresentationRegistry.add('unitcell', UnitcellRepresentation)\n\nexport default UnitcellRepresentation\n","/**\n * @file Validation Representation\n * @author Alexander Rose \n * @private\n */\n\nimport { RepresentationRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureRepresentation, { StructureRepresentationParameters } from './structure-representation'\nimport CylinderBuffer from '../buffer/cylinder-buffer'\nimport { Structure } from '../ngl';\nimport Viewer from '../viewer/viewer';\nimport StructureView from '../structure/structure-view';\nimport CylinderGeometryBuffer from '../buffer/cylindergeometry-buffer';\nimport CylinderImpostorBuffer from '../buffer/cylinderimpostor-buffer';\n\n/**\n * Validation representation\n */\nclass ValidationRepresentation extends StructureRepresentation {\n constructor (structure: Structure, viewer: Viewer, params: Partial) {\n super(structure, viewer, params)\n\n this.type = 'validation'\n\n this.parameters = Object.assign({\n\n }, this.parameters, {\n radiusType: null,\n radiusSize: null,\n radiusScale: null\n })\n\n this.init(params)\n }\n\n init (params: Partial) {\n const p = params || {}\n p.colorValue = defaults(p.colorValue, '#f0027f')\n p.useInteriorColor = defaults(p.useInteriorColor, true)\n\n super.init(p)\n }\n\n createData (sview: StructureView) {\n if (!sview.validation) return\n\n const clashData = sview.validation.getClashData({\n structure: sview,\n color: this.colorValue\n })\n\n const cylinderBuffer = new CylinderBuffer(\n clashData, this.getBufferParams({ openEnded: false })\n )\n\n return {\n bufferList: [ cylinderBuffer as CylinderGeometryBuffer|CylinderImpostorBuffer ]\n }\n }\n}\n\nRepresentationRegistry.add('validation', ValidationRepresentation)\n\nexport default ValidationRepresentation\n","/**\n * @file Cone Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3, ConeBufferGeometry } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport { calculateCenterArray } from '../math/array-utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferDefaultParameters } from './buffer'\n\nconst scale = new Vector3()\nconst eye = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3(0, 1, 0)\n\nfunction getGeo (params: Partial = {}) {\n const geo = new ConeBufferGeometry(\n 1, // radius\n 1, // height\n defaults(params.radialSegments, 60), // radialSegments\n 1, // heightSegments\n defaults(params.openEnded, false) // openEnded\n )\n geo.applyMatrix4(new Matrix4().makeRotationX(-Math.PI / 2))\n\n return geo\n}\n\nexport interface ConeBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n radius: Float32Array\n}\n\nexport const ConeBufferDefaultParameters = Object.assign({\n radialSegments: 60,\n openEnded: false\n}, BufferDefaultParameters)\nexport type ConeBufferParameters = typeof ConeBufferDefaultParameters\n\n\n/**\n * Cone geometry buffer.\n *\n * @example\n * var coneBuffer = new ConeBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 1, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * color2: new Float32Array([ 0, 1, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass ConeBuffer extends GeometryBuffer {\n updateNormals = true\n\n get defaultParameters() { return ConeBufferDefaultParameters }\n parameters: ConeBufferParameters\n\n _position: Float32Array\n _position1: Float32Array\n _position2: Float32Array\n _radius: Float32Array\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n */\n constructor (data: ConeBufferData, params: Partial = {}) {\n super({\n position: new Float32Array(data.position1.length),\n color: data.color,\n picking: data.picking\n }, params, getGeo(params))\n\n this._position = new Float32Array(data.position1.length)\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n eye.fromArray(this._position1 as any, i3)\n target.fromArray(this._position2 as any, i3)\n matrix.lookAt(eye, target, up)\n\n const r = this._radius[ i ]\n scale.set(r, r, eye.distanceTo(target))\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.position1 && data.position2) {\n calculateCenterArray(data.position1, data.position2, this._position)\n this._position1 = data.position1\n this._position2 = data.position2\n data.position = this._position\n }\n if (data.radius) this._radius = data.radius\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('cone', ConeBuffer)\n\nexport default ConeBuffer\n","/**\n * @file Geometry Group\n * @author Alexander Rose \n * @private\n */\n\nimport { Box3, BufferGeometry } from 'three'\n\nclass GeometryGroup {\n geometryList: BufferGeometry[]\n boundingBox: Box3\n\n constructor (geometryList: BufferGeometry[] = []) {\n this.geometryList = geometryList\n }\n\n computeBoundingBox () {\n if (!this.boundingBox) {\n this.boundingBox = new Box3()\n } else {\n this.boundingBox.empty()\n }\n\n this.geometryList.forEach(geo => {\n if (!geo.boundingBox) geo.computeBoundingBox()\n this.boundingBox.union(geo.boundingBox as Box3)\n })\n }\n}\n\nexport default GeometryGroup\n","/**\n * @file Arrow Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3, Group } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport { createParams, defaults } from '../utils'\nimport { Picker } from '../utils/picker'\nimport Buffer from './buffer'\nimport CylinderBuffer, { CylinderBufferData } from './cylinder-buffer'\nimport CylinderGeometryBuffer from './cylindergeometry-buffer'\nimport ConeBuffer, { ConeBufferData } from './cone-buffer'\nimport GeometryGroup from '../viewer/geometry-group'\nimport { BufferData, BufferDefaultParameters } from './buffer'\n\nexport interface ArrowBufferData extends BufferData {\n position1: Float32Array\n position2: Float32Array\n radius: Float32Array\n}\n\nexport const ArrowBufferDefaultParameters = Object.assign({\n aspectRatio: 1.5,\n radialSegments: 50,\n openEnded: false,\n disableImpostor: false\n}, BufferDefaultParameters)\nexport type ArrowBufferParameters = typeof ArrowBufferDefaultParameters\n\n/**\n * Arrow buffer. Draws arrows made from a cylinder and a cone.\n * @implements {Buffer}\n *\n * @example\n * var arrowBuffer = new ArrowBuffer({\n * position1: new Float32Array([ 0, 0, 0 ]),\n * position2: new Float32Array([ 10, 1, 1 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ])\n * });\n */\nclass ArrowBuffer {\n parameters: ArrowBufferParameters\n get defaultParameters() { return ArrowBufferDefaultParameters }\n\n cylinderBuffer: CylinderGeometryBuffer\n coneBuffer: ConeBuffer\n\n splitPosition: Float32Array\n cylinderRadius: Float32Array\n\n geometry: GeometryGroup\n picking?: Picker\n\n group = new Group()\n wireframeGroup = new Group()\n pickingGroup = new Group()\n\n visible = true\n\n /**\n * @param {Object} data - buffer data\n * @param {Float32Array} data.position1 - from positions\n * @param {Float32Array} data.position2 - to positions\n * @param {Float32Array} data.color - colors\n * @param {Float32Array} data.radius - radii\n * @param {Picker} [data.picking] - picking ids\n * @param {BufferParameters} [params] - parameters object\n */\n constructor (data: ArrowBufferData, params: Partial = {}) {\n this.parameters = createParams(params, this.defaultParameters)\n\n this.splitPosition = new Float32Array(data.position1.length)\n this.cylinderRadius = new Float32Array(data.radius.length)\n\n const attr = this.makeAttributes(data)\n const bufferParams = {\n radialSegments: this.parameters.radialSegments,\n openEnded: this.parameters.openEnded,\n disableImpostor: this.parameters.disableImpostor\n }\n\n this.cylinderBuffer = new CylinderBuffer(\n attr.cylinder as CylinderBufferData, bufferParams\n ) as CylinderGeometryBuffer\n this.coneBuffer = new ConeBuffer(\n attr.cone as ConeBufferData, bufferParams\n )\n\n this.geometry = new GeometryGroup([\n this.cylinderBuffer.geometry,\n this.coneBuffer.geometry\n ])\n\n // requires Group objects to be present\n this.matrix = defaults(params.matrix, new Matrix4())\n\n this.picking = data.picking\n }\n\n set matrix (m) {\n Buffer.prototype.setMatrix.call(this, m)\n }\n get matrix () {\n return this.group.matrix.clone()\n }\n\n get pickable () {\n return !!this.picking\n }\n\n makeAttributes (data: Partial = {}) {\n const splitPosition = this.splitPosition\n const cylinderRadius = this.cylinderRadius\n\n const aspectRatio = this.parameters.aspectRatio\n\n let i, il\n const cylinder: Partial = {}\n const cone: Partial = {}\n\n if (data.radius) {\n for (i = 0, il = cylinderRadius.length; i < il; ++i) {\n cylinderRadius[ i ] = data.radius[ i ] / aspectRatio\n }\n cylinder.radius = cylinderRadius\n cone.radius = data.radius\n }\n\n if (data.position1 && data.position2) {\n const vFrom = new Vector3()\n const vTo = new Vector3()\n const vDir = new Vector3()\n const vSplit = new Vector3()\n for (i = 0, il = splitPosition.length; i < il; i += 3) {\n vFrom.fromArray(data.position1 as any, i)\n vTo.fromArray(data.position2 as any, i)\n vDir.subVectors(vFrom, vTo)\n const fullLength = vDir.length()\n const coneLength = cylinderRadius[ i / 3 ] * aspectRatio * 2\n const length = Math.min(fullLength, coneLength)\n vDir.setLength(length)\n vSplit.copy(vTo).add(vDir)\n vSplit.toArray(splitPosition as any, i)\n }\n cylinder.position1 = data.position1\n cylinder.position2 = splitPosition\n cone.position1 = splitPosition\n cone.position2 = data.position2\n }\n\n if (data.color) {\n cylinder.color = data.color\n cylinder.color2 = data.color\n cone.color = data.color\n }\n\n return {\n cylinder: cylinder,\n cone: cone\n }\n }\n\n getMesh () {\n return new Group().add(\n this.cylinderBuffer.getMesh(),\n this.coneBuffer.getMesh()\n )\n }\n\n getWireframeMesh () {\n return new Group().add(\n this.cylinderBuffer.getWireframeMesh(),\n this.coneBuffer.getWireframeMesh()\n )\n }\n\n getPickingMesh () {\n return new Group().add(\n this.cylinderBuffer.getPickingMesh(),\n this.coneBuffer.getPickingMesh()\n )\n }\n\n setAttributes (data: Partial = {}) {\n const attr = this.makeAttributes(data)\n\n this.cylinderBuffer.setAttributes(attr.cylinder)\n this.coneBuffer.setAttributes(attr.cone)\n }\n\n /**\n * Set buffer parameters\n * @param {BufferParameters} params - buffer parameters object\n * @return {undefined}\n */\n setParameters (params: Partial = {}) {\n params = Object.assign({}, params)\n\n if (params && params.matrix !== undefined) {\n this.matrix = params.matrix\n }\n delete params.matrix\n\n if (params && params.wireframe !== undefined) {\n this.parameters.wireframe = params.wireframe\n this.setVisibility(this.visible)\n }\n\n this.cylinderBuffer.setParameters(params)\n this.coneBuffer.setParameters(params)\n }\n\n setVisibility (value: boolean) {\n Buffer.prototype.setVisibility.call(this, value)\n }\n\n dispose () {\n this.cylinderBuffer.dispose()\n this.coneBuffer.dispose()\n }\n}\n\nBufferRegistry.add('arrow', ArrowBuffer)\n\nexport default ArrowBuffer\n","/**\n * @file Box Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { BoxBufferGeometry, Vector3, Matrix4 } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface BoxBufferData extends BufferData {\n heightAxis: Float32Array\n depthAxis: Float32Array\n size: Float32Array\n}\n\n/**\n * Box buffer. Draws boxes.\n *\n * @example\n * var boxBuffer = new BoxBuffer({\n * position: new Float32Array([ 0, 3, 0, -2, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 1, 0, 1, 0 ]),\n * size: new Float32Array([ 2, 1.5 ]),\n * heightAxis: new Float32Array([ 0, 1, 1, 0, 2, 0 ]),\n * depthAxis: new Float32Array([ 1, 0, 1, 0, 0, 2 ])\n * })\n */\nclass BoxBuffer extends GeometryBuffer {\n updateNormals = true\n\n _heightAxis: Float32Array\n _depthAxis: Float32Array\n _size: Float32Array\n\n constructor (data: BoxBufferData, params: Partial = {}) {\n super(data, params, new BoxBufferGeometry(1, 1, 1))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._heightAxis as any, i3)\n up.fromArray(this._depthAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n scale.set(this._size[ i ], up.length(), target.length())\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.size) this._size = data.size\n if (data.heightAxis) this._heightAxis = data.heightAxis\n if (data.depthAxis) this._depthAxis = data.depthAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('box', BoxBuffer)\n\nexport default BoxBuffer\n","/**\n * @file Ellipsoid Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { IcosahedronBufferGeometry, Vector3, Matrix4 } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferDefaultParameters } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface EllipsoidBufferData extends BufferData {\n majorAxis: Float32Array\n minorAxis: Float32Array\n radius: Float32Array\n}\n\nexport const EllipsoidBufferDefaultParameters = Object.assign({\n sphereDetail: 2,\n}, BufferDefaultParameters)\nexport type EllipsoidBufferParameters = typeof EllipsoidBufferDefaultParameters\n\n/**\n * Ellipsoid buffer. Draws ellipsoids.\n *\n * @example\n * var ellipsoidBuffer = new EllipsoidBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ]),\n * majorAxis: new Float32Array([ 1, 1, 0 ]),\n * minorAxis: new Float32Array([ 0.5, 0, 0.5 ]),\n * });\n */\nclass EllipsoidBuffer extends GeometryBuffer {\n updateNormals = true\n\n get defaultParameters() { return EllipsoidBufferDefaultParameters }\n parameters: EllipsoidBufferParameters\n\n _majorAxis: Float32Array\n _minorAxis: Float32Array\n _radius: Float32Array\n\n constructor (data: EllipsoidBufferData, params: Partial = {}) {\n super(data, params, new IcosahedronBufferGeometry(1, defaults(params.sphereDetail, 2)))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._majorAxis as any, i3)\n up.fromArray(this._minorAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n scale.set(this._radius[ i ], up.length(), target.length())\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.radius) this._radius = data.radius\n if (data.majorAxis) this._majorAxis = data.majorAxis\n if (data.minorAxis) this._minorAxis = data.minorAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('ellipsoid', EllipsoidBuffer)\n\nexport default EllipsoidBuffer\n","/**\n * @file Octahedron Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { OctahedronBufferGeometry, Vector3, Matrix4 } from 'three'\nimport { BufferRegistry } from '../globals'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface OctahedronBufferData extends BufferData {\n heightAxis: Float32Array\n depthAxis: Float32Array\n size: Float32Array\n}\n\n/**\n * Octahedron buffer. Draws octahedrons.\n *\n * @example\n * var octahedronBuffer = new OctahedronBuffer({\n * position: new Float32Array([ 0, 3, 0, -2, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 1, 0, 1, 0 ]),\n * size: new Float32Array([ 2, 1.5 ]),\n * heightAxis: new Float32Array([ 0, 1, 1, 0, 2, 0 ]),\n * depthAxis: new Float32Array([ 1, 0, 1, 0, 0, 2 ])\n * })\n */\nclass OctahedronBuffer extends GeometryBuffer {\n updateNormals = true\n\n _heightAxis: Float32Array\n _depthAxis: Float32Array\n _size: Float32Array\n\n constructor (data: OctahedronBufferData, params: Partial = {}) {\n super(data, params, new OctahedronBufferGeometry(1, 0))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._heightAxis as any, i3)\n up.fromArray(this._depthAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n scale.set(this._size[ i ], up.length(), target.length())\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.size) this._size = data.size\n if (data.heightAxis) this._heightAxis = data.heightAxis\n if (data.depthAxis) this._depthAxis = data.depthAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('octahedron', OctahedronBuffer)\n\nexport default OctahedronBuffer\n","/**\n * @file Tetrahedron Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { TetrahedronBufferGeometry, Vector3, Matrix4 } from 'three'\nimport { BufferRegistry } from '../globals'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferData, BufferParameters } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface TetrahedronBufferData extends BufferData {\n heightAxis: Float32Array\n depthAxis: Float32Array\n size: Float32Array\n}\n\n/**\n * Tetrahedron buffer. Draws tetrahedrons.\n *\n * @example\n * var tetrahedronBuffer = new TetrahedronBuffer({\n * position: new Float32Array([ 0, 3, 0, -2, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 1, 0, 1, 0 ]),\n * size: new Float32Array([ 2, 1.5 ]),\n * heightAxis: new Float32Array([ 0, 1, 1, 0, 2, 0 ]),\n * depthAxis: new Float32Array([ 1, 0, 1, 0, 0, 2 ])\n * })\n */\nclass TetrahedronBuffer extends GeometryBuffer {\n updateNormals = true\n\n _heightAxis: Float32Array\n _depthAxis: Float32Array\n _size: Float32Array\n\n constructor (data: TetrahedronBufferData, params: Partial = {}) {\n super(data, params, new TetrahedronBufferGeometry(1, 0))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._heightAxis as any, i3)\n up.fromArray(this._depthAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n scale.set(this._size[ i ], up.length(), target.length())\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.size) this._size = data.size\n if (data.heightAxis) this._heightAxis = data.heightAxis\n if (data.depthAxis) this._depthAxis = data.depthAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('tetrahedron', TetrahedronBuffer)\n\nexport default TetrahedronBuffer\n","/**\n * @file Tetrahedron Geometry Buffer\n * @author Alexander Rose \n * @private\n */\n\nimport { TorusBufferGeometry, Vector3, Matrix4 } from 'three'\n\nimport { BufferRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport GeometryBuffer from './geometry-buffer'\nimport { BufferDefaultParameters, BufferData } from './buffer'\n\nconst scale = new Vector3()\nconst target = new Vector3()\nconst up = new Vector3()\nconst eye = new Vector3(0, 0, 0)\n\nexport interface TorusBufferData extends BufferData {\n majorAxis: Float32Array\n minorAxis: Float32Array\n radius: Float32Array\n}\n\nexport const TorusBufferDefaultParameters = Object.assign({\n radiusRatio: 0.2,\n radialSegments: 16,\n tubularSegments: 32\n}, BufferDefaultParameters)\nexport type TorusBufferParameters = typeof TorusBufferDefaultParameters\n\n/**\n * Torus geometry buffer. Draws torii.\n *\n * @example\n * var torusBuffer = new TorusBuffer({\n * position: new Float32Array([ 0, 0, 0 ]),\n * color: new Float32Array([ 1, 0, 0 ]),\n * radius: new Float32Array([ 1 ]),\n * majorAxis: new Float32Array([ 1, 1, 0 ]),\n * minorAxis: new Float32Array([ 0.5, 0, 0.5 ]),\n * });\n */\nclass TorusBuffer extends GeometryBuffer {\n updateNormals = true\n\n get defaultParameters() { return TorusBufferDefaultParameters }\n parameters: TorusBufferParameters\n\n _majorAxis: Float32Array\n _minorAxis: Float32Array\n _radius: Float32Array\n\n constructor (data: TorusBufferData, params: Partial = {}) {\n super(data, params, new TorusBufferGeometry(\n 1,\n defaults(params.radiusRatio, 0.2),\n defaults(params.radialSegments, 16),\n defaults(params.tubularSegments, 32)\n ))\n\n this.setAttributes(data, true)\n }\n\n applyPositionTransform (matrix: Matrix4, i: number, i3: number) {\n target.fromArray(this._majorAxis as any, i3)\n up.fromArray(this._minorAxis as any, i3)\n matrix.lookAt(eye, target, up)\n\n const r = this._radius[ i ]\n scale.set(r, r, r)\n matrix.scale(scale)\n }\n\n setAttributes (data: Partial = {}, initNormals?: boolean) {\n if (data.radius) this._radius = data.radius\n if (data.majorAxis) this._majorAxis = data.majorAxis\n if (data.minorAxis) this._minorAxis = data.minorAxis\n\n super.setAttributes(data, initNormals)\n }\n}\n\nBufferRegistry.add('torus', TorusBuffer)\n\nexport default TorusBuffer\n","/**\n * @file Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log } from '../globals'\nimport { defaults } from '../utils'\nimport Streamer from '../streamer/streamer';\n\nexport interface ParserParameters {\n name: string\n path: string\n}\n\nclass Parser {\n streamer: Streamer\n name: string\n path: string\n [k: string]: any\n \n constructor (streamer: Streamer, params?: Partial) {\n var p = params || {}\n\n this.streamer = streamer\n\n this.name = defaults(p.name, '')\n this.path = defaults(p.path, '')\n }\n\n get type () { return '' }\n get __objName () { return '' }\n get isBinary () { return false }\n get isJson () { return false }\n get isXml () { return false }\n\n parse () {\n return this.streamer.read().then(() => {\n this._beforeParse()\n this._parse()\n this._afterParse()\n return this[ this.__objName ]\n })\n }\n\n _parse () {}\n\n _beforeParse () {}\n\n _afterParse () {\n if (Debug) Log.log(this[ this.__objName ])\n }\n}\n\nexport default Parser\n","/**\n * @file Structure Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport Parser, { ParserParameters } from './parser'\nimport Structure from '../structure/structure'\nimport StructureBuilder from '../structure/structure-builder'\nimport Streamer from '../streamer/streamer';\n\nexport interface StructureParserParameters extends ParserParameters {\n firstModelOnly: boolean\n asTrajectory: boolean\n cAlphaOnly: boolean\n}\nclass StructureParser extends Parser {\n\n structureBuilder: StructureBuilder\n\n constructor (streamer: Streamer, params?: Partial) {\n var p = params || {}\n\n super(streamer, p)\n\n this.firstModelOnly = defaults(p.firstModelOnly, false)\n this.asTrajectory = defaults(p.asTrajectory, false)\n this.cAlphaOnly = defaults(p.cAlphaOnly, false)\n\n this.structure = new Structure(this.name, this.path)\n this.structureBuilder = new StructureBuilder(this.structure)\n }\n\n get type () { return 'structure' }\n get __objName () { return 'structure' }\n}\n\nexport default StructureParser\n","/**\n * @file Entity\n * @author Alexander Rose \n * @private\n */\n\nimport Structure from './structure'\nimport {\n UnknownEntity, PolymerEntity, NonPolymerEntity, MacrolideEntity, WaterEntity\n} from './structure-constants'\nimport ChainProxy from '../proxy/chain-proxy'\n\nfunction entityTypeFromString (string: string) {\n string = string.toLowerCase()\n switch (string) {\n case 'polymer':\n return PolymerEntity\n case 'non-polymer':\n return NonPolymerEntity\n case 'macrolide':\n return MacrolideEntity\n case 'water':\n return WaterEntity\n default:\n return UnknownEntity\n }\n}\n\nfunction entityFromType (type: number) {\n switch (type) {\n case PolymerEntity:\n return 'polymer'\n case NonPolymerEntity:\n return 'non-polymer'\n case MacrolideEntity:\n return 'macrolide'\n case WaterEntity:\n return 'water'\n default:\n return undefined\n }\n}\n\nexport const EntityTypeString = {\n 'polymer': PolymerEntity,\n 'non-polymer': NonPolymerEntity,\n 'macrolide': MacrolideEntity,\n 'water': WaterEntity,\n}\nexport type EntityTypeString = keyof typeof EntityTypeString\n\n/**\n * Entity of a {@link Structure}\n */\nexport default class Entity {\n structure: Structure\n index: number\n description: string\n entityType: number\n chainIndexList: number[]\n\n /**\n * @param {Structure} structure - structure the entity belongs to\n * @param {Integer} index - index within structure.entityList\n * @param {String} description - entity description\n * @param {String} type - entity type\n * @param {Array} chainIndexList - entity chainIndexList\n */\n constructor (structure: Structure, index: number, description = '', type?: EntityTypeString, chainIndexList: number[] = []) {\n this.structure = structure\n this.index = index\n this.description = description\n this.entityType = entityTypeFromString(type || '')\n this.chainIndexList = chainIndexList\n\n chainIndexList.forEach(function (ci: number) {\n structure.chainStore.entityIndex[ ci ] = index\n })\n }\n\n get type () { return entityFromType(this.entityType) }\n\n getEntityType () {\n return this.entityType\n }\n\n isPolymer () {\n return this.entityType === PolymerEntity\n }\n\n isNonPolymer () {\n return this.entityType === NonPolymerEntity\n }\n\n isMacrolide () {\n return this.entityType === MacrolideEntity\n }\n\n isWater () {\n return this.entityType === WaterEntity\n }\n\n eachChain (callback: (cp: ChainProxy) => any) {\n const cp = this.structure.getChainProxy()\n\n this.chainIndexList.forEach(function (index) {\n cp.index = index\n callback(cp)\n })\n }\n}","/**\n * @file Unitcell\n * @author Alexander Rose \n * @private\n */\n\nimport { Color, Vector3, Matrix4 } from 'three'\n\nimport { defaults } from '../utils'\nimport { degToRad } from '../math/math-utils'\nimport {\n uniformArray, uniformArray3, centerArray3\n} from '../math/array-utils'\nimport { UnitcellPicker } from '../utils/picker'\nimport Structure from '../structure/structure'\n\nexport interface UnitcellParams {\n a: number\n b: number\n c: number\n alpha: number\n beta: number\n gamma: number\n spacegroup: string\n cartToFrac?: Matrix4\n}\n\nconst DefaultBoxParams = {\n a: 1,\n b: 1,\n c: 1,\n alpha: 90,\n beta: 90,\n gamma: 90,\n spacegroup: 'P 1'\n}\n\nexport interface UnitcellDataParams {\n colorValue?: string|number,\n radius?: number\n}\n\n/**\n * Unitcell class\n */\nclass Unitcell {\n a: number\n b: number\n c: number\n alpha: number\n beta: number\n gamma: number\n\n spacegroup: string\n\n cartToFrac = new Matrix4()\n fracToCart = new Matrix4()\n\n volume: number\n\n /**\n * @param {Object} params - unitcell parameters\n * @param {Number} params.a - length a\n * @param {Number} params.b - length b\n * @param {Number} params.c - length c\n * @param {Number} params.alpha - angle alpha\n * @param {Number} params.beta - angle beta\n * @param {Number} params.gamma - angle gamma\n * @param {String} params.spacegroup - spacegroup\n * @param {Matrix4} [params.cartToFrac] - transformation matrix from\n * cartesian to fractional coordinates\n * @param {Matrix4} [params.scale] - alias for `params.cartToFrac`\n */\n constructor (params: UnitcellParams = DefaultBoxParams) {\n this.a = params.a\n this.b = params.b\n this.c = params.c\n this.alpha = params.alpha\n this.beta = params.beta\n this.gamma = params.gamma\n this.spacegroup = params.spacegroup\n\n const alphaRad = degToRad(this.alpha)\n const betaRad = degToRad(this.beta)\n const gammaRad = degToRad(this.gamma)\n const cosAlpha = Math.cos(alphaRad)\n const cosBeta = Math.cos(betaRad)\n const cosGamma = Math.cos(gammaRad)\n const sinBeta = Math.sin(betaRad)\n const sinGamma = Math.sin(gammaRad)\n\n this.volume = (\n this.a * this.b * this.c *\n Math.sqrt(\n 1 - cosAlpha * cosAlpha - cosBeta * cosBeta - cosGamma * cosGamma +\n 2.0 * cosAlpha * cosBeta * cosGamma\n )\n )\n\n if (params.cartToFrac === undefined) {\n // https://github.com/biojava/biojava/blob/master/biojava-structure/src/main/java/org/biojava/nbio/structure/xtal/CrystalCell.java\n\n const cStar = (this.a * this.b * sinGamma) / this.volume\n const cosAlphaStar = (\n (cosBeta * cosGamma - cosAlpha) / (sinBeta * sinGamma)\n )\n\n this.fracToCart.set(\n this.a, 0, 0, 0,\n this.b * cosGamma, this.b * sinGamma, 0, 0,\n this.c * cosBeta, -this.c * sinBeta * cosAlphaStar, 1.0 / cStar, 0,\n 0, 0, 0, 1\n ).transpose()\n this.cartToFrac.getInverse(this.fracToCart)\n } else {\n this.cartToFrac.copy(params.cartToFrac)\n this.fracToCart.getInverse(this.cartToFrac)\n }\n }\n\n getPosition (structure: Structure): Float32Array {\n const vertexPosition = new Float32Array(3 * 8)\n\n if (structure.unitcell) {\n const uc = structure.unitcell\n const centerFrac = structure.center.clone().applyMatrix4(uc.cartToFrac).floor()\n const v = new Vector3()\n\n let cornerOffset = 0\n const addCorner = function (x: number, y: number, z: number) {\n v.set(x, y, z)\n .add(centerFrac)\n .applyMatrix4(uc.fracToCart)\n .toArray(vertexPosition as any, cornerOffset)\n cornerOffset += 3\n }\n addCorner(0, 0, 0)\n addCorner(1, 0, 0)\n addCorner(0, 1, 0)\n addCorner(0, 0, 1)\n addCorner(1, 1, 0)\n addCorner(1, 0, 1)\n addCorner(0, 1, 1)\n addCorner(1, 1, 1)\n }\n\n return vertexPosition\n }\n\n getCenter (structure: Structure) {\n return centerArray3(this.getPosition(structure))\n }\n\n getData (structure: Structure, params: UnitcellDataParams = {}) {\n const colorValue = defaults(params.colorValue, 'orange')\n const radius = defaults(params.radius, Math.cbrt(this.volume) / 200)\n\n const c = new Color(colorValue)\n const v = new Vector3()\n\n const vertexPosition = this.getPosition(structure)\n const vertexColor = uniformArray3(8, c.r, c.g, c.b)\n const vertexRadius = uniformArray(8, radius)\n\n const edgePosition1 = new Float32Array(3 * 12)\n const edgePosition2 = new Float32Array(3 * 12)\n const edgeColor = uniformArray3(12, c.r, c.g, c.b)\n const edgeRadius = uniformArray(12, radius)\n\n let edgeOffset = 0\n function addEdge (a: number, b: number) {\n v.fromArray(vertexPosition as any, a * 3)\n .toArray(edgePosition1 as any, edgeOffset)\n v.fromArray(vertexPosition as any, b * 3)\n .toArray(edgePosition2 as any, edgeOffset)\n edgeOffset += 3\n }\n addEdge(0, 1)\n addEdge(0, 2)\n addEdge(0, 3)\n addEdge(1, 4)\n addEdge(1, 5)\n addEdge(2, 6)\n addEdge(3, 5)\n addEdge(4, 7)\n addEdge(5, 7)\n addEdge(2, 4)\n addEdge(7, 6)\n addEdge(3, 6)\n\n const picker = new UnitcellPicker(this, structure)\n\n return {\n vertex: {\n position: vertexPosition,\n color: vertexColor,\n radius: vertexRadius,\n picking: picker\n },\n edge: {\n position1: edgePosition1,\n position2: edgePosition2,\n color: edgeColor,\n color2: edgeColor,\n radius: edgeRadius,\n picking: picker\n }\n }\n }\n}\n\nexport default Unitcell\n","/**\n * @file Pdb Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport StructureParser from './structure-parser'\nimport Entity, { EntityTypeString } from '../structure/entity'\nimport Unitcell, { UnitcellParams } from '../symmetry/unitcell'\nimport Assembly, { AssemblyPart } from '../symmetry/assembly'\nimport { PDBQTSpecialElements, WaterNames } from '../structure/structure-constants'\nimport {\n assignSecondaryStructure, InferBondsOptions, buildUnitcellAssembly,\n calculateBonds, calculateChainnames, calculateSecondaryStructure\n} from '../structure/structure-utils'\nimport Streamer from '../streamer/streamer';\nimport { ParserParameters } from './parser';\nimport { NumberArray } from '../types';\nimport { Structure } from '../ngl';\n\n// PDB helix record encoding\nconst HelixTypes: {[k: number]: string} = {\n 1: 'h', // Right-handed alpha (default)\n 2: 'h', // Right-handed omega\n 3: 'i', // Right-handed pi\n 4: 'h', // Right-handed gamma\n 5: 'g', // Right-handed 310\n 6: 'h', // Left-handed alpha\n 7: 'h', // Left-handed omega\n 8: 'h', // Left-handed gamma\n 9: 'h', // 27 ribbon/helix\n 10: 'h', // Polyproline\n 0: 'h' //Used to be ''\n}\n\nconst dAminoAcids = [\n 'DAL', // D-ALANINE\n 'DAR', // D-ARGININE\n 'DSG', // D-ASPARAGINE\n 'DAS', // D-ASPARTIC ACID\n 'DCY', // D-CYSTEINE\n 'DGL', // D-GLUTAMIC ACID\n 'DGN', // D-GLUTAMINE\n 'DHI', // D-HISTIDINE\n 'DIL', // D-ISOLEUCINE\n 'DLE', // D-LEUCINE\n 'DLY', // D-LYSINE\n 'MED', // D-METHIONINE\n 'DPN', // D-PHENYLALANINE\n 'DPR', // D-PROLINE\n 'DSN', // D-SERINE\n 'DTH', // D-THREONINE\n 'DTR', // D-TRYPTOPHAN\n 'DTY', // D-TYROSINE\n 'DVA', // D-VALINE\n\n 'DNE' // D-NORLEUCINE\n\n // ??? // D-SELENOCYSTEINE\n]\n\nconst entityKeyList = [\n 'MOL_ID', 'MOLECULE', 'CHAIN', 'FRAGMENT', 'SYNONYM',\n 'EC', 'ENGINEERED', 'MUTATION', 'OTHER_DETAILS'\n]\n\nconst reWhitespace = /\\s+/\n\nfunction getModresId (resno: number, chainname?: string, inscode?: string) {\n let id = `${resno}`\n if (chainname) id += `:${chainname}`\n if (inscode) id += `^${inscode}`\n return id\n}\n\nexport interface PdbParserParameters extends ParserParameters {\n hex: boolean\n inferBonds: InferBondsOptions\n}\n\nclass PdbParser extends StructureParser {\n\n hex: boolean\n inferBonds: InferBondsOptions\n\n /**\n * Create a pdb parser\n * @param {Streamer} streamer - streamer object\n * @param {Object} params - params object\n * @param {Boolean} params.hex - hexadecimal parsing of\n * atom numbers >99.999 and\n * residue numbers >9.999\n * @param {InferBondsOptions} params.inferBonds: 'all': use explicit bonds and detect by distance\n * 'auto': If a hetgroup residue has explicit bonds, don't auto-detect\n * 'none': Don't add any bonds automatically\n * @return {undefined}\n */\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.hex = defaults(p.hex, false)\n this.inferBonds = defaults(p.inferBonds, 'all')\n }\n\n get type () { return 'pdb' }\n\n _parse () {\n // http://www.wwpdb.org/documentation/file-format.php\n\n if (Debug) Log.time('PdbParser._parse ' + this.name)\n\n let isLegacy = false\n const headerLine = this.streamer.peekLines(1)[ 0 ]\n const headerId = headerLine.substr(62, 4)\n const legacyId = headerLine.substr(72, 4)\n if (headerId === legacyId && legacyId.trim()) {\n isLegacy = true\n }\n\n const isPqr = this.type === 'pqr'\n const isPdbqt = this.type === 'pdbqt'\n\n const s: Structure = this.structure\n const sb = this.structureBuilder\n\n const hex = this.hex\n let serialRadix = 10\n let resnoRadix = 10\n\n const firstModelOnly = this.firstModelOnly\n const asTrajectory = this.asTrajectory\n const cAlphaOnly = this.cAlphaOnly\n\n const frames = s.frames\n const boxes = s.boxes\n let doFrames = false\n let currentFrame: NumberArray, currentCoord: number\n\n const biomolDict = s.biomolDict\n let currentBiomol: Assembly\n let currentPart: AssemblyPart\n let currentMatrix: Matrix4\n\n let line, recordName\n let serial, chainname: string, resno: number, resname: string, occupancy: number\n let inscode: string, atomname, hetero: boolean, bfactor: number, altloc\n let formalCharge: number\n\n let startChain, startResi, startIcode\n let endChain, endResi, endIcode\n\n let serialDict: {[k: number]: number} = {}\n const unitcellDict: Partial<{\n origx: Matrix4\n scale: Matrix4\n a: number\n b: number\n c: number\n alpha: number\n beta: number\n gamma: number\n spacegroup: string\n }> = {}\n const bondDict: {[k: string]: boolean} = {}\n\n const entityDataList: {chainList: string[], name: string}[] = []\n let currentEntityData: {chainList: string[], name: string}\n let currentEntityKey: 'MOL_ID'|'MOLECULE'|'CHAIN'|'FRAGMENT'|'SYNONYM'|'EC'|'ENGINEERED'|'MUTATION'|'OTHER_DETAILS'\n // MOL_ID Numbers each component; also used in SOURCE to associate\n // the information.\n // MOLECULE Name of the macromolecule.\n // CHAIN Comma-separated list of chain identifier(s).\n // FRAGMENT Specifies a domain or region of the molecule.\n // SYNONYM Comma-separated list of synonyms for the MOLECULE.\n // EC The Enzyme Commission number associated with the molecule.\n // If there is more than one EC number, they are presented\n // as a comma-separated list.\n // ENGINEERED Indicates that the molecule was produced using\n // recombinant technology or by purely chemical synthesis.\n // MUTATION Indicates if there is a mutation.\n // OTHER_DETAILS Additional comments.\n\n const hetnameDict: {[k: string]: string} = {}\n const modresDict: {[k: string]: any} = {}\n\n const chainDict: {[k: string]: number} = {}\n let chainIdx: number, chainid: string, newChain: boolean\n let currentChainname: string, currentResno: number, currentResname: string, currentInscode: string\n\n const seqresDict: {[k: string]: string[]} = {}\n let currentSeqresChainname: string\n\n const secStruct = {\n helices: [] as any[],\n sheets: [] as any[]\n }\n const helices = secStruct.helices\n const sheets = secStruct.sheets\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.resize(Math.round(this.streamer.data.length / 80))\n if (isPqr || isPdbqt) atomStore.addField('partialCharge', 1, 'float32')\n if (isPqr) atomStore.addField('radius', 1, 'float32')\n\n const ap1 = s.getAtomProxy()\n const ap2 = s.getAtomProxy()\n\n let idx = 0\n let modelIdx = 0\n let pendingStart = true\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n line = lines[ i ]\n recordName = line.substr(0, 6)\n\n if (recordName === 'ATOM ' || recordName === 'HETATM') {\n // http://www.wwpdb.org/documentation/file-format-content/format33/sect9.html#ATOM\n // PQR: Field_name Atom_number Atom_name Residue_name Chain_ID Residue_number X Y Z Charge Radius\n\n if (pendingStart) {\n if (asTrajectory) {\n if (doFrames) {\n currentFrame = new Float32Array(atomStore.count * 3)\n frames.push(currentFrame)\n } else {\n currentFrame = []\n }\n currentCoord = 0\n } else {\n if (!firstModelOnly) serialDict = {}\n }\n\n chainIdx = 1\n chainid = chainIdx.toString()\n newChain = true\n\n pendingStart = false\n }\n\n if (firstModelOnly && modelIdx > 0) continue\n\n let x, y, z, ls: string[], dd = 0\n\n if (isPqr) {\n ls = line.split(reWhitespace)\n dd = ls.length === 10 ? 1 : 0\n\n atomname = ls[ 2 ]\n if (cAlphaOnly && atomname !== 'CA') continue\n\n x = parseFloat(ls[ 6 - dd ])\n y = parseFloat(ls[ 7 - dd ])\n z = parseFloat(ls[ 8 - dd ])\n } else {\n atomname = line.substr(12, 4).trim()\n if (cAlphaOnly && atomname !== 'CA') continue\n\n x = parseFloat(line.substr(30, 8))\n y = parseFloat(line.substr(38, 8))\n z = parseFloat(line.substr(46, 8))\n }\n\n if (asTrajectory) {\n const j = currentCoord * 3\n\n currentFrame[ j + 0 ] = x\n currentFrame[ j + 1 ] = y\n currentFrame[ j + 2 ] = z\n\n currentCoord += 1\n\n if (doFrames) continue\n }\n\n let element\n\n if (isPqr) {\n serial = parseInt(ls![ 1 ])\n element = ''\n hetero = (line[ 0 ] === 'H')\n chainname = dd ? '' : ls![ 4 ]\n resno = parseInt(ls![ 5 - dd! ])\n inscode = ''\n resname = ls![ 3 ]\n altloc = ''\n occupancy = 1.0\n } else {\n serial = parseInt(line.substr(6, 5), serialRadix)\n if (hex && serial === 99999) {\n serialRadix = 16\n }\n hetero = (line[ 0 ] === 'H')\n chainname = line[ 21 ].trim()\n resno = parseInt(line.substr(22, 4), resnoRadix)\n if (hex && resno === 9999) {\n resnoRadix = 16\n }\n inscode = line[ 26 ].trim()\n resname = line.substr(17, 4).trim() || 'MOL'\n bfactor = parseFloat(line.substr(60, 6))\n altloc = line[ 16 ].trim()\n occupancy = parseFloat(line.substr(54, 6))\n\n if (!isLegacy) {\n if (isPdbqt) {\n element = line.substr(76, 3).trim()\n // @ts-expect-error TS limitation on narrowing indexes types with `in`\n if (element in PDBQTSpecialElements) element = PDBQTSpecialElements[element]\n } else {\n element = line.substr(76, 2).trim()\n if (!chainname) {\n chainname = line.substr(72, 4).trim() // segid\n }\n }\n // Where specified, formalCharge is of form \"2-\" or \"1+\"\n formalCharge = parseInt((line.substr(79,1) + line.substr(78, 1)).trim())\n }\n }\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname, element)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = serial\n atomStore.altloc[ idx ] = altloc.charCodeAt(0)\n atomStore.occupancy[ idx ] = isNaN(occupancy) ? 0 : occupancy\n\n if (isPqr) {\n atomStore.partialCharge![ idx ] = parseFloat(ls![ 9 - dd! ])\n atomStore.radius[ idx ] = parseFloat(ls![ 10 - dd! ])\n } else {\n atomStore.bfactor[ idx ] = isNaN(bfactor) ? 0 : bfactor\n if (isPdbqt) {\n atomStore.partialCharge![ idx ] = parseFloat(line.substr(70, 6))\n }\n // isFinite check will reject undefined (in legacy case) and NaN values\n if (isFinite(formalCharge)) {\n if (!atomStore.formalCharge) {\n atomStore.addField('formalCharge', 1, 'int8')\n }\n atomStore.formalCharge![ idx ] = formalCharge\n }\n }\n\n const modresId = getModresId(resno, chainname, inscode)\n\n // TODO instead of looking at MODRES look at SEQRES and\n // missing residues in REMARK 465\n if (hetero && !modresDict[modresId] && !dAminoAcids.includes(resname)) {\n if (currentChainname !== chainname || currentResname !== resname ||\n (!WaterNames.includes(resname) &&\n (currentResno !== resno || currentInscode !== inscode))\n ) {\n chainIdx += 1\n chainid = chainIdx.toString()\n\n currentResno = resno\n currentResname = resname\n currentInscode = inscode\n }\n } else if (!newChain && currentChainname !== chainname) {\n chainIdx += 1\n chainid = chainIdx.toString()\n }\n\n sb.addAtom(modelIdx, chainname, chainid, resname, resno, hetero, undefined, inscode)\n\n serialDict[ serial ] = idx\n idx += 1\n newChain = false\n currentChainname = chainname\n } else if (recordName === 'CONECT') {\n const fromIdx = serialDict[ parseInt(line.substr(6, 5)) ]\n const pos = [ 11, 16, 21, 26 ]\n const bondIndex: {[k: number]: number} = {}\n\n if (fromIdx === undefined) {\n // Log.log( \"missing CONNECT serial\" );\n continue\n }\n\n for (let j = 0; j < 4; ++j) {\n let toIdx = parseInt(line.substr(pos[ j ], 5))\n if (Number.isNaN(toIdx)) continue\n toIdx = serialDict[ toIdx ]\n if (toIdx === undefined) {\n // Log.log( \"missing CONNECT serial\" );\n continue\n }/* else if( toIdx < fromIdx ){\n // likely a duplicate in standard PDB format\n // but not necessarily, so better remove duplicates\n // in a pass after parsing (and auto bonding)\n continue;\n } */\n\n if (fromIdx < toIdx) {\n ap1.index = fromIdx\n ap2.index = toIdx\n } else {\n ap1.index = toIdx\n ap2.index = fromIdx\n }\n\n // interpret records where a 'toIdx' atom is given multiple times\n // as double/triple bonds, e.g. CONECT 1529 1528 1528 is a double bond\n if (bondIndex[ toIdx ] !== undefined) {\n s.bondStore.bondOrder[ bondIndex[ toIdx ] ] += 1\n } else {\n const hash = ap1.index + '|' + ap2.index\n if (bondDict[ hash ] === undefined) {\n bondDict[ hash ] = true\n bondIndex[ toIdx ] = s.bondStore.count\n s.bondStore.addBond(ap1, ap2, 1) // start/assume with single bond\n }\n }\n }\n } else if (recordName === 'HELIX ') {\n startChain = line[ 19 ].trim()\n startResi = parseInt(line.substr(21, 4))\n startIcode = line[ 25 ].trim()\n endChain = line[ 31 ].trim()\n endResi = parseInt(line.substr(33, 4))\n endIcode = line[ 37 ].trim()\n let helixType = parseInt(line.substr(39, 1))\n helixType = (HelixTypes[ helixType ] || HelixTypes[0]).charCodeAt(0)\n helices.push([\n startChain, startResi, startIcode,\n endChain, endResi, endIcode,\n helixType\n ])\n } else if (recordName === 'SHEET ') {\n startChain = line[ 21 ].trim()\n startResi = parseInt(line.substr(22, 4))\n startIcode = line[ 26 ].trim()\n endChain = line[ 32 ].trim()\n endResi = parseInt(line.substr(33, 4))\n endIcode = line[ 37 ].trim()\n sheets.push([\n startChain, startResi, startIcode,\n endChain, endResi, endIcode\n ])\n } else if (recordName === 'HETNAM') {\n hetnameDict[ line.substr(11, 3) ] = line.substr(15).trim()\n } else if (recordName === 'SEQRES') {\n const seqresChainname = line[11].trim()\n if (seqresChainname !== currentSeqresChainname) {\n seqresDict[ seqresChainname ] = []\n currentSeqresChainname = seqresChainname\n }\n seqresDict[ seqresChainname ].push(\n ...line.substr(19).trim().split(reWhitespace)\n )\n } else if (recordName === 'MODRES') {\n // MODRES 2SRC PTR A 527 TYR O-PHOSPHOTYROSINE\n const resname = line.substr(12, 3).trim()\n const chainname = line[16].trim()\n const inscode = line[22].trim()\n const resno = parseInt(line.substr(18, 4).trim())\n const id = getModresId(resno, chainname, inscode)\n modresDict[ id ] = { resname, chainname, inscode, resno }\n } else if (recordName === 'COMPND') {\n const comp = line.substr(10, 70).trim()\n const keyEnd = comp.indexOf(':')\n const key = comp.substring(0, keyEnd)\n let value\n\n if (entityKeyList.includes(key)) {\n currentEntityKey = key as 'MOL_ID'|'MOLECULE'|'CHAIN'|'FRAGMENT'|'SYNONYM'|'EC'|'ENGINEERED'|'MUTATION'|'OTHER_DETAILS'\n value = comp.substring(keyEnd + 2)\n } else {\n value = comp\n }\n value = value.replace(/;$/, '')\n\n if (currentEntityKey === 'MOL_ID') {\n currentEntityData = {\n chainList: [],\n name: ''\n }\n entityDataList.push(currentEntityData)\n } else if (currentEntityKey === 'MOLECULE') {\n if (currentEntityData.name) currentEntityData.name += ' '\n currentEntityData.name += value\n } else if (currentEntityKey === 'CHAIN') {\n Array.prototype.push.apply(\n currentEntityData.chainList,\n value.split(/\\s*,\\s*/)\n )\n }\n } else if (line.startsWith('TER')) {\n const cp = s.getChainProxy(s.chainStore.count - 1)\n chainDict[ cp.chainname ] = cp.index\n chainIdx += 1\n chainid = chainIdx.toString()\n newChain = true\n } else if (recordName === 'REMARK' && line.substr(7, 3) === '350') {\n if (line.substr(11, 12) === 'BIOMOLECULE:') {\n let name = line.substr(23).trim()\n if (/^(0|[1-9][0-9]*)$/.test(name)) name = 'BU' + name\n\n currentBiomol = new Assembly(name)\n biomolDict[ name ] = currentBiomol\n } else if (line.substr(13, 5) === 'BIOMT') {\n const biomt = line.split(/\\s+/)\n const row = parseInt(line[ 18 ]) - 1\n\n if (row === 0) {\n currentMatrix = new Matrix4()\n currentPart.matrixList.push(currentMatrix)\n }\n\n const biomtElms = currentMatrix.elements\n\n biomtElms[ 4 * 0 + row ] = parseFloat(biomt[ 4 ])\n biomtElms[ 4 * 1 + row ] = parseFloat(biomt[ 5 ])\n biomtElms[ 4 * 2 + row ] = parseFloat(biomt[ 6 ])\n biomtElms[ 4 * 3 + row ] = parseFloat(biomt[ 7 ])\n } else if (\n line.substr(11, 30) === 'APPLY THE FOLLOWING TO CHAINS:' ||\n line.substr(11, 30) === ' AND CHAINS:'\n ) {\n if (line.substr(11, 5) === 'APPLY') {\n currentPart = currentBiomol.addPart()\n }\n\n const chainList = line.substr(41, 30).split(',')\n for (let j = 0, jl = chainList.length; j < jl; ++j) {\n const c = chainList[ j ].trim()\n if (c) currentPart.chainList.push(c)\n }\n }\n } else if (recordName === 'HEADER') {\n s.id = line.substr(62, 4)\n } else if (recordName === 'TITLE ') {\n s.title += (s.title ? ' ' : '') + line.substr(10, 70).trim()\n } else if (recordName === 'MODEL ') {\n pendingStart = true\n } else if (recordName === 'ENDMDL' || line.trim() === 'END') {\n if (pendingStart) continue\n\n if (asTrajectory && !doFrames) {\n frames.push(new Float32Array(currentFrame))\n doFrames = true\n }\n\n modelIdx += 1\n pendingStart = true\n } else if (line.substr(0, 5) === 'MTRIX') {\n // ignore 'given' operators\n if (line[ 59 ] === '1') continue\n\n if (!currentBiomol || currentBiomol.name !== 'NCS') {\n const ncsName = 'NCS'\n currentBiomol = new Assembly(ncsName)\n biomolDict[ ncsName ] = currentBiomol\n currentPart = currentBiomol.addPart()\n }\n\n const ncs = line.split(/\\s+/)\n const ncsRow = parseInt(line[ 5 ]) - 1\n\n if (ncsRow === 0) {\n currentMatrix = new Matrix4()\n currentPart.matrixList.push(currentMatrix)\n }\n\n const ncsElms = currentMatrix.elements\n\n ncsElms[ 4 * 0 + ncsRow ] = parseFloat(ncs[ 2 ])\n ncsElms[ 4 * 1 + ncsRow ] = parseFloat(ncs[ 3 ])\n ncsElms[ 4 * 2 + ncsRow ] = parseFloat(ncs[ 4 ])\n ncsElms[ 4 * 3 + ncsRow ] = parseFloat(ncs[ 5 ])\n } else if (line.substr(0, 5) === 'ORIGX') {\n if (!unitcellDict.origx) {\n unitcellDict.origx = new Matrix4()\n }\n\n const orgix = line.split(/\\s+/)\n const origxRow = parseInt(line[ 5 ]) - 1\n const origxElms = unitcellDict.origx.elements\n\n origxElms[ 4 * 0 + origxRow ] = parseFloat(orgix[ 1 ])\n origxElms[ 4 * 1 + origxRow ] = parseFloat(orgix[ 2 ])\n origxElms[ 4 * 2 + origxRow ] = parseFloat(orgix[ 3 ])\n origxElms[ 4 * 3 + origxRow ] = parseFloat(orgix[ 4 ])\n } else if (line.substr(0, 5) === 'SCALE') {\n if (!unitcellDict.scale) {\n unitcellDict.scale = new Matrix4()\n }\n\n const scale = line.split(/\\s+/)\n const scaleRow = parseInt(line[ 5 ]) - 1\n const scaleElms = unitcellDict.scale.elements\n\n scaleElms[ 4 * 0 + scaleRow ] = parseFloat(scale[ 1 ])\n scaleElms[ 4 * 1 + scaleRow ] = parseFloat(scale[ 2 ])\n scaleElms[ 4 * 2 + scaleRow ] = parseFloat(scale[ 3 ])\n scaleElms[ 4 * 3 + scaleRow ] = parseFloat(scale[ 4 ])\n } else if (recordName === 'CRYST1') {\n // CRYST1 55.989 55.989 55.989 90.00 90.00 90.00 P 1 1\n // 7 - 15 Real(9.3) a (Angstroms)\n // 16 - 24 Real(9.3) b (Angstroms)\n // 25 - 33 Real(9.3) c (Angstroms)\n // 34 - 40 Real(7.2) alpha alpha (degrees).\n // 41 - 47 Real(7.2) beta beta (degrees).\n // 48 - 54 Real(7.2) gamma gamma (degrees).\n // 56 - 66 LString sGroup Space group.\n // 67 - 70 Integer z Z value.\n\n const aLength = parseFloat(line.substr(6, 9))\n const bLength = parseFloat(line.substr(15, 9))\n const cLength = parseFloat(line.substr(24, 9))\n\n const alpha = parseFloat(line.substr(33, 7))\n const beta = parseFloat(line.substr(40, 7))\n const gamma = parseFloat(line.substr(47, 7))\n\n const sGroup = line.substr(55, 11).trim()\n // const zValue = parseInt( line.substr( 66, 4 ) );\n\n const box = new Float32Array(9)\n box[ 0 ] = aLength\n box[ 4 ] = bLength\n box[ 8 ] = cLength\n boxes.push(box)\n\n if (modelIdx === 0) {\n unitcellDict.a = aLength\n unitcellDict.b = bLength\n unitcellDict.c = cLength\n unitcellDict.alpha = alpha\n unitcellDict.beta = beta\n unitcellDict.gamma = gamma\n unitcellDict.spacegroup = sGroup\n }\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n\n // finalize ensures resname will be defined for all rp.resname\n // (required in entity handling below)\n sb.finalize()\n\n //\n\n const en = entityDataList.length\n\n if (en) {\n s.eachChain(function (cp) {\n cp.entityIndex = en\n })\n\n entityDataList.forEach(function (e, i) {\n const chainIndexList = e.chainList.map(function (chainname) {\n return chainDict[ chainname ]\n })\n s.entityList.push(new Entity(\n s, i, e.name, 'polymer', chainIndexList\n ))\n })\n\n let ei = entityDataList.length\n const rp = s.getResidueProxy()\n const residueDict: {[k: string]: number[]} = {}\n\n s.eachChain(function (cp) {\n if (cp.entityIndex === en) {\n rp.index = cp.residueOffset\n if (!residueDict[ rp.resname ]) {\n residueDict[ rp.resname ] = []\n }\n residueDict[ rp.resname ].push(cp.index)\n }\n })\n\n Object.keys(residueDict).forEach(function (resname) {\n const chainList = residueDict[ resname ]\n let type: EntityTypeString = 'non-polymer'\n let name = hetnameDict[ resname ] || resname\n if (WaterNames.includes(resname)) {\n name = 'water'\n type = 'water'\n }\n s.entityList.push(new Entity(\n s, ei, name, type, chainList\n ))\n ei += 1\n })\n }\n\n //\n\n if (unitcellDict.a !== undefined) {\n s.unitcell = new Unitcell(unitcellDict as UnitcellParams)\n } else {\n s.unitcell = undefined\n }\n\n if (helices.length || sheets.length) {\n assignSecondaryStructure(s, secStruct)\n }\n\n s.finalizeAtoms()\n if (!isLegacy) calculateChainnames(s)\n calculateBonds(s, this.inferBonds)\n s.finalizeBonds()\n\n if (!helices.length && !sheets.length) {\n calculateSecondaryStructure(s)\n }\n buildUnitcellAssembly(s)\n\n if (Debug) Log.timeEnd('PdbParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('pdb', PdbParser)\nParserRegistry.add('pdb1', PdbParser)\nParserRegistry.add('ent', PdbParser)\n\nexport default PdbParser\n\nexport {\n HelixTypes\n}\n","/**\n * @file Cif Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport { HelixTypes } from './pdb-parser'\nimport Entity from '../structure/entity'\nimport Unitcell, { UnitcellParams } from '../symmetry/unitcell'\nimport Assembly from '../symmetry/assembly'\nimport Selection from '../selection/selection'\nimport {\n assignResidueTypeBonds, assignSecondaryStructure, buildUnitcellAssembly,\n calculateBonds, calculateSecondaryStructure\n} from '../structure/structure-utils'\nimport { Structure } from '../ngl';\nimport StructureBuilder from '../structure/structure-builder';\nimport { NumberArray } from '../types';\n\nconst reWhitespace = /\\s+/\nconst reQuotedWhitespace = /'((?:(?!'\\s).)*)'|\"((?:(?!\"\\s).)*)\"|(\\S+)/g\nconst reDoubleQuote = /\"/g\nconst reTrimQuotes = /^['\"]+|['\"]+$/g\nconst reAtomSymbol = /^\\D{1,2}/ // atom symbol in atom_site_label\n\ninterface Cif {[k: string]: any}\n\nfunction trimQuotes (str: string) {\n if (str && str[0] === str[ str.length - 1 ] && (str[0] === \"'\" || str[0] === '\"')) {\n return str.substring(1, str.length - 1)\n } else {\n return str\n }\n}\n\nfunction ensureArray (dict: {[k: string]: any[]}, field: string) {\n if (!Array.isArray(dict[ field ])) {\n Object.keys(dict).forEach(function (key) {\n dict[ key ] = [ dict[ key ] ]\n })\n }\n}\n\nfunction hasValue (d: string) {\n return d !== '?'\n}\n\nfunction cifDefaults (value: string, defaultValue: string) {\n return hasValue(value) ? value : defaultValue\n}\n\nfunction getBondOrder (valueOrder: string) {\n switch (valueOrder.toLowerCase()) {\n case '?': // assume single bond\n case 'sing':\n return 1\n case 'doub':\n return 2\n case 'trip':\n return 3\n case 'quad':\n return 4\n }\n return 0\n}\n\nfunction parseChemComp (cif: Cif, structure: Structure, structureBuilder: StructureBuilder) {\n const atomStore = structure.atomStore\n const atomMap = structure.atomMap\n\n let i, n\n const cc = cif.chem_comp\n const cca = cif.chem_comp_atom\n const ccb = cif.chem_comp_bond\n\n if (cc) {\n if (cc.name) {\n structure.title = cc.name.trim().replace(reTrimQuotes, '')\n }\n if (cc.id) {\n structure.id = cc.id.trim().replace(reTrimQuotes, '')\n }\n }\n\n var atomnameDict: {[k: string]: number} = {}\n\n if (cca) {\n ensureArray(cca, 'comp_id')\n\n var atomname, element, resname, resno\n n = cca.comp_id.length\n\n for (i = 0; i < n; ++i) {\n atomStore.growIfFull()\n\n atomname = cca.atom_id[ i ].replace(reDoubleQuote, '')\n element = cca.type_symbol[ i ]\n\n atomnameDict[ atomname ] = i\n atomStore.atomTypeId[ i ] = atomMap.add(atomname, element)\n\n atomStore.x[ i ] = cca.model_Cartn_x[ i ]\n atomStore.y[ i ] = cca.model_Cartn_y[ i ]\n atomStore.z[ i ] = cca.model_Cartn_z[ i ]\n atomStore.serial[ i ] = i\n\n resname = cca.pdbx_component_comp_id[ i ]\n resno = cca.pdbx_residue_numbering ? cca.pdbx_residue_numbering[ i ] : 1\n\n structureBuilder.addAtom(0, '', '', resname, resno, true)\n }\n\n for (i = 0; i < n; ++i) {\n var j = i + n\n\n atomStore.growIfFull()\n\n atomname = cca.atom_id[ i ].replace(reDoubleQuote, '')\n element = cca.type_symbol[ i ]\n\n atomStore.atomTypeId[ j ] = atomMap.add(atomname, element)\n\n atomStore.x[ j ] = cca.pdbx_model_Cartn_x_ideal[ i ]\n atomStore.y[ j ] = cca.pdbx_model_Cartn_y_ideal[ i ]\n atomStore.z[ j ] = cca.pdbx_model_Cartn_z_ideal[ i ]\n atomStore.serial[ j ] = j\n\n resname = cca.pdbx_component_comp_id[ i ]\n resno = cca.pdbx_residue_numbering ? cca.pdbx_residue_numbering[ i ] : 1\n\n structureBuilder.addAtom(1, '', '', resname, resno, true)\n }\n }\n\n if (cca && ccb) {\n ensureArray(ccb, 'comp_id')\n\n var atomname1, atomname2, bondOrder\n n = ccb.comp_id.length\n var na = cca.comp_id.length\n\n var ap1 = structure.getAtomProxy()\n var ap2 = structure.getAtomProxy()\n\n for (i = 0; i < n; ++i) {\n atomname1 = ccb.atom_id_1[ i ].replace(reDoubleQuote, '')\n atomname2 = ccb.atom_id_2[ i ].replace(reDoubleQuote, '')\n bondOrder = getBondOrder(ccb.value_order[ i ])\n\n ap1.index = atomnameDict[ atomname1 ]\n ap2.index = atomnameDict[ atomname2 ]\n structure.bondStore.growIfFull()\n structure.bondStore.addBond(ap1, ap2, bondOrder)\n\n ap1.index += na\n ap2.index += na\n structure.bondStore.growIfFull()\n structure.bondStore.addBond(ap1, ap2, bondOrder)\n }\n }\n}\n\nfunction parseCore (cif: Cif, structure: Structure, structureBuilder: StructureBuilder) {\n var atomStore = structure.atomStore\n var atomMap = structure.atomMap\n\n if (cif.data) {\n structure.id = cif.data\n structure.name = cif.data\n }\n\n structure.unitcell = new Unitcell({\n a: parseFloat(cif.cell_length_a),\n b: parseFloat(cif.cell_length_b),\n c: parseFloat(cif.cell_length_c),\n alpha: parseFloat(cif.cell_angle_alpha),\n beta: parseFloat(cif.cell_angle_beta),\n gamma: parseFloat(cif.cell_angle_gamma),\n spacegroup: trimQuotes(cif['symmetry_space_group_name_H-M'])\n })\n\n const v = new Vector3()\n const c = new Vector3()\n const n = cif.atom_site_type_symbol.length\n\n const typeSymbolMap: Record = {}\n\n for (let i = 0; i < n; ++i) {\n atomStore.growIfFull()\n\n const atomname = cif.atom_site_label[ i ]\n const typeSymbol = cif.atom_site_type_symbol[ i ]\n\n // typeSymbol can be like `Al2.5+`. Retain element symbol only.\n let element = typeSymbolMap[typeSymbol]\n if (!element) {\n const match = typeSymbol.match(reAtomSymbol)\n typeSymbolMap[typeSymbol] = element = match?.[0] ?? typeSymbol\n }\n\n atomStore.atomTypeId[ i ] = atomMap.add(atomname, element)\n\n v.set(\n cif.atom_site_fract_x[ i ],\n cif.atom_site_fract_y[ i ],\n cif.atom_site_fract_z[ i ]\n )\n v.applyMatrix4(structure.unitcell.fracToCart)\n c.add(v)\n\n atomStore.x[ i ] = v.x\n atomStore.y[ i ] = v.y\n atomStore.z[ i ] = v.z\n if (cif.atom_site_occupancy) {\n atomStore.occupancy[ i ] = parseFloat(cif.atom_site_occupancy[ i ])\n }\n atomStore.serial[ i ] = i\n\n structureBuilder.addAtom(0, '', '', 'HET', 1, true)\n }\n\n c.divideScalar(n)\n structure.center = c\n buildUnitcellAssembly(structure)\n\n const v2 = new Vector3()\n const v3 = new Vector3()\n const ml = structure.biomolDict.SUPERCELL.partList[ 0 ].matrixList\n\n let k = n\n\n function covalent (idx: number) {\n return atomMap.get(atomStore.atomTypeId[ idx ]).covalent\n }\n const identityMatrix = new Matrix4()\n\n for (let i = 0; i < n; ++i) {\n const covalentI = covalent(i)\n\n v.set(\n atomStore.x[ i ],\n atomStore.y[ i ],\n atomStore.z[ i ]\n )\n\n ml.forEach(function (m) {\n if (identityMatrix.equals(m)) return\n\n v2.copy(v)\n v2.applyMatrix4(m)\n\n for (let j = 0; j < n; ++j) {\n v3.set(\n atomStore.x[ j ],\n atomStore.y[ j ],\n atomStore.z[ j ]\n )\n\n const distSquared = v2.distanceToSquared(v3)\n const d = covalent(j) + covalentI\n const d1 = d + 0.3\n const d2 = d - 0.5\n\n if (distSquared < (d1 * d1) && distSquared > (d2 * d2)) {\n atomStore.growIfFull()\n\n atomStore.atomTypeId[ k ] = atomStore.atomTypeId[ i ]\n atomStore.x[ k ] = v2.x\n atomStore.y[ k ] = v2.y\n atomStore.z[ k ] = v2.z\n atomStore.occupancy[ k ] = atomStore.occupancy[ i ]\n atomStore.serial[ k ] = k\n atomStore.altloc[ k ] = 'A'.charCodeAt(0)\n\n structureBuilder.addAtom(0, '', '', 'HET', 1, true)\n\n k += 1\n return\n }\n }\n })\n }\n}\n\nfunction processSecondaryStructure (cif: Cif, structure: Structure, asymIdDict: {[k: string]: string}) {\n var helices: [string, number, string, string, number, string, number][] = []\n var sheets: [string, number, string, string, number, string][] = []\n\n var i, il, begIcode, endIcode\n\n // get helices\n var sc = cif.struct_conf\n\n if (sc?.pdbx_PDB_helix_class) {\n ensureArray(sc, 'id')\n\n for (i = 0, il = sc.beg_auth_seq_id.length; i < il; ++i) {\n var helixType = parseInt(sc.pdbx_PDB_helix_class[ i ])\n if (!Number.isNaN(helixType)) {\n begIcode = sc.pdbx_beg_PDB_ins_code[ i ]\n endIcode = sc.pdbx_end_PDB_ins_code[ i ]\n helices.push([\n asymIdDict[ sc.beg_label_asym_id[ i ] ],\n parseInt(sc.beg_auth_seq_id[ i ]),\n cifDefaults(begIcode, ''),\n asymIdDict[ sc.end_label_asym_id[ i ] ],\n parseInt(sc.end_auth_seq_id[ i ]),\n cifDefaults(endIcode, ''),\n (HelixTypes[ helixType ] || HelixTypes[0]).charCodeAt(0)\n ])\n }\n }\n }\n\n // get sheets\n var ssr = cif.struct_sheet_range\n\n if (ssr) {\n ensureArray(ssr, 'id')\n\n for (i = 0, il = ssr.beg_auth_seq_id.length; i < il; ++i) {\n begIcode = ssr.pdbx_beg_PDB_ins_code[ i ]\n endIcode = ssr.pdbx_end_PDB_ins_code[ i ]\n sheets.push([\n asymIdDict[ ssr.beg_label_asym_id[ i ] ],\n parseInt(ssr.beg_auth_seq_id[ i ]),\n cifDefaults(begIcode, ''),\n asymIdDict[ ssr.end_label_asym_id[ i ] ],\n parseInt(ssr.end_auth_seq_id[ i ]),\n cifDefaults(endIcode, '')\n ])\n }\n }\n\n if (sc || ssr) {\n return {\n helices: helices,\n sheets: sheets\n }\n } else {\n return false\n }\n}\n\nfunction processSymmetry (cif: Cif, structure: Structure, asymIdDict: {[k: string]: string}) {\n // biomol & ncs processing\n var operDict: {[k: string]: Matrix4} = {}\n var biomolDict = structure.biomolDict\n\n if (cif.pdbx_struct_oper_list) {\n var biomolOp = cif.pdbx_struct_oper_list\n ensureArray(biomolOp, 'id')\n\n biomolOp.id.forEach(function (id: number, i: number) {\n var m = new Matrix4()\n var elms = m.elements\n\n elms[ 0 ] = parseFloat(biomolOp[ 'matrix[1][1]' ][ i ])\n elms[ 1 ] = parseFloat(biomolOp[ 'matrix[1][2]' ][ i ])\n elms[ 2 ] = parseFloat(biomolOp[ 'matrix[1][3]' ][ i ])\n\n elms[ 4 ] = parseFloat(biomolOp[ 'matrix[2][1]' ][ i ])\n elms[ 5 ] = parseFloat(biomolOp[ 'matrix[2][2]' ][ i ])\n elms[ 6 ] = parseFloat(biomolOp[ 'matrix[2][3]' ][ i ])\n\n elms[ 8 ] = parseFloat(biomolOp[ 'matrix[3][1]' ][ i ])\n elms[ 9 ] = parseFloat(biomolOp[ 'matrix[3][2]' ][ i ])\n elms[ 10 ] = parseFloat(biomolOp[ 'matrix[3][3]' ][ i ])\n\n elms[ 3 ] = parseFloat(biomolOp[ 'vector[1]' ][ i ])\n elms[ 7 ] = parseFloat(biomolOp[ 'vector[2]' ][ i ])\n elms[ 11 ] = parseFloat(biomolOp[ 'vector[3]' ][ i ])\n\n m.transpose()\n\n operDict[ id ] = m\n })\n }\n\n if (cif.pdbx_struct_assembly_gen) {\n var gen = cif.pdbx_struct_assembly_gen\n ensureArray(gen, 'assembly_id')\n\n var getMatrixDict = function (expr: string) {\n var matDict: {[k: string]: Matrix4} = {}\n\n var l = expr.replace(/[()']/g, '').split(',')\n\n l.forEach(function (e) {\n if (e.includes('-')) {\n var es = e.split('-')\n\n var j = parseInt(es[ 0 ])\n var m = parseInt(es[ 1 ])\n\n for (; j <= m; ++j) {\n matDict[ j ] = operDict[ j ]\n }\n } else {\n matDict[ e ] = operDict[ e ]\n }\n })\n\n return matDict\n }\n\n gen.assembly_id.forEach(function (id: string, i: number) {\n var md:{[k: string]: Matrix4} = {}\n var oe = gen.oper_expression[ i ].replace(/['\"]\\(|['\"]/g, '')\n\n if (oe.includes(')(') || oe.indexOf('(') > 0) {\n oe = oe.split('(')\n\n var md1 = getMatrixDict(oe[ 0 ])\n var md2 = getMatrixDict(oe[ 1 ])\n\n Object.keys(md1).forEach(function (k1) {\n Object.keys(md2).forEach(function (k2) {\n var mat = new Matrix4()\n\n mat.multiplyMatrices(md1[ k1 ], md2[ k2 ])\n md[ k1 + 'x' + k2 ] = mat\n })\n })\n } else {\n md = getMatrixDict(oe)\n }\n\n var matrixList = []\n for (var k in md) {\n matrixList.push(md[ k ])\n }\n\n var name = id\n if (/^(0|[1-9][0-9]*)$/.test(name)) name = 'BU' + name\n\n var chainList = gen.asym_id_list[ i ].split(',')\n for (var j = 0, jl = chainList.length; j < jl; ++j) {\n chainList[ j ] = asymIdDict[ chainList[ j ] ]\n }\n\n if (biomolDict[ name ] === undefined) {\n biomolDict[ name ] = new Assembly(name)\n }\n biomolDict[ name ].addPart(matrixList, chainList)\n })\n }\n\n // non-crystallographic symmetry operations\n if (cif.struct_ncs_oper) {\n var ncsOp = cif.struct_ncs_oper\n ensureArray(ncsOp, 'id')\n\n var ncsName = 'NCS'\n biomolDict[ ncsName ] = new Assembly(ncsName)\n var ncsPart = biomolDict[ ncsName ].addPart()\n\n ncsOp.id.forEach(function (id: string, i: number) {\n // ignore 'given' operators\n if (ncsOp.code[ i ] === 'given') return\n\n var m = new Matrix4()\n var elms = m.elements\n\n elms[ 0 ] = parseFloat(ncsOp[ 'matrix[1][1]' ][ i ])\n elms[ 1 ] = parseFloat(ncsOp[ 'matrix[1][2]' ][ i ])\n elms[ 2 ] = parseFloat(ncsOp[ 'matrix[1][3]' ][ i ])\n\n elms[ 4 ] = parseFloat(ncsOp[ 'matrix[2][1]' ][ i ])\n elms[ 5 ] = parseFloat(ncsOp[ 'matrix[2][2]' ][ i ])\n elms[ 6 ] = parseFloat(ncsOp[ 'matrix[2][3]' ][ i ])\n\n elms[ 8 ] = parseFloat(ncsOp[ 'matrix[3][1]' ][ i ])\n elms[ 9 ] = parseFloat(ncsOp[ 'matrix[3][2]' ][ i ])\n elms[ 10 ] = parseFloat(ncsOp[ 'matrix[3][3]' ][ i ])\n\n elms[ 3 ] = parseFloat(ncsOp[ 'vector[1]' ][ i ])\n elms[ 7 ] = parseFloat(ncsOp[ 'vector[2]' ][ i ])\n elms[ 11 ] = parseFloat(ncsOp[ 'vector[3]' ][ i ])\n\n m.transpose()\n\n ncsPart.matrixList.push(m)\n })\n\n if (ncsPart.matrixList.length === 0) {\n delete biomolDict[ ncsName ]\n }\n }\n\n // cell & symmetry\n const unitcellDict: {\n a?: number\n b?: number\n c?: number\n alpha?: number\n beta?: number\n gamma?: number\n spacegroup?: string\n origx?: Matrix4\n scale?: Matrix4\n } = {}\n\n if (cif.cell) {\n const cell = cif.cell\n\n const a = parseFloat(cell.length_a)\n const b = parseFloat(cell.length_b)\n const c = parseFloat(cell.length_c)\n\n const box = new Float32Array(9)\n box[ 0 ] = a\n box[ 4 ] = b\n box[ 8 ] = c\n structure.boxes.push(box)\n\n unitcellDict.a = a\n unitcellDict.b = b\n unitcellDict.c = c\n unitcellDict.alpha = parseFloat(cell.angle_alpha)\n unitcellDict.beta = parseFloat(cell.angle_beta)\n unitcellDict.gamma = parseFloat(cell.angle_gamma)\n }\n\n if (cif.symmetry) {\n unitcellDict.spacegroup = trimQuotes(\n cif.symmetry[ 'space_group_name_H-M' ]\n )\n }\n\n // origx\n var origx = new Matrix4()\n\n if (cif.database_PDB_matrix) {\n var origxMat = cif.database_PDB_matrix\n var origxElms = origx.elements\n\n origxElms[ 0 ] = parseFloat(origxMat[ 'origx[1][1]' ])\n origxElms[ 1 ] = parseFloat(origxMat[ 'origx[1][2]' ])\n origxElms[ 2 ] = parseFloat(origxMat[ 'origx[1][3]' ])\n\n origxElms[ 4 ] = parseFloat(origxMat[ 'origx[2][1]' ])\n origxElms[ 5 ] = parseFloat(origxMat[ 'origx[2][2]' ])\n origxElms[ 6 ] = parseFloat(origxMat[ 'origx[2][3]' ])\n\n origxElms[ 8 ] = parseFloat(origxMat[ 'origx[3][1]' ])\n origxElms[ 9 ] = parseFloat(origxMat[ 'origx[3][2]' ])\n origxElms[ 10 ] = parseFloat(origxMat[ 'origx[3][3]' ])\n\n origxElms[ 3 ] = parseFloat(origxMat[ 'origx_vector[1]' ])\n origxElms[ 7 ] = parseFloat(origxMat[ 'origx_vector[2]' ])\n origxElms[ 11 ] = parseFloat(origxMat[ 'origx_vector[3]' ])\n\n origx.transpose()\n\n unitcellDict.origx = origx\n }\n\n // scale\n var scale = new Matrix4()\n\n if (cif.atom_sites) {\n var scaleMat = cif.atom_sites\n var scaleElms = scale.elements\n\n scaleElms[ 0 ] = parseFloat(scaleMat[ 'fract_transf_matrix[1][1]' ])\n scaleElms[ 1 ] = parseFloat(scaleMat[ 'fract_transf_matrix[1][2]' ])\n scaleElms[ 2 ] = parseFloat(scaleMat[ 'fract_transf_matrix[1][3]' ])\n\n scaleElms[ 4 ] = parseFloat(scaleMat[ 'fract_transf_matrix[2][1]' ])\n scaleElms[ 5 ] = parseFloat(scaleMat[ 'fract_transf_matrix[2][2]' ])\n scaleElms[ 6 ] = parseFloat(scaleMat[ 'fract_transf_matrix[2][3]' ])\n\n scaleElms[ 8 ] = parseFloat(scaleMat[ 'fract_transf_matrix[3][1]' ])\n scaleElms[ 9 ] = parseFloat(scaleMat[ 'fract_transf_matrix[3][2]' ])\n scaleElms[ 10 ] = parseFloat(scaleMat[ 'fract_transf_matrix[3][3]' ])\n\n scaleElms[ 3 ] = parseFloat(scaleMat[ 'fract_transf_vector[1]' ])\n scaleElms[ 7 ] = parseFloat(scaleMat[ 'fract_transf_vector[2]' ])\n scaleElms[ 11 ] = parseFloat(scaleMat[ 'fract_transf_vector[3]' ])\n\n scale.transpose()\n\n unitcellDict.scale = scale\n }\n\n if (unitcellDict.a !== undefined) {\n structure.unitcell = new Unitcell(unitcellDict as UnitcellParams)\n } else {\n structure.unitcell = undefined\n }\n}\n\nfunction processConnections (cif: Cif, structure: Structure, asymIdDict: {[k: string]: string}) {\n // add connections\n var sc = cif.struct_conn\n\n if (sc) {\n ensureArray(sc, 'id')\n\n var reDoubleQuote = /\"/g\n var ap1 = structure.getAtomProxy()\n var ap2 = structure.getAtomProxy()\n var atomIndicesCache: {[k: string]: Uint32Array|undefined} = {}\n\n for (var i = 0, il = sc.id.length; i < il; ++i) {\n // ignore:\n // hydrog - hydrogen bond\n // mismat - mismatched base pairs\n // saltbr - ionic interaction\n\n var connTypeId = sc.conn_type_id[ i ]\n if (connTypeId === 'hydrog' ||\n connTypeId === 'mismat' ||\n connTypeId === 'saltbr') continue\n\n // ignore bonds between symmetry mates\n if (sc.ptnr1_symmetry[ i ] !== '1_555' ||\n sc.ptnr2_symmetry[ i ] !== '1_555') continue\n\n // process:\n // covale - covalent bond\n // covale_base -\n // covalent modification of a nucleotide base\n // covale_phosphate -\n // covalent modification of a nucleotide phosphate\n // covale_sugar -\n // covalent modification of a nucleotide sugar\n // disulf - disulfide bridge\n // metalc - metal coordination\n // modres - covalent residue modification\n\n var inscode1 = sc.pdbx_ptnr1_PDB_ins_code[ i ]\n var altloc1 = sc.pdbx_ptnr1_label_alt_id[ i ]\n var sele1 = (\n sc.ptnr1_auth_seq_id[ i ] +\n (hasValue(inscode1) ? ('^' + inscode1) : '') +\n ':' + asymIdDict[ sc.ptnr1_label_asym_id[ i ] ] +\n '.' + sc.ptnr1_label_atom_id[ i ].replace(reDoubleQuote, '') +\n (hasValue(altloc1) ? ('%' + altloc1) : '')\n )\n var atomIndices1 = atomIndicesCache[ sele1 ]\n if (!atomIndices1) {\n var selection1 = new Selection(sele1)\n if (selection1.selection.error) {\n if (Debug) Log.warn('invalid selection for connection', sele1)\n continue\n }\n atomIndices1 = structure.getAtomIndices(selection1)\n atomIndicesCache[ sele1 ] = atomIndices1\n }\n\n var inscode2 = sc.pdbx_ptnr2_PDB_ins_code[ i ]\n var altloc2 = sc.pdbx_ptnr2_label_alt_id[ i ]\n var sele2 = (\n sc.ptnr2_auth_seq_id[ i ] +\n (hasValue(inscode2) ? ('^' + inscode2) : '') +\n ':' + asymIdDict[ sc.ptnr2_label_asym_id[ i ] ] +\n '.' + sc.ptnr2_label_atom_id[ i ].replace(reDoubleQuote, '') +\n (hasValue(altloc2) ? ('%' + altloc2) : '')\n )\n var atomIndices2 = atomIndicesCache[ sele2 ]\n if (!atomIndices2) {\n var selection2 = new Selection(sele2)\n if (selection2.selection.error) {\n if (Debug) Log.warn('invalid selection for connection', sele2)\n continue\n }\n atomIndices2 = structure.getAtomIndices(selection2)\n atomIndicesCache[ sele2 ] = atomIndices2\n }\n\n // cases with more than one atom per selection\n // - #altloc1 to #altloc2\n // - #model to #model\n // - #altloc1 * #model to #altloc2 * #model\n\n var k = atomIndices1!.length\n var l = atomIndices2!.length\n\n if (k > l) {\n var tmpA = k\n k = l\n l = tmpA\n var tmpB = atomIndices1\n atomIndices1 = atomIndices2\n atomIndices2 = tmpB\n }\n\n // console.log( k, l );\n\n if (k === 0 || l === 0) {\n if (Debug) Log.warn('no atoms found for', sele1, sele2)\n continue\n }\n\n for (var j = 0; j < l; ++j) {\n ap1.index = atomIndices1![ j % k ]\n ap2.index = atomIndices2![ j ]\n\n if (ap1 && ap2) {\n structure.bondStore.addBond(\n ap1, ap2, getBondOrder(sc.pdbx_value_order[ i ])\n )\n } else {\n Log.log('atoms for connection not found')\n }\n }\n }\n }\n}\n\nfunction processEntities (cif: Cif, structure: Structure, chainIndexDict: {[k: string]: Set}) {\n if (cif.entity) {\n ensureArray(cif.entity, 'id')\n var e = cif.entity\n var n = e.id.length\n for (var i = 0; i < n; ++i) {\n var description = e.pdbx_description[ i ]\n var type = e.type[ i ]\n var chainIndexList: number[] = Array.from(chainIndexDict[ e.id[ i ] ])\n structure.entityList[ i ] = new Entity(\n structure, i, description, type, chainIndexList\n )\n }\n }\n}\n\n//\n\nclass CifParser extends StructureParser {\n get type () { return 'cif' }\n\n _parse () {\n // http://mmcif.wwpdb.org/\n\n Log.time('CifParser._parse ' + this.name)\n\n var s = this.structure\n var sb = this.structureBuilder\n\n var firstModelOnly = this.firstModelOnly\n var asTrajectory = this.asTrajectory\n var cAlphaOnly = this.cAlphaOnly\n\n var frames = s.frames\n var currentFrame: NumberArray, currentCoord: number\n\n var rawline, line\n\n //\n\n var cif: Cif = {}\n var asymIdDict: {[k: string]: string} = {}\n var chainIndexDict:{[k: string]: Set} = {}\n\n var pendingString = false\n var currentString: string|null = null\n var pendingValue = false\n var pendingLoop = false\n var pendingName = false\n var loopPointers: string[][] = []\n var currentLoopIndex: number|null = null\n var currentCategory: string|null = null\n var currentName: string|boolean|null = null\n var first: boolean|null = null\n var pointerNames: string[] = []\n\n var authAsymId: number, authSeqId: number, labelSeqId: number,\n labelAtomId: number, labelCompId: number, labelAsymId: number, labelEntityId: number, labelAltId: number,\n groupPDB: number, id: number, typeSymbol: number, pdbxPDBmodelNum: number, pdbxPDBinsCode: number,\n CartnX: number, CartnY: number, CartnZ: number, bIsoOrEquiv: number, occupancy: number\n\n //\n\n var atomMap = s.atomMap\n var atomStore = s.atomStore\n atomStore.resize(this.streamer.data.length / 100)\n\n var idx = 0\n var modelIdx = 0\n var modelNum: number\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (var i = _i; i < _n; ++i) {\n rawline = lines[i]\n line = rawline.trim()\n\n if ((!line && !pendingString && !pendingLoop) || line[0] === '#') {\n // Log.log( \"NEW BLOCK\" );\n\n pendingString = false\n pendingLoop = false\n pendingValue = false\n loopPointers.length = 0\n currentLoopIndex = null\n currentCategory = null\n currentName = null\n first = null\n pointerNames.length = 0\n } else if (line.substring(0, 5) === 'data_') {\n cif.data = line.substring(5).trim()\n\n // Log.log( \"DATA\", data );\n } else if (line[0] === ';') {\n if (pendingString) {\n // Log.log( \"STRING END\", currentString );\n\n if (pendingLoop) {\n if (currentLoopIndex === loopPointers.length) {\n currentLoopIndex = 0\n }\n loopPointers[ currentLoopIndex as number ].push(currentString as string);\n (currentLoopIndex as number) += 1\n } else {\n if (currentName === false) {\n cif[ currentCategory as string ] = currentString\n } else {\n cif[ currentCategory as string ][ currentName as string ] = currentString //TODO currentname can equals null\n }\n }\n\n pendingString = false\n currentString = null\n } else {\n // Log.log( \"STRING START\" );\n\n pendingString = true\n currentString = line.substring(1)\n }\n } else if (line === 'loop_') {\n // Log.log( \"LOOP START\" );\n\n pendingLoop = true\n pendingName = true\n loopPointers.length = 0\n pointerNames.length = 0\n currentLoopIndex = 0\n } else if (line[0] === '_') {\n var keyParts, category, name\n\n if (pendingLoop && !pendingName) {\n pendingLoop = false\n }\n\n if (pendingLoop) {\n // Log.log( \"LOOP KEY\", line );\n\n keyParts = line.split('.')\n category = keyParts[ 0 ].substring(1)\n name = keyParts[ 1 ]\n\n if (keyParts.length === 1) {\n name = false\n if (!cif[ category ]) cif[ category ] = []\n loopPointers.push(cif[ category ])\n } else {\n if (!cif[ category ]) cif[ category ] = {}\n if (cif[ category ][ name ]) {\n if (Debug) Log.warn(category, name, 'already exists')\n } else {\n cif[ category ][ name ] = []\n loopPointers.push(cif[ category ][ name ])\n pointerNames.push(name)\n }\n }\n\n currentCategory = category\n currentName = name\n first = true\n } else {\n var keyValuePair = line.match(reQuotedWhitespace)\n var key = keyValuePair![ 0 ]\n var value = keyValuePair![ 1 ]\n keyParts = key.split('.')\n category = keyParts[ 0 ].substring(1)\n name = keyParts[ 1 ]\n\n if (keyParts.length === 1) {\n name = false\n cif[ category ] = value\n } else {\n if (!cif[ category ]) cif[ category ] = {}\n\n if (cif[ category ][ name ]) {\n if (Debug) Log.warn(category, name, 'already exists')\n } else {\n cif[ category ][ name ] = value\n }\n }\n\n if (!value) pendingValue = true\n\n currentCategory = category\n currentName = name\n }\n } else {\n if (pendingString) {\n // Log.log( \"STRING VALUE\", line );\n\n currentString += rawline\n } else if (pendingLoop) {\n // Log.log( \"LOOP VALUE\", line );\n\n if (!line) {\n continue\n } else if (currentCategory === 'atom_site') {\n const ls = line.split(reWhitespace)\n\n if (first) {\n authAsymId = pointerNames.indexOf('auth_asym_id')\n authSeqId = pointerNames.indexOf('auth_seq_id')\n labelSeqId = pointerNames.indexOf('label_seq_id')\n labelAtomId = pointerNames.indexOf('label_atom_id')\n labelCompId = pointerNames.indexOf('label_comp_id')\n labelAsymId = pointerNames.indexOf('label_asym_id')\n labelEntityId = pointerNames.indexOf('label_entity_id')\n labelAltId = pointerNames.indexOf('label_alt_id')\n CartnX = pointerNames.indexOf('Cartn_x')\n CartnY = pointerNames.indexOf('Cartn_y')\n CartnZ = pointerNames.indexOf('Cartn_z')\n id = pointerNames.indexOf('id')\n typeSymbol = pointerNames.indexOf('type_symbol')\n groupPDB = pointerNames.indexOf('group_PDB')\n bIsoOrEquiv = pointerNames.indexOf('B_iso_or_equiv')\n pdbxPDBmodelNum = pointerNames.indexOf('pdbx_PDB_model_num')\n\n pdbxPDBinsCode = pointerNames.indexOf('pdbx_PDB_ins_code')\n occupancy = pointerNames.indexOf('occupancy')\n\n first = false\n\n modelNum = parseInt(ls[ pdbxPDBmodelNum ])\n\n if (asTrajectory) {\n currentFrame = []\n currentCoord = 0\n }\n }\n\n //\n\n const _modelNum = parseInt(ls[ pdbxPDBmodelNum ])\n\n if (modelNum !== _modelNum) {\n if (asTrajectory) {\n if (modelIdx === 0) {\n frames.push(new Float32Array(currentFrame))\n }\n\n currentFrame = new Float32Array(atomStore.count * 3)\n frames.push(currentFrame)\n currentCoord = 0\n }\n\n modelIdx += 1\n }\n\n modelNum = _modelNum\n\n if (firstModelOnly && modelIdx > 0) continue\n\n //\n\n const atomname = ls[ labelAtomId ].replace(reDoubleQuote, '')\n if (cAlphaOnly && atomname !== 'CA') continue\n\n const x = parseFloat(ls[ CartnX ])\n const y = parseFloat(ls[ CartnY ])\n const z = parseFloat(ls[ CartnZ ])\n\n if (asTrajectory) {\n const frameOffset = currentCoord * 3\n\n currentFrame[ frameOffset + 0 ] = x\n currentFrame[ frameOffset + 1 ] = y\n currentFrame[ frameOffset + 2 ] = z\n\n currentCoord += 1\n\n if (modelIdx > 0) continue\n }\n\n //\n\n const resname = ls[ labelCompId ]\n const resno = parseInt(ls[ authSeqId !== -1 ? authSeqId : labelSeqId ])\n let inscode = ls[ pdbxPDBinsCode ]\n inscode = (inscode === '?') ? '' : inscode\n const chainname = ls[ authAsymId ]\n const chainid = ls[ labelAsymId ]\n const hetero = (ls[ groupPDB ][ 0 ] === 'H')\n\n //\n\n const element = ls[ typeSymbol ]\n const bfactor = parseFloat(ls[ bIsoOrEquiv ])\n const occ = parseFloat(ls[ occupancy ])\n let altloc = ls[ labelAltId ]\n altloc = (altloc === '.') ? '' : altloc\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname, element)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = parseInt(ls[ id ])\n atomStore.bfactor[ idx ] = isNaN(bfactor) ? 0 : bfactor\n atomStore.occupancy[ idx ] = isNaN(occ) ? 0 : occ\n atomStore.altloc[ idx ] = altloc.charCodeAt(0)\n\n sb.addAtom(modelIdx, chainname, chainid, resname, resno, hetero, undefined, inscode)\n\n if (Debug) {\n // check if one-to-many (chainname-asymId) relationship is\n // actually a many-to-many mapping\n const assignedChainname = asymIdDict[ chainid ]\n if (assignedChainname !== undefined && assignedChainname !== chainname) {\n if (Debug) Log.warn(assignedChainname, chainname)\n }\n }\n // chainname mapping: label_asym_id -> auth_asym_id\n asymIdDict[ chainid ] = chainname\n\n // entity mapping: chainIndex -> label_entity_id\n const entityId = ls[ labelEntityId ]\n if (!chainIndexDict[ entityId ]) {\n chainIndexDict[ entityId ] = new Set()\n }\n chainIndexDict[ entityId ].add(s.chainStore.count - 1)\n\n idx += 1\n } else {\n const ls = line.match(reQuotedWhitespace)\n const nn = ls!.length\n\n if (currentLoopIndex === loopPointers.length) {\n currentLoopIndex = 0\n }/* else if( currentLoopIndex + nn > loopPointers.length ){\n Log.warn( \"cif parsing error, wrong number of loop data entries\", nn, loopPointers.length );\n } */\n\n for (let j = 0; j < nn; ++j) {\n loopPointers[ currentLoopIndex + j ].push(ls![ j ])\n }\n\n (currentLoopIndex) += nn\n }\n\n pendingName = false\n } else if (line[0] === \"'\" && line[line.length - 1] === \"'\") {\n // Log.log( \"NEWLINE STRING\", line );\n\n const str = line.substring(1, line.length - 1)\n\n if (currentName === false) {\n cif[ currentCategory as string ] = str\n } else {\n cif[ currentCategory as string ][ currentName as string ] = str\n }\n } else if (pendingValue) {\n // Log.log( \"NEWLINE VALUE\", line );\n\n if (currentName === false) {\n cif[ currentCategory as string ] = line\n } else {\n cif[ currentCategory as string ][ currentName as string ] = line\n }\n } else {\n if (Debug) Log.log('CifParser._parse: unknown state', line)\n }\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n if (cif.chem_comp && cif.chem_comp_atom && !cif.struct) {\n parseChemComp(cif, s, sb)\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n assignResidueTypeBonds(s)\n } else if (cif.atom_site_type_symbol && cif.atom_site_label && cif.atom_site_fract_x) {\n parseCore(cif, s, sb)\n sb.finalize()\n s.finalizeAtoms()\n calculateBonds(s)\n s.finalizeBonds()\n // assignResidueTypeBonds( s );\n } else {\n var secStruct = processSecondaryStructure(cif, s, asymIdDict)\n processSymmetry(cif, s, asymIdDict)\n processConnections(cif, s, asymIdDict)\n processEntities(cif, s, chainIndexDict)\n\n if (cif.struct && cif.struct.title) {\n s.title = cif.struct.title.trim().replace(reTrimQuotes, '')\n }\n if (cif.entry && cif.entry.id) {\n s.id = cif.entry.id.trim().replace(reTrimQuotes, '')\n }\n\n // structure header (mimicking biojava)\n if (cif.pdbx_audit_revision_history) {\n if (cif.pdbx_audit_revision_history.revision_date) {\n ensureArray(cif.pdbx_audit_revision_history, 'revision_date')\n const dates = cif.pdbx_audit_revision_history.revision_date.filter(hasValue)\n if (dates.length) {\n s.header.releaseDate = dates[ 0 ]\n }\n }\n if (cif.pdbx_database_status.recvd_initial_deposition_date) {\n ensureArray(cif.pdbx_database_status, 'recvd_initial_deposition_date')\n const depDates = cif.pdbx_database_status.recvd_initial_deposition_date.filter(hasValue)\n if (depDates.length) {\n s.header.depositionDate = depDates[ 0 ]\n }\n }\n } else if (cif.database_PDB_rev) {\n if (cif.database_PDB_rev.date) {\n ensureArray(cif.database_PDB_rev, 'date')\n const dates = cif.database_PDB_rev.date.filter(hasValue)\n if (dates.length) {\n s.header.releaseDate = dates[ 0 ]\n }\n }\n if (cif.database_PDB_rev.date_original) {\n ensureArray(cif.database_PDB_rev, 'date_original')\n const depDates = cif.database_PDB_rev.date_original.filter(hasValue)\n if (depDates.length) {\n s.header.depositionDate = depDates[ 0 ]\n }\n }\n }\n if (cif.reflns && cif.reflns.d_resolution_high) {\n if (hasValue(cif.reflns.d_resolution_high)) {\n s.header.resolution = parseFloat(cif.reflns.d_resolution_high)\n }\n } else if (cif.refine && cif.refine.ls_d_res_high) {\n if (hasValue(cif.refine.ls_d_res_high)) {\n s.header.resolution = parseFloat(cif.refine.ls_d_res_high)\n }\n }\n if (cif.refine && cif.refine.ls_R_factor_R_free) {\n if (hasValue(cif.refine.ls_R_factor_R_free)) {\n s.header.rFree = parseFloat(cif.refine.ls_R_factor_R_free)\n }\n }\n if (cif.refine && cif.refine.ls_R_factor_R_work) {\n if (hasValue(cif.refine.ls_R_factor_R_work)) {\n s.header.rWork = parseFloat(cif.refine.ls_R_factor_R_work)\n }\n }\n if (cif.exptl && cif.exptl.method) {\n ensureArray(cif.exptl, 'method')\n s.header.experimentalMethods = cif.exptl.method.map(function (m: string) {\n return m.replace(reTrimQuotes, '')\n })\n }\n\n sb.finalize()\n s.finalizeAtoms()\n calculateBonds(s)\n s.finalizeBonds()\n\n if (!secStruct) {\n calculateSecondaryStructure(s)\n } else {\n assignSecondaryStructure(s, secStruct)\n }\n buildUnitcellAssembly(s)\n\n s.extraData.cif = cif\n }\n\n if (Debug) Log.timeEnd('CifParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('cif', CifParser)\nParserRegistry.add('mcif', CifParser)\nParserRegistry.add('mmcif', CifParser)\n\nexport default CifParser\n","/**\n * @file Gro Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport {\n calculateBonds, calculateChainnames, calculateSecondaryStructure\n} from '../structure/structure-utils'\n\nclass GroParser extends StructureParser {\n get type () { return 'gro' }\n\n _parse () {\n // http://manual.gromacs.org/current/online/gro.html\n\n if (Debug) Log.time('GroParser._parse ' + this.name)\n\n var s = this.structure\n var sb = this.structureBuilder\n\n var firstModelOnly = this.firstModelOnly\n var asTrajectory = this.asTrajectory\n var cAlphaOnly = this.cAlphaOnly\n\n var frames = s.frames\n var boxes = s.boxes\n var currentFrame: Float32Array, currentCoord: number\n\n var firstLines = this.streamer.peekLines(3)\n\n s.title = firstLines[ 0 ].trim()\n\n // determine number of decimal places\n var ndec = firstLines[ 2 ].length - firstLines[ 2 ].lastIndexOf('.') - 1\n var lpos = 5 + ndec\n var xpos = 20\n var ypos = 20 + lpos\n var zpos = 20 + 2 * lpos\n\n //\n\n var atomname, resname, resno, serial\n\n var atomCount = parseInt(firstLines[ 1 ])\n var modelLineCount = atomCount + 3\n\n var atomMap = s.atomMap\n var atomStore = s.atomStore\n atomStore.resize(atomCount)\n\n var idx = 0\n var modelIdx = 0\n var lineNo = 0\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (var i = _i; i < _n; ++i) {\n ++lineNo\n var l = lineNo - 1\n\n var line = lines[ i ]\n\n if (!line) continue\n\n if (l % modelLineCount === 0) {\n // Log.log( \"title\", line )\n\n if (asTrajectory) {\n currentFrame = new Float32Array(atomCount * 3)\n frames.push(currentFrame)\n currentCoord = 0\n }\n } else if (l % modelLineCount === 1) {\n\n // Log.log( \"atomCount\", line )\n\n } else if (l % modelLineCount === modelLineCount - 1) {\n var str = line.trim().split(/\\s+/)\n var box = new Float32Array(9)\n box[ 0 ] = parseFloat(str[ 0 ]) * 10\n box[ 4 ] = parseFloat(str[ 1 ]) * 10\n box[ 8 ] = parseFloat(str[ 2 ]) * 10\n boxes.push(box)\n\n if (firstModelOnly) {\n return true\n }\n\n modelIdx += 1\n } else {\n atomname = line.substr(10, 5).trim()\n if (cAlphaOnly && atomname !== 'CA') continue\n\n var x = parseFloat(line.substr(xpos, lpos)) * 10\n var y = parseFloat(line.substr(ypos, lpos)) * 10\n var z = parseFloat(line.substr(zpos, lpos)) * 10\n\n if (asTrajectory) {\n var j = currentCoord * 3\n\n currentFrame[ j + 0 ] = x\n currentFrame[ j + 1 ] = y\n currentFrame[ j + 2 ] = z\n\n currentCoord += 1\n\n if (l > modelLineCount) continue\n }\n\n resname = line.substr(5, 5).trim()\n resno = parseInt(line.substr(0, 5))\n serial = parseInt(line.substr(15, 5))\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = serial\n\n sb.addAtom(modelIdx, '', '', resname, resno, false, 'l')\n\n idx += 1\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n sb.finalize()\n s.finalizeAtoms()\n calculateChainnames(s)\n calculateBonds(s)\n s.finalizeBonds()\n\n calculateSecondaryStructure(s)\n\n if (Debug) Log.timeEnd('GroParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('gro', GroParser)\n\nexport default GroParser\n","/**\n * @file utf8-utils\n * @private\n * @author Alexander Rose \n * mostly copied from https://github.com/creationix/msgpack-js-browser\n * by Tim Caswell , MIT License, Copyright (c) 2013\n */\n\n\n// Encode string as utf8 into dataview at offset\nfunction utf8Write(view, offset, string) {\n var byteLength = view.byteLength;\n for(var i = 0, l = string.length; i < l; i++) {\n var codePoint = string.charCodeAt(i);\n\n // One byte of UTF-8\n if (codePoint < 0x80) {\n view.setUint8(offset++, codePoint >>> 0 & 0x7f | 0x00);\n continue;\n }\n\n // Two bytes of UTF-8\n if (codePoint < 0x800) {\n view.setUint8(offset++, codePoint >>> 6 & 0x1f | 0xc0);\n view.setUint8(offset++, codePoint >>> 0 & 0x3f | 0x80);\n continue;\n }\n\n // Three bytes of UTF-8.\n if (codePoint < 0x10000) {\n view.setUint8(offset++, codePoint >>> 12 & 0x0f | 0xe0);\n view.setUint8(offset++, codePoint >>> 6 & 0x3f | 0x80);\n view.setUint8(offset++, codePoint >>> 0 & 0x3f | 0x80);\n continue;\n }\n\n // Four bytes of UTF-8\n if (codePoint < 0x110000) {\n view.setUint8(offset++, codePoint >>> 18 & 0x07 | 0xf0);\n view.setUint8(offset++, codePoint >>> 12 & 0x3f | 0x80);\n view.setUint8(offset++, codePoint >>> 6 & 0x3f | 0x80);\n view.setUint8(offset++, codePoint >>> 0 & 0x3f | 0x80);\n continue;\n }\n throw new Error(\"bad codepoint \" + codePoint);\n }\n}\n\nfunction utf8ByteCount(string) {\n var count = 0;\n for(var i = 0, l = string.length; i < l; i++) {\n var codePoint = string.charCodeAt(i);\n if (codePoint < 0x80) {\n count += 1;\n continue;\n }\n if (codePoint < 0x800) {\n count += 2;\n continue;\n }\n if (codePoint < 0x10000) {\n count += 3;\n continue;\n }\n if (codePoint < 0x110000) {\n count += 4;\n continue;\n }\n throw new Error(\"bad codepoint \" + codePoint);\n }\n return count;\n}\n\n/**\n * encode data value (recursively) into binary encoded MessagePack v5 (http://msgpack.org/)\n * @param {Object|Array|String|Number|Boolean|null} value [description]\n * @param {DataView} view [description]\n * @param {Integer} offset [description]\n * @return {Integer} number of bytes written into view\n */\nfunction encode$1(value, view, offset) {\n var type = typeof value;\n\n // Strings Bytes\n if (type === \"string\") {\n var length = utf8ByteCount(value);\n // fix str\n if (length < 0x20) {\n view.setUint8(offset, length | 0xa0);\n utf8Write(view, offset + 1, value);\n return 1 + length;\n }\n // str 8\n if (length < 0x100) {\n view.setUint8(offset, 0xd9);\n view.setUint8(offset + 1, length);\n utf8Write(view, offset + 2, value);\n return 2 + length;\n }\n // str 16\n if (length < 0x10000) {\n view.setUint8(offset, 0xda);\n view.setUint16(offset + 1, length);\n utf8Write(view, offset + 3, value);\n return 3 + length;\n }\n // str 32\n if (length < 0x100000000) {\n view.setUint8(offset, 0xdb);\n view.setUint32(offset + 1, length);\n utf8Write(view, offset + 5, value);\n return 5 + length;\n }\n }\n\n if (value instanceof Uint8Array) {\n var length = value.byteLength;\n var bytes = new Uint8Array(view.buffer);\n // bin 8\n if (length < 0x100) {\n view.setUint8(offset, 0xc4);\n view.setUint8(offset + 1, length);\n bytes.set(value, offset + 2);\n return 2 + length;\n }\n // bin 16\n if (length < 0x10000) {\n view.setUint8(offset, 0xc5);\n view.setUint16(offset + 1, length);\n bytes.set(value, offset + 3);\n return 3 + length;\n }\n // bin 32\n if (length < 0x100000000) {\n view.setUint8(offset, 0xc6);\n view.setUint32(offset + 1, length);\n bytes.set(value, offset + 5);\n return 5 + length;\n }\n }\n\n if (type === \"number\") {\n if (!isFinite(value)) {\n throw new Error(\"Number not finite: \" + value);\n }\n\n // Floating point\n if (Math.floor(value) !== value) {\n view.setUint8(offset, 0xcb);\n view.setFloat64(offset + 1, value);\n return 9;\n }\n\n // Integers\n if (value >=0) {\n // positive fixnum\n if (value < 0x80) {\n view.setUint8(offset, value);\n return 1;\n }\n // uint 8\n if (value < 0x100) {\n view.setUint8(offset, 0xcc);\n view.setUint8(offset + 1, value);\n return 2;\n }\n // uint 16\n if (value < 0x10000) {\n view.setUint8(offset, 0xcd);\n view.setUint16(offset + 1, value);\n return 3;\n }\n // uint 32\n if (value < 0x100000000) {\n view.setUint8(offset, 0xce);\n view.setUint32(offset + 1, value);\n return 5;\n }\n throw new Error(\"Number too big 0x\" + value.toString(16));\n }\n // negative fixnum\n if (value >= -0x20) {\n view.setInt8(offset, value);\n return 1;\n }\n // int 8\n if (value >= -0x80) {\n view.setUint8(offset, 0xd0);\n view.setInt8(offset + 1, value);\n return 2;\n }\n // int 16\n if (value >= -0x8000) {\n view.setUint8(offset, 0xd1);\n view.setInt16(offset + 1, value);\n return 3;\n }\n // int 32\n if (value >= -0x80000000) {\n view.setUint8(offset, 0xd2);\n view.setInt32(offset + 1, value);\n return 5;\n }\n throw new Error(\"Number too small -0x\" + (-value).toString(16).substr(1));\n }\n\n // null\n if (value === null) {\n view.setUint8(offset, 0xc0);\n return 1;\n }\n\n // Boolean\n if (type === \"boolean\") {\n view.setUint8(offset, value ? 0xc3 : 0xc2);\n return 1;\n }\n\n // Container Types\n if (type === \"object\") {\n var length, size = 0;\n var isArray = Array.isArray(value);\n\n if (isArray) {\n length = value.length;\n }\n else {\n var keys = Object.keys(value);\n length = keys.length;\n }\n\n var size;\n if (length < 0x10) {\n view.setUint8(offset, length | (isArray ? 0x90 : 0x80));\n size = 1;\n }\n else if (length < 0x10000) {\n view.setUint8(offset, isArray ? 0xdc : 0xde);\n view.setUint16(offset + 1, length);\n size = 3;\n }\n else if (length < 0x100000000) {\n view.setUint8(offset, isArray ? 0xdd : 0xdf);\n view.setUint32(offset + 1, length);\n size = 5;\n }\n\n if (isArray) {\n for (var i = 0; i < length; i++) {\n size += encode$1(value[i], view, offset + size);\n }\n }\n else {\n for (var i = 0; i < length; i++) {\n var key = keys[i];\n size += encode$1(key, view, offset + size);\n size += encode$1(value[key], view, offset + size);\n }\n }\n\n return size;\n }\n throw new Error(\"Unknown type \" + type);\n}\n\nfunction encodedSize(value) {\n var type = typeof value;\n\n // Raw Bytes\n if (type === \"string\") {\n var length = utf8ByteCount(value);\n if (length < 0x20) {\n return 1 + length;\n }\n if (length < 0x100) {\n return 2 + length;\n }\n if (length < 0x10000) {\n return 3 + length;\n }\n if (length < 0x100000000) {\n return 5 + length;\n }\n }\n\n if (value instanceof Uint8Array) {\n var length = value.byteLength;\n if (length < 0x100) {\n return 2 + length;\n }\n if (length < 0x10000) {\n return 3 + length;\n }\n if (length < 0x100000000) {\n return 5 + length;\n }\n }\n\n if (type === \"number\") {\n // Floating Point\n // double\n if (Math.floor(value) !== value) return 9;\n\n // Integers\n if (value >=0) {\n // positive fixnum\n if (value < 0x80) return 1;\n // uint 8\n if (value < 0x100) return 2;\n // uint 16\n if (value < 0x10000) return 3;\n // uint 32\n if (value < 0x100000000) return 5;\n throw new Error(\"Number too big 0x\" + value.toString(16));\n }\n // negative fixnum\n if (value >= -0x20) return 1;\n // int 8\n if (value >= -0x80) return 2;\n // int 16\n if (value >= -0x8000) return 3;\n // int 32\n if (value >= -0x80000000) return 5;\n throw new Error(\"Number too small -0x\" + value.toString(16).substr(1));\n }\n\n // Boolean, null\n if (type === \"boolean\" || value === null) return 1;\n\n // Container Types\n if (type === \"object\") {\n var length, size = 0;\n if (Array.isArray(value)) {\n length = value.length;\n for (var i = 0; i < length; i++) {\n size += encodedSize(value[i]);\n }\n }\n else {\n var keys = Object.keys(value);\n length = keys.length;\n for (var i = 0; i < length; i++) {\n var key = keys[i];\n size += encodedSize(key) + encodedSize(value[key]);\n }\n }\n if (length < 0x10) {\n return 1 + size;\n }\n if (length < 0x10000) {\n return 3 + size;\n }\n if (length < 0x100000000) {\n return 5 + size;\n }\n throw new Error(\"Array or object too long 0x\" + length.toString(16));\n }\n throw new Error(\"Unknown type \" + type);\n}\n\nfunction encodeMsgpack(value) {\n var buffer = new ArrayBuffer(encodedSize(value));\n var view = new DataView(buffer);\n encode$1(value, view, 0);\n return new Uint8Array(buffer);\n}\n\n/**\n * @file mmtf-constants\n * @private\n * @author Alexander Rose \n */\n\n\nvar PassThroughFields = [\n \"mmtfVersion\", \"mmtfProducer\",\n \"unitCell\", \"spaceGroup\", \"structureId\", \"title\",\n \"depositionDate\", \"releaseDate\",\n \"experimentalMethods\", \"resolution\", \"rFree\", \"rWork\",\n \"bioAssemblyList\", \"ncsOperatorList\", \"entityList\", \"groupList\",\n \"numBonds\", \"numAtoms\", \"numGroups\", \"numChains\", \"numModels\",\n \"groupsPerChain\", \"chainsPerModel\",\n];\n\nvar EncodedFields = [\n\t// required\n \"xCoordList\", \"yCoordList\", \"zCoordList\",\n \"groupIdList\", \"groupTypeList\",\n \"chainIdList\",\n // optional\n \"bFactorList\", \"atomIdList\", \"altLocList\", \"occupancyList\",\n \"secStructList\", \"insCodeList\", \"sequenceIndexList\",\n \"chainNameList\",\n \"bondAtomList\", \"bondOrderList\"\n];\n\nvar AllFields = PassThroughFields.concat( EncodedFields );\n\n/**\n * @file mmtf-utils\n * @private\n * @author Alexander Rose \n */\n\n/**\n * mmtf utils module.\n * @module MmtfUtils\n */\n\n\nfunction getView( ctor, typedArray, elemSize ){\n return typedArray ? new ctor(\n typedArray.buffer,\n typedArray.byteOffset,\n typedArray.byteLength / ( elemSize || 1 )\n ) : undefined;\n}\n\nfunction getDataView( typedArray ){\n return getView( DataView, typedArray );\n}\n\n/**\n * get an Uint8Array view on the input array memory\n * @static\n * @param {TypedArray} dataArray - input array\n * @return {Uint8Array} new view on the input array memory\n */\nfunction getUint8View( typedArray ){\n return getView( Uint8Array, typedArray );\n}\n\n/**\n * get an Int8Array view on the input array memory\n * @static\n * @param {TypedArray} dataArray - input array\n * @return {Int8Array} new view on the input array memory\n */\nfunction getInt8View( typedArray ){\n return getView( Int8Array, typedArray );\n}\n\n/**\n * get an Int32Array view on the input array memory\n * @static\n * @param {TypedArray} dataArray - input array\n * @return {Int32Array} new view on the input array memory\n */\nfunction getInt32View( typedArray ){\n return getView( Int32Array, typedArray, 4 );\n}\n\nfunction getFloat32View( typedArray ){\n return getView( Float32Array, typedArray, 4 );\n}\n\n\n/**\n * get an Int16Array copy of the the input array data\n * @static\n * @param {TypedArray} view - input data in big endian format\n * @param {Int16Array} [dataArray] - pre-allocated output array\n * @return {Int16Array} copy of the input array data\n */\nfunction decodeInt16( bytes, output ){\n var n = bytes.length / 2;\n if( !output ) output = new Int16Array( n );\n for( var i = 0, i2 = 0; i < n; ++i, i2 += 2 ){\n output[ i ] = bytes[ i2 ] << 8 ^ bytes[ i2 + 1 ] << 0;\n }\n return output;\n}\n\n/**\n * make big endian buffer of an int16 array\n * @static\n * @param {Array|TypedArray} array - array of int16 values\n * @return {ArrayBuffer} big endian buffer\n */\nfunction encodeInt16( array, output ){\n var n = array.length;\n if( !output ) output = new Uint8Array( 2 * n );\n var dv = getDataView( output );\n for( var i = 0; i < n; ++i ){\n dv.setInt16( 2 * i, array[ i ] );\n }\n return getUint8View( output );\n}\n\n/**\n * get an Int32Array copy of the the input array data\n * @static\n * @param {TypedArray} view - input data in big endian format\n * @param {Int32Array} [dataArray] - pre-allocated output array\n * @return {Int32Array} copy of the input array data\n */\nfunction decodeInt32( bytes, output ){\n var n = bytes.length / 4;\n if( !output ) output = new Int32Array( n );\n for( var i = 0, i4 = 0; i < n; ++i, i4 += 4 ){\n output[ i ] = (\n bytes[ i4 ] << 24 ^ bytes[ i4 + 1 ] << 16 ^\n bytes[ i4 + 2 ] << 8 ^ bytes[ i4 + 3 ] << 0\n );\n }\n return output;\n}\n\n/**\n * make big endian buffer of an int32 array\n * @static\n * @param {Array|TypedArray} array - array of int32 values\n * @return {ArrayBuffer} big endian buffer\n */\nfunction encodeInt32( array, output ){\n var n = array.length;\n if( !output ) output = new Uint8Array( 4 * n );\n var dv = getDataView( output );\n for( var i = 0; i < n; ++i ){\n dv.setInt32( 4 * i, array[ i ] );\n }\n return getUint8View( output );\n}\n\nfunction decodeFloat32( bytes, output ){\n var n = bytes.length;\n if( !output ) output = new Float32Array( n / 4 );\n var dvOut = getDataView( output );\n var dvIn = getDataView( bytes );\n for( var i = 0, i4 = 0, il = n / 4; i < il; ++i, i4 += 4 ){\n dvOut.setFloat32( i4, dvIn.getFloat32( i4 ), true );\n }\n return output;\n}\n\n/**\n * decode integers into floats using given divisor\n * example:\n * intArray: [ 12, 34, 543, 687, 2, 0, 4689 ]\n * divisor: 100\n * return: [ 0.12, 0.34, 5.43, 6.87, 0.02, 0.00, 46.89 ]\n * @static\n * @param {TypedArray|Array} intArray - input array containing integers\n * @param {Number} divisor - number to devide the integers to obtain floats\n * @param {Float32Array} [dataArray] - pre-allocated output array\n * @return {Float32Array} decoded array\n */\nfunction decodeInteger( intArray, divisor, output ){\n var n = intArray.length;\n var invDiv = 1/divisor;\n if( !output ) output = new Float32Array( n );\n for( var i = 0; i < n; ++i ){\n // multiply by inverse of the divisor which is faster then division\n output[ i ] = intArray[ i ] * invDiv;\n }\n return output;\n}\n\nfunction encodeInteger( floatArray, factor, output ){\n var n = floatArray.length;\n if( !output ) output = new Int32Array( n );\n for( var i = 0; i < n; ++i ){\n output[ i ] = Math.round( floatArray[ i ] * factor );\n }\n return output;\n}\n\n\n\n/**\n * perform run-length decoding of input array\n * example:\n * array: [ 0, 2, 3, 5 ] // pairs of values and length of a run\n * return: [ 0, 0, 3, 3, 3, 3, 3 ]\n * @static\n * @param {TypedArray|Array} array - run-length encoded input array\n * @param {TypedArray|Array} [dataArray] - pre-allocated output array\n * @return {TypedArray|Array} decoded array\n */\nfunction decodeRun( array, output ){\n var i, il;\n if( !output ){\n // calculate the length the decoded array will have\n var fullLength = 0;\n for( i = 0, il = array.length; i < il; i+=2 ){\n fullLength += array[ i + 1 ];\n }\n // create a new array of the same type of the input array\n output = new array.constructor( fullLength );\n }\n var dataOffset = 0;\n for( i = 0, il = array.length; i < il; i+=2 ){\n var value = array[ i ]; // value to be repeated\n var length = array[ i + 1 ]; // number of repeats\n for( var j = 0; j < length; ++j ){\n output[ dataOffset ] = value;\n ++dataOffset;\n }\n }\n return output;\n}\n\nfunction encodeRun( array ){\n if( array.length === 0 ) return new Int32Array();\n var i, il;\n // calculate output size\n var fullLength = 2;\n for( i = 1, il = array.length; i < il; ++i ){\n if( array[ i - 1 ] !== array[ i ] ){\n fullLength += 2;\n }\n }\n var output = new Int32Array( fullLength );\n var offset = 0;\n var runLength = 1;\n for( i = 1, il = array.length; i < il; ++i ){\n if( array[ i - 1 ] !== array[ i ] ){\n output[ offset ] = array[ i - 1 ];\n output[ offset + 1 ] = runLength;\n runLength = 1;\n offset += 2;\n }else{\n ++runLength;\n }\n }\n output[ offset ] = array[ array.length - 1 ];\n output[ offset + 1 ] = runLength;\n return output;\n}\n\n\n\n/**\n * perform delta decoding of the input array\n * by iterativly adding the ith element's value to the i+1th\n * example:\n * dataArray: [ 0, 2, 1, 2, 1, 1, -4, -2, 9 ]\n * return: [ 0, 2, 3, 5, 6, 7, 3, 1, 10 ]\n * @static\n * @param {TypedArray|Array} dataArray - delta encoded input array\n * @return {TypedArray|Array} decoded array\n */\nfunction decodeDelta( array, output ){\n var n = array.length;\n if( !output ) output = new array.constructor( n );\n if( n ) output[ 0 ] = array[ 0 ];\n for( var i = 1; i < n; ++i ){\n output[ i ] = array[ i ] + output[ i - 1 ];\n }\n return output;\n}\n\nfunction encodeDelta( array, output ){\n var n = array.length;\n if( !output ) output = new array.constructor( n );\n output[ 0 ] = array[ 0 ];\n for( var i = 1; i < n; ++i ){\n output[ i ] = array[ i ] - array[ i - 1 ];\n }\n return output;\n}\n\n\n\n/**\n * [decodePacking description]\n * @param {Int16Array|Int8Array} int16or8 [description]\n * @param {Int32Array} output [description]\n * @return {Int32Array} [description]\n */\nfunction decodePacking( int16or8, output ){\n var upperLimit = int16or8 instanceof Int8Array ? 0x7F : 0x7FFF;\n var lowerLimit = -upperLimit - 1;\n var n = int16or8.length;\n var i, j;\n if( !output ){\n var fullLength = 0;\n for( i = 0; i < n; ++i ){\n if( int16or8[ i ] < upperLimit && int16or8[ i ] > lowerLimit ){\n ++fullLength;\n }\n }\n output = new Int32Array( fullLength );\n }\n i = 0;\n j = 0;\n while( i < n ){\n var value = 0;\n while( int16or8[ i ] === upperLimit || int16or8[ i ] === lowerLimit ){\n value += int16or8[ i ];\n ++i;\n }\n value += int16or8[ i ];\n ++i;\n output[ j ] = value;\n ++j;\n }\n return output;\n}\n\n/**\n * integer packing using recursive indexing\n * @param {Array|TyepedArray} intArray [description]\n * @param {Boolean} useInt8 [description]\n * @return {Int16Array|Int8Array} [description]\n */\nfunction encodePacking( intArray, useInt8 ){\n var upperLimit = useInt8 ? 0x7F : 0x7FFF;\n var lowerLimit = -upperLimit - 1;\n var i;\n var n = intArray.length;\n var size = 0;\n for( i = 0; i < n; ++i ){\n var value = intArray[ i ];\n if( value === 0 ){\n ++size;\n }else if( value === upperLimit || value === lowerLimit ){\n size += 2;\n }else if( value > 0) {\n size += Math.ceil( value / upperLimit );\n }else {\n size += Math.ceil( value / lowerLimit );\n }\n }\n var output = useInt8 ? new Int8Array( size ) : new Int16Array( size );\n var j = 0;\n for( i = 0; i < n; ++i ){\n var value = intArray[ i ];\n if( value >= 0) {\n while( value >= upperLimit ){\n output[ j ] = upperLimit;\n ++j;\n value -= upperLimit;\n }\n }else{\n while( value <= lowerLimit ){\n output[ j ] = lowerLimit;\n ++j;\n value -= lowerLimit;\n }\n }\n output[ j ] = value;\n ++j;\n }\n return output;\n}\n\n\n\nfunction decodeDeltaRun( array, output ){\n return decodeDelta( decodeRun( array ), output );\n}\n\nfunction encodeDeltaRun( array ){\n return encodeRun( encodeDelta( array ) );\n}\n\n\n\n/**\n * perform run-length decoding followed (@see decodeRunLength)\n * by decoding integers into floats using given divisor (@see decodeIntegerToFloat)\n * example:\n * array: [ 320, 3, 100, 2 ]\n * divisor: 100\n * return: [ 3.20, 3.20, 3.20, 1.00, 1.00 ]\n * @static\n * @param {Uint8Array} array - run-length encoded int32 array as bytes in big endian format\n * @param {Integer} divisor - number to devide the integers to obtain floats\n * @param {Float32Array} dataArray - pre-allocated output array\n * @return {Float32Array} decoded array\n */\nfunction decodeIntegerRun( intArray, divisor, output ){\n return decodeInteger(\n decodeRun( intArray, getInt32View( output ) ), divisor, output\n );\n}\n\nfunction encodeIntegerRun( floatArray, factor ){\n return encodeRun( encodeInteger( floatArray, factor ) );\n}\n\n\n\nfunction decodeIntegerDelta( intArray, divisor, output ){\n return decodeInteger(\n decodeDelta( intArray, getInt32View( output ) ), divisor, output\n );\n}\n\nfunction encodeIntegerDelta( floatArray, factor, output ){\n return encodeDelta( encodeInteger( floatArray, factor ), output );\n}\n\n\n\nfunction decodeIntegerPacking( int16or8, divisor, output ){\n return decodeInteger(\n decodePacking( int16or8, getInt32View( output ) ), divisor, output\n );\n}\n\nfunction decodeIntegerDeltaPacking( int16or8, divisor, output ){\n var unpacked = decodePacking( int16or8, getInt32View( output ) );\n return decodeIntegerDelta( unpacked, divisor, getFloat32View( unpacked ) );\n}\n\nfunction encodeIntegerDeltaPacking( floatArray, factor, useInt8 ){\n return encodePacking( encodeIntegerDelta( floatArray, factor ), useInt8 );\n}\n\n\n\nfunction decodeBytes( bytes ){\n var dv = getDataView( bytes );\n var type = dv.getInt32( 0 );\n var size = dv.getInt32( 4 );\n var param = bytes.subarray( 8, 12 );\n var bytes = bytes.subarray( 12 );\n return [ type, bytes, size, param ];\n}\n\nfunction encodeBytes( type, size, param, bytes ){\n var buffer = new ArrayBuffer( 12 + bytes.byteLength );\n var out = new Uint8Array( buffer );\n var dv = new DataView( buffer );\n dv.setInt32( 0, type );\n dv.setInt32( 4, size );\n if( param ) out.set( param, 8 );\n out.set( bytes, 12 );\n return out;\n}\n\nfunction passInt8( int8 ){\n var size = int8.length;\n var bytes = getUint8View( int8 );\n return encodeBytes( 2, size, undefined, bytes );\n}\n\nfunction passInt32( int32 ){\n var size = int32.length;\n var bytes = encodeInt32( int32 );\n return encodeBytes( 4, size, undefined, bytes );\n}\n\nfunction passString( stringBytes, length ){\n var size = stringBytes.length / length;\n var param = encodeInt32([ length ]);\n var bytes = getUint8View( stringBytes );\n return encodeBytes( 5, size, param, bytes );\n}\n\nfunction runChar( charBytes ){\n var size = charBytes.length;\n var bytes = encodeInt32( encodeRun( charBytes ) );\n return encodeBytes( 6, size, undefined, bytes );\n}\n\nfunction deltaRun( int32 ){\n var size = int32.length;\n var bytes = encodeInt32( encodeDeltaRun( int32 ) );\n return encodeBytes( 8, size, undefined, bytes );\n}\n\nfunction integerRun( float32, factor ){\n var size = float32.length;\n var param = encodeInt32([ factor ]);\n var bytes = encodeInt32( encodeIntegerRun( float32, factor ) );\n return encodeBytes( 9, size, param, bytes );\n}\n\nfunction integerDeltaPacking16( float32, factor ){\n var size = float32.length;\n var param = encodeInt32([ factor ]);\n var bytes = encodeInt16( encodeIntegerDeltaPacking( float32, factor ) );\n return encodeBytes( 10, size, param, bytes );\n}\n\nfunction encodeMmtf( inputDict ){\n\n var outputDict = {};\n\n // copy some fields over from the input dict\n PassThroughFields.forEach( function( name ){\n if( inputDict[ name ] !== undefined ){\n outputDict[ name ] = inputDict[ name ];\n }\n } );\n\n //////////////\n // bond data\n\n // encode inter group bond atom indices, i.e. get bytes in big endian order\n if( inputDict.bondAtomList ){\n outputDict.bondAtomList = passInt32( inputDict.bondAtomList );\n }\n\n // encode inter group bond orders, i.e. get bytes\n if( inputDict.bondOrderList ){\n outputDict.bondOrderList = passInt8( inputDict.bondOrderList );\n }\n\n //////////////\n // atom data\n\n // split-list delta & integer encode x, y, z atom coords\n outputDict.xCoordList = integerDeltaPacking16( inputDict.xCoordList, 1000 );\n outputDict.yCoordList = integerDeltaPacking16( inputDict.yCoordList, 1000 );\n outputDict.zCoordList = integerDeltaPacking16( inputDict.zCoordList, 1000 );\n\n // split-list delta & integer encode b-factors\n if( inputDict.bFactorList ){\n outputDict.bFactorList = integerDeltaPacking16( inputDict.bFactorList, 100 );\n }\n\n // delta & run-length encode atom ids\n if( inputDict.atomIdList ){\n outputDict.atomIdList = deltaRun( inputDict.atomIdList );\n }\n\n // run-length encode alternate labels\n if( inputDict.altLocList ){\n outputDict.altLocList = runChar( inputDict.altLocList );\n }\n\n // run-length & integer encode occupancies\n if( inputDict.occupancyList ){\n outputDict.occupancyList = integerRun( inputDict.occupancyList, 100 );\n }\n\n ///////////////\n // group data\n\n // run-length & delta encode group numbers\n outputDict.groupIdList = deltaRun( inputDict.groupIdList );\n\n // encode group types, i.e. get int32 array\n outputDict.groupTypeList = passInt32( inputDict.groupTypeList );\n\n // encode secondary structure, i.e. get bytes\n if( inputDict.secStructList ){\n outputDict.secStructList = passInt8( inputDict.secStructList, 1 );\n }\n\n // run-length encode insertion codes\n if( inputDict.insCodeList ){\n outputDict.insCodeList = runChar( inputDict.insCodeList );\n }\n\n // run-length & delta encode sequence indices\n if( inputDict.sequenceIndexList ){\n outputDict.sequenceIndexList = deltaRun( inputDict.sequenceIndexList );\n }\n\n ///////////////\n // chain data\n\n // encode chain ids, i.e. get bytes\n outputDict.chainIdList = passString( inputDict.chainIdList, 4 );\n\n // encode chain names, i.e. get bytes\n if( inputDict.chainNameList ){\n outputDict.chainNameList = passString( inputDict.chainNameList, 4 );\n }\n\n return outputDict;\n\n}\n\n/**\n * @file msgpack-decode\n * @private\n * @author Alexander Rose \n */\n\n/**\n * msgpack decode module.\n * @module MsgpackDecode\n */\n\n/**\n * decode binary encoded MessagePack v5 (http://msgpack.org/) data\n * @static\n * @param {Uint8Array} buffer - binary encoded MessagePack data\n * @return {Object|Array|String|Number|Boolean|null} decoded Messagepack data\n */\nfunction decodeMsgpack(buffer) {\n // Loosely based on\n // The MIT License (MIT)\n // Copyright (c) 2013 Tim Caswell \n // https://github.com/creationix/msgpack-js\n var offset = 0;\n var dataView = new DataView(buffer.buffer);\n\n /**\n * decode all key-value pairs of a map into an object\n * @param {Integer} length - number of key-value pairs\n * @return {Object} decoded map\n */\n function map(length) {\n var value = {};\n for (var i = 0; i < length; i++) {\n var key = parse();\n value[key] = parse();\n }\n return value;\n }\n\n /**\n * decode binary array\n * @param {Integer} length - number of elements in the array\n * @return {Uint8Array} decoded array\n */\n function bin(length) {\n var value = buffer.subarray(offset, offset + length);\n offset += length;\n return value;\n }\n\n /**\n * decode string\n * @param {Integer} length - number string characters\n * @return {String} decoded string\n */\n function str(length) {\n var array = buffer.subarray(offset, offset + length);\n offset += length;\n // limit number of arguments to String.fromCharCode to something\n // browsers can handle, see http://stackoverflow.com/a/22747272\n var chunkSize = 0xffff;\n if(length > chunkSize){\n var c = [];\n for(var i = 0; i < array.length; i += chunkSize) {\n c.push(String.fromCharCode.apply(\n null, array.subarray(i, i + chunkSize)\n ));\n }\n return c.join(\"\");\n }else{\n return String.fromCharCode.apply(null, array);\n }\n }\n\n /**\n * decode array\n * @param {Integer} length - number of array elements\n * @return {Array} decoded array\n */\n function array(length) {\n var value = new Array(length);\n for (var i = 0; i < length; i++) {\n value[i] = parse();\n }\n return value;\n }\n\n /**\n * recursively parse the MessagePack data\n * @return {Object|Array|String|Number|Boolean|null} decoded MessagePack data\n */\n function parse() {\n var type = buffer[offset];\n var value, length, extType;\n // Positive FixInt\n if ((type & 0x80) === 0x00) {\n offset++;\n return type;\n }\n // FixMap\n if ((type & 0xf0) === 0x80) {\n length = type & 0x0f;\n offset++;\n return map(length);\n }\n // FixArray\n if ((type & 0xf0) === 0x90) {\n length = type & 0x0f;\n offset++;\n return array(length);\n }\n // FixStr\n if ((type & 0xe0) === 0xa0) {\n length = type & 0x1f;\n offset++;\n return str(length);\n }\n // Negative FixInt\n if ((type & 0xe0) === 0xe0) {\n value = dataView.getInt8(offset);\n offset++;\n return value;\n }\n switch (type) {\n // nil\n case 0xc0:\n offset++;\n return null;\n // 0xc1: (never used, could be employed for padding)\n // false\n case 0xc2:\n offset++;\n return false;\n // true\n case 0xc3:\n offset++;\n return true;\n // bin 8\n case 0xc4:\n length = dataView.getUint8(offset + 1);\n offset += 2;\n return bin(length);\n // bin 16\n case 0xc5:\n length = dataView.getUint16(offset + 1);\n offset += 3;\n return bin(length);\n // bin 32\n case 0xc6:\n length = dataView.getUint32(offset + 1);\n offset += 5;\n return bin(length);\n // // ext 8\n // case 0xc7:\n // length = dataView.getUint8(offset + 1);\n // extType = dataView.getUint8(offset + 2);\n // offset += 3;\n // return [extType, bin(length)];\n // // ext 16\n // case 0xc8:\n // length = dataView.getUint16(offset + 1);\n // extType = dataView.getUint8(offset + 3);\n // offset += 4;\n // return [extType, bin(length)];\n // // ext 32\n // case 0xc9:\n // length = dataView.getUint32(offset + 1);\n // extType = dataView.getUint8(offset + 5);\n // offset += 6;\n // return [extType, bin(length)];\n // float 32\n case 0xca:\n value = dataView.getFloat32(offset + 1);\n offset += 5;\n return value;\n // float 64\n case 0xcb:\n value = dataView.getFloat64(offset + 1);\n offset += 9;\n return value;\n // uint8\n case 0xcc:\n value = buffer[offset + 1];\n offset += 2;\n return value;\n // uint 16\n case 0xcd:\n value = dataView.getUint16(offset + 1);\n offset += 3;\n return value;\n // uint 32\n case 0xce:\n value = dataView.getUint32(offset + 1);\n offset += 5;\n return value;\n // // uint64\n // case 0xcf:\n // // FIXME not available/representable in JS\n // // largest possible int in JS is 2^53\n // // value = dataView.getUint64(offset + 1);\n // offset += 9;\n // return 0;\n // int 8\n case 0xd0:\n value = dataView.getInt8(offset + 1);\n offset += 2;\n return value;\n // int 16\n case 0xd1:\n value = dataView.getInt16(offset + 1);\n offset += 3;\n return value;\n // int 32\n case 0xd2:\n value = dataView.getInt32(offset + 1);\n offset += 5;\n return value;\n // // int 64\n // case 0xd3:\n // // FIXME not available/representable in JS\n // // largest possible int in JS is 2^53\n // // value = dataView.getInt64(offset + 1);\n // offset += 9;\n // return 0;\n\n // // fixext 1\n // case 0xd4:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(1)];\n // // fixext 2\n // case 0xd5:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(2)];\n // // fixext 4\n // case 0xd6:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(4)];\n // // fixext 8\n // case 0xd7:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(8)];\n // // fixext 16\n // case 0xd8:\n // extType = dataView.getUint8(offset + 1);\n // offset += 2;\n // return [extType, bin(16)];\n // str 8\n case 0xd9:\n length = dataView.getUint8(offset + 1);\n offset += 2;\n return str(length);\n // str 16\n case 0xda:\n length = dataView.getUint16(offset + 1);\n offset += 3;\n return str(length);\n // str 32\n case 0xdb:\n length = dataView.getUint32(offset + 1);\n offset += 5;\n return str(length);\n // array 16\n case 0xdc:\n length = dataView.getUint16(offset + 1);\n offset += 3;\n return array(length);\n // array 32\n case 0xdd:\n length = dataView.getUint32(offset + 1);\n offset += 5;\n return array(length);\n // map 16:\n case 0xde:\n length = dataView.getUint16(offset + 1);\n offset += 3;\n return map(length);\n // map 32\n case 0xdf:\n length = dataView.getUint32(offset + 1);\n offset += 5;\n return map(length);\n }\n\n throw new Error(\"Unknown type 0x\" + type.toString(16));\n }\n\n // start the recursive parsing\n return parse();\n}\n\n/**\n * Fields shared in encoded and decoded mmtf data objects.\n * @typedef {Object} module:MmtfDecode.SharedMmtfData\n * @property {String} mmtfVersion - MMTF specification version\n * @property {String} mmtfProducer - Program that created the file\n * @property {Float[]} [unitCell] - Crystallographic unit cell\n * @property {Float} unitCell.0 - x length\n * @property {Float} unitCell.1 - y length\n * @property {Float} unitCell.2 - z length\n * @property {Float} unitCell.3 - alpha angle\n * @property {Float} unitCell.4 - beta angle\n * @property {Float} unitCell.5 - gamma angle\n * @property {String} [spaceGroup] - Hermann-Mauguin symbol\n * @property {String} [structureId] - Some reference, e.g. a PDB ID\n * @property {String} [title] - Short description\n * @property {String} [depositionDate] - Deposition date in YYYY-MM-DD format\n * @property {String} [releaseDate] - Release date in YYYY-MM-DD format\n * @property {String[]} [experimentalMethods] - Structure determination methods\n * @property {Float} [resolution] - Resolution in Å\n * @property {Float} [rFree] - R-free value\n * @property {Float} [rWork] - R-work value\n * @property {Integer} numBonds - Number of bonds\n * @property {Integer} numAtoms - Number of atoms\n * @property {Integer} numGroups - Number of groups (residues)\n * @property {Integer} numChains - Number of chains\n * @property {Integer} numModels - Number of models\n * @property {Integer[]} chainsPerModel - List of number of chains in each model\n * @property {Integer[]} groupsPerChain - List of number of groups in each chain\n * @property {Entity[]} [entityList] - List of entity objects\n * @property {Integer[]} entityList.chainIndexList - Pointers into chain data fields\n * @property {String} entityList.description - Description of the entity\n * @property {String} entityList.type - Name of the entity type\n * @property {String} entityList.sequence - One letter code sequence\n * @property {Assembly[]} [bioAssemblyList] - List of assembly objects\n * @property {Transform[]} bioAssemblyList.transformList - List of transform objects\n * @property {Integer[]} bioAssemblyList.transformList.chainIndexList - Pointers into chain data fields\n * @property {Float[]} bioAssemblyList.transformList.matrix - 4x4 transformation matrix\n * @property {Array[]} [ncsOperatorList] - List of ncs operator matrices\n * @property {Float[]} ncsOperatorList. - 4x4 transformation matrix\n * @property {GroupType[]} groupList - List of groupType objects\n * @property {Integer[]} groupList.formalChargeList - List of atom formal charges\n * @property {String[]} groupList.elementList - List of elements\n * @property {String[]} groupList.atomNameList - List of atom names\n * @property {Integer[]} groupList.bondAtomList - List of bonded atom indices\n * @property {Integer[]} groupList.bondOrderList - List of bond orders\n * @property {String} groupList.groupName - The name of the group\n * @property {String} groupList.singleLetterCode - The single letter code\n * @property {String} groupList.chemCompType - The chemical component type\n */\n\n/**\n * Encoded mmtf data object. Also includes the fields from {@link module:MmtfDecode.SharedMmtfData}. See MMTF specification on how they are encoded.\n * @typedef {Object} module:MmtfDecode.EncodedMmtfData\n * @mixes module:MmtfDecode.SharedMmtfData\n * @property {Uint8Array} [bondAtomList] - Encoded bonded atom indices\n * @property {Uint8Array} [bondOrderList] - Encoded bond orders\n * @property {Uint8Array} xCoordBig - Encoded x coordinates in Å, part 1\n * @property {Uint8Array} xCoordSmall - Encoded x coordinates in Å, part 2\n * @property {Uint8Array} yCoordBig - Encoded y coordinates in Å, part 1\n * @property {Uint8Array} yCoordSmall - Encoded y coordinates in Å, part 2\n * @property {Uint8Array} yCoordBig - Encoded y coordinates in Å, part 1\n * @property {Uint8Array} yCoordSmall - Encoded y coordinates in Å, part 2\n * @property {Uint8Array} [bFactorBig] - Encoded B-factors in Å^2, part 1\n * @property {Uint8Array} [bFactorSmall] - Encoded B-factors in Å^2, part 2\n * @property {Uint8Array} [atomIdList] - Encoded atom ids\n * @property {Uint8Array} [altLocList] - Encoded alternate location labels\n * @property {Uint8Array} [occupancyList] - Encoded occupancies\n * @property {Uint8Array} groupIdList - Encoded group ids\n * @property {Uint8Array} groupTypeList - Encoded group types\n * @property {Uint8Array} [secStructList] - Encoded secondary structure codes\n * @property {Uint8Array} [insCodeList] - Encoded insertion codes\n * @property {Uint8Array} [seuenceIdList] - Encoded sequence ids\n * @property {Uint8Array} chainIdList - Encoded chain ids\n * @property {Uint8Array} [chainNameList] - Encoded chain names\n */\n\n/**\n * Decoded mmtf data object. Also includes fields the from {@link module:MmtfDecode.SharedMmtfData}.\n * @typedef {Object} module:MmtfDecode.MmtfData\n * @mixes module:MmtfDecode.SharedMmtfData\n * @property {Int32Array} [bondAtomList] - List of bonded atom indices\n * @property {Uint8Array} [bondOrderList] - List of bond orders\n * @property {Float32Array} xCoordList - List of x coordinates in Å\n * @property {Float32Array} yCoordList - List of y coordinates in Å\n * @property {Float32Array} zCoordList - List of z coordinates in Å\n * @property {Float32Array} [bFactorList] - List of B-factors in Å^2\n * @property {Int32Array} [atomIdList] - List of atom ids\n * @property {Uint8Array} [altLocList] - List of alternate location labels\n * @property {Float32Array} [occupancyList] - List of occupancies\n * @property {Int32Array} groupIdList - List of group ids\n * @property {Int32Array} groupTypeList - List of group types\n * @property {Int8Array} [secStructList] - List of secondary structure codes, encoding\n * 0: pi helix, 1: bend, 2: alpha helix, 3: extended,\n * 4: 3-10 helix, 5: bridge, 6: turn, 7: coil, -1: undefined\n * @property {Uint8Array} [insCodeList] - List of insertion codes\n * @property {Int32Array} [seuenceIdList] - List of sequence ids\n * @property {Uint8Array} chainIdList - List of chain ids\n * @property {Uint8Array} [chainNameList] - List of chain names\n */\n\n\n/**\n * [performDecoding description]\n * @param {Integer} bytes [description]\n * @param {Integer} size [description]\n * @param {Uint8Array} param [description]\n * @return {TypedArray} [description]\n */\nfunction performDecoding( type, bytes, size, param ){\n\n switch( type ){\n case 1:\n return decodeFloat32( bytes );\n case 2:\n return getInt8View( bytes );\n case 3:\n return decodeInt16( bytes );\n case 4:\n return decodeInt32( bytes );\n case 5:\n // var length = decodeInt32( param )[ 0 ];\n return getUint8View( bytes ); // interpret as string array\n case 6:\n // interpret as char array\n return decodeRun( decodeInt32( bytes ), new Uint8Array( size ) );\n case 7:\n return decodeRun( decodeInt32( bytes ) )\n case 8:\n return decodeDeltaRun( decodeInt32( bytes ) );\n case 9:\n return decodeIntegerRun( decodeInt32( bytes ), decodeInt32( param )[ 0 ] );\n case 10:\n return decodeIntegerDeltaPacking( decodeInt16( bytes ), decodeInt32( param )[ 0 ] );\n case 11:\n return decodeInteger( decodeInt16( bytes ), decodeInt32( param )[ 0 ] );\n case 12:\n return decodeIntegerPacking( decodeInt16( bytes ), decodeInt32( param )[ 0 ] );\n case 13:\n return decodeIntegerPacking( getInt8View( bytes ), decodeInt32( param )[ 0 ] );\n case 14:\n return decodePacking( decodeInt16( bytes ) );\n case 15:\n return decodePacking( getInt8View( bytes ) );\n }\n\n};\n\n\n/**\n * Decode MMTF fields\n * @static\n * @param {Object} inputDict - encoded MMTF data\n * @param {Object} [params] - decoding parameters\n * @param {String[]} params.ignoreFields - names of optional fields not to decode\n * @return {module:MmtfDecode.MmtfData} mmtfData\n */\nfunction decodeMmtf( inputDict, params ){\n\n params = params || {};\n var ignoreFields = params.ignoreFields;\n var outputDict = {};\n\n AllFields.forEach( function( name ){\n var ignore = ignoreFields ? ignoreFields.indexOf( name ) !== -1 : false;\n var data = inputDict[ name ];\n if( !ignore && data !== undefined ){\n if( data instanceof Uint8Array ){\n outputDict[ name ] = performDecoding.apply( null, decodeBytes( data ) );\n }else{\n outputDict[ name ] = data;\n }\n }\n } );\n\n return outputDict;\n\n}\n\n/**\n * @file mmtf-traverse\n * @private\n * @author Alexander Rose \n */\n\n/**\n * mmtf traverse module.\n * @module MmtfTraverse\n */\n\n/**\n * Converts an array of ASCII codes trimming '\\0' bytes\n * @private\n * @param {Array} charCodeArray - array of ASCII char codes\n * @return {String} '\\0' trimmed string\n */\nfunction fromCharCode( charCodeArray ){\n return String.fromCharCode.apply( null, charCodeArray ).replace(/\\0/g, '');\n}\n\n\n/**\n * @callback module:MmtfTraverse.onModel\n * @param {Object} modelData\n * @param {Integer} modelData.chainCount - number of chains in the model\n * @param {Integer} modelData.modelIndex - index of the model\n */\n\n/**\n * @callback module:MmtfTraverse.onChain\n * @param {Object} chainData\n * @param {Integer} chainData.groupCount - number of groups in the chain\n * @param {Integer} chainData.chainIndex - index of the chain\n * @param {Integer} chainData.modelIndex - index of the parent model\n * @param {String} chainData.chainId - chain id\n * @param {?String} chainData.chainName - additional chain name\n */\n\n/**\n * @callback module:MmtfTraverse.onGroup\n * @param {Object} groupData\n * @param {Integer} groupData.atomCount - number of atoms in the group\n * @param {Integer} groupData.groupIndex - index of the group\n * @param {Integer} groupData.chainIndex - index of the parent chain\n * @param {Integer} groupData.modelIndex - index of the parent model\n * @param {Integer} groupData.groupId - group id (residue number)\n * @param {Integer} groupData.groupType - index to an entry in {@link module:MmtfDecode.MmtfData}#groupList\n * @param {String} groupData.groupName - name of the group, 0 to 5 characters\n * @param {Char} groupData.singleLetterCode - IUPAC single letter code, otherwise 'X', 1 character\n * @param {String} groupData.chemCompType - chemical component type from the mmCIF dictionary\n * @param {?Integer} groupData.secStruct - sencoded secondary structure |\n * 0: pi helix, 1: bend, 2: alpha helix, 3: extended,\n * 4: 3-10 helix, 5: bridge, 6: turn, 7: coil, -1: undefined\n * @param {?Char} groupData.insCode - insertion code\n * @param {?Integer} groupData.sequenceIndex - index to the `sequence` property of\n * the corresponding entity, -1 when the entity has no sequence\n */\n\n/**\n * @callback module:MmtfTraverse.onAtom\n * @param {Object} atomData\n * @param {Integer} atomData.atomIndex - index of the atom\n * @param {Integer} atomData.groupIndex - index of the parent group\n * @param {Integer} atomData.chainIndex - index of the parent chain\n * @param {Integer} atomData.modelIndex - index of the parent model\n * @param {?Integer} atomData.atomId - atom id\n * @param {String} atomData.element - IUPAC element name, 0 to 3 characters\n * @param {String} atomData.atomName - name of the atom, 0 to 5 characters\n * @param {Integer} atomData.formalCharge - formal charge of the atom\n * @param {Float} atomData.xCoord - x coordinate in Å\n * @param {Float} atomData.yCoord - y coordinate in Å\n * @param {Float} atomData.zCoord - z coordinate in Å\n * @param {?Float} atomData.bFactor - B-factor in in Å^2\n * @param {?Char} atomData.altLoc - alternate location identifier\n * @param {?Float} atomData.occupancy - occupancy of the atom\n */\n\n/**\n * @callback module:MmtfTraverse.onBond\n * @param {Object} bondData\n * @param {Integer} bondData.atomIndex1 - index of the first atom\n * @param {Integer} bondData.atomIndex2 - index of the secound atom\n * @param {Integer} bondData.bondOrder - bond order, allowed values are 1 to 3\n */\n\n\n/**\n * Traverse the MMTF structure data.\n * @static\n * @param {module:MmtfDecode.MmtfData} mmtfData - decoded mmtf data\n * @param {Object} eventCallbacks\n * @param {module:MmtfTraverse.onModel} [eventCallbacks.onModel] - called for each model\n * @param {module:MmtfTraverse.onChain} [eventCallbacks.onChain] - called for each chain\n * @param {module:MmtfTraverse.onGroup} [eventCallbacks.onGroup] - called for each group\n * @param {module:MmtfTraverse.onAtom} [eventCallbacks.onAtom] - called for each atom\n * @param {module:MmtfTraverse.onBond} [eventCallbacks.onBond] - called for each bond\n * @param {Object} [params] - traversal parameters\n * @param {Boolean} [params.firstModelOnly] - traverse only the first model\n */\nfunction traverseMmtf( mmtfData, eventCallbacks, params ){\n\n params = params || {};\n\n var firstModelOnly = params.firstModelOnly;\n\n // setup callbacks\n var onModel = eventCallbacks.onModel;\n var onChain = eventCallbacks.onChain;\n var onGroup = eventCallbacks.onGroup;\n var onAtom = eventCallbacks.onAtom;\n var onBond = eventCallbacks.onBond;\n\n // setup index counters\n var modelIndex = 0;\n var chainIndex = 0;\n var groupIndex = 0;\n var atomIndex = 0;\n\n var modelFirstAtomIndex = 0;\n var modelLastAtomIndex = -1;\n\n // setup optional fields\n var chainNameList = mmtfData.chainNameList;\n var secStructList = mmtfData.secStructList;\n var insCodeList = mmtfData.insCodeList;\n var sequenceIndexList = mmtfData.sequenceIndexList;\n var atomIdList = mmtfData.atomIdList;\n var bFactorList = mmtfData.bFactorList;\n var altLocList = mmtfData.altLocList;\n var occupancyList = mmtfData.occupancyList;\n var bondAtomList = mmtfData.bondAtomList;\n var bondOrderList = mmtfData.bondOrderList;\n\n // hoisted loop variables\n var o, ol, i, j, k, kl;\n\n // loop over all models\n for( o = 0, ol = mmtfData.chainsPerModel.length; o < ol; ++o ){\n\n if( firstModelOnly && modelIndex > 0 ) break;\n\n var modelChainCount = mmtfData.chainsPerModel[ modelIndex ];\n\n if( onModel ){\n onModel({\n chainCount: modelChainCount,\n modelIndex: modelIndex\n });\n }\n\n for( i = 0; i < modelChainCount; ++i ){\n\n var chainGroupCount = mmtfData.groupsPerChain[ chainIndex ];\n if( onChain ){\n var chainId = fromCharCode(\n mmtfData.chainIdList.subarray( chainIndex * 4, chainIndex * 4 + 4 )\n );\n var chainName = null;\n if( chainNameList ){\n chainName = fromCharCode(\n chainNameList.subarray( chainIndex * 4, chainIndex * 4 + 4 )\n );\n }\n onChain({\n groupCount: chainGroupCount,\n chainIndex: chainIndex,\n modelIndex: modelIndex,\n chainId: chainId,\n chainName: chainName\n });\n }\n\n for( j = 0; j < chainGroupCount; ++j ){\n\n var groupData = mmtfData.groupList[ mmtfData.groupTypeList[ groupIndex ] ];\n var groupAtomCount = groupData.atomNameList.length;\n if( onGroup ){\n var secStruct = null;\n if( secStructList ){\n secStruct = secStructList[ groupIndex ];\n }\n var insCode = null;\n if( mmtfData.insCodeList ){\n insCode = String.fromCharCode( insCodeList[ groupIndex ] );\n }\n var sequenceIndex = null;\n if( sequenceIndexList ){\n sequenceIndex = sequenceIndexList[ groupIndex ];\n }\n onGroup({\n atomCount: groupAtomCount,\n groupIndex: groupIndex,\n chainIndex: chainIndex,\n modelIndex: modelIndex,\n groupId: mmtfData.groupIdList[ groupIndex ],\n groupType: mmtfData.groupTypeList[ groupIndex ],\n groupName: groupData.groupName,\n singleLetterCode: groupData.singleLetterCode,\n chemCompType: groupData.chemCompType,\n secStruct: secStruct,\n insCode: insCode,\n sequenceIndex: sequenceIndex\n });\n }\n\n for( k = 0; k < groupAtomCount; ++k ){\n\n if( onAtom ){\n var atomId = null;\n if( atomIdList ){\n atomId = atomIdList[ atomIndex ];\n }\n var bFactor = null;\n if( bFactorList ){\n bFactor = bFactorList[ atomIndex ];\n }\n var altLoc = null;\n if( altLocList ){\n altLoc = String.fromCharCode( altLocList[ atomIndex ] );\n }\n var occupancy = null;\n if( occupancyList ){\n occupancy = occupancyList[ atomIndex ];\n }\n onAtom({\n atomIndex: atomIndex,\n groupIndex: groupIndex,\n chainIndex: chainIndex,\n modelIndex: modelIndex,\n atomId: atomId,\n element: groupData.elementList[ k ],\n atomName: groupData.atomNameList[ k ],\n formalCharge: groupData.formalChargeList[ k ],\n xCoord: mmtfData.xCoordList[ atomIndex ],\n yCoord: mmtfData.yCoordList[ atomIndex ],\n zCoord: mmtfData.zCoordList[ atomIndex ],\n bFactor: bFactor,\n altLoc: altLoc,\n occupancy: occupancy\n });\n }\n\n atomIndex += 1;\n }\n\n if( onBond ){\n // intra group bonds\n var groupBondAtomList = groupData.bondAtomList;\n for( k = 0, kl = groupData.bondOrderList.length; k < kl; ++k ){\n onBond({\n atomIndex1: atomIndex - groupAtomCount + groupBondAtomList[ k * 2 ],\n atomIndex2: atomIndex - groupAtomCount + groupBondAtomList[ k * 2 + 1 ],\n bondOrder: groupData.bondOrderList[ k ]\n });\n }\n }\n\n groupIndex += 1;\n }\n\n chainIndex += 1;\n }\n\n modelFirstAtomIndex = modelLastAtomIndex + 1;\n modelLastAtomIndex = atomIndex - 1; // subtract one as it already has been incremented\n\n if( onBond ){\n // inter group bonds\n if( bondAtomList ){\n for( k = 0, kl = bondAtomList.length; k < kl; k += 2 ){\n var atomIndex1 = bondAtomList[ k ];\n var atomIndex2 = bondAtomList[ k + 1 ];\n if( ( atomIndex1 >= modelFirstAtomIndex && atomIndex1 <= modelLastAtomIndex ) ||\n ( atomIndex2 >= modelFirstAtomIndex && atomIndex2 <= modelLastAtomIndex )\n ){\n onBond({\n atomIndex1: atomIndex1,\n atomIndex2: atomIndex2,\n bondOrder: bondOrderList ? bondOrderList[ k / 2 ] : null\n });\n }\n }\n }\n }\n\n modelIndex += 1;\n }\n\n}\n\n/**\n * Version name\n * @static\n * @type {String}\n */\nvar version = \"v1.1.0dev\";\n\n/**\n * Version name\n * @private\n * @type {String}\n */\nvar baseUrl = \"//mmtf.rcsb.org/v1.0/\";\n\n/**\n * URL of the RCSB webservice to obtain MMTF files\n * @static\n * @type {String}\n */\nvar fetchUrl = baseUrl + \"full/\";\n\n/**\n * URL of the RCSB webservice to obtain reduced MMTF files\n * @static\n * @type {String}\n */\nvar fetchReducedUrl = baseUrl + \"reduced/\";\n\n/**\n * Encode MMTF fields\n * @static\n * @param {module:MmtfDecode.MmtfData} mmtfData - mmtf data\n * @return {Uint8Array} encoded MMTF fields\n */\nfunction encode( mmtfData ){\n return encodeMsgpack( encodeMmtf( mmtfData ) );\n}\n\n/**\n * Decode MMTF fields\n * @static\n * @example\n * // bin is Uint8Array containing the mmtf msgpack\n * var mmtfData = MMTF.decode( bin );\n * console.log( mmtfData.numAtoms );\n *\n * @param {Uint8Array|ArrayBuffer|module:MmtfDecode.EncodedMmtfData} binOrDict - binary MessagePack or encoded MMTF data\n * @param {Object} [params] - decoding parameters\n * @param {String[]} params.ignoreFields - names of optional fields not to decode\n * @return {module:MmtfDecode.MmtfData} mmtfData\n */\nfunction decode( binOrDict, params ){\n\t// make sure binOrDict is not a plain Arraybuffer\n if( binOrDict instanceof ArrayBuffer ){\n binOrDict = new Uint8Array( binOrDict );\n }\n\n var inputDict;\n if( binOrDict instanceof Uint8Array ){\n // get dict from msgpack\n inputDict = decodeMsgpack( binOrDict );\n }else{\n // already a dict\n inputDict = binOrDict;\n }\n\n return decodeMmtf( inputDict, params );\n}\n\n/**\n * @callback module:MMTF.onLoad\n * @param {module:MmtfDecode.MmtfData} mmtfData - decoded mmtf data object\n */\n\n/**\n * helper method to fetch binary files from an URL\n * @private\n * @param {String} pdbid - PDB ID to fetch\n * @param {String} baseUrl - URL to fetch from\n * @param {module:MMTF.onLoad} onLoad - callback( mmtfData )\n * @param {Function} onError - callback( error )\n * @return {undefined}\n */\nfunction _fetch( pdbid, baseUrl, onLoad, onError ){\n var xhr = new XMLHttpRequest();\n function _onLoad(){\n try{\n var mmtfData = decode( xhr.response );\n onLoad( mmtfData );\n }catch( error ){\n onError( error );\n }\n }\n xhr.addEventListener( \"load\", _onLoad, true );\n xhr.addEventListener( \"error\", onError, true );\n xhr.responseType = \"arraybuffer\";\n xhr.open( \"GET\", baseUrl + pdbid.toUpperCase() );\n xhr.send();\n}\n\n/**\n * Fetch MMTF file from RCSB webservice which contains\n * @static\n * @example\n * MMTF.fetch(\n * \"3PQR\",\n * // onLoad callback\n * function( mmtfData ){ console.log( mmtfData ) },\n * // onError callback\n * function( error ){ console.error( error ) }\n * );\n *\n * @param {String} pdbid - PDB ID to fetch\n * @param {module:MMTF.onLoad} onLoad - callback( mmtfData )\n * @param {Function} onError - callback( error )\n * @return {undefined}\n */\nfunction fetch( pdbid, onLoad, onError ){\n _fetch( pdbid, fetchUrl, onLoad, onError );\n}\n\n/**\n * Fetch reduced MMTF file from RCSB webservice which contains\n * protein C-alpha, nucleotide phosphate and ligand atoms\n * @static\n * @example\n * MMTF.fetchReduced(\n * \"3PQR\",\n * // onLoad callback\n * function( mmtfData ){ console.log( mmtfData ) },\n * // onError callback\n * function( error ){ console.error( error ) }\n * );\n *\n * @param {String} pdbid - PDB ID to fetch\n * @param {module:MMTF.onLoad} onLoad - callback( mmtfData )\n * @param {Function} onError - callback( error )\n * @return {undefined}\n */\nfunction fetchReduced( pdbid, onLoad, onError ){\n _fetch( pdbid, fetchReducedUrl, onLoad, onError );\n}\n\nexport { encode, decode, traverseMmtf as traverse, fetch, fetchReduced, version, fetchUrl, fetchReducedUrl, encodeMsgpack, encodeMmtf, decodeMsgpack, decodeMmtf };","/**\n * @file Mmtf Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport {\n buildUnitcellAssembly, calculateBondsBetween, calculateBondsWithin\n} from '../structure/structure-utils'\nimport { ChemCompHetero } from '../structure/structure-constants'\nimport Entity from '../structure/entity'\nimport Unitcell from '../symmetry/unitcell'\nimport Assembly, { AssemblyPart } from '../symmetry/assembly'\n\nimport { decodeMsgpack, decodeMmtf } from '../../lib/mmtf.es6'\n\nconst SstrucMap: {[k: string]: number} = {\n '0': 'i'.charCodeAt(0), // pi helix\n '1': 's'.charCodeAt(0), // bend\n '2': 'h'.charCodeAt(0), // alpha helix\n '3': 'e'.charCodeAt(0), // extended\n '4': 'g'.charCodeAt(0), // 3-10 helix\n '5': 'b'.charCodeAt(0), // bridge\n '6': 't'.charCodeAt(0), // turn\n '7': 'l'.charCodeAt(0), // coil\n '-1': ''.charCodeAt(0) // NA\n}\n\nclass MmtfParser extends StructureParser {\n get type () { return 'mmtf' }\n get isBinary () { return true }\n\n _parse () {\n // https://github.com/rcsb/mmtf\n\n if (Debug) Log.time('MmtfParser._parse ' + this.name)\n\n let i, il, j, jl, groupData\n\n const s = this.structure\n const sd: {[k: string]: any} = decodeMmtf(decodeMsgpack(this.streamer.data))\n\n // structure header\n const headerFields = [\n 'depositionDate', 'releaseDate', 'resolution',\n 'rFree', 'rWork', 'experimentalMethods'\n ]\n headerFields.forEach(function (name) {\n if (sd[ name ] !== undefined) {\n s.header[ name ] = sd[ name ]\n }\n })\n\n let numBonds, numAtoms, numGroups, numChains, numModels\n let chainsPerModel\n\n s.id = sd.structureId\n s.title = sd.title\n\n s.atomStore.addField('formalCharge', 1, 'int8')\n\n if (this.firstModelOnly || this.asTrajectory) {\n numModels = 1\n numChains = sd.chainsPerModel[ 0 ]\n\n numGroups = 0\n for (i = 0, il = numChains; i < il; ++i) {\n numGroups += sd.groupsPerChain[ i ]\n }\n\n numAtoms = 0\n for (i = 0, il = numGroups; i < il; ++i) {\n groupData = sd.groupList[ sd.groupTypeList[ i ] ]\n numAtoms += groupData.atomNameList.length\n }\n\n numBonds = sd.numBonds\n\n chainsPerModel = [ numChains ]\n } else {\n numBonds = sd.numBonds\n numAtoms = sd.numAtoms\n numGroups = sd.numGroups\n numChains = sd.numChains\n numModels = sd.numModels\n\n chainsPerModel = sd.chainsPerModel\n }\n\n numBonds += numGroups // add numGroups to have space for polymer bonds\n\n //\n\n if (this.asTrajectory) {\n for (i = 0, il = sd.numModels; i < il; ++i) {\n const frame = new Float32Array(numAtoms * 3)\n const frameAtomOffset = numAtoms * i\n\n for (j = 0; j < numAtoms; ++j) {\n const j3 = j * 3\n const offset = j + frameAtomOffset\n frame[ j3 ] = sd.xCoordList[ offset ]\n frame[ j3 + 1 ] = sd.yCoordList[ offset ]\n frame[ j3 + 2 ] = sd.zCoordList[ offset ]\n }\n\n s.frames.push(frame)\n }\n }\n\n // bondStore\n const bAtomIndex1 = new Uint32Array(numBonds)\n const bAtomIndex2 = new Uint32Array(numBonds)\n const bBondOrder = new Uint8Array(numBonds)\n\n const aGroupIndex = new Uint32Array(numAtoms)\n const aFormalCharge = new Int8Array(numAtoms)\n\n const gChainIndex = new Uint32Array(numGroups)\n const gAtomOffset = new Uint32Array(numGroups)\n const gAtomCount = new Uint16Array(numGroups)\n\n const cModelIndex = new Uint16Array(numChains)\n const cGroupOffset = new Uint32Array(numChains)\n const cGroupCount = new Uint32Array(numChains)\n\n const mChainOffset = new Uint32Array(numModels)\n const mChainCount = new Uint32Array(numModels)\n\n // set-up model-chain relations\n let chainOffset = 0\n for (i = 0, il = numModels; i < il; ++i) {\n const modelChainCount = chainsPerModel[ i ]\n mChainOffset[ i ] = chainOffset\n mChainCount[ i ] = modelChainCount\n for (j = 0; j < modelChainCount; ++j) {\n cModelIndex[ j + chainOffset ] = i\n }\n chainOffset += modelChainCount\n }\n\n // set-up chain-residue relations\n const groupsPerChain = sd.groupsPerChain\n let groupOffset = 0\n for (i = 0, il = numChains; i < il; ++i) {\n const chainGroupCount = groupsPerChain[ i ]\n cGroupOffset[ i ] = groupOffset\n cGroupCount[ i ] = chainGroupCount\n for (j = 0; j < chainGroupCount; ++j) {\n gChainIndex[ j + groupOffset ] = i\n }\n groupOffset += chainGroupCount\n }\n\n /// ///\n // get data from group map\n\n let atomOffset = 0\n let bondOffset = 0\n\n for (i = 0, il = numGroups; i < il; ++i) {\n groupData = sd.groupList[ sd.groupTypeList[ i ] ]\n const groupAtomCount = groupData.atomNameList.length\n const groupFormalChargeList = groupData.formalChargeList\n\n const groupBondAtomList = groupData.bondAtomList\n const groupBondOrderList = groupData.bondOrderList\n\n for (j = 0, jl = groupBondOrderList.length; j < jl; ++j) {\n bAtomIndex1[ bondOffset ] = atomOffset + groupBondAtomList[ j * 2 ]\n bAtomIndex2[ bondOffset ] = atomOffset + groupBondAtomList[ j * 2 + 1 ]\n bBondOrder[ bondOffset ] = groupBondOrderList[ j ]\n bondOffset += 1\n }\n\n //\n\n gAtomOffset[ i ] = atomOffset\n gAtomCount[ i ] = groupAtomCount\n\n for (j = 0; j < groupAtomCount; ++j) {\n aGroupIndex[ atomOffset ] = i\n aFormalCharge[ atomOffset ] = groupFormalChargeList[ j ]\n atomOffset += 1\n }\n }\n\n // extra bonds\n\n const bondAtomList = sd.bondAtomList\n if (bondAtomList) {\n if (sd.bondOrderList) {\n bBondOrder.set(sd.bondOrderList, bondOffset)\n }\n\n for (i = 0, il = bondAtomList.length; i < il; i += 2) {\n const atomIndex1 = bondAtomList[ i ]\n const atomIndex2 = bondAtomList[ i + 1 ]\n if (atomIndex1 < numAtoms && atomIndex2 < numAtoms) {\n bAtomIndex1[ bondOffset ] = atomIndex1\n bAtomIndex2[ bondOffset ] = atomIndex2\n bondOffset += 1\n }\n }\n }\n\n //\n\n s.bondStore.length = bBondOrder.length\n s.bondStore.count = bondOffset\n s.bondStore.atomIndex1 = bAtomIndex1\n s.bondStore.atomIndex2 = bAtomIndex2\n s.bondStore.bondOrder = bBondOrder\n\n s.atomStore.length = numAtoms\n s.atomStore.count = numAtoms\n s.atomStore.residueIndex = aGroupIndex\n s.atomStore.atomTypeId = new Uint16Array(numAtoms)\n s.atomStore.x = sd.xCoordList.subarray(0, numAtoms)\n s.atomStore.y = sd.yCoordList.subarray(0, numAtoms)\n s.atomStore.z = sd.zCoordList.subarray(0, numAtoms)\n s.atomStore.serial = sd.atomIdList.subarray(0, numAtoms)\n s.atomStore.bfactor = sd.bFactorList.subarray(0, numAtoms)\n s.atomStore.altloc = sd.altLocList.subarray(0, numAtoms)\n s.atomStore.occupancy = sd.occupancyList.subarray(0, numAtoms)\n s.atomStore.formalCharge = aFormalCharge\n\n s.residueStore.length = numGroups\n s.residueStore.count = numGroups\n s.residueStore.chainIndex = gChainIndex\n s.residueStore.residueTypeId = sd.groupTypeList\n s.residueStore.atomOffset = gAtomOffset\n s.residueStore.atomCount = gAtomCount\n s.residueStore.resno = sd.groupIdList.subarray(0, numGroups)\n s.residueStore.sstruc = sd.secStructList.subarray(0, numGroups)\n s.residueStore.inscode = sd.insCodeList.subarray(0, numGroups)\n\n s.chainStore.length = numChains\n s.chainStore.count = numChains\n s.chainStore.entityIndex = new Uint16Array(numChains)\n s.chainStore.modelIndex = cModelIndex\n s.chainStore.residueOffset = cGroupOffset\n s.chainStore.residueCount = cGroupCount\n s.chainStore.chainname = sd.chainNameList.subarray(0, numChains * 4)\n s.chainStore.chainid = sd.chainIdList.subarray(0, numChains * 4)\n\n s.modelStore.length = numModels\n s.modelStore.count = numModels\n s.modelStore.chainOffset = mChainOffset\n s.modelStore.chainCount = mChainCount\n\n //\n\n let groupTypeDict: {[k: number]: any} = {}\n for (i = 0, il = sd.groupList.length; i < il; ++i) {\n const groupType = sd.groupList[ i ]\n const atomTypeIdList: number[] = []\n for (j = 0, jl = groupType.atomNameList.length; j < jl; ++j) {\n const element = groupType.elementList[ j ].toUpperCase()\n const atomname = groupType.atomNameList[ j ]\n atomTypeIdList.push(s.atomMap.add(atomname, element))\n }\n const chemCompType = groupType.chemCompType.toUpperCase()\n const hetFlag = ChemCompHetero.includes(chemCompType)\n\n const numGroupBonds = groupType.bondOrderList.length\n const atomIndices1 = new Array(numGroupBonds)\n const atomIndices2 = new Array(numGroupBonds)\n for (j = 0; j < numGroupBonds; ++j) {\n atomIndices1[ j ] = groupType.bondAtomList[ j * 2 ]\n atomIndices2[ j ] = groupType.bondAtomList[ j * 2 + 1 ]\n }\n const bonds = {\n atomIndices1: atomIndices1,\n atomIndices2: atomIndices2,\n bondOrders: groupType.bondOrderList\n }\n\n groupTypeDict[ i ] = s.residueMap.add(\n groupType.groupName, atomTypeIdList, hetFlag, chemCompType, bonds\n )\n }\n\n for (i = 0, il = numGroups; i < il; ++i) {\n s.residueStore.residueTypeId[ i ] = groupTypeDict[ s.residueStore.residueTypeId[ i ] ]\n }\n\n for (i = 0, il = s.atomStore.count; i < il; ++i) {\n const residueIndex = s.atomStore.residueIndex[ i ]\n const residueType = s.residueMap.list[ s.residueStore.residueTypeId[ residueIndex ] ]\n const resAtomOffset = s.residueStore.atomOffset[ residueIndex ]\n s.atomStore.atomTypeId[ i ] = residueType.atomTypeIdList[ i - resAtomOffset ]\n }\n\n if (sd.secStructList) {\n const secStructLength: number = sd.secStructList.length\n for (i = 0, il = s.residueStore.count; i < il; ++i) {\n // with ( i % secStructLength ) secStruct entries are reused\n const sstruc = SstrucMap[ s.residueStore.sstruc[ i % secStructLength ] ]\n if (sstruc !== undefined) s.residueStore.sstruc[ i ] = sstruc\n }\n }\n\n //\n\n if (sd.entityList) {\n sd.entityList.forEach(function (e: Entity, i: number) {\n s.entityList[ i ] = new Entity(\n s, i, e.description, e.type, e.chainIndexList\n )\n })\n }\n\n if (sd.bioAssemblyList) {\n sd.bioAssemblyList.forEach(function (_assembly: any, k: number) {\n const id = k + 1\n const assembly = new Assembly('' + id)\n s.biomolDict[ 'BU' + id ] = assembly\n let chainToPart: {[k: string]: AssemblyPart} = {}\n _assembly.transformList.forEach(function (_transform: any) {\n const matrix = new Matrix4().fromArray(_transform.matrix).transpose()\n const chainList: string[] = _transform.chainIndexList.map(function (chainIndex: number) {\n let chainname = ''\n for (let k = 0; k < 4; ++k) {\n const code = sd.chainNameList[ chainIndex * 4 + k ]\n if (code) {\n chainname += String.fromCharCode(code)\n } else {\n break\n }\n }\n return chainname\n })\n const part = chainToPart[ chainList.toString() ]\n if (part) {\n part.matrixList.push(matrix)\n } else {\n chainToPart[ chainList.toString() ] = assembly.addPart([ matrix ], chainList)\n }\n })\n })\n }\n\n if (sd.ncsOperatorList) {\n const ncsName = 'NCS'\n const ncsAssembly = new Assembly(ncsName)\n const ncsPart = ncsAssembly.addPart()\n sd.ncsOperatorList.forEach(function (_operator: number[]) {\n const matrix = new Matrix4().fromArray(_operator).transpose()\n ncsPart.matrixList.push(matrix)\n })\n if (ncsPart.matrixList.length > 0) {\n s.biomolDict[ ncsName ] = ncsAssembly\n }\n }\n\n const uc = sd.unitCell\n if (uc && Array.isArray(uc) && uc[ 0 ]) {\n s.unitcell = new Unitcell({\n a: uc[ 0 ],\n b: uc[ 1 ],\n c: uc[ 2 ],\n alpha: uc[ 3 ],\n beta: uc[ 4 ],\n gamma: uc[ 5 ],\n spacegroup: sd.spaceGroup\n })\n } else {\n s.unitcell = undefined\n }\n\n // calculate backbone bonds\n calculateBondsBetween(s, true)\n\n // calculate rung bonds\n calculateBondsWithin(s, true)\n\n s.finalizeAtoms()\n s.finalizeBonds()\n\n buildUnitcellAssembly(s)\n\n if (Debug) Log.timeEnd('MmtfParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('mmtf', MmtfParser)\n\nexport default MmtfParser\n","/**\n * @file Mol2 Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport {\n assignResidueTypeBonds,\n calculateChainnames, calculateSecondaryStructure,\n calculateBondsBetween, calculateBondsWithin\n} from '../structure/structure-utils'\nimport StructureParser from './structure-parser'\n\nconst reWhitespace = /\\s+/\nconst bondTypes: {[k: string]: number} = {\n '1': 1,\n '2': 2,\n '3': 3,\n 'am': 1, // amide\n 'ar': 1, // aromatic\n 'du': 1, // dummy\n 'un': 1, // unknown\n 'nc': 0 // not connected\n}\n\nclass Mol2Parser extends StructureParser {\n get type () { return 'mol2' }\n\n _parse () {\n // http://paulbourke.net/dataformats/mol2/\n\n if (Debug) Log.time('Mol2Parser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n const firstModelOnly = this.firstModelOnly\n const asTrajectory = this.asTrajectory\n\n const frames = s.frames\n let doFrames = false\n let currentFrame: Float32Array, currentCoord: number\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.resize(Math.round(this.streamer.data.length / 60))\n atomStore.addField('partialCharge', 1, 'float32')\n\n let idx = 0\n let moleculeLineNo = 0\n let modelAtomIdxStart = 0\n let modelIdx = -1\n let numAtoms = 0\n\n let currentRecordType = 0\n let moleculeRecordType = 1\n let atomRecordType = 2\n let bondRecordType = 3\n\n const ap1 = s.getAtomProxy()\n const ap2 = s.getAtomProxy()\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ].trim()\n\n if (line === '' || line[ 0 ] === '#') continue\n\n if (line[ 0 ] === '@') {\n if (line === '@MOLECULE') {\n currentRecordType = moleculeRecordType\n moleculeLineNo = 0\n\n ++modelIdx\n } else if (line === '@ATOM') {\n currentRecordType = atomRecordType\n modelAtomIdxStart = atomStore.count\n\n if (asTrajectory) {\n currentCoord = 0\n currentFrame = new Float32Array(numAtoms * 3)\n frames.push(currentFrame)\n\n if (modelIdx > 0) doFrames = true\n }\n } else if (line === '@BOND') {\n currentRecordType = bondRecordType\n } else {\n currentRecordType = 0\n }\n } else if (currentRecordType === moleculeRecordType) {\n if (moleculeLineNo === 0) {\n s.title = line\n s.id = line\n } else if (moleculeLineNo === 1) {\n const ls = line.split(reWhitespace)\n numAtoms = parseInt(ls[ 0 ])\n // num_atoms [num_bonds [num_subst [num_feat [num_sets]]]]\n } else if (moleculeLineNo === 2) {\n\n // const molType = line;\n // SMALL, BIOPOLYMER, PROTEIN, NUCLEIC_ACID, SACCHARIDE\n\n } else if (moleculeLineNo === 3) {\n\n // const chargeType = line;\n // NO_CHARGES, DEL_RE, GASTEIGER, GAST_HUCK, HUCKEL,\n // PULLMAN, GAUSS80_CHARGES, AMPAC_CHARGES,\n // MULLIKEN_CHARGES, DICT_ CHARGES, MMFF94_CHARGES,\n // USER_CHARGES\n\n } else if (moleculeLineNo === 4) {\n\n // const statusBits = line;\n\n } else if (moleculeLineNo === 5) {\n\n // const molComment = line;\n\n }\n\n ++moleculeLineNo\n } else if (currentRecordType === atomRecordType) {\n const ls = line.split(reWhitespace)\n\n if (firstModelOnly && modelIdx > 0) continue\n\n const x = parseFloat(ls[ 2 ])\n const y = parseFloat(ls[ 3 ])\n const z = parseFloat(ls[ 4 ])\n\n if (asTrajectory) {\n const j = currentCoord * 3\n\n currentFrame[ j + 0 ] = x\n currentFrame[ j + 1 ] = y\n currentFrame[ j + 2 ] = z\n\n currentCoord += 1\n\n if (doFrames) continue\n }\n\n const serial = ls[ 0 ]\n const atomname = ls[ 1 ]\n const element = ls[ 5 ].split('.')[ 0 ]\n const resno = ls[ 6 ] ? parseInt(ls[ 6 ]) : 1\n const resname = ls[ 7 ] ? ls[ 7 ] : ''\n const partialCharge = ls[ 8 ] ? parseFloat(ls[ 8 ]) : 0.0\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname, element)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = serial\n atomStore.partialCharge[ idx ] = partialCharge\n\n sb.addAtom(modelIdx, '', '', resname, resno, true)\n\n idx += 1\n } else if (currentRecordType === bondRecordType) {\n if (firstModelOnly && modelIdx > 0) continue\n if (asTrajectory && modelIdx > 0) continue\n\n const ls = line.split(reWhitespace)\n\n // ls[ 0 ] is bond id\n ap1.index = parseInt(ls[ 1 ]) - 1 + modelAtomIdxStart\n ap2.index = parseInt(ls[ 2 ]) - 1 + modelAtomIdxStart\n const order = bondTypes[ ls[ 3 ] ]\n\n s.bondStore.addBond(ap1, ap2, order)\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n sb.finalize()\n s.finalizeAtoms()\n calculateChainnames(s)\n calculateBondsWithin(s, true)\n calculateBondsBetween(s, true)\n s.finalizeBonds()\n assignResidueTypeBonds(s)\n calculateSecondaryStructure(s)\n\n if (Debug) Log.timeEnd('Mol2Parser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('mol2', Mol2Parser)\n\nexport default Mol2Parser\n","/**\n * @file Pdbqt Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport PdbParser from './pdb-parser'\n\n// autodock variant of PDB format with\n// - atom partial charges (empty column in pdb format)\n// - atom types (bfactor column in pdb format)\n// http://autodock.scripps.edu/faqs-help/faq/what-is-the-format-of-a-pdbqt-file\n\nclass PdbqtParser extends PdbParser {\n get type () { return 'pdbqt' }\n}\n\nParserRegistry.add('pdbqt', PdbqtParser)\n\nexport default PdbqtParser\n","/**\n * @file Pqr Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport PdbParser from './pdb-parser'\n\n// http://www.poissonboltzmann.org/docs/file-format-info/\n\nclass PqrParser extends PdbParser {\n get type () { return 'pqr' }\n}\n\nParserRegistry.add('pqr', PqrParser)\n\nexport default PqrParser\n","/**\n * @file Sdf Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { assignResidueTypeBonds } from '../structure/structure-utils'\nimport StructureParser from './structure-parser'\n\nconst reItem = /> +<(.+)>/\n\nclass SdfParser extends StructureParser {\n get type () { return 'sdf' }\n\n _parse () {\n // https://en.wikipedia.org/wiki/Chemical_table_file#SDF\n // http://download.accelrys.com/freeware/ctfile-formats/ctfile-formats.zip\n\n if (Debug) Log.time('SdfParser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n const firstModelOnly = this.firstModelOnly\n const asTrajectory = this.asTrajectory\n\n const headerLines = this.streamer.peekLines(2)\n\n s.id = headerLines[ 0 ].trim()\n s.title = headerLines[ 1 ].trim()\n\n const frames = s.frames\n let doFrames = false\n let currentFrame: Float32Array, currentCoord: number\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.resize(Math.round(this.streamer.data.length / 50))\n atomStore.addField('formalCharge', 1, 'int8')\n\n const ap1 = s.getAtomProxy()\n const ap2 = s.getAtomProxy()\n\n let idx = 0\n let lineNo = 0 // for V2000: current line number in currently parsed Mol file\n let modelIdx = 0\n let modelAtomIdxStart = 0\n\n const sdfData: {[k: string]: string[]}[] = []\n let currentItem: string|boolean = false\n let currentData: {[k: string]: string[]} = {}\n let mItem: RegExpMatchArray | null\n s.extraData.sdf = sdfData\n\n let atomCount, bondCount, atomStart: number, atomEnd: number, bondStart: number, bondEnd: number, x: number, y: number, z: number, atomname: string, element: string, atomindex: number, order: number\n let isV3000 = false, isAtomBlock = false, isBondBlock = false\n let tokens: string[] = [], acc: string[] = []\n const atomindexToStoreindex = new Map()\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n\n if (isV3000 && line) {\n tokens = line.substring(7).split(' ')\n\n // Entity properties may extend over multiple lines (hanging line finishes with '-')\n // Tokens are accumulated to be processed at the same time for a given entity\n if (acc.length) {\n tokens = [...acc, ...tokens]\n acc = []\n }\n if (tokens[tokens.length - 1] === '-') {\n tokens.pop();\n acc = tokens;\n continue;\n }\n }\n\n if (line.substr(0, 4) === '$$$$') {\n lineNo = -1\n ++modelIdx\n modelAtomIdxStart = atomStore.count\n sdfData.push(currentData)\n currentData = {}\n currentItem = false\n isV3000 = false\n } else if (lineNo === 3) {\n isV3000 = line.indexOf(' V3000') > -1\n\n if (isV3000) {\n atomindexToStoreindex.clear()\n } else {\n\n atomCount = parseInt(line.substr(0, 3))\n bondCount = parseInt(line.substr(3, 3))\n\n atomStart = 4\n atomEnd = atomStart + atomCount\n bondStart = atomEnd\n bondEnd = bondStart + bondCount\n\n if (asTrajectory) {\n currentCoord = 0\n currentFrame = new Float32Array(atomCount * 3)\n frames.push(currentFrame)\n\n if (modelIdx > 0) doFrames = true\n }\n }\n } else if (isV3000 && tokens[0] === 'COUNTS') {\n atomCount = parseInt(tokens[1]);\n\n if (asTrajectory) {\n currentCoord = 0\n currentFrame = new Float32Array(atomCount * 3)\n frames.push(currentFrame)\n\n if (modelIdx > 0) doFrames = true\n }\n } else if (isV3000 && tokens.length == 2) {\n if (tokens[1] === 'ATOM') {\n if (tokens[0] === 'BEGIN') isAtomBlock = true\n else if (tokens[0] === 'END') isAtomBlock = false\n } else if (tokens[1] === 'BOND') {\n if (tokens[0] === 'BEGIN') isBondBlock = true\n else if (tokens[0] === 'END') isBondBlock = false\n }\n } else if (\n isAtomBlock \n || (!isV3000 && lineNo >= atomStart && lineNo < atomEnd)\n ) {\n if (firstModelOnly && modelIdx > 0) continue\n\n let charge = 0\n if (isV3000) {\n x = parseFloat(tokens[2])\n y = parseFloat(tokens[3])\n z = parseFloat(tokens[4])\n\n element = tokens[1]\n atomindex = parseInt(tokens[0])\n atomindexToStoreindex.set(atomindex, idx)\n atomname = element + atomindex\n\n if (tokens.length > 6) {\n let chgTok = tokens.slice(6).find(t => t.indexOf('CHG=') === 0);\n if (chgTok) {\n charge = parseInt(chgTok.substring(4))\n }\n }\n } else {\n x = parseFloat(line.substr(0, 10))\n y = parseFloat(line.substr(10, 10))\n z = parseFloat(line.substr(20, 10))\n\n element = line.substr(31, 3).trim()\n atomname = element + (idx - modelAtomIdxStart + 1)\n }\n\n if (asTrajectory) {\n const j = currentCoord * 3\n\n currentFrame[ j + 0 ] = x\n currentFrame[ j + 1 ] = y\n currentFrame[ j + 2 ] = z\n\n currentCoord += 1\n\n if (doFrames) continue\n }\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname, element)\n\n atomStore.x[ idx ] = x\n atomStore.y[ idx ] = y\n atomStore.z[ idx ] = z\n atomStore.serial[ idx ] = isV3000 ? atomindex : idx\n atomStore.formalCharge[ idx ] = charge\n\n sb.addAtom(modelIdx, '', '', 'HET', 1, true)\n\n idx += 1\n } else if (\n isBondBlock \n || (!isV3000 && lineNo >= bondStart && lineNo < bondEnd)\n ) {\n if (firstModelOnly && modelIdx > 0) continue\n if (asTrajectory && modelIdx > 0) continue\n\n if (isV3000) {\n ap1.index = atomindexToStoreindex.get(parseInt(tokens[2]))\n ap2.index = atomindexToStoreindex.get(parseInt(tokens[3]))\n order = parseInt(tokens[1])\n } else {\n ap1.index = parseInt(line.substr(0, 3)) - 1 + modelAtomIdxStart\n ap2.index = parseInt(line.substr(3, 3)) - 1 + modelAtomIdxStart\n order = parseInt(line.substr(6, 3))\n }\n\n s.bondStore.addBond(ap1, ap2, order)\n } else if (line.substr(0, 6) === 'M CHG') {\n const chargeCount = parseInt(line.substr(6, 3))\n for (let ci = 0, coffset = 10; ci < chargeCount; ++ci, coffset += 8) {\n const aToken = parseInt(line.substr(coffset, 3))\n const atomIdx = aToken - 1 + modelAtomIdxStart\n const cToken = parseInt(line.substr(coffset + 4, 3))\n atomStore.formalCharge[ atomIdx ] = cToken\n }\n // eslint-disable-next-line no-cond-assign\n } else if (line.charAt(0) === '>' && (mItem = line.match(reItem))) {\n currentItem = mItem[ 1 ]\n currentData[ currentItem ] = []\n } else if (currentItem !== false && line) {\n currentData[ currentItem ].push(line)\n }\n\n ++lineNo\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n assignResidueTypeBonds(s)\n\n if (Debug) Log.timeEnd('SdfParser._parse ' + this.name)\n }\n\n _postProcess () {\n assignResidueTypeBonds(this.structure)\n }\n}\n\nParserRegistry.add('sdf', SdfParser)\nParserRegistry.add('sd', SdfParser)\nParserRegistry.add('mol', SdfParser)\n\nexport default SdfParser\n","/**\n * @file Prmtop Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport {\n assignResidueTypeBonds, calculateBondsBetween,\n calculateBondsWithin, calculateChainnames\n} from '../structure/structure-utils'\n\nconst amberChargeUnitFactor = 18.2223\n\nconst enum Mode {\n Title,\n Pointers,\n AtomName,\n Charge,\n Mass,\n ResidueLabel,\n ResiduePointer,\n BondsIncHydrogen,\n BondsWithoutHydrogen,\n Radii\n}\n\nfunction parseIntSubstr (line: string, start: number, length: number) {\n return parseInt(line.substr(start, length).trim())\n}\n\nclass PrmtopParser extends StructureParser {\n get type () { return 'prmtop' }\n\n _parse () {\n // http://ambermd.org/prmtop.pdf\n // http://ambermd.org/formats.html#topology\n\n if (Debug) Log.time('PrmtopParser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n //\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.addField('partialCharge', 1, 'float32')\n atomStore.addField('radius', 1, 'float32')\n\n const title: string[] = []\n const pointersDict: {[k: string]: number} = {}\n const pointers = [\n 'NATOM', 'NTYPES', 'NBONH', 'MBONA', 'NTHETH', 'MTHETA',\n 'NPHIH', 'MPHIA', 'NHPARM', 'NPARM', 'NNB', 'NRES',\n 'NBONA', 'NTHETA', 'NPHIA', 'NUMBND', 'NUMANG', 'NPTRA',\n 'NATYP', 'NPHB', 'IFPERT', 'NBPER', 'NGPER', 'NDPER',\n 'MBPER', 'MGPER', 'MDPER', 'IFBOX', 'NMXRS', 'IFCAP',\n 'NUMEXTRA', 'NCOPY'\n ]\n pointers.forEach(name => { pointersDict[ name ] = 0 })\n\n let atomNames: string[]\n let charges: Float32Array\n let radii: Float32Array\n let bAtomIndex1: Uint32Array\n let bAtomIndex2: Uint32Array\n let bBondOrder: Uint8Array = new Uint8Array(0)\n let residueLabels: string[]\n let residuePointers: Uint32Array\n\n let mode: number|undefined\n // let currentFormat\n let curIdx: number\n let bondIdx: number\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n const lt = line.trim()\n\n if (!lt) {\n continue\n } else if (line.startsWith('%FORMAT')) {\n // currentFormat = lt.substring(8, lt.length - 1)\n } else if (line.startsWith('%FLAG')) {\n const flag = line.substr(5).trim()\n curIdx = 0\n\n if (flag === 'TITLE') {\n mode = Mode.Title\n } else if (flag === 'POINTERS') {\n mode = Mode.Pointers\n } else if (flag === 'ATOM_NAME') {\n mode = Mode.AtomName\n } else if (flag === 'CHARGE') {\n mode = Mode.Charge\n } else if (flag === 'MASS') {\n mode = Mode.Mass\n } else if (flag === 'RESIDUE_LABEL') {\n mode = Mode.ResidueLabel\n } else if (flag === 'RESIDUE_POINTER') {\n mode = Mode.ResiduePointer\n } else if (flag === 'BONDS_INC_HYDROGEN') {\n bondIdx = 0\n mode = Mode.BondsIncHydrogen\n } else if (flag === 'BONDS_WITHOUT_HYDROGEN') {\n bondIdx = pointersDict['NBONH']\n mode = Mode.BondsWithoutHydrogen\n } else if (flag === 'RADII') {\n mode = Mode.Radii\n } else {\n mode = undefined\n }\n } else if (mode === Mode.Title) {\n title.push(lt)\n } else if (mode === Mode.Pointers) {\n const n = Math.min(curIdx + 10, 32)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n pointersDict[pointers[curIdx]] = parseInt(\n line.substr(i * 8, 8).trim()\n )\n }\n atomNames = new Array(pointersDict.NATOM)\n charges = new Float32Array(pointersDict.NATOM)\n radii = new Float32Array(pointersDict.NATOM)\n atomStore.resize(pointersDict.NATOM)\n const bondCount = pointersDict.NBONH + pointersDict.MBONA\n bAtomIndex1 = new Uint32Array(bondCount)\n bAtomIndex2 = new Uint32Array(bondCount)\n bBondOrder = new Uint8Array(bondCount)\n residueLabels = new Array(pointersDict.NRES)\n residuePointers = new Uint32Array(pointersDict.NRES)\n } else if (mode === Mode.AtomName) {\n const n = Math.min(curIdx + 20, pointersDict.NATOM)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n atomNames[curIdx] = line.substr(i * 4, 4).trim()\n }\n } else if (mode === Mode.Charge) {\n const n = Math.min(curIdx + 5, pointersDict.NATOM)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n charges[curIdx] = parseFloat(line.substr(i * 16, 16)) / amberChargeUnitFactor\n }\n } else if (mode === Mode.Mass) {\n\n // not currently used\n\n } else if (mode === Mode.ResidueLabel) {\n const n = Math.min(curIdx + 20, pointersDict.NRES)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n residueLabels[curIdx] = line.substr(i * 4, 4).trim()\n }\n } else if (mode === Mode.ResiduePointer) {\n const n = Math.min(curIdx + 10, pointersDict.NRES)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n residuePointers[curIdx] = parseIntSubstr(line, i * 8, 8)\n }\n } else if (mode === Mode.BondsIncHydrogen) {\n const n = Math.min(curIdx + 10, pointersDict.NBONH * 3)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n const r = curIdx % 3\n if (r === 0) {\n bAtomIndex1[bondIdx] = parseIntSubstr(line, i * 8, 8) / 3\n } if (r === 1) {\n bAtomIndex2[bondIdx] = parseIntSubstr(line, i * 8, 8) / 3\n bBondOrder[bondIdx] = 1\n ++bondIdx\n }\n }\n } else if (mode === Mode.BondsWithoutHydrogen) {\n const n = Math.min(curIdx + 10, pointersDict.MBONA * 3)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n const r = curIdx % 3\n if (r === 0) {\n bAtomIndex1[bondIdx] = parseIntSubstr(line, i * 8, 8) / 3\n } if (r === 1) {\n bAtomIndex2[bondIdx] = parseIntSubstr(line, i * 8, 8) / 3\n bBondOrder[bondIdx] = 1\n ++bondIdx\n }\n }\n } else if (mode === Mode.Radii) {\n const n = Math.min(curIdx + 5, pointersDict.NATOM)\n for (let i = 0; curIdx < n; ++i, ++curIdx) {\n radii[curIdx] = parseFloat(line.substr(i * 16, 16))\n }\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n s.title = title.join(' ')\n\n const atomCount = pointersDict.NATOM\n let curResIdx = 0\n let curResname = residueLabels![0]\n let curResno = 1\n for (let i = 0; i < atomCount; ++i) {\n if (i + 1 === residuePointers![curResIdx + 1]) {\n ++curResIdx\n curResname = residueLabels![curResIdx]\n curResno = curResIdx + 1\n }\n atomStore.atomTypeId[i] = atomMap.add(atomNames![i])\n atomStore.serial[i] = i + 1\n sb.addAtom(0, '', '', curResname, curResno, false)\n }\n\n atomStore.partialCharge.set(charges!)\n atomStore.radius.set(radii!)\n\n s.bondStore.length = bBondOrder!.length\n s.bondStore.count = bBondOrder!.length\n s.bondStore.atomIndex1 = bAtomIndex1!\n s.bondStore.atomIndex2 = bAtomIndex2!\n s.bondStore.bondOrder = bBondOrder\n\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n calculateBondsWithin(s, true)\n calculateBondsBetween(s, true, true)\n calculateChainnames(s, true)\n assignResidueTypeBonds(s)\n\n if (Debug) Log.timeEnd('PrmtopParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('prmtop', PrmtopParser)\nParserRegistry.add('parm7', PrmtopParser)\n\nexport default PrmtopParser\n","/**\n * @file Psf Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport {\n assignResidueTypeBonds, calculateBondsBetween,\n calculateBondsWithin, getChainname\n} from '../structure/structure-utils'\n\nconst TitleMode = 1\nconst AtomMode = 2\nconst BondMode = 3\nconst AngleMode = 4\nconst DihedralMode = 5\nconst ImproperMode = 6\n\nconst reWhitespace = /\\s+/\nconst reTitle = /(^\\*|REMARK)*/\n\nclass PsfParser extends StructureParser {\n get type () { return 'psf' }\n\n _parse () {\n // http://www.ks.uiuc.edu/Training/Tutorials/namd/namd-tutorial-unix-html/node23.html\n\n if (Debug) Log.time('PsfParser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n //\n\n const atomMap = s.atomMap\n const atomStore = s.atomStore\n atomStore.addField('partialCharge', 1, 'float32')\n\n const title: string[] = []\n\n let mode: number|undefined\n let chainid: string\n let lastSegid: string\n let idx = 0\n let chainIdx = 0\n let bondIdx = 0\n let bAtomIndex1: Uint32Array, bAtomIndex2: Uint32Array, bBondOrder: Uint8Array\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ].trim()\n\n if (!line) {\n mode = undefined\n continue\n }\n\n if (mode === AtomMode) {\n const ls = line.split(reWhitespace)\n\n const serial = parseInt(ls[ 0 ])\n const segid = ls[ 1 ]\n const resno = parseInt(ls[ 2 ])\n const resname = ls[ 3 ]\n const atomname = ls[ 4 ]\n const charge = parseFloat(ls[ 6 ])\n\n if (segid !== lastSegid) {\n chainid = getChainname(chainIdx)\n ++chainIdx\n }\n\n atomStore.growIfFull()\n atomStore.atomTypeId[ idx ] = atomMap.add(atomname)\n\n atomStore.serial[ idx ] = serial\n atomStore.partialCharge[ idx ] = charge\n\n sb.addAtom(0, chainid, chainid, resname, resno, false)\n\n idx += 1\n lastSegid = segid\n } else if (mode === BondMode) {\n const ls = line.split(reWhitespace)\n\n for (let j = 0, m = ls.length; j < m; j += 2) {\n bAtomIndex1[ bondIdx ] = parseInt(ls[ j ]) - 1\n bAtomIndex2[ bondIdx ] = parseInt(ls[ j + 1 ]) - 1\n bBondOrder[ bondIdx ] = 1\n bondIdx += 1\n }\n } else if (mode === TitleMode) {\n title.push(line.replace(reTitle, '').trim())\n } else if (mode === AngleMode) {\n\n // currently not used\n\n } else if (mode === DihedralMode) {\n\n // currently not used\n\n } else if (mode === ImproperMode) {\n\n // currently not used\n\n } else if (line.includes('!NATOM')) {\n mode = AtomMode\n\n const numAtoms = parseInt(line.split(reWhitespace)[ 0 ])\n atomStore.resize(numAtoms)\n } else if (line.includes('!NBOND')) {\n mode = BondMode\n\n const numBonds = parseInt(line.split(reWhitespace)[ 0 ])\n bAtomIndex1 = new Uint32Array(numBonds)\n bAtomIndex2 = new Uint32Array(numBonds)\n bBondOrder = new Uint8Array(numBonds)\n } else if (line.includes('!NTITLE')) {\n mode = TitleMode\n } else if (line.includes('!NTHETA')) {\n mode = AngleMode\n } else if (line.includes('!NPHI')) {\n mode = DihedralMode\n } else if (line.includes('!NIMPHI')) {\n mode = ImproperMode\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n s.title = title.join(' ')\n\n s.bondStore.length = bBondOrder!.length\n s.bondStore.count = bondIdx\n s.bondStore.atomIndex1 = bAtomIndex1!\n s.bondStore.atomIndex2 = bAtomIndex2!\n s.bondStore.bondOrder = bBondOrder!\n\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n calculateBondsWithin(s, true)\n calculateBondsBetween(s, true, true)\n assignResidueTypeBonds(s)\n\n if (Debug) Log.timeEnd('PsfParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('psf', PsfParser)\n\nexport default PsfParser\n","/**\n * @file Top Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport StructureParser from './structure-parser'\nimport { WaterNames } from '../structure/structure-constants'\nimport {\n assignResidueTypeBonds, calculateBondsBetween,\n calculateBondsWithin, getChainname\n} from '../structure/structure-utils'\n\nconst enum Mode {\n System,\n Molecules,\n Moleculetype,\n Atoms,\n Bonds\n}\n\nconst reField = /\\[ (.+) \\]/\nconst reWhitespace = /\\s+/\n\nclass TopParser extends StructureParser {\n get type () { return 'top' }\n\n _parse () {\n // http://manual.gromacs.org/online/top.html\n\n if (Debug) Log.time('TopParser._parse ' + this.name)\n\n const s = this.structure\n const sb = this.structureBuilder\n\n //\n\n const atomMap = s.atomMap\n const bondStore = s.bondStore\n\n const atomStore = s.atomStore\n atomStore.addField('partialCharge', 1, 'float32')\n\n const molecules: [string, number][] = []\n const moleculetypeDict: {[k: string]: {atoms: any[], bonds: any[] }} = {}\n\n let currentMoleculetype: {\n atoms: [number, string, string, number][],\n bonds: [number, number][]\n }\n let mode: number|undefined\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n let lt = line.trim()\n\n if (!lt || lt[0] === '*' || lt[0] === ';') {\n continue\n }\n\n if (lt.startsWith('#include')) {\n throw new Error('TopParser: #include statements not allowed')\n }\n\n const fieldMatch = line.match(reField)\n if (fieldMatch !== null) {\n const name = fieldMatch[1]\n if (name === 'moleculetype') {\n mode = Mode.Moleculetype\n currentMoleculetype = {\n atoms: [],\n bonds: []\n }\n } else if (name === 'atoms') {\n mode = Mode.Atoms\n } else if (name === 'bonds') {\n mode = Mode.Bonds\n } else if (name === 'system') {\n mode = Mode.System\n } else if (name === 'molecules') {\n mode = Mode.Molecules\n } else {\n mode = undefined\n }\n continue\n }\n\n const cIdx = lt.indexOf(';')\n if (cIdx !== -1) {\n lt = lt.substring(0, cIdx).trim()\n }\n if (mode === Mode.Moleculetype) {\n const molName = lt.split(reWhitespace)[0]\n moleculetypeDict[molName] = currentMoleculetype\n } else if (mode === Mode.Atoms) {\n const ls = lt.split(reWhitespace)\n currentMoleculetype.atoms.push([\n parseInt(ls[2]), // resnr\n ls[3], // residue\n ls[4], // atom\n parseFloat(ls[6]) // charge\n ])\n } else if (mode === Mode.Bonds) {\n const ls = lt.split(reWhitespace)\n currentMoleculetype.bonds.push([\n parseInt(ls[0]), // ai\n parseInt(ls[1]) // aj\n ])\n } else if (mode === Mode.System) {\n s.title = lt\n } else if (mode === Mode.Molecules) {\n const ls = lt.split(reWhitespace)\n molecules.push([\n ls[0], // name\n parseInt(ls[1]) // count\n ])\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n let atomCount = 0\n let bondCount = 0\n molecules.forEach(function (val) {\n const [name, molCount] = val\n const molType = moleculetypeDict[name]\n atomCount += molCount * molType.atoms.length\n bondCount += molCount * molType.bonds.length\n })\n\n atomStore.resize(atomCount)\n bondStore.resize(bondCount)\n\n let atomIdx = 0\n let resIdx = 0\n let chainidIdx = 0\n let chainnameIdx = 0\n let bondIdx = 0\n let atomOffset = 0\n let lastResno: number\n\n molecules.forEach(function (val) {\n const [name, molCount] = val\n const molType = moleculetypeDict[name]\n const chainname = getChainname(chainnameIdx)\n for (let i = 0; i < molCount; ++i) {\n lastResno = -1\n const chainid = WaterNames.includes(name) ? chainname : getChainname(chainidIdx)\n molType.atoms.forEach(function (atomData) {\n const [resno, resname, atomname, charge] = atomData\n if (resno !== lastResno) {\n ++resIdx\n }\n atomStore.atomTypeId[atomIdx] = atomMap.add(atomname)\n atomStore.serial[atomIdx] = atomIdx + 1\n atomStore.partialCharge[atomIdx] = charge\n sb.addAtom(0, chainname, chainid, resname, resIdx + 1, false)\n ++atomIdx\n lastResno = resno\n })\n molType.bonds.forEach(function (bondData) {\n bondStore.atomIndex1[bondIdx] = atomOffset + bondData[0] - 1\n bondStore.atomIndex2[bondIdx] = atomOffset + bondData[1] - 1\n ++bondIdx\n })\n ++chainidIdx\n atomOffset += molType.atoms.length\n }\n ++chainnameIdx\n })\n\n bondStore.count = bondCount\n\n sb.finalize()\n s.finalizeAtoms()\n s.finalizeBonds()\n calculateBondsWithin(s, true)\n calculateBondsBetween(s, true, true)\n assignResidueTypeBonds(s)\n\n if (Debug) Log.timeEnd('TopParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('top', TopParser)\n\nexport default TopParser\n","/**\n * @file Trajectory Parser\n * @author Alexander Rose \n * @private\n */\n\nimport Parser, { ParserParameters } from './parser'\nimport Frames from '../trajectory/frames'\nimport Streamer from '../streamer/streamer';\n\nclass TrajectoryParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n super(streamer, params)\n\n this.frames = new Frames(this.name, this.path)\n }\n\n get type () { return 'trajectory' }\n get __objName () { return 'frames' }\n}\n\nexport default TrajectoryParser\n","/**\n * @file Netcdf Reader\n * @author Alexander Rose \n * @private\n *\n * Adapted from https://github.com/cheminfo-js/netcdfjs\n * MIT License, Copyright (c) 2016 cheminfo\n */\n\nimport IOBuffer from './io-buffer'\n\nexport interface NetCDFRecordDimension {\n length: number,\n id?: number,\n name?: string,\n recordStep?: number\n}\n\nexport interface NetCDFHeader {\n recordDimension: NetCDFRecordDimension,\n version: number,\n dimensions: any[],\n globalAttributes: any[],\n variables: any[]\n}\n\nexport interface NetCDFDimension {\n name: string,\n size: number\n}\n\n/**\n * Throws a non-valid NetCDF exception if the statement it's true\n * @ignore\n * @param {boolean} statement - Throws if true\n * @param {string} reason - Reason to throw\n */\nfunction notNetcdf (statement: boolean, reason: string) {\n if (statement) {\n throw new TypeError('Not a valid NetCDF v3.x file: ' + reason)\n }\n}\n\n/**\n * Moves 1, 2, or 3 bytes to next 4-byte boundary\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n */\nfunction padding (buffer: IOBuffer) {\n if ((buffer.offset % 4) !== 0) {\n buffer.skip(4 - (buffer.offset % 4))\n }\n}\n\n/**\n * Reads the name\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @return {string} - Name\n */\nfunction readName (buffer: IOBuffer) {\n // Read name\n const nameLength = buffer.readUint32()\n const name = buffer.readChars(nameLength)\n\n // validate name\n // TODO\n\n // Apply padding\n padding(buffer)\n return name\n}\n\nconst types = {\n BYTE: 1,\n CHAR: 2,\n SHORT: 3,\n INT: 4,\n FLOAT: 5,\n DOUBLE: 6\n}\n\n/**\n * Parse a number into their respective type\n * @ignore\n * @param {number} type - integer that represents the type\n * @return {string} - parsed value of the type\n */\nfunction num2str (type: number) {\n switch (Number(type)) {\n case types.BYTE:\n return 'byte'\n case types.CHAR:\n return 'char'\n case types.SHORT:\n return 'short'\n case types.INT:\n return 'int'\n case types.FLOAT:\n return 'float'\n case types.DOUBLE:\n return 'double'\n default:\n return 'undefined'\n }\n}\n\n/**\n * Parse a number type identifier to his size in bytes\n * @ignore\n * @param {number} type - integer that represents the type\n * @return {number} -size of the type\n */\nfunction num2bytes (type: number) {\n switch (Number(type)) {\n case types.BYTE:\n return 1\n case types.CHAR:\n return 1\n case types.SHORT:\n return 2\n case types.INT:\n return 4\n case types.FLOAT:\n return 4\n case types.DOUBLE:\n return 8\n default:\n return -1\n }\n}\n\n/**\n * Reverse search of num2str\n * @ignore\n * @param {string} type - string that represents the type\n * @return {number} - parsed value of the type\n */\nfunction str2num (type: string) {\n switch (String(type)) {\n case 'byte':\n return types.BYTE\n case 'char':\n return types.CHAR\n case 'short':\n return types.SHORT\n case 'int':\n return types.INT\n case 'float':\n return types.FLOAT\n case 'double':\n return types.DOUBLE\n default:\n return -1\n }\n}\n\n/**\n * Auxiliary function to read numeric data\n * @ignore\n * @param {number} size - Size of the element to read\n * @param {function} bufferReader - Function to read next value\n * @return {Array|number}\n */\nfunction readNumber (size: number, bufferReader: Function) {\n if (size !== 1) {\n const numbers = new Array(size)\n for (let i = 0; i < size; i++) {\n numbers[i] = bufferReader()\n }\n return numbers\n } else {\n return bufferReader()\n }\n}\n\n/**\n * Given a type and a size reads the next element\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {number} type - Type of the data to read\n * @param {number} size - Size of the element to read\n * @return {string|Array|number}\n */\nfunction readType (buffer: IOBuffer, type: number, size: number) {\n switch (type) {\n case types.BYTE:\n return buffer.readBytes(size)\n case types.CHAR:\n return trimNull(buffer.readChars(size))\n case types.SHORT:\n return readNumber(size, buffer.readInt16.bind(buffer))\n case types.INT:\n return readNumber(size, buffer.readInt32.bind(buffer))\n case types.FLOAT:\n return readNumber(size, buffer.readFloat32.bind(buffer))\n case types.DOUBLE:\n return readNumber(size, buffer.readFloat64.bind(buffer))\n default:\n notNetcdf(true, 'non valid type ' + type)\n return undefined\n }\n}\n\n/**\n * Removes null terminate value\n * @ignore\n * @param {string} value - String to trim\n * @return {string} - Trimmed string\n */\nfunction trimNull (value: string) {\n if (value.charCodeAt(value.length - 1) === 0) {\n return value.substring(0, value.length - 1)\n }\n return value\n}\n\n// const STREAMING = 4294967295;\n\n/**\n * Read data for the given non-record variable\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {object} variable - Variable metadata\n * @return {Array} - Data of the element\n */\nfunction nonRecord (buffer: IOBuffer, variable: {type: string, size: number}) {\n // variable type\n const type = str2num(variable.type)\n\n // size of the data\n const size = variable.size / num2bytes(type)\n\n // iterates over the data\n const data = new Array(size)\n for (let i = 0; i < size; i++) {\n data[i] = readType(buffer, type, 1)\n }\n\n return data\n}\n\n/**\n * Read data for the given record variable\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {object} variable - Variable metadata\n * @param {object} recordDimension - Record dimension metadata\n * @return {Array} - Data of the element\n */\nfunction record (buffer:IOBuffer, variable: {type: string, size: number}, recordDimension: NetCDFRecordDimension) {\n // variable type\n const type = str2num(variable.type)\n const width = variable.size ? variable.size / num2bytes(type) : 1\n\n // size of the data\n // TODO streaming data\n const size = recordDimension.length\n\n // iterates over the data\n const data = new Array(size)\n const step = recordDimension.recordStep\n\n for (let i = 0; i < size; i++) {\n const currentOffset = buffer.offset\n data[i] = readType(buffer, type, width)\n buffer.seek(currentOffset + step!)\n }\n\n return data\n}\n\n// Grammar constants\nconst ZERO = 0\nconst NC_DIMENSION = 10\nconst NC_VARIABLE = 11\nconst NC_ATTRIBUTE = 12\n\n/**\n * Read the header of the file\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {number} version - Version of the file\n * @return {object} - Object with the fields:\n * * `recordDimension`: Number with the length of record dimension\n * * `dimensions`: List of dimensions\n * * `globalAttributes`: List of global attributes\n * * `variables`: List of variables\n */\nfunction header (buffer: IOBuffer, version: number) {\n // Length of record dimension\n // sum of the varSize's of all the record variables.\n const header: Partial = {recordDimension: {length: buffer.readUint32()}}\n\n // Version\n header.version = version\n\n // List of dimensions\n const dimList = dimensionsList(buffer) as {dimensions: NetCDFDimension[], recordId: number, recordName: string}\n header.recordDimension!.id = dimList.recordId\n header.recordDimension!.name = dimList.recordName\n header.dimensions = dimList.dimensions\n\n // List of global attributes\n header.globalAttributes = attributesList(buffer)\n\n // List of variables\n const variables = variablesList(buffer, dimList.recordId, version) as {variables: any[], recordStep: number}\n header.variables = variables.variables\n header.recordDimension!.recordStep = variables.recordStep\n\n return header\n}\n\n/**\n * List of dimensions\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @return {object} - List of dimensions and record dimension with:\n * * `name`: String with the name of the dimension\n * * `size`: Number with the size of the dimension\n */\nfunction dimensionsList (buffer: IOBuffer) {\n let dimensions: NetCDFDimension[], recordId, recordName\n const dimList = buffer.readUint32()\n if (dimList === ZERO) {\n notNetcdf((buffer.readUint32() !== ZERO), 'wrong empty tag for list of dimensions')\n return []\n } else {\n notNetcdf((dimList !== NC_DIMENSION), 'wrong tag for list of dimensions')\n\n // Length of dimensions\n const dimensionSize = buffer.readUint32()\n dimensions = new Array(dimensionSize)\n for (let dim = 0; dim < dimensionSize; dim++) {\n // Read name\n const name = readName(buffer)\n\n // Read dimension size\n const size = buffer.readUint32()\n if (size === 0) {\n recordId = dim\n recordName = name\n }\n\n dimensions[dim] = {\n name: name,\n size: size\n }\n }\n return {\n dimensions: dimensions,\n recordId: recordId,\n recordName: recordName\n }\n }\n}\n\n/**\n * List of attributes\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @return {Array} - List of attributes with:\n * * `name`: String with the name of the attribute\n * * `type`: String with the type of the attribute\n * * `value`: A number or string with the value of the attribute\n */\nfunction attributesList (buffer: IOBuffer) {\n let attributes\n const gAttList = buffer.readUint32()\n if (gAttList === ZERO) {\n notNetcdf((buffer.readUint32() !== ZERO), 'wrong empty tag for list of attributes')\n return []\n } else {\n notNetcdf((gAttList !== NC_ATTRIBUTE), 'wrong tag for list of attributes')\n\n // Length of attributes\n const attributeSize = buffer.readUint32()\n attributes = new Array(attributeSize)\n for (let gAtt = 0; gAtt < attributeSize; gAtt++) {\n // Read name\n const name = readName(buffer)\n\n // Read type\n const type = buffer.readUint32()\n notNetcdf(((type < 1) || (type > 6)), 'non valid type ' + type)\n\n // Read attribute\n const size = buffer.readUint32()\n const value = readType(buffer, type, size)\n\n // Apply padding\n padding(buffer)\n\n attributes[gAtt] = {\n name: name,\n type: num2str(type),\n value: value\n }\n }\n }\n return attributes\n}\n\n/**\n * List of variables\n * @ignore\n * @param {IOBuffer} buffer - Buffer for the file data\n * @param {number} recordId - Id if the record dimension\n * @param {number} version - Version of the file\n * @return {object} - Number of recordStep and list of variables with:\n * * `name`: String with the name of the variable\n * * `dimensions`: Array with the dimension IDs of the variable\n * * `attributes`: Array with the attributes of the variable\n * * `type`: String with the type of the variable\n * * `size`: Number with the size of the variable\n * * `offset`: Number with the offset where of the variable begins\n * * `record`: True if is a record variable, false otherwise\n */\nfunction variablesList (buffer: IOBuffer, recordId: number, version: number) {\n const varList = buffer.readUint32()\n let recordStep = 0\n let variables\n if (varList === ZERO) {\n notNetcdf(\n (buffer.readUint32() !== ZERO),\n 'wrong empty tag for list of variables'\n )\n return []\n } else {\n notNetcdf((varList !== NC_VARIABLE), 'wrong tag for list of variables')\n\n // Length of variables\n const variableSize = buffer.readUint32()\n variables = new Array(variableSize)\n for (let v = 0; v < variableSize; v++) {\n // Read name\n const name = readName(buffer)\n\n // Read dimensionality of the variable\n const dimensionality = buffer.readUint32()\n\n // Index into the list of dimensions\n const dimensionsIds = new Array(dimensionality)\n for (let dim = 0; dim < dimensionality; dim++) {\n dimensionsIds[dim] = buffer.readUint32()\n }\n\n // Read variables size\n const attributes = attributesList(buffer)\n\n // Read type\n const type = buffer.readUint32()\n notNetcdf(((type < 1) && (type > 6)), 'non valid type ' + type)\n\n // Read variable size\n // The 32-bit varSize field is not large enough to contain the\n // size of variables that require more than 2^32 - 4 bytes,\n // so 2^32 - 1 is used in the varSize field for such variables.\n const varSize = buffer.readUint32()\n\n // Read offset\n let offset = buffer.readUint32()\n if (version === 2) {\n notNetcdf((offset > 0), 'offsets larger than 4GB not supported')\n offset = buffer.readUint32()\n }\n\n // Count amount of record variables\n if (dimensionsIds[0] === recordId) {\n recordStep += varSize\n }\n\n variables[v] = {\n name: name,\n dimensions: dimensionsIds,\n attributes: attributes,\n type: num2str(type),\n size: varSize,\n offset: offset,\n record: (dimensionsIds[0] === recordId)\n }\n }\n }\n\n return {\n variables: variables,\n recordStep: recordStep\n }\n}\n\n/**\n * Reads a NetCDF v3.x file\n * https://www.unidata.ucar.edu/software/netcdf/docs/file_format_specifications.html\n */\nclass NetcdfReader {\n header: Partial\n buffer: IOBuffer\n /**\n * @param {ArrayBuffer} data - ArrayBuffer or any Typed Array with the data\n */\n constructor (data: ArrayBuffer) {\n const buffer = new IOBuffer(data)\n buffer.setBigEndian()\n\n // Validate that it's a NetCDF file\n notNetcdf((buffer.readChars(3) !== 'CDF'), 'should start with CDF')\n\n // Check the NetCDF format\n const version = buffer.readByte()\n notNetcdf((version > 2), 'unknown version')\n\n // Read the header\n this.header = header(buffer, version)\n this.buffer = buffer\n }\n\n /**\n * @return {string} - Version for the NetCDF format\n */\n get version () {\n if (this.header.version === 1) {\n return 'classic format'\n } else {\n return '64-bit offset format'\n }\n }\n\n /**\n * @return {object} - Metadata for the record dimension\n * * `length`: Number of elements in the record dimension\n * * `id`: Id number in the list of dimensions for the record dimension\n * * `name`: String with the name of the record dimension\n * * `recordStep`: Number with the record variables step size\n */\n get recordDimension () {\n return this.header.recordDimension\n }\n\n /**\n * @return {Array} - List of dimensions with:\n * * `name`: String with the name of the dimension\n * * `size`: Number with the size of the dimension\n */\n get dimensions () {\n return this.header.dimensions\n }\n\n /**\n * @return {Array} - List of global attributes with:\n * * `name`: String with the name of the attribute\n * * `type`: String with the type of the attribute\n * * `value`: A number or string with the value of the attribute\n */\n get globalAttributes () {\n return this.header.globalAttributes\n }\n\n /**\n * @return {Array} - List of variables with:\n * * `name`: String with the name of the variable\n * * `dimensions`: Array with the dimension IDs of the variable\n * * `attributes`: Array with the attributes of the variable\n * * `type`: String with the type of the variable\n * * `size`: Number with the size of the variable\n * * `offset`: Number with the offset where of the variable begins\n * * `record`: True if is a record variable, false otherwise\n */\n get variables () {\n return this.header.variables\n }\n\n /**\n * Checks if a variable is available\n * @param {string|object} variableName - Name of the variable to check\n * @return {Boolean} - Variable existence\n */\n hasDataVariable (variableName: string) {\n return this.header.variables!.findIndex(function (val) {\n return val.name === variableName\n }) !== -1\n }\n\n /**\n * Retrieves the data for a given variable\n * @param {string|object} variableName - Name of the variable to search or variable object\n * @return {Array} - List with the variable values\n */\n getDataVariable (variableName: string|{}) {\n let variable\n if (typeof variableName === 'string') {\n // search the variable\n variable = this.header.variables!.find(function (val) {\n return val.name === variableName\n })\n } else {\n variable = variableName\n }\n\n // throws if variable not found\n notNetcdf((variable === undefined), 'variable not found')\n\n // go to the offset position\n this.buffer.seek(variable.offset)\n\n if (variable.record) {\n // record variable case\n return record(this.buffer, variable, this.header.recordDimension!)\n } else {\n // non-record variable case\n return nonRecord(this.buffer, variable)\n }\n }\n}\n\nexport default NetcdfReader\n","/**\n * @file Dcd Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { uint8ToString, ensureBuffer } from '../utils'\nimport TrajectoryParser from './trajectory-parser'\n\nconst charmmTimeUnitFactor = 20.45482949774598\n\ninterface DcdHeader {\n NSET: number,\n ISTART: number,\n NSAVC: number,\n NAMNF: number,\n DELTA: number,\n TITLE: string,\n NATOM: number\n}\n\nclass DcdParser extends TrajectoryParser {\n get type () { return 'dcd' }\n get isBinary () { return true }\n\n _parse () {\n // http://www.ks.uiuc.edu/Research/vmd/plugins/molfile/dcdplugin.html\n\n // The DCD format is structured as follows\n // (FORTRAN UNFORMATTED, with Fortran data type descriptions):\n // HDR NSET ISTRT NSAVC 5-ZEROS NATOM-NFREAT DELTA 9-ZEROS\n // `CORD' #files step 1 step zeroes (zero) timestep (zeroes)\n // interval\n // C*4 INT INT INT 5INT INT DOUBLE 9INT\n // ==========================================================================\n // NTITLE TITLE\n // INT (=2) C*MAXTITL\n // (=32)\n // ==========================================================================\n // NATOM\n // #atoms\n // INT\n // ==========================================================================\n // X(I), I=1,NATOM (DOUBLE)\n // Y(I), I=1,NATOM\n // Z(I), I=1,NATOM\n // ==========================================================================\n\n if (Debug) Log.time('DcdParser._parse ' + this.name)\n\n const bin = ensureBuffer(this.streamer.data)\n const dv = new DataView(bin)\n\n const f = this.frames\n const coordinates = f.coordinates\n const boxes = f.boxes\n const header: Partial = {}\n\n let nextPos = 0\n\n // header block\n\n const intView = new Int32Array(bin, 0, 23)\n const ef = intView[ 0 ] !== dv.getInt32(0) // endianess flag\n // swap byte order when big endian (84 indicates little endian)\n if (intView[ 0 ] !== 84) {\n const n = bin.byteLength\n for (let i = 0; i < n; i += 4) {\n dv.setFloat32(i, dv.getFloat32(i), true)\n }\n }\n if (intView[ 0 ] !== 84) {\n Log.error('dcd bad format, header block start')\n }\n // format indicator, should read 'CORD'\n const formatString = String.fromCharCode(\n dv.getUint8(4), dv.getUint8(5),\n dv.getUint8(6), dv.getUint8(7)\n )\n if (formatString !== 'CORD') {\n Log.error('dcd bad format, format string')\n }\n let isCharmm = false\n let extraBlock = false\n let fourDims = false\n // version field in charmm, unused in X-PLOR\n if (intView[ 22 ] !== 0) {\n isCharmm = true\n if (intView[ 12 ] !== 0) extraBlock = true\n if (intView[ 13 ] === 1) fourDims = true\n }\n header.NSET = intView[ 2 ]\n header.ISTART = intView[ 3 ]\n header.NSAVC = intView[ 4 ]\n header.NAMNF = intView[ 10 ]\n if (isCharmm) {\n header.DELTA = dv.getFloat32(44, ef)\n } else {\n header.DELTA = dv.getFloat64(44, ef)\n }\n if (intView[ 22 ] !== 84) {\n Log.error('dcd bad format, header block end')\n }\n nextPos = nextPos + 21 * 4 + 8\n\n // title block\n\n const titleLength = dv.getInt32(nextPos, ef)\n const titlePos = nextPos + 1\n if ((titleLength - 4) % 80 !== 0) {\n Log.error('dcd bad format, title block start')\n }\n header.TITLE = uint8ToString(\n new Uint8Array(bin, titlePos, titleLength)\n )\n if (dv.getInt32(titlePos + titleLength + 4 - 1, ef) !== titleLength) {\n Log.error('dcd bad format, title block end')\n }\n nextPos = nextPos + titleLength + 8\n\n // natom block\n\n if (dv.getInt32(nextPos, ef) !== 4) {\n Log.error('dcd bad format, natom block start')\n }\n header.NATOM = dv.getInt32(nextPos + 4, ef)\n if (dv.getInt32(nextPos + 8, ef) !== 4) {\n Log.error('dcd bad format, natom block end')\n }\n nextPos = nextPos + 4 + 8\n\n // fixed atoms block\n\n if (header.NAMNF > 0) {\n // TODO read coordinates and indices of fixed atoms\n Log.error('dcd format with fixed atoms unsupported, aborting')\n return\n }\n\n // frames\n\n const natom = header.NATOM\n const natom4 = natom * 4\n\n for (let i = 0, n = header.NSET; i < n; ++i) {\n if (extraBlock) {\n nextPos += 4 // block start\n // unitcell: A, alpha, B, beta, gamma, C (doubles)\n const box = new Float32Array(9)\n box[ 0 ] = dv.getFloat64(nextPos, ef)\n box[ 4 ] = dv.getFloat64(nextPos + 2 * 8, ef)\n box[ 8 ] = dv.getFloat64(nextPos + 5 * 8, ef)\n boxes.push(box)\n nextPos += 48\n nextPos += 4 // block end\n }\n\n // xyz coordinates\n const coord = new Float32Array(natom * 3)\n for (let j = 0; j < 3; ++j) {\n if (dv.getInt32(nextPos, ef) !== natom4) {\n Log.error('dcd bad format, coord block start', i, j)\n }\n nextPos += 4 // block start\n const c = new Float32Array(bin, nextPos, natom)\n for (let k = 0; k < natom; ++k) {\n coord[ 3 * k + j ] = c[ k ]\n }\n nextPos += natom4\n if (dv.getInt32(nextPos, ef) !== natom4) {\n Log.error('dcd bad format, coord block end', i, j)\n }\n nextPos += 4 // block end\n }\n coordinates.push(coord)\n\n if (fourDims) {\n const bytes = dv.getInt32(nextPos, ef)\n nextPos += 4 + bytes + 4 // block start + skip + block end\n }\n }\n\n if (header.DELTA) {\n f.deltaTime = header.DELTA * charmmTimeUnitFactor\n }\n if (header.ISTART >= 1) {\n f.timeOffset = (header.ISTART - 1) * f.deltaTime\n }\n\n // console.log(header)\n // console.log(header.TITLE)\n // console.log('isCharmm', isCharmm, 'extraBlock', extraBlock, 'fourDims, fourDims)\n\n if (Debug) Log.timeEnd('DcdParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('dcd', DcdParser)\n\nexport default DcdParser\n","/**\n * @file Nctraj Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport TrajectoryParser from './trajectory-parser'\nimport NetcdfReader from '../utils/netcdf-reader'\n\nclass NctrajParser extends TrajectoryParser {\n get type () { return 'nctraj' }\n get isBinary () { return true }\n\n _parse () {\n // http://ambermd.org/netcdf/nctraj.xhtml\n\n if (Debug) Log.time('NctrajParser._parse ' + this.name)\n\n const netcdfReader = new NetcdfReader(this.streamer.data)\n\n const f = this.frames\n const coordinates = f.coordinates\n const boxes = f.boxes\n const times = f.times\n\n netcdfReader.getDataVariable('coordinates').forEach(function (c) {\n coordinates.push(new Float32Array(c))\n })\n\n if (netcdfReader.hasDataVariable('cell_lengths')) {\n netcdfReader.getDataVariable('cell_lengths').forEach(function (b) {\n boxes.push(new Float32Array(b))\n })\n }\n\n if (netcdfReader.hasDataVariable('time')) {\n netcdfReader.getDataVariable('time').forEach(function (t) {\n times.push(t)\n })\n }\n\n if (times.length >= 1) {\n f.timeOffset = times[0]\n }\n if (times.length >= 2) {\n f.deltaTime = times[1] - times[0]\n }\n\n if (Debug) Log.timeEnd('NctrajParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('nctraj', NctrajParser)\nParserRegistry.add('ncdf', NctrajParser)\nParserRegistry.add('nc', NctrajParser)\n\nexport default NctrajParser\n","/**\n * @file Trr Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { ensureBuffer } from '../utils'\nimport TrajectoryParser from './trajectory-parser'\n\nclass TrrParser extends TrajectoryParser {\n get type () { return 'trr' }\n get isBinary () { return true }\n\n _parse () {\n // https://github.com/gromacs/gromacs/blob/master/src/gromacs/fileio/trrio.cpp\n\n if (Debug) Log.time('TrrParser._parse ' + this.name)\n\n const bin = ensureBuffer(this.streamer.data)\n const dv = new DataView(bin)\n\n const f = this.frames\n const coordinates = f.coordinates\n const boxes = f.boxes\n const times = f.times\n\n let offset = 0\n\n while (true) {\n // const magicnum = dv.getInt32(offset)\n // const i1 = dv.getFloat32(offset + 4)\n offset += 8\n\n const versionSize = dv.getInt32(offset)\n offset += 4\n offset += versionSize\n\n // const irSize = dv.getInt32(offset)\n // const eSize = dv.getInt32(offset + 4)\n const boxSize = dv.getInt32(offset + 8)\n const virSize = dv.getInt32(offset + 12)\n const presSize = dv.getInt32(offset + 16)\n // const topSize = dv.getInt32(offset + 20)\n // const symSize = dv.getInt32(offset + 24)\n const coordSize = dv.getInt32(offset + 28)\n const velocitySize = dv.getInt32(offset + 32)\n const forceSize = dv.getInt32(offset + 36)\n const natoms = dv.getInt32(offset + 40)\n // const step = dv.getInt32(offset + 44)\n // const nre = dv.getInt32(offset + 48)\n offset += 52\n\n const floatSize = boxSize / 9\n const natoms3 = natoms * 3\n\n // let lambda\n if (floatSize === 8) {\n times.push(dv.getFloat64(offset))\n // lambda = dv.getFloat64(offset + 8)\n } else {\n times.push(dv.getFloat32(offset))\n // lambda = dv.getFloat32(offset + 4)\n }\n offset += 2 * floatSize\n\n if (boxSize) {\n const box = new Float32Array(9)\n if (floatSize === 8) {\n for (let i = 0; i < 9; ++i) {\n box[i] = dv.getFloat64(offset) * 10\n offset += 8\n }\n } else {\n for (let i = 0; i < 9; ++i) {\n box[i] = dv.getFloat32(offset) * 10\n offset += 4\n }\n }\n boxes.push(box)\n }\n\n // ignore, unused\n offset += virSize\n\n // ignore, unused\n offset += presSize\n\n if (coordSize) {\n let frameCoords\n if (floatSize === 8) {\n frameCoords = new Float32Array(natoms3)\n for (let i = 0; i < natoms3; ++i) {\n frameCoords[i] = dv.getFloat64(offset) * 10\n offset += 8\n }\n } else {\n const tmp = new Uint32Array(bin, offset, natoms3)\n for (let i = 0; i < natoms3; ++i) {\n const value = tmp[i]\n tmp[i] = (\n ((value & 0xFF) << 24) | ((value & 0xFF00) << 8) |\n ((value >> 8) & 0xFF00) | ((value >> 24) & 0xFF)\n )\n }\n frameCoords = new Float32Array(bin, offset, natoms3)\n for (let i = 0; i < natoms3; ++i) {\n frameCoords[i] *= 10\n offset += 4\n }\n }\n coordinates.push(frameCoords)\n }\n\n // ignore, unused\n offset += velocitySize\n\n // ignore, unused\n offset += forceSize\n\n if (offset >= bin.byteLength) break\n }\n\n if (times.length >= 1) {\n f.timeOffset = times[0]\n }\n if (times.length >= 2) {\n f.deltaTime = times[1] - times[0]\n }\n\n if (Debug) Log.timeEnd('TrrParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('trr', TrrParser)\n\nexport default TrrParser\n","/**\n * @file Xtc Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { ensureBuffer } from '../utils'\nimport TrajectoryParser from './trajectory-parser'\nimport { NumberArray } from '../types';\n\nconst MagicInts = new Uint32Array([\n 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 10, 12, 16, 20, 25, 32, 40, 50, 64,\n 80, 101, 128, 161, 203, 256, 322, 406, 512, 645, 812, 1024, 1290,\n 1625, 2048, 2580, 3250, 4096, 5060, 6501, 8192, 10321, 13003,\n 16384, 20642, 26007, 32768, 41285, 52015, 65536, 82570, 104031,\n 131072, 165140, 208063, 262144, 330280, 416127, 524287, 660561,\n 832255, 1048576, 1321122, 1664510, 2097152, 2642245, 3329021,\n 4194304, 5284491, 6658042, 8388607, 10568983, 13316085, 16777216\n])\nconst FirstIdx = 9\n// const LastIdx = MagicInts.length\n\nfunction sizeOfInt (size: number) {\n let num = 1\n let numOfBits = 0\n while (size >= num && numOfBits < 32) {\n numOfBits++\n num <<= 1\n }\n return numOfBits\n}\n\nconst _tmpBytes = new Uint8Array(32)\n\nfunction sizeOfInts (numOfInts: number, sizes: Int32Array) {\n let numOfBytes = 1\n let numOfBits = 0\n _tmpBytes[0] = 1\n for (let i = 0; i < numOfInts; i++) {\n let bytecnt\n let tmp = 0\n for (bytecnt = 0; bytecnt < numOfBytes; bytecnt++) {\n tmp += _tmpBytes[bytecnt] * sizes[i]\n _tmpBytes[bytecnt] = tmp & 0xff\n tmp >>= 8\n }\n while (tmp !== 0) {\n _tmpBytes[bytecnt++] = tmp & 0xff\n tmp >>= 8\n }\n numOfBytes = bytecnt\n }\n let num = 1\n numOfBytes--\n while (_tmpBytes[numOfBytes] >= num) {\n numOfBits++\n num *= 2\n }\n return numOfBits + numOfBytes * 8\n}\n\nfunction decodeBits (buf: Int32Array, cbuf: Uint8Array, numOfBits: number, buf2: Uint32Array) {\n const mask = (1 << numOfBits) - 1\n let lastBB0 = buf2[1]\n let lastBB1 = buf2[2]\n let cnt = buf[0]\n let num = 0\n\n while (numOfBits >= 8) {\n lastBB1 = (lastBB1 << 8) | cbuf[cnt++]\n num |= (lastBB1 >> lastBB0) << (numOfBits - 8)\n numOfBits -= 8\n }\n\n if (numOfBits > 0) {\n if (lastBB0 < numOfBits) {\n lastBB0 += 8\n lastBB1 = (lastBB1 << 8) | cbuf[cnt++]\n }\n lastBB0 -= numOfBits\n num |= (lastBB1 >> lastBB0) & ((1 << numOfBits) - 1)\n }\n\n num &= mask\n buf[0] = cnt\n buf[1] = lastBB0\n buf[2] = lastBB1\n\n return num\n}\n\nconst _tmpIntBytes = new Int32Array(32)\n\nfunction decodeInts (buf: Int32Array, cbuf: Uint8Array, numOfInts: number, numOfBits: number, sizes: NumberArray, nums: Float32Array, buf2: Uint32Array) {\n let numOfBytes = 0\n _tmpIntBytes[1] = 0\n _tmpIntBytes[2] = 0\n _tmpIntBytes[3] = 0\n\n while (numOfBits > 8) {\n // this is inversed??? why??? because of the endiannness???\n _tmpIntBytes[numOfBytes++] = decodeBits(buf, cbuf, 8, buf2)\n numOfBits -= 8\n }\n\n if (numOfBits > 0) {\n _tmpIntBytes[numOfBytes++] = decodeBits(buf, cbuf, numOfBits, buf2)\n }\n\n for (let i = numOfInts - 1; i > 0; i--) {\n let num = 0\n for (let j = numOfBytes - 1; j >= 0; j--) {\n num = (num << 8) | _tmpIntBytes[j]\n const p = (num / sizes[i]) | 0\n _tmpIntBytes[j] = p\n num = num - p * sizes[i]\n }\n nums[i] = num\n }\n nums[0] = (\n _tmpIntBytes[0] |\n (_tmpIntBytes[1] << 8) |\n (_tmpIntBytes[2] << 16) |\n (_tmpIntBytes[3] << 24)\n )\n}\n\nclass XtcParser extends TrajectoryParser {\n get type () { return 'xtc' }\n get isBinary () { return true }\n\n _parse () {\n // https://github.com/gromacs/gromacs/blob/master/src/gromacs/fileio/xtcio.cpp\n // https://github.com/gromacs/gromacs/blob/master/src/gromacs/fileio/libxdrf.cpp\n\n if (Debug) Log.time('XtcParser._parse ' + this.name)\n\n const bin = ensureBuffer(this.streamer.data)\n const dv = new DataView(bin)\n\n const f = this.frames\n const coordinates = f.coordinates\n const boxes = f.boxes\n const times = f.times\n\n const minMaxInt = new Int32Array(6)\n const sizeint = new Int32Array(3)\n const bitsizeint = new Int32Array(3)\n const sizesmall = new Uint32Array(3)\n const thiscoord = new Float32Array(3)\n const prevcoord = new Float32Array(3)\n\n let offset = 0\n const buf = new Int32Array(3)\n const buf2 = new Uint32Array(buf.buffer)\n\n while (true) {\n let frameCoords: NumberArray\n\n // const magicnum = dv.getInt32(offset)\n const natoms = dv.getInt32(offset + 4)\n // const step = dv.getInt32(offset + 8)\n offset += 12\n\n const natoms3 = natoms * 3\n\n times.push(dv.getFloat32(offset))\n offset += 4\n\n const box = new Float32Array(9)\n for (let i = 0; i < 9; ++i) {\n box[i] = dv.getFloat32(offset) * 10\n offset += 4\n }\n boxes.push(box)\n\n if (natoms <= 9) { // no compression\n frameCoords = new Float32Array(natoms)\n for (let i = 0; i < natoms; ++i) {\n frameCoords[i] = dv.getFloat32(offset)\n offset += 4\n }\n } else {\n buf[0] = buf[1] = buf[2] = 0.0\n sizeint[0] = sizeint[1] = sizeint[2] = 0\n sizesmall[0] = sizesmall[1] = sizesmall[2] = 0\n bitsizeint[0] = bitsizeint[1] = bitsizeint[2] = 0\n thiscoord[0] = thiscoord[1] = thiscoord[2] = 0\n prevcoord[0] = prevcoord[1] = prevcoord[2] = 0\n\n frameCoords = new Float32Array(natoms3)\n let lfp = 0\n\n const lsize = dv.getInt32(offset)\n offset += 4\n const precision = dv.getFloat32(offset)\n offset += 4\n\n minMaxInt[0] = dv.getInt32(offset)\n minMaxInt[1] = dv.getInt32(offset + 4)\n minMaxInt[2] = dv.getInt32(offset + 8)\n minMaxInt[3] = dv.getInt32(offset + 12)\n minMaxInt[4] = dv.getInt32(offset + 16)\n minMaxInt[5] = dv.getInt32(offset + 20)\n sizeint[0] = minMaxInt[3] - minMaxInt[0] + 1\n sizeint[1] = minMaxInt[4] - minMaxInt[1] + 1\n sizeint[2] = minMaxInt[5] - minMaxInt[2] + 1\n offset += 24\n\n let bitsize\n if ((sizeint[0] | sizeint[1] | sizeint[2]) > 0xffffff) {\n bitsizeint[0] = sizeOfInt(sizeint[0])\n bitsizeint[1] = sizeOfInt(sizeint[1])\n bitsizeint[2] = sizeOfInt(sizeint[2])\n bitsize = 0 // flag the use of large sizes\n } else {\n bitsize = sizeOfInts(3, sizeint)\n }\n\n let smallidx = dv.getInt32(offset)\n offset += 4\n // if (smallidx == 0) {alert(\"Undocumented error 1\"); return;}\n\n // let tmpIdx = smallidx + 8\n // const maxidx = (LastIdx < tmpIdx) ? LastIdx : tmpIdx\n // const minidx = maxidx - 8 // often this equal smallidx\n let tmpIdx = smallidx - 1\n tmpIdx = (FirstIdx > tmpIdx) ? FirstIdx : tmpIdx\n let smaller = (MagicInts[tmpIdx] / 2) | 0\n let smallnum = (MagicInts[smallidx] / 2) | 0\n\n sizesmall[0] = sizesmall[1] = sizesmall[2] = MagicInts[smallidx]\n // larger = MagicInts[maxidx]\n\n let adz = Math.ceil(dv.getInt32(offset) / 4) * 4\n offset += 4\n // if (tmpIdx == 0) {alert(\"Undocumented error 2\"); return;}\n\n // buf = new Int32Array(bin, offset);\n // buf8 = new Uint8Array(bin, offset);\n\n // tmpIdx += 3; rndup = tmpIdx%4;\n // for (i=tmpIdx+rndup-1; i>=tmpIdx; i--) buf8[i] = 0;\n\n // now unpack buf2...\n\n const invPrecision = 1.0 / precision\n let run = 0\n let i = 0\n\n const buf8 = new Uint8Array(bin, offset) // 229...\n\n thiscoord[0] = thiscoord[1] = thiscoord[2] = 0\n\n while (i < lsize) {\n if (bitsize === 0) {\n thiscoord[0] = decodeBits(buf, buf8, bitsizeint[0], buf2)\n thiscoord[1] = decodeBits(buf, buf8, bitsizeint[1], buf2)\n thiscoord[2] = decodeBits(buf, buf8, bitsizeint[2], buf2)\n } else {\n decodeInts(buf, buf8, 3, bitsize, sizeint, thiscoord, buf2)\n }\n\n i++\n\n thiscoord[0] += minMaxInt[0]\n thiscoord[1] += minMaxInt[1]\n thiscoord[2] += minMaxInt[2]\n\n prevcoord[0] = thiscoord[0]\n prevcoord[1] = thiscoord[1]\n prevcoord[2] = thiscoord[2]\n\n const flag = decodeBits(buf, buf8, 1, buf2)\n let isSmaller = 0\n\n if (flag === 1) {\n run = decodeBits(buf, buf8, 5, buf2)\n isSmaller = run % 3\n run -= isSmaller\n isSmaller--\n }\n\n // if ((lfp-ptrstart)+run > size3){\n // fprintf(stderr, \"(xdrfile error) Buffer overrun during decompression.\\n\");\n // return 0;\n // }\n\n if (run > 0) {\n thiscoord[0] = thiscoord[1] = thiscoord[2] = 0\n\n for (let k = 0; k < run; k += 3) {\n decodeInts(buf, buf8, 3, smallidx, sizesmall, thiscoord, buf2)\n i++\n\n thiscoord[0] += prevcoord[0] - smallnum\n thiscoord[1] += prevcoord[1] - smallnum\n thiscoord[2] += prevcoord[2] - smallnum\n\n if (k === 0) {\n // interchange first with second atom for\n // better compression of water molecules\n let tmpSwap = thiscoord[0]\n thiscoord[0] = prevcoord[0]\n prevcoord[0] = tmpSwap\n\n tmpSwap = thiscoord[1]\n thiscoord[1] = prevcoord[1]\n prevcoord[1] = tmpSwap\n\n tmpSwap = thiscoord[2]\n thiscoord[2] = prevcoord[2]\n prevcoord[2] = tmpSwap\n\n frameCoords[lfp++] = prevcoord[0] * invPrecision\n frameCoords[lfp++] = prevcoord[1] * invPrecision\n frameCoords[lfp++] = prevcoord[2] * invPrecision\n } else {\n prevcoord[0] = thiscoord[0]\n prevcoord[1] = thiscoord[1]\n prevcoord[2] = thiscoord[2]\n }\n frameCoords[lfp++] = thiscoord[0] * invPrecision\n frameCoords[lfp++] = thiscoord[1] * invPrecision\n frameCoords[lfp++] = thiscoord[2] * invPrecision\n }\n } else {\n frameCoords[lfp++] = thiscoord[0] * invPrecision\n frameCoords[lfp++] = thiscoord[1] * invPrecision\n frameCoords[lfp++] = thiscoord[2] * invPrecision\n }\n\n smallidx += isSmaller\n\n if (isSmaller < 0) {\n smallnum = smaller\n if (smallidx > FirstIdx) {\n smaller = (MagicInts[smallidx - 1] / 2) | 0\n } else {\n smaller = 0\n }\n } else if (isSmaller > 0) {\n smaller = smallnum\n smallnum = (MagicInts[smallidx] / 2) | 0\n }\n sizesmall[0] = sizesmall[1] = sizesmall[2] = MagicInts[smallidx]\n\n if (sizesmall[0] === 0 || sizesmall[1] === 0 || sizesmall[2] === 0) {\n console.error('(xdrfile error) Undefined error.')\n return\n }\n }\n offset += adz\n }\n\n for (let c = 0; c < natoms3; c++) {\n frameCoords[c] *= 10\n }\n\n coordinates.push(frameCoords)\n\n if (offset >= bin.byteLength) break\n }\n\n if (times.length >= 1) {\n f.timeOffset = times[0]\n }\n if (times.length >= 2) {\n f.deltaTime = times[1] - times[0]\n }\n\n if (Debug) Log.timeEnd('XtcParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('xtc', XtcParser)\n\nexport default XtcParser\n","/**\n * @file Volume Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { defaults } from '../utils'\nimport Parser, { ParserParameters } from './parser'\nimport Volume from '../surface/volume'\nimport Streamer from '../streamer/streamer';\n\nexport interface VolumeParserParameters extends ParserParameters {\n voxelSize: number\n}\n\nclass VolumeParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.volume = new Volume(this.name, this.path)\n this.voxelSize = defaults(p.voxelSize, 1)\n }\n\n get type () { return 'volume' }\n get __objName () { return 'volume' }\n\n _afterParse () {\n this.volume.setMatrix(this.getMatrix())\n super._afterParse()\n }\n\n getMatrix () {\n return new Matrix4()\n }\n}\n\nexport default VolumeParser\n","/**\n * @file Cube Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4, Vector3 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport VolumeParser from './volume-parser'\n\n// @author Johanna Tiemann \n// @author Alexander Rose \n\nconst reWhitespace = /\\s+/\nconst reScientificNotation = /-?\\d+(?:\\.\\d*)?(?:[eE][+-]?\\d+)?/g\nconst bohrToAngstromFactor = 0.529177210859\ninterface Header {\n atomCount: number,\n originX: number,\n originY: number,\n originZ: number,\n NVX: number,\n NVY: number,\n NVZ: number,\n basisX: Vector3,\n basisY: Vector3,\n basisZ: Vector3\n}\n\nclass CubeParser extends VolumeParser {\n get type () { return 'cube' }\n\n _parse () {\n // http://paulbourke.net/dataformats/cube/\n\n if (Debug) Log.time('CubeParser._parse ' + this.name)\n\n const v = this.volume\n const headerLines = this.streamer.peekLines(6)\n const header: Partial
= {}\n\n const scaleFactor = bohrToAngstromFactor * this.voxelSize\n\n function h (k: number, l: number) {\n var field = headerLines[ k ].trim().split(reWhitespace)[ l ]\n return parseFloat(field)\n }\n\n header.atomCount = Math.abs(h(2, 0)) // Number of atoms\n header.originX = h(2, 1) * bohrToAngstromFactor // Position of origin of volumetric data\n header.originY = h(2, 2) * bohrToAngstromFactor\n header.originZ = h(2, 3) * bohrToAngstromFactor\n header.NVX = h(3, 0) // Number of voxels\n header.NVY = h(4, 0)\n header.NVZ = h(5, 0)\n\n header.basisX = new Vector3(h(3, 1), h(3, 2), h(3, 3))\n .multiplyScalar(scaleFactor)\n header.basisY = new Vector3(h(4, 1), h(4, 2), h(4, 3))\n .multiplyScalar(scaleFactor)\n header.basisZ = new Vector3(h(5, 1), h(5, 2), h(5, 3))\n .multiplyScalar(scaleFactor)\n\n const data = new Float32Array(header.NVX * header.NVY * header.NVZ)\n let count = 0\n let lineNo = 0\n const oribitalFlag = h(2, 0) > 0 ? 0 : 1\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ].trim()\n\n if (line !== '' && lineNo >= header.atomCount! + 6 + oribitalFlag) {\n const m = line.match(reScientificNotation) as RegExpMatchArray\n for (let j = 0, lj = m.length; j < lj; ++j) {\n data[ count ] = parseFloat(m[ j ])\n ++count\n }\n }\n\n ++lineNo\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n v.header = header\n v.setData(data, header.NVZ, header.NVY, header.NVX)\n\n if (Debug) Log.timeEnd('CubeParser._parse ' + this.name)\n }\n\n getMatrix () {\n const h = this.volume.header\n const matrix = new Matrix4()\n\n matrix.multiply(\n new Matrix4().makeTranslation(\n h.originX, h.originY, h.originZ\n )\n )\n\n matrix.multiply(\n new Matrix4().makeBasis(\n h.basisZ, h.basisY, h.basisX\n )\n )\n\n return matrix\n }\n}\n\nParserRegistry.add('cub', CubeParser)\nParserRegistry.add('cube', CubeParser)\n\nexport default CubeParser\n","/**\n * @file Dsn6 Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { ensureBuffer } from '../utils'\nimport { degToRad } from '../math/math-utils'\nimport VolumeParser from './volume-parser'\n\ninterface Dsn6Header {\n xStart: number,\n yStart: number,\n zStart: number,\n xExtent: number,\n yExtent: number,\n zExtent: number,\n xRate: number,\n yRate: number,\n zRate: number,\n xlen: number,\n ylen: number,\n zlen: number,\n alpha: number,\n beta: number,\n gamma: number,\n sigma: number\n}\n\nclass Dsn6Parser extends VolumeParser {\n get type () { return 'dsn6' }\n get isBinary () { return true }\n\n _parse () {\n // DSN6 http://www.uoxray.uoregon.edu/tnt/manual/node104.html\n // BRIX http://svn.cgl.ucsf.edu/svn/chimera/trunk/libs/VolumeData/dsn6/brix-1.html\n\n if (Debug) Log.time('Dsn6Parser._parse ' + this.name)\n\n const v = this.volume\n const header: Partial = {}\n let divisor, summand\n\n const bin = ensureBuffer(this.streamer.data)\n const intView = new Int16Array(bin)\n const byteView = new Uint8Array(bin)\n const brixStr = String.fromCharCode.apply(null, byteView.subarray(0, 512))\n\n if (brixStr.startsWith(':-)')) {\n header.xStart = parseInt(brixStr.substr(10, 5)) // NXSTART\n header.yStart = parseInt(brixStr.substr(15, 5))\n header.zStart = parseInt(brixStr.substr(20, 5))\n\n header.xExtent = parseInt(brixStr.substr(32, 5)) // NX\n header.yExtent = parseInt(brixStr.substr(38, 5))\n header.zExtent = parseInt(brixStr.substr(42, 5))\n\n header.xRate = parseInt(brixStr.substr(52, 5)) // MX\n header.yRate = parseInt(brixStr.substr(58, 5))\n header.zRate = parseInt(brixStr.substr(62, 5))\n\n header.xlen = parseFloat(brixStr.substr(73, 10)) * this.voxelSize\n header.ylen = parseFloat(brixStr.substr(83, 10)) * this.voxelSize\n header.zlen = parseFloat(brixStr.substr(93, 10)) * this.voxelSize\n\n header.alpha = parseFloat(brixStr.substr(103, 10))\n header.beta = parseFloat(brixStr.substr(113, 10))\n header.gamma = parseFloat(brixStr.substr(123, 10))\n\n divisor = parseFloat(brixStr.substr(138, 12)) / 100\n summand = parseInt(brixStr.substr(155, 8))\n\n header.sigma = parseFloat(brixStr.substr(170, 12)) * 100\n } else {\n // swap byte order when big endian\n if (intView[ 18 ] !== 100) {\n for (let i = 0, n = intView.length; i < n; ++i) {\n const val = intView[ i ]\n intView[ i ] = ((val & 0xff) << 8) | ((val >> 8) & 0xff)\n }\n }\n\n header.xStart = intView[ 0 ] // NXSTART\n header.yStart = intView[ 1 ]\n header.zStart = intView[ 2 ]\n\n header.xExtent = intView[ 3 ] // NX\n header.yExtent = intView[ 4 ]\n header.zExtent = intView[ 5 ]\n\n header.xRate = intView[ 6 ] // MX\n header.yRate = intView[ 7 ]\n header.zRate = intView[ 8 ]\n\n const factor = 1 / intView[ 17 ]\n const scalingFactor = factor * this.voxelSize\n\n header.xlen = intView[ 9 ] * scalingFactor\n header.ylen = intView[ 10 ] * scalingFactor\n header.zlen = intView[ 11 ] * scalingFactor\n\n header.alpha = intView[ 12 ] * factor\n header.beta = intView[ 13 ] * factor\n header.gamma = intView[ 14 ] * factor\n\n divisor = intView[ 15 ] / 100\n summand = intView[ 16 ]\n header.gamma = intView[ 14 ] * factor\n }\n\n v.header = header\n\n if (Debug) Log.log(header, divisor, summand)\n\n const data = new Float32Array(\n header.xExtent * header.yExtent * header.zExtent\n )\n\n let offset = 512\n const xBlocks = Math.ceil(header.xExtent / 8)\n const yBlocks = Math.ceil(header.yExtent / 8)\n const zBlocks = Math.ceil(header.zExtent / 8)\n\n // loop over blocks\n for (var zz = 0; zz < zBlocks; ++zz) {\n for (var yy = 0; yy < yBlocks; ++yy) {\n for (var xx = 0; xx < xBlocks; ++xx) {\n // loop inside block\n for (var k = 0; k < 8; ++k) {\n var z = 8 * zz + k\n for (var j = 0; j < 8; ++j) {\n var y = 8 * yy + j\n for (var i = 0; i < 8; ++i) {\n var x = 8 * xx + i\n\n // check if remaining slice-part contains data\n if (x < header.xExtent && y < header.yExtent && z < header.zExtent) {\n var idx = ((((x * header.yExtent) + y) * header.zExtent) + z)\n data[ idx ] = (byteView[ offset ] - summand) / divisor\n ++offset\n } else {\n offset += 8 - i\n break\n }\n }\n }\n }\n }\n }\n }\n\n v.setData(data, header.zExtent, header.yExtent, header.xExtent)\n if (header.sigma) {\n v.setStats(undefined, undefined, undefined, header.sigma)\n }\n\n if (Debug) Log.timeEnd('Dsn6Parser._parse ' + this.name)\n }\n\n getMatrix () {\n const h: Dsn6Header = this.volume.header\n\n const basisX = [\n h.xlen as number,\n 0,\n 0\n ]\n\n const basisY = [\n h.ylen * Math.cos(Math.PI / 180.0 * h.gamma),\n h.ylen * Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n\n const basisZ = [\n h.zlen * Math.cos(Math.PI / 180.0 * h.beta),\n h.zlen * (\n Math.cos(Math.PI / 180.0 * h.alpha) -\n Math.cos(Math.PI / 180.0 * h.gamma) *\n Math.cos(Math.PI / 180.0 * h.beta)\n ) / Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n basisZ[ 2 ] = Math.sqrt(\n h.zlen * h.zlen * Math.sin(Math.PI / 180.0 * h.beta) *\n Math.sin(Math.PI / 180.0 * h.beta) - basisZ[ 1 ] * basisZ[ 1 ]\n )\n\n const basis = [ [], basisX, basisY, basisZ ]\n const nxyz = [ 0, h.xRate, h.yRate, h.zRate ]\n const mapcrs = [ 0, 1, 2, 3 ]\n\n const matrix = new Matrix4()\n\n matrix.set(\n basis[ mapcrs[1] ][0] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][0] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][0] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][1] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][1] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][1] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][2] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][2] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][2] / nxyz[ mapcrs[3] ],\n 0,\n 0, 0, 0, 1\n )\n\n matrix.multiply(\n new Matrix4().makeRotationY(degToRad(90))\n )\n\n matrix.multiply(new Matrix4().makeTranslation(\n -h.zStart, h.yStart, h.xStart\n ))\n\n matrix.multiply(new Matrix4().makeScale(\n -1, 1, 1\n ))\n\n return matrix\n }\n}\n\nParserRegistry.add('dsn6', Dsn6Parser)\nParserRegistry.add('brix', Dsn6Parser)\n\nexport default Dsn6Parser\n","/**\n * @file Dx Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { degToRad } from '../math/math-utils'\nimport VolumeParser from './volume-parser'\n\nconst reWhitespace = /\\s+/\n\ninterface DxHeader {\n nx: number,\n ny: number,\n nz: number,\n xmin: number,\n ymin: number,\n zmin: number,\n hx: number,\n hy: number,\n hz: number\n}\n\nclass DxParser extends VolumeParser {\n get type () { return 'dx' }\n\n _parse () {\n // http://apbs.readthedocs.io/en/latest/formats/opendx.html\n\n if (Debug) Log.time('DxParser._parse ' + this.name)\n\n const v = this.volume\n const headerLines = this.streamer.peekLines(30)\n const headerInfo = this.parseHeaderLines(headerLines)\n const header = this.volume.header\n const dataLineStart = headerInfo.dataLineStart\n\n const size = header.nx * header.ny * header.nz\n const data = new Float32Array(size)\n let count = 0\n let lineNo = 0\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string []) {\n for (let i = _i; i < _n; ++i) {\n if (count < size && lineNo > dataLineStart) {\n const line = lines[ i ].trim()\n\n if (line !== '') {\n const ls = line.split(reWhitespace)\n\n for (let j = 0, lj = ls.length; j < lj; ++j) {\n data[ count ] = parseFloat(ls[ j ])\n ++count\n }\n }\n }\n\n ++lineNo\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n v.setData(data, header.nz, header.ny, header.nx)\n\n if (Debug) Log.timeEnd('DxParser._parse ' + this.name)\n }\n\n parseHeaderLines (headerLines: string []) {\n const header: Partial = {}\n const n = headerLines.length\n\n let dataLineStart = 0\n let headerByteCount = 0\n let deltaLineCount = 0\n\n for (let i = 0; i < n; ++i) {\n let ls\n const line = headerLines[ i ]\n\n if (line.startsWith('object 1')) {\n ls = line.split(reWhitespace)\n\n header.nx = parseInt(ls[ 5 ])\n header.ny = parseInt(ls[ 6 ])\n header.nz = parseInt(ls[ 7 ])\n } else if (line.startsWith('origin')) {\n ls = line.split(reWhitespace)\n\n header.xmin = parseFloat(ls[ 1 ])\n header.ymin = parseFloat(ls[ 2 ])\n header.zmin = parseFloat(ls[ 3 ])\n } else if (line.startsWith('delta')) {\n ls = line.split(reWhitespace)\n\n if (deltaLineCount === 0) {\n header.hx = parseFloat(ls[ 1 ]) * this.voxelSize\n } else if (deltaLineCount === 1) {\n header.hy = parseFloat(ls[ 2 ]) * this.voxelSize\n } else if (deltaLineCount === 2) {\n header.hz = parseFloat(ls[ 3 ]) * this.voxelSize\n }\n\n deltaLineCount += 1\n } else if (line.startsWith('object 3')) {\n dataLineStart = i\n headerByteCount += line.length + 1\n break\n }\n\n headerByteCount += line.length + 1\n }\n\n this.volume.header = header\n\n return {\n dataLineStart: dataLineStart,\n headerByteCount: headerByteCount\n }\n }\n\n getMatrix () {\n const h = this.volume.header\n const matrix = new Matrix4()\n\n matrix.multiply(\n new Matrix4().makeRotationY(degToRad(90))\n )\n\n matrix.multiply(\n new Matrix4().makeTranslation(\n -h.zmin, h.ymin, h.xmin\n )\n )\n\n matrix.multiply(\n new Matrix4().makeScale(\n -h.hz, h.hy, h.hx\n )\n )\n\n return matrix\n }\n}\n\nParserRegistry.add('dx', DxParser)\n\nexport default DxParser\n","/**\n * @file Dxbin Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { uint8ToLines, ensureBuffer } from '../utils'\nimport DxParser from './dx-parser'\n\nclass DxbinParser extends DxParser {\n get type () { return 'dxbin' }\n get isBinary () { return true }\n\n _parse () {\n // https://github.com/Electrostatics/apbs-pdb2pqr/issues/216\n\n if (Debug) Log.time('DxbinParser._parse ' + this.name)\n\n const bin = ensureBuffer(this.streamer.data)\n const headerLines = uint8ToLines(new Uint8Array(bin, 0, 1000))\n const headerInfo = this.parseHeaderLines(headerLines)\n const header = this.volume.header\n const headerByteCount = headerInfo.headerByteCount\n\n const size = header.nx * header.ny * header.nz\n const dv = new DataView(bin)\n const data = new Float32Array(size)\n\n for (let i = 0; i < size; ++i) {\n data[ i ] = dv.getFloat64(i * 8 + headerByteCount, true)\n }\n\n this.volume.setData(data, header.nz, header.ny, header.nx)\n\n if (Debug) Log.timeEnd('DxbinParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('dxbin', DxbinParser)\n\nexport default DxbinParser\n","/**\n * @file Mrc Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { ensureBuffer } from '../utils'\nimport VolumeParser from './volume-parser'\n\ninterface MrcHeader {\n MAP: string,\n MACHST: number [],\n NX: number,\n NY: number,\n NZ: number,\n MODE: number,\n NXSTART: number,\n NYSTART: number,\n NZSTART: number,\n MX: number,\n MY: number,\n MZ: number,\n xlen: number,\n ylen: number,\n zlen: number,\n alpha: number,\n beta: number,\n gamma: number,\n MAPC: number,\n MAPR: number,\n MAPS: number,\n DMIN: number,\n DMAX: number,\n DMEAN: number,\n ISPG: number,\n NSYMBT: number,\n LSKFLG: number,\n originX: number,\n originY: number,\n originZ: number,\n ARMS: number\n}\n\nclass MrcParser extends VolumeParser {\n get type () { return 'mrc' }\n get isBinary () { return true }\n\n _parse () {\n // MRC\n // http://ami.scripps.edu/software/mrctools/mrc_specification.php\n // http://www2.mrc-lmb.cam.ac.uk/research/locally-developed-software/image-processing-software/#image\n // http://bio3d.colorado.edu/imod/doc/mrc_format.txt\n\n // CCP4 (MAP)\n // http://www.ccp4.ac.uk/html/maplib.html\n\n // MRC format does not use the skew transformation header records (words 25-37)\n // CCP4 format does not use the ORIGIN header records (words 50-52)\n\n if (Debug) Log.time('MrcParser._parse ' + this.name)\n\n const v = this.volume\n const header: Partial = {}\n\n const bin = ensureBuffer(this.streamer.data)\n const intView = new Int32Array(bin, 0, 56)\n const floatView = new Float32Array(bin, 0, 56)\n const dv = new DataView(bin)\n\n // 53 MAP Character string 'MAP ' to identify file type\n header.MAP = String.fromCharCode(\n dv.getUint8(52 * 4), dv.getUint8(52 * 4 + 1),\n dv.getUint8(52 * 4 + 2), dv.getUint8(52 * 4 + 3)\n )\n\n // 54 MACHST Machine stamp indicating machine type which wrote file\n // 17 and 17 for big-endian or 68 and 65 for little-endian\n header.MACHST = [ dv.getUint8(53 * 4), dv.getUint8(53 * 4 + 1) ]\n\n // swap byte order when big endian\n if (header.MACHST[ 0 ] === 17 && header.MACHST[ 1 ] === 17) {\n const n = bin.byteLength\n for (let i = 0; i < n; i += 4) {\n dv.setFloat32(i, dv.getFloat32(i), true)\n }\n }\n\n header.NX = intView[ 0 ] // NC - columns (fastest changing)\n header.NY = intView[ 1 ] // NR - rows\n header.NZ = intView[ 2 ] // NS - sections (slowest changing)\n\n // mode\n // 0 image : signed 8-bit bytes range -128 to 127\n // 1 image : 16-bit halfwords\n // 2 image : 32-bit reals\n // 3 transform : complex 16-bit integers\n // 4 transform : complex 32-bit reals\n // 6 image : unsigned 16-bit range 0 to 65535\n // 16 image: unsigned char * 3 (for rgb data, non-standard)\n //\n // Note: Mode 2 is the normal mode used in the CCP4 programs.\n // Other modes than 2 and 0 may NOT WORK\n header.MODE = intView[ 3 ]\n\n // start\n header.NXSTART = intView[ 4 ] // NCSTART - first column\n header.NYSTART = intView[ 5 ] // NRSTART - first row\n header.NZSTART = intView[ 6 ] // NSSTART - first section\n\n // intervals\n header.MX = intView[ 7 ] // intervals along x\n header.MY = intView[ 8 ] // intervals along y\n header.MZ = intView[ 9 ] // intervals along z\n\n // cell length (Angstroms in CCP4)\n header.xlen = floatView[ 10 ] * this.voxelSize\n header.ylen = floatView[ 11 ] * this.voxelSize\n header.zlen = floatView[ 12 ] * this.voxelSize\n\n // cell angle (Degrees)\n header.alpha = floatView[ 13 ]\n header.beta = floatView[ 14 ]\n header.gamma = floatView[ 15 ]\n\n // axis correspondence (1,2,3 for X,Y,Z)\n header.MAPC = intView[ 16 ] // column\n header.MAPR = intView[ 17 ] // row\n header.MAPS = intView[ 18 ] // section\n\n // density statistics\n header.DMIN = floatView[ 19 ]\n header.DMAX = floatView[ 20 ]\n header.DMEAN = floatView[ 21 ]\n\n // space group number 0 or 1 (default=0)\n header.ISPG = intView[ 22 ]\n\n // number of bytes used for symmetry data (0 or 80)\n header.NSYMBT = intView[ 23 ]\n\n // Flag for skew transformation, =0 none, =1 if foll\n header.LSKFLG = intView[ 24 ]\n\n // 26-34 SKWMAT Skew matrix S (in order S11, S12, S13, S21 etc) if\n // LSKFLG .ne. 0.\n // 35-37 SKWTRN Skew translation t if LSKFLG != 0.\n // Skew transformation is from standard orthogonal\n // coordinate frame (as used for atoms) to orthogonal\n // map frame, as Xo(map) = S * (Xo(atoms) - t)\n\n // 38 future use (some of these are used by the MSUBSX routines\n // . \" in MAPBRICK, MAPCONT and FRODO)\n // . \" (all set to zero by default)\n // . \"\n // 52 \"\n\n // 50-52 origin in X,Y,Z used for transforms\n header.originX = floatView[ 49 ]\n header.originY = floatView[ 50 ]\n header.originZ = floatView[ 51 ]\n\n // 53 MAP Character string 'MAP ' to identify file type\n // => see top of this parser\n\n // 54 MACHST Machine stamp indicating machine type which wrote file\n // => see top of this parser\n\n // Rms deviation of map from mean density\n header.ARMS = floatView[ 54 ]\n\n // 56 NLABL Number of labels being used\n // 57-256 LABEL(20,10) 10 80 character text labels (ie. A4 format)\n\n v.header = header\n\n // Log.log( header );\n\n let data\n if (header.MODE === 2) {\n data = new Float32Array(\n bin, 256 * 4 + header.NSYMBT,\n header.NX * header.NY * header.NZ\n )\n } else if (header.MODE === 0) {\n data = new Float32Array(new Int8Array(\n bin, 256 * 4 + header.NSYMBT,\n header.NX * header.NY * header.NZ\n ))\n\n // based on uglymol (https://github.com/uglymol/uglymol) by Marcin Wojdyr (wojdyr)\n // if the file was converted by mapmode2to0 - scale the data\n if (intView[ 39 ] === -128 && intView[ 40 ] === 127) {\n // scaling f(x)=b1*x+b0 such that f(-128)=min and f(127)=max\n const b1 = (header.DMAX - header.DMIN) / 255.0\n const b0 = 0.5 * (header.DMIN + header.DMAX + b1)\n for (let j = 0, jl = data.length; j < jl; ++j) {\n data[ j ] = b1 * data[ j ] + b0\n }\n }\n } else {\n Log.error('MrcParser unknown mode', header.MODE)\n }\n\n v.setData(data, header.NX, header.NY, header.NZ)\n if (header.ARMS !== 0) {\n v.setStats(header.DMIN, header.DMAX, header.DMEAN, header.ARMS)\n }\n\n if (Debug) Log.timeEnd('MrcParser._parse ' + this.name)\n }\n\n getMatrix () {\n const h = this.volume.header\n\n const basisX = [\n h.xlen,\n 0,\n 0\n ]\n\n const basisY = [\n h.ylen * Math.cos(Math.PI / 180.0 * h.gamma),\n h.ylen * Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n\n const basisZ = [\n h.zlen * Math.cos(Math.PI / 180.0 * h.beta),\n h.zlen * (\n Math.cos(Math.PI / 180.0 * h.alpha) -\n Math.cos(Math.PI / 180.0 * h.gamma) *\n Math.cos(Math.PI / 180.0 * h.beta)\n ) / Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n basisZ[ 2 ] = Math.sqrt(\n h.zlen * h.zlen * Math.sin(Math.PI / 180.0 * h.beta) *\n Math.sin(Math.PI / 180.0 * h.beta) - basisZ[ 1 ] * basisZ[ 1 ]\n )\n\n const basis = [ [], basisX, basisY, basisZ ]\n const nxyz = [ 0, h.MX, h.MY, h.MZ ]\n const mapcrs = [ 0, h.MAPC, h.MAPR, h.MAPS ]\n\n const matrix = new Matrix4()\n\n matrix.set(\n basis[ mapcrs[1] ][0] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][0] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][0] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][1] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][1] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][1] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][2] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][2] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][2] / nxyz[ mapcrs[3] ],\n 0,\n 0, 0, 0, 1\n )\n\n matrix.setPosition(new Vector3(\n h.originX, h.originY, h.originZ\n ))\n\n matrix.multiply(new Matrix4().makeTranslation(\n h.NXSTART, h.NYSTART, h.NZSTART\n ))\n\n return matrix\n }\n}\n\nParserRegistry.add('mrc', MrcParser)\nParserRegistry.add('ccp4', MrcParser)\nParserRegistry.add('map', MrcParser)\n\nexport default MrcParser\n","/**\n * @file Xplor Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Matrix4 } from 'three'\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport VolumeParser from './volume-parser'\n\nconst reWhitespace = /\\s+/\n\nfunction parseNumberLine (line: string) {\n return line.trim().split(reWhitespace).map(parseFloat)\n}\n\ninterface XplorHeader {\n NA: number,\n AMIN: number,\n AMAX: number,\n NB: number,\n BMIN: number,\n BMAX: number,\n NC: number,\n CMIN: number,\n CMAX: number,\n a: number,\n b: number,\n c: number,\n alpha: number,\n beta: number,\n gamma: number,\n RAVE: number,\n RSIGMA: number\n}\n\nclass XplorParser extends VolumeParser {\n get type () { return 'xplor' }\n\n _parse () {\n // http://hincklab.uthscsa.edu/html/soft_packs/msi_docs/insight980/xplor/formats.html\n // http://www.mrc-lmb.cam.ac.uk/public/xtal/doc/cns/cns_1.3/tutorial/formats/maps/text.html\n\n if (Debug) Log.time('XplorParser._parse ' + this.name)\n\n const v = this.volume\n const headerLines = this.streamer.peekLines(8)\n const header: Partial = {}\n\n let infoStart\n if (headerLines[ 2 ].startsWith('REMARKS')) {\n infoStart = parseInt(headerLines[ 1 ].substring(0, 8)) + 2\n } else {\n infoStart = 5\n }\n const dataStart = infoStart + 3\n\n const gridInfo = parseNumberLine(headerLines[ infoStart ])\n header.NA = gridInfo[ 0 ]\n header.AMIN = gridInfo[ 1 ]\n header.AMAX = gridInfo[ 2 ]\n header.NB = gridInfo[ 3 ]\n header.BMIN = gridInfo[ 4 ]\n header.BMAX = gridInfo[ 5 ]\n header.NC = gridInfo[ 6 ]\n header.CMIN = gridInfo[ 7 ]\n header.CMAX = gridInfo[ 8 ]\n\n const cellInfo = parseNumberLine(headerLines[ infoStart + 1 ])\n header.a = cellInfo[ 0 ] * this.voxelSize\n header.b = cellInfo[ 1 ] * this.voxelSize\n header.c = cellInfo[ 2 ] * this.voxelSize\n header.alpha = cellInfo[ 3 ]\n header.beta = cellInfo[ 4 ]\n header.gamma = cellInfo[ 5 ]\n\n const na = header.AMAX - header.AMIN + 1\n const nb = header.BMAX - header.BMIN + 1\n const nc = header.CMAX - header.CMIN + 1\n const n = na * nb * nc\n\n const data = new Float32Array(n)\n const lineSection = Math.ceil(1 + (na * nb) / 6)\n let count = 0\n let lineNo = 0\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n\n if (lineNo >= dataStart && (lineNo - dataStart) % lineSection !== 0 && count < n) {\n for (let j = 0, lj = 6; j < lj; ++j) {\n const value = parseFloat(line.substr(12 * j, 12))\n if (isNaN(value)) { break } // Last line of map section\n data[count++] = value\n }\n } else if (count === n) {\n const lt = line.trim()\n if (lt && lt !== '-9999') {\n const ls = parseNumberLine(line)\n header.RAVE = ls[0]\n header.RSIGMA = ls[1]\n }\n }\n\n ++lineNo\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n v.header = header\n v.setData(data, na, nb, nc)\n if (header.RAVE !== 0 && header.RSIGMA !== 1) {\n v.setStats(undefined, undefined, header.RAVE, header.RSIGMA)\n }\n\n if (Debug) Log.timeEnd('XplorParser._parse ' + this.name)\n }\n\n getMatrix () {\n const h = this.volume.header\n\n const basisX = [\n h.a,\n 0,\n 0\n ]\n\n const basisY = [\n h.b * Math.cos(Math.PI / 180.0 * h.gamma),\n h.b * Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n\n const basisZ = [\n h.c * Math.cos(Math.PI / 180.0 * h.beta),\n h.c * (\n Math.cos(Math.PI / 180.0 * h.alpha) -\n Math.cos(Math.PI / 180.0 * h.gamma) *\n Math.cos(Math.PI / 180.0 * h.beta)\n ) / Math.sin(Math.PI / 180.0 * h.gamma),\n 0\n ]\n basisZ[ 2 ] = Math.sqrt(\n h.c * h.c * Math.sin(Math.PI / 180.0 * h.beta) *\n Math.sin(Math.PI / 180.0 * h.beta) - basisZ[ 1 ] * basisZ[ 1 ]\n )\n\n const basis = [ [], basisX, basisY, basisZ ]\n const nxyz = [ 0, h.NA, h.NB, h.NC ]\n const mapcrs = [ 0, 1, 2, 3 ]\n\n const matrix = new Matrix4()\n\n matrix.set(\n basis[ mapcrs[1] ][0] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][0] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][0] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][1] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][1] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][1] / nxyz[ mapcrs[3] ],\n 0,\n basis[ mapcrs[1] ][2] / nxyz[ mapcrs[1] ],\n basis[ mapcrs[2] ][2] / nxyz[ mapcrs[2] ],\n basis[ mapcrs[3] ][2] / nxyz[ mapcrs[3] ],\n 0,\n 0, 0, 0, 1\n )\n\n matrix.multiply(new Matrix4().makeTranslation(\n h.AMIN, h.BMIN, h.CMIN\n ))\n\n return matrix\n }\n}\n\nParserRegistry.add('xplor', XplorParser)\nParserRegistry.add('cns', XplorParser)\n\nexport default XplorParser\n","/**\n * @file Kin Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { Vector3 } from 'three'\nimport Parser from './parser'\n\nfunction hsvToRgb (h: number, s: number, v: number) {\n h /= 360\n s /= 100\n v /= 100\n let r, g, b\n const i = Math.floor(h * 6)\n const f = h * 6 - i\n const p = v * (1 - s)\n const q = v * (1 - f * s)\n const t = v * (1 - (1 - f) * s)\n switch (i % 6) {\n case 0: r = v; g = t; b = p; break\n case 1: r = q; g = v; b = p; break\n case 2: r = p; g = v; b = t; break\n case 3: r = p; g = q; b = v; break\n case 4: r = t; g = p; b = v; break\n case 5: r = v; g = p; b = q; break\n }\n return [ r, g, b ] as number []\n}\n\nconst ColorDict: {[k: string]: number[]} = {\n red: hsvToRgb(0, 100, 100),\n orange: hsvToRgb(20, 100, 100),\n gold: hsvToRgb(40, 100, 100),\n yellow: hsvToRgb(60, 100, 100),\n lime: hsvToRgb(80, 100, 100),\n green: hsvToRgb(120, 80, 100),\n sea: hsvToRgb(150, 100, 100),\n cyan: hsvToRgb(180, 100, 85),\n sky: hsvToRgb(210, 75, 95),\n blue: hsvToRgb(240, 70, 100),\n purple: hsvToRgb(275, 75, 100),\n magenta: hsvToRgb(300, 95, 100),\n hotpink: hsvToRgb(335, 100, 100),\n pink: hsvToRgb(350, 55, 100),\n peach: hsvToRgb(25, 75, 100),\n lilac: hsvToRgb(275, 55, 100),\n pinktint: hsvToRgb(340, 30, 100),\n peachtint: hsvToRgb(25, 50, 100),\n yellowtint: hsvToRgb(60, 50, 100),\n greentint: hsvToRgb(135, 40, 100),\n bluetint: hsvToRgb(220, 40, 100),\n lilactint: hsvToRgb(275, 35, 100),\n white: hsvToRgb(0, 0, 100),\n gray: hsvToRgb(0, 0, 50),\n brown: hsvToRgb(20, 45, 75),\n deadwhite: [ 1, 1, 1 ],\n deadblack: [ 0, 0, 0 ],\n invisible: [ 0, 0, 0 ]\n}\n\nconst reWhitespaceComma = /[\\s,]+/\nconst reCurlyWhitespace = /[^{}\\s]*{[^{}]+}|[^{}\\s]+/g\nconst reTrimCurly = /^{+|}+$/g\nconst reTrimQuotes = /^['\"]+|['\"]+$/g\nconst reCollapseEqual = /\\s*=\\s*/g\n\nfunction parseListDef (line: string) {\n let name\n let defaultColor\n let master = []\n let width\n\n line = line.replace(reCollapseEqual, '=')\n\n const lm = line.match(reCurlyWhitespace) as RegExpMatchArray\n for (let j = 1; j < lm.length; ++j) {\n const e = lm[ j ]\n if (e[ 0 ] === '{') {\n name = e.substring(1, e.length - 1)\n } else {\n const es = e.split('=')\n if (es.length === 2) {\n if (es[ 0 ] === 'color') {\n defaultColor = ColorDict[ es[ 1 ] ]\n } else if (es[ 0 ] === 'width') {\n width = parseInt(es[ 1 ])\n } else if (es[ 0 ] === 'master') {\n master.push(es[ 1 ].replace(reTrimCurly, ''))\n }\n }\n }\n }\n\n return {\n listName: name,\n listColor: defaultColor,\n listMasters: master,\n listWidth: width\n }\n}\n\nfunction parseListElm (line: string) {\n line = line.trim()\n\n const idx1 = line.indexOf('{')\n const idx2 = line.indexOf('}')\n const ls = line.substr(idx2 + 1).split(reWhitespaceComma)\n\n const label = line.substr(idx1 + 1, idx2 - 1)\n const position = [\n parseFloat(ls[ ls.length - 3 ]),\n parseFloat(ls[ ls.length - 2 ]),\n parseFloat(ls[ ls.length - 1 ])\n ]\n let color, width, radius\n let lineBreak = false\n let triangleBreak = false\n for (let lsindex = 4; lsindex <= ls.length; lsindex++) {\n const literal = ls[ ls.length - lsindex ]\n if (literal in ColorDict) {\n color = ColorDict[ ls[ ls.length - lsindex ] ]\n }\n if (literal.startsWith('width')) {\n width = parseInt(literal.substring(5))\n }\n if (literal.startsWith('r=')) {\n radius = parseFloat(literal.split('=')[1])\n }\n if (literal.startsWith('P')) {\n lineBreak = true\n }\n if (literal.startsWith('X')) {\n triangleBreak = true\n }\n }\n // const color = line[ idx2 + 1 ] === ' ' ? undefined : ColorDict[ ls[ 0 ] ]\n\n return {\n label: label,\n position: position,\n color: color,\n radius: radius,\n width: width,\n isLineBreak: lineBreak,\n isTriangleBreak: triangleBreak\n }\n}\n\nfunction parseStr (line: string) {\n const start = line.indexOf('{')\n const end = line.indexOf('}')\n return line.substring(\n start !== -1 ? start + 1 : 0,\n end !== -1 ? end : undefined\n ).trim()\n}\n\nfunction parseFlag (line: string) {\n const end = line.indexOf('}')\n return end === -1 ? undefined : line.substr(end + 1).trim()\n}\n\nfunction parseGroup (line: string) {\n let name:string = ''\n let master:string[] = []\n let flags: {[k: string]: string|boolean} = {}\n\n line = line.replace(reCollapseEqual, '=')\n\n const lm = line.match(reCurlyWhitespace) as RegExpMatchArray\n for (let j = 1; j < lm.length; ++j) {\n const e = lm[ j ]\n if (e[ 0 ] === '{') {\n name = e.substring(1, e.length - 1)\n } else {\n const es = e.split('=')\n if (es.length === 2) {\n if (es[ 0 ] === 'master') {\n master.push(es[ 1 ].replace(reTrimCurly, ''))\n } else {\n flags[ es[ 0 ] ] = es[ 1 ].replace(reTrimCurly, '')\n }\n } else {\n flags[ es[ 0 ] ] = true\n }\n }\n }\n\n return { groupName: name,\n groupFlags: flags,\n groupMasters: master\n }\n}\ninterface RibbonObject {\n labelArray: string[],\n positionArray: number[],\n breakArray: boolean[],\n colorArray: number[],\n name?: string,\n masterArray: any[]\n}\nfunction convertKinTriangleArrays (ribbonObject: RibbonObject) {\n // have to convert ribbons/triangle lists from stripdrawmode to normal drawmode\n // index [ 0 1 2 3 4 5 6 7 8 91011 ]\n // label [ 0 1 2 3 4 5 ] to [ 0 1 2 1 2 3 2 3 4 3 4 5 ]\n // convertedindex [ 0 1 2 3 4 5 6 7 8 91011121314151617181920212223242526 ]\n // index [ 0 1 2 3 4 5 6 7 8 91011121314 ] [ 0 1 2 3 4 5 6 7 8 3 4 5 6 7 8 91011 6 7 8 91011121314 ]\n // position/color [ 0 0 0 1 1 1 2 2 2 3 3 3 4 4 4 ] to [ 0 0 0 1 1 1 2 2 2 1 1 1 2 2 2 3 3 3 2 2 2 3 3 3 4 4 4 ]\n let { labelArray, positionArray, colorArray, breakArray } = ribbonObject\n let convertedLabels = []\n for (let i = 0; i < (labelArray.length - 2) * 3; ++i) {\n convertedLabels[i] = labelArray[i - Math.floor(i / 3) * 2]\n }\n let convertedBreaks = []\n for (let i = 0; i < (breakArray.length - 2) * 3; ++i) {\n convertedBreaks[i] = breakArray[i - Math.floor(i / 3) * 2]\n }\n let convertedPositions = []\n for (let i = 0; i < (positionArray.length / 3 - 2) * 9; ++i) {\n convertedPositions[i] = positionArray[i - Math.floor(i / 9) * 6]\n }\n let convertedColors = []\n for (let i = 0; i < (colorArray.length / 3 - 2) * 9; ++i) {\n convertedColors[i] = colorArray[i - Math.floor(i / 9) * 6]\n }\n let vector3Positions = []\n for (let i = 0; i < (convertedPositions.length) / 3; ++i) {\n vector3Positions.push(new Vector3(convertedPositions[i * 3], convertedPositions[i * 3] + 1, convertedPositions[i * 3] + 2))\n }\n //let normals = []\n //for (let i = 0; i < vector3Positions.length - 1; ++i) {\n // let normalVec3 = vector3Positions[i].cross(vector3Positions[i + 1])\n // normals.push(normalVec3.x)\n // normals.push(normalVec3.y)\n // normals.push(normalVec3.z)\n //}\n return {\n name: ribbonObject.name,\n masterArray: ribbonObject.masterArray,\n labelArray: convertedLabels,\n positionArray: convertedPositions,\n breakArray: convertedBreaks,\n colorArray: convertedColors\n }\n}\n\nfunction removePointBreaksTriangleArrays (convertedRibbonObject: RibbonObject) {\n // after converting ribbon/triangle arrys to drawmode, removed point break triangles\n // label [ 0 1 2 3 4 5 ] to [ 0 1 2 1 2 3 2 3 4 3 4 5 ]\n // position/color [ 0 0 0 1 1 1 2 2 2 3 3 3 4 4 4 ] to [ 0 0 0 1 1 1 2 2 2 1 1 1 2 2 2 3 3 3 2 2 2 3 3 3 4 4 4 ]\n let { labelArray, positionArray, colorArray, breakArray } = convertedRibbonObject\n let editedLabels = []\n let editedPositions = []\n let editedColors = []\n let editedBreaks = []\n for (let i = 0; i < breakArray.length / 3; i++) {\n let breakPointer = i * 3\n let positionPointer = i * 9\n if (!breakArray[breakPointer+1]&&!breakArray[breakPointer+2]) {\n editedLabels.push(labelArray[breakPointer])\n editedLabels.push(labelArray[breakPointer+1])\n editedLabels.push(labelArray[breakPointer+2])\n editedBreaks.push(breakArray[breakPointer])\n editedBreaks.push(breakArray[breakPointer+1])\n editedBreaks.push(breakArray[breakPointer+2])\n editedPositions.push(positionArray[positionPointer])\n editedPositions.push(positionArray[positionPointer+1])\n editedPositions.push(positionArray[positionPointer+2])\n editedPositions.push(positionArray[positionPointer+3])\n editedPositions.push(positionArray[positionPointer+4])\n editedPositions.push(positionArray[positionPointer+5])\n editedPositions.push(positionArray[positionPointer+6])\n editedPositions.push(positionArray[positionPointer+7])\n editedPositions.push(positionArray[positionPointer+8])\n editedColors.push(colorArray[positionPointer])\n editedColors.push(colorArray[positionPointer+1])\n editedColors.push(colorArray[positionPointer+2])\n editedColors.push(colorArray[positionPointer+3])\n editedColors.push(colorArray[positionPointer+4])\n editedColors.push(colorArray[positionPointer+5])\n editedColors.push(colorArray[positionPointer+6])\n editedColors.push(colorArray[positionPointer+7])\n editedColors.push(colorArray[positionPointer+8])\n } else {\n //console.log('X triangle break found')\n //console.log('skipping: '+positionArray[positionPointer]+','+positionArray[positionPointer+1]+','+positionArray[positionPointer+2]+','\n // +positionArray[positionPointer+3]+','+positionArray[positionPointer+4]+','+positionArray[positionPointer+5]+','\n // +positionArray[positionPointer+6]+','+positionArray[positionPointer+7]+','+positionArray[positionPointer+8])\n }\n }\n return {\n name: convertedRibbonObject.name,\n masterArray: convertedRibbonObject.masterArray,\n labelArray: editedLabels,\n positionArray: editedPositions,\n breakArray: editedBreaks,\n colorArray: editedColors\n }\n}\n\ninterface Kinemage {\n kinemage?: number,\n onewidth?: any,\n '1viewid'?: string,\n pdbfile?: string,\n text: string,\n texts: string[],\n captions: string[],\n caption: string,\n groupDict: {[k:string]: {[k:string]: boolean}},\n subgroupDict: {[k: string]: any},\n masterDict: {[k:string]: {indent: boolean, visible: boolean}},\n pointmasterDict: {[k: string]: any},\n dotLists: DotList[],\n vectorLists: VectorList[],\n ballLists: any[],\n ribbonLists: RibbonObject[]\n}\n\ninterface DotList {\n name?: string,\n masterArray: any[],\n labelArray: any[],\n positionArray: any[],\n colorArray: any[]\n}\n\ninterface VectorList {\n name?: string,\n masterArray: any[],\n label1Array: string[],\n label2Array: string[],\n position1Array: number[],\n position2Array: number[],\n color1Array: number[],\n color2Array: number[],\n width: number[]\n}\n\nclass KinParser extends Parser {\n kinemage: Kinemage\n get type () { return 'kin' }\n get __objName () { return 'kinemage' }\n\n _parse () {\n // http://kinemage.biochem.duke.edu/software/king.php\n\n if (Debug) Log.time(`KinParser._parse ${this.name}`)\n\n const kinemage: Kinemage = {\n kinemage: undefined,\n onewidth: undefined,\n '1viewid': undefined,\n pdbfile: undefined,\n texts: [],\n text: '',\n captions: [],\n caption: '',\n groupDict: {},\n subgroupDict: {},\n masterDict: {},\n pointmasterDict: {},\n dotLists: [],\n vectorLists: [],\n ballLists: [],\n ribbonLists: []\n }\n this.kinemage = kinemage\n\n let currentGroupMasters: string[]\n let currentSubgroupMasters: string[]\n\n let isDotList = false\n let prevDotLabel = ''\n let dotDefaultColor: number[]\n let dotLabel: string[], dotPosition: number[], dotColor: number[]\n\n let isVectorList = false\n let prevVecLabel = ''\n let prevVecPosition: number[]|null = null\n let prevVecColor: number[]|null = null\n let vecDefaultColor: number[], vecDefaultWidth: number[]\n let vecLabel1: string[], vecLabel2: string[], vecPosition1: number[], vecPosition2: number[], vecColor1: number[], vecColor2: number[]\n\n let isBallList = false\n let prevBallLabel = ''\n let ballRadius: number[], ballDefaultColor: number[]\n let ballLabel: string[], ballPosition: number[], ballColor: number[]\n\n let isRibbonList = false\n let prevRibbonPointLabel = ''\n\n let ribbonListDefaultColor: number[]\n let ribbonPointLabelArray: string[], ribbonPointPositionArray: number[], ribbonPointBreakArray: boolean[], ribbonPointColorArray: number[]\n\n let isText = false\n let isCaption = false\n\n // @vectorlist {mc} color= white master= {mainchain}\n // { n thr A 1 B13.79 1crnFH} P 17.047, 14.099, 3.625 { n thr A 1 B13.79 1crnFH} L 17.047, 14.099, 3.625\n\n // @dotlist {x} color=white master={vdw contact} master={dots}\n // { CB THR 1 A}sky 'P' 18.915,14.199,5.024\n\n function _parseChunkOfLines (_i: number, _n: number, lines: string[]) {\n for (let i = _i; i < _n; ++i) {\n const line = lines[ i ]\n\n if (line[ 0 ] === '@') {\n isDotList = false\n isVectorList = false\n isBallList = false\n isRibbonList = false\n isText = false\n isCaption = false\n }\n\n if (!line) {\n isDotList = false\n isVectorList = false\n isBallList = false\n isRibbonList = false\n } else if (line.startsWith('@dotlist')) {\n // @dotlist {x} color=white master={vdw contact} master={dots}\n\n let { listColor, listName, listMasters } = parseListDef(line)\n\n isDotList = true\n prevDotLabel = ''\n dotLabel = []\n dotPosition = []\n dotColor = []\n dotDefaultColor = listColor as number[]\n\n if (currentGroupMasters) {\n listMasters = listMasters.concat(currentGroupMasters)\n }\n if (currentSubgroupMasters) {\n listMasters = listMasters.concat(currentSubgroupMasters)\n }\n\n kinemage.dotLists.push({\n name: listName,\n masterArray: listMasters,\n labelArray: dotLabel,\n positionArray: dotPosition,\n colorArray: dotColor\n })\n } else if (line.startsWith('@vectorlist')) {\n // @vectorlist {x} color=white master={small overlap} master={dots}\n\n let { listMasters, listName, listWidth, listColor } = parseListDef(line)\n\n if (listMasters) {\n listMasters.forEach(function (name: string) {\n if (!kinemage.masterDict[ name ]) {\n kinemage.masterDict[ name ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n\n isVectorList = true\n prevVecLabel = ''\n prevVecPosition = null\n prevVecColor = null\n vecLabel1 = []\n vecLabel2 = []\n vecPosition1 = []\n vecPosition2 = []\n vecColor1 = []\n vecColor2 = []\n vecDefaultColor = listColor as number[]\n vecDefaultWidth = []\n if (listWidth) {\n vecDefaultWidth.push(listWidth)\n }\n\n if (currentGroupMasters) {\n listMasters = listMasters.concat(currentGroupMasters)\n }\n if (currentSubgroupMasters) {\n listMasters = listMasters.concat(currentSubgroupMasters)\n }\n\n kinemage.vectorLists.push({\n name: listName,\n masterArray: listMasters,\n label1Array: vecLabel1,\n label2Array: vecLabel2,\n position1Array: vecPosition1,\n position2Array: vecPosition2,\n color1Array: vecColor1,\n color2Array: vecColor2,\n width: vecDefaultWidth\n })\n } else if (line.startsWith('@balllist')) {\n let { listName, listColor, listMasters } = parseListDef(line)\n\n if (listMasters) {\n listMasters.forEach(function (name: string) {\n if (!kinemage.masterDict[ name ]) {\n kinemage.masterDict[ name ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n\n isBallList = true\n\n prevBallLabel = ''\n ballLabel = []\n ballRadius = []\n ballPosition = []\n ballColor = []\n ballDefaultColor = listColor as number[]\n\n if (currentGroupMasters) {\n listMasters = listMasters.concat(currentGroupMasters)\n }\n if (currentSubgroupMasters) {\n listMasters = listMasters.concat(currentSubgroupMasters)\n }\n\n kinemage.ballLists.push({\n name: listName,\n masterArray: listMasters,\n labelArray: ballLabel,\n radiusArray: ballRadius,\n positionArray: ballPosition,\n colorArray: ballColor\n })\n } else if (line.startsWith('@ribbonlist')||line.startsWith('@trianglelist')) {\n let { listMasters, listName, listColor } = parseListDef(line)\n\n if (listMasters) {\n listMasters.forEach(function (name: string) {\n if (!kinemage.masterDict[ name ]) {\n kinemage.masterDict[ name ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n isRibbonList = true\n prevRibbonPointLabel = ''\n ribbonPointLabelArray = []\n ribbonPointPositionArray = []\n ribbonPointBreakArray = []\n ribbonPointColorArray = []\n ribbonListDefaultColor = listColor as number[]\n\n if (currentGroupMasters) {\n listMasters = listMasters.concat(currentGroupMasters)\n }\n if (currentSubgroupMasters) {\n listMasters = listMasters.concat(currentSubgroupMasters)\n }\n\n kinemage.ribbonLists.push({\n name: listName,\n masterArray: listMasters,\n labelArray: ribbonPointLabelArray,\n positionArray: ribbonPointPositionArray,\n breakArray: ribbonPointBreakArray,\n colorArray: ribbonPointColorArray\n })\n } else if (line.startsWith('@text')) {\n isText = true\n kinemage.texts.push(line.substr(5))\n } else if (line.startsWith('@caption')) {\n isCaption = true\n kinemage.captions.push(line.substr(8))\n } else if (isDotList) {\n // { CB THR 1 A}sky 'P' 18.915,14.199,5.024\n\n let { label, color, position } = parseListElm(line)\n\n if (label === '\"') {\n label = prevDotLabel\n } else {\n prevDotLabel = label\n }\n\n if (color === undefined) {\n color = dotDefaultColor\n }\n\n dotLabel.push(label)\n dotPosition.push(...position)\n dotColor.push(...color)\n } else if (isVectorList) {\n // { n thr A 1 B13.79 1crnFH} P 17.047, 14.099, 3.625 { n thr A 1 B13.79 1crnFH} L 17.047, 14.099, 3.625\n\n let doubleLine = line.replace(/(?!^){/g, '\\n{')\n let splitLine = doubleLine.split(/\\n/)\n\n for (var i2 = 0; i2 < splitLine.length; i2++) {\n let singlePointLine = splitLine[i2]\n let { label, color, width, position, isLineBreak } = parseListElm(singlePointLine)\n\n if (label === '\"') {\n label = prevVecLabel\n } else {\n prevVecLabel = label\n }\n\n if (color === undefined) {\n color = vecDefaultColor\n }\n\n if (!isLineBreak) {\n if (prevVecPosition !== null) {\n if (width) {\n vecDefaultWidth.push(width)\n }\n\n vecLabel1.push(prevVecLabel)\n vecPosition1.push(...prevVecPosition)\n vecColor1.push(...prevVecColor as number[])\n\n vecLabel2.push(label)\n vecPosition2.push(...position)\n vecColor2.push(...color)\n\n }\n }\n\n prevVecLabel = label\n prevVecPosition = position\n prevVecColor = color\n }\n } else if (isBallList) {\n // {cb arg A 1 1.431 -106.80} r=1.431 39.085, 8.083, 22.182\n\n let { label, radius, color, position } = parseListElm(line)\n\n if (label === '\"') {\n label = prevBallLabel\n } else {\n prevBallLabel = label\n }\n\n if (radius === undefined) {\n radius = 1 // temporary default radius\n }\n\n if (color === undefined) {\n color = ballDefaultColor\n }\n\n ballLabel.push(label)\n ballRadius.push(radius)\n ballPosition.push(...position)\n ballColor.push(...color)\n } else if (isRibbonList) {\n let { label, color, position, isTriangleBreak } = parseListElm(line)\n\n if (label === '\"') {\n label = prevRibbonPointLabel\n } else {\n prevRibbonPointLabel = label\n }\n\n if (color === undefined) {\n color = ribbonListDefaultColor\n }\n\n ribbonPointLabelArray.push(label)\n ribbonPointPositionArray.push(...position)\n ribbonPointBreakArray.push(isTriangleBreak)\n ribbonPointColorArray.push(...color)\n } else if (isText) {\n kinemage.texts.push(line)\n } else if (isCaption) {\n kinemage.captions.push(line)\n } else if (line.startsWith('@kinemage')) {\n kinemage.kinemage = parseInt(line.substr(9).trim())\n } else if (line.startsWith('@onewidth')) {\n kinemage.onewidth = true\n } else if (line.startsWith('@1viewid')) {\n kinemage[ '1viewid' ] = parseStr(line)\n } else if (line.startsWith('@pdbfile')) {\n kinemage.pdbfile = parseStr(line)\n } else if (line.startsWith('@group')) {\n let { groupName, groupFlags, groupMasters } = parseGroup(line)\n if (!kinemage.groupDict[ groupName as string ]) {\n kinemage.groupDict[ groupName as string ] = {\n dominant: false,\n animate: false\n }\n currentGroupMasters = groupMasters\n }\n\n if (currentGroupMasters) {\n currentGroupMasters.forEach(function (master) {\n if (!kinemage.masterDict[ master ]) {\n kinemage.masterDict[ master ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n\n for (let key in groupFlags as {[k: string]: boolean}) {\n kinemage.groupDict[ groupName as string ][ key ] = (groupFlags as {[k: string]: boolean})[ key ]\n }\n } else if (line.startsWith('@subgroup')) {\n const { groupName, groupFlags, groupMasters } = parseGroup(line)\n\n if (!kinemage.subgroupDict[ groupName as string ]) {\n kinemage.subgroupDict[ groupName as string ] = {\n dominant: false,\n animate: false\n }\n currentSubgroupMasters = groupMasters\n }\n\n if (currentSubgroupMasters) {\n currentSubgroupMasters.forEach(function (master) {\n if (!kinemage.masterDict[ master ]) {\n kinemage.masterDict[ master ] = {\n indent: false,\n visible: false\n }\n }\n })\n }\n\n for (let key in groupFlags as {[k: string]: boolean}) {\n kinemage.subgroupDict[ groupName as string ][ key ] = (groupFlags as {[k: string]: boolean})[ key ]\n }\n } else if (line.startsWith('@master')) {\n const name = parseStr(line)\n const flag = parseFlag(line)\n\n if (!kinemage.masterDict[ name ]) {\n kinemage.masterDict[ name ] = {\n indent: false,\n visible: false\n }\n }\n\n if (flag === 'on') {\n kinemage.masterDict[ name ].visible = true\n } else if (flag === 'off') {\n kinemage.masterDict[ name ].visible = false\n } else if (flag === 'indent') {\n kinemage.masterDict[ name ].indent = true\n } else if (!flag) {\n // nothing to do\n }\n } else if (line.startsWith('@pointmaster')) {\n const { groupName, groupFlags } = parseGroup(line)\n\n kinemage.pointmasterDict[ groupName as string] = {\n id: Object.keys(groupFlags as {[k: string]: boolean})[ 0 ].replace(reTrimQuotes, '')\n }\n } else {\n console.log(line)\n }\n }\n }\n\n this.streamer.eachChunkOfLines(function (lines/*, chunkNo, chunkCount */) {\n _parseChunkOfLines(0, lines.length, lines)\n })\n\n kinemage.text = kinemage.texts.join('\\n').trim()\n kinemage.caption = kinemage.captions.join('\\n').trim()\n if (kinemage.ribbonLists) {\n let convertedLists: RibbonObject[] = []\n kinemage.ribbonLists.forEach(function (listObject) {\n convertedLists.push(removePointBreaksTriangleArrays(convertKinTriangleArrays(listObject)))\n })\n kinemage.ribbonLists = convertedLists\n }\n\n if (Debug) Log.timeEnd(`KinParser._parse ${this.name}`)\n }\n}\n\nParserRegistry.add('kin', KinParser)\n\nexport default KinParser\n","/**\n * @file Surface Parser\n * @author Alexander Rose \n * @private\n */\n\nimport Parser, { ParserParameters } from './parser'\nimport Surface from '../surface/surface'\nimport Streamer from '../streamer/streamer';\n\nclass SurfaceParser extends Parser {\n constructor (streamer: Streamer, params?:Partial) {\n super(streamer, params)\n\n this.loader = this.getLoader()\n this.surface = new Surface(this.name, this.path)\n }\n\n get type () { return 'surface' }\n get __objName () { return 'surface' }\n\n _parse () {\n var geometry = this.loader.parse(this.streamer.asText())\n\n this.surface.fromGeometry(geometry)\n }\n}\n\nexport default SurfaceParser\n","/**\n * @file Obj Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { BufferGeometry, BufferAttribute } from 'three'\n\nimport { ParserRegistry } from '../globals'\nimport SurfaceParser from './surface-parser'\n\nexport interface _OBJLoader {\n regexp: {[k: string]: RegExp}\n}\n\ninterface _OBJLoaderConstructor {\n (this: _OBJLoader): void\n new(): _OBJLoader\n}\n\ninterface ObjectType {\n name: string,\n fromDeclaration: boolean,\n geometry: {\n vertices: number[],\n normals: number[],\n type?: string\n }\n}\n/**\n * OBJLoader\n * @class\n * @private\n * @author mrdoob / http://mrdoob.com/\n */\nconst OBJLoader = (function OBJLoader (this: _OBJLoader) {\n this.regexp = {\n // v float float float\n vertex_pattern: /^v\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)/,\n // vn float float float\n normal_pattern: /^vn\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)/,\n // vt float float\n uv_pattern: /^vt\\s+([\\d.+\\-eE]+)\\s+([\\d.+\\-eE]+)/,\n // f vertex vertex vertex\n face_vertex: /^f\\s+(-?\\d+)\\s+(-?\\d+)\\s+(-?\\d+)(?:\\s+(-?\\d+))?/,\n // f vertex/uv vertex/uv vertex/uv\n face_vertex_uv: /^f\\s+(-?\\d+)\\/(-?\\d+)\\s+(-?\\d+)\\/(-?\\d+)\\s+(-?\\d+)\\/(-?\\d+)(?:\\s+(-?\\d+)\\/(-?\\d+))?/,\n // f vertex/uv/normal vertex/uv/normal vertex/uv/normal\n face_vertex_uv_normal: /^f\\s+(-?\\d+)\\/(-?\\d+)\\/(-?\\d+)\\s+(-?\\d+)\\/(-?\\d+)\\/(-?\\d+)\\s+(-?\\d+)\\/(-?\\d+)\\/(-?\\d+)(?:\\s+(-?\\d+)\\/(-?\\d+)\\/(-?\\d+))?/,\n // f vertex//normal vertex//normal vertex//normal\n face_vertex_normal: /^f\\s+(-?\\d+)\\/\\/(-?\\d+)\\s+(-?\\d+)\\/\\/(-?\\d+)\\s+(-?\\d+)\\/\\/(-?\\d+)(?:\\s+(-?\\d+)\\/\\/(-?\\d+))?/,\n // o object_name | g group_name\n object_pattern: /^[og]\\s*(.+)?/,\n // s boolean\n smoothing_pattern: /^s\\s+(\\d+|on|off)/,\n // mtllib file_reference\n material_library_pattern: /^mtllib /,\n // usemtl material_name\n material_use_pattern: /^usemtl /\n }\n}) as _OBJLoaderConstructor\n\nOBJLoader.prototype = {\n\n constructor: OBJLoader,\n\n setPath: function (value: string) {\n this.path = value\n },\n\n _createParserState: function () {\n var state = {\n objects: [] as ObjectType[],\n object: {} as ObjectType,\n\n vertices: [],\n normals: [],\n\n startObject: function (name: string, fromDeclaration: boolean) {\n // If the current object (initial from reset) is not from a g/o declaration in the parsed\n // file. We need to use it for the first parsed g/o to keep things in sync.\n if (this.object && this.object.fromDeclaration === false) {\n this.object.name = name\n this.object.fromDeclaration = (fromDeclaration !== false)\n return\n }\n\n this.object = {\n name: name || '',\n geometry: {\n vertices: [],\n normals: []\n },\n fromDeclaration: (fromDeclaration !== false)\n }\n\n this.objects.push(this.object)\n },\n\n parseVertexIndex: function (value: string, len: number) {\n var index = parseInt(value, 10)\n return (index >= 0 ? index - 1 : index + len / 3) * 3\n },\n\n parseNormalIndex: function (value: string, len: number) {\n var index = parseInt(value, 10)\n return (index >= 0 ? index - 1 : index + len / 3) * 3\n },\n\n addVertex: function (a: number, b: number, c: number) {\n var src = this.vertices\n var dst = this.object.geometry.vertices\n\n dst.push(src[ a + 0 ])\n dst.push(src[ a + 1 ])\n dst.push(src[ a + 2 ])\n dst.push(src[ b + 0 ])\n dst.push(src[ b + 1 ])\n dst.push(src[ b + 2 ])\n dst.push(src[ c + 0 ])\n dst.push(src[ c + 1 ])\n dst.push(src[ c + 2 ])\n },\n\n addVertexLine: function (a: number) {\n var src = this.vertices\n var dst = this.object.geometry.vertices\n\n dst.push(src[ a + 0 ])\n dst.push(src[ a + 1 ])\n dst.push(src[ a + 2 ])\n },\n\n addNormal: function (a: number, b: number, c: number) {\n var src = this.normals\n var dst = this.object.geometry.normals\n\n dst.push(src[ a + 0 ])\n dst.push(src[ a + 1 ])\n dst.push(src[ a + 2 ])\n dst.push(src[ b + 0 ])\n dst.push(src[ b + 1 ])\n dst.push(src[ b + 2 ])\n dst.push(src[ c + 0 ])\n dst.push(src[ c + 1 ])\n dst.push(src[ c + 2 ])\n },\n\n addFace: function (a: string, b: string, c: string, d?: string, na?: string, nb?: string, nc?: string, nd?: string) {\n var vLen = this.vertices.length\n\n var ia = this.parseVertexIndex(a, vLen)\n var ib = this.parseVertexIndex(b, vLen)\n var ic = this.parseVertexIndex(c, vLen)\n var id\n\n if (d === undefined) {\n this.addVertex(ia, ib, ic)\n } else {\n id = this.parseVertexIndex(d, vLen)\n\n this.addVertex(ia, ib, id)\n this.addVertex(ib, ic, id)\n }\n\n if (na !== undefined) {\n // Normals are many times the same. If so, skip function call and parseInt.\n var nLen = this.normals.length\n ia = this.parseNormalIndex(na, nLen)\n\n ib = na === nb ? ia : this.parseNormalIndex(nb!, nLen)\n ic = na === nc ? ia : this.parseNormalIndex(nc!, nLen)\n\n if (d === undefined) {\n this.addNormal(ia, ib, ic)\n } else {\n id = this.parseNormalIndex(nd!, nLen)\n\n this.addNormal(ia, ib, id)\n this.addNormal(ib, ic, id)\n }\n }\n },\n\n addLineGeometry: function (vertices: string[]) {\n this.object.geometry.type = 'Line'\n\n var vLen = this.vertices.length\n\n for (var vi = 0, l = vertices.length; vi < l; vi++) {\n this.addVertexLine(this.parseVertexIndex(vertices[ vi ], vLen))\n }\n }\n\n }\n\n state.startObject('', false)\n\n return state\n },\n\n parse: function (text: string) {\n var state = this._createParserState()\n\n if (text.indexOf('\\r\\n') !== -1) {\n // This is faster than String.split with regex that splits on both\n text = text.replace(/\\r\\n/g, '\\n')\n }\n\n if (text.indexOf('\\\\\\n') !== -1) {\n // join lines separated by a line continuation character (\\)\n text = text.replace(/\\\\\\n/g, '')\n }\n\n var i, l\n var lines = text.split('\\n')\n var line = ''\n var lineFirstChar = ''\n var lineSecondChar = ''\n var lineLength = 0\n var result = []\n\n // Faster to just trim left side of the line. Use if available.\n var trimLeft = (typeof ''.trimLeft === 'function')\n\n for (i = 0, l = lines.length; i < l; i++) {\n line = lines[ i ]\n\n line = trimLeft ? line.trimLeft() : line.trim()\n\n lineLength = line.length\n\n if (lineLength === 0) continue\n\n lineFirstChar = line.charAt(0)\n\n // @todo invoke passed in handler if any\n if (lineFirstChar === '#') continue\n\n if (lineFirstChar === 'v') {\n lineSecondChar = line.charAt(1)\n\n if (lineSecondChar === ' ' && (result = this.regexp.vertex_pattern.exec(line)) !== null) {\n // 0 1 2 3\n // [\"v 1.0 2.0 3.0\", \"1.0\", \"2.0\", \"3.0\"]\n\n state.vertices.push(\n parseFloat(result[ 1 ]),\n parseFloat(result[ 2 ]),\n parseFloat(result[ 3 ])\n )\n } else if (lineSecondChar === 'n' && (result = this.regexp.normal_pattern.exec(line)) !== null) {\n // 0 1 2 3\n // [\"vn 1.0 2.0 3.0\", \"1.0\", \"2.0\", \"3.0\"]\n\n state.normals.push(\n parseFloat(result[ 1 ]),\n parseFloat(result[ 2 ]),\n parseFloat(result[ 3 ])\n )\n } else if (lineSecondChar === 't' && this.regexp.uv_pattern.exec(line) !== null) {\n\n // ignore uv line\n\n } else {\n throw new Error(\"Unexpected vertex/normal/uv line: '\" + line + \"'\")\n }\n } else if (lineFirstChar === 'f') {\n if ((result = this.regexp.face_vertex_uv_normal.exec(line)) !== null) {\n // f vertex/uv/normal vertex/uv/normal vertex/uv/normal\n // 0 1 2 3 4 5 6 7 8 9 10 11 12\n // [\"f 1/1/1 2/2/2 3/3/3\", \"1\", \"1\", \"1\", \"2\", \"2\", \"2\", \"3\", \"3\", \"3\", undefined, undefined, undefined]\n\n state.addFace(\n result[ 1 ], result[ 4 ], result[ 7 ], result[ 10 ],\n // result[ 2 ], result[ 5 ], result[ 8 ], result[ 11 ], // ignore uv part\n result[ 3 ], result[ 6 ], result[ 9 ], result[ 12 ]\n )\n } else if (this.regexp.face_vertex_uv.exec(line) !== null) {\n\n // ignore uv line\n\n } else if ((result = this.regexp.face_vertex_normal.exec(line)) !== null) {\n // f vertex//normal vertex//normal vertex//normal\n // 0 1 2 3 4 5 6 7 8\n // [\"f 1//1 2//2 3//3\", \"1\", \"1\", \"2\", \"2\", \"3\", \"3\", undefined, undefined]\n\n state.addFace(\n result[ 1 ], result[ 3 ], result[ 5 ], result[ 7 ],\n result[ 2 ], result[ 4 ], result[ 6 ], result[ 8 ]\n )\n } else if ((result = this.regexp.face_vertex.exec(line)) !== null) {\n // f vertex vertex vertex\n // 0 1 2 3 4\n // [\"f 1 2 3\", \"1\", \"2\", \"3\", undefined]\n\n state.addFace(\n result[ 1 ], result[ 2 ], result[ 3 ], result[ 4 ]\n )\n } else {\n throw new Error(\"Unexpected face line: '\" + line + \"'\")\n }\n } else if (lineFirstChar === 'l') {\n var lineParts = line.substring(1).trim().split(' ')\n var lineVertices = []\n var lineUVs = []\n\n if (line.indexOf('/') === -1) {\n lineVertices = lineParts\n } else {\n for (var li = 0, llen = lineParts.length; li < llen; li++) {\n var parts = lineParts[ li ].split('/')\n\n if (parts[ 0 ] !== '') lineVertices.push(parts[ 0 ])\n if (parts[ 1 ] !== '') lineUVs.push(parts[ 1 ])\n }\n }\n state.addLineGeometry(lineVertices, lineUVs)\n } else if ((result = this.regexp.object_pattern.exec(line)) !== null) {\n // o object_name\n // or\n // g group_name\n\n var name = result[ 0 ].substr(1).trim()\n state.startObject(name)\n\n // ignore material related lines\n // eslint-disable-next-line no-empty\n } else if (this.regexp.material_use_pattern.test(line)) {\n // eslint-disable-next-line no-empty\n } else if (this.regexp.material_library_pattern.test(line)) {\n // eslint-disable-next-line no-empty\n } else if (this.regexp.smoothing_pattern.exec(line) !== null) {\n } else {\n // Handle null terminated files without exception\n if (line === '\\0') continue\n\n throw new Error(\"Unexpected line: '\" + line + \"'\")\n }\n }\n\n var container = []\n\n for (i = 0, l = state.objects.length; i < l; i++) {\n var object = state.objects[ i ]\n var geometry = object.geometry\n\n // Skip o/g line declarations that did not follow with any faces\n if (geometry.vertices.length === 0) continue\n\n var buffergeometry = new BufferGeometry()\n\n buffergeometry.setAttribute('position', new BufferAttribute(new Float32Array(geometry.vertices), 3))\n\n if (geometry.normals.length > 0) {\n buffergeometry.setAttribute('normal', new BufferAttribute(new Float32Array(geometry.normals), 3))\n } else {\n buffergeometry.computeVertexNormals()\n }\n\n container.push(buffergeometry)\n }\n\n return container\n }\n\n}\n\nclass ObjParser extends SurfaceParser {\n get type () { return 'obj' }\n\n getLoader () {\n return new OBJLoader()\n }\n}\n\nParserRegistry.add('obj', ObjParser)\n\nexport default ObjParser\n","/**\n * @file Ply Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Geometry, Vector3, Face3, Color } from 'three'\n\nimport { ParserRegistry } from '../globals'\nimport SurfaceParser from './surface-parser'\n\n/**\n * PLYLoader\n * @class\n * @private\n * @author Wei Meng / http://about.me/menway\n *\n * @description\n * A THREE loader for PLY ASCII files (known as the Polygon File Format or the Stanford Triangle Format).\n *\n * Limitations: ASCII decoding assumes file is UTF-8.\n *\n * @example\n * var loader = new THREE.PLYLoader();\n * loader.load('./models/ply/ascii/dolphins.ply', function (geometry) {\n * scene.add( new THREE.Mesh( geometry ) );\n * } );\n *\n * // If the PLY file uses non standard property names, they can be mapped while\n * // loading. For example, the following maps the properties\n * // “diffuse_(red|green|blue)” in the file to standard color names.\n *\n * loader.setPropertyNameMapping( {\n * diffuse_red: 'red',\n * diffuse_green: 'green',\n * diffuse_blue: 'blue'\n * } );\n *\n */\n\nexport interface _PLYLoader {\n propertyNameMapping: {[k: string]: string}\n}\n\ninterface _PLYLoaderConstructor {\n (this: _PLYLoader): void\n new(): _PLYLoader\n}\n\ninterface PLYProperty {\n type: string,\n name: string,\n countType: string,\n itemType: string\n}\n\ninterface PLYElement {\n name: string,\n count: number,\n properties: PLYProperty[],\n x: number,\n y: number,\n z: number,\n red: number,\n green: number,\n blue: number,\n [k:string]: any\n}\n\ninterface PLYHeader {\n format: string,\n version: string,\n comments: string[],\n elements: PLYElement[],\n headerLength: number\n}\n\ninterface GeometryPLY extends Geometry {\n useColor: boolean\n}\n\nconst PLYLoader = (function PLYLoader (this: _PLYLoader) {\n this.propertyNameMapping = {}\n}) as _PLYLoaderConstructor\n\nPLYLoader.prototype = {\n\n constructor: PLYLoader,\n\n setPropertyNameMapping: function (mapping: {[k: string]: string}) {\n this.propertyNameMapping = mapping\n },\n\n bin2str: function (buf: ArrayBuffer) {\n var arrayBuffer = new Uint8Array(buf)\n var str = ''\n for (var i = 0; i < buf.byteLength; i++) {\n str += String.fromCharCode(arrayBuffer[ i ]) // implicitly assumes little-endian\n }\n\n return str\n },\n\n isASCII: function (data: ArrayBuffer) {\n var header = this.parseHeader(this.bin2str(data))\n\n return header.format === 'ascii'\n },\n\n parse: function (data: string|ArrayBuffer) {\n if (data instanceof ArrayBuffer) {\n return (\n this.isASCII(data)\n ? this.parseASCII(this.bin2str(data))\n : this.parseBinary(data)\n )\n } else {\n return this.parseASCII(data)\n }\n },\n\n parseHeader: function (data: string) {\n var patternHeader = /ply([\\s\\S]*)end_header\\s/\n var headerText = ''\n var headerLength = 0\n var result = patternHeader.exec(data)\n if (result !== null) {\n headerText = result[ 1 ]\n headerLength = result[ 0 ].length\n }\n\n var header: Partial = {\n comments: [],\n elements: [],\n headerLength: headerLength\n }\n\n var lines = headerText.split('\\n')\n var currentElement: PLYElement|undefined, lineType, lineValues\n\n function makePlyElementProperty (propertValues: string[], propertyNameMapping: {[k: string]: string}) {\n var property = {\n type: propertValues[ 0 ]\n } as PLYProperty\n\n if (property.type === 'list') {\n property.name = propertValues[ 3 ]\n property.countType = propertValues[ 1 ]\n property.itemType = propertValues[ 2 ]\n } else {\n property.name = propertValues[ 1 ]\n }\n\n if (property.name in propertyNameMapping) {\n property.name = propertyNameMapping[ property.name ]\n }\n\n return property\n }\n\n for (var i = 0; i < lines.length; i++) {\n var line = lines[ i ]\n line = line.trim()\n if (line === '') {\n continue\n }\n lineValues = line.split(/\\s+/)\n lineType = lineValues.shift()\n line = lineValues.join(' ')\n\n switch (lineType) {\n case 'format':\n\n header.format = lineValues[ 0 ]\n header.version = lineValues[ 1 ]\n\n break\n\n case 'comment':\n\n header.comments!.push(line)\n\n break\n\n case 'element':\n\n if (currentElement !== undefined) {\n header.elements!.push(currentElement as PLYElement)\n }\n\n currentElement = {} as PLYElement\n currentElement.name = lineValues[ 0 ]\n currentElement.count = parseInt(lineValues[ 1 ])\n currentElement.properties = []\n\n break\n\n case 'property':\n\n currentElement!.properties.push(makePlyElementProperty(lineValues, this.propertyNameMapping))\n\n break\n\n default:\n\n console.log('unhandled', lineType, lineValues)\n }\n }\n\n if (currentElement !== undefined) {\n header.elements!.push(currentElement)\n }\n\n return header\n },\n\n parseASCIINumber: function (n: string, type: string) {\n switch (type) {\n case 'char': case 'uchar': case 'short': case 'ushort': case 'int': case 'uint':\n case 'int8': case 'uint8': case 'int16': case 'uint16': case 'int32': case 'uint32':\n\n return parseInt(n)\n\n case 'float': case 'double': case 'float32': case 'float64':\n\n return parseFloat(n)\n }\n },\n\n parseASCIIElement: function (properties: PLYProperty[], line: string) {\n var values = line.split(/\\s+/)\n\n var element = {} as PLYElement\n\n for (var i = 0; i < properties.length; i++) {\n if (properties[ i ].type === 'list') {\n var list = []\n var n = this.parseASCIINumber(values.shift(), properties[ i ].countType)\n\n for (var j = 0; j < n; j++) {\n list.push(this.parseASCIINumber(values.shift(), properties[ i ].itemType))\n }\n\n element[ properties[ i ].name ] = list\n } else {\n element[ properties[ i ].name ] = this.parseASCIINumber(values.shift(), properties[ i ].type)\n }\n }\n\n return element\n },\n\n parseASCII: function (data: string) {\n // PLY ascii format specification, as per http://en.wikipedia.org/wiki/PLY_(file_format)\n\n var geometry = new Geometry() as GeometryPLY\n\n var result\n\n var header = this.parseHeader(data)\n\n var patternBody = /end_header\\s([\\s\\S]*)$/\n var body = ''\n if ((result = patternBody.exec(data)) !== null) {\n body = result[ 1 ]\n }\n\n var lines = body.split('\\n')\n var currentElement = 0\n var currentElementCount = 0\n geometry.useColor = false\n\n for (var i = 0; i < lines.length; i++) {\n var line = lines[ i ]\n line = line.trim()\n if (line === '') {\n continue\n }\n\n if (currentElementCount >= header.elements[ currentElement ].count) {\n currentElement++\n currentElementCount = 0\n }\n\n var element = this.parseASCIIElement(header.elements[ currentElement ].properties, line)\n\n this.handleElement(geometry, header.elements[ currentElement ].name, element)\n\n currentElementCount++\n }\n\n return this.postProcess(geometry)\n },\n\n postProcess: function (geometry: GeometryPLY) {\n if (geometry.useColor) {\n for (var i = 0; i < geometry.faces.length; i++) {\n geometry.faces[ i ].vertexColors = [\n geometry.colors[ geometry.faces[ i ].a ],\n geometry.colors[ geometry.faces[ i ].b ],\n geometry.colors[ geometry.faces[ i ].c ]\n ]\n }\n\n geometry.elementsNeedUpdate = true\n }\n\n geometry.computeBoundingSphere()\n\n return geometry\n },\n\n handleElement: function (geometry: GeometryPLY, elementName: string, element: PLYElement) {\n if (elementName === 'vertex') {\n geometry.vertices.push(\n new Vector3(element.x, element.y, element.z)\n )\n\n if ('red' in element && 'green' in element && 'blue' in element) {\n geometry.useColor = true\n\n var color = new Color()\n color.setRGB(element.red / 255.0, element.green / 255.0, element.blue / 255.0)\n geometry.colors.push(color)\n }\n } else if (elementName === 'face') {\n var vertexIndices = element.vertex_indices\n\n if (vertexIndices.length === 3) {\n geometry.faces.push(\n new Face3(vertexIndices[ 0 ], vertexIndices[ 1 ], vertexIndices[ 2 ])\n )\n } else if (vertexIndices.length === 4) {\n geometry.faces.push(\n new Face3(vertexIndices[ 0 ], vertexIndices[ 1 ], vertexIndices[ 3 ]),\n new Face3(vertexIndices[ 1 ], vertexIndices[ 2 ], vertexIndices[ 3 ])\n )\n }\n }\n },\n\n binaryRead: function (dataview: DataView, at: number, type: string, littleEndian: boolean) {\n switch (type) {\n // corespondences for non-specific length types here match rply:\n case 'int8': case 'char': return [ dataview.getInt8(at), 1 ]\n\n case 'uint8': case 'uchar': return [ dataview.getUint8(at), 1 ]\n\n case 'int16': case 'short': return [ dataview.getInt16(at, littleEndian), 2 ]\n\n case 'uint16': case 'ushort': return [ dataview.getUint16(at, littleEndian), 2 ]\n\n case 'int32': case 'int': return [ dataview.getInt32(at, littleEndian), 4 ]\n\n case 'uint32': case 'uint': return [ dataview.getUint32(at, littleEndian), 4 ]\n\n case 'float32': case 'float': return [ dataview.getFloat32(at, littleEndian), 4 ]\n\n case 'float64': case 'double': return [ dataview.getFloat64(at, littleEndian), 8 ]\n }\n },\n\n binaryReadElement: function (dataview: DataView, at: number, properties: PLYProperty[], littleEndian: boolean) {\n var element = {} as PLYElement\n var result\n var read = 0\n\n for (var i = 0; i < properties.length; i++) {\n if (properties[ i ].type === 'list') {\n var list = []\n\n result = this.binaryRead(dataview, at + read, properties[ i ].countType, littleEndian)\n var n = result[ 0 ]\n read += result[ 1 ]\n\n for (var j = 0; j < n; j++) {\n result = this.binaryRead(dataview, at + read, properties[ i ].itemType, littleEndian)\n list.push(result[ 0 ])\n read += result[ 1 ]\n }\n\n element[ properties[ i ].name ] = list\n } else {\n result = this.binaryRead(dataview, at + read, properties[ i ].type, littleEndian)\n element[ properties[ i ].name ] = result[ 0 ]\n read += result[ 1 ]\n }\n }\n\n return [ element, read ]\n },\n\n parseBinary: function (data: ArrayBuffer) {\n var geometry = new Geometry()\n\n var header = this.parseHeader(this.bin2str(data))\n var littleEndian = (header.format === 'binary_little_endian')\n var body = new DataView(data, header.headerLength)\n var result\n var loc = 0\n\n for (var currentElement = 0; currentElement < header.elements.length; currentElement++) {\n for (var currentElementCount = 0; currentElementCount < header.elements[ currentElement ].count; currentElementCount++) {\n result = this.binaryReadElement(body, loc, header.elements[ currentElement ].properties, littleEndian)\n loc += result[ 1 ]\n var element = result[ 0 ]\n\n this.handleElement(geometry, header.elements[ currentElement ].name, element)\n }\n }\n\n return this.postProcess(geometry)\n }\n\n}\n\nclass PlyParser extends SurfaceParser {\n get type () { return 'ply' }\n\n getLoader () {\n return new PLYLoader()\n }\n}\n\nParserRegistry.add('ply', PlyParser)\n\nexport default PlyParser\n","/**\n * @file Csv Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { defaults } from '../utils'\nimport { ParserRegistry } from '../globals'\nimport Parser, { ParserParameters } from './parser'\nimport Streamer from '../streamer/streamer';\n\nexport interface CsvParserParameters extends ParserParameters {\n delimiter: string\n comment: string\n columnNames: boolean\n}\n/**\n * CSV parser\n */\nclass CsvParser extends Parser {\n /**\n * [constructor description]\n * @param {Streamer} streamer - the streamer object\n * @param {Object} params - parameter object\n * @param {Char} params.delimiter - delimiter character\n * @param {Char} params.comment - comment character\n * @param {Boolean} params.columnNames - use first data line as column names\n */\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.delimiter = defaults(p.delimiter, ',')\n this.comment = defaults(p.comment, '#')\n this.columnNames = defaults(p.columnNames, false)\n\n this.table = {\n name: this.name,\n path: this.path,\n columnNames: [],\n data: []\n }\n }\n\n get type () { return 'csv' }\n get __objName () { return 'table' }\n\n _parse () {\n const data = this.table.data\n const reDelimiter = new RegExp('\\\\s*' + this.delimiter + '\\\\s*')\n\n let j = 0\n\n this.streamer.eachChunkOfLines(chunk => {\n const n = chunk.length\n\n for (let i = 0; i < n; ++i) {\n const line = chunk[ i ].trim()\n if (line.startsWith(this.comment)) continue\n const values = line.split(reDelimiter)\n\n if (j === 0) {\n this.table.columnNames = values\n } else if (line) {\n data.push(values)\n }\n ++j\n }\n })\n }\n}\n\nParserRegistry.add('csv', CsvParser)\n\nexport default CsvParser\n","/**\n * @file Json Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport { defaults } from '../utils'\nimport Parser, { ParserParameters } from './parser'\nimport Streamer from '../streamer/streamer';\n\nexport interface JsonParserParameters extends ParserParameters {\n string: boolean\n}\n\nclass JsonParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.string = defaults(p.string, false)\n\n this.json = {\n name: this.name,\n path: this.path,\n data: {}\n }\n }\n\n get type () { return 'json' }\n get __objName () { return 'json' }\n get isJson () { return true }\n\n _parse () {\n if (this.streamer.isBinary() || this.string) {\n this.json.data = JSON.parse(this.streamer.asText())\n } else {\n this.json.data = this.streamer.data\n }\n }\n}\n\nParserRegistry.add('json', JsonParser)\n\nexport default JsonParser\n","/**\n * @file Msgpack Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport Parser, { ParserParameters } from './parser'\n\nimport { decodeMsgpack } from '../../lib/mmtf.es6'\nimport Streamer from '../streamer/streamer';\n\nclass MsgpackParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.msgpack = {\n name: this.name,\n path: this.path,\n data: undefined\n }\n }\n\n get type () { return 'msgpack' }\n get __objName () { return 'msgpack' }\n get isBinary () { return true }\n\n _parse () {\n if (Debug) Log.time('MsgpackParser._parse ' + this.name)\n\n this.msgpack.data = decodeMsgpack(this.streamer.data)\n\n if (Debug) Log.timeEnd('MsgpackParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('msgpack', MsgpackParser)\n\nexport default MsgpackParser\n","/**\n * @file Netcdf Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport Parser, { ParserParameters } from './parser'\nimport NetcdfReader from '../utils/netcdf-reader'\nimport Streamer from '../streamer/streamer';\n\nclass NetcdfParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.netcdf = {\n name: this.name,\n path: this.path,\n data: undefined\n }\n }\n\n get type () { return 'netcdf' }\n get __objName () { return 'netcdf' }\n get isBinary () { return true }\n\n _parse () {\n if (Debug) Log.time('NetcdfParser._parse ' + this.name)\n\n this.netcdf.data = new NetcdfReader(this.streamer.data)\n\n if (Debug) Log.timeEnd('NetcdfParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('netcdf', NetcdfParser)\n\nexport default NetcdfParser\n","/**\n * @file Text Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { ParserRegistry } from '../globals'\nimport Parser, { ParserParameters } from './parser'\nimport Streamer from '../streamer/streamer';\n\nclass TextParser extends Parser {\n constructor (streamer: Streamer, params?: Partial) {\n super(streamer, params)\n\n this.text = {\n\n name: this.name,\n path: this.path,\n data: ''\n\n }\n }\n\n get type () { return 'text' }\n get __objName () { return 'text' }\n\n _parse () {\n this.text.data = this.streamer.asText()\n }\n}\n\nParserRegistry.add('txt', TextParser)\nParserRegistry.add('text', TextParser)\n\nexport default TextParser\n","/**\n * @file Parse Xml\n * @author Alexander Rose \n * @private\n */\n\n// https://github.com/segmentio/xml-parser\n// MIT license\n\nexport type XMLNodeAttributes = { [k: string]: any }\nexport interface XMLNode {\n name?: string\n content?: string\n attributes: XMLNodeAttributes\n children?: XMLNode[]\n}\n\nconst reStrip = /^['\"]|['\"]$/g\nconst reTag = /^<([\\w-:.]+)\\s*/\nconst reContent = /^([^<]*)/\nconst reAttr = /([\\w:-]+)\\s*=\\s*(\"[^\"]*\"|'[^']*'|\\w+)\\s*/\n\nfunction strip (val: string) {\n return val.replace(reStrip, '')\n}\n\nexport function parseXml (xml: string) {\n // trim and strip comments\n xml = xml.trim().replace(//g, '')\n\n return document()\n\n function document () {\n return {\n declaration: declaration(),\n root: tag()\n }\n }\n\n function declaration () {\n const m = match(/^<\\?xml\\s*/)\n if (!m) return\n\n // tag\n const node: XMLNode = {\n attributes: {}\n }\n\n // attributes\n while (!(eos() || is('?>'))) {\n const attr = attribute()\n if (!attr) return node\n node.attributes[attr.name] = attr.value\n }\n match(/\\?>\\s*/)\n return node\n }\n\n function tag () {\n const m = match(reTag)\n if (!m) return\n\n // name\n const node: XMLNode = {\n name: m[1],\n attributes: {},\n children: []\n }\n\n // attributes\n while (!(eos() || is('>') || is('?>') || is('/>'))) {\n const attr = attribute()\n if (!attr) return node\n node.attributes[attr.name] = attr.value\n }\n\n // self closing tag\n if (match(/^\\s*\\/>\\s*/)) {\n return node\n }\n match(/\\??>\\s*/)\n\n // content\n node.content = content()\n\n // children\n let child\n while ((child = tag())) {\n node.children!.push(child)\n }\n\n // closing\n match(/^<\\/[\\w-:.]+>\\s*/)\n return node\n }\n\n function content () {\n const m = match(reContent)\n if (m) return m[1]\n return ''\n }\n\n function attribute () {\n const m = match(reAttr)\n if (!m) return\n return { name: m[1], value: strip(m[2]) }\n }\n\n function match (re: RegExp) {\n const m = xml.match(re)\n if (!m) return\n xml = xml.slice(m[0].length)\n return m\n }\n\n function eos () {\n return xml.length === 0\n }\n\n function is (prefix: string) {\n return xml.indexOf(prefix) === 0\n }\n}\n","/**\n * @file Xml Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport { defaults } from '../utils'\n// @ts-ignore: unused import XMLNode required for declaration only\nimport { parseXml, XMLNode } from '../utils/parse-xml'\nimport Parser, { ParserParameters } from './parser'\nimport Streamer from '../streamer/streamer';\n\nexport interface XmlParserParameters extends ParserParameters {\n useDomParser: boolean\n}\n\nclass XmlParser extends Parser {\n xml: {\n name: string\n path: string\n data: any\n }\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.useDomParser = defaults(p.useDomParser, false)\n\n this.xml = {\n name: this.name,\n path: this.path,\n data: {}\n }\n }\n\n get type () { return 'xml' }\n get __objName () { return 'xml' }\n get isXml () { return true }\n\n __xmlParser (xml: string) {\n return parseXml(xml)\n }\n\n __domParser (xml: string) {\n const domParser = new (window as any).DOMParser() as DOMParser\n return domParser.parseFromString(xml, 'text/xml')\n }\n\n _parse () {\n if (Debug) Log.time('XmlParser._parse ' + this.name)\n\n if (this.useDomParser) {\n if (this.streamer.data instanceof Document) { //TS conversion: stripped the window prefix from window.Document\n this.xml.data = this.streamer.data\n } else {\n this.xml.data = this.__domParser(this.streamer.asText())\n }\n } else {\n this.xml.data = this.__xmlParser(this.streamer.asText())\n }\n\n if (Debug) Log.timeEnd('XmlParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('xml', XmlParser)\n\nexport default XmlParser\n","/**\n * @file Validation\n * @author Alexander Rose \n * @private\n */\n\nimport { Vector3, Color } from 'three'\n\nimport { Debug, Log } from '../globals'\nimport { defaults } from '../utils'\nimport { ClashPicker } from '../utils/picker'\nimport { uniformArray3 } from '../math/array-utils'\nimport { guessElement } from '../structure/structure-utils'\nimport AtomProxy from '../proxy/atom-proxy'\nimport Structure from '../structure/structure'\n\nfunction getNamedItem(a: NamedNodeMap, name: string) {\n const item = a.getNamedItem(name)\n return item !== null ? item.value : ''\n}\n\nfunction getSele (a: NamedNodeMap, atomname?: string, useAltcode = false) {\n const icode = getNamedItem(a, 'icode').trim()\n const chain = getNamedItem(a, 'chain').trim()\n const altcode = getNamedItem(a, 'altcode')\n let sele = getNamedItem(a, 'resnum')\n if (icode) sele += '^' + icode\n if (chain) sele += ':' + chain\n if (atomname) sele += '.' + atomname\n if (useAltcode && altcode.trim()) sele += '%' + altcode\n sele += '/' + (parseInt(getNamedItem(a, 'model')) - 1)\n return sele\n}\n\nfunction getResSele (a: NamedNodeMap) {\n const chain = getNamedItem(a, 'chain').trim()\n const rescode = getNamedItem(a, 'rescode')\n const resnum = getNamedItem(a, 'resnum')\n let sele = `[${rescode}]${resnum}`\n if (chain) sele += `:${chain}`\n return sele\n}\n\nfunction setBitDict (dict: { [k: string]: number }, key: string, bit: number) {\n if (dict[ key ] === undefined) {\n dict[ key ] = bit\n } else {\n dict[ key ] |= bit\n }\n}\n\nfunction hasAttrValue (attr: Attr|null, value: string) {\n return attr !== null && attr.value === value\n}\n\nfunction getAtomSele (ap: AtomProxy) {\n const icode = ap.inscode\n const chain = ap.chainname\n const atomname = ap.atomname\n const altcode = ap.altloc\n let sele = ap.resno + ''\n if (icode) sele += '^' + icode\n if (chain) sele += ':' + chain\n if (atomname) sele += '.' + atomname\n if (altcode) sele += '%' + altcode\n sele += '/' + ap.modelIndex\n return sele\n}\n\nfunction getProblemCount (clashDict: { [k: string]: { [k: string]: string } }, g: Element, ga: NamedNodeMap) {\n let geoProblemCount = 0\n\n const clashes = g.getElementsByTagName('clash')\n for (let j = 0, jl = clashes.length; j < jl; ++j) {\n if (clashDict[ getNamedItem(clashes[ j ].attributes, 'cid') ]) {\n geoProblemCount += 1\n break\n }\n }\n\n const angleOutliers = g.getElementsByTagName('angle-outlier')\n if (angleOutliers.length > 0) {\n geoProblemCount += 1\n }\n\n const bondOutliers = g.getElementsByTagName('bond-outlier')\n if (bondOutliers.length > 0) {\n geoProblemCount += 1\n }\n\n const planeOutliers = g.getElementsByTagName('plane-outlier')\n if (planeOutliers.length > 0) {\n geoProblemCount += 1\n }\n\n if (hasAttrValue(ga.getNamedItem('rota'), 'OUTLIER')) {\n geoProblemCount += 1\n }\n\n if (hasAttrValue(ga.getNamedItem('rama'), 'OUTLIER')) {\n geoProblemCount += 1\n }\n\n if (hasAttrValue(ga.getNamedItem('RNApucker'), 'outlier')) {\n geoProblemCount += 1\n }\n\n return geoProblemCount\n}\n\nclass Validation {\n rsrzDict: { [k: string]: number } = {}\n rsccDict: { [k: string]: number } = {}\n /**\n * Random Coil Index (RCI) - evaluates the proximity of residue structural\n * and dynamic properties to the properties of flexible random coil regions\n * from NMR chemical shifts.\n *\n * Mark V. Berjanskii and David S. Wishart (2005)\n * A Simple Method To Predict Protein Flexibility Using Secondary Chemical Shifts\n * J. Am. Chem. Soc., 2005, 127 (43), pp 14970–14971\n * http://pubs.acs.org/doi/abs/10.1021/ja054842f\n *\n * Mark V. Berjanskii and David S. Wishart (2008)\n * Application of the random coil index to studying protein flexibility.\n * J Biomol NMR. 2008 Jan;40(1):31-48. Epub 2007 Nov 6.\n * http://www.springerlink.com/content/2966482w10306126/\n */\n rciDict: { [k: string]: number } = {}\n clashDict: { [k: string]: { [k: string]: string } } = {}\n clashArray: { [k: string]: string }[] = []\n geoDict: { [k: string]: number } = {}\n geoAtomDict: { [k: string]: { [k: string]: number } } = {}\n atomDict: { [k: string]: boolean|number } = {}\n clashSele = 'NONE'\n\n constructor (readonly name: string, readonly path: string) {}\n\n get type () { return 'validation' }\n\n fromXml (xml: XMLDocument) {\n if (Debug) Log.time('Validation.fromXml')\n\n const rsrzDict = this.rsrzDict\n const rsccDict = this.rsccDict\n const rciDict = this.rciDict\n const clashDict = this.clashDict\n const clashArray = this.clashArray\n const geoDict = this.geoDict\n const geoAtomDict = this.geoAtomDict\n const atomDict = this.atomDict\n\n const entries = xml.getElementsByTagName('Entry')\n if (entries.length === 1) {\n const chemicalShiftLists = entries[0].getElementsByTagName('chemical_shift_list')\n if (chemicalShiftLists.length === 1) {\n const randomCoilIndices = chemicalShiftLists[0].getElementsByTagName('random_coil_index')\n for (let j = 0, jl = randomCoilIndices.length; j < jl; ++j) {\n const rcia = randomCoilIndices[ j ].attributes\n const sele = getResSele(rcia)\n rciDict[ sele ] = parseFloat(getNamedItem(rcia, 'value'))\n }\n }\n }\n\n const groups = xml.getElementsByTagName('ModelledSubgroup')\n\n const _clashDict: { [k: string]: { [k: string]: string } } = {}\n const clashList: string[] = []\n\n if (Debug) Log.time('Validation.fromXml#clashDict')\n\n for (let i = 0, il = groups.length; i < il; ++i) {\n const g = groups[ i ]\n const ga = g.attributes\n\n const sele = getSele(ga)\n if (ga.getNamedItem('rsrz') !== null) {\n rsrzDict[ sele ] = parseFloat(getNamedItem(ga, 'rsrz'))\n }\n if (ga.getNamedItem('rscc') !== null) {\n rsccDict[ sele ] = parseFloat(getNamedItem(ga, 'rscc'))\n }\n const seleAttr = xml.createAttribute('sele')\n seleAttr.value = sele\n ga.setNamedItem(seleAttr)\n\n const clashes = g.getElementsByTagName('clash')\n\n for (let j = 0, jl = clashes.length; j < jl; ++j) {\n const ca = clashes[ j ].attributes\n const atom = getNamedItem(ca, 'atom')\n\n if (guessElement(atom) !== 'H') {\n const cid = getNamedItem(ca, 'cid')\n const atomSele = getSele(ga, atom, true)\n atomDict[ atomSele ] = true\n\n if (_clashDict[ cid ] === undefined) {\n _clashDict[ cid ] = {\n sele1: atomSele,\n res1: sele\n }\n } else {\n const c = _clashDict[ cid ]\n if (c.res1 !== sele) {\n c.sele2 = atomSele\n c.res2 = sele\n clashList.push(c.res1, sele)\n clashDict[ cid ] = c\n clashArray.push(c)\n }\n }\n }\n }\n }\n\n if (Debug) Log.timeEnd('Validation.fromXml#clashDict')\n\n for (let i = 0, il = groups.length; i < il; ++i) {\n const g = groups[ i ]\n const ga = g.attributes\n\n const sele = getNamedItem(ga, 'sele')\n const isPolymer = getNamedItem(ga, 'seq') !== '.'\n\n if (isPolymer) {\n const geoProblemCount = getProblemCount(clashDict, g, ga)\n if (geoProblemCount > 0) {\n geoDict[ sele ] = geoProblemCount\n }\n } else {\n const clashes = g.getElementsByTagName('clash')\n const mogBondOutliers = g.getElementsByTagName('mog-bond-outlier')\n const mogAngleOutliers = g.getElementsByTagName('mog-angle-outlier')\n\n if (mogBondOutliers.length > 0 || mogAngleOutliers.length > 0 || clashes.length > 0) {\n const atomDict = {}\n geoAtomDict[ sele ] = atomDict\n\n for (let j = 0, jl = clashes.length; j < jl; ++j) {\n const ca = clashes[ j ].attributes\n if (clashDict[ getNamedItem(ca, 'cid') ]) {\n setBitDict(atomDict, getNamedItem(ca, 'atom'), 1)\n }\n }\n\n for (let j = 0, jl = mogBondOutliers.length; j < jl; ++j) {\n const mbo = mogBondOutliers[ j ].attributes\n getNamedItem(mbo, 'atoms').split(',').forEach(function (atomname) {\n setBitDict(atomDict, atomname, 2)\n })\n }\n\n for (let j = 0, jl = mogAngleOutliers.length; j < jl; ++j) {\n const mao = mogAngleOutliers[ j ].attributes\n getNamedItem(mao, 'atoms').split(',').forEach(function (atomname) {\n setBitDict(atomDict, atomname, 4)\n })\n }\n }\n }\n }\n\n this.clashSele = clashList.length ? clashList.join(' OR ') : 'NONE'\n\n if (Debug) Log.timeEnd('Validation.fromXml')\n }\n\n getClashData (params: { color: number|string|Color, structure: Structure }) {\n if (Debug) Log.time('Validation.getClashData')\n\n const p = params || {}\n\n const s = p.structure\n const atomSet = s.atomSet! // TODO\n const c = new Color(defaults(p.color, '#f0027f'))\n\n const ap1 = s.getAtomProxy()\n const ap2 = s.getAtomProxy()\n const vDir = new Vector3()\n const vPos1 = new Vector3()\n const vPos2 = new Vector3()\n\n const clashArray = this.clashArray\n const n = clashArray.length\n\n const position1 = new Float32Array(n * 3)\n const position2 = new Float32Array(n * 3)\n const color = uniformArray3(n, c.r, c.g, c.b) as Float32Array\n const radius = new Float32Array(n)\n const picking = new Float32Array(n)\n\n if (Debug) Log.time('Validation.getClashData#atomDict')\n\n const atomDict = this.atomDict\n\n s.eachAtom(function (ap) {\n const sele = getAtomSele(ap)\n if (atomDict[ sele ] === true) {\n atomDict[ sele ] = ap.index\n }\n })\n\n if (Debug) Log.timeEnd('Validation.getClashData#atomDict')\n\n let i = 0\n\n clashArray.forEach(function (c, idx) {\n ap1.index = atomDict[ c.sele1 ] as number // TODO\n ap2.index = atomDict[ c.sele2 ] as number // TODO\n\n if (ap1.index === undefined || ap2.index === undefined ||\n !atomSet.isSet(ap1.index, ap2.index)) return\n\n vDir.subVectors(ap2 as any, ap1 as any).setLength(ap1.vdw) // TODO\n vPos1.copy(ap1 as any).add(vDir) // TODO\n\n vDir.subVectors(ap1 as any, ap2 as any).setLength(ap2.vdw) // TODO\n vPos2.copy(ap2 as any).add(vDir) // TODO\n\n const dHalf = ap1.distanceTo(ap2) / 2\n const r1 = Math.sqrt(ap1.vdw * ap1.vdw - dHalf * dHalf)\n const r2 = Math.sqrt(ap2.vdw * ap2.vdw - dHalf * dHalf)\n\n vPos1.toArray(position1 as any, i * 3) // TODO\n vPos2.toArray(position2 as any, i * 3)\n radius[ i ] = (r1 + r2) / 2\n picking[ i ] = idx\n\n ++i\n })\n\n if (Debug) Log.timeEnd('Validation.getClashData')\n\n return {\n position1: position1.subarray(0, i * 3),\n position2: position2.subarray(0, i * 3),\n color: color.subarray(0, i * 3),\n color2: color.subarray(0, i * 3),\n radius: radius.subarray(0, i),\n picking: new ClashPicker(picking.subarray(0, i), this, s)\n }\n }\n}\n\nexport default Validation\n","\n// https://github.com/nodeca/pako\n// MIT License, Copyright (c) 2014 by Vitaly Puzrin\n\n\n// 'use strict';\n\n\n// var TYPED_OK = (typeof Uint8Array !== 'undefined') &&\n// (typeof Uint16Array !== 'undefined') &&\n// (typeof Int32Array !== 'undefined');\n\n\nfunction assign(obj /*from1, from2, from3, ...*/) {\n var sources = Array.prototype.slice.call(arguments, 1);\n while (sources.length) {\n var source = sources.shift();\n if (!source) { continue; }\n\n if (typeof source !== 'object') {\n throw new TypeError(source + 'must be non-object');\n }\n\n for (var p in source) {\n if (source.hasOwnProperty(p)) {\n obj[p] = source[p];\n }\n }\n }\n\n return obj;\n}\n\n\n// reduce buffer size, avoiding mem copy\nfunction shrinkBuf(buf, size) {\n if (buf.length === size) { return buf; }\n if (buf.subarray) { return buf.subarray(0, size); }\n buf.length = size;\n return buf;\n}\n\n\nfunction arraySet(dest, src, src_offs, len, dest_offs) {\n if (src.subarray && dest.subarray) {\n dest.set(src.subarray(src_offs, src_offs + len), dest_offs);\n return;\n }\n // Fallback to ordinary array\n for (var i = 0; i < len; i++) {\n dest[dest_offs + i] = src[src_offs + i];\n }\n}\n\n// Join array of chunks to single array.\nfunction flattenChunks(chunks) {\n var i, l, len, pos, chunk, result;\n\n // calculate data length\n len = 0;\n for (i = 0, l = chunks.length; i < l; i++) {\n len += chunks[i].length;\n }\n\n // join chunks\n result = new Uint8Array(len);\n pos = 0;\n for (i = 0, l = chunks.length; i < l; i++) {\n chunk = chunks[i];\n result.set(chunk, pos);\n pos += chunk.length;\n }\n\n return result;\n}\n\n// 'use strict';\n\n// Note: adler32 takes 12% for level 0 and 2% for level 6.\n// It doesn't worth to make additional optimizationa as in original.\n// Small size is preferable.\n\nfunction adler32(adler, buf, len, pos) {\n var s1 = (adler & 0xffff) |0,\n s2 = ((adler >>> 16) & 0xffff) |0,\n n = 0;\n\n while (len !== 0) {\n // Set limit ~ twice less than 5552, to keep\n // s2 in 31-bits, because we force signed ints.\n // in other case %= will fail.\n n = len > 2000 ? 2000 : len;\n len -= n;\n\n do {\n s1 = (s1 + buf[pos++]) |0;\n s2 = (s2 + s1) |0;\n } while (--n);\n\n s1 %= 65521;\n s2 %= 65521;\n }\n\n return (s1 | (s2 << 16)) |0;\n}\n\n// 'use strict';\n\n// Note: we can't get significant speed boost here.\n// So write code to minimize size - no pregenerated tables\n// and array tools dependencies.\n\n\n// Use ordinary array, since untyped makes no boost here\nfunction makeTable() {\n var c, table = [];\n\n for (var n = 0; n < 256; n++) {\n c = n;\n for (var k = 0; k < 8; k++) {\n c = ((c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));\n }\n table[n] = c;\n }\n\n return table;\n}\n\n// Create table on load. Just 255 signed longs. Not a problem.\nvar crcTable = makeTable();\n\n\nfunction crc32(crc, buf, len, pos) {\n var t = crcTable,\n end = pos + len;\n\n crc ^= -1;\n\n for (var i = pos; i < end; i++) {\n crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF];\n }\n\n return (crc ^ (-1)); // >>> 0;\n}\n\n// 'use strict';\n\n// See state defs from inflate.js\nvar BAD$1 = 30; /* got a data error -- remain here until reset */\nvar TYPE$1 = 12; /* i: waiting for type bits, including last-flag bit */\n\n/*\n Decode literal, length, and distance codes and write out the resulting\n literal and match bytes until either not enough input or output is\n available, an end-of-block is encountered, or a data error is encountered.\n When large enough input and output buffers are supplied to inflate(), for\n example, a 16K input buffer and a 64K output buffer, more than 95% of the\n inflate execution time is spent in this routine.\n\n Entry assumptions:\n\n state.mode === LEN\n strm.avail_in >= 6\n strm.avail_out >= 258\n start >= strm.avail_out\n state.bits < 8\n\n On return, state.mode is one of:\n\n LEN -- ran out of enough output space or enough available input\n TYPE -- reached end of block code, inflate() to interpret next block\n BAD -- error in block data\n\n Notes:\n\n - The maximum input bits used by a length/distance pair is 15 bits for the\n length code, 5 bits for the length extra, 15 bits for the distance code,\n and 13 bits for the distance extra. This totals 48 bits, or six bytes.\n Therefore if strm.avail_in >= 6, then there is enough input to avoid\n checking for available input while decoding.\n\n - The maximum bytes that a single length/distance pair can output is 258\n bytes, which is the maximum length that can be coded. inflate_fast()\n requires strm.avail_out >= 258 for each loop to avoid checking for\n output space.\n */\n// module.exports =\nfunction inflate_fast(strm, start) {\n var state;\n var _in; /* local strm.input */\n var last; /* have enough input while in < last */\n var _out; /* local strm.output */\n var beg; /* inflate()'s initial strm.output */\n var end; /* while out < end, enough space available */\n//#ifdef INFLATE_STRICT\n var dmax; /* maximum distance from zlib header */\n//#endif\n var wsize; /* window size or zero if not using window */\n var whave; /* valid bytes in the window */\n var wnext; /* window write index */\n // Use `s_window` instead `window`, avoid conflict with instrumentation tools\n var s_window; /* allocated sliding window, if wsize != 0 */\n var hold; /* local strm.hold */\n var bits; /* local strm.bits */\n var lcode; /* local strm.lencode */\n var dcode; /* local strm.distcode */\n var lmask; /* mask for first level of length codes */\n var dmask; /* mask for first level of distance codes */\n var here; /* retrieved table entry */\n var op; /* code bits, operation, extra bits, or */\n /* window position, window bytes to copy */\n var len; /* match length, unused bytes */\n var dist; /* match distance */\n var from; /* where to copy match from */\n var from_source;\n\n\n var input, output; // JS specific, because we have no pointers\n\n /* copy state to local variables */\n state = strm.state;\n //here = state.here;\n _in = strm.next_in;\n input = strm.input;\n last = _in + (strm.avail_in - 5);\n _out = strm.next_out;\n output = strm.output;\n beg = _out - (start - strm.avail_out);\n end = _out + (strm.avail_out - 257);\n//#ifdef INFLATE_STRICT\n dmax = state.dmax;\n//#endif\n wsize = state.wsize;\n whave = state.whave;\n wnext = state.wnext;\n s_window = state.window;\n hold = state.hold;\n bits = state.bits;\n lcode = state.lencode;\n dcode = state.distcode;\n lmask = (1 << state.lenbits) - 1;\n dmask = (1 << state.distbits) - 1;\n\n\n /* decode literals and length/distances until end-of-block or not enough\n input data or output space */\n\n top:\n do {\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n\n here = lcode[hold & lmask];\n\n dolen:\n for (;;) { // Goto emulation\n op = here >>> 24/*here.bits*/;\n hold >>>= op;\n bits -= op;\n op = (here >>> 16) & 0xff/*here.op*/;\n if (op === 0) { /* literal */\n //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n // \"inflate: literal '%c'\\n\" :\n // \"inflate: literal 0x%02x\\n\", here.val));\n output[_out++] = here & 0xffff/*here.val*/;\n }\n else if (op & 16) { /* length base */\n len = here & 0xffff/*here.val*/;\n op &= 15; /* number of extra bits */\n if (op) {\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n len += hold & ((1 << op) - 1);\n hold >>>= op;\n bits -= op;\n }\n //Tracevv((stderr, \"inflate: length %u\\n\", len));\n if (bits < 15) {\n hold += input[_in++] << bits;\n bits += 8;\n hold += input[_in++] << bits;\n bits += 8;\n }\n here = dcode[hold & dmask];\n\n dodist:\n for (;;) { // goto emulation\n op = here >>> 24/*here.bits*/;\n hold >>>= op;\n bits -= op;\n op = (here >>> 16) & 0xff/*here.op*/;\n\n if (op & 16) { /* distance base */\n dist = here & 0xffff/*here.val*/;\n op &= 15; /* number of extra bits */\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n if (bits < op) {\n hold += input[_in++] << bits;\n bits += 8;\n }\n }\n dist += hold & ((1 << op) - 1);\n//#ifdef INFLATE_STRICT\n if (dist > dmax) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD$1;\n break top;\n }\n//#endif\n hold >>>= op;\n bits -= op;\n //Tracevv((stderr, \"inflate: distance %u\\n\", dist));\n op = _out - beg; /* max distance in output */\n if (dist > op) { /* see if copy from window */\n op = dist - op; /* distance back in window */\n if (op > whave) {\n if (state.sane) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD$1;\n break top;\n }\n\n// (!) This block is disabled in zlib defailts,\n// don't enable it for binary compatibility\n//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n// if (len <= op - whave) {\n// do {\n// output[_out++] = 0;\n// } while (--len);\n// continue top;\n// }\n// len -= op - whave;\n// do {\n// output[_out++] = 0;\n// } while (--op > whave);\n// if (op === 0) {\n// from = _out - dist;\n// do {\n// output[_out++] = output[from++];\n// } while (--len);\n// continue top;\n// }\n//#endif\n }\n from = 0; // window index\n from_source = s_window;\n if (wnext === 0) { /* very common case */\n from += wsize - op;\n if (op < len) { /* some from window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n else if (wnext < op) { /* wrap around window */\n from += wsize + wnext - op;\n op -= wnext;\n if (op < len) { /* some from end of window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = 0;\n if (wnext < len) { /* some from start of window */\n op = wnext;\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n }\n else { /* contiguous in window */\n from += wnext - op;\n if (op < len) { /* some from window */\n len -= op;\n do {\n output[_out++] = s_window[from++];\n } while (--op);\n from = _out - dist; /* rest from output */\n from_source = output;\n }\n }\n while (len > 2) {\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n output[_out++] = from_source[from++];\n len -= 3;\n }\n if (len) {\n output[_out++] = from_source[from++];\n if (len > 1) {\n output[_out++] = from_source[from++];\n }\n }\n }\n else {\n from = _out - dist; /* copy direct from output */\n do { /* minimum length is three */\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n output[_out++] = output[from++];\n len -= 3;\n } while (len > 2);\n if (len) {\n output[_out++] = output[from++];\n if (len > 1) {\n output[_out++] = output[from++];\n }\n }\n }\n }\n else if ((op & 64) === 0) { /* 2nd level distance code */\n here = dcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n continue dodist;\n }\n else {\n strm.msg = 'invalid distance code';\n state.mode = BAD$1;\n break top;\n }\n\n break; // need to emulate goto via \"continue\"\n }\n }\n else if ((op & 64) === 0) { /* 2nd level length code */\n here = lcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];\n continue dolen;\n }\n else if (op & 32) { /* end-of-block */\n //Tracevv((stderr, \"inflate: end of block\\n\"));\n state.mode = TYPE$1;\n break top;\n }\n else {\n strm.msg = 'invalid literal/length code';\n state.mode = BAD$1;\n break top;\n }\n\n break; // need to emulate goto via \"continue\"\n }\n } while (_in < last && _out < end);\n\n /* return unused bytes (on entry, bits < 8, so in won't go too far back) */\n len = bits >> 3;\n _in -= len;\n bits -= len << 3;\n hold &= (1 << bits) - 1;\n\n /* update state and return */\n strm.next_in = _in;\n strm.next_out = _out;\n strm.avail_in = (_in < last ? 5 + (last - _in) : 5 - (_in - last));\n strm.avail_out = (_out < end ? 257 + (end - _out) : 257 - (_out - end));\n state.hold = hold;\n state.bits = bits;\n return;\n};\n\n// 'use strict';\n\n\n// var utils = require('../utils/common');\n\nvar MAXBITS = 15;\nvar ENOUGH_LENS$1 = 852;\nvar ENOUGH_DISTS$1 = 592;\n//var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);\n\nvar CODES$1 = 0;\nvar LENS$1 = 1;\nvar DISTS$1 = 2;\n\nvar lbase = [ /* Length codes 257..285 base */\n 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,\n 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0\n];\n\nvar lext = [ /* Length codes 257..285 extra */\n 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,\n 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78\n];\n\nvar dbase = [ /* Distance codes 0..29 base */\n 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,\n 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,\n 8193, 12289, 16385, 24577, 0, 0\n];\n\nvar dext = [ /* Distance codes 0..29 extra */\n 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,\n 23, 23, 24, 24, 25, 25, 26, 26, 27, 27,\n 28, 28, 29, 29, 64, 64\n];\n\n// module.exports =\nfunction inflate_table(type, lens, lens_index, codes, table, table_index, work, opts)\n{\n var bits = opts.bits;\n //here = opts.here; /* table entry for duplication */\n\n var len = 0; /* a code's length in bits */\n var sym = 0; /* index of code symbols */\n var min = 0, max = 0; /* minimum and maximum code lengths */\n var root = 0; /* number of index bits for root table */\n var curr = 0; /* number of index bits for current table */\n var drop = 0; /* code bits to drop for sub-table */\n var left = 0; /* number of prefix codes available */\n var used = 0; /* code entries in table used */\n var huff = 0; /* Huffman code */\n var incr; /* for incrementing code, index */\n var fill; /* index for replicating entries */\n var low; /* low bits for current root entry */\n var mask; /* mask for low root bits */\n var next; /* next available space in table */\n var base = null; /* base value table to use */\n var base_index = 0;\n// var shoextra; /* extra bits table to use */\n var end; /* use base and extra for symbol > end */\n var count = new Uint16Array(MAXBITS + 1); //[MAXBITS+1]; /* number of codes of each length */\n var offs = new Uint16Array(MAXBITS + 1); //[MAXBITS+1]; /* offsets in table for each length */\n var extra = null;\n var extra_index = 0;\n\n var here_bits, here_op, here_val;\n\n /*\n Process a set of code lengths to create a canonical Huffman code. The\n code lengths are lens[0..codes-1]. Each length corresponds to the\n symbols 0..codes-1. The Huffman code is generated by first sorting the\n symbols by length from short to long, and retaining the symbol order\n for codes with equal lengths. Then the code starts with all zero bits\n for the first code of the shortest length, and the codes are integer\n increments for the same length, and zeros are appended as the length\n increases. For the deflate format, these bits are stored backwards\n from their more natural integer increment ordering, and so when the\n decoding tables are built in the large loop below, the integer codes\n are incremented backwards.\n\n This routine assumes, but does not check, that all of the entries in\n lens[] are in the range 0..MAXBITS. The caller must assure this.\n 1..MAXBITS is interpreted as that code length. zero means that that\n symbol does not occur in this code.\n\n The codes are sorted by computing a count of codes for each length,\n creating from that a table of starting indices for each length in the\n sorted table, and then entering the symbols in order in the sorted\n table. The sorted table is work[], with that space being provided by\n the caller.\n\n The length counts are used for other purposes as well, i.e. finding\n the minimum and maximum length codes, determining if there are any\n codes at all, checking for a valid set of lengths, and looking ahead\n at length counts to determine sub-table sizes when building the\n decoding tables.\n */\n\n /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */\n for (len = 0; len <= MAXBITS; len++) {\n count[len] = 0;\n }\n for (sym = 0; sym < codes; sym++) {\n count[lens[lens_index + sym]]++;\n }\n\n /* bound code lengths, force root to be within code lengths */\n root = bits;\n for (max = MAXBITS; max >= 1; max--) {\n if (count[max] !== 0) { break; }\n }\n if (root > max) {\n root = max;\n }\n if (max === 0) { /* no symbols to code at all */\n //table.op[opts.table_index] = 64; //here.op = (var char)64; /* invalid code marker */\n //table.bits[opts.table_index] = 1; //here.bits = (var char)1;\n //table.val[opts.table_index++] = 0; //here.val = (var short)0;\n table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n\n //table.op[opts.table_index] = 64;\n //table.bits[opts.table_index] = 1;\n //table.val[opts.table_index++] = 0;\n table[table_index++] = (1 << 24) | (64 << 16) | 0;\n\n opts.bits = 1;\n return 0; /* no symbols, but wait for decoding to report error */\n }\n for (min = 1; min < max; min++) {\n if (count[min] !== 0) { break; }\n }\n if (root < min) {\n root = min;\n }\n\n /* check for an over-subscribed or incomplete set of lengths */\n left = 1;\n for (len = 1; len <= MAXBITS; len++) {\n left <<= 1;\n left -= count[len];\n if (left < 0) {\n return -1;\n } /* over-subscribed */\n }\n if (left > 0 && (type === CODES$1 || max !== 1)) {\n return -1; /* incomplete set */\n }\n\n /* generate offsets into symbol table for each length for sorting */\n offs[1] = 0;\n for (len = 1; len < MAXBITS; len++) {\n offs[len + 1] = offs[len] + count[len];\n }\n\n /* sort symbols by length, by symbol order within each length */\n for (sym = 0; sym < codes; sym++) {\n if (lens[lens_index + sym] !== 0) {\n work[offs[lens[lens_index + sym]]++] = sym;\n }\n }\n\n /*\n Create and fill in decoding tables. In this loop, the table being\n filled is at next and has curr index bits. The code being used is huff\n with length len. That code is converted to an index by dropping drop\n bits off of the bottom. For codes where len is less than drop + curr,\n those top drop + curr - len bits are incremented through all values to\n fill the table with replicated entries.\n\n root is the number of index bits for the root table. When len exceeds\n root, sub-tables are created pointed to by the root entry with an index\n of the low root bits of huff. This is saved in low to check for when a\n new sub-table should be started. drop is zero when the root table is\n being filled, and drop is root when sub-tables are being filled.\n\n When a new sub-table is needed, it is necessary to look ahead in the\n code lengths to determine what size sub-table is needed. The length\n counts are used for this, and so count[] is decremented as codes are\n entered in the tables.\n\n used keeps track of how many table entries have been allocated from the\n provided *table space. It is checked for LENS and DIST tables against\n the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in\n the initial root table size constants. See the comments in inftrees.h\n for more information.\n\n sym increments through all symbols, and the loop terminates when\n all codes of length max, i.e. all codes, have been processed. This\n routine permits incomplete codes, so another loop after this one fills\n in the rest of the decoding tables with invalid code markers.\n */\n\n /* set up for code type */\n // poor man optimization - use if-else instead of switch,\n // to avoid deopts in old v8\n if (type === CODES$1) {\n base = extra = work; /* dummy value--not used */\n end = 19;\n\n } else if (type === LENS$1) {\n base = lbase;\n base_index -= 257;\n extra = lext;\n extra_index -= 257;\n end = 256;\n\n } else { /* DISTS */\n base = dbase;\n extra = dext;\n end = -1;\n }\n\n /* initialize opts for loop */\n huff = 0; /* starting code */\n sym = 0; /* starting code symbol */\n len = min; /* starting code length */\n next = table_index; /* current table to fill in */\n curr = root; /* current table index bits */\n drop = 0; /* current bits to drop from code for index */\n low = -1; /* trigger new sub-table when len > root */\n used = 1 << root; /* use root table entries */\n mask = used - 1; /* mask for comparing low */\n\n /* check available table space */\n if ((type === LENS$1 && used > ENOUGH_LENS$1) ||\n (type === DISTS$1 && used > ENOUGH_DISTS$1)) {\n return 1;\n }\n\n var i = 0;\n /* process all codes and make table entries */\n for (;;) {\n i++;\n /* create table entry */\n here_bits = len - drop;\n if (work[sym] < end) {\n here_op = 0;\n here_val = work[sym];\n }\n else if (work[sym] > end) {\n here_op = extra[extra_index + work[sym]];\n here_val = base[base_index + work[sym]];\n }\n else {\n here_op = 32 + 64; /* end of block */\n here_val = 0;\n }\n\n /* replicate for those indices with low len bits equal to huff */\n incr = 1 << (len - drop);\n fill = 1 << curr;\n min = fill; /* save offset to next table */\n do {\n fill -= incr;\n table[next + (huff >> drop) + fill] = (here_bits << 24) | (here_op << 16) | here_val |0;\n } while (fill !== 0);\n\n /* backwards increment the len-bit code huff */\n incr = 1 << (len - 1);\n while (huff & incr) {\n incr >>= 1;\n }\n if (incr !== 0) {\n huff &= incr - 1;\n huff += incr;\n } else {\n huff = 0;\n }\n\n /* go to next symbol, update count, len */\n sym++;\n if (--count[len] === 0) {\n if (len === max) { break; }\n len = lens[lens_index + work[sym]];\n }\n\n /* create new sub-table if needed */\n if (len > root && (huff & mask) !== low) {\n /* if first time, transition to sub-tables */\n if (drop === 0) {\n drop = root;\n }\n\n /* increment past last table */\n next += min; /* here min is 1 << curr */\n\n /* determine length of next table */\n curr = len - drop;\n left = 1 << curr;\n while (curr + drop < max) {\n left -= count[curr + drop];\n if (left <= 0) { break; }\n curr++;\n left <<= 1;\n }\n\n /* check for enough space */\n used += 1 << curr;\n if ((type === LENS$1 && used > ENOUGH_LENS$1) ||\n (type === DISTS$1 && used > ENOUGH_DISTS$1)) {\n return 1;\n }\n\n /* point entry in root table to sub-table */\n low = huff & mask;\n /*table.op[low] = curr;\n table.bits[low] = root;\n table.val[low] = next - opts.table_index;*/\n table[low] = (root << 24) | (curr << 16) | (next - table_index) |0;\n }\n }\n\n /* fill in remaining table entry if code is incomplete (guaranteed to have\n at most one remaining entry, since if the code is incomplete, the\n maximum code length that was allowed to get this far is one bit) */\n if (huff !== 0) {\n //table.op[next + huff] = 64; /* invalid code marker */\n //table.bits[next + huff] = len - drop;\n //table.val[next + huff] = 0;\n table[next + huff] = ((len - drop) << 24) | (64 << 16) |0;\n }\n\n /* set return parameters */\n //opts.table_index += used;\n opts.bits = root;\n return 0;\n};\n\n// 'use strict';\n\n\n// var utils = require('../utils/common');\n// var adler32 = require('./adler32');\n// var crc32 = require('./crc32');\n// var inflate_fast = require('./inffast');\n// var inflate_table = require('./inftrees');\n\nvar CODES = 0;\nvar LENS = 1;\nvar DISTS = 2;\n\n/* Public constants ==========================================================*/\n/* ===========================================================================*/\n\n\n/* Allowed flush values; see deflate() and inflate() below for details */\n//var Z_NO_FLUSH = 0;\n//var Z_PARTIAL_FLUSH = 1;\n//var Z_SYNC_FLUSH = 2;\n//var Z_FULL_FLUSH = 3;\nvar Z_FINISH = 4;\nvar Z_BLOCK = 5;\nvar Z_TREES = 6;\n\n\n/* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\nvar Z_OK = 0;\nvar Z_STREAM_END = 1;\nvar Z_NEED_DICT = 2;\n//var Z_ERRNO = -1;\nvar Z_STREAM_ERROR = -2;\nvar Z_DATA_ERROR = -3;\nvar Z_MEM_ERROR = -4;\nvar Z_BUF_ERROR = -5;\n//var Z_VERSION_ERROR = -6;\n\n/* The deflate compression method */\nvar Z_DEFLATED = 8;\n\n\n/* STATES ====================================================================*/\n/* ===========================================================================*/\n\n\nvar HEAD = 1; /* i: waiting for magic header */\nvar FLAGS = 2; /* i: waiting for method and flags (gzip) */\nvar TIME = 3; /* i: waiting for modification time (gzip) */\nvar OS = 4; /* i: waiting for extra flags and operating system (gzip) */\nvar EXLEN = 5; /* i: waiting for extra length (gzip) */\nvar EXTRA = 6; /* i: waiting for extra bytes (gzip) */\nvar NAME = 7; /* i: waiting for end of file name (gzip) */\nvar COMMENT = 8; /* i: waiting for end of comment (gzip) */\nvar HCRC = 9; /* i: waiting for header crc (gzip) */\nvar DICTID = 10; /* i: waiting for dictionary check value */\nvar DICT = 11; /* waiting for inflateSetDictionary() call */\nvar TYPE = 12; /* i: waiting for type bits, including last-flag bit */\nvar TYPEDO = 13; /* i: same, but skip check to exit inflate on new block */\nvar STORED = 14; /* i: waiting for stored size (length and complement) */\nvar COPY_ = 15; /* i/o: same as COPY below, but only first time in */\nvar COPY = 16; /* i/o: waiting for input or output to copy stored block */\nvar TABLE = 17; /* i: waiting for dynamic block table lengths */\nvar LENLENS = 18; /* i: waiting for code length code lengths */\nvar CODELENS = 19; /* i: waiting for length/lit and distance code lengths */\nvar LEN_ = 20; /* i: same as LEN below, but only first time in */\nvar LEN = 21; /* i: waiting for length/lit/eob code */\nvar LENEXT = 22; /* i: waiting for length extra bits */\nvar DIST = 23; /* i: waiting for distance code */\nvar DISTEXT = 24; /* i: waiting for distance extra bits */\nvar MATCH = 25; /* o: waiting for output space to copy string */\nvar LIT = 26; /* o: waiting for output space to write literal */\nvar CHECK = 27; /* i: waiting for 32-bit check value */\nvar LENGTH = 28; /* i: waiting for 32-bit length (gzip) */\nvar DONE = 29; /* finished check, done -- remain here until reset */\nvar BAD = 30; /* got a data error -- remain here until reset */\nvar MEM = 31; /* got an inflate() memory error -- remain here until reset */\nvar SYNC = 32; /* looking for synchronization bytes to restart inflate() */\n\n/* ===========================================================================*/\n\n\n\nvar ENOUGH_LENS = 852;\nvar ENOUGH_DISTS = 592;\nfunction zswap32(q) {\n return (((q >>> 24) & 0xff) +\n ((q >>> 8) & 0xff00) +\n ((q & 0xff00) << 8) +\n ((q & 0xff) << 24));\n}\n\n\nfunction InflateState() {\n this.mode = 0; /* current inflate mode */\n this.last = false; /* true if processing last block */\n this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip */\n this.havedict = false; /* true if dictionary provided */\n this.flags = 0; /* gzip header method and flags (0 if zlib) */\n this.dmax = 0; /* zlib header max distance (INFLATE_STRICT) */\n this.check = 0; /* protected copy of check value */\n this.total = 0; /* protected copy of output count */\n // TODO: may be {}\n this.head = null; /* where to save gzip header information */\n\n /* sliding window */\n this.wbits = 0; /* log base 2 of requested window size */\n this.wsize = 0; /* window size or zero if not using window */\n this.whave = 0; /* valid bytes in the window */\n this.wnext = 0; /* window write index */\n this.window = null; /* allocated sliding window, if needed */\n\n /* bit accumulator */\n this.hold = 0; /* input bit accumulator */\n this.bits = 0; /* number of bits in \"in\" */\n\n /* for string and stored block copying */\n this.length = 0; /* literal or length of data to copy */\n this.offset = 0; /* distance back to copy string from */\n\n /* for table and code decoding */\n this.extra = 0; /* extra bits needed */\n\n /* fixed and dynamic code tables */\n this.lencode = null; /* starting table for length/literal codes */\n this.distcode = null; /* starting table for distance codes */\n this.lenbits = 0; /* index bits for lencode */\n this.distbits = 0; /* index bits for distcode */\n\n /* dynamic table building */\n this.ncode = 0; /* number of code length code lengths */\n this.nlen = 0; /* number of length code lengths */\n this.ndist = 0; /* number of distance code lengths */\n this.have = 0; /* number of code lengths in lens[] */\n this.next = null; /* next available space in codes[] */\n\n this.lens = new Uint16Array(320); /* temporary storage for code lengths */\n this.work = new Uint16Array(288); /* work area for code table building */\n\n /*\n because we don't have pointers in js, we use lencode and distcode directly\n as buffers so we don't need codes\n */\n //this.codes = new Buf32(ENOUGH); /* space for code tables */\n this.lendyn = null; /* dynamic table for length/literal codes (JS specific) */\n this.distdyn = null; /* dynamic table for distance codes (JS specific) */\n this.sane = 0; /* if false, allow invalid distance too far */\n this.back = 0; /* bits back of last unprocessed length/lit */\n this.was = 0; /* initial length of match */\n}\n\nfunction inflateResetKeep(strm) {\n var state;\n\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n strm.total_in = strm.total_out = state.total = 0;\n strm.msg = ''; /*Z_NULL*/\n if (state.wrap) { /* to support ill-conceived Java test suite */\n strm.adler = state.wrap & 1;\n }\n state.mode = HEAD;\n state.last = 0;\n state.havedict = 0;\n state.dmax = 32768;\n state.head = null/*Z_NULL*/;\n state.hold = 0;\n state.bits = 0;\n //state.lencode = state.distcode = state.next = state.codes;\n state.lencode = state.lendyn = new Int32Array(ENOUGH_LENS);\n state.distcode = state.distdyn = new Int32Array(ENOUGH_DISTS);\n\n state.sane = 1;\n state.back = -1;\n //Tracev((stderr, \"inflate: reset\\n\"));\n return Z_OK;\n}\n\nfunction inflateReset(strm) {\n var state;\n\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n state.wsize = 0;\n state.whave = 0;\n state.wnext = 0;\n return inflateResetKeep(strm);\n\n}\n\nfunction inflateReset2(strm, windowBits) {\n var wrap;\n var state;\n\n /* get the state */\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n\n /* extract wrap request from windowBits parameter */\n if (windowBits < 0) {\n wrap = 0;\n windowBits = -windowBits;\n }\n else {\n wrap = (windowBits >> 4) + 1;\n if (windowBits < 48) {\n windowBits &= 15;\n }\n }\n\n /* set number of window bits, free window if different */\n if (windowBits && (windowBits < 8 || windowBits > 15)) {\n return Z_STREAM_ERROR;\n }\n if (state.window !== null && state.wbits !== windowBits) {\n state.window = null;\n }\n\n /* update state and reset the rest of it */\n state.wrap = wrap;\n state.wbits = windowBits;\n return inflateReset(strm);\n}\n\nfunction inflateInit2(strm, windowBits) {\n var ret;\n var state;\n\n if (!strm) { return Z_STREAM_ERROR; }\n //strm.msg = Z_NULL; /* in case we return an error */\n\n state = new InflateState();\n\n //if (state === Z_NULL) return Z_MEM_ERROR;\n //Tracev((stderr, \"inflate: allocated\\n\"));\n strm.state = state;\n state.window = null/*Z_NULL*/;\n ret = inflateReset2(strm, windowBits);\n if (ret !== Z_OK) {\n strm.state = null/*Z_NULL*/;\n }\n return ret;\n}\n\n/*\n Return state with length and distance decoding tables and index sizes set to\n fixed code decoding. Normally this returns fixed tables from inffixed.h.\n If BUILDFIXED is defined, then instead this routine builds the tables the\n first time it's called, and returns those tables the first time and\n thereafter. This reduces the size of the code by about 2K bytes, in\n exchange for a little execution time. However, BUILDFIXED should not be\n used for threaded applications, since the rewriting of the tables and virgin\n may not be thread-safe.\n */\nvar virgin = true;\n\nvar lenfix;\nvar distfix;\n// We have no pointers in JS, so keep tables separate\n\nfunction fixedtables(state) {\n /* build fixed huffman tables if first call (may not be thread safe) */\n if (virgin) {\n var sym;\n\n lenfix = new Int32Array(512);\n distfix = new Int32Array(32);\n\n /* literal/length table */\n sym = 0;\n while (sym < 144) { state.lens[sym++] = 8; }\n while (sym < 256) { state.lens[sym++] = 9; }\n while (sym < 280) { state.lens[sym++] = 7; }\n while (sym < 288) { state.lens[sym++] = 8; }\n\n inflate_table(LENS, state.lens, 0, 288, lenfix, 0, state.work, { bits: 9 });\n\n /* distance table */\n sym = 0;\n while (sym < 32) { state.lens[sym++] = 5; }\n\n inflate_table(DISTS, state.lens, 0, 32, distfix, 0, state.work, { bits: 5 });\n\n /* do this just once */\n virgin = false;\n }\n\n state.lencode = lenfix;\n state.lenbits = 9;\n state.distcode = distfix;\n state.distbits = 5;\n}\n\n\n/*\n Update the window with the last wsize (normally 32K) bytes written before\n returning. If window does not exist yet, create it. This is only called\n when a window is already in use, or when output has been written during this\n inflate call, but the end of the deflate stream has not been reached yet.\n It is also called to create a window for dictionary data when a dictionary\n is loaded.\n\n Providing output buffers larger than 32K to inflate() should provide a speed\n advantage, since only the last 32K of output is copied to the sliding window\n upon return from inflate(), and since all distances after the first 32K of\n output will fall in the output data, making match copies simpler and faster.\n The advantage may be dependent on the size of the processor's data caches.\n */\nfunction updatewindow(strm, src, end, copy) {\n var dist;\n var state = strm.state;\n\n /* if it hasn't been done already, allocate space for the window */\n if (state.window === null) {\n state.wsize = 1 << state.wbits;\n state.wnext = 0;\n state.whave = 0;\n\n state.window = new Uint8Array(state.wsize);\n }\n\n /* copy state->wsize or less output bytes into the circular window */\n if (copy >= state.wsize) {\n arraySet(state.window, src, end - state.wsize, state.wsize, 0);\n state.wnext = 0;\n state.whave = state.wsize;\n }\n else {\n dist = state.wsize - state.wnext;\n if (dist > copy) {\n dist = copy;\n }\n //zmemcpy(state->window + state->wnext, end - copy, dist);\n arraySet(state.window, src, end - copy, dist, state.wnext);\n copy -= dist;\n if (copy) {\n //zmemcpy(state->window, end - copy, copy);\n arraySet(state.window, src, end - copy, copy, 0);\n state.wnext = copy;\n state.whave = state.wsize;\n }\n else {\n state.wnext += dist;\n if (state.wnext === state.wsize) { state.wnext = 0; }\n if (state.whave < state.wsize) { state.whave += dist; }\n }\n }\n return 0;\n}\n\nfunction inflate(strm, flush) {\n var state;\n var input, output; // input/output buffers\n var next; /* next input INDEX */\n var put; /* next output INDEX */\n var have, left; /* available input and output */\n var hold; /* bit buffer */\n var bits; /* bits in bit buffer */\n var _in, _out; /* save starting available input and output */\n var copy; /* number of stored or match bytes to copy */\n var from; /* where to copy match bytes from */\n var from_source;\n var here = 0; /* current decoding table entry */\n var here_bits, here_op, here_val; // paked \"here\" denormalized (JS specific)\n //var last; /* parent table entry */\n var last_bits, last_op, last_val; // paked \"last\" denormalized (JS specific)\n var len; /* length to copy for repeats, bits to drop */\n var ret; /* return code */\n var hbuf = new Uint8Array(4); /* buffer for gzip header crc calculation */\n var opts;\n\n var n; // temporary var for NEED_BITS\n\n var order = /* permutation of code lengths */\n [ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ];\n\n\n if (!strm || !strm.state || !strm.output ||\n (!strm.input && strm.avail_in !== 0)) {\n return Z_STREAM_ERROR;\n }\n\n state = strm.state;\n if (state.mode === TYPE) { state.mode = TYPEDO; } /* skip check */\n\n\n //--- LOAD() ---\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n //---\n\n _in = have;\n _out = left;\n ret = Z_OK;\n\n inf_leave: // goto emulation\n for (;;) {\n switch (state.mode) {\n case HEAD:\n if (state.wrap === 0) {\n state.mode = TYPEDO;\n break;\n }\n //=== NEEDBITS(16);\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if ((state.wrap & 2) && hold === 0x8b1f) { /* gzip header */\n state.check = 0/*crc32(0L, Z_NULL, 0)*/;\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = FLAGS;\n break;\n }\n state.flags = 0; /* expect zlib header */\n if (state.head) {\n state.head.done = false;\n }\n if (!(state.wrap & 1) || /* check if zlib header allowed */\n (((hold & 0xff)/*BITS(8)*/ << 8) + (hold >> 8)) % 31) {\n strm.msg = 'incorrect header check';\n state.mode = BAD;\n break;\n }\n if ((hold & 0x0f)/*BITS(4)*/ !== Z_DEFLATED) {\n strm.msg = 'unknown compression method';\n state.mode = BAD;\n break;\n }\n //--- DROPBITS(4) ---//\n hold >>>= 4;\n bits -= 4;\n //---//\n len = (hold & 0x0f)/*BITS(4)*/ + 8;\n if (state.wbits === 0) {\n state.wbits = len;\n }\n else if (len > state.wbits) {\n strm.msg = 'invalid window size';\n state.mode = BAD;\n break;\n }\n state.dmax = 1 << len;\n //Tracev((stderr, \"inflate: zlib header ok\\n\"));\n strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n state.mode = hold & 0x200 ? DICTID : TYPE;\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n break;\n case FLAGS:\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.flags = hold;\n if ((state.flags & 0xff) !== Z_DEFLATED) {\n strm.msg = 'unknown compression method';\n state.mode = BAD;\n break;\n }\n if (state.flags & 0xe000) {\n strm.msg = 'unknown header flags set';\n state.mode = BAD;\n break;\n }\n if (state.head) {\n state.head.text = ((hold >> 8) & 1);\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = TIME;\n /* falls through */\n case TIME:\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (state.head) {\n state.head.time = hold;\n }\n if (state.flags & 0x0200) {\n //=== CRC4(state.check, hold)\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n hbuf[2] = (hold >>> 16) & 0xff;\n hbuf[3] = (hold >>> 24) & 0xff;\n state.check = crc32(state.check, hbuf, 4, 0);\n //===\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = OS;\n /* falls through */\n case OS:\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (state.head) {\n state.head.xflags = (hold & 0xff);\n state.head.os = (hold >> 8);\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = EXLEN;\n /* falls through */\n case EXLEN:\n if (state.flags & 0x0400) {\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.length = hold;\n if (state.head) {\n state.head.extra_len = hold;\n }\n if (state.flags & 0x0200) {\n //=== CRC2(state.check, hold);\n hbuf[0] = hold & 0xff;\n hbuf[1] = (hold >>> 8) & 0xff;\n state.check = crc32(state.check, hbuf, 2, 0);\n //===//\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n }\n else if (state.head) {\n state.head.extra = null/*Z_NULL*/;\n }\n state.mode = EXTRA;\n /* falls through */\n case EXTRA:\n if (state.flags & 0x0400) {\n copy = state.length;\n if (copy > have) { copy = have; }\n if (copy) {\n if (state.head) {\n len = state.head.extra_len - state.length;\n if (!state.head.extra) {\n // Use untyped array for more conveniend processing later\n state.head.extra = new Array(state.head.extra_len);\n }\n arraySet(\n state.head.extra,\n input,\n next,\n // extra field is limited to 65536 bytes\n // - no need for additional size check\n copy,\n /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/\n len\n );\n //zmemcpy(state.head.extra + len, next,\n // len + copy > state.head.extra_max ?\n // state.head.extra_max - len : copy);\n }\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n state.length -= copy;\n }\n if (state.length) { break inf_leave; }\n }\n state.length = 0;\n state.mode = NAME;\n /* falls through */\n case NAME:\n if (state.flags & 0x0800) {\n if (have === 0) { break inf_leave; }\n copy = 0;\n do {\n // TODO: 2 or 1 bytes?\n len = input[next + copy++];\n /* use constant limit because in js we should not preallocate memory */\n if (state.head && len &&\n (state.length < 65536 /*state.head.name_max*/)) {\n state.head.name += String.fromCharCode(len);\n }\n } while (len && copy < have);\n\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) { break inf_leave; }\n }\n else if (state.head) {\n state.head.name = null;\n }\n state.length = 0;\n state.mode = COMMENT;\n /* falls through */\n case COMMENT:\n if (state.flags & 0x1000) {\n if (have === 0) { break inf_leave; }\n copy = 0;\n do {\n len = input[next + copy++];\n /* use constant limit because in js we should not preallocate memory */\n if (state.head && len &&\n (state.length < 65536 /*state.head.comm_max*/)) {\n state.head.comment += String.fromCharCode(len);\n }\n } while (len && copy < have);\n if (state.flags & 0x0200) {\n state.check = crc32(state.check, input, copy, next);\n }\n have -= copy;\n next += copy;\n if (len) { break inf_leave; }\n }\n else if (state.head) {\n state.head.comment = null;\n }\n state.mode = HCRC;\n /* falls through */\n case HCRC:\n if (state.flags & 0x0200) {\n //=== NEEDBITS(16); */\n while (bits < 16) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (hold !== (state.check & 0xffff)) {\n strm.msg = 'header crc mismatch';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n }\n if (state.head) {\n state.head.hcrc = ((state.flags >> 9) & 1);\n state.head.done = true;\n }\n strm.adler = state.check = 0;\n state.mode = TYPE;\n break;\n case DICTID:\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n strm.adler = state.check = zswap32(hold);\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = DICT;\n /* falls through */\n case DICT:\n if (state.havedict === 0) {\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n return Z_NEED_DICT;\n }\n strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;\n state.mode = TYPE;\n /* falls through */\n case TYPE:\n if (flush === Z_BLOCK || flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case TYPEDO:\n if (state.last) {\n //--- BYTEBITS() ---//\n hold >>>= bits & 7;\n bits -= bits & 7;\n //---//\n state.mode = CHECK;\n break;\n }\n //=== NEEDBITS(3); */\n while (bits < 3) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.last = (hold & 0x01)/*BITS(1)*/;\n //--- DROPBITS(1) ---//\n hold >>>= 1;\n bits -= 1;\n //---//\n\n switch ((hold & 0x03)/*BITS(2)*/) {\n case 0: /* stored block */\n //Tracev((stderr, \"inflate: stored block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = STORED;\n break;\n case 1: /* fixed block */\n fixedtables(state);\n //Tracev((stderr, \"inflate: fixed codes block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = LEN_; /* decode codes */\n if (flush === Z_TREES) {\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n break inf_leave;\n }\n break;\n case 2: /* dynamic block */\n //Tracev((stderr, \"inflate: dynamic codes block%s\\n\",\n // state.last ? \" (last)\" : \"\"));\n state.mode = TABLE;\n break;\n case 3:\n strm.msg = 'invalid block type';\n state.mode = BAD;\n }\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n break;\n case STORED:\n //--- BYTEBITS() ---// /* go to byte boundary */\n hold >>>= bits & 7;\n bits -= bits & 7;\n //---//\n //=== NEEDBITS(32); */\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if ((hold & 0xffff) !== ((hold >>> 16) ^ 0xffff)) {\n strm.msg = 'invalid stored block lengths';\n state.mode = BAD;\n break;\n }\n state.length = hold & 0xffff;\n //Tracev((stderr, \"inflate: stored length %u\\n\",\n // state.length));\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n state.mode = COPY_;\n if (flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case COPY_:\n state.mode = COPY;\n /* falls through */\n case COPY:\n copy = state.length;\n if (copy) {\n if (copy > have) { copy = have; }\n if (copy > left) { copy = left; }\n if (copy === 0) { break inf_leave; }\n //--- zmemcpy(put, next, copy); ---\n arraySet(output, input, next, copy, put);\n //---//\n have -= copy;\n next += copy;\n left -= copy;\n put += copy;\n state.length -= copy;\n break;\n }\n //Tracev((stderr, \"inflate: stored end\\n\"));\n state.mode = TYPE;\n break;\n case TABLE:\n //=== NEEDBITS(14); */\n while (bits < 14) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.nlen = (hold & 0x1f)/*BITS(5)*/ + 257;\n //--- DROPBITS(5) ---//\n hold >>>= 5;\n bits -= 5;\n //---//\n state.ndist = (hold & 0x1f)/*BITS(5)*/ + 1;\n //--- DROPBITS(5) ---//\n hold >>>= 5;\n bits -= 5;\n //---//\n state.ncode = (hold & 0x0f)/*BITS(4)*/ + 4;\n //--- DROPBITS(4) ---//\n hold >>>= 4;\n bits -= 4;\n //---//\n//#ifndef PKZIP_BUG_WORKAROUND\n if (state.nlen > 286 || state.ndist > 30) {\n strm.msg = 'too many length or distance symbols';\n state.mode = BAD;\n break;\n }\n//#endif\n //Tracev((stderr, \"inflate: table sizes ok\\n\"));\n state.have = 0;\n state.mode = LENLENS;\n /* falls through */\n case LENLENS:\n while (state.have < state.ncode) {\n //=== NEEDBITS(3);\n while (bits < 3) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.lens[order[state.have++]] = (hold & 0x07);//BITS(3);\n //--- DROPBITS(3) ---//\n hold >>>= 3;\n bits -= 3;\n //---//\n }\n while (state.have < 19) {\n state.lens[order[state.have++]] = 0;\n }\n // We have separate tables & no pointers. 2 commented lines below not needed.\n //state.next = state.codes;\n //state.lencode = state.next;\n // Switch to use dynamic table\n state.lencode = state.lendyn;\n state.lenbits = 7;\n\n opts = { bits: state.lenbits };\n ret = inflate_table(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts);\n state.lenbits = opts.bits;\n\n if (ret) {\n strm.msg = 'invalid code lengths set';\n state.mode = BAD;\n break;\n }\n //Tracev((stderr, \"inflate: code lengths ok\\n\"));\n state.have = 0;\n state.mode = CODELENS;\n /* falls through */\n case CODELENS:\n while (state.have < state.nlen + state.ndist) {\n for (;;) {\n here = state.lencode[hold & ((1 << state.lenbits) - 1)];/*BITS(state.lenbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if (here_val < 16) {\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.lens[state.have++] = here_val;\n }\n else {\n if (here_val === 16) {\n //=== NEEDBITS(here.bits + 2);\n n = here_bits + 2;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n if (state.have === 0) {\n strm.msg = 'invalid bit length repeat';\n state.mode = BAD;\n break;\n }\n len = state.lens[state.have - 1];\n copy = 3 + (hold & 0x03);//BITS(2);\n //--- DROPBITS(2) ---//\n hold >>>= 2;\n bits -= 2;\n //---//\n }\n else if (here_val === 17) {\n //=== NEEDBITS(here.bits + 3);\n n = here_bits + 3;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n len = 0;\n copy = 3 + (hold & 0x07);//BITS(3);\n //--- DROPBITS(3) ---//\n hold >>>= 3;\n bits -= 3;\n //---//\n }\n else {\n //=== NEEDBITS(here.bits + 7);\n n = here_bits + 7;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n len = 0;\n copy = 11 + (hold & 0x7f);//BITS(7);\n //--- DROPBITS(7) ---//\n hold >>>= 7;\n bits -= 7;\n //---//\n }\n if (state.have + copy > state.nlen + state.ndist) {\n strm.msg = 'invalid bit length repeat';\n state.mode = BAD;\n break;\n }\n while (copy--) {\n state.lens[state.have++] = len;\n }\n }\n }\n\n /* handle error breaks in while */\n if (state.mode === BAD) { break; }\n\n /* check for end-of-block code (better have one) */\n if (state.lens[256] === 0) {\n strm.msg = 'invalid code -- missing end-of-block';\n state.mode = BAD;\n break;\n }\n\n /* build code tables -- note: do not change the lenbits or distbits\n values here (9 and 6) without reading the comments in inftrees.h\n concerning the ENOUGH constants, which depend on those values */\n state.lenbits = 9;\n\n opts = { bits: state.lenbits };\n ret = inflate_table(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts);\n // We have separate tables & no pointers. 2 commented lines below not needed.\n // state.next_index = opts.table_index;\n state.lenbits = opts.bits;\n // state.lencode = state.next;\n\n if (ret) {\n strm.msg = 'invalid literal/lengths set';\n state.mode = BAD;\n break;\n }\n\n state.distbits = 6;\n //state.distcode.copy(state.codes);\n // Switch to use dynamic table\n state.distcode = state.distdyn;\n opts = { bits: state.distbits };\n ret = inflate_table(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts);\n // We have separate tables & no pointers. 2 commented lines below not needed.\n // state.next_index = opts.table_index;\n state.distbits = opts.bits;\n // state.distcode = state.next;\n\n if (ret) {\n strm.msg = 'invalid distances set';\n state.mode = BAD;\n break;\n }\n //Tracev((stderr, 'inflate: codes ok\\n'));\n state.mode = LEN_;\n if (flush === Z_TREES) { break inf_leave; }\n /* falls through */\n case LEN_:\n state.mode = LEN;\n /* falls through */\n case LEN:\n if (have >= 6 && left >= 258) {\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n inflate_fast(strm, _out);\n //--- LOAD() ---\n put = strm.next_out;\n output = strm.output;\n left = strm.avail_out;\n next = strm.next_in;\n input = strm.input;\n have = strm.avail_in;\n hold = state.hold;\n bits = state.bits;\n //---\n\n if (state.mode === TYPE) {\n state.back = -1;\n }\n break;\n }\n state.back = 0;\n for (;;) {\n here = state.lencode[hold & ((1 << state.lenbits) - 1)]; /*BITS(state.lenbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if (here_bits <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if (here_op && (here_op & 0xf0) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (;;) {\n here = state.lencode[last_val +\n ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((last_bits + here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n //--- DROPBITS(last.bits) ---//\n hold >>>= last_bits;\n bits -= last_bits;\n //---//\n state.back += last_bits;\n }\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.back += here_bits;\n state.length = here_val;\n if (here_op === 0) {\n //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?\n // \"inflate: literal '%c'\\n\" :\n // \"inflate: literal 0x%02x\\n\", here.val));\n state.mode = LIT;\n break;\n }\n if (here_op & 32) {\n //Tracevv((stderr, \"inflate: end of block\\n\"));\n state.back = -1;\n state.mode = TYPE;\n break;\n }\n if (here_op & 64) {\n strm.msg = 'invalid literal/length code';\n state.mode = BAD;\n break;\n }\n state.extra = here_op & 15;\n state.mode = LENEXT;\n /* falls through */\n case LENEXT:\n if (state.extra) {\n //=== NEEDBITS(state.extra);\n n = state.extra;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.length += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n //--- DROPBITS(state.extra) ---//\n hold >>>= state.extra;\n bits -= state.extra;\n //---//\n state.back += state.extra;\n }\n //Tracevv((stderr, \"inflate: length %u\\n\", state.length));\n state.was = state.length;\n state.mode = DIST;\n /* falls through */\n case DIST:\n for (;;) {\n here = state.distcode[hold & ((1 << state.distbits) - 1)];/*BITS(state.distbits)*/\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n if ((here_op & 0xf0) === 0) {\n last_bits = here_bits;\n last_op = here_op;\n last_val = here_val;\n for (;;) {\n here = state.distcode[last_val +\n ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];\n here_bits = here >>> 24;\n here_op = (here >>> 16) & 0xff;\n here_val = here & 0xffff;\n\n if ((last_bits + here_bits) <= bits) { break; }\n //--- PULLBYTE() ---//\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n //---//\n }\n //--- DROPBITS(last.bits) ---//\n hold >>>= last_bits;\n bits -= last_bits;\n //---//\n state.back += last_bits;\n }\n //--- DROPBITS(here.bits) ---//\n hold >>>= here_bits;\n bits -= here_bits;\n //---//\n state.back += here_bits;\n if (here_op & 64) {\n strm.msg = 'invalid distance code';\n state.mode = BAD;\n break;\n }\n state.offset = here_val;\n state.extra = (here_op) & 15;\n state.mode = DISTEXT;\n /* falls through */\n case DISTEXT:\n if (state.extra) {\n //=== NEEDBITS(state.extra);\n n = state.extra;\n while (bits < n) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n state.offset += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;\n //--- DROPBITS(state.extra) ---//\n hold >>>= state.extra;\n bits -= state.extra;\n //---//\n state.back += state.extra;\n }\n//#ifdef INFLATE_STRICT\n if (state.offset > state.dmax) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break;\n }\n//#endif\n //Tracevv((stderr, \"inflate: distance %u\\n\", state.offset));\n state.mode = MATCH;\n /* falls through */\n case MATCH:\n if (left === 0) { break inf_leave; }\n copy = _out - left;\n if (state.offset > copy) { /* copy from window */\n copy = state.offset - copy;\n if (copy > state.whave) {\n if (state.sane) {\n strm.msg = 'invalid distance too far back';\n state.mode = BAD;\n break;\n }\n// (!) This block is disabled in zlib defailts,\n// don't enable it for binary compatibility\n//#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR\n// Trace((stderr, \"inflate.c too far\\n\"));\n// copy -= state.whave;\n// if (copy > state.length) { copy = state.length; }\n// if (copy > left) { copy = left; }\n// left -= copy;\n// state.length -= copy;\n// do {\n// output[put++] = 0;\n// } while (--copy);\n// if (state.length === 0) { state.mode = LEN; }\n// break;\n//#endif\n }\n if (copy > state.wnext) {\n copy -= state.wnext;\n from = state.wsize - copy;\n }\n else {\n from = state.wnext - copy;\n }\n if (copy > state.length) { copy = state.length; }\n from_source = state.window;\n }\n else { /* copy from output */\n from_source = output;\n from = put - state.offset;\n copy = state.length;\n }\n if (copy > left) { copy = left; }\n left -= copy;\n state.length -= copy;\n do {\n output[put++] = from_source[from++];\n } while (--copy);\n if (state.length === 0) { state.mode = LEN; }\n break;\n case LIT:\n if (left === 0) { break inf_leave; }\n output[put++] = state.length;\n left--;\n state.mode = LEN;\n break;\n case CHECK:\n if (state.wrap) {\n //=== NEEDBITS(32);\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n // Use '|' insdead of '+' to make sure that result is signed\n hold |= input[next++] << bits;\n bits += 8;\n }\n //===//\n _out -= left;\n strm.total_out += _out;\n state.total += _out;\n if (_out) {\n strm.adler = state.check =\n /*UPDATE(state.check, put - _out, _out);*/\n (state.flags ? crc32(state.check, output, _out, put - _out) : adler32(state.check, output, _out, put - _out));\n\n }\n _out = left;\n // NB: crc32 stored as signed 32-bit int, zswap32 returns signed too\n if ((state.flags ? hold : zswap32(hold)) !== state.check) {\n strm.msg = 'incorrect data check';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n //Tracev((stderr, \"inflate: check matches trailer\\n\"));\n }\n state.mode = LENGTH;\n /* falls through */\n case LENGTH:\n if (state.wrap && state.flags) {\n //=== NEEDBITS(32);\n while (bits < 32) {\n if (have === 0) { break inf_leave; }\n have--;\n hold += input[next++] << bits;\n bits += 8;\n }\n //===//\n if (hold !== (state.total & 0xffffffff)) {\n strm.msg = 'incorrect length check';\n state.mode = BAD;\n break;\n }\n //=== INITBITS();\n hold = 0;\n bits = 0;\n //===//\n //Tracev((stderr, \"inflate: length matches trailer\\n\"));\n }\n state.mode = DONE;\n /* falls through */\n case DONE:\n ret = Z_STREAM_END;\n break inf_leave;\n case BAD:\n ret = Z_DATA_ERROR;\n break inf_leave;\n case MEM:\n return Z_MEM_ERROR;\n case SYNC:\n /* falls through */\n default:\n return Z_STREAM_ERROR;\n }\n }\n\n // inf_leave <- here is real place for \"goto inf_leave\", emulated via \"break inf_leave\"\n\n /*\n Return from inflate(), updating the total counts and the check value.\n If there was no progress during the inflate() call, return a buffer\n error. Call updatewindow() to create and/or update the window state.\n Note: a memory error from inflate() is non-recoverable.\n */\n\n //--- RESTORE() ---\n strm.next_out = put;\n strm.avail_out = left;\n strm.next_in = next;\n strm.avail_in = have;\n state.hold = hold;\n state.bits = bits;\n //---\n\n if (state.wsize || (_out !== strm.avail_out && state.mode < BAD &&\n (state.mode < CHECK || flush !== Z_FINISH))) {\n if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) {\n state.mode = MEM;\n return Z_MEM_ERROR;\n }\n }\n _in -= strm.avail_in;\n _out -= strm.avail_out;\n strm.total_in += _in;\n strm.total_out += _out;\n state.total += _out;\n if (state.wrap && _out) {\n strm.adler = state.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/\n (state.flags ? crc32(state.check, output, _out, strm.next_out - _out) : adler32(state.check, output, _out, strm.next_out - _out));\n }\n strm.data_type = state.bits + (state.last ? 64 : 0) +\n (state.mode === TYPE ? 128 : 0) +\n (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);\n if (((_in === 0 && _out === 0) || flush === Z_FINISH) && ret === Z_OK) {\n ret = Z_BUF_ERROR;\n }\n return ret;\n}\n\nfunction inflateEnd(strm) {\n\n if (!strm || !strm.state /*|| strm->zfree == (free_func)0*/) {\n return Z_STREAM_ERROR;\n }\n\n var state = strm.state;\n if (state.window) {\n state.window = null;\n }\n strm.state = null;\n return Z_OK;\n}\n\nfunction inflateGetHeader(strm, head) {\n var state;\n\n /* check state */\n if (!strm || !strm.state) { return Z_STREAM_ERROR; }\n state = strm.state;\n if ((state.wrap & 2) === 0) { return Z_STREAM_ERROR; }\n\n /* save header structure */\n state.head = head;\n head.done = false;\n return Z_OK;\n}\n\nfunction inflateSetDictionary(strm, dictionary) {\n var dictLength = dictionary.length;\n\n var state;\n var dictid;\n var ret;\n\n /* check state */\n if (!strm /* == Z_NULL */ || !strm.state /* == Z_NULL */) { return Z_STREAM_ERROR; }\n state = strm.state;\n\n if (state.wrap !== 0 && state.mode !== DICT) {\n return Z_STREAM_ERROR;\n }\n\n /* check for correct dictionary identifier */\n if (state.mode === DICT) {\n dictid = 1; /* adler32(0, null, 0)*/\n /* dictid = adler32(dictid, dictionary, dictLength); */\n dictid = adler32(dictid, dictionary, dictLength, 0);\n if (dictid !== state.check) {\n return Z_DATA_ERROR;\n }\n }\n /* copy dictionary to window using updatewindow(), which will amend the\n existing dictionary if appropriate */\n ret = updatewindow(strm, dictionary, dictLength, dictLength);\n if (ret) {\n state.mode = MEM;\n return Z_MEM_ERROR;\n }\n state.havedict = 1;\n // Tracev((stderr, \"inflate: dictionary set\\n\"));\n return Z_OK;\n}\n\n// String encode/decode helpers\n// 'use strict';\n\n\n// var utils = require('./common');\n\n\n// Quick check if we can use fast array to bin string conversion\n//\n// - apply(Array) can fail on Android 2.2\n// - apply(Uint8Array) can fail on iOS 5.1 Safary\n//\nvar STR_APPLY_OK = true;\nvar STR_APPLY_UIA_OK = true;\n\ntry { String.fromCharCode.apply(null, [ 0 ]); } catch (__) { STR_APPLY_OK = false; }\ntry { String.fromCharCode.apply(null, new Uint8Array(1)); } catch (__) { STR_APPLY_UIA_OK = false; }\n\n\n// Table with utf8 lengths (calculated by first byte of sequence)\n// Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS,\n// because max possible codepoint is 0x10ffff\nvar _utf8len = new Uint8Array(256);\nfor (var q = 0; q < 256; q++) {\n _utf8len[q] = (q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1);\n}\n_utf8len[254] = _utf8len[254] = 1; // Invalid sequence start\n\n\n// convert string to array (typed, when possible)\nfunction string2buf(str) {\n var buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;\n\n // count binary size\n for (m_pos = 0; m_pos < str_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n m_pos++;\n }\n }\n buf_len += c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4;\n }\n\n // allocate buffer\n buf = new Uint8Array(buf_len);\n\n // convert\n for (i = 0, m_pos = 0; i < buf_len; m_pos++) {\n c = str.charCodeAt(m_pos);\n if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {\n c2 = str.charCodeAt(m_pos + 1);\n if ((c2 & 0xfc00) === 0xdc00) {\n c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);\n m_pos++;\n }\n }\n if (c < 0x80) {\n /* one byte */\n buf[i++] = c;\n } else if (c < 0x800) {\n /* two bytes */\n buf[i++] = 0xC0 | (c >>> 6);\n buf[i++] = 0x80 | (c & 0x3f);\n } else if (c < 0x10000) {\n /* three bytes */\n buf[i++] = 0xE0 | (c >>> 12);\n buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n buf[i++] = 0x80 | (c & 0x3f);\n } else {\n /* four bytes */\n buf[i++] = 0xf0 | (c >>> 18);\n buf[i++] = 0x80 | (c >>> 12 & 0x3f);\n buf[i++] = 0x80 | (c >>> 6 & 0x3f);\n buf[i++] = 0x80 | (c & 0x3f);\n }\n }\n\n return buf;\n}\n\n// Helper (used in 2 places)\nfunction _buf2binstring(buf, len) {\n // use fallback for big arrays to avoid stack overflow\n if (len < 65537) {\n if ((buf.subarray && STR_APPLY_UIA_OK) || (!buf.subarray && STR_APPLY_OK)) {\n return String.fromCharCode.apply(null, shrinkBuf(buf, len));\n }\n }\n\n var result = '';\n for (var i = 0; i < len; i++) {\n result += String.fromCharCode(buf[i]);\n }\n return result;\n}\n\n\n// Convert binary string (typed, when possible)\nfunction binstring2buf(str) {\n var buf = new Uint8Array(str.length);\n for (var i = 0, len = buf.length; i < len; i++) {\n buf[i] = str.charCodeAt(i);\n }\n return buf;\n}\n\n\n// convert array to string\nfunction buf2string(buf, max) {\n var i, out, c, c_len;\n var len = max || buf.length;\n\n // Reserve max possible length (2 words per char)\n // NB: by unknown reasons, Array is significantly faster for\n // String.fromCharCode.apply than Uint16Array.\n var utf16buf = new Array(len * 2);\n\n for (out = 0, i = 0; i < len;) {\n c = buf[i++];\n // quick process ascii\n if (c < 0x80) { utf16buf[out++] = c; continue; }\n\n c_len = _utf8len[c];\n // skip 5 & 6 byte codes\n if (c_len > 4) { utf16buf[out++] = 0xfffd; i += c_len - 1; continue; }\n\n // apply mask on first byte\n c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07;\n // join the rest\n while (c_len > 1 && i < len) {\n c = (c << 6) | (buf[i++] & 0x3f);\n c_len--;\n }\n\n // terminated by end of string?\n if (c_len > 1) { utf16buf[out++] = 0xfffd; continue; }\n\n if (c < 0x10000) {\n utf16buf[out++] = c;\n } else {\n c -= 0x10000;\n utf16buf[out++] = 0xd800 | ((c >> 10) & 0x3ff);\n utf16buf[out++] = 0xdc00 | (c & 0x3ff);\n }\n }\n\n return _buf2binstring(utf16buf, out);\n}\n\n\n// Calculate max possible position in utf8 buffer,\n// that will not break sequence. If that's not possible\n// - (very small limits) return max size as is.\n//\n// buf[] - utf8 bytes array\n// max - length limit (mandatory);\nfunction utf8border(buf, max) {\n var pos;\n\n max = max || buf.length;\n if (max > buf.length) { max = buf.length; }\n\n // go back from last position, until start of sequence found\n pos = max - 1;\n while (pos >= 0 && (buf[pos] & 0xC0) === 0x80) { pos--; }\n\n // Fuckup - very small and broken sequence,\n // return max, because we should return something anyway.\n if (pos < 0) { return max; }\n\n // If we came to start of buffer - that means vuffer is too small,\n // return max too.\n if (pos === 0) { return max; }\n\n return (pos + _utf8len[buf[pos]] > max) ? pos : max;\n}\n\n/* Allowed flush values; see deflate() and inflate() below for details */\nvar Z_NO_FLUSH = 0;\nvar Z_SYNC_FLUSH = 2;\nvar Z_FINISH$1 = 4;\n/* Return codes for the compression/decompression functions. Negative values\n * are errors, positive values are used for special but normal events.\n */\nvar Z_OK$1 = 0;\nvar Z_STREAM_END$1 = 1;\nvar Z_NEED_DICT$1 = 2;\n//export var Z_MEM_ERROR = -4;\nvar Z_BUF_ERROR$1 = -5;\n\n// 'use strict';\n\nvar messages = {\n 2: 'need dictionary', /* Z_NEED_DICT 2 */\n 1: 'stream end', /* Z_STREAM_END 1 */\n 0: '', /* Z_OK 0 */\n '-1': 'file error', /* Z_ERRNO (-1) */\n '-2': 'stream error', /* Z_STREAM_ERROR (-2) */\n '-3': 'data error', /* Z_DATA_ERROR (-3) */\n '-4': 'insufficient memory', /* Z_MEM_ERROR (-4) */\n '-5': 'buffer error', /* Z_BUF_ERROR (-5) */\n '-6': 'incompatible version' /* Z_VERSION_ERROR (-6) */\n};\n\n// 'use strict';\n\n\nfunction ZStream() {\n /* next input byte */\n this.input = null; // JS specific, because we have no pointers\n this.next_in = 0;\n /* number of bytes available at input */\n this.avail_in = 0;\n /* total number of input bytes read so far */\n this.total_in = 0;\n /* next output byte should be put there */\n this.output = null; // JS specific, because we have no pointers\n this.next_out = 0;\n /* remaining free space at output */\n this.avail_out = 0;\n /* total number of bytes output so far */\n this.total_out = 0;\n /* last error message, NULL if no error */\n this.msg = ''/*Z_NULL*/;\n /* not visible by applications */\n this.state = null;\n /* best guess about the data type: binary or text */\n this.data_type = 2/*Z_UNKNOWN*/;\n /* adler32 value of the uncompressed data */\n this.adler = 0;\n}\n\n// 'use strict';\n\n\nfunction GZheader() {\n /* true if compressed data believed to be text */\n this.text = 0;\n /* modification time */\n this.time = 0;\n /* extra flags (not used when writing a gzip file) */\n this.xflags = 0;\n /* operating system */\n this.os = 0;\n /* pointer to extra field or Z_NULL if none */\n this.extra = null;\n /* extra field length (valid if extra != Z_NULL) */\n this.extra_len = 0; // Actually, we don't need it in JS,\n // but leave for few code modifications\n\n //\n // Setup limits is not necessary because in js we should not preallocate memory\n // for inflate use constant limit in 65536 bytes\n //\n\n /* space at extra (only when reading header) */\n // this.extra_max = 0;\n /* pointer to zero-terminated file name or Z_NULL */\n this.name = '';\n /* space at name (only when reading header) */\n // this.name_max = 0;\n /* pointer to zero-terminated comment or Z_NULL */\n this.comment = '';\n /* space at comment (only when reading header) */\n // this.comm_max = 0;\n /* true if there was or will be a header crc */\n this.hcrc = 0;\n /* true when done reading gzip header (not used when writing a gzip file) */\n this.done = false;\n}\n\n// 'use strict';\n\n\n// var zlib_inflate = require('./zlib/inflate');\n// var utils = require('./utils/common');\n// var strings = require('./utils/strings');\n// var c = require('./zlib/constants');\n// var msg = require('./zlib/messages');\n// var ZStream = require('./zlib/zstream');\n// var GZheader = require('./zlib/gzheader');\n\nvar toString = Object.prototype.toString;\n\n/**\n * class Inflate\n *\n * Generic JS-style wrapper for zlib calls. If you don't need\n * streaming behaviour - use more simple functions: [[inflate]]\n * and [[inflateRaw]].\n **/\n\n/* internal\n * inflate.chunks -> Array\n *\n * Chunks of output data, if [[Inflate#onData]] not overriden.\n **/\n\n/**\n * Inflate.result -> Uint8Array|Array|String\n *\n * Uncompressed result, generated by default [[Inflate#onData]]\n * and [[Inflate#onEnd]] handlers. Filled after you push last chunk\n * (call [[Inflate#push]] with `Z_FINISH` / `true` param) or if you\n * push a chunk with explicit flush (call [[Inflate#push]] with\n * `Z_SYNC_FLUSH` param).\n **/\n\n/**\n * Inflate.err -> Number\n *\n * Error code after inflate finished. 0 (Z_OK) on success.\n * Should be checked if broken data possible.\n **/\n\n/**\n * Inflate.msg -> String\n *\n * Error message, if [[Inflate.err]] != 0\n **/\n\n\n/**\n * new Inflate(options)\n * - options (Object): zlib inflate options.\n *\n * Creates new inflator instance with specified params. Throws exception\n * on bad params. Supported options:\n *\n * - `windowBits`\n * - `dictionary`\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information on these.\n *\n * Additional options, for internal needs:\n *\n * - `chunkSize` - size of generated data chunks (16K by default)\n * - `raw` (Boolean) - do raw inflate\n * - `to` (String) - if equal to 'string', then result will be converted\n * from utf8 to utf16 (javascript) string. When string output requested,\n * chunk length can differ from `chunkSize`, depending on content.\n *\n * By default, when no options set, autodetect deflate/gzip data format via\n * wrapper header.\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , chunk1 = Uint8Array([1,2,3,4,5,6,7,8,9])\n * , chunk2 = Uint8Array([10,11,12,13,14,15,16,17,18,19]);\n *\n * var inflate = new pako.Inflate({ level: 3});\n *\n * inflate.push(chunk1, false);\n * inflate.push(chunk2, true); // true -> last chunk\n *\n * if (inflate.err) { throw new Error(inflate.err); }\n *\n * console.log(inflate.result);\n * ```\n **/\nfunction Inflate(options) {\n if (!(this instanceof Inflate)) return new Inflate(options);\n\n this.options = assign({\n chunkSize: 16384,\n windowBits: 0,\n to: ''\n }, options || {});\n\n var opt = this.options;\n\n // Force window size for `raw` data, if not set directly,\n // because we have no header for autodetect.\n if (opt.raw && (opt.windowBits >= 0) && (opt.windowBits < 16)) {\n opt.windowBits = -opt.windowBits;\n if (opt.windowBits === 0) { opt.windowBits = -15; }\n }\n\n // If `windowBits` not defined (and mode not raw) - set autodetect flag for gzip/deflate\n if ((opt.windowBits >= 0) && (opt.windowBits < 16) &&\n !(options && options.windowBits)) {\n opt.windowBits += 32;\n }\n\n // Gzip header has no info about windows size, we can do autodetect only\n // for deflate. So, if window size not set, force it to max when gzip possible\n if ((opt.windowBits > 15) && (opt.windowBits < 48)) {\n // bit 3 (16) -> gzipped data\n // bit 4 (32) -> autodetect gzip/deflate\n if ((opt.windowBits & 15) === 0) {\n opt.windowBits |= 15;\n }\n }\n\n this.err = 0; // error code, if happens (0 = Z_OK)\n this.msg = ''; // error message\n this.ended = false; // used to avoid multiple onEnd() calls\n this.chunks = []; // chunks of compressed data\n\n this.strm = new ZStream();\n this.strm.avail_out = 0;\n\n var status = inflateInit2(\n this.strm,\n opt.windowBits\n );\n\n if (status !== Z_OK$1) {\n throw new Error(messages[status]);\n }\n\n this.header = new GZheader();\n\n inflateGetHeader(this.strm, this.header);\n}\n\n/**\n * Inflate#push(data[, mode]) -> Boolean\n * - data (Uint8Array|Array|ArrayBuffer|String): input data\n * - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.\n * See constants. Skipped or `false` means Z_NO_FLUSH, `true` meansh Z_FINISH.\n *\n * Sends input data to inflate pipe, generating [[Inflate#onData]] calls with\n * new output chunks. Returns `true` on success. The last data block must have\n * mode Z_FINISH (or `true`). That will flush internal pending buffers and call\n * [[Inflate#onEnd]]. For interim explicit flushes (without ending the stream) you\n * can use mode Z_SYNC_FLUSH, keeping the decompression context.\n *\n * On fail call [[Inflate#onEnd]] with error code and return false.\n *\n * We strongly recommend to use `Uint8Array` on input for best speed (output\n * format is detected automatically). Also, don't skip last param and always\n * use the same type in your code (boolean or number). That will improve JS speed.\n *\n * For regular `Array`-s make sure all elements are [0..255].\n *\n * ##### Example\n *\n * ```javascript\n * push(chunk, false); // push one of data chunks\n * ...\n * push(chunk, true); // push last chunk\n * ```\n **/\nInflate.prototype.push = function (data, mode) {\n var strm = this.strm;\n var chunkSize = this.options.chunkSize;\n var dictionary = this.options.dictionary;\n var status, _mode;\n var next_out_utf8, tail, utf8str;\n var dict;\n\n // Flag to properly process Z_BUF_ERROR on testing inflate call\n // when we check that all output data was flushed.\n var allowBufError = false;\n\n if (this.ended) { return false; }\n _mode = (mode === ~~mode) ? mode : ((mode === true) ? Z_FINISH$1 : Z_NO_FLUSH);\n\n // Convert data if needed\n if (typeof data === 'string') {\n // Only binary strings can be decompressed on practice\n strm.input = binstring2buf(data);\n } else if (toString.call(data) === '[object ArrayBuffer]') {\n strm.input = new Uint8Array(data);\n } else {\n strm.input = data;\n }\n\n strm.next_in = 0;\n strm.avail_in = strm.input.length;\n\n do {\n if (strm.avail_out === 0) {\n strm.output = new Uint8Array(chunkSize);\n strm.next_out = 0;\n strm.avail_out = chunkSize;\n }\n\n status = inflate(strm, Z_NO_FLUSH); /* no bad return value */\n\n if (status === Z_NEED_DICT$1 && dictionary) {\n // Convert data if needed\n if (typeof dictionary === 'string') {\n dict = string2buf(dictionary);\n } else if (toString.call(dictionary) === '[object ArrayBuffer]') {\n dict = new Uint8Array(dictionary);\n } else {\n dict = dictionary;\n }\n\n status = inflateSetDictionary(this.strm, dict);\n\n }\n\n if (status === Z_BUF_ERROR$1 && allowBufError === true) {\n status = Z_OK$1;\n allowBufError = false;\n }\n\n if (status !== Z_STREAM_END$1 && status !== Z_OK$1) {\n this.onEnd(status);\n this.ended = true;\n return false;\n }\n\n if (strm.next_out) {\n if (strm.avail_out === 0 || status === Z_STREAM_END$1 || (strm.avail_in === 0 && (_mode === Z_FINISH$1 || _mode === Z_SYNC_FLUSH))) {\n\n if (this.options.to === 'string') {\n\n next_out_utf8 = utf8border(strm.output, strm.next_out);\n\n tail = strm.next_out - next_out_utf8;\n utf8str = buf2string(strm.output, next_out_utf8);\n\n // move tail\n strm.next_out = tail;\n strm.avail_out = chunkSize - tail;\n if (tail) { arraySet(strm.output, strm.output, next_out_utf8, tail, 0); }\n\n this.onData(utf8str);\n\n } else {\n this.onData(shrinkBuf(strm.output, strm.next_out));\n }\n }\n }\n\n // When no more input data, we should check that internal inflate buffers\n // are flushed. The only way to do it when avail_out = 0 - run one more\n // inflate pass. But if output data not exists, inflate return Z_BUF_ERROR.\n // Here we set flag to process this error properly.\n //\n // NOTE. Deflate does not return error in this case and does not needs such\n // logic.\n if (strm.avail_in === 0 && strm.avail_out === 0) {\n allowBufError = true;\n }\n\n } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== Z_STREAM_END$1);\n\n if (status === Z_STREAM_END$1) {\n _mode = Z_FINISH$1;\n }\n\n // Finalize on the last chunk.\n if (_mode === Z_FINISH$1) {\n status = inflateEnd(this.strm);\n this.onEnd(status);\n this.ended = true;\n return status === Z_OK$1;\n }\n\n // callback interim results if Z_SYNC_FLUSH.\n if (_mode === Z_SYNC_FLUSH) {\n this.onEnd(Z_OK$1);\n strm.avail_out = 0;\n return true;\n }\n\n return true;\n};\n\n\n/**\n * Inflate#onData(chunk) -> Void\n * - chunk (Uint8Array|Array|String): ouput data. Type of array depends\n * on js engine support. When string output requested, each chunk\n * will be string.\n *\n * By default, stores data blocks in `chunks[]` property and glue\n * those in `onEnd`. Override this handler, if you need another behaviour.\n **/\nInflate.prototype.onData = function (chunk) {\n this.chunks.push(chunk);\n};\n\n\n/**\n * Inflate#onEnd(status) -> Void\n * - status (Number): inflate status. 0 (Z_OK) on success,\n * other if not.\n *\n * Called either after you tell inflate that the input stream is\n * complete (Z_FINISH) or should be flushed (Z_SYNC_FLUSH)\n * or if an error happened. By default - join collected chunks,\n * free memory and fill `results` / `err` properties.\n **/\nInflate.prototype.onEnd = function (status) {\n // On success - join\n if (status === Z_OK$1) {\n if (this.options.to === 'string') {\n // Glue & convert here, until we teach pako to send\n // utf8 alligned strings to onData\n this.result = this.chunks.join('');\n } else {\n this.result = flattenChunks(this.chunks);\n }\n }\n this.chunks = [];\n this.err = status;\n this.msg = this.strm.msg;\n};\n\n\n/**\n * inflate(data[, options]) -> Uint8Array|Array|String\n * - data (Uint8Array|Array|String): input data to decompress.\n * - options (Object): zlib inflate options.\n *\n * Decompress `data` with inflate/ungzip and `options`. Autodetect\n * format via wrapper header by default. That's why we don't provide\n * separate `ungzip` method.\n *\n * Supported options are:\n *\n * - windowBits\n *\n * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)\n * for more information.\n *\n * Sugar (options):\n *\n * - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify\n * negative windowBits implicitly.\n * - `to` (String) - if equal to 'string', then result will be converted\n * from utf8 to utf16 (javascript) string. When string output requested,\n * chunk length can differ from `chunkSize`, depending on content.\n *\n *\n * ##### Example:\n *\n * ```javascript\n * var pako = require('pako')\n * , input = pako.deflate([1,2,3,4,5,6,7,8,9])\n * , output;\n *\n * try {\n * output = pako.inflate(input);\n * } catch (err)\n * console.log(err);\n * }\n * ```\n **/\nfunction doInflate(input, options) {\n var inflator = new Inflate(options);\n\n inflator.push(input, true);\n\n // That will never happens, if you don't cheat with options :)\n if (inflator.err) { throw inflator.msg; }\n\n return inflator.result;\n}\n\nexport { doInflate as ungzip };","/**\n * @file Validation Parser\n * @author Alexander Rose \n * @private\n */\n\nimport { Debug, Log, ParserRegistry } from '../globals'\nimport XmlParser, { XmlParserParameters } from './xml-parser'\nimport Validation from '../structure/validation'\nimport Streamer from '../streamer/streamer';\n\nclass ValidationParser extends XmlParser {\n constructor (streamer: Streamer, params?: Partial) {\n const p = params || {}\n\n super(streamer, p)\n\n this.useDomParser = true\n this.validation = new Validation(this.name, this.path)\n }\n\n get __objName () { return 'validation' }\n get isXml () { return true }\n\n _parse () {\n super._parse()\n\n if (Debug) Log.time('ValidationParser._parse ' + this.name)\n\n this.validation.fromXml(this.xml.data)\n\n if (Debug) Log.timeEnd('ValidationParser._parse ' + this.name)\n }\n}\n\nParserRegistry.add('validation', ValidationParser)\n\nexport default ValidationParser\n","/**\n * @file Gzip Decompressor\n * @author Alexander Rose \n * @private\n */\n\nimport { ungzip } from '../../lib/pako_inflate.es6'\n\nimport { DecompressorRegistry } from '../globals'\n\nfunction gzipDecompress (data: ArrayBuffer|Uint8Array) {\n let decompressedData\n\n if (data instanceof ArrayBuffer) {\n data = new Uint8Array(data)\n }\n\n try {\n decompressedData = ungzip(data as Uint8Array)\n } catch (e) {\n decompressedData = data // assume it is already uncompressed\n }\n\n return decompressedData\n}\n\nDecompressorRegistry.add('gz', gzipDecompress)\n","/**\n * @file Datasource\n * @author Alexander Rose \n * @private\n */\n\n/**\n * Datasource base class\n * @interface\n */\nabstract class Datasource {\n /**\n * Get full url\n * @abstract\n * @param {String} path - datasource string\n * @return {String} - url\n */\n abstract getUrl (path: string): string\n\n /**\n * Get file extension\n * @abstract\n * @param {String} path - datasource string\n * @return {String} - extension\n */\n abstract getExt (path: string): string\n}\n\nexport default Datasource\n","/**\n * @file RCSB Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { Log, DatasourceRegistry } from '../globals'\nimport { getProtocol } from '../utils'\nimport { getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nconst baseUrl = '//files.rcsb.org/download/'\nconst mmtfBaseUrl = '//mmtf.rcsb.org/v1.0/'\nconst mmtfFullUrl = mmtfBaseUrl + 'full/'\nconst mmtfReducedUrl = mmtfBaseUrl + 'reduced/'\n\nclass RcsbDatasource extends Datasource {\n getUrl (src: string) {\n // valid path are\n // XXXX.pdb, XXXX.pdb.gz, XXXX.cif, XXXX.cif.gz, XXXX.mmtf, XXXX.bb.mmtf\n // XXXX defaults to XXXX.cif\n const info = getFileInfo(src)\n const pdbid = info.name.substr(0, 4)\n let url\n if ([ 'pdb', 'cif' ].includes(info.ext) &&\n (info.compressed === false || info.compressed === 'gz')\n ) {\n url = baseUrl + info.path\n } else if (info.ext === 'mmtf') {\n if (info.base.endsWith('.bb')) {\n url = mmtfReducedUrl + pdbid\n } else {\n url = mmtfFullUrl + pdbid\n }\n } else if (!info.ext) {\n url = mmtfFullUrl + pdbid\n } else {\n Log.warn('unsupported ext', info.ext)\n url = mmtfFullUrl + pdbid\n }\n return getProtocol() + url\n }\n\n getExt (src: string) {\n const ext = getFileInfo(src).ext\n return ext ? ext : 'mmtf'\n }\n}\n\nDatasourceRegistry.add('rcsb', new RcsbDatasource())\n\nexport default RcsbDatasource\n","/**\n * @file PubChem Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { Log, DatasourceRegistry } from '../globals'\nimport { getProtocol } from '../utils'\nimport { getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nconst baseUrl = '//pubchem.ncbi.nlm.nih.gov/rest/pug/compound/cid/'\nconst suffixUrl = '/SDF?record_type=3d'\n\nclass PubchemDatasource extends Datasource {\n getUrl (src: string) {\n const info = getFileInfo(src)\n const cid = info.name\n let url\n if (!info.ext || info.ext === 'sdf') {\n url = baseUrl + cid + suffixUrl\n } else {\n Log.warn('unsupported ext', info.ext)\n url = baseUrl + cid + suffixUrl\n }\n return getProtocol() + url\n }\n\n getExt (src: string) {\n const ext = getFileInfo(src).ext\n return ext ? ext : 'sdf'\n }\n}\n\nDatasourceRegistry.add('pubchem', new PubchemDatasource())\n\nexport default PubchemDatasource\n","/**\n * @file Pass Through Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { DatasourceRegistry } from '../globals'\nimport { getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nclass PassThroughDatasource extends Datasource {\n getUrl (path: string) {\n return path\n }\n\n getExt (path: string) {\n return getFileInfo(path).ext\n }\n}\n\nDatasourceRegistry.add('ftp', new PassThroughDatasource())\nDatasourceRegistry.add('http', new PassThroughDatasource())\nDatasourceRegistry.add('https', new PassThroughDatasource())\n\nexport default PassThroughDatasource\n","/**\r\n * @file Alphafold Datasource\r\n * @author Fredric Johansson \r\n * @private\r\n */\r\n\r\nimport { Log, DatasourceRegistry } from '../globals'\r\nimport { getProtocol } from '../utils'\r\nimport { getFileInfo } from '../loader/loader-utils'\r\nimport Datasource from './datasource'\r\n\r\nconst baseUrl = '//alphafold.ebi.ac.uk/files/AF-'\r\nconst suffixURL = '-F1-model_v2.pdb'\r\n\r\nclass AlphafoldDatasource extends Datasource {\r\n getUrl (src: string) {\r\n const info = getFileInfo(src)\r\n const uniprotid = info.name\r\n let url\r\n if (!info.ext || info.ext === 'pdb') {\r\n url = baseUrl + uniprotid + suffixURL\r\n } else {\r\n Log.warn('unsupported AF ext', info.ext)\r\n url = baseUrl + uniprotid + suffixURL\r\n }\r\n return getProtocol() + url\r\n }\r\n\r\n getExt (src: string) {\r\n const ext = getFileInfo(src).ext\r\n return ext ? ext : 'pdb'\r\n }\r\n}\r\n\r\nDatasourceRegistry.add('alphafold', new AlphafoldDatasource())\r\n\r\nexport default AlphafoldDatasource\r\n","/**\n * @file Static Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { getAbsolutePath } from '../utils'\nimport { getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nconst reProtocol = /^((http|https|ftp):)*\\/\\//\n\nclass StaticDatasource extends Datasource {\n baseUrl: string\n\n constructor (baseUrl: string = '') {\n super()\n this.baseUrl = baseUrl\n }\n\n getUrl (src: string) {\n const info = getFileInfo(src)\n let url = this.baseUrl + info.path\n if (!reProtocol.test(this.baseUrl)) {\n url = getAbsolutePath(url)\n }\n return url\n }\n\n getExt (src: string) {\n return getFileInfo(src).ext\n }\n}\n\nexport default StaticDatasource\n","/**\n * @file UI Parameters\n * @author Alexander Rose \n */\n\nimport { StageParameters } from '../stage/stage'\nimport { MouseActionPresets } from '../controls/mouse-actions'\n\nexport type BooleanParam = { type: 'boolean' }\nfunction BooleanParam () { return { type: 'boolean' } as BooleanParam }\n\nexport type ColorParam = { type: 'color' }\nfunction ColorParam () { return { type: 'color' } as ColorParam }\n\nexport type IntegerParam = { type: 'integer', max: number, min: number }\nfunction IntegerParam (max: number, min: number) {\n return { type: 'integer', max, min } as IntegerParam\n}\n\nexport type NumberParam = { type: 'number', precision: number, max: number, min: number }\nfunction NumberParam (precision: number, max: number, min: number) {\n return { type: 'number', precision, max, min } as NumberParam\n}\n\nexport type RangeParam = { type: 'range', step: number, max: number, min: number }\nfunction RangeParam (step: number, max: number, min: number) {\n return { type: 'range', step, max, min } as RangeParam\n}\n\nexport type SelectParam = { type: 'select', options: { [k: string]: string } }\nfunction SelectParam (...options: string[]) {\n return { type: 'select', options: options.reduce((o, k) => ({ ...o, [k]: k}), {}) } as SelectParam\n}\n\nexport type ParamType = BooleanParam|ColorParam|IntegerParam|NumberParam|RangeParam|SelectParam\n\nexport const UIStageParameters: { [k in keyof StageParameters]: ParamType } = {\n backgroundColor: ColorParam(),\n quality: SelectParam('auto', 'low', 'medium', 'high'),\n sampleLevel: RangeParam(1, 5, -1),\n impostor: BooleanParam(),\n workerDefault: BooleanParam(),\n rotateSpeed: NumberParam(1, 10, 0),\n zoomSpeed: NumberParam(1, 10, 0),\n panSpeed: NumberParam(1, 10, 0),\n clipNear: RangeParam(1, 100, 0),\n clipFar: RangeParam(1, 100, 0),\n clipDist: IntegerParam(200, 0),\n clipMode: SelectParam('scene', 'camera'),\n clipScale: SelectParam('relative', 'absolute'),\n fogNear: RangeParam(1, 100, 0),\n fogFar: RangeParam(1, 100, 0),\n cameraType: SelectParam('perspective', 'orthographic', 'stereo'),\n cameraEyeSep: NumberParam(3, 1.0, 0.01),\n cameraFov: RangeParam(1, 120, 15),\n lightColor: ColorParam(),\n lightIntensity: NumberParam(2, 10, 0),\n ambientColor: ColorParam(),\n ambientIntensity: NumberParam(2, 10, 0),\n hoverTimeout: IntegerParam(10000, -1),\n tooltip: BooleanParam(),\n mousePreset: SelectParam(...Object.keys(MouseActionPresets))\n}\n","/**\n * @file MDsrv Datasource\n * @author Alexander Rose \n * @private\n */\n\nimport { autoLoad, getFileInfo } from '../loader/loader-utils'\nimport Datasource from './datasource'\n\nclass MdsrvDatasource extends Datasource {\n baseUrl: string\n\n constructor (baseUrl: string = '') {\n super()\n this.baseUrl = baseUrl\n }\n\n getListing (path: string = '') {\n let url = `${this.baseUrl}dir/${path}`\n if (url[url.length - 1] !== '/') url += '/'\n return autoLoad(url, {\n ext: 'json'\n }).then((jsonData: any) => ({\n path: path,\n data: jsonData.data\n }))\n }\n\n getUrl (src: string) {\n const info = getFileInfo(src)\n return `${this.baseUrl}file/${info.path}${info.query}`\n }\n\n getCountUrl (src: string) {\n const info = getFileInfo(src)\n return `${this.baseUrl}traj/numframes/${info.path}${info.query}`\n }\n\n getFrameUrl (src: string, frameIndex: number|string) {\n const info = getFileInfo(src)\n return `${this.baseUrl}traj/frame/${frameIndex}/${info.path}${info.query}`\n }\n\n getFrameParams (src: string, atomIndices: (number|string)[]) {\n return `atomIndices=${atomIndices.join(';')}`\n }\n\n getPathUrl (src: string, atomIndex: number|string) {\n const info = getFileInfo(src)\n return `${this.baseUrl}traj/path/${atomIndex}/${info.path}${info.query}`\n }\n\n getExt (src: string) {\n return getFileInfo(src).ext\n }\n}\n\nexport default MdsrvDatasource\n","/**\n * @file Pdb Writer\n * @author Alexander Rose \n * @private\n */\n\nimport { sprintf } from 'sprintf-js'\n\nimport Writer from './writer'\nimport { defaults, ensureArray } from '../utils'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\n\n// http://www.wwpdb.org/documentation/file-format\n\n// Sample PDB line, the coords X,Y,Z are fields 5,6,7 on each line.\n// ATOM 1 N ARG 1 29.292 13.212 -12.751 1.00 33.78 1BPT 108\n\nconst AtomFormat =\n 'ATOM %5d %-4s %3s %1s%4d %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%1s%1s'\n\nconst HetatmFormat =\n 'HETATM%5d %-4s %3s %1s%4d %8.3f%8.3f%8.3f%6.2f%6.2f %4s%2s%1s%1s'\n\nexport interface PdbWriterParams {\n renumberSerial: boolean\n remarks: string[]\n}\n\n/**\n * Create a PDB file from a Structure object\n */\nexport default class PdbWriter extends Writer {\n readonly mimeType = 'text/plain'\n readonly defaultName = 'structure'\n readonly defaultExt = 'pdb'\n\n renumberSerial: boolean\n remarks: string[]\n\n structure: Structure\n private _records: string[]\n\n /**\n * @param {Structure} structure - the structure object\n * @param {Object} params - parameters]\n */\n constructor (structure: Structure, params?: PdbWriterParams) {\n super()\n\n const p = Object.assign({}, params)\n\n this.renumberSerial = defaults(p.renumberSerial, true)\n this.remarks = ensureArray(defaults(p.remarks, []))\n\n this.structure = structure\n this._records = []\n }\n\n private _writeRecords () {\n this._records.length = 0\n\n this._writeTitle()\n this._writeRemarks()\n this._writeAtoms()\n }\n\n private _writeTitle () {\n // FIXME multiline if title line longer than 80 chars\n this._records.push(sprintf('TITLE %-74s', this.structure.name))\n }\n\n private _writeRemarks () {\n this.remarks.forEach(str => {\n this._records.push(sprintf('REMARK %-73s', str))\n })\n\n if (this.structure.trajectory) {\n this._records.push(sprintf(\n 'REMARK %-73s',\n \"Trajectory '\" + this.structure.trajectory.name + \"'\"\n ))\n this._records.push(sprintf(\n 'REMARK %-73s',\n `Frame ${(this.structure.trajectory as any).frame}` // TODO\n ))\n }\n }\n\n private _writeAtoms () {\n let ia = 1\n let im = 1\n let charge = \" \"\n let chargeSign = \" \"\n const hasModels = this.structure.modelStore.count > 1\n\n this.structure.eachModel(m => {\n if (hasModels) this._records.push(sprintf('MODEL %4d%-66s', im++, ''))\n\n m.eachAtom((a: AtomProxy) => {\n const formatString = a.hetero ? HetatmFormat : AtomFormat\n const serial = this.renumberSerial ? ia : a.serial\n\n // Formal PDB spec\n // Alignment of one-letter atom name such as C starts at column 14,\n // while two-letter atom name such as FE starts at column 13.\n\n // This, however, leaves Calcium and C-alpha ambiguous\n // The convention (from earlier versions of the spec, see 1992, and also: \n // https://www.cgl.ucsf.edu/chimera/docs/UsersGuide/tutorials/pdbintro.html#misalignment)\n // is that element is right-justified in 13-14, modifiers are left justified in columns 15-16\n // A single-character element symmbol should not appear in column 13 unless the atom name has four characters\n let atomname = a.atomname\n\n if (atomname.length === 1) {\n // Simple case\n atomname = ' ' + atomname\n } else if (atomname.length < 4) {\n // 2 or 3-letter name, if element symbol is single char and matches name, add a space\n if (a.element.length === 1 && atomname[0] === a.element) {\n atomname = ' ' + atomname\n }\n }\n\n if (a.formalCharge) { // Skip nulls and zeros\n charge = Math.abs(a.formalCharge).toPrecision(1)\n chargeSign = (a.formalCharge > 0) ? \"+\" : \"-\"\n } else {\n charge = \" \"\n chargeSign = \" \"\n }\n\n this._records.push(sprintf(\n formatString,\n\n serial,\n atomname,\n a.resname,\n defaults(a.chainname, ' '),\n a.resno,\n a.x, a.y, a.z,\n defaults(a.occupancy, 1.0),\n defaults(a.bfactor, 0.0),\n '', // segid\n defaults(a.element, ''),\n charge,\n chargeSign\n ))\n ia += 1\n }, this.structure.getSelection())\n\n if (hasModels) this._records.push(sprintf('%-80s', 'ENDMDL'))\n })\n\n this._records.push(sprintf('%-80s', 'END'))\n }\n\n getString () {\n console.warn('PdbWriter.getString() is deprecated, use .getData instead')\n return this.getData()\n }\n\n /**\n * Get string containing the PDB file data\n * @return {String} PDB file\n */\n getData () {\n this._writeRecords()\n return this._records.join('\\n')\n }\n}\n","/**\n * Writer class for sdf/mol files.\n */\n\nimport { sprintf } from 'sprintf-js'\n\nimport Writer from './writer'\nimport Structure from '../structure/structure'\nimport AtomProxy from '../proxy/atom-proxy'\nimport BondProxy from '../proxy/bond-proxy'\n\n// Hard-coded chiral as false as we don't specify it any atoms\nconst CountFormat = '%3i%3i 0 0 0 0 0 0 0 0999 V2000'\nconst AtomLine = '%10.4f%10.4f%10.4f %-3s 0%3i 0 0 0'\nconst BondFormat = '%3i%3i%3i 0 0 0'\n\nclass SdfWriter extends Writer {\n readonly mimeType = 'text/plain'\n readonly defaultName = 'structure'\n readonly defaultExt = 'sdf'\n\n structure: Structure\n private _records: string[]\n\n /**\n * @param {Structure} structure - structure to write\n * @param {Object} params - parameters\n */\n constructor (structure: Structure) {\n super()\n\n this.structure = structure\n // Follow the pdb-writer example:\n this._records = []\n }\n\n get idString () {\n return this.structure.id\n }\n\n get titleString () {\n return ' ' + this.structure.title\n }\n\n get countsString () {\n return sprintf(\n CountFormat,\n this.structure.atomCount,\n this.structure.bondCount\n )\n }\n\n get chargeLines () {\n const pairs: [number, number][] = []\n this.structure.eachAtom(ap => {\n if (ap.formalCharge != null && ap.formalCharge !== 0) {\n pairs.push([ap.index, ap.formalCharge])\n }\n })\n const lines = []\n for (let i = 0; i < pairs.length; i += 8) {\n const nCharges = Math.min(8, pairs.length - i)\n let s = sprintf('M CHG%3i', nCharges)\n for (let j = i; j < i + nCharges; j++) {\n s += sprintf(' %3i %3i', pairs[j][0] + 1, pairs[j][1])\n }\n lines.push(s)\n }\n return lines\n }\n\n formatAtom (ap: AtomProxy) {\n let charge = 0\n if (ap.formalCharge != null && ap.formalCharge !== 0) {\n charge = 4 - ap.formalCharge\n }\n const line = sprintf(\n AtomLine, ap.x, ap.y, ap.z, ap.element, charge\n )\n if (line.length !== 48) { throw new Error('Incompatible atom for sdf format') }\n\n return line\n }\n\n formatBond (bp: BondProxy) {\n return sprintf(\n BondFormat,\n bp.atomIndex1 + 1,\n bp.atomIndex2 + 1,\n bp.bondOrder)\n }\n\n _writeRecords () {\n this._records.length = 0\n this._writeHeader()\n this._writeCTab()\n this._writeFooter()\n }\n\n _writeHeader () {\n this._records.push(this.idString, this.titleString, '')\n }\n\n _writeCTab () {\n this._records.push(this.countsString)\n this.structure.eachAtom(ap => {\n this._records.push(this.formatAtom(ap))\n })\n this.structure.eachBond(bp => {\n this._records.push(this.formatBond(bp))\n })\n this.chargeLines.forEach(line => {\n this._records.push(line)\n })\n this._records.push('M END')\n }\n\n _writeFooter () {\n this._records.push('$$$$')\n }\n\n getData () {\n this._writeRecords()\n return this._records.join('\\n')\n }\n}\n\nexport default SdfWriter\n","/**\n * @file STL Writer\n * @author Paul Pillot \n * @private\n */\n\nimport { Vector3 } from 'three'\n\nimport Writer from './writer'\nimport IOBuffer from '../utils/io-buffer'\nimport Surface from '../surface/surface'\n\n// https://en.wikipedia.org/wiki/STL_(file_format)#ASCII_STL\n\n/**\n * Create an STL File from a surface Object (e.g. for 3D printing)\n *\n * @example\n * molsurf = new MolecularSurface(structure)\n * surf = molsurf.getSurface({type: 'av', probeRadius: 1.4})\n * stl = new StlWriter(surf)\n * stl.download('myFileName')\n */\nexport default class StlWriter extends Writer {\n readonly mimeType = 'application/vnd.ms-pki.stl'\n readonly defaultName = 'surface'\n readonly defaultExt = 'stl'\n\n surface: any // TODO\n\n /**\n * @param {Surface} surface - the surface to write out\n */\n constructor (surface: Surface) {\n super()\n\n this.surface = surface\n }\n\n /*\n * Get STL Binary data\n *\n * Adapted from: https://github.com/mrdoob/three.js/blob/master/examples/js/exporters/STLBinaryExporter.js\n * see https://en.wikipedia.org/wiki/STL_(file_format)#Binary_STL for the file format description\n *\n * @return {DataView} the data\n */\n getData () {\n const triangles = this.surface.index.length / 3\n const bufferLength = triangles * 2 + triangles * 3 * 4 * 4 + 80 + 4\n const output = new IOBuffer(bufferLength)\n\n output.skip(80) // skip header\n output.writeUint32(triangles)\n\n const vector = new Vector3()\n const vectorNorm1 = new Vector3()\n const vectorNorm2 = new Vector3()\n const vectorNorm3 = new Vector3()\n\n // traversing vertices\n for (let i = 0; i < triangles; i++) {\n const indices = [\n this.surface.index[i * 3],\n this.surface.index[i * 3 + 1],\n this.surface.index[i * 3 + 2]\n ]\n\n vectorNorm1.fromArray(this.surface.normal, indices[0] * 3)\n vectorNorm2.fromArray(this.surface.normal, indices[1] * 3)\n vectorNorm3.fromArray(this.surface.normal, indices[2] * 3)\n\n vector.addVectors(vectorNorm1, vectorNorm2).add(vectorNorm3).normalize()\n\n output.writeFloat32(vector.x)\n output.writeFloat32(vector.y)\n output.writeFloat32(vector.z)\n\n for (let j = 0; j < 3; j++) {\n vector.fromArray(this.surface.position, indices[j] * 3)\n\n output.writeFloat32(vector.x) // vertices\n output.writeFloat32(vector.y)\n output.writeFloat32(vector.z)\n }\n\n output.writeUint16(0) // attribute byte count\n }\n\n return new DataView(output.buffer)\n }\n}"],"names":["getQuery","id","window","m","RegExp","exec","location","search","decodeURIComponent","defaults","value","defaultValue","undefined","createParams","params","defaultParams","o","Object","assign","k","updateParams","newParams","getProtocol","protocol","match","getBrowser","ua","navigator","userAgent","test","openUrl","url","open","href","download","data","downloadName","isSafari","isChromeIos","a","document","createElement","str","replace","msSaveOrOpenBlob","FileReader","Blob","reader","onloadend","result","readAsDataURL","objectUrlCreated","URL","createObjectURL","style","display","body","appendChild","target","click","removeChild","revokeObjectURL","lexicographicCompare","elm1","elm2","binarySearchIndexOf","array","element","compareFunction","low","high","length","mid","cmp","rangeInSortedArray","min","max","indexLeft","leftRange","binarySearchForLeftRange","indexRight","rightRange","binarySearchForRightRange","uniqueArray","sort","filter","index","sorted","uint8ToString","u8a","chunkSize","c","i","push","String","fromCharCode","apply","subarray","join","getTypedArray","arrayType","arraySize","Int8Array","Int16Array","Int32Array","Uint8Array","Uint16Array","Uint32Array","Float32Array","Error","getUintArray","sizeOrArray","maxUint","ensureBuffer","buffer","ArrayBuffer","_ensureClassFromArray","constructor","Array","isArray","fromArray","ensureVector3","v","Vector3","ensureMatrix4","Matrix4","ensureQuaternion","q","Quaternion","ensureFloat32Array","arg","toLowerCaseString","toString","toLowerCase","Registry","name","this","_dict","add","key","get","names","keys","degToRad","deg","chars","split","uuid","generateUUID","r","rnd","Math","random","clamp","lerp","start","stop","alpha","spline","p0","p1","p2","p3","t","tension","v0","v1","t2","smoothstep","x","normalize","colorSpace","ScaleDefaultParameters","scale","mode","domain","reverse","tmpColor","Color","manageColor","_target","_name","descriptor","originalMethod","fromTo","bind","set","convertSRGBToLinear","getHex","Colormaker","parameters","structure","atomProxy","getAtomProxy","getScale","p","slice","chroma","out","colorToArray","color","offset","atomColorToArray","atom","atomColor","bondColor","bond","atomIndex1","atomIndex2","bondColorToArray","volumeColorToArray","volumeColor","positionColorToArray","coords","positionColor","kwd","SelectAllKeyword","SelectNoneKeyword","AtomOnlyKeywords","BACKBONE","SIDECHAIN","BONDED","RING","AROMATICRING","METAL","POLARH","ChainKeywords","POLYMER","WATER","SmallResname","NucleophilicResname","HydrophobicResname","AromaticResname","AmideResname","AcidicResname","BasicResname","ChargedResname","PolarResname","NonpolarResname","CyclicResname","AliphaticResname","atomTestFn","s","atomname","altloc","atomindex","keyword","inscode","resname","sstruc","resno","chainname","model","isBackbone","isSidechain","isBonded","isRing","isAromatic","HETERO","isHetero","PROTEIN","isProtein","NUCLEIC","isNucleic","RNA","isRna","DNA","isDna","isPolymer","isWater","HELIX","isHelix","SHEET","isSheet","TURN","isTurn","ION","isIon","SACCHARIDE","isSaccharide","isMetal","isPolarHydrogen","includes","modelIndex","residueTestFn","atomOffset","atomEnd","chainTestFn","entity","modelTestFn","makeTest","selection","fn","error","rules","n","negate","f","subTests","hasOwnProperty","and","operator","na","ret","ALL","NONE","filtered","fs","makeAtomTest","atomOnly","filteredSelection","makeResidueTest","residueOnly","makeChainTest","chainOnly","makeModelTest","modelOnly","Selection","string","signals","stringChanged","Signal","setString","type","silent","retSelection","newSelection","oldSelection","selectionStack","trim","charAt","substr","chunks","createNewContext","getPrevContext","pop","pushRule","rule","not","cu","toUpperCase","lastRule","indexOf","indexList","map","parseInt","b","console","resnameList","isNaN","sele","substring","chain","negate2","resi","resiSingle","resiRange","parseSele","e","message","residueTest","chainTest","modelTest","atomOnlyTest","residueOnlyTest","chainOnlyTest","modelOnlyTest","dispatch","isAllSelection","isNoneSelection","SelectionColormaker","super","colormakerList","selectionList","dataList","forEach","scheme","ColormakerRegistry","hasScheme","getScheme","ColormakerScales","OrRd","PuBu","BuPu","Oranges","BuGn","YlOrBr","YlGn","Reds","RdPu","Greens","YlGnBu","Purples","GnBu","Greys","YlOrRd","PuRd","Blues","PuBuGn","Viridis","Spectral","RdYlGn","RdBu","PiYG","PRGn","RdYlBu","BrBG","RdGy","PuOr","Set1","Set2","Set3","Dark2","Paired","Pastel1","Pastel2","Accent","rainbow","rwb","ColormakerModes","rgb","hsv","hsl","hsi","lab","hcl","getWorkerDeps","vars","deps","sym","__deps","prototype","makeWorkerString","onmessage","__name","postId","__postId","self","func","callback","aMessage","transferList","postMessage","makeWorkerBlob","Browser","SupportsPassiveEventHandler","opts","defineProperty","addEventListener","Mobile","orientation","SupportsReadPixelsFloat","setSupportsReadPixelsFloat","ExtensionFragDepth","setExtensionFragDepth","Log","log","Function","call","info","warn","time","timeEnd","MeasurementDefaultParams","labelColor","labelAttachment","labelSize","labelZOffset","labelYOffset","labelBorder","labelBorderColor","labelBorderWidth","lineOpacity","linewidth","opacity","labelUnit","arcVisible","planeVisible","Debug","ScriptExtensions","WorkerRegistry","activeWorkerCount","_funcDict","_depsDict","_blobDict","schemes","userSchemes","SchemeClass","getSchemes","types","getScales","getModes","addScheme","label","_createScheme","_addUserScheme","removeScheme","_Colormaker","addSelectionScheme","DatasourceRegistry","RepresentationRegistry","ParserRegistry","__hasObjName","objName","parser","__objName","isTrajectory","isStructure","isVolume","isSurface","isBinary","isXml","isJson","getTrajectoryExtensions","getStructureExtensions","getVolumeExtensions","getSurfaceExtensions","ShaderRegistry","DecompressorRegistry","ComponentRegistry","BufferRegistry","PickerRegistry","exports","ListingDatasource","TrajectoryDatasource","Streamer","src","newline","__pointer","__partialLine","compressed","binary","json","xml","read","_read","then","decompressFn","_chunk","end","chunk","peekLines","charCodeAt","count","chunkToLines","lines","chunkCount","floor","asText","partialLine","isLast","idx","lastIndexOf","str2","concat","nextChunk","nextChunkOfLines","d","eachChunk","round","eachChunkOfLines","chunkNo","dispose","FileStreamer","Promise","resolve","reject","file","onload","event","onerror","readAsArrayBuffer","readAsText","NetworkStreamer","xhr","XMLHttpRequest","status","response","statusText","responseType","send","Loader","ext","dir","path","streamerParams","File","streamer","ParserLoader","parserParams","voxelSize","firstModelOnly","asTrajectory","cAlphaOnly","delimiter","comment","columnNames","inferBonds","load","parse","Script","functionBody","elementAdded","elementRemoved","nameChanged","run","stage","ScriptLoader","getFileInfo","compressedExtList","queryIndex","query","base","nameSplit","protocolMatch","getDataInfo","datasource","getUrl","getExt","autoLoad","loader","Writer","getBlob","getData","mimeType","defaultName","defaultExt","charArray","IOBuffer","_mark","_marks","littleEndian","dataIsGiven","byteLength","dvOffset","byteOffset","_lastWrittenByte","_data","DataView","available","isLittleEndian","setLittleEndian","isBigEndian","setBigEndian","skip","seek","mark","reset","pushMark","popMark","rewind","ensureAvailable","newLength","newArray","readBoolean","readUint8","readInt8","getInt8","getUint8","readByte","readBytes","bytes","readInt16","getInt16","readUint16","getUint16","readInt32","getInt32","readUint32","getUint32","readFloat32","getFloat32","readFloat64","getFloat64","readChar","readChars","writeBoolean","writeUint8","writeInt8","setInt8","_updateLastWrittenByte","setUint8","writeByte","writeBytes","writeInt16","setInt16","writeUint16","setUint16","writeInt32","setInt32","writeUint32","setUint32","writeFloat32","setFloat32","writeFloat64","setFloat64","writeChar","writeChars","toArray","Counter","countChanged","signalsWrapper","clear","change","delta","increment","decrement","listen","counter","unlisten","has","remove","onZeroOnce","context","Stats","updated","maxDuration","Infinity","minDuration","avgDuration","lastDuration","prevFpsTime","lastFps","lastFrames","frames","begin","update","startTime","currentTime","performance","now","reInclude","shaderCache","getShader","defines","hash","definesText","getDefines","shaderText","ShaderChunk","WebGLRenderingContext","wrcp","_getShaderParameter","getShaderParameter","arguments","_getShaderInfoLog","getShaderInfoLog","_getProgramParameter","getProgramParameter","program","pname","LINK_STATUS","_getProgramInfoLog","getProgramInfoLog","JitterVectors","offsetList","TiledRenderer","renderer","camera","viewer","canvas","_viewer","_factor","factor","_antialias","antialias","_onProgress","onProgress","_onFinish","onFinish","_n","_width","width","_height","height","_ctx","getContext","_viewerSampleLevel","sampleLevel","setSampling","_renderTile","offsetX","offsetY","setViewOffset","render","w","h","drawImage","domElement","ceil","_finalize","view","renderAsync","setTimeout","TwoPI","PI","RAD2DEG","circularMean","stride","indices","cosMean","sinMean","angle","cos","sin","atan2","calculateCenterArray","array1","array2","center","calculateDirectionArray","direction","uniformArray","optionalTarget","uniformArray3","j","serialArray","serialBlockArray","replicateArrayEntries","repArr","copyArray","dst","srcOffset","dstOffset","copyWithin","arrayMax","il","arrayMin","arraySum","sum","arrayMean","ImageDefaultParameters","transparent","makeImage","originalClearAlpha","getClearAlpha","backgroundColor","getClearColor","setLineWidthAndPixelSize","invert","scene","traverse","material","uniforms","size","__seen","trimCanvas","bg","g","canvasHeight","canvasWidth","pixels","getImageData","y","doBreak","off","topY","topX","bottomY","bottomX","trimedCanvas","_trimCanvas","finished","tiledRenderer","toBlob","blob","setClearAlpha","requestRender","vertex","matrix","modelViewProjectionMatrix","resolution","Vector2","projectionMatrixInverse","projectionMatrixTranspose","updateCameraUniforms","group","getInverse","projectionMatrix","copy","transpose","u","loadShader","gl","shaderSource","shaderType","shader","createShader","compileShader","COMPILE_STATUS","deleteShader","getExtension","TextureTestTexCoords","testTextureSupport","vertShader","VERTEX_SHADER","fragShader","FRAGMENT_SHADER","shaders","attribs","locations","createProgram","attachShader","attrib","bindAttribLocation","linkProgram","deleteProgram","useProgram","positionLocation","getAttribLocation","colorLoc","getUniformLocation","positionBuffer","createBuffer","bindBuffer","ARRAY_BUFFER","bufferData","STATIC_DRAW","enableVertexAttribArray","vertexAttribPointer","FLOAT","whiteTex","createTexture","whiteData","bindTexture","TEXTURE_2D","texImage2D","RGBA","UNSIGNED_BYTE","tex","texParameteri","TEXTURE_MIN_FILTER","NEAREST","TEXTURE_MAG_FILTER","fb","createFramebuffer","bindFramebuffer","FRAMEBUFFER","framebufferTexture2D","COLOR_ATTACHMENT0","checkFramebufferStatus","FRAMEBUFFER_COMPLETE","uniform4fv","drawArrays","TRIANGLES","clearColor","COLOR_BUFFER_BIT","pixel","readPixels","floatPixel","getError","NO_ERROR","INVALID_ENUM","INVALID_VALUE","INVALID_OPERATION","INVALID_FRAMEBUFFER_OPERATION","OUT_OF_MEMORY","CONTEXT_LOST_WEBGL","getErrorDescription","pixelBufferFloat","pixelBufferUint","pixelOrder","tmpMatrix","onBeforeRender","geometry","updateList","objectId","modelViewMatrixInverse","modelViewMatrixInverseTranspose","modelViewProjectionMatrixInverse","modelViewMatrix","multiplyMatrices","matrixWorldInverse","matrixWorld","materialProperties","properties","pu","getUniforms","setValue","Viewer","idOrElement","boundingBox","Box3","boundingBoxSize","boundingBoxLength","memory","programs","geometries","textures","calls","vertices","faces","points","distVector","ticked","rendered","elm","getElementById","container","HTMLElement","innerWidth","innerHeight","box","getBoundingClientRect","overflow","wrapper","position","_initParams","_initStats","_initCamera","_initScene","_initRenderer","_initHelper","setBackground","setFog","animate","fogColor","fogNear","fogFar","cameraType","cameraFov","cameraEyeSep","cameraZ","clipNear","clipFar","clipDist","clipMode","clipScale","lightColor","lightIntensity","ambientColor","ambientIntensity","rendererEncoding","LinearEncoding","lookAt","perspectiveCamera","PerspectiveCamera","z","orthographicCamera","OrthographicCamera","stereoCamera","StereoCamera","aspect","eyeSep","updateProjectionMatrix","stats","Scene","rotationGroup","Group","translationGroup","modelGroup","pickingGroup","backgroundGroup","helperGroup","fog","Fog","spotLight","SpotLight","ambientLight","AmbientLight","dpr","devicePixelRatio","WebGLRenderer","preserveDrawingBuffer","innerHTML","setPixelRatio","setSize","autoClear","sortObjects","outputEncoding","capabilities","isWebGL2","extensions","supportsHalfFloat","dprWidth","dprHeight","JSON","stringify","OES_texture_float","OES_texture_half_float","WEBGL_color_buffer_float","pickingTarget","WebGLRenderTarget","minFilter","NearestFilter","magFilter","stencilBuffer","format","RGBAFormat","FloatType","UnsignedByteType","texture","generateMipmaps","encoding","setRenderTarget","sampleTarget","LinearFilter","holdTarget","compositeUniforms","tForeground","Uniform","compositeMaterial","ShaderMaterial","vertexShader","fragmentShader","premultipliedAlpha","blending","AdditiveBlending","depthTest","depthWrite","compositeCamera","compositeScene","Mesh","PlaneGeometry","positions","bbGeometry","BufferGeometry","setIndex","BufferAttribute","setAttribute","bbMaterial","uColor","boundingBoxMesh","LineSegments","updateHelper","attributes","needsUpdate","isEmpty","computeBoundingSphere","cameraDistance","abs","instanceList","instance","addBuffer","wireframeGroup","background","pickable","setUserData","object","children","userData","mesh","getMesh","applyMatrix4","wireframeMesh","getWireframeMesh","quaternion","pickingMesh","getPickingMesh","_updateBoundingBox","updateBoundingBox","instanceMatrix","updateGeometry","computeBoundingBox","geoBoundingBox","clone","equals","expandByScalar","union","updateNode","node","makeEmpty","getSize","getPickingPixels","imgBuffer","readRenderTargetPixels","getImage","picking","imgBuffer2","ctx","imgData","putImageData","setLight","intensity","near","far","setClearColor","getStyle","level","setOutputEncoding","setColorWorkflow","sRGBEncoding","setCamera","fov","up","updateZoom","setClip","dist","left","right","top","bottom","handleResize","updateInfo","rInfo","rMemory","rRender","triangles","isStill","currentSampleLevel","renderPending","frameRequest","requestAnimationFrame","pick","pid","picker","pixelBuffer","oid","getObjectById","tan","zoom","absoluteToRelative","bRadius","relativeToAbsolute","__updateClipping","isFinite","getWorldPosition","cDist","nearFactor","farFactor","fogNearFactor","fogFarFactor","__updateCamera","updateMatrix","updateMatrixWorld","pixelRatio","getPixelRatio","ortho","nearClip","updateMaterialUniforms","traverseVisible","Points","sortParticles","sortData","sortArray","zArray","cmpFn","indexSrc","indexDst","tmpTab","__zArray","__sortArray","__cmpFn","ai","bi","arr","stack","tmp","sp","swap","tmp2","quicksortCmp","attr","itemSize","sortProjectedPosition","__setVisibility","helper","visible","__updateLights","setLength","__renderPickingGroup","__renderModelGroup","renderTarget","__renderSuperSample","baseSampleWeight","sampleWeight","clearViewOffset","__renderStereo","_renderTarget","setScissorTest","setScissor","setViewport","cameraL","__render","cameraR","lastRenderedPicking","rendering","cancelAnimationFrame","getTouchDistance","dx","touches","pageX","dy","pageY","sqrt","MouseObserver","moved","scrolled","dragged","dropped","clicked","hovered","doubleClicked","prevPosition","down","canvasPosition","prevClickCP","moving","hovering","lastMoved","which","buttons","pressed","altKey","ctrlKey","metaKey","shiftKey","touchAction","hoverTimeout","handleScroll","doubleClickSpeed","_listen","_onMousewheel","_onMousemove","_onMousedown","_onMouseup","_onContextmenu","_onTouchstart","_onTouchend","_onTouchmove","opt","passive","setParameters","cp","doubleClickPending","lastClicked","overElement","preventDefault","_setKeys","deltaY","deltaMode","WheelEvent","DOM_DELTA_PIXEL","DOM_DELTA_LINE","wheelDelta","wheelDeltaY","detail","clientX","clientY","_setCanvasPosition","button","getMouseButtons","_distance","distanceTo","lastTouchDistance","touchDistance","removeEventListener","tmpRotateXMatrix","tmpRotateYMatrix","tmpRotateZMatrix","tmpRotateMatrix","tmpRotateCameraMatrix","tmpRotateVector","tmpRotateQuaternion","tmpRotateQuaternion2","tmpPanMatrix","tmpPanVector","tmpAtomVector","TrackballControls","rotateSpeed","zoomSpeed","panSpeed","mouse","mouseObserver","controls","viewerControls","component","transformComponent","transformAtom","_setPanVector","scaleFactor","getCanvasScaleFactor","multiplyScalar","_getRotateXY","_getCameraRotation","extractRotation","multiply","makeRotationY","_transformPanVector","transform","premultiply","pan","translate","panComponent","panAtom","positionToVector3","positionAdd","updateRepresentations","rotate","setFromAxisAngle","makeRotationFromQuaternion","applyMatrix","zRotate","dz","makeRotationZ","rotateComponent","makeRotationAxis","setFromRotationMatrix","tmpVec","PickingProxy","pickingData","getComponentsByObject","list","getObject","getPosition","closestBondAtom","atom1","v2","atom2","acp1","getPositionOnCanvas","acp2","closeAtom","ca","acp","radius","getMaxRepresentationRadius","arrow","_objectIfType","axes","cone","clash","contact","cylinder","distance","ellipsoid","octahedron","point","sphere","tetrahedron","torus","surface","unitcell","unknown","volume","wideline","getLabel","msg","qualifiedName","sele1","sele2","serial","shape","toPrecision","spacegroup","PickingControls","pickerArray","tmpQ","tmpP","tmpS","tmpCanvasVector","tmpScaleVector","tmpAlignMatrix","ViewerControls","changed","rotation","project","getCameraDistance","getOrientation","setPosition","orient","decompose","setRotationFromQuaternion","vector","spin","axis","rotateOnAxis","align","basis","setRotationFromMatrix","Animation","duration","args","pausedTime","elapsedDuration","pausedDuration","ignoreGlobalToggle","_paused","_resolveList","_init","done","paused","tick","_tick","pause","hold","_hold","resume","releaseHold","toggle","SpinAnimation","RockAnimation","angleSum","angleStep","angleEnd","MoveAnimation","moveFrom","moveTo","lerpVectors","ZoomAnimation","zoomFrom","zoomTo","RotateAnimation","_currentRotation","rotateFrom","rotateTo","slerp","ValueAnimation","valueFrom","valueTo","TimeoutAnimation","AnimationList","_list","every","animation","AnimationControls","animationList","finishedList","splice","rock","move","zoomMove","orientTo","timeout","spinComponent","rockComponent","moveComponent","Queue","argList","queue","pending","next","shift","kill","Representation","lazy","step","clipRadius","precision","clipCenter","flatShaded","side","options","front","back","double","wireframe","colorData","colorScheme","colorScale","colorReverse","colorValue","colorDomain","colorMode","roughness","metalness","diffuse","diffuseInterior","useInteriorColor","interiorColor","interiorDarkening","disablePicking","rebuild","tasks","make","bufferList","toBePrepared","init","setColor","quality","lazyProps","build","bufferParams","what","tp","sphereDetail","radialSegments","openEnded","disableImpostor","getColorParams","getBufferParams","val","prepare","cb","create","updateWhat","_make","manualAttach","disposed","attach","setVisibility","noRenderRequest","updateParameters","int","float","parseFloat","getParameters","_Worker","postCount","onmessageDict","onerrorDict","blobUrl","worker","Worker","post","__debug","terminate","WorkerPool","maxCount","pool","getNextWorker","nextWorker","minPending","calculateMeanVector3","projectPointOnVector","origin","sub","projectOnVector","minX","minY","minZ","maxX","maxY","maxZ","l","v3new","applyMatrix4toVector3array","applyMatrix3toVector3array","normalizeVector3array","len2","v3cross","ax","ay","az","bx","by","bz","v3dot","v3sub","v3add","v3fromArray","v3toArray","input","v3length2","v3length","v3divideScalar","v3multiplyScalar","v3normalize","length2","v3subScalar","v3addScalar","v3floor","v3ceil","v3negate","v3angle","cx","cy","cz","getFixedCountDashData","segmentCount","position1","sn3","position2","i3","j3","f1","f2","replicateArray3Entries","color2","primitiveId","getFixedLengthDashData","segmentLength","pos1","pos2","col","rad","getFixedLengthWrappedDashData","remaining","drawing","k3","kprev","vl","inv","Primitive","Picker","Buffer","static","_primitiveData","getShapeKey","fields","valueToShape","expandBoundingBox","valueFromShape","arrayFromShape","dataFromShape","SpherePrimitive","expandByPoint","BoxPrimitive","heightAxis","depthAxis","OctahedronPrimitive","TetrahedronPrimitive","CylinderPrimitive","dashedCylinder","ArrowPrimitive","ConePrimitive","EllipsoidPrimitive","majorAxis","minorAxis","TorusPrimitive","TextPrimitive","text","PointPrimitive","WidelinePrimitive","SpatialHash","exp","bb","createBoundingBox","boundX","boundY","boundZ","an","xArray","yArray","grid","bucketIndex","bucketCount","bucketOffset","bucketFill","bucketArray","bucketIdx","within","eachWithin","atomIndex","rSq","loX","loY","loZ","hiX","hiY","hiZ","ix","iy","iz","dSq","Store","_fields","_defaultFields","_initField","addField","resize","tmpArray","growIfFull","copyFrom","other","thisOffset","otherOffset","thisField","otherField","thisIndex","otherIndex","offsetTarget","offsetSource","targetIndex","sourceIndex","thisStore","tmpStore","quicksort","pivot","leftNew","rightNew","index1","index2","ContactStore","addContact","hammingWeight","BitArray","setAll","_words","flip","_assignRange","words","wordValue","wordStart","wordEnd","startWord","endWord","setRange","clearRange","setBits","clearBits","clearAll","flipAll","bs","_isRangeValue","isRangeSet","isRangeClear","isAllSet","isAllClear","isSet","isClear","isEqualTo","otherBitarray","words1","words2","difference","intersection","intersects","getIntersectionSize","makeIntersection","wordsA","answer","pos","toSeleString","createAdjacencyList","edges","edgeCount","nodeCount","nodeArray1","nodeArray2","countArray","offsetArray","bondCount2","indexArray","idx1","idx2","j1","j2","createFeatureState","atomSet","addAtom","state","addFeature","features","groups","centers","atomSets","UnknownBackboneType","ChemCompProtein","ChemCompRna","ChemCompDna","ChemCompSaccharide","ChemCompHetero","SecStrucHelix","SecStrucSheet","SecStrucTurn","AtomicNumbers","H","D","T","HE","LI","BE","B","C","N","O","F","NE","NA","MG","AL","SI","P","S","CL","AR","K","CA","SC","TI","V","CR","MN","FE","CO","NI","CU","ZN","GA","GE","AS","SE","BR","KR","RB","SR","Y","ZR","NB","MO","TC","RU","RH","PD","AG","CD","IN","SN","SB","TE","I","XE","CS","BA","LA","CE","PR","ND","PM","SM","EU","GD","TB","DY","HO","ER","TM","YB","LU","HF","TA","W","RE","OS","IR","PT","AU","HG","TL","PB","BI","PO","AT","RN","FR","RA","AC","TH","PA","U","NP","PU","AM","CM","BK","CF","ES","FM","MD","NO","LR","RF","DB","SG","BH","HS","MT","DS","RG","CN","NH","FL","MC","LV","TS","OG","VdwRadii","CovalentRadii","Valences","OuterShellElectronCounts","ResidueHydrophobicity","ALA","ARG","ASN","ASP","ASH","CYS","GLN","GLU","GLH","GLY","HIS","ILE","LEU","LYS","MET","PHE","PRO","SER","THR","TRP","TYR","VAL","DefaultResidueHydrophobicity","AA1","SEC","PYL","AA3","RnaBases","DnaBases","PurinBases","Bases","WaterNames","IonNames","SaccharideNames","ProteinBackboneAtoms","NucleicBackboneAtoms","ResidueTypeAtoms","trace","direction1","direction2","backboneStart","backboneEnd","PDBQTSpecialElements","HD","A","NS","OA","SA","G0","G1","G2","G3","CG0","CG1","CG2","CG3","assignGeometry","totalCoordination","Angles","Map","calcAngles","ap1","ap2","angles","d1","d2","subVectors","eachBondedAtom","number","angleTo","calcPlaneAngle","x1","v12","neighbours","ni","cross","ValenceModel","atomCount","charge","implicitH","totalH","idealGeometry","eachAtom","chg","implH","totH","geom","hydrogenCount","bondToElementCount","formalCharge","assignCharge","assignH","degree","bondCount","valence","eachBond","bondOrder","explicitValence","conjugated","_bp","getBondProxy","atomicNumber","hetero","flag","a2","getOtherAtom","b2","atomicNumber2","isConjugated","multiBond","implicitHCount","ba","oa","calculateHydrogensCharge","valenceModel","isPhosphate","PositvelyCharged","NegativelyCharged","isIonicInteraction","ti","tj","isPiStacking","isCationPi","isHistidineNitrogen","ap","isHydrogenBond","isWeakHydrogenBond","IonicTypeMetals","isMetalComplex","halBondElements","X","OptimalHalogenAngle","OptimalAcceptorAngle","invalidAtomContact","masterIdx","isMasterContact","ContactDefaultParams","maxHydrophobicDist","maxHbondDist","maxHbondSulfurDist","maxHbondAccAngle","maxHbondDonAngle","maxHbondAccPlaneAngle","maxHbondDonPlaneAngle","maxPiStackingDist","maxPiStackingOffset","maxPiStackingAngle","maxCationPiDist","maxCationPiOffset","maxIonicDist","maxHalogenBondDist","maxHalogenBondAngle","maxMetalDist","refineSaltBridges","masterModelIndex","lineOfSightDistFactor","residueIndex","calculateFeatures","atomInGroupDict","eachResidue","addGroup","terminalNitrogenCount","isGuanidine","isAcetamidine","addPositiveCharges","isSulfonicAcid","isSulfate","terminalOxygenCount","isCarboxylate","addNegativeCharges","rings","getAromaticRings","ring","addAromaticRings","totalBonds","ig","addHydrogenAcceptors","addHydrogenDonors","ringData","residueType","getRings","hasElement","some","residueAtomOffset","atomTypeId","atomTypeIdList","atomMap","inAromaticRingWithElectronNegativeElement","addWeakHydrogenDonors","dative","ionic","isStandardAminoacid","isStandardBase","isHalogen","addMetalBinding","isTransitionMetal","addMetals","addHydrophobic","addHalogenAcceptors","addHalogenDonors","calculateContacts","contacts","spatialHash","contactStore","featureSet","createContacts","maxDistance","maxPiStackingDistSq","maxCationPiDistSq","atomStore","areAtomSetsWithinDist","atomSet1","atomSet2","maxDist","sn","sm","si","sj","v3","n1","n2","getNormal","atoms","normal","crossVectors","getOffset","projectOnPlane","ct","addChargedContacts","maxHbondDistSq","donor","acceptor","isWeak","connectedTo","donorAngles","idealDonorAngle","donorAngle","outOfPlane","acceptorAngles","idealAcceptorAngle","acceptorAngle","bondType","isWaterHydrogenBond","isBackboneHydrogenBond","addHydrogenBonds","m1","m2","addMetalComplexation","addHydrophobicContacts","halogen","halogenAngles","addHalogenBonds","frozenContacts","adjacencyList","contactSet","createFrozenContacts","ac1","ac2","aw","c1","c2","lineOfSightDist","lineOfSightDistFactorSq","as1","as2","vdw","distanceToSquared","refineLineOfSight","residueContactDict","handleResidueContact","minDist","minIndex","refineHydrophobicContacts","ionicInteractionDict","isHydrogenBondType","iil1","iil2","piStackingDict","pil1","pil2","refinePiStacking","refineMetalCoordination","contactTypeName","ContactDataDefaultParams","hydrogenBond","hydrophobic","halogenBond","ionicInteraction","metalCoordination","cationPi","piStacking","weakHydrogenBond","waterHydrogenBond","backboneHydrogenBond","filterSele","getContactData","filterSet","getAtomSet","setHex","contactColor","ContactPicker","getIndex","_applyTransformations","_getPosition","ShapePicker","primitive","objectFromShape","positionFromShape","AtomPicker","AxesPicker","BondPicker","bondStore","bp","center1","center2","addVectors","ClashPicker","validation","clashArray","_getAtomProxyFromSele","getAtomIndices","DistancePicker","IgnorePicker","MeshPicker","__position","SurfacePicker","UnitcellPicker","getCenter","VolumePicker","vol","dp","SlicePicker","getEdgeTable","getTriTable","MarchingCubes","field","nx","ny","nz","normalCache","vertexIndex","icount","mx","my","mz","allowedContours","isolevel","noNormals","contour","wrap","isNegativeIso","normalFactor","yd","zd","ilist","positionArray","normalArray","atomindexArray","edgeTable","triTable","VIntX","valp1","valp2","_q","mu","nc","q3","VIntY","q6","VIntZ","compNorm","polygonize","fx","fy","fz","edgeFilter","q1","qy","qz","q1y","q1z","qyz","q1yz","cubeindex","field0","field1","field2","field3","field4","field5","field6","field7","bits","fx2","fy2","fz2","e1","e2","e3","triIndex","triangulate","xBeg","yBeg","zBeg","xEnd","yEnd","zEnd","yOffset","zOffset","xBeg2","yBeg2","zBeg2","xEnd2","yEnd2","zEnd2","__break","__xBeg","__yBeg","__zBeg","__xEnd","__yEnd","__zEnd","_isolevel","_noNormals","_box","_contour","_wrap","vIndexLength","Matrix","cols","rows","copyTo","At","nrows","ncols","Ai","Ati","pAt","ad","atd","multiplyABt","Ap","pA","pB","Cp","mrows","bd","cd","multiply3x3","Cd","Ad","Bd","m10","m11","m12","m13","m14","m15","m16","m17","m18","m20","m21","m22","m23","m24","m25","m26","m27","m28","meanRows","mean","subRows","row","i0","i1","hypot","EPSILON","FLT_MIN","svd","at","_m","amt","wmt","vmt","astep","_W","Vt","vstep","eps","minval","iter","maxIter","Aj","Vi","Vj","t0","t1","sd","beta","gamma","seed","val0","asum","Float64Array","JacobiSVDImpl","m4new","m4set","n11","n12","n13","n14","n21","n22","n23","n24","n31","n32","n33","n34","n41","n42","n43","n44","m4multiply","a11","a12","a13","a14","a21","a22","a23","a24","a31","a32","a33","a34","a41","a42","a43","a44","b11","b12","b13","b14","b21","b22","b23","b24","b31","b32","b33","b34","b41","b42","b43","b44","m4makeScale","m4makeTranslation","m4makeRotationY","theta","m3new","m3makeNormal","m4","r0","r1","r2","laplacianSmooth","verts","numiter","inflate","nv","nf","norms","tps","vertdeg","jl","flagvert","ao","bo","co","vi3","vdi","wtvi","wt2vi","wt2","outwt","computeVertexNormals","nv3","ab","ci","getRadiusDict","radiusList","radiusDict","getSurfaceGrid","maxRadius","extraMargin","margin","dim","maxSize","pow","tmpSize","tran","mroty","mscale","mtrans","Surface","Geometry","fromGeometry","setFromArray","geo","getColor","colormaker","tc","getPicking","getFilteredIndex","filteredIndex","elementSize","include","getAtomindex","VolumeSurface","mc","getSurface","smooth","normalMatrix","volsurf","Volume","Matrix3","inverseMatrix","setData","setAtomindex","_position","_min","_max","_mean","_rms","setStats","rms","setMatrix","me","elements","ne","getBox","_getBox","__box","_makeSurface","getValueForSigma","getSurfaceWorker","workerPool","sigma","getSigmaForValue","getDataAtomindex","getDataPosition","getDataColor","getDataPicking","getDataSize","_sum","sumSq","di","arrayRms","header","getThreeSide","FrontSide","BackSide","DoubleSide","setObjectMatrix","matrixWorldNeedsUpdate","BufferDefaultParameters","opaqueBack","forceTransparent","BufferParameterTypes","updateShader","property","uniform","updateVisibility","parameterTypes","indexVersion","wireframeIndexVersion","isImpostor","isText","isPoint","isLine","dynamic","wireframeIndexCount","defaultParameters","UniformsUtils","merge","UniformsLib","common","emissive","lights","pickingUniforms","_positionDataSize","addAttributes","initIndex","makeWireframeGeometry","attributeSize","nindex","setUsage","DYNAMIC_DRAW","makeMaterial","vertexColors","derivatives","fragDepth","wm","pm","NoBlending","wireframeMaterial","pickingMaterial","makeWireframeIndex","wireframeIndex","wireframeGeometry","setDrawRange","checkEdge","drawRange","updateWireframeIndex","updateRange","getRenderOrder","renderOrder","_getMesh","materialName","frustumCulled","getVertexShader","getFragmentShader","NEAR_CLIP","RADIUS_CLIP","PICKING","NOLIGHT","FLAT_SHADED","OPAQUE_BACK","DIFFUSE_INTERIOR","USE_INTERIOR_COLOR","addUniforms","buf","updateRenderOrder","setRenderOrder","pt","pv","propertyData","uniformData","doShaderUpdate","doVisibilityUpdate","setProperties","setUniforms","setAttributes","attribute","wu","isVector3","toJSON","MeshBuffer","SurfaceBuffer","setVisibilityTrue","setVisibilityFalse","DoubleSidedBuffer","frontMeshes","backMeshes","frontBuffer","backBuffer","ContourBuffer","SurfaceRepresentation","isolevelType","negateIsolevel","isolevelScroll","boxSize","colorVolume","useWorker","boxCenter","__boxCenter","setBox","__isolevel","__smooth","__contour","__wrap","__boxSize","onSurfaceFinish","surfaceBuffer","dullInterior","surfaceData","MouseActions","trackballControls","focus","getFocus","sign","almostIdentity","setFocus","eachRepresentation","reprElem","comp","repr","pickingProxy","animationControls","tt","tooltip","mp","innerText","measurePick","measureClear","MouseActionPresets","default","zoomScroll","focusScroll","zoomFocusScroll","rotateDrag","panDrag","zRotateDrag","zoomDrag","zoomFocusDrag","panComponentDrag","rotateComponentDrag","movePick","tooltipPick","pymol","coot","astexviewer","triggerFromString","tokens","MouseControls","actionList","disabled","preset","triggerStr","wildcard","action","KeyActions","autoView","toggleRock","toggleSpin","KeyActionPresets","toggleAnimations","toggleAntialiasing","KeyControls","char","PickingBehavior","mouseControls","_onClick","_onHover","pickingControls","MouseBehavior","_onMove","_onScroll","_onDrag","_onDblclick","AnimationBehavior","_onTick","KeyBehavior","keyControls","outline","_focusDomElement","_onKeydown","_onKeyup","_onKeypress","pressedKey","KeyboardEvent","keyCode","Annotation","content","_viewerPosition","_updateViewerPosition","_canvasPosition","_cameraPosition","pointerEvents","whiteSpace","setContent","_update","matrixChanged","displayValue","padding","fontFamily","_clientRect","getVisibility","vp","cr","depth","zIndex","ComponentControls","RadiusFactoryTypes","covalent","bfactor","explicit","RadiusFactory","atomRadius","negateVector","PrincipalAxes","n3","pointsT","vm","van","vbn","vcn","va","vb","vc","begA","endA","begB","endB","begC","endC","vecA","vecB","vecC","normVecA","normVecB","normVecC","getBasisMatrix","makeBasis","determinant","getRotationQuaternion","inverse","getProjectedScaleForAtoms","d1a","d1b","d2a","d2b","d3a","d3b","ax1","ax2","ax3","dp1","dot","dt1","dp2","dt2","dp3","dt3","FilteredVolume","minValue","maxValue","outside","setFilter","_getFilterHash","DMEAN","ARMS","filterHash","_filterHash","_dataBuffer","_positionBuffer","_atomindexBuffer","filteredData","filteredPosition","filteredAtomindex","BondHash","al","BondStore","addBond","ai1","ai2","addBondIfConnected","AtomStore","setAltloc","getAltloc","code","ResidueStore","setSstruc","getSstruc","setInscode","getInscode","ChainStore","setChainname","getChainname","setChainid","chainid","getChainid","ModelStore","Helixorient","polymer","residueCount","getCenterIterator","cache","idx3","residueIndexStart","rp","getResidueProxy","traceAtomIndex","radiusFactory","diff","rise","twist","resdir","r12","r23","r34","diff13","diff24","vt","_axis","_prevAxis","_resdir","_center","a1","getAtomIndexByType","a3","a4","acos","diff13Length","diff24Length","resRadius","resTwist","resRise","resBending","resAxis","bending","Helixbundle","helixorient","getAxis","localAngle","centerDist","ssBorder","colorParams","radiusParams","beg","residueOffset","tmpAxis","tmpCenter","_beg","_end","rp1","rp2","BinaryHeap","scoreFunction","bubbleUp","sinkDown","peek","len","parentN","parent","elemScore","child1Score","child2Score","child2N","child1N","child1","child2","Kdtree","metric","maxDepth","currentNode","nodes","rootIndex","buildTree","arrBegin","arrEnd","plength","nodeIndex","arrMedian","currentDim","pivotIndex","pivotValue","storeIndex","getNodeDepth","parentIndex","nearest","maxNodes","bestNodes","nearestSearch","bestChild","otherChild","dimension","pointIndex","ownPoint","ownDistance","saveNode","leftIndex","rightIndex","linearPoint","linearDistance","verify","AtomProxy","chainStore","residueStore","residueMap","bondHash","entityList","entityIndex","chainIndex","residue","residueTypeId","atomType","occupancy","partialCharge","aromatic","_ap","hasBondTo","bap","hasBondToElement","backboneIndexList","moleculeType","isCg","backboneType","isTrace","atomRings","isNonmetal","isMetalloid","isDiatomicNonmetal","isPolyatomicNonmetal","isAlkaliMetal","isAlkalineEarthMetal","isNobleGas","isPostTransitionMetal","isLanthanide","isActinide","getDefaultValence","getValenceList","getOuterShellElectronCount","taa","aaa","distSquared","ta","aa","positionFromArray","positionToArray","positionFromVector3","positionSub","getResidueBonds","firstOnly","relativeIndex","bonds","getBonds","atomIndices1","atomIndices2","connectedAtomIndex","connectedAtomIndices","noResname","modelStore","toObject","euclideanDistSq","euclideanDist","pointArray","useSquaredDist","atomIndices","kdtree","_Kdtree","nodeList","resultList","SymOpCode","$","E","G","J","L","M","Q","R","Z","_","EncodedSymOp","reInteger","selectionFromChains","chainList","Assembly","partList","addPart","matrixList","part","AssemblyPart","getAtomCount","reduce","getResidueCount","getInstanceCount","instanceCount","isIdentity","structureChainList","eachChain","getBoundingBox","partBox","getSelection","_getCount","propertyName","instanceBox","structureBox","getView","getInstanceList","StructureBuilder","currentModelindex","currentChainid","currentResname","currentResno","currentInscode","currentHetero","previousResname","previousHetero","ri","mi","addResidueType","modelindex","addModel","addChain","addResidue","chainOffset","chainCount","finalize","assignSecondaryStructure","secStruct","chainnames","eachModel","chainnamesSorted","chainnamesIndex","helices","h1","h2","helix","helixRun","chainChange","sheets","s1","s2","strandCharCode","sheet","sheetRun","calculateSecondaryStructure","zhangSkolnickSS","distances","isHelical","eachPolymer","cgPolymer","proteinPolymer","prevSstruc","sstrucCount","ChainnameAlphabet","calculateChainnames","useExistingBonds","doAutoChainName","mIndex","rOffset","rCount","rStart","rEnd","chainData","eachResidueN","newChain","bbType1","bbType2","bbTypeUnk","backboneEndAtomIndex","backboneStartAtomIndex","fill","calculateBonds","calculateBondsWithin","calculateBondsBetween","BondOrderTable","getBondOrderFromTable","atomname1","atomname2","onlyAddRung","rungBondStore","rungAtomSet","atomBondMap","calculateAtomBondMap","bondedAtoms","Set","rai","bondOrders","nn","rai1","rai2","getBondIndex","rungEndAtomIndex","atomSetDict","rung","onlyAddBackbone","backboneBondStore","backboneAtomSet","needsBond","needsBackbone","backbone","buildUnitcellAssembly","uc","structureCenterFrac","cartToFrac","centerFrac","symopDict","encodedSymopList","matrixDict","symopList","symop","denominator","integer","getSymmetryOperations","centerFracSymop","positionFracSymop","getMatrixList","setFromMatrixPosition","fracToCart","unitcellAssembly","unitcellMatrixList","ncsMatrixList","biomolDict","NCS","ncsUnitcellMatrixList","nm","vec","supercellAssembly","supercellMatrixList","ncsSupercellMatrixList","UNITCELL","SUPERCELL","guessElement","atomName","assignResidueTypeBonds","bondDict","nextAtomOffset","AlkaliMetals","AlkalineEarthMetals","PolyatomicNonmetals","DiatomicNonmetals","NobleGases","PostTransitionMetals","Metalloids","Halogens","AtomType","no","AtomMap","dict","getHash","ResidueType","chemCompType","bondReferenceAtomIndices","getMoleculeType","getBackboneType","backboneEndType","backboneStartType","getBackboneIndexList","atomnames","atomnamesStart","atomnamesEnd","traceIndex","getAtomIndexByName","dir1Index","direction1AtomIndex","dir2Index","direction2AtomIndex","bbStartIndex","bbEndIndex","rungEndIndex","atomnameList","hasProteinBackbone","hasRnaBackbone","hasDnaBackbone","hasCgProteinBackbone","hasCgRnaBackbone","hasCgDnaBackbone","hasAtomWithName","hasBackboneAtoms","hasBackbone","end1","maxd","nearestAtoms","calculateResidueBonds","calculateRings","getBondGraph","bondGraph","calculateBondGraph","getAromatic","aromaticAtoms","calculateAromatic","aromaticRings","nb","capacity","visited","pred","RingFinderMaxDepth","currentColor","RingFinderState","findRings","aromaticRingFlags","AromaticRingElements","AromaticRingPlanarityThreshold","isRingAromatic","assignBondReferenceAtomIndices","refRing","rings1","rings2","ri1","ai3","_idx2","getBondReferenceAtomIndex","bondIndex","addRing","current","leftOffset","rightOffset","found","rn","ringOffset","from","head","ResidueMap","BondProxy","_v12","_v13","_ap1","_ap2","_ap3","getOtherAtomIndex","getReferenceAtomIndex","typeAtomIndex1","typeAtomIndex2","calculateShiftDir","ap3","v13","ResidueProxy","getChainProxy","getAtomType","getResname1","getAtomnameList","rNext","bbAtomEnd","bbAtomStart","getNextConnectedResidue","nextIndex","rpNext","rpFirst","getPreviousConnectedResidue","residueProxy","prevIndex","rpPrev","rpLast","Polymer","residueIndexEnd","rpStart","rpEnd","isPrevConnected","isNextConnected","isNextNextConnected","isCyclic","__residueProxy","aIndex","eachAtomN","rStartIndex","ChainProxy","getModelProxy","residueEnd","_rp","rNextIndex","first","ModelProxy","chainEnd","_cp","Structure","refreshed","title","extraData","atomSetCache","boxes","bondSet","finalizeAtoms","finalizeBonds","getBondSet","getBackboneBondSet","backboneBondSet","__backbone","getRungBondSet","rungBondSet","__rung","seleString","getAtomSetWithinSelection","getAtomSetWithinPoint","getAtomSetWithinVolume","fv","getMaxScaleOnAxis","getAtomSetWithinGroup","atomResidueIndex","getStructure","eachEntity","getEntityType","mn","cn","getAtomData","atomData","getBondData","multipleBond","isMulti","isOffset","bondScale","bondSpacing","bondData","storeBondOrder","radius2","absOffset","multiRadius","vShortening","vShift","getBackboneAtomData","getBackboneBondData","getRungAtomData","getRungBondData","getPrincipalAxes","atomCenter","hasCoords","_hasCoords","getSequence","seq","getChainnameCount","updatePosition","refresh","refreshPosition","tmpBox","Primitives","ShapeDefaultParameters","aspectRatio","labelParams","pointSize","sizeAttenuation","useTexture","Shape","meshCount","addMesh","meshBuffer","addSphere","objectToShape","addEllipsoid","addTorus","addCylinder","addCone","addArrow","addBox","addOctahedron","addTetrahedron","addText","addPoint","addWideline","addLabel","getBufferList","buffers","bufferFromShape","BufferRepresentation","GeometryBuffer","geoPosition","geoIndex","meshPosition","meshNormal","meshColor","meshIndex","updateNormals","geoNormal","positionCount","geoPositionCount","transformedGeoPosition","transformedGeoNormal","makeIndex","initNormals","makeTranslation","applyPositionTransform","getNormalMatrix","o3","SphereGeometryBufferDefaultParameters","SphereGeometryBuffer","IcosahedronBufferGeometry","_radius","MappedBuffer","mappingType","indexSize","mapping","mappingSize","mappingIndicesSize","nullValueAttributes","getAttributeIndex","dataIndex","makeMapping","mappingItemSize","aMapping","mappingIndices","it","MappedQuadBuffer","SphereImpostorBuffer","SphereBuffer","x0","y0","y1","PointBufferDefaultParameters","alphaTest","edgeBleach","PointBufferParameterTypes","PointBuffer","makeTexture","DataTexture","makePointTexture","USE_SIZEATTENUATION","USE_MAP","ALPHATEST","DotRepresentation","thresholdType","thresholdMin","thresholdMax","thresholdOut","dotType","radiusType","deviation","dotData","dotBuffer","quadIndices","quadUvs","ImageBufferDefaultParameters","ImageBufferParameterTypes","ImageBuffer","alwaysTransparent","hasWireframe","imageData","flipY","pickingTex","pickingMap","mapSize","startsWith","CUBIC_INTERPOLATION","endsWith","BSPLINE_FILTER","CATMULROM_FILTER","MITCHELL_FILTER","updateTexture","NormalBlending","VolumeSlice","positionType","getPositionFromCoordinate","coord","ms","setFromMatrixScale","vn","dimLen","z0","setVec","pickingArray","tMin","tMax","SliceRepresentation","linear","percent","coordinate","volumeSlice","sliceBuffer","logReprUnknown","ElementDefaultParameters","Element","statusChanged","setStatus","setName","RepresentationElementDefaultParameters","RepresentationElement","visibilityChanged","parametersChanged","setRepresentation","getType","_disposeRepresentation","hasRepresentation","removeRepresentation","toggleVisibility","setSelection","_v","ComponentDefaultParameters","Component","representationAdded","representationRemoved","reprList","annotationList","setRotation","Euler","setFromEuler","setScale","setTransform","getCenterUntransformed","makeScale","updateRepresentationMatrices","addAnnotation","annotation","eachAnnotation","removeAnnotation","removeAllAnnotations","_addRepresentation","hidden","impostor","workerDefault","ReprClass","makeRepresentation","addBufferRepresentation","removeAllRepresentations","getBoxUntransformed","getZoom","getZoomForBox","Collection","_remove","RepresentationCollection","TrajectoryElementDefaultParameters","defaultStep","defaultTimeout","defaultInterpolateType","defaultInterpolateStep","defaultMode","defaultDirection","initialFrame","TrajectoryElement","trajectory","frameChanged","playerChanged","player","setFrame","Frames","coordinates","times","timeOffset","deltaTime","Superposition","atoms1","atoms2","VH","coords1","coords2","coords1t","coords2t","transformationMatrix","prepCoords","_superpose","mean1","mean2","to","invA","t4","t5","t8","t9","t11","t13","t14","t15","t17","t18","t20","t21","t23","t26","invert3x3","md","mat3x3determinant","transformMat_","tmp_1","tmp_2","mult","M1","M2","is4X4","tCoords","det","_pB","mcols","invertTrasform","mat","n4","TrajectoryPlayerDefaultParameters","interpolateType","interpolateStep","TrajectoryPlayer","traj","startedRunning","haltedRunning","_run","_previousTime","_currentTime","_currentStep","frameCount","_currentFrame","_direction","_animate","isRunning","dt","inProgress","_nextInterpolated","hasFrame","ip","ipp","ippp","setFrameInterpolated","loadFrame","_next","currentFrame","play","setPlayer","frame","Trajectory","trajPath","frameCache","loadQueue","boxCache","pathCache","frameCacheSize","_frameCount","_disposed","centerPbc","removePbc","removePeriodicity","superpose","selectionIndices","_resetCache","_saveInitialCoords","setStructure","_loadFrameCount","backboneIndices","_getIndices","_makeAtomIndices","_saveStructureCoords","initialCoords","structureCoords","_makeSuperposeCoords","resetCache","_updateStructure","_interpolate","fc","cpp","cppp","j0","interpolateSpline","interpolateLerp","iList","_loadFrame","_doSuperpose","_process","_setFrameCount","box2","circMean","circularMean3","arrayMean3","getFrameTime","FramesTrajectory","StructureTrajectory","RemoteTrajectory","request","getFrameUrl","getFrameParams","setRequestHeader","arrayBuffer","getCountUrl","CallbackTrajectory","requestCallback","StructureView","seleList","parentSelection","ignoreView","blosum62x","prepareMatrix","cellNames","matDict","rowDict","SubstitutionMatrices","blosum62","Alignment","seq1","seq2","gapPenalty","gapExtensionPenalty","substMatrix","initMatrices","score","ali","gap","makeScoreFn","calc","gap0","scoreFn","Vi1","Si1","Hi","Si","ali1","ali2","_s1","_s2","_i","_j","aliIdx1","aliIdx2","_atoms1","_atoms2","StructureComponentDefaultParameters","defaultAssembly","StructureComponent","trajList","trajectoryAdded","trajectoryRemoved","defaultAssemblyChanged","initSelection","pickBuffer","pointer","item","createRingBuffer","pickDict","del","values","createSimpleDict","spacefillRepresentation","addRepresentation","distanceRepresentation","angleRepresentation","dihedralRepresentation","measureRepresentations","setDefaultAssembly","structureView","rebuildRepresentations","rebuildTrajectories","reprParams","trajComp","reprComp","measureUpdate","addTrajectory","trajSrc","makeTrajectory","removeTrajectory","getAtomRadius","pickCount","lastPick","atomList","atomListSorted","atomPair","atomTriple","atomQuad","measureBuild","measureData","dihedral","pickData","radiusData","removeAllMeasurements","pd","removeMeasurement","addMeasurement","SurfaceComponent","VolumeComponent","ComponentCollection","matchName","tmpZoomVector","StageDefaultParameters","mousePreset","ShapeComponent","__decorate","decorators","desc","getOwnPropertyDescriptor","Reflect","decorate","AtomindexColormaker","scalePerModel","BfactorColormaker","bfactorScale","ChainidColormaker","chainidDictPerModel","chainidDict","ChainindexColormaker","ChainnameColormaker","chainnameDictPerModel","chainnameDict","DensityfitColormaker","rsrzDict","rsccDict","rsrzScale","rsccScale","rsrz","rscc","partialCharges","CZ","CG","OD1","CB","OD2","OE1","OE2","CD2","CE1","ND1","NE2","NZ","SD","PTR","O1P","O2P","O3P","OG1","SEP","TPO","CD1","CE2","CE3","NE1","OH","ElectrostaticColormaker","hCharges","charges","hPositions","hPos","backboneNHPosition","bbox","hStore","buildStoreLike","hHash","ElementColors","UUT","UUP","UUH","ElementColormaker","EntityindexColormaker","entityindexScale","EntitytypeColormaker","entityType","GeoqualityColormaker","geoAtomDict","geoDict","geoProblemCount","geoAtom","atomProblems","HydrophobicityColormaker","resHF","defaultResidueHydrophobicity","hfScale","ModelindexColormaker","modelindexScale","MoleculetypeColormaker","OccupancyColormaker","occupancyScale","PartialchargeColormaker","partialchargeScale","randomColor","RandomColormaker","RandomcoilindexColormaker","rciDict","rciScale","rci","ResidueindexColormaker","scalePerChain","ResidueColors","ASX","GLX","DA","DG","DI","DX","DC","DT","DU","DD","ResnameColormaker","StructureColors","SstrucColormaker","StructuredataColormaker","_a","_b","UniformColormaker","valueColor","ValueColormaker","valueScale","VolumeColormaker","nxy","i1y","i1z","iyz","i1yz","vy","vz","v1y","v1z","vyz","v1yz","xd","c00","c01","c10","c11","c0","StructureRepresentation","radiusSize","radiusScale","assembly","biomolOptions","defaultScale","setRadius","getQuality","getAssembly","needsBuild","sview","createData","updateData","getRadiusParams","param","getAtomParams","getBondParams","MeasurementRepresentation","labelVisible","labelFontFamily","monospace","serif","labelFontStyle","italic","labelFontWeight","bold","labelsdf","labelXOffset","labelBackground","labelBackgroundColor","labelBackgroundMargin","labelBackgroundOpacity","labelFixedSize","labelFontstyle","textData","textBuffer","getLabelBufferParams","fontStyle","fontWeight","sdf","xOffset","attachment","showBorder","borderColor","borderWidth","showBackground","backgroundMargin","backgroundOpacity","fixedSize","parseNestedAtoms","nSets","order","selected","_break","Number","isInteger","calcArcPoint","edt","edt1d","MIN_SAFE_INTEGER","MAX_SAFE_INTEGER","TextAtlasCache","TextAtlasDefaultParams","font","variant","weight","TextAtlas","mapped","scratchW","scratchH","currentX","currentY","cutoff","lineHeight","maxWidth","fillStyle","textAlign","textBaseline","lineJoin","gridOuter","gridInner","canvas2","context2","placeholder","CanvasTexture","draw","measureText","clearRect","fillText","TextBufferDefaultParameters","fontSize","TextBufferParameterTypes","getCharCount","charCount","TextBuffer","fontTexture","inputTexCoord","inputSize","aPosition","aColor","txt","iChar","nChar","iCharAll","textAtlas","getTextAtlas","inputMapping","xadvance","xShift","yShift","texWidth","texHeight","texCoords","FIXED_SIZE","WideLineBufferDefaultParameters","WideLineBufferParameterTypes","WideLineBuffer","AngleRepresentation","vectorVisible","sectorVisible","atomPosition","okay","outPosition","outIdx","validatePositions","atomTriplePositions","angleData","labelPosition","labelText","vectorPosition1","vectorPosition2","arcPositionTmp1","arcPositionTmp2","sectorPositionTmp","totalSegments","v21","v23","cross2","labelTmp","arcPoint","crossLength","toFixed","nSegments","sectorVertices","arcVertices1","arcVertices2","appendArcSection","arcSize","sectorSize","arcPosition1","arcPosition2","sectorPosition","sectorOffset","arcOffset","getAngleData","vectorBuffer","arcLength","arcBuffer","sectorLength","sectorBuffer","vectorData","arcData","sectorData","eye","CylinderGeometryBufferDefaultParameters","getGeo","makeRotationX","CylinderBufferGeometry","CylinderGeometryBuffer","geoLength","__center","_color","_from","_to","meshData","MappedAlignedBoxBuffer","CylinderImpostorBufferDefaultParameters","CylinderImpostorBufferParameterTypes","CylinderImpostorBuffer","CAP","CylinderBuffer","AxesRepresentation","showAxes","showBox","getAxesData","pa","en","vertexPosition","vertexColor","vertexRadius","edgePosition1","edgePosition2","edgeColor","edgeRadius","addAxis","offset2","addCorner","d3","addScaledVector","edgeOffset","addEdge","edge","axesData","sphereBuffer","cylinderBuffer","sphereData","cylinderData","BallAndStickRepresentation","lineOnly","cylinderOnly","symmetric","lineBuffer","lineData","BackboneRepresentation","BaseRepresentation","Interpolator","vec1","vec2","vDir","vTan","vNorm","vBin","interpolateToArr","interpolateToVec","interpolatePosition","interpolateTangent","vectorSubdivide","interpolationFn","iterator","getTangent","interpolateNormalDir","u0","u1","u2","u3","norm","bin","interpolateNormal","getNormalDir","iterDir1","iterDir2","vSub1","vSub2","vSub3","vSub4","d1v1","d1v2","d1v3","d1v4","d2v1","d2v2","d2v3","d2v4","interpolateColor","item1","item2","colFn","interpolatePicking","pickFn","interpolateSize","sizeFn","Spline","directional","positionIterator","subdiv","smoothSheet","interpolator","getAtomIterator","cache2","apPrev","apNext","getSubdividedColor","nCol","getSubdividedPicking","getSubdividedPosition","getSubdividedOrientation","normals","getNormals","tangent","binormal","getSubdividedSize","nSize","nPos","nTan","nNorm","vTangent","vMeshNormal","TubeMeshBufferDefaultParameters","capped","TubeMeshBuffer","capVertices","capTriangles","xi","size2","meshPrimitiveId","normX","normY","normZ","biX","biY","biZ","posX","posY","posZ","cxArr","cyArr","cx1Arr","cy1Arr","cx2Arr","cy2Arr","cx1","cy1","cx2","cy2","radialSegments1","irs","irs1","strip","CartoonRepresentation","NaN","getSplineParams","getSpline","getAspectRatio","polymerList","subPos","subOri","subCol","subPick","subSize","ContactRepresentation","angstrom","dataParams","contactData","unit","getLabelData","DihedralRepresentation","extendLine","lineVisible","dihedralData","lineTmp1","lineTmp2","sectorTmp","planeTmp","totalLines","totalPlanes","p4","v34","inPlane1","inPlane2","improperStart","improperEnd","nLines","nPlanes","line1","line2","sector","plane","li","nSuccess","linePosition1","linePosition2","planePosition","lineOffset","planeOffset","lp1","lp2","pp","getDihedralData","lineLength","lineColor","planeLength","planeBuffer","planeData","createUpdatedObject","updateSource","hasKey","obj","createColorArray","arrayLength","targetArray","DihedralHistogramRepresentation","histogramsData","histogramBinBorderVisible","scaleBinToSectorArea","histogramBinBorderColor","adjacentBondArrowColor","distantBondArrowColor","frontHistogramColor","backHistogramColor","opaqueMiddleDiscColor","histogramOpacity","opaqueMiddleDiscVisible","opaqueMiddleDiscOpacity","histogramBinBorderWidth","histogramBinBorderOpacity","bondArrowVisible","bondArrowWidth","bondArrowOpacity","specificColorData","getHistogramBinBorderBufferParameters","getBondArrowsBufferParameters","getOpaqueMiddleDiscBufferParameters","getHistogramBufferParameters","atomPositions","scaleData","Float32Concat","arrays","lengths","accumulatedOffset","createWideLineBuffer","linesList","startPoints","endPoints","startColors","endColors","createMeshBuffer","triangleColors","histogram360Scaled","histogram360","dihedralDataArray","currentHistogramData","calculateDihedralHistogram","frontHistogramBinBordersBuffer","frontHistogramBinBorders","backHistogramBinBordersBuffer","backHistogramBinBorders","adjacentBondArrowsBuffer","adjacentBondArrows","distantBondArrowsBuffer","distantBondArrows","opaqueMiddleDiscBuffer","opaqueMiddleDisc","frontHistogramBuffer","frontHistogram","backHistogramBuffer","backHistogram","histogramData","positionOfDihedralAtoms","histogram","totalSectorTrianglesInOpaqueMiddleDisc","frontAndBack","v32","cross1","dihedralAtomVectors","absAngle","maxHist","histBinAngleStep","setHistogramBinCoordinates","ind","zeroDegreeVector","crossVector","startOffset","scalingFactor","setOneSideHistogram","discHistogram","binBorders","sectionIndex","opaqueCircleSectorAngleStep","DistanceRepresentation","useCylinder","getDistanceData","pair","distanceData","bondParams","distanceBuffer","VectorBufferDefaultParameters","VectorBuffer","HelixorientRepresentation","LicoriceRepresentation","MappedBoxBuffer","HyperballStickImpostorBufferDefaultParameters","shrink","HyperballStickImpostorBufferParameterTypes","HyperballStickImpostorBuffer","HyperballStickBuffer","calculateMinArray","HyperballRepresentation","stickData","LabelFactory","errorLogged","atomLabel","aa1","sprintf","res","qualified","LabelRepresentation","labelType","labelFormat","labelGrouping","getTextData","labelFactory","positionN","sizeN","colorN","getLoneAtomSet","LineRepresentation","crosses","lone","all","crossSize","_crossData","crossData","attrSize","cPosition1","cPosition2","cColor","cColor2","cOffset","cimax","crossBuffer","bufferIdx","lineAttributes","crossAttributes","makeGrid","DataCtor","elemSize","EDTSurface","coordList","probeRadius","pLength","pWidth","pHeight","ptran","depty","widxz","cutRadius","setAtomID","vpBits","vpDistance","vpAtomID","btype","_probeRadius","_scaleFactor","_cutoff","_setAtomID","boundingatom","INOUT","ISDONE","ISBOUND","txz","tdept","sradius","tradius","widxzR","deptyName","indx","fillatom","ox","oy","oz","mj","mk","sk","ii","jj","kk","deptyAtNind","deptyAt","nind","pWH","ci2","fillvoxels","fillAtomWaals","fastdistancemap","boundPoint","cutRSq","totalsurfacevox","inarray","positin","outarray","positout","fastoneshell","cutoffSq","tx","ty","tz","square","nbj","tnvix","tnviy","tnviz","getVolume","tk","buildboundary","fillvoxelswaals","stype","marchingcubeinit","vd","makeAVHash","atomsX","atomsY","atomsZ","atomsR","nAtoms","hashFunc","minW","iDim","jDim","kDim","nCells","jkDim","preHash","cid","cellOffsets","cellLengths","maxCellLength","subArray","cellLength","neighbourListLength","withinRadii","rExtra","nearI","nearJ","nearK","loI","loJ","loK","hiI","hiJ","hiK","iOffset","jOffset","cellStart","cellEnd","rSum","AVSurface","probePositions","gridx","gridy","gridz","sinTable","cosTable","lastClip","atob","ngTorus","_probePositions","rExt","surfGrid","fillGridDim","initializeGrid","initializeAngleTables","obscured","singleAtomObscures","ra2","projectPoints","ar","ar2","ng","iax","iay","iaz","minx","miny","minz","maxx","maxy","maxz","xoffset","dxy2","xyoffset","spx","spy","spz","dd","projectTorus","dmp","normalToLine","rInt","cost","sint","px","py","pz","ia","projectTorii","fixNegatives","fixAtomIDs","MolecularSurface","_getAtomData","MolecularSurfaceRepresentation","surfaceType","vws","sas","ses","av","__infoList","__forceNewMolsurf","prepareData","molsurf","sviewFilter","bbSize","maxDim","asWithin","getSurfaceParams","__sele","__surfaceParams","after","contourBuffer","doubleSidedBuffer","PointRepresentation","pointData","RibbonBuffer","aNormal","aSize","aDir","aPrimitiveId","currSize","prevSize","RibbonRepresentation","RocketRepresentation","axisList","helixbundleList","helixbundle","axisData","RopeRepresentation","SpacefillRepresentation","TraceBuffer","linePosition","TraceRepresentation","TubeRepresentation","UnitcellRepresentation","defaultRadius","cbrt","getUnitcellData","unitcellData","ValidationRepresentation","clashData","getClashData","ConeBufferDefaultParameters","ConeBuffer","ConeBufferGeometry","_position1","_position2","GeometryGroup","geometryList","empty","ArrowBufferDefaultParameters","ArrowBuffer","splitPosition","cylinderRadius","makeAttributes","coneBuffer","vFrom","vTo","vSplit","fullLength","coneLength","BoxBuffer","BoxBufferGeometry","_heightAxis","_depthAxis","_size","EllipsoidBufferDefaultParameters","EllipsoidBuffer","_majorAxis","_minorAxis","OctahedronBuffer","OctahedronBufferGeometry","TetrahedronBuffer","TetrahedronBufferGeometry","TorusBufferDefaultParameters","radiusRatio","tubularSegments","TorusBuffer","TorusBufferGeometry","Parser","_beforeParse","_parse","_afterParse","StructureParser","structureBuilder","Entity","description","chainIndexList","entityTypeFromString","entityFromType","isNonPolymer","isMacrolide","DefaultBoxParams","Unitcell","alphaRad","betaRad","gammaRad","cosAlpha","cosBeta","cosGamma","sinBeta","sinGamma","cStar","cosAlphaStar","cornerOffset","divideScalar","centerArray3","HelixTypes","dAminoAcids","entityKeyList","reWhitespace","getModresId","PdbParser","hex","isLegacy","headerLine","headerId","legacyId","isPqr","isPdbqt","sb","serialRadix","resnoRadix","currentCoord","doFrames","currentBiomol","currentPart","currentMatrix","line","recordName","startChain","startResi","startIcode","endChain","endResi","endIcode","serialDict","unitcellDict","entityDataList","currentEntityData","currentEntityKey","hetnameDict","modresDict","chainDict","chainIdx","currentChainname","seqresDict","currentSeqresChainname","modelIdx","pendingStart","ls","modresId","fromIdx","toIdx","helixType","seqresChainname","keyEnd","biomt","biomtElms","ncsName","ncs","ncsRow","ncsElms","origx","orgix","origxRow","origxElms","scaleRow","scaleElms","aLength","bLength","cLength","sGroup","_parseChunkOfLines","ei","residueDict","reQuotedWhitespace","reDoubleQuote","reTrimQuotes","reAtomSymbol","trimQuotes","ensureArray","hasValue","cifDefaults","getBondOrder","valueOrder","CifParser","rawline","authAsymId","authSeqId","labelSeqId","labelAtomId","labelCompId","labelAsymId","labelEntityId","labelAltId","groupPDB","typeSymbol","pdbxPDBmodelNum","pdbxPDBinsCode","CartnX","CartnY","CartnZ","bIsoOrEquiv","cif","asymIdDict","chainIndexDict","pendingString","currentString","pendingValue","pendingLoop","pendingName","loopPointers","currentLoopIndex","currentCategory","currentName","pointerNames","modelNum","keyParts","category","keyValuePair","_modelNum","frameOffset","occ","assignedChainname","entityId","chem_comp","chem_comp_atom","struct","cc","cca","ccb","chem_comp_bond","atomnameDict","comp_id","atom_id","type_symbol","model_Cartn_x","model_Cartn_y","model_Cartn_z","pdbx_component_comp_id","pdbx_residue_numbering","pdbx_model_Cartn_x_ideal","pdbx_model_Cartn_y_ideal","pdbx_model_Cartn_z_ideal","atom_id_1","atom_id_2","value_order","parseChemComp","atom_site_type_symbol","atom_site_label","atom_site_fract_x","cell_length_a","cell_length_b","cell_length_c","cell_angle_alpha","cell_angle_beta","cell_angle_gamma","typeSymbolMap","atom_site_fract_y","atom_site_fract_z","atom_site_occupancy","ml","identityMatrix","covalentI","parseCore","begIcode","sc","struct_conf","pdbx_PDB_helix_class","beg_auth_seq_id","pdbx_beg_PDB_ins_code","pdbx_end_PDB_ins_code","beg_label_asym_id","end_label_asym_id","end_auth_seq_id","ssr","struct_sheet_range","processSecondaryStructure","operDict","pdbx_struct_oper_list","biomolOp","elms","pdbx_struct_assembly_gen","gen","getMatrixDict","expr","es","assembly_id","oe","oper_expression","md1","md2","k1","k2","asym_id_list","struct_ncs_oper","ncsOp","ncsPart","cell","length_a","length_b","length_c","angle_alpha","angle_beta","angle_gamma","symmetry","database_PDB_matrix","origxMat","atom_sites","scaleMat","processSymmetry","struct_conn","atomIndicesCache","connTypeId","conn_type_id","ptnr1_symmetry","ptnr2_symmetry","inscode1","pdbx_ptnr1_PDB_ins_code","altloc1","pdbx_ptnr1_label_alt_id","ptnr1_auth_seq_id","ptnr1_label_asym_id","ptnr1_label_atom_id","selection1","inscode2","pdbx_ptnr2_PDB_ins_code","altloc2","pdbx_ptnr2_label_alt_id","ptnr2_auth_seq_id","ptnr2_label_asym_id","ptnr2_label_atom_id","selection2","tmpA","tmpB","pdbx_value_order","processConnections","pdbx_description","processEntities","entry","pdbx_audit_revision_history","revision_date","dates","releaseDate","pdbx_database_status","recvd_initial_deposition_date","depDates","depositionDate","database_PDB_rev","date","date_original","reflns","d_resolution_high","refine","ls_d_res_high","ls_R_factor_R_free","rFree","ls_R_factor_R_work","rWork","exptl","method","experimentalMethods","firstLines","lpos","ypos","zpos","modelLineCount","lineNo","AllFields","ctor","typedArray","getDataView","getInt8View","getInt32View","decodeInt16","output","i2","decodeInt32","i4","decodeInteger","intArray","divisor","invDiv","decodeRun","dataOffset","decodeDelta","decodePacking","int16or8","upperLimit","lowerLimit","decodeIntegerPacking","decodeIntegerDeltaPacking","unpacked","decodeIntegerDelta","decodeMsgpack","dataView","performDecoding","dvOut","dvIn","decodeFloat32","decodeIntegerRun","decodeMmtf","inputDict","ignoreFields","outputDict","dv","ignore","SstrucMap","groupData","numBonds","numAtoms","numGroups","numChains","numModels","chainsPerModel","structureId","groupsPerChain","groupList","groupTypeList","atomNameList","frameAtomOffset","xCoordList","yCoordList","zCoordList","bAtomIndex1","bAtomIndex2","bBondOrder","aGroupIndex","aFormalCharge","gChainIndex","gAtomOffset","gAtomCount","cModelIndex","cGroupOffset","cGroupCount","mChainOffset","mChainCount","modelChainCount","groupOffset","chainGroupCount","bondOffset","groupAtomCount","groupFormalChargeList","formalChargeList","groupBondAtomList","bondAtomList","groupBondOrderList","bondOrderList","atomIdList","bFactorList","altLocList","occupancyList","groupIdList","secStructList","insCodeList","chainNameList","chainIdList","groupTypeDict","groupType","elementList","hetFlag","numGroupBonds","groupName","resAtomOffset","secStructLength","bioAssemblyList","_assembly","chainToPart","transformList","_transform","ncsOperatorList","ncsAssembly","_operator","unitCell","spaceGroup","bondTypes","am","du","un","moleculeLineNo","modelAtomIdxStart","currentRecordType","reItem","SdfParser","headerLines","sdfData","mItem","atomStart","bondStart","bondEnd","currentItem","currentData","isV3000","isAtomBlock","isBondBlock","acc","atomindexToStoreindex","chgTok","find","chargeCount","coffset","atomIdx","cToken","_postProcess","parseIntSubstr","PrmtopParser","pointersDict","pointers","atomNames","radii","residueLabels","residuePointers","curIdx","bondIdx","lt","NATOM","NBONH","MBONA","NRES","curResIdx","curResname","curResno","reTitle","lastSegid","segid","reField","molecules","moleculetypeDict","currentMoleculetype","fieldMatch","cIdx","molName","molCount","molType","lastResno","resIdx","chainidIdx","chainnameIdx","TrajectoryParser","notNetcdf","statement","reason","TypeError","readName","nameLength","nextPos","intView","ef","isCharmm","extraBlock","fourDims","NSET","ISTART","NSAVC","NAMNF","DELTA","titleLength","titlePos","TITLE","natom","natom4","BYTE","CHAR","SHORT","INT","DOUBLE","num2str","num2bytes","str2num","readNumber","bufferReader","numbers","readType","trimNull","ZERO","NC_DIMENSION","NC_VARIABLE","NC_ATTRIBUTE","version","recordDimension","dimList","dimensions","recordId","dimensionSize","dimensionsList","globalAttributes","attributesList","variables","varList","recordStep","variableSize","dimensionality","dimensionsIds","varSize","record","variablesList","gAttList","gAtt","NetcdfReader","hasDataVariable","variableName","findIndex","getDataVariable","variable","currentOffset","nonRecord","NctrajParser","netcdfReader","versionSize","virSize","presSize","coordSize","velocitySize","forceSize","natoms","floatSize","natoms3","frameCoords","MagicInts","sizeOfInt","num","numOfBits","_tmpBytes","sizeOfInts","numOfInts","sizes","numOfBytes","bytecnt","decodeBits","cbuf","buf2","mask","lastBB0","lastBB1","cnt","_tmpIntBytes","decodeInts","nums","minMaxInt","sizeint","bitsizeint","sizesmall","thiscoord","prevcoord","lfp","lsize","bitsize","smallidx","tmpIdx","smaller","smallnum","adz","invPrecision","buf8","isSmaller","tmpSwap","VolumeParser","getMatrix","reScientificNotation","bohrToAngstromFactor","CubeParser","originX","originY","originZ","NVX","NVY","NVZ","basisX","basisY","basisZ","oribitalFlag","lj","Dsn6Parser","summand","byteView","brixStr","xStart","yStart","zStart","xExtent","yExtent","zExtent","xRate","yRate","zRate","xlen","ylen","zlen","xBlocks","yBlocks","zBlocks","zz","yy","xx","nxyz","mapcrs","DxParser","headerInfo","parseHeaderLines","dataLineStart","headerByteCount","deltaLineCount","xmin","ymin","zmin","hx","hy","hz","uint8ToLines","MrcParser","floatView","MAP","MACHST","NX","NY","MODE","NXSTART","NYSTART","NZSTART","MX","MY","MZ","MAPC","MAPR","MAPS","DMIN","DMAX","ISPG","NSYMBT","LSKFLG","b1","b0","parseNumberLine","XplorParser","infoStart","dataStart","gridInfo","AMIN","AMAX","BMIN","BMAX","NC","CMIN","CMAX","cellInfo","lineSection","RAVE","RSIGMA","hsvToRgb","ColorDict","red","orange","gold","yellow","lime","green","sea","cyan","sky","blue","purple","magenta","hotpink","pink","peach","lilac","pinktint","peachtint","yellowtint","greentint","bluetint","lilactint","white","gray","brown","deadwhite","deadblack","invisible","reWhitespaceComma","reCurlyWhitespace","reTrimCurly","reCollapseEqual","parseListDef","defaultColor","master","lm","listName","listColor","listMasters","listWidth","parseListElm","lineBreak","triangleBreak","lsindex","literal","isLineBreak","isTriangleBreak","parseStr","parseFlag","parseGroup","flags","groupFlags","groupMasters","kinemage","onewidth","pdbfile","texts","captions","caption","groupDict","subgroupDict","masterDict","pointmasterDict","dotLists","vectorLists","ballLists","ribbonLists","currentGroupMasters","currentSubgroupMasters","dotDefaultColor","dotLabel","dotPosition","dotColor","vecDefaultColor","vecDefaultWidth","vecLabel1","vecLabel2","vecPosition1","vecPosition2","vecColor1","vecColor2","ballRadius","ballDefaultColor","ballLabel","ballPosition","ballColor","ribbonListDefaultColor","ribbonPointLabelArray","ribbonPointPositionArray","ribbonPointBreakArray","ribbonPointColorArray","isDotList","prevDotLabel","isVectorList","prevVecLabel","prevVecPosition","prevVecColor","isBallList","prevBallLabel","isRibbonList","prevRibbonPointLabel","isCaption","masterArray","labelArray","colorArray","indent","label1Array","label2Array","position1Array","position2Array","color1Array","color2Array","radiusArray","breakArray","splitLine","singlePointLine","dominant","convertedLists","listObject","convertedRibbonObject","editedLabels","editedPositions","editedColors","editedBreaks","breakPointer","positionPointer","removePointBreaksTriangleArrays","ribbonObject","convertedLabels","convertedBreaks","convertedPositions","convertedColors","vector3Positions","convertKinTriangleArrays","SurfaceParser","getLoader","OBJLoader","regexp","vertex_pattern","normal_pattern","uv_pattern","face_vertex","face_vertex_uv","face_vertex_uv_normal","face_vertex_normal","object_pattern","smoothing_pattern","material_library_pattern","material_use_pattern","setPath","_createParserState","objects","startObject","fromDeclaration","parseVertexIndex","parseNormalIndex","addVertex","addVertexLine","addNormal","addFace","nd","vLen","ib","ic","nLen","addLineGeometry","vi","lineFirstChar","lineSecondChar","trimLeft","lineParts","lineVertices","lineUVs","llen","parts","buffergeometry","PLYLoader","propertyNameMapping","setPropertyNameMapping","bin2str","isASCII","parseHeader","parseASCII","parseBinary","headerText","headerLength","currentElement","lineType","lineValues","propertValues","comments","countType","itemType","parseASCIINumber","parseASCIIElement","currentElementCount","useColor","handleElement","postProcess","colors","elementsNeedUpdate","elementName","setRGB","vertexIndices","vertex_indices","Face3","binaryRead","dataview","binaryReadElement","loc","table","reDelimiter","msgpack","netcdf","TextParser","reStrip","reTag","reContent","reAttr","parseXml","declaration","root","tag","eos","is","child","re","prefix","XmlParser","useDomParser","__xmlParser","__domParser","DOMParser","parseFromString","Document","getNamedItem","getSele","useAltcode","icode","altcode","getResSele","setBitDict","bit","hasAttrValue","getProblemCount","clashDict","ga","clashes","getElementsByTagName","Validation","atomDict","clashSele","fromXml","entries","chemicalShiftLists","randomCoilIndices","rcia","_clashDict","clashList","seleAttr","createAttribute","setNamedItem","atomSele","res1","res2","mogBondOutliers","mogAngleOutliers","vPos1","vPos2","getAtomSele","dHalf","shrinkBuf","arraySet","dest","src_offs","dest_offs","adler32","adler","crcTable","makeTable","crc32","crc","BAD$1","TYPE$1","inflate_fast","strm","_in","last","_out","dmax","wsize","whave","wnext","s_window","lcode","dcode","lmask","dmask","here","op","from_source","next_in","avail_in","next_out","avail_out","lencode","distcode","lenbits","distbits","dolen","dodist","sane","MAXBITS","ENOUGH_LENS$1","ENOUGH_DISTS$1","CODES$1","LENS$1","DISTS$1","lbase","lext","dbase","dext","inflate_table","lens","lens_index","codes","table_index","work","incr","here_bits","here_op","here_val","curr","drop","used","huff","base_index","offs","extra","extra_index","LENS","DISTS","Z_OK","Z_STREAM_ERROR","HEAD","TYPE","BAD","ENOUGH_LENS","ENOUGH_DISTS","zswap32","InflateState","havedict","check","total","wbits","ncode","nlen","ndist","have","lendyn","distdyn","was","inflateReset","total_in","total_out","inflateResetKeep","inflateInit2","windowBits","inflateReset2","lenfix","distfix","virgin","fixedtables","updatewindow","flush","put","last_bits","last_op","last_val","hbuf","inf_leave","xflags","os","extra_len","hcrc","data_type","inflateSetDictionary","dictionary","dictLength","STR_APPLY_OK","STR_APPLY_UIA_OK","__","_utf8len","string2buf","m_pos","str_len","buf_len","buf2string","c_len","utf16buf","_buf2binstring","utf8border","Z_OK$1","messages","ZStream","GZheader","Inflate","sources","source","raw","err","ended","_mode","next_out_utf8","tail","utf8str","allowBufError","binstring2buf","onEnd","onData","inflateEnd","flattenChunks","decompressedData","inflator","ungzip","Datasource","mmtfBaseUrl","mmtfFullUrl","mmtfReducedUrl","pdbid","baseUrl","suffixUrl","PassThroughDatasource","suffixURL","uniprotid","reProtocol","IntegerParam","NumberParam","RangeParam","SelectParam","UIStageParameters","getListing","jsonData","frameIndex","getPathUrl","renumberSerial","remarks","_records","_writeRecords","_writeTitle","_writeRemarks","_writeAtoms","im","chargeSign","hasModels","formatString","getString","idString","titleString","countsString","chargeLines","pairs","nCharges","formatAtom","formatBond","_writeHeader","_writeCTab","_writeFooter","fullscreenChanged","componentAdded","componentRemoved","compList","defaultFileParams","logList","pickingBehavior","mouseBehavior","animationBehavior","keyBehavior","spinAnimation","rockAnimation","setQuality","setImpostor","defaultFileRepresentation","BU1","sizeScore","backboneOnly","loadFile","promise","addComponentFromObject","defaultRepresentation","errorMsg","loadScript","script","addComponent","CompClass","removeComponent","removeAllComponents","toggleFullscreen","fullscreenEnabled","mozFullScreenEnabled","webkitFullscreenEnabled","msFullscreenEnabled","getFullscreenElement","fullscreenElement","mozFullScreenElement","webkitFullscreenElement","msFullscreenElement","resizeElement","lastFullscreenElement","dataset","normalWidth","normalHeight","exitFullscreen","msExitFullscreen","mozCancelFullScreen","webkitExitFullscreen","screen","requestFullscreen","msRequestFullscreen","mozRequestFullScreen","webkitRequestFullscreen","setSpin","setRock","pclamp","minSize","aspectFactor","catch","impostorTypes","eachComponent","getComponentsByName","getRepresentationsByName","relativePath","pn","pathname","basePath","getAbsolutePath","vectorNorm1","vectorNorm2","vectorNorm3","structures","atomIndexDict","modelCount","flatten","wait","previous","later","leading","Date","clearTimeout","trailing"],"mappings":"4sBAQM,SAAUA,EAAUC,GACxB,GAAsB,oBAAXC,OAAwB,OAEnC,MACMC,EADI,IAAIC,OAAO,GAAGH,eACZI,KAAKH,OAAOI,SAASC,QAEjC,OAAIJ,EACKK,mBAAmBL,EAAE,SAE5B,CAEJ,CAcgB,SAAAM,EAAUC,EAAYC,GACpC,YAAiBC,IAAVF,EAAsBA,EAAQC,CACvC,CAEgB,SAAAE,EAAiBC,EAAgCC,GAC/D,MAAMC,EAASC,OAAOC,OAAO,CAAE,EAAEJ,GACjC,IAAK,MAAMK,KAAKJ,EAAe,MAEfH,IADAE,EAAOK,KACIH,EAAEG,GAAKJ,EAAcI,GAC/C,CACD,OAAOH,CACT,CAEgB,SAAAI,EAAiBN,EAAWO,GAC1C,IAAK,MAAMF,KAAKE,EAAW,CACzB,MAAMX,EAAQW,EAAUF,QACVP,IAAVF,IAAqBI,EAAOK,GAAKT,EACtC,CACD,OAAOI,CACT,UAsBgBQ,IACd,MAAMC,EAAWrB,OAAOI,SAASiB,SACjC,OAAyC,OAAlCA,EAASC,MAAM,eAA0B,QAAUD,CAC5D,UAEgBE,IACd,GAAsB,oBAAXvB,OAAwB,OAAO,EAE1C,MAAMwB,EAAKxB,OAAOyB,UAAUC,UAE5B,MAAI,YAAYC,KAAKH,GACZ,QACE,UAAUG,KAAKH,GACjB,SACE,WAAWG,KAAKH,GAClB,UACE,wBAAwBG,KAAKH,GAC/B,gBACE,QAAQG,KAAKH,GACf,sBACE,UAAUG,KAAKH,IACjB,QAIX,CAqEA,SAASI,EAASC,GACD7B,OAAO8B,KAAKD,EAAK,YAE9B7B,OAAOI,SAAS2B,KAAOF,EAE3B,UAEgBG,EAAUC,EAAmBC,EAAe,YAG1D,IAAKD,EAAM,OAEX,MA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G,CAEb,IADAmuF,EAAKv+I,EAAOu+I,GACHR,GACH31H,EAAM+2H,KAAM,CACd1B,EAAK/tI,IAAM,gCACX0Y,EAAMznD,KAAO28K,GACb,MAAMn9I,CACP,CA0BH,GAFAunE,EAAO,EACP82E,EAAcP,EACA,IAAVD,GAEF,GADAt2E,GAAQo2E,EAAQS,EACZA,EAAKttF,EAAK,CACZA,GAAOstF,EACP,GACElqB,EAAOupB,KAAUK,EAASv2E,aACjB62E,GACX72E,EAAOk2E,EAAO59I,EACdw+I,EAAcnqB,CACf,OAEE,GAAI2pB,EAAQO,GAGf,GAFA72E,GAAQo2E,EAAQE,EAAQO,GACxBA,GAAMP,GACG/sF,EAAK,CACZA,GAAOstF,EACP,GACElqB,EAAOupB,KAAUK,EAASv2E,aACjB62E,GAEX,GADA72E,EAAO,EACHs2E,EAAQ/sF,EAAK,CAEfA,GADAstF,EAAKP,EAEL,GACE3pB,EAAOupB,KAAUK,EAASv2E,aACjB62E,GACX72E,EAAOk2E,EAAO59I,EACdw+I,EAAcnqB,CACf,CACF,OAID,GADA3sD,GAAQs2E,EAAQO,EACZA,EAAKttF,EAAK,CACZA,GAAOstF,EACP,GACElqB,EAAOupB,KAAUK,EAASv2E,aACjB62E,GACX72E,EAAOk2E,EAAO59I,EACdw+I,EAAcnqB,CACf,CAEH,KAAOpjE,EAAM,GACXojE,EAAOupB,KAAUY,EAAY92E,KAC7B2sD,EAAOupB,KAAUY,EAAY92E,KAC7B2sD,EAAOupB,KAAUY,EAAY92E,KAC7BzW,GAAO,EAELA,IACFojE,EAAOupB,KAAUY,EAAY92E,KACzBzW,EAAM,IACRojE,EAAOupB,KAAUY,EAAY92E,MAGlC,KACI,CACHA,EAAOk2E,EAAO59I,EACd,GACEq0H,EAAOupB,KAAUvpB,EAAO3sD,KACxB2sD,EAAOupB,KAAUvpB,EAAO3sD,KACxB2sD,EAAOupB,KAAUvpB,EAAO3sD,KACxBzW,GAAO,QACAA,EAAM,GACXA,IACFojE,EAAOup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yB,EAAMwqK,KAAKxqK,MACVqqK,IAAgC,IAApBz3I,EAAQ23I,UAAmBF,EAAWrqK,GACvD,IAAIm7B,EAAYivI,GAAQpqK,EAAMqqK,GAe9B,OAdAtrK,EAAUjkB,KACVwzC,EAAOxtB,UACHq6B,GAAa,GAAKA,EAAYivI,GAC5B34I,IACFg5I,aAAah5I,GACbA,EAAU,MAEZ44I,EAAWrqK,EACXzqB,EAASqY,EAAKtV,MAAMymB,EAASuvB,GACxBmD,IAAS1yB,EAAUuvB,EAAO,OACrBmD,IAAgC,IAArBmB,EAAQ83I,WAC7Bj5I,EAAU1tB,WAAWumK,EAAOnvI,IAGvB5lD,CACT,CACF"} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index d3fb9add..8de86698 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "ngl", - "version": "2.2.0", + "version": "2.2.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "ngl", - "version": "2.2.0", + "version": "2.2.1", "license": "MIT", "dependencies": { "chroma-js": "^1.3.7", diff --git a/package.json b/package.json index 09a8d156..2a8b248f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ngl", - "version": "2.2.0", + "version": "2.2.1", "description": "Scalable molecular graphics for the web", "main": "dist/ngl.umd.js", "module": "dist/ngl.esm.js",